From b855240b782395f94315f43ea3e7e182299fac48 Mon Sep 17 00:00:00 2001 From: Matthew Vogt Date: Thu, 16 Feb 2012 14:43:03 +1000 Subject: Rename QDeclarative symbols to QQuick and QQml Symbols beginning with QDeclarative are already exported by the quick1 module. Users can apply the bin/rename-qtdeclarative-symbols.sh script to modify client code using the previous names of the renamed symbols. Task-number: QTBUG-23737 Change-Id: Ifaa482663767634931e8711a8e9bf6e404859e66 Reviewed-by: Martin Jones --- bin/rename-qtdeclarative-symbols.sh | 639 ++ doc/src/localstorage/localstorage.qdoc | 2 +- doc/src/qml/basictypes.qdoc | 2 +- doc/src/qml/c++models.qdoc | 10 +- doc/src/qml/codingconventions.qdoc | 20 +- doc/src/qml/debugging.qdoc | 10 +- doc/src/qml/dynamicobjects.qdoc | 32 +- doc/src/qml/extending-tutorial.qdoc | 30 +- doc/src/qml/integrating.qdoc | 18 +- doc/src/qml/javascriptblocks.qdoc | 40 +- doc/src/qml/modules.qdoc | 44 +- doc/src/qml/network.qdoc | 10 +- doc/src/qml/propertybinding.qdoc | 54 +- doc/src/qml/qmlcomponents.qdoc | 40 +- doc/src/qml/qmldocument.qdoc | 10 +- doc/src/qml/qmlengine.qdoc | 136 +- doc/src/qml/qmlevents.qdoc | 16 +- doc/src/qml/qmlintro.qdoc | 2 +- doc/src/qml/qmlplugins.qdoc | 12 +- doc/src/qml/qmlruntime.qdoc | 38 +- doc/src/qml/qmlsyntax.qdoc | 2 +- doc/src/qml/qmltypes.qdoc | 10 +- doc/src/qml/qmlviewer.qdoc | 2 +- doc/src/qml/qtbinding.qdoc | 166 +- doc/src/qml/qtdeclarative.qdoc | 48 +- doc/src/qml/qtprogrammers.qdoc | 14 +- doc/src/qtquick2/animation.qdoc | 28 +- doc/src/qtquick2/focus.qdoc | 22 +- doc/src/qtquick2/modelview.qdoc | 30 +- doc/src/qtquick2/mouseevents.qdoc | 6 +- doc/src/qtquick2/positioners.qdoc | 8 +- doc/src/qtquick2/qmltexthandling.qdoc | 4 +- doc/src/qtquick2/qtquick-intro.qdoc | 10 +- doc/src/qtquick2/qtquick2.qdoc | 2 +- doc/src/qtquick2/righttoleft.qdoc | 12 +- doc/src/qtquick2/states.qdoc | 6 +- doc/src/qtquick2/writingcomponents.qdoc | 34 +- doc/src/snippets/declarative/Button.qml | 67 - .../snippets/declarative/SelfDestroyingRect.qml | 60 - doc/src/snippets/declarative/Sprite.qml | 45 - doc/src/snippets/declarative/anchoranimation.qml | 66 - doc/src/snippets/declarative/anchorchanges.qml | 68 - doc/src/snippets/declarative/animatedimage.qml | 61 - doc/src/snippets/declarative/animation.qml | 226 - doc/src/snippets/declarative/application.qml | 53 - doc/src/snippets/declarative/behavior.qml | 58 - .../declarative/borderimage/borderimage-scaled.qml | 81 - .../declarative/borderimage/borderimage-tiled.qml | 81 - .../declarative/borderimage/normal-image.qml | 77 - .../codingconventions/dotproperties.qml | 68 - .../codingconventions/javascript-imports.qml | 47 - .../declarative/codingconventions/javascript.qml | 73 - .../declarative/codingconventions/lists.qml | 62 - .../declarative/codingconventions/myscript.js | 12 - .../declarative/codingconventions/photo.qml | 85 - .../declarative/codingconventions/private.qml | 49 - doc/src/snippets/declarative/coloranimation.qml | 51 - doc/src/snippets/declarative/colors.qml | 125 - .../declarative/column/column-transitions.qml | 58 - doc/src/snippets/declarative/column/column.qml | 67 - .../declarative/column/vertical-positioner.qml | 51 - doc/src/snippets/declarative/comments.qml | 53 - doc/src/snippets/declarative/component.qml | 59 - doc/src/snippets/declarative/componentCreation.js | 45 - .../declarative/createComponent-simple.qml | 57 - doc/src/snippets/declarative/createComponent.qml | 51 - doc/src/snippets/declarative/createQmlObject.qml | 61 - doc/src/snippets/declarative/drag.qml | 75 - .../declarative/dynamicObjects-destroy.qml | 55 - doc/src/snippets/declarative/events.qml | 141 - doc/src/snippets/declarative/flickable.qml | 50 - .../snippets/declarative/flickableScrollbar.qml | 66 - doc/src/snippets/declarative/flipable/flipable.qml | 78 - doc/src/snippets/declarative/flow.qml | 64 - .../declarative/focus/MyClickableWidget.qml | 69 - doc/src/snippets/declarative/focus/MyWidget.qml | 58 - .../snippets/declarative/focus/advancedFocus.qml | 67 - doc/src/snippets/declarative/focus/basicwidget.qml | 59 - .../snippets/declarative/focus/clickablewidget.qml | 61 - .../declarative/focus/myfocusscopewidget.qml | 68 - doc/src/snippets/declarative/focus/rectangle.qml | 62 - doc/src/snippets/declarative/focus/widget.qml | 61 - doc/src/snippets/declarative/folderlistmodel.qml | 61 - doc/src/snippets/declarative/gradient.qml | 52 - doc/src/snippets/declarative/grid-spacing.qml | 60 - doc/src/snippets/declarative/grid/grid-items.qml | 58 - .../snippets/declarative/grid/grid-no-spacing.qml | 57 - doc/src/snippets/declarative/grid/grid-spacing.qml | 60 - doc/src/snippets/declarative/grid/grid.qml | 53 - .../snippets/declarative/gridview/ContactModel.qml | 63 - doc/src/snippets/declarative/gridview/gridview.qml | 163 - doc/src/snippets/declarative/image.qml | 47 - doc/src/snippets/declarative/imports/chart.qml | 46 - .../declarative/imports/installed-module.qml | 47 - .../declarative/imports/merged-named-imports.qml | 47 - .../snippets/declarative/imports/named-imports.qml | 61 - .../declarative/imports/network-imports.qml | 47 - .../snippets/declarative/imports/qtquick-1.0.qml | 46 - .../snippets/declarative/imports/timeexample.qml | 46 - .../integrating-javascript/connectjs.qml | 57 - .../integrating-javascript/includejs/app.qml | 56 - .../integrating-javascript/includejs/factorial.js | 49 - .../integrating-javascript/includejs/script.js | 48 - .../scarceresources/avatarExample.cpp | 124 - .../scarceresources/avatarExample.h | 73 - .../scarceresources/exampleFive.qml | 54 - .../scarceresources/exampleFour.js | 56 - .../scarceresources/exampleFour.qml | 56 - .../scarceresources/exampleOne.qml | 54 - .../scarceresources/exampleThree.js | 58 - .../scarceresources/exampleThree.qml | 49 - .../scarceresources/exampleTwo.qml | 51 - .../declarative/integrating-javascript/script.js | 47 - doc/src/snippets/declarative/keynavigation.qml | 84 - doc/src/snippets/declarative/keys/keys-handler.qml | 60 - doc/src/snippets/declarative/keys/keys-pressed.qml | 65 - doc/src/snippets/declarative/layoutmirroring.qml | 71 - doc/src/snippets/declarative/listmodel-modify.qml | 96 - doc/src/snippets/declarative/listmodel-nested.qml | 102 - doc/src/snippets/declarative/listmodel-simple.qml | 79 - doc/src/snippets/declarative/listmodel.qml | 59 - .../snippets/declarative/listview-decorations.qml | 111 - doc/src/snippets/declarative/listview-sections.qml | 101 - doc/src/snippets/declarative/listview.qml | 87 - .../snippets/declarative/listview/ContactModel.qml | 58 - .../declarative/listview/listview-snippet.qml | 52 - doc/src/snippets/declarative/listview/listview.qml | 149 - doc/src/snippets/declarative/loader/KeyReader.qml | 53 - doc/src/snippets/declarative/loader/MyItem.qml | 55 - .../snippets/declarative/loader/connections.qml | 57 - doc/src/snippets/declarative/loader/focus.qml | 62 - doc/src/snippets/declarative/loader/simple.qml | 54 - doc/src/snippets/declarative/loader/sizeitem.qml | 62 - doc/src/snippets/declarative/loader/sizeloader.qml | 62 - .../declarative/models/views-models-delegates.qml | 79 - .../declarative/models/visual-model-and-view.qml | 58 - .../declarative/mousearea/mousearea-snippet.qml | 98 - .../snippets/declarative/mousearea/mousearea.qml | 117 - .../declarative/mousearea/mouseareadragfilter.qml | 72 - .../multipointtoucharea/multipointtoucharea.qml | 67 - doc/src/snippets/declarative/numberanimation.qml | 51 - doc/src/snippets/declarative/parallelanimation.qml | 56 - doc/src/snippets/declarative/parentanimation.qml | 73 - doc/src/snippets/declarative/parentchange.qml | 67 - doc/src/snippets/declarative/path/arcdirection.qml | 51 - doc/src/snippets/declarative/path/arcradius.qml | 63 - doc/src/snippets/declarative/path/basicarc.qml | 52 - doc/src/snippets/declarative/path/basiccurve.qml | 63 - doc/src/snippets/declarative/path/largearc.qml | 51 - doc/src/snippets/declarative/pathinterpolator.qml | 74 - .../snippets/declarative/pathview/ContactModel.qml | 58 - .../declarative/pathview/pathattributes.qml | 79 - doc/src/snippets/declarative/pathview/pathview.qml | 80 - doc/src/snippets/declarative/properties.qml | 315 - .../declarative/propertyaction-sequential.qml | 72 - doc/src/snippets/declarative/propertyaction.qml | 83 - doc/src/snippets/declarative/propertyanimation.qml | 100 - doc/src/snippets/declarative/propertychanges.qml | 91 - .../qml-data-models/dynamic-listmodel.qml | 67 - .../declarative/qml-data-models/listelements.qml | 77 - .../qml-data-models/listmodel-listview.qml | 64 - .../declarative/qml-documents/inline-component.qml | 57 - .../qml-documents/inline-text-component.qml | 55 - .../declarative/qml-documents/non-trivial.qml | 62 - .../declarative/qml-documents/qmldocuments.qml | 66 - .../declarative/qml-intro/images/qt-logo.svg | 104 - .../qtbinding/context-advanced/MyItem.qml | 46 - .../qtbinding/context-advanced/applicationdata.h | 52 - .../qtbinding/context-advanced/connections.qml | 52 - .../qtbinding/context-advanced/main.cpp | 60 - .../declarative/qtbinding/context/MyItem.qml | 45 - .../declarative/qtbinding/context/main.cpp | 56 - .../declarative/qtbinding/enums/imageviewer.h | 68 - .../declarative/qtbinding/enums/standalone.qml | 64 - .../declarative/qtbinding/functions-cpp/MyItem.qml | 55 - .../declarative/qtbinding/functions-cpp/main.cpp | 59 - .../declarative/qtbinding/functions-cpp/myclass.h | 57 - .../declarative/qtbinding/functions-qml/MyItem.qml | 50 - .../declarative/qtbinding/functions-qml/main.cpp | 63 - .../declarative/qtbinding/loading/MyItem.qml | 56 - .../declarative/qtbinding/loading/main.cpp | 90 - .../qtbinding/newelements/imageviewer.h | 56 - .../declarative/qtbinding/newelements/main.cpp | 62 - .../qtbinding/newelements/standalone.qml | 44 - .../qtbinding/properties-cpp/MyItem.qml | 54 - .../qtbinding/properties-cpp/applicationdata.h | 71 - .../qtbinding/properties-qml/MyItem.qml | 47 - .../declarative/qtbinding/properties-qml/main.cpp | 61 - .../declarative/qtbinding/resources/example.qrc | 10 - .../declarative/qtbinding/resources/main.cpp | 57 - .../declarative/qtbinding/resources/main.qml | 46 - .../declarative/qtbinding/resources/resources.pro | 4 - .../declarative/qtbinding/signals-cpp/MyItem.qml | 50 - .../qtbinding/signals-cpp/imageviewer.h | 64 - .../declarative/qtbinding/signals-cpp/main.cpp | 81 - .../qtbinding/signals-cpp/standalone.qml | 48 - .../declarative/qtbinding/signals-qml/MyItem.qml | 55 - .../declarative/qtbinding/signals-qml/main.cpp | 59 - .../declarative/qtbinding/signals-qml/myclass.h | 51 - .../qtbinding/variantlistmap/MyItem.qml | 54 - .../declarative/qtbinding/variantlistmap/main.cpp | 67 - doc/src/snippets/declarative/qtobject.qml | 54 - .../declarative/rectangle/rect-border-width.qml | 59 - .../declarative/rectangle/rectangle-colors.qml | 62 - .../declarative/rectangle/rectangle-gradient.qml | 74 - .../snippets/declarative/rectangle/rectangle.qml | 52 - .../declarative/repeaters/repeater-grid-index.qml | 61 - .../snippets/declarative/repeaters/repeater.qml | 89 - .../declarative/reusablecomponents/Button.qml | 87 - .../declarative/reusablecomponents/application.qml | 58 - .../declarative/reusablecomponents/component.qml | 77 - .../declarative/reusablecomponents/focusbutton.qml | 98 - .../snippets/declarative/reusablecomponents/qmldir | 4 - doc/src/snippets/declarative/righttoleft.qml | 149 - doc/src/snippets/declarative/righttoleft/Child.qml | 51 - doc/src/snippets/declarative/rotation.qml | 69 - doc/src/snippets/declarative/rotationanimation.qml | 66 - doc/src/snippets/declarative/row.qml | 62 - doc/src/snippets/declarative/row/row.qml | 50 - doc/src/snippets/declarative/script.js | 4 - .../snippets/declarative/sequentialanimation.qml | 56 - doc/src/snippets/declarative/smoothedanimation.qml | 69 - doc/src/snippets/declarative/springanimation.qml | 65 - doc/src/snippets/declarative/state-when.qml | 54 - doc/src/snippets/declarative/state.qml | 61 - doc/src/snippets/declarative/states.qml | 121 - .../declarative/states/statechangescript.qml | 63 - doc/src/snippets/declarative/systempalette.qml | 54 - .../snippets/declarative/text/onLinkActivated.qml | 54 - doc/src/snippets/declarative/texthandling.qml | 89 - .../declarative/transition-from-to-modified.qml | 60 - .../snippets/declarative/transition-from-to.qml | 59 - .../snippets/declarative/transition-reversible.qml | 66 - doc/src/snippets/declarative/transition.qml | 63 - doc/src/snippets/declarative/transitions-list.qml | 89 - .../viewtransitions/viewtransitions-basic.qml | 70 - .../viewtransitions-delayedbyindex.qml | 78 - .../viewtransitions-intermediatemove.qml | 90 - .../viewtransitions-interruptedgood.qml | 74 - .../viewtransitions/viewtransitions-pathanim.qml | 105 - .../viewtransitions-scriptactionbad.qml | 81 - .../viewtransitions-scriptactiongood.qml | 84 - doc/src/snippets/declarative/visualdatagroup.qml | 81 - doc/src/snippets/declarative/visualdatamodel.qml | 64 - .../declarative/visualdatamodel_rootindex/main.cpp | 62 - .../declarative/visualdatamodel_rootindex/view.qml | 65 - doc/src/snippets/declarative/workerscript.qml | 64 - doc/src/snippets/declarative/xmlrole.qml | 81 - doc/src/snippets/declarative/xmlrole.xml | 14 - doc/src/snippets/qml/Button.qml | 67 + doc/src/snippets/qml/SelfDestroyingRect.qml | 60 + doc/src/snippets/qml/Sprite.qml | 45 + doc/src/snippets/qml/anchoranimation.qml | 66 + doc/src/snippets/qml/anchorchanges.qml | 68 + doc/src/snippets/qml/animatedimage.qml | 61 + doc/src/snippets/qml/animation.qml | 226 + doc/src/snippets/qml/application.qml | 53 + doc/src/snippets/qml/behavior.qml | 58 + .../qml/borderimage/borderimage-scaled.qml | 81 + .../snippets/qml/borderimage/borderimage-tiled.qml | 81 + doc/src/snippets/qml/borderimage/normal-image.qml | 77 + .../qml/codingconventions/dotproperties.qml | 68 + .../qml/codingconventions/javascript-imports.qml | 47 + .../snippets/qml/codingconventions/javascript.qml | 73 + doc/src/snippets/qml/codingconventions/lists.qml | 62 + doc/src/snippets/qml/codingconventions/myscript.js | 12 + doc/src/snippets/qml/codingconventions/photo.qml | 85 + doc/src/snippets/qml/codingconventions/private.qml | 49 + doc/src/snippets/qml/coloranimation.qml | 51 + doc/src/snippets/qml/colors.qml | 125 + doc/src/snippets/qml/column/column-transitions.qml | 58 + doc/src/snippets/qml/column/column.qml | 67 + .../snippets/qml/column/vertical-positioner.qml | 51 + doc/src/snippets/qml/comments.qml | 53 + doc/src/snippets/qml/component.qml | 59 + doc/src/snippets/qml/componentCreation.js | 45 + doc/src/snippets/qml/createComponent-simple.qml | 57 + doc/src/snippets/qml/createComponent.qml | 51 + doc/src/snippets/qml/createQmlObject.qml | 61 + doc/src/snippets/qml/drag.qml | 75 + doc/src/snippets/qml/dynamicObjects-destroy.qml | 55 + doc/src/snippets/qml/events.qml | 141 + doc/src/snippets/qml/flickable.qml | 50 + doc/src/snippets/qml/flickableScrollbar.qml | 66 + doc/src/snippets/qml/flipable/flipable.qml | 78 + doc/src/snippets/qml/flow.qml | 64 + doc/src/snippets/qml/focus/MyClickableWidget.qml | 69 + doc/src/snippets/qml/focus/MyWidget.qml | 58 + doc/src/snippets/qml/focus/advancedFocus.qml | 67 + doc/src/snippets/qml/focus/basicwidget.qml | 59 + doc/src/snippets/qml/focus/clickablewidget.qml | 61 + doc/src/snippets/qml/focus/myfocusscopewidget.qml | 68 + doc/src/snippets/qml/focus/rectangle.qml | 62 + doc/src/snippets/qml/focus/widget.qml | 61 + doc/src/snippets/qml/folderlistmodel.qml | 61 + doc/src/snippets/qml/gradient.qml | 52 + doc/src/snippets/qml/grid-spacing.qml | 60 + doc/src/snippets/qml/grid/grid-items.qml | 58 + doc/src/snippets/qml/grid/grid-no-spacing.qml | 57 + doc/src/snippets/qml/grid/grid-spacing.qml | 60 + doc/src/snippets/qml/grid/grid.qml | 53 + doc/src/snippets/qml/gridview/ContactModel.qml | 63 + doc/src/snippets/qml/gridview/gridview.qml | 163 + doc/src/snippets/qml/image.qml | 47 + doc/src/snippets/qml/imports/chart.qml | 46 + doc/src/snippets/qml/imports/installed-module.qml | 47 + .../snippets/qml/imports/merged-named-imports.qml | 47 + doc/src/snippets/qml/imports/named-imports.qml | 61 + doc/src/snippets/qml/imports/network-imports.qml | 47 + doc/src/snippets/qml/imports/qtquick-1.0.qml | 46 + doc/src/snippets/qml/imports/timeexample.qml | 46 + .../qml/integrating-javascript/connectjs.qml | 57 + .../qml/integrating-javascript/includejs/app.qml | 56 + .../integrating-javascript/includejs/factorial.js | 49 + .../qml/integrating-javascript/includejs/script.js | 48 + .../scarceresources/avatarExample.cpp | 124 + .../scarceresources/avatarExample.h | 73 + .../scarceresources/exampleFive.qml | 54 + .../scarceresources/exampleFour.js | 56 + .../scarceresources/exampleFour.qml | 56 + .../scarceresources/exampleOne.qml | 54 + .../scarceresources/exampleThree.js | 58 + .../scarceresources/exampleThree.qml | 49 + .../scarceresources/exampleTwo.qml | 51 + .../snippets/qml/integrating-javascript/script.js | 47 + doc/src/snippets/qml/keynavigation.qml | 84 + doc/src/snippets/qml/keys/keys-handler.qml | 60 + doc/src/snippets/qml/keys/keys-pressed.qml | 65 + doc/src/snippets/qml/layoutmirroring.qml | 71 + doc/src/snippets/qml/listmodel-modify.qml | 96 + doc/src/snippets/qml/listmodel-nested.qml | 102 + doc/src/snippets/qml/listmodel-simple.qml | 79 + doc/src/snippets/qml/listmodel.qml | 59 + doc/src/snippets/qml/listview-decorations.qml | 111 + doc/src/snippets/qml/listview-sections.qml | 101 + doc/src/snippets/qml/listview.qml | 87 + doc/src/snippets/qml/listview/ContactModel.qml | 58 + doc/src/snippets/qml/listview/listview-snippet.qml | 52 + doc/src/snippets/qml/listview/listview.qml | 149 + doc/src/snippets/qml/loader/KeyReader.qml | 53 + doc/src/snippets/qml/loader/MyItem.qml | 55 + doc/src/snippets/qml/loader/connections.qml | 57 + doc/src/snippets/qml/loader/focus.qml | 62 + doc/src/snippets/qml/loader/simple.qml | 54 + doc/src/snippets/qml/loader/sizeitem.qml | 62 + doc/src/snippets/qml/loader/sizeloader.qml | 62 + .../snippets/qml/models/views-models-delegates.qml | 79 + .../snippets/qml/models/visual-model-and-view.qml | 58 + .../snippets/qml/mousearea/mousearea-snippet.qml | 98 + doc/src/snippets/qml/mousearea/mousearea.qml | 117 + .../snippets/qml/mousearea/mouseareadragfilter.qml | 72 + .../multipointtoucharea/multipointtoucharea.qml | 67 + doc/src/snippets/qml/numberanimation.qml | 51 + doc/src/snippets/qml/parallelanimation.qml | 56 + doc/src/snippets/qml/parentanimation.qml | 73 + doc/src/snippets/qml/parentchange.qml | 67 + doc/src/snippets/qml/path/arcdirection.qml | 51 + doc/src/snippets/qml/path/arcradius.qml | 63 + doc/src/snippets/qml/path/basicarc.qml | 52 + doc/src/snippets/qml/path/basiccurve.qml | 63 + doc/src/snippets/qml/path/largearc.qml | 51 + doc/src/snippets/qml/pathinterpolator.qml | 74 + doc/src/snippets/qml/pathview/ContactModel.qml | 58 + doc/src/snippets/qml/pathview/pathattributes.qml | 79 + doc/src/snippets/qml/pathview/pathview.qml | 80 + doc/src/snippets/qml/properties.qml | 315 + doc/src/snippets/qml/propertyaction-sequential.qml | 72 + doc/src/snippets/qml/propertyaction.qml | 83 + doc/src/snippets/qml/propertyanimation.qml | 100 + doc/src/snippets/qml/propertychanges.qml | 91 + .../qml/qml-data-models/dynamic-listmodel.qml | 67 + .../snippets/qml/qml-data-models/listelements.qml | 77 + .../qml/qml-data-models/listmodel-listview.qml | 64 + .../qml/qml-documents/inline-component.qml | 57 + .../qml/qml-documents/inline-text-component.qml | 55 + doc/src/snippets/qml/qml-documents/non-trivial.qml | 62 + .../snippets/qml/qml-documents/qmldocuments.qml | 66 + doc/src/snippets/qml/qml-intro/images/qt-logo.svg | 104 + .../qml/qtbinding/context-advanced/MyItem.qml | 46 + .../qtbinding/context-advanced/applicationdata.h | 52 + .../qml/qtbinding/context-advanced/connections.qml | 52 + .../qml/qtbinding/context-advanced/main.cpp | 60 + doc/src/snippets/qml/qtbinding/context/MyItem.qml | 45 + doc/src/snippets/qml/qtbinding/context/main.cpp | 56 + doc/src/snippets/qml/qtbinding/enums/imageviewer.h | 68 + .../snippets/qml/qtbinding/enums/standalone.qml | 64 + .../qml/qtbinding/functions-cpp/MyItem.qml | 55 + .../snippets/qml/qtbinding/functions-cpp/main.cpp | 59 + .../snippets/qml/qtbinding/functions-cpp/myclass.h | 57 + .../qml/qtbinding/functions-qml/MyItem.qml | 50 + .../snippets/qml/qtbinding/functions-qml/main.cpp | 63 + doc/src/snippets/qml/qtbinding/loading/MyItem.qml | 56 + doc/src/snippets/qml/qtbinding/loading/main.cpp | 90 + .../qml/qtbinding/newelements/imageviewer.h | 56 + .../snippets/qml/qtbinding/newelements/main.cpp | 62 + .../qml/qtbinding/newelements/standalone.qml | 44 + .../qml/qtbinding/properties-cpp/MyItem.qml | 54 + .../qml/qtbinding/properties-cpp/applicationdata.h | 71 + .../qml/qtbinding/properties-qml/MyItem.qml | 47 + .../snippets/qml/qtbinding/properties-qml/main.cpp | 61 + .../snippets/qml/qtbinding/resources/example.qrc | 10 + doc/src/snippets/qml/qtbinding/resources/main.cpp | 57 + doc/src/snippets/qml/qtbinding/resources/main.qml | 46 + .../snippets/qml/qtbinding/resources/resources.pro | 4 + .../snippets/qml/qtbinding/signals-cpp/MyItem.qml | 50 + .../qml/qtbinding/signals-cpp/imageviewer.h | 64 + .../snippets/qml/qtbinding/signals-cpp/main.cpp | 81 + .../qml/qtbinding/signals-cpp/standalone.qml | 48 + .../snippets/qml/qtbinding/signals-qml/MyItem.qml | 55 + .../snippets/qml/qtbinding/signals-qml/main.cpp | 59 + .../snippets/qml/qtbinding/signals-qml/myclass.h | 51 + .../qml/qtbinding/variantlistmap/MyItem.qml | 54 + .../snippets/qml/qtbinding/variantlistmap/main.cpp | 67 + doc/src/snippets/qml/qtobject.qml | 54 + .../snippets/qml/rectangle/rect-border-width.qml | 59 + .../snippets/qml/rectangle/rectangle-colors.qml | 62 + .../snippets/qml/rectangle/rectangle-gradient.qml | 74 + doc/src/snippets/qml/rectangle/rectangle.qml | 52 + .../snippets/qml/repeaters/repeater-grid-index.qml | 61 + doc/src/snippets/qml/repeaters/repeater.qml | 89 + doc/src/snippets/qml/reusablecomponents/Button.qml | 87 + .../qml/reusablecomponents/application.qml | 58 + .../snippets/qml/reusablecomponents/component.qml | 77 + .../qml/reusablecomponents/focusbutton.qml | 98 + doc/src/snippets/qml/reusablecomponents/qmldir | 4 + doc/src/snippets/qml/righttoleft.qml | 149 + doc/src/snippets/qml/righttoleft/Child.qml | 51 + doc/src/snippets/qml/rotation.qml | 69 + doc/src/snippets/qml/rotationanimation.qml | 66 + doc/src/snippets/qml/row.qml | 62 + doc/src/snippets/qml/row/row.qml | 50 + doc/src/snippets/qml/script.js | 4 + doc/src/snippets/qml/sequentialanimation.qml | 56 + doc/src/snippets/qml/smoothedanimation.qml | 69 + doc/src/snippets/qml/springanimation.qml | 65 + doc/src/snippets/qml/state-when.qml | 54 + doc/src/snippets/qml/state.qml | 61 + doc/src/snippets/qml/states.qml | 121 + doc/src/snippets/qml/states/statechangescript.qml | 63 + doc/src/snippets/qml/systempalette.qml | 54 + doc/src/snippets/qml/text/onLinkActivated.qml | 54 + doc/src/snippets/qml/texthandling.qml | 89 + .../snippets/qml/transition-from-to-modified.qml | 60 + doc/src/snippets/qml/transition-from-to.qml | 59 + doc/src/snippets/qml/transition-reversible.qml | 66 + doc/src/snippets/qml/transition.qml | 63 + doc/src/snippets/qml/transitions-list.qml | 89 + .../qml/viewtransitions/viewtransitions-basic.qml | 70 + .../viewtransitions-delayedbyindex.qml | 78 + .../viewtransitions-intermediatemove.qml | 90 + .../viewtransitions-interruptedgood.qml | 74 + .../viewtransitions/viewtransitions-pathanim.qml | 105 + .../viewtransitions-scriptactionbad.qml | 81 + .../viewtransitions-scriptactiongood.qml | 84 + doc/src/snippets/qml/visualdatagroup.qml | 81 + doc/src/snippets/qml/visualdatamodel.qml | 64 + .../qml/visualdatamodel_rootindex/main.cpp | 62 + .../qml/visualdatamodel_rootindex/view.qml | 65 + doc/src/snippets/qml/workerscript.qml | 64 + doc/src/snippets/qml/xmlrole.qml | 81 + doc/src/snippets/qml/xmlrole.xml | 14 + doc/src/snippets/qtjavascript/evaluation/main.cpp | 2 +- .../qtjavascript/registeringobjects/main.cpp | 2 +- .../qtjavascript/registeringvalues/main.cpp | 2 +- doc/src/whatsnew.qdoc | 4 +- examples/declarative/README | 13 - .../declarative/accessibility/accessibility.qml | 105 - .../declarative/accessibility/widgets/Button.qml | 79 - examples/declarative/animation/animation.qml | 62 - .../declarative/animation/animation.qmlproject | 16 - .../animation/basics/color-animation.qml | 121 - .../animation/basics/images/face-smile.png | Bin 15408 -> 0 bytes .../declarative/animation/basics/images/moon.png | Bin 2433 -> 0 bytes .../declarative/animation/basics/images/shadow.png | Bin 425 -> 0 bytes .../declarative/animation/basics/images/star.png | Bin 349 -> 0 bytes .../declarative/animation/basics/images/sun.png | Bin 8153 -> 0 bytes .../animation/basics/property-animation.qml | 105 - .../declarative/animation/behaviors/SideRect.qml | 62 - .../animation/behaviors/behavior-example.qml | 118 - .../declarative/animation/behaviors/wigglytext.qml | 108 - .../animation/easing/content/QuitButton.qml | 52 - .../declarative/animation/easing/content/quit.png | Bin 583 -> 0 bytes examples/declarative/animation/easing/easing.qml | 170 - .../animation/pathanimation/pathanimation.qml | 108 - .../pathinterpolator/pathinterpolator.qml | 115 - examples/declarative/animation/states/qt-logo.png | Bin 5149 -> 0 bytes examples/declarative/animation/states/states.qml | 101 - .../declarative/animation/states/transitions.qml | 130 - examples/declarative/calculator/calculator.qml | 163 - examples/declarative/calculator/content/Button.qml | 84 - .../declarative/calculator/content/Display.qml | 68 - .../declarative/calculator/content/calculator.js | 91 - .../calculator/content/images/button-.png | Bin 1288 -> 0 bytes .../calculator/content/images/button-blue.png | Bin 1565 -> 0 bytes .../calculator/content/images/button-green.png | Bin 1543 -> 0 bytes .../calculator/content/images/button-purple.png | Bin 1566 -> 0 bytes .../calculator/content/images/button-red.png | Bin 1586 -> 0 bytes .../calculator/content/images/display.png | Bin 998 -> 0 bytes examples/declarative/calculator/content/qmldir | 2 - .../declarative/canvas/bezierCurve/bezierCurve.qml | 124 - examples/declarative/canvas/clip/clip.qml | 150 - examples/declarative/canvas/contents/Button.qml | 87 - examples/declarative/canvas/contents/ScrollBar.qml | 74 - examples/declarative/canvas/contents/Slider.qml | 115 - examples/declarative/canvas/contents/Stocks.qml | 147 - examples/declarative/canvas/contents/TitleBar.qml | 70 - examples/declarative/canvas/contents/ToolBar.qml | 69 - .../canvas/contents/images/button-pressed.png | Bin 571 -> 0 bytes .../declarative/canvas/contents/images/button.png | Bin 564 -> 0 bytes .../declarative/canvas/contents/images/default.svg | 82 - .../declarative/canvas/contents/images/gloss.png | Bin 1236 -> 0 bytes .../canvas/contents/images/lineedit.png | Bin 1415 -> 0 bytes .../canvas/contents/images/lineedit.sci | 5 - .../declarative/canvas/contents/images/quit.png | Bin 2369 -> 0 bytes .../declarative/canvas/contents/images/stripes.png | Bin 257 -> 0 bytes .../canvas/contents/images/titlebar.png | Bin 1436 -> 0 bytes .../canvas/contents/images/titlebar.sci | 5 - .../canvas/contents/images/toolbutton.png | Bin 2550 -> 0 bytes .../canvas/contents/images/toolbutton.sci | 5 - examples/declarative/canvas/contents/qt-logo.png | Bin 23519 -> 0 bytes .../canvas/quadraticCurveTo/quadraticCurveTo.qml | 128 - .../declarative/canvas/roundedrect/roundedrect.qml | 125 - examples/declarative/canvas/smile/smile.qml | 128 - examples/declarative/canvas/squircle/squircle.png | Bin 771 -> 0 bytes examples/declarative/canvas/squircle/squircle.qml | 155 - examples/declarative/canvas/stockchart/README | 5 - .../stockchart/com/nokia/StockChartExample/qmldir | 1 - examples/declarative/canvas/stockchart/model.cpp | 255 - examples/declarative/canvas/stockchart/model.h | 166 - examples/declarative/canvas/stockchart/plugin.cpp | 60 - examples/declarative/canvas/stockchart/stock.qml | 726 -- .../declarative/canvas/stockchart/stockchart.pro | 20 - examples/declarative/canvas/tiger/tiger.js | 721 -- examples/declarative/canvas/tiger/tiger.qml | 129 - .../canvas/twitterfriends/TwitterUser.qml | 294 - .../declarative/canvas/twitterfriends/cache.js | 42 - .../declarative/canvas/twitterfriends/twitter.qml | 141 - .../declarative/cppextensions/cppextensions.pro | 8 - .../cppextensions/cppextensions.qmlproject | 16 - .../imageprovider/ImageProviderCore/qmldir | 2 - .../imageprovider/imageprovider-example.qml | 49 - .../cppextensions/imageprovider/imageprovider.cpp | 107 - .../cppextensions/imageprovider/imageprovider.pro | 20 - .../imageprovider/imageprovider.qmlproject | 14 - .../networkaccessmanagerfactory/main.cpp | 108 - .../networkaccessmanagerfactory.pro | 4 - .../networkaccessmanagerfactory.qmlproject | 14 - .../networkaccessmanagerfactory.qrc | 5 - .../networkaccessmanagerfactory/view.qml | 47 - examples/declarative/cppextensions/plugins/README | 9 - .../plugins/com/nokia/TimeExample/Clock.qml | 90 - .../plugins/com/nokia/TimeExample/center.png | Bin 765 -> 0 bytes .../plugins/com/nokia/TimeExample/clock.png | Bin 20653 -> 0 bytes .../plugins/com/nokia/TimeExample/hour.png | Bin 625 -> 0 bytes .../plugins/com/nokia/TimeExample/minute.png | Bin 625 -> 0 bytes .../plugins/com/nokia/TimeExample/qmldir | 2 - .../declarative/cppextensions/plugins/plugin.cpp | 157 - .../declarative/cppextensions/plugins/plugins.pro | 25 - .../declarative/cppextensions/plugins/plugins.qml | 53 - .../cppextensions/plugins/plugins.qmlproject | 16 - .../referenceexamples/adding/adding.pro | 11 - .../referenceexamples/adding/adding.qrc | 5 - .../referenceexamples/adding/example.qml | 48 - .../referenceexamples/adding/main.cpp | 64 - .../referenceexamples/adding/person.cpp | 68 - .../referenceexamples/adding/person.h | 65 - .../referenceexamples/attached/attached.pro | 13 - .../referenceexamples/attached/attached.qrc | 5 - .../referenceexamples/attached/birthdayparty.cpp | 91 - .../referenceexamples/attached/birthdayparty.h | 89 - .../referenceexamples/attached/example.qml | 68 - .../referenceexamples/attached/main.cpp | 91 - .../referenceexamples/attached/person.cpp | 118 - .../referenceexamples/attached/person.h | 105 - .../referenceexamples/binding/binding.pro | 15 - .../referenceexamples/binding/binding.qrc | 5 - .../referenceexamples/binding/birthdayparty.cpp | 113 - .../referenceexamples/binding/birthdayparty.h | 102 - .../referenceexamples/binding/example.qml | 77 - .../binding/happybirthdaysong.cpp | 85 - .../referenceexamples/binding/happybirthdaysong.h | 74 - .../referenceexamples/binding/main.cpp | 92 - .../referenceexamples/binding/person.cpp | 138 - .../referenceexamples/binding/person.h | 113 - .../referenceexamples/coercion/birthdayparty.cpp | 71 - .../referenceexamples/coercion/birthdayparty.h | 69 - .../referenceexamples/coercion/coercion.pro | 13 - .../referenceexamples/coercion/coercion.qrc | 5 - .../referenceexamples/coercion/example.qml | 55 - .../referenceexamples/coercion/main.cpp | 80 - .../referenceexamples/coercion/person.cpp | 79 - .../referenceexamples/coercion/person.h | 83 - .../referenceexamples/default/birthdayparty.cpp | 71 - .../referenceexamples/default/birthdayparty.h | 70 - .../referenceexamples/default/default.pro | 13 - .../referenceexamples/default/default.qrc | 5 - .../referenceexamples/default/example.qml | 54 - .../referenceexamples/default/main.cpp | 75 - .../referenceexamples/default/person.cpp | 78 - .../referenceexamples/default/person.h | 77 - .../referenceexamples/extended/example.qml | 47 - .../referenceexamples/extended/extended.pro | 11 - .../referenceexamples/extended/extended.qrc | 5 - .../referenceexamples/extended/lineedit.cpp | 104 - .../referenceexamples/extended/lineedit.h | 73 - .../referenceexamples/extended/main.cpp | 64 - .../referenceexamples/grouped/birthdayparty.cpp | 71 - .../referenceexamples/grouped/birthdayparty.h | 69 - .../referenceexamples/grouped/example.qml | 77 - .../referenceexamples/grouped/grouped.pro | 13 - .../referenceexamples/grouped/grouped.qrc | 5 - .../referenceexamples/grouped/main.cpp | 85 - .../referenceexamples/grouped/person.cpp | 118 - .../referenceexamples/grouped/person.h | 107 - .../referenceexamples/methods/birthdayparty.cpp | 80 - .../referenceexamples/methods/birthdayparty.h | 71 - .../referenceexamples/methods/example.qml | 58 - .../referenceexamples/methods/main.cpp | 68 - .../referenceexamples/methods/methods.pro | 13 - .../referenceexamples/methods/methods.qrc | 5 - .../referenceexamples/methods/person.cpp | 66 - .../referenceexamples/methods/person.h | 63 - .../referenceexamples/properties/birthdayparty.cpp | 73 - .../referenceexamples/properties/birthdayparty.h | 75 - .../referenceexamples/properties/example.qml | 55 - .../referenceexamples/properties/main.cpp | 70 - .../referenceexamples/properties/person.cpp | 66 - .../referenceexamples/properties/person.h | 63 - .../referenceexamples/properties/properties.pro | 13 - .../referenceexamples/properties/properties.qrc | 5 - .../referenceexamples/referenceexamples.pro | 14 - .../referenceexamples/referenceexamples.qmlproject | 14 - .../referenceexamples/signal/birthdayparty.cpp | 98 - .../referenceexamples/signal/birthdayparty.h | 92 - .../referenceexamples/signal/example.qml | 72 - .../referenceexamples/signal/main.cpp | 91 - .../referenceexamples/signal/person.cpp | 118 - .../referenceexamples/signal/person.h | 105 - .../referenceexamples/signal/signal.pro | 13 - .../referenceexamples/signal/signal.qrc | 5 - .../valuesource/birthdayparty.cpp | 108 - .../referenceexamples/valuesource/birthdayparty.h | 97 - .../referenceexamples/valuesource/example.qml | 76 - .../valuesource/happybirthdaysong.cpp | 80 - .../valuesource/happybirthdaysong.h | 79 - .../referenceexamples/valuesource/main.cpp | 93 - .../referenceexamples/valuesource/person.cpp | 118 - .../referenceexamples/valuesource/person.h | 105 - .../referenceexamples/valuesource/valuesource.pro | 15 - .../referenceexamples/valuesource/valuesource.qrc | 5 - examples/declarative/declarative.pro | 38 - .../declarative/draganddrop/dragtarget.qmlproject | 14 - .../declarative/draganddrop/tiles/DragTile.qml | 89 - .../declarative/draganddrop/tiles/DropTile.qml | 68 - examples/declarative/draganddrop/tiles/tiles.qml | 109 - .../declarative/draganddrop/views/gridview.qml | 117 - examples/declarative/flickr/content/Button.qml | 79 - .../declarative/flickr/content/GridDelegate.qml | 111 - .../declarative/flickr/content/ImageDetails.qml | 323 - .../declarative/flickr/content/ListDelegate.qml | 64 - examples/declarative/flickr/content/Progress.qml | 88 - examples/declarative/flickr/content/RssModel.qml | 64 - examples/declarative/flickr/content/ScrollBar.qml | 81 - examples/declarative/flickr/content/Slider.qml | 91 - examples/declarative/flickr/content/TitleBar.qml | 128 - examples/declarative/flickr/content/ToolBar.qml | 69 - .../declarative/flickr/content/UnifiedDelegate.qml | 154 - .../declarative/flickr/content/images/gloss.png | Bin 1236 -> 0 bytes .../declarative/flickr/content/images/lineedit.png | Bin 1415 -> 0 bytes .../declarative/flickr/content/images/lineedit.sci | 5 - .../declarative/flickr/content/images/noise.png | Bin 25447 -> 0 bytes .../declarative/flickr/content/images/particle.png | Bin 5148 -> 0 bytes .../declarative/flickr/content/images/quit.png | Bin 2369 -> 0 bytes .../flickr/content/images/squareParticle.png | Bin 933 -> 0 bytes .../declarative/flickr/content/images/stripes.png | Bin 257 -> 0 bytes .../declarative/flickr/content/images/titlebar.png | Bin 1436 -> 0 bytes .../declarative/flickr/content/images/titlebar.sci | 5 - .../flickr/content/images/toolbutton.png | Bin 2550 -> 0 bytes .../flickr/content/images/toolbutton.sci | 5 - examples/declarative/flickr/content/qmldir | 10 - examples/declarative/flickr/flickr-90.qml | 52 - examples/declarative/flickr/flickr.qml | 158 - examples/declarative/flickr/flickr.qmlproject | 17 - examples/declarative/i18n/i18n.qml | 78 - examples/declarative/i18n/i18n/base.ts | 12 - examples/declarative/i18n/i18n/qml_en_AU.ts | 12 - examples/declarative/i18n/i18n/qml_fr.ts | 12 - examples/declarative/imageelements/borderimage.qml | 97 - .../imageelements/content/BearSheet.png | Bin 406337 -> 0 bytes .../imageelements/content/ImageCell.qml | 60 - .../imageelements/content/MyBorderImage.qml | 90 - .../imageelements/content/ShadowRectangle.qml | 54 - examples/declarative/imageelements/content/bw.png | Bin 1357 -> 0 bytes .../imageelements/content/colors-round.sci | 7 - .../imageelements/content/colors-stretch.sci | 5 - .../declarative/imageelements/content/colors.png | Bin 1655 -> 0 bytes .../declarative/imageelements/content/qt-logo.png | Bin 5149 -> 0 bytes .../declarative/imageelements/content/shadow.png | Bin 588 -> 0 bytes .../declarative/imageelements/content/speaker.png | Bin 784525 -> 0 bytes examples/declarative/imageelements/image.qml | 67 - .../declarative/imageelements/imageelements.qml | 58 - .../imageelements/imageelements.qmlproject | 16 - examples/declarative/imageelements/shadows.qml | 64 - .../declarative/imageelements/simplesprite.qml | 59 - examples/declarative/imageelements/spriteimage.qml | 116 - .../keyinteraction/focus/Core/ContextMenu.qml | 65 - .../keyinteraction/focus/Core/GridMenu.qml | 105 - .../keyinteraction/focus/Core/ListMenu.qml | 105 - .../keyinteraction/focus/Core/ListViewDelegate.qml | 85 - .../keyinteraction/focus/Core/images/arrow.png | Bin 583 -> 0 bytes .../keyinteraction/focus/Core/images/qt-logo.png | Bin 5149 -> 0 bytes .../declarative/keyinteraction/focus/focus.qml | 111 - examples/declarative/locale/locale.qml | 132 - .../minehunt/MinehuntCore/Explosion.qml | 69 - .../declarative/minehunt/MinehuntCore/Tile.qml | 128 - .../minehunt/MinehuntCore/pics/back.png | Bin 558 -> 0 bytes .../minehunt/MinehuntCore/pics/background.png | Bin 313930 -> 0 bytes .../minehunt/MinehuntCore/pics/bomb-color.png | Bin 284 -> 0 bytes .../minehunt/MinehuntCore/pics/bomb.png | Bin 535 -> 0 bytes .../minehunt/MinehuntCore/pics/face-sad.png | Bin 14844 -> 0 bytes .../minehunt/MinehuntCore/pics/face-smile-big.png | Bin 13810 -> 0 bytes .../minehunt/MinehuntCore/pics/face-smile.png | Bin 15408 -> 0 bytes .../minehunt/MinehuntCore/pics/flag-color.png | Bin 219 -> 0 bytes .../minehunt/MinehuntCore/pics/flag.png | Bin 196 -> 0 bytes .../minehunt/MinehuntCore/pics/front.png | Bin 580 -> 0 bytes .../minehunt/MinehuntCore/pics/quit.png | Bin 583 -> 0 bytes .../minehunt/MinehuntCore/pics/star.png | Bin 2677 -> 0 bytes examples/declarative/minehunt/MinehuntCore/qmldir | 2 - examples/declarative/minehunt/README | 6 - examples/declarative/minehunt/main.cpp | 64 - examples/declarative/minehunt/minehunt.cpp | 221 - examples/declarative/minehunt/minehunt.h | 129 - examples/declarative/minehunt/minehunt.pro | 5 - examples/declarative/minehunt/minehunt.qml | 112 - examples/declarative/minehunt/minehunt.qmlproject | 16 - examples/declarative/minehunt/minehunt.qrc | 20 - .../abstractitemmodel/abstractitemmodel.pro | 10 - .../abstractitemmodel/abstractitemmodel.qrc | 6 - .../modelviews/abstractitemmodel/main.cpp | 70 - .../modelviews/abstractitemmodel/model.cpp | 90 - .../modelviews/abstractitemmodel/model.h | 83 - .../modelviews/abstractitemmodel/view.qml | 50 - .../modelviews/gridview/gridview-example.qml | 93 - .../modelviews/gridview/pics/AddressBook_48.png | Bin 3350 -> 0 bytes .../modelviews/gridview/pics/AudioPlayer_48.png | Bin 3806 -> 0 bytes .../modelviews/gridview/pics/Camera_48.png | Bin 3540 -> 0 bytes .../modelviews/gridview/pics/DateBook_48.png | Bin 2610 -> 0 bytes .../modelviews/gridview/pics/EMail_48.png | Bin 3655 -> 0 bytes .../modelviews/gridview/pics/TodoList_48.png | Bin 3429 -> 0 bytes .../modelviews/gridview/pics/VideoPlayer_48.png | Bin 4151 -> 0 bytes .../modelviews/listview/content/PetsModel.qml | 98 - .../listview/content/PressAndHoldButton.qml | 82 - .../modelviews/listview/content/RecipesModel.qml | 129 - .../modelviews/listview/content/TextButton.qml | 78 - .../modelviews/listview/content/ToggleButton.qml | 58 - .../listview/content/pics/arrow-down.png | Bin 594 -> 0 bytes .../modelviews/listview/content/pics/arrow-up.png | Bin 692 -> 0 bytes .../listview/content/pics/fruit-salad.jpg | Bin 17952 -> 0 bytes .../modelviews/listview/content/pics/hamburger.jpg | Bin 8572 -> 0 bytes .../modelviews/listview/content/pics/lemonade.jpg | Bin 6645 -> 0 bytes .../listview/content/pics/list-delete.png | Bin 831 -> 0 bytes .../listview/content/pics/minus-sign.png | Bin 250 -> 0 bytes .../modelviews/listview/content/pics/moreDown.png | Bin 217 -> 0 bytes .../modelviews/listview/content/pics/moreUp.png | Bin 212 -> 0 bytes .../modelviews/listview/content/pics/pancakes.jpg | Bin 9163 -> 0 bytes .../modelviews/listview/content/pics/plus-sign.png | Bin 462 -> 0 bytes .../listview/content/pics/vegetable-soup.jpg | Bin 8639 -> 0 bytes .../modelviews/listview/dynamiclist.qml | 203 - .../modelviews/listview/expandingdelegates.qml | 202 - .../declarative/modelviews/listview/highlight.qml | 99 - .../modelviews/listview/highlightranges.qml | 122 - .../declarative/modelviews/listview/sections.qml | 127 - examples/declarative/modelviews/modelviews.pro | 8 - examples/declarative/modelviews/modelviews.qml | 64 - .../declarative/modelviews/modelviews.qmlproject | 16 - .../modelviews/objectlistmodel/dataobject.cpp | 78 - .../modelviews/objectlistmodel/dataobject.h | 76 - .../modelviews/objectlistmodel/main.cpp | 78 - .../modelviews/objectlistmodel/objectlistmodel.pro | 6 - .../objectlistmodel/objectlistmodel.qmlproject | 14 - .../modelviews/objectlistmodel/objectlistmodel.qrc | 5 - .../modelviews/objectlistmodel/view.qml | 55 - .../declarative/modelviews/package/Delegate.qml | 88 - examples/declarative/modelviews/package/view.qml | 76 - .../modelviews/parallax/content/ParallaxView.qml | 123 - .../modelviews/parallax/content/Smiley.qml | 84 - .../parallax/content/pics/background.jpg | Bin 209814 -> 0 bytes .../parallax/content/pics/face-smile.png | Bin 15408 -> 0 bytes .../modelviews/parallax/content/pics/home-page.png | Bin 3051 -> 0 bytes .../modelviews/parallax/content/pics/home-page.svg | 445 - .../modelviews/parallax/content/pics/shadow.png | Bin 425 -> 0 bytes .../parallax/content/pics/yast-joystick.png | Bin 2723 -> 0 bytes .../modelviews/parallax/content/pics/yast-wol.png | Bin 3769 -> 0 bytes .../declarative/modelviews/parallax/parallax.qml | 77 - .../modelviews/pathview/pathview-example.qml | 107 - .../modelviews/pathview/pics/AddressBook_48.png | Bin 3350 -> 0 bytes .../modelviews/pathview/pics/AudioPlayer_48.png | Bin 3806 -> 0 bytes .../modelviews/pathview/pics/Camera_48.png | Bin 3540 -> 0 bytes .../modelviews/pathview/pics/DateBook_48.png | Bin 2610 -> 0 bytes .../modelviews/pathview/pics/EMail_48.png | Bin 3655 -> 0 bytes .../modelviews/pathview/pics/TodoList_48.png | Bin 3429 -> 0 bytes .../modelviews/pathview/pics/VideoPlayer_48.png | Bin 4151 -> 0 bytes .../modelviews/stringlistmodel/main.cpp | 77 - .../modelviews/stringlistmodel/stringlistmodel.pro | 4 - .../modelviews/stringlistmodel/stringlistmodel.qrc | 5 - .../modelviews/stringlistmodel/view.qml | 54 - .../modelviews/visualdatamodel/dragselection.qml | 200 - .../modelviews/visualdatamodel/slideshow.qml | 156 - .../modelviews/visualdatamodel/sortedmodel.qml | 141 - .../visualdatamodel/visualdatamodel.qmlproject | 14 - .../modelviews/visualitemmodel/visualitemmodel.qml | 115 - examples/declarative/openglunderqml/main.cpp | 60 - examples/declarative/openglunderqml/main.qml | 78 - .../declarative/openglunderqml/openglunderqml.pro | 6 - examples/declarative/openglunderqml/squircle.cpp | 123 - examples/declarative/openglunderqml/squircle.h | 76 - examples/declarative/painteditem/painteditem.pro | 5 - examples/declarative/painteditem/smile/main.cpp | 96 - examples/declarative/painteditem/smile/smile.pro | 11 - examples/declarative/painteditem/smile/smile.qml | 132 - .../textballoons/TextBalloonPlugin/plugin.h | 56 - .../textballoons/TextBalloonPlugin/qmldir | 1 - .../painteditem/textballoons/textballoon.cpp | 92 - .../painteditem/textballoons/textballoon.h | 68 - .../painteditem/textballoons/textballoons.pro | 23 - .../painteditem/textballoons/textballoons.qml | 110 - examples/declarative/particles/affectors/age.qml | 97 - .../declarative/particles/affectors/attractor.qml | 213 - .../particles/affectors/customaffector.qml | 173 - .../declarative/particles/affectors/friction.qml | 109 - .../declarative/particles/affectors/gravity.qml | 103 - .../declarative/particles/affectors/groupgoal.qml | 193 - examples/declarative/particles/affectors/move.qml | 141 - .../declarative/particles/affectors/spritegoal.qml | 212 - .../declarative/particles/affectors/turbulence.qml | 135 - .../declarative/particles/affectors/wander.qml | 95 - .../particles/customparticle/blurparticles.qml | 140 - .../particles/customparticle/fragmentshader.qml | 115 - .../particles/customparticle/imagecolors.qml | 118 - .../particles/emitters/burstandpulse.qml | 84 - .../particles/emitters/customemitter.qml | 92 - .../declarative/particles/emitters/emitmask.qml | 72 - .../particles/emitters/maximumemitted.qml | 81 - .../particles/emitters/shapeanddirection.qml | 112 - .../particles/emitters/timedgroupchanges.qml | 121 - .../particles/emitters/trailemitter.qml | 175 - .../particles/emitters/velocityfrommotion.qml | 311 - .../particles/exampleslauncher/content/Button.qml | 73 - .../particles/exampleslauncher/content/Shell.qml | 78 - .../particles/exampleslauncher/content/launcher.js | 8 - .../exampleslauncher/exampleslauncher.qml | 116 - .../particles/imageparticle/allatonce.qml | 98 - .../particles/imageparticle/colored.qml | 86 - .../particles/imageparticle/colortable.qml | 84 - .../particles/imageparticle/deformation.qml | 121 - .../particles/imageparticle/rotation.qml | 71 - .../particles/imageparticle/sharing.qml | 199 - .../particles/imageparticle/sprites.qml | 116 - examples/declarative/particles/images/_explo.png | Bin 81528 -> 0 bytes .../particles/images/backgroundLeaves.jpg | Bin 78665 -> 0 bytes .../declarative/particles/images/bear_tiles.png | Bin 40349 -> 0 bytes examples/declarative/particles/images/candle.png | Bin 1348 -> 0 bytes .../declarative/particles/images/colortable.png | Bin 704 -> 0 bytes .../declarative/particles/images/finalfrontier.png | Bin 695061 -> 0 bytes examples/declarative/particles/images/flower.png | Bin 4683 -> 0 bytes .../particles/images/launcherIcons/allatonce.png | Bin 7075 -> 0 bytes .../particles/images/launcherIcons/attractor.png | Bin 31296 -> 0 bytes .../images/launcherIcons/blurparticles.png | Bin 19109 -> 0 bytes .../particles/images/launcherIcons/close.png | Bin 2144 -> 0 bytes .../particles/images/launcherIcons/colortable.png | Bin 6538 -> 0 bytes .../images/launcherIcons/customaffector.png | Bin 10350 -> 0 bytes .../images/launcherIcons/customemitter.png | Bin 22967 -> 0 bytes .../particles/images/launcherIcons/deformation.png | Bin 2870 -> 0 bytes .../particles/images/launcherIcons/delegates.png | Bin 1892 -> 0 bytes .../images/launcherIcons/dynamicemitters.png | Bin 9347 -> 0 bytes .../particles/images/launcherIcons/emitmask.png | Bin 45055 -> 0 bytes .../particles/images/launcherIcons/flickr.png | Bin 10542 -> 0 bytes .../images/launcherIcons/fragmentshader.png | Bin 22294 -> 0 bytes .../images/launcherIcons/gridsplosion.png | Bin 8154 -> 0 bytes .../particles/images/launcherIcons/groupgoal.png | Bin 7173 -> 0 bytes .../particles/images/launcherIcons/imagecolors.png | Bin 56647 -> 0 bytes .../particles/images/launcherIcons/list.png | Bin 32912 -> 0 bytes .../images/launcherIcons/maximumemitted.png | Bin 1019 -> 0 bytes .../images/launcherIcons/multiplepainters.png | Bin 8572 -> 0 bytes .../particles/images/launcherIcons/package.png | Bin 3163 -> 0 bytes .../images/launcherIcons/particleview.png | Bin 26560 -> 0 bytes .../images/launcherIcons/plasmapatrol.png | Bin 9839 -> 0 bytes .../particles/images/launcherIcons/remove.png | Bin 2144 -> 0 bytes .../particles/images/launcherIcons/rotation.png | Bin 20661 -> 0 bytes .../particles/images/launcherIcons/samegame.png | Bin 8647 -> 0 bytes .../images/launcherIcons/shapeanddirection.png | Bin 11359 -> 0 bytes .../images/launcherIcons/spaceexplorer.png | Bin 9152 -> 0 bytes .../particles/images/launcherIcons/spritegoal.png | Bin 35579 -> 0 bytes .../particles/images/launcherIcons/sprites.png | Bin 17009 -> 0 bytes .../images/launcherIcons/spritevariedparticles.png | Bin 2569 -> 0 bytes .../particles/images/launcherIcons/startstop.png | Bin 13670 -> 0 bytes .../images/launcherIcons/timedgroupchanges.png | Bin 16139 -> 0 bytes .../images/launcherIcons/trailemitter.png | Bin 5371 -> 0 bytes .../particles/images/launcherIcons/trails.png | Bin 23168 -> 0 bytes .../particles/images/launcherIcons/turbulence.png | Bin 9684 -> 0 bytes .../images/launcherIcons/velocityfrommotion.png | Bin 36360 -> 0 bytes .../particles/images/launcherIcons/wander.png | Bin 5858 -> 0 bytes .../declarative/particles/images/matchmask.png | Bin 2369 -> 0 bytes examples/declarative/particles/images/meteor.png | Bin 83169 -> 0 bytes .../declarative/particles/images/meteor_explo.png | Bin 219946 -> 0 bytes examples/declarative/particles/images/meteors.png | Bin 132137 -> 0 bytes examples/declarative/particles/images/nullRock.png | Bin 140 -> 0 bytes examples/declarative/particles/images/particle.png | Bin 861 -> 0 bytes .../declarative/particles/images/particle2.png | Bin 3909 -> 0 bytes .../declarative/particles/images/particle3.png | Bin 3186 -> 0 bytes .../declarative/particles/images/particle4.png | Bin 1799 -> 0 bytes .../declarative/particles/images/particleA.png | Bin 3541 -> 0 bytes .../declarative/particles/images/portal_bg.png | Bin 96858 -> 0 bytes .../declarative/particles/images/realLeaf1.png | Bin 15625 -> 0 bytes .../declarative/particles/images/realLeaf2.png | Bin 13660 -> 0 bytes .../declarative/particles/images/realLeaf3.png | Bin 23809 -> 0 bytes .../declarative/particles/images/realLeaf4.png | Bin 23655 -> 0 bytes examples/declarative/particles/images/rocket.png | Bin 7315 -> 0 bytes examples/declarative/particles/images/rocket2.png | Bin 1918 -> 0 bytes .../declarative/particles/images/sizeInOut.png | Bin 251 -> 0 bytes .../declarative/particles/images/snowflake.png | Bin 189327 -> 0 bytes .../declarative/particles/images/sparkleSize.png | Bin 378 -> 0 bytes examples/declarative/particles/images/star.png | Bin 1550 -> 0 bytes .../declarative/particles/images/starfish_0.png | Bin 15972 -> 0 bytes .../declarative/particles/images/starfish_1.png | Bin 15746 -> 0 bytes .../declarative/particles/images/starfish_2.png | Bin 16067 -> 0 bytes .../declarative/particles/images/starfish_3.png | Bin 16201 -> 0 bytes .../declarative/particles/images/starfish_4.png | Bin 14698 -> 0 bytes .../declarative/particles/images/starfish_mask.png | Bin 11301 -> 0 bytes .../particles/itemparticle/content/Delegate.qml | 88 - .../particles/itemparticle/content/Delegate2.qml | 79 - .../itemparticle/content/ExpandingDelegate.qml | 204 - .../particles/itemparticle/content/RssModel.qml | 56 - .../particles/itemparticle/content/bubble.png | Bin 3413 -> 0 bytes .../particles/itemparticle/content/script.js | 27 - .../particles/itemparticle/delegates.qml | 91 - .../particles/itemparticle/particleview.qml | 274 - .../particles/plasmapatrol/PlasmaPatrol.qmlproject | 19 - examples/declarative/particles/plasmapatrol/TODO | 10 - .../plasmapatrol/content/BlasterHardpoint.qml | 133 - .../particles/plasmapatrol/content/Button.qml | 66 - .../plasmapatrol/content/CannonHardpoint.qml | 97 - .../particles/plasmapatrol/content/ChoiceBox.qml | 105 - .../particles/plasmapatrol/content/Cruiser.qml | 146 - .../particles/plasmapatrol/content/Frigate.qml | 114 - .../particles/plasmapatrol/content/Hardpoint.qml | 114 - .../particles/plasmapatrol/content/HelpScreens.qml | 268 - .../plasmapatrol/content/LaserHardpoint.qml | 108 - .../plasmapatrol/content/PlasmaPatrolParticles.qml | 173 - .../plasmapatrol/content/SequentialLoader.qml | 54 - .../particles/plasmapatrol/content/Ship.qml | 114 - .../particles/plasmapatrol/content/Sloop.qml | 108 - .../plasmapatrol/content/pics/TitleText.png | Bin 1109 -> 0 bytes .../plasmapatrol/content/pics/blur-circle2.png | Bin 3627 -> 0 bytes .../plasmapatrol/content/pics/blur-circle3.png | Bin 5148 -> 0 bytes .../plasmapatrol/content/pics/finalfrontier.png | Bin 695061 -> 0 bytes .../particles/plasmapatrol/content/pics/meteor.png | Bin 83169 -> 0 bytes .../plasmapatrol/content/pics/meteor_explo.png | Bin 81528 -> 0 bytes .../plasmapatrol/content/pics/nullRock.png | Bin 140 -> 0 bytes .../plasmapatrol/content/pics/particle.png | Bin 861 -> 0 bytes .../particles/plasmapatrol/content/pics/star.png | Bin 1550 -> 0 bytes .../particles/plasmapatrol/content/pics/star2.png | Bin 6507 -> 0 bytes .../particles/plasmapatrol/content/pics/star3.png | Bin 4602 -> 0 bytes .../particles/plasmapatrol/plasmapatrol.qml | 386 - .../particles/simple/dynamiccomparison.qml | 126 - .../particles/simple/dynamicemitters.qml | 122 - .../particles/simple/multiplepainters.qml | 90 - .../declarative/particles/simple/startstop.qml | 81 - .../photoviewer/PhotoViewerCore/AlbumDelegate.qml | 147 - .../photoviewer/PhotoViewerCore/BusyIndicator.qml | 50 - .../photoviewer/PhotoViewerCore/Button.qml | 72 - .../photoviewer/PhotoViewerCore/EditableButton.qml | 86 - .../photoviewer/PhotoViewerCore/PhotoDelegate.qml | 188 - .../photoviewer/PhotoViewerCore/ProgressBar.qml | 57 - .../photoviewer/PhotoViewerCore/RssModel.qml | 57 - .../photoviewer/PhotoViewerCore/Tag.qml | 91 - .../PhotoViewerCore/images/box-shadow.png | Bin 588 -> 0 bytes .../photoviewer/PhotoViewerCore/images/busy.png | Bin 2629 -> 0 bytes .../PhotoViewerCore/images/cardboard.png | Bin 8844 -> 0 bytes .../declarative/photoviewer/PhotoViewerCore/qmldir | 8 - .../photoviewer/PhotoViewerCore/script/script.js | 27 - examples/declarative/photoviewer/i18n/base.ts | 30 - examples/declarative/photoviewer/i18n/qml_fr.qm | Bin 268 -> 0 bytes examples/declarative/photoviewer/i18n/qml_fr.ts | 30 - examples/declarative/photoviewer/photoviewer.qml | 110 - .../declarative/photoviewer/photoviewer.qmlproject | 20 - .../declarative/positioners/content/Button.qml | 78 - examples/declarative/positioners/content/add.png | Bin 810 -> 0 bytes examples/declarative/positioners/content/del.png | Bin 488 -> 0 bytes .../positioners/positioners-attachedproperties.qml | 106 - examples/declarative/positioners/positioners.qml | 264 - .../layoutdirection/layoutdirection.qml | 246 - .../layoutdirection/layoutdirection.qmlproject | 16 - .../layoutmirroring/layoutmirroring.qml | 313 - .../layoutmirroring/layoutmirroring.qmlproject | 16 - .../righttoleft/textalignment/textalignment.qml | 427 - .../textalignment/textalignment.qmlproject | 16 - .../declarative/rssnews/content/BusyIndicator.qml | 53 - .../rssnews/content/CategoryDelegate.qml | 82 - .../declarative/rssnews/content/NewsDelegate.qml | 71 - examples/declarative/rssnews/content/RssFeeds.qml | 59 - examples/declarative/rssnews/content/ScrollBar.qml | 107 - .../declarative/rssnews/content/images/busy.png | Bin 2629 -> 0 bytes .../rssnews/content/images/scrollbar.png | Bin 161 -> 0 bytes examples/declarative/rssnews/rssnews.qml | 112 - examples/declarative/rssnews/rssnews.qmlproject | 16 - .../declarative/samegame/content/BoomBlock.qml | 112 - examples/declarative/samegame/content/Button.qml | 75 - examples/declarative/samegame/content/Dialog.qml | 81 - examples/declarative/samegame/content/GameArea.qml | 92 - .../samegame/content/NameInputDialog.qml | 93 - .../samegame/content/pics/background.png | Bin 313930 -> 0 bytes .../samegame/content/pics/blueStone.png | Bin 3054 -> 0 bytes .../samegame/content/pics/greenStone.png | Bin 2932 -> 0 bytes .../declarative/samegame/content/pics/particle.png | Bin 861 -> 0 bytes .../declarative/samegame/content/pics/redStone.png | Bin 2902 -> 0 bytes .../samegame/content/pics/yellowStone.png | Bin 3056 -> 0 bytes examples/declarative/samegame/content/samegame.js | 290 - examples/declarative/samegame/samegame.qml | 87 - examples/declarative/samegame/samegame.qmlproject | 16 - examples/declarative/script/script.pro | 4 - examples/declarative/script/shell/main.cpp | 153 - examples/declarative/script/shell/shell.pro | 7 - .../declarative/shadereffects/content/Slider.qml | 93 - .../shadereffects/content/face-smile.png | Bin 15408 -> 0 bytes .../declarative/shadereffects/content/qt-logo.png | Bin 13923 -> 0 bytes .../declarative/shadereffects/shadereffects.qml | 300 - examples/declarative/shared/Button.qml | 64 - examples/declarative/shared/LauncherList.qml | 101 - examples/declarative/shared/README | 11 - .../declarative/shared/SimpleLauncherDelegate.qml | 53 - examples/declarative/shared/back.png | Bin 404 -> 0 bytes examples/declarative/snake/content/Button.qml | 66 - examples/declarative/snake/content/Cookie.qml | 102 - .../declarative/snake/content/HighScoreModel.qml | 140 - examples/declarative/snake/content/Link.qml | 129 - examples/declarative/snake/content/Skull.qml | 62 - examples/declarative/snake/content/pics/README | 1 - .../declarative/snake/content/pics/background.png | Bin 144508 -> 0 bytes .../declarative/snake/content/pics/blueStar.png | Bin 272 -> 0 bytes .../declarative/snake/content/pics/blueStone.png | Bin 3139 -> 0 bytes examples/declarative/snake/content/pics/cookie.png | Bin 2729 -> 0 bytes examples/declarative/snake/content/pics/eyes.svg | 118 - examples/declarative/snake/content/pics/head.png | Bin 3473 -> 0 bytes examples/declarative/snake/content/pics/pause.png | Bin 4327 -> 0 bytes .../declarative/snake/content/pics/redStar.png | Bin 273 -> 0 bytes .../declarative/snake/content/pics/redStone.png | Bin 3456 -> 0 bytes examples/declarative/snake/content/pics/skull.png | Bin 2543 -> 0 bytes examples/declarative/snake/content/pics/snake.jpg | Bin 663901 -> 0 bytes examples/declarative/snake/content/pics/star.png | Bin 262 -> 0 bytes .../declarative/snake/content/pics/stoneShadow.png | Bin 1699 -> 0 bytes .../declarative/snake/content/pics/yellowStar.png | Bin 276 -> 0 bytes .../declarative/snake/content/pics/yellowStone.png | Bin 2667 -> 0 bytes examples/declarative/snake/content/snake.js | 316 - examples/declarative/snake/snake.qml | 272 - examples/declarative/snake/snake.qmlproject | 16 - examples/declarative/sqllocalstorage/hello.qml | 78 - examples/declarative/text/fonts/availableFonts.qml | 57 - examples/declarative/text/fonts/banner.qml | 61 - .../text/fonts/content/fonts/tarzeau_ocr_a.ttf | Bin 24544 -> 0 bytes examples/declarative/text/fonts/fonts.qml | 104 - examples/declarative/text/fonts/hello.qml | 79 - examples/declarative/text/imgtag/TextWithImage.qml | 55 - .../declarative/text/imgtag/images/face-sad.png | Bin 6148 -> 0 bytes .../text/imgtag/images/face-smile-big.png | Bin 6058 -> 0 bytes .../declarative/text/imgtag/images/face-smile.png | Bin 6446 -> 0 bytes .../declarative/text/imgtag/images/heart200.png | Bin 8248 -> 0 bytes examples/declarative/text/imgtag/images/qtlogo.png | Bin 6450 -> 0 bytes .../declarative/text/imgtag/images/starfish_2.png | Bin 18243 -> 0 bytes examples/declarative/text/imgtag/imgtag.qml | 101 - examples/declarative/text/styledtext-layout.qml | 107 - examples/declarative/text/text.qml | 57 - examples/declarative/text/text.qmlproject | 16 - .../text/textselection/pics/endHandle.png | Bin 185 -> 0 bytes .../text/textselection/pics/endHandle.sci | 5 - .../text/textselection/pics/startHandle.png | Bin 178 -> 0 bytes .../text/textselection/pics/startHandle.sci | 5 - .../text/textselection/textselection.qml | 211 - .../threading/threadedlistmodel/dataloader.js | 49 - .../threadedlistmodel/threadedlistmodel.qmlproject | 56 - .../threading/threadedlistmodel/timedisplay.qml | 76 - .../threading/workerscript/workerscript.js | 15 - .../threading/workerscript/workerscript.qml | 83 - .../threading/workerscript/workerscript.qmlproject | 16 - .../mousearea/mousearea-example.qml | 176 - .../touchinteraction/multipointtouch/bearwhack.qml | 133 - .../content/AugmentedTouchPoint.qml | 70 - .../multipointtouch/content/Bear0.png | Bin 15163 -> 0 bytes .../multipointtouch/content/Bear1.png | Bin 99378 -> 0 bytes .../multipointtouch/content/Bear2.png | Bin 80759 -> 0 bytes .../multipointtouch/content/Bear3.png | Bin 21122 -> 0 bytes .../multipointtouch/content/BearB.png | Bin 18667 -> 0 bytes .../content/BearWhackParticleSystem.qml | 180 - .../multipointtouch/content/ParticleFlame.qml | 65 - .../multipointtouch/content/blur-circle.png | Bin 4279 -> 0 bytes .../multipointtouch/content/blur-circle3.png | Bin 5148 -> 0 bytes .../multipointtouch/content/heart-blur.png | Bin 5406 -> 0 bytes .../multipointtouch/content/title.png | Bin 81252 -> 0 bytes .../multipointtouch/multiflame.qml | 91 - .../touchinteraction/pincharea/flickresize.qml | 97 - .../touchinteraction/pincharea/qt-logo.jpg | Bin 40886 -> 0 bytes .../touchinteraction/touchinteraction.qml | 57 - .../touchinteraction/touchinteraction.qmlproject | 16 - examples/declarative/toys/clocks/clocks.qml | 88 - examples/declarative/toys/clocks/content/Clock.qml | 143 - .../declarative/toys/clocks/content/QuitButton.qml | 52 - examples/declarative/toys/clocks/content/arrow.png | Bin 692 -> 0 bytes .../declarative/toys/clocks/content/background.png | Bin 46895 -> 0 bytes .../declarative/toys/clocks/content/center.png | Bin 765 -> 0 bytes .../toys/clocks/content/clock-night.png | Bin 23359 -> 0 bytes examples/declarative/toys/clocks/content/clock.png | Bin 20653 -> 0 bytes examples/declarative/toys/clocks/content/hour.png | Bin 625 -> 0 bytes .../declarative/toys/clocks/content/minute.png | Bin 625 -> 0 bytes examples/declarative/toys/clocks/content/quit.png | Bin 583 -> 0 bytes .../declarative/toys/clocks/content/second.png | Bin 303 -> 0 bytes .../declarative/toys/corkboards/content/Day.qml | 153 - .../declarative/toys/corkboards/content/cork.jpg | Bin 149337 -> 0 bytes .../toys/corkboards/content/note-yellow.png | Bin 54559 -> 0 bytes .../declarative/toys/corkboards/content/tack.png | Bin 7282 -> 0 bytes .../declarative/toys/corkboards/corkboards.qml | 116 - .../toys/dynamicscene/content/Button.qml | 80 - .../toys/dynamicscene/content/GenericSceneItem.qml | 49 - .../toys/dynamicscene/content/PaletteItem.qml | 59 - .../toys/dynamicscene/content/PerspectiveItem.qml | 65 - .../declarative/toys/dynamicscene/content/Sun.qml | 78 - .../toys/dynamicscene/content/images/NOTE | 1 - .../dynamicscene/content/images/face-smile.png | Bin 15408 -> 0 bytes .../toys/dynamicscene/content/images/moon.png | Bin 1757 -> 0 bytes .../dynamicscene/content/images/rabbit_brown.png | Bin 1245 -> 0 bytes .../toys/dynamicscene/content/images/rabbit_bw.png | Bin 1759 -> 0 bytes .../toys/dynamicscene/content/images/star.png | Bin 349 -> 0 bytes .../toys/dynamicscene/content/images/sun.png | Bin 8153 -> 0 bytes .../toys/dynamicscene/content/images/tree_s.png | Bin 3406 -> 0 bytes .../toys/dynamicscene/content/itemCreation.js | 62 - .../declarative/toys/dynamicscene/dynamicscene.qml | 275 - .../toys/tic-tac-toe/content/Button.qml | 79 - .../toys/tic-tac-toe/content/TicTac.qml | 60 - .../toys/tic-tac-toe/content/pics/board.png | Bin 12258 -> 0 bytes .../toys/tic-tac-toe/content/pics/o.png | Bin 1470 -> 0 bytes .../toys/tic-tac-toe/content/pics/x.png | Bin 1331 -> 0 bytes .../toys/tic-tac-toe/content/tic-tac-toe.js | 149 - .../declarative/toys/tic-tac-toe/tic-tac-toe.qml | 123 - examples/declarative/toys/tvtennis/tvtennis.qml | 109 - .../dynamicview/dynamicview1/PetsModel.qml | 102 - .../dynamicview/dynamicview1/dynamicview.qml | 90 - .../dynamicview/dynamicview2/PetsModel.qml | 98 - .../dynamicview/dynamicview2/dynamicview.qml | 121 - .../dynamicview/dynamicview3/PetsModel.qml | 98 - .../dynamicview/dynamicview3/dynamicview.qml | 143 - .../dynamicview/dynamicview4/ListSelector.qml | 120 - .../dynamicview/dynamicview4/PetsModel.qml | 98 - .../dynamicview/dynamicview4/dynamicview.qml | 219 - .../tutorials/extending/chapter1-basics/app.qml | 60 - .../extending/chapter1-basics/chapter1-basics.pro | 5 - .../tutorials/extending/chapter1-basics/main.cpp | 57 - .../extending/chapter1-basics/piechart.cpp | 79 - .../tutorials/extending/chapter1-basics/piechart.h | 71 - .../tutorials/extending/chapter2-methods/app.qml | 66 - .../chapter2-methods/chapter2-methods.pro | 5 - .../tutorials/extending/chapter2-methods/main.cpp | 57 - .../extending/chapter2-methods/piechart.cpp | 84 - .../extending/chapter2-methods/piechart.h | 84 - .../tutorials/extending/chapter3-bindings/app.qml | 74 - .../chapter3-bindings/chapter3-bindings.pro | 5 - .../tutorials/extending/chapter3-bindings/main.cpp | 57 - .../extending/chapter3-bindings/piechart.cpp | 86 - .../extending/chapter3-bindings/piechart.h | 84 - .../extending/chapter4-customPropertyTypes/app.qml | 60 - .../chapter4-customPropertyTypes.pro | 7 - .../chapter4-customPropertyTypes/main.cpp | 66 - .../chapter4-customPropertyTypes/piechart.cpp | 70 - .../chapter4-customPropertyTypes/piechart.h | 78 - .../chapter4-customPropertyTypes/pieslice.cpp | 66 - .../chapter4-customPropertyTypes/pieslice.h | 66 - .../extending/chapter5-listproperties/app.qml | 70 - .../chapter5-listproperties.pro | 7 - .../extending/chapter5-listproperties/main.cpp | 58 - .../extending/chapter5-listproperties/piechart.cpp | 72 - .../extending/chapter5-listproperties/piechart.h | 75 - .../extending/chapter5-listproperties/pieslice.cpp | 86 - .../extending/chapter5-listproperties/pieslice.h | 76 - .../extending/chapter6-plugins/ChartsPlugin/qmldir | 1 - .../tutorials/extending/chapter6-plugins/app.qml | 69 - .../chapter6-plugins/chapter6-plugins.pro | 18 - .../extending/chapter6-plugins/chartsplugin.cpp | 54 - .../extending/chapter6-plugins/chartsplugin.h | 55 - .../extending/chapter6-plugins/piechart.cpp | 71 - .../extending/chapter6-plugins/piechart.h | 69 - .../extending/chapter6-plugins/pieslice.cpp | 86 - .../extending/chapter6-plugins/pieslice.h | 74 - .../declarative/tutorials/extending/extending.pro | 10 - examples/declarative/tutorials/helloworld/Cell.qml | 72 - .../declarative/tutorials/helloworld/tutorial1.qml | 63 - .../declarative/tutorials/helloworld/tutorial2.qml | 72 - .../declarative/tutorials/helloworld/tutorial3.qml | 91 - .../tutorials/samegame/samegame1/Block.qml | 53 - .../tutorials/samegame/samegame1/Button.qml | 83 - .../tutorials/samegame/samegame1/samegame.qml | 82 - .../samegame/samegame1/samegame1.qmlproject | 16 - .../tutorials/samegame/samegame2/Block.qml | 51 - .../tutorials/samegame/samegame2/Button.qml | 81 - .../tutorials/samegame/samegame2/samegame.js | 63 - .../tutorials/samegame/samegame2/samegame.qml | 85 - .../samegame/samegame2/samegame2.qmlproject | 16 - .../tutorials/samegame/samegame3/Block.qml | 63 - .../tutorials/samegame/samegame3/Button.qml | 81 - .../tutorials/samegame/samegame3/Dialog.qml | 71 - .../tutorials/samegame/samegame3/samegame.js | 174 - .../tutorials/samegame/samegame3/samegame.qml | 109 - .../samegame/samegame3/samegame3.qmlproject | 16 - .../samegame/samegame4/content/BoomBlock.qml | 122 - .../samegame/samegame4/content/Button.qml | 81 - .../samegame/samegame4/content/Dialog.qml | 107 - .../samegame/samegame4/content/samegame.js | 226 - .../tutorials/samegame/samegame4/highscores/README | 1 - .../samegame/samegame4/highscores/score_data.xml | 2 - .../samegame/samegame4/highscores/score_style.xsl | 28 - .../samegame/samegame4/highscores/scores.php | 31 - .../tutorials/samegame/samegame4/samegame.qml | 115 - .../samegame/samegame4/samegame4.qmlproject | 16 - .../tutorials/samegame/shared/pics/background.jpg | Bin 36473 -> 0 bytes .../tutorials/samegame/shared/pics/blueStar.png | Bin 278 -> 0 bytes .../tutorials/samegame/shared/pics/blueStone.png | Bin 3054 -> 0 bytes .../tutorials/samegame/shared/pics/greenStar.png | Bin 273 -> 0 bytes .../tutorials/samegame/shared/pics/greenStone.png | Bin 2932 -> 0 bytes .../tutorials/samegame/shared/pics/redStar.png | Bin 274 -> 0 bytes .../tutorials/samegame/shared/pics/redStone.png | Bin 2902 -> 0 bytes .../tutorials/samegame/shared/pics/star.png | Bin 262 -> 0 bytes .../tutorials/samegame/shared/pics/yellowStone.png | Bin 3056 -> 0 bytes examples/declarative/tutorials/tutorials.pro | 5 - .../declarative/tutorials/tutorials.qmlproject | 14 - .../declarative/twitter/TwitterCore/Button.qml | 90 - .../twitter/TwitterCore/FatDelegate.qml | 105 - examples/declarative/twitter/TwitterCore/Input.qml | 65 - .../declarative/twitter/TwitterCore/Loading.qml | 49 - .../twitter/TwitterCore/MultiTitleBar.qml | 60 - .../declarative/twitter/TwitterCore/RssModel.qml | 80 - .../declarative/twitter/TwitterCore/SearchView.qml | 124 - .../declarative/twitter/TwitterCore/TitleBar.qml | 130 - .../declarative/twitter/TwitterCore/ToolBar.qml | 64 - .../declarative/twitter/TwitterCore/UserModel.qml | 66 - .../twitter/TwitterCore/images/gloss.png | Bin 1236 -> 0 bytes .../twitter/TwitterCore/images/lineedit.png | Bin 1415 -> 0 bytes .../twitter/TwitterCore/images/lineedit.sci | 5 - .../twitter/TwitterCore/images/loading.png | Bin 813 -> 0 bytes .../twitter/TwitterCore/images/quit.png | Bin 2369 -> 0 bytes .../twitter/TwitterCore/images/stripes.png | Bin 257 -> 0 bytes .../twitter/TwitterCore/images/titlebar.png | Bin 1436 -> 0 bytes .../twitter/TwitterCore/images/titlebar.sci | 5 - .../twitter/TwitterCore/images/toolbutton.png | Bin 2550 -> 0 bytes .../twitter/TwitterCore/images/toolbutton.sci | 5 - examples/declarative/twitter/TwitterCore/qmldir | 10 - examples/declarative/twitter/twitter.qml | 135 - examples/declarative/twitter/twitter.qmlproject | 16 - .../ui-components/dialcontrol/content/Dial.qml | 86 - .../dialcontrol/content/QuitButton.qml | 52 - .../dialcontrol/content/background.png | Bin 35876 -> 0 bytes .../ui-components/dialcontrol/content/needle.png | Bin 342 -> 0 bytes .../dialcontrol/content/needle_shadow.png | Bin 632 -> 0 bytes .../ui-components/dialcontrol/content/overlay.png | Bin 3564 -> 0 bytes .../ui-components/dialcontrol/content/quit.png | Bin 583 -> 0 bytes .../ui-components/dialcontrol/dialcontrol.qml | 98 - .../ui-components/flipable/content/5_heart.png | Bin 3872 -> 0 bytes .../ui-components/flipable/content/9_club.png | Bin 6135 -> 0 bytes .../ui-components/flipable/content/Card.qml | 80 - .../ui-components/flipable/content/back.png | Bin 1418 -> 0 bytes .../ui-components/flipable/flipable.qml | 55 - .../progressbar/content/ProgressBar.qml | 83 - .../progressbar/content/background.png | Bin 426 -> 0 bytes .../declarative/ui-components/progressbar/main.qml | 73 - .../ui-components/scrollbar/ScrollBar.qml | 74 - .../declarative/ui-components/scrollbar/main.qml | 93 - .../ui-components/scrollbar/pics/niagara_falls.jpg | Bin 142510 -> 0 bytes .../ui-components/scrollbar/scrollbar.qmlproject | 16 - .../ui-components/searchbox/SearchBox.qml | 109 - .../ui-components/searchbox/images/clear.png | Bin 429 -> 0 bytes .../searchbox/images/lineedit-bg-focus.png | Bin 526 -> 0 bytes .../ui-components/searchbox/images/lineedit-bg.png | Bin 426 -> 0 bytes .../declarative/ui-components/searchbox/main.qml | 60 - .../ui-components/searchbox/searchbox.qmlproject | 16 - .../ui-components/slideswitch/content/Switch.qml | 117 - .../slideswitch/content/background.png | Bin 3091 -> 0 bytes .../slideswitch/content/background.svg | 23 - .../ui-components/slideswitch/content/knob.png | Bin 3101 -> 0 bytes .../ui-components/slideswitch/content/knob.svg | 867 -- .../ui-components/slideswitch/slideswitch.qml | 51 - .../ui-components/spinner/content/Spinner.qml | 70 - .../ui-components/spinner/content/spinner-bg.png | Bin 345 -> 0 bytes .../spinner/content/spinner-select.png | Bin 320 -> 0 bytes .../declarative/ui-components/spinner/main.qml | 61 - .../ui-components/spinner/spinner.qmlproject | 16 - .../ui-components/tabwidget/TabWidget.qml | 102 - .../declarative/ui-components/tabwidget/main.qml | 99 - .../declarative/ui-components/tabwidget/tab.png | Bin 507 -> 0 bytes .../ui-components/tabwidget/tabwidget.qmlproject | 16 - examples/declarative/window/Window.qml | 58 - examples/declarative/window/screen/screenInfo.qml | 90 - examples/declarative/window/standalone.qml | 71 - examples/declarative/window/window.cpp | 58 - examples/declarative/window/window.pro | 5 - examples/declarative/xml/xmlhttprequest/data.xml | 5 - .../xml/xmlhttprequest/xmlhttprequest-example.qml | 95 - examples/embedded/qmlcalculator/deployment.pri | 2 +- examples/embedded/qmlcalculator/qmlcalculator.cpp | 8 +- examples/embedded/qmlcalculator/qmlcalculator.pro | 2 +- examples/embedded/qmlclocks/deployment.pri | 2 +- examples/embedded/qmlclocks/qmlclocks.cpp | 8 +- examples/embedded/qmlclocks/qmlclocks.pro | 2 +- examples/embedded/qmldialcontrol/deployment.pri | 2 +- .../embedded/qmldialcontrol/qmldialcontrol.cpp | 8 +- .../embedded/qmldialcontrol/qmldialcontrol.pro | 2 +- examples/embedded/qmleasing/deployment.pri | 2 +- examples/embedded/qmleasing/qmleasing.cpp | 8 +- examples/embedded/qmleasing/qmleasing.pro | 2 +- examples/embedded/qmlflickr/deployment.pri | 2 +- examples/embedded/qmlflickr/qmlflickr.cpp | 14 +- examples/embedded/qmlflickr/qmlflickr.pro | 2 +- examples/embedded/qmlphotoviewer/deployment.pri | 2 +- .../embedded/qmlphotoviewer/qmlphotoviewer.cpp | 12 +- .../embedded/qmlphotoviewer/qmlphotoviewer.pro | 2 +- examples/embedded/qmltwitter/deployment.pri | 2 +- examples/embedded/qmltwitter/qmltwitter.cpp | 12 +- examples/embedded/qmltwitter/qmltwitter.pro | 2 +- examples/examples.pro | 2 +- examples/qml/README | 13 + examples/qml/accessibility/accessibility.qml | 105 + examples/qml/accessibility/widgets/Button.qml | 79 + examples/qml/animation/animation.qml | 62 + examples/qml/animation/animation.qmlproject | 16 + examples/qml/animation/basics/color-animation.qml | 121 + .../qml/animation/basics/images/face-smile.png | Bin 0 -> 15408 bytes examples/qml/animation/basics/images/moon.png | Bin 0 -> 2433 bytes examples/qml/animation/basics/images/shadow.png | Bin 0 -> 425 bytes examples/qml/animation/basics/images/star.png | Bin 0 -> 349 bytes examples/qml/animation/basics/images/sun.png | Bin 0 -> 8153 bytes .../qml/animation/basics/property-animation.qml | 105 + examples/qml/animation/behaviors/SideRect.qml | 62 + .../qml/animation/behaviors/behavior-example.qml | 118 + examples/qml/animation/behaviors/wigglytext.qml | 108 + .../qml/animation/easing/content/QuitButton.qml | 52 + examples/qml/animation/easing/content/quit.png | Bin 0 -> 583 bytes examples/qml/animation/easing/easing.qml | 170 + .../qml/animation/pathanimation/pathanimation.qml | 108 + .../pathinterpolator/pathinterpolator.qml | 115 + examples/qml/animation/states/qt-logo.png | Bin 0 -> 5149 bytes examples/qml/animation/states/states.qml | 101 + examples/qml/animation/states/transitions.qml | 130 + examples/qml/calculator/calculator.qml | 163 + examples/qml/calculator/content/Button.qml | 84 + examples/qml/calculator/content/Display.qml | 68 + examples/qml/calculator/content/calculator.js | 91 + examples/qml/calculator/content/images/button-.png | Bin 0 -> 1288 bytes .../qml/calculator/content/images/button-blue.png | Bin 0 -> 1565 bytes .../qml/calculator/content/images/button-green.png | Bin 0 -> 1543 bytes .../calculator/content/images/button-purple.png | Bin 0 -> 1566 bytes .../qml/calculator/content/images/button-red.png | Bin 0 -> 1586 bytes examples/qml/calculator/content/images/display.png | Bin 0 -> 998 bytes examples/qml/calculator/content/qmldir | 2 + examples/qml/canvas/bezierCurve/bezierCurve.qml | 124 + examples/qml/canvas/clip/clip.qml | 150 + examples/qml/canvas/contents/Button.qml | 87 + examples/qml/canvas/contents/ScrollBar.qml | 74 + examples/qml/canvas/contents/Slider.qml | 115 + examples/qml/canvas/contents/Stocks.qml | 147 + examples/qml/canvas/contents/TitleBar.qml | 70 + examples/qml/canvas/contents/ToolBar.qml | 69 + .../qml/canvas/contents/images/button-pressed.png | Bin 0 -> 571 bytes examples/qml/canvas/contents/images/button.png | Bin 0 -> 564 bytes examples/qml/canvas/contents/images/default.svg | 82 + examples/qml/canvas/contents/images/gloss.png | Bin 0 -> 1236 bytes examples/qml/canvas/contents/images/lineedit.png | Bin 0 -> 1415 bytes examples/qml/canvas/contents/images/lineedit.sci | 5 + examples/qml/canvas/contents/images/quit.png | Bin 0 -> 2369 bytes examples/qml/canvas/contents/images/stripes.png | Bin 0 -> 257 bytes examples/qml/canvas/contents/images/titlebar.png | Bin 0 -> 1436 bytes examples/qml/canvas/contents/images/titlebar.sci | 5 + examples/qml/canvas/contents/images/toolbutton.png | Bin 0 -> 2550 bytes examples/qml/canvas/contents/images/toolbutton.sci | 5 + examples/qml/canvas/contents/qt-logo.png | Bin 0 -> 23519 bytes .../canvas/quadraticCurveTo/quadraticCurveTo.qml | 128 + examples/qml/canvas/roundedrect/roundedrect.qml | 125 + examples/qml/canvas/smile/smile.qml | 128 + examples/qml/canvas/squircle/squircle.png | Bin 0 -> 771 bytes examples/qml/canvas/squircle/squircle.qml | 155 + examples/qml/canvas/stockchart/README | 5 + .../stockchart/com/nokia/StockChartExample/qmldir | 1 + examples/qml/canvas/stockchart/model.cpp | 255 + examples/qml/canvas/stockchart/model.h | 166 + examples/qml/canvas/stockchart/plugin.cpp | 60 + examples/qml/canvas/stockchart/stock.qml | 726 ++ examples/qml/canvas/stockchart/stockchart.pro | 20 + examples/qml/canvas/tiger/tiger.js | 721 ++ examples/qml/canvas/tiger/tiger.qml | 129 + examples/qml/canvas/twitterfriends/TwitterUser.qml | 294 + examples/qml/canvas/twitterfriends/cache.js | 42 + examples/qml/canvas/twitterfriends/twitter.qml | 141 + examples/qml/cppextensions/cppextensions.pro | 8 + .../qml/cppextensions/cppextensions.qmlproject | 16 + .../imageprovider/ImageProviderCore/qmldir | 2 + .../imageprovider/imageprovider-example.qml | 49 + .../cppextensions/imageprovider/imageprovider.cpp | 107 + .../cppextensions/imageprovider/imageprovider.pro | 20 + .../imageprovider/imageprovider.qmlproject | 14 + .../networkaccessmanagerfactory/main.cpp | 108 + .../networkaccessmanagerfactory.pro | 4 + .../networkaccessmanagerfactory.qmlproject | 14 + .../networkaccessmanagerfactory.qrc | 5 + .../networkaccessmanagerfactory/view.qml | 47 + examples/qml/cppextensions/plugins/README | 9 + .../plugins/com/nokia/TimeExample/Clock.qml | 90 + .../plugins/com/nokia/TimeExample/center.png | Bin 0 -> 765 bytes .../plugins/com/nokia/TimeExample/clock.png | Bin 0 -> 20653 bytes .../plugins/com/nokia/TimeExample/hour.png | Bin 0 -> 625 bytes .../plugins/com/nokia/TimeExample/minute.png | Bin 0 -> 625 bytes .../plugins/com/nokia/TimeExample/qmldir | 2 + examples/qml/cppextensions/plugins/plugin.cpp | 157 + examples/qml/cppextensions/plugins/plugins.pro | 25 + examples/qml/cppextensions/plugins/plugins.qml | 53 + .../qml/cppextensions/plugins/plugins.qmlproject | 16 + .../referenceexamples/adding/adding.pro | 11 + .../referenceexamples/adding/adding.qrc | 5 + .../referenceexamples/adding/example.qml | 48 + .../referenceexamples/adding/main.cpp | 64 + .../referenceexamples/adding/person.cpp | 68 + .../referenceexamples/adding/person.h | 65 + .../referenceexamples/attached/attached.pro | 13 + .../referenceexamples/attached/attached.qrc | 5 + .../referenceexamples/attached/birthdayparty.cpp | 91 + .../referenceexamples/attached/birthdayparty.h | 89 + .../referenceexamples/attached/example.qml | 68 + .../referenceexamples/attached/main.cpp | 91 + .../referenceexamples/attached/person.cpp | 118 + .../referenceexamples/attached/person.h | 105 + .../referenceexamples/binding/binding.pro | 15 + .../referenceexamples/binding/binding.qrc | 5 + .../referenceexamples/binding/birthdayparty.cpp | 113 + .../referenceexamples/binding/birthdayparty.h | 102 + .../referenceexamples/binding/example.qml | 77 + .../binding/happybirthdaysong.cpp | 85 + .../referenceexamples/binding/happybirthdaysong.h | 74 + .../referenceexamples/binding/main.cpp | 92 + .../referenceexamples/binding/person.cpp | 138 + .../referenceexamples/binding/person.h | 113 + .../referenceexamples/coercion/birthdayparty.cpp | 71 + .../referenceexamples/coercion/birthdayparty.h | 69 + .../referenceexamples/coercion/coercion.pro | 13 + .../referenceexamples/coercion/coercion.qrc | 5 + .../referenceexamples/coercion/example.qml | 55 + .../referenceexamples/coercion/main.cpp | 80 + .../referenceexamples/coercion/person.cpp | 79 + .../referenceexamples/coercion/person.h | 83 + .../referenceexamples/default/birthdayparty.cpp | 71 + .../referenceexamples/default/birthdayparty.h | 70 + .../referenceexamples/default/default.pro | 13 + .../referenceexamples/default/default.qrc | 5 + .../referenceexamples/default/example.qml | 54 + .../referenceexamples/default/main.cpp | 75 + .../referenceexamples/default/person.cpp | 78 + .../referenceexamples/default/person.h | 77 + .../referenceexamples/extended/example.qml | 47 + .../referenceexamples/extended/extended.pro | 11 + .../referenceexamples/extended/extended.qrc | 5 + .../referenceexamples/extended/lineedit.cpp | 104 + .../referenceexamples/extended/lineedit.h | 73 + .../referenceexamples/extended/main.cpp | 64 + .../referenceexamples/grouped/birthdayparty.cpp | 71 + .../referenceexamples/grouped/birthdayparty.h | 69 + .../referenceexamples/grouped/example.qml | 77 + .../referenceexamples/grouped/grouped.pro | 13 + .../referenceexamples/grouped/grouped.qrc | 5 + .../referenceexamples/grouped/main.cpp | 85 + .../referenceexamples/grouped/person.cpp | 118 + .../referenceexamples/grouped/person.h | 107 + .../referenceexamples/methods/birthdayparty.cpp | 80 + .../referenceexamples/methods/birthdayparty.h | 71 + .../referenceexamples/methods/example.qml | 58 + .../referenceexamples/methods/main.cpp | 68 + .../referenceexamples/methods/methods.pro | 13 + .../referenceexamples/methods/methods.qrc | 5 + .../referenceexamples/methods/person.cpp | 66 + .../referenceexamples/methods/person.h | 63 + .../referenceexamples/properties/birthdayparty.cpp | 73 + .../referenceexamples/properties/birthdayparty.h | 75 + .../referenceexamples/properties/example.qml | 55 + .../referenceexamples/properties/main.cpp | 70 + .../referenceexamples/properties/person.cpp | 66 + .../referenceexamples/properties/person.h | 63 + .../referenceexamples/properties/properties.pro | 13 + .../referenceexamples/properties/properties.qrc | 5 + .../referenceexamples/referenceexamples.pro | 14 + .../referenceexamples/referenceexamples.qmlproject | 14 + .../referenceexamples/signal/birthdayparty.cpp | 98 + .../referenceexamples/signal/birthdayparty.h | 92 + .../referenceexamples/signal/example.qml | 72 + .../referenceexamples/signal/main.cpp | 91 + .../referenceexamples/signal/person.cpp | 118 + .../referenceexamples/signal/person.h | 105 + .../referenceexamples/signal/signal.pro | 13 + .../referenceexamples/signal/signal.qrc | 5 + .../valuesource/birthdayparty.cpp | 108 + .../referenceexamples/valuesource/birthdayparty.h | 97 + .../referenceexamples/valuesource/example.qml | 76 + .../valuesource/happybirthdaysong.cpp | 80 + .../valuesource/happybirthdaysong.h | 79 + .../referenceexamples/valuesource/main.cpp | 93 + .../referenceexamples/valuesource/person.cpp | 118 + .../referenceexamples/valuesource/person.h | 105 + .../referenceexamples/valuesource/valuesource.pro | 15 + .../referenceexamples/valuesource/valuesource.qrc | 5 + examples/qml/draganddrop/dragtarget.qmlproject | 14 + examples/qml/draganddrop/tiles/DragTile.qml | 89 + examples/qml/draganddrop/tiles/DropTile.qml | 68 + examples/qml/draganddrop/tiles/tiles.qml | 109 + examples/qml/draganddrop/views/gridview.qml | 117 + examples/qml/flickr/content/Button.qml | 79 + examples/qml/flickr/content/GridDelegate.qml | 111 + examples/qml/flickr/content/ImageDetails.qml | 323 + examples/qml/flickr/content/ListDelegate.qml | 64 + examples/qml/flickr/content/Progress.qml | 88 + examples/qml/flickr/content/RssModel.qml | 64 + examples/qml/flickr/content/ScrollBar.qml | 81 + examples/qml/flickr/content/Slider.qml | 91 + examples/qml/flickr/content/TitleBar.qml | 128 + examples/qml/flickr/content/ToolBar.qml | 69 + examples/qml/flickr/content/UnifiedDelegate.qml | 154 + examples/qml/flickr/content/images/gloss.png | Bin 0 -> 1236 bytes examples/qml/flickr/content/images/lineedit.png | Bin 0 -> 1415 bytes examples/qml/flickr/content/images/lineedit.sci | 5 + examples/qml/flickr/content/images/noise.png | Bin 0 -> 25447 bytes examples/qml/flickr/content/images/particle.png | Bin 0 -> 5148 bytes examples/qml/flickr/content/images/quit.png | Bin 0 -> 2369 bytes .../qml/flickr/content/images/squareParticle.png | Bin 0 -> 933 bytes examples/qml/flickr/content/images/stripes.png | Bin 0 -> 257 bytes examples/qml/flickr/content/images/titlebar.png | Bin 0 -> 1436 bytes examples/qml/flickr/content/images/titlebar.sci | 5 + examples/qml/flickr/content/images/toolbutton.png | Bin 0 -> 2550 bytes examples/qml/flickr/content/images/toolbutton.sci | 5 + examples/qml/flickr/content/qmldir | 10 + examples/qml/flickr/flickr-90.qml | 52 + examples/qml/flickr/flickr.qml | 158 + examples/qml/flickr/flickr.qmlproject | 17 + examples/qml/i18n/i18n.qml | 78 + examples/qml/i18n/i18n/base.ts | 12 + examples/qml/i18n/i18n/qml_en_AU.ts | 12 + examples/qml/i18n/i18n/qml_fr.ts | 12 + examples/qml/imageelements/borderimage.qml | 97 + examples/qml/imageelements/content/BearSheet.png | Bin 0 -> 406337 bytes examples/qml/imageelements/content/ImageCell.qml | 60 + .../qml/imageelements/content/MyBorderImage.qml | 90 + .../qml/imageelements/content/ShadowRectangle.qml | 54 + examples/qml/imageelements/content/bw.png | Bin 0 -> 1357 bytes .../qml/imageelements/content/colors-round.sci | 7 + .../qml/imageelements/content/colors-stretch.sci | 5 + examples/qml/imageelements/content/colors.png | Bin 0 -> 1655 bytes examples/qml/imageelements/content/qt-logo.png | Bin 0 -> 5149 bytes examples/qml/imageelements/content/shadow.png | Bin 0 -> 588 bytes examples/qml/imageelements/content/speaker.png | Bin 0 -> 784525 bytes examples/qml/imageelements/image.qml | 67 + examples/qml/imageelements/imageelements.qml | 58 + .../qml/imageelements/imageelements.qmlproject | 16 + examples/qml/imageelements/shadows.qml | 64 + examples/qml/imageelements/simplesprite.qml | 59 + examples/qml/imageelements/spriteimage.qml | 116 + .../qml/keyinteraction/focus/Core/ContextMenu.qml | 65 + .../qml/keyinteraction/focus/Core/GridMenu.qml | 105 + .../qml/keyinteraction/focus/Core/ListMenu.qml | 105 + .../keyinteraction/focus/Core/ListViewDelegate.qml | 85 + .../qml/keyinteraction/focus/Core/images/arrow.png | Bin 0 -> 583 bytes .../keyinteraction/focus/Core/images/qt-logo.png | Bin 0 -> 5149 bytes examples/qml/keyinteraction/focus/focus.qml | 111 + examples/qml/locale/locale.qml | 132 + examples/qml/minehunt/MinehuntCore/Explosion.qml | 69 + examples/qml/minehunt/MinehuntCore/Tile.qml | 128 + examples/qml/minehunt/MinehuntCore/pics/back.png | Bin 0 -> 558 bytes .../qml/minehunt/MinehuntCore/pics/background.png | Bin 0 -> 313930 bytes .../qml/minehunt/MinehuntCore/pics/bomb-color.png | Bin 0 -> 284 bytes examples/qml/minehunt/MinehuntCore/pics/bomb.png | Bin 0 -> 535 bytes .../qml/minehunt/MinehuntCore/pics/face-sad.png | Bin 0 -> 14844 bytes .../minehunt/MinehuntCore/pics/face-smile-big.png | Bin 0 -> 13810 bytes .../qml/minehunt/MinehuntCore/pics/face-smile.png | Bin 0 -> 15408 bytes .../qml/minehunt/MinehuntCore/pics/flag-color.png | Bin 0 -> 219 bytes examples/qml/minehunt/MinehuntCore/pics/flag.png | Bin 0 -> 196 bytes examples/qml/minehunt/MinehuntCore/pics/front.png | Bin 0 -> 580 bytes examples/qml/minehunt/MinehuntCore/pics/quit.png | Bin 0 -> 583 bytes examples/qml/minehunt/MinehuntCore/pics/star.png | Bin 0 -> 2677 bytes examples/qml/minehunt/MinehuntCore/qmldir | 2 + examples/qml/minehunt/README | 6 + examples/qml/minehunt/main.cpp | 64 + examples/qml/minehunt/minehunt.cpp | 221 + examples/qml/minehunt/minehunt.h | 129 + examples/qml/minehunt/minehunt.pro | 5 + examples/qml/minehunt/minehunt.qml | 112 + examples/qml/minehunt/minehunt.qmlproject | 16 + examples/qml/minehunt/minehunt.qrc | 20 + .../abstractitemmodel/abstractitemmodel.pro | 10 + .../abstractitemmodel/abstractitemmodel.qrc | 6 + examples/qml/modelviews/abstractitemmodel/main.cpp | 70 + .../qml/modelviews/abstractitemmodel/model.cpp | 90 + examples/qml/modelviews/abstractitemmodel/model.h | 83 + examples/qml/modelviews/abstractitemmodel/view.qml | 50 + .../qml/modelviews/gridview/gridview-example.qml | 93 + .../modelviews/gridview/pics/AddressBook_48.png | Bin 0 -> 3350 bytes .../modelviews/gridview/pics/AudioPlayer_48.png | Bin 0 -> 3806 bytes .../qml/modelviews/gridview/pics/Camera_48.png | Bin 0 -> 3540 bytes .../qml/modelviews/gridview/pics/DateBook_48.png | Bin 0 -> 2610 bytes examples/qml/modelviews/gridview/pics/EMail_48.png | Bin 0 -> 3655 bytes .../qml/modelviews/gridview/pics/TodoList_48.png | Bin 0 -> 3429 bytes .../modelviews/gridview/pics/VideoPlayer_48.png | Bin 0 -> 4151 bytes .../qml/modelviews/listview/content/PetsModel.qml | 98 + .../listview/content/PressAndHoldButton.qml | 82 + .../modelviews/listview/content/RecipesModel.qml | 129 + .../qml/modelviews/listview/content/TextButton.qml | 78 + .../modelviews/listview/content/ToggleButton.qml | 58 + .../listview/content/pics/arrow-down.png | Bin 0 -> 594 bytes .../modelviews/listview/content/pics/arrow-up.png | Bin 0 -> 692 bytes .../listview/content/pics/fruit-salad.jpg | Bin 0 -> 17952 bytes .../modelviews/listview/content/pics/hamburger.jpg | Bin 0 -> 8572 bytes .../modelviews/listview/content/pics/lemonade.jpg | Bin 0 -> 6645 bytes .../listview/content/pics/list-delete.png | Bin 0 -> 831 bytes .../listview/content/pics/minus-sign.png | Bin 0 -> 250 bytes .../modelviews/listview/content/pics/moreDown.png | Bin 0 -> 217 bytes .../modelviews/listview/content/pics/moreUp.png | Bin 0 -> 212 bytes .../modelviews/listview/content/pics/pancakes.jpg | Bin 0 -> 9163 bytes .../modelviews/listview/content/pics/plus-sign.png | Bin 0 -> 462 bytes .../listview/content/pics/vegetable-soup.jpg | Bin 0 -> 8639 bytes examples/qml/modelviews/listview/dynamiclist.qml | 203 + .../qml/modelviews/listview/expandingdelegates.qml | 202 + examples/qml/modelviews/listview/highlight.qml | 99 + .../qml/modelviews/listview/highlightranges.qml | 122 + examples/qml/modelviews/listview/sections.qml | 127 + examples/qml/modelviews/modelviews.pro | 8 + examples/qml/modelviews/modelviews.qml | 64 + examples/qml/modelviews/modelviews.qmlproject | 16 + .../qml/modelviews/objectlistmodel/dataobject.cpp | 78 + .../qml/modelviews/objectlistmodel/dataobject.h | 76 + examples/qml/modelviews/objectlistmodel/main.cpp | 78 + .../modelviews/objectlistmodel/objectlistmodel.pro | 6 + .../objectlistmodel/objectlistmodel.qmlproject | 14 + .../modelviews/objectlistmodel/objectlistmodel.qrc | 5 + examples/qml/modelviews/objectlistmodel/view.qml | 55 + examples/qml/modelviews/package/Delegate.qml | 88 + examples/qml/modelviews/package/view.qml | 76 + .../modelviews/parallax/content/ParallaxView.qml | 123 + .../qml/modelviews/parallax/content/Smiley.qml | 84 + .../parallax/content/pics/background.jpg | Bin 0 -> 209814 bytes .../parallax/content/pics/face-smile.png | Bin 0 -> 15408 bytes .../modelviews/parallax/content/pics/home-page.png | Bin 0 -> 3051 bytes .../modelviews/parallax/content/pics/home-page.svg | 445 + .../modelviews/parallax/content/pics/shadow.png | Bin 0 -> 425 bytes .../parallax/content/pics/yast-joystick.png | Bin 0 -> 2723 bytes .../modelviews/parallax/content/pics/yast-wol.png | Bin 0 -> 3769 bytes examples/qml/modelviews/parallax/parallax.qml | 77 + .../qml/modelviews/pathview/pathview-example.qml | 107 + .../modelviews/pathview/pics/AddressBook_48.png | Bin 0 -> 3350 bytes .../modelviews/pathview/pics/AudioPlayer_48.png | Bin 0 -> 3806 bytes .../qml/modelviews/pathview/pics/Camera_48.png | Bin 0 -> 3540 bytes .../qml/modelviews/pathview/pics/DateBook_48.png | Bin 0 -> 2610 bytes examples/qml/modelviews/pathview/pics/EMail_48.png | Bin 0 -> 3655 bytes .../qml/modelviews/pathview/pics/TodoList_48.png | Bin 0 -> 3429 bytes .../modelviews/pathview/pics/VideoPlayer_48.png | Bin 0 -> 4151 bytes examples/qml/modelviews/stringlistmodel/main.cpp | 77 + .../modelviews/stringlistmodel/stringlistmodel.pro | 4 + .../modelviews/stringlistmodel/stringlistmodel.qrc | 5 + examples/qml/modelviews/stringlistmodel/view.qml | 54 + .../modelviews/visualdatamodel/dragselection.qml | 200 + .../qml/modelviews/visualdatamodel/slideshow.qml | 156 + .../qml/modelviews/visualdatamodel/sortedmodel.qml | 141 + .../visualdatamodel/visualdatamodel.qmlproject | 14 + .../modelviews/visualitemmodel/visualitemmodel.qml | 115 + examples/qml/openglunderqml/main.cpp | 60 + examples/qml/openglunderqml/main.qml | 78 + examples/qml/openglunderqml/openglunderqml.pro | 6 + examples/qml/openglunderqml/squircle.cpp | 123 + examples/qml/openglunderqml/squircle.h | 76 + examples/qml/painteditem/painteditem.pro | 5 + examples/qml/painteditem/smile/main.cpp | 96 + examples/qml/painteditem/smile/smile.pro | 11 + examples/qml/painteditem/smile/smile.qml | 132 + .../textballoons/TextBalloonPlugin/plugin.h | 56 + .../textballoons/TextBalloonPlugin/qmldir | 1 + .../qml/painteditem/textballoons/textballoon.cpp | 92 + .../qml/painteditem/textballoons/textballoon.h | 68 + .../qml/painteditem/textballoons/textballoons.pro | 23 + .../qml/painteditem/textballoons/textballoons.qml | 110 + examples/qml/particles/affectors/age.qml | 97 + examples/qml/particles/affectors/attractor.qml | 213 + .../qml/particles/affectors/customaffector.qml | 173 + examples/qml/particles/affectors/friction.qml | 109 + examples/qml/particles/affectors/gravity.qml | 103 + examples/qml/particles/affectors/groupgoal.qml | 193 + examples/qml/particles/affectors/move.qml | 141 + examples/qml/particles/affectors/spritegoal.qml | 212 + examples/qml/particles/affectors/turbulence.qml | 135 + examples/qml/particles/affectors/wander.qml | 95 + .../qml/particles/customparticle/blurparticles.qml | 140 + .../particles/customparticle/fragmentshader.qml | 115 + .../qml/particles/customparticle/imagecolors.qml | 118 + examples/qml/particles/emitters/burstandpulse.qml | 84 + examples/qml/particles/emitters/customemitter.qml | 92 + examples/qml/particles/emitters/emitmask.qml | 72 + examples/qml/particles/emitters/maximumemitted.qml | 81 + .../qml/particles/emitters/shapeanddirection.qml | 112 + .../qml/particles/emitters/timedgroupchanges.qml | 121 + examples/qml/particles/emitters/trailemitter.qml | 175 + .../qml/particles/emitters/velocityfrommotion.qml | 311 + .../particles/exampleslauncher/content/Button.qml | 73 + .../particles/exampleslauncher/content/Shell.qml | 78 + .../particles/exampleslauncher/content/launcher.js | 8 + .../exampleslauncher/exampleslauncher.qml | 116 + examples/qml/particles/imageparticle/allatonce.qml | 98 + examples/qml/particles/imageparticle/colored.qml | 86 + .../qml/particles/imageparticle/colortable.qml | 84 + .../qml/particles/imageparticle/deformation.qml | 121 + examples/qml/particles/imageparticle/rotation.qml | 71 + examples/qml/particles/imageparticle/sharing.qml | 199 + examples/qml/particles/imageparticle/sprites.qml | 116 + examples/qml/particles/images/_explo.png | Bin 0 -> 81528 bytes examples/qml/particles/images/backgroundLeaves.jpg | Bin 0 -> 78665 bytes examples/qml/particles/images/bear_tiles.png | Bin 0 -> 40349 bytes examples/qml/particles/images/candle.png | Bin 0 -> 1348 bytes examples/qml/particles/images/colortable.png | Bin 0 -> 704 bytes examples/qml/particles/images/finalfrontier.png | Bin 0 -> 695061 bytes examples/qml/particles/images/flower.png | Bin 0 -> 4683 bytes .../particles/images/launcherIcons/allatonce.png | Bin 0 -> 7075 bytes .../particles/images/launcherIcons/attractor.png | Bin 0 -> 31296 bytes .../images/launcherIcons/blurparticles.png | Bin 0 -> 19109 bytes .../qml/particles/images/launcherIcons/close.png | Bin 0 -> 2144 bytes .../particles/images/launcherIcons/colortable.png | Bin 0 -> 6538 bytes .../images/launcherIcons/customaffector.png | Bin 0 -> 10350 bytes .../images/launcherIcons/customemitter.png | Bin 0 -> 22967 bytes .../particles/images/launcherIcons/deformation.png | Bin 0 -> 2870 bytes .../particles/images/launcherIcons/delegates.png | Bin 0 -> 1892 bytes .../images/launcherIcons/dynamicemitters.png | Bin 0 -> 9347 bytes .../particles/images/launcherIcons/emitmask.png | Bin 0 -> 45055 bytes .../qml/particles/images/launcherIcons/flickr.png | Bin 0 -> 10542 bytes .../images/launcherIcons/fragmentshader.png | Bin 0 -> 22294 bytes .../images/launcherIcons/gridsplosion.png | Bin 0 -> 8154 bytes .../particles/images/launcherIcons/groupgoal.png | Bin 0 -> 7173 bytes .../particles/images/launcherIcons/imagecolors.png | Bin 0 -> 56647 bytes .../qml/particles/images/launcherIcons/list.png | Bin 0 -> 32912 bytes .../images/launcherIcons/maximumemitted.png | Bin 0 -> 1019 bytes .../images/launcherIcons/multiplepainters.png | Bin 0 -> 8572 bytes .../qml/particles/images/launcherIcons/package.png | Bin 0 -> 3163 bytes .../images/launcherIcons/particleview.png | Bin 0 -> 26560 bytes .../images/launcherIcons/plasmapatrol.png | Bin 0 -> 9839 bytes .../qml/particles/images/launcherIcons/remove.png | Bin 0 -> 2144 bytes .../particles/images/launcherIcons/rotation.png | Bin 0 -> 20661 bytes .../particles/images/launcherIcons/samegame.png | Bin 0 -> 8647 bytes .../images/launcherIcons/shapeanddirection.png | Bin 0 -> 11359 bytes .../images/launcherIcons/spaceexplorer.png | Bin 0 -> 9152 bytes .../particles/images/launcherIcons/spritegoal.png | Bin 0 -> 35579 bytes .../qml/particles/images/launcherIcons/sprites.png | Bin 0 -> 17009 bytes .../images/launcherIcons/spritevariedparticles.png | Bin 0 -> 2569 bytes .../particles/images/launcherIcons/startstop.png | Bin 0 -> 13670 bytes .../images/launcherIcons/timedgroupchanges.png | Bin 0 -> 16139 bytes .../images/launcherIcons/trailemitter.png | Bin 0 -> 5371 bytes .../qml/particles/images/launcherIcons/trails.png | Bin 0 -> 23168 bytes .../particles/images/launcherIcons/turbulence.png | Bin 0 -> 9684 bytes .../images/launcherIcons/velocityfrommotion.png | Bin 0 -> 36360 bytes .../qml/particles/images/launcherIcons/wander.png | Bin 0 -> 5858 bytes examples/qml/particles/images/matchmask.png | Bin 0 -> 2369 bytes examples/qml/particles/images/meteor.png | Bin 0 -> 83169 bytes examples/qml/particles/images/meteor_explo.png | Bin 0 -> 219946 bytes examples/qml/particles/images/meteors.png | Bin 0 -> 132137 bytes examples/qml/particles/images/nullRock.png | Bin 0 -> 140 bytes examples/qml/particles/images/particle.png | Bin 0 -> 861 bytes examples/qml/particles/images/particle2.png | Bin 0 -> 3909 bytes examples/qml/particles/images/particle3.png | Bin 0 -> 3186 bytes examples/qml/particles/images/particle4.png | Bin 0 -> 1799 bytes examples/qml/particles/images/particleA.png | Bin 0 -> 3541 bytes examples/qml/particles/images/portal_bg.png | Bin 0 -> 96858 bytes examples/qml/particles/images/realLeaf1.png | Bin 0 -> 15625 bytes examples/qml/particles/images/realLeaf2.png | Bin 0 -> 13660 bytes examples/qml/particles/images/realLeaf3.png | Bin 0 -> 23809 bytes examples/qml/particles/images/realLeaf4.png | Bin 0 -> 23655 bytes examples/qml/particles/images/rocket.png | Bin 0 -> 7315 bytes examples/qml/particles/images/rocket2.png | Bin 0 -> 1918 bytes examples/qml/particles/images/sizeInOut.png | Bin 0 -> 251 bytes examples/qml/particles/images/snowflake.png | Bin 0 -> 189327 bytes examples/qml/particles/images/sparkleSize.png | Bin 0 -> 378 bytes examples/qml/particles/images/star.png | Bin 0 -> 1550 bytes examples/qml/particles/images/starfish_0.png | Bin 0 -> 15972 bytes examples/qml/particles/images/starfish_1.png | Bin 0 -> 15746 bytes examples/qml/particles/images/starfish_2.png | Bin 0 -> 16067 bytes examples/qml/particles/images/starfish_3.png | Bin 0 -> 16201 bytes examples/qml/particles/images/starfish_4.png | Bin 0 -> 14698 bytes examples/qml/particles/images/starfish_mask.png | Bin 0 -> 11301 bytes .../particles/itemparticle/content/Delegate.qml | 88 + .../particles/itemparticle/content/Delegate2.qml | 79 + .../itemparticle/content/ExpandingDelegate.qml | 204 + .../particles/itemparticle/content/RssModel.qml | 56 + .../qml/particles/itemparticle/content/bubble.png | Bin 0 -> 3413 bytes .../qml/particles/itemparticle/content/script.js | 27 + examples/qml/particles/itemparticle/delegates.qml | 91 + .../qml/particles/itemparticle/particleview.qml | 274 + .../particles/plasmapatrol/PlasmaPatrol.qmlproject | 19 + examples/qml/particles/plasmapatrol/TODO | 10 + .../plasmapatrol/content/BlasterHardpoint.qml | 133 + .../qml/particles/plasmapatrol/content/Button.qml | 66 + .../plasmapatrol/content/CannonHardpoint.qml | 97 + .../particles/plasmapatrol/content/ChoiceBox.qml | 105 + .../qml/particles/plasmapatrol/content/Cruiser.qml | 146 + .../qml/particles/plasmapatrol/content/Frigate.qml | 114 + .../particles/plasmapatrol/content/Hardpoint.qml | 114 + .../particles/plasmapatrol/content/HelpScreens.qml | 268 + .../plasmapatrol/content/LaserHardpoint.qml | 108 + .../plasmapatrol/content/PlasmaPatrolParticles.qml | 173 + .../plasmapatrol/content/SequentialLoader.qml | 54 + .../qml/particles/plasmapatrol/content/Ship.qml | 114 + .../qml/particles/plasmapatrol/content/Sloop.qml | 108 + .../plasmapatrol/content/pics/TitleText.png | Bin 0 -> 1109 bytes .../plasmapatrol/content/pics/blur-circle2.png | Bin 0 -> 3627 bytes .../plasmapatrol/content/pics/blur-circle3.png | Bin 0 -> 5148 bytes .../plasmapatrol/content/pics/finalfrontier.png | Bin 0 -> 695061 bytes .../particles/plasmapatrol/content/pics/meteor.png | Bin 0 -> 83169 bytes .../plasmapatrol/content/pics/meteor_explo.png | Bin 0 -> 81528 bytes .../plasmapatrol/content/pics/nullRock.png | Bin 0 -> 140 bytes .../plasmapatrol/content/pics/particle.png | Bin 0 -> 861 bytes .../particles/plasmapatrol/content/pics/star.png | Bin 0 -> 1550 bytes .../particles/plasmapatrol/content/pics/star2.png | Bin 0 -> 6507 bytes .../particles/plasmapatrol/content/pics/star3.png | Bin 0 -> 4602 bytes .../qml/particles/plasmapatrol/plasmapatrol.qml | 386 + .../qml/particles/simple/dynamiccomparison.qml | 126 + examples/qml/particles/simple/dynamicemitters.qml | 122 + examples/qml/particles/simple/multiplepainters.qml | 90 + examples/qml/particles/simple/startstop.qml | 81 + .../photoviewer/PhotoViewerCore/AlbumDelegate.qml | 147 + .../photoviewer/PhotoViewerCore/BusyIndicator.qml | 50 + .../qml/photoviewer/PhotoViewerCore/Button.qml | 72 + .../photoviewer/PhotoViewerCore/EditableButton.qml | 86 + .../photoviewer/PhotoViewerCore/PhotoDelegate.qml | 188 + .../photoviewer/PhotoViewerCore/ProgressBar.qml | 57 + .../qml/photoviewer/PhotoViewerCore/RssModel.qml | 57 + examples/qml/photoviewer/PhotoViewerCore/Tag.qml | 91 + .../PhotoViewerCore/images/box-shadow.png | Bin 0 -> 588 bytes .../photoviewer/PhotoViewerCore/images/busy.png | Bin 0 -> 2629 bytes .../PhotoViewerCore/images/cardboard.png | Bin 0 -> 8844 bytes examples/qml/photoviewer/PhotoViewerCore/qmldir | 8 + .../photoviewer/PhotoViewerCore/script/script.js | 27 + examples/qml/photoviewer/i18n/base.ts | 30 + examples/qml/photoviewer/i18n/qml_fr.qm | Bin 0 -> 268 bytes examples/qml/photoviewer/i18n/qml_fr.ts | 30 + examples/qml/photoviewer/photoviewer.qml | 110 + examples/qml/photoviewer/photoviewer.qmlproject | 20 + examples/qml/positioners/content/Button.qml | 78 + examples/qml/positioners/content/add.png | Bin 0 -> 810 bytes examples/qml/positioners/content/del.png | Bin 0 -> 488 bytes .../positioners/positioners-attachedproperties.qml | 106 + examples/qml/positioners/positioners.qml | 264 + examples/qml/qml.pro | 38 + .../layoutdirection/layoutdirection.qml | 246 + .../layoutdirection/layoutdirection.qmlproject | 16 + .../layoutmirroring/layoutmirroring.qml | 313 + .../layoutmirroring/layoutmirroring.qmlproject | 16 + .../righttoleft/textalignment/textalignment.qml | 427 + .../textalignment/textalignment.qmlproject | 16 + examples/qml/rssnews/content/BusyIndicator.qml | 53 + examples/qml/rssnews/content/CategoryDelegate.qml | 82 + examples/qml/rssnews/content/NewsDelegate.qml | 71 + examples/qml/rssnews/content/RssFeeds.qml | 59 + examples/qml/rssnews/content/ScrollBar.qml | 107 + examples/qml/rssnews/content/images/busy.png | Bin 0 -> 2629 bytes examples/qml/rssnews/content/images/scrollbar.png | Bin 0 -> 161 bytes examples/qml/rssnews/rssnews.qml | 112 + examples/qml/rssnews/rssnews.qmlproject | 16 + examples/qml/samegame/content/BoomBlock.qml | 112 + examples/qml/samegame/content/Button.qml | 75 + examples/qml/samegame/content/Dialog.qml | 81 + examples/qml/samegame/content/GameArea.qml | 92 + examples/qml/samegame/content/NameInputDialog.qml | 93 + examples/qml/samegame/content/pics/background.png | Bin 0 -> 313930 bytes examples/qml/samegame/content/pics/blueStone.png | Bin 0 -> 3054 bytes examples/qml/samegame/content/pics/greenStone.png | Bin 0 -> 2932 bytes examples/qml/samegame/content/pics/particle.png | Bin 0 -> 861 bytes examples/qml/samegame/content/pics/redStone.png | Bin 0 -> 2902 bytes examples/qml/samegame/content/pics/yellowStone.png | Bin 0 -> 3056 bytes examples/qml/samegame/content/samegame.js | 290 + examples/qml/samegame/samegame.qml | 87 + examples/qml/samegame/samegame.qmlproject | 16 + examples/qml/script/script.pro | 4 + examples/qml/script/shell/main.cpp | 153 + examples/qml/script/shell/shell.pro | 7 + examples/qml/shadereffects/content/Slider.qml | 93 + examples/qml/shadereffects/content/face-smile.png | Bin 0 -> 15408 bytes examples/qml/shadereffects/content/qt-logo.png | Bin 0 -> 13923 bytes examples/qml/shadereffects/shadereffects.qml | 300 + examples/qml/shared/Button.qml | 64 + examples/qml/shared/LauncherList.qml | 101 + examples/qml/shared/README | 11 + examples/qml/shared/SimpleLauncherDelegate.qml | 53 + examples/qml/shared/back.png | Bin 0 -> 404 bytes examples/qml/snake/content/Button.qml | 66 + examples/qml/snake/content/Cookie.qml | 102 + examples/qml/snake/content/HighScoreModel.qml | 140 + examples/qml/snake/content/Link.qml | 129 + examples/qml/snake/content/Skull.qml | 62 + examples/qml/snake/content/pics/README | 1 + examples/qml/snake/content/pics/background.png | Bin 0 -> 144508 bytes examples/qml/snake/content/pics/blueStar.png | Bin 0 -> 272 bytes examples/qml/snake/content/pics/blueStone.png | Bin 0 -> 3139 bytes examples/qml/snake/content/pics/cookie.png | Bin 0 -> 2729 bytes examples/qml/snake/content/pics/eyes.svg | 118 + examples/qml/snake/content/pics/head.png | Bin 0 -> 3473 bytes examples/qml/snake/content/pics/pause.png | Bin 0 -> 4327 bytes examples/qml/snake/content/pics/redStar.png | Bin 0 -> 273 bytes examples/qml/snake/content/pics/redStone.png | Bin 0 -> 3456 bytes examples/qml/snake/content/pics/skull.png | Bin 0 -> 2543 bytes examples/qml/snake/content/pics/snake.jpg | Bin 0 -> 663901 bytes examples/qml/snake/content/pics/star.png | Bin 0 -> 262 bytes examples/qml/snake/content/pics/stoneShadow.png | Bin 0 -> 1699 bytes examples/qml/snake/content/pics/yellowStar.png | Bin 0 -> 276 bytes examples/qml/snake/content/pics/yellowStone.png | Bin 0 -> 2667 bytes examples/qml/snake/content/snake.js | 316 + examples/qml/snake/snake.qml | 272 + examples/qml/snake/snake.qmlproject | 16 + examples/qml/sqllocalstorage/hello.qml | 78 + examples/qml/text/fonts/availableFonts.qml | 57 + examples/qml/text/fonts/banner.qml | 61 + .../qml/text/fonts/content/fonts/tarzeau_ocr_a.ttf | Bin 0 -> 24544 bytes examples/qml/text/fonts/fonts.qml | 104 + examples/qml/text/fonts/hello.qml | 79 + examples/qml/text/imgtag/TextWithImage.qml | 55 + examples/qml/text/imgtag/images/face-sad.png | Bin 0 -> 6148 bytes examples/qml/text/imgtag/images/face-smile-big.png | Bin 0 -> 6058 bytes examples/qml/text/imgtag/images/face-smile.png | Bin 0 -> 6446 bytes examples/qml/text/imgtag/images/heart200.png | Bin 0 -> 8248 bytes examples/qml/text/imgtag/images/qtlogo.png | Bin 0 -> 6450 bytes examples/qml/text/imgtag/images/starfish_2.png | Bin 0 -> 18243 bytes examples/qml/text/imgtag/imgtag.qml | 101 + examples/qml/text/styledtext-layout.qml | 107 + examples/qml/text/text.qml | 57 + examples/qml/text/text.qmlproject | 16 + examples/qml/text/textselection/pics/endHandle.png | Bin 0 -> 185 bytes examples/qml/text/textselection/pics/endHandle.sci | 5 + .../qml/text/textselection/pics/startHandle.png | Bin 0 -> 178 bytes .../qml/text/textselection/pics/startHandle.sci | 5 + examples/qml/text/textselection/textselection.qml | 211 + .../qml/threading/threadedlistmodel/dataloader.js | 49 + .../threadedlistmodel/threadedlistmodel.qmlproject | 56 + .../threading/threadedlistmodel/timedisplay.qml | 76 + .../qml/threading/workerscript/workerscript.js | 15 + .../qml/threading/workerscript/workerscript.qml | 83 + .../threading/workerscript/workerscript.qmlproject | 16 + .../mousearea/mousearea-example.qml | 176 + .../touchinteraction/multipointtouch/bearwhack.qml | 133 + .../content/AugmentedTouchPoint.qml | 70 + .../multipointtouch/content/Bear0.png | Bin 0 -> 15163 bytes .../multipointtouch/content/Bear1.png | Bin 0 -> 99378 bytes .../multipointtouch/content/Bear2.png | Bin 0 -> 80759 bytes .../multipointtouch/content/Bear3.png | Bin 0 -> 21122 bytes .../multipointtouch/content/BearB.png | Bin 0 -> 18667 bytes .../content/BearWhackParticleSystem.qml | 180 + .../multipointtouch/content/ParticleFlame.qml | 65 + .../multipointtouch/content/blur-circle.png | Bin 0 -> 4279 bytes .../multipointtouch/content/blur-circle3.png | Bin 0 -> 5148 bytes .../multipointtouch/content/heart-blur.png | Bin 0 -> 5406 bytes .../multipointtouch/content/title.png | Bin 0 -> 81252 bytes .../multipointtouch/multiflame.qml | 91 + .../qml/touchinteraction/pincharea/flickresize.qml | 97 + .../qml/touchinteraction/pincharea/qt-logo.jpg | Bin 0 -> 40886 bytes examples/qml/touchinteraction/touchinteraction.qml | 57 + .../touchinteraction/touchinteraction.qmlproject | 16 + examples/qml/toys/clocks/clocks.qml | 88 + examples/qml/toys/clocks/content/Clock.qml | 143 + examples/qml/toys/clocks/content/QuitButton.qml | 52 + examples/qml/toys/clocks/content/arrow.png | Bin 0 -> 692 bytes examples/qml/toys/clocks/content/background.png | Bin 0 -> 46895 bytes examples/qml/toys/clocks/content/center.png | Bin 0 -> 765 bytes examples/qml/toys/clocks/content/clock-night.png | Bin 0 -> 23359 bytes examples/qml/toys/clocks/content/clock.png | Bin 0 -> 20653 bytes examples/qml/toys/clocks/content/hour.png | Bin 0 -> 625 bytes examples/qml/toys/clocks/content/minute.png | Bin 0 -> 625 bytes examples/qml/toys/clocks/content/quit.png | Bin 0 -> 583 bytes examples/qml/toys/clocks/content/second.png | Bin 0 -> 303 bytes examples/qml/toys/corkboards/content/Day.qml | 153 + examples/qml/toys/corkboards/content/cork.jpg | Bin 0 -> 149337 bytes .../qml/toys/corkboards/content/note-yellow.png | Bin 0 -> 54559 bytes examples/qml/toys/corkboards/content/tack.png | Bin 0 -> 7282 bytes examples/qml/toys/corkboards/corkboards.qml | 116 + examples/qml/toys/dynamicscene/content/Button.qml | 80 + .../toys/dynamicscene/content/GenericSceneItem.qml | 49 + .../qml/toys/dynamicscene/content/PaletteItem.qml | 59 + .../toys/dynamicscene/content/PerspectiveItem.qml | 65 + examples/qml/toys/dynamicscene/content/Sun.qml | 78 + examples/qml/toys/dynamicscene/content/images/NOTE | 1 + .../dynamicscene/content/images/face-smile.png | Bin 0 -> 15408 bytes .../qml/toys/dynamicscene/content/images/moon.png | Bin 0 -> 1757 bytes .../dynamicscene/content/images/rabbit_brown.png | Bin 0 -> 1245 bytes .../toys/dynamicscene/content/images/rabbit_bw.png | Bin 0 -> 1759 bytes .../qml/toys/dynamicscene/content/images/star.png | Bin 0 -> 349 bytes .../qml/toys/dynamicscene/content/images/sun.png | Bin 0 -> 8153 bytes .../toys/dynamicscene/content/images/tree_s.png | Bin 0 -> 3406 bytes .../qml/toys/dynamicscene/content/itemCreation.js | 62 + examples/qml/toys/dynamicscene/dynamicscene.qml | 275 + examples/qml/toys/tic-tac-toe/content/Button.qml | 79 + examples/qml/toys/tic-tac-toe/content/TicTac.qml | 60 + .../qml/toys/tic-tac-toe/content/pics/board.png | Bin 0 -> 12258 bytes examples/qml/toys/tic-tac-toe/content/pics/o.png | Bin 0 -> 1470 bytes examples/qml/toys/tic-tac-toe/content/pics/x.png | Bin 0 -> 1331 bytes .../qml/toys/tic-tac-toe/content/tic-tac-toe.js | 149 + examples/qml/toys/tic-tac-toe/tic-tac-toe.qml | 123 + examples/qml/toys/tvtennis/tvtennis.qml | 109 + .../dynamicview/dynamicview1/PetsModel.qml | 102 + .../dynamicview/dynamicview1/dynamicview.qml | 90 + .../dynamicview/dynamicview2/PetsModel.qml | 98 + .../dynamicview/dynamicview2/dynamicview.qml | 121 + .../dynamicview/dynamicview3/PetsModel.qml | 98 + .../dynamicview/dynamicview3/dynamicview.qml | 143 + .../dynamicview/dynamicview4/ListSelector.qml | 120 + .../dynamicview/dynamicview4/PetsModel.qml | 98 + .../dynamicview/dynamicview4/dynamicview.qml | 219 + .../tutorials/extending/chapter1-basics/app.qml | 60 + .../extending/chapter1-basics/chapter1-basics.pro | 5 + .../tutorials/extending/chapter1-basics/main.cpp | 57 + .../extending/chapter1-basics/piechart.cpp | 79 + .../tutorials/extending/chapter1-basics/piechart.h | 71 + .../tutorials/extending/chapter2-methods/app.qml | 66 + .../chapter2-methods/chapter2-methods.pro | 5 + .../tutorials/extending/chapter2-methods/main.cpp | 57 + .../extending/chapter2-methods/piechart.cpp | 84 + .../extending/chapter2-methods/piechart.h | 84 + .../tutorials/extending/chapter3-bindings/app.qml | 74 + .../chapter3-bindings/chapter3-bindings.pro | 5 + .../tutorials/extending/chapter3-bindings/main.cpp | 57 + .../extending/chapter3-bindings/piechart.cpp | 86 + .../extending/chapter3-bindings/piechart.h | 84 + .../extending/chapter4-customPropertyTypes/app.qml | 60 + .../chapter4-customPropertyTypes.pro | 7 + .../chapter4-customPropertyTypes/main.cpp | 66 + .../chapter4-customPropertyTypes/piechart.cpp | 70 + .../chapter4-customPropertyTypes/piechart.h | 78 + .../chapter4-customPropertyTypes/pieslice.cpp | 66 + .../chapter4-customPropertyTypes/pieslice.h | 66 + .../extending/chapter5-listproperties/app.qml | 70 + .../chapter5-listproperties.pro | 7 + .../extending/chapter5-listproperties/main.cpp | 58 + .../extending/chapter5-listproperties/piechart.cpp | 72 + .../extending/chapter5-listproperties/piechart.h | 75 + .../extending/chapter5-listproperties/pieslice.cpp | 86 + .../extending/chapter5-listproperties/pieslice.h | 76 + .../extending/chapter6-plugins/ChartsPlugin/qmldir | 1 + .../tutorials/extending/chapter6-plugins/app.qml | 69 + .../chapter6-plugins/chapter6-plugins.pro | 18 + .../extending/chapter6-plugins/chartsplugin.cpp | 54 + .../extending/chapter6-plugins/chartsplugin.h | 55 + .../extending/chapter6-plugins/piechart.cpp | 71 + .../extending/chapter6-plugins/piechart.h | 69 + .../extending/chapter6-plugins/pieslice.cpp | 86 + .../extending/chapter6-plugins/pieslice.h | 74 + examples/qml/tutorials/extending/extending.pro | 10 + examples/qml/tutorials/helloworld/Cell.qml | 72 + examples/qml/tutorials/helloworld/tutorial1.qml | 63 + examples/qml/tutorials/helloworld/tutorial2.qml | 72 + examples/qml/tutorials/helloworld/tutorial3.qml | 91 + .../qml/tutorials/samegame/samegame1/Block.qml | 53 + .../qml/tutorials/samegame/samegame1/Button.qml | 83 + .../qml/tutorials/samegame/samegame1/samegame.qml | 82 + .../samegame/samegame1/samegame1.qmlproject | 16 + .../qml/tutorials/samegame/samegame2/Block.qml | 51 + .../qml/tutorials/samegame/samegame2/Button.qml | 81 + .../qml/tutorials/samegame/samegame2/samegame.js | 63 + .../qml/tutorials/samegame/samegame2/samegame.qml | 85 + .../samegame/samegame2/samegame2.qmlproject | 16 + .../qml/tutorials/samegame/samegame3/Block.qml | 63 + .../qml/tutorials/samegame/samegame3/Button.qml | 81 + .../qml/tutorials/samegame/samegame3/Dialog.qml | 71 + .../qml/tutorials/samegame/samegame3/samegame.js | 174 + .../qml/tutorials/samegame/samegame3/samegame.qml | 109 + .../samegame/samegame3/samegame3.qmlproject | 16 + .../samegame/samegame4/content/BoomBlock.qml | 122 + .../samegame/samegame4/content/Button.qml | 81 + .../samegame/samegame4/content/Dialog.qml | 107 + .../samegame/samegame4/content/samegame.js | 226 + .../tutorials/samegame/samegame4/highscores/README | 1 + .../samegame/samegame4/highscores/score_data.xml | 2 + .../samegame/samegame4/highscores/score_style.xsl | 28 + .../samegame/samegame4/highscores/scores.php | 31 + .../qml/tutorials/samegame/samegame4/samegame.qml | 115 + .../samegame/samegame4/samegame4.qmlproject | 16 + .../tutorials/samegame/shared/pics/background.jpg | Bin 0 -> 36473 bytes .../tutorials/samegame/shared/pics/blueStar.png | Bin 0 -> 278 bytes .../tutorials/samegame/shared/pics/blueStone.png | Bin 0 -> 3054 bytes .../tutorials/samegame/shared/pics/greenStar.png | Bin 0 -> 273 bytes .../tutorials/samegame/shared/pics/greenStone.png | Bin 0 -> 2932 bytes .../qml/tutorials/samegame/shared/pics/redStar.png | Bin 0 -> 274 bytes .../tutorials/samegame/shared/pics/redStone.png | Bin 0 -> 2902 bytes .../qml/tutorials/samegame/shared/pics/star.png | Bin 0 -> 262 bytes .../tutorials/samegame/shared/pics/yellowStone.png | Bin 0 -> 3056 bytes examples/qml/tutorials/tutorials.pro | 5 + examples/qml/tutorials/tutorials.qmlproject | 14 + examples/qml/twitter/TwitterCore/Button.qml | 90 + examples/qml/twitter/TwitterCore/FatDelegate.qml | 105 + examples/qml/twitter/TwitterCore/Input.qml | 65 + examples/qml/twitter/TwitterCore/Loading.qml | 49 + examples/qml/twitter/TwitterCore/MultiTitleBar.qml | 60 + examples/qml/twitter/TwitterCore/RssModel.qml | 80 + examples/qml/twitter/TwitterCore/SearchView.qml | 124 + examples/qml/twitter/TwitterCore/TitleBar.qml | 130 + examples/qml/twitter/TwitterCore/ToolBar.qml | 64 + examples/qml/twitter/TwitterCore/UserModel.qml | 66 + examples/qml/twitter/TwitterCore/images/gloss.png | Bin 0 -> 1236 bytes .../qml/twitter/TwitterCore/images/lineedit.png | Bin 0 -> 1415 bytes .../qml/twitter/TwitterCore/images/lineedit.sci | 5 + .../qml/twitter/TwitterCore/images/loading.png | Bin 0 -> 813 bytes examples/qml/twitter/TwitterCore/images/quit.png | Bin 0 -> 2369 bytes .../qml/twitter/TwitterCore/images/stripes.png | Bin 0 -> 257 bytes .../qml/twitter/TwitterCore/images/titlebar.png | Bin 0 -> 1436 bytes .../qml/twitter/TwitterCore/images/titlebar.sci | 5 + .../qml/twitter/TwitterCore/images/toolbutton.png | Bin 0 -> 2550 bytes .../qml/twitter/TwitterCore/images/toolbutton.sci | 5 + examples/qml/twitter/TwitterCore/qmldir | 10 + examples/qml/twitter/twitter.qml | 135 + examples/qml/twitter/twitter.qmlproject | 16 + .../qml/ui-components/dialcontrol/content/Dial.qml | 86 + .../dialcontrol/content/QuitButton.qml | 52 + .../dialcontrol/content/background.png | Bin 0 -> 35876 bytes .../ui-components/dialcontrol/content/needle.png | Bin 0 -> 342 bytes .../dialcontrol/content/needle_shadow.png | Bin 0 -> 632 bytes .../ui-components/dialcontrol/content/overlay.png | Bin 0 -> 3564 bytes .../qml/ui-components/dialcontrol/content/quit.png | Bin 0 -> 583 bytes .../qml/ui-components/dialcontrol/dialcontrol.qml | 98 + .../qml/ui-components/flipable/content/5_heart.png | Bin 0 -> 3872 bytes .../qml/ui-components/flipable/content/9_club.png | Bin 0 -> 6135 bytes .../qml/ui-components/flipable/content/Card.qml | 80 + .../qml/ui-components/flipable/content/back.png | Bin 0 -> 1418 bytes examples/qml/ui-components/flipable/flipable.qml | 55 + .../progressbar/content/ProgressBar.qml | 83 + .../progressbar/content/background.png | Bin 0 -> 426 bytes examples/qml/ui-components/progressbar/main.qml | 73 + examples/qml/ui-components/scrollbar/ScrollBar.qml | 74 + examples/qml/ui-components/scrollbar/main.qml | 93 + .../ui-components/scrollbar/pics/niagara_falls.jpg | Bin 0 -> 142510 bytes .../ui-components/scrollbar/scrollbar.qmlproject | 16 + examples/qml/ui-components/searchbox/SearchBox.qml | 109 + .../qml/ui-components/searchbox/images/clear.png | Bin 0 -> 429 bytes .../searchbox/images/lineedit-bg-focus.png | Bin 0 -> 526 bytes .../ui-components/searchbox/images/lineedit-bg.png | Bin 0 -> 426 bytes examples/qml/ui-components/searchbox/main.qml | 60 + .../ui-components/searchbox/searchbox.qmlproject | 16 + .../ui-components/slideswitch/content/Switch.qml | 117 + .../slideswitch/content/background.png | Bin 0 -> 3091 bytes .../slideswitch/content/background.svg | 23 + .../qml/ui-components/slideswitch/content/knob.png | Bin 0 -> 3101 bytes .../qml/ui-components/slideswitch/content/knob.svg | 867 ++ .../qml/ui-components/slideswitch/slideswitch.qml | 51 + .../qml/ui-components/spinner/content/Spinner.qml | 70 + .../ui-components/spinner/content/spinner-bg.png | Bin 0 -> 345 bytes .../spinner/content/spinner-select.png | Bin 0 -> 320 bytes examples/qml/ui-components/spinner/main.qml | 61 + .../qml/ui-components/spinner/spinner.qmlproject | 16 + examples/qml/ui-components/tabwidget/TabWidget.qml | 102 + examples/qml/ui-components/tabwidget/main.qml | 99 + examples/qml/ui-components/tabwidget/tab.png | Bin 0 -> 507 bytes .../ui-components/tabwidget/tabwidget.qmlproject | 16 + examples/qml/window/Window.qml | 58 + examples/qml/window/screen/screenInfo.qml | 90 + examples/qml/window/standalone.qml | 71 + examples/qml/window/window.cpp | 58 + examples/qml/window/window.pro | 5 + examples/qml/xml/xmlhttprequest/data.xml | 5 + .../xml/xmlhttprequest/xmlhttprequest-example.qml | 95 + .../tutorials/gettingStartedQml/core/Button.qml | 2 +- .../tutorials/gettingStartedQml/core/EditMenu.qml | 2 +- .../gettingStartedQml/core/FileDialog.qml | 2 +- .../tutorials/gettingStartedQml/core/FileMenu.qml | 2 +- .../tutorials/gettingStartedQml/core/MenuBar.qml | 2 +- .../tutorials/gettingStartedQml/core/TextArea.qml | 2 +- .../gettingStartedQml/filedialog/dialogPlugin.cpp | 4 +- .../gettingStartedQml/filedialog/dialogPlugin.h | 8 +- .../gettingStartedQml/filedialog/directory.cpp | 16 +- .../gettingStartedQml/filedialog/directory.h | 8 +- .../gettingStartedQml/filedialog/file.cpp | 2 +- .../tutorials/gettingStartedQml/filedialog/file.h | 2 +- .../gettingStartedQml/filedialog/filedialog.pro | 2 +- .../gettingStartedQml/parts/part0/Button.qml | 2 +- .../gettingStartedQml/parts/part1/Button.qml | 2 +- .../gettingStartedQml/parts/part1/EditMenu.qml | 2 +- .../gettingStartedQml/parts/part1/FileMenu.qml | 2 +- .../gettingStartedQml/parts/part1/SimpleButton.qml | 2 +- .../gettingStartedQml/parts/part2/Button.qml | 2 +- .../gettingStartedQml/parts/part2/EditMenu.qml | 2 +- .../gettingStartedQml/parts/part2/FileMenu.qml | 2 +- .../gettingStartedQml/parts/part2/MenuBar.qml | 2 +- .../gettingStartedQml/parts/part3/Button.qml | 2 +- .../gettingStartedQml/parts/part3/EditMenu.qml | 2 +- .../gettingStartedQml/parts/part3/FileMenu.qml | 2 +- .../gettingStartedQml/parts/part3/MenuBar.qml | 2 +- .../gettingStartedQml/parts/part3/TextArea.qml | 2 +- .../gettingStartedQml/parts/part3/TextEditor.qml | 2 +- .../gettingStartedQml/parts/part4/Button.qml | 2 +- .../gettingStartedQml/parts/part4/EditMenu.qml | 2 +- .../gettingStartedQml/parts/part4/FileMenu.qml | 2 +- .../gettingStartedQml/parts/part4/MenuBar.qml | 2 +- .../gettingStartedQml/parts/part4/SimpleButton.qml | 2 +- .../gettingStartedQml/parts/part4/TextArea.qml | 2 +- .../gettingStartedQml/parts/part4/TextEditor.qml | 2 +- .../gettingStartedQml/parts/part5/TextEditor.qml | 2 +- .../gettingStartedQml/parts/part5/core/Button.qml | 2 +- .../parts/part5/core/EditMenu.qml | 2 +- .../parts/part5/core/FileDialog.qml | 2 +- .../parts/part5/core/FileMenu.qml | 2 +- .../gettingStartedQml/parts/part5/core/MenuBar.qml | 2 +- .../parts/part5/core/TextArea.qml | 2 +- .../parts/part5/filedialog/dialogPlugin.cpp | 6 +- .../parts/part5/filedialog/dialogPlugin.h | 8 +- .../parts/part5/filedialog/directory.cpp | 18 +- .../parts/part5/filedialog/directory.h | 8 +- .../parts/part5/filedialog/file.cpp | 2 +- .../parts/part5/filedialog/file.h | 2 +- .../parts/part5/filedialog/filedialog.pro | 2 +- .../tutorials/gettingStartedQml/texteditor.qml | 2 +- modules/qt_declarative.pri | 17 - modules/qt_qml.pri | 17 + modules/qt_qmltest.pri | 2 +- modules/qt_quick.pri | 2 +- src/declarative/animations/animations.pri | 16 - .../animations/qabstractanimationjob.cpp | 544 -- .../animations/qabstractanimationjob_p.h | 232 - src/declarative/animations/qanimationgroupjob.cpp | 164 - src/declarative/animations/qanimationgroupjob_p.h | 93 - src/declarative/animations/qanimationjobutil_p.h | 59 - .../animations/qparallelanimationgroupjob.cpp | 227 - .../animations/qparallelanimationgroupjob_p.h | 81 - src/declarative/animations/qpauseanimationjob.cpp | 71 - src/declarative/animations/qpauseanimationjob_p.h | 75 - .../animations/qsequentialanimationgroupjob.cpp | 388 - .../animations/qsequentialanimationgroupjob_p.h | 108 - src/declarative/debugger/debugger.pri | 32 - src/declarative/debugger/qdebugmessageservice.cpp | 124 - src/declarative/debugger/qdebugmessageservice_p.h | 91 - src/declarative/debugger/qdeclarativedebug.h | 66 - .../debugger/qdeclarativedebugclient.cpp | 421 - .../debugger/qdeclarativedebugclient_p.h | 131 - .../debugger/qdeclarativedebughelper.cpp | 70 - .../debugger/qdeclarativedebughelper_p.h | 86 - .../debugger/qdeclarativedebugserver.cpp | 539 -- .../debugger/qdeclarativedebugserver_p.h | 105 - .../debugger/qdeclarativedebugserverconnection_p.h | 84 - .../debugger/qdeclarativedebugservice.cpp | 268 - .../debugger/qdeclarativedebugservice_p.h | 113 - .../debugger/qdeclarativedebugservice_p_p.h | 82 - .../debugger/qdeclarativedebugstatesdelegate_p.h | 98 - .../debugger/qdeclarativeenginedebug.cpp | 1072 --- .../debugger/qdeclarativeenginedebug_p.h | 397 - .../debugger/qdeclarativeenginedebugservice.cpp | 733 -- .../debugger/qdeclarativeenginedebugservice_p.h | 136 - .../debugger/qdeclarativeinspectorinterface_p.h | 83 - .../debugger/qdeclarativeinspectorservice.cpp | 184 - .../debugger/qdeclarativeinspectorservice_p.h | 101 - .../debugger/qdeclarativeprofilerservice.cpp | 357 - .../debugger/qdeclarativeprofilerservice_p.h | 183 - src/declarative/debugger/qpacketprotocol.cpp | 550 -- src/declarative/debugger/qpacketprotocol_p.h | 137 - src/declarative/debugger/qv8debugservice.cpp | 294 - src/declarative/debugger/qv8debugservice_p.h | 105 - src/declarative/debugger/qv8profilerservice.cpp | 287 - src/declarative/debugger/qv8profilerservice_p.h | 119 - src/declarative/declarative.pro | 34 - src/declarative/qml/ftw/ftw.pri | 29 - src/declarative/qml/ftw/qbitfield_p.h | 165 - src/declarative/qml/ftw/qdeclarativepool.cpp | 92 - src/declarative/qml/ftw/qdeclarativepool_p.h | 278 - src/declarative/qml/ftw/qdeclarativerefcount_p.h | 192 - src/declarative/qml/ftw/qdeclarativethread.cpp | 359 - src/declarative/qml/ftw/qdeclarativethread_p.h | 318 - src/declarative/qml/ftw/qdeclarativetrace.cpp | 154 - src/declarative/qml/ftw/qdeclarativetrace_p.h | 294 - src/declarative/qml/ftw/qdeletewatcher_p.h | 113 - src/declarative/qml/ftw/qfastmetabuilder.cpp | 369 - src/declarative/qml/ftw/qfastmetabuilder_p.h | 206 - src/declarative/qml/ftw/qfieldlist_p.h | 426 - src/declarative/qml/ftw/qfinitestack_p.h | 186 - src/declarative/qml/ftw/qflagpointer_p.h | 338 - src/declarative/qml/ftw/qhashedstring.cpp | 490 -- src/declarative/qml/ftw/qhashedstring_p.h | 1418 --- src/declarative/qml/ftw/qhashfield_p.h | 120 - src/declarative/qml/ftw/qintrusivelist.cpp | 179 - src/declarative/qml/ftw/qintrusivelist_p.h | 274 - src/declarative/qml/ftw/qlazilyallocated_p.h | 146 - src/declarative/qml/ftw/qpodvector_p.h | 173 - src/declarative/qml/ftw/qpointervaluepair_p.h | 196 - src/declarative/qml/ftw/qrecursionwatcher_p.h | 105 - src/declarative/qml/ftw/qrecyclepool_p.h | 220 - src/declarative/qml/parser/parser.pri | 19 - src/declarative/qml/parser/qdeclarativejs.g | 3016 ------- src/declarative/qml/parser/qdeclarativejsast.cpp | 931 -- src/declarative/qml/parser/qdeclarativejsast_p.h | 2640 ------ .../qml/parser/qdeclarativejsastfwd_p.h | 186 - .../qml/parser/qdeclarativejsastvisitor.cpp | 58 - .../qml/parser/qdeclarativejsastvisitor_p.h | 329 - .../qml/parser/qdeclarativejsengine_p.cpp | 161 - .../qml/parser/qdeclarativejsengine_p.h | 126 - .../qml/parser/qdeclarativejsglobal_p.h | 69 - .../qml/parser/qdeclarativejsgrammar.cpp | 1013 --- .../qml/parser/qdeclarativejsgrammar_p.h | 211 - .../qml/parser/qdeclarativejskeywords_p.h | 860 -- src/declarative/qml/parser/qdeclarativejslexer.cpp | 1166 --- src/declarative/qml/parser/qdeclarativejslexer_p.h | 248 - .../qml/parser/qdeclarativejsmemorypool_p.h | 173 - .../qml/parser/qdeclarativejsparser.cpp | 1812 ---- .../qml/parser/qdeclarativejsparser_p.h | 248 - src/declarative/qml/qdeclarative.h | 451 - src/declarative/qml/qdeclarativeaccessors.cpp | 127 - src/declarative/qml/qdeclarativeaccessors_p.h | 165 - src/declarative/qml/qdeclarativeapplication.cpp | 124 - src/declarative/qml/qdeclarativeapplication_p.h | 87 - src/declarative/qml/qdeclarativebinding.cpp | 551 -- src/declarative/qml/qdeclarativebinding_p.h | 219 - src/declarative/qml/qdeclarativebinding_p_p.h | 89 - src/declarative/qml/qdeclarativeboundsignal.cpp | 300 - src/declarative/qml/qdeclarativeboundsignal_p.h | 103 - src/declarative/qml/qdeclarativecleanup.cpp | 118 - src/declarative/qml/qdeclarativecleanup_p.h | 87 - src/declarative/qml/qdeclarativecompileddata.cpp | 261 - src/declarative/qml/qdeclarativecompiler.cpp | 3882 --------- src/declarative/qml/qdeclarativecompiler_p.h | 466 - src/declarative/qml/qdeclarativecomponent.cpp | 1351 --- src/declarative/qml/qdeclarativecomponent.h | 138 - src/declarative/qml/qdeclarativecomponent_p.h | 129 - .../qml/qdeclarativecomponentattached_p.h | 85 - src/declarative/qml/qdeclarativecontext.cpp | 811 -- src/declarative/qml/qdeclarativecontext.h | 113 - src/declarative/qml/qdeclarativecontext_p.h | 334 - src/declarative/qml/qdeclarativecustomparser.cpp | 319 - src/declarative/qml/qdeclarativecustomparser_p.h | 168 - src/declarative/qml/qdeclarativecustomparser_p_p.h | 89 - src/declarative/qml/qdeclarativedata_p.h | 207 - src/declarative/qml/qdeclarativedirparser.cpp | 298 - src/declarative/qml/qdeclarativedirparser_p.h | 166 - src/declarative/qml/qdeclarativeengine.cpp | 1854 ---- src/declarative/qml/qdeclarativeengine.h | 138 - src/declarative/qml/qdeclarativeengine_p.h | 522 -- src/declarative/qml/qdeclarativeerror.cpp | 285 - src/declarative/qml/qdeclarativeerror.h | 85 - src/declarative/qml/qdeclarativeexpression.cpp | 982 --- src/declarative/qml/qdeclarativeexpression.h | 121 - src/declarative/qml/qdeclarativeexpression_p.h | 406 - .../qml/qdeclarativeextensioninterface.h | 75 - .../qml/qdeclarativeextensionplugin.cpp | 171 - src/declarative/qml/qdeclarativeextensionplugin.h | 77 - src/declarative/qml/qdeclarativeglobal_p.h | 131 - src/declarative/qml/qdeclarativeguard_p.h | 218 - src/declarative/qml/qdeclarativeimageprovider.cpp | 334 - src/declarative/qml/qdeclarativeimageprovider.h | 95 - src/declarative/qml/qdeclarativeimport.cpp | 1183 --- src/declarative/qml/qdeclarativeimport_p.h | 157 - src/declarative/qml/qdeclarativeincubator.cpp | 696 -- src/declarative/qml/qdeclarativeincubator.h | 129 - src/declarative/qml/qdeclarativeincubator_p.h | 106 - src/declarative/qml/qdeclarativeinfo.cpp | 192 - src/declarative/qml/qdeclarativeinfo.h | 103 - src/declarative/qml/qdeclarativeinstruction.cpp | 278 - src/declarative/qml/qdeclarativeinstruction_p.h | 558 -- src/declarative/qml/qdeclarativeintegercache.cpp | 82 - src/declarative/qml/qdeclarativeintegercache_p.h | 97 - src/declarative/qml/qdeclarativelist.cpp | 417 - src/declarative/qml/qdeclarativelist.h | 151 - src/declarative/qml/qdeclarativelist_p.h | 85 - src/declarative/qml/qdeclarativelistmodel.cpp | 2467 ------ src/declarative/qml/qdeclarativelistmodel_p.h | 199 - src/declarative/qml/qdeclarativelistmodel_p_p.h | 378 - .../qml/qdeclarativelistmodelworkeragent.cpp | 246 - .../qml/qdeclarativelistmodelworkeragent_p.h | 161 - src/declarative/qml/qdeclarativelocale.cpp | 1123 --- src/declarative/qml/qdeclarativelocale_p.h | 135 - src/declarative/qml/qdeclarativemetatype.cpp | 1359 --- src/declarative/qml/qdeclarativemetatype_p.h | 268 - .../qdeclarativenetworkaccessmanagerfactory.cpp | 103 - .../qml/qdeclarativenetworkaccessmanagerfactory.h | 65 - src/declarative/qml/qdeclarativenotifier.cpp | 115 - src/declarative/qml/qdeclarativenotifier_p.h | 206 - .../qml/qdeclarativenullablevalue_p_p.h | 81 - src/declarative/qml/qdeclarativeopenmetaobject.cpp | 387 - src/declarative/qml/qdeclarativeopenmetaobject_p.h | 130 - src/declarative/qml/qdeclarativeparserstatus.cpp | 107 - src/declarative/qml/qdeclarativeparserstatus.h | 74 - src/declarative/qml/qdeclarativeprivate.h | 263 - src/declarative/qml/qdeclarativeproperty.cpp | 1917 ----- src/declarative/qml/qdeclarativeproperty.h | 142 - src/declarative/qml/qdeclarativeproperty_p.h | 171 - src/declarative/qml/qdeclarativepropertycache.cpp | 889 -- src/declarative/qml/qdeclarativepropertycache_p.h | 383 - .../qml/qdeclarativepropertyvalueinterceptor.cpp | 79 - .../qml/qdeclarativepropertyvalueinterceptor_p.h | 73 - .../qml/qdeclarativepropertyvaluesource.cpp | 76 - .../qml/qdeclarativepropertyvaluesource.h | 66 - .../qml/qdeclarativeproxymetaobject.cpp | 124 - .../qml/qdeclarativeproxymetaobject_p.h | 99 - src/declarative/qml/qdeclarativerewrite.cpp | 441 - src/declarative/qml/qdeclarativerewrite_p.h | 149 - src/declarative/qml/qdeclarativescript.cpp | 1700 ---- src/declarative/qml/qdeclarativescript_p.h | 533 -- src/declarative/qml/qdeclarativescriptstring.cpp | 157 - src/declarative/qml/qdeclarativescriptstring.h | 89 - src/declarative/qml/qdeclarativescriptstring_p.h | 64 - .../qml/qdeclarativestringconverters.cpp | 311 - .../qml/qdeclarativestringconverters_p.h | 93 - src/declarative/qml/qdeclarativetypeloader.cpp | 1928 ----- src/declarative/qml/qdeclarativetypeloader_p.h | 435 - src/declarative/qml/qdeclarativetypenamecache.cpp | 127 - src/declarative/qml/qdeclarativetypenamecache_p.h | 187 - .../qml/qdeclarativetypenotavailable.cpp | 53 - .../qml/qdeclarativetypenotavailable_p.h | 64 - src/declarative/qml/qdeclarativevaluetype.cpp | 868 -- src/declarative/qml/qdeclarativevaluetype_p.h | 635 -- src/declarative/qml/qdeclarativevme.cpp | 1370 --- src/declarative/qml/qdeclarativevme_p.h | 240 - src/declarative/qml/qdeclarativevmemetaobject.cpp | 1110 --- src/declarative/qml/qdeclarativevmemetaobject_p.h | 221 - src/declarative/qml/qdeclarativewatcher.cpp | 188 - src/declarative/qml/qdeclarativewatcher_p.h | 94 - src/declarative/qml/qdeclarativeworkerscript.cpp | 730 -- src/declarative/qml/qdeclarativeworkerscript_p.h | 130 - src/declarative/qml/qdeclarativexmlhttprequest.cpp | 1797 ---- src/declarative/qml/qdeclarativexmlhttprequest_p.h | 73 - src/declarative/qml/qlistmodelinterface.cpp | 104 - src/declarative/qml/qlistmodelinterface_p.h | 83 - src/declarative/qml/qml.pri | 125 - src/declarative/qml/rewriter/rewriter.pri | 2 - src/declarative/qml/rewriter/textwriter.cpp | 217 - src/declarative/qml/rewriter/textwriter_p.h | 101 - src/declarative/qml/v4/qv4bindings.cpp | 1538 ---- src/declarative/qml/v4/qv4bindings_p.h | 153 - src/declarative/qml/v4/qv4compiler.cpp | 1398 --- src/declarative/qml/v4/qv4compiler_p.h | 105 - src/declarative/qml/v4/qv4compiler_p_p.h | 245 - src/declarative/qml/v4/qv4instruction.cpp | 412 - src/declarative/qml/v4/qv4instruction_p.h | 432 - src/declarative/qml/v4/qv4ir.cpp | 882 -- src/declarative/qml/v4/qv4ir_p.h | 604 -- src/declarative/qml/v4/qv4irbuilder.cpp | 1302 --- src/declarative/qml/v4/qv4irbuilder_p.h | 240 - src/declarative/qml/v4/qv4program_p.h | 122 - src/declarative/qml/v4/v4.pri | 15 - src/declarative/qml/v8/notes.txt | 4 - .../qml/v8/qdeclarativebuiltinfunctions.cpp | 1320 --- .../qml/v8/qdeclarativebuiltinfunctions_p.h | 110 - src/declarative/qml/v8/qjsconverter_impl_p.h | 268 - src/declarative/qml/v8/qjsconverter_p.h | 93 - src/declarative/qml/v8/qjsengine.cpp | 476 - src/declarative/qml/v8/qjsengine.h | 141 - src/declarative/qml/v8/qjsengine_p.h | 57 - src/declarative/qml/v8/qjsvalue.cpp | 856 -- src/declarative/qml/v8/qjsvalue.h | 142 - src/declarative/qml/v8/qjsvalue_impl_p.h | 977 --- src/declarative/qml/v8/qjsvalue_p.h | 195 - src/declarative/qml/v8/qjsvalueiterator.cpp | 157 - src/declarative/qml/v8/qjsvalueiterator.h | 63 - src/declarative/qml/v8/qjsvalueiterator_impl_p.h | 121 - src/declarative/qml/v8/qjsvalueiterator_p.h | 68 - src/declarative/qml/v8/qscript_impl_p.h | 43 - src/declarative/qml/v8/qscriptisolate_p.h | 71 - .../qml/v8/qscriptoriginalglobalobject_p.h | 159 - src/declarative/qml/v8/qscriptshareddata_p.h | 151 - src/declarative/qml/v8/qscripttools_p.h | 68 - src/declarative/qml/v8/qv8_p.h | 42 - src/declarative/qml/v8/qv8bindings.cpp | 285 - src/declarative/qml/v8/qv8bindings_p.h | 148 - src/declarative/qml/v8/qv8contextwrapper.cpp | 455 - src/declarative/qml/v8/qv8contextwrapper_p.h | 120 - src/declarative/qml/v8/qv8debug_p.h | 42 - src/declarative/qml/v8/qv8domerrors.cpp | 73 - src/declarative/qml/v8/qv8domerrors_p.h | 94 - src/declarative/qml/v8/qv8engine.cpp | 1598 ---- src/declarative/qml/v8/qv8engine_impl_p.h | 155 - src/declarative/qml/v8/qv8engine_p.h | 631 -- src/declarative/qml/v8/qv8include.cpp | 244 - src/declarative/qml/v8/qv8include_p.h | 113 - src/declarative/qml/v8/qv8listwrapper.cpp | 194 - src/declarative/qml/v8/qv8listwrapper_p.h | 97 - src/declarative/qml/v8/qv8profiler_p.h | 42 - src/declarative/qml/v8/qv8qobjectwrapper.cpp | 2113 ----- src/declarative/qml/v8/qv8qobjectwrapper_p.h | 159 - src/declarative/qml/v8/qv8sequencewrapper.cpp | 264 - src/declarative/qml/v8/qv8sequencewrapper_p.h | 106 - src/declarative/qml/v8/qv8sequencewrapper_p_p.h | 503 -- src/declarative/qml/v8/qv8sqlerrors.cpp | 64 - src/declarative/qml/v8/qv8sqlerrors_p.h | 77 - src/declarative/qml/v8/qv8stringwrapper.cpp | 78 - src/declarative/qml/v8/qv8stringwrapper_p.h | 76 - src/declarative/qml/v8/qv8typewrapper.cpp | 314 - src/declarative/qml/v8/qv8typewrapper_p.h | 94 - src/declarative/qml/v8/qv8valuetypewrapper.cpp | 387 - src/declarative/qml/v8/qv8valuetypewrapper_p.h | 104 - src/declarative/qml/v8/qv8variantresource_p.h | 81 - src/declarative/qml/v8/qv8variantwrapper.cpp | 279 - src/declarative/qml/v8/qv8variantwrapper_p.h | 110 - src/declarative/qml/v8/qv8worker.cpp | 392 - src/declarative/qml/v8/qv8worker_p.h | 75 - src/declarative/qml/v8/script.pri | 21 - src/declarative/qml/v8/v8.pri | 45 - src/declarative/util/qdeclarativepropertymap.cpp | 309 - src/declarative/util/qdeclarativepropertymap.h | 89 - src/declarative/util/util.pri | 5 - src/imports/folderlistmodel/folderlistmodel.pro | 8 +- src/imports/folderlistmodel/plugin.cpp | 12 +- .../qdeclarativefolderlistmodel.cpp | 529 -- .../folderlistmodel/qdeclarativefolderlistmodel.h | 159 - .../folderlistmodel/qquickfolderlistmodel.cpp | 529 ++ .../folderlistmodel/qquickfolderlistmodel.h | 159 + src/imports/localstorage/localstorage.pro | 4 +- src/imports/localstorage/plugin.cpp | 46 +- src/imports/qimportbase.pri | 2 +- src/imports/qtquick2/plugin.cpp | 8 +- src/imports/qtquick2/qtquick2.pro | 4 +- src/imports/testlib/main.cpp | 28 +- src/imports/testlib/signalspy.h | 6 +- src/imports/testlib/testcase.h | 6 +- src/imports/testlib/testlib.pro | 6 +- src/imports/xmllistmodel/plugin.cpp | 14 +- .../xmllistmodel/qdeclarativexmllistmodel.cpp | 1160 --- .../xmllistmodel/qdeclarativexmllistmodel_p.h | 212 - src/imports/xmllistmodel/qqmlxmllistmodel.cpp | 1160 +++ src/imports/xmllistmodel/qqmlxmllistmodel_p.h | 212 + src/imports/xmllistmodel/xmllistmodel.pro | 8 +- src/plugins/accessible/quick/main.cpp | 4 +- .../accessible/quick/qaccessiblequickitem.cpp | 4 +- .../accessible/quick/qaccessiblequickitem.h | 6 +- .../accessible/quick/qaccessiblequickview.cpp | 4 +- .../accessible/quick/qaccessiblequickview.h | 2 +- src/plugins/accessible/quick/quick.pro | 2 +- src/plugins/accessible/shared/qaccessiblebase.pri | 4 +- .../accessible/shared/qdeclarativeaccessible.cpp | 161 - .../accessible/shared/qdeclarativeaccessible.h | 96 - src/plugins/accessible/shared/qqmlaccessible.cpp | 161 + src/plugins/accessible/shared/qqmlaccessible.h | 96 + src/plugins/qmltooling/qmldbg_ost/qmldbg_ost.pro | 4 +- src/plugins/qmltooling/qmldbg_ost/qmlostplugin.cpp | 12 +- src/plugins/qmltooling/qmldbg_ost/qmlostplugin.h | 12 +- src/plugins/qmltooling/qmldbg_ost/qostdevice.cpp | 2 +- src/plugins/qmltooling/qmldbg_ost/qostdevice.h | 2 +- src/plugins/qmltooling/qmldbg_ost/usbostcomm.h | 2 +- .../qmltooling/qmldbg_qtquick2/highlight.cpp | 2 +- src/plugins/qmltooling/qmldbg_qtquick2/highlight.h | 2 +- .../qmltooling/qmldbg_qtquick2/qmldbg_qtquick2.pro | 6 +- .../qmldbg_qtquick2/qquickviewinspector.cpp | 6 +- .../qmldbg_qtquick2/qquickviewinspector.h | 4 +- .../qmltooling/qmldbg_qtquick2/qtquick2plugin.cpp | 4 +- .../qmltooling/qmldbg_qtquick2/qtquick2plugin.h | 16 +- .../qmltooling/qmldbg_qtquick2/selectiontool.cpp | 2 +- .../qmltooling/qmldbg_qtquick2/selectiontool.h | 2 +- src/plugins/qmltooling/qmldbg_tcp/qmldbg_tcp.pro | 6 +- .../qmltooling/qmldbg_tcp/qtcpserverconnection.cpp | 16 +- .../qmltooling/qmldbg_tcp/qtcpserverconnection.h | 12 +- src/plugins/qmltooling/shared/abstracttool.cpp | 2 +- src/plugins/qmltooling/shared/abstracttool.h | 2 +- .../qmltooling/shared/abstractviewinspector.cpp | 30 +- .../qmltooling/shared/abstractviewinspector.h | 14 +- .../shared/qdeclarativeinspectorprotocol.h | 137 - .../qmltooling/shared/qmlinspectorconstants.h | 4 +- .../qmltooling/shared/qqmlinspectorprotocol.h | 137 + src/qml/animations/animations.pri | 16 + src/qml/animations/qabstractanimationjob.cpp | 544 ++ src/qml/animations/qabstractanimationjob_p.h | 233 + src/qml/animations/qanimationgroupjob.cpp | 164 + src/qml/animations/qanimationgroupjob_p.h | 93 + src/qml/animations/qanimationjobutil_p.h | 59 + src/qml/animations/qparallelanimationgroupjob.cpp | 227 + src/qml/animations/qparallelanimationgroupjob_p.h | 81 + src/qml/animations/qpauseanimationjob.cpp | 71 + src/qml/animations/qpauseanimationjob_p.h | 75 + .../animations/qsequentialanimationgroupjob.cpp | 388 + .../animations/qsequentialanimationgroupjob_p.h | 108 + src/qml/debugger/debugger.pri | 32 + src/qml/debugger/qdebugmessageservice.cpp | 124 + src/qml/debugger/qdebugmessageservice_p.h | 91 + src/qml/debugger/qpacketprotocol.cpp | 550 ++ src/qml/debugger/qpacketprotocol_p.h | 137 + src/qml/debugger/qqmldebug.h | 66 + src/qml/debugger/qqmldebugclient.cpp | 421 + src/qml/debugger/qqmldebugclient_p.h | 131 + src/qml/debugger/qqmldebughelper.cpp | 70 + src/qml/debugger/qqmldebughelper_p.h | 84 + src/qml/debugger/qqmldebugserver.cpp | 540 ++ src/qml/debugger/qqmldebugserver_p.h | 105 + src/qml/debugger/qqmldebugserverconnection_p.h | 85 + src/qml/debugger/qqmldebugservice.cpp | 268 + src/qml/debugger/qqmldebugservice_p.h | 113 + src/qml/debugger/qqmldebugservice_p_p.h | 82 + src/qml/debugger/qqmldebugstatesdelegate_p.h | 98 + src/qml/debugger/qqmlenginedebug.cpp | 1072 +++ src/qml/debugger/qqmlenginedebug_p.h | 397 + src/qml/debugger/qqmlenginedebugservice.cpp | 733 ++ src/qml/debugger/qqmlenginedebugservice_p.h | 136 + src/qml/debugger/qqmlinspectorinterface_p.h | 83 + src/qml/debugger/qqmlinspectorservice.cpp | 186 + src/qml/debugger/qqmlinspectorservice_p.h | 101 + src/qml/debugger/qqmlprofilerservice.cpp | 357 + src/qml/debugger/qqmlprofilerservice_p.h | 183 + src/qml/debugger/qv8debugservice.cpp | 294 + src/qml/debugger/qv8debugservice_p.h | 105 + src/qml/debugger/qv8profilerservice.cpp | 287 + src/qml/debugger/qv8profilerservice_p.h | 119 + src/qml/qml.pro | 37 + src/qml/qml/ftw/ftw.pri | 29 + src/qml/qml/ftw/qbitfield_p.h | 165 + src/qml/qml/ftw/qdeletewatcher_p.h | 113 + src/qml/qml/ftw/qfastmetabuilder.cpp | 369 + src/qml/qml/ftw/qfastmetabuilder_p.h | 206 + src/qml/qml/ftw/qfieldlist_p.h | 426 + src/qml/qml/ftw/qfinitestack_p.h | 186 + src/qml/qml/ftw/qflagpointer_p.h | 338 + src/qml/qml/ftw/qhashedstring.cpp | 490 ++ src/qml/qml/ftw/qhashedstring_p.h | 1418 +++ src/qml/qml/ftw/qhashfield_p.h | 120 + src/qml/qml/ftw/qintrusivelist.cpp | 179 + src/qml/qml/ftw/qintrusivelist_p.h | 274 + src/qml/qml/ftw/qlazilyallocated_p.h | 146 + src/qml/qml/ftw/qpodvector_p.h | 173 + src/qml/qml/ftw/qpointervaluepair_p.h | 196 + src/qml/qml/ftw/qqmlpool.cpp | 92 + src/qml/qml/ftw/qqmlpool_p.h | 278 + src/qml/qml/ftw/qqmlrefcount_p.h | 192 + src/qml/qml/ftw/qqmlthread.cpp | 359 + src/qml/qml/ftw/qqmlthread_p.h | 318 + src/qml/qml/ftw/qqmltrace.cpp | 154 + src/qml/qml/ftw/qqmltrace_p.h | 294 + src/qml/qml/ftw/qrecursionwatcher_p.h | 105 + src/qml/qml/ftw/qrecyclepool_p.h | 220 + src/qml/qml/parser/parser.pri | 19 + src/qml/qml/parser/qqmljs.g | 3016 +++++++ src/qml/qml/parser/qqmljsast.cpp | 931 ++ src/qml/qml/parser/qqmljsast_p.h | 2640 ++++++ src/qml/qml/parser/qqmljsastfwd_p.h | 186 + src/qml/qml/parser/qqmljsastvisitor.cpp | 58 + src/qml/qml/parser/qqmljsastvisitor_p.h | 329 + src/qml/qml/parser/qqmljsengine_p.cpp | 161 + src/qml/qml/parser/qqmljsengine_p.h | 126 + src/qml/qml/parser/qqmljsglobal_p.h | 69 + src/qml/qml/parser/qqmljsgrammar.cpp | 1013 +++ src/qml/qml/parser/qqmljsgrammar_p.h | 211 + src/qml/qml/parser/qqmljskeywords_p.h | 860 ++ src/qml/qml/parser/qqmljslexer.cpp | 1166 +++ src/qml/qml/parser/qqmljslexer_p.h | 248 + src/qml/qml/parser/qqmljsmemorypool_p.h | 173 + src/qml/qml/parser/qqmljsparser.cpp | 1812 ++++ src/qml/qml/parser/qqmljsparser_p.h | 248 + src/qml/qml/qlistmodelinterface.cpp | 104 + src/qml/qml/qlistmodelinterface_p.h | 83 + src/qml/qml/qml.pri | 125 + src/qml/qml/qqml.h | 451 + src/qml/qml/qqmlaccessors.cpp | 127 + src/qml/qml/qqmlaccessors_p.h | 166 + src/qml/qml/qqmlbinding.cpp | 551 ++ src/qml/qml/qqmlbinding_p.h | 219 + src/qml/qml/qqmlbinding_p_p.h | 89 + src/qml/qml/qqmlboundsignal.cpp | 300 + src/qml/qml/qqmlboundsignal_p.h | 103 + src/qml/qml/qqmlcleanup.cpp | 118 + src/qml/qml/qqmlcleanup_p.h | 87 + src/qml/qml/qqmlcompileddata.cpp | 261 + src/qml/qml/qqmlcompiler.cpp | 3882 +++++++++ src/qml/qml/qqmlcompiler_p.h | 466 + src/qml/qml/qqmlcomponent.cpp | 1350 +++ src/qml/qml/qqmlcomponent.h | 138 + src/qml/qml/qqmlcomponent_p.h | 129 + src/qml/qml/qqmlcomponentattached_p.h | 85 + src/qml/qml/qqmlcontext.cpp | 811 ++ src/qml/qml/qqmlcontext.h | 113 + src/qml/qml/qqmlcontext_p.h | 334 + src/qml/qml/qqmlcustomparser.cpp | 319 + src/qml/qml/qqmlcustomparser_p.h | 168 + src/qml/qml/qqmlcustomparser_p_p.h | 89 + src/qml/qml/qqmldata_p.h | 207 + src/qml/qml/qqmldirparser.cpp | 298 + src/qml/qml/qqmldirparser_p.h | 166 + src/qml/qml/qqmlengine.cpp | 1854 ++++ src/qml/qml/qqmlengine.h | 138 + src/qml/qml/qqmlengine_p.h | 522 ++ src/qml/qml/qqmlerror.cpp | 285 + src/qml/qml/qqmlerror.h | 87 + src/qml/qml/qqmlexpression.cpp | 982 +++ src/qml/qml/qqmlexpression.h | 121 + src/qml/qml/qqmlexpression_p.h | 406 + src/qml/qml/qqmlextensioninterface.h | 76 + src/qml/qml/qqmlextensionplugin.cpp | 171 + src/qml/qml/qqmlextensionplugin.h | 77 + src/qml/qml/qqmlglobal_p.h | 129 + src/qml/qml/qqmlguard_p.h | 218 + src/qml/qml/qqmlimageprovider.cpp | 334 + src/qml/qml/qqmlimageprovider.h | 96 + src/qml/qml/qqmlimport.cpp | 1183 +++ src/qml/qml/qqmlimport_p.h | 157 + src/qml/qml/qqmlincubator.cpp | 696 ++ src/qml/qml/qqmlincubator.h | 129 + src/qml/qml/qqmlincubator_p.h | 106 + src/qml/qml/qqmlinfo.cpp | 192 + src/qml/qml/qqmlinfo.h | 103 + src/qml/qml/qqmlinstruction.cpp | 278 + src/qml/qml/qqmlinstruction_p.h | 558 ++ src/qml/qml/qqmlintegercache.cpp | 82 + src/qml/qml/qqmlintegercache_p.h | 97 + src/qml/qml/qqmllist.cpp | 417 + src/qml/qml/qqmllist.h | 151 + src/qml/qml/qqmllist_p.h | 85 + src/qml/qml/qqmllocale.cpp | 1123 +++ src/qml/qml/qqmllocale_p.h | 135 + src/qml/qml/qqmlmetatype.cpp | 1359 +++ src/qml/qml/qqmlmetatype_p.h | 268 + src/qml/qml/qqmlnetworkaccessmanagerfactory.cpp | 103 + src/qml/qml/qqmlnetworkaccessmanagerfactory.h | 66 + src/qml/qml/qqmlnotifier.cpp | 115 + src/qml/qml/qqmlnotifier_p.h | 206 + src/qml/qml/qqmlnullablevalue_p_p.h | 81 + src/qml/qml/qqmlopenmetaobject.cpp | 387 + src/qml/qml/qqmlopenmetaobject_p.h | 130 + src/qml/qml/qqmlparserstatus.cpp | 107 + src/qml/qml/qqmlparserstatus.h | 75 + src/qml/qml/qqmlprivate.h | 265 + src/qml/qml/qqmlproperty.cpp | 1917 +++++ src/qml/qml/qqmlproperty.h | 143 + src/qml/qml/qqmlproperty_p.h | 171 + src/qml/qml/qqmlpropertycache.cpp | 889 ++ src/qml/qml/qqmlpropertycache_p.h | 383 + src/qml/qml/qqmlpropertyvalueinterceptor.cpp | 79 + src/qml/qml/qqmlpropertyvalueinterceptor_p.h | 74 + src/qml/qml/qqmlpropertyvaluesource.cpp | 76 + src/qml/qml/qqmlpropertyvaluesource.h | 67 + src/qml/qml/qqmlproxymetaobject.cpp | 124 + src/qml/qml/qqmlproxymetaobject_p.h | 99 + src/qml/qml/qqmlrewrite.cpp | 441 + src/qml/qml/qqmlrewrite_p.h | 149 + src/qml/qml/qqmlscript.cpp | 1700 ++++ src/qml/qml/qqmlscript_p.h | 533 ++ src/qml/qml/qqmlscriptstring.cpp | 157 + src/qml/qml/qqmlscriptstring.h | 90 + src/qml/qml/qqmlscriptstring_p.h | 64 + src/qml/qml/qqmlstringconverters.cpp | 311 + src/qml/qml/qqmlstringconverters_p.h | 93 + src/qml/qml/qqmltypeloader.cpp | 1928 +++++ src/qml/qml/qqmltypeloader_p.h | 435 + src/qml/qml/qqmltypenamecache.cpp | 127 + src/qml/qml/qqmltypenamecache_p.h | 187 + src/qml/qml/qqmltypenotavailable.cpp | 53 + src/qml/qml/qqmltypenotavailable_p.h | 64 + src/qml/qml/qqmlvaluetype.cpp | 868 ++ src/qml/qml/qqmlvaluetype_p.h | 635 ++ src/qml/qml/qqmlvme.cpp | 1370 +++ src/qml/qml/qqmlvme_p.h | 240 + src/qml/qml/qqmlvmemetaobject.cpp | 1110 +++ src/qml/qml/qqmlvmemetaobject_p.h | 221 + src/qml/qml/qqmlwatcher.cpp | 188 + src/qml/qml/qqmlwatcher_p.h | 94 + src/qml/qml/qqmlxmlhttprequest.cpp | 1797 ++++ src/qml/qml/qqmlxmlhttprequest_p.h | 73 + src/qml/qml/qquickapplication.cpp | 124 + src/qml/qml/qquickapplication_p.h | 87 + src/qml/qml/qquicklistmodel.cpp | 2467 ++++++ src/qml/qml/qquicklistmodel_p.h | 199 + src/qml/qml/qquicklistmodel_p_p.h | 378 + src/qml/qml/qquicklistmodelworkeragent.cpp | 246 + src/qml/qml/qquicklistmodelworkeragent_p.h | 161 + src/qml/qml/qquickworkerscript.cpp | 730 ++ src/qml/qml/qquickworkerscript_p.h | 130 + src/qml/qml/rewriter/rewriter.pri | 2 + src/qml/qml/rewriter/textwriter.cpp | 217 + src/qml/qml/rewriter/textwriter_p.h | 101 + src/qml/qml/v4/qv4bindings.cpp | 1538 ++++ src/qml/qml/v4/qv4bindings_p.h | 153 + src/qml/qml/v4/qv4compiler.cpp | 1399 +++ src/qml/qml/v4/qv4compiler_p.h | 105 + src/qml/qml/v4/qv4compiler_p_p.h | 245 + src/qml/qml/v4/qv4instruction.cpp | 412 + src/qml/qml/v4/qv4instruction_p.h | 432 + src/qml/qml/v4/qv4ir.cpp | 882 ++ src/qml/qml/v4/qv4ir_p.h | 604 ++ src/qml/qml/v4/qv4irbuilder.cpp | 1303 +++ src/qml/qml/v4/qv4irbuilder_p.h | 240 + src/qml/qml/v4/qv4program_p.h | 122 + src/qml/qml/v4/v4.pri | 15 + src/qml/qml/v8/notes.txt | 4 + src/qml/qml/v8/qjsconverter_impl_p.h | 268 + src/qml/qml/v8/qjsconverter_p.h | 93 + src/qml/qml/v8/qjsengine.cpp | 476 + src/qml/qml/v8/qjsengine.h | 141 + src/qml/qml/v8/qjsengine_p.h | 57 + src/qml/qml/v8/qjsvalue.cpp | 856 ++ src/qml/qml/v8/qjsvalue.h | 143 + src/qml/qml/v8/qjsvalue_impl_p.h | 977 +++ src/qml/qml/v8/qjsvalue_p.h | 195 + src/qml/qml/v8/qjsvalueiterator.cpp | 157 + src/qml/qml/v8/qjsvalueiterator.h | 63 + src/qml/qml/v8/qjsvalueiterator_impl_p.h | 121 + src/qml/qml/v8/qjsvalueiterator_p.h | 68 + src/qml/qml/v8/qqmlbuiltinfunctions.cpp | 1320 +++ src/qml/qml/v8/qqmlbuiltinfunctions_p.h | 110 + src/qml/qml/v8/qscript_impl_p.h | 43 + src/qml/qml/v8/qscriptisolate_p.h | 71 + src/qml/qml/v8/qscriptoriginalglobalobject_p.h | 159 + src/qml/qml/v8/qscriptshareddata_p.h | 151 + src/qml/qml/v8/qscripttools_p.h | 68 + src/qml/qml/v8/qv8_p.h | 42 + src/qml/qml/v8/qv8bindings.cpp | 285 + src/qml/qml/v8/qv8bindings_p.h | 148 + src/qml/qml/v8/qv8contextwrapper.cpp | 455 + src/qml/qml/v8/qv8contextwrapper_p.h | 120 + src/qml/qml/v8/qv8debug_p.h | 42 + src/qml/qml/v8/qv8domerrors.cpp | 73 + src/qml/qml/v8/qv8domerrors_p.h | 94 + src/qml/qml/v8/qv8engine.cpp | 1598 ++++ src/qml/qml/v8/qv8engine_impl_p.h | 155 + src/qml/qml/v8/qv8engine_p.h | 631 ++ src/qml/qml/v8/qv8include.cpp | 244 + src/qml/qml/v8/qv8include_p.h | 113 + src/qml/qml/v8/qv8listwrapper.cpp | 194 + src/qml/qml/v8/qv8listwrapper_p.h | 97 + src/qml/qml/v8/qv8profiler_p.h | 42 + src/qml/qml/v8/qv8qobjectwrapper.cpp | 2113 +++++ src/qml/qml/v8/qv8qobjectwrapper_p.h | 159 + src/qml/qml/v8/qv8sequencewrapper.cpp | 264 + src/qml/qml/v8/qv8sequencewrapper_p.h | 106 + src/qml/qml/v8/qv8sequencewrapper_p_p.h | 503 ++ src/qml/qml/v8/qv8sqlerrors.cpp | 64 + src/qml/qml/v8/qv8sqlerrors_p.h | 77 + src/qml/qml/v8/qv8stringwrapper.cpp | 78 + src/qml/qml/v8/qv8stringwrapper_p.h | 78 + src/qml/qml/v8/qv8typewrapper.cpp | 314 + src/qml/qml/v8/qv8typewrapper_p.h | 94 + src/qml/qml/v8/qv8valuetypewrapper.cpp | 387 + src/qml/qml/v8/qv8valuetypewrapper_p.h | 104 + src/qml/qml/v8/qv8variantresource_p.h | 81 + src/qml/qml/v8/qv8variantwrapper.cpp | 279 + src/qml/qml/v8/qv8variantwrapper_p.h | 110 + src/qml/qml/v8/qv8worker.cpp | 392 + src/qml/qml/v8/qv8worker_p.h | 75 + src/qml/qml/v8/script.pri | 21 + src/qml/qml/v8/v8.pri | 45 + src/qml/qtqmlglobal.h | 67 + src/qml/qtqmlglobal_p.h | 60 + src/qml/util/qqmlpropertymap.cpp | 309 + src/qml/util/qqmlpropertymap.h | 91 + src/qml/util/util.pri | 5 + src/qmldevtools/qmldevtools.pro | 2 +- src/qmltest/qmltest.pro | 2 +- src/qmltest/quicktest.cpp | 18 +- src/qmltest/quicktestevent.cpp | 4 +- src/quick/designer/designersupport.cpp | 16 +- src/quick/designer/designersupport.h | 8 +- src/quick/items/context2d/qquickcanvascontext.cpp | 2 +- src/quick/items/context2d/qquickcanvascontext_p.h | 2 +- src/quick/items/context2d/qquickcanvasitem.cpp | 32 +- src/quick/items/context2d/qquickcanvasitem_p.h | 12 +- src/quick/items/context2d/qquickcanvasitemnode.cpp | 2 +- src/quick/items/context2d/qquickcanvasitemnode_p.h | 2 +- src/quick/items/context2d/qquickcontext2d.cpp | 14 +- src/quick/items/context2d/qquickcontext2d_p.h | 8 +- .../context2d/qquickcontext2dcommandbuffer.cpp | 4 +- .../context2d/qquickcontext2dcommandbuffer_p.h | 4 +- .../items/context2d/qquickcontext2dtexture.cpp | 2 +- .../items/context2d/qquickcontext2dtexture_p.h | 2 +- src/quick/items/context2d/qquickcontext2dtile.cpp | 2 +- src/quick/items/context2d/qquickcontext2dtile_p.h | 2 +- src/quick/items/items.pri | 6 +- src/quick/items/qquickaccessibleattached.cpp | 2 +- src/quick/items/qquickaccessibleattached_p.h | 2 +- src/quick/items/qquickanchors.cpp | 4 +- src/quick/items/qquickanchors_p.h | 4 +- src/quick/items/qquickanchors_p_p.h | 2 +- src/quick/items/qquickanimatedimage.cpp | 12 +- src/quick/items/qquickanimatedimage_p.h | 2 +- src/quick/items/qquickanimatedimage_p_p.h | 2 +- src/quick/items/qquickanimation.cpp | 1042 --- src/quick/items/qquickanimation_p.h | 203 - src/quick/items/qquickanimation_p_p.h | 161 - src/quick/items/qquickborderimage.cpp | 29 +- src/quick/items/qquickborderimage_p.h | 2 +- src/quick/items/qquickborderimage_p_p.h | 4 +- src/quick/items/qquickcanvas.cpp | 20 +- src/quick/items/qquickcanvas.h | 8 +- src/quick/items/qquickcanvas_p.h | 6 +- src/quick/items/qquickclipnode.cpp | 2 +- src/quick/items/qquickclipnode_p.h | 2 +- src/quick/items/qquickdrag.cpp | 12 +- src/quick/items/qquickdrag_p.h | 10 +- src/quick/items/qquickdroparea.cpp | 10 +- src/quick/items/qquickdroparea_p.h | 6 +- src/quick/items/qquickevents.cpp | 2 +- src/quick/items/qquickevents_p_p.h | 4 +- src/quick/items/qquickflickable.cpp | 38 +- src/quick/items/qquickflickable_p.h | 10 +- src/quick/items/qquickflickable_p_p.h | 28 +- src/quick/items/qquickflipable.cpp | 14 +- src/quick/items/qquickflipable_p.h | 2 +- src/quick/items/qquickfocusscope.cpp | 2 +- src/quick/items/qquickfocusscope_p.h | 2 +- src/quick/items/qquickgridview.cpp | 34 +- src/quick/items/qquickgridview_p.h | 6 +- src/quick/items/qquickimage.cpp | 8 +- src/quick/items/qquickimage_p.h | 2 +- src/quick/items/qquickimage_p_p.h | 2 +- src/quick/items/qquickimagebase.cpp | 10 +- src/quick/items/qquickimagebase_p.h | 2 +- src/quick/items/qquickimagebase_p_p.h | 6 +- src/quick/items/qquickimplicitsizeitem.cpp | 2 +- src/quick/items/qquickimplicitsizeitem_p.h | 2 +- src/quick/items/qquickimplicitsizeitem_p_p.h | 2 +- src/quick/items/qquickitem.cpp | 115 +- src/quick/items/qquickitem.h | 36 +- src/quick/items/qquickitem_p.h | 86 +- src/quick/items/qquickitemanimation.cpp | 1042 +++ src/quick/items/qquickitemanimation_p.h | 203 + src/quick/items/qquickitemanimation_p_p.h | 161 + src/quick/items/qquickitemchangelistener_p.h | 2 +- src/quick/items/qquickitemsmodule.cpp | 50 +- src/quick/items/qquickitemsmodule_p.h | 4 +- src/quick/items/qquickitemview.cpp | 118 +- src/quick/items/qquickitemview_p.h | 78 +- src/quick/items/qquickitemview_p_p.h | 56 +- src/quick/items/qquicklistview.cpp | 60 +- src/quick/items/qquicklistview_p.h | 14 +- src/quick/items/qquickloader.cpp | 78 +- src/quick/items/qquickloader_p.h | 10 +- src/quick/items/qquickloader_p_p.h | 20 +- src/quick/items/qquickmousearea.cpp | 14 +- src/quick/items/qquickmousearea_p.h | 4 +- src/quick/items/qquickmousearea_p_p.h | 4 +- src/quick/items/qquickmultipointtoucharea.cpp | 4 +- src/quick/items/qquickmultipointtoucharea_p.h | 20 +- src/quick/items/qquickninepatchnode.cpp | 2 +- src/quick/items/qquickninepatchnode_p.h | 2 +- src/quick/items/qquickpainteditem.cpp | 2 +- src/quick/items/qquickpainteditem.h | 2 +- src/quick/items/qquickpainteditem_p.h | 2 +- src/quick/items/qquickpathview.cpp | 69 +- src/quick/items/qquickpathview_p.h | 30 +- src/quick/items/qquickpathview_p_p.h | 30 +- src/quick/items/qquickpositioners.cpp | 62 +- src/quick/items/qquickpositioners_p.h | 16 +- src/quick/items/qquickpositioners_p_p.h | 20 +- src/quick/items/qquickrectangle.cpp | 16 +- src/quick/items/qquickrectangle_p.h | 6 +- src/quick/items/qquickrectangle_p_p.h | 2 +- src/quick/items/qquickrepeater.cpp | 40 +- src/quick/items/qquickrepeater_p.h | 12 +- src/quick/items/qquickrepeater_p_p.h | 4 +- src/quick/items/qquickscalegrid.cpp | 4 +- src/quick/items/qquickscalegrid_p_p.h | 6 +- src/quick/items/qquickscreen.cpp | 2 +- src/quick/items/qquickscreen_p.h | 6 +- src/quick/items/qquickshadereffect.cpp | 2 +- src/quick/items/qquickshadereffect_p.h | 2 +- src/quick/items/qquickshadereffectmesh.cpp | 2 +- src/quick/items/qquickshadereffectmesh_p.h | 4 +- src/quick/items/qquickshadereffectnode.cpp | 2 +- src/quick/items/qquickshadereffectnode_p.h | 2 +- src/quick/items/qquickshadereffectsource.cpp | 2 +- src/quick/items/qquickshadereffectsource_p.h | 2 +- src/quick/items/qquicksprite.cpp | 2 +- src/quick/items/qquicksprite_p.h | 6 +- src/quick/items/qquickspriteengine.cpp | 30 +- src/quick/items/qquickspriteengine_p.h | 36 +- src/quick/items/qquickspriteimage.cpp | 10 +- src/quick/items/qquickspriteimage_p.h | 4 +- src/quick/items/qquickstateoperations.cpp | 358 +- src/quick/items/qquickstateoperations_p.h | 98 +- src/quick/items/qquicktext.cpp | 59 +- src/quick/items/qquicktext_p.h | 2 +- src/quick/items/qquicktext_p_p.h | 16 +- src/quick/items/qquicktextedit.cpp | 24 +- src/quick/items/qquicktextedit_p.h | 8 +- src/quick/items/qquicktextedit_p_p.h | 6 +- src/quick/items/qquicktextinput.cpp | 20 +- src/quick/items/qquicktextinput_p.h | 10 +- src/quick/items/qquicktextinput_p_p.h | 8 +- src/quick/items/qquicktextnode.cpp | 4 +- src/quick/items/qquicktextnode_p.h | 2 +- src/quick/items/qquicktranslate.cpp | 2 +- src/quick/items/qquicktranslate_p.h | 2 +- src/quick/items/qquickview.cpp | 62 +- src/quick/items/qquickview.h | 16 +- src/quick/items/qquickview_p.h | 14 +- src/quick/items/qquickvisualadaptormodel.cpp | 38 +- src/quick/items/qquickvisualadaptormodel_p.h | 6 +- src/quick/items/qquickvisualdatamodel.cpp | 168 +- src/quick/items/qquickvisualdatamodel_p.h | 54 +- src/quick/items/qquickvisualdatamodel_p_p.h | 98 +- src/quick/items/qquickvisualitemmodel.cpp | 28 +- src/quick/items/qquickvisualitemmodel_p.h | 12 +- src/quick/items/qquickwindowmanager.cpp | 4 +- src/quick/items/qquickwindowmanager_p.h | 2 +- src/quick/items/qquickwindowmodule_p.h | 2 +- src/quick/items/syncexcludes | 4 +- src/quick/particles/qquickcumulativedirection.cpp | 4 +- src/quick/particles/qquickcumulativedirection_p.h | 6 +- src/quick/particles/qquickcustomaffector.cpp | 14 +- src/quick/particles/qquickcustomaffector_p.h | 2 +- src/quick/particles/qquickcustomparticle.cpp | 2 +- src/quick/particles/qquickcustomparticle_p.h | 2 +- src/quick/particles/qquickimageparticle.cpp | 8 +- src/quick/particles/qquickimageparticle_p.h | 10 +- src/quick/particles/qquickitemparticle.cpp | 2 +- src/quick/particles/qquickitemparticle_p.h | 12 +- src/quick/particles/qquickmaskextruder.cpp | 4 +- src/quick/particles/qquickmaskextruder_p.h | 4 +- src/quick/particles/qquickparticleemitter.cpp | 8 +- src/quick/particles/qquickparticleemitter_p.h | 2 +- src/quick/particles/qquickparticlegroup.cpp | 8 +- src/quick/particles/qquickparticlegroup_p.h | 10 +- src/quick/particles/qquickparticlesmodule_p.h | 2 +- src/quick/particles/qquickparticlesystem.cpp | 9 +- src/quick/particles/qquickparticlesystem_p.h | 8 +- src/quick/particles/qquickspritegoal_p.h | 2 +- src/quick/particles/qquicktrailemitter.cpp | 10 +- src/quick/particles/qquicktrailemitter_p.h | 2 +- src/quick/particles/qquickturbulence_p.h | 2 +- src/quick/particles/qquickv8particledata.cpp | 4 +- src/quick/particles/qquickv8particledata_p.h | 2 +- src/quick/qtquick2.cpp | 86 +- src/quick/qtquick2_p.h | 4 +- src/quick/qtquickglobal.h | 2 +- src/quick/qtquickglobal_p.h | 2 +- src/quick/quick.pro | 12 +- .../scenegraph/coreapi/qsgdefaultrenderer.cpp | 2 +- .../scenegraph/coreapi/qsgdefaultrenderer_p.h | 2 +- src/quick/scenegraph/coreapi/qsggeometry_p.h | 2 +- src/quick/scenegraph/coreapi/qsgmaterial.cpp | 2 +- src/quick/scenegraph/coreapi/qsgmaterial.h | 2 +- src/quick/scenegraph/coreapi/qsgnode.cpp | 2 +- src/quick/scenegraph/coreapi/qsgnode.h | 2 +- src/quick/scenegraph/coreapi/qsgnodeupdater.cpp | 2 +- src/quick/scenegraph/coreapi/qsgnodeupdater_p.h | 2 +- src/quick/scenegraph/coreapi/qsgrenderer.cpp | 2 +- src/quick/scenegraph/coreapi/qsgrenderer_p.h | 2 +- src/quick/scenegraph/qsgadaptationlayer.cpp | 2 +- src/quick/scenegraph/qsgadaptationlayer_p.h | 2 +- src/quick/scenegraph/qsgcontext.cpp | 16 +- src/quick/scenegraph/qsgcontext_p.h | 8 +- src/quick/scenegraph/qsgcontextplugin.cpp | 6 +- src/quick/scenegraph/qsgcontextplugin_p.h | 8 +- .../qsgdefaultdistancefieldglyphcache.cpp | 2 +- .../qsgdefaultdistancefieldglyphcache_p.h | 2 +- src/quick/scenegraph/qsgdefaultglyphnode.cpp | 2 +- src/quick/scenegraph/qsgdefaultglyphnode_p.cpp | 2 +- src/quick/scenegraph/qsgdefaultglyphnode_p.h | 2 +- src/quick/scenegraph/qsgdefaultglyphnode_p_p.h | 2 +- src/quick/scenegraph/qsgdefaultimagenode.cpp | 2 +- src/quick/scenegraph/qsgdefaultimagenode_p.h | 2 +- src/quick/scenegraph/qsgdefaultrectanglenode.cpp | 2 +- src/quick/scenegraph/qsgdefaultrectanglenode_p.h | 2 +- src/quick/scenegraph/qsgdistancefieldglyphnode.cpp | 2 +- .../scenegraph/qsgdistancefieldglyphnode_p.cpp | 2 +- src/quick/scenegraph/qsgdistancefieldglyphnode_p.h | 2 +- .../scenegraph/qsgdistancefieldglyphnode_p_p.h | 2 +- src/quick/scenegraph/qsgflashnode.cpp | 2 +- src/quick/scenegraph/qsgflashnode_p.h | 2 +- src/quick/scenegraph/qsgpathsimplifier.cpp | 2 +- src/quick/scenegraph/qsgpathsimplifier_p.h | 2 +- .../qsgshareddistancefieldglyphcache.cpp | 2 +- .../qsgshareddistancefieldglyphcache_p.h | 2 +- src/quick/scenegraph/util/qsgareaallocator.cpp | 2 +- src/quick/scenegraph/util/qsgareaallocator_p.h | 2 +- src/quick/scenegraph/util/qsgdistancefieldutil.cpp | 2 +- src/quick/scenegraph/util/qsgdistancefieldutil_p.h | 2 +- src/quick/scenegraph/util/qsgengine.cpp | 2 +- src/quick/scenegraph/util/qsgengine.h | 2 +- src/quick/scenegraph/util/qsgflatcolormaterial.cpp | 2 +- src/quick/scenegraph/util/qsgflatcolormaterial.h | 2 +- src/quick/scenegraph/util/qsgpainternode.cpp | 2 +- src/quick/scenegraph/util/qsgpainternode_p.h | 2 +- src/quick/scenegraph/util/qsgsimplematerial.h | 2 +- src/quick/scenegraph/util/qsgsimplerectnode.cpp | 2 +- src/quick/scenegraph/util/qsgsimplerectnode.h | 2 +- src/quick/scenegraph/util/qsgsimpletexturenode.cpp | 2 +- src/quick/scenegraph/util/qsgsimpletexturenode.h | 2 +- src/quick/scenegraph/util/qsgtexture.cpp | 5 +- src/quick/scenegraph/util/qsgtexture.h | 2 +- src/quick/scenegraph/util/qsgtexture_p.h | 2 +- src/quick/scenegraph/util/qsgtexturematerial.cpp | 2 +- src/quick/scenegraph/util/qsgtexturematerial.h | 2 +- src/quick/scenegraph/util/qsgtexturematerial_p.h | 2 +- src/quick/scenegraph/util/qsgtextureprovider.cpp | 2 +- src/quick/scenegraph/util/qsgtextureprovider.h | 2 +- .../scenegraph/util/qsgvertexcolormaterial.cpp | 2 +- src/quick/scenegraph/util/qsgvertexcolormaterial.h | 2 +- src/quick/util/qdeclarativeanimation.cpp | 2530 ------ src/quick/util/qdeclarativeanimation_p.h | 464 - src/quick/util/qdeclarativeanimation_p_p.h | 322 - src/quick/util/qdeclarativeanimationcontroller.cpp | 204 - src/quick/util/qdeclarativeanimationcontroller_p.h | 94 - src/quick/util/qdeclarativebehavior.cpp | 238 - src/quick/util/qdeclarativebehavior_p.h | 93 - src/quick/util/qdeclarativebind.cpp | 309 - src/quick/util/qdeclarativebind_p.h | 96 - src/quick/util/qdeclarativechangeset.cpp | 479 -- src/quick/util/qdeclarativechangeset_p.h | 166 - src/quick/util/qdeclarativeconnections.cpp | 307 - src/quick/util/qdeclarativeconnections_p.h | 100 - src/quick/util/qdeclarativefontloader.cpp | 335 - src/quick/util/qdeclarativefontloader_p.h | 95 - src/quick/util/qdeclarativelistaccessor.cpp | 138 - src/quick/util/qdeclarativelistaccessor_p.h | 78 - src/quick/util/qdeclarativelistcompositor.cpp | 1214 --- src/quick/util/qdeclarativelistcompositor_p.h | 382 - src/quick/util/qdeclarativepackage.cpp | 202 - src/quick/util/qdeclarativepackage_p.h | 96 - src/quick/util/qdeclarativepath.cpp | 1798 ---- src/quick/util/qdeclarativepath_p.h | 451 - src/quick/util/qdeclarativepath_p_p.h | 88 - src/quick/util/qdeclarativepathinterpolator.cpp | 169 - src/quick/util/qdeclarativepathinterpolator_p.h | 98 - src/quick/util/qdeclarativepixmapcache.cpp | 1278 --- src/quick/util/qdeclarativepixmapcache_p.h | 144 - src/quick/util/qdeclarativepropertychanges.cpp | 796 -- src/quick/util/qdeclarativepropertychanges_p.h | 110 - src/quick/util/qdeclarativesmoothedanimation.cpp | 557 -- src/quick/util/qdeclarativesmoothedanimation_p.h | 100 - src/quick/util/qdeclarativesmoothedanimation_p_p.h | 154 - src/quick/util/qdeclarativespringanimation.cpp | 593 -- src/quick/util/qdeclarativespringanimation_p.h | 107 - src/quick/util/qdeclarativestate.cpp | 729 -- src/quick/util/qdeclarativestate_p.h | 210 - src/quick/util/qdeclarativestate_p_p.h | 264 - src/quick/util/qdeclarativestategroup.cpp | 516 -- src/quick/util/qdeclarativestategroup_p.h | 95 - src/quick/util/qdeclarativestateoperations.cpp | 157 - src/quick/util/qdeclarativestateoperations_p.h | 85 - src/quick/util/qdeclarativestyledtext.cpp | 798 -- src/quick/util/qdeclarativestyledtext_p.h | 103 - src/quick/util/qdeclarativesvgparser.cpp | 614 -- src/quick/util/qdeclarativesvgparser_p.h | 60 - src/quick/util/qdeclarativesystempalette.cpp | 312 - src/quick/util/qdeclarativesystempalette_p.h | 120 - src/quick/util/qdeclarativetimeline.cpp | 947 -- src/quick/util/qdeclarativetimeline_p_p.h | 200 - src/quick/util/qdeclarativetimer.cpp | 327 - src/quick/util/qdeclarativetimer_p.h | 111 - src/quick/util/qdeclarativetransition.cpp | 412 - src/quick/util/qdeclarativetransition_p.h | 127 - src/quick/util/qdeclarativetransitionmanager.cpp | 294 - src/quick/util/qdeclarativetransitionmanager_p_p.h | 91 - src/quick/util/qdeclarativeutilmodule.cpp | 103 - src/quick/util/qdeclarativeutilmodule_p.h | 61 - src/quick/util/qquickanimation.cpp | 2530 ++++++ src/quick/util/qquickanimation_p.h | 464 + src/quick/util/qquickanimation_p_p.h | 322 + src/quick/util/qquickanimationcontroller.cpp | 204 + src/quick/util/qquickanimationcontroller_p.h | 94 + src/quick/util/qquickbehavior.cpp | 238 + src/quick/util/qquickbehavior_p.h | 93 + src/quick/util/qquickbind.cpp | 309 + src/quick/util/qquickbind_p.h | 96 + src/quick/util/qquickchangeset.cpp | 479 ++ src/quick/util/qquickchangeset_p.h | 166 + src/quick/util/qquickconnections.cpp | 307 + src/quick/util/qquickconnections_p.h | 100 + src/quick/util/qquickfontloader.cpp | 335 + src/quick/util/qquickfontloader_p.h | 95 + src/quick/util/qquicklistaccessor.cpp | 138 + src/quick/util/qquicklistaccessor_p.h | 78 + src/quick/util/qquicklistcompositor.cpp | 1214 +++ src/quick/util/qquicklistcompositor_p.h | 382 + src/quick/util/qquickpackage.cpp | 202 + src/quick/util/qquickpackage_p.h | 96 + src/quick/util/qquickpath.cpp | 1798 ++++ src/quick/util/qquickpath_p.h | 451 + src/quick/util/qquickpath_p_p.h | 88 + src/quick/util/qquickpathinterpolator.cpp | 169 + src/quick/util/qquickpathinterpolator_p.h | 98 + src/quick/util/qquickpixmapcache.cpp | 1278 +++ src/quick/util/qquickpixmapcache_p.h | 144 + src/quick/util/qquickpropertychanges.cpp | 796 ++ src/quick/util/qquickpropertychanges_p.h | 110 + src/quick/util/qquicksmoothedanimation.cpp | 557 ++ src/quick/util/qquicksmoothedanimation_p.h | 100 + src/quick/util/qquicksmoothedanimation_p_p.h | 154 + src/quick/util/qquickspringanimation.cpp | 593 ++ src/quick/util/qquickspringanimation_p.h | 107 + src/quick/util/qquickstate.cpp | 729 ++ src/quick/util/qquickstate_p.h | 210 + src/quick/util/qquickstate_p_p.h | 264 + src/quick/util/qquickstatechangescript.cpp | 158 + src/quick/util/qquickstatechangescript_p.h | 85 + src/quick/util/qquickstategroup.cpp | 516 ++ src/quick/util/qquickstategroup_p.h | 95 + src/quick/util/qquickstyledtext.cpp | 798 ++ src/quick/util/qquickstyledtext_p.h | 103 + src/quick/util/qquicksvgparser.cpp | 614 ++ src/quick/util/qquicksvgparser_p.h | 60 + src/quick/util/qquicksystempalette.cpp | 312 + src/quick/util/qquicksystempalette_p.h | 120 + src/quick/util/qquicktimeline.cpp | 947 ++ src/quick/util/qquicktimeline_p_p.h | 200 + src/quick/util/qquicktimer.cpp | 327 + src/quick/util/qquicktimer_p.h | 111 + src/quick/util/qquicktransition.cpp | 412 + src/quick/util/qquicktransition_p.h | 127 + src/quick/util/qquicktransitionmanager.cpp | 294 + src/quick/util/qquicktransitionmanager_p_p.h | 91 + src/quick/util/qquickutilmodule.cpp | 103 + src/quick/util/qquickutilmodule_p.h | 61 + src/quick/util/util.pri | 116 +- src/src.pro | 2 +- sync.profile | 8 +- tests/auto/auto.pro | 4 +- tests/auto/compilerwarnings/data/test_cpp.txt | 2 +- tests/auto/declarative/animation/animation.pro | 7 - .../qabstractanimationjob.pro | 5 - .../tst_qabstractanimationjob.cpp | 229 - .../qanimationgroupjob/qanimationgroupjob.pro | 5 - .../qanimationgroupjob/tst_qanimationgroupjob.cpp | 310 - .../qparallelanimationgroupjob.pro | 5 - .../tst_qparallelanimationgroupjob.cpp | 931 -- .../qpauseanimationjob/qpauseanimationjob.pro | 5 - .../qpauseanimationjob/tst_qpauseanimationjob.cpp | 470 - .../qsequentialanimationgroupjob.pro | 5 - .../tst_qsequentialanimationgroupjob.cpp | 1617 ---- tests/auto/declarative/debugger/debugger.pro | 16 - .../debugger/qdebugmessageservice/data/test.qml | 51 - .../qdebugmessageservice/qdebugmessageservice.pro | 21 - .../tst_qdebugmessageservice.cpp | 242 - .../qdeclarativedebugclient.pro | 11 - .../tst_qdeclarativedebugclient.cpp | 197 - .../data/breakpointRelocation.qml | 53 - .../qdeclarativedebugjs/data/changeBreakpoint.qml | 60 - .../qdeclarativedebugjs/data/condition.qml | 54 - .../qdeclarativedebugjs/data/createComponent.qml | 54 - .../qdeclarativedebugjs/data/exception.qml | 51 - .../qdeclarativedebugjs/data/loadjsfile.qml | 48 - .../qdeclarativedebugjs/data/oncompleted.qml | 53 - .../qdeclarativedebugjs/data/stepAction.qml | 57 - .../debugger/qdeclarativedebugjs/data/test.js | 53 - .../debugger/qdeclarativedebugjs/data/test.qml | 54 - .../debugger/qdeclarativedebugjs/data/timer.qml | 52 - .../qdeclarativedebugjs/qdeclarativedebugjs.pro | 29 - .../tst_qdeclarativedebugjs.cpp | 1790 ---- .../qdeclarativedebugservice.pro | 11 - .../tst_qdeclarativedebugservice.cpp | 216 - .../qdeclarativeenginedebug.pro | 11 - .../tst_qdeclarativeenginedebug.cpp | 1235 --- .../debugger/qdeclarativeinspector/app/app.pro | 9 - .../debugger/qdeclarativeinspector/app/main.cpp | 71 - .../qdeclarativeinspector/app/qtquick2.qml | 5 - .../qdeclarativeinspector.pro | 3 - .../tst_qdeclarativeinspector.cpp | 186 - .../tst_qdeclarativeinspector.pro | 12 - .../qdeclarativeprofilerservice/data/exit.qml | 9 - .../qdeclarativeprofilerservice/data/test.qml | 5 - .../qdeclarativeprofilerservice.pro | 15 - .../tst_qdeclarativeprofilerservice.cpp | 310 - .../debugger/qpacketprotocol/qpacketprotocol.pro | 10 - .../qpacketprotocol/tst_qpacketprotocol.cpp | 263 - .../debugger/qv8profilerservice/data/console.qml | 14 - .../debugger/qv8profilerservice/data/exit.qml | 11 - .../debugger/qv8profilerservice/data/test.qml | 5 - .../qv8profilerservice/qv8profilerservice.pro | 16 - .../qv8profilerservice/tst_qv8profilerservice.cpp | 280 - .../auto/declarative/debugger/shared/debugutil.cpp | 190 - .../auto/declarative/debugger/shared/debugutil_p.h | 127 - tests/auto/declarative/declarative.pro | 55 - .../auto/declarative/parserstress/parserstress.pro | 12 - .../parserstress/tests/ecma/Array/15.4-1.js | 135 - .../parserstress/tests/ecma/Array/15.4-2.js | 114 - .../parserstress/tests/ecma/Array/15.4.1.1.js | 111 - .../parserstress/tests/ecma/Array/15.4.1.2.js | 162 - .../parserstress/tests/ecma/Array/15.4.1.3.js | 84 - .../parserstress/tests/ecma/Array/15.4.1.js | 132 - .../parserstress/tests/ecma/Array/15.4.2.1-1.js | 112 - .../parserstress/tests/ecma/Array/15.4.2.1-2.js | 101 - .../parserstress/tests/ecma/Array/15.4.2.1-3.js | 137 - .../parserstress/tests/ecma/Array/15.4.2.2-1.js | 183 - .../parserstress/tests/ecma/Array/15.4.2.2-2.js | 118 - .../parserstress/tests/ecma/Array/15.4.2.3.js | 101 - .../parserstress/tests/ecma/Array/15.4.3.1-2.js | 81 - .../parserstress/tests/ecma/Array/15.4.3.2.js | 62 - .../parserstress/tests/ecma/Array/15.4.4.1.js | 63 - .../parserstress/tests/ecma/Array/15.4.4.2.js | 120 - .../parserstress/tests/ecma/Array/15.4.4.3-1.js | 163 - .../parserstress/tests/ecma/Array/15.4.4.4-1.js | 294 - .../parserstress/tests/ecma/Array/15.4.4.4-2.js | 169 - .../parserstress/tests/ecma/Array/15.4.4.5-1.js | 225 - .../parserstress/tests/ecma/Array/15.4.4.5-2.js | 227 - .../parserstress/tests/ecma/Array/15.4.4.5-3.js | 182 - .../parserstress/tests/ecma/Array/15.4.4.js | 74 - .../parserstress/tests/ecma/Array/15.4.5.1-1.js | 170 - .../parserstress/tests/ecma/Array/15.4.5.1-2.js | 152 - .../parserstress/tests/ecma/Array/15.4.5.2-1.js | 86 - .../parserstress/tests/ecma/Array/15.4.5.2-2.js | 127 - .../parserstress/tests/ecma/Array/browser.js | 0 .../parserstress/tests/ecma/Array/shell.js | 1 - .../parserstress/tests/ecma/Boolean/15.6.1.js | 96 - .../parserstress/tests/ecma/Boolean/15.6.2.js | 161 - .../parserstress/tests/ecma/Boolean/15.6.3.1-1.js | 72 - .../parserstress/tests/ecma/Boolean/15.6.3.1-2.js | 71 - .../parserstress/tests/ecma/Boolean/15.6.3.1-3.js | 71 - .../parserstress/tests/ecma/Boolean/15.6.3.1-4.js | 75 - .../parserstress/tests/ecma/Boolean/15.6.3.1.js | 69 - .../parserstress/tests/ecma/Boolean/15.6.4-1.js | 72 - .../parserstress/tests/ecma/Boolean/15.6.4.1.js | 62 - .../parserstress/tests/ecma/Boolean/15.6.4.2-1.js | 97 - .../parserstress/tests/ecma/Boolean/15.6.4.2-2.js | 73 - .../parserstress/tests/ecma/Boolean/15.6.4.2-3.js | 65 - .../tests/ecma/Boolean/15.6.4.2-4-n.js | 69 - .../parserstress/tests/ecma/Boolean/15.6.4.3-1.js | 88 - .../parserstress/tests/ecma/Boolean/15.6.4.3-2.js | 67 - .../parserstress/tests/ecma/Boolean/15.6.4.3-3.js | 66 - .../tests/ecma/Boolean/15.6.4.3-4-n.js | 69 - .../parserstress/tests/ecma/Boolean/15.6.4.3.js | 83 - .../parserstress/tests/ecma/Boolean/15.6.4.js | 80 - .../parserstress/tests/ecma/Boolean/browser.js | 0 .../parserstress/tests/ecma/Boolean/shell.js | 1 - .../parserstress/tests/ecma/Date/15.9.1.1-1.js | 96 - .../parserstress/tests/ecma/Date/15.9.1.1-2.js | 91 - .../parserstress/tests/ecma/Date/15.9.1.13-1.js | 79 - .../parserstress/tests/ecma/Date/15.9.2.1.js | 104 - .../parserstress/tests/ecma/Date/15.9.2.2-1.js | 69 - .../parserstress/tests/ecma/Date/15.9.2.2-2.js | 69 - .../parserstress/tests/ecma/Date/15.9.2.2-3.js | 69 - .../parserstress/tests/ecma/Date/15.9.2.2-4.js | 68 - .../parserstress/tests/ecma/Date/15.9.2.2-5.js | 68 - .../parserstress/tests/ecma/Date/15.9.2.2-6.js | 67 - .../parserstress/tests/ecma/Date/15.9.3.1-1.js | 239 - .../parserstress/tests/ecma/Date/15.9.3.1-2.js | 152 - .../parserstress/tests/ecma/Date/15.9.3.1-3.js | 141 - .../parserstress/tests/ecma/Date/15.9.3.1-4.js | 151 - .../parserstress/tests/ecma/Date/15.9.3.1-5.js | 140 - .../parserstress/tests/ecma/Date/15.9.3.2-1.js | 151 - .../parserstress/tests/ecma/Date/15.9.3.2-2.js | 142 - .../parserstress/tests/ecma/Date/15.9.3.2-3.js | 146 - .../parserstress/tests/ecma/Date/15.9.3.2-4.js | 143 - .../parserstress/tests/ecma/Date/15.9.3.2-5.js | 140 - .../parserstress/tests/ecma/Date/15.9.3.8-1.js | 155 - .../parserstress/tests/ecma/Date/15.9.3.8-2.js | 153 - .../parserstress/tests/ecma/Date/15.9.3.8-3.js | 160 - .../parserstress/tests/ecma/Date/15.9.3.8-4.js | 161 - .../parserstress/tests/ecma/Date/15.9.3.8-5.js | 161 - .../parserstress/tests/ecma/Date/15.9.4.2-1.js | 81 - .../parserstress/tests/ecma/Date/15.9.4.2.js | 191 - .../parserstress/tests/ecma/Date/15.9.4.3.js | 186 - .../parserstress/tests/ecma/Date/15.9.5.1.js | 63 - .../parserstress/tests/ecma/Date/15.9.5.10-1.js | 85 - .../parserstress/tests/ecma/Date/15.9.5.10-10.js | 89 - .../parserstress/tests/ecma/Date/15.9.5.10-11.js | 89 - .../parserstress/tests/ecma/Date/15.9.5.10-12.js | 89 - .../parserstress/tests/ecma/Date/15.9.5.10-13.js | 89 - .../parserstress/tests/ecma/Date/15.9.5.10-2.js | 87 - .../parserstress/tests/ecma/Date/15.9.5.10-3.js | 85 - .../parserstress/tests/ecma/Date/15.9.5.10-4.js | 85 - .../parserstress/tests/ecma/Date/15.9.5.10-5.js | 85 - .../parserstress/tests/ecma/Date/15.9.5.10-6.js | 85 - .../parserstress/tests/ecma/Date/15.9.5.10-7.js | 85 - .../parserstress/tests/ecma/Date/15.9.5.10-8.js | 89 - .../parserstress/tests/ecma/Date/15.9.5.10-9.js | 89 - .../parserstress/tests/ecma/Date/15.9.5.11-1.js | 76 - .../parserstress/tests/ecma/Date/15.9.5.11-2.js | 76 - .../parserstress/tests/ecma/Date/15.9.5.11-3.js | 76 - .../parserstress/tests/ecma/Date/15.9.5.11-4.js | 76 - .../parserstress/tests/ecma/Date/15.9.5.11-5.js | 76 - .../parserstress/tests/ecma/Date/15.9.5.11-6.js | 76 - .../parserstress/tests/ecma/Date/15.9.5.11-7.js | 76 - .../parserstress/tests/ecma/Date/15.9.5.12-1.js | 77 - .../parserstress/tests/ecma/Date/15.9.5.12-2.js | 77 - .../parserstress/tests/ecma/Date/15.9.5.12-3.js | 77 - .../parserstress/tests/ecma/Date/15.9.5.12-4.js | 77 - .../parserstress/tests/ecma/Date/15.9.5.12-5.js | 77 - .../parserstress/tests/ecma/Date/15.9.5.12-6.js | 77 - .../parserstress/tests/ecma/Date/15.9.5.12-7.js | 77 - .../parserstress/tests/ecma/Date/15.9.5.12-8.js | 71 - .../parserstress/tests/ecma/Date/15.9.5.13-1.js | 79 - .../parserstress/tests/ecma/Date/15.9.5.13-2.js | 76 - .../parserstress/tests/ecma/Date/15.9.5.13-3.js | 77 - .../parserstress/tests/ecma/Date/15.9.5.13-4.js | 77 - .../parserstress/tests/ecma/Date/15.9.5.13-5.js | 77 - .../parserstress/tests/ecma/Date/15.9.5.13-6.js | 77 - .../parserstress/tests/ecma/Date/15.9.5.13-7.js | 76 - .../parserstress/tests/ecma/Date/15.9.5.13-8.js | 71 - .../parserstress/tests/ecma/Date/15.9.5.14.js | 87 - .../parserstress/tests/ecma/Date/15.9.5.15.js | 88 - .../parserstress/tests/ecma/Date/15.9.5.16.js | 87 - .../parserstress/tests/ecma/Date/15.9.5.17.js | 88 - .../parserstress/tests/ecma/Date/15.9.5.18.js | 88 - .../parserstress/tests/ecma/Date/15.9.5.19.js | 88 - .../parserstress/tests/ecma/Date/15.9.5.2-1.js | 151 - .../parserstress/tests/ecma/Date/15.9.5.2-2-n.js | 84 - .../parserstress/tests/ecma/Date/15.9.5.2.js | 151 - .../parserstress/tests/ecma/Date/15.9.5.20.js | 88 - .../parserstress/tests/ecma/Date/15.9.5.21-1.js | 70 - .../parserstress/tests/ecma/Date/15.9.5.21-2.js | 70 - .../parserstress/tests/ecma/Date/15.9.5.21-3.js | 70 - .../parserstress/tests/ecma/Date/15.9.5.21-4.js | 70 - .../parserstress/tests/ecma/Date/15.9.5.21-5.js | 70 - .../parserstress/tests/ecma/Date/15.9.5.21-6.js | 70 - .../parserstress/tests/ecma/Date/15.9.5.21-7.js | 70 - .../parserstress/tests/ecma/Date/15.9.5.21-8.js | 71 - .../parserstress/tests/ecma/Date/15.9.5.22-1.js | 89 - .../parserstress/tests/ecma/Date/15.9.5.22-2.js | 74 - .../parserstress/tests/ecma/Date/15.9.5.22-3.js | 74 - .../parserstress/tests/ecma/Date/15.9.5.22-4.js | 74 - .../parserstress/tests/ecma/Date/15.9.5.22-5.js | 74 - .../parserstress/tests/ecma/Date/15.9.5.22-6.js | 74 - .../parserstress/tests/ecma/Date/15.9.5.22-7.js | 74 - .../parserstress/tests/ecma/Date/15.9.5.22-8.js | 72 - .../parserstress/tests/ecma/Date/15.9.5.23-1.js | 139 - .../parserstress/tests/ecma/Date/15.9.5.23-10.js | 139 - .../parserstress/tests/ecma/Date/15.9.5.23-11.js | 140 - .../parserstress/tests/ecma/Date/15.9.5.23-12.js | 137 - .../parserstress/tests/ecma/Date/15.9.5.23-13.js | 137 - .../parserstress/tests/ecma/Date/15.9.5.23-14.js | 137 - .../parserstress/tests/ecma/Date/15.9.5.23-15.js | 137 - .../parserstress/tests/ecma/Date/15.9.5.23-16.js | 137 - .../parserstress/tests/ecma/Date/15.9.5.23-17.js | 137 - .../parserstress/tests/ecma/Date/15.9.5.23-18.js | 137 - .../parserstress/tests/ecma/Date/15.9.5.23-2.js | 109 - .../parserstress/tests/ecma/Date/15.9.5.23-3-n.js | 79 - .../parserstress/tests/ecma/Date/15.9.5.23-4.js | 112 - .../parserstress/tests/ecma/Date/15.9.5.23-5.js | 113 - .../parserstress/tests/ecma/Date/15.9.5.23-6.js | 112 - .../parserstress/tests/ecma/Date/15.9.5.23-7.js | 113 - .../parserstress/tests/ecma/Date/15.9.5.23-8.js | 103 - .../parserstress/tests/ecma/Date/15.9.5.23-9.js | 103 - .../parserstress/tests/ecma/Date/15.9.5.24-1.js | 134 - .../parserstress/tests/ecma/Date/15.9.5.24-2.js | 134 - .../parserstress/tests/ecma/Date/15.9.5.24-3.js | 134 - .../parserstress/tests/ecma/Date/15.9.5.24-4.js | 134 - .../parserstress/tests/ecma/Date/15.9.5.24-5.js | 134 - .../parserstress/tests/ecma/Date/15.9.5.24-6.js | 134 - .../parserstress/tests/ecma/Date/15.9.5.24-7.js | 134 - .../parserstress/tests/ecma/Date/15.9.5.24-8.js | 133 - .../parserstress/tests/ecma/Date/15.9.5.25-1.js | 174 - .../parserstress/tests/ecma/Date/15.9.5.26-1.js | 183 - .../parserstress/tests/ecma/Date/15.9.5.27-1.js | 183 - .../parserstress/tests/ecma/Date/15.9.5.28-1.js | 196 - .../parserstress/tests/ecma/Date/15.9.5.29-1.js | 191 - .../parserstress/tests/ecma/Date/15.9.5.3-1-n.js | 80 - .../parserstress/tests/ecma/Date/15.9.5.3-2.js | 104 - .../parserstress/tests/ecma/Date/15.9.5.30-1.js | 192 - .../parserstress/tests/ecma/Date/15.9.5.31-1.js | 221 - .../parserstress/tests/ecma/Date/15.9.5.32-1.js | 141 - .../parserstress/tests/ecma/Date/15.9.5.33-1.js | 145 - .../parserstress/tests/ecma/Date/15.9.5.34-1.js | 182 - .../parserstress/tests/ecma/Date/15.9.5.35-1.js | 139 - .../parserstress/tests/ecma/Date/15.9.5.36-1.js | 165 - .../parserstress/tests/ecma/Date/15.9.5.36-2.js | 164 - .../parserstress/tests/ecma/Date/15.9.5.36-3.js | 163 - .../parserstress/tests/ecma/Date/15.9.5.36-4.js | 163 - .../parserstress/tests/ecma/Date/15.9.5.36-5.js | 163 - .../parserstress/tests/ecma/Date/15.9.5.36-6.js | 163 - .../parserstress/tests/ecma/Date/15.9.5.36-7.js | 163 - .../parserstress/tests/ecma/Date/15.9.5.37-1.js | 173 - .../parserstress/tests/ecma/Date/15.9.5.37-2.js | 161 - .../parserstress/tests/ecma/Date/15.9.5.37-3.js | 164 - .../parserstress/tests/ecma/Date/15.9.5.37-4.js | 163 - .../parserstress/tests/ecma/Date/15.9.5.37-5.js | 159 - .../parserstress/tests/ecma/Date/15.9.5.4-1.js | 93 - .../parserstress/tests/ecma/Date/15.9.5.4-2-n.js | 76 - .../parserstress/tests/ecma/Date/15.9.5.5.js | 112 - .../parserstress/tests/ecma/Date/15.9.5.6.js | 104 - .../parserstress/tests/ecma/Date/15.9.5.7.js | 105 - .../parserstress/tests/ecma/Date/15.9.5.8.js | 113 - .../parserstress/tests/ecma/Date/15.9.5.9.js | 113 - .../parserstress/tests/ecma/Date/15.9.5.js | 83 - .../parserstress/tests/ecma/Date/browser.js | 0 .../parserstress/tests/ecma/Date/shell.js | 1 - .../tests/ecma/ExecutionContexts/10.1.3-1.js | 107 - .../tests/ecma/ExecutionContexts/10.1.3-2.js | 73 - .../tests/ecma/ExecutionContexts/10.1.3.js | 170 - .../tests/ecma/ExecutionContexts/10.1.4-1.js | 111 - .../tests/ecma/ExecutionContexts/10.1.4-10.js | 105 - .../tests/ecma/ExecutionContexts/10.1.4-2.js | 113 - .../tests/ecma/ExecutionContexts/10.1.4-3.js | 111 - .../tests/ecma/ExecutionContexts/10.1.4-4.js | 113 - .../tests/ecma/ExecutionContexts/10.1.4-5.js | 112 - .../tests/ecma/ExecutionContexts/10.1.4-6.js | 100 - .../tests/ecma/ExecutionContexts/10.1.4-7.js | 112 - .../tests/ecma/ExecutionContexts/10.1.4-8.js | 113 - .../tests/ecma/ExecutionContexts/10.1.5-1.js | 118 - .../tests/ecma/ExecutionContexts/10.1.5-2.js | 100 - .../tests/ecma/ExecutionContexts/10.1.5-3.js | 130 - .../tests/ecma/ExecutionContexts/10.1.5-4.js | 91 - .../tests/ecma/ExecutionContexts/10.1.8-2.js | 120 - .../tests/ecma/ExecutionContexts/10.1.8-3.js | 66 - .../tests/ecma/ExecutionContexts/10.2.1.js | 85 - .../tests/ecma/ExecutionContexts/10.2.2-1.js | 122 - .../tests/ecma/ExecutionContexts/10.2.2-2.js | 133 - .../tests/ecma/ExecutionContexts/10.2.3-1.js | 86 - .../tests/ecma/ExecutionContexts/10.2.3-2.js | 92 - .../tests/ecma/ExecutionContexts/browser.js | 0 .../tests/ecma/ExecutionContexts/shell.js | 1 - .../parserstress/tests/ecma/Expressions/11.1.1.js | 137 - .../parserstress/tests/ecma/Expressions/11.10-1.js | 270 - .../parserstress/tests/ecma/Expressions/11.10-2.js | 269 - .../parserstress/tests/ecma/Expressions/11.10-3.js | 268 - .../parserstress/tests/ecma/Expressions/11.12-1.js | 110 - .../tests/ecma/Expressions/11.12-2-n.js | 74 - .../parserstress/tests/ecma/Expressions/11.12-3.js | 71 - .../parserstress/tests/ecma/Expressions/11.12-4.js | 71 - .../parserstress/tests/ecma/Expressions/11.13.1.js | 72 - .../tests/ecma/Expressions/11.13.2-1.js | 231 - .../tests/ecma/Expressions/11.13.2-2.js | 253 - .../tests/ecma/Expressions/11.13.2-3.js | 300 - .../tests/ecma/Expressions/11.13.2-4.js | 137 - .../tests/ecma/Expressions/11.13.2-5.js | 137 - .../parserstress/tests/ecma/Expressions/11.13.js | 86 - .../parserstress/tests/ecma/Expressions/11.14-1.js | 73 - .../tests/ecma/Expressions/11.2.1-1.js | 272 - .../tests/ecma/Expressions/11.2.1-2.js | 128 - .../tests/ecma/Expressions/11.2.1-3-n.js | 128 - .../tests/ecma/Expressions/11.2.1-4-n.js | 128 - .../tests/ecma/Expressions/11.2.1-5.js | 128 - .../tests/ecma/Expressions/11.2.2-1-n.js | 104 - .../tests/ecma/Expressions/11.2.2-1.js | 100 - .../tests/ecma/Expressions/11.2.2-10-n.js | 102 - .../tests/ecma/Expressions/11.2.2-11.js | 104 - .../tests/ecma/Expressions/11.2.2-2-n.js | 104 - .../tests/ecma/Expressions/11.2.2-3-n.js | 100 - .../tests/ecma/Expressions/11.2.2-4-n.js | 104 - .../tests/ecma/Expressions/11.2.2-5-n.js | 104 - .../tests/ecma/Expressions/11.2.2-6-n.js | 103 - .../tests/ecma/Expressions/11.2.2-7-n.js | 104 - .../tests/ecma/Expressions/11.2.2-8-n.js | 104 - .../tests/ecma/Expressions/11.2.2-9-n.js | 104 - .../tests/ecma/Expressions/11.2.3-1.js | 125 - .../tests/ecma/Expressions/11.2.3-2-n.js | 94 - .../tests/ecma/Expressions/11.2.3-3-n.js | 91 - .../tests/ecma/Expressions/11.2.3-4-n.js | 91 - .../tests/ecma/Expressions/11.2.3-5.js | 85 - .../parserstress/tests/ecma/Expressions/11.3.1.js | 153 - .../parserstress/tests/ecma/Expressions/11.3.2.js | 153 - .../parserstress/tests/ecma/Expressions/11.4.1.js | 92 - .../parserstress/tests/ecma/Expressions/11.4.2.js | 83 - .../parserstress/tests/ecma/Expressions/11.4.3.js | 111 - .../parserstress/tests/ecma/Expressions/11.4.4.js | 156 - .../parserstress/tests/ecma/Expressions/11.4.5.js | 154 - .../parserstress/tests/ecma/Expressions/11.4.6.js | 299 - .../tests/ecma/Expressions/11.4.7-01.js | 299 - .../tests/ecma/Expressions/11.4.7-02.js | 87 - .../parserstress/tests/ecma/Expressions/11.4.8.js | 215 - .../parserstress/tests/ecma/Expressions/11.4.9.js | 94 - .../parserstress/tests/ecma/Expressions/11.5.1.js | 115 - .../parserstress/tests/ecma/Expressions/11.5.2.js | 154 - .../parserstress/tests/ecma/Expressions/11.5.3.js | 161 - .../tests/ecma/Expressions/11.6.1-1.js | 160 - .../tests/ecma/Expressions/11.6.1-2.js | 164 - .../tests/ecma/Expressions/11.6.1-3.js | 150 - .../tests/ecma/Expressions/11.6.2-1.js | 165 - .../parserstress/tests/ecma/Expressions/11.6.3.js | 115 - .../parserstress/tests/ecma/Expressions/11.7.1.js | 228 - .../parserstress/tests/ecma/Expressions/11.7.2.js | 246 - .../parserstress/tests/ecma/Expressions/11.7.3.js | 230 - .../parserstress/tests/ecma/Expressions/11.8.1.js | 121 - .../parserstress/tests/ecma/Expressions/11.8.2.js | 121 - .../parserstress/tests/ecma/Expressions/11.8.3.js | 120 - .../parserstress/tests/ecma/Expressions/11.8.4.js | 121 - .../parserstress/tests/ecma/Expressions/11.9.1.js | 159 - .../parserstress/tests/ecma/Expressions/11.9.2.js | 159 - .../parserstress/tests/ecma/Expressions/11.9.3.js | 159 - .../parserstress/tests/ecma/Expressions/browser.js | 0 .../parserstress/tests/ecma/Expressions/shell.js | 1 - .../tests/ecma/FunctionObjects/15.3.1.1-1.js | 136 - .../tests/ecma/FunctionObjects/15.3.1.1-2.js | 183 - .../tests/ecma/FunctionObjects/15.3.1.1-3.js | 99 - .../tests/ecma/FunctionObjects/15.3.2.1-1.js | 132 - .../tests/ecma/FunctionObjects/15.3.2.1-2.js | 107 - .../tests/ecma/FunctionObjects/15.3.2.1-3.js | 95 - .../tests/ecma/FunctionObjects/15.3.3.1-2.js | 70 - .../tests/ecma/FunctionObjects/15.3.3.1-3.js | 79 - .../tests/ecma/FunctionObjects/15.3.3.1-4.js | 70 - .../tests/ecma/FunctionObjects/15.3.3.2.js | 62 - .../tests/ecma/FunctionObjects/15.3.4-1.js | 94 - .../tests/ecma/FunctionObjects/15.3.4.1.js | 61 - .../tests/ecma/FunctionObjects/15.3.4.js | 81 - .../tests/ecma/FunctionObjects/15.3.5-1.js | 117 - .../tests/ecma/FunctionObjects/15.3.5-2.js | 90 - .../tests/ecma/FunctionObjects/15.3.5.1.js | 83 - .../tests/ecma/FunctionObjects/15.3.5.3.js | 72 - .../tests/ecma/FunctionObjects/browser.js | 0 .../tests/ecma/FunctionObjects/shell.js | 1 - .../tests/ecma/GlobalObject/15.1-1-n.js | 70 - .../tests/ecma/GlobalObject/15.1-2-n.js | 67 - .../tests/ecma/GlobalObject/15.1.1.1.js | 63 - .../tests/ecma/GlobalObject/15.1.1.2.js | 62 - .../tests/ecma/GlobalObject/15.1.2.1-2.js | 66 - .../tests/ecma/GlobalObject/15.1.2.2-1.js | 410 - .../tests/ecma/GlobalObject/15.1.2.2-2.js | 238 - .../tests/ecma/GlobalObject/15.1.2.3-1.js | 441 - .../tests/ecma/GlobalObject/15.1.2.3-2.js | 291 - .../tests/ecma/GlobalObject/15.1.2.4.js | 205 - .../tests/ecma/GlobalObject/15.1.2.5-1.js | 206 - .../tests/ecma/GlobalObject/15.1.2.5-2.js | 183 - .../tests/ecma/GlobalObject/15.1.2.5-3.js | 207 - .../tests/ecma/GlobalObject/15.1.2.6.js | 125 - .../tests/ecma/GlobalObject/15.1.2.7.js | 130 - .../tests/ecma/GlobalObject/browser.js | 0 .../parserstress/tests/ecma/GlobalObject/shell.js | 1 - .../tests/ecma/LexicalConventions/7.1-1.js | 82 - .../tests/ecma/LexicalConventions/7.1-2.js | 73 - .../tests/ecma/LexicalConventions/7.1-3.js | 89 - .../tests/ecma/LexicalConventions/7.2-1.js | 73 - .../tests/ecma/LexicalConventions/7.2-2-n.js | 74 - .../tests/ecma/LexicalConventions/7.2-3-n.js | 74 - .../tests/ecma/LexicalConventions/7.2-4-n.js | 73 - .../tests/ecma/LexicalConventions/7.2-5-n.js | 72 - .../tests/ecma/LexicalConventions/7.2-6.js | 68 - .../tests/ecma/LexicalConventions/7.3-1.js | 92 - .../tests/ecma/LexicalConventions/7.3-10.js | 65 - .../tests/ecma/LexicalConventions/7.3-11.js | 66 - .../tests/ecma/LexicalConventions/7.3-12.js | 64 - .../tests/ecma/LexicalConventions/7.3-13-n.js | 66 - .../tests/ecma/LexicalConventions/7.3-2.js | 65 - .../tests/ecma/LexicalConventions/7.3-3.js | 65 - .../tests/ecma/LexicalConventions/7.3-4.js | 65 - .../tests/ecma/LexicalConventions/7.3-5.js | 65 - .../tests/ecma/LexicalConventions/7.3-6.js | 65 - .../tests/ecma/LexicalConventions/7.3-7.js | 66 - .../tests/ecma/LexicalConventions/7.3-8.js | 65 - .../tests/ecma/LexicalConventions/7.3-9.js | 65 - .../tests/ecma/LexicalConventions/7.4.1-1-n.js | 71 - .../tests/ecma/LexicalConventions/7.4.1-2-n.js | 71 - .../tests/ecma/LexicalConventions/7.4.1-3-n.js | 69 - .../tests/ecma/LexicalConventions/7.4.2-1-n.js | 77 - .../tests/ecma/LexicalConventions/7.4.2-10-n.js | 77 - .../tests/ecma/LexicalConventions/7.4.2-11-n.js | 77 - .../tests/ecma/LexicalConventions/7.4.2-12-n.js | 77 - .../tests/ecma/LexicalConventions/7.4.2-13-n.js | 77 - .../tests/ecma/LexicalConventions/7.4.2-14-n.js | 77 - .../tests/ecma/LexicalConventions/7.4.2-15-n.js | 77 - .../tests/ecma/LexicalConventions/7.4.2-16-n.js | 77 - .../tests/ecma/LexicalConventions/7.4.2-2-n.js | 77 - .../tests/ecma/LexicalConventions/7.4.2-3-n.js | 77 - .../tests/ecma/LexicalConventions/7.4.2-4-n.js | 77 - .../tests/ecma/LexicalConventions/7.4.2-5-n.js | 77 - .../tests/ecma/LexicalConventions/7.4.2-6-n.js | 77 - .../tests/ecma/LexicalConventions/7.4.2-7-n.js | 75 - .../tests/ecma/LexicalConventions/7.4.2-8-n.js | 76 - .../tests/ecma/LexicalConventions/7.4.2-9-n.js | 77 - .../tests/ecma/LexicalConventions/7.4.3-1-n.js | 71 - .../tests/ecma/LexicalConventions/7.4.3-10-n.js | 71 - .../tests/ecma/LexicalConventions/7.4.3-11-n.js | 71 - .../tests/ecma/LexicalConventions/7.4.3-12-n.js | 71 - .../tests/ecma/LexicalConventions/7.4.3-13-n.js | 71 - .../tests/ecma/LexicalConventions/7.4.3-14-n.js | 97 - .../tests/ecma/LexicalConventions/7.4.3-15-n.js | 97 - .../tests/ecma/LexicalConventions/7.4.3-16-n.js | 88 - .../tests/ecma/LexicalConventions/7.4.3-2-n.js | 71 - .../tests/ecma/LexicalConventions/7.4.3-3-n.js | 71 - .../tests/ecma/LexicalConventions/7.4.3-4-n.js | 96 - .../tests/ecma/LexicalConventions/7.4.3-5-n.js | 71 - .../tests/ecma/LexicalConventions/7.4.3-6-n.js | 71 - .../tests/ecma/LexicalConventions/7.4.3-7-n.js | 97 - .../tests/ecma/LexicalConventions/7.4.3-8-n.js | 71 - .../tests/ecma/LexicalConventions/7.4.3-9-n.js | 98 - .../tests/ecma/LexicalConventions/7.5-1.js | 62 - .../tests/ecma/LexicalConventions/7.5-10-n.js | 64 - .../tests/ecma/LexicalConventions/7.5-2-n.js | 64 - .../tests/ecma/LexicalConventions/7.5-3-n.js | 64 - .../tests/ecma/LexicalConventions/7.5-4-n.js | 64 - .../tests/ecma/LexicalConventions/7.5-5-n.js | 64 - .../tests/ecma/LexicalConventions/7.5-6.js | 61 - .../tests/ecma/LexicalConventions/7.5-7.js | 61 - .../tests/ecma/LexicalConventions/7.5-8-n.js | 64 - .../tests/ecma/LexicalConventions/7.5-9-n.js | 64 - .../tests/ecma/LexicalConventions/7.6.js | 313 - .../tests/ecma/LexicalConventions/7.7.1.js | 64 - .../tests/ecma/LexicalConventions/7.7.2.js | 71 - .../tests/ecma/LexicalConventions/7.7.3-1.js | 198 - .../tests/ecma/LexicalConventions/7.7.3-2.js | 93 - .../tests/ecma/LexicalConventions/7.7.3.js | 331 - .../tests/ecma/LexicalConventions/7.7.4.js | 269 - .../tests/ecma/LexicalConventions/7.8.2-n.js | 63 - .../tests/ecma/LexicalConventions/browser.js | 0 .../tests/ecma/LexicalConventions/shell.js | 1 - .../parserstress/tests/ecma/Math/15.8-2-n.js | 82 - .../parserstress/tests/ecma/Math/15.8-3-n.js | 81 - .../parserstress/tests/ecma/Math/15.8.1.1-1.js | 64 - .../parserstress/tests/ecma/Math/15.8.1.1-2.js | 69 - .../parserstress/tests/ecma/Math/15.8.1.2-1.js | 64 - .../parserstress/tests/ecma/Math/15.8.1.2-2.js | 70 - .../parserstress/tests/ecma/Math/15.8.1.3-1.js | 65 - .../parserstress/tests/ecma/Math/15.8.1.3-2.js | 72 - .../parserstress/tests/ecma/Math/15.8.1.4-1.js | 65 - .../parserstress/tests/ecma/Math/15.8.1.4-2.js | 69 - .../parserstress/tests/ecma/Math/15.8.1.5-1.js | 66 - .../parserstress/tests/ecma/Math/15.8.1.5-2.js | 70 - .../parserstress/tests/ecma/Math/15.8.1.6-1.js | 65 - .../parserstress/tests/ecma/Math/15.8.1.6-2.js | 70 - .../parserstress/tests/ecma/Math/15.8.1.7-1.js | 65 - .../parserstress/tests/ecma/Math/15.8.1.7-2.js | 70 - .../parserstress/tests/ecma/Math/15.8.1.8-1.js | 65 - .../parserstress/tests/ecma/Math/15.8.1.8-2.js | 69 - .../parserstress/tests/ecma/Math/15.8.1.8-3.js | 63 - .../parserstress/tests/ecma/Math/15.8.1.js | 149 - .../parserstress/tests/ecma/Math/15.8.2.1.js | 226 - .../parserstress/tests/ecma/Math/15.8.2.10.js | 153 - .../parserstress/tests/ecma/Math/15.8.2.11.js | 200 - .../parserstress/tests/ecma/Math/15.8.2.12.js | 177 - .../parserstress/tests/ecma/Math/15.8.2.13.js | 385 - .../parserstress/tests/ecma/Math/15.8.2.14.js | 79 - .../parserstress/tests/ecma/Math/15.8.2.15.js | 202 - .../parserstress/tests/ecma/Math/15.8.2.16.js | 132 - .../parserstress/tests/ecma/Math/15.8.2.17.js | 217 - .../parserstress/tests/ecma/Math/15.8.2.18.js | 165 - .../parserstress/tests/ecma/Math/15.8.2.2.js | 151 - .../parserstress/tests/ecma/Math/15.8.2.3.js | 158 - .../parserstress/tests/ecma/Math/15.8.2.4.js | 156 - .../parserstress/tests/ecma/Math/15.8.2.5.js | 244 - .../parserstress/tests/ecma/Math/15.8.2.6.js | 232 - .../parserstress/tests/ecma/Math/15.8.2.7.js | 283 - .../parserstress/tests/ecma/Math/15.8.2.8.js | 134 - .../parserstress/tests/ecma/Math/15.8.2.9.js | 191 - .../parserstress/tests/ecma/Math/browser.js | 0 .../parserstress/tests/ecma/Math/shell.js | 1 - .../tests/ecma/NativeObjects/browser.js | 0 .../parserstress/tests/ecma/NativeObjects/shell.js | 1 - .../parserstress/tests/ecma/Number/15.7.1.js | 88 - .../parserstress/tests/ecma/Number/15.7.2.js | 168 - .../parserstress/tests/ecma/Number/15.7.3.1-1.js | 71 - .../parserstress/tests/ecma/Number/15.7.3.1-2.js | 71 - .../parserstress/tests/ecma/Number/15.7.3.1-3.js | 67 - .../parserstress/tests/ecma/Number/15.7.3.2-1.js | 65 - .../parserstress/tests/ecma/Number/15.7.3.2-2.js | 70 - .../parserstress/tests/ecma/Number/15.7.3.2-3.js | 67 - .../parserstress/tests/ecma/Number/15.7.3.2-4.js | 64 - .../parserstress/tests/ecma/Number/15.7.3.3-1.js | 68 - .../parserstress/tests/ecma/Number/15.7.3.3-2.js | 73 - .../parserstress/tests/ecma/Number/15.7.3.3-3.js | 64 - .../parserstress/tests/ecma/Number/15.7.3.3-4.js | 66 - .../parserstress/tests/ecma/Number/15.7.3.4-1.js | 66 - .../parserstress/tests/ecma/Number/15.7.3.4-2.js | 71 - .../parserstress/tests/ecma/Number/15.7.3.4-3.js | 65 - .../parserstress/tests/ecma/Number/15.7.3.4-4.js | 66 - .../parserstress/tests/ecma/Number/15.7.3.5-1.js | 64 - .../parserstress/tests/ecma/Number/15.7.3.5-2.js | 70 - .../parserstress/tests/ecma/Number/15.7.3.5-3.js | 65 - .../parserstress/tests/ecma/Number/15.7.3.5-4.js | 66 - .../parserstress/tests/ecma/Number/15.7.3.6-1.js | 65 - .../parserstress/tests/ecma/Number/15.7.3.6-2.js | 69 - .../parserstress/tests/ecma/Number/15.7.3.6-3.js | 65 - .../parserstress/tests/ecma/Number/15.7.3.6-4.js | 66 - .../parserstress/tests/ecma/Number/15.7.3.js | 69 - .../parserstress/tests/ecma/Number/15.7.4-1.js | 60 - .../parserstress/tests/ecma/Number/15.7.4.1.js | 62 - .../parserstress/tests/ecma/Number/15.7.4.2-1.js | 111 - .../parserstress/tests/ecma/Number/15.7.4.2-2-n.js | 76 - .../parserstress/tests/ecma/Number/15.7.4.2-3-n.js | 73 - .../parserstress/tests/ecma/Number/15.7.4.2-4.js | 70 - .../parserstress/tests/ecma/Number/15.7.4.3-1.js | 97 - .../parserstress/tests/ecma/Number/15.7.4.3-2.js | 65 - .../parserstress/tests/ecma/Number/15.7.4.3-3-n.js | 72 - .../parserstress/tests/ecma/Number/browser.js | 0 .../parserstress/tests/ecma/Number/shell.js | 1 - .../tests/ecma/ObjectObjects/15.2.1.1.js | 146 - .../tests/ecma/ObjectObjects/15.2.1.2.js | 81 - .../tests/ecma/ObjectObjects/15.2.2.1.js | 138 - .../tests/ecma/ObjectObjects/15.2.2.2.js | 74 - .../tests/ecma/ObjectObjects/15.2.3-1.js | 64 - .../tests/ecma/ObjectObjects/15.2.3.1-1.js | 69 - .../tests/ecma/ObjectObjects/15.2.3.1-2.js | 70 - .../tests/ecma/ObjectObjects/15.2.3.1-3.js | 70 - .../tests/ecma/ObjectObjects/15.2.3.1-4.js | 70 - .../tests/ecma/ObjectObjects/15.2.3.js | 67 - .../tests/ecma/ObjectObjects/15.2.4.1.js | 64 - .../tests/ecma/ObjectObjects/15.2.4.2.js | 130 - .../tests/ecma/ObjectObjects/15.2.4.3.js | 117 - .../tests/ecma/ObjectObjects/browser.js | 0 .../parserstress/tests/ecma/ObjectObjects/shell.js | 1 - .../declarative/parserstress/tests/ecma/README | 1 - .../parserstress/tests/ecma/SourceText/6-1.js | 128 - .../parserstress/tests/ecma/SourceText/6-2.js | 131 - .../parserstress/tests/ecma/SourceText/browser.js | 0 .../parserstress/tests/ecma/SourceText/shell.js | 1 - .../parserstress/tests/ecma/Statements/12.10-1.js | 151 - .../parserstress/tests/ecma/Statements/12.10.js | 61 - .../parserstress/tests/ecma/Statements/12.2-1.js | 74 - .../parserstress/tests/ecma/Statements/12.5-1.js | 102 - .../parserstress/tests/ecma/Statements/12.5-2.js | 99 - .../parserstress/tests/ecma/Statements/12.6.1-1.js | 74 - .../parserstress/tests/ecma/Statements/12.6.2-1.js | 75 - .../parserstress/tests/ecma/Statements/12.6.2-2.js | 76 - .../parserstress/tests/ecma/Statements/12.6.2-3.js | 72 - .../parserstress/tests/ecma/Statements/12.6.2-4.js | 72 - .../parserstress/tests/ecma/Statements/12.6.2-5.js | 73 - .../parserstress/tests/ecma/Statements/12.6.2-6.js | 75 - .../parserstress/tests/ecma/Statements/12.6.2-7.js | 73 - .../parserstress/tests/ecma/Statements/12.6.2-8.js | 71 - .../tests/ecma/Statements/12.6.2-9-n.js | 76 - .../parserstress/tests/ecma/Statements/12.6.3-1.js | 63 - .../tests/ecma/Statements/12.6.3-10.js | 115 - .../tests/ecma/Statements/12.6.3-11.js | 98 - .../tests/ecma/Statements/12.6.3-12.js | 103 - .../tests/ecma/Statements/12.6.3-19.js | 117 - .../parserstress/tests/ecma/Statements/12.6.3-2.js | 63 - .../parserstress/tests/ecma/Statements/12.6.3-3.js | 73 - .../parserstress/tests/ecma/Statements/12.6.3-4.js | 202 - .../tests/ecma/Statements/12.6.3-5-n.js | 110 - .../tests/ecma/Statements/12.6.3-6-n.js | 109 - .../tests/ecma/Statements/12.6.3-7-n.js | 110 - .../tests/ecma/Statements/12.6.3-8-n.js | 110 - .../tests/ecma/Statements/12.6.3-9-n.js | 109 - .../parserstress/tests/ecma/Statements/12.7-1-n.js | 64 - .../parserstress/tests/ecma/Statements/12.8-1-n.js | 67 - .../parserstress/tests/ecma/Statements/12.9-1-n.js | 63 - .../parserstress/tests/ecma/Statements/browser.js | 0 .../parserstress/tests/ecma/Statements/shell.js | 1 - .../parserstress/tests/ecma/String/15.5.1.js | 134 - .../parserstress/tests/ecma/String/15.5.2.js | 110 - .../parserstress/tests/ecma/String/15.5.3.1-1.js | 71 - .../parserstress/tests/ecma/String/15.5.3.1-2.js | 69 - .../parserstress/tests/ecma/String/15.5.3.1-3.js | 66 - .../parserstress/tests/ecma/String/15.5.3.1-4.js | 66 - .../parserstress/tests/ecma/String/15.5.3.2-1.js | 190 - .../parserstress/tests/ecma/String/15.5.3.2-2.js | 77 - .../parserstress/tests/ecma/String/15.5.3.2-3.js | 121 - .../parserstress/tests/ecma/String/15.5.3.js | 66 - .../parserstress/tests/ecma/String/15.5.4.1.js | 63 - .../parserstress/tests/ecma/String/15.5.4.10-1.js | 217 - .../parserstress/tests/ecma/String/15.5.4.11-1.js | 518 -- .../parserstress/tests/ecma/String/15.5.4.11-2.js | 515 -- .../parserstress/tests/ecma/String/15.5.4.11-3.js | 514 -- .../parserstress/tests/ecma/String/15.5.4.11-4.js | 507 -- .../parserstress/tests/ecma/String/15.5.4.11-5.js | 520 -- .../parserstress/tests/ecma/String/15.5.4.11-6.js | 516 -- .../parserstress/tests/ecma/String/15.5.4.12-1.js | 520 -- .../parserstress/tests/ecma/String/15.5.4.12-2.js | 518 -- .../parserstress/tests/ecma/String/15.5.4.12-3.js | 559 -- .../parserstress/tests/ecma/String/15.5.4.12-4.js | 515 -- .../parserstress/tests/ecma/String/15.5.4.12-5.js | 515 -- .../parserstress/tests/ecma/String/15.5.4.2-1.js | 72 - .../parserstress/tests/ecma/String/15.5.4.2-2-n.js | 73 - .../parserstress/tests/ecma/String/15.5.4.2-3.js | 83 - .../parserstress/tests/ecma/String/15.5.4.2.js | 87 - .../parserstress/tests/ecma/String/15.5.4.3-1.js | 72 - .../parserstress/tests/ecma/String/15.5.4.3-2.js | 90 - .../parserstress/tests/ecma/String/15.5.4.3-3-n.js | 72 - .../parserstress/tests/ecma/String/15.5.4.4-1.js | 92 - .../parserstress/tests/ecma/String/15.5.4.4-2.js | 136 - .../parserstress/tests/ecma/String/15.5.4.4-3.js | 112 - .../parserstress/tests/ecma/String/15.5.4.4-4.js | 124 - .../parserstress/tests/ecma/String/15.5.4.5-1.js | 87 - .../parserstress/tests/ecma/String/15.5.4.5-2.js | 121 - .../parserstress/tests/ecma/String/15.5.4.5-3.js | 131 - .../parserstress/tests/ecma/String/15.5.4.5-4.js | 75 - .../parserstress/tests/ecma/String/15.5.4.5-5.js | 106 - .../parserstress/tests/ecma/String/15.5.4.6-1.js | 155 - .../parserstress/tests/ecma/String/15.5.4.6-2.js | 259 - .../parserstress/tests/ecma/String/15.5.4.7-1.js | 219 - .../parserstress/tests/ecma/String/15.5.4.7-2.js | 217 - .../parserstress/tests/ecma/String/15.5.4.8-1.js | 232 - .../parserstress/tests/ecma/String/15.5.4.8-2.js | 247 - .../parserstress/tests/ecma/String/15.5.4.8-3.js | 204 - .../parserstress/tests/ecma/String/15.5.4.9-1.js | 202 - .../parserstress/tests/ecma/String/15.5.4.js | 108 - .../parserstress/tests/ecma/String/15.5.5.1.js | 88 - .../parserstress/tests/ecma/String/browser.js | 0 .../parserstress/tests/ecma/String/shell.js | 1 - .../parserstress/tests/ecma/TypeConversion/9.2.js | 138 - .../tests/ecma/TypeConversion/9.3-1.js | 100 - .../tests/ecma/TypeConversion/9.3.1-1.js | 323 - .../tests/ecma/TypeConversion/9.3.1-2.js | 87 - .../tests/ecma/TypeConversion/9.3.1-3.js | 743 -- .../parserstress/tests/ecma/TypeConversion/9.3.js | 87 - .../tests/ecma/TypeConversion/9.4-1.js | 112 - .../tests/ecma/TypeConversion/9.4-2.js | 112 - .../tests/ecma/TypeConversion/9.5-2.js | 173 - .../parserstress/tests/ecma/TypeConversion/9.6.js | 140 - .../parserstress/tests/ecma/TypeConversion/9.7.js | 160 - .../tests/ecma/TypeConversion/9.8.1.js | 167 - .../tests/ecma/TypeConversion/9.9-1.js | 119 - .../tests/ecma/TypeConversion/browser.js | 0 .../tests/ecma/TypeConversion/shell.js | 1 - .../parserstress/tests/ecma/Types/8.1.js | 75 - .../parserstress/tests/ecma/Types/8.4.js | 130 - .../parserstress/tests/ecma/Types/8.6.2.1-1.js | 78 - .../parserstress/tests/ecma/Types/browser.js | 0 .../parserstress/tests/ecma/Types/shell.js | 1 - .../declarative/parserstress/tests/ecma/browser.js | 62 - .../parserstress/tests/ecma/extensions/10.1.4-9.js | 110 - .../parserstress/tests/ecma/extensions/10.1.6.js | 127 - .../parserstress/tests/ecma/extensions/10.1.8-1.js | 135 - .../parserstress/tests/ecma/extensions/11.6.1-1.js | 145 - .../parserstress/tests/ecma/extensions/11.6.1-2.js | 136 - .../parserstress/tests/ecma/extensions/11.6.1-3.js | 137 - .../parserstress/tests/ecma/extensions/11.6.2-1.js | 124 - .../parserstress/tests/ecma/extensions/15-1.js | 94 - .../parserstress/tests/ecma/extensions/15-2.js | 77 - .../tests/ecma/extensions/15.1.2.1-1.js | 88 - .../parserstress/tests/ecma/extensions/15.2.1.1.js | 82 - .../parserstress/tests/ecma/extensions/15.2.3-1.js | 64 - .../parserstress/tests/ecma/extensions/15.2.4.js | 66 - .../tests/ecma/extensions/15.3.1.1-1.js | 82 - .../tests/ecma/extensions/15.3.1.1-2.js | 82 - .../tests/ecma/extensions/15.3.2.1-1.js | 72 - .../tests/ecma/extensions/15.3.2.1-2.js | 72 - .../tests/ecma/extensions/15.3.3.1-1.js | 67 - .../parserstress/tests/ecma/extensions/15.4.3.js | 63 - .../parserstress/tests/ecma/extensions/15.5.3.js | 66 - .../parserstress/tests/ecma/extensions/15.5.4.2.js | 59 - .../tests/ecma/extensions/15.5.4.4-4.js | 107 - .../tests/ecma/extensions/15.5.4.5-6.js | 94 - .../tests/ecma/extensions/15.5.4.7-3.js | 161 - .../tests/ecma/extensions/15.6.3.1-5.js | 58 - .../parserstress/tests/ecma/extensions/15.6.3.js | 65 - .../parserstress/tests/ecma/extensions/15.6.4-2.js | 66 - .../parserstress/tests/ecma/extensions/15.7.3.js | 69 - .../parserstress/tests/ecma/extensions/15.7.4.js | 90 - .../parserstress/tests/ecma/extensions/15.8-1.js | 84 - .../parserstress/tests/ecma/extensions/15.9.5.js | 76 - .../tests/ecma/extensions/8.6.2.1-1.js | 98 - .../parserstress/tests/ecma/extensions/9.9-1.js | 102 - .../parserstress/tests/ecma/extensions/browser.js | 0 .../parserstress/tests/ecma/extensions/shell.js | 1 - .../declarative/parserstress/tests/ecma/jsref.js | 634 -- .../declarative/parserstress/tests/ecma/shell.js | 577 -- .../parserstress/tests/ecma/template.js | 70 - .../tests/ecma_2/Exceptions/boolean-001.js | 80 - .../tests/ecma_2/Exceptions/boolean-002.js | 84 - .../tests/ecma_2/Exceptions/browser.js | 0 .../tests/ecma_2/Exceptions/date-001.js | 93 - .../tests/ecma_2/Exceptions/date-002.js | 87 - .../tests/ecma_2/Exceptions/date-003.js | 89 - .../tests/ecma_2/Exceptions/date-004.js | 83 - .../tests/ecma_2/Exceptions/exception-001.js | 78 - .../tests/ecma_2/Exceptions/exception-002.js | 78 - .../tests/ecma_2/Exceptions/exception-003.js | 82 - .../tests/ecma_2/Exceptions/exception-004.js | 78 - .../tests/ecma_2/Exceptions/exception-005.js | 78 - .../tests/ecma_2/Exceptions/exception-006.js | 89 - .../tests/ecma_2/Exceptions/exception-007.js | 90 - .../tests/ecma_2/Exceptions/exception-008.js | 77 - .../tests/ecma_2/Exceptions/exception-009.js | 86 - .../tests/ecma_2/Exceptions/exception-010-n.js | 61 - .../tests/ecma_2/Exceptions/exception-011-n.js | 62 - .../tests/ecma_2/Exceptions/expression-001.js | 83 - .../tests/ecma_2/Exceptions/expression-002.js | 93 - .../tests/ecma_2/Exceptions/expression-003.js | 88 - .../tests/ecma_2/Exceptions/expression-004.js | 82 - .../tests/ecma_2/Exceptions/expression-005.js | 74 - .../tests/ecma_2/Exceptions/expression-006.js | 79 - .../tests/ecma_2/Exceptions/expression-007.js | 77 - .../tests/ecma_2/Exceptions/expression-008.js | 74 - .../tests/ecma_2/Exceptions/expression-009.js | 75 - .../tests/ecma_2/Exceptions/expression-010.js | 76 - .../tests/ecma_2/Exceptions/expression-011.js | 76 - .../tests/ecma_2/Exceptions/expression-012.js | 77 - .../tests/ecma_2/Exceptions/expression-013.js | 77 - .../tests/ecma_2/Exceptions/expression-014.js | 79 - .../tests/ecma_2/Exceptions/expression-015.js | 73 - .../tests/ecma_2/Exceptions/expression-016.js | 73 - .../tests/ecma_2/Exceptions/expression-017.js | 73 - .../tests/ecma_2/Exceptions/expression-019.js | 77 - .../tests/ecma_2/Exceptions/function-001.js | 86 - .../tests/ecma_2/Exceptions/global-001.js | 78 - .../tests/ecma_2/Exceptions/global-002.js | 78 - .../tests/ecma_2/Exceptions/lexical-001.js | 85 - .../tests/ecma_2/Exceptions/lexical-002.js | 85 - .../tests/ecma_2/Exceptions/lexical-003.js | 76 - .../tests/ecma_2/Exceptions/lexical-004.js | 85 - .../tests/ecma_2/Exceptions/lexical-005.js | 85 - .../tests/ecma_2/Exceptions/lexical-006.js | 91 - .../tests/ecma_2/Exceptions/lexical-007.js | 84 - .../tests/ecma_2/Exceptions/lexical-008.js | 86 - .../tests/ecma_2/Exceptions/lexical-009.js | 86 - .../tests/ecma_2/Exceptions/lexical-010.js | 84 - .../tests/ecma_2/Exceptions/lexical-011.js | 95 - .../tests/ecma_2/Exceptions/lexical-012.js | 86 - .../tests/ecma_2/Exceptions/lexical-013.js | 86 - .../tests/ecma_2/Exceptions/lexical-014.js | 95 - .../tests/ecma_2/Exceptions/lexical-015.js | 86 - .../tests/ecma_2/Exceptions/lexical-016.js | 95 - .../tests/ecma_2/Exceptions/lexical-017.js | 87 - .../tests/ecma_2/Exceptions/lexical-018.js | 86 - .../tests/ecma_2/Exceptions/lexical-019.js | 86 - .../tests/ecma_2/Exceptions/lexical-020.js | 86 - .../tests/ecma_2/Exceptions/lexical-021.js | 95 - .../tests/ecma_2/Exceptions/lexical-022.js | 86 - .../tests/ecma_2/Exceptions/lexical-023.js | 85 - .../tests/ecma_2/Exceptions/lexical-024.js | 92 - .../tests/ecma_2/Exceptions/lexical-025.js | 92 - .../tests/ecma_2/Exceptions/lexical-026.js | 92 - .../tests/ecma_2/Exceptions/lexical-027.js | 94 - .../tests/ecma_2/Exceptions/lexical-028.js | 92 - .../tests/ecma_2/Exceptions/lexical-029.js | 92 - .../tests/ecma_2/Exceptions/lexical-030.js | 92 - .../tests/ecma_2/Exceptions/lexical-031.js | 92 - .../tests/ecma_2/Exceptions/lexical-032.js | 92 - .../tests/ecma_2/Exceptions/lexical-033.js | 92 - .../tests/ecma_2/Exceptions/lexical-034.js | 91 - .../tests/ecma_2/Exceptions/lexical-035.js | 92 - .../tests/ecma_2/Exceptions/lexical-036.js | 92 - .../tests/ecma_2/Exceptions/lexical-037.js | 92 - .../tests/ecma_2/Exceptions/lexical-038.js | 92 - .../tests/ecma_2/Exceptions/lexical-039.js | 79 - .../tests/ecma_2/Exceptions/lexical-040.js | 79 - .../tests/ecma_2/Exceptions/lexical-041.js | 81 - .../tests/ecma_2/Exceptions/lexical-042.js | 82 - .../tests/ecma_2/Exceptions/lexical-047.js | 83 - .../tests/ecma_2/Exceptions/lexical-048.js | 77 - .../tests/ecma_2/Exceptions/lexical-049.js | 82 - .../tests/ecma_2/Exceptions/lexical-050.js | 78 - .../tests/ecma_2/Exceptions/lexical-051.js | 78 - .../tests/ecma_2/Exceptions/lexical-052.js | 80 - .../tests/ecma_2/Exceptions/lexical-053.js | 78 - .../tests/ecma_2/Exceptions/lexical-054.js | 79 - .../tests/ecma_2/Exceptions/number-001.js | 86 - .../tests/ecma_2/Exceptions/number-002.js | 81 - .../tests/ecma_2/Exceptions/number-003.js | 83 - .../parserstress/tests/ecma_2/Exceptions/shell.js | 1 - .../tests/ecma_2/Exceptions/statement-001.js | 80 - .../tests/ecma_2/Exceptions/statement-002.js | 102 - .../tests/ecma_2/Exceptions/statement-003.js | 113 - .../tests/ecma_2/Exceptions/statement-004.js | 85 - .../tests/ecma_2/Exceptions/statement-005.js | 84 - .../tests/ecma_2/Exceptions/statement-006.js | 84 - .../tests/ecma_2/Exceptions/statement-007.js | 75 - .../tests/ecma_2/Exceptions/statement-008.js | 75 - .../tests/ecma_2/Exceptions/statement-009.js | 74 - .../tests/ecma_2/Exceptions/string-001.js | 86 - .../tests/ecma_2/Exceptions/string-002.js | 85 - .../tests/ecma_2/Expressions/StrictEquality-001.js | 106 - .../tests/ecma_2/Expressions/browser.js | 0 .../parserstress/tests/ecma_2/Expressions/shell.js | 1 - .../tests/ecma_2/FunctionObjects/apply-001-n.js | 65 - .../tests/ecma_2/FunctionObjects/browser.js | 0 .../tests/ecma_2/FunctionObjects/call-1.js | 75 - .../tests/ecma_2/FunctionObjects/shell.js | 1 - .../tests/ecma_2/LexicalConventions/browser.js | 0 .../ecma_2/LexicalConventions/keywords-001.js | 81 - .../LexicalConventions/regexp-literals-001.js | 77 - .../LexicalConventions/regexp-literals-002.js | 61 - .../tests/ecma_2/LexicalConventions/shell.js | 1 - .../declarative/parserstress/tests/ecma_2/README | 1 - .../parserstress/tests/ecma_2/RegExp/browser.js | 0 .../tests/ecma_2/RegExp/constructor-001.js | 99 - .../parserstress/tests/ecma_2/RegExp/exec-001.js | 73 - .../parserstress/tests/ecma_2/RegExp/exec-002.js | 221 - .../tests/ecma_2/RegExp/function-001.js | 99 - .../parserstress/tests/ecma_2/RegExp/hex-001.js | 102 - .../tests/ecma_2/RegExp/multiline-001.js | 101 - .../parserstress/tests/ecma_2/RegExp/octal-001.js | 111 - .../parserstress/tests/ecma_2/RegExp/octal-002.js | 126 - .../parserstress/tests/ecma_2/RegExp/octal-003.js | 120 - .../tests/ecma_2/RegExp/properties-001.js | 124 - .../tests/ecma_2/RegExp/properties-002.js | 162 - .../tests/ecma_2/RegExp/regexp-enumerate-001.js | 121 - .../tests/ecma_2/RegExp/regress-001.js | 78 - .../parserstress/tests/ecma_2/RegExp/shell.js | 1 - .../tests/ecma_2/RegExp/unicode-001.js | 92 - .../tests/ecma_2/Statements/browser.js | 0 .../tests/ecma_2/Statements/dowhile-001.js | 77 - .../tests/ecma_2/Statements/dowhile-002.js | 104 - .../tests/ecma_2/Statements/dowhile-003.js | 96 - .../tests/ecma_2/Statements/dowhile-004.js | 100 - .../tests/ecma_2/Statements/dowhile-005.js | 106 - .../tests/ecma_2/Statements/dowhile-006.js | 122 - .../tests/ecma_2/Statements/dowhile-007.js | 130 - .../tests/ecma_2/Statements/forin-001.js | 330 - .../tests/ecma_2/Statements/forin-002.js | 109 - .../parserstress/tests/ecma_2/Statements/if-001.js | 75 - .../tests/ecma_2/Statements/label-001.js | 75 - .../tests/ecma_2/Statements/label-002.js | 89 - .../parserstress/tests/ecma_2/Statements/shell.js | 1 - .../tests/ecma_2/Statements/switch-001.js | 98 - .../tests/ecma_2/Statements/switch-002.js | 96 - .../tests/ecma_2/Statements/switch-003.js | 90 - .../tests/ecma_2/Statements/switch-004.js | 127 - .../tests/ecma_2/Statements/try-001.js | 118 - .../tests/ecma_2/Statements/try-003.js | 115 - .../tests/ecma_2/Statements/try-004.js | 87 - .../tests/ecma_2/Statements/try-005.js | 90 - .../tests/ecma_2/Statements/try-006.js | 120 - .../tests/ecma_2/Statements/try-007.js | 125 - .../tests/ecma_2/Statements/try-008.js | 92 - .../tests/ecma_2/Statements/try-009.js | 99 - .../tests/ecma_2/Statements/try-010.js | 106 - .../tests/ecma_2/Statements/try-012.js | 128 - .../tests/ecma_2/Statements/while-001.js | 75 - .../tests/ecma_2/Statements/while-002.js | 119 - .../tests/ecma_2/Statements/while-003.js | 120 - .../tests/ecma_2/Statements/while-004.js | 250 - .../parserstress/tests/ecma_2/String/browser.js | 0 .../parserstress/tests/ecma_2/String/match-001.js | 139 - .../parserstress/tests/ecma_2/String/match-002.js | 207 - .../parserstress/tests/ecma_2/String/match-003.js | 165 - .../parserstress/tests/ecma_2/String/match-004.js | 206 - .../tests/ecma_2/String/replace-001.js | 99 - .../parserstress/tests/ecma_2/String/shell.js | 1 - .../parserstress/tests/ecma_2/String/split-001.js | 145 - .../parserstress/tests/ecma_2/String/split-002.js | 303 - .../parserstress/tests/ecma_2/String/split-003.js | 156 - .../parserstress/tests/ecma_2/browser.js | 37 - .../tests/ecma_2/extensions/browser.js | 0 .../tests/ecma_2/extensions/constructor-001.js | 74 - .../tests/ecma_2/extensions/function-001.js | 74 - .../tests/ecma_2/extensions/instanceof-001.js | 144 - .../tests/ecma_2/extensions/instanceof-002.js | 160 - .../tests/ecma_2/extensions/instanceof-003-n.js | 121 - .../tests/ecma_2/extensions/instanceof-004-n.js | 121 - .../tests/ecma_2/extensions/instanceof-005-n.js | 122 - .../tests/ecma_2/extensions/instanceof-006.js | 119 - .../parserstress/tests/ecma_2/extensions/shell.js | 1 - .../tests/ecma_2/instanceof/browser.js | 0 .../tests/ecma_2/instanceof/instanceof-001.js | 67 - .../tests/ecma_2/instanceof/instanceof-002.js | 84 - .../tests/ecma_2/instanceof/instanceof-003.js | 98 - .../tests/ecma_2/instanceof/regress-7635.js | 88 - .../parserstress/tests/ecma_2/instanceof/shell.js | 1 - .../declarative/parserstress/tests/ecma_2/jsref.js | 591 -- .../declarative/parserstress/tests/ecma_2/shell.js | 51 - .../parserstress/tests/ecma_2/template.js | 57 - .../tests/ecma_3/Array/15.4.4.11-01.js | 61 - .../parserstress/tests/ecma_3/Array/15.4.4.3-1.js | 88 - .../tests/ecma_3/Array/15.4.4.4-001.js | 153 - .../parserstress/tests/ecma_3/Array/15.4.5.1-01.js | 93 - .../parserstress/tests/ecma_3/Array/browser.js | 0 .../tests/ecma_3/Array/regress-101488.js | 172 - .../tests/ecma_3/Array/regress-130451.js | 219 - .../tests/ecma_3/Array/regress-322135-01.js | 73 - .../tests/ecma_3/Array/regress-322135-02.js | 65 - .../tests/ecma_3/Array/regress-322135-03.js | 73 - .../tests/ecma_3/Array/regress-322135-04.js | 71 - .../tests/ecma_3/Array/regress-387501.js | 94 - .../tests/ecma_3/Array/regress-421325.js | 67 - .../tests/ecma_3/Array/regress-430717.js | 65 - .../parserstress/tests/ecma_3/Array/shell.js | 1 - .../parserstress/tests/ecma_3/Date/15.9.1.2-01.js | 62 - .../parserstress/tests/ecma_3/Date/15.9.3.2-1.js | 91 - .../parserstress/tests/ecma_3/Date/15.9.4.3.js | 233 - .../parserstress/tests/ecma_3/Date/15.9.5.3.js | 152 - .../parserstress/tests/ecma_3/Date/15.9.5.4.js | 185 - .../parserstress/tests/ecma_3/Date/15.9.5.5-02.js | 88 - .../parserstress/tests/ecma_3/Date/15.9.5.5.js | 144 - .../parserstress/tests/ecma_3/Date/15.9.5.6.js | 153 - .../parserstress/tests/ecma_3/Date/15.9.5.7.js | 142 - .../parserstress/tests/ecma_3/Date/browser.js | 37 - .../parserstress/tests/ecma_3/Date/shell.js | 564 -- .../tests/ecma_3/Exceptions/15.11.1.1.js | 137 - .../tests/ecma_3/Exceptions/15.11.4.4-1.js | 174 - .../tests/ecma_3/Exceptions/15.11.7.6-001.js | 130 - .../tests/ecma_3/Exceptions/15.11.7.6-002.js | 132 - .../tests/ecma_3/Exceptions/15.11.7.6-003.js | 132 - .../tests/ecma_3/Exceptions/binding-001.js | 128 - .../tests/ecma_3/Exceptions/browser.js | 0 .../tests/ecma_3/Exceptions/regress-181654.js | 155 - .../tests/ecma_3/Exceptions/regress-181914.js | 194 - .../tests/ecma_3/Exceptions/regress-58946.js | 71 - .../tests/ecma_3/Exceptions/regress-95101.js | 118 - .../parserstress/tests/ecma_3/Exceptions/shell.js | 1 - .../tests/ecma_3/ExecutionContexts/10.1.3-1.js | 201 - .../tests/ecma_3/ExecutionContexts/10.1.3-2.js | 70 - .../tests/ecma_3/ExecutionContexts/10.1.3.js | 73 - .../tests/ecma_3/ExecutionContexts/10.1.4-1.js | 85 - .../tests/ecma_3/ExecutionContexts/10.6.1-01.js | 136 - .../tests/ecma_3/ExecutionContexts/browser.js | 0 .../ecma_3/ExecutionContexts/regress-23346.js | 71 - .../ecma_3/ExecutionContexts/regress-448595-01.js | 91 - .../tests/ecma_3/ExecutionContexts/shell.js | 1 - .../tests/ecma_3/Expressions/11.10-01.js | 76 - .../tests/ecma_3/Expressions/11.10-02.js | 76 - .../tests/ecma_3/Expressions/11.10-03.js | 76 - .../tests/ecma_3/Expressions/11.6.1-1.js | 176 - .../tests/ecma_3/Expressions/11.7.1-01.js | 76 - .../tests/ecma_3/Expressions/11.7.2-01.js | 76 - .../tests/ecma_3/Expressions/11.7.3-01.js | 76 - .../tests/ecma_3/Expressions/11.9.6-1.js | 213 - .../tests/ecma_3/Expressions/browser.js | 0 .../parserstress/tests/ecma_3/Expressions/shell.js | 1 - .../parserstress/tests/ecma_3/FunExpr/browser.js | 0 .../parserstress/tests/ecma_3/FunExpr/fe-001-n.js | 58 - .../parserstress/tests/ecma_3/FunExpr/fe-001.js | 57 - .../parserstress/tests/ecma_3/FunExpr/fe-002.js | 61 - .../parserstress/tests/ecma_3/FunExpr/shell.js | 1 - .../tests/ecma_3/Function/15.3.4.3-1.js | 210 - .../tests/ecma_3/Function/15.3.4.4-1.js | 185 - .../tests/ecma_3/Function/arguments-001.js | 169 - .../tests/ecma_3/Function/arguments-002.js | 73 - .../parserstress/tests/ecma_3/Function/browser.js | 0 .../parserstress/tests/ecma_3/Function/call-001.js | 153 - .../tests/ecma_3/Function/regress-131964.js | 196 - .../tests/ecma_3/Function/regress-137181.js | 113 - .../tests/ecma_3/Function/regress-193555.js | 136 - .../tests/ecma_3/Function/regress-313570.js | 63 - .../tests/ecma_3/Function/regress-49286.js | 137 - .../tests/ecma_3/Function/regress-58274.js | 226 - .../tests/ecma_3/Function/regress-85880.js | 173 - .../tests/ecma_3/Function/regress-94506.js | 163 - .../tests/ecma_3/Function/regress-97921.js | 152 - .../tests/ecma_3/Function/scope-001.js | 265 - .../tests/ecma_3/Function/scope-002.js | 245 - .../parserstress/tests/ecma_3/Function/shell.js | 1 - .../tests/ecma_3/LexicalConventions/7.9.1.js | 157 - .../tests/ecma_3/LexicalConventions/browser.js | 0 .../tests/ecma_3/LexicalConventions/shell.js | 1 - .../tests/ecma_3/Number/15.7.4.2-01.js | 77 - .../tests/ecma_3/Number/15.7.4.3-01.js | 69 - .../tests/ecma_3/Number/15.7.4.3-02.js | 53 - .../parserstress/tests/ecma_3/Number/15.7.4.5-1.js | 145 - .../parserstress/tests/ecma_3/Number/15.7.4.6-1.js | 134 - .../parserstress/tests/ecma_3/Number/15.7.4.7-1.js | 139 - .../parserstress/tests/ecma_3/Number/15.7.4.7-2.js | 72 - .../parserstress/tests/ecma_3/Number/browser.js | 0 .../tests/ecma_3/Number/regress-442242-01.js | 62 - .../parserstress/tests/ecma_3/Number/shell.js | 1 - .../tests/ecma_3/NumberFormatting/browser.js | 0 .../tests/ecma_3/NumberFormatting/shell.js | 1 - .../tests/ecma_3/NumberFormatting/tostring-001.js | 60 - .../parserstress/tests/ecma_3/Object/8.6.1-01.js | 113 - .../tests/ecma_3/Object/8.6.2.6-001.js | 113 - .../parserstress/tests/ecma_3/Object/browser.js | 7 - .../parserstress/tests/ecma_3/Object/class-001.js | 156 - .../parserstress/tests/ecma_3/Object/class-002.js | 146 - .../parserstress/tests/ecma_3/Object/class-003.js | 139 - .../parserstress/tests/ecma_3/Object/class-004.js | 139 - .../parserstress/tests/ecma_3/Object/class-005.js | 124 - .../tests/ecma_3/Object/regress-361274.js | 66 - .../tests/ecma_3/Object/regress-385393-07.js | 67 - .../tests/ecma_3/Object/regress-72773.js | 97 - .../tests/ecma_3/Object/regress-79129-001.js | 80 - .../parserstress/tests/ecma_3/Object/shell.js | 105 - .../tests/ecma_3/Operators/11.13.1-001.js | 152 - .../tests/ecma_3/Operators/11.13.1-002.js | 57 - .../tests/ecma_3/Operators/11.4.1-001.js | 120 - .../tests/ecma_3/Operators/11.4.1-002.js | 72 - .../parserstress/tests/ecma_3/Operators/browser.js | 0 .../tests/ecma_3/Operators/order-01.js | 108 - .../parserstress/tests/ecma_3/Operators/shell.js | 1 - .../declarative/parserstress/tests/ecma_3/README | 1 - .../parserstress/tests/ecma_3/RegExp/15.10.2-1.js | 181 - .../parserstress/tests/ecma_3/RegExp/15.10.2.12.js | 63 - .../tests/ecma_3/RegExp/15.10.3.1-1.js | 136 - .../tests/ecma_3/RegExp/15.10.3.1-2.js | 144 - .../tests/ecma_3/RegExp/15.10.4.1-1.js | 127 - .../tests/ecma_3/RegExp/15.10.4.1-2.js | 133 - .../tests/ecma_3/RegExp/15.10.4.1-3.js | 139 - .../tests/ecma_3/RegExp/15.10.4.1-4.js | 146 - .../tests/ecma_3/RegExp/15.10.4.1-5-n.js | 139 - .../tests/ecma_3/RegExp/15.10.6.2-1.js | 140 - .../tests/ecma_3/RegExp/15.10.6.2-2.js | 367 - .../parserstress/tests/ecma_3/RegExp/browser.js | 0 .../parserstress/tests/ecma_3/RegExp/octal-001.js | 136 - .../parserstress/tests/ecma_3/RegExp/octal-002.js | 218 - .../tests/ecma_3/RegExp/perlstress-001.js | 3230 ------- .../tests/ecma_3/RegExp/perlstress-002.js | 1842 ---- .../tests/ecma_3/RegExp/regress-100199.js | 307 - .../tests/ecma_3/RegExp/regress-105972.js | 157 - .../tests/ecma_3/RegExp/regress-119909.js | 92 - .../tests/ecma_3/RegExp/regress-122076.js | 110 - .../tests/ecma_3/RegExp/regress-123437.js | 112 - .../tests/ecma_3/RegExp/regress-165353.js | 122 - .../tests/ecma_3/RegExp/regress-169497.js | 105 - .../tests/ecma_3/RegExp/regress-169534.js | 95 - .../tests/ecma_3/RegExp/regress-187133.js | 142 - .../tests/ecma_3/RegExp/regress-188206.js | 219 - .../tests/ecma_3/RegExp/regress-191479.js | 198 - .../tests/ecma_3/RegExp/regress-202564.js | 101 - .../tests/ecma_3/RegExp/regress-209067.js | 1106 --- .../tests/ecma_3/RegExp/regress-209919.js | 174 - .../tests/ecma_3/RegExp/regress-216591.js | 117 - .../tests/ecma_3/RegExp/regress-220367-001.js | 104 - .../tests/ecma_3/RegExp/regress-223273.js | 279 - .../tests/ecma_3/RegExp/regress-223535.js | 133 - .../tests/ecma_3/RegExp/regress-224676.js | 232 - .../tests/ecma_3/RegExp/regress-225289.js | 176 - .../tests/ecma_3/RegExp/regress-225343.js | 125 - .../tests/ecma_3/RegExp/regress-24712.js | 59 - .../tests/ecma_3/RegExp/regress-285219.js | 51 - .../tests/ecma_3/RegExp/regress-28686.js | 57 - .../tests/ecma_3/RegExp/regress-289669.js | 88 - .../tests/ecma_3/RegExp/regress-307456.js | 54 - .../tests/ecma_3/RegExp/regress-309840.js | 58 - .../tests/ecma_3/RegExp/regress-311414.js | 101 - .../tests/ecma_3/RegExp/regress-312351.js | 50 - .../tests/ecma_3/RegExp/regress-31316.js | 96 - .../tests/ecma_3/RegExp/regress-330684.js | 53 - .../tests/ecma_3/RegExp/regress-334158.js | 58 - .../tests/ecma_3/RegExp/regress-346090.js | 63 - .../tests/ecma_3/RegExp/regress-367888.js | 62 - .../tests/ecma_3/RegExp/regress-375642.js | 61 - .../tests/ecma_3/RegExp/regress-375711.js | 118 - .../tests/ecma_3/RegExp/regress-375715-01-n.js | 63 - .../tests/ecma_3/RegExp/regress-375715-02.js | 60 - .../tests/ecma_3/RegExp/regress-375715-03.js | 60 - .../tests/ecma_3/RegExp/regress-375715-04.js | 68 - .../tests/ecma_3/RegExp/regress-57572.js | 150 - .../tests/ecma_3/RegExp/regress-57631.js | 152 - .../tests/ecma_3/RegExp/regress-67773.js | 211 - .../tests/ecma_3/RegExp/regress-72964.js | 121 - .../tests/ecma_3/RegExp/regress-76683.js | 114 - .../tests/ecma_3/RegExp/regress-78156.js | 123 - .../tests/ecma_3/RegExp/regress-85721.js | 276 - .../tests/ecma_3/RegExp/regress-87231.js | 145 - .../tests/ecma_3/RegExp/regress-98306.js | 99 - .../parserstress/tests/ecma_3/RegExp/shell.js | 266 - .../parserstress/tests/ecma_3/Regress/browser.js | 0 .../tests/ecma_3/Regress/regress-385393-04.js | 66 - .../tests/ecma_3/Regress/regress-419152.js | 90 - .../tests/ecma_3/Regress/regress-420087.js | 64 - .../tests/ecma_3/Regress/regress-420610.js | 50 - .../tests/ecma_3/Regress/regress-441477-01.js | 73 - .../parserstress/tests/ecma_3/Regress/shell.js | 1 - .../parserstress/tests/ecma_3/Statements/12.6.3.js | 80 - .../tests/ecma_3/Statements/browser.js | 0 .../tests/ecma_3/Statements/regress-121744.js | 217 - .../tests/ecma_3/Statements/regress-131348.js | 184 - .../tests/ecma_3/Statements/regress-157509.js | 111 - .../tests/ecma_3/Statements/regress-194364.js | 152 - .../tests/ecma_3/Statements/regress-226517.js | 112 - .../tests/ecma_3/Statements/regress-302439.js | 1368 --- .../tests/ecma_3/Statements/regress-324650.js | 5461 ------------ .../tests/ecma_3/Statements/regress-74474-001.js | 139 - .../tests/ecma_3/Statements/regress-74474-002.js | 9097 ------------------- .../tests/ecma_3/Statements/regress-74474-003.js | 9099 -------------------- .../tests/ecma_3/Statements/regress-83532-001.js | 71 - .../tests/ecma_3/Statements/regress-83532-002.js | 74 - .../parserstress/tests/ecma_3/Statements/shell.js | 1 - .../tests/ecma_3/Statements/switch-001.js | 143 - .../parserstress/tests/ecma_3/String/15.5.4.11.js | 532 -- .../parserstress/tests/ecma_3/String/15.5.4.14.js | 50 - .../parserstress/tests/ecma_3/String/browser.js | 0 .../tests/ecma_3/String/regress-104375.js | 116 - .../tests/ecma_3/String/regress-189898.js | 157 - .../tests/ecma_3/String/regress-304376.js | 68 - .../tests/ecma_3/String/regress-313567.js | 56 - .../tests/ecma_3/String/regress-392378.js | 77 - .../tests/ecma_3/String/regress-83293.js | 216 - .../parserstress/tests/ecma_3/String/shell.js | 1 - .../parserstress/tests/ecma_3/Unicode/browser.js | 0 .../tests/ecma_3/Unicode/regress-352044-01.js | 72 - .../tests/ecma_3/Unicode/regress-352044-02-n.js | 72 - .../parserstress/tests/ecma_3/Unicode/shell.js | 1 - .../parserstress/tests/ecma_3/Unicode/uc-001-n.js | 62 - .../parserstress/tests/ecma_3/Unicode/uc-001.js | 56 - .../parserstress/tests/ecma_3/Unicode/uc-002-n.js | 55 - .../parserstress/tests/ecma_3/Unicode/uc-002.js | 60 - .../parserstress/tests/ecma_3/Unicode/uc-003.js | 71 - .../parserstress/tests/ecma_3/Unicode/uc-004.js | 65 - .../parserstress/tests/ecma_3/Unicode/uc-005.js | 276 - .../parserstress/tests/ecma_3/browser.js | 36 - .../tests/ecma_3/extensions/10.1.3-2.js | 162 - .../parserstress/tests/ecma_3/extensions/7.9.1.js | 83 - .../tests/ecma_3/extensions/browser.js | 0 .../tests/ecma_3/extensions/regress-103087.js | 178 - .../tests/ecma_3/extensions/regress-188206-01.js | 108 - .../tests/ecma_3/extensions/regress-188206-02.js | 158 - .../tests/ecma_3/extensions/regress-220367-002.js | 112 - .../tests/ecma_3/extensions/regress-228087.js | 352 - .../tests/ecma_3/extensions/regress-274152.js | 83 - .../tests/ecma_3/extensions/regress-320854.js | 53 - .../tests/ecma_3/extensions/regress-327170.js | 58 - .../tests/ecma_3/extensions/regress-368516.js | 78 - .../tests/ecma_3/extensions/regress-385393-03.js | 63 - .../tests/ecma_3/extensions/regress-429248.js | 67 - .../tests/ecma_3/extensions/regress-430740.js | 72 - .../parserstress/tests/ecma_3/extensions/shell.js | 266 - .../declarative/parserstress/tests/ecma_3/shell.js | 40 - .../parserstress/tests/ecma_3/template.js | 59 - tests/auto/declarative/parserstress/tests/shell.js | 886 -- .../declarative/parserstress/tst_parserstress.cpp | 154 - .../qdeclarativebinding/data/deletedObject.qml | 24 - .../qdeclarativebinding/data/restoreBinding.qml | 26 - .../data/restoreBindingWithLoop.qml | 23 - .../qdeclarativebinding/data/test-binding.qml | 16 - .../qdeclarativebinding/data/test-binding2.qml | 16 - .../qdeclarativebinding/qdeclarativebinding.pro | 15 - .../tst_qdeclarativebinding.cpp | 197 - .../qdeclarativechangeset.pro | 9 - .../tst_qdeclarativechangeset.cpp | 812 -- .../qdeclarativecomponent/data/createObject.qml | 13 - .../data/createObjectWithScript.qml | 43 - .../qdeclarativecomponent/data/incubateObject.qml | 36 - .../qdeclarativecomponent.pro | 15 - .../tst_qdeclarativecomponent.cpp | 186 - .../data/connection-targetchange.qml | 25 - .../data/connection-unknownsignals-ignored.qml | 8 - .../data/connection-unknownsignals-notarget.qml | 7 - .../data/connection-unknownsignals-parent.qml | 7 - .../data/connection-unknownsignals.qml | 7 - .../qdeclarativeconnection/data/error-object.qml | 7 - .../qdeclarativeconnection/data/error-property.qml | 5 - .../data/error-property2.qml | 5 - .../qdeclarativeconnection/data/error-syntax.qml | 9 - .../data/moduleapi-target.qml | 22 - .../data/test-connection.qml | 10 - .../data/test-connection2.qml | 3 - .../data/test-connection3.qml | 3 - .../qdeclarativeconnection/data/trimming.qml | 10 - .../qdeclarativeconnection.pro | 15 - .../tst_qdeclarativeconnection.cpp | 292 - .../qdeclarativeconsole/data/assert.qml | 62 - .../qdeclarativeconsole/data/exception.qml | 58 - .../qdeclarativeconsole/data/logging.qml | 90 - .../qdeclarativeconsole/data/profiling.qml | 51 - .../qdeclarativeconsole/data/tracing.qml | 56 - .../qdeclarativeconsole/qdeclarativeconsole.pro | 15 - .../tst_qdeclarativeconsole.cpp | 170 - .../qdeclarativecontext/data/Object_22535.qml | 8 - .../data/RefreshExpressionsType.qml | 5 - .../qdeclarativecontext/data/qtbug_22535.qml | 10 - .../data/refreshExpressions.qml | 6 - .../data/refreshExpressionsRootContext.qml | 6 - .../qdeclarativecontext/qdeclarativecontext.pro | 15 - .../tst_qdeclarativecontext.cpp | 652 -- .../qdeclarativecpputils/qdeclarativecpputils.pro | 9 - .../tst_qdeclarativecpputils.cpp | 106 - .../data/AliasBindingsAssignCorrectlyType.qml | 9 - .../data/AliasBindingsOverrideTargetType.qml | 14 - .../data/AliasBindingsOverrideTargetType3.qml | 9 - .../data/AliasToCompositeElementType1.qml | 6 - .../data/AliasToCompositeElementType2.qml | 5 - .../data/ConstantsOverrideBindings.qml | 12 - .../qdeclarativeecmascript/data/CustomObject.qml | 5 - .../data/ElementAssignType.qml | 5 - .../qdeclarativeecmascript/data/MethodsObject.qml | 6 - .../data/NestedTypeTransientErrors.qml | 11 - .../data/PropertyVarBaseItem.qml | 5 - .../data/PropertyVarCircularComponent.qml | 23 - .../data/PropertyVarCircularComponent2.qml | 26 - .../data/PropertyVarCircularComponent3.qml | 16 - .../data/PropertyVarCircularComponent4.qml | 28 - .../data/PropertyVarCircularComponent5.qml | 7 - .../data/PropertyVarInheritanceComponent.qml | 22 - .../data/PropertyVarOwnershipComponent.qml | 37 - .../data/ScarceResourceSignalComponentVar.qml | 9 - .../data/ScarceResourceSignalComponentVariant.qml | 9 - .../data/ScarceResourceVarComponent.qml | 13 - .../qdeclarativeecmascript/data/Scope6Nested.qml | 7 - .../qdeclarativeecmascript/data/ScopeObject.qml | 12 - .../data/SequenceConversionComponent.qml | 7 - .../data/SpuriousWarning.qml | 5 - .../data/TypeForDynamicCreation.qml | 2 - .../data/aliasBindingsAssignCorrectly.qml | 59 - .../data/aliasBindingsOverrideTarget.2.qml | 29 - .../data/aliasBindingsOverrideTarget.3.qml | 24 - .../data/aliasBindingsOverrideTarget.qml | 28 - .../data/aliasPropertyAndBinding.qml | 14 - .../data/aliasToCompositeElement.qml | 6 - .../data/aliasWritesOverrideBindings.2.qml | 29 - .../data/aliasWritesOverrideBindings.3.qml | 23 - .../data/aliasWritesOverrideBindings.qml | 23 - .../data/aliasreset/AliasPropertyComponent.qml | 17 - .../data/aliasreset/aliasPropertyReset.1.qml | 23 - .../data/aliasreset/aliasPropertyReset.2.qml | 23 - .../data/aliasreset/aliasPropertyReset.3.qml | 31 - .../data/aliasreset/aliasPropertyReset.4.qml | 26 - .../data/aliasreset/aliasPropertyReset.5.qml | 14 - .../data/aliasreset/aliasPropertyReset.error.1.qml | 18 - .../data/assignBasicTypes.2.qml | 26 - .../data/assignBasicTypes.qml | 29 - .../data/assignSequenceTypes.1.qml | 11 - .../data/assignSequenceTypes.2.qml | 11 - .../data/assignSequenceTypes.3.qml | 9 - .../data/assignSequenceTypes.4.qml | 13 - .../data/assignSequenceTypes.5.qml | 13 - .../data/assignSequenceTypes.6.qml | 11 - .../data/assignSequenceTypes.7.qml | 42 - .../data/attachedProperty.2.qml | 22 - .../data/attachedProperty.qml | 11 - .../data/attachedPropertyScope.qml | 9 - .../data/automaticSemicolon.qml | 11 - .../qdeclarativeecmascript/data/bindingLoop.qml | 14 - .../qdeclarativeecmascript/data/blank.js | 0 .../data/boolPropertiesEvaluateAsBool.1.qml | 5 - .../data/boolPropertiesEvaluateAsBool.2.qml | 5 - .../data/booleanConversion.qml | 28 - .../qdeclarativeecmascript/data/bug.1.qml | 10 - .../data/canAssignNullToQObject.1.qml | 9 - .../data/canAssignNullToQObject.2.qml | 11 - .../changeslots/propertyChangeSlotErrors.1.qml | 12 - .../changeslots/propertyChangeSlotErrors.2.qml | 12 - .../changeslots/propertyChangeSlotErrors.3.qml | 12 - .../changeslots/propertyChangeSlotErrors.4.qml | 12 - .../data/changeslots/propertyChangeSlots.qml | 27 - .../qdeclarativeecmascript/data/compiled.qml | 48 - .../data/compositePropertyType.qml | 8 - .../data/constantsOverrideBindings.1.qml | 8 - .../data/constantsOverrideBindings.2.qml | 11 - .../data/constantsOverrideBindings.3.qml | 7 - .../data/constantsOverrideBindings.4.qml | 11 - .../data/declarativeHasOwnProperty.qml | 72 - .../data/declarativeToString.qml | 11 - .../data/deferredProperties.qml | 10 - .../data/deferredPropertiesErrors.qml | 10 - .../qdeclarativeecmascript/data/deleteLater.qml | 14 - .../data/deleteWhileBindingRunning.qml | 5 - .../qdeclarativeecmascript/data/deletedEngine.qml | 11 - .../qdeclarativeecmascript/data/deletedObject.qml | 25 - .../qdeclarativeecmascript/data/doubleEvaluate.qml | 6 - .../data/dynamicCreation.helper.qml | 6 - .../data/dynamicCreation.qml | 27 - .../data/dynamicCreationOwnership.qml | 20 - .../data/dynamicDeletion.2.qml | 21 - .../data/dynamicDeletion.qml | 20 - .../qdeclarativeecmascript/data/dynamicString.qml | 16 - .../qdeclarativeecmascript/data/elementAssign.qml | 10 - .../qdeclarativeecmascript/data/enums.1.qml | 20 - .../qdeclarativeecmascript/data/enums.2.qml | 8 - .../qdeclarativeecmascript/data/eval.qml | 27 - .../qdeclarativeecmascript/data/exception.js | 1 - .../data/exceptionClearsOnReeval.qml | 6 - .../data/exceptionProducesWarning.qml | 8 - .../data/exceptionProducesWarning2.qml | 7 - .../data/extendedObjectPropertyLookup.qml | 8 - .../data/extendedObjectPropertyLookup2.qml | 14 - .../data/extensionObjects.qml | 19 - .../data/extensionObjectsPropertyOverride.qml | 7 - .../qdeclarativeecmascript/data/forInLoop.qml | 13 - .../qdeclarativeecmascript/data/function.qml | 23 - .../data/functionAssignment.1.qml | 5 - .../data/functionAssignment.2.qml | 73 - .../data/functionAssignment.js | 17 - .../qdeclarativeecmascript/data/functionErrors.qml | 10 - .../data/handleReferenceManagement.handle.1.qml | 21 - .../data/handleReferenceManagement.handle.2.qml | 22 - .../data/handleReferenceManagement.object.1.qml | 27 - .../data/handleReferenceManagement.object.2.qml | 28 - .../data/idShortcutInvalidates.1.qml | 13 - .../data/idShortcutInvalidates.qml | 12 - .../qdeclarativeecmascript/data/importScope.1.js | 1 - .../qdeclarativeecmascript/data/importScope.2.js | 3 - .../qdeclarativeecmascript/data/importScope.qml | 7 - .../declarative/qdeclarativeecmascript/data/in.qml | 7 - .../qdeclarativeecmascript/data/include.js | 8 - .../qdeclarativeecmascript/data/include.qml | 23 - .../data/include_callback.js | 11 - .../data/include_callback.qml | 15 - .../qdeclarativeecmascript/data/include_pragma.qml | 11 - .../data/include_pragma_inner.js | 5 - .../data/include_pragma_outer.js | 6 - .../qdeclarativeecmascript/data/include_remote.js | 26 - .../qdeclarativeecmascript/data/include_remote.qml | 21 - .../data/include_remote_missing.js | 13 - .../data/include_remote_missing.qml | 12 - .../qdeclarativeecmascript/data/include_shared.js | 12 - .../qdeclarativeecmascript/data/include_shared.qml | 22 - .../data/invokableObjectArg.qml | 9 - .../data/invokableObjectRet.qml | 11 - .../qdeclarativeecmascript/data/js/include2.js | 4 - .../qdeclarativeecmascript/data/js/include3.js | 3 - .../qdeclarativeecmascript/data/jsObject.qml | 12 - .../data/jsimport/SpecialRectangleOne.qml | 9 - .../data/jsimport/SpecialRectangleTwo.qml | 9 - .../data/jsimport/importFive.js | 3 - .../data/jsimport/importFour.js | 9 - .../data/jsimport/importOne.js | 13 - .../data/jsimport/importPragmaLibrary.js | 9 - .../jsimport/importPragmaLibraryWithImports.js | 9 - .../importPragmaLibraryWithPragmaLibraryImports.js | 11 - .../data/jsimport/importThree.js | 9 - .../data/jsimport/importTwo.js | 10 - .../data/jsimport/importWithNoImports.js | 11 - .../data/jsimport/testImport.qml | 14 - .../data/jsimport/testImportPragmaLibrary.qml | 20 - .../testImportPragmaLibraryWithImports.qml | 7 - ...ImportPragmaLibraryWithPragmaLibraryImports.qml | 7 - .../data/jsimport/testImportScoping.qml | 11 - .../data/jsimport/testModuleImport.js | 8 - .../data/jsimport/testScriptImport.js | 11 - .../data/jsimportfail/failFive.qml | 11 - .../data/jsimportfail/failFour.qml | 7 - .../data/jsimportfail/failOne.qml | 7 - .../data/jsimportfail/failThree.qml | 8 - .../data/jsimportfail/failTwo.qml | 7 - .../data/jsimportfail/importOne.js | 7 - .../data/jsimportfail/importPragmaLibrary.js | 11 - .../data/jsimportfail/importWithImports.js | 13 - .../data/jsimportfail/testImportPragmaLibrary.qml | 8 - .../data/jsimportfail/testModuleImport.js | 8 - .../data/jsimportfail/testScriptImport.js | 11 - .../data/libraryScriptAssert.js | 6 - .../data/libraryScriptAssert.qml | 7 - .../qdeclarativeecmascript/data/listAssignment.qml | 20 - .../qdeclarativeecmascript/data/listProperties.qml | 24 - .../qdeclarativeecmascript/data/listToVariant.qml | 5 - .../data/metaobjectRevision.qml | 7 - .../data/metaobjectRevision2.qml | 9 - .../data/metaobjectRevision3.qml | 8 - .../data/metaobjectRevision4.qml | 14 - .../data/metaobjectRevisionErrors.qml | 14 - .../data/metaobjectRevisionErrors2.qml | 24 - .../data/metaobjectRevisionErrors3.qml | 36 - .../qdeclarativeecmascript/data/methods.1.qml | 6 - .../qdeclarativeecmascript/data/methods.2.qml | 6 - .../qdeclarativeecmascript/data/methods.3.qml | 7 - .../qdeclarativeecmascript/data/methods.4.qml | 11 - .../qdeclarativeecmascript/data/methods.5.qml | 9 - .../data/moduleapi/moduleApiMajorVersionFail.qml | 10 - .../data/moduleapi/moduleApiMinorVersionFail.qml | 10 - .../data/moduleapi/qobjectModuleApi.qml | 21 - .../data/moduleapi/qobjectModuleApiCaching.qml | 10 - .../data/moduleapi/qobjectModuleApiEnums.qml | 8 - .../data/moduleapi/qobjectModuleApiWriting.qml | 26 - .../data/moduleapi/scriptModuleApi.qml | 6 - .../data/moduleapi/scriptModuleApiCaching.qml | 6 - .../data/moduleapi/scriptModuleApiWriting.qml | 32 - .../data/multiEngineObject.qml | 5 - .../data/noSpuriousWarningsAtShutdown.2.qml | 10 - .../data/noSpuriousWarningsAtShutdown.qml | 9 - .../data/nonExistentAttachedObject.qml | 5 - .../qdeclarativeecmascript/data/nonNotifyable.qml | 6 - .../qdeclarativeecmascript/data/nonscriptable.qml | 19 - .../data/nullObjectBinding.qml | 8 - .../data/numberAssignment.qml | 18 - .../data/objectConversion.qml | 16 - .../qdeclarativeecmascript/data/objectName.qml | 8 - .../data/objectsCompareAsEqual.qml | 15 - .../data/objectsPassThroughSignals.qml | 18 - .../data/outerBindingOverridesInnerBinding.qml | 15 - .../qdeclarativeecmascript/data/ownership.qml | 5 - .../data/propertyAssignmentErrors.qml | 29 - .../data/propertySplicing.qml | 10 - .../qdeclarativeecmascript/data/propertyVar.1.qml | 22 - .../qdeclarativeecmascript/data/propertyVar.10.qml | 8 - .../qdeclarativeecmascript/data/propertyVar.2.qml | 24 - .../qdeclarativeecmascript/data/propertyVar.3.qml | 19 - .../qdeclarativeecmascript/data/propertyVar.4.qml | 18 - .../qdeclarativeecmascript/data/propertyVar.5.qml | 18 - .../qdeclarativeecmascript/data/propertyVar.6.qml | 27 - .../qdeclarativeecmascript/data/propertyVar.7.qml | 18 - .../qdeclarativeecmascript/data/propertyVar.8.qml | 12 - .../qdeclarativeecmascript/data/propertyVar.9.qml | 19 - .../data/propertyVar.circular.2.qml | 26 - .../data/propertyVar.circular.qml | 44 - .../data/propertyVar.inherit.qml | 34 - .../data/propertyVar.reparent.qml | 27 - .../qdeclarativeecmascript/data/propertyVarCpp.qml | 17 - .../data/propertyVarImplicitOwnership.qml | 26 - .../data/propertyVarOwnership.2.qml | 24 - .../data/propertyVarOwnership.3.qml | 31 - .../data/propertyVarOwnership.3.type.qml | 5 - .../data/propertyVarOwnership.4.qml | 25 - .../data/propertyVarOwnership.4.type1.qml | 23 - .../data/propertyVarOwnership.4.type2.qml | 6 - .../data/propertyVarOwnership.qml | 22 - .../data/qlistqobjectMethods.qml | 6 - .../qobjectConnectionListExceptionHandling.qml | 24 - .../data/qobjectDerivedArgument.qml | 17 - .../qdeclarativeecmascript/data/qtbug_10696.qml | 26 - .../qdeclarativeecmascript/data/qtbug_11600.js | 1 - .../qdeclarativeecmascript/data/qtbug_11600.qml | 8 - .../qdeclarativeecmascript/data/qtbug_11606.qml | 12 - .../qdeclarativeecmascript/data/qtbug_20344.qml | 6 - .../qdeclarativeecmascript/data/qtbug_21580.qml | 22 - .../qdeclarativeecmascript/data/qtbug_21864.js | 2 - .../qdeclarativeecmascript/data/qtbug_21864.qml | 6 - .../qdeclarativeecmascript/data/qtbug_22464.qml | 15 - .../qdeclarativeecmascript/data/qtbug_22679.qml | 14 - .../qdeclarativeecmascript/data/qtbug_22843.js | 5 - .../data/qtbug_22843.library.js | 5 - .../data/qtbug_22843.library.qml | 6 - .../qdeclarativeecmascript/data/qtbug_22843.qml | 6 - .../qdeclarativeecmascript/data/qtbug_9792.qml | 5 - .../data/qtcreatorbug_1289.qml | 13 - .../data/readonlyDeclaration.qml | 45 - .../qdeclarativeecmascript/data/realToInt.qml | 11 - .../qdeclarativeecmascript/data/regExp.2.qml | 7 - .../qdeclarativeecmascript/data/regExp.qml | 7 - .../qdeclarativeecmascript/data/remote_file.js | 2 - .../data/rewriteMultiLineStrings.qml | 35 - .../data/scarceResourceCopy.var.qml | 14 - .../data/scarceResourceCopy.variant.qml | 15 - .../data/scarceResourceCopyFromJs.var.qml | 14 - .../data/scarceResourceCopyFromJs.variant.qml | 15 - .../data/scarceResourceCopyImport.var.js | 25 - .../data/scarceResourceCopyImport.var.qml | 18 - .../data/scarceResourceCopyImport.variant.js | 25 - .../data/scarceResourceCopyImport.variant.qml | 18 - .../data/scarceResourceCopyImportDifferent.var.js | 19 - .../data/scarceResourceCopyImportDifferent.var.qml | 22 - .../data/scarceResourceCopyImportFail.var.js | 19 - .../data/scarceResourceCopyImportFail.var.qml | 7 - .../data/scarceResourceCopyImportFail.variant.js | 19 - .../data/scarceResourceCopyImportFail.variant.qml | 8 - .../data/scarceResourceCopyImportNoBinding.var.js | 15 - .../data/scarceResourceCopyImportNoBinding.var.qml | 12 - .../scarceResourceCopyImportNoBinding.variant.js | 15 - .../scarceResourceCopyImportNoBinding.variant.qml | 12 - .../data/scarceResourceCopyNoBinding.var.qml | 14 - .../data/scarceResourceCopyNoBinding.variant.qml | 14 - .../data/scarceResourceDestroyedCopy.var.qml | 13 - .../data/scarceResourceDestroyedCopy.variant.qml | 14 - .../data/scarceResourceFunction.var.qml | 23 - .../data/scarceResourceFunction.variant.qml | 23 - .../data/scarceResourceFunctionFail.var.qml | 23 - .../data/scarceResourceFunctionFail.variant.qml | 23 - ...scarceResourceMultipleDifferentNoBinding.var.js | 14 - ...carceResourceMultipleDifferentNoBinding.var.qml | 14 - .../scarceResourceMultipleSameNoBinding.var.js | 15 - .../scarceResourceMultipleSameNoBinding.var.qml | 14 - .../scarceResourceMultipleSameWithBinding.var.qml | 12 - .../data/scarceResourceObjectGc.var.qml | 30 - .../data/scarceResourceSignal.var.qml | 29 - .../data/scarceResourceSignal.variant.qml | 29 - .../data/scarceResourceTest.var.js | 48 - .../data/scarceResourceTest.var.qml | 14 - .../data/scarceResourceTest.variant.js | 48 - .../data/scarceResourceTest.variant.qml | 14 - .../data/scarceResourceTestMultiple.var.qml | 16 - .../data/scarceResourceTestMultiple.variant.qml | 15 - .../data/scarceResourceTestPreserve.var.qml | 15 - .../data/scarceResourceTestPreserve.variant.qml | 15 - .../qdeclarativeecmascript/data/scope.2.qml | 40 - .../qdeclarativeecmascript/data/scope.3.qml | 13 - .../qdeclarativeecmascript/data/scope.4.qml | 12 - .../qdeclarativeecmascript/data/scope.5.qml | 27 - .../qdeclarativeecmascript/data/scope.6.qml | 10 - .../qdeclarativeecmascript/data/scope.qml | 44 - .../qdeclarativeecmascript/data/scriptConnect.1.js | 4 - .../data/scriptConnect.1.qml | 10 - .../qdeclarativeecmascript/data/scriptConnect.2.js | 5 - .../data/scriptConnect.2.qml | 16 - .../data/scriptConnect.3.qml | 15 - .../data/scriptConnect.4.qml | 12 - .../data/scriptConnect.5.qml | 11 - .../qdeclarativeecmascript/data/scriptConnect.6.js | 3 - .../data/scriptConnect.6.qml | 15 - .../data/scriptDisconnect.1.js | 6 - .../data/scriptDisconnect.1.qml | 13 - .../data/scriptDisconnect.2.qml | 14 - .../data/scriptDisconnect.3.qml | 14 - .../data/scriptDisconnect.4.qml | 13 - .../qdeclarativeecmascript/data/scriptErrors.js | 4 - .../qdeclarativeecmascript/data/scriptErrors.qml | 18 - .../data/selfDeletingBinding.2.qml | 17 - .../data/selfDeletingBinding.qml | 18 - .../data/sequenceConversion.array.qml | 193 - .../data/sequenceConversion.bindings.error.qml | 19 - .../data/sequenceConversion.bindings.qml | 28 - .../data/sequenceConversion.copy.qml | 160 - .../data/sequenceConversion.indexes.qml | 89 - .../data/sequenceConversion.read.error.qml | 21 - .../data/sequenceConversion.read.qml | 105 - .../data/sequenceConversion.threads.qml | 74 - .../data/sequenceConversion.write.error.qml | 18 - .../data/sequenceConversion.write.qml | 109 - .../data/sharedAttachedObject.qml | 16 - .../qdeclarativeecmascript/data/shutdownErrors.qml | 13 - .../data/signalAssignment.1.qml | 5 - .../data/signalAssignment.2.qml | 5 - .../qdeclarativeecmascript/data/signalHandlers.qml | 60 - .../data/signalParameterTypes.qml | 18 - .../data/signalTriggeredBindings.qml | 20 - .../data/signalWithJSValueInVariant.qml | 12 - .../data/signalWithQJSValue.qml | 14 - .../data/signalWithUnknownTypes.qml | 5 - .../qdeclarativeecmascript/data/strictlyEquals.qml | 17 - .../qdeclarativeecmascript/data/stringArg.qml | 49 - .../data/switchStatement.1.qml | 33 - .../data/switchStatement.2.qml | 33 - .../data/switchStatement.3.qml | 33 - .../data/switchStatement.4.qml | 31 - .../data/switchStatement.5.qml | 12 - .../data/switchStatement.6.qml | 13 - .../qdeclarativeecmascript/data/threadScript.js | 4 - .../data/transientErrors.2.qml | 14 - .../data/transientErrors.qml | 10 - .../qdeclarativeecmascript/data/tryStatement.1.qml | 13 - .../qdeclarativeecmascript/data/tryStatement.2.qml | 11 - .../qdeclarativeecmascript/data/tryStatement.3.qml | 13 - .../qdeclarativeecmascript/data/tryStatement.4.qml | 12 - .../qdeclarativeecmascript/data/typeOf.js | 25 - .../qdeclarativeecmascript/data/typeOf.qml | 26 - .../data/unaryExpression.qml | 9 - .../data/undefinedResetsProperty.2.qml | 10 - .../data/undefinedResetsProperty.qml | 7 - .../data/urlListProperty.qml | 41 - .../qdeclarativeecmascript/data/urlProperty.1.qml | 10 - .../qdeclarativeecmascript/data/urlProperty.2.qml | 10 - .../data/v8bindingException.qml | 21 - .../data/v8functionException.qml | 15 - .../data/valueTypeFunctions.qml | 6 - .../data/variantsAssignedUndefined.qml | 9 - .../data/withStatement.1.qml | 14 - .../data/writeAttachedProperty.qml | 6 - .../data/writeRemovesBinding.qml | 46 - .../qdeclarativeecmascript.pro | 22 - .../qdeclarativeecmascript/testtypes.cpp | 210 - .../declarative/qdeclarativeecmascript/testtypes.h | 1311 --- .../tst_qdeclarativeecmascript.cpp | 6062 ------------- .../qdeclarativeengine/qdeclarativeengine.pro | 9 - .../qdeclarativeengine/tst_qdeclarativeengine.cpp | 365 - .../declarative/qdeclarativeerror/data/test.txt | 3 - .../qdeclarativeerror/qdeclarativeerror.pro | 15 - .../qdeclarativeerror/tst_qdeclarativeerror.cpp | 243 - .../qdeclarativeexpression/data/scriptString.qml | 9 - .../qdeclarativeexpression.pro | 15 - .../tst_qdeclarativeexpression.cpp | 121 - .../qdeclarativefolderlistmodel/data/basic.qml | 5 - .../qdeclarativefolderlistmodel/data/dummy.qml | 1 - .../data/resetFiltering.qml | 5 - .../data/resetfiltering/innerdir/test2.txt | 1 - .../data/resetfiltering/test.txt | 1 - .../qdeclarativefolderlistmodel.pro | 14 - .../tst_qdeclarativefolderlistmodel.cpp | 179 - .../qdeclarativeimageprovider.pro | 9 - .../tst_qdeclarativeimageprovider.cpp | 424 - .../data/AsynchronousIfNestedType.qml | 7 - .../data/asynchronousIfNested.1.qml | 5 - .../data/asynchronousIfNested.2.qml | 6 - .../data/asynchronousIfNested.3.qml | 5 - .../data/chainInCompletion.qml | 5 - .../data/chainedAsynchronousIfNested.qml | 5 - .../qdeclarativeincubator/data/clear.qml | 8 - .../data/clearDuringCompletion.qml | 6 - .../qdeclarativeincubator/data/contextDelete.qml | 5 - .../qdeclarativeincubator/data/forceCompletion.qml | 9 - .../qdeclarativeincubator/data/nestedComponent.js | 1 - .../qdeclarativeincubator/data/nestedComponent.qml | 10 - .../data/noIncubationController.qml | 5 - .../data/objectDeleted.errors.txt | 1 - .../qdeclarativeincubator/data/objectDeleted.qml | 8 - .../data/recursiveClear.1.qml | 9 - .../data/recursiveClear.2.qml | 8 - .../qdeclarativeincubator/data/selfDelete.qml | 5 - .../qdeclarativeincubator/data/setInitialState.qml | 17 - .../data/statusChanged.nested.qml | 12 - .../qdeclarativeincubator/data/statusChanged.qml | 5 - .../qdeclarativeincubator.pro | 18 - .../qdeclarativeincubator/testtypes.cpp | 137 - .../declarative/qdeclarativeincubator/testtypes.h | 125 - .../tst_qdeclarativeincubator.cpp | 1030 --- .../qdeclarativeinfo/data/NestedComponent.qml | 23 - .../qdeclarativeinfo/data/NestedObject.qml | 8 - .../qdeclarativeinfo/data/nestedQmlObject.qml | 8 - .../qdeclarativeinfo/data/qmlObject.qml | 8 - .../qdeclarativeinfo/qdeclarativeinfo.pro | 14 - .../qdeclarativeinfo/tst_qdeclarativeinfo.cpp | 221 - .../qdeclarativeinstruction.pro | 8 - .../tst_qdeclarativeinstruction.cpp | 678 -- .../qdeclarativelanguage/data/Alias.qml | 8 - .../qdeclarativelanguage/data/Alias2.qml | 9 - .../qdeclarativelanguage/data/Alias3.qml | 12 - .../qdeclarativelanguage/data/Alias4.qml | 5 - .../data/AliasPropertyChangeSignalsType.qml | 20 - .../data/ComponentComposite.qml | 5 - .../qdeclarativelanguage/data/CompositeType.qml | 4 - .../qdeclarativelanguage/data/CompositeType2.qml | 5 - .../qdeclarativelanguage/data/CompositeType3.qml | 5 - .../qdeclarativelanguage/data/CompositeType4.qml | 6 - .../data/DontDoubleCallClassBeginItem.qml | 4 - .../data/DynamicPropertiesNestedType.qml | 6 - .../qdeclarativelanguage/data/HelperAlias.qml | 9 - .../declarative/qdeclarativelanguage/data/I18n.qml | 6 - .../qdeclarativelanguage/data/I18nType30.qml | 5 - .../data/InlineAssignmentsOverrideBindingsType.qml | 7 - .../InlineAssignmentsOverrideBindingsType2.qml | 5 - .../qdeclarativelanguage/data/LocalLast.qml | 2 - .../qdeclarativelanguage/data/MyComponent.qml | 6 - .../data/MyCompositeValueSource.qml | 6 - .../data/MyContainerComponent.qml | 5 - .../qdeclarativelanguage/data/NestedAlias.qml | 14 - .../data/NestedComponentRoot.qml | 6 - .../qdeclarativelanguage/data/NestedErrorsType.qml | 5 - .../qdeclarativelanguage/data/OnCompletedType.qml | 8 - .../data/OnDestructionType.qml | 8 - .../qdeclarativelanguage/data/ReadOnlyType.qml | 5 - .../qdeclarativelanguage/data/alias.1.qml | 8 - .../qdeclarativelanguage/data/alias.10.qml | 8 - .../qdeclarativelanguage/data/alias.11.qml | 8 - .../qdeclarativelanguage/data/alias.2.qml | 8 - .../qdeclarativelanguage/data/alias.3.qml | 10 - .../qdeclarativelanguage/data/alias.4.qml | 6 - .../qdeclarativelanguage/data/alias.5.qml | 13 - .../qdeclarativelanguage/data/alias.6.qml | 8 - .../qdeclarativelanguage/data/alias.7.qml | 14 - .../qdeclarativelanguage/data/alias.8.qml | 9 - .../qdeclarativelanguage/data/alias.9.qml | 9 - .../data/aliasPropertiesAndSignals.qml | 14 - .../data/aliasPropertyChangeSignals.2.qml | 10 - .../data/aliasPropertyChangeSignals.qml | 16 - .../data/allowedRevisionOverloads.qml | 6 - .../qdeclarativelanguage/data/assignBasicTypes.qml | 28 - .../data/assignCompositeToType.qml | 18 - .../data/assignLiteralSignalProperty.qml | 4 - .../data/assignLiteralToVar.qml | 32 - .../data/assignLiteralToVariant.qml | 17 - .../data/assignObjectToSignal.qml | 4 - .../data/assignObjectToVariant.qml | 7 - .../data/assignQmlComponent.qml | 4 - .../qdeclarativelanguage/data/assignSignal.qml | 5 - .../data/assignToNamespace.errors.txt | 1 - .../data/assignToNamespace.qml | 5 - .../data/assignTypeExtremes.qml | 5 - .../data/assignValueToSignal.errors.txt | 1 - .../data/assignValueToSignal.qml | 6 - .../data/attachedProperties.qml | 8 - .../data/autoComponentCreation.qml | 4 - .../data/autoNotifyConnection.qml | 6 - .../data/component.1.errors.txt | 1 - .../qdeclarativelanguage/data/component.1.qml | 4 - .../data/component.2.errors.txt | 1 - .../qdeclarativelanguage/data/component.2.qml | 9 - .../data/component.3.errors.txt | 1 - .../qdeclarativelanguage/data/component.3.qml | 9 - .../data/component.4.errors.txt | 1 - .../qdeclarativelanguage/data/component.4.qml | 6 - .../data/component.5.errors.txt | 1 - .../qdeclarativelanguage/data/component.5.qml | 6 - .../data/component.6.errors.txt | 1 - .../qdeclarativelanguage/data/component.6.qml | 6 - .../data/component.7.errors.txt | 1 - .../qdeclarativelanguage/data/component.7.qml | 7 - .../data/component.8.errors.txt | 1 - .../qdeclarativelanguage/data/component.8.qml | 7 - .../data/component.9.errors.txt | 1 - .../qdeclarativelanguage/data/component.9.qml | 7 - .../data/componentCompositeType.qml | 8 - .../qdeclarativelanguage/data/cppnamespace.2.qml | 5 - .../qdeclarativelanguage/data/cppnamespace.qml | 4 - .../qdeclarativelanguage/data/crash2.qml | 5 - .../qdeclarativelanguage/data/customOnProperty.qml | 7 - .../data/customParserIdNotAllowed.errors.txt | 1 - .../data/customParserIdNotAllowed.qml | 5 - .../data/customParserTypes.qml | 5 - .../data/customVariantTypes.qml | 4 - .../data/declaredPropertyValues.qml | 8 - .../data/defaultGrouped.errors.txt | 1 - .../qdeclarativelanguage/data/defaultGrouped.qml | 10 - .../data/defaultPropertyListOrder.qml | 29 - .../data/destroyedSignal.errors.txt | 1 - .../qdeclarativelanguage/data/destroyedSignal.qml | 5 - .../data/disallowedRevisionOverloads.errors.txt | 1 - .../data/disallowedRevisionOverloads.qml | 7 - .../data/dontDoubleCallClassBegin.qml | 5 - .../data/doubleSignal.errors.txt | 1 - .../qdeclarativelanguage/data/doubleSignal.qml | 7 - .../data/duplicateIDs.errors.txt | 1 - .../qdeclarativelanguage/data/duplicateIDs.qml | 6 - .../data/dynamicMeta.1.errors.txt | 1 - .../qdeclarativelanguage/data/dynamicMeta.1.qml | 6 - .../data/dynamicMeta.2.errors.txt | 1 - .../qdeclarativelanguage/data/dynamicMeta.2.qml | 6 - .../data/dynamicMeta.3.errors.txt | 1 - .../qdeclarativelanguage/data/dynamicMeta.3.qml | 6 - .../data/dynamicMeta.4.errors.txt | 1 - .../qdeclarativelanguage/data/dynamicMeta.4.qml | 6 - .../data/dynamicMeta.5.errors.txt | 1 - .../qdeclarativelanguage/data/dynamicMeta.5.qml | 5 - .../qdeclarativelanguage/data/dynamicObject.1.qml | 8 - .../data/dynamicObjectProperties.2.qml | 11 - .../data/dynamicObjectProperties.qml | 13 - .../data/dynamicProperties.qml | 13 - .../data/dynamicPropertiesNested.qml | 9 - .../data/dynamicSignalsAndSlots.qml | 10 - .../qdeclarativelanguage/data/empty.errors.txt | 2 - .../qdeclarativelanguage/data/empty.qml | 0 .../data/emptySignal.errors.txt | 1 - .../qdeclarativelanguage/data/emptySignal.qml | 7 - .../qdeclarativelanguage/data/enumTypes.errors.txt | 1 - .../qdeclarativelanguage/data/enumTypes.qml | 4 - .../data/failingComponent.errors.txt | 1 - .../data/failingComponentTest.qml | 4 - .../data/fakeDotProperty.errors.txt | 1 - .../qdeclarativelanguage/data/fakeDotProperty.qml | 4 - .../data/finalOverride.errors.txt | 1 - .../qdeclarativelanguage/data/finalOverride.qml | 4 - .../data/i18nDeclaredPropertyNames.qml | 6 - .../data/i18nDeclaredPropertyUse.qml | 3 - .../qdeclarativelanguage/data/i18nNameSpace.qml | 5 - .../qdeclarativelanguage/data/i18nScript.qml | 9 - .../qdeclarativelanguage/data/i18nStrings.qml | 5 - .../qdeclarativelanguage/data/i18nType.qml | 1 - .../qdeclarativelanguage/data/idProperty.qml | 8 - .../data/importFile.errors.txt | 1 - .../qdeclarativelanguage/data/importFile.qml | 3 - .../data/importIncorrectCase.qml | 5 - .../data/importJs.1.errors.txt | 0 .../qdeclarativelanguage/data/importJs.1.qml | 12 - .../data/importJs.10.errors.txt | 0 .../qdeclarativelanguage/data/importJs.10.qml | 16 - .../data/importJs.2.errors.txt | 0 .../qdeclarativelanguage/data/importJs.2.qml | 12 - .../data/importJs.3.errors.txt | 0 .../qdeclarativelanguage/data/importJs.3.qml | 16 - .../data/importJs.4.errors.txt | 0 .../qdeclarativelanguage/data/importJs.4.qml | 15 - .../data/importJs.5.errors.txt | 1 - .../qdeclarativelanguage/data/importJs.5.qml | 6 - .../data/importJs.6.errors.txt | 1 - .../qdeclarativelanguage/data/importJs.6.qml | 13 - .../data/importJs.7.errors.txt | 1 - .../qdeclarativelanguage/data/importJs.7.qml | 13 - .../data/importJs.8.errors.txt | 0 .../qdeclarativelanguage/data/importJs.8.qml | 15 - .../data/importJs.9.errors.txt | 0 .../qdeclarativelanguage/data/importJs.9.qml | 19 - .../data/importNamespaceConflict.errors.txt | 1 - .../data/importNamespaceConflict.qml | 4 - .../data/importNewerVersion.errors.txt | 1 - .../data/importNewerVersion.qml | 3 - .../data/importNonExist.errors.txt | 1 - .../qdeclarativelanguage/data/importNonExist.qml | 5 - .../data/importNonExistOlder.errors.txt | 1 - .../data/importNonExistOlder.qml | 3 - .../data/importVersionMissingBuiltIn.errors.txt | 1 - .../data/importVersionMissingBuiltIn.qml | 7 - .../data/importVersionMissingInstalled.errors.txt | 1 - .../data/importVersionMissingInstalled.qml | 3 - .../data/importscript.1.errors.txt | 1 - .../qdeclarativelanguage/data/importscript.1.qml | 3 - .../data/incorrectCase.errors.insensitive.txt | 2 - .../data/incorrectCase.errors.sensitive.txt | 1 - .../qdeclarativelanguage/data/incorrectCase.qml | 4 - .../data/incorrectCaseType.qml | 4 - .../data/inlineAssignmentsOverrideBindings.qml | 6 - .../data/inlineQmlComponents.qml | 10 - .../data/insertedSemicolon.1.errors.txt | 1 - .../data/insertedSemicolon.1.qml | 10 - .../data/interfaceProperty.qml | 5 - .../qdeclarativelanguage/data/interfaceQList.qml | 7 - .../data/invalidAlias.1.errors.txt | 1 - .../qdeclarativelanguage/data/invalidAlias.1.qml | 5 - .../data/invalidAlias.10.errors.txt | 1 - .../qdeclarativelanguage/data/invalidAlias.10.qml | 6 - .../data/invalidAlias.2.errors.txt | 1 - .../qdeclarativelanguage/data/invalidAlias.2.qml | 6 - .../data/invalidAlias.3.errors.txt | 1 - .../qdeclarativelanguage/data/invalidAlias.3.qml | 6 - .../data/invalidAlias.4.errors.txt | 1 - .../qdeclarativelanguage/data/invalidAlias.4.qml | 7 - .../data/invalidAlias.5.errors.txt | 1 - .../qdeclarativelanguage/data/invalidAlias.5.qml | 7 - .../data/invalidAlias.6.errors.txt | 1 - .../qdeclarativelanguage/data/invalidAlias.6.qml | 7 - .../data/invalidAlias.7.errors.txt | 1 - .../qdeclarativelanguage/data/invalidAlias.7.qml | 6 - .../data/invalidAlias.8.errors.txt | 1 - .../qdeclarativelanguage/data/invalidAlias.8.qml | 7 - .../data/invalidAlias.9.errors.txt | 1 - .../qdeclarativelanguage/data/invalidAlias.9.qml | 6 - .../data/invalidAttachedProperty.1.errors.txt | 1 - .../data/invalidAttachedProperty.1.qml | 7 - .../data/invalidAttachedProperty.10.errors.txt | 1 - .../data/invalidAttachedProperty.10.qml | 6 - .../data/invalidAttachedProperty.11.errors.txt | 1 - .../data/invalidAttachedProperty.11.qml | 7 - .../data/invalidAttachedProperty.12.errors.txt | 1 - .../data/invalidAttachedProperty.12.qml | 6 - .../data/invalidAttachedProperty.13.errors.txt | 1 - .../data/invalidAttachedProperty.13.qml | 8 - .../data/invalidAttachedProperty.2.errors.txt | 1 - .../data/invalidAttachedProperty.2.qml | 6 - .../data/invalidAttachedProperty.3.errors.txt | 1 - .../data/invalidAttachedProperty.3.qml | 8 - .../data/invalidAttachedProperty.4.errors.txt | 1 - .../data/invalidAttachedProperty.4.qml | 7 - .../data/invalidAttachedProperty.5.errors.txt | 1 - .../data/invalidAttachedProperty.5.qml | 7 - .../data/invalidAttachedProperty.6.errors.txt | 1 - .../data/invalidAttachedProperty.6.qml | 7 - .../data/invalidAttachedProperty.7.errors.txt | 1 - .../data/invalidAttachedProperty.7.qml | 6 - .../data/invalidAttachedProperty.8.errors.txt | 1 - .../data/invalidAttachedProperty.8.qml | 6 - .../data/invalidAttachedProperty.9.errors.txt | 1 - .../data/invalidAttachedProperty.9.qml | 7 - .../data/invalidGroupedProperty.1.errors.txt | 1 - .../data/invalidGroupedProperty.1.qml | 6 - .../data/invalidGroupedProperty.10.errors.txt | 1 - .../data/invalidGroupedProperty.10.qml | 7 - .../data/invalidGroupedProperty.2.errors.txt | 1 - .../data/invalidGroupedProperty.2.qml | 7 - .../data/invalidGroupedProperty.3.errors.txt | 1 - .../data/invalidGroupedProperty.3.qml | 5 - .../data/invalidGroupedProperty.4.errors.txt | 1 - .../data/invalidGroupedProperty.4.qml | 5 - .../data/invalidGroupedProperty.5.errors.txt | 1 - .../data/invalidGroupedProperty.5.qml | 5 - .../data/invalidGroupedProperty.6.errors.txt | 1 - .../data/invalidGroupedProperty.6.qml | 6 - .../data/invalidGroupedProperty.7.errors.txt | 1 - .../data/invalidGroupedProperty.7.qml | 5 - .../data/invalidGroupedProperty.8.errors.txt | 1 - .../data/invalidGroupedProperty.8.qml | 6 - .../data/invalidGroupedProperty.9.errors.txt | 1 - .../data/invalidGroupedProperty.9.qml | 6 - .../data/invalidID.2.errors.txt | 2 - .../qdeclarativelanguage/data/invalidID.2.qml | 5 - .../data/invalidID.3.errors.txt | 1 - .../qdeclarativelanguage/data/invalidID.3.qml | 5 - .../data/invalidID.4.errors.txt | 1 - .../qdeclarativelanguage/data/invalidID.4.qml | 6 - .../data/invalidID.5.errors.txt | 1 - .../qdeclarativelanguage/data/invalidID.5.qml | 6 - .../data/invalidID.6.errors.txt | 1 - .../qdeclarativelanguage/data/invalidID.6.qml | 5 - .../data/invalidID.7.errors.txt | 1 - .../qdeclarativelanguage/data/invalidID.7.qml | 5 - .../data/invalidID.8.errors.txt | 1 - .../qdeclarativelanguage/data/invalidID.8.qml | 5 - .../data/invalidID.9.errors.txt | 1 - .../qdeclarativelanguage/data/invalidID.9.qml | 5 - .../qdeclarativelanguage/data/invalidID.errors.txt | 1 - .../qdeclarativelanguage/data/invalidID.qml | 4 - .../data/invalidImportID.errors.txt | 1 - .../qdeclarativelanguage/data/invalidImportID.qml | 4 - .../qdeclarativelanguage/data/invalidOn.errors.txt | 1 - .../qdeclarativelanguage/data/invalidOn.qml | 4 - .../data/invalidProperty.errors.txt | 1 - .../qdeclarativelanguage/data/invalidProperty.qml | 5 - .../data/invalidRoot.1.errors.txt | 1 - .../qdeclarativelanguage/data/invalidRoot.1.qml | 2 - .../data/invalidRoot.2.errors.txt | 1 - .../qdeclarativelanguage/data/invalidRoot.2.qml | 2 - .../data/invalidRoot.3.errors.txt | 1 - .../qdeclarativelanguage/data/invalidRoot.3.qml | 4 - .../data/invalidRoot.4.errors.txt | 1 - .../qdeclarativelanguage/data/invalidRoot.4.qml | 4 - .../data/invalidTypeName.1.errors.txt | 1 - .../data/invalidTypeName.1.qml | 2 - .../data/invalidTypeName.2.errors.txt | 1 - .../data/invalidTypeName.2.qml | 5 - .../data/invalidTypeName.3.errors.txt | 1 - .../data/invalidTypeName.3.qml | 7 - .../data/invalidTypeName.4.errors.txt | 1 - .../data/invalidTypeName.4.qml | 4 - .../lib/com/nokia/PureJsModule.1.6/FirstAPI.1.6.js | 5 - .../lib/com/nokia/PureJsModule.1.6/FirstAPI.js | 5 - .../lib/com/nokia/PureJsModule.1.6/SecondAPI.js | 5 - .../data/lib/com/nokia/PureJsModule.1.6/qmldir | 3 - .../data/lib/com/nokia/PureJsModule/FirstAPI.js | 5 - .../data/lib/com/nokia/PureJsModule/SecondAPI.js | 5 - .../data/lib/com/nokia/PureJsModule/qmldir | 2 - .../com/nokia/VersionedOnlyJsModule.9.0/SomeAPI.js | 5 - .../lib/com/nokia/VersionedOnlyJsModule.9.0/qmldir | 1 - .../lib/com/nokia/installedtest/InstalledTest.qml | 2 - .../lib/com/nokia/installedtest/InstalledTest2.qml | 2 - .../data/lib/com/nokia/installedtest/LocalLast.qml | 2 - .../lib/com/nokia/installedtest/PrivateType.qml | 2 - .../data/lib/com/nokia/installedtest/qmldir | 4 - .../lib/com/nokia/installedtest0/InstalledTest.qml | 2 - .../com/nokia/installedtest0/InstalledTest2.qml | 2 - .../data/lib/com/nokia/installedtest0/qmldir | 2 - .../data/listAssignment.1.errors.txt | 1 - .../qdeclarativelanguage/data/listAssignment.1.qml | 6 - .../data/listAssignment.2.errors.txt | 2 - .../qdeclarativelanguage/data/listAssignment.2.qml | 4 - .../data/listAssignment.3.errors.txt | 1 - .../qdeclarativelanguage/data/listAssignment.3.qml | 6 - .../data/listItemDeleteSelf.qml | 38 - .../qdeclarativelanguage/data/listProperties.qml | 9 - .../data/majorVersionIsolation.errors.txt | 1 - .../data/majorVersionIsolation.qml | 4 - .../data/metaobjectRevision.1.errors.txt | 1 - .../data/metaobjectRevision.1.qml | 9 - .../data/metaobjectRevision.2.errors.txt | 1 - .../data/metaobjectRevision.2.qml | 7 - .../data/metaobjectRevision.3.errors.txt | 1 - .../data/metaobjectRevision.3.qml | 10 - .../qdeclarativelanguage/data/method.1.errors.txt | 1 - .../qdeclarativelanguage/data/method.1.qml | 5 - .../data/missingObject.errors.txt | 1 - .../qdeclarativelanguage/data/missingObject.qml | 1 - .../data/missingSignal.errors.txt | 1 - .../qdeclarativelanguage/data/missingSignal.qml | 5 - .../data/missingValueTypeProperty.errors.txt | 1 - .../data/missingValueTypeProperty.qml | 5 - .../data/multiSet.1.errors.txt | 1 - .../qdeclarativelanguage/data/multiSet.1.qml | 7 - .../data/multiSet.10.errors.txt | 1 - .../qdeclarativelanguage/data/multiSet.10.qml | 6 - .../data/multiSet.11.errors.txt | 1 - .../qdeclarativelanguage/data/multiSet.11.qml | 6 - .../data/multiSet.2.errors.txt | 1 - .../qdeclarativelanguage/data/multiSet.2.qml | 7 - .../data/multiSet.3.errors.txt | 1 - .../qdeclarativelanguage/data/multiSet.3.qml | 7 - .../data/multiSet.4.errors.txt | 1 - .../qdeclarativelanguage/data/multiSet.4.qml | 7 - .../data/multiSet.5.errors.txt | 1 - .../qdeclarativelanguage/data/multiSet.5.qml | 6 - .../data/multiSet.6.errors.txt | 1 - .../qdeclarativelanguage/data/multiSet.6.qml | 7 - .../data/multiSet.7.errors.txt | 1 - .../qdeclarativelanguage/data/multiSet.7.qml | 7 - .../data/multiSet.8.errors.txt | 1 - .../qdeclarativelanguage/data/multiSet.8.qml | 8 - .../data/multiSet.9.errors.txt | 1 - .../qdeclarativelanguage/data/multiSet.9.qml | 6 - .../data/nestedComponentRoots.qml | 4 - .../data/nestedErrors.errors.txt | 2 - .../qdeclarativelanguage/data/nestedErrors.qml | 6 - .../data/noCreation.errors.txt | 1 - .../qdeclarativelanguage/data/noCreation.qml | 4 - .../data/nonScriptableProperty.errors.txt | 1 - .../data/nonScriptableProperty.qml | 5 - .../data/nonexistantProperty.1.errors.txt | 1 - .../data/nonexistantProperty.1.qml | 2 - .../data/nonexistantProperty.2.errors.txt | 1 - .../data/nonexistantProperty.2.qml | 4 - .../data/nonexistantProperty.3.errors.txt | 1 - .../data/nonexistantProperty.3.qml | 4 - .../data/nonexistantProperty.4.errors.txt | 1 - .../data/nonexistantProperty.4.qml | 4 - .../data/nonexistantProperty.5.errors.txt | 1 - .../data/nonexistantProperty.5.qml | 4 - .../data/nonexistantProperty.6.errors.txt | 1 - .../data/nonexistantProperty.6.qml | 4 - .../data/notAvailable.errors.txt | 1 - .../qdeclarativelanguage/data/notAvailable.qml | 4 - .../data/nullDotProperty.errors.txt | 1 - .../qdeclarativelanguage/data/nullDotProperty.qml | 4 - .../data/objectValueTypeProperty.errors.txt | 1 - .../data/objectValueTypeProperty.qml | 6 - .../qdeclarativelanguage/data/onCompleted.qml | 17 - .../qdeclarativelanguage/data/onDestruction.qml | 17 - .../data/property.1.errors.txt | 1 - .../qdeclarativelanguage/data/property.1.qml | 5 - .../data/property.2.errors.txt | 1 - .../qdeclarativelanguage/data/property.2.qml | 6 - .../data/property.3.errors.txt | 1 - .../qdeclarativelanguage/data/property.3.qml | 7 - .../data/property.4.errors.txt | 1 - .../qdeclarativelanguage/data/property.4.qml | 5 - .../data/property.6.errors.txt | 1 - .../qdeclarativelanguage/data/property.6.qml | 6 - .../data/property.7.errors.txt | 1 - .../qdeclarativelanguage/data/property.7.qml | 5 - .../qdeclarativelanguage/data/propertyInit.1.qml | 5 - .../qdeclarativelanguage/data/propertyInit.2.qml | 6 - .../data/propertyValueSource.2.qml | 5 - .../data/propertyValueSource.qml | 4 - .../data/qmlAttachedPropertiesObjectMethod.1.qml | 5 - .../data/qmlAttachedPropertiesObjectMethod.2.qml | 6 - .../declarative/qmllanguage/LocalInternal.qml | 3 - .../data/qtest/declarative/qmllanguage/Test.qml | 2 - .../qtest/declarative/qmllanguage/TestLocal.qml | 1 - .../qtest/declarative/qmllanguage/TestNamed.qml | 1 - .../qtest/declarative/qmllanguage/TestSubDir.qml | 2 - .../declarative/qmllanguage/UndeclaredLocal.qml | 3 - .../declarative/qmllanguage/WrongTestLocal.qml | 1 - .../declarative/qmllanguage/noqmldir/Test.qml | 2 - .../qtest/declarative/qmllanguage/pics/blue.png | Bin 84 -> 0 bytes .../data/qtest/declarative/qmllanguage/qmldir | 5 - .../declarative/qmllanguage/subdir/SubTest.qml | 3 - .../qtest/declarative/qmllanguage/subdir/qmldir | 1 - .../data/readOnly.1.errors.txt | 1 - .../qdeclarativelanguage/data/readOnly.1.qml | 4 - .../data/readOnly.2.errors.txt | 1 - .../qdeclarativelanguage/data/readOnly.2.qml | 4 - .../data/readOnly.3.errors.txt | 1 - .../qdeclarativelanguage/data/readOnly.3.qml | 8 - .../data/readOnly.4.errors.txt | 1 - .../qdeclarativelanguage/data/readOnly.4.qml | 4 - .../data/readOnly.5.errors.txt | 1 - .../qdeclarativelanguage/data/readOnly.5.qml | 3 - .../qdeclarativelanguage/data/readonly.qml | 17 - .../data/registrationOrder.qml | 4 - .../qdeclarativelanguage/data/remoteLoadCrash.qml | 3 - .../qdeclarativelanguage/data/revisions11.qml | 10 - .../data/revisionsbasesub11.qml | 16 - .../qdeclarativelanguage/data/revisionssub11.qml | 12 - .../data/rootAsQmlComponent.qml | 6 - .../data/scriptString.1.errors.txt | 1 - .../qdeclarativelanguage/data/scriptString.1.qml | 5 - .../data/scriptString.2.errors.txt | 1 - .../qdeclarativelanguage/data/scriptString.2.qml | 6 - .../qdeclarativelanguage/data/scriptString.qml | 6 - .../qdeclarativelanguage/data/scriptString2.qml | 5 - .../qdeclarativelanguage/data/scriptString3.qml | 5 - .../qdeclarativelanguage/data/scriptString4.qml | 5 - .../qdeclarativelanguage/data/signal.1.errors.txt | 1 - .../qdeclarativelanguage/data/signal.1.qml | 5 - .../qdeclarativelanguage/data/signal.2.errors.txt | 1 - .../qdeclarativelanguage/data/signal.2.qml | 6 - .../qdeclarativelanguage/data/signal.3.errors.txt | 1 - .../qdeclarativelanguage/data/signal.3.qml | 6 - .../qdeclarativelanguage/data/signal.4.errors.txt | 1 - .../qdeclarativelanguage/data/signal.4.qml | 6 - .../qdeclarativelanguage/data/simpleBindings.qml | 18 - .../qdeclarativelanguage/data/simpleContainer.qml | 5 - .../qdeclarativelanguage/data/simpleObject.qml | 2 - .../data/singularProperty.2.errors.txt | 1 - .../data/singularProperty.2.qml | 7 - .../data/singularProperty.errors.txt | 1 - .../qdeclarativelanguage/data/singularProperty.qml | 6 - .../qdeclarativelanguage/data/subdir/Test.qml | 2 - .../data/subdir/subsubdir/SubTest.qml | 2 - .../declarative/qdeclarativelanguage/data/test.js | 0 .../declarative/qdeclarativelanguage/data/test2.js | 0 .../data/unregisteredObject.errors.txt | 1 - .../data/unregisteredObject.qml | 2 - .../data/unsupportedProperty.errors.txt | 1 - .../data/unsupportedProperty.qml | 4 - .../qdeclarativelanguage/data/valueTypes.qml | 13 - .../qdeclarativelanguage/data/variantNotify.qml | 13 - .../qdeclarativelanguage/data/versionedbase.qml | 8 - .../data/wrongType.1.errors.txt | 1 - .../qdeclarativelanguage/data/wrongType.1.qml | 4 - .../data/wrongType.10.errors.txt | 1 - .../qdeclarativelanguage/data/wrongType.10.qml | 5 - .../data/wrongType.11.errors.txt | 1 - .../qdeclarativelanguage/data/wrongType.11.qml | 5 - .../data/wrongType.12.errors.txt | 1 - .../qdeclarativelanguage/data/wrongType.12.qml | 5 - .../data/wrongType.13.errors.txt | 1 - .../qdeclarativelanguage/data/wrongType.13.qml | 4 - .../data/wrongType.14.errors.txt | 1 - .../qdeclarativelanguage/data/wrongType.14.qml | 5 - .../data/wrongType.15.errors.txt | 1 - .../qdeclarativelanguage/data/wrongType.15.qml | 4 - .../data/wrongType.16.errors.txt | 1 - .../qdeclarativelanguage/data/wrongType.16.qml | 5 - .../data/wrongType.17.errors.txt | 1 - .../qdeclarativelanguage/data/wrongType.17.qml | 5 - .../data/wrongType.2.errors.txt | 1 - .../qdeclarativelanguage/data/wrongType.2.qml | 4 - .../data/wrongType.3.errors.txt | 1 - .../qdeclarativelanguage/data/wrongType.3.qml | 4 - .../data/wrongType.4.errors.txt | 1 - .../qdeclarativelanguage/data/wrongType.4.qml | 4 - .../data/wrongType.5.errors.txt | 1 - .../qdeclarativelanguage/data/wrongType.5.qml | 5 - .../data/wrongType.6.errors.txt | 1 - .../qdeclarativelanguage/data/wrongType.6.qml | 5 - .../data/wrongType.7.errors.txt | 1 - .../qdeclarativelanguage/data/wrongType.7.qml | 5 - .../data/wrongType.8.errors.txt | 1 - .../qdeclarativelanguage/data/wrongType.8.qml | 5 - .../data/wrongType.9.errors.txt | 1 - .../qdeclarativelanguage/data/wrongType.9.qml | 5 - .../qdeclarativelanguage/qdeclarativelanguage.pro | 18 - .../declarative/qdeclarativelanguage/testtypes.cpp | 88 - .../declarative/qdeclarativelanguage/testtypes.h | 823 -- .../tst_qdeclarativelanguage.cpp | 2289 ----- .../qdeclarativelistcompositor.pro | 9 - .../tst_qdeclarativelistcompositor.cpp | 1637 ---- .../qdeclarativelistmodel/data/enumerate.qml | 24 - .../qdeclarativelistmodel/data/model.qml | 26 - .../qdeclarativelistmodel/data/multipleroles.qml | 25 - .../qdeclarativelistmodel/data/script.js | 13 - .../data/setmodelcachelist.qml | 20 - .../qdeclarativelistmodel/data/signalhandlers.qml | 8 - .../data/workerremoveelement.js | 8 - .../data/workerremoveelement.qml | 33 - .../qdeclarativelistmodel/data/workerremovelist.js | 9 - .../data/workerremovelist.qml | 33 - .../qdeclarativelistmodel/data/workersync.js | 8 - .../qdeclarativelistmodel/data/workersync.qml | 32 - .../qdeclarativelistmodel.pro | 15 - .../tst_qdeclarativelistmodel.cpp | 1632 ---- .../qdeclarativelistreference/data/MyType.qml | 5 - .../qdeclarativelistreference/data/engineTypes.qml | 9 - .../data/variantToList.qml | 10 - .../qdeclarativelistreference.pro | 15 - .../tst_qdeclarativelistreference.cpp | 570 -- .../declarative/qdeclarativelocale/data/date.qml | 45 - .../qdeclarativelocale/data/functions.qml | 65 - .../qdeclarativelocale/data/localeCompare.qml | 7 - .../declarative/qdeclarativelocale/data/number.qml | 30 - .../qdeclarativelocale/data/properties.qml | 27 - .../qdeclarativelocale/qdeclarativelocale.pro | 15 - .../qdeclarativelocale/tst_qdeclarativelocale.cpp | 1183 --- .../qdeclarativemetatype/qdeclarativemetatype.pro | 7 - .../tst_qdeclarativemetatype.cpp | 202 - .../data/implicit1/implicitQmldir.errors.txt | 1 - .../qdeclarativemoduleplugin/data/implicit1/qmldir | 2 - .../data/implicit1/temptest.qml | 14 - .../data/implicit2/Test.qml | 5 - .../data/implicit2/implicitQmldir.2.errors.txt | 3 - .../qdeclarativemoduleplugin/data/implicit2/qmldir | 3 - .../data/implicit2/temptest2.qml | 8 - .../data/importsMixedQmlCppPlugin.2.qml | 21 - .../data/importsMixedQmlCppPlugin.qml | 13 - .../data/incorrectCase.qml | 4 - .../data/pluginWithQmlFile.qml | 3 - .../data/versionNotInstalled.2.errors.txt | 1 - .../data/versionNotInstalled.2.qml | 5 - .../data/versionNotInstalled.errors.txt | 1 - .../data/versionNotInstalled.qml | 6 - .../qdeclarativemoduleplugin/data/works.qml | 3 - .../qdeclarativemoduleplugin/data/works2.qml | 3 - .../qdeclarativemoduleplugin/data/works21.qml | 3 - .../nokia/AutoTestPluginWithQmlFile/MyQmlFile.qml | 3 - .../com/nokia/AutoTestPluginWithQmlFile/qmldir | 3 - .../com/nokia/AutoTestQmlMixedPluginType/Foo.qml | 5 - .../com/nokia/AutoTestQmlMixedPluginType/qmldir | 2 - .../com/nokia/AutoTestQmlPluginType.2.1/qmldir | 1 - .../com/nokia/AutoTestQmlPluginType.2/qmldir | 1 - .../imports/com/nokia/AutoTestQmlPluginType/qmldir | 1 - .../com/nokia/AutoTestQmlVersionPluginType/qmldir | 1 - .../imports/com/nokia/PureQmlModule/ComponentA.qml | 3 - .../imports/com/nokia/PureQmlModule/ComponentB.qml | 4 - .../imports/com/nokia/PureQmlModule/qmldir | 3 - .../imports/com/nokia/WrongCase/qmldir | 1 - .../plugin.2.1/plugin.2.1.pro | 7 - .../qdeclarativemoduleplugin/plugin.2.1/plugin.cpp | 84 - .../qdeclarativemoduleplugin/plugin.2/plugin.2.pro | 7 - .../qdeclarativemoduleplugin/plugin.2/plugin.cpp | 84 - .../qdeclarativemoduleplugin/plugin/plugin.cpp | 83 - .../qdeclarativemoduleplugin/plugin/plugin.pro | 7 - .../pluginMixed/plugin.cpp | 73 - .../pluginMixed/pluginMixed.pro | 7 - .../pluginVersion/plugin.cpp | 73 - .../pluginVersion/pluginVersion.pro | 7 - .../pluginWithQmlFile/plugin.cpp | 58 - .../pluginWithQmlFile/pluginWithQmlFile.pro | 7 - .../pluginWrongCase/plugin.cpp | 83 - .../pluginWrongCase/pluginWrongCase.pro | 8 - .../qdeclarativemoduleplugin.pro | 9 - .../tst_qdeclarativemoduleplugin.cpp | 353 - .../tst_qdeclarativemoduleplugin.pro | 19 - .../qdeclarativeparser/qdeclarativeparser.pro | 9 - .../qdeclarativeparser/tst_qdeclarativeparser.cpp | 210 - .../qdeclarativepixmapcache/data/dataLeak.qml | 18 - .../qdeclarativeproperty/data/NoContextTypeA.qml | 5 - .../qdeclarativeproperty/data/NoContextTypeB.qml | 5 - .../qdeclarativeproperty/data/TestType.qml | 6 - .../data/aliasPropertyBindings.qml | 19 - .../data/assignEmptyVariantMap.qml | 5 - .../data/readSynthesizedObject.qml | 9 - .../qdeclarativeproperty/qdeclarativeproperty.pro | 15 - .../tst_qdeclarativeproperty.cpp | 1721 ---- .../qdeclarativepropertycache.pro | 8 - .../tst_qdeclarativepropertycache.cpp | 281 - .../qdeclarativepropertymap.pro | 9 - .../tst_qdeclarativepropertymap.cpp | 241 - .../auto/declarative/qdeclarativeqt/data/atob.qml | 7 - .../auto/declarative/qdeclarativeqt/data/btoa.qml | 6 - .../qdeclarativeqt/data/createComponent.qml | 20 - .../qdeclarativeqt/data/createComponentData.qml | 5 - .../qdeclarativeqt/data/createComponent_lib.js | 11 - .../qdeclarativeqt/data/createComponent_lib.qml | 12 - .../qdeclarativeqt/data/createQmlObject.qml | 31 - .../declarative/qdeclarativeqt/data/darker.qml | 12 - .../qdeclarativeqt/data/dateTimeConversion.qml | 14 - .../auto/declarative/qdeclarativeqt/data/enums.qml | 9 - .../qdeclarativeqt/data/fontFamilies.qml | 6 - .../declarative/qdeclarativeqt/data/formatting.qml | 44 - .../auto/declarative/qdeclarativeqt/data/hsla.qml | 11 - .../declarative/qdeclarativeqt/data/isQtObject.qml | 14 - .../declarative/qdeclarativeqt/data/lighter.qml | 11 - tests/auto/declarative/qdeclarativeqt/data/md5.qml | 6 - .../qdeclarativeqt/data/openUrlExternally.qml | 8 - .../qdeclarativeqt/data/openUrlExternally_lib.js | 9 - .../qdeclarativeqt/data/openUrlExternally_lib.qml | 9 - .../auto/declarative/qdeclarativeqt/data/point.qml | 9 - .../auto/declarative/qdeclarativeqt/data/quit.qml | 5 - .../auto/declarative/qdeclarativeqt/data/rect.qml | 9 - .../qdeclarativeqt/data/resolvedUrl.qml | 13 - .../auto/declarative/qdeclarativeqt/data/rgba.qml | 10 - .../auto/declarative/qdeclarativeqt/data/size.qml | 11 - .../auto/declarative/qdeclarativeqt/data/tint.qml | 9 - .../declarative/qdeclarativeqt/data/vector.qml | 8 - .../declarative/qdeclarativeqt/data/vector4.qml | 8 - .../declarative/qdeclarativeqt/qdeclarativeqt.pro | 15 - .../qdeclarativeqt/tst_qdeclarativeqt.cpp | 732 -- .../qdeclarativesqldatabase/data/README | 3 - .../qdeclarativesqldatabase/data/changeversion.js | 55 - .../qdeclarativesqldatabase/data/creation-a.js | 20 - .../qdeclarativesqldatabase/data/creation.js | 15 - .../qdeclarativesqldatabase/data/error-a.js | 22 - .../qdeclarativesqldatabase/data/error-b.js | 15 - .../qdeclarativesqldatabase/data/error-creation.js | 16 - .../data/error-notransaction.js | 17 - .../data/error-outsidetransaction.js | 19 - .../data/iteration-forwardonly.js | 31 - .../qdeclarativesqldatabase/data/iteration.js | 30 - .../qdeclarativesqldatabase/data/readonly-error.js | 29 - .../qdeclarativesqldatabase/data/readonly.js | 26 - .../qdeclarativesqldatabase/data/reopen1.js | 16 - .../qdeclarativesqldatabase/data/reopen2.js | 18 - .../data/selection-bindnames.js | 28 - .../qdeclarativesqldatabase/data/selection.js | 46 - .../qdeclarativesqldatabase.pro | 15 - .../tst_qdeclarativesqldatabase.cpp | 243 - .../qdeclarativetranslation/data/idtranslation.qml | 8 - .../qdeclarativetranslation/data/qml_fr.qm | Bin 374 -> 0 bytes .../qdeclarativetranslation/data/qml_fr.ts | 43 - .../qdeclarativetranslation/data/qmlid_fr.qm | Bin 119 -> 0 bytes .../qdeclarativetranslation/data/qmlid_fr.ts | 13 - .../qdeclarativetranslation/data/translation.qml | 21 - .../qdeclarativetranslation/data/translation.qrc | 6 - .../qdeclarativetranslation.pro | 16 - .../tst_qdeclarativetranslation.cpp | 137 - .../data/BindingsSpliceCorrectlyType.qml | 7 - .../data/BindingsSpliceCorrectlyType4.qml | 7 - .../data/BindingsSpliceCorrectlyType5.qml | 7 - .../data/autoBindingRemoval.2.qml | 9 - .../data/autoBindingRemoval.3.qml | 10 - .../data/autoBindingRemoval.qml | 9 - .../data/bindingAssignment.qml | 7 - .../data/bindingConflict.qml | 8 - .../qdeclarativevaluetypes/data/bindingRead.qml | 5 - .../data/bindingVariantCopy.qml | 13 - .../data/bindingsSpliceCorrectly.1.qml | 29 - .../data/bindingsSpliceCorrectly.2.qml | 31 - .../data/bindingsSpliceCorrectly.3.qml | 36 - .../data/bindingsSpliceCorrectly.4.qml | 27 - .../data/bindingsSpliceCorrectly.5.qml | 27 - .../qdeclarativevaluetypes/data/color_compare.qml | 37 - .../qdeclarativevaluetypes/data/color_read.qml | 9 - .../qdeclarativevaluetypes/data/color_write.qml | 8 - .../qdeclarativevaluetypes/data/conflicting.1.qml | 42 - .../qdeclarativevaluetypes/data/conflicting.2.qml | 42 - .../qdeclarativevaluetypes/data/conflicting.3.qml | 42 - .../qdeclarativevaluetypes/data/deletedObject.js | 13 - .../qdeclarativevaluetypes/data/deletedObject.qml | 11 - .../qdeclarativevaluetypes/data/enums.1.qml | 6 - .../qdeclarativevaluetypes/data/enums.2.qml | 6 - .../qdeclarativevaluetypes/data/enums.3.qml | 6 - .../qdeclarativevaluetypes/data/enums.4.qml | 7 - .../qdeclarativevaluetypes/data/enums.5.qml | 10 - .../qdeclarativevaluetypes/data/font_compare.qml | 31 - .../qdeclarativevaluetypes/data/font_read.qml | 18 - .../qdeclarativevaluetypes/data/font_write.2.qml | 6 - .../qdeclarativevaluetypes/data/font_write.3.qml | 7 - .../qdeclarativevaluetypes/data/font_write.4.qml | 7 - .../qdeclarativevaluetypes/data/font_write.5.qml | 14 - .../qdeclarativevaluetypes/data/font_write.qml | 16 - .../data/matrix4x4_compare.qml | 35 - .../qdeclarativevaluetypes/data/matrix4x4_read.qml | 22 - .../data/matrix4x4_write.qml | 21 - .../qdeclarativevaluetypes/data/point_compare.qml | 22 - .../qdeclarativevaluetypes/data/point_read.qml | 7 - .../qdeclarativevaluetypes/data/point_write.qml | 6 - .../qdeclarativevaluetypes/data/pointf_compare.qml | 22 - .../qdeclarativevaluetypes/data/pointf_read.qml | 8 - .../qdeclarativevaluetypes/data/pointf_write.qml | 6 - .../data/quaternion_compare.qml | 23 - .../data/quaternion_read.qml | 10 - .../data/quaternion_write.qml | 9 - .../qdeclarativevaluetypes/data/rect_compare.qml | 25 - .../qdeclarativevaluetypes/data/rect_read.qml | 10 - .../qdeclarativevaluetypes/data/rect_write.qml | 9 - .../qdeclarativevaluetypes/data/rectf_compare.qml | 25 - .../qdeclarativevaluetypes/data/rectf_read.qml | 10 - .../qdeclarativevaluetypes/data/rectf_write.qml | 9 - .../qdeclarativevaluetypes/data/returnValues.qml | 17 - .../qdeclarativevaluetypes/data/scriptAccess.qml | 9 - .../data/scriptVariantCopy.qml | 14 - .../qdeclarativevaluetypes/data/size_compare.qml | 23 - .../qdeclarativevaluetypes/data/size_read.qml | 8 - .../qdeclarativevaluetypes/data/size_write.qml | 7 - .../qdeclarativevaluetypes/data/sizef_compare.qml | 24 - .../qdeclarativevaluetypes/data/sizef_read.qml | 9 - .../qdeclarativevaluetypes/data/sizef_write.qml | 6 - .../data/sizereadonly_read.qml | 8 - .../data/sizereadonly_writeerror.qml | 6 - .../data/sizereadonly_writeerror2.qml | 7 - .../data/sizereadonly_writeerror3.qml | 7 - .../data/sizereadonly_writeerror4.qml | 10 - .../data/staticAssignment.qml | 5 - .../data/valueInterceptors.qml | 8 - .../qdeclarativevaluetypes/data/valueSources.qml | 5 - .../qdeclarativevaluetypes/data/varAssignment.qml | 14 - .../qdeclarativevaluetypes/data/variant_read.qml | 9 - .../data/vector2d_compare.qml | 21 - .../qdeclarativevaluetypes/data/vector2d_read.qml | 8 - .../qdeclarativevaluetypes/data/vector2d_write.qml | 7 - .../data/vector3d_compare.qml | 23 - .../qdeclarativevaluetypes/data/vector3d_read.qml | 9 - .../qdeclarativevaluetypes/data/vector3d_write.qml | 8 - .../data/vector4d_compare.qml | 23 - .../qdeclarativevaluetypes/data/vector4d_read.qml | 10 - .../qdeclarativevaluetypes/data/vector4d_write.qml | 9 - .../qdeclarativevaluetypes.pro | 18 - .../qdeclarativevaluetypes/testtypes.cpp | 48 - .../declarative/qdeclarativevaluetypes/testtypes.h | 219 - .../tst_qdeclarativevaluetypes.cpp | 1306 --- .../qdeclarativeworkerscript/data/BaseWorker.qml | 24 - .../qdeclarativeworkerscript/data/Global.js | 1 - .../data/externalObjectWorker.qml | 14 - .../qdeclarativeworkerscript/data/script.js | 4 - .../data/script_error_onCall.js | 6 - .../data/script_error_onLoad.js | 5 - .../data/script_fixed_return.js | 4 - .../data/script_include.js | 5 - .../qdeclarativeworkerscript/data/script_pragma.js | 6 - .../qdeclarativeworkerscript/data/stressDispose.js | 6 - .../data/stressDispose.qml | 13 - .../qdeclarativeworkerscript/data/worker.qml | 5 - .../data/worker_error_onCall.qml | 6 - .../data/worker_error_onLoad.qml | 7 - .../data/worker_include.qml | 5 - .../data/worker_pragma.qml | 6 - .../qdeclarativeworkerscript.pro | 15 - .../tst_qdeclarativeworkerscript.cpp | 300 - .../qdeclarativexmlhttprequest/data/abort.expect | 10 - .../qdeclarativexmlhttprequest/data/abort.qml | 44 - .../qdeclarativexmlhttprequest/data/abort.reply | 3 - .../data/abort_opened.qml | 60 - .../data/abort_unsent.qml | 55 - .../qdeclarativexmlhttprequest/data/attr.qml | 78 - .../qdeclarativexmlhttprequest/data/attr.xml | 1 - .../data/callbackException.qml | 25 - .../qdeclarativexmlhttprequest/data/cdata.qml | 133 - .../qdeclarativexmlhttprequest/data/cdata.xml | 2 - .../data/constructor.qml | 14 - .../data/defaultState.qml | 30 - .../qdeclarativexmlhttprequest/data/document.qml | 56 - .../qdeclarativexmlhttprequest/data/document.xml | 3 - .../data/domExceptionCodes.qml | 60 - .../qdeclarativexmlhttprequest/data/element.qml | 145 - .../qdeclarativexmlhttprequest/data/element.xml | 1 - .../data/getAllResponseHeaders.qml | 66 - .../data/getAllResponseHeaders_args.qml | 23 - .../data/getAllResponseHeaders_sent.qml | 20 - .../data/getAllResponseHeaders_unsent.qml | 16 - .../data/getResponseHeader.expect | 7 - .../data/getResponseHeader.qml | 76 - .../data/getResponseHeader.reply | 8 - .../data/getResponseHeader_args.qml | 23 - .../data/getResponseHeader_sent.qml | 20 - .../data/getResponseHeader_unsent.qml | 16 - .../data/instanceStateValues.qml | 33 - .../data/invalidMethodUsage.qml | 148 - .../qdeclarativexmlhttprequest/data/open.qml | 54 - .../data/open_arg_count.1.qml | 18 - .../data/open_arg_count.2.qml | 18 - .../data/open_invalid_method.qml | 16 - .../data/open_network.expect | 7 - .../data/open_network.reply | 3 - .../data/open_network.wait | 0 .../qdeclarativexmlhttprequest/data/open_sync.qml | 17 - .../qdeclarativexmlhttprequest/data/open_user.qml | 54 - .../data/open_username.qml | 54 - .../data/redirectError.qml | 23 - .../data/redirectRecur.qml | 23 - .../qdeclarativexmlhttprequest/data/redirects.qml | 22 - .../data/redirecttarget.html | 1 - .../data/responseText.qml | 54 - .../data/responseXML_invalid.qml | 24 - .../data/seconddocument.html | 1 - .../data/send_alreadySent.qml | 28 - .../data/send_data.1.expect | 10 - .../data/send_data.1.qml | 22 - .../data/send_data.2.qml | 24 - .../data/send_data.3.qml | 24 - .../data/send_data.4.expect | 10 - .../data/send_data.4.qml | 24 - .../data/send_data.5.qml | 24 - .../data/send_data.6.expect | 10 - .../data/send_data.6.qml | 22 - .../data/send_data.7.qml | 24 - .../data/send_data.reply | 3 - .../data/send_ignoreData.qml | 27 - .../data/send_ignoreData.reply | 3 - .../data/send_ignoreData_DELETE.expect | 7 - .../data/send_ignoreData_GET.expect | 7 - .../data/send_ignoreData_HEAD.expect | 7 - .../data/send_unsent.qml | 16 - .../data/setRequestHeader.expect | 9 - .../data/setRequestHeader.qml | 29 - .../data/setRequestHeader.reply | 3 - .../data/setRequestHeader_args.qml | 18 - .../data/setRequestHeader_caseInsensitive.qml | 30 - .../data/setRequestHeader_illegalName.qml | 58 - .../data/setRequestHeader_sent.qml | 32 - .../data/setRequestHeader_unsent.qml | 17 - .../data/staticStateValues.qml | 24 - .../data/status.200.reply | 3 - .../data/status.400.reply | 4 - .../data/status.404.reply | 3 - .../qdeclarativexmlhttprequest/data/status.expect | 7 - .../qdeclarativexmlhttprequest/data/status.qml | 79 - .../qdeclarativexmlhttprequest/data/statusText.qml | 79 - .../data/testdocument.html | 1 - .../qdeclarativexmlhttprequest/data/text.qml | 129 - .../qdeclarativexmlhttprequest/data/text.xml | 1 - .../qdeclarativexmlhttprequest/data/utf16.html | 1 - .../qdeclarativexmlhttprequest/data/utf16.qml | 29 - .../qdeclarativexmlhttprequest/data/utf16.xml | Bin 154 -> 0 bytes .../qdeclarativexmlhttprequest.pro | 19 - .../tst_qdeclarativexmlhttprequest.cpp | 1160 --- tests/auto/declarative/qjsengine/qjsengine.pro | 13 - .../declarative/qjsengine/script/com/__init__.js | 9 - .../qjsengine/script/com/trolltech/__init__.js | 9 - .../script/com/trolltech/recursive/__init__.js | 1 - .../script/com/trolltech/syntaxerror/__init__.js | 5 - tests/auto/declarative/qjsengine/tst_qjsengine.cpp | 6353 -------------- tests/auto/declarative/qjsvalue/qjsvalue.pro | 6 - tests/auto/declarative/qjsvalue/tst_qjsvalue.cpp | 3655 -------- tests/auto/declarative/qjsvalue/tst_qjsvalue.h | 204 - .../qjsvalueiterator/qjsvalueiterator.pro | 7 - .../qjsvalueiterator/tst_qjsvalueiterator.cpp | 522 -- tests/auto/declarative/qmlmin/qmlmin.pro | 9 - tests/auto/declarative/qmlmin/tst_qmlmin.cpp | 192 - .../declarative/qmlplugindump/qmlplugindump.pro | 7 - .../qmlplugindump/tst_qmlplugindump.cpp | 117 - tests/auto/declarative/runall.sh | 100 - tests/auto/declarative/v4/data/conditionalExpr.qml | 6 - tests/auto/declarative/v4/data/doubleBoolJump.qml | 18 - tests/auto/declarative/v4/data/fetchException.qml | 6 - tests/auto/declarative/v4/data/logicalOr.2.qml | 6 - tests/auto/declarative/v4/data/logicalOr.qml | 6 - tests/auto/declarative/v4/data/nestedLogicalOr.qml | 14 - .../declarative/v4/data/nestedObjectAccess.qml | 5 - tests/auto/declarative/v4/data/nullQObject.qml | 7 - .../declarative/v4/data/qrealToIntRounding.qml | 10 - tests/auto/declarative/v4/data/qtbug_21883.qml | 5 - tests/auto/declarative/v4/data/qtbug_22816.qml | 18 - .../auto/declarative/v4/data/stringComparison.qml | 34 - .../data/subscriptionsInConditionalExpressions.qml | 11 - tests/auto/declarative/v4/data/unaryMinus.qml | 24 - tests/auto/declarative/v4/data/unaryPlus.qml | 24 - .../auto/declarative/v4/data/unnecessaryReeval.qml | 7 - tests/auto/declarative/v4/testtypes.cpp | 49 - tests/auto/declarative/v4/testtypes.h | 83 - tests/auto/declarative/v4/tst_v4.cpp | 353 - tests/auto/declarative/v4/v4.pro | 17 - tests/auto/headersclean/headersclean.pro | 2 +- tests/auto/headersclean/tst_headersclean.cpp | 2 +- tests/auto/particles/qquickage/qquickage.pro | 2 +- .../qquickangleddirection.pro | 2 +- .../qquickcumulativedirection.pro | 2 +- .../qquickcustomaffector/qquickcustomaffector.pro | 2 +- .../qquickcustomparticle/qquickcustomparticle.pro | 2 +- .../qquickellipseextruder.pro | 2 +- .../particles/qquickfriction/qquickfriction.pro | 2 +- .../auto/particles/qquickgravity/qquickgravity.pro | 2 +- .../particles/qquickgroupgoal/qquickgroupgoal.pro | 2 +- .../qquickimageparticle/qquickimageparticle.pro | 2 +- .../qquickitemparticle/qquickitemparticle.pro | 2 +- .../qquicklineextruder/qquicklineextruder.pro | 2 +- .../qquickmaskextruder/qquickmaskextruder.pro | 2 +- .../qquickparticlegroup/qquickparticlegroup.pro | 2 +- .../qquickparticlesystem/qquickparticlesystem.pro | 2 +- .../qquickpointattractor/qquickpointattractor.pro | 2 +- .../qquickpointdirection/qquickpointdirection.pro | 2 +- .../qquickrectangleextruder.pro | 2 +- .../qquickspritegoal/qquickspritegoal.pro | 2 +- .../qquicktargetdirection.pro | 2 +- .../qquicktrailemitter/qquicktrailemitter.pro | 2 +- .../qquickturbulence/qquickturbulence.pro | 2 +- tests/auto/particles/qquickwander/qquickwander.pro | 2 +- tests/auto/qml/animation/animation.pro | 7 + .../qabstractanimationjob.pro | 5 + .../tst_qabstractanimationjob.cpp | 229 + .../qanimationgroupjob/qanimationgroupjob.pro | 5 + .../qanimationgroupjob/tst_qanimationgroupjob.cpp | 310 + .../qparallelanimationgroupjob.pro | 5 + .../tst_qparallelanimationgroupjob.cpp | 931 ++ .../qpauseanimationjob/qpauseanimationjob.pro | 5 + .../qpauseanimationjob/tst_qpauseanimationjob.cpp | 470 + .../qsequentialanimationgroupjob.pro | 5 + .../tst_qsequentialanimationgroupjob.cpp | 1617 ++++ tests/auto/qml/debugger/debugger.pro | 16 + .../debugger/qdebugmessageservice/data/test.qml | 51 + .../qdebugmessageservice/qdebugmessageservice.pro | 21 + .../tst_qdebugmessageservice.cpp | 242 + .../debugger/qpacketprotocol/qpacketprotocol.pro | 10 + .../qpacketprotocol/tst_qpacketprotocol.cpp | 263 + .../debugger/qqmldebugclient/qqmldebugclient.pro | 11 + .../qqmldebugclient/tst_qqmldebugclient.cpp | 197 + .../qqmldebugjs/data/breakpointRelocation.qml | 53 + .../debugger/qqmldebugjs/data/changeBreakpoint.qml | 60 + .../qml/debugger/qqmldebugjs/data/condition.qml | 54 + .../debugger/qqmldebugjs/data/createComponent.qml | 54 + .../qml/debugger/qqmldebugjs/data/exception.qml | 51 + .../qml/debugger/qqmldebugjs/data/loadjsfile.qml | 48 + .../qml/debugger/qqmldebugjs/data/oncompleted.qml | 53 + .../qml/debugger/qqmldebugjs/data/stepAction.qml | 57 + tests/auto/qml/debugger/qqmldebugjs/data/test.js | 53 + tests/auto/qml/debugger/qqmldebugjs/data/test.qml | 54 + tests/auto/qml/debugger/qqmldebugjs/data/timer.qml | 52 + .../auto/qml/debugger/qqmldebugjs/qqmldebugjs.pro | 29 + .../qml/debugger/qqmldebugjs/tst_qqmldebugjs.cpp | 1790 ++++ .../debugger/qqmldebugservice/qqmldebugservice.pro | 11 + .../qqmldebugservice/tst_qqmldebugservice.cpp | 216 + .../debugger/qqmlenginedebug/qqmlenginedebug.pro | 11 + .../qqmlenginedebug/tst_qqmlenginedebug.cpp | 1235 +++ tests/auto/qml/debugger/qqmlinspector/app/app.pro | 9 + tests/auto/qml/debugger/qqmlinspector/app/main.cpp | 71 + .../qml/debugger/qqmlinspector/app/qtquick2.qml | 5 + .../qml/debugger/qqmlinspector/qqmlinspector.pro | 3 + .../debugger/qqmlinspector/tst_qqmlinspector.cpp | 186 + .../debugger/qqmlinspector/tst_qqmlinspector.pro | 12 + .../qml/debugger/qqmlprofilerservice/data/exit.qml | 9 + .../qml/debugger/qqmlprofilerservice/data/test.qml | 5 + .../qqmlprofilerservice/qqmlprofilerservice.pro | 15 + .../tst_qqmlprofilerservice.cpp | 310 + .../debugger/qv8profilerservice/data/console.qml | 14 + .../qml/debugger/qv8profilerservice/data/exit.qml | 11 + .../qml/debugger/qv8profilerservice/data/test.qml | 5 + .../qv8profilerservice/qv8profilerservice.pro | 16 + .../qv8profilerservice/tst_qv8profilerservice.cpp | 280 + tests/auto/qml/debugger/shared/debugutil.cpp | 190 + tests/auto/qml/debugger/shared/debugutil_p.h | 127 + tests/auto/qml/parserstress/parserstress.pro | 12 + .../qml/parserstress/tests/ecma/Array/15.4-1.js | 135 + .../qml/parserstress/tests/ecma/Array/15.4-2.js | 114 + .../qml/parserstress/tests/ecma/Array/15.4.1.1.js | 111 + .../qml/parserstress/tests/ecma/Array/15.4.1.2.js | 162 + .../qml/parserstress/tests/ecma/Array/15.4.1.3.js | 84 + .../qml/parserstress/tests/ecma/Array/15.4.1.js | 132 + .../parserstress/tests/ecma/Array/15.4.2.1-1.js | 112 + .../parserstress/tests/ecma/Array/15.4.2.1-2.js | 101 + .../parserstress/tests/ecma/Array/15.4.2.1-3.js | 137 + .../parserstress/tests/ecma/Array/15.4.2.2-1.js | 183 + .../parserstress/tests/ecma/Array/15.4.2.2-2.js | 118 + .../qml/parserstress/tests/ecma/Array/15.4.2.3.js | 101 + .../parserstress/tests/ecma/Array/15.4.3.1-2.js | 81 + .../qml/parserstress/tests/ecma/Array/15.4.3.2.js | 62 + .../qml/parserstress/tests/ecma/Array/15.4.4.1.js | 63 + .../qml/parserstress/tests/ecma/Array/15.4.4.2.js | 120 + .../parserstress/tests/ecma/Array/15.4.4.3-1.js | 163 + .../parserstress/tests/ecma/Array/15.4.4.4-1.js | 294 + .../parserstress/tests/ecma/Array/15.4.4.4-2.js | 169 + .../parserstress/tests/ecma/Array/15.4.4.5-1.js | 225 + .../parserstress/tests/ecma/Array/15.4.4.5-2.js | 227 + .../parserstress/tests/ecma/Array/15.4.4.5-3.js | 182 + .../qml/parserstress/tests/ecma/Array/15.4.4.js | 74 + .../parserstress/tests/ecma/Array/15.4.5.1-1.js | 170 + .../parserstress/tests/ecma/Array/15.4.5.1-2.js | 152 + .../parserstress/tests/ecma/Array/15.4.5.2-1.js | 86 + .../parserstress/tests/ecma/Array/15.4.5.2-2.js | 127 + .../qml/parserstress/tests/ecma/Array/browser.js | 0 .../qml/parserstress/tests/ecma/Array/shell.js | 1 + .../qml/parserstress/tests/ecma/Boolean/15.6.1.js | 96 + .../qml/parserstress/tests/ecma/Boolean/15.6.2.js | 161 + .../parserstress/tests/ecma/Boolean/15.6.3.1-1.js | 72 + .../parserstress/tests/ecma/Boolean/15.6.3.1-2.js | 71 + .../parserstress/tests/ecma/Boolean/15.6.3.1-3.js | 71 + .../parserstress/tests/ecma/Boolean/15.6.3.1-4.js | 75 + .../parserstress/tests/ecma/Boolean/15.6.3.1.js | 69 + .../parserstress/tests/ecma/Boolean/15.6.4-1.js | 72 + .../parserstress/tests/ecma/Boolean/15.6.4.1.js | 62 + .../parserstress/tests/ecma/Boolean/15.6.4.2-1.js | 97 + .../parserstress/tests/ecma/Boolean/15.6.4.2-2.js | 73 + .../parserstress/tests/ecma/Boolean/15.6.4.2-3.js | 65 + .../tests/ecma/Boolean/15.6.4.2-4-n.js | 69 + .../parserstress/tests/ecma/Boolean/15.6.4.3-1.js | 88 + .../parserstress/tests/ecma/Boolean/15.6.4.3-2.js | 67 + .../parserstress/tests/ecma/Boolean/15.6.4.3-3.js | 66 + .../tests/ecma/Boolean/15.6.4.3-4-n.js | 69 + .../parserstress/tests/ecma/Boolean/15.6.4.3.js | 83 + .../qml/parserstress/tests/ecma/Boolean/15.6.4.js | 80 + .../qml/parserstress/tests/ecma/Boolean/browser.js | 0 .../qml/parserstress/tests/ecma/Boolean/shell.js | 1 + .../qml/parserstress/tests/ecma/Date/15.9.1.1-1.js | 96 + .../qml/parserstress/tests/ecma/Date/15.9.1.1-2.js | 91 + .../parserstress/tests/ecma/Date/15.9.1.13-1.js | 79 + .../qml/parserstress/tests/ecma/Date/15.9.2.1.js | 104 + .../qml/parserstress/tests/ecma/Date/15.9.2.2-1.js | 69 + .../qml/parserstress/tests/ecma/Date/15.9.2.2-2.js | 69 + .../qml/parserstress/tests/ecma/Date/15.9.2.2-3.js | 69 + .../qml/parserstress/tests/ecma/Date/15.9.2.2-4.js | 68 + .../qml/parserstress/tests/ecma/Date/15.9.2.2-5.js | 68 + .../qml/parserstress/tests/ecma/Date/15.9.2.2-6.js | 67 + .../qml/parserstress/tests/ecma/Date/15.9.3.1-1.js | 239 + .../qml/parserstress/tests/ecma/Date/15.9.3.1-2.js | 152 + .../qml/parserstress/tests/ecma/Date/15.9.3.1-3.js | 141 + .../qml/parserstress/tests/ecma/Date/15.9.3.1-4.js | 151 + .../qml/parserstress/tests/ecma/Date/15.9.3.1-5.js | 140 + .../qml/parserstress/tests/ecma/Date/15.9.3.2-1.js | 151 + .../qml/parserstress/tests/ecma/Date/15.9.3.2-2.js | 142 + .../qml/parserstress/tests/ecma/Date/15.9.3.2-3.js | 146 + .../qml/parserstress/tests/ecma/Date/15.9.3.2-4.js | 143 + .../qml/parserstress/tests/ecma/Date/15.9.3.2-5.js | 140 + .../qml/parserstress/tests/ecma/Date/15.9.3.8-1.js | 155 + .../qml/parserstress/tests/ecma/Date/15.9.3.8-2.js | 153 + .../qml/parserstress/tests/ecma/Date/15.9.3.8-3.js | 160 + .../qml/parserstress/tests/ecma/Date/15.9.3.8-4.js | 161 + .../qml/parserstress/tests/ecma/Date/15.9.3.8-5.js | 161 + .../qml/parserstress/tests/ecma/Date/15.9.4.2-1.js | 81 + .../qml/parserstress/tests/ecma/Date/15.9.4.2.js | 191 + .../qml/parserstress/tests/ecma/Date/15.9.4.3.js | 186 + .../qml/parserstress/tests/ecma/Date/15.9.5.1.js | 63 + .../parserstress/tests/ecma/Date/15.9.5.10-1.js | 85 + .../parserstress/tests/ecma/Date/15.9.5.10-10.js | 89 + .../parserstress/tests/ecma/Date/15.9.5.10-11.js | 89 + .../parserstress/tests/ecma/Date/15.9.5.10-12.js | 89 + .../parserstress/tests/ecma/Date/15.9.5.10-13.js | 89 + .../parserstress/tests/ecma/Date/15.9.5.10-2.js | 87 + .../parserstress/tests/ecma/Date/15.9.5.10-3.js | 85 + .../parserstress/tests/ecma/Date/15.9.5.10-4.js | 85 + .../parserstress/tests/ecma/Date/15.9.5.10-5.js | 85 + .../parserstress/tests/ecma/Date/15.9.5.10-6.js | 85 + .../parserstress/tests/ecma/Date/15.9.5.10-7.js | 85 + .../parserstress/tests/ecma/Date/15.9.5.10-8.js | 89 + .../parserstress/tests/ecma/Date/15.9.5.10-9.js | 89 + .../parserstress/tests/ecma/Date/15.9.5.11-1.js | 76 + .../parserstress/tests/ecma/Date/15.9.5.11-2.js | 76 + .../parserstress/tests/ecma/Date/15.9.5.11-3.js | 76 + .../parserstress/tests/ecma/Date/15.9.5.11-4.js | 76 + .../parserstress/tests/ecma/Date/15.9.5.11-5.js | 76 + .../parserstress/tests/ecma/Date/15.9.5.11-6.js | 76 + .../parserstress/tests/ecma/Date/15.9.5.11-7.js | 76 + .../parserstress/tests/ecma/Date/15.9.5.12-1.js | 77 + .../parserstress/tests/ecma/Date/15.9.5.12-2.js | 77 + .../parserstress/tests/ecma/Date/15.9.5.12-3.js | 77 + .../parserstress/tests/ecma/Date/15.9.5.12-4.js | 77 + .../parserstress/tests/ecma/Date/15.9.5.12-5.js | 77 + .../parserstress/tests/ecma/Date/15.9.5.12-6.js | 77 + .../parserstress/tests/ecma/Date/15.9.5.12-7.js | 77 + .../parserstress/tests/ecma/Date/15.9.5.12-8.js | 71 + .../parserstress/tests/ecma/Date/15.9.5.13-1.js | 79 + .../parserstress/tests/ecma/Date/15.9.5.13-2.js | 76 + .../parserstress/tests/ecma/Date/15.9.5.13-3.js | 77 + .../parserstress/tests/ecma/Date/15.9.5.13-4.js | 77 + .../parserstress/tests/ecma/Date/15.9.5.13-5.js | 77 + .../parserstress/tests/ecma/Date/15.9.5.13-6.js | 77 + .../parserstress/tests/ecma/Date/15.9.5.13-7.js | 76 + .../parserstress/tests/ecma/Date/15.9.5.13-8.js | 71 + .../qml/parserstress/tests/ecma/Date/15.9.5.14.js | 87 + .../qml/parserstress/tests/ecma/Date/15.9.5.15.js | 88 + .../qml/parserstress/tests/ecma/Date/15.9.5.16.js | 87 + .../qml/parserstress/tests/ecma/Date/15.9.5.17.js | 88 + .../qml/parserstress/tests/ecma/Date/15.9.5.18.js | 88 + .../qml/parserstress/tests/ecma/Date/15.9.5.19.js | 88 + .../qml/parserstress/tests/ecma/Date/15.9.5.2-1.js | 151 + .../parserstress/tests/ecma/Date/15.9.5.2-2-n.js | 84 + .../qml/parserstress/tests/ecma/Date/15.9.5.2.js | 151 + .../qml/parserstress/tests/ecma/Date/15.9.5.20.js | 88 + .../parserstress/tests/ecma/Date/15.9.5.21-1.js | 70 + .../parserstress/tests/ecma/Date/15.9.5.21-2.js | 70 + .../parserstress/tests/ecma/Date/15.9.5.21-3.js | 70 + .../parserstress/tests/ecma/Date/15.9.5.21-4.js | 70 + .../parserstress/tests/ecma/Date/15.9.5.21-5.js | 70 + .../parserstress/tests/ecma/Date/15.9.5.21-6.js | 70 + .../parserstress/tests/ecma/Date/15.9.5.21-7.js | 70 + .../parserstress/tests/ecma/Date/15.9.5.21-8.js | 71 + .../parserstress/tests/ecma/Date/15.9.5.22-1.js | 89 + .../parserstress/tests/ecma/Date/15.9.5.22-2.js | 74 + .../parserstress/tests/ecma/Date/15.9.5.22-3.js | 74 + .../parserstress/tests/ecma/Date/15.9.5.22-4.js | 74 + .../parserstress/tests/ecma/Date/15.9.5.22-5.js | 74 + .../parserstress/tests/ecma/Date/15.9.5.22-6.js | 74 + .../parserstress/tests/ecma/Date/15.9.5.22-7.js | 74 + .../parserstress/tests/ecma/Date/15.9.5.22-8.js | 72 + .../parserstress/tests/ecma/Date/15.9.5.23-1.js | 139 + .../parserstress/tests/ecma/Date/15.9.5.23-10.js | 139 + .../parserstress/tests/ecma/Date/15.9.5.23-11.js | 140 + .../parserstress/tests/ecma/Date/15.9.5.23-12.js | 137 + .../parserstress/tests/ecma/Date/15.9.5.23-13.js | 137 + .../parserstress/tests/ecma/Date/15.9.5.23-14.js | 137 + .../parserstress/tests/ecma/Date/15.9.5.23-15.js | 137 + .../parserstress/tests/ecma/Date/15.9.5.23-16.js | 137 + .../parserstress/tests/ecma/Date/15.9.5.23-17.js | 137 + .../parserstress/tests/ecma/Date/15.9.5.23-18.js | 137 + .../parserstress/tests/ecma/Date/15.9.5.23-2.js | 109 + .../parserstress/tests/ecma/Date/15.9.5.23-3-n.js | 79 + .../parserstress/tests/ecma/Date/15.9.5.23-4.js | 112 + .../parserstress/tests/ecma/Date/15.9.5.23-5.js | 113 + .../parserstress/tests/ecma/Date/15.9.5.23-6.js | 112 + .../parserstress/tests/ecma/Date/15.9.5.23-7.js | 113 + .../parserstress/tests/ecma/Date/15.9.5.23-8.js | 103 + .../parserstress/tests/ecma/Date/15.9.5.23-9.js | 103 + .../parserstress/tests/ecma/Date/15.9.5.24-1.js | 134 + .../parserstress/tests/ecma/Date/15.9.5.24-2.js | 134 + .../parserstress/tests/ecma/Date/15.9.5.24-3.js | 134 + .../parserstress/tests/ecma/Date/15.9.5.24-4.js | 134 + .../parserstress/tests/ecma/Date/15.9.5.24-5.js | 134 + .../parserstress/tests/ecma/Date/15.9.5.24-6.js | 134 + .../parserstress/tests/ecma/Date/15.9.5.24-7.js | 134 + .../parserstress/tests/ecma/Date/15.9.5.24-8.js | 133 + .../parserstress/tests/ecma/Date/15.9.5.25-1.js | 174 + .../parserstress/tests/ecma/Date/15.9.5.26-1.js | 183 + .../parserstress/tests/ecma/Date/15.9.5.27-1.js | 183 + .../parserstress/tests/ecma/Date/15.9.5.28-1.js | 196 + .../parserstress/tests/ecma/Date/15.9.5.29-1.js | 191 + .../parserstress/tests/ecma/Date/15.9.5.3-1-n.js | 80 + .../qml/parserstress/tests/ecma/Date/15.9.5.3-2.js | 104 + .../parserstress/tests/ecma/Date/15.9.5.30-1.js | 192 + .../parserstress/tests/ecma/Date/15.9.5.31-1.js | 221 + .../parserstress/tests/ecma/Date/15.9.5.32-1.js | 141 + .../parserstress/tests/ecma/Date/15.9.5.33-1.js | 145 + .../parserstress/tests/ecma/Date/15.9.5.34-1.js | 182 + .../parserstress/tests/ecma/Date/15.9.5.35-1.js | 139 + .../parserstress/tests/ecma/Date/15.9.5.36-1.js | 165 + .../parserstress/tests/ecma/Date/15.9.5.36-2.js | 164 + .../parserstress/tests/ecma/Date/15.9.5.36-3.js | 163 + .../parserstress/tests/ecma/Date/15.9.5.36-4.js | 163 + .../parserstress/tests/ecma/Date/15.9.5.36-5.js | 163 + .../parserstress/tests/ecma/Date/15.9.5.36-6.js | 163 + .../parserstress/tests/ecma/Date/15.9.5.36-7.js | 163 + .../parserstress/tests/ecma/Date/15.9.5.37-1.js | 173 + .../parserstress/tests/ecma/Date/15.9.5.37-2.js | 161 + .../parserstress/tests/ecma/Date/15.9.5.37-3.js | 164 + .../parserstress/tests/ecma/Date/15.9.5.37-4.js | 163 + .../parserstress/tests/ecma/Date/15.9.5.37-5.js | 159 + .../qml/parserstress/tests/ecma/Date/15.9.5.4-1.js | 93 + .../parserstress/tests/ecma/Date/15.9.5.4-2-n.js | 76 + .../qml/parserstress/tests/ecma/Date/15.9.5.5.js | 112 + .../qml/parserstress/tests/ecma/Date/15.9.5.6.js | 104 + .../qml/parserstress/tests/ecma/Date/15.9.5.7.js | 105 + .../qml/parserstress/tests/ecma/Date/15.9.5.8.js | 113 + .../qml/parserstress/tests/ecma/Date/15.9.5.9.js | 113 + .../qml/parserstress/tests/ecma/Date/15.9.5.js | 83 + .../qml/parserstress/tests/ecma/Date/browser.js | 0 .../auto/qml/parserstress/tests/ecma/Date/shell.js | 1 + .../tests/ecma/ExecutionContexts/10.1.3-1.js | 107 + .../tests/ecma/ExecutionContexts/10.1.3-2.js | 73 + .../tests/ecma/ExecutionContexts/10.1.3.js | 170 + .../tests/ecma/ExecutionContexts/10.1.4-1.js | 111 + .../tests/ecma/ExecutionContexts/10.1.4-10.js | 105 + .../tests/ecma/ExecutionContexts/10.1.4-2.js | 113 + .../tests/ecma/ExecutionContexts/10.1.4-3.js | 111 + .../tests/ecma/ExecutionContexts/10.1.4-4.js | 113 + .../tests/ecma/ExecutionContexts/10.1.4-5.js | 112 + .../tests/ecma/ExecutionContexts/10.1.4-6.js | 100 + .../tests/ecma/ExecutionContexts/10.1.4-7.js | 112 + .../tests/ecma/ExecutionContexts/10.1.4-8.js | 113 + .../tests/ecma/ExecutionContexts/10.1.5-1.js | 118 + .../tests/ecma/ExecutionContexts/10.1.5-2.js | 100 + .../tests/ecma/ExecutionContexts/10.1.5-3.js | 130 + .../tests/ecma/ExecutionContexts/10.1.5-4.js | 91 + .../tests/ecma/ExecutionContexts/10.1.8-2.js | 120 + .../tests/ecma/ExecutionContexts/10.1.8-3.js | 66 + .../tests/ecma/ExecutionContexts/10.2.1.js | 85 + .../tests/ecma/ExecutionContexts/10.2.2-1.js | 122 + .../tests/ecma/ExecutionContexts/10.2.2-2.js | 133 + .../tests/ecma/ExecutionContexts/10.2.3-1.js | 86 + .../tests/ecma/ExecutionContexts/10.2.3-2.js | 92 + .../tests/ecma/ExecutionContexts/browser.js | 0 .../tests/ecma/ExecutionContexts/shell.js | 1 + .../parserstress/tests/ecma/Expressions/11.1.1.js | 137 + .../parserstress/tests/ecma/Expressions/11.10-1.js | 270 + .../parserstress/tests/ecma/Expressions/11.10-2.js | 269 + .../parserstress/tests/ecma/Expressions/11.10-3.js | 268 + .../parserstress/tests/ecma/Expressions/11.12-1.js | 110 + .../tests/ecma/Expressions/11.12-2-n.js | 74 + .../parserstress/tests/ecma/Expressions/11.12-3.js | 71 + .../parserstress/tests/ecma/Expressions/11.12-4.js | 71 + .../parserstress/tests/ecma/Expressions/11.13.1.js | 72 + .../tests/ecma/Expressions/11.13.2-1.js | 231 + .../tests/ecma/Expressions/11.13.2-2.js | 253 + .../tests/ecma/Expressions/11.13.2-3.js | 300 + .../tests/ecma/Expressions/11.13.2-4.js | 137 + .../tests/ecma/Expressions/11.13.2-5.js | 137 + .../parserstress/tests/ecma/Expressions/11.13.js | 86 + .../parserstress/tests/ecma/Expressions/11.14-1.js | 73 + .../tests/ecma/Expressions/11.2.1-1.js | 272 + .../tests/ecma/Expressions/11.2.1-2.js | 128 + .../tests/ecma/Expressions/11.2.1-3-n.js | 128 + .../tests/ecma/Expressions/11.2.1-4-n.js | 128 + .../tests/ecma/Expressions/11.2.1-5.js | 128 + .../tests/ecma/Expressions/11.2.2-1-n.js | 104 + .../tests/ecma/Expressions/11.2.2-1.js | 100 + .../tests/ecma/Expressions/11.2.2-10-n.js | 102 + .../tests/ecma/Expressions/11.2.2-11.js | 104 + .../tests/ecma/Expressions/11.2.2-2-n.js | 104 + .../tests/ecma/Expressions/11.2.2-3-n.js | 100 + .../tests/ecma/Expressions/11.2.2-4-n.js | 104 + .../tests/ecma/Expressions/11.2.2-5-n.js | 104 + .../tests/ecma/Expressions/11.2.2-6-n.js | 103 + .../tests/ecma/Expressions/11.2.2-7-n.js | 104 + .../tests/ecma/Expressions/11.2.2-8-n.js | 104 + .../tests/ecma/Expressions/11.2.2-9-n.js | 104 + .../tests/ecma/Expressions/11.2.3-1.js | 125 + .../tests/ecma/Expressions/11.2.3-2-n.js | 94 + .../tests/ecma/Expressions/11.2.3-3-n.js | 91 + .../tests/ecma/Expressions/11.2.3-4-n.js | 91 + .../tests/ecma/Expressions/11.2.3-5.js | 85 + .../parserstress/tests/ecma/Expressions/11.3.1.js | 153 + .../parserstress/tests/ecma/Expressions/11.3.2.js | 153 + .../parserstress/tests/ecma/Expressions/11.4.1.js | 92 + .../parserstress/tests/ecma/Expressions/11.4.2.js | 83 + .../parserstress/tests/ecma/Expressions/11.4.3.js | 111 + .../parserstress/tests/ecma/Expressions/11.4.4.js | 156 + .../parserstress/tests/ecma/Expressions/11.4.5.js | 154 + .../parserstress/tests/ecma/Expressions/11.4.6.js | 299 + .../tests/ecma/Expressions/11.4.7-01.js | 299 + .../tests/ecma/Expressions/11.4.7-02.js | 87 + .../parserstress/tests/ecma/Expressions/11.4.8.js | 215 + .../parserstress/tests/ecma/Expressions/11.4.9.js | 94 + .../parserstress/tests/ecma/Expressions/11.5.1.js | 115 + .../parserstress/tests/ecma/Expressions/11.5.2.js | 154 + .../parserstress/tests/ecma/Expressions/11.5.3.js | 161 + .../tests/ecma/Expressions/11.6.1-1.js | 160 + .../tests/ecma/Expressions/11.6.1-2.js | 164 + .../tests/ecma/Expressions/11.6.1-3.js | 150 + .../tests/ecma/Expressions/11.6.2-1.js | 165 + .../parserstress/tests/ecma/Expressions/11.6.3.js | 115 + .../parserstress/tests/ecma/Expressions/11.7.1.js | 228 + .../parserstress/tests/ecma/Expressions/11.7.2.js | 246 + .../parserstress/tests/ecma/Expressions/11.7.3.js | 230 + .../parserstress/tests/ecma/Expressions/11.8.1.js | 121 + .../parserstress/tests/ecma/Expressions/11.8.2.js | 121 + .../parserstress/tests/ecma/Expressions/11.8.3.js | 120 + .../parserstress/tests/ecma/Expressions/11.8.4.js | 121 + .../parserstress/tests/ecma/Expressions/11.9.1.js | 159 + .../parserstress/tests/ecma/Expressions/11.9.2.js | 159 + .../parserstress/tests/ecma/Expressions/11.9.3.js | 159 + .../parserstress/tests/ecma/Expressions/browser.js | 0 .../parserstress/tests/ecma/Expressions/shell.js | 1 + .../tests/ecma/FunctionObjects/15.3.1.1-1.js | 136 + .../tests/ecma/FunctionObjects/15.3.1.1-2.js | 183 + .../tests/ecma/FunctionObjects/15.3.1.1-3.js | 99 + .../tests/ecma/FunctionObjects/15.3.2.1-1.js | 132 + .../tests/ecma/FunctionObjects/15.3.2.1-2.js | 107 + .../tests/ecma/FunctionObjects/15.3.2.1-3.js | 95 + .../tests/ecma/FunctionObjects/15.3.3.1-2.js | 70 + .../tests/ecma/FunctionObjects/15.3.3.1-3.js | 79 + .../tests/ecma/FunctionObjects/15.3.3.1-4.js | 70 + .../tests/ecma/FunctionObjects/15.3.3.2.js | 62 + .../tests/ecma/FunctionObjects/15.3.4-1.js | 94 + .../tests/ecma/FunctionObjects/15.3.4.1.js | 61 + .../tests/ecma/FunctionObjects/15.3.4.js | 81 + .../tests/ecma/FunctionObjects/15.3.5-1.js | 117 + .../tests/ecma/FunctionObjects/15.3.5-2.js | 90 + .../tests/ecma/FunctionObjects/15.3.5.1.js | 83 + .../tests/ecma/FunctionObjects/15.3.5.3.js | 72 + .../tests/ecma/FunctionObjects/browser.js | 0 .../tests/ecma/FunctionObjects/shell.js | 1 + .../tests/ecma/GlobalObject/15.1-1-n.js | 70 + .../tests/ecma/GlobalObject/15.1-2-n.js | 67 + .../tests/ecma/GlobalObject/15.1.1.1.js | 63 + .../tests/ecma/GlobalObject/15.1.1.2.js | 62 + .../tests/ecma/GlobalObject/15.1.2.1-2.js | 66 + .../tests/ecma/GlobalObject/15.1.2.2-1.js | 410 + .../tests/ecma/GlobalObject/15.1.2.2-2.js | 238 + .../tests/ecma/GlobalObject/15.1.2.3-1.js | 441 + .../tests/ecma/GlobalObject/15.1.2.3-2.js | 291 + .../tests/ecma/GlobalObject/15.1.2.4.js | 205 + .../tests/ecma/GlobalObject/15.1.2.5-1.js | 206 + .../tests/ecma/GlobalObject/15.1.2.5-2.js | 183 + .../tests/ecma/GlobalObject/15.1.2.5-3.js | 207 + .../tests/ecma/GlobalObject/15.1.2.6.js | 125 + .../tests/ecma/GlobalObject/15.1.2.7.js | 130 + .../tests/ecma/GlobalObject/browser.js | 0 .../parserstress/tests/ecma/GlobalObject/shell.js | 1 + .../tests/ecma/LexicalConventions/7.1-1.js | 82 + .../tests/ecma/LexicalConventions/7.1-2.js | 73 + .../tests/ecma/LexicalConventions/7.1-3.js | 89 + .../tests/ecma/LexicalConventions/7.2-1.js | 73 + .../tests/ecma/LexicalConventions/7.2-2-n.js | 74 + .../tests/ecma/LexicalConventions/7.2-3-n.js | 74 + .../tests/ecma/LexicalConventions/7.2-4-n.js | 73 + .../tests/ecma/LexicalConventions/7.2-5-n.js | 72 + .../tests/ecma/LexicalConventions/7.2-6.js | 68 + .../tests/ecma/LexicalConventions/7.3-1.js | 92 + .../tests/ecma/LexicalConventions/7.3-10.js | 65 + .../tests/ecma/LexicalConventions/7.3-11.js | 66 + .../tests/ecma/LexicalConventions/7.3-12.js | 64 + .../tests/ecma/LexicalConventions/7.3-13-n.js | 66 + .../tests/ecma/LexicalConventions/7.3-2.js | 65 + .../tests/ecma/LexicalConventions/7.3-3.js | 65 + .../tests/ecma/LexicalConventions/7.3-4.js | 65 + .../tests/ecma/LexicalConventions/7.3-5.js | 65 + .../tests/ecma/LexicalConventions/7.3-6.js | 65 + .../tests/ecma/LexicalConventions/7.3-7.js | 66 + .../tests/ecma/LexicalConventions/7.3-8.js | 65 + .../tests/ecma/LexicalConventions/7.3-9.js | 65 + .../tests/ecma/LexicalConventions/7.4.1-1-n.js | 71 + .../tests/ecma/LexicalConventions/7.4.1-2-n.js | 71 + .../tests/ecma/LexicalConventions/7.4.1-3-n.js | 69 + .../tests/ecma/LexicalConventions/7.4.2-1-n.js | 77 + .../tests/ecma/LexicalConventions/7.4.2-10-n.js | 77 + .../tests/ecma/LexicalConventions/7.4.2-11-n.js | 77 + .../tests/ecma/LexicalConventions/7.4.2-12-n.js | 77 + .../tests/ecma/LexicalConventions/7.4.2-13-n.js | 77 + .../tests/ecma/LexicalConventions/7.4.2-14-n.js | 77 + .../tests/ecma/LexicalConventions/7.4.2-15-n.js | 77 + .../tests/ecma/LexicalConventions/7.4.2-16-n.js | 77 + .../tests/ecma/LexicalConventions/7.4.2-2-n.js | 77 + .../tests/ecma/LexicalConventions/7.4.2-3-n.js | 77 + .../tests/ecma/LexicalConventions/7.4.2-4-n.js | 77 + .../tests/ecma/LexicalConventions/7.4.2-5-n.js | 77 + .../tests/ecma/LexicalConventions/7.4.2-6-n.js | 77 + .../tests/ecma/LexicalConventions/7.4.2-7-n.js | 75 + .../tests/ecma/LexicalConventions/7.4.2-8-n.js | 76 + .../tests/ecma/LexicalConventions/7.4.2-9-n.js | 77 + .../tests/ecma/LexicalConventions/7.4.3-1-n.js | 71 + .../tests/ecma/LexicalConventions/7.4.3-10-n.js | 71 + .../tests/ecma/LexicalConventions/7.4.3-11-n.js | 71 + .../tests/ecma/LexicalConventions/7.4.3-12-n.js | 71 + .../tests/ecma/LexicalConventions/7.4.3-13-n.js | 71 + .../tests/ecma/LexicalConventions/7.4.3-14-n.js | 97 + .../tests/ecma/LexicalConventions/7.4.3-15-n.js | 97 + .../tests/ecma/LexicalConventions/7.4.3-16-n.js | 88 + .../tests/ecma/LexicalConventions/7.4.3-2-n.js | 71 + .../tests/ecma/LexicalConventions/7.4.3-3-n.js | 71 + .../tests/ecma/LexicalConventions/7.4.3-4-n.js | 96 + .../tests/ecma/LexicalConventions/7.4.3-5-n.js | 71 + .../tests/ecma/LexicalConventions/7.4.3-6-n.js | 71 + .../tests/ecma/LexicalConventions/7.4.3-7-n.js | 97 + .../tests/ecma/LexicalConventions/7.4.3-8-n.js | 71 + .../tests/ecma/LexicalConventions/7.4.3-9-n.js | 98 + .../tests/ecma/LexicalConventions/7.5-1.js | 62 + .../tests/ecma/LexicalConventions/7.5-10-n.js | 64 + .../tests/ecma/LexicalConventions/7.5-2-n.js | 64 + .../tests/ecma/LexicalConventions/7.5-3-n.js | 64 + .../tests/ecma/LexicalConventions/7.5-4-n.js | 64 + .../tests/ecma/LexicalConventions/7.5-5-n.js | 64 + .../tests/ecma/LexicalConventions/7.5-6.js | 61 + .../tests/ecma/LexicalConventions/7.5-7.js | 61 + .../tests/ecma/LexicalConventions/7.5-8-n.js | 64 + .../tests/ecma/LexicalConventions/7.5-9-n.js | 64 + .../tests/ecma/LexicalConventions/7.6.js | 313 + .../tests/ecma/LexicalConventions/7.7.1.js | 64 + .../tests/ecma/LexicalConventions/7.7.2.js | 71 + .../tests/ecma/LexicalConventions/7.7.3-1.js | 198 + .../tests/ecma/LexicalConventions/7.7.3-2.js | 93 + .../tests/ecma/LexicalConventions/7.7.3.js | 331 + .../tests/ecma/LexicalConventions/7.7.4.js | 269 + .../tests/ecma/LexicalConventions/7.8.2-n.js | 63 + .../tests/ecma/LexicalConventions/browser.js | 0 .../tests/ecma/LexicalConventions/shell.js | 1 + .../qml/parserstress/tests/ecma/Math/15.8-2-n.js | 82 + .../qml/parserstress/tests/ecma/Math/15.8-3-n.js | 81 + .../qml/parserstress/tests/ecma/Math/15.8.1.1-1.js | 64 + .../qml/parserstress/tests/ecma/Math/15.8.1.1-2.js | 69 + .../qml/parserstress/tests/ecma/Math/15.8.1.2-1.js | 64 + .../qml/parserstress/tests/ecma/Math/15.8.1.2-2.js | 70 + .../qml/parserstress/tests/ecma/Math/15.8.1.3-1.js | 65 + .../qml/parserstress/tests/ecma/Math/15.8.1.3-2.js | 72 + .../qml/parserstress/tests/ecma/Math/15.8.1.4-1.js | 65 + .../qml/parserstress/tests/ecma/Math/15.8.1.4-2.js | 69 + .../qml/parserstress/tests/ecma/Math/15.8.1.5-1.js | 66 + .../qml/parserstress/tests/ecma/Math/15.8.1.5-2.js | 70 + .../qml/parserstress/tests/ecma/Math/15.8.1.6-1.js | 65 + .../qml/parserstress/tests/ecma/Math/15.8.1.6-2.js | 70 + .../qml/parserstress/tests/ecma/Math/15.8.1.7-1.js | 65 + .../qml/parserstress/tests/ecma/Math/15.8.1.7-2.js | 70 + .../qml/parserstress/tests/ecma/Math/15.8.1.8-1.js | 65 + .../qml/parserstress/tests/ecma/Math/15.8.1.8-2.js | 69 + .../qml/parserstress/tests/ecma/Math/15.8.1.8-3.js | 63 + .../qml/parserstress/tests/ecma/Math/15.8.1.js | 149 + .../qml/parserstress/tests/ecma/Math/15.8.2.1.js | 226 + .../qml/parserstress/tests/ecma/Math/15.8.2.10.js | 153 + .../qml/parserstress/tests/ecma/Math/15.8.2.11.js | 200 + .../qml/parserstress/tests/ecma/Math/15.8.2.12.js | 177 + .../qml/parserstress/tests/ecma/Math/15.8.2.13.js | 385 + .../qml/parserstress/tests/ecma/Math/15.8.2.14.js | 79 + .../qml/parserstress/tests/ecma/Math/15.8.2.15.js | 202 + .../qml/parserstress/tests/ecma/Math/15.8.2.16.js | 132 + .../qml/parserstress/tests/ecma/Math/15.8.2.17.js | 217 + .../qml/parserstress/tests/ecma/Math/15.8.2.18.js | 165 + .../qml/parserstress/tests/ecma/Math/15.8.2.2.js | 151 + .../qml/parserstress/tests/ecma/Math/15.8.2.3.js | 158 + .../qml/parserstress/tests/ecma/Math/15.8.2.4.js | 156 + .../qml/parserstress/tests/ecma/Math/15.8.2.5.js | 244 + .../qml/parserstress/tests/ecma/Math/15.8.2.6.js | 232 + .../qml/parserstress/tests/ecma/Math/15.8.2.7.js | 283 + .../qml/parserstress/tests/ecma/Math/15.8.2.8.js | 134 + .../qml/parserstress/tests/ecma/Math/15.8.2.9.js | 191 + .../qml/parserstress/tests/ecma/Math/browser.js | 0 .../auto/qml/parserstress/tests/ecma/Math/shell.js | 1 + .../tests/ecma/NativeObjects/browser.js | 0 .../parserstress/tests/ecma/NativeObjects/shell.js | 1 + .../qml/parserstress/tests/ecma/Number/15.7.1.js | 88 + .../qml/parserstress/tests/ecma/Number/15.7.2.js | 168 + .../parserstress/tests/ecma/Number/15.7.3.1-1.js | 71 + .../parserstress/tests/ecma/Number/15.7.3.1-2.js | 71 + .../parserstress/tests/ecma/Number/15.7.3.1-3.js | 67 + .../parserstress/tests/ecma/Number/15.7.3.2-1.js | 65 + .../parserstress/tests/ecma/Number/15.7.3.2-2.js | 70 + .../parserstress/tests/ecma/Number/15.7.3.2-3.js | 67 + .../parserstress/tests/ecma/Number/15.7.3.2-4.js | 64 + .../parserstress/tests/ecma/Number/15.7.3.3-1.js | 68 + .../parserstress/tests/ecma/Number/15.7.3.3-2.js | 73 + .../parserstress/tests/ecma/Number/15.7.3.3-3.js | 64 + .../parserstress/tests/ecma/Number/15.7.3.3-4.js | 66 + .../parserstress/tests/ecma/Number/15.7.3.4-1.js | 66 + .../parserstress/tests/ecma/Number/15.7.3.4-2.js | 71 + .../parserstress/tests/ecma/Number/15.7.3.4-3.js | 65 + .../parserstress/tests/ecma/Number/15.7.3.4-4.js | 66 + .../parserstress/tests/ecma/Number/15.7.3.5-1.js | 64 + .../parserstress/tests/ecma/Number/15.7.3.5-2.js | 70 + .../parserstress/tests/ecma/Number/15.7.3.5-3.js | 65 + .../parserstress/tests/ecma/Number/15.7.3.5-4.js | 66 + .../parserstress/tests/ecma/Number/15.7.3.6-1.js | 65 + .../parserstress/tests/ecma/Number/15.7.3.6-2.js | 69 + .../parserstress/tests/ecma/Number/15.7.3.6-3.js | 65 + .../parserstress/tests/ecma/Number/15.7.3.6-4.js | 66 + .../qml/parserstress/tests/ecma/Number/15.7.3.js | 69 + .../qml/parserstress/tests/ecma/Number/15.7.4-1.js | 60 + .../qml/parserstress/tests/ecma/Number/15.7.4.1.js | 62 + .../parserstress/tests/ecma/Number/15.7.4.2-1.js | 111 + .../parserstress/tests/ecma/Number/15.7.4.2-2-n.js | 76 + .../parserstress/tests/ecma/Number/15.7.4.2-3-n.js | 73 + .../parserstress/tests/ecma/Number/15.7.4.2-4.js | 70 + .../parserstress/tests/ecma/Number/15.7.4.3-1.js | 97 + .../parserstress/tests/ecma/Number/15.7.4.3-2.js | 65 + .../parserstress/tests/ecma/Number/15.7.4.3-3-n.js | 72 + .../qml/parserstress/tests/ecma/Number/browser.js | 0 .../qml/parserstress/tests/ecma/Number/shell.js | 1 + .../tests/ecma/ObjectObjects/15.2.1.1.js | 146 + .../tests/ecma/ObjectObjects/15.2.1.2.js | 81 + .../tests/ecma/ObjectObjects/15.2.2.1.js | 138 + .../tests/ecma/ObjectObjects/15.2.2.2.js | 74 + .../tests/ecma/ObjectObjects/15.2.3-1.js | 64 + .../tests/ecma/ObjectObjects/15.2.3.1-1.js | 69 + .../tests/ecma/ObjectObjects/15.2.3.1-2.js | 70 + .../tests/ecma/ObjectObjects/15.2.3.1-3.js | 70 + .../tests/ecma/ObjectObjects/15.2.3.1-4.js | 70 + .../tests/ecma/ObjectObjects/15.2.3.js | 67 + .../tests/ecma/ObjectObjects/15.2.4.1.js | 64 + .../tests/ecma/ObjectObjects/15.2.4.2.js | 130 + .../tests/ecma/ObjectObjects/15.2.4.3.js | 117 + .../tests/ecma/ObjectObjects/browser.js | 0 .../parserstress/tests/ecma/ObjectObjects/shell.js | 1 + tests/auto/qml/parserstress/tests/ecma/README | 1 + .../qml/parserstress/tests/ecma/SourceText/6-1.js | 128 + .../qml/parserstress/tests/ecma/SourceText/6-2.js | 131 + .../parserstress/tests/ecma/SourceText/browser.js | 0 .../parserstress/tests/ecma/SourceText/shell.js | 1 + .../parserstress/tests/ecma/Statements/12.10-1.js | 151 + .../parserstress/tests/ecma/Statements/12.10.js | 61 + .../parserstress/tests/ecma/Statements/12.2-1.js | 74 + .../parserstress/tests/ecma/Statements/12.5-1.js | 102 + .../parserstress/tests/ecma/Statements/12.5-2.js | 99 + .../parserstress/tests/ecma/Statements/12.6.1-1.js | 74 + .../parserstress/tests/ecma/Statements/12.6.2-1.js | 75 + .../parserstress/tests/ecma/Statements/12.6.2-2.js | 76 + .../parserstress/tests/ecma/Statements/12.6.2-3.js | 72 + .../parserstress/tests/ecma/Statements/12.6.2-4.js | 72 + .../parserstress/tests/ecma/Statements/12.6.2-5.js | 73 + .../parserstress/tests/ecma/Statements/12.6.2-6.js | 75 + .../parserstress/tests/ecma/Statements/12.6.2-7.js | 73 + .../parserstress/tests/ecma/Statements/12.6.2-8.js | 71 + .../tests/ecma/Statements/12.6.2-9-n.js | 76 + .../parserstress/tests/ecma/Statements/12.6.3-1.js | 63 + .../tests/ecma/Statements/12.6.3-10.js | 115 + .../tests/ecma/Statements/12.6.3-11.js | 98 + .../tests/ecma/Statements/12.6.3-12.js | 103 + .../tests/ecma/Statements/12.6.3-19.js | 117 + .../parserstress/tests/ecma/Statements/12.6.3-2.js | 63 + .../parserstress/tests/ecma/Statements/12.6.3-3.js | 73 + .../parserstress/tests/ecma/Statements/12.6.3-4.js | 202 + .../tests/ecma/Statements/12.6.3-5-n.js | 110 + .../tests/ecma/Statements/12.6.3-6-n.js | 109 + .../tests/ecma/Statements/12.6.3-7-n.js | 110 + .../tests/ecma/Statements/12.6.3-8-n.js | 110 + .../tests/ecma/Statements/12.6.3-9-n.js | 109 + .../parserstress/tests/ecma/Statements/12.7-1-n.js | 64 + .../parserstress/tests/ecma/Statements/12.8-1-n.js | 67 + .../parserstress/tests/ecma/Statements/12.9-1-n.js | 63 + .../parserstress/tests/ecma/Statements/browser.js | 0 .../parserstress/tests/ecma/Statements/shell.js | 1 + .../qml/parserstress/tests/ecma/String/15.5.1.js | 134 + .../qml/parserstress/tests/ecma/String/15.5.2.js | 110 + .../parserstress/tests/ecma/String/15.5.3.1-1.js | 71 + .../parserstress/tests/ecma/String/15.5.3.1-2.js | 69 + .../parserstress/tests/ecma/String/15.5.3.1-3.js | 66 + .../parserstress/tests/ecma/String/15.5.3.1-4.js | 66 + .../parserstress/tests/ecma/String/15.5.3.2-1.js | 190 + .../parserstress/tests/ecma/String/15.5.3.2-2.js | 77 + .../parserstress/tests/ecma/String/15.5.3.2-3.js | 121 + .../qml/parserstress/tests/ecma/String/15.5.3.js | 66 + .../qml/parserstress/tests/ecma/String/15.5.4.1.js | 63 + .../parserstress/tests/ecma/String/15.5.4.10-1.js | 217 + .../parserstress/tests/ecma/String/15.5.4.11-1.js | 518 ++ .../parserstress/tests/ecma/String/15.5.4.11-2.js | 515 ++ .../parserstress/tests/ecma/String/15.5.4.11-3.js | 514 ++ .../parserstress/tests/ecma/String/15.5.4.11-4.js | 507 ++ .../parserstress/tests/ecma/String/15.5.4.11-5.js | 520 ++ .../parserstress/tests/ecma/String/15.5.4.11-6.js | 516 ++ .../parserstress/tests/ecma/String/15.5.4.12-1.js | 520 ++ .../parserstress/tests/ecma/String/15.5.4.12-2.js | 518 ++ .../parserstress/tests/ecma/String/15.5.4.12-3.js | 559 ++ .../parserstress/tests/ecma/String/15.5.4.12-4.js | 515 ++ .../parserstress/tests/ecma/String/15.5.4.12-5.js | 515 ++ .../parserstress/tests/ecma/String/15.5.4.2-1.js | 72 + .../parserstress/tests/ecma/String/15.5.4.2-2-n.js | 73 + .../parserstress/tests/ecma/String/15.5.4.2-3.js | 83 + .../qml/parserstress/tests/ecma/String/15.5.4.2.js | 87 + .../parserstress/tests/ecma/String/15.5.4.3-1.js | 72 + .../parserstress/tests/ecma/String/15.5.4.3-2.js | 90 + .../parserstress/tests/ecma/String/15.5.4.3-3-n.js | 72 + .../parserstress/tests/ecma/String/15.5.4.4-1.js | 92 + .../parserstress/tests/ecma/String/15.5.4.4-2.js | 136 + .../parserstress/tests/ecma/String/15.5.4.4-3.js | 112 + .../parserstress/tests/ecma/String/15.5.4.4-4.js | 124 + .../parserstress/tests/ecma/String/15.5.4.5-1.js | 87 + .../parserstress/tests/ecma/String/15.5.4.5-2.js | 121 + .../parserstress/tests/ecma/String/15.5.4.5-3.js | 131 + .../parserstress/tests/ecma/String/15.5.4.5-4.js | 75 + .../parserstress/tests/ecma/String/15.5.4.5-5.js | 106 + .../parserstress/tests/ecma/String/15.5.4.6-1.js | 155 + .../parserstress/tests/ecma/String/15.5.4.6-2.js | 259 + .../parserstress/tests/ecma/String/15.5.4.7-1.js | 219 + .../parserstress/tests/ecma/String/15.5.4.7-2.js | 217 + .../parserstress/tests/ecma/String/15.5.4.8-1.js | 232 + .../parserstress/tests/ecma/String/15.5.4.8-2.js | 247 + .../parserstress/tests/ecma/String/15.5.4.8-3.js | 204 + .../parserstress/tests/ecma/String/15.5.4.9-1.js | 202 + .../qml/parserstress/tests/ecma/String/15.5.4.js | 108 + .../qml/parserstress/tests/ecma/String/15.5.5.1.js | 88 + .../qml/parserstress/tests/ecma/String/browser.js | 0 .../qml/parserstress/tests/ecma/String/shell.js | 1 + .../parserstress/tests/ecma/TypeConversion/9.2.js | 138 + .../tests/ecma/TypeConversion/9.3-1.js | 100 + .../tests/ecma/TypeConversion/9.3.1-1.js | 323 + .../tests/ecma/TypeConversion/9.3.1-2.js | 87 + .../tests/ecma/TypeConversion/9.3.1-3.js | 743 ++ .../parserstress/tests/ecma/TypeConversion/9.3.js | 87 + .../tests/ecma/TypeConversion/9.4-1.js | 112 + .../tests/ecma/TypeConversion/9.4-2.js | 112 + .../tests/ecma/TypeConversion/9.5-2.js | 173 + .../parserstress/tests/ecma/TypeConversion/9.6.js | 140 + .../parserstress/tests/ecma/TypeConversion/9.7.js | 160 + .../tests/ecma/TypeConversion/9.8.1.js | 167 + .../tests/ecma/TypeConversion/9.9-1.js | 119 + .../tests/ecma/TypeConversion/browser.js | 0 .../tests/ecma/TypeConversion/shell.js | 1 + .../auto/qml/parserstress/tests/ecma/Types/8.1.js | 75 + .../auto/qml/parserstress/tests/ecma/Types/8.4.js | 130 + .../qml/parserstress/tests/ecma/Types/8.6.2.1-1.js | 78 + .../qml/parserstress/tests/ecma/Types/browser.js | 0 .../qml/parserstress/tests/ecma/Types/shell.js | 1 + tests/auto/qml/parserstress/tests/ecma/browser.js | 62 + .../parserstress/tests/ecma/extensions/10.1.4-9.js | 110 + .../parserstress/tests/ecma/extensions/10.1.6.js | 127 + .../parserstress/tests/ecma/extensions/10.1.8-1.js | 135 + .../parserstress/tests/ecma/extensions/11.6.1-1.js | 145 + .../parserstress/tests/ecma/extensions/11.6.1-2.js | 136 + .../parserstress/tests/ecma/extensions/11.6.1-3.js | 137 + .../parserstress/tests/ecma/extensions/11.6.2-1.js | 124 + .../qml/parserstress/tests/ecma/extensions/15-1.js | 94 + .../qml/parserstress/tests/ecma/extensions/15-2.js | 77 + .../tests/ecma/extensions/15.1.2.1-1.js | 88 + .../parserstress/tests/ecma/extensions/15.2.1.1.js | 82 + .../parserstress/tests/ecma/extensions/15.2.3-1.js | 64 + .../parserstress/tests/ecma/extensions/15.2.4.js | 66 + .../tests/ecma/extensions/15.3.1.1-1.js | 82 + .../tests/ecma/extensions/15.3.1.1-2.js | 82 + .../tests/ecma/extensions/15.3.2.1-1.js | 72 + .../tests/ecma/extensions/15.3.2.1-2.js | 72 + .../tests/ecma/extensions/15.3.3.1-1.js | 67 + .../parserstress/tests/ecma/extensions/15.4.3.js | 63 + .../parserstress/tests/ecma/extensions/15.5.3.js | 66 + .../parserstress/tests/ecma/extensions/15.5.4.2.js | 59 + .../tests/ecma/extensions/15.5.4.4-4.js | 107 + .../tests/ecma/extensions/15.5.4.5-6.js | 94 + .../tests/ecma/extensions/15.5.4.7-3.js | 161 + .../tests/ecma/extensions/15.6.3.1-5.js | 58 + .../parserstress/tests/ecma/extensions/15.6.3.js | 65 + .../parserstress/tests/ecma/extensions/15.6.4-2.js | 66 + .../parserstress/tests/ecma/extensions/15.7.3.js | 69 + .../parserstress/tests/ecma/extensions/15.7.4.js | 90 + .../parserstress/tests/ecma/extensions/15.8-1.js | 84 + .../parserstress/tests/ecma/extensions/15.9.5.js | 76 + .../tests/ecma/extensions/8.6.2.1-1.js | 98 + .../parserstress/tests/ecma/extensions/9.9-1.js | 102 + .../parserstress/tests/ecma/extensions/browser.js | 0 .../parserstress/tests/ecma/extensions/shell.js | 1 + tests/auto/qml/parserstress/tests/ecma/jsref.js | 634 ++ tests/auto/qml/parserstress/tests/ecma/shell.js | 577 ++ tests/auto/qml/parserstress/tests/ecma/template.js | 70 + .../tests/ecma_2/Exceptions/boolean-001.js | 80 + .../tests/ecma_2/Exceptions/boolean-002.js | 84 + .../tests/ecma_2/Exceptions/browser.js | 0 .../tests/ecma_2/Exceptions/date-001.js | 93 + .../tests/ecma_2/Exceptions/date-002.js | 87 + .../tests/ecma_2/Exceptions/date-003.js | 89 + .../tests/ecma_2/Exceptions/date-004.js | 83 + .../tests/ecma_2/Exceptions/exception-001.js | 78 + .../tests/ecma_2/Exceptions/exception-002.js | 78 + .../tests/ecma_2/Exceptions/exception-003.js | 82 + .../tests/ecma_2/Exceptions/exception-004.js | 78 + .../tests/ecma_2/Exceptions/exception-005.js | 78 + .../tests/ecma_2/Exceptions/exception-006.js | 89 + .../tests/ecma_2/Exceptions/exception-007.js | 90 + .../tests/ecma_2/Exceptions/exception-008.js | 77 + .../tests/ecma_2/Exceptions/exception-009.js | 86 + .../tests/ecma_2/Exceptions/exception-010-n.js | 61 + .../tests/ecma_2/Exceptions/exception-011-n.js | 62 + .../tests/ecma_2/Exceptions/expression-001.js | 83 + .../tests/ecma_2/Exceptions/expression-002.js | 93 + .../tests/ecma_2/Exceptions/expression-003.js | 88 + .../tests/ecma_2/Exceptions/expression-004.js | 82 + .../tests/ecma_2/Exceptions/expression-005.js | 74 + .../tests/ecma_2/Exceptions/expression-006.js | 79 + .../tests/ecma_2/Exceptions/expression-007.js | 77 + .../tests/ecma_2/Exceptions/expression-008.js | 74 + .../tests/ecma_2/Exceptions/expression-009.js | 75 + .../tests/ecma_2/Exceptions/expression-010.js | 76 + .../tests/ecma_2/Exceptions/expression-011.js | 76 + .../tests/ecma_2/Exceptions/expression-012.js | 77 + .../tests/ecma_2/Exceptions/expression-013.js | 77 + .../tests/ecma_2/Exceptions/expression-014.js | 79 + .../tests/ecma_2/Exceptions/expression-015.js | 73 + .../tests/ecma_2/Exceptions/expression-016.js | 73 + .../tests/ecma_2/Exceptions/expression-017.js | 73 + .../tests/ecma_2/Exceptions/expression-019.js | 77 + .../tests/ecma_2/Exceptions/function-001.js | 86 + .../tests/ecma_2/Exceptions/global-001.js | 78 + .../tests/ecma_2/Exceptions/global-002.js | 78 + .../tests/ecma_2/Exceptions/lexical-001.js | 85 + .../tests/ecma_2/Exceptions/lexical-002.js | 85 + .../tests/ecma_2/Exceptions/lexical-003.js | 76 + .../tests/ecma_2/Exceptions/lexical-004.js | 85 + .../tests/ecma_2/Exceptions/lexical-005.js | 85 + .../tests/ecma_2/Exceptions/lexical-006.js | 91 + .../tests/ecma_2/Exceptions/lexical-007.js | 84 + .../tests/ecma_2/Exceptions/lexical-008.js | 86 + .../tests/ecma_2/Exceptions/lexical-009.js | 86 + .../tests/ecma_2/Exceptions/lexical-010.js | 84 + .../tests/ecma_2/Exceptions/lexical-011.js | 95 + .../tests/ecma_2/Exceptions/lexical-012.js | 86 + .../tests/ecma_2/Exceptions/lexical-013.js | 86 + .../tests/ecma_2/Exceptions/lexical-014.js | 95 + .../tests/ecma_2/Exceptions/lexical-015.js | 86 + .../tests/ecma_2/Exceptions/lexical-016.js | 95 + .../tests/ecma_2/Exceptions/lexical-017.js | 87 + .../tests/ecma_2/Exceptions/lexical-018.js | 86 + .../tests/ecma_2/Exceptions/lexical-019.js | 86 + .../tests/ecma_2/Exceptions/lexical-020.js | 86 + .../tests/ecma_2/Exceptions/lexical-021.js | 95 + .../tests/ecma_2/Exceptions/lexical-022.js | 86 + .../tests/ecma_2/Exceptions/lexical-023.js | 85 + .../tests/ecma_2/Exceptions/lexical-024.js | 92 + .../tests/ecma_2/Exceptions/lexical-025.js | 92 + .../tests/ecma_2/Exceptions/lexical-026.js | 92 + .../tests/ecma_2/Exceptions/lexical-027.js | 94 + .../tests/ecma_2/Exceptions/lexical-028.js | 92 + .../tests/ecma_2/Exceptions/lexical-029.js | 92 + .../tests/ecma_2/Exceptions/lexical-030.js | 92 + .../tests/ecma_2/Exceptions/lexical-031.js | 92 + .../tests/ecma_2/Exceptions/lexical-032.js | 92 + .../tests/ecma_2/Exceptions/lexical-033.js | 92 + .../tests/ecma_2/Exceptions/lexical-034.js | 91 + .../tests/ecma_2/Exceptions/lexical-035.js | 92 + .../tests/ecma_2/Exceptions/lexical-036.js | 92 + .../tests/ecma_2/Exceptions/lexical-037.js | 92 + .../tests/ecma_2/Exceptions/lexical-038.js | 92 + .../tests/ecma_2/Exceptions/lexical-039.js | 79 + .../tests/ecma_2/Exceptions/lexical-040.js | 79 + .../tests/ecma_2/Exceptions/lexical-041.js | 81 + .../tests/ecma_2/Exceptions/lexical-042.js | 82 + .../tests/ecma_2/Exceptions/lexical-047.js | 83 + .../tests/ecma_2/Exceptions/lexical-048.js | 77 + .../tests/ecma_2/Exceptions/lexical-049.js | 82 + .../tests/ecma_2/Exceptions/lexical-050.js | 78 + .../tests/ecma_2/Exceptions/lexical-051.js | 78 + .../tests/ecma_2/Exceptions/lexical-052.js | 80 + .../tests/ecma_2/Exceptions/lexical-053.js | 78 + .../tests/ecma_2/Exceptions/lexical-054.js | 79 + .../tests/ecma_2/Exceptions/number-001.js | 86 + .../tests/ecma_2/Exceptions/number-002.js | 81 + .../tests/ecma_2/Exceptions/number-003.js | 83 + .../parserstress/tests/ecma_2/Exceptions/shell.js | 1 + .../tests/ecma_2/Exceptions/statement-001.js | 80 + .../tests/ecma_2/Exceptions/statement-002.js | 102 + .../tests/ecma_2/Exceptions/statement-003.js | 113 + .../tests/ecma_2/Exceptions/statement-004.js | 85 + .../tests/ecma_2/Exceptions/statement-005.js | 84 + .../tests/ecma_2/Exceptions/statement-006.js | 84 + .../tests/ecma_2/Exceptions/statement-007.js | 75 + .../tests/ecma_2/Exceptions/statement-008.js | 75 + .../tests/ecma_2/Exceptions/statement-009.js | 74 + .../tests/ecma_2/Exceptions/string-001.js | 86 + .../tests/ecma_2/Exceptions/string-002.js | 85 + .../tests/ecma_2/Expressions/StrictEquality-001.js | 106 + .../tests/ecma_2/Expressions/browser.js | 0 .../parserstress/tests/ecma_2/Expressions/shell.js | 1 + .../tests/ecma_2/FunctionObjects/apply-001-n.js | 65 + .../tests/ecma_2/FunctionObjects/browser.js | 0 .../tests/ecma_2/FunctionObjects/call-1.js | 75 + .../tests/ecma_2/FunctionObjects/shell.js | 1 + .../tests/ecma_2/LexicalConventions/browser.js | 0 .../ecma_2/LexicalConventions/keywords-001.js | 81 + .../LexicalConventions/regexp-literals-001.js | 77 + .../LexicalConventions/regexp-literals-002.js | 61 + .../tests/ecma_2/LexicalConventions/shell.js | 1 + tests/auto/qml/parserstress/tests/ecma_2/README | 1 + .../parserstress/tests/ecma_2/RegExp/browser.js | 0 .../tests/ecma_2/RegExp/constructor-001.js | 99 + .../parserstress/tests/ecma_2/RegExp/exec-001.js | 73 + .../parserstress/tests/ecma_2/RegExp/exec-002.js | 221 + .../tests/ecma_2/RegExp/function-001.js | 99 + .../parserstress/tests/ecma_2/RegExp/hex-001.js | 102 + .../tests/ecma_2/RegExp/multiline-001.js | 101 + .../parserstress/tests/ecma_2/RegExp/octal-001.js | 111 + .../parserstress/tests/ecma_2/RegExp/octal-002.js | 126 + .../parserstress/tests/ecma_2/RegExp/octal-003.js | 120 + .../tests/ecma_2/RegExp/properties-001.js | 124 + .../tests/ecma_2/RegExp/properties-002.js | 162 + .../tests/ecma_2/RegExp/regexp-enumerate-001.js | 121 + .../tests/ecma_2/RegExp/regress-001.js | 78 + .../qml/parserstress/tests/ecma_2/RegExp/shell.js | 1 + .../tests/ecma_2/RegExp/unicode-001.js | 92 + .../tests/ecma_2/Statements/browser.js | 0 .../tests/ecma_2/Statements/dowhile-001.js | 77 + .../tests/ecma_2/Statements/dowhile-002.js | 104 + .../tests/ecma_2/Statements/dowhile-003.js | 96 + .../tests/ecma_2/Statements/dowhile-004.js | 100 + .../tests/ecma_2/Statements/dowhile-005.js | 106 + .../tests/ecma_2/Statements/dowhile-006.js | 122 + .../tests/ecma_2/Statements/dowhile-007.js | 130 + .../tests/ecma_2/Statements/forin-001.js | 330 + .../tests/ecma_2/Statements/forin-002.js | 109 + .../parserstress/tests/ecma_2/Statements/if-001.js | 75 + .../tests/ecma_2/Statements/label-001.js | 75 + .../tests/ecma_2/Statements/label-002.js | 89 + .../parserstress/tests/ecma_2/Statements/shell.js | 1 + .../tests/ecma_2/Statements/switch-001.js | 98 + .../tests/ecma_2/Statements/switch-002.js | 96 + .../tests/ecma_2/Statements/switch-003.js | 90 + .../tests/ecma_2/Statements/switch-004.js | 127 + .../tests/ecma_2/Statements/try-001.js | 118 + .../tests/ecma_2/Statements/try-003.js | 115 + .../tests/ecma_2/Statements/try-004.js | 87 + .../tests/ecma_2/Statements/try-005.js | 90 + .../tests/ecma_2/Statements/try-006.js | 120 + .../tests/ecma_2/Statements/try-007.js | 125 + .../tests/ecma_2/Statements/try-008.js | 92 + .../tests/ecma_2/Statements/try-009.js | 99 + .../tests/ecma_2/Statements/try-010.js | 106 + .../tests/ecma_2/Statements/try-012.js | 128 + .../tests/ecma_2/Statements/while-001.js | 75 + .../tests/ecma_2/Statements/while-002.js | 119 + .../tests/ecma_2/Statements/while-003.js | 120 + .../tests/ecma_2/Statements/while-004.js | 250 + .../parserstress/tests/ecma_2/String/browser.js | 0 .../parserstress/tests/ecma_2/String/match-001.js | 139 + .../parserstress/tests/ecma_2/String/match-002.js | 207 + .../parserstress/tests/ecma_2/String/match-003.js | 165 + .../parserstress/tests/ecma_2/String/match-004.js | 206 + .../tests/ecma_2/String/replace-001.js | 99 + .../qml/parserstress/tests/ecma_2/String/shell.js | 1 + .../parserstress/tests/ecma_2/String/split-001.js | 145 + .../parserstress/tests/ecma_2/String/split-002.js | 303 + .../parserstress/tests/ecma_2/String/split-003.js | 156 + .../auto/qml/parserstress/tests/ecma_2/browser.js | 37 + .../tests/ecma_2/extensions/browser.js | 0 .../tests/ecma_2/extensions/constructor-001.js | 74 + .../tests/ecma_2/extensions/function-001.js | 74 + .../tests/ecma_2/extensions/instanceof-001.js | 144 + .../tests/ecma_2/extensions/instanceof-002.js | 160 + .../tests/ecma_2/extensions/instanceof-003-n.js | 121 + .../tests/ecma_2/extensions/instanceof-004-n.js | 121 + .../tests/ecma_2/extensions/instanceof-005-n.js | 122 + .../tests/ecma_2/extensions/instanceof-006.js | 119 + .../parserstress/tests/ecma_2/extensions/shell.js | 1 + .../tests/ecma_2/instanceof/browser.js | 0 .../tests/ecma_2/instanceof/instanceof-001.js | 67 + .../tests/ecma_2/instanceof/instanceof-002.js | 84 + .../tests/ecma_2/instanceof/instanceof-003.js | 98 + .../tests/ecma_2/instanceof/regress-7635.js | 88 + .../parserstress/tests/ecma_2/instanceof/shell.js | 1 + tests/auto/qml/parserstress/tests/ecma_2/jsref.js | 591 ++ tests/auto/qml/parserstress/tests/ecma_2/shell.js | 51 + .../auto/qml/parserstress/tests/ecma_2/template.js | 57 + .../tests/ecma_3/Array/15.4.4.11-01.js | 61 + .../parserstress/tests/ecma_3/Array/15.4.4.3-1.js | 88 + .../tests/ecma_3/Array/15.4.4.4-001.js | 153 + .../parserstress/tests/ecma_3/Array/15.4.5.1-01.js | 93 + .../qml/parserstress/tests/ecma_3/Array/browser.js | 0 .../tests/ecma_3/Array/regress-101488.js | 172 + .../tests/ecma_3/Array/regress-130451.js | 219 + .../tests/ecma_3/Array/regress-322135-01.js | 73 + .../tests/ecma_3/Array/regress-322135-02.js | 65 + .../tests/ecma_3/Array/regress-322135-03.js | 73 + .../tests/ecma_3/Array/regress-322135-04.js | 71 + .../tests/ecma_3/Array/regress-387501.js | 94 + .../tests/ecma_3/Array/regress-421325.js | 67 + .../tests/ecma_3/Array/regress-430717.js | 65 + .../qml/parserstress/tests/ecma_3/Array/shell.js | 1 + .../parserstress/tests/ecma_3/Date/15.9.1.2-01.js | 62 + .../parserstress/tests/ecma_3/Date/15.9.3.2-1.js | 91 + .../qml/parserstress/tests/ecma_3/Date/15.9.4.3.js | 233 + .../qml/parserstress/tests/ecma_3/Date/15.9.5.3.js | 152 + .../qml/parserstress/tests/ecma_3/Date/15.9.5.4.js | 185 + .../parserstress/tests/ecma_3/Date/15.9.5.5-02.js | 88 + .../qml/parserstress/tests/ecma_3/Date/15.9.5.5.js | 144 + .../qml/parserstress/tests/ecma_3/Date/15.9.5.6.js | 153 + .../qml/parserstress/tests/ecma_3/Date/15.9.5.7.js | 142 + .../qml/parserstress/tests/ecma_3/Date/browser.js | 37 + .../qml/parserstress/tests/ecma_3/Date/shell.js | 564 ++ .../tests/ecma_3/Exceptions/15.11.1.1.js | 137 + .../tests/ecma_3/Exceptions/15.11.4.4-1.js | 174 + .../tests/ecma_3/Exceptions/15.11.7.6-001.js | 130 + .../tests/ecma_3/Exceptions/15.11.7.6-002.js | 132 + .../tests/ecma_3/Exceptions/15.11.7.6-003.js | 132 + .../tests/ecma_3/Exceptions/binding-001.js | 128 + .../tests/ecma_3/Exceptions/browser.js | 0 .../tests/ecma_3/Exceptions/regress-181654.js | 155 + .../tests/ecma_3/Exceptions/regress-181914.js | 194 + .../tests/ecma_3/Exceptions/regress-58946.js | 71 + .../tests/ecma_3/Exceptions/regress-95101.js | 118 + .../parserstress/tests/ecma_3/Exceptions/shell.js | 1 + .../tests/ecma_3/ExecutionContexts/10.1.3-1.js | 201 + .../tests/ecma_3/ExecutionContexts/10.1.3-2.js | 70 + .../tests/ecma_3/ExecutionContexts/10.1.3.js | 73 + .../tests/ecma_3/ExecutionContexts/10.1.4-1.js | 85 + .../tests/ecma_3/ExecutionContexts/10.6.1-01.js | 136 + .../tests/ecma_3/ExecutionContexts/browser.js | 0 .../ecma_3/ExecutionContexts/regress-23346.js | 71 + .../ecma_3/ExecutionContexts/regress-448595-01.js | 91 + .../tests/ecma_3/ExecutionContexts/shell.js | 1 + .../tests/ecma_3/Expressions/11.10-01.js | 76 + .../tests/ecma_3/Expressions/11.10-02.js | 76 + .../tests/ecma_3/Expressions/11.10-03.js | 76 + .../tests/ecma_3/Expressions/11.6.1-1.js | 176 + .../tests/ecma_3/Expressions/11.7.1-01.js | 76 + .../tests/ecma_3/Expressions/11.7.2-01.js | 76 + .../tests/ecma_3/Expressions/11.7.3-01.js | 76 + .../tests/ecma_3/Expressions/11.9.6-1.js | 213 + .../tests/ecma_3/Expressions/browser.js | 0 .../parserstress/tests/ecma_3/Expressions/shell.js | 1 + .../parserstress/tests/ecma_3/FunExpr/browser.js | 0 .../parserstress/tests/ecma_3/FunExpr/fe-001-n.js | 58 + .../parserstress/tests/ecma_3/FunExpr/fe-001.js | 57 + .../parserstress/tests/ecma_3/FunExpr/fe-002.js | 61 + .../qml/parserstress/tests/ecma_3/FunExpr/shell.js | 1 + .../tests/ecma_3/Function/15.3.4.3-1.js | 210 + .../tests/ecma_3/Function/15.3.4.4-1.js | 185 + .../tests/ecma_3/Function/arguments-001.js | 169 + .../tests/ecma_3/Function/arguments-002.js | 73 + .../parserstress/tests/ecma_3/Function/browser.js | 0 .../parserstress/tests/ecma_3/Function/call-001.js | 153 + .../tests/ecma_3/Function/regress-131964.js | 196 + .../tests/ecma_3/Function/regress-137181.js | 113 + .../tests/ecma_3/Function/regress-193555.js | 136 + .../tests/ecma_3/Function/regress-313570.js | 63 + .../tests/ecma_3/Function/regress-49286.js | 137 + .../tests/ecma_3/Function/regress-58274.js | 226 + .../tests/ecma_3/Function/regress-85880.js | 173 + .../tests/ecma_3/Function/regress-94506.js | 163 + .../tests/ecma_3/Function/regress-97921.js | 152 + .../tests/ecma_3/Function/scope-001.js | 265 + .../tests/ecma_3/Function/scope-002.js | 245 + .../parserstress/tests/ecma_3/Function/shell.js | 1 + .../tests/ecma_3/LexicalConventions/7.9.1.js | 157 + .../tests/ecma_3/LexicalConventions/browser.js | 0 .../tests/ecma_3/LexicalConventions/shell.js | 1 + .../tests/ecma_3/Number/15.7.4.2-01.js | 77 + .../tests/ecma_3/Number/15.7.4.3-01.js | 69 + .../tests/ecma_3/Number/15.7.4.3-02.js | 53 + .../parserstress/tests/ecma_3/Number/15.7.4.5-1.js | 145 + .../parserstress/tests/ecma_3/Number/15.7.4.6-1.js | 134 + .../parserstress/tests/ecma_3/Number/15.7.4.7-1.js | 139 + .../parserstress/tests/ecma_3/Number/15.7.4.7-2.js | 72 + .../parserstress/tests/ecma_3/Number/browser.js | 0 .../tests/ecma_3/Number/regress-442242-01.js | 62 + .../qml/parserstress/tests/ecma_3/Number/shell.js | 1 + .../tests/ecma_3/NumberFormatting/browser.js | 0 .../tests/ecma_3/NumberFormatting/shell.js | 1 + .../tests/ecma_3/NumberFormatting/tostring-001.js | 60 + .../parserstress/tests/ecma_3/Object/8.6.1-01.js | 113 + .../tests/ecma_3/Object/8.6.2.6-001.js | 113 + .../parserstress/tests/ecma_3/Object/browser.js | 7 + .../parserstress/tests/ecma_3/Object/class-001.js | 156 + .../parserstress/tests/ecma_3/Object/class-002.js | 146 + .../parserstress/tests/ecma_3/Object/class-003.js | 139 + .../parserstress/tests/ecma_3/Object/class-004.js | 139 + .../parserstress/tests/ecma_3/Object/class-005.js | 124 + .../tests/ecma_3/Object/regress-361274.js | 66 + .../tests/ecma_3/Object/regress-385393-07.js | 67 + .../tests/ecma_3/Object/regress-72773.js | 97 + .../tests/ecma_3/Object/regress-79129-001.js | 80 + .../qml/parserstress/tests/ecma_3/Object/shell.js | 105 + .../tests/ecma_3/Operators/11.13.1-001.js | 152 + .../tests/ecma_3/Operators/11.13.1-002.js | 57 + .../tests/ecma_3/Operators/11.4.1-001.js | 120 + .../tests/ecma_3/Operators/11.4.1-002.js | 72 + .../parserstress/tests/ecma_3/Operators/browser.js | 0 .../tests/ecma_3/Operators/order-01.js | 108 + .../parserstress/tests/ecma_3/Operators/shell.js | 1 + tests/auto/qml/parserstress/tests/ecma_3/README | 1 + .../parserstress/tests/ecma_3/RegExp/15.10.2-1.js | 181 + .../parserstress/tests/ecma_3/RegExp/15.10.2.12.js | 63 + .../tests/ecma_3/RegExp/15.10.3.1-1.js | 136 + .../tests/ecma_3/RegExp/15.10.3.1-2.js | 144 + .../tests/ecma_3/RegExp/15.10.4.1-1.js | 127 + .../tests/ecma_3/RegExp/15.10.4.1-2.js | 133 + .../tests/ecma_3/RegExp/15.10.4.1-3.js | 139 + .../tests/ecma_3/RegExp/15.10.4.1-4.js | 146 + .../tests/ecma_3/RegExp/15.10.4.1-5-n.js | 139 + .../tests/ecma_3/RegExp/15.10.6.2-1.js | 140 + .../tests/ecma_3/RegExp/15.10.6.2-2.js | 367 + .../parserstress/tests/ecma_3/RegExp/browser.js | 0 .../parserstress/tests/ecma_3/RegExp/octal-001.js | 136 + .../parserstress/tests/ecma_3/RegExp/octal-002.js | 218 + .../tests/ecma_3/RegExp/perlstress-001.js | 3230 +++++++ .../tests/ecma_3/RegExp/perlstress-002.js | 1842 ++++ .../tests/ecma_3/RegExp/regress-100199.js | 307 + .../tests/ecma_3/RegExp/regress-105972.js | 157 + .../tests/ecma_3/RegExp/regress-119909.js | 92 + .../tests/ecma_3/RegExp/regress-122076.js | 110 + .../tests/ecma_3/RegExp/regress-123437.js | 112 + .../tests/ecma_3/RegExp/regress-165353.js | 122 + .../tests/ecma_3/RegExp/regress-169497.js | 105 + .../tests/ecma_3/RegExp/regress-169534.js | 95 + .../tests/ecma_3/RegExp/regress-187133.js | 142 + .../tests/ecma_3/RegExp/regress-188206.js | 219 + .../tests/ecma_3/RegExp/regress-191479.js | 198 + .../tests/ecma_3/RegExp/regress-202564.js | 101 + .../tests/ecma_3/RegExp/regress-209067.js | 1106 +++ .../tests/ecma_3/RegExp/regress-209919.js | 174 + .../tests/ecma_3/RegExp/regress-216591.js | 117 + .../tests/ecma_3/RegExp/regress-220367-001.js | 104 + .../tests/ecma_3/RegExp/regress-223273.js | 279 + .../tests/ecma_3/RegExp/regress-223535.js | 133 + .../tests/ecma_3/RegExp/regress-224676.js | 232 + .../tests/ecma_3/RegExp/regress-225289.js | 176 + .../tests/ecma_3/RegExp/regress-225343.js | 125 + .../tests/ecma_3/RegExp/regress-24712.js | 59 + .../tests/ecma_3/RegExp/regress-285219.js | 51 + .../tests/ecma_3/RegExp/regress-28686.js | 57 + .../tests/ecma_3/RegExp/regress-289669.js | 88 + .../tests/ecma_3/RegExp/regress-307456.js | 54 + .../tests/ecma_3/RegExp/regress-309840.js | 58 + .../tests/ecma_3/RegExp/regress-311414.js | 101 + .../tests/ecma_3/RegExp/regress-312351.js | 50 + .../tests/ecma_3/RegExp/regress-31316.js | 96 + .../tests/ecma_3/RegExp/regress-330684.js | 53 + .../tests/ecma_3/RegExp/regress-334158.js | 58 + .../tests/ecma_3/RegExp/regress-346090.js | 63 + .../tests/ecma_3/RegExp/regress-367888.js | 62 + .../tests/ecma_3/RegExp/regress-375642.js | 61 + .../tests/ecma_3/RegExp/regress-375711.js | 118 + .../tests/ecma_3/RegExp/regress-375715-01-n.js | 63 + .../tests/ecma_3/RegExp/regress-375715-02.js | 60 + .../tests/ecma_3/RegExp/regress-375715-03.js | 60 + .../tests/ecma_3/RegExp/regress-375715-04.js | 68 + .../tests/ecma_3/RegExp/regress-57572.js | 150 + .../tests/ecma_3/RegExp/regress-57631.js | 152 + .../tests/ecma_3/RegExp/regress-67773.js | 211 + .../tests/ecma_3/RegExp/regress-72964.js | 121 + .../tests/ecma_3/RegExp/regress-76683.js | 114 + .../tests/ecma_3/RegExp/regress-78156.js | 123 + .../tests/ecma_3/RegExp/regress-85721.js | 276 + .../tests/ecma_3/RegExp/regress-87231.js | 145 + .../tests/ecma_3/RegExp/regress-98306.js | 99 + .../qml/parserstress/tests/ecma_3/RegExp/shell.js | 266 + .../parserstress/tests/ecma_3/Regress/browser.js | 0 .../tests/ecma_3/Regress/regress-385393-04.js | 66 + .../tests/ecma_3/Regress/regress-419152.js | 90 + .../tests/ecma_3/Regress/regress-420087.js | 64 + .../tests/ecma_3/Regress/regress-420610.js | 50 + .../tests/ecma_3/Regress/regress-441477-01.js | 73 + .../qml/parserstress/tests/ecma_3/Regress/shell.js | 1 + .../parserstress/tests/ecma_3/Statements/12.6.3.js | 80 + .../tests/ecma_3/Statements/browser.js | 0 .../tests/ecma_3/Statements/regress-121744.js | 217 + .../tests/ecma_3/Statements/regress-131348.js | 184 + .../tests/ecma_3/Statements/regress-157509.js | 111 + .../tests/ecma_3/Statements/regress-194364.js | 152 + .../tests/ecma_3/Statements/regress-226517.js | 112 + .../tests/ecma_3/Statements/regress-302439.js | 1368 +++ .../tests/ecma_3/Statements/regress-324650.js | 5461 ++++++++++++ .../tests/ecma_3/Statements/regress-74474-001.js | 139 + .../tests/ecma_3/Statements/regress-74474-002.js | 9097 +++++++++++++++++++ .../tests/ecma_3/Statements/regress-74474-003.js | 9099 ++++++++++++++++++++ .../tests/ecma_3/Statements/regress-83532-001.js | 71 + .../tests/ecma_3/Statements/regress-83532-002.js | 74 + .../parserstress/tests/ecma_3/Statements/shell.js | 1 + .../tests/ecma_3/Statements/switch-001.js | 143 + .../parserstress/tests/ecma_3/String/15.5.4.11.js | 532 ++ .../parserstress/tests/ecma_3/String/15.5.4.14.js | 50 + .../parserstress/tests/ecma_3/String/browser.js | 0 .../tests/ecma_3/String/regress-104375.js | 116 + .../tests/ecma_3/String/regress-189898.js | 157 + .../tests/ecma_3/String/regress-304376.js | 68 + .../tests/ecma_3/String/regress-313567.js | 56 + .../tests/ecma_3/String/regress-392378.js | 77 + .../tests/ecma_3/String/regress-83293.js | 216 + .../qml/parserstress/tests/ecma_3/String/shell.js | 1 + .../parserstress/tests/ecma_3/Unicode/browser.js | 0 .../tests/ecma_3/Unicode/regress-352044-01.js | 72 + .../tests/ecma_3/Unicode/regress-352044-02-n.js | 72 + .../qml/parserstress/tests/ecma_3/Unicode/shell.js | 1 + .../parserstress/tests/ecma_3/Unicode/uc-001-n.js | 62 + .../parserstress/tests/ecma_3/Unicode/uc-001.js | 56 + .../parserstress/tests/ecma_3/Unicode/uc-002-n.js | 55 + .../parserstress/tests/ecma_3/Unicode/uc-002.js | 60 + .../parserstress/tests/ecma_3/Unicode/uc-003.js | 71 + .../parserstress/tests/ecma_3/Unicode/uc-004.js | 65 + .../parserstress/tests/ecma_3/Unicode/uc-005.js | 276 + .../auto/qml/parserstress/tests/ecma_3/browser.js | 36 + .../tests/ecma_3/extensions/10.1.3-2.js | 162 + .../parserstress/tests/ecma_3/extensions/7.9.1.js | 83 + .../tests/ecma_3/extensions/browser.js | 0 .../tests/ecma_3/extensions/regress-103087.js | 178 + .../tests/ecma_3/extensions/regress-188206-01.js | 108 + .../tests/ecma_3/extensions/regress-188206-02.js | 158 + .../tests/ecma_3/extensions/regress-220367-002.js | 112 + .../tests/ecma_3/extensions/regress-228087.js | 352 + .../tests/ecma_3/extensions/regress-274152.js | 83 + .../tests/ecma_3/extensions/regress-320854.js | 53 + .../tests/ecma_3/extensions/regress-327170.js | 58 + .../tests/ecma_3/extensions/regress-368516.js | 78 + .../tests/ecma_3/extensions/regress-385393-03.js | 63 + .../tests/ecma_3/extensions/regress-429248.js | 67 + .../tests/ecma_3/extensions/regress-430740.js | 72 + .../parserstress/tests/ecma_3/extensions/shell.js | 266 + tests/auto/qml/parserstress/tests/ecma_3/shell.js | 40 + .../auto/qml/parserstress/tests/ecma_3/template.js | 59 + tests/auto/qml/parserstress/tests/shell.js | 886 ++ tests/auto/qml/parserstress/tst_parserstress.cpp | 154 + tests/auto/qml/qjsengine/qjsengine.pro | 13 + tests/auto/qml/qjsengine/script/com/__init__.js | 9 + .../qml/qjsengine/script/com/trolltech/__init__.js | 9 + .../script/com/trolltech/recursive/__init__.js | 1 + .../script/com/trolltech/syntaxerror/__init__.js | 5 + tests/auto/qml/qjsengine/tst_qjsengine.cpp | 6353 ++++++++++++++ tests/auto/qml/qjsvalue/qjsvalue.pro | 6 + tests/auto/qml/qjsvalue/tst_qjsvalue.cpp | 3655 ++++++++ tests/auto/qml/qjsvalue/tst_qjsvalue.h | 204 + .../auto/qml/qjsvalueiterator/qjsvalueiterator.pro | 7 + .../qml/qjsvalueiterator/tst_qjsvalueiterator.cpp | 522 ++ tests/auto/qml/qml.pro | 55 + tests/auto/qml/qmlmin/qmlmin.pro | 9 + tests/auto/qml/qmlmin/tst_qmlmin.cpp | 192 + tests/auto/qml/qmlplugindump/qmlplugindump.pro | 7 + tests/auto/qml/qmlplugindump/tst_qmlplugindump.cpp | 117 + tests/auto/qml/qqmlcomponent/data/createObject.qml | 13 + .../qqmlcomponent/data/createObjectWithScript.qml | 43 + .../auto/qml/qqmlcomponent/data/incubateObject.qml | 36 + tests/auto/qml/qqmlcomponent/qqmlcomponent.pro | 15 + tests/auto/qml/qqmlcomponent/tst_qqmlcomponent.cpp | 186 + tests/auto/qml/qqmlconsole/data/assert.qml | 62 + tests/auto/qml/qqmlconsole/data/exception.qml | 58 + tests/auto/qml/qqmlconsole/data/logging.qml | 90 + tests/auto/qml/qqmlconsole/data/profiling.qml | 51 + tests/auto/qml/qqmlconsole/data/tracing.qml | 56 + tests/auto/qml/qqmlconsole/qqmlconsole.pro | 15 + tests/auto/qml/qqmlconsole/tst_qqmlconsole.cpp | 170 + tests/auto/qml/qqmlcontext/data/Object_22535.qml | 8 + .../qqmlcontext/data/RefreshExpressionsType.qml | 5 + tests/auto/qml/qqmlcontext/data/qtbug_22535.qml | 10 + .../qml/qqmlcontext/data/refreshExpressions.qml | 6 + .../data/refreshExpressionsRootContext.qml | 6 + tests/auto/qml/qqmlcontext/qqmlcontext.pro | 15 + tests/auto/qml/qqmlcontext/tst_qqmlcontext.cpp | 652 ++ tests/auto/qml/qqmlcpputils/qqmlcpputils.pro | 9 + tests/auto/qml/qqmlcpputils/tst_qqmlcpputils.cpp | 106 + .../data/AliasBindingsAssignCorrectlyType.qml | 9 + .../data/AliasBindingsOverrideTargetType.qml | 14 + .../data/AliasBindingsOverrideTargetType3.qml | 9 + .../data/AliasToCompositeElementType1.qml | 6 + .../data/AliasToCompositeElementType2.qml | 5 + .../data/ConstantsOverrideBindings.qml | 12 + .../auto/qml/qqmlecmascript/data/CustomObject.qml | 5 + .../qml/qqmlecmascript/data/ElementAssignType.qml | 5 + .../auto/qml/qqmlecmascript/data/MethodsObject.qml | 6 + .../data/NestedTypeTransientErrors.qml | 11 + .../qqmlecmascript/data/PropertyVarBaseItem.qml | 5 + .../data/PropertyVarCircularComponent.qml | 23 + .../data/PropertyVarCircularComponent2.qml | 26 + .../data/PropertyVarCircularComponent3.qml | 16 + .../data/PropertyVarCircularComponent4.qml | 28 + .../data/PropertyVarCircularComponent5.qml | 7 + .../data/PropertyVarInheritanceComponent.qml | 22 + .../data/PropertyVarOwnershipComponent.qml | 37 + .../data/ScarceResourceSignalComponentVar.qml | 9 + .../data/ScarceResourceSignalComponentVariant.qml | 9 + .../data/ScarceResourceVarComponent.qml | 13 + .../auto/qml/qqmlecmascript/data/Scope6Nested.qml | 7 + tests/auto/qml/qqmlecmascript/data/ScopeObject.qml | 12 + .../data/SequenceConversionComponent.qml | 7 + .../qml/qqmlecmascript/data/SpuriousWarning.qml | 5 + .../qqmlecmascript/data/TypeForDynamicCreation.qml | 2 + .../data/aliasBindingsAssignCorrectly.qml | 59 + .../data/aliasBindingsOverrideTarget.2.qml | 29 + .../data/aliasBindingsOverrideTarget.3.qml | 24 + .../data/aliasBindingsOverrideTarget.qml | 28 + .../data/aliasPropertyAndBinding.qml | 14 + .../data/aliasToCompositeElement.qml | 6 + .../data/aliasWritesOverrideBindings.2.qml | 29 + .../data/aliasWritesOverrideBindings.3.qml | 23 + .../data/aliasWritesOverrideBindings.qml | 23 + .../data/aliasreset/AliasPropertyComponent.qml | 17 + .../data/aliasreset/aliasPropertyReset.1.qml | 23 + .../data/aliasreset/aliasPropertyReset.2.qml | 23 + .../data/aliasreset/aliasPropertyReset.3.qml | 31 + .../data/aliasreset/aliasPropertyReset.4.qml | 26 + .../data/aliasreset/aliasPropertyReset.5.qml | 14 + .../data/aliasreset/aliasPropertyReset.error.1.qml | 18 + .../qml/qqmlecmascript/data/assignBasicTypes.2.qml | 26 + .../qml/qqmlecmascript/data/assignBasicTypes.qml | 29 + .../qqmlecmascript/data/assignSequenceTypes.1.qml | 11 + .../qqmlecmascript/data/assignSequenceTypes.2.qml | 11 + .../qqmlecmascript/data/assignSequenceTypes.3.qml | 9 + .../qqmlecmascript/data/assignSequenceTypes.4.qml | 13 + .../qqmlecmascript/data/assignSequenceTypes.5.qml | 13 + .../qqmlecmascript/data/assignSequenceTypes.6.qml | 11 + .../qqmlecmascript/data/assignSequenceTypes.7.qml | 42 + .../qml/qqmlecmascript/data/attachedProperty.2.qml | 22 + .../qml/qqmlecmascript/data/attachedProperty.qml | 11 + .../qqmlecmascript/data/attachedPropertyScope.qml | 9 + .../qml/qqmlecmascript/data/automaticSemicolon.qml | 11 + tests/auto/qml/qqmlecmascript/data/bindingLoop.qml | 14 + tests/auto/qml/qqmlecmascript/data/blank.js | 0 .../data/boolPropertiesEvaluateAsBool.1.qml | 5 + .../data/boolPropertiesEvaluateAsBool.2.qml | 5 + .../qml/qqmlecmascript/data/booleanConversion.qml | 28 + tests/auto/qml/qqmlecmascript/data/bug.1.qml | 10 + .../data/canAssignNullToQObject.1.qml | 9 + .../data/canAssignNullToQObject.2.qml | 11 + .../changeslots/propertyChangeSlotErrors.1.qml | 12 + .../changeslots/propertyChangeSlotErrors.2.qml | 12 + .../changeslots/propertyChangeSlotErrors.3.qml | 12 + .../changeslots/propertyChangeSlotErrors.4.qml | 12 + .../data/changeslots/propertyChangeSlots.qml | 27 + tests/auto/qml/qqmlecmascript/data/compiled.qml | 48 + .../qqmlecmascript/data/compositePropertyType.qml | 8 + .../data/constantsOverrideBindings.1.qml | 8 + .../data/constantsOverrideBindings.2.qml | 11 + .../data/constantsOverrideBindings.3.qml | 7 + .../data/constantsOverrideBindings.4.qml | 11 + .../qml/qqmlecmascript/data/deferredProperties.qml | 10 + .../data/deferredPropertiesErrors.qml | 10 + tests/auto/qml/qqmlecmascript/data/deleteLater.qml | 14 + .../data/deleteWhileBindingRunning.qml | 5 + .../auto/qml/qqmlecmascript/data/deletedEngine.qml | 11 + .../auto/qml/qqmlecmascript/data/deletedObject.qml | 25 + .../qml/qqmlecmascript/data/doubleEvaluate.qml | 6 + .../qqmlecmascript/data/dynamicCreation.helper.qml | 6 + .../qml/qqmlecmascript/data/dynamicCreation.qml | 27 + .../data/dynamicCreationOwnership.qml | 20 + .../qml/qqmlecmascript/data/dynamicDeletion.2.qml | 21 + .../qml/qqmlecmascript/data/dynamicDeletion.qml | 20 + .../auto/qml/qqmlecmascript/data/dynamicString.qml | 16 + .../auto/qml/qqmlecmascript/data/elementAssign.qml | 10 + tests/auto/qml/qqmlecmascript/data/enums.1.qml | 20 + tests/auto/qml/qqmlecmascript/data/enums.2.qml | 8 + tests/auto/qml/qqmlecmascript/data/eval.qml | 27 + tests/auto/qml/qqmlecmascript/data/exception.js | 1 + .../data/exceptionClearsOnReeval.qml | 6 + .../data/exceptionProducesWarning.qml | 8 + .../data/exceptionProducesWarning2.qml | 7 + .../data/extendedObjectPropertyLookup.qml | 8 + .../data/extendedObjectPropertyLookup2.qml | 14 + .../qml/qqmlecmascript/data/extensionObjects.qml | 19 + .../data/extensionObjectsPropertyOverride.qml | 7 + tests/auto/qml/qqmlecmascript/data/forInLoop.qml | 13 + tests/auto/qml/qqmlecmascript/data/function.qml | 23 + .../qqmlecmascript/data/functionAssignment.1.qml | 5 + .../qqmlecmascript/data/functionAssignment.2.qml | 73 + .../qml/qqmlecmascript/data/functionAssignment.js | 17 + .../qml/qqmlecmascript/data/functionErrors.qml | 10 + .../data/handleReferenceManagement.handle.1.qml | 21 + .../data/handleReferenceManagement.handle.2.qml | 22 + .../data/handleReferenceManagement.object.1.qml | 27 + .../data/handleReferenceManagement.object.2.qml | 28 + .../data/idShortcutInvalidates.1.qml | 13 + .../qqmlecmascript/data/idShortcutInvalidates.qml | 12 + .../auto/qml/qqmlecmascript/data/importScope.1.js | 1 + .../auto/qml/qqmlecmascript/data/importScope.2.js | 3 + tests/auto/qml/qqmlecmascript/data/importScope.qml | 7 + tests/auto/qml/qqmlecmascript/data/in.qml | 7 + tests/auto/qml/qqmlecmascript/data/include.js | 8 + tests/auto/qml/qqmlecmascript/data/include.qml | 23 + .../qml/qqmlecmascript/data/include_callback.js | 11 + .../qml/qqmlecmascript/data/include_callback.qml | 15 + .../qml/qqmlecmascript/data/include_pragma.qml | 11 + .../qqmlecmascript/data/include_pragma_inner.js | 5 + .../qqmlecmascript/data/include_pragma_outer.js | 6 + .../auto/qml/qqmlecmascript/data/include_remote.js | 26 + .../qml/qqmlecmascript/data/include_remote.qml | 21 + .../qqmlecmascript/data/include_remote_missing.js | 13 + .../qqmlecmascript/data/include_remote_missing.qml | 12 + .../auto/qml/qqmlecmascript/data/include_shared.js | 12 + .../qml/qqmlecmascript/data/include_shared.qml | 22 + .../qml/qqmlecmascript/data/invokableObjectArg.qml | 9 + .../qml/qqmlecmascript/data/invokableObjectRet.qml | 11 + tests/auto/qml/qqmlecmascript/data/js/include2.js | 4 + tests/auto/qml/qqmlecmascript/data/js/include3.js | 3 + tests/auto/qml/qqmlecmascript/data/jsObject.qml | 12 + .../data/jsimport/SpecialRectangleOne.qml | 9 + .../data/jsimport/SpecialRectangleTwo.qml | 9 + .../qml/qqmlecmascript/data/jsimport/importFive.js | 3 + .../qml/qqmlecmascript/data/jsimport/importFour.js | 9 + .../qml/qqmlecmascript/data/jsimport/importOne.js | 13 + .../data/jsimport/importPragmaLibrary.js | 9 + .../jsimport/importPragmaLibraryWithImports.js | 9 + .../importPragmaLibraryWithPragmaLibraryImports.js | 11 + .../qqmlecmascript/data/jsimport/importThree.js | 9 + .../qml/qqmlecmascript/data/jsimport/importTwo.js | 10 + .../data/jsimport/importWithNoImports.js | 11 + .../qqmlecmascript/data/jsimport/testImport.qml | 14 + .../data/jsimport/testImportPragmaLibrary.qml | 20 + .../testImportPragmaLibraryWithImports.qml | 7 + ...ImportPragmaLibraryWithPragmaLibraryImports.qml | 7 + .../data/jsimport/testImportScoping.qml | 11 + .../data/jsimport/testModuleImport.js | 8 + .../data/jsimport/testScriptImport.js | 11 + .../qqmlecmascript/data/jsimportfail/failFive.qml | 11 + .../qqmlecmascript/data/jsimportfail/failFour.qml | 7 + .../qqmlecmascript/data/jsimportfail/failOne.qml | 7 + .../qqmlecmascript/data/jsimportfail/failThree.qml | 8 + .../qqmlecmascript/data/jsimportfail/failTwo.qml | 7 + .../qqmlecmascript/data/jsimportfail/importOne.js | 7 + .../data/jsimportfail/importPragmaLibrary.js | 11 + .../data/jsimportfail/importWithImports.js | 13 + .../data/jsimportfail/testImportPragmaLibrary.qml | 8 + .../data/jsimportfail/testModuleImport.js | 8 + .../data/jsimportfail/testScriptImport.js | 11 + .../qml/qqmlecmascript/data/libraryScriptAssert.js | 6 + .../qqmlecmascript/data/libraryScriptAssert.qml | 7 + .../qml/qqmlecmascript/data/listAssignment.qml | 20 + .../qml/qqmlecmascript/data/listProperties.qml | 24 + .../auto/qml/qqmlecmascript/data/listToVariant.qml | 5 + .../qml/qqmlecmascript/data/metaobjectRevision.qml | 7 + .../qqmlecmascript/data/metaobjectRevision2.qml | 9 + .../qqmlecmascript/data/metaobjectRevision3.qml | 8 + .../qqmlecmascript/data/metaobjectRevision4.qml | 14 + .../data/metaobjectRevisionErrors.qml | 14 + .../data/metaobjectRevisionErrors2.qml | 24 + .../data/metaobjectRevisionErrors3.qml | 36 + tests/auto/qml/qqmlecmascript/data/methods.1.qml | 6 + tests/auto/qml/qqmlecmascript/data/methods.2.qml | 6 + tests/auto/qml/qqmlecmascript/data/methods.3.qml | 7 + tests/auto/qml/qqmlecmascript/data/methods.4.qml | 11 + tests/auto/qml/qqmlecmascript/data/methods.5.qml | 9 + .../data/moduleapi/moduleApiMajorVersionFail.qml | 10 + .../data/moduleapi/moduleApiMinorVersionFail.qml | 10 + .../data/moduleapi/qobjectModuleApi.qml | 21 + .../data/moduleapi/qobjectModuleApiCaching.qml | 10 + .../data/moduleapi/qobjectModuleApiEnums.qml | 8 + .../data/moduleapi/qobjectModuleApiWriting.qml | 26 + .../data/moduleapi/scriptModuleApi.qml | 6 + .../data/moduleapi/scriptModuleApiCaching.qml | 6 + .../data/moduleapi/scriptModuleApiWriting.qml | 32 + .../qml/qqmlecmascript/data/multiEngineObject.qml | 5 + .../data/noSpuriousWarningsAtShutdown.2.qml | 10 + .../data/noSpuriousWarningsAtShutdown.qml | 9 + .../data/nonExistentAttachedObject.qml | 5 + .../auto/qml/qqmlecmascript/data/nonNotifyable.qml | 6 + .../auto/qml/qqmlecmascript/data/nonscriptable.qml | 19 + .../qml/qqmlecmascript/data/nullObjectBinding.qml | 8 + .../qml/qqmlecmascript/data/numberAssignment.qml | 18 + .../qml/qqmlecmascript/data/objectConversion.qml | 16 + tests/auto/qml/qqmlecmascript/data/objectName.qml | 8 + .../qqmlecmascript/data/objectsCompareAsEqual.qml | 15 + .../data/objectsPassThroughSignals.qml | 18 + .../data/outerBindingOverridesInnerBinding.qml | 15 + tests/auto/qml/qqmlecmascript/data/ownership.qml | 5 + .../data/propertyAssignmentErrors.qml | 29 + .../qml/qqmlecmascript/data/propertySplicing.qml | 10 + .../auto/qml/qqmlecmascript/data/propertyVar.1.qml | 22 + .../qml/qqmlecmascript/data/propertyVar.10.qml | 8 + .../auto/qml/qqmlecmascript/data/propertyVar.2.qml | 24 + .../auto/qml/qqmlecmascript/data/propertyVar.3.qml | 19 + .../auto/qml/qqmlecmascript/data/propertyVar.4.qml | 18 + .../auto/qml/qqmlecmascript/data/propertyVar.5.qml | 18 + .../auto/qml/qqmlecmascript/data/propertyVar.6.qml | 27 + .../auto/qml/qqmlecmascript/data/propertyVar.7.qml | 18 + .../auto/qml/qqmlecmascript/data/propertyVar.8.qml | 12 + .../auto/qml/qqmlecmascript/data/propertyVar.9.qml | 19 + .../qqmlecmascript/data/propertyVar.circular.2.qml | 26 + .../qqmlecmascript/data/propertyVar.circular.qml | 44 + .../qqmlecmascript/data/propertyVar.inherit.qml | 34 + .../qqmlecmascript/data/propertyVar.reparent.qml | 27 + .../qml/qqmlecmascript/data/propertyVarCpp.qml | 17 + .../data/propertyVarImplicitOwnership.qml | 26 + .../qqmlecmascript/data/propertyVarOwnership.2.qml | 24 + .../qqmlecmascript/data/propertyVarOwnership.3.qml | 31 + .../data/propertyVarOwnership.3.type.qml | 5 + .../qqmlecmascript/data/propertyVarOwnership.4.qml | 25 + .../data/propertyVarOwnership.4.type1.qml | 23 + .../data/propertyVarOwnership.4.type2.qml | 6 + .../qqmlecmascript/data/propertyVarOwnership.qml | 22 + .../qqmlecmascript/data/qlistqobjectMethods.qml | 6 + .../qml/qqmlecmascript/data/qmlHasOwnProperty.qml | 72 + tests/auto/qml/qqmlecmascript/data/qmlToString.qml | 11 + .../qobjectConnectionListExceptionHandling.qml | 24 + .../qqmlecmascript/data/qobjectDerivedArgument.qml | 17 + tests/auto/qml/qqmlecmascript/data/qtbug_10696.qml | 26 + tests/auto/qml/qqmlecmascript/data/qtbug_11600.js | 1 + tests/auto/qml/qqmlecmascript/data/qtbug_11600.qml | 8 + tests/auto/qml/qqmlecmascript/data/qtbug_11606.qml | 12 + tests/auto/qml/qqmlecmascript/data/qtbug_20344.qml | 6 + tests/auto/qml/qqmlecmascript/data/qtbug_21580.qml | 22 + tests/auto/qml/qqmlecmascript/data/qtbug_21864.js | 2 + tests/auto/qml/qqmlecmascript/data/qtbug_21864.qml | 6 + tests/auto/qml/qqmlecmascript/data/qtbug_22464.qml | 15 + tests/auto/qml/qqmlecmascript/data/qtbug_22679.qml | 14 + tests/auto/qml/qqmlecmascript/data/qtbug_22843.js | 5 + .../qml/qqmlecmascript/data/qtbug_22843.library.js | 5 + .../qqmlecmascript/data/qtbug_22843.library.qml | 6 + tests/auto/qml/qqmlecmascript/data/qtbug_22843.qml | 6 + tests/auto/qml/qqmlecmascript/data/qtbug_9792.qml | 5 + .../qml/qqmlecmascript/data/qtcreatorbug_1289.qml | 13 + .../qqmlecmascript/data/readonlyDeclaration.qml | 45 + tests/auto/qml/qqmlecmascript/data/realToInt.qml | 11 + tests/auto/qml/qqmlecmascript/data/regExp.2.qml | 7 + tests/auto/qml/qqmlecmascript/data/regExp.qml | 7 + tests/auto/qml/qqmlecmascript/data/remote_file.js | 2 + .../data/rewriteMultiLineStrings.qml | 35 + .../qqmlecmascript/data/scarceResourceCopy.var.qml | 14 + .../data/scarceResourceCopy.variant.qml | 15 + .../data/scarceResourceCopyFromJs.var.qml | 14 + .../data/scarceResourceCopyFromJs.variant.qml | 15 + .../data/scarceResourceCopyImport.var.js | 25 + .../data/scarceResourceCopyImport.var.qml | 18 + .../data/scarceResourceCopyImport.variant.js | 25 + .../data/scarceResourceCopyImport.variant.qml | 18 + .../data/scarceResourceCopyImportDifferent.var.js | 19 + .../data/scarceResourceCopyImportDifferent.var.qml | 22 + .../data/scarceResourceCopyImportFail.var.js | 19 + .../data/scarceResourceCopyImportFail.var.qml | 7 + .../data/scarceResourceCopyImportFail.variant.js | 19 + .../data/scarceResourceCopyImportFail.variant.qml | 8 + .../data/scarceResourceCopyImportNoBinding.var.js | 15 + .../data/scarceResourceCopyImportNoBinding.var.qml | 12 + .../scarceResourceCopyImportNoBinding.variant.js | 15 + .../scarceResourceCopyImportNoBinding.variant.qml | 12 + .../data/scarceResourceCopyNoBinding.var.qml | 14 + .../data/scarceResourceCopyNoBinding.variant.qml | 14 + .../data/scarceResourceDestroyedCopy.var.qml | 13 + .../data/scarceResourceDestroyedCopy.variant.qml | 14 + .../data/scarceResourceFunction.var.qml | 23 + .../data/scarceResourceFunction.variant.qml | 23 + .../data/scarceResourceFunctionFail.var.qml | 23 + .../data/scarceResourceFunctionFail.variant.qml | 23 + ...scarceResourceMultipleDifferentNoBinding.var.js | 14 + ...carceResourceMultipleDifferentNoBinding.var.qml | 14 + .../scarceResourceMultipleSameNoBinding.var.js | 15 + .../scarceResourceMultipleSameNoBinding.var.qml | 14 + .../scarceResourceMultipleSameWithBinding.var.qml | 12 + .../data/scarceResourceObjectGc.var.qml | 30 + .../data/scarceResourceSignal.var.qml | 29 + .../data/scarceResourceSignal.variant.qml | 29 + .../qqmlecmascript/data/scarceResourceTest.var.js | 48 + .../qqmlecmascript/data/scarceResourceTest.var.qml | 14 + .../data/scarceResourceTest.variant.js | 48 + .../data/scarceResourceTest.variant.qml | 14 + .../data/scarceResourceTestMultiple.var.qml | 16 + .../data/scarceResourceTestMultiple.variant.qml | 15 + .../data/scarceResourceTestPreserve.var.qml | 15 + .../data/scarceResourceTestPreserve.variant.qml | 15 + tests/auto/qml/qqmlecmascript/data/scope.2.qml | 40 + tests/auto/qml/qqmlecmascript/data/scope.3.qml | 13 + tests/auto/qml/qqmlecmascript/data/scope.4.qml | 12 + tests/auto/qml/qqmlecmascript/data/scope.5.qml | 27 + tests/auto/qml/qqmlecmascript/data/scope.6.qml | 10 + tests/auto/qml/qqmlecmascript/data/scope.qml | 44 + .../qml/qqmlecmascript/data/scriptConnect.1.js | 4 + .../qml/qqmlecmascript/data/scriptConnect.1.qml | 10 + .../qml/qqmlecmascript/data/scriptConnect.2.js | 5 + .../qml/qqmlecmascript/data/scriptConnect.2.qml | 16 + .../qml/qqmlecmascript/data/scriptConnect.3.qml | 15 + .../qml/qqmlecmascript/data/scriptConnect.4.qml | 12 + .../qml/qqmlecmascript/data/scriptConnect.5.qml | 11 + .../qml/qqmlecmascript/data/scriptConnect.6.js | 3 + .../qml/qqmlecmascript/data/scriptConnect.6.qml | 15 + .../qml/qqmlecmascript/data/scriptDisconnect.1.js | 6 + .../qml/qqmlecmascript/data/scriptDisconnect.1.qml | 13 + .../qml/qqmlecmascript/data/scriptDisconnect.2.qml | 14 + .../qml/qqmlecmascript/data/scriptDisconnect.3.qml | 14 + .../qml/qqmlecmascript/data/scriptDisconnect.4.qml | 13 + tests/auto/qml/qqmlecmascript/data/scriptErrors.js | 4 + .../auto/qml/qqmlecmascript/data/scriptErrors.qml | 18 + .../qqmlecmascript/data/selfDeletingBinding.2.qml | 17 + .../qqmlecmascript/data/selfDeletingBinding.qml | 18 + .../data/sequenceConversion.array.qml | 193 + .../data/sequenceConversion.bindings.error.qml | 19 + .../data/sequenceConversion.bindings.qml | 28 + .../data/sequenceConversion.copy.qml | 160 + .../data/sequenceConversion.indexes.qml | 89 + .../data/sequenceConversion.read.error.qml | 21 + .../data/sequenceConversion.read.qml | 105 + .../data/sequenceConversion.threads.qml | 74 + .../data/sequenceConversion.write.error.qml | 18 + .../data/sequenceConversion.write.qml | 109 + .../qqmlecmascript/data/sharedAttachedObject.qml | 16 + .../qml/qqmlecmascript/data/shutdownErrors.qml | 13 + .../qml/qqmlecmascript/data/signalAssignment.1.qml | 5 + .../qml/qqmlecmascript/data/signalAssignment.2.qml | 5 + .../qml/qqmlecmascript/data/signalHandlers.qml | 60 + .../qqmlecmascript/data/signalParameterTypes.qml | 18 + .../data/signalTriggeredBindings.qml | 20 + .../data/signalWithJSValueInVariant.qml | 12 + .../qml/qqmlecmascript/data/signalWithQJSValue.qml | 14 + .../qqmlecmascript/data/signalWithUnknownTypes.qml | 5 + .../qml/qqmlecmascript/data/strictlyEquals.qml | 17 + tests/auto/qml/qqmlecmascript/data/stringArg.qml | 49 + .../qml/qqmlecmascript/data/switchStatement.1.qml | 33 + .../qml/qqmlecmascript/data/switchStatement.2.qml | 33 + .../qml/qqmlecmascript/data/switchStatement.3.qml | 33 + .../qml/qqmlecmascript/data/switchStatement.4.qml | 31 + .../qml/qqmlecmascript/data/switchStatement.5.qml | 12 + .../qml/qqmlecmascript/data/switchStatement.6.qml | 13 + tests/auto/qml/qqmlecmascript/data/threadScript.js | 4 + .../qml/qqmlecmascript/data/transientErrors.2.qml | 14 + .../qml/qqmlecmascript/data/transientErrors.qml | 10 + .../qml/qqmlecmascript/data/tryStatement.1.qml | 13 + .../qml/qqmlecmascript/data/tryStatement.2.qml | 11 + .../qml/qqmlecmascript/data/tryStatement.3.qml | 13 + .../qml/qqmlecmascript/data/tryStatement.4.qml | 12 + tests/auto/qml/qqmlecmascript/data/typeOf.js | 25 + tests/auto/qml/qqmlecmascript/data/typeOf.qml | 26 + .../qml/qqmlecmascript/data/unaryExpression.qml | 9 + .../data/undefinedResetsProperty.2.qml | 10 + .../data/undefinedResetsProperty.qml | 7 + .../qml/qqmlecmascript/data/urlListProperty.qml | 41 + .../auto/qml/qqmlecmascript/data/urlProperty.1.qml | 10 + .../auto/qml/qqmlecmascript/data/urlProperty.2.qml | 10 + .../qml/qqmlecmascript/data/v8bindingException.qml | 21 + .../qqmlecmascript/data/v8functionException.qml | 15 + .../qml/qqmlecmascript/data/valueTypeFunctions.qml | 6 + .../data/variantsAssignedUndefined.qml | 9 + .../qml/qqmlecmascript/data/withStatement.1.qml | 14 + .../qqmlecmascript/data/writeAttachedProperty.qml | 6 + .../qqmlecmascript/data/writeRemovesBinding.qml | 46 + tests/auto/qml/qqmlecmascript/qqmlecmascript.pro | 22 + tests/auto/qml/qqmlecmascript/testtypes.cpp | 210 + tests/auto/qml/qqmlecmascript/testtypes.h | 1311 +++ .../auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp | 6062 +++++++++++++ tests/auto/qml/qqmlengine/qqmlengine.pro | 9 + tests/auto/qml/qqmlengine/tst_qqmlengine.cpp | 365 + tests/auto/qml/qqmlerror/data/test.txt | 3 + tests/auto/qml/qqmlerror/qqmlerror.pro | 15 + tests/auto/qml/qqmlerror/tst_qqmlerror.cpp | 243 + .../auto/qml/qqmlexpression/data/scriptString.qml | 9 + tests/auto/qml/qqmlexpression/qqmlexpression.pro | 15 + .../auto/qml/qqmlexpression/tst_qqmlexpression.cpp | 121 + .../qml/qqmlimageprovider/qqmlimageprovider.pro | 9 + .../qqmlimageprovider/tst_qqmlimageprovider.cpp | 424 + .../data/AsynchronousIfNestedType.qml | 7 + .../qqmlincubator/data/asynchronousIfNested.1.qml | 5 + .../qqmlincubator/data/asynchronousIfNested.2.qml | 6 + .../qqmlincubator/data/asynchronousIfNested.3.qml | 5 + .../qml/qqmlincubator/data/chainInCompletion.qml | 5 + .../data/chainedAsynchronousIfNested.qml | 5 + tests/auto/qml/qqmlincubator/data/clear.qml | 8 + .../qqmlincubator/data/clearDuringCompletion.qml | 6 + .../auto/qml/qqmlincubator/data/contextDelete.qml | 5 + .../qml/qqmlincubator/data/forceCompletion.qml | 9 + .../auto/qml/qqmlincubator/data/nestedComponent.js | 1 + .../qml/qqmlincubator/data/nestedComponent.qml | 10 + .../qqmlincubator/data/noIncubationController.qml | 5 + .../qqmlincubator/data/objectDeleted.errors.txt | 1 + .../auto/qml/qqmlincubator/data/objectDeleted.qml | 8 + .../qml/qqmlincubator/data/recursiveClear.1.qml | 9 + .../qml/qqmlincubator/data/recursiveClear.2.qml | 8 + tests/auto/qml/qqmlincubator/data/selfDelete.qml | 5 + .../qml/qqmlincubator/data/setInitialState.qml | 17 + .../qqmlincubator/data/statusChanged.nested.qml | 12 + .../auto/qml/qqmlincubator/data/statusChanged.qml | 5 + tests/auto/qml/qqmlincubator/qqmlincubator.pro | 18 + tests/auto/qml/qqmlincubator/testtypes.cpp | 137 + tests/auto/qml/qqmlincubator/testtypes.h | 125 + tests/auto/qml/qqmlincubator/tst_qqmlincubator.cpp | 1030 +++ tests/auto/qml/qqmlinfo/data/NestedComponent.qml | 23 + tests/auto/qml/qqmlinfo/data/NestedObject.qml | 8 + tests/auto/qml/qqmlinfo/data/nestedQmlObject.qml | 8 + tests/auto/qml/qqmlinfo/data/qmlObject.qml | 8 + tests/auto/qml/qqmlinfo/qqmlinfo.pro | 14 + tests/auto/qml/qqmlinfo/tst_qqmlinfo.cpp | 221 + tests/auto/qml/qqmlinstruction/qqmlinstruction.pro | 8 + .../qml/qqmlinstruction/tst_qqmlinstruction.cpp | 678 ++ tests/auto/qml/qqmllanguage/data/Alias.qml | 8 + tests/auto/qml/qqmllanguage/data/Alias2.qml | 9 + tests/auto/qml/qqmllanguage/data/Alias3.qml | 12 + tests/auto/qml/qqmllanguage/data/Alias4.qml | 5 + .../data/AliasPropertyChangeSignalsType.qml | 20 + .../qml/qqmllanguage/data/ComponentComposite.qml | 5 + tests/auto/qml/qqmllanguage/data/CompositeType.qml | 4 + .../auto/qml/qqmllanguage/data/CompositeType2.qml | 5 + .../auto/qml/qqmllanguage/data/CompositeType3.qml | 5 + .../auto/qml/qqmllanguage/data/CompositeType4.qml | 6 + .../data/DontDoubleCallClassBeginItem.qml | 4 + .../data/DynamicPropertiesNestedType.qml | 6 + tests/auto/qml/qqmllanguage/data/HelperAlias.qml | 9 + tests/auto/qml/qqmllanguage/data/I18n.qml | 6 + tests/auto/qml/qqmllanguage/data/I18nType30.qml | 5 + .../data/InlineAssignmentsOverrideBindingsType.qml | 7 + .../InlineAssignmentsOverrideBindingsType2.qml | 5 + tests/auto/qml/qqmllanguage/data/LocalLast.qml | 2 + tests/auto/qml/qqmllanguage/data/MyComponent.qml | 6 + .../qqmllanguage/data/MyCompositeValueSource.qml | 6 + .../qml/qqmllanguage/data/MyContainerComponent.qml | 5 + tests/auto/qml/qqmllanguage/data/NestedAlias.qml | 14 + .../qml/qqmllanguage/data/NestedComponentRoot.qml | 6 + .../qml/qqmllanguage/data/NestedErrorsType.qml | 5 + .../auto/qml/qqmllanguage/data/OnCompletedType.qml | 8 + .../qml/qqmllanguage/data/OnDestructionType.qml | 8 + tests/auto/qml/qqmllanguage/data/ReadOnlyType.qml | 5 + tests/auto/qml/qqmllanguage/data/alias.1.qml | 8 + tests/auto/qml/qqmllanguage/data/alias.10.qml | 8 + tests/auto/qml/qqmllanguage/data/alias.11.qml | 8 + tests/auto/qml/qqmllanguage/data/alias.2.qml | 8 + tests/auto/qml/qqmllanguage/data/alias.3.qml | 10 + tests/auto/qml/qqmllanguage/data/alias.4.qml | 6 + tests/auto/qml/qqmllanguage/data/alias.5.qml | 13 + tests/auto/qml/qqmllanguage/data/alias.6.qml | 8 + tests/auto/qml/qqmllanguage/data/alias.7.qml | 14 + tests/auto/qml/qqmllanguage/data/alias.8.qml | 9 + tests/auto/qml/qqmllanguage/data/alias.9.qml | 9 + .../data/aliasPropertiesAndSignals.qml | 14 + .../data/aliasPropertyChangeSignals.2.qml | 10 + .../data/aliasPropertyChangeSignals.qml | 16 + .../qqmllanguage/data/allowedRevisionOverloads.qml | 6 + .../qml/qqmllanguage/data/assignBasicTypes.qml | 28 + .../qqmllanguage/data/assignCompositeToType.qml | 18 + .../data/assignLiteralSignalProperty.qml | 4 + .../qml/qqmllanguage/data/assignLiteralToVar.qml | 32 + .../qqmllanguage/data/assignLiteralToVariant.qml | 17 + .../qml/qqmllanguage/data/assignObjectToSignal.qml | 4 + .../qqmllanguage/data/assignObjectToVariant.qml | 7 + .../qml/qqmllanguage/data/assignQmlComponent.qml | 4 + tests/auto/qml/qqmllanguage/data/assignSignal.qml | 5 + .../qqmllanguage/data/assignToNamespace.errors.txt | 1 + .../qml/qqmllanguage/data/assignToNamespace.qml | 5 + .../qml/qqmllanguage/data/assignTypeExtremes.qml | 5 + .../data/assignValueToSignal.errors.txt | 1 + .../qml/qqmllanguage/data/assignValueToSignal.qml | 6 + .../qml/qqmllanguage/data/attachedProperties.qml | 8 + .../qqmllanguage/data/autoComponentCreation.qml | 4 + .../qml/qqmllanguage/data/autoNotifyConnection.qml | 6 + .../qml/qqmllanguage/data/component.1.errors.txt | 1 + tests/auto/qml/qqmllanguage/data/component.1.qml | 4 + .../qml/qqmllanguage/data/component.2.errors.txt | 1 + tests/auto/qml/qqmllanguage/data/component.2.qml | 9 + .../qml/qqmllanguage/data/component.3.errors.txt | 1 + tests/auto/qml/qqmllanguage/data/component.3.qml | 9 + .../qml/qqmllanguage/data/component.4.errors.txt | 1 + tests/auto/qml/qqmllanguage/data/component.4.qml | 6 + .../qml/qqmllanguage/data/component.5.errors.txt | 1 + tests/auto/qml/qqmllanguage/data/component.5.qml | 6 + .../qml/qqmllanguage/data/component.6.errors.txt | 1 + tests/auto/qml/qqmllanguage/data/component.6.qml | 6 + .../qml/qqmllanguage/data/component.7.errors.txt | 1 + tests/auto/qml/qqmllanguage/data/component.7.qml | 7 + .../qml/qqmllanguage/data/component.8.errors.txt | 1 + tests/auto/qml/qqmllanguage/data/component.8.qml | 7 + .../qml/qqmllanguage/data/component.9.errors.txt | 1 + tests/auto/qml/qqmllanguage/data/component.9.qml | 7 + .../qqmllanguage/data/componentCompositeType.qml | 8 + .../auto/qml/qqmllanguage/data/cppnamespace.2.qml | 5 + tests/auto/qml/qqmllanguage/data/cppnamespace.qml | 4 + tests/auto/qml/qqmllanguage/data/crash2.qml | 5 + .../qml/qqmllanguage/data/customOnProperty.qml | 7 + .../data/customParserIdNotAllowed.errors.txt | 1 + .../qqmllanguage/data/customParserIdNotAllowed.qml | 5 + .../qml/qqmllanguage/data/customParserTypes.qml | 5 + .../qml/qqmllanguage/data/customVariantTypes.qml | 4 + .../qqmllanguage/data/declaredPropertyValues.qml | 8 + .../qqmllanguage/data/defaultGrouped.errors.txt | 1 + .../auto/qml/qqmllanguage/data/defaultGrouped.qml | 10 + .../qqmllanguage/data/defaultPropertyListOrder.qml | 29 + .../qqmllanguage/data/destroyedSignal.errors.txt | 1 + .../auto/qml/qqmllanguage/data/destroyedSignal.qml | 5 + .../data/disallowedRevisionOverloads.errors.txt | 1 + .../data/disallowedRevisionOverloads.qml | 7 + .../qqmllanguage/data/dontDoubleCallClassBegin.qml | 5 + .../qml/qqmllanguage/data/doubleSignal.errors.txt | 1 + tests/auto/qml/qqmllanguage/data/doubleSignal.qml | 7 + .../qml/qqmllanguage/data/duplicateIDs.errors.txt | 1 + tests/auto/qml/qqmllanguage/data/duplicateIDs.qml | 6 + .../qml/qqmllanguage/data/dynamicMeta.1.errors.txt | 1 + tests/auto/qml/qqmllanguage/data/dynamicMeta.1.qml | 6 + .../qml/qqmllanguage/data/dynamicMeta.2.errors.txt | 1 + tests/auto/qml/qqmllanguage/data/dynamicMeta.2.qml | 6 + .../qml/qqmllanguage/data/dynamicMeta.3.errors.txt | 1 + tests/auto/qml/qqmllanguage/data/dynamicMeta.3.qml | 6 + .../qml/qqmllanguage/data/dynamicMeta.4.errors.txt | 1 + tests/auto/qml/qqmllanguage/data/dynamicMeta.4.qml | 6 + .../qml/qqmllanguage/data/dynamicMeta.5.errors.txt | 1 + tests/auto/qml/qqmllanguage/data/dynamicMeta.5.qml | 5 + .../auto/qml/qqmllanguage/data/dynamicObject.1.qml | 8 + .../data/dynamicObjectProperties.2.qml | 11 + .../qqmllanguage/data/dynamicObjectProperties.qml | 13 + .../qml/qqmllanguage/data/dynamicProperties.qml | 13 + .../qqmllanguage/data/dynamicPropertiesNested.qml | 9 + .../qqmllanguage/data/dynamicSignalsAndSlots.qml | 10 + tests/auto/qml/qqmllanguage/data/empty.errors.txt | 2 + tests/auto/qml/qqmllanguage/data/empty.qml | 0 .../qml/qqmllanguage/data/emptySignal.errors.txt | 1 + tests/auto/qml/qqmllanguage/data/emptySignal.qml | 7 + .../qml/qqmllanguage/data/enumTypes.errors.txt | 1 + tests/auto/qml/qqmllanguage/data/enumTypes.qml | 4 + .../qqmllanguage/data/failingComponent.errors.txt | 1 + .../qml/qqmllanguage/data/failingComponentTest.qml | 4 + .../qqmllanguage/data/fakeDotProperty.errors.txt | 1 + .../auto/qml/qqmllanguage/data/fakeDotProperty.qml | 4 + .../qml/qqmllanguage/data/finalOverride.errors.txt | 1 + tests/auto/qml/qqmllanguage/data/finalOverride.qml | 4 + .../data/i18nDeclaredPropertyNames.qml | 6 + .../qqmllanguage/data/i18nDeclaredPropertyUse.qml | 3 + tests/auto/qml/qqmllanguage/data/i18nNameSpace.qml | 5 + tests/auto/qml/qqmllanguage/data/i18nScript.qml | 9 + tests/auto/qml/qqmllanguage/data/i18nStrings.qml | 5 + tests/auto/qml/qqmllanguage/data/i18nType.qml | 1 + tests/auto/qml/qqmllanguage/data/idProperty.qml | 8 + .../qml/qqmllanguage/data/importFile.errors.txt | 1 + tests/auto/qml/qqmllanguage/data/importFile.qml | 3 + .../qml/qqmllanguage/data/importIncorrectCase.qml | 5 + .../qml/qqmllanguage/data/importJs.1.errors.txt | 0 tests/auto/qml/qqmllanguage/data/importJs.1.qml | 12 + .../qml/qqmllanguage/data/importJs.10.errors.txt | 0 tests/auto/qml/qqmllanguage/data/importJs.10.qml | 16 + .../qml/qqmllanguage/data/importJs.2.errors.txt | 0 tests/auto/qml/qqmllanguage/data/importJs.2.qml | 12 + .../qml/qqmllanguage/data/importJs.3.errors.txt | 0 tests/auto/qml/qqmllanguage/data/importJs.3.qml | 16 + .../qml/qqmllanguage/data/importJs.4.errors.txt | 0 tests/auto/qml/qqmllanguage/data/importJs.4.qml | 15 + .../qml/qqmllanguage/data/importJs.5.errors.txt | 1 + tests/auto/qml/qqmllanguage/data/importJs.5.qml | 6 + .../qml/qqmllanguage/data/importJs.6.errors.txt | 1 + tests/auto/qml/qqmllanguage/data/importJs.6.qml | 13 + .../qml/qqmllanguage/data/importJs.7.errors.txt | 1 + tests/auto/qml/qqmllanguage/data/importJs.7.qml | 13 + .../qml/qqmllanguage/data/importJs.8.errors.txt | 0 tests/auto/qml/qqmllanguage/data/importJs.8.qml | 15 + .../qml/qqmllanguage/data/importJs.9.errors.txt | 0 tests/auto/qml/qqmllanguage/data/importJs.9.qml | 19 + .../data/importNamespaceConflict.errors.txt | 1 + .../qqmllanguage/data/importNamespaceConflict.qml | 4 + .../data/importNewerVersion.errors.txt | 1 + .../qml/qqmllanguage/data/importNewerVersion.qml | 3 + .../qqmllanguage/data/importNonExist.errors.txt | 1 + .../auto/qml/qqmllanguage/data/importNonExist.qml | 5 + .../data/importNonExistOlder.errors.txt | 1 + .../qml/qqmllanguage/data/importNonExistOlder.qml | 3 + .../data/importVersionMissingBuiltIn.errors.txt | 1 + .../data/importVersionMissingBuiltIn.qml | 7 + .../data/importVersionMissingInstalled.errors.txt | 1 + .../data/importVersionMissingInstalled.qml | 3 + .../qqmllanguage/data/importscript.1.errors.txt | 1 + .../auto/qml/qqmllanguage/data/importscript.1.qml | 3 + .../data/incorrectCase.errors.insensitive.txt | 2 + .../data/incorrectCase.errors.sensitive.txt | 1 + tests/auto/qml/qqmllanguage/data/incorrectCase.qml | 4 + .../qml/qqmllanguage/data/incorrectCaseType.qml | 4 + .../data/inlineAssignmentsOverrideBindings.qml | 6 + .../qml/qqmllanguage/data/inlineQmlComponents.qml | 10 + .../data/insertedSemicolon.1.errors.txt | 1 + .../qml/qqmllanguage/data/insertedSemicolon.1.qml | 10 + .../qml/qqmllanguage/data/interfaceProperty.qml | 5 + .../auto/qml/qqmllanguage/data/interfaceQList.qml | 7 + .../qqmllanguage/data/invalidAlias.1.errors.txt | 1 + .../auto/qml/qqmllanguage/data/invalidAlias.1.qml | 5 + .../qqmllanguage/data/invalidAlias.10.errors.txt | 1 + .../auto/qml/qqmllanguage/data/invalidAlias.10.qml | 6 + .../qqmllanguage/data/invalidAlias.2.errors.txt | 1 + .../auto/qml/qqmllanguage/data/invalidAlias.2.qml | 6 + .../qqmllanguage/data/invalidAlias.3.errors.txt | 1 + .../auto/qml/qqmllanguage/data/invalidAlias.3.qml | 6 + .../qqmllanguage/data/invalidAlias.4.errors.txt | 1 + .../auto/qml/qqmllanguage/data/invalidAlias.4.qml | 7 + .../qqmllanguage/data/invalidAlias.5.errors.txt | 1 + .../auto/qml/qqmllanguage/data/invalidAlias.5.qml | 7 + .../qqmllanguage/data/invalidAlias.6.errors.txt | 1 + .../auto/qml/qqmllanguage/data/invalidAlias.6.qml | 7 + .../qqmllanguage/data/invalidAlias.7.errors.txt | 1 + .../auto/qml/qqmllanguage/data/invalidAlias.7.qml | 6 + .../qqmllanguage/data/invalidAlias.8.errors.txt | 1 + .../auto/qml/qqmllanguage/data/invalidAlias.8.qml | 7 + .../qqmllanguage/data/invalidAlias.9.errors.txt | 1 + .../auto/qml/qqmllanguage/data/invalidAlias.9.qml | 6 + .../data/invalidAttachedProperty.1.errors.txt | 1 + .../data/invalidAttachedProperty.1.qml | 7 + .../data/invalidAttachedProperty.10.errors.txt | 1 + .../data/invalidAttachedProperty.10.qml | 6 + .../data/invalidAttachedProperty.11.errors.txt | 1 + .../data/invalidAttachedProperty.11.qml | 7 + .../data/invalidAttachedProperty.12.errors.txt | 1 + .../data/invalidAttachedProperty.12.qml | 6 + .../data/invalidAttachedProperty.13.errors.txt | 1 + .../data/invalidAttachedProperty.13.qml | 8 + .../data/invalidAttachedProperty.2.errors.txt | 1 + .../data/invalidAttachedProperty.2.qml | 6 + .../data/invalidAttachedProperty.3.errors.txt | 1 + .../data/invalidAttachedProperty.3.qml | 8 + .../data/invalidAttachedProperty.4.errors.txt | 1 + .../data/invalidAttachedProperty.4.qml | 7 + .../data/invalidAttachedProperty.5.errors.txt | 1 + .../data/invalidAttachedProperty.5.qml | 7 + .../data/invalidAttachedProperty.6.errors.txt | 1 + .../data/invalidAttachedProperty.6.qml | 7 + .../data/invalidAttachedProperty.7.errors.txt | 1 + .../data/invalidAttachedProperty.7.qml | 6 + .../data/invalidAttachedProperty.8.errors.txt | 1 + .../data/invalidAttachedProperty.8.qml | 6 + .../data/invalidAttachedProperty.9.errors.txt | 1 + .../data/invalidAttachedProperty.9.qml | 7 + .../data/invalidGroupedProperty.1.errors.txt | 1 + .../qqmllanguage/data/invalidGroupedProperty.1.qml | 6 + .../data/invalidGroupedProperty.10.errors.txt | 1 + .../data/invalidGroupedProperty.10.qml | 7 + .../data/invalidGroupedProperty.2.errors.txt | 1 + .../qqmllanguage/data/invalidGroupedProperty.2.qml | 7 + .../data/invalidGroupedProperty.3.errors.txt | 1 + .../qqmllanguage/data/invalidGroupedProperty.3.qml | 5 + .../data/invalidGroupedProperty.4.errors.txt | 1 + .../qqmllanguage/data/invalidGroupedProperty.4.qml | 5 + .../data/invalidGroupedProperty.5.errors.txt | 1 + .../qqmllanguage/data/invalidGroupedProperty.5.qml | 5 + .../data/invalidGroupedProperty.6.errors.txt | 1 + .../qqmllanguage/data/invalidGroupedProperty.6.qml | 6 + .../data/invalidGroupedProperty.7.errors.txt | 1 + .../qqmllanguage/data/invalidGroupedProperty.7.qml | 5 + .../data/invalidGroupedProperty.8.errors.txt | 1 + .../qqmllanguage/data/invalidGroupedProperty.8.qml | 6 + .../data/invalidGroupedProperty.9.errors.txt | 1 + .../qqmllanguage/data/invalidGroupedProperty.9.qml | 6 + .../qml/qqmllanguage/data/invalidID.2.errors.txt | 2 + tests/auto/qml/qqmllanguage/data/invalidID.2.qml | 5 + .../qml/qqmllanguage/data/invalidID.3.errors.txt | 1 + tests/auto/qml/qqmllanguage/data/invalidID.3.qml | 5 + .../qml/qqmllanguage/data/invalidID.4.errors.txt | 1 + tests/auto/qml/qqmllanguage/data/invalidID.4.qml | 6 + .../qml/qqmllanguage/data/invalidID.5.errors.txt | 1 + tests/auto/qml/qqmllanguage/data/invalidID.5.qml | 6 + .../qml/qqmllanguage/data/invalidID.6.errors.txt | 1 + tests/auto/qml/qqmllanguage/data/invalidID.6.qml | 5 + .../qml/qqmllanguage/data/invalidID.7.errors.txt | 1 + tests/auto/qml/qqmllanguage/data/invalidID.7.qml | 5 + .../qml/qqmllanguage/data/invalidID.8.errors.txt | 1 + tests/auto/qml/qqmllanguage/data/invalidID.8.qml | 5 + .../qml/qqmllanguage/data/invalidID.9.errors.txt | 1 + tests/auto/qml/qqmllanguage/data/invalidID.9.qml | 5 + .../qml/qqmllanguage/data/invalidID.errors.txt | 1 + tests/auto/qml/qqmllanguage/data/invalidID.qml | 4 + .../qqmllanguage/data/invalidImportID.errors.txt | 1 + .../auto/qml/qqmllanguage/data/invalidImportID.qml | 4 + .../qml/qqmllanguage/data/invalidOn.errors.txt | 1 + tests/auto/qml/qqmllanguage/data/invalidOn.qml | 4 + .../qqmllanguage/data/invalidProperty.errors.txt | 1 + .../auto/qml/qqmllanguage/data/invalidProperty.qml | 5 + .../qml/qqmllanguage/data/invalidRoot.1.errors.txt | 1 + tests/auto/qml/qqmllanguage/data/invalidRoot.1.qml | 2 + .../qml/qqmllanguage/data/invalidRoot.2.errors.txt | 1 + tests/auto/qml/qqmllanguage/data/invalidRoot.2.qml | 2 + .../qml/qqmllanguage/data/invalidRoot.3.errors.txt | 1 + tests/auto/qml/qqmllanguage/data/invalidRoot.3.qml | 4 + .../qml/qqmllanguage/data/invalidRoot.4.errors.txt | 1 + tests/auto/qml/qqmllanguage/data/invalidRoot.4.qml | 4 + .../qqmllanguage/data/invalidTypeName.1.errors.txt | 1 + .../qml/qqmllanguage/data/invalidTypeName.1.qml | 2 + .../qqmllanguage/data/invalidTypeName.2.errors.txt | 1 + .../qml/qqmllanguage/data/invalidTypeName.2.qml | 5 + .../qqmllanguage/data/invalidTypeName.3.errors.txt | 1 + .../qml/qqmllanguage/data/invalidTypeName.3.qml | 7 + .../qqmllanguage/data/invalidTypeName.4.errors.txt | 1 + .../qml/qqmllanguage/data/invalidTypeName.4.qml | 4 + .../lib/com/nokia/PureJsModule.1.6/FirstAPI.1.6.js | 5 + .../lib/com/nokia/PureJsModule.1.6/FirstAPI.js | 5 + .../lib/com/nokia/PureJsModule.1.6/SecondAPI.js | 5 + .../data/lib/com/nokia/PureJsModule.1.6/qmldir | 3 + .../data/lib/com/nokia/PureJsModule/FirstAPI.js | 5 + .../data/lib/com/nokia/PureJsModule/SecondAPI.js | 5 + .../data/lib/com/nokia/PureJsModule/qmldir | 2 + .../com/nokia/VersionedOnlyJsModule.9.0/SomeAPI.js | 5 + .../lib/com/nokia/VersionedOnlyJsModule.9.0/qmldir | 1 + .../lib/com/nokia/installedtest/InstalledTest.qml | 2 + .../lib/com/nokia/installedtest/InstalledTest2.qml | 2 + .../data/lib/com/nokia/installedtest/LocalLast.qml | 2 + .../lib/com/nokia/installedtest/PrivateType.qml | 2 + .../data/lib/com/nokia/installedtest/qmldir | 4 + .../lib/com/nokia/installedtest0/InstalledTest.qml | 2 + .../com/nokia/installedtest0/InstalledTest2.qml | 2 + .../data/lib/com/nokia/installedtest0/qmldir | 2 + .../qqmllanguage/data/listAssignment.1.errors.txt | 1 + .../qml/qqmllanguage/data/listAssignment.1.qml | 6 + .../qqmllanguage/data/listAssignment.2.errors.txt | 2 + .../qml/qqmllanguage/data/listAssignment.2.qml | 4 + .../qqmllanguage/data/listAssignment.3.errors.txt | 1 + .../qml/qqmllanguage/data/listAssignment.3.qml | 6 + .../qml/qqmllanguage/data/listItemDeleteSelf.qml | 38 + .../auto/qml/qqmllanguage/data/listProperties.qml | 9 + .../data/majorVersionIsolation.errors.txt | 1 + .../qqmllanguage/data/majorVersionIsolation.qml | 4 + .../data/metaobjectRevision.1.errors.txt | 1 + .../qml/qqmllanguage/data/metaobjectRevision.1.qml | 9 + .../data/metaobjectRevision.2.errors.txt | 1 + .../qml/qqmllanguage/data/metaobjectRevision.2.qml | 7 + .../data/metaobjectRevision.3.errors.txt | 1 + .../qml/qqmllanguage/data/metaobjectRevision.3.qml | 10 + .../auto/qml/qqmllanguage/data/method.1.errors.txt | 1 + tests/auto/qml/qqmllanguage/data/method.1.qml | 5 + .../qml/qqmllanguage/data/missingObject.errors.txt | 1 + tests/auto/qml/qqmllanguage/data/missingObject.qml | 1 + .../qml/qqmllanguage/data/missingSignal.errors.txt | 1 + tests/auto/qml/qqmllanguage/data/missingSignal.qml | 5 + .../data/missingValueTypeProperty.errors.txt | 1 + .../qqmllanguage/data/missingValueTypeProperty.qml | 5 + .../qml/qqmllanguage/data/multiSet.1.errors.txt | 1 + tests/auto/qml/qqmllanguage/data/multiSet.1.qml | 7 + .../qml/qqmllanguage/data/multiSet.10.errors.txt | 1 + tests/auto/qml/qqmllanguage/data/multiSet.10.qml | 6 + .../qml/qqmllanguage/data/multiSet.11.errors.txt | 1 + tests/auto/qml/qqmllanguage/data/multiSet.11.qml | 6 + .../qml/qqmllanguage/data/multiSet.2.errors.txt | 1 + tests/auto/qml/qqmllanguage/data/multiSet.2.qml | 7 + .../qml/qqmllanguage/data/multiSet.3.errors.txt | 1 + tests/auto/qml/qqmllanguage/data/multiSet.3.qml | 7 + .../qml/qqmllanguage/data/multiSet.4.errors.txt | 1 + tests/auto/qml/qqmllanguage/data/multiSet.4.qml | 7 + .../qml/qqmllanguage/data/multiSet.5.errors.txt | 1 + tests/auto/qml/qqmllanguage/data/multiSet.5.qml | 6 + .../qml/qqmllanguage/data/multiSet.6.errors.txt | 1 + tests/auto/qml/qqmllanguage/data/multiSet.6.qml | 7 + .../qml/qqmllanguage/data/multiSet.7.errors.txt | 1 + tests/auto/qml/qqmllanguage/data/multiSet.7.qml | 7 + .../qml/qqmllanguage/data/multiSet.8.errors.txt | 1 + tests/auto/qml/qqmllanguage/data/multiSet.8.qml | 8 + .../qml/qqmllanguage/data/multiSet.9.errors.txt | 1 + tests/auto/qml/qqmllanguage/data/multiSet.9.qml | 6 + .../qml/qqmllanguage/data/nestedComponentRoots.qml | 4 + .../qml/qqmllanguage/data/nestedErrors.errors.txt | 2 + tests/auto/qml/qqmllanguage/data/nestedErrors.qml | 6 + .../qml/qqmllanguage/data/noCreation.errors.txt | 1 + tests/auto/qml/qqmllanguage/data/noCreation.qml | 4 + .../data/nonScriptableProperty.errors.txt | 1 + .../qqmllanguage/data/nonScriptableProperty.qml | 5 + .../data/nonexistantProperty.1.errors.txt | 1 + .../qqmllanguage/data/nonexistantProperty.1.qml | 2 + .../data/nonexistantProperty.2.errors.txt | 1 + .../qqmllanguage/data/nonexistantProperty.2.qml | 4 + .../data/nonexistantProperty.3.errors.txt | 1 + .../qqmllanguage/data/nonexistantProperty.3.qml | 4 + .../data/nonexistantProperty.4.errors.txt | 1 + .../qqmllanguage/data/nonexistantProperty.4.qml | 4 + .../data/nonexistantProperty.5.errors.txt | 1 + .../qqmllanguage/data/nonexistantProperty.5.qml | 4 + .../data/nonexistantProperty.6.errors.txt | 1 + .../qqmllanguage/data/nonexistantProperty.6.qml | 4 + .../qml/qqmllanguage/data/notAvailable.errors.txt | 1 + tests/auto/qml/qqmllanguage/data/notAvailable.qml | 4 + .../qqmllanguage/data/nullDotProperty.errors.txt | 1 + .../auto/qml/qqmllanguage/data/nullDotProperty.qml | 4 + .../data/objectValueTypeProperty.errors.txt | 1 + .../qqmllanguage/data/objectValueTypeProperty.qml | 6 + tests/auto/qml/qqmllanguage/data/onCompleted.qml | 17 + tests/auto/qml/qqmllanguage/data/onDestruction.qml | 17 + .../qml/qqmllanguage/data/property.1.errors.txt | 1 + tests/auto/qml/qqmllanguage/data/property.1.qml | 5 + .../qml/qqmllanguage/data/property.2.errors.txt | 1 + tests/auto/qml/qqmllanguage/data/property.2.qml | 6 + .../qml/qqmllanguage/data/property.3.errors.txt | 1 + tests/auto/qml/qqmllanguage/data/property.3.qml | 7 + .../qml/qqmllanguage/data/property.4.errors.txt | 1 + tests/auto/qml/qqmllanguage/data/property.4.qml | 5 + .../qml/qqmllanguage/data/property.6.errors.txt | 1 + tests/auto/qml/qqmllanguage/data/property.6.qml | 6 + .../qml/qqmllanguage/data/property.7.errors.txt | 1 + tests/auto/qml/qqmllanguage/data/property.7.qml | 5 + .../auto/qml/qqmllanguage/data/propertyInit.1.qml | 5 + .../auto/qml/qqmllanguage/data/propertyInit.2.qml | 6 + .../qqmllanguage/data/propertyValueSource.2.qml | 5 + .../qml/qqmllanguage/data/propertyValueSource.qml | 4 + .../data/qmlAttachedPropertiesObjectMethod.1.qml | 5 + .../data/qmlAttachedPropertiesObjectMethod.2.qml | 6 + .../data/qtest/qml/qqmllanguage/LocalInternal.qml | 3 + .../data/qtest/qml/qqmllanguage/Test.qml | 2 + .../data/qtest/qml/qqmllanguage/TestLocal.qml | 1 + .../data/qtest/qml/qqmllanguage/TestNamed.qml | 1 + .../data/qtest/qml/qqmllanguage/TestSubDir.qml | 2 + .../qtest/qml/qqmllanguage/UndeclaredLocal.qml | 3 + .../data/qtest/qml/qqmllanguage/WrongTestLocal.qml | 1 + .../data/qtest/qml/qqmllanguage/noqmldir/Test.qml | 2 + .../data/qtest/qml/qqmllanguage/pics/blue.png | Bin 0 -> 84 bytes .../data/qtest/qml/qqmllanguage/qmldir | 5 + .../data/qtest/qml/qqmllanguage/subdir/SubTest.qml | 3 + .../data/qtest/qml/qqmllanguage/subdir/qmldir | 1 + .../qml/qqmllanguage/data/readOnly.1.errors.txt | 1 + tests/auto/qml/qqmllanguage/data/readOnly.1.qml | 4 + .../qml/qqmllanguage/data/readOnly.2.errors.txt | 1 + tests/auto/qml/qqmllanguage/data/readOnly.2.qml | 4 + .../qml/qqmllanguage/data/readOnly.3.errors.txt | 1 + tests/auto/qml/qqmllanguage/data/readOnly.3.qml | 8 + .../qml/qqmllanguage/data/readOnly.4.errors.txt | 1 + tests/auto/qml/qqmllanguage/data/readOnly.4.qml | 4 + .../qml/qqmllanguage/data/readOnly.5.errors.txt | 1 + tests/auto/qml/qqmllanguage/data/readOnly.5.qml | 3 + tests/auto/qml/qqmllanguage/data/readonly.qml | 17 + .../qml/qqmllanguage/data/registrationOrder.qml | 4 + .../auto/qml/qqmllanguage/data/remoteLoadCrash.qml | 3 + tests/auto/qml/qqmllanguage/data/revisions11.qml | 10 + .../qml/qqmllanguage/data/revisionsbasesub11.qml | 16 + .../auto/qml/qqmllanguage/data/revisionssub11.qml | 12 + .../qml/qqmllanguage/data/rootAsQmlComponent.qml | 6 + .../qqmllanguage/data/scriptString.1.errors.txt | 1 + .../auto/qml/qqmllanguage/data/scriptString.1.qml | 5 + .../qqmllanguage/data/scriptString.2.errors.txt | 1 + .../auto/qml/qqmllanguage/data/scriptString.2.qml | 6 + tests/auto/qml/qqmllanguage/data/scriptString.qml | 6 + tests/auto/qml/qqmllanguage/data/scriptString2.qml | 5 + tests/auto/qml/qqmllanguage/data/scriptString3.qml | 5 + tests/auto/qml/qqmllanguage/data/scriptString4.qml | 5 + .../auto/qml/qqmllanguage/data/signal.1.errors.txt | 1 + tests/auto/qml/qqmllanguage/data/signal.1.qml | 5 + .../auto/qml/qqmllanguage/data/signal.2.errors.txt | 1 + tests/auto/qml/qqmllanguage/data/signal.2.qml | 6 + .../auto/qml/qqmllanguage/data/signal.3.errors.txt | 1 + tests/auto/qml/qqmllanguage/data/signal.3.qml | 6 + .../auto/qml/qqmllanguage/data/signal.4.errors.txt | 1 + tests/auto/qml/qqmllanguage/data/signal.4.qml | 6 + .../auto/qml/qqmllanguage/data/simpleBindings.qml | 18 + .../auto/qml/qqmllanguage/data/simpleContainer.qml | 5 + tests/auto/qml/qqmllanguage/data/simpleObject.qml | 2 + .../data/singularProperty.2.errors.txt | 1 + .../qml/qqmllanguage/data/singularProperty.2.qml | 7 + .../qqmllanguage/data/singularProperty.errors.txt | 1 + .../qml/qqmllanguage/data/singularProperty.qml | 6 + tests/auto/qml/qqmllanguage/data/subdir/Test.qml | 2 + .../qqmllanguage/data/subdir/subsubdir/SubTest.qml | 2 + tests/auto/qml/qqmllanguage/data/test.js | 0 tests/auto/qml/qqmllanguage/data/test2.js | 0 .../data/unregisteredObject.errors.txt | 1 + .../qml/qqmllanguage/data/unregisteredObject.qml | 2 + .../data/unsupportedProperty.errors.txt | 1 + .../qml/qqmllanguage/data/unsupportedProperty.qml | 4 + tests/auto/qml/qqmllanguage/data/valueTypes.qml | 13 + tests/auto/qml/qqmllanguage/data/variantNotify.qml | 13 + tests/auto/qml/qqmllanguage/data/versionedbase.qml | 8 + .../qml/qqmllanguage/data/wrongType.1.errors.txt | 1 + tests/auto/qml/qqmllanguage/data/wrongType.1.qml | 4 + .../qml/qqmllanguage/data/wrongType.10.errors.txt | 1 + tests/auto/qml/qqmllanguage/data/wrongType.10.qml | 5 + .../qml/qqmllanguage/data/wrongType.11.errors.txt | 1 + tests/auto/qml/qqmllanguage/data/wrongType.11.qml | 5 + .../qml/qqmllanguage/data/wrongType.12.errors.txt | 1 + tests/auto/qml/qqmllanguage/data/wrongType.12.qml | 5 + .../qml/qqmllanguage/data/wrongType.13.errors.txt | 1 + tests/auto/qml/qqmllanguage/data/wrongType.13.qml | 4 + .../qml/qqmllanguage/data/wrongType.14.errors.txt | 1 + tests/auto/qml/qqmllanguage/data/wrongType.14.qml | 5 + .../qml/qqmllanguage/data/wrongType.15.errors.txt | 1 + tests/auto/qml/qqmllanguage/data/wrongType.15.qml | 4 + .../qml/qqmllanguage/data/wrongType.16.errors.txt | 1 + tests/auto/qml/qqmllanguage/data/wrongType.16.qml | 5 + .../qml/qqmllanguage/data/wrongType.17.errors.txt | 1 + tests/auto/qml/qqmllanguage/data/wrongType.17.qml | 5 + .../qml/qqmllanguage/data/wrongType.2.errors.txt | 1 + tests/auto/qml/qqmllanguage/data/wrongType.2.qml | 4 + .../qml/qqmllanguage/data/wrongType.3.errors.txt | 1 + tests/auto/qml/qqmllanguage/data/wrongType.3.qml | 4 + .../qml/qqmllanguage/data/wrongType.4.errors.txt | 1 + tests/auto/qml/qqmllanguage/data/wrongType.4.qml | 4 + .../qml/qqmllanguage/data/wrongType.5.errors.txt | 1 + tests/auto/qml/qqmllanguage/data/wrongType.5.qml | 5 + .../qml/qqmllanguage/data/wrongType.6.errors.txt | 1 + tests/auto/qml/qqmllanguage/data/wrongType.6.qml | 5 + .../qml/qqmllanguage/data/wrongType.7.errors.txt | 1 + tests/auto/qml/qqmllanguage/data/wrongType.7.qml | 5 + .../qml/qqmllanguage/data/wrongType.8.errors.txt | 1 + tests/auto/qml/qqmllanguage/data/wrongType.8.qml | 5 + .../qml/qqmllanguage/data/wrongType.9.errors.txt | 1 + tests/auto/qml/qqmllanguage/data/wrongType.9.qml | 5 + tests/auto/qml/qqmllanguage/qqmllanguage.pro | 18 + tests/auto/qml/qqmllanguage/testtypes.cpp | 88 + tests/auto/qml/qqmllanguage/testtypes.h | 823 ++ tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp | 2289 +++++ tests/auto/qml/qqmllistreference/data/MyType.qml | 5 + .../qml/qqmllistreference/data/engineTypes.qml | 9 + .../qml/qqmllistreference/data/variantToList.qml | 10 + .../qml/qqmllistreference/qqmllistreference.pro | 15 + .../qqmllistreference/tst_qqmllistreference.cpp | 570 ++ tests/auto/qml/qqmllocale/data/date.qml | 45 + tests/auto/qml/qqmllocale/data/functions.qml | 65 + tests/auto/qml/qqmllocale/data/localeCompare.qml | 7 + tests/auto/qml/qqmllocale/data/number.qml | 30 + tests/auto/qml/qqmllocale/data/properties.qml | 27 + tests/auto/qml/qqmllocale/qqmllocale.pro | 15 + tests/auto/qml/qqmllocale/tst_qqmllocale.cpp | 1183 +++ tests/auto/qml/qqmlmetatype/qqmlmetatype.pro | 7 + tests/auto/qml/qqmlmetatype/tst_qqmlmetatype.cpp | 202 + .../data/implicit1/implicitQmldir.errors.txt | 1 + .../qml/qqmlmoduleplugin/data/implicit1/qmldir | 2 + .../qqmlmoduleplugin/data/implicit1/temptest.qml | 14 + .../qml/qqmlmoduleplugin/data/implicit2/Test.qml | 5 + .../data/implicit2/implicitQmldir.2.errors.txt | 3 + .../qml/qqmlmoduleplugin/data/implicit2/qmldir | 3 + .../qqmlmoduleplugin/data/implicit2/temptest2.qml | 8 + .../data/importsMixedQmlCppPlugin.2.qml | 21 + .../data/importsMixedQmlCppPlugin.qml | 13 + .../qml/qqmlmoduleplugin/data/incorrectCase.qml | 4 + .../qqmlmoduleplugin/data/pluginWithQmlFile.qml | 3 + .../data/versionNotInstalled.2.errors.txt | 1 + .../data/versionNotInstalled.2.qml | 5 + .../data/versionNotInstalled.errors.txt | 1 + .../qqmlmoduleplugin/data/versionNotInstalled.qml | 6 + tests/auto/qml/qqmlmoduleplugin/data/works.qml | 3 + tests/auto/qml/qqmlmoduleplugin/data/works2.qml | 3 + tests/auto/qml/qqmlmoduleplugin/data/works21.qml | 3 + .../nokia/AutoTestPluginWithQmlFile/MyQmlFile.qml | 3 + .../com/nokia/AutoTestPluginWithQmlFile/qmldir | 3 + .../com/nokia/AutoTestQmlMixedPluginType/Foo.qml | 5 + .../com/nokia/AutoTestQmlMixedPluginType/qmldir | 2 + .../com/nokia/AutoTestQmlPluginType.2.1/qmldir | 1 + .../com/nokia/AutoTestQmlPluginType.2/qmldir | 1 + .../imports/com/nokia/AutoTestQmlPluginType/qmldir | 1 + .../com/nokia/AutoTestQmlVersionPluginType/qmldir | 1 + .../imports/com/nokia/PureQmlModule/ComponentA.qml | 3 + .../imports/com/nokia/PureQmlModule/ComponentB.qml | 4 + .../imports/com/nokia/PureQmlModule/qmldir | 3 + .../imports/com/nokia/WrongCase/qmldir | 1 + .../qml/qqmlmoduleplugin/plugin.2.1/plugin.2.1.pro | 7 + .../qml/qqmlmoduleplugin/plugin.2.1/plugin.cpp | 84 + .../qml/qqmlmoduleplugin/plugin.2/plugin.2.pro | 7 + .../auto/qml/qqmlmoduleplugin/plugin.2/plugin.cpp | 84 + tests/auto/qml/qqmlmoduleplugin/plugin/plugin.cpp | 83 + tests/auto/qml/qqmlmoduleplugin/plugin/plugin.pro | 7 + .../qml/qqmlmoduleplugin/pluginMixed/plugin.cpp | 73 + .../qqmlmoduleplugin/pluginMixed/pluginMixed.pro | 7 + .../qml/qqmlmoduleplugin/pluginVersion/plugin.cpp | 73 + .../pluginVersion/pluginVersion.pro | 7 + .../qqmlmoduleplugin/pluginWithQmlFile/plugin.cpp | 58 + .../pluginWithQmlFile/pluginWithQmlFile.pro | 7 + .../qqmlmoduleplugin/pluginWrongCase/plugin.cpp | 83 + .../pluginWrongCase/pluginWrongCase.pro | 8 + .../auto/qml/qqmlmoduleplugin/qqmlmoduleplugin.pro | 9 + .../qml/qqmlmoduleplugin/tst_qqmlmoduleplugin.cpp | 353 + .../qml/qqmlmoduleplugin/tst_qqmlmoduleplugin.pro | 19 + tests/auto/qml/qqmlparser/qqmlparser.pro | 9 + tests/auto/qml/qqmlparser/tst_qqmlparser.cpp | 210 + tests/auto/qml/qqmlpixmapcache/data/dataLeak.qml | 18 + .../auto/qml/qqmlproperty/data/NoContextTypeA.qml | 5 + .../auto/qml/qqmlproperty/data/NoContextTypeB.qml | 5 + tests/auto/qml/qqmlproperty/data/TestType.qml | 6 + .../qqmlproperty/data/aliasPropertyBindings.qml | 19 + .../qqmlproperty/data/assignEmptyVariantMap.qml | 5 + .../qqmlproperty/data/readSynthesizedObject.qml | 9 + tests/auto/qml/qqmlproperty/qqmlproperty.pro | 15 + tests/auto/qml/qqmlproperty/tst_qqmlproperty.cpp | 1721 ++++ .../qml/qqmlpropertycache/qqmlpropertycache.pro | 8 + .../qqmlpropertycache/tst_qqmlpropertycache.cpp | 281 + tests/auto/qml/qqmlpropertymap/qqmlpropertymap.pro | 9 + .../qml/qqmlpropertymap/tst_qqmlpropertymap.cpp | 241 + tests/auto/qml/qqmlqt/data/atob.qml | 7 + tests/auto/qml/qqmlqt/data/btoa.qml | 6 + tests/auto/qml/qqmlqt/data/createComponent.qml | 20 + tests/auto/qml/qqmlqt/data/createComponentData.qml | 5 + tests/auto/qml/qqmlqt/data/createComponent_lib.js | 11 + tests/auto/qml/qqmlqt/data/createComponent_lib.qml | 12 + tests/auto/qml/qqmlqt/data/createQmlObject.qml | 31 + tests/auto/qml/qqmlqt/data/darker.qml | 12 + tests/auto/qml/qqmlqt/data/dateTimeConversion.qml | 14 + tests/auto/qml/qqmlqt/data/enums.qml | 9 + tests/auto/qml/qqmlqt/data/fontFamilies.qml | 6 + tests/auto/qml/qqmlqt/data/formatting.qml | 44 + tests/auto/qml/qqmlqt/data/hsla.qml | 11 + tests/auto/qml/qqmlqt/data/isQtObject.qml | 14 + tests/auto/qml/qqmlqt/data/lighter.qml | 11 + tests/auto/qml/qqmlqt/data/md5.qml | 6 + tests/auto/qml/qqmlqt/data/openUrlExternally.qml | 8 + .../auto/qml/qqmlqt/data/openUrlExternally_lib.js | 9 + .../auto/qml/qqmlqt/data/openUrlExternally_lib.qml | 9 + tests/auto/qml/qqmlqt/data/point.qml | 9 + tests/auto/qml/qqmlqt/data/quit.qml | 5 + tests/auto/qml/qqmlqt/data/rect.qml | 9 + tests/auto/qml/qqmlqt/data/resolvedUrl.qml | 13 + tests/auto/qml/qqmlqt/data/rgba.qml | 10 + tests/auto/qml/qqmlqt/data/size.qml | 11 + tests/auto/qml/qqmlqt/data/tint.qml | 9 + tests/auto/qml/qqmlqt/data/vector.qml | 8 + tests/auto/qml/qqmlqt/data/vector4.qml | 8 + tests/auto/qml/qqmlqt/qqmlqt.pro | 15 + tests/auto/qml/qqmlqt/tst_qqmlqt.cpp | 732 ++ tests/auto/qml/qqmlsqldatabase/data/README | 3 + .../auto/qml/qqmlsqldatabase/data/changeversion.js | 55 + tests/auto/qml/qqmlsqldatabase/data/creation-a.js | 20 + tests/auto/qml/qqmlsqldatabase/data/creation.js | 15 + tests/auto/qml/qqmlsqldatabase/data/error-a.js | 22 + tests/auto/qml/qqmlsqldatabase/data/error-b.js | 15 + .../qml/qqmlsqldatabase/data/error-creation.js | 16 + .../qqmlsqldatabase/data/error-notransaction.js | 17 + .../data/error-outsidetransaction.js | 19 + .../qqmlsqldatabase/data/iteration-forwardonly.js | 31 + tests/auto/qml/qqmlsqldatabase/data/iteration.js | 30 + .../qml/qqmlsqldatabase/data/readonly-error.js | 29 + tests/auto/qml/qqmlsqldatabase/data/readonly.js | 26 + tests/auto/qml/qqmlsqldatabase/data/reopen1.js | 16 + tests/auto/qml/qqmlsqldatabase/data/reopen2.js | 18 + .../qqmlsqldatabase/data/selection-bindnames.js | 28 + tests/auto/qml/qqmlsqldatabase/data/selection.js | 46 + tests/auto/qml/qqmlsqldatabase/qqmlsqldatabase.pro | 15 + .../qml/qqmlsqldatabase/tst_qqmlsqldatabase.cpp | 243 + .../qml/qqmltranslation/data/idtranslation.qml | 8 + tests/auto/qml/qqmltranslation/data/qml_fr.qm | Bin 0 -> 374 bytes tests/auto/qml/qqmltranslation/data/qml_fr.ts | 43 + tests/auto/qml/qqmltranslation/data/qmlid_fr.qm | Bin 0 -> 119 bytes tests/auto/qml/qqmltranslation/data/qmlid_fr.ts | 13 + .../auto/qml/qqmltranslation/data/translation.qml | 21 + .../auto/qml/qqmltranslation/data/translation.qrc | 6 + tests/auto/qml/qqmltranslation/qqmltranslation.pro | 16 + .../qml/qqmltranslation/tst_qqmltranslation.cpp | 137 + .../data/BindingsSpliceCorrectlyType.qml | 7 + .../data/BindingsSpliceCorrectlyType4.qml | 7 + .../data/BindingsSpliceCorrectlyType5.qml | 7 + .../qqmlvaluetypes/data/autoBindingRemoval.2.qml | 9 + .../qqmlvaluetypes/data/autoBindingRemoval.3.qml | 10 + .../qml/qqmlvaluetypes/data/autoBindingRemoval.qml | 9 + .../qml/qqmlvaluetypes/data/bindingAssignment.qml | 7 + .../qml/qqmlvaluetypes/data/bindingConflict.qml | 8 + tests/auto/qml/qqmlvaluetypes/data/bindingRead.qml | 5 + .../qml/qqmlvaluetypes/data/bindingVariantCopy.qml | 13 + .../data/bindingsSpliceCorrectly.1.qml | 29 + .../data/bindingsSpliceCorrectly.2.qml | 31 + .../data/bindingsSpliceCorrectly.3.qml | 36 + .../data/bindingsSpliceCorrectly.4.qml | 27 + .../data/bindingsSpliceCorrectly.5.qml | 27 + .../auto/qml/qqmlvaluetypes/data/color_compare.qml | 37 + tests/auto/qml/qqmlvaluetypes/data/color_read.qml | 9 + tests/auto/qml/qqmlvaluetypes/data/color_write.qml | 8 + .../auto/qml/qqmlvaluetypes/data/conflicting.1.qml | 42 + .../auto/qml/qqmlvaluetypes/data/conflicting.2.qml | 42 + .../auto/qml/qqmlvaluetypes/data/conflicting.3.qml | 42 + .../auto/qml/qqmlvaluetypes/data/deletedObject.js | 13 + .../auto/qml/qqmlvaluetypes/data/deletedObject.qml | 11 + tests/auto/qml/qqmlvaluetypes/data/enums.1.qml | 6 + tests/auto/qml/qqmlvaluetypes/data/enums.2.qml | 6 + tests/auto/qml/qqmlvaluetypes/data/enums.3.qml | 6 + tests/auto/qml/qqmlvaluetypes/data/enums.4.qml | 7 + tests/auto/qml/qqmlvaluetypes/data/enums.5.qml | 10 + .../auto/qml/qqmlvaluetypes/data/font_compare.qml | 31 + tests/auto/qml/qqmlvaluetypes/data/font_read.qml | 18 + .../auto/qml/qqmlvaluetypes/data/font_write.2.qml | 6 + .../auto/qml/qqmlvaluetypes/data/font_write.3.qml | 7 + .../auto/qml/qqmlvaluetypes/data/font_write.4.qml | 7 + .../auto/qml/qqmlvaluetypes/data/font_write.5.qml | 14 + tests/auto/qml/qqmlvaluetypes/data/font_write.qml | 16 + .../qml/qqmlvaluetypes/data/matrix4x4_compare.qml | 35 + .../qml/qqmlvaluetypes/data/matrix4x4_read.qml | 22 + .../qml/qqmlvaluetypes/data/matrix4x4_write.qml | 21 + .../auto/qml/qqmlvaluetypes/data/point_compare.qml | 22 + tests/auto/qml/qqmlvaluetypes/data/point_read.qml | 7 + tests/auto/qml/qqmlvaluetypes/data/point_write.qml | 6 + .../qml/qqmlvaluetypes/data/pointf_compare.qml | 22 + tests/auto/qml/qqmlvaluetypes/data/pointf_read.qml | 8 + .../auto/qml/qqmlvaluetypes/data/pointf_write.qml | 6 + .../qml/qqmlvaluetypes/data/quaternion_compare.qml | 23 + .../qml/qqmlvaluetypes/data/quaternion_read.qml | 10 + .../qml/qqmlvaluetypes/data/quaternion_write.qml | 9 + .../auto/qml/qqmlvaluetypes/data/rect_compare.qml | 25 + tests/auto/qml/qqmlvaluetypes/data/rect_read.qml | 10 + tests/auto/qml/qqmlvaluetypes/data/rect_write.qml | 9 + .../auto/qml/qqmlvaluetypes/data/rectf_compare.qml | 25 + tests/auto/qml/qqmlvaluetypes/data/rectf_read.qml | 10 + tests/auto/qml/qqmlvaluetypes/data/rectf_write.qml | 9 + .../auto/qml/qqmlvaluetypes/data/returnValues.qml | 17 + .../auto/qml/qqmlvaluetypes/data/scriptAccess.qml | 9 + .../qml/qqmlvaluetypes/data/scriptVariantCopy.qml | 14 + .../auto/qml/qqmlvaluetypes/data/size_compare.qml | 23 + tests/auto/qml/qqmlvaluetypes/data/size_read.qml | 8 + tests/auto/qml/qqmlvaluetypes/data/size_write.qml | 7 + .../auto/qml/qqmlvaluetypes/data/sizef_compare.qml | 24 + tests/auto/qml/qqmlvaluetypes/data/sizef_read.qml | 9 + tests/auto/qml/qqmlvaluetypes/data/sizef_write.qml | 6 + .../qml/qqmlvaluetypes/data/sizereadonly_read.qml | 8 + .../data/sizereadonly_writeerror.qml | 6 + .../data/sizereadonly_writeerror2.qml | 7 + .../data/sizereadonly_writeerror3.qml | 7 + .../data/sizereadonly_writeerror4.qml | 10 + .../qml/qqmlvaluetypes/data/staticAssignment.qml | 5 + .../qml/qqmlvaluetypes/data/valueInterceptors.qml | 8 + .../auto/qml/qqmlvaluetypes/data/valueSources.qml | 5 + .../auto/qml/qqmlvaluetypes/data/varAssignment.qml | 14 + .../auto/qml/qqmlvaluetypes/data/variant_read.qml | 9 + .../qml/qqmlvaluetypes/data/vector2d_compare.qml | 21 + .../auto/qml/qqmlvaluetypes/data/vector2d_read.qml | 8 + .../qml/qqmlvaluetypes/data/vector2d_write.qml | 7 + .../qml/qqmlvaluetypes/data/vector3d_compare.qml | 23 + .../auto/qml/qqmlvaluetypes/data/vector3d_read.qml | 9 + .../qml/qqmlvaluetypes/data/vector3d_write.qml | 8 + .../qml/qqmlvaluetypes/data/vector4d_compare.qml | 23 + .../auto/qml/qqmlvaluetypes/data/vector4d_read.qml | 10 + .../qml/qqmlvaluetypes/data/vector4d_write.qml | 9 + tests/auto/qml/qqmlvaluetypes/qqmlvaluetypes.pro | 18 + tests/auto/qml/qqmlvaluetypes/testtypes.cpp | 48 + tests/auto/qml/qqmlvaluetypes/testtypes.h | 219 + .../auto/qml/qqmlvaluetypes/tst_qqmlvaluetypes.cpp | 1306 +++ .../auto/qml/qqmlxmlhttprequest/data/abort.expect | 10 + tests/auto/qml/qqmlxmlhttprequest/data/abort.qml | 44 + tests/auto/qml/qqmlxmlhttprequest/data/abort.reply | 3 + .../qml/qqmlxmlhttprequest/data/abort_opened.qml | 60 + .../qml/qqmlxmlhttprequest/data/abort_unsent.qml | 55 + tests/auto/qml/qqmlxmlhttprequest/data/attr.qml | 78 + tests/auto/qml/qqmlxmlhttprequest/data/attr.xml | 1 + .../qqmlxmlhttprequest/data/callbackException.qml | 25 + tests/auto/qml/qqmlxmlhttprequest/data/cdata.qml | 133 + tests/auto/qml/qqmlxmlhttprequest/data/cdata.xml | 2 + .../qml/qqmlxmlhttprequest/data/constructor.qml | 14 + .../qml/qqmlxmlhttprequest/data/defaultState.qml | 30 + .../auto/qml/qqmlxmlhttprequest/data/document.qml | 56 + .../auto/qml/qqmlxmlhttprequest/data/document.xml | 3 + .../qqmlxmlhttprequest/data/domExceptionCodes.qml | 60 + tests/auto/qml/qqmlxmlhttprequest/data/element.qml | 145 + tests/auto/qml/qqmlxmlhttprequest/data/element.xml | 1 + .../data/getAllResponseHeaders.qml | 66 + .../data/getAllResponseHeaders_args.qml | 23 + .../data/getAllResponseHeaders_sent.qml | 20 + .../data/getAllResponseHeaders_unsent.qml | 16 + .../data/getResponseHeader.expect | 7 + .../qqmlxmlhttprequest/data/getResponseHeader.qml | 76 + .../data/getResponseHeader.reply | 8 + .../data/getResponseHeader_args.qml | 23 + .../data/getResponseHeader_sent.qml | 20 + .../data/getResponseHeader_unsent.qml | 16 + .../data/instanceStateValues.qml | 33 + .../qqmlxmlhttprequest/data/invalidMethodUsage.qml | 148 + tests/auto/qml/qqmlxmlhttprequest/data/open.qml | 54 + .../qqmlxmlhttprequest/data/open_arg_count.1.qml | 18 + .../qqmlxmlhttprequest/data/open_arg_count.2.qml | 18 + .../data/open_invalid_method.qml | 16 + .../qqmlxmlhttprequest/data/open_network.expect | 7 + .../qml/qqmlxmlhttprequest/data/open_network.reply | 3 + .../qml/qqmlxmlhttprequest/data/open_network.wait | 0 .../auto/qml/qqmlxmlhttprequest/data/open_sync.qml | 17 + .../auto/qml/qqmlxmlhttprequest/data/open_user.qml | 54 + .../qml/qqmlxmlhttprequest/data/open_username.qml | 54 + .../qml/qqmlxmlhttprequest/data/redirectError.qml | 23 + .../qml/qqmlxmlhttprequest/data/redirectRecur.qml | 23 + .../auto/qml/qqmlxmlhttprequest/data/redirects.qml | 22 + .../qqmlxmlhttprequest/data/redirecttarget.html | 1 + .../qml/qqmlxmlhttprequest/data/responseText.qml | 54 + .../data/responseXML_invalid.qml | 24 + .../qqmlxmlhttprequest/data/seconddocument.html | 1 + .../qqmlxmlhttprequest/data/send_alreadySent.qml | 28 + .../qml/qqmlxmlhttprequest/data/send_data.1.expect | 10 + .../qml/qqmlxmlhttprequest/data/send_data.1.qml | 22 + .../qml/qqmlxmlhttprequest/data/send_data.2.qml | 24 + .../qml/qqmlxmlhttprequest/data/send_data.3.qml | 24 + .../qml/qqmlxmlhttprequest/data/send_data.4.expect | 10 + .../qml/qqmlxmlhttprequest/data/send_data.4.qml | 24 + .../qml/qqmlxmlhttprequest/data/send_data.5.qml | 24 + .../qml/qqmlxmlhttprequest/data/send_data.6.expect | 10 + .../qml/qqmlxmlhttprequest/data/send_data.6.qml | 22 + .../qml/qqmlxmlhttprequest/data/send_data.7.qml | 24 + .../qml/qqmlxmlhttprequest/data/send_data.reply | 3 + .../qqmlxmlhttprequest/data/send_ignoreData.qml | 27 + .../qqmlxmlhttprequest/data/send_ignoreData.reply | 3 + .../data/send_ignoreData_DELETE.expect | 7 + .../data/send_ignoreData_GET.expect | 7 + .../data/send_ignoreData_HEAD.expect | 7 + .../qml/qqmlxmlhttprequest/data/send_unsent.qml | 16 + .../data/setRequestHeader.expect | 9 + .../qqmlxmlhttprequest/data/setRequestHeader.qml | 29 + .../qqmlxmlhttprequest/data/setRequestHeader.reply | 3 + .../data/setRequestHeader_args.qml | 18 + .../data/setRequestHeader_caseInsensitive.qml | 30 + .../data/setRequestHeader_illegalName.qml | 58 + .../data/setRequestHeader_sent.qml | 32 + .../data/setRequestHeader_unsent.qml | 17 + .../qqmlxmlhttprequest/data/staticStateValues.qml | 24 + .../qml/qqmlxmlhttprequest/data/status.200.reply | 3 + .../qml/qqmlxmlhttprequest/data/status.400.reply | 4 + .../qml/qqmlxmlhttprequest/data/status.404.reply | 3 + .../auto/qml/qqmlxmlhttprequest/data/status.expect | 7 + tests/auto/qml/qqmlxmlhttprequest/data/status.qml | 79 + .../qml/qqmlxmlhttprequest/data/statusText.qml | 79 + .../qml/qqmlxmlhttprequest/data/testdocument.html | 1 + tests/auto/qml/qqmlxmlhttprequest/data/text.qml | 129 + tests/auto/qml/qqmlxmlhttprequest/data/text.xml | 1 + tests/auto/qml/qqmlxmlhttprequest/data/utf16.html | 1 + tests/auto/qml/qqmlxmlhttprequest/data/utf16.qml | 29 + tests/auto/qml/qqmlxmlhttprequest/data/utf16.xml | Bin 0 -> 154 bytes .../qml/qqmlxmlhttprequest/qqmlxmlhttprequest.pro | 19 + .../qqmlxmlhttprequest/tst_qqmlxmlhttprequest.cpp | 1160 +++ .../auto/qml/qquickbinding/data/deletedObject.qml | 24 + .../auto/qml/qquickbinding/data/restoreBinding.qml | 26 + .../qquickbinding/data/restoreBindingWithLoop.qml | 23 + tests/auto/qml/qquickbinding/data/test-binding.qml | 16 + .../auto/qml/qquickbinding/data/test-binding2.qml | 16 + tests/auto/qml/qquickbinding/qquickbinding.pro | 15 + tests/auto/qml/qquickbinding/tst_qquickbinding.cpp | 197 + tests/auto/qml/qquickchangeset/qquickchangeset.pro | 9 + .../qml/qquickchangeset/tst_qquickchangeset.cpp | 812 ++ .../data/connection-targetchange.qml | 25 + .../data/connection-unknownsignals-ignored.qml | 8 + .../data/connection-unknownsignals-notarget.qml | 7 + .../data/connection-unknownsignals-parent.qml | 7 + .../data/connection-unknownsignals.qml | 7 + .../qml/qquickconnection/data/error-object.qml | 7 + .../qml/qquickconnection/data/error-property.qml | 5 + .../qml/qquickconnection/data/error-property2.qml | 5 + .../qml/qquickconnection/data/error-syntax.qml | 9 + .../qml/qquickconnection/data/moduleapi-target.qml | 22 + .../qml/qquickconnection/data/test-connection.qml | 10 + .../qml/qquickconnection/data/test-connection2.qml | 3 + .../qml/qquickconnection/data/test-connection3.qml | 3 + tests/auto/qml/qquickconnection/data/trimming.qml | 10 + .../auto/qml/qquickconnection/qquickconnection.pro | 15 + .../qml/qquickconnection/tst_qquickconnection.cpp | 292 + .../auto/qml/qquickfolderlistmodel/data/basic.qml | 5 + .../auto/qml/qquickfolderlistmodel/data/dummy.qml | 1 + .../qquickfolderlistmodel/data/resetFiltering.qml | 5 + .../data/resetfiltering/innerdir/test2.txt | 1 + .../data/resetfiltering/test.txt | 1 + .../qquickfolderlistmodel.pro | 14 + .../tst_qquickfolderlistmodel.cpp | 179 + .../qquicklistcompositor/qquicklistcompositor.pro | 9 + .../tst_qquicklistcompositor.cpp | 1637 ++++ tests/auto/qml/qquicklistmodel/data/enumerate.qml | 24 + tests/auto/qml/qquicklistmodel/data/model.qml | 26 + .../qml/qquicklistmodel/data/multipleroles.qml | 25 + tests/auto/qml/qquicklistmodel/data/script.js | 13 + .../qml/qquicklistmodel/data/setmodelcachelist.qml | 20 + .../qml/qquicklistmodel/data/signalhandlers.qml | 8 + .../qquicklistmodel/data/workerremoveelement.js | 8 + .../qquicklistmodel/data/workerremoveelement.qml | 33 + .../qml/qquicklistmodel/data/workerremovelist.js | 9 + .../qml/qquicklistmodel/data/workerremovelist.qml | 33 + tests/auto/qml/qquicklistmodel/data/workersync.js | 8 + tests/auto/qml/qquicklistmodel/data/workersync.qml | 32 + tests/auto/qml/qquicklistmodel/qquicklistmodel.pro | 15 + .../qml/qquicklistmodel/tst_qquicklistmodel.cpp | 1632 ++++ .../qml/qquickworkerscript/data/BaseWorker.qml | 24 + tests/auto/qml/qquickworkerscript/data/Global.js | 1 + .../data/externalObjectWorker.qml | 14 + tests/auto/qml/qquickworkerscript/data/script.js | 4 + .../qquickworkerscript/data/script_error_onCall.js | 6 + .../qquickworkerscript/data/script_error_onLoad.js | 5 + .../qquickworkerscript/data/script_fixed_return.js | 4 + .../qml/qquickworkerscript/data/script_include.js | 5 + .../qml/qquickworkerscript/data/script_pragma.js | 6 + .../qml/qquickworkerscript/data/stressDispose.js | 6 + .../qml/qquickworkerscript/data/stressDispose.qml | 13 + tests/auto/qml/qquickworkerscript/data/worker.qml | 5 + .../data/worker_error_onCall.qml | 6 + .../data/worker_error_onLoad.qml | 7 + .../qml/qquickworkerscript/data/worker_include.qml | 5 + .../qml/qquickworkerscript/data/worker_pragma.qml | 6 + .../qml/qquickworkerscript/qquickworkerscript.pro | 15 + .../qquickworkerscript/tst_qquickworkerscript.cpp | 300 + tests/auto/qml/runall.sh | 100 + tests/auto/qml/v4/data/conditionalExpr.qml | 6 + tests/auto/qml/v4/data/doubleBoolJump.qml | 18 + tests/auto/qml/v4/data/fetchException.qml | 6 + tests/auto/qml/v4/data/logicalOr.2.qml | 6 + tests/auto/qml/v4/data/logicalOr.qml | 6 + tests/auto/qml/v4/data/nestedLogicalOr.qml | 14 + tests/auto/qml/v4/data/nestedObjectAccess.qml | 5 + tests/auto/qml/v4/data/nullQObject.qml | 7 + tests/auto/qml/v4/data/qrealToIntRounding.qml | 10 + tests/auto/qml/v4/data/qtbug_21883.qml | 5 + tests/auto/qml/v4/data/qtbug_22816.qml | 18 + tests/auto/qml/v4/data/stringComparison.qml | 34 + .../data/subscriptionsInConditionalExpressions.qml | 11 + tests/auto/qml/v4/data/unaryMinus.qml | 24 + tests/auto/qml/v4/data/unaryPlus.qml | 24 + tests/auto/qml/v4/data/unnecessaryReeval.qml | 7 + tests/auto/qml/v4/testtypes.cpp | 49 + tests/auto/qml/v4/testtypes.h | 83 + tests/auto/qml/v4/tst_v4.cpp | 353 + tests/auto/qml/v4/v4.pro | 17 + tests/auto/qmldevtools/compile/tst_compile.cpp | 10 +- tests/auto/qmltest/createbenchmark/item.qml | 2 +- .../qmltest/qdeclarativebinding/tst_binding.qml | 75 - .../qmltest/qdeclarativebinding/tst_binding2.qml | 70 - tests/auto/qmltest/qmltest.pro | 2 +- tests/auto/qmltest/qqmlbinding/tst_binding.qml | 75 + tests/auto/qmltest/qqmlbinding/tst_binding2.qml | 70 + tests/auto/qtquick2/examples/data/dummytest.qml | 6 - .../examples/data/webbrowser/webbrowser.qml | 6 - tests/auto/qtquick2/examples/examples.pro | 10 - tests/auto/qtquick2/examples/tst_examples.cpp | 307 - tests/auto/qtquick2/geometry/geometry.pro | 9 - tests/auto/qtquick2/geometry/tst_geometry.cpp | 181 - tests/auto/qtquick2/nodes/nodes.pro | 9 - tests/auto/qtquick2/nodes/tst_nodestest.cpp | 354 - .../data/tst_numberanimation.qml | 38 - .../qdeclarativeanimationcontroller.pro | 10 - .../tst_qdeclarativeanimationcontroller.cpp | 42 - .../qdeclarativeanimations/data/Double.qml | 14 - .../qdeclarativeanimations/data/attached.qml | 34 - .../qdeclarativeanimations/data/badproperty1.qml | 21 - .../qdeclarativeanimations/data/badproperty2.qml | 21 - .../qdeclarativeanimations/data/badtype1.qml | 12 - .../qdeclarativeanimations/data/badtype2.qml | 12 - .../qdeclarativeanimations/data/badtype3.qml | 12 - .../qdeclarativeanimations/data/badtype4.qml | 27 - .../data/disabledTransition.qml | 30 - .../qdeclarativeanimations/data/dontAutoStart.qml | 18 - .../qdeclarativeanimations/data/dontStart.qml | 19 - .../qdeclarativeanimations/data/dontStart2.qml | 19 - .../qdeclarativeanimations/data/dotproperty.qml | 24 - .../data/doubleRegistrationBug.qml | 8 - .../qdeclarativeanimations/data/looping.qml | 16 - .../qdeclarativeanimations/data/mixedtype1.qml | 25 - .../qdeclarativeanimations/data/mixedtype2.qml | 25 - .../data/nonTransitionBug.qml | 30 - .../qdeclarativeanimations/data/pathAnimation.qml | 27 - .../qdeclarativeanimations/data/pathAnimation2.qml | 26 - .../data/pathAnimationNoStart.qml | 27 - .../data/pathInterpolator.qml | 13 - .../data/pathInterpolatorBack.qml | 11 - .../data/pathInterpolatorBack2.qml | 10 - .../qdeclarativeanimations/data/pathTransition.qml | 41 - .../data/pauseBindingBug.qml | 17 - .../qdeclarativeanimations/data/pauseBug.qml | 7 - .../qdeclarativeanimations/data/properties.qml | 14 - .../qdeclarativeanimations/data/properties2.qml | 14 - .../qdeclarativeanimations/data/properties3.qml | 14 - .../qdeclarativeanimations/data/properties4.qml | 14 - .../qdeclarativeanimations/data/properties5.qml | 14 - .../data/propertiesTransition.qml | 29 - .../data/propertiesTransition2.qml | 29 - .../data/propertiesTransition3.qml | 29 - .../data/propertiesTransition4.qml | 29 - .../data/propertiesTransition5.qml | 29 - .../data/propertiesTransition6.qml | 29 - .../data/propertiesTransition7.qml | 29 - .../qdeclarativeanimations/data/reanchor.qml | 46 - .../data/registrationBug.qml | 18 - .../qdeclarativeanimations/data/reparent.qml | 56 - .../qdeclarativeanimations/data/rotation.qml | 48 - .../qdeclarativeanimations/data/runningTrueBug.qml | 30 - .../data/transitionAssignmentBug.qml | 12 - .../qdeclarativeanimations/data/valuesource.qml | 14 - .../qdeclarativeanimations/data/valuesource2.qml | 14 - .../qdeclarativeanimations.pro | 18 - .../tst_qdeclarativeanimations.cpp | 1319 --- .../qdeclarativeapplication.pro | 7 - .../tst_qdeclarativeapplication.cpp | 159 - .../qdeclarativebehaviors/data/binding.qml | 26 - .../qtquick2/qdeclarativebehaviors/data/color.qml | 24 - .../qdeclarativebehaviors/data/cpptrigger.qml | 11 - .../data/delayedRegistration.qml | 25 - .../qdeclarativebehaviors/data/disabled.qml | 27 - .../qdeclarativebehaviors/data/dontStart.qml | 18 - .../qtquick2/qdeclarativebehaviors/data/empty.qml | 23 - .../qdeclarativebehaviors/data/explicit.qml | 26 - .../qdeclarativebehaviors/data/groupProperty.qml | 23 - .../qdeclarativebehaviors/data/groupProperty2.qml | 23 - .../data/groupedPropertyCrash.qml | 10 - .../qtquick2/qdeclarativebehaviors/data/loop.qml | 19 - .../qdeclarativebehaviors/data/nonSelecting2.qml | 26 - .../qtquick2/qdeclarativebehaviors/data/parent.qml | 28 - .../qdeclarativebehaviors/data/qtbug12295.qml | 17 - .../data/reassignedAnimation.qml | 32 - .../qdeclarativebehaviors/data/runningTrue.qml | 20 - .../qdeclarativebehaviors/data/scripttrigger.qml | 16 - .../qtquick2/qdeclarativebehaviors/data/simple.qml | 26 - .../data/startOnCompleted.qml | 15 - .../qdeclarativebehaviors/data/startup.qml | 17 - .../qdeclarativebehaviors/data/startup2.qml | 16 - .../qdeclarativebehaviors/data/valueType.qml | 13 - .../qdeclarativebehaviors.pro | 15 - .../tst_qdeclarativebehaviors.cpp | 473 - .../qdeclarativefontloader/data/daniel.ttf | Bin 51984 -> 0 bytes .../qtquick2/qdeclarativefontloader/data/dummy.ttf | 0 .../qdeclarativefontloader/data/qtbug-20268.qml | 27 - .../qdeclarativefontloader/data/tarzeau_ocr_a.ttf | Bin 24544 -> 0 bytes .../qdeclarativefontloader.pro | 17 - .../tst_qdeclarativefontloader.cpp | 255 - tests/auto/qtquick2/qdeclarativepath/data/arc.qml | 11 - .../qtquick2/qdeclarativepath/data/closedcurve.qml | 9 - .../auto/qtquick2/qdeclarativepath/data/curve.qml | 9 - tests/auto/qtquick2/qdeclarativepath/data/svg.qml | 5 - .../qtquick2/qdeclarativepath/qdeclarativepath.pro | 15 - .../qdeclarativepath/tst_qdeclarativepath.cpp | 199 - .../qdeclarativepixmapcache/data/exists.png | Bin 2738 -> 0 bytes .../qdeclarativepixmapcache/data/exists1.png | Bin 2738 -> 0 bytes .../qdeclarativepixmapcache/data/exists2.png | Bin 2738 -> 0 bytes .../qdeclarativepixmapcache/data/http/exists.png | Bin 2738 -> 0 bytes .../qdeclarativepixmapcache/data/http/exists1.png | Bin 2738 -> 0 bytes .../qdeclarativepixmapcache/data/http/exists2.png | Bin 2738 -> 0 bytes .../qdeclarativepixmapcache/data/http/exists3.png | Bin 2738 -> 0 bytes .../qdeclarativepixmapcache/data/http/exists4.png | Bin 2738 -> 0 bytes .../qdeclarativepixmapcache/data/http/exists5.png | Bin 2738 -> 0 bytes .../qdeclarativepixmapcache/data/http/exists6.png | Bin 2738 -> 0 bytes .../qdeclarativepixmapcache/data/http/exists7.png | Bin 2738 -> 0 bytes .../qdeclarativepixmapcache/data/http/exists8.png | Bin 2738 -> 0 bytes .../qdeclarativepixmapcache/data/massive.png | Bin 31834 -> 0 bytes .../qdeclarativepixmapcache.pro | 21 - .../tst_qdeclarativepixmapcache.cpp | 467 - .../data/deleteOnUpdate.qml | 27 - .../data/simpleanimation.qml | 12 - .../data/smoothedanimation1.qml | 3 - .../data/smoothedanimation2.qml | 5 - .../data/smoothedanimation3.qml | 6 - .../data/smoothedanimationBehavior.qml | 24 - .../data/smoothedanimationValueSource.qml | 13 - .../qdeclarativesmoothedanimation.pro | 15 - .../tst_qdeclarativesmoothedanimation.cpp | 242 - .../data/springanimation1.qml | 4 - .../data/springanimation2.qml | 16 - .../data/springanimation3.qml | 8 - .../qdeclarativespringanimation.pro | 15 - .../tst_qdeclarativespringanimation.cpp | 133 - .../qdeclarativestates/data/ExtendedRectangle.qml | 19 - .../data/Implementation/MyType.qml | 32 - .../data/Implementation/images/qt-logo.png | Bin 5149 -> 0 bytes .../qdeclarativestates/data/QTBUG-14830.qml | 29 - .../qdeclarativestates/data/anchorChanges1.qml | 23 - .../qdeclarativestates/data/anchorChanges2.qml | 21 - .../qdeclarativestates/data/anchorChanges3.qml | 29 - .../qdeclarativestates/data/anchorChanges4.qml | 22 - .../qdeclarativestates/data/anchorChanges5.qml | 22 - .../qdeclarativestates/data/anchorChangesCrash.qml | 14 - .../qdeclarativestates/data/anchorRewindBug.qml | 37 - .../qdeclarativestates/data/anchorRewindBug2.qml | 25 - .../data/attachedPropertyChanges.qml | 20 - .../data/autoStateAtStartupRestoreBug.qml | 18 - .../qdeclarativestates/data/avoidFastForward.qml | 17 - .../qdeclarativestates/data/basicBinding.qml | 12 - .../qdeclarativestates/data/basicBinding2.qml | 12 - .../qdeclarativestates/data/basicBinding3.qml | 13 - .../qdeclarativestates/data/basicBinding4.qml | 17 - .../qdeclarativestates/data/basicChanges.qml | 10 - .../qdeclarativestates/data/basicChanges2.qml | 15 - .../qdeclarativestates/data/basicChanges3.qml | 15 - .../qdeclarativestates/data/basicChanges4.qml | 19 - .../qdeclarativestates/data/basicExtension.qml | 16 - .../qtquick2/qdeclarativestates/data/deleting.qml | 11 - .../qdeclarativestates/data/deletingState.qml | 13 - .../qdeclarativestates/data/editProperties.qml | 34 - .../qtquick2/qdeclarativestates/data/explicit.qml | 15 - .../qdeclarativestates/data/extendsBug.qml | 26 - .../qdeclarativestates/data/fakeExtension.qml | 16 - .../qdeclarativestates/data/illegalObj.qml | 12 - .../qdeclarativestates/data/illegalTempState.qml | 21 - .../qtquick2/qdeclarativestates/data/image.png | Bin 173 -> 0 bytes .../qdeclarativestates/data/legalTempState.qml | 23 - .../qdeclarativestates/data/nonExistantProp.qml | 11 - .../qdeclarativestates/data/parentChange1.qml | 37 - .../qdeclarativestates/data/parentChange2.qml | 31 - .../qdeclarativestates/data/parentChange3.qml | 42 - .../qdeclarativestates/data/parentChange4.qml | 30 - .../qdeclarativestates/data/parentChange5.qml | 30 - .../qdeclarativestates/data/parentChange6.qml | 30 - .../qdeclarativestates/data/propertyErrors.qml | 10 - .../qtquick2/qdeclarativestates/data/reset.qml | 19 - .../qdeclarativestates/data/restoreEntryValues.qml | 14 - .../qdeclarativestates/data/returnToBase.qml | 21 - .../qdeclarativestates/data/revertListBug.qml | 47 - .../qtquick2/qdeclarativestates/data/script.qml | 10 - .../qdeclarativestates/data/signalOverride.qml | 18 - .../qdeclarativestates/data/signalOverride2.qml | 9 - .../data/signalOverrideCrash.qml | 15 - .../data/signalOverrideCrash2.qml | 24 - .../data/signalOverrideCrash3.qml | 27 - .../qdeclarativestates/data/unnamedWhen.qml | 14 - .../qdeclarativestates/data/urlResolution.qml | 12 - .../qdeclarativestates/data/whenOrdering.qml | 11 - .../qdeclarativestates/qdeclarativestates.pro | 14 - .../qdeclarativestates/tst_qdeclarativestates.cpp | 1608 ---- .../qdeclarativestyledtext.pro | 8 - .../tst_qdeclarativestyledtext.cpp | 185 - .../qdeclarativesystempalette.pro | 8 - .../tst_qdeclarativesystempalette.cpp | 185 - .../qdeclarativetimer/qdeclarativetimer.pro | 8 - .../qdeclarativetimer/tst_qdeclarativetimer.cpp | 393 - .../qdeclarativexmllistmodel/data/empty.xml | 0 .../qtquick2/qdeclarativexmllistmodel/data/get.qml | 61 - .../qdeclarativexmllistmodel/data/model.qml | 11 - .../qdeclarativexmllistmodel/data/model.xml | 54 - .../qdeclarativexmllistmodel/data/model2.xml | 14 - .../data/propertychanges.qml | 11 - .../qdeclarativexmllistmodel/data/recipes.qml | 11 - .../qdeclarativexmllistmodel/data/recipes.xml | 90 - .../qdeclarativexmllistmodel/data/roleCrash.qml | 8 - .../qdeclarativexmllistmodel/data/roleErrors.qml | 11 - .../qdeclarativexmllistmodel/data/roleKeys.qml | 13 - .../qdeclarativexmllistmodel/data/testtypes.qml | 8 - .../qdeclarativexmllistmodel/data/unique.qml | 9 - .../qdeclarativexmllistmodel.pro | 15 - .../tst_qdeclarativexmllistmodel.cpp | 962 --- .../qquickaccessible/data/checkbuttons.qml | 47 - .../qtquick2/qquickaccessible/data/hittest.qml | 176 - .../qtquick2/qquickaccessible/data/pushbutton.qml | 15 - .../qtquick2/qquickaccessible/data/statictext.qml | 25 - .../qquickaccessible/data/widgets/TextRect.qml | 26 - .../qtquick2/qquickaccessible/qquickaccessible.pro | 25 - .../qquickaccessible/tst_qquickaccessible.cpp | 410 - tests/auto/qtquick2/qquickanchors/data/anchors.qml | 162 - .../auto/qtquick2/qquickanchors/data/centerin.qml | 18 - .../qquickanchors/data/centerinRotation.qml | 17 - tests/auto/qtquick2/qquickanchors/data/crash1.qml | 11 - tests/auto/qtquick2/qquickanchors/data/fill.qml | 14 - .../auto/qtquick2/qquickanchors/data/hvCenter.qml | 11 - tests/auto/qtquick2/qquickanchors/data/loop1.qml | 8 - tests/auto/qtquick2/qquickanchors/data/loop2.qml | 20 - tests/auto/qtquick2/qquickanchors/data/margins.qml | 13 - .../auto/qtquick2/qquickanchors/qquickanchors.pro | 16 - .../qtquick2/qquickanchors/tst_qquickanchors.cpp | 669 -- .../qtquick2/qquickanimatedimage/data/colors.gif | Bin 505 -> 0 bytes .../qtquick2/qquickanimatedimage/data/colors.qml | 5 - .../qtquick2/qquickanimatedimage/data/hearts.gif | Bin 6524 -> 0 bytes .../qtquick2/qquickanimatedimage/data/hearts.qml | 6 - .../auto/qtquick2/qquickanimatedimage/data/qmldir | 1 - .../qquickanimatedimage/data/qtbug-16520.qml | 17 - .../qtquick2/qquickanimatedimage/data/stickman.gif | Bin 164923 -> 0 bytes .../qtquick2/qquickanimatedimage/data/stickman.qml | 5 - .../qquickanimatedimage/data/stickmanerror1.qml | 6 - .../qquickanimatedimage/data/stickmanpause.qml | 7 - .../qquickanimatedimage/data/stickmanscaled.qml | 7 - .../qquickanimatedimage/data/stickmanstopped.qml | 6 - .../qquickanimatedimage/qquickanimatedimage.pro | 17 - .../tst_qquickanimatedimage.cpp | 374 - .../qquickborderimage/data/colors-mirror.png | Bin 5554 -> 0 bytes .../qquickborderimage/data/colors-round-quotes.sci | 7 - .../qquickborderimage/data/colors-round-remote.sci | 7 - .../qquickborderimage/data/colors-round.sci | 7 - .../qtquick2/qquickborderimage/data/colors.png | Bin 1655 -> 0 bytes .../qtquick2/qquickborderimage/data/heart200.png | Bin 7943 -> 0 bytes .../qtquick2/qquickborderimage/data/invalid.sci | 7 - .../qtquick2/qquickborderimage/data/mirror.qml | 7 - .../qquickborderimage/qquickborderimage.pro | 17 - .../qquickborderimage/tst_qquickborderimage.cpp | 373 - .../qquickcanvas/data/AnimationsWhileHidden.qml | 17 - tests/auto/qtquick2/qquickcanvas/data/Headless.qml | 33 - tests/auto/qtquick2/qquickcanvas/data/colors.png | Bin 1655 -> 0 bytes tests/auto/qtquick2/qquickcanvas/data/focus.qml | 11 - tests/auto/qtquick2/qquickcanvas/data/window.qml | 9 - tests/auto/qtquick2/qquickcanvas/qquickcanvas.pro | 20 - .../qtquick2/qquickcanvas/tst_qquickcanvas.cpp | 775 -- .../qtquick2/qquickcanvasitem/data/anim-gr.gif | Bin 241 -> 0 bytes .../qtquick2/qquickcanvasitem/data/anim-gr.png | Bin 460 -> 0 bytes .../qquickcanvasitem/data/anim-poster-gr.png | Bin 422 -> 0 bytes .../qtquick2/qquickcanvasitem/data/background.png | Bin 86 -> 0 bytes .../auto/qtquick2/qquickcanvasitem/data/broken.png | Bin 87 -> 0 bytes .../qquickcanvasitem/data/ggrr-256x256.png | Bin 120 -> 0 bytes .../qtquick2/qquickcanvasitem/data/green-16x16.png | Bin 92 -> 0 bytes .../qtquick2/qquickcanvasitem/data/green-1x1.png | Bin 82 -> 0 bytes .../qquickcanvasitem/data/green-256x256.png | Bin 103 -> 0 bytes .../qtquick2/qquickcanvasitem/data/green-2x2.png | Bin 118 -> 0 bytes .../auto/qtquick2/qquickcanvasitem/data/green.png | Bin 87 -> 0 bytes .../qquickcanvasitem/data/grgr-256x256.png | Bin 130 -> 0 bytes .../qtquick2/qquickcanvasitem/data/red-16x16.png | Bin 130 -> 0 bytes tests/auto/qtquick2/qquickcanvasitem/data/red.png | Bin 87 -> 0 bytes .../qquickcanvasitem/data/redtransparent.png | Bin 109 -> 0 bytes .../qquickcanvasitem/data/rgrg-256x256.png | Bin 131 -> 0 bytes .../qquickcanvasitem/data/rrgg-256x256.png | Bin 120 -> 0 bytes .../qtquick2/qquickcanvasitem/data/testhelper.js | 18 - .../qtquick2/qquickcanvasitem/data/transparent.png | Bin 100 -> 0 bytes .../qquickcanvasitem/data/transparent50.png | Bin 155 -> 0 bytes .../qtquick2/qquickcanvasitem/data/tst_arc.qml | 487 -- .../qtquick2/qquickcanvasitem/data/tst_arcto.qml | 410 - .../qtquick2/qquickcanvasitem/data/tst_canvas.qml | 278 - .../qquickcanvasitem/data/tst_composite.qml | 380 - .../qtquick2/qquickcanvasitem/data/tst_context.qml | 73 - .../qquickcanvasitem/data/tst_drawimage.qml | 667 -- .../qquickcanvasitem/data/tst_fillStyle.qml | 113 - .../qquickcanvasitem/data/tst_fillrect.qml | 26 - .../qquickcanvasitem/data/tst_gradient.qml | 981 --- .../qtquick2/qquickcanvasitem/data/tst_line.qml | 831 -- .../qtquick2/qquickcanvasitem/data/tst_path.qml | 1443 ---- .../qtquick2/qquickcanvasitem/data/tst_pattern.qml | 34 - .../qtquick2/qquickcanvasitem/data/tst_pixel.qml | 30 - .../qtquick2/qquickcanvasitem/data/tst_shadow.qml | 59 - .../qtquick2/qquickcanvasitem/data/tst_state.qml | 390 - .../qquickcanvasitem/data/tst_strokeStyle.qml | 48 - .../qtquick2/qquickcanvasitem/data/tst_text.qml | 34 - .../qquickcanvasitem/data/tst_transform.qml | 487 -- .../auto/qtquick2/qquickcanvasitem/data/yellow.png | Bin 95 -> 0 bytes .../qtquick2/qquickcanvasitem/data/yellow75.png | Bin 150 -> 0 bytes .../qtquick2/qquickcanvasitem/qquickcanvasitem.pro | 34 - .../qquickcanvasitem/tst_qquickcanvasitem.cpp | 42 - tests/auto/qtquick2/qquickdrag/qquickdrag.pro | 9 - tests/auto/qtquick2/qquickdrag/tst_qquickdrag.cpp | 1034 --- .../qtquick2/qquickdroparea/qquickdroparea.pro | 9 - .../qtquick2/qquickdroparea/tst_qquickdroparea.cpp | 1117 --- .../qtquick2/qquickflickable/data/disabled.qml | 30 - .../qtquick2/qquickflickable/data/flickable01.qml | 4 - .../qtquick2/qquickflickable/data/flickable02.qml | 14 - .../qtquick2/qquickflickable/data/flickable03.qml | 14 - .../qtquick2/qquickflickable/data/flickable04.qml | 22 - .../data/flickableqgraphicswidget.qml | 7 - .../auto/qtquick2/qquickflickable/data/margins.qml | 19 - .../qquickflickable/data/nestedPressDelay.qml | 33 - .../auto/qtquick2/qquickflickable/data/resize.qml | 27 - tests/auto/qtquick2/qquickflickable/data/wheel.qml | 25 - .../qtquick2/qquickflickable/qquickflickable.pro | 15 - .../qquickflickable/tst_qquickflickable.cpp | 663 -- tests/auto/qtquick2/qquickflipable/data/crash.qml | 9 - .../qquickflipable/data/flipable-abort.qml | 10 - .../qtquick2/qquickflipable/data/test-flipable.qml | 9 - .../qtquick2/qquickflipable/qquickflipable.pro | 15 - .../qtquick2/qquickflipable/tst_qquickflipable.cpp | 135 - .../qtquick2/qquickfocusscope/data/canvasFocus.qml | 22 - .../auto/qtquick2/qquickfocusscope/data/chain.qml | 28 - .../qquickfocusscope/data/forceActiveFocus.qml | 26 - .../qtquick2/qquickfocusscope/data/forcefocus.qml | 81 - .../qtquick2/qquickfocusscope/data/qtBug13380.qml | 24 - .../qquickfocusscope/data/signalEmission.qml | 33 - tests/auto/qtquick2/qquickfocusscope/data/test.qml | 77 - .../auto/qtquick2/qquickfocusscope/data/test2.qml | 39 - .../auto/qtquick2/qquickfocusscope/data/test3.qml | 52 - .../auto/qtquick2/qquickfocusscope/data/test4.qml | 76 - .../auto/qtquick2/qquickfocusscope/data/test5.qml | 84 - .../qtquick2/qquickfocusscope/qquickfocusscope.pro | 14 - .../qquickfocusscope/tst_qquickfocusscope.cpp | 636 -- .../qtquick2/qquickgridview/data/ComponentView.qml | 14 - .../qquickgridview/data/addTransitions.qml | 129 - .../qtquick2/qquickgridview/data/asyncloader.qml | 36 - .../qquickgridview/data/attachedSignals.qml | 27 - .../qquickgridview/data/creationContext.qml | 5 - .../qtquick2/qquickgridview/data/displaygrid.qml | 39 - tests/auto/qtquick2/qquickgridview/data/footer.qml | 48 - .../qquickgridview/data/gridview-enforcerange.qml | 58 - .../qquickgridview/data/gridview-initCurrent.qml | 66 - .../qquickgridview/data/gridview-noCurrent.qml | 52 - .../qtquick2/qquickgridview/data/gridview1.qml | 69 - .../qtquick2/qquickgridview/data/gridview2.qml | 26 - .../qtquick2/qquickgridview/data/gridview3.qml | 6 - .../qtquick2/qquickgridview/data/gridview4.qml | 11 - tests/auto/qtquick2/qquickgridview/data/header.qml | 40 - .../qquickgridview/data/manual-highlight.qml | 48 - .../auto/qtquick2/qquickgridview/data/margins.qml | 55 - .../qtquick2/qquickgridview/data/mirroring.qml | 43 - .../qquickgridview/data/moveTransitions.qml | 143 - .../qquickgridview/data/multipleTransitions.qml | 123 - .../qquickgridview/data/populateTransitions.qml | 103 - .../qquickgridview/data/propertychangestest.qml | 69 - .../qquickgridview/data/removeTransitions.qml | 146 - .../qtquick2/qquickgridview/data/resizeview.qml | 25 - .../auto/qtquick2/qquickgridview/data/setindex.qml | 29 - .../qtquick2/qquickgridview/data/snapOneRow.qml | 49 - .../qtquick2/qquickgridview/data/snapToRow.qml | 49 - .../qtquick2/qquickgridview/data/unaligned.qml | 15 - .../qquickgridview/data/unrequestedItems.qml | 71 - .../qtquick2/qquickgridview/qquickgridview.pro | 15 - .../qtquick2/qquickgridview/tst_qquickgridview.cpp | 5075 ----------- .../auto/qtquick2/qquickimage/data/aspectratio.qml | 6 - tests/auto/qtquick2/qquickimage/data/big.jpeg | Bin 1700081 -> 0 bytes tests/auto/qtquick2/qquickimage/data/big256.png | Bin 3566 -> 0 bytes tests/auto/qtquick2/qquickimage/data/colors.png | Bin 1655 -> 0 bytes tests/auto/qtquick2/qquickimage/data/colors1.png | Bin 1655 -> 0 bytes tests/auto/qtquick2/qquickimage/data/green.png | Bin 314 -> 0 bytes .../auto/qtquick2/qquickimage/data/heart-win32.png | Bin 12621 -> 0 bytes tests/auto/qtquick2/qquickimage/data/heart.png | Bin 12577 -> 0 bytes tests/auto/qtquick2/qquickimage/data/heart.svg | 55 - .../qtquick2/qquickimage/data/heart200-win32.png | Bin 8062 -> 0 bytes tests/auto/qtquick2/qquickimage/data/heart200.png | Bin 8063 -> 0 bytes tests/auto/qtquick2/qquickimage/data/htiling.qml | 11 - tests/auto/qtquick2/qquickimage/data/mirror.qml | 11 - .../auto/qtquick2/qquickimage/data/nullpixmap.qml | 6 - tests/auto/qtquick2/qquickimage/data/pattern.png | Bin 1371 -> 0 bytes .../auto/qtquick2/qquickimage/data/qtbug_16389.qml | 30 - .../auto/qtquick2/qquickimage/data/qtbug_22125.qml | 44 - tests/auto/qtquick2/qquickimage/data/rect.png | Bin 171 -> 0 bytes .../auto/qtquick2/qquickimage/data/sourceSize.qml | 7 - tests/auto/qtquick2/qquickimage/data/vtiling.qml | 11 - tests/auto/qtquick2/qquickimage/qquickimage.pro | 17 - .../auto/qtquick2/qquickimage/tst_qquickimage.cpp | 749 -- tests/auto/qtquick2/qquickitem/data/order.1.qml | 7 - tests/auto/qtquick2/qquickitem/data/order.2.qml | 7 - .../qtquick2/qquickitem/data/polishOnCompleted.qml | 11 - tests/auto/qtquick2/qquickitem/qquickitem.pro | 14 - tests/auto/qtquick2/qquickitem/tst_qquickitem.cpp | 1468 ---- .../qtquick2/qquickitem2/data/childrenProperty.qml | 14 - .../qtquick2/qquickitem2/data/childrenRect.qml | 27 - .../qtquick2/qquickitem2/data/childrenRectBug.qml | 23 - .../qtquick2/qquickitem2/data/childrenRectBug2.qml | 53 - .../qtquick2/qquickitem2/data/childrenRectBug3.qml | 15 - .../qtquick2/qquickitem2/data/implicitsize.qml | 19 - .../qquickitem2/data/keynavigationtest.qml | 87 - .../data/keynavigationtest_implicit.qml | 68 - tests/auto/qtquick2/qquickitem2/data/keysim.qml | 11 - .../qtquick2/qquickitem2/data/keyspriority.qml | 11 - tests/auto/qtquick2/qquickitem2/data/keystest.qml | 24 - .../qtquick2/qquickitem2/data/layoutmirroring.qml | 54 - .../qtquick2/qquickitem2/data/mapCoordinates.qml | 84 - .../auto/qtquick2/qquickitem2/data/parentLoop.qml | 14 - .../qtquick2/qquickitem2/data/propertychanges.qml | 10 - .../auto/qtquick2/qquickitem2/data/qtbug_16871.qml | 5 - .../qquickitem2/data/resourcesProperty.qml | 21 - .../qtquick2/qquickitem2/data/transformCrash.qml | 13 - .../qtquick2/qquickitem2/data/visiblechildren.qml | 143 - tests/auto/qtquick2/qquickitem2/qquickitem2.pro | 15 - tests/auto/qtquick2/qquickitem2/tst_qquickitem.cpp | 1380 --- .../qtquick2/qquickitemlayer/data/DisableLayer.qml | 18 - .../auto/qtquick2/qquickitemlayer/data/Effect.qml | 34 - .../auto/qtquick2/qquickitemlayer/data/Enabled.qml | 25 - .../qtquick2/qquickitemlayer/data/ItemEffect.qml | 23 - .../auto/qtquick2/qquickitemlayer/data/Mipmap.qml | 30 - .../qquickitemlayer/data/RectangleEffect.qml | 22 - .../qquickitemlayer/data/SamplerNameChange.qml | 18 - .../auto/qtquick2/qquickitemlayer/data/Smooth.qml | 23 - .../qtquick2/qquickitemlayer/data/SourceRect.qml | 33 - .../qquickitemlayer/data/TextureProvider.qml | 40 - .../qquickitemlayer/data/ToggleLayerAndEffect.qml | 23 - .../auto/qtquick2/qquickitemlayer/data/Visible.qml | 56 - .../auto/qtquick2/qquickitemlayer/data/ZOrder.qml | 52 - .../qtquick2/qquickitemlayer/data/ZOrderChange.qml | 50 - .../qtquick2/qquickitemlayer/qquickitemlayer.pro | 38 - .../qquickitemlayer/tst_qquickitemlayer.cpp | 436 - .../qtquick2/qquicklistview/data/ComponentView.qml | 16 - tests/auto/qtquick2/qquicklistview/data/Page.qml | 10 - .../qquicklistview/data/addTransitions.qml | 134 - .../qtquick2/qquicklistview/data/asyncloader.qml | 36 - .../qquicklistview/data/attachedSignals.qml | 24 - .../qquicklistview/data/creationContext.qml | 5 - .../qtquick2/qquicklistview/data/displaylist.qml | 50 - .../data/fillModelOnComponentCompleted.qml | 36 - tests/auto/qtquick2/qquicklistview/data/footer.qml | 46 - tests/auto/qtquick2/qquicklistview/data/header.qml | 39 - .../qtquick2/qquicklistview/data/headerfooter.qml | 26 - .../auto/qtquick2/qquicklistview/data/itemlist.qml | 46 - .../data/listview-enforcerange-nohighlight.qml | 61 - .../qquicklistview/data/listview-enforcerange.qml | 55 - .../qquicklistview/data/listview-initCurrent.qml | 64 - .../qquicklistview/data/listview-noCurrent.qml | 50 - .../data/listview-sections-package.qml | 72 - .../qquicklistview/data/listview-sections.qml | 64 - .../data/listview-sections_delegate.qml | 71 - .../qquicklistview/data/listviewtest-package.qml | 145 - .../qtquick2/qquicklistview/data/listviewtest.qml | 133 - .../qquicklistview/data/manual-highlight.qml | 47 - .../auto/qtquick2/qquicklistview/data/margins.qml | 47 - .../auto/qtquick2/qquicklistview/data/margins2.qml | 29 - .../qquicklistview/data/moveTransitions.qml | 141 - .../qquicklistview/data/multipleTransitions.qml | 121 - .../qquicklistview/data/populateTransitions.qml | 102 - .../qquicklistview/data/propertychangestest.qml | 71 - .../qtquick2/qquicklistview/data/qtbug-21742.qml | 36 - .../qtquick2/qquicklistview/data/qtbug14821.qml | 31 - .../qtquick2/qquicklistview/data/qtbug16037.qml | 37 - .../qquicklistview/data/removeTransitions.qml | 144 - .../qtquick2/qquicklistview/data/resizeview.qml | 25 - .../qtquick2/qquicklistview/data/rightToLeft.qml | 42 - .../qtquick2/qquicklistview/data/sizelessthan1.qml | 26 - .../qtquick2/qquicklistview/data/snapOneItem.qml | 49 - .../qtquick2/qquicklistview/data/snapToItem.qml | 49 - .../qquicklistview/data/strictlyenforcerange.qml | 29 - .../qquicklistview/data/unrequestedItems.qml | 63 - .../qtquick2/qquicklistview/incrementalmodel.cpp | 89 - .../qtquick2/qquicklistview/incrementalmodel.h | 68 - .../qtquick2/qquicklistview/qquicklistview.pro | 16 - .../qtquick2/qquicklistview/tst_qquicklistview.cpp | 5715 ------------ .../qtquick2/qquickloader/data/ActiveComponent.qml | 11 - .../qtquick2/qquickloader/data/AnchoredLoader.qml | 14 - .../qtquick2/qquickloader/data/BigComponent.qml | 5015 ----------- tests/auto/qtquick2/qquickloader/data/BlueRect.qml | 8 - .../qquickloader/data/CreationContextLoader.qml | 15 - .../qquickloader/data/GraphicsWidget250x250.qml | 5 - .../auto/qtquick2/qquickloader/data/GreenRect.qml | 7 - .../data/InitialPropertyValuesComponent.qml | 11 - .../qquickloader/data/InvalidSourceComponent.qml | 5 - tests/auto/qtquick2/qquickloader/data/NoResize.qml | 8 - .../qquickloader/data/NoResizeGraphicsWidget.qml | 9 - .../qtquick2/qquickloader/data/QTBUG_16928.qml | 23 - .../qtquick2/qquickloader/data/QTBUG_17114.qml | 18 - .../auto/qtquick2/qquickloader/data/Rect120x60.qml | 6 - .../qquickloader/data/SetSourceComponent.qml | 9 - .../data/SizeGraphicsWidgetToLoader.qml | 7 - .../data/SizeLoaderToGraphicsWidget.qml | 5 - .../auto/qtquick2/qquickloader/data/SizeToItem.qml | 5 - .../qtquick2/qquickloader/data/SizeToLoader.qml | 6 - tests/auto/qtquick2/qquickloader/data/VmeError.qml | 7 - tests/auto/qtquick2/qquickloader/data/active.1.qml | 31 - tests/auto/qtquick2/qquickloader/data/active.2.qml | 18 - tests/auto/qtquick2/qquickloader/data/active.3.qml | 18 - tests/auto/qtquick2/qquickloader/data/active.4.qml | 26 - tests/auto/qtquick2/qquickloader/data/active.5.qml | 18 - tests/auto/qtquick2/qquickloader/data/active.6.qml | 21 - tests/auto/qtquick2/qquickloader/data/active.7.qml | 14 - tests/auto/qtquick2/qquickloader/data/active.8.qml | 13 - .../qtquick2/qquickloader/data/asynchronous.qml | 16 - tests/auto/qtquick2/qquickloader/data/crash.qml | 14 - .../qtquick2/qquickloader/data/creationContext.qml | 8 - .../qtquick2/qquickloader/data/differentorigin.qml | 3 - .../qtquick2/qquickloader/data/implicitSize.qml | 28 - .../qquickloader/data/initialPropertyValues.1.qml | 22 - .../qquickloader/data/initialPropertyValues.2.qml | 20 - .../qquickloader/data/initialPropertyValues.3.qml | 18 - .../qquickloader/data/initialPropertyValues.4.qml | 22 - .../qquickloader/data/initialPropertyValues.5.qml | 20 - .../qquickloader/data/initialPropertyValues.6.qml | 25 - .../qquickloader/data/initialPropertyValues.7.qml | 29 - .../qquickloader/data/initialPropertyValues.8.qml | 20 - .../data/initialPropertyValues.binding.qml | 21 - .../data/initialPropertyValues.error.1.qml | 14 - .../data/initialPropertyValues.error.2.qml | 14 - .../data/initialPropertyValues.error.3.qml | 14 - .../data/initialPropertyValues.error.4.qml | 15 - tests/auto/qtquick2/qquickloader/data/nonItem.qml | 5 - tests/auto/qtquick2/qquickloader/data/parented.qml | 21 - tests/auto/qtquick2/qquickloader/data/qmldir | 1 - .../qtquick2/qquickloader/data/sameorigin-load.qml | 3 - .../auto/qtquick2/qquickloader/data/sameorigin.qml | 3 - .../auto/qtquick2/qquickloader/data/sizebound.qml | 30 - .../auto/qtquick2/qquickloader/data/vmeErrors.qml | 6 - tests/auto/qtquick2/qquickloader/qquickloader.pro | 19 - .../qtquick2/qquickloader/tst_qquickloader.cpp | 987 --- .../qtquick2/qquickmousearea/data/clickThrough.qml | 25 - .../qquickmousearea/data/clickThrough2.qml | 35 - .../qtquick2/qquickmousearea/data/clickandhold.qml | 13 - .../qtquick2/qquickmousearea/data/clicktwice.qml | 16 - .../qtquick2/qquickmousearea/data/doubleclick.qml | 16 - .../qtquick2/qquickmousearea/data/dragging.qml | 28 - .../qquickmousearea/data/dragproperties.qml | 28 - .../qtquick2/qquickmousearea/data/dragreset.qml | 28 - .../qquickmousearea/data/hoverPosition.qml | 17 - .../qquickmousearea/data/hoverPropagation.qml | 54 - .../qtquick2/qquickmousearea/data/hoverVisible.qml | 15 - .../qquickmousearea/data/noclickandhold.qml | 11 - .../qquickmousearea/data/pressedCanceled.qml | 18 - .../qquickmousearea/data/pressedOrdering.qml | 28 - .../qquickmousearea/data/preventstealing.qml | 24 - .../qtquick2/qquickmousearea/data/rejectEvent.qml | 28 - .../qquickmousearea/data/updateMousePosOnClick.qml | 20 - .../data/updateMousePosOnResize.qml | 43 - .../qtquick2/qquickmousearea/qquickmousearea.pro | 17 - .../qquickmousearea/tst_qquickmousearea.cpp | 806 -- .../qquickmultipointtoucharea/data/basic.qml | 15 - .../qquickmultipointtoucharea/data/inFlickable.qml | 31 - .../qquickmultipointtoucharea/data/nested.qml | 27 - .../data/nonOverlapping.qml | 32 - .../qquickmultipointtoucharea/data/properties.qml | 15 - .../qquickmultipointtoucharea/data/signalTest.qml | 30 - .../qquickmultipointtoucharea.pro | 11 - .../tst_qquickmultipointtoucharea.cpp | 727 -- .../qtquick2/qquickpathview/data/ComponentView.qml | 17 - .../qtquick2/qquickpathview/data/asyncloader.qml | 71 - .../qtquick2/qquickpathview/data/closedPath.qml | 24 - .../qquickpathview/data/creationContext.qml | 5 - .../qtquick2/qquickpathview/data/datamodel.qml | 38 - .../qtquick2/qquickpathview/data/displaypath.qml | 59 - .../auto/qtquick2/qquickpathview/data/dragpath.qml | 19 - .../qtquick2/qquickpathview/data/emptymodel.qml | 5 - .../qquickpathview/data/missingPercent.qml | 9 - .../auto/qtquick2/qquickpathview/data/openPath.qml | 10 - .../qtquick2/qquickpathview/data/pathUpdate.qml | 18 - .../data/pathUpdateOnStartChanged.qml | 38 - .../auto/qtquick2/qquickpathview/data/pathline.qml | 48 - .../auto/qtquick2/qquickpathview/data/pathtest.qml | 14 - .../qtquick2/qquickpathview/data/pathview0.qml | 85 - .../qtquick2/qquickpathview/data/pathview1.qml | 4 - .../qtquick2/qquickpathview/data/pathview2.qml | 57 - .../qtquick2/qquickpathview/data/pathview3.qml | 59 - .../qquickpathview/data/pathview_package.qml | 88 - .../qquickpathview/data/propertychanges.qml | 116 - .../qtquick2/qquickpathview/data/treemodel.qml | 19 - .../qtquick2/qquickpathview/data/undefinedpath.qml | 17 - tests/auto/qtquick2/qquickpathview/data/vdm.qml | 28 - .../qtquick2/qquickpathview/qquickpathview.pro | 15 - .../qtquick2/qquickpathview/tst_qquickpathview.cpp | 1458 ---- .../qquickpincharea/data/pinchproperties.qml | 50 - .../qtquick2/qquickpincharea/qquickpincharea.pro | 15 - .../qquickpincharea/tst_qquickpincharea.cpp | 404 - .../qquickpositioners/data/allInvisible.qml | 44 - .../data/attachedproperties-column.qml | 50 - .../data/attachedproperties-dynamic.qml | 44 - .../data/attachedproperties-flow.qml | 50 - .../data/attachedproperties-grid.qml | 50 - .../data/attachedproperties-row.qml | 50 - .../data/flow-testimplicitsize.qml | 19 - .../data/flowtest-toptobottom.qml | 44 - .../qtquick2/qquickpositioners/data/flowtest.qml | 43 - .../qquickpositioners/data/grid-animated.qml | 64 - .../data/grid-row-column-spacing.qml | 43 - .../qquickpositioners/data/grid-spacing.qml | 41 - .../qquickpositioners/data/grid-toptobottom.qml | 41 - .../qtquick2/qquickpositioners/data/gridtest.qml | 42 - .../qquickpositioners/data/gridzerocolumns.qml | 40 - .../data/horizontal-animated-disabled.qml | 40 - .../qquickpositioners/data/horizontal-animated.qml | 47 - .../qquickpositioners/data/horizontal-spacing.qml | 31 - .../qtquick2/qquickpositioners/data/horizontal.qml | 29 - .../qquickpositioners/data/propertychangestest.qml | 39 - .../qquickpositioners/data/rectangleComponent.qml | 11 - .../qquickpositioners/data/repeatertest.qml | 38 - .../qquickpositioners/data/vertical-animated.qml | 41 - .../qquickpositioners/data/vertical-spacing.qml | 28 - .../qtquick2/qquickpositioners/data/vertical.qml | 27 - .../qquickpositioners/qquickpositioners.pro | 14 - .../qquickpositioners/tst_qquickpositioners.cpp | 1472 ---- .../qtquick2/qquickrepeater/data/asyncloader.qml | 32 - .../qtquick2/qquickrepeater/data/initparent.qml | 12 - .../auto/qtquick2/qquickrepeater/data/intmodel.qml | 29 - .../auto/qtquick2/qquickrepeater/data/itemlist.qml | 68 - .../qtquick2/qquickrepeater/data/modelChanged.qml | 26 - .../auto/qtquick2/qquickrepeater/data/objlist.qml | 21 - .../qtquick2/qquickrepeater/data/properties.qml | 11 - .../qtquick2/qquickrepeater/data/repeater1.qml | 30 - .../qtquick2/qquickrepeater/data/repeater2.qml | 36 - .../qtquick2/qquickrepeater/qquickrepeater.pro | 15 - .../qtquick2/qquickrepeater/tst_qquickrepeater.cpp | 644 -- tests/auto/qtquick2/qquickscreen/data/screen.qml | 11 - tests/auto/qtquick2/qquickscreen/qquickscreen.pro | 10 - .../qtquick2/qquickscreen/tst_qquickscreen.cpp | 77 - .../qquickshadereffect/qquickshadereffect.pro | 8 - .../qquickshadereffect/tst_qquickshadereffect.cpp | 275 - .../qtquick2/qquickspriteimage/data/advance.qml | 66 - .../auto/qtquick2/qquickspriteimage/data/basic.qml | 60 - .../qquickspriteimage/data/squarefacesprite.png | Bin 496 -> 0 bytes .../qquickspriteimage/qquickspriteimage.pro | 15 - .../qquickspriteimage/tst_qquickspriteimage.cpp | 98 - tests/auto/qtquick2/qquicktext/data/alignments.qml | 41 - .../qtquick2/qquicktext/data/alignments_cb.png | Bin 496 -> 0 bytes .../qtquick2/qquicktext/data/alignments_cc.png | Bin 556 -> 0 bytes .../qtquick2/qquicktext/data/alignments_ct.png | Bin 533 -> 0 bytes .../qtquick2/qquicktext/data/alignments_lb.png | Bin 496 -> 0 bytes .../qtquick2/qquicktext/data/alignments_lc.png | Bin 535 -> 0 bytes .../qtquick2/qquicktext/data/alignments_lt.png | Bin 514 -> 0 bytes .../qtquick2/qquicktext/data/alignments_rb.png | Bin 505 -> 0 bytes .../qtquick2/qquicktext/data/alignments_rc.png | Bin 559 -> 0 bytes .../qtquick2/qquicktext/data/alignments_rt.png | Bin 539 -> 0 bytes .../qquicktext/data/embeddedImagesLocal.qml | 6 - .../qquicktext/data/embeddedImagesLocalError.qml | 6 - .../data/embeddedImagesLocalRelative.qml | 7 - .../qquicktext/data/embeddedImagesRemote.qml | 6 - .../qquicktext/data/embeddedImagesRemoteError.qml | 6 - .../data/embeddedImagesRemoteRelative.qml | 7 - .../auto/qtquick2/qquicktext/data/fontSizeMode.qml | 24 - .../data/horizontalAlignment_RightToLeft.qml | 23 - .../auto/qtquick2/qquicktext/data/http/exists.png | Bin 2738 -> 0 bytes .../qtquick2/qquicktext/data/images/face-sad.png | Bin 6148 -> 0 bytes .../qtquick2/qquicktext/data/images/heart200.png | Bin 8248 -> 0 bytes .../qtquick2/qquicktext/data/images/starfish_2.png | Bin 18243 -> 0 bytes .../auto/qtquick2/qquicktext/data/imgTagsElide.qml | 24 - .../qtquick2/qquicktext/data/imgTagsUpdates.qml | 12 - tests/auto/qtquick2/qquicktext/data/lineCount.qml | 15 - tests/auto/qtquick2/qquicktext/data/lineHeight.qml | 15 - tests/auto/qtquick2/qquicktext/data/lineLayout.qml | 35 - .../qquicktext/data/multilengthStrings.qml | 14 - .../qquicktext/data/multilengthStringsWrapped.qml | 16 - .../qtquick2/qquicktext/data/multilineelide.qml | 10 - .../auto/qtquick2/qquicktext/data/qtbug_14734.qml | 10 - tests/auto/qtquick2/qquicktext/data/rotated.qml | 18 - tests/auto/qtquick2/qquicktext/qquicktext.pro | 19 - tests/auto/qtquick2/qquicktext/tst_qquicktext.cpp | 2432 ------ tests/auto/qtquick2/qquicktextedit/data/Cursor.qml | 5 - .../qtquick2/qquicktextedit/data/CursorRect.qml | 8 - .../qtquick2/qquicktextedit/data/alignments.qml | 41 - .../qtquick2/qquicktextedit/data/alignments_cb.png | Bin 496 -> 0 bytes .../qtquick2/qquicktextedit/data/alignments_cc.png | Bin 556 -> 0 bytes .../qtquick2/qquicktextedit/data/alignments_ct.png | Bin 533 -> 0 bytes .../qtquick2/qquicktextedit/data/alignments_lb.png | Bin 496 -> 0 bytes .../qtquick2/qquicktextedit/data/alignments_lc.png | Bin 535 -> 0 bytes .../qtquick2/qquicktextedit/data/alignments_lt.png | Bin 514 -> 0 bytes .../qtquick2/qquicktextedit/data/alignments_rb.png | Bin 505 -> 0 bytes .../qtquick2/qquicktextedit/data/alignments_rc.png | Bin 559 -> 0 bytes .../qtquick2/qquicktextedit/data/alignments_rt.png | Bin 539 -> 0 bytes .../qtquick2/qquicktextedit/data/cursorTest.qml | 9 - .../qquicktextedit/data/cursorTestExternal.qml | 15 - .../qquicktextedit/data/cursorTestInline.qml | 15 - .../qtquick2/qquicktextedit/data/cursorVisible.qml | 6 - .../qquicktextedit/data/embeddedImagesLocal.qml | 6 - .../data/embeddedImagesLocalError.qml | 6 - .../data/embeddedImagesLocalRelative.qml | 7 - .../qquicktextedit/data/embeddedImagesRemote.qml | 6 - .../data/embeddedImagesRemoteError.qml | 6 - .../data/embeddedImagesRemoteRelative.qml | 7 - .../qquicktextedit/data/geometrySignals.qml | 12 - .../data/horizontalAlignment_RightToLeft.qml | 25 - .../qtquick2/qquicktextedit/data/http/ErrItem.qml | 7 - .../qtquick2/qquicktextedit/data/http/NormItem.qml | 6 - .../qquicktextedit/data/http/cursorHttpTest.qml | 22 - .../data/http/cursorHttpTestFail1.qml | 18 - .../data/http/cursorHttpTestFail2.qml | 18 - .../data/http/cursorHttpTestPass.qml | 18 - .../qtquick2/qquicktextedit/data/http/exists.png | Bin 2738 -> 0 bytes .../auto/qtquick2/qquicktextedit/data/http/qmldir | 4 - .../qquicktextedit/data/httpfail/FailItem.qml | 5 - .../qquicktextedit/data/httpslow/WaitItem.qml | 5 - .../qtquick2/qquicktextedit/data/inputContext.qml | 7 - .../qquicktextedit/data/inputMethodEvent.qml | 5 - .../qquicktextedit/data/inputmethodhints.qml | 6 - .../qtquick2/qquicktextedit/data/linkActivated.qml | 6 - .../qquicktextedit/data/mouseselection_default.qml | 7 - .../qquicktextedit/data/mouseselection_false.qml | 7 - .../data/mouseselection_false_words.qml | 8 - .../qquicktextedit/data/mouseselection_true.qml | 7 - .../data/mouseselection_true_words.qml | 8 - .../data/mouseselectionmode_characters.qml | 8 - .../data/mouseselectionmode_default.qml | 7 - .../data/mouseselectionmode_words.qml | 8 - .../qtquick2/qquicktextedit/data/navigation.qml | 24 - .../qquicktextedit/data/openInputPanel.qml | 7 - .../qquicktextedit/data/persistentSelection.qml | 8 - .../qtquick2/qquicktextedit/data/positionAt.qml | 9 - .../qtquick2/qquicktextedit/data/qtbug-22058.qml | 39 - .../auto/qtquick2/qquicktextedit/data/readOnly.qml | 12 - .../qtquick2/qquicktextedit/qquicktextedit.pro | 16 - .../qtquick2/qquicktextedit/tst_qquicktextedit.cpp | 3884 --------- .../auto/qtquick2/qquicktextinput/data/Cursor.qml | 5 - .../qtquick2/qquicktextinput/data/cursorTest.qml | 9 - .../qquicktextinput/data/cursorTestExternal.qml | 15 - .../qquicktextinput/data/cursorTestInline.qml | 15 - .../qquicktextinput/data/cursorVisible.qml | 6 - .../qtquick2/qquicktextinput/data/echoMode.qml | 11 - .../qquicktextinput/data/geometrySignals.qml | 12 - .../qquicktextinput/data/halign_center.png | Bin 293 -> 0 bytes .../qtquick2/qquicktextinput/data/halign_left.png | Bin 291 -> 0 bytes .../qtquick2/qquicktextinput/data/halign_right.png | Bin 292 -> 0 bytes .../qquicktextinput/data/horizontalAlignment.qml | 23 - .../data/horizontalAlignment_RightToLeft.qml | 24 - .../qtquick2/qquicktextinput/data/inputContext.qml | 8 - .../qquicktextinput/data/inputMethodEvent.qml | 6 - .../qtquick2/qquicktextinput/data/inputmethods.qml | 7 - tests/auto/qtquick2/qquicktextinput/data/masks.qml | 7 - .../qtquick2/qquicktextinput/data/maxLength.qml | 7 - .../qquicktextinput/data/mouseselection_true.qml | 7 - .../data/mouseselectionmode_characters.qml | 8 - .../data/mouseselectionmode_default.qml | 7 - .../data/mouseselectionmode_words.qml | 8 - .../qtquick2/qquicktextinput/data/navigation.qml | 24 - .../qquicktextinput/data/negativeDimensions.qml | 19 - .../qquicktextinput/data/openInputPanel.qml | 7 - .../qquicktextinput/data/persistentSelection.qml | 8 - .../qtquick2/qquicktextinput/data/positionAt.qml | 9 - .../qquicktextinput/data/preeditAutoScroll.qml | 7 - .../qquicktextinput/data/qtbug-19956double.qml | 15 - .../qquicktextinput/data/qtbug-19956int.qml | 15 - .../qquicktextinput/data/qtbug-19956regexp.qml | 13 - .../qtquick2/qquicktextinput/data/readOnly.qml | 12 - .../qtquick2/qquicktextinput/data/validators.qml | 29 - .../qtquick2/qquicktextinput/qquicktextinput.pro | 13 - .../qquicktextinput/tst_qquicktextinput.cpp | 4706 ---------- tests/auto/qtquick2/qquickview/data/error1.qml | 5 - .../qtquick2/qquickview/data/resizemodeitem.qml | 5 - tests/auto/qtquick2/qquickview/qquickview.pro | 13 - tests/auto/qtquick2/qquickview/tst_qquickview.cpp | 207 - .../qtquick2/qquickvisualdatamodel/data/create.qml | 22 - .../data/datalist-package.qml | 20 - .../qquickvisualdatamodel/data/datalist.qml | 18 - .../qquickvisualdatamodel/data/groups-invalid.qml | 14 - .../qquickvisualdatamodel/data/groups-package.qml | 52 - .../qtquick2/qquickvisualdatamodel/data/groups.qml | 46 - .../data/itemsDestroyed_listView.qml | 13 - .../data/itemsDestroyed_package.qml | 42 - .../data/itemsDestroyed_pathView.qml | 18 - .../data/itemsDestroyed_repeater.qml | 15 - .../data/listmodelproperties-package.qml | 51 - .../data/listmodelproperties.qml | 45 - .../qquickvisualdatamodel/data/modelproperties.qml | 21 - .../data/modelproperties2.qml | 21 - .../data/multipleroleproperties-package.qml | 46 - .../data/multipleroleproperties.qml | 41 - .../qquickvisualdatamodel/data/objectlist.qml | 19 - .../data/objectlistproperties-package.qml | 48 - .../data/objectlistproperties.qml | 43 - .../qquickvisualdatamodel/data/onChanged.qml | 87 - .../qquickvisualdatamodel/data/packageView.qml | 63 - .../qquickvisualdatamodel/data/singlerole1.qml | 10 - .../qquickvisualdatamodel/data/singlerole2.qml | 10 - .../data/singleroleproperties-package.qml | 45 - .../data/singleroleproperties.qml | 39 - .../data/stringlistproperties-package.qml | 45 - .../data/stringlistproperties.qml | 40 - .../qquickvisualdatamodel/data/visualdatamodel.qml | 12 - .../qquickvisualdatamodel.pro | 16 - .../tst_qquickvisualdatamodel.cpp | 3446 -------- tests/auto/qtquick2/qtquick2.pro | 70 - .../auto/qtquick2/rendernode/data/MessUpState.qml | 32 - .../auto/qtquick2/rendernode/data/RenderOrder.qml | 53 - tests/auto/qtquick2/rendernode/rendernode.pro | 18 - tests/auto/qtquick2/rendernode/tst_rendernode.cpp | 242 - tests/auto/qtquick2/shared/util.pri | 7 - tests/auto/qtquick2/shared/viewtestutil.cpp | 493 -- tests/auto/qtquick2/shared/viewtestutil.h | 180 - tests/auto/qtquick2/shared/visualtestutil.cpp | 71 - tests/auto/qtquick2/shared/visualtestutil.h | 112 - tests/auto/quick/examples/data/dummytest.qml | 6 + .../quick/examples/data/webbrowser/webbrowser.qml | 6 + tests/auto/quick/examples/examples.pro | 10 + tests/auto/quick/examples/tst_examples.cpp | 307 + tests/auto/quick/geometry/geometry.pro | 9 + tests/auto/quick/geometry/tst_geometry.cpp | 181 + tests/auto/quick/nodes/nodes.pro | 9 + tests/auto/quick/nodes/tst_nodestest.cpp | 354 + .../quick/qquickaccessible/data/checkbuttons.qml | 47 + tests/auto/quick/qquickaccessible/data/hittest.qml | 176 + .../quick/qquickaccessible/data/pushbutton.qml | 15 + .../quick/qquickaccessible/data/statictext.qml | 25 + .../qquickaccessible/data/widgets/TextRect.qml | 26 + .../quick/qquickaccessible/qquickaccessible.pro | 25 + .../qquickaccessible/tst_qquickaccessible.cpp | 410 + tests/auto/quick/qquickanchors/data/anchors.qml | 162 + tests/auto/quick/qquickanchors/data/centerin.qml | 18 + .../quick/qquickanchors/data/centerinRotation.qml | 17 + tests/auto/quick/qquickanchors/data/crash1.qml | 11 + tests/auto/quick/qquickanchors/data/fill.qml | 14 + tests/auto/quick/qquickanchors/data/hvCenter.qml | 11 + tests/auto/quick/qquickanchors/data/loop1.qml | 8 + tests/auto/quick/qquickanchors/data/loop2.qml | 20 + tests/auto/quick/qquickanchors/data/margins.qml | 13 + tests/auto/quick/qquickanchors/qquickanchors.pro | 16 + .../auto/quick/qquickanchors/tst_qquickanchors.cpp | 669 ++ .../auto/quick/qquickanimatedimage/data/colors.gif | Bin 0 -> 505 bytes .../auto/quick/qquickanimatedimage/data/colors.qml | 5 + .../auto/quick/qquickanimatedimage/data/hearts.gif | Bin 0 -> 6524 bytes .../auto/quick/qquickanimatedimage/data/hearts.qml | 6 + tests/auto/quick/qquickanimatedimage/data/qmldir | 1 + .../quick/qquickanimatedimage/data/qtbug-16520.qml | 17 + .../quick/qquickanimatedimage/data/stickman.gif | Bin 0 -> 164923 bytes .../quick/qquickanimatedimage/data/stickman.qml | 5 + .../qquickanimatedimage/data/stickmanerror1.qml | 6 + .../qquickanimatedimage/data/stickmanpause.qml | 7 + .../qquickanimatedimage/data/stickmanscaled.qml | 7 + .../qquickanimatedimage/data/stickmanstopped.qml | 6 + .../qquickanimatedimage/qquickanimatedimage.pro | 17 + .../tst_qquickanimatedimage.cpp | 374 + .../data/tst_numberanimation.qml | 38 + .../qquickanimationcontroller.pro | 10 + .../tst_qquickanimationcontroller.cpp | 42 + tests/auto/quick/qquickanimations/data/Double.qml | 14 + .../auto/quick/qquickanimations/data/attached.qml | 34 + .../quick/qquickanimations/data/badproperty1.qml | 21 + .../quick/qquickanimations/data/badproperty2.qml | 21 + .../auto/quick/qquickanimations/data/badtype1.qml | 12 + .../auto/quick/qquickanimations/data/badtype2.qml | 12 + .../auto/quick/qquickanimations/data/badtype3.qml | 12 + .../auto/quick/qquickanimations/data/badtype4.qml | 27 + .../qquickanimations/data/disabledTransition.qml | 30 + .../quick/qquickanimations/data/dontAutoStart.qml | 18 + .../auto/quick/qquickanimations/data/dontStart.qml | 19 + .../quick/qquickanimations/data/dontStart2.qml | 19 + .../quick/qquickanimations/data/dotproperty.qml | 24 + .../data/doubleRegistrationBug.qml | 8 + tests/auto/quick/qquickanimations/data/looping.qml | 16 + .../quick/qquickanimations/data/mixedtype1.qml | 25 + .../quick/qquickanimations/data/mixedtype2.qml | 25 + .../qquickanimations/data/nonTransitionBug.qml | 30 + .../quick/qquickanimations/data/pathAnimation.qml | 27 + .../quick/qquickanimations/data/pathAnimation2.qml | 26 + .../qquickanimations/data/pathAnimationNoStart.qml | 27 + .../qquickanimations/data/pathInterpolator.qml | 13 + .../qquickanimations/data/pathInterpolatorBack.qml | 11 + .../data/pathInterpolatorBack2.qml | 10 + .../quick/qquickanimations/data/pathTransition.qml | 41 + .../qquickanimations/data/pauseBindingBug.qml | 17 + .../auto/quick/qquickanimations/data/pauseBug.qml | 7 + .../quick/qquickanimations/data/properties.qml | 14 + .../quick/qquickanimations/data/properties2.qml | 14 + .../quick/qquickanimations/data/properties3.qml | 14 + .../quick/qquickanimations/data/properties4.qml | 14 + .../quick/qquickanimations/data/properties5.qml | 14 + .../qquickanimations/data/propertiesTransition.qml | 29 + .../data/propertiesTransition2.qml | 29 + .../data/propertiesTransition3.qml | 29 + .../data/propertiesTransition4.qml | 29 + .../data/propertiesTransition5.qml | 29 + .../data/propertiesTransition6.qml | 29 + .../data/propertiesTransition7.qml | 29 + .../auto/quick/qquickanimations/data/reanchor.qml | 46 + .../qquickanimations/data/registrationBug.qml | 18 + .../auto/quick/qquickanimations/data/reparent.qml | 56 + .../auto/quick/qquickanimations/data/rotation.qml | 48 + .../quick/qquickanimations/data/runningTrueBug.qml | 30 + .../data/transitionAssignmentBug.qml | 12 + .../quick/qquickanimations/data/valuesource.qml | 14 + .../quick/qquickanimations/data/valuesource2.qml | 14 + .../quick/qquickanimations/qquickanimations.pro | 18 + .../qquickanimations/tst_qquickanimations.cpp | 1319 +++ .../quick/qquickapplication/qquickapplication.pro | 7 + .../qquickapplication/tst_qquickapplication.cpp | 159 + tests/auto/quick/qquickbehaviors/data/binding.qml | 26 + tests/auto/quick/qquickbehaviors/data/color.qml | 24 + .../auto/quick/qquickbehaviors/data/cpptrigger.qml | 11 + .../qquickbehaviors/data/delayedRegistration.qml | 25 + tests/auto/quick/qquickbehaviors/data/disabled.qml | 27 + .../auto/quick/qquickbehaviors/data/dontStart.qml | 18 + tests/auto/quick/qquickbehaviors/data/empty.qml | 23 + tests/auto/quick/qquickbehaviors/data/explicit.qml | 26 + .../quick/qquickbehaviors/data/groupProperty.qml | 23 + .../quick/qquickbehaviors/data/groupProperty2.qml | 23 + .../qquickbehaviors/data/groupedPropertyCrash.qml | 10 + tests/auto/quick/qquickbehaviors/data/loop.qml | 19 + .../quick/qquickbehaviors/data/nonSelecting2.qml | 26 + tests/auto/quick/qquickbehaviors/data/parent.qml | 28 + .../auto/quick/qquickbehaviors/data/qtbug12295.qml | 17 + .../qquickbehaviors/data/reassignedAnimation.qml | 32 + .../quick/qquickbehaviors/data/runningTrue.qml | 20 + .../quick/qquickbehaviors/data/scripttrigger.qml | 16 + tests/auto/quick/qquickbehaviors/data/simple.qml | 26 + .../qquickbehaviors/data/startOnCompleted.qml | 15 + tests/auto/quick/qquickbehaviors/data/startup.qml | 17 + tests/auto/quick/qquickbehaviors/data/startup2.qml | 16 + .../auto/quick/qquickbehaviors/data/valueType.qml | 13 + .../auto/quick/qquickbehaviors/qquickbehaviors.pro | 15 + .../quick/qquickbehaviors/tst_qquickbehaviors.cpp | 473 + .../quick/qquickborderimage/data/colors-mirror.png | Bin 0 -> 5554 bytes .../qquickborderimage/data/colors-round-quotes.sci | 7 + .../qquickborderimage/data/colors-round-remote.sci | 7 + .../quick/qquickborderimage/data/colors-round.sci | 7 + tests/auto/quick/qquickborderimage/data/colors.png | Bin 0 -> 1655 bytes .../auto/quick/qquickborderimage/data/heart200.png | Bin 0 -> 7943 bytes .../auto/quick/qquickborderimage/data/invalid.sci | 7 + tests/auto/quick/qquickborderimage/data/mirror.qml | 7 + .../quick/qquickborderimage/qquickborderimage.pro | 17 + .../qquickborderimage/tst_qquickborderimage.cpp | 373 + .../qquickcanvas/data/AnimationsWhileHidden.qml | 17 + tests/auto/quick/qquickcanvas/data/Headless.qml | 33 + tests/auto/quick/qquickcanvas/data/colors.png | Bin 0 -> 1655 bytes tests/auto/quick/qquickcanvas/data/focus.qml | 11 + tests/auto/quick/qquickcanvas/data/window.qml | 9 + tests/auto/quick/qquickcanvas/qquickcanvas.pro | 20 + tests/auto/quick/qquickcanvas/tst_qquickcanvas.cpp | 775 ++ tests/auto/quick/qquickcanvasitem/data/anim-gr.gif | Bin 0 -> 241 bytes tests/auto/quick/qquickcanvasitem/data/anim-gr.png | Bin 0 -> 460 bytes .../quick/qquickcanvasitem/data/anim-poster-gr.png | Bin 0 -> 422 bytes .../quick/qquickcanvasitem/data/background.png | Bin 0 -> 86 bytes tests/auto/quick/qquickcanvasitem/data/broken.png | Bin 0 -> 87 bytes .../quick/qquickcanvasitem/data/ggrr-256x256.png | Bin 0 -> 120 bytes .../quick/qquickcanvasitem/data/green-16x16.png | Bin 0 -> 92 bytes .../auto/quick/qquickcanvasitem/data/green-1x1.png | Bin 0 -> 82 bytes .../quick/qquickcanvasitem/data/green-256x256.png | Bin 0 -> 103 bytes .../auto/quick/qquickcanvasitem/data/green-2x2.png | Bin 0 -> 118 bytes tests/auto/quick/qquickcanvasitem/data/green.png | Bin 0 -> 87 bytes .../quick/qquickcanvasitem/data/grgr-256x256.png | Bin 0 -> 130 bytes .../auto/quick/qquickcanvasitem/data/red-16x16.png | Bin 0 -> 130 bytes tests/auto/quick/qquickcanvasitem/data/red.png | Bin 0 -> 87 bytes .../quick/qquickcanvasitem/data/redtransparent.png | Bin 0 -> 109 bytes .../quick/qquickcanvasitem/data/rgrg-256x256.png | Bin 0 -> 131 bytes .../quick/qquickcanvasitem/data/rrgg-256x256.png | Bin 0 -> 120 bytes .../auto/quick/qquickcanvasitem/data/testhelper.js | 18 + .../quick/qquickcanvasitem/data/transparent.png | Bin 0 -> 100 bytes .../quick/qquickcanvasitem/data/transparent50.png | Bin 0 -> 155 bytes tests/auto/quick/qquickcanvasitem/data/tst_arc.qml | 487 ++ .../auto/quick/qquickcanvasitem/data/tst_arcto.qml | 410 + .../quick/qquickcanvasitem/data/tst_canvas.qml | 278 + .../quick/qquickcanvasitem/data/tst_composite.qml | 380 + .../quick/qquickcanvasitem/data/tst_context.qml | 73 + .../quick/qquickcanvasitem/data/tst_drawimage.qml | 667 ++ .../quick/qquickcanvasitem/data/tst_fillStyle.qml | 113 + .../quick/qquickcanvasitem/data/tst_fillrect.qml | 26 + .../quick/qquickcanvasitem/data/tst_gradient.qml | 981 +++ .../auto/quick/qquickcanvasitem/data/tst_line.qml | 831 ++ .../auto/quick/qquickcanvasitem/data/tst_path.qml | 1443 ++++ .../quick/qquickcanvasitem/data/tst_pattern.qml | 34 + .../auto/quick/qquickcanvasitem/data/tst_pixel.qml | 30 + .../quick/qquickcanvasitem/data/tst_shadow.qml | 59 + .../auto/quick/qquickcanvasitem/data/tst_state.qml | 390 + .../qquickcanvasitem/data/tst_strokeStyle.qml | 48 + .../auto/quick/qquickcanvasitem/data/tst_text.qml | 34 + .../quick/qquickcanvasitem/data/tst_transform.qml | 487 ++ tests/auto/quick/qquickcanvasitem/data/yellow.png | Bin 0 -> 95 bytes .../auto/quick/qquickcanvasitem/data/yellow75.png | Bin 0 -> 150 bytes .../quick/qquickcanvasitem/qquickcanvasitem.pro | 34 + .../qquickcanvasitem/tst_qquickcanvasitem.cpp | 42 + tests/auto/quick/qquickdrag/qquickdrag.pro | 9 + tests/auto/quick/qquickdrag/tst_qquickdrag.cpp | 1034 +++ tests/auto/quick/qquickdroparea/qquickdroparea.pro | 9 + .../quick/qquickdroparea/tst_qquickdroparea.cpp | 1117 +++ tests/auto/quick/qquickflickable/data/disabled.qml | 30 + .../quick/qquickflickable/data/flickable01.qml | 4 + .../quick/qquickflickable/data/flickable02.qml | 14 + .../quick/qquickflickable/data/flickable03.qml | 14 + .../quick/qquickflickable/data/flickable04.qml | 22 + .../data/flickableqgraphicswidget.qml | 7 + tests/auto/quick/qquickflickable/data/margins.qml | 19 + .../qquickflickable/data/nestedPressDelay.qml | 33 + tests/auto/quick/qquickflickable/data/resize.qml | 27 + tests/auto/quick/qquickflickable/data/wheel.qml | 25 + .../auto/quick/qquickflickable/qquickflickable.pro | 15 + .../quick/qquickflickable/tst_qquickflickable.cpp | 663 ++ tests/auto/quick/qquickflipable/data/crash.qml | 9 + .../quick/qquickflipable/data/flipable-abort.qml | 10 + .../quick/qquickflipable/data/test-flipable.qml | 9 + tests/auto/quick/qquickflipable/qquickflipable.pro | 15 + .../quick/qquickflipable/tst_qquickflipable.cpp | 135 + .../quick/qquickfocusscope/data/canvasFocus.qml | 22 + tests/auto/quick/qquickfocusscope/data/chain.qml | 28 + .../qquickfocusscope/data/forceActiveFocus.qml | 26 + .../quick/qquickfocusscope/data/forcefocus.qml | 81 + .../quick/qquickfocusscope/data/qtBug13380.qml | 24 + .../quick/qquickfocusscope/data/signalEmission.qml | 33 + tests/auto/quick/qquickfocusscope/data/test.qml | 77 + tests/auto/quick/qquickfocusscope/data/test2.qml | 39 + tests/auto/quick/qquickfocusscope/data/test3.qml | 52 + tests/auto/quick/qquickfocusscope/data/test4.qml | 76 + tests/auto/quick/qquickfocusscope/data/test5.qml | 84 + .../quick/qquickfocusscope/qquickfocusscope.pro | 14 + .../qquickfocusscope/tst_qquickfocusscope.cpp | 636 ++ tests/auto/quick/qquickfontloader/data/daniel.ttf | Bin 0 -> 51984 bytes tests/auto/quick/qquickfontloader/data/dummy.ttf | 0 .../quick/qquickfontloader/data/qtbug-20268.qml | 27 + .../quick/qquickfontloader/data/tarzeau_ocr_a.ttf | Bin 0 -> 24544 bytes .../quick/qquickfontloader/qquickfontloader.pro | 17 + .../qquickfontloader/tst_qquickfontloader.cpp | 255 + .../quick/qquickgridview/data/ComponentView.qml | 14 + .../quick/qquickgridview/data/addTransitions.qml | 129 + .../auto/quick/qquickgridview/data/asyncloader.qml | 36 + .../quick/qquickgridview/data/attachedSignals.qml | 27 + .../quick/qquickgridview/data/creationContext.qml | 5 + .../auto/quick/qquickgridview/data/displaygrid.qml | 39 + tests/auto/quick/qquickgridview/data/footer.qml | 48 + .../qquickgridview/data/gridview-enforcerange.qml | 58 + .../qquickgridview/data/gridview-initCurrent.qml | 66 + .../qquickgridview/data/gridview-noCurrent.qml | 52 + tests/auto/quick/qquickgridview/data/gridview1.qml | 69 + tests/auto/quick/qquickgridview/data/gridview2.qml | 26 + tests/auto/quick/qquickgridview/data/gridview3.qml | 6 + tests/auto/quick/qquickgridview/data/gridview4.qml | 11 + tests/auto/quick/qquickgridview/data/header.qml | 40 + .../quick/qquickgridview/data/manual-highlight.qml | 48 + tests/auto/quick/qquickgridview/data/margins.qml | 55 + tests/auto/quick/qquickgridview/data/mirroring.qml | 43 + .../quick/qquickgridview/data/moveTransitions.qml | 143 + .../qquickgridview/data/multipleTransitions.qml | 123 + .../qquickgridview/data/populateTransitions.qml | 103 + .../qquickgridview/data/propertychangestest.qml | 69 + .../qquickgridview/data/removeTransitions.qml | 146 + .../auto/quick/qquickgridview/data/resizeview.qml | 25 + tests/auto/quick/qquickgridview/data/setindex.qml | 29 + .../auto/quick/qquickgridview/data/snapOneRow.qml | 49 + tests/auto/quick/qquickgridview/data/snapToRow.qml | 49 + tests/auto/quick/qquickgridview/data/unaligned.qml | 15 + .../quick/qquickgridview/data/unrequestedItems.qml | 71 + tests/auto/quick/qquickgridview/qquickgridview.pro | 15 + .../quick/qquickgridview/tst_qquickgridview.cpp | 5075 +++++++++++ tests/auto/quick/qquickimage/data/aspectratio.qml | 6 + tests/auto/quick/qquickimage/data/big.jpeg | Bin 0 -> 1700081 bytes tests/auto/quick/qquickimage/data/big256.png | Bin 0 -> 3566 bytes tests/auto/quick/qquickimage/data/colors.png | Bin 0 -> 1655 bytes tests/auto/quick/qquickimage/data/colors1.png | Bin 0 -> 1655 bytes tests/auto/quick/qquickimage/data/green.png | Bin 0 -> 314 bytes tests/auto/quick/qquickimage/data/heart-win32.png | Bin 0 -> 12621 bytes tests/auto/quick/qquickimage/data/heart.png | Bin 0 -> 12577 bytes tests/auto/quick/qquickimage/data/heart.svg | 55 + .../auto/quick/qquickimage/data/heart200-win32.png | Bin 0 -> 8062 bytes tests/auto/quick/qquickimage/data/heart200.png | Bin 0 -> 8063 bytes tests/auto/quick/qquickimage/data/htiling.qml | 11 + tests/auto/quick/qquickimage/data/mirror.qml | 11 + tests/auto/quick/qquickimage/data/nullpixmap.qml | 6 + tests/auto/quick/qquickimage/data/pattern.png | Bin 0 -> 1371 bytes tests/auto/quick/qquickimage/data/qtbug_16389.qml | 30 + tests/auto/quick/qquickimage/data/qtbug_22125.qml | 44 + tests/auto/quick/qquickimage/data/rect.png | Bin 0 -> 171 bytes tests/auto/quick/qquickimage/data/sourceSize.qml | 7 + tests/auto/quick/qquickimage/data/vtiling.qml | 11 + tests/auto/quick/qquickimage/qquickimage.pro | 17 + tests/auto/quick/qquickimage/tst_qquickimage.cpp | 749 ++ tests/auto/quick/qquickitem/data/order.1.qml | 7 + tests/auto/quick/qquickitem/data/order.2.qml | 7 + .../quick/qquickitem/data/polishOnCompleted.qml | 11 + tests/auto/quick/qquickitem/qquickitem.pro | 14 + tests/auto/quick/qquickitem/tst_qquickitem.cpp | 1468 ++++ .../quick/qquickitem2/data/childrenProperty.qml | 14 + tests/auto/quick/qquickitem2/data/childrenRect.qml | 27 + .../quick/qquickitem2/data/childrenRectBug.qml | 23 + .../quick/qquickitem2/data/childrenRectBug2.qml | 53 + .../quick/qquickitem2/data/childrenRectBug3.qml | 15 + tests/auto/quick/qquickitem2/data/implicitsize.qml | 19 + .../quick/qquickitem2/data/keynavigationtest.qml | 87 + .../data/keynavigationtest_implicit.qml | 68 + tests/auto/quick/qquickitem2/data/keysim.qml | 11 + tests/auto/quick/qquickitem2/data/keyspriority.qml | 11 + tests/auto/quick/qquickitem2/data/keystest.qml | 24 + .../quick/qquickitem2/data/layoutmirroring.qml | 54 + .../auto/quick/qquickitem2/data/mapCoordinates.qml | 84 + tests/auto/quick/qquickitem2/data/parentLoop.qml | 14 + .../quick/qquickitem2/data/propertychanges.qml | 10 + tests/auto/quick/qquickitem2/data/qtbug_16871.qml | 5 + .../quick/qquickitem2/data/resourcesProperty.qml | 21 + .../auto/quick/qquickitem2/data/transformCrash.qml | 13 + .../quick/qquickitem2/data/visiblechildren.qml | 143 + tests/auto/quick/qquickitem2/qquickitem2.pro | 15 + tests/auto/quick/qquickitem2/tst_qquickitem.cpp | 1380 +++ .../quick/qquickitemlayer/data/DisableLayer.qml | 18 + tests/auto/quick/qquickitemlayer/data/Effect.qml | 34 + tests/auto/quick/qquickitemlayer/data/Enabled.qml | 25 + .../auto/quick/qquickitemlayer/data/ItemEffect.qml | 23 + tests/auto/quick/qquickitemlayer/data/Mipmap.qml | 30 + .../quick/qquickitemlayer/data/RectangleEffect.qml | 22 + .../qquickitemlayer/data/SamplerNameChange.qml | 18 + tests/auto/quick/qquickitemlayer/data/Smooth.qml | 23 + .../auto/quick/qquickitemlayer/data/SourceRect.qml | 33 + .../quick/qquickitemlayer/data/TextureProvider.qml | 40 + .../qquickitemlayer/data/ToggleLayerAndEffect.qml | 23 + tests/auto/quick/qquickitemlayer/data/Visible.qml | 56 + tests/auto/quick/qquickitemlayer/data/ZOrder.qml | 52 + .../quick/qquickitemlayer/data/ZOrderChange.qml | 50 + .../auto/quick/qquickitemlayer/qquickitemlayer.pro | 38 + .../quick/qquickitemlayer/tst_qquickitemlayer.cpp | 436 + .../quick/qquicklistview/data/ComponentView.qml | 16 + tests/auto/quick/qquicklistview/data/Page.qml | 10 + .../quick/qquicklistview/data/addTransitions.qml | 134 + .../auto/quick/qquicklistview/data/asyncloader.qml | 36 + .../quick/qquicklistview/data/attachedSignals.qml | 24 + .../quick/qquicklistview/data/creationContext.qml | 5 + .../auto/quick/qquicklistview/data/displaylist.qml | 50 + .../data/fillModelOnComponentCompleted.qml | 36 + tests/auto/quick/qquicklistview/data/footer.qml | 46 + tests/auto/quick/qquicklistview/data/header.qml | 39 + .../quick/qquicklistview/data/headerfooter.qml | 26 + tests/auto/quick/qquicklistview/data/itemlist.qml | 46 + .../data/listview-enforcerange-nohighlight.qml | 61 + .../qquicklistview/data/listview-enforcerange.qml | 55 + .../qquicklistview/data/listview-initCurrent.qml | 64 + .../qquicklistview/data/listview-noCurrent.qml | 50 + .../data/listview-sections-package.qml | 72 + .../qquicklistview/data/listview-sections.qml | 64 + .../data/listview-sections_delegate.qml | 71 + .../qquicklistview/data/listviewtest-package.qml | 145 + .../quick/qquicklistview/data/listviewtest.qml | 133 + .../quick/qquicklistview/data/manual-highlight.qml | 47 + tests/auto/quick/qquicklistview/data/margins.qml | 47 + tests/auto/quick/qquicklistview/data/margins2.qml | 29 + .../quick/qquicklistview/data/moveTransitions.qml | 141 + .../qquicklistview/data/multipleTransitions.qml | 121 + .../qquicklistview/data/populateTransitions.qml | 102 + .../qquicklistview/data/propertychangestest.qml | 71 + .../auto/quick/qquicklistview/data/qtbug-21742.qml | 36 + .../auto/quick/qquicklistview/data/qtbug14821.qml | 31 + .../auto/quick/qquicklistview/data/qtbug16037.qml | 37 + .../qquicklistview/data/removeTransitions.qml | 144 + .../auto/quick/qquicklistview/data/resizeview.qml | 25 + .../auto/quick/qquicklistview/data/rightToLeft.qml | 42 + .../quick/qquicklistview/data/sizelessthan1.qml | 26 + .../auto/quick/qquicklistview/data/snapOneItem.qml | 49 + .../auto/quick/qquicklistview/data/snapToItem.qml | 49 + .../qquicklistview/data/strictlyenforcerange.qml | 29 + .../quick/qquicklistview/data/unrequestedItems.qml | 63 + .../auto/quick/qquicklistview/incrementalmodel.cpp | 89 + tests/auto/quick/qquicklistview/incrementalmodel.h | 68 + tests/auto/quick/qquicklistview/qquicklistview.pro | 16 + .../quick/qquicklistview/tst_qquicklistview.cpp | 5716 ++++++++++++ .../quick/qquickloader/data/ActiveComponent.qml | 11 + .../quick/qquickloader/data/AnchoredLoader.qml | 14 + .../auto/quick/qquickloader/data/BigComponent.qml | 5015 +++++++++++ tests/auto/quick/qquickloader/data/BlueRect.qml | 8 + .../qquickloader/data/CreationContextLoader.qml | 15 + .../qquickloader/data/GraphicsWidget250x250.qml | 5 + tests/auto/quick/qquickloader/data/GreenRect.qml | 7 + .../data/InitialPropertyValuesComponent.qml | 11 + .../qquickloader/data/InvalidSourceComponent.qml | 5 + tests/auto/quick/qquickloader/data/NoResize.qml | 8 + .../qquickloader/data/NoResizeGraphicsWidget.qml | 9 + tests/auto/quick/qquickloader/data/QTBUG_16928.qml | 23 + tests/auto/quick/qquickloader/data/QTBUG_17114.qml | 18 + tests/auto/quick/qquickloader/data/Rect120x60.qml | 6 + .../quick/qquickloader/data/SetSourceComponent.qml | 9 + .../data/SizeGraphicsWidgetToLoader.qml | 7 + .../data/SizeLoaderToGraphicsWidget.qml | 5 + tests/auto/quick/qquickloader/data/SizeToItem.qml | 5 + .../auto/quick/qquickloader/data/SizeToLoader.qml | 6 + tests/auto/quick/qquickloader/data/VmeError.qml | 7 + tests/auto/quick/qquickloader/data/active.1.qml | 31 + tests/auto/quick/qquickloader/data/active.2.qml | 18 + tests/auto/quick/qquickloader/data/active.3.qml | 18 + tests/auto/quick/qquickloader/data/active.4.qml | 26 + tests/auto/quick/qquickloader/data/active.5.qml | 18 + tests/auto/quick/qquickloader/data/active.6.qml | 21 + tests/auto/quick/qquickloader/data/active.7.qml | 14 + tests/auto/quick/qquickloader/data/active.8.qml | 13 + .../auto/quick/qquickloader/data/asynchronous.qml | 16 + tests/auto/quick/qquickloader/data/crash.qml | 14 + .../quick/qquickloader/data/creationContext.qml | 8 + .../quick/qquickloader/data/differentorigin.qml | 3 + .../auto/quick/qquickloader/data/implicitSize.qml | 28 + .../qquickloader/data/initialPropertyValues.1.qml | 22 + .../qquickloader/data/initialPropertyValues.2.qml | 20 + .../qquickloader/data/initialPropertyValues.3.qml | 18 + .../qquickloader/data/initialPropertyValues.4.qml | 22 + .../qquickloader/data/initialPropertyValues.5.qml | 20 + .../qquickloader/data/initialPropertyValues.6.qml | 25 + .../qquickloader/data/initialPropertyValues.7.qml | 29 + .../qquickloader/data/initialPropertyValues.8.qml | 20 + .../data/initialPropertyValues.binding.qml | 21 + .../data/initialPropertyValues.error.1.qml | 14 + .../data/initialPropertyValues.error.2.qml | 14 + .../data/initialPropertyValues.error.3.qml | 14 + .../data/initialPropertyValues.error.4.qml | 15 + tests/auto/quick/qquickloader/data/nonItem.qml | 5 + tests/auto/quick/qquickloader/data/parented.qml | 21 + tests/auto/quick/qquickloader/data/qmldir | 1 + .../quick/qquickloader/data/sameorigin-load.qml | 3 + tests/auto/quick/qquickloader/data/sameorigin.qml | 3 + tests/auto/quick/qquickloader/data/sizebound.qml | 30 + tests/auto/quick/qquickloader/data/vmeErrors.qml | 6 + tests/auto/quick/qquickloader/qquickloader.pro | 19 + tests/auto/quick/qquickloader/tst_qquickloader.cpp | 987 +++ .../quick/qquickmousearea/data/clickThrough.qml | 25 + .../quick/qquickmousearea/data/clickThrough2.qml | 35 + .../quick/qquickmousearea/data/clickandhold.qml | 13 + .../auto/quick/qquickmousearea/data/clicktwice.qml | 16 + .../quick/qquickmousearea/data/doubleclick.qml | 16 + tests/auto/quick/qquickmousearea/data/dragging.qml | 28 + .../quick/qquickmousearea/data/dragproperties.qml | 28 + .../auto/quick/qquickmousearea/data/dragreset.qml | 28 + .../quick/qquickmousearea/data/hoverPosition.qml | 17 + .../qquickmousearea/data/hoverPropagation.qml | 54 + .../quick/qquickmousearea/data/hoverVisible.qml | 15 + .../quick/qquickmousearea/data/noclickandhold.qml | 11 + .../quick/qquickmousearea/data/pressedCanceled.qml | 18 + .../quick/qquickmousearea/data/pressedOrdering.qml | 28 + .../quick/qquickmousearea/data/preventstealing.qml | 24 + .../quick/qquickmousearea/data/rejectEvent.qml | 28 + .../qquickmousearea/data/updateMousePosOnClick.qml | 20 + .../data/updateMousePosOnResize.qml | 43 + .../auto/quick/qquickmousearea/qquickmousearea.pro | 17 + .../quick/qquickmousearea/tst_qquickmousearea.cpp | 806 ++ .../quick/qquickmultipointtoucharea/data/basic.qml | 15 + .../qquickmultipointtoucharea/data/inFlickable.qml | 31 + .../qquickmultipointtoucharea/data/nested.qml | 27 + .../data/nonOverlapping.qml | 32 + .../qquickmultipointtoucharea/data/properties.qml | 15 + .../qquickmultipointtoucharea/data/signalTest.qml | 30 + .../qquickmultipointtoucharea.pro | 11 + .../tst_qquickmultipointtoucharea.cpp | 727 ++ tests/auto/quick/qquickpath/data/arc.qml | 11 + tests/auto/quick/qquickpath/data/closedcurve.qml | 9 + tests/auto/quick/qquickpath/data/curve.qml | 9 + tests/auto/quick/qquickpath/data/svg.qml | 5 + tests/auto/quick/qquickpath/qquickpath.pro | 15 + tests/auto/quick/qquickpath/tst_qquickpath.cpp | 199 + .../quick/qquickpathview/data/ComponentView.qml | 17 + .../auto/quick/qquickpathview/data/asyncloader.qml | 71 + .../auto/quick/qquickpathview/data/closedPath.qml | 24 + .../quick/qquickpathview/data/creationContext.qml | 5 + tests/auto/quick/qquickpathview/data/datamodel.qml | 38 + .../auto/quick/qquickpathview/data/displaypath.qml | 59 + tests/auto/quick/qquickpathview/data/dragpath.qml | 19 + .../auto/quick/qquickpathview/data/emptymodel.qml | 5 + .../quick/qquickpathview/data/missingPercent.qml | 9 + tests/auto/quick/qquickpathview/data/openPath.qml | 10 + .../auto/quick/qquickpathview/data/pathUpdate.qml | 18 + .../data/pathUpdateOnStartChanged.qml | 38 + tests/auto/quick/qquickpathview/data/pathline.qml | 48 + tests/auto/quick/qquickpathview/data/pathtest.qml | 14 + tests/auto/quick/qquickpathview/data/pathview0.qml | 85 + tests/auto/quick/qquickpathview/data/pathview1.qml | 4 + tests/auto/quick/qquickpathview/data/pathview2.qml | 57 + tests/auto/quick/qquickpathview/data/pathview3.qml | 59 + .../quick/qquickpathview/data/pathview_package.qml | 88 + .../quick/qquickpathview/data/propertychanges.qml | 116 + tests/auto/quick/qquickpathview/data/treemodel.qml | 19 + .../quick/qquickpathview/data/undefinedpath.qml | 17 + tests/auto/quick/qquickpathview/data/vdm.qml | 28 + tests/auto/quick/qquickpathview/qquickpathview.pro | 15 + .../quick/qquickpathview/tst_qquickpathview.cpp | 1458 ++++ .../quick/qquickpincharea/data/pinchproperties.qml | 50 + .../auto/quick/qquickpincharea/qquickpincharea.pro | 15 + .../quick/qquickpincharea/tst_qquickpincharea.cpp | 404 + tests/auto/quick/qquickpixmapcache/data/exists.png | Bin 0 -> 2738 bytes .../auto/quick/qquickpixmapcache/data/exists1.png | Bin 0 -> 2738 bytes .../auto/quick/qquickpixmapcache/data/exists2.png | Bin 0 -> 2738 bytes .../quick/qquickpixmapcache/data/http/exists.png | Bin 0 -> 2738 bytes .../quick/qquickpixmapcache/data/http/exists1.png | Bin 0 -> 2738 bytes .../quick/qquickpixmapcache/data/http/exists2.png | Bin 0 -> 2738 bytes .../quick/qquickpixmapcache/data/http/exists3.png | Bin 0 -> 2738 bytes .../quick/qquickpixmapcache/data/http/exists4.png | Bin 0 -> 2738 bytes .../quick/qquickpixmapcache/data/http/exists5.png | Bin 0 -> 2738 bytes .../quick/qquickpixmapcache/data/http/exists6.png | Bin 0 -> 2738 bytes .../quick/qquickpixmapcache/data/http/exists7.png | Bin 0 -> 2738 bytes .../quick/qquickpixmapcache/data/http/exists8.png | Bin 0 -> 2738 bytes .../auto/quick/qquickpixmapcache/data/massive.png | Bin 0 -> 31834 bytes .../quick/qquickpixmapcache/qquickpixmapcache.pro | 21 + .../qquickpixmapcache/tst_qquickpixmapcache.cpp | 467 + .../quick/qquickpositioners/data/allInvisible.qml | 44 + .../data/attachedproperties-column.qml | 50 + .../data/attachedproperties-dynamic.qml | 44 + .../data/attachedproperties-flow.qml | 50 + .../data/attachedproperties-grid.qml | 50 + .../data/attachedproperties-row.qml | 50 + .../data/flow-testimplicitsize.qml | 19 + .../data/flowtest-toptobottom.qml | 44 + .../auto/quick/qquickpositioners/data/flowtest.qml | 43 + .../quick/qquickpositioners/data/grid-animated.qml | 64 + .../data/grid-row-column-spacing.qml | 43 + .../quick/qquickpositioners/data/grid-spacing.qml | 41 + .../qquickpositioners/data/grid-toptobottom.qml | 41 + .../auto/quick/qquickpositioners/data/gridtest.qml | 42 + .../qquickpositioners/data/gridzerocolumns.qml | 40 + .../data/horizontal-animated-disabled.qml | 40 + .../qquickpositioners/data/horizontal-animated.qml | 47 + .../qquickpositioners/data/horizontal-spacing.qml | 31 + .../quick/qquickpositioners/data/horizontal.qml | 29 + .../qquickpositioners/data/propertychangestest.qml | 39 + .../qquickpositioners/data/rectangleComponent.qml | 11 + .../quick/qquickpositioners/data/repeatertest.qml | 38 + .../qquickpositioners/data/vertical-animated.qml | 41 + .../qquickpositioners/data/vertical-spacing.qml | 28 + .../auto/quick/qquickpositioners/data/vertical.qml | 27 + .../quick/qquickpositioners/qquickpositioners.pro | 14 + .../qquickpositioners/tst_qquickpositioners.cpp | 1472 ++++ .../auto/quick/qquickrepeater/data/asyncloader.qml | 32 + .../auto/quick/qquickrepeater/data/initparent.qml | 12 + tests/auto/quick/qquickrepeater/data/intmodel.qml | 29 + tests/auto/quick/qquickrepeater/data/itemlist.qml | 68 + .../quick/qquickrepeater/data/modelChanged.qml | 26 + tests/auto/quick/qquickrepeater/data/objlist.qml | 21 + .../auto/quick/qquickrepeater/data/properties.qml | 11 + tests/auto/quick/qquickrepeater/data/repeater1.qml | 30 + tests/auto/quick/qquickrepeater/data/repeater2.qml | 36 + tests/auto/quick/qquickrepeater/qquickrepeater.pro | 15 + .../quick/qquickrepeater/tst_qquickrepeater.cpp | 644 ++ tests/auto/quick/qquickscreen/data/screen.qml | 11 + tests/auto/quick/qquickscreen/qquickscreen.pro | 10 + tests/auto/quick/qquickscreen/tst_qquickscreen.cpp | 77 + .../qquickshadereffect/qquickshadereffect.pro | 8 + .../qquickshadereffect/tst_qquickshadereffect.cpp | 275 + .../data/deleteOnUpdate.qml | 27 + .../data/simpleanimation.qml | 12 + .../data/smoothedanimation1.qml | 3 + .../data/smoothedanimation2.qml | 5 + .../data/smoothedanimation3.qml | 6 + .../data/smoothedanimationBehavior.qml | 24 + .../data/smoothedanimationValueSource.qml | 13 + .../qquicksmoothedanimation.pro | 15 + .../tst_qquicksmoothedanimation.cpp | 242 + .../data/springanimation1.qml | 4 + .../data/springanimation2.qml | 16 + .../data/springanimation3.qml | 8 + .../qquickspringanimation.pro | 15 + .../tst_qquickspringanimation.cpp | 133 + .../auto/quick/qquickspriteimage/data/advance.qml | 66 + tests/auto/quick/qquickspriteimage/data/basic.qml | 60 + .../qquickspriteimage/data/squarefacesprite.png | Bin 0 -> 496 bytes .../quick/qquickspriteimage/qquickspriteimage.pro | 15 + .../qquickspriteimage/tst_qquickspriteimage.cpp | 98 + .../quick/qquickstates/data/ExtendedRectangle.qml | 19 + .../qquickstates/data/Implementation/MyType.qml | 32 + .../data/Implementation/images/qt-logo.png | Bin 0 -> 5149 bytes tests/auto/quick/qquickstates/data/QTBUG-14830.qml | 29 + .../quick/qquickstates/data/anchorChanges1.qml | 23 + .../quick/qquickstates/data/anchorChanges2.qml | 21 + .../quick/qquickstates/data/anchorChanges3.qml | 29 + .../quick/qquickstates/data/anchorChanges4.qml | 22 + .../quick/qquickstates/data/anchorChanges5.qml | 22 + .../quick/qquickstates/data/anchorChangesCrash.qml | 14 + .../quick/qquickstates/data/anchorRewindBug.qml | 37 + .../quick/qquickstates/data/anchorRewindBug2.qml | 25 + .../qquickstates/data/attachedPropertyChanges.qml | 20 + .../data/autoStateAtStartupRestoreBug.qml | 18 + .../quick/qquickstates/data/avoidFastForward.qml | 17 + .../auto/quick/qquickstates/data/basicBinding.qml | 12 + .../auto/quick/qquickstates/data/basicBinding2.qml | 12 + .../auto/quick/qquickstates/data/basicBinding3.qml | 13 + .../auto/quick/qquickstates/data/basicBinding4.qml | 17 + .../auto/quick/qquickstates/data/basicChanges.qml | 10 + .../auto/quick/qquickstates/data/basicChanges2.qml | 15 + .../auto/quick/qquickstates/data/basicChanges3.qml | 15 + .../auto/quick/qquickstates/data/basicChanges4.qml | 19 + .../quick/qquickstates/data/basicExtension.qml | 16 + tests/auto/quick/qquickstates/data/deleting.qml | 11 + .../auto/quick/qquickstates/data/deletingState.qml | 13 + .../quick/qquickstates/data/editProperties.qml | 34 + tests/auto/quick/qquickstates/data/explicit.qml | 15 + tests/auto/quick/qquickstates/data/extendsBug.qml | 26 + .../auto/quick/qquickstates/data/fakeExtension.qml | 16 + tests/auto/quick/qquickstates/data/illegalObj.qml | 12 + .../quick/qquickstates/data/illegalTempState.qml | 21 + tests/auto/quick/qquickstates/data/image.png | Bin 0 -> 173 bytes .../quick/qquickstates/data/legalTempState.qml | 23 + .../quick/qquickstates/data/nonExistantProp.qml | 11 + .../auto/quick/qquickstates/data/parentChange1.qml | 37 + .../auto/quick/qquickstates/data/parentChange2.qml | 31 + .../auto/quick/qquickstates/data/parentChange3.qml | 42 + .../auto/quick/qquickstates/data/parentChange4.qml | 30 + .../auto/quick/qquickstates/data/parentChange5.qml | 30 + .../auto/quick/qquickstates/data/parentChange6.qml | 30 + .../quick/qquickstates/data/propertyErrors.qml | 10 + tests/auto/quick/qquickstates/data/reset.qml | 19 + .../quick/qquickstates/data/restoreEntryValues.qml | 14 + .../auto/quick/qquickstates/data/returnToBase.qml | 21 + .../auto/quick/qquickstates/data/revertListBug.qml | 47 + tests/auto/quick/qquickstates/data/script.qml | 10 + .../quick/qquickstates/data/signalOverride.qml | 18 + .../quick/qquickstates/data/signalOverride2.qml | 9 + .../qquickstates/data/signalOverrideCrash.qml | 15 + .../qquickstates/data/signalOverrideCrash2.qml | 24 + .../qquickstates/data/signalOverrideCrash3.qml | 27 + tests/auto/quick/qquickstates/data/unnamedWhen.qml | 14 + .../auto/quick/qquickstates/data/urlResolution.qml | 12 + .../auto/quick/qquickstates/data/whenOrdering.qml | 11 + tests/auto/quick/qquickstates/qquickstates.pro | 14 + tests/auto/quick/qquickstates/tst_qquickstates.cpp | 1608 ++++ .../quick/qquickstyledtext/qquickstyledtext.pro | 8 + .../qquickstyledtext/tst_qquickstyledtext.cpp | 185 + .../qquicksystempalette/qquicksystempalette.pro | 8 + .../tst_qquicksystempalette.cpp | 185 + tests/auto/quick/qquicktext/data/alignments.qml | 41 + tests/auto/quick/qquicktext/data/alignments_cb.png | Bin 0 -> 496 bytes tests/auto/quick/qquicktext/data/alignments_cc.png | Bin 0 -> 556 bytes tests/auto/quick/qquicktext/data/alignments_ct.png | Bin 0 -> 533 bytes tests/auto/quick/qquicktext/data/alignments_lb.png | Bin 0 -> 496 bytes tests/auto/quick/qquicktext/data/alignments_lc.png | Bin 0 -> 535 bytes tests/auto/quick/qquicktext/data/alignments_lt.png | Bin 0 -> 514 bytes tests/auto/quick/qquicktext/data/alignments_rb.png | Bin 0 -> 505 bytes tests/auto/quick/qquicktext/data/alignments_rc.png | Bin 0 -> 559 bytes tests/auto/quick/qquicktext/data/alignments_rt.png | Bin 0 -> 539 bytes .../quick/qquicktext/data/embeddedImagesLocal.qml | 6 + .../qquicktext/data/embeddedImagesLocalError.qml | 6 + .../data/embeddedImagesLocalRelative.qml | 7 + .../quick/qquicktext/data/embeddedImagesRemote.qml | 6 + .../qquicktext/data/embeddedImagesRemoteError.qml | 6 + .../data/embeddedImagesRemoteRelative.qml | 7 + tests/auto/quick/qquicktext/data/fontSizeMode.qml | 24 + .../data/horizontalAlignment_RightToLeft.qml | 23 + tests/auto/quick/qquicktext/data/http/exists.png | Bin 0 -> 2738 bytes .../auto/quick/qquicktext/data/images/face-sad.png | Bin 0 -> 6148 bytes .../auto/quick/qquicktext/data/images/heart200.png | Bin 0 -> 8248 bytes .../quick/qquicktext/data/images/starfish_2.png | Bin 0 -> 18243 bytes tests/auto/quick/qquicktext/data/imgTagsElide.qml | 24 + .../auto/quick/qquicktext/data/imgTagsUpdates.qml | 12 + tests/auto/quick/qquicktext/data/lineCount.qml | 15 + tests/auto/quick/qquicktext/data/lineHeight.qml | 15 + tests/auto/quick/qquicktext/data/lineLayout.qml | 35 + .../quick/qquicktext/data/multilengthStrings.qml | 14 + .../qquicktext/data/multilengthStringsWrapped.qml | 16 + .../auto/quick/qquicktext/data/multilineelide.qml | 10 + tests/auto/quick/qquicktext/data/qtbug_14734.qml | 10 + tests/auto/quick/qquicktext/data/rotated.qml | 18 + tests/auto/quick/qquicktext/qquicktext.pro | 19 + tests/auto/quick/qquicktext/tst_qquicktext.cpp | 2432 ++++++ tests/auto/quick/qquicktextedit/data/Cursor.qml | 5 + .../auto/quick/qquicktextedit/data/CursorRect.qml | 8 + .../auto/quick/qquicktextedit/data/alignments.qml | 41 + .../quick/qquicktextedit/data/alignments_cb.png | Bin 0 -> 496 bytes .../quick/qquicktextedit/data/alignments_cc.png | Bin 0 -> 556 bytes .../quick/qquicktextedit/data/alignments_ct.png | Bin 0 -> 533 bytes .../quick/qquicktextedit/data/alignments_lb.png | Bin 0 -> 496 bytes .../quick/qquicktextedit/data/alignments_lc.png | Bin 0 -> 535 bytes .../quick/qquicktextedit/data/alignments_lt.png | Bin 0 -> 514 bytes .../quick/qquicktextedit/data/alignments_rb.png | Bin 0 -> 505 bytes .../quick/qquicktextedit/data/alignments_rc.png | Bin 0 -> 559 bytes .../quick/qquicktextedit/data/alignments_rt.png | Bin 0 -> 539 bytes .../auto/quick/qquicktextedit/data/cursorTest.qml | 9 + .../qquicktextedit/data/cursorTestExternal.qml | 15 + .../quick/qquicktextedit/data/cursorTestInline.qml | 15 + .../quick/qquicktextedit/data/cursorVisible.qml | 6 + .../qquicktextedit/data/embeddedImagesLocal.qml | 6 + .../data/embeddedImagesLocalError.qml | 6 + .../data/embeddedImagesLocalRelative.qml | 7 + .../qquicktextedit/data/embeddedImagesRemote.qml | 6 + .../data/embeddedImagesRemoteError.qml | 6 + .../data/embeddedImagesRemoteRelative.qml | 7 + .../quick/qquicktextedit/data/geometrySignals.qml | 12 + .../data/horizontalAlignment_RightToLeft.qml | 25 + .../quick/qquicktextedit/data/http/ErrItem.qml | 7 + .../quick/qquicktextedit/data/http/NormItem.qml | 6 + .../qquicktextedit/data/http/cursorHttpTest.qml | 22 + .../data/http/cursorHttpTestFail1.qml | 18 + .../data/http/cursorHttpTestFail2.qml | 18 + .../data/http/cursorHttpTestPass.qml | 18 + .../auto/quick/qquicktextedit/data/http/exists.png | Bin 0 -> 2738 bytes tests/auto/quick/qquicktextedit/data/http/qmldir | 4 + .../qquicktextedit/data/httpfail/FailItem.qml | 5 + .../qquicktextedit/data/httpslow/WaitItem.qml | 5 + .../quick/qquicktextedit/data/inputContext.qml | 7 + .../quick/qquicktextedit/data/inputMethodEvent.qml | 5 + .../quick/qquicktextedit/data/inputmethodhints.qml | 6 + .../quick/qquicktextedit/data/linkActivated.qml | 6 + .../qquicktextedit/data/mouseselection_default.qml | 7 + .../qquicktextedit/data/mouseselection_false.qml | 7 + .../data/mouseselection_false_words.qml | 8 + .../qquicktextedit/data/mouseselection_true.qml | 7 + .../data/mouseselection_true_words.qml | 8 + .../data/mouseselectionmode_characters.qml | 8 + .../data/mouseselectionmode_default.qml | 7 + .../data/mouseselectionmode_words.qml | 8 + .../auto/quick/qquicktextedit/data/navigation.qml | 24 + .../quick/qquicktextedit/data/openInputPanel.qml | 7 + .../qquicktextedit/data/persistentSelection.qml | 8 + .../auto/quick/qquicktextedit/data/positionAt.qml | 9 + .../auto/quick/qquicktextedit/data/qtbug-22058.qml | 39 + tests/auto/quick/qquicktextedit/data/readOnly.qml | 12 + tests/auto/quick/qquicktextedit/qquicktextedit.pro | 16 + .../quick/qquicktextedit/tst_qquicktextedit.cpp | 3884 +++++++++ tests/auto/quick/qquicktextinput/data/Cursor.qml | 5 + .../auto/quick/qquicktextinput/data/cursorTest.qml | 9 + .../qquicktextinput/data/cursorTestExternal.qml | 15 + .../qquicktextinput/data/cursorTestInline.qml | 15 + .../quick/qquicktextinput/data/cursorVisible.qml | 6 + tests/auto/quick/qquicktextinput/data/echoMode.qml | 11 + .../quick/qquicktextinput/data/geometrySignals.qml | 12 + .../quick/qquicktextinput/data/halign_center.png | Bin 0 -> 293 bytes .../quick/qquicktextinput/data/halign_left.png | Bin 0 -> 291 bytes .../quick/qquicktextinput/data/halign_right.png | Bin 0 -> 292 bytes .../qquicktextinput/data/horizontalAlignment.qml | 23 + .../data/horizontalAlignment_RightToLeft.qml | 24 + .../quick/qquicktextinput/data/inputContext.qml | 8 + .../qquicktextinput/data/inputMethodEvent.qml | 6 + .../quick/qquicktextinput/data/inputmethods.qml | 7 + tests/auto/quick/qquicktextinput/data/masks.qml | 7 + .../auto/quick/qquicktextinput/data/maxLength.qml | 7 + .../qquicktextinput/data/mouseselection_true.qml | 7 + .../data/mouseselectionmode_characters.qml | 8 + .../data/mouseselectionmode_default.qml | 7 + .../data/mouseselectionmode_words.qml | 8 + .../auto/quick/qquicktextinput/data/navigation.qml | 24 + .../qquicktextinput/data/negativeDimensions.qml | 19 + .../quick/qquicktextinput/data/openInputPanel.qml | 7 + .../qquicktextinput/data/persistentSelection.qml | 8 + .../auto/quick/qquicktextinput/data/positionAt.qml | 9 + .../qquicktextinput/data/preeditAutoScroll.qml | 7 + .../qquicktextinput/data/qtbug-19956double.qml | 15 + .../quick/qquicktextinput/data/qtbug-19956int.qml | 15 + .../qquicktextinput/data/qtbug-19956regexp.qml | 13 + tests/auto/quick/qquicktextinput/data/readOnly.qml | 12 + .../auto/quick/qquicktextinput/data/validators.qml | 29 + .../auto/quick/qquicktextinput/qquicktextinput.pro | 13 + .../quick/qquicktextinput/tst_qquicktextinput.cpp | 4706 ++++++++++ tests/auto/quick/qquicktimer/qquicktimer.pro | 8 + tests/auto/quick/qquicktimer/tst_qquicktimer.cpp | 393 + tests/auto/quick/qquickview/data/error1.qml | 5 + .../auto/quick/qquickview/data/resizemodeitem.qml | 5 + tests/auto/quick/qquickview/qquickview.pro | 13 + tests/auto/quick/qquickview/tst_qquickview.cpp | 207 + .../quick/qquickvisualdatamodel/data/create.qml | 22 + .../data/datalist-package.qml | 20 + .../quick/qquickvisualdatamodel/data/datalist.qml | 18 + .../qquickvisualdatamodel/data/groups-invalid.qml | 14 + .../qquickvisualdatamodel/data/groups-package.qml | 52 + .../quick/qquickvisualdatamodel/data/groups.qml | 46 + .../data/itemsDestroyed_listView.qml | 13 + .../data/itemsDestroyed_package.qml | 42 + .../data/itemsDestroyed_pathView.qml | 18 + .../data/itemsDestroyed_repeater.qml | 15 + .../data/listmodelproperties-package.qml | 51 + .../data/listmodelproperties.qml | 45 + .../qquickvisualdatamodel/data/modelproperties.qml | 21 + .../data/modelproperties2.qml | 21 + .../data/multipleroleproperties-package.qml | 46 + .../data/multipleroleproperties.qml | 41 + .../qquickvisualdatamodel/data/objectlist.qml | 19 + .../data/objectlistproperties-package.qml | 48 + .../data/objectlistproperties.qml | 43 + .../quick/qquickvisualdatamodel/data/onChanged.qml | 87 + .../qquickvisualdatamodel/data/packageView.qml | 63 + .../qquickvisualdatamodel/data/singlerole1.qml | 10 + .../qquickvisualdatamodel/data/singlerole2.qml | 10 + .../data/singleroleproperties-package.qml | 45 + .../data/singleroleproperties.qml | 39 + .../data/stringlistproperties-package.qml | 45 + .../data/stringlistproperties.qml | 40 + .../qquickvisualdatamodel/data/visualdatamodel.qml | 12 + .../qquickvisualdatamodel.pro | 16 + .../tst_qquickvisualdatamodel.cpp | 3446 ++++++++ tests/auto/quick/qquickxmllistmodel/data/empty.xml | 0 tests/auto/quick/qquickxmllistmodel/data/get.qml | 61 + tests/auto/quick/qquickxmllistmodel/data/model.qml | 11 + tests/auto/quick/qquickxmllistmodel/data/model.xml | 54 + .../auto/quick/qquickxmllistmodel/data/model2.xml | 14 + .../qquickxmllistmodel/data/propertychanges.qml | 11 + .../auto/quick/qquickxmllistmodel/data/recipes.qml | 11 + .../auto/quick/qquickxmllistmodel/data/recipes.xml | 90 + .../quick/qquickxmllistmodel/data/roleCrash.qml | 8 + .../quick/qquickxmllistmodel/data/roleErrors.qml | 11 + .../quick/qquickxmllistmodel/data/roleKeys.qml | 13 + .../quick/qquickxmllistmodel/data/testtypes.qml | 8 + .../auto/quick/qquickxmllistmodel/data/unique.qml | 9 + .../qquickxmllistmodel/qquickxmllistmodel.pro | 15 + .../qquickxmllistmodel/tst_qquickxmllistmodel.cpp | 962 +++ tests/auto/quick/quick.pro | 70 + tests/auto/quick/rendernode/data/MessUpState.qml | 32 + tests/auto/quick/rendernode/data/RenderOrder.qml | 53 + tests/auto/quick/rendernode/rendernode.pro | 18 + tests/auto/quick/rendernode/tst_rendernode.cpp | 242 + tests/auto/quick/shared/util.pri | 7 + tests/auto/quick/shared/viewtestutil.cpp | 493 ++ tests/auto/quick/shared/viewtestutil.h | 180 + tests/auto/quick/shared/visualtestutil.cpp | 71 + tests/auto/quick/shared/visualtestutil.h | 112 + tests/auto/shared/util.cpp | 32 +- tests/auto/shared/util.h | 24 +- tests/auto/shared/util.pri | 2 +- .../benchmarks/declarative/animation/animation.pro | 10 - .../declarative/animation/data/animation.qml | 75 - .../declarative/animation/tst_animation.cpp | 204 - tests/benchmarks/declarative/binding/binding.pro | 11 - .../declarative/binding/data/creation.txt | 9 - .../declarative/binding/data/idproperty.txt | 9 - .../declarative/binding/data/localproperty.txt | 5 - .../declarative/binding/data/objectproperty.txt | 8 - tests/benchmarks/declarative/binding/testtypes.cpp | 46 - tests/benchmarks/declarative/binding/testtypes.h | 83 - .../benchmarks/declarative/binding/tst_binding.cpp | 188 - .../declarative/compilation/compilation.pro | 11 - .../declarative/compilation/data/BoomBlock.qml | 106 - .../declarative/compilation/tst_compilation.cpp | 160 - tests/benchmarks/declarative/creation/creation.pro | 10 - .../benchmarks/declarative/creation/data/item.qml | 75 - .../declarative/creation/data/qobject.qml | 45 - .../declarative/creation/tst_creation.cpp | 361 - tests/benchmarks/declarative/declarative.pro | 18 - .../holistic/data/dynamicTargets/DynamicFour.qml | 78 - .../holistic/data/dynamicTargets/DynamicOne.qml | 56 - .../holistic/data/dynamicTargets/DynamicThree.qml | 61 - .../holistic/data/dynamicTargets/DynamicTwo.qml | 68 - .../declarative/holistic/data/jsImports/Mlbsi.qml | 49 - .../declarative/holistic/data/jsImports/Mldsi.qml | 49 - .../declarative/holistic/data/jsImports/Mlsi.qml | 49 - .../holistic/data/jsImports/ModuleBm.qml | 49 - .../declarative/holistic/data/jsImports/Msbsi.qml | 49 - .../declarative/holistic/data/jsImports/Msdsi.qml | 49 - .../declarative/holistic/data/jsImports/Mssi.qml | 49 - .../holistic/data/jsImports/PragmaBm.qml | 55 - .../holistic/data/jsImports/PragmaModuleBm.qml | 51 - .../declarative/holistic/data/jsImports/Slsi.qml | 49 - .../declarative/holistic/data/jsImports/Sssi.qml | 49 - .../declarative/holistic/data/jsImports/mlbsi.js | 133 - .../declarative/holistic/data/jsImports/mlbsi1.js | 108 - .../declarative/holistic/data/jsImports/mlbsi10.js | 108 - .../declarative/holistic/data/jsImports/mlbsi11.js | 108 - .../declarative/holistic/data/jsImports/mlbsi12.js | 108 - .../declarative/holistic/data/jsImports/mlbsi13.js | 108 - .../declarative/holistic/data/jsImports/mlbsi14.js | 108 - .../declarative/holistic/data/jsImports/mlbsi15.js | 108 - .../declarative/holistic/data/jsImports/mlbsi2.js | 108 - .../declarative/holistic/data/jsImports/mlbsi3.js | 108 - .../declarative/holistic/data/jsImports/mlbsi4.js | 108 - .../declarative/holistic/data/jsImports/mlbsi5.js | 108 - .../declarative/holistic/data/jsImports/mlbsi6.js | 108 - .../declarative/holistic/data/jsImports/mlbsi7.js | 108 - .../declarative/holistic/data/jsImports/mlbsi8.js | 108 - .../declarative/holistic/data/jsImports/mlbsi9.js | 108 - .../declarative/holistic/data/jsImports/mldsi.js | 105 - .../declarative/holistic/data/jsImports/mldsi1.js | 107 - .../declarative/holistic/data/jsImports/mldsi10.js | 107 - .../declarative/holistic/data/jsImports/mldsi11.js | 107 - .../declarative/holistic/data/jsImports/mldsi12.js | 107 - .../declarative/holistic/data/jsImports/mldsi13.js | 107 - .../declarative/holistic/data/jsImports/mldsi14.js | 107 - .../declarative/holistic/data/jsImports/mldsi15.js | 104 - .../declarative/holistic/data/jsImports/mldsi2.js | 107 - .../declarative/holistic/data/jsImports/mldsi3.js | 107 - .../declarative/holistic/data/jsImports/mldsi4.js | 107 - .../declarative/holistic/data/jsImports/mldsi5.js | 107 - .../declarative/holistic/data/jsImports/mldsi6.js | 107 - .../declarative/holistic/data/jsImports/mldsi7.js | 107 - .../declarative/holistic/data/jsImports/mldsi8.js | 107 - .../declarative/holistic/data/jsImports/mldsi9.js | 107 - .../declarative/holistic/data/jsImports/mlsi.js | 138 - .../holistic/data/jsImports/moduleBm.js | 109 - .../declarative/holistic/data/jsImports/msbsi.js | 79 - .../declarative/holistic/data/jsImports/msbsi1.js | 53 - .../declarative/holistic/data/jsImports/msbsi10.js | 53 - .../declarative/holistic/data/jsImports/msbsi11.js | 53 - .../declarative/holistic/data/jsImports/msbsi12.js | 53 - .../declarative/holistic/data/jsImports/msbsi13.js | 53 - .../declarative/holistic/data/jsImports/msbsi14.js | 53 - .../declarative/holistic/data/jsImports/msbsi15.js | 53 - .../declarative/holistic/data/jsImports/msbsi2.js | 53 - .../declarative/holistic/data/jsImports/msbsi3.js | 53 - .../declarative/holistic/data/jsImports/msbsi4.js | 53 - .../declarative/holistic/data/jsImports/msbsi5.js | 53 - .../declarative/holistic/data/jsImports/msbsi6.js | 53 - .../declarative/holistic/data/jsImports/msbsi7.js | 53 - .../declarative/holistic/data/jsImports/msbsi8.js | 53 - .../declarative/holistic/data/jsImports/msbsi9.js | 53 - .../declarative/holistic/data/jsImports/msdsi.js | 51 - .../declarative/holistic/data/jsImports/msdsi1.js | 52 - .../declarative/holistic/data/jsImports/msdsi10.js | 52 - .../declarative/holistic/data/jsImports/msdsi11.js | 52 - .../declarative/holistic/data/jsImports/msdsi12.js | 52 - .../declarative/holistic/data/jsImports/msdsi13.js | 52 - .../declarative/holistic/data/jsImports/msdsi14.js | 52 - .../declarative/holistic/data/jsImports/msdsi15.js | 49 - .../declarative/holistic/data/jsImports/msdsi2.js | 52 - .../declarative/holistic/data/jsImports/msdsi3.js | 52 - .../declarative/holistic/data/jsImports/msdsi4.js | 52 - .../declarative/holistic/data/jsImports/msdsi5.js | 52 - .../declarative/holistic/data/jsImports/msdsi6.js | 52 - .../declarative/holistic/data/jsImports/msdsi7.js | 52 - .../declarative/holistic/data/jsImports/msdsi8.js | 52 - .../declarative/holistic/data/jsImports/msdsi9.js | 52 - .../declarative/holistic/data/jsImports/mssi.js | 84 - .../holistic/data/jsImports/pragmaBmOne.js | 50 - .../holistic/data/jsImports/pragmaBmTwo.js | 50 - .../holistic/data/jsImports/pragmaLib.js | 119 - .../holistic/data/jsImports/pragmaModuleBm.js | 57 - .../declarative/holistic/data/jsImports/slsi.js | 108 - .../declarative/holistic/data/jsImports/sssi.js | 52 - .../declarative/holistic/data/jsTargets/JsOne.qml | 61 - .../declarative/holistic/data/jsTargets/JsTwo.qml | 118 - .../data/largeTargets/gridview-example.qml | 91 - .../holistic/data/largeTargets/layoutdirection.qml | 151 - .../data/largeTargets/mousearea-example.qml | 112 - .../holistic/data/resolutionTargets/ResolveOne.qml | 111 - .../holistic/data/scopeSwitching/CppToJs.qml | 52 - .../holistic/data/scopeSwitching/CppToQml.qml | 48 - .../holistic/data/scopeSwitching/JsToCppEight.qml | 54 - .../holistic/data/scopeSwitching/JsToCppEleven.qml | 57 - .../holistic/data/scopeSwitching/JsToCppFive.qml | 54 - .../holistic/data/scopeSwitching/JsToCppFour.qml | 55 - .../holistic/data/scopeSwitching/JsToCppNine.qml | 56 - .../holistic/data/scopeSwitching/JsToCppOne.qml | 55 - .../holistic/data/scopeSwitching/JsToCppSeven.qml | 54 - .../holistic/data/scopeSwitching/JsToCppSix.qml | 54 - .../holistic/data/scopeSwitching/JsToCppTen.qml | 56 - .../holistic/data/scopeSwitching/JsToCppThree.qml | 55 - .../holistic/data/scopeSwitching/JsToCppTwo.qml | 55 - .../holistic/data/scopeSwitching/ScarceOne.qml | 57 - .../holistic/data/scopeSwitching/ScarceTwo.qml | 52 - .../holistic/data/scopeSwitching/cppToJs.js | 49 - .../holistic/data/smallTargets/SmallFour.qml | 49 - .../holistic/data/smallTargets/SmallOne.qml | 51 - .../holistic/data/smallTargets/SmallThree.qml | 51 - .../holistic/data/smallTargets/SmallTwo.qml | 51 - tests/benchmarks/declarative/holistic/holistic.pro | 13 - .../benchmarks/declarative/holistic/testtypes.cpp | 98 - tests/benchmarks/declarative/holistic/testtypes.h | 355 - .../declarative/holistic/tst_holistic.cpp | 607 -- .../declarative/javascript/data/NestedIdObject.qml | 9 - .../javascript/data/intQObjectProperty.qml | 13 - .../declarative/javascript/data/localId.qml | 13 - .../declarative/javascript/data/nestedId.qml | 13 - .../javascript/data/stringQObjectProperty.qml | 14 - .../declarative/javascript/javascript.pro | 11 - .../declarative/javascript/testtypes.cpp | 48 - .../benchmarks/declarative/javascript/testtypes.h | 65 - .../declarative/javascript/tst_javascript.cpp | 123 - tests/benchmarks/declarative/js/js.pro | 10 - .../declarative/js/qjsengine/qjsengine.pro | 7 - .../declarative/js/qjsengine/tst_qjsengine.cpp | 600 -- .../declarative/js/qjsvalue/qjsvalue.pro | 7 - .../declarative/js/qjsvalue/tst_qjsvalue.cpp | 979 --- .../js/qjsvalueiterator/qjsvalueiterator.pro | 7 - .../js/qjsvalueiterator/tst_qjsvalueiterator.cpp | 309 - .../benchmarks/declarative/painting/data/63x63.png | Bin 3077 -> 0 bytes .../declarative/painting/data/63x63_opaque.png | Bin 3440 -> 0 bytes .../benchmarks/declarative/painting/data/64x64.png | Bin 3101 -> 0 bytes .../declarative/painting/data/64x64_opaque.png | Bin 3588 -> 0 bytes .../declarative/painting/paintbenchmark.cpp | 417 - tests/benchmarks/declarative/painting/painting.pro | 7 - tests/benchmarks/declarative/pointers/pointers.pro | 8 - .../declarative/pointers/tst_pointers.cpp | 77 - .../qdeclarativecomponent/data/myqmlobject.qml | 44 - .../data/myqmlobject_binding.qml | 47 - .../qdeclarativecomponent/data/object.qml | 44 - .../qdeclarativecomponent/data/object_id.qml | 47 - .../data/samegame/BoomBlock.qml | 112 - .../data/samegame/pics/blueStone.png | Bin 3054 -> 0 bytes .../data/samegame/pics/greenStone.png | Bin 2932 -> 0 bytes .../data/samegame/pics/redStone.png | Bin 2902 -> 0 bytes .../data/samegame/pics/yellowStone.png | Bin 3056 -> 0 bytes .../data/synthesized_properties.2.qml | 56 - .../data/synthesized_properties.qml | 46 - .../qdeclarativecomponent.pro | 11 - .../qdeclarativecomponent/testtypes.cpp | 46 - .../declarative/qdeclarativecomponent/testtypes.h | 83 - .../tst_qdeclarativecomponent.cpp | 116 - .../qdeclarativedebugtrace.pro | 8 - .../tst_qdeclarativedebugtrace.cpp | 100 - .../declarative/qdeclarativeimage/image.png | Bin 611 -> 0 bytes .../qdeclarativeimage/qdeclarativeimage.pro | 11 - .../qdeclarativeimage/tst_qdeclarativeimage.cpp | 108 - .../qdeclarativemetaproperty/data/object.qml | 44 - .../data/synthesized_object.qml | 47 - .../qdeclarativemetaproperty.pro | 10 - .../tst_qdeclarativemetaproperty.cpp | 110 - tests/benchmarks/declarative/qmltime/example.qml | 55 - tests/benchmarks/declarative/qmltime/qmltime.cpp | 283 - tests/benchmarks/declarative/qmltime/qmltime.pro | 8 - .../declarative/qmltime/tests/anchors/empty.qml | 75 - .../declarative/qmltime/tests/anchors/fill.qml | 82 - .../declarative/qmltime/tests/anchors/null.qml | 68 - .../declarative/qmltime/tests/animation/large.qml | 82 - .../qmltime/tests/animation/largeNoProps.qml | 82 - .../qmltime/tests/item_creation/children.qml | 75 - .../qmltime/tests/item_creation/data.qml | 75 - .../qmltime/tests/item_creation/no_creation.qml | 53 - .../qmltime/tests/item_creation/resources.qml | 75 - .../declarative/qmltime/tests/loader/Loaded.qml | 48 - .../qmltime/tests/loader/component_loader.qml | 57 - .../qmltime/tests/loader/empty_loader.qml | 56 - .../declarative/qmltime/tests/loader/no_loader.qml | 55 - .../qmltime/tests/loader/source_loader.qml | 57 - .../tests/positioner_creation/no_positioner.qml | 78 - .../tests/positioner_creation/null_positioner.qml | 75 - .../tests/positioner_creation/positioner.qml | 78 - .../qmltime/tests/vmemetaobject/null.qml | 54 - .../qmltime/tests/vmemetaobject/property.qml | 59 - .../declarative/script/data/CustomObject.qml | 48 - tests/benchmarks/declarative/script/data/block.qml | 75 - tests/benchmarks/declarative/script/data/enums.qml | 51 - tests/benchmarks/declarative/script/data/global.js | 54 - .../declarative/script/data/global_prop.qml | 53 - .../declarative/script/data/namespacedEnums.qml | 52 - tests/benchmarks/declarative/script/data/script.js | 1 - .../benchmarks/declarative/script/data/script2.js | 2 - .../declarative/script/data/scriptCall.qml | 54 - .../declarative/script/data/signal_args.qml | 47 - .../declarative/script/data/signal_qml.qml | 47 - .../declarative/script/data/signal_unconnected.qml | 45 - .../declarative/script/data/signal_unusedArgs.qml | 47 - .../declarative/script/data/slot_complex.qml | 57 - .../declarative/script/data/slot_complex_js.js | 8 - .../declarative/script/data/slot_complex_js.qml | 49 - .../declarative/script/data/slot_simple.qml | 50 - .../declarative/script/data/slot_simple_js.js | 3 - .../declarative/script/data/slot_simple_js.qml | 48 - tests/benchmarks/declarative/script/script.pro | 10 - tests/benchmarks/declarative/script/tst_script.cpp | 803 -- .../declarative/typeimports/data/QmlTestType1.qml | 43 - .../declarative/typeimports/data/QmlTestType2.qml | 43 - .../declarative/typeimports/data/QmlTestType3.qml | 43 - .../declarative/typeimports/data/QmlTestType4.qml | 43 - .../declarative/typeimports/data/cpp.qml | 56 - .../declarative/typeimports/data/qml.qml | 54 - .../declarative/typeimports/tst_typeimports.cpp | 135 - .../declarative/typeimports/typeimports.pro | 9 - tests/benchmarks/particles/affectors/affectors.pro | 2 +- tests/benchmarks/particles/emission/emission.pro | 2 +- tests/benchmarks/qml/animation/animation.pro | 10 + tests/benchmarks/qml/animation/data/animation.qml | 75 + tests/benchmarks/qml/animation/tst_animation.cpp | 204 + tests/benchmarks/qml/binding/binding.pro | 11 + tests/benchmarks/qml/binding/data/creation.txt | 9 + tests/benchmarks/qml/binding/data/idproperty.txt | 9 + .../benchmarks/qml/binding/data/localproperty.txt | 5 + .../benchmarks/qml/binding/data/objectproperty.txt | 8 + tests/benchmarks/qml/binding/testtypes.cpp | 46 + tests/benchmarks/qml/binding/testtypes.h | 83 + tests/benchmarks/qml/binding/tst_binding.cpp | 188 + tests/benchmarks/qml/compilation/compilation.pro | 11 + .../benchmarks/qml/compilation/data/BoomBlock.qml | 106 + .../benchmarks/qml/compilation/tst_compilation.cpp | 160 + tests/benchmarks/qml/creation/creation.pro | 10 + tests/benchmarks/qml/creation/data/item.qml | 75 + tests/benchmarks/qml/creation/data/qobject.qml | 45 + tests/benchmarks/qml/creation/tst_creation.cpp | 361 + .../holistic/data/dynamicTargets/DynamicFour.qml | 78 + .../holistic/data/dynamicTargets/DynamicOne.qml | 56 + .../holistic/data/dynamicTargets/DynamicThree.qml | 61 + .../holistic/data/dynamicTargets/DynamicTwo.qml | 68 + .../qml/holistic/data/jsImports/Mlbsi.qml | 49 + .../qml/holistic/data/jsImports/Mldsi.qml | 49 + .../qml/holistic/data/jsImports/Mlsi.qml | 49 + .../qml/holistic/data/jsImports/ModuleBm.qml | 49 + .../qml/holistic/data/jsImports/Msbsi.qml | 49 + .../qml/holistic/data/jsImports/Msdsi.qml | 49 + .../qml/holistic/data/jsImports/Mssi.qml | 49 + .../qml/holistic/data/jsImports/PragmaBm.qml | 55 + .../qml/holistic/data/jsImports/PragmaModuleBm.qml | 51 + .../qml/holistic/data/jsImports/Slsi.qml | 49 + .../qml/holistic/data/jsImports/Sssi.qml | 49 + .../qml/holistic/data/jsImports/mlbsi.js | 133 + .../qml/holistic/data/jsImports/mlbsi1.js | 108 + .../qml/holistic/data/jsImports/mlbsi10.js | 108 + .../qml/holistic/data/jsImports/mlbsi11.js | 108 + .../qml/holistic/data/jsImports/mlbsi12.js | 108 + .../qml/holistic/data/jsImports/mlbsi13.js | 108 + .../qml/holistic/data/jsImports/mlbsi14.js | 108 + .../qml/holistic/data/jsImports/mlbsi15.js | 108 + .../qml/holistic/data/jsImports/mlbsi2.js | 108 + .../qml/holistic/data/jsImports/mlbsi3.js | 108 + .../qml/holistic/data/jsImports/mlbsi4.js | 108 + .../qml/holistic/data/jsImports/mlbsi5.js | 108 + .../qml/holistic/data/jsImports/mlbsi6.js | 108 + .../qml/holistic/data/jsImports/mlbsi7.js | 108 + .../qml/holistic/data/jsImports/mlbsi8.js | 108 + .../qml/holistic/data/jsImports/mlbsi9.js | 108 + .../qml/holistic/data/jsImports/mldsi.js | 105 + .../qml/holistic/data/jsImports/mldsi1.js | 107 + .../qml/holistic/data/jsImports/mldsi10.js | 107 + .../qml/holistic/data/jsImports/mldsi11.js | 107 + .../qml/holistic/data/jsImports/mldsi12.js | 107 + .../qml/holistic/data/jsImports/mldsi13.js | 107 + .../qml/holistic/data/jsImports/mldsi14.js | 107 + .../qml/holistic/data/jsImports/mldsi15.js | 104 + .../qml/holistic/data/jsImports/mldsi2.js | 107 + .../qml/holistic/data/jsImports/mldsi3.js | 107 + .../qml/holistic/data/jsImports/mldsi4.js | 107 + .../qml/holistic/data/jsImports/mldsi5.js | 107 + .../qml/holistic/data/jsImports/mldsi6.js | 107 + .../qml/holistic/data/jsImports/mldsi7.js | 107 + .../qml/holistic/data/jsImports/mldsi8.js | 107 + .../qml/holistic/data/jsImports/mldsi9.js | 107 + .../benchmarks/qml/holistic/data/jsImports/mlsi.js | 138 + .../qml/holistic/data/jsImports/moduleBm.js | 109 + .../qml/holistic/data/jsImports/msbsi.js | 79 + .../qml/holistic/data/jsImports/msbsi1.js | 53 + .../qml/holistic/data/jsImports/msbsi10.js | 53 + .../qml/holistic/data/jsImports/msbsi11.js | 53 + .../qml/holistic/data/jsImports/msbsi12.js | 53 + .../qml/holistic/data/jsImports/msbsi13.js | 53 + .../qml/holistic/data/jsImports/msbsi14.js | 53 + .../qml/holistic/data/jsImports/msbsi15.js | 53 + .../qml/holistic/data/jsImports/msbsi2.js | 53 + .../qml/holistic/data/jsImports/msbsi3.js | 53 + .../qml/holistic/data/jsImports/msbsi4.js | 53 + .../qml/holistic/data/jsImports/msbsi5.js | 53 + .../qml/holistic/data/jsImports/msbsi6.js | 53 + .../qml/holistic/data/jsImports/msbsi7.js | 53 + .../qml/holistic/data/jsImports/msbsi8.js | 53 + .../qml/holistic/data/jsImports/msbsi9.js | 53 + .../qml/holistic/data/jsImports/msdsi.js | 51 + .../qml/holistic/data/jsImports/msdsi1.js | 52 + .../qml/holistic/data/jsImports/msdsi10.js | 52 + .../qml/holistic/data/jsImports/msdsi11.js | 52 + .../qml/holistic/data/jsImports/msdsi12.js | 52 + .../qml/holistic/data/jsImports/msdsi13.js | 52 + .../qml/holistic/data/jsImports/msdsi14.js | 52 + .../qml/holistic/data/jsImports/msdsi15.js | 49 + .../qml/holistic/data/jsImports/msdsi2.js | 52 + .../qml/holistic/data/jsImports/msdsi3.js | 52 + .../qml/holistic/data/jsImports/msdsi4.js | 52 + .../qml/holistic/data/jsImports/msdsi5.js | 52 + .../qml/holistic/data/jsImports/msdsi6.js | 52 + .../qml/holistic/data/jsImports/msdsi7.js | 52 + .../qml/holistic/data/jsImports/msdsi8.js | 52 + .../qml/holistic/data/jsImports/msdsi9.js | 52 + .../benchmarks/qml/holistic/data/jsImports/mssi.js | 84 + .../qml/holistic/data/jsImports/pragmaBmOne.js | 50 + .../qml/holistic/data/jsImports/pragmaBmTwo.js | 50 + .../qml/holistic/data/jsImports/pragmaLib.js | 119 + .../qml/holistic/data/jsImports/pragmaModuleBm.js | 57 + .../benchmarks/qml/holistic/data/jsImports/slsi.js | 108 + .../benchmarks/qml/holistic/data/jsImports/sssi.js | 52 + .../qml/holistic/data/jsTargets/JsOne.qml | 61 + .../qml/holistic/data/jsTargets/JsTwo.qml | 118 + .../data/largeTargets/gridview-example.qml | 91 + .../holistic/data/largeTargets/layoutdirection.qml | 151 + .../data/largeTargets/mousearea-example.qml | 112 + .../holistic/data/resolutionTargets/ResolveOne.qml | 111 + .../qml/holistic/data/scopeSwitching/CppToJs.qml | 52 + .../qml/holistic/data/scopeSwitching/CppToQml.qml | 48 + .../holistic/data/scopeSwitching/JsToCppEight.qml | 54 + .../holistic/data/scopeSwitching/JsToCppEleven.qml | 57 + .../holistic/data/scopeSwitching/JsToCppFive.qml | 54 + .../holistic/data/scopeSwitching/JsToCppFour.qml | 55 + .../holistic/data/scopeSwitching/JsToCppNine.qml | 56 + .../holistic/data/scopeSwitching/JsToCppOne.qml | 55 + .../holistic/data/scopeSwitching/JsToCppSeven.qml | 54 + .../holistic/data/scopeSwitching/JsToCppSix.qml | 54 + .../holistic/data/scopeSwitching/JsToCppTen.qml | 56 + .../holistic/data/scopeSwitching/JsToCppThree.qml | 55 + .../holistic/data/scopeSwitching/JsToCppTwo.qml | 55 + .../qml/holistic/data/scopeSwitching/ScarceOne.qml | 57 + .../qml/holistic/data/scopeSwitching/ScarceTwo.qml | 52 + .../qml/holistic/data/scopeSwitching/cppToJs.js | 49 + .../qml/holistic/data/smallTargets/SmallFour.qml | 49 + .../qml/holistic/data/smallTargets/SmallOne.qml | 51 + .../qml/holistic/data/smallTargets/SmallThree.qml | 51 + .../qml/holistic/data/smallTargets/SmallTwo.qml | 51 + tests/benchmarks/qml/holistic/holistic.pro | 13 + tests/benchmarks/qml/holistic/testtypes.cpp | 98 + tests/benchmarks/qml/holistic/testtypes.h | 355 + tests/benchmarks/qml/holistic/tst_holistic.cpp | 607 ++ .../qml/javascript/data/NestedIdObject.qml | 9 + .../qml/javascript/data/intQObjectProperty.qml | 13 + tests/benchmarks/qml/javascript/data/localId.qml | 13 + tests/benchmarks/qml/javascript/data/nestedId.qml | 13 + .../qml/javascript/data/stringQObjectProperty.qml | 14 + tests/benchmarks/qml/javascript/javascript.pro | 11 + tests/benchmarks/qml/javascript/testtypes.cpp | 48 + tests/benchmarks/qml/javascript/testtypes.h | 65 + tests/benchmarks/qml/javascript/tst_javascript.cpp | 123 + tests/benchmarks/qml/js/js.pro | 10 + tests/benchmarks/qml/js/qjsengine/qjsengine.pro | 7 + .../benchmarks/qml/js/qjsengine/tst_qjsengine.cpp | 600 ++ tests/benchmarks/qml/js/qjsvalue/qjsvalue.pro | 7 + tests/benchmarks/qml/js/qjsvalue/tst_qjsvalue.cpp | 979 +++ .../qml/js/qjsvalueiterator/qjsvalueiterator.pro | 7 + .../js/qjsvalueiterator/tst_qjsvalueiterator.cpp | 309 + tests/benchmarks/qml/painting/data/63x63.png | Bin 0 -> 3077 bytes .../benchmarks/qml/painting/data/63x63_opaque.png | Bin 0 -> 3440 bytes tests/benchmarks/qml/painting/data/64x64.png | Bin 0 -> 3101 bytes .../benchmarks/qml/painting/data/64x64_opaque.png | Bin 0 -> 3588 bytes tests/benchmarks/qml/painting/paintbenchmark.cpp | 417 + tests/benchmarks/qml/painting/painting.pro | 7 + tests/benchmarks/qml/pointers/pointers.pro | 8 + tests/benchmarks/qml/pointers/tst_pointers.cpp | 77 + tests/benchmarks/qml/qml.pro | 18 + tests/benchmarks/qml/qmltime/example.qml | 55 + tests/benchmarks/qml/qmltime/qmltime.cpp | 283 + tests/benchmarks/qml/qmltime/qmltime.pro | 8 + .../benchmarks/qml/qmltime/tests/anchors/empty.qml | 75 + .../benchmarks/qml/qmltime/tests/anchors/fill.qml | 82 + .../benchmarks/qml/qmltime/tests/anchors/null.qml | 68 + .../qml/qmltime/tests/animation/large.qml | 82 + .../qml/qmltime/tests/animation/largeNoProps.qml | 82 + .../qml/qmltime/tests/item_creation/children.qml | 75 + .../qml/qmltime/tests/item_creation/data.qml | 75 + .../qmltime/tests/item_creation/no_creation.qml | 53 + .../qml/qmltime/tests/item_creation/resources.qml | 75 + .../benchmarks/qml/qmltime/tests/loader/Loaded.qml | 48 + .../qml/qmltime/tests/loader/component_loader.qml | 57 + .../qml/qmltime/tests/loader/empty_loader.qml | 56 + .../qml/qmltime/tests/loader/no_loader.qml | 55 + .../qml/qmltime/tests/loader/source_loader.qml | 57 + .../tests/positioner_creation/no_positioner.qml | 78 + .../tests/positioner_creation/null_positioner.qml | 75 + .../tests/positioner_creation/positioner.qml | 78 + .../qml/qmltime/tests/vmemetaobject/null.qml | 54 + .../qml/qmltime/tests/vmemetaobject/property.qml | 59 + .../qml/qqmlcomponent/data/myqmlobject.qml | 44 + .../qml/qqmlcomponent/data/myqmlobject_binding.qml | 47 + tests/benchmarks/qml/qqmlcomponent/data/object.qml | 44 + .../qml/qqmlcomponent/data/object_id.qml | 47 + .../qml/qqmlcomponent/data/samegame/BoomBlock.qml | 112 + .../qqmlcomponent/data/samegame/pics/blueStone.png | Bin 0 -> 3054 bytes .../data/samegame/pics/greenStone.png | Bin 0 -> 2932 bytes .../qqmlcomponent/data/samegame/pics/redStone.png | Bin 0 -> 2902 bytes .../data/samegame/pics/yellowStone.png | Bin 0 -> 3056 bytes .../data/synthesized_properties.2.qml | 56 + .../qqmlcomponent/data/synthesized_properties.qml | 46 + .../benchmarks/qml/qqmlcomponent/qqmlcomponent.pro | 11 + tests/benchmarks/qml/qqmlcomponent/testtypes.cpp | 46 + tests/benchmarks/qml/qqmlcomponent/testtypes.h | 83 + .../qml/qqmlcomponent/tst_qqmlcomponent.cpp | 116 + .../qml/qqmldebugtrace/qqmldebugtrace.pro | 8 + .../qml/qqmldebugtrace/tst_qqmldebugtrace.cpp | 100 + tests/benchmarks/qml/qqmlimage/image.png | Bin 0 -> 611 bytes tests/benchmarks/qml/qqmlimage/qqmlimage.pro | 11 + tests/benchmarks/qml/qqmlimage/tst_qqmlimage.cpp | 108 + .../qml/qqmlmetaproperty/data/object.qml | 44 + .../qqmlmetaproperty/data/synthesized_object.qml | 47 + .../qml/qqmlmetaproperty/qqmlmetaproperty.pro | 10 + .../qml/qqmlmetaproperty/tst_qqmlmetaproperty.cpp | 110 + tests/benchmarks/qml/script/data/CustomObject.qml | 48 + tests/benchmarks/qml/script/data/block.qml | 75 + tests/benchmarks/qml/script/data/enums.qml | 51 + tests/benchmarks/qml/script/data/global.js | 54 + tests/benchmarks/qml/script/data/global_prop.qml | 53 + .../benchmarks/qml/script/data/namespacedEnums.qml | 52 + tests/benchmarks/qml/script/data/script.js | 1 + tests/benchmarks/qml/script/data/script2.js | 2 + tests/benchmarks/qml/script/data/scriptCall.qml | 54 + tests/benchmarks/qml/script/data/signal_args.qml | 47 + tests/benchmarks/qml/script/data/signal_qml.qml | 47 + .../qml/script/data/signal_unconnected.qml | 45 + .../qml/script/data/signal_unusedArgs.qml | 47 + tests/benchmarks/qml/script/data/slot_complex.qml | 57 + .../benchmarks/qml/script/data/slot_complex_js.js | 8 + .../benchmarks/qml/script/data/slot_complex_js.qml | 49 + tests/benchmarks/qml/script/data/slot_simple.qml | 50 + tests/benchmarks/qml/script/data/slot_simple_js.js | 3 + .../benchmarks/qml/script/data/slot_simple_js.qml | 48 + tests/benchmarks/qml/script/script.pro | 10 + tests/benchmarks/qml/script/tst_script.cpp | 803 ++ .../qml/typeimports/data/QmlTestType1.qml | 43 + .../qml/typeimports/data/QmlTestType2.qml | 43 + .../qml/typeimports/data/QmlTestType3.qml | 43 + .../qml/typeimports/data/QmlTestType4.qml | 43 + tests/benchmarks/qml/typeimports/data/cpp.qml | 56 + tests/benchmarks/qml/typeimports/data/qml.qml | 54 + .../benchmarks/qml/typeimports/tst_typeimports.cpp | 135 + tests/benchmarks/qml/typeimports/typeimports.pro | 9 + tests/global/global.cfg | 2 +- tests/manual/accessibility/animation.qml | 2 +- tests/manual/accessibility/behavior.qml | 2 +- tests/manual/accessibility/flickable.qml | 2 +- tests/manual/accessibility/hittest.qml | 2 +- tests/manual/accessibility/numberanimation.qml | 2 +- tests/manual/accessibility/textandbuttons.qml | 2 +- tests/manual/accessibility/transition.qml | 2 +- tests/testapplications/qsgimage/ImageNG.qml | 2 +- tests/testapplications/qsgimage/img-align.qml | 2 +- tools/qmleasing/TextField.qml | 2 +- tools/qmleasing/easing.qml | 2 +- tools/qmleasing/qmleasing.pro | 2 +- tools/qmlmin/main.cpp | 20 +- tools/qmlmin/qmlmin.pro | 2 +- tools/qmlplugindump/main.cpp | 66 +- tools/qmlplugindump/qmlplugindump.pro | 4 +- tools/qmlprofiler/commandlistener.cpp | 2 +- tools/qmlprofiler/commandlistener.h | 2 +- tools/qmlprofiler/constants.h | 2 +- tools/qmlprofiler/profileclient.cpp | 46 +- tools/qmlprofiler/profileclient.h | 16 +- tools/qmlprofiler/profiledata.cpp | 60 +- tools/qmlprofiler/profiledata.h | 10 +- tools/qmlprofiler/qmlprofiler.pro | 4 +- tools/qmlprofiler/qmlprofilerapplication.cpp | 10 +- tools/qmlprofiler/qmlprofilerapplication.h | 4 +- tools/qmlscene/main.cpp | 18 +- tools/qmlscene/qmlscene.pro | 4 +- tools/qmltestrunner/qmltestrunner.pro | 4 +- 10306 files changed, 503377 insertions(+), 502576 deletions(-) create mode 100755 bin/rename-qtdeclarative-symbols.sh delete mode 100644 doc/src/snippets/declarative/Button.qml delete mode 100644 doc/src/snippets/declarative/SelfDestroyingRect.qml delete mode 100644 doc/src/snippets/declarative/Sprite.qml delete mode 100644 doc/src/snippets/declarative/anchoranimation.qml delete mode 100644 doc/src/snippets/declarative/anchorchanges.qml delete mode 100644 doc/src/snippets/declarative/animatedimage.qml delete mode 100644 doc/src/snippets/declarative/animation.qml delete mode 100644 doc/src/snippets/declarative/application.qml delete mode 100644 doc/src/snippets/declarative/behavior.qml delete mode 100644 doc/src/snippets/declarative/borderimage/borderimage-scaled.qml delete mode 100644 doc/src/snippets/declarative/borderimage/borderimage-tiled.qml delete mode 100644 doc/src/snippets/declarative/borderimage/normal-image.qml delete mode 100644 doc/src/snippets/declarative/codingconventions/dotproperties.qml delete mode 100644 doc/src/snippets/declarative/codingconventions/javascript-imports.qml delete mode 100644 doc/src/snippets/declarative/codingconventions/javascript.qml delete mode 100644 doc/src/snippets/declarative/codingconventions/lists.qml delete mode 100644 doc/src/snippets/declarative/codingconventions/myscript.js delete mode 100644 doc/src/snippets/declarative/codingconventions/photo.qml delete mode 100644 doc/src/snippets/declarative/codingconventions/private.qml delete mode 100644 doc/src/snippets/declarative/coloranimation.qml delete mode 100644 doc/src/snippets/declarative/colors.qml delete mode 100644 doc/src/snippets/declarative/column/column-transitions.qml delete mode 100644 doc/src/snippets/declarative/column/column.qml delete mode 100644 doc/src/snippets/declarative/column/vertical-positioner.qml delete mode 100644 doc/src/snippets/declarative/comments.qml delete mode 100644 doc/src/snippets/declarative/component.qml delete mode 100644 doc/src/snippets/declarative/componentCreation.js delete mode 100644 doc/src/snippets/declarative/createComponent-simple.qml delete mode 100644 doc/src/snippets/declarative/createComponent.qml delete mode 100644 doc/src/snippets/declarative/createQmlObject.qml delete mode 100644 doc/src/snippets/declarative/drag.qml delete mode 100644 doc/src/snippets/declarative/dynamicObjects-destroy.qml delete mode 100644 doc/src/snippets/declarative/events.qml delete mode 100644 doc/src/snippets/declarative/flickable.qml delete mode 100644 doc/src/snippets/declarative/flickableScrollbar.qml delete mode 100644 doc/src/snippets/declarative/flipable/flipable.qml delete mode 100644 doc/src/snippets/declarative/flow.qml delete mode 100644 doc/src/snippets/declarative/focus/MyClickableWidget.qml delete mode 100644 doc/src/snippets/declarative/focus/MyWidget.qml delete mode 100644 doc/src/snippets/declarative/focus/advancedFocus.qml delete mode 100644 doc/src/snippets/declarative/focus/basicwidget.qml delete mode 100644 doc/src/snippets/declarative/focus/clickablewidget.qml delete mode 100644 doc/src/snippets/declarative/focus/myfocusscopewidget.qml delete mode 100644 doc/src/snippets/declarative/focus/rectangle.qml delete mode 100644 doc/src/snippets/declarative/focus/widget.qml delete mode 100644 doc/src/snippets/declarative/folderlistmodel.qml delete mode 100644 doc/src/snippets/declarative/gradient.qml delete mode 100644 doc/src/snippets/declarative/grid-spacing.qml delete mode 100644 doc/src/snippets/declarative/grid/grid-items.qml delete mode 100644 doc/src/snippets/declarative/grid/grid-no-spacing.qml delete mode 100644 doc/src/snippets/declarative/grid/grid-spacing.qml delete mode 100644 doc/src/snippets/declarative/grid/grid.qml delete mode 100644 doc/src/snippets/declarative/gridview/ContactModel.qml delete mode 100644 doc/src/snippets/declarative/gridview/gridview.qml delete mode 100644 doc/src/snippets/declarative/image.qml delete mode 100644 doc/src/snippets/declarative/imports/chart.qml delete mode 100644 doc/src/snippets/declarative/imports/installed-module.qml delete mode 100644 doc/src/snippets/declarative/imports/merged-named-imports.qml delete mode 100644 doc/src/snippets/declarative/imports/named-imports.qml delete mode 100644 doc/src/snippets/declarative/imports/network-imports.qml delete mode 100644 doc/src/snippets/declarative/imports/qtquick-1.0.qml delete mode 100644 doc/src/snippets/declarative/imports/timeexample.qml delete mode 100644 doc/src/snippets/declarative/integrating-javascript/connectjs.qml delete mode 100644 doc/src/snippets/declarative/integrating-javascript/includejs/app.qml delete mode 100644 doc/src/snippets/declarative/integrating-javascript/includejs/factorial.js delete mode 100644 doc/src/snippets/declarative/integrating-javascript/includejs/script.js delete mode 100644 doc/src/snippets/declarative/integrating-javascript/scarceresources/avatarExample.cpp delete mode 100644 doc/src/snippets/declarative/integrating-javascript/scarceresources/avatarExample.h delete mode 100644 doc/src/snippets/declarative/integrating-javascript/scarceresources/exampleFive.qml delete mode 100644 doc/src/snippets/declarative/integrating-javascript/scarceresources/exampleFour.js delete mode 100644 doc/src/snippets/declarative/integrating-javascript/scarceresources/exampleFour.qml delete mode 100644 doc/src/snippets/declarative/integrating-javascript/scarceresources/exampleOne.qml delete mode 100644 doc/src/snippets/declarative/integrating-javascript/scarceresources/exampleThree.js delete mode 100644 doc/src/snippets/declarative/integrating-javascript/scarceresources/exampleThree.qml delete mode 100644 doc/src/snippets/declarative/integrating-javascript/scarceresources/exampleTwo.qml delete mode 100644 doc/src/snippets/declarative/integrating-javascript/script.js delete mode 100644 doc/src/snippets/declarative/keynavigation.qml delete mode 100644 doc/src/snippets/declarative/keys/keys-handler.qml delete mode 100644 doc/src/snippets/declarative/keys/keys-pressed.qml delete mode 100644 doc/src/snippets/declarative/layoutmirroring.qml delete mode 100644 doc/src/snippets/declarative/listmodel-modify.qml delete mode 100644 doc/src/snippets/declarative/listmodel-nested.qml delete mode 100644 doc/src/snippets/declarative/listmodel-simple.qml delete mode 100644 doc/src/snippets/declarative/listmodel.qml delete mode 100644 doc/src/snippets/declarative/listview-decorations.qml delete mode 100644 doc/src/snippets/declarative/listview-sections.qml delete mode 100644 doc/src/snippets/declarative/listview.qml delete mode 100644 doc/src/snippets/declarative/listview/ContactModel.qml delete mode 100644 doc/src/snippets/declarative/listview/listview-snippet.qml delete mode 100644 doc/src/snippets/declarative/listview/listview.qml delete mode 100644 doc/src/snippets/declarative/loader/KeyReader.qml delete mode 100644 doc/src/snippets/declarative/loader/MyItem.qml delete mode 100644 doc/src/snippets/declarative/loader/connections.qml delete mode 100644 doc/src/snippets/declarative/loader/focus.qml delete mode 100644 doc/src/snippets/declarative/loader/simple.qml delete mode 100644 doc/src/snippets/declarative/loader/sizeitem.qml delete mode 100644 doc/src/snippets/declarative/loader/sizeloader.qml delete mode 100644 doc/src/snippets/declarative/models/views-models-delegates.qml delete mode 100644 doc/src/snippets/declarative/models/visual-model-and-view.qml delete mode 100644 doc/src/snippets/declarative/mousearea/mousearea-snippet.qml delete mode 100644 doc/src/snippets/declarative/mousearea/mousearea.qml delete mode 100644 doc/src/snippets/declarative/mousearea/mouseareadragfilter.qml delete mode 100644 doc/src/snippets/declarative/multipointtoucharea/multipointtoucharea.qml delete mode 100644 doc/src/snippets/declarative/numberanimation.qml delete mode 100644 doc/src/snippets/declarative/parallelanimation.qml delete mode 100644 doc/src/snippets/declarative/parentanimation.qml delete mode 100644 doc/src/snippets/declarative/parentchange.qml delete mode 100644 doc/src/snippets/declarative/path/arcdirection.qml delete mode 100644 doc/src/snippets/declarative/path/arcradius.qml delete mode 100644 doc/src/snippets/declarative/path/basicarc.qml delete mode 100644 doc/src/snippets/declarative/path/basiccurve.qml delete mode 100644 doc/src/snippets/declarative/path/largearc.qml delete mode 100644 doc/src/snippets/declarative/pathinterpolator.qml delete mode 100644 doc/src/snippets/declarative/pathview/ContactModel.qml delete mode 100644 doc/src/snippets/declarative/pathview/pathattributes.qml delete mode 100644 doc/src/snippets/declarative/pathview/pathview.qml delete mode 100644 doc/src/snippets/declarative/properties.qml delete mode 100644 doc/src/snippets/declarative/propertyaction-sequential.qml delete mode 100644 doc/src/snippets/declarative/propertyaction.qml delete mode 100644 doc/src/snippets/declarative/propertyanimation.qml delete mode 100644 doc/src/snippets/declarative/propertychanges.qml delete mode 100644 doc/src/snippets/declarative/qml-data-models/dynamic-listmodel.qml delete mode 100644 doc/src/snippets/declarative/qml-data-models/listelements.qml delete mode 100644 doc/src/snippets/declarative/qml-data-models/listmodel-listview.qml delete mode 100644 doc/src/snippets/declarative/qml-documents/inline-component.qml delete mode 100644 doc/src/snippets/declarative/qml-documents/inline-text-component.qml delete mode 100644 doc/src/snippets/declarative/qml-documents/non-trivial.qml delete mode 100644 doc/src/snippets/declarative/qml-documents/qmldocuments.qml delete mode 100644 doc/src/snippets/declarative/qml-intro/images/qt-logo.svg delete mode 100644 doc/src/snippets/declarative/qtbinding/context-advanced/MyItem.qml delete mode 100644 doc/src/snippets/declarative/qtbinding/context-advanced/applicationdata.h delete mode 100644 doc/src/snippets/declarative/qtbinding/context-advanced/connections.qml delete mode 100644 doc/src/snippets/declarative/qtbinding/context-advanced/main.cpp delete mode 100644 doc/src/snippets/declarative/qtbinding/context/MyItem.qml delete mode 100644 doc/src/snippets/declarative/qtbinding/context/main.cpp delete mode 100644 doc/src/snippets/declarative/qtbinding/enums/imageviewer.h delete mode 100644 doc/src/snippets/declarative/qtbinding/enums/standalone.qml delete mode 100644 doc/src/snippets/declarative/qtbinding/functions-cpp/MyItem.qml delete mode 100644 doc/src/snippets/declarative/qtbinding/functions-cpp/main.cpp delete mode 100644 doc/src/snippets/declarative/qtbinding/functions-cpp/myclass.h delete mode 100644 doc/src/snippets/declarative/qtbinding/functions-qml/MyItem.qml delete mode 100644 doc/src/snippets/declarative/qtbinding/functions-qml/main.cpp delete mode 100644 doc/src/snippets/declarative/qtbinding/loading/MyItem.qml delete mode 100644 doc/src/snippets/declarative/qtbinding/loading/main.cpp delete mode 100644 doc/src/snippets/declarative/qtbinding/newelements/imageviewer.h delete mode 100644 doc/src/snippets/declarative/qtbinding/newelements/main.cpp delete mode 100644 doc/src/snippets/declarative/qtbinding/newelements/standalone.qml delete mode 100644 doc/src/snippets/declarative/qtbinding/properties-cpp/MyItem.qml delete mode 100644 doc/src/snippets/declarative/qtbinding/properties-cpp/applicationdata.h delete mode 100644 doc/src/snippets/declarative/qtbinding/properties-qml/MyItem.qml delete mode 100644 doc/src/snippets/declarative/qtbinding/properties-qml/main.cpp delete mode 100644 doc/src/snippets/declarative/qtbinding/resources/example.qrc delete mode 100644 doc/src/snippets/declarative/qtbinding/resources/main.cpp delete mode 100644 doc/src/snippets/declarative/qtbinding/resources/main.qml delete mode 100644 doc/src/snippets/declarative/qtbinding/resources/resources.pro delete mode 100644 doc/src/snippets/declarative/qtbinding/signals-cpp/MyItem.qml delete mode 100644 doc/src/snippets/declarative/qtbinding/signals-cpp/imageviewer.h delete mode 100644 doc/src/snippets/declarative/qtbinding/signals-cpp/main.cpp delete mode 100644 doc/src/snippets/declarative/qtbinding/signals-cpp/standalone.qml delete mode 100644 doc/src/snippets/declarative/qtbinding/signals-qml/MyItem.qml delete mode 100644 doc/src/snippets/declarative/qtbinding/signals-qml/main.cpp delete mode 100644 doc/src/snippets/declarative/qtbinding/signals-qml/myclass.h delete mode 100644 doc/src/snippets/declarative/qtbinding/variantlistmap/MyItem.qml delete mode 100644 doc/src/snippets/declarative/qtbinding/variantlistmap/main.cpp delete mode 100644 doc/src/snippets/declarative/qtobject.qml delete mode 100644 doc/src/snippets/declarative/rectangle/rect-border-width.qml delete mode 100644 doc/src/snippets/declarative/rectangle/rectangle-colors.qml delete mode 100644 doc/src/snippets/declarative/rectangle/rectangle-gradient.qml delete mode 100644 doc/src/snippets/declarative/rectangle/rectangle.qml delete mode 100644 doc/src/snippets/declarative/repeaters/repeater-grid-index.qml delete mode 100644 doc/src/snippets/declarative/repeaters/repeater.qml delete mode 100644 doc/src/snippets/declarative/reusablecomponents/Button.qml delete mode 100644 doc/src/snippets/declarative/reusablecomponents/application.qml delete mode 100644 doc/src/snippets/declarative/reusablecomponents/component.qml delete mode 100644 doc/src/snippets/declarative/reusablecomponents/focusbutton.qml delete mode 100644 doc/src/snippets/declarative/reusablecomponents/qmldir delete mode 100644 doc/src/snippets/declarative/righttoleft.qml delete mode 100644 doc/src/snippets/declarative/righttoleft/Child.qml delete mode 100644 doc/src/snippets/declarative/rotation.qml delete mode 100644 doc/src/snippets/declarative/rotationanimation.qml delete mode 100644 doc/src/snippets/declarative/row.qml delete mode 100644 doc/src/snippets/declarative/row/row.qml delete mode 100644 doc/src/snippets/declarative/script.js delete mode 100644 doc/src/snippets/declarative/sequentialanimation.qml delete mode 100644 doc/src/snippets/declarative/smoothedanimation.qml delete mode 100644 doc/src/snippets/declarative/springanimation.qml delete mode 100644 doc/src/snippets/declarative/state-when.qml delete mode 100644 doc/src/snippets/declarative/state.qml delete mode 100644 doc/src/snippets/declarative/states.qml delete mode 100644 doc/src/snippets/declarative/states/statechangescript.qml delete mode 100644 doc/src/snippets/declarative/systempalette.qml delete mode 100644 doc/src/snippets/declarative/text/onLinkActivated.qml delete mode 100644 doc/src/snippets/declarative/texthandling.qml delete mode 100644 doc/src/snippets/declarative/transition-from-to-modified.qml delete mode 100644 doc/src/snippets/declarative/transition-from-to.qml delete mode 100644 doc/src/snippets/declarative/transition-reversible.qml delete mode 100644 doc/src/snippets/declarative/transition.qml delete mode 100644 doc/src/snippets/declarative/transitions-list.qml delete mode 100644 doc/src/snippets/declarative/viewtransitions/viewtransitions-basic.qml delete mode 100644 doc/src/snippets/declarative/viewtransitions/viewtransitions-delayedbyindex.qml delete mode 100644 doc/src/snippets/declarative/viewtransitions/viewtransitions-intermediatemove.qml delete mode 100644 doc/src/snippets/declarative/viewtransitions/viewtransitions-interruptedgood.qml delete mode 100644 doc/src/snippets/declarative/viewtransitions/viewtransitions-pathanim.qml delete mode 100644 doc/src/snippets/declarative/viewtransitions/viewtransitions-scriptactionbad.qml delete mode 100644 doc/src/snippets/declarative/viewtransitions/viewtransitions-scriptactiongood.qml delete mode 100644 doc/src/snippets/declarative/visualdatagroup.qml delete mode 100644 doc/src/snippets/declarative/visualdatamodel.qml delete mode 100644 doc/src/snippets/declarative/visualdatamodel_rootindex/main.cpp delete mode 100644 doc/src/snippets/declarative/visualdatamodel_rootindex/view.qml delete mode 100644 doc/src/snippets/declarative/workerscript.qml delete mode 100644 doc/src/snippets/declarative/xmlrole.qml delete mode 100644 doc/src/snippets/declarative/xmlrole.xml create mode 100644 doc/src/snippets/qml/Button.qml create mode 100644 doc/src/snippets/qml/SelfDestroyingRect.qml create mode 100644 doc/src/snippets/qml/Sprite.qml create mode 100644 doc/src/snippets/qml/anchoranimation.qml create mode 100644 doc/src/snippets/qml/anchorchanges.qml create mode 100644 doc/src/snippets/qml/animatedimage.qml create mode 100644 doc/src/snippets/qml/animation.qml create mode 100644 doc/src/snippets/qml/application.qml create mode 100644 doc/src/snippets/qml/behavior.qml create mode 100644 doc/src/snippets/qml/borderimage/borderimage-scaled.qml create mode 100644 doc/src/snippets/qml/borderimage/borderimage-tiled.qml create mode 100644 doc/src/snippets/qml/borderimage/normal-image.qml create mode 100644 doc/src/snippets/qml/codingconventions/dotproperties.qml create mode 100644 doc/src/snippets/qml/codingconventions/javascript-imports.qml create mode 100644 doc/src/snippets/qml/codingconventions/javascript.qml create mode 100644 doc/src/snippets/qml/codingconventions/lists.qml create mode 100644 doc/src/snippets/qml/codingconventions/myscript.js create mode 100644 doc/src/snippets/qml/codingconventions/photo.qml create mode 100644 doc/src/snippets/qml/codingconventions/private.qml create mode 100644 doc/src/snippets/qml/coloranimation.qml create mode 100644 doc/src/snippets/qml/colors.qml create mode 100644 doc/src/snippets/qml/column/column-transitions.qml create mode 100644 doc/src/snippets/qml/column/column.qml create mode 100644 doc/src/snippets/qml/column/vertical-positioner.qml create mode 100644 doc/src/snippets/qml/comments.qml create mode 100644 doc/src/snippets/qml/component.qml create mode 100644 doc/src/snippets/qml/componentCreation.js create mode 100644 doc/src/snippets/qml/createComponent-simple.qml create mode 100644 doc/src/snippets/qml/createComponent.qml create mode 100644 doc/src/snippets/qml/createQmlObject.qml create mode 100644 doc/src/snippets/qml/drag.qml create mode 100644 doc/src/snippets/qml/dynamicObjects-destroy.qml create mode 100644 doc/src/snippets/qml/events.qml create mode 100644 doc/src/snippets/qml/flickable.qml create mode 100644 doc/src/snippets/qml/flickableScrollbar.qml create mode 100644 doc/src/snippets/qml/flipable/flipable.qml create mode 100644 doc/src/snippets/qml/flow.qml create mode 100644 doc/src/snippets/qml/focus/MyClickableWidget.qml create mode 100644 doc/src/snippets/qml/focus/MyWidget.qml create mode 100644 doc/src/snippets/qml/focus/advancedFocus.qml create mode 100644 doc/src/snippets/qml/focus/basicwidget.qml create mode 100644 doc/src/snippets/qml/focus/clickablewidget.qml create mode 100644 doc/src/snippets/qml/focus/myfocusscopewidget.qml create mode 100644 doc/src/snippets/qml/focus/rectangle.qml create mode 100644 doc/src/snippets/qml/focus/widget.qml create mode 100644 doc/src/snippets/qml/folderlistmodel.qml create mode 100644 doc/src/snippets/qml/gradient.qml create mode 100644 doc/src/snippets/qml/grid-spacing.qml create mode 100644 doc/src/snippets/qml/grid/grid-items.qml create mode 100644 doc/src/snippets/qml/grid/grid-no-spacing.qml create mode 100644 doc/src/snippets/qml/grid/grid-spacing.qml create mode 100644 doc/src/snippets/qml/grid/grid.qml create mode 100644 doc/src/snippets/qml/gridview/ContactModel.qml create mode 100644 doc/src/snippets/qml/gridview/gridview.qml create mode 100644 doc/src/snippets/qml/image.qml create mode 100644 doc/src/snippets/qml/imports/chart.qml create mode 100644 doc/src/snippets/qml/imports/installed-module.qml create mode 100644 doc/src/snippets/qml/imports/merged-named-imports.qml create mode 100644 doc/src/snippets/qml/imports/named-imports.qml create mode 100644 doc/src/snippets/qml/imports/network-imports.qml create mode 100644 doc/src/snippets/qml/imports/qtquick-1.0.qml create mode 100644 doc/src/snippets/qml/imports/timeexample.qml create mode 100644 doc/src/snippets/qml/integrating-javascript/connectjs.qml create mode 100644 doc/src/snippets/qml/integrating-javascript/includejs/app.qml create mode 100644 doc/src/snippets/qml/integrating-javascript/includejs/factorial.js create mode 100644 doc/src/snippets/qml/integrating-javascript/includejs/script.js create mode 100644 doc/src/snippets/qml/integrating-javascript/scarceresources/avatarExample.cpp create mode 100644 doc/src/snippets/qml/integrating-javascript/scarceresources/avatarExample.h create mode 100644 doc/src/snippets/qml/integrating-javascript/scarceresources/exampleFive.qml create mode 100644 doc/src/snippets/qml/integrating-javascript/scarceresources/exampleFour.js create mode 100644 doc/src/snippets/qml/integrating-javascript/scarceresources/exampleFour.qml create mode 100644 doc/src/snippets/qml/integrating-javascript/scarceresources/exampleOne.qml create mode 100644 doc/src/snippets/qml/integrating-javascript/scarceresources/exampleThree.js create mode 100644 doc/src/snippets/qml/integrating-javascript/scarceresources/exampleThree.qml create mode 100644 doc/src/snippets/qml/integrating-javascript/scarceresources/exampleTwo.qml create mode 100644 doc/src/snippets/qml/integrating-javascript/script.js create mode 100644 doc/src/snippets/qml/keynavigation.qml create mode 100644 doc/src/snippets/qml/keys/keys-handler.qml create mode 100644 doc/src/snippets/qml/keys/keys-pressed.qml create mode 100644 doc/src/snippets/qml/layoutmirroring.qml create mode 100644 doc/src/snippets/qml/listmodel-modify.qml create mode 100644 doc/src/snippets/qml/listmodel-nested.qml create mode 100644 doc/src/snippets/qml/listmodel-simple.qml create mode 100644 doc/src/snippets/qml/listmodel.qml create mode 100644 doc/src/snippets/qml/listview-decorations.qml create mode 100644 doc/src/snippets/qml/listview-sections.qml create mode 100644 doc/src/snippets/qml/listview.qml create mode 100644 doc/src/snippets/qml/listview/ContactModel.qml create mode 100644 doc/src/snippets/qml/listview/listview-snippet.qml create mode 100644 doc/src/snippets/qml/listview/listview.qml create mode 100644 doc/src/snippets/qml/loader/KeyReader.qml create mode 100644 doc/src/snippets/qml/loader/MyItem.qml create mode 100644 doc/src/snippets/qml/loader/connections.qml create mode 100644 doc/src/snippets/qml/loader/focus.qml create mode 100644 doc/src/snippets/qml/loader/simple.qml create mode 100644 doc/src/snippets/qml/loader/sizeitem.qml create mode 100644 doc/src/snippets/qml/loader/sizeloader.qml create mode 100644 doc/src/snippets/qml/models/views-models-delegates.qml create mode 100644 doc/src/snippets/qml/models/visual-model-and-view.qml create mode 100644 doc/src/snippets/qml/mousearea/mousearea-snippet.qml create mode 100644 doc/src/snippets/qml/mousearea/mousearea.qml create mode 100644 doc/src/snippets/qml/mousearea/mouseareadragfilter.qml create mode 100644 doc/src/snippets/qml/multipointtoucharea/multipointtoucharea.qml create mode 100644 doc/src/snippets/qml/numberanimation.qml create mode 100644 doc/src/snippets/qml/parallelanimation.qml create mode 100644 doc/src/snippets/qml/parentanimation.qml create mode 100644 doc/src/snippets/qml/parentchange.qml create mode 100644 doc/src/snippets/qml/path/arcdirection.qml create mode 100644 doc/src/snippets/qml/path/arcradius.qml create mode 100644 doc/src/snippets/qml/path/basicarc.qml create mode 100644 doc/src/snippets/qml/path/basiccurve.qml create mode 100644 doc/src/snippets/qml/path/largearc.qml create mode 100644 doc/src/snippets/qml/pathinterpolator.qml create mode 100644 doc/src/snippets/qml/pathview/ContactModel.qml create mode 100644 doc/src/snippets/qml/pathview/pathattributes.qml create mode 100644 doc/src/snippets/qml/pathview/pathview.qml create mode 100644 doc/src/snippets/qml/properties.qml create mode 100644 doc/src/snippets/qml/propertyaction-sequential.qml create mode 100644 doc/src/snippets/qml/propertyaction.qml create mode 100644 doc/src/snippets/qml/propertyanimation.qml create mode 100644 doc/src/snippets/qml/propertychanges.qml create mode 100644 doc/src/snippets/qml/qml-data-models/dynamic-listmodel.qml create mode 100644 doc/src/snippets/qml/qml-data-models/listelements.qml create mode 100644 doc/src/snippets/qml/qml-data-models/listmodel-listview.qml create mode 100644 doc/src/snippets/qml/qml-documents/inline-component.qml create mode 100644 doc/src/snippets/qml/qml-documents/inline-text-component.qml create mode 100644 doc/src/snippets/qml/qml-documents/non-trivial.qml create mode 100644 doc/src/snippets/qml/qml-documents/qmldocuments.qml create mode 100644 doc/src/snippets/qml/qml-intro/images/qt-logo.svg create mode 100644 doc/src/snippets/qml/qtbinding/context-advanced/MyItem.qml create mode 100644 doc/src/snippets/qml/qtbinding/context-advanced/applicationdata.h create mode 100644 doc/src/snippets/qml/qtbinding/context-advanced/connections.qml create mode 100644 doc/src/snippets/qml/qtbinding/context-advanced/main.cpp create mode 100644 doc/src/snippets/qml/qtbinding/context/MyItem.qml create mode 100644 doc/src/snippets/qml/qtbinding/context/main.cpp create mode 100644 doc/src/snippets/qml/qtbinding/enums/imageviewer.h create mode 100644 doc/src/snippets/qml/qtbinding/enums/standalone.qml create mode 100644 doc/src/snippets/qml/qtbinding/functions-cpp/MyItem.qml create mode 100644 doc/src/snippets/qml/qtbinding/functions-cpp/main.cpp create mode 100644 doc/src/snippets/qml/qtbinding/functions-cpp/myclass.h create mode 100644 doc/src/snippets/qml/qtbinding/functions-qml/MyItem.qml create mode 100644 doc/src/snippets/qml/qtbinding/functions-qml/main.cpp create mode 100644 doc/src/snippets/qml/qtbinding/loading/MyItem.qml create mode 100644 doc/src/snippets/qml/qtbinding/loading/main.cpp create mode 100644 doc/src/snippets/qml/qtbinding/newelements/imageviewer.h create mode 100644 doc/src/snippets/qml/qtbinding/newelements/main.cpp create mode 100644 doc/src/snippets/qml/qtbinding/newelements/standalone.qml create mode 100644 doc/src/snippets/qml/qtbinding/properties-cpp/MyItem.qml create mode 100644 doc/src/snippets/qml/qtbinding/properties-cpp/applicationdata.h create mode 100644 doc/src/snippets/qml/qtbinding/properties-qml/MyItem.qml create mode 100644 doc/src/snippets/qml/qtbinding/properties-qml/main.cpp create mode 100644 doc/src/snippets/qml/qtbinding/resources/example.qrc create mode 100644 doc/src/snippets/qml/qtbinding/resources/main.cpp create mode 100644 doc/src/snippets/qml/qtbinding/resources/main.qml create mode 100644 doc/src/snippets/qml/qtbinding/resources/resources.pro create mode 100644 doc/src/snippets/qml/qtbinding/signals-cpp/MyItem.qml create mode 100644 doc/src/snippets/qml/qtbinding/signals-cpp/imageviewer.h create mode 100644 doc/src/snippets/qml/qtbinding/signals-cpp/main.cpp create mode 100644 doc/src/snippets/qml/qtbinding/signals-cpp/standalone.qml create mode 100644 doc/src/snippets/qml/qtbinding/signals-qml/MyItem.qml create mode 100644 doc/src/snippets/qml/qtbinding/signals-qml/main.cpp create mode 100644 doc/src/snippets/qml/qtbinding/signals-qml/myclass.h create mode 100644 doc/src/snippets/qml/qtbinding/variantlistmap/MyItem.qml create mode 100644 doc/src/snippets/qml/qtbinding/variantlistmap/main.cpp create mode 100644 doc/src/snippets/qml/qtobject.qml create mode 100644 doc/src/snippets/qml/rectangle/rect-border-width.qml create mode 100644 doc/src/snippets/qml/rectangle/rectangle-colors.qml create mode 100644 doc/src/snippets/qml/rectangle/rectangle-gradient.qml create mode 100644 doc/src/snippets/qml/rectangle/rectangle.qml create mode 100644 doc/src/snippets/qml/repeaters/repeater-grid-index.qml create mode 100644 doc/src/snippets/qml/repeaters/repeater.qml create mode 100644 doc/src/snippets/qml/reusablecomponents/Button.qml create mode 100644 doc/src/snippets/qml/reusablecomponents/application.qml create mode 100644 doc/src/snippets/qml/reusablecomponents/component.qml create mode 100644 doc/src/snippets/qml/reusablecomponents/focusbutton.qml create mode 100644 doc/src/snippets/qml/reusablecomponents/qmldir create mode 100644 doc/src/snippets/qml/righttoleft.qml create mode 100644 doc/src/snippets/qml/righttoleft/Child.qml create mode 100644 doc/src/snippets/qml/rotation.qml create mode 100644 doc/src/snippets/qml/rotationanimation.qml create mode 100644 doc/src/snippets/qml/row.qml create mode 100644 doc/src/snippets/qml/row/row.qml create mode 100644 doc/src/snippets/qml/script.js create mode 100644 doc/src/snippets/qml/sequentialanimation.qml create mode 100644 doc/src/snippets/qml/smoothedanimation.qml create mode 100644 doc/src/snippets/qml/springanimation.qml create mode 100644 doc/src/snippets/qml/state-when.qml create mode 100644 doc/src/snippets/qml/state.qml create mode 100644 doc/src/snippets/qml/states.qml create mode 100644 doc/src/snippets/qml/states/statechangescript.qml create mode 100644 doc/src/snippets/qml/systempalette.qml create mode 100644 doc/src/snippets/qml/text/onLinkActivated.qml create mode 100644 doc/src/snippets/qml/texthandling.qml create mode 100644 doc/src/snippets/qml/transition-from-to-modified.qml create mode 100644 doc/src/snippets/qml/transition-from-to.qml create mode 100644 doc/src/snippets/qml/transition-reversible.qml create mode 100644 doc/src/snippets/qml/transition.qml create mode 100644 doc/src/snippets/qml/transitions-list.qml create mode 100644 doc/src/snippets/qml/viewtransitions/viewtransitions-basic.qml create mode 100644 doc/src/snippets/qml/viewtransitions/viewtransitions-delayedbyindex.qml create mode 100644 doc/src/snippets/qml/viewtransitions/viewtransitions-intermediatemove.qml create mode 100644 doc/src/snippets/qml/viewtransitions/viewtransitions-interruptedgood.qml create mode 100644 doc/src/snippets/qml/viewtransitions/viewtransitions-pathanim.qml create mode 100644 doc/src/snippets/qml/viewtransitions/viewtransitions-scriptactionbad.qml create mode 100644 doc/src/snippets/qml/viewtransitions/viewtransitions-scriptactiongood.qml create mode 100644 doc/src/snippets/qml/visualdatagroup.qml create mode 100644 doc/src/snippets/qml/visualdatamodel.qml create mode 100644 doc/src/snippets/qml/visualdatamodel_rootindex/main.cpp create mode 100644 doc/src/snippets/qml/visualdatamodel_rootindex/view.qml create mode 100644 doc/src/snippets/qml/workerscript.qml create mode 100644 doc/src/snippets/qml/xmlrole.qml create mode 100644 doc/src/snippets/qml/xmlrole.xml delete mode 100644 examples/declarative/README delete mode 100644 examples/declarative/accessibility/accessibility.qml delete mode 100644 examples/declarative/accessibility/widgets/Button.qml delete mode 100644 examples/declarative/animation/animation.qml delete mode 100644 examples/declarative/animation/animation.qmlproject delete mode 100644 examples/declarative/animation/basics/color-animation.qml delete mode 100644 examples/declarative/animation/basics/images/face-smile.png delete mode 100644 examples/declarative/animation/basics/images/moon.png delete mode 100644 examples/declarative/animation/basics/images/shadow.png delete mode 100644 examples/declarative/animation/basics/images/star.png delete mode 100644 examples/declarative/animation/basics/images/sun.png delete mode 100644 examples/declarative/animation/basics/property-animation.qml delete mode 100644 examples/declarative/animation/behaviors/SideRect.qml delete mode 100644 examples/declarative/animation/behaviors/behavior-example.qml delete mode 100644 examples/declarative/animation/behaviors/wigglytext.qml delete mode 100644 examples/declarative/animation/easing/content/QuitButton.qml delete mode 100644 examples/declarative/animation/easing/content/quit.png delete mode 100644 examples/declarative/animation/easing/easing.qml delete mode 100644 examples/declarative/animation/pathanimation/pathanimation.qml delete mode 100644 examples/declarative/animation/pathinterpolator/pathinterpolator.qml delete mode 100644 examples/declarative/animation/states/qt-logo.png delete mode 100644 examples/declarative/animation/states/states.qml delete mode 100644 examples/declarative/animation/states/transitions.qml delete mode 100644 examples/declarative/calculator/calculator.qml delete mode 100644 examples/declarative/calculator/content/Button.qml delete mode 100644 examples/declarative/calculator/content/Display.qml delete mode 100644 examples/declarative/calculator/content/calculator.js delete mode 100644 examples/declarative/calculator/content/images/button-.png delete mode 100644 examples/declarative/calculator/content/images/button-blue.png delete mode 100644 examples/declarative/calculator/content/images/button-green.png delete mode 100644 examples/declarative/calculator/content/images/button-purple.png delete mode 100644 examples/declarative/calculator/content/images/button-red.png delete mode 100644 examples/declarative/calculator/content/images/display.png delete mode 100644 examples/declarative/calculator/content/qmldir delete mode 100644 examples/declarative/canvas/bezierCurve/bezierCurve.qml delete mode 100644 examples/declarative/canvas/clip/clip.qml delete mode 100644 examples/declarative/canvas/contents/Button.qml delete mode 100644 examples/declarative/canvas/contents/ScrollBar.qml delete mode 100644 examples/declarative/canvas/contents/Slider.qml delete mode 100644 examples/declarative/canvas/contents/Stocks.qml delete mode 100644 examples/declarative/canvas/contents/TitleBar.qml delete mode 100644 examples/declarative/canvas/contents/ToolBar.qml delete mode 100644 examples/declarative/canvas/contents/images/button-pressed.png delete mode 100644 examples/declarative/canvas/contents/images/button.png delete mode 100644 examples/declarative/canvas/contents/images/default.svg delete mode 100755 examples/declarative/canvas/contents/images/gloss.png delete mode 100755 examples/declarative/canvas/contents/images/lineedit.png delete mode 100644 examples/declarative/canvas/contents/images/lineedit.sci delete mode 100755 examples/declarative/canvas/contents/images/quit.png delete mode 100755 examples/declarative/canvas/contents/images/stripes.png delete mode 100755 examples/declarative/canvas/contents/images/titlebar.png delete mode 100644 examples/declarative/canvas/contents/images/titlebar.sci delete mode 100755 examples/declarative/canvas/contents/images/toolbutton.png delete mode 100644 examples/declarative/canvas/contents/images/toolbutton.sci delete mode 100644 examples/declarative/canvas/contents/qt-logo.png delete mode 100644 examples/declarative/canvas/quadraticCurveTo/quadraticCurveTo.qml delete mode 100644 examples/declarative/canvas/roundedrect/roundedrect.qml delete mode 100644 examples/declarative/canvas/smile/smile.qml delete mode 100644 examples/declarative/canvas/squircle/squircle.png delete mode 100644 examples/declarative/canvas/squircle/squircle.qml delete mode 100644 examples/declarative/canvas/stockchart/README delete mode 100644 examples/declarative/canvas/stockchart/com/nokia/StockChartExample/qmldir delete mode 100644 examples/declarative/canvas/stockchart/model.cpp delete mode 100644 examples/declarative/canvas/stockchart/model.h delete mode 100644 examples/declarative/canvas/stockchart/plugin.cpp delete mode 100644 examples/declarative/canvas/stockchart/stock.qml delete mode 100644 examples/declarative/canvas/stockchart/stockchart.pro delete mode 100644 examples/declarative/canvas/tiger/tiger.js delete mode 100644 examples/declarative/canvas/tiger/tiger.qml delete mode 100644 examples/declarative/canvas/twitterfriends/TwitterUser.qml delete mode 100644 examples/declarative/canvas/twitterfriends/cache.js delete mode 100644 examples/declarative/canvas/twitterfriends/twitter.qml delete mode 100644 examples/declarative/cppextensions/cppextensions.pro delete mode 100644 examples/declarative/cppextensions/cppextensions.qmlproject delete mode 100644 examples/declarative/cppextensions/imageprovider/ImageProviderCore/qmldir delete mode 100644 examples/declarative/cppextensions/imageprovider/imageprovider-example.qml delete mode 100644 examples/declarative/cppextensions/imageprovider/imageprovider.cpp delete mode 100644 examples/declarative/cppextensions/imageprovider/imageprovider.pro delete mode 100644 examples/declarative/cppextensions/imageprovider/imageprovider.qmlproject delete mode 100644 examples/declarative/cppextensions/networkaccessmanagerfactory/main.cpp delete mode 100644 examples/declarative/cppextensions/networkaccessmanagerfactory/networkaccessmanagerfactory.pro delete mode 100644 examples/declarative/cppextensions/networkaccessmanagerfactory/networkaccessmanagerfactory.qmlproject delete mode 100644 examples/declarative/cppextensions/networkaccessmanagerfactory/networkaccessmanagerfactory.qrc delete mode 100644 examples/declarative/cppextensions/networkaccessmanagerfactory/view.qml delete mode 100644 examples/declarative/cppextensions/plugins/README delete mode 100644 examples/declarative/cppextensions/plugins/com/nokia/TimeExample/Clock.qml delete mode 100644 examples/declarative/cppextensions/plugins/com/nokia/TimeExample/center.png delete mode 100644 examples/declarative/cppextensions/plugins/com/nokia/TimeExample/clock.png delete mode 100644 examples/declarative/cppextensions/plugins/com/nokia/TimeExample/hour.png delete mode 100644 examples/declarative/cppextensions/plugins/com/nokia/TimeExample/minute.png delete mode 100644 examples/declarative/cppextensions/plugins/com/nokia/TimeExample/qmldir delete mode 100644 examples/declarative/cppextensions/plugins/plugin.cpp delete mode 100644 examples/declarative/cppextensions/plugins/plugins.pro delete mode 100644 examples/declarative/cppextensions/plugins/plugins.qml delete mode 100644 examples/declarative/cppextensions/plugins/plugins.qmlproject delete mode 100644 examples/declarative/cppextensions/referenceexamples/adding/adding.pro delete mode 100644 examples/declarative/cppextensions/referenceexamples/adding/adding.qrc delete mode 100644 examples/declarative/cppextensions/referenceexamples/adding/example.qml delete mode 100644 examples/declarative/cppextensions/referenceexamples/adding/main.cpp delete mode 100644 examples/declarative/cppextensions/referenceexamples/adding/person.cpp delete mode 100644 examples/declarative/cppextensions/referenceexamples/adding/person.h delete mode 100644 examples/declarative/cppextensions/referenceexamples/attached/attached.pro delete mode 100644 examples/declarative/cppextensions/referenceexamples/attached/attached.qrc delete mode 100644 examples/declarative/cppextensions/referenceexamples/attached/birthdayparty.cpp delete mode 100644 examples/declarative/cppextensions/referenceexamples/attached/birthdayparty.h delete mode 100644 examples/declarative/cppextensions/referenceexamples/attached/example.qml delete mode 100644 examples/declarative/cppextensions/referenceexamples/attached/main.cpp delete mode 100644 examples/declarative/cppextensions/referenceexamples/attached/person.cpp delete mode 100644 examples/declarative/cppextensions/referenceexamples/attached/person.h delete mode 100644 examples/declarative/cppextensions/referenceexamples/binding/binding.pro delete mode 100644 examples/declarative/cppextensions/referenceexamples/binding/binding.qrc delete mode 100644 examples/declarative/cppextensions/referenceexamples/binding/birthdayparty.cpp delete mode 100644 examples/declarative/cppextensions/referenceexamples/binding/birthdayparty.h delete mode 100644 examples/declarative/cppextensions/referenceexamples/binding/example.qml delete mode 100644 examples/declarative/cppextensions/referenceexamples/binding/happybirthdaysong.cpp delete mode 100644 examples/declarative/cppextensions/referenceexamples/binding/happybirthdaysong.h delete mode 100644 examples/declarative/cppextensions/referenceexamples/binding/main.cpp delete mode 100644 examples/declarative/cppextensions/referenceexamples/binding/person.cpp delete mode 100644 examples/declarative/cppextensions/referenceexamples/binding/person.h delete mode 100644 examples/declarative/cppextensions/referenceexamples/coercion/birthdayparty.cpp delete mode 100644 examples/declarative/cppextensions/referenceexamples/coercion/birthdayparty.h delete mode 100644 examples/declarative/cppextensions/referenceexamples/coercion/coercion.pro delete mode 100644 examples/declarative/cppextensions/referenceexamples/coercion/coercion.qrc delete mode 100644 examples/declarative/cppextensions/referenceexamples/coercion/example.qml delete mode 100644 examples/declarative/cppextensions/referenceexamples/coercion/main.cpp delete mode 100644 examples/declarative/cppextensions/referenceexamples/coercion/person.cpp delete mode 100644 examples/declarative/cppextensions/referenceexamples/coercion/person.h delete mode 100644 examples/declarative/cppextensions/referenceexamples/default/birthdayparty.cpp delete mode 100644 examples/declarative/cppextensions/referenceexamples/default/birthdayparty.h delete mode 100644 examples/declarative/cppextensions/referenceexamples/default/default.pro delete mode 100644 examples/declarative/cppextensions/referenceexamples/default/default.qrc delete mode 100644 examples/declarative/cppextensions/referenceexamples/default/example.qml delete mode 100644 examples/declarative/cppextensions/referenceexamples/default/main.cpp delete mode 100644 examples/declarative/cppextensions/referenceexamples/default/person.cpp delete mode 100644 examples/declarative/cppextensions/referenceexamples/default/person.h delete mode 100644 examples/declarative/cppextensions/referenceexamples/extended/example.qml delete mode 100644 examples/declarative/cppextensions/referenceexamples/extended/extended.pro delete mode 100644 examples/declarative/cppextensions/referenceexamples/extended/extended.qrc delete mode 100644 examples/declarative/cppextensions/referenceexamples/extended/lineedit.cpp delete mode 100644 examples/declarative/cppextensions/referenceexamples/extended/lineedit.h delete mode 100644 examples/declarative/cppextensions/referenceexamples/extended/main.cpp delete mode 100644 examples/declarative/cppextensions/referenceexamples/grouped/birthdayparty.cpp delete mode 100644 examples/declarative/cppextensions/referenceexamples/grouped/birthdayparty.h delete mode 100644 examples/declarative/cppextensions/referenceexamples/grouped/example.qml delete mode 100644 examples/declarative/cppextensions/referenceexamples/grouped/grouped.pro delete mode 100644 examples/declarative/cppextensions/referenceexamples/grouped/grouped.qrc delete mode 100644 examples/declarative/cppextensions/referenceexamples/grouped/main.cpp delete mode 100644 examples/declarative/cppextensions/referenceexamples/grouped/person.cpp delete mode 100644 examples/declarative/cppextensions/referenceexamples/grouped/person.h delete mode 100644 examples/declarative/cppextensions/referenceexamples/methods/birthdayparty.cpp delete mode 100644 examples/declarative/cppextensions/referenceexamples/methods/birthdayparty.h delete mode 100644 examples/declarative/cppextensions/referenceexamples/methods/example.qml delete mode 100644 examples/declarative/cppextensions/referenceexamples/methods/main.cpp delete mode 100644 examples/declarative/cppextensions/referenceexamples/methods/methods.pro delete mode 100644 examples/declarative/cppextensions/referenceexamples/methods/methods.qrc delete mode 100644 examples/declarative/cppextensions/referenceexamples/methods/person.cpp delete mode 100644 examples/declarative/cppextensions/referenceexamples/methods/person.h delete mode 100644 examples/declarative/cppextensions/referenceexamples/properties/birthdayparty.cpp delete mode 100644 examples/declarative/cppextensions/referenceexamples/properties/birthdayparty.h delete mode 100644 examples/declarative/cppextensions/referenceexamples/properties/example.qml delete mode 100644 examples/declarative/cppextensions/referenceexamples/properties/main.cpp delete mode 100644 examples/declarative/cppextensions/referenceexamples/properties/person.cpp delete mode 100644 examples/declarative/cppextensions/referenceexamples/properties/person.h delete mode 100644 examples/declarative/cppextensions/referenceexamples/properties/properties.pro delete mode 100644 examples/declarative/cppextensions/referenceexamples/properties/properties.qrc delete mode 100644 examples/declarative/cppextensions/referenceexamples/referenceexamples.pro delete mode 100644 examples/declarative/cppextensions/referenceexamples/referenceexamples.qmlproject delete mode 100644 examples/declarative/cppextensions/referenceexamples/signal/birthdayparty.cpp delete mode 100644 examples/declarative/cppextensions/referenceexamples/signal/birthdayparty.h delete mode 100644 examples/declarative/cppextensions/referenceexamples/signal/example.qml delete mode 100644 examples/declarative/cppextensions/referenceexamples/signal/main.cpp delete mode 100644 examples/declarative/cppextensions/referenceexamples/signal/person.cpp delete mode 100644 examples/declarative/cppextensions/referenceexamples/signal/person.h delete mode 100644 examples/declarative/cppextensions/referenceexamples/signal/signal.pro delete mode 100644 examples/declarative/cppextensions/referenceexamples/signal/signal.qrc delete mode 100644 examples/declarative/cppextensions/referenceexamples/valuesource/birthdayparty.cpp delete mode 100644 examples/declarative/cppextensions/referenceexamples/valuesource/birthdayparty.h delete mode 100644 examples/declarative/cppextensions/referenceexamples/valuesource/example.qml delete mode 100644 examples/declarative/cppextensions/referenceexamples/valuesource/happybirthdaysong.cpp delete mode 100644 examples/declarative/cppextensions/referenceexamples/valuesource/happybirthdaysong.h delete mode 100644 examples/declarative/cppextensions/referenceexamples/valuesource/main.cpp delete mode 100644 examples/declarative/cppextensions/referenceexamples/valuesource/person.cpp delete mode 100644 examples/declarative/cppextensions/referenceexamples/valuesource/person.h delete mode 100644 examples/declarative/cppextensions/referenceexamples/valuesource/valuesource.pro delete mode 100644 examples/declarative/cppextensions/referenceexamples/valuesource/valuesource.qrc delete mode 100644 examples/declarative/declarative.pro delete mode 100644 examples/declarative/draganddrop/dragtarget.qmlproject delete mode 100644 examples/declarative/draganddrop/tiles/DragTile.qml delete mode 100644 examples/declarative/draganddrop/tiles/DropTile.qml delete mode 100644 examples/declarative/draganddrop/tiles/tiles.qml delete mode 100644 examples/declarative/draganddrop/views/gridview.qml delete mode 100644 examples/declarative/flickr/content/Button.qml delete mode 100644 examples/declarative/flickr/content/GridDelegate.qml delete mode 100644 examples/declarative/flickr/content/ImageDetails.qml delete mode 100644 examples/declarative/flickr/content/ListDelegate.qml delete mode 100644 examples/declarative/flickr/content/Progress.qml delete mode 100644 examples/declarative/flickr/content/RssModel.qml delete mode 100644 examples/declarative/flickr/content/ScrollBar.qml delete mode 100644 examples/declarative/flickr/content/Slider.qml delete mode 100644 examples/declarative/flickr/content/TitleBar.qml delete mode 100644 examples/declarative/flickr/content/ToolBar.qml delete mode 100644 examples/declarative/flickr/content/UnifiedDelegate.qml delete mode 100644 examples/declarative/flickr/content/images/gloss.png delete mode 100644 examples/declarative/flickr/content/images/lineedit.png delete mode 100644 examples/declarative/flickr/content/images/lineedit.sci delete mode 100644 examples/declarative/flickr/content/images/noise.png delete mode 100644 examples/declarative/flickr/content/images/particle.png delete mode 100644 examples/declarative/flickr/content/images/quit.png delete mode 100644 examples/declarative/flickr/content/images/squareParticle.png delete mode 100644 examples/declarative/flickr/content/images/stripes.png delete mode 100644 examples/declarative/flickr/content/images/titlebar.png delete mode 100644 examples/declarative/flickr/content/images/titlebar.sci delete mode 100644 examples/declarative/flickr/content/images/toolbutton.png delete mode 100644 examples/declarative/flickr/content/images/toolbutton.sci delete mode 100644 examples/declarative/flickr/content/qmldir delete mode 100644 examples/declarative/flickr/flickr-90.qml delete mode 100644 examples/declarative/flickr/flickr.qml delete mode 100644 examples/declarative/flickr/flickr.qmlproject delete mode 100644 examples/declarative/i18n/i18n.qml delete mode 100644 examples/declarative/i18n/i18n/base.ts delete mode 100644 examples/declarative/i18n/i18n/qml_en_AU.ts delete mode 100644 examples/declarative/i18n/i18n/qml_fr.ts delete mode 100644 examples/declarative/imageelements/borderimage.qml delete mode 100644 examples/declarative/imageelements/content/BearSheet.png delete mode 100644 examples/declarative/imageelements/content/ImageCell.qml delete mode 100644 examples/declarative/imageelements/content/MyBorderImage.qml delete mode 100644 examples/declarative/imageelements/content/ShadowRectangle.qml delete mode 100644 examples/declarative/imageelements/content/bw.png delete mode 100644 examples/declarative/imageelements/content/colors-round.sci delete mode 100644 examples/declarative/imageelements/content/colors-stretch.sci delete mode 100644 examples/declarative/imageelements/content/colors.png delete mode 100644 examples/declarative/imageelements/content/qt-logo.png delete mode 100644 examples/declarative/imageelements/content/shadow.png delete mode 100644 examples/declarative/imageelements/content/speaker.png delete mode 100644 examples/declarative/imageelements/image.qml delete mode 100644 examples/declarative/imageelements/imageelements.qml delete mode 100644 examples/declarative/imageelements/imageelements.qmlproject delete mode 100644 examples/declarative/imageelements/shadows.qml delete mode 100644 examples/declarative/imageelements/simplesprite.qml delete mode 100644 examples/declarative/imageelements/spriteimage.qml delete mode 100644 examples/declarative/keyinteraction/focus/Core/ContextMenu.qml delete mode 100644 examples/declarative/keyinteraction/focus/Core/GridMenu.qml delete mode 100644 examples/declarative/keyinteraction/focus/Core/ListMenu.qml delete mode 100644 examples/declarative/keyinteraction/focus/Core/ListViewDelegate.qml delete mode 100644 examples/declarative/keyinteraction/focus/Core/images/arrow.png delete mode 100644 examples/declarative/keyinteraction/focus/Core/images/qt-logo.png delete mode 100644 examples/declarative/keyinteraction/focus/focus.qml delete mode 100644 examples/declarative/locale/locale.qml delete mode 100644 examples/declarative/minehunt/MinehuntCore/Explosion.qml delete mode 100644 examples/declarative/minehunt/MinehuntCore/Tile.qml delete mode 100644 examples/declarative/minehunt/MinehuntCore/pics/back.png delete mode 100644 examples/declarative/minehunt/MinehuntCore/pics/background.png delete mode 100644 examples/declarative/minehunt/MinehuntCore/pics/bomb-color.png delete mode 100644 examples/declarative/minehunt/MinehuntCore/pics/bomb.png delete mode 100644 examples/declarative/minehunt/MinehuntCore/pics/face-sad.png delete mode 100644 examples/declarative/minehunt/MinehuntCore/pics/face-smile-big.png delete mode 100644 examples/declarative/minehunt/MinehuntCore/pics/face-smile.png delete mode 100644 examples/declarative/minehunt/MinehuntCore/pics/flag-color.png delete mode 100644 examples/declarative/minehunt/MinehuntCore/pics/flag.png delete mode 100644 examples/declarative/minehunt/MinehuntCore/pics/front.png delete mode 100644 examples/declarative/minehunt/MinehuntCore/pics/quit.png delete mode 100644 examples/declarative/minehunt/MinehuntCore/pics/star.png delete mode 100644 examples/declarative/minehunt/MinehuntCore/qmldir delete mode 100644 examples/declarative/minehunt/README delete mode 100644 examples/declarative/minehunt/main.cpp delete mode 100644 examples/declarative/minehunt/minehunt.cpp delete mode 100644 examples/declarative/minehunt/minehunt.h delete mode 100644 examples/declarative/minehunt/minehunt.pro delete mode 100644 examples/declarative/minehunt/minehunt.qml delete mode 100644 examples/declarative/minehunt/minehunt.qmlproject delete mode 100644 examples/declarative/minehunt/minehunt.qrc delete mode 100644 examples/declarative/modelviews/abstractitemmodel/abstractitemmodel.pro delete mode 100644 examples/declarative/modelviews/abstractitemmodel/abstractitemmodel.qrc delete mode 100644 examples/declarative/modelviews/abstractitemmodel/main.cpp delete mode 100644 examples/declarative/modelviews/abstractitemmodel/model.cpp delete mode 100644 examples/declarative/modelviews/abstractitemmodel/model.h delete mode 100644 examples/declarative/modelviews/abstractitemmodel/view.qml delete mode 100644 examples/declarative/modelviews/gridview/gridview-example.qml delete mode 100644 examples/declarative/modelviews/gridview/pics/AddressBook_48.png delete mode 100644 examples/declarative/modelviews/gridview/pics/AudioPlayer_48.png delete mode 100644 examples/declarative/modelviews/gridview/pics/Camera_48.png delete mode 100644 examples/declarative/modelviews/gridview/pics/DateBook_48.png delete mode 100644 examples/declarative/modelviews/gridview/pics/EMail_48.png delete mode 100644 examples/declarative/modelviews/gridview/pics/TodoList_48.png delete mode 100644 examples/declarative/modelviews/gridview/pics/VideoPlayer_48.png delete mode 100644 examples/declarative/modelviews/listview/content/PetsModel.qml delete mode 100644 examples/declarative/modelviews/listview/content/PressAndHoldButton.qml delete mode 100644 examples/declarative/modelviews/listview/content/RecipesModel.qml delete mode 100644 examples/declarative/modelviews/listview/content/TextButton.qml delete mode 100644 examples/declarative/modelviews/listview/content/ToggleButton.qml delete mode 100644 examples/declarative/modelviews/listview/content/pics/arrow-down.png delete mode 100644 examples/declarative/modelviews/listview/content/pics/arrow-up.png delete mode 100644 examples/declarative/modelviews/listview/content/pics/fruit-salad.jpg delete mode 100644 examples/declarative/modelviews/listview/content/pics/hamburger.jpg delete mode 100644 examples/declarative/modelviews/listview/content/pics/lemonade.jpg delete mode 100644 examples/declarative/modelviews/listview/content/pics/list-delete.png delete mode 100644 examples/declarative/modelviews/listview/content/pics/minus-sign.png delete mode 100644 examples/declarative/modelviews/listview/content/pics/moreDown.png delete mode 100644 examples/declarative/modelviews/listview/content/pics/moreUp.png delete mode 100644 examples/declarative/modelviews/listview/content/pics/pancakes.jpg delete mode 100644 examples/declarative/modelviews/listview/content/pics/plus-sign.png delete mode 100644 examples/declarative/modelviews/listview/content/pics/vegetable-soup.jpg delete mode 100644 examples/declarative/modelviews/listview/dynamiclist.qml delete mode 100644 examples/declarative/modelviews/listview/expandingdelegates.qml delete mode 100644 examples/declarative/modelviews/listview/highlight.qml delete mode 100644 examples/declarative/modelviews/listview/highlightranges.qml delete mode 100644 examples/declarative/modelviews/listview/sections.qml delete mode 100644 examples/declarative/modelviews/modelviews.pro delete mode 100644 examples/declarative/modelviews/modelviews.qml delete mode 100644 examples/declarative/modelviews/modelviews.qmlproject delete mode 100644 examples/declarative/modelviews/objectlistmodel/dataobject.cpp delete mode 100644 examples/declarative/modelviews/objectlistmodel/dataobject.h delete mode 100644 examples/declarative/modelviews/objectlistmodel/main.cpp delete mode 100644 examples/declarative/modelviews/objectlistmodel/objectlistmodel.pro delete mode 100644 examples/declarative/modelviews/objectlistmodel/objectlistmodel.qmlproject delete mode 100644 examples/declarative/modelviews/objectlistmodel/objectlistmodel.qrc delete mode 100644 examples/declarative/modelviews/objectlistmodel/view.qml delete mode 100644 examples/declarative/modelviews/package/Delegate.qml delete mode 100644 examples/declarative/modelviews/package/view.qml delete mode 100644 examples/declarative/modelviews/parallax/content/ParallaxView.qml delete mode 100644 examples/declarative/modelviews/parallax/content/Smiley.qml delete mode 100644 examples/declarative/modelviews/parallax/content/pics/background.jpg delete mode 100644 examples/declarative/modelviews/parallax/content/pics/face-smile.png delete mode 100644 examples/declarative/modelviews/parallax/content/pics/home-page.png delete mode 100644 examples/declarative/modelviews/parallax/content/pics/home-page.svg delete mode 100644 examples/declarative/modelviews/parallax/content/pics/shadow.png delete mode 100644 examples/declarative/modelviews/parallax/content/pics/yast-joystick.png delete mode 100644 examples/declarative/modelviews/parallax/content/pics/yast-wol.png delete mode 100644 examples/declarative/modelviews/parallax/parallax.qml delete mode 100644 examples/declarative/modelviews/pathview/pathview-example.qml delete mode 100644 examples/declarative/modelviews/pathview/pics/AddressBook_48.png delete mode 100644 examples/declarative/modelviews/pathview/pics/AudioPlayer_48.png delete mode 100644 examples/declarative/modelviews/pathview/pics/Camera_48.png delete mode 100644 examples/declarative/modelviews/pathview/pics/DateBook_48.png delete mode 100644 examples/declarative/modelviews/pathview/pics/EMail_48.png delete mode 100644 examples/declarative/modelviews/pathview/pics/TodoList_48.png delete mode 100644 examples/declarative/modelviews/pathview/pics/VideoPlayer_48.png delete mode 100644 examples/declarative/modelviews/stringlistmodel/main.cpp delete mode 100644 examples/declarative/modelviews/stringlistmodel/stringlistmodel.pro delete mode 100644 examples/declarative/modelviews/stringlistmodel/stringlistmodel.qrc delete mode 100644 examples/declarative/modelviews/stringlistmodel/view.qml delete mode 100644 examples/declarative/modelviews/visualdatamodel/dragselection.qml delete mode 100644 examples/declarative/modelviews/visualdatamodel/slideshow.qml delete mode 100644 examples/declarative/modelviews/visualdatamodel/sortedmodel.qml delete mode 100644 examples/declarative/modelviews/visualdatamodel/visualdatamodel.qmlproject delete mode 100644 examples/declarative/modelviews/visualitemmodel/visualitemmodel.qml delete mode 100644 examples/declarative/openglunderqml/main.cpp delete mode 100644 examples/declarative/openglunderqml/main.qml delete mode 100644 examples/declarative/openglunderqml/openglunderqml.pro delete mode 100644 examples/declarative/openglunderqml/squircle.cpp delete mode 100644 examples/declarative/openglunderqml/squircle.h delete mode 100644 examples/declarative/painteditem/painteditem.pro delete mode 100644 examples/declarative/painteditem/smile/main.cpp delete mode 100644 examples/declarative/painteditem/smile/smile.pro delete mode 100644 examples/declarative/painteditem/smile/smile.qml delete mode 100644 examples/declarative/painteditem/textballoons/TextBalloonPlugin/plugin.h delete mode 100644 examples/declarative/painteditem/textballoons/TextBalloonPlugin/qmldir delete mode 100644 examples/declarative/painteditem/textballoons/textballoon.cpp delete mode 100644 examples/declarative/painteditem/textballoons/textballoon.h delete mode 100644 examples/declarative/painteditem/textballoons/textballoons.pro delete mode 100644 examples/declarative/painteditem/textballoons/textballoons.qml delete mode 100644 examples/declarative/particles/affectors/age.qml delete mode 100644 examples/declarative/particles/affectors/attractor.qml delete mode 100644 examples/declarative/particles/affectors/customaffector.qml delete mode 100644 examples/declarative/particles/affectors/friction.qml delete mode 100644 examples/declarative/particles/affectors/gravity.qml delete mode 100644 examples/declarative/particles/affectors/groupgoal.qml delete mode 100644 examples/declarative/particles/affectors/move.qml delete mode 100644 examples/declarative/particles/affectors/spritegoal.qml delete mode 100644 examples/declarative/particles/affectors/turbulence.qml delete mode 100644 examples/declarative/particles/affectors/wander.qml delete mode 100644 examples/declarative/particles/customparticle/blurparticles.qml delete mode 100644 examples/declarative/particles/customparticle/fragmentshader.qml delete mode 100644 examples/declarative/particles/customparticle/imagecolors.qml delete mode 100644 examples/declarative/particles/emitters/burstandpulse.qml delete mode 100644 examples/declarative/particles/emitters/customemitter.qml delete mode 100644 examples/declarative/particles/emitters/emitmask.qml delete mode 100644 examples/declarative/particles/emitters/maximumemitted.qml delete mode 100644 examples/declarative/particles/emitters/shapeanddirection.qml delete mode 100644 examples/declarative/particles/emitters/timedgroupchanges.qml delete mode 100644 examples/declarative/particles/emitters/trailemitter.qml delete mode 100644 examples/declarative/particles/emitters/velocityfrommotion.qml delete mode 100644 examples/declarative/particles/exampleslauncher/content/Button.qml delete mode 100644 examples/declarative/particles/exampleslauncher/content/Shell.qml delete mode 100644 examples/declarative/particles/exampleslauncher/content/launcher.js delete mode 100644 examples/declarative/particles/exampleslauncher/exampleslauncher.qml delete mode 100644 examples/declarative/particles/imageparticle/allatonce.qml delete mode 100644 examples/declarative/particles/imageparticle/colored.qml delete mode 100644 examples/declarative/particles/imageparticle/colortable.qml delete mode 100644 examples/declarative/particles/imageparticle/deformation.qml delete mode 100644 examples/declarative/particles/imageparticle/rotation.qml delete mode 100644 examples/declarative/particles/imageparticle/sharing.qml delete mode 100644 examples/declarative/particles/imageparticle/sprites.qml delete mode 100644 examples/declarative/particles/images/_explo.png delete mode 100755 examples/declarative/particles/images/backgroundLeaves.jpg delete mode 100644 examples/declarative/particles/images/bear_tiles.png delete mode 100644 examples/declarative/particles/images/candle.png delete mode 100644 examples/declarative/particles/images/colortable.png delete mode 100644 examples/declarative/particles/images/finalfrontier.png delete mode 100644 examples/declarative/particles/images/flower.png delete mode 100644 examples/declarative/particles/images/launcherIcons/allatonce.png delete mode 100644 examples/declarative/particles/images/launcherIcons/attractor.png delete mode 100644 examples/declarative/particles/images/launcherIcons/blurparticles.png delete mode 100644 examples/declarative/particles/images/launcherIcons/close.png delete mode 100644 examples/declarative/particles/images/launcherIcons/colortable.png delete mode 100644 examples/declarative/particles/images/launcherIcons/customaffector.png delete mode 100644 examples/declarative/particles/images/launcherIcons/customemitter.png delete mode 100644 examples/declarative/particles/images/launcherIcons/deformation.png delete mode 100644 examples/declarative/particles/images/launcherIcons/delegates.png delete mode 100644 examples/declarative/particles/images/launcherIcons/dynamicemitters.png delete mode 100644 examples/declarative/particles/images/launcherIcons/emitmask.png delete mode 100644 examples/declarative/particles/images/launcherIcons/flickr.png delete mode 100644 examples/declarative/particles/images/launcherIcons/fragmentshader.png delete mode 100644 examples/declarative/particles/images/launcherIcons/gridsplosion.png delete mode 100644 examples/declarative/particles/images/launcherIcons/groupgoal.png delete mode 100644 examples/declarative/particles/images/launcherIcons/imagecolors.png delete mode 100644 examples/declarative/particles/images/launcherIcons/list.png delete mode 100644 examples/declarative/particles/images/launcherIcons/maximumemitted.png delete mode 100644 examples/declarative/particles/images/launcherIcons/multiplepainters.png delete mode 100644 examples/declarative/particles/images/launcherIcons/package.png delete mode 100644 examples/declarative/particles/images/launcherIcons/particleview.png delete mode 100644 examples/declarative/particles/images/launcherIcons/plasmapatrol.png delete mode 100644 examples/declarative/particles/images/launcherIcons/remove.png delete mode 100644 examples/declarative/particles/images/launcherIcons/rotation.png delete mode 100644 examples/declarative/particles/images/launcherIcons/samegame.png delete mode 100644 examples/declarative/particles/images/launcherIcons/shapeanddirection.png delete mode 100644 examples/declarative/particles/images/launcherIcons/spaceexplorer.png delete mode 100644 examples/declarative/particles/images/launcherIcons/spritegoal.png delete mode 100644 examples/declarative/particles/images/launcherIcons/sprites.png delete mode 100644 examples/declarative/particles/images/launcherIcons/spritevariedparticles.png delete mode 100644 examples/declarative/particles/images/launcherIcons/startstop.png delete mode 100644 examples/declarative/particles/images/launcherIcons/timedgroupchanges.png delete mode 100644 examples/declarative/particles/images/launcherIcons/trailemitter.png delete mode 100644 examples/declarative/particles/images/launcherIcons/trails.png delete mode 100644 examples/declarative/particles/images/launcherIcons/turbulence.png delete mode 100644 examples/declarative/particles/images/launcherIcons/velocityfrommotion.png delete mode 100644 examples/declarative/particles/images/launcherIcons/wander.png delete mode 100644 examples/declarative/particles/images/matchmask.png delete mode 100644 examples/declarative/particles/images/meteor.png delete mode 100644 examples/declarative/particles/images/meteor_explo.png delete mode 100644 examples/declarative/particles/images/meteors.png delete mode 100644 examples/declarative/particles/images/nullRock.png delete mode 100644 examples/declarative/particles/images/particle.png delete mode 100644 examples/declarative/particles/images/particle2.png delete mode 100644 examples/declarative/particles/images/particle3.png delete mode 100644 examples/declarative/particles/images/particle4.png delete mode 100644 examples/declarative/particles/images/particleA.png delete mode 100644 examples/declarative/particles/images/portal_bg.png delete mode 100644 examples/declarative/particles/images/realLeaf1.png delete mode 100644 examples/declarative/particles/images/realLeaf2.png delete mode 100644 examples/declarative/particles/images/realLeaf3.png delete mode 100644 examples/declarative/particles/images/realLeaf4.png delete mode 100644 examples/declarative/particles/images/rocket.png delete mode 100644 examples/declarative/particles/images/rocket2.png delete mode 100644 examples/declarative/particles/images/sizeInOut.png delete mode 100644 examples/declarative/particles/images/snowflake.png delete mode 100644 examples/declarative/particles/images/sparkleSize.png delete mode 100644 examples/declarative/particles/images/star.png delete mode 100644 examples/declarative/particles/images/starfish_0.png delete mode 100644 examples/declarative/particles/images/starfish_1.png delete mode 100644 examples/declarative/particles/images/starfish_2.png delete mode 100644 examples/declarative/particles/images/starfish_3.png delete mode 100644 examples/declarative/particles/images/starfish_4.png delete mode 100644 examples/declarative/particles/images/starfish_mask.png delete mode 100644 examples/declarative/particles/itemparticle/content/Delegate.qml delete mode 100644 examples/declarative/particles/itemparticle/content/Delegate2.qml delete mode 100644 examples/declarative/particles/itemparticle/content/ExpandingDelegate.qml delete mode 100644 examples/declarative/particles/itemparticle/content/RssModel.qml delete mode 100644 examples/declarative/particles/itemparticle/content/bubble.png delete mode 100644 examples/declarative/particles/itemparticle/content/script.js delete mode 100644 examples/declarative/particles/itemparticle/delegates.qml delete mode 100644 examples/declarative/particles/itemparticle/particleview.qml delete mode 100644 examples/declarative/particles/plasmapatrol/PlasmaPatrol.qmlproject delete mode 100644 examples/declarative/particles/plasmapatrol/TODO delete mode 100644 examples/declarative/particles/plasmapatrol/content/BlasterHardpoint.qml delete mode 100644 examples/declarative/particles/plasmapatrol/content/Button.qml delete mode 100644 examples/declarative/particles/plasmapatrol/content/CannonHardpoint.qml delete mode 100644 examples/declarative/particles/plasmapatrol/content/ChoiceBox.qml delete mode 100644 examples/declarative/particles/plasmapatrol/content/Cruiser.qml delete mode 100644 examples/declarative/particles/plasmapatrol/content/Frigate.qml delete mode 100644 examples/declarative/particles/plasmapatrol/content/Hardpoint.qml delete mode 100644 examples/declarative/particles/plasmapatrol/content/HelpScreens.qml delete mode 100644 examples/declarative/particles/plasmapatrol/content/LaserHardpoint.qml delete mode 100644 examples/declarative/particles/plasmapatrol/content/PlasmaPatrolParticles.qml delete mode 100644 examples/declarative/particles/plasmapatrol/content/SequentialLoader.qml delete mode 100644 examples/declarative/particles/plasmapatrol/content/Ship.qml delete mode 100644 examples/declarative/particles/plasmapatrol/content/Sloop.qml delete mode 100644 examples/declarative/particles/plasmapatrol/content/pics/TitleText.png delete mode 100644 examples/declarative/particles/plasmapatrol/content/pics/blur-circle2.png delete mode 100644 examples/declarative/particles/plasmapatrol/content/pics/blur-circle3.png delete mode 100644 examples/declarative/particles/plasmapatrol/content/pics/finalfrontier.png delete mode 100644 examples/declarative/particles/plasmapatrol/content/pics/meteor.png delete mode 100644 examples/declarative/particles/plasmapatrol/content/pics/meteor_explo.png delete mode 100644 examples/declarative/particles/plasmapatrol/content/pics/nullRock.png delete mode 100644 examples/declarative/particles/plasmapatrol/content/pics/particle.png delete mode 100644 examples/declarative/particles/plasmapatrol/content/pics/star.png delete mode 100644 examples/declarative/particles/plasmapatrol/content/pics/star2.png delete mode 100644 examples/declarative/particles/plasmapatrol/content/pics/star3.png delete mode 100644 examples/declarative/particles/plasmapatrol/plasmapatrol.qml delete mode 100644 examples/declarative/particles/simple/dynamiccomparison.qml delete mode 100644 examples/declarative/particles/simple/dynamicemitters.qml delete mode 100644 examples/declarative/particles/simple/multiplepainters.qml delete mode 100644 examples/declarative/particles/simple/startstop.qml delete mode 100644 examples/declarative/photoviewer/PhotoViewerCore/AlbumDelegate.qml delete mode 100644 examples/declarative/photoviewer/PhotoViewerCore/BusyIndicator.qml delete mode 100644 examples/declarative/photoviewer/PhotoViewerCore/Button.qml delete mode 100644 examples/declarative/photoviewer/PhotoViewerCore/EditableButton.qml delete mode 100644 examples/declarative/photoviewer/PhotoViewerCore/PhotoDelegate.qml delete mode 100644 examples/declarative/photoviewer/PhotoViewerCore/ProgressBar.qml delete mode 100644 examples/declarative/photoviewer/PhotoViewerCore/RssModel.qml delete mode 100644 examples/declarative/photoviewer/PhotoViewerCore/Tag.qml delete mode 100644 examples/declarative/photoviewer/PhotoViewerCore/images/box-shadow.png delete mode 100644 examples/declarative/photoviewer/PhotoViewerCore/images/busy.png delete mode 100644 examples/declarative/photoviewer/PhotoViewerCore/images/cardboard.png delete mode 100644 examples/declarative/photoviewer/PhotoViewerCore/qmldir delete mode 100644 examples/declarative/photoviewer/PhotoViewerCore/script/script.js delete mode 100644 examples/declarative/photoviewer/i18n/base.ts delete mode 100644 examples/declarative/photoviewer/i18n/qml_fr.qm delete mode 100644 examples/declarative/photoviewer/i18n/qml_fr.ts delete mode 100644 examples/declarative/photoviewer/photoviewer.qml delete mode 100644 examples/declarative/photoviewer/photoviewer.qmlproject delete mode 100644 examples/declarative/positioners/content/Button.qml delete mode 100644 examples/declarative/positioners/content/add.png delete mode 100644 examples/declarative/positioners/content/del.png delete mode 100644 examples/declarative/positioners/positioners-attachedproperties.qml delete mode 100644 examples/declarative/positioners/positioners.qml delete mode 100644 examples/declarative/righttoleft/layoutdirection/layoutdirection.qml delete mode 100644 examples/declarative/righttoleft/layoutdirection/layoutdirection.qmlproject delete mode 100644 examples/declarative/righttoleft/layoutmirroring/layoutmirroring.qml delete mode 100644 examples/declarative/righttoleft/layoutmirroring/layoutmirroring.qmlproject delete mode 100644 examples/declarative/righttoleft/textalignment/textalignment.qml delete mode 100644 examples/declarative/righttoleft/textalignment/textalignment.qmlproject delete mode 100644 examples/declarative/rssnews/content/BusyIndicator.qml delete mode 100644 examples/declarative/rssnews/content/CategoryDelegate.qml delete mode 100644 examples/declarative/rssnews/content/NewsDelegate.qml delete mode 100644 examples/declarative/rssnews/content/RssFeeds.qml delete mode 100644 examples/declarative/rssnews/content/ScrollBar.qml delete mode 100644 examples/declarative/rssnews/content/images/busy.png delete mode 100644 examples/declarative/rssnews/content/images/scrollbar.png delete mode 100644 examples/declarative/rssnews/rssnews.qml delete mode 100644 examples/declarative/rssnews/rssnews.qmlproject delete mode 100644 examples/declarative/samegame/content/BoomBlock.qml delete mode 100644 examples/declarative/samegame/content/Button.qml delete mode 100644 examples/declarative/samegame/content/Dialog.qml delete mode 100644 examples/declarative/samegame/content/GameArea.qml delete mode 100644 examples/declarative/samegame/content/NameInputDialog.qml delete mode 100644 examples/declarative/samegame/content/pics/background.png delete mode 100644 examples/declarative/samegame/content/pics/blueStone.png delete mode 100644 examples/declarative/samegame/content/pics/greenStone.png delete mode 100644 examples/declarative/samegame/content/pics/particle.png delete mode 100644 examples/declarative/samegame/content/pics/redStone.png delete mode 100644 examples/declarative/samegame/content/pics/yellowStone.png delete mode 100755 examples/declarative/samegame/content/samegame.js delete mode 100644 examples/declarative/samegame/samegame.qml delete mode 100644 examples/declarative/samegame/samegame.qmlproject delete mode 100644 examples/declarative/script/script.pro delete mode 100644 examples/declarative/script/shell/main.cpp delete mode 100644 examples/declarative/script/shell/shell.pro delete mode 100644 examples/declarative/shadereffects/content/Slider.qml delete mode 100644 examples/declarative/shadereffects/content/face-smile.png delete mode 100644 examples/declarative/shadereffects/content/qt-logo.png delete mode 100644 examples/declarative/shadereffects/shadereffects.qml delete mode 100644 examples/declarative/shared/Button.qml delete mode 100644 examples/declarative/shared/LauncherList.qml delete mode 100644 examples/declarative/shared/README delete mode 100644 examples/declarative/shared/SimpleLauncherDelegate.qml delete mode 100644 examples/declarative/shared/back.png delete mode 100644 examples/declarative/snake/content/Button.qml delete mode 100644 examples/declarative/snake/content/Cookie.qml delete mode 100644 examples/declarative/snake/content/HighScoreModel.qml delete mode 100644 examples/declarative/snake/content/Link.qml delete mode 100644 examples/declarative/snake/content/Skull.qml delete mode 100644 examples/declarative/snake/content/pics/README delete mode 100644 examples/declarative/snake/content/pics/background.png delete mode 100644 examples/declarative/snake/content/pics/blueStar.png delete mode 100644 examples/declarative/snake/content/pics/blueStone.png delete mode 100644 examples/declarative/snake/content/pics/cookie.png delete mode 100644 examples/declarative/snake/content/pics/eyes.svg delete mode 100644 examples/declarative/snake/content/pics/head.png delete mode 100644 examples/declarative/snake/content/pics/pause.png delete mode 100644 examples/declarative/snake/content/pics/redStar.png delete mode 100644 examples/declarative/snake/content/pics/redStone.png delete mode 100644 examples/declarative/snake/content/pics/skull.png delete mode 100644 examples/declarative/snake/content/pics/snake.jpg delete mode 100644 examples/declarative/snake/content/pics/star.png delete mode 100644 examples/declarative/snake/content/pics/stoneShadow.png delete mode 100644 examples/declarative/snake/content/pics/yellowStar.png delete mode 100644 examples/declarative/snake/content/pics/yellowStone.png delete mode 100644 examples/declarative/snake/content/snake.js delete mode 100644 examples/declarative/snake/snake.qml delete mode 100644 examples/declarative/snake/snake.qmlproject delete mode 100644 examples/declarative/sqllocalstorage/hello.qml delete mode 100644 examples/declarative/text/fonts/availableFonts.qml delete mode 100644 examples/declarative/text/fonts/banner.qml delete mode 100644 examples/declarative/text/fonts/content/fonts/tarzeau_ocr_a.ttf delete mode 100644 examples/declarative/text/fonts/fonts.qml delete mode 100644 examples/declarative/text/fonts/hello.qml delete mode 100644 examples/declarative/text/imgtag/TextWithImage.qml delete mode 100644 examples/declarative/text/imgtag/images/face-sad.png delete mode 100644 examples/declarative/text/imgtag/images/face-smile-big.png delete mode 100644 examples/declarative/text/imgtag/images/face-smile.png delete mode 100644 examples/declarative/text/imgtag/images/heart200.png delete mode 100644 examples/declarative/text/imgtag/images/qtlogo.png delete mode 100644 examples/declarative/text/imgtag/images/starfish_2.png delete mode 100644 examples/declarative/text/imgtag/imgtag.qml delete mode 100644 examples/declarative/text/styledtext-layout.qml delete mode 100644 examples/declarative/text/text.qml delete mode 100644 examples/declarative/text/text.qmlproject delete mode 100644 examples/declarative/text/textselection/pics/endHandle.png delete mode 100644 examples/declarative/text/textselection/pics/endHandle.sci delete mode 100644 examples/declarative/text/textselection/pics/startHandle.png delete mode 100644 examples/declarative/text/textselection/pics/startHandle.sci delete mode 100644 examples/declarative/text/textselection/textselection.qml delete mode 100644 examples/declarative/threading/threadedlistmodel/dataloader.js delete mode 100644 examples/declarative/threading/threadedlistmodel/threadedlistmodel.qmlproject delete mode 100644 examples/declarative/threading/threadedlistmodel/timedisplay.qml delete mode 100644 examples/declarative/threading/workerscript/workerscript.js delete mode 100644 examples/declarative/threading/workerscript/workerscript.qml delete mode 100644 examples/declarative/threading/workerscript/workerscript.qmlproject delete mode 100644 examples/declarative/touchinteraction/mousearea/mousearea-example.qml delete mode 100644 examples/declarative/touchinteraction/multipointtouch/bearwhack.qml delete mode 100644 examples/declarative/touchinteraction/multipointtouch/content/AugmentedTouchPoint.qml delete mode 100644 examples/declarative/touchinteraction/multipointtouch/content/Bear0.png delete mode 100644 examples/declarative/touchinteraction/multipointtouch/content/Bear1.png delete mode 100644 examples/declarative/touchinteraction/multipointtouch/content/Bear2.png delete mode 100644 examples/declarative/touchinteraction/multipointtouch/content/Bear3.png delete mode 100644 examples/declarative/touchinteraction/multipointtouch/content/BearB.png delete mode 100644 examples/declarative/touchinteraction/multipointtouch/content/BearWhackParticleSystem.qml delete mode 100644 examples/declarative/touchinteraction/multipointtouch/content/ParticleFlame.qml delete mode 100644 examples/declarative/touchinteraction/multipointtouch/content/blur-circle.png delete mode 100644 examples/declarative/touchinteraction/multipointtouch/content/blur-circle3.png delete mode 100644 examples/declarative/touchinteraction/multipointtouch/content/heart-blur.png delete mode 100644 examples/declarative/touchinteraction/multipointtouch/content/title.png delete mode 100644 examples/declarative/touchinteraction/multipointtouch/multiflame.qml delete mode 100644 examples/declarative/touchinteraction/pincharea/flickresize.qml delete mode 100644 examples/declarative/touchinteraction/pincharea/qt-logo.jpg delete mode 100644 examples/declarative/touchinteraction/touchinteraction.qml delete mode 100644 examples/declarative/touchinteraction/touchinteraction.qmlproject delete mode 100644 examples/declarative/toys/clocks/clocks.qml delete mode 100644 examples/declarative/toys/clocks/content/Clock.qml delete mode 100644 examples/declarative/toys/clocks/content/QuitButton.qml delete mode 100644 examples/declarative/toys/clocks/content/arrow.png delete mode 100644 examples/declarative/toys/clocks/content/background.png delete mode 100644 examples/declarative/toys/clocks/content/center.png delete mode 100644 examples/declarative/toys/clocks/content/clock-night.png delete mode 100644 examples/declarative/toys/clocks/content/clock.png delete mode 100644 examples/declarative/toys/clocks/content/hour.png delete mode 100644 examples/declarative/toys/clocks/content/minute.png delete mode 100644 examples/declarative/toys/clocks/content/quit.png delete mode 100644 examples/declarative/toys/clocks/content/second.png delete mode 100644 examples/declarative/toys/corkboards/content/Day.qml delete mode 100644 examples/declarative/toys/corkboards/content/cork.jpg delete mode 100644 examples/declarative/toys/corkboards/content/note-yellow.png delete mode 100644 examples/declarative/toys/corkboards/content/tack.png delete mode 100644 examples/declarative/toys/corkboards/corkboards.qml delete mode 100644 examples/declarative/toys/dynamicscene/content/Button.qml delete mode 100644 examples/declarative/toys/dynamicscene/content/GenericSceneItem.qml delete mode 100644 examples/declarative/toys/dynamicscene/content/PaletteItem.qml delete mode 100644 examples/declarative/toys/dynamicscene/content/PerspectiveItem.qml delete mode 100644 examples/declarative/toys/dynamicscene/content/Sun.qml delete mode 100644 examples/declarative/toys/dynamicscene/content/images/NOTE delete mode 100644 examples/declarative/toys/dynamicscene/content/images/face-smile.png delete mode 100644 examples/declarative/toys/dynamicscene/content/images/moon.png delete mode 100644 examples/declarative/toys/dynamicscene/content/images/rabbit_brown.png delete mode 100644 examples/declarative/toys/dynamicscene/content/images/rabbit_bw.png delete mode 100644 examples/declarative/toys/dynamicscene/content/images/star.png delete mode 100644 examples/declarative/toys/dynamicscene/content/images/sun.png delete mode 100644 examples/declarative/toys/dynamicscene/content/images/tree_s.png delete mode 100644 examples/declarative/toys/dynamicscene/content/itemCreation.js delete mode 100644 examples/declarative/toys/dynamicscene/dynamicscene.qml delete mode 100644 examples/declarative/toys/tic-tac-toe/content/Button.qml delete mode 100644 examples/declarative/toys/tic-tac-toe/content/TicTac.qml delete mode 100644 examples/declarative/toys/tic-tac-toe/content/pics/board.png delete mode 100644 examples/declarative/toys/tic-tac-toe/content/pics/o.png delete mode 100644 examples/declarative/toys/tic-tac-toe/content/pics/x.png delete mode 100644 examples/declarative/toys/tic-tac-toe/content/tic-tac-toe.js delete mode 100644 examples/declarative/toys/tic-tac-toe/tic-tac-toe.qml delete mode 100644 examples/declarative/toys/tvtennis/tvtennis.qml delete mode 100644 examples/declarative/tutorials/dynamicview/dynamicview1/PetsModel.qml delete mode 100644 examples/declarative/tutorials/dynamicview/dynamicview1/dynamicview.qml delete mode 100644 examples/declarative/tutorials/dynamicview/dynamicview2/PetsModel.qml delete mode 100644 examples/declarative/tutorials/dynamicview/dynamicview2/dynamicview.qml delete mode 100644 examples/declarative/tutorials/dynamicview/dynamicview3/PetsModel.qml delete mode 100644 examples/declarative/tutorials/dynamicview/dynamicview3/dynamicview.qml delete mode 100644 examples/declarative/tutorials/dynamicview/dynamicview4/ListSelector.qml delete mode 100644 examples/declarative/tutorials/dynamicview/dynamicview4/PetsModel.qml delete mode 100644 examples/declarative/tutorials/dynamicview/dynamicview4/dynamicview.qml delete mode 100644 examples/declarative/tutorials/extending/chapter1-basics/app.qml delete mode 100644 examples/declarative/tutorials/extending/chapter1-basics/chapter1-basics.pro delete mode 100644 examples/declarative/tutorials/extending/chapter1-basics/main.cpp delete mode 100644 examples/declarative/tutorials/extending/chapter1-basics/piechart.cpp delete mode 100644 examples/declarative/tutorials/extending/chapter1-basics/piechart.h delete mode 100644 examples/declarative/tutorials/extending/chapter2-methods/app.qml delete mode 100644 examples/declarative/tutorials/extending/chapter2-methods/chapter2-methods.pro delete mode 100644 examples/declarative/tutorials/extending/chapter2-methods/main.cpp delete mode 100644 examples/declarative/tutorials/extending/chapter2-methods/piechart.cpp delete mode 100644 examples/declarative/tutorials/extending/chapter2-methods/piechart.h delete mode 100644 examples/declarative/tutorials/extending/chapter3-bindings/app.qml delete mode 100644 examples/declarative/tutorials/extending/chapter3-bindings/chapter3-bindings.pro delete mode 100644 examples/declarative/tutorials/extending/chapter3-bindings/main.cpp delete mode 100644 examples/declarative/tutorials/extending/chapter3-bindings/piechart.cpp delete mode 100644 examples/declarative/tutorials/extending/chapter3-bindings/piechart.h delete mode 100644 examples/declarative/tutorials/extending/chapter4-customPropertyTypes/app.qml delete mode 100644 examples/declarative/tutorials/extending/chapter4-customPropertyTypes/chapter4-customPropertyTypes.pro delete mode 100644 examples/declarative/tutorials/extending/chapter4-customPropertyTypes/main.cpp delete mode 100644 examples/declarative/tutorials/extending/chapter4-customPropertyTypes/piechart.cpp delete mode 100644 examples/declarative/tutorials/extending/chapter4-customPropertyTypes/piechart.h delete mode 100644 examples/declarative/tutorials/extending/chapter4-customPropertyTypes/pieslice.cpp delete mode 100644 examples/declarative/tutorials/extending/chapter4-customPropertyTypes/pieslice.h delete mode 100644 examples/declarative/tutorials/extending/chapter5-listproperties/app.qml delete mode 100644 examples/declarative/tutorials/extending/chapter5-listproperties/chapter5-listproperties.pro delete mode 100644 examples/declarative/tutorials/extending/chapter5-listproperties/main.cpp delete mode 100644 examples/declarative/tutorials/extending/chapter5-listproperties/piechart.cpp delete mode 100644 examples/declarative/tutorials/extending/chapter5-listproperties/piechart.h delete mode 100644 examples/declarative/tutorials/extending/chapter5-listproperties/pieslice.cpp delete mode 100644 examples/declarative/tutorials/extending/chapter5-listproperties/pieslice.h delete mode 100644 examples/declarative/tutorials/extending/chapter6-plugins/ChartsPlugin/qmldir delete mode 100644 examples/declarative/tutorials/extending/chapter6-plugins/app.qml delete mode 100644 examples/declarative/tutorials/extending/chapter6-plugins/chapter6-plugins.pro delete mode 100644 examples/declarative/tutorials/extending/chapter6-plugins/chartsplugin.cpp delete mode 100644 examples/declarative/tutorials/extending/chapter6-plugins/chartsplugin.h delete mode 100644 examples/declarative/tutorials/extending/chapter6-plugins/piechart.cpp delete mode 100644 examples/declarative/tutorials/extending/chapter6-plugins/piechart.h delete mode 100644 examples/declarative/tutorials/extending/chapter6-plugins/pieslice.cpp delete mode 100644 examples/declarative/tutorials/extending/chapter6-plugins/pieslice.h delete mode 100644 examples/declarative/tutorials/extending/extending.pro delete mode 100644 examples/declarative/tutorials/helloworld/Cell.qml delete mode 100644 examples/declarative/tutorials/helloworld/tutorial1.qml delete mode 100644 examples/declarative/tutorials/helloworld/tutorial2.qml delete mode 100644 examples/declarative/tutorials/helloworld/tutorial3.qml delete mode 100644 examples/declarative/tutorials/samegame/samegame1/Block.qml delete mode 100644 examples/declarative/tutorials/samegame/samegame1/Button.qml delete mode 100644 examples/declarative/tutorials/samegame/samegame1/samegame.qml delete mode 100644 examples/declarative/tutorials/samegame/samegame1/samegame1.qmlproject delete mode 100644 examples/declarative/tutorials/samegame/samegame2/Block.qml delete mode 100644 examples/declarative/tutorials/samegame/samegame2/Button.qml delete mode 100644 examples/declarative/tutorials/samegame/samegame2/samegame.js delete mode 100644 examples/declarative/tutorials/samegame/samegame2/samegame.qml delete mode 100644 examples/declarative/tutorials/samegame/samegame2/samegame2.qmlproject delete mode 100644 examples/declarative/tutorials/samegame/samegame3/Block.qml delete mode 100644 examples/declarative/tutorials/samegame/samegame3/Button.qml delete mode 100644 examples/declarative/tutorials/samegame/samegame3/Dialog.qml delete mode 100644 examples/declarative/tutorials/samegame/samegame3/samegame.js delete mode 100644 examples/declarative/tutorials/samegame/samegame3/samegame.qml delete mode 100644 examples/declarative/tutorials/samegame/samegame3/samegame3.qmlproject delete mode 100644 examples/declarative/tutorials/samegame/samegame4/content/BoomBlock.qml delete mode 100644 examples/declarative/tutorials/samegame/samegame4/content/Button.qml delete mode 100644 examples/declarative/tutorials/samegame/samegame4/content/Dialog.qml delete mode 100755 examples/declarative/tutorials/samegame/samegame4/content/samegame.js delete mode 100644 examples/declarative/tutorials/samegame/samegame4/highscores/README delete mode 100755 examples/declarative/tutorials/samegame/samegame4/highscores/score_data.xml delete mode 100755 examples/declarative/tutorials/samegame/samegame4/highscores/score_style.xsl delete mode 100755 examples/declarative/tutorials/samegame/samegame4/highscores/scores.php delete mode 100644 examples/declarative/tutorials/samegame/samegame4/samegame.qml delete mode 100644 examples/declarative/tutorials/samegame/samegame4/samegame4.qmlproject delete mode 100644 examples/declarative/tutorials/samegame/shared/pics/background.jpg delete mode 100644 examples/declarative/tutorials/samegame/shared/pics/blueStar.png delete mode 100644 examples/declarative/tutorials/samegame/shared/pics/blueStone.png delete mode 100644 examples/declarative/tutorials/samegame/shared/pics/greenStar.png delete mode 100644 examples/declarative/tutorials/samegame/shared/pics/greenStone.png delete mode 100644 examples/declarative/tutorials/samegame/shared/pics/redStar.png delete mode 100644 examples/declarative/tutorials/samegame/shared/pics/redStone.png delete mode 100644 examples/declarative/tutorials/samegame/shared/pics/star.png delete mode 100644 examples/declarative/tutorials/samegame/shared/pics/yellowStone.png delete mode 100644 examples/declarative/tutorials/tutorials.pro delete mode 100644 examples/declarative/tutorials/tutorials.qmlproject delete mode 100644 examples/declarative/twitter/TwitterCore/Button.qml delete mode 100644 examples/declarative/twitter/TwitterCore/FatDelegate.qml delete mode 100644 examples/declarative/twitter/TwitterCore/Input.qml delete mode 100644 examples/declarative/twitter/TwitterCore/Loading.qml delete mode 100644 examples/declarative/twitter/TwitterCore/MultiTitleBar.qml delete mode 100644 examples/declarative/twitter/TwitterCore/RssModel.qml delete mode 100644 examples/declarative/twitter/TwitterCore/SearchView.qml delete mode 100644 examples/declarative/twitter/TwitterCore/TitleBar.qml delete mode 100644 examples/declarative/twitter/TwitterCore/ToolBar.qml delete mode 100644 examples/declarative/twitter/TwitterCore/UserModel.qml delete mode 100644 examples/declarative/twitter/TwitterCore/images/gloss.png delete mode 100644 examples/declarative/twitter/TwitterCore/images/lineedit.png delete mode 100644 examples/declarative/twitter/TwitterCore/images/lineedit.sci delete mode 100644 examples/declarative/twitter/TwitterCore/images/loading.png delete mode 100644 examples/declarative/twitter/TwitterCore/images/quit.png delete mode 100644 examples/declarative/twitter/TwitterCore/images/stripes.png delete mode 100644 examples/declarative/twitter/TwitterCore/images/titlebar.png delete mode 100644 examples/declarative/twitter/TwitterCore/images/titlebar.sci delete mode 100644 examples/declarative/twitter/TwitterCore/images/toolbutton.png delete mode 100644 examples/declarative/twitter/TwitterCore/images/toolbutton.sci delete mode 100644 examples/declarative/twitter/TwitterCore/qmldir delete mode 100644 examples/declarative/twitter/twitter.qml delete mode 100644 examples/declarative/twitter/twitter.qmlproject delete mode 100644 examples/declarative/ui-components/dialcontrol/content/Dial.qml delete mode 100644 examples/declarative/ui-components/dialcontrol/content/QuitButton.qml delete mode 100644 examples/declarative/ui-components/dialcontrol/content/background.png delete mode 100644 examples/declarative/ui-components/dialcontrol/content/needle.png delete mode 100644 examples/declarative/ui-components/dialcontrol/content/needle_shadow.png delete mode 100644 examples/declarative/ui-components/dialcontrol/content/overlay.png delete mode 100644 examples/declarative/ui-components/dialcontrol/content/quit.png delete mode 100644 examples/declarative/ui-components/dialcontrol/dialcontrol.qml delete mode 100644 examples/declarative/ui-components/flipable/content/5_heart.png delete mode 100644 examples/declarative/ui-components/flipable/content/9_club.png delete mode 100644 examples/declarative/ui-components/flipable/content/Card.qml delete mode 100644 examples/declarative/ui-components/flipable/content/back.png delete mode 100644 examples/declarative/ui-components/flipable/flipable.qml delete mode 100644 examples/declarative/ui-components/progressbar/content/ProgressBar.qml delete mode 100644 examples/declarative/ui-components/progressbar/content/background.png delete mode 100644 examples/declarative/ui-components/progressbar/main.qml delete mode 100644 examples/declarative/ui-components/scrollbar/ScrollBar.qml delete mode 100644 examples/declarative/ui-components/scrollbar/main.qml delete mode 100644 examples/declarative/ui-components/scrollbar/pics/niagara_falls.jpg delete mode 100644 examples/declarative/ui-components/scrollbar/scrollbar.qmlproject delete mode 100644 examples/declarative/ui-components/searchbox/SearchBox.qml delete mode 100644 examples/declarative/ui-components/searchbox/images/clear.png delete mode 100644 examples/declarative/ui-components/searchbox/images/lineedit-bg-focus.png delete mode 100644 examples/declarative/ui-components/searchbox/images/lineedit-bg.png delete mode 100644 examples/declarative/ui-components/searchbox/main.qml delete mode 100644 examples/declarative/ui-components/searchbox/searchbox.qmlproject delete mode 100644 examples/declarative/ui-components/slideswitch/content/Switch.qml delete mode 100644 examples/declarative/ui-components/slideswitch/content/background.png delete mode 100644 examples/declarative/ui-components/slideswitch/content/background.svg delete mode 100644 examples/declarative/ui-components/slideswitch/content/knob.png delete mode 100644 examples/declarative/ui-components/slideswitch/content/knob.svg delete mode 100644 examples/declarative/ui-components/slideswitch/slideswitch.qml delete mode 100644 examples/declarative/ui-components/spinner/content/Spinner.qml delete mode 100644 examples/declarative/ui-components/spinner/content/spinner-bg.png delete mode 100644 examples/declarative/ui-components/spinner/content/spinner-select.png delete mode 100644 examples/declarative/ui-components/spinner/main.qml delete mode 100644 examples/declarative/ui-components/spinner/spinner.qmlproject delete mode 100644 examples/declarative/ui-components/tabwidget/TabWidget.qml delete mode 100644 examples/declarative/ui-components/tabwidget/main.qml delete mode 100644 examples/declarative/ui-components/tabwidget/tab.png delete mode 100644 examples/declarative/ui-components/tabwidget/tabwidget.qmlproject delete mode 100644 examples/declarative/window/Window.qml delete mode 100644 examples/declarative/window/screen/screenInfo.qml delete mode 100644 examples/declarative/window/standalone.qml delete mode 100644 examples/declarative/window/window.cpp delete mode 100644 examples/declarative/window/window.pro delete mode 100644 examples/declarative/xml/xmlhttprequest/data.xml delete mode 100644 examples/declarative/xml/xmlhttprequest/xmlhttprequest-example.qml create mode 100644 examples/qml/README create mode 100644 examples/qml/accessibility/accessibility.qml create mode 100644 examples/qml/accessibility/widgets/Button.qml create mode 100644 examples/qml/animation/animation.qml create mode 100644 examples/qml/animation/animation.qmlproject create mode 100644 examples/qml/animation/basics/color-animation.qml create mode 100644 examples/qml/animation/basics/images/face-smile.png create mode 100644 examples/qml/animation/basics/images/moon.png create mode 100644 examples/qml/animation/basics/images/shadow.png create mode 100644 examples/qml/animation/basics/images/star.png create mode 100644 examples/qml/animation/basics/images/sun.png create mode 100644 examples/qml/animation/basics/property-animation.qml create mode 100644 examples/qml/animation/behaviors/SideRect.qml create mode 100644 examples/qml/animation/behaviors/behavior-example.qml create mode 100644 examples/qml/animation/behaviors/wigglytext.qml create mode 100644 examples/qml/animation/easing/content/QuitButton.qml create mode 100644 examples/qml/animation/easing/content/quit.png create mode 100644 examples/qml/animation/easing/easing.qml create mode 100644 examples/qml/animation/pathanimation/pathanimation.qml create mode 100644 examples/qml/animation/pathinterpolator/pathinterpolator.qml create mode 100644 examples/qml/animation/states/qt-logo.png create mode 100644 examples/qml/animation/states/states.qml create mode 100644 examples/qml/animation/states/transitions.qml create mode 100644 examples/qml/calculator/calculator.qml create mode 100644 examples/qml/calculator/content/Button.qml create mode 100644 examples/qml/calculator/content/Display.qml create mode 100644 examples/qml/calculator/content/calculator.js create mode 100644 examples/qml/calculator/content/images/button-.png create mode 100644 examples/qml/calculator/content/images/button-blue.png create mode 100644 examples/qml/calculator/content/images/button-green.png create mode 100644 examples/qml/calculator/content/images/button-purple.png create mode 100644 examples/qml/calculator/content/images/button-red.png create mode 100644 examples/qml/calculator/content/images/display.png create mode 100644 examples/qml/calculator/content/qmldir create mode 100644 examples/qml/canvas/bezierCurve/bezierCurve.qml create mode 100644 examples/qml/canvas/clip/clip.qml create mode 100644 examples/qml/canvas/contents/Button.qml create mode 100644 examples/qml/canvas/contents/ScrollBar.qml create mode 100644 examples/qml/canvas/contents/Slider.qml create mode 100644 examples/qml/canvas/contents/Stocks.qml create mode 100644 examples/qml/canvas/contents/TitleBar.qml create mode 100644 examples/qml/canvas/contents/ToolBar.qml create mode 100644 examples/qml/canvas/contents/images/button-pressed.png create mode 100644 examples/qml/canvas/contents/images/button.png create mode 100644 examples/qml/canvas/contents/images/default.svg create mode 100755 examples/qml/canvas/contents/images/gloss.png create mode 100755 examples/qml/canvas/contents/images/lineedit.png create mode 100644 examples/qml/canvas/contents/images/lineedit.sci create mode 100755 examples/qml/canvas/contents/images/quit.png create mode 100755 examples/qml/canvas/contents/images/stripes.png create mode 100755 examples/qml/canvas/contents/images/titlebar.png create mode 100644 examples/qml/canvas/contents/images/titlebar.sci create mode 100755 examples/qml/canvas/contents/images/toolbutton.png create mode 100644 examples/qml/canvas/contents/images/toolbutton.sci create mode 100644 examples/qml/canvas/contents/qt-logo.png create mode 100644 examples/qml/canvas/quadraticCurveTo/quadraticCurveTo.qml create mode 100644 examples/qml/canvas/roundedrect/roundedrect.qml create mode 100644 examples/qml/canvas/smile/smile.qml create mode 100644 examples/qml/canvas/squircle/squircle.png create mode 100644 examples/qml/canvas/squircle/squircle.qml create mode 100644 examples/qml/canvas/stockchart/README create mode 100644 examples/qml/canvas/stockchart/com/nokia/StockChartExample/qmldir create mode 100644 examples/qml/canvas/stockchart/model.cpp create mode 100644 examples/qml/canvas/stockchart/model.h create mode 100644 examples/qml/canvas/stockchart/plugin.cpp create mode 100644 examples/qml/canvas/stockchart/stock.qml create mode 100644 examples/qml/canvas/stockchart/stockchart.pro create mode 100644 examples/qml/canvas/tiger/tiger.js create mode 100644 examples/qml/canvas/tiger/tiger.qml create mode 100644 examples/qml/canvas/twitterfriends/TwitterUser.qml create mode 100644 examples/qml/canvas/twitterfriends/cache.js create mode 100644 examples/qml/canvas/twitterfriends/twitter.qml create mode 100644 examples/qml/cppextensions/cppextensions.pro create mode 100644 examples/qml/cppextensions/cppextensions.qmlproject create mode 100644 examples/qml/cppextensions/imageprovider/ImageProviderCore/qmldir create mode 100644 examples/qml/cppextensions/imageprovider/imageprovider-example.qml create mode 100644 examples/qml/cppextensions/imageprovider/imageprovider.cpp create mode 100644 examples/qml/cppextensions/imageprovider/imageprovider.pro create mode 100644 examples/qml/cppextensions/imageprovider/imageprovider.qmlproject create mode 100644 examples/qml/cppextensions/networkaccessmanagerfactory/main.cpp create mode 100644 examples/qml/cppextensions/networkaccessmanagerfactory/networkaccessmanagerfactory.pro create mode 100644 examples/qml/cppextensions/networkaccessmanagerfactory/networkaccessmanagerfactory.qmlproject create mode 100644 examples/qml/cppextensions/networkaccessmanagerfactory/networkaccessmanagerfactory.qrc create mode 100644 examples/qml/cppextensions/networkaccessmanagerfactory/view.qml create mode 100644 examples/qml/cppextensions/plugins/README create mode 100644 examples/qml/cppextensions/plugins/com/nokia/TimeExample/Clock.qml create mode 100644 examples/qml/cppextensions/plugins/com/nokia/TimeExample/center.png create mode 100644 examples/qml/cppextensions/plugins/com/nokia/TimeExample/clock.png create mode 100644 examples/qml/cppextensions/plugins/com/nokia/TimeExample/hour.png create mode 100644 examples/qml/cppextensions/plugins/com/nokia/TimeExample/minute.png create mode 100644 examples/qml/cppextensions/plugins/com/nokia/TimeExample/qmldir create mode 100644 examples/qml/cppextensions/plugins/plugin.cpp create mode 100644 examples/qml/cppextensions/plugins/plugins.pro create mode 100644 examples/qml/cppextensions/plugins/plugins.qml create mode 100644 examples/qml/cppextensions/plugins/plugins.qmlproject create mode 100644 examples/qml/cppextensions/referenceexamples/adding/adding.pro create mode 100644 examples/qml/cppextensions/referenceexamples/adding/adding.qrc create mode 100644 examples/qml/cppextensions/referenceexamples/adding/example.qml create mode 100644 examples/qml/cppextensions/referenceexamples/adding/main.cpp create mode 100644 examples/qml/cppextensions/referenceexamples/adding/person.cpp create mode 100644 examples/qml/cppextensions/referenceexamples/adding/person.h create mode 100644 examples/qml/cppextensions/referenceexamples/attached/attached.pro create mode 100644 examples/qml/cppextensions/referenceexamples/attached/attached.qrc create mode 100644 examples/qml/cppextensions/referenceexamples/attached/birthdayparty.cpp create mode 100644 examples/qml/cppextensions/referenceexamples/attached/birthdayparty.h create mode 100644 examples/qml/cppextensions/referenceexamples/attached/example.qml create mode 100644 examples/qml/cppextensions/referenceexamples/attached/main.cpp create mode 100644 examples/qml/cppextensions/referenceexamples/attached/person.cpp create mode 100644 examples/qml/cppextensions/referenceexamples/attached/person.h create mode 100644 examples/qml/cppextensions/referenceexamples/binding/binding.pro create mode 100644 examples/qml/cppextensions/referenceexamples/binding/binding.qrc create mode 100644 examples/qml/cppextensions/referenceexamples/binding/birthdayparty.cpp create mode 100644 examples/qml/cppextensions/referenceexamples/binding/birthdayparty.h create mode 100644 examples/qml/cppextensions/referenceexamples/binding/example.qml create mode 100644 examples/qml/cppextensions/referenceexamples/binding/happybirthdaysong.cpp create mode 100644 examples/qml/cppextensions/referenceexamples/binding/happybirthdaysong.h create mode 100644 examples/qml/cppextensions/referenceexamples/binding/main.cpp create mode 100644 examples/qml/cppextensions/referenceexamples/binding/person.cpp create mode 100644 examples/qml/cppextensions/referenceexamples/binding/person.h create mode 100644 examples/qml/cppextensions/referenceexamples/coercion/birthdayparty.cpp create mode 100644 examples/qml/cppextensions/referenceexamples/coercion/birthdayparty.h create mode 100644 examples/qml/cppextensions/referenceexamples/coercion/coercion.pro create mode 100644 examples/qml/cppextensions/referenceexamples/coercion/coercion.qrc create mode 100644 examples/qml/cppextensions/referenceexamples/coercion/example.qml create mode 100644 examples/qml/cppextensions/referenceexamples/coercion/main.cpp create mode 100644 examples/qml/cppextensions/referenceexamples/coercion/person.cpp create mode 100644 examples/qml/cppextensions/referenceexamples/coercion/person.h create mode 100644 examples/qml/cppextensions/referenceexamples/default/birthdayparty.cpp create mode 100644 examples/qml/cppextensions/referenceexamples/default/birthdayparty.h create mode 100644 examples/qml/cppextensions/referenceexamples/default/default.pro create mode 100644 examples/qml/cppextensions/referenceexamples/default/default.qrc create mode 100644 examples/qml/cppextensions/referenceexamples/default/example.qml create mode 100644 examples/qml/cppextensions/referenceexamples/default/main.cpp create mode 100644 examples/qml/cppextensions/referenceexamples/default/person.cpp create mode 100644 examples/qml/cppextensions/referenceexamples/default/person.h create mode 100644 examples/qml/cppextensions/referenceexamples/extended/example.qml create mode 100644 examples/qml/cppextensions/referenceexamples/extended/extended.pro create mode 100644 examples/qml/cppextensions/referenceexamples/extended/extended.qrc create mode 100644 examples/qml/cppextensions/referenceexamples/extended/lineedit.cpp create mode 100644 examples/qml/cppextensions/referenceexamples/extended/lineedit.h create mode 100644 examples/qml/cppextensions/referenceexamples/extended/main.cpp create mode 100644 examples/qml/cppextensions/referenceexamples/grouped/birthdayparty.cpp create mode 100644 examples/qml/cppextensions/referenceexamples/grouped/birthdayparty.h create mode 100644 examples/qml/cppextensions/referenceexamples/grouped/example.qml create mode 100644 examples/qml/cppextensions/referenceexamples/grouped/grouped.pro create mode 100644 examples/qml/cppextensions/referenceexamples/grouped/grouped.qrc create mode 100644 examples/qml/cppextensions/referenceexamples/grouped/main.cpp create mode 100644 examples/qml/cppextensions/referenceexamples/grouped/person.cpp create mode 100644 examples/qml/cppextensions/referenceexamples/grouped/person.h create mode 100644 examples/qml/cppextensions/referenceexamples/methods/birthdayparty.cpp create mode 100644 examples/qml/cppextensions/referenceexamples/methods/birthdayparty.h create mode 100644 examples/qml/cppextensions/referenceexamples/methods/example.qml create mode 100644 examples/qml/cppextensions/referenceexamples/methods/main.cpp create mode 100644 examples/qml/cppextensions/referenceexamples/methods/methods.pro create mode 100644 examples/qml/cppextensions/referenceexamples/methods/methods.qrc create mode 100644 examples/qml/cppextensions/referenceexamples/methods/person.cpp create mode 100644 examples/qml/cppextensions/referenceexamples/methods/person.h create mode 100644 examples/qml/cppextensions/referenceexamples/properties/birthdayparty.cpp create mode 100644 examples/qml/cppextensions/referenceexamples/properties/birthdayparty.h create mode 100644 examples/qml/cppextensions/referenceexamples/properties/example.qml create mode 100644 examples/qml/cppextensions/referenceexamples/properties/main.cpp create mode 100644 examples/qml/cppextensions/referenceexamples/properties/person.cpp create mode 100644 examples/qml/cppextensions/referenceexamples/properties/person.h create mode 100644 examples/qml/cppextensions/referenceexamples/properties/properties.pro create mode 100644 examples/qml/cppextensions/referenceexamples/properties/properties.qrc create mode 100644 examples/qml/cppextensions/referenceexamples/referenceexamples.pro create mode 100644 examples/qml/cppextensions/referenceexamples/referenceexamples.qmlproject create mode 100644 examples/qml/cppextensions/referenceexamples/signal/birthdayparty.cpp create mode 100644 examples/qml/cppextensions/referenceexamples/signal/birthdayparty.h create mode 100644 examples/qml/cppextensions/referenceexamples/signal/example.qml create mode 100644 examples/qml/cppextensions/referenceexamples/signal/main.cpp create mode 100644 examples/qml/cppextensions/referenceexamples/signal/person.cpp create mode 100644 examples/qml/cppextensions/referenceexamples/signal/person.h create mode 100644 examples/qml/cppextensions/referenceexamples/signal/signal.pro create mode 100644 examples/qml/cppextensions/referenceexamples/signal/signal.qrc create mode 100644 examples/qml/cppextensions/referenceexamples/valuesource/birthdayparty.cpp create mode 100644 examples/qml/cppextensions/referenceexamples/valuesource/birthdayparty.h create mode 100644 examples/qml/cppextensions/referenceexamples/valuesource/example.qml create mode 100644 examples/qml/cppextensions/referenceexamples/valuesource/happybirthdaysong.cpp create mode 100644 examples/qml/cppextensions/referenceexamples/valuesource/happybirthdaysong.h create mode 100644 examples/qml/cppextensions/referenceexamples/valuesource/main.cpp create mode 100644 examples/qml/cppextensions/referenceexamples/valuesource/person.cpp create mode 100644 examples/qml/cppextensions/referenceexamples/valuesource/person.h create mode 100644 examples/qml/cppextensions/referenceexamples/valuesource/valuesource.pro create mode 100644 examples/qml/cppextensions/referenceexamples/valuesource/valuesource.qrc create mode 100644 examples/qml/draganddrop/dragtarget.qmlproject create mode 100644 examples/qml/draganddrop/tiles/DragTile.qml create mode 100644 examples/qml/draganddrop/tiles/DropTile.qml create mode 100644 examples/qml/draganddrop/tiles/tiles.qml create mode 100644 examples/qml/draganddrop/views/gridview.qml create mode 100644 examples/qml/flickr/content/Button.qml create mode 100644 examples/qml/flickr/content/GridDelegate.qml create mode 100644 examples/qml/flickr/content/ImageDetails.qml create mode 100644 examples/qml/flickr/content/ListDelegate.qml create mode 100644 examples/qml/flickr/content/Progress.qml create mode 100644 examples/qml/flickr/content/RssModel.qml create mode 100644 examples/qml/flickr/content/ScrollBar.qml create mode 100644 examples/qml/flickr/content/Slider.qml create mode 100644 examples/qml/flickr/content/TitleBar.qml create mode 100644 examples/qml/flickr/content/ToolBar.qml create mode 100644 examples/qml/flickr/content/UnifiedDelegate.qml create mode 100644 examples/qml/flickr/content/images/gloss.png create mode 100644 examples/qml/flickr/content/images/lineedit.png create mode 100644 examples/qml/flickr/content/images/lineedit.sci create mode 100644 examples/qml/flickr/content/images/noise.png create mode 100644 examples/qml/flickr/content/images/particle.png create mode 100644 examples/qml/flickr/content/images/quit.png create mode 100644 examples/qml/flickr/content/images/squareParticle.png create mode 100644 examples/qml/flickr/content/images/stripes.png create mode 100644 examples/qml/flickr/content/images/titlebar.png create mode 100644 examples/qml/flickr/content/images/titlebar.sci create mode 100644 examples/qml/flickr/content/images/toolbutton.png create mode 100644 examples/qml/flickr/content/images/toolbutton.sci create mode 100644 examples/qml/flickr/content/qmldir create mode 100644 examples/qml/flickr/flickr-90.qml create mode 100644 examples/qml/flickr/flickr.qml create mode 100644 examples/qml/flickr/flickr.qmlproject create mode 100644 examples/qml/i18n/i18n.qml create mode 100644 examples/qml/i18n/i18n/base.ts create mode 100644 examples/qml/i18n/i18n/qml_en_AU.ts create mode 100644 examples/qml/i18n/i18n/qml_fr.ts create mode 100644 examples/qml/imageelements/borderimage.qml create mode 100644 examples/qml/imageelements/content/BearSheet.png create mode 100644 examples/qml/imageelements/content/ImageCell.qml create mode 100644 examples/qml/imageelements/content/MyBorderImage.qml create mode 100644 examples/qml/imageelements/content/ShadowRectangle.qml create mode 100644 examples/qml/imageelements/content/bw.png create mode 100644 examples/qml/imageelements/content/colors-round.sci create mode 100644 examples/qml/imageelements/content/colors-stretch.sci create mode 100644 examples/qml/imageelements/content/colors.png create mode 100644 examples/qml/imageelements/content/qt-logo.png create mode 100644 examples/qml/imageelements/content/shadow.png create mode 100644 examples/qml/imageelements/content/speaker.png create mode 100644 examples/qml/imageelements/image.qml create mode 100644 examples/qml/imageelements/imageelements.qml create mode 100644 examples/qml/imageelements/imageelements.qmlproject create mode 100644 examples/qml/imageelements/shadows.qml create mode 100644 examples/qml/imageelements/simplesprite.qml create mode 100644 examples/qml/imageelements/spriteimage.qml create mode 100644 examples/qml/keyinteraction/focus/Core/ContextMenu.qml create mode 100644 examples/qml/keyinteraction/focus/Core/GridMenu.qml create mode 100644 examples/qml/keyinteraction/focus/Core/ListMenu.qml create mode 100644 examples/qml/keyinteraction/focus/Core/ListViewDelegate.qml create mode 100644 examples/qml/keyinteraction/focus/Core/images/arrow.png create mode 100644 examples/qml/keyinteraction/focus/Core/images/qt-logo.png create mode 100644 examples/qml/keyinteraction/focus/focus.qml create mode 100644 examples/qml/locale/locale.qml create mode 100644 examples/qml/minehunt/MinehuntCore/Explosion.qml create mode 100644 examples/qml/minehunt/MinehuntCore/Tile.qml create mode 100644 examples/qml/minehunt/MinehuntCore/pics/back.png create mode 100644 examples/qml/minehunt/MinehuntCore/pics/background.png create mode 100644 examples/qml/minehunt/MinehuntCore/pics/bomb-color.png create mode 100644 examples/qml/minehunt/MinehuntCore/pics/bomb.png create mode 100644 examples/qml/minehunt/MinehuntCore/pics/face-sad.png create mode 100644 examples/qml/minehunt/MinehuntCore/pics/face-smile-big.png create mode 100644 examples/qml/minehunt/MinehuntCore/pics/face-smile.png create mode 100644 examples/qml/minehunt/MinehuntCore/pics/flag-color.png create mode 100644 examples/qml/minehunt/MinehuntCore/pics/flag.png create mode 100644 examples/qml/minehunt/MinehuntCore/pics/front.png create mode 100644 examples/qml/minehunt/MinehuntCore/pics/quit.png create mode 100644 examples/qml/minehunt/MinehuntCore/pics/star.png create mode 100644 examples/qml/minehunt/MinehuntCore/qmldir create mode 100644 examples/qml/minehunt/README create mode 100644 examples/qml/minehunt/main.cpp create mode 100644 examples/qml/minehunt/minehunt.cpp create mode 100644 examples/qml/minehunt/minehunt.h create mode 100644 examples/qml/minehunt/minehunt.pro create mode 100644 examples/qml/minehunt/minehunt.qml create mode 100644 examples/qml/minehunt/minehunt.qmlproject create mode 100644 examples/qml/minehunt/minehunt.qrc create mode 100644 examples/qml/modelviews/abstractitemmodel/abstractitemmodel.pro create mode 100644 examples/qml/modelviews/abstractitemmodel/abstractitemmodel.qrc create mode 100644 examples/qml/modelviews/abstractitemmodel/main.cpp create mode 100644 examples/qml/modelviews/abstractitemmodel/model.cpp create mode 100644 examples/qml/modelviews/abstractitemmodel/model.h create mode 100644 examples/qml/modelviews/abstractitemmodel/view.qml create mode 100644 examples/qml/modelviews/gridview/gridview-example.qml create mode 100644 examples/qml/modelviews/gridview/pics/AddressBook_48.png create mode 100644 examples/qml/modelviews/gridview/pics/AudioPlayer_48.png create mode 100644 examples/qml/modelviews/gridview/pics/Camera_48.png create mode 100644 examples/qml/modelviews/gridview/pics/DateBook_48.png create mode 100644 examples/qml/modelviews/gridview/pics/EMail_48.png create mode 100644 examples/qml/modelviews/gridview/pics/TodoList_48.png create mode 100644 examples/qml/modelviews/gridview/pics/VideoPlayer_48.png create mode 100644 examples/qml/modelviews/listview/content/PetsModel.qml create mode 100644 examples/qml/modelviews/listview/content/PressAndHoldButton.qml create mode 100644 examples/qml/modelviews/listview/content/RecipesModel.qml create mode 100644 examples/qml/modelviews/listview/content/TextButton.qml create mode 100644 examples/qml/modelviews/listview/content/ToggleButton.qml create mode 100644 examples/qml/modelviews/listview/content/pics/arrow-down.png create mode 100644 examples/qml/modelviews/listview/content/pics/arrow-up.png create mode 100644 examples/qml/modelviews/listview/content/pics/fruit-salad.jpg create mode 100644 examples/qml/modelviews/listview/content/pics/hamburger.jpg create mode 100644 examples/qml/modelviews/listview/content/pics/lemonade.jpg create mode 100644 examples/qml/modelviews/listview/content/pics/list-delete.png create mode 100644 examples/qml/modelviews/listview/content/pics/minus-sign.png create mode 100644 examples/qml/modelviews/listview/content/pics/moreDown.png create mode 100644 examples/qml/modelviews/listview/content/pics/moreUp.png create mode 100644 examples/qml/modelviews/listview/content/pics/pancakes.jpg create mode 100644 examples/qml/modelviews/listview/content/pics/plus-sign.png create mode 100644 examples/qml/modelviews/listview/content/pics/vegetable-soup.jpg create mode 100644 examples/qml/modelviews/listview/dynamiclist.qml create mode 100644 examples/qml/modelviews/listview/expandingdelegates.qml create mode 100644 examples/qml/modelviews/listview/highlight.qml create mode 100644 examples/qml/modelviews/listview/highlightranges.qml create mode 100644 examples/qml/modelviews/listview/sections.qml create mode 100644 examples/qml/modelviews/modelviews.pro create mode 100644 examples/qml/modelviews/modelviews.qml create mode 100644 examples/qml/modelviews/modelviews.qmlproject create mode 100644 examples/qml/modelviews/objectlistmodel/dataobject.cpp create mode 100644 examples/qml/modelviews/objectlistmodel/dataobject.h create mode 100644 examples/qml/modelviews/objectlistmodel/main.cpp create mode 100644 examples/qml/modelviews/objectlistmodel/objectlistmodel.pro create mode 100644 examples/qml/modelviews/objectlistmodel/objectlistmodel.qmlproject create mode 100644 examples/qml/modelviews/objectlistmodel/objectlistmodel.qrc create mode 100644 examples/qml/modelviews/objectlistmodel/view.qml create mode 100644 examples/qml/modelviews/package/Delegate.qml create mode 100644 examples/qml/modelviews/package/view.qml create mode 100644 examples/qml/modelviews/parallax/content/ParallaxView.qml create mode 100644 examples/qml/modelviews/parallax/content/Smiley.qml create mode 100644 examples/qml/modelviews/parallax/content/pics/background.jpg create mode 100644 examples/qml/modelviews/parallax/content/pics/face-smile.png create mode 100644 examples/qml/modelviews/parallax/content/pics/home-page.png create mode 100644 examples/qml/modelviews/parallax/content/pics/home-page.svg create mode 100644 examples/qml/modelviews/parallax/content/pics/shadow.png create mode 100644 examples/qml/modelviews/parallax/content/pics/yast-joystick.png create mode 100644 examples/qml/modelviews/parallax/content/pics/yast-wol.png create mode 100644 examples/qml/modelviews/parallax/parallax.qml create mode 100644 examples/qml/modelviews/pathview/pathview-example.qml create mode 100644 examples/qml/modelviews/pathview/pics/AddressBook_48.png create mode 100644 examples/qml/modelviews/pathview/pics/AudioPlayer_48.png create mode 100644 examples/qml/modelviews/pathview/pics/Camera_48.png create mode 100644 examples/qml/modelviews/pathview/pics/DateBook_48.png create mode 100644 examples/qml/modelviews/pathview/pics/EMail_48.png create mode 100644 examples/qml/modelviews/pathview/pics/TodoList_48.png create mode 100644 examples/qml/modelviews/pathview/pics/VideoPlayer_48.png create mode 100644 examples/qml/modelviews/stringlistmodel/main.cpp create mode 100644 examples/qml/modelviews/stringlistmodel/stringlistmodel.pro create mode 100644 examples/qml/modelviews/stringlistmodel/stringlistmodel.qrc create mode 100644 examples/qml/modelviews/stringlistmodel/view.qml create mode 100644 examples/qml/modelviews/visualdatamodel/dragselection.qml create mode 100644 examples/qml/modelviews/visualdatamodel/slideshow.qml create mode 100644 examples/qml/modelviews/visualdatamodel/sortedmodel.qml create mode 100644 examples/qml/modelviews/visualdatamodel/visualdatamodel.qmlproject create mode 100644 examples/qml/modelviews/visualitemmodel/visualitemmodel.qml create mode 100644 examples/qml/openglunderqml/main.cpp create mode 100644 examples/qml/openglunderqml/main.qml create mode 100644 examples/qml/openglunderqml/openglunderqml.pro create mode 100644 examples/qml/openglunderqml/squircle.cpp create mode 100644 examples/qml/openglunderqml/squircle.h create mode 100644 examples/qml/painteditem/painteditem.pro create mode 100644 examples/qml/painteditem/smile/main.cpp create mode 100644 examples/qml/painteditem/smile/smile.pro create mode 100644 examples/qml/painteditem/smile/smile.qml create mode 100644 examples/qml/painteditem/textballoons/TextBalloonPlugin/plugin.h create mode 100644 examples/qml/painteditem/textballoons/TextBalloonPlugin/qmldir create mode 100644 examples/qml/painteditem/textballoons/textballoon.cpp create mode 100644 examples/qml/painteditem/textballoons/textballoon.h create mode 100644 examples/qml/painteditem/textballoons/textballoons.pro create mode 100644 examples/qml/painteditem/textballoons/textballoons.qml create mode 100644 examples/qml/particles/affectors/age.qml create mode 100644 examples/qml/particles/affectors/attractor.qml create mode 100644 examples/qml/particles/affectors/customaffector.qml create mode 100644 examples/qml/particles/affectors/friction.qml create mode 100644 examples/qml/particles/affectors/gravity.qml create mode 100644 examples/qml/particles/affectors/groupgoal.qml create mode 100644 examples/qml/particles/affectors/move.qml create mode 100644 examples/qml/particles/affectors/spritegoal.qml create mode 100644 examples/qml/particles/affectors/turbulence.qml create mode 100644 examples/qml/particles/affectors/wander.qml create mode 100644 examples/qml/particles/customparticle/blurparticles.qml create mode 100644 examples/qml/particles/customparticle/fragmentshader.qml create mode 100644 examples/qml/particles/customparticle/imagecolors.qml create mode 100644 examples/qml/particles/emitters/burstandpulse.qml create mode 100644 examples/qml/particles/emitters/customemitter.qml create mode 100644 examples/qml/particles/emitters/emitmask.qml create mode 100644 examples/qml/particles/emitters/maximumemitted.qml create mode 100644 examples/qml/particles/emitters/shapeanddirection.qml create mode 100644 examples/qml/particles/emitters/timedgroupchanges.qml create mode 100644 examples/qml/particles/emitters/trailemitter.qml create mode 100644 examples/qml/particles/emitters/velocityfrommotion.qml create mode 100644 examples/qml/particles/exampleslauncher/content/Button.qml create mode 100644 examples/qml/particles/exampleslauncher/content/Shell.qml create mode 100644 examples/qml/particles/exampleslauncher/content/launcher.js create mode 100644 examples/qml/particles/exampleslauncher/exampleslauncher.qml create mode 100644 examples/qml/particles/imageparticle/allatonce.qml create mode 100644 examples/qml/particles/imageparticle/colored.qml create mode 100644 examples/qml/particles/imageparticle/colortable.qml create mode 100644 examples/qml/particles/imageparticle/deformation.qml create mode 100644 examples/qml/particles/imageparticle/rotation.qml create mode 100644 examples/qml/particles/imageparticle/sharing.qml create mode 100644 examples/qml/particles/imageparticle/sprites.qml create mode 100644 examples/qml/particles/images/_explo.png create mode 100755 examples/qml/particles/images/backgroundLeaves.jpg create mode 100644 examples/qml/particles/images/bear_tiles.png create mode 100644 examples/qml/particles/images/candle.png create mode 100644 examples/qml/particles/images/colortable.png create mode 100644 examples/qml/particles/images/finalfrontier.png create mode 100644 examples/qml/particles/images/flower.png create mode 100644 examples/qml/particles/images/launcherIcons/allatonce.png create mode 100644 examples/qml/particles/images/launcherIcons/attractor.png create mode 100644 examples/qml/particles/images/launcherIcons/blurparticles.png create mode 100644 examples/qml/particles/images/launcherIcons/close.png create mode 100644 examples/qml/particles/images/launcherIcons/colortable.png create mode 100644 examples/qml/particles/images/launcherIcons/customaffector.png create mode 100644 examples/qml/particles/images/launcherIcons/customemitter.png create mode 100644 examples/qml/particles/images/launcherIcons/deformation.png create mode 100644 examples/qml/particles/images/launcherIcons/delegates.png create mode 100644 examples/qml/particles/images/launcherIcons/dynamicemitters.png create mode 100644 examples/qml/particles/images/launcherIcons/emitmask.png create mode 100644 examples/qml/particles/images/launcherIcons/flickr.png create mode 100644 examples/qml/particles/images/launcherIcons/fragmentshader.png create mode 100644 examples/qml/particles/images/launcherIcons/gridsplosion.png create mode 100644 examples/qml/particles/images/launcherIcons/groupgoal.png create mode 100644 examples/qml/particles/images/launcherIcons/imagecolors.png create mode 100644 examples/qml/particles/images/launcherIcons/list.png create mode 100644 examples/qml/particles/images/launcherIcons/maximumemitted.png create mode 100644 examples/qml/particles/images/launcherIcons/multiplepainters.png create mode 100644 examples/qml/particles/images/launcherIcons/package.png create mode 100644 examples/qml/particles/images/launcherIcons/particleview.png create mode 100644 examples/qml/particles/images/launcherIcons/plasmapatrol.png create mode 100644 examples/qml/particles/images/launcherIcons/remove.png create mode 100644 examples/qml/particles/images/launcherIcons/rotation.png create mode 100644 examples/qml/particles/images/launcherIcons/samegame.png create mode 100644 examples/qml/particles/images/launcherIcons/shapeanddirection.png create mode 100644 examples/qml/particles/images/launcherIcons/spaceexplorer.png create mode 100644 examples/qml/particles/images/launcherIcons/spritegoal.png create mode 100644 examples/qml/particles/images/launcherIcons/sprites.png create mode 100644 examples/qml/particles/images/launcherIcons/spritevariedparticles.png create mode 100644 examples/qml/particles/images/launcherIcons/startstop.png create mode 100644 examples/qml/particles/images/launcherIcons/timedgroupchanges.png create mode 100644 examples/qml/particles/images/launcherIcons/trailemitter.png create mode 100644 examples/qml/particles/images/launcherIcons/trails.png create mode 100644 examples/qml/particles/images/launcherIcons/turbulence.png create mode 100644 examples/qml/particles/images/launcherIcons/velocityfrommotion.png create mode 100644 examples/qml/particles/images/launcherIcons/wander.png create mode 100644 examples/qml/particles/images/matchmask.png create mode 100644 examples/qml/particles/images/meteor.png create mode 100644 examples/qml/particles/images/meteor_explo.png create mode 100644 examples/qml/particles/images/meteors.png create mode 100644 examples/qml/particles/images/nullRock.png create mode 100644 examples/qml/particles/images/particle.png create mode 100644 examples/qml/particles/images/particle2.png create mode 100644 examples/qml/particles/images/particle3.png create mode 100644 examples/qml/particles/images/particle4.png create mode 100644 examples/qml/particles/images/particleA.png create mode 100644 examples/qml/particles/images/portal_bg.png create mode 100644 examples/qml/particles/images/realLeaf1.png create mode 100644 examples/qml/particles/images/realLeaf2.png create mode 100644 examples/qml/particles/images/realLeaf3.png create mode 100644 examples/qml/particles/images/realLeaf4.png create mode 100644 examples/qml/particles/images/rocket.png create mode 100644 examples/qml/particles/images/rocket2.png create mode 100644 examples/qml/particles/images/sizeInOut.png create mode 100644 examples/qml/particles/images/snowflake.png create mode 100644 examples/qml/particles/images/sparkleSize.png create mode 100644 examples/qml/particles/images/star.png create mode 100644 examples/qml/particles/images/starfish_0.png create mode 100644 examples/qml/particles/images/starfish_1.png create mode 100644 examples/qml/particles/images/starfish_2.png create mode 100644 examples/qml/particles/images/starfish_3.png create mode 100644 examples/qml/particles/images/starfish_4.png create mode 100644 examples/qml/particles/images/starfish_mask.png create mode 100644 examples/qml/particles/itemparticle/content/Delegate.qml create mode 100644 examples/qml/particles/itemparticle/content/Delegate2.qml create mode 100644 examples/qml/particles/itemparticle/content/ExpandingDelegate.qml create mode 100644 examples/qml/particles/itemparticle/content/RssModel.qml create mode 100644 examples/qml/particles/itemparticle/content/bubble.png create mode 100644 examples/qml/particles/itemparticle/content/script.js create mode 100644 examples/qml/particles/itemparticle/delegates.qml create mode 100644 examples/qml/particles/itemparticle/particleview.qml create mode 100644 examples/qml/particles/plasmapatrol/PlasmaPatrol.qmlproject create mode 100644 examples/qml/particles/plasmapatrol/TODO create mode 100644 examples/qml/particles/plasmapatrol/content/BlasterHardpoint.qml create mode 100644 examples/qml/particles/plasmapatrol/content/Button.qml create mode 100644 examples/qml/particles/plasmapatrol/content/CannonHardpoint.qml create mode 100644 examples/qml/particles/plasmapatrol/content/ChoiceBox.qml create mode 100644 examples/qml/particles/plasmapatrol/content/Cruiser.qml create mode 100644 examples/qml/particles/plasmapatrol/content/Frigate.qml create mode 100644 examples/qml/particles/plasmapatrol/content/Hardpoint.qml create mode 100644 examples/qml/particles/plasmapatrol/content/HelpScreens.qml create mode 100644 examples/qml/particles/plasmapatrol/content/LaserHardpoint.qml create mode 100644 examples/qml/particles/plasmapatrol/content/PlasmaPatrolParticles.qml create mode 100644 examples/qml/particles/plasmapatrol/content/SequentialLoader.qml create mode 100644 examples/qml/particles/plasmapatrol/content/Ship.qml create mode 100644 examples/qml/particles/plasmapatrol/content/Sloop.qml create mode 100644 examples/qml/particles/plasmapatrol/content/pics/TitleText.png create mode 100644 examples/qml/particles/plasmapatrol/content/pics/blur-circle2.png create mode 100644 examples/qml/particles/plasmapatrol/content/pics/blur-circle3.png create mode 100644 examples/qml/particles/plasmapatrol/content/pics/finalfrontier.png create mode 100644 examples/qml/particles/plasmapatrol/content/pics/meteor.png create mode 100644 examples/qml/particles/plasmapatrol/content/pics/meteor_explo.png create mode 100644 examples/qml/particles/plasmapatrol/content/pics/nullRock.png create mode 100644 examples/qml/particles/plasmapatrol/content/pics/particle.png create mode 100644 examples/qml/particles/plasmapatrol/content/pics/star.png create mode 100644 examples/qml/particles/plasmapatrol/content/pics/star2.png create mode 100644 examples/qml/particles/plasmapatrol/content/pics/star3.png create mode 100644 examples/qml/particles/plasmapatrol/plasmapatrol.qml create mode 100644 examples/qml/particles/simple/dynamiccomparison.qml create mode 100644 examples/qml/particles/simple/dynamicemitters.qml create mode 100644 examples/qml/particles/simple/multiplepainters.qml create mode 100644 examples/qml/particles/simple/startstop.qml create mode 100644 examples/qml/photoviewer/PhotoViewerCore/AlbumDelegate.qml create mode 100644 examples/qml/photoviewer/PhotoViewerCore/BusyIndicator.qml create mode 100644 examples/qml/photoviewer/PhotoViewerCore/Button.qml create mode 100644 examples/qml/photoviewer/PhotoViewerCore/EditableButton.qml create mode 100644 examples/qml/photoviewer/PhotoViewerCore/PhotoDelegate.qml create mode 100644 examples/qml/photoviewer/PhotoViewerCore/ProgressBar.qml create mode 100644 examples/qml/photoviewer/PhotoViewerCore/RssModel.qml create mode 100644 examples/qml/photoviewer/PhotoViewerCore/Tag.qml create mode 100644 examples/qml/photoviewer/PhotoViewerCore/images/box-shadow.png create mode 100644 examples/qml/photoviewer/PhotoViewerCore/images/busy.png create mode 100644 examples/qml/photoviewer/PhotoViewerCore/images/cardboard.png create mode 100644 examples/qml/photoviewer/PhotoViewerCore/qmldir create mode 100644 examples/qml/photoviewer/PhotoViewerCore/script/script.js create mode 100644 examples/qml/photoviewer/i18n/base.ts create mode 100644 examples/qml/photoviewer/i18n/qml_fr.qm create mode 100644 examples/qml/photoviewer/i18n/qml_fr.ts create mode 100644 examples/qml/photoviewer/photoviewer.qml create mode 100644 examples/qml/photoviewer/photoviewer.qmlproject create mode 100644 examples/qml/positioners/content/Button.qml create mode 100644 examples/qml/positioners/content/add.png create mode 100644 examples/qml/positioners/content/del.png create mode 100644 examples/qml/positioners/positioners-attachedproperties.qml create mode 100644 examples/qml/positioners/positioners.qml create mode 100644 examples/qml/qml.pro create mode 100644 examples/qml/righttoleft/layoutdirection/layoutdirection.qml create mode 100644 examples/qml/righttoleft/layoutdirection/layoutdirection.qmlproject create mode 100644 examples/qml/righttoleft/layoutmirroring/layoutmirroring.qml create mode 100644 examples/qml/righttoleft/layoutmirroring/layoutmirroring.qmlproject create mode 100644 examples/qml/righttoleft/textalignment/textalignment.qml create mode 100644 examples/qml/righttoleft/textalignment/textalignment.qmlproject create mode 100644 examples/qml/rssnews/content/BusyIndicator.qml create mode 100644 examples/qml/rssnews/content/CategoryDelegate.qml create mode 100644 examples/qml/rssnews/content/NewsDelegate.qml create mode 100644 examples/qml/rssnews/content/RssFeeds.qml create mode 100644 examples/qml/rssnews/content/ScrollBar.qml create mode 100644 examples/qml/rssnews/content/images/busy.png create mode 100644 examples/qml/rssnews/content/images/scrollbar.png create mode 100644 examples/qml/rssnews/rssnews.qml create mode 100644 examples/qml/rssnews/rssnews.qmlproject create mode 100644 examples/qml/samegame/content/BoomBlock.qml create mode 100644 examples/qml/samegame/content/Button.qml create mode 100644 examples/qml/samegame/content/Dialog.qml create mode 100644 examples/qml/samegame/content/GameArea.qml create mode 100644 examples/qml/samegame/content/NameInputDialog.qml create mode 100644 examples/qml/samegame/content/pics/background.png create mode 100644 examples/qml/samegame/content/pics/blueStone.png create mode 100644 examples/qml/samegame/content/pics/greenStone.png create mode 100644 examples/qml/samegame/content/pics/particle.png create mode 100644 examples/qml/samegame/content/pics/redStone.png create mode 100644 examples/qml/samegame/content/pics/yellowStone.png create mode 100755 examples/qml/samegame/content/samegame.js create mode 100644 examples/qml/samegame/samegame.qml create mode 100644 examples/qml/samegame/samegame.qmlproject create mode 100644 examples/qml/script/script.pro create mode 100644 examples/qml/script/shell/main.cpp create mode 100644 examples/qml/script/shell/shell.pro create mode 100644 examples/qml/shadereffects/content/Slider.qml create mode 100644 examples/qml/shadereffects/content/face-smile.png create mode 100644 examples/qml/shadereffects/content/qt-logo.png create mode 100644 examples/qml/shadereffects/shadereffects.qml create mode 100644 examples/qml/shared/Button.qml create mode 100644 examples/qml/shared/LauncherList.qml create mode 100644 examples/qml/shared/README create mode 100644 examples/qml/shared/SimpleLauncherDelegate.qml create mode 100644 examples/qml/shared/back.png create mode 100644 examples/qml/snake/content/Button.qml create mode 100644 examples/qml/snake/content/Cookie.qml create mode 100644 examples/qml/snake/content/HighScoreModel.qml create mode 100644 examples/qml/snake/content/Link.qml create mode 100644 examples/qml/snake/content/Skull.qml create mode 100644 examples/qml/snake/content/pics/README create mode 100644 examples/qml/snake/content/pics/background.png create mode 100644 examples/qml/snake/content/pics/blueStar.png create mode 100644 examples/qml/snake/content/pics/blueStone.png create mode 100644 examples/qml/snake/content/pics/cookie.png create mode 100644 examples/qml/snake/content/pics/eyes.svg create mode 100644 examples/qml/snake/content/pics/head.png create mode 100644 examples/qml/snake/content/pics/pause.png create mode 100644 examples/qml/snake/content/pics/redStar.png create mode 100644 examples/qml/snake/content/pics/redStone.png create mode 100644 examples/qml/snake/content/pics/skull.png create mode 100644 examples/qml/snake/content/pics/snake.jpg create mode 100644 examples/qml/snake/content/pics/star.png create mode 100644 examples/qml/snake/content/pics/stoneShadow.png create mode 100644 examples/qml/snake/content/pics/yellowStar.png create mode 100644 examples/qml/snake/content/pics/yellowStone.png create mode 100644 examples/qml/snake/content/snake.js create mode 100644 examples/qml/snake/snake.qml create mode 100644 examples/qml/snake/snake.qmlproject create mode 100644 examples/qml/sqllocalstorage/hello.qml create mode 100644 examples/qml/text/fonts/availableFonts.qml create mode 100644 examples/qml/text/fonts/banner.qml create mode 100644 examples/qml/text/fonts/content/fonts/tarzeau_ocr_a.ttf create mode 100644 examples/qml/text/fonts/fonts.qml create mode 100644 examples/qml/text/fonts/hello.qml create mode 100644 examples/qml/text/imgtag/TextWithImage.qml create mode 100644 examples/qml/text/imgtag/images/face-sad.png create mode 100644 examples/qml/text/imgtag/images/face-smile-big.png create mode 100644 examples/qml/text/imgtag/images/face-smile.png create mode 100644 examples/qml/text/imgtag/images/heart200.png create mode 100644 examples/qml/text/imgtag/images/qtlogo.png create mode 100644 examples/qml/text/imgtag/images/starfish_2.png create mode 100644 examples/qml/text/imgtag/imgtag.qml create mode 100644 examples/qml/text/styledtext-layout.qml create mode 100644 examples/qml/text/text.qml create mode 100644 examples/qml/text/text.qmlproject create mode 100644 examples/qml/text/textselection/pics/endHandle.png create mode 100644 examples/qml/text/textselection/pics/endHandle.sci create mode 100644 examples/qml/text/textselection/pics/startHandle.png create mode 100644 examples/qml/text/textselection/pics/startHandle.sci create mode 100644 examples/qml/text/textselection/textselection.qml create mode 100644 examples/qml/threading/threadedlistmodel/dataloader.js create mode 100644 examples/qml/threading/threadedlistmodel/threadedlistmodel.qmlproject create mode 100644 examples/qml/threading/threadedlistmodel/timedisplay.qml create mode 100644 examples/qml/threading/workerscript/workerscript.js create mode 100644 examples/qml/threading/workerscript/workerscript.qml create mode 100644 examples/qml/threading/workerscript/workerscript.qmlproject create mode 100644 examples/qml/touchinteraction/mousearea/mousearea-example.qml create mode 100644 examples/qml/touchinteraction/multipointtouch/bearwhack.qml create mode 100644 examples/qml/touchinteraction/multipointtouch/content/AugmentedTouchPoint.qml create mode 100644 examples/qml/touchinteraction/multipointtouch/content/Bear0.png create mode 100644 examples/qml/touchinteraction/multipointtouch/content/Bear1.png create mode 100644 examples/qml/touchinteraction/multipointtouch/content/Bear2.png create mode 100644 examples/qml/touchinteraction/multipointtouch/content/Bear3.png create mode 100644 examples/qml/touchinteraction/multipointtouch/content/BearB.png create mode 100644 examples/qml/touchinteraction/multipointtouch/content/BearWhackParticleSystem.qml create mode 100644 examples/qml/touchinteraction/multipointtouch/content/ParticleFlame.qml create mode 100644 examples/qml/touchinteraction/multipointtouch/content/blur-circle.png create mode 100644 examples/qml/touchinteraction/multipointtouch/content/blur-circle3.png create mode 100644 examples/qml/touchinteraction/multipointtouch/content/heart-blur.png create mode 100644 examples/qml/touchinteraction/multipointtouch/content/title.png create mode 100644 examples/qml/touchinteraction/multipointtouch/multiflame.qml create mode 100644 examples/qml/touchinteraction/pincharea/flickresize.qml create mode 100644 examples/qml/touchinteraction/pincharea/qt-logo.jpg create mode 100644 examples/qml/touchinteraction/touchinteraction.qml create mode 100644 examples/qml/touchinteraction/touchinteraction.qmlproject create mode 100644 examples/qml/toys/clocks/clocks.qml create mode 100644 examples/qml/toys/clocks/content/Clock.qml create mode 100644 examples/qml/toys/clocks/content/QuitButton.qml create mode 100644 examples/qml/toys/clocks/content/arrow.png create mode 100644 examples/qml/toys/clocks/content/background.png create mode 100644 examples/qml/toys/clocks/content/center.png create mode 100644 examples/qml/toys/clocks/content/clock-night.png create mode 100644 examples/qml/toys/clocks/content/clock.png create mode 100644 examples/qml/toys/clocks/content/hour.png create mode 100644 examples/qml/toys/clocks/content/minute.png create mode 100644 examples/qml/toys/clocks/content/quit.png create mode 100644 examples/qml/toys/clocks/content/second.png create mode 100644 examples/qml/toys/corkboards/content/Day.qml create mode 100644 examples/qml/toys/corkboards/content/cork.jpg create mode 100644 examples/qml/toys/corkboards/content/note-yellow.png create mode 100644 examples/qml/toys/corkboards/content/tack.png create mode 100644 examples/qml/toys/corkboards/corkboards.qml create mode 100644 examples/qml/toys/dynamicscene/content/Button.qml create mode 100644 examples/qml/toys/dynamicscene/content/GenericSceneItem.qml create mode 100644 examples/qml/toys/dynamicscene/content/PaletteItem.qml create mode 100644 examples/qml/toys/dynamicscene/content/PerspectiveItem.qml create mode 100644 examples/qml/toys/dynamicscene/content/Sun.qml create mode 100644 examples/qml/toys/dynamicscene/content/images/NOTE create mode 100644 examples/qml/toys/dynamicscene/content/images/face-smile.png create mode 100644 examples/qml/toys/dynamicscene/content/images/moon.png create mode 100644 examples/qml/toys/dynamicscene/content/images/rabbit_brown.png create mode 100644 examples/qml/toys/dynamicscene/content/images/rabbit_bw.png create mode 100644 examples/qml/toys/dynamicscene/content/images/star.png create mode 100644 examples/qml/toys/dynamicscene/content/images/sun.png create mode 100644 examples/qml/toys/dynamicscene/content/images/tree_s.png create mode 100644 examples/qml/toys/dynamicscene/content/itemCreation.js create mode 100644 examples/qml/toys/dynamicscene/dynamicscene.qml create mode 100644 examples/qml/toys/tic-tac-toe/content/Button.qml create mode 100644 examples/qml/toys/tic-tac-toe/content/TicTac.qml create mode 100644 examples/qml/toys/tic-tac-toe/content/pics/board.png create mode 100644 examples/qml/toys/tic-tac-toe/content/pics/o.png create mode 100644 examples/qml/toys/tic-tac-toe/content/pics/x.png create mode 100644 examples/qml/toys/tic-tac-toe/content/tic-tac-toe.js create mode 100644 examples/qml/toys/tic-tac-toe/tic-tac-toe.qml create mode 100644 examples/qml/toys/tvtennis/tvtennis.qml create mode 100644 examples/qml/tutorials/dynamicview/dynamicview1/PetsModel.qml create mode 100644 examples/qml/tutorials/dynamicview/dynamicview1/dynamicview.qml create mode 100644 examples/qml/tutorials/dynamicview/dynamicview2/PetsModel.qml create mode 100644 examples/qml/tutorials/dynamicview/dynamicview2/dynamicview.qml create mode 100644 examples/qml/tutorials/dynamicview/dynamicview3/PetsModel.qml create mode 100644 examples/qml/tutorials/dynamicview/dynamicview3/dynamicview.qml create mode 100644 examples/qml/tutorials/dynamicview/dynamicview4/ListSelector.qml create mode 100644 examples/qml/tutorials/dynamicview/dynamicview4/PetsModel.qml create mode 100644 examples/qml/tutorials/dynamicview/dynamicview4/dynamicview.qml create mode 100644 examples/qml/tutorials/extending/chapter1-basics/app.qml create mode 100644 examples/qml/tutorials/extending/chapter1-basics/chapter1-basics.pro create mode 100644 examples/qml/tutorials/extending/chapter1-basics/main.cpp create mode 100644 examples/qml/tutorials/extending/chapter1-basics/piechart.cpp create mode 100644 examples/qml/tutorials/extending/chapter1-basics/piechart.h create mode 100644 examples/qml/tutorials/extending/chapter2-methods/app.qml create mode 100644 examples/qml/tutorials/extending/chapter2-methods/chapter2-methods.pro create mode 100644 examples/qml/tutorials/extending/chapter2-methods/main.cpp create mode 100644 examples/qml/tutorials/extending/chapter2-methods/piechart.cpp create mode 100644 examples/qml/tutorials/extending/chapter2-methods/piechart.h create mode 100644 examples/qml/tutorials/extending/chapter3-bindings/app.qml create mode 100644 examples/qml/tutorials/extending/chapter3-bindings/chapter3-bindings.pro create mode 100644 examples/qml/tutorials/extending/chapter3-bindings/main.cpp create mode 100644 examples/qml/tutorials/extending/chapter3-bindings/piechart.cpp create mode 100644 examples/qml/tutorials/extending/chapter3-bindings/piechart.h create mode 100644 examples/qml/tutorials/extending/chapter4-customPropertyTypes/app.qml create mode 100644 examples/qml/tutorials/extending/chapter4-customPropertyTypes/chapter4-customPropertyTypes.pro create mode 100644 examples/qml/tutorials/extending/chapter4-customPropertyTypes/main.cpp create mode 100644 examples/qml/tutorials/extending/chapter4-customPropertyTypes/piechart.cpp create mode 100644 examples/qml/tutorials/extending/chapter4-customPropertyTypes/piechart.h create mode 100644 examples/qml/tutorials/extending/chapter4-customPropertyTypes/pieslice.cpp create mode 100644 examples/qml/tutorials/extending/chapter4-customPropertyTypes/pieslice.h create mode 100644 examples/qml/tutorials/extending/chapter5-listproperties/app.qml create mode 100644 examples/qml/tutorials/extending/chapter5-listproperties/chapter5-listproperties.pro create mode 100644 examples/qml/tutorials/extending/chapter5-listproperties/main.cpp create mode 100644 examples/qml/tutorials/extending/chapter5-listproperties/piechart.cpp create mode 100644 examples/qml/tutorials/extending/chapter5-listproperties/piechart.h create mode 100644 examples/qml/tutorials/extending/chapter5-listproperties/pieslice.cpp create mode 100644 examples/qml/tutorials/extending/chapter5-listproperties/pieslice.h create mode 100644 examples/qml/tutorials/extending/chapter6-plugins/ChartsPlugin/qmldir create mode 100644 examples/qml/tutorials/extending/chapter6-plugins/app.qml create mode 100644 examples/qml/tutorials/extending/chapter6-plugins/chapter6-plugins.pro create mode 100644 examples/qml/tutorials/extending/chapter6-plugins/chartsplugin.cpp create mode 100644 examples/qml/tutorials/extending/chapter6-plugins/chartsplugin.h create mode 100644 examples/qml/tutorials/extending/chapter6-plugins/piechart.cpp create mode 100644 examples/qml/tutorials/extending/chapter6-plugins/piechart.h create mode 100644 examples/qml/tutorials/extending/chapter6-plugins/pieslice.cpp create mode 100644 examples/qml/tutorials/extending/chapter6-plugins/pieslice.h create mode 100644 examples/qml/tutorials/extending/extending.pro create mode 100644 examples/qml/tutorials/helloworld/Cell.qml create mode 100644 examples/qml/tutorials/helloworld/tutorial1.qml create mode 100644 examples/qml/tutorials/helloworld/tutorial2.qml create mode 100644 examples/qml/tutorials/helloworld/tutorial3.qml create mode 100644 examples/qml/tutorials/samegame/samegame1/Block.qml create mode 100644 examples/qml/tutorials/samegame/samegame1/Button.qml create mode 100644 examples/qml/tutorials/samegame/samegame1/samegame.qml create mode 100644 examples/qml/tutorials/samegame/samegame1/samegame1.qmlproject create mode 100644 examples/qml/tutorials/samegame/samegame2/Block.qml create mode 100644 examples/qml/tutorials/samegame/samegame2/Button.qml create mode 100644 examples/qml/tutorials/samegame/samegame2/samegame.js create mode 100644 examples/qml/tutorials/samegame/samegame2/samegame.qml create mode 100644 examples/qml/tutorials/samegame/samegame2/samegame2.qmlproject create mode 100644 examples/qml/tutorials/samegame/samegame3/Block.qml create mode 100644 examples/qml/tutorials/samegame/samegame3/Button.qml create mode 100644 examples/qml/tutorials/samegame/samegame3/Dialog.qml create mode 100644 examples/qml/tutorials/samegame/samegame3/samegame.js create mode 100644 examples/qml/tutorials/samegame/samegame3/samegame.qml create mode 100644 examples/qml/tutorials/samegame/samegame3/samegame3.qmlproject create mode 100644 examples/qml/tutorials/samegame/samegame4/content/BoomBlock.qml create mode 100644 examples/qml/tutorials/samegame/samegame4/content/Button.qml create mode 100644 examples/qml/tutorials/samegame/samegame4/content/Dialog.qml create mode 100755 examples/qml/tutorials/samegame/samegame4/content/samegame.js create mode 100644 examples/qml/tutorials/samegame/samegame4/highscores/README create mode 100755 examples/qml/tutorials/samegame/samegame4/highscores/score_data.xml create mode 100755 examples/qml/tutorials/samegame/samegame4/highscores/score_style.xsl create mode 100755 examples/qml/tutorials/samegame/samegame4/highscores/scores.php create mode 100644 examples/qml/tutorials/samegame/samegame4/samegame.qml create mode 100644 examples/qml/tutorials/samegame/samegame4/samegame4.qmlproject create mode 100644 examples/qml/tutorials/samegame/shared/pics/background.jpg create mode 100644 examples/qml/tutorials/samegame/shared/pics/blueStar.png create mode 100644 examples/qml/tutorials/samegame/shared/pics/blueStone.png create mode 100644 examples/qml/tutorials/samegame/shared/pics/greenStar.png create mode 100644 examples/qml/tutorials/samegame/shared/pics/greenStone.png create mode 100644 examples/qml/tutorials/samegame/shared/pics/redStar.png create mode 100644 examples/qml/tutorials/samegame/shared/pics/redStone.png create mode 100644 examples/qml/tutorials/samegame/shared/pics/star.png create mode 100644 examples/qml/tutorials/samegame/shared/pics/yellowStone.png create mode 100644 examples/qml/tutorials/tutorials.pro create mode 100644 examples/qml/tutorials/tutorials.qmlproject create mode 100644 examples/qml/twitter/TwitterCore/Button.qml create mode 100644 examples/qml/twitter/TwitterCore/FatDelegate.qml create mode 100644 examples/qml/twitter/TwitterCore/Input.qml create mode 100644 examples/qml/twitter/TwitterCore/Loading.qml create mode 100644 examples/qml/twitter/TwitterCore/MultiTitleBar.qml create mode 100644 examples/qml/twitter/TwitterCore/RssModel.qml create mode 100644 examples/qml/twitter/TwitterCore/SearchView.qml create mode 100644 examples/qml/twitter/TwitterCore/TitleBar.qml create mode 100644 examples/qml/twitter/TwitterCore/ToolBar.qml create mode 100644 examples/qml/twitter/TwitterCore/UserModel.qml create mode 100644 examples/qml/twitter/TwitterCore/images/gloss.png create mode 100644 examples/qml/twitter/TwitterCore/images/lineedit.png create mode 100644 examples/qml/twitter/TwitterCore/images/lineedit.sci create mode 100644 examples/qml/twitter/TwitterCore/images/loading.png create mode 100644 examples/qml/twitter/TwitterCore/images/quit.png create mode 100644 examples/qml/twitter/TwitterCore/images/stripes.png create mode 100644 examples/qml/twitter/TwitterCore/images/titlebar.png create mode 100644 examples/qml/twitter/TwitterCore/images/titlebar.sci create mode 100644 examples/qml/twitter/TwitterCore/images/toolbutton.png create mode 100644 examples/qml/twitter/TwitterCore/images/toolbutton.sci create mode 100644 examples/qml/twitter/TwitterCore/qmldir create mode 100644 examples/qml/twitter/twitter.qml create mode 100644 examples/qml/twitter/twitter.qmlproject create mode 100644 examples/qml/ui-components/dialcontrol/content/Dial.qml create mode 100644 examples/qml/ui-components/dialcontrol/content/QuitButton.qml create mode 100644 examples/qml/ui-components/dialcontrol/content/background.png create mode 100644 examples/qml/ui-components/dialcontrol/content/needle.png create mode 100644 examples/qml/ui-components/dialcontrol/content/needle_shadow.png create mode 100644 examples/qml/ui-components/dialcontrol/content/overlay.png create mode 100644 examples/qml/ui-components/dialcontrol/content/quit.png create mode 100644 examples/qml/ui-components/dialcontrol/dialcontrol.qml create mode 100644 examples/qml/ui-components/flipable/content/5_heart.png create mode 100644 examples/qml/ui-components/flipable/content/9_club.png create mode 100644 examples/qml/ui-components/flipable/content/Card.qml create mode 100644 examples/qml/ui-components/flipable/content/back.png create mode 100644 examples/qml/ui-components/flipable/flipable.qml create mode 100644 examples/qml/ui-components/progressbar/content/ProgressBar.qml create mode 100644 examples/qml/ui-components/progressbar/content/background.png create mode 100644 examples/qml/ui-components/progressbar/main.qml create mode 100644 examples/qml/ui-components/scrollbar/ScrollBar.qml create mode 100644 examples/qml/ui-components/scrollbar/main.qml create mode 100644 examples/qml/ui-components/scrollbar/pics/niagara_falls.jpg create mode 100644 examples/qml/ui-components/scrollbar/scrollbar.qmlproject create mode 100644 examples/qml/ui-components/searchbox/SearchBox.qml create mode 100644 examples/qml/ui-components/searchbox/images/clear.png create mode 100644 examples/qml/ui-components/searchbox/images/lineedit-bg-focus.png create mode 100644 examples/qml/ui-components/searchbox/images/lineedit-bg.png create mode 100644 examples/qml/ui-components/searchbox/main.qml create mode 100644 examples/qml/ui-components/searchbox/searchbox.qmlproject create mode 100644 examples/qml/ui-components/slideswitch/content/Switch.qml create mode 100644 examples/qml/ui-components/slideswitch/content/background.png create mode 100644 examples/qml/ui-components/slideswitch/content/background.svg create mode 100644 examples/qml/ui-components/slideswitch/content/knob.png create mode 100644 examples/qml/ui-components/slideswitch/content/knob.svg create mode 100644 examples/qml/ui-components/slideswitch/slideswitch.qml create mode 100644 examples/qml/ui-components/spinner/content/Spinner.qml create mode 100644 examples/qml/ui-components/spinner/content/spinner-bg.png create mode 100644 examples/qml/ui-components/spinner/content/spinner-select.png create mode 100644 examples/qml/ui-components/spinner/main.qml create mode 100644 examples/qml/ui-components/spinner/spinner.qmlproject create mode 100644 examples/qml/ui-components/tabwidget/TabWidget.qml create mode 100644 examples/qml/ui-components/tabwidget/main.qml create mode 100644 examples/qml/ui-components/tabwidget/tab.png create mode 100644 examples/qml/ui-components/tabwidget/tabwidget.qmlproject create mode 100644 examples/qml/window/Window.qml create mode 100644 examples/qml/window/screen/screenInfo.qml create mode 100644 examples/qml/window/standalone.qml create mode 100644 examples/qml/window/window.cpp create mode 100644 examples/qml/window/window.pro create mode 100644 examples/qml/xml/xmlhttprequest/data.xml create mode 100644 examples/qml/xml/xmlhttprequest/xmlhttprequest-example.qml delete mode 100644 modules/qt_declarative.pri create mode 100644 modules/qt_qml.pri delete mode 100644 src/declarative/animations/animations.pri delete mode 100644 src/declarative/animations/qabstractanimationjob.cpp delete mode 100644 src/declarative/animations/qabstractanimationjob_p.h delete mode 100644 src/declarative/animations/qanimationgroupjob.cpp delete mode 100644 src/declarative/animations/qanimationgroupjob_p.h delete mode 100644 src/declarative/animations/qanimationjobutil_p.h delete mode 100644 src/declarative/animations/qparallelanimationgroupjob.cpp delete mode 100644 src/declarative/animations/qparallelanimationgroupjob_p.h delete mode 100644 src/declarative/animations/qpauseanimationjob.cpp delete mode 100644 src/declarative/animations/qpauseanimationjob_p.h delete mode 100644 src/declarative/animations/qsequentialanimationgroupjob.cpp delete mode 100644 src/declarative/animations/qsequentialanimationgroupjob_p.h delete mode 100644 src/declarative/debugger/debugger.pri delete mode 100644 src/declarative/debugger/qdebugmessageservice.cpp delete mode 100644 src/declarative/debugger/qdebugmessageservice_p.h delete mode 100644 src/declarative/debugger/qdeclarativedebug.h delete mode 100644 src/declarative/debugger/qdeclarativedebugclient.cpp delete mode 100644 src/declarative/debugger/qdeclarativedebugclient_p.h delete mode 100644 src/declarative/debugger/qdeclarativedebughelper.cpp delete mode 100644 src/declarative/debugger/qdeclarativedebughelper_p.h delete mode 100644 src/declarative/debugger/qdeclarativedebugserver.cpp delete mode 100644 src/declarative/debugger/qdeclarativedebugserver_p.h delete mode 100644 src/declarative/debugger/qdeclarativedebugserverconnection_p.h delete mode 100644 src/declarative/debugger/qdeclarativedebugservice.cpp delete mode 100644 src/declarative/debugger/qdeclarativedebugservice_p.h delete mode 100644 src/declarative/debugger/qdeclarativedebugservice_p_p.h delete mode 100644 src/declarative/debugger/qdeclarativedebugstatesdelegate_p.h delete mode 100644 src/declarative/debugger/qdeclarativeenginedebug.cpp delete mode 100644 src/declarative/debugger/qdeclarativeenginedebug_p.h delete mode 100644 src/declarative/debugger/qdeclarativeenginedebugservice.cpp delete mode 100644 src/declarative/debugger/qdeclarativeenginedebugservice_p.h delete mode 100644 src/declarative/debugger/qdeclarativeinspectorinterface_p.h delete mode 100644 src/declarative/debugger/qdeclarativeinspectorservice.cpp delete mode 100644 src/declarative/debugger/qdeclarativeinspectorservice_p.h delete mode 100644 src/declarative/debugger/qdeclarativeprofilerservice.cpp delete mode 100644 src/declarative/debugger/qdeclarativeprofilerservice_p.h delete mode 100644 src/declarative/debugger/qpacketprotocol.cpp delete mode 100644 src/declarative/debugger/qpacketprotocol_p.h delete mode 100644 src/declarative/debugger/qv8debugservice.cpp delete mode 100644 src/declarative/debugger/qv8debugservice_p.h delete mode 100644 src/declarative/debugger/qv8profilerservice.cpp delete mode 100644 src/declarative/debugger/qv8profilerservice_p.h delete mode 100644 src/declarative/declarative.pro delete mode 100644 src/declarative/qml/ftw/ftw.pri delete mode 100644 src/declarative/qml/ftw/qbitfield_p.h delete mode 100644 src/declarative/qml/ftw/qdeclarativepool.cpp delete mode 100644 src/declarative/qml/ftw/qdeclarativepool_p.h delete mode 100644 src/declarative/qml/ftw/qdeclarativerefcount_p.h delete mode 100644 src/declarative/qml/ftw/qdeclarativethread.cpp delete mode 100644 src/declarative/qml/ftw/qdeclarativethread_p.h delete mode 100644 src/declarative/qml/ftw/qdeclarativetrace.cpp delete mode 100644 src/declarative/qml/ftw/qdeclarativetrace_p.h delete mode 100644 src/declarative/qml/ftw/qdeletewatcher_p.h delete mode 100644 src/declarative/qml/ftw/qfastmetabuilder.cpp delete mode 100644 src/declarative/qml/ftw/qfastmetabuilder_p.h delete mode 100644 src/declarative/qml/ftw/qfieldlist_p.h delete mode 100644 src/declarative/qml/ftw/qfinitestack_p.h delete mode 100644 src/declarative/qml/ftw/qflagpointer_p.h delete mode 100644 src/declarative/qml/ftw/qhashedstring.cpp delete mode 100644 src/declarative/qml/ftw/qhashedstring_p.h delete mode 100644 src/declarative/qml/ftw/qhashfield_p.h delete mode 100644 src/declarative/qml/ftw/qintrusivelist.cpp delete mode 100644 src/declarative/qml/ftw/qintrusivelist_p.h delete mode 100644 src/declarative/qml/ftw/qlazilyallocated_p.h delete mode 100644 src/declarative/qml/ftw/qpodvector_p.h delete mode 100644 src/declarative/qml/ftw/qpointervaluepair_p.h delete mode 100644 src/declarative/qml/ftw/qrecursionwatcher_p.h delete mode 100644 src/declarative/qml/ftw/qrecyclepool_p.h delete mode 100644 src/declarative/qml/parser/parser.pri delete mode 100644 src/declarative/qml/parser/qdeclarativejs.g delete mode 100644 src/declarative/qml/parser/qdeclarativejsast.cpp delete mode 100644 src/declarative/qml/parser/qdeclarativejsast_p.h delete mode 100644 src/declarative/qml/parser/qdeclarativejsastfwd_p.h delete mode 100644 src/declarative/qml/parser/qdeclarativejsastvisitor.cpp delete mode 100644 src/declarative/qml/parser/qdeclarativejsastvisitor_p.h delete mode 100644 src/declarative/qml/parser/qdeclarativejsengine_p.cpp delete mode 100644 src/declarative/qml/parser/qdeclarativejsengine_p.h delete mode 100644 src/declarative/qml/parser/qdeclarativejsglobal_p.h delete mode 100644 src/declarative/qml/parser/qdeclarativejsgrammar.cpp delete mode 100644 src/declarative/qml/parser/qdeclarativejsgrammar_p.h delete mode 100644 src/declarative/qml/parser/qdeclarativejskeywords_p.h delete mode 100644 src/declarative/qml/parser/qdeclarativejslexer.cpp delete mode 100644 src/declarative/qml/parser/qdeclarativejslexer_p.h delete mode 100644 src/declarative/qml/parser/qdeclarativejsmemorypool_p.h delete mode 100644 src/declarative/qml/parser/qdeclarativejsparser.cpp delete mode 100644 src/declarative/qml/parser/qdeclarativejsparser_p.h delete mode 100644 src/declarative/qml/qdeclarative.h delete mode 100644 src/declarative/qml/qdeclarativeaccessors.cpp delete mode 100644 src/declarative/qml/qdeclarativeaccessors_p.h delete mode 100644 src/declarative/qml/qdeclarativeapplication.cpp delete mode 100644 src/declarative/qml/qdeclarativeapplication_p.h delete mode 100644 src/declarative/qml/qdeclarativebinding.cpp delete mode 100644 src/declarative/qml/qdeclarativebinding_p.h delete mode 100644 src/declarative/qml/qdeclarativebinding_p_p.h delete mode 100644 src/declarative/qml/qdeclarativeboundsignal.cpp delete mode 100644 src/declarative/qml/qdeclarativeboundsignal_p.h delete mode 100644 src/declarative/qml/qdeclarativecleanup.cpp delete mode 100644 src/declarative/qml/qdeclarativecleanup_p.h delete mode 100644 src/declarative/qml/qdeclarativecompileddata.cpp delete mode 100644 src/declarative/qml/qdeclarativecompiler.cpp delete mode 100644 src/declarative/qml/qdeclarativecompiler_p.h delete mode 100644 src/declarative/qml/qdeclarativecomponent.cpp delete mode 100644 src/declarative/qml/qdeclarativecomponent.h delete mode 100644 src/declarative/qml/qdeclarativecomponent_p.h delete mode 100644 src/declarative/qml/qdeclarativecomponentattached_p.h delete mode 100644 src/declarative/qml/qdeclarativecontext.cpp delete mode 100644 src/declarative/qml/qdeclarativecontext.h delete mode 100644 src/declarative/qml/qdeclarativecontext_p.h delete mode 100644 src/declarative/qml/qdeclarativecustomparser.cpp delete mode 100644 src/declarative/qml/qdeclarativecustomparser_p.h delete mode 100644 src/declarative/qml/qdeclarativecustomparser_p_p.h delete mode 100644 src/declarative/qml/qdeclarativedata_p.h delete mode 100644 src/declarative/qml/qdeclarativedirparser.cpp delete mode 100644 src/declarative/qml/qdeclarativedirparser_p.h delete mode 100644 src/declarative/qml/qdeclarativeengine.cpp delete mode 100644 src/declarative/qml/qdeclarativeengine.h delete mode 100644 src/declarative/qml/qdeclarativeengine_p.h delete mode 100644 src/declarative/qml/qdeclarativeerror.cpp delete mode 100644 src/declarative/qml/qdeclarativeerror.h delete mode 100644 src/declarative/qml/qdeclarativeexpression.cpp delete mode 100644 src/declarative/qml/qdeclarativeexpression.h delete mode 100644 src/declarative/qml/qdeclarativeexpression_p.h delete mode 100644 src/declarative/qml/qdeclarativeextensioninterface.h delete mode 100644 src/declarative/qml/qdeclarativeextensionplugin.cpp delete mode 100644 src/declarative/qml/qdeclarativeextensionplugin.h delete mode 100644 src/declarative/qml/qdeclarativeglobal_p.h delete mode 100644 src/declarative/qml/qdeclarativeguard_p.h delete mode 100644 src/declarative/qml/qdeclarativeimageprovider.cpp delete mode 100644 src/declarative/qml/qdeclarativeimageprovider.h delete mode 100644 src/declarative/qml/qdeclarativeimport.cpp delete mode 100644 src/declarative/qml/qdeclarativeimport_p.h delete mode 100644 src/declarative/qml/qdeclarativeincubator.cpp delete mode 100644 src/declarative/qml/qdeclarativeincubator.h delete mode 100644 src/declarative/qml/qdeclarativeincubator_p.h delete mode 100644 src/declarative/qml/qdeclarativeinfo.cpp delete mode 100644 src/declarative/qml/qdeclarativeinfo.h delete mode 100644 src/declarative/qml/qdeclarativeinstruction.cpp delete mode 100644 src/declarative/qml/qdeclarativeinstruction_p.h delete mode 100644 src/declarative/qml/qdeclarativeintegercache.cpp delete mode 100644 src/declarative/qml/qdeclarativeintegercache_p.h delete mode 100644 src/declarative/qml/qdeclarativelist.cpp delete mode 100644 src/declarative/qml/qdeclarativelist.h delete mode 100644 src/declarative/qml/qdeclarativelist_p.h delete mode 100644 src/declarative/qml/qdeclarativelistmodel.cpp delete mode 100644 src/declarative/qml/qdeclarativelistmodel_p.h delete mode 100644 src/declarative/qml/qdeclarativelistmodel_p_p.h delete mode 100644 src/declarative/qml/qdeclarativelistmodelworkeragent.cpp delete mode 100644 src/declarative/qml/qdeclarativelistmodelworkeragent_p.h delete mode 100644 src/declarative/qml/qdeclarativelocale.cpp delete mode 100644 src/declarative/qml/qdeclarativelocale_p.h delete mode 100644 src/declarative/qml/qdeclarativemetatype.cpp delete mode 100644 src/declarative/qml/qdeclarativemetatype_p.h delete mode 100644 src/declarative/qml/qdeclarativenetworkaccessmanagerfactory.cpp delete mode 100644 src/declarative/qml/qdeclarativenetworkaccessmanagerfactory.h delete mode 100644 src/declarative/qml/qdeclarativenotifier.cpp delete mode 100644 src/declarative/qml/qdeclarativenotifier_p.h delete mode 100644 src/declarative/qml/qdeclarativenullablevalue_p_p.h delete mode 100644 src/declarative/qml/qdeclarativeopenmetaobject.cpp delete mode 100644 src/declarative/qml/qdeclarativeopenmetaobject_p.h delete mode 100644 src/declarative/qml/qdeclarativeparserstatus.cpp delete mode 100644 src/declarative/qml/qdeclarativeparserstatus.h delete mode 100644 src/declarative/qml/qdeclarativeprivate.h delete mode 100644 src/declarative/qml/qdeclarativeproperty.cpp delete mode 100644 src/declarative/qml/qdeclarativeproperty.h delete mode 100644 src/declarative/qml/qdeclarativeproperty_p.h delete mode 100644 src/declarative/qml/qdeclarativepropertycache.cpp delete mode 100644 src/declarative/qml/qdeclarativepropertycache_p.h delete mode 100644 src/declarative/qml/qdeclarativepropertyvalueinterceptor.cpp delete mode 100644 src/declarative/qml/qdeclarativepropertyvalueinterceptor_p.h delete mode 100644 src/declarative/qml/qdeclarativepropertyvaluesource.cpp delete mode 100644 src/declarative/qml/qdeclarativepropertyvaluesource.h delete mode 100644 src/declarative/qml/qdeclarativeproxymetaobject.cpp delete mode 100644 src/declarative/qml/qdeclarativeproxymetaobject_p.h delete mode 100644 src/declarative/qml/qdeclarativerewrite.cpp delete mode 100644 src/declarative/qml/qdeclarativerewrite_p.h delete mode 100644 src/declarative/qml/qdeclarativescript.cpp delete mode 100644 src/declarative/qml/qdeclarativescript_p.h delete mode 100644 src/declarative/qml/qdeclarativescriptstring.cpp delete mode 100644 src/declarative/qml/qdeclarativescriptstring.h delete mode 100644 src/declarative/qml/qdeclarativescriptstring_p.h delete mode 100644 src/declarative/qml/qdeclarativestringconverters.cpp delete mode 100644 src/declarative/qml/qdeclarativestringconverters_p.h delete mode 100644 src/declarative/qml/qdeclarativetypeloader.cpp delete mode 100644 src/declarative/qml/qdeclarativetypeloader_p.h delete mode 100644 src/declarative/qml/qdeclarativetypenamecache.cpp delete mode 100644 src/declarative/qml/qdeclarativetypenamecache_p.h delete mode 100644 src/declarative/qml/qdeclarativetypenotavailable.cpp delete mode 100644 src/declarative/qml/qdeclarativetypenotavailable_p.h delete mode 100644 src/declarative/qml/qdeclarativevaluetype.cpp delete mode 100644 src/declarative/qml/qdeclarativevaluetype_p.h delete mode 100644 src/declarative/qml/qdeclarativevme.cpp delete mode 100644 src/declarative/qml/qdeclarativevme_p.h delete mode 100644 src/declarative/qml/qdeclarativevmemetaobject.cpp delete mode 100644 src/declarative/qml/qdeclarativevmemetaobject_p.h delete mode 100644 src/declarative/qml/qdeclarativewatcher.cpp delete mode 100644 src/declarative/qml/qdeclarativewatcher_p.h delete mode 100644 src/declarative/qml/qdeclarativeworkerscript.cpp delete mode 100644 src/declarative/qml/qdeclarativeworkerscript_p.h delete mode 100644 src/declarative/qml/qdeclarativexmlhttprequest.cpp delete mode 100644 src/declarative/qml/qdeclarativexmlhttprequest_p.h delete mode 100644 src/declarative/qml/qlistmodelinterface.cpp delete mode 100644 src/declarative/qml/qlistmodelinterface_p.h delete mode 100644 src/declarative/qml/qml.pri delete mode 100644 src/declarative/qml/rewriter/rewriter.pri delete mode 100644 src/declarative/qml/rewriter/textwriter.cpp delete mode 100644 src/declarative/qml/rewriter/textwriter_p.h delete mode 100644 src/declarative/qml/v4/qv4bindings.cpp delete mode 100644 src/declarative/qml/v4/qv4bindings_p.h delete mode 100644 src/declarative/qml/v4/qv4compiler.cpp delete mode 100644 src/declarative/qml/v4/qv4compiler_p.h delete mode 100644 src/declarative/qml/v4/qv4compiler_p_p.h delete mode 100644 src/declarative/qml/v4/qv4instruction.cpp delete mode 100644 src/declarative/qml/v4/qv4instruction_p.h delete mode 100644 src/declarative/qml/v4/qv4ir.cpp delete mode 100644 src/declarative/qml/v4/qv4ir_p.h delete mode 100644 src/declarative/qml/v4/qv4irbuilder.cpp delete mode 100644 src/declarative/qml/v4/qv4irbuilder_p.h delete mode 100644 src/declarative/qml/v4/qv4program_p.h delete mode 100644 src/declarative/qml/v4/v4.pri delete mode 100644 src/declarative/qml/v8/notes.txt delete mode 100644 src/declarative/qml/v8/qdeclarativebuiltinfunctions.cpp delete mode 100644 src/declarative/qml/v8/qdeclarativebuiltinfunctions_p.h delete mode 100644 src/declarative/qml/v8/qjsconverter_impl_p.h delete mode 100644 src/declarative/qml/v8/qjsconverter_p.h delete mode 100644 src/declarative/qml/v8/qjsengine.cpp delete mode 100644 src/declarative/qml/v8/qjsengine.h delete mode 100644 src/declarative/qml/v8/qjsengine_p.h delete mode 100644 src/declarative/qml/v8/qjsvalue.cpp delete mode 100644 src/declarative/qml/v8/qjsvalue.h delete mode 100644 src/declarative/qml/v8/qjsvalue_impl_p.h delete mode 100644 src/declarative/qml/v8/qjsvalue_p.h delete mode 100644 src/declarative/qml/v8/qjsvalueiterator.cpp delete mode 100644 src/declarative/qml/v8/qjsvalueiterator.h delete mode 100644 src/declarative/qml/v8/qjsvalueiterator_impl_p.h delete mode 100644 src/declarative/qml/v8/qjsvalueiterator_p.h delete mode 100644 src/declarative/qml/v8/qscript_impl_p.h delete mode 100644 src/declarative/qml/v8/qscriptisolate_p.h delete mode 100644 src/declarative/qml/v8/qscriptoriginalglobalobject_p.h delete mode 100644 src/declarative/qml/v8/qscriptshareddata_p.h delete mode 100644 src/declarative/qml/v8/qscripttools_p.h delete mode 100644 src/declarative/qml/v8/qv8_p.h delete mode 100644 src/declarative/qml/v8/qv8bindings.cpp delete mode 100644 src/declarative/qml/v8/qv8bindings_p.h delete mode 100644 src/declarative/qml/v8/qv8contextwrapper.cpp delete mode 100644 src/declarative/qml/v8/qv8contextwrapper_p.h delete mode 100644 src/declarative/qml/v8/qv8debug_p.h delete mode 100644 src/declarative/qml/v8/qv8domerrors.cpp delete mode 100644 src/declarative/qml/v8/qv8domerrors_p.h delete mode 100644 src/declarative/qml/v8/qv8engine.cpp delete mode 100644 src/declarative/qml/v8/qv8engine_impl_p.h delete mode 100644 src/declarative/qml/v8/qv8engine_p.h delete mode 100644 src/declarative/qml/v8/qv8include.cpp delete mode 100644 src/declarative/qml/v8/qv8include_p.h delete mode 100644 src/declarative/qml/v8/qv8listwrapper.cpp delete mode 100644 src/declarative/qml/v8/qv8listwrapper_p.h delete mode 100644 src/declarative/qml/v8/qv8profiler_p.h delete mode 100644 src/declarative/qml/v8/qv8qobjectwrapper.cpp delete mode 100644 src/declarative/qml/v8/qv8qobjectwrapper_p.h delete mode 100644 src/declarative/qml/v8/qv8sequencewrapper.cpp delete mode 100644 src/declarative/qml/v8/qv8sequencewrapper_p.h delete mode 100644 src/declarative/qml/v8/qv8sequencewrapper_p_p.h delete mode 100644 src/declarative/qml/v8/qv8sqlerrors.cpp delete mode 100644 src/declarative/qml/v8/qv8sqlerrors_p.h delete mode 100644 src/declarative/qml/v8/qv8stringwrapper.cpp delete mode 100644 src/declarative/qml/v8/qv8stringwrapper_p.h delete mode 100644 src/declarative/qml/v8/qv8typewrapper.cpp delete mode 100644 src/declarative/qml/v8/qv8typewrapper_p.h delete mode 100644 src/declarative/qml/v8/qv8valuetypewrapper.cpp delete mode 100644 src/declarative/qml/v8/qv8valuetypewrapper_p.h delete mode 100644 src/declarative/qml/v8/qv8variantresource_p.h delete mode 100644 src/declarative/qml/v8/qv8variantwrapper.cpp delete mode 100644 src/declarative/qml/v8/qv8variantwrapper_p.h delete mode 100644 src/declarative/qml/v8/qv8worker.cpp delete mode 100644 src/declarative/qml/v8/qv8worker_p.h delete mode 100644 src/declarative/qml/v8/script.pri delete mode 100644 src/declarative/qml/v8/v8.pri delete mode 100644 src/declarative/util/qdeclarativepropertymap.cpp delete mode 100644 src/declarative/util/qdeclarativepropertymap.h delete mode 100644 src/declarative/util/util.pri delete mode 100644 src/imports/folderlistmodel/qdeclarativefolderlistmodel.cpp delete mode 100644 src/imports/folderlistmodel/qdeclarativefolderlistmodel.h create mode 100644 src/imports/folderlistmodel/qquickfolderlistmodel.cpp create mode 100644 src/imports/folderlistmodel/qquickfolderlistmodel.h delete mode 100644 src/imports/xmllistmodel/qdeclarativexmllistmodel.cpp delete mode 100644 src/imports/xmllistmodel/qdeclarativexmllistmodel_p.h create mode 100644 src/imports/xmllistmodel/qqmlxmllistmodel.cpp create mode 100644 src/imports/xmllistmodel/qqmlxmllistmodel_p.h delete mode 100644 src/plugins/accessible/shared/qdeclarativeaccessible.cpp delete mode 100644 src/plugins/accessible/shared/qdeclarativeaccessible.h create mode 100644 src/plugins/accessible/shared/qqmlaccessible.cpp create mode 100644 src/plugins/accessible/shared/qqmlaccessible.h delete mode 100644 src/plugins/qmltooling/shared/qdeclarativeinspectorprotocol.h create mode 100644 src/plugins/qmltooling/shared/qqmlinspectorprotocol.h create mode 100644 src/qml/animations/animations.pri create mode 100644 src/qml/animations/qabstractanimationjob.cpp create mode 100644 src/qml/animations/qabstractanimationjob_p.h create mode 100644 src/qml/animations/qanimationgroupjob.cpp create mode 100644 src/qml/animations/qanimationgroupjob_p.h create mode 100644 src/qml/animations/qanimationjobutil_p.h create mode 100644 src/qml/animations/qparallelanimationgroupjob.cpp create mode 100644 src/qml/animations/qparallelanimationgroupjob_p.h create mode 100644 src/qml/animations/qpauseanimationjob.cpp create mode 100644 src/qml/animations/qpauseanimationjob_p.h create mode 100644 src/qml/animations/qsequentialanimationgroupjob.cpp create mode 100644 src/qml/animations/qsequentialanimationgroupjob_p.h create mode 100644 src/qml/debugger/debugger.pri create mode 100644 src/qml/debugger/qdebugmessageservice.cpp create mode 100644 src/qml/debugger/qdebugmessageservice_p.h create mode 100644 src/qml/debugger/qpacketprotocol.cpp create mode 100644 src/qml/debugger/qpacketprotocol_p.h create mode 100644 src/qml/debugger/qqmldebug.h create mode 100644 src/qml/debugger/qqmldebugclient.cpp create mode 100644 src/qml/debugger/qqmldebugclient_p.h create mode 100644 src/qml/debugger/qqmldebughelper.cpp create mode 100644 src/qml/debugger/qqmldebughelper_p.h create mode 100644 src/qml/debugger/qqmldebugserver.cpp create mode 100644 src/qml/debugger/qqmldebugserver_p.h create mode 100644 src/qml/debugger/qqmldebugserverconnection_p.h create mode 100644 src/qml/debugger/qqmldebugservice.cpp create mode 100644 src/qml/debugger/qqmldebugservice_p.h create mode 100644 src/qml/debugger/qqmldebugservice_p_p.h create mode 100644 src/qml/debugger/qqmldebugstatesdelegate_p.h create mode 100644 src/qml/debugger/qqmlenginedebug.cpp create mode 100644 src/qml/debugger/qqmlenginedebug_p.h create mode 100644 src/qml/debugger/qqmlenginedebugservice.cpp create mode 100644 src/qml/debugger/qqmlenginedebugservice_p.h create mode 100644 src/qml/debugger/qqmlinspectorinterface_p.h create mode 100644 src/qml/debugger/qqmlinspectorservice.cpp create mode 100644 src/qml/debugger/qqmlinspectorservice_p.h create mode 100644 src/qml/debugger/qqmlprofilerservice.cpp create mode 100644 src/qml/debugger/qqmlprofilerservice_p.h create mode 100644 src/qml/debugger/qv8debugservice.cpp create mode 100644 src/qml/debugger/qv8debugservice_p.h create mode 100644 src/qml/debugger/qv8profilerservice.cpp create mode 100644 src/qml/debugger/qv8profilerservice_p.h create mode 100644 src/qml/qml.pro create mode 100644 src/qml/qml/ftw/ftw.pri create mode 100644 src/qml/qml/ftw/qbitfield_p.h create mode 100644 src/qml/qml/ftw/qdeletewatcher_p.h create mode 100644 src/qml/qml/ftw/qfastmetabuilder.cpp create mode 100644 src/qml/qml/ftw/qfastmetabuilder_p.h create mode 100644 src/qml/qml/ftw/qfieldlist_p.h create mode 100644 src/qml/qml/ftw/qfinitestack_p.h create mode 100644 src/qml/qml/ftw/qflagpointer_p.h create mode 100644 src/qml/qml/ftw/qhashedstring.cpp create mode 100644 src/qml/qml/ftw/qhashedstring_p.h create mode 100644 src/qml/qml/ftw/qhashfield_p.h create mode 100644 src/qml/qml/ftw/qintrusivelist.cpp create mode 100644 src/qml/qml/ftw/qintrusivelist_p.h create mode 100644 src/qml/qml/ftw/qlazilyallocated_p.h create mode 100644 src/qml/qml/ftw/qpodvector_p.h create mode 100644 src/qml/qml/ftw/qpointervaluepair_p.h create mode 100644 src/qml/qml/ftw/qqmlpool.cpp create mode 100644 src/qml/qml/ftw/qqmlpool_p.h create mode 100644 src/qml/qml/ftw/qqmlrefcount_p.h create mode 100644 src/qml/qml/ftw/qqmlthread.cpp create mode 100644 src/qml/qml/ftw/qqmlthread_p.h create mode 100644 src/qml/qml/ftw/qqmltrace.cpp create mode 100644 src/qml/qml/ftw/qqmltrace_p.h create mode 100644 src/qml/qml/ftw/qrecursionwatcher_p.h create mode 100644 src/qml/qml/ftw/qrecyclepool_p.h create mode 100644 src/qml/qml/parser/parser.pri create mode 100644 src/qml/qml/parser/qqmljs.g create mode 100644 src/qml/qml/parser/qqmljsast.cpp create mode 100644 src/qml/qml/parser/qqmljsast_p.h create mode 100644 src/qml/qml/parser/qqmljsastfwd_p.h create mode 100644 src/qml/qml/parser/qqmljsastvisitor.cpp create mode 100644 src/qml/qml/parser/qqmljsastvisitor_p.h create mode 100644 src/qml/qml/parser/qqmljsengine_p.cpp create mode 100644 src/qml/qml/parser/qqmljsengine_p.h create mode 100644 src/qml/qml/parser/qqmljsglobal_p.h create mode 100644 src/qml/qml/parser/qqmljsgrammar.cpp create mode 100644 src/qml/qml/parser/qqmljsgrammar_p.h create mode 100644 src/qml/qml/parser/qqmljskeywords_p.h create mode 100644 src/qml/qml/parser/qqmljslexer.cpp create mode 100644 src/qml/qml/parser/qqmljslexer_p.h create mode 100644 src/qml/qml/parser/qqmljsmemorypool_p.h create mode 100644 src/qml/qml/parser/qqmljsparser.cpp create mode 100644 src/qml/qml/parser/qqmljsparser_p.h create mode 100644 src/qml/qml/qlistmodelinterface.cpp create mode 100644 src/qml/qml/qlistmodelinterface_p.h create mode 100644 src/qml/qml/qml.pri create mode 100644 src/qml/qml/qqml.h create mode 100644 src/qml/qml/qqmlaccessors.cpp create mode 100644 src/qml/qml/qqmlaccessors_p.h create mode 100644 src/qml/qml/qqmlbinding.cpp create mode 100644 src/qml/qml/qqmlbinding_p.h create mode 100644 src/qml/qml/qqmlbinding_p_p.h create mode 100644 src/qml/qml/qqmlboundsignal.cpp create mode 100644 src/qml/qml/qqmlboundsignal_p.h create mode 100644 src/qml/qml/qqmlcleanup.cpp create mode 100644 src/qml/qml/qqmlcleanup_p.h create mode 100644 src/qml/qml/qqmlcompileddata.cpp create mode 100644 src/qml/qml/qqmlcompiler.cpp create mode 100644 src/qml/qml/qqmlcompiler_p.h create mode 100644 src/qml/qml/qqmlcomponent.cpp create mode 100644 src/qml/qml/qqmlcomponent.h create mode 100644 src/qml/qml/qqmlcomponent_p.h create mode 100644 src/qml/qml/qqmlcomponentattached_p.h create mode 100644 src/qml/qml/qqmlcontext.cpp create mode 100644 src/qml/qml/qqmlcontext.h create mode 100644 src/qml/qml/qqmlcontext_p.h create mode 100644 src/qml/qml/qqmlcustomparser.cpp create mode 100644 src/qml/qml/qqmlcustomparser_p.h create mode 100644 src/qml/qml/qqmlcustomparser_p_p.h create mode 100644 src/qml/qml/qqmldata_p.h create mode 100644 src/qml/qml/qqmldirparser.cpp create mode 100644 src/qml/qml/qqmldirparser_p.h create mode 100644 src/qml/qml/qqmlengine.cpp create mode 100644 src/qml/qml/qqmlengine.h create mode 100644 src/qml/qml/qqmlengine_p.h create mode 100644 src/qml/qml/qqmlerror.cpp create mode 100644 src/qml/qml/qqmlerror.h create mode 100644 src/qml/qml/qqmlexpression.cpp create mode 100644 src/qml/qml/qqmlexpression.h create mode 100644 src/qml/qml/qqmlexpression_p.h create mode 100644 src/qml/qml/qqmlextensioninterface.h create mode 100644 src/qml/qml/qqmlextensionplugin.cpp create mode 100644 src/qml/qml/qqmlextensionplugin.h create mode 100644 src/qml/qml/qqmlglobal_p.h create mode 100644 src/qml/qml/qqmlguard_p.h create mode 100644 src/qml/qml/qqmlimageprovider.cpp create mode 100644 src/qml/qml/qqmlimageprovider.h create mode 100644 src/qml/qml/qqmlimport.cpp create mode 100644 src/qml/qml/qqmlimport_p.h create mode 100644 src/qml/qml/qqmlincubator.cpp create mode 100644 src/qml/qml/qqmlincubator.h create mode 100644 src/qml/qml/qqmlincubator_p.h create mode 100644 src/qml/qml/qqmlinfo.cpp create mode 100644 src/qml/qml/qqmlinfo.h create mode 100644 src/qml/qml/qqmlinstruction.cpp create mode 100644 src/qml/qml/qqmlinstruction_p.h create mode 100644 src/qml/qml/qqmlintegercache.cpp create mode 100644 src/qml/qml/qqmlintegercache_p.h create mode 100644 src/qml/qml/qqmllist.cpp create mode 100644 src/qml/qml/qqmllist.h create mode 100644 src/qml/qml/qqmllist_p.h create mode 100644 src/qml/qml/qqmllocale.cpp create mode 100644 src/qml/qml/qqmllocale_p.h create mode 100644 src/qml/qml/qqmlmetatype.cpp create mode 100644 src/qml/qml/qqmlmetatype_p.h create mode 100644 src/qml/qml/qqmlnetworkaccessmanagerfactory.cpp create mode 100644 src/qml/qml/qqmlnetworkaccessmanagerfactory.h create mode 100644 src/qml/qml/qqmlnotifier.cpp create mode 100644 src/qml/qml/qqmlnotifier_p.h create mode 100644 src/qml/qml/qqmlnullablevalue_p_p.h create mode 100644 src/qml/qml/qqmlopenmetaobject.cpp create mode 100644 src/qml/qml/qqmlopenmetaobject_p.h create mode 100644 src/qml/qml/qqmlparserstatus.cpp create mode 100644 src/qml/qml/qqmlparserstatus.h create mode 100644 src/qml/qml/qqmlprivate.h create mode 100644 src/qml/qml/qqmlproperty.cpp create mode 100644 src/qml/qml/qqmlproperty.h create mode 100644 src/qml/qml/qqmlproperty_p.h create mode 100644 src/qml/qml/qqmlpropertycache.cpp create mode 100644 src/qml/qml/qqmlpropertycache_p.h create mode 100644 src/qml/qml/qqmlpropertyvalueinterceptor.cpp create mode 100644 src/qml/qml/qqmlpropertyvalueinterceptor_p.h create mode 100644 src/qml/qml/qqmlpropertyvaluesource.cpp create mode 100644 src/qml/qml/qqmlpropertyvaluesource.h create mode 100644 src/qml/qml/qqmlproxymetaobject.cpp create mode 100644 src/qml/qml/qqmlproxymetaobject_p.h create mode 100644 src/qml/qml/qqmlrewrite.cpp create mode 100644 src/qml/qml/qqmlrewrite_p.h create mode 100644 src/qml/qml/qqmlscript.cpp create mode 100644 src/qml/qml/qqmlscript_p.h create mode 100644 src/qml/qml/qqmlscriptstring.cpp create mode 100644 src/qml/qml/qqmlscriptstring.h create mode 100644 src/qml/qml/qqmlscriptstring_p.h create mode 100644 src/qml/qml/qqmlstringconverters.cpp create mode 100644 src/qml/qml/qqmlstringconverters_p.h create mode 100644 src/qml/qml/qqmltypeloader.cpp create mode 100644 src/qml/qml/qqmltypeloader_p.h create mode 100644 src/qml/qml/qqmltypenamecache.cpp create mode 100644 src/qml/qml/qqmltypenamecache_p.h create mode 100644 src/qml/qml/qqmltypenotavailable.cpp create mode 100644 src/qml/qml/qqmltypenotavailable_p.h create mode 100644 src/qml/qml/qqmlvaluetype.cpp create mode 100644 src/qml/qml/qqmlvaluetype_p.h create mode 100644 src/qml/qml/qqmlvme.cpp create mode 100644 src/qml/qml/qqmlvme_p.h create mode 100644 src/qml/qml/qqmlvmemetaobject.cpp create mode 100644 src/qml/qml/qqmlvmemetaobject_p.h create mode 100644 src/qml/qml/qqmlwatcher.cpp create mode 100644 src/qml/qml/qqmlwatcher_p.h create mode 100644 src/qml/qml/qqmlxmlhttprequest.cpp create mode 100644 src/qml/qml/qqmlxmlhttprequest_p.h create mode 100644 src/qml/qml/qquickapplication.cpp create mode 100644 src/qml/qml/qquickapplication_p.h create mode 100644 src/qml/qml/qquicklistmodel.cpp create mode 100644 src/qml/qml/qquicklistmodel_p.h create mode 100644 src/qml/qml/qquicklistmodel_p_p.h create mode 100644 src/qml/qml/qquicklistmodelworkeragent.cpp create mode 100644 src/qml/qml/qquicklistmodelworkeragent_p.h create mode 100644 src/qml/qml/qquickworkerscript.cpp create mode 100644 src/qml/qml/qquickworkerscript_p.h create mode 100644 src/qml/qml/rewriter/rewriter.pri create mode 100644 src/qml/qml/rewriter/textwriter.cpp create mode 100644 src/qml/qml/rewriter/textwriter_p.h create mode 100644 src/qml/qml/v4/qv4bindings.cpp create mode 100644 src/qml/qml/v4/qv4bindings_p.h create mode 100644 src/qml/qml/v4/qv4compiler.cpp create mode 100644 src/qml/qml/v4/qv4compiler_p.h create mode 100644 src/qml/qml/v4/qv4compiler_p_p.h create mode 100644 src/qml/qml/v4/qv4instruction.cpp create mode 100644 src/qml/qml/v4/qv4instruction_p.h create mode 100644 src/qml/qml/v4/qv4ir.cpp create mode 100644 src/qml/qml/v4/qv4ir_p.h create mode 100644 src/qml/qml/v4/qv4irbuilder.cpp create mode 100644 src/qml/qml/v4/qv4irbuilder_p.h create mode 100644 src/qml/qml/v4/qv4program_p.h create mode 100644 src/qml/qml/v4/v4.pri create mode 100644 src/qml/qml/v8/notes.txt create mode 100644 src/qml/qml/v8/qjsconverter_impl_p.h create mode 100644 src/qml/qml/v8/qjsconverter_p.h create mode 100644 src/qml/qml/v8/qjsengine.cpp create mode 100644 src/qml/qml/v8/qjsengine.h create mode 100644 src/qml/qml/v8/qjsengine_p.h create mode 100644 src/qml/qml/v8/qjsvalue.cpp create mode 100644 src/qml/qml/v8/qjsvalue.h create mode 100644 src/qml/qml/v8/qjsvalue_impl_p.h create mode 100644 src/qml/qml/v8/qjsvalue_p.h create mode 100644 src/qml/qml/v8/qjsvalueiterator.cpp create mode 100644 src/qml/qml/v8/qjsvalueiterator.h create mode 100644 src/qml/qml/v8/qjsvalueiterator_impl_p.h create mode 100644 src/qml/qml/v8/qjsvalueiterator_p.h create mode 100644 src/qml/qml/v8/qqmlbuiltinfunctions.cpp create mode 100644 src/qml/qml/v8/qqmlbuiltinfunctions_p.h create mode 100644 src/qml/qml/v8/qscript_impl_p.h create mode 100644 src/qml/qml/v8/qscriptisolate_p.h create mode 100644 src/qml/qml/v8/qscriptoriginalglobalobject_p.h create mode 100644 src/qml/qml/v8/qscriptshareddata_p.h create mode 100644 src/qml/qml/v8/qscripttools_p.h create mode 100644 src/qml/qml/v8/qv8_p.h create mode 100644 src/qml/qml/v8/qv8bindings.cpp create mode 100644 src/qml/qml/v8/qv8bindings_p.h create mode 100644 src/qml/qml/v8/qv8contextwrapper.cpp create mode 100644 src/qml/qml/v8/qv8contextwrapper_p.h create mode 100644 src/qml/qml/v8/qv8debug_p.h create mode 100644 src/qml/qml/v8/qv8domerrors.cpp create mode 100644 src/qml/qml/v8/qv8domerrors_p.h create mode 100644 src/qml/qml/v8/qv8engine.cpp create mode 100644 src/qml/qml/v8/qv8engine_impl_p.h create mode 100644 src/qml/qml/v8/qv8engine_p.h create mode 100644 src/qml/qml/v8/qv8include.cpp create mode 100644 src/qml/qml/v8/qv8include_p.h create mode 100644 src/qml/qml/v8/qv8listwrapper.cpp create mode 100644 src/qml/qml/v8/qv8listwrapper_p.h create mode 100644 src/qml/qml/v8/qv8profiler_p.h create mode 100644 src/qml/qml/v8/qv8qobjectwrapper.cpp create mode 100644 src/qml/qml/v8/qv8qobjectwrapper_p.h create mode 100644 src/qml/qml/v8/qv8sequencewrapper.cpp create mode 100644 src/qml/qml/v8/qv8sequencewrapper_p.h create mode 100644 src/qml/qml/v8/qv8sequencewrapper_p_p.h create mode 100644 src/qml/qml/v8/qv8sqlerrors.cpp create mode 100644 src/qml/qml/v8/qv8sqlerrors_p.h create mode 100644 src/qml/qml/v8/qv8stringwrapper.cpp create mode 100644 src/qml/qml/v8/qv8stringwrapper_p.h create mode 100644 src/qml/qml/v8/qv8typewrapper.cpp create mode 100644 src/qml/qml/v8/qv8typewrapper_p.h create mode 100644 src/qml/qml/v8/qv8valuetypewrapper.cpp create mode 100644 src/qml/qml/v8/qv8valuetypewrapper_p.h create mode 100644 src/qml/qml/v8/qv8variantresource_p.h create mode 100644 src/qml/qml/v8/qv8variantwrapper.cpp create mode 100644 src/qml/qml/v8/qv8variantwrapper_p.h create mode 100644 src/qml/qml/v8/qv8worker.cpp create mode 100644 src/qml/qml/v8/qv8worker_p.h create mode 100644 src/qml/qml/v8/script.pri create mode 100644 src/qml/qml/v8/v8.pri create mode 100644 src/qml/qtqmlglobal.h create mode 100644 src/qml/qtqmlglobal_p.h create mode 100644 src/qml/util/qqmlpropertymap.cpp create mode 100644 src/qml/util/qqmlpropertymap.h create mode 100644 src/qml/util/util.pri delete mode 100644 src/quick/items/qquickanimation.cpp delete mode 100644 src/quick/items/qquickanimation_p.h delete mode 100644 src/quick/items/qquickanimation_p_p.h create mode 100644 src/quick/items/qquickitemanimation.cpp create mode 100644 src/quick/items/qquickitemanimation_p.h create mode 100644 src/quick/items/qquickitemanimation_p_p.h delete mode 100644 src/quick/util/qdeclarativeanimation.cpp delete mode 100644 src/quick/util/qdeclarativeanimation_p.h delete mode 100644 src/quick/util/qdeclarativeanimation_p_p.h delete mode 100644 src/quick/util/qdeclarativeanimationcontroller.cpp delete mode 100644 src/quick/util/qdeclarativeanimationcontroller_p.h delete mode 100644 src/quick/util/qdeclarativebehavior.cpp delete mode 100644 src/quick/util/qdeclarativebehavior_p.h delete mode 100644 src/quick/util/qdeclarativebind.cpp delete mode 100644 src/quick/util/qdeclarativebind_p.h delete mode 100644 src/quick/util/qdeclarativechangeset.cpp delete mode 100644 src/quick/util/qdeclarativechangeset_p.h delete mode 100644 src/quick/util/qdeclarativeconnections.cpp delete mode 100644 src/quick/util/qdeclarativeconnections_p.h delete mode 100644 src/quick/util/qdeclarativefontloader.cpp delete mode 100644 src/quick/util/qdeclarativefontloader_p.h delete mode 100644 src/quick/util/qdeclarativelistaccessor.cpp delete mode 100644 src/quick/util/qdeclarativelistaccessor_p.h delete mode 100644 src/quick/util/qdeclarativelistcompositor.cpp delete mode 100644 src/quick/util/qdeclarativelistcompositor_p.h delete mode 100644 src/quick/util/qdeclarativepackage.cpp delete mode 100644 src/quick/util/qdeclarativepackage_p.h delete mode 100644 src/quick/util/qdeclarativepath.cpp delete mode 100644 src/quick/util/qdeclarativepath_p.h delete mode 100644 src/quick/util/qdeclarativepath_p_p.h delete mode 100644 src/quick/util/qdeclarativepathinterpolator.cpp delete mode 100644 src/quick/util/qdeclarativepathinterpolator_p.h delete mode 100644 src/quick/util/qdeclarativepixmapcache.cpp delete mode 100644 src/quick/util/qdeclarativepixmapcache_p.h delete mode 100644 src/quick/util/qdeclarativepropertychanges.cpp delete mode 100644 src/quick/util/qdeclarativepropertychanges_p.h delete mode 100644 src/quick/util/qdeclarativesmoothedanimation.cpp delete mode 100644 src/quick/util/qdeclarativesmoothedanimation_p.h delete mode 100644 src/quick/util/qdeclarativesmoothedanimation_p_p.h delete mode 100644 src/quick/util/qdeclarativespringanimation.cpp delete mode 100644 src/quick/util/qdeclarativespringanimation_p.h delete mode 100644 src/quick/util/qdeclarativestate.cpp delete mode 100644 src/quick/util/qdeclarativestate_p.h delete mode 100644 src/quick/util/qdeclarativestate_p_p.h delete mode 100644 src/quick/util/qdeclarativestategroup.cpp delete mode 100644 src/quick/util/qdeclarativestategroup_p.h delete mode 100644 src/quick/util/qdeclarativestateoperations.cpp delete mode 100644 src/quick/util/qdeclarativestateoperations_p.h delete mode 100644 src/quick/util/qdeclarativestyledtext.cpp delete mode 100644 src/quick/util/qdeclarativestyledtext_p.h delete mode 100644 src/quick/util/qdeclarativesvgparser.cpp delete mode 100644 src/quick/util/qdeclarativesvgparser_p.h delete mode 100644 src/quick/util/qdeclarativesystempalette.cpp delete mode 100644 src/quick/util/qdeclarativesystempalette_p.h delete mode 100644 src/quick/util/qdeclarativetimeline.cpp delete mode 100644 src/quick/util/qdeclarativetimeline_p_p.h delete mode 100644 src/quick/util/qdeclarativetimer.cpp delete mode 100644 src/quick/util/qdeclarativetimer_p.h delete mode 100644 src/quick/util/qdeclarativetransition.cpp delete mode 100644 src/quick/util/qdeclarativetransition_p.h delete mode 100644 src/quick/util/qdeclarativetransitionmanager.cpp delete mode 100644 src/quick/util/qdeclarativetransitionmanager_p_p.h delete mode 100644 src/quick/util/qdeclarativeutilmodule.cpp delete mode 100644 src/quick/util/qdeclarativeutilmodule_p.h create mode 100644 src/quick/util/qquickanimation.cpp create mode 100644 src/quick/util/qquickanimation_p.h create mode 100644 src/quick/util/qquickanimation_p_p.h create mode 100644 src/quick/util/qquickanimationcontroller.cpp create mode 100644 src/quick/util/qquickanimationcontroller_p.h create mode 100644 src/quick/util/qquickbehavior.cpp create mode 100644 src/quick/util/qquickbehavior_p.h create mode 100644 src/quick/util/qquickbind.cpp create mode 100644 src/quick/util/qquickbind_p.h create mode 100644 src/quick/util/qquickchangeset.cpp create mode 100644 src/quick/util/qquickchangeset_p.h create mode 100644 src/quick/util/qquickconnections.cpp create mode 100644 src/quick/util/qquickconnections_p.h create mode 100644 src/quick/util/qquickfontloader.cpp create mode 100644 src/quick/util/qquickfontloader_p.h create mode 100644 src/quick/util/qquicklistaccessor.cpp create mode 100644 src/quick/util/qquicklistaccessor_p.h create mode 100644 src/quick/util/qquicklistcompositor.cpp create mode 100644 src/quick/util/qquicklistcompositor_p.h create mode 100644 src/quick/util/qquickpackage.cpp create mode 100644 src/quick/util/qquickpackage_p.h create mode 100644 src/quick/util/qquickpath.cpp create mode 100644 src/quick/util/qquickpath_p.h create mode 100644 src/quick/util/qquickpath_p_p.h create mode 100644 src/quick/util/qquickpathinterpolator.cpp create mode 100644 src/quick/util/qquickpathinterpolator_p.h create mode 100644 src/quick/util/qquickpixmapcache.cpp create mode 100644 src/quick/util/qquickpixmapcache_p.h create mode 100644 src/quick/util/qquickpropertychanges.cpp create mode 100644 src/quick/util/qquickpropertychanges_p.h create mode 100644 src/quick/util/qquicksmoothedanimation.cpp create mode 100644 src/quick/util/qquicksmoothedanimation_p.h create mode 100644 src/quick/util/qquicksmoothedanimation_p_p.h create mode 100644 src/quick/util/qquickspringanimation.cpp create mode 100644 src/quick/util/qquickspringanimation_p.h create mode 100644 src/quick/util/qquickstate.cpp create mode 100644 src/quick/util/qquickstate_p.h create mode 100644 src/quick/util/qquickstate_p_p.h create mode 100644 src/quick/util/qquickstatechangescript.cpp create mode 100644 src/quick/util/qquickstatechangescript_p.h create mode 100644 src/quick/util/qquickstategroup.cpp create mode 100644 src/quick/util/qquickstategroup_p.h create mode 100644 src/quick/util/qquickstyledtext.cpp create mode 100644 src/quick/util/qquickstyledtext_p.h create mode 100644 src/quick/util/qquicksvgparser.cpp create mode 100644 src/quick/util/qquicksvgparser_p.h create mode 100644 src/quick/util/qquicksystempalette.cpp create mode 100644 src/quick/util/qquicksystempalette_p.h create mode 100644 src/quick/util/qquicktimeline.cpp create mode 100644 src/quick/util/qquicktimeline_p_p.h create mode 100644 src/quick/util/qquicktimer.cpp create mode 100644 src/quick/util/qquicktimer_p.h create mode 100644 src/quick/util/qquicktransition.cpp create mode 100644 src/quick/util/qquicktransition_p.h create mode 100644 src/quick/util/qquicktransitionmanager.cpp create mode 100644 src/quick/util/qquicktransitionmanager_p_p.h create mode 100644 src/quick/util/qquickutilmodule.cpp create mode 100644 src/quick/util/qquickutilmodule_p.h delete mode 100644 tests/auto/declarative/animation/animation.pro delete mode 100644 tests/auto/declarative/animation/qabstractanimationjob/qabstractanimationjob.pro delete mode 100644 tests/auto/declarative/animation/qabstractanimationjob/tst_qabstractanimationjob.cpp delete mode 100644 tests/auto/declarative/animation/qanimationgroupjob/qanimationgroupjob.pro delete mode 100644 tests/auto/declarative/animation/qanimationgroupjob/tst_qanimationgroupjob.cpp delete mode 100644 tests/auto/declarative/animation/qparallelanimationgroupjob/qparallelanimationgroupjob.pro delete mode 100644 tests/auto/declarative/animation/qparallelanimationgroupjob/tst_qparallelanimationgroupjob.cpp delete mode 100644 tests/auto/declarative/animation/qpauseanimationjob/qpauseanimationjob.pro delete mode 100644 tests/auto/declarative/animation/qpauseanimationjob/tst_qpauseanimationjob.cpp delete mode 100644 tests/auto/declarative/animation/qsequentialanimationgroupjob/qsequentialanimationgroupjob.pro delete mode 100644 tests/auto/declarative/animation/qsequentialanimationgroupjob/tst_qsequentialanimationgroupjob.cpp delete mode 100644 tests/auto/declarative/debugger/debugger.pro delete mode 100644 tests/auto/declarative/debugger/qdebugmessageservice/data/test.qml delete mode 100644 tests/auto/declarative/debugger/qdebugmessageservice/qdebugmessageservice.pro delete mode 100644 tests/auto/declarative/debugger/qdebugmessageservice/tst_qdebugmessageservice.cpp delete mode 100644 tests/auto/declarative/debugger/qdeclarativedebugclient/qdeclarativedebugclient.pro delete mode 100644 tests/auto/declarative/debugger/qdeclarativedebugclient/tst_qdeclarativedebugclient.cpp delete mode 100644 tests/auto/declarative/debugger/qdeclarativedebugjs/data/breakpointRelocation.qml delete mode 100644 tests/auto/declarative/debugger/qdeclarativedebugjs/data/changeBreakpoint.qml delete mode 100644 tests/auto/declarative/debugger/qdeclarativedebugjs/data/condition.qml delete mode 100644 tests/auto/declarative/debugger/qdeclarativedebugjs/data/createComponent.qml delete mode 100644 tests/auto/declarative/debugger/qdeclarativedebugjs/data/exception.qml delete mode 100644 tests/auto/declarative/debugger/qdeclarativedebugjs/data/loadjsfile.qml delete mode 100644 tests/auto/declarative/debugger/qdeclarativedebugjs/data/oncompleted.qml delete mode 100644 tests/auto/declarative/debugger/qdeclarativedebugjs/data/stepAction.qml delete mode 100644 tests/auto/declarative/debugger/qdeclarativedebugjs/data/test.js delete mode 100644 tests/auto/declarative/debugger/qdeclarativedebugjs/data/test.qml delete mode 100644 tests/auto/declarative/debugger/qdeclarativedebugjs/data/timer.qml delete mode 100644 tests/auto/declarative/debugger/qdeclarativedebugjs/qdeclarativedebugjs.pro delete mode 100644 tests/auto/declarative/debugger/qdeclarativedebugjs/tst_qdeclarativedebugjs.cpp delete mode 100644 tests/auto/declarative/debugger/qdeclarativedebugservice/qdeclarativedebugservice.pro delete mode 100644 tests/auto/declarative/debugger/qdeclarativedebugservice/tst_qdeclarativedebugservice.cpp delete mode 100644 tests/auto/declarative/debugger/qdeclarativeenginedebug/qdeclarativeenginedebug.pro delete mode 100644 tests/auto/declarative/debugger/qdeclarativeenginedebug/tst_qdeclarativeenginedebug.cpp delete mode 100644 tests/auto/declarative/debugger/qdeclarativeinspector/app/app.pro delete mode 100644 tests/auto/declarative/debugger/qdeclarativeinspector/app/main.cpp delete mode 100644 tests/auto/declarative/debugger/qdeclarativeinspector/app/qtquick2.qml delete mode 100644 tests/auto/declarative/debugger/qdeclarativeinspector/qdeclarativeinspector.pro delete mode 100644 tests/auto/declarative/debugger/qdeclarativeinspector/tst_qdeclarativeinspector.cpp delete mode 100644 tests/auto/declarative/debugger/qdeclarativeinspector/tst_qdeclarativeinspector.pro delete mode 100644 tests/auto/declarative/debugger/qdeclarativeprofilerservice/data/exit.qml delete mode 100644 tests/auto/declarative/debugger/qdeclarativeprofilerservice/data/test.qml delete mode 100644 tests/auto/declarative/debugger/qdeclarativeprofilerservice/qdeclarativeprofilerservice.pro delete mode 100644 tests/auto/declarative/debugger/qdeclarativeprofilerservice/tst_qdeclarativeprofilerservice.cpp delete mode 100644 tests/auto/declarative/debugger/qpacketprotocol/qpacketprotocol.pro delete mode 100644 tests/auto/declarative/debugger/qpacketprotocol/tst_qpacketprotocol.cpp delete mode 100644 tests/auto/declarative/debugger/qv8profilerservice/data/console.qml delete mode 100644 tests/auto/declarative/debugger/qv8profilerservice/data/exit.qml delete mode 100644 tests/auto/declarative/debugger/qv8profilerservice/data/test.qml delete mode 100644 tests/auto/declarative/debugger/qv8profilerservice/qv8profilerservice.pro delete mode 100644 tests/auto/declarative/debugger/qv8profilerservice/tst_qv8profilerservice.cpp delete mode 100644 tests/auto/declarative/debugger/shared/debugutil.cpp delete mode 100644 tests/auto/declarative/debugger/shared/debugutil_p.h delete mode 100644 tests/auto/declarative/declarative.pro delete mode 100644 tests/auto/declarative/parserstress/parserstress.pro delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Array/15.4-1.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Array/15.4-2.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Array/15.4.1.1.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Array/15.4.1.2.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Array/15.4.1.3.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Array/15.4.1.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Array/15.4.2.1-1.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Array/15.4.2.1-2.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Array/15.4.2.1-3.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Array/15.4.2.2-1.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Array/15.4.2.2-2.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Array/15.4.2.3.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Array/15.4.3.1-2.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Array/15.4.3.2.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Array/15.4.4.1.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Array/15.4.4.2.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Array/15.4.4.3-1.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Array/15.4.4.4-1.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Array/15.4.4.4-2.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Array/15.4.4.5-1.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Array/15.4.4.5-2.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Array/15.4.4.5-3.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Array/15.4.4.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Array/15.4.5.1-1.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Array/15.4.5.1-2.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Array/15.4.5.2-1.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Array/15.4.5.2-2.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Array/browser.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Array/shell.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Boolean/15.6.1.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Boolean/15.6.2.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Boolean/15.6.3.1-1.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Boolean/15.6.3.1-2.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Boolean/15.6.3.1-3.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Boolean/15.6.3.1-4.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Boolean/15.6.3.1.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Boolean/15.6.4-1.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Boolean/15.6.4.1.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Boolean/15.6.4.2-1.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Boolean/15.6.4.2-2.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Boolean/15.6.4.2-3.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Boolean/15.6.4.2-4-n.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Boolean/15.6.4.3-1.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Boolean/15.6.4.3-2.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Boolean/15.6.4.3-3.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Boolean/15.6.4.3-4-n.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Boolean/15.6.4.3.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Boolean/15.6.4.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Boolean/browser.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Boolean/shell.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Date/15.9.1.1-1.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Date/15.9.1.1-2.js delete mode 100755 tests/auto/declarative/parserstress/tests/ecma/Date/15.9.1.13-1.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Date/15.9.2.1.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Date/15.9.2.2-1.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Date/15.9.2.2-2.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Date/15.9.2.2-3.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Date/15.9.2.2-4.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Date/15.9.2.2-5.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Date/15.9.2.2-6.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Date/15.9.3.1-1.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Date/15.9.3.1-2.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Date/15.9.3.1-3.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Date/15.9.3.1-4.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Date/15.9.3.1-5.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Date/15.9.3.2-1.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Date/15.9.3.2-2.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Date/15.9.3.2-3.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Date/15.9.3.2-4.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Date/15.9.3.2-5.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Date/15.9.3.8-1.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Date/15.9.3.8-2.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Date/15.9.3.8-3.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Date/15.9.3.8-4.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Date/15.9.3.8-5.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Date/15.9.4.2-1.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Date/15.9.4.2.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Date/15.9.4.3.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.1.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.10-1.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.10-10.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.10-11.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.10-12.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.10-13.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.10-2.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.10-3.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.10-4.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.10-5.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.10-6.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.10-7.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.10-8.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.10-9.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.11-1.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.11-2.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.11-3.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.11-4.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.11-5.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.11-6.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.11-7.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.12-1.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.12-2.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.12-3.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.12-4.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.12-5.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.12-6.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.12-7.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.12-8.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.13-1.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.13-2.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.13-3.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.13-4.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.13-5.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.13-6.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.13-7.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.13-8.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.14.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.15.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.16.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.17.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.18.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.19.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.2-1.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.2-2-n.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.2.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.20.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.21-1.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.21-2.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.21-3.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.21-4.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.21-5.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.21-6.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.21-7.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.21-8.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.22-1.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.22-2.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.22-3.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.22-4.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.22-5.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.22-6.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.22-7.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.22-8.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.23-1.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.23-10.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.23-11.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.23-12.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.23-13.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.23-14.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.23-15.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.23-16.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.23-17.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.23-18.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.23-2.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.23-3-n.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.23-4.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.23-5.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.23-6.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.23-7.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.23-8.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.23-9.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.24-1.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.24-2.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.24-3.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.24-4.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.24-5.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.24-6.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.24-7.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.24-8.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.25-1.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.26-1.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.27-1.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.28-1.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.29-1.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.3-1-n.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.3-2.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.30-1.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.31-1.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.32-1.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.33-1.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.34-1.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.35-1.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.36-1.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.36-2.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.36-3.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.36-4.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.36-5.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.36-6.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.36-7.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.37-1.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.37-2.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.37-3.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.37-4.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.37-5.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.4-1.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.4-2-n.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.5.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.6.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.7.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.8.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.9.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Date/browser.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Date/shell.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/ExecutionContexts/10.1.3-1.js delete mode 100755 tests/auto/declarative/parserstress/tests/ecma/ExecutionContexts/10.1.3-2.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/ExecutionContexts/10.1.3.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/ExecutionContexts/10.1.4-1.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/ExecutionContexts/10.1.4-10.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/ExecutionContexts/10.1.4-2.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/ExecutionContexts/10.1.4-3.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/ExecutionContexts/10.1.4-4.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/ExecutionContexts/10.1.4-5.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/ExecutionContexts/10.1.4-6.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/ExecutionContexts/10.1.4-7.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/ExecutionContexts/10.1.4-8.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/ExecutionContexts/10.1.5-1.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/ExecutionContexts/10.1.5-2.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/ExecutionContexts/10.1.5-3.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/ExecutionContexts/10.1.5-4.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/ExecutionContexts/10.1.8-2.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/ExecutionContexts/10.1.8-3.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/ExecutionContexts/10.2.1.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/ExecutionContexts/10.2.2-1.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/ExecutionContexts/10.2.2-2.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/ExecutionContexts/10.2.3-1.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/ExecutionContexts/10.2.3-2.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/ExecutionContexts/browser.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/ExecutionContexts/shell.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Expressions/11.1.1.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Expressions/11.10-1.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Expressions/11.10-2.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Expressions/11.10-3.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Expressions/11.12-1.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Expressions/11.12-2-n.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Expressions/11.12-3.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Expressions/11.12-4.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Expressions/11.13.1.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Expressions/11.13.2-1.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Expressions/11.13.2-2.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Expressions/11.13.2-3.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Expressions/11.13.2-4.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Expressions/11.13.2-5.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Expressions/11.13.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Expressions/11.14-1.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Expressions/11.2.1-1.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Expressions/11.2.1-2.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Expressions/11.2.1-3-n.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Expressions/11.2.1-4-n.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Expressions/11.2.1-5.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Expressions/11.2.2-1-n.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Expressions/11.2.2-1.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Expressions/11.2.2-10-n.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Expressions/11.2.2-11.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Expressions/11.2.2-2-n.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Expressions/11.2.2-3-n.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Expressions/11.2.2-4-n.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Expressions/11.2.2-5-n.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Expressions/11.2.2-6-n.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Expressions/11.2.2-7-n.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Expressions/11.2.2-8-n.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Expressions/11.2.2-9-n.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Expressions/11.2.3-1.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Expressions/11.2.3-2-n.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Expressions/11.2.3-3-n.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Expressions/11.2.3-4-n.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Expressions/11.2.3-5.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Expressions/11.3.1.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Expressions/11.3.2.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Expressions/11.4.1.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Expressions/11.4.2.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Expressions/11.4.3.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Expressions/11.4.4.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Expressions/11.4.5.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Expressions/11.4.6.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Expressions/11.4.7-01.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Expressions/11.4.7-02.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Expressions/11.4.8.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Expressions/11.4.9.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Expressions/11.5.1.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Expressions/11.5.2.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Expressions/11.5.3.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Expressions/11.6.1-1.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Expressions/11.6.1-2.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Expressions/11.6.1-3.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Expressions/11.6.2-1.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Expressions/11.6.3.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Expressions/11.7.1.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Expressions/11.7.2.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Expressions/11.7.3.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Expressions/11.8.1.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Expressions/11.8.2.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Expressions/11.8.3.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Expressions/11.8.4.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Expressions/11.9.1.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Expressions/11.9.2.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Expressions/11.9.3.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Expressions/browser.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Expressions/shell.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/FunctionObjects/15.3.1.1-1.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/FunctionObjects/15.3.1.1-2.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/FunctionObjects/15.3.1.1-3.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/FunctionObjects/15.3.2.1-1.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/FunctionObjects/15.3.2.1-2.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/FunctionObjects/15.3.2.1-3.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/FunctionObjects/15.3.3.1-2.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/FunctionObjects/15.3.3.1-3.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/FunctionObjects/15.3.3.1-4.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/FunctionObjects/15.3.3.2.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/FunctionObjects/15.3.4-1.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/FunctionObjects/15.3.4.1.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/FunctionObjects/15.3.4.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/FunctionObjects/15.3.5-1.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/FunctionObjects/15.3.5-2.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/FunctionObjects/15.3.5.1.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/FunctionObjects/15.3.5.3.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/FunctionObjects/browser.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/FunctionObjects/shell.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/GlobalObject/15.1-1-n.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/GlobalObject/15.1-2-n.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/GlobalObject/15.1.1.1.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/GlobalObject/15.1.1.2.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/GlobalObject/15.1.2.1-2.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/GlobalObject/15.1.2.2-1.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/GlobalObject/15.1.2.2-2.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/GlobalObject/15.1.2.3-1.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/GlobalObject/15.1.2.3-2.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/GlobalObject/15.1.2.4.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/GlobalObject/15.1.2.5-1.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/GlobalObject/15.1.2.5-2.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/GlobalObject/15.1.2.5-3.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/GlobalObject/15.1.2.6.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/GlobalObject/15.1.2.7.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/GlobalObject/browser.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/GlobalObject/shell.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.1-1.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.1-2.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.1-3.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.2-1.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.2-2-n.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.2-3-n.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.2-4-n.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.2-5-n.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.2-6.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.3-1.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.3-10.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.3-11.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.3-12.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.3-13-n.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.3-2.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.3-3.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.3-4.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.3-5.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.3-6.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.3-7.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.3-8.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.3-9.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.4.1-1-n.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.4.1-2-n.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.4.1-3-n.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.4.2-1-n.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.4.2-10-n.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.4.2-11-n.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.4.2-12-n.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.4.2-13-n.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.4.2-14-n.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.4.2-15-n.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.4.2-16-n.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.4.2-2-n.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.4.2-3-n.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.4.2-4-n.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.4.2-5-n.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.4.2-6-n.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.4.2-7-n.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.4.2-8-n.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.4.2-9-n.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.4.3-1-n.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.4.3-10-n.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.4.3-11-n.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.4.3-12-n.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.4.3-13-n.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.4.3-14-n.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.4.3-15-n.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.4.3-16-n.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.4.3-2-n.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.4.3-3-n.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.4.3-4-n.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.4.3-5-n.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.4.3-6-n.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.4.3-7-n.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.4.3-8-n.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.4.3-9-n.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.5-1.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.5-10-n.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.5-2-n.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.5-3-n.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.5-4-n.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.5-5-n.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.5-6.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.5-7.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.5-8-n.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.5-9-n.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.6.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.7.1.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.7.2.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.7.3-1.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.7.3-2.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.7.3.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.7.4.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.8.2-n.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/browser.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/shell.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Math/15.8-2-n.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Math/15.8-3-n.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Math/15.8.1.1-1.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Math/15.8.1.1-2.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Math/15.8.1.2-1.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Math/15.8.1.2-2.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Math/15.8.1.3-1.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Math/15.8.1.3-2.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Math/15.8.1.4-1.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Math/15.8.1.4-2.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Math/15.8.1.5-1.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Math/15.8.1.5-2.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Math/15.8.1.6-1.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Math/15.8.1.6-2.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Math/15.8.1.7-1.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Math/15.8.1.7-2.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Math/15.8.1.8-1.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Math/15.8.1.8-2.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Math/15.8.1.8-3.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Math/15.8.1.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Math/15.8.2.1.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Math/15.8.2.10.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Math/15.8.2.11.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Math/15.8.2.12.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Math/15.8.2.13.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Math/15.8.2.14.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Math/15.8.2.15.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Math/15.8.2.16.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Math/15.8.2.17.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Math/15.8.2.18.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Math/15.8.2.2.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Math/15.8.2.3.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Math/15.8.2.4.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Math/15.8.2.5.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Math/15.8.2.6.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Math/15.8.2.7.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Math/15.8.2.8.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Math/15.8.2.9.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Math/browser.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Math/shell.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/NativeObjects/browser.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/NativeObjects/shell.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Number/15.7.1.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Number/15.7.2.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Number/15.7.3.1-1.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Number/15.7.3.1-2.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Number/15.7.3.1-3.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Number/15.7.3.2-1.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Number/15.7.3.2-2.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Number/15.7.3.2-3.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Number/15.7.3.2-4.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Number/15.7.3.3-1.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Number/15.7.3.3-2.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Number/15.7.3.3-3.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Number/15.7.3.3-4.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Number/15.7.3.4-1.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Number/15.7.3.4-2.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Number/15.7.3.4-3.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Number/15.7.3.4-4.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Number/15.7.3.5-1.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Number/15.7.3.5-2.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Number/15.7.3.5-3.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Number/15.7.3.5-4.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Number/15.7.3.6-1.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Number/15.7.3.6-2.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Number/15.7.3.6-3.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Number/15.7.3.6-4.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Number/15.7.3.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Number/15.7.4-1.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Number/15.7.4.1.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Number/15.7.4.2-1.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Number/15.7.4.2-2-n.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Number/15.7.4.2-3-n.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Number/15.7.4.2-4.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Number/15.7.4.3-1.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Number/15.7.4.3-2.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Number/15.7.4.3-3-n.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Number/browser.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Number/shell.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/ObjectObjects/15.2.1.1.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/ObjectObjects/15.2.1.2.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/ObjectObjects/15.2.2.1.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/ObjectObjects/15.2.2.2.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/ObjectObjects/15.2.3-1.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/ObjectObjects/15.2.3.1-1.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/ObjectObjects/15.2.3.1-2.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/ObjectObjects/15.2.3.1-3.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/ObjectObjects/15.2.3.1-4.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/ObjectObjects/15.2.3.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/ObjectObjects/15.2.4.1.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/ObjectObjects/15.2.4.2.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/ObjectObjects/15.2.4.3.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/ObjectObjects/browser.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/ObjectObjects/shell.js delete mode 100755 tests/auto/declarative/parserstress/tests/ecma/README delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/SourceText/6-1.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/SourceText/6-2.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/SourceText/browser.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/SourceText/shell.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Statements/12.10-1.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Statements/12.10.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Statements/12.2-1.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Statements/12.5-1.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Statements/12.5-2.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Statements/12.6.1-1.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Statements/12.6.2-1.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Statements/12.6.2-2.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Statements/12.6.2-3.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Statements/12.6.2-4.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Statements/12.6.2-5.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Statements/12.6.2-6.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Statements/12.6.2-7.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Statements/12.6.2-8.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Statements/12.6.2-9-n.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Statements/12.6.3-1.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Statements/12.6.3-10.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Statements/12.6.3-11.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Statements/12.6.3-12.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Statements/12.6.3-19.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Statements/12.6.3-2.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Statements/12.6.3-3.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Statements/12.6.3-4.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Statements/12.6.3-5-n.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Statements/12.6.3-6-n.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Statements/12.6.3-7-n.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Statements/12.6.3-8-n.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Statements/12.6.3-9-n.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Statements/12.7-1-n.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Statements/12.8-1-n.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Statements/12.9-1-n.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Statements/browser.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Statements/shell.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/String/15.5.1.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/String/15.5.2.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/String/15.5.3.1-1.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/String/15.5.3.1-2.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/String/15.5.3.1-3.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/String/15.5.3.1-4.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/String/15.5.3.2-1.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/String/15.5.3.2-2.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/String/15.5.3.2-3.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/String/15.5.3.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/String/15.5.4.1.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/String/15.5.4.10-1.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/String/15.5.4.11-1.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/String/15.5.4.11-2.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/String/15.5.4.11-3.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/String/15.5.4.11-4.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/String/15.5.4.11-5.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/String/15.5.4.11-6.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/String/15.5.4.12-1.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/String/15.5.4.12-2.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/String/15.5.4.12-3.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/String/15.5.4.12-4.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/String/15.5.4.12-5.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/String/15.5.4.2-1.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/String/15.5.4.2-2-n.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/String/15.5.4.2-3.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/String/15.5.4.2.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/String/15.5.4.3-1.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/String/15.5.4.3-2.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/String/15.5.4.3-3-n.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/String/15.5.4.4-1.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/String/15.5.4.4-2.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/String/15.5.4.4-3.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/String/15.5.4.4-4.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/String/15.5.4.5-1.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/String/15.5.4.5-2.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/String/15.5.4.5-3.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/String/15.5.4.5-4.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/String/15.5.4.5-5.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/String/15.5.4.6-1.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/String/15.5.4.6-2.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/String/15.5.4.7-1.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/String/15.5.4.7-2.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/String/15.5.4.8-1.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/String/15.5.4.8-2.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/String/15.5.4.8-3.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/String/15.5.4.9-1.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/String/15.5.4.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/String/15.5.5.1.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/String/browser.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/String/shell.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/TypeConversion/9.2.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/TypeConversion/9.3-1.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/TypeConversion/9.3.1-1.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/TypeConversion/9.3.1-2.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/TypeConversion/9.3.1-3.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/TypeConversion/9.3.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/TypeConversion/9.4-1.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/TypeConversion/9.4-2.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/TypeConversion/9.5-2.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/TypeConversion/9.6.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/TypeConversion/9.7.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/TypeConversion/9.8.1.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/TypeConversion/9.9-1.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/TypeConversion/browser.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/TypeConversion/shell.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Types/8.1.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Types/8.4.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Types/8.6.2.1-1.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Types/browser.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/Types/shell.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/browser.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/extensions/10.1.4-9.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/extensions/10.1.6.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/extensions/10.1.8-1.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/extensions/11.6.1-1.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/extensions/11.6.1-2.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/extensions/11.6.1-3.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/extensions/11.6.2-1.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/extensions/15-1.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/extensions/15-2.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/extensions/15.1.2.1-1.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/extensions/15.2.1.1.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/extensions/15.2.3-1.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/extensions/15.2.4.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/extensions/15.3.1.1-1.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/extensions/15.3.1.1-2.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/extensions/15.3.2.1-1.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/extensions/15.3.2.1-2.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/extensions/15.3.3.1-1.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/extensions/15.4.3.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/extensions/15.5.3.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/extensions/15.5.4.2.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/extensions/15.5.4.4-4.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/extensions/15.5.4.5-6.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/extensions/15.5.4.7-3.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/extensions/15.6.3.1-5.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/extensions/15.6.3.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/extensions/15.6.4-2.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/extensions/15.7.3.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/extensions/15.7.4.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/extensions/15.8-1.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/extensions/15.9.5.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/extensions/8.6.2.1-1.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/extensions/9.9-1.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/extensions/browser.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/extensions/shell.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/jsref.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/shell.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma/template.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/boolean-001.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/boolean-002.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/browser.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/date-001.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/date-002.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/date-003.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/date-004.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/exception-001.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/exception-002.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/exception-003.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/exception-004.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/exception-005.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/exception-006.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/exception-007.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/exception-008.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/exception-009.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/exception-010-n.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/exception-011-n.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/expression-001.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/expression-002.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/expression-003.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/expression-004.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/expression-005.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/expression-006.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/expression-007.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/expression-008.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/expression-009.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/expression-010.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/expression-011.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/expression-012.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/expression-013.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/expression-014.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/expression-015.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/expression-016.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/expression-017.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/expression-019.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/function-001.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/global-001.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/global-002.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-001.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-002.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-003.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-004.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-005.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-006.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-007.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-008.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-009.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-010.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-011.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-012.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-013.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-014.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-015.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-016.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-017.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-018.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-019.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-020.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-021.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-022.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-023.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-024.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-025.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-026.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-027.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-028.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-029.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-030.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-031.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-032.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-033.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-034.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-035.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-036.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-037.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-038.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-039.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-040.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-041.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-042.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-047.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-048.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-049.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-050.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-051.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-052.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-053.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-054.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/number-001.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/number-002.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/number-003.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/shell.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/statement-001.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/statement-002.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/statement-003.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/statement-004.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/statement-005.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/statement-006.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/statement-007.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/statement-008.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/statement-009.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/string-001.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/string-002.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_2/Expressions/StrictEquality-001.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_2/Expressions/browser.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_2/Expressions/shell.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_2/FunctionObjects/apply-001-n.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_2/FunctionObjects/browser.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_2/FunctionObjects/call-1.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_2/FunctionObjects/shell.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_2/LexicalConventions/browser.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_2/LexicalConventions/keywords-001.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_2/LexicalConventions/regexp-literals-001.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_2/LexicalConventions/regexp-literals-002.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_2/LexicalConventions/shell.js delete mode 100755 tests/auto/declarative/parserstress/tests/ecma_2/README delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_2/RegExp/browser.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_2/RegExp/constructor-001.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_2/RegExp/exec-001.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_2/RegExp/exec-002.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_2/RegExp/function-001.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_2/RegExp/hex-001.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_2/RegExp/multiline-001.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_2/RegExp/octal-001.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_2/RegExp/octal-002.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_2/RegExp/octal-003.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_2/RegExp/properties-001.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_2/RegExp/properties-002.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_2/RegExp/regexp-enumerate-001.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_2/RegExp/regress-001.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_2/RegExp/shell.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_2/RegExp/unicode-001.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_2/Statements/browser.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_2/Statements/dowhile-001.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_2/Statements/dowhile-002.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_2/Statements/dowhile-003.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_2/Statements/dowhile-004.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_2/Statements/dowhile-005.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_2/Statements/dowhile-006.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_2/Statements/dowhile-007.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_2/Statements/forin-001.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_2/Statements/forin-002.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_2/Statements/if-001.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_2/Statements/label-001.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_2/Statements/label-002.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_2/Statements/shell.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_2/Statements/switch-001.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_2/Statements/switch-002.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_2/Statements/switch-003.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_2/Statements/switch-004.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_2/Statements/try-001.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_2/Statements/try-003.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_2/Statements/try-004.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_2/Statements/try-005.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_2/Statements/try-006.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_2/Statements/try-007.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_2/Statements/try-008.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_2/Statements/try-009.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_2/Statements/try-010.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_2/Statements/try-012.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_2/Statements/while-001.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_2/Statements/while-002.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_2/Statements/while-003.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_2/Statements/while-004.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_2/String/browser.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_2/String/match-001.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_2/String/match-002.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_2/String/match-003.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_2/String/match-004.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_2/String/replace-001.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_2/String/shell.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_2/String/split-001.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_2/String/split-002.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_2/String/split-003.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_2/browser.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_2/extensions/browser.js delete mode 100755 tests/auto/declarative/parserstress/tests/ecma_2/extensions/constructor-001.js delete mode 100755 tests/auto/declarative/parserstress/tests/ecma_2/extensions/function-001.js delete mode 100755 tests/auto/declarative/parserstress/tests/ecma_2/extensions/instanceof-001.js delete mode 100755 tests/auto/declarative/parserstress/tests/ecma_2/extensions/instanceof-002.js delete mode 100755 tests/auto/declarative/parserstress/tests/ecma_2/extensions/instanceof-003-n.js delete mode 100755 tests/auto/declarative/parserstress/tests/ecma_2/extensions/instanceof-004-n.js delete mode 100755 tests/auto/declarative/parserstress/tests/ecma_2/extensions/instanceof-005-n.js delete mode 100755 tests/auto/declarative/parserstress/tests/ecma_2/extensions/instanceof-006.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_2/extensions/shell.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_2/instanceof/browser.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_2/instanceof/instanceof-001.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_2/instanceof/instanceof-002.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_2/instanceof/instanceof-003.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_2/instanceof/regress-7635.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_2/instanceof/shell.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_2/jsref.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_2/shell.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_2/template.js delete mode 100755 tests/auto/declarative/parserstress/tests/ecma_3/Array/15.4.4.11-01.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_3/Array/15.4.4.3-1.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_3/Array/15.4.4.4-001.js delete mode 100755 tests/auto/declarative/parserstress/tests/ecma_3/Array/15.4.5.1-01.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_3/Array/browser.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_3/Array/regress-101488.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_3/Array/regress-130451.js delete mode 100755 tests/auto/declarative/parserstress/tests/ecma_3/Array/regress-322135-01.js delete mode 100755 tests/auto/declarative/parserstress/tests/ecma_3/Array/regress-322135-02.js delete mode 100755 tests/auto/declarative/parserstress/tests/ecma_3/Array/regress-322135-03.js delete mode 100755 tests/auto/declarative/parserstress/tests/ecma_3/Array/regress-322135-04.js delete mode 100755 tests/auto/declarative/parserstress/tests/ecma_3/Array/regress-387501.js delete mode 100755 tests/auto/declarative/parserstress/tests/ecma_3/Array/regress-421325.js delete mode 100755 tests/auto/declarative/parserstress/tests/ecma_3/Array/regress-430717.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_3/Array/shell.js delete mode 100755 tests/auto/declarative/parserstress/tests/ecma_3/Date/15.9.1.2-01.js delete mode 100755 tests/auto/declarative/parserstress/tests/ecma_3/Date/15.9.3.2-1.js delete mode 100755 tests/auto/declarative/parserstress/tests/ecma_3/Date/15.9.4.3.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_3/Date/15.9.5.3.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_3/Date/15.9.5.4.js delete mode 100755 tests/auto/declarative/parserstress/tests/ecma_3/Date/15.9.5.5-02.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_3/Date/15.9.5.5.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_3/Date/15.9.5.6.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_3/Date/15.9.5.7.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_3/Date/browser.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_3/Date/shell.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_3/Exceptions/15.11.1.1.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_3/Exceptions/15.11.4.4-1.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_3/Exceptions/15.11.7.6-001.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_3/Exceptions/15.11.7.6-002.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_3/Exceptions/15.11.7.6-003.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_3/Exceptions/binding-001.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_3/Exceptions/browser.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_3/Exceptions/regress-181654.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_3/Exceptions/regress-181914.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_3/Exceptions/regress-58946.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_3/Exceptions/regress-95101.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_3/Exceptions/shell.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_3/ExecutionContexts/10.1.3-1.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_3/ExecutionContexts/10.1.3-2.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_3/ExecutionContexts/10.1.3.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_3/ExecutionContexts/10.1.4-1.js delete mode 100755 tests/auto/declarative/parserstress/tests/ecma_3/ExecutionContexts/10.6.1-01.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_3/ExecutionContexts/browser.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_3/ExecutionContexts/regress-23346.js delete mode 100755 tests/auto/declarative/parserstress/tests/ecma_3/ExecutionContexts/regress-448595-01.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_3/ExecutionContexts/shell.js delete mode 100755 tests/auto/declarative/parserstress/tests/ecma_3/Expressions/11.10-01.js delete mode 100755 tests/auto/declarative/parserstress/tests/ecma_3/Expressions/11.10-02.js delete mode 100755 tests/auto/declarative/parserstress/tests/ecma_3/Expressions/11.10-03.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_3/Expressions/11.6.1-1.js delete mode 100755 tests/auto/declarative/parserstress/tests/ecma_3/Expressions/11.7.1-01.js delete mode 100755 tests/auto/declarative/parserstress/tests/ecma_3/Expressions/11.7.2-01.js delete mode 100755 tests/auto/declarative/parserstress/tests/ecma_3/Expressions/11.7.3-01.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_3/Expressions/11.9.6-1.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_3/Expressions/browser.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_3/Expressions/shell.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_3/FunExpr/browser.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_3/FunExpr/fe-001-n.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_3/FunExpr/fe-001.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_3/FunExpr/fe-002.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_3/FunExpr/shell.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_3/Function/15.3.4.3-1.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_3/Function/15.3.4.4-1.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_3/Function/arguments-001.js delete mode 100755 tests/auto/declarative/parserstress/tests/ecma_3/Function/arguments-002.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_3/Function/browser.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_3/Function/call-001.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_3/Function/regress-131964.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_3/Function/regress-137181.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_3/Function/regress-193555.js delete mode 100755 tests/auto/declarative/parserstress/tests/ecma_3/Function/regress-313570.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_3/Function/regress-49286.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_3/Function/regress-58274.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_3/Function/regress-85880.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_3/Function/regress-94506.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_3/Function/regress-97921.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_3/Function/scope-001.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_3/Function/scope-002.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_3/Function/shell.js delete mode 100755 tests/auto/declarative/parserstress/tests/ecma_3/LexicalConventions/7.9.1.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_3/LexicalConventions/browser.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_3/LexicalConventions/shell.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_3/Number/15.7.4.2-01.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_3/Number/15.7.4.3-01.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_3/Number/15.7.4.3-02.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_3/Number/15.7.4.5-1.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_3/Number/15.7.4.6-1.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_3/Number/15.7.4.7-1.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_3/Number/15.7.4.7-2.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_3/Number/browser.js delete mode 100755 tests/auto/declarative/parserstress/tests/ecma_3/Number/regress-442242-01.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_3/Number/shell.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_3/NumberFormatting/browser.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_3/NumberFormatting/shell.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_3/NumberFormatting/tostring-001.js delete mode 100755 tests/auto/declarative/parserstress/tests/ecma_3/Object/8.6.1-01.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_3/Object/8.6.2.6-001.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_3/Object/browser.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_3/Object/class-001.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_3/Object/class-002.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_3/Object/class-003.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_3/Object/class-004.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_3/Object/class-005.js delete mode 100755 tests/auto/declarative/parserstress/tests/ecma_3/Object/regress-361274.js delete mode 100755 tests/auto/declarative/parserstress/tests/ecma_3/Object/regress-385393-07.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_3/Object/regress-72773.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_3/Object/regress-79129-001.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_3/Object/shell.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_3/Operators/11.13.1-001.js delete mode 100755 tests/auto/declarative/parserstress/tests/ecma_3/Operators/11.13.1-002.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_3/Operators/11.4.1-001.js delete mode 100755 tests/auto/declarative/parserstress/tests/ecma_3/Operators/11.4.1-002.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_3/Operators/browser.js delete mode 100755 tests/auto/declarative/parserstress/tests/ecma_3/Operators/order-01.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_3/Operators/shell.js delete mode 100755 tests/auto/declarative/parserstress/tests/ecma_3/README delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_3/RegExp/15.10.2-1.js delete mode 100755 tests/auto/declarative/parserstress/tests/ecma_3/RegExp/15.10.2.12.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_3/RegExp/15.10.3.1-1.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_3/RegExp/15.10.3.1-2.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_3/RegExp/15.10.4.1-1.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_3/RegExp/15.10.4.1-2.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_3/RegExp/15.10.4.1-3.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_3/RegExp/15.10.4.1-4.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_3/RegExp/15.10.4.1-5-n.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_3/RegExp/15.10.6.2-1.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_3/RegExp/15.10.6.2-2.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_3/RegExp/browser.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_3/RegExp/octal-001.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_3/RegExp/octal-002.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_3/RegExp/perlstress-001.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_3/RegExp/perlstress-002.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-100199.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-105972.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-119909.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-122076.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-123437.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-165353.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-169497.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-169534.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-187133.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-188206.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-191479.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-202564.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-209067.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-209919.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-216591.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-220367-001.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-223273.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-223535.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-224676.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-225289.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-225343.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-24712.js delete mode 100755 tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-285219.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-28686.js delete mode 100755 tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-289669.js delete mode 100755 tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-307456.js delete mode 100755 tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-309840.js delete mode 100755 tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-311414.js delete mode 100755 tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-312351.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-31316.js delete mode 100755 tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-330684.js delete mode 100755 tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-334158.js delete mode 100755 tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-346090.js delete mode 100755 tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-367888.js delete mode 100755 tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-375642.js delete mode 100755 tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-375711.js delete mode 100755 tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-375715-01-n.js delete mode 100755 tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-375715-02.js delete mode 100755 tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-375715-03.js delete mode 100755 tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-375715-04.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-57572.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-57631.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-67773.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-72964.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-76683.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-78156.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-85721.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-87231.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-98306.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_3/RegExp/shell.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_3/Regress/browser.js delete mode 100755 tests/auto/declarative/parserstress/tests/ecma_3/Regress/regress-385393-04.js delete mode 100755 tests/auto/declarative/parserstress/tests/ecma_3/Regress/regress-419152.js delete mode 100755 tests/auto/declarative/parserstress/tests/ecma_3/Regress/regress-420087.js delete mode 100755 tests/auto/declarative/parserstress/tests/ecma_3/Regress/regress-420610.js delete mode 100755 tests/auto/declarative/parserstress/tests/ecma_3/Regress/regress-441477-01.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_3/Regress/shell.js delete mode 100755 tests/auto/declarative/parserstress/tests/ecma_3/Statements/12.6.3.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_3/Statements/browser.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_3/Statements/regress-121744.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_3/Statements/regress-131348.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_3/Statements/regress-157509.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_3/Statements/regress-194364.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_3/Statements/regress-226517.js delete mode 100755 tests/auto/declarative/parserstress/tests/ecma_3/Statements/regress-302439.js delete mode 100755 tests/auto/declarative/parserstress/tests/ecma_3/Statements/regress-324650.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_3/Statements/regress-74474-001.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_3/Statements/regress-74474-002.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_3/Statements/regress-74474-003.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_3/Statements/regress-83532-001.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_3/Statements/regress-83532-002.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_3/Statements/shell.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_3/Statements/switch-001.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_3/String/15.5.4.11.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_3/String/15.5.4.14.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_3/String/browser.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_3/String/regress-104375.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_3/String/regress-189898.js delete mode 100755 tests/auto/declarative/parserstress/tests/ecma_3/String/regress-304376.js delete mode 100755 tests/auto/declarative/parserstress/tests/ecma_3/String/regress-313567.js delete mode 100755 tests/auto/declarative/parserstress/tests/ecma_3/String/regress-392378.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_3/String/regress-83293.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_3/String/shell.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_3/Unicode/browser.js delete mode 100755 tests/auto/declarative/parserstress/tests/ecma_3/Unicode/regress-352044-01.js delete mode 100755 tests/auto/declarative/parserstress/tests/ecma_3/Unicode/regress-352044-02-n.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_3/Unicode/shell.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_3/Unicode/uc-001-n.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_3/Unicode/uc-001.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_3/Unicode/uc-002-n.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_3/Unicode/uc-002.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_3/Unicode/uc-003.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_3/Unicode/uc-004.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_3/Unicode/uc-005.js delete mode 100755 tests/auto/declarative/parserstress/tests/ecma_3/browser.js delete mode 100755 tests/auto/declarative/parserstress/tests/ecma_3/extensions/10.1.3-2.js delete mode 100755 tests/auto/declarative/parserstress/tests/ecma_3/extensions/7.9.1.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_3/extensions/browser.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_3/extensions/regress-103087.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_3/extensions/regress-188206-01.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_3/extensions/regress-188206-02.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_3/extensions/regress-220367-002.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_3/extensions/regress-228087.js delete mode 100755 tests/auto/declarative/parserstress/tests/ecma_3/extensions/regress-274152.js delete mode 100755 tests/auto/declarative/parserstress/tests/ecma_3/extensions/regress-320854.js delete mode 100755 tests/auto/declarative/parserstress/tests/ecma_3/extensions/regress-327170.js delete mode 100755 tests/auto/declarative/parserstress/tests/ecma_3/extensions/regress-368516.js delete mode 100755 tests/auto/declarative/parserstress/tests/ecma_3/extensions/regress-385393-03.js delete mode 100755 tests/auto/declarative/parserstress/tests/ecma_3/extensions/regress-429248.js delete mode 100755 tests/auto/declarative/parserstress/tests/ecma_3/extensions/regress-430740.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_3/extensions/shell.js delete mode 100644 tests/auto/declarative/parserstress/tests/ecma_3/shell.js delete mode 100755 tests/auto/declarative/parserstress/tests/ecma_3/template.js delete mode 100644 tests/auto/declarative/parserstress/tests/shell.js delete mode 100644 tests/auto/declarative/parserstress/tst_parserstress.cpp delete mode 100644 tests/auto/declarative/qdeclarativebinding/data/deletedObject.qml delete mode 100644 tests/auto/declarative/qdeclarativebinding/data/restoreBinding.qml delete mode 100644 tests/auto/declarative/qdeclarativebinding/data/restoreBindingWithLoop.qml delete mode 100644 tests/auto/declarative/qdeclarativebinding/data/test-binding.qml delete mode 100644 tests/auto/declarative/qdeclarativebinding/data/test-binding2.qml delete mode 100644 tests/auto/declarative/qdeclarativebinding/qdeclarativebinding.pro delete mode 100644 tests/auto/declarative/qdeclarativebinding/tst_qdeclarativebinding.cpp delete mode 100644 tests/auto/declarative/qdeclarativechangeset/qdeclarativechangeset.pro delete mode 100644 tests/auto/declarative/qdeclarativechangeset/tst_qdeclarativechangeset.cpp delete mode 100644 tests/auto/declarative/qdeclarativecomponent/data/createObject.qml delete mode 100644 tests/auto/declarative/qdeclarativecomponent/data/createObjectWithScript.qml delete mode 100644 tests/auto/declarative/qdeclarativecomponent/data/incubateObject.qml delete mode 100644 tests/auto/declarative/qdeclarativecomponent/qdeclarativecomponent.pro delete mode 100644 tests/auto/declarative/qdeclarativecomponent/tst_qdeclarativecomponent.cpp delete mode 100644 tests/auto/declarative/qdeclarativeconnection/data/connection-targetchange.qml delete mode 100644 tests/auto/declarative/qdeclarativeconnection/data/connection-unknownsignals-ignored.qml delete mode 100644 tests/auto/declarative/qdeclarativeconnection/data/connection-unknownsignals-notarget.qml delete mode 100644 tests/auto/declarative/qdeclarativeconnection/data/connection-unknownsignals-parent.qml delete mode 100644 tests/auto/declarative/qdeclarativeconnection/data/connection-unknownsignals.qml delete mode 100644 tests/auto/declarative/qdeclarativeconnection/data/error-object.qml delete mode 100644 tests/auto/declarative/qdeclarativeconnection/data/error-property.qml delete mode 100644 tests/auto/declarative/qdeclarativeconnection/data/error-property2.qml delete mode 100644 tests/auto/declarative/qdeclarativeconnection/data/error-syntax.qml delete mode 100644 tests/auto/declarative/qdeclarativeconnection/data/moduleapi-target.qml delete mode 100644 tests/auto/declarative/qdeclarativeconnection/data/test-connection.qml delete mode 100644 tests/auto/declarative/qdeclarativeconnection/data/test-connection2.qml delete mode 100644 tests/auto/declarative/qdeclarativeconnection/data/test-connection3.qml delete mode 100644 tests/auto/declarative/qdeclarativeconnection/data/trimming.qml delete mode 100644 tests/auto/declarative/qdeclarativeconnection/qdeclarativeconnection.pro delete mode 100644 tests/auto/declarative/qdeclarativeconnection/tst_qdeclarativeconnection.cpp delete mode 100644 tests/auto/declarative/qdeclarativeconsole/data/assert.qml delete mode 100644 tests/auto/declarative/qdeclarativeconsole/data/exception.qml delete mode 100644 tests/auto/declarative/qdeclarativeconsole/data/logging.qml delete mode 100644 tests/auto/declarative/qdeclarativeconsole/data/profiling.qml delete mode 100644 tests/auto/declarative/qdeclarativeconsole/data/tracing.qml delete mode 100644 tests/auto/declarative/qdeclarativeconsole/qdeclarativeconsole.pro delete mode 100644 tests/auto/declarative/qdeclarativeconsole/tst_qdeclarativeconsole.cpp delete mode 100644 tests/auto/declarative/qdeclarativecontext/data/Object_22535.qml delete mode 100644 tests/auto/declarative/qdeclarativecontext/data/RefreshExpressionsType.qml delete mode 100644 tests/auto/declarative/qdeclarativecontext/data/qtbug_22535.qml delete mode 100644 tests/auto/declarative/qdeclarativecontext/data/refreshExpressions.qml delete mode 100644 tests/auto/declarative/qdeclarativecontext/data/refreshExpressionsRootContext.qml delete mode 100644 tests/auto/declarative/qdeclarativecontext/qdeclarativecontext.pro delete mode 100644 tests/auto/declarative/qdeclarativecontext/tst_qdeclarativecontext.cpp delete mode 100644 tests/auto/declarative/qdeclarativecpputils/qdeclarativecpputils.pro delete mode 100644 tests/auto/declarative/qdeclarativecpputils/tst_qdeclarativecpputils.cpp delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/AliasBindingsAssignCorrectlyType.qml delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/AliasBindingsOverrideTargetType.qml delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/AliasBindingsOverrideTargetType3.qml delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/AliasToCompositeElementType1.qml delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/AliasToCompositeElementType2.qml delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/ConstantsOverrideBindings.qml delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/CustomObject.qml delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/ElementAssignType.qml delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/MethodsObject.qml delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/NestedTypeTransientErrors.qml delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/PropertyVarBaseItem.qml delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/PropertyVarCircularComponent.qml delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/PropertyVarCircularComponent2.qml delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/PropertyVarCircularComponent3.qml delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/PropertyVarCircularComponent4.qml delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/PropertyVarCircularComponent5.qml delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/PropertyVarInheritanceComponent.qml delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/PropertyVarOwnershipComponent.qml delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/ScarceResourceSignalComponentVar.qml delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/ScarceResourceSignalComponentVariant.qml delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/ScarceResourceVarComponent.qml delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/Scope6Nested.qml delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/ScopeObject.qml delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/SequenceConversionComponent.qml delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/SpuriousWarning.qml delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/TypeForDynamicCreation.qml delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/aliasBindingsAssignCorrectly.qml delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/aliasBindingsOverrideTarget.2.qml delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/aliasBindingsOverrideTarget.3.qml delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/aliasBindingsOverrideTarget.qml delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/aliasPropertyAndBinding.qml delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/aliasToCompositeElement.qml delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/aliasWritesOverrideBindings.2.qml delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/aliasWritesOverrideBindings.3.qml delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/aliasWritesOverrideBindings.qml delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/aliasreset/AliasPropertyComponent.qml delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/aliasreset/aliasPropertyReset.1.qml delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/aliasreset/aliasPropertyReset.2.qml delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/aliasreset/aliasPropertyReset.3.qml delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/aliasreset/aliasPropertyReset.4.qml delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/aliasreset/aliasPropertyReset.5.qml delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/aliasreset/aliasPropertyReset.error.1.qml delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/assignBasicTypes.2.qml delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/assignBasicTypes.qml delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/assignSequenceTypes.1.qml delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/assignSequenceTypes.2.qml delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/assignSequenceTypes.3.qml delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/assignSequenceTypes.4.qml delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/assignSequenceTypes.5.qml delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/assignSequenceTypes.6.qml delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/assignSequenceTypes.7.qml delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/attachedProperty.2.qml delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/attachedProperty.qml delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/attachedPropertyScope.qml delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/automaticSemicolon.qml delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/bindingLoop.qml delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/blank.js delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/boolPropertiesEvaluateAsBool.1.qml delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/boolPropertiesEvaluateAsBool.2.qml delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/booleanConversion.qml delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/bug.1.qml delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/canAssignNullToQObject.1.qml delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/canAssignNullToQObject.2.qml delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/changeslots/propertyChangeSlotErrors.1.qml delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/changeslots/propertyChangeSlotErrors.2.qml delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/changeslots/propertyChangeSlotErrors.3.qml delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/changeslots/propertyChangeSlotErrors.4.qml delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/changeslots/propertyChangeSlots.qml delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/compiled.qml delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/compositePropertyType.qml delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/constantsOverrideBindings.1.qml delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/constantsOverrideBindings.2.qml delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/constantsOverrideBindings.3.qml delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/constantsOverrideBindings.4.qml delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/declarativeHasOwnProperty.qml delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/declarativeToString.qml delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/deferredProperties.qml delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/deferredPropertiesErrors.qml delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/deleteLater.qml delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/deleteWhileBindingRunning.qml delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/deletedEngine.qml delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/deletedObject.qml delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/doubleEvaluate.qml delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/dynamicCreation.helper.qml delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/dynamicCreation.qml delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/dynamicCreationOwnership.qml delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/dynamicDeletion.2.qml delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/dynamicDeletion.qml delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/dynamicString.qml delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/elementAssign.qml delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/enums.1.qml delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/enums.2.qml delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/eval.qml delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/exception.js delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/exceptionClearsOnReeval.qml delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/exceptionProducesWarning.qml delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/exceptionProducesWarning2.qml delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/extendedObjectPropertyLookup.qml delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/extendedObjectPropertyLookup2.qml delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/extensionObjects.qml delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/extensionObjectsPropertyOverride.qml delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/forInLoop.qml delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/function.qml delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/functionAssignment.1.qml delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/functionAssignment.2.qml delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/functionAssignment.js delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/functionErrors.qml delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/handleReferenceManagement.handle.1.qml delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/handleReferenceManagement.handle.2.qml delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/handleReferenceManagement.object.1.qml delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/handleReferenceManagement.object.2.qml delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/idShortcutInvalidates.1.qml delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/idShortcutInvalidates.qml delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/importScope.1.js delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/importScope.2.js delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/importScope.qml delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/in.qml delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/include.js delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/include.qml delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/include_callback.js delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/include_callback.qml delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/include_pragma.qml delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/include_pragma_inner.js delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/include_pragma_outer.js delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/include_remote.js delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/include_remote.qml delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/include_remote_missing.js delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/include_remote_missing.qml delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/include_shared.js delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/include_shared.qml delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/invokableObjectArg.qml delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/invokableObjectRet.qml delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/js/include2.js delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/js/include3.js delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/jsObject.qml delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/jsimport/SpecialRectangleOne.qml delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/jsimport/SpecialRectangleTwo.qml delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/jsimport/importFive.js delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/jsimport/importFour.js delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/jsimport/importOne.js delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/jsimport/importPragmaLibrary.js delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/jsimport/importPragmaLibraryWithImports.js delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/jsimport/importPragmaLibraryWithPragmaLibraryImports.js delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/jsimport/importThree.js delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/jsimport/importTwo.js delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/jsimport/importWithNoImports.js delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/jsimport/testImport.qml delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/jsimport/testImportPragmaLibrary.qml delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/jsimport/testImportPragmaLibraryWithImports.qml delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/jsimport/testImportPragmaLibraryWithPragmaLibraryImports.qml delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/jsimport/testImportScoping.qml delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/jsimport/testModuleImport.js delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/jsimport/testScriptImport.js delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/jsimportfail/failFive.qml delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/jsimportfail/failFour.qml delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/jsimportfail/failOne.qml delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/jsimportfail/failThree.qml delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/jsimportfail/failTwo.qml delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/jsimportfail/importOne.js delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/jsimportfail/importPragmaLibrary.js delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/jsimportfail/importWithImports.js delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/jsimportfail/testImportPragmaLibrary.qml delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/jsimportfail/testModuleImport.js delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/jsimportfail/testScriptImport.js delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/libraryScriptAssert.js delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/libraryScriptAssert.qml delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/listAssignment.qml delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/listProperties.qml delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/listToVariant.qml delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/metaobjectRevision.qml delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/metaobjectRevision2.qml delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/metaobjectRevision3.qml delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/metaobjectRevision4.qml delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/metaobjectRevisionErrors.qml delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/metaobjectRevisionErrors2.qml delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/metaobjectRevisionErrors3.qml delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/methods.1.qml delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/methods.2.qml delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/methods.3.qml delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/methods.4.qml delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/methods.5.qml delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/moduleapi/moduleApiMajorVersionFail.qml delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/moduleapi/moduleApiMinorVersionFail.qml delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/moduleapi/qobjectModuleApi.qml delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/moduleapi/qobjectModuleApiCaching.qml delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/moduleapi/qobjectModuleApiEnums.qml delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/moduleapi/qobjectModuleApiWriting.qml delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/moduleapi/scriptModuleApi.qml delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/moduleapi/scriptModuleApiCaching.qml delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/moduleapi/scriptModuleApiWriting.qml delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/multiEngineObject.qml delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/noSpuriousWarningsAtShutdown.2.qml delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/noSpuriousWarningsAtShutdown.qml delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/nonExistentAttachedObject.qml delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/nonNotifyable.qml delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/nonscriptable.qml delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/nullObjectBinding.qml delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/numberAssignment.qml delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/objectConversion.qml delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/objectName.qml delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/objectsCompareAsEqual.qml delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/objectsPassThroughSignals.qml delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/outerBindingOverridesInnerBinding.qml delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/ownership.qml delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/propertyAssignmentErrors.qml delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/propertySplicing.qml delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/propertyVar.1.qml delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/propertyVar.10.qml delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/propertyVar.2.qml delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/propertyVar.3.qml delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/propertyVar.4.qml delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/propertyVar.5.qml delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/propertyVar.6.qml delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/propertyVar.7.qml delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/propertyVar.8.qml delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/propertyVar.9.qml delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/propertyVar.circular.2.qml delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/propertyVar.circular.qml delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/propertyVar.inherit.qml delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/propertyVar.reparent.qml delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/propertyVarCpp.qml delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/propertyVarImplicitOwnership.qml delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/propertyVarOwnership.2.qml delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/propertyVarOwnership.3.qml delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/propertyVarOwnership.3.type.qml delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/propertyVarOwnership.4.qml delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/propertyVarOwnership.4.type1.qml delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/propertyVarOwnership.4.type2.qml delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/propertyVarOwnership.qml delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/qlistqobjectMethods.qml delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/qobjectConnectionListExceptionHandling.qml delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/qobjectDerivedArgument.qml delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/qtbug_10696.qml delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/qtbug_11600.js delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/qtbug_11600.qml delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/qtbug_11606.qml delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/qtbug_20344.qml delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/qtbug_21580.qml delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/qtbug_21864.js delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/qtbug_21864.qml delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/qtbug_22464.qml delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/qtbug_22679.qml delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/qtbug_22843.js delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/qtbug_22843.library.js delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/qtbug_22843.library.qml delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/qtbug_22843.qml delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/qtbug_9792.qml delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/qtcreatorbug_1289.qml delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/readonlyDeclaration.qml delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/realToInt.qml delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/regExp.2.qml delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/regExp.qml delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/remote_file.js delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/rewriteMultiLineStrings.qml delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/scarceResourceCopy.var.qml delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/scarceResourceCopy.variant.qml delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/scarceResourceCopyFromJs.var.qml delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/scarceResourceCopyFromJs.variant.qml delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/scarceResourceCopyImport.var.js delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/scarceResourceCopyImport.var.qml delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/scarceResourceCopyImport.variant.js delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/scarceResourceCopyImport.variant.qml delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/scarceResourceCopyImportDifferent.var.js delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/scarceResourceCopyImportDifferent.var.qml delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/scarceResourceCopyImportFail.var.js delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/scarceResourceCopyImportFail.var.qml delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/scarceResourceCopyImportFail.variant.js delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/scarceResourceCopyImportFail.variant.qml delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/scarceResourceCopyImportNoBinding.var.js delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/scarceResourceCopyImportNoBinding.var.qml delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/scarceResourceCopyImportNoBinding.variant.js delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/scarceResourceCopyImportNoBinding.variant.qml delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/scarceResourceCopyNoBinding.var.qml delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/scarceResourceCopyNoBinding.variant.qml delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/scarceResourceDestroyedCopy.var.qml delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/scarceResourceDestroyedCopy.variant.qml delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/scarceResourceFunction.var.qml delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/scarceResourceFunction.variant.qml delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/scarceResourceFunctionFail.var.qml delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/scarceResourceFunctionFail.variant.qml delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/scarceResourceMultipleDifferentNoBinding.var.js delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/scarceResourceMultipleDifferentNoBinding.var.qml delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/scarceResourceMultipleSameNoBinding.var.js delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/scarceResourceMultipleSameNoBinding.var.qml delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/scarceResourceMultipleSameWithBinding.var.qml delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/scarceResourceObjectGc.var.qml delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/scarceResourceSignal.var.qml delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/scarceResourceSignal.variant.qml delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/scarceResourceTest.var.js delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/scarceResourceTest.var.qml delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/scarceResourceTest.variant.js delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/scarceResourceTest.variant.qml delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/scarceResourceTestMultiple.var.qml delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/scarceResourceTestMultiple.variant.qml delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/scarceResourceTestPreserve.var.qml delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/scarceResourceTestPreserve.variant.qml delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/scope.2.qml delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/scope.3.qml delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/scope.4.qml delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/scope.5.qml delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/scope.6.qml delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/scope.qml delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/scriptConnect.1.js delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/scriptConnect.1.qml delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/scriptConnect.2.js delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/scriptConnect.2.qml delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/scriptConnect.3.qml delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/scriptConnect.4.qml delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/scriptConnect.5.qml delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/scriptConnect.6.js delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/scriptConnect.6.qml delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/scriptDisconnect.1.js delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/scriptDisconnect.1.qml delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/scriptDisconnect.2.qml delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/scriptDisconnect.3.qml delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/scriptDisconnect.4.qml delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/scriptErrors.js delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/scriptErrors.qml delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/selfDeletingBinding.2.qml delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/selfDeletingBinding.qml delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/sequenceConversion.array.qml delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/sequenceConversion.bindings.error.qml delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/sequenceConversion.bindings.qml delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/sequenceConversion.copy.qml delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/sequenceConversion.indexes.qml delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/sequenceConversion.read.error.qml delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/sequenceConversion.read.qml delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/sequenceConversion.threads.qml delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/sequenceConversion.write.error.qml delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/sequenceConversion.write.qml delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/sharedAttachedObject.qml delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/shutdownErrors.qml delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/signalAssignment.1.qml delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/signalAssignment.2.qml delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/signalHandlers.qml delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/signalParameterTypes.qml delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/signalTriggeredBindings.qml delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/signalWithJSValueInVariant.qml delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/signalWithQJSValue.qml delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/signalWithUnknownTypes.qml delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/strictlyEquals.qml delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/stringArg.qml delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/switchStatement.1.qml delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/switchStatement.2.qml delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/switchStatement.3.qml delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/switchStatement.4.qml delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/switchStatement.5.qml delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/switchStatement.6.qml delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/threadScript.js delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/transientErrors.2.qml delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/transientErrors.qml delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/tryStatement.1.qml delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/tryStatement.2.qml delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/tryStatement.3.qml delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/tryStatement.4.qml delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/typeOf.js delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/typeOf.qml delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/unaryExpression.qml delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/undefinedResetsProperty.2.qml delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/undefinedResetsProperty.qml delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/urlListProperty.qml delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/urlProperty.1.qml delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/urlProperty.2.qml delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/v8bindingException.qml delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/v8functionException.qml delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/valueTypeFunctions.qml delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/variantsAssignedUndefined.qml delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/withStatement.1.qml delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/writeAttachedProperty.qml delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/writeRemovesBinding.qml delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/qdeclarativeecmascript.pro delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/testtypes.cpp delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/testtypes.h delete mode 100644 tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp delete mode 100644 tests/auto/declarative/qdeclarativeengine/qdeclarativeengine.pro delete mode 100644 tests/auto/declarative/qdeclarativeengine/tst_qdeclarativeengine.cpp delete mode 100644 tests/auto/declarative/qdeclarativeerror/data/test.txt delete mode 100644 tests/auto/declarative/qdeclarativeerror/qdeclarativeerror.pro delete mode 100644 tests/auto/declarative/qdeclarativeerror/tst_qdeclarativeerror.cpp delete mode 100644 tests/auto/declarative/qdeclarativeexpression/data/scriptString.qml delete mode 100644 tests/auto/declarative/qdeclarativeexpression/qdeclarativeexpression.pro delete mode 100644 tests/auto/declarative/qdeclarativeexpression/tst_qdeclarativeexpression.cpp delete mode 100644 tests/auto/declarative/qdeclarativefolderlistmodel/data/basic.qml delete mode 100644 tests/auto/declarative/qdeclarativefolderlistmodel/data/dummy.qml delete mode 100644 tests/auto/declarative/qdeclarativefolderlistmodel/data/resetFiltering.qml delete mode 100644 tests/auto/declarative/qdeclarativefolderlistmodel/data/resetfiltering/innerdir/test2.txt delete mode 100644 tests/auto/declarative/qdeclarativefolderlistmodel/data/resetfiltering/test.txt delete mode 100644 tests/auto/declarative/qdeclarativefolderlistmodel/qdeclarativefolderlistmodel.pro delete mode 100644 tests/auto/declarative/qdeclarativefolderlistmodel/tst_qdeclarativefolderlistmodel.cpp delete mode 100644 tests/auto/declarative/qdeclarativeimageprovider/qdeclarativeimageprovider.pro delete mode 100644 tests/auto/declarative/qdeclarativeimageprovider/tst_qdeclarativeimageprovider.cpp delete mode 100644 tests/auto/declarative/qdeclarativeincubator/data/AsynchronousIfNestedType.qml delete mode 100644 tests/auto/declarative/qdeclarativeincubator/data/asynchronousIfNested.1.qml delete mode 100644 tests/auto/declarative/qdeclarativeincubator/data/asynchronousIfNested.2.qml delete mode 100644 tests/auto/declarative/qdeclarativeincubator/data/asynchronousIfNested.3.qml delete mode 100644 tests/auto/declarative/qdeclarativeincubator/data/chainInCompletion.qml delete mode 100644 tests/auto/declarative/qdeclarativeincubator/data/chainedAsynchronousIfNested.qml delete mode 100644 tests/auto/declarative/qdeclarativeincubator/data/clear.qml delete mode 100644 tests/auto/declarative/qdeclarativeincubator/data/clearDuringCompletion.qml delete mode 100644 tests/auto/declarative/qdeclarativeincubator/data/contextDelete.qml delete mode 100644 tests/auto/declarative/qdeclarativeincubator/data/forceCompletion.qml delete mode 100644 tests/auto/declarative/qdeclarativeincubator/data/nestedComponent.js delete mode 100644 tests/auto/declarative/qdeclarativeincubator/data/nestedComponent.qml delete mode 100644 tests/auto/declarative/qdeclarativeincubator/data/noIncubationController.qml delete mode 100644 tests/auto/declarative/qdeclarativeincubator/data/objectDeleted.errors.txt delete mode 100644 tests/auto/declarative/qdeclarativeincubator/data/objectDeleted.qml delete mode 100644 tests/auto/declarative/qdeclarativeincubator/data/recursiveClear.1.qml delete mode 100644 tests/auto/declarative/qdeclarativeincubator/data/recursiveClear.2.qml delete mode 100644 tests/auto/declarative/qdeclarativeincubator/data/selfDelete.qml delete mode 100644 tests/auto/declarative/qdeclarativeincubator/data/setInitialState.qml delete mode 100644 tests/auto/declarative/qdeclarativeincubator/data/statusChanged.nested.qml delete mode 100644 tests/auto/declarative/qdeclarativeincubator/data/statusChanged.qml delete mode 100644 tests/auto/declarative/qdeclarativeincubator/qdeclarativeincubator.pro delete mode 100644 tests/auto/declarative/qdeclarativeincubator/testtypes.cpp delete mode 100644 tests/auto/declarative/qdeclarativeincubator/testtypes.h delete mode 100644 tests/auto/declarative/qdeclarativeincubator/tst_qdeclarativeincubator.cpp delete mode 100644 tests/auto/declarative/qdeclarativeinfo/data/NestedComponent.qml delete mode 100644 tests/auto/declarative/qdeclarativeinfo/data/NestedObject.qml delete mode 100644 tests/auto/declarative/qdeclarativeinfo/data/nestedQmlObject.qml delete mode 100644 tests/auto/declarative/qdeclarativeinfo/data/qmlObject.qml delete mode 100644 tests/auto/declarative/qdeclarativeinfo/qdeclarativeinfo.pro delete mode 100644 tests/auto/declarative/qdeclarativeinfo/tst_qdeclarativeinfo.cpp delete mode 100644 tests/auto/declarative/qdeclarativeinstruction/qdeclarativeinstruction.pro delete mode 100644 tests/auto/declarative/qdeclarativeinstruction/tst_qdeclarativeinstruction.cpp delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/Alias.qml delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/Alias2.qml delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/Alias3.qml delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/Alias4.qml delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/AliasPropertyChangeSignalsType.qml delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/ComponentComposite.qml delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/CompositeType.qml delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/CompositeType2.qml delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/CompositeType3.qml delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/CompositeType4.qml delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/DontDoubleCallClassBeginItem.qml delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/DynamicPropertiesNestedType.qml delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/HelperAlias.qml delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/I18n.qml delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/I18nType30.qml delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/InlineAssignmentsOverrideBindingsType.qml delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/InlineAssignmentsOverrideBindingsType2.qml delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/LocalLast.qml delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/MyComponent.qml delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/MyCompositeValueSource.qml delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/MyContainerComponent.qml delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/NestedAlias.qml delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/NestedComponentRoot.qml delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/NestedErrorsType.qml delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/OnCompletedType.qml delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/OnDestructionType.qml delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/ReadOnlyType.qml delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/alias.1.qml delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/alias.10.qml delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/alias.11.qml delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/alias.2.qml delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/alias.3.qml delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/alias.4.qml delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/alias.5.qml delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/alias.6.qml delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/alias.7.qml delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/alias.8.qml delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/alias.9.qml delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/aliasPropertiesAndSignals.qml delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/aliasPropertyChangeSignals.2.qml delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/aliasPropertyChangeSignals.qml delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/allowedRevisionOverloads.qml delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/assignBasicTypes.qml delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/assignCompositeToType.qml delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/assignLiteralSignalProperty.qml delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/assignLiteralToVar.qml delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/assignLiteralToVariant.qml delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/assignObjectToSignal.qml delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/assignObjectToVariant.qml delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/assignQmlComponent.qml delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/assignSignal.qml delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/assignToNamespace.errors.txt delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/assignToNamespace.qml delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/assignTypeExtremes.qml delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/assignValueToSignal.errors.txt delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/assignValueToSignal.qml delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/attachedProperties.qml delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/autoComponentCreation.qml delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/autoNotifyConnection.qml delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/component.1.errors.txt delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/component.1.qml delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/component.2.errors.txt delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/component.2.qml delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/component.3.errors.txt delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/component.3.qml delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/component.4.errors.txt delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/component.4.qml delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/component.5.errors.txt delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/component.5.qml delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/component.6.errors.txt delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/component.6.qml delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/component.7.errors.txt delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/component.7.qml delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/component.8.errors.txt delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/component.8.qml delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/component.9.errors.txt delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/component.9.qml delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/componentCompositeType.qml delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/cppnamespace.2.qml delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/cppnamespace.qml delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/crash2.qml delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/customOnProperty.qml delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/customParserIdNotAllowed.errors.txt delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/customParserIdNotAllowed.qml delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/customParserTypes.qml delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/customVariantTypes.qml delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/declaredPropertyValues.qml delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/defaultGrouped.errors.txt delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/defaultGrouped.qml delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/defaultPropertyListOrder.qml delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/destroyedSignal.errors.txt delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/destroyedSignal.qml delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/disallowedRevisionOverloads.errors.txt delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/disallowedRevisionOverloads.qml delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/dontDoubleCallClassBegin.qml delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/doubleSignal.errors.txt delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/doubleSignal.qml delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/duplicateIDs.errors.txt delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/duplicateIDs.qml delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/dynamicMeta.1.errors.txt delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/dynamicMeta.1.qml delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/dynamicMeta.2.errors.txt delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/dynamicMeta.2.qml delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/dynamicMeta.3.errors.txt delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/dynamicMeta.3.qml delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/dynamicMeta.4.errors.txt delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/dynamicMeta.4.qml delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/dynamicMeta.5.errors.txt delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/dynamicMeta.5.qml delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/dynamicObject.1.qml delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/dynamicObjectProperties.2.qml delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/dynamicObjectProperties.qml delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/dynamicProperties.qml delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/dynamicPropertiesNested.qml delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/dynamicSignalsAndSlots.qml delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/empty.errors.txt delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/empty.qml delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/emptySignal.errors.txt delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/emptySignal.qml delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/enumTypes.errors.txt delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/enumTypes.qml delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/failingComponent.errors.txt delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/failingComponentTest.qml delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/fakeDotProperty.errors.txt delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/fakeDotProperty.qml delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/finalOverride.errors.txt delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/finalOverride.qml delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/i18nDeclaredPropertyNames.qml delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/i18nDeclaredPropertyUse.qml delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/i18nNameSpace.qml delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/i18nScript.qml delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/i18nStrings.qml delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/i18nType.qml delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/idProperty.qml delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/importFile.errors.txt delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/importFile.qml delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/importIncorrectCase.qml delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/importJs.1.errors.txt delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/importJs.1.qml delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/importJs.10.errors.txt delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/importJs.10.qml delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/importJs.2.errors.txt delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/importJs.2.qml delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/importJs.3.errors.txt delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/importJs.3.qml delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/importJs.4.errors.txt delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/importJs.4.qml delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/importJs.5.errors.txt delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/importJs.5.qml delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/importJs.6.errors.txt delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/importJs.6.qml delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/importJs.7.errors.txt delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/importJs.7.qml delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/importJs.8.errors.txt delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/importJs.8.qml delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/importJs.9.errors.txt delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/importJs.9.qml delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/importNamespaceConflict.errors.txt delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/importNamespaceConflict.qml delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/importNewerVersion.errors.txt delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/importNewerVersion.qml delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/importNonExist.errors.txt delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/importNonExist.qml delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/importNonExistOlder.errors.txt delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/importNonExistOlder.qml delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/importVersionMissingBuiltIn.errors.txt delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/importVersionMissingBuiltIn.qml delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/importVersionMissingInstalled.errors.txt delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/importVersionMissingInstalled.qml delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/importscript.1.errors.txt delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/importscript.1.qml delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/incorrectCase.errors.insensitive.txt delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/incorrectCase.errors.sensitive.txt delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/incorrectCase.qml delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/incorrectCaseType.qml delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/inlineAssignmentsOverrideBindings.qml delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/inlineQmlComponents.qml delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/insertedSemicolon.1.errors.txt delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/insertedSemicolon.1.qml delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/interfaceProperty.qml delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/interfaceQList.qml delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/invalidAlias.1.errors.txt delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/invalidAlias.1.qml delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/invalidAlias.10.errors.txt delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/invalidAlias.10.qml delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/invalidAlias.2.errors.txt delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/invalidAlias.2.qml delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/invalidAlias.3.errors.txt delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/invalidAlias.3.qml delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/invalidAlias.4.errors.txt delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/invalidAlias.4.qml delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/invalidAlias.5.errors.txt delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/invalidAlias.5.qml delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/invalidAlias.6.errors.txt delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/invalidAlias.6.qml delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/invalidAlias.7.errors.txt delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/invalidAlias.7.qml delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/invalidAlias.8.errors.txt delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/invalidAlias.8.qml delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/invalidAlias.9.errors.txt delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/invalidAlias.9.qml delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.1.errors.txt delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.1.qml delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.10.errors.txt delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.10.qml delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.11.errors.txt delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.11.qml delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.12.errors.txt delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.12.qml delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.13.errors.txt delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.13.qml delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.2.errors.txt delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.2.qml delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.3.errors.txt delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.3.qml delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.4.errors.txt delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.4.qml delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.5.errors.txt delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.5.qml delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.6.errors.txt delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.6.qml delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.7.errors.txt delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.7.qml delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.8.errors.txt delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.8.qml delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.9.errors.txt delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.9.qml delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/invalidGroupedProperty.1.errors.txt delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/invalidGroupedProperty.1.qml delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/invalidGroupedProperty.10.errors.txt delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/invalidGroupedProperty.10.qml delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/invalidGroupedProperty.2.errors.txt delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/invalidGroupedProperty.2.qml delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/invalidGroupedProperty.3.errors.txt delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/invalidGroupedProperty.3.qml delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/invalidGroupedProperty.4.errors.txt delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/invalidGroupedProperty.4.qml delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/invalidGroupedProperty.5.errors.txt delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/invalidGroupedProperty.5.qml delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/invalidGroupedProperty.6.errors.txt delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/invalidGroupedProperty.6.qml delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/invalidGroupedProperty.7.errors.txt delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/invalidGroupedProperty.7.qml delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/invalidGroupedProperty.8.errors.txt delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/invalidGroupedProperty.8.qml delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/invalidGroupedProperty.9.errors.txt delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/invalidGroupedProperty.9.qml delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/invalidID.2.errors.txt delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/invalidID.2.qml delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/invalidID.3.errors.txt delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/invalidID.3.qml delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/invalidID.4.errors.txt delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/invalidID.4.qml delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/invalidID.5.errors.txt delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/invalidID.5.qml delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/invalidID.6.errors.txt delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/invalidID.6.qml delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/invalidID.7.errors.txt delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/invalidID.7.qml delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/invalidID.8.errors.txt delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/invalidID.8.qml delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/invalidID.9.errors.txt delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/invalidID.9.qml delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/invalidID.errors.txt delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/invalidID.qml delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/invalidImportID.errors.txt delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/invalidImportID.qml delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/invalidOn.errors.txt delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/invalidOn.qml delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/invalidProperty.errors.txt delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/invalidProperty.qml delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/invalidRoot.1.errors.txt delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/invalidRoot.1.qml delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/invalidRoot.2.errors.txt delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/invalidRoot.2.qml delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/invalidRoot.3.errors.txt delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/invalidRoot.3.qml delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/invalidRoot.4.errors.txt delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/invalidRoot.4.qml delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/invalidTypeName.1.errors.txt delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/invalidTypeName.1.qml delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/invalidTypeName.2.errors.txt delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/invalidTypeName.2.qml delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/invalidTypeName.3.errors.txt delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/invalidTypeName.3.qml delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/invalidTypeName.4.errors.txt delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/invalidTypeName.4.qml delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/lib/com/nokia/PureJsModule.1.6/FirstAPI.1.6.js delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/lib/com/nokia/PureJsModule.1.6/FirstAPI.js delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/lib/com/nokia/PureJsModule.1.6/SecondAPI.js delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/lib/com/nokia/PureJsModule.1.6/qmldir delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/lib/com/nokia/PureJsModule/FirstAPI.js delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/lib/com/nokia/PureJsModule/SecondAPI.js delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/lib/com/nokia/PureJsModule/qmldir delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/lib/com/nokia/VersionedOnlyJsModule.9.0/SomeAPI.js delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/lib/com/nokia/VersionedOnlyJsModule.9.0/qmldir delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/lib/com/nokia/installedtest/InstalledTest.qml delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/lib/com/nokia/installedtest/InstalledTest2.qml delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/lib/com/nokia/installedtest/LocalLast.qml delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/lib/com/nokia/installedtest/PrivateType.qml delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/lib/com/nokia/installedtest/qmldir delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/lib/com/nokia/installedtest0/InstalledTest.qml delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/lib/com/nokia/installedtest0/InstalledTest2.qml delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/lib/com/nokia/installedtest0/qmldir delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/listAssignment.1.errors.txt delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/listAssignment.1.qml delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/listAssignment.2.errors.txt delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/listAssignment.2.qml delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/listAssignment.3.errors.txt delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/listAssignment.3.qml delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/listItemDeleteSelf.qml delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/listProperties.qml delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/majorVersionIsolation.errors.txt delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/majorVersionIsolation.qml delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/metaobjectRevision.1.errors.txt delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/metaobjectRevision.1.qml delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/metaobjectRevision.2.errors.txt delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/metaobjectRevision.2.qml delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/metaobjectRevision.3.errors.txt delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/metaobjectRevision.3.qml delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/method.1.errors.txt delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/method.1.qml delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/missingObject.errors.txt delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/missingObject.qml delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/missingSignal.errors.txt delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/missingSignal.qml delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/missingValueTypeProperty.errors.txt delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/missingValueTypeProperty.qml delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/multiSet.1.errors.txt delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/multiSet.1.qml delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/multiSet.10.errors.txt delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/multiSet.10.qml delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/multiSet.11.errors.txt delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/multiSet.11.qml delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/multiSet.2.errors.txt delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/multiSet.2.qml delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/multiSet.3.errors.txt delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/multiSet.3.qml delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/multiSet.4.errors.txt delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/multiSet.4.qml delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/multiSet.5.errors.txt delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/multiSet.5.qml delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/multiSet.6.errors.txt delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/multiSet.6.qml delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/multiSet.7.errors.txt delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/multiSet.7.qml delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/multiSet.8.errors.txt delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/multiSet.8.qml delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/multiSet.9.errors.txt delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/multiSet.9.qml delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/nestedComponentRoots.qml delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/nestedErrors.errors.txt delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/nestedErrors.qml delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/noCreation.errors.txt delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/noCreation.qml delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/nonScriptableProperty.errors.txt delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/nonScriptableProperty.qml delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/nonexistantProperty.1.errors.txt delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/nonexistantProperty.1.qml delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/nonexistantProperty.2.errors.txt delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/nonexistantProperty.2.qml delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/nonexistantProperty.3.errors.txt delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/nonexistantProperty.3.qml delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/nonexistantProperty.4.errors.txt delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/nonexistantProperty.4.qml delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/nonexistantProperty.5.errors.txt delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/nonexistantProperty.5.qml delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/nonexistantProperty.6.errors.txt delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/nonexistantProperty.6.qml delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/notAvailable.errors.txt delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/notAvailable.qml delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/nullDotProperty.errors.txt delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/nullDotProperty.qml delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/objectValueTypeProperty.errors.txt delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/objectValueTypeProperty.qml delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/onCompleted.qml delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/onDestruction.qml delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/property.1.errors.txt delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/property.1.qml delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/property.2.errors.txt delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/property.2.qml delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/property.3.errors.txt delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/property.3.qml delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/property.4.errors.txt delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/property.4.qml delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/property.6.errors.txt delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/property.6.qml delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/property.7.errors.txt delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/property.7.qml delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/propertyInit.1.qml delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/propertyInit.2.qml delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/propertyValueSource.2.qml delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/propertyValueSource.qml delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/qmlAttachedPropertiesObjectMethod.1.qml delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/qmlAttachedPropertiesObjectMethod.2.qml delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/qtest/declarative/qmllanguage/LocalInternal.qml delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/qtest/declarative/qmllanguage/Test.qml delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/qtest/declarative/qmllanguage/TestLocal.qml delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/qtest/declarative/qmllanguage/TestNamed.qml delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/qtest/declarative/qmllanguage/TestSubDir.qml delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/qtest/declarative/qmllanguage/UndeclaredLocal.qml delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/qtest/declarative/qmllanguage/WrongTestLocal.qml delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/qtest/declarative/qmllanguage/noqmldir/Test.qml delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/qtest/declarative/qmllanguage/pics/blue.png delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/qtest/declarative/qmllanguage/qmldir delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/qtest/declarative/qmllanguage/subdir/SubTest.qml delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/qtest/declarative/qmllanguage/subdir/qmldir delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/readOnly.1.errors.txt delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/readOnly.1.qml delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/readOnly.2.errors.txt delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/readOnly.2.qml delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/readOnly.3.errors.txt delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/readOnly.3.qml delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/readOnly.4.errors.txt delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/readOnly.4.qml delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/readOnly.5.errors.txt delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/readOnly.5.qml delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/readonly.qml delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/registrationOrder.qml delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/remoteLoadCrash.qml delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/revisions11.qml delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/revisionsbasesub11.qml delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/revisionssub11.qml delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/rootAsQmlComponent.qml delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/scriptString.1.errors.txt delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/scriptString.1.qml delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/scriptString.2.errors.txt delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/scriptString.2.qml delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/scriptString.qml delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/scriptString2.qml delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/scriptString3.qml delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/scriptString4.qml delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/signal.1.errors.txt delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/signal.1.qml delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/signal.2.errors.txt delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/signal.2.qml delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/signal.3.errors.txt delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/signal.3.qml delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/signal.4.errors.txt delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/signal.4.qml delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/simpleBindings.qml delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/simpleContainer.qml delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/simpleObject.qml delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/singularProperty.2.errors.txt delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/singularProperty.2.qml delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/singularProperty.errors.txt delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/singularProperty.qml delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/subdir/Test.qml delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/subdir/subsubdir/SubTest.qml delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/test.js delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/test2.js delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/unregisteredObject.errors.txt delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/unregisteredObject.qml delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/unsupportedProperty.errors.txt delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/unsupportedProperty.qml delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/valueTypes.qml delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/variantNotify.qml delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/versionedbase.qml delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/wrongType.1.errors.txt delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/wrongType.1.qml delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/wrongType.10.errors.txt delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/wrongType.10.qml delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/wrongType.11.errors.txt delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/wrongType.11.qml delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/wrongType.12.errors.txt delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/wrongType.12.qml delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/wrongType.13.errors.txt delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/wrongType.13.qml delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/wrongType.14.errors.txt delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/wrongType.14.qml delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/wrongType.15.errors.txt delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/wrongType.15.qml delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/wrongType.16.errors.txt delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/wrongType.16.qml delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/wrongType.17.errors.txt delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/wrongType.17.qml delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/wrongType.2.errors.txt delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/wrongType.2.qml delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/wrongType.3.errors.txt delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/wrongType.3.qml delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/wrongType.4.errors.txt delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/wrongType.4.qml delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/wrongType.5.errors.txt delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/wrongType.5.qml delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/wrongType.6.errors.txt delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/wrongType.6.qml delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/wrongType.7.errors.txt delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/wrongType.7.qml delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/wrongType.8.errors.txt delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/wrongType.8.qml delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/wrongType.9.errors.txt delete mode 100644 tests/auto/declarative/qdeclarativelanguage/data/wrongType.9.qml delete mode 100644 tests/auto/declarative/qdeclarativelanguage/qdeclarativelanguage.pro delete mode 100644 tests/auto/declarative/qdeclarativelanguage/testtypes.cpp delete mode 100644 tests/auto/declarative/qdeclarativelanguage/testtypes.h delete mode 100644 tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp delete mode 100644 tests/auto/declarative/qdeclarativelistcompositor/qdeclarativelistcompositor.pro delete mode 100644 tests/auto/declarative/qdeclarativelistcompositor/tst_qdeclarativelistcompositor.cpp delete mode 100644 tests/auto/declarative/qdeclarativelistmodel/data/enumerate.qml delete mode 100644 tests/auto/declarative/qdeclarativelistmodel/data/model.qml delete mode 100644 tests/auto/declarative/qdeclarativelistmodel/data/multipleroles.qml delete mode 100644 tests/auto/declarative/qdeclarativelistmodel/data/script.js delete mode 100644 tests/auto/declarative/qdeclarativelistmodel/data/setmodelcachelist.qml delete mode 100644 tests/auto/declarative/qdeclarativelistmodel/data/signalhandlers.qml delete mode 100644 tests/auto/declarative/qdeclarativelistmodel/data/workerremoveelement.js delete mode 100644 tests/auto/declarative/qdeclarativelistmodel/data/workerremoveelement.qml delete mode 100644 tests/auto/declarative/qdeclarativelistmodel/data/workerremovelist.js delete mode 100644 tests/auto/declarative/qdeclarativelistmodel/data/workerremovelist.qml delete mode 100644 tests/auto/declarative/qdeclarativelistmodel/data/workersync.js delete mode 100644 tests/auto/declarative/qdeclarativelistmodel/data/workersync.qml delete mode 100644 tests/auto/declarative/qdeclarativelistmodel/qdeclarativelistmodel.pro delete mode 100644 tests/auto/declarative/qdeclarativelistmodel/tst_qdeclarativelistmodel.cpp delete mode 100644 tests/auto/declarative/qdeclarativelistreference/data/MyType.qml delete mode 100644 tests/auto/declarative/qdeclarativelistreference/data/engineTypes.qml delete mode 100644 tests/auto/declarative/qdeclarativelistreference/data/variantToList.qml delete mode 100644 tests/auto/declarative/qdeclarativelistreference/qdeclarativelistreference.pro delete mode 100644 tests/auto/declarative/qdeclarativelistreference/tst_qdeclarativelistreference.cpp delete mode 100644 tests/auto/declarative/qdeclarativelocale/data/date.qml delete mode 100644 tests/auto/declarative/qdeclarativelocale/data/functions.qml delete mode 100644 tests/auto/declarative/qdeclarativelocale/data/localeCompare.qml delete mode 100644 tests/auto/declarative/qdeclarativelocale/data/number.qml delete mode 100644 tests/auto/declarative/qdeclarativelocale/data/properties.qml delete mode 100644 tests/auto/declarative/qdeclarativelocale/qdeclarativelocale.pro delete mode 100644 tests/auto/declarative/qdeclarativelocale/tst_qdeclarativelocale.cpp delete mode 100644 tests/auto/declarative/qdeclarativemetatype/qdeclarativemetatype.pro delete mode 100644 tests/auto/declarative/qdeclarativemetatype/tst_qdeclarativemetatype.cpp delete mode 100644 tests/auto/declarative/qdeclarativemoduleplugin/data/implicit1/implicitQmldir.errors.txt delete mode 100644 tests/auto/declarative/qdeclarativemoduleplugin/data/implicit1/qmldir delete mode 100644 tests/auto/declarative/qdeclarativemoduleplugin/data/implicit1/temptest.qml delete mode 100644 tests/auto/declarative/qdeclarativemoduleplugin/data/implicit2/Test.qml delete mode 100644 tests/auto/declarative/qdeclarativemoduleplugin/data/implicit2/implicitQmldir.2.errors.txt delete mode 100644 tests/auto/declarative/qdeclarativemoduleplugin/data/implicit2/qmldir delete mode 100644 tests/auto/declarative/qdeclarativemoduleplugin/data/implicit2/temptest2.qml delete mode 100644 tests/auto/declarative/qdeclarativemoduleplugin/data/importsMixedQmlCppPlugin.2.qml delete mode 100644 tests/auto/declarative/qdeclarativemoduleplugin/data/importsMixedQmlCppPlugin.qml delete mode 100644 tests/auto/declarative/qdeclarativemoduleplugin/data/incorrectCase.qml delete mode 100644 tests/auto/declarative/qdeclarativemoduleplugin/data/pluginWithQmlFile.qml delete mode 100644 tests/auto/declarative/qdeclarativemoduleplugin/data/versionNotInstalled.2.errors.txt delete mode 100644 tests/auto/declarative/qdeclarativemoduleplugin/data/versionNotInstalled.2.qml delete mode 100644 tests/auto/declarative/qdeclarativemoduleplugin/data/versionNotInstalled.errors.txt delete mode 100644 tests/auto/declarative/qdeclarativemoduleplugin/data/versionNotInstalled.qml delete mode 100644 tests/auto/declarative/qdeclarativemoduleplugin/data/works.qml delete mode 100644 tests/auto/declarative/qdeclarativemoduleplugin/data/works2.qml delete mode 100644 tests/auto/declarative/qdeclarativemoduleplugin/data/works21.qml delete mode 100644 tests/auto/declarative/qdeclarativemoduleplugin/imports/com/nokia/AutoTestPluginWithQmlFile/MyQmlFile.qml delete mode 100644 tests/auto/declarative/qdeclarativemoduleplugin/imports/com/nokia/AutoTestPluginWithQmlFile/qmldir delete mode 100644 tests/auto/declarative/qdeclarativemoduleplugin/imports/com/nokia/AutoTestQmlMixedPluginType/Foo.qml delete mode 100644 tests/auto/declarative/qdeclarativemoduleplugin/imports/com/nokia/AutoTestQmlMixedPluginType/qmldir delete mode 100644 tests/auto/declarative/qdeclarativemoduleplugin/imports/com/nokia/AutoTestQmlPluginType.2.1/qmldir delete mode 100644 tests/auto/declarative/qdeclarativemoduleplugin/imports/com/nokia/AutoTestQmlPluginType.2/qmldir delete mode 100644 tests/auto/declarative/qdeclarativemoduleplugin/imports/com/nokia/AutoTestQmlPluginType/qmldir delete mode 100644 tests/auto/declarative/qdeclarativemoduleplugin/imports/com/nokia/AutoTestQmlVersionPluginType/qmldir delete mode 100644 tests/auto/declarative/qdeclarativemoduleplugin/imports/com/nokia/PureQmlModule/ComponentA.qml delete mode 100644 tests/auto/declarative/qdeclarativemoduleplugin/imports/com/nokia/PureQmlModule/ComponentB.qml delete mode 100644 tests/auto/declarative/qdeclarativemoduleplugin/imports/com/nokia/PureQmlModule/qmldir delete mode 100644 tests/auto/declarative/qdeclarativemoduleplugin/imports/com/nokia/WrongCase/qmldir delete mode 100644 tests/auto/declarative/qdeclarativemoduleplugin/plugin.2.1/plugin.2.1.pro delete mode 100644 tests/auto/declarative/qdeclarativemoduleplugin/plugin.2.1/plugin.cpp delete mode 100644 tests/auto/declarative/qdeclarativemoduleplugin/plugin.2/plugin.2.pro delete mode 100644 tests/auto/declarative/qdeclarativemoduleplugin/plugin.2/plugin.cpp delete mode 100644 tests/auto/declarative/qdeclarativemoduleplugin/plugin/plugin.cpp delete mode 100644 tests/auto/declarative/qdeclarativemoduleplugin/plugin/plugin.pro delete mode 100644 tests/auto/declarative/qdeclarativemoduleplugin/pluginMixed/plugin.cpp delete mode 100644 tests/auto/declarative/qdeclarativemoduleplugin/pluginMixed/pluginMixed.pro delete mode 100644 tests/auto/declarative/qdeclarativemoduleplugin/pluginVersion/plugin.cpp delete mode 100644 tests/auto/declarative/qdeclarativemoduleplugin/pluginVersion/pluginVersion.pro delete mode 100644 tests/auto/declarative/qdeclarativemoduleplugin/pluginWithQmlFile/plugin.cpp delete mode 100644 tests/auto/declarative/qdeclarativemoduleplugin/pluginWithQmlFile/pluginWithQmlFile.pro delete mode 100644 tests/auto/declarative/qdeclarativemoduleplugin/pluginWrongCase/plugin.cpp delete mode 100644 tests/auto/declarative/qdeclarativemoduleplugin/pluginWrongCase/pluginWrongCase.pro delete mode 100644 tests/auto/declarative/qdeclarativemoduleplugin/qdeclarativemoduleplugin.pro delete mode 100644 tests/auto/declarative/qdeclarativemoduleplugin/tst_qdeclarativemoduleplugin.cpp delete mode 100644 tests/auto/declarative/qdeclarativemoduleplugin/tst_qdeclarativemoduleplugin.pro delete mode 100644 tests/auto/declarative/qdeclarativeparser/qdeclarativeparser.pro delete mode 100644 tests/auto/declarative/qdeclarativeparser/tst_qdeclarativeparser.cpp delete mode 100644 tests/auto/declarative/qdeclarativepixmapcache/data/dataLeak.qml delete mode 100644 tests/auto/declarative/qdeclarativeproperty/data/NoContextTypeA.qml delete mode 100644 tests/auto/declarative/qdeclarativeproperty/data/NoContextTypeB.qml delete mode 100644 tests/auto/declarative/qdeclarativeproperty/data/TestType.qml delete mode 100644 tests/auto/declarative/qdeclarativeproperty/data/aliasPropertyBindings.qml delete mode 100644 tests/auto/declarative/qdeclarativeproperty/data/assignEmptyVariantMap.qml delete mode 100644 tests/auto/declarative/qdeclarativeproperty/data/readSynthesizedObject.qml delete mode 100644 tests/auto/declarative/qdeclarativeproperty/qdeclarativeproperty.pro delete mode 100644 tests/auto/declarative/qdeclarativeproperty/tst_qdeclarativeproperty.cpp delete mode 100644 tests/auto/declarative/qdeclarativepropertycache/qdeclarativepropertycache.pro delete mode 100644 tests/auto/declarative/qdeclarativepropertycache/tst_qdeclarativepropertycache.cpp delete mode 100644 tests/auto/declarative/qdeclarativepropertymap/qdeclarativepropertymap.pro delete mode 100644 tests/auto/declarative/qdeclarativepropertymap/tst_qdeclarativepropertymap.cpp delete mode 100644 tests/auto/declarative/qdeclarativeqt/data/atob.qml delete mode 100644 tests/auto/declarative/qdeclarativeqt/data/btoa.qml delete mode 100644 tests/auto/declarative/qdeclarativeqt/data/createComponent.qml delete mode 100644 tests/auto/declarative/qdeclarativeqt/data/createComponentData.qml delete mode 100644 tests/auto/declarative/qdeclarativeqt/data/createComponent_lib.js delete mode 100644 tests/auto/declarative/qdeclarativeqt/data/createComponent_lib.qml delete mode 100644 tests/auto/declarative/qdeclarativeqt/data/createQmlObject.qml delete mode 100644 tests/auto/declarative/qdeclarativeqt/data/darker.qml delete mode 100644 tests/auto/declarative/qdeclarativeqt/data/dateTimeConversion.qml delete mode 100644 tests/auto/declarative/qdeclarativeqt/data/enums.qml delete mode 100644 tests/auto/declarative/qdeclarativeqt/data/fontFamilies.qml delete mode 100644 tests/auto/declarative/qdeclarativeqt/data/formatting.qml delete mode 100644 tests/auto/declarative/qdeclarativeqt/data/hsla.qml delete mode 100644 tests/auto/declarative/qdeclarativeqt/data/isQtObject.qml delete mode 100644 tests/auto/declarative/qdeclarativeqt/data/lighter.qml delete mode 100644 tests/auto/declarative/qdeclarativeqt/data/md5.qml delete mode 100644 tests/auto/declarative/qdeclarativeqt/data/openUrlExternally.qml delete mode 100644 tests/auto/declarative/qdeclarativeqt/data/openUrlExternally_lib.js delete mode 100644 tests/auto/declarative/qdeclarativeqt/data/openUrlExternally_lib.qml delete mode 100644 tests/auto/declarative/qdeclarativeqt/data/point.qml delete mode 100644 tests/auto/declarative/qdeclarativeqt/data/quit.qml delete mode 100644 tests/auto/declarative/qdeclarativeqt/data/rect.qml delete mode 100644 tests/auto/declarative/qdeclarativeqt/data/resolvedUrl.qml delete mode 100644 tests/auto/declarative/qdeclarativeqt/data/rgba.qml delete mode 100644 tests/auto/declarative/qdeclarativeqt/data/size.qml delete mode 100644 tests/auto/declarative/qdeclarativeqt/data/tint.qml delete mode 100644 tests/auto/declarative/qdeclarativeqt/data/vector.qml delete mode 100644 tests/auto/declarative/qdeclarativeqt/data/vector4.qml delete mode 100644 tests/auto/declarative/qdeclarativeqt/qdeclarativeqt.pro delete mode 100644 tests/auto/declarative/qdeclarativeqt/tst_qdeclarativeqt.cpp delete mode 100644 tests/auto/declarative/qdeclarativesqldatabase/data/README delete mode 100644 tests/auto/declarative/qdeclarativesqldatabase/data/changeversion.js delete mode 100644 tests/auto/declarative/qdeclarativesqldatabase/data/creation-a.js delete mode 100644 tests/auto/declarative/qdeclarativesqldatabase/data/creation.js delete mode 100644 tests/auto/declarative/qdeclarativesqldatabase/data/error-a.js delete mode 100644 tests/auto/declarative/qdeclarativesqldatabase/data/error-b.js delete mode 100644 tests/auto/declarative/qdeclarativesqldatabase/data/error-creation.js delete mode 100644 tests/auto/declarative/qdeclarativesqldatabase/data/error-notransaction.js delete mode 100644 tests/auto/declarative/qdeclarativesqldatabase/data/error-outsidetransaction.js delete mode 100644 tests/auto/declarative/qdeclarativesqldatabase/data/iteration-forwardonly.js delete mode 100644 tests/auto/declarative/qdeclarativesqldatabase/data/iteration.js delete mode 100644 tests/auto/declarative/qdeclarativesqldatabase/data/readonly-error.js delete mode 100644 tests/auto/declarative/qdeclarativesqldatabase/data/readonly.js delete mode 100644 tests/auto/declarative/qdeclarativesqldatabase/data/reopen1.js delete mode 100644 tests/auto/declarative/qdeclarativesqldatabase/data/reopen2.js delete mode 100644 tests/auto/declarative/qdeclarativesqldatabase/data/selection-bindnames.js delete mode 100644 tests/auto/declarative/qdeclarativesqldatabase/data/selection.js delete mode 100644 tests/auto/declarative/qdeclarativesqldatabase/qdeclarativesqldatabase.pro delete mode 100644 tests/auto/declarative/qdeclarativesqldatabase/tst_qdeclarativesqldatabase.cpp delete mode 100644 tests/auto/declarative/qdeclarativetranslation/data/idtranslation.qml delete mode 100644 tests/auto/declarative/qdeclarativetranslation/data/qml_fr.qm delete mode 100644 tests/auto/declarative/qdeclarativetranslation/data/qml_fr.ts delete mode 100644 tests/auto/declarative/qdeclarativetranslation/data/qmlid_fr.qm delete mode 100644 tests/auto/declarative/qdeclarativetranslation/data/qmlid_fr.ts delete mode 100644 tests/auto/declarative/qdeclarativetranslation/data/translation.qml delete mode 100644 tests/auto/declarative/qdeclarativetranslation/data/translation.qrc delete mode 100644 tests/auto/declarative/qdeclarativetranslation/qdeclarativetranslation.pro delete mode 100644 tests/auto/declarative/qdeclarativetranslation/tst_qdeclarativetranslation.cpp delete mode 100644 tests/auto/declarative/qdeclarativevaluetypes/data/BindingsSpliceCorrectlyType.qml delete mode 100644 tests/auto/declarative/qdeclarativevaluetypes/data/BindingsSpliceCorrectlyType4.qml delete mode 100644 tests/auto/declarative/qdeclarativevaluetypes/data/BindingsSpliceCorrectlyType5.qml delete mode 100644 tests/auto/declarative/qdeclarativevaluetypes/data/autoBindingRemoval.2.qml delete mode 100644 tests/auto/declarative/qdeclarativevaluetypes/data/autoBindingRemoval.3.qml delete mode 100644 tests/auto/declarative/qdeclarativevaluetypes/data/autoBindingRemoval.qml delete mode 100644 tests/auto/declarative/qdeclarativevaluetypes/data/bindingAssignment.qml delete mode 100644 tests/auto/declarative/qdeclarativevaluetypes/data/bindingConflict.qml delete mode 100644 tests/auto/declarative/qdeclarativevaluetypes/data/bindingRead.qml delete mode 100644 tests/auto/declarative/qdeclarativevaluetypes/data/bindingVariantCopy.qml delete mode 100644 tests/auto/declarative/qdeclarativevaluetypes/data/bindingsSpliceCorrectly.1.qml delete mode 100644 tests/auto/declarative/qdeclarativevaluetypes/data/bindingsSpliceCorrectly.2.qml delete mode 100644 tests/auto/declarative/qdeclarativevaluetypes/data/bindingsSpliceCorrectly.3.qml delete mode 100644 tests/auto/declarative/qdeclarativevaluetypes/data/bindingsSpliceCorrectly.4.qml delete mode 100644 tests/auto/declarative/qdeclarativevaluetypes/data/bindingsSpliceCorrectly.5.qml delete mode 100644 tests/auto/declarative/qdeclarativevaluetypes/data/color_compare.qml delete mode 100644 tests/auto/declarative/qdeclarativevaluetypes/data/color_read.qml delete mode 100644 tests/auto/declarative/qdeclarativevaluetypes/data/color_write.qml delete mode 100644 tests/auto/declarative/qdeclarativevaluetypes/data/conflicting.1.qml delete mode 100644 tests/auto/declarative/qdeclarativevaluetypes/data/conflicting.2.qml delete mode 100644 tests/auto/declarative/qdeclarativevaluetypes/data/conflicting.3.qml delete mode 100644 tests/auto/declarative/qdeclarativevaluetypes/data/deletedObject.js delete mode 100644 tests/auto/declarative/qdeclarativevaluetypes/data/deletedObject.qml delete mode 100644 tests/auto/declarative/qdeclarativevaluetypes/data/enums.1.qml delete mode 100644 tests/auto/declarative/qdeclarativevaluetypes/data/enums.2.qml delete mode 100644 tests/auto/declarative/qdeclarativevaluetypes/data/enums.3.qml delete mode 100644 tests/auto/declarative/qdeclarativevaluetypes/data/enums.4.qml delete mode 100644 tests/auto/declarative/qdeclarativevaluetypes/data/enums.5.qml delete mode 100644 tests/auto/declarative/qdeclarativevaluetypes/data/font_compare.qml delete mode 100644 tests/auto/declarative/qdeclarativevaluetypes/data/font_read.qml delete mode 100644 tests/auto/declarative/qdeclarativevaluetypes/data/font_write.2.qml delete mode 100644 tests/auto/declarative/qdeclarativevaluetypes/data/font_write.3.qml delete mode 100644 tests/auto/declarative/qdeclarativevaluetypes/data/font_write.4.qml delete mode 100644 tests/auto/declarative/qdeclarativevaluetypes/data/font_write.5.qml delete mode 100644 tests/auto/declarative/qdeclarativevaluetypes/data/font_write.qml delete mode 100644 tests/auto/declarative/qdeclarativevaluetypes/data/matrix4x4_compare.qml delete mode 100644 tests/auto/declarative/qdeclarativevaluetypes/data/matrix4x4_read.qml delete mode 100644 tests/auto/declarative/qdeclarativevaluetypes/data/matrix4x4_write.qml delete mode 100644 tests/auto/declarative/qdeclarativevaluetypes/data/point_compare.qml delete mode 100644 tests/auto/declarative/qdeclarativevaluetypes/data/point_read.qml delete mode 100644 tests/auto/declarative/qdeclarativevaluetypes/data/point_write.qml delete mode 100644 tests/auto/declarative/qdeclarativevaluetypes/data/pointf_compare.qml delete mode 100644 tests/auto/declarative/qdeclarativevaluetypes/data/pointf_read.qml delete mode 100644 tests/auto/declarative/qdeclarativevaluetypes/data/pointf_write.qml delete mode 100644 tests/auto/declarative/qdeclarativevaluetypes/data/quaternion_compare.qml delete mode 100644 tests/auto/declarative/qdeclarativevaluetypes/data/quaternion_read.qml delete mode 100644 tests/auto/declarative/qdeclarativevaluetypes/data/quaternion_write.qml delete mode 100644 tests/auto/declarative/qdeclarativevaluetypes/data/rect_compare.qml delete mode 100644 tests/auto/declarative/qdeclarativevaluetypes/data/rect_read.qml delete mode 100644 tests/auto/declarative/qdeclarativevaluetypes/data/rect_write.qml delete mode 100644 tests/auto/declarative/qdeclarativevaluetypes/data/rectf_compare.qml delete mode 100644 tests/auto/declarative/qdeclarativevaluetypes/data/rectf_read.qml delete mode 100644 tests/auto/declarative/qdeclarativevaluetypes/data/rectf_write.qml delete mode 100644 tests/auto/declarative/qdeclarativevaluetypes/data/returnValues.qml delete mode 100644 tests/auto/declarative/qdeclarativevaluetypes/data/scriptAccess.qml delete mode 100644 tests/auto/declarative/qdeclarativevaluetypes/data/scriptVariantCopy.qml delete mode 100644 tests/auto/declarative/qdeclarativevaluetypes/data/size_compare.qml delete mode 100644 tests/auto/declarative/qdeclarativevaluetypes/data/size_read.qml delete mode 100644 tests/auto/declarative/qdeclarativevaluetypes/data/size_write.qml delete mode 100644 tests/auto/declarative/qdeclarativevaluetypes/data/sizef_compare.qml delete mode 100644 tests/auto/declarative/qdeclarativevaluetypes/data/sizef_read.qml delete mode 100644 tests/auto/declarative/qdeclarativevaluetypes/data/sizef_write.qml delete mode 100644 tests/auto/declarative/qdeclarativevaluetypes/data/sizereadonly_read.qml delete mode 100644 tests/auto/declarative/qdeclarativevaluetypes/data/sizereadonly_writeerror.qml delete mode 100644 tests/auto/declarative/qdeclarativevaluetypes/data/sizereadonly_writeerror2.qml delete mode 100644 tests/auto/declarative/qdeclarativevaluetypes/data/sizereadonly_writeerror3.qml delete mode 100644 tests/auto/declarative/qdeclarativevaluetypes/data/sizereadonly_writeerror4.qml delete mode 100644 tests/auto/declarative/qdeclarativevaluetypes/data/staticAssignment.qml delete mode 100644 tests/auto/declarative/qdeclarativevaluetypes/data/valueInterceptors.qml delete mode 100644 tests/auto/declarative/qdeclarativevaluetypes/data/valueSources.qml delete mode 100644 tests/auto/declarative/qdeclarativevaluetypes/data/varAssignment.qml delete mode 100644 tests/auto/declarative/qdeclarativevaluetypes/data/variant_read.qml delete mode 100644 tests/auto/declarative/qdeclarativevaluetypes/data/vector2d_compare.qml delete mode 100644 tests/auto/declarative/qdeclarativevaluetypes/data/vector2d_read.qml delete mode 100644 tests/auto/declarative/qdeclarativevaluetypes/data/vector2d_write.qml delete mode 100644 tests/auto/declarative/qdeclarativevaluetypes/data/vector3d_compare.qml delete mode 100644 tests/auto/declarative/qdeclarativevaluetypes/data/vector3d_read.qml delete mode 100644 tests/auto/declarative/qdeclarativevaluetypes/data/vector3d_write.qml delete mode 100644 tests/auto/declarative/qdeclarativevaluetypes/data/vector4d_compare.qml delete mode 100644 tests/auto/declarative/qdeclarativevaluetypes/data/vector4d_read.qml delete mode 100644 tests/auto/declarative/qdeclarativevaluetypes/data/vector4d_write.qml delete mode 100644 tests/auto/declarative/qdeclarativevaluetypes/qdeclarativevaluetypes.pro delete mode 100644 tests/auto/declarative/qdeclarativevaluetypes/testtypes.cpp delete mode 100644 tests/auto/declarative/qdeclarativevaluetypes/testtypes.h delete mode 100644 tests/auto/declarative/qdeclarativevaluetypes/tst_qdeclarativevaluetypes.cpp delete mode 100644 tests/auto/declarative/qdeclarativeworkerscript/data/BaseWorker.qml delete mode 100644 tests/auto/declarative/qdeclarativeworkerscript/data/Global.js delete mode 100644 tests/auto/declarative/qdeclarativeworkerscript/data/externalObjectWorker.qml delete mode 100644 tests/auto/declarative/qdeclarativeworkerscript/data/script.js delete mode 100644 tests/auto/declarative/qdeclarativeworkerscript/data/script_error_onCall.js delete mode 100644 tests/auto/declarative/qdeclarativeworkerscript/data/script_error_onLoad.js delete mode 100644 tests/auto/declarative/qdeclarativeworkerscript/data/script_fixed_return.js delete mode 100644 tests/auto/declarative/qdeclarativeworkerscript/data/script_include.js delete mode 100644 tests/auto/declarative/qdeclarativeworkerscript/data/script_pragma.js delete mode 100644 tests/auto/declarative/qdeclarativeworkerscript/data/stressDispose.js delete mode 100644 tests/auto/declarative/qdeclarativeworkerscript/data/stressDispose.qml delete mode 100644 tests/auto/declarative/qdeclarativeworkerscript/data/worker.qml delete mode 100644 tests/auto/declarative/qdeclarativeworkerscript/data/worker_error_onCall.qml delete mode 100644 tests/auto/declarative/qdeclarativeworkerscript/data/worker_error_onLoad.qml delete mode 100644 tests/auto/declarative/qdeclarativeworkerscript/data/worker_include.qml delete mode 100644 tests/auto/declarative/qdeclarativeworkerscript/data/worker_pragma.qml delete mode 100644 tests/auto/declarative/qdeclarativeworkerscript/qdeclarativeworkerscript.pro delete mode 100644 tests/auto/declarative/qdeclarativeworkerscript/tst_qdeclarativeworkerscript.cpp delete mode 100644 tests/auto/declarative/qdeclarativexmlhttprequest/data/abort.expect delete mode 100644 tests/auto/declarative/qdeclarativexmlhttprequest/data/abort.qml delete mode 100644 tests/auto/declarative/qdeclarativexmlhttprequest/data/abort.reply delete mode 100644 tests/auto/declarative/qdeclarativexmlhttprequest/data/abort_opened.qml delete mode 100644 tests/auto/declarative/qdeclarativexmlhttprequest/data/abort_unsent.qml delete mode 100644 tests/auto/declarative/qdeclarativexmlhttprequest/data/attr.qml delete mode 100644 tests/auto/declarative/qdeclarativexmlhttprequest/data/attr.xml delete mode 100644 tests/auto/declarative/qdeclarativexmlhttprequest/data/callbackException.qml delete mode 100644 tests/auto/declarative/qdeclarativexmlhttprequest/data/cdata.qml delete mode 100644 tests/auto/declarative/qdeclarativexmlhttprequest/data/cdata.xml delete mode 100644 tests/auto/declarative/qdeclarativexmlhttprequest/data/constructor.qml delete mode 100644 tests/auto/declarative/qdeclarativexmlhttprequest/data/defaultState.qml delete mode 100644 tests/auto/declarative/qdeclarativexmlhttprequest/data/document.qml delete mode 100644 tests/auto/declarative/qdeclarativexmlhttprequest/data/document.xml delete mode 100644 tests/auto/declarative/qdeclarativexmlhttprequest/data/domExceptionCodes.qml delete mode 100644 tests/auto/declarative/qdeclarativexmlhttprequest/data/element.qml delete mode 100644 tests/auto/declarative/qdeclarativexmlhttprequest/data/element.xml delete mode 100644 tests/auto/declarative/qdeclarativexmlhttprequest/data/getAllResponseHeaders.qml delete mode 100644 tests/auto/declarative/qdeclarativexmlhttprequest/data/getAllResponseHeaders_args.qml delete mode 100644 tests/auto/declarative/qdeclarativexmlhttprequest/data/getAllResponseHeaders_sent.qml delete mode 100644 tests/auto/declarative/qdeclarativexmlhttprequest/data/getAllResponseHeaders_unsent.qml delete mode 100644 tests/auto/declarative/qdeclarativexmlhttprequest/data/getResponseHeader.expect delete mode 100644 tests/auto/declarative/qdeclarativexmlhttprequest/data/getResponseHeader.qml delete mode 100644 tests/auto/declarative/qdeclarativexmlhttprequest/data/getResponseHeader.reply delete mode 100644 tests/auto/declarative/qdeclarativexmlhttprequest/data/getResponseHeader_args.qml delete mode 100644 tests/auto/declarative/qdeclarativexmlhttprequest/data/getResponseHeader_sent.qml delete mode 100644 tests/auto/declarative/qdeclarativexmlhttprequest/data/getResponseHeader_unsent.qml delete mode 100644 tests/auto/declarative/qdeclarativexmlhttprequest/data/instanceStateValues.qml delete mode 100644 tests/auto/declarative/qdeclarativexmlhttprequest/data/invalidMethodUsage.qml delete mode 100644 tests/auto/declarative/qdeclarativexmlhttprequest/data/open.qml delete mode 100644 tests/auto/declarative/qdeclarativexmlhttprequest/data/open_arg_count.1.qml delete mode 100644 tests/auto/declarative/qdeclarativexmlhttprequest/data/open_arg_count.2.qml delete mode 100644 tests/auto/declarative/qdeclarativexmlhttprequest/data/open_invalid_method.qml delete mode 100644 tests/auto/declarative/qdeclarativexmlhttprequest/data/open_network.expect delete mode 100644 tests/auto/declarative/qdeclarativexmlhttprequest/data/open_network.reply delete mode 100644 tests/auto/declarative/qdeclarativexmlhttprequest/data/open_network.wait delete mode 100644 tests/auto/declarative/qdeclarativexmlhttprequest/data/open_sync.qml delete mode 100644 tests/auto/declarative/qdeclarativexmlhttprequest/data/open_user.qml delete mode 100644 tests/auto/declarative/qdeclarativexmlhttprequest/data/open_username.qml delete mode 100644 tests/auto/declarative/qdeclarativexmlhttprequest/data/redirectError.qml delete mode 100644 tests/auto/declarative/qdeclarativexmlhttprequest/data/redirectRecur.qml delete mode 100644 tests/auto/declarative/qdeclarativexmlhttprequest/data/redirects.qml delete mode 100644 tests/auto/declarative/qdeclarativexmlhttprequest/data/redirecttarget.html delete mode 100644 tests/auto/declarative/qdeclarativexmlhttprequest/data/responseText.qml delete mode 100644 tests/auto/declarative/qdeclarativexmlhttprequest/data/responseXML_invalid.qml delete mode 100644 tests/auto/declarative/qdeclarativexmlhttprequest/data/seconddocument.html delete mode 100644 tests/auto/declarative/qdeclarativexmlhttprequest/data/send_alreadySent.qml delete mode 100644 tests/auto/declarative/qdeclarativexmlhttprequest/data/send_data.1.expect delete mode 100644 tests/auto/declarative/qdeclarativexmlhttprequest/data/send_data.1.qml delete mode 100644 tests/auto/declarative/qdeclarativexmlhttprequest/data/send_data.2.qml delete mode 100644 tests/auto/declarative/qdeclarativexmlhttprequest/data/send_data.3.qml delete mode 100644 tests/auto/declarative/qdeclarativexmlhttprequest/data/send_data.4.expect delete mode 100644 tests/auto/declarative/qdeclarativexmlhttprequest/data/send_data.4.qml delete mode 100644 tests/auto/declarative/qdeclarativexmlhttprequest/data/send_data.5.qml delete mode 100644 tests/auto/declarative/qdeclarativexmlhttprequest/data/send_data.6.expect delete mode 100644 tests/auto/declarative/qdeclarativexmlhttprequest/data/send_data.6.qml delete mode 100644 tests/auto/declarative/qdeclarativexmlhttprequest/data/send_data.7.qml delete mode 100644 tests/auto/declarative/qdeclarativexmlhttprequest/data/send_data.reply delete mode 100644 tests/auto/declarative/qdeclarativexmlhttprequest/data/send_ignoreData.qml delete mode 100644 tests/auto/declarative/qdeclarativexmlhttprequest/data/send_ignoreData.reply delete mode 100644 tests/auto/declarative/qdeclarativexmlhttprequest/data/send_ignoreData_DELETE.expect delete mode 100644 tests/auto/declarative/qdeclarativexmlhttprequest/data/send_ignoreData_GET.expect delete mode 100644 tests/auto/declarative/qdeclarativexmlhttprequest/data/send_ignoreData_HEAD.expect delete mode 100644 tests/auto/declarative/qdeclarativexmlhttprequest/data/send_unsent.qml delete mode 100644 tests/auto/declarative/qdeclarativexmlhttprequest/data/setRequestHeader.expect delete mode 100644 tests/auto/declarative/qdeclarativexmlhttprequest/data/setRequestHeader.qml delete mode 100644 tests/auto/declarative/qdeclarativexmlhttprequest/data/setRequestHeader.reply delete mode 100644 tests/auto/declarative/qdeclarativexmlhttprequest/data/setRequestHeader_args.qml delete mode 100644 tests/auto/declarative/qdeclarativexmlhttprequest/data/setRequestHeader_caseInsensitive.qml delete mode 100644 tests/auto/declarative/qdeclarativexmlhttprequest/data/setRequestHeader_illegalName.qml delete mode 100644 tests/auto/declarative/qdeclarativexmlhttprequest/data/setRequestHeader_sent.qml delete mode 100644 tests/auto/declarative/qdeclarativexmlhttprequest/data/setRequestHeader_unsent.qml delete mode 100644 tests/auto/declarative/qdeclarativexmlhttprequest/data/staticStateValues.qml delete mode 100644 tests/auto/declarative/qdeclarativexmlhttprequest/data/status.200.reply delete mode 100644 tests/auto/declarative/qdeclarativexmlhttprequest/data/status.400.reply delete mode 100644 tests/auto/declarative/qdeclarativexmlhttprequest/data/status.404.reply delete mode 100644 tests/auto/declarative/qdeclarativexmlhttprequest/data/status.expect delete mode 100644 tests/auto/declarative/qdeclarativexmlhttprequest/data/status.qml delete mode 100644 tests/auto/declarative/qdeclarativexmlhttprequest/data/statusText.qml delete mode 100644 tests/auto/declarative/qdeclarativexmlhttprequest/data/testdocument.html delete mode 100644 tests/auto/declarative/qdeclarativexmlhttprequest/data/text.qml delete mode 100644 tests/auto/declarative/qdeclarativexmlhttprequest/data/text.xml delete mode 100644 tests/auto/declarative/qdeclarativexmlhttprequest/data/utf16.html delete mode 100644 tests/auto/declarative/qdeclarativexmlhttprequest/data/utf16.qml delete mode 100644 tests/auto/declarative/qdeclarativexmlhttprequest/data/utf16.xml delete mode 100644 tests/auto/declarative/qdeclarativexmlhttprequest/qdeclarativexmlhttprequest.pro delete mode 100644 tests/auto/declarative/qdeclarativexmlhttprequest/tst_qdeclarativexmlhttprequest.cpp delete mode 100644 tests/auto/declarative/qjsengine/qjsengine.pro delete mode 100644 tests/auto/declarative/qjsengine/script/com/__init__.js delete mode 100644 tests/auto/declarative/qjsengine/script/com/trolltech/__init__.js delete mode 100644 tests/auto/declarative/qjsengine/script/com/trolltech/recursive/__init__.js delete mode 100644 tests/auto/declarative/qjsengine/script/com/trolltech/syntaxerror/__init__.js delete mode 100644 tests/auto/declarative/qjsengine/tst_qjsengine.cpp delete mode 100644 tests/auto/declarative/qjsvalue/qjsvalue.pro delete mode 100644 tests/auto/declarative/qjsvalue/tst_qjsvalue.cpp delete mode 100644 tests/auto/declarative/qjsvalue/tst_qjsvalue.h delete mode 100644 tests/auto/declarative/qjsvalueiterator/qjsvalueiterator.pro delete mode 100644 tests/auto/declarative/qjsvalueiterator/tst_qjsvalueiterator.cpp delete mode 100644 tests/auto/declarative/qmlmin/qmlmin.pro delete mode 100644 tests/auto/declarative/qmlmin/tst_qmlmin.cpp delete mode 100644 tests/auto/declarative/qmlplugindump/qmlplugindump.pro delete mode 100644 tests/auto/declarative/qmlplugindump/tst_qmlplugindump.cpp delete mode 100755 tests/auto/declarative/runall.sh delete mode 100644 tests/auto/declarative/v4/data/conditionalExpr.qml delete mode 100644 tests/auto/declarative/v4/data/doubleBoolJump.qml delete mode 100644 tests/auto/declarative/v4/data/fetchException.qml delete mode 100644 tests/auto/declarative/v4/data/logicalOr.2.qml delete mode 100644 tests/auto/declarative/v4/data/logicalOr.qml delete mode 100644 tests/auto/declarative/v4/data/nestedLogicalOr.qml delete mode 100644 tests/auto/declarative/v4/data/nestedObjectAccess.qml delete mode 100644 tests/auto/declarative/v4/data/nullQObject.qml delete mode 100644 tests/auto/declarative/v4/data/qrealToIntRounding.qml delete mode 100644 tests/auto/declarative/v4/data/qtbug_21883.qml delete mode 100644 tests/auto/declarative/v4/data/qtbug_22816.qml delete mode 100644 tests/auto/declarative/v4/data/stringComparison.qml delete mode 100644 tests/auto/declarative/v4/data/subscriptionsInConditionalExpressions.qml delete mode 100644 tests/auto/declarative/v4/data/unaryMinus.qml delete mode 100644 tests/auto/declarative/v4/data/unaryPlus.qml delete mode 100644 tests/auto/declarative/v4/data/unnecessaryReeval.qml delete mode 100644 tests/auto/declarative/v4/testtypes.cpp delete mode 100644 tests/auto/declarative/v4/testtypes.h delete mode 100644 tests/auto/declarative/v4/tst_v4.cpp delete mode 100644 tests/auto/declarative/v4/v4.pro create mode 100644 tests/auto/qml/animation/animation.pro create mode 100644 tests/auto/qml/animation/qabstractanimationjob/qabstractanimationjob.pro create mode 100644 tests/auto/qml/animation/qabstractanimationjob/tst_qabstractanimationjob.cpp create mode 100644 tests/auto/qml/animation/qanimationgroupjob/qanimationgroupjob.pro create mode 100644 tests/auto/qml/animation/qanimationgroupjob/tst_qanimationgroupjob.cpp create mode 100644 tests/auto/qml/animation/qparallelanimationgroupjob/qparallelanimationgroupjob.pro create mode 100644 tests/auto/qml/animation/qparallelanimationgroupjob/tst_qparallelanimationgroupjob.cpp create mode 100644 tests/auto/qml/animation/qpauseanimationjob/qpauseanimationjob.pro create mode 100644 tests/auto/qml/animation/qpauseanimationjob/tst_qpauseanimationjob.cpp create mode 100644 tests/auto/qml/animation/qsequentialanimationgroupjob/qsequentialanimationgroupjob.pro create mode 100644 tests/auto/qml/animation/qsequentialanimationgroupjob/tst_qsequentialanimationgroupjob.cpp create mode 100644 tests/auto/qml/debugger/debugger.pro create mode 100644 tests/auto/qml/debugger/qdebugmessageservice/data/test.qml create mode 100644 tests/auto/qml/debugger/qdebugmessageservice/qdebugmessageservice.pro create mode 100644 tests/auto/qml/debugger/qdebugmessageservice/tst_qdebugmessageservice.cpp create mode 100644 tests/auto/qml/debugger/qpacketprotocol/qpacketprotocol.pro create mode 100644 tests/auto/qml/debugger/qpacketprotocol/tst_qpacketprotocol.cpp create mode 100644 tests/auto/qml/debugger/qqmldebugclient/qqmldebugclient.pro create mode 100644 tests/auto/qml/debugger/qqmldebugclient/tst_qqmldebugclient.cpp create mode 100644 tests/auto/qml/debugger/qqmldebugjs/data/breakpointRelocation.qml create mode 100644 tests/auto/qml/debugger/qqmldebugjs/data/changeBreakpoint.qml create mode 100644 tests/auto/qml/debugger/qqmldebugjs/data/condition.qml create mode 100644 tests/auto/qml/debugger/qqmldebugjs/data/createComponent.qml create mode 100644 tests/auto/qml/debugger/qqmldebugjs/data/exception.qml create mode 100644 tests/auto/qml/debugger/qqmldebugjs/data/loadjsfile.qml create mode 100644 tests/auto/qml/debugger/qqmldebugjs/data/oncompleted.qml create mode 100644 tests/auto/qml/debugger/qqmldebugjs/data/stepAction.qml create mode 100644 tests/auto/qml/debugger/qqmldebugjs/data/test.js create mode 100644 tests/auto/qml/debugger/qqmldebugjs/data/test.qml create mode 100644 tests/auto/qml/debugger/qqmldebugjs/data/timer.qml create mode 100644 tests/auto/qml/debugger/qqmldebugjs/qqmldebugjs.pro create mode 100644 tests/auto/qml/debugger/qqmldebugjs/tst_qqmldebugjs.cpp create mode 100644 tests/auto/qml/debugger/qqmldebugservice/qqmldebugservice.pro create mode 100644 tests/auto/qml/debugger/qqmldebugservice/tst_qqmldebugservice.cpp create mode 100644 tests/auto/qml/debugger/qqmlenginedebug/qqmlenginedebug.pro create mode 100644 tests/auto/qml/debugger/qqmlenginedebug/tst_qqmlenginedebug.cpp create mode 100644 tests/auto/qml/debugger/qqmlinspector/app/app.pro create mode 100644 tests/auto/qml/debugger/qqmlinspector/app/main.cpp create mode 100644 tests/auto/qml/debugger/qqmlinspector/app/qtquick2.qml create mode 100644 tests/auto/qml/debugger/qqmlinspector/qqmlinspector.pro create mode 100644 tests/auto/qml/debugger/qqmlinspector/tst_qqmlinspector.cpp create mode 100644 tests/auto/qml/debugger/qqmlinspector/tst_qqmlinspector.pro create mode 100644 tests/auto/qml/debugger/qqmlprofilerservice/data/exit.qml create mode 100644 tests/auto/qml/debugger/qqmlprofilerservice/data/test.qml create mode 100644 tests/auto/qml/debugger/qqmlprofilerservice/qqmlprofilerservice.pro create mode 100644 tests/auto/qml/debugger/qqmlprofilerservice/tst_qqmlprofilerservice.cpp create mode 100644 tests/auto/qml/debugger/qv8profilerservice/data/console.qml create mode 100644 tests/auto/qml/debugger/qv8profilerservice/data/exit.qml create mode 100644 tests/auto/qml/debugger/qv8profilerservice/data/test.qml create mode 100644 tests/auto/qml/debugger/qv8profilerservice/qv8profilerservice.pro create mode 100644 tests/auto/qml/debugger/qv8profilerservice/tst_qv8profilerservice.cpp create mode 100644 tests/auto/qml/debugger/shared/debugutil.cpp create mode 100644 tests/auto/qml/debugger/shared/debugutil_p.h create mode 100644 tests/auto/qml/parserstress/parserstress.pro create mode 100644 tests/auto/qml/parserstress/tests/ecma/Array/15.4-1.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Array/15.4-2.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Array/15.4.1.1.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Array/15.4.1.2.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Array/15.4.1.3.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Array/15.4.1.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Array/15.4.2.1-1.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Array/15.4.2.1-2.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Array/15.4.2.1-3.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Array/15.4.2.2-1.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Array/15.4.2.2-2.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Array/15.4.2.3.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Array/15.4.3.1-2.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Array/15.4.3.2.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Array/15.4.4.1.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Array/15.4.4.2.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Array/15.4.4.3-1.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Array/15.4.4.4-1.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Array/15.4.4.4-2.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Array/15.4.4.5-1.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Array/15.4.4.5-2.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Array/15.4.4.5-3.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Array/15.4.4.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Array/15.4.5.1-1.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Array/15.4.5.1-2.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Array/15.4.5.2-1.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Array/15.4.5.2-2.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Array/browser.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Array/shell.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Boolean/15.6.1.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Boolean/15.6.2.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Boolean/15.6.3.1-1.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Boolean/15.6.3.1-2.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Boolean/15.6.3.1-3.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Boolean/15.6.3.1-4.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Boolean/15.6.3.1.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Boolean/15.6.4-1.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Boolean/15.6.4.1.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Boolean/15.6.4.2-1.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Boolean/15.6.4.2-2.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Boolean/15.6.4.2-3.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Boolean/15.6.4.2-4-n.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Boolean/15.6.4.3-1.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Boolean/15.6.4.3-2.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Boolean/15.6.4.3-3.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Boolean/15.6.4.3-4-n.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Boolean/15.6.4.3.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Boolean/15.6.4.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Boolean/browser.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Boolean/shell.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Date/15.9.1.1-1.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Date/15.9.1.1-2.js create mode 100755 tests/auto/qml/parserstress/tests/ecma/Date/15.9.1.13-1.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Date/15.9.2.1.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Date/15.9.2.2-1.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Date/15.9.2.2-2.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Date/15.9.2.2-3.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Date/15.9.2.2-4.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Date/15.9.2.2-5.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Date/15.9.2.2-6.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Date/15.9.3.1-1.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Date/15.9.3.1-2.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Date/15.9.3.1-3.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Date/15.9.3.1-4.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Date/15.9.3.1-5.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Date/15.9.3.2-1.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Date/15.9.3.2-2.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Date/15.9.3.2-3.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Date/15.9.3.2-4.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Date/15.9.3.2-5.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Date/15.9.3.8-1.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Date/15.9.3.8-2.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Date/15.9.3.8-3.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Date/15.9.3.8-4.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Date/15.9.3.8-5.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Date/15.9.4.2-1.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Date/15.9.4.2.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Date/15.9.4.3.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.1.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.10-1.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.10-10.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.10-11.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.10-12.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.10-13.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.10-2.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.10-3.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.10-4.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.10-5.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.10-6.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.10-7.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.10-8.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.10-9.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.11-1.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.11-2.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.11-3.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.11-4.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.11-5.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.11-6.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.11-7.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.12-1.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.12-2.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.12-3.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.12-4.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.12-5.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.12-6.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.12-7.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.12-8.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.13-1.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.13-2.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.13-3.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.13-4.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.13-5.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.13-6.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.13-7.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.13-8.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.14.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.15.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.16.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.17.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.18.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.19.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.2-1.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.2-2-n.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.2.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.20.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.21-1.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.21-2.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.21-3.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.21-4.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.21-5.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.21-6.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.21-7.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.21-8.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.22-1.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.22-2.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.22-3.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.22-4.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.22-5.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.22-6.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.22-7.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.22-8.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.23-1.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.23-10.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.23-11.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.23-12.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.23-13.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.23-14.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.23-15.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.23-16.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.23-17.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.23-18.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.23-2.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.23-3-n.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.23-4.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.23-5.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.23-6.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.23-7.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.23-8.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.23-9.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.24-1.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.24-2.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.24-3.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.24-4.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.24-5.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.24-6.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.24-7.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.24-8.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.25-1.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.26-1.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.27-1.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.28-1.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.29-1.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.3-1-n.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.3-2.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.30-1.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.31-1.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.32-1.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.33-1.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.34-1.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.35-1.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.36-1.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.36-2.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.36-3.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.36-4.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.36-5.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.36-6.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.36-7.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.37-1.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.37-2.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.37-3.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.37-4.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.37-5.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.4-1.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.4-2-n.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.5.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.6.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.7.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.8.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.9.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Date/browser.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Date/shell.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/ExecutionContexts/10.1.3-1.js create mode 100755 tests/auto/qml/parserstress/tests/ecma/ExecutionContexts/10.1.3-2.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/ExecutionContexts/10.1.3.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/ExecutionContexts/10.1.4-1.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/ExecutionContexts/10.1.4-10.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/ExecutionContexts/10.1.4-2.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/ExecutionContexts/10.1.4-3.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/ExecutionContexts/10.1.4-4.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/ExecutionContexts/10.1.4-5.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/ExecutionContexts/10.1.4-6.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/ExecutionContexts/10.1.4-7.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/ExecutionContexts/10.1.4-8.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/ExecutionContexts/10.1.5-1.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/ExecutionContexts/10.1.5-2.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/ExecutionContexts/10.1.5-3.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/ExecutionContexts/10.1.5-4.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/ExecutionContexts/10.1.8-2.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/ExecutionContexts/10.1.8-3.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/ExecutionContexts/10.2.1.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/ExecutionContexts/10.2.2-1.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/ExecutionContexts/10.2.2-2.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/ExecutionContexts/10.2.3-1.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/ExecutionContexts/10.2.3-2.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/ExecutionContexts/browser.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/ExecutionContexts/shell.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Expressions/11.1.1.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Expressions/11.10-1.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Expressions/11.10-2.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Expressions/11.10-3.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Expressions/11.12-1.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Expressions/11.12-2-n.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Expressions/11.12-3.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Expressions/11.12-4.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Expressions/11.13.1.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Expressions/11.13.2-1.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Expressions/11.13.2-2.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Expressions/11.13.2-3.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Expressions/11.13.2-4.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Expressions/11.13.2-5.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Expressions/11.13.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Expressions/11.14-1.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Expressions/11.2.1-1.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Expressions/11.2.1-2.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Expressions/11.2.1-3-n.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Expressions/11.2.1-4-n.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Expressions/11.2.1-5.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Expressions/11.2.2-1-n.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Expressions/11.2.2-1.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Expressions/11.2.2-10-n.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Expressions/11.2.2-11.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Expressions/11.2.2-2-n.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Expressions/11.2.2-3-n.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Expressions/11.2.2-4-n.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Expressions/11.2.2-5-n.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Expressions/11.2.2-6-n.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Expressions/11.2.2-7-n.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Expressions/11.2.2-8-n.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Expressions/11.2.2-9-n.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Expressions/11.2.3-1.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Expressions/11.2.3-2-n.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Expressions/11.2.3-3-n.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Expressions/11.2.3-4-n.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Expressions/11.2.3-5.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Expressions/11.3.1.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Expressions/11.3.2.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Expressions/11.4.1.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Expressions/11.4.2.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Expressions/11.4.3.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Expressions/11.4.4.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Expressions/11.4.5.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Expressions/11.4.6.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Expressions/11.4.7-01.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Expressions/11.4.7-02.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Expressions/11.4.8.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Expressions/11.4.9.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Expressions/11.5.1.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Expressions/11.5.2.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Expressions/11.5.3.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Expressions/11.6.1-1.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Expressions/11.6.1-2.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Expressions/11.6.1-3.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Expressions/11.6.2-1.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Expressions/11.6.3.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Expressions/11.7.1.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Expressions/11.7.2.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Expressions/11.7.3.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Expressions/11.8.1.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Expressions/11.8.2.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Expressions/11.8.3.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Expressions/11.8.4.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Expressions/11.9.1.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Expressions/11.9.2.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Expressions/11.9.3.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Expressions/browser.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Expressions/shell.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/FunctionObjects/15.3.1.1-1.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/FunctionObjects/15.3.1.1-2.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/FunctionObjects/15.3.1.1-3.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/FunctionObjects/15.3.2.1-1.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/FunctionObjects/15.3.2.1-2.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/FunctionObjects/15.3.2.1-3.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/FunctionObjects/15.3.3.1-2.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/FunctionObjects/15.3.3.1-3.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/FunctionObjects/15.3.3.1-4.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/FunctionObjects/15.3.3.2.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/FunctionObjects/15.3.4-1.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/FunctionObjects/15.3.4.1.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/FunctionObjects/15.3.4.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/FunctionObjects/15.3.5-1.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/FunctionObjects/15.3.5-2.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/FunctionObjects/15.3.5.1.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/FunctionObjects/15.3.5.3.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/FunctionObjects/browser.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/FunctionObjects/shell.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/GlobalObject/15.1-1-n.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/GlobalObject/15.1-2-n.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/GlobalObject/15.1.1.1.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/GlobalObject/15.1.1.2.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/GlobalObject/15.1.2.1-2.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/GlobalObject/15.1.2.2-1.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/GlobalObject/15.1.2.2-2.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/GlobalObject/15.1.2.3-1.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/GlobalObject/15.1.2.3-2.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/GlobalObject/15.1.2.4.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/GlobalObject/15.1.2.5-1.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/GlobalObject/15.1.2.5-2.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/GlobalObject/15.1.2.5-3.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/GlobalObject/15.1.2.6.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/GlobalObject/15.1.2.7.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/GlobalObject/browser.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/GlobalObject/shell.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.1-1.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.1-2.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.1-3.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.2-1.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.2-2-n.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.2-3-n.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.2-4-n.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.2-5-n.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.2-6.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.3-1.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.3-10.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.3-11.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.3-12.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.3-13-n.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.3-2.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.3-3.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.3-4.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.3-5.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.3-6.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.3-7.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.3-8.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.3-9.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.1-1-n.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.1-2-n.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.1-3-n.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.2-1-n.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.2-10-n.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.2-11-n.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.2-12-n.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.2-13-n.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.2-14-n.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.2-15-n.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.2-16-n.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.2-2-n.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.2-3-n.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.2-4-n.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.2-5-n.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.2-6-n.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.2-7-n.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.2-8-n.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.2-9-n.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.3-1-n.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.3-10-n.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.3-11-n.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.3-12-n.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.3-13-n.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.3-14-n.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.3-15-n.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.3-16-n.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.3-2-n.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.3-3-n.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.3-4-n.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.3-5-n.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.3-6-n.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.3-7-n.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.3-8-n.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.3-9-n.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.5-1.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.5-10-n.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.5-2-n.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.5-3-n.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.5-4-n.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.5-5-n.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.5-6.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.5-7.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.5-8-n.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.5-9-n.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.6.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.7.1.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.7.2.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.7.3-1.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.7.3-2.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.7.3.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.7.4.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.8.2-n.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/LexicalConventions/browser.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/LexicalConventions/shell.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Math/15.8-2-n.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Math/15.8-3-n.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Math/15.8.1.1-1.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Math/15.8.1.1-2.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Math/15.8.1.2-1.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Math/15.8.1.2-2.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Math/15.8.1.3-1.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Math/15.8.1.3-2.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Math/15.8.1.4-1.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Math/15.8.1.4-2.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Math/15.8.1.5-1.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Math/15.8.1.5-2.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Math/15.8.1.6-1.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Math/15.8.1.6-2.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Math/15.8.1.7-1.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Math/15.8.1.7-2.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Math/15.8.1.8-1.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Math/15.8.1.8-2.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Math/15.8.1.8-3.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Math/15.8.1.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Math/15.8.2.1.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Math/15.8.2.10.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Math/15.8.2.11.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Math/15.8.2.12.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Math/15.8.2.13.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Math/15.8.2.14.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Math/15.8.2.15.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Math/15.8.2.16.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Math/15.8.2.17.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Math/15.8.2.18.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Math/15.8.2.2.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Math/15.8.2.3.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Math/15.8.2.4.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Math/15.8.2.5.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Math/15.8.2.6.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Math/15.8.2.7.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Math/15.8.2.8.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Math/15.8.2.9.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Math/browser.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Math/shell.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/NativeObjects/browser.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/NativeObjects/shell.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Number/15.7.1.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Number/15.7.2.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Number/15.7.3.1-1.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Number/15.7.3.1-2.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Number/15.7.3.1-3.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Number/15.7.3.2-1.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Number/15.7.3.2-2.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Number/15.7.3.2-3.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Number/15.7.3.2-4.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Number/15.7.3.3-1.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Number/15.7.3.3-2.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Number/15.7.3.3-3.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Number/15.7.3.3-4.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Number/15.7.3.4-1.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Number/15.7.3.4-2.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Number/15.7.3.4-3.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Number/15.7.3.4-4.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Number/15.7.3.5-1.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Number/15.7.3.5-2.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Number/15.7.3.5-3.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Number/15.7.3.5-4.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Number/15.7.3.6-1.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Number/15.7.3.6-2.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Number/15.7.3.6-3.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Number/15.7.3.6-4.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Number/15.7.3.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Number/15.7.4-1.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Number/15.7.4.1.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Number/15.7.4.2-1.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Number/15.7.4.2-2-n.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Number/15.7.4.2-3-n.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Number/15.7.4.2-4.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Number/15.7.4.3-1.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Number/15.7.4.3-2.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Number/15.7.4.3-3-n.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Number/browser.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Number/shell.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/ObjectObjects/15.2.1.1.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/ObjectObjects/15.2.1.2.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/ObjectObjects/15.2.2.1.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/ObjectObjects/15.2.2.2.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/ObjectObjects/15.2.3-1.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/ObjectObjects/15.2.3.1-1.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/ObjectObjects/15.2.3.1-2.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/ObjectObjects/15.2.3.1-3.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/ObjectObjects/15.2.3.1-4.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/ObjectObjects/15.2.3.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/ObjectObjects/15.2.4.1.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/ObjectObjects/15.2.4.2.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/ObjectObjects/15.2.4.3.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/ObjectObjects/browser.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/ObjectObjects/shell.js create mode 100755 tests/auto/qml/parserstress/tests/ecma/README create mode 100644 tests/auto/qml/parserstress/tests/ecma/SourceText/6-1.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/SourceText/6-2.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/SourceText/browser.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/SourceText/shell.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Statements/12.10-1.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Statements/12.10.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Statements/12.2-1.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Statements/12.5-1.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Statements/12.5-2.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Statements/12.6.1-1.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Statements/12.6.2-1.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Statements/12.6.2-2.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Statements/12.6.2-3.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Statements/12.6.2-4.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Statements/12.6.2-5.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Statements/12.6.2-6.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Statements/12.6.2-7.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Statements/12.6.2-8.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Statements/12.6.2-9-n.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Statements/12.6.3-1.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Statements/12.6.3-10.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Statements/12.6.3-11.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Statements/12.6.3-12.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Statements/12.6.3-19.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Statements/12.6.3-2.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Statements/12.6.3-3.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Statements/12.6.3-4.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Statements/12.6.3-5-n.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Statements/12.6.3-6-n.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Statements/12.6.3-7-n.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Statements/12.6.3-8-n.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Statements/12.6.3-9-n.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Statements/12.7-1-n.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Statements/12.8-1-n.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Statements/12.9-1-n.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Statements/browser.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Statements/shell.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/String/15.5.1.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/String/15.5.2.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/String/15.5.3.1-1.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/String/15.5.3.1-2.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/String/15.5.3.1-3.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/String/15.5.3.1-4.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/String/15.5.3.2-1.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/String/15.5.3.2-2.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/String/15.5.3.2-3.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/String/15.5.3.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/String/15.5.4.1.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/String/15.5.4.10-1.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/String/15.5.4.11-1.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/String/15.5.4.11-2.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/String/15.5.4.11-3.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/String/15.5.4.11-4.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/String/15.5.4.11-5.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/String/15.5.4.11-6.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/String/15.5.4.12-1.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/String/15.5.4.12-2.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/String/15.5.4.12-3.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/String/15.5.4.12-4.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/String/15.5.4.12-5.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/String/15.5.4.2-1.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/String/15.5.4.2-2-n.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/String/15.5.4.2-3.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/String/15.5.4.2.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/String/15.5.4.3-1.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/String/15.5.4.3-2.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/String/15.5.4.3-3-n.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/String/15.5.4.4-1.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/String/15.5.4.4-2.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/String/15.5.4.4-3.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/String/15.5.4.4-4.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/String/15.5.4.5-1.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/String/15.5.4.5-2.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/String/15.5.4.5-3.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/String/15.5.4.5-4.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/String/15.5.4.5-5.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/String/15.5.4.6-1.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/String/15.5.4.6-2.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/String/15.5.4.7-1.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/String/15.5.4.7-2.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/String/15.5.4.8-1.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/String/15.5.4.8-2.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/String/15.5.4.8-3.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/String/15.5.4.9-1.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/String/15.5.4.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/String/15.5.5.1.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/String/browser.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/String/shell.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/TypeConversion/9.2.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/TypeConversion/9.3-1.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/TypeConversion/9.3.1-1.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/TypeConversion/9.3.1-2.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/TypeConversion/9.3.1-3.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/TypeConversion/9.3.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/TypeConversion/9.4-1.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/TypeConversion/9.4-2.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/TypeConversion/9.5-2.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/TypeConversion/9.6.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/TypeConversion/9.7.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/TypeConversion/9.8.1.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/TypeConversion/9.9-1.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/TypeConversion/browser.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/TypeConversion/shell.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Types/8.1.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Types/8.4.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Types/8.6.2.1-1.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Types/browser.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/Types/shell.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/browser.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/extensions/10.1.4-9.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/extensions/10.1.6.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/extensions/10.1.8-1.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/extensions/11.6.1-1.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/extensions/11.6.1-2.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/extensions/11.6.1-3.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/extensions/11.6.2-1.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/extensions/15-1.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/extensions/15-2.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/extensions/15.1.2.1-1.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/extensions/15.2.1.1.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/extensions/15.2.3-1.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/extensions/15.2.4.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/extensions/15.3.1.1-1.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/extensions/15.3.1.1-2.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/extensions/15.3.2.1-1.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/extensions/15.3.2.1-2.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/extensions/15.3.3.1-1.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/extensions/15.4.3.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/extensions/15.5.3.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/extensions/15.5.4.2.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/extensions/15.5.4.4-4.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/extensions/15.5.4.5-6.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/extensions/15.5.4.7-3.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/extensions/15.6.3.1-5.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/extensions/15.6.3.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/extensions/15.6.4-2.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/extensions/15.7.3.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/extensions/15.7.4.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/extensions/15.8-1.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/extensions/15.9.5.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/extensions/8.6.2.1-1.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/extensions/9.9-1.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/extensions/browser.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/extensions/shell.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/jsref.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/shell.js create mode 100644 tests/auto/qml/parserstress/tests/ecma/template.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_2/Exceptions/boolean-001.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_2/Exceptions/boolean-002.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_2/Exceptions/browser.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_2/Exceptions/date-001.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_2/Exceptions/date-002.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_2/Exceptions/date-003.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_2/Exceptions/date-004.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_2/Exceptions/exception-001.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_2/Exceptions/exception-002.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_2/Exceptions/exception-003.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_2/Exceptions/exception-004.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_2/Exceptions/exception-005.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_2/Exceptions/exception-006.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_2/Exceptions/exception-007.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_2/Exceptions/exception-008.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_2/Exceptions/exception-009.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_2/Exceptions/exception-010-n.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_2/Exceptions/exception-011-n.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_2/Exceptions/expression-001.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_2/Exceptions/expression-002.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_2/Exceptions/expression-003.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_2/Exceptions/expression-004.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_2/Exceptions/expression-005.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_2/Exceptions/expression-006.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_2/Exceptions/expression-007.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_2/Exceptions/expression-008.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_2/Exceptions/expression-009.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_2/Exceptions/expression-010.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_2/Exceptions/expression-011.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_2/Exceptions/expression-012.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_2/Exceptions/expression-013.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_2/Exceptions/expression-014.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_2/Exceptions/expression-015.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_2/Exceptions/expression-016.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_2/Exceptions/expression-017.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_2/Exceptions/expression-019.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_2/Exceptions/function-001.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_2/Exceptions/global-001.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_2/Exceptions/global-002.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-001.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-002.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-003.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-004.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-005.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-006.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-007.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-008.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-009.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-010.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-011.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-012.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-013.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-014.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-015.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-016.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-017.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-018.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-019.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-020.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-021.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-022.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-023.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-024.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-025.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-026.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-027.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-028.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-029.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-030.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-031.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-032.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-033.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-034.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-035.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-036.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-037.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-038.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-039.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-040.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-041.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-042.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-047.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-048.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-049.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-050.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-051.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-052.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-053.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-054.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_2/Exceptions/number-001.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_2/Exceptions/number-002.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_2/Exceptions/number-003.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_2/Exceptions/shell.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_2/Exceptions/statement-001.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_2/Exceptions/statement-002.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_2/Exceptions/statement-003.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_2/Exceptions/statement-004.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_2/Exceptions/statement-005.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_2/Exceptions/statement-006.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_2/Exceptions/statement-007.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_2/Exceptions/statement-008.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_2/Exceptions/statement-009.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_2/Exceptions/string-001.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_2/Exceptions/string-002.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_2/Expressions/StrictEquality-001.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_2/Expressions/browser.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_2/Expressions/shell.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_2/FunctionObjects/apply-001-n.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_2/FunctionObjects/browser.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_2/FunctionObjects/call-1.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_2/FunctionObjects/shell.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_2/LexicalConventions/browser.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_2/LexicalConventions/keywords-001.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_2/LexicalConventions/regexp-literals-001.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_2/LexicalConventions/regexp-literals-002.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_2/LexicalConventions/shell.js create mode 100755 tests/auto/qml/parserstress/tests/ecma_2/README create mode 100644 tests/auto/qml/parserstress/tests/ecma_2/RegExp/browser.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_2/RegExp/constructor-001.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_2/RegExp/exec-001.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_2/RegExp/exec-002.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_2/RegExp/function-001.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_2/RegExp/hex-001.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_2/RegExp/multiline-001.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_2/RegExp/octal-001.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_2/RegExp/octal-002.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_2/RegExp/octal-003.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_2/RegExp/properties-001.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_2/RegExp/properties-002.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_2/RegExp/regexp-enumerate-001.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_2/RegExp/regress-001.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_2/RegExp/shell.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_2/RegExp/unicode-001.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_2/Statements/browser.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_2/Statements/dowhile-001.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_2/Statements/dowhile-002.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_2/Statements/dowhile-003.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_2/Statements/dowhile-004.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_2/Statements/dowhile-005.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_2/Statements/dowhile-006.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_2/Statements/dowhile-007.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_2/Statements/forin-001.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_2/Statements/forin-002.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_2/Statements/if-001.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_2/Statements/label-001.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_2/Statements/label-002.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_2/Statements/shell.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_2/Statements/switch-001.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_2/Statements/switch-002.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_2/Statements/switch-003.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_2/Statements/switch-004.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_2/Statements/try-001.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_2/Statements/try-003.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_2/Statements/try-004.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_2/Statements/try-005.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_2/Statements/try-006.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_2/Statements/try-007.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_2/Statements/try-008.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_2/Statements/try-009.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_2/Statements/try-010.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_2/Statements/try-012.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_2/Statements/while-001.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_2/Statements/while-002.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_2/Statements/while-003.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_2/Statements/while-004.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_2/String/browser.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_2/String/match-001.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_2/String/match-002.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_2/String/match-003.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_2/String/match-004.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_2/String/replace-001.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_2/String/shell.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_2/String/split-001.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_2/String/split-002.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_2/String/split-003.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_2/browser.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_2/extensions/browser.js create mode 100755 tests/auto/qml/parserstress/tests/ecma_2/extensions/constructor-001.js create mode 100755 tests/auto/qml/parserstress/tests/ecma_2/extensions/function-001.js create mode 100755 tests/auto/qml/parserstress/tests/ecma_2/extensions/instanceof-001.js create mode 100755 tests/auto/qml/parserstress/tests/ecma_2/extensions/instanceof-002.js create mode 100755 tests/auto/qml/parserstress/tests/ecma_2/extensions/instanceof-003-n.js create mode 100755 tests/auto/qml/parserstress/tests/ecma_2/extensions/instanceof-004-n.js create mode 100755 tests/auto/qml/parserstress/tests/ecma_2/extensions/instanceof-005-n.js create mode 100755 tests/auto/qml/parserstress/tests/ecma_2/extensions/instanceof-006.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_2/extensions/shell.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_2/instanceof/browser.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_2/instanceof/instanceof-001.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_2/instanceof/instanceof-002.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_2/instanceof/instanceof-003.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_2/instanceof/regress-7635.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_2/instanceof/shell.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_2/jsref.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_2/shell.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_2/template.js create mode 100755 tests/auto/qml/parserstress/tests/ecma_3/Array/15.4.4.11-01.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_3/Array/15.4.4.3-1.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_3/Array/15.4.4.4-001.js create mode 100755 tests/auto/qml/parserstress/tests/ecma_3/Array/15.4.5.1-01.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_3/Array/browser.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_3/Array/regress-101488.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_3/Array/regress-130451.js create mode 100755 tests/auto/qml/parserstress/tests/ecma_3/Array/regress-322135-01.js create mode 100755 tests/auto/qml/parserstress/tests/ecma_3/Array/regress-322135-02.js create mode 100755 tests/auto/qml/parserstress/tests/ecma_3/Array/regress-322135-03.js create mode 100755 tests/auto/qml/parserstress/tests/ecma_3/Array/regress-322135-04.js create mode 100755 tests/auto/qml/parserstress/tests/ecma_3/Array/regress-387501.js create mode 100755 tests/auto/qml/parserstress/tests/ecma_3/Array/regress-421325.js create mode 100755 tests/auto/qml/parserstress/tests/ecma_3/Array/regress-430717.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_3/Array/shell.js create mode 100755 tests/auto/qml/parserstress/tests/ecma_3/Date/15.9.1.2-01.js create mode 100755 tests/auto/qml/parserstress/tests/ecma_3/Date/15.9.3.2-1.js create mode 100755 tests/auto/qml/parserstress/tests/ecma_3/Date/15.9.4.3.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_3/Date/15.9.5.3.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_3/Date/15.9.5.4.js create mode 100755 tests/auto/qml/parserstress/tests/ecma_3/Date/15.9.5.5-02.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_3/Date/15.9.5.5.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_3/Date/15.9.5.6.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_3/Date/15.9.5.7.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_3/Date/browser.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_3/Date/shell.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_3/Exceptions/15.11.1.1.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_3/Exceptions/15.11.4.4-1.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_3/Exceptions/15.11.7.6-001.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_3/Exceptions/15.11.7.6-002.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_3/Exceptions/15.11.7.6-003.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_3/Exceptions/binding-001.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_3/Exceptions/browser.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_3/Exceptions/regress-181654.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_3/Exceptions/regress-181914.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_3/Exceptions/regress-58946.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_3/Exceptions/regress-95101.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_3/Exceptions/shell.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_3/ExecutionContexts/10.1.3-1.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_3/ExecutionContexts/10.1.3-2.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_3/ExecutionContexts/10.1.3.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_3/ExecutionContexts/10.1.4-1.js create mode 100755 tests/auto/qml/parserstress/tests/ecma_3/ExecutionContexts/10.6.1-01.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_3/ExecutionContexts/browser.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_3/ExecutionContexts/regress-23346.js create mode 100755 tests/auto/qml/parserstress/tests/ecma_3/ExecutionContexts/regress-448595-01.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_3/ExecutionContexts/shell.js create mode 100755 tests/auto/qml/parserstress/tests/ecma_3/Expressions/11.10-01.js create mode 100755 tests/auto/qml/parserstress/tests/ecma_3/Expressions/11.10-02.js create mode 100755 tests/auto/qml/parserstress/tests/ecma_3/Expressions/11.10-03.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_3/Expressions/11.6.1-1.js create mode 100755 tests/auto/qml/parserstress/tests/ecma_3/Expressions/11.7.1-01.js create mode 100755 tests/auto/qml/parserstress/tests/ecma_3/Expressions/11.7.2-01.js create mode 100755 tests/auto/qml/parserstress/tests/ecma_3/Expressions/11.7.3-01.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_3/Expressions/11.9.6-1.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_3/Expressions/browser.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_3/Expressions/shell.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_3/FunExpr/browser.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_3/FunExpr/fe-001-n.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_3/FunExpr/fe-001.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_3/FunExpr/fe-002.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_3/FunExpr/shell.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_3/Function/15.3.4.3-1.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_3/Function/15.3.4.4-1.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_3/Function/arguments-001.js create mode 100755 tests/auto/qml/parserstress/tests/ecma_3/Function/arguments-002.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_3/Function/browser.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_3/Function/call-001.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_3/Function/regress-131964.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_3/Function/regress-137181.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_3/Function/regress-193555.js create mode 100755 tests/auto/qml/parserstress/tests/ecma_3/Function/regress-313570.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_3/Function/regress-49286.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_3/Function/regress-58274.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_3/Function/regress-85880.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_3/Function/regress-94506.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_3/Function/regress-97921.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_3/Function/scope-001.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_3/Function/scope-002.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_3/Function/shell.js create mode 100755 tests/auto/qml/parserstress/tests/ecma_3/LexicalConventions/7.9.1.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_3/LexicalConventions/browser.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_3/LexicalConventions/shell.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_3/Number/15.7.4.2-01.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_3/Number/15.7.4.3-01.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_3/Number/15.7.4.3-02.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_3/Number/15.7.4.5-1.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_3/Number/15.7.4.6-1.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_3/Number/15.7.4.7-1.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_3/Number/15.7.4.7-2.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_3/Number/browser.js create mode 100755 tests/auto/qml/parserstress/tests/ecma_3/Number/regress-442242-01.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_3/Number/shell.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_3/NumberFormatting/browser.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_3/NumberFormatting/shell.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_3/NumberFormatting/tostring-001.js create mode 100755 tests/auto/qml/parserstress/tests/ecma_3/Object/8.6.1-01.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_3/Object/8.6.2.6-001.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_3/Object/browser.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_3/Object/class-001.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_3/Object/class-002.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_3/Object/class-003.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_3/Object/class-004.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_3/Object/class-005.js create mode 100755 tests/auto/qml/parserstress/tests/ecma_3/Object/regress-361274.js create mode 100755 tests/auto/qml/parserstress/tests/ecma_3/Object/regress-385393-07.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_3/Object/regress-72773.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_3/Object/regress-79129-001.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_3/Object/shell.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_3/Operators/11.13.1-001.js create mode 100755 tests/auto/qml/parserstress/tests/ecma_3/Operators/11.13.1-002.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_3/Operators/11.4.1-001.js create mode 100755 tests/auto/qml/parserstress/tests/ecma_3/Operators/11.4.1-002.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_3/Operators/browser.js create mode 100755 tests/auto/qml/parserstress/tests/ecma_3/Operators/order-01.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_3/Operators/shell.js create mode 100755 tests/auto/qml/parserstress/tests/ecma_3/README create mode 100644 tests/auto/qml/parserstress/tests/ecma_3/RegExp/15.10.2-1.js create mode 100755 tests/auto/qml/parserstress/tests/ecma_3/RegExp/15.10.2.12.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_3/RegExp/15.10.3.1-1.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_3/RegExp/15.10.3.1-2.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_3/RegExp/15.10.4.1-1.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_3/RegExp/15.10.4.1-2.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_3/RegExp/15.10.4.1-3.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_3/RegExp/15.10.4.1-4.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_3/RegExp/15.10.4.1-5-n.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_3/RegExp/15.10.6.2-1.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_3/RegExp/15.10.6.2-2.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_3/RegExp/browser.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_3/RegExp/octal-001.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_3/RegExp/octal-002.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_3/RegExp/perlstress-001.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_3/RegExp/perlstress-002.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-100199.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-105972.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-119909.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-122076.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-123437.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-165353.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-169497.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-169534.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-187133.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-188206.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-191479.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-202564.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-209067.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-209919.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-216591.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-220367-001.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-223273.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-223535.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-224676.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-225289.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-225343.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-24712.js create mode 100755 tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-285219.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-28686.js create mode 100755 tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-289669.js create mode 100755 tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-307456.js create mode 100755 tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-309840.js create mode 100755 tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-311414.js create mode 100755 tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-312351.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-31316.js create mode 100755 tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-330684.js create mode 100755 tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-334158.js create mode 100755 tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-346090.js create mode 100755 tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-367888.js create mode 100755 tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-375642.js create mode 100755 tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-375711.js create mode 100755 tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-375715-01-n.js create mode 100755 tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-375715-02.js create mode 100755 tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-375715-03.js create mode 100755 tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-375715-04.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-57572.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-57631.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-67773.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-72964.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-76683.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-78156.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-85721.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-87231.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-98306.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_3/RegExp/shell.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_3/Regress/browser.js create mode 100755 tests/auto/qml/parserstress/tests/ecma_3/Regress/regress-385393-04.js create mode 100755 tests/auto/qml/parserstress/tests/ecma_3/Regress/regress-419152.js create mode 100755 tests/auto/qml/parserstress/tests/ecma_3/Regress/regress-420087.js create mode 100755 tests/auto/qml/parserstress/tests/ecma_3/Regress/regress-420610.js create mode 100755 tests/auto/qml/parserstress/tests/ecma_3/Regress/regress-441477-01.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_3/Regress/shell.js create mode 100755 tests/auto/qml/parserstress/tests/ecma_3/Statements/12.6.3.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_3/Statements/browser.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_3/Statements/regress-121744.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_3/Statements/regress-131348.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_3/Statements/regress-157509.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_3/Statements/regress-194364.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_3/Statements/regress-226517.js create mode 100755 tests/auto/qml/parserstress/tests/ecma_3/Statements/regress-302439.js create mode 100755 tests/auto/qml/parserstress/tests/ecma_3/Statements/regress-324650.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_3/Statements/regress-74474-001.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_3/Statements/regress-74474-002.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_3/Statements/regress-74474-003.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_3/Statements/regress-83532-001.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_3/Statements/regress-83532-002.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_3/Statements/shell.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_3/Statements/switch-001.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_3/String/15.5.4.11.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_3/String/15.5.4.14.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_3/String/browser.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_3/String/regress-104375.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_3/String/regress-189898.js create mode 100755 tests/auto/qml/parserstress/tests/ecma_3/String/regress-304376.js create mode 100755 tests/auto/qml/parserstress/tests/ecma_3/String/regress-313567.js create mode 100755 tests/auto/qml/parserstress/tests/ecma_3/String/regress-392378.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_3/String/regress-83293.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_3/String/shell.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_3/Unicode/browser.js create mode 100755 tests/auto/qml/parserstress/tests/ecma_3/Unicode/regress-352044-01.js create mode 100755 tests/auto/qml/parserstress/tests/ecma_3/Unicode/regress-352044-02-n.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_3/Unicode/shell.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_3/Unicode/uc-001-n.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_3/Unicode/uc-001.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_3/Unicode/uc-002-n.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_3/Unicode/uc-002.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_3/Unicode/uc-003.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_3/Unicode/uc-004.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_3/Unicode/uc-005.js create mode 100755 tests/auto/qml/parserstress/tests/ecma_3/browser.js create mode 100755 tests/auto/qml/parserstress/tests/ecma_3/extensions/10.1.3-2.js create mode 100755 tests/auto/qml/parserstress/tests/ecma_3/extensions/7.9.1.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_3/extensions/browser.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_3/extensions/regress-103087.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_3/extensions/regress-188206-01.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_3/extensions/regress-188206-02.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_3/extensions/regress-220367-002.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_3/extensions/regress-228087.js create mode 100755 tests/auto/qml/parserstress/tests/ecma_3/extensions/regress-274152.js create mode 100755 tests/auto/qml/parserstress/tests/ecma_3/extensions/regress-320854.js create mode 100755 tests/auto/qml/parserstress/tests/ecma_3/extensions/regress-327170.js create mode 100755 tests/auto/qml/parserstress/tests/ecma_3/extensions/regress-368516.js create mode 100755 tests/auto/qml/parserstress/tests/ecma_3/extensions/regress-385393-03.js create mode 100755 tests/auto/qml/parserstress/tests/ecma_3/extensions/regress-429248.js create mode 100755 tests/auto/qml/parserstress/tests/ecma_3/extensions/regress-430740.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_3/extensions/shell.js create mode 100644 tests/auto/qml/parserstress/tests/ecma_3/shell.js create mode 100755 tests/auto/qml/parserstress/tests/ecma_3/template.js create mode 100644 tests/auto/qml/parserstress/tests/shell.js create mode 100644 tests/auto/qml/parserstress/tst_parserstress.cpp create mode 100644 tests/auto/qml/qjsengine/qjsengine.pro create mode 100644 tests/auto/qml/qjsengine/script/com/__init__.js create mode 100644 tests/auto/qml/qjsengine/script/com/trolltech/__init__.js create mode 100644 tests/auto/qml/qjsengine/script/com/trolltech/recursive/__init__.js create mode 100644 tests/auto/qml/qjsengine/script/com/trolltech/syntaxerror/__init__.js create mode 100644 tests/auto/qml/qjsengine/tst_qjsengine.cpp create mode 100644 tests/auto/qml/qjsvalue/qjsvalue.pro create mode 100644 tests/auto/qml/qjsvalue/tst_qjsvalue.cpp create mode 100644 tests/auto/qml/qjsvalue/tst_qjsvalue.h create mode 100644 tests/auto/qml/qjsvalueiterator/qjsvalueiterator.pro create mode 100644 tests/auto/qml/qjsvalueiterator/tst_qjsvalueiterator.cpp create mode 100644 tests/auto/qml/qml.pro create mode 100644 tests/auto/qml/qmlmin/qmlmin.pro create mode 100644 tests/auto/qml/qmlmin/tst_qmlmin.cpp create mode 100644 tests/auto/qml/qmlplugindump/qmlplugindump.pro create mode 100644 tests/auto/qml/qmlplugindump/tst_qmlplugindump.cpp create mode 100644 tests/auto/qml/qqmlcomponent/data/createObject.qml create mode 100644 tests/auto/qml/qqmlcomponent/data/createObjectWithScript.qml create mode 100644 tests/auto/qml/qqmlcomponent/data/incubateObject.qml create mode 100644 tests/auto/qml/qqmlcomponent/qqmlcomponent.pro create mode 100644 tests/auto/qml/qqmlcomponent/tst_qqmlcomponent.cpp create mode 100644 tests/auto/qml/qqmlconsole/data/assert.qml create mode 100644 tests/auto/qml/qqmlconsole/data/exception.qml create mode 100644 tests/auto/qml/qqmlconsole/data/logging.qml create mode 100644 tests/auto/qml/qqmlconsole/data/profiling.qml create mode 100644 tests/auto/qml/qqmlconsole/data/tracing.qml create mode 100644 tests/auto/qml/qqmlconsole/qqmlconsole.pro create mode 100644 tests/auto/qml/qqmlconsole/tst_qqmlconsole.cpp create mode 100644 tests/auto/qml/qqmlcontext/data/Object_22535.qml create mode 100644 tests/auto/qml/qqmlcontext/data/RefreshExpressionsType.qml create mode 100644 tests/auto/qml/qqmlcontext/data/qtbug_22535.qml create mode 100644 tests/auto/qml/qqmlcontext/data/refreshExpressions.qml create mode 100644 tests/auto/qml/qqmlcontext/data/refreshExpressionsRootContext.qml create mode 100644 tests/auto/qml/qqmlcontext/qqmlcontext.pro create mode 100644 tests/auto/qml/qqmlcontext/tst_qqmlcontext.cpp create mode 100644 tests/auto/qml/qqmlcpputils/qqmlcpputils.pro create mode 100644 tests/auto/qml/qqmlcpputils/tst_qqmlcpputils.cpp create mode 100644 tests/auto/qml/qqmlecmascript/data/AliasBindingsAssignCorrectlyType.qml create mode 100644 tests/auto/qml/qqmlecmascript/data/AliasBindingsOverrideTargetType.qml create mode 100644 tests/auto/qml/qqmlecmascript/data/AliasBindingsOverrideTargetType3.qml create mode 100644 tests/auto/qml/qqmlecmascript/data/AliasToCompositeElementType1.qml create mode 100644 tests/auto/qml/qqmlecmascript/data/AliasToCompositeElementType2.qml create mode 100644 tests/auto/qml/qqmlecmascript/data/ConstantsOverrideBindings.qml create mode 100644 tests/auto/qml/qqmlecmascript/data/CustomObject.qml create mode 100644 tests/auto/qml/qqmlecmascript/data/ElementAssignType.qml create mode 100644 tests/auto/qml/qqmlecmascript/data/MethodsObject.qml create mode 100644 tests/auto/qml/qqmlecmascript/data/NestedTypeTransientErrors.qml create mode 100644 tests/auto/qml/qqmlecmascript/data/PropertyVarBaseItem.qml create mode 100644 tests/auto/qml/qqmlecmascript/data/PropertyVarCircularComponent.qml create mode 100644 tests/auto/qml/qqmlecmascript/data/PropertyVarCircularComponent2.qml create mode 100644 tests/auto/qml/qqmlecmascript/data/PropertyVarCircularComponent3.qml create mode 100644 tests/auto/qml/qqmlecmascript/data/PropertyVarCircularComponent4.qml create mode 100644 tests/auto/qml/qqmlecmascript/data/PropertyVarCircularComponent5.qml create mode 100644 tests/auto/qml/qqmlecmascript/data/PropertyVarInheritanceComponent.qml create mode 100644 tests/auto/qml/qqmlecmascript/data/PropertyVarOwnershipComponent.qml create mode 100644 tests/auto/qml/qqmlecmascript/data/ScarceResourceSignalComponentVar.qml create mode 100644 tests/auto/qml/qqmlecmascript/data/ScarceResourceSignalComponentVariant.qml create mode 100644 tests/auto/qml/qqmlecmascript/data/ScarceResourceVarComponent.qml create mode 100644 tests/auto/qml/qqmlecmascript/data/Scope6Nested.qml create mode 100644 tests/auto/qml/qqmlecmascript/data/ScopeObject.qml create mode 100644 tests/auto/qml/qqmlecmascript/data/SequenceConversionComponent.qml create mode 100644 tests/auto/qml/qqmlecmascript/data/SpuriousWarning.qml create mode 100644 tests/auto/qml/qqmlecmascript/data/TypeForDynamicCreation.qml create mode 100644 tests/auto/qml/qqmlecmascript/data/aliasBindingsAssignCorrectly.qml create mode 100644 tests/auto/qml/qqmlecmascript/data/aliasBindingsOverrideTarget.2.qml create mode 100644 tests/auto/qml/qqmlecmascript/data/aliasBindingsOverrideTarget.3.qml create mode 100644 tests/auto/qml/qqmlecmascript/data/aliasBindingsOverrideTarget.qml create mode 100644 tests/auto/qml/qqmlecmascript/data/aliasPropertyAndBinding.qml create mode 100644 tests/auto/qml/qqmlecmascript/data/aliasToCompositeElement.qml create mode 100644 tests/auto/qml/qqmlecmascript/data/aliasWritesOverrideBindings.2.qml create mode 100644 tests/auto/qml/qqmlecmascript/data/aliasWritesOverrideBindings.3.qml create mode 100644 tests/auto/qml/qqmlecmascript/data/aliasWritesOverrideBindings.qml create mode 100644 tests/auto/qml/qqmlecmascript/data/aliasreset/AliasPropertyComponent.qml create mode 100644 tests/auto/qml/qqmlecmascript/data/aliasreset/aliasPropertyReset.1.qml create mode 100644 tests/auto/qml/qqmlecmascript/data/aliasreset/aliasPropertyReset.2.qml create mode 100644 tests/auto/qml/qqmlecmascript/data/aliasreset/aliasPropertyReset.3.qml create mode 100644 tests/auto/qml/qqmlecmascript/data/aliasreset/aliasPropertyReset.4.qml create mode 100644 tests/auto/qml/qqmlecmascript/data/aliasreset/aliasPropertyReset.5.qml create mode 100644 tests/auto/qml/qqmlecmascript/data/aliasreset/aliasPropertyReset.error.1.qml create mode 100644 tests/auto/qml/qqmlecmascript/data/assignBasicTypes.2.qml create mode 100644 tests/auto/qml/qqmlecmascript/data/assignBasicTypes.qml create mode 100644 tests/auto/qml/qqmlecmascript/data/assignSequenceTypes.1.qml create mode 100644 tests/auto/qml/qqmlecmascript/data/assignSequenceTypes.2.qml create mode 100644 tests/auto/qml/qqmlecmascript/data/assignSequenceTypes.3.qml create mode 100644 tests/auto/qml/qqmlecmascript/data/assignSequenceTypes.4.qml create mode 100644 tests/auto/qml/qqmlecmascript/data/assignSequenceTypes.5.qml create mode 100644 tests/auto/qml/qqmlecmascript/data/assignSequenceTypes.6.qml create mode 100644 tests/auto/qml/qqmlecmascript/data/assignSequenceTypes.7.qml create mode 100644 tests/auto/qml/qqmlecmascript/data/attachedProperty.2.qml create mode 100644 tests/auto/qml/qqmlecmascript/data/attachedProperty.qml create mode 100644 tests/auto/qml/qqmlecmascript/data/attachedPropertyScope.qml create mode 100644 tests/auto/qml/qqmlecmascript/data/automaticSemicolon.qml create mode 100644 tests/auto/qml/qqmlecmascript/data/bindingLoop.qml create mode 100644 tests/auto/qml/qqmlecmascript/data/blank.js create mode 100644 tests/auto/qml/qqmlecmascript/data/boolPropertiesEvaluateAsBool.1.qml create mode 100644 tests/auto/qml/qqmlecmascript/data/boolPropertiesEvaluateAsBool.2.qml create mode 100644 tests/auto/qml/qqmlecmascript/data/booleanConversion.qml create mode 100644 tests/auto/qml/qqmlecmascript/data/bug.1.qml create mode 100644 tests/auto/qml/qqmlecmascript/data/canAssignNullToQObject.1.qml create mode 100644 tests/auto/qml/qqmlecmascript/data/canAssignNullToQObject.2.qml create mode 100644 tests/auto/qml/qqmlecmascript/data/changeslots/propertyChangeSlotErrors.1.qml create mode 100644 tests/auto/qml/qqmlecmascript/data/changeslots/propertyChangeSlotErrors.2.qml create mode 100644 tests/auto/qml/qqmlecmascript/data/changeslots/propertyChangeSlotErrors.3.qml create mode 100644 tests/auto/qml/qqmlecmascript/data/changeslots/propertyChangeSlotErrors.4.qml create mode 100644 tests/auto/qml/qqmlecmascript/data/changeslots/propertyChangeSlots.qml create mode 100644 tests/auto/qml/qqmlecmascript/data/compiled.qml create mode 100644 tests/auto/qml/qqmlecmascript/data/compositePropertyType.qml create mode 100644 tests/auto/qml/qqmlecmascript/data/constantsOverrideBindings.1.qml create mode 100644 tests/auto/qml/qqmlecmascript/data/constantsOverrideBindings.2.qml create mode 100644 tests/auto/qml/qqmlecmascript/data/constantsOverrideBindings.3.qml create mode 100644 tests/auto/qml/qqmlecmascript/data/constantsOverrideBindings.4.qml create mode 100644 tests/auto/qml/qqmlecmascript/data/deferredProperties.qml create mode 100644 tests/auto/qml/qqmlecmascript/data/deferredPropertiesErrors.qml create mode 100644 tests/auto/qml/qqmlecmascript/data/deleteLater.qml create mode 100644 tests/auto/qml/qqmlecmascript/data/deleteWhileBindingRunning.qml create mode 100644 tests/auto/qml/qqmlecmascript/data/deletedEngine.qml create mode 100644 tests/auto/qml/qqmlecmascript/data/deletedObject.qml create mode 100644 tests/auto/qml/qqmlecmascript/data/doubleEvaluate.qml create mode 100644 tests/auto/qml/qqmlecmascript/data/dynamicCreation.helper.qml create mode 100644 tests/auto/qml/qqmlecmascript/data/dynamicCreation.qml create mode 100644 tests/auto/qml/qqmlecmascript/data/dynamicCreationOwnership.qml create mode 100644 tests/auto/qml/qqmlecmascript/data/dynamicDeletion.2.qml create mode 100644 tests/auto/qml/qqmlecmascript/data/dynamicDeletion.qml create mode 100644 tests/auto/qml/qqmlecmascript/data/dynamicString.qml create mode 100644 tests/auto/qml/qqmlecmascript/data/elementAssign.qml create mode 100644 tests/auto/qml/qqmlecmascript/data/enums.1.qml create mode 100644 tests/auto/qml/qqmlecmascript/data/enums.2.qml create mode 100644 tests/auto/qml/qqmlecmascript/data/eval.qml create mode 100644 tests/auto/qml/qqmlecmascript/data/exception.js create mode 100644 tests/auto/qml/qqmlecmascript/data/exceptionClearsOnReeval.qml create mode 100644 tests/auto/qml/qqmlecmascript/data/exceptionProducesWarning.qml create mode 100644 tests/auto/qml/qqmlecmascript/data/exceptionProducesWarning2.qml create mode 100644 tests/auto/qml/qqmlecmascript/data/extendedObjectPropertyLookup.qml create mode 100644 tests/auto/qml/qqmlecmascript/data/extendedObjectPropertyLookup2.qml create mode 100644 tests/auto/qml/qqmlecmascript/data/extensionObjects.qml create mode 100644 tests/auto/qml/qqmlecmascript/data/extensionObjectsPropertyOverride.qml create mode 100644 tests/auto/qml/qqmlecmascript/data/forInLoop.qml create mode 100644 tests/auto/qml/qqmlecmascript/data/function.qml create mode 100644 tests/auto/qml/qqmlecmascript/data/functionAssignment.1.qml create mode 100644 tests/auto/qml/qqmlecmascript/data/functionAssignment.2.qml create mode 100644 tests/auto/qml/qqmlecmascript/data/functionAssignment.js create mode 100644 tests/auto/qml/qqmlecmascript/data/functionErrors.qml create mode 100644 tests/auto/qml/qqmlecmascript/data/handleReferenceManagement.handle.1.qml create mode 100644 tests/auto/qml/qqmlecmascript/data/handleReferenceManagement.handle.2.qml create mode 100644 tests/auto/qml/qqmlecmascript/data/handleReferenceManagement.object.1.qml create mode 100644 tests/auto/qml/qqmlecmascript/data/handleReferenceManagement.object.2.qml create mode 100644 tests/auto/qml/qqmlecmascript/data/idShortcutInvalidates.1.qml create mode 100644 tests/auto/qml/qqmlecmascript/data/idShortcutInvalidates.qml create mode 100644 tests/auto/qml/qqmlecmascript/data/importScope.1.js create mode 100644 tests/auto/qml/qqmlecmascript/data/importScope.2.js create mode 100644 tests/auto/qml/qqmlecmascript/data/importScope.qml create mode 100644 tests/auto/qml/qqmlecmascript/data/in.qml create mode 100644 tests/auto/qml/qqmlecmascript/data/include.js create mode 100644 tests/auto/qml/qqmlecmascript/data/include.qml create mode 100644 tests/auto/qml/qqmlecmascript/data/include_callback.js create mode 100644 tests/auto/qml/qqmlecmascript/data/include_callback.qml create mode 100644 tests/auto/qml/qqmlecmascript/data/include_pragma.qml create mode 100644 tests/auto/qml/qqmlecmascript/data/include_pragma_inner.js create mode 100644 tests/auto/qml/qqmlecmascript/data/include_pragma_outer.js create mode 100644 tests/auto/qml/qqmlecmascript/data/include_remote.js create mode 100644 tests/auto/qml/qqmlecmascript/data/include_remote.qml create mode 100644 tests/auto/qml/qqmlecmascript/data/include_remote_missing.js create mode 100644 tests/auto/qml/qqmlecmascript/data/include_remote_missing.qml create mode 100644 tests/auto/qml/qqmlecmascript/data/include_shared.js create mode 100644 tests/auto/qml/qqmlecmascript/data/include_shared.qml create mode 100644 tests/auto/qml/qqmlecmascript/data/invokableObjectArg.qml create mode 100644 tests/auto/qml/qqmlecmascript/data/invokableObjectRet.qml create mode 100644 tests/auto/qml/qqmlecmascript/data/js/include2.js create mode 100644 tests/auto/qml/qqmlecmascript/data/js/include3.js create mode 100644 tests/auto/qml/qqmlecmascript/data/jsObject.qml create mode 100644 tests/auto/qml/qqmlecmascript/data/jsimport/SpecialRectangleOne.qml create mode 100644 tests/auto/qml/qqmlecmascript/data/jsimport/SpecialRectangleTwo.qml create mode 100644 tests/auto/qml/qqmlecmascript/data/jsimport/importFive.js create mode 100644 tests/auto/qml/qqmlecmascript/data/jsimport/importFour.js create mode 100644 tests/auto/qml/qqmlecmascript/data/jsimport/importOne.js create mode 100644 tests/auto/qml/qqmlecmascript/data/jsimport/importPragmaLibrary.js create mode 100644 tests/auto/qml/qqmlecmascript/data/jsimport/importPragmaLibraryWithImports.js create mode 100644 tests/auto/qml/qqmlecmascript/data/jsimport/importPragmaLibraryWithPragmaLibraryImports.js create mode 100644 tests/auto/qml/qqmlecmascript/data/jsimport/importThree.js create mode 100644 tests/auto/qml/qqmlecmascript/data/jsimport/importTwo.js create mode 100644 tests/auto/qml/qqmlecmascript/data/jsimport/importWithNoImports.js create mode 100644 tests/auto/qml/qqmlecmascript/data/jsimport/testImport.qml create mode 100644 tests/auto/qml/qqmlecmascript/data/jsimport/testImportPragmaLibrary.qml create mode 100644 tests/auto/qml/qqmlecmascript/data/jsimport/testImportPragmaLibraryWithImports.qml create mode 100644 tests/auto/qml/qqmlecmascript/data/jsimport/testImportPragmaLibraryWithPragmaLibraryImports.qml create mode 100644 tests/auto/qml/qqmlecmascript/data/jsimport/testImportScoping.qml create mode 100644 tests/auto/qml/qqmlecmascript/data/jsimport/testModuleImport.js create mode 100644 tests/auto/qml/qqmlecmascript/data/jsimport/testScriptImport.js create mode 100644 tests/auto/qml/qqmlecmascript/data/jsimportfail/failFive.qml create mode 100644 tests/auto/qml/qqmlecmascript/data/jsimportfail/failFour.qml create mode 100644 tests/auto/qml/qqmlecmascript/data/jsimportfail/failOne.qml create mode 100644 tests/auto/qml/qqmlecmascript/data/jsimportfail/failThree.qml create mode 100644 tests/auto/qml/qqmlecmascript/data/jsimportfail/failTwo.qml create mode 100644 tests/auto/qml/qqmlecmascript/data/jsimportfail/importOne.js create mode 100644 tests/auto/qml/qqmlecmascript/data/jsimportfail/importPragmaLibrary.js create mode 100644 tests/auto/qml/qqmlecmascript/data/jsimportfail/importWithImports.js create mode 100644 tests/auto/qml/qqmlecmascript/data/jsimportfail/testImportPragmaLibrary.qml create mode 100644 tests/auto/qml/qqmlecmascript/data/jsimportfail/testModuleImport.js create mode 100644 tests/auto/qml/qqmlecmascript/data/jsimportfail/testScriptImport.js create mode 100644 tests/auto/qml/qqmlecmascript/data/libraryScriptAssert.js create mode 100644 tests/auto/qml/qqmlecmascript/data/libraryScriptAssert.qml create mode 100644 tests/auto/qml/qqmlecmascript/data/listAssignment.qml create mode 100644 tests/auto/qml/qqmlecmascript/data/listProperties.qml create mode 100644 tests/auto/qml/qqmlecmascript/data/listToVariant.qml create mode 100644 tests/auto/qml/qqmlecmascript/data/metaobjectRevision.qml create mode 100644 tests/auto/qml/qqmlecmascript/data/metaobjectRevision2.qml create mode 100644 tests/auto/qml/qqmlecmascript/data/metaobjectRevision3.qml create mode 100644 tests/auto/qml/qqmlecmascript/data/metaobjectRevision4.qml create mode 100644 tests/auto/qml/qqmlecmascript/data/metaobjectRevisionErrors.qml create mode 100644 tests/auto/qml/qqmlecmascript/data/metaobjectRevisionErrors2.qml create mode 100644 tests/auto/qml/qqmlecmascript/data/metaobjectRevisionErrors3.qml create mode 100644 tests/auto/qml/qqmlecmascript/data/methods.1.qml create mode 100644 tests/auto/qml/qqmlecmascript/data/methods.2.qml create mode 100644 tests/auto/qml/qqmlecmascript/data/methods.3.qml create mode 100644 tests/auto/qml/qqmlecmascript/data/methods.4.qml create mode 100644 tests/auto/qml/qqmlecmascript/data/methods.5.qml create mode 100644 tests/auto/qml/qqmlecmascript/data/moduleapi/moduleApiMajorVersionFail.qml create mode 100644 tests/auto/qml/qqmlecmascript/data/moduleapi/moduleApiMinorVersionFail.qml create mode 100644 tests/auto/qml/qqmlecmascript/data/moduleapi/qobjectModuleApi.qml create mode 100644 tests/auto/qml/qqmlecmascript/data/moduleapi/qobjectModuleApiCaching.qml create mode 100644 tests/auto/qml/qqmlecmascript/data/moduleapi/qobjectModuleApiEnums.qml create mode 100644 tests/auto/qml/qqmlecmascript/data/moduleapi/qobjectModuleApiWriting.qml create mode 100644 tests/auto/qml/qqmlecmascript/data/moduleapi/scriptModuleApi.qml create mode 100644 tests/auto/qml/qqmlecmascript/data/moduleapi/scriptModuleApiCaching.qml create mode 100644 tests/auto/qml/qqmlecmascript/data/moduleapi/scriptModuleApiWriting.qml create mode 100644 tests/auto/qml/qqmlecmascript/data/multiEngineObject.qml create mode 100644 tests/auto/qml/qqmlecmascript/data/noSpuriousWarningsAtShutdown.2.qml create mode 100644 tests/auto/qml/qqmlecmascript/data/noSpuriousWarningsAtShutdown.qml create mode 100644 tests/auto/qml/qqmlecmascript/data/nonExistentAttachedObject.qml create mode 100644 tests/auto/qml/qqmlecmascript/data/nonNotifyable.qml create mode 100644 tests/auto/qml/qqmlecmascript/data/nonscriptable.qml create mode 100644 tests/auto/qml/qqmlecmascript/data/nullObjectBinding.qml create mode 100644 tests/auto/qml/qqmlecmascript/data/numberAssignment.qml create mode 100644 tests/auto/qml/qqmlecmascript/data/objectConversion.qml create mode 100644 tests/auto/qml/qqmlecmascript/data/objectName.qml create mode 100644 tests/auto/qml/qqmlecmascript/data/objectsCompareAsEqual.qml create mode 100644 tests/auto/qml/qqmlecmascript/data/objectsPassThroughSignals.qml create mode 100644 tests/auto/qml/qqmlecmascript/data/outerBindingOverridesInnerBinding.qml create mode 100644 tests/auto/qml/qqmlecmascript/data/ownership.qml create mode 100644 tests/auto/qml/qqmlecmascript/data/propertyAssignmentErrors.qml create mode 100644 tests/auto/qml/qqmlecmascript/data/propertySplicing.qml create mode 100644 tests/auto/qml/qqmlecmascript/data/propertyVar.1.qml create mode 100644 tests/auto/qml/qqmlecmascript/data/propertyVar.10.qml create mode 100644 tests/auto/qml/qqmlecmascript/data/propertyVar.2.qml create mode 100644 tests/auto/qml/qqmlecmascript/data/propertyVar.3.qml create mode 100644 tests/auto/qml/qqmlecmascript/data/propertyVar.4.qml create mode 100644 tests/auto/qml/qqmlecmascript/data/propertyVar.5.qml create mode 100644 tests/auto/qml/qqmlecmascript/data/propertyVar.6.qml create mode 100644 tests/auto/qml/qqmlecmascript/data/propertyVar.7.qml create mode 100644 tests/auto/qml/qqmlecmascript/data/propertyVar.8.qml create mode 100644 tests/auto/qml/qqmlecmascript/data/propertyVar.9.qml create mode 100644 tests/auto/qml/qqmlecmascript/data/propertyVar.circular.2.qml create mode 100644 tests/auto/qml/qqmlecmascript/data/propertyVar.circular.qml create mode 100644 tests/auto/qml/qqmlecmascript/data/propertyVar.inherit.qml create mode 100644 tests/auto/qml/qqmlecmascript/data/propertyVar.reparent.qml create mode 100644 tests/auto/qml/qqmlecmascript/data/propertyVarCpp.qml create mode 100644 tests/auto/qml/qqmlecmascript/data/propertyVarImplicitOwnership.qml create mode 100644 tests/auto/qml/qqmlecmascript/data/propertyVarOwnership.2.qml create mode 100644 tests/auto/qml/qqmlecmascript/data/propertyVarOwnership.3.qml create mode 100644 tests/auto/qml/qqmlecmascript/data/propertyVarOwnership.3.type.qml create mode 100644 tests/auto/qml/qqmlecmascript/data/propertyVarOwnership.4.qml create mode 100644 tests/auto/qml/qqmlecmascript/data/propertyVarOwnership.4.type1.qml create mode 100644 tests/auto/qml/qqmlecmascript/data/propertyVarOwnership.4.type2.qml create mode 100644 tests/auto/qml/qqmlecmascript/data/propertyVarOwnership.qml create mode 100644 tests/auto/qml/qqmlecmascript/data/qlistqobjectMethods.qml create mode 100644 tests/auto/qml/qqmlecmascript/data/qmlHasOwnProperty.qml create mode 100644 tests/auto/qml/qqmlecmascript/data/qmlToString.qml create mode 100644 tests/auto/qml/qqmlecmascript/data/qobjectConnectionListExceptionHandling.qml create mode 100644 tests/auto/qml/qqmlecmascript/data/qobjectDerivedArgument.qml create mode 100644 tests/auto/qml/qqmlecmascript/data/qtbug_10696.qml create mode 100644 tests/auto/qml/qqmlecmascript/data/qtbug_11600.js create mode 100644 tests/auto/qml/qqmlecmascript/data/qtbug_11600.qml create mode 100644 tests/auto/qml/qqmlecmascript/data/qtbug_11606.qml create mode 100644 tests/auto/qml/qqmlecmascript/data/qtbug_20344.qml create mode 100644 tests/auto/qml/qqmlecmascript/data/qtbug_21580.qml create mode 100644 tests/auto/qml/qqmlecmascript/data/qtbug_21864.js create mode 100644 tests/auto/qml/qqmlecmascript/data/qtbug_21864.qml create mode 100644 tests/auto/qml/qqmlecmascript/data/qtbug_22464.qml create mode 100644 tests/auto/qml/qqmlecmascript/data/qtbug_22679.qml create mode 100644 tests/auto/qml/qqmlecmascript/data/qtbug_22843.js create mode 100644 tests/auto/qml/qqmlecmascript/data/qtbug_22843.library.js create mode 100644 tests/auto/qml/qqmlecmascript/data/qtbug_22843.library.qml create mode 100644 tests/auto/qml/qqmlecmascript/data/qtbug_22843.qml create mode 100644 tests/auto/qml/qqmlecmascript/data/qtbug_9792.qml create mode 100644 tests/auto/qml/qqmlecmascript/data/qtcreatorbug_1289.qml create mode 100644 tests/auto/qml/qqmlecmascript/data/readonlyDeclaration.qml create mode 100644 tests/auto/qml/qqmlecmascript/data/realToInt.qml create mode 100644 tests/auto/qml/qqmlecmascript/data/regExp.2.qml create mode 100644 tests/auto/qml/qqmlecmascript/data/regExp.qml create mode 100644 tests/auto/qml/qqmlecmascript/data/remote_file.js create mode 100644 tests/auto/qml/qqmlecmascript/data/rewriteMultiLineStrings.qml create mode 100644 tests/auto/qml/qqmlecmascript/data/scarceResourceCopy.var.qml create mode 100644 tests/auto/qml/qqmlecmascript/data/scarceResourceCopy.variant.qml create mode 100644 tests/auto/qml/qqmlecmascript/data/scarceResourceCopyFromJs.var.qml create mode 100644 tests/auto/qml/qqmlecmascript/data/scarceResourceCopyFromJs.variant.qml create mode 100644 tests/auto/qml/qqmlecmascript/data/scarceResourceCopyImport.var.js create mode 100644 tests/auto/qml/qqmlecmascript/data/scarceResourceCopyImport.var.qml create mode 100644 tests/auto/qml/qqmlecmascript/data/scarceResourceCopyImport.variant.js create mode 100644 tests/auto/qml/qqmlecmascript/data/scarceResourceCopyImport.variant.qml create mode 100644 tests/auto/qml/qqmlecmascript/data/scarceResourceCopyImportDifferent.var.js create mode 100644 tests/auto/qml/qqmlecmascript/data/scarceResourceCopyImportDifferent.var.qml create mode 100644 tests/auto/qml/qqmlecmascript/data/scarceResourceCopyImportFail.var.js create mode 100644 tests/auto/qml/qqmlecmascript/data/scarceResourceCopyImportFail.var.qml create mode 100644 tests/auto/qml/qqmlecmascript/data/scarceResourceCopyImportFail.variant.js create mode 100644 tests/auto/qml/qqmlecmascript/data/scarceResourceCopyImportFail.variant.qml create mode 100644 tests/auto/qml/qqmlecmascript/data/scarceResourceCopyImportNoBinding.var.js create mode 100644 tests/auto/qml/qqmlecmascript/data/scarceResourceCopyImportNoBinding.var.qml create mode 100644 tests/auto/qml/qqmlecmascript/data/scarceResourceCopyImportNoBinding.variant.js create mode 100644 tests/auto/qml/qqmlecmascript/data/scarceResourceCopyImportNoBinding.variant.qml create mode 100644 tests/auto/qml/qqmlecmascript/data/scarceResourceCopyNoBinding.var.qml create mode 100644 tests/auto/qml/qqmlecmascript/data/scarceResourceCopyNoBinding.variant.qml create mode 100644 tests/auto/qml/qqmlecmascript/data/scarceResourceDestroyedCopy.var.qml create mode 100644 tests/auto/qml/qqmlecmascript/data/scarceResourceDestroyedCopy.variant.qml create mode 100644 tests/auto/qml/qqmlecmascript/data/scarceResourceFunction.var.qml create mode 100644 tests/auto/qml/qqmlecmascript/data/scarceResourceFunction.variant.qml create mode 100644 tests/auto/qml/qqmlecmascript/data/scarceResourceFunctionFail.var.qml create mode 100644 tests/auto/qml/qqmlecmascript/data/scarceResourceFunctionFail.variant.qml create mode 100644 tests/auto/qml/qqmlecmascript/data/scarceResourceMultipleDifferentNoBinding.var.js create mode 100644 tests/auto/qml/qqmlecmascript/data/scarceResourceMultipleDifferentNoBinding.var.qml create mode 100644 tests/auto/qml/qqmlecmascript/data/scarceResourceMultipleSameNoBinding.var.js create mode 100644 tests/auto/qml/qqmlecmascript/data/scarceResourceMultipleSameNoBinding.var.qml create mode 100644 tests/auto/qml/qqmlecmascript/data/scarceResourceMultipleSameWithBinding.var.qml create mode 100644 tests/auto/qml/qqmlecmascript/data/scarceResourceObjectGc.var.qml create mode 100644 tests/auto/qml/qqmlecmascript/data/scarceResourceSignal.var.qml create mode 100644 tests/auto/qml/qqmlecmascript/data/scarceResourceSignal.variant.qml create mode 100644 tests/auto/qml/qqmlecmascript/data/scarceResourceTest.var.js create mode 100644 tests/auto/qml/qqmlecmascript/data/scarceResourceTest.var.qml create mode 100644 tests/auto/qml/qqmlecmascript/data/scarceResourceTest.variant.js create mode 100644 tests/auto/qml/qqmlecmascript/data/scarceResourceTest.variant.qml create mode 100644 tests/auto/qml/qqmlecmascript/data/scarceResourceTestMultiple.var.qml create mode 100644 tests/auto/qml/qqmlecmascript/data/scarceResourceTestMultiple.variant.qml create mode 100644 tests/auto/qml/qqmlecmascript/data/scarceResourceTestPreserve.var.qml create mode 100644 tests/auto/qml/qqmlecmascript/data/scarceResourceTestPreserve.variant.qml create mode 100644 tests/auto/qml/qqmlecmascript/data/scope.2.qml create mode 100644 tests/auto/qml/qqmlecmascript/data/scope.3.qml create mode 100644 tests/auto/qml/qqmlecmascript/data/scope.4.qml create mode 100644 tests/auto/qml/qqmlecmascript/data/scope.5.qml create mode 100644 tests/auto/qml/qqmlecmascript/data/scope.6.qml create mode 100644 tests/auto/qml/qqmlecmascript/data/scope.qml create mode 100644 tests/auto/qml/qqmlecmascript/data/scriptConnect.1.js create mode 100644 tests/auto/qml/qqmlecmascript/data/scriptConnect.1.qml create mode 100644 tests/auto/qml/qqmlecmascript/data/scriptConnect.2.js create mode 100644 tests/auto/qml/qqmlecmascript/data/scriptConnect.2.qml create mode 100644 tests/auto/qml/qqmlecmascript/data/scriptConnect.3.qml create mode 100644 tests/auto/qml/qqmlecmascript/data/scriptConnect.4.qml create mode 100644 tests/auto/qml/qqmlecmascript/data/scriptConnect.5.qml create mode 100644 tests/auto/qml/qqmlecmascript/data/scriptConnect.6.js create mode 100644 tests/auto/qml/qqmlecmascript/data/scriptConnect.6.qml create mode 100644 tests/auto/qml/qqmlecmascript/data/scriptDisconnect.1.js create mode 100644 tests/auto/qml/qqmlecmascript/data/scriptDisconnect.1.qml create mode 100644 tests/auto/qml/qqmlecmascript/data/scriptDisconnect.2.qml create mode 100644 tests/auto/qml/qqmlecmascript/data/scriptDisconnect.3.qml create mode 100644 tests/auto/qml/qqmlecmascript/data/scriptDisconnect.4.qml create mode 100644 tests/auto/qml/qqmlecmascript/data/scriptErrors.js create mode 100644 tests/auto/qml/qqmlecmascript/data/scriptErrors.qml create mode 100644 tests/auto/qml/qqmlecmascript/data/selfDeletingBinding.2.qml create mode 100644 tests/auto/qml/qqmlecmascript/data/selfDeletingBinding.qml create mode 100644 tests/auto/qml/qqmlecmascript/data/sequenceConversion.array.qml create mode 100644 tests/auto/qml/qqmlecmascript/data/sequenceConversion.bindings.error.qml create mode 100644 tests/auto/qml/qqmlecmascript/data/sequenceConversion.bindings.qml create mode 100644 tests/auto/qml/qqmlecmascript/data/sequenceConversion.copy.qml create mode 100644 tests/auto/qml/qqmlecmascript/data/sequenceConversion.indexes.qml create mode 100644 tests/auto/qml/qqmlecmascript/data/sequenceConversion.read.error.qml create mode 100644 tests/auto/qml/qqmlecmascript/data/sequenceConversion.read.qml create mode 100644 tests/auto/qml/qqmlecmascript/data/sequenceConversion.threads.qml create mode 100644 tests/auto/qml/qqmlecmascript/data/sequenceConversion.write.error.qml create mode 100644 tests/auto/qml/qqmlecmascript/data/sequenceConversion.write.qml create mode 100644 tests/auto/qml/qqmlecmascript/data/sharedAttachedObject.qml create mode 100644 tests/auto/qml/qqmlecmascript/data/shutdownErrors.qml create mode 100644 tests/auto/qml/qqmlecmascript/data/signalAssignment.1.qml create mode 100644 tests/auto/qml/qqmlecmascript/data/signalAssignment.2.qml create mode 100644 tests/auto/qml/qqmlecmascript/data/signalHandlers.qml create mode 100644 tests/auto/qml/qqmlecmascript/data/signalParameterTypes.qml create mode 100644 tests/auto/qml/qqmlecmascript/data/signalTriggeredBindings.qml create mode 100644 tests/auto/qml/qqmlecmascript/data/signalWithJSValueInVariant.qml create mode 100644 tests/auto/qml/qqmlecmascript/data/signalWithQJSValue.qml create mode 100644 tests/auto/qml/qqmlecmascript/data/signalWithUnknownTypes.qml create mode 100644 tests/auto/qml/qqmlecmascript/data/strictlyEquals.qml create mode 100644 tests/auto/qml/qqmlecmascript/data/stringArg.qml create mode 100644 tests/auto/qml/qqmlecmascript/data/switchStatement.1.qml create mode 100644 tests/auto/qml/qqmlecmascript/data/switchStatement.2.qml create mode 100644 tests/auto/qml/qqmlecmascript/data/switchStatement.3.qml create mode 100644 tests/auto/qml/qqmlecmascript/data/switchStatement.4.qml create mode 100644 tests/auto/qml/qqmlecmascript/data/switchStatement.5.qml create mode 100644 tests/auto/qml/qqmlecmascript/data/switchStatement.6.qml create mode 100644 tests/auto/qml/qqmlecmascript/data/threadScript.js create mode 100644 tests/auto/qml/qqmlecmascript/data/transientErrors.2.qml create mode 100644 tests/auto/qml/qqmlecmascript/data/transientErrors.qml create mode 100644 tests/auto/qml/qqmlecmascript/data/tryStatement.1.qml create mode 100644 tests/auto/qml/qqmlecmascript/data/tryStatement.2.qml create mode 100644 tests/auto/qml/qqmlecmascript/data/tryStatement.3.qml create mode 100644 tests/auto/qml/qqmlecmascript/data/tryStatement.4.qml create mode 100644 tests/auto/qml/qqmlecmascript/data/typeOf.js create mode 100644 tests/auto/qml/qqmlecmascript/data/typeOf.qml create mode 100644 tests/auto/qml/qqmlecmascript/data/unaryExpression.qml create mode 100644 tests/auto/qml/qqmlecmascript/data/undefinedResetsProperty.2.qml create mode 100644 tests/auto/qml/qqmlecmascript/data/undefinedResetsProperty.qml create mode 100644 tests/auto/qml/qqmlecmascript/data/urlListProperty.qml create mode 100644 tests/auto/qml/qqmlecmascript/data/urlProperty.1.qml create mode 100644 tests/auto/qml/qqmlecmascript/data/urlProperty.2.qml create mode 100644 tests/auto/qml/qqmlecmascript/data/v8bindingException.qml create mode 100644 tests/auto/qml/qqmlecmascript/data/v8functionException.qml create mode 100644 tests/auto/qml/qqmlecmascript/data/valueTypeFunctions.qml create mode 100644 tests/auto/qml/qqmlecmascript/data/variantsAssignedUndefined.qml create mode 100644 tests/auto/qml/qqmlecmascript/data/withStatement.1.qml create mode 100644 tests/auto/qml/qqmlecmascript/data/writeAttachedProperty.qml create mode 100644 tests/auto/qml/qqmlecmascript/data/writeRemovesBinding.qml create mode 100644 tests/auto/qml/qqmlecmascript/qqmlecmascript.pro create mode 100644 tests/auto/qml/qqmlecmascript/testtypes.cpp create mode 100644 tests/auto/qml/qqmlecmascript/testtypes.h create mode 100644 tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp create mode 100644 tests/auto/qml/qqmlengine/qqmlengine.pro create mode 100644 tests/auto/qml/qqmlengine/tst_qqmlengine.cpp create mode 100644 tests/auto/qml/qqmlerror/data/test.txt create mode 100644 tests/auto/qml/qqmlerror/qqmlerror.pro create mode 100644 tests/auto/qml/qqmlerror/tst_qqmlerror.cpp create mode 100644 tests/auto/qml/qqmlexpression/data/scriptString.qml create mode 100644 tests/auto/qml/qqmlexpression/qqmlexpression.pro create mode 100644 tests/auto/qml/qqmlexpression/tst_qqmlexpression.cpp create mode 100644 tests/auto/qml/qqmlimageprovider/qqmlimageprovider.pro create mode 100644 tests/auto/qml/qqmlimageprovider/tst_qqmlimageprovider.cpp create mode 100644 tests/auto/qml/qqmlincubator/data/AsynchronousIfNestedType.qml create mode 100644 tests/auto/qml/qqmlincubator/data/asynchronousIfNested.1.qml create mode 100644 tests/auto/qml/qqmlincubator/data/asynchronousIfNested.2.qml create mode 100644 tests/auto/qml/qqmlincubator/data/asynchronousIfNested.3.qml create mode 100644 tests/auto/qml/qqmlincubator/data/chainInCompletion.qml create mode 100644 tests/auto/qml/qqmlincubator/data/chainedAsynchronousIfNested.qml create mode 100644 tests/auto/qml/qqmlincubator/data/clear.qml create mode 100644 tests/auto/qml/qqmlincubator/data/clearDuringCompletion.qml create mode 100644 tests/auto/qml/qqmlincubator/data/contextDelete.qml create mode 100644 tests/auto/qml/qqmlincubator/data/forceCompletion.qml create mode 100644 tests/auto/qml/qqmlincubator/data/nestedComponent.js create mode 100644 tests/auto/qml/qqmlincubator/data/nestedComponent.qml create mode 100644 tests/auto/qml/qqmlincubator/data/noIncubationController.qml create mode 100644 tests/auto/qml/qqmlincubator/data/objectDeleted.errors.txt create mode 100644 tests/auto/qml/qqmlincubator/data/objectDeleted.qml create mode 100644 tests/auto/qml/qqmlincubator/data/recursiveClear.1.qml create mode 100644 tests/auto/qml/qqmlincubator/data/recursiveClear.2.qml create mode 100644 tests/auto/qml/qqmlincubator/data/selfDelete.qml create mode 100644 tests/auto/qml/qqmlincubator/data/setInitialState.qml create mode 100644 tests/auto/qml/qqmlincubator/data/statusChanged.nested.qml create mode 100644 tests/auto/qml/qqmlincubator/data/statusChanged.qml create mode 100644 tests/auto/qml/qqmlincubator/qqmlincubator.pro create mode 100644 tests/auto/qml/qqmlincubator/testtypes.cpp create mode 100644 tests/auto/qml/qqmlincubator/testtypes.h create mode 100644 tests/auto/qml/qqmlincubator/tst_qqmlincubator.cpp create mode 100644 tests/auto/qml/qqmlinfo/data/NestedComponent.qml create mode 100644 tests/auto/qml/qqmlinfo/data/NestedObject.qml create mode 100644 tests/auto/qml/qqmlinfo/data/nestedQmlObject.qml create mode 100644 tests/auto/qml/qqmlinfo/data/qmlObject.qml create mode 100644 tests/auto/qml/qqmlinfo/qqmlinfo.pro create mode 100644 tests/auto/qml/qqmlinfo/tst_qqmlinfo.cpp create mode 100644 tests/auto/qml/qqmlinstruction/qqmlinstruction.pro create mode 100644 tests/auto/qml/qqmlinstruction/tst_qqmlinstruction.cpp create mode 100644 tests/auto/qml/qqmllanguage/data/Alias.qml create mode 100644 tests/auto/qml/qqmllanguage/data/Alias2.qml create mode 100644 tests/auto/qml/qqmllanguage/data/Alias3.qml create mode 100644 tests/auto/qml/qqmllanguage/data/Alias4.qml create mode 100644 tests/auto/qml/qqmllanguage/data/AliasPropertyChangeSignalsType.qml create mode 100644 tests/auto/qml/qqmllanguage/data/ComponentComposite.qml create mode 100644 tests/auto/qml/qqmllanguage/data/CompositeType.qml create mode 100644 tests/auto/qml/qqmllanguage/data/CompositeType2.qml create mode 100644 tests/auto/qml/qqmllanguage/data/CompositeType3.qml create mode 100644 tests/auto/qml/qqmllanguage/data/CompositeType4.qml create mode 100644 tests/auto/qml/qqmllanguage/data/DontDoubleCallClassBeginItem.qml create mode 100644 tests/auto/qml/qqmllanguage/data/DynamicPropertiesNestedType.qml create mode 100644 tests/auto/qml/qqmllanguage/data/HelperAlias.qml create mode 100644 tests/auto/qml/qqmllanguage/data/I18n.qml create mode 100644 tests/auto/qml/qqmllanguage/data/I18nType30.qml create mode 100644 tests/auto/qml/qqmllanguage/data/InlineAssignmentsOverrideBindingsType.qml create mode 100644 tests/auto/qml/qqmllanguage/data/InlineAssignmentsOverrideBindingsType2.qml create mode 100644 tests/auto/qml/qqmllanguage/data/LocalLast.qml create mode 100644 tests/auto/qml/qqmllanguage/data/MyComponent.qml create mode 100644 tests/auto/qml/qqmllanguage/data/MyCompositeValueSource.qml create mode 100644 tests/auto/qml/qqmllanguage/data/MyContainerComponent.qml create mode 100644 tests/auto/qml/qqmllanguage/data/NestedAlias.qml create mode 100644 tests/auto/qml/qqmllanguage/data/NestedComponentRoot.qml create mode 100644 tests/auto/qml/qqmllanguage/data/NestedErrorsType.qml create mode 100644 tests/auto/qml/qqmllanguage/data/OnCompletedType.qml create mode 100644 tests/auto/qml/qqmllanguage/data/OnDestructionType.qml create mode 100644 tests/auto/qml/qqmllanguage/data/ReadOnlyType.qml create mode 100644 tests/auto/qml/qqmllanguage/data/alias.1.qml create mode 100644 tests/auto/qml/qqmllanguage/data/alias.10.qml create mode 100644 tests/auto/qml/qqmllanguage/data/alias.11.qml create mode 100644 tests/auto/qml/qqmllanguage/data/alias.2.qml create mode 100644 tests/auto/qml/qqmllanguage/data/alias.3.qml create mode 100644 tests/auto/qml/qqmllanguage/data/alias.4.qml create mode 100644 tests/auto/qml/qqmllanguage/data/alias.5.qml create mode 100644 tests/auto/qml/qqmllanguage/data/alias.6.qml create mode 100644 tests/auto/qml/qqmllanguage/data/alias.7.qml create mode 100644 tests/auto/qml/qqmllanguage/data/alias.8.qml create mode 100644 tests/auto/qml/qqmllanguage/data/alias.9.qml create mode 100644 tests/auto/qml/qqmllanguage/data/aliasPropertiesAndSignals.qml create mode 100644 tests/auto/qml/qqmllanguage/data/aliasPropertyChangeSignals.2.qml create mode 100644 tests/auto/qml/qqmllanguage/data/aliasPropertyChangeSignals.qml create mode 100644 tests/auto/qml/qqmllanguage/data/allowedRevisionOverloads.qml create mode 100644 tests/auto/qml/qqmllanguage/data/assignBasicTypes.qml create mode 100644 tests/auto/qml/qqmllanguage/data/assignCompositeToType.qml create mode 100644 tests/auto/qml/qqmllanguage/data/assignLiteralSignalProperty.qml create mode 100644 tests/auto/qml/qqmllanguage/data/assignLiteralToVar.qml create mode 100644 tests/auto/qml/qqmllanguage/data/assignLiteralToVariant.qml create mode 100644 tests/auto/qml/qqmllanguage/data/assignObjectToSignal.qml create mode 100644 tests/auto/qml/qqmllanguage/data/assignObjectToVariant.qml create mode 100644 tests/auto/qml/qqmllanguage/data/assignQmlComponent.qml create mode 100644 tests/auto/qml/qqmllanguage/data/assignSignal.qml create mode 100644 tests/auto/qml/qqmllanguage/data/assignToNamespace.errors.txt create mode 100644 tests/auto/qml/qqmllanguage/data/assignToNamespace.qml create mode 100644 tests/auto/qml/qqmllanguage/data/assignTypeExtremes.qml create mode 100644 tests/auto/qml/qqmllanguage/data/assignValueToSignal.errors.txt create mode 100644 tests/auto/qml/qqmllanguage/data/assignValueToSignal.qml create mode 100644 tests/auto/qml/qqmllanguage/data/attachedProperties.qml create mode 100644 tests/auto/qml/qqmllanguage/data/autoComponentCreation.qml create mode 100644 tests/auto/qml/qqmllanguage/data/autoNotifyConnection.qml create mode 100644 tests/auto/qml/qqmllanguage/data/component.1.errors.txt create mode 100644 tests/auto/qml/qqmllanguage/data/component.1.qml create mode 100644 tests/auto/qml/qqmllanguage/data/component.2.errors.txt create mode 100644 tests/auto/qml/qqmllanguage/data/component.2.qml create mode 100644 tests/auto/qml/qqmllanguage/data/component.3.errors.txt create mode 100644 tests/auto/qml/qqmllanguage/data/component.3.qml create mode 100644 tests/auto/qml/qqmllanguage/data/component.4.errors.txt create mode 100644 tests/auto/qml/qqmllanguage/data/component.4.qml create mode 100644 tests/auto/qml/qqmllanguage/data/component.5.errors.txt create mode 100644 tests/auto/qml/qqmllanguage/data/component.5.qml create mode 100644 tests/auto/qml/qqmllanguage/data/component.6.errors.txt create mode 100644 tests/auto/qml/qqmllanguage/data/component.6.qml create mode 100644 tests/auto/qml/qqmllanguage/data/component.7.errors.txt create mode 100644 tests/auto/qml/qqmllanguage/data/component.7.qml create mode 100644 tests/auto/qml/qqmllanguage/data/component.8.errors.txt create mode 100644 tests/auto/qml/qqmllanguage/data/component.8.qml create mode 100644 tests/auto/qml/qqmllanguage/data/component.9.errors.txt create mode 100644 tests/auto/qml/qqmllanguage/data/component.9.qml create mode 100644 tests/auto/qml/qqmllanguage/data/componentCompositeType.qml create mode 100644 tests/auto/qml/qqmllanguage/data/cppnamespace.2.qml create mode 100644 tests/auto/qml/qqmllanguage/data/cppnamespace.qml create mode 100644 tests/auto/qml/qqmllanguage/data/crash2.qml create mode 100644 tests/auto/qml/qqmllanguage/data/customOnProperty.qml create mode 100644 tests/auto/qml/qqmllanguage/data/customParserIdNotAllowed.errors.txt create mode 100644 tests/auto/qml/qqmllanguage/data/customParserIdNotAllowed.qml create mode 100644 tests/auto/qml/qqmllanguage/data/customParserTypes.qml create mode 100644 tests/auto/qml/qqmllanguage/data/customVariantTypes.qml create mode 100644 tests/auto/qml/qqmllanguage/data/declaredPropertyValues.qml create mode 100644 tests/auto/qml/qqmllanguage/data/defaultGrouped.errors.txt create mode 100644 tests/auto/qml/qqmllanguage/data/defaultGrouped.qml create mode 100644 tests/auto/qml/qqmllanguage/data/defaultPropertyListOrder.qml create mode 100644 tests/auto/qml/qqmllanguage/data/destroyedSignal.errors.txt create mode 100644 tests/auto/qml/qqmllanguage/data/destroyedSignal.qml create mode 100644 tests/auto/qml/qqmllanguage/data/disallowedRevisionOverloads.errors.txt create mode 100644 tests/auto/qml/qqmllanguage/data/disallowedRevisionOverloads.qml create mode 100644 tests/auto/qml/qqmllanguage/data/dontDoubleCallClassBegin.qml create mode 100644 tests/auto/qml/qqmllanguage/data/doubleSignal.errors.txt create mode 100644 tests/auto/qml/qqmllanguage/data/doubleSignal.qml create mode 100644 tests/auto/qml/qqmllanguage/data/duplicateIDs.errors.txt create mode 100644 tests/auto/qml/qqmllanguage/data/duplicateIDs.qml create mode 100644 tests/auto/qml/qqmllanguage/data/dynamicMeta.1.errors.txt create mode 100644 tests/auto/qml/qqmllanguage/data/dynamicMeta.1.qml create mode 100644 tests/auto/qml/qqmllanguage/data/dynamicMeta.2.errors.txt create mode 100644 tests/auto/qml/qqmllanguage/data/dynamicMeta.2.qml create mode 100644 tests/auto/qml/qqmllanguage/data/dynamicMeta.3.errors.txt create mode 100644 tests/auto/qml/qqmllanguage/data/dynamicMeta.3.qml create mode 100644 tests/auto/qml/qqmllanguage/data/dynamicMeta.4.errors.txt create mode 100644 tests/auto/qml/qqmllanguage/data/dynamicMeta.4.qml create mode 100644 tests/auto/qml/qqmllanguage/data/dynamicMeta.5.errors.txt create mode 100644 tests/auto/qml/qqmllanguage/data/dynamicMeta.5.qml create mode 100644 tests/auto/qml/qqmllanguage/data/dynamicObject.1.qml create mode 100644 tests/auto/qml/qqmllanguage/data/dynamicObjectProperties.2.qml create mode 100644 tests/auto/qml/qqmllanguage/data/dynamicObjectProperties.qml create mode 100644 tests/auto/qml/qqmllanguage/data/dynamicProperties.qml create mode 100644 tests/auto/qml/qqmllanguage/data/dynamicPropertiesNested.qml create mode 100644 tests/auto/qml/qqmllanguage/data/dynamicSignalsAndSlots.qml create mode 100644 tests/auto/qml/qqmllanguage/data/empty.errors.txt create mode 100644 tests/auto/qml/qqmllanguage/data/empty.qml create mode 100644 tests/auto/qml/qqmllanguage/data/emptySignal.errors.txt create mode 100644 tests/auto/qml/qqmllanguage/data/emptySignal.qml create mode 100644 tests/auto/qml/qqmllanguage/data/enumTypes.errors.txt create mode 100644 tests/auto/qml/qqmllanguage/data/enumTypes.qml create mode 100644 tests/auto/qml/qqmllanguage/data/failingComponent.errors.txt create mode 100644 tests/auto/qml/qqmllanguage/data/failingComponentTest.qml create mode 100644 tests/auto/qml/qqmllanguage/data/fakeDotProperty.errors.txt create mode 100644 tests/auto/qml/qqmllanguage/data/fakeDotProperty.qml create mode 100644 tests/auto/qml/qqmllanguage/data/finalOverride.errors.txt create mode 100644 tests/auto/qml/qqmllanguage/data/finalOverride.qml create mode 100644 tests/auto/qml/qqmllanguage/data/i18nDeclaredPropertyNames.qml create mode 100644 tests/auto/qml/qqmllanguage/data/i18nDeclaredPropertyUse.qml create mode 100644 tests/auto/qml/qqmllanguage/data/i18nNameSpace.qml create mode 100644 tests/auto/qml/qqmllanguage/data/i18nScript.qml create mode 100644 tests/auto/qml/qqmllanguage/data/i18nStrings.qml create mode 100644 tests/auto/qml/qqmllanguage/data/i18nType.qml create mode 100644 tests/auto/qml/qqmllanguage/data/idProperty.qml create mode 100644 tests/auto/qml/qqmllanguage/data/importFile.errors.txt create mode 100644 tests/auto/qml/qqmllanguage/data/importFile.qml create mode 100644 tests/auto/qml/qqmllanguage/data/importIncorrectCase.qml create mode 100644 tests/auto/qml/qqmllanguage/data/importJs.1.errors.txt create mode 100644 tests/auto/qml/qqmllanguage/data/importJs.1.qml create mode 100644 tests/auto/qml/qqmllanguage/data/importJs.10.errors.txt create mode 100644 tests/auto/qml/qqmllanguage/data/importJs.10.qml create mode 100644 tests/auto/qml/qqmllanguage/data/importJs.2.errors.txt create mode 100644 tests/auto/qml/qqmllanguage/data/importJs.2.qml create mode 100644 tests/auto/qml/qqmllanguage/data/importJs.3.errors.txt create mode 100644 tests/auto/qml/qqmllanguage/data/importJs.3.qml create mode 100644 tests/auto/qml/qqmllanguage/data/importJs.4.errors.txt create mode 100644 tests/auto/qml/qqmllanguage/data/importJs.4.qml create mode 100644 tests/auto/qml/qqmllanguage/data/importJs.5.errors.txt create mode 100644 tests/auto/qml/qqmllanguage/data/importJs.5.qml create mode 100644 tests/auto/qml/qqmllanguage/data/importJs.6.errors.txt create mode 100644 tests/auto/qml/qqmllanguage/data/importJs.6.qml create mode 100644 tests/auto/qml/qqmllanguage/data/importJs.7.errors.txt create mode 100644 tests/auto/qml/qqmllanguage/data/importJs.7.qml create mode 100644 tests/auto/qml/qqmllanguage/data/importJs.8.errors.txt create mode 100644 tests/auto/qml/qqmllanguage/data/importJs.8.qml create mode 100644 tests/auto/qml/qqmllanguage/data/importJs.9.errors.txt create mode 100644 tests/auto/qml/qqmllanguage/data/importJs.9.qml create mode 100644 tests/auto/qml/qqmllanguage/data/importNamespaceConflict.errors.txt create mode 100644 tests/auto/qml/qqmllanguage/data/importNamespaceConflict.qml create mode 100644 tests/auto/qml/qqmllanguage/data/importNewerVersion.errors.txt create mode 100644 tests/auto/qml/qqmllanguage/data/importNewerVersion.qml create mode 100644 tests/auto/qml/qqmllanguage/data/importNonExist.errors.txt create mode 100644 tests/auto/qml/qqmllanguage/data/importNonExist.qml create mode 100644 tests/auto/qml/qqmllanguage/data/importNonExistOlder.errors.txt create mode 100644 tests/auto/qml/qqmllanguage/data/importNonExistOlder.qml create mode 100644 tests/auto/qml/qqmllanguage/data/importVersionMissingBuiltIn.errors.txt create mode 100644 tests/auto/qml/qqmllanguage/data/importVersionMissingBuiltIn.qml create mode 100644 tests/auto/qml/qqmllanguage/data/importVersionMissingInstalled.errors.txt create mode 100644 tests/auto/qml/qqmllanguage/data/importVersionMissingInstalled.qml create mode 100644 tests/auto/qml/qqmllanguage/data/importscript.1.errors.txt create mode 100644 tests/auto/qml/qqmllanguage/data/importscript.1.qml create mode 100644 tests/auto/qml/qqmllanguage/data/incorrectCase.errors.insensitive.txt create mode 100644 tests/auto/qml/qqmllanguage/data/incorrectCase.errors.sensitive.txt create mode 100644 tests/auto/qml/qqmllanguage/data/incorrectCase.qml create mode 100644 tests/auto/qml/qqmllanguage/data/incorrectCaseType.qml create mode 100644 tests/auto/qml/qqmllanguage/data/inlineAssignmentsOverrideBindings.qml create mode 100644 tests/auto/qml/qqmllanguage/data/inlineQmlComponents.qml create mode 100644 tests/auto/qml/qqmllanguage/data/insertedSemicolon.1.errors.txt create mode 100644 tests/auto/qml/qqmllanguage/data/insertedSemicolon.1.qml create mode 100644 tests/auto/qml/qqmllanguage/data/interfaceProperty.qml create mode 100644 tests/auto/qml/qqmllanguage/data/interfaceQList.qml create mode 100644 tests/auto/qml/qqmllanguage/data/invalidAlias.1.errors.txt create mode 100644 tests/auto/qml/qqmllanguage/data/invalidAlias.1.qml create mode 100644 tests/auto/qml/qqmllanguage/data/invalidAlias.10.errors.txt create mode 100644 tests/auto/qml/qqmllanguage/data/invalidAlias.10.qml create mode 100644 tests/auto/qml/qqmllanguage/data/invalidAlias.2.errors.txt create mode 100644 tests/auto/qml/qqmllanguage/data/invalidAlias.2.qml create mode 100644 tests/auto/qml/qqmllanguage/data/invalidAlias.3.errors.txt create mode 100644 tests/auto/qml/qqmllanguage/data/invalidAlias.3.qml create mode 100644 tests/auto/qml/qqmllanguage/data/invalidAlias.4.errors.txt create mode 100644 tests/auto/qml/qqmllanguage/data/invalidAlias.4.qml create mode 100644 tests/auto/qml/qqmllanguage/data/invalidAlias.5.errors.txt create mode 100644 tests/auto/qml/qqmllanguage/data/invalidAlias.5.qml create mode 100644 tests/auto/qml/qqmllanguage/data/invalidAlias.6.errors.txt create mode 100644 tests/auto/qml/qqmllanguage/data/invalidAlias.6.qml create mode 100644 tests/auto/qml/qqmllanguage/data/invalidAlias.7.errors.txt create mode 100644 tests/auto/qml/qqmllanguage/data/invalidAlias.7.qml create mode 100644 tests/auto/qml/qqmllanguage/data/invalidAlias.8.errors.txt create mode 100644 tests/auto/qml/qqmllanguage/data/invalidAlias.8.qml create mode 100644 tests/auto/qml/qqmllanguage/data/invalidAlias.9.errors.txt create mode 100644 tests/auto/qml/qqmllanguage/data/invalidAlias.9.qml create mode 100644 tests/auto/qml/qqmllanguage/data/invalidAttachedProperty.1.errors.txt create mode 100644 tests/auto/qml/qqmllanguage/data/invalidAttachedProperty.1.qml create mode 100644 tests/auto/qml/qqmllanguage/data/invalidAttachedProperty.10.errors.txt create mode 100644 tests/auto/qml/qqmllanguage/data/invalidAttachedProperty.10.qml create mode 100644 tests/auto/qml/qqmllanguage/data/invalidAttachedProperty.11.errors.txt create mode 100644 tests/auto/qml/qqmllanguage/data/invalidAttachedProperty.11.qml create mode 100644 tests/auto/qml/qqmllanguage/data/invalidAttachedProperty.12.errors.txt create mode 100644 tests/auto/qml/qqmllanguage/data/invalidAttachedProperty.12.qml create mode 100644 tests/auto/qml/qqmllanguage/data/invalidAttachedProperty.13.errors.txt create mode 100644 tests/auto/qml/qqmllanguage/data/invalidAttachedProperty.13.qml create mode 100644 tests/auto/qml/qqmllanguage/data/invalidAttachedProperty.2.errors.txt create mode 100644 tests/auto/qml/qqmllanguage/data/invalidAttachedProperty.2.qml create mode 100644 tests/auto/qml/qqmllanguage/data/invalidAttachedProperty.3.errors.txt create mode 100644 tests/auto/qml/qqmllanguage/data/invalidAttachedProperty.3.qml create mode 100644 tests/auto/qml/qqmllanguage/data/invalidAttachedProperty.4.errors.txt create mode 100644 tests/auto/qml/qqmllanguage/data/invalidAttachedProperty.4.qml create mode 100644 tests/auto/qml/qqmllanguage/data/invalidAttachedProperty.5.errors.txt create mode 100644 tests/auto/qml/qqmllanguage/data/invalidAttachedProperty.5.qml create mode 100644 tests/auto/qml/qqmllanguage/data/invalidAttachedProperty.6.errors.txt create mode 100644 tests/auto/qml/qqmllanguage/data/invalidAttachedProperty.6.qml create mode 100644 tests/auto/qml/qqmllanguage/data/invalidAttachedProperty.7.errors.txt create mode 100644 tests/auto/qml/qqmllanguage/data/invalidAttachedProperty.7.qml create mode 100644 tests/auto/qml/qqmllanguage/data/invalidAttachedProperty.8.errors.txt create mode 100644 tests/auto/qml/qqmllanguage/data/invalidAttachedProperty.8.qml create mode 100644 tests/auto/qml/qqmllanguage/data/invalidAttachedProperty.9.errors.txt create mode 100644 tests/auto/qml/qqmllanguage/data/invalidAttachedProperty.9.qml create mode 100644 tests/auto/qml/qqmllanguage/data/invalidGroupedProperty.1.errors.txt create mode 100644 tests/auto/qml/qqmllanguage/data/invalidGroupedProperty.1.qml create mode 100644 tests/auto/qml/qqmllanguage/data/invalidGroupedProperty.10.errors.txt create mode 100644 tests/auto/qml/qqmllanguage/data/invalidGroupedProperty.10.qml create mode 100644 tests/auto/qml/qqmllanguage/data/invalidGroupedProperty.2.errors.txt create mode 100644 tests/auto/qml/qqmllanguage/data/invalidGroupedProperty.2.qml create mode 100644 tests/auto/qml/qqmllanguage/data/invalidGroupedProperty.3.errors.txt create mode 100644 tests/auto/qml/qqmllanguage/data/invalidGroupedProperty.3.qml create mode 100644 tests/auto/qml/qqmllanguage/data/invalidGroupedProperty.4.errors.txt create mode 100644 tests/auto/qml/qqmllanguage/data/invalidGroupedProperty.4.qml create mode 100644 tests/auto/qml/qqmllanguage/data/invalidGroupedProperty.5.errors.txt create mode 100644 tests/auto/qml/qqmllanguage/data/invalidGroupedProperty.5.qml create mode 100644 tests/auto/qml/qqmllanguage/data/invalidGroupedProperty.6.errors.txt create mode 100644 tests/auto/qml/qqmllanguage/data/invalidGroupedProperty.6.qml create mode 100644 tests/auto/qml/qqmllanguage/data/invalidGroupedProperty.7.errors.txt create mode 100644 tests/auto/qml/qqmllanguage/data/invalidGroupedProperty.7.qml create mode 100644 tests/auto/qml/qqmllanguage/data/invalidGroupedProperty.8.errors.txt create mode 100644 tests/auto/qml/qqmllanguage/data/invalidGroupedProperty.8.qml create mode 100644 tests/auto/qml/qqmllanguage/data/invalidGroupedProperty.9.errors.txt create mode 100644 tests/auto/qml/qqmllanguage/data/invalidGroupedProperty.9.qml create mode 100644 tests/auto/qml/qqmllanguage/data/invalidID.2.errors.txt create mode 100644 tests/auto/qml/qqmllanguage/data/invalidID.2.qml create mode 100644 tests/auto/qml/qqmllanguage/data/invalidID.3.errors.txt create mode 100644 tests/auto/qml/qqmllanguage/data/invalidID.3.qml create mode 100644 tests/auto/qml/qqmllanguage/data/invalidID.4.errors.txt create mode 100644 tests/auto/qml/qqmllanguage/data/invalidID.4.qml create mode 100644 tests/auto/qml/qqmllanguage/data/invalidID.5.errors.txt create mode 100644 tests/auto/qml/qqmllanguage/data/invalidID.5.qml create mode 100644 tests/auto/qml/qqmllanguage/data/invalidID.6.errors.txt create mode 100644 tests/auto/qml/qqmllanguage/data/invalidID.6.qml create mode 100644 tests/auto/qml/qqmllanguage/data/invalidID.7.errors.txt create mode 100644 tests/auto/qml/qqmllanguage/data/invalidID.7.qml create mode 100644 tests/auto/qml/qqmllanguage/data/invalidID.8.errors.txt create mode 100644 tests/auto/qml/qqmllanguage/data/invalidID.8.qml create mode 100644 tests/auto/qml/qqmllanguage/data/invalidID.9.errors.txt create mode 100644 tests/auto/qml/qqmllanguage/data/invalidID.9.qml create mode 100644 tests/auto/qml/qqmllanguage/data/invalidID.errors.txt create mode 100644 tests/auto/qml/qqmllanguage/data/invalidID.qml create mode 100644 tests/auto/qml/qqmllanguage/data/invalidImportID.errors.txt create mode 100644 tests/auto/qml/qqmllanguage/data/invalidImportID.qml create mode 100644 tests/auto/qml/qqmllanguage/data/invalidOn.errors.txt create mode 100644 tests/auto/qml/qqmllanguage/data/invalidOn.qml create mode 100644 tests/auto/qml/qqmllanguage/data/invalidProperty.errors.txt create mode 100644 tests/auto/qml/qqmllanguage/data/invalidProperty.qml create mode 100644 tests/auto/qml/qqmllanguage/data/invalidRoot.1.errors.txt create mode 100644 tests/auto/qml/qqmllanguage/data/invalidRoot.1.qml create mode 100644 tests/auto/qml/qqmllanguage/data/invalidRoot.2.errors.txt create mode 100644 tests/auto/qml/qqmllanguage/data/invalidRoot.2.qml create mode 100644 tests/auto/qml/qqmllanguage/data/invalidRoot.3.errors.txt create mode 100644 tests/auto/qml/qqmllanguage/data/invalidRoot.3.qml create mode 100644 tests/auto/qml/qqmllanguage/data/invalidRoot.4.errors.txt create mode 100644 tests/auto/qml/qqmllanguage/data/invalidRoot.4.qml create mode 100644 tests/auto/qml/qqmllanguage/data/invalidTypeName.1.errors.txt create mode 100644 tests/auto/qml/qqmllanguage/data/invalidTypeName.1.qml create mode 100644 tests/auto/qml/qqmllanguage/data/invalidTypeName.2.errors.txt create mode 100644 tests/auto/qml/qqmllanguage/data/invalidTypeName.2.qml create mode 100644 tests/auto/qml/qqmllanguage/data/invalidTypeName.3.errors.txt create mode 100644 tests/auto/qml/qqmllanguage/data/invalidTypeName.3.qml create mode 100644 tests/auto/qml/qqmllanguage/data/invalidTypeName.4.errors.txt create mode 100644 tests/auto/qml/qqmllanguage/data/invalidTypeName.4.qml create mode 100644 tests/auto/qml/qqmllanguage/data/lib/com/nokia/PureJsModule.1.6/FirstAPI.1.6.js create mode 100644 tests/auto/qml/qqmllanguage/data/lib/com/nokia/PureJsModule.1.6/FirstAPI.js create mode 100644 tests/auto/qml/qqmllanguage/data/lib/com/nokia/PureJsModule.1.6/SecondAPI.js create mode 100644 tests/auto/qml/qqmllanguage/data/lib/com/nokia/PureJsModule.1.6/qmldir create mode 100644 tests/auto/qml/qqmllanguage/data/lib/com/nokia/PureJsModule/FirstAPI.js create mode 100644 tests/auto/qml/qqmllanguage/data/lib/com/nokia/PureJsModule/SecondAPI.js create mode 100644 tests/auto/qml/qqmllanguage/data/lib/com/nokia/PureJsModule/qmldir create mode 100644 tests/auto/qml/qqmllanguage/data/lib/com/nokia/VersionedOnlyJsModule.9.0/SomeAPI.js create mode 100644 tests/auto/qml/qqmllanguage/data/lib/com/nokia/VersionedOnlyJsModule.9.0/qmldir create mode 100644 tests/auto/qml/qqmllanguage/data/lib/com/nokia/installedtest/InstalledTest.qml create mode 100644 tests/auto/qml/qqmllanguage/data/lib/com/nokia/installedtest/InstalledTest2.qml create mode 100644 tests/auto/qml/qqmllanguage/data/lib/com/nokia/installedtest/LocalLast.qml create mode 100644 tests/auto/qml/qqmllanguage/data/lib/com/nokia/installedtest/PrivateType.qml create mode 100644 tests/auto/qml/qqmllanguage/data/lib/com/nokia/installedtest/qmldir create mode 100644 tests/auto/qml/qqmllanguage/data/lib/com/nokia/installedtest0/InstalledTest.qml create mode 100644 tests/auto/qml/qqmllanguage/data/lib/com/nokia/installedtest0/InstalledTest2.qml create mode 100644 tests/auto/qml/qqmllanguage/data/lib/com/nokia/installedtest0/qmldir create mode 100644 tests/auto/qml/qqmllanguage/data/listAssignment.1.errors.txt create mode 100644 tests/auto/qml/qqmllanguage/data/listAssignment.1.qml create mode 100644 tests/auto/qml/qqmllanguage/data/listAssignment.2.errors.txt create mode 100644 tests/auto/qml/qqmllanguage/data/listAssignment.2.qml create mode 100644 tests/auto/qml/qqmllanguage/data/listAssignment.3.errors.txt create mode 100644 tests/auto/qml/qqmllanguage/data/listAssignment.3.qml create mode 100644 tests/auto/qml/qqmllanguage/data/listItemDeleteSelf.qml create mode 100644 tests/auto/qml/qqmllanguage/data/listProperties.qml create mode 100644 tests/auto/qml/qqmllanguage/data/majorVersionIsolation.errors.txt create mode 100644 tests/auto/qml/qqmllanguage/data/majorVersionIsolation.qml create mode 100644 tests/auto/qml/qqmllanguage/data/metaobjectRevision.1.errors.txt create mode 100644 tests/auto/qml/qqmllanguage/data/metaobjectRevision.1.qml create mode 100644 tests/auto/qml/qqmllanguage/data/metaobjectRevision.2.errors.txt create mode 100644 tests/auto/qml/qqmllanguage/data/metaobjectRevision.2.qml create mode 100644 tests/auto/qml/qqmllanguage/data/metaobjectRevision.3.errors.txt create mode 100644 tests/auto/qml/qqmllanguage/data/metaobjectRevision.3.qml create mode 100644 tests/auto/qml/qqmllanguage/data/method.1.errors.txt create mode 100644 tests/auto/qml/qqmllanguage/data/method.1.qml create mode 100644 tests/auto/qml/qqmllanguage/data/missingObject.errors.txt create mode 100644 tests/auto/qml/qqmllanguage/data/missingObject.qml create mode 100644 tests/auto/qml/qqmllanguage/data/missingSignal.errors.txt create mode 100644 tests/auto/qml/qqmllanguage/data/missingSignal.qml create mode 100644 tests/auto/qml/qqmllanguage/data/missingValueTypeProperty.errors.txt create mode 100644 tests/auto/qml/qqmllanguage/data/missingValueTypeProperty.qml create mode 100644 tests/auto/qml/qqmllanguage/data/multiSet.1.errors.txt create mode 100644 tests/auto/qml/qqmllanguage/data/multiSet.1.qml create mode 100644 tests/auto/qml/qqmllanguage/data/multiSet.10.errors.txt create mode 100644 tests/auto/qml/qqmllanguage/data/multiSet.10.qml create mode 100644 tests/auto/qml/qqmllanguage/data/multiSet.11.errors.txt create mode 100644 tests/auto/qml/qqmllanguage/data/multiSet.11.qml create mode 100644 tests/auto/qml/qqmllanguage/data/multiSet.2.errors.txt create mode 100644 tests/auto/qml/qqmllanguage/data/multiSet.2.qml create mode 100644 tests/auto/qml/qqmllanguage/data/multiSet.3.errors.txt create mode 100644 tests/auto/qml/qqmllanguage/data/multiSet.3.qml create mode 100644 tests/auto/qml/qqmllanguage/data/multiSet.4.errors.txt create mode 100644 tests/auto/qml/qqmllanguage/data/multiSet.4.qml create mode 100644 tests/auto/qml/qqmllanguage/data/multiSet.5.errors.txt create mode 100644 tests/auto/qml/qqmllanguage/data/multiSet.5.qml create mode 100644 tests/auto/qml/qqmllanguage/data/multiSet.6.errors.txt create mode 100644 tests/auto/qml/qqmllanguage/data/multiSet.6.qml create mode 100644 tests/auto/qml/qqmllanguage/data/multiSet.7.errors.txt create mode 100644 tests/auto/qml/qqmllanguage/data/multiSet.7.qml create mode 100644 tests/auto/qml/qqmllanguage/data/multiSet.8.errors.txt create mode 100644 tests/auto/qml/qqmllanguage/data/multiSet.8.qml create mode 100644 tests/auto/qml/qqmllanguage/data/multiSet.9.errors.txt create mode 100644 tests/auto/qml/qqmllanguage/data/multiSet.9.qml create mode 100644 tests/auto/qml/qqmllanguage/data/nestedComponentRoots.qml create mode 100644 tests/auto/qml/qqmllanguage/data/nestedErrors.errors.txt create mode 100644 tests/auto/qml/qqmllanguage/data/nestedErrors.qml create mode 100644 tests/auto/qml/qqmllanguage/data/noCreation.errors.txt create mode 100644 tests/auto/qml/qqmllanguage/data/noCreation.qml create mode 100644 tests/auto/qml/qqmllanguage/data/nonScriptableProperty.errors.txt create mode 100644 tests/auto/qml/qqmllanguage/data/nonScriptableProperty.qml create mode 100644 tests/auto/qml/qqmllanguage/data/nonexistantProperty.1.errors.txt create mode 100644 tests/auto/qml/qqmllanguage/data/nonexistantProperty.1.qml create mode 100644 tests/auto/qml/qqmllanguage/data/nonexistantProperty.2.errors.txt create mode 100644 tests/auto/qml/qqmllanguage/data/nonexistantProperty.2.qml create mode 100644 tests/auto/qml/qqmllanguage/data/nonexistantProperty.3.errors.txt create mode 100644 tests/auto/qml/qqmllanguage/data/nonexistantProperty.3.qml create mode 100644 tests/auto/qml/qqmllanguage/data/nonexistantProperty.4.errors.txt create mode 100644 tests/auto/qml/qqmllanguage/data/nonexistantProperty.4.qml create mode 100644 tests/auto/qml/qqmllanguage/data/nonexistantProperty.5.errors.txt create mode 100644 tests/auto/qml/qqmllanguage/data/nonexistantProperty.5.qml create mode 100644 tests/auto/qml/qqmllanguage/data/nonexistantProperty.6.errors.txt create mode 100644 tests/auto/qml/qqmllanguage/data/nonexistantProperty.6.qml create mode 100644 tests/auto/qml/qqmllanguage/data/notAvailable.errors.txt create mode 100644 tests/auto/qml/qqmllanguage/data/notAvailable.qml create mode 100644 tests/auto/qml/qqmllanguage/data/nullDotProperty.errors.txt create mode 100644 tests/auto/qml/qqmllanguage/data/nullDotProperty.qml create mode 100644 tests/auto/qml/qqmllanguage/data/objectValueTypeProperty.errors.txt create mode 100644 tests/auto/qml/qqmllanguage/data/objectValueTypeProperty.qml create mode 100644 tests/auto/qml/qqmllanguage/data/onCompleted.qml create mode 100644 tests/auto/qml/qqmllanguage/data/onDestruction.qml create mode 100644 tests/auto/qml/qqmllanguage/data/property.1.errors.txt create mode 100644 tests/auto/qml/qqmllanguage/data/property.1.qml create mode 100644 tests/auto/qml/qqmllanguage/data/property.2.errors.txt create mode 100644 tests/auto/qml/qqmllanguage/data/property.2.qml create mode 100644 tests/auto/qml/qqmllanguage/data/property.3.errors.txt create mode 100644 tests/auto/qml/qqmllanguage/data/property.3.qml create mode 100644 tests/auto/qml/qqmllanguage/data/property.4.errors.txt create mode 100644 tests/auto/qml/qqmllanguage/data/property.4.qml create mode 100644 tests/auto/qml/qqmllanguage/data/property.6.errors.txt create mode 100644 tests/auto/qml/qqmllanguage/data/property.6.qml create mode 100644 tests/auto/qml/qqmllanguage/data/property.7.errors.txt create mode 100644 tests/auto/qml/qqmllanguage/data/property.7.qml create mode 100644 tests/auto/qml/qqmllanguage/data/propertyInit.1.qml create mode 100644 tests/auto/qml/qqmllanguage/data/propertyInit.2.qml create mode 100644 tests/auto/qml/qqmllanguage/data/propertyValueSource.2.qml create mode 100644 tests/auto/qml/qqmllanguage/data/propertyValueSource.qml create mode 100644 tests/auto/qml/qqmllanguage/data/qmlAttachedPropertiesObjectMethod.1.qml create mode 100644 tests/auto/qml/qqmllanguage/data/qmlAttachedPropertiesObjectMethod.2.qml create mode 100644 tests/auto/qml/qqmllanguage/data/qtest/qml/qqmllanguage/LocalInternal.qml create mode 100644 tests/auto/qml/qqmllanguage/data/qtest/qml/qqmllanguage/Test.qml create mode 100644 tests/auto/qml/qqmllanguage/data/qtest/qml/qqmllanguage/TestLocal.qml create mode 100644 tests/auto/qml/qqmllanguage/data/qtest/qml/qqmllanguage/TestNamed.qml create mode 100644 tests/auto/qml/qqmllanguage/data/qtest/qml/qqmllanguage/TestSubDir.qml create mode 100644 tests/auto/qml/qqmllanguage/data/qtest/qml/qqmllanguage/UndeclaredLocal.qml create mode 100644 tests/auto/qml/qqmllanguage/data/qtest/qml/qqmllanguage/WrongTestLocal.qml create mode 100644 tests/auto/qml/qqmllanguage/data/qtest/qml/qqmllanguage/noqmldir/Test.qml create mode 100644 tests/auto/qml/qqmllanguage/data/qtest/qml/qqmllanguage/pics/blue.png create mode 100644 tests/auto/qml/qqmllanguage/data/qtest/qml/qqmllanguage/qmldir create mode 100644 tests/auto/qml/qqmllanguage/data/qtest/qml/qqmllanguage/subdir/SubTest.qml create mode 100644 tests/auto/qml/qqmllanguage/data/qtest/qml/qqmllanguage/subdir/qmldir create mode 100644 tests/auto/qml/qqmllanguage/data/readOnly.1.errors.txt create mode 100644 tests/auto/qml/qqmllanguage/data/readOnly.1.qml create mode 100644 tests/auto/qml/qqmllanguage/data/readOnly.2.errors.txt create mode 100644 tests/auto/qml/qqmllanguage/data/readOnly.2.qml create mode 100644 tests/auto/qml/qqmllanguage/data/readOnly.3.errors.txt create mode 100644 tests/auto/qml/qqmllanguage/data/readOnly.3.qml create mode 100644 tests/auto/qml/qqmllanguage/data/readOnly.4.errors.txt create mode 100644 tests/auto/qml/qqmllanguage/data/readOnly.4.qml create mode 100644 tests/auto/qml/qqmllanguage/data/readOnly.5.errors.txt create mode 100644 tests/auto/qml/qqmllanguage/data/readOnly.5.qml create mode 100644 tests/auto/qml/qqmllanguage/data/readonly.qml create mode 100644 tests/auto/qml/qqmllanguage/data/registrationOrder.qml create mode 100644 tests/auto/qml/qqmllanguage/data/remoteLoadCrash.qml create mode 100644 tests/auto/qml/qqmllanguage/data/revisions11.qml create mode 100644 tests/auto/qml/qqmllanguage/data/revisionsbasesub11.qml create mode 100644 tests/auto/qml/qqmllanguage/data/revisionssub11.qml create mode 100644 tests/auto/qml/qqmllanguage/data/rootAsQmlComponent.qml create mode 100644 tests/auto/qml/qqmllanguage/data/scriptString.1.errors.txt create mode 100644 tests/auto/qml/qqmllanguage/data/scriptString.1.qml create mode 100644 tests/auto/qml/qqmllanguage/data/scriptString.2.errors.txt create mode 100644 tests/auto/qml/qqmllanguage/data/scriptString.2.qml create mode 100644 tests/auto/qml/qqmllanguage/data/scriptString.qml create mode 100644 tests/auto/qml/qqmllanguage/data/scriptString2.qml create mode 100644 tests/auto/qml/qqmllanguage/data/scriptString3.qml create mode 100644 tests/auto/qml/qqmllanguage/data/scriptString4.qml create mode 100644 tests/auto/qml/qqmllanguage/data/signal.1.errors.txt create mode 100644 tests/auto/qml/qqmllanguage/data/signal.1.qml create mode 100644 tests/auto/qml/qqmllanguage/data/signal.2.errors.txt create mode 100644 tests/auto/qml/qqmllanguage/data/signal.2.qml create mode 100644 tests/auto/qml/qqmllanguage/data/signal.3.errors.txt create mode 100644 tests/auto/qml/qqmllanguage/data/signal.3.qml create mode 100644 tests/auto/qml/qqmllanguage/data/signal.4.errors.txt create mode 100644 tests/auto/qml/qqmllanguage/data/signal.4.qml create mode 100644 tests/auto/qml/qqmllanguage/data/simpleBindings.qml create mode 100644 tests/auto/qml/qqmllanguage/data/simpleContainer.qml create mode 100644 tests/auto/qml/qqmllanguage/data/simpleObject.qml create mode 100644 tests/auto/qml/qqmllanguage/data/singularProperty.2.errors.txt create mode 100644 tests/auto/qml/qqmllanguage/data/singularProperty.2.qml create mode 100644 tests/auto/qml/qqmllanguage/data/singularProperty.errors.txt create mode 100644 tests/auto/qml/qqmllanguage/data/singularProperty.qml create mode 100644 tests/auto/qml/qqmllanguage/data/subdir/Test.qml create mode 100644 tests/auto/qml/qqmllanguage/data/subdir/subsubdir/SubTest.qml create mode 100644 tests/auto/qml/qqmllanguage/data/test.js create mode 100644 tests/auto/qml/qqmllanguage/data/test2.js create mode 100644 tests/auto/qml/qqmllanguage/data/unregisteredObject.errors.txt create mode 100644 tests/auto/qml/qqmllanguage/data/unregisteredObject.qml create mode 100644 tests/auto/qml/qqmllanguage/data/unsupportedProperty.errors.txt create mode 100644 tests/auto/qml/qqmllanguage/data/unsupportedProperty.qml create mode 100644 tests/auto/qml/qqmllanguage/data/valueTypes.qml create mode 100644 tests/auto/qml/qqmllanguage/data/variantNotify.qml create mode 100644 tests/auto/qml/qqmllanguage/data/versionedbase.qml create mode 100644 tests/auto/qml/qqmllanguage/data/wrongType.1.errors.txt create mode 100644 tests/auto/qml/qqmllanguage/data/wrongType.1.qml create mode 100644 tests/auto/qml/qqmllanguage/data/wrongType.10.errors.txt create mode 100644 tests/auto/qml/qqmllanguage/data/wrongType.10.qml create mode 100644 tests/auto/qml/qqmllanguage/data/wrongType.11.errors.txt create mode 100644 tests/auto/qml/qqmllanguage/data/wrongType.11.qml create mode 100644 tests/auto/qml/qqmllanguage/data/wrongType.12.errors.txt create mode 100644 tests/auto/qml/qqmllanguage/data/wrongType.12.qml create mode 100644 tests/auto/qml/qqmllanguage/data/wrongType.13.errors.txt create mode 100644 tests/auto/qml/qqmllanguage/data/wrongType.13.qml create mode 100644 tests/auto/qml/qqmllanguage/data/wrongType.14.errors.txt create mode 100644 tests/auto/qml/qqmllanguage/data/wrongType.14.qml create mode 100644 tests/auto/qml/qqmllanguage/data/wrongType.15.errors.txt create mode 100644 tests/auto/qml/qqmllanguage/data/wrongType.15.qml create mode 100644 tests/auto/qml/qqmllanguage/data/wrongType.16.errors.txt create mode 100644 tests/auto/qml/qqmllanguage/data/wrongType.16.qml create mode 100644 tests/auto/qml/qqmllanguage/data/wrongType.17.errors.txt create mode 100644 tests/auto/qml/qqmllanguage/data/wrongType.17.qml create mode 100644 tests/auto/qml/qqmllanguage/data/wrongType.2.errors.txt create mode 100644 tests/auto/qml/qqmllanguage/data/wrongType.2.qml create mode 100644 tests/auto/qml/qqmllanguage/data/wrongType.3.errors.txt create mode 100644 tests/auto/qml/qqmllanguage/data/wrongType.3.qml create mode 100644 tests/auto/qml/qqmllanguage/data/wrongType.4.errors.txt create mode 100644 tests/auto/qml/qqmllanguage/data/wrongType.4.qml create mode 100644 tests/auto/qml/qqmllanguage/data/wrongType.5.errors.txt create mode 100644 tests/auto/qml/qqmllanguage/data/wrongType.5.qml create mode 100644 tests/auto/qml/qqmllanguage/data/wrongType.6.errors.txt create mode 100644 tests/auto/qml/qqmllanguage/data/wrongType.6.qml create mode 100644 tests/auto/qml/qqmllanguage/data/wrongType.7.errors.txt create mode 100644 tests/auto/qml/qqmllanguage/data/wrongType.7.qml create mode 100644 tests/auto/qml/qqmllanguage/data/wrongType.8.errors.txt create mode 100644 tests/auto/qml/qqmllanguage/data/wrongType.8.qml create mode 100644 tests/auto/qml/qqmllanguage/data/wrongType.9.errors.txt create mode 100644 tests/auto/qml/qqmllanguage/data/wrongType.9.qml create mode 100644 tests/auto/qml/qqmllanguage/qqmllanguage.pro create mode 100644 tests/auto/qml/qqmllanguage/testtypes.cpp create mode 100644 tests/auto/qml/qqmllanguage/testtypes.h create mode 100644 tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp create mode 100644 tests/auto/qml/qqmllistreference/data/MyType.qml create mode 100644 tests/auto/qml/qqmllistreference/data/engineTypes.qml create mode 100644 tests/auto/qml/qqmllistreference/data/variantToList.qml create mode 100644 tests/auto/qml/qqmllistreference/qqmllistreference.pro create mode 100644 tests/auto/qml/qqmllistreference/tst_qqmllistreference.cpp create mode 100644 tests/auto/qml/qqmllocale/data/date.qml create mode 100644 tests/auto/qml/qqmllocale/data/functions.qml create mode 100644 tests/auto/qml/qqmllocale/data/localeCompare.qml create mode 100644 tests/auto/qml/qqmllocale/data/number.qml create mode 100644 tests/auto/qml/qqmllocale/data/properties.qml create mode 100644 tests/auto/qml/qqmllocale/qqmllocale.pro create mode 100644 tests/auto/qml/qqmllocale/tst_qqmllocale.cpp create mode 100644 tests/auto/qml/qqmlmetatype/qqmlmetatype.pro create mode 100644 tests/auto/qml/qqmlmetatype/tst_qqmlmetatype.cpp create mode 100644 tests/auto/qml/qqmlmoduleplugin/data/implicit1/implicitQmldir.errors.txt create mode 100644 tests/auto/qml/qqmlmoduleplugin/data/implicit1/qmldir create mode 100644 tests/auto/qml/qqmlmoduleplugin/data/implicit1/temptest.qml create mode 100644 tests/auto/qml/qqmlmoduleplugin/data/implicit2/Test.qml create mode 100644 tests/auto/qml/qqmlmoduleplugin/data/implicit2/implicitQmldir.2.errors.txt create mode 100644 tests/auto/qml/qqmlmoduleplugin/data/implicit2/qmldir create mode 100644 tests/auto/qml/qqmlmoduleplugin/data/implicit2/temptest2.qml create mode 100644 tests/auto/qml/qqmlmoduleplugin/data/importsMixedQmlCppPlugin.2.qml create mode 100644 tests/auto/qml/qqmlmoduleplugin/data/importsMixedQmlCppPlugin.qml create mode 100644 tests/auto/qml/qqmlmoduleplugin/data/incorrectCase.qml create mode 100644 tests/auto/qml/qqmlmoduleplugin/data/pluginWithQmlFile.qml create mode 100644 tests/auto/qml/qqmlmoduleplugin/data/versionNotInstalled.2.errors.txt create mode 100644 tests/auto/qml/qqmlmoduleplugin/data/versionNotInstalled.2.qml create mode 100644 tests/auto/qml/qqmlmoduleplugin/data/versionNotInstalled.errors.txt create mode 100644 tests/auto/qml/qqmlmoduleplugin/data/versionNotInstalled.qml create mode 100644 tests/auto/qml/qqmlmoduleplugin/data/works.qml create mode 100644 tests/auto/qml/qqmlmoduleplugin/data/works2.qml create mode 100644 tests/auto/qml/qqmlmoduleplugin/data/works21.qml create mode 100644 tests/auto/qml/qqmlmoduleplugin/imports/com/nokia/AutoTestPluginWithQmlFile/MyQmlFile.qml create mode 100644 tests/auto/qml/qqmlmoduleplugin/imports/com/nokia/AutoTestPluginWithQmlFile/qmldir create mode 100644 tests/auto/qml/qqmlmoduleplugin/imports/com/nokia/AutoTestQmlMixedPluginType/Foo.qml create mode 100644 tests/auto/qml/qqmlmoduleplugin/imports/com/nokia/AutoTestQmlMixedPluginType/qmldir create mode 100644 tests/auto/qml/qqmlmoduleplugin/imports/com/nokia/AutoTestQmlPluginType.2.1/qmldir create mode 100644 tests/auto/qml/qqmlmoduleplugin/imports/com/nokia/AutoTestQmlPluginType.2/qmldir create mode 100644 tests/auto/qml/qqmlmoduleplugin/imports/com/nokia/AutoTestQmlPluginType/qmldir create mode 100644 tests/auto/qml/qqmlmoduleplugin/imports/com/nokia/AutoTestQmlVersionPluginType/qmldir create mode 100644 tests/auto/qml/qqmlmoduleplugin/imports/com/nokia/PureQmlModule/ComponentA.qml create mode 100644 tests/auto/qml/qqmlmoduleplugin/imports/com/nokia/PureQmlModule/ComponentB.qml create mode 100644 tests/auto/qml/qqmlmoduleplugin/imports/com/nokia/PureQmlModule/qmldir create mode 100644 tests/auto/qml/qqmlmoduleplugin/imports/com/nokia/WrongCase/qmldir create mode 100644 tests/auto/qml/qqmlmoduleplugin/plugin.2.1/plugin.2.1.pro create mode 100644 tests/auto/qml/qqmlmoduleplugin/plugin.2.1/plugin.cpp create mode 100644 tests/auto/qml/qqmlmoduleplugin/plugin.2/plugin.2.pro create mode 100644 tests/auto/qml/qqmlmoduleplugin/plugin.2/plugin.cpp create mode 100644 tests/auto/qml/qqmlmoduleplugin/plugin/plugin.cpp create mode 100644 tests/auto/qml/qqmlmoduleplugin/plugin/plugin.pro create mode 100644 tests/auto/qml/qqmlmoduleplugin/pluginMixed/plugin.cpp create mode 100644 tests/auto/qml/qqmlmoduleplugin/pluginMixed/pluginMixed.pro create mode 100644 tests/auto/qml/qqmlmoduleplugin/pluginVersion/plugin.cpp create mode 100644 tests/auto/qml/qqmlmoduleplugin/pluginVersion/pluginVersion.pro create mode 100644 tests/auto/qml/qqmlmoduleplugin/pluginWithQmlFile/plugin.cpp create mode 100644 tests/auto/qml/qqmlmoduleplugin/pluginWithQmlFile/pluginWithQmlFile.pro create mode 100644 tests/auto/qml/qqmlmoduleplugin/pluginWrongCase/plugin.cpp create mode 100644 tests/auto/qml/qqmlmoduleplugin/pluginWrongCase/pluginWrongCase.pro create mode 100644 tests/auto/qml/qqmlmoduleplugin/qqmlmoduleplugin.pro create mode 100644 tests/auto/qml/qqmlmoduleplugin/tst_qqmlmoduleplugin.cpp create mode 100644 tests/auto/qml/qqmlmoduleplugin/tst_qqmlmoduleplugin.pro create mode 100644 tests/auto/qml/qqmlparser/qqmlparser.pro create mode 100644 tests/auto/qml/qqmlparser/tst_qqmlparser.cpp create mode 100644 tests/auto/qml/qqmlpixmapcache/data/dataLeak.qml create mode 100644 tests/auto/qml/qqmlproperty/data/NoContextTypeA.qml create mode 100644 tests/auto/qml/qqmlproperty/data/NoContextTypeB.qml create mode 100644 tests/auto/qml/qqmlproperty/data/TestType.qml create mode 100644 tests/auto/qml/qqmlproperty/data/aliasPropertyBindings.qml create mode 100644 tests/auto/qml/qqmlproperty/data/assignEmptyVariantMap.qml create mode 100644 tests/auto/qml/qqmlproperty/data/readSynthesizedObject.qml create mode 100644 tests/auto/qml/qqmlproperty/qqmlproperty.pro create mode 100644 tests/auto/qml/qqmlproperty/tst_qqmlproperty.cpp create mode 100644 tests/auto/qml/qqmlpropertycache/qqmlpropertycache.pro create mode 100644 tests/auto/qml/qqmlpropertycache/tst_qqmlpropertycache.cpp create mode 100644 tests/auto/qml/qqmlpropertymap/qqmlpropertymap.pro create mode 100644 tests/auto/qml/qqmlpropertymap/tst_qqmlpropertymap.cpp create mode 100644 tests/auto/qml/qqmlqt/data/atob.qml create mode 100644 tests/auto/qml/qqmlqt/data/btoa.qml create mode 100644 tests/auto/qml/qqmlqt/data/createComponent.qml create mode 100644 tests/auto/qml/qqmlqt/data/createComponentData.qml create mode 100644 tests/auto/qml/qqmlqt/data/createComponent_lib.js create mode 100644 tests/auto/qml/qqmlqt/data/createComponent_lib.qml create mode 100644 tests/auto/qml/qqmlqt/data/createQmlObject.qml create mode 100644 tests/auto/qml/qqmlqt/data/darker.qml create mode 100644 tests/auto/qml/qqmlqt/data/dateTimeConversion.qml create mode 100644 tests/auto/qml/qqmlqt/data/enums.qml create mode 100644 tests/auto/qml/qqmlqt/data/fontFamilies.qml create mode 100644 tests/auto/qml/qqmlqt/data/formatting.qml create mode 100644 tests/auto/qml/qqmlqt/data/hsla.qml create mode 100644 tests/auto/qml/qqmlqt/data/isQtObject.qml create mode 100644 tests/auto/qml/qqmlqt/data/lighter.qml create mode 100644 tests/auto/qml/qqmlqt/data/md5.qml create mode 100644 tests/auto/qml/qqmlqt/data/openUrlExternally.qml create mode 100644 tests/auto/qml/qqmlqt/data/openUrlExternally_lib.js create mode 100644 tests/auto/qml/qqmlqt/data/openUrlExternally_lib.qml create mode 100644 tests/auto/qml/qqmlqt/data/point.qml create mode 100644 tests/auto/qml/qqmlqt/data/quit.qml create mode 100644 tests/auto/qml/qqmlqt/data/rect.qml create mode 100644 tests/auto/qml/qqmlqt/data/resolvedUrl.qml create mode 100644 tests/auto/qml/qqmlqt/data/rgba.qml create mode 100644 tests/auto/qml/qqmlqt/data/size.qml create mode 100644 tests/auto/qml/qqmlqt/data/tint.qml create mode 100644 tests/auto/qml/qqmlqt/data/vector.qml create mode 100644 tests/auto/qml/qqmlqt/data/vector4.qml create mode 100644 tests/auto/qml/qqmlqt/qqmlqt.pro create mode 100644 tests/auto/qml/qqmlqt/tst_qqmlqt.cpp create mode 100644 tests/auto/qml/qqmlsqldatabase/data/README create mode 100644 tests/auto/qml/qqmlsqldatabase/data/changeversion.js create mode 100644 tests/auto/qml/qqmlsqldatabase/data/creation-a.js create mode 100644 tests/auto/qml/qqmlsqldatabase/data/creation.js create mode 100644 tests/auto/qml/qqmlsqldatabase/data/error-a.js create mode 100644 tests/auto/qml/qqmlsqldatabase/data/error-b.js create mode 100644 tests/auto/qml/qqmlsqldatabase/data/error-creation.js create mode 100644 tests/auto/qml/qqmlsqldatabase/data/error-notransaction.js create mode 100644 tests/auto/qml/qqmlsqldatabase/data/error-outsidetransaction.js create mode 100644 tests/auto/qml/qqmlsqldatabase/data/iteration-forwardonly.js create mode 100644 tests/auto/qml/qqmlsqldatabase/data/iteration.js create mode 100644 tests/auto/qml/qqmlsqldatabase/data/readonly-error.js create mode 100644 tests/auto/qml/qqmlsqldatabase/data/readonly.js create mode 100644 tests/auto/qml/qqmlsqldatabase/data/reopen1.js create mode 100644 tests/auto/qml/qqmlsqldatabase/data/reopen2.js create mode 100644 tests/auto/qml/qqmlsqldatabase/data/selection-bindnames.js create mode 100644 tests/auto/qml/qqmlsqldatabase/data/selection.js create mode 100644 tests/auto/qml/qqmlsqldatabase/qqmlsqldatabase.pro create mode 100644 tests/auto/qml/qqmlsqldatabase/tst_qqmlsqldatabase.cpp create mode 100644 tests/auto/qml/qqmltranslation/data/idtranslation.qml create mode 100644 tests/auto/qml/qqmltranslation/data/qml_fr.qm create mode 100644 tests/auto/qml/qqmltranslation/data/qml_fr.ts create mode 100644 tests/auto/qml/qqmltranslation/data/qmlid_fr.qm create mode 100644 tests/auto/qml/qqmltranslation/data/qmlid_fr.ts create mode 100644 tests/auto/qml/qqmltranslation/data/translation.qml create mode 100644 tests/auto/qml/qqmltranslation/data/translation.qrc create mode 100644 tests/auto/qml/qqmltranslation/qqmltranslation.pro create mode 100644 tests/auto/qml/qqmltranslation/tst_qqmltranslation.cpp create mode 100644 tests/auto/qml/qqmlvaluetypes/data/BindingsSpliceCorrectlyType.qml create mode 100644 tests/auto/qml/qqmlvaluetypes/data/BindingsSpliceCorrectlyType4.qml create mode 100644 tests/auto/qml/qqmlvaluetypes/data/BindingsSpliceCorrectlyType5.qml create mode 100644 tests/auto/qml/qqmlvaluetypes/data/autoBindingRemoval.2.qml create mode 100644 tests/auto/qml/qqmlvaluetypes/data/autoBindingRemoval.3.qml create mode 100644 tests/auto/qml/qqmlvaluetypes/data/autoBindingRemoval.qml create mode 100644 tests/auto/qml/qqmlvaluetypes/data/bindingAssignment.qml create mode 100644 tests/auto/qml/qqmlvaluetypes/data/bindingConflict.qml create mode 100644 tests/auto/qml/qqmlvaluetypes/data/bindingRead.qml create mode 100644 tests/auto/qml/qqmlvaluetypes/data/bindingVariantCopy.qml create mode 100644 tests/auto/qml/qqmlvaluetypes/data/bindingsSpliceCorrectly.1.qml create mode 100644 tests/auto/qml/qqmlvaluetypes/data/bindingsSpliceCorrectly.2.qml create mode 100644 tests/auto/qml/qqmlvaluetypes/data/bindingsSpliceCorrectly.3.qml create mode 100644 tests/auto/qml/qqmlvaluetypes/data/bindingsSpliceCorrectly.4.qml create mode 100644 tests/auto/qml/qqmlvaluetypes/data/bindingsSpliceCorrectly.5.qml create mode 100644 tests/auto/qml/qqmlvaluetypes/data/color_compare.qml create mode 100644 tests/auto/qml/qqmlvaluetypes/data/color_read.qml create mode 100644 tests/auto/qml/qqmlvaluetypes/data/color_write.qml create mode 100644 tests/auto/qml/qqmlvaluetypes/data/conflicting.1.qml create mode 100644 tests/auto/qml/qqmlvaluetypes/data/conflicting.2.qml create mode 100644 tests/auto/qml/qqmlvaluetypes/data/conflicting.3.qml create mode 100644 tests/auto/qml/qqmlvaluetypes/data/deletedObject.js create mode 100644 tests/auto/qml/qqmlvaluetypes/data/deletedObject.qml create mode 100644 tests/auto/qml/qqmlvaluetypes/data/enums.1.qml create mode 100644 tests/auto/qml/qqmlvaluetypes/data/enums.2.qml create mode 100644 tests/auto/qml/qqmlvaluetypes/data/enums.3.qml create mode 100644 tests/auto/qml/qqmlvaluetypes/data/enums.4.qml create mode 100644 tests/auto/qml/qqmlvaluetypes/data/enums.5.qml create mode 100644 tests/auto/qml/qqmlvaluetypes/data/font_compare.qml create mode 100644 tests/auto/qml/qqmlvaluetypes/data/font_read.qml create mode 100644 tests/auto/qml/qqmlvaluetypes/data/font_write.2.qml create mode 100644 tests/auto/qml/qqmlvaluetypes/data/font_write.3.qml create mode 100644 tests/auto/qml/qqmlvaluetypes/data/font_write.4.qml create mode 100644 tests/auto/qml/qqmlvaluetypes/data/font_write.5.qml create mode 100644 tests/auto/qml/qqmlvaluetypes/data/font_write.qml create mode 100644 tests/auto/qml/qqmlvaluetypes/data/matrix4x4_compare.qml create mode 100644 tests/auto/qml/qqmlvaluetypes/data/matrix4x4_read.qml create mode 100644 tests/auto/qml/qqmlvaluetypes/data/matrix4x4_write.qml create mode 100644 tests/auto/qml/qqmlvaluetypes/data/point_compare.qml create mode 100644 tests/auto/qml/qqmlvaluetypes/data/point_read.qml create mode 100644 tests/auto/qml/qqmlvaluetypes/data/point_write.qml create mode 100644 tests/auto/qml/qqmlvaluetypes/data/pointf_compare.qml create mode 100644 tests/auto/qml/qqmlvaluetypes/data/pointf_read.qml create mode 100644 tests/auto/qml/qqmlvaluetypes/data/pointf_write.qml create mode 100644 tests/auto/qml/qqmlvaluetypes/data/quaternion_compare.qml create mode 100644 tests/auto/qml/qqmlvaluetypes/data/quaternion_read.qml create mode 100644 tests/auto/qml/qqmlvaluetypes/data/quaternion_write.qml create mode 100644 tests/auto/qml/qqmlvaluetypes/data/rect_compare.qml create mode 100644 tests/auto/qml/qqmlvaluetypes/data/rect_read.qml create mode 100644 tests/auto/qml/qqmlvaluetypes/data/rect_write.qml create mode 100644 tests/auto/qml/qqmlvaluetypes/data/rectf_compare.qml create mode 100644 tests/auto/qml/qqmlvaluetypes/data/rectf_read.qml create mode 100644 tests/auto/qml/qqmlvaluetypes/data/rectf_write.qml create mode 100644 tests/auto/qml/qqmlvaluetypes/data/returnValues.qml create mode 100644 tests/auto/qml/qqmlvaluetypes/data/scriptAccess.qml create mode 100644 tests/auto/qml/qqmlvaluetypes/data/scriptVariantCopy.qml create mode 100644 tests/auto/qml/qqmlvaluetypes/data/size_compare.qml create mode 100644 tests/auto/qml/qqmlvaluetypes/data/size_read.qml create mode 100644 tests/auto/qml/qqmlvaluetypes/data/size_write.qml create mode 100644 tests/auto/qml/qqmlvaluetypes/data/sizef_compare.qml create mode 100644 tests/auto/qml/qqmlvaluetypes/data/sizef_read.qml create mode 100644 tests/auto/qml/qqmlvaluetypes/data/sizef_write.qml create mode 100644 tests/auto/qml/qqmlvaluetypes/data/sizereadonly_read.qml create mode 100644 tests/auto/qml/qqmlvaluetypes/data/sizereadonly_writeerror.qml create mode 100644 tests/auto/qml/qqmlvaluetypes/data/sizereadonly_writeerror2.qml create mode 100644 tests/auto/qml/qqmlvaluetypes/data/sizereadonly_writeerror3.qml create mode 100644 tests/auto/qml/qqmlvaluetypes/data/sizereadonly_writeerror4.qml create mode 100644 tests/auto/qml/qqmlvaluetypes/data/staticAssignment.qml create mode 100644 tests/auto/qml/qqmlvaluetypes/data/valueInterceptors.qml create mode 100644 tests/auto/qml/qqmlvaluetypes/data/valueSources.qml create mode 100644 tests/auto/qml/qqmlvaluetypes/data/varAssignment.qml create mode 100644 tests/auto/qml/qqmlvaluetypes/data/variant_read.qml create mode 100644 tests/auto/qml/qqmlvaluetypes/data/vector2d_compare.qml create mode 100644 tests/auto/qml/qqmlvaluetypes/data/vector2d_read.qml create mode 100644 tests/auto/qml/qqmlvaluetypes/data/vector2d_write.qml create mode 100644 tests/auto/qml/qqmlvaluetypes/data/vector3d_compare.qml create mode 100644 tests/auto/qml/qqmlvaluetypes/data/vector3d_read.qml create mode 100644 tests/auto/qml/qqmlvaluetypes/data/vector3d_write.qml create mode 100644 tests/auto/qml/qqmlvaluetypes/data/vector4d_compare.qml create mode 100644 tests/auto/qml/qqmlvaluetypes/data/vector4d_read.qml create mode 100644 tests/auto/qml/qqmlvaluetypes/data/vector4d_write.qml create mode 100644 tests/auto/qml/qqmlvaluetypes/qqmlvaluetypes.pro create mode 100644 tests/auto/qml/qqmlvaluetypes/testtypes.cpp create mode 100644 tests/auto/qml/qqmlvaluetypes/testtypes.h create mode 100644 tests/auto/qml/qqmlvaluetypes/tst_qqmlvaluetypes.cpp create mode 100644 tests/auto/qml/qqmlxmlhttprequest/data/abort.expect create mode 100644 tests/auto/qml/qqmlxmlhttprequest/data/abort.qml create mode 100644 tests/auto/qml/qqmlxmlhttprequest/data/abort.reply create mode 100644 tests/auto/qml/qqmlxmlhttprequest/data/abort_opened.qml create mode 100644 tests/auto/qml/qqmlxmlhttprequest/data/abort_unsent.qml create mode 100644 tests/auto/qml/qqmlxmlhttprequest/data/attr.qml create mode 100644 tests/auto/qml/qqmlxmlhttprequest/data/attr.xml create mode 100644 tests/auto/qml/qqmlxmlhttprequest/data/callbackException.qml create mode 100644 tests/auto/qml/qqmlxmlhttprequest/data/cdata.qml create mode 100644 tests/auto/qml/qqmlxmlhttprequest/data/cdata.xml create mode 100644 tests/auto/qml/qqmlxmlhttprequest/data/constructor.qml create mode 100644 tests/auto/qml/qqmlxmlhttprequest/data/defaultState.qml create mode 100644 tests/auto/qml/qqmlxmlhttprequest/data/document.qml create mode 100644 tests/auto/qml/qqmlxmlhttprequest/data/document.xml create mode 100644 tests/auto/qml/qqmlxmlhttprequest/data/domExceptionCodes.qml create mode 100644 tests/auto/qml/qqmlxmlhttprequest/data/element.qml create mode 100644 tests/auto/qml/qqmlxmlhttprequest/data/element.xml create mode 100644 tests/auto/qml/qqmlxmlhttprequest/data/getAllResponseHeaders.qml create mode 100644 tests/auto/qml/qqmlxmlhttprequest/data/getAllResponseHeaders_args.qml create mode 100644 tests/auto/qml/qqmlxmlhttprequest/data/getAllResponseHeaders_sent.qml create mode 100644 tests/auto/qml/qqmlxmlhttprequest/data/getAllResponseHeaders_unsent.qml create mode 100644 tests/auto/qml/qqmlxmlhttprequest/data/getResponseHeader.expect create mode 100644 tests/auto/qml/qqmlxmlhttprequest/data/getResponseHeader.qml create mode 100644 tests/auto/qml/qqmlxmlhttprequest/data/getResponseHeader.reply create mode 100644 tests/auto/qml/qqmlxmlhttprequest/data/getResponseHeader_args.qml create mode 100644 tests/auto/qml/qqmlxmlhttprequest/data/getResponseHeader_sent.qml create mode 100644 tests/auto/qml/qqmlxmlhttprequest/data/getResponseHeader_unsent.qml create mode 100644 tests/auto/qml/qqmlxmlhttprequest/data/instanceStateValues.qml create mode 100644 tests/auto/qml/qqmlxmlhttprequest/data/invalidMethodUsage.qml create mode 100644 tests/auto/qml/qqmlxmlhttprequest/data/open.qml create mode 100644 tests/auto/qml/qqmlxmlhttprequest/data/open_arg_count.1.qml create mode 100644 tests/auto/qml/qqmlxmlhttprequest/data/open_arg_count.2.qml create mode 100644 tests/auto/qml/qqmlxmlhttprequest/data/open_invalid_method.qml create mode 100644 tests/auto/qml/qqmlxmlhttprequest/data/open_network.expect create mode 100644 tests/auto/qml/qqmlxmlhttprequest/data/open_network.reply create mode 100644 tests/auto/qml/qqmlxmlhttprequest/data/open_network.wait create mode 100644 tests/auto/qml/qqmlxmlhttprequest/data/open_sync.qml create mode 100644 tests/auto/qml/qqmlxmlhttprequest/data/open_user.qml create mode 100644 tests/auto/qml/qqmlxmlhttprequest/data/open_username.qml create mode 100644 tests/auto/qml/qqmlxmlhttprequest/data/redirectError.qml create mode 100644 tests/auto/qml/qqmlxmlhttprequest/data/redirectRecur.qml create mode 100644 tests/auto/qml/qqmlxmlhttprequest/data/redirects.qml create mode 100644 tests/auto/qml/qqmlxmlhttprequest/data/redirecttarget.html create mode 100644 tests/auto/qml/qqmlxmlhttprequest/data/responseText.qml create mode 100644 tests/auto/qml/qqmlxmlhttprequest/data/responseXML_invalid.qml create mode 100644 tests/auto/qml/qqmlxmlhttprequest/data/seconddocument.html create mode 100644 tests/auto/qml/qqmlxmlhttprequest/data/send_alreadySent.qml create mode 100644 tests/auto/qml/qqmlxmlhttprequest/data/send_data.1.expect create mode 100644 tests/auto/qml/qqmlxmlhttprequest/data/send_data.1.qml create mode 100644 tests/auto/qml/qqmlxmlhttprequest/data/send_data.2.qml create mode 100644 tests/auto/qml/qqmlxmlhttprequest/data/send_data.3.qml create mode 100644 tests/auto/qml/qqmlxmlhttprequest/data/send_data.4.expect create mode 100644 tests/auto/qml/qqmlxmlhttprequest/data/send_data.4.qml create mode 100644 tests/auto/qml/qqmlxmlhttprequest/data/send_data.5.qml create mode 100644 tests/auto/qml/qqmlxmlhttprequest/data/send_data.6.expect create mode 100644 tests/auto/qml/qqmlxmlhttprequest/data/send_data.6.qml create mode 100644 tests/auto/qml/qqmlxmlhttprequest/data/send_data.7.qml create mode 100644 tests/auto/qml/qqmlxmlhttprequest/data/send_data.reply create mode 100644 tests/auto/qml/qqmlxmlhttprequest/data/send_ignoreData.qml create mode 100644 tests/auto/qml/qqmlxmlhttprequest/data/send_ignoreData.reply create mode 100644 tests/auto/qml/qqmlxmlhttprequest/data/send_ignoreData_DELETE.expect create mode 100644 tests/auto/qml/qqmlxmlhttprequest/data/send_ignoreData_GET.expect create mode 100644 tests/auto/qml/qqmlxmlhttprequest/data/send_ignoreData_HEAD.expect create mode 100644 tests/auto/qml/qqmlxmlhttprequest/data/send_unsent.qml create mode 100644 tests/auto/qml/qqmlxmlhttprequest/data/setRequestHeader.expect create mode 100644 tests/auto/qml/qqmlxmlhttprequest/data/setRequestHeader.qml create mode 100644 tests/auto/qml/qqmlxmlhttprequest/data/setRequestHeader.reply create mode 100644 tests/auto/qml/qqmlxmlhttprequest/data/setRequestHeader_args.qml create mode 100644 tests/auto/qml/qqmlxmlhttprequest/data/setRequestHeader_caseInsensitive.qml create mode 100644 tests/auto/qml/qqmlxmlhttprequest/data/setRequestHeader_illegalName.qml create mode 100644 tests/auto/qml/qqmlxmlhttprequest/data/setRequestHeader_sent.qml create mode 100644 tests/auto/qml/qqmlxmlhttprequest/data/setRequestHeader_unsent.qml create mode 100644 tests/auto/qml/qqmlxmlhttprequest/data/staticStateValues.qml create mode 100644 tests/auto/qml/qqmlxmlhttprequest/data/status.200.reply create mode 100644 tests/auto/qml/qqmlxmlhttprequest/data/status.400.reply create mode 100644 tests/auto/qml/qqmlxmlhttprequest/data/status.404.reply create mode 100644 tests/auto/qml/qqmlxmlhttprequest/data/status.expect create mode 100644 tests/auto/qml/qqmlxmlhttprequest/data/status.qml create mode 100644 tests/auto/qml/qqmlxmlhttprequest/data/statusText.qml create mode 100644 tests/auto/qml/qqmlxmlhttprequest/data/testdocument.html create mode 100644 tests/auto/qml/qqmlxmlhttprequest/data/text.qml create mode 100644 tests/auto/qml/qqmlxmlhttprequest/data/text.xml create mode 100644 tests/auto/qml/qqmlxmlhttprequest/data/utf16.html create mode 100644 tests/auto/qml/qqmlxmlhttprequest/data/utf16.qml create mode 100644 tests/auto/qml/qqmlxmlhttprequest/data/utf16.xml create mode 100644 tests/auto/qml/qqmlxmlhttprequest/qqmlxmlhttprequest.pro create mode 100644 tests/auto/qml/qqmlxmlhttprequest/tst_qqmlxmlhttprequest.cpp create mode 100644 tests/auto/qml/qquickbinding/data/deletedObject.qml create mode 100644 tests/auto/qml/qquickbinding/data/restoreBinding.qml create mode 100644 tests/auto/qml/qquickbinding/data/restoreBindingWithLoop.qml create mode 100644 tests/auto/qml/qquickbinding/data/test-binding.qml create mode 100644 tests/auto/qml/qquickbinding/data/test-binding2.qml create mode 100644 tests/auto/qml/qquickbinding/qquickbinding.pro create mode 100644 tests/auto/qml/qquickbinding/tst_qquickbinding.cpp create mode 100644 tests/auto/qml/qquickchangeset/qquickchangeset.pro create mode 100644 tests/auto/qml/qquickchangeset/tst_qquickchangeset.cpp create mode 100644 tests/auto/qml/qquickconnection/data/connection-targetchange.qml create mode 100644 tests/auto/qml/qquickconnection/data/connection-unknownsignals-ignored.qml create mode 100644 tests/auto/qml/qquickconnection/data/connection-unknownsignals-notarget.qml create mode 100644 tests/auto/qml/qquickconnection/data/connection-unknownsignals-parent.qml create mode 100644 tests/auto/qml/qquickconnection/data/connection-unknownsignals.qml create mode 100644 tests/auto/qml/qquickconnection/data/error-object.qml create mode 100644 tests/auto/qml/qquickconnection/data/error-property.qml create mode 100644 tests/auto/qml/qquickconnection/data/error-property2.qml create mode 100644 tests/auto/qml/qquickconnection/data/error-syntax.qml create mode 100644 tests/auto/qml/qquickconnection/data/moduleapi-target.qml create mode 100644 tests/auto/qml/qquickconnection/data/test-connection.qml create mode 100644 tests/auto/qml/qquickconnection/data/test-connection2.qml create mode 100644 tests/auto/qml/qquickconnection/data/test-connection3.qml create mode 100644 tests/auto/qml/qquickconnection/data/trimming.qml create mode 100644 tests/auto/qml/qquickconnection/qquickconnection.pro create mode 100644 tests/auto/qml/qquickconnection/tst_qquickconnection.cpp create mode 100644 tests/auto/qml/qquickfolderlistmodel/data/basic.qml create mode 100644 tests/auto/qml/qquickfolderlistmodel/data/dummy.qml create mode 100644 tests/auto/qml/qquickfolderlistmodel/data/resetFiltering.qml create mode 100644 tests/auto/qml/qquickfolderlistmodel/data/resetfiltering/innerdir/test2.txt create mode 100644 tests/auto/qml/qquickfolderlistmodel/data/resetfiltering/test.txt create mode 100644 tests/auto/qml/qquickfolderlistmodel/qquickfolderlistmodel.pro create mode 100644 tests/auto/qml/qquickfolderlistmodel/tst_qquickfolderlistmodel.cpp create mode 100644 tests/auto/qml/qquicklistcompositor/qquicklistcompositor.pro create mode 100644 tests/auto/qml/qquicklistcompositor/tst_qquicklistcompositor.cpp create mode 100644 tests/auto/qml/qquicklistmodel/data/enumerate.qml create mode 100644 tests/auto/qml/qquicklistmodel/data/model.qml create mode 100644 tests/auto/qml/qquicklistmodel/data/multipleroles.qml create mode 100644 tests/auto/qml/qquicklistmodel/data/script.js create mode 100644 tests/auto/qml/qquicklistmodel/data/setmodelcachelist.qml create mode 100644 tests/auto/qml/qquicklistmodel/data/signalhandlers.qml create mode 100644 tests/auto/qml/qquicklistmodel/data/workerremoveelement.js create mode 100644 tests/auto/qml/qquicklistmodel/data/workerremoveelement.qml create mode 100644 tests/auto/qml/qquicklistmodel/data/workerremovelist.js create mode 100644 tests/auto/qml/qquicklistmodel/data/workerremovelist.qml create mode 100644 tests/auto/qml/qquicklistmodel/data/workersync.js create mode 100644 tests/auto/qml/qquicklistmodel/data/workersync.qml create mode 100644 tests/auto/qml/qquicklistmodel/qquicklistmodel.pro create mode 100644 tests/auto/qml/qquicklistmodel/tst_qquicklistmodel.cpp create mode 100644 tests/auto/qml/qquickworkerscript/data/BaseWorker.qml create mode 100644 tests/auto/qml/qquickworkerscript/data/Global.js create mode 100644 tests/auto/qml/qquickworkerscript/data/externalObjectWorker.qml create mode 100644 tests/auto/qml/qquickworkerscript/data/script.js create mode 100644 tests/auto/qml/qquickworkerscript/data/script_error_onCall.js create mode 100644 tests/auto/qml/qquickworkerscript/data/script_error_onLoad.js create mode 100644 tests/auto/qml/qquickworkerscript/data/script_fixed_return.js create mode 100644 tests/auto/qml/qquickworkerscript/data/script_include.js create mode 100644 tests/auto/qml/qquickworkerscript/data/script_pragma.js create mode 100644 tests/auto/qml/qquickworkerscript/data/stressDispose.js create mode 100644 tests/auto/qml/qquickworkerscript/data/stressDispose.qml create mode 100644 tests/auto/qml/qquickworkerscript/data/worker.qml create mode 100644 tests/auto/qml/qquickworkerscript/data/worker_error_onCall.qml create mode 100644 tests/auto/qml/qquickworkerscript/data/worker_error_onLoad.qml create mode 100644 tests/auto/qml/qquickworkerscript/data/worker_include.qml create mode 100644 tests/auto/qml/qquickworkerscript/data/worker_pragma.qml create mode 100644 tests/auto/qml/qquickworkerscript/qquickworkerscript.pro create mode 100644 tests/auto/qml/qquickworkerscript/tst_qquickworkerscript.cpp create mode 100644 tests/auto/qml/runall.sh create mode 100644 tests/auto/qml/v4/data/conditionalExpr.qml create mode 100644 tests/auto/qml/v4/data/doubleBoolJump.qml create mode 100644 tests/auto/qml/v4/data/fetchException.qml create mode 100644 tests/auto/qml/v4/data/logicalOr.2.qml create mode 100644 tests/auto/qml/v4/data/logicalOr.qml create mode 100644 tests/auto/qml/v4/data/nestedLogicalOr.qml create mode 100644 tests/auto/qml/v4/data/nestedObjectAccess.qml create mode 100644 tests/auto/qml/v4/data/nullQObject.qml create mode 100644 tests/auto/qml/v4/data/qrealToIntRounding.qml create mode 100644 tests/auto/qml/v4/data/qtbug_21883.qml create mode 100644 tests/auto/qml/v4/data/qtbug_22816.qml create mode 100644 tests/auto/qml/v4/data/stringComparison.qml create mode 100644 tests/auto/qml/v4/data/subscriptionsInConditionalExpressions.qml create mode 100644 tests/auto/qml/v4/data/unaryMinus.qml create mode 100644 tests/auto/qml/v4/data/unaryPlus.qml create mode 100644 tests/auto/qml/v4/data/unnecessaryReeval.qml create mode 100644 tests/auto/qml/v4/testtypes.cpp create mode 100644 tests/auto/qml/v4/testtypes.h create mode 100644 tests/auto/qml/v4/tst_v4.cpp create mode 100644 tests/auto/qml/v4/v4.pro delete mode 100644 tests/auto/qmltest/qdeclarativebinding/tst_binding.qml delete mode 100644 tests/auto/qmltest/qdeclarativebinding/tst_binding2.qml create mode 100644 tests/auto/qmltest/qqmlbinding/tst_binding.qml create mode 100644 tests/auto/qmltest/qqmlbinding/tst_binding2.qml delete mode 100644 tests/auto/qtquick2/examples/data/dummytest.qml delete mode 100644 tests/auto/qtquick2/examples/data/webbrowser/webbrowser.qml delete mode 100644 tests/auto/qtquick2/examples/examples.pro delete mode 100644 tests/auto/qtquick2/examples/tst_examples.cpp delete mode 100644 tests/auto/qtquick2/geometry/geometry.pro delete mode 100644 tests/auto/qtquick2/geometry/tst_geometry.cpp delete mode 100644 tests/auto/qtquick2/nodes/nodes.pro delete mode 100644 tests/auto/qtquick2/nodes/tst_nodestest.cpp delete mode 100644 tests/auto/qtquick2/qdeclarativeanimationcontroller/data/tst_numberanimation.qml delete mode 100644 tests/auto/qtquick2/qdeclarativeanimationcontroller/qdeclarativeanimationcontroller.pro delete mode 100644 tests/auto/qtquick2/qdeclarativeanimationcontroller/tst_qdeclarativeanimationcontroller.cpp delete mode 100644 tests/auto/qtquick2/qdeclarativeanimations/data/Double.qml delete mode 100644 tests/auto/qtquick2/qdeclarativeanimations/data/attached.qml delete mode 100644 tests/auto/qtquick2/qdeclarativeanimations/data/badproperty1.qml delete mode 100644 tests/auto/qtquick2/qdeclarativeanimations/data/badproperty2.qml delete mode 100644 tests/auto/qtquick2/qdeclarativeanimations/data/badtype1.qml delete mode 100644 tests/auto/qtquick2/qdeclarativeanimations/data/badtype2.qml delete mode 100644 tests/auto/qtquick2/qdeclarativeanimations/data/badtype3.qml delete mode 100644 tests/auto/qtquick2/qdeclarativeanimations/data/badtype4.qml delete mode 100644 tests/auto/qtquick2/qdeclarativeanimations/data/disabledTransition.qml delete mode 100644 tests/auto/qtquick2/qdeclarativeanimations/data/dontAutoStart.qml delete mode 100644 tests/auto/qtquick2/qdeclarativeanimations/data/dontStart.qml delete mode 100644 tests/auto/qtquick2/qdeclarativeanimations/data/dontStart2.qml delete mode 100644 tests/auto/qtquick2/qdeclarativeanimations/data/dotproperty.qml delete mode 100644 tests/auto/qtquick2/qdeclarativeanimations/data/doubleRegistrationBug.qml delete mode 100644 tests/auto/qtquick2/qdeclarativeanimations/data/looping.qml delete mode 100644 tests/auto/qtquick2/qdeclarativeanimations/data/mixedtype1.qml delete mode 100644 tests/auto/qtquick2/qdeclarativeanimations/data/mixedtype2.qml delete mode 100644 tests/auto/qtquick2/qdeclarativeanimations/data/nonTransitionBug.qml delete mode 100644 tests/auto/qtquick2/qdeclarativeanimations/data/pathAnimation.qml delete mode 100644 tests/auto/qtquick2/qdeclarativeanimations/data/pathAnimation2.qml delete mode 100644 tests/auto/qtquick2/qdeclarativeanimations/data/pathAnimationNoStart.qml delete mode 100644 tests/auto/qtquick2/qdeclarativeanimations/data/pathInterpolator.qml delete mode 100644 tests/auto/qtquick2/qdeclarativeanimations/data/pathInterpolatorBack.qml delete mode 100644 tests/auto/qtquick2/qdeclarativeanimations/data/pathInterpolatorBack2.qml delete mode 100644 tests/auto/qtquick2/qdeclarativeanimations/data/pathTransition.qml delete mode 100644 tests/auto/qtquick2/qdeclarativeanimations/data/pauseBindingBug.qml delete mode 100644 tests/auto/qtquick2/qdeclarativeanimations/data/pauseBug.qml delete mode 100644 tests/auto/qtquick2/qdeclarativeanimations/data/properties.qml delete mode 100644 tests/auto/qtquick2/qdeclarativeanimations/data/properties2.qml delete mode 100644 tests/auto/qtquick2/qdeclarativeanimations/data/properties3.qml delete mode 100644 tests/auto/qtquick2/qdeclarativeanimations/data/properties4.qml delete mode 100644 tests/auto/qtquick2/qdeclarativeanimations/data/properties5.qml delete mode 100644 tests/auto/qtquick2/qdeclarativeanimations/data/propertiesTransition.qml delete mode 100644 tests/auto/qtquick2/qdeclarativeanimations/data/propertiesTransition2.qml delete mode 100644 tests/auto/qtquick2/qdeclarativeanimations/data/propertiesTransition3.qml delete mode 100644 tests/auto/qtquick2/qdeclarativeanimations/data/propertiesTransition4.qml delete mode 100644 tests/auto/qtquick2/qdeclarativeanimations/data/propertiesTransition5.qml delete mode 100644 tests/auto/qtquick2/qdeclarativeanimations/data/propertiesTransition6.qml delete mode 100644 tests/auto/qtquick2/qdeclarativeanimations/data/propertiesTransition7.qml delete mode 100644 tests/auto/qtquick2/qdeclarativeanimations/data/reanchor.qml delete mode 100644 tests/auto/qtquick2/qdeclarativeanimations/data/registrationBug.qml delete mode 100644 tests/auto/qtquick2/qdeclarativeanimations/data/reparent.qml delete mode 100644 tests/auto/qtquick2/qdeclarativeanimations/data/rotation.qml delete mode 100644 tests/auto/qtquick2/qdeclarativeanimations/data/runningTrueBug.qml delete mode 100644 tests/auto/qtquick2/qdeclarativeanimations/data/transitionAssignmentBug.qml delete mode 100644 tests/auto/qtquick2/qdeclarativeanimations/data/valuesource.qml delete mode 100644 tests/auto/qtquick2/qdeclarativeanimations/data/valuesource2.qml delete mode 100644 tests/auto/qtquick2/qdeclarativeanimations/qdeclarativeanimations.pro delete mode 100644 tests/auto/qtquick2/qdeclarativeanimations/tst_qdeclarativeanimations.cpp delete mode 100644 tests/auto/qtquick2/qdeclarativeapplication/qdeclarativeapplication.pro delete mode 100644 tests/auto/qtquick2/qdeclarativeapplication/tst_qdeclarativeapplication.cpp delete mode 100644 tests/auto/qtquick2/qdeclarativebehaviors/data/binding.qml delete mode 100644 tests/auto/qtquick2/qdeclarativebehaviors/data/color.qml delete mode 100644 tests/auto/qtquick2/qdeclarativebehaviors/data/cpptrigger.qml delete mode 100644 tests/auto/qtquick2/qdeclarativebehaviors/data/delayedRegistration.qml delete mode 100644 tests/auto/qtquick2/qdeclarativebehaviors/data/disabled.qml delete mode 100644 tests/auto/qtquick2/qdeclarativebehaviors/data/dontStart.qml delete mode 100644 tests/auto/qtquick2/qdeclarativebehaviors/data/empty.qml delete mode 100644 tests/auto/qtquick2/qdeclarativebehaviors/data/explicit.qml delete mode 100644 tests/auto/qtquick2/qdeclarativebehaviors/data/groupProperty.qml delete mode 100644 tests/auto/qtquick2/qdeclarativebehaviors/data/groupProperty2.qml delete mode 100644 tests/auto/qtquick2/qdeclarativebehaviors/data/groupedPropertyCrash.qml delete mode 100644 tests/auto/qtquick2/qdeclarativebehaviors/data/loop.qml delete mode 100644 tests/auto/qtquick2/qdeclarativebehaviors/data/nonSelecting2.qml delete mode 100644 tests/auto/qtquick2/qdeclarativebehaviors/data/parent.qml delete mode 100644 tests/auto/qtquick2/qdeclarativebehaviors/data/qtbug12295.qml delete mode 100644 tests/auto/qtquick2/qdeclarativebehaviors/data/reassignedAnimation.qml delete mode 100644 tests/auto/qtquick2/qdeclarativebehaviors/data/runningTrue.qml delete mode 100644 tests/auto/qtquick2/qdeclarativebehaviors/data/scripttrigger.qml delete mode 100644 tests/auto/qtquick2/qdeclarativebehaviors/data/simple.qml delete mode 100644 tests/auto/qtquick2/qdeclarativebehaviors/data/startOnCompleted.qml delete mode 100644 tests/auto/qtquick2/qdeclarativebehaviors/data/startup.qml delete mode 100644 tests/auto/qtquick2/qdeclarativebehaviors/data/startup2.qml delete mode 100644 tests/auto/qtquick2/qdeclarativebehaviors/data/valueType.qml delete mode 100644 tests/auto/qtquick2/qdeclarativebehaviors/qdeclarativebehaviors.pro delete mode 100644 tests/auto/qtquick2/qdeclarativebehaviors/tst_qdeclarativebehaviors.cpp delete mode 100644 tests/auto/qtquick2/qdeclarativefontloader/data/daniel.ttf delete mode 100644 tests/auto/qtquick2/qdeclarativefontloader/data/dummy.ttf delete mode 100644 tests/auto/qtquick2/qdeclarativefontloader/data/qtbug-20268.qml delete mode 100644 tests/auto/qtquick2/qdeclarativefontloader/data/tarzeau_ocr_a.ttf delete mode 100644 tests/auto/qtquick2/qdeclarativefontloader/qdeclarativefontloader.pro delete mode 100644 tests/auto/qtquick2/qdeclarativefontloader/tst_qdeclarativefontloader.cpp delete mode 100644 tests/auto/qtquick2/qdeclarativepath/data/arc.qml delete mode 100644 tests/auto/qtquick2/qdeclarativepath/data/closedcurve.qml delete mode 100644 tests/auto/qtquick2/qdeclarativepath/data/curve.qml delete mode 100644 tests/auto/qtquick2/qdeclarativepath/data/svg.qml delete mode 100644 tests/auto/qtquick2/qdeclarativepath/qdeclarativepath.pro delete mode 100644 tests/auto/qtquick2/qdeclarativepath/tst_qdeclarativepath.cpp delete mode 100644 tests/auto/qtquick2/qdeclarativepixmapcache/data/exists.png delete mode 100644 tests/auto/qtquick2/qdeclarativepixmapcache/data/exists1.png delete mode 100644 tests/auto/qtquick2/qdeclarativepixmapcache/data/exists2.png delete mode 100644 tests/auto/qtquick2/qdeclarativepixmapcache/data/http/exists.png delete mode 100644 tests/auto/qtquick2/qdeclarativepixmapcache/data/http/exists1.png delete mode 100644 tests/auto/qtquick2/qdeclarativepixmapcache/data/http/exists2.png delete mode 100644 tests/auto/qtquick2/qdeclarativepixmapcache/data/http/exists3.png delete mode 100644 tests/auto/qtquick2/qdeclarativepixmapcache/data/http/exists4.png delete mode 100644 tests/auto/qtquick2/qdeclarativepixmapcache/data/http/exists5.png delete mode 100644 tests/auto/qtquick2/qdeclarativepixmapcache/data/http/exists6.png delete mode 100644 tests/auto/qtquick2/qdeclarativepixmapcache/data/http/exists7.png delete mode 100644 tests/auto/qtquick2/qdeclarativepixmapcache/data/http/exists8.png delete mode 100644 tests/auto/qtquick2/qdeclarativepixmapcache/data/massive.png delete mode 100644 tests/auto/qtquick2/qdeclarativepixmapcache/qdeclarativepixmapcache.pro delete mode 100644 tests/auto/qtquick2/qdeclarativepixmapcache/tst_qdeclarativepixmapcache.cpp delete mode 100644 tests/auto/qtquick2/qdeclarativesmoothedanimation/data/deleteOnUpdate.qml delete mode 100644 tests/auto/qtquick2/qdeclarativesmoothedanimation/data/simpleanimation.qml delete mode 100644 tests/auto/qtquick2/qdeclarativesmoothedanimation/data/smoothedanimation1.qml delete mode 100644 tests/auto/qtquick2/qdeclarativesmoothedanimation/data/smoothedanimation2.qml delete mode 100644 tests/auto/qtquick2/qdeclarativesmoothedanimation/data/smoothedanimation3.qml delete mode 100644 tests/auto/qtquick2/qdeclarativesmoothedanimation/data/smoothedanimationBehavior.qml delete mode 100644 tests/auto/qtquick2/qdeclarativesmoothedanimation/data/smoothedanimationValueSource.qml delete mode 100644 tests/auto/qtquick2/qdeclarativesmoothedanimation/qdeclarativesmoothedanimation.pro delete mode 100644 tests/auto/qtquick2/qdeclarativesmoothedanimation/tst_qdeclarativesmoothedanimation.cpp delete mode 100644 tests/auto/qtquick2/qdeclarativespringanimation/data/springanimation1.qml delete mode 100644 tests/auto/qtquick2/qdeclarativespringanimation/data/springanimation2.qml delete mode 100644 tests/auto/qtquick2/qdeclarativespringanimation/data/springanimation3.qml delete mode 100644 tests/auto/qtquick2/qdeclarativespringanimation/qdeclarativespringanimation.pro delete mode 100644 tests/auto/qtquick2/qdeclarativespringanimation/tst_qdeclarativespringanimation.cpp delete mode 100644 tests/auto/qtquick2/qdeclarativestates/data/ExtendedRectangle.qml delete mode 100644 tests/auto/qtquick2/qdeclarativestates/data/Implementation/MyType.qml delete mode 100644 tests/auto/qtquick2/qdeclarativestates/data/Implementation/images/qt-logo.png delete mode 100644 tests/auto/qtquick2/qdeclarativestates/data/QTBUG-14830.qml delete mode 100644 tests/auto/qtquick2/qdeclarativestates/data/anchorChanges1.qml delete mode 100644 tests/auto/qtquick2/qdeclarativestates/data/anchorChanges2.qml delete mode 100644 tests/auto/qtquick2/qdeclarativestates/data/anchorChanges3.qml delete mode 100644 tests/auto/qtquick2/qdeclarativestates/data/anchorChanges4.qml delete mode 100644 tests/auto/qtquick2/qdeclarativestates/data/anchorChanges5.qml delete mode 100644 tests/auto/qtquick2/qdeclarativestates/data/anchorChangesCrash.qml delete mode 100644 tests/auto/qtquick2/qdeclarativestates/data/anchorRewindBug.qml delete mode 100644 tests/auto/qtquick2/qdeclarativestates/data/anchorRewindBug2.qml delete mode 100644 tests/auto/qtquick2/qdeclarativestates/data/attachedPropertyChanges.qml delete mode 100644 tests/auto/qtquick2/qdeclarativestates/data/autoStateAtStartupRestoreBug.qml delete mode 100644 tests/auto/qtquick2/qdeclarativestates/data/avoidFastForward.qml delete mode 100644 tests/auto/qtquick2/qdeclarativestates/data/basicBinding.qml delete mode 100644 tests/auto/qtquick2/qdeclarativestates/data/basicBinding2.qml delete mode 100644 tests/auto/qtquick2/qdeclarativestates/data/basicBinding3.qml delete mode 100644 tests/auto/qtquick2/qdeclarativestates/data/basicBinding4.qml delete mode 100644 tests/auto/qtquick2/qdeclarativestates/data/basicChanges.qml delete mode 100644 tests/auto/qtquick2/qdeclarativestates/data/basicChanges2.qml delete mode 100644 tests/auto/qtquick2/qdeclarativestates/data/basicChanges3.qml delete mode 100644 tests/auto/qtquick2/qdeclarativestates/data/basicChanges4.qml delete mode 100644 tests/auto/qtquick2/qdeclarativestates/data/basicExtension.qml delete mode 100644 tests/auto/qtquick2/qdeclarativestates/data/deleting.qml delete mode 100644 tests/auto/qtquick2/qdeclarativestates/data/deletingState.qml delete mode 100644 tests/auto/qtquick2/qdeclarativestates/data/editProperties.qml delete mode 100644 tests/auto/qtquick2/qdeclarativestates/data/explicit.qml delete mode 100644 tests/auto/qtquick2/qdeclarativestates/data/extendsBug.qml delete mode 100644 tests/auto/qtquick2/qdeclarativestates/data/fakeExtension.qml delete mode 100644 tests/auto/qtquick2/qdeclarativestates/data/illegalObj.qml delete mode 100644 tests/auto/qtquick2/qdeclarativestates/data/illegalTempState.qml delete mode 100644 tests/auto/qtquick2/qdeclarativestates/data/image.png delete mode 100644 tests/auto/qtquick2/qdeclarativestates/data/legalTempState.qml delete mode 100644 tests/auto/qtquick2/qdeclarativestates/data/nonExistantProp.qml delete mode 100644 tests/auto/qtquick2/qdeclarativestates/data/parentChange1.qml delete mode 100644 tests/auto/qtquick2/qdeclarativestates/data/parentChange2.qml delete mode 100644 tests/auto/qtquick2/qdeclarativestates/data/parentChange3.qml delete mode 100644 tests/auto/qtquick2/qdeclarativestates/data/parentChange4.qml delete mode 100644 tests/auto/qtquick2/qdeclarativestates/data/parentChange5.qml delete mode 100644 tests/auto/qtquick2/qdeclarativestates/data/parentChange6.qml delete mode 100644 tests/auto/qtquick2/qdeclarativestates/data/propertyErrors.qml delete mode 100644 tests/auto/qtquick2/qdeclarativestates/data/reset.qml delete mode 100644 tests/auto/qtquick2/qdeclarativestates/data/restoreEntryValues.qml delete mode 100644 tests/auto/qtquick2/qdeclarativestates/data/returnToBase.qml delete mode 100644 tests/auto/qtquick2/qdeclarativestates/data/revertListBug.qml delete mode 100644 tests/auto/qtquick2/qdeclarativestates/data/script.qml delete mode 100644 tests/auto/qtquick2/qdeclarativestates/data/signalOverride.qml delete mode 100644 tests/auto/qtquick2/qdeclarativestates/data/signalOverride2.qml delete mode 100644 tests/auto/qtquick2/qdeclarativestates/data/signalOverrideCrash.qml delete mode 100644 tests/auto/qtquick2/qdeclarativestates/data/signalOverrideCrash2.qml delete mode 100644 tests/auto/qtquick2/qdeclarativestates/data/signalOverrideCrash3.qml delete mode 100644 tests/auto/qtquick2/qdeclarativestates/data/unnamedWhen.qml delete mode 100644 tests/auto/qtquick2/qdeclarativestates/data/urlResolution.qml delete mode 100644 tests/auto/qtquick2/qdeclarativestates/data/whenOrdering.qml delete mode 100644 tests/auto/qtquick2/qdeclarativestates/qdeclarativestates.pro delete mode 100644 tests/auto/qtquick2/qdeclarativestates/tst_qdeclarativestates.cpp delete mode 100644 tests/auto/qtquick2/qdeclarativestyledtext/qdeclarativestyledtext.pro delete mode 100644 tests/auto/qtquick2/qdeclarativestyledtext/tst_qdeclarativestyledtext.cpp delete mode 100644 tests/auto/qtquick2/qdeclarativesystempalette/qdeclarativesystempalette.pro delete mode 100644 tests/auto/qtquick2/qdeclarativesystempalette/tst_qdeclarativesystempalette.cpp delete mode 100644 tests/auto/qtquick2/qdeclarativetimer/qdeclarativetimer.pro delete mode 100644 tests/auto/qtquick2/qdeclarativetimer/tst_qdeclarativetimer.cpp delete mode 100644 tests/auto/qtquick2/qdeclarativexmllistmodel/data/empty.xml delete mode 100644 tests/auto/qtquick2/qdeclarativexmllistmodel/data/get.qml delete mode 100644 tests/auto/qtquick2/qdeclarativexmllistmodel/data/model.qml delete mode 100644 tests/auto/qtquick2/qdeclarativexmllistmodel/data/model.xml delete mode 100644 tests/auto/qtquick2/qdeclarativexmllistmodel/data/model2.xml delete mode 100644 tests/auto/qtquick2/qdeclarativexmllistmodel/data/propertychanges.qml delete mode 100644 tests/auto/qtquick2/qdeclarativexmllistmodel/data/recipes.qml delete mode 100644 tests/auto/qtquick2/qdeclarativexmllistmodel/data/recipes.xml delete mode 100644 tests/auto/qtquick2/qdeclarativexmllistmodel/data/roleCrash.qml delete mode 100644 tests/auto/qtquick2/qdeclarativexmllistmodel/data/roleErrors.qml delete mode 100644 tests/auto/qtquick2/qdeclarativexmllistmodel/data/roleKeys.qml delete mode 100644 tests/auto/qtquick2/qdeclarativexmllistmodel/data/testtypes.qml delete mode 100644 tests/auto/qtquick2/qdeclarativexmllistmodel/data/unique.qml delete mode 100644 tests/auto/qtquick2/qdeclarativexmllistmodel/qdeclarativexmllistmodel.pro delete mode 100644 tests/auto/qtquick2/qdeclarativexmllistmodel/tst_qdeclarativexmllistmodel.cpp delete mode 100644 tests/auto/qtquick2/qquickaccessible/data/checkbuttons.qml delete mode 100644 tests/auto/qtquick2/qquickaccessible/data/hittest.qml delete mode 100644 tests/auto/qtquick2/qquickaccessible/data/pushbutton.qml delete mode 100644 tests/auto/qtquick2/qquickaccessible/data/statictext.qml delete mode 100644 tests/auto/qtquick2/qquickaccessible/data/widgets/TextRect.qml delete mode 100644 tests/auto/qtquick2/qquickaccessible/qquickaccessible.pro delete mode 100644 tests/auto/qtquick2/qquickaccessible/tst_qquickaccessible.cpp delete mode 100644 tests/auto/qtquick2/qquickanchors/data/anchors.qml delete mode 100644 tests/auto/qtquick2/qquickanchors/data/centerin.qml delete mode 100644 tests/auto/qtquick2/qquickanchors/data/centerinRotation.qml delete mode 100644 tests/auto/qtquick2/qquickanchors/data/crash1.qml delete mode 100644 tests/auto/qtquick2/qquickanchors/data/fill.qml delete mode 100644 tests/auto/qtquick2/qquickanchors/data/hvCenter.qml delete mode 100644 tests/auto/qtquick2/qquickanchors/data/loop1.qml delete mode 100644 tests/auto/qtquick2/qquickanchors/data/loop2.qml delete mode 100644 tests/auto/qtquick2/qquickanchors/data/margins.qml delete mode 100644 tests/auto/qtquick2/qquickanchors/qquickanchors.pro delete mode 100644 tests/auto/qtquick2/qquickanchors/tst_qquickanchors.cpp delete mode 100644 tests/auto/qtquick2/qquickanimatedimage/data/colors.gif delete mode 100644 tests/auto/qtquick2/qquickanimatedimage/data/colors.qml delete mode 100644 tests/auto/qtquick2/qquickanimatedimage/data/hearts.gif delete mode 100644 tests/auto/qtquick2/qquickanimatedimage/data/hearts.qml delete mode 100644 tests/auto/qtquick2/qquickanimatedimage/data/qmldir delete mode 100644 tests/auto/qtquick2/qquickanimatedimage/data/qtbug-16520.qml delete mode 100644 tests/auto/qtquick2/qquickanimatedimage/data/stickman.gif delete mode 100644 tests/auto/qtquick2/qquickanimatedimage/data/stickman.qml delete mode 100644 tests/auto/qtquick2/qquickanimatedimage/data/stickmanerror1.qml delete mode 100644 tests/auto/qtquick2/qquickanimatedimage/data/stickmanpause.qml delete mode 100644 tests/auto/qtquick2/qquickanimatedimage/data/stickmanscaled.qml delete mode 100644 tests/auto/qtquick2/qquickanimatedimage/data/stickmanstopped.qml delete mode 100644 tests/auto/qtquick2/qquickanimatedimage/qquickanimatedimage.pro delete mode 100644 tests/auto/qtquick2/qquickanimatedimage/tst_qquickanimatedimage.cpp delete mode 100644 tests/auto/qtquick2/qquickborderimage/data/colors-mirror.png delete mode 100644 tests/auto/qtquick2/qquickborderimage/data/colors-round-quotes.sci delete mode 100644 tests/auto/qtquick2/qquickborderimage/data/colors-round-remote.sci delete mode 100644 tests/auto/qtquick2/qquickborderimage/data/colors-round.sci delete mode 100644 tests/auto/qtquick2/qquickborderimage/data/colors.png delete mode 100644 tests/auto/qtquick2/qquickborderimage/data/heart200.png delete mode 100644 tests/auto/qtquick2/qquickborderimage/data/invalid.sci delete mode 100644 tests/auto/qtquick2/qquickborderimage/data/mirror.qml delete mode 100644 tests/auto/qtquick2/qquickborderimage/qquickborderimage.pro delete mode 100644 tests/auto/qtquick2/qquickborderimage/tst_qquickborderimage.cpp delete mode 100644 tests/auto/qtquick2/qquickcanvas/data/AnimationsWhileHidden.qml delete mode 100644 tests/auto/qtquick2/qquickcanvas/data/Headless.qml delete mode 100644 tests/auto/qtquick2/qquickcanvas/data/colors.png delete mode 100644 tests/auto/qtquick2/qquickcanvas/data/focus.qml delete mode 100644 tests/auto/qtquick2/qquickcanvas/data/window.qml delete mode 100644 tests/auto/qtquick2/qquickcanvas/qquickcanvas.pro delete mode 100644 tests/auto/qtquick2/qquickcanvas/tst_qquickcanvas.cpp delete mode 100644 tests/auto/qtquick2/qquickcanvasitem/data/anim-gr.gif delete mode 100644 tests/auto/qtquick2/qquickcanvasitem/data/anim-gr.png delete mode 100644 tests/auto/qtquick2/qquickcanvasitem/data/anim-poster-gr.png delete mode 100644 tests/auto/qtquick2/qquickcanvasitem/data/background.png delete mode 100644 tests/auto/qtquick2/qquickcanvasitem/data/broken.png delete mode 100644 tests/auto/qtquick2/qquickcanvasitem/data/ggrr-256x256.png delete mode 100644 tests/auto/qtquick2/qquickcanvasitem/data/green-16x16.png delete mode 100644 tests/auto/qtquick2/qquickcanvasitem/data/green-1x1.png delete mode 100644 tests/auto/qtquick2/qquickcanvasitem/data/green-256x256.png delete mode 100644 tests/auto/qtquick2/qquickcanvasitem/data/green-2x2.png delete mode 100644 tests/auto/qtquick2/qquickcanvasitem/data/green.png delete mode 100644 tests/auto/qtquick2/qquickcanvasitem/data/grgr-256x256.png delete mode 100644 tests/auto/qtquick2/qquickcanvasitem/data/red-16x16.png delete mode 100644 tests/auto/qtquick2/qquickcanvasitem/data/red.png delete mode 100644 tests/auto/qtquick2/qquickcanvasitem/data/redtransparent.png delete mode 100644 tests/auto/qtquick2/qquickcanvasitem/data/rgrg-256x256.png delete mode 100644 tests/auto/qtquick2/qquickcanvasitem/data/rrgg-256x256.png delete mode 100644 tests/auto/qtquick2/qquickcanvasitem/data/testhelper.js delete mode 100644 tests/auto/qtquick2/qquickcanvasitem/data/transparent.png delete mode 100644 tests/auto/qtquick2/qquickcanvasitem/data/transparent50.png delete mode 100644 tests/auto/qtquick2/qquickcanvasitem/data/tst_arc.qml delete mode 100644 tests/auto/qtquick2/qquickcanvasitem/data/tst_arcto.qml delete mode 100644 tests/auto/qtquick2/qquickcanvasitem/data/tst_canvas.qml delete mode 100644 tests/auto/qtquick2/qquickcanvasitem/data/tst_composite.qml delete mode 100644 tests/auto/qtquick2/qquickcanvasitem/data/tst_context.qml delete mode 100644 tests/auto/qtquick2/qquickcanvasitem/data/tst_drawimage.qml delete mode 100644 tests/auto/qtquick2/qquickcanvasitem/data/tst_fillStyle.qml delete mode 100644 tests/auto/qtquick2/qquickcanvasitem/data/tst_fillrect.qml delete mode 100644 tests/auto/qtquick2/qquickcanvasitem/data/tst_gradient.qml delete mode 100644 tests/auto/qtquick2/qquickcanvasitem/data/tst_line.qml delete mode 100644 tests/auto/qtquick2/qquickcanvasitem/data/tst_path.qml delete mode 100644 tests/auto/qtquick2/qquickcanvasitem/data/tst_pattern.qml delete mode 100644 tests/auto/qtquick2/qquickcanvasitem/data/tst_pixel.qml delete mode 100644 tests/auto/qtquick2/qquickcanvasitem/data/tst_shadow.qml delete mode 100644 tests/auto/qtquick2/qquickcanvasitem/data/tst_state.qml delete mode 100644 tests/auto/qtquick2/qquickcanvasitem/data/tst_strokeStyle.qml delete mode 100644 tests/auto/qtquick2/qquickcanvasitem/data/tst_text.qml delete mode 100644 tests/auto/qtquick2/qquickcanvasitem/data/tst_transform.qml delete mode 100644 tests/auto/qtquick2/qquickcanvasitem/data/yellow.png delete mode 100644 tests/auto/qtquick2/qquickcanvasitem/data/yellow75.png delete mode 100644 tests/auto/qtquick2/qquickcanvasitem/qquickcanvasitem.pro delete mode 100644 tests/auto/qtquick2/qquickcanvasitem/tst_qquickcanvasitem.cpp delete mode 100644 tests/auto/qtquick2/qquickdrag/qquickdrag.pro delete mode 100644 tests/auto/qtquick2/qquickdrag/tst_qquickdrag.cpp delete mode 100644 tests/auto/qtquick2/qquickdroparea/qquickdroparea.pro delete mode 100644 tests/auto/qtquick2/qquickdroparea/tst_qquickdroparea.cpp delete mode 100644 tests/auto/qtquick2/qquickflickable/data/disabled.qml delete mode 100644 tests/auto/qtquick2/qquickflickable/data/flickable01.qml delete mode 100644 tests/auto/qtquick2/qquickflickable/data/flickable02.qml delete mode 100644 tests/auto/qtquick2/qquickflickable/data/flickable03.qml delete mode 100644 tests/auto/qtquick2/qquickflickable/data/flickable04.qml delete mode 100644 tests/auto/qtquick2/qquickflickable/data/flickableqgraphicswidget.qml delete mode 100644 tests/auto/qtquick2/qquickflickable/data/margins.qml delete mode 100644 tests/auto/qtquick2/qquickflickable/data/nestedPressDelay.qml delete mode 100644 tests/auto/qtquick2/qquickflickable/data/resize.qml delete mode 100644 tests/auto/qtquick2/qquickflickable/data/wheel.qml delete mode 100644 tests/auto/qtquick2/qquickflickable/qquickflickable.pro delete mode 100644 tests/auto/qtquick2/qquickflickable/tst_qquickflickable.cpp delete mode 100644 tests/auto/qtquick2/qquickflipable/data/crash.qml delete mode 100644 tests/auto/qtquick2/qquickflipable/data/flipable-abort.qml delete mode 100644 tests/auto/qtquick2/qquickflipable/data/test-flipable.qml delete mode 100644 tests/auto/qtquick2/qquickflipable/qquickflipable.pro delete mode 100644 tests/auto/qtquick2/qquickflipable/tst_qquickflipable.cpp delete mode 100644 tests/auto/qtquick2/qquickfocusscope/data/canvasFocus.qml delete mode 100644 tests/auto/qtquick2/qquickfocusscope/data/chain.qml delete mode 100644 tests/auto/qtquick2/qquickfocusscope/data/forceActiveFocus.qml delete mode 100644 tests/auto/qtquick2/qquickfocusscope/data/forcefocus.qml delete mode 100644 tests/auto/qtquick2/qquickfocusscope/data/qtBug13380.qml delete mode 100644 tests/auto/qtquick2/qquickfocusscope/data/signalEmission.qml delete mode 100644 tests/auto/qtquick2/qquickfocusscope/data/test.qml delete mode 100644 tests/auto/qtquick2/qquickfocusscope/data/test2.qml delete mode 100644 tests/auto/qtquick2/qquickfocusscope/data/test3.qml delete mode 100644 tests/auto/qtquick2/qquickfocusscope/data/test4.qml delete mode 100644 tests/auto/qtquick2/qquickfocusscope/data/test5.qml delete mode 100644 tests/auto/qtquick2/qquickfocusscope/qquickfocusscope.pro delete mode 100644 tests/auto/qtquick2/qquickfocusscope/tst_qquickfocusscope.cpp delete mode 100644 tests/auto/qtquick2/qquickgridview/data/ComponentView.qml delete mode 100644 tests/auto/qtquick2/qquickgridview/data/addTransitions.qml delete mode 100644 tests/auto/qtquick2/qquickgridview/data/asyncloader.qml delete mode 100644 tests/auto/qtquick2/qquickgridview/data/attachedSignals.qml delete mode 100644 tests/auto/qtquick2/qquickgridview/data/creationContext.qml delete mode 100644 tests/auto/qtquick2/qquickgridview/data/displaygrid.qml delete mode 100644 tests/auto/qtquick2/qquickgridview/data/footer.qml delete mode 100644 tests/auto/qtquick2/qquickgridview/data/gridview-enforcerange.qml delete mode 100644 tests/auto/qtquick2/qquickgridview/data/gridview-initCurrent.qml delete mode 100644 tests/auto/qtquick2/qquickgridview/data/gridview-noCurrent.qml delete mode 100644 tests/auto/qtquick2/qquickgridview/data/gridview1.qml delete mode 100644 tests/auto/qtquick2/qquickgridview/data/gridview2.qml delete mode 100644 tests/auto/qtquick2/qquickgridview/data/gridview3.qml delete mode 100644 tests/auto/qtquick2/qquickgridview/data/gridview4.qml delete mode 100644 tests/auto/qtquick2/qquickgridview/data/header.qml delete mode 100644 tests/auto/qtquick2/qquickgridview/data/manual-highlight.qml delete mode 100644 tests/auto/qtquick2/qquickgridview/data/margins.qml delete mode 100644 tests/auto/qtquick2/qquickgridview/data/mirroring.qml delete mode 100644 tests/auto/qtquick2/qquickgridview/data/moveTransitions.qml delete mode 100644 tests/auto/qtquick2/qquickgridview/data/multipleTransitions.qml delete mode 100644 tests/auto/qtquick2/qquickgridview/data/populateTransitions.qml delete mode 100644 tests/auto/qtquick2/qquickgridview/data/propertychangestest.qml delete mode 100644 tests/auto/qtquick2/qquickgridview/data/removeTransitions.qml delete mode 100644 tests/auto/qtquick2/qquickgridview/data/resizeview.qml delete mode 100644 tests/auto/qtquick2/qquickgridview/data/setindex.qml delete mode 100644 tests/auto/qtquick2/qquickgridview/data/snapOneRow.qml delete mode 100644 tests/auto/qtquick2/qquickgridview/data/snapToRow.qml delete mode 100644 tests/auto/qtquick2/qquickgridview/data/unaligned.qml delete mode 100644 tests/auto/qtquick2/qquickgridview/data/unrequestedItems.qml delete mode 100644 tests/auto/qtquick2/qquickgridview/qquickgridview.pro delete mode 100644 tests/auto/qtquick2/qquickgridview/tst_qquickgridview.cpp delete mode 100644 tests/auto/qtquick2/qquickimage/data/aspectratio.qml delete mode 100644 tests/auto/qtquick2/qquickimage/data/big.jpeg delete mode 100644 tests/auto/qtquick2/qquickimage/data/big256.png delete mode 100644 tests/auto/qtquick2/qquickimage/data/colors.png delete mode 100644 tests/auto/qtquick2/qquickimage/data/colors1.png delete mode 100644 tests/auto/qtquick2/qquickimage/data/green.png delete mode 100644 tests/auto/qtquick2/qquickimage/data/heart-win32.png delete mode 100644 tests/auto/qtquick2/qquickimage/data/heart.png delete mode 100644 tests/auto/qtquick2/qquickimage/data/heart.svg delete mode 100644 tests/auto/qtquick2/qquickimage/data/heart200-win32.png delete mode 100644 tests/auto/qtquick2/qquickimage/data/heart200.png delete mode 100644 tests/auto/qtquick2/qquickimage/data/htiling.qml delete mode 100644 tests/auto/qtquick2/qquickimage/data/mirror.qml delete mode 100644 tests/auto/qtquick2/qquickimage/data/nullpixmap.qml delete mode 100644 tests/auto/qtquick2/qquickimage/data/pattern.png delete mode 100644 tests/auto/qtquick2/qquickimage/data/qtbug_16389.qml delete mode 100644 tests/auto/qtquick2/qquickimage/data/qtbug_22125.qml delete mode 100644 tests/auto/qtquick2/qquickimage/data/rect.png delete mode 100644 tests/auto/qtquick2/qquickimage/data/sourceSize.qml delete mode 100644 tests/auto/qtquick2/qquickimage/data/vtiling.qml delete mode 100644 tests/auto/qtquick2/qquickimage/qquickimage.pro delete mode 100644 tests/auto/qtquick2/qquickimage/tst_qquickimage.cpp delete mode 100644 tests/auto/qtquick2/qquickitem/data/order.1.qml delete mode 100644 tests/auto/qtquick2/qquickitem/data/order.2.qml delete mode 100644 tests/auto/qtquick2/qquickitem/data/polishOnCompleted.qml delete mode 100644 tests/auto/qtquick2/qquickitem/qquickitem.pro delete mode 100644 tests/auto/qtquick2/qquickitem/tst_qquickitem.cpp delete mode 100644 tests/auto/qtquick2/qquickitem2/data/childrenProperty.qml delete mode 100644 tests/auto/qtquick2/qquickitem2/data/childrenRect.qml delete mode 100644 tests/auto/qtquick2/qquickitem2/data/childrenRectBug.qml delete mode 100644 tests/auto/qtquick2/qquickitem2/data/childrenRectBug2.qml delete mode 100644 tests/auto/qtquick2/qquickitem2/data/childrenRectBug3.qml delete mode 100644 tests/auto/qtquick2/qquickitem2/data/implicitsize.qml delete mode 100644 tests/auto/qtquick2/qquickitem2/data/keynavigationtest.qml delete mode 100644 tests/auto/qtquick2/qquickitem2/data/keynavigationtest_implicit.qml delete mode 100644 tests/auto/qtquick2/qquickitem2/data/keysim.qml delete mode 100644 tests/auto/qtquick2/qquickitem2/data/keyspriority.qml delete mode 100644 tests/auto/qtquick2/qquickitem2/data/keystest.qml delete mode 100644 tests/auto/qtquick2/qquickitem2/data/layoutmirroring.qml delete mode 100644 tests/auto/qtquick2/qquickitem2/data/mapCoordinates.qml delete mode 100644 tests/auto/qtquick2/qquickitem2/data/parentLoop.qml delete mode 100644 tests/auto/qtquick2/qquickitem2/data/propertychanges.qml delete mode 100644 tests/auto/qtquick2/qquickitem2/data/qtbug_16871.qml delete mode 100644 tests/auto/qtquick2/qquickitem2/data/resourcesProperty.qml delete mode 100644 tests/auto/qtquick2/qquickitem2/data/transformCrash.qml delete mode 100644 tests/auto/qtquick2/qquickitem2/data/visiblechildren.qml delete mode 100644 tests/auto/qtquick2/qquickitem2/qquickitem2.pro delete mode 100644 tests/auto/qtquick2/qquickitem2/tst_qquickitem.cpp delete mode 100644 tests/auto/qtquick2/qquickitemlayer/data/DisableLayer.qml delete mode 100644 tests/auto/qtquick2/qquickitemlayer/data/Effect.qml delete mode 100644 tests/auto/qtquick2/qquickitemlayer/data/Enabled.qml delete mode 100644 tests/auto/qtquick2/qquickitemlayer/data/ItemEffect.qml delete mode 100644 tests/auto/qtquick2/qquickitemlayer/data/Mipmap.qml delete mode 100644 tests/auto/qtquick2/qquickitemlayer/data/RectangleEffect.qml delete mode 100644 tests/auto/qtquick2/qquickitemlayer/data/SamplerNameChange.qml delete mode 100644 tests/auto/qtquick2/qquickitemlayer/data/Smooth.qml delete mode 100644 tests/auto/qtquick2/qquickitemlayer/data/SourceRect.qml delete mode 100644 tests/auto/qtquick2/qquickitemlayer/data/TextureProvider.qml delete mode 100644 tests/auto/qtquick2/qquickitemlayer/data/ToggleLayerAndEffect.qml delete mode 100644 tests/auto/qtquick2/qquickitemlayer/data/Visible.qml delete mode 100644 tests/auto/qtquick2/qquickitemlayer/data/ZOrder.qml delete mode 100644 tests/auto/qtquick2/qquickitemlayer/data/ZOrderChange.qml delete mode 100644 tests/auto/qtquick2/qquickitemlayer/qquickitemlayer.pro delete mode 100644 tests/auto/qtquick2/qquickitemlayer/tst_qquickitemlayer.cpp delete mode 100644 tests/auto/qtquick2/qquicklistview/data/ComponentView.qml delete mode 100644 tests/auto/qtquick2/qquicklistview/data/Page.qml delete mode 100644 tests/auto/qtquick2/qquicklistview/data/addTransitions.qml delete mode 100644 tests/auto/qtquick2/qquicklistview/data/asyncloader.qml delete mode 100644 tests/auto/qtquick2/qquicklistview/data/attachedSignals.qml delete mode 100644 tests/auto/qtquick2/qquicklistview/data/creationContext.qml delete mode 100644 tests/auto/qtquick2/qquicklistview/data/displaylist.qml delete mode 100644 tests/auto/qtquick2/qquicklistview/data/fillModelOnComponentCompleted.qml delete mode 100644 tests/auto/qtquick2/qquicklistview/data/footer.qml delete mode 100644 tests/auto/qtquick2/qquicklistview/data/header.qml delete mode 100644 tests/auto/qtquick2/qquicklistview/data/headerfooter.qml delete mode 100644 tests/auto/qtquick2/qquicklistview/data/itemlist.qml delete mode 100644 tests/auto/qtquick2/qquicklistview/data/listview-enforcerange-nohighlight.qml delete mode 100644 tests/auto/qtquick2/qquicklistview/data/listview-enforcerange.qml delete mode 100644 tests/auto/qtquick2/qquicklistview/data/listview-initCurrent.qml delete mode 100644 tests/auto/qtquick2/qquicklistview/data/listview-noCurrent.qml delete mode 100644 tests/auto/qtquick2/qquicklistview/data/listview-sections-package.qml delete mode 100644 tests/auto/qtquick2/qquicklistview/data/listview-sections.qml delete mode 100644 tests/auto/qtquick2/qquicklistview/data/listview-sections_delegate.qml delete mode 100644 tests/auto/qtquick2/qquicklistview/data/listviewtest-package.qml delete mode 100644 tests/auto/qtquick2/qquicklistview/data/listviewtest.qml delete mode 100644 tests/auto/qtquick2/qquicklistview/data/manual-highlight.qml delete mode 100644 tests/auto/qtquick2/qquicklistview/data/margins.qml delete mode 100644 tests/auto/qtquick2/qquicklistview/data/margins2.qml delete mode 100644 tests/auto/qtquick2/qquicklistview/data/moveTransitions.qml delete mode 100644 tests/auto/qtquick2/qquicklistview/data/multipleTransitions.qml delete mode 100644 tests/auto/qtquick2/qquicklistview/data/populateTransitions.qml delete mode 100644 tests/auto/qtquick2/qquicklistview/data/propertychangestest.qml delete mode 100644 tests/auto/qtquick2/qquicklistview/data/qtbug-21742.qml delete mode 100644 tests/auto/qtquick2/qquicklistview/data/qtbug14821.qml delete mode 100644 tests/auto/qtquick2/qquicklistview/data/qtbug16037.qml delete mode 100644 tests/auto/qtquick2/qquicklistview/data/removeTransitions.qml delete mode 100644 tests/auto/qtquick2/qquicklistview/data/resizeview.qml delete mode 100644 tests/auto/qtquick2/qquicklistview/data/rightToLeft.qml delete mode 100644 tests/auto/qtquick2/qquicklistview/data/sizelessthan1.qml delete mode 100644 tests/auto/qtquick2/qquicklistview/data/snapOneItem.qml delete mode 100644 tests/auto/qtquick2/qquicklistview/data/snapToItem.qml delete mode 100644 tests/auto/qtquick2/qquicklistview/data/strictlyenforcerange.qml delete mode 100644 tests/auto/qtquick2/qquicklistview/data/unrequestedItems.qml delete mode 100644 tests/auto/qtquick2/qquicklistview/incrementalmodel.cpp delete mode 100644 tests/auto/qtquick2/qquicklistview/incrementalmodel.h delete mode 100644 tests/auto/qtquick2/qquicklistview/qquicklistview.pro delete mode 100644 tests/auto/qtquick2/qquicklistview/tst_qquicklistview.cpp delete mode 100644 tests/auto/qtquick2/qquickloader/data/ActiveComponent.qml delete mode 100644 tests/auto/qtquick2/qquickloader/data/AnchoredLoader.qml delete mode 100644 tests/auto/qtquick2/qquickloader/data/BigComponent.qml delete mode 100644 tests/auto/qtquick2/qquickloader/data/BlueRect.qml delete mode 100644 tests/auto/qtquick2/qquickloader/data/CreationContextLoader.qml delete mode 100644 tests/auto/qtquick2/qquickloader/data/GraphicsWidget250x250.qml delete mode 100644 tests/auto/qtquick2/qquickloader/data/GreenRect.qml delete mode 100644 tests/auto/qtquick2/qquickloader/data/InitialPropertyValuesComponent.qml delete mode 100644 tests/auto/qtquick2/qquickloader/data/InvalidSourceComponent.qml delete mode 100644 tests/auto/qtquick2/qquickloader/data/NoResize.qml delete mode 100644 tests/auto/qtquick2/qquickloader/data/NoResizeGraphicsWidget.qml delete mode 100644 tests/auto/qtquick2/qquickloader/data/QTBUG_16928.qml delete mode 100644 tests/auto/qtquick2/qquickloader/data/QTBUG_17114.qml delete mode 100644 tests/auto/qtquick2/qquickloader/data/Rect120x60.qml delete mode 100644 tests/auto/qtquick2/qquickloader/data/SetSourceComponent.qml delete mode 100644 tests/auto/qtquick2/qquickloader/data/SizeGraphicsWidgetToLoader.qml delete mode 100644 tests/auto/qtquick2/qquickloader/data/SizeLoaderToGraphicsWidget.qml delete mode 100644 tests/auto/qtquick2/qquickloader/data/SizeToItem.qml delete mode 100644 tests/auto/qtquick2/qquickloader/data/SizeToLoader.qml delete mode 100644 tests/auto/qtquick2/qquickloader/data/VmeError.qml delete mode 100644 tests/auto/qtquick2/qquickloader/data/active.1.qml delete mode 100644 tests/auto/qtquick2/qquickloader/data/active.2.qml delete mode 100644 tests/auto/qtquick2/qquickloader/data/active.3.qml delete mode 100644 tests/auto/qtquick2/qquickloader/data/active.4.qml delete mode 100644 tests/auto/qtquick2/qquickloader/data/active.5.qml delete mode 100644 tests/auto/qtquick2/qquickloader/data/active.6.qml delete mode 100644 tests/auto/qtquick2/qquickloader/data/active.7.qml delete mode 100644 tests/auto/qtquick2/qquickloader/data/active.8.qml delete mode 100644 tests/auto/qtquick2/qquickloader/data/asynchronous.qml delete mode 100644 tests/auto/qtquick2/qquickloader/data/crash.qml delete mode 100644 tests/auto/qtquick2/qquickloader/data/creationContext.qml delete mode 100644 tests/auto/qtquick2/qquickloader/data/differentorigin.qml delete mode 100644 tests/auto/qtquick2/qquickloader/data/implicitSize.qml delete mode 100644 tests/auto/qtquick2/qquickloader/data/initialPropertyValues.1.qml delete mode 100644 tests/auto/qtquick2/qquickloader/data/initialPropertyValues.2.qml delete mode 100644 tests/auto/qtquick2/qquickloader/data/initialPropertyValues.3.qml delete mode 100644 tests/auto/qtquick2/qquickloader/data/initialPropertyValues.4.qml delete mode 100644 tests/auto/qtquick2/qquickloader/data/initialPropertyValues.5.qml delete mode 100644 tests/auto/qtquick2/qquickloader/data/initialPropertyValues.6.qml delete mode 100644 tests/auto/qtquick2/qquickloader/data/initialPropertyValues.7.qml delete mode 100644 tests/auto/qtquick2/qquickloader/data/initialPropertyValues.8.qml delete mode 100644 tests/auto/qtquick2/qquickloader/data/initialPropertyValues.binding.qml delete mode 100644 tests/auto/qtquick2/qquickloader/data/initialPropertyValues.error.1.qml delete mode 100644 tests/auto/qtquick2/qquickloader/data/initialPropertyValues.error.2.qml delete mode 100644 tests/auto/qtquick2/qquickloader/data/initialPropertyValues.error.3.qml delete mode 100644 tests/auto/qtquick2/qquickloader/data/initialPropertyValues.error.4.qml delete mode 100644 tests/auto/qtquick2/qquickloader/data/nonItem.qml delete mode 100644 tests/auto/qtquick2/qquickloader/data/parented.qml delete mode 100644 tests/auto/qtquick2/qquickloader/data/qmldir delete mode 100644 tests/auto/qtquick2/qquickloader/data/sameorigin-load.qml delete mode 100644 tests/auto/qtquick2/qquickloader/data/sameorigin.qml delete mode 100644 tests/auto/qtquick2/qquickloader/data/sizebound.qml delete mode 100644 tests/auto/qtquick2/qquickloader/data/vmeErrors.qml delete mode 100644 tests/auto/qtquick2/qquickloader/qquickloader.pro delete mode 100644 tests/auto/qtquick2/qquickloader/tst_qquickloader.cpp delete mode 100644 tests/auto/qtquick2/qquickmousearea/data/clickThrough.qml delete mode 100644 tests/auto/qtquick2/qquickmousearea/data/clickThrough2.qml delete mode 100644 tests/auto/qtquick2/qquickmousearea/data/clickandhold.qml delete mode 100644 tests/auto/qtquick2/qquickmousearea/data/clicktwice.qml delete mode 100644 tests/auto/qtquick2/qquickmousearea/data/doubleclick.qml delete mode 100644 tests/auto/qtquick2/qquickmousearea/data/dragging.qml delete mode 100644 tests/auto/qtquick2/qquickmousearea/data/dragproperties.qml delete mode 100644 tests/auto/qtquick2/qquickmousearea/data/dragreset.qml delete mode 100644 tests/auto/qtquick2/qquickmousearea/data/hoverPosition.qml delete mode 100644 tests/auto/qtquick2/qquickmousearea/data/hoverPropagation.qml delete mode 100644 tests/auto/qtquick2/qquickmousearea/data/hoverVisible.qml delete mode 100644 tests/auto/qtquick2/qquickmousearea/data/noclickandhold.qml delete mode 100644 tests/auto/qtquick2/qquickmousearea/data/pressedCanceled.qml delete mode 100644 tests/auto/qtquick2/qquickmousearea/data/pressedOrdering.qml delete mode 100644 tests/auto/qtquick2/qquickmousearea/data/preventstealing.qml delete mode 100644 tests/auto/qtquick2/qquickmousearea/data/rejectEvent.qml delete mode 100644 tests/auto/qtquick2/qquickmousearea/data/updateMousePosOnClick.qml delete mode 100644 tests/auto/qtquick2/qquickmousearea/data/updateMousePosOnResize.qml delete mode 100644 tests/auto/qtquick2/qquickmousearea/qquickmousearea.pro delete mode 100644 tests/auto/qtquick2/qquickmousearea/tst_qquickmousearea.cpp delete mode 100644 tests/auto/qtquick2/qquickmultipointtoucharea/data/basic.qml delete mode 100644 tests/auto/qtquick2/qquickmultipointtoucharea/data/inFlickable.qml delete mode 100644 tests/auto/qtquick2/qquickmultipointtoucharea/data/nested.qml delete mode 100644 tests/auto/qtquick2/qquickmultipointtoucharea/data/nonOverlapping.qml delete mode 100644 tests/auto/qtquick2/qquickmultipointtoucharea/data/properties.qml delete mode 100644 tests/auto/qtquick2/qquickmultipointtoucharea/data/signalTest.qml delete mode 100644 tests/auto/qtquick2/qquickmultipointtoucharea/qquickmultipointtoucharea.pro delete mode 100644 tests/auto/qtquick2/qquickmultipointtoucharea/tst_qquickmultipointtoucharea.cpp delete mode 100644 tests/auto/qtquick2/qquickpathview/data/ComponentView.qml delete mode 100644 tests/auto/qtquick2/qquickpathview/data/asyncloader.qml delete mode 100644 tests/auto/qtquick2/qquickpathview/data/closedPath.qml delete mode 100644 tests/auto/qtquick2/qquickpathview/data/creationContext.qml delete mode 100644 tests/auto/qtquick2/qquickpathview/data/datamodel.qml delete mode 100644 tests/auto/qtquick2/qquickpathview/data/displaypath.qml delete mode 100644 tests/auto/qtquick2/qquickpathview/data/dragpath.qml delete mode 100644 tests/auto/qtquick2/qquickpathview/data/emptymodel.qml delete mode 100644 tests/auto/qtquick2/qquickpathview/data/missingPercent.qml delete mode 100644 tests/auto/qtquick2/qquickpathview/data/openPath.qml delete mode 100644 tests/auto/qtquick2/qquickpathview/data/pathUpdate.qml delete mode 100644 tests/auto/qtquick2/qquickpathview/data/pathUpdateOnStartChanged.qml delete mode 100644 tests/auto/qtquick2/qquickpathview/data/pathline.qml delete mode 100644 tests/auto/qtquick2/qquickpathview/data/pathtest.qml delete mode 100644 tests/auto/qtquick2/qquickpathview/data/pathview0.qml delete mode 100644 tests/auto/qtquick2/qquickpathview/data/pathview1.qml delete mode 100644 tests/auto/qtquick2/qquickpathview/data/pathview2.qml delete mode 100644 tests/auto/qtquick2/qquickpathview/data/pathview3.qml delete mode 100644 tests/auto/qtquick2/qquickpathview/data/pathview_package.qml delete mode 100644 tests/auto/qtquick2/qquickpathview/data/propertychanges.qml delete mode 100644 tests/auto/qtquick2/qquickpathview/data/treemodel.qml delete mode 100644 tests/auto/qtquick2/qquickpathview/data/undefinedpath.qml delete mode 100644 tests/auto/qtquick2/qquickpathview/data/vdm.qml delete mode 100644 tests/auto/qtquick2/qquickpathview/qquickpathview.pro delete mode 100644 tests/auto/qtquick2/qquickpathview/tst_qquickpathview.cpp delete mode 100644 tests/auto/qtquick2/qquickpincharea/data/pinchproperties.qml delete mode 100644 tests/auto/qtquick2/qquickpincharea/qquickpincharea.pro delete mode 100644 tests/auto/qtquick2/qquickpincharea/tst_qquickpincharea.cpp delete mode 100644 tests/auto/qtquick2/qquickpositioners/data/allInvisible.qml delete mode 100644 tests/auto/qtquick2/qquickpositioners/data/attachedproperties-column.qml delete mode 100644 tests/auto/qtquick2/qquickpositioners/data/attachedproperties-dynamic.qml delete mode 100644 tests/auto/qtquick2/qquickpositioners/data/attachedproperties-flow.qml delete mode 100644 tests/auto/qtquick2/qquickpositioners/data/attachedproperties-grid.qml delete mode 100644 tests/auto/qtquick2/qquickpositioners/data/attachedproperties-row.qml delete mode 100644 tests/auto/qtquick2/qquickpositioners/data/flow-testimplicitsize.qml delete mode 100644 tests/auto/qtquick2/qquickpositioners/data/flowtest-toptobottom.qml delete mode 100644 tests/auto/qtquick2/qquickpositioners/data/flowtest.qml delete mode 100644 tests/auto/qtquick2/qquickpositioners/data/grid-animated.qml delete mode 100644 tests/auto/qtquick2/qquickpositioners/data/grid-row-column-spacing.qml delete mode 100644 tests/auto/qtquick2/qquickpositioners/data/grid-spacing.qml delete mode 100644 tests/auto/qtquick2/qquickpositioners/data/grid-toptobottom.qml delete mode 100644 tests/auto/qtquick2/qquickpositioners/data/gridtest.qml delete mode 100644 tests/auto/qtquick2/qquickpositioners/data/gridzerocolumns.qml delete mode 100644 tests/auto/qtquick2/qquickpositioners/data/horizontal-animated-disabled.qml delete mode 100644 tests/auto/qtquick2/qquickpositioners/data/horizontal-animated.qml delete mode 100644 tests/auto/qtquick2/qquickpositioners/data/horizontal-spacing.qml delete mode 100644 tests/auto/qtquick2/qquickpositioners/data/horizontal.qml delete mode 100644 tests/auto/qtquick2/qquickpositioners/data/propertychangestest.qml delete mode 100644 tests/auto/qtquick2/qquickpositioners/data/rectangleComponent.qml delete mode 100644 tests/auto/qtquick2/qquickpositioners/data/repeatertest.qml delete mode 100644 tests/auto/qtquick2/qquickpositioners/data/vertical-animated.qml delete mode 100644 tests/auto/qtquick2/qquickpositioners/data/vertical-spacing.qml delete mode 100644 tests/auto/qtquick2/qquickpositioners/data/vertical.qml delete mode 100644 tests/auto/qtquick2/qquickpositioners/qquickpositioners.pro delete mode 100644 tests/auto/qtquick2/qquickpositioners/tst_qquickpositioners.cpp delete mode 100644 tests/auto/qtquick2/qquickrepeater/data/asyncloader.qml delete mode 100644 tests/auto/qtquick2/qquickrepeater/data/initparent.qml delete mode 100644 tests/auto/qtquick2/qquickrepeater/data/intmodel.qml delete mode 100644 tests/auto/qtquick2/qquickrepeater/data/itemlist.qml delete mode 100644 tests/auto/qtquick2/qquickrepeater/data/modelChanged.qml delete mode 100644 tests/auto/qtquick2/qquickrepeater/data/objlist.qml delete mode 100644 tests/auto/qtquick2/qquickrepeater/data/properties.qml delete mode 100644 tests/auto/qtquick2/qquickrepeater/data/repeater1.qml delete mode 100644 tests/auto/qtquick2/qquickrepeater/data/repeater2.qml delete mode 100644 tests/auto/qtquick2/qquickrepeater/qquickrepeater.pro delete mode 100644 tests/auto/qtquick2/qquickrepeater/tst_qquickrepeater.cpp delete mode 100644 tests/auto/qtquick2/qquickscreen/data/screen.qml delete mode 100644 tests/auto/qtquick2/qquickscreen/qquickscreen.pro delete mode 100644 tests/auto/qtquick2/qquickscreen/tst_qquickscreen.cpp delete mode 100644 tests/auto/qtquick2/qquickshadereffect/qquickshadereffect.pro delete mode 100644 tests/auto/qtquick2/qquickshadereffect/tst_qquickshadereffect.cpp delete mode 100644 tests/auto/qtquick2/qquickspriteimage/data/advance.qml delete mode 100644 tests/auto/qtquick2/qquickspriteimage/data/basic.qml delete mode 100644 tests/auto/qtquick2/qquickspriteimage/data/squarefacesprite.png delete mode 100644 tests/auto/qtquick2/qquickspriteimage/qquickspriteimage.pro delete mode 100644 tests/auto/qtquick2/qquickspriteimage/tst_qquickspriteimage.cpp delete mode 100644 tests/auto/qtquick2/qquicktext/data/alignments.qml delete mode 100644 tests/auto/qtquick2/qquicktext/data/alignments_cb.png delete mode 100644 tests/auto/qtquick2/qquicktext/data/alignments_cc.png delete mode 100644 tests/auto/qtquick2/qquicktext/data/alignments_ct.png delete mode 100644 tests/auto/qtquick2/qquicktext/data/alignments_lb.png delete mode 100644 tests/auto/qtquick2/qquicktext/data/alignments_lc.png delete mode 100644 tests/auto/qtquick2/qquicktext/data/alignments_lt.png delete mode 100644 tests/auto/qtquick2/qquicktext/data/alignments_rb.png delete mode 100644 tests/auto/qtquick2/qquicktext/data/alignments_rc.png delete mode 100644 tests/auto/qtquick2/qquicktext/data/alignments_rt.png delete mode 100644 tests/auto/qtquick2/qquicktext/data/embeddedImagesLocal.qml delete mode 100644 tests/auto/qtquick2/qquicktext/data/embeddedImagesLocalError.qml delete mode 100644 tests/auto/qtquick2/qquicktext/data/embeddedImagesLocalRelative.qml delete mode 100644 tests/auto/qtquick2/qquicktext/data/embeddedImagesRemote.qml delete mode 100644 tests/auto/qtquick2/qquicktext/data/embeddedImagesRemoteError.qml delete mode 100644 tests/auto/qtquick2/qquicktext/data/embeddedImagesRemoteRelative.qml delete mode 100644 tests/auto/qtquick2/qquicktext/data/fontSizeMode.qml delete mode 100644 tests/auto/qtquick2/qquicktext/data/horizontalAlignment_RightToLeft.qml delete mode 100644 tests/auto/qtquick2/qquicktext/data/http/exists.png delete mode 100644 tests/auto/qtquick2/qquicktext/data/images/face-sad.png delete mode 100644 tests/auto/qtquick2/qquicktext/data/images/heart200.png delete mode 100644 tests/auto/qtquick2/qquicktext/data/images/starfish_2.png delete mode 100644 tests/auto/qtquick2/qquicktext/data/imgTagsElide.qml delete mode 100644 tests/auto/qtquick2/qquicktext/data/imgTagsUpdates.qml delete mode 100644 tests/auto/qtquick2/qquicktext/data/lineCount.qml delete mode 100644 tests/auto/qtquick2/qquicktext/data/lineHeight.qml delete mode 100644 tests/auto/qtquick2/qquicktext/data/lineLayout.qml delete mode 100644 tests/auto/qtquick2/qquicktext/data/multilengthStrings.qml delete mode 100644 tests/auto/qtquick2/qquicktext/data/multilengthStringsWrapped.qml delete mode 100644 tests/auto/qtquick2/qquicktext/data/multilineelide.qml delete mode 100644 tests/auto/qtquick2/qquicktext/data/qtbug_14734.qml delete mode 100644 tests/auto/qtquick2/qquicktext/data/rotated.qml delete mode 100644 tests/auto/qtquick2/qquicktext/qquicktext.pro delete mode 100644 tests/auto/qtquick2/qquicktext/tst_qquicktext.cpp delete mode 100644 tests/auto/qtquick2/qquicktextedit/data/Cursor.qml delete mode 100644 tests/auto/qtquick2/qquicktextedit/data/CursorRect.qml delete mode 100644 tests/auto/qtquick2/qquicktextedit/data/alignments.qml delete mode 100644 tests/auto/qtquick2/qquicktextedit/data/alignments_cb.png delete mode 100644 tests/auto/qtquick2/qquicktextedit/data/alignments_cc.png delete mode 100644 tests/auto/qtquick2/qquicktextedit/data/alignments_ct.png delete mode 100644 tests/auto/qtquick2/qquicktextedit/data/alignments_lb.png delete mode 100644 tests/auto/qtquick2/qquicktextedit/data/alignments_lc.png delete mode 100644 tests/auto/qtquick2/qquicktextedit/data/alignments_lt.png delete mode 100644 tests/auto/qtquick2/qquicktextedit/data/alignments_rb.png delete mode 100644 tests/auto/qtquick2/qquicktextedit/data/alignments_rc.png delete mode 100644 tests/auto/qtquick2/qquicktextedit/data/alignments_rt.png delete mode 100644 tests/auto/qtquick2/qquicktextedit/data/cursorTest.qml delete mode 100644 tests/auto/qtquick2/qquicktextedit/data/cursorTestExternal.qml delete mode 100644 tests/auto/qtquick2/qquicktextedit/data/cursorTestInline.qml delete mode 100644 tests/auto/qtquick2/qquicktextedit/data/cursorVisible.qml delete mode 100644 tests/auto/qtquick2/qquicktextedit/data/embeddedImagesLocal.qml delete mode 100644 tests/auto/qtquick2/qquicktextedit/data/embeddedImagesLocalError.qml delete mode 100644 tests/auto/qtquick2/qquicktextedit/data/embeddedImagesLocalRelative.qml delete mode 100644 tests/auto/qtquick2/qquicktextedit/data/embeddedImagesRemote.qml delete mode 100644 tests/auto/qtquick2/qquicktextedit/data/embeddedImagesRemoteError.qml delete mode 100644 tests/auto/qtquick2/qquicktextedit/data/embeddedImagesRemoteRelative.qml delete mode 100644 tests/auto/qtquick2/qquicktextedit/data/geometrySignals.qml delete mode 100644 tests/auto/qtquick2/qquicktextedit/data/horizontalAlignment_RightToLeft.qml delete mode 100644 tests/auto/qtquick2/qquicktextedit/data/http/ErrItem.qml delete mode 100644 tests/auto/qtquick2/qquicktextedit/data/http/NormItem.qml delete mode 100644 tests/auto/qtquick2/qquicktextedit/data/http/cursorHttpTest.qml delete mode 100644 tests/auto/qtquick2/qquicktextedit/data/http/cursorHttpTestFail1.qml delete mode 100644 tests/auto/qtquick2/qquicktextedit/data/http/cursorHttpTestFail2.qml delete mode 100644 tests/auto/qtquick2/qquicktextedit/data/http/cursorHttpTestPass.qml delete mode 100644 tests/auto/qtquick2/qquicktextedit/data/http/exists.png delete mode 100644 tests/auto/qtquick2/qquicktextedit/data/http/qmldir delete mode 100644 tests/auto/qtquick2/qquicktextedit/data/httpfail/FailItem.qml delete mode 100644 tests/auto/qtquick2/qquicktextedit/data/httpslow/WaitItem.qml delete mode 100644 tests/auto/qtquick2/qquicktextedit/data/inputContext.qml delete mode 100644 tests/auto/qtquick2/qquicktextedit/data/inputMethodEvent.qml delete mode 100644 tests/auto/qtquick2/qquicktextedit/data/inputmethodhints.qml delete mode 100644 tests/auto/qtquick2/qquicktextedit/data/linkActivated.qml delete mode 100644 tests/auto/qtquick2/qquicktextedit/data/mouseselection_default.qml delete mode 100644 tests/auto/qtquick2/qquicktextedit/data/mouseselection_false.qml delete mode 100644 tests/auto/qtquick2/qquicktextedit/data/mouseselection_false_words.qml delete mode 100644 tests/auto/qtquick2/qquicktextedit/data/mouseselection_true.qml delete mode 100644 tests/auto/qtquick2/qquicktextedit/data/mouseselection_true_words.qml delete mode 100644 tests/auto/qtquick2/qquicktextedit/data/mouseselectionmode_characters.qml delete mode 100644 tests/auto/qtquick2/qquicktextedit/data/mouseselectionmode_default.qml delete mode 100644 tests/auto/qtquick2/qquicktextedit/data/mouseselectionmode_words.qml delete mode 100644 tests/auto/qtquick2/qquicktextedit/data/navigation.qml delete mode 100644 tests/auto/qtquick2/qquicktextedit/data/openInputPanel.qml delete mode 100644 tests/auto/qtquick2/qquicktextedit/data/persistentSelection.qml delete mode 100644 tests/auto/qtquick2/qquicktextedit/data/positionAt.qml delete mode 100644 tests/auto/qtquick2/qquicktextedit/data/qtbug-22058.qml delete mode 100644 tests/auto/qtquick2/qquicktextedit/data/readOnly.qml delete mode 100644 tests/auto/qtquick2/qquicktextedit/qquicktextedit.pro delete mode 100644 tests/auto/qtquick2/qquicktextedit/tst_qquicktextedit.cpp delete mode 100644 tests/auto/qtquick2/qquicktextinput/data/Cursor.qml delete mode 100644 tests/auto/qtquick2/qquicktextinput/data/cursorTest.qml delete mode 100644 tests/auto/qtquick2/qquicktextinput/data/cursorTestExternal.qml delete mode 100644 tests/auto/qtquick2/qquicktextinput/data/cursorTestInline.qml delete mode 100644 tests/auto/qtquick2/qquicktextinput/data/cursorVisible.qml delete mode 100644 tests/auto/qtquick2/qquicktextinput/data/echoMode.qml delete mode 100644 tests/auto/qtquick2/qquicktextinput/data/geometrySignals.qml delete mode 100644 tests/auto/qtquick2/qquicktextinput/data/halign_center.png delete mode 100644 tests/auto/qtquick2/qquicktextinput/data/halign_left.png delete mode 100644 tests/auto/qtquick2/qquicktextinput/data/halign_right.png delete mode 100644 tests/auto/qtquick2/qquicktextinput/data/horizontalAlignment.qml delete mode 100644 tests/auto/qtquick2/qquicktextinput/data/horizontalAlignment_RightToLeft.qml delete mode 100644 tests/auto/qtquick2/qquicktextinput/data/inputContext.qml delete mode 100644 tests/auto/qtquick2/qquicktextinput/data/inputMethodEvent.qml delete mode 100644 tests/auto/qtquick2/qquicktextinput/data/inputmethods.qml delete mode 100644 tests/auto/qtquick2/qquicktextinput/data/masks.qml delete mode 100644 tests/auto/qtquick2/qquicktextinput/data/maxLength.qml delete mode 100644 tests/auto/qtquick2/qquicktextinput/data/mouseselection_true.qml delete mode 100644 tests/auto/qtquick2/qquicktextinput/data/mouseselectionmode_characters.qml delete mode 100644 tests/auto/qtquick2/qquicktextinput/data/mouseselectionmode_default.qml delete mode 100644 tests/auto/qtquick2/qquicktextinput/data/mouseselectionmode_words.qml delete mode 100644 tests/auto/qtquick2/qquicktextinput/data/navigation.qml delete mode 100644 tests/auto/qtquick2/qquicktextinput/data/negativeDimensions.qml delete mode 100644 tests/auto/qtquick2/qquicktextinput/data/openInputPanel.qml delete mode 100644 tests/auto/qtquick2/qquicktextinput/data/persistentSelection.qml delete mode 100644 tests/auto/qtquick2/qquicktextinput/data/positionAt.qml delete mode 100644 tests/auto/qtquick2/qquicktextinput/data/preeditAutoScroll.qml delete mode 100644 tests/auto/qtquick2/qquicktextinput/data/qtbug-19956double.qml delete mode 100644 tests/auto/qtquick2/qquicktextinput/data/qtbug-19956int.qml delete mode 100644 tests/auto/qtquick2/qquicktextinput/data/qtbug-19956regexp.qml delete mode 100644 tests/auto/qtquick2/qquicktextinput/data/readOnly.qml delete mode 100644 tests/auto/qtquick2/qquicktextinput/data/validators.qml delete mode 100644 tests/auto/qtquick2/qquicktextinput/qquicktextinput.pro delete mode 100644 tests/auto/qtquick2/qquicktextinput/tst_qquicktextinput.cpp delete mode 100644 tests/auto/qtquick2/qquickview/data/error1.qml delete mode 100644 tests/auto/qtquick2/qquickview/data/resizemodeitem.qml delete mode 100644 tests/auto/qtquick2/qquickview/qquickview.pro delete mode 100644 tests/auto/qtquick2/qquickview/tst_qquickview.cpp delete mode 100644 tests/auto/qtquick2/qquickvisualdatamodel/data/create.qml delete mode 100644 tests/auto/qtquick2/qquickvisualdatamodel/data/datalist-package.qml delete mode 100644 tests/auto/qtquick2/qquickvisualdatamodel/data/datalist.qml delete mode 100644 tests/auto/qtquick2/qquickvisualdatamodel/data/groups-invalid.qml delete mode 100644 tests/auto/qtquick2/qquickvisualdatamodel/data/groups-package.qml delete mode 100644 tests/auto/qtquick2/qquickvisualdatamodel/data/groups.qml delete mode 100644 tests/auto/qtquick2/qquickvisualdatamodel/data/itemsDestroyed_listView.qml delete mode 100644 tests/auto/qtquick2/qquickvisualdatamodel/data/itemsDestroyed_package.qml delete mode 100644 tests/auto/qtquick2/qquickvisualdatamodel/data/itemsDestroyed_pathView.qml delete mode 100644 tests/auto/qtquick2/qquickvisualdatamodel/data/itemsDestroyed_repeater.qml delete mode 100644 tests/auto/qtquick2/qquickvisualdatamodel/data/listmodelproperties-package.qml delete mode 100644 tests/auto/qtquick2/qquickvisualdatamodel/data/listmodelproperties.qml delete mode 100644 tests/auto/qtquick2/qquickvisualdatamodel/data/modelproperties.qml delete mode 100644 tests/auto/qtquick2/qquickvisualdatamodel/data/modelproperties2.qml delete mode 100644 tests/auto/qtquick2/qquickvisualdatamodel/data/multipleroleproperties-package.qml delete mode 100644 tests/auto/qtquick2/qquickvisualdatamodel/data/multipleroleproperties.qml delete mode 100644 tests/auto/qtquick2/qquickvisualdatamodel/data/objectlist.qml delete mode 100644 tests/auto/qtquick2/qquickvisualdatamodel/data/objectlistproperties-package.qml delete mode 100644 tests/auto/qtquick2/qquickvisualdatamodel/data/objectlistproperties.qml delete mode 100644 tests/auto/qtquick2/qquickvisualdatamodel/data/onChanged.qml delete mode 100644 tests/auto/qtquick2/qquickvisualdatamodel/data/packageView.qml delete mode 100644 tests/auto/qtquick2/qquickvisualdatamodel/data/singlerole1.qml delete mode 100644 tests/auto/qtquick2/qquickvisualdatamodel/data/singlerole2.qml delete mode 100644 tests/auto/qtquick2/qquickvisualdatamodel/data/singleroleproperties-package.qml delete mode 100644 tests/auto/qtquick2/qquickvisualdatamodel/data/singleroleproperties.qml delete mode 100644 tests/auto/qtquick2/qquickvisualdatamodel/data/stringlistproperties-package.qml delete mode 100644 tests/auto/qtquick2/qquickvisualdatamodel/data/stringlistproperties.qml delete mode 100644 tests/auto/qtquick2/qquickvisualdatamodel/data/visualdatamodel.qml delete mode 100644 tests/auto/qtquick2/qquickvisualdatamodel/qquickvisualdatamodel.pro delete mode 100644 tests/auto/qtquick2/qquickvisualdatamodel/tst_qquickvisualdatamodel.cpp delete mode 100644 tests/auto/qtquick2/qtquick2.pro delete mode 100644 tests/auto/qtquick2/rendernode/data/MessUpState.qml delete mode 100644 tests/auto/qtquick2/rendernode/data/RenderOrder.qml delete mode 100644 tests/auto/qtquick2/rendernode/rendernode.pro delete mode 100644 tests/auto/qtquick2/rendernode/tst_rendernode.cpp delete mode 100644 tests/auto/qtquick2/shared/util.pri delete mode 100644 tests/auto/qtquick2/shared/viewtestutil.cpp delete mode 100644 tests/auto/qtquick2/shared/viewtestutil.h delete mode 100644 tests/auto/qtquick2/shared/visualtestutil.cpp delete mode 100644 tests/auto/qtquick2/shared/visualtestutil.h create mode 100644 tests/auto/quick/examples/data/dummytest.qml create mode 100644 tests/auto/quick/examples/data/webbrowser/webbrowser.qml create mode 100644 tests/auto/quick/examples/examples.pro create mode 100644 tests/auto/quick/examples/tst_examples.cpp create mode 100644 tests/auto/quick/geometry/geometry.pro create mode 100644 tests/auto/quick/geometry/tst_geometry.cpp create mode 100644 tests/auto/quick/nodes/nodes.pro create mode 100644 tests/auto/quick/nodes/tst_nodestest.cpp create mode 100644 tests/auto/quick/qquickaccessible/data/checkbuttons.qml create mode 100644 tests/auto/quick/qquickaccessible/data/hittest.qml create mode 100644 tests/auto/quick/qquickaccessible/data/pushbutton.qml create mode 100644 tests/auto/quick/qquickaccessible/data/statictext.qml create mode 100644 tests/auto/quick/qquickaccessible/data/widgets/TextRect.qml create mode 100644 tests/auto/quick/qquickaccessible/qquickaccessible.pro create mode 100644 tests/auto/quick/qquickaccessible/tst_qquickaccessible.cpp create mode 100644 tests/auto/quick/qquickanchors/data/anchors.qml create mode 100644 tests/auto/quick/qquickanchors/data/centerin.qml create mode 100644 tests/auto/quick/qquickanchors/data/centerinRotation.qml create mode 100644 tests/auto/quick/qquickanchors/data/crash1.qml create mode 100644 tests/auto/quick/qquickanchors/data/fill.qml create mode 100644 tests/auto/quick/qquickanchors/data/hvCenter.qml create mode 100644 tests/auto/quick/qquickanchors/data/loop1.qml create mode 100644 tests/auto/quick/qquickanchors/data/loop2.qml create mode 100644 tests/auto/quick/qquickanchors/data/margins.qml create mode 100644 tests/auto/quick/qquickanchors/qquickanchors.pro create mode 100644 tests/auto/quick/qquickanchors/tst_qquickanchors.cpp create mode 100644 tests/auto/quick/qquickanimatedimage/data/colors.gif create mode 100644 tests/auto/quick/qquickanimatedimage/data/colors.qml create mode 100644 tests/auto/quick/qquickanimatedimage/data/hearts.gif create mode 100644 tests/auto/quick/qquickanimatedimage/data/hearts.qml create mode 100644 tests/auto/quick/qquickanimatedimage/data/qmldir create mode 100644 tests/auto/quick/qquickanimatedimage/data/qtbug-16520.qml create mode 100644 tests/auto/quick/qquickanimatedimage/data/stickman.gif create mode 100644 tests/auto/quick/qquickanimatedimage/data/stickman.qml create mode 100644 tests/auto/quick/qquickanimatedimage/data/stickmanerror1.qml create mode 100644 tests/auto/quick/qquickanimatedimage/data/stickmanpause.qml create mode 100644 tests/auto/quick/qquickanimatedimage/data/stickmanscaled.qml create mode 100644 tests/auto/quick/qquickanimatedimage/data/stickmanstopped.qml create mode 100644 tests/auto/quick/qquickanimatedimage/qquickanimatedimage.pro create mode 100644 tests/auto/quick/qquickanimatedimage/tst_qquickanimatedimage.cpp create mode 100644 tests/auto/quick/qquickanimationcontroller/data/tst_numberanimation.qml create mode 100644 tests/auto/quick/qquickanimationcontroller/qquickanimationcontroller.pro create mode 100644 tests/auto/quick/qquickanimationcontroller/tst_qquickanimationcontroller.cpp create mode 100644 tests/auto/quick/qquickanimations/data/Double.qml create mode 100644 tests/auto/quick/qquickanimations/data/attached.qml create mode 100644 tests/auto/quick/qquickanimations/data/badproperty1.qml create mode 100644 tests/auto/quick/qquickanimations/data/badproperty2.qml create mode 100644 tests/auto/quick/qquickanimations/data/badtype1.qml create mode 100644 tests/auto/quick/qquickanimations/data/badtype2.qml create mode 100644 tests/auto/quick/qquickanimations/data/badtype3.qml create mode 100644 tests/auto/quick/qquickanimations/data/badtype4.qml create mode 100644 tests/auto/quick/qquickanimations/data/disabledTransition.qml create mode 100644 tests/auto/quick/qquickanimations/data/dontAutoStart.qml create mode 100644 tests/auto/quick/qquickanimations/data/dontStart.qml create mode 100644 tests/auto/quick/qquickanimations/data/dontStart2.qml create mode 100644 tests/auto/quick/qquickanimations/data/dotproperty.qml create mode 100644 tests/auto/quick/qquickanimations/data/doubleRegistrationBug.qml create mode 100644 tests/auto/quick/qquickanimations/data/looping.qml create mode 100644 tests/auto/quick/qquickanimations/data/mixedtype1.qml create mode 100644 tests/auto/quick/qquickanimations/data/mixedtype2.qml create mode 100644 tests/auto/quick/qquickanimations/data/nonTransitionBug.qml create mode 100644 tests/auto/quick/qquickanimations/data/pathAnimation.qml create mode 100644 tests/auto/quick/qquickanimations/data/pathAnimation2.qml create mode 100644 tests/auto/quick/qquickanimations/data/pathAnimationNoStart.qml create mode 100644 tests/auto/quick/qquickanimations/data/pathInterpolator.qml create mode 100644 tests/auto/quick/qquickanimations/data/pathInterpolatorBack.qml create mode 100644 tests/auto/quick/qquickanimations/data/pathInterpolatorBack2.qml create mode 100644 tests/auto/quick/qquickanimations/data/pathTransition.qml create mode 100644 tests/auto/quick/qquickanimations/data/pauseBindingBug.qml create mode 100644 tests/auto/quick/qquickanimations/data/pauseBug.qml create mode 100644 tests/auto/quick/qquickanimations/data/properties.qml create mode 100644 tests/auto/quick/qquickanimations/data/properties2.qml create mode 100644 tests/auto/quick/qquickanimations/data/properties3.qml create mode 100644 tests/auto/quick/qquickanimations/data/properties4.qml create mode 100644 tests/auto/quick/qquickanimations/data/properties5.qml create mode 100644 tests/auto/quick/qquickanimations/data/propertiesTransition.qml create mode 100644 tests/auto/quick/qquickanimations/data/propertiesTransition2.qml create mode 100644 tests/auto/quick/qquickanimations/data/propertiesTransition3.qml create mode 100644 tests/auto/quick/qquickanimations/data/propertiesTransition4.qml create mode 100644 tests/auto/quick/qquickanimations/data/propertiesTransition5.qml create mode 100644 tests/auto/quick/qquickanimations/data/propertiesTransition6.qml create mode 100644 tests/auto/quick/qquickanimations/data/propertiesTransition7.qml create mode 100644 tests/auto/quick/qquickanimations/data/reanchor.qml create mode 100644 tests/auto/quick/qquickanimations/data/registrationBug.qml create mode 100644 tests/auto/quick/qquickanimations/data/reparent.qml create mode 100644 tests/auto/quick/qquickanimations/data/rotation.qml create mode 100644 tests/auto/quick/qquickanimations/data/runningTrueBug.qml create mode 100644 tests/auto/quick/qquickanimations/data/transitionAssignmentBug.qml create mode 100644 tests/auto/quick/qquickanimations/data/valuesource.qml create mode 100644 tests/auto/quick/qquickanimations/data/valuesource2.qml create mode 100644 tests/auto/quick/qquickanimations/qquickanimations.pro create mode 100644 tests/auto/quick/qquickanimations/tst_qquickanimations.cpp create mode 100644 tests/auto/quick/qquickapplication/qquickapplication.pro create mode 100644 tests/auto/quick/qquickapplication/tst_qquickapplication.cpp create mode 100644 tests/auto/quick/qquickbehaviors/data/binding.qml create mode 100644 tests/auto/quick/qquickbehaviors/data/color.qml create mode 100644 tests/auto/quick/qquickbehaviors/data/cpptrigger.qml create mode 100644 tests/auto/quick/qquickbehaviors/data/delayedRegistration.qml create mode 100644 tests/auto/quick/qquickbehaviors/data/disabled.qml create mode 100644 tests/auto/quick/qquickbehaviors/data/dontStart.qml create mode 100644 tests/auto/quick/qquickbehaviors/data/empty.qml create mode 100644 tests/auto/quick/qquickbehaviors/data/explicit.qml create mode 100644 tests/auto/quick/qquickbehaviors/data/groupProperty.qml create mode 100644 tests/auto/quick/qquickbehaviors/data/groupProperty2.qml create mode 100644 tests/auto/quick/qquickbehaviors/data/groupedPropertyCrash.qml create mode 100644 tests/auto/quick/qquickbehaviors/data/loop.qml create mode 100644 tests/auto/quick/qquickbehaviors/data/nonSelecting2.qml create mode 100644 tests/auto/quick/qquickbehaviors/data/parent.qml create mode 100644 tests/auto/quick/qquickbehaviors/data/qtbug12295.qml create mode 100644 tests/auto/quick/qquickbehaviors/data/reassignedAnimation.qml create mode 100644 tests/auto/quick/qquickbehaviors/data/runningTrue.qml create mode 100644 tests/auto/quick/qquickbehaviors/data/scripttrigger.qml create mode 100644 tests/auto/quick/qquickbehaviors/data/simple.qml create mode 100644 tests/auto/quick/qquickbehaviors/data/startOnCompleted.qml create mode 100644 tests/auto/quick/qquickbehaviors/data/startup.qml create mode 100644 tests/auto/quick/qquickbehaviors/data/startup2.qml create mode 100644 tests/auto/quick/qquickbehaviors/data/valueType.qml create mode 100644 tests/auto/quick/qquickbehaviors/qquickbehaviors.pro create mode 100644 tests/auto/quick/qquickbehaviors/tst_qquickbehaviors.cpp create mode 100644 tests/auto/quick/qquickborderimage/data/colors-mirror.png create mode 100644 tests/auto/quick/qquickborderimage/data/colors-round-quotes.sci create mode 100644 tests/auto/quick/qquickborderimage/data/colors-round-remote.sci create mode 100644 tests/auto/quick/qquickborderimage/data/colors-round.sci create mode 100644 tests/auto/quick/qquickborderimage/data/colors.png create mode 100644 tests/auto/quick/qquickborderimage/data/heart200.png create mode 100644 tests/auto/quick/qquickborderimage/data/invalid.sci create mode 100644 tests/auto/quick/qquickborderimage/data/mirror.qml create mode 100644 tests/auto/quick/qquickborderimage/qquickborderimage.pro create mode 100644 tests/auto/quick/qquickborderimage/tst_qquickborderimage.cpp create mode 100644 tests/auto/quick/qquickcanvas/data/AnimationsWhileHidden.qml create mode 100644 tests/auto/quick/qquickcanvas/data/Headless.qml create mode 100644 tests/auto/quick/qquickcanvas/data/colors.png create mode 100644 tests/auto/quick/qquickcanvas/data/focus.qml create mode 100644 tests/auto/quick/qquickcanvas/data/window.qml create mode 100644 tests/auto/quick/qquickcanvas/qquickcanvas.pro create mode 100644 tests/auto/quick/qquickcanvas/tst_qquickcanvas.cpp create mode 100644 tests/auto/quick/qquickcanvasitem/data/anim-gr.gif create mode 100644 tests/auto/quick/qquickcanvasitem/data/anim-gr.png create mode 100644 tests/auto/quick/qquickcanvasitem/data/anim-poster-gr.png create mode 100644 tests/auto/quick/qquickcanvasitem/data/background.png create mode 100644 tests/auto/quick/qquickcanvasitem/data/broken.png create mode 100644 tests/auto/quick/qquickcanvasitem/data/ggrr-256x256.png create mode 100644 tests/auto/quick/qquickcanvasitem/data/green-16x16.png create mode 100644 tests/auto/quick/qquickcanvasitem/data/green-1x1.png create mode 100644 tests/auto/quick/qquickcanvasitem/data/green-256x256.png create mode 100644 tests/auto/quick/qquickcanvasitem/data/green-2x2.png create mode 100644 tests/auto/quick/qquickcanvasitem/data/green.png create mode 100644 tests/auto/quick/qquickcanvasitem/data/grgr-256x256.png create mode 100644 tests/auto/quick/qquickcanvasitem/data/red-16x16.png create mode 100644 tests/auto/quick/qquickcanvasitem/data/red.png create mode 100644 tests/auto/quick/qquickcanvasitem/data/redtransparent.png create mode 100644 tests/auto/quick/qquickcanvasitem/data/rgrg-256x256.png create mode 100644 tests/auto/quick/qquickcanvasitem/data/rrgg-256x256.png create mode 100644 tests/auto/quick/qquickcanvasitem/data/testhelper.js create mode 100644 tests/auto/quick/qquickcanvasitem/data/transparent.png create mode 100644 tests/auto/quick/qquickcanvasitem/data/transparent50.png create mode 100644 tests/auto/quick/qquickcanvasitem/data/tst_arc.qml create mode 100644 tests/auto/quick/qquickcanvasitem/data/tst_arcto.qml create mode 100644 tests/auto/quick/qquickcanvasitem/data/tst_canvas.qml create mode 100644 tests/auto/quick/qquickcanvasitem/data/tst_composite.qml create mode 100644 tests/auto/quick/qquickcanvasitem/data/tst_context.qml create mode 100644 tests/auto/quick/qquickcanvasitem/data/tst_drawimage.qml create mode 100644 tests/auto/quick/qquickcanvasitem/data/tst_fillStyle.qml create mode 100644 tests/auto/quick/qquickcanvasitem/data/tst_fillrect.qml create mode 100644 tests/auto/quick/qquickcanvasitem/data/tst_gradient.qml create mode 100644 tests/auto/quick/qquickcanvasitem/data/tst_line.qml create mode 100644 tests/auto/quick/qquickcanvasitem/data/tst_path.qml create mode 100644 tests/auto/quick/qquickcanvasitem/data/tst_pattern.qml create mode 100644 tests/auto/quick/qquickcanvasitem/data/tst_pixel.qml create mode 100644 tests/auto/quick/qquickcanvasitem/data/tst_shadow.qml create mode 100644 tests/auto/quick/qquickcanvasitem/data/tst_state.qml create mode 100644 tests/auto/quick/qquickcanvasitem/data/tst_strokeStyle.qml create mode 100644 tests/auto/quick/qquickcanvasitem/data/tst_text.qml create mode 100644 tests/auto/quick/qquickcanvasitem/data/tst_transform.qml create mode 100644 tests/auto/quick/qquickcanvasitem/data/yellow.png create mode 100644 tests/auto/quick/qquickcanvasitem/data/yellow75.png create mode 100644 tests/auto/quick/qquickcanvasitem/qquickcanvasitem.pro create mode 100644 tests/auto/quick/qquickcanvasitem/tst_qquickcanvasitem.cpp create mode 100644 tests/auto/quick/qquickdrag/qquickdrag.pro create mode 100644 tests/auto/quick/qquickdrag/tst_qquickdrag.cpp create mode 100644 tests/auto/quick/qquickdroparea/qquickdroparea.pro create mode 100644 tests/auto/quick/qquickdroparea/tst_qquickdroparea.cpp create mode 100644 tests/auto/quick/qquickflickable/data/disabled.qml create mode 100644 tests/auto/quick/qquickflickable/data/flickable01.qml create mode 100644 tests/auto/quick/qquickflickable/data/flickable02.qml create mode 100644 tests/auto/quick/qquickflickable/data/flickable03.qml create mode 100644 tests/auto/quick/qquickflickable/data/flickable04.qml create mode 100644 tests/auto/quick/qquickflickable/data/flickableqgraphicswidget.qml create mode 100644 tests/auto/quick/qquickflickable/data/margins.qml create mode 100644 tests/auto/quick/qquickflickable/data/nestedPressDelay.qml create mode 100644 tests/auto/quick/qquickflickable/data/resize.qml create mode 100644 tests/auto/quick/qquickflickable/data/wheel.qml create mode 100644 tests/auto/quick/qquickflickable/qquickflickable.pro create mode 100644 tests/auto/quick/qquickflickable/tst_qquickflickable.cpp create mode 100644 tests/auto/quick/qquickflipable/data/crash.qml create mode 100644 tests/auto/quick/qquickflipable/data/flipable-abort.qml create mode 100644 tests/auto/quick/qquickflipable/data/test-flipable.qml create mode 100644 tests/auto/quick/qquickflipable/qquickflipable.pro create mode 100644 tests/auto/quick/qquickflipable/tst_qquickflipable.cpp create mode 100644 tests/auto/quick/qquickfocusscope/data/canvasFocus.qml create mode 100644 tests/auto/quick/qquickfocusscope/data/chain.qml create mode 100644 tests/auto/quick/qquickfocusscope/data/forceActiveFocus.qml create mode 100644 tests/auto/quick/qquickfocusscope/data/forcefocus.qml create mode 100644 tests/auto/quick/qquickfocusscope/data/qtBug13380.qml create mode 100644 tests/auto/quick/qquickfocusscope/data/signalEmission.qml create mode 100644 tests/auto/quick/qquickfocusscope/data/test.qml create mode 100644 tests/auto/quick/qquickfocusscope/data/test2.qml create mode 100644 tests/auto/quick/qquickfocusscope/data/test3.qml create mode 100644 tests/auto/quick/qquickfocusscope/data/test4.qml create mode 100644 tests/auto/quick/qquickfocusscope/data/test5.qml create mode 100644 tests/auto/quick/qquickfocusscope/qquickfocusscope.pro create mode 100644 tests/auto/quick/qquickfocusscope/tst_qquickfocusscope.cpp create mode 100644 tests/auto/quick/qquickfontloader/data/daniel.ttf create mode 100644 tests/auto/quick/qquickfontloader/data/dummy.ttf create mode 100644 tests/auto/quick/qquickfontloader/data/qtbug-20268.qml create mode 100644 tests/auto/quick/qquickfontloader/data/tarzeau_ocr_a.ttf create mode 100644 tests/auto/quick/qquickfontloader/qquickfontloader.pro create mode 100644 tests/auto/quick/qquickfontloader/tst_qquickfontloader.cpp create mode 100644 tests/auto/quick/qquickgridview/data/ComponentView.qml create mode 100644 tests/auto/quick/qquickgridview/data/addTransitions.qml create mode 100644 tests/auto/quick/qquickgridview/data/asyncloader.qml create mode 100644 tests/auto/quick/qquickgridview/data/attachedSignals.qml create mode 100644 tests/auto/quick/qquickgridview/data/creationContext.qml create mode 100644 tests/auto/quick/qquickgridview/data/displaygrid.qml create mode 100644 tests/auto/quick/qquickgridview/data/footer.qml create mode 100644 tests/auto/quick/qquickgridview/data/gridview-enforcerange.qml create mode 100644 tests/auto/quick/qquickgridview/data/gridview-initCurrent.qml create mode 100644 tests/auto/quick/qquickgridview/data/gridview-noCurrent.qml create mode 100644 tests/auto/quick/qquickgridview/data/gridview1.qml create mode 100644 tests/auto/quick/qquickgridview/data/gridview2.qml create mode 100644 tests/auto/quick/qquickgridview/data/gridview3.qml create mode 100644 tests/auto/quick/qquickgridview/data/gridview4.qml create mode 100644 tests/auto/quick/qquickgridview/data/header.qml create mode 100644 tests/auto/quick/qquickgridview/data/manual-highlight.qml create mode 100644 tests/auto/quick/qquickgridview/data/margins.qml create mode 100644 tests/auto/quick/qquickgridview/data/mirroring.qml create mode 100644 tests/auto/quick/qquickgridview/data/moveTransitions.qml create mode 100644 tests/auto/quick/qquickgridview/data/multipleTransitions.qml create mode 100644 tests/auto/quick/qquickgridview/data/populateTransitions.qml create mode 100644 tests/auto/quick/qquickgridview/data/propertychangestest.qml create mode 100644 tests/auto/quick/qquickgridview/data/removeTransitions.qml create mode 100644 tests/auto/quick/qquickgridview/data/resizeview.qml create mode 100644 tests/auto/quick/qquickgridview/data/setindex.qml create mode 100644 tests/auto/quick/qquickgridview/data/snapOneRow.qml create mode 100644 tests/auto/quick/qquickgridview/data/snapToRow.qml create mode 100644 tests/auto/quick/qquickgridview/data/unaligned.qml create mode 100644 tests/auto/quick/qquickgridview/data/unrequestedItems.qml create mode 100644 tests/auto/quick/qquickgridview/qquickgridview.pro create mode 100644 tests/auto/quick/qquickgridview/tst_qquickgridview.cpp create mode 100644 tests/auto/quick/qquickimage/data/aspectratio.qml create mode 100644 tests/auto/quick/qquickimage/data/big.jpeg create mode 100644 tests/auto/quick/qquickimage/data/big256.png create mode 100644 tests/auto/quick/qquickimage/data/colors.png create mode 100644 tests/auto/quick/qquickimage/data/colors1.png create mode 100644 tests/auto/quick/qquickimage/data/green.png create mode 100644 tests/auto/quick/qquickimage/data/heart-win32.png create mode 100644 tests/auto/quick/qquickimage/data/heart.png create mode 100644 tests/auto/quick/qquickimage/data/heart.svg create mode 100644 tests/auto/quick/qquickimage/data/heart200-win32.png create mode 100644 tests/auto/quick/qquickimage/data/heart200.png create mode 100644 tests/auto/quick/qquickimage/data/htiling.qml create mode 100644 tests/auto/quick/qquickimage/data/mirror.qml create mode 100644 tests/auto/quick/qquickimage/data/nullpixmap.qml create mode 100644 tests/auto/quick/qquickimage/data/pattern.png create mode 100644 tests/auto/quick/qquickimage/data/qtbug_16389.qml create mode 100644 tests/auto/quick/qquickimage/data/qtbug_22125.qml create mode 100644 tests/auto/quick/qquickimage/data/rect.png create mode 100644 tests/auto/quick/qquickimage/data/sourceSize.qml create mode 100644 tests/auto/quick/qquickimage/data/vtiling.qml create mode 100644 tests/auto/quick/qquickimage/qquickimage.pro create mode 100644 tests/auto/quick/qquickimage/tst_qquickimage.cpp create mode 100644 tests/auto/quick/qquickitem/data/order.1.qml create mode 100644 tests/auto/quick/qquickitem/data/order.2.qml create mode 100644 tests/auto/quick/qquickitem/data/polishOnCompleted.qml create mode 100644 tests/auto/quick/qquickitem/qquickitem.pro create mode 100644 tests/auto/quick/qquickitem/tst_qquickitem.cpp create mode 100644 tests/auto/quick/qquickitem2/data/childrenProperty.qml create mode 100644 tests/auto/quick/qquickitem2/data/childrenRect.qml create mode 100644 tests/auto/quick/qquickitem2/data/childrenRectBug.qml create mode 100644 tests/auto/quick/qquickitem2/data/childrenRectBug2.qml create mode 100644 tests/auto/quick/qquickitem2/data/childrenRectBug3.qml create mode 100644 tests/auto/quick/qquickitem2/data/implicitsize.qml create mode 100644 tests/auto/quick/qquickitem2/data/keynavigationtest.qml create mode 100644 tests/auto/quick/qquickitem2/data/keynavigationtest_implicit.qml create mode 100644 tests/auto/quick/qquickitem2/data/keysim.qml create mode 100644 tests/auto/quick/qquickitem2/data/keyspriority.qml create mode 100644 tests/auto/quick/qquickitem2/data/keystest.qml create mode 100644 tests/auto/quick/qquickitem2/data/layoutmirroring.qml create mode 100644 tests/auto/quick/qquickitem2/data/mapCoordinates.qml create mode 100644 tests/auto/quick/qquickitem2/data/parentLoop.qml create mode 100644 tests/auto/quick/qquickitem2/data/propertychanges.qml create mode 100644 tests/auto/quick/qquickitem2/data/qtbug_16871.qml create mode 100644 tests/auto/quick/qquickitem2/data/resourcesProperty.qml create mode 100644 tests/auto/quick/qquickitem2/data/transformCrash.qml create mode 100644 tests/auto/quick/qquickitem2/data/visiblechildren.qml create mode 100644 tests/auto/quick/qquickitem2/qquickitem2.pro create mode 100644 tests/auto/quick/qquickitem2/tst_qquickitem.cpp create mode 100644 tests/auto/quick/qquickitemlayer/data/DisableLayer.qml create mode 100644 tests/auto/quick/qquickitemlayer/data/Effect.qml create mode 100644 tests/auto/quick/qquickitemlayer/data/Enabled.qml create mode 100644 tests/auto/quick/qquickitemlayer/data/ItemEffect.qml create mode 100644 tests/auto/quick/qquickitemlayer/data/Mipmap.qml create mode 100644 tests/auto/quick/qquickitemlayer/data/RectangleEffect.qml create mode 100644 tests/auto/quick/qquickitemlayer/data/SamplerNameChange.qml create mode 100644 tests/auto/quick/qquickitemlayer/data/Smooth.qml create mode 100644 tests/auto/quick/qquickitemlayer/data/SourceRect.qml create mode 100644 tests/auto/quick/qquickitemlayer/data/TextureProvider.qml create mode 100644 tests/auto/quick/qquickitemlayer/data/ToggleLayerAndEffect.qml create mode 100644 tests/auto/quick/qquickitemlayer/data/Visible.qml create mode 100644 tests/auto/quick/qquickitemlayer/data/ZOrder.qml create mode 100644 tests/auto/quick/qquickitemlayer/data/ZOrderChange.qml create mode 100644 tests/auto/quick/qquickitemlayer/qquickitemlayer.pro create mode 100644 tests/auto/quick/qquickitemlayer/tst_qquickitemlayer.cpp create mode 100644 tests/auto/quick/qquicklistview/data/ComponentView.qml create mode 100644 tests/auto/quick/qquicklistview/data/Page.qml create mode 100644 tests/auto/quick/qquicklistview/data/addTransitions.qml create mode 100644 tests/auto/quick/qquicklistview/data/asyncloader.qml create mode 100644 tests/auto/quick/qquicklistview/data/attachedSignals.qml create mode 100644 tests/auto/quick/qquicklistview/data/creationContext.qml create mode 100644 tests/auto/quick/qquicklistview/data/displaylist.qml create mode 100644 tests/auto/quick/qquicklistview/data/fillModelOnComponentCompleted.qml create mode 100644 tests/auto/quick/qquicklistview/data/footer.qml create mode 100644 tests/auto/quick/qquicklistview/data/header.qml create mode 100644 tests/auto/quick/qquicklistview/data/headerfooter.qml create mode 100644 tests/auto/quick/qquicklistview/data/itemlist.qml create mode 100644 tests/auto/quick/qquicklistview/data/listview-enforcerange-nohighlight.qml create mode 100644 tests/auto/quick/qquicklistview/data/listview-enforcerange.qml create mode 100644 tests/auto/quick/qquicklistview/data/listview-initCurrent.qml create mode 100644 tests/auto/quick/qquicklistview/data/listview-noCurrent.qml create mode 100644 tests/auto/quick/qquicklistview/data/listview-sections-package.qml create mode 100644 tests/auto/quick/qquicklistview/data/listview-sections.qml create mode 100644 tests/auto/quick/qquicklistview/data/listview-sections_delegate.qml create mode 100644 tests/auto/quick/qquicklistview/data/listviewtest-package.qml create mode 100644 tests/auto/quick/qquicklistview/data/listviewtest.qml create mode 100644 tests/auto/quick/qquicklistview/data/manual-highlight.qml create mode 100644 tests/auto/quick/qquicklistview/data/margins.qml create mode 100644 tests/auto/quick/qquicklistview/data/margins2.qml create mode 100644 tests/auto/quick/qquicklistview/data/moveTransitions.qml create mode 100644 tests/auto/quick/qquicklistview/data/multipleTransitions.qml create mode 100644 tests/auto/quick/qquicklistview/data/populateTransitions.qml create mode 100644 tests/auto/quick/qquicklistview/data/propertychangestest.qml create mode 100644 tests/auto/quick/qquicklistview/data/qtbug-21742.qml create mode 100644 tests/auto/quick/qquicklistview/data/qtbug14821.qml create mode 100644 tests/auto/quick/qquicklistview/data/qtbug16037.qml create mode 100644 tests/auto/quick/qquicklistview/data/removeTransitions.qml create mode 100644 tests/auto/quick/qquicklistview/data/resizeview.qml create mode 100644 tests/auto/quick/qquicklistview/data/rightToLeft.qml create mode 100644 tests/auto/quick/qquicklistview/data/sizelessthan1.qml create mode 100644 tests/auto/quick/qquicklistview/data/snapOneItem.qml create mode 100644 tests/auto/quick/qquicklistview/data/snapToItem.qml create mode 100644 tests/auto/quick/qquicklistview/data/strictlyenforcerange.qml create mode 100644 tests/auto/quick/qquicklistview/data/unrequestedItems.qml create mode 100644 tests/auto/quick/qquicklistview/incrementalmodel.cpp create mode 100644 tests/auto/quick/qquicklistview/incrementalmodel.h create mode 100644 tests/auto/quick/qquicklistview/qquicklistview.pro create mode 100644 tests/auto/quick/qquicklistview/tst_qquicklistview.cpp create mode 100644 tests/auto/quick/qquickloader/data/ActiveComponent.qml create mode 100644 tests/auto/quick/qquickloader/data/AnchoredLoader.qml create mode 100644 tests/auto/quick/qquickloader/data/BigComponent.qml create mode 100644 tests/auto/quick/qquickloader/data/BlueRect.qml create mode 100644 tests/auto/quick/qquickloader/data/CreationContextLoader.qml create mode 100644 tests/auto/quick/qquickloader/data/GraphicsWidget250x250.qml create mode 100644 tests/auto/quick/qquickloader/data/GreenRect.qml create mode 100644 tests/auto/quick/qquickloader/data/InitialPropertyValuesComponent.qml create mode 100644 tests/auto/quick/qquickloader/data/InvalidSourceComponent.qml create mode 100644 tests/auto/quick/qquickloader/data/NoResize.qml create mode 100644 tests/auto/quick/qquickloader/data/NoResizeGraphicsWidget.qml create mode 100644 tests/auto/quick/qquickloader/data/QTBUG_16928.qml create mode 100644 tests/auto/quick/qquickloader/data/QTBUG_17114.qml create mode 100644 tests/auto/quick/qquickloader/data/Rect120x60.qml create mode 100644 tests/auto/quick/qquickloader/data/SetSourceComponent.qml create mode 100644 tests/auto/quick/qquickloader/data/SizeGraphicsWidgetToLoader.qml create mode 100644 tests/auto/quick/qquickloader/data/SizeLoaderToGraphicsWidget.qml create mode 100644 tests/auto/quick/qquickloader/data/SizeToItem.qml create mode 100644 tests/auto/quick/qquickloader/data/SizeToLoader.qml create mode 100644 tests/auto/quick/qquickloader/data/VmeError.qml create mode 100644 tests/auto/quick/qquickloader/data/active.1.qml create mode 100644 tests/auto/quick/qquickloader/data/active.2.qml create mode 100644 tests/auto/quick/qquickloader/data/active.3.qml create mode 100644 tests/auto/quick/qquickloader/data/active.4.qml create mode 100644 tests/auto/quick/qquickloader/data/active.5.qml create mode 100644 tests/auto/quick/qquickloader/data/active.6.qml create mode 100644 tests/auto/quick/qquickloader/data/active.7.qml create mode 100644 tests/auto/quick/qquickloader/data/active.8.qml create mode 100644 tests/auto/quick/qquickloader/data/asynchronous.qml create mode 100644 tests/auto/quick/qquickloader/data/crash.qml create mode 100644 tests/auto/quick/qquickloader/data/creationContext.qml create mode 100644 tests/auto/quick/qquickloader/data/differentorigin.qml create mode 100644 tests/auto/quick/qquickloader/data/implicitSize.qml create mode 100644 tests/auto/quick/qquickloader/data/initialPropertyValues.1.qml create mode 100644 tests/auto/quick/qquickloader/data/initialPropertyValues.2.qml create mode 100644 tests/auto/quick/qquickloader/data/initialPropertyValues.3.qml create mode 100644 tests/auto/quick/qquickloader/data/initialPropertyValues.4.qml create mode 100644 tests/auto/quick/qquickloader/data/initialPropertyValues.5.qml create mode 100644 tests/auto/quick/qquickloader/data/initialPropertyValues.6.qml create mode 100644 tests/auto/quick/qquickloader/data/initialPropertyValues.7.qml create mode 100644 tests/auto/quick/qquickloader/data/initialPropertyValues.8.qml create mode 100644 tests/auto/quick/qquickloader/data/initialPropertyValues.binding.qml create mode 100644 tests/auto/quick/qquickloader/data/initialPropertyValues.error.1.qml create mode 100644 tests/auto/quick/qquickloader/data/initialPropertyValues.error.2.qml create mode 100644 tests/auto/quick/qquickloader/data/initialPropertyValues.error.3.qml create mode 100644 tests/auto/quick/qquickloader/data/initialPropertyValues.error.4.qml create mode 100644 tests/auto/quick/qquickloader/data/nonItem.qml create mode 100644 tests/auto/quick/qquickloader/data/parented.qml create mode 100644 tests/auto/quick/qquickloader/data/qmldir create mode 100644 tests/auto/quick/qquickloader/data/sameorigin-load.qml create mode 100644 tests/auto/quick/qquickloader/data/sameorigin.qml create mode 100644 tests/auto/quick/qquickloader/data/sizebound.qml create mode 100644 tests/auto/quick/qquickloader/data/vmeErrors.qml create mode 100644 tests/auto/quick/qquickloader/qquickloader.pro create mode 100644 tests/auto/quick/qquickloader/tst_qquickloader.cpp create mode 100644 tests/auto/quick/qquickmousearea/data/clickThrough.qml create mode 100644 tests/auto/quick/qquickmousearea/data/clickThrough2.qml create mode 100644 tests/auto/quick/qquickmousearea/data/clickandhold.qml create mode 100644 tests/auto/quick/qquickmousearea/data/clicktwice.qml create mode 100644 tests/auto/quick/qquickmousearea/data/doubleclick.qml create mode 100644 tests/auto/quick/qquickmousearea/data/dragging.qml create mode 100644 tests/auto/quick/qquickmousearea/data/dragproperties.qml create mode 100644 tests/auto/quick/qquickmousearea/data/dragreset.qml create mode 100644 tests/auto/quick/qquickmousearea/data/hoverPosition.qml create mode 100644 tests/auto/quick/qquickmousearea/data/hoverPropagation.qml create mode 100644 tests/auto/quick/qquickmousearea/data/hoverVisible.qml create mode 100644 tests/auto/quick/qquickmousearea/data/noclickandhold.qml create mode 100644 tests/auto/quick/qquickmousearea/data/pressedCanceled.qml create mode 100644 tests/auto/quick/qquickmousearea/data/pressedOrdering.qml create mode 100644 tests/auto/quick/qquickmousearea/data/preventstealing.qml create mode 100644 tests/auto/quick/qquickmousearea/data/rejectEvent.qml create mode 100644 tests/auto/quick/qquickmousearea/data/updateMousePosOnClick.qml create mode 100644 tests/auto/quick/qquickmousearea/data/updateMousePosOnResize.qml create mode 100644 tests/auto/quick/qquickmousearea/qquickmousearea.pro create mode 100644 tests/auto/quick/qquickmousearea/tst_qquickmousearea.cpp create mode 100644 tests/auto/quick/qquickmultipointtoucharea/data/basic.qml create mode 100644 tests/auto/quick/qquickmultipointtoucharea/data/inFlickable.qml create mode 100644 tests/auto/quick/qquickmultipointtoucharea/data/nested.qml create mode 100644 tests/auto/quick/qquickmultipointtoucharea/data/nonOverlapping.qml create mode 100644 tests/auto/quick/qquickmultipointtoucharea/data/properties.qml create mode 100644 tests/auto/quick/qquickmultipointtoucharea/data/signalTest.qml create mode 100644 tests/auto/quick/qquickmultipointtoucharea/qquickmultipointtoucharea.pro create mode 100644 tests/auto/quick/qquickmultipointtoucharea/tst_qquickmultipointtoucharea.cpp create mode 100644 tests/auto/quick/qquickpath/data/arc.qml create mode 100644 tests/auto/quick/qquickpath/data/closedcurve.qml create mode 100644 tests/auto/quick/qquickpath/data/curve.qml create mode 100644 tests/auto/quick/qquickpath/data/svg.qml create mode 100644 tests/auto/quick/qquickpath/qquickpath.pro create mode 100644 tests/auto/quick/qquickpath/tst_qquickpath.cpp create mode 100644 tests/auto/quick/qquickpathview/data/ComponentView.qml create mode 100644 tests/auto/quick/qquickpathview/data/asyncloader.qml create mode 100644 tests/auto/quick/qquickpathview/data/closedPath.qml create mode 100644 tests/auto/quick/qquickpathview/data/creationContext.qml create mode 100644 tests/auto/quick/qquickpathview/data/datamodel.qml create mode 100644 tests/auto/quick/qquickpathview/data/displaypath.qml create mode 100644 tests/auto/quick/qquickpathview/data/dragpath.qml create mode 100644 tests/auto/quick/qquickpathview/data/emptymodel.qml create mode 100644 tests/auto/quick/qquickpathview/data/missingPercent.qml create mode 100644 tests/auto/quick/qquickpathview/data/openPath.qml create mode 100644 tests/auto/quick/qquickpathview/data/pathUpdate.qml create mode 100644 tests/auto/quick/qquickpathview/data/pathUpdateOnStartChanged.qml create mode 100644 tests/auto/quick/qquickpathview/data/pathline.qml create mode 100644 tests/auto/quick/qquickpathview/data/pathtest.qml create mode 100644 tests/auto/quick/qquickpathview/data/pathview0.qml create mode 100644 tests/auto/quick/qquickpathview/data/pathview1.qml create mode 100644 tests/auto/quick/qquickpathview/data/pathview2.qml create mode 100644 tests/auto/quick/qquickpathview/data/pathview3.qml create mode 100644 tests/auto/quick/qquickpathview/data/pathview_package.qml create mode 100644 tests/auto/quick/qquickpathview/data/propertychanges.qml create mode 100644 tests/auto/quick/qquickpathview/data/treemodel.qml create mode 100644 tests/auto/quick/qquickpathview/data/undefinedpath.qml create mode 100644 tests/auto/quick/qquickpathview/data/vdm.qml create mode 100644 tests/auto/quick/qquickpathview/qquickpathview.pro create mode 100644 tests/auto/quick/qquickpathview/tst_qquickpathview.cpp create mode 100644 tests/auto/quick/qquickpincharea/data/pinchproperties.qml create mode 100644 tests/auto/quick/qquickpincharea/qquickpincharea.pro create mode 100644 tests/auto/quick/qquickpincharea/tst_qquickpincharea.cpp create mode 100644 tests/auto/quick/qquickpixmapcache/data/exists.png create mode 100644 tests/auto/quick/qquickpixmapcache/data/exists1.png create mode 100644 tests/auto/quick/qquickpixmapcache/data/exists2.png create mode 100644 tests/auto/quick/qquickpixmapcache/data/http/exists.png create mode 100644 tests/auto/quick/qquickpixmapcache/data/http/exists1.png create mode 100644 tests/auto/quick/qquickpixmapcache/data/http/exists2.png create mode 100644 tests/auto/quick/qquickpixmapcache/data/http/exists3.png create mode 100644 tests/auto/quick/qquickpixmapcache/data/http/exists4.png create mode 100644 tests/auto/quick/qquickpixmapcache/data/http/exists5.png create mode 100644 tests/auto/quick/qquickpixmapcache/data/http/exists6.png create mode 100644 tests/auto/quick/qquickpixmapcache/data/http/exists7.png create mode 100644 tests/auto/quick/qquickpixmapcache/data/http/exists8.png create mode 100644 tests/auto/quick/qquickpixmapcache/data/massive.png create mode 100644 tests/auto/quick/qquickpixmapcache/qquickpixmapcache.pro create mode 100644 tests/auto/quick/qquickpixmapcache/tst_qquickpixmapcache.cpp create mode 100644 tests/auto/quick/qquickpositioners/data/allInvisible.qml create mode 100644 tests/auto/quick/qquickpositioners/data/attachedproperties-column.qml create mode 100644 tests/auto/quick/qquickpositioners/data/attachedproperties-dynamic.qml create mode 100644 tests/auto/quick/qquickpositioners/data/attachedproperties-flow.qml create mode 100644 tests/auto/quick/qquickpositioners/data/attachedproperties-grid.qml create mode 100644 tests/auto/quick/qquickpositioners/data/attachedproperties-row.qml create mode 100644 tests/auto/quick/qquickpositioners/data/flow-testimplicitsize.qml create mode 100644 tests/auto/quick/qquickpositioners/data/flowtest-toptobottom.qml create mode 100644 tests/auto/quick/qquickpositioners/data/flowtest.qml create mode 100644 tests/auto/quick/qquickpositioners/data/grid-animated.qml create mode 100644 tests/auto/quick/qquickpositioners/data/grid-row-column-spacing.qml create mode 100644 tests/auto/quick/qquickpositioners/data/grid-spacing.qml create mode 100644 tests/auto/quick/qquickpositioners/data/grid-toptobottom.qml create mode 100644 tests/auto/quick/qquickpositioners/data/gridtest.qml create mode 100644 tests/auto/quick/qquickpositioners/data/gridzerocolumns.qml create mode 100644 tests/auto/quick/qquickpositioners/data/horizontal-animated-disabled.qml create mode 100644 tests/auto/quick/qquickpositioners/data/horizontal-animated.qml create mode 100644 tests/auto/quick/qquickpositioners/data/horizontal-spacing.qml create mode 100644 tests/auto/quick/qquickpositioners/data/horizontal.qml create mode 100644 tests/auto/quick/qquickpositioners/data/propertychangestest.qml create mode 100644 tests/auto/quick/qquickpositioners/data/rectangleComponent.qml create mode 100644 tests/auto/quick/qquickpositioners/data/repeatertest.qml create mode 100644 tests/auto/quick/qquickpositioners/data/vertical-animated.qml create mode 100644 tests/auto/quick/qquickpositioners/data/vertical-spacing.qml create mode 100644 tests/auto/quick/qquickpositioners/data/vertical.qml create mode 100644 tests/auto/quick/qquickpositioners/qquickpositioners.pro create mode 100644 tests/auto/quick/qquickpositioners/tst_qquickpositioners.cpp create mode 100644 tests/auto/quick/qquickrepeater/data/asyncloader.qml create mode 100644 tests/auto/quick/qquickrepeater/data/initparent.qml create mode 100644 tests/auto/quick/qquickrepeater/data/intmodel.qml create mode 100644 tests/auto/quick/qquickrepeater/data/itemlist.qml create mode 100644 tests/auto/quick/qquickrepeater/data/modelChanged.qml create mode 100644 tests/auto/quick/qquickrepeater/data/objlist.qml create mode 100644 tests/auto/quick/qquickrepeater/data/properties.qml create mode 100644 tests/auto/quick/qquickrepeater/data/repeater1.qml create mode 100644 tests/auto/quick/qquickrepeater/data/repeater2.qml create mode 100644 tests/auto/quick/qquickrepeater/qquickrepeater.pro create mode 100644 tests/auto/quick/qquickrepeater/tst_qquickrepeater.cpp create mode 100644 tests/auto/quick/qquickscreen/data/screen.qml create mode 100644 tests/auto/quick/qquickscreen/qquickscreen.pro create mode 100644 tests/auto/quick/qquickscreen/tst_qquickscreen.cpp create mode 100644 tests/auto/quick/qquickshadereffect/qquickshadereffect.pro create mode 100644 tests/auto/quick/qquickshadereffect/tst_qquickshadereffect.cpp create mode 100644 tests/auto/quick/qquicksmoothedanimation/data/deleteOnUpdate.qml create mode 100644 tests/auto/quick/qquicksmoothedanimation/data/simpleanimation.qml create mode 100644 tests/auto/quick/qquicksmoothedanimation/data/smoothedanimation1.qml create mode 100644 tests/auto/quick/qquicksmoothedanimation/data/smoothedanimation2.qml create mode 100644 tests/auto/quick/qquicksmoothedanimation/data/smoothedanimation3.qml create mode 100644 tests/auto/quick/qquicksmoothedanimation/data/smoothedanimationBehavior.qml create mode 100644 tests/auto/quick/qquicksmoothedanimation/data/smoothedanimationValueSource.qml create mode 100644 tests/auto/quick/qquicksmoothedanimation/qquicksmoothedanimation.pro create mode 100644 tests/auto/quick/qquicksmoothedanimation/tst_qquicksmoothedanimation.cpp create mode 100644 tests/auto/quick/qquickspringanimation/data/springanimation1.qml create mode 100644 tests/auto/quick/qquickspringanimation/data/springanimation2.qml create mode 100644 tests/auto/quick/qquickspringanimation/data/springanimation3.qml create mode 100644 tests/auto/quick/qquickspringanimation/qquickspringanimation.pro create mode 100644 tests/auto/quick/qquickspringanimation/tst_qquickspringanimation.cpp create mode 100644 tests/auto/quick/qquickspriteimage/data/advance.qml create mode 100644 tests/auto/quick/qquickspriteimage/data/basic.qml create mode 100644 tests/auto/quick/qquickspriteimage/data/squarefacesprite.png create mode 100644 tests/auto/quick/qquickspriteimage/qquickspriteimage.pro create mode 100644 tests/auto/quick/qquickspriteimage/tst_qquickspriteimage.cpp create mode 100644 tests/auto/quick/qquickstates/data/ExtendedRectangle.qml create mode 100644 tests/auto/quick/qquickstates/data/Implementation/MyType.qml create mode 100644 tests/auto/quick/qquickstates/data/Implementation/images/qt-logo.png create mode 100644 tests/auto/quick/qquickstates/data/QTBUG-14830.qml create mode 100644 tests/auto/quick/qquickstates/data/anchorChanges1.qml create mode 100644 tests/auto/quick/qquickstates/data/anchorChanges2.qml create mode 100644 tests/auto/quick/qquickstates/data/anchorChanges3.qml create mode 100644 tests/auto/quick/qquickstates/data/anchorChanges4.qml create mode 100644 tests/auto/quick/qquickstates/data/anchorChanges5.qml create mode 100644 tests/auto/quick/qquickstates/data/anchorChangesCrash.qml create mode 100644 tests/auto/quick/qquickstates/data/anchorRewindBug.qml create mode 100644 tests/auto/quick/qquickstates/data/anchorRewindBug2.qml create mode 100644 tests/auto/quick/qquickstates/data/attachedPropertyChanges.qml create mode 100644 tests/auto/quick/qquickstates/data/autoStateAtStartupRestoreBug.qml create mode 100644 tests/auto/quick/qquickstates/data/avoidFastForward.qml create mode 100644 tests/auto/quick/qquickstates/data/basicBinding.qml create mode 100644 tests/auto/quick/qquickstates/data/basicBinding2.qml create mode 100644 tests/auto/quick/qquickstates/data/basicBinding3.qml create mode 100644 tests/auto/quick/qquickstates/data/basicBinding4.qml create mode 100644 tests/auto/quick/qquickstates/data/basicChanges.qml create mode 100644 tests/auto/quick/qquickstates/data/basicChanges2.qml create mode 100644 tests/auto/quick/qquickstates/data/basicChanges3.qml create mode 100644 tests/auto/quick/qquickstates/data/basicChanges4.qml create mode 100644 tests/auto/quick/qquickstates/data/basicExtension.qml create mode 100644 tests/auto/quick/qquickstates/data/deleting.qml create mode 100644 tests/auto/quick/qquickstates/data/deletingState.qml create mode 100644 tests/auto/quick/qquickstates/data/editProperties.qml create mode 100644 tests/auto/quick/qquickstates/data/explicit.qml create mode 100644 tests/auto/quick/qquickstates/data/extendsBug.qml create mode 100644 tests/auto/quick/qquickstates/data/fakeExtension.qml create mode 100644 tests/auto/quick/qquickstates/data/illegalObj.qml create mode 100644 tests/auto/quick/qquickstates/data/illegalTempState.qml create mode 100644 tests/auto/quick/qquickstates/data/image.png create mode 100644 tests/auto/quick/qquickstates/data/legalTempState.qml create mode 100644 tests/auto/quick/qquickstates/data/nonExistantProp.qml create mode 100644 tests/auto/quick/qquickstates/data/parentChange1.qml create mode 100644 tests/auto/quick/qquickstates/data/parentChange2.qml create mode 100644 tests/auto/quick/qquickstates/data/parentChange3.qml create mode 100644 tests/auto/quick/qquickstates/data/parentChange4.qml create mode 100644 tests/auto/quick/qquickstates/data/parentChange5.qml create mode 100644 tests/auto/quick/qquickstates/data/parentChange6.qml create mode 100644 tests/auto/quick/qquickstates/data/propertyErrors.qml create mode 100644 tests/auto/quick/qquickstates/data/reset.qml create mode 100644 tests/auto/quick/qquickstates/data/restoreEntryValues.qml create mode 100644 tests/auto/quick/qquickstates/data/returnToBase.qml create mode 100644 tests/auto/quick/qquickstates/data/revertListBug.qml create mode 100644 tests/auto/quick/qquickstates/data/script.qml create mode 100644 tests/auto/quick/qquickstates/data/signalOverride.qml create mode 100644 tests/auto/quick/qquickstates/data/signalOverride2.qml create mode 100644 tests/auto/quick/qquickstates/data/signalOverrideCrash.qml create mode 100644 tests/auto/quick/qquickstates/data/signalOverrideCrash2.qml create mode 100644 tests/auto/quick/qquickstates/data/signalOverrideCrash3.qml create mode 100644 tests/auto/quick/qquickstates/data/unnamedWhen.qml create mode 100644 tests/auto/quick/qquickstates/data/urlResolution.qml create mode 100644 tests/auto/quick/qquickstates/data/whenOrdering.qml create mode 100644 tests/auto/quick/qquickstates/qquickstates.pro create mode 100644 tests/auto/quick/qquickstates/tst_qquickstates.cpp create mode 100644 tests/auto/quick/qquickstyledtext/qquickstyledtext.pro create mode 100644 tests/auto/quick/qquickstyledtext/tst_qquickstyledtext.cpp create mode 100644 tests/auto/quick/qquicksystempalette/qquicksystempalette.pro create mode 100644 tests/auto/quick/qquicksystempalette/tst_qquicksystempalette.cpp create mode 100644 tests/auto/quick/qquicktext/data/alignments.qml create mode 100644 tests/auto/quick/qquicktext/data/alignments_cb.png create mode 100644 tests/auto/quick/qquicktext/data/alignments_cc.png create mode 100644 tests/auto/quick/qquicktext/data/alignments_ct.png create mode 100644 tests/auto/quick/qquicktext/data/alignments_lb.png create mode 100644 tests/auto/quick/qquicktext/data/alignments_lc.png create mode 100644 tests/auto/quick/qquicktext/data/alignments_lt.png create mode 100644 tests/auto/quick/qquicktext/data/alignments_rb.png create mode 100644 tests/auto/quick/qquicktext/data/alignments_rc.png create mode 100644 tests/auto/quick/qquicktext/data/alignments_rt.png create mode 100644 tests/auto/quick/qquicktext/data/embeddedImagesLocal.qml create mode 100644 tests/auto/quick/qquicktext/data/embeddedImagesLocalError.qml create mode 100644 tests/auto/quick/qquicktext/data/embeddedImagesLocalRelative.qml create mode 100644 tests/auto/quick/qquicktext/data/embeddedImagesRemote.qml create mode 100644 tests/auto/quick/qquicktext/data/embeddedImagesRemoteError.qml create mode 100644 tests/auto/quick/qquicktext/data/embeddedImagesRemoteRelative.qml create mode 100644 tests/auto/quick/qquicktext/data/fontSizeMode.qml create mode 100644 tests/auto/quick/qquicktext/data/horizontalAlignment_RightToLeft.qml create mode 100644 tests/auto/quick/qquicktext/data/http/exists.png create mode 100644 tests/auto/quick/qquicktext/data/images/face-sad.png create mode 100644 tests/auto/quick/qquicktext/data/images/heart200.png create mode 100644 tests/auto/quick/qquicktext/data/images/starfish_2.png create mode 100644 tests/auto/quick/qquicktext/data/imgTagsElide.qml create mode 100644 tests/auto/quick/qquicktext/data/imgTagsUpdates.qml create mode 100644 tests/auto/quick/qquicktext/data/lineCount.qml create mode 100644 tests/auto/quick/qquicktext/data/lineHeight.qml create mode 100644 tests/auto/quick/qquicktext/data/lineLayout.qml create mode 100644 tests/auto/quick/qquicktext/data/multilengthStrings.qml create mode 100644 tests/auto/quick/qquicktext/data/multilengthStringsWrapped.qml create mode 100644 tests/auto/quick/qquicktext/data/multilineelide.qml create mode 100644 tests/auto/quick/qquicktext/data/qtbug_14734.qml create mode 100644 tests/auto/quick/qquicktext/data/rotated.qml create mode 100644 tests/auto/quick/qquicktext/qquicktext.pro create mode 100644 tests/auto/quick/qquicktext/tst_qquicktext.cpp create mode 100644 tests/auto/quick/qquicktextedit/data/Cursor.qml create mode 100644 tests/auto/quick/qquicktextedit/data/CursorRect.qml create mode 100644 tests/auto/quick/qquicktextedit/data/alignments.qml create mode 100644 tests/auto/quick/qquicktextedit/data/alignments_cb.png create mode 100644 tests/auto/quick/qquicktextedit/data/alignments_cc.png create mode 100644 tests/auto/quick/qquicktextedit/data/alignments_ct.png create mode 100644 tests/auto/quick/qquicktextedit/data/alignments_lb.png create mode 100644 tests/auto/quick/qquicktextedit/data/alignments_lc.png create mode 100644 tests/auto/quick/qquicktextedit/data/alignments_lt.png create mode 100644 tests/auto/quick/qquicktextedit/data/alignments_rb.png create mode 100644 tests/auto/quick/qquicktextedit/data/alignments_rc.png create mode 100644 tests/auto/quick/qquicktextedit/data/alignments_rt.png create mode 100644 tests/auto/quick/qquicktextedit/data/cursorTest.qml create mode 100644 tests/auto/quick/qquicktextedit/data/cursorTestExternal.qml create mode 100644 tests/auto/quick/qquicktextedit/data/cursorTestInline.qml create mode 100644 tests/auto/quick/qquicktextedit/data/cursorVisible.qml create mode 100644 tests/auto/quick/qquicktextedit/data/embeddedImagesLocal.qml create mode 100644 tests/auto/quick/qquicktextedit/data/embeddedImagesLocalError.qml create mode 100644 tests/auto/quick/qquicktextedit/data/embeddedImagesLocalRelative.qml create mode 100644 tests/auto/quick/qquicktextedit/data/embeddedImagesRemote.qml create mode 100644 tests/auto/quick/qquicktextedit/data/embeddedImagesRemoteError.qml create mode 100644 tests/auto/quick/qquicktextedit/data/embeddedImagesRemoteRelative.qml create mode 100644 tests/auto/quick/qquicktextedit/data/geometrySignals.qml create mode 100644 tests/auto/quick/qquicktextedit/data/horizontalAlignment_RightToLeft.qml create mode 100644 tests/auto/quick/qquicktextedit/data/http/ErrItem.qml create mode 100644 tests/auto/quick/qquicktextedit/data/http/NormItem.qml create mode 100644 tests/auto/quick/qquicktextedit/data/http/cursorHttpTest.qml create mode 100644 tests/auto/quick/qquicktextedit/data/http/cursorHttpTestFail1.qml create mode 100644 tests/auto/quick/qquicktextedit/data/http/cursorHttpTestFail2.qml create mode 100644 tests/auto/quick/qquicktextedit/data/http/cursorHttpTestPass.qml create mode 100644 tests/auto/quick/qquicktextedit/data/http/exists.png create mode 100644 tests/auto/quick/qquicktextedit/data/http/qmldir create mode 100644 tests/auto/quick/qquicktextedit/data/httpfail/FailItem.qml create mode 100644 tests/auto/quick/qquicktextedit/data/httpslow/WaitItem.qml create mode 100644 tests/auto/quick/qquicktextedit/data/inputContext.qml create mode 100644 tests/auto/quick/qquicktextedit/data/inputMethodEvent.qml create mode 100644 tests/auto/quick/qquicktextedit/data/inputmethodhints.qml create mode 100644 tests/auto/quick/qquicktextedit/data/linkActivated.qml create mode 100644 tests/auto/quick/qquicktextedit/data/mouseselection_default.qml create mode 100644 tests/auto/quick/qquicktextedit/data/mouseselection_false.qml create mode 100644 tests/auto/quick/qquicktextedit/data/mouseselection_false_words.qml create mode 100644 tests/auto/quick/qquicktextedit/data/mouseselection_true.qml create mode 100644 tests/auto/quick/qquicktextedit/data/mouseselection_true_words.qml create mode 100644 tests/auto/quick/qquicktextedit/data/mouseselectionmode_characters.qml create mode 100644 tests/auto/quick/qquicktextedit/data/mouseselectionmode_default.qml create mode 100644 tests/auto/quick/qquicktextedit/data/mouseselectionmode_words.qml create mode 100644 tests/auto/quick/qquicktextedit/data/navigation.qml create mode 100644 tests/auto/quick/qquicktextedit/data/openInputPanel.qml create mode 100644 tests/auto/quick/qquicktextedit/data/persistentSelection.qml create mode 100644 tests/auto/quick/qquicktextedit/data/positionAt.qml create mode 100644 tests/auto/quick/qquicktextedit/data/qtbug-22058.qml create mode 100644 tests/auto/quick/qquicktextedit/data/readOnly.qml create mode 100644 tests/auto/quick/qquicktextedit/qquicktextedit.pro create mode 100644 tests/auto/quick/qquicktextedit/tst_qquicktextedit.cpp create mode 100644 tests/auto/quick/qquicktextinput/data/Cursor.qml create mode 100644 tests/auto/quick/qquicktextinput/data/cursorTest.qml create mode 100644 tests/auto/quick/qquicktextinput/data/cursorTestExternal.qml create mode 100644 tests/auto/quick/qquicktextinput/data/cursorTestInline.qml create mode 100644 tests/auto/quick/qquicktextinput/data/cursorVisible.qml create mode 100644 tests/auto/quick/qquicktextinput/data/echoMode.qml create mode 100644 tests/auto/quick/qquicktextinput/data/geometrySignals.qml create mode 100644 tests/auto/quick/qquicktextinput/data/halign_center.png create mode 100644 tests/auto/quick/qquicktextinput/data/halign_left.png create mode 100644 tests/auto/quick/qquicktextinput/data/halign_right.png create mode 100644 tests/auto/quick/qquicktextinput/data/horizontalAlignment.qml create mode 100644 tests/auto/quick/qquicktextinput/data/horizontalAlignment_RightToLeft.qml create mode 100644 tests/auto/quick/qquicktextinput/data/inputContext.qml create mode 100644 tests/auto/quick/qquicktextinput/data/inputMethodEvent.qml create mode 100644 tests/auto/quick/qquicktextinput/data/inputmethods.qml create mode 100644 tests/auto/quick/qquicktextinput/data/masks.qml create mode 100644 tests/auto/quick/qquicktextinput/data/maxLength.qml create mode 100644 tests/auto/quick/qquicktextinput/data/mouseselection_true.qml create mode 100644 tests/auto/quick/qquicktextinput/data/mouseselectionmode_characters.qml create mode 100644 tests/auto/quick/qquicktextinput/data/mouseselectionmode_default.qml create mode 100644 tests/auto/quick/qquicktextinput/data/mouseselectionmode_words.qml create mode 100644 tests/auto/quick/qquicktextinput/data/navigation.qml create mode 100644 tests/auto/quick/qquicktextinput/data/negativeDimensions.qml create mode 100644 tests/auto/quick/qquicktextinput/data/openInputPanel.qml create mode 100644 tests/auto/quick/qquicktextinput/data/persistentSelection.qml create mode 100644 tests/auto/quick/qquicktextinput/data/positionAt.qml create mode 100644 tests/auto/quick/qquicktextinput/data/preeditAutoScroll.qml create mode 100644 tests/auto/quick/qquicktextinput/data/qtbug-19956double.qml create mode 100644 tests/auto/quick/qquicktextinput/data/qtbug-19956int.qml create mode 100644 tests/auto/quick/qquicktextinput/data/qtbug-19956regexp.qml create mode 100644 tests/auto/quick/qquicktextinput/data/readOnly.qml create mode 100644 tests/auto/quick/qquicktextinput/data/validators.qml create mode 100644 tests/auto/quick/qquicktextinput/qquicktextinput.pro create mode 100644 tests/auto/quick/qquicktextinput/tst_qquicktextinput.cpp create mode 100644 tests/auto/quick/qquicktimer/qquicktimer.pro create mode 100644 tests/auto/quick/qquicktimer/tst_qquicktimer.cpp create mode 100644 tests/auto/quick/qquickview/data/error1.qml create mode 100644 tests/auto/quick/qquickview/data/resizemodeitem.qml create mode 100644 tests/auto/quick/qquickview/qquickview.pro create mode 100644 tests/auto/quick/qquickview/tst_qquickview.cpp create mode 100644 tests/auto/quick/qquickvisualdatamodel/data/create.qml create mode 100644 tests/auto/quick/qquickvisualdatamodel/data/datalist-package.qml create mode 100644 tests/auto/quick/qquickvisualdatamodel/data/datalist.qml create mode 100644 tests/auto/quick/qquickvisualdatamodel/data/groups-invalid.qml create mode 100644 tests/auto/quick/qquickvisualdatamodel/data/groups-package.qml create mode 100644 tests/auto/quick/qquickvisualdatamodel/data/groups.qml create mode 100644 tests/auto/quick/qquickvisualdatamodel/data/itemsDestroyed_listView.qml create mode 100644 tests/auto/quick/qquickvisualdatamodel/data/itemsDestroyed_package.qml create mode 100644 tests/auto/quick/qquickvisualdatamodel/data/itemsDestroyed_pathView.qml create mode 100644 tests/auto/quick/qquickvisualdatamodel/data/itemsDestroyed_repeater.qml create mode 100644 tests/auto/quick/qquickvisualdatamodel/data/listmodelproperties-package.qml create mode 100644 tests/auto/quick/qquickvisualdatamodel/data/listmodelproperties.qml create mode 100644 tests/auto/quick/qquickvisualdatamodel/data/modelproperties.qml create mode 100644 tests/auto/quick/qquickvisualdatamodel/data/modelproperties2.qml create mode 100644 tests/auto/quick/qquickvisualdatamodel/data/multipleroleproperties-package.qml create mode 100644 tests/auto/quick/qquickvisualdatamodel/data/multipleroleproperties.qml create mode 100644 tests/auto/quick/qquickvisualdatamodel/data/objectlist.qml create mode 100644 tests/auto/quick/qquickvisualdatamodel/data/objectlistproperties-package.qml create mode 100644 tests/auto/quick/qquickvisualdatamodel/data/objectlistproperties.qml create mode 100644 tests/auto/quick/qquickvisualdatamodel/data/onChanged.qml create mode 100644 tests/auto/quick/qquickvisualdatamodel/data/packageView.qml create mode 100644 tests/auto/quick/qquickvisualdatamodel/data/singlerole1.qml create mode 100644 tests/auto/quick/qquickvisualdatamodel/data/singlerole2.qml create mode 100644 tests/auto/quick/qquickvisualdatamodel/data/singleroleproperties-package.qml create mode 100644 tests/auto/quick/qquickvisualdatamodel/data/singleroleproperties.qml create mode 100644 tests/auto/quick/qquickvisualdatamodel/data/stringlistproperties-package.qml create mode 100644 tests/auto/quick/qquickvisualdatamodel/data/stringlistproperties.qml create mode 100644 tests/auto/quick/qquickvisualdatamodel/data/visualdatamodel.qml create mode 100644 tests/auto/quick/qquickvisualdatamodel/qquickvisualdatamodel.pro create mode 100644 tests/auto/quick/qquickvisualdatamodel/tst_qquickvisualdatamodel.cpp create mode 100644 tests/auto/quick/qquickxmllistmodel/data/empty.xml create mode 100644 tests/auto/quick/qquickxmllistmodel/data/get.qml create mode 100644 tests/auto/quick/qquickxmllistmodel/data/model.qml create mode 100644 tests/auto/quick/qquickxmllistmodel/data/model.xml create mode 100644 tests/auto/quick/qquickxmllistmodel/data/model2.xml create mode 100644 tests/auto/quick/qquickxmllistmodel/data/propertychanges.qml create mode 100644 tests/auto/quick/qquickxmllistmodel/data/recipes.qml create mode 100644 tests/auto/quick/qquickxmllistmodel/data/recipes.xml create mode 100644 tests/auto/quick/qquickxmllistmodel/data/roleCrash.qml create mode 100644 tests/auto/quick/qquickxmllistmodel/data/roleErrors.qml create mode 100644 tests/auto/quick/qquickxmllistmodel/data/roleKeys.qml create mode 100644 tests/auto/quick/qquickxmllistmodel/data/testtypes.qml create mode 100644 tests/auto/quick/qquickxmllistmodel/data/unique.qml create mode 100644 tests/auto/quick/qquickxmllistmodel/qquickxmllistmodel.pro create mode 100644 tests/auto/quick/qquickxmllistmodel/tst_qquickxmllistmodel.cpp create mode 100644 tests/auto/quick/quick.pro create mode 100644 tests/auto/quick/rendernode/data/MessUpState.qml create mode 100644 tests/auto/quick/rendernode/data/RenderOrder.qml create mode 100644 tests/auto/quick/rendernode/rendernode.pro create mode 100644 tests/auto/quick/rendernode/tst_rendernode.cpp create mode 100644 tests/auto/quick/shared/util.pri create mode 100644 tests/auto/quick/shared/viewtestutil.cpp create mode 100644 tests/auto/quick/shared/viewtestutil.h create mode 100644 tests/auto/quick/shared/visualtestutil.cpp create mode 100644 tests/auto/quick/shared/visualtestutil.h delete mode 100644 tests/benchmarks/declarative/animation/animation.pro delete mode 100644 tests/benchmarks/declarative/animation/data/animation.qml delete mode 100644 tests/benchmarks/declarative/animation/tst_animation.cpp delete mode 100644 tests/benchmarks/declarative/binding/binding.pro delete mode 100644 tests/benchmarks/declarative/binding/data/creation.txt delete mode 100644 tests/benchmarks/declarative/binding/data/idproperty.txt delete mode 100644 tests/benchmarks/declarative/binding/data/localproperty.txt delete mode 100644 tests/benchmarks/declarative/binding/data/objectproperty.txt delete mode 100644 tests/benchmarks/declarative/binding/testtypes.cpp delete mode 100644 tests/benchmarks/declarative/binding/testtypes.h delete mode 100644 tests/benchmarks/declarative/binding/tst_binding.cpp delete mode 100644 tests/benchmarks/declarative/compilation/compilation.pro delete mode 100644 tests/benchmarks/declarative/compilation/data/BoomBlock.qml delete mode 100644 tests/benchmarks/declarative/compilation/tst_compilation.cpp delete mode 100644 tests/benchmarks/declarative/creation/creation.pro delete mode 100644 tests/benchmarks/declarative/creation/data/item.qml delete mode 100644 tests/benchmarks/declarative/creation/data/qobject.qml delete mode 100644 tests/benchmarks/declarative/creation/tst_creation.cpp delete mode 100644 tests/benchmarks/declarative/declarative.pro delete mode 100644 tests/benchmarks/declarative/holistic/data/dynamicTargets/DynamicFour.qml delete mode 100644 tests/benchmarks/declarative/holistic/data/dynamicTargets/DynamicOne.qml delete mode 100644 tests/benchmarks/declarative/holistic/data/dynamicTargets/DynamicThree.qml delete mode 100644 tests/benchmarks/declarative/holistic/data/dynamicTargets/DynamicTwo.qml delete mode 100644 tests/benchmarks/declarative/holistic/data/jsImports/Mlbsi.qml delete mode 100644 tests/benchmarks/declarative/holistic/data/jsImports/Mldsi.qml delete mode 100644 tests/benchmarks/declarative/holistic/data/jsImports/Mlsi.qml delete mode 100644 tests/benchmarks/declarative/holistic/data/jsImports/ModuleBm.qml delete mode 100644 tests/benchmarks/declarative/holistic/data/jsImports/Msbsi.qml delete mode 100644 tests/benchmarks/declarative/holistic/data/jsImports/Msdsi.qml delete mode 100644 tests/benchmarks/declarative/holistic/data/jsImports/Mssi.qml delete mode 100644 tests/benchmarks/declarative/holistic/data/jsImports/PragmaBm.qml delete mode 100644 tests/benchmarks/declarative/holistic/data/jsImports/PragmaModuleBm.qml delete mode 100644 tests/benchmarks/declarative/holistic/data/jsImports/Slsi.qml delete mode 100644 tests/benchmarks/declarative/holistic/data/jsImports/Sssi.qml delete mode 100644 tests/benchmarks/declarative/holistic/data/jsImports/mlbsi.js delete mode 100644 tests/benchmarks/declarative/holistic/data/jsImports/mlbsi1.js delete mode 100644 tests/benchmarks/declarative/holistic/data/jsImports/mlbsi10.js delete mode 100644 tests/benchmarks/declarative/holistic/data/jsImports/mlbsi11.js delete mode 100644 tests/benchmarks/declarative/holistic/data/jsImports/mlbsi12.js delete mode 100644 tests/benchmarks/declarative/holistic/data/jsImports/mlbsi13.js delete mode 100644 tests/benchmarks/declarative/holistic/data/jsImports/mlbsi14.js delete mode 100644 tests/benchmarks/declarative/holistic/data/jsImports/mlbsi15.js delete mode 100644 tests/benchmarks/declarative/holistic/data/jsImports/mlbsi2.js delete mode 100644 tests/benchmarks/declarative/holistic/data/jsImports/mlbsi3.js delete mode 100644 tests/benchmarks/declarative/holistic/data/jsImports/mlbsi4.js delete mode 100644 tests/benchmarks/declarative/holistic/data/jsImports/mlbsi5.js delete mode 100644 tests/benchmarks/declarative/holistic/data/jsImports/mlbsi6.js delete mode 100644 tests/benchmarks/declarative/holistic/data/jsImports/mlbsi7.js delete mode 100644 tests/benchmarks/declarative/holistic/data/jsImports/mlbsi8.js delete mode 100644 tests/benchmarks/declarative/holistic/data/jsImports/mlbsi9.js delete mode 100644 tests/benchmarks/declarative/holistic/data/jsImports/mldsi.js delete mode 100644 tests/benchmarks/declarative/holistic/data/jsImports/mldsi1.js delete mode 100644 tests/benchmarks/declarative/holistic/data/jsImports/mldsi10.js delete mode 100644 tests/benchmarks/declarative/holistic/data/jsImports/mldsi11.js delete mode 100644 tests/benchmarks/declarative/holistic/data/jsImports/mldsi12.js delete mode 100644 tests/benchmarks/declarative/holistic/data/jsImports/mldsi13.js delete mode 100644 tests/benchmarks/declarative/holistic/data/jsImports/mldsi14.js delete mode 100644 tests/benchmarks/declarative/holistic/data/jsImports/mldsi15.js delete mode 100644 tests/benchmarks/declarative/holistic/data/jsImports/mldsi2.js delete mode 100644 tests/benchmarks/declarative/holistic/data/jsImports/mldsi3.js delete mode 100644 tests/benchmarks/declarative/holistic/data/jsImports/mldsi4.js delete mode 100644 tests/benchmarks/declarative/holistic/data/jsImports/mldsi5.js delete mode 100644 tests/benchmarks/declarative/holistic/data/jsImports/mldsi6.js delete mode 100644 tests/benchmarks/declarative/holistic/data/jsImports/mldsi7.js delete mode 100644 tests/benchmarks/declarative/holistic/data/jsImports/mldsi8.js delete mode 100644 tests/benchmarks/declarative/holistic/data/jsImports/mldsi9.js delete mode 100644 tests/benchmarks/declarative/holistic/data/jsImports/mlsi.js delete mode 100644 tests/benchmarks/declarative/holistic/data/jsImports/moduleBm.js delete mode 100644 tests/benchmarks/declarative/holistic/data/jsImports/msbsi.js delete mode 100644 tests/benchmarks/declarative/holistic/data/jsImports/msbsi1.js delete mode 100644 tests/benchmarks/declarative/holistic/data/jsImports/msbsi10.js delete mode 100644 tests/benchmarks/declarative/holistic/data/jsImports/msbsi11.js delete mode 100644 tests/benchmarks/declarative/holistic/data/jsImports/msbsi12.js delete mode 100644 tests/benchmarks/declarative/holistic/data/jsImports/msbsi13.js delete mode 100644 tests/benchmarks/declarative/holistic/data/jsImports/msbsi14.js delete mode 100644 tests/benchmarks/declarative/holistic/data/jsImports/msbsi15.js delete mode 100644 tests/benchmarks/declarative/holistic/data/jsImports/msbsi2.js delete mode 100644 tests/benchmarks/declarative/holistic/data/jsImports/msbsi3.js delete mode 100644 tests/benchmarks/declarative/holistic/data/jsImports/msbsi4.js delete mode 100644 tests/benchmarks/declarative/holistic/data/jsImports/msbsi5.js delete mode 100644 tests/benchmarks/declarative/holistic/data/jsImports/msbsi6.js delete mode 100644 tests/benchmarks/declarative/holistic/data/jsImports/msbsi7.js delete mode 100644 tests/benchmarks/declarative/holistic/data/jsImports/msbsi8.js delete mode 100644 tests/benchmarks/declarative/holistic/data/jsImports/msbsi9.js delete mode 100644 tests/benchmarks/declarative/holistic/data/jsImports/msdsi.js delete mode 100644 tests/benchmarks/declarative/holistic/data/jsImports/msdsi1.js delete mode 100644 tests/benchmarks/declarative/holistic/data/jsImports/msdsi10.js delete mode 100644 tests/benchmarks/declarative/holistic/data/jsImports/msdsi11.js delete mode 100644 tests/benchmarks/declarative/holistic/data/jsImports/msdsi12.js delete mode 100644 tests/benchmarks/declarative/holistic/data/jsImports/msdsi13.js delete mode 100644 tests/benchmarks/declarative/holistic/data/jsImports/msdsi14.js delete mode 100644 tests/benchmarks/declarative/holistic/data/jsImports/msdsi15.js delete mode 100644 tests/benchmarks/declarative/holistic/data/jsImports/msdsi2.js delete mode 100644 tests/benchmarks/declarative/holistic/data/jsImports/msdsi3.js delete mode 100644 tests/benchmarks/declarative/holistic/data/jsImports/msdsi4.js delete mode 100644 tests/benchmarks/declarative/holistic/data/jsImports/msdsi5.js delete mode 100644 tests/benchmarks/declarative/holistic/data/jsImports/msdsi6.js delete mode 100644 tests/benchmarks/declarative/holistic/data/jsImports/msdsi7.js delete mode 100644 tests/benchmarks/declarative/holistic/data/jsImports/msdsi8.js delete mode 100644 tests/benchmarks/declarative/holistic/data/jsImports/msdsi9.js delete mode 100644 tests/benchmarks/declarative/holistic/data/jsImports/mssi.js delete mode 100644 tests/benchmarks/declarative/holistic/data/jsImports/pragmaBmOne.js delete mode 100644 tests/benchmarks/declarative/holistic/data/jsImports/pragmaBmTwo.js delete mode 100644 tests/benchmarks/declarative/holistic/data/jsImports/pragmaLib.js delete mode 100644 tests/benchmarks/declarative/holistic/data/jsImports/pragmaModuleBm.js delete mode 100644 tests/benchmarks/declarative/holistic/data/jsImports/slsi.js delete mode 100644 tests/benchmarks/declarative/holistic/data/jsImports/sssi.js delete mode 100644 tests/benchmarks/declarative/holistic/data/jsTargets/JsOne.qml delete mode 100644 tests/benchmarks/declarative/holistic/data/jsTargets/JsTwo.qml delete mode 100644 tests/benchmarks/declarative/holistic/data/largeTargets/gridview-example.qml delete mode 100644 tests/benchmarks/declarative/holistic/data/largeTargets/layoutdirection.qml delete mode 100644 tests/benchmarks/declarative/holistic/data/largeTargets/mousearea-example.qml delete mode 100644 tests/benchmarks/declarative/holistic/data/resolutionTargets/ResolveOne.qml delete mode 100644 tests/benchmarks/declarative/holistic/data/scopeSwitching/CppToJs.qml delete mode 100644 tests/benchmarks/declarative/holistic/data/scopeSwitching/CppToQml.qml delete mode 100644 tests/benchmarks/declarative/holistic/data/scopeSwitching/JsToCppEight.qml delete mode 100644 tests/benchmarks/declarative/holistic/data/scopeSwitching/JsToCppEleven.qml delete mode 100644 tests/benchmarks/declarative/holistic/data/scopeSwitching/JsToCppFive.qml delete mode 100644 tests/benchmarks/declarative/holistic/data/scopeSwitching/JsToCppFour.qml delete mode 100644 tests/benchmarks/declarative/holistic/data/scopeSwitching/JsToCppNine.qml delete mode 100644 tests/benchmarks/declarative/holistic/data/scopeSwitching/JsToCppOne.qml delete mode 100644 tests/benchmarks/declarative/holistic/data/scopeSwitching/JsToCppSeven.qml delete mode 100644 tests/benchmarks/declarative/holistic/data/scopeSwitching/JsToCppSix.qml delete mode 100644 tests/benchmarks/declarative/holistic/data/scopeSwitching/JsToCppTen.qml delete mode 100644 tests/benchmarks/declarative/holistic/data/scopeSwitching/JsToCppThree.qml delete mode 100644 tests/benchmarks/declarative/holistic/data/scopeSwitching/JsToCppTwo.qml delete mode 100644 tests/benchmarks/declarative/holistic/data/scopeSwitching/ScarceOne.qml delete mode 100644 tests/benchmarks/declarative/holistic/data/scopeSwitching/ScarceTwo.qml delete mode 100644 tests/benchmarks/declarative/holistic/data/scopeSwitching/cppToJs.js delete mode 100644 tests/benchmarks/declarative/holistic/data/smallTargets/SmallFour.qml delete mode 100644 tests/benchmarks/declarative/holistic/data/smallTargets/SmallOne.qml delete mode 100644 tests/benchmarks/declarative/holistic/data/smallTargets/SmallThree.qml delete mode 100644 tests/benchmarks/declarative/holistic/data/smallTargets/SmallTwo.qml delete mode 100644 tests/benchmarks/declarative/holistic/holistic.pro delete mode 100644 tests/benchmarks/declarative/holistic/testtypes.cpp delete mode 100644 tests/benchmarks/declarative/holistic/testtypes.h delete mode 100644 tests/benchmarks/declarative/holistic/tst_holistic.cpp delete mode 100644 tests/benchmarks/declarative/javascript/data/NestedIdObject.qml delete mode 100644 tests/benchmarks/declarative/javascript/data/intQObjectProperty.qml delete mode 100644 tests/benchmarks/declarative/javascript/data/localId.qml delete mode 100644 tests/benchmarks/declarative/javascript/data/nestedId.qml delete mode 100644 tests/benchmarks/declarative/javascript/data/stringQObjectProperty.qml delete mode 100644 tests/benchmarks/declarative/javascript/javascript.pro delete mode 100644 tests/benchmarks/declarative/javascript/testtypes.cpp delete mode 100644 tests/benchmarks/declarative/javascript/testtypes.h delete mode 100644 tests/benchmarks/declarative/javascript/tst_javascript.cpp delete mode 100644 tests/benchmarks/declarative/js/js.pro delete mode 100644 tests/benchmarks/declarative/js/qjsengine/qjsengine.pro delete mode 100644 tests/benchmarks/declarative/js/qjsengine/tst_qjsengine.cpp delete mode 100644 tests/benchmarks/declarative/js/qjsvalue/qjsvalue.pro delete mode 100644 tests/benchmarks/declarative/js/qjsvalue/tst_qjsvalue.cpp delete mode 100644 tests/benchmarks/declarative/js/qjsvalueiterator/qjsvalueiterator.pro delete mode 100644 tests/benchmarks/declarative/js/qjsvalueiterator/tst_qjsvalueiterator.cpp delete mode 100644 tests/benchmarks/declarative/painting/data/63x63.png delete mode 100644 tests/benchmarks/declarative/painting/data/63x63_opaque.png delete mode 100644 tests/benchmarks/declarative/painting/data/64x64.png delete mode 100644 tests/benchmarks/declarative/painting/data/64x64_opaque.png delete mode 100644 tests/benchmarks/declarative/painting/paintbenchmark.cpp delete mode 100644 tests/benchmarks/declarative/painting/painting.pro delete mode 100644 tests/benchmarks/declarative/pointers/pointers.pro delete mode 100644 tests/benchmarks/declarative/pointers/tst_pointers.cpp delete mode 100644 tests/benchmarks/declarative/qdeclarativecomponent/data/myqmlobject.qml delete mode 100644 tests/benchmarks/declarative/qdeclarativecomponent/data/myqmlobject_binding.qml delete mode 100644 tests/benchmarks/declarative/qdeclarativecomponent/data/object.qml delete mode 100644 tests/benchmarks/declarative/qdeclarativecomponent/data/object_id.qml delete mode 100644 tests/benchmarks/declarative/qdeclarativecomponent/data/samegame/BoomBlock.qml delete mode 100644 tests/benchmarks/declarative/qdeclarativecomponent/data/samegame/pics/blueStone.png delete mode 100644 tests/benchmarks/declarative/qdeclarativecomponent/data/samegame/pics/greenStone.png delete mode 100644 tests/benchmarks/declarative/qdeclarativecomponent/data/samegame/pics/redStone.png delete mode 100644 tests/benchmarks/declarative/qdeclarativecomponent/data/samegame/pics/yellowStone.png delete mode 100644 tests/benchmarks/declarative/qdeclarativecomponent/data/synthesized_properties.2.qml delete mode 100644 tests/benchmarks/declarative/qdeclarativecomponent/data/synthesized_properties.qml delete mode 100644 tests/benchmarks/declarative/qdeclarativecomponent/qdeclarativecomponent.pro delete mode 100644 tests/benchmarks/declarative/qdeclarativecomponent/testtypes.cpp delete mode 100644 tests/benchmarks/declarative/qdeclarativecomponent/testtypes.h delete mode 100644 tests/benchmarks/declarative/qdeclarativecomponent/tst_qdeclarativecomponent.cpp delete mode 100644 tests/benchmarks/declarative/qdeclarativedebugtrace/qdeclarativedebugtrace.pro delete mode 100644 tests/benchmarks/declarative/qdeclarativedebugtrace/tst_qdeclarativedebugtrace.cpp delete mode 100644 tests/benchmarks/declarative/qdeclarativeimage/image.png delete mode 100644 tests/benchmarks/declarative/qdeclarativeimage/qdeclarativeimage.pro delete mode 100644 tests/benchmarks/declarative/qdeclarativeimage/tst_qdeclarativeimage.cpp delete mode 100644 tests/benchmarks/declarative/qdeclarativemetaproperty/data/object.qml delete mode 100644 tests/benchmarks/declarative/qdeclarativemetaproperty/data/synthesized_object.qml delete mode 100644 tests/benchmarks/declarative/qdeclarativemetaproperty/qdeclarativemetaproperty.pro delete mode 100644 tests/benchmarks/declarative/qdeclarativemetaproperty/tst_qdeclarativemetaproperty.cpp delete mode 100644 tests/benchmarks/declarative/qmltime/example.qml delete mode 100644 tests/benchmarks/declarative/qmltime/qmltime.cpp delete mode 100644 tests/benchmarks/declarative/qmltime/qmltime.pro delete mode 100644 tests/benchmarks/declarative/qmltime/tests/anchors/empty.qml delete mode 100644 tests/benchmarks/declarative/qmltime/tests/anchors/fill.qml delete mode 100644 tests/benchmarks/declarative/qmltime/tests/anchors/null.qml delete mode 100644 tests/benchmarks/declarative/qmltime/tests/animation/large.qml delete mode 100644 tests/benchmarks/declarative/qmltime/tests/animation/largeNoProps.qml delete mode 100644 tests/benchmarks/declarative/qmltime/tests/item_creation/children.qml delete mode 100644 tests/benchmarks/declarative/qmltime/tests/item_creation/data.qml delete mode 100644 tests/benchmarks/declarative/qmltime/tests/item_creation/no_creation.qml delete mode 100644 tests/benchmarks/declarative/qmltime/tests/item_creation/resources.qml delete mode 100644 tests/benchmarks/declarative/qmltime/tests/loader/Loaded.qml delete mode 100644 tests/benchmarks/declarative/qmltime/tests/loader/component_loader.qml delete mode 100644 tests/benchmarks/declarative/qmltime/tests/loader/empty_loader.qml delete mode 100644 tests/benchmarks/declarative/qmltime/tests/loader/no_loader.qml delete mode 100644 tests/benchmarks/declarative/qmltime/tests/loader/source_loader.qml delete mode 100644 tests/benchmarks/declarative/qmltime/tests/positioner_creation/no_positioner.qml delete mode 100644 tests/benchmarks/declarative/qmltime/tests/positioner_creation/null_positioner.qml delete mode 100644 tests/benchmarks/declarative/qmltime/tests/positioner_creation/positioner.qml delete mode 100644 tests/benchmarks/declarative/qmltime/tests/vmemetaobject/null.qml delete mode 100644 tests/benchmarks/declarative/qmltime/tests/vmemetaobject/property.qml delete mode 100644 tests/benchmarks/declarative/script/data/CustomObject.qml delete mode 100644 tests/benchmarks/declarative/script/data/block.qml delete mode 100644 tests/benchmarks/declarative/script/data/enums.qml delete mode 100644 tests/benchmarks/declarative/script/data/global.js delete mode 100644 tests/benchmarks/declarative/script/data/global_prop.qml delete mode 100644 tests/benchmarks/declarative/script/data/namespacedEnums.qml delete mode 100644 tests/benchmarks/declarative/script/data/script.js delete mode 100644 tests/benchmarks/declarative/script/data/script2.js delete mode 100644 tests/benchmarks/declarative/script/data/scriptCall.qml delete mode 100644 tests/benchmarks/declarative/script/data/signal_args.qml delete mode 100644 tests/benchmarks/declarative/script/data/signal_qml.qml delete mode 100644 tests/benchmarks/declarative/script/data/signal_unconnected.qml delete mode 100644 tests/benchmarks/declarative/script/data/signal_unusedArgs.qml delete mode 100644 tests/benchmarks/declarative/script/data/slot_complex.qml delete mode 100644 tests/benchmarks/declarative/script/data/slot_complex_js.js delete mode 100644 tests/benchmarks/declarative/script/data/slot_complex_js.qml delete mode 100644 tests/benchmarks/declarative/script/data/slot_simple.qml delete mode 100644 tests/benchmarks/declarative/script/data/slot_simple_js.js delete mode 100644 tests/benchmarks/declarative/script/data/slot_simple_js.qml delete mode 100644 tests/benchmarks/declarative/script/script.pro delete mode 100644 tests/benchmarks/declarative/script/tst_script.cpp delete mode 100644 tests/benchmarks/declarative/typeimports/data/QmlTestType1.qml delete mode 100644 tests/benchmarks/declarative/typeimports/data/QmlTestType2.qml delete mode 100644 tests/benchmarks/declarative/typeimports/data/QmlTestType3.qml delete mode 100644 tests/benchmarks/declarative/typeimports/data/QmlTestType4.qml delete mode 100644 tests/benchmarks/declarative/typeimports/data/cpp.qml delete mode 100644 tests/benchmarks/declarative/typeimports/data/qml.qml delete mode 100644 tests/benchmarks/declarative/typeimports/tst_typeimports.cpp delete mode 100644 tests/benchmarks/declarative/typeimports/typeimports.pro create mode 100644 tests/benchmarks/qml/animation/animation.pro create mode 100644 tests/benchmarks/qml/animation/data/animation.qml create mode 100644 tests/benchmarks/qml/animation/tst_animation.cpp create mode 100644 tests/benchmarks/qml/binding/binding.pro create mode 100644 tests/benchmarks/qml/binding/data/creation.txt create mode 100644 tests/benchmarks/qml/binding/data/idproperty.txt create mode 100644 tests/benchmarks/qml/binding/data/localproperty.txt create mode 100644 tests/benchmarks/qml/binding/data/objectproperty.txt create mode 100644 tests/benchmarks/qml/binding/testtypes.cpp create mode 100644 tests/benchmarks/qml/binding/testtypes.h create mode 100644 tests/benchmarks/qml/binding/tst_binding.cpp create mode 100644 tests/benchmarks/qml/compilation/compilation.pro create mode 100644 tests/benchmarks/qml/compilation/data/BoomBlock.qml create mode 100644 tests/benchmarks/qml/compilation/tst_compilation.cpp create mode 100644 tests/benchmarks/qml/creation/creation.pro create mode 100644 tests/benchmarks/qml/creation/data/item.qml create mode 100644 tests/benchmarks/qml/creation/data/qobject.qml create mode 100644 tests/benchmarks/qml/creation/tst_creation.cpp create mode 100644 tests/benchmarks/qml/holistic/data/dynamicTargets/DynamicFour.qml create mode 100644 tests/benchmarks/qml/holistic/data/dynamicTargets/DynamicOne.qml create mode 100644 tests/benchmarks/qml/holistic/data/dynamicTargets/DynamicThree.qml create mode 100644 tests/benchmarks/qml/holistic/data/dynamicTargets/DynamicTwo.qml create mode 100644 tests/benchmarks/qml/holistic/data/jsImports/Mlbsi.qml create mode 100644 tests/benchmarks/qml/holistic/data/jsImports/Mldsi.qml create mode 100644 tests/benchmarks/qml/holistic/data/jsImports/Mlsi.qml create mode 100644 tests/benchmarks/qml/holistic/data/jsImports/ModuleBm.qml create mode 100644 tests/benchmarks/qml/holistic/data/jsImports/Msbsi.qml create mode 100644 tests/benchmarks/qml/holistic/data/jsImports/Msdsi.qml create mode 100644 tests/benchmarks/qml/holistic/data/jsImports/Mssi.qml create mode 100644 tests/benchmarks/qml/holistic/data/jsImports/PragmaBm.qml create mode 100644 tests/benchmarks/qml/holistic/data/jsImports/PragmaModuleBm.qml create mode 100644 tests/benchmarks/qml/holistic/data/jsImports/Slsi.qml create mode 100644 tests/benchmarks/qml/holistic/data/jsImports/Sssi.qml create mode 100644 tests/benchmarks/qml/holistic/data/jsImports/mlbsi.js create mode 100644 tests/benchmarks/qml/holistic/data/jsImports/mlbsi1.js create mode 100644 tests/benchmarks/qml/holistic/data/jsImports/mlbsi10.js create mode 100644 tests/benchmarks/qml/holistic/data/jsImports/mlbsi11.js create mode 100644 tests/benchmarks/qml/holistic/data/jsImports/mlbsi12.js create mode 100644 tests/benchmarks/qml/holistic/data/jsImports/mlbsi13.js create mode 100644 tests/benchmarks/qml/holistic/data/jsImports/mlbsi14.js create mode 100644 tests/benchmarks/qml/holistic/data/jsImports/mlbsi15.js create mode 100644 tests/benchmarks/qml/holistic/data/jsImports/mlbsi2.js create mode 100644 tests/benchmarks/qml/holistic/data/jsImports/mlbsi3.js create mode 100644 tests/benchmarks/qml/holistic/data/jsImports/mlbsi4.js create mode 100644 tests/benchmarks/qml/holistic/data/jsImports/mlbsi5.js create mode 100644 tests/benchmarks/qml/holistic/data/jsImports/mlbsi6.js create mode 100644 tests/benchmarks/qml/holistic/data/jsImports/mlbsi7.js create mode 100644 tests/benchmarks/qml/holistic/data/jsImports/mlbsi8.js create mode 100644 tests/benchmarks/qml/holistic/data/jsImports/mlbsi9.js create mode 100644 tests/benchmarks/qml/holistic/data/jsImports/mldsi.js create mode 100644 tests/benchmarks/qml/holistic/data/jsImports/mldsi1.js create mode 100644 tests/benchmarks/qml/holistic/data/jsImports/mldsi10.js create mode 100644 tests/benchmarks/qml/holistic/data/jsImports/mldsi11.js create mode 100644 tests/benchmarks/qml/holistic/data/jsImports/mldsi12.js create mode 100644 tests/benchmarks/qml/holistic/data/jsImports/mldsi13.js create mode 100644 tests/benchmarks/qml/holistic/data/jsImports/mldsi14.js create mode 100644 tests/benchmarks/qml/holistic/data/jsImports/mldsi15.js create mode 100644 tests/benchmarks/qml/holistic/data/jsImports/mldsi2.js create mode 100644 tests/benchmarks/qml/holistic/data/jsImports/mldsi3.js create mode 100644 tests/benchmarks/qml/holistic/data/jsImports/mldsi4.js create mode 100644 tests/benchmarks/qml/holistic/data/jsImports/mldsi5.js create mode 100644 tests/benchmarks/qml/holistic/data/jsImports/mldsi6.js create mode 100644 tests/benchmarks/qml/holistic/data/jsImports/mldsi7.js create mode 100644 tests/benchmarks/qml/holistic/data/jsImports/mldsi8.js create mode 100644 tests/benchmarks/qml/holistic/data/jsImports/mldsi9.js create mode 100644 tests/benchmarks/qml/holistic/data/jsImports/mlsi.js create mode 100644 tests/benchmarks/qml/holistic/data/jsImports/moduleBm.js create mode 100644 tests/benchmarks/qml/holistic/data/jsImports/msbsi.js create mode 100644 tests/benchmarks/qml/holistic/data/jsImports/msbsi1.js create mode 100644 tests/benchmarks/qml/holistic/data/jsImports/msbsi10.js create mode 100644 tests/benchmarks/qml/holistic/data/jsImports/msbsi11.js create mode 100644 tests/benchmarks/qml/holistic/data/jsImports/msbsi12.js create mode 100644 tests/benchmarks/qml/holistic/data/jsImports/msbsi13.js create mode 100644 tests/benchmarks/qml/holistic/data/jsImports/msbsi14.js create mode 100644 tests/benchmarks/qml/holistic/data/jsImports/msbsi15.js create mode 100644 tests/benchmarks/qml/holistic/data/jsImports/msbsi2.js create mode 100644 tests/benchmarks/qml/holistic/data/jsImports/msbsi3.js create mode 100644 tests/benchmarks/qml/holistic/data/jsImports/msbsi4.js create mode 100644 tests/benchmarks/qml/holistic/data/jsImports/msbsi5.js create mode 100644 tests/benchmarks/qml/holistic/data/jsImports/msbsi6.js create mode 100644 tests/benchmarks/qml/holistic/data/jsImports/msbsi7.js create mode 100644 tests/benchmarks/qml/holistic/data/jsImports/msbsi8.js create mode 100644 tests/benchmarks/qml/holistic/data/jsImports/msbsi9.js create mode 100644 tests/benchmarks/qml/holistic/data/jsImports/msdsi.js create mode 100644 tests/benchmarks/qml/holistic/data/jsImports/msdsi1.js create mode 100644 tests/benchmarks/qml/holistic/data/jsImports/msdsi10.js create mode 100644 tests/benchmarks/qml/holistic/data/jsImports/msdsi11.js create mode 100644 tests/benchmarks/qml/holistic/data/jsImports/msdsi12.js create mode 100644 tests/benchmarks/qml/holistic/data/jsImports/msdsi13.js create mode 100644 tests/benchmarks/qml/holistic/data/jsImports/msdsi14.js create mode 100644 tests/benchmarks/qml/holistic/data/jsImports/msdsi15.js create mode 100644 tests/benchmarks/qml/holistic/data/jsImports/msdsi2.js create mode 100644 tests/benchmarks/qml/holistic/data/jsImports/msdsi3.js create mode 100644 tests/benchmarks/qml/holistic/data/jsImports/msdsi4.js create mode 100644 tests/benchmarks/qml/holistic/data/jsImports/msdsi5.js create mode 100644 tests/benchmarks/qml/holistic/data/jsImports/msdsi6.js create mode 100644 tests/benchmarks/qml/holistic/data/jsImports/msdsi7.js create mode 100644 tests/benchmarks/qml/holistic/data/jsImports/msdsi8.js create mode 100644 tests/benchmarks/qml/holistic/data/jsImports/msdsi9.js create mode 100644 tests/benchmarks/qml/holistic/data/jsImports/mssi.js create mode 100644 tests/benchmarks/qml/holistic/data/jsImports/pragmaBmOne.js create mode 100644 tests/benchmarks/qml/holistic/data/jsImports/pragmaBmTwo.js create mode 100644 tests/benchmarks/qml/holistic/data/jsImports/pragmaLib.js create mode 100644 tests/benchmarks/qml/holistic/data/jsImports/pragmaModuleBm.js create mode 100644 tests/benchmarks/qml/holistic/data/jsImports/slsi.js create mode 100644 tests/benchmarks/qml/holistic/data/jsImports/sssi.js create mode 100644 tests/benchmarks/qml/holistic/data/jsTargets/JsOne.qml create mode 100644 tests/benchmarks/qml/holistic/data/jsTargets/JsTwo.qml create mode 100644 tests/benchmarks/qml/holistic/data/largeTargets/gridview-example.qml create mode 100644 tests/benchmarks/qml/holistic/data/largeTargets/layoutdirection.qml create mode 100644 tests/benchmarks/qml/holistic/data/largeTargets/mousearea-example.qml create mode 100644 tests/benchmarks/qml/holistic/data/resolutionTargets/ResolveOne.qml create mode 100644 tests/benchmarks/qml/holistic/data/scopeSwitching/CppToJs.qml create mode 100644 tests/benchmarks/qml/holistic/data/scopeSwitching/CppToQml.qml create mode 100644 tests/benchmarks/qml/holistic/data/scopeSwitching/JsToCppEight.qml create mode 100644 tests/benchmarks/qml/holistic/data/scopeSwitching/JsToCppEleven.qml create mode 100644 tests/benchmarks/qml/holistic/data/scopeSwitching/JsToCppFive.qml create mode 100644 tests/benchmarks/qml/holistic/data/scopeSwitching/JsToCppFour.qml create mode 100644 tests/benchmarks/qml/holistic/data/scopeSwitching/JsToCppNine.qml create mode 100644 tests/benchmarks/qml/holistic/data/scopeSwitching/JsToCppOne.qml create mode 100644 tests/benchmarks/qml/holistic/data/scopeSwitching/JsToCppSeven.qml create mode 100644 tests/benchmarks/qml/holistic/data/scopeSwitching/JsToCppSix.qml create mode 100644 tests/benchmarks/qml/holistic/data/scopeSwitching/JsToCppTen.qml create mode 100644 tests/benchmarks/qml/holistic/data/scopeSwitching/JsToCppThree.qml create mode 100644 tests/benchmarks/qml/holistic/data/scopeSwitching/JsToCppTwo.qml create mode 100644 tests/benchmarks/qml/holistic/data/scopeSwitching/ScarceOne.qml create mode 100644 tests/benchmarks/qml/holistic/data/scopeSwitching/ScarceTwo.qml create mode 100644 tests/benchmarks/qml/holistic/data/scopeSwitching/cppToJs.js create mode 100644 tests/benchmarks/qml/holistic/data/smallTargets/SmallFour.qml create mode 100644 tests/benchmarks/qml/holistic/data/smallTargets/SmallOne.qml create mode 100644 tests/benchmarks/qml/holistic/data/smallTargets/SmallThree.qml create mode 100644 tests/benchmarks/qml/holistic/data/smallTargets/SmallTwo.qml create mode 100644 tests/benchmarks/qml/holistic/holistic.pro create mode 100644 tests/benchmarks/qml/holistic/testtypes.cpp create mode 100644 tests/benchmarks/qml/holistic/testtypes.h create mode 100644 tests/benchmarks/qml/holistic/tst_holistic.cpp create mode 100644 tests/benchmarks/qml/javascript/data/NestedIdObject.qml create mode 100644 tests/benchmarks/qml/javascript/data/intQObjectProperty.qml create mode 100644 tests/benchmarks/qml/javascript/data/localId.qml create mode 100644 tests/benchmarks/qml/javascript/data/nestedId.qml create mode 100644 tests/benchmarks/qml/javascript/data/stringQObjectProperty.qml create mode 100644 tests/benchmarks/qml/javascript/javascript.pro create mode 100644 tests/benchmarks/qml/javascript/testtypes.cpp create mode 100644 tests/benchmarks/qml/javascript/testtypes.h create mode 100644 tests/benchmarks/qml/javascript/tst_javascript.cpp create mode 100644 tests/benchmarks/qml/js/js.pro create mode 100644 tests/benchmarks/qml/js/qjsengine/qjsengine.pro create mode 100644 tests/benchmarks/qml/js/qjsengine/tst_qjsengine.cpp create mode 100644 tests/benchmarks/qml/js/qjsvalue/qjsvalue.pro create mode 100644 tests/benchmarks/qml/js/qjsvalue/tst_qjsvalue.cpp create mode 100644 tests/benchmarks/qml/js/qjsvalueiterator/qjsvalueiterator.pro create mode 100644 tests/benchmarks/qml/js/qjsvalueiterator/tst_qjsvalueiterator.cpp create mode 100644 tests/benchmarks/qml/painting/data/63x63.png create mode 100644 tests/benchmarks/qml/painting/data/63x63_opaque.png create mode 100644 tests/benchmarks/qml/painting/data/64x64.png create mode 100644 tests/benchmarks/qml/painting/data/64x64_opaque.png create mode 100644 tests/benchmarks/qml/painting/paintbenchmark.cpp create mode 100644 tests/benchmarks/qml/painting/painting.pro create mode 100644 tests/benchmarks/qml/pointers/pointers.pro create mode 100644 tests/benchmarks/qml/pointers/tst_pointers.cpp create mode 100644 tests/benchmarks/qml/qml.pro create mode 100644 tests/benchmarks/qml/qmltime/example.qml create mode 100644 tests/benchmarks/qml/qmltime/qmltime.cpp create mode 100644 tests/benchmarks/qml/qmltime/qmltime.pro create mode 100644 tests/benchmarks/qml/qmltime/tests/anchors/empty.qml create mode 100644 tests/benchmarks/qml/qmltime/tests/anchors/fill.qml create mode 100644 tests/benchmarks/qml/qmltime/tests/anchors/null.qml create mode 100644 tests/benchmarks/qml/qmltime/tests/animation/large.qml create mode 100644 tests/benchmarks/qml/qmltime/tests/animation/largeNoProps.qml create mode 100644 tests/benchmarks/qml/qmltime/tests/item_creation/children.qml create mode 100644 tests/benchmarks/qml/qmltime/tests/item_creation/data.qml create mode 100644 tests/benchmarks/qml/qmltime/tests/item_creation/no_creation.qml create mode 100644 tests/benchmarks/qml/qmltime/tests/item_creation/resources.qml create mode 100644 tests/benchmarks/qml/qmltime/tests/loader/Loaded.qml create mode 100644 tests/benchmarks/qml/qmltime/tests/loader/component_loader.qml create mode 100644 tests/benchmarks/qml/qmltime/tests/loader/empty_loader.qml create mode 100644 tests/benchmarks/qml/qmltime/tests/loader/no_loader.qml create mode 100644 tests/benchmarks/qml/qmltime/tests/loader/source_loader.qml create mode 100644 tests/benchmarks/qml/qmltime/tests/positioner_creation/no_positioner.qml create mode 100644 tests/benchmarks/qml/qmltime/tests/positioner_creation/null_positioner.qml create mode 100644 tests/benchmarks/qml/qmltime/tests/positioner_creation/positioner.qml create mode 100644 tests/benchmarks/qml/qmltime/tests/vmemetaobject/null.qml create mode 100644 tests/benchmarks/qml/qmltime/tests/vmemetaobject/property.qml create mode 100644 tests/benchmarks/qml/qqmlcomponent/data/myqmlobject.qml create mode 100644 tests/benchmarks/qml/qqmlcomponent/data/myqmlobject_binding.qml create mode 100644 tests/benchmarks/qml/qqmlcomponent/data/object.qml create mode 100644 tests/benchmarks/qml/qqmlcomponent/data/object_id.qml create mode 100644 tests/benchmarks/qml/qqmlcomponent/data/samegame/BoomBlock.qml create mode 100644 tests/benchmarks/qml/qqmlcomponent/data/samegame/pics/blueStone.png create mode 100644 tests/benchmarks/qml/qqmlcomponent/data/samegame/pics/greenStone.png create mode 100644 tests/benchmarks/qml/qqmlcomponent/data/samegame/pics/redStone.png create mode 100644 tests/benchmarks/qml/qqmlcomponent/data/samegame/pics/yellowStone.png create mode 100644 tests/benchmarks/qml/qqmlcomponent/data/synthesized_properties.2.qml create mode 100644 tests/benchmarks/qml/qqmlcomponent/data/synthesized_properties.qml create mode 100644 tests/benchmarks/qml/qqmlcomponent/qqmlcomponent.pro create mode 100644 tests/benchmarks/qml/qqmlcomponent/testtypes.cpp create mode 100644 tests/benchmarks/qml/qqmlcomponent/testtypes.h create mode 100644 tests/benchmarks/qml/qqmlcomponent/tst_qqmlcomponent.cpp create mode 100644 tests/benchmarks/qml/qqmldebugtrace/qqmldebugtrace.pro create mode 100644 tests/benchmarks/qml/qqmldebugtrace/tst_qqmldebugtrace.cpp create mode 100644 tests/benchmarks/qml/qqmlimage/image.png create mode 100644 tests/benchmarks/qml/qqmlimage/qqmlimage.pro create mode 100644 tests/benchmarks/qml/qqmlimage/tst_qqmlimage.cpp create mode 100644 tests/benchmarks/qml/qqmlmetaproperty/data/object.qml create mode 100644 tests/benchmarks/qml/qqmlmetaproperty/data/synthesized_object.qml create mode 100644 tests/benchmarks/qml/qqmlmetaproperty/qqmlmetaproperty.pro create mode 100644 tests/benchmarks/qml/qqmlmetaproperty/tst_qqmlmetaproperty.cpp create mode 100644 tests/benchmarks/qml/script/data/CustomObject.qml create mode 100644 tests/benchmarks/qml/script/data/block.qml create mode 100644 tests/benchmarks/qml/script/data/enums.qml create mode 100644 tests/benchmarks/qml/script/data/global.js create mode 100644 tests/benchmarks/qml/script/data/global_prop.qml create mode 100644 tests/benchmarks/qml/script/data/namespacedEnums.qml create mode 100644 tests/benchmarks/qml/script/data/script.js create mode 100644 tests/benchmarks/qml/script/data/script2.js create mode 100644 tests/benchmarks/qml/script/data/scriptCall.qml create mode 100644 tests/benchmarks/qml/script/data/signal_args.qml create mode 100644 tests/benchmarks/qml/script/data/signal_qml.qml create mode 100644 tests/benchmarks/qml/script/data/signal_unconnected.qml create mode 100644 tests/benchmarks/qml/script/data/signal_unusedArgs.qml create mode 100644 tests/benchmarks/qml/script/data/slot_complex.qml create mode 100644 tests/benchmarks/qml/script/data/slot_complex_js.js create mode 100644 tests/benchmarks/qml/script/data/slot_complex_js.qml create mode 100644 tests/benchmarks/qml/script/data/slot_simple.qml create mode 100644 tests/benchmarks/qml/script/data/slot_simple_js.js create mode 100644 tests/benchmarks/qml/script/data/slot_simple_js.qml create mode 100644 tests/benchmarks/qml/script/script.pro create mode 100644 tests/benchmarks/qml/script/tst_script.cpp create mode 100644 tests/benchmarks/qml/typeimports/data/QmlTestType1.qml create mode 100644 tests/benchmarks/qml/typeimports/data/QmlTestType2.qml create mode 100644 tests/benchmarks/qml/typeimports/data/QmlTestType3.qml create mode 100644 tests/benchmarks/qml/typeimports/data/QmlTestType4.qml create mode 100644 tests/benchmarks/qml/typeimports/data/cpp.qml create mode 100644 tests/benchmarks/qml/typeimports/data/qml.qml create mode 100644 tests/benchmarks/qml/typeimports/tst_typeimports.cpp create mode 100644 tests/benchmarks/qml/typeimports/typeimports.pro diff --git a/bin/rename-qtdeclarative-symbols.sh b/bin/rename-qtdeclarative-symbols.sh new file mode 100755 index 0000000000..841850230f --- /dev/null +++ b/bin/rename-qtdeclarative-symbols.sh @@ -0,0 +1,639 @@ +#!/bin/sh +############################################################################# +## +## Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +## Contact: http://www.qt-project.org/ +## +## This file is part of the QtQml module of the Qt Toolkit. +## +## $QT_BEGIN_LICENSE:LGPL$ +## GNU Lesser General Public License Usage +## This file may be used under the terms of the GNU Lesser General Public +## License version 2.1 as published by the Free Software Foundation and +## appearing in the file LICENSE.LGPL included in the packaging of this +## file. Please review the following information to ensure the GNU Lesser +## General Public License version 2.1 requirements will be met: +## http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +## +## In addition, as a special exception, Nokia gives you certain additional +## rights. These rights are described in the Nokia Qt LGPL Exception +## version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +## +## GNU General Public License Usage +## Alternatively, this file may be used under the terms of the GNU General +## Public License version 3.0 as published by the Free Software Foundation +## and appearing in the file LICENSE.GPL included in the packaging of this +## file. Please review the following information to ensure the GNU General +## Public License version 3.0 requirements will be met: +## http://www.gnu.org/copyleft/gpl.html. +## +## Other Usage +## Alternatively, this file may be used in accordance with the terms and +## conditions contained in a signed written agreement between you and Nokia. +## +## +## +## +## +## +## $QT_END_LICENSE$ +## +############################################################################# + +# Replaces deprecated QDeclarative symbol names with their replacements +# +# Changes instances in all regular files under the specified directory; +# use on a clean source tree! + +if [ "$#" -lt "1" ] +then + echo " Usage: $0 " + exit 1; +fi + +MODIFY_DIR="$1" + +QML_SYMBOLS="\ + QDeclarativeAbstractBinding + QDeclarativeAbstractBoundSignal + QDeclarativeAbstractExpression + QDeclarativeAccessible + QDeclarativeAccessors + QDeclarativeAccessorProperties + QDeclarativeAnimationTimer + QDeclarativeAssociationList + QDeclarativeAttachedPropertiesFunc + QDeclarativeBinding + QDeclarativeBindingPrivate + QDeclarativeBindingProfiler + QDeclarativeBoundSignal + QDeclarativeBoundSignalParameters + QDeclarativeBoundSignalProxy + QDeclarativeBuiltinFunctions + QDeclarativeCleanup + QDeclarativeColorValueType + QDeclarativeCompiledData + QDeclarativeCompiler + QDeclarativeCompilerTypes + QDeclarativeComponent + QDeclarativeComponentAttached + QDeclarativeComponentExtension + QDeclarativeComponentPrivate + QDeclarativeComponent_setQmlParent + QDeclarativeCompositeTypeData + QDeclarativeConnectionsParser + QDeclarativeContext + QDeclarativeContextData + QDeclarativeContextPrivate + QDeclarativeCustomParser + QDeclarativeCustomParserNode + QDeclarativeCustomParserNodePrivate + QDeclarativeCustomParserProperty + QDeclarativeCustomParserPropertyPrivate + QDeclarativeData + QDeclarativeDataBlob + QDeclarativeDataExtended + QDeclarativeDataLoader + QDeclarativeDataLoaderNetworkReplyProxy + QDeclarativeDataLoaderThread + QDeclarativeDateExtension + QDeclarativeDataTest + QDeclarativeDebug + QDeclarativeDebugClient + QDeclarativeDebugClientPrivate + QDeclarativeDebugConnection + QDeclarativeDebugConnectionPrivate + QDeclarativeDebugContextReference + QDeclarativeDebugData + QDeclarativeDebugEngineReference + QDeclarativeDebugEnginesQuery + QDeclarativeDebugExpressionQuery + QDeclarativeDebugFileReference + QDeclarativeDebugger + QDeclarativeDebuggingEnabler + QDeclarativeDebugHelper + QDeclarativeDebugObjectExpressionWatch + QDeclarativeDebugObjectQuery + QDeclarativeDebugObjectReference + QDeclarativeDebugPropertyReference + QDeclarativeDebugPropertyWatch + QDeclarativeDebugQuery + QDeclarativeDebugRootContextQuery + QDeclarativeDebugServer + QDeclarativeDebugServerConnection + QDeclarativeDebugServerPrivate + QDeclarativeDebugServerThread + QDeclarativeDebugService + QDeclarativeDebugServicePrivate + QDeclarativeDebugStatesDelegate + QDeclarativeDebugTrace + QDeclarativeDebugWatch + QDeclarativeDelayedError + QDeclarativeDirComponents + QDeclarativeDirParser + QDeclarativeDirScripts + QDeclarativeDOMNodeResource + QDeclarativeEasingValueType + QDeclarativeElement + QDeclarativeEngine + QDeclarativeEngineDebug + QDeclarativeEngineDebugClient + QDeclarativeEngineDebugService + QDeclarativeEngineDebugPrivate + QDeclarativeEnginePrivate + QDeclarativeError + QDeclarativeErrorPrivate + QDeclarativeExpression + QDeclarativeExpressionPrivate + QDeclarativeExtensionInterface + QDeclarativeExtensionPlugin + QDeclarativeFontValueType + QDeclarativeGraphics_DerivedObject + QDeclarativeGuard + QDeclarativeGuardedContextData + QDeclarativeGuardImpl + QDeclarativeImageProvider + QDeclarativeImageProviderPrivate + QDeclarativeImportDatabase + QDeclarativeImportedNamespace + QDeclarativeImports + QDeclarativeImportsPrivate + QDeclarativeIncubationController + QDeclarativeIncubator + QDeclarativeIncubatorController + QDeclarativeIncubatorPrivate + QDeclarativeIncubators + QDeclarativeInfo + QDeclarativeInfoPrivate + QDeclarativeInspector + QDeclarativeInspectorInterface + QDeclarativeInspectorService + QDeclarativeInstruction + QDeclarativeInstructionData + QDeclarativeInstructionMeta + QDeclarativeIntegerCache + QDeclarativeJavaScriptExpression + QDeclarativeJavaScriptExpressionGuard + QDeclarativeJS + QDeclarativeJSGrammar + QDeclarativeListProperty + QDeclarativeListReference + QDeclarativeListReferencePrivate + QDeclarativeLocale + QDeclarativeLocalStoragePlugin + QDeclarativeMatrix4x4ValueType + QDeclarativeMetaType + QDeclarativeMetaTypeData + QDeclarativeNetworkAccessManagerFactory + QDeclarativeNotifier + QDeclarativeNotifierEndpoint + QDeclarativeNullableValue + QDeclarativeNumberExtension + QDeclarativeObjectData + QDeclarativeObjectProperty + QDeclarativeObserverMode + QDeclarativeOpenMetaObject + QDeclarativeOpenMetaObjectPrivate + QDeclarativeOpenMetaObjectType + QDeclarativeOpenMetaObjectTypePrivate + QDeclarativeParser + QDeclarativeParserStatus + QDeclarativePointFValueType + QDeclarativePointValueType + QDeclarativePool + QDeclarativePrivate + QDeclarativeProfilerData + QDeclarativeProfilerService + QDeclarativeProperties + QDeclarativeProperty + QDeclarativePropertyCache + QDeclarativePropertyCacheMethodArguments + QDeclarativePropertyData + QDeclarativePropertyMap + QDeclarativePropertyMapMetaObject + QDeclarativePropertyMapPrivate + QDeclarativePropertyPrivate + QDeclarativePropertyRawData + QDeclarativePropertyValueInterceptor + QDeclarativePropertyValueSource + QDeclarativeProxyMetaObject + QDeclarativeQmldirData + QDeclarativeQtQuick1Module + QDeclarativeQtQuick2Module + QDeclarativeQtQuick2DebugStatesDelegate + QDeclarativeQuaternionValueType + QDeclarativeRectFValueType + QDeclarativeRectValueType + QDeclarativeRefCount + QDeclarativeRefPointer + QDeclarativeRegisterType + QDeclarativeRewrite + QDeclarativeScript + QDeclarativeScriptBlob + QDeclarativeScriptData + QDeclarativeScriptPrivate + QDeclarativeScriptString + QDeclarativeScriptStringPrivate + QDeclarativeSizeFValueType + QDeclarativeSizeValueType + QDeclarativeSqlDatabaseData + QDeclarativeStringConverters + QDeclarativeThread + QDeclarativeThreadPrivate + QDeclarativeTrace + QDeclarativeType + QDeclarativeTypeData + QDeclarativeTypeInfo + QDeclarativeTypeLoader + QDeclarativeTypeModule + QDeclarativeTypeModulePrivate + QDeclarativeTypeModuleVersion + QDeclarativeTypeNameCache + QDeclarativeTypeNotAvailable + QDeclarativeTypePrivate + QDeclarativeTypesExtensionInterface + QDeclarativeV8Function + QDeclarativeV8Handle + QDeclarativeValueType + QDeclarativeValueTypeProxyBinding + QDeclarativeValueTypeFactory + QDeclarativeVector2DValueType + QDeclarativeVector3DValueType + QDeclarativeVector4DValueType + QDeclarativeVME + QDeclarativeVMEGuard + QDeclarativeVMEMetaData + QDeclarativeVMEMetaObject + QDeclarativeVMEMetaObjectEndpoint + QDeclarativeVMEVariant + QDeclarativeVMETypes + QDeclarativeWatcher + QDeclarativeWatchProxy + QDeclarativeXMLHttpRequest + QDeclarativeXMLHttpRequestData + QDeclarative_isFileCaseCorrect + QDeclarative_setParent_noEvent + QQuickProperties + QQuickPropertyCacheMethodArguments + QQuickPropertyData +" + +QUICK_SYMBOLS="\ + QDeclarativeAbstractAnimation + QDeclarativeAbstractAnimationAction + QDeclarativeAbstractAnimationPrivate + QDeclarativeAction + QDeclarativeActionEvent + QDeclarativeAnchors + QDeclarativeAnimationController + QDeclarativeAnimationControllerPrivate + QDeclarativeAnimationGroup + QDeclarativeAnimationGroupPrivate + QDeclarativeAnimationPropertyUpdater + QDeclarativeApplication + QDeclarativeApplicationPrivate + QDeclarativeBehavior + QDeclarativeBehaviorPrivate + QDeclarativeBind + QDeclarativeBindPrivate + QDeclarativeBulkValueAnimator + QDeclarativeBulkValueUpdater + QDeclarativeCachedBezier + QDeclarativeChangeSet + QDeclarativeColorAnimation + QDeclarativeConnections + QDeclarativeConnectionsPrivate + QDeclarativeCurve + QDeclarativeDefaultTextureFactory + QDeclarativeFlick + QDeclarativeFocusPanel + QDeclarativeFolderListModel + QDeclarativeFolderListModelPrivate + QDeclarativeFontLoader + QDeclarativeFontLoaderPrivate + QDeclarativeFontObject + QDeclarativeGestureArea + QDeclarativeGestureAreaParser + QDeclarativeGestureAreaPrivate + QDeclarativeGraphics + QDeclarativeItem + QDeclarativeItemAccessor + QDeclarativeItemChangeListener + QDeclarativeItemKeyFilter + QDeclarativeItemPrivate + QDeclarativeListAccessor + QDeclarativeListCompositor + QDeclarativeListElement + QDeclarativeListModel + QDeclarativeListModelParser + QDeclarativeListModelWorkerAgent + QDeclarativeListView + QDeclarativeNumberAnimation + QDeclarativePackage + QDeclarativePackageAttached + QDeclarativePackagePrivate + QDeclarativeParallelAnimation + QDeclarativeParticle + QDeclarativeParticleMotion + QDeclarativeParticleMotionGravity + QDeclarativeParticleMotionLinear + QDeclarativeParticleMotionWander + QDeclarativeParticles + QDeclarativeParticlesPainter + QDeclarativeParticlesPrivate + QDeclarativePath + QDeclarativePathArc + QDeclarativePathAttribute + QDeclarativePathCatmullRomCurve + QDeclarativePathCubic + QDeclarativePathCurve + QDeclarativePathData + QDeclarativePathElement + QDeclarativePathInterpolator + QDeclarativePathLine + QDeclarativePathPercent + QDeclarativePathPrivate + QDeclarativePathQuad + QDeclarativePathSvg + QDeclarativePauseAnimation + QDeclarativePauseAnimationPrivate + QDeclarativePixmap + QDeclarativePixmapData + QDeclarativePixmapKey + QDeclarativePixmapNull + QDeclarativePixmapReader + QDeclarativePixmapReaderThreadObject + QDeclarativePixmapReply + QDeclarativePixmapStore + QDeclarativePropertyAction + QDeclarativePropertyActionPrivate + QDeclarativePropertyAnimation + QDeclarativePropertyAnimationPrivate + QDeclarativePropertyChanges + QDeclarativePropertyChangesParser + QDeclarativePropertyChangesPrivate + QDeclarativeReplaceSignalHandler + QDeclarativeRevertAction + QDeclarativeRotationAnimation + QDeclarativeRotationAnimationPrivate + QDeclarativeSequentialAnimation + QDeclarativeScriptAction + QDeclarativeScriptActionPrivate + QDeclarativeSetPropertyAnimationAction + QDeclarativeSimpleAction + QDeclarativeSmoothedAnimation + QDeclarativeSmoothedAnimationPrivate + QDeclarativeSpringAnimation + QDeclarativeSpringAnimationPrivate + QDeclarativeState + QDeclarativeStateActions + QDeclarativeStateChange + QDeclarativeStateChangeScript + QDeclarativeStateChangeScriptPrivate + QDeclarativeStateGroup + QDeclarativeStateGroupPrivate + QDeclarativeStateOperation + QDeclarativeStateOperationPrivate + QDeclarativeStatePrivate + QDeclarativeStyledText + QDeclarativeStyledTextImgTag + QDeclarativeStyledTextPrivate + QDeclarativeSystemPalette + QDeclarativeSystemPalettePrivate + QDeclarativeTextureFactory + QDeclarativeTimeLine + QDeclarativeTimeLineCallback + QDeclarativeTimeLineObject + QDeclarativeTimeLinePrivate + QDeclarativeTimeLineValue + QDeclarativeTimeLineValueProxy + QDeclarativeTimeLineValues + QDeclarativeTimer + QDeclarativeTimerPrivate + QDeclarativeTransition + QDeclarativeTransitionInstance + QDeclarativeTransitionManager + QDeclarativeTransitionManagerPrivate + QDeclarativeTransitionPrivate + QDeclarativeUtilModule + QDeclarativeVector3dAnimation + QDeclarativeView + QDeclarativeViewInspector + QDeclarativeViewInspectorPrivate + QDeclarativeViewPrivate + QDeclarativeWebView + QDeclarativeXmlListModel + QDeclarativeXmlListModelPrivate + QDeclarativeXmlListModelRole + QDeclarativeXmlListRange + QDeclarativeXmlQueryEngine + QDeclarativeXmlQueryResult + QDeclarativeXmlQueryThreadObject + QDeclarativeXmlRoleList + QDeclarativeSvgParser + QDeclarativeWorkerScript + QDeclarativeWorkerScriptEngine + QDeclarativeWorkerScriptEnginePrivate +" + +QML_INCLUDE_FILES="\ + qdeclarativeaccessible.h + qdeclarativeaccessors_p.h + qdeclarativebinding_p.h + qdeclarativebinding_p_p.h + qdeclarativeboundsignal_p.h + qdeclarativebuiltinfunctions_p.h + qdeclarativecleanup_p.h + qdeclarativecompiler_p.h + qdeclarativecomponentattached_p.h + qdeclarativecomponent.h + qdeclarativecomponent_p.h + qdeclarativecontext.h + qdeclarativecontext_p.h + qdeclarativecustomparser_p.h + qdeclarativecustomparser_p_p.h + qdeclarativedata_p.h + qdeclarativedebugclient_p.h + qdeclarativedebug.h + qdeclarativedebughelper_p.h + qdeclarativedebugserverconnection_p.h + qdeclarativedebugserver_p.h + qdeclarativedebugservice_p.h + qdeclarativedebugservice_p_p.h + qdeclarativedebugstatesdelegate_p.h + qdeclarativedebugtrace_p.h + qdeclarativedirparser_p.h + qdeclarativeenginedebug_p.h + qdeclarativeenginedebugservice_p.h + qdeclarativeengine.h + qdeclarativeengine_p.h + qdeclarativeerror.h + qdeclarativeexpression.h + qdeclarativeexpression_p.h + qdeclarativeextensioninterface.h + qdeclarativeextensionplugin.h + qdeclarativeglobal_p.h + qdeclarativeguard_p.h + qdeclarative.h + qdeclarativeimageprovider.h + qdeclarativeimport_p.h + qdeclarativeincubator.h + qdeclarativeincubator_p.h + qdeclarativeinfo.h + qdeclarativeinspectorinterface_p.h + qdeclarativeinspectorprotocol.h + qdeclarativeinspectorservice_p.h + qdeclarativeinstruction_p.h + qdeclarativeintegercache_p.h + qdeclarativejsastfwd_p.h + qdeclarativejsast_p.h + qdeclarativejsastvisitor_p.h + qdeclarativejsengine_p.h + qdeclarativejsglobal_p.h + qdeclarativejsgrammar_p.h + qdeclarativejskeywords_p.h + qdeclarativejslexer_p.h + qdeclarativejsmemorypool_p.h + qdeclarativejsparser_p.h + qdeclarativelist.h + qdeclarativelist_p.h + qdeclarativelocale_p.h + qdeclarativemetatype_p.h + qdeclarativenetworkaccessmanagerfactory.h + qdeclarativenotifier_p.h + qdeclarativenullablevalue_p_p.h + qdeclarativeopenmetaobject_p.h + qdeclarativeparserstatus.h + qdeclarativepool_p.h + qdeclarativeprivate.h + qdeclarativeprofilerservice_p.h + qdeclarativepropertycache_p.h + qdeclarativeproperty.h + qdeclarativepropertymap.h + qdeclarativeproperty_p.h + qdeclarativepropertyvalueinterceptor_p.h + qdeclarativepropertyvaluesource.h + qdeclarativeproxymetaobject_p.h + qdeclarativerefcount_p.h + qdeclarativerewrite_p.h + qdeclarativescript_p.h + qdeclarativescriptstring.h + qdeclarativescriptstring_p.h + qdeclarativesqldatabase_p.h + qdeclarativestringconverters_p.h + qdeclarativethread_p.h + qdeclarativetrace_p.h + qdeclarativetypeloader_p.h + qdeclarativetypenamecache_p.h + qdeclarativetypenotavailable_p.h + qdeclarativevaluetype_p.h + qdeclarativevmemetaobject_p.h + qdeclarativevme_p.h + qdeclarativewatcher_p.h + qdeclarativexmlhttprequest_p.h + qdeclarativexmllistmodel_p.h +" + +QUICK_INCLUDE_FILES="\ + qdeclarativeanimation_p.h + qdeclarativeanimation_p_p.h + qdeclarativeanimationcontroller_p.h + qdeclarativeapplication_p.h + qdeclarativebehavior_p.h + qdeclarativebind_p.h + qdeclarativechangeset_p.h + qdeclarativeconnections_p.h + qdeclarativefolderlistmodel.h + qdeclarativefontloader_p.h + qdeclarativelistaccessor_p.h + qdeclarativelistcompositor_p.h + qdeclarativelistmodel_p.h + qdeclarativelistmodel_p_p.h + qdeclarativelistmodelworkeragent_p.h + qdeclarativepackage_p.h + qdeclarativepathinterpolator_p.h + qdeclarativepath_p.h + qdeclarativepath_p_p.h + qdeclarativepixmapcache_p.h + qdeclarativepropertychanges_p.h + qdeclarativesmoothedanimation_p.h + qdeclarativesmoothedanimation_p_p.h + qdeclarativespringanimation_p.h + qdeclarativestategroup_p.h + qdeclarativestateoperations_p.h + qdeclarativestate_p.h + qdeclarativestate_p_p.h + qdeclarativestyledtext_p.h + qdeclarativesvgparser_p.h + qdeclarativesystempalette_p.h + qdeclarativetimeline_p_p.h + qdeclarativetimer_p.h + qdeclarativetransitionmanager_p_p.h + qdeclarativetransition_p.h + qdeclarativeutilmodule_p.h + qdeclarativeworkerscript_p.h +" + +replaceMatch() +{ + SYMBOL="$1" + REPLACEMENT="$2" + echo "Replacing $SYMBOL with $REPLACEMENT:" + + CONTAINERS=$(find "$MODIFY_DIR" ! -path ".git" -type f | xargs grep -l -I "$SYMBOL") + for CONTAINER in $CONTAINERS + do + echo " $CONTAINER" + TMP_FILE="$CONTAINER.tmp" + + sed 's|'"$SYMBOL"'|'"$REPLACEMENT"'|g' <"$CONTAINER" >"$TMP_FILE" + mv "$TMP_FILE" "$CONTAINER" + done + echo +} + +for QML_SYMBOL in $QML_SYMBOLS +do + QML_REPLACEMENT="QQml${QML_SYMBOL#QDeclarative}" + replaceMatch "\" "QtQml/$QML_REPLACEMENT" + replaceMatch "\<$QML_SYMBOL\>" "$QML_REPLACEMENT" +done + +for QUICK_SYMBOL in $QUICK_SYMBOLS +do + QUICK_REPLACEMENT="QQuick${QUICK_SYMBOL#QDeclarative}" + replaceMatch "\" "QtQuick/$QUICK_REPLACEMENT" + replaceMatch "\<$QUICK_SYMBOL\>" "$QUICK_REPLACEMENT" +done + +for QML_INCLUDE_FILE in $QML_INCLUDE_FILES +do + QML_INCLUDE_REPLACEMENT="qqml${QML_INCLUDE_FILE#qdeclarative}" + replaceMatch "\<$QML_INCLUDE_FILE\>" "$QML_INCLUDE_REPLACEMENT" +done + +for QUICK_INCLUDE_FILE in $QUICK_INCLUDE_FILES +do + QUICK_INCLUDE_REPLACEMENT="qquick${QUICK_INCLUDE_FILE#qdeclarative}" + replaceMatch "\<$QUICK_INCLUDE_FILE\>" "$QUICK_INCLUDE_REPLACEMENT" +done + +# Various one-off replacements +replaceMatch "\" "QtQml" +replaceMatch "\") +for CONTAINER in $CONTAINERS +do + echo " $CONTAINER" + TMP_FILE="$CONTAINER.tmp" + + sed 's|\|qml|g' <"$CONTAINER" >"$TMP_FILE" + mv "$TMP_FILE" "$CONTAINER" +done +echo + +echo "Replacements complete" +exit 0 diff --git a/doc/src/localstorage/localstorage.qdoc b/doc/src/localstorage/localstorage.qdoc index bee491f9b9..406de25339 100644 --- a/doc/src/localstorage/localstorage.qdoc +++ b/doc/src/localstorage/localstorage.qdoc @@ -43,7 +43,7 @@ provide the ability to access local storage in an SQL database. These databases are user-specific and QML-specific, but accessible to all QML applications. They are stored in the \c Databases subdirectory -of QDeclarativeEngine::offlineStoragePath(), currently as SQLite databases. +of QQmlEngine::offlineStoragePath(), currently as SQLite databases. Database connections are automatically closed during Javascript garbage collection. diff --git a/doc/src/qml/basictypes.qdoc b/doc/src/qml/basictypes.qdoc index 150383fdc2..0f66a96731 100644 --- a/doc/src/qml/basictypes.qdoc +++ b/doc/src/qml/basictypes.qdoc @@ -180,7 +180,7 @@ \div{float-right} \inlineimage declarative-colors.png \enddiv - \snippet doc/src/snippets/declarative/colors.qml colors + \snippet doc/src/snippets/qml/colors.qml colors Or with the \l{QML:Qt::rgba()}{Qt.rgba()}, \l{QML:Qt::hsla()}{Qt.hsla()}, \l{QML:Qt::darker()}{Qt.darker()}, \l{QML:Qt::lighter()}{Qt.lighter()} or \l{QML:Qt::tint()}{Qt.tint()} functions: diff --git a/doc/src/qml/c++models.qdoc b/doc/src/qml/c++models.qdoc index e2498134fe..943c79c184 100644 --- a/doc/src/qml/c++models.qdoc +++ b/doc/src/qml/c++models.qdoc @@ -57,7 +57,7 @@ models. \bold{Note:} There is no way for the view to know that the contents of a QStringList have changed. If the QStringList changes, it will be necessary to reset - the model by calling QDeclarativeContext::setContextProperty() again. + the model by calling QQmlContext::setContextProperty() again. \section1 QObjectList-based model @@ -92,7 +92,7 @@ models. Note: There is no way for the view to know that the contents of a QList have changed. If the QList changes, it will be necessary to reset - the model by calling QDeclarativeContext::setContextProperty() again. + the model by calling QQmlContext::setContextProperty() again. \section1 QAbstractItemModel @@ -160,10 +160,10 @@ models. \section1 Exposing C++ Data Models to QML -The above examples use QDeclarativeContext::setContextProperty() to set +The above examples use QQmlContext::setContextProperty() to set model values directly in QML components. An alternative to this is to register the C++ model class as a QML type from a QML C++ plugin using -QDeclarativeExtensionPlugin. This would allow the model classes to be +QQmlExtensionPlugin. This would allow the model classes to be created directly as elements within QML: \table @@ -171,7 +171,7 @@ created directly as elements within QML: \o \code -class MyModelPlugin : public QDeclarativeExtensionPlugin +class MyModelPlugin : public QQmlExtensionPlugin { public: void registerTypes(const char *uri) diff --git a/doc/src/qml/codingconventions.qdoc b/doc/src/qml/codingconventions.qdoc index 89fdfd59f9..9e1ce34c2c 100644 --- a/doc/src/qml/codingconventions.qdoc +++ b/doc/src/qml/codingconventions.qdoc @@ -52,7 +52,7 @@ For better readability, we separate these different parts with an empty line. For example, a hypothetical \i photo QML object would look like this: -\snippet doc/src/snippets/declarative/codingconventions/photo.qml 0 +\snippet doc/src/snippets/qml/codingconventions/photo.qml 0 \section1 Grouped Properties @@ -62,11 +62,11 @@ we use the \i {group notation} rather than the \i {dot notation} to improve read For example, this: -\snippet doc/src/snippets/declarative/codingconventions/dotproperties.qml 0 +\snippet doc/src/snippets/qml/codingconventions/dotproperties.qml 0 can be written like this: -\snippet doc/src/snippets/declarative/codingconventions/dotproperties.qml 1 +\snippet doc/src/snippets/qml/codingconventions/dotproperties.qml 1 \section1 Private Properties @@ -78,7 +78,7 @@ the implementation. As a convention, private properties begin with two accessible but is not meant for public use. Note that QML and JavaScript will grant the user access to these properties. -\snippet doc/src/snippets/declarative/codingconventions/private.qml 0 +\snippet doc/src/snippets/qml/codingconventions/private.qml 0 \section1 Lists @@ -89,30 +89,30 @@ For example, it is very common for a component to only have one state. In this case, instead of: -\snippet doc/src/snippets/declarative/codingconventions/lists.qml 0 +\snippet doc/src/snippets/qml/codingconventions/lists.qml 0 we will write this: -\snippet doc/src/snippets/declarative/codingconventions/lists.qml 1 +\snippet doc/src/snippets/qml/codingconventions/lists.qml 1 \section1 JavaScript Code If the script is a single expression, we recommend writing it inline: -\snippet doc/src/snippets/declarative/codingconventions/javascript.qml 0 +\snippet doc/src/snippets/qml/codingconventions/javascript.qml 0 If the script is only a couple of lines long, we generally use a block: -\snippet doc/src/snippets/declarative/codingconventions/javascript.qml 1 +\snippet doc/src/snippets/qml/codingconventions/javascript.qml 1 If the script is more than a couple of lines long or can be used by different objects, we recommend creating a function and calling it like this: -\snippet doc/src/snippets/declarative/codingconventions/javascript.qml 2 +\snippet doc/src/snippets/qml/codingconventions/javascript.qml 2 For long scripts, we will put the functions in their own JavaScript file and import it like this: -\snippet doc/src/snippets/declarative/codingconventions/javascript-imports.qml 0 +\snippet doc/src/snippets/qml/codingconventions/javascript-imports.qml 0 */ diff --git a/doc/src/qml/debugging.qdoc b/doc/src/qml/debugging.qdoc index 520e23abb5..562464a419 100644 --- a/doc/src/qml/debugging.qdoc +++ b/doc/src/qml/debugging.qdoc @@ -148,11 +148,11 @@ If you set \c {QML_IMPORT_TRACE=1} before running the \l {QML Viewer} (or your QML C++ application), you will see output similar to this: \code -QDeclarativeImportDatabase::addImportPath "/qt-sdk/imports" -QDeclarativeImportDatabase::addImportPath "/qt-sdk/bin/QMLViewer.app/Contents/MacOS" -QDeclarativeImportDatabase::addToImport 0x106237370 "." -1.-1 File as "" -QDeclarativeImportDatabase::addToImport 0x106237370 "Qt" 4.7 Library as "" -QDeclarativeImportDatabase::resolveType "Rectangle" = "QDeclarativeRectangle" +QQmlImportDatabase::addImportPath "/qt-sdk/imports" +QQmlImportDatabase::addImportPath "/qt-sdk/bin/QMLViewer.app/Contents/MacOS" +QQmlImportDatabase::addToImport 0x106237370 "." -1.-1 File as "" +QQmlImportDatabase::addToImport 0x106237370 "Qt" 4.7 Library as "" +QQmlImportDatabase::resolveType "Rectangle" = "QDeclarativeRectangle" \endcode diff --git a/doc/src/qml/dynamicobjects.qdoc b/doc/src/qml/dynamicobjects.qdoc index e3d9adb49a..c50f9dd337 100644 --- a/doc/src/qml/dynamicobjects.qdoc +++ b/doc/src/qml/dynamicobjects.qdoc @@ -80,31 +80,31 @@ the component. This function can take one or two arguments: Here is an example. First there is \c Sprite.qml, which defines a simple QML component: -\snippet doc/src/snippets/declarative/Sprite.qml 0 +\snippet doc/src/snippets/qml/Sprite.qml 0 Our main application file, \c main.qml, imports a \c componentCreation.js JavaScript file that will create \c Sprite objects: -\snippet doc/src/snippets/declarative/createComponent.qml 0 +\snippet doc/src/snippets/qml/createComponent.qml 0 Here is \c componentCreation.js. Notice it checks whether the component \l{Component::status}{status} is \c Component.Ready before calling \l {Component::createObject()}{createObject()} in case the QML file is loaded over a network and thus is not ready immediately. -\snippet doc/src/snippets/declarative/componentCreation.js vars +\snippet doc/src/snippets/qml/componentCreation.js vars \codeline -\snippet doc/src/snippets/declarative/componentCreation.js func -\snippet doc/src/snippets/declarative/componentCreation.js remote -\snippet doc/src/snippets/declarative/componentCreation.js func-end +\snippet doc/src/snippets/qml/componentCreation.js func +\snippet doc/src/snippets/qml/componentCreation.js remote +\snippet doc/src/snippets/qml/componentCreation.js func-end \codeline -\snippet doc/src/snippets/declarative/componentCreation.js finishCreation +\snippet doc/src/snippets/qml/componentCreation.js finishCreation If you are certain the QML file to be loaded is a local file, you could omit the \c finishCreation() function and call \l {Component::createObject()}{createObject()} immediately: -\snippet doc/src/snippets/declarative/componentCreation.js func -\snippet doc/src/snippets/declarative/componentCreation.js local -\snippet doc/src/snippets/declarative/componentCreation.js func-end +\snippet doc/src/snippets/qml/componentCreation.js func +\snippet doc/src/snippets/qml/componentCreation.js local +\snippet doc/src/snippets/qml/componentCreation.js func-end Notice in both instances, \l {Component::createObject()}{createObject()} is called with \c appWindow passed as an argument so that the created object will become a child of the @@ -124,7 +124,7 @@ use the signal \c connect() method. See If the QML is not defined until runtime, you can create a QML item from a string of QML using the \l{QML:Qt::createQmlObject()}{Qt.createQmlObject()} function, as in the following example: -\snippet doc/src/snippets/declarative/createQmlObject.qml 0 +\snippet doc/src/snippets/qml/createQmlObject.qml 0 The first argument is the string of QML to create. Just like in a new file, you will need to import any types you wish to use. The second argument is the parent item for the new item; @@ -145,7 +145,7 @@ The actual creation context depends on how an item is created: \list \o If \l {QML:Qt::createComponent()}{Qt.createComponent()} is used, the creation context - is the QDeclarativeContext in which this method is called + is the QQmlContext in which this method is called \o If \l{QML:Qt::createQmlObject()}{Qt.createQmlObject()} if called, the creation context is the context of the parent item passed to this method \o If a \c {Component{}} item is defined and \l {Component::createObject()}{createObject()} @@ -181,8 +181,8 @@ component. Each instance runs a NumberAnimation, and when the animation has fini \o \c SelfDestroyingRect.qml \row -\o \snippet doc/src/snippets/declarative/dynamicObjects-destroy.qml 0 -\o \snippet doc/src/snippets/declarative/SelfDestroyingRect.qml 0 +\o \snippet doc/src/snippets/qml/dynamicObjects-destroy.qml 0 +\o \snippet doc/src/snippets/qml/SelfDestroyingRect.qml 0 \endtable @@ -209,6 +209,6 @@ destroyed if they were dynamically created. Objects created with \l{QML:Qt::createQmlObject()}{Qt.createQmlObject()} can similarly be destroyed using \c destroy(): -\snippet doc/src/snippets/declarative/createQmlObject.qml 0 -\snippet doc/src/snippets/declarative/createQmlObject.qml destroy +\snippet doc/src/snippets/qml/createQmlObject.qml 0 +\snippet doc/src/snippets/qml/createQmlObject.qml destroy */ diff --git a/doc/src/qml/extending-tutorial.qdoc b/doc/src/qml/extending-tutorial.qdoc index 00f4bb5691..b995c32cca 100644 --- a/doc/src/qml/extending-tutorial.qdoc +++ b/doc/src/qml/extending-tutorial.qdoc @@ -100,14 +100,14 @@ Here is our \c PieChart class, defined in \c piechart.h: \snippet declarative/tutorials/extending/chapter1-basics/piechart.h 0 -The class inherits from QDeclarativeItem because we want to override -QDeclarativeItem::paint() in order to draw. If the class just represented some +The class inherits from QQuickItem because we want to override +QQuickItem::paint() in order to draw. If the class just represented some data type and was not an item that actually needed to be displayed, it could simply inherit from QObject. Or, if we want to extend the functionality of an existing QObject-based class, it could inherit from that class instead. The \c PieChart class defines the two properties, \c name and \c color, with the Q_PROPERTY macro, -and overrides QDeclarativeItem::paint(). The class implementation in \c piechart.cpp +and overrides QQuickItem::paint(). The class implementation in \c piechart.cpp simply sets and returns the \c m_name and \c m_color values as appropriate, and implements \c paint() to draw a simple pie chart. It also turns off the QGraphicsItem::ItemHasNoContents flag to enable painting: @@ -127,7 +127,7 @@ converted to a QColor object for the PieChart \c color property. Automatic conve provided for various other \l {QML Basic Types}{basic types}; for example, a string like "640x480" can be automatically converted to a QSize value. -We'll also create a C++ application that uses a QDeclarativeView to run and +We'll also create a C++ application that uses a QQuickView to run and display \c app.qml. The application must register the \c PieChart type using the qmlRegisterType() function, to allow it to be used from QML. If you don't register the type, \c app.qml won't be able to create a \c PieChart. @@ -265,7 +265,7 @@ int-type property to store an identifier for each chart: \code // C++ - class PieChart : public QDeclarativeItem + class PieChart : public QQuickItem { Q_PROPERTY(int chartId READ chartId WRITE setChartId NOTIFY chartIdChanged) ... @@ -306,7 +306,7 @@ we assign an \c PieSlice value which itself contains a \c color: \snippet declarative/tutorials/extending/chapter4-customPropertyTypes/app.qml 0 -Like \c PieChart, this new \c PieSlice type inherits from QDeclarativeItem and declares +Like \c PieChart, this new \c PieSlice type inherits from QQuickItem and declares its properties with Q_PROPERTY(): \snippet declarative/tutorials/extending/chapter4-customPropertyTypes/pieslice.h 0 @@ -324,7 +324,7 @@ and associated method signatures: There is one thing to be aware of when implementing \c setPieSlice(). The \c PieSlice is a visual item, so it must be set as a child of the \c PieChart using -QDeclarativeItem::setParentItem() so that the \c PieChart knows to paint this child +QQuickItem::setParentItem() so that the \c PieChart knows to paint this child item when its contents are drawn: \snippet declarative/tutorials/extending/chapter4-customPropertyTypes/piechart.cpp 0 @@ -359,7 +359,7 @@ have a \c slices property that accepts a list of \c PieSlice items: \image extending-tutorial-chapter5.png To do this, we replace the \c pieSlice property in \c PieChart with a \c slices property, -declared as a QDeclarativeListProperty type. The QDeclarativeListProperty class enables the +declared as a QQmlListProperty type. The QQmlListProperty class enables the creation of list properties in QML extensions. We replace the \c pieSlice() function with a \c slices() function that returns a list of slices, and add an internal \c append_slice() function (discussed below). We also use a QList to @@ -372,9 +372,9 @@ store the internal list of slices as \c m_slices: \snippet declarative/tutorials/extending/chapter5-listproperties/piechart.h 2 Although the \c slices property does not have an associated \c WRITE function, -it is still modifiable because of the way QDeclarativeListProperty works. +it is still modifiable because of the way QQmlListProperty works. In the \c PieChart implementation, we implement \c PieChart::slices() to -return a QDeclarativeListProperty value and indicate that the internal +return a QQmlListProperty value and indicate that the internal \c PieChart::append_slice() function is to be called whenever a request is made from QML to add items to the list: @@ -382,7 +382,7 @@ to add items to the list: The \c append_slice() function simply sets the parent item as before, and adds the new item to the \c m_slices list. As you can see, the append function for a -QDeclarativeListProperty is called with two arguments: the list property, and +QQmlListProperty is called with two arguments: the list property, and the item that is to be appended. The \c PieSlice class has also been modified to include \c fromAngle and \c angleSpan @@ -400,7 +400,7 @@ The complete code can be seen in the updated \c examples/tutorials/extending/cha \example declarative/tutorials/extending/chapter6-plugins Currently the \c PieChart and \c PieSlice types are used by \c app.qml, -which is displayed using a QDeclarativeView in a C++ application. An alternative +which is displayed using a QQuickView in a C++ application. An alternative way to use our QML extension is to create a plugin library to make it available to the QML engine. This allows \c app.qml to be loaded with the \l {QML Viewer} (or some other QML \l{Qt Declarative UI Runtime}{runtime} application) instead of writing a \c main.cpp file and @@ -414,8 +414,8 @@ To create a plugin library, we need: \o A \l{Writing a qmldir file}{qmldir} file that tells the QML engine to load the plugin \endlist -First, we create a plugin class named \c ChartsPlugin. It subclasses QDeclarativeExtensionPlugin -and registers our QML types in the inherited \l{QDeclarativeExtensionPlugin::}{registerTypes()} method. It also calls +First, we create a plugin class named \c ChartsPlugin. It subclasses QQmlExtensionPlugin +and registers our QML types in the inherited \l{QQmlExtensionPlugin::}{registerTypes()} method. It also calls Q_EXPORT_PLUGIN2 for Qt's \l{How to Create Qt Plugins}{plugin system}. Here is the \c ChartsPlugin definition in \c chartsplugin.h: @@ -464,7 +464,7 @@ In this tutorial, we've shown the basic steps for creating a QML extension: \o Add callable methods using Q_INVOKABLE or Qt slots, and connect to Qt signals with an \c onSignal syntax \o Add property bindings by defining \l{Qt's Property System}{NOTIFY} signals \o Define custom property types if the built-in types are not sufficient -\o Define list property types using QDeclarativeListProperty +\o Define list property types using QQmlListProperty \o Create a plugin library by defining a Qt plugin and writing a \c qmldir file \endlist diff --git a/doc/src/qml/integrating.qdoc b/doc/src/qml/integrating.qdoc index 7cd15a4fd4..2a88246006 100644 --- a/doc/src/qml/integrating.qdoc +++ b/doc/src/qml/integrating.qdoc @@ -38,13 +38,13 @@ depending on the characteristics of your existing UI code. \section1 Integrating with a \l{QWidget}-based UI If you have an existing QWidget-based UI, QML widgets can be integrated into -it using QDeclarativeView. QDeclarativeView is a subclass of QWidget so you +it using QQuickView. QQuickView is a subclass of QWidget so you can add it to your user interface like any other QWidget. Use -QDeclarativeView::setSource() to load a QML file into the view, then add the +QQuickView::setSource() to load a QML file into the view, then add the view to your UI: \code -QDeclarativeView *qmlView = new QDeclarativeView; +QQuickView *qmlView = new QQuickView; qmlView->setSource(QUrl::fromLocalFile("myqml.qml")); QWidget *widget = myExistingWidget(); @@ -52,11 +52,11 @@ QVBoxLayout *layout = new QVBoxLayout(widget); layout->addWidget(qmlView); \endcode -The one drawback to this approach is that QDeclarativeView is slower to initialize -and uses more memory than a QWidget, and creating large numbers of QDeclarativeView +The one drawback to this approach is that QQuickView is slower to initialize +and uses more memory than a QWidget, and creating large numbers of QQuickView objects may lead to performance degradation. If this is the case, it may be better to rewrite your widgets in QML, and load the widgets from a main QML widget -instead of using QDeclarativeView. +instead of using QQuickView. Keep in mind that QWidgets were designed for a different type of user interface than QML, so it is not always a good idea to port a QWidget-based application to @@ -71,7 +71,7 @@ of simple and dynamic elements. If you have an existing UI based on the \l{Graphics View Framework}, you can integrate QML widgets directly into your QGraphicsScene. Use -QDeclarativeComponent to create a QGraphicsObject from a QML file, and +QQmlComponent to create a QGraphicsObject from a QML file, and place the graphics object into your scene using \l{QGraphicsScene::addItem()}, or reparent it to an item already in the \l{QGraphicsScene}. @@ -79,8 +79,8 @@ For example: \code QGraphicsScene* scene = myExistingGraphicsScene(); -QDeclarativeEngine *engine = new QDeclarativeEngine; -QDeclarativeComponent component(engine, QUrl::fromLocalFile("myqml.qml")); +QQmlEngine *engine = new QQmlEngine; +QQmlComponent component(engine, QUrl::fromLocalFile("myqml.qml")); QGraphicsObject *object = qobject_cast(component.create()); scene->addItem(object); diff --git a/doc/src/qml/javascriptblocks.qdoc b/doc/src/qml/javascriptblocks.qdoc index 4cc98f1d7a..0c1d4c284c 100644 --- a/doc/src/qml/javascriptblocks.qdoc +++ b/doc/src/qml/javascriptblocks.qdoc @@ -200,8 +200,8 @@ in \c script.js: \table \row -\o \snippet doc/src/snippets/declarative/integrating-javascript/connectjs.qml 0 -\o \snippet doc/src/snippets/declarative/integrating-javascript/script.js 0 +\o \snippet doc/src/snippets/qml/integrating-javascript/connectjs.qml 0 +\o \snippet doc/src/snippets/qml/integrating-javascript/script.js 0 \endtable The \c jsFunction() will now be called whenever MouseArea's \c clicked signal is emitted. @@ -222,7 +222,7 @@ Both relative and absolute JavaScript URLs can be imported. In the case of a relative URL, the location is resolved relative to the location of the \l {QML Document} that contains the import. If the script file is not accessible, an error will occur. If the JavaScript needs to be fetched from a network -resource, the component's \l {QDeclarativeComponent::status()}{status} is set to +resource, the component's \l {QQmlComponent::status()}{status} is set to "Loading" until the script has been downloaded. Imported JavaScript files are always qualified using the "as" keyword. The @@ -243,10 +243,10 @@ which in turn can call \c factorial() in \c factorial.js, as it has included \table \row -\o {1,2} \snippet doc/src/snippets/declarative/integrating-javascript/includejs/app.qml 0 -\o \snippet doc/src/snippets/declarative/integrating-javascript/includejs/script.js 0 +\o {1,2} \snippet doc/src/snippets/qml/integrating-javascript/includejs/app.qml 0 +\o \snippet doc/src/snippets/qml/integrating-javascript/includejs/script.js 0 \row -\o \snippet doc/src/snippets/declarative/integrating-javascript/includejs/factorial.js 0 +\o \snippet doc/src/snippets/qml/integrating-javascript/includejs/factorial.js 0 \endtable Notice that calling \l {QML:Qt::include()}{Qt.include()} imports all functions from @@ -479,11 +479,11 @@ themselves. For the following examples, imagine that we have defined the following class: -\snippet doc/src/snippets/declarative/integrating-javascript/scarceresources/avatarExample.h 0 +\snippet doc/src/snippets/qml/integrating-javascript/scarceresources/avatarExample.h 0 and that we have registered it with the QML type-system as follows: -\snippet doc/src/snippets/declarative/integrating-javascript/scarceresources/avatarExample.cpp 0 +\snippet doc/src/snippets/qml/integrating-javascript/scarceresources/avatarExample.cpp 0 The AvatarExample class has a property which is a pixmap. When the property is accessed in JavaScript scope, a copy of the resource will be created and @@ -498,9 +498,9 @@ unless the client explicitly preserves it. In the following example, the scarce resource will be automatically released after the binding evaluation is complete. -\snippet doc/src/snippets/declarative/integrating-javascript/scarceresources/exampleOne.qml 0 +\snippet doc/src/snippets/qml/integrating-javascript/scarceresources/exampleOne.qml 0 -\snippet doc/src/snippets/declarative/integrating-javascript/scarceresources/avatarExample.cpp 1 +\snippet doc/src/snippets/qml/integrating-javascript/scarceresources/avatarExample.cpp 1 \section2 Example Two: Automatic Release Prevented By Reference @@ -509,9 +509,9 @@ released after the binding expression evaluation is complete, because there is a property var referencing the scarce resource. -\snippet doc/src/snippets/declarative/integrating-javascript/scarceresources/exampleTwo.qml 0 +\snippet doc/src/snippets/qml/integrating-javascript/scarceresources/exampleTwo.qml 0 -\snippet doc/src/snippets/declarative/integrating-javascript/scarceresources/avatarExample.cpp 2 +\snippet doc/src/snippets/qml/integrating-javascript/scarceresources/avatarExample.cpp 2 \section2 Example Three: Explicit Preservation @@ -519,11 +519,11 @@ In this example, the resource must be explicitly preserved in order to prevent the declarative engine from automatically releasing the resource after evaluation of the imported script. -\snippet doc/src/snippets/declarative/integrating-javascript/scarceresources/exampleThree.js 0 +\snippet doc/src/snippets/qml/integrating-javascript/scarceresources/exampleThree.js 0 -\snippet doc/src/snippets/declarative/integrating-javascript/scarceresources/exampleThree.qml 0 +\snippet doc/src/snippets/qml/integrating-javascript/scarceresources/exampleThree.qml 0 -\snippet doc/src/snippets/declarative/integrating-javascript/scarceresources/avatarExample.cpp 3 +\snippet doc/src/snippets/qml/integrating-javascript/scarceresources/avatarExample.cpp 3 \section2 Example Four: Explicit Destruction @@ -532,11 +532,11 @@ scarce resource variant. This example shows how a client may free system resources by releasing the scarce resource held in a JavaScript object, if required, during evaluation of a JavaScript expression. -\snippet doc/src/snippets/declarative/integrating-javascript/scarceresources/exampleFour.js 0 +\snippet doc/src/snippets/qml/integrating-javascript/scarceresources/exampleFour.js 0 -\snippet doc/src/snippets/declarative/integrating-javascript/scarceresources/exampleFour.qml 0 +\snippet doc/src/snippets/qml/integrating-javascript/scarceresources/exampleFour.qml 0 -\snippet doc/src/snippets/declarative/integrating-javascript/scarceresources/avatarExample.cpp 4 +\snippet doc/src/snippets/qml/integrating-javascript/scarceresources/avatarExample.cpp 4 \section2 Example Five: Explicit Destruction And JavaScript References @@ -546,8 +546,8 @@ to one scarce resource is held, and the client calls destroy() on one of those references (to explicitly release the scarce resource), all of the references will be affected. -\snippet doc/src/snippets/declarative/integrating-javascript/scarceresources/exampleFive.qml 0 +\snippet doc/src/snippets/qml/integrating-javascript/scarceresources/exampleFive.qml 0 -\snippet doc/src/snippets/declarative/integrating-javascript/scarceresources/avatarExample.cpp 5 +\snippet doc/src/snippets/qml/integrating-javascript/scarceresources/avatarExample.cpp 5 */ diff --git a/doc/src/qml/modules.qdoc b/doc/src/qml/modules.qdoc index f75c03301c..27f8ae8fb1 100644 --- a/doc/src/qml/modules.qdoc +++ b/doc/src/qml/modules.qdoc @@ -45,14 +45,14 @@ example, an \c import statement is required to use: \list \o A component defined in another QML file that is not in the same directory \o A component defined in a QML file located on a remote server -\o A \l{QDeclarativeExtensionPlugin}{QML extension plugin} library (unless the plugin is installed in the same directory) +\o A \l{QQmlExtensionPlugin}{QML extension plugin} library (unless the plugin is installed in the same directory) \o A JavaScript file (note this must be imported using \l {#namespaces}{named imports}) \endlist An \c import statement includes the module name, and possibly a version number. This can be seen in the snippet commonly found at the top of QML files: -\snippet doc/src/snippets/declarative/imports/qtquick-1.0.qml import +\snippet doc/src/snippets/qml/imports/qtquick-1.0.qml import This imports version 1.0 of the "QtQuick" module into the global namespace. (The QML library itself must be imported to use any of the \l {QML Elements}, as they @@ -111,7 +111,7 @@ Window { Similarly, if the directory resided on a network source, it could be imported like this: -\snippet doc/src/snippets/declarative/imports/network-imports.qml imports +\snippet doc/src/snippets/qml/imports/network-imports.qml imports A located module can also be imported as a network resource if it has a \l{Writing a qmldir file}{qmldir file} in the directory that specifies the QML files @@ -145,7 +145,7 @@ a later version was used, as the \c qmldir file specifies that these elements are only available in the 1.0 version. Note that modules imported as a network resource allow only access to components -defined in QML files; components defined by C++ \l{QDeclarativeExtensionPlugin}{QML extension plugins} +defined in QML files; components defined by C++ \l{QQmlExtensionPlugin}{QML extension plugins} are not available. @@ -153,7 +153,7 @@ are not available. \section1 Installed Modules Installed modules are modules that are made available through the QML import path, -as defined by QDeclarativeEngine::importPathList(), or modules defined within +as defined by QQmlEngine::importPathList(), or modules defined within C++ application code. An installed module is referred to by a URI, which allows the module to be imported from QML code without specifying a complete filesystem path or network resource URL. @@ -161,7 +161,7 @@ path or network resource URL. When importing an installed module, an un-quoted URI is used, with a mandatory version number: -\snippet doc/src/snippets/declarative/imports/installed-module.qml imports +\snippet doc/src/snippets/qml/imports/installed-module.qml imports When a module is imported, the QML engine searches the QML import path for a matching module. The root directory of the module must contain a @@ -177,7 +177,7 @@ module could be located under \c com/nokia/qml/mymodule.2/qmldir or \c com/nokia/qml/mymodule.2.1/qmldir. The engine will automatically load the module which matches best. -The import path, as returned by QDeclarativeEngine::importPathList(), defines the default +The import path, as returned by QQmlEngine::importPathList(), defines the default locations to be searched by the QML engine for a matching module. By default, this list contains: @@ -187,7 +187,7 @@ contains: \o Paths specified by the \c QML_IMPORT_PATH environment variable \endlist -Additional import paths can be added through QDeclarativeEngine::addImportPath() or the +Additional import paths can be added through QQmlEngine::addImportPath() or the \c QML_IMPORT_PATH environment variable. When running the \l {QML Viewer}, you can also use the \c -I option to add an import path. @@ -227,7 +227,7 @@ as \c http://www.some-server.com/qml and this URL was added to the QML import pa QML code would work just the same. Note that modules imported as a network resource allow only access to components -defined in QML files; components defined by C++ \l{QDeclarativeExtensionPlugin}{QML extension plugins} +defined in QML files; components defined by C++ \l{QQmlExtensionPlugin}{QML extension plugins} are not available. @@ -244,10 +244,10 @@ qmlRegisterType("Charts", 1, 0, "PieChart"); This allows the application's QML files to use the \c PieChart type by importing the declared \c Charts module: -\snippet doc/src/snippets/declarative/imports/chart.qml import +\snippet doc/src/snippets/qml/imports/chart.qml import -For \l{QDeclarativeExtensionPlugin}{QML plugins}, the -module URI is automatically passed to QDeclarativeExtensionPlugin::registerTypes(). This method +For \l{QQmlExtensionPlugin}{QML plugins}, the +module URI is automatically passed to QQmlExtensionPlugin::registerTypes(). This method can be reimplemented by the developer to register the necessary types for the module. Below is the \c registerTypes() implementation from the \l{declarative/cppextensions/plugins}{QML plugins} example: @@ -257,7 +257,7 @@ example: Once the plugin is built and installed, and includes a \l{Writing a qmldir file}{qmldir file}, the module can be imported from QML, like this: -\snippet doc/src/snippets/declarative/imports/timeexample.qml import +\snippet doc/src/snippets/qml/imports/timeexample.qml import Unlike QML types defined by QML files, a QML type defined in a C++ extension plugin cannot be loaded by a module that is imported as a network resource. @@ -271,15 +271,15 @@ By default, when a module is imported, its contents are imported into the global To import a module into a specific namespace, use the \i as keyword: -\snippet doc/src/snippets/declarative/imports/named-imports.qml imports +\snippet doc/src/snippets/qml/imports/named-imports.qml imports Types from these modules can then only be used when qualified by the namespace: -\snippet doc/src/snippets/declarative/imports/named-imports.qml imported items +\snippet doc/src/snippets/qml/imports/named-imports.qml imported items Multiple modules can be imported into the same namespace in the same way that multiple modules can be imported into the global namespace: -\snippet doc/src/snippets/declarative/imports/merged-named-imports.qml imports +\snippet doc/src/snippets/qml/imports/merged-named-imports.qml imports \section2 JavaScript Files @@ -381,14 +381,14 @@ into a Namespace exported by the module. The contents of the script file are ma available inside the namespace , which has the version number . -\bold {plugin []} lines are used to add \l{QDeclarativeExtensionPlugin}{QML C++ plugins} to the module. is the name of the library. It is usually not the same as the file name +\bold {plugin []} lines are used to add \l{QQmlExtensionPlugin}{QML C++ plugins} to the module. is the name of the library. It is usually not the same as the file name of the plugin binary, which is platform dependent; e.g. the library \c MyAppTypes would produce \c libMyAppTypes.so on Linux and \c MyAppTypes.dll on Windows. is an optional argument specifying either an absolute path to the directory containing the plugin file, or a relative path from the directory containing the \c qmldir file to the directory containing the plugin file. By default the engine searches for the plugin library in the directory that contains the \c qmldir -file. The plugin search path can be queried with QDeclarativeEngine::pluginPathList() and modified using QDeclarativeEngine::addPluginPath(). When running the \l {QML Viewer}, use the \c -P option to add paths to the plugin search path. +file. The plugin search path can be queried with QQmlEngine::pluginPathList() and modified using QQmlEngine::addPluginPath(). When running the \l {QML Viewer}, use the \c -P option to add paths to the plugin search path. \bold {typeinfo } lines add \l{Writing a qmltypes file}{type description files} to the module that can be read by QML tools such as Qt Creator to get information about the @@ -434,7 +434,7 @@ to \c /tmp/imports/My/Module/qmldir to register it. While the qmldump tool covers most cases, it does not work if: \list -\o The plugin uses a \l{QDeclarativeCustomParser}. The component that uses +\o The plugin uses a \l{QQmlCustomParser}. The component that uses the custom parser will not get its members documented. \o The plugin can not be loaded. In particular if you cross-compiled the plugin for a different architecture, qmldump will not be able to @@ -456,7 +456,7 @@ Module { // The name is a unique identifier used to refer to this type. // It is recommended you simply use the C++ type name. - name: "QDeclarativeAbstractAnimation" + name: "QQuickAbstractAnimation" // The name of the prototype Component. prototype: "QObject" @@ -492,12 +492,12 @@ Module { Property { name: "animations"; - type: "QDeclarativeAbstractAnimation" + type: "QQuickAbstractAnimation" // defaults to false, whether this property is read only isReadonly: true // defaults to false, whether the type of this property was a pointer in C++ isPointer: true - // defaults to false: whether the type actually is a QDeclarativeListProperty + // defaults to false: whether the type actually is a QQmlListProperty isList: true // defaults to 0: the meta object revision that introduced this property revision: 1 diff --git a/doc/src/qml/network.qdoc b/doc/src/qml/network.qdoc index 15a17203c3..71f42a4bfe 100644 --- a/doc/src/qml/network.qdoc +++ b/doc/src/qml/network.qdoc @@ -118,11 +118,11 @@ See the \tt examples/declarative/flickr for a real demonstration of this. \section1 Configuring the Network Access Manager -All network access from QML is managed by a QNetworkAccessManager set on the QDeclarativeEngine which executes the QML. +All network access from QML is managed by a QNetworkAccessManager set on the QQmlEngine which executes the QML. By default, this is an unmodified Qt QNetworkAccessManager. You may set a different manager by -providing a QDeclarativeNetworkAccessManagerFactory and setting it via -QDeclarativeEngine::setNetworkAccessManagerFactory(). -For example, the \l {QML Viewer} sets a QDeclarativeNetworkAccessManagerFactory which +providing a QQmlNetworkAccessManagerFactory and setting it via +QQmlEngine::setNetworkAccessManagerFactory(). +For example, the \l {QML Viewer} sets a QQmlNetworkAccessManagerFactory which creates QNetworkAccessManager that trusts HTTP Expiry headers to avoid network cache checks, allows HTTP Pipelining, adds a persistent HTTP CookieJar, a simple disk cache, and supports proxy settings. @@ -134,7 +134,7 @@ the executable using \l{The Qt Resource System}. Using this, an executable can r that is compiled into the executable: \code - QDeclarativeView *canvas = new QDeclarativeView; + QQuickView *canvas = new QQuickView; canvas->setUrl(QUrl("qrc:/dial.qml")); \endcode diff --git a/doc/src/qml/propertybinding.qdoc b/doc/src/qml/propertybinding.qdoc index b89b3d7a61..6dd862f55b 100644 --- a/doc/src/qml/propertybinding.qdoc +++ b/doc/src/qml/propertybinding.qdoc @@ -44,10 +44,10 @@ The syntax for properties is: Elements already possess useful properties but, to create custom properties, precede the property name with the keyword \c property. -\snippet doc/src/snippets/declarative/properties.qml parent begin -\snippet doc/src/snippets/declarative/properties.qml inherited properties -\snippet doc/src/snippets/declarative/properties.qml custom properties -\snippet doc/src/snippets/declarative/properties.qml parent end +\snippet doc/src/snippets/qml/properties.qml parent begin +\snippet doc/src/snippets/qml/properties.qml inherited properties +\snippet doc/src/snippets/qml/properties.qml custom properties +\snippet doc/src/snippets/qml/properties.qml parent end QML property rules coincide with many of JavaScript's property rules, for example, property names must begin with a lowercase letter. @@ -62,14 +62,14 @@ to other property values or data accessible in the application. The property val automatically kept up to date if the other properties or data values change. Property bindings are created in QML using the colon "\c {:}" before the value: -\snippet doc/src/snippets/declarative/properties.qml property binding +\snippet doc/src/snippets/qml/properties.qml property binding The property binding causes the width of the \c Rectangle to update whenever the \c {parent}'s width changes. QML extends a standards compliant JavaScript engine, so any valid JavaScript expression can be used as a property binding. Bindings can access object properties, make function calls and even use built-in JavaScript objects such as \c {Date} and \c {Math}. -\snippet doc/src/snippets/declarative/properties.qml JavaScript sample +\snippet doc/src/snippets/qml/properties.qml JavaScript sample While syntactically bindings can be of arbitrary complexity, if a binding starts to become overly complex - such as involving multiple lines, or imperative loops - it may be better @@ -82,13 +82,13 @@ function. When working with both QML and JavaScript, it is important to differentiate between QML property binding and JavaScript value assignment. In QML, a property binding is created using the colon "\c {:}". -\snippet doc/src/snippets/declarative/properties.qml property binding +\snippet doc/src/snippets/qml/properties.qml property binding The property binding causes the width of the \c Rectangle to update whenever the \c {parent}'s width changes. Assigning a property value (using the equals sign "\c {=}") does not create a property binding. -\snippet doc/src/snippets/declarative/properties.qml property assignment +\snippet doc/src/snippets/qml/properties.qml property assignment Instead of creating a property binding, the assignment simply sets the \c Rectangle \c width value to a number when the \c Component.onCompleted code is invoked. @@ -186,7 +186,7 @@ Care must be taken when referring to the parent of an object property binding. Elements and components that are bound to properties are not necessarily set as children of the properties' component. -\snippet doc/src/snippets/declarative/properties.qml object binding +\snippet doc/src/snippets/qml/properties.qml object binding The code snippet has a \l Gradient element that attempts to print its parent's \c width value. However, the \c Gradient element is bound to the \c gradient property, not the \c children property of the \c Rectangle. As a result, the @@ -205,7 +205,7 @@ Certain objects provide additional properties by \i attaching properties to othe objects. For example, the \l Keys element have properties that can \i attach to other QML objects to provide keyboard handling. -\snippet doc/src/snippets/declarative/properties.qml list attached property +\snippet doc/src/snippets/qml/properties.qml list attached property The element \l ListView provides the delegate, \c listdelegate, the property \c isCurrentItem as an attached property. The \c ListView.isCurrentItem \i{attached property} provides highlight information to the delegate. @@ -221,7 +221,7 @@ to provide additional functionality to objects. Two prominent elements, \l Component and \l Keys element provide \l{QML Signal and Handler Event System}{signal handlers} as attached signal handlers. -\snippet doc/src/snippets/declarative/properties.qml attached signal handler +\snippet doc/src/snippets/qml/properties.qml attached signal handler Read the \l{QML Signal and Handler Event System} and the \l{Keyboard Focus in QML} articles for more information. @@ -232,14 +232,14 @@ Some properties may accept a binding to a list property, where more than one component can bind to the property. List properties allow multiple \l {State}{States}, \l {Gradient}{Gradients}, and other components to bind to a single property. -\snippet doc/src/snippets/declarative/properties.qml list property +\snippet doc/src/snippets/qml/properties.qml list property The list is enclosed in square brackets, with a comma separating the list elements. In cases where you are only assigning a single item to a list, you may omit the square brackets. -\snippet doc/src/snippets/declarative/properties.qml single property +\snippet doc/src/snippets/qml/properties.qml single property To access the list, use the \c index property. -\snippet doc/src/snippets/declarative/properties.qml print list property +\snippet doc/src/snippets/qml/properties.qml print list property The snippet code simply prints the name of the first state, \c FETCH. See the \l{list}{list type} documentation @@ -252,7 +252,7 @@ In some cases properties form a logical group and use either the \i dot notation or \i group notation. Grouped properties may be written both ways: -\snippet doc/src/snippets/declarative/properties.qml grouped properties +\snippet doc/src/snippets/qml/properties.qml grouped properties In the element documentation grouped properties are shown using the dot notation. @@ -275,18 +275,18 @@ Accessing the aliasing property is similar to accessing a regular property. In addition, the optional \c default keyword indicates that the aliasing property is a \l{Default Properties}{default property}. -\snippet doc/src/snippets/declarative/Button.qml property alias +\snippet doc/src/snippets/qml/Button.qml property alias When importing the component as a \c Button, the \c buttonlabel is directly accessible through the \c label property. -\snippet doc/src/snippets/declarative/properties.qml alias usage +\snippet doc/src/snippets/qml/properties.qml alias usage In addition, the \c id property may also be aliased and referred outside the component. -\snippet doc/src/snippets/declarative/Button.qml parent begin -\snippet doc/src/snippets/declarative/Button.qml id alias -\snippet doc/src/snippets/declarative/Button.qml parent end +\snippet doc/src/snippets/qml/Button.qml parent begin +\snippet doc/src/snippets/qml/Button.qml id alias +\snippet doc/src/snippets/qml/Button.qml parent end The \c imagebutton component has the ability to modify the child \l Image object and its properties. -\snippet doc/src/snippets/declarative/properties.qml image alias +\snippet doc/src/snippets/qml/properties.qml image alias Using aliases, properties may be exposed to the \l{qml-top-level-component}{top level component}. Exposing properties to the @@ -299,7 +299,7 @@ Aliases are only activated once the component when an uninitialized alias is referenced. Likewise, aliasing an aliasing property will also result in an error. -\snippet doc/src/snippets/declarative/properties.qml alias complete +\snippet doc/src/snippets/qml/properties.qml alias complete When importing the component, however, aliasing properties appear as regular Qt properties and consequently can be used in alias references. @@ -309,7 +309,7 @@ property, effectively overwriting the existing property. For example, the following component has a \c color alias property, named the same as the built-in \l {Rectangle::color} property: -\snippet doc/src/snippets/declarative/properties.qml alias overwrite +\snippet doc/src/snippets/qml/properties.qml alias overwrite Any object that use this component and refer to its \c color property will be referring to the alias rather than the ordinary \l {Rectangle::color} property. @@ -328,13 +328,13 @@ as the \i {default property}. For example, the State element's default property is its \l{State::changes}{changes} property. \l PropertyChanges elements may simply be placed as the \c{State}'s children and they will be bound to the \c changes property. -\snippet doc/src/snippets/declarative/properties.qml state default +\snippet doc/src/snippets/qml/properties.qml state default Similarly, the \l Item element's default property is its \l{Item::data}{data} property. The \c data property manages Item's \c children and \c resources properties. This way, different data types may be placed as direct children of the \c Item. -\snippet doc/src/snippets/declarative/properties.qml default property +\snippet doc/src/snippets/qml/properties.qml default property Reassigning a default property is useful when a component is reused. For example, the \l{declarative/ui-components/tabwidget}{TabWidget} example uses @@ -350,14 +350,14 @@ For example, to bind a property exposed from the \l{The QML Engine}{declarative runtime} or \l{QmlGlobalQtObject}{Qt object}, such as the \c system.brightness property, to a value written in QML, you could use the \l Binding element as follows: -\snippet doc/src/snippets/declarative/properties.qml binding element +\snippet doc/src/snippets/qml/properties.qml binding element \section1 Changing Property Values in States The \l PropertyChanges element is for setting property bindings within a \l State element to set a property binding. -\snippet doc/src/snippets/declarative/properties.qml PropertyChanges element +\snippet doc/src/snippets/qml/properties.qml PropertyChanges element The rectangle's \c color property will bind to the \c warning component's \c color property when its \c state is set to the \c WARNING state. */ diff --git a/doc/src/qml/qmlcomponents.qdoc b/doc/src/qml/qmlcomponents.qdoc index bcc465f4b2..21b94f2ae3 100644 --- a/doc/src/qml/qmlcomponents.qdoc +++ b/doc/src/qml/qmlcomponents.qdoc @@ -50,7 +50,7 @@ is the emphasis in QML. Any snippet of QML code may become a component, by placing the code in a QML file, whose file extension is \c .qml). A complete Button component that responds to user input may be in a Button.qml file. -\snippet doc/src/snippets/declarative/reusablecomponents/Button.qml document +\snippet doc/src/snippets/qml/reusablecomponents/Button.qml document The component name, \c Button, matches the QML filename, \c Button.qml. Also, the first character is in upper case. Matching the names allow @@ -60,9 +60,9 @@ naming components with different filenames. Alternatively, a \l Component element may encapsulate a QML object to form a component. -\snippet doc/src/snippets/declarative/reusablecomponents/component.qml parent begin -\snippet doc/src/snippets/declarative/reusablecomponents/component.qml define inline component -\snippet doc/src/snippets/declarative/reusablecomponents/component.qml parent end +\snippet doc/src/snippets/qml/reusablecomponents/component.qml parent begin +\snippet doc/src/snippets/qml/reusablecomponents/component.qml define inline component +\snippet doc/src/snippets/qml/reusablecomponents/component.qml parent end Components may incorporate any \l{Qt Quick}{QML feature} such as: @@ -89,7 +89,7 @@ A component defined in a \c .qml file is directly usable by declaring the name of the component. For example, a button defined in \c Button.qml is created by declaring a \c Button. The button is defined in the \l {qml-define-components}{Defining New Components} section. -\snippet doc/src/snippets/declarative/reusablecomponents/application.qml document +\snippet doc/src/snippets/qml/reusablecomponents/application.qml document Note that the component name, \c Button, matches the QML filename, \c Button.qml. Also, the first character is in upper case. Matching the names allow @@ -100,7 +100,7 @@ For flexibility, a \c qmldir file is for dictating which additional components, plugins, or directories should be imported. By using a \c qmldir file, component names do not need to match the filenames. The \c qmldir file should, however, be in an imported path. -\snippet doc/src/snippets/declarative/reusablecomponents/qmldir document +\snippet doc/src/snippets/qml/reusablecomponents/qmldir document \section2 Loading an Inline Component @@ -109,8 +109,8 @@ delayed. A component may be created during a MouseArea event or by using a \l Loader element. The component can create an object, which is addressable in a similar way as an \l {qml-id}{identifier}. Thus, the created object may have its bindings set and read like a normal QML object. -\snippet doc/src/snippets/declarative/reusablecomponents/component.qml define inline component -\snippet doc/src/snippets/declarative/reusablecomponents/component.qml create inline component +\snippet doc/src/snippets/qml/reusablecomponents/component.qml define inline component +\snippet doc/src/snippets/qml/reusablecomponents/component.qml create inline component \keyword qml-component-properties \section1 Component Properties @@ -140,11 +140,11 @@ Consider the Button component from the object is a \l Rectangle. When imported, the Button component will possess the Rectangle's properties, methods, signals, and any custom properties. -\snippet doc/src/snippets/declarative/reusablecomponents/Button.qml parent begin -\snippet doc/src/snippets/declarative/reusablecomponents/Button.qml ellipses -\snippet doc/src/snippets/declarative/reusablecomponents/Button.qml properties -\snippet doc/src/snippets/declarative/reusablecomponents/Button.qml ellipses -\snippet doc/src/snippets/declarative/reusablecomponents/Button.qml parent end +\snippet doc/src/snippets/qml/reusablecomponents/Button.qml parent begin +\snippet doc/src/snippets/qml/reusablecomponents/Button.qml ellipses +\snippet doc/src/snippets/qml/reusablecomponents/Button.qml properties +\snippet doc/src/snippets/qml/reusablecomponents/Button.qml ellipses +\snippet doc/src/snippets/qml/reusablecomponents/Button.qml parent end The Button's \c text alias is accessible from outside the component as well as the Rectangle's visual properties and signals such as \c x, \c y, \c anchors, @@ -156,7 +156,7 @@ children which is beneficial for certain types of interfaces. However, since \c FocusScopes are not visual elements, the visual properties of its child need to be exposed. -\snippet doc/src/snippets/declarative/reusablecomponents/focusbutton.qml document +\snippet doc/src/snippets/qml/reusablecomponents/focusbutton.qml document \keyword qml-id \section2 The Object Identifier @@ -165,7 +165,7 @@ Each QML object may be given a special unique identifier called an \c id. No other object within the same QML component (see \l{QML Documents}) can have the same \c id value. QML objects may then access an object using the \c id property. -\snippet doc/src/snippets/declarative/properties.qml id property +\snippet doc/src/snippets/qml/properties.qml id property A component may readily access its parent's properties by using the \c parent property. @@ -178,15 +178,15 @@ Note that an \c id must begin with a lower-case letter or an underscore. The Objects or Items declared within a component can be made accessible by binding their id to a property alias. -\snippet doc/src/snippets/declarative/reusablecomponents/Button.qml parent begin -\snippet doc/src/snippets/declarative/reusablecomponents/Button.qml object alias -\snippet doc/src/snippets/declarative/reusablecomponents/Button.qml text -\snippet doc/src/snippets/declarative/reusablecomponents/Button.qml parent end +\snippet doc/src/snippets/qml/reusablecomponents/Button.qml parent begin +\snippet doc/src/snippets/qml/reusablecomponents/Button.qml object alias +\snippet doc/src/snippets/qml/reusablecomponents/Button.qml text +\snippet doc/src/snippets/qml/reusablecomponents/Button.qml parent end The advantage of using an alias instead a property of type of the object is that the value of the alias cannot be overridden, and members of the object can be used in property bindings when declaring an instance of the component. -\snippet doc/src/snippets/declarative/reusablecomponents/application.qml grouped property +\snippet doc/src/snippets/qml/reusablecomponents/application.qml grouped property If a property of type \c Text was used instead of an alias in this instance there would be no guarantee that \c label would be initialized before the binding was attempted which would cause the binding to fail. diff --git a/doc/src/qml/qmldocument.qdoc b/doc/src/qml/qmldocument.qdoc index fedeba35e1..426f135a45 100644 --- a/doc/src/qml/qmldocument.qdoc +++ b/doc/src/qml/qmldocument.qdoc @@ -36,7 +36,7 @@ from text data. Here is a simple QML document: -\snippet doc/src/snippets/declarative/qml-documents/non-trivial.qml document +\snippet doc/src/snippets/qml/qml-documents/non-trivial.qml document QML documents are always encoded in UTF-8 format. @@ -79,7 +79,7 @@ text property: \o application.qml \row -\o \snippet doc/src/snippets/declarative/qml-documents/qmldocuments.qml document +\o \snippet doc/src/snippets/qml/qml-documents/qmldocuments.qml document \o \qml import QtQuick 2.0 @@ -138,14 +138,14 @@ These final two examples perform identically to the original document. \table \row \o -\snippet doc/src/snippets/declarative/qml-documents/inline-component.qml document +\snippet doc/src/snippets/qml/qml-documents/inline-component.qml document \o -\snippet doc/src/snippets/declarative/qml-documents/inline-text-component.qml document +\snippet doc/src/snippets/qml/qml-documents/inline-text-component.qml document \endtable For information about components, the \l{QML Components} article details the creation of components and how to load them in other components. -\sa QDeclarativeComponent +\sa QQmlComponent */ diff --git a/doc/src/qml/qmlengine.qdoc b/doc/src/qml/qmlengine.qdoc index 3e8ef1ae3f..0865755c7b 100644 --- a/doc/src/qml/qmlengine.qdoc +++ b/doc/src/qml/qmlengine.qdoc @@ -38,16 +38,16 @@ specified in QML files, plugins, or applications. \section1 Core Module Classes - The \l{QtDeclarative}{Qt Declarative} module provides a set of C++ APIs for + The \l{QtQml}{Qt Declarative} module provides a set of C++ APIs for extending your QML applications from C++ and embedding QML into C++ applications. There are several core classes in the Qt Declarative module that provide the essential capabilities for doing this. These are: \list - \o QDeclarativeEngine: A QML engine provides the environment for executing QML code. Every + \o QQmlEngine: A QML engine provides the environment for executing QML code. Every application requires at least one engine instance. - \o QDeclarativeComponent: A component encapsulates QML information. - \o QDeclarativeContext: A context allows an application to expose data to + \o QQmlComponent: A component encapsulates QML information. + \o QQmlContext: A context allows an application to expose data to the QML components created by an engine. \endlist @@ -61,27 +61,27 @@ specified in QML files, plugins, or applications. \endlist \section2 Declarative Engine - A QDeclarativeEngine allows the configuration of global settings that + A QQmlEngine allows the configuration of global settings that apply to all of its QML component instances: for example, the QNetworkAccessManager to be used for network communications, and the file path to be used for persistent storage. - QDeclarativeComponent is used to load QML documents. Each - QDeclarativeComponent instance represents a single document. A component + QQmlComponent is used to load QML documents. Each + QQmlComponent instance represents a single document. A component can be created from the URL or file path of a QML document, or the raw QML code of the document. Component instances are instatiated through - the QDeclarativeComponent::create() method, like this: + the QQmlComponent::create() method, like this: \code - QDeclarativeEngine engine; - QDeclarativeComponent component(&engine, QUrl::fromLocalFile("MyRectangle.qml")); + QQmlEngine engine; + QQmlComponent component(&engine, QUrl::fromLocalFile("MyRectangle.qml")); QObject *rectangleInstance = component.create(); // ... delete rectangleInstance; \endcode - QML documents can also be loaded using QDeclarativeView. This class + QML documents can also be loaded using QQuickView. This class provides a convenient QWidget-based view for embedding QML components into QGraphicsView-based applications. (For other methods of integrating QML into QWidget-based applications, see \l {Integrating QML Code with @@ -91,44 +91,44 @@ specified in QML files, plugins, or applications. \section2 Loading QML Components from C++ - A QML document can be loaded with QDeclarativeComponent or QDeclarativeView. - QDeclarativeComponent loads a QML component as a C++ object; - QDeclarativeView also does this, but additionally loads the QML component + A QML document can be loaded with QQmlComponent or QQuickView. + QQmlComponent loads a QML component as a C++ object; + QQuickView also does this, but additionally loads the QML component directly into a QGraphicsView. It is convenient for loading a displayable QML component into a QWidget-based application. For example, suppose there is a \c MyItem.qml file that looks like this: - \snippet doc/src/snippets/declarative/qtbinding/loading/MyItem.qml start - \snippet doc/src/snippets/declarative/qtbinding/loading/MyItem.qml end + \snippet doc/src/snippets/qml/qtbinding/loading/MyItem.qml start + \snippet doc/src/snippets/qml/qtbinding/loading/MyItem.qml end - This QML document can be loaded with QDeclarativeComponent or - QDeclarativeView with the following C++ code. Using a QDeclarativeComponent - requires calling QDeclarativeComponent::create() to create a new instance of - the component, while a QDeclarativeView automatically creates an instance of - the component, which is accessible via QDeclarativeView::rootObject(): + This QML document can be loaded with QQmlComponent or + QQuickView with the following C++ code. Using a QQmlComponent + requires calling QQmlComponent::create() to create a new instance of + the component, while a QQuickView automatically creates an instance of + the component, which is accessible via QQuickView::rootObject(): \table \row \o - \snippet doc/src/snippets/declarative/qtbinding/loading/main.cpp QDeclarativeComponent-a + \snippet doc/src/snippets/qml/qtbinding/loading/main.cpp QQmlComponent-a \dots 0 - \snippet doc/src/snippets/declarative/qtbinding/loading/main.cpp QDeclarativeComponent-b + \snippet doc/src/snippets/qml/qtbinding/loading/main.cpp QQmlComponent-b \o - \snippet doc/src/snippets/declarative/qtbinding/loading/main.cpp QDeclarativeView + \snippet doc/src/snippets/qml/qtbinding/loading/main.cpp QQuickView \endtable This \c object is the instance of the \c MyItem.qml component that has been created. You can now modify the item's properties using - QObject::setProperty() or QDeclarativeProperty: + QObject::setProperty() or QQmlProperty: - \snippet doc/src/snippets/declarative/qtbinding/loading/main.cpp properties + \snippet doc/src/snippets/qml/qtbinding/loading/main.cpp properties Alternatively, you can cast the object to its actual type and call functions with compile-time safety. In this case the base object of \c MyItem.qml is - an \l Item, which is defined by the QDeclarativeItem class: + an \l Item, which is defined by the QQuickItem class: - \snippet doc/src/snippets/declarative/qtbinding/loading/main.cpp cast + \snippet doc/src/snippets/qml/qtbinding/loading/main.cpp cast You can also connect to any signals or call functions defined in the component using QMetaObject::invokeMethod() and QObject::connect(). See \l @@ -141,14 +141,14 @@ specified in QML files, plugins, or applications. the QObject::objectName property with QObject::findChild(). For example, if the root item in \c MyItem.qml had a child \l Rectangle item: - \snippet doc/src/snippets/declarative/qtbinding/loading/MyItem.qml start + \snippet doc/src/snippets/qml/qtbinding/loading/MyItem.qml start \codeline - \snippet doc/src/snippets/declarative/qtbinding/loading/MyItem.qml child - \snippet doc/src/snippets/declarative/qtbinding/loading/MyItem.qml end + \snippet doc/src/snippets/qml/qtbinding/loading/MyItem.qml child + \snippet doc/src/snippets/qml/qtbinding/loading/MyItem.qml end The child could be located like this: - \snippet doc/src/snippets/declarative/qtbinding/loading/main.cpp findChild + \snippet doc/src/snippets/qml/qtbinding/loading/main.cpp findChild If \c objectName is used inside a delegate of a ListView, \l Repeater or some other element that creates multiple instances of its delegates, there @@ -172,20 +172,20 @@ specified in QML files, plugins, or applications. \section2 Embedding C++ Objects into QML Components When loading a QML scene into a C++ application, it can be useful to - directly embed C++ data into the QML object. QDeclarativeContext enables + directly embed C++ data into the QML object. QQmlContext enables this by exposing data to the context of a QML component, allowing data to be injected from C++ into QML. For example, here is a QML item that refers to a \c currentDateTime value that does not exist in the current scope: - \snippet doc/src/snippets/declarative/qtbinding/context/MyItem.qml 0 + \snippet doc/src/snippets/qml/qtbinding/context/MyItem.qml 0 This \c currentDateTime value can be set directly by the C++ application that loads the QML component, using - QDeclarativeContext::setContextProperty(): + QQmlContext::setContextProperty(): - \snippet doc/src/snippets/declarative/qtbinding/context/main.cpp 0 + \snippet doc/src/snippets/qml/qtbinding/context/main.cpp 0 Context properties can hold either QVariant or QObject* values. This means custom C++ objects can also be injected using this approach, and these @@ -196,11 +196,11 @@ specified in QML files, plugins, or applications. \table \row \o - \snippet doc/src/snippets/declarative/qtbinding/context-advanced/applicationdata.h 0 + \snippet doc/src/snippets/qml/qtbinding/context-advanced/applicationdata.h 0 \codeline - \snippet doc/src/snippets/declarative/qtbinding/context-advanced/main.cpp 0 + \snippet doc/src/snippets/qml/qtbinding/context-advanced/main.cpp 0 \o - \snippet doc/src/snippets/declarative/qtbinding/context-advanced/MyItem.qml 0 + \snippet doc/src/snippets/qml/qtbinding/context-advanced/MyItem.qml 0 \endtable (Note that date/time values returned from C++ to QML can be formatted through @@ -212,7 +212,7 @@ specified in QML files, plugins, or applications. connected to using an \c onDataChanged handler within a \l Connections object: - \snippet doc/src/snippets/declarative/qtbinding/context-advanced/connections.qml 0 + \snippet doc/src/snippets/qml/qtbinding/context-advanced/connections.qml 0 Context properties can be useful for using C++ based data models in a QML view. See the \l {declarative/modelviews/stringlistmodel}{String ListModel}, @@ -221,7 +221,7 @@ specified in QML files, plugins, or applications. respective examples on using QStringListModel, QObjectList-based models and QAbstractItemModel in QML views. - Also see the QDeclarativeContext documentation for more information. + Also see the QQmlContext documentation for more information. \section1 Invoking QML Entities through the Engine @@ -246,8 +246,8 @@ specified in QML files, plugins, or applications. \table \row - \o \snippet doc/src/snippets/declarative/qtbinding/functions-qml/MyItem.qml 0 - \o \snippet doc/src/snippets/declarative/qtbinding/functions-qml/main.cpp 0 + \o \snippet doc/src/snippets/qml/qtbinding/functions-qml/MyItem.qml 0 + \o \snippet doc/src/snippets/qml/qtbinding/functions-qml/main.cpp 0 \endtable Notice the Q_RETURN_ARG() and Q_ARG() arguments for @@ -257,16 +257,16 @@ specified in QML files, plugins, or applications. To call a C++ function from QML, the function must be either a Qt slot, or a function marked with the Q_INVOKABLE macro, to be available to QML. In the following example, the QML code invokes methods on the \c myObject object, - which has been set using QDeclarativeContext::setContextProperty(): + which has been set using QQmlContext::setContextProperty(): \table \row \o - \snippet doc/src/snippets/declarative/qtbinding/functions-cpp/MyItem.qml 0 + \snippet doc/src/snippets/qml/qtbinding/functions-cpp/MyItem.qml 0 \o - \snippet doc/src/snippets/declarative/qtbinding/functions-cpp/myclass.h 0 + \snippet doc/src/snippets/qml/qtbinding/functions-cpp/myclass.h 0 \codeline - \snippet doc/src/snippets/declarative/qtbinding/functions-cpp/main.cpp 0 + \snippet doc/src/snippets/qml/qtbinding/functions-cpp/main.cpp 0 \endtable QML supports the calling of overloaded C++ functions. If there are multiple @@ -289,11 +289,11 @@ specified in QML files, plugins, or applications. \table \row \o - \snippet doc/src/snippets/declarative/qtbinding/signals-qml/MyItem.qml 0 + \snippet doc/src/snippets/qml/qtbinding/signals-qml/MyItem.qml 0 \o - \snippet doc/src/snippets/declarative/qtbinding/signals-qml/myclass.h 0 + \snippet doc/src/snippets/qml/qtbinding/signals-qml/myclass.h 0 \codeline - \snippet doc/src/snippets/declarative/qtbinding/signals-qml/main.cpp 0 + \snippet doc/src/snippets/qml/qtbinding/signals-qml/main.cpp 0 \endtable To connect to Qt C++ signals from within QML, use a signal handler with the @@ -308,12 +308,12 @@ specified in QML files, plugins, or applications. \row \o - \snippet doc/src/snippets/declarative/qtbinding/signals-cpp/imageviewer.h start + \snippet doc/src/snippets/qml/qtbinding/signals-cpp/imageviewer.h start \dots 4 - \snippet doc/src/snippets/declarative/qtbinding/signals-cpp/imageviewer.h end + \snippet doc/src/snippets/qml/qtbinding/signals-cpp/imageviewer.h end \o - \snippet doc/src/snippets/declarative/qtbinding/signals-cpp/standalone.qml 0 + \snippet doc/src/snippets/qml/qtbinding/signals-cpp/standalone.qml 0 \endtable (Note that if a signal has been declared as the NOTIFY signal for a @@ -326,13 +326,13 @@ specified in QML files, plugins, or applications. If, however, the object with the signal is not created from within the QML code, and the QML item only has a reference to the created object - for example, if the object was set using - QDeclarativeContext::setContextProperty() - then the \l Connections element + QQmlContext::setContextProperty() - then the \l Connections element can be used instead to create the signal handler: \table \row - \o \snippet doc/src/snippets/declarative/qtbinding/signals-cpp/main.cpp connections - \o \snippet doc/src/snippets/declarative/qtbinding/signals-cpp/MyItem.qml 0 + \o \snippet doc/src/snippets/qml/qtbinding/signals-cpp/main.cpp connections + \o \snippet doc/src/snippets/qml/qtbinding/signals-cpp/MyItem.qml 0 \endtable C++ signals can use enum values as parameters provided that the enum is @@ -346,14 +346,14 @@ specified in QML files, plugins, or applications. Any properties declared in a QML object are automatically accessible from C++. Given a QML item like this: - \snippet doc/src/snippets/declarative/qtbinding/properties-qml/MyItem.qml 0 + \snippet doc/src/snippets/qml/qtbinding/properties-qml/MyItem.qml 0 The value of the \c someNumber property can be set and read using - QDeclarativeProperty, or QObject::setProperty() and QObject::property(): + QQmlProperty, or QObject::setProperty() and QObject::property(): - \snippet doc/src/snippets/declarative/qtbinding/properties-qml/main.cpp 0 + \snippet doc/src/snippets/qml/qtbinding/properties-qml/main.cpp 0 - You should always use QObject::setProperty(), QDeclarativeProperty or + You should always use QObject::setProperty(), QQmlProperty or QMetaProperty::write() to change a QML property value, to ensure the QML engine is made aware of the property change. For example, say you have a custom element \c PushButton with a \c buttonText property that internally @@ -362,7 +362,7 @@ specified in QML files, plugins, or applications. \badcode // BAD! - QDeclarativeComponent component(engine, "MyButton.qml"); + QQmlComponent component(engine, "MyButton.qml"); PushButton *button = qobject_cast(component.create()); button->m_buttonText = "Click me"; \endcode @@ -381,8 +381,8 @@ specified in QML files, plugins, or applications. \table \row - \o \snippet doc/src/snippets/declarative/qtbinding/properties-cpp/applicationdata.h 0 - \o \snippet doc/src/snippets/declarative/qtbinding/properties-cpp/MyItem.qml 0 + \o \snippet doc/src/snippets/qml/qtbinding/properties-cpp/applicationdata.h 0 + \o \snippet doc/src/snippets/qml/qtbinding/properties-cpp/MyItem.qml 0 \endtable Notice the \c backgroundColorChanged signal is declared as the NOTIFY signal @@ -401,7 +401,7 @@ specified in QML files, plugins, or applications. Additional Qt code is runnable in the engine as a QML plugin. The \l{QML Plugins} article covers the creation and usage patterns of QML plugins. The - QDeclarativeExtensionPlugin class is an abstract class for writing QML + QQmlExtensionPlugin class is an abstract class for writing QML plugins. The \l {How to Create Qt Plugins} contains more information about Qt's plugin system. @@ -413,17 +413,17 @@ specified in QML files, plugins, or applications. initializing some costly data structures until after all the properties have been set. - The QML engine defines an interface class called QDeclarativeParserStatus, + The QML engine defines an interface class called QQmlParserStatus, which contains a number of virtual methods that are invoked at various stages during component instantiation. To receive these notifications, an - element implementation inherits QDeclarativeParserStatus and notifies the Qt + element implementation inherits QQmlParserStatus and notifies the Qt meta system using the Q_INTERFACES() macro. \code - class Example : public QObject, public QDeclarativeParserStatus + class Example : public QObject, public QQmlParserStatus { Q_OBJECT - Q_INTERFACES(QDeclarativeParserStatus) + Q_INTERFACES(QQmlParserStatus) public: virtual void componentComplete() { diff --git a/doc/src/qml/qmlevents.qdoc b/doc/src/qml/qmlevents.qdoc index f29b2f260b..1f2e7a9908 100644 --- a/doc/src/qml/qmlevents.qdoc +++ b/doc/src/qml/qmlevents.qdoc @@ -58,9 +58,9 @@ Attempting to declare two signals or methods with the same name in the same type block generates an error. However, a new signal may reuse the name of an existing signal on the type. (This should be done with caution, as the existing signal may be hidden and become inaccessible.) Here are various examples of signal declarations: -\snippet doc/src/snippets/declarative/events.qml parent begin -\snippet doc/src/snippets/declarative/events.qml signal declaration -\snippet doc/src/snippets/declarative/events.qml parent end +\snippet doc/src/snippets/qml/events.qml parent begin +\snippet doc/src/snippets/qml/events.qml signal declaration +\snippet doc/src/snippets/qml/events.qml parent end If the signal has no parameters, the "\c{()}" brackets are optional. If parameters are used, the parameter types must be declared, as for the \c string @@ -69,17 +69,17 @@ and \c variant arguments of the \c perform signal. Adding a signal to an item automatically adds a \i{signal handler} as well. The signal hander is named \c on, with the first letter of the signal in uppercase. The previous signals have the following signal handlers: -\snippet doc/src/snippets/declarative/events.qml signal handler declaration +\snippet doc/src/snippets/qml/events.qml signal handler declaration Further, each QML properties have a \c{Changed} signal and its corresponding \c{onChanged} signal handler. As a result, property changes may notify other components for any changes. -\snippet doc/src/snippets/declarative/events.qml automatic signals +\snippet doc/src/snippets/qml/events.qml automatic signals To emit a signal, invoke it as a method. The signal handler binding is similar to a property binding and it is invoked when the signal is emitted. Use the defined argument names to access the respective arguments. -\snippet doc/src/snippets/declarative/events.qml signal emit +\snippet doc/src/snippets/qml/events.qml signal emit Note that the \c Component.onCompleted is an \l{attached-signalhandlers}{attached signal handler}; it is invoked when the \l Component initialization is complete. @@ -93,7 +93,7 @@ automatically invoked whenever the signal is emitted. This mechanism enables a signal to be received by a method instead of a \l {Signal Handlers}{signal handler}. -\snippet doc/src/snippets/declarative/events.qml connect method +\snippet doc/src/snippets/qml/events.qml connect method The \c {connect()} method is appropriate when connecting a JavaScript method to a signal. @@ -104,7 +104,7 @@ signals. By connecting signals to other signals, the \c connect() method can form different signal chains. -\snippet doc/src/snippets/declarative/events.qml forward signal +\snippet doc/src/snippets/qml/events.qml forward signal Whenever the \l MouseArea \c clicked signal is emitted, the \c send diff --git a/doc/src/qml/qmlintro.qdoc b/doc/src/qml/qmlintro.qdoc index 03ee94d6d1..3290a27bc3 100644 --- a/doc/src/qml/qmlintro.qdoc +++ b/doc/src/qml/qmlintro.qdoc @@ -1197,7 +1197,7 @@ arrange a set of Rectangle items. The Repeater item creates a series of 24 rectangles for the Grid item to position in a 5 by 5 arrangement. \clearfloat -\snippet doc/src/snippets/declarative/repeaters/repeater-grid-index.qml document +\snippet doc/src/snippets/qml/repeaters/repeater-grid-index.qml document The number of items created by a Repeater is held by its \l{Repeater::}{count} property. It is not possible to set this property to determine the number of diff --git a/doc/src/qml/qmlplugins.qdoc b/doc/src/qml/qmlplugins.qdoc index 9b6fe29c1e..e41bba2906 100644 --- a/doc/src/qml/qmlplugins.qdoc +++ b/doc/src/qml/qmlplugins.qdoc @@ -36,16 +36,16 @@ C++ code as plugins. Plugins are imported and labeled as modules and its content are available as components. - QDeclarativeExtensionPlugin is a plugin interface that makes it possible to + QQmlExtensionPlugin is a plugin interface that makes it possible to create QML extensions that can be loaded dynamically into QML applications. These extensions allow custom QML types to be made available to the QML engine. To write a QML extension plugin: \list 1 - \o Subclass QDeclarativeExtensionPlugin - \o Implement QDeclarativeExtensionPlugin's - \l{QDeclarativeExtensionPlugin::}{registerTypes()} method + \o Subclass QQmlExtensionPlugin + \o Implement QQmlExtensionPlugin's + \l{QQmlExtensionPlugin::}{registerTypes()} method \o Register types with qmlRegisterType() \o Export the class using the Q_EXPORT_PLUGIN2() macro \o Write a project file for the plugin @@ -67,8 +67,8 @@ \dots A plugin class, \c QExampleQMLPlugin, is a subclass of - \l QDeclarativeExtensionPlugin and it implements the - \l{QDeclarativeExtensionPlugin::}{registerTypes()} method. + \l QQmlExtensionPlugin and it implements the + \l{QQmlExtensionPlugin::}{registerTypes()} method. In the registerTypes() method, the plugin class can \l{register-c++-type}{register} the \c TimeModel class to the declarative diff --git a/doc/src/qml/qmlruntime.qdoc b/doc/src/qml/qmlruntime.qdoc index 5853c14844..a803fabd7a 100644 --- a/doc/src/qml/qmlruntime.qdoc +++ b/doc/src/qml/qmlruntime.qdoc @@ -35,8 +35,8 @@ Declarative UI engine along with the built-in QML elements and plugin modules, and it also provides access to third-party QML elements and modules. Applications that use QML need to invoke the QML runtime in order to -execute QML documents. This can be done by creating a QDeclarativeView -or a QDeclarativeEngine, as described below. In addition, the Declarative UI +execute QML documents. This can be done by creating a QQuickView +or a QQmlEngine, as described below. In addition, the Declarative UI package includes the \QQV tool, which loads \c .qml files. This tool is useful for developing and testing QML code without the need to write a C++ application to load the QML runtime. @@ -47,17 +47,17 @@ a C++ application to load the QML runtime. To deploy an application that uses QML, the QML runtime must be invoked by the application. This is done by writing a Qt C++ application that loads the -QDeclarativeEngine by either: +QQmlEngine by either: \list -\o Loading the QML file through a QDeclarativeView instance, or -\o Creating a QDeclarativeEngine instance and loading QML files with QDeclarativeComponent +\o Loading the QML file through a QQuickView instance, or +\o Creating a QQmlEngine instance and loading QML files with QQmlComponent \endlist -\section2 Deploying with QDeclarativeView +\section2 Deploying with QQuickView -QDeclarativeView is a QWidget-based class that is able to load QML files. +QQuickView is a QWidget-based class that is able to load QML files. For example, if there is a QML file, \c application.qml, like this: \qml @@ -70,13 +70,13 @@ It can be loaded in a Qt application's \c main.cpp file like this: \code #include - #include + #include int main(int argc, char *argv[]) { QApplication app(argc, argv); - QDeclarativeView view; + QQuickView view; view.setSource(QUrl::fromLocalFile("application.qml")); view.show(); @@ -97,27 +97,27 @@ the \c declarative module for the \c QT variable. For example: \endcode -\section2 Creating a QDeclarativeEngine directly +\section2 Creating a QQmlEngine directly If \c application.qml does not have any graphical components, or if it is -preferred to avoid QDeclarativeView for other reasons, the QDeclarativeEngine +preferred to avoid QQuickView for other reasons, the QQmlEngine can be constructed directly instead. In this case, \c application.qml is -loaded as a QDeclarativeComponent instance rather than placed into a view: +loaded as a QQmlComponent instance rather than placed into a view: \code #include - #include - #include - #include + #include + #include + #include int main(int argc, char *argv[]) { QApplication app(argc, argv); - QDeclarativeEngine engine; - QDeclarativeContext *objectContext = new QDeclarativeContext(engine.rootContext()); + QQmlEngine engine; + QQmlContext *objectContext = new QQmlContext(engine.rootContext()); - QDeclarativeComponent component(&engine, "application.qml"); + QQmlComponent component(&engine, "application.qml"); QObject *object = component.create(objectContext); // ... delete object and objectContext when necessary @@ -127,7 +127,7 @@ loaded as a QDeclarativeComponent instance rather than placed into a view: \endcode See \l {Using QML Bindings in C++ Applications} for more information about using -QDeclarativeEngine, QDeclarativeContext and QDeclarativeComponent, as well +QQmlEngine, QQmlContext and QQmlComponent, as well as details on including QML files through \l{The Qt Resource System}{Qt's Resource system}. diff --git a/doc/src/qml/qmlsyntax.qdoc b/doc/src/qml/qmlsyntax.qdoc index b2b7fc89bd..1cd6ad7f46 100644 --- a/doc/src/qml/qmlsyntax.qdoc +++ b/doc/src/qml/qmlsyntax.qdoc @@ -133,7 +133,7 @@ Commenting in QML is similar to JavaScript. \o Multiline comments start with /* and finish with *\/ \endlist -\snippet doc/src/snippets/declarative/comments.qml 0 +\snippet doc/src/snippets/qml/comments.qml 0 Comments are ignored by the engine. They are useful for explaining what you are doing; for referring back to at a later date, or for others reading diff --git a/doc/src/qml/qmltypes.qdoc b/doc/src/qml/qmltypes.qdoc index 964ff98a15..9555e54f7e 100644 --- a/doc/src/qml/qmltypes.qdoc +++ b/doc/src/qml/qmltypes.qdoc @@ -350,7 +350,7 @@ Q_PROPERTY(int size READ size CONSTANT) Properties that are lists of objects or Qt interfaces are also declared with the Q_PROPERTY() macro. However, list properties must have the type - \l{QDeclarativeListProperty}{QDeclarativeListProperty}. + \l{QQmlListProperty}{QQmlListProperty}. \snippet examples/declarative/cppextensions/referenceexamples/properties/birthdayparty.h 2 @@ -361,7 +361,7 @@ Q_PROPERTY(int size READ size CONSTANT) \l {Extending QML - Object and List Property Types Example} shows the complete code used to create the \c BirthdayParty type. For more - information, visit \l{QDeclarativeListProperty}{QDeclarativeListProperty} + information, visit \l{QQmlListProperty}{QQmlListProperty} for creating list properties. \section2 Sequence Types @@ -756,8 +756,8 @@ itself, the QML engine sets up an association between the value source and the property. Property value sources are special types that derive from the -QDeclarativePropertyValueSource base class. This base class contains a single method, -QDeclarativePropertyValueSource::setTarget(), that the QML engine invokes when +QQmlPropertyValueSource base class. This base class contains a single method, +QQmlPropertyValueSource::setTarget(), that the QML engine invokes when associating the property value source with a property. The relevant part of the \c HappyBirthdaySong type declaration looks like this: @@ -771,7 +771,7 @@ contain properties, signals and methods just like other types. When a property value source object is assigned to a property, QML first tries to assign it normally, as though it were a regular QML type. Only if this -assignment fails does the engine call the \l {QDeclarativePropertyValueSource::}{setTarget()} method. This allows +assignment fails does the engine call the \l {QQmlPropertyValueSource::}{setTarget()} method. This allows the type to also be used in contexts other than just as a value source. \l {Extending QML - Property Value Source Example} shows the complete code used diff --git a/doc/src/qml/qmlviewer.qdoc b/doc/src/qml/qmlviewer.qdoc index 6439e95f4e..9006a053fc 100644 --- a/doc/src/qml/qmlviewer.qdoc +++ b/doc/src/qml/qmlviewer.qdoc @@ -160,7 +160,7 @@ QtObject { property int time: 54321 } \endqml To replace this with real data, you can simply bind the real data object to -the root context in C++ using QDeclarativeContext::setContextProperty(). This +the root context in C++ using QQmlContext::setContextProperty(). This is detailed in \l {Using QML Bindings in C++ Applications}. \section1 Using the \c runtime object diff --git a/doc/src/qml/qtbinding.qdoc b/doc/src/qml/qtbinding.qdoc index 10581857dc..7410836e9c 100644 --- a/doc/src/qml/qtbinding.qdoc +++ b/doc/src/qml/qtbinding.qdoc @@ -43,12 +43,12 @@ You may want to mix QML and C++ for a number of reasons. For example: \o To use functionality defined in a C++ source (for example, when using a C++ Qt-based data model, or calling functions in a third-party C++ library) \o To access functionality in the Qt Declarative module (for example, to dynamically generate -images using QDeclarativeImageProvider) +images using QQmlImageProvider) \o To write your own QML elements (whether for your applications, or for distribution to others) \endlist To use the Qt Declarative module, you must include and link to the module appropriately, as shown on -the \l {QtDeclarative}{module index page}. The \l {Qt Declarative UI Runtime} documentation +the \l {QtQml}{module index page}. The \l {Qt Declarative UI Runtime} documentation shows how to build a basic C++ application that uses this module. @@ -59,32 +59,32 @@ embedding QML into C++ applications. There are several core classes in the Qt De that provide the essential capabilities for doing this. These are: \list -\o QDeclarativeEngine: A QML engine provides the environment for executing QML code. Every +\o QQmlEngine: A QML engine provides the environment for executing QML code. Every application requires at least one engine instance. -\o QDeclarativeComponent: A component encapsulates a \l{QML Documents}{QML document}. -\o QDeclarativeContext: A context allows an application to expose data to the QML components +\o QQmlComponent: A component encapsulates a \l{QML Documents}{QML document}. +\o QQmlContext: A context allows an application to expose data to the QML components created by an engine. \endlist -A QDeclarativeEngine allows the configuration of global settings that apply to all of its QML +A QQmlEngine allows the configuration of global settings that apply to all of its QML component instances: for example, the QNetworkAccessManager to be used for network communications, and the file path to be used for persistent storage. -QDeclarativeComponent is used to load QML documents. Each QDeclarativeComponent instance represents +QQmlComponent is used to load QML documents. Each QQmlComponent instance represents a single document. A component can be created from the URL or file path of a QML document, or the raw QML code of the document. Component instances are instatiated through the -QDeclarativeComponent::create() method, like this: +QQmlComponent::create() method, like this: \code -QDeclarativeEngine engine; -QDeclarativeComponent component(&engine, QUrl::fromLocalFile("MyRectangle.qml")); +QQmlEngine engine; +QQmlComponent component(&engine, QUrl::fromLocalFile("MyRectangle.qml")); QObject *rectangleInstance = component.create(); // ... delete rectangleInstance; \endcode -QML documents can also be loaded using QDeclarativeView. This class provides a convenient +QML documents can also be loaded using QQuickView. This class provides a convenient QWidget-based view for embedding QML components into QGraphicsView-based applications. (For other methods of integrating QML into QWidget-based applications, see \l {Integrating QML Code with existing Qt UI code}.) @@ -108,41 +108,41 @@ these methods throughout your application as appropriate. \section2 Loading QML Components from C++ -A QML document can be loaded with QDeclarativeComponent or QDeclarativeView. QDeclarativeComponent -loads a QML component as a C++ object; QDeclarativeView also does this, +A QML document can be loaded with QQmlComponent or QQuickView. QQmlComponent +loads a QML component as a C++ object; QQuickView also does this, but additionally loads the QML component directly into a QGraphicsView. It is convenient for loading a displayable QML component into a QWidget-based application. For example, suppose there is a \c MyItem.qml file that looks like this: -\snippet doc/src/snippets/declarative/qtbinding/loading/MyItem.qml start -\snippet doc/src/snippets/declarative/qtbinding/loading/MyItem.qml end +\snippet doc/src/snippets/qml/qtbinding/loading/MyItem.qml start +\snippet doc/src/snippets/qml/qtbinding/loading/MyItem.qml end -This QML document can be loaded with QDeclarativeComponent or QDeclarativeView with the following -C++ code. Using a QDeclarativeComponent requires calling QDeclarativeComponent::create() to create -a new instance of the component, while a QDeclarativeView automatically creates an instance of the -component, which is accessible via QDeclarativeView::rootObject(): +This QML document can be loaded with QQmlComponent or QQuickView with the following +C++ code. Using a QQmlComponent requires calling QQmlComponent::create() to create +a new instance of the component, while a QQuickView automatically creates an instance of the +component, which is accessible via QQuickView::rootObject(): \table \row \o -\snippet doc/src/snippets/declarative/qtbinding/loading/main.cpp QDeclarativeComponent-a +\snippet doc/src/snippets/qml/qtbinding/loading/main.cpp QQmlComponent-a \dots 0 -\snippet doc/src/snippets/declarative/qtbinding/loading/main.cpp QDeclarativeComponent-b +\snippet doc/src/snippets/qml/qtbinding/loading/main.cpp QQmlComponent-b \o -\snippet doc/src/snippets/declarative/qtbinding/loading/main.cpp QDeclarativeView +\snippet doc/src/snippets/qml/qtbinding/loading/main.cpp QQuickView \endtable This \c object is the instance of the \c MyItem.qml component that has been created. You can now -modify the item's properties using QObject::setProperty() or QDeclarativeProperty: +modify the item's properties using QObject::setProperty() or QQmlProperty: -\snippet doc/src/snippets/declarative/qtbinding/loading/main.cpp properties +\snippet doc/src/snippets/qml/qtbinding/loading/main.cpp properties Alternatively, you can cast the object to its actual type and call functions with compile-time safety. In this case the base object of \c MyItem.qml is an \l Item, which is defined by the -QDeclarativeItem class: +QQuickItem class: -\snippet doc/src/snippets/declarative/qtbinding/loading/main.cpp cast +\snippet doc/src/snippets/qml/qtbinding/loading/main.cpp cast You can also connect to any signals or call functions defined in the component using QMetaObject::invokeMethod() and QObject::connect(). See \l {Exchanging data between QML and C++} @@ -154,14 +154,14 @@ QML components are essentially object trees with children that have siblings and Child objects of QML components can be located using the QObject::objectName property with QObject::findChild(). For example, if the root item in \c MyItem.qml had a child \l Rectangle item: -\snippet doc/src/snippets/declarative/qtbinding/loading/MyItem.qml start +\snippet doc/src/snippets/qml/qtbinding/loading/MyItem.qml start \codeline -\snippet doc/src/snippets/declarative/qtbinding/loading/MyItem.qml child -\snippet doc/src/snippets/declarative/qtbinding/loading/MyItem.qml end +\snippet doc/src/snippets/qml/qtbinding/loading/MyItem.qml child +\snippet doc/src/snippets/qml/qtbinding/loading/MyItem.qml end The child could be located like this: -\snippet doc/src/snippets/declarative/qtbinding/loading/main.cpp findChild +\snippet doc/src/snippets/qml/qtbinding/loading/main.cpp findChild If \c objectName is used inside a delegate of a ListView, \l Repeater or some other element that creates multiple instances of its delegates, there will be multiple children with @@ -181,18 +181,18 @@ the QML user interface implementation and the composition of the QML object tree \section2 Embedding C++ Objects into QML Components When loading a QML scene into a C++ application, it can be useful to directly embed C++ data into -the QML object. QDeclarativeContext enables this by exposing data to the context of a QML +the QML object. QQmlContext enables this by exposing data to the context of a QML component, allowing data to be injected from C++ into QML. For example, here is a QML item that refers to a \c currentDateTime value that does not exist in the current scope: -\snippet doc/src/snippets/declarative/qtbinding/context/MyItem.qml 0 +\snippet doc/src/snippets/qml/qtbinding/context/MyItem.qml 0 This \c currentDateTime value can be set directly by the C++ application that loads the QML -component, using QDeclarativeContext::setContextProperty(): +component, using QQmlContext::setContextProperty(): -\snippet doc/src/snippets/declarative/qtbinding/context/main.cpp 0 +\snippet doc/src/snippets/qml/qtbinding/context/main.cpp 0 Context properties can hold either QVariant or QObject* values. This means custom C++ objects can also be injected using this approach, and these objects can be modified and read directly in QML. @@ -202,11 +202,11 @@ invokes a method on the object instance: \table \row \o -\snippet doc/src/snippets/declarative/qtbinding/context-advanced/applicationdata.h 0 +\snippet doc/src/snippets/qml/qtbinding/context-advanced/applicationdata.h 0 \codeline -\snippet doc/src/snippets/declarative/qtbinding/context-advanced/main.cpp 0 +\snippet doc/src/snippets/qml/qtbinding/context-advanced/main.cpp 0 \o -\snippet doc/src/snippets/declarative/qtbinding/context-advanced/MyItem.qml 0 +\snippet doc/src/snippets/qml/qtbinding/context-advanced/MyItem.qml 0 \endtable (Note that date/time values returned from C++ to QML can be formatted through @@ -217,7 +217,7 @@ If the QML item needs to receive signals from the context property, it can conne dataChanged(), this signal can be connected to using an \c onDataChanged handler within a \l Connections object: -\snippet doc/src/snippets/declarative/qtbinding/context-advanced/connections.qml 0 +\snippet doc/src/snippets/qml/qtbinding/context-advanced/connections.qml 0 Context properties can be useful for using C++ based data models in a QML view. See the \l {declarative/modelviews/stringlistmodel}{String ListModel}, @@ -226,7 +226,7 @@ Context properties can be useful for using C++ based data models in a QML view. respective examples on using QStringListModel, QObjectList-based models and QAbstractItemModel in QML views. -Also see the QDeclarativeContext documentation for more information. +Also see the QQmlContext documentation for more information. \section2 Defining New QML Elements @@ -236,30 +236,30 @@ defined by C++ classes; in fact, many of the core \l {QML Elements} are implemen C++ classes. When you create a QML object using one of these elements, you are simply creating an instance of a QObject-based C++ class and setting its properties. -To create a visual item that fits in with the Qt Quick elements, base your class off \l QDeclarativeItem instead of QObject directly. -You can then implement your own painting and functionality like any other QGraphicsObject. Note that QGraphicsItem::ItemHasNoContents is set by default on QDeclarativeItem because +To create a visual item that fits in with the Qt Quick elements, base your class off \l QQuickItem instead of QObject directly. +You can then implement your own painting and functionality like any other QGraphicsObject. Note that QGraphicsItem::ItemHasNoContents is set by default on QQuickItem because it does not paint anything; you will need to clear this if your item is supposed to paint anything (as opposed to being solely for input handling or logical grouping). For example, here is an \c ImageViewer class with an \c image URL property: -\snippet doc/src/snippets/declarative/qtbinding/newelements/imageviewer.h 0 +\snippet doc/src/snippets/qml/qtbinding/newelements/imageviewer.h 0 -Aside from the fact that it inherits QDeclarativeItem, this is an ordinary class that could +Aside from the fact that it inherits QQuickItem, this is an ordinary class that could exist outside of QML. However, once it is registered with the QML engine using qmlRegisterType(): -\snippet doc/src/snippets/declarative/qtbinding/newelements/main.cpp register +\snippet doc/src/snippets/qml/qtbinding/newelements/main.cpp register -Then, any QML code loaded by your C++ application or \l{QDeclarativeExtensionPlugin}{plugin} can create and manipulate +Then, any QML code loaded by your C++ application or \l{QQmlExtensionPlugin}{plugin} can create and manipulate \c ImageViewer objects: -\snippet doc/src/snippets/declarative/qtbinding/newelements/standalone.qml 0 +\snippet doc/src/snippets/qml/qtbinding/newelements/standalone.qml 0 -It is advised that you avoid using QGraphicsItem functionality beyond the properties documented in QDeclarativeItem. +It is advised that you avoid using QGraphicsItem functionality beyond the properties documented in QQuickItem. This is because the GraphicsView backend is intended to be an implementation detail for QML, so the QtQuick items can be moved to faster backends as they become available with no change from a QML perspective. -To minimize any porting requirements for custom visual items, try to stick to the documented properties in QDeclarativeItem where possible. Properties QDeclarativeItem inherits but doesn't document are classed as implementation details; they are not officially supported and may disappear between releases. +To minimize any porting requirements for custom visual items, try to stick to the documented properties in QQuickItem where possible. Properties QQuickItem inherits but doesn't document are classed as implementation details; they are not officially supported and may disappear between releases. -Note that custom C++ types do not have to inherit from QDeclarativeItem; this is only necessary if it is +Note that custom C++ types do not have to inherit from QQuickItem; this is only necessary if it is a displayable item. If the item is not displayable, it can simply inherit from QObject. For more information on defining new QML elements, see the \l {Tutorial: Writing QML extensions with C++} @@ -286,8 +286,8 @@ QMetaObject::invokeMethod(). Here is a C++ application that uses this to call a \table \row -\o \snippet doc/src/snippets/declarative/qtbinding/functions-qml/MyItem.qml 0 -\o \snippet doc/src/snippets/declarative/qtbinding/functions-qml/main.cpp 0 +\o \snippet doc/src/snippets/qml/qtbinding/functions-qml/MyItem.qml 0 +\o \snippet doc/src/snippets/qml/qtbinding/functions-qml/main.cpp 0 \endtable Notice the Q_RETURN_ARG() and Q_ARG() arguments for QMetaObject::invokeMethod() must be specified as @@ -295,16 +295,16 @@ QVariant types, as this is the generic data type used for QML functions and retu To call a C++ function from QML, the function must be either a Qt slot, or a function marked with the Q_INVOKABLE macro, to be available to QML. In the following example, the QML code invokes -methods on the \c myObject object, which has been set using QDeclarativeContext::setContextProperty(): +methods on the \c myObject object, which has been set using QQmlContext::setContextProperty(): \table \row \o -\snippet doc/src/snippets/declarative/qtbinding/functions-cpp/MyItem.qml 0 +\snippet doc/src/snippets/qml/qtbinding/functions-cpp/MyItem.qml 0 \o -\snippet doc/src/snippets/declarative/qtbinding/functions-cpp/myclass.h 0 +\snippet doc/src/snippets/qml/qtbinding/functions-cpp/myclass.h 0 \codeline -\snippet doc/src/snippets/declarative/qtbinding/functions-cpp/main.cpp 0 +\snippet doc/src/snippets/qml/qtbinding/functions-cpp/main.cpp 0 \endtable QML supports the calling of overloaded C++ functions. If there are multiple C++ functions with the @@ -325,11 +325,11 @@ is emitted: \table \row \o -\snippet doc/src/snippets/declarative/qtbinding/signals-qml/MyItem.qml 0 +\snippet doc/src/snippets/qml/qtbinding/signals-qml/MyItem.qml 0 \o -\snippet doc/src/snippets/declarative/qtbinding/signals-qml/myclass.h 0 +\snippet doc/src/snippets/qml/qtbinding/signals-qml/myclass.h 0 \codeline -\snippet doc/src/snippets/declarative/qtbinding/signals-qml/main.cpp 0 +\snippet doc/src/snippets/qml/qtbinding/signals-qml/main.cpp 0 \endtable To connect to Qt C++ signals from within QML, use a signal handler with the \c on syntax. @@ -342,12 +342,12 @@ C++ object are connected to through \c onImagedChanged and \c onLoadingError sig \row \o -\snippet doc/src/snippets/declarative/qtbinding/signals-cpp/imageviewer.h start +\snippet doc/src/snippets/qml/qtbinding/signals-cpp/imageviewer.h start \dots 4 -\snippet doc/src/snippets/declarative/qtbinding/signals-cpp/imageviewer.h end +\snippet doc/src/snippets/qml/qtbinding/signals-cpp/imageviewer.h end \o -\snippet doc/src/snippets/declarative/qtbinding/signals-cpp/standalone.qml 0 +\snippet doc/src/snippets/qml/qtbinding/signals-cpp/standalone.qml 0 \endtable (Note that if a signal has been declared as the NOTIFY signal for a property, QML allows it to be @@ -357,13 +357,13 @@ received with an \c onChanged handler even if the signal's name does n If, however, the object with the signal is not created from within the QML code, and the QML item only has a reference to the created object - for example, if the object was set using -QDeclarativeContext::setContextProperty() - then the \l Connections element can be used +QQmlContext::setContextProperty() - then the \l Connections element can be used instead to create the signal handler: \table \row -\o \snippet doc/src/snippets/declarative/qtbinding/signals-cpp/main.cpp connections -\o \snippet doc/src/snippets/declarative/qtbinding/signals-cpp/MyItem.qml 0 +\o \snippet doc/src/snippets/qml/qtbinding/signals-cpp/main.cpp connections +\o \snippet doc/src/snippets/qml/qtbinding/signals-cpp/MyItem.qml 0 \endtable C++ signals can use enum values as parameters provided that the enum is declared in the @@ -376,14 +376,14 @@ See \l {Using enumerations of a custom type} below for details. Any properties declared in a QML object are automatically accessible from C++. Given a QML item like this: -\snippet doc/src/snippets/declarative/qtbinding/properties-qml/MyItem.qml 0 +\snippet doc/src/snippets/qml/qtbinding/properties-qml/MyItem.qml 0 -The value of the \c someNumber property can be set and read using QDeclarativeProperty, or +The value of the \c someNumber property can be set and read using QQmlProperty, or QObject::setProperty() and QObject::property(): -\snippet doc/src/snippets/declarative/qtbinding/properties-qml/main.cpp 0 +\snippet doc/src/snippets/qml/qtbinding/properties-qml/main.cpp 0 -You should always use QObject::setProperty(), QDeclarativeProperty or QMetaProperty::write() to +You should always use QObject::setProperty(), QQmlProperty or QMetaProperty::write() to change a QML property value, to ensure the QML engine is made aware of the property change. For example, say you have a custom element \c PushButton with a \c buttonText property that internally reflects the value of a \c m_buttonText member variable. Modifying the member variable directly like this is @@ -391,7 +391,7 @@ not a good idea: \badcode // BAD! -QDeclarativeComponent component(engine, "MyButton.qml"); +QQmlComponent component(engine, "MyButton.qml"); PushButton *button = qobject_cast(component.create()); button->m_buttonText = "Click me"; \endcode @@ -410,8 +410,8 @@ property. This property can be written to and read from QML: \table \row -\o \snippet doc/src/snippets/declarative/qtbinding/properties-cpp/applicationdata.h 0 -\o \snippet doc/src/snippets/declarative/qtbinding/properties-cpp/MyItem.qml 0 +\o \snippet doc/src/snippets/qml/qtbinding/properties-cpp/applicationdata.h 0 +\o \snippet doc/src/snippets/qml/qtbinding/properties-cpp/MyItem.qml 0 \endtable Notice the \c backgroundColorChanged signal is declared as the NOTIFY signal for the @@ -468,8 +468,8 @@ converted to JavaScript array and object values, repectively: \o String format \o Example \row -\o \snippet doc/src/snippets/declarative/qtbinding/variantlistmap/MyItem.qml 0 -\o \snippet doc/src/snippets/declarative/qtbinding/variantlistmap/main.cpp 0 +\o \snippet doc/src/snippets/qml/qtbinding/variantlistmap/MyItem.qml 0 +\o \snippet doc/src/snippets/qml/qtbinding/variantlistmap/main.cpp 0 \endtable This produces output like: @@ -492,13 +492,13 @@ side, and is automatically converted to a QVariantList or QVariantMap when it is To use an enumeration from a custom C++ component, the enumeration must be declared with Q_ENUMS() to register it with Qt's meta object system. For example, the following C++ type has a \c Status enum: -\snippet doc/src/snippets/declarative/qtbinding/enums/imageviewer.h start -\snippet doc/src/snippets/declarative/qtbinding/enums/imageviewer.h end +\snippet doc/src/snippets/qml/qtbinding/enums/imageviewer.h start +\snippet doc/src/snippets/qml/qtbinding/enums/imageviewer.h end Providing the \c ImageViewer class has been registered using qmlRegisterType(), its \c Status enum can now be used from QML: -\snippet doc/src/snippets/declarative/qtbinding/enums/standalone.qml 0 +\snippet doc/src/snippets/qml/qtbinding/enums/standalone.qml 0 The C++ type must be registered with QML to use its enums. If your C++ type is not instantiable, it can be registered using qmlRegisterUncreatableType(). To be accessible from QML, the names of enum values @@ -525,7 +525,7 @@ function, the enum type must be registered using qRegisterMetaType(). For QML signals, enum values may be used as signal parameters using the \c int type: -\snippet doc/src/snippets/declarative/qtbinding/enums/standalone.qml 1 +\snippet doc/src/snippets/qml/qtbinding/enums/standalone.qml 1 \section2 Automatic Type Conversion from Strings @@ -594,11 +594,11 @@ a QColor-type property or to call a C++ function that requires a QColor paramete \section1 Writing QML plugins -The Qt Declarative module includes the QDeclarativeExtensionPlugin class, which is an abstract +The Qt Declarative module includes the QQmlExtensionPlugin class, which is an abstract class for writing QML plugins. This allows QML extension types to be dynamically loaded into QML applications. -See the QDeclarativeExtensionPlugin documentation and \l {How to Create Qt Plugins} for more +See the QQmlExtensionPlugin documentation and \l {How to Create Qt Plugins} for more details. @@ -643,22 +643,22 @@ project The \c main.qml and \c background.png files will be packaged as resource files. This is done in the \c example.qrc resource collection file: -\quotefile doc/src/snippets/declarative/qtbinding/resources/example.qrc +\quotefile doc/src/snippets/qml/qtbinding/resources/example.qrc Since \c background.png is a resource file, \c main.qml can refer to it using the relative path specified in \c example.qrc: -\snippet doc/src/snippets/declarative/qtbinding/resources/main.qml 0 +\snippet doc/src/snippets/qml/qtbinding/resources/main.qml 0 To allow QML to locate resource files correctly, the \c main.cpp loads the main QML file, \c main.qml, as a resource file using the \c qrc scheme: -\snippet doc/src/snippets/declarative/qtbinding/resources/main.cpp 0 +\snippet doc/src/snippets/qml/qtbinding/resources/main.cpp 0 Finally \c project.pro uses the RESOURCES variable to indicate that \c example.qrc should be used to build the application resources: -\quotefile doc/src/snippets/declarative/qtbinding/resources/resources.pro +\quotefile doc/src/snippets/qml/qtbinding/resources/resources.pro See \l {The Qt Resource System} for more information. diff --git a/doc/src/qml/qtdeclarative.qdoc b/doc/src/qml/qtdeclarative.qdoc index c4b59fb07b..9d14f7fc57 100644 --- a/doc/src/qml/qtdeclarative.qdoc +++ b/doc/src/qml/qtdeclarative.qdoc @@ -26,7 +26,7 @@ ****************************************************************************/ /*! - \module QtDeclarative + \module QtQml \title Qt Declarative Module \ingroup modules @@ -37,7 +37,7 @@ following directive: \code - #include + #include \endcode To link against the module, add this line to your \l qmake \c @@ -54,16 +54,16 @@ /*! \macro QML_DECLARE_TYPE() - \relates QDeclarativeEngine + \relates QQmlEngine - Equivalent to \c Q_DECLARE_METATYPE(TYPE *) and \c Q_DECLARE_METATYPE(QDeclarativeListProperty) + Equivalent to \c Q_DECLARE_METATYPE(TYPE *) and \c Q_DECLARE_METATYPE(QQmlListProperty) - #include to use this macro. + #include to use this macro. */ /*! \macro QML_DECLARE_TYPEINFO(Type,Flags) - \relates QDeclarativeEngine + \relates QQmlEngine Declares additional properties of the given \a Type as described by the specified \a Flags. @@ -71,13 +71,13 @@ Current the only supported type info is \c QML_HAS_ATTACHED_PROPERTIES which declares that the \a Type supports \l {Attached Properties}. - #include to use this macro. + #include to use this macro. */ /*! \fn int qmlRegisterType(const char *uri, int versionMajor, int versionMinor, const char *qmlName) - \relates QDeclarativeEngine + \relates QQmlEngine This template function registers the C++ type in the QML system with the name \a qmlName, in the library imported from \a uri having the @@ -105,7 +105,7 @@ "com.mycompany.qmlcomponents": \code - #include + #include ... @@ -131,7 +131,7 @@ /*! \fn int qmlRegisterRevision(const char *uri, int versionMajor, int versionMinor) - \relates QDeclarativeEngine + \relates QQmlEngine This template function registers the specified revision of a C++ type in the QML system with the library imported from \a uri having the version number composed @@ -150,7 +150,7 @@ /*! \fn int qmlRegisterUncreatableType(const char *uri, int versionMajor, int versionMinor, const char *qmlName, const QString& message) - \relates QDeclarativeEngine + \relates QQmlEngine This template function registers the C++ type in the QML system with the name \a qmlName, in the library imported from \a uri having the @@ -163,14 +163,14 @@ Returns the QML type id. - #include to use this function. + #include to use this function. \sa qmlRegisterTypeNotAvailable() */ /*! \fn int qmlRegisterTypeNotAvailable(const char *uri, int versionMajor, int versionMinor, const char *qmlName, const QString& message) - \relates QDeclarativeEngine + \relates QQmlEngine This function registers a type in the QML system with the name \a qmlName, in the library imported from \a uri having the version number composed from \a versionMajor and \a versionMinor, but any attempt to instantiate the type @@ -200,40 +200,40 @@ Without this, a generic "Game is not a type" message would be given. - #include to use this function. + #include to use this function. \sa qmlRegisterUncreatableType() */ /*! \fn int qmlRegisterType() - \relates QDeclarativeEngine + \relates QQmlEngine \overload This template function registers the C++ type in the QML system. Instances of this type cannot be created from the QML system. - #include to use this function. + #include to use this function. Returns the QML type id. */ /*! \fn int qmlRegisterInterface(const char *typeName) - \relates QDeclarativeEngine + \relates QQmlEngine This template function registers the C++ type in the QML system under the name \a typeName. - #include to use this function. + #include to use this function. Returns the QML type id. */ /*! - \fn int qmlRegisterModuleApi(const char *uri, int versionMajor, int versionMinor, QJSValue (*callback)(QDeclarativeEngine *, QJSEngine *)) - \relates QDeclarativeEngine + \fn int qmlRegisterModuleApi(const char *uri, int versionMajor, int versionMinor, QJSValue (*callback)(QQmlEngine *, QJSEngine *)) + \relates QQmlEngine This function may be used to register a module API provider \a callback in a particular \a uri with a version specified in \a versionMajor and \a versionMinor. @@ -250,7 +250,7 @@ Usage: \code // first, define the module API provider function (callback). - static QJSValue *example_qjsvalue_module_api_provider(QDeclarativeEngine *engine, QJSEngine *scriptEngine) + static QJSValue *example_qjsvalue_module_api_provider(QQmlEngine *engine, QJSEngine *scriptEngine) { Q_UNUSED(engine) @@ -278,8 +278,8 @@ */ /*! - \fn int qmlRegisterModuleApi(const char *uri, int versionMajor, int versionMinor, QObject *(*callback)(QDeclarativeEngine *, QJSEngine *)) - \relates QDeclarativeEngine + \fn int qmlRegisterModuleApi(const char *uri, int versionMajor, int versionMinor, QObject *(*callback)(QQmlEngine *, QJSEngine *)) + \relates QQmlEngine This function may be used to register a module API provider \a callback in a particular \a uri with a version specified in \a versionMajor and \a versionMinor. @@ -325,7 +325,7 @@ }; // second, define the module API provider function (callback). - static QObject *example_qobject_module_api_provider(QDeclarativeEngine *engine, QJSEngine *scriptEngine) + static QObject *example_qobject_module_api_provider(QQmlEngine *engine, QJSEngine *scriptEngine) { Q_UNUSED(engine) Q_UNUSED(scriptEngine) diff --git a/doc/src/qml/qtprogrammers.qdoc b/doc/src/qml/qtprogrammers.qdoc index 215f71859c..9338a2c29f 100644 --- a/doc/src/qml/qtprogrammers.qdoc +++ b/doc/src/qml/qtprogrammers.qdoc @@ -44,7 +44,7 @@ QML provides direct access to the following concepts from Qt: \o QAction - the \l {QML Basic Types}{action} type \o QObject signals and slots - available as functions to call in JavaScript \o QObject properties - available as variables in JavaScript - \o QWidget - QDeclarativeView is a QML-displaying widget + \o QWidget - QQuickView is a QML-displaying widget \o Qt models - used directly in data binding (QAbstractItemModel) \endlist @@ -71,12 +71,12 @@ QML Items also serve these purposes. Each is considered separately below. \section2 Simple Widgets -The most important rule to remember while implementing a new QDeclarativeItem in C++ +The most important rule to remember while implementing a new QQuickItem in C++ is that it should not contain any look and feel policies; leave that to the QML usage of the item. As an example, imagine you wanted a reusable Button item. If you therefore decided -to write a QDeclarativeItem subclass to implement a button, just as QToolButton +to write a QQuickItem subclass to implement a button, just as QToolButton subclasses QWidget for this purpose, following the rule above, your \c QDeclarativeButton would not have any appearance; just the notions of enabled, triggering, etc. @@ -92,7 +92,7 @@ between states, and exactly how it responds to mouse, key, or touch input, shoul all be left for definition in QML. It is illustrative to note that QDeclarativeTextEdit is built upon QTextControl, -QDeclarativeWebView is built upon QWebPage, and ListView uses QAbstractItemModel, +QQuickWebView is built upon QWebPage, and ListView uses QAbstractItemModel, just as QTextEdit, QWebView, and QListView are built upon those same UI-agnostic components. @@ -167,7 +167,7 @@ QGraphicsWidgets are usually designed to be laid out with QGraphicsLayouts. QML not use QGraphicsLayouts, as the Qt layouts do not mix well with animated and fluid UIs, so the geometry interface is one of the main differences. When writing QML elements, you allow the designers to place their bounding rectangle using absolute -geometry, bindings or anchors (all set up for you when you inherit QDeclarativeItem) +geometry, bindings or anchors (all set up for you when you inherit QQuickItem) and you do not use layouts or size hints. If size hints are appropriate, then place them in the QML documentation so that the designers know how to use the item best, but still have complete control over the look and feel. @@ -182,14 +182,14 @@ look and feel (which involves the UI logic) can be written in QML. Both differences are caused by the different method of interaction. QGraphicsWidget is a QGraphicsObject subclass which makes fluid UI development from C++ easier, and -QDeclarativeItem is a QGraphicsObject subclass which makes fluid UI development +QQuickItem is a QGraphicsObject subclass which makes fluid UI development from QML easier. The difference, therefore, is primarily one of the interface exposed, and the design of the items that come with it; the declarative primitives for QML and nothing for QGraphicsWidget, because you need to write your own UI logic into the subclass. If you wish to use both QML and C++ to write the UI, for example to ease the -transition period, it is recommended to use QDeclarativeItem subclasses, although +transition period, it is recommended to use QQuickItem subclasses, although you can use QGraphicsWidgets as well. To allow for easier use from C++, make the root item of each C++ component a \l LayoutItem, and load individual "widgets" of QML (possibly comprised of multiple files, and containing a self-contained bundle diff --git a/doc/src/qtquick2/animation.qdoc b/doc/src/qtquick2/animation.qdoc index 626571f50e..cf656fb209 100644 --- a/doc/src/qtquick2/animation.qdoc +++ b/doc/src/qtquick2/animation.qdoc @@ -76,14 +76,14 @@ There are several ways of setting animation to an object. To create an immediate movement or animated movement, set the property value directly. This may be done in signal handlers or attached properties. -\snippet doc/src/snippets/declarative/animation.qml direct property change +\snippet doc/src/snippets/qml/animation.qml direct property change However, to create more control, \i {property animations} apply smooth movements by interpolating values between property value changes. Property animations provide timing controls and allows different interpolations through \l{qml-easing-animation}{easing curves}. -\snippet doc/src/snippets/declarative/animation.qml property animation +\snippet doc/src/snippets/qml/animation.qml property animation Specialized \l{qml-property-animation-elements}{property animation elements} have more efficient implementations than the \l{PropertyAnimation} element. They @@ -112,14 +112,14 @@ change from the \c pressed state to the \c released state. Likewise, there would be an animation during the change from the \c released state to the \c pressed state. -\snippet doc/src/snippets/declarative/animation.qml transition animation +\snippet doc/src/snippets/qml/animation.qml transition animation Binding the \c to and \c from properties to the state's name will assign that particular transition to the state change. For simple or symmetric transitions, setting the to \c to property to the wild card symbol, "\c{*}", denotes that the transition applies to any state change. -\snippet doc/src/snippets/declarative/animation.qml wildcard animation +\snippet doc/src/snippets/qml/animation.qml wildcard animation \section2 Default Animation as Behaviors @@ -133,7 +133,7 @@ A ball component might have a behavior animation assigned to its \c x, \c y, and elastic effect. In effect, this behavior animation would apply the elastic effect to the properties whenever the ball moves. -\snippet doc/src/snippets/declarative/animation.qml behavior animation +\snippet doc/src/snippets/qml/animation.qml behavior animation There are several methods of assigning behavior animations to properties. The \c{Behavior on } declaration is a convenient way of assigning a @@ -156,7 +156,7 @@ object. Using the \l{SequentialAnimation} element, the opacity animations will play after the preceding animation finishes. The \l{ParallelAnimation} element will play the animations at the same time. -\snippet doc/src/snippets/declarative/animation.qml sequential animation +\snippet doc/src/snippets/qml/animation.qml sequential animation Once individual animations are placed into a SequentialAnimation or ParallelAnimation, they can no longer be started and stopped independently. The @@ -257,15 +257,15 @@ Rectangle { -\snippet doc/src/snippets/declarative/animation-elements.qml color -\snippet doc/src/snippets/declarative/animation-propertyvaluesource.qml 0 -\snippet doc/src/snippets/declarative/animation-signalhandler.qml 0 -\snippet doc/src/snippets/declarative/animation-standalone.qml 0 +\snippet doc/src/snippets/qml/animation-elements.qml color +\snippet doc/src/snippets/qml/animation-propertyvaluesource.qml 0 +\snippet doc/src/snippets/qml/animation-signalhandler.qml 0 +\snippet doc/src/snippets/qml/animation-standalone.qml 0 -\snippet doc/src/snippets/declarative/animation-transitions.qml 0 -\snippet doc/src/snippets/declarative/animation-groups.qml 0 +\snippet doc/src/snippets/qml/animation-transitions.qml 0 +\snippet doc/src/snippets/qml/animation-groups.qml 0 -\snippet doc/src/snippets/declarative/animation-groups.qml 1 -\snippet doc/src/snippets/declarative/animation-groups.qml 0 +\snippet doc/src/snippets/qml/animation-groups.qml 1 +\snippet doc/src/snippets/qml/animation-groups.qml 0 \image propanim.gif diff --git a/doc/src/qtquick2/focus.qdoc b/doc/src/qtquick2/focus.qdoc index 05d797e7be..e2c4c79d3c 100644 --- a/doc/src/qtquick2/focus.qdoc +++ b/doc/src/qtquick2/focus.qdoc @@ -43,7 +43,7 @@ and to address some of the cases unique to fluid user interfaces, the QML items When the user presses or releases a key, the following occurs: \list 1 \o Qt receives the key action and generates a key event. -\o If the Qt widget containing the \l QDeclarativeView has focus, the key event +\o If the Qt widget containing the \l QQuickView has focus, the key event is delivered to it. Otherwise, regular Qt key handling continues. \o The key event is delivered by the scene to the QML \l Item with \i {active focus}. If no Item has active focus, the key event is @@ -56,8 +56,8 @@ If the \c {Rectangle} element in the following example has active focus and the it will bubble up to its parent. However, pressing the \c B key will bubble up to the root item and thus subsequently be ignored. -\snippet doc/src/snippets/declarative/focus/rectangle.qml simple key event -\snippet doc/src/snippets/declarative/focus/rectangle.qml simple key event end +\snippet doc/src/snippets/qml/focus/rectangle.qml simple key event +\snippet doc/src/snippets/qml/focus/rectangle.qml simple key event end \o If the root \l Item is reached, the key event is \l {QEvent::ignore()}{ignored} and regular Qt key handling continues. @@ -71,7 +71,7 @@ Whether or not an \l Item has active focus can be queried through the property \c {Item::activeFocus} property. For example, here we have a \l Text element whose text is determined by whether or not it has active focus. -\snippet doc/src/snippets/declarative/focus/rectangle.qml active focus +\snippet doc/src/snippets/qml/focus/rectangle.qml active focus \section1 Acquiring Focus and Focus Scopes @@ -82,7 +82,7 @@ sufficient. If we run the following example with the \l {QML Viewer}, we see tha the \c {keyHandler} element has active focus and pressing the \c A, \c B, or \c C keys modifies the text appropriately. -\snippet doc/src/snippets/declarative/focus/basicwidget.qml focus true +\snippet doc/src/snippets/qml/focus/basicwidget.qml focus true \image declarative-qmlfocus1.png @@ -95,10 +95,10 @@ set the first one to have focus. The intention is that when the \c A, \c B, or responds accordingly. The code that imports and creates two MyWidget instances: -\snippet doc/src/snippets/declarative/focus/widget.qml window +\snippet doc/src/snippets/qml/focus/widget.qml window The MyWidget code: -\snippet doc/src/snippets/declarative/focus/MyWidget.qml mywidget +\snippet doc/src/snippets/qml/focus/MyWidget.qml mywidget We would like to have the first MyWidget object to have the focus by setting its \c focus property to \c true. However, by running the code, we can confirm that @@ -126,7 +126,7 @@ A focus scope is created by declaring the \l FocusScope element. In the next example, a \l FocusScope element is added to the component, and the visual result shown. -\snippet doc/src/snippets/declarative/focus/myfocusscopewidget.qml widget in focusscope +\snippet doc/src/snippets/qml/focus/myfocusscopewidget.qml widget in focusscope \image declarative-qmlfocus3.png @@ -158,10 +158,10 @@ Now, clicking either MyClickableWidget gives it focus and the other widget loses the focus. The code that imports and creates two MyClickableWidget instances: -\snippet doc/src/snippets/declarative/focus/clickablewidget.qml clickable window +\snippet doc/src/snippets/qml/focus/clickablewidget.qml clickable window The MyClickableWidget code: -\snippet doc/src/snippets/declarative/focus/MyClickableWidget.qml clickable in focusscope +\snippet doc/src/snippets/qml/focus/MyClickableWidget.qml clickable in focusscope \image declarative-qmlfocus4.png @@ -188,7 +188,7 @@ current item delegate to react to key presses. This contrived example shows how this works. Pressing the \c Return key will print the name of the current list item. -\snippet doc/src/snippets/declarative/focus/advancedFocus.qml FocusScope delegate +\snippet doc/src/snippets/qml/focus/advancedFocus.qml FocusScope delegate \image declarative-qmlfocus5.png diff --git a/doc/src/qtquick2/modelview.qdoc b/doc/src/qtquick2/modelview.qdoc index 56c726eab8..5d799027ad 100644 --- a/doc/src/qtquick2/modelview.qdoc +++ b/doc/src/qtquick2/modelview.qdoc @@ -80,13 +80,13 @@ To visualize data, bind the view's \c model property to a model and the Suppose that a specific club wants to decorate its members list with its brand colors. A member list is in a \c model and the \c delegate will display the model's content. - \snippet doc/src/snippets/declarative/listview-decorations.qml model - \snippet doc/src/snippets/declarative/listview-decorations.qml delegate + \snippet doc/src/snippets/qml/listview-decorations.qml model + \snippet doc/src/snippets/qml/listview-decorations.qml delegate The club may decorate the members list by binding visual objects to the \c header and \c footer properties. The visual object may be defined inline, in another file, or in a \l {Component} element. - \snippet doc/src/snippets/declarative/listview-decorations.qml decorations + \snippet doc/src/snippets/qml/listview-decorations.qml decorations \image listview-decorations.png \section2 Mouse and Touch Handling @@ -110,8 +110,8 @@ To visualize data, bind the view's \c model property to a model and the A list may contain a list indicating people's names and the team on which team the person belongs. - \snippet doc/src/snippets/declarative/listview-sections.qml model - \snippet doc/src/snippets/declarative/listview-sections.qml delegate + \snippet doc/src/snippets/qml/listview-sections.qml model + \snippet doc/src/snippets/qml/listview-sections.qml delegate The ListView element has the \c section \l{Property Binding in QML#Attached Properties}{attached property} that can combine adjacent and related @@ -119,7 +119,7 @@ To visualize data, bind the view's \c model property to a model and the which list element property to use as sections. The \c criteria can dictate how the section names are displayed and the \c delegate is similar to the views' \l {qml-view-delegate}{delegate} property. - \snippet doc/src/snippets/declarative/listview-sections.qml section + \snippet doc/src/snippets/qml/listview-sections.qml section \image listview-section.png \keyword qml-view-delegate @@ -129,7 +129,7 @@ To visualize data, bind the view's \c model property to a model and the visualize each item list according to the template defined by the delegate. Items in a model are accessible through the \c index property as well as the item's properties. - \snippet doc/src/snippets/declarative/listview.qml delegate + \snippet doc/src/snippets/qml/listview.qml delegate \image listview-setup.png \section2 Accessing Views and Models from Delegates @@ -150,7 +150,7 @@ To visualize data, bind the view's \c model property to a model and the the model, and the color of one of the fields depends on the property \i{fruit_color} of the view. - \snippet doc/src/snippets/declarative/models/views-models-delegates.qml rectangle + \snippet doc/src/snippets/qml/models/views-models-delegates.qml rectangle \keyword qml-data-models \section1 Models @@ -159,7 +159,7 @@ To visualize data, bind the view's \c model property to a model and the bind to. Here is a ListModel with two roles, \i type and \i age, and a ListView with a delegate that binds to these roles to display their values: - \snippet doc/src/snippets/declarative/qml-data-models/listmodel-listview.qml document + \snippet doc/src/snippets/qml/qml-data-models/listmodel-listview.qml document If there is a naming clash between the model's properties and the delegate's properties, the roles can be accessed with the qualified \i model name @@ -197,12 +197,12 @@ To visualize data, bind the view's \c model property to a model and the ListModel is a simple hierarchy of elements specified in QML. The available roles are specified by the \l ListElement properties. - \snippet doc/src/snippets/declarative/qml-data-models/listelements.qml model + \snippet doc/src/snippets/qml/qml-data-models/listelements.qml model The above model has two roles, \i name and \i cost. These can be bound to by a ListView delegate, for example: - \snippet doc/src/snippets/declarative/qml-data-models/listelements.qml view + \snippet doc/src/snippets/qml/qml-data-models/listelements.qml view ListModel provides methods to manipulate the ListModel directly via JavaScript. In this case, the first item inserted determines the roles available @@ -210,9 +210,9 @@ To visualize data, bind the view's \c model property to a model and the created and populated via JavaScript, the roles provided by the first insertion are the only roles that will be shown in the view: - \snippet doc/src/snippets/declarative/qml-data-models/dynamic-listmodel.qml model + \snippet doc/src/snippets/qml/qml-data-models/dynamic-listmodel.qml model \dots - \snippet doc/src/snippets/declarative/qml-data-models/dynamic-listmodel.qml mouse area + \snippet doc/src/snippets/qml/qml-data-models/dynamic-listmodel.qml mouse area When the MouseArea is clicked, \c fruitModel will have two roles, \i cost and \i name. Even if subsequent roles are added, only the first two will be handled by views @@ -253,7 +253,7 @@ To visualize data, bind the view's \c model property to a model and the VisualItemModel provide the contents of the delegate. The model does not provide any roles. - \snippet doc/src/snippets/declarative/models/visual-model-and-view.qml visual model and view + \snippet doc/src/snippets/qml/models/visual-model-and-view.qml visual model and view Note that in the above example there is no delegate required. The items of the model itself provide the visual elements that @@ -347,7 +347,7 @@ The following example shows a repeater used with a \l{#Grid}{Grid} item to arrange a set of Rectangle items. The Repeater item creates a series of 24 rectangles for the Grid item to position in a 5 by 5 arrangement. -\snippet doc/src/snippets/declarative/repeaters/repeater-grid-index.qml document +\snippet doc/src/snippets/qml/repeaters/repeater-grid-index.qml document The number of items created by a Repeater is held by its \l{Repeater::}{count} property. It is not possible to set this property to determine the number of diff --git a/doc/src/qtquick2/mouseevents.qdoc b/doc/src/qtquick2/mouseevents.qdoc index d981c7c1dd..e452611416 100644 --- a/doc/src/qtquick2/mouseevents.qdoc +++ b/doc/src/qtquick2/mouseevents.qdoc @@ -55,7 +55,7 @@ to define this area is to anchor the \c MouseArea to its parent's area using the component), then the MouseArea will fill the area defined by the parent's dimensions. Alternatively, an area smaller or larger than the parent is definable. -\snippet doc/src/snippets/declarative/mousearea/mousearea-snippet.qml anchor fill +\snippet doc/src/snippets/qml/mousearea/mousearea-snippet.qml anchor fill \section1 Receiving Events @@ -77,7 +77,7 @@ gestures in greater detail: \endlist These signals have signal handlers that are invoked when the signals are emitted. -\snippet doc/src/snippets/declarative/mousearea/mousearea-snippet.qml mouse handlers +\snippet doc/src/snippets/qml/mousearea/mousearea-snippet.qml mouse handlers \section1 Enabling Gestures Some mouse gestures and button clicks need to be enabled before they send or @@ -95,7 +95,7 @@ positioning even when there are no mouse button presses. Setting the \c hoverEnabled property to \c true, in turn will enable the \c entered, \c exited, and \c positionChanged signal and their respective signal handlers. -\snippet doc/src/snippets/declarative/mousearea/mousearea-snippet.qml enable handlers +\snippet doc/src/snippets/qml/mousearea/mousearea-snippet.qml enable handlers Additionally, to disable the whole mouse area, set the \c MouseArea element's \c enabled property to \c false. diff --git a/doc/src/qtquick2/positioners.qdoc b/doc/src/qtquick2/positioners.qdoc index c7110f7cf9..55be7087fd 100644 --- a/doc/src/qtquick2/positioners.qdoc +++ b/doc/src/qtquick2/positioners.qdoc @@ -61,7 +61,7 @@ uses a Column item to arrange three \l Rectangle items in an area defined by an outer \l Item. The \l{Column::spacing}{spacing} property is set to include a small amount of space between the rectangles. -\snippet doc/src/snippets/declarative/column/column.qml document +\snippet doc/src/snippets/qml/column/column.qml document Note that, since Column inherits directly from Item, any background color must be added to a parent Rectangle, if desired. @@ -80,7 +80,7 @@ include a small amount of space between the rectangles. We ensure that the parent Rectangle is large enough so that there is some space left around the edges of the horizontally centered Row item. -\snippet doc/src/snippets/declarative/row.qml document +\snippet doc/src/snippets/qml/row.qml document \section2 Grid @@ -93,7 +93,7 @@ The following example uses a Grid item to place four \l Rectangle items in a 2-by-2 grid. As with the other positioners, the spacing between items can be specified using the \l{Grid::spacing}{spacing} property. -\snippet doc/src/snippets/declarative/grid-spacing.qml document +\snippet doc/src/snippets/qml/grid-spacing.qml document There is no difference between horizontal and vertical spacing inserted between items, so any additional space must be added within the items @@ -122,7 +122,7 @@ The following example shows a Flow item containing a number of \l Text child items. These are arranged in a similar way to those shown in the screenshots. -\snippet doc/src/snippets/declarative/flow.qml document +\snippet doc/src/snippets/qml/flow.qml document The main differences between the Grid and Flow positioners are that items inside a Flow will wrap when they run out of space on the minor axis, and diff --git a/doc/src/qtquick2/qmltexthandling.qdoc b/doc/src/qtquick2/qmltexthandling.qdoc index 876ab3c42f..6e6b2a4c6b 100644 --- a/doc/src/qtquick2/qmltexthandling.qdoc +++ b/doc/src/qtquick2/qmltexthandling.qdoc @@ -62,10 +62,10 @@ respective element documentation. The \l {Validators}{validator} elements enforce the type and format of \l TextInput objects. -\snippet doc/src/snippets/declarative/texthandling.qml int validator +\snippet doc/src/snippets/qml/texthandling.qml int validator The validator elements bind to \c {TextInput}'s \c validator property. -\snippet doc/src/snippets/declarative/texthandling.qml regexp validator +\snippet doc/src/snippets/qml/texthandling.qml regexp validator The regular expression in the snippet will only allow the inputted text to be \c {fruit basket}. diff --git a/doc/src/qtquick2/qtquick-intro.qdoc b/doc/src/qtquick2/qtquick-intro.qdoc index 8aeab7e199..9eebb0bddc 100644 --- a/doc/src/qtquick2/qtquick-intro.qdoc +++ b/doc/src/qtquick2/qtquick-intro.qdoc @@ -34,7 +34,7 @@ create the kind of intuitive, modern, and fluid user interfaces that are increasingly used on mobile phones, media players, set-top boxes, and other portable devices. Qt Quick consists of a rich set of user interface \l{QML Elements}{elements}, a \l{QML Syntax}{declarative} language for -describing user interfaces, and a language \l{QtDeclarative Module}{runtime}. A +describing user interfaces, and a language \l{QtQml Module}{runtime}. A collection of C++ APIs is used to integrate these high level features with classic Qt applications. Version 2.1 of the Qt Creator integrated development environment (IDE) introduces tools for developing Qt Quick applications. @@ -74,16 +74,16 @@ used to implement high level user interface logic. \l{How to Learn QML} introduces the reader to the language and declarative concepts. -\section1 QtDeclarative Module +\section1 QtQml Module -To make Qt Quick possible, Qt introduces the \l{QtDeclarative} module. The +To make Qt Quick possible, Qt introduces the \l{QtQml} module. The module creates a JavaScript runtime that QML runs under with a Qt based backend. -Because QtDeclarative and QML are built upon Qt, they inherit many of Qt's +Because QtQml and QML are built upon Qt, they inherit many of Qt's technology, namely the \l{Signals and Slots}{signals and slots} mechanism and the \l{The Meta-Object System}{meta-object} system. Data created using C++ are directly accessible from QML, and QML objects are also accessible from C++ code. -The QtDeclarative module separates the interface logic in QML from the +The QtQml module separates the interface logic in QML from the application logic in C++. It also allows the range of standard QML elements to be \l{Extending QML with C++}{extended with new ones written in C++}. diff --git a/doc/src/qtquick2/qtquick2.qdoc b/doc/src/qtquick2/qtquick2.qdoc index 6a1b7999c9..20361adb16 100644 --- a/doc/src/qtquick2/qtquick2.qdoc +++ b/doc/src/qtquick2/qtquick2.qdoc @@ -32,7 +32,7 @@ \brief The QML Elements This QML module contains all the QML elements that are - instantiated as objects of C++ classes in the QtDeclarative + instantiated as objects of C++ classes in the QtQml module. These elements work with the Scenegraph renderer and their own canvas. */ diff --git a/doc/src/qtquick2/righttoleft.qdoc b/doc/src/qtquick2/righttoleft.qdoc index b2cff57ee0..1781e3582a 100644 --- a/doc/src/qtquick2/righttoleft.qdoc +++ b/doc/src/qtquick2/righttoleft.qdoc @@ -68,7 +68,7 @@ Note that when \l LayoutMirroring is set, the \c horizontalAlignment property va the effective alignment of the text element that takes the mirroring into account can be read from the \c effectiveHorizontalAlignment property. -\snippet doc/src/snippets/declarative/righttoleft.qml 0 +\snippet doc/src/snippets/qml/righttoleft.qml 0 \section1 Layout direction of positioners and views @@ -84,7 +84,7 @@ This causes the effective \c layoutDirection of positioners and views to be mirr of the \c layoutDirection property will remain unchanged; the effective layout direction of positioners and views that takes the mirroring into account can be read from the \c effectiveLayoutDirection property. -\snippet doc/src/snippets/declarative/righttoleft.qml 1 +\snippet doc/src/snippets/qml/righttoleft.qml 1 \section1 Layout mirroring @@ -95,11 +95,11 @@ support for existing left-to-right Qt Quick applications. It mirrors the behavio You can enable layout mirroring for a particular \l Item: -\snippet doc/src/snippets/declarative/righttoleft.qml 2 +\snippet doc/src/snippets/qml/righttoleft.qml 2 Or set all child elements to also inherit the layout direction: -\snippet doc/src/snippets/declarative/righttoleft.qml 3 +\snippet doc/src/snippets/qml/righttoleft.qml 3 Applying mirroring in this manner does not change the actual value of the relevant anchor, \c layoutDirection or \c horizontalAlignment properties. The separate read-only property @@ -116,7 +116,7 @@ especially in views that rely on both the anchors and x coordinate-based positio the \l LayoutMirroring attached property to apply mirroring to an item that is positioned using \l {Item::}{x} coordinates: -\snippet doc/src/snippets/declarative/righttoleft.qml 4 +\snippet doc/src/snippets/qml/righttoleft.qml 4 Not all layouts should necessarily be mirrored. There are cases where a visual element is positioned to the right side of the screen for improved one-handed use, because most people are right-handed, and not @@ -135,7 +135,7 @@ aligned and just make sure that text is translated and aligned properly. Most images do not need to be mirrored, but some directional icons, such as arrows, may need to be mirrored. The painting of these icons can be mirrored with a dedicated \c mirror property introduced in Qt Quick 1.1: -\snippet doc/src/snippets/declarative/righttoleft.qml 5 +\snippet doc/src/snippets/qml/righttoleft.qml 5 \section1 Default layout direction diff --git a/doc/src/qtquick2/states.qdoc b/doc/src/qtquick2/states.qdoc index 559b4facac..622a1619b0 100644 --- a/doc/src/qtquick2/states.qdoc +++ b/doc/src/qtquick2/states.qdoc @@ -80,7 +80,7 @@ signal should be \c green and the warning \c flag is down. Meanwhile, in the \c CRITICAL state, the \c color should be \c red and the flag is \c up. We may model the states using the \c State element and the color and flag configurations with the \c PropertyChanges element. -\snippet doc/src/snippets/declarative/states.qml signal states +\snippet doc/src/snippets/qml/states.qml signal states The \l PropertyChanges element will change the values of object properties. Objects are referenced through their \l {qml-id}{id}. Objects outside the component are also referenced using the \c id property, exemplified by the @@ -89,7 +89,7 @@ property change to the external \c flag object. Further, the state may change by assigning the \c state property with the appropriate signal state. A state switch could be in a \l MouseArea element, assigning a different state whenever the signal receives a mouse click. -\snippet doc/src/snippets/declarative/states.qml switch states +\snippet doc/src/snippets/qml/states.qml switch states The State element is not limited to performing modifications on property values. It can also: @@ -115,7 +115,7 @@ expressions to change the state whenever the bound expression evaluates to \c true. The \c when property will revert the state back to the \l {The Default State}{default state} when the expression evaluates to false. -\snippet doc/src/snippets/declarative/states.qml when property +\snippet doc/src/snippets/qml/states.qml when property The \c bell component will change to the \c RINGING state whenever the \c signal.state is \c CRITICAL. diff --git a/doc/src/qtquick2/writingcomponents.qdoc b/doc/src/qtquick2/writingcomponents.qdoc index 64d28eff0b..31267cf20c 100644 --- a/doc/src/qtquick2/writingcomponents.qdoc +++ b/doc/src/qtquick2/writingcomponents.qdoc @@ -55,14 +55,14 @@ For example, one of the simplest and most common components you can build in QML button-type component. Below, we implement this component as a \l Rectangle with a clickable \l MouseArea, in a file named \c Button.qml: -\snippet doc/src/snippets/declarative/qml-extending-types/components/Button.qml 0 +\snippet doc/src/snippets/qml/qml-extending-types/components/Button.qml 0 Now this component can be reused by another file within the same directory. Since the file is named \c Button.qml, the component is referred to as \c Button: \table \row -\o \snippet doc/src/snippets/declarative/qml-extending-types/components/application.qml 0 +\o \snippet doc/src/snippets/qml/qml-extending-types/components/application.qml 0 \o \image qml-extending-types.png \endtable @@ -73,7 +73,7 @@ customize the \c width, \c height, \c radius and \c color properties of \c Butto If \c Button.qml was not in the same directory, \c application.qml would need to load it as a -\l {Modules}{module} from a specific filesystem path or \l{QDeclarativeExtensionPlugin}{plugin}. +\l {Modules}{module} from a specific filesystem path or \l{QQmlExtensionPlugin}{plugin}. Also, note the letter case of the component file name is significant on some (notably UNIX) filesystems. It is recommended the file name case matches the case of the QML component name exactly - for example, \c Box.qml and not \c BoX.qml - regardless of the platform to which the @@ -119,8 +119,8 @@ an \c ImageViewer object and read or modify the \c currentImage value: \table \row -\o \snippet doc/src/snippets/declarative/qml-extending-types/properties/ImageViewer.qml 0 -\o \snippet doc/src/snippets/declarative/qml-extending-types/properties/application.qml 0 +\o \snippet doc/src/snippets/qml/qml-extending-types/properties/ImageViewer.qml 0 +\o \snippet doc/src/snippets/qml/qml-extending-types/properties/application.qml 0 \endtable It is optional for a property to have a default value. The default value is a convenient shortcut, and is @@ -195,7 +195,7 @@ property name. For example, the following \c onMyNumberChanged signal handler is automatically called whenever the \c myNumber property changes: -\snippet doc/src/snippets/declarative/qml-extending-types/properties/property-signals.qml 0 +\snippet doc/src/snippets/qml/qml-extending-types/properties/property-signals.qml 0 \section2 Default properties @@ -266,7 +266,7 @@ declaring the alias, and, optionally, refers to a property on that ob For example, below is a \c Button.qml component with a \c buttonText aliased property which is connected to the child Text object's \c text property: -\snippet doc/src/snippets/declarative/qml-extending-types/properties/alias.qml 0 +\snippet doc/src/snippets/qml/qml-extending-types/properties/alias.qml 0 The following code would create a \c Button with a defined text string for the child \l Text object: @@ -290,8 +290,8 @@ been changed to an alias to the child \l Image object: \table \row -\o \snippet doc/src/snippets/declarative/qml-extending-types/properties/alias/ImageViewer.qml 0 -\o \snippet doc/src/snippets/declarative/qml-extending-types/properties/alias/application.qml 0 +\o \snippet doc/src/snippets/qml/qml-extending-types/properties/alias/ImageViewer.qml 0 +\o \snippet doc/src/snippets/qml/qml-extending-types/properties/alias/application.qml 0 \endtable Instead of being limited to setting the \l Image source, \c application.qml can now directly @@ -335,7 +335,7 @@ It is possible for an aliased property to have the same name as an existing prop the following component has a \c color alias property, named the same as the built-in \l {Rectangle::color} property: -\snippet doc/src/snippets/declarative/qml-extending-types/properties/alias-override.qml 0 +\snippet doc/src/snippets/qml/qml-extending-types/properties/alias-override.qml 0 Any objects that use this component and refer to its \c color property will be referring to the alias rather than the ordinary \l {Rectangle::color} property. Internally, @@ -366,7 +366,7 @@ the parameters by name. Here is an example of a component with a \c say() method that accepts a single \c text argument: -\snippet doc/src/snippets/declarative/qml-extending-types/methods/app.qml 0 +\snippet doc/src/snippets/qml/qml-extending-types/methods/app.qml 0 A method can be connected to a signal so that it is automatically invoked whenever the signal is emitted. See \l {Connecting signals to methods and other signals} below. @@ -422,8 +422,8 @@ signal is received by \c application.qml through an \c onButtonClicked signal ha \table \row -\o \snippet doc/src/snippets/declarative/qml-extending-types/signals/basic.qml 0 -\o \snippet doc/src/snippets/declarative/qml-extending-types/signals/no-parameters.qml 0 +\o \snippet doc/src/snippets/qml/qml-extending-types/signals/basic.qml 0 +\o \snippet doc/src/snippets/qml/qml-extending-types/signals/no-parameters.qml 0 \endtable If the signal has parameters, they are accessible by parameter name in the signal handler. @@ -431,8 +431,8 @@ In the example below, \c buttonClicked is emitted with \c xPos and \c yPos param \table \row -\o \snippet doc/src/snippets/declarative/qml-extending-types/signals/Button.qml 0 -\o \snippet doc/src/snippets/declarative/qml-extending-types/signals/parameters.qml 0 +\o \snippet doc/src/snippets/qml/qml-extending-types/signals/Button.qml 0 +\o \snippet doc/src/snippets/qml/qml-extending-types/signals/parameters.qml 0 \endtable @@ -446,7 +446,7 @@ to be received by a method instead of a \l {Signal Handlers}{signal handler}. For example, the \c application.qml above could be rewritten as: -\snippet doc/src/snippets/declarative/qml-extending-types/signals/connectslots.qml 0 +\snippet doc/src/snippets/qml/qml-extending-types/signals/connectslots.qml 0 The \c myMethod() method will be called whenever the \c buttonClicked signal is received. @@ -458,7 +458,7 @@ or \l {Integrating JavaScript}{integrating JavaScript code}, then you will find objects dynamically, and connects the \c buttonClicked signal of each object to the \c myMethod() function: -\snippet doc/src/snippets/declarative/qml-extending-types/signals/connectdynamic.qml 0 +\snippet doc/src/snippets/qml/qml-extending-types/signals/connectdynamic.qml 0 In the same way, you could connect a signal to methods defined in a dynamically created object, or \l {Receiving QML Signals in JavaScript}{connect a signal to a JavaScript method}. diff --git a/doc/src/snippets/declarative/Button.qml b/doc/src/snippets/declarative/Button.qml deleted file mode 100644 index 0525ac1383..0000000000 --- a/doc/src/snippets/declarative/Button.qml +++ /dev/null @@ -1,67 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -//! [document] -import QtQuick 2.0 - -//! [parent begin] -Rectangle { -//! [parent begin] - -//! [property alias] -property alias buttonLabel: label.text -Text { - id: label - text: "empty label" -} - //! [property alias] - -//! [id alias] - property alias buttonImage: image - - Image {id: image} -//! [id alias] -//! [parent end] -} -//! [parent end] - -//! [document] - - diff --git a/doc/src/snippets/declarative/SelfDestroyingRect.qml b/doc/src/snippets/declarative/SelfDestroyingRect.qml deleted file mode 100644 index baa4ab63a1..0000000000 --- a/doc/src/snippets/declarative/SelfDestroyingRect.qml +++ /dev/null @@ -1,60 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -//![0] -import QtQuick 2.0 - -Rectangle { - id: rect - width: 80; height: 80 - color: "red" - - NumberAnimation on opacity { - to: 0 - duration: 1000 - - onRunningChanged: { - if (!running) { - console.log("Destroying...") - rect.destroy(); - } - } - } -} -//![0] diff --git a/doc/src/snippets/declarative/Sprite.qml b/doc/src/snippets/declarative/Sprite.qml deleted file mode 100644 index ec08963be5..0000000000 --- a/doc/src/snippets/declarative/Sprite.qml +++ /dev/null @@ -1,45 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -//![0] -import QtQuick 2.0 - -Rectangle { width: 80; height: 50; color: "red" } -//![0] diff --git a/doc/src/snippets/declarative/anchoranimation.qml b/doc/src/snippets/declarative/anchoranimation.qml deleted file mode 100644 index 8f0603fab8..0000000000 --- a/doc/src/snippets/declarative/anchoranimation.qml +++ /dev/null @@ -1,66 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -//![0] -import QtQuick 2.0 - -Item { - id: container - width: 200; height: 200 - - Rectangle { - id: myRect - width: 100; height: 100 - color: "red" - } - - states: State { - name: "reanchored" - AnchorChanges { target: myRect; anchors.right: container.right } - } - - transitions: Transition { - // smoothly reanchor myRect and move into new position - AnchorAnimation { duration: 1000 } - } - - Component.onCompleted: container.state = "reanchored" -} -//![0] diff --git a/doc/src/snippets/declarative/anchorchanges.qml b/doc/src/snippets/declarative/anchorchanges.qml deleted file mode 100644 index 9cc9d15221..0000000000 --- a/doc/src/snippets/declarative/anchorchanges.qml +++ /dev/null @@ -1,68 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -//![0] -import QtQuick 2.0 - -Rectangle { - id: window - width: 120; height: 120 - color: "black" - - Rectangle { id: myRect; width: 50; height: 50; color: "red" } - - states: State { - name: "reanchored" - - AnchorChanges { - target: myRect - anchors.top: window.top - anchors.bottom: window.bottom - } - PropertyChanges { - target: myRect - anchors.topMargin: 10 - anchors.bottomMargin: 10 - } - } - - MouseArea { anchors.fill: parent; onClicked: window.state = "reanchored" } -} -//![0] - diff --git a/doc/src/snippets/declarative/animatedimage.qml b/doc/src/snippets/declarative/animatedimage.qml deleted file mode 100644 index a483619e11..0000000000 --- a/doc/src/snippets/declarative/animatedimage.qml +++ /dev/null @@ -1,61 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -// This snippet should be turned into an example and put in -// examples/declarative/imageelements/animatedimage - -//! [document] -import QtQuick 2.0 - -Rectangle { - width: animation.width; height: animation.height + 8 - - AnimatedImage { id: animation; source: "animation.gif" } - - Rectangle { - property int frames: animation.frameCount - - width: 4; height: 8 - x: (animation.width - width) * animation.currentFrame / frames - y: animation.height - color: "red" - } -} -//! [document] diff --git a/doc/src/snippets/declarative/animation.qml b/doc/src/snippets/declarative/animation.qml deleted file mode 100644 index d45ded397f..0000000000 --- a/doc/src/snippets/declarative/animation.qml +++ /dev/null @@ -1,226 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -//! [document] -import QtQuick 2.0 - - -//! [parent begin] -Rectangle { -//! [parent begin] - width: 200; height: 600 - id: screen - -Column { - spacing: 12 -//! [direct property change] -Rectangle { - id: blob - width: 75; height: 75 - color: "blue" - - MouseArea { - anchors.fill: parent - onClicked: blob.color = "green" - } -} -//! [direct property change] - -//! [property animation] -Rectangle { - id: flashingblob - width: 75; height: 75 - color: "blue" - opacity: 1.0 - - MouseArea { - anchors.fill: parent - onClicked: { - animateColor.start() - animateOpacity.start() - } - } - - PropertyAnimation {id: animateColor; target: flashingblob; properties: "color"; to: "green"; duration: 100} - - NumberAnimation { - id: animateOpacity - target: flashingblob - properties: "opacity" - from: 0.99 - to: 1.0 - loops: Animation.Infinite - easing {type: Easing.OutBack; overshoot: 500} - } -} -//! [property animation] - -//! [transition animation] -Rectangle { - width: 75; height: 75 - id: button - state: "RELEASED" - - MouseArea { - anchors.fill: parent - onPressed: button.state = "PRESSED" - onReleased: button.state = "RELEASED" - } - - states: [ - State { - name: "PRESSED" - PropertyChanges { target: button; color: "lightblue"} - }, - State { - name: "RELEASED" - PropertyChanges { target: button; color: "lightsteelblue"} - } - ] - - transitions: [ - Transition { - from: "PRESSED" - to: "RELEASED" - ColorAnimation { target: button; duration: 100} - }, - Transition { - from: "RELEASED" - to: "PRESSED" - ColorAnimation { target: button; duration: 100} - } - ] -} -//! [transition animation] - -Rectangle { - width: 75; height: 75 - id: wildcard - color: "green" -//! [wildcard animation] - transitions: - Transition { - to: "*" - ColorAnimation { target: button; duration: 100} - } -//! [wildcard animation] - - MouseArea { - anchors.fill: parent - onPressed: { - ball.x = 10 - ball.color = "red" - } - onReleased: { - ball.x = screen.width / 2 - ball.color = "salmon" - } - } -} - -//! [behavior animation] -Rectangle { - width: 75; height: 75; radius: width - id: ball - color: "salmon" - - Behavior on x { - NumberAnimation { - id: bouncebehavior - easing { - type: Easing.OutElastic - amplitude: 1.0 - period: 0.5 - } - } - } - Behavior on y { - animation: bouncebehavior - } - Behavior { - ColorAnimation { target: ball; duration: 100 } - } -} -//! [behavior animation] - -//! [sequential animation] -Rectangle { - id: banner - width: 150; height: 100; border.color: "black" - - Column { - anchors.centerIn: parent - Text { - id: code - text: "Code less." - opacity: 0.01 - } - Text { - id: create - text: "Create more." - opacity: 0.01 - } - Text { - id: deploy - text: "Deploy everywhere." - opacity: 0.01 - } - } - - MouseArea { - anchors.fill: parent - onPressed: playbanner.start() - } - - SequentialAnimation { - id: playbanner - running: false - NumberAnimation { target: code; property: "opacity"; to: 1.0; duration: 200} - NumberAnimation { target: create; property: "opacity"; to: 1.0; duration: 200} - NumberAnimation { target: deploy; property: "opacity"; to: 1.0; duration: 200} - } -} -//! [sequential animation] - -}//end of col -//! [parent end] -} -//! [parent end] - -//! [document] diff --git a/doc/src/snippets/declarative/application.qml b/doc/src/snippets/declarative/application.qml deleted file mode 100644 index 4e847176fa..0000000000 --- a/doc/src/snippets/declarative/application.qml +++ /dev/null @@ -1,53 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -//! [document] -import QtQuick 2.0 - -Rectangle { - width: 300; height: 55 - color: Qt.application.active ? "white" : "lightgray" - Text { - text: "Application " + (Qt.application.active ? "active" : "inactive") - opacity: Qt.application.active ? 1.0 : 0.5 - anchors.centerIn: parent - } -} -//! [document] diff --git a/doc/src/snippets/declarative/behavior.qml b/doc/src/snippets/declarative/behavior.qml deleted file mode 100644 index 4776e09a54..0000000000 --- a/doc/src/snippets/declarative/behavior.qml +++ /dev/null @@ -1,58 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -//![0] -import QtQuick 2.0 - -Rectangle { - id: rect - width: 100; height: 100 - color: "red" - - Behavior on width { - NumberAnimation { duration: 1000 } - } - - MouseArea { - anchors.fill: parent - onClicked: rect.width = 50 - } -} -//![0] diff --git a/doc/src/snippets/declarative/borderimage/borderimage-scaled.qml b/doc/src/snippets/declarative/borderimage/borderimage-scaled.qml deleted file mode 100644 index 468aa24eab..0000000000 --- a/doc/src/snippets/declarative/borderimage/borderimage-scaled.qml +++ /dev/null @@ -1,81 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -Rectangle { - id: page - color: "white" - width: 180; height: 180 - -//! [scaled border image] -BorderImage { - width: 180; height: 180 - border { left: 30; top: 30; right: 30; bottom: 30 } - horizontalTileMode: BorderImage.Stretch - verticalTileMode: BorderImage.Stretch - source: "pics/borderframe.png" -} -//! [scaled border image] - - Rectangle { - x: 30; y: 0 - width: 1; height: 180 - color: "gray" - } - - Rectangle { - x: 150; y: 0 - width: 1; height: 180 - color: "gray" - } - - Rectangle { - x: 0; y: 30 - width: 180; height: 1 - color: "gray" - } - - Rectangle { - x: 0; y: 150 - width: 180; height: 1 - color: "gray" - } -} diff --git a/doc/src/snippets/declarative/borderimage/borderimage-tiled.qml b/doc/src/snippets/declarative/borderimage/borderimage-tiled.qml deleted file mode 100644 index 69297378bf..0000000000 --- a/doc/src/snippets/declarative/borderimage/borderimage-tiled.qml +++ /dev/null @@ -1,81 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -Rectangle { - id: page - color: "white" - width: 180; height: 180 - -//! [tiled border image] -BorderImage { - width: 180; height: 180 - border { left: 30; top: 30; right: 30; bottom: 30 } - horizontalTileMode: BorderImage.Repeat - verticalTileMode: BorderImage.Repeat - source: "pics/borderframe.png" -} -//! [tiled border image] - - Rectangle { - x: 30; y: 0 - width: 1; height: 180 - color: "gray" - } - - Rectangle { - x: 150; y: 0 - width: 1; height: 180 - color: "gray" - } - - Rectangle { - x: 0; y: 30 - width: 180; height: 1 - color: "gray" - } - - Rectangle { - x: 0; y: 150 - width: 180; height: 1 - color: "gray" - } -} diff --git a/doc/src/snippets/declarative/borderimage/normal-image.qml b/doc/src/snippets/declarative/borderimage/normal-image.qml deleted file mode 100644 index 3bd34e3933..0000000000 --- a/doc/src/snippets/declarative/borderimage/normal-image.qml +++ /dev/null @@ -1,77 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -Rectangle { - id: page - color: "white" - width: 120; height: 120 - -//! [normal image] -Image { - source: "pics/borderframe.png" -} -//! [normal image] - - Rectangle { - x: 30; y: 0 - width: 1; height: 120 - color: "gray" - } - - Rectangle { - x: 90; y: 0 - width: 1; height: 120 - color: "gray" - } - - Rectangle { - x: 0; y: 30 - width: 200; height: 1 - color: "gray" - } - - Rectangle { - x: 0; y: 90 - width: 200; height: 1 - color: "gray" - } -} diff --git a/doc/src/snippets/declarative/codingconventions/dotproperties.qml b/doc/src/snippets/declarative/codingconventions/dotproperties.qml deleted file mode 100644 index 75f4629b3e..0000000000 --- a/doc/src/snippets/declarative/codingconventions/dotproperties.qml +++ /dev/null @@ -1,68 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -Item { - -//! [0] -Rectangle { - anchors.left: parent.left; anchors.top: parent.top; anchors.right: parent.right; anchors.leftMargin: 20 -} - -Text { - text: "hello" - font.bold: true; font.italic: true; font.pixelSize: 20; font.capitalization: Font.AllUppercase -} - -//! [0] - -//! [1] -Rectangle { - anchors { left: parent.left; top: parent.top; right: parent.right; leftMargin: 20 } -} - -Text { - text: "hello" - font { bold: true; italic: true; pixelSize: 20; capitalization: Font.AllUppercase } -} -//! [1] - -} diff --git a/doc/src/snippets/declarative/codingconventions/javascript-imports.qml b/doc/src/snippets/declarative/codingconventions/javascript-imports.qml deleted file mode 100644 index 5ea66a9b1f..0000000000 --- a/doc/src/snippets/declarative/codingconventions/javascript-imports.qml +++ /dev/null @@ -1,47 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -//![0] -import "myscript.js" as Script - -Rectangle { color: "blue"; width: Script.calculateWidth(parent) } -//![0] diff --git a/doc/src/snippets/declarative/codingconventions/javascript.qml b/doc/src/snippets/declarative/codingconventions/javascript.qml deleted file mode 100644 index de3cc21493..0000000000 --- a/doc/src/snippets/declarative/codingconventions/javascript.qml +++ /dev/null @@ -1,73 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -Rectangle { - -//![0] -Rectangle { color: "blue"; width: parent.width / 3 } -//![0] - -//![1] -Rectangle { - color: "blue" - width: { - var w = parent.width / 3 - console.debug(w) - return w - } -} -//![1] - -//![2] -function calculateWidth(object) -{ - var w = object.width / 3 - // ... - // more javascript code - // ... - console.debug(w) - return w -} - -Rectangle { color: "blue"; width: calculateWidth(parent) } -//![2] -} diff --git a/doc/src/snippets/declarative/codingconventions/lists.qml b/doc/src/snippets/declarative/codingconventions/lists.qml deleted file mode 100644 index f99c92b08e..0000000000 --- a/doc/src/snippets/declarative/codingconventions/lists.qml +++ /dev/null @@ -1,62 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -Item { - Item { -//! [0] -states: [ - State { - name: "open" - PropertyChanges { target: container; width: 200 } - } -] -//! [0] - } - Item { -//! [1] -states: State { - name: "open" - PropertyChanges { target: container; width: 200 } -} -//! [1] - } -} diff --git a/doc/src/snippets/declarative/codingconventions/myscript.js b/doc/src/snippets/declarative/codingconventions/myscript.js deleted file mode 100644 index e7f83c259c..0000000000 --- a/doc/src/snippets/declarative/codingconventions/myscript.js +++ /dev/null @@ -1,12 +0,0 @@ -function calculateWidth(parent) -{ - if (parent == null) - return 0 - - var w = parent.width / 3 - // ... - // more javascript code - // ... - console.debug(w) - return w -} diff --git a/doc/src/snippets/declarative/codingconventions/photo.qml b/doc/src/snippets/declarative/codingconventions/photo.qml deleted file mode 100644 index 1bd2811e9f..0000000000 --- a/doc/src/snippets/declarative/codingconventions/photo.qml +++ /dev/null @@ -1,85 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -//! [0] -Rectangle { - id: photo // id on the first line makes it easy to find an object - - property bool thumbnail: false // property declarations - property alias image: photoImage.source - - signal clicked // signal declarations - - function doSomething(x) // javascript functions - { - return x + photoImage.width - } - - color: "gray" // object properties - x: 20; y: 20; height: 150 // try to group related properties together - width: { // large bindings - if(photoImage.width > 200){ - photoImage.width; - }else{ - 200; - } - } - - Rectangle { // child objects - id: border - anchors.centerIn: parent; color: "white" - - Image { id: photoImage; anchors.centerIn: parent } - } - - states: State { // states - name: "selected" - PropertyChanges { target: border; color: "red" } - } - - transitions: Transition { // transitions - from: ""; to: "selected" - ColorAnimation { target: border; duration: 200 } - } -} -//! [0] - diff --git a/doc/src/snippets/declarative/codingconventions/private.qml b/doc/src/snippets/declarative/codingconventions/private.qml deleted file mode 100644 index 9aba1d0377..0000000000 --- a/doc/src/snippets/declarative/codingconventions/private.qml +++ /dev/null @@ -1,49 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -//! [0] -Item { - id: component - width: 40; height: 50 - property real __area: width * height * 0.5 //not meant for outside use -} -//! [0] diff --git a/doc/src/snippets/declarative/coloranimation.qml b/doc/src/snippets/declarative/coloranimation.qml deleted file mode 100644 index bb2d83bfb8..0000000000 --- a/doc/src/snippets/declarative/coloranimation.qml +++ /dev/null @@ -1,51 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -//![0] -import QtQuick 2.0 - -Rectangle { - width: 100; height: 100 - color: "red" - - ColorAnimation on color { to: "yellow"; duration: 1000 } -} -//![0] - diff --git a/doc/src/snippets/declarative/colors.qml b/doc/src/snippets/declarative/colors.qml deleted file mode 100644 index 7f94c6b843..0000000000 --- a/doc/src/snippets/declarative/colors.qml +++ /dev/null @@ -1,125 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -Rectangle { - width: 160; height: 250 - - Image { - width: 160; height: 200 - source: "pics/checker.svg" - fillMode: Image.Tile - - //! [colors] - Rectangle { - color: "steelblue" - width: 40; height: 40 - } - Rectangle { - color: "transparent" - y: 40; width: 40; height: 40 - } - Rectangle { - color: "#FF0000" - y: 80; width: 40; height: 40 - } - Rectangle { - color: "#800000FF" - y: 120; width: 40; height: 40 - } - Rectangle { - color: "#00000000" // ARGB fully transparent - y: 160 - width: 40; height: 40 - } - //! [colors] - - Rectangle { - x: 40 - width: 120; height: 200 - - Text { - font.pixelSize: 16 - text: "steelblue" - x: 10; height: 40 - verticalAlignment: Text.AlignVCenter - } - Text { - font.pixelSize: 16 - text: "transparent" - x: 10; y: 40; height: 40 - verticalAlignment: Text.AlignVCenter - } - Text { - font.pixelSize: 16 - text: "FF0000" - x: 10; y: 80; height: 40 - verticalAlignment: Text.AlignVCenter - } - Text { - font.pixelSize: 16 - text: "800000FF" - x: 10; y: 120; height: 40 - verticalAlignment: Text.AlignVCenter - } - Text { - font.pixelSize: 16 - text: "00000000" - x: 10; y: 160; height: 40 - verticalAlignment: Text.AlignVCenter - } - } - } - - Image { - y: 210 - width: 40; height: 40 - source: "pics/checker.svg" - fillMode: Image.Tile - } - - Text { - font.pixelSize: 16 - text: "(background)" - x: 50; y: 210; height: 40 - verticalAlignment: Text.AlignVCenter - } -} diff --git a/doc/src/snippets/declarative/column/column-transitions.qml b/doc/src/snippets/declarative/column/column-transitions.qml deleted file mode 100644 index 8e291b12c8..0000000000 --- a/doc/src/snippets/declarative/column/column-transitions.qml +++ /dev/null @@ -1,58 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -//! [document] -Column { - spacing: 2 - - Rectangle { color: "red"; width: 50; height: 50 } - Rectangle { id: greenRect; color: "green"; width: 20; height: 50 } - Rectangle { color: "blue"; width: 50; height: 20 } - - move: Transition { - NumberAnimation { properties: "x,y"; duration: 1000 } - } - - focus: true - Keys.onSpacePressed: greenRect.visible = !greenRect.visible -} -//! [document] diff --git a/doc/src/snippets/declarative/column/column.qml b/doc/src/snippets/declarative/column/column.qml deleted file mode 100644 index 3d51728d13..0000000000 --- a/doc/src/snippets/declarative/column/column.qml +++ /dev/null @@ -1,67 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -//! [document] -import QtQuick 2.0 - -Item { - width: 310; height: 170 - - Column { - anchors.horizontalCenter: parent.horizontalCenter - anchors.verticalCenter: parent.verticalCenter - - spacing: 5 - - Rectangle { color: "lightblue"; radius: 10.0 - width: 300; height: 50 - Text { anchors.centerIn: parent - font.pointSize: 24; text: "Books" } } - Rectangle { color: "gold"; radius: 10.0 - width: 300; height: 50 - Text { anchors.centerIn: parent - font.pointSize: 24; text: "Music" } } - Rectangle { color: "lightgreen"; radius: 10.0 - width: 300; height: 50 - Text { anchors.centerIn: parent - font.pointSize: 24; text: "Movies" } } - } -} -//! [document] diff --git a/doc/src/snippets/declarative/column/vertical-positioner.qml b/doc/src/snippets/declarative/column/vertical-positioner.qml deleted file mode 100644 index 1661c46ba8..0000000000 --- a/doc/src/snippets/declarative/column/vertical-positioner.qml +++ /dev/null @@ -1,51 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -//! [document] -Column { - spacing: 2 - - Rectangle { color: "red"; width: 50; height: 50 } - Rectangle { color: "green"; width: 20; height: 50 } - Rectangle { color: "blue"; width: 50; height: 20 } -} -//! [document] diff --git a/doc/src/snippets/declarative/comments.qml b/doc/src/snippets/declarative/comments.qml deleted file mode 100644 index 8c3f0045b9..0000000000 --- a/doc/src/snippets/declarative/comments.qml +++ /dev/null @@ -1,53 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -//![0] -Text { - text: "Hello world!" //a basic greeting - /* - We want this text to stand out from the rest so - we give it a large size and different font. - */ - font.family: "Helvetica" - font.pointSize: 24 -} -//![0] diff --git a/doc/src/snippets/declarative/component.qml b/doc/src/snippets/declarative/component.qml deleted file mode 100644 index e2a359e0e4..0000000000 --- a/doc/src/snippets/declarative/component.qml +++ /dev/null @@ -1,59 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -//![0] -import QtQuick 2.0 - -Item { - width: 100; height: 100 - - Component { - id: redSquare - - Rectangle { - color: "red" - width: 10 - height: 10 - } - } - - Loader { sourceComponent: redSquare } - Loader { sourceComponent: redSquare; x: 20 } -} -//![0] diff --git a/doc/src/snippets/declarative/componentCreation.js b/doc/src/snippets/declarative/componentCreation.js deleted file mode 100644 index 7364139d3d..0000000000 --- a/doc/src/snippets/declarative/componentCreation.js +++ /dev/null @@ -1,45 +0,0 @@ -//![vars] -var component; -var sprite; -//![vars] - -//![func] -function createSpriteObjects() { -//![func] - -//![remote] - component = Qt.createComponent("Sprite.qml"); - if (component.status == Component.Ready) - finishCreation(); - else - component.statusChanged.connect(finishCreation); -//![remote] - -//![local] - component = Qt.createComponent("Sprite.qml"); - sprite = component.createObject(appWindow, {"x": 100, "y": 100}); - - if (sprite == null) { - // Error Handling - console.log("Error creating object"); - } -//![local] - -//![func-end] -} -//![func-end] - -//![finishCreation] -function finishCreation() { - if (component.status == Component.Ready) { - sprite = component.createObject(appWindow, {"x": 100, "y": 100}); - if (sprite == null) { - // Error Handling - console.log("Error creating object"); - } - } else if (component.status == Component.Error) { - // Error Handling - console.log("Error loading component:", component.errorString()); - } -} -//![finishCreation] diff --git a/doc/src/snippets/declarative/createComponent-simple.qml b/doc/src/snippets/declarative/createComponent-simple.qml deleted file mode 100644 index 3f90a39166..0000000000 --- a/doc/src/snippets/declarative/createComponent-simple.qml +++ /dev/null @@ -1,57 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -//![0] -import QtQuick 2.0 - -Item { - id: container - width: 300; height: 300 - - function loadButton() { - var component = Qt.createComponent("Button.qml"); - if (component.status == Component.Ready) { - var button = component.createObject(container); - button.color = "red"; - } - } - - Component.onCompleted: loadButton() -} -//![0] diff --git a/doc/src/snippets/declarative/createComponent.qml b/doc/src/snippets/declarative/createComponent.qml deleted file mode 100644 index e2d81170e4..0000000000 --- a/doc/src/snippets/declarative/createComponent.qml +++ /dev/null @@ -1,51 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -//![0] -import QtQuick 2.0 -import "componentCreation.js" as MyScript - -Rectangle { - id: appWindow - width: 300; height: 300 - - Component.onCompleted: MyScript.createSpriteObjects(); -} -//![0] diff --git a/doc/src/snippets/declarative/createQmlObject.qml b/doc/src/snippets/declarative/createQmlObject.qml deleted file mode 100644 index 76cf836914..0000000000 --- a/doc/src/snippets/declarative/createQmlObject.qml +++ /dev/null @@ -1,61 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -Rectangle { - id: parentItem - - width: 100 - height: 100 - - function createIt() { -//![0] -var newObject = Qt.createQmlObject('import QtQuick 2.0; Rectangle {color: "red"; width: 20; height: 20}', - parentItem, "dynamicSnippet1"); -//![0] - -//![destroy] -newObject.destroy(1000); -//![destroy] - } - - Component.onCompleted: createIt() -} diff --git a/doc/src/snippets/declarative/drag.qml b/doc/src/snippets/declarative/drag.qml deleted file mode 100644 index 286fcfc52b..0000000000 --- a/doc/src/snippets/declarative/drag.qml +++ /dev/null @@ -1,75 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -//![0] -import QtQuick 2.0 - -Item { - width: 200; height: 200 - - DropArea { - x: 75; y: 75 - width: 50; height: 50 - - Rectangle { - anchors.fill: parent - color: "green" - - visible: parent.containsDrag - } - } - - Rectangle { - x: 10; y: 10 - width: 20; height: 20 - color: "red" - - Drag.active: dragArea.drag.active - Drag.hotSpot.x: 10 - Drag.hotSpot.y: 10 - - MouseArea { - id: dragArea - anchors.fill: parent - - drag.target: parent - } - } -} -//![0] diff --git a/doc/src/snippets/declarative/dynamicObjects-destroy.qml b/doc/src/snippets/declarative/dynamicObjects-destroy.qml deleted file mode 100644 index 66fbc0b243..0000000000 --- a/doc/src/snippets/declarative/dynamicObjects-destroy.qml +++ /dev/null @@ -1,55 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -//![0] -import QtQuick 2.0 - -Item { - id: container - width: 500; height: 100 - - Component.onCompleted: { - var component = Qt.createComponent("SelfDestroyingRect.qml"); - for (var i=0; i<5; i++) { - var object = component.createObject(container); - object.x = (object.width + 10) * i; - } - } -} -//![0] diff --git a/doc/src/snippets/declarative/events.qml b/doc/src/snippets/declarative/events.qml deleted file mode 100644 index b9c5fef954..0000000000 --- a/doc/src/snippets/declarative/events.qml +++ /dev/null @@ -1,141 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -//![document] -import QtQuick 2.0 - -//![parent begin] -Rectangle { -//![parent begin] - - id: screen - width: 400; height: 500 - -//! [signal declaration] - signal trigger - signal send (string notice) - signal perform (string task, variant object) -//! [signal declaration] - -//! [signal handler declaration] -onTrigger: console.log("trigger signal emitted") - -onSend: { - console.log("send signal emitted with notice: " + notice) -} - -onPerform: console.log("perform signal emitted") -//! [signal handler declaration] - -//! [automatic signals] -Rectangle { - id: sprite - width: 25; height: 25 - x: 50; y: 15 - - onXChanged: console.log("x property changed, emitted xChanged signal") - onYChanged: console.log("y property changed, emitted yChanged signal") -} -//! [automatic signals] - -//! [signal emit] -Rectangle { - id: messenger - - signal send( string person, string notice) - - onSend: { - console.log("For " + person + ", the notice is: " + notice) - } - - Component.onCompleted: messenger.send("Tom", "the door is ajar.") -} -//! [signal emit] - -//! [connect method] -Rectangle { - id: relay - - signal send( string person, string notice) - onSend: console.log("Send signal to: " + person + ", " + notice) - - Component.onCompleted: { - relay.send.connect(sendToPost) - relay.send.connect(sendToTelegraph) - relay.send.connect(sendToEmail) - relay.send("Tom", "Happy Birthday") - } - - function sendToPost(person, notice) { - console.log("Sending to post: " + person + ", " + notice) - } - function sendToTelegraph(person, notice) { - console.log("Sending to telegraph: " + person + ", " + notice) - } - function sendToEmail(person, notice) { - console.log("Sending to email: " + person + ", " + notice) - } -} -//! [connect method] - -//! [forward signal] -Rectangle { - id: forwarder - width: 100; height: 100 - - signal send() - onSend: console.log("Send clicked") - - MouseArea { - id: mousearea - anchors.fill: parent - onClicked: console.log("MouseArea clicked") - } - Component.onCompleted: { - mousearea.clicked.connect(send) - } -} -//! [forward signal] - -//! [connect method] -//![parent end] -} -//![parent end] - -//![document] diff --git a/doc/src/snippets/declarative/flickable.qml b/doc/src/snippets/declarative/flickable.qml deleted file mode 100644 index fda2615e14..0000000000 --- a/doc/src/snippets/declarative/flickable.qml +++ /dev/null @@ -1,50 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -//! [document] -import QtQuick 2.0 - -Flickable { - width: 200; height: 200 - contentWidth: image.width; contentHeight: image.height - - Image { id: image; source: "bigImage.png" } -} -//! [document] diff --git a/doc/src/snippets/declarative/flickableScrollbar.qml b/doc/src/snippets/declarative/flickableScrollbar.qml deleted file mode 100644 index fd0aee3fc1..0000000000 --- a/doc/src/snippets/declarative/flickableScrollbar.qml +++ /dev/null @@ -1,66 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -//![0] -Rectangle { - width: 200; height: 200 - - Flickable { - id: flickable -//![0] - anchors.fill: parent - contentWidth: image.width; contentHeight: image.height - - Image { id: image; source: "pics/qt.png" } -//![1] - } - - Rectangle { - id: scrollbar - anchors.right: flickable.right - y: flickable.visibleArea.yPosition * flickable.height - width: 10 - height: flickable.visibleArea.heightRatio * flickable.height - color: "black" - } -} -//![1] diff --git a/doc/src/snippets/declarative/flipable/flipable.qml b/doc/src/snippets/declarative/flipable/flipable.qml deleted file mode 100644 index 4e451204d4..0000000000 --- a/doc/src/snippets/declarative/flipable/flipable.qml +++ /dev/null @@ -1,78 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -//! [0] -import QtQuick 2.0 - -Flipable { - id: flipable - width: 240 - height: 240 - - property bool flipped: false - - front: Image { source: "front.png"; anchors.centerIn: parent } - back: Image { source: "back.png"; anchors.centerIn: parent } - - transform: Rotation { - id: rotation - origin.x: flipable.width/2 - origin.y: flipable.height/2 - axis.x: 0; axis.y: 1; axis.z: 0 // set axis.y to 1 to rotate around y-axis - angle: 0 // the default angle - } - - states: State { - name: "back" - PropertyChanges { target: rotation; angle: 180 } - when: flipable.flipped - } - - transitions: Transition { - NumberAnimation { target: rotation; property: "angle"; duration: 4000 } - } - - MouseArea { - anchors.fill: parent - onClicked: flipable.flipped = !flipable.flipped - } -} -//! [0] - diff --git a/doc/src/snippets/declarative/flow.qml b/doc/src/snippets/declarative/flow.qml deleted file mode 100644 index 1141269986..0000000000 --- a/doc/src/snippets/declarative/flow.qml +++ /dev/null @@ -1,64 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -//! [document] -import QtQuick 2.0 - -Rectangle { - color: "lightblue" - width: 300; height: 200 - -//! [flow item] - Flow { - anchors.fill: parent - anchors.margins: 4 - spacing: 10 - - Text { text: "Text"; font.pixelSize: 40 } - Text { text: "items"; font.pixelSize: 40 } - Text { text: "flowing"; font.pixelSize: 40 } - Text { text: "inside"; font.pixelSize: 40 } - Text { text: "a"; font.pixelSize: 40 } - Text { text: "Flow"; font.pixelSize: 40 } - Text { text: "item"; font.pixelSize: 40 } - } -//! [flow item] -} -//! [document] diff --git a/doc/src/snippets/declarative/focus/MyClickableWidget.qml b/doc/src/snippets/declarative/focus/MyClickableWidget.qml deleted file mode 100644 index 7017f1bcb6..0000000000 --- a/doc/src/snippets/declarative/focus/MyClickableWidget.qml +++ /dev/null @@ -1,69 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -import QtQuick 2.0 - -//! [clickable in focusscope] -FocusScope { - - id: scope - - //FocusScope needs to bind to visual properties of the children - property alias color: rectangle.color - x: rectangle.x; y: rectangle.y - width: rectangle.width; height: rectangle.height - - Rectangle { - id: rectangle - anchors.centerIn: parent - color: "lightsteelblue"; width: 175; height: 25; radius: 10; smooth: true - Text { id: label; anchors.centerIn: parent } - focus: true - Keys.onPressed: { - if (event.key == Qt.Key_A) - label.text = 'Key A was pressed' - else if (event.key == Qt.Key_B) - label.text = 'Key B was pressed' - else if (event.key == Qt.Key_C) - label.text = 'Key C was pressed' - } - } - MouseArea { anchors.fill: parent; onClicked: { scope.focus = true } } -} -//! [clickable in focusscope] diff --git a/doc/src/snippets/declarative/focus/MyWidget.qml b/doc/src/snippets/declarative/focus/MyWidget.qml deleted file mode 100644 index 5899b18ae0..0000000000 --- a/doc/src/snippets/declarative/focus/MyWidget.qml +++ /dev/null @@ -1,58 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -//! [document] -import QtQuick 2.0 - -//! [mywidget] -Rectangle { - id: widget - color: "lightsteelblue"; width: 175; height: 25; radius: 10; smooth: true - Text { id: label; anchors.centerIn: parent} - focus: true - Keys.onPressed: { - if (event.key == Qt.Key_A) - label.text = 'Key A was pressed' - else if (event.key == Qt.Key_B) - label.text = 'Key B was pressed' - else if (event.key == Qt.Key_C) - label.text = 'Key C was pressed' - } -} -//! [mywidget] diff --git a/doc/src/snippets/declarative/focus/advancedFocus.qml b/doc/src/snippets/declarative/focus/advancedFocus.qml deleted file mode 100644 index ec4efca450..0000000000 --- a/doc/src/snippets/declarative/focus/advancedFocus.qml +++ /dev/null @@ -1,67 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -import QtQuick 2.0 - -//! [FocusScope delegate] -Rectangle { - color: "lightsteelblue"; width: 100; height: 50 - - ListView { - anchors.fill: parent - focus: true - - model: ListModel { - ListElement { name: "Bob" } - ListElement { name: "John" } - ListElement { name: "Michael" } - } - - delegate: FocusScope { - width: childrenRect.width; height: childrenRect.height - x:childrenRect.x; y: childrenRect.y - TextInput { - focus: true - text: name - Keys.onReturnPressed: console.log(name) - } - } - } -} -//! [FocusScope delegate] diff --git a/doc/src/snippets/declarative/focus/basicwidget.qml b/doc/src/snippets/declarative/focus/basicwidget.qml deleted file mode 100644 index bd5778948a..0000000000 --- a/doc/src/snippets/declarative/focus/basicwidget.qml +++ /dev/null @@ -1,59 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -import QtQuick 2.0 - -//! [focus true] -Rectangle { - color: "lightsteelblue"; width: 240; height: 25 - Text { id: myText } - Item { - id: keyHandler - focus: true - Keys.onPressed: { - if (event.key == Qt.Key_A) - myText.text = 'Key A was pressed' - else if (event.key == Qt.Key_B) - myText.text = 'Key B was pressed' - else if (event.key == Qt.Key_C) - myText.text = 'Key C was pressed' - } - } -} -//! [focus true] diff --git a/doc/src/snippets/declarative/focus/clickablewidget.qml b/doc/src/snippets/declarative/focus/clickablewidget.qml deleted file mode 100644 index 81bd5f7e51..0000000000 --- a/doc/src/snippets/declarative/focus/clickablewidget.qml +++ /dev/null @@ -1,61 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the FOO module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -import QtQuick 2.0 - -//! [clickable window] -Rectangle { - id: window - - color: "white"; width: 240; height: 150 - - Column { - anchors.centerIn: parent; spacing: 15 - - MyClickableWidget { - focus: true //set this MyWidget to receive the focus - color: "lightblue" - } - MyClickableWidget { - color: "palegreen" - } - } - -} -//! [clickable window] diff --git a/doc/src/snippets/declarative/focus/myfocusscopewidget.qml b/doc/src/snippets/declarative/focus/myfocusscopewidget.qml deleted file mode 100644 index f568c39a32..0000000000 --- a/doc/src/snippets/declarative/focus/myfocusscopewidget.qml +++ /dev/null @@ -1,68 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -//! [document] -import QtQuick 2.0 - -//! [widget in focusscope] -FocusScope { - - //FocusScope needs to bind to visual properties of the Rectangle - property alias color: rectangle.color - x: rectangle.x; y: rectangle.y - width: rectangle.width; height: rectangle.height - - Rectangle { - id: rectangle - anchors.centerIn: parent - color: "lightsteelblue"; width: 175; height: 25; radius: 10; smooth: true - Text { id: label; anchors.centerIn: parent } - focus: true - Keys.onPressed: { - if (event.key == Qt.Key_A) - label.text = 'Key A was pressed' - else if (event.key == Qt.Key_B) - label.text = 'Key B was pressed' - else if (event.key == Qt.Key_C) - label.text = 'Key C was pressed' - } - } -} -//! [widget in focusscope] -//! [document] diff --git a/doc/src/snippets/declarative/focus/rectangle.qml b/doc/src/snippets/declarative/focus/rectangle.qml deleted file mode 100644 index cb00f1f11a..0000000000 --- a/doc/src/snippets/declarative/focus/rectangle.qml +++ /dev/null @@ -1,62 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the FOO module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -import QtQuick 2.0 - -//! [simple key event] -Rectangle { - width: 100; height: 100 - focus: true - Keys.onPressed: { - if (event.key == Qt.Key_A) { - console.log('Key A was pressed'); - event.accepted = true; - } - } -//! [simple key event] - -//! [active focus] - Text { - text: activeFocus ? "I have active focus!" : "I do not have active focus" - } -//! [active focus] - -//! [simple key event end] -} -//! [simple key event end] diff --git a/doc/src/snippets/declarative/focus/widget.qml b/doc/src/snippets/declarative/focus/widget.qml deleted file mode 100644 index 5ee8a71846..0000000000 --- a/doc/src/snippets/declarative/focus/widget.qml +++ /dev/null @@ -1,61 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -import QtQuick 2.0 - -//! [window] - -//Window code that imports MyWidget -Rectangle { - id: window - color: "white"; width: 240; height: 150 - - Column { - anchors.centerIn: parent; spacing: 15 - - MyWidget { - focus: true //set this MyWidget to receive the focus - color: "lightblue" - } - MyWidget { - color: "palegreen" - } - } -} -//! [window] diff --git a/doc/src/snippets/declarative/folderlistmodel.qml b/doc/src/snippets/declarative/folderlistmodel.qml deleted file mode 100644 index 5878640567..0000000000 --- a/doc/src/snippets/declarative/folderlistmodel.qml +++ /dev/null @@ -1,61 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -//![0] -import QtQuick 2.0 -import Qt.labs.folderlistmodel 1.0 - -ListView { - width: 200; height: 400 - - FolderListModel { - id: folderModel - nameFilters: ["*.qml"] - } - - Component { - id: fileDelegate - Text { text: fileName } - } - - model: folderModel - delegate: fileDelegate -} -//![0] diff --git a/doc/src/snippets/declarative/gradient.qml b/doc/src/snippets/declarative/gradient.qml deleted file mode 100644 index a5af6a7930..0000000000 --- a/doc/src/snippets/declarative/gradient.qml +++ /dev/null @@ -1,52 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -//![code] -Rectangle { - width: 100; height: 100 - gradient: Gradient { - GradientStop { position: 0.0; color: "red" } - GradientStop { position: 0.33; color: "yellow" } - GradientStop { position: 1.0; color: "green" } - } -} -//![code] diff --git a/doc/src/snippets/declarative/grid-spacing.qml b/doc/src/snippets/declarative/grid-spacing.qml deleted file mode 100644 index 1385492ac6..0000000000 --- a/doc/src/snippets/declarative/grid-spacing.qml +++ /dev/null @@ -1,60 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -//! [document] -import QtQuick 2.0 - -Rectangle { - width: 112; height: 112 - color: "#303030" - - Grid { - anchors.horizontalCenter: parent.horizontalCenter - anchors.verticalCenter: parent.verticalCenter - columns: 2 - spacing: 6 - - Rectangle { color: "#aa6666"; width: 50; height: 50 } - Rectangle { color: "#aaaa66"; width: 50; height: 50 } - Rectangle { color: "#9999aa"; width: 50; height: 50 } - Rectangle { color: "#6666aa"; width: 50; height: 50 } - } -} -//! [document] diff --git a/doc/src/snippets/declarative/grid/grid-items.qml b/doc/src/snippets/declarative/grid/grid-items.qml deleted file mode 100644 index 8afb170f75..0000000000 --- a/doc/src/snippets/declarative/grid/grid-items.qml +++ /dev/null @@ -1,58 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -Rectangle { - width: 112; height: 112 - color: "#303030" - - Grid { - anchors.horizontalCenter: parent.horizontalCenter - anchors.verticalCenter: parent.verticalCenter - columns: 2 - spacing: 6 - - Rectangle { color: "#aa6666"; width: 50; height: 50 } - Rectangle { color: "#aaaa66"; width: 50; height: 50 } - Rectangle { color: "#9999aa"; width: 50; height: 50 } - Rectangle { color: "#6666aa"; width: 50; height: 50 } - } -} diff --git a/doc/src/snippets/declarative/grid/grid-no-spacing.qml b/doc/src/snippets/declarative/grid/grid-no-spacing.qml deleted file mode 100644 index c44eadce63..0000000000 --- a/doc/src/snippets/declarative/grid/grid-no-spacing.qml +++ /dev/null @@ -1,57 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -Rectangle { - width: 112; height: 112 - color: "#303030" - - Grid { - anchors.horizontalCenter: parent.horizontalCenter - anchors.verticalCenter: parent.verticalCenter - columns: 2 - - Rectangle { color: "#aa6666"; width: 50; height: 50 } - Rectangle { color: "#aaaa66"; width: 50; height: 50 } - Rectangle { color: "#9999aa"; width: 50; height: 50 } - Rectangle { color: "#6666aa"; width: 50; height: 50 } - } -} diff --git a/doc/src/snippets/declarative/grid/grid-spacing.qml b/doc/src/snippets/declarative/grid/grid-spacing.qml deleted file mode 100644 index 1385492ac6..0000000000 --- a/doc/src/snippets/declarative/grid/grid-spacing.qml +++ /dev/null @@ -1,60 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -//! [document] -import QtQuick 2.0 - -Rectangle { - width: 112; height: 112 - color: "#303030" - - Grid { - anchors.horizontalCenter: parent.horizontalCenter - anchors.verticalCenter: parent.verticalCenter - columns: 2 - spacing: 6 - - Rectangle { color: "#aa6666"; width: 50; height: 50 } - Rectangle { color: "#aaaa66"; width: 50; height: 50 } - Rectangle { color: "#9999aa"; width: 50; height: 50 } - Rectangle { color: "#6666aa"; width: 50; height: 50 } - } -} -//! [document] diff --git a/doc/src/snippets/declarative/grid/grid.qml b/doc/src/snippets/declarative/grid/grid.qml deleted file mode 100644 index 7fb1bb6f5a..0000000000 --- a/doc/src/snippets/declarative/grid/grid.qml +++ /dev/null @@ -1,53 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -//! [document] -import QtQuick 2.0 - -Grid { - columns: 3 - spacing: 2 - Rectangle { color: "red"; width: 50; height: 50 } - Rectangle { color: "green"; width: 20; height: 50 } - Rectangle { color: "blue"; width: 50; height: 20 } - Rectangle { color: "cyan"; width: 50; height: 50 } - Rectangle { color: "magenta"; width: 10; height: 10 } -} -//! [document] diff --git a/doc/src/snippets/declarative/gridview/ContactModel.qml b/doc/src/snippets/declarative/gridview/ContactModel.qml deleted file mode 100644 index f744c1e73f..0000000000 --- a/doc/src/snippets/declarative/gridview/ContactModel.qml +++ /dev/null @@ -1,63 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -//![0] -import QtQuick 2.0 - -ListModel { - - ListElement { - name: "Jim Williams" - portrait: "pics/portrait.png" - } - ListElement { - name: "John Brown" - portrait: "pics/portrait.png" - } - ListElement { - name: "Bill Smyth" - portrait: "pics/portrait.png" - } - ListElement { - name: "Sam Wise" - portrait: "pics/portrait.png" - } -} -//![0] diff --git a/doc/src/snippets/declarative/gridview/gridview.qml b/doc/src/snippets/declarative/gridview/gridview.qml deleted file mode 100644 index d3b37d1338..0000000000 --- a/doc/src/snippets/declarative/gridview/gridview.qml +++ /dev/null @@ -1,163 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -//![import] -import QtQuick 2.0 -//![import] - -Rectangle { - width: childrenRect.width; height: childrenRect.height - -Row { - -//![classdocs simple] -GridView { - width: 300; height: 200 - - model: ContactModel {} - delegate: Column { - Image { source: portrait; anchors.horizontalCenter: parent.horizontalCenter } - Text { text: name; anchors.horizontalCenter: parent.horizontalCenter } - } -} -//![classdocs simple] - - -//![classdocs advanced] -Rectangle { - width: 300; height: 200 - - Component { - id: contactDelegate - Item { - width: grid.cellWidth; height: grid.cellHeight - Column { - anchors.fill: parent - Image { source: portrait; anchors.horizontalCenter: parent.horizontalCenter } - Text { text: name; anchors.horizontalCenter: parent.horizontalCenter } - } - } - } - - GridView { - id: grid - anchors.fill: parent - cellWidth: 80; cellHeight: 80 - - model: ContactModel {} - delegate: contactDelegate - highlight: Rectangle { color: "lightsteelblue"; radius: 5 } - focus: true - } -} -//![classdocs advanced] - -//![delayRemove] -Component { - id: delegate - Item { - GridView.onRemove: SequentialAnimation { - PropertyAction { target: wrapper; property: "GridView.delayRemove"; value: true } - NumberAnimation { target: wrapper; property: "scale"; to: 0; duration: 250; easing.type: Easing.InOutQuad } - PropertyAction { target: wrapper; property: "GridView.delayRemove"; value: false } - } - } -} -//![delayRemove] - -//![highlightFollowsCurrentItem] -Component { - id: highlight - Rectangle { - width: view.cellWidth; height: view.cellHeight - color: "lightsteelblue"; radius: 5 - x: view.currentItem.x - y: view.currentItem.y - Behavior on x { SpringAnimation { spring: 3; damping: 0.2 } } - Behavior on y { SpringAnimation { spring: 3; damping: 0.2 } } - } -} - -GridView { - id: view - width: 300; height: 200 - cellWidth: 80; cellHeight: 80 - - model: ContactModel {} - delegate: Column { - Image { source: portrait; anchors.horizontalCenter: parent.horizontalCenter } - Text { text: name; anchors.horizontalCenter: parent.horizontalCenter } - } - - highlight: highlight - highlightFollowsCurrentItem: false - focus: true -} -//![highlightFollowsCurrentItem] - -//![isCurrentItem] -GridView { - width: 300; height: 200 - cellWidth: 80; cellHeight: 80 - - Component { - id: contactsDelegate - Rectangle { - id: wrapper - width: 80 - height: 80 - color: GridView.isCurrentItem ? "black" : "red" - Text { - id: contactInfo - text: name + ": " + number - color: wrapper.GridView.isCurrentItem ? "red" : "black" - } - } - } - - model: ContactModel {} - delegate: contactsDelegate - focus: true -} -//![isCurrentItem] - -} - -} diff --git a/doc/src/snippets/declarative/image.qml b/doc/src/snippets/declarative/image.qml deleted file mode 100644 index 61724ffeea..0000000000 --- a/doc/src/snippets/declarative/image.qml +++ /dev/null @@ -1,47 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -//! [document] -import QtQuick 2.0 - -Image { - source: "pics/qtlogo.png" -} -//! [document] diff --git a/doc/src/snippets/declarative/imports/chart.qml b/doc/src/snippets/declarative/imports/chart.qml deleted file mode 100644 index d5a2d3bf45..0000000000 --- a/doc/src/snippets/declarative/imports/chart.qml +++ /dev/null @@ -1,46 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -//! [import] -import Charts 1.0 -//! [import] - -Item { -} diff --git a/doc/src/snippets/declarative/imports/installed-module.qml b/doc/src/snippets/declarative/imports/installed-module.qml deleted file mode 100644 index c263ea89ed..0000000000 --- a/doc/src/snippets/declarative/imports/installed-module.qml +++ /dev/null @@ -1,47 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -//! [imports] -import QtQuick 2.0 -import com.nokia.qml.mymodule 1.0 -//! [imports] - -Item { -} diff --git a/doc/src/snippets/declarative/imports/merged-named-imports.qml b/doc/src/snippets/declarative/imports/merged-named-imports.qml deleted file mode 100644 index a75687c740..0000000000 --- a/doc/src/snippets/declarative/imports/merged-named-imports.qml +++ /dev/null @@ -1,47 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -//! [imports] -import QtQuick 2.0 as Nokia -import Ovi 1.0 as Nokia -//! [imports] - -Item { -} diff --git a/doc/src/snippets/declarative/imports/named-imports.qml b/doc/src/snippets/declarative/imports/named-imports.qml deleted file mode 100644 index 125e6cfa27..0000000000 --- a/doc/src/snippets/declarative/imports/named-imports.qml +++ /dev/null @@ -1,61 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -//! [imports] -import QtQuick 2.0 as QtLibrary -import "../MyComponents" as MyComponents -import com.nokia.qml.mymodule 1.0 as MyModule -//! [imports] - -Item { - //! [imported items] - QtLibrary.Rectangle { - // ... - } - - MyComponents.Slider { - // ... - } - - MyModule.SomeComponent { - // ... - } - //! [imported items] -} diff --git a/doc/src/snippets/declarative/imports/network-imports.qml b/doc/src/snippets/declarative/imports/network-imports.qml deleted file mode 100644 index f039c44f1e..0000000000 --- a/doc/src/snippets/declarative/imports/network-imports.qml +++ /dev/null @@ -1,47 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -//! [imports] -import "http://www.my-server.com/MyQMLProject/MyComponents" -import "http://www.my-server.com/MyQMLProject/MyComponents" 1.0 -//! [imports] - -Item { -} diff --git a/doc/src/snippets/declarative/imports/qtquick-1.0.qml b/doc/src/snippets/declarative/imports/qtquick-1.0.qml deleted file mode 100644 index 481bc12e7e..0000000000 --- a/doc/src/snippets/declarative/imports/qtquick-1.0.qml +++ /dev/null @@ -1,46 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -//! [import] -import QtQuick 2.0 -//! [import] - -Item { -} diff --git a/doc/src/snippets/declarative/imports/timeexample.qml b/doc/src/snippets/declarative/imports/timeexample.qml deleted file mode 100644 index 4d79dbe15e..0000000000 --- a/doc/src/snippets/declarative/imports/timeexample.qml +++ /dev/null @@ -1,46 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -//! [import] -import com.nokia.TimeExample 1.0 -//! [import] - -Item { -} diff --git a/doc/src/snippets/declarative/integrating-javascript/connectjs.qml b/doc/src/snippets/declarative/integrating-javascript/connectjs.qml deleted file mode 100644 index 89c9ebc21a..0000000000 --- a/doc/src/snippets/declarative/integrating-javascript/connectjs.qml +++ /dev/null @@ -1,57 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -//![0] -import QtQuick 2.0 -import "script.js" as MyScript - -Item { - id: item - width: 200; height: 200 - - MouseArea { - id: mouseArea - anchors.fill: parent - } - - Component.onCompleted: { - mouseArea.clicked.connect(MyScript.jsFunction) - } -} -//![0] diff --git a/doc/src/snippets/declarative/integrating-javascript/includejs/app.qml b/doc/src/snippets/declarative/integrating-javascript/includejs/app.qml deleted file mode 100644 index 0dd7b533a6..0000000000 --- a/doc/src/snippets/declarative/integrating-javascript/includejs/app.qml +++ /dev/null @@ -1,56 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -//![0] -import QtQuick 2.0 -import "script.js" as MyScript - -Item { - width: 100; height: 100 - - MouseArea { - anchors.fill: parent - onClicked: { - MyScript.showCalculations(10) - console.log("Call factorial() from QML:", - MyScript.factorial(10)) - } - } -} -//![0] diff --git a/doc/src/snippets/declarative/integrating-javascript/includejs/factorial.js b/doc/src/snippets/declarative/integrating-javascript/includejs/factorial.js deleted file mode 100644 index a7bc4ac69f..0000000000 --- a/doc/src/snippets/declarative/integrating-javascript/includejs/factorial.js +++ /dev/null @@ -1,49 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -//![0] -// factorial.js -function factorial(a) { - a = parseInt(a); - if (a <= 0) - return 1; - else - return a * factorial(a - 1); -} -//![0] diff --git a/doc/src/snippets/declarative/integrating-javascript/includejs/script.js b/doc/src/snippets/declarative/integrating-javascript/includejs/script.js deleted file mode 100644 index 964b2f5e8a..0000000000 --- a/doc/src/snippets/declarative/integrating-javascript/includejs/script.js +++ /dev/null @@ -1,48 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -//![0] -// script.js -Qt.include("factorial.js") - -function showCalculations(value) { - console.log("Call factorial() from script.js:", - factorial(value)); -} -//![0] diff --git a/doc/src/snippets/declarative/integrating-javascript/scarceresources/avatarExample.cpp b/doc/src/snippets/declarative/integrating-javascript/scarceresources/avatarExample.cpp deleted file mode 100644 index 8825cca4bb..0000000000 --- a/doc/src/snippets/declarative/integrating-javascript/scarceresources/avatarExample.cpp +++ /dev/null @@ -1,124 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "avatarExample.h" -#include -#include - -void registerTypes() -{ -//![0] - qmlRegisterType("Qt.example", 1, 0, "AvatarExample"); -//![0] -} - -void expectOne() -{ -//![1] -QDeclarativeComponent component(&engine, "exampleOne.qml"); -QObject *object = component.create(); -// The scarce resource will have been released automatically -// by this point, after the binding expression was evaluated. -delete object; -//![1] -} - -void expectTwo() -{ -//![2] -QDeclarativeComponent component(&engine, "exampleTwo.qml"); -QObject *object = component.create(); -// The scarce resource will not have been released automatically -// after the binding expression was evaluated. -// Since the scarce resource was not released explicitly prior -// to the binding expression being evaluated, we get: -bool expectedResult = (object->property("avatar").isValid() == true); -delete object; -//![2] -} - -void expectThree() -{ -//![3] -QDeclarativeComponent component(&engine, "exampleThree.qml"); -QObject *object = component.create(); -// The resource was preserved explicitly during evaluation of the -// JavaScript expression. Thus, during property assignment, the -// scarce resource was still valid, and so we get: -bool expectedResult = (object->property("avatar").isValid() == true); -// The scarce resource will not be released until all references to -// the resource are released, and the JavaScript garbage collector runs. -delete object; -//![3] -} - -void expectFour() -{ -//![4] -QDeclarativeComponent component(&engine, "exampleFour.qml"); -QObject *object = component.create(); -// The scarce resource was explicitly preserved by the client during -// the importAvatar() function, and so the scarce resource -// remains valid until the explicit call to releaseAvatar(). As such, -// we get the expected results: -bool expectedResultOne = (object->property("avatarOne").isValid() == true); -bool expectedResultTwo = (object->property("avatarTwo").isValid() == false); -// Because the scarce resource referenced by avatarTwo was released explicitly, -// it will no longer be consuming any system resources (beyond what a normal -// JS Object would; that small overhead will exist until the JS GC runs, as per -// any other JavaScript object). -delete object; -//![4] -} - -void expectFive() -{ -//![5] -QDeclarativeComponent component(&engine, "exampleFive.qml"); -QObject *object = component.create(); -// We have the expected results: -bool expectedResultOne = (object->property("avatarOne").isValid() == false); -bool expectedResultTwo = (object->property("avatarTwo").isValid() == false); -// Because although only avatarTwo was explicitly released, -// avatarOne and avatarTwo were referencing the same -// scarce resource. -delete object; -//![5] -} diff --git a/doc/src/snippets/declarative/integrating-javascript/scarceresources/avatarExample.h b/doc/src/snippets/declarative/integrating-javascript/scarceresources/avatarExample.h deleted file mode 100644 index d9fbff4fde..0000000000 --- a/doc/src/snippets/declarative/integrating-javascript/scarceresources/avatarExample.h +++ /dev/null @@ -1,73 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef AVATAREXAMPLE_P_H -#define AVATAREXAMPLE_P_H - -#include -#include - -//![0] -// avatarExample.h -class AvatarExample : public QObject -{ - Q_OBJECT - Q_PROPERTY(QPixmap avatar READ avatar WRITE setAvatar NOTIFY avatarChanged) -public: - AvatarExample(QObject *parent = 0) - : QObject(parent), m_value(100, 100) - { - m_value.fill(Qt::blue); - } - - ~AvatarExample() {} - - QPixmap avatar() const { return m_value; } - void setAvatar(QPixmap v) { m_value = v; emit avatarChanged(); } - -signals: - void avatarChanged(); - -private: - QPixmap m_value; -}; -//![0] - -#endif diff --git a/doc/src/snippets/declarative/integrating-javascript/scarceresources/exampleFive.qml b/doc/src/snippets/declarative/integrating-javascript/scarceresources/exampleFive.qml deleted file mode 100644 index 7cfab16a51..0000000000 --- a/doc/src/snippets/declarative/integrating-javascript/scarceresources/exampleFive.qml +++ /dev/null @@ -1,54 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -//![0] -// exampleFive.qml -import QtQuick 2.0 -import Qt.example 1.0 -import "exampleFour.js" as ExampleFourJs // use factory from example four - -QtObject { - property var avatarOne: ExampleFourJs.importAvatar() - property var avatarTwo: avatarOne - - Component.onCompleted: { - ExampleFourJs.releaseAvatar(avatarTwo); - } -} -//![0] \ No newline at end of file diff --git a/doc/src/snippets/declarative/integrating-javascript/scarceresources/exampleFour.js b/doc/src/snippets/declarative/integrating-javascript/scarceresources/exampleFour.js deleted file mode 100644 index d104e6f6c7..0000000000 --- a/doc/src/snippets/declarative/integrating-javascript/scarceresources/exampleFour.js +++ /dev/null @@ -1,56 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -//![0] -// exampleFour.js -.import Qt.example 1.0 as QtExample - -function importAvatar() { - var component = Qt.createComponent("exampleTwo.qml"); - var exampleOneElement = component.createObject(null); - var avatarExample = exampleOneElement.a; - var retn = avatarExample.avatar; - retn.preserve(); - return retn; -} - -function releaseAvatar(avatar) { - avatar.destroy(); -} -//![0] \ No newline at end of file diff --git a/doc/src/snippets/declarative/integrating-javascript/scarceresources/exampleFour.qml b/doc/src/snippets/declarative/integrating-javascript/scarceresources/exampleFour.qml deleted file mode 100644 index f5811602dc..0000000000 --- a/doc/src/snippets/declarative/integrating-javascript/scarceresources/exampleFour.qml +++ /dev/null @@ -1,56 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -//![0] -// exampleFour.qml -import QtQuick 2.0 -import Qt.example 1.0 -import "exampleFour.js" as ExampleFourJs - -QtObject { - property var avatarOne - property var avatarTwo - - Component.onCompleted: { - avatarOne = ExampleFourJs.importAvatar(); - avatarTwo = ExampleFourJs.importAvatar(); - ExampleFourJs.releaseAvatar(avatarTwo); - } -} -//![0] \ No newline at end of file diff --git a/doc/src/snippets/declarative/integrating-javascript/scarceresources/exampleOne.qml b/doc/src/snippets/declarative/integrating-javascript/scarceresources/exampleOne.qml deleted file mode 100644 index cf9b3ebc5d..0000000000 --- a/doc/src/snippets/declarative/integrating-javascript/scarceresources/exampleOne.qml +++ /dev/null @@ -1,54 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -//![0] -// exampleOne.qml -import QtQuick 2.0 -import Qt.example 1.0 - -QtObject { - property AvatarExample a; - a: AvatarExample { id: example } - property var avatarWidth: example.avatar,100 - // Here, we use "example.avatar,100" purely for illustration. - // The value of `avatarWidth' will be 100 after evaluation. - // E.g., you could imagine some js function which takes - // an avatar, and returns the width of the avatar. -} -//![0] \ No newline at end of file diff --git a/doc/src/snippets/declarative/integrating-javascript/scarceresources/exampleThree.js b/doc/src/snippets/declarative/integrating-javascript/scarceresources/exampleThree.js deleted file mode 100644 index 44df13f7a4..0000000000 --- a/doc/src/snippets/declarative/integrating-javascript/scarceresources/exampleThree.js +++ /dev/null @@ -1,58 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -//![0] -// exampleThree.js -.import Qt.example 1.0 as QtExample - -var component = Qt.createComponent("exampleTwo.qml"); -var exampleOneElement = component.createObject(null); -var avatarExample = exampleOneElement.a; -var retn = avatarExample.avatar; - -// without the following call, the scarce resource held -// by retn would be automatically released by the engine -// after the import statement in exampleTwo.qml, prior -// to the variable assignment. -retn.preserve(); - -function importAvatar() { - return retn; -} -//![0] \ No newline at end of file diff --git a/doc/src/snippets/declarative/integrating-javascript/scarceresources/exampleThree.qml b/doc/src/snippets/declarative/integrating-javascript/scarceresources/exampleThree.qml deleted file mode 100644 index 3f12458cec..0000000000 --- a/doc/src/snippets/declarative/integrating-javascript/scarceresources/exampleThree.qml +++ /dev/null @@ -1,49 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -//![0] -// exampleThree.qml -import QtQuick 2.0 -import Qt.example 1.0 -import "exampleThree.js" as ExampleThreeJs - -QtObject { - property var avatar: ExampleThreeJs.importAvatar() -} -//![0] \ No newline at end of file diff --git a/doc/src/snippets/declarative/integrating-javascript/scarceresources/exampleTwo.qml b/doc/src/snippets/declarative/integrating-javascript/scarceresources/exampleTwo.qml deleted file mode 100644 index f322fb9ed9..0000000000 --- a/doc/src/snippets/declarative/integrating-javascript/scarceresources/exampleTwo.qml +++ /dev/null @@ -1,51 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -//![0] -// exampleTwo.qml -import QtQuick 2.0 -import Qt.example 1.0 - -QtObject { - property AvatarExample a; - a: AvatarExample { id: example } - property var avatar: example.avatar - // Now `avatar' contains a reference to the scarce resource. -} -//![0] \ No newline at end of file diff --git a/doc/src/snippets/declarative/integrating-javascript/script.js b/doc/src/snippets/declarative/integrating-javascript/script.js deleted file mode 100644 index 006cf1aead..0000000000 --- a/doc/src/snippets/declarative/integrating-javascript/script.js +++ /dev/null @@ -1,47 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -//![0] -// script.js - -function jsFunction() { - console.log("Called JavaScript function!") -} -//![0] - diff --git a/doc/src/snippets/declarative/keynavigation.qml b/doc/src/snippets/declarative/keynavigation.qml deleted file mode 100644 index 4854ecd0ed..0000000000 --- a/doc/src/snippets/declarative/keynavigation.qml +++ /dev/null @@ -1,84 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -//![0] -import QtQuick 2.0 - -Grid { - width: 100; height: 100 - columns: 2 - - Rectangle { - id: topLeft - width: 50; height: 50 - color: focus ? "red" : "lightgray" - focus: true - - KeyNavigation.right: topRight - KeyNavigation.down: bottomLeft - } - - Rectangle { - id: topRight - width: 50; height: 50 - color: focus ? "red" : "lightgray" - - KeyNavigation.left: topLeft - KeyNavigation.down: bottomRight - } - - Rectangle { - id: bottomLeft - width: 50; height: 50 - color: focus ? "red" : "lightgray" - - KeyNavigation.right: bottomRight - KeyNavigation.up: topLeft - } - - Rectangle { - id: bottomRight - width: 50; height: 50 - color: focus ? "red" : "lightgray" - - KeyNavigation.left: bottomLeft - KeyNavigation.up: topRight - } -} -//![0] diff --git a/doc/src/snippets/declarative/keys/keys-handler.qml b/doc/src/snippets/declarative/keys/keys-handler.qml deleted file mode 100644 index 21fc98e23d..0000000000 --- a/doc/src/snippets/declarative/keys/keys-handler.qml +++ /dev/null @@ -1,60 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -Item { - width: 400; height: 400 - -//! [key item] -Item { - anchors.fill: parent - focus: true - Keys.onLeftPressed: console.log("move left") -} -//! [key item] - -Text { - anchors.fill: parent - text: "Press a cursor key" - horizontalAlignment: Text.AlignHCenter - verticalAlignment: Text.AlignVCenter -} -} diff --git a/doc/src/snippets/declarative/keys/keys-pressed.qml b/doc/src/snippets/declarative/keys/keys-pressed.qml deleted file mode 100644 index 3c9a2d9dce..0000000000 --- a/doc/src/snippets/declarative/keys/keys-pressed.qml +++ /dev/null @@ -1,65 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -Item { - width: 400; height: 400 - -//! [key item] -Item { - anchors.fill: parent - focus: true - Keys.onPressed: { - if (event.key == Qt.Key_Left) { - console.log("move left"); - event.accepted = true; - } - } -} -//! [key item] - -Text { - anchors.fill: parent - text: "Press a cursor key" - horizontalAlignment: Text.AlignHCenter - verticalAlignment: Text.AlignVCenter -} -} diff --git a/doc/src/snippets/declarative/layoutmirroring.qml b/doc/src/snippets/declarative/layoutmirroring.qml deleted file mode 100644 index 5daf3f58b3..0000000000 --- a/doc/src/snippets/declarative/layoutmirroring.qml +++ /dev/null @@ -1,71 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -//![0] -import QtQuick 2.0 - -Rectangle { - LayoutMirroring.enabled: true - LayoutMirroring.childrenInherit: true - - width: 300; height: 50 - color: "yellow" - border.width: 1 - - Row { - anchors { left: parent.left; margins: 5 } - y: 5; spacing: 5 - - Repeater { - model: 5 - - Rectangle { - color: "red" - opacity: (5 - index) / 5 - width: 40; height: 40 - - Text { - text: index + 1 - anchors.centerIn: parent - } - } - } - } -} -//![0] diff --git a/doc/src/snippets/declarative/listmodel-modify.qml b/doc/src/snippets/declarative/listmodel-modify.qml deleted file mode 100644 index 308453b393..0000000000 --- a/doc/src/snippets/declarative/listmodel-modify.qml +++ /dev/null @@ -1,96 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -import QtQuick 2.0 - -Rectangle { - width: 200; height: 200 - -ListModel { - id: fruitModel - - ListElement { - name: "Apple" - cost: 2.45 - attributes: [ - ListElement { description: "Core" }, - ListElement { description: "Deciduous" } - ] - } - ListElement { - name: "Orange" - cost: 3.25 - attributes: [ - ListElement { description: "Citrus" } - ] - } - ListElement { - name: "Banana" - cost: 1.95 - attributes: [ - ListElement { description: "Tropical" }, - ListElement { description: "Seedless" } - ] - } -} - -//![delegate] - Component { - id: fruitDelegate - Item { - width: 200; height: 50 - Text { text: name } - Text { text: '$' + cost; anchors.right: parent.right } - - // Double the price when clicked. - MouseArea { - anchors.fill: parent - onClicked: fruitModel.setProperty(index, "cost", cost * 2) - } - } - } -//![delegate] - -ListView { - width: 200; height: 200 - model: fruitModel - delegate: fruitDelegate -} - -} diff --git a/doc/src/snippets/declarative/listmodel-nested.qml b/doc/src/snippets/declarative/listmodel-nested.qml deleted file mode 100644 index bac95608e1..0000000000 --- a/doc/src/snippets/declarative/listmodel-nested.qml +++ /dev/null @@ -1,102 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -import QtQuick 2.0 - -Rectangle { - width: 200; height: 200 - - -//![model] -ListModel { - id: fruitModel - - ListElement { - name: "Apple" - cost: 2.45 - attributes: [ - ListElement { description: "Core" }, - ListElement { description: "Deciduous" } - ] - } - ListElement { - name: "Orange" - cost: 3.25 - attributes: [ - ListElement { description: "Citrus" } - ] - } - ListElement { - name: "Banana" - cost: 1.95 - attributes: [ - ListElement { description: "Tropical" }, - ListElement { description: "Seedless" } - ] - } -} -//![model] - -//![delegate] -Component { - id: fruitDelegate - Item { - width: 200; height: 50 - Text { id: nameField; text: name } - Text { text: '$' + cost; anchors.left: nameField.right } - Row { - anchors.top: nameField.bottom - spacing: 5 - Text { text: "Attributes:" } - Repeater { - model: attributes - Text { text: description } - } - } - } -} -//![delegate] - -ListView { - width: 200; height: 200 - model: fruitModel - delegate: fruitDelegate -} - -} diff --git a/doc/src/snippets/declarative/listmodel-simple.qml b/doc/src/snippets/declarative/listmodel-simple.qml deleted file mode 100644 index e8c4cea68e..0000000000 --- a/doc/src/snippets/declarative/listmodel-simple.qml +++ /dev/null @@ -1,79 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -//![0] -import QtQuick 2.0 - -Rectangle { - width: 200; height: 200 - - ListModel { - id: fruitModel -//![0] - ListElement { - name: "Apple" - cost: 2.45 - } - ListElement { - name: "Orange" - cost: 3.25 - } - ListElement { - name: "Banana" - cost: 1.95 - } -//![1] - } - - Component { - id: fruitDelegate - Row { - spacing: 10 - Text { text: name } - Text { text: '$' + cost } - } - } - - ListView { - anchors.fill: parent - model: fruitModel - delegate: fruitDelegate - } -} -//![1] diff --git a/doc/src/snippets/declarative/listmodel.qml b/doc/src/snippets/declarative/listmodel.qml deleted file mode 100644 index e93732e2ee..0000000000 --- a/doc/src/snippets/declarative/listmodel.qml +++ /dev/null @@ -1,59 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -//![0] -import QtQuick 2.0 - -ListModel { - id: fruitModel - - ListElement { - name: "Apple" - cost: 2.45 - } - ListElement { - name: "Orange" - cost: 3.25 - } - ListElement { - name: "Banana" - cost: 1.95 - } -} -//![0] diff --git a/doc/src/snippets/declarative/listview-decorations.qml b/doc/src/snippets/declarative/listview-decorations.qml deleted file mode 100644 index ccd7023d9c..0000000000 --- a/doc/src/snippets/declarative/listview-decorations.qml +++ /dev/null @@ -1,111 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -//! [document] -import QtQuick 2.0 - -//! [parent begin] -Rectangle { -//! [parent begin] - width: 550; height: 220; color: "white" - -//! [model] -ListModel { - id: nameModel - ListElement { name: "Alice" } - ListElement { name: "Bob" } - ListElement { name: "Jane" } - ListElement { name: "Harry" } - ListElement { name: "Wendy" } -} -//! [model] - -//! [delegate] -Component { - id: nameDelegate - Text { - text: name; - font.pixelSize: 24 - } -} -//! [delegate] - -//! [decorations] -ListView { - anchors.fill: parent - clip: true - model: nameModel - delegate: nameDelegate - header: bannercomponent - footer: Rectangle { - width: parent.width; height: 30; - gradient: clubcolors - } - highlight: Rectangle { - width: parent.width - color: "lightgray" - } -} - -Component { //instantiated when header is processed - id: bannercomponent - Rectangle { - id: banner - width: parent.width; height: 50 - gradient: clubcolors - border {color: "#9EDDF2"; width: 2} - Text { - anchors.centerIn: parent - text: "Club Members" - font.pixelSize: 32 - } - } -} -Gradient { - id: clubcolors - GradientStop { position: 0.0; color: "#8EE2FE"} - GradientStop { position: 0.66; color: "#7ED2EE"} -} -//! [decorations] - -//! [parent end] -} -//! [parent end] -//! [document] diff --git a/doc/src/snippets/declarative/listview-sections.qml b/doc/src/snippets/declarative/listview-sections.qml deleted file mode 100644 index 59cfdf80bb..0000000000 --- a/doc/src/snippets/declarative/listview-sections.qml +++ /dev/null @@ -1,101 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -//! [document] -import QtQuick 2.0 - -//! [parent begin] -Rectangle { -//! [parent begin] - width: 150; height: 300; color: "white" - -//! [model] -ListModel { - id: nameModel - ListElement { name: "Alice"; team: "Crypto" } - ListElement { name: "Bob"; team: "Crypto" } - ListElement { name: "Jane"; team: "QA" } - ListElement { name: "Victor"; team: "QA" } - ListElement { name: "Wendy"; team: "Graphics" } -} -//! [model] - -//! [delegate] -Component { - id: nameDelegate - Text { - text: name; - font.pixelSize: 24 - anchors.left: parent.left - anchors.leftMargin: 2 - } -} -//! [delegate] - -//! [section] -ListView { - anchors.fill: parent - model: nameModel - delegate: nameDelegate - focus: true - highlight: Rectangle { - color: "lightblue" - width: parent.width - } - section { - property: "team" - criteria: ViewSection.FullString - delegate: Rectangle { - color: "#b0dfb0" - width: parent.width - height: childrenRect.height + 4 - Text { anchors.horizontalCenter: parent.horizontalCenter - font.pixelSize: 16 - font.bold: true - text: section - } - } - } -} -//! [section] - -//! [parent end] -} -//! [parent end] -//! [document] diff --git a/doc/src/snippets/declarative/listview.qml b/doc/src/snippets/declarative/listview.qml deleted file mode 100644 index e8752a47cd..0000000000 --- a/doc/src/snippets/declarative/listview.qml +++ /dev/null @@ -1,87 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -//! [document] -import QtQuick 2.0 - -//! [parent begin] -Rectangle { -//! [parent begin] - width: 175; height: 175; color: "white" - -//! [model] -ListModel { - id: petlist - ListElement { type: "Cat" } - ListElement { type: "Dog" } - ListElement { type: "Mouse" } - ListElement { type: "Rabbit" } - ListElement { type: "Horse" } -} -//! [model] - -//! [delegate] -Component { - id: petdelegate - Text { - id: label - font.pixelSize: 24 - text: if (index == 0) - label.text = type + " (default)" - else - text: type - } -} -//! [delegate] - -//! [view] -ListView { - id: view - anchors.fill: parent - - model: petlist - delegate: petdelegate -} -//! [view] - -//! [parent end] -} -//! [parent end] -//! [document] diff --git a/doc/src/snippets/declarative/listview/ContactModel.qml b/doc/src/snippets/declarative/listview/ContactModel.qml deleted file mode 100644 index 395c637b6a..0000000000 --- a/doc/src/snippets/declarative/listview/ContactModel.qml +++ /dev/null @@ -1,58 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -//![0] -import QtQuick 2.0 - -ListModel { - ListElement { - name: "Bill Smith" - number: "555 3264" - } - ListElement { - name: "John Brown" - number: "555 8426" - } - ListElement { - name: "Sam Wise" - number: "555 0473" - } -} -//![0] diff --git a/doc/src/snippets/declarative/listview/listview-snippet.qml b/doc/src/snippets/declarative/listview/listview-snippet.qml deleted file mode 100644 index 1458e9aa50..0000000000 --- a/doc/src/snippets/declarative/listview/listview-snippet.qml +++ /dev/null @@ -1,52 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -//! [document] -import QtQuick 2.0 - -ListView { - width: 50; height: 200 - model: 4 - delegate: Text { - text: index; - font.pixelSize: 40 - } -} -//! [document] diff --git a/doc/src/snippets/declarative/listview/listview.qml b/doc/src/snippets/declarative/listview/listview.qml deleted file mode 100644 index 689e6d2c45..0000000000 --- a/doc/src/snippets/declarative/listview/listview.qml +++ /dev/null @@ -1,149 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -//![import] -import QtQuick 2.0 -//![import] - -Item { - -//![classdocs simple] -ListView { - width: 180; height: 200 - - model: ContactModel {} - delegate: Text { - text: name + ": " + number - } -} -//![classdocs simple] - -//![classdocs advanced] -Rectangle { - width: 180; height: 200 - - Component { - id: contactDelegate - Item { - width: 180; height: 40 - Column { - Text { text: 'Name: ' + name } - Text { text: 'Number: ' + number } - } - } - } - - ListView { - anchors.fill: parent - model: ContactModel {} - delegate: contactDelegate - highlight: Rectangle { color: "lightsteelblue"; radius: 5 } - focus: true - } -} -//![classdocs advanced] - -//![delayRemove] -Component { - id: delegate - Item { - ListView.onRemove: SequentialAnimation { - PropertyAction { target: wrapper; property: "ListView.delayRemove"; value: true } - NumberAnimation { target: wrapper; property: "scale"; to: 0; duration: 250; easing.type: Easing.InOutQuad } - PropertyAction { target: wrapper; property: "ListView.delayRemove"; value: false } - } - } -} -//![delayRemove] - -//![highlightFollowsCurrentItem] -Component { - id: highlight - Rectangle { - width: 180; height: 40 - color: "lightsteelblue"; radius: 5 - y: list.currentItem.y - Behavior on y { - SpringAnimation { - spring: 3 - damping: 0.2 - } - } - } -} - -ListView { - id: list - width: 180; height: 200 - model: ContactModel {} - delegate: Text { text: name } - - highlight: highlight - highlightFollowsCurrentItem: false - focus: true -} -//![highlightFollowsCurrentItem] - -//![isCurrentItem] -ListView { - width: 180; height: 200 - - Component { - id: contactsDelegate - Rectangle { - id: wrapper - width: 180 - height: contactInfo.height - color: ListView.isCurrentItem ? "black" : "red" - Text { - id: contactInfo - text: name + ": " + number - color: wrapper.ListView.isCurrentItem ? "red" : "black" - } - } - } - - model: ContactModel {} - delegate: contactsDelegate - focus: true -} -//![isCurrentItem] - -} diff --git a/doc/src/snippets/declarative/loader/KeyReader.qml b/doc/src/snippets/declarative/loader/KeyReader.qml deleted file mode 100644 index ef15a01bb1..0000000000 --- a/doc/src/snippets/declarative/loader/KeyReader.qml +++ /dev/null @@ -1,53 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -//![0] -import QtQuick 2.0 - -Item { - Item { - focus: true - Keys.onPressed: { - console.log("Loaded item captured:", event.text); - event.accepted = true; - } - } -} -//![0] diff --git a/doc/src/snippets/declarative/loader/MyItem.qml b/doc/src/snippets/declarative/loader/MyItem.qml deleted file mode 100644 index 2879e7ae23..0000000000 --- a/doc/src/snippets/declarative/loader/MyItem.qml +++ /dev/null @@ -1,55 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -//![0] -import QtQuick 2.0 - -Rectangle { - id: myItem - signal message(string msg) - - width: 100; height: 100 - - MouseArea { - anchors.fill: parent - onClicked: myItem.message("clicked!") - } -} -//![0] diff --git a/doc/src/snippets/declarative/loader/connections.qml b/doc/src/snippets/declarative/loader/connections.qml deleted file mode 100644 index 82d770b2cb..0000000000 --- a/doc/src/snippets/declarative/loader/connections.qml +++ /dev/null @@ -1,57 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -//![0] -import QtQuick 2.0 - -Item { - width: 100; height: 100 - - Loader { - id: myLoader - source: "MyItem.qml" - } - - Connections { - target: myLoader.item - onMessage: console.log(msg) - } -} -//![0] diff --git a/doc/src/snippets/declarative/loader/focus.qml b/doc/src/snippets/declarative/loader/focus.qml deleted file mode 100644 index 4447c62905..0000000000 --- a/doc/src/snippets/declarative/loader/focus.qml +++ /dev/null @@ -1,62 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -//![0] -import QtQuick 2.0 - -Rectangle { - width: 200; height: 200 - - Loader { - id: loader - focus: true - } - - MouseArea { - anchors.fill: parent - onClicked: loader.source = "KeyReader.qml" - } - - Keys.onPressed: { - console.log("Captured:", event.text); - } -} -//![0] - diff --git a/doc/src/snippets/declarative/loader/simple.qml b/doc/src/snippets/declarative/loader/simple.qml deleted file mode 100644 index a4408c2231..0000000000 --- a/doc/src/snippets/declarative/loader/simple.qml +++ /dev/null @@ -1,54 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -//![0] -import QtQuick 2.0 - -Item { - width: 200; height: 200 - - Loader { id: pageLoader } - - MouseArea { - anchors.fill: parent - onClicked: pageLoader.source = "Page1.qml" - } -} -//![0] diff --git a/doc/src/snippets/declarative/loader/sizeitem.qml b/doc/src/snippets/declarative/loader/sizeitem.qml deleted file mode 100644 index d673d82817..0000000000 --- a/doc/src/snippets/declarative/loader/sizeitem.qml +++ /dev/null @@ -1,62 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -//![0] -import QtQuick 2.0 - -Item { - width: 200; height: 200 - - Loader { - // position the Loader in the center of the parent - anchors.centerIn: parent - sourceComponent: rect - } - - Component { - id: rect - Rectangle { - width: 50 - height: 50 - color: "red" - } - } -} -//![0] diff --git a/doc/src/snippets/declarative/loader/sizeloader.qml b/doc/src/snippets/declarative/loader/sizeloader.qml deleted file mode 100644 index 551324598c..0000000000 --- a/doc/src/snippets/declarative/loader/sizeloader.qml +++ /dev/null @@ -1,62 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -//![0] -import QtQuick 2.0 - -Item { - width: 200; height: 200 - - Loader { - // Explicitly set the size of the Loader to the parent item's size - anchors.fill: parent - sourceComponent: rect - } - - Component { - id: rect - Rectangle { - width: 50 - height: 50 - color: "red" - } - } -} -//![0] diff --git a/doc/src/snippets/declarative/models/views-models-delegates.qml b/doc/src/snippets/declarative/models/views-models-delegates.qml deleted file mode 100644 index e9f872578f..0000000000 --- a/doc/src/snippets/declarative/models/views-models-delegates.qml +++ /dev/null @@ -1,79 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -import QtQuick 2.0 - -//! [rectangle] -Rectangle { - width: 200; height: 200 - - ListModel { - id: fruitModel - property string language: "en" - ListElement { - name: "Apple" - cost: 2.45 - } - ListElement { - name: "Orange" - cost: 3.25 - } - ListElement { - name: "Banana" - cost: 1.95 - } - } - - Component { - id: fruitDelegate - Row { - Text { text: " Fruit: " + name; color: ListView.view.fruit_color } - Text { text: " Cost: $" + cost } - Text { text: " Language: " + ListView.view.model.language } - } - } - - ListView { - property color fruit_color: "green" - model: fruitModel - delegate: fruitDelegate - anchors.fill: parent - } -} -//! [rectangle] diff --git a/doc/src/snippets/declarative/models/visual-model-and-view.qml b/doc/src/snippets/declarative/models/visual-model-and-view.qml deleted file mode 100644 index 97e443b675..0000000000 --- a/doc/src/snippets/declarative/models/visual-model-and-view.qml +++ /dev/null @@ -1,58 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -import QtQuick 2.0 - -Rectangle { - width: 200; height: 200 - - //! [visual model and view] - VisualItemModel { - id: itemModel - Rectangle { height: 30; width: 80; color: "red" } - Rectangle { height: 30; width: 80; color: "green" } - Rectangle { height: 30; width: 80; color: "blue" } - } - - ListView { - anchors.fill: parent - model: itemModel - } - //! [visual model and view] -} diff --git a/doc/src/snippets/declarative/mousearea/mousearea-snippet.qml b/doc/src/snippets/declarative/mousearea/mousearea-snippet.qml deleted file mode 100644 index 237c0c31b0..0000000000 --- a/doc/src/snippets/declarative/mousearea/mousearea-snippet.qml +++ /dev/null @@ -1,98 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -//! [document] -import QtQuick 2.0 - -//! [parent begin] -Rectangle { -//! [parent begin] - width: 500; height: 500 - color: "green" - - Column { - //! [anchor fill] - Rectangle { - id: button - width: 100; height: 100 - - MouseArea { - anchors.fill: parent - onClicked: console.log("button clicked") - } - MouseArea { - width:150; height: 75 - onClicked: console.log("irregular area clicked") - } - } - //! [anchor fill] - - Rectangle { - width: 100; height: 100 - - //! [enable handlers] - MouseArea { - hoverEnabled: true - acceptedButtons: Qt.LeftButton | Qt.RightButton - onEntered: console.log("mouse entered the area") - onExited: console.log("mouse left the area") - } - //! [enable handlers] - } - - Rectangle { - width: 100; height: 100 - - //! [mouse handlers] - MouseArea { - anchors.fill: parent - onClicked: console.log("area clicked") - onDoubleClicked: console.log("area double clicked") - onEntered: console.log("mouse entered the area") - onExited: console.log("mouse left the area") - } - //! [mouse handlers] - } - - } //end of column -//! [parent end] -} -//! [parent end] -//! [document] diff --git a/doc/src/snippets/declarative/mousearea/mousearea.qml b/doc/src/snippets/declarative/mousearea/mousearea.qml deleted file mode 100644 index 1f35cd8b5f..0000000000 --- a/doc/src/snippets/declarative/mousearea/mousearea.qml +++ /dev/null @@ -1,117 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -//! [import] -import QtQuick 2.0 -//! [import] - -Rectangle { - width: childrenRect.width - height: childrenRect.height - - Row { - //! [intro] - Rectangle { - width: 100; height: 100 - color: "green" - - MouseArea { - anchors.fill: parent - onClicked: { parent.color = 'red' } - } - } - //! [intro] - - //! [intro-extended] - Rectangle { - width: 100; height: 100 - color: "green" - - MouseArea { - anchors.fill: parent - acceptedButtons: Qt.LeftButton | Qt.RightButton - onClicked: { - if (mouse.button == Qt.RightButton) - parent.color = 'blue'; - else - parent.color = 'red'; - } - } - } - //! [intro-extended] - - //! [drag] - Rectangle { - id: container - width: 600; height: 200 - - Rectangle { - id: rect - width: 50; height: 50 - color: "red" - opacity: (600.0 - rect.x) / 600 - - MouseArea { - anchors.fill: parent - drag.target: rect - drag.axis: Drag.XAxis - drag.minimumX: 0 - drag.maximumX: container.width - rect.width - } - } - } - //! [drag] - - //! [mousebuttons] - Text { - text: mouseArea.pressedButtons & Qt.RightButton ? "right" : "" - horizontalAlignment: Text.AlignHCenter - verticalAlignment: Text.AlignVCenter - - MouseArea { - id: mouseArea - anchors.fill: parent - acceptedButtons: Qt.LeftButton | Qt.RightButton - } - } - //! [mousebuttons] - - } -} diff --git a/doc/src/snippets/declarative/mousearea/mouseareadragfilter.qml b/doc/src/snippets/declarative/mousearea/mouseareadragfilter.qml deleted file mode 100644 index 922bfea636..0000000000 --- a/doc/src/snippets/declarative/mousearea/mouseareadragfilter.qml +++ /dev/null @@ -1,72 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -//! [dragfilter] -import QtQuick 2.0 - -Rectangle { - width: 480 - height: 320 - Rectangle { - x: 30; y: 30 - width: 300; height: 240 - color: "lightsteelblue" - - MouseArea { - anchors.fill: parent - drag.target: parent; - drag.axis: "XAxis" - drag.minimumX: 30 - drag.maximumX: 150 - drag.filterChildren: true - - Rectangle { - color: "yellow" - x: 50; y : 50 - width: 100; height: 100 - MouseArea { - anchors.fill: parent - onClicked: console.log("Clicked") - } - } - } - } -} -//! [dragfilter] diff --git a/doc/src/snippets/declarative/multipointtoucharea/multipointtoucharea.qml b/doc/src/snippets/declarative/multipointtoucharea/multipointtoucharea.qml deleted file mode 100644 index e4c2ffb039..0000000000 --- a/doc/src/snippets/declarative/multipointtoucharea/multipointtoucharea.qml +++ /dev/null @@ -1,67 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -//![0] -import QtQuick 2.0 - -Rectangle { - width: 400; height: 400 - MultiPointTouchArea { - anchors.fill: parent - touchPoints: [ - TouchPoint { id: point1 }, - TouchPoint { id: point2 } - ] - } - - Rectangle { - width: 30; height: 30 - color: "green" - x: point1.x - y: point1.y - } - - Rectangle { - width: 30; height: 30 - color: "yellow" - x: point2.x - y: point2.y - } -} -//![0] diff --git a/doc/src/snippets/declarative/numberanimation.qml b/doc/src/snippets/declarative/numberanimation.qml deleted file mode 100644 index 404381863d..0000000000 --- a/doc/src/snippets/declarative/numberanimation.qml +++ /dev/null @@ -1,51 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -//![0] -import QtQuick 2.0 - -Rectangle { - width: 100; height: 100 - color: "red" - - NumberAnimation on x { to: 50; duration: 1000 } -} -//![0] - diff --git a/doc/src/snippets/declarative/parallelanimation.qml b/doc/src/snippets/declarative/parallelanimation.qml deleted file mode 100644 index 20f6ccc1df..0000000000 --- a/doc/src/snippets/declarative/parallelanimation.qml +++ /dev/null @@ -1,56 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -//![0] -import QtQuick 2.0 - -Rectangle { - id: rect - width: 100; height: 100 - color: "red" - - ParallelAnimation { - running: true - NumberAnimation { target: rect; property: "x"; to: 50; duration: 1000 } - NumberAnimation { target: rect; property: "y"; to: 50; duration: 1000 } - } -} -//![0] - diff --git a/doc/src/snippets/declarative/parentanimation.qml b/doc/src/snippets/declarative/parentanimation.qml deleted file mode 100644 index 60429ed61c..0000000000 --- a/doc/src/snippets/declarative/parentanimation.qml +++ /dev/null @@ -1,73 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -//![0] -import QtQuick 2.0 - -Item { - width: 200; height: 100 - - Rectangle { - id: redRect - width: 100; height: 100 - color: "red" - } - - Rectangle { - id: blueRect - x: redRect.width - width: 50; height: 50 - color: "blue" - - states: State { - name: "reparented" - ParentChange { target: blueRect; parent: redRect; x: 10; y: 10 } - } - - transitions: Transition { - ParentAnimation { - NumberAnimation { properties: "x,y"; duration: 1000 } - } - } - - MouseArea { anchors.fill: parent; onClicked: blueRect.state = "reparented" } - } -} -//![0] - diff --git a/doc/src/snippets/declarative/parentchange.qml b/doc/src/snippets/declarative/parentchange.qml deleted file mode 100644 index 4ae4476e13..0000000000 --- a/doc/src/snippets/declarative/parentchange.qml +++ /dev/null @@ -1,67 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -//![0] -import QtQuick 2.0 - -Item { - width: 200; height: 100 - - Rectangle { - id: redRect - width: 100; height: 100 - color: "red" - } - - Rectangle { - id: blueRect - x: redRect.width - width: 50; height: 50 - color: "blue" - - states: State { - name: "reparented" - ParentChange { target: blueRect; parent: redRect; x: 10; y: 10 } - } - - MouseArea { anchors.fill: parent; onClicked: blueRect.state = "reparented" } - } -} -//![0] - diff --git a/doc/src/snippets/declarative/path/arcdirection.qml b/doc/src/snippets/declarative/path/arcdirection.qml deleted file mode 100644 index 7522649607..0000000000 --- a/doc/src/snippets/declarative/path/arcdirection.qml +++ /dev/null @@ -1,51 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 -//![0] -Path { - startX: 50; startY: 50 - - PathArc { - x: 150; y: 50 - radiusX: 75; radiusY: 50 - } -} -//![0] diff --git a/doc/src/snippets/declarative/path/arcradius.qml b/doc/src/snippets/declarative/path/arcradius.qml deleted file mode 100644 index 04f2919270..0000000000 --- a/doc/src/snippets/declarative/path/arcradius.qml +++ /dev/null @@ -1,63 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 -//![0] -Path { - startX: 0; startY: 100 - - PathArc { - relativeX: 50; y: 100 - radiusX: 25; radiusY: 15 - } - PathArc { - relativeX: 50; y: 100 - radiusX: 25; radiusY: 25 - } - PathArc { - relativeX: 50; y: 100 - radiusX: 25; radiusY: 50 - } - PathArc { - relativeX: 50; y: 100 - radiusX: 50; radiusY: 100 - } -} -//![0] diff --git a/doc/src/snippets/declarative/path/basicarc.qml b/doc/src/snippets/declarative/path/basicarc.qml deleted file mode 100644 index 562f2a0adf..0000000000 --- a/doc/src/snippets/declarative/path/basicarc.qml +++ /dev/null @@ -1,52 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 -//![0] -Path { - startX: 100; startY: 0 - - PathArc { - x: 0; y: 100 - radiusX: 100; radiusY: 100 - useLargeArc: true - } -} -//![0] diff --git a/doc/src/snippets/declarative/path/basiccurve.qml b/doc/src/snippets/declarative/path/basiccurve.qml deleted file mode 100644 index feb783cb01..0000000000 --- a/doc/src/snippets/declarative/path/basiccurve.qml +++ /dev/null @@ -1,63 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -//![0] -import QtQuick 2.0 - -Canvas { - width: 400; height: 200 - - Path { - id: myPath - startX: 0; startY: 100 - - PathCurve { x: 75; y: 75 } - PathCurve { x: 200; y: 150 } - PathCurve { x: 325; y: 25 } - PathCurve { x: 400; y: 100 } - } - - onPaint: { - context.strokeStyle = Qt.rgba(.4,.6,.8); - context.path = myPath; - context.stroke(); - } -} -//![0] diff --git a/doc/src/snippets/declarative/path/largearc.qml b/doc/src/snippets/declarative/path/largearc.qml deleted file mode 100644 index 69ce953c92..0000000000 --- a/doc/src/snippets/declarative/path/largearc.qml +++ /dev/null @@ -1,51 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 -//![0] -Path { - startX: 0; startY: 100 - PathArc { - x: 100; y: 200 - radiusX: 100; radiusY: 100 - direction: PathArc.Clockwise - } -} -//![0] diff --git a/doc/src/snippets/declarative/pathinterpolator.qml b/doc/src/snippets/declarative/pathinterpolator.qml deleted file mode 100644 index 77cc664e27..0000000000 --- a/doc/src/snippets/declarative/pathinterpolator.qml +++ /dev/null @@ -1,74 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -//![0] -import QtQuick 2.0 - -Rectangle { - width: 400 - height: 400 - - PathInterpolator { - id: motionPath - - path: Path { - startX: 0; startY: 0 - - PathCubic { - x: 350; y: 350 - - control1X: 350; control1Y: 0 - control2X: 0; control2Y: 350 - } - } - - NumberAnimation on progress { from: 0; to: 1; duration: 2000 } - } - - Rectangle { - width: 50; height: 50 - color: "green" - - //bind our attributes to follow the path as progress changes - x: motionPath.x - y: motionPath.y - rotation: motionPath.angle - } -} -//![0] diff --git a/doc/src/snippets/declarative/pathview/ContactModel.qml b/doc/src/snippets/declarative/pathview/ContactModel.qml deleted file mode 100644 index d191413f27..0000000000 --- a/doc/src/snippets/declarative/pathview/ContactModel.qml +++ /dev/null @@ -1,58 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -//![0] -import QtQuick 2.0 - -ListModel { - ListElement { - name: "Bill Jones" - icon: "pics/qtlogo.png" - } - ListElement { - name: "Jane Doe" - icon: "pics/qtlogo.png" - } - ListElement { - name: "John Smith" - icon: "pics/qtlogo.png" - } -} -//![0] diff --git a/doc/src/snippets/declarative/pathview/pathattributes.qml b/doc/src/snippets/declarative/pathview/pathattributes.qml deleted file mode 100644 index d555998650..0000000000 --- a/doc/src/snippets/declarative/pathview/pathattributes.qml +++ /dev/null @@ -1,79 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -//! [0] -import QtQuick 2.0 - -Rectangle { - width: 240; height: 200 - -//! [1] - Component { - id: delegate - Item { - width: 80; height: 80 - scale: PathView.iconScale - opacity: PathView.iconOpacity - Column { - Image { anchors.horizontalCenter: nameText.horizontalCenter; width: 64; height: 64; source: icon } - Text { id: nameText; text: name; font.pointSize: 16 } - } - } - } -//! [1] - -//! [2] - PathView { - anchors.fill: parent - model: ContactModel {} - delegate: delegate - path: Path { - startX: 120; startY: 100 - PathAttribute { name: "iconScale"; value: 1.0 } - PathAttribute { name: "iconOpacity"; value: 1.0 } - PathQuad { x: 120; y: 25; controlX: 260; controlY: 75 } - PathAttribute { name: "iconScale"; value: 0.3 } - PathAttribute { name: "iconOpacity"; value: 0.5 } - PathQuad { x: 120; y: 100; controlX: -20; controlY: 75 } - } - } -//! [2] -} -//! [0] diff --git a/doc/src/snippets/declarative/pathview/pathview.qml b/doc/src/snippets/declarative/pathview/pathview.qml deleted file mode 100644 index e5249d4cb6..0000000000 --- a/doc/src/snippets/declarative/pathview/pathview.qml +++ /dev/null @@ -1,80 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -//! [0] -import QtQuick 2.0 - -Rectangle { - width: 240; height: 200 - -//! [1] - Component { - id: delegate - Column { - id: wrapper - Image { - anchors.horizontalCenter: nameText.horizontalCenter - width: 64; height: 64 - source: icon - } - Text { - id: nameText - text: name - font.pointSize: 16 - color: wrapper.PathView.isCurrentItem ? "red" : "black" - } - } - } -//! [1] - -//! [2] - PathView { - anchors.fill: parent - model: ContactModel {} - delegate: delegate - path: Path { - startX: 120; startY: 100 - PathQuad { x: 120; y: 25; controlX: 260; controlY: 75 } - PathQuad { x: 120; y: 100; controlX: -20; controlY: 75 } - } - } -//! [2] -} -//! [0] diff --git a/doc/src/snippets/declarative/properties.qml b/doc/src/snippets/declarative/properties.qml deleted file mode 100644 index 21894b68e0..0000000000 --- a/doc/src/snippets/declarative/properties.qml +++ /dev/null @@ -1,315 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -//! [document] -import QtQuick 2.0 - -//! [parent begin] -Rectangle { -//! [parent begin] - - //! [inherited properties] - width: 320; height: 240 - color: "lightblue" - focus: true - //! [inherited properties] - - //! [custom properties] - property int counter - property real area: 100.45 - //! [custom properties] - - //! [property types] - property int number - property real volume: 100.45 - property date today: "2011-01-01" - property color background: "yellow" - //! [property types] - - -//! [grouped properties] -Text { - //dot notation - font.pixelSize: 12 - font.bold: true -} - -Text { - //group notation - font {pixelSize: 12; bold: true} -} -//! [grouped properties] - - -//! [property binding] -Rectangle { - width: parent.width -} -//! [property binding] - -//! [property assignment] -Rectangle { - Component.onCompleted: { - width = 150 - } -} -//! [property assignment] - -Rectangle { - //placeholder slider - id: slider - property real value -} -Rectangle { - //placeholder system - id: system - property real brightness -} -//! [binding element] -Binding { - target: system - property: "brightness" - value: slider.value -} -//! [binding element] - -Rectangle { - //placeholder warning - id: warning - color: "red" -} -//! [PropertyChanges element] -Rectangle { - id: rectangle - - states: State { - name: "WARNING" - PropertyChanges { - target: rectangle - color: warning.color - } - } -} -//! [PropertyChanges element] - -//! [list property] -Item { - id: multistate - states: [ - State {name: "FETCH"}, - State {name: "DECODE"}, - State {name: "EXECUTE"} - ] -} -//! [list property] -//! [single property] -Item { - id: monostate - states: State {name: "RUNNING"} -} -//! [single property] - -Item { - id: printstate -//! [print list property] - Component.onCompleted: console.log (multistate.states[0].name) -//! [print list property] -} - -//! [JavaScript sample] -function calculateArea(width, height) { - return (width * height) * 0.5 -} - -Rectangle { - width: 150; height: 75 - property real area: calculateArea(width, height) - property real parentArea: calculateArea(parent.width,parent.height) - color: { if (area > parentArea) "blue"; else "red" } -} -//! [JavaScript sample] - -//! [id property] -Rectangle { - id: container - width: 100; height: 100 - Rectangle { - width: parent.width; height: parent.height - } -} -Rectangle { - width: container.width; height: container.height -} -//! [id property] - -//! [default property] -Item { - Text {} - Rectangle {} - Timer {} -} - -Item { - //without default property - children: [ - Text {}, - Rectangle {} - ] - resources: [ - Timer {} - ] -} -//! [default property] - -//! [state default] -State { - changes: [ - PropertyChanges {}, - PropertyChanges {} - ] -} - -State { - PropertyChanges {} - PropertyChanges {} -} -//! [state default] - -//! [object binding] -Rectangle { - - id: parentrectangle - gradient: - Gradient { //not a child of parentrectangle - - //generates a TypeError - //Component.onCompleted: console.log(parent.width) - } - - //child of parentrectangle - Rectangle {property string name: "childrectangle"} - - //prints "childrectangle" - Component.onCompleted: console.log(children[0].name) -} -//! [object binding] - -//! [list attached property] -Component { - id: listdelegate - Text { - text: "Hello" - color: ListView.isCurrentItem ? "red" : "blue" - } -} -ListView { - delegate: listdelegate -} -//! [list attached property] - -//! [attached signal handler] -Item { - Keys.onPressed: console.log("Key Press Detected") - Component.onCompleted: console.log("Completed initialization") -} -//! [attached signal handler] - -//! [alias usage] -Button { - id: textbutton - buttonLabel: "Click Me!" -} -//! [alias usage] - -//! [image alias] -Button { - id: imagebutton - buttonImage.source: "http://qt.nokia.com/logo.png" - buttonLabel: buttonImage.source -} -//! [image alias] - -Item { -id: widget - -//! [alias complete] -property alias widgetLabel: label - -//will generate an error -//widgetLabel.text: "Initial text" - -//will generate an error -//property alias widgetLabelText: widgetLabel.text - -Component.onCompleted: widgetLabel.text = "Alias completed Initialization" -//! [alias complete] - - Text {id: label} -} - -//![alias overwrite] -Rectangle { - id: coloredrectangle - property alias color: bluerectangle.color - color: "red" - - Rectangle { - id: bluerectangle - color: "#1234ff" - } - - Component.onCompleted: { - console.log (coloredrectangle.color) //prints "#1234ff" - setInternalColor() - console.log (coloredrectangle.color) //prints "#111111" - coloredrectangle.color = "#884646" - console.log (coloredrectangle.color) //prints #884646 - } - - //internal function that has access to internal properties - function setInternalColor() { - color = "#111111" - } -} -//![alias overwrite] -//! [parent end] -} -//! [parent end] -//! [document] diff --git a/doc/src/snippets/declarative/propertyaction-sequential.qml b/doc/src/snippets/declarative/propertyaction-sequential.qml deleted file mode 100644 index 77d6ec194e..0000000000 --- a/doc/src/snippets/declarative/propertyaction-sequential.qml +++ /dev/null @@ -1,72 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -import QtQuick 2.0 - -Row { - - Item { - width: 400; height: 400 - - Rectangle { - id: rect - width: 200; height: 100 - color: "red" - - states: State { - name: "rotated" - PropertyChanges { target: rect; rotation: 180; transformOrigin: Item.BottomRight } - } - - //! [sequential] - transitions: Transition { - SequentialAnimation { - PropertyAction { target: rect; property: "transformOrigin" } - RotationAnimation { duration: 1000; direction: RotationAnimation.Counterclockwise } - } - } - //! [sequential] - - MouseArea { - anchors.fill: parent - onClicked: rect.state = "rotated" - } - } - } -} diff --git a/doc/src/snippets/declarative/propertyaction.qml b/doc/src/snippets/declarative/propertyaction.qml deleted file mode 100644 index 5ddef30177..0000000000 --- a/doc/src/snippets/declarative/propertyaction.qml +++ /dev/null @@ -1,83 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -import QtQuick 2.0 - -Row { - - //![transition] - Item { - width: 400; height: 400 - - Rectangle { - id: rect - width: 200; height: 100 - color: "red" - - states: State { - name: "rotated" - PropertyChanges { target: rect; rotation: 180; transformOrigin: Item.BottomRight } - } - - transitions: Transition { - RotationAnimation { duration: 1000; direction: RotationAnimation.Counterclockwise } - } - - MouseArea { - anchors.fill: parent - onClicked: rect.state = "rotated" - } - } - } - //![transition] - - Item { - width: 300; height: 300 - - Image { id: img; source: "pics/qt.png" } - - //![standalone] - SequentialAnimation { - PropertyAction { target: img; property: "smooth"; value: "true" } - NumberAnimation { target: img; property: "width"; to: 300; duration: 1000 } - PropertyAction { target: img; property: "smooth"; value: "false" } - } - //![standalone] - } -} diff --git a/doc/src/snippets/declarative/propertyanimation.qml b/doc/src/snippets/declarative/propertyanimation.qml deleted file mode 100644 index b5781af94a..0000000000 --- a/doc/src/snippets/declarative/propertyanimation.qml +++ /dev/null @@ -1,100 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -Row { - -//![transition] -Rectangle { - id: rect - width: 100; height: 100 - color: "red" - - //! [single state] - states: State { - name: "moved" - PropertyChanges { target: rect; x: 50 } - } - //! [single state] - - transitions: Transition { - PropertyAnimation { properties: "x,y"; easing.type: Easing.InOutQuad } - } -} -//![transition] - -//![behavior] -Rectangle { - width: 100; height: 100 - color: "red" - - Behavior on x { PropertyAnimation {} } - - MouseArea { anchors.fill: parent; onClicked: parent.x = 50 } -} -//![behavior] - -//![propertyvaluesource] -Rectangle { - width: 100; height: 100 - color: "red" - - SequentialAnimation on x { - loops: Animation.Infinite - PropertyAnimation { to: 50 } - PropertyAnimation { to: 0 } - } -} -//![propertyvaluesource] - - //![standalone] - Rectangle { - id: theRect - width: 100; height: 100 - color: "red" - - // this is a standalone animation, it's not running by default - PropertyAnimation { id: animation; target: theRect; property: "width"; to: 30; duration: 500 } - - MouseArea { anchors.fill: parent; onClicked: animation.running = true } - } - //![standalone] -} diff --git a/doc/src/snippets/declarative/propertychanges.qml b/doc/src/snippets/declarative/propertychanges.qml deleted file mode 100644 index 3be13f7861..0000000000 --- a/doc/src/snippets/declarative/propertychanges.qml +++ /dev/null @@ -1,91 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -//![import] -import QtQuick 2.0 -//![import] - -Column { - -//![0] -Item { - id: container - width: 300; height: 300 - - Rectangle { - id: rect - width: 100; height: 100 - color: "red" - - MouseArea { - id: mouseArea - anchors.fill: parent - } - - states: State { - name: "resized"; when: mouseArea.pressed - PropertyChanges { target: rect; color: "blue"; height: container.height } - } - } -} -//![0] - -//![reset] -Rectangle { - width: 300; height: 200 - - Text { - id: myText - width: 50 - wrapMode: Text.WordWrap - text: "a text string that is longer than 50 pixels" - - states: State { - name: "widerText" - PropertyChanges { target: myText; width: undefined } - } - } - - MouseArea { - anchors.fill: parent - onClicked: myText.state = "widerText" - } -} -//![reset] -} diff --git a/doc/src/snippets/declarative/qml-data-models/dynamic-listmodel.qml b/doc/src/snippets/declarative/qml-data-models/dynamic-listmodel.qml deleted file mode 100644 index da9610c117..0000000000 --- a/doc/src/snippets/declarative/qml-data-models/dynamic-listmodel.qml +++ /dev/null @@ -1,67 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -Item { - width: 200; height: 250 - - //! [model] - ListModel { id: fruitModel } - //! [model] - - //! [view] - ListView { - anchors.fill: parent - model: fruitModel - delegate: Row { - Text { text: "Fruit: " + name } - Text { text: "Cost: $" + cost } - } - } - //! [view] - - //! [mouse area] - MouseArea { - anchors.fill: parent - onClicked: fruitModel.append({"cost": 5.95, "name":"Pizza"}) - } - //! [mouse area] -} diff --git a/doc/src/snippets/declarative/qml-data-models/listelements.qml b/doc/src/snippets/declarative/qml-data-models/listelements.qml deleted file mode 100644 index 0097423142..0000000000 --- a/doc/src/snippets/declarative/qml-data-models/listelements.qml +++ /dev/null @@ -1,77 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -//! [document] -import QtQuick 2.0 - -Item { - width: 200; height: 250 - - //! [model] - ListModel { - id: fruitModel - - ListElement { - name: "Apple" - cost: 2.45 - } - ListElement { - name: "Orange" - cost: 3.25 - } - ListElement { - name: "Banana" - cost: 1.95 - } - } - //! [model] - - //! [view] - ListView { - anchors.fill: parent - model: fruitModel - delegate: Row { - Text { text: "Fruit: " + name } - Text { text: "Cost: $" + cost } - } - } - //! [view] -} -//! [document] diff --git a/doc/src/snippets/declarative/qml-data-models/listmodel-listview.qml b/doc/src/snippets/declarative/qml-data-models/listmodel-listview.qml deleted file mode 100644 index 406fada2ce..0000000000 --- a/doc/src/snippets/declarative/qml-data-models/listmodel-listview.qml +++ /dev/null @@ -1,64 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -//! [document] -import QtQuick 2.0 - -Item { - width: 200; height: 250 - - ListModel { - id: myModel - ListElement { type: "Dog"; age: 8 } - ListElement { type: "Cat"; age: 5 } - } - - Component { - id: myDelegate - Text { text: type + ", " + age } - } - - ListView { - anchors.fill: parent - model: myModel - delegate: myDelegate - } -} -//! [document] diff --git a/doc/src/snippets/declarative/qml-documents/inline-component.qml b/doc/src/snippets/declarative/qml-documents/inline-component.qml deleted file mode 100644 index 7e01ca369b..0000000000 --- a/doc/src/snippets/declarative/qml-documents/inline-component.qml +++ /dev/null @@ -1,57 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -//! [document] -import QtQuick 2.0 - -Rectangle { - width: 240; height: 320; - - ListView { - anchors.fill: parent - model: contactModel - delegate: Component { - Text { - text: modelData.firstName + " " + modelData.lastName - } - } - } -} -//! [document] diff --git a/doc/src/snippets/declarative/qml-documents/inline-text-component.qml b/doc/src/snippets/declarative/qml-documents/inline-text-component.qml deleted file mode 100644 index 2405585b43..0000000000 --- a/doc/src/snippets/declarative/qml-documents/inline-text-component.qml +++ /dev/null @@ -1,55 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -//! [document] -import QtQuick 2.0 - -Rectangle { - width: 240; height: 320; - - ListView { - anchors.fill: parent - model: contactModel - delegate: Text { - text: modelData.firstName + " " + modelData.lastName - } - } -} -//! [document] diff --git a/doc/src/snippets/declarative/qml-documents/non-trivial.qml b/doc/src/snippets/declarative/qml-documents/non-trivial.qml deleted file mode 100644 index bd1b94a3cc..0000000000 --- a/doc/src/snippets/declarative/qml-documents/non-trivial.qml +++ /dev/null @@ -1,62 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -//! [document] -import QtQuick 2.0 - -Rectangle { - width: 240; height: 320; - - resources: [ - Component { - id: contactDelegate - Text { - text: modelData.firstName + " " + modelData.lastName - } - } - ] - - ListView { - anchors.fill: parent - model: contactModel - delegate: contactDelegate - } -} -//! [document] diff --git a/doc/src/snippets/declarative/qml-documents/qmldocuments.qml b/doc/src/snippets/declarative/qml-documents/qmldocuments.qml deleted file mode 100644 index cf60741f0c..0000000000 --- a/doc/src/snippets/declarative/qml-documents/qmldocuments.qml +++ /dev/null @@ -1,66 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -//! [document] -import QtQuick 2.0 - -Rectangle { - property alias text: textItem.text - - width: 100; height: 30 - border.width: 1 - radius: 5 - smooth: true - - gradient: Gradient { - GradientStop { position: 0.0; color: "darkGray" } - GradientStop { position: 0.5; color: "black" } - GradientStop { position: 1.0; color: "darkGray" } - } - - Text { - id: textItem - anchors.centerIn: parent - font.pointSize: 20 - color: "white" - } - -} -//! [document] diff --git a/doc/src/snippets/declarative/qml-intro/images/qt-logo.svg b/doc/src/snippets/declarative/qml-intro/images/qt-logo.svg deleted file mode 100644 index 8c018be6a2..0000000000 --- a/doc/src/snippets/declarative/qml-intro/images/qt-logo.svg +++ /dev/null @@ -1,104 +0,0 @@ - - - - - - image/svg+xml - - - - - - SVG generated by Lineform - - - - - - - - - - - - - - - diff --git a/doc/src/snippets/declarative/qtbinding/context-advanced/MyItem.qml b/doc/src/snippets/declarative/qtbinding/context-advanced/MyItem.qml deleted file mode 100644 index a9b873d4b0..0000000000 --- a/doc/src/snippets/declarative/qtbinding/context-advanced/MyItem.qml +++ /dev/null @@ -1,46 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -//![0] -// MyItem.qml -import QtQuick 2.0 - -Text { text: applicationData.getCurrentDateTime() } -//![0] - diff --git a/doc/src/snippets/declarative/qtbinding/context-advanced/applicationdata.h b/doc/src/snippets/declarative/qtbinding/context-advanced/applicationdata.h deleted file mode 100644 index fc5bbc6400..0000000000 --- a/doc/src/snippets/declarative/qtbinding/context-advanced/applicationdata.h +++ /dev/null @@ -1,52 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include -#include - -//![0] -class ApplicationData : public QObject -{ - Q_OBJECT -public: - Q_INVOKABLE QDateTime getCurrentDateTime() const { - return QDateTime::currentDateTime(); - } -}; -//![0] diff --git a/doc/src/snippets/declarative/qtbinding/context-advanced/connections.qml b/doc/src/snippets/declarative/qtbinding/context-advanced/connections.qml deleted file mode 100644 index 01f0cdefb9..0000000000 --- a/doc/src/snippets/declarative/qtbinding/context-advanced/connections.qml +++ /dev/null @@ -1,52 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -import QtQuick 2.0 - -//![0] -Text { - text: applicationData.getCurrentDateTime() - - Connections { - target: applicationData - onDataChanged: console.log("The application data changed!") - } -} -//![0] - diff --git a/doc/src/snippets/declarative/qtbinding/context-advanced/main.cpp b/doc/src/snippets/declarative/qtbinding/context-advanced/main.cpp deleted file mode 100644 index d7cfe6f3ef..0000000000 --- a/doc/src/snippets/declarative/qtbinding/context-advanced/main.cpp +++ /dev/null @@ -1,60 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include -#include - -#include "applicationdata.h" - -//![0] -int main(int argc, char *argv[]) { - QApplication app(argc, argv); - - QDeclarativeView view; - - ApplicationData data; - view.rootContext()->setContextProperty("applicationData", &data); - - view.setSource(QUrl::fromLocalFile("MyItem.qml")); - view.show(); - - return app.exec(); -} -//![0] - diff --git a/doc/src/snippets/declarative/qtbinding/context/MyItem.qml b/doc/src/snippets/declarative/qtbinding/context/MyItem.qml deleted file mode 100644 index 3abf2411f0..0000000000 --- a/doc/src/snippets/declarative/qtbinding/context/MyItem.qml +++ /dev/null @@ -1,45 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -//![0] -// MyItem.qml -import QtQuick 2.0 - -Text { text: currentDateTime } -//![0] diff --git a/doc/src/snippets/declarative/qtbinding/context/main.cpp b/doc/src/snippets/declarative/qtbinding/context/main.cpp deleted file mode 100644 index e0d9a83e64..0000000000 --- a/doc/src/snippets/declarative/qtbinding/context/main.cpp +++ /dev/null @@ -1,56 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include -#include - -int main(int argc, char *argv[]) -{ - QApplication app(argc, argv); - -//![0] -QDeclarativeView view; -view.rootContext()->setContextProperty("currentDateTime", QDateTime::currentDateTime()); -view.setSource(QUrl::fromLocalFile("MyItem.qml")); -view.show(); -//![0] - - return app.exec(); -} - diff --git a/doc/src/snippets/declarative/qtbinding/enums/imageviewer.h b/doc/src/snippets/declarative/qtbinding/enums/imageviewer.h deleted file mode 100644 index de9f2ecaab..0000000000 --- a/doc/src/snippets/declarative/qtbinding/enums/imageviewer.h +++ /dev/null @@ -1,68 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include -#include - -//![start] -class ImageViewer : public QDeclarativeItem -{ - Q_OBJECT - Q_ENUMS(Status) - Q_PROPERTY(Status status READ status NOTIFY statusChanged) -public: - enum Status { - Ready, - Loading, - Error - }; - - Status status() const; -//![start] - - ImageViewer(QDeclarativeItem *parent = 0); - -public slots: - void emitSignals(); - -//![end] -signals: - void statusChanged(); -}; -//![end] diff --git a/doc/src/snippets/declarative/qtbinding/enums/standalone.qml b/doc/src/snippets/declarative/qtbinding/enums/standalone.qml deleted file mode 100644 index 5641854175..0000000000 --- a/doc/src/snippets/declarative/qtbinding/enums/standalone.qml +++ /dev/null @@ -1,64 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -import MyLibrary 1.0 -import QtQuick 2.0 - -Item { - -//![0] -ImageViewer { - onStatusChanged: { - if (status == ImageViewer.Ready) - console.log("Image viewer is ready!") - } -} -//![0] - -//![1] -ImageViewer { - signal someOtherSignal(int statusValue) - - Component.onCompleted: { - someOtherSignal(ImageViewer.Loading) - } -} -//![1] - -} diff --git a/doc/src/snippets/declarative/qtbinding/functions-cpp/MyItem.qml b/doc/src/snippets/declarative/qtbinding/functions-cpp/MyItem.qml deleted file mode 100644 index e5ba588b25..0000000000 --- a/doc/src/snippets/declarative/qtbinding/functions-cpp/MyItem.qml +++ /dev/null @@ -1,55 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -//![0] -// MyItem.qml -import QtQuick 2.0 - -Item { - width: 100; height: 100 - - MouseArea { - anchors.fill: parent - onClicked: { - myObject.cppMethod("Hello from QML") - myObject.cppSlot(12345) - } - } -} -//![0] diff --git a/doc/src/snippets/declarative/qtbinding/functions-cpp/main.cpp b/doc/src/snippets/declarative/qtbinding/functions-cpp/main.cpp deleted file mode 100644 index 5e6c474a8f..0000000000 --- a/doc/src/snippets/declarative/qtbinding/functions-cpp/main.cpp +++ /dev/null @@ -1,59 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include -#include - -#include "myclass.h" - -//![0] -int main(int argc, char *argv[]) { - QApplication app(argc, argv); - - QDeclarativeView view; - MyClass myClass; - view.rootContext()->setContextProperty("myObject", &myClass); - - view.setSource(QUrl::fromLocalFile("MyItem.qml")); - view.show(); - - return app.exec(); -} -//![0] - diff --git a/doc/src/snippets/declarative/qtbinding/functions-cpp/myclass.h b/doc/src/snippets/declarative/qtbinding/functions-cpp/myclass.h deleted file mode 100644 index 8b6847ca99..0000000000 --- a/doc/src/snippets/declarative/qtbinding/functions-cpp/myclass.h +++ /dev/null @@ -1,57 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include -#include - -//![0] -class MyClass : public QObject -{ - Q_OBJECT -public: - Q_INVOKABLE void cppMethod(const QString &msg) { - qDebug() << "Called the C++ method with" << msg; - } - -public slots: - void cppSlot(int number) { - qDebug() << "Called the C++ slot with" << number; - } -}; -//![0] diff --git a/doc/src/snippets/declarative/qtbinding/functions-qml/MyItem.qml b/doc/src/snippets/declarative/qtbinding/functions-qml/MyItem.qml deleted file mode 100644 index a8b41d55a0..0000000000 --- a/doc/src/snippets/declarative/qtbinding/functions-qml/MyItem.qml +++ /dev/null @@ -1,50 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -//![0] -// MyItem.qml -import QtQuick 2.0 - -Item { - function myQmlFunction(msg) { - console.log("Got message:", msg) - return "some return value" - } -} -//![0] diff --git a/doc/src/snippets/declarative/qtbinding/functions-qml/main.cpp b/doc/src/snippets/declarative/qtbinding/functions-qml/main.cpp deleted file mode 100644 index ba72e9459a..0000000000 --- a/doc/src/snippets/declarative/qtbinding/functions-qml/main.cpp +++ /dev/null @@ -1,63 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include -#include - -int main(int argc, char *argv[]) -{ - QApplication app(argc, argv); - -//![0] -// main.cpp -QDeclarativeEngine engine; -QDeclarativeComponent component(&engine, "MyItem.qml"); -QObject *object = component.create(); - -QVariant returnedValue; -QVariant msg = "Hello from C++"; -QMetaObject::invokeMethod(object, "myQmlFunction", - Q_RETURN_ARG(QVariant, returnedValue), - Q_ARG(QVariant, msg)); - -qDebug() << "QML function returned:" << returnedValue.toString(); -delete object; -//![0] -} - diff --git a/doc/src/snippets/declarative/qtbinding/loading/MyItem.qml b/doc/src/snippets/declarative/qtbinding/loading/MyItem.qml deleted file mode 100644 index b496479c95..0000000000 --- a/doc/src/snippets/declarative/qtbinding/loading/MyItem.qml +++ /dev/null @@ -1,56 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -//![start] -import QtQuick 2.0 - -Item { - width: 100; height: 100 -//![start] - -//![child] - Rectangle { - anchors.fill: parent - objectName: "rect" - } -//![child] - -//![end] -} -//![end] diff --git a/doc/src/snippets/declarative/qtbinding/loading/main.cpp b/doc/src/snippets/declarative/qtbinding/loading/main.cpp deleted file mode 100644 index 839b7352a5..0000000000 --- a/doc/src/snippets/declarative/qtbinding/loading/main.cpp +++ /dev/null @@ -1,90 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include -#include - -static void withComponent() -{ -//![QDeclarativeComponent-a] -// Using QDeclarativeComponent -QDeclarativeEngine engine; -QDeclarativeComponent component(&engine, - QUrl::fromLocalFile("MyItem.qml")); -QObject *object = component.create(); -//![QDeclarativeComponent-a] -} - -int main(int argc, char *argv[]) -{ - QApplication app(argc, argv); - -//![QDeclarativeView] -// Using QDeclarativeView -QDeclarativeView view; -view.setSource(QUrl::fromLocalFile("MyItem.qml")); -view.show(); -QObject *object = view.rootObject(); -//![QDeclarativeView] - -//![properties] -object->setProperty("width", 500); -QDeclarativeProperty(object, "width").write(500); -//![properties] - -//![cast] -QDeclarativeItem *item = qobject_cast(object); -item->setWidth(500); -//![cast] - -//![findChild] -QObject *rect = object->findChild("rect"); -if (rect) - rect->setProperty("color", "red"); -//![findChild] - -//![QDeclarativeComponent-b] -delete object; -//![QDeclarativeComponent-b] - -withComponent(); - - return app.exec(); -} - diff --git a/doc/src/snippets/declarative/qtbinding/newelements/imageviewer.h b/doc/src/snippets/declarative/qtbinding/newelements/imageviewer.h deleted file mode 100644 index 7bbc243d83..0000000000 --- a/doc/src/snippets/declarative/qtbinding/newelements/imageviewer.h +++ /dev/null @@ -1,56 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -//![0] -#include -#include - -class ImageViewer : public QDeclarativeItem -{ - Q_OBJECT - Q_PROPERTY(QUrl image READ image WRITE setImage NOTIFY imageChanged) - -public: - void setImage(const QUrl &url); - QUrl image() const; - -signals: - void imageChanged(); -}; -//![0] diff --git a/doc/src/snippets/declarative/qtbinding/newelements/main.cpp b/doc/src/snippets/declarative/qtbinding/newelements/main.cpp deleted file mode 100644 index ead2fd1722..0000000000 --- a/doc/src/snippets/declarative/qtbinding/newelements/main.cpp +++ /dev/null @@ -1,62 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include -#include - -#include "imageviewer.h" - -void ImageViewer::setImage(const QUrl &url) {} -QUrl ImageViewer::image() const { return QUrl(); } - -int main(int argc, char *argv[]) -{ - QApplication app(argc, argv); - - //![register] - qmlRegisterType("MyLibrary", 1, 0, "ImageViewer"); - //![register] - - QDeclarativeView view; - view.setSource(QUrl::fromLocalFile("standalone.qml")); - view.show(); - - return app.exec(); -} - diff --git a/doc/src/snippets/declarative/qtbinding/newelements/standalone.qml b/doc/src/snippets/declarative/qtbinding/newelements/standalone.qml deleted file mode 100644 index d2a8926bd0..0000000000 --- a/doc/src/snippets/declarative/qtbinding/newelements/standalone.qml +++ /dev/null @@ -1,44 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -//![0] -import MyLibrary 1.0 - -ImageViewer { image: "smile.png" } -//![0] diff --git a/doc/src/snippets/declarative/qtbinding/properties-cpp/MyItem.qml b/doc/src/snippets/declarative/qtbinding/properties-cpp/MyItem.qml deleted file mode 100644 index f2a14d92a4..0000000000 --- a/doc/src/snippets/declarative/qtbinding/properties-cpp/MyItem.qml +++ /dev/null @@ -1,54 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -//![0] -// MyItem.qml -import QtQuick 2.0 - -Rectangle { - width: 100; height: 100 - color: applicationData.backgroundColor - - MouseArea { - anchors.fill: parent - onClicked: applicationData.backgroundColor = "red" - } -} -//![0] - diff --git a/doc/src/snippets/declarative/qtbinding/properties-cpp/applicationdata.h b/doc/src/snippets/declarative/qtbinding/properties-cpp/applicationdata.h deleted file mode 100644 index b558e8528f..0000000000 --- a/doc/src/snippets/declarative/qtbinding/properties-cpp/applicationdata.h +++ /dev/null @@ -1,71 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include -#include - -//![0] -class ApplicationData : public QObject -{ - Q_OBJECT - Q_PROPERTY(QColor backgroundColor - READ backgroundColor - WRITE setBackgroundColor - NOTIFY backgroundColorChanged) - -public: - void setBackgroundColor(const QColor &c) { - if (c != m_color) { - m_color = c; - emit backgroundColorChanged(); - } - } - - QColor backgroundColor() const { - return m_color; - } - -signals: - void backgroundColorChanged(); - -private: - QColor m_color; -}; -//![0] diff --git a/doc/src/snippets/declarative/qtbinding/properties-qml/MyItem.qml b/doc/src/snippets/declarative/qtbinding/properties-qml/MyItem.qml deleted file mode 100644 index 87015eac24..0000000000 --- a/doc/src/snippets/declarative/qtbinding/properties-qml/MyItem.qml +++ /dev/null @@ -1,47 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -//![0] -// MyItem.qml -import QtQuick 2.0 - -Item { - property int someNumber: 100 -} -//![0] diff --git a/doc/src/snippets/declarative/qtbinding/properties-qml/main.cpp b/doc/src/snippets/declarative/qtbinding/properties-qml/main.cpp deleted file mode 100644 index 91347ee70f..0000000000 --- a/doc/src/snippets/declarative/qtbinding/properties-qml/main.cpp +++ /dev/null @@ -1,61 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include -#include - -int main(int argc, char *argv[]) -{ - QApplication app(argc, argv); - -//![0] -QDeclarativeEngine engine; -QDeclarativeComponent component(&engine, "MyItem.qml"); -QObject *object = component.create(); - -qDebug() << "Property value:" << QDeclarativeProperty::read(object, "someNumber").toInt(); -QDeclarativeProperty::write(object, "someNumber", 5000); - -qDebug() << "Property value:" << object->property("someNumber").toInt(); -object->setProperty("someNumber", 100); -//![0] - - return app.exec(); -} - diff --git a/doc/src/snippets/declarative/qtbinding/resources/example.qrc b/doc/src/snippets/declarative/qtbinding/resources/example.qrc deleted file mode 100644 index 5e4941512b..0000000000 --- a/doc/src/snippets/declarative/qtbinding/resources/example.qrc +++ /dev/null @@ -1,10 +0,0 @@ - - - - - main.qml - images/background.png - - - - diff --git a/doc/src/snippets/declarative/qtbinding/resources/main.cpp b/doc/src/snippets/declarative/qtbinding/resources/main.cpp deleted file mode 100644 index 0ec1189eeb..0000000000 --- a/doc/src/snippets/declarative/qtbinding/resources/main.cpp +++ /dev/null @@ -1,57 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include -#include -#include - -//![0] -int main(int argc, char *argv[]) -{ - QApplication app(argc, argv); - - QDeclarativeView view; - view.setSource(QUrl("qrc:/main.qml")); - view.show(); - - return app.exec(); -} -//![0] - diff --git a/doc/src/snippets/declarative/qtbinding/resources/main.qml b/doc/src/snippets/declarative/qtbinding/resources/main.qml deleted file mode 100644 index 670d1a5309..0000000000 --- a/doc/src/snippets/declarative/qtbinding/resources/main.qml +++ /dev/null @@ -1,46 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -//![0] -// main.qml -import QtQuick 2.0 - -Image { source: "images/background.png" } -//![0] diff --git a/doc/src/snippets/declarative/qtbinding/resources/resources.pro b/doc/src/snippets/declarative/qtbinding/resources/resources.pro deleted file mode 100644 index cc01ee126f..0000000000 --- a/doc/src/snippets/declarative/qtbinding/resources/resources.pro +++ /dev/null @@ -1,4 +0,0 @@ -QT += declarative - -SOURCES += main.cpp -RESOURCES += example.qrc diff --git a/doc/src/snippets/declarative/qtbinding/signals-cpp/MyItem.qml b/doc/src/snippets/declarative/qtbinding/signals-cpp/MyItem.qml deleted file mode 100644 index 17df7704c5..0000000000 --- a/doc/src/snippets/declarative/qtbinding/signals-cpp/MyItem.qml +++ /dev/null @@ -1,50 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -//![0] -// MyItem.qml -import QtQuick 2.0 - -Item { - Connections { - target: imageViewer - onImageChanged: console.log("Image has changed!") - } -} -//![0] diff --git a/doc/src/snippets/declarative/qtbinding/signals-cpp/imageviewer.h b/doc/src/snippets/declarative/qtbinding/signals-cpp/imageviewer.h deleted file mode 100644 index a066447cfb..0000000000 --- a/doc/src/snippets/declarative/qtbinding/signals-cpp/imageviewer.h +++ /dev/null @@ -1,64 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include -#include - -//![start] -class ImageViewer : public QDeclarativeItem -{ - Q_OBJECT - Q_PROPERTY(QUrl image READ image WRITE setImage NOTIFY imageChanged) -public: -//![start] - ImageViewer(QDeclarativeItem *item = 0); - - void setImage(const QUrl &url) {} - QUrl image() const { return QUrl(); } - -public slots: - void emitSignals(); - -//![end] -signals: - void imageChanged(); - void loadingError(const QString &errorMsg); -}; -//![end] - diff --git a/doc/src/snippets/declarative/qtbinding/signals-cpp/main.cpp b/doc/src/snippets/declarative/qtbinding/signals-cpp/main.cpp deleted file mode 100644 index f3ea3f26df..0000000000 --- a/doc/src/snippets/declarative/qtbinding/signals-cpp/main.cpp +++ /dev/null @@ -1,81 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include -#include - -#include "imageviewer.h" - - -ImageViewer::ImageViewer(QDeclarativeItem *item) - : QDeclarativeItem(item) -{ - QTimer::singleShot(0, this, SLOT(emitSignals())); -} - -void ImageViewer::emitSignals() -{ - emit imageChanged(); - emit loadingError("some error message"); -} - -int main(int argc, char *argv[]) -{ - QApplication app(argc, argv); - - qmlRegisterType("MyLibrary", 1, 0, "ImageViewer"); - - QDeclarativeView standalone; - standalone.setSource(QUrl::fromLocalFile("standalone.qml")); - standalone.show(); - -//![connections] -ImageViewer viewer; - -QDeclarativeView view; -view.rootContext()->setContextProperty("imageViewer", &viewer); - -view.setSource(QUrl::fromLocalFile("MyItem.qml")); -view.show(); -//![connections] - - return app.exec(); -} - - diff --git a/doc/src/snippets/declarative/qtbinding/signals-cpp/standalone.qml b/doc/src/snippets/declarative/qtbinding/signals-cpp/standalone.qml deleted file mode 100644 index 33afc1f39c..0000000000 --- a/doc/src/snippets/declarative/qtbinding/signals-cpp/standalone.qml +++ /dev/null @@ -1,48 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -import MyLibrary 1.0 - -//![0] -ImageViewer { - onImageChanged: console.log("Image changed!") - onLoadingError: console.log("Image failed to load:", errorMsg) -} -//![0] - diff --git a/doc/src/snippets/declarative/qtbinding/signals-qml/MyItem.qml b/doc/src/snippets/declarative/qtbinding/signals-qml/MyItem.qml deleted file mode 100644 index 9269b51863..0000000000 --- a/doc/src/snippets/declarative/qtbinding/signals-qml/MyItem.qml +++ /dev/null @@ -1,55 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -//![0] -// MyItem.qml -import QtQuick 2.0 - -Item { - id: item - width: 100; height: 100 - - signal qmlSignal(string msg) - - MouseArea { - anchors.fill: parent - onClicked: item.qmlSignal("Hello from QML") - } -} -//![0] diff --git a/doc/src/snippets/declarative/qtbinding/signals-qml/main.cpp b/doc/src/snippets/declarative/qtbinding/signals-qml/main.cpp deleted file mode 100644 index 084d5f0e4b..0000000000 --- a/doc/src/snippets/declarative/qtbinding/signals-qml/main.cpp +++ /dev/null @@ -1,59 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include -#include - -//![0] -int main(int argc, char *argv[]) { - QApplication app(argc, argv); - - QDeclarativeView view(QUrl::fromLocalFile("MyItem.qml")); - QObject *item = view.rootObject(); - - MyClass myClass; - QObject::connect(item, SIGNAL(qmlSignal(QString)), - &myClass, SLOT(cppSlot(QString))); - - view.show(); - return app.exec(); -} -//![0] - -#include "moc_main.cpp" diff --git a/doc/src/snippets/declarative/qtbinding/signals-qml/myclass.h b/doc/src/snippets/declarative/qtbinding/signals-qml/myclass.h deleted file mode 100644 index 6275de6b2c..0000000000 --- a/doc/src/snippets/declarative/qtbinding/signals-qml/myclass.h +++ /dev/null @@ -1,51 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include -#include -//![0] -class MyClass : public QObject -{ - Q_OBJECT -public slots: - void cppSlot(const QString &msg) { - qDebug() << "Called the C++ slot with message:" << msg; - } -}; -//![0] diff --git a/doc/src/snippets/declarative/qtbinding/variantlistmap/MyItem.qml b/doc/src/snippets/declarative/qtbinding/variantlistmap/MyItem.qml deleted file mode 100644 index ff4be87795..0000000000 --- a/doc/src/snippets/declarative/qtbinding/variantlistmap/MyItem.qml +++ /dev/null @@ -1,54 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -import QtQuick 2.0 - -//![0] -// MyItem.qml -Item { - function readValues(anArray, anObject) { - for (var i=0; i -#include - -int main(int argc, char *argv[]) { - QApplication app(argc, argv); - -//![0] -// C++ -QDeclarativeView view(QUrl::fromLocalFile("MyItem.qml")); - -QVariantList list; -list << 10 << Qt::green << "bottles"; - -QVariantMap map; -map.insert("language", "QML"); -map.insert("released", QDate(2010, 9, 21)); - -QMetaObject::invokeMethod(view.rootObject(), "readValues", - Q_ARG(QVariant, QVariant::fromValue(list)), - Q_ARG(QVariant, QVariant::fromValue(map))); -//![0] - - view.setSource(QUrl::fromLocalFile("MyItem.qml")); - view.show(); - - return app.exec(); -} - diff --git a/doc/src/snippets/declarative/qtobject.qml b/doc/src/snippets/declarative/qtobject.qml deleted file mode 100644 index 04811b6316..0000000000 --- a/doc/src/snippets/declarative/qtobject.qml +++ /dev/null @@ -1,54 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -//![0] -import QtQuick 2.0 - -Item { - QtObject { - id: attributes - property string name - property int size - property variant attributes - } - - Text { text: attributes.name } -} -//![0] - diff --git a/doc/src/snippets/declarative/rectangle/rect-border-width.qml b/doc/src/snippets/declarative/rectangle/rect-border-width.qml deleted file mode 100644 index 6dd4dbe739..0000000000 --- a/doc/src/snippets/declarative/rectangle/rect-border-width.qml +++ /dev/null @@ -1,59 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -//![0] -Rectangle { - width: 100; height: 100 - color: "lightblue" - - Rectangle { - anchors.fill: parent - anchors.margins: 10 - clip: true - - Rectangle { - anchors.fill: parent - border.width: 1 - } - } -} -//![0] diff --git a/doc/src/snippets/declarative/rectangle/rectangle-colors.qml b/doc/src/snippets/declarative/rectangle/rectangle-colors.qml deleted file mode 100644 index 70f7a203f4..0000000000 --- a/doc/src/snippets/declarative/rectangle/rectangle-colors.qml +++ /dev/null @@ -1,62 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -Item { - width: 100; height: 200 - -Item { - x: 10; y: 10 - width: 80; height: 180 - -//! [rectangles] -Rectangle { - color: "#00B000" - width: 80; height: 80 -} - -Rectangle { - color: "steelblue" - y: 100; width: 80; height: 80 -} -//! [rectangles] -} -} diff --git a/doc/src/snippets/declarative/rectangle/rectangle-gradient.qml b/doc/src/snippets/declarative/rectangle/rectangle-gradient.qml deleted file mode 100644 index e8146a6467..0000000000 --- a/doc/src/snippets/declarative/rectangle/rectangle-gradient.qml +++ /dev/null @@ -1,74 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -Item { - width: 100; height: 300 - -Item { - x: 10; y: 10 - width: 80; height: 280 - -//! [rectangles] -Rectangle { - y: 0; width: 80; height: 80 - color: "lightsteelblue" -} - -Rectangle { - y: 100; width: 80; height: 80 - gradient: Gradient { - GradientStop { position: 0.0; color: "lightsteelblue" } - GradientStop { position: 1.0; color: "blue" } - } -} - -Rectangle { - y: 200; width: 80; height: 80 - rotation: 90 - gradient: Gradient { - GradientStop { position: 0.0; color: "lightsteelblue" } - GradientStop { position: 1.0; color: "blue" } - } -} -//! [rectangles] -} -} diff --git a/doc/src/snippets/declarative/rectangle/rectangle.qml b/doc/src/snippets/declarative/rectangle/rectangle.qml deleted file mode 100644 index c315a27da0..0000000000 --- a/doc/src/snippets/declarative/rectangle/rectangle.qml +++ /dev/null @@ -1,52 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -//! [document] -import QtQuick 2.0 - -Rectangle { - width: 100 - height: 100 - color: "red" - border.color: "black" - border.width: 5 - radius: 10 -} -//! [document] diff --git a/doc/src/snippets/declarative/repeaters/repeater-grid-index.qml b/doc/src/snippets/declarative/repeaters/repeater-grid-index.qml deleted file mode 100644 index 0f2b770d82..0000000000 --- a/doc/src/snippets/declarative/repeaters/repeater-grid-index.qml +++ /dev/null @@ -1,61 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -//! [document] -import QtQuick 2.0 - -Rectangle { - width: 400; height: 400; color: "black" - - Grid { - x: 5; y: 5 - rows: 5; columns: 5; spacing: 10 - - Repeater { model: 24 - Rectangle { width: 70; height: 70 - color: "lightgreen" - - Text { text: index - font.pointSize: 30 - anchors.centerIn: parent } } - } - } -} -//! [document] diff --git a/doc/src/snippets/declarative/repeaters/repeater.qml b/doc/src/snippets/declarative/repeaters/repeater.qml deleted file mode 100644 index 856b038a04..0000000000 --- a/doc/src/snippets/declarative/repeaters/repeater.qml +++ /dev/null @@ -1,89 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -//! [import] -import QtQuick 2.0 -//! [import] - -Row { - -//! [simple] -Row { - Repeater { - model: 3 - Rectangle { - width: 100; height: 40 - border.width: 1 - color: "yellow" - } - } -} -//! [simple] - -//! [index] -Column { - Repeater { - model: 10 - Text { text: "I'm item " + index } - } -} -//! [index] - -//! [modeldata] -Column { - Repeater { - model: ["apples", "oranges", "pears"] - Text { text: "Data: " + modelData } - } -} -//! [modeldata] - -//! [layout] -Row { - Rectangle { width: 10; height: 20; color: "red" } - Repeater { - model: 10 - Rectangle { width: 20; height: 20; radius: 10; color: "green" } - } - Rectangle { width: 10; height: 20; color: "blue" } -} -//! [layout] - -} diff --git a/doc/src/snippets/declarative/reusablecomponents/Button.qml b/doc/src/snippets/declarative/reusablecomponents/Button.qml deleted file mode 100644 index cedc782f75..0000000000 --- a/doc/src/snippets/declarative/reusablecomponents/Button.qml +++ /dev/null @@ -1,87 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -//! [document] -//contents of Button.qml -import QtQuick 2.0 - -//! [parent begin] -Rectangle { -//! [parent begin] - id: button -//! [properties] - width: 145; height: 60 - color: "blue" - smooth: true; radius: 9 - property alias text: label.text -//! [properties] -//! [object alias] - property alias label: label -//! [object alias] - border {color: "#B9C5D0"; width: 1} - - gradient: Gradient { - GradientStop {color: "#CFF7FF"; position: 0.0} - GradientStop {color: "#99C0E5"; position: 0.57} - GradientStop {color: "#719FCB"; position: 0.9} - } -//![text] - Text { - id: label - anchors.centerIn: parent - text: "Click Me!" - font.pointSize: 12 - color: "blue" - } -//![text] - MouseArea { - anchors.fill: parent - onClicked: console.log(text + " clicked") - } -//! [parent end] -} -//! [parent end] - -//! [document] - -//! [ellipses] - //... -//! [ellipses] - - diff --git a/doc/src/snippets/declarative/reusablecomponents/application.qml b/doc/src/snippets/declarative/reusablecomponents/application.qml deleted file mode 100644 index 42428ce25e..0000000000 --- a/doc/src/snippets/declarative/reusablecomponents/application.qml +++ /dev/null @@ -1,58 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -//! [document] -import QtQuick 2.0 - -Rectangle { - width: 175; height: 350 - color: "lightgrey" - - Column { - anchors.centerIn: parent - spacing: 15 - Button {} - Button {text: "Me Too!"} - Button {text: "Me Three!"} -//! [grouped property] - Button {label.color: "green"} -//! [grouped property] - } -} -//! [document] diff --git a/doc/src/snippets/declarative/reusablecomponents/component.qml b/doc/src/snippets/declarative/reusablecomponents/component.qml deleted file mode 100644 index 9a60468d73..0000000000 --- a/doc/src/snippets/declarative/reusablecomponents/component.qml +++ /dev/null @@ -1,77 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -//! [document] -import QtQuick 2.0 - -//! [parent begin] -Rectangle { -//! [parent begin] - id: screen - width: 175; height: 175 - color: "lightgrey" - -//! [define inline component] - Component { - id: inlinecomponent - Rectangle { - id: display - width: 50; height: 50 - color: "blue" - } - } -//! [define inline component] -//! [create inline component] - MouseArea { - anchors.fill: parent - onClicked: { - inlinecomponent.createObject(parent) - - var second = inlinecomponent.createObject(parent) - - var third = inlinecomponent.createObject(parent) - third.x = second.width + 10 - third.color = "red" - } - } -//! [create inline component] -//! [parent end] -} -//! [parent end] -//! [document] diff --git a/doc/src/snippets/declarative/reusablecomponents/focusbutton.qml b/doc/src/snippets/declarative/reusablecomponents/focusbutton.qml deleted file mode 100644 index 34fc6294e2..0000000000 --- a/doc/src/snippets/declarative/reusablecomponents/focusbutton.qml +++ /dev/null @@ -1,98 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -//! [document] -//contents of focusbutton.qml -import QtQuick 2.0 - -//! [parent begin] -FocusScope { -//! [parent begin] - - //! [expose visuals] - //FocusScope needs to bind to visual properties of the children - property alias color: button.color - x: button.x; y: button.y - width: button.width; height: button.height - //! [expose visuals] - - //! [rectangle begin] - Rectangle { - //! [rectangle begin] - id: button - //! [properties] - width: 145; height: 60 - color: "blue" - smooth: true; radius: 9 - property alias text: label.text - //! [properties] - border {color: "#B9C5D0"; width: 1} - - gradient: Gradient { - GradientStop {color: "#CFF7FF"; position: 0.0} - GradientStop {color: "#99C0E5"; position: 0.57} - GradientStop {color: "#719FCB"; position: 0.9} - } - - Text { - id: label - anchors.centerIn: parent - text: "Click Me!" - font.pointSize: 12 - color: "blue" - } - - MouseArea { - anchors.fill: parent - onClicked: console.log(text + " clicked") - } - //! [rectangle end] - } - //! [rectangle end] -//! [parent end] -} -//! [parent end] - -//! [document] - -//! [ellipses] - //... -//! [ellipses] - - diff --git a/doc/src/snippets/declarative/reusablecomponents/qmldir b/doc/src/snippets/declarative/reusablecomponents/qmldir deleted file mode 100644 index 253732de01..0000000000 --- a/doc/src/snippets/declarative/reusablecomponents/qmldir +++ /dev/null @@ -1,4 +0,0 @@ -//! [document] -Button ./Button.qml -FocusButton ./focusbutton.qml -//! [document] diff --git a/doc/src/snippets/declarative/righttoleft.qml b/doc/src/snippets/declarative/righttoleft.qml deleted file mode 100644 index 0566be2f67..0000000000 --- a/doc/src/snippets/declarative/righttoleft.qml +++ /dev/null @@ -1,149 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 -import "righttoleft" - -Column { - width: 200 -//![0] -// automatically aligned to the left -Text { - text: "Phone" - width: 200 -} - -// automatically aligned to the right -Text { - text: "خامل" - width: 200 -} - -// aligned to the left -Text { - text: "خامل" - horizontalAlignment: Text.AlignLeft - width: 200 -} - -// aligned to the right -Text { - text: "خامل" - horizontalAlignment: Text.AlignLeft - LayoutMirroring.enabled: true - width: 200 -} -//![0] - -//![1] -// by default child items are positioned from left to right -Row { - Child {} - Child {} -} - -// position child items from right to left -Row { - layoutDirection: Qt.RightToLeft - Child {} - Child {} -} - -// position child items from left to right -Row { - LayoutMirroring.enabled: true - layoutDirection: Qt.RightToLeft - Child {} - Child {} -} -//![1] - -//![2] -Item { - height: 50; width: 150 - - LayoutMirroring.enabled: true - anchors.left: parent.left // anchor left becomes right - - Row { - // items flow from left to right (as per default) - Child {} - Child {} - Child {} - } -} -//![2] - -//![3] -Item { - height: 50; width: 150 - - LayoutMirroring.enabled: true - LayoutMirroring.childrenInherit: true - anchors.left: parent.left // anchor left becomes right - - Row { - // setting childrenInherit in the parent causes these - // items to flow from right to left instead - Child {} - Child {} - Child {} - } -} -//![3] - -//![4] -Rectangle { - color: "black" - height: 50; width: 50 - x: mirror(10) - function mirror(value) { - return LayoutMirroring.enabled ? (parent.width - width - value) : value; - } -} -//![4] - -//![5] -Image { - source: "arrow.png" - mirror: true -} -//![5] -} diff --git a/doc/src/snippets/declarative/righttoleft/Child.qml b/doc/src/snippets/declarative/righttoleft/Child.qml deleted file mode 100644 index 50068540cb..0000000000 --- a/doc/src/snippets/declarative/righttoleft/Child.qml +++ /dev/null @@ -1,51 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -Rectangle { - width: 50; height: 50 - color: "black" - Text { - color: "white" - text: String.fromCharCode(65 + Math.floor(26*Math.random())) - anchors.centerIn: parent - } -} diff --git a/doc/src/snippets/declarative/rotation.qml b/doc/src/snippets/declarative/rotation.qml deleted file mode 100644 index c7f9df3a9b..0000000000 --- a/doc/src/snippets/declarative/rotation.qml +++ /dev/null @@ -1,69 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -//! [0] -import QtQuick 2.0 - -Row { - x: 10; y: 10 - spacing: 10 - - Image { source: "pics/qt.png" } - Image { - source: "pics/qt.png" - transform: Rotation { origin.x: 30; origin.y: 30; axis { x: 0; y: 1; z: 0 } angle: 18 } - smooth: true - } - Image { - source: "pics/qt.png" - transform: Rotation { origin.x: 30; origin.y: 30; axis { x: 0; y: 1; z: 0 } angle: 36 } - smooth: true - } - Image { - source: "pics/qt.png" - transform: Rotation { origin.x: 30; origin.y: 30; axis { x: 0; y: 1; z: 0 } angle: 54 } - smooth: true - } - Image { - source: "pics/qt.png" - transform: Rotation { origin.x: 30; origin.y: 30; axis { x: 0; y: 1; z: 0 } angle: 72 } - smooth: true - } -} -//! [0] diff --git a/doc/src/snippets/declarative/rotationanimation.qml b/doc/src/snippets/declarative/rotationanimation.qml deleted file mode 100644 index caa1ce8207..0000000000 --- a/doc/src/snippets/declarative/rotationanimation.qml +++ /dev/null @@ -1,66 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -//![0] -import QtQuick 2.0 - -Item { - width: 300; height: 300 - - Rectangle { - id: rect - width: 150; height: 100; anchors.centerIn: parent - color: "red" - smooth: true - - states: State { - name: "rotated" - PropertyChanges { target: rect; rotation: 180 } - } - - transitions: Transition { - RotationAnimation { duration: 1000; direction: RotationAnimation.Counterclockwise } - } - } - - MouseArea { anchors.fill: parent; onClicked: rect.state = "rotated" } -} -//![0] - diff --git a/doc/src/snippets/declarative/row.qml b/doc/src/snippets/declarative/row.qml deleted file mode 100644 index 3e505717d6..0000000000 --- a/doc/src/snippets/declarative/row.qml +++ /dev/null @@ -1,62 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -//! [document] -import QtQuick 2.0 - -Rectangle { - width: 320; height: 110 - color: "#c0c0c0" - - Row { - anchors.horizontalCenter: parent.horizontalCenter - anchors.verticalCenter: parent.verticalCenter - - spacing: 5 - - Rectangle { width: 100; height: 100; radius: 20.0 - color: "#024c1c" } - Rectangle { width: 100; height: 100; radius: 20.0 - color: "#42a51c" } - Rectangle { width: 100; height: 100; radius: 20.0 - color: "white" } - } -} -//! [document] diff --git a/doc/src/snippets/declarative/row/row.qml b/doc/src/snippets/declarative/row/row.qml deleted file mode 100644 index 465baa577b..0000000000 --- a/doc/src/snippets/declarative/row/row.qml +++ /dev/null @@ -1,50 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -//! [document] -import QtQuick 2.0 - -Row { - spacing: 2 - Rectangle { color: "red"; width: 50; height: 50 } - Rectangle { color: "green"; width: 20; height: 50 } - Rectangle { color: "blue"; width: 50; height: 20 } -} -//! [document] diff --git a/doc/src/snippets/declarative/script.js b/doc/src/snippets/declarative/script.js deleted file mode 100644 index f55dee3507..0000000000 --- a/doc/src/snippets/declarative/script.js +++ /dev/null @@ -1,4 +0,0 @@ -WorkerScript.onMessage = function(message) { - // ... long-running operations and calculations are done here - WorkerScript.sendMessage({ 'reply': 'Mouse is at ' + message.x + ',' + message.y }) -} diff --git a/doc/src/snippets/declarative/sequentialanimation.qml b/doc/src/snippets/declarative/sequentialanimation.qml deleted file mode 100644 index 73923e4ea0..0000000000 --- a/doc/src/snippets/declarative/sequentialanimation.qml +++ /dev/null @@ -1,56 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -//![0] -import QtQuick 2.0 - -Rectangle { - id: rect - width: 100; height: 100 - color: "red" - - SequentialAnimation { - running: true - NumberAnimation { target: rect; property: "x"; to: 50; duration: 1000 } - NumberAnimation { target: rect; property: "y"; to: 50; duration: 1000 } - } -} -//![0] - diff --git a/doc/src/snippets/declarative/smoothedanimation.qml b/doc/src/snippets/declarative/smoothedanimation.qml deleted file mode 100644 index ba6f505976..0000000000 --- a/doc/src/snippets/declarative/smoothedanimation.qml +++ /dev/null @@ -1,69 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -//![0] -import QtQuick 2.0 - -Rectangle { - width: 800; height: 600 - color: "blue" - - Rectangle { - width: 60; height: 60 - x: rect1.x - 5; y: rect1.y - 5 - color: "green" - - Behavior on x { SmoothedAnimation { velocity: 200 } } - Behavior on y { SmoothedAnimation { velocity: 200 } } - } - - Rectangle { - id: rect1 - width: 50; height: 50 - color: "red" - } - - focus: true - Keys.onRightPressed: rect1.x = rect1.x + 100 - Keys.onLeftPressed: rect1.x = rect1.x - 100 - Keys.onUpPressed: rect1.y = rect1.y - 100 - Keys.onDownPressed: rect1.y = rect1.y + 100 -} -//![0] diff --git a/doc/src/snippets/declarative/springanimation.qml b/doc/src/snippets/declarative/springanimation.qml deleted file mode 100644 index e04c483405..0000000000 --- a/doc/src/snippets/declarative/springanimation.qml +++ /dev/null @@ -1,65 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -//![0] -import QtQuick 2.0 - -Item { - width: 300; height: 300 - - Rectangle { - id: rect - width: 50; height: 50 - color: "red" - - Behavior on x { SpringAnimation { spring: 2; damping: 0.2 } } - Behavior on y { SpringAnimation { spring: 2; damping: 0.2 } } - } - - MouseArea { - anchors.fill: parent - onClicked: { - rect.x = mouse.x - rect.width/2 - rect.y = mouse.y - rect.height/2 - } - } -} -//![0] - diff --git a/doc/src/snippets/declarative/state-when.qml b/doc/src/snippets/declarative/state-when.qml deleted file mode 100644 index de9fb39cef..0000000000 --- a/doc/src/snippets/declarative/state-when.qml +++ /dev/null @@ -1,54 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -import QtQuick 2.0 -//![0] -Rectangle { - id: myRect - width: 100; height: 100 - color: "red" - - MouseArea { id: mouseArea; anchors.fill: parent } - - states: State { - name: "hidden"; when: mouseArea.pressed - PropertyChanges { target: myRect; opacity: 0 } - } -} -//![0] diff --git a/doc/src/snippets/declarative/state.qml b/doc/src/snippets/declarative/state.qml deleted file mode 100644 index 5948cba770..0000000000 --- a/doc/src/snippets/declarative/state.qml +++ /dev/null @@ -1,61 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -//![0] -import QtQuick 2.0 - -Rectangle { - id: myRect - width: 100; height: 100 - color: "black" - - MouseArea { - id: mouseArea - anchors.fill: parent - onClicked: myRect.state == 'clicked' ? myRect.state = "" : myRect.state = 'clicked'; - } - - states: [ - State { - name: "clicked" - PropertyChanges { target: myRect; color: "red" } - } - ] -} -//![0] diff --git a/doc/src/snippets/declarative/states.qml b/doc/src/snippets/declarative/states.qml deleted file mode 100644 index aeb805f38e..0000000000 --- a/doc/src/snippets/declarative/states.qml +++ /dev/null @@ -1,121 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -//![document] -import QtQuick 2.0 - -//![parent begin] -Rectangle { -//![parent begin] - - id: screen - width: 400; height: 500 - - -Rectangle { - id: flag -} -Column { - spacing: 15 -//![signal states] -Rectangle { - id: signal - width: 200; height: 200 - state: "NORMAL" - - states: [ - State { - name: "NORMAL" - PropertyChanges { target: signal; color: "green"} - PropertyChanges { target: flag; state: "FLAG_DOWN"} - }, - State { - name: "CRITICAL" - PropertyChanges { target: signal; color: "red"} - PropertyChanges { target: flag; state: "FLAG_UP"} - } - ] -} -//![signal states] - -//![switch states] -Rectangle { - id: signalswitch - width: 75; height: 75 - color: "blue" - - MouseArea { - anchors.fill: parent - onClicked: { - if (signal.state == "NORMAL") - signal.state = "CRITICAL" - else - signal.state = "NORMAL" - } - } -} -//![switch states] - -//![when property] -Rectangle { - id: bell - width: 75; height: 75 - color: "yellow" - - states: State { - name: "RINGING" - when: (signal.state == "CRITICAL") - PropertyChanges {target: speaker; play: "RING!"} - } -} -//![when property] - -Text { - id: speaker - property alias play: speaker.text - text: "NORMAL" -} - -} // end of row - -//![parent end] -} -//![parent end] - -//![document] diff --git a/doc/src/snippets/declarative/states/statechangescript.qml b/doc/src/snippets/declarative/states/statechangescript.qml deleted file mode 100644 index 262938fc9c..0000000000 --- a/doc/src/snippets/declarative/states/statechangescript.qml +++ /dev/null @@ -1,63 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -Item { -//! [state and transition] -State { - name: "state1" - StateChangeScript { - name: "myScript" - script: doStateStuff(); - } - // ... -} -// ... -Transition { - to: "state1" - SequentialAnimation { - NumberAnimation { /* ... */ } - ScriptAction { scriptName: "myScript" } - NumberAnimation { /* ... */ } - } -} -//! [state and transition] -} diff --git a/doc/src/snippets/declarative/systempalette.qml b/doc/src/snippets/declarative/systempalette.qml deleted file mode 100644 index 4cb42dee93..0000000000 --- a/doc/src/snippets/declarative/systempalette.qml +++ /dev/null @@ -1,54 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -//![0] -import QtQuick 2.0 - -Rectangle { - SystemPalette { id: myPalette; colorGroup: SystemPalette.Active } - - width: 640; height: 480 - color: myPalette.window - - Text { - anchors.fill: parent - text: "Hello!"; color: myPalette.windowText - } -} -//![0] diff --git a/doc/src/snippets/declarative/text/onLinkActivated.qml b/doc/src/snippets/declarative/text/onLinkActivated.qml deleted file mode 100644 index 71545ad3e2..0000000000 --- a/doc/src/snippets/declarative/text/onLinkActivated.qml +++ /dev/null @@ -1,54 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -import QtQuick 2.0 - -Rectangle { - width: 700; height: 400 - -//![0] - Text { - textFormat: Text.RichText - text: "The main website is at Nokia Qt DF." - onLinkActivated: console.log(link + " link activated") - } -//![0] - -} - diff --git a/doc/src/snippets/declarative/texthandling.qml b/doc/src/snippets/declarative/texthandling.qml deleted file mode 100644 index 03e5011202..0000000000 --- a/doc/src/snippets/declarative/texthandling.qml +++ /dev/null @@ -1,89 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -//! [document] -import QtQuick 2.0 - - -//! [parent begin] -Rectangle { -//! [parent begin] - width: 300; height: 300 - id: screen - -Column { - anchors.centerIn:parent - -//! [int validator] -Column { - spacing: 10 - - Text { - text: "Enter a value from 0 to 2000" - } - TextInput { - focus: true - validator: IntValidator { bottom:0; top: 2000} - } -} -//! [int validator] - -//! [regexp validator] -Column { - spacing: 10 - - Text { - text: "Which basket?" - } - TextInput { - focus: true - validator: RegExpValidator { regExp: /fruit basket/ } - } -} -//! [regexp validator] - -//end of column -} - -//! [parent end] -} -//! [parent end] - -//! [document] - diff --git a/doc/src/snippets/declarative/transition-from-to-modified.qml b/doc/src/snippets/declarative/transition-from-to-modified.qml deleted file mode 100644 index 184e95afe2..0000000000 --- a/doc/src/snippets/declarative/transition-from-to-modified.qml +++ /dev/null @@ -1,60 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -import QtQuick 2.0 - -Rectangle { - id: rect - width: 100; height: 100 - color: "red" - - MouseArea { id: mouseArea; anchors.fill: parent } - - states: State { - name: "brighter"; when: mouseArea.pressed - PropertyChanges { target: rect; color: "yellow" } - } - - //! [modified transition] - transitions: Transition { - to: "brighter" - ColorAnimation { duration: 1000 } - } - //! [modified transition] -} diff --git a/doc/src/snippets/declarative/transition-from-to.qml b/doc/src/snippets/declarative/transition-from-to.qml deleted file mode 100644 index c876f5cb9c..0000000000 --- a/doc/src/snippets/declarative/transition-from-to.qml +++ /dev/null @@ -1,59 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -import QtQuick 2.0 - -//![0] -Rectangle { - id: rect - width: 100; height: 100 - color: "red" - - MouseArea { id: mouseArea; anchors.fill: parent } - - states: State { - name: "brighter"; when: mouseArea.pressed - PropertyChanges { target: rect; color: "yellow" } - } - - transitions: Transition { - ColorAnimation { duration: 1000 } - } -} -//![0] diff --git a/doc/src/snippets/declarative/transition-reversible.qml b/doc/src/snippets/declarative/transition-reversible.qml deleted file mode 100644 index 4f7ae83468..0000000000 --- a/doc/src/snippets/declarative/transition-reversible.qml +++ /dev/null @@ -1,66 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -import QtQuick 2.0 - -//![0] -Rectangle { - id: rect - width: 100; height: 100 - color: "red" - - MouseArea { id: mouseArea; anchors.fill: parent } - - states: State { - name: "brighter" - when: mouseArea.pressed - PropertyChanges { target: rect; color: "yellow"; x: 50 } - } - - //! [sequential animations] - transitions: Transition { - SequentialAnimation { - PropertyAnimation { property: "x"; duration: 1000 } - ColorAnimation { duration: 1000 } - } - } - //! [sequential animations] -} -//![0] - diff --git a/doc/src/snippets/declarative/transition.qml b/doc/src/snippets/declarative/transition.qml deleted file mode 100644 index 614c5d364f..0000000000 --- a/doc/src/snippets/declarative/transition.qml +++ /dev/null @@ -1,63 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -//![0] -import QtQuick 2.0 - -Rectangle { - id: rect - width: 100; height: 100 - color: "red" - - MouseArea { - id: mouseArea - anchors.fill: parent - } - - states: State { - name: "moved"; when: mouseArea.pressed - PropertyChanges { target: rect; x: 50; y: 50 } - } - - transitions: Transition { - NumberAnimation { properties: "x,y"; easing.type: Easing.InOutQuad } - } -} -//![0] - diff --git a/doc/src/snippets/declarative/transitions-list.qml b/doc/src/snippets/declarative/transitions-list.qml deleted file mode 100644 index f2ba768559..0000000000 --- a/doc/src/snippets/declarative/transitions-list.qml +++ /dev/null @@ -1,89 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -Rectangle { - width: 150; height: 250 - - Rectangle { - id: stopLight - x: 25; y: 15; width: 100; height: 100 - } - Rectangle { - id: goLight - x: 25; y: 135; width: 100; height: 100 - } - - states: [ - State { - name: "stop" - PropertyChanges { target: stopLight; color: "red" } - PropertyChanges { target: goLight; color: "black" } - }, - State { - name: "go" - PropertyChanges { target: stopLight; color: "black" } - PropertyChanges { target: goLight; color: "green" } - } - ] - - state: "stop" - - MouseArea { - anchors.fill: parent - onClicked: parent.state == "stop" ? - parent.state = "go" : parent.state = "stop" - } - - //! [list of transitions] - transitions: [ - Transition { - from: "stop"; to: "go" - PropertyAnimation { target: stopLight - properties: "color"; duration: 1000 } - }, - Transition { - from: "go"; to: "stop" - PropertyAnimation { target: goLight - properties: "color"; duration: 1000 } - } ] - //! [list of transitions] -} diff --git a/doc/src/snippets/declarative/viewtransitions/viewtransitions-basic.qml b/doc/src/snippets/declarative/viewtransitions/viewtransitions-basic.qml deleted file mode 100644 index 8a05491ee1..0000000000 --- a/doc/src/snippets/declarative/viewtransitions/viewtransitions-basic.qml +++ /dev/null @@ -1,70 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -//! [0] -ListView { - width: 240; height: 320 - model: ListModel {} - - delegate: Rectangle { - width: 100; height: 30 - border.width: 1 - color: "lightsteelblue" - Text { - anchors.centerIn: parent - text: name - } - } - - add: Transition { - NumberAnimation { property: "opacity"; from: 0; to: 1.0; duration: 400 } - NumberAnimation { property: "scale"; from: 0; to: 1.0; duration: 400 } - } - - addDisplaced: Transition { - NumberAnimation { properties: "x,y"; duration: 400; easing.type: Easing.OutBounce } - } - - focus: true - Keys.onSpacePressed: model.insert(0, { "name": "Item " + model.count }) -} -//! [0] diff --git a/doc/src/snippets/declarative/viewtransitions/viewtransitions-delayedbyindex.qml b/doc/src/snippets/declarative/viewtransitions/viewtransitions-delayedbyindex.qml deleted file mode 100644 index 79d00d2d1c..0000000000 --- a/doc/src/snippets/declarative/viewtransitions/viewtransitions-delayedbyindex.qml +++ /dev/null @@ -1,78 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -ListView { - width: 240; height: 320 - model: ListModel {} - - delegate: Rectangle { - width: 100; height: 30 - border.width: 1 - color: "lightsteelblue" - Text { - anchors.centerIn: parent - text: name - } - } - - add: Transition { - NumberAnimation { property: "opacity"; from: 0; to: 1.0; duration: 400 } - NumberAnimation { property: "scale"; from: 0; to: 1.0; duration: 400 } - } - -//! [0] - addDisplaced: Transition { - id: addDispTrans - SequentialAnimation { - PauseAnimation { - duration: (addDispTrans.ViewTransition.index - - addDispTrans.ViewTransition.targetIndexes[0]) * 100 - } - NumberAnimation { properties: "x,y"; duration: 400; easing.type: Easing.OutBounce } - } - } -//! [0] - - focus: true - Keys.onSpacePressed: model.insert(0, { "name": "Item " + model.count }) -} - diff --git a/doc/src/snippets/declarative/viewtransitions/viewtransitions-intermediatemove.qml b/doc/src/snippets/declarative/viewtransitions/viewtransitions-intermediatemove.qml deleted file mode 100644 index a43d3a8b7f..0000000000 --- a/doc/src/snippets/declarative/viewtransitions/viewtransitions-intermediatemove.qml +++ /dev/null @@ -1,90 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -ListView { - width: 240; height: 320 - model: ListModel {} - - delegate: Rectangle { - width: 100; height: 30 - border.width: 1 - color: "lightsteelblue" - Text { - anchors.centerIn: parent - text: name - } - } - - add: Transition { - NumberAnimation { property: "opacity"; from: 0; to: 1.0; duration: 400 } - NumberAnimation { property: "scale"; from: 0; to: 1.0; duration: 400 } - } - -//! [0] - addDisplaced: Transition { - id: addDispTrans - SequentialAnimation { - PauseAnimation { - duration: (addDispTrans.ViewTransition.index - - addDispTrans.ViewTransition.targetIndexes[0]) * 100 - } - ParallelAnimation { - NumberAnimation { - property: "x"; to: addDispTrans.ViewTransition.item.x + 20 - easing.type: Easing.OutQuad - } - NumberAnimation { - property: "y"; to: addDispTrans.ViewTransition.item.y + 50 - easing.type: Easing.OutQuad - } - } - NumberAnimation { properties: "x,y"; duration: 500; easing.type: Easing.OutBounce } - } - } - -//! [0] - - focus: true - Keys.onSpacePressed: model.insert(0, { "name": "Item " + model.count }) -} - - diff --git a/doc/src/snippets/declarative/viewtransitions/viewtransitions-interruptedgood.qml b/doc/src/snippets/declarative/viewtransitions/viewtransitions-interruptedgood.qml deleted file mode 100644 index 1355268710..0000000000 --- a/doc/src/snippets/declarative/viewtransitions/viewtransitions-interruptedgood.qml +++ /dev/null @@ -1,74 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -ListView { - width: 240; height: 320 - model: ListModel {} - - delegate: Rectangle { - width: 100; height: 30 - border.width: 1 - color: "lightsteelblue" - Text { - anchors.centerIn: parent - text: name - } - } - - add: Transition { - NumberAnimation { property: "opacity"; from: 0; to: 1.0; duration: 400 } - NumberAnimation { property: "scale"; from: 0; to: 1.0; duration: 400 } - } - -//! [0] - addDisplaced: Transition { - NumberAnimation { properties: "x,y"; duration: 400; easing.type: Easing.OutBounce } - - // ensure opacity and scale values return to 1.0 - NumberAnimation { property: "opacity"; to: 1.0 } - NumberAnimation { property: "scale"; to: 1.0 } - } -//! [0] - - focus: true - Keys.onSpacePressed: model.insert(0, { "name": "Item " + model.count }) -} diff --git a/doc/src/snippets/declarative/viewtransitions/viewtransitions-pathanim.qml b/doc/src/snippets/declarative/viewtransitions/viewtransitions-pathanim.qml deleted file mode 100644 index 3d075c4367..0000000000 --- a/doc/src/snippets/declarative/viewtransitions/viewtransitions-pathanim.qml +++ /dev/null @@ -1,105 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -ListView { - width: 240; height: 320 - model: ListModel {} - - delegate: Rectangle { - width: 100; height: 30 - border.width: 1 - color: "lightsteelblue" - Text { - anchors.centerIn: parent - text: name - } - } - -//! [0] - add: Transition { - id: addTrans - NumberAnimation { property: "opacity"; from: 0; to: 1.0; duration: 400 } - NumberAnimation { property: "scale"; from: 0; to: 1.0; duration: 400 } - - PathAnimation { - duration: 1000 - path: Path { - startX: addTrans.ViewTransition.destination.x + 200 - startY: addTrans.ViewTransition.destination.y + 200 - PathCurve { relativeX: -100; relativeY: -50 } - PathCurve { relativeX: 50; relativeY: -150 } - PathCurve { - x: addTrans.ViewTransition.destination.x - y: addTrans.ViewTransition.destination.y - } - } - } - } -//! [0] - - addDisplaced: Transition { - id: addDispTrans - SequentialAnimation { - PauseAnimation { - duration: (addDispTrans.ViewTransition.index - - addDispTrans.ViewTransition.targetIndexes[0]) * 100 - } - ParallelAnimation { - NumberAnimation { - property: "x"; to: addDispTrans.ViewTransition.item.x + 20 - easing.type: Easing.OutQuad - } - NumberAnimation { - property: "y"; to: addDispTrans.ViewTransition.item.y + 50 - easing.type: Easing.OutQuad - } - } - NumberAnimation { properties: "x,y"; duration: 500; easing.type: Easing.OutBounce } - } - } - - focus: true - Keys.onSpacePressed: model.insert(0, { "name": "Item " + model.count }) -} - - - diff --git a/doc/src/snippets/declarative/viewtransitions/viewtransitions-scriptactionbad.qml b/doc/src/snippets/declarative/viewtransitions/viewtransitions-scriptactionbad.qml deleted file mode 100644 index 03348356e1..0000000000 --- a/doc/src/snippets/declarative/viewtransitions/viewtransitions-scriptactionbad.qml +++ /dev/null @@ -1,81 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -//! [0] -ListView { - width: 240; height: 320 - model: ListModel { - Component.onCompleted: { - for (var i=0; i<8; i++) - append({"name": i}) - } - } - - delegate: Rectangle { - width: 100; height: 30 - border.width: 1 - color: "lightsteelblue" - Text { - anchors.centerIn: parent - text: name - } - objectName: name - } - - move: Transition { - id: moveTrans - SequentialAnimation { - ColorAnimation { property: "color"; to: "yellow"; duration: 400 } - NumberAnimation { properties: "x,y"; duration: 800; easing.type: Easing.OutBack } - ScriptAction { script: moveTrans.ViewTransition.item.color = "lightsteelblue" } - } - } - - moveDisplaced: Transition { - NumberAnimation { properties: "x,y"; duration: 400; easing.type: Easing.OutBounce } - } - - focus: true - Keys.onSpacePressed: model.move(5, 1, 3) -} -//! [0] - diff --git a/doc/src/snippets/declarative/viewtransitions/viewtransitions-scriptactiongood.qml b/doc/src/snippets/declarative/viewtransitions/viewtransitions-scriptactiongood.qml deleted file mode 100644 index eda5c35479..0000000000 --- a/doc/src/snippets/declarative/viewtransitions/viewtransitions-scriptactiongood.qml +++ /dev/null @@ -1,84 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -ListView { - width: 240; height: 320 - model: ListModel { - Component.onCompleted: { - for (var i=0; i<8; i++) - append({"name": i}) - } - } - - delegate: Rectangle { - width: 100; height: 30 - border.width: 1 - color: "lightsteelblue" - Text { - anchors.centerIn: parent - text: name - } - objectName: name - } - -//! [0] - move: Transition { - id: moveTrans - SequentialAnimation { - ColorAnimation { property: "color"; to: "yellow"; duration: 400 } - NumberAnimation { properties: "x,y"; duration: 800; easing.type: Easing.OutBack } - //ScriptAction { script: moveTrans.ViewTransition.item.color = "lightsteelblue" } BAD! - - PropertyAction { property: "color"; value: "lightsteelblue" } - } - } -//! [0] - - moveDisplaced: Transition { - NumberAnimation { properties: "x,y"; duration: 400; easing.type: Easing.OutBounce } - } - - focus: true - Keys.onSpacePressed: model.move(5, 1, 3) -} - - diff --git a/doc/src/snippets/declarative/visualdatagroup.qml b/doc/src/snippets/declarative/visualdatagroup.qml deleted file mode 100644 index 46ac9a3d7a..0000000000 --- a/doc/src/snippets/declarative/visualdatagroup.qml +++ /dev/null @@ -1,81 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -//![0] -import QtQuick 2.0 - -Rectangle { - width: 200; height: 100 - - VisualDataModel { - id: visualModel - model: ListModel { - ListElement { name: "Apple" } - ListElement { name: "Orange" } - } - - groups: [ - VisualDataGroup { name: "selected" } - ] - - delegate: Rectangle { - id: item - height: 25 - width: 200 - Text { - text: { - var text = "Name: " + name - if (item.VisualDataModel.inSelected) - text += " (" + item.VisualDataModel.selectedIndex + ")" - return text; - } - } - MouseArea { - anchors.fill: parent - onClicked: item.VisualDataModel.inSelected = !item.VisualDataModel.inSelected - } - } - } - - ListView { - anchors.fill: parent - model: visualModel - } -} -//![0] diff --git a/doc/src/snippets/declarative/visualdatamodel.qml b/doc/src/snippets/declarative/visualdatamodel.qml deleted file mode 100644 index 87b836e224..0000000000 --- a/doc/src/snippets/declarative/visualdatamodel.qml +++ /dev/null @@ -1,64 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -//![0] -import QtQuick 2.0 - -Rectangle { - width: 200; height: 100 - - VisualDataModel { - id: visualModel - model: ListModel { - ListElement { name: "Apple" } - ListElement { name: "Orange" } - } - delegate: Rectangle { - height: 25 - width: 100 - Text { text: "Name: " + name} - } - } - - ListView { - anchors.fill: parent - model: visualModel - } -} -//![0] diff --git a/doc/src/snippets/declarative/visualdatamodel_rootindex/main.cpp b/doc/src/snippets/declarative/visualdatamodel_rootindex/main.cpp deleted file mode 100644 index 206828e883..0000000000 --- a/doc/src/snippets/declarative/visualdatamodel_rootindex/main.cpp +++ /dev/null @@ -1,62 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include -#include - -#include -#include - -//![0] -int main(int argc, char ** argv) -{ - QApplication app(argc, argv); - - QDeclarativeView view; - - QDirModel model; - view.rootContext()->setContextProperty("dirModel", &model); - - view.setSource(QUrl::fromLocalFile("view.qml")); - view.show(); - - return app.exec(); -} -//![0] - diff --git a/doc/src/snippets/declarative/visualdatamodel_rootindex/view.qml b/doc/src/snippets/declarative/visualdatamodel_rootindex/view.qml deleted file mode 100644 index 24d6b47f8d..0000000000 --- a/doc/src/snippets/declarative/visualdatamodel_rootindex/view.qml +++ /dev/null @@ -1,65 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -//![0] -import QtQuick 2.0 - -ListView { - id: view - width: 300 - height: 400 - - model: VisualDataModel { - model: dirModel - - delegate: Rectangle { - width: 200; height: 25 - Text { text: filePath } - - MouseArea { - anchors.fill: parent - onClicked: { - if (model.hasModelChildren) - view.model.rootIndex = view.model.modelIndex(index) - } - } - } - } -} -//![0] diff --git a/doc/src/snippets/declarative/workerscript.qml b/doc/src/snippets/declarative/workerscript.qml deleted file mode 100644 index 6af6b47766..0000000000 --- a/doc/src/snippets/declarative/workerscript.qml +++ /dev/null @@ -1,64 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -//![0] -import QtQuick 2.0 - -Rectangle { - width: 300; height: 300 - - Text { - id: myText - text: 'Click anywhere' - } - - WorkerScript { - id: myWorker - source: "script.js" - - onMessage: myText.text = messageObject.reply - } - - MouseArea { - anchors.fill: parent - onClicked: myWorker.sendMessage({ 'x': mouse.x, 'y': mouse.y }) - } -} -//![0] diff --git a/doc/src/snippets/declarative/xmlrole.qml b/doc/src/snippets/declarative/xmlrole.qml deleted file mode 100644 index 34868fb76d..0000000000 --- a/doc/src/snippets/declarative/xmlrole.qml +++ /dev/null @@ -1,81 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 -import QtQuick.XmlListModel 2.0 - -Rectangle { - width: 300; height: 200 - -//![0] -XmlListModel { - id: model -//![0] - source: "xmlrole.xml" - -//![1] - // XmlRole queries will be made on elements - query: "/catalogue/book" - - // query the book title - XmlRole { name: "title"; query: "title/string()" } - - // query the book's year - XmlRole { name: "year"; query: "year/number()" } - - // query the book's type (the '@' indicates 'type' is an attribute, not an element) - XmlRole { name: "type"; query: "@type/string()" } - - // query the book's first listed author (note in XPath the first index is 1, not 0) - XmlRole { name: "first_author"; query: "author[1]/string()" } -} -//![1] - -ListView { - width: 300; height: 200 - model: model - delegate: Column { - Text { text: title + " (" + type + ")"; font.bold: true } - Text { text: first_author } - Text { text: year } - } -} - -} diff --git a/doc/src/snippets/declarative/xmlrole.xml b/doc/src/snippets/declarative/xmlrole.xml deleted file mode 100644 index c9f999e523..0000000000 --- a/doc/src/snippets/declarative/xmlrole.xml +++ /dev/null @@ -1,14 +0,0 @@ - - - - C++ GUI Programming with Qt 4 - 2006 - Jasmin Blanchette - Mark Summerfield - - - Programming with Qt - 2002 - Matthias Kalle Dalheimer - - diff --git a/doc/src/snippets/qml/Button.qml b/doc/src/snippets/qml/Button.qml new file mode 100644 index 0000000000..0525ac1383 --- /dev/null +++ b/doc/src/snippets/qml/Button.qml @@ -0,0 +1,67 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +//! [document] +import QtQuick 2.0 + +//! [parent begin] +Rectangle { +//! [parent begin] + +//! [property alias] +property alias buttonLabel: label.text +Text { + id: label + text: "empty label" +} + //! [property alias] + +//! [id alias] + property alias buttonImage: image + + Image {id: image} +//! [id alias] +//! [parent end] +} +//! [parent end] + +//! [document] + + diff --git a/doc/src/snippets/qml/SelfDestroyingRect.qml b/doc/src/snippets/qml/SelfDestroyingRect.qml new file mode 100644 index 0000000000..baa4ab63a1 --- /dev/null +++ b/doc/src/snippets/qml/SelfDestroyingRect.qml @@ -0,0 +1,60 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +//![0] +import QtQuick 2.0 + +Rectangle { + id: rect + width: 80; height: 80 + color: "red" + + NumberAnimation on opacity { + to: 0 + duration: 1000 + + onRunningChanged: { + if (!running) { + console.log("Destroying...") + rect.destroy(); + } + } + } +} +//![0] diff --git a/doc/src/snippets/qml/Sprite.qml b/doc/src/snippets/qml/Sprite.qml new file mode 100644 index 0000000000..ec08963be5 --- /dev/null +++ b/doc/src/snippets/qml/Sprite.qml @@ -0,0 +1,45 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +//![0] +import QtQuick 2.0 + +Rectangle { width: 80; height: 50; color: "red" } +//![0] diff --git a/doc/src/snippets/qml/anchoranimation.qml b/doc/src/snippets/qml/anchoranimation.qml new file mode 100644 index 0000000000..8f0603fab8 --- /dev/null +++ b/doc/src/snippets/qml/anchoranimation.qml @@ -0,0 +1,66 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +//![0] +import QtQuick 2.0 + +Item { + id: container + width: 200; height: 200 + + Rectangle { + id: myRect + width: 100; height: 100 + color: "red" + } + + states: State { + name: "reanchored" + AnchorChanges { target: myRect; anchors.right: container.right } + } + + transitions: Transition { + // smoothly reanchor myRect and move into new position + AnchorAnimation { duration: 1000 } + } + + Component.onCompleted: container.state = "reanchored" +} +//![0] diff --git a/doc/src/snippets/qml/anchorchanges.qml b/doc/src/snippets/qml/anchorchanges.qml new file mode 100644 index 0000000000..9cc9d15221 --- /dev/null +++ b/doc/src/snippets/qml/anchorchanges.qml @@ -0,0 +1,68 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +//![0] +import QtQuick 2.0 + +Rectangle { + id: window + width: 120; height: 120 + color: "black" + + Rectangle { id: myRect; width: 50; height: 50; color: "red" } + + states: State { + name: "reanchored" + + AnchorChanges { + target: myRect + anchors.top: window.top + anchors.bottom: window.bottom + } + PropertyChanges { + target: myRect + anchors.topMargin: 10 + anchors.bottomMargin: 10 + } + } + + MouseArea { anchors.fill: parent; onClicked: window.state = "reanchored" } +} +//![0] + diff --git a/doc/src/snippets/qml/animatedimage.qml b/doc/src/snippets/qml/animatedimage.qml new file mode 100644 index 0000000000..a483619e11 --- /dev/null +++ b/doc/src/snippets/qml/animatedimage.qml @@ -0,0 +1,61 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +// This snippet should be turned into an example and put in +// examples/declarative/imageelements/animatedimage + +//! [document] +import QtQuick 2.0 + +Rectangle { + width: animation.width; height: animation.height + 8 + + AnimatedImage { id: animation; source: "animation.gif" } + + Rectangle { + property int frames: animation.frameCount + + width: 4; height: 8 + x: (animation.width - width) * animation.currentFrame / frames + y: animation.height + color: "red" + } +} +//! [document] diff --git a/doc/src/snippets/qml/animation.qml b/doc/src/snippets/qml/animation.qml new file mode 100644 index 0000000000..d45ded397f --- /dev/null +++ b/doc/src/snippets/qml/animation.qml @@ -0,0 +1,226 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +//! [document] +import QtQuick 2.0 + + +//! [parent begin] +Rectangle { +//! [parent begin] + width: 200; height: 600 + id: screen + +Column { + spacing: 12 +//! [direct property change] +Rectangle { + id: blob + width: 75; height: 75 + color: "blue" + + MouseArea { + anchors.fill: parent + onClicked: blob.color = "green" + } +} +//! [direct property change] + +//! [property animation] +Rectangle { + id: flashingblob + width: 75; height: 75 + color: "blue" + opacity: 1.0 + + MouseArea { + anchors.fill: parent + onClicked: { + animateColor.start() + animateOpacity.start() + } + } + + PropertyAnimation {id: animateColor; target: flashingblob; properties: "color"; to: "green"; duration: 100} + + NumberAnimation { + id: animateOpacity + target: flashingblob + properties: "opacity" + from: 0.99 + to: 1.0 + loops: Animation.Infinite + easing {type: Easing.OutBack; overshoot: 500} + } +} +//! [property animation] + +//! [transition animation] +Rectangle { + width: 75; height: 75 + id: button + state: "RELEASED" + + MouseArea { + anchors.fill: parent + onPressed: button.state = "PRESSED" + onReleased: button.state = "RELEASED" + } + + states: [ + State { + name: "PRESSED" + PropertyChanges { target: button; color: "lightblue"} + }, + State { + name: "RELEASED" + PropertyChanges { target: button; color: "lightsteelblue"} + } + ] + + transitions: [ + Transition { + from: "PRESSED" + to: "RELEASED" + ColorAnimation { target: button; duration: 100} + }, + Transition { + from: "RELEASED" + to: "PRESSED" + ColorAnimation { target: button; duration: 100} + } + ] +} +//! [transition animation] + +Rectangle { + width: 75; height: 75 + id: wildcard + color: "green" +//! [wildcard animation] + transitions: + Transition { + to: "*" + ColorAnimation { target: button; duration: 100} + } +//! [wildcard animation] + + MouseArea { + anchors.fill: parent + onPressed: { + ball.x = 10 + ball.color = "red" + } + onReleased: { + ball.x = screen.width / 2 + ball.color = "salmon" + } + } +} + +//! [behavior animation] +Rectangle { + width: 75; height: 75; radius: width + id: ball + color: "salmon" + + Behavior on x { + NumberAnimation { + id: bouncebehavior + easing { + type: Easing.OutElastic + amplitude: 1.0 + period: 0.5 + } + } + } + Behavior on y { + animation: bouncebehavior + } + Behavior { + ColorAnimation { target: ball; duration: 100 } + } +} +//! [behavior animation] + +//! [sequential animation] +Rectangle { + id: banner + width: 150; height: 100; border.color: "black" + + Column { + anchors.centerIn: parent + Text { + id: code + text: "Code less." + opacity: 0.01 + } + Text { + id: create + text: "Create more." + opacity: 0.01 + } + Text { + id: deploy + text: "Deploy everywhere." + opacity: 0.01 + } + } + + MouseArea { + anchors.fill: parent + onPressed: playbanner.start() + } + + SequentialAnimation { + id: playbanner + running: false + NumberAnimation { target: code; property: "opacity"; to: 1.0; duration: 200} + NumberAnimation { target: create; property: "opacity"; to: 1.0; duration: 200} + NumberAnimation { target: deploy; property: "opacity"; to: 1.0; duration: 200} + } +} +//! [sequential animation] + +}//end of col +//! [parent end] +} +//! [parent end] + +//! [document] diff --git a/doc/src/snippets/qml/application.qml b/doc/src/snippets/qml/application.qml new file mode 100644 index 0000000000..4e847176fa --- /dev/null +++ b/doc/src/snippets/qml/application.qml @@ -0,0 +1,53 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +//! [document] +import QtQuick 2.0 + +Rectangle { + width: 300; height: 55 + color: Qt.application.active ? "white" : "lightgray" + Text { + text: "Application " + (Qt.application.active ? "active" : "inactive") + opacity: Qt.application.active ? 1.0 : 0.5 + anchors.centerIn: parent + } +} +//! [document] diff --git a/doc/src/snippets/qml/behavior.qml b/doc/src/snippets/qml/behavior.qml new file mode 100644 index 0000000000..4776e09a54 --- /dev/null +++ b/doc/src/snippets/qml/behavior.qml @@ -0,0 +1,58 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +//![0] +import QtQuick 2.0 + +Rectangle { + id: rect + width: 100; height: 100 + color: "red" + + Behavior on width { + NumberAnimation { duration: 1000 } + } + + MouseArea { + anchors.fill: parent + onClicked: rect.width = 50 + } +} +//![0] diff --git a/doc/src/snippets/qml/borderimage/borderimage-scaled.qml b/doc/src/snippets/qml/borderimage/borderimage-scaled.qml new file mode 100644 index 0000000000..468aa24eab --- /dev/null +++ b/doc/src/snippets/qml/borderimage/borderimage-scaled.qml @@ -0,0 +1,81 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Rectangle { + id: page + color: "white" + width: 180; height: 180 + +//! [scaled border image] +BorderImage { + width: 180; height: 180 + border { left: 30; top: 30; right: 30; bottom: 30 } + horizontalTileMode: BorderImage.Stretch + verticalTileMode: BorderImage.Stretch + source: "pics/borderframe.png" +} +//! [scaled border image] + + Rectangle { + x: 30; y: 0 + width: 1; height: 180 + color: "gray" + } + + Rectangle { + x: 150; y: 0 + width: 1; height: 180 + color: "gray" + } + + Rectangle { + x: 0; y: 30 + width: 180; height: 1 + color: "gray" + } + + Rectangle { + x: 0; y: 150 + width: 180; height: 1 + color: "gray" + } +} diff --git a/doc/src/snippets/qml/borderimage/borderimage-tiled.qml b/doc/src/snippets/qml/borderimage/borderimage-tiled.qml new file mode 100644 index 0000000000..69297378bf --- /dev/null +++ b/doc/src/snippets/qml/borderimage/borderimage-tiled.qml @@ -0,0 +1,81 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Rectangle { + id: page + color: "white" + width: 180; height: 180 + +//! [tiled border image] +BorderImage { + width: 180; height: 180 + border { left: 30; top: 30; right: 30; bottom: 30 } + horizontalTileMode: BorderImage.Repeat + verticalTileMode: BorderImage.Repeat + source: "pics/borderframe.png" +} +//! [tiled border image] + + Rectangle { + x: 30; y: 0 + width: 1; height: 180 + color: "gray" + } + + Rectangle { + x: 150; y: 0 + width: 1; height: 180 + color: "gray" + } + + Rectangle { + x: 0; y: 30 + width: 180; height: 1 + color: "gray" + } + + Rectangle { + x: 0; y: 150 + width: 180; height: 1 + color: "gray" + } +} diff --git a/doc/src/snippets/qml/borderimage/normal-image.qml b/doc/src/snippets/qml/borderimage/normal-image.qml new file mode 100644 index 0000000000..3bd34e3933 --- /dev/null +++ b/doc/src/snippets/qml/borderimage/normal-image.qml @@ -0,0 +1,77 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Rectangle { + id: page + color: "white" + width: 120; height: 120 + +//! [normal image] +Image { + source: "pics/borderframe.png" +} +//! [normal image] + + Rectangle { + x: 30; y: 0 + width: 1; height: 120 + color: "gray" + } + + Rectangle { + x: 90; y: 0 + width: 1; height: 120 + color: "gray" + } + + Rectangle { + x: 0; y: 30 + width: 200; height: 1 + color: "gray" + } + + Rectangle { + x: 0; y: 90 + width: 200; height: 1 + color: "gray" + } +} diff --git a/doc/src/snippets/qml/codingconventions/dotproperties.qml b/doc/src/snippets/qml/codingconventions/dotproperties.qml new file mode 100644 index 0000000000..75f4629b3e --- /dev/null +++ b/doc/src/snippets/qml/codingconventions/dotproperties.qml @@ -0,0 +1,68 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Item { + +//! [0] +Rectangle { + anchors.left: parent.left; anchors.top: parent.top; anchors.right: parent.right; anchors.leftMargin: 20 +} + +Text { + text: "hello" + font.bold: true; font.italic: true; font.pixelSize: 20; font.capitalization: Font.AllUppercase +} + +//! [0] + +//! [1] +Rectangle { + anchors { left: parent.left; top: parent.top; right: parent.right; leftMargin: 20 } +} + +Text { + text: "hello" + font { bold: true; italic: true; pixelSize: 20; capitalization: Font.AllUppercase } +} +//! [1] + +} diff --git a/doc/src/snippets/qml/codingconventions/javascript-imports.qml b/doc/src/snippets/qml/codingconventions/javascript-imports.qml new file mode 100644 index 0000000000..5ea66a9b1f --- /dev/null +++ b/doc/src/snippets/qml/codingconventions/javascript-imports.qml @@ -0,0 +1,47 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +//![0] +import "myscript.js" as Script + +Rectangle { color: "blue"; width: Script.calculateWidth(parent) } +//![0] diff --git a/doc/src/snippets/qml/codingconventions/javascript.qml b/doc/src/snippets/qml/codingconventions/javascript.qml new file mode 100644 index 0000000000..de3cc21493 --- /dev/null +++ b/doc/src/snippets/qml/codingconventions/javascript.qml @@ -0,0 +1,73 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Rectangle { + +//![0] +Rectangle { color: "blue"; width: parent.width / 3 } +//![0] + +//![1] +Rectangle { + color: "blue" + width: { + var w = parent.width / 3 + console.debug(w) + return w + } +} +//![1] + +//![2] +function calculateWidth(object) +{ + var w = object.width / 3 + // ... + // more javascript code + // ... + console.debug(w) + return w +} + +Rectangle { color: "blue"; width: calculateWidth(parent) } +//![2] +} diff --git a/doc/src/snippets/qml/codingconventions/lists.qml b/doc/src/snippets/qml/codingconventions/lists.qml new file mode 100644 index 0000000000..f99c92b08e --- /dev/null +++ b/doc/src/snippets/qml/codingconventions/lists.qml @@ -0,0 +1,62 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Item { + Item { +//! [0] +states: [ + State { + name: "open" + PropertyChanges { target: container; width: 200 } + } +] +//! [0] + } + Item { +//! [1] +states: State { + name: "open" + PropertyChanges { target: container; width: 200 } +} +//! [1] + } +} diff --git a/doc/src/snippets/qml/codingconventions/myscript.js b/doc/src/snippets/qml/codingconventions/myscript.js new file mode 100644 index 0000000000..e7f83c259c --- /dev/null +++ b/doc/src/snippets/qml/codingconventions/myscript.js @@ -0,0 +1,12 @@ +function calculateWidth(parent) +{ + if (parent == null) + return 0 + + var w = parent.width / 3 + // ... + // more javascript code + // ... + console.debug(w) + return w +} diff --git a/doc/src/snippets/qml/codingconventions/photo.qml b/doc/src/snippets/qml/codingconventions/photo.qml new file mode 100644 index 0000000000..1bd2811e9f --- /dev/null +++ b/doc/src/snippets/qml/codingconventions/photo.qml @@ -0,0 +1,85 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +//! [0] +Rectangle { + id: photo // id on the first line makes it easy to find an object + + property bool thumbnail: false // property declarations + property alias image: photoImage.source + + signal clicked // signal declarations + + function doSomething(x) // javascript functions + { + return x + photoImage.width + } + + color: "gray" // object properties + x: 20; y: 20; height: 150 // try to group related properties together + width: { // large bindings + if(photoImage.width > 200){ + photoImage.width; + }else{ + 200; + } + } + + Rectangle { // child objects + id: border + anchors.centerIn: parent; color: "white" + + Image { id: photoImage; anchors.centerIn: parent } + } + + states: State { // states + name: "selected" + PropertyChanges { target: border; color: "red" } + } + + transitions: Transition { // transitions + from: ""; to: "selected" + ColorAnimation { target: border; duration: 200 } + } +} +//! [0] + diff --git a/doc/src/snippets/qml/codingconventions/private.qml b/doc/src/snippets/qml/codingconventions/private.qml new file mode 100644 index 0000000000..9aba1d0377 --- /dev/null +++ b/doc/src/snippets/qml/codingconventions/private.qml @@ -0,0 +1,49 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +//! [0] +Item { + id: component + width: 40; height: 50 + property real __area: width * height * 0.5 //not meant for outside use +} +//! [0] diff --git a/doc/src/snippets/qml/coloranimation.qml b/doc/src/snippets/qml/coloranimation.qml new file mode 100644 index 0000000000..bb2d83bfb8 --- /dev/null +++ b/doc/src/snippets/qml/coloranimation.qml @@ -0,0 +1,51 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +//![0] +import QtQuick 2.0 + +Rectangle { + width: 100; height: 100 + color: "red" + + ColorAnimation on color { to: "yellow"; duration: 1000 } +} +//![0] + diff --git a/doc/src/snippets/qml/colors.qml b/doc/src/snippets/qml/colors.qml new file mode 100644 index 0000000000..7f94c6b843 --- /dev/null +++ b/doc/src/snippets/qml/colors.qml @@ -0,0 +1,125 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Rectangle { + width: 160; height: 250 + + Image { + width: 160; height: 200 + source: "pics/checker.svg" + fillMode: Image.Tile + + //! [colors] + Rectangle { + color: "steelblue" + width: 40; height: 40 + } + Rectangle { + color: "transparent" + y: 40; width: 40; height: 40 + } + Rectangle { + color: "#FF0000" + y: 80; width: 40; height: 40 + } + Rectangle { + color: "#800000FF" + y: 120; width: 40; height: 40 + } + Rectangle { + color: "#00000000" // ARGB fully transparent + y: 160 + width: 40; height: 40 + } + //! [colors] + + Rectangle { + x: 40 + width: 120; height: 200 + + Text { + font.pixelSize: 16 + text: "steelblue" + x: 10; height: 40 + verticalAlignment: Text.AlignVCenter + } + Text { + font.pixelSize: 16 + text: "transparent" + x: 10; y: 40; height: 40 + verticalAlignment: Text.AlignVCenter + } + Text { + font.pixelSize: 16 + text: "FF0000" + x: 10; y: 80; height: 40 + verticalAlignment: Text.AlignVCenter + } + Text { + font.pixelSize: 16 + text: "800000FF" + x: 10; y: 120; height: 40 + verticalAlignment: Text.AlignVCenter + } + Text { + font.pixelSize: 16 + text: "00000000" + x: 10; y: 160; height: 40 + verticalAlignment: Text.AlignVCenter + } + } + } + + Image { + y: 210 + width: 40; height: 40 + source: "pics/checker.svg" + fillMode: Image.Tile + } + + Text { + font.pixelSize: 16 + text: "(background)" + x: 50; y: 210; height: 40 + verticalAlignment: Text.AlignVCenter + } +} diff --git a/doc/src/snippets/qml/column/column-transitions.qml b/doc/src/snippets/qml/column/column-transitions.qml new file mode 100644 index 0000000000..8e291b12c8 --- /dev/null +++ b/doc/src/snippets/qml/column/column-transitions.qml @@ -0,0 +1,58 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +//! [document] +Column { + spacing: 2 + + Rectangle { color: "red"; width: 50; height: 50 } + Rectangle { id: greenRect; color: "green"; width: 20; height: 50 } + Rectangle { color: "blue"; width: 50; height: 20 } + + move: Transition { + NumberAnimation { properties: "x,y"; duration: 1000 } + } + + focus: true + Keys.onSpacePressed: greenRect.visible = !greenRect.visible +} +//! [document] diff --git a/doc/src/snippets/qml/column/column.qml b/doc/src/snippets/qml/column/column.qml new file mode 100644 index 0000000000..3d51728d13 --- /dev/null +++ b/doc/src/snippets/qml/column/column.qml @@ -0,0 +1,67 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +//! [document] +import QtQuick 2.0 + +Item { + width: 310; height: 170 + + Column { + anchors.horizontalCenter: parent.horizontalCenter + anchors.verticalCenter: parent.verticalCenter + + spacing: 5 + + Rectangle { color: "lightblue"; radius: 10.0 + width: 300; height: 50 + Text { anchors.centerIn: parent + font.pointSize: 24; text: "Books" } } + Rectangle { color: "gold"; radius: 10.0 + width: 300; height: 50 + Text { anchors.centerIn: parent + font.pointSize: 24; text: "Music" } } + Rectangle { color: "lightgreen"; radius: 10.0 + width: 300; height: 50 + Text { anchors.centerIn: parent + font.pointSize: 24; text: "Movies" } } + } +} +//! [document] diff --git a/doc/src/snippets/qml/column/vertical-positioner.qml b/doc/src/snippets/qml/column/vertical-positioner.qml new file mode 100644 index 0000000000..1661c46ba8 --- /dev/null +++ b/doc/src/snippets/qml/column/vertical-positioner.qml @@ -0,0 +1,51 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +//! [document] +Column { + spacing: 2 + + Rectangle { color: "red"; width: 50; height: 50 } + Rectangle { color: "green"; width: 20; height: 50 } + Rectangle { color: "blue"; width: 50; height: 20 } +} +//! [document] diff --git a/doc/src/snippets/qml/comments.qml b/doc/src/snippets/qml/comments.qml new file mode 100644 index 0000000000..8c3f0045b9 --- /dev/null +++ b/doc/src/snippets/qml/comments.qml @@ -0,0 +1,53 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +//![0] +Text { + text: "Hello world!" //a basic greeting + /* + We want this text to stand out from the rest so + we give it a large size and different font. + */ + font.family: "Helvetica" + font.pointSize: 24 +} +//![0] diff --git a/doc/src/snippets/qml/component.qml b/doc/src/snippets/qml/component.qml new file mode 100644 index 0000000000..e2a359e0e4 --- /dev/null +++ b/doc/src/snippets/qml/component.qml @@ -0,0 +1,59 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +//![0] +import QtQuick 2.0 + +Item { + width: 100; height: 100 + + Component { + id: redSquare + + Rectangle { + color: "red" + width: 10 + height: 10 + } + } + + Loader { sourceComponent: redSquare } + Loader { sourceComponent: redSquare; x: 20 } +} +//![0] diff --git a/doc/src/snippets/qml/componentCreation.js b/doc/src/snippets/qml/componentCreation.js new file mode 100644 index 0000000000..7364139d3d --- /dev/null +++ b/doc/src/snippets/qml/componentCreation.js @@ -0,0 +1,45 @@ +//![vars] +var component; +var sprite; +//![vars] + +//![func] +function createSpriteObjects() { +//![func] + +//![remote] + component = Qt.createComponent("Sprite.qml"); + if (component.status == Component.Ready) + finishCreation(); + else + component.statusChanged.connect(finishCreation); +//![remote] + +//![local] + component = Qt.createComponent("Sprite.qml"); + sprite = component.createObject(appWindow, {"x": 100, "y": 100}); + + if (sprite == null) { + // Error Handling + console.log("Error creating object"); + } +//![local] + +//![func-end] +} +//![func-end] + +//![finishCreation] +function finishCreation() { + if (component.status == Component.Ready) { + sprite = component.createObject(appWindow, {"x": 100, "y": 100}); + if (sprite == null) { + // Error Handling + console.log("Error creating object"); + } + } else if (component.status == Component.Error) { + // Error Handling + console.log("Error loading component:", component.errorString()); + } +} +//![finishCreation] diff --git a/doc/src/snippets/qml/createComponent-simple.qml b/doc/src/snippets/qml/createComponent-simple.qml new file mode 100644 index 0000000000..3f90a39166 --- /dev/null +++ b/doc/src/snippets/qml/createComponent-simple.qml @@ -0,0 +1,57 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +//![0] +import QtQuick 2.0 + +Item { + id: container + width: 300; height: 300 + + function loadButton() { + var component = Qt.createComponent("Button.qml"); + if (component.status == Component.Ready) { + var button = component.createObject(container); + button.color = "red"; + } + } + + Component.onCompleted: loadButton() +} +//![0] diff --git a/doc/src/snippets/qml/createComponent.qml b/doc/src/snippets/qml/createComponent.qml new file mode 100644 index 0000000000..e2d81170e4 --- /dev/null +++ b/doc/src/snippets/qml/createComponent.qml @@ -0,0 +1,51 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +//![0] +import QtQuick 2.0 +import "componentCreation.js" as MyScript + +Rectangle { + id: appWindow + width: 300; height: 300 + + Component.onCompleted: MyScript.createSpriteObjects(); +} +//![0] diff --git a/doc/src/snippets/qml/createQmlObject.qml b/doc/src/snippets/qml/createQmlObject.qml new file mode 100644 index 0000000000..76cf836914 --- /dev/null +++ b/doc/src/snippets/qml/createQmlObject.qml @@ -0,0 +1,61 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Rectangle { + id: parentItem + + width: 100 + height: 100 + + function createIt() { +//![0] +var newObject = Qt.createQmlObject('import QtQuick 2.0; Rectangle {color: "red"; width: 20; height: 20}', + parentItem, "dynamicSnippet1"); +//![0] + +//![destroy] +newObject.destroy(1000); +//![destroy] + } + + Component.onCompleted: createIt() +} diff --git a/doc/src/snippets/qml/drag.qml b/doc/src/snippets/qml/drag.qml new file mode 100644 index 0000000000..286fcfc52b --- /dev/null +++ b/doc/src/snippets/qml/drag.qml @@ -0,0 +1,75 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +//![0] +import QtQuick 2.0 + +Item { + width: 200; height: 200 + + DropArea { + x: 75; y: 75 + width: 50; height: 50 + + Rectangle { + anchors.fill: parent + color: "green" + + visible: parent.containsDrag + } + } + + Rectangle { + x: 10; y: 10 + width: 20; height: 20 + color: "red" + + Drag.active: dragArea.drag.active + Drag.hotSpot.x: 10 + Drag.hotSpot.y: 10 + + MouseArea { + id: dragArea + anchors.fill: parent + + drag.target: parent + } + } +} +//![0] diff --git a/doc/src/snippets/qml/dynamicObjects-destroy.qml b/doc/src/snippets/qml/dynamicObjects-destroy.qml new file mode 100644 index 0000000000..66fbc0b243 --- /dev/null +++ b/doc/src/snippets/qml/dynamicObjects-destroy.qml @@ -0,0 +1,55 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +//![0] +import QtQuick 2.0 + +Item { + id: container + width: 500; height: 100 + + Component.onCompleted: { + var component = Qt.createComponent("SelfDestroyingRect.qml"); + for (var i=0; i<5; i++) { + var object = component.createObject(container); + object.x = (object.width + 10) * i; + } + } +} +//![0] diff --git a/doc/src/snippets/qml/events.qml b/doc/src/snippets/qml/events.qml new file mode 100644 index 0000000000..b9c5fef954 --- /dev/null +++ b/doc/src/snippets/qml/events.qml @@ -0,0 +1,141 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +//![document] +import QtQuick 2.0 + +//![parent begin] +Rectangle { +//![parent begin] + + id: screen + width: 400; height: 500 + +//! [signal declaration] + signal trigger + signal send (string notice) + signal perform (string task, variant object) +//! [signal declaration] + +//! [signal handler declaration] +onTrigger: console.log("trigger signal emitted") + +onSend: { + console.log("send signal emitted with notice: " + notice) +} + +onPerform: console.log("perform signal emitted") +//! [signal handler declaration] + +//! [automatic signals] +Rectangle { + id: sprite + width: 25; height: 25 + x: 50; y: 15 + + onXChanged: console.log("x property changed, emitted xChanged signal") + onYChanged: console.log("y property changed, emitted yChanged signal") +} +//! [automatic signals] + +//! [signal emit] +Rectangle { + id: messenger + + signal send( string person, string notice) + + onSend: { + console.log("For " + person + ", the notice is: " + notice) + } + + Component.onCompleted: messenger.send("Tom", "the door is ajar.") +} +//! [signal emit] + +//! [connect method] +Rectangle { + id: relay + + signal send( string person, string notice) + onSend: console.log("Send signal to: " + person + ", " + notice) + + Component.onCompleted: { + relay.send.connect(sendToPost) + relay.send.connect(sendToTelegraph) + relay.send.connect(sendToEmail) + relay.send("Tom", "Happy Birthday") + } + + function sendToPost(person, notice) { + console.log("Sending to post: " + person + ", " + notice) + } + function sendToTelegraph(person, notice) { + console.log("Sending to telegraph: " + person + ", " + notice) + } + function sendToEmail(person, notice) { + console.log("Sending to email: " + person + ", " + notice) + } +} +//! [connect method] + +//! [forward signal] +Rectangle { + id: forwarder + width: 100; height: 100 + + signal send() + onSend: console.log("Send clicked") + + MouseArea { + id: mousearea + anchors.fill: parent + onClicked: console.log("MouseArea clicked") + } + Component.onCompleted: { + mousearea.clicked.connect(send) + } +} +//! [forward signal] + +//! [connect method] +//![parent end] +} +//![parent end] + +//![document] diff --git a/doc/src/snippets/qml/flickable.qml b/doc/src/snippets/qml/flickable.qml new file mode 100644 index 0000000000..fda2615e14 --- /dev/null +++ b/doc/src/snippets/qml/flickable.qml @@ -0,0 +1,50 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +//! [document] +import QtQuick 2.0 + +Flickable { + width: 200; height: 200 + contentWidth: image.width; contentHeight: image.height + + Image { id: image; source: "bigImage.png" } +} +//! [document] diff --git a/doc/src/snippets/qml/flickableScrollbar.qml b/doc/src/snippets/qml/flickableScrollbar.qml new file mode 100644 index 0000000000..fd0aee3fc1 --- /dev/null +++ b/doc/src/snippets/qml/flickableScrollbar.qml @@ -0,0 +1,66 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +//![0] +Rectangle { + width: 200; height: 200 + + Flickable { + id: flickable +//![0] + anchors.fill: parent + contentWidth: image.width; contentHeight: image.height + + Image { id: image; source: "pics/qt.png" } +//![1] + } + + Rectangle { + id: scrollbar + anchors.right: flickable.right + y: flickable.visibleArea.yPosition * flickable.height + width: 10 + height: flickable.visibleArea.heightRatio * flickable.height + color: "black" + } +} +//![1] diff --git a/doc/src/snippets/qml/flipable/flipable.qml b/doc/src/snippets/qml/flipable/flipable.qml new file mode 100644 index 0000000000..4e451204d4 --- /dev/null +++ b/doc/src/snippets/qml/flipable/flipable.qml @@ -0,0 +1,78 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +//! [0] +import QtQuick 2.0 + +Flipable { + id: flipable + width: 240 + height: 240 + + property bool flipped: false + + front: Image { source: "front.png"; anchors.centerIn: parent } + back: Image { source: "back.png"; anchors.centerIn: parent } + + transform: Rotation { + id: rotation + origin.x: flipable.width/2 + origin.y: flipable.height/2 + axis.x: 0; axis.y: 1; axis.z: 0 // set axis.y to 1 to rotate around y-axis + angle: 0 // the default angle + } + + states: State { + name: "back" + PropertyChanges { target: rotation; angle: 180 } + when: flipable.flipped + } + + transitions: Transition { + NumberAnimation { target: rotation; property: "angle"; duration: 4000 } + } + + MouseArea { + anchors.fill: parent + onClicked: flipable.flipped = !flipable.flipped + } +} +//! [0] + diff --git a/doc/src/snippets/qml/flow.qml b/doc/src/snippets/qml/flow.qml new file mode 100644 index 0000000000..1141269986 --- /dev/null +++ b/doc/src/snippets/qml/flow.qml @@ -0,0 +1,64 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +//! [document] +import QtQuick 2.0 + +Rectangle { + color: "lightblue" + width: 300; height: 200 + +//! [flow item] + Flow { + anchors.fill: parent + anchors.margins: 4 + spacing: 10 + + Text { text: "Text"; font.pixelSize: 40 } + Text { text: "items"; font.pixelSize: 40 } + Text { text: "flowing"; font.pixelSize: 40 } + Text { text: "inside"; font.pixelSize: 40 } + Text { text: "a"; font.pixelSize: 40 } + Text { text: "Flow"; font.pixelSize: 40 } + Text { text: "item"; font.pixelSize: 40 } + } +//! [flow item] +} +//! [document] diff --git a/doc/src/snippets/qml/focus/MyClickableWidget.qml b/doc/src/snippets/qml/focus/MyClickableWidget.qml new file mode 100644 index 0000000000..7017f1bcb6 --- /dev/null +++ b/doc/src/snippets/qml/focus/MyClickableWidget.qml @@ -0,0 +1,69 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +import QtQuick 2.0 + +//! [clickable in focusscope] +FocusScope { + + id: scope + + //FocusScope needs to bind to visual properties of the children + property alias color: rectangle.color + x: rectangle.x; y: rectangle.y + width: rectangle.width; height: rectangle.height + + Rectangle { + id: rectangle + anchors.centerIn: parent + color: "lightsteelblue"; width: 175; height: 25; radius: 10; smooth: true + Text { id: label; anchors.centerIn: parent } + focus: true + Keys.onPressed: { + if (event.key == Qt.Key_A) + label.text = 'Key A was pressed' + else if (event.key == Qt.Key_B) + label.text = 'Key B was pressed' + else if (event.key == Qt.Key_C) + label.text = 'Key C was pressed' + } + } + MouseArea { anchors.fill: parent; onClicked: { scope.focus = true } } +} +//! [clickable in focusscope] diff --git a/doc/src/snippets/qml/focus/MyWidget.qml b/doc/src/snippets/qml/focus/MyWidget.qml new file mode 100644 index 0000000000..5899b18ae0 --- /dev/null +++ b/doc/src/snippets/qml/focus/MyWidget.qml @@ -0,0 +1,58 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +//! [document] +import QtQuick 2.0 + +//! [mywidget] +Rectangle { + id: widget + color: "lightsteelblue"; width: 175; height: 25; radius: 10; smooth: true + Text { id: label; anchors.centerIn: parent} + focus: true + Keys.onPressed: { + if (event.key == Qt.Key_A) + label.text = 'Key A was pressed' + else if (event.key == Qt.Key_B) + label.text = 'Key B was pressed' + else if (event.key == Qt.Key_C) + label.text = 'Key C was pressed' + } +} +//! [mywidget] diff --git a/doc/src/snippets/qml/focus/advancedFocus.qml b/doc/src/snippets/qml/focus/advancedFocus.qml new file mode 100644 index 0000000000..ec4efca450 --- /dev/null +++ b/doc/src/snippets/qml/focus/advancedFocus.qml @@ -0,0 +1,67 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +import QtQuick 2.0 + +//! [FocusScope delegate] +Rectangle { + color: "lightsteelblue"; width: 100; height: 50 + + ListView { + anchors.fill: parent + focus: true + + model: ListModel { + ListElement { name: "Bob" } + ListElement { name: "John" } + ListElement { name: "Michael" } + } + + delegate: FocusScope { + width: childrenRect.width; height: childrenRect.height + x:childrenRect.x; y: childrenRect.y + TextInput { + focus: true + text: name + Keys.onReturnPressed: console.log(name) + } + } + } +} +//! [FocusScope delegate] diff --git a/doc/src/snippets/qml/focus/basicwidget.qml b/doc/src/snippets/qml/focus/basicwidget.qml new file mode 100644 index 0000000000..bd5778948a --- /dev/null +++ b/doc/src/snippets/qml/focus/basicwidget.qml @@ -0,0 +1,59 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +import QtQuick 2.0 + +//! [focus true] +Rectangle { + color: "lightsteelblue"; width: 240; height: 25 + Text { id: myText } + Item { + id: keyHandler + focus: true + Keys.onPressed: { + if (event.key == Qt.Key_A) + myText.text = 'Key A was pressed' + else if (event.key == Qt.Key_B) + myText.text = 'Key B was pressed' + else if (event.key == Qt.Key_C) + myText.text = 'Key C was pressed' + } + } +} +//! [focus true] diff --git a/doc/src/snippets/qml/focus/clickablewidget.qml b/doc/src/snippets/qml/focus/clickablewidget.qml new file mode 100644 index 0000000000..81bd5f7e51 --- /dev/null +++ b/doc/src/snippets/qml/focus/clickablewidget.qml @@ -0,0 +1,61 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the FOO module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +import QtQuick 2.0 + +//! [clickable window] +Rectangle { + id: window + + color: "white"; width: 240; height: 150 + + Column { + anchors.centerIn: parent; spacing: 15 + + MyClickableWidget { + focus: true //set this MyWidget to receive the focus + color: "lightblue" + } + MyClickableWidget { + color: "palegreen" + } + } + +} +//! [clickable window] diff --git a/doc/src/snippets/qml/focus/myfocusscopewidget.qml b/doc/src/snippets/qml/focus/myfocusscopewidget.qml new file mode 100644 index 0000000000..f568c39a32 --- /dev/null +++ b/doc/src/snippets/qml/focus/myfocusscopewidget.qml @@ -0,0 +1,68 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +//! [document] +import QtQuick 2.0 + +//! [widget in focusscope] +FocusScope { + + //FocusScope needs to bind to visual properties of the Rectangle + property alias color: rectangle.color + x: rectangle.x; y: rectangle.y + width: rectangle.width; height: rectangle.height + + Rectangle { + id: rectangle + anchors.centerIn: parent + color: "lightsteelblue"; width: 175; height: 25; radius: 10; smooth: true + Text { id: label; anchors.centerIn: parent } + focus: true + Keys.onPressed: { + if (event.key == Qt.Key_A) + label.text = 'Key A was pressed' + else if (event.key == Qt.Key_B) + label.text = 'Key B was pressed' + else if (event.key == Qt.Key_C) + label.text = 'Key C was pressed' + } + } +} +//! [widget in focusscope] +//! [document] diff --git a/doc/src/snippets/qml/focus/rectangle.qml b/doc/src/snippets/qml/focus/rectangle.qml new file mode 100644 index 0000000000..cb00f1f11a --- /dev/null +++ b/doc/src/snippets/qml/focus/rectangle.qml @@ -0,0 +1,62 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the FOO module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +import QtQuick 2.0 + +//! [simple key event] +Rectangle { + width: 100; height: 100 + focus: true + Keys.onPressed: { + if (event.key == Qt.Key_A) { + console.log('Key A was pressed'); + event.accepted = true; + } + } +//! [simple key event] + +//! [active focus] + Text { + text: activeFocus ? "I have active focus!" : "I do not have active focus" + } +//! [active focus] + +//! [simple key event end] +} +//! [simple key event end] diff --git a/doc/src/snippets/qml/focus/widget.qml b/doc/src/snippets/qml/focus/widget.qml new file mode 100644 index 0000000000..5ee8a71846 --- /dev/null +++ b/doc/src/snippets/qml/focus/widget.qml @@ -0,0 +1,61 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +import QtQuick 2.0 + +//! [window] + +//Window code that imports MyWidget +Rectangle { + id: window + color: "white"; width: 240; height: 150 + + Column { + anchors.centerIn: parent; spacing: 15 + + MyWidget { + focus: true //set this MyWidget to receive the focus + color: "lightblue" + } + MyWidget { + color: "palegreen" + } + } +} +//! [window] diff --git a/doc/src/snippets/qml/folderlistmodel.qml b/doc/src/snippets/qml/folderlistmodel.qml new file mode 100644 index 0000000000..5878640567 --- /dev/null +++ b/doc/src/snippets/qml/folderlistmodel.qml @@ -0,0 +1,61 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +//![0] +import QtQuick 2.0 +import Qt.labs.folderlistmodel 1.0 + +ListView { + width: 200; height: 400 + + FolderListModel { + id: folderModel + nameFilters: ["*.qml"] + } + + Component { + id: fileDelegate + Text { text: fileName } + } + + model: folderModel + delegate: fileDelegate +} +//![0] diff --git a/doc/src/snippets/qml/gradient.qml b/doc/src/snippets/qml/gradient.qml new file mode 100644 index 0000000000..a5af6a7930 --- /dev/null +++ b/doc/src/snippets/qml/gradient.qml @@ -0,0 +1,52 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +//![code] +Rectangle { + width: 100; height: 100 + gradient: Gradient { + GradientStop { position: 0.0; color: "red" } + GradientStop { position: 0.33; color: "yellow" } + GradientStop { position: 1.0; color: "green" } + } +} +//![code] diff --git a/doc/src/snippets/qml/grid-spacing.qml b/doc/src/snippets/qml/grid-spacing.qml new file mode 100644 index 0000000000..1385492ac6 --- /dev/null +++ b/doc/src/snippets/qml/grid-spacing.qml @@ -0,0 +1,60 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +//! [document] +import QtQuick 2.0 + +Rectangle { + width: 112; height: 112 + color: "#303030" + + Grid { + anchors.horizontalCenter: parent.horizontalCenter + anchors.verticalCenter: parent.verticalCenter + columns: 2 + spacing: 6 + + Rectangle { color: "#aa6666"; width: 50; height: 50 } + Rectangle { color: "#aaaa66"; width: 50; height: 50 } + Rectangle { color: "#9999aa"; width: 50; height: 50 } + Rectangle { color: "#6666aa"; width: 50; height: 50 } + } +} +//! [document] diff --git a/doc/src/snippets/qml/grid/grid-items.qml b/doc/src/snippets/qml/grid/grid-items.qml new file mode 100644 index 0000000000..8afb170f75 --- /dev/null +++ b/doc/src/snippets/qml/grid/grid-items.qml @@ -0,0 +1,58 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Rectangle { + width: 112; height: 112 + color: "#303030" + + Grid { + anchors.horizontalCenter: parent.horizontalCenter + anchors.verticalCenter: parent.verticalCenter + columns: 2 + spacing: 6 + + Rectangle { color: "#aa6666"; width: 50; height: 50 } + Rectangle { color: "#aaaa66"; width: 50; height: 50 } + Rectangle { color: "#9999aa"; width: 50; height: 50 } + Rectangle { color: "#6666aa"; width: 50; height: 50 } + } +} diff --git a/doc/src/snippets/qml/grid/grid-no-spacing.qml b/doc/src/snippets/qml/grid/grid-no-spacing.qml new file mode 100644 index 0000000000..c44eadce63 --- /dev/null +++ b/doc/src/snippets/qml/grid/grid-no-spacing.qml @@ -0,0 +1,57 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Rectangle { + width: 112; height: 112 + color: "#303030" + + Grid { + anchors.horizontalCenter: parent.horizontalCenter + anchors.verticalCenter: parent.verticalCenter + columns: 2 + + Rectangle { color: "#aa6666"; width: 50; height: 50 } + Rectangle { color: "#aaaa66"; width: 50; height: 50 } + Rectangle { color: "#9999aa"; width: 50; height: 50 } + Rectangle { color: "#6666aa"; width: 50; height: 50 } + } +} diff --git a/doc/src/snippets/qml/grid/grid-spacing.qml b/doc/src/snippets/qml/grid/grid-spacing.qml new file mode 100644 index 0000000000..1385492ac6 --- /dev/null +++ b/doc/src/snippets/qml/grid/grid-spacing.qml @@ -0,0 +1,60 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +//! [document] +import QtQuick 2.0 + +Rectangle { + width: 112; height: 112 + color: "#303030" + + Grid { + anchors.horizontalCenter: parent.horizontalCenter + anchors.verticalCenter: parent.verticalCenter + columns: 2 + spacing: 6 + + Rectangle { color: "#aa6666"; width: 50; height: 50 } + Rectangle { color: "#aaaa66"; width: 50; height: 50 } + Rectangle { color: "#9999aa"; width: 50; height: 50 } + Rectangle { color: "#6666aa"; width: 50; height: 50 } + } +} +//! [document] diff --git a/doc/src/snippets/qml/grid/grid.qml b/doc/src/snippets/qml/grid/grid.qml new file mode 100644 index 0000000000..7fb1bb6f5a --- /dev/null +++ b/doc/src/snippets/qml/grid/grid.qml @@ -0,0 +1,53 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +//! [document] +import QtQuick 2.0 + +Grid { + columns: 3 + spacing: 2 + Rectangle { color: "red"; width: 50; height: 50 } + Rectangle { color: "green"; width: 20; height: 50 } + Rectangle { color: "blue"; width: 50; height: 20 } + Rectangle { color: "cyan"; width: 50; height: 50 } + Rectangle { color: "magenta"; width: 10; height: 10 } +} +//! [document] diff --git a/doc/src/snippets/qml/gridview/ContactModel.qml b/doc/src/snippets/qml/gridview/ContactModel.qml new file mode 100644 index 0000000000..f744c1e73f --- /dev/null +++ b/doc/src/snippets/qml/gridview/ContactModel.qml @@ -0,0 +1,63 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +//![0] +import QtQuick 2.0 + +ListModel { + + ListElement { + name: "Jim Williams" + portrait: "pics/portrait.png" + } + ListElement { + name: "John Brown" + portrait: "pics/portrait.png" + } + ListElement { + name: "Bill Smyth" + portrait: "pics/portrait.png" + } + ListElement { + name: "Sam Wise" + portrait: "pics/portrait.png" + } +} +//![0] diff --git a/doc/src/snippets/qml/gridview/gridview.qml b/doc/src/snippets/qml/gridview/gridview.qml new file mode 100644 index 0000000000..d3b37d1338 --- /dev/null +++ b/doc/src/snippets/qml/gridview/gridview.qml @@ -0,0 +1,163 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +//![import] +import QtQuick 2.0 +//![import] + +Rectangle { + width: childrenRect.width; height: childrenRect.height + +Row { + +//![classdocs simple] +GridView { + width: 300; height: 200 + + model: ContactModel {} + delegate: Column { + Image { source: portrait; anchors.horizontalCenter: parent.horizontalCenter } + Text { text: name; anchors.horizontalCenter: parent.horizontalCenter } + } +} +//![classdocs simple] + + +//![classdocs advanced] +Rectangle { + width: 300; height: 200 + + Component { + id: contactDelegate + Item { + width: grid.cellWidth; height: grid.cellHeight + Column { + anchors.fill: parent + Image { source: portrait; anchors.horizontalCenter: parent.horizontalCenter } + Text { text: name; anchors.horizontalCenter: parent.horizontalCenter } + } + } + } + + GridView { + id: grid + anchors.fill: parent + cellWidth: 80; cellHeight: 80 + + model: ContactModel {} + delegate: contactDelegate + highlight: Rectangle { color: "lightsteelblue"; radius: 5 } + focus: true + } +} +//![classdocs advanced] + +//![delayRemove] +Component { + id: delegate + Item { + GridView.onRemove: SequentialAnimation { + PropertyAction { target: wrapper; property: "GridView.delayRemove"; value: true } + NumberAnimation { target: wrapper; property: "scale"; to: 0; duration: 250; easing.type: Easing.InOutQuad } + PropertyAction { target: wrapper; property: "GridView.delayRemove"; value: false } + } + } +} +//![delayRemove] + +//![highlightFollowsCurrentItem] +Component { + id: highlight + Rectangle { + width: view.cellWidth; height: view.cellHeight + color: "lightsteelblue"; radius: 5 + x: view.currentItem.x + y: view.currentItem.y + Behavior on x { SpringAnimation { spring: 3; damping: 0.2 } } + Behavior on y { SpringAnimation { spring: 3; damping: 0.2 } } + } +} + +GridView { + id: view + width: 300; height: 200 + cellWidth: 80; cellHeight: 80 + + model: ContactModel {} + delegate: Column { + Image { source: portrait; anchors.horizontalCenter: parent.horizontalCenter } + Text { text: name; anchors.horizontalCenter: parent.horizontalCenter } + } + + highlight: highlight + highlightFollowsCurrentItem: false + focus: true +} +//![highlightFollowsCurrentItem] + +//![isCurrentItem] +GridView { + width: 300; height: 200 + cellWidth: 80; cellHeight: 80 + + Component { + id: contactsDelegate + Rectangle { + id: wrapper + width: 80 + height: 80 + color: GridView.isCurrentItem ? "black" : "red" + Text { + id: contactInfo + text: name + ": " + number + color: wrapper.GridView.isCurrentItem ? "red" : "black" + } + } + } + + model: ContactModel {} + delegate: contactsDelegate + focus: true +} +//![isCurrentItem] + +} + +} diff --git a/doc/src/snippets/qml/image.qml b/doc/src/snippets/qml/image.qml new file mode 100644 index 0000000000..61724ffeea --- /dev/null +++ b/doc/src/snippets/qml/image.qml @@ -0,0 +1,47 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +//! [document] +import QtQuick 2.0 + +Image { + source: "pics/qtlogo.png" +} +//! [document] diff --git a/doc/src/snippets/qml/imports/chart.qml b/doc/src/snippets/qml/imports/chart.qml new file mode 100644 index 0000000000..d5a2d3bf45 --- /dev/null +++ b/doc/src/snippets/qml/imports/chart.qml @@ -0,0 +1,46 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +//! [import] +import Charts 1.0 +//! [import] + +Item { +} diff --git a/doc/src/snippets/qml/imports/installed-module.qml b/doc/src/snippets/qml/imports/installed-module.qml new file mode 100644 index 0000000000..c263ea89ed --- /dev/null +++ b/doc/src/snippets/qml/imports/installed-module.qml @@ -0,0 +1,47 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +//! [imports] +import QtQuick 2.0 +import com.nokia.qml.mymodule 1.0 +//! [imports] + +Item { +} diff --git a/doc/src/snippets/qml/imports/merged-named-imports.qml b/doc/src/snippets/qml/imports/merged-named-imports.qml new file mode 100644 index 0000000000..a75687c740 --- /dev/null +++ b/doc/src/snippets/qml/imports/merged-named-imports.qml @@ -0,0 +1,47 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +//! [imports] +import QtQuick 2.0 as Nokia +import Ovi 1.0 as Nokia +//! [imports] + +Item { +} diff --git a/doc/src/snippets/qml/imports/named-imports.qml b/doc/src/snippets/qml/imports/named-imports.qml new file mode 100644 index 0000000000..125e6cfa27 --- /dev/null +++ b/doc/src/snippets/qml/imports/named-imports.qml @@ -0,0 +1,61 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +//! [imports] +import QtQuick 2.0 as QtLibrary +import "../MyComponents" as MyComponents +import com.nokia.qml.mymodule 1.0 as MyModule +//! [imports] + +Item { + //! [imported items] + QtLibrary.Rectangle { + // ... + } + + MyComponents.Slider { + // ... + } + + MyModule.SomeComponent { + // ... + } + //! [imported items] +} diff --git a/doc/src/snippets/qml/imports/network-imports.qml b/doc/src/snippets/qml/imports/network-imports.qml new file mode 100644 index 0000000000..f039c44f1e --- /dev/null +++ b/doc/src/snippets/qml/imports/network-imports.qml @@ -0,0 +1,47 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +//! [imports] +import "http://www.my-server.com/MyQMLProject/MyComponents" +import "http://www.my-server.com/MyQMLProject/MyComponents" 1.0 +//! [imports] + +Item { +} diff --git a/doc/src/snippets/qml/imports/qtquick-1.0.qml b/doc/src/snippets/qml/imports/qtquick-1.0.qml new file mode 100644 index 0000000000..481bc12e7e --- /dev/null +++ b/doc/src/snippets/qml/imports/qtquick-1.0.qml @@ -0,0 +1,46 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +//! [import] +import QtQuick 2.0 +//! [import] + +Item { +} diff --git a/doc/src/snippets/qml/imports/timeexample.qml b/doc/src/snippets/qml/imports/timeexample.qml new file mode 100644 index 0000000000..4d79dbe15e --- /dev/null +++ b/doc/src/snippets/qml/imports/timeexample.qml @@ -0,0 +1,46 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +//! [import] +import com.nokia.TimeExample 1.0 +//! [import] + +Item { +} diff --git a/doc/src/snippets/qml/integrating-javascript/connectjs.qml b/doc/src/snippets/qml/integrating-javascript/connectjs.qml new file mode 100644 index 0000000000..89c9ebc21a --- /dev/null +++ b/doc/src/snippets/qml/integrating-javascript/connectjs.qml @@ -0,0 +1,57 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +//![0] +import QtQuick 2.0 +import "script.js" as MyScript + +Item { + id: item + width: 200; height: 200 + + MouseArea { + id: mouseArea + anchors.fill: parent + } + + Component.onCompleted: { + mouseArea.clicked.connect(MyScript.jsFunction) + } +} +//![0] diff --git a/doc/src/snippets/qml/integrating-javascript/includejs/app.qml b/doc/src/snippets/qml/integrating-javascript/includejs/app.qml new file mode 100644 index 0000000000..0dd7b533a6 --- /dev/null +++ b/doc/src/snippets/qml/integrating-javascript/includejs/app.qml @@ -0,0 +1,56 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +//![0] +import QtQuick 2.0 +import "script.js" as MyScript + +Item { + width: 100; height: 100 + + MouseArea { + anchors.fill: parent + onClicked: { + MyScript.showCalculations(10) + console.log("Call factorial() from QML:", + MyScript.factorial(10)) + } + } +} +//![0] diff --git a/doc/src/snippets/qml/integrating-javascript/includejs/factorial.js b/doc/src/snippets/qml/integrating-javascript/includejs/factorial.js new file mode 100644 index 0000000000..a7bc4ac69f --- /dev/null +++ b/doc/src/snippets/qml/integrating-javascript/includejs/factorial.js @@ -0,0 +1,49 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +//![0] +// factorial.js +function factorial(a) { + a = parseInt(a); + if (a <= 0) + return 1; + else + return a * factorial(a - 1); +} +//![0] diff --git a/doc/src/snippets/qml/integrating-javascript/includejs/script.js b/doc/src/snippets/qml/integrating-javascript/includejs/script.js new file mode 100644 index 0000000000..964b2f5e8a --- /dev/null +++ b/doc/src/snippets/qml/integrating-javascript/includejs/script.js @@ -0,0 +1,48 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +//![0] +// script.js +Qt.include("factorial.js") + +function showCalculations(value) { + console.log("Call factorial() from script.js:", + factorial(value)); +} +//![0] diff --git a/doc/src/snippets/qml/integrating-javascript/scarceresources/avatarExample.cpp b/doc/src/snippets/qml/integrating-javascript/scarceresources/avatarExample.cpp new file mode 100644 index 0000000000..e018a68292 --- /dev/null +++ b/doc/src/snippets/qml/integrating-javascript/scarceresources/avatarExample.cpp @@ -0,0 +1,124 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "avatarExample.h" +#include +#include + +void registerTypes() +{ +//![0] + qmlRegisterType("Qt.example", 1, 0, "AvatarExample"); +//![0] +} + +void expectOne() +{ +//![1] +QQmlComponent component(&engine, "exampleOne.qml"); +QObject *object = component.create(); +// The scarce resource will have been released automatically +// by this point, after the binding expression was evaluated. +delete object; +//![1] +} + +void expectTwo() +{ +//![2] +QQmlComponent component(&engine, "exampleTwo.qml"); +QObject *object = component.create(); +// The scarce resource will not have been released automatically +// after the binding expression was evaluated. +// Since the scarce resource was not released explicitly prior +// to the binding expression being evaluated, we get: +bool expectedResult = (object->property("avatar").isValid() == true); +delete object; +//![2] +} + +void expectThree() +{ +//![3] +QQmlComponent component(&engine, "exampleThree.qml"); +QObject *object = component.create(); +// The resource was preserved explicitly during evaluation of the +// JavaScript expression. Thus, during property assignment, the +// scarce resource was still valid, and so we get: +bool expectedResult = (object->property("avatar").isValid() == true); +// The scarce resource will not be released until all references to +// the resource are released, and the JavaScript garbage collector runs. +delete object; +//![3] +} + +void expectFour() +{ +//![4] +QQmlComponent component(&engine, "exampleFour.qml"); +QObject *object = component.create(); +// The scarce resource was explicitly preserved by the client during +// the importAvatar() function, and so the scarce resource +// remains valid until the explicit call to releaseAvatar(). As such, +// we get the expected results: +bool expectedResultOne = (object->property("avatarOne").isValid() == true); +bool expectedResultTwo = (object->property("avatarTwo").isValid() == false); +// Because the scarce resource referenced by avatarTwo was released explicitly, +// it will no longer be consuming any system resources (beyond what a normal +// JS Object would; that small overhead will exist until the JS GC runs, as per +// any other JavaScript object). +delete object; +//![4] +} + +void expectFive() +{ +//![5] +QQmlComponent component(&engine, "exampleFive.qml"); +QObject *object = component.create(); +// We have the expected results: +bool expectedResultOne = (object->property("avatarOne").isValid() == false); +bool expectedResultTwo = (object->property("avatarTwo").isValid() == false); +// Because although only avatarTwo was explicitly released, +// avatarOne and avatarTwo were referencing the same +// scarce resource. +delete object; +//![5] +} diff --git a/doc/src/snippets/qml/integrating-javascript/scarceresources/avatarExample.h b/doc/src/snippets/qml/integrating-javascript/scarceresources/avatarExample.h new file mode 100644 index 0000000000..d9fbff4fde --- /dev/null +++ b/doc/src/snippets/qml/integrating-javascript/scarceresources/avatarExample.h @@ -0,0 +1,73 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef AVATAREXAMPLE_P_H +#define AVATAREXAMPLE_P_H + +#include +#include + +//![0] +// avatarExample.h +class AvatarExample : public QObject +{ + Q_OBJECT + Q_PROPERTY(QPixmap avatar READ avatar WRITE setAvatar NOTIFY avatarChanged) +public: + AvatarExample(QObject *parent = 0) + : QObject(parent), m_value(100, 100) + { + m_value.fill(Qt::blue); + } + + ~AvatarExample() {} + + QPixmap avatar() const { return m_value; } + void setAvatar(QPixmap v) { m_value = v; emit avatarChanged(); } + +signals: + void avatarChanged(); + +private: + QPixmap m_value; +}; +//![0] + +#endif diff --git a/doc/src/snippets/qml/integrating-javascript/scarceresources/exampleFive.qml b/doc/src/snippets/qml/integrating-javascript/scarceresources/exampleFive.qml new file mode 100644 index 0000000000..7cfab16a51 --- /dev/null +++ b/doc/src/snippets/qml/integrating-javascript/scarceresources/exampleFive.qml @@ -0,0 +1,54 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +//![0] +// exampleFive.qml +import QtQuick 2.0 +import Qt.example 1.0 +import "exampleFour.js" as ExampleFourJs // use factory from example four + +QtObject { + property var avatarOne: ExampleFourJs.importAvatar() + property var avatarTwo: avatarOne + + Component.onCompleted: { + ExampleFourJs.releaseAvatar(avatarTwo); + } +} +//![0] \ No newline at end of file diff --git a/doc/src/snippets/qml/integrating-javascript/scarceresources/exampleFour.js b/doc/src/snippets/qml/integrating-javascript/scarceresources/exampleFour.js new file mode 100644 index 0000000000..d104e6f6c7 --- /dev/null +++ b/doc/src/snippets/qml/integrating-javascript/scarceresources/exampleFour.js @@ -0,0 +1,56 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +//![0] +// exampleFour.js +.import Qt.example 1.0 as QtExample + +function importAvatar() { + var component = Qt.createComponent("exampleTwo.qml"); + var exampleOneElement = component.createObject(null); + var avatarExample = exampleOneElement.a; + var retn = avatarExample.avatar; + retn.preserve(); + return retn; +} + +function releaseAvatar(avatar) { + avatar.destroy(); +} +//![0] \ No newline at end of file diff --git a/doc/src/snippets/qml/integrating-javascript/scarceresources/exampleFour.qml b/doc/src/snippets/qml/integrating-javascript/scarceresources/exampleFour.qml new file mode 100644 index 0000000000..f5811602dc --- /dev/null +++ b/doc/src/snippets/qml/integrating-javascript/scarceresources/exampleFour.qml @@ -0,0 +1,56 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +//![0] +// exampleFour.qml +import QtQuick 2.0 +import Qt.example 1.0 +import "exampleFour.js" as ExampleFourJs + +QtObject { + property var avatarOne + property var avatarTwo + + Component.onCompleted: { + avatarOne = ExampleFourJs.importAvatar(); + avatarTwo = ExampleFourJs.importAvatar(); + ExampleFourJs.releaseAvatar(avatarTwo); + } +} +//![0] \ No newline at end of file diff --git a/doc/src/snippets/qml/integrating-javascript/scarceresources/exampleOne.qml b/doc/src/snippets/qml/integrating-javascript/scarceresources/exampleOne.qml new file mode 100644 index 0000000000..cf9b3ebc5d --- /dev/null +++ b/doc/src/snippets/qml/integrating-javascript/scarceresources/exampleOne.qml @@ -0,0 +1,54 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +//![0] +// exampleOne.qml +import QtQuick 2.0 +import Qt.example 1.0 + +QtObject { + property AvatarExample a; + a: AvatarExample { id: example } + property var avatarWidth: example.avatar,100 + // Here, we use "example.avatar,100" purely for illustration. + // The value of `avatarWidth' will be 100 after evaluation. + // E.g., you could imagine some js function which takes + // an avatar, and returns the width of the avatar. +} +//![0] \ No newline at end of file diff --git a/doc/src/snippets/qml/integrating-javascript/scarceresources/exampleThree.js b/doc/src/snippets/qml/integrating-javascript/scarceresources/exampleThree.js new file mode 100644 index 0000000000..44df13f7a4 --- /dev/null +++ b/doc/src/snippets/qml/integrating-javascript/scarceresources/exampleThree.js @@ -0,0 +1,58 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +//![0] +// exampleThree.js +.import Qt.example 1.0 as QtExample + +var component = Qt.createComponent("exampleTwo.qml"); +var exampleOneElement = component.createObject(null); +var avatarExample = exampleOneElement.a; +var retn = avatarExample.avatar; + +// without the following call, the scarce resource held +// by retn would be automatically released by the engine +// after the import statement in exampleTwo.qml, prior +// to the variable assignment. +retn.preserve(); + +function importAvatar() { + return retn; +} +//![0] \ No newline at end of file diff --git a/doc/src/snippets/qml/integrating-javascript/scarceresources/exampleThree.qml b/doc/src/snippets/qml/integrating-javascript/scarceresources/exampleThree.qml new file mode 100644 index 0000000000..3f12458cec --- /dev/null +++ b/doc/src/snippets/qml/integrating-javascript/scarceresources/exampleThree.qml @@ -0,0 +1,49 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +//![0] +// exampleThree.qml +import QtQuick 2.0 +import Qt.example 1.0 +import "exampleThree.js" as ExampleThreeJs + +QtObject { + property var avatar: ExampleThreeJs.importAvatar() +} +//![0] \ No newline at end of file diff --git a/doc/src/snippets/qml/integrating-javascript/scarceresources/exampleTwo.qml b/doc/src/snippets/qml/integrating-javascript/scarceresources/exampleTwo.qml new file mode 100644 index 0000000000..f322fb9ed9 --- /dev/null +++ b/doc/src/snippets/qml/integrating-javascript/scarceresources/exampleTwo.qml @@ -0,0 +1,51 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +//![0] +// exampleTwo.qml +import QtQuick 2.0 +import Qt.example 1.0 + +QtObject { + property AvatarExample a; + a: AvatarExample { id: example } + property var avatar: example.avatar + // Now `avatar' contains a reference to the scarce resource. +} +//![0] \ No newline at end of file diff --git a/doc/src/snippets/qml/integrating-javascript/script.js b/doc/src/snippets/qml/integrating-javascript/script.js new file mode 100644 index 0000000000..006cf1aead --- /dev/null +++ b/doc/src/snippets/qml/integrating-javascript/script.js @@ -0,0 +1,47 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +//![0] +// script.js + +function jsFunction() { + console.log("Called JavaScript function!") +} +//![0] + diff --git a/doc/src/snippets/qml/keynavigation.qml b/doc/src/snippets/qml/keynavigation.qml new file mode 100644 index 0000000000..4854ecd0ed --- /dev/null +++ b/doc/src/snippets/qml/keynavigation.qml @@ -0,0 +1,84 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +//![0] +import QtQuick 2.0 + +Grid { + width: 100; height: 100 + columns: 2 + + Rectangle { + id: topLeft + width: 50; height: 50 + color: focus ? "red" : "lightgray" + focus: true + + KeyNavigation.right: topRight + KeyNavigation.down: bottomLeft + } + + Rectangle { + id: topRight + width: 50; height: 50 + color: focus ? "red" : "lightgray" + + KeyNavigation.left: topLeft + KeyNavigation.down: bottomRight + } + + Rectangle { + id: bottomLeft + width: 50; height: 50 + color: focus ? "red" : "lightgray" + + KeyNavigation.right: bottomRight + KeyNavigation.up: topLeft + } + + Rectangle { + id: bottomRight + width: 50; height: 50 + color: focus ? "red" : "lightgray" + + KeyNavigation.left: bottomLeft + KeyNavigation.up: topRight + } +} +//![0] diff --git a/doc/src/snippets/qml/keys/keys-handler.qml b/doc/src/snippets/qml/keys/keys-handler.qml new file mode 100644 index 0000000000..21fc98e23d --- /dev/null +++ b/doc/src/snippets/qml/keys/keys-handler.qml @@ -0,0 +1,60 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Item { + width: 400; height: 400 + +//! [key item] +Item { + anchors.fill: parent + focus: true + Keys.onLeftPressed: console.log("move left") +} +//! [key item] + +Text { + anchors.fill: parent + text: "Press a cursor key" + horizontalAlignment: Text.AlignHCenter + verticalAlignment: Text.AlignVCenter +} +} diff --git a/doc/src/snippets/qml/keys/keys-pressed.qml b/doc/src/snippets/qml/keys/keys-pressed.qml new file mode 100644 index 0000000000..3c9a2d9dce --- /dev/null +++ b/doc/src/snippets/qml/keys/keys-pressed.qml @@ -0,0 +1,65 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Item { + width: 400; height: 400 + +//! [key item] +Item { + anchors.fill: parent + focus: true + Keys.onPressed: { + if (event.key == Qt.Key_Left) { + console.log("move left"); + event.accepted = true; + } + } +} +//! [key item] + +Text { + anchors.fill: parent + text: "Press a cursor key" + horizontalAlignment: Text.AlignHCenter + verticalAlignment: Text.AlignVCenter +} +} diff --git a/doc/src/snippets/qml/layoutmirroring.qml b/doc/src/snippets/qml/layoutmirroring.qml new file mode 100644 index 0000000000..5daf3f58b3 --- /dev/null +++ b/doc/src/snippets/qml/layoutmirroring.qml @@ -0,0 +1,71 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +//![0] +import QtQuick 2.0 + +Rectangle { + LayoutMirroring.enabled: true + LayoutMirroring.childrenInherit: true + + width: 300; height: 50 + color: "yellow" + border.width: 1 + + Row { + anchors { left: parent.left; margins: 5 } + y: 5; spacing: 5 + + Repeater { + model: 5 + + Rectangle { + color: "red" + opacity: (5 - index) / 5 + width: 40; height: 40 + + Text { + text: index + 1 + anchors.centerIn: parent + } + } + } + } +} +//![0] diff --git a/doc/src/snippets/qml/listmodel-modify.qml b/doc/src/snippets/qml/listmodel-modify.qml new file mode 100644 index 0000000000..308453b393 --- /dev/null +++ b/doc/src/snippets/qml/listmodel-modify.qml @@ -0,0 +1,96 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +import QtQuick 2.0 + +Rectangle { + width: 200; height: 200 + +ListModel { + id: fruitModel + + ListElement { + name: "Apple" + cost: 2.45 + attributes: [ + ListElement { description: "Core" }, + ListElement { description: "Deciduous" } + ] + } + ListElement { + name: "Orange" + cost: 3.25 + attributes: [ + ListElement { description: "Citrus" } + ] + } + ListElement { + name: "Banana" + cost: 1.95 + attributes: [ + ListElement { description: "Tropical" }, + ListElement { description: "Seedless" } + ] + } +} + +//![delegate] + Component { + id: fruitDelegate + Item { + width: 200; height: 50 + Text { text: name } + Text { text: '$' + cost; anchors.right: parent.right } + + // Double the price when clicked. + MouseArea { + anchors.fill: parent + onClicked: fruitModel.setProperty(index, "cost", cost * 2) + } + } + } +//![delegate] + +ListView { + width: 200; height: 200 + model: fruitModel + delegate: fruitDelegate +} + +} diff --git a/doc/src/snippets/qml/listmodel-nested.qml b/doc/src/snippets/qml/listmodel-nested.qml new file mode 100644 index 0000000000..bac95608e1 --- /dev/null +++ b/doc/src/snippets/qml/listmodel-nested.qml @@ -0,0 +1,102 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +import QtQuick 2.0 + +Rectangle { + width: 200; height: 200 + + +//![model] +ListModel { + id: fruitModel + + ListElement { + name: "Apple" + cost: 2.45 + attributes: [ + ListElement { description: "Core" }, + ListElement { description: "Deciduous" } + ] + } + ListElement { + name: "Orange" + cost: 3.25 + attributes: [ + ListElement { description: "Citrus" } + ] + } + ListElement { + name: "Banana" + cost: 1.95 + attributes: [ + ListElement { description: "Tropical" }, + ListElement { description: "Seedless" } + ] + } +} +//![model] + +//![delegate] +Component { + id: fruitDelegate + Item { + width: 200; height: 50 + Text { id: nameField; text: name } + Text { text: '$' + cost; anchors.left: nameField.right } + Row { + anchors.top: nameField.bottom + spacing: 5 + Text { text: "Attributes:" } + Repeater { + model: attributes + Text { text: description } + } + } + } +} +//![delegate] + +ListView { + width: 200; height: 200 + model: fruitModel + delegate: fruitDelegate +} + +} diff --git a/doc/src/snippets/qml/listmodel-simple.qml b/doc/src/snippets/qml/listmodel-simple.qml new file mode 100644 index 0000000000..e8c4cea68e --- /dev/null +++ b/doc/src/snippets/qml/listmodel-simple.qml @@ -0,0 +1,79 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +//![0] +import QtQuick 2.0 + +Rectangle { + width: 200; height: 200 + + ListModel { + id: fruitModel +//![0] + ListElement { + name: "Apple" + cost: 2.45 + } + ListElement { + name: "Orange" + cost: 3.25 + } + ListElement { + name: "Banana" + cost: 1.95 + } +//![1] + } + + Component { + id: fruitDelegate + Row { + spacing: 10 + Text { text: name } + Text { text: '$' + cost } + } + } + + ListView { + anchors.fill: parent + model: fruitModel + delegate: fruitDelegate + } +} +//![1] diff --git a/doc/src/snippets/qml/listmodel.qml b/doc/src/snippets/qml/listmodel.qml new file mode 100644 index 0000000000..e93732e2ee --- /dev/null +++ b/doc/src/snippets/qml/listmodel.qml @@ -0,0 +1,59 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +//![0] +import QtQuick 2.0 + +ListModel { + id: fruitModel + + ListElement { + name: "Apple" + cost: 2.45 + } + ListElement { + name: "Orange" + cost: 3.25 + } + ListElement { + name: "Banana" + cost: 1.95 + } +} +//![0] diff --git a/doc/src/snippets/qml/listview-decorations.qml b/doc/src/snippets/qml/listview-decorations.qml new file mode 100644 index 0000000000..ccd7023d9c --- /dev/null +++ b/doc/src/snippets/qml/listview-decorations.qml @@ -0,0 +1,111 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +//! [document] +import QtQuick 2.0 + +//! [parent begin] +Rectangle { +//! [parent begin] + width: 550; height: 220; color: "white" + +//! [model] +ListModel { + id: nameModel + ListElement { name: "Alice" } + ListElement { name: "Bob" } + ListElement { name: "Jane" } + ListElement { name: "Harry" } + ListElement { name: "Wendy" } +} +//! [model] + +//! [delegate] +Component { + id: nameDelegate + Text { + text: name; + font.pixelSize: 24 + } +} +//! [delegate] + +//! [decorations] +ListView { + anchors.fill: parent + clip: true + model: nameModel + delegate: nameDelegate + header: bannercomponent + footer: Rectangle { + width: parent.width; height: 30; + gradient: clubcolors + } + highlight: Rectangle { + width: parent.width + color: "lightgray" + } +} + +Component { //instantiated when header is processed + id: bannercomponent + Rectangle { + id: banner + width: parent.width; height: 50 + gradient: clubcolors + border {color: "#9EDDF2"; width: 2} + Text { + anchors.centerIn: parent + text: "Club Members" + font.pixelSize: 32 + } + } +} +Gradient { + id: clubcolors + GradientStop { position: 0.0; color: "#8EE2FE"} + GradientStop { position: 0.66; color: "#7ED2EE"} +} +//! [decorations] + +//! [parent end] +} +//! [parent end] +//! [document] diff --git a/doc/src/snippets/qml/listview-sections.qml b/doc/src/snippets/qml/listview-sections.qml new file mode 100644 index 0000000000..59cfdf80bb --- /dev/null +++ b/doc/src/snippets/qml/listview-sections.qml @@ -0,0 +1,101 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +//! [document] +import QtQuick 2.0 + +//! [parent begin] +Rectangle { +//! [parent begin] + width: 150; height: 300; color: "white" + +//! [model] +ListModel { + id: nameModel + ListElement { name: "Alice"; team: "Crypto" } + ListElement { name: "Bob"; team: "Crypto" } + ListElement { name: "Jane"; team: "QA" } + ListElement { name: "Victor"; team: "QA" } + ListElement { name: "Wendy"; team: "Graphics" } +} +//! [model] + +//! [delegate] +Component { + id: nameDelegate + Text { + text: name; + font.pixelSize: 24 + anchors.left: parent.left + anchors.leftMargin: 2 + } +} +//! [delegate] + +//! [section] +ListView { + anchors.fill: parent + model: nameModel + delegate: nameDelegate + focus: true + highlight: Rectangle { + color: "lightblue" + width: parent.width + } + section { + property: "team" + criteria: ViewSection.FullString + delegate: Rectangle { + color: "#b0dfb0" + width: parent.width + height: childrenRect.height + 4 + Text { anchors.horizontalCenter: parent.horizontalCenter + font.pixelSize: 16 + font.bold: true + text: section + } + } + } +} +//! [section] + +//! [parent end] +} +//! [parent end] +//! [document] diff --git a/doc/src/snippets/qml/listview.qml b/doc/src/snippets/qml/listview.qml new file mode 100644 index 0000000000..e8752a47cd --- /dev/null +++ b/doc/src/snippets/qml/listview.qml @@ -0,0 +1,87 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +//! [document] +import QtQuick 2.0 + +//! [parent begin] +Rectangle { +//! [parent begin] + width: 175; height: 175; color: "white" + +//! [model] +ListModel { + id: petlist + ListElement { type: "Cat" } + ListElement { type: "Dog" } + ListElement { type: "Mouse" } + ListElement { type: "Rabbit" } + ListElement { type: "Horse" } +} +//! [model] + +//! [delegate] +Component { + id: petdelegate + Text { + id: label + font.pixelSize: 24 + text: if (index == 0) + label.text = type + " (default)" + else + text: type + } +} +//! [delegate] + +//! [view] +ListView { + id: view + anchors.fill: parent + + model: petlist + delegate: petdelegate +} +//! [view] + +//! [parent end] +} +//! [parent end] +//! [document] diff --git a/doc/src/snippets/qml/listview/ContactModel.qml b/doc/src/snippets/qml/listview/ContactModel.qml new file mode 100644 index 0000000000..395c637b6a --- /dev/null +++ b/doc/src/snippets/qml/listview/ContactModel.qml @@ -0,0 +1,58 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +//![0] +import QtQuick 2.0 + +ListModel { + ListElement { + name: "Bill Smith" + number: "555 3264" + } + ListElement { + name: "John Brown" + number: "555 8426" + } + ListElement { + name: "Sam Wise" + number: "555 0473" + } +} +//![0] diff --git a/doc/src/snippets/qml/listview/listview-snippet.qml b/doc/src/snippets/qml/listview/listview-snippet.qml new file mode 100644 index 0000000000..1458e9aa50 --- /dev/null +++ b/doc/src/snippets/qml/listview/listview-snippet.qml @@ -0,0 +1,52 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +//! [document] +import QtQuick 2.0 + +ListView { + width: 50; height: 200 + model: 4 + delegate: Text { + text: index; + font.pixelSize: 40 + } +} +//! [document] diff --git a/doc/src/snippets/qml/listview/listview.qml b/doc/src/snippets/qml/listview/listview.qml new file mode 100644 index 0000000000..689e6d2c45 --- /dev/null +++ b/doc/src/snippets/qml/listview/listview.qml @@ -0,0 +1,149 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +//![import] +import QtQuick 2.0 +//![import] + +Item { + +//![classdocs simple] +ListView { + width: 180; height: 200 + + model: ContactModel {} + delegate: Text { + text: name + ": " + number + } +} +//![classdocs simple] + +//![classdocs advanced] +Rectangle { + width: 180; height: 200 + + Component { + id: contactDelegate + Item { + width: 180; height: 40 + Column { + Text { text: 'Name: ' + name } + Text { text: 'Number: ' + number } + } + } + } + + ListView { + anchors.fill: parent + model: ContactModel {} + delegate: contactDelegate + highlight: Rectangle { color: "lightsteelblue"; radius: 5 } + focus: true + } +} +//![classdocs advanced] + +//![delayRemove] +Component { + id: delegate + Item { + ListView.onRemove: SequentialAnimation { + PropertyAction { target: wrapper; property: "ListView.delayRemove"; value: true } + NumberAnimation { target: wrapper; property: "scale"; to: 0; duration: 250; easing.type: Easing.InOutQuad } + PropertyAction { target: wrapper; property: "ListView.delayRemove"; value: false } + } + } +} +//![delayRemove] + +//![highlightFollowsCurrentItem] +Component { + id: highlight + Rectangle { + width: 180; height: 40 + color: "lightsteelblue"; radius: 5 + y: list.currentItem.y + Behavior on y { + SpringAnimation { + spring: 3 + damping: 0.2 + } + } + } +} + +ListView { + id: list + width: 180; height: 200 + model: ContactModel {} + delegate: Text { text: name } + + highlight: highlight + highlightFollowsCurrentItem: false + focus: true +} +//![highlightFollowsCurrentItem] + +//![isCurrentItem] +ListView { + width: 180; height: 200 + + Component { + id: contactsDelegate + Rectangle { + id: wrapper + width: 180 + height: contactInfo.height + color: ListView.isCurrentItem ? "black" : "red" + Text { + id: contactInfo + text: name + ": " + number + color: wrapper.ListView.isCurrentItem ? "red" : "black" + } + } + } + + model: ContactModel {} + delegate: contactsDelegate + focus: true +} +//![isCurrentItem] + +} diff --git a/doc/src/snippets/qml/loader/KeyReader.qml b/doc/src/snippets/qml/loader/KeyReader.qml new file mode 100644 index 0000000000..ef15a01bb1 --- /dev/null +++ b/doc/src/snippets/qml/loader/KeyReader.qml @@ -0,0 +1,53 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +//![0] +import QtQuick 2.0 + +Item { + Item { + focus: true + Keys.onPressed: { + console.log("Loaded item captured:", event.text); + event.accepted = true; + } + } +} +//![0] diff --git a/doc/src/snippets/qml/loader/MyItem.qml b/doc/src/snippets/qml/loader/MyItem.qml new file mode 100644 index 0000000000..2879e7ae23 --- /dev/null +++ b/doc/src/snippets/qml/loader/MyItem.qml @@ -0,0 +1,55 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +//![0] +import QtQuick 2.0 + +Rectangle { + id: myItem + signal message(string msg) + + width: 100; height: 100 + + MouseArea { + anchors.fill: parent + onClicked: myItem.message("clicked!") + } +} +//![0] diff --git a/doc/src/snippets/qml/loader/connections.qml b/doc/src/snippets/qml/loader/connections.qml new file mode 100644 index 0000000000..82d770b2cb --- /dev/null +++ b/doc/src/snippets/qml/loader/connections.qml @@ -0,0 +1,57 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +//![0] +import QtQuick 2.0 + +Item { + width: 100; height: 100 + + Loader { + id: myLoader + source: "MyItem.qml" + } + + Connections { + target: myLoader.item + onMessage: console.log(msg) + } +} +//![0] diff --git a/doc/src/snippets/qml/loader/focus.qml b/doc/src/snippets/qml/loader/focus.qml new file mode 100644 index 0000000000..4447c62905 --- /dev/null +++ b/doc/src/snippets/qml/loader/focus.qml @@ -0,0 +1,62 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +//![0] +import QtQuick 2.0 + +Rectangle { + width: 200; height: 200 + + Loader { + id: loader + focus: true + } + + MouseArea { + anchors.fill: parent + onClicked: loader.source = "KeyReader.qml" + } + + Keys.onPressed: { + console.log("Captured:", event.text); + } +} +//![0] + diff --git a/doc/src/snippets/qml/loader/simple.qml b/doc/src/snippets/qml/loader/simple.qml new file mode 100644 index 0000000000..a4408c2231 --- /dev/null +++ b/doc/src/snippets/qml/loader/simple.qml @@ -0,0 +1,54 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +//![0] +import QtQuick 2.0 + +Item { + width: 200; height: 200 + + Loader { id: pageLoader } + + MouseArea { + anchors.fill: parent + onClicked: pageLoader.source = "Page1.qml" + } +} +//![0] diff --git a/doc/src/snippets/qml/loader/sizeitem.qml b/doc/src/snippets/qml/loader/sizeitem.qml new file mode 100644 index 0000000000..d673d82817 --- /dev/null +++ b/doc/src/snippets/qml/loader/sizeitem.qml @@ -0,0 +1,62 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +//![0] +import QtQuick 2.0 + +Item { + width: 200; height: 200 + + Loader { + // position the Loader in the center of the parent + anchors.centerIn: parent + sourceComponent: rect + } + + Component { + id: rect + Rectangle { + width: 50 + height: 50 + color: "red" + } + } +} +//![0] diff --git a/doc/src/snippets/qml/loader/sizeloader.qml b/doc/src/snippets/qml/loader/sizeloader.qml new file mode 100644 index 0000000000..551324598c --- /dev/null +++ b/doc/src/snippets/qml/loader/sizeloader.qml @@ -0,0 +1,62 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +//![0] +import QtQuick 2.0 + +Item { + width: 200; height: 200 + + Loader { + // Explicitly set the size of the Loader to the parent item's size + anchors.fill: parent + sourceComponent: rect + } + + Component { + id: rect + Rectangle { + width: 50 + height: 50 + color: "red" + } + } +} +//![0] diff --git a/doc/src/snippets/qml/models/views-models-delegates.qml b/doc/src/snippets/qml/models/views-models-delegates.qml new file mode 100644 index 0000000000..e9f872578f --- /dev/null +++ b/doc/src/snippets/qml/models/views-models-delegates.qml @@ -0,0 +1,79 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +import QtQuick 2.0 + +//! [rectangle] +Rectangle { + width: 200; height: 200 + + ListModel { + id: fruitModel + property string language: "en" + ListElement { + name: "Apple" + cost: 2.45 + } + ListElement { + name: "Orange" + cost: 3.25 + } + ListElement { + name: "Banana" + cost: 1.95 + } + } + + Component { + id: fruitDelegate + Row { + Text { text: " Fruit: " + name; color: ListView.view.fruit_color } + Text { text: " Cost: $" + cost } + Text { text: " Language: " + ListView.view.model.language } + } + } + + ListView { + property color fruit_color: "green" + model: fruitModel + delegate: fruitDelegate + anchors.fill: parent + } +} +//! [rectangle] diff --git a/doc/src/snippets/qml/models/visual-model-and-view.qml b/doc/src/snippets/qml/models/visual-model-and-view.qml new file mode 100644 index 0000000000..97e443b675 --- /dev/null +++ b/doc/src/snippets/qml/models/visual-model-and-view.qml @@ -0,0 +1,58 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +import QtQuick 2.0 + +Rectangle { + width: 200; height: 200 + + //! [visual model and view] + VisualItemModel { + id: itemModel + Rectangle { height: 30; width: 80; color: "red" } + Rectangle { height: 30; width: 80; color: "green" } + Rectangle { height: 30; width: 80; color: "blue" } + } + + ListView { + anchors.fill: parent + model: itemModel + } + //! [visual model and view] +} diff --git a/doc/src/snippets/qml/mousearea/mousearea-snippet.qml b/doc/src/snippets/qml/mousearea/mousearea-snippet.qml new file mode 100644 index 0000000000..237c0c31b0 --- /dev/null +++ b/doc/src/snippets/qml/mousearea/mousearea-snippet.qml @@ -0,0 +1,98 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +//! [document] +import QtQuick 2.0 + +//! [parent begin] +Rectangle { +//! [parent begin] + width: 500; height: 500 + color: "green" + + Column { + //! [anchor fill] + Rectangle { + id: button + width: 100; height: 100 + + MouseArea { + anchors.fill: parent + onClicked: console.log("button clicked") + } + MouseArea { + width:150; height: 75 + onClicked: console.log("irregular area clicked") + } + } + //! [anchor fill] + + Rectangle { + width: 100; height: 100 + + //! [enable handlers] + MouseArea { + hoverEnabled: true + acceptedButtons: Qt.LeftButton | Qt.RightButton + onEntered: console.log("mouse entered the area") + onExited: console.log("mouse left the area") + } + //! [enable handlers] + } + + Rectangle { + width: 100; height: 100 + + //! [mouse handlers] + MouseArea { + anchors.fill: parent + onClicked: console.log("area clicked") + onDoubleClicked: console.log("area double clicked") + onEntered: console.log("mouse entered the area") + onExited: console.log("mouse left the area") + } + //! [mouse handlers] + } + + } //end of column +//! [parent end] +} +//! [parent end] +//! [document] diff --git a/doc/src/snippets/qml/mousearea/mousearea.qml b/doc/src/snippets/qml/mousearea/mousearea.qml new file mode 100644 index 0000000000..1f35cd8b5f --- /dev/null +++ b/doc/src/snippets/qml/mousearea/mousearea.qml @@ -0,0 +1,117 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +//! [import] +import QtQuick 2.0 +//! [import] + +Rectangle { + width: childrenRect.width + height: childrenRect.height + + Row { + //! [intro] + Rectangle { + width: 100; height: 100 + color: "green" + + MouseArea { + anchors.fill: parent + onClicked: { parent.color = 'red' } + } + } + //! [intro] + + //! [intro-extended] + Rectangle { + width: 100; height: 100 + color: "green" + + MouseArea { + anchors.fill: parent + acceptedButtons: Qt.LeftButton | Qt.RightButton + onClicked: { + if (mouse.button == Qt.RightButton) + parent.color = 'blue'; + else + parent.color = 'red'; + } + } + } + //! [intro-extended] + + //! [drag] + Rectangle { + id: container + width: 600; height: 200 + + Rectangle { + id: rect + width: 50; height: 50 + color: "red" + opacity: (600.0 - rect.x) / 600 + + MouseArea { + anchors.fill: parent + drag.target: rect + drag.axis: Drag.XAxis + drag.minimumX: 0 + drag.maximumX: container.width - rect.width + } + } + } + //! [drag] + + //! [mousebuttons] + Text { + text: mouseArea.pressedButtons & Qt.RightButton ? "right" : "" + horizontalAlignment: Text.AlignHCenter + verticalAlignment: Text.AlignVCenter + + MouseArea { + id: mouseArea + anchors.fill: parent + acceptedButtons: Qt.LeftButton | Qt.RightButton + } + } + //! [mousebuttons] + + } +} diff --git a/doc/src/snippets/qml/mousearea/mouseareadragfilter.qml b/doc/src/snippets/qml/mousearea/mouseareadragfilter.qml new file mode 100644 index 0000000000..922bfea636 --- /dev/null +++ b/doc/src/snippets/qml/mousearea/mouseareadragfilter.qml @@ -0,0 +1,72 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +//! [dragfilter] +import QtQuick 2.0 + +Rectangle { + width: 480 + height: 320 + Rectangle { + x: 30; y: 30 + width: 300; height: 240 + color: "lightsteelblue" + + MouseArea { + anchors.fill: parent + drag.target: parent; + drag.axis: "XAxis" + drag.minimumX: 30 + drag.maximumX: 150 + drag.filterChildren: true + + Rectangle { + color: "yellow" + x: 50; y : 50 + width: 100; height: 100 + MouseArea { + anchors.fill: parent + onClicked: console.log("Clicked") + } + } + } + } +} +//! [dragfilter] diff --git a/doc/src/snippets/qml/multipointtoucharea/multipointtoucharea.qml b/doc/src/snippets/qml/multipointtoucharea/multipointtoucharea.qml new file mode 100644 index 0000000000..e4c2ffb039 --- /dev/null +++ b/doc/src/snippets/qml/multipointtoucharea/multipointtoucharea.qml @@ -0,0 +1,67 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +//![0] +import QtQuick 2.0 + +Rectangle { + width: 400; height: 400 + MultiPointTouchArea { + anchors.fill: parent + touchPoints: [ + TouchPoint { id: point1 }, + TouchPoint { id: point2 } + ] + } + + Rectangle { + width: 30; height: 30 + color: "green" + x: point1.x + y: point1.y + } + + Rectangle { + width: 30; height: 30 + color: "yellow" + x: point2.x + y: point2.y + } +} +//![0] diff --git a/doc/src/snippets/qml/numberanimation.qml b/doc/src/snippets/qml/numberanimation.qml new file mode 100644 index 0000000000..404381863d --- /dev/null +++ b/doc/src/snippets/qml/numberanimation.qml @@ -0,0 +1,51 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +//![0] +import QtQuick 2.0 + +Rectangle { + width: 100; height: 100 + color: "red" + + NumberAnimation on x { to: 50; duration: 1000 } +} +//![0] + diff --git a/doc/src/snippets/qml/parallelanimation.qml b/doc/src/snippets/qml/parallelanimation.qml new file mode 100644 index 0000000000..20f6ccc1df --- /dev/null +++ b/doc/src/snippets/qml/parallelanimation.qml @@ -0,0 +1,56 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +//![0] +import QtQuick 2.0 + +Rectangle { + id: rect + width: 100; height: 100 + color: "red" + + ParallelAnimation { + running: true + NumberAnimation { target: rect; property: "x"; to: 50; duration: 1000 } + NumberAnimation { target: rect; property: "y"; to: 50; duration: 1000 } + } +} +//![0] + diff --git a/doc/src/snippets/qml/parentanimation.qml b/doc/src/snippets/qml/parentanimation.qml new file mode 100644 index 0000000000..60429ed61c --- /dev/null +++ b/doc/src/snippets/qml/parentanimation.qml @@ -0,0 +1,73 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +//![0] +import QtQuick 2.0 + +Item { + width: 200; height: 100 + + Rectangle { + id: redRect + width: 100; height: 100 + color: "red" + } + + Rectangle { + id: blueRect + x: redRect.width + width: 50; height: 50 + color: "blue" + + states: State { + name: "reparented" + ParentChange { target: blueRect; parent: redRect; x: 10; y: 10 } + } + + transitions: Transition { + ParentAnimation { + NumberAnimation { properties: "x,y"; duration: 1000 } + } + } + + MouseArea { anchors.fill: parent; onClicked: blueRect.state = "reparented" } + } +} +//![0] + diff --git a/doc/src/snippets/qml/parentchange.qml b/doc/src/snippets/qml/parentchange.qml new file mode 100644 index 0000000000..4ae4476e13 --- /dev/null +++ b/doc/src/snippets/qml/parentchange.qml @@ -0,0 +1,67 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +//![0] +import QtQuick 2.0 + +Item { + width: 200; height: 100 + + Rectangle { + id: redRect + width: 100; height: 100 + color: "red" + } + + Rectangle { + id: blueRect + x: redRect.width + width: 50; height: 50 + color: "blue" + + states: State { + name: "reparented" + ParentChange { target: blueRect; parent: redRect; x: 10; y: 10 } + } + + MouseArea { anchors.fill: parent; onClicked: blueRect.state = "reparented" } + } +} +//![0] + diff --git a/doc/src/snippets/qml/path/arcdirection.qml b/doc/src/snippets/qml/path/arcdirection.qml new file mode 100644 index 0000000000..7522649607 --- /dev/null +++ b/doc/src/snippets/qml/path/arcdirection.qml @@ -0,0 +1,51 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +//![0] +Path { + startX: 50; startY: 50 + + PathArc { + x: 150; y: 50 + radiusX: 75; radiusY: 50 + } +} +//![0] diff --git a/doc/src/snippets/qml/path/arcradius.qml b/doc/src/snippets/qml/path/arcradius.qml new file mode 100644 index 0000000000..04f2919270 --- /dev/null +++ b/doc/src/snippets/qml/path/arcradius.qml @@ -0,0 +1,63 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +//![0] +Path { + startX: 0; startY: 100 + + PathArc { + relativeX: 50; y: 100 + radiusX: 25; radiusY: 15 + } + PathArc { + relativeX: 50; y: 100 + radiusX: 25; radiusY: 25 + } + PathArc { + relativeX: 50; y: 100 + radiusX: 25; radiusY: 50 + } + PathArc { + relativeX: 50; y: 100 + radiusX: 50; radiusY: 100 + } +} +//![0] diff --git a/doc/src/snippets/qml/path/basicarc.qml b/doc/src/snippets/qml/path/basicarc.qml new file mode 100644 index 0000000000..562f2a0adf --- /dev/null +++ b/doc/src/snippets/qml/path/basicarc.qml @@ -0,0 +1,52 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +//![0] +Path { + startX: 100; startY: 0 + + PathArc { + x: 0; y: 100 + radiusX: 100; radiusY: 100 + useLargeArc: true + } +} +//![0] diff --git a/doc/src/snippets/qml/path/basiccurve.qml b/doc/src/snippets/qml/path/basiccurve.qml new file mode 100644 index 0000000000..feb783cb01 --- /dev/null +++ b/doc/src/snippets/qml/path/basiccurve.qml @@ -0,0 +1,63 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +//![0] +import QtQuick 2.0 + +Canvas { + width: 400; height: 200 + + Path { + id: myPath + startX: 0; startY: 100 + + PathCurve { x: 75; y: 75 } + PathCurve { x: 200; y: 150 } + PathCurve { x: 325; y: 25 } + PathCurve { x: 400; y: 100 } + } + + onPaint: { + context.strokeStyle = Qt.rgba(.4,.6,.8); + context.path = myPath; + context.stroke(); + } +} +//![0] diff --git a/doc/src/snippets/qml/path/largearc.qml b/doc/src/snippets/qml/path/largearc.qml new file mode 100644 index 0000000000..69ce953c92 --- /dev/null +++ b/doc/src/snippets/qml/path/largearc.qml @@ -0,0 +1,51 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +//![0] +Path { + startX: 0; startY: 100 + PathArc { + x: 100; y: 200 + radiusX: 100; radiusY: 100 + direction: PathArc.Clockwise + } +} +//![0] diff --git a/doc/src/snippets/qml/pathinterpolator.qml b/doc/src/snippets/qml/pathinterpolator.qml new file mode 100644 index 0000000000..77cc664e27 --- /dev/null +++ b/doc/src/snippets/qml/pathinterpolator.qml @@ -0,0 +1,74 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +//![0] +import QtQuick 2.0 + +Rectangle { + width: 400 + height: 400 + + PathInterpolator { + id: motionPath + + path: Path { + startX: 0; startY: 0 + + PathCubic { + x: 350; y: 350 + + control1X: 350; control1Y: 0 + control2X: 0; control2Y: 350 + } + } + + NumberAnimation on progress { from: 0; to: 1; duration: 2000 } + } + + Rectangle { + width: 50; height: 50 + color: "green" + + //bind our attributes to follow the path as progress changes + x: motionPath.x + y: motionPath.y + rotation: motionPath.angle + } +} +//![0] diff --git a/doc/src/snippets/qml/pathview/ContactModel.qml b/doc/src/snippets/qml/pathview/ContactModel.qml new file mode 100644 index 0000000000..d191413f27 --- /dev/null +++ b/doc/src/snippets/qml/pathview/ContactModel.qml @@ -0,0 +1,58 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +//![0] +import QtQuick 2.0 + +ListModel { + ListElement { + name: "Bill Jones" + icon: "pics/qtlogo.png" + } + ListElement { + name: "Jane Doe" + icon: "pics/qtlogo.png" + } + ListElement { + name: "John Smith" + icon: "pics/qtlogo.png" + } +} +//![0] diff --git a/doc/src/snippets/qml/pathview/pathattributes.qml b/doc/src/snippets/qml/pathview/pathattributes.qml new file mode 100644 index 0000000000..d555998650 --- /dev/null +++ b/doc/src/snippets/qml/pathview/pathattributes.qml @@ -0,0 +1,79 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +//! [0] +import QtQuick 2.0 + +Rectangle { + width: 240; height: 200 + +//! [1] + Component { + id: delegate + Item { + width: 80; height: 80 + scale: PathView.iconScale + opacity: PathView.iconOpacity + Column { + Image { anchors.horizontalCenter: nameText.horizontalCenter; width: 64; height: 64; source: icon } + Text { id: nameText; text: name; font.pointSize: 16 } + } + } + } +//! [1] + +//! [2] + PathView { + anchors.fill: parent + model: ContactModel {} + delegate: delegate + path: Path { + startX: 120; startY: 100 + PathAttribute { name: "iconScale"; value: 1.0 } + PathAttribute { name: "iconOpacity"; value: 1.0 } + PathQuad { x: 120; y: 25; controlX: 260; controlY: 75 } + PathAttribute { name: "iconScale"; value: 0.3 } + PathAttribute { name: "iconOpacity"; value: 0.5 } + PathQuad { x: 120; y: 100; controlX: -20; controlY: 75 } + } + } +//! [2] +} +//! [0] diff --git a/doc/src/snippets/qml/pathview/pathview.qml b/doc/src/snippets/qml/pathview/pathview.qml new file mode 100644 index 0000000000..e5249d4cb6 --- /dev/null +++ b/doc/src/snippets/qml/pathview/pathview.qml @@ -0,0 +1,80 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +//! [0] +import QtQuick 2.0 + +Rectangle { + width: 240; height: 200 + +//! [1] + Component { + id: delegate + Column { + id: wrapper + Image { + anchors.horizontalCenter: nameText.horizontalCenter + width: 64; height: 64 + source: icon + } + Text { + id: nameText + text: name + font.pointSize: 16 + color: wrapper.PathView.isCurrentItem ? "red" : "black" + } + } + } +//! [1] + +//! [2] + PathView { + anchors.fill: parent + model: ContactModel {} + delegate: delegate + path: Path { + startX: 120; startY: 100 + PathQuad { x: 120; y: 25; controlX: 260; controlY: 75 } + PathQuad { x: 120; y: 100; controlX: -20; controlY: 75 } + } + } +//! [2] +} +//! [0] diff --git a/doc/src/snippets/qml/properties.qml b/doc/src/snippets/qml/properties.qml new file mode 100644 index 0000000000..21894b68e0 --- /dev/null +++ b/doc/src/snippets/qml/properties.qml @@ -0,0 +1,315 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +//! [document] +import QtQuick 2.0 + +//! [parent begin] +Rectangle { +//! [parent begin] + + //! [inherited properties] + width: 320; height: 240 + color: "lightblue" + focus: true + //! [inherited properties] + + //! [custom properties] + property int counter + property real area: 100.45 + //! [custom properties] + + //! [property types] + property int number + property real volume: 100.45 + property date today: "2011-01-01" + property color background: "yellow" + //! [property types] + + +//! [grouped properties] +Text { + //dot notation + font.pixelSize: 12 + font.bold: true +} + +Text { + //group notation + font {pixelSize: 12; bold: true} +} +//! [grouped properties] + + +//! [property binding] +Rectangle { + width: parent.width +} +//! [property binding] + +//! [property assignment] +Rectangle { + Component.onCompleted: { + width = 150 + } +} +//! [property assignment] + +Rectangle { + //placeholder slider + id: slider + property real value +} +Rectangle { + //placeholder system + id: system + property real brightness +} +//! [binding element] +Binding { + target: system + property: "brightness" + value: slider.value +} +//! [binding element] + +Rectangle { + //placeholder warning + id: warning + color: "red" +} +//! [PropertyChanges element] +Rectangle { + id: rectangle + + states: State { + name: "WARNING" + PropertyChanges { + target: rectangle + color: warning.color + } + } +} +//! [PropertyChanges element] + +//! [list property] +Item { + id: multistate + states: [ + State {name: "FETCH"}, + State {name: "DECODE"}, + State {name: "EXECUTE"} + ] +} +//! [list property] +//! [single property] +Item { + id: monostate + states: State {name: "RUNNING"} +} +//! [single property] + +Item { + id: printstate +//! [print list property] + Component.onCompleted: console.log (multistate.states[0].name) +//! [print list property] +} + +//! [JavaScript sample] +function calculateArea(width, height) { + return (width * height) * 0.5 +} + +Rectangle { + width: 150; height: 75 + property real area: calculateArea(width, height) + property real parentArea: calculateArea(parent.width,parent.height) + color: { if (area > parentArea) "blue"; else "red" } +} +//! [JavaScript sample] + +//! [id property] +Rectangle { + id: container + width: 100; height: 100 + Rectangle { + width: parent.width; height: parent.height + } +} +Rectangle { + width: container.width; height: container.height +} +//! [id property] + +//! [default property] +Item { + Text {} + Rectangle {} + Timer {} +} + +Item { + //without default property + children: [ + Text {}, + Rectangle {} + ] + resources: [ + Timer {} + ] +} +//! [default property] + +//! [state default] +State { + changes: [ + PropertyChanges {}, + PropertyChanges {} + ] +} + +State { + PropertyChanges {} + PropertyChanges {} +} +//! [state default] + +//! [object binding] +Rectangle { + + id: parentrectangle + gradient: + Gradient { //not a child of parentrectangle + + //generates a TypeError + //Component.onCompleted: console.log(parent.width) + } + + //child of parentrectangle + Rectangle {property string name: "childrectangle"} + + //prints "childrectangle" + Component.onCompleted: console.log(children[0].name) +} +//! [object binding] + +//! [list attached property] +Component { + id: listdelegate + Text { + text: "Hello" + color: ListView.isCurrentItem ? "red" : "blue" + } +} +ListView { + delegate: listdelegate +} +//! [list attached property] + +//! [attached signal handler] +Item { + Keys.onPressed: console.log("Key Press Detected") + Component.onCompleted: console.log("Completed initialization") +} +//! [attached signal handler] + +//! [alias usage] +Button { + id: textbutton + buttonLabel: "Click Me!" +} +//! [alias usage] + +//! [image alias] +Button { + id: imagebutton + buttonImage.source: "http://qt.nokia.com/logo.png" + buttonLabel: buttonImage.source +} +//! [image alias] + +Item { +id: widget + +//! [alias complete] +property alias widgetLabel: label + +//will generate an error +//widgetLabel.text: "Initial text" + +//will generate an error +//property alias widgetLabelText: widgetLabel.text + +Component.onCompleted: widgetLabel.text = "Alias completed Initialization" +//! [alias complete] + + Text {id: label} +} + +//![alias overwrite] +Rectangle { + id: coloredrectangle + property alias color: bluerectangle.color + color: "red" + + Rectangle { + id: bluerectangle + color: "#1234ff" + } + + Component.onCompleted: { + console.log (coloredrectangle.color) //prints "#1234ff" + setInternalColor() + console.log (coloredrectangle.color) //prints "#111111" + coloredrectangle.color = "#884646" + console.log (coloredrectangle.color) //prints #884646 + } + + //internal function that has access to internal properties + function setInternalColor() { + color = "#111111" + } +} +//![alias overwrite] +//! [parent end] +} +//! [parent end] +//! [document] diff --git a/doc/src/snippets/qml/propertyaction-sequential.qml b/doc/src/snippets/qml/propertyaction-sequential.qml new file mode 100644 index 0000000000..77d6ec194e --- /dev/null +++ b/doc/src/snippets/qml/propertyaction-sequential.qml @@ -0,0 +1,72 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +import QtQuick 2.0 + +Row { + + Item { + width: 400; height: 400 + + Rectangle { + id: rect + width: 200; height: 100 + color: "red" + + states: State { + name: "rotated" + PropertyChanges { target: rect; rotation: 180; transformOrigin: Item.BottomRight } + } + + //! [sequential] + transitions: Transition { + SequentialAnimation { + PropertyAction { target: rect; property: "transformOrigin" } + RotationAnimation { duration: 1000; direction: RotationAnimation.Counterclockwise } + } + } + //! [sequential] + + MouseArea { + anchors.fill: parent + onClicked: rect.state = "rotated" + } + } + } +} diff --git a/doc/src/snippets/qml/propertyaction.qml b/doc/src/snippets/qml/propertyaction.qml new file mode 100644 index 0000000000..5ddef30177 --- /dev/null +++ b/doc/src/snippets/qml/propertyaction.qml @@ -0,0 +1,83 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +import QtQuick 2.0 + +Row { + + //![transition] + Item { + width: 400; height: 400 + + Rectangle { + id: rect + width: 200; height: 100 + color: "red" + + states: State { + name: "rotated" + PropertyChanges { target: rect; rotation: 180; transformOrigin: Item.BottomRight } + } + + transitions: Transition { + RotationAnimation { duration: 1000; direction: RotationAnimation.Counterclockwise } + } + + MouseArea { + anchors.fill: parent + onClicked: rect.state = "rotated" + } + } + } + //![transition] + + Item { + width: 300; height: 300 + + Image { id: img; source: "pics/qt.png" } + + //![standalone] + SequentialAnimation { + PropertyAction { target: img; property: "smooth"; value: "true" } + NumberAnimation { target: img; property: "width"; to: 300; duration: 1000 } + PropertyAction { target: img; property: "smooth"; value: "false" } + } + //![standalone] + } +} diff --git a/doc/src/snippets/qml/propertyanimation.qml b/doc/src/snippets/qml/propertyanimation.qml new file mode 100644 index 0000000000..b5781af94a --- /dev/null +++ b/doc/src/snippets/qml/propertyanimation.qml @@ -0,0 +1,100 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Row { + +//![transition] +Rectangle { + id: rect + width: 100; height: 100 + color: "red" + + //! [single state] + states: State { + name: "moved" + PropertyChanges { target: rect; x: 50 } + } + //! [single state] + + transitions: Transition { + PropertyAnimation { properties: "x,y"; easing.type: Easing.InOutQuad } + } +} +//![transition] + +//![behavior] +Rectangle { + width: 100; height: 100 + color: "red" + + Behavior on x { PropertyAnimation {} } + + MouseArea { anchors.fill: parent; onClicked: parent.x = 50 } +} +//![behavior] + +//![propertyvaluesource] +Rectangle { + width: 100; height: 100 + color: "red" + + SequentialAnimation on x { + loops: Animation.Infinite + PropertyAnimation { to: 50 } + PropertyAnimation { to: 0 } + } +} +//![propertyvaluesource] + + //![standalone] + Rectangle { + id: theRect + width: 100; height: 100 + color: "red" + + // this is a standalone animation, it's not running by default + PropertyAnimation { id: animation; target: theRect; property: "width"; to: 30; duration: 500 } + + MouseArea { anchors.fill: parent; onClicked: animation.running = true } + } + //![standalone] +} diff --git a/doc/src/snippets/qml/propertychanges.qml b/doc/src/snippets/qml/propertychanges.qml new file mode 100644 index 0000000000..3be13f7861 --- /dev/null +++ b/doc/src/snippets/qml/propertychanges.qml @@ -0,0 +1,91 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +//![import] +import QtQuick 2.0 +//![import] + +Column { + +//![0] +Item { + id: container + width: 300; height: 300 + + Rectangle { + id: rect + width: 100; height: 100 + color: "red" + + MouseArea { + id: mouseArea + anchors.fill: parent + } + + states: State { + name: "resized"; when: mouseArea.pressed + PropertyChanges { target: rect; color: "blue"; height: container.height } + } + } +} +//![0] + +//![reset] +Rectangle { + width: 300; height: 200 + + Text { + id: myText + width: 50 + wrapMode: Text.WordWrap + text: "a text string that is longer than 50 pixels" + + states: State { + name: "widerText" + PropertyChanges { target: myText; width: undefined } + } + } + + MouseArea { + anchors.fill: parent + onClicked: myText.state = "widerText" + } +} +//![reset] +} diff --git a/doc/src/snippets/qml/qml-data-models/dynamic-listmodel.qml b/doc/src/snippets/qml/qml-data-models/dynamic-listmodel.qml new file mode 100644 index 0000000000..da9610c117 --- /dev/null +++ b/doc/src/snippets/qml/qml-data-models/dynamic-listmodel.qml @@ -0,0 +1,67 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Item { + width: 200; height: 250 + + //! [model] + ListModel { id: fruitModel } + //! [model] + + //! [view] + ListView { + anchors.fill: parent + model: fruitModel + delegate: Row { + Text { text: "Fruit: " + name } + Text { text: "Cost: $" + cost } + } + } + //! [view] + + //! [mouse area] + MouseArea { + anchors.fill: parent + onClicked: fruitModel.append({"cost": 5.95, "name":"Pizza"}) + } + //! [mouse area] +} diff --git a/doc/src/snippets/qml/qml-data-models/listelements.qml b/doc/src/snippets/qml/qml-data-models/listelements.qml new file mode 100644 index 0000000000..0097423142 --- /dev/null +++ b/doc/src/snippets/qml/qml-data-models/listelements.qml @@ -0,0 +1,77 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +//! [document] +import QtQuick 2.0 + +Item { + width: 200; height: 250 + + //! [model] + ListModel { + id: fruitModel + + ListElement { + name: "Apple" + cost: 2.45 + } + ListElement { + name: "Orange" + cost: 3.25 + } + ListElement { + name: "Banana" + cost: 1.95 + } + } + //! [model] + + //! [view] + ListView { + anchors.fill: parent + model: fruitModel + delegate: Row { + Text { text: "Fruit: " + name } + Text { text: "Cost: $" + cost } + } + } + //! [view] +} +//! [document] diff --git a/doc/src/snippets/qml/qml-data-models/listmodel-listview.qml b/doc/src/snippets/qml/qml-data-models/listmodel-listview.qml new file mode 100644 index 0000000000..406fada2ce --- /dev/null +++ b/doc/src/snippets/qml/qml-data-models/listmodel-listview.qml @@ -0,0 +1,64 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +//! [document] +import QtQuick 2.0 + +Item { + width: 200; height: 250 + + ListModel { + id: myModel + ListElement { type: "Dog"; age: 8 } + ListElement { type: "Cat"; age: 5 } + } + + Component { + id: myDelegate + Text { text: type + ", " + age } + } + + ListView { + anchors.fill: parent + model: myModel + delegate: myDelegate + } +} +//! [document] diff --git a/doc/src/snippets/qml/qml-documents/inline-component.qml b/doc/src/snippets/qml/qml-documents/inline-component.qml new file mode 100644 index 0000000000..7e01ca369b --- /dev/null +++ b/doc/src/snippets/qml/qml-documents/inline-component.qml @@ -0,0 +1,57 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +//! [document] +import QtQuick 2.0 + +Rectangle { + width: 240; height: 320; + + ListView { + anchors.fill: parent + model: contactModel + delegate: Component { + Text { + text: modelData.firstName + " " + modelData.lastName + } + } + } +} +//! [document] diff --git a/doc/src/snippets/qml/qml-documents/inline-text-component.qml b/doc/src/snippets/qml/qml-documents/inline-text-component.qml new file mode 100644 index 0000000000..2405585b43 --- /dev/null +++ b/doc/src/snippets/qml/qml-documents/inline-text-component.qml @@ -0,0 +1,55 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +//! [document] +import QtQuick 2.0 + +Rectangle { + width: 240; height: 320; + + ListView { + anchors.fill: parent + model: contactModel + delegate: Text { + text: modelData.firstName + " " + modelData.lastName + } + } +} +//! [document] diff --git a/doc/src/snippets/qml/qml-documents/non-trivial.qml b/doc/src/snippets/qml/qml-documents/non-trivial.qml new file mode 100644 index 0000000000..bd1b94a3cc --- /dev/null +++ b/doc/src/snippets/qml/qml-documents/non-trivial.qml @@ -0,0 +1,62 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +//! [document] +import QtQuick 2.0 + +Rectangle { + width: 240; height: 320; + + resources: [ + Component { + id: contactDelegate + Text { + text: modelData.firstName + " " + modelData.lastName + } + } + ] + + ListView { + anchors.fill: parent + model: contactModel + delegate: contactDelegate + } +} +//! [document] diff --git a/doc/src/snippets/qml/qml-documents/qmldocuments.qml b/doc/src/snippets/qml/qml-documents/qmldocuments.qml new file mode 100644 index 0000000000..cf60741f0c --- /dev/null +++ b/doc/src/snippets/qml/qml-documents/qmldocuments.qml @@ -0,0 +1,66 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +//! [document] +import QtQuick 2.0 + +Rectangle { + property alias text: textItem.text + + width: 100; height: 30 + border.width: 1 + radius: 5 + smooth: true + + gradient: Gradient { + GradientStop { position: 0.0; color: "darkGray" } + GradientStop { position: 0.5; color: "black" } + GradientStop { position: 1.0; color: "darkGray" } + } + + Text { + id: textItem + anchors.centerIn: parent + font.pointSize: 20 + color: "white" + } + +} +//! [document] diff --git a/doc/src/snippets/qml/qml-intro/images/qt-logo.svg b/doc/src/snippets/qml/qml-intro/images/qt-logo.svg new file mode 100644 index 0000000000..8c018be6a2 --- /dev/null +++ b/doc/src/snippets/qml/qml-intro/images/qt-logo.svg @@ -0,0 +1,104 @@ + + + + + + image/svg+xml + + + + + + SVG generated by Lineform + + + + + + + + + + + + + + + diff --git a/doc/src/snippets/qml/qtbinding/context-advanced/MyItem.qml b/doc/src/snippets/qml/qtbinding/context-advanced/MyItem.qml new file mode 100644 index 0000000000..a9b873d4b0 --- /dev/null +++ b/doc/src/snippets/qml/qtbinding/context-advanced/MyItem.qml @@ -0,0 +1,46 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +//![0] +// MyItem.qml +import QtQuick 2.0 + +Text { text: applicationData.getCurrentDateTime() } +//![0] + diff --git a/doc/src/snippets/qml/qtbinding/context-advanced/applicationdata.h b/doc/src/snippets/qml/qtbinding/context-advanced/applicationdata.h new file mode 100644 index 0000000000..fc5bbc6400 --- /dev/null +++ b/doc/src/snippets/qml/qtbinding/context-advanced/applicationdata.h @@ -0,0 +1,52 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include +#include + +//![0] +class ApplicationData : public QObject +{ + Q_OBJECT +public: + Q_INVOKABLE QDateTime getCurrentDateTime() const { + return QDateTime::currentDateTime(); + } +}; +//![0] diff --git a/doc/src/snippets/qml/qtbinding/context-advanced/connections.qml b/doc/src/snippets/qml/qtbinding/context-advanced/connections.qml new file mode 100644 index 0000000000..01f0cdefb9 --- /dev/null +++ b/doc/src/snippets/qml/qtbinding/context-advanced/connections.qml @@ -0,0 +1,52 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +import QtQuick 2.0 + +//![0] +Text { + text: applicationData.getCurrentDateTime() + + Connections { + target: applicationData + onDataChanged: console.log("The application data changed!") + } +} +//![0] + diff --git a/doc/src/snippets/qml/qtbinding/context-advanced/main.cpp b/doc/src/snippets/qml/qtbinding/context-advanced/main.cpp new file mode 100644 index 0000000000..b9676e4b66 --- /dev/null +++ b/doc/src/snippets/qml/qtbinding/context-advanced/main.cpp @@ -0,0 +1,60 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include +#include + +#include "applicationdata.h" + +//![0] +int main(int argc, char *argv[]) { + QApplication app(argc, argv); + + QQuickView view; + + ApplicationData data; + view.rootContext()->setContextProperty("applicationData", &data); + + view.setSource(QUrl::fromLocalFile("MyItem.qml")); + view.show(); + + return app.exec(); +} +//![0] + diff --git a/doc/src/snippets/qml/qtbinding/context/MyItem.qml b/doc/src/snippets/qml/qtbinding/context/MyItem.qml new file mode 100644 index 0000000000..3abf2411f0 --- /dev/null +++ b/doc/src/snippets/qml/qtbinding/context/MyItem.qml @@ -0,0 +1,45 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +//![0] +// MyItem.qml +import QtQuick 2.0 + +Text { text: currentDateTime } +//![0] diff --git a/doc/src/snippets/qml/qtbinding/context/main.cpp b/doc/src/snippets/qml/qtbinding/context/main.cpp new file mode 100644 index 0000000000..0849a845a6 --- /dev/null +++ b/doc/src/snippets/qml/qtbinding/context/main.cpp @@ -0,0 +1,56 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include +#include + +int main(int argc, char *argv[]) +{ + QApplication app(argc, argv); + +//![0] +QQuickView view; +view.rootContext()->setContextProperty("currentDateTime", QDateTime::currentDateTime()); +view.setSource(QUrl::fromLocalFile("MyItem.qml")); +view.show(); +//![0] + + return app.exec(); +} + diff --git a/doc/src/snippets/qml/qtbinding/enums/imageviewer.h b/doc/src/snippets/qml/qtbinding/enums/imageviewer.h new file mode 100644 index 0000000000..df9709953f --- /dev/null +++ b/doc/src/snippets/qml/qtbinding/enums/imageviewer.h @@ -0,0 +1,68 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include +#include + +//![start] +class ImageViewer : public QQuickItem +{ + Q_OBJECT + Q_ENUMS(Status) + Q_PROPERTY(Status status READ status NOTIFY statusChanged) +public: + enum Status { + Ready, + Loading, + Error + }; + + Status status() const; +//![start] + + ImageViewer(QQuickItem *parent = 0); + +public slots: + void emitSignals(); + +//![end] +signals: + void statusChanged(); +}; +//![end] diff --git a/doc/src/snippets/qml/qtbinding/enums/standalone.qml b/doc/src/snippets/qml/qtbinding/enums/standalone.qml new file mode 100644 index 0000000000..5641854175 --- /dev/null +++ b/doc/src/snippets/qml/qtbinding/enums/standalone.qml @@ -0,0 +1,64 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +import MyLibrary 1.0 +import QtQuick 2.0 + +Item { + +//![0] +ImageViewer { + onStatusChanged: { + if (status == ImageViewer.Ready) + console.log("Image viewer is ready!") + } +} +//![0] + +//![1] +ImageViewer { + signal someOtherSignal(int statusValue) + + Component.onCompleted: { + someOtherSignal(ImageViewer.Loading) + } +} +//![1] + +} diff --git a/doc/src/snippets/qml/qtbinding/functions-cpp/MyItem.qml b/doc/src/snippets/qml/qtbinding/functions-cpp/MyItem.qml new file mode 100644 index 0000000000..e5ba588b25 --- /dev/null +++ b/doc/src/snippets/qml/qtbinding/functions-cpp/MyItem.qml @@ -0,0 +1,55 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +//![0] +// MyItem.qml +import QtQuick 2.0 + +Item { + width: 100; height: 100 + + MouseArea { + anchors.fill: parent + onClicked: { + myObject.cppMethod("Hello from QML") + myObject.cppSlot(12345) + } + } +} +//![0] diff --git a/doc/src/snippets/qml/qtbinding/functions-cpp/main.cpp b/doc/src/snippets/qml/qtbinding/functions-cpp/main.cpp new file mode 100644 index 0000000000..3d63e055a3 --- /dev/null +++ b/doc/src/snippets/qml/qtbinding/functions-cpp/main.cpp @@ -0,0 +1,59 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include +#include + +#include "myclass.h" + +//![0] +int main(int argc, char *argv[]) { + QApplication app(argc, argv); + + QQuickView view; + MyClass myClass; + view.rootContext()->setContextProperty("myObject", &myClass); + + view.setSource(QUrl::fromLocalFile("MyItem.qml")); + view.show(); + + return app.exec(); +} +//![0] + diff --git a/doc/src/snippets/qml/qtbinding/functions-cpp/myclass.h b/doc/src/snippets/qml/qtbinding/functions-cpp/myclass.h new file mode 100644 index 0000000000..8b6847ca99 --- /dev/null +++ b/doc/src/snippets/qml/qtbinding/functions-cpp/myclass.h @@ -0,0 +1,57 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include +#include + +//![0] +class MyClass : public QObject +{ + Q_OBJECT +public: + Q_INVOKABLE void cppMethod(const QString &msg) { + qDebug() << "Called the C++ method with" << msg; + } + +public slots: + void cppSlot(int number) { + qDebug() << "Called the C++ slot with" << number; + } +}; +//![0] diff --git a/doc/src/snippets/qml/qtbinding/functions-qml/MyItem.qml b/doc/src/snippets/qml/qtbinding/functions-qml/MyItem.qml new file mode 100644 index 0000000000..a8b41d55a0 --- /dev/null +++ b/doc/src/snippets/qml/qtbinding/functions-qml/MyItem.qml @@ -0,0 +1,50 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +//![0] +// MyItem.qml +import QtQuick 2.0 + +Item { + function myQmlFunction(msg) { + console.log("Got message:", msg) + return "some return value" + } +} +//![0] diff --git a/doc/src/snippets/qml/qtbinding/functions-qml/main.cpp b/doc/src/snippets/qml/qtbinding/functions-qml/main.cpp new file mode 100644 index 0000000000..5c6a0c507d --- /dev/null +++ b/doc/src/snippets/qml/qtbinding/functions-qml/main.cpp @@ -0,0 +1,63 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include +#include + +int main(int argc, char *argv[]) +{ + QApplication app(argc, argv); + +//![0] +// main.cpp +QQmlEngine engine; +QQmlComponent component(&engine, "MyItem.qml"); +QObject *object = component.create(); + +QVariant returnedValue; +QVariant msg = "Hello from C++"; +QMetaObject::invokeMethod(object, "myQmlFunction", + Q_RETURN_ARG(QVariant, returnedValue), + Q_ARG(QVariant, msg)); + +qDebug() << "QML function returned:" << returnedValue.toString(); +delete object; +//![0] +} + diff --git a/doc/src/snippets/qml/qtbinding/loading/MyItem.qml b/doc/src/snippets/qml/qtbinding/loading/MyItem.qml new file mode 100644 index 0000000000..b496479c95 --- /dev/null +++ b/doc/src/snippets/qml/qtbinding/loading/MyItem.qml @@ -0,0 +1,56 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +//![start] +import QtQuick 2.0 + +Item { + width: 100; height: 100 +//![start] + +//![child] + Rectangle { + anchors.fill: parent + objectName: "rect" + } +//![child] + +//![end] +} +//![end] diff --git a/doc/src/snippets/qml/qtbinding/loading/main.cpp b/doc/src/snippets/qml/qtbinding/loading/main.cpp new file mode 100644 index 0000000000..98ed4173f9 --- /dev/null +++ b/doc/src/snippets/qml/qtbinding/loading/main.cpp @@ -0,0 +1,90 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include +#include + +static void withComponent() +{ +//![QQmlComponent-a] +// Using QQmlComponent +QQmlEngine engine; +QQmlComponent component(&engine, + QUrl::fromLocalFile("MyItem.qml")); +QObject *object = component.create(); +//![QQmlComponent-a] +} + +int main(int argc, char *argv[]) +{ + QApplication app(argc, argv); + +//![QQuickView] +// Using QQuickView +QQuickView view; +view.setSource(QUrl::fromLocalFile("MyItem.qml")); +view.show(); +QObject *object = view.rootObject(); +//![QQuickView] + +//![properties] +object->setProperty("width", 500); +QQmlProperty(object, "width").write(500); +//![properties] + +//![cast] +QQuickItem *item = qobject_cast(object); +item->setWidth(500); +//![cast] + +//![findChild] +QObject *rect = object->findChild("rect"); +if (rect) + rect->setProperty("color", "red"); +//![findChild] + +//![QQmlComponent-b] +delete object; +//![QQmlComponent-b] + +withComponent(); + + return app.exec(); +} + diff --git a/doc/src/snippets/qml/qtbinding/newelements/imageviewer.h b/doc/src/snippets/qml/qtbinding/newelements/imageviewer.h new file mode 100644 index 0000000000..3559951693 --- /dev/null +++ b/doc/src/snippets/qml/qtbinding/newelements/imageviewer.h @@ -0,0 +1,56 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +//![0] +#include +#include + +class ImageViewer : public QQuickItem +{ + Q_OBJECT + Q_PROPERTY(QUrl image READ image WRITE setImage NOTIFY imageChanged) + +public: + void setImage(const QUrl &url); + QUrl image() const; + +signals: + void imageChanged(); +}; +//![0] diff --git a/doc/src/snippets/qml/qtbinding/newelements/main.cpp b/doc/src/snippets/qml/qtbinding/newelements/main.cpp new file mode 100644 index 0000000000..8ab7eb63f4 --- /dev/null +++ b/doc/src/snippets/qml/qtbinding/newelements/main.cpp @@ -0,0 +1,62 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include +#include + +#include "imageviewer.h" + +void ImageViewer::setImage(const QUrl &url) {} +QUrl ImageViewer::image() const { return QUrl(); } + +int main(int argc, char *argv[]) +{ + QApplication app(argc, argv); + + //![register] + qmlRegisterType("MyLibrary", 1, 0, "ImageViewer"); + //![register] + + QQuickView view; + view.setSource(QUrl::fromLocalFile("standalone.qml")); + view.show(); + + return app.exec(); +} + diff --git a/doc/src/snippets/qml/qtbinding/newelements/standalone.qml b/doc/src/snippets/qml/qtbinding/newelements/standalone.qml new file mode 100644 index 0000000000..d2a8926bd0 --- /dev/null +++ b/doc/src/snippets/qml/qtbinding/newelements/standalone.qml @@ -0,0 +1,44 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +//![0] +import MyLibrary 1.0 + +ImageViewer { image: "smile.png" } +//![0] diff --git a/doc/src/snippets/qml/qtbinding/properties-cpp/MyItem.qml b/doc/src/snippets/qml/qtbinding/properties-cpp/MyItem.qml new file mode 100644 index 0000000000..f2a14d92a4 --- /dev/null +++ b/doc/src/snippets/qml/qtbinding/properties-cpp/MyItem.qml @@ -0,0 +1,54 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +//![0] +// MyItem.qml +import QtQuick 2.0 + +Rectangle { + width: 100; height: 100 + color: applicationData.backgroundColor + + MouseArea { + anchors.fill: parent + onClicked: applicationData.backgroundColor = "red" + } +} +//![0] + diff --git a/doc/src/snippets/qml/qtbinding/properties-cpp/applicationdata.h b/doc/src/snippets/qml/qtbinding/properties-cpp/applicationdata.h new file mode 100644 index 0000000000..b558e8528f --- /dev/null +++ b/doc/src/snippets/qml/qtbinding/properties-cpp/applicationdata.h @@ -0,0 +1,71 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include + +//![0] +class ApplicationData : public QObject +{ + Q_OBJECT + Q_PROPERTY(QColor backgroundColor + READ backgroundColor + WRITE setBackgroundColor + NOTIFY backgroundColorChanged) + +public: + void setBackgroundColor(const QColor &c) { + if (c != m_color) { + m_color = c; + emit backgroundColorChanged(); + } + } + + QColor backgroundColor() const { + return m_color; + } + +signals: + void backgroundColorChanged(); + +private: + QColor m_color; +}; +//![0] diff --git a/doc/src/snippets/qml/qtbinding/properties-qml/MyItem.qml b/doc/src/snippets/qml/qtbinding/properties-qml/MyItem.qml new file mode 100644 index 0000000000..87015eac24 --- /dev/null +++ b/doc/src/snippets/qml/qtbinding/properties-qml/MyItem.qml @@ -0,0 +1,47 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +//![0] +// MyItem.qml +import QtQuick 2.0 + +Item { + property int someNumber: 100 +} +//![0] diff --git a/doc/src/snippets/qml/qtbinding/properties-qml/main.cpp b/doc/src/snippets/qml/qtbinding/properties-qml/main.cpp new file mode 100644 index 0000000000..15cb517c7b --- /dev/null +++ b/doc/src/snippets/qml/qtbinding/properties-qml/main.cpp @@ -0,0 +1,61 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include +#include + +int main(int argc, char *argv[]) +{ + QApplication app(argc, argv); + +//![0] +QQmlEngine engine; +QQmlComponent component(&engine, "MyItem.qml"); +QObject *object = component.create(); + +qDebug() << "Property value:" << QQmlProperty::read(object, "someNumber").toInt(); +QQmlProperty::write(object, "someNumber", 5000); + +qDebug() << "Property value:" << object->property("someNumber").toInt(); +object->setProperty("someNumber", 100); +//![0] + + return app.exec(); +} + diff --git a/doc/src/snippets/qml/qtbinding/resources/example.qrc b/doc/src/snippets/qml/qtbinding/resources/example.qrc new file mode 100644 index 0000000000..5e4941512b --- /dev/null +++ b/doc/src/snippets/qml/qtbinding/resources/example.qrc @@ -0,0 +1,10 @@ + + + + + main.qml + images/background.png + + + + diff --git a/doc/src/snippets/qml/qtbinding/resources/main.cpp b/doc/src/snippets/qml/qtbinding/resources/main.cpp new file mode 100644 index 0000000000..2902064fc9 --- /dev/null +++ b/doc/src/snippets/qml/qtbinding/resources/main.cpp @@ -0,0 +1,57 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include +#include + +//![0] +int main(int argc, char *argv[]) +{ + QApplication app(argc, argv); + + QQuickView view; + view.setSource(QUrl("qrc:/main.qml")); + view.show(); + + return app.exec(); +} +//![0] + diff --git a/doc/src/snippets/qml/qtbinding/resources/main.qml b/doc/src/snippets/qml/qtbinding/resources/main.qml new file mode 100644 index 0000000000..670d1a5309 --- /dev/null +++ b/doc/src/snippets/qml/qtbinding/resources/main.qml @@ -0,0 +1,46 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +//![0] +// main.qml +import QtQuick 2.0 + +Image { source: "images/background.png" } +//![0] diff --git a/doc/src/snippets/qml/qtbinding/resources/resources.pro b/doc/src/snippets/qml/qtbinding/resources/resources.pro new file mode 100644 index 0000000000..5aee288a6e --- /dev/null +++ b/doc/src/snippets/qml/qtbinding/resources/resources.pro @@ -0,0 +1,4 @@ +QT += qml + +SOURCES += main.cpp +RESOURCES += example.qrc diff --git a/doc/src/snippets/qml/qtbinding/signals-cpp/MyItem.qml b/doc/src/snippets/qml/qtbinding/signals-cpp/MyItem.qml new file mode 100644 index 0000000000..17df7704c5 --- /dev/null +++ b/doc/src/snippets/qml/qtbinding/signals-cpp/MyItem.qml @@ -0,0 +1,50 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +//![0] +// MyItem.qml +import QtQuick 2.0 + +Item { + Connections { + target: imageViewer + onImageChanged: console.log("Image has changed!") + } +} +//![0] diff --git a/doc/src/snippets/qml/qtbinding/signals-cpp/imageviewer.h b/doc/src/snippets/qml/qtbinding/signals-cpp/imageviewer.h new file mode 100644 index 0000000000..3423295234 --- /dev/null +++ b/doc/src/snippets/qml/qtbinding/signals-cpp/imageviewer.h @@ -0,0 +1,64 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include +#include + +//![start] +class ImageViewer : public QQuickItem +{ + Q_OBJECT + Q_PROPERTY(QUrl image READ image WRITE setImage NOTIFY imageChanged) +public: +//![start] + ImageViewer(QQuickItem *item = 0); + + void setImage(const QUrl &url) {} + QUrl image() const { return QUrl(); } + +public slots: + void emitSignals(); + +//![end] +signals: + void imageChanged(); + void loadingError(const QString &errorMsg); +}; +//![end] + diff --git a/doc/src/snippets/qml/qtbinding/signals-cpp/main.cpp b/doc/src/snippets/qml/qtbinding/signals-cpp/main.cpp new file mode 100644 index 0000000000..402e811913 --- /dev/null +++ b/doc/src/snippets/qml/qtbinding/signals-cpp/main.cpp @@ -0,0 +1,81 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include +#include + +#include "imageviewer.h" + + +ImageViewer::ImageViewer(QQuickItem *item) + : QQuickItem(item) +{ + QTimer::singleShot(0, this, SLOT(emitSignals())); +} + +void ImageViewer::emitSignals() +{ + emit imageChanged(); + emit loadingError("some error message"); +} + +int main(int argc, char *argv[]) +{ + QApplication app(argc, argv); + + qmlRegisterType("MyLibrary", 1, 0, "ImageViewer"); + + QQuickView standalone; + standalone.setSource(QUrl::fromLocalFile("standalone.qml")); + standalone.show(); + +//![connections] +ImageViewer viewer; + +QQuickView view; +view.rootContext()->setContextProperty("imageViewer", &viewer); + +view.setSource(QUrl::fromLocalFile("MyItem.qml")); +view.show(); +//![connections] + + return app.exec(); +} + + diff --git a/doc/src/snippets/qml/qtbinding/signals-cpp/standalone.qml b/doc/src/snippets/qml/qtbinding/signals-cpp/standalone.qml new file mode 100644 index 0000000000..33afc1f39c --- /dev/null +++ b/doc/src/snippets/qml/qtbinding/signals-cpp/standalone.qml @@ -0,0 +1,48 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +import MyLibrary 1.0 + +//![0] +ImageViewer { + onImageChanged: console.log("Image changed!") + onLoadingError: console.log("Image failed to load:", errorMsg) +} +//![0] + diff --git a/doc/src/snippets/qml/qtbinding/signals-qml/MyItem.qml b/doc/src/snippets/qml/qtbinding/signals-qml/MyItem.qml new file mode 100644 index 0000000000..9269b51863 --- /dev/null +++ b/doc/src/snippets/qml/qtbinding/signals-qml/MyItem.qml @@ -0,0 +1,55 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +//![0] +// MyItem.qml +import QtQuick 2.0 + +Item { + id: item + width: 100; height: 100 + + signal qmlSignal(string msg) + + MouseArea { + anchors.fill: parent + onClicked: item.qmlSignal("Hello from QML") + } +} +//![0] diff --git a/doc/src/snippets/qml/qtbinding/signals-qml/main.cpp b/doc/src/snippets/qml/qtbinding/signals-qml/main.cpp new file mode 100644 index 0000000000..8528d9ce5e --- /dev/null +++ b/doc/src/snippets/qml/qtbinding/signals-qml/main.cpp @@ -0,0 +1,59 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include +#include + +//![0] +int main(int argc, char *argv[]) { + QApplication app(argc, argv); + + QQuickView view(QUrl::fromLocalFile("MyItem.qml")); + QObject *item = view.rootObject(); + + MyClass myClass; + QObject::connect(item, SIGNAL(qmlSignal(QString)), + &myClass, SLOT(cppSlot(QString))); + + view.show(); + return app.exec(); +} +//![0] + +#include "moc_main.cpp" diff --git a/doc/src/snippets/qml/qtbinding/signals-qml/myclass.h b/doc/src/snippets/qml/qtbinding/signals-qml/myclass.h new file mode 100644 index 0000000000..6275de6b2c --- /dev/null +++ b/doc/src/snippets/qml/qtbinding/signals-qml/myclass.h @@ -0,0 +1,51 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include +#include +//![0] +class MyClass : public QObject +{ + Q_OBJECT +public slots: + void cppSlot(const QString &msg) { + qDebug() << "Called the C++ slot with message:" << msg; + } +}; +//![0] diff --git a/doc/src/snippets/qml/qtbinding/variantlistmap/MyItem.qml b/doc/src/snippets/qml/qtbinding/variantlistmap/MyItem.qml new file mode 100644 index 0000000000..ff4be87795 --- /dev/null +++ b/doc/src/snippets/qml/qtbinding/variantlistmap/MyItem.qml @@ -0,0 +1,54 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +import QtQuick 2.0 + +//![0] +// MyItem.qml +Item { + function readValues(anArray, anObject) { + for (var i=0; i +#include + +int main(int argc, char *argv[]) { + QApplication app(argc, argv); + +//![0] +// C++ +QQuickView view(QUrl::fromLocalFile("MyItem.qml")); + +QVariantList list; +list << 10 << Qt::green << "bottles"; + +QVariantMap map; +map.insert("language", "QML"); +map.insert("released", QDate(2010, 9, 21)); + +QMetaObject::invokeMethod(view.rootObject(), "readValues", + Q_ARG(QVariant, QVariant::fromValue(list)), + Q_ARG(QVariant, QVariant::fromValue(map))); +//![0] + + view.setSource(QUrl::fromLocalFile("MyItem.qml")); + view.show(); + + return app.exec(); +} + diff --git a/doc/src/snippets/qml/qtobject.qml b/doc/src/snippets/qml/qtobject.qml new file mode 100644 index 0000000000..04811b6316 --- /dev/null +++ b/doc/src/snippets/qml/qtobject.qml @@ -0,0 +1,54 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +//![0] +import QtQuick 2.0 + +Item { + QtObject { + id: attributes + property string name + property int size + property variant attributes + } + + Text { text: attributes.name } +} +//![0] + diff --git a/doc/src/snippets/qml/rectangle/rect-border-width.qml b/doc/src/snippets/qml/rectangle/rect-border-width.qml new file mode 100644 index 0000000000..6dd4dbe739 --- /dev/null +++ b/doc/src/snippets/qml/rectangle/rect-border-width.qml @@ -0,0 +1,59 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +//![0] +Rectangle { + width: 100; height: 100 + color: "lightblue" + + Rectangle { + anchors.fill: parent + anchors.margins: 10 + clip: true + + Rectangle { + anchors.fill: parent + border.width: 1 + } + } +} +//![0] diff --git a/doc/src/snippets/qml/rectangle/rectangle-colors.qml b/doc/src/snippets/qml/rectangle/rectangle-colors.qml new file mode 100644 index 0000000000..70f7a203f4 --- /dev/null +++ b/doc/src/snippets/qml/rectangle/rectangle-colors.qml @@ -0,0 +1,62 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Item { + width: 100; height: 200 + +Item { + x: 10; y: 10 + width: 80; height: 180 + +//! [rectangles] +Rectangle { + color: "#00B000" + width: 80; height: 80 +} + +Rectangle { + color: "steelblue" + y: 100; width: 80; height: 80 +} +//! [rectangles] +} +} diff --git a/doc/src/snippets/qml/rectangle/rectangle-gradient.qml b/doc/src/snippets/qml/rectangle/rectangle-gradient.qml new file mode 100644 index 0000000000..e8146a6467 --- /dev/null +++ b/doc/src/snippets/qml/rectangle/rectangle-gradient.qml @@ -0,0 +1,74 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Item { + width: 100; height: 300 + +Item { + x: 10; y: 10 + width: 80; height: 280 + +//! [rectangles] +Rectangle { + y: 0; width: 80; height: 80 + color: "lightsteelblue" +} + +Rectangle { + y: 100; width: 80; height: 80 + gradient: Gradient { + GradientStop { position: 0.0; color: "lightsteelblue" } + GradientStop { position: 1.0; color: "blue" } + } +} + +Rectangle { + y: 200; width: 80; height: 80 + rotation: 90 + gradient: Gradient { + GradientStop { position: 0.0; color: "lightsteelblue" } + GradientStop { position: 1.0; color: "blue" } + } +} +//! [rectangles] +} +} diff --git a/doc/src/snippets/qml/rectangle/rectangle.qml b/doc/src/snippets/qml/rectangle/rectangle.qml new file mode 100644 index 0000000000..c315a27da0 --- /dev/null +++ b/doc/src/snippets/qml/rectangle/rectangle.qml @@ -0,0 +1,52 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +//! [document] +import QtQuick 2.0 + +Rectangle { + width: 100 + height: 100 + color: "red" + border.color: "black" + border.width: 5 + radius: 10 +} +//! [document] diff --git a/doc/src/snippets/qml/repeaters/repeater-grid-index.qml b/doc/src/snippets/qml/repeaters/repeater-grid-index.qml new file mode 100644 index 0000000000..0f2b770d82 --- /dev/null +++ b/doc/src/snippets/qml/repeaters/repeater-grid-index.qml @@ -0,0 +1,61 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +//! [document] +import QtQuick 2.0 + +Rectangle { + width: 400; height: 400; color: "black" + + Grid { + x: 5; y: 5 + rows: 5; columns: 5; spacing: 10 + + Repeater { model: 24 + Rectangle { width: 70; height: 70 + color: "lightgreen" + + Text { text: index + font.pointSize: 30 + anchors.centerIn: parent } } + } + } +} +//! [document] diff --git a/doc/src/snippets/qml/repeaters/repeater.qml b/doc/src/snippets/qml/repeaters/repeater.qml new file mode 100644 index 0000000000..856b038a04 --- /dev/null +++ b/doc/src/snippets/qml/repeaters/repeater.qml @@ -0,0 +1,89 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +//! [import] +import QtQuick 2.0 +//! [import] + +Row { + +//! [simple] +Row { + Repeater { + model: 3 + Rectangle { + width: 100; height: 40 + border.width: 1 + color: "yellow" + } + } +} +//! [simple] + +//! [index] +Column { + Repeater { + model: 10 + Text { text: "I'm item " + index } + } +} +//! [index] + +//! [modeldata] +Column { + Repeater { + model: ["apples", "oranges", "pears"] + Text { text: "Data: " + modelData } + } +} +//! [modeldata] + +//! [layout] +Row { + Rectangle { width: 10; height: 20; color: "red" } + Repeater { + model: 10 + Rectangle { width: 20; height: 20; radius: 10; color: "green" } + } + Rectangle { width: 10; height: 20; color: "blue" } +} +//! [layout] + +} diff --git a/doc/src/snippets/qml/reusablecomponents/Button.qml b/doc/src/snippets/qml/reusablecomponents/Button.qml new file mode 100644 index 0000000000..cedc782f75 --- /dev/null +++ b/doc/src/snippets/qml/reusablecomponents/Button.qml @@ -0,0 +1,87 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +//! [document] +//contents of Button.qml +import QtQuick 2.0 + +//! [parent begin] +Rectangle { +//! [parent begin] + id: button +//! [properties] + width: 145; height: 60 + color: "blue" + smooth: true; radius: 9 + property alias text: label.text +//! [properties] +//! [object alias] + property alias label: label +//! [object alias] + border {color: "#B9C5D0"; width: 1} + + gradient: Gradient { + GradientStop {color: "#CFF7FF"; position: 0.0} + GradientStop {color: "#99C0E5"; position: 0.57} + GradientStop {color: "#719FCB"; position: 0.9} + } +//![text] + Text { + id: label + anchors.centerIn: parent + text: "Click Me!" + font.pointSize: 12 + color: "blue" + } +//![text] + MouseArea { + anchors.fill: parent + onClicked: console.log(text + " clicked") + } +//! [parent end] +} +//! [parent end] + +//! [document] + +//! [ellipses] + //... +//! [ellipses] + + diff --git a/doc/src/snippets/qml/reusablecomponents/application.qml b/doc/src/snippets/qml/reusablecomponents/application.qml new file mode 100644 index 0000000000..42428ce25e --- /dev/null +++ b/doc/src/snippets/qml/reusablecomponents/application.qml @@ -0,0 +1,58 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +//! [document] +import QtQuick 2.0 + +Rectangle { + width: 175; height: 350 + color: "lightgrey" + + Column { + anchors.centerIn: parent + spacing: 15 + Button {} + Button {text: "Me Too!"} + Button {text: "Me Three!"} +//! [grouped property] + Button {label.color: "green"} +//! [grouped property] + } +} +//! [document] diff --git a/doc/src/snippets/qml/reusablecomponents/component.qml b/doc/src/snippets/qml/reusablecomponents/component.qml new file mode 100644 index 0000000000..9a60468d73 --- /dev/null +++ b/doc/src/snippets/qml/reusablecomponents/component.qml @@ -0,0 +1,77 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +//! [document] +import QtQuick 2.0 + +//! [parent begin] +Rectangle { +//! [parent begin] + id: screen + width: 175; height: 175 + color: "lightgrey" + +//! [define inline component] + Component { + id: inlinecomponent + Rectangle { + id: display + width: 50; height: 50 + color: "blue" + } + } +//! [define inline component] +//! [create inline component] + MouseArea { + anchors.fill: parent + onClicked: { + inlinecomponent.createObject(parent) + + var second = inlinecomponent.createObject(parent) + + var third = inlinecomponent.createObject(parent) + third.x = second.width + 10 + third.color = "red" + } + } +//! [create inline component] +//! [parent end] +} +//! [parent end] +//! [document] diff --git a/doc/src/snippets/qml/reusablecomponents/focusbutton.qml b/doc/src/snippets/qml/reusablecomponents/focusbutton.qml new file mode 100644 index 0000000000..34fc6294e2 --- /dev/null +++ b/doc/src/snippets/qml/reusablecomponents/focusbutton.qml @@ -0,0 +1,98 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +//! [document] +//contents of focusbutton.qml +import QtQuick 2.0 + +//! [parent begin] +FocusScope { +//! [parent begin] + + //! [expose visuals] + //FocusScope needs to bind to visual properties of the children + property alias color: button.color + x: button.x; y: button.y + width: button.width; height: button.height + //! [expose visuals] + + //! [rectangle begin] + Rectangle { + //! [rectangle begin] + id: button + //! [properties] + width: 145; height: 60 + color: "blue" + smooth: true; radius: 9 + property alias text: label.text + //! [properties] + border {color: "#B9C5D0"; width: 1} + + gradient: Gradient { + GradientStop {color: "#CFF7FF"; position: 0.0} + GradientStop {color: "#99C0E5"; position: 0.57} + GradientStop {color: "#719FCB"; position: 0.9} + } + + Text { + id: label + anchors.centerIn: parent + text: "Click Me!" + font.pointSize: 12 + color: "blue" + } + + MouseArea { + anchors.fill: parent + onClicked: console.log(text + " clicked") + } + //! [rectangle end] + } + //! [rectangle end] +//! [parent end] +} +//! [parent end] + +//! [document] + +//! [ellipses] + //... +//! [ellipses] + + diff --git a/doc/src/snippets/qml/reusablecomponents/qmldir b/doc/src/snippets/qml/reusablecomponents/qmldir new file mode 100644 index 0000000000..253732de01 --- /dev/null +++ b/doc/src/snippets/qml/reusablecomponents/qmldir @@ -0,0 +1,4 @@ +//! [document] +Button ./Button.qml +FocusButton ./focusbutton.qml +//! [document] diff --git a/doc/src/snippets/qml/righttoleft.qml b/doc/src/snippets/qml/righttoleft.qml new file mode 100644 index 0000000000..0566be2f67 --- /dev/null +++ b/doc/src/snippets/qml/righttoleft.qml @@ -0,0 +1,149 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import "righttoleft" + +Column { + width: 200 +//![0] +// automatically aligned to the left +Text { + text: "Phone" + width: 200 +} + +// automatically aligned to the right +Text { + text: "خامل" + width: 200 +} + +// aligned to the left +Text { + text: "خامل" + horizontalAlignment: Text.AlignLeft + width: 200 +} + +// aligned to the right +Text { + text: "خامل" + horizontalAlignment: Text.AlignLeft + LayoutMirroring.enabled: true + width: 200 +} +//![0] + +//![1] +// by default child items are positioned from left to right +Row { + Child {} + Child {} +} + +// position child items from right to left +Row { + layoutDirection: Qt.RightToLeft + Child {} + Child {} +} + +// position child items from left to right +Row { + LayoutMirroring.enabled: true + layoutDirection: Qt.RightToLeft + Child {} + Child {} +} +//![1] + +//![2] +Item { + height: 50; width: 150 + + LayoutMirroring.enabled: true + anchors.left: parent.left // anchor left becomes right + + Row { + // items flow from left to right (as per default) + Child {} + Child {} + Child {} + } +} +//![2] + +//![3] +Item { + height: 50; width: 150 + + LayoutMirroring.enabled: true + LayoutMirroring.childrenInherit: true + anchors.left: parent.left // anchor left becomes right + + Row { + // setting childrenInherit in the parent causes these + // items to flow from right to left instead + Child {} + Child {} + Child {} + } +} +//![3] + +//![4] +Rectangle { + color: "black" + height: 50; width: 50 + x: mirror(10) + function mirror(value) { + return LayoutMirroring.enabled ? (parent.width - width - value) : value; + } +} +//![4] + +//![5] +Image { + source: "arrow.png" + mirror: true +} +//![5] +} diff --git a/doc/src/snippets/qml/righttoleft/Child.qml b/doc/src/snippets/qml/righttoleft/Child.qml new file mode 100644 index 0000000000..50068540cb --- /dev/null +++ b/doc/src/snippets/qml/righttoleft/Child.qml @@ -0,0 +1,51 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Rectangle { + width: 50; height: 50 + color: "black" + Text { + color: "white" + text: String.fromCharCode(65 + Math.floor(26*Math.random())) + anchors.centerIn: parent + } +} diff --git a/doc/src/snippets/qml/rotation.qml b/doc/src/snippets/qml/rotation.qml new file mode 100644 index 0000000000..c7f9df3a9b --- /dev/null +++ b/doc/src/snippets/qml/rotation.qml @@ -0,0 +1,69 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +//! [0] +import QtQuick 2.0 + +Row { + x: 10; y: 10 + spacing: 10 + + Image { source: "pics/qt.png" } + Image { + source: "pics/qt.png" + transform: Rotation { origin.x: 30; origin.y: 30; axis { x: 0; y: 1; z: 0 } angle: 18 } + smooth: true + } + Image { + source: "pics/qt.png" + transform: Rotation { origin.x: 30; origin.y: 30; axis { x: 0; y: 1; z: 0 } angle: 36 } + smooth: true + } + Image { + source: "pics/qt.png" + transform: Rotation { origin.x: 30; origin.y: 30; axis { x: 0; y: 1; z: 0 } angle: 54 } + smooth: true + } + Image { + source: "pics/qt.png" + transform: Rotation { origin.x: 30; origin.y: 30; axis { x: 0; y: 1; z: 0 } angle: 72 } + smooth: true + } +} +//! [0] diff --git a/doc/src/snippets/qml/rotationanimation.qml b/doc/src/snippets/qml/rotationanimation.qml new file mode 100644 index 0000000000..caa1ce8207 --- /dev/null +++ b/doc/src/snippets/qml/rotationanimation.qml @@ -0,0 +1,66 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +//![0] +import QtQuick 2.0 + +Item { + width: 300; height: 300 + + Rectangle { + id: rect + width: 150; height: 100; anchors.centerIn: parent + color: "red" + smooth: true + + states: State { + name: "rotated" + PropertyChanges { target: rect; rotation: 180 } + } + + transitions: Transition { + RotationAnimation { duration: 1000; direction: RotationAnimation.Counterclockwise } + } + } + + MouseArea { anchors.fill: parent; onClicked: rect.state = "rotated" } +} +//![0] + diff --git a/doc/src/snippets/qml/row.qml b/doc/src/snippets/qml/row.qml new file mode 100644 index 0000000000..3e505717d6 --- /dev/null +++ b/doc/src/snippets/qml/row.qml @@ -0,0 +1,62 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +//! [document] +import QtQuick 2.0 + +Rectangle { + width: 320; height: 110 + color: "#c0c0c0" + + Row { + anchors.horizontalCenter: parent.horizontalCenter + anchors.verticalCenter: parent.verticalCenter + + spacing: 5 + + Rectangle { width: 100; height: 100; radius: 20.0 + color: "#024c1c" } + Rectangle { width: 100; height: 100; radius: 20.0 + color: "#42a51c" } + Rectangle { width: 100; height: 100; radius: 20.0 + color: "white" } + } +} +//! [document] diff --git a/doc/src/snippets/qml/row/row.qml b/doc/src/snippets/qml/row/row.qml new file mode 100644 index 0000000000..465baa577b --- /dev/null +++ b/doc/src/snippets/qml/row/row.qml @@ -0,0 +1,50 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +//! [document] +import QtQuick 2.0 + +Row { + spacing: 2 + Rectangle { color: "red"; width: 50; height: 50 } + Rectangle { color: "green"; width: 20; height: 50 } + Rectangle { color: "blue"; width: 50; height: 20 } +} +//! [document] diff --git a/doc/src/snippets/qml/script.js b/doc/src/snippets/qml/script.js new file mode 100644 index 0000000000..f55dee3507 --- /dev/null +++ b/doc/src/snippets/qml/script.js @@ -0,0 +1,4 @@ +WorkerScript.onMessage = function(message) { + // ... long-running operations and calculations are done here + WorkerScript.sendMessage({ 'reply': 'Mouse is at ' + message.x + ',' + message.y }) +} diff --git a/doc/src/snippets/qml/sequentialanimation.qml b/doc/src/snippets/qml/sequentialanimation.qml new file mode 100644 index 0000000000..73923e4ea0 --- /dev/null +++ b/doc/src/snippets/qml/sequentialanimation.qml @@ -0,0 +1,56 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +//![0] +import QtQuick 2.0 + +Rectangle { + id: rect + width: 100; height: 100 + color: "red" + + SequentialAnimation { + running: true + NumberAnimation { target: rect; property: "x"; to: 50; duration: 1000 } + NumberAnimation { target: rect; property: "y"; to: 50; duration: 1000 } + } +} +//![0] + diff --git a/doc/src/snippets/qml/smoothedanimation.qml b/doc/src/snippets/qml/smoothedanimation.qml new file mode 100644 index 0000000000..ba6f505976 --- /dev/null +++ b/doc/src/snippets/qml/smoothedanimation.qml @@ -0,0 +1,69 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +//![0] +import QtQuick 2.0 + +Rectangle { + width: 800; height: 600 + color: "blue" + + Rectangle { + width: 60; height: 60 + x: rect1.x - 5; y: rect1.y - 5 + color: "green" + + Behavior on x { SmoothedAnimation { velocity: 200 } } + Behavior on y { SmoothedAnimation { velocity: 200 } } + } + + Rectangle { + id: rect1 + width: 50; height: 50 + color: "red" + } + + focus: true + Keys.onRightPressed: rect1.x = rect1.x + 100 + Keys.onLeftPressed: rect1.x = rect1.x - 100 + Keys.onUpPressed: rect1.y = rect1.y - 100 + Keys.onDownPressed: rect1.y = rect1.y + 100 +} +//![0] diff --git a/doc/src/snippets/qml/springanimation.qml b/doc/src/snippets/qml/springanimation.qml new file mode 100644 index 0000000000..e04c483405 --- /dev/null +++ b/doc/src/snippets/qml/springanimation.qml @@ -0,0 +1,65 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +//![0] +import QtQuick 2.0 + +Item { + width: 300; height: 300 + + Rectangle { + id: rect + width: 50; height: 50 + color: "red" + + Behavior on x { SpringAnimation { spring: 2; damping: 0.2 } } + Behavior on y { SpringAnimation { spring: 2; damping: 0.2 } } + } + + MouseArea { + anchors.fill: parent + onClicked: { + rect.x = mouse.x - rect.width/2 + rect.y = mouse.y - rect.height/2 + } + } +} +//![0] + diff --git a/doc/src/snippets/qml/state-when.qml b/doc/src/snippets/qml/state-when.qml new file mode 100644 index 0000000000..de9fb39cef --- /dev/null +++ b/doc/src/snippets/qml/state-when.qml @@ -0,0 +1,54 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +import QtQuick 2.0 +//![0] +Rectangle { + id: myRect + width: 100; height: 100 + color: "red" + + MouseArea { id: mouseArea; anchors.fill: parent } + + states: State { + name: "hidden"; when: mouseArea.pressed + PropertyChanges { target: myRect; opacity: 0 } + } +} +//![0] diff --git a/doc/src/snippets/qml/state.qml b/doc/src/snippets/qml/state.qml new file mode 100644 index 0000000000..5948cba770 --- /dev/null +++ b/doc/src/snippets/qml/state.qml @@ -0,0 +1,61 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +//![0] +import QtQuick 2.0 + +Rectangle { + id: myRect + width: 100; height: 100 + color: "black" + + MouseArea { + id: mouseArea + anchors.fill: parent + onClicked: myRect.state == 'clicked' ? myRect.state = "" : myRect.state = 'clicked'; + } + + states: [ + State { + name: "clicked" + PropertyChanges { target: myRect; color: "red" } + } + ] +} +//![0] diff --git a/doc/src/snippets/qml/states.qml b/doc/src/snippets/qml/states.qml new file mode 100644 index 0000000000..aeb805f38e --- /dev/null +++ b/doc/src/snippets/qml/states.qml @@ -0,0 +1,121 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +//![document] +import QtQuick 2.0 + +//![parent begin] +Rectangle { +//![parent begin] + + id: screen + width: 400; height: 500 + + +Rectangle { + id: flag +} +Column { + spacing: 15 +//![signal states] +Rectangle { + id: signal + width: 200; height: 200 + state: "NORMAL" + + states: [ + State { + name: "NORMAL" + PropertyChanges { target: signal; color: "green"} + PropertyChanges { target: flag; state: "FLAG_DOWN"} + }, + State { + name: "CRITICAL" + PropertyChanges { target: signal; color: "red"} + PropertyChanges { target: flag; state: "FLAG_UP"} + } + ] +} +//![signal states] + +//![switch states] +Rectangle { + id: signalswitch + width: 75; height: 75 + color: "blue" + + MouseArea { + anchors.fill: parent + onClicked: { + if (signal.state == "NORMAL") + signal.state = "CRITICAL" + else + signal.state = "NORMAL" + } + } +} +//![switch states] + +//![when property] +Rectangle { + id: bell + width: 75; height: 75 + color: "yellow" + + states: State { + name: "RINGING" + when: (signal.state == "CRITICAL") + PropertyChanges {target: speaker; play: "RING!"} + } +} +//![when property] + +Text { + id: speaker + property alias play: speaker.text + text: "NORMAL" +} + +} // end of row + +//![parent end] +} +//![parent end] + +//![document] diff --git a/doc/src/snippets/qml/states/statechangescript.qml b/doc/src/snippets/qml/states/statechangescript.qml new file mode 100644 index 0000000000..262938fc9c --- /dev/null +++ b/doc/src/snippets/qml/states/statechangescript.qml @@ -0,0 +1,63 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Item { +//! [state and transition] +State { + name: "state1" + StateChangeScript { + name: "myScript" + script: doStateStuff(); + } + // ... +} +// ... +Transition { + to: "state1" + SequentialAnimation { + NumberAnimation { /* ... */ } + ScriptAction { scriptName: "myScript" } + NumberAnimation { /* ... */ } + } +} +//! [state and transition] +} diff --git a/doc/src/snippets/qml/systempalette.qml b/doc/src/snippets/qml/systempalette.qml new file mode 100644 index 0000000000..4cb42dee93 --- /dev/null +++ b/doc/src/snippets/qml/systempalette.qml @@ -0,0 +1,54 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +//![0] +import QtQuick 2.0 + +Rectangle { + SystemPalette { id: myPalette; colorGroup: SystemPalette.Active } + + width: 640; height: 480 + color: myPalette.window + + Text { + anchors.fill: parent + text: "Hello!"; color: myPalette.windowText + } +} +//![0] diff --git a/doc/src/snippets/qml/text/onLinkActivated.qml b/doc/src/snippets/qml/text/onLinkActivated.qml new file mode 100644 index 0000000000..03641d989e --- /dev/null +++ b/doc/src/snippets/qml/text/onLinkActivated.qml @@ -0,0 +1,54 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtQml module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +import QtQuick 2.0 + +Rectangle { + width: 700; height: 400 + +//![0] + Text { + textFormat: Text.RichText + text: "The main website is at Nokia Qt DF." + onLinkActivated: console.log(link + " link activated") + } +//![0] + +} + diff --git a/doc/src/snippets/qml/texthandling.qml b/doc/src/snippets/qml/texthandling.qml new file mode 100644 index 0000000000..03e5011202 --- /dev/null +++ b/doc/src/snippets/qml/texthandling.qml @@ -0,0 +1,89 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +//! [document] +import QtQuick 2.0 + + +//! [parent begin] +Rectangle { +//! [parent begin] + width: 300; height: 300 + id: screen + +Column { + anchors.centerIn:parent + +//! [int validator] +Column { + spacing: 10 + + Text { + text: "Enter a value from 0 to 2000" + } + TextInput { + focus: true + validator: IntValidator { bottom:0; top: 2000} + } +} +//! [int validator] + +//! [regexp validator] +Column { + spacing: 10 + + Text { + text: "Which basket?" + } + TextInput { + focus: true + validator: RegExpValidator { regExp: /fruit basket/ } + } +} +//! [regexp validator] + +//end of column +} + +//! [parent end] +} +//! [parent end] + +//! [document] + diff --git a/doc/src/snippets/qml/transition-from-to-modified.qml b/doc/src/snippets/qml/transition-from-to-modified.qml new file mode 100644 index 0000000000..184e95afe2 --- /dev/null +++ b/doc/src/snippets/qml/transition-from-to-modified.qml @@ -0,0 +1,60 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +import QtQuick 2.0 + +Rectangle { + id: rect + width: 100; height: 100 + color: "red" + + MouseArea { id: mouseArea; anchors.fill: parent } + + states: State { + name: "brighter"; when: mouseArea.pressed + PropertyChanges { target: rect; color: "yellow" } + } + + //! [modified transition] + transitions: Transition { + to: "brighter" + ColorAnimation { duration: 1000 } + } + //! [modified transition] +} diff --git a/doc/src/snippets/qml/transition-from-to.qml b/doc/src/snippets/qml/transition-from-to.qml new file mode 100644 index 0000000000..c876f5cb9c --- /dev/null +++ b/doc/src/snippets/qml/transition-from-to.qml @@ -0,0 +1,59 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +import QtQuick 2.0 + +//![0] +Rectangle { + id: rect + width: 100; height: 100 + color: "red" + + MouseArea { id: mouseArea; anchors.fill: parent } + + states: State { + name: "brighter"; when: mouseArea.pressed + PropertyChanges { target: rect; color: "yellow" } + } + + transitions: Transition { + ColorAnimation { duration: 1000 } + } +} +//![0] diff --git a/doc/src/snippets/qml/transition-reversible.qml b/doc/src/snippets/qml/transition-reversible.qml new file mode 100644 index 0000000000..4f7ae83468 --- /dev/null +++ b/doc/src/snippets/qml/transition-reversible.qml @@ -0,0 +1,66 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +import QtQuick 2.0 + +//![0] +Rectangle { + id: rect + width: 100; height: 100 + color: "red" + + MouseArea { id: mouseArea; anchors.fill: parent } + + states: State { + name: "brighter" + when: mouseArea.pressed + PropertyChanges { target: rect; color: "yellow"; x: 50 } + } + + //! [sequential animations] + transitions: Transition { + SequentialAnimation { + PropertyAnimation { property: "x"; duration: 1000 } + ColorAnimation { duration: 1000 } + } + } + //! [sequential animations] +} +//![0] + diff --git a/doc/src/snippets/qml/transition.qml b/doc/src/snippets/qml/transition.qml new file mode 100644 index 0000000000..614c5d364f --- /dev/null +++ b/doc/src/snippets/qml/transition.qml @@ -0,0 +1,63 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +//![0] +import QtQuick 2.0 + +Rectangle { + id: rect + width: 100; height: 100 + color: "red" + + MouseArea { + id: mouseArea + anchors.fill: parent + } + + states: State { + name: "moved"; when: mouseArea.pressed + PropertyChanges { target: rect; x: 50; y: 50 } + } + + transitions: Transition { + NumberAnimation { properties: "x,y"; easing.type: Easing.InOutQuad } + } +} +//![0] + diff --git a/doc/src/snippets/qml/transitions-list.qml b/doc/src/snippets/qml/transitions-list.qml new file mode 100644 index 0000000000..f2ba768559 --- /dev/null +++ b/doc/src/snippets/qml/transitions-list.qml @@ -0,0 +1,89 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Rectangle { + width: 150; height: 250 + + Rectangle { + id: stopLight + x: 25; y: 15; width: 100; height: 100 + } + Rectangle { + id: goLight + x: 25; y: 135; width: 100; height: 100 + } + + states: [ + State { + name: "stop" + PropertyChanges { target: stopLight; color: "red" } + PropertyChanges { target: goLight; color: "black" } + }, + State { + name: "go" + PropertyChanges { target: stopLight; color: "black" } + PropertyChanges { target: goLight; color: "green" } + } + ] + + state: "stop" + + MouseArea { + anchors.fill: parent + onClicked: parent.state == "stop" ? + parent.state = "go" : parent.state = "stop" + } + + //! [list of transitions] + transitions: [ + Transition { + from: "stop"; to: "go" + PropertyAnimation { target: stopLight + properties: "color"; duration: 1000 } + }, + Transition { + from: "go"; to: "stop" + PropertyAnimation { target: goLight + properties: "color"; duration: 1000 } + } ] + //! [list of transitions] +} diff --git a/doc/src/snippets/qml/viewtransitions/viewtransitions-basic.qml b/doc/src/snippets/qml/viewtransitions/viewtransitions-basic.qml new file mode 100644 index 0000000000..8a05491ee1 --- /dev/null +++ b/doc/src/snippets/qml/viewtransitions/viewtransitions-basic.qml @@ -0,0 +1,70 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +//! [0] +ListView { + width: 240; height: 320 + model: ListModel {} + + delegate: Rectangle { + width: 100; height: 30 + border.width: 1 + color: "lightsteelblue" + Text { + anchors.centerIn: parent + text: name + } + } + + add: Transition { + NumberAnimation { property: "opacity"; from: 0; to: 1.0; duration: 400 } + NumberAnimation { property: "scale"; from: 0; to: 1.0; duration: 400 } + } + + addDisplaced: Transition { + NumberAnimation { properties: "x,y"; duration: 400; easing.type: Easing.OutBounce } + } + + focus: true + Keys.onSpacePressed: model.insert(0, { "name": "Item " + model.count }) +} +//! [0] diff --git a/doc/src/snippets/qml/viewtransitions/viewtransitions-delayedbyindex.qml b/doc/src/snippets/qml/viewtransitions/viewtransitions-delayedbyindex.qml new file mode 100644 index 0000000000..79d00d2d1c --- /dev/null +++ b/doc/src/snippets/qml/viewtransitions/viewtransitions-delayedbyindex.qml @@ -0,0 +1,78 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +ListView { + width: 240; height: 320 + model: ListModel {} + + delegate: Rectangle { + width: 100; height: 30 + border.width: 1 + color: "lightsteelblue" + Text { + anchors.centerIn: parent + text: name + } + } + + add: Transition { + NumberAnimation { property: "opacity"; from: 0; to: 1.0; duration: 400 } + NumberAnimation { property: "scale"; from: 0; to: 1.0; duration: 400 } + } + +//! [0] + addDisplaced: Transition { + id: addDispTrans + SequentialAnimation { + PauseAnimation { + duration: (addDispTrans.ViewTransition.index - + addDispTrans.ViewTransition.targetIndexes[0]) * 100 + } + NumberAnimation { properties: "x,y"; duration: 400; easing.type: Easing.OutBounce } + } + } +//! [0] + + focus: true + Keys.onSpacePressed: model.insert(0, { "name": "Item " + model.count }) +} + diff --git a/doc/src/snippets/qml/viewtransitions/viewtransitions-intermediatemove.qml b/doc/src/snippets/qml/viewtransitions/viewtransitions-intermediatemove.qml new file mode 100644 index 0000000000..a43d3a8b7f --- /dev/null +++ b/doc/src/snippets/qml/viewtransitions/viewtransitions-intermediatemove.qml @@ -0,0 +1,90 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +ListView { + width: 240; height: 320 + model: ListModel {} + + delegate: Rectangle { + width: 100; height: 30 + border.width: 1 + color: "lightsteelblue" + Text { + anchors.centerIn: parent + text: name + } + } + + add: Transition { + NumberAnimation { property: "opacity"; from: 0; to: 1.0; duration: 400 } + NumberAnimation { property: "scale"; from: 0; to: 1.0; duration: 400 } + } + +//! [0] + addDisplaced: Transition { + id: addDispTrans + SequentialAnimation { + PauseAnimation { + duration: (addDispTrans.ViewTransition.index - + addDispTrans.ViewTransition.targetIndexes[0]) * 100 + } + ParallelAnimation { + NumberAnimation { + property: "x"; to: addDispTrans.ViewTransition.item.x + 20 + easing.type: Easing.OutQuad + } + NumberAnimation { + property: "y"; to: addDispTrans.ViewTransition.item.y + 50 + easing.type: Easing.OutQuad + } + } + NumberAnimation { properties: "x,y"; duration: 500; easing.type: Easing.OutBounce } + } + } + +//! [0] + + focus: true + Keys.onSpacePressed: model.insert(0, { "name": "Item " + model.count }) +} + + diff --git a/doc/src/snippets/qml/viewtransitions/viewtransitions-interruptedgood.qml b/doc/src/snippets/qml/viewtransitions/viewtransitions-interruptedgood.qml new file mode 100644 index 0000000000..1355268710 --- /dev/null +++ b/doc/src/snippets/qml/viewtransitions/viewtransitions-interruptedgood.qml @@ -0,0 +1,74 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +ListView { + width: 240; height: 320 + model: ListModel {} + + delegate: Rectangle { + width: 100; height: 30 + border.width: 1 + color: "lightsteelblue" + Text { + anchors.centerIn: parent + text: name + } + } + + add: Transition { + NumberAnimation { property: "opacity"; from: 0; to: 1.0; duration: 400 } + NumberAnimation { property: "scale"; from: 0; to: 1.0; duration: 400 } + } + +//! [0] + addDisplaced: Transition { + NumberAnimation { properties: "x,y"; duration: 400; easing.type: Easing.OutBounce } + + // ensure opacity and scale values return to 1.0 + NumberAnimation { property: "opacity"; to: 1.0 } + NumberAnimation { property: "scale"; to: 1.0 } + } +//! [0] + + focus: true + Keys.onSpacePressed: model.insert(0, { "name": "Item " + model.count }) +} diff --git a/doc/src/snippets/qml/viewtransitions/viewtransitions-pathanim.qml b/doc/src/snippets/qml/viewtransitions/viewtransitions-pathanim.qml new file mode 100644 index 0000000000..3d075c4367 --- /dev/null +++ b/doc/src/snippets/qml/viewtransitions/viewtransitions-pathanim.qml @@ -0,0 +1,105 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +ListView { + width: 240; height: 320 + model: ListModel {} + + delegate: Rectangle { + width: 100; height: 30 + border.width: 1 + color: "lightsteelblue" + Text { + anchors.centerIn: parent + text: name + } + } + +//! [0] + add: Transition { + id: addTrans + NumberAnimation { property: "opacity"; from: 0; to: 1.0; duration: 400 } + NumberAnimation { property: "scale"; from: 0; to: 1.0; duration: 400 } + + PathAnimation { + duration: 1000 + path: Path { + startX: addTrans.ViewTransition.destination.x + 200 + startY: addTrans.ViewTransition.destination.y + 200 + PathCurve { relativeX: -100; relativeY: -50 } + PathCurve { relativeX: 50; relativeY: -150 } + PathCurve { + x: addTrans.ViewTransition.destination.x + y: addTrans.ViewTransition.destination.y + } + } + } + } +//! [0] + + addDisplaced: Transition { + id: addDispTrans + SequentialAnimation { + PauseAnimation { + duration: (addDispTrans.ViewTransition.index - + addDispTrans.ViewTransition.targetIndexes[0]) * 100 + } + ParallelAnimation { + NumberAnimation { + property: "x"; to: addDispTrans.ViewTransition.item.x + 20 + easing.type: Easing.OutQuad + } + NumberAnimation { + property: "y"; to: addDispTrans.ViewTransition.item.y + 50 + easing.type: Easing.OutQuad + } + } + NumberAnimation { properties: "x,y"; duration: 500; easing.type: Easing.OutBounce } + } + } + + focus: true + Keys.onSpacePressed: model.insert(0, { "name": "Item " + model.count }) +} + + + diff --git a/doc/src/snippets/qml/viewtransitions/viewtransitions-scriptactionbad.qml b/doc/src/snippets/qml/viewtransitions/viewtransitions-scriptactionbad.qml new file mode 100644 index 0000000000..03348356e1 --- /dev/null +++ b/doc/src/snippets/qml/viewtransitions/viewtransitions-scriptactionbad.qml @@ -0,0 +1,81 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +//! [0] +ListView { + width: 240; height: 320 + model: ListModel { + Component.onCompleted: { + for (var i=0; i<8; i++) + append({"name": i}) + } + } + + delegate: Rectangle { + width: 100; height: 30 + border.width: 1 + color: "lightsteelblue" + Text { + anchors.centerIn: parent + text: name + } + objectName: name + } + + move: Transition { + id: moveTrans + SequentialAnimation { + ColorAnimation { property: "color"; to: "yellow"; duration: 400 } + NumberAnimation { properties: "x,y"; duration: 800; easing.type: Easing.OutBack } + ScriptAction { script: moveTrans.ViewTransition.item.color = "lightsteelblue" } + } + } + + moveDisplaced: Transition { + NumberAnimation { properties: "x,y"; duration: 400; easing.type: Easing.OutBounce } + } + + focus: true + Keys.onSpacePressed: model.move(5, 1, 3) +} +//! [0] + diff --git a/doc/src/snippets/qml/viewtransitions/viewtransitions-scriptactiongood.qml b/doc/src/snippets/qml/viewtransitions/viewtransitions-scriptactiongood.qml new file mode 100644 index 0000000000..eda5c35479 --- /dev/null +++ b/doc/src/snippets/qml/viewtransitions/viewtransitions-scriptactiongood.qml @@ -0,0 +1,84 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +ListView { + width: 240; height: 320 + model: ListModel { + Component.onCompleted: { + for (var i=0; i<8; i++) + append({"name": i}) + } + } + + delegate: Rectangle { + width: 100; height: 30 + border.width: 1 + color: "lightsteelblue" + Text { + anchors.centerIn: parent + text: name + } + objectName: name + } + +//! [0] + move: Transition { + id: moveTrans + SequentialAnimation { + ColorAnimation { property: "color"; to: "yellow"; duration: 400 } + NumberAnimation { properties: "x,y"; duration: 800; easing.type: Easing.OutBack } + //ScriptAction { script: moveTrans.ViewTransition.item.color = "lightsteelblue" } BAD! + + PropertyAction { property: "color"; value: "lightsteelblue" } + } + } +//! [0] + + moveDisplaced: Transition { + NumberAnimation { properties: "x,y"; duration: 400; easing.type: Easing.OutBounce } + } + + focus: true + Keys.onSpacePressed: model.move(5, 1, 3) +} + + diff --git a/doc/src/snippets/qml/visualdatagroup.qml b/doc/src/snippets/qml/visualdatagroup.qml new file mode 100644 index 0000000000..46ac9a3d7a --- /dev/null +++ b/doc/src/snippets/qml/visualdatagroup.qml @@ -0,0 +1,81 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +//![0] +import QtQuick 2.0 + +Rectangle { + width: 200; height: 100 + + VisualDataModel { + id: visualModel + model: ListModel { + ListElement { name: "Apple" } + ListElement { name: "Orange" } + } + + groups: [ + VisualDataGroup { name: "selected" } + ] + + delegate: Rectangle { + id: item + height: 25 + width: 200 + Text { + text: { + var text = "Name: " + name + if (item.VisualDataModel.inSelected) + text += " (" + item.VisualDataModel.selectedIndex + ")" + return text; + } + } + MouseArea { + anchors.fill: parent + onClicked: item.VisualDataModel.inSelected = !item.VisualDataModel.inSelected + } + } + } + + ListView { + anchors.fill: parent + model: visualModel + } +} +//![0] diff --git a/doc/src/snippets/qml/visualdatamodel.qml b/doc/src/snippets/qml/visualdatamodel.qml new file mode 100644 index 0000000000..87b836e224 --- /dev/null +++ b/doc/src/snippets/qml/visualdatamodel.qml @@ -0,0 +1,64 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +//![0] +import QtQuick 2.0 + +Rectangle { + width: 200; height: 100 + + VisualDataModel { + id: visualModel + model: ListModel { + ListElement { name: "Apple" } + ListElement { name: "Orange" } + } + delegate: Rectangle { + height: 25 + width: 100 + Text { text: "Name: " + name} + } + } + + ListView { + anchors.fill: parent + model: visualModel + } +} +//![0] diff --git a/doc/src/snippets/qml/visualdatamodel_rootindex/main.cpp b/doc/src/snippets/qml/visualdatamodel_rootindex/main.cpp new file mode 100644 index 0000000000..4468d06db4 --- /dev/null +++ b/doc/src/snippets/qml/visualdatamodel_rootindex/main.cpp @@ -0,0 +1,62 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtQml module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include +#include + +#include +#include + +//![0] +int main(int argc, char ** argv) +{ + QApplication app(argc, argv); + + QQuickView view; + + QDirModel model; + view.rootContext()->setContextProperty("dirModel", &model); + + view.setSource(QUrl::fromLocalFile("view.qml")); + view.show(); + + return app.exec(); +} +//![0] + diff --git a/doc/src/snippets/qml/visualdatamodel_rootindex/view.qml b/doc/src/snippets/qml/visualdatamodel_rootindex/view.qml new file mode 100644 index 0000000000..24d6b47f8d --- /dev/null +++ b/doc/src/snippets/qml/visualdatamodel_rootindex/view.qml @@ -0,0 +1,65 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +//![0] +import QtQuick 2.0 + +ListView { + id: view + width: 300 + height: 400 + + model: VisualDataModel { + model: dirModel + + delegate: Rectangle { + width: 200; height: 25 + Text { text: filePath } + + MouseArea { + anchors.fill: parent + onClicked: { + if (model.hasModelChildren) + view.model.rootIndex = view.model.modelIndex(index) + } + } + } + } +} +//![0] diff --git a/doc/src/snippets/qml/workerscript.qml b/doc/src/snippets/qml/workerscript.qml new file mode 100644 index 0000000000..6af6b47766 --- /dev/null +++ b/doc/src/snippets/qml/workerscript.qml @@ -0,0 +1,64 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +//![0] +import QtQuick 2.0 + +Rectangle { + width: 300; height: 300 + + Text { + id: myText + text: 'Click anywhere' + } + + WorkerScript { + id: myWorker + source: "script.js" + + onMessage: myText.text = messageObject.reply + } + + MouseArea { + anchors.fill: parent + onClicked: myWorker.sendMessage({ 'x': mouse.x, 'y': mouse.y }) + } +} +//![0] diff --git a/doc/src/snippets/qml/xmlrole.qml b/doc/src/snippets/qml/xmlrole.qml new file mode 100644 index 0000000000..34868fb76d --- /dev/null +++ b/doc/src/snippets/qml/xmlrole.qml @@ -0,0 +1,81 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import QtQuick.XmlListModel 2.0 + +Rectangle { + width: 300; height: 200 + +//![0] +XmlListModel { + id: model +//![0] + source: "xmlrole.xml" + +//![1] + // XmlRole queries will be made on elements + query: "/catalogue/book" + + // query the book title + XmlRole { name: "title"; query: "title/string()" } + + // query the book's year + XmlRole { name: "year"; query: "year/number()" } + + // query the book's type (the '@' indicates 'type' is an attribute, not an element) + XmlRole { name: "type"; query: "@type/string()" } + + // query the book's first listed author (note in XPath the first index is 1, not 0) + XmlRole { name: "first_author"; query: "author[1]/string()" } +} +//![1] + +ListView { + width: 300; height: 200 + model: model + delegate: Column { + Text { text: title + " (" + type + ")"; font.bold: true } + Text { text: first_author } + Text { text: year } + } +} + +} diff --git a/doc/src/snippets/qml/xmlrole.xml b/doc/src/snippets/qml/xmlrole.xml new file mode 100644 index 0000000000..c9f999e523 --- /dev/null +++ b/doc/src/snippets/qml/xmlrole.xml @@ -0,0 +1,14 @@ + + + + C++ GUI Programming with Qt 4 + 2006 + Jasmin Blanchette + Mark Summerfield + + + Programming with Qt + 2002 + Matthias Kalle Dalheimer + + diff --git a/doc/src/snippets/qtjavascript/evaluation/main.cpp b/doc/src/snippets/qtjavascript/evaluation/main.cpp index 8d1cbf0484..3d3e3bfda2 100644 --- a/doc/src/snippets/qtjavascript/evaluation/main.cpp +++ b/doc/src/snippets/qtjavascript/evaluation/main.cpp @@ -38,7 +38,7 @@ ** ****************************************************************************/ -#include +#include int main(int argc, char *argv[]) { diff --git a/doc/src/snippets/qtjavascript/registeringobjects/main.cpp b/doc/src/snippets/qtjavascript/registeringobjects/main.cpp index 27d696da63..f34c1061fe 100644 --- a/doc/src/snippets/qtjavascript/registeringobjects/main.cpp +++ b/doc/src/snippets/qtjavascript/registeringobjects/main.cpp @@ -39,7 +39,7 @@ ****************************************************************************/ #include -#include +#include #include "myobject.h" int main(int argc, char *argv[]) diff --git a/doc/src/snippets/qtjavascript/registeringvalues/main.cpp b/doc/src/snippets/qtjavascript/registeringvalues/main.cpp index be2d293cf7..f168f4f554 100644 --- a/doc/src/snippets/qtjavascript/registeringvalues/main.cpp +++ b/doc/src/snippets/qtjavascript/registeringvalues/main.cpp @@ -38,7 +38,7 @@ ** ****************************************************************************/ -#include +#include int main(int argc, char *argv[]) { diff --git a/doc/src/whatsnew.qdoc b/doc/src/whatsnew.qdoc index 88d5e91d76..bf77e0e6c0 100644 --- a/doc/src/whatsnew.qdoc +++ b/doc/src/whatsnew.qdoc @@ -67,8 +67,8 @@ Properties of the "var" type may hold JavaScript references. See \l{QML Basic T QML properties of type \c var and \c variant can now hold pixmaps. See \l{Scarce Resources in JavaScript} for more information -QDeclarativeExpression can now be directly (and more efficiently) constructed from a -QDeclarativeScriptString. +QQmlExpression can now be directly (and more efficiently) constructed from a +QQmlScriptString. Support for certain sequence types (QList, QList, QList, QList, QList and QStringList) has been improved. QObjects can define Q_PROPERTYs of these types which can be accessed transparently from JavaScript. See the section on diff --git a/examples/declarative/README b/examples/declarative/README deleted file mode 100644 index 56c48d71fb..0000000000 --- a/examples/declarative/README +++ /dev/null @@ -1,13 +0,0 @@ -The Qt Declarative module provides the ability to specify and implement -your user interface declaratively, using the Qt Meta-Object Language (QML). This -language is very expressive and human readable, and can be used by -designers to actually implement their UI vision. QML UIs can integrate -with C++ code in many ways, including being loaded as a part of a C++ UI -and loading data models from C++ and interacting with them. - -Mostof these examples can be viewed directly with the -QML viewer utility, without requiring compilation. - - -Documentation for these examples can be found via the Examples -link in the main Qt documentation. diff --git a/examples/declarative/accessibility/accessibility.qml b/examples/declarative/accessibility/accessibility.qml deleted file mode 100644 index 6fdcd38ac6..0000000000 --- a/examples/declarative/accessibility/accessibility.qml +++ /dev/null @@ -1,105 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 -import QtQuick.Window 2.0 -import "widgets" - -Rectangle { - id: window - - width: 360; height: 300 - color: "white" - - Column { - id: column - spacing: 6 - anchors.fill: parent - width: parent.width - Row { - spacing: 6 - width: column.width - Button { width: 100; height: column.h + 20; text: "Send" } - Button { width: 100; height: column.h + 20; text: "Discard" } - } - - Row { - spacing: 6 - width: column.width - height: column.h - Text { - id: subjectLabel - Accessible.role: Accessible.StaticText - Accessible.name: text - text: "Subject:" - width: 50 - } - Rectangle { - id: subjectBorder - Accessible.role: Accessible.EditableText - Accessible.name: subjectEdit.text - border.width: 1 - border.color: "black" - height: subjectEdit.height - width: 304 - TextInput { - id: subjectEdit - text: "Vacation plans" - } - } - } - Rectangle { - id: textBorder - Accessible.role: Accessible.EditableText - property alias text : textEdit.text - border.width: 1 - border.color: "black" - width: parent.width - height: textEdit.height - TextEdit { - id: textEdit - text: "Hi, we're going to the Dolomites this summer. Weren't you also going to northern Italy? \n\nbest wishes, your friend Luke" - width: parent.width - wrapMode: TextEdit.WordWrap - } - } - } -} diff --git a/examples/declarative/accessibility/widgets/Button.qml b/examples/declarative/accessibility/widgets/Button.qml deleted file mode 100644 index 4a076fa428..0000000000 --- a/examples/declarative/accessibility/widgets/Button.qml +++ /dev/null @@ -1,79 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -Rectangle { - id: button - - property alias text : buttonText.text - Accessible.name: text - Accessible.description: "This button does " + text - Accessible.role: Accessible.Button - - signal clicked - - width: buttonText.width + 20 - height: 30 - gradient: Gradient { - GradientStop { position: 0.0; color: "lightsteelblue" } - GradientStop { position: 1.0; color: "blue" } - } - border.width: 2 - border.color: "black"; - radius: 10 - - Text { - id: buttonText - text: parent.description - anchors.centerIn: parent - font.pixelSize: parent.height * .5 - style: Text.Sunken; color: "white"; styleColor: "black"; smooth: true - } - - MouseArea { - id: mouseArea - anchors.fill: parent - onClicked: { - checked = !checked; - } - } -} diff --git a/examples/declarative/animation/animation.qml b/examples/declarative/animation/animation.qml deleted file mode 100644 index 7c5829e790..0000000000 --- a/examples/declarative/animation/animation.qml +++ /dev/null @@ -1,62 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 -import "../shared" - -Item { - height: 480 - width: 320 - LauncherList { - id: ll - anchors.fill: parent - Component.onCompleted: { - addExample("ColorAnimation", "Interpolates between colors", Qt.resolvedUrl("basics/color-animation.qml")); - addExample("PropertyAnimation", "Interpolates between numbers", Qt.resolvedUrl("basics/property-animation.qml")); - addExample("Behaviors", "Animates procedural movement", Qt.resolvedUrl("behaviors/behavior-example.qml")); - addExample("WigglyText", "Text that wiggles as you drag it", Qt.resolvedUrl("behaviors/wigglytext.qml")); - addExample("Easing Curves", "Compare available easing curves", Qt.resolvedUrl("easing/easing.qml")); - addExample("States", "Simple states", Qt.resolvedUrl("states/states.qml")); - addExample("Transitions", "Simple states with animated transitions", Qt.resolvedUrl("states/transitions.qml")); - addExample("PathAnimation", "Animate along a path", Qt.resolvedUrl("pathanimation/pathanimation.qml")); - addExample("PathInterpolator", "Interpolates along a path", Qt.resolvedUrl("pathinterpolator/pathinterpolator.qml")); - } - } -} diff --git a/examples/declarative/animation/animation.qmlproject b/examples/declarative/animation/animation.qmlproject deleted file mode 100644 index 2e96daa881..0000000000 --- a/examples/declarative/animation/animation.qmlproject +++ /dev/null @@ -1,16 +0,0 @@ -import QmlProject 1.1 - -Project { - mainFile: "animation.qml" - - /* Include .qml, .js, and image files from current directory and subdirectories */ - QmlFiles { - directory: "." - } - JavaScriptFiles { - directory: "." - } - ImageFiles { - directory: "." - } -} diff --git a/examples/declarative/animation/basics/color-animation.qml b/examples/declarative/animation/basics/color-animation.qml deleted file mode 100644 index a54091d7dd..0000000000 --- a/examples/declarative/animation/basics/color-animation.qml +++ /dev/null @@ -1,121 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 -import QtQuick.Particles 2.0 - -Item { - id: window - width: 640; height: 480 - - // Let's draw the sky... - Rectangle { - anchors { left: parent.left; top: parent.top; right: parent.right; bottom: parent.verticalCenter } - gradient: Gradient { - GradientStop { - position: 0.0 - SequentialAnimation on color { - loops: Animation.Infinite - ColorAnimation { from: "DeepSkyBlue"; to: "#0E1533"; duration: 5000 } - ColorAnimation { from: "#0E1533"; to: "DeepSkyBlue"; duration: 5000 } - } - } - GradientStop { - position: 1.0 - SequentialAnimation on color { - loops: Animation.Infinite - ColorAnimation { from: "SkyBlue"; to: "#437284"; duration: 5000 } - ColorAnimation { from: "#437284"; to: "SkyBlue"; duration: 5000 } - } - } - } - } - - // the sun, moon, and stars - Item { - width: parent.width; height: 2 * parent.height - NumberAnimation on rotation { from: 0; to: 360; duration: 10000; loops: Animation.Infinite } - Image { - source: "images/sun.png"; y: 10; anchors.horizontalCenter: parent.horizontalCenter - rotation: -3 * parent.rotation - } - Image { - source: "images/moon.png"; y: parent.height - 74; anchors.horizontalCenter: parent.horizontalCenter - rotation: -parent.rotation - } - ParticleSystem { - id: particlesystem - x: 0; y: parent.height/2 - width: parent.width; height: parent.height/2 - ImageParticle { - source: "images/star.png" - groups: ["star"] - color: "#00333333" - SequentialAnimation on opacity { - loops: Animation.Infinite - NumberAnimation { from: 0; to: 1; duration: 5000 } - NumberAnimation { from: 1; to: 0; duration: 5000 } - } - } - Emitter { - group: "star" - anchors.fill: parent - emitRate: parent.width / 50 - lifeSpan: 5000 - } - } - } - - // ...and the ground. - Rectangle { - anchors { left: parent.left; top: parent.verticalCenter; right: parent.right; bottom: parent.bottom } - gradient: Gradient { - GradientStop { - position: 0.0 - SequentialAnimation on color { - loops: Animation.Infinite - ColorAnimation { from: "ForestGreen"; to: "#001600"; duration: 5000 } - ColorAnimation { from: "#001600"; to: "ForestGreen"; duration: 5000 } - } - } - GradientStop { position: 1.0; color: "DarkGreen" } - } - } -} diff --git a/examples/declarative/animation/basics/images/face-smile.png b/examples/declarative/animation/basics/images/face-smile.png deleted file mode 100644 index 3d66d72578..0000000000 Binary files a/examples/declarative/animation/basics/images/face-smile.png and /dev/null differ diff --git a/examples/declarative/animation/basics/images/moon.png b/examples/declarative/animation/basics/images/moon.png deleted file mode 100644 index 9407b2b4f0..0000000000 Binary files a/examples/declarative/animation/basics/images/moon.png and /dev/null differ diff --git a/examples/declarative/animation/basics/images/shadow.png b/examples/declarative/animation/basics/images/shadow.png deleted file mode 100644 index 8270565e87..0000000000 Binary files a/examples/declarative/animation/basics/images/shadow.png and /dev/null differ diff --git a/examples/declarative/animation/basics/images/star.png b/examples/declarative/animation/basics/images/star.png deleted file mode 100644 index 27ef924267..0000000000 Binary files a/examples/declarative/animation/basics/images/star.png and /dev/null differ diff --git a/examples/declarative/animation/basics/images/sun.png b/examples/declarative/animation/basics/images/sun.png deleted file mode 100644 index 7713ca5ce7..0000000000 Binary files a/examples/declarative/animation/basics/images/sun.png and /dev/null differ diff --git a/examples/declarative/animation/basics/property-animation.qml b/examples/declarative/animation/basics/property-animation.qml deleted file mode 100644 index 4a4d3e3b2a..0000000000 --- a/examples/declarative/animation/basics/property-animation.qml +++ /dev/null @@ -1,105 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -Item { - id: window - width: 320; height: 480 - - // Let's draw the sky... - Rectangle { - anchors { left: parent.left; top: parent.top; right: parent.right; bottom: parent.verticalCenter } - gradient: Gradient { - GradientStop { position: 0.0; color: "DeepSkyBlue" } - GradientStop { position: 1.0; color: "LightSkyBlue" } - } - } - - // ...and the ground. - Rectangle { - anchors { left: parent.left; top: parent.verticalCenter; right: parent.right; bottom: parent.bottom } - gradient: Gradient { - GradientStop { position: 0.0; color: "ForestGreen" } - GradientStop { position: 1.0; color: "DarkGreen" } - } - } - - // The shadow for the smiley face - Image { - anchors.horizontalCenter: parent.horizontalCenter - y: smiley.minHeight + 58 - source: "images/shadow.png" - - // The scale property depends on the y position of the smiley face. - scale: smiley.y * 0.5 / (smiley.minHeight - smiley.maxHeight) - } - - Image { - id: smiley - property int maxHeight: window.height / 3 - property int minHeight: 2 * window.height / 3 - - anchors.horizontalCenter: parent.horizontalCenter - y: minHeight - source: "images/face-smile.png" - - // Animate the y property. Setting loops to Animation.Infinite makes the - // animation repeat indefinitely, otherwise it would only run once. - SequentialAnimation on y { - loops: Animation.Infinite - - // Move from minHeight to maxHeight in 300ms, using the OutExpo easing function - NumberAnimation { - from: smiley.minHeight; to: smiley.maxHeight - easing.type: Easing.OutExpo; duration: 300 - } - - // Then move back to minHeight in 1 second, using the OutBounce easing function - NumberAnimation { - from: smiley.maxHeight; to: smiley.minHeight - easing.type: Easing.OutBounce; duration: 1000 - } - - // Then pause for 500ms - PauseAnimation { duration: 500 } - } - } -} diff --git a/examples/declarative/animation/behaviors/SideRect.qml b/examples/declarative/animation/behaviors/SideRect.qml deleted file mode 100644 index 623c6965d8..0000000000 --- a/examples/declarative/animation/behaviors/SideRect.qml +++ /dev/null @@ -1,62 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -Rectangle { - id: myRect - - property string text - - width: 75; height: 50 - radius: 6 - color: "#646464" - border.width: 4; border.color: "white" - - MouseArea { - anchors.fill: parent - hoverEnabled: true - onEntered: { - focusRect.x = myRect.x; - focusRect.y = myRect.y; - focusRect.text = myRect.text; - } - } -} diff --git a/examples/declarative/animation/behaviors/behavior-example.qml b/examples/declarative/animation/behaviors/behavior-example.qml deleted file mode 100644 index 89fc9992b6..0000000000 --- a/examples/declarative/animation/behaviors/behavior-example.qml +++ /dev/null @@ -1,118 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -Rectangle { - width: 600; height: 400 - color: "#343434" - - Rectangle { - anchors.centerIn: parent - width: 200; height: 200 - radius: 30 - color: "transparent" - border.width: 4; border.color: "white" - - - SideRect { - id: leftRect - anchors { verticalCenter: parent.verticalCenter; horizontalCenter: parent.left } - text: "Left" - } - - SideRect { - id: rightRect - anchors { verticalCenter: parent.verticalCenter; horizontalCenter: parent.right } - text: "Right" - } - - SideRect { - id: topRect - anchors { verticalCenter: parent.top; horizontalCenter: parent.horizontalCenter } - text: "Top" - } - - SideRect { - id: bottomRect - anchors { verticalCenter: parent.bottom; horizontalCenter: parent.horizontalCenter } - text: "Bottom" - } - - - Rectangle { - id: focusRect - - property string text - - x: 62; y: 75; width: 75; height: 50 - radius: 6 - border.width: 4; border.color: "white" - color: "firebrick" - - // Set an 'elastic' behavior on the focusRect's x property. - Behavior on x { - NumberAnimation { easing.type: Easing.OutElastic; easing.amplitude: 3.0; easing.period: 2.0; duration: 300 } - } - - // Set an 'elastic' behavior on the focusRect's y property. - Behavior on y { - NumberAnimation { easing.type: Easing.OutElastic; easing.amplitude: 3.0; easing.period: 2.0; duration: 300 } - } - - Text { - id: focusText - text: focusRect.text - anchors.centerIn: parent - color: "white" - font.pixelSize: 16; font.bold: true - - // Set a behavior on the focusText's x property: - // Set the opacity to 0, set the new text value, then set the opacity back to 1. - Behavior on text { - SequentialAnimation { - NumberAnimation { target: focusText; property: "opacity"; to: 0; duration: 150 } - NumberAnimation { target: focusText; property: "opacity"; to: 1; duration: 150 } - } - } - } - } - } -} diff --git a/examples/declarative/animation/behaviors/wigglytext.qml b/examples/declarative/animation/behaviors/wigglytext.qml deleted file mode 100644 index e2ed472088..0000000000 --- a/examples/declarative/animation/behaviors/wigglytext.qml +++ /dev/null @@ -1,108 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -Rectangle { - id: container - - property string text: "Drag this text..." - property bool animated: true - - width: 640; height: 480; color: "#474747"; focus: true - - Keys.onPressed: { - if (event.key == Qt.Key_Delete || event.key == Qt.Key_Backspace) - container.remove() - else if (event.text != "") { - container.append(event.text) - } - } - - function append(text) { - container.animated = false - var lastLetter = container.children[container.children.length - 1] - var newLetter = letterComponent.createObject(container) - newLetter.text = text - newLetter.follow = lastLetter - container.animated = true - } - - function remove() { - if (container.children.length) - container.children[container.children.length - 1].destroy() - } - - function doLayout() { - var follow = null - for (var i = 0; i < container.text.length; ++i) { - var newLetter = letterComponent.createObject(container) - newLetter.text = container.text[i] - newLetter.follow = follow - follow = newLetter - } - } - - Component { - id: letterComponent - Text { - id: letter - property variant follow - - x: follow ? follow.x + follow.width : container.width / 3 - y: follow ? follow.y : container.height / 2 - - font.pixelSize: 40; font.bold: true - color: "#999999"; styleColor: "#222222"; style: Text.Raised - - MouseArea { - anchors.fill: parent - drag.target: letter; drag.axis: Drag.XandYAxis - onPressed: letter.color = "#dddddd" - onReleased: letter.color = "#999999" - } - - Behavior on x { enabled: container.animated; SpringAnimation { spring: 3; damping: 0.3; mass: 1.0 } } - Behavior on y { enabled: container.animated; SpringAnimation { spring: 3; damping: 0.3; mass: 1.0 } } - } - } - - Component.onCompleted: doLayout() -} diff --git a/examples/declarative/animation/easing/content/QuitButton.qml b/examples/declarative/animation/easing/content/QuitButton.qml deleted file mode 100644 index 702b892d23..0000000000 --- a/examples/declarative/animation/easing/content/QuitButton.qml +++ /dev/null @@ -1,52 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 -Image { - source: "quit.png" - scale: quitMouse.pressed ? 0.8 : 1.0 - smooth: quitMouse.pressed - MouseArea { - id: quitMouse - anchors.fill: parent - anchors.margins: -10 - onClicked: Qt.quit() - } -} diff --git a/examples/declarative/animation/easing/content/quit.png b/examples/declarative/animation/easing/content/quit.png deleted file mode 100644 index b822057d4e..0000000000 Binary files a/examples/declarative/animation/easing/content/quit.png and /dev/null differ diff --git a/examples/declarative/animation/easing/easing.qml b/examples/declarative/animation/easing/easing.qml deleted file mode 100644 index 207b653d6e..0000000000 --- a/examples/declarative/animation/easing/easing.qml +++ /dev/null @@ -1,170 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 -import "content" - -Rectangle { - id: window - width: 600; height: 460; color: "#232323" - - property var easingCurve: [ 0.2, 0.2, 0.13, 0.65, 0.2, 0.8, - 0.624, 0.98, 0.93, 0.95, 1, 1 ] - - ListModel { - id: easingTypes - ListElement { name: "Easing.Linear"; type: Easing.Linear; ballColor: "DarkRed" } - ListElement { name: "Easing.InQuad"; type: Easing.InQuad; ballColor: "IndianRed" } - ListElement { name: "Easing.OutQuad"; type: Easing.OutQuad; ballColor: "Salmon" } - ListElement { name: "Easing.InOutQuad"; type: Easing.InOutQuad; ballColor: "Tomato" } - ListElement { name: "Easing.OutInQuad"; type: Easing.OutInQuad; ballColor: "DarkOrange" } - ListElement { name: "Easing.InCubic"; type: Easing.InCubic; ballColor: "Gold" } - ListElement { name: "Easing.OutCubic"; type: Easing.OutCubic; ballColor: "Yellow" } - ListElement { name: "Easing.InOutCubic"; type: Easing.InOutCubic; ballColor: "PeachPuff" } - ListElement { name: "Easing.OutInCubic"; type: Easing.OutInCubic; ballColor: "Thistle" } - ListElement { name: "Easing.InQuart"; type: Easing.InQuart; ballColor: "Orchid" } - ListElement { name: "Easing.OutQuart"; type: Easing.OutQuart; ballColor: "Purple" } - ListElement { name: "Easing.InOutQuart"; type: Easing.InOutQuart; ballColor: "SlateBlue" } - ListElement { name: "Easing.OutInQuart"; type: Easing.OutInQuart; ballColor: "Chartreuse" } - ListElement { name: "Easing.InQuint"; type: Easing.InQuint; ballColor: "LimeGreen" } - ListElement { name: "Easing.OutQuint"; type: Easing.OutQuint; ballColor: "SeaGreen" } - ListElement { name: "Easing.InOutQuint"; type: Easing.InOutQuint; ballColor: "DarkGreen" } - ListElement { name: "Easing.OutInQuint"; type: Easing.OutInQuint; ballColor: "Olive" } - ListElement { name: "Easing.InSine"; type: Easing.InSine; ballColor: "DarkSeaGreen" } - ListElement { name: "Easing.OutSine"; type: Easing.OutSine; ballColor: "Teal" } - ListElement { name: "Easing.InOutSine"; type: Easing.InOutSine; ballColor: "Turquoise" } - ListElement { name: "Easing.OutInSine"; type: Easing.OutInSine; ballColor: "SteelBlue" } - ListElement { name: "Easing.InExpo"; type: Easing.InExpo; ballColor: "SkyBlue" } - ListElement { name: "Easing.OutExpo"; type: Easing.OutExpo; ballColor: "RoyalBlue" } - ListElement { name: "Easing.InOutExpo"; type: Easing.InOutExpo; ballColor: "MediumBlue" } - ListElement { name: "Easing.OutInExpo"; type: Easing.OutInExpo; ballColor: "MidnightBlue" } - ListElement { name: "Easing.InCirc"; type: Easing.InCirc; ballColor: "CornSilk" } - ListElement { name: "Easing.OutCirc"; type: Easing.OutCirc; ballColor: "Bisque" } - ListElement { name: "Easing.InOutCirc"; type: Easing.InOutCirc; ballColor: "RosyBrown" } - ListElement { name: "Easing.OutInCirc"; type: Easing.OutInCirc; ballColor: "SandyBrown" } - ListElement { name: "Easing.InElastic"; type: Easing.InElastic; ballColor: "DarkGoldenRod" } - ListElement { name: "Easing.OutElastic"; type: Easing.OutElastic; ballColor: "Chocolate" } - ListElement { name: "Easing.InOutElastic"; type: Easing.InOutElastic; ballColor: "SaddleBrown" } - ListElement { name: "Easing.OutInElastic"; type: Easing.OutInElastic; ballColor: "Brown" } - ListElement { name: "Easing.InBack"; type: Easing.InBack; ballColor: "Maroon" } - ListElement { name: "Easing.OutBack"; type: Easing.OutBack; ballColor: "LavenderBlush" } - ListElement { name: "Easing.InOutBack"; type: Easing.InOutBack; ballColor: "MistyRose" } - ListElement { name: "Easing.OutInBack"; type: Easing.OutInBack; ballColor: "Gainsboro" } - ListElement { name: "Easing.OutBounce"; type: Easing.OutBounce; ballColor: "Silver" } - ListElement { name: "Easing.InBounce"; type: Easing.InBounce; ballColor: "DimGray" } - ListElement { name: "Easing.InOutBounce"; type: Easing.InOutBounce; ballColor: "SlateGray" } - ListElement { name: "Easing.OutInBounce"; type: Easing.OutInBounce; ballColor: "DarkSlateGray" } - ListElement { name: "Easing.Bezier"; type: Easing.Bezier; ballColor: "Chartreuse"; } - } - - Component { - id: delegate - - Item { - height: 56; width: window.width - - Text { text: name; anchors.centerIn: parent; color: "White" } - - Rectangle { - id: slot1; color: "#121212"; x: 30; height: 46; width: 46 - border.color: "#343434"; border.width: 1; radius: 12 - anchors.verticalCenter: parent.verticalCenter - } - - Rectangle { - id: slot2; color: "#121212"; x: window.width - 76; height: 46; width: 46 - border.color: "#343434"; border.width: 1; radius: 12 - anchors.verticalCenter: parent.verticalCenter - } - - Rectangle { - id: rect; x: 30; color: "#454545" - border.color: "White"; border.width: 2 - height: 46; width: 46; radius: 12 - anchors.verticalCenter: parent.verticalCenter - - MouseArea { - onClicked: if (rect.state == '') rect.state = "right"; else rect.state = '' - anchors.fill: parent - anchors.margins: -5 // Make MouseArea bigger than the rectangle, itself - } - - states : State { - name: "right" - PropertyChanges { target: rect; x: window.width - 76; color: ballColor } - } - - transitions: Transition { - NumberAnimation { properties: "x"; easing.type: type; easing.bezierCurve: getBezierCurve(name); duration: 1000 } - ColorAnimation { properties: "color"; easing.type: type; easing.bezierCurve: getBezierCurve(name); duration: 1000 } - } - } - } - } - - Flickable { - anchors.fill: parent - contentHeight: layout.height+50 - Rectangle { - id: titlePane - color: "#444444" - height: 35 - anchors { top: parent.top; left: parent.left; right: parent.right } - QuitButton { - id: quitButton - anchors.verticalCenter: parent.verticalCenter - anchors.right: parent.right - anchors.rightMargin: 10 - } - } - Column { - id: layout - anchors { top: titlePane.bottom; topMargin: 10; left: parent.left; right: parent.right } - Repeater { model: easingTypes; delegate: delegate } - } - } - - function getBezierCurve(name) - { - if (name === "Easing.Bezier") - return easingCurve; - return []; - } -} diff --git a/examples/declarative/animation/pathanimation/pathanimation.qml b/examples/declarative/animation/pathanimation/pathanimation.qml deleted file mode 100644 index 4d0a31bdf8..0000000000 --- a/examples/declarative/animation/pathanimation/pathanimation.qml +++ /dev/null @@ -1,108 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -Rectangle { - id: window - width: 400 - height: 400 - - Canvas { - id: canvas - anchors.fill: parent - smooth: true - - onPaint: { - context.clearRect(0, 0, width, height) - context.strokeStyle = "black" - context.path = pathAnim.path - context.stroke() - } - } - - PathAnimation { - id: pathAnim - - duration: 2000 - easing.type: Easing.InQuad - - target: box - orientation: PathAnimation.RightFirst - anchorPoint: Qt.point(box.width/2, box.height/2) - path: Path { - startX: 50; startY: 50 - - PathCubic { - x: window.width - 50 - y: window.height - 50 - - control1X: x; control1Y: 50 - control2X: 50; control2Y: y - } - - onChanged: canvas.requestPaint() - } - } - - Rectangle { - id: box - - x: 25; y: 25 - width: 50; height: 50 - border.width: 1 - smooth: true - - Text { - anchors.centerIn: parent - text: "Box" - } - } - - MouseArea { - anchors.fill: parent - onClicked: pathAnim.restart() - } - - Text { - text: "Click anywhere to animate along the path" - anchors.horizontalCenter: parent.horizontalCenter - } -} diff --git a/examples/declarative/animation/pathinterpolator/pathinterpolator.qml b/examples/declarative/animation/pathinterpolator/pathinterpolator.qml deleted file mode 100644 index 67a34ce582..0000000000 --- a/examples/declarative/animation/pathinterpolator/pathinterpolator.qml +++ /dev/null @@ -1,115 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -Rectangle { - id: window - width: 400 - height: 400 - - Canvas { - id: canvas - anchors.fill: parent - smooth: true - - onPaint: { - context.clearRect(0, 0, width, height) - context.strokeStyle = "black" - context.path = motionPath.path - context.stroke() - } - } - - PathInterpolator { - id: motionPath - - path: Path { - startX: 50; startY: 50 - - PathCubic { - x: window.width - 50 - y: window.height - 50 - - control1X: x; control1Y: 50 - control2X: 50; control2Y: y - } - - onChanged: canvas.requestPaint() - } - - NumberAnimation on progress { - id: progressAnim - running: false - from: 0; to: 1 - duration: 2000 - easing.type: Easing.InQuad - } - } - - Rectangle { - id: box - - width: 50; height: 50 - border.width: 1 - smooth: true - - //bind our attributes to follow the path as progress changes - x: motionPath.x - y: motionPath.y - rotation: motionPath.angle - transform: Translate { x: -box.width/2; y: -box.height/2 } - - Text { - anchors.centerIn: parent - text: "Box" - } - } - - MouseArea { - anchors.fill: parent - onClicked: progressAnim.restart() - } - - Text { - text: "Click anywhere to animate along the path" - anchors.horizontalCenter: parent.horizontalCenter - } -} diff --git a/examples/declarative/animation/states/qt-logo.png b/examples/declarative/animation/states/qt-logo.png deleted file mode 100644 index 14ddf2a028..0000000000 Binary files a/examples/declarative/animation/states/qt-logo.png and /dev/null differ diff --git a/examples/declarative/animation/states/states.qml b/examples/declarative/animation/states/states.qml deleted file mode 100644 index 7ca56a9295..0000000000 --- a/examples/declarative/animation/states/states.qml +++ /dev/null @@ -1,101 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -Rectangle { - id: page - width: 640; height: 480 - color: "#343434" - - Image { - id: userIcon - x: topLeftRect.x; y: topLeftRect.y - source: "qt-logo.png" - } - - Rectangle { - id: topLeftRect - - anchors { left: parent.left; top: parent.top; leftMargin: 10; topMargin: 20 } - width: 46; height: 54 - color: "Transparent"; border.color: "Gray"; radius: 6 - - // Clicking in here sets the state to the default state, returning the image to - // its initial position - MouseArea { anchors.fill: parent; onClicked: page.state = '' } - } - - Rectangle { - id: middleRightRect - - anchors { right: parent.right; verticalCenter: parent.verticalCenter; rightMargin: 20 } - width: 46; height: 54 - color: "Transparent"; border.color: "Gray"; radius: 6 - - // Clicking in here sets the state to 'middleRight' - MouseArea { anchors.fill: parent; onClicked: page.state = 'middleRight' } - } - - Rectangle { - id: bottomLeftRect - - anchors { left: parent.left; bottom: parent.bottom; leftMargin: 10; bottomMargin: 20 } - width: 46; height: 54 - color: "Transparent"; border.color: "Gray"; radius: 6 - - // Clicking in here sets the state to 'bottomLeft' - MouseArea { anchors.fill: parent; onClicked: page.state = 'bottomLeft' } - } - - states: [ - // In state 'middleRight', move the image to middleRightRect - State { - name: "middleRight" - PropertyChanges { target: userIcon; x: middleRightRect.x; y: middleRightRect.y } - }, - - // In state 'bottomLeft', move the image to bottomLeftRect - State { - name: "bottomLeft" - PropertyChanges { target: userIcon; x: bottomLeftRect.x; y: bottomLeftRect.y } - } - ] -} diff --git a/examples/declarative/animation/states/transitions.qml b/examples/declarative/animation/states/transitions.qml deleted file mode 100644 index d57924d6d2..0000000000 --- a/examples/declarative/animation/states/transitions.qml +++ /dev/null @@ -1,130 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -/* - This is exactly the same as states.qml, except that we have appended - a set of transitions to apply animations when the item changes - between each state. -*/ - -Rectangle { - id: page - width: 640; height: 480 - color: "#343434" - - Image { - id: userIcon - x: topLeftRect.x; y: topLeftRect.y - source: "qt-logo.png" - } - - Rectangle { - id: topLeftRect - - anchors { left: parent.left; top: parent.top; leftMargin: 10; topMargin: 20 } - width: 46; height: 54 - color: "Transparent"; border.color: "Gray"; radius: 6 - - // Clicking in here sets the state to the default state, returning the image to - // its initial position - MouseArea { anchors.fill: parent; onClicked: page.state = '' } - } - - Rectangle { - id: middleRightRect - - anchors { right: parent.right; verticalCenter: parent.verticalCenter; rightMargin: 20 } - width: 46; height: 54 - color: "Transparent"; border.color: "Gray"; radius: 6 - - // Clicking in here sets the state to 'middleRight' - MouseArea { anchors.fill: parent; onClicked: page.state = 'middleRight' } - } - - Rectangle { - id: bottomLeftRect - - anchors { left: parent.left; bottom: parent.bottom; leftMargin: 10; bottomMargin: 20 } - width: 46; height: 54 - color: "Transparent"; border.color: "Gray"; radius: 6 - - // Clicking in here sets the state to 'bottomLeft' - MouseArea { anchors.fill: parent; onClicked: page.state = 'bottomLeft' } - } - - states: [ - // In state 'middleRight', move the image to middleRightRect - State { - name: "middleRight" - PropertyChanges { target: userIcon; x: middleRightRect.x; y: middleRightRect.y } - }, - - // In state 'bottomLeft', move the image to bottomLeftRect - State { - name: "bottomLeft" - PropertyChanges { target: userIcon; x: bottomLeftRect.x; y: bottomLeftRect.y } - } - ] - - // Transitions define how the properties change when the item moves between each state - transitions: [ - - // When transitioning to 'middleRight' move x,y over a duration of 1 second, - // with OutBounce easing function. - Transition { - from: "*"; to: "middleRight" - NumberAnimation { properties: "x,y"; easing.type: Easing.OutBounce; duration: 1000 } - }, - - // When transitioning to 'bottomLeft' move x,y over a duration of 2 seconds, - // with InOutQuad easing function. - Transition { - from: "*"; to: "bottomLeft" - NumberAnimation { properties: "x,y"; easing.type: Easing.InOutQuad; duration: 2000 } - }, - - // For any other state changes move x,y linearly over duration of 200ms. - Transition { - NumberAnimation { properties: "x,y"; duration: 200 } - } - ] -} diff --git a/examples/declarative/calculator/calculator.qml b/examples/declarative/calculator/calculator.qml deleted file mode 100644 index e2d6679b89..0000000000 --- a/examples/declarative/calculator/calculator.qml +++ /dev/null @@ -1,163 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 -import QtQuick.Window 2.0 -import "content" -import "content/calculator.js" as CalcEngine - -Rectangle { - id: window - - width: 360; height: 480 - color: "#282828" - - property string rotateLeft: "\u2939" - property string rotateRight: "\u2935" - property string leftArrow: "\u2190" - property string division : "\u00f7" - property string multiplication : "\u00d7" - property string squareRoot : "\u221a" - property string plusminus : "\u00b1" - - function doOp(operation) { CalcEngine.doOperation(operation) } - - Item { - id: main - state: "orientation " + Screen.orientation - - property bool landscapeWindow: window.width > window.height - property real baseWidth: landscapeWindow ? window.height : window.width - property real baseHeight: landscapeWindow ? window.width : window.height - property real rotationDelta: landscapeWindow ? -90 : 0 - - rotation: rotationDelta - width: main.baseWidth - height: main.baseHeight - anchors.centerIn: parent - - Column { - id: box; spacing: 8 - - anchors { fill: parent; topMargin: 6; bottomMargin: 6; leftMargin: 6; rightMargin: 6 } - - Display { - id: display - width: box.width-3 - height: 64 - } - - Column { - id: column; spacing: 6 - - property real h: ((box.height - 72) / 6) - ((spacing * (6 - 1)) / 6) - property real w: (box.width / 4) - ((spacing * (4 - 1)) / 4) - - Row { - spacing: 6 - Button { width: column.w; height: column.h; color: 'purple'; operation: "Off" } - Button { width: column.w; height: column.h; color: 'purple'; operation: leftArrow } - Button { width: column.w; height: column.h; color: 'purple'; operation: "C" } - Button { width: column.w; height: column.h; color: 'purple'; operation: "AC" } - } - - Row { - spacing: 6 - property real w: (box.width / 4) - ((spacing * (4 - 1)) / 4) - - Button { width: column.w; height: column.h; color: 'green'; operation: "mc" } - Button { width: column.w; height: column.h; color: 'green'; operation: "m+" } - Button { width: column.w; height: column.h; color: 'green'; operation: "m-" } - Button { width: column.w; height: column.h; color: 'green'; operation: "mr" } - } - - Grid { - id: grid; rows: 5; columns: 5; spacing: 6 - - property real w: (box.width / columns) - ((spacing * (columns - 1)) / columns) - - Button { width: grid.w; height: column.h; operation: "7"; color: 'blue' } - Button { width: grid.w; height: column.h; operation: "8"; color: 'blue' } - Button { width: grid.w; height: column.h; operation: "9"; color: 'blue' } - Button { width: grid.w; height: column.h; operation: division } - Button { width: grid.w; height: column.h; operation: squareRoot } - Button { width: grid.w; height: column.h; operation: "4"; color: 'blue' } - Button { width: grid.w; height: column.h; operation: "5"; color: 'blue' } - Button { width: grid.w; height: column.h; operation: "6"; color: 'blue' } - Button { width: grid.w; height: column.h; operation: multiplication } - Button { width: grid.w; height: column.h; operation: "x^2" } - Button { width: grid.w; height: column.h; operation: "1"; color: 'blue' } - Button { width: grid.w; height: column.h; operation: "2"; color: 'blue' } - Button { width: grid.w; height: column.h; operation: "3"; color: 'blue' } - Button { width: grid.w; height: column.h; operation: "-" } - Button { width: grid.w; height: column.h; operation: "1/x" } - Button { width: grid.w; height: column.h; operation: "0"; color: 'blue' } - Button { width: grid.w; height: column.h; operation: "." } - Button { width: grid.w; height: column.h; operation: plusminus } - Button { width: grid.w; height: column.h; operation: "+" } - Button { width: grid.w; height: column.h; operation: "="; color: 'red' } - } - } - } - - states: [ - State { - name: "orientation " + Qt.LandscapeOrientation - PropertyChanges { target: main; rotation: 90 + rotationDelta; width: main.baseHeight; height: main.baseWidth } - }, - State { - name: "orientation " + Qt.InvertedPortraitOrientation - PropertyChanges { target: main; rotation: 180 + rotationDelta; } - }, - State { - name: "orientation " + Qt.InvertedLandscapeOrientation - PropertyChanges { target: main; rotation: 270 + rotationDelta; width: main.baseHeight; height: main.baseWidth } - } - ] - - transitions: Transition { - SequentialAnimation { - RotationAnimation { direction: RotationAnimation.Shortest; duration: 300; easing.type: Easing.InOutQuint } - NumberAnimation { properties: "x,y,width,height"; duration: 300; easing.type: Easing.InOutQuint } - } - } - } -} diff --git a/examples/declarative/calculator/content/Button.qml b/examples/declarative/calculator/content/Button.qml deleted file mode 100644 index 6b480eb9b8..0000000000 --- a/examples/declarative/calculator/content/Button.qml +++ /dev/null @@ -1,84 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -BorderImage { - id: button - - property alias operation: buttonText.text - property string color: "" - - Accessible.name: operation - Accessible.description: "This button does " + operation - Accessible.role: Accessible.Button - - signal clicked - - source: "images/button-" + color + ".png"; clip: true - border { left: 10; top: 10; right: 10; bottom: 10 } - - Rectangle { - id: shade - anchors.fill: button; radius: 10; color: "black"; opacity: 0 - } - - Text { - id: buttonText - anchors.centerIn: parent; anchors.verticalCenterOffset: -1 - font.pixelSize: parent.width > parent.height ? parent.height * .5 : parent.width * .5 - style: Text.Sunken; color: "white"; styleColor: "black"; smooth: true - } - - MouseArea { - id: mouseArea - anchors.fill: parent - onClicked: { - doOp(operation) - button.clicked() - } - } - - states: State { - name: "pressed"; when: mouseArea.pressed == true - PropertyChanges { target: shade; opacity: .4 } - } -} diff --git a/examples/declarative/calculator/content/Display.qml b/examples/declarative/calculator/content/Display.qml deleted file mode 100644 index 3333484971..0000000000 --- a/examples/declarative/calculator/content/Display.qml +++ /dev/null @@ -1,68 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -BorderImage { - id: image - - property alias text : displayText.text - property alias currentOperation : operationText - - source: "images/display.png" - border { left: 10; top: 10; right: 10; bottom: 10 } - - Text { - id: displayText - anchors { - right: parent.right; verticalCenter: parent.verticalCenter; verticalCenterOffset: -1 - rightMargin: 6; left: operationText.right - } - font.pixelSize: parent.height * .6; text: "0"; horizontalAlignment: Text.AlignRight; elide: Text.ElideRight - color: "#343434"; smooth: true; font.bold: true - } - Text { - id: operationText - font.bold: true; font.pixelSize: parent.height * .7 - color: "#343434"; smooth: true - anchors { left: parent.left; leftMargin: 6; verticalCenterOffset: -3; verticalCenter: parent.verticalCenter } - } -} diff --git a/examples/declarative/calculator/content/calculator.js b/examples/declarative/calculator/content/calculator.js deleted file mode 100644 index 7c363c7f30..0000000000 --- a/examples/declarative/calculator/content/calculator.js +++ /dev/null @@ -1,91 +0,0 @@ - -var curVal = 0 -var memory = 0 -var lastOp = "" -var timer = 0 - -function disabled(op) { - if (op == "." && display.text.toString().search(/\./) != -1) { - return true - } else if (op == squareRoot && display.text.toString().search(/-/) != -1) { - return true - } else { - return false - } -} - -function doOperation(op) { - if (disabled(op)) { - return - } - - if (op.toString().length==1 && ((op >= "0" && op <= "9") || op==".") ) { - if (display.text.toString().length >= 14) - return; // No arbitrary length numbers - if (lastOp.toString().length == 1 && ((lastOp >= "0" && lastOp <= "9") || lastOp == ".") ) { - display.text = display.text + op.toString() - } else { - display.text = op - } - lastOp = op - return - } - lastOp = op - - if (display.currentOperation.text == "+") { - display.text = Number(display.text.valueOf()) + Number(curVal.valueOf()) - } else if (display.currentOperation.text == "-") { - display.text = Number(curVal) - Number(display.text.valueOf()) - } else if (display.currentOperation.text == multiplication) { - display.text = Number(curVal) * Number(display.text.valueOf()) - } else if (display.currentOperation.text == division) { - display.text = Number(Number(curVal) / Number(display.text.valueOf())).toString() - } else if (display.currentOperation.text == "=") { - } - - if (op == "+" || op == "-" || op == multiplication || op == division) { - display.currentOperation.text = op - curVal = display.text.valueOf() - return - } - - curVal = 0 - display.currentOperation.text = "" - - if (op == "1/x") { - display.text = (1 / display.text.valueOf()).toString() - } else if (op == "x^2") { - display.text = (display.text.valueOf() * display.text.valueOf()).toString() - } else if (op == "Abs") { - display.text = (Math.abs(display.text.valueOf())).toString() - } else if (op == "Int") { - display.text = (Math.floor(display.text.valueOf())).toString() - } else if (op == plusminus) { - display.text = (display.text.valueOf() * -1).toString() - } else if (op == squareRoot) { - display.text = (Math.sqrt(display.text.valueOf())).toString() - } else if (op == "mc") { - memory = 0; - } else if (op == "m+") { - memory += display.text.valueOf() - } else if (op == "mr") { - display.text = memory.toString() - } else if (op == "m-") { - memory = display.text.valueOf() - } else if (op == leftArrow) { - display.text = display.text.toString().slice(0, -1) - if (display.text.length == 0) { - display.text = "0" - } - } else if (op == "Off") { - Qt.quit(); - } else if (op == "C") { - display.text = "0" - } else if (op == "AC") { - curVal = 0 - memory = 0 - lastOp = "" - display.text ="0" - } -} - diff --git a/examples/declarative/calculator/content/images/button-.png b/examples/declarative/calculator/content/images/button-.png deleted file mode 100644 index 544e514536..0000000000 Binary files a/examples/declarative/calculator/content/images/button-.png and /dev/null differ diff --git a/examples/declarative/calculator/content/images/button-blue.png b/examples/declarative/calculator/content/images/button-blue.png deleted file mode 100644 index 5f92de32d0..0000000000 Binary files a/examples/declarative/calculator/content/images/button-blue.png and /dev/null differ diff --git a/examples/declarative/calculator/content/images/button-green.png b/examples/declarative/calculator/content/images/button-green.png deleted file mode 100644 index 36c93914c7..0000000000 Binary files a/examples/declarative/calculator/content/images/button-green.png and /dev/null differ diff --git a/examples/declarative/calculator/content/images/button-purple.png b/examples/declarative/calculator/content/images/button-purple.png deleted file mode 100644 index 347cbbea9d..0000000000 Binary files a/examples/declarative/calculator/content/images/button-purple.png and /dev/null differ diff --git a/examples/declarative/calculator/content/images/button-red.png b/examples/declarative/calculator/content/images/button-red.png deleted file mode 100644 index 3b335891ae..0000000000 Binary files a/examples/declarative/calculator/content/images/button-red.png and /dev/null differ diff --git a/examples/declarative/calculator/content/images/display.png b/examples/declarative/calculator/content/images/display.png deleted file mode 100644 index 9507f4382e..0000000000 Binary files a/examples/declarative/calculator/content/images/display.png and /dev/null differ diff --git a/examples/declarative/calculator/content/qmldir b/examples/declarative/calculator/content/qmldir deleted file mode 100644 index a926b93fac..0000000000 --- a/examples/declarative/calculator/content/qmldir +++ /dev/null @@ -1,2 +0,0 @@ -Button Button.qml -Display Display.qml diff --git a/examples/declarative/canvas/bezierCurve/bezierCurve.qml b/examples/declarative/canvas/bezierCurve/bezierCurve.qml deleted file mode 100644 index f57839b0a5..0000000000 --- a/examples/declarative/canvas/bezierCurve/bezierCurve.qml +++ /dev/null @@ -1,124 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 -import "../contents" -Item { - id:container - width:360 - height:600 - - Column { - spacing:5 - anchors.fill:parent - Text { font.pointSize:25; text:"Bezier Curve"; anchors.horizontalCenter:parent.horizontalCenter} - - Canvas { - id:canvas - width:360 - height:360 - property string strokeStyle:"red" - property string fillStyle:"red" - property int lineWidth:lineWidthCtrl.value - property bool fill:true - property bool stroke:true - property real alpha:alphaCtrl.value - property real scaleX : scaleXCtrl.value - property real scaleY : scaleYCtrl.value - property real rotate : rotateCtrl.value - smooth:true - renderTarget:Canvas.Image - renderStrategy: Canvas.Immediate - - - Behavior on scaleX { SpringAnimation { spring: 2; damping: 0.2; loops:Animation.Infinite } } - Behavior on scaleY { SpringAnimation { spring: 2; damping: 0.2; loops:Animation.Infinite} } - Behavior on rotate { SpringAnimation { spring: 2; damping: 0.2; loops:Animation.Infinite} } - - onLineWidthChanged:requestPaint(); - onFillChanged:requestPaint(); - onStrokeChanged:requestPaint(); - onAlphaChanged:requestPaint(); - onScaleXChanged:requestPaint(); - onScaleYChanged:requestPaint(); - onRotateChanged:requestPaint(); - - onPaint: { - var ctx = canvas.getContext('2d'); - ctx.save(); - ctx.clearRect(0, 0, canvas.width, canvas.height); - ctx.globalAlpha = canvas.alpha; - ctx.strokeStyle = canvas.strokeStyle; - ctx.fillStyle = canvas.fillStyle; - ctx.lineWidth = canvas.lineWidth; - ctx.scale(canvas.scaleX, canvas.scaleY); - ctx.rotate(canvas.rotate); - ctx.beginPath(); - ctx.moveTo(75,40); - ctx.bezierCurveTo(75,37,70,25,50,25); - ctx.bezierCurveTo(20,25,20,62.5,20,62.5); - ctx.bezierCurveTo(20,80,40,102,75,120); - ctx.bezierCurveTo(110,102,130,80,130,62.5); - ctx.bezierCurveTo(130,62.5,130,25,100,25); - ctx.bezierCurveTo(85,25,75,37,75,40); - ctx.closePath(); - if (canvas.fill) - ctx.fill(); - if (canvas.stroke) - ctx.stroke(); - ctx.restore(); - } - } - - Rectangle { - id:controls - width:360 - height:160 - Column { - spacing:3 - Slider {id:lineWidthCtrl; width:300; height:30; min:1; max:10; init:2; name:"Line width"} - Slider {id:scaleXCtrl; width:300; height:30; min:0.1; max:10; init:1; name:"ScaleX"} - Slider {id:scaleYCtrl; width:300; height:30; min:0.1; max:10; init:1; name:"ScaleY"} - Slider {id:rotateCtrl; width:300; height:30; min:0; max:Math.PI*2; init:0; name:"Rotate"} - Slider {id:alphaCtrl; width:300; height:30; min:0; max:1; init:1; name:"Alpha"} - } - } - } -} diff --git a/examples/declarative/canvas/clip/clip.qml b/examples/declarative/canvas/clip/clip.qml deleted file mode 100644 index d861ff0a46..0000000000 --- a/examples/declarative/canvas/clip/clip.qml +++ /dev/null @@ -1,150 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 -import "../contents" -Item { - id:container - width:360 - height:600 - - Column { - spacing:5 - anchors.fill:parent - Text { font.pointSize:25; text:"Makes squircle icon with clip"; anchors.horizontalCenter:parent.horizontalCenter} - Canvas { - id:canvas - width:360 - height:360 - property string strokeStyle:"blue" - property string fillStyle:"steelblue" - property int lineWidth:2 - property int nSize:nCtrl.value - property real radius:rCtrl.value - property bool fill:true - property bool stroke:false - property real px:xCtrl.value - property real py:yCtrl.value - property real alpha:alphaCtrl.value - property string imagefile:"../contents/qt-logo.png" - smooth:true - renderTarget:Canvas.Image - renderStrategy: Canvas.Immediate - Component.onCompleted:loadImage(canvas.imagefile); - - onAlphaChanged:requestPaint(); - onRadiusChanged:requestPaint(); - onLineWidthChanged:requestPaint(); - onNSizeChanged:requestPaint(); - onFillChanged:requestPaint(); - onStrokeChanged:requestPaint(); - onPxChanged:requestPaint(); - onPyChanged:requestPaint(); - - onImageLoaded : requestPaint(); - - onPaint: squcirle(); - - function squcirle() { - var ctx = canvas.getContext("2d"); - var N = canvas.nSize; - var R = canvas.radius; - - N=Math.abs(N); - var M=N; - if (N>100) M=100; - if (N<0.00000000001) M=0.00000000001; - - ctx.save(); - ctx.globalAlpha =canvas.alpha; - ctx.fillStyle = "gray"; - ctx.fillRect(0, 0, canvas.width, canvas.height); - - ctx.strokeStyle = canvas.strokeStyle; - ctx.fillStyle = canvas.fillStyle; - ctx.lineWidth = canvas.lineWidth; - - ctx.beginPath(); - var i = 0, x, y; - for (i=0; i<(2*R+1); i++){ - x = Math.round(i-R) + canvas.px; - y = Math.round(Math.pow(Math.abs(Math.pow(R,M)-Math.pow(Math.abs(i-R),M)),1/M)) + canvas.py; - - if (i == 0) - ctx.moveTo(x, y); - else - ctx.lineTo(x, y); - } - - for (i=(2*R); i<(4*R+1); i++){ - x =Math.round(3*R-i)+canvas.px; - y = Math.round(-Math.pow(Math.abs(Math.pow(R,M)-Math.pow(Math.abs(3*R-i),M)),1/M)) + canvas.py; - ctx.lineTo(x, y); - } - ctx.closePath(); - if (canvas.stroke) { - ctx.stroke(); - } - - if (canvas.fill) { - ctx.fill(); - } - ctx.clip(); - - ctx.drawImage(canvas.imagefile, 0, 0); - ctx.restore(); - } - } - - Rectangle { - id:controls - width:360 - height:160 - Column { - spacing:3 - Slider {id:nCtrl; width:300; height:30; min:1; max:10; init:4; name:"N"} - Slider {id:rCtrl; width:300; height:30; min:30; max:180; init:100; name:"Radius"} - Slider {id:xCtrl; width:300; height:30; min:50; max:300; init:180; name:"X"} - Slider {id:yCtrl; width:300; height:30; min:30; max:300; init:220; name:"Y"} - Slider {id:alphaCtrl; width:300; height:30; min:0; max:1; init:1; name:"Alpha"} - } - } - } -} diff --git a/examples/declarative/canvas/contents/Button.qml b/examples/declarative/canvas/contents/Button.qml deleted file mode 100644 index 1413cdb9fa..0000000000 --- a/examples/declarative/canvas/contents/Button.qml +++ /dev/null @@ -1,87 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -Item { - id: container - - signal clicked - - property string text - width: buttonText.width + 28 - height: buttonText.height + 14 - - BorderImage { - id: buttonImage - source: "images/toolbutton.sci" - width: container.width - 10 - height: container.height - } - BorderImage { - id: pressed - opacity: 0 - source: "images/toolbutton.sci" - width: container.width - 10 - height: container.height - } - MouseArea { - id: mouseRegion - anchors.fill: buttonImage - onClicked: { container.clicked(); } - } - Text { - id: buttonText - color: "white" - anchors.centerIn: buttonImage - font.bold: true - font.pointSize: 15 - text: container.text - style: Text.Raised - styleColor: "black" - } - states: [ - State { - name: "Pressed" - when: mouseRegion.pressed == true - PropertyChanges { target: pressed; opacity: 1 } - } - ] -} \ No newline at end of file diff --git a/examples/declarative/canvas/contents/ScrollBar.qml b/examples/declarative/canvas/contents/ScrollBar.qml deleted file mode 100644 index 98b8efee4a..0000000000 --- a/examples/declarative/canvas/contents/ScrollBar.qml +++ /dev/null @@ -1,74 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the Qt Mobility Components. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -Item { - id: scrollBar - // The properties that define the scrollbar's state. - // position and pageSize are in the range 0.0 - 1.0. They are relative to the - // height of the page, i.e. a pageSize of 0.5 means that you can see 50% - // of the height of the view. - // orientation can be either 'Vertical' or 'Horizontal' - property real position - property real pageSize - property string orientation : "Vertical" - property alias bgColor: background.color - property alias fgColor: thumb.color - - // A light, semi-transparent background - Rectangle { - id: background - radius: orientation == 'Vertical' ? (width/2 - 1) : (height/2 - 1) - color: "white"; opacity: 0.3 - anchors.fill: parent - } - // Size the bar to the required size, depending upon the orientation. - Rectangle { - id: thumb - opacity: 0.7 - color: "black" - radius: orientation == 'Vertical' ? (width/2 - 1) : (height/2 - 1) - x: orientation == 'Vertical' ? 1 : (scrollBar.position * (scrollBar.width-2) + 1) - y: orientation == 'Vertical' ? (scrollBar.position * (scrollBar.height-2) + 1) : 1 - width: orientation == 'Vertical' ? (parent.width-2) : (scrollBar.pageSize * (scrollBar.width-2)) - height: orientation == 'Vertical' ? (scrollBar.pageSize * (scrollBar.height-2)) : (parent.height-2) - } -} diff --git a/examples/declarative/canvas/contents/Slider.qml b/examples/declarative/canvas/contents/Slider.qml deleted file mode 100644 index 1050e307f6..0000000000 --- a/examples/declarative/canvas/contents/Slider.qml +++ /dev/null @@ -1,115 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the Declarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -Item { - id:slider - property real min:0 - property real max:1 - property real value: min + (max - min) * (bar.x / (foo.width - bar.width)) - property real init:min+(max-min)/2 - property string name:"Slider" - - Component.onCompleted: setValue(init) - function setValue(v) { - if (min < max) - bar.x = v/(max - min) * (foo.width - bar.width); - } - Rectangle { - id:sliderName - anchors.left:parent.left - height: childrenRect.height - width:childrenRect.width - anchors.verticalCenter:parent.verticalCenter - Text { - text:slider.name - font.pointSize:12 - } - } - Item { - id: foo - height: 6 - width: parent.width - 4 - sliderName.width - anchors.verticalCenter:parent.verticalCenter - anchors.left:sliderName.right - anchors.leftMargin:5 - Rectangle { - height: parent.height - anchors.left: parent.left - anchors.right: bar.horizontalCenter - color: "blue" - radius: 3 - } - Rectangle { - height: parent.height - anchors.left: bar.horizontalCenter - anchors.right: parent.right - color: "gray" - radius: 3 - } - Rectangle { - anchors.fill: parent - color: "transparent" - radius: 3 - border.width: 2 - border.color: "black" - } - - Rectangle { - id: bar - y: -7 - width: 20 - height: 20 - radius: 15 - color: "white" - border.width: 2 - border.color: "black" - MouseArea { - anchors.fill: parent - drag.target: parent - drag.axis: Drag.XAxis - drag.minimumX: 0 - drag.maximumX: foo.width - parent.width - } - } - } -} diff --git a/examples/declarative/canvas/contents/Stocks.qml b/examples/declarative/canvas/contents/Stocks.qml deleted file mode 100644 index 043bca132e..0000000000 --- a/examples/declarative/canvas/contents/Stocks.qml +++ /dev/null @@ -1,147 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -ListModel { - id:stocks - //Data from : http://en.wikipedia.org/wiki/NASDAQ-100 - - ListElement {name:"Activision Blizzard"; stockId:"ATVI"} - ListElement {name:"Adobe Systems Incorporated"; stockId:"ADBE"} - ListElement {name:"Akamai Technologies, Inc"; stockId:"AKAM"} - ListElement {name:"Alexion Pharmaceuticals"; stockId:"ALXN"} - ListElement {name:"Altera Corporation"; stockId:"ALTR"} - ListElement {name:"Amazon.com, Inc."; stockId:"AMZN"} - ListElement {name:"Amgen Inc."; stockId:"AMGN"} - ListElement {name:"Apollo Group, Inc."; stockId:"APOL"} - ListElement {name:"Apple Inc."; stockId:"AAPL"} - ListElement {name:"Applied Materials, Inc."; stockId:"AMAT"} - ListElement {name:"Autodesk, Inc."; stockId:"ADSK"} - ListElement {name:"Automatic Data Processing, Inc."; stockId:"ADP"} - ListElement {name:"Baidu.com, Inc."; stockId:"BIDU"} - ListElement {name:"Bed Bath & Beyond Inc."; stockId:"BBBY"} - ListElement {name:"Biogen Idec, Inc"; stockId:"BIIB"} - ListElement {name:"BMC Software, Inc."; stockId:"BMC"} - ListElement {name:"Broadcom Corporation"; stockId:"BRCM"} - ListElement {name:"C. H. Robinson Worldwide, Inc."; stockId:"CHRW"} - ListElement {name:"CA, Inc."; stockId:"CA"} - ListElement {name:"Celgene Corporation"; stockId:"CELG"} - ListElement {name:"Cephalon, Inc."; stockId:"CEPH"} - ListElement {name:"Cerner Corporation"; stockId:"CERN"} - ListElement {name:"Check Point Software Technologies Ltd."; stockId:"CHKP"} - ListElement {name:"Cisco Systems, Inc."; stockId:"CSCO"} - ListElement {name:"Citrix Systems, Inc."; stockId:"CTXS"} - ListElement {name:"Cognizant Technology Solutions Corporation"; stockId:"CTSH"} - ListElement {name:"Comcast Corporation"; stockId:"CMCSA"} - ListElement {name:"Costco Wholesale Corporation"; stockId:"COST"} - ListElement {name:"Ctrip.com International, Ltd."; stockId:"CTRP"} - ListElement {name:"Dell Inc."; stockId:"DELL"} - ListElement {name:"DENTSPLY International Inc."; stockId:"XRAY"} - ListElement {name:"DirecTV"; stockId:"DTV"} - ListElement {name:"Dollar Tree, Inc."; stockId:"DLTR"} - ListElement {name:"eBay Inc."; stockId:"EBAY"} - ListElement {name:"Electronic Arts Inc."; stockId:"ERTS"} - ListElement {name:"Expedia, Inc."; stockId:"EXPE"} - ListElement {name:"Expeditors International of Washington, Inc."; stockId:"EXPD"} - ListElement {name:"Express Scripts, Inc."; stockId:"ESRX"} - ListElement {name:"F5 Networks, Inc."; stockId:"FFIV"} - ListElement {name:"Fastenal Company"; stockId:"FAST"} - ListElement {name:"First Solar, Inc."; stockId:"FSLR"} - ListElement {name:"Fiserv, Inc."; stockId:"FISV"} - ListElement {name:"Flextronics International Ltd."; stockId:"FLEX"} - ListElement {name:"FLIR Systems, Inc."; stockId:"FLIR"} - ListElement {name:"Garmin Ltd."; stockId:"GRMN"} - ListElement {name:"Gilead Sciences, Inc."; stockId:"GILD"} - ListElement {name:"Google Inc."; stockId:"GOOG"} - ListElement {name:"Green Mountain Coffee Roasters, Inc."; stockId:"GMCR"} - ListElement {name:"Henry Schein, Inc."; stockId:"HSIC"} - ListElement {name:"Illumina, Inc."; stockId:"ILMN"} - ListElement {name:"Infosys Technologies"; stockId:"INFY"} - ListElement {name:"Intel Corporation"; stockId:"INTC"} - ListElement {name:"Intuit, Inc."; stockId:"INTU"} - ListElement {name:"Intuitive Surgical Inc."; stockId:"ISRG"} - ListElement {name:"Joy Global Inc."; stockId:"JOYG"} - ListElement {name:"KLA Tencor Corporation"; stockId:"KLAC"} - ListElement {name:"Lam Research Corporation"; stockId:"LRCX"} - ListElement {name:"Liberty Media Corporation, Interactive Series A"; stockId:"LINTA"} - ListElement {name:"Life Technologies Corporation"; stockId:"LIFE"} - ListElement {name:"Linear Technology Corporation"; stockId:"LLTC"} - ListElement {name:"Marvell Technology Group, Ltd."; stockId:"MRVL"} - ListElement {name:"Mattel, Inc."; stockId:"MAT"} - ListElement {name:"Maxim Integrated Products"; stockId:"MXIM"} - ListElement {name:"Microchip Technology Incorporated"; stockId:"MCHP"} - ListElement {name:"Micron Technology, Inc."; stockId:"MU"} - ListElement {name:"Microsoft Corporation"; stockId:"MSFT"} - ListElement {name:"Mylan, Inc."; stockId:"MYL"} - ListElement {name:"NetApp, Inc."; stockId:"NTAP"} - ListElement {name:"Netflix, Inc."; stockId:"NFLX"} - ListElement {name:"News Corporation, Ltd."; stockId:"NWSA"} - ListElement {name:"NII Holdings, Inc."; stockId:"NIHD"} - ListElement {name:"NVIDIA Corporation"; stockId:"NVDA"} - ListElement {name:"O'Reilly Automotive, Inc."; stockId:"ORLY"} - ListElement {name:"Oracle Corporation"; stockId:"ORCL"} - ListElement {name:"PACCAR Inc."; stockId:"PCAR"} - ListElement {name:"Paychex, Inc."; stockId:"PAYX"} - ListElement {name:"Priceline.com, Incorporated"; stockId:"PCLN"} - ListElement {name:"Qiagen N.V."; stockId:"QGEN"} - ListElement {name:"QUALCOMM Incorporated"; stockId:"QCOM"} - ListElement {name:"Research in Motion Limited"; stockId:"RIMM"} - ListElement {name:"Ross Stores Inc."; stockId:"ROST"} - ListElement {name:"SanDisk Corporation"; stockId:"SNDK"} - ListElement {name:"Seagate Technology Holdings"; stockId:"STX"} - ListElement {name:"Sears Holdings Corporation"; stockId:"SHLD"} - ListElement {name:"Sigma-Aldrich Corporation"; stockId:"SIAL"} - ListElement {name:"Staples Inc."; stockId:"SPLS"} - ListElement {name:"Starbucks Corporation"; stockId:"SBUX"} - ListElement {name:"Stericycle, Inc"; stockId:"SRCL"} - ListElement {name:"Symantec Corporation"; stockId:"SYMC"} - ListElement {name:"Teva Pharmaceutical Industries Ltd."; stockId:"TEVA"} - ListElement {name:"Urban Outfitters, Inc."; stockId:"URBN"} - ListElement {name:"VeriSign, Inc."; stockId:"VRSN"} - ListElement {name:"Vertex Pharmaceuticals"; stockId:"VRTX"} - ListElement {name:"Virgin Media, Inc."; stockId:"VMED"} - ListElement {name:"Vodafone Group, plc."; stockId:"VOD"} - ListElement {name:"Warner Chilcott, Ltd."; stockId:"WCRX"} - ListElement {name:"Whole Foods Market, Inc."; stockId:"WFM"} - ListElement {name:"Wynn Resorts Ltd."; stockId:"WYNN"} - ListElement {name:"Xilinx, Inc."; stockId:"XLNX"} - ListElement {name:"Yahoo! Inc."; stockId:"YHOO"} -} diff --git a/examples/declarative/canvas/contents/TitleBar.qml b/examples/declarative/canvas/contents/TitleBar.qml deleted file mode 100644 index 28edda2ae7..0000000000 --- a/examples/declarative/canvas/contents/TitleBar.qml +++ /dev/null @@ -1,70 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -Item { - id: titleBar - property string title: "" - - BorderImage { source: "images/titlebar.sci"; width: parent.width; height: parent.height + 14; y: -7 } - - Image { - id: quitButton - anchors.left: parent.left//; anchors.leftMargin: 0 - anchors.verticalCenter: parent.verticalCenter - source: "images/quit.png" - MouseArea { - anchors.fill: parent - onClicked: Qt.quit() - } - } - - Text { - id: categoryText - anchors { - left: quitButton.right; right: parent.right; //leftMargin: 10; rightMargin: 10 - verticalCenter: parent.verticalCenter - } - elide: Text.ElideLeft - text: title - font.bold: true; font.pointSize: 20; color: "White"; style: Text.Raised; styleColor: "Black" - } -} diff --git a/examples/declarative/canvas/contents/ToolBar.qml b/examples/declarative/canvas/contents/ToolBar.qml deleted file mode 100644 index 7ae7391ddf..0000000000 --- a/examples/declarative/canvas/contents/ToolBar.qml +++ /dev/null @@ -1,69 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -Item { - id: toolbar - - property variant labels - signal buttonClicked(int index) - - BorderImage { - source: "images/titlebar.sci" - width: parent.width - height: parent.height + 14 - y: -7 - } - - Row { - y: 3 - anchors.horizontalCenter: parent.horizontalCenter - Repeater { - model: toolbar.labels - delegate: - Button { - text: modelData - onClicked: toolbar.buttonClicked(model.index) - } - } - } - -} diff --git a/examples/declarative/canvas/contents/images/button-pressed.png b/examples/declarative/canvas/contents/images/button-pressed.png deleted file mode 100644 index e434d327f2..0000000000 Binary files a/examples/declarative/canvas/contents/images/button-pressed.png and /dev/null differ diff --git a/examples/declarative/canvas/contents/images/button.png b/examples/declarative/canvas/contents/images/button.png deleted file mode 100644 index 56a63ce641..0000000000 Binary files a/examples/declarative/canvas/contents/images/button.png and /dev/null differ diff --git a/examples/declarative/canvas/contents/images/default.svg b/examples/declarative/canvas/contents/images/default.svg deleted file mode 100644 index 248199cc4e..0000000000 --- a/examples/declarative/canvas/contents/images/default.svg +++ /dev/null @@ -1,82 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - image/svg+xml - - weather-clear - January 2006 - - - Ryan Collier (pseudo) - - - - - http://www.tango-project.org - - - http://www.pseudocode.org - - - weather - applet - notification - - - - - - Garrett LeSage - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/examples/declarative/canvas/contents/images/gloss.png b/examples/declarative/canvas/contents/images/gloss.png deleted file mode 100755 index 5d370cd93d..0000000000 Binary files a/examples/declarative/canvas/contents/images/gloss.png and /dev/null differ diff --git a/examples/declarative/canvas/contents/images/lineedit.png b/examples/declarative/canvas/contents/images/lineedit.png deleted file mode 100755 index 2cc38dc35b..0000000000 Binary files a/examples/declarative/canvas/contents/images/lineedit.png and /dev/null differ diff --git a/examples/declarative/canvas/contents/images/lineedit.sci b/examples/declarative/canvas/contents/images/lineedit.sci deleted file mode 100644 index 054bff78be..0000000000 --- a/examples/declarative/canvas/contents/images/lineedit.sci +++ /dev/null @@ -1,5 +0,0 @@ -border.left: 10 -border.top: 10 -border.bottom: 10 -border.right: 10 -source: lineedit.png diff --git a/examples/declarative/canvas/contents/images/quit.png b/examples/declarative/canvas/contents/images/quit.png deleted file mode 100755 index 5bda1b6e0d..0000000000 Binary files a/examples/declarative/canvas/contents/images/quit.png and /dev/null differ diff --git a/examples/declarative/canvas/contents/images/stripes.png b/examples/declarative/canvas/contents/images/stripes.png deleted file mode 100755 index 9f36727ea4..0000000000 Binary files a/examples/declarative/canvas/contents/images/stripes.png and /dev/null differ diff --git a/examples/declarative/canvas/contents/images/titlebar.png b/examples/declarative/canvas/contents/images/titlebar.png deleted file mode 100755 index 51c90082d0..0000000000 Binary files a/examples/declarative/canvas/contents/images/titlebar.png and /dev/null differ diff --git a/examples/declarative/canvas/contents/images/titlebar.sci b/examples/declarative/canvas/contents/images/titlebar.sci deleted file mode 100644 index 0418d94cd6..0000000000 --- a/examples/declarative/canvas/contents/images/titlebar.sci +++ /dev/null @@ -1,5 +0,0 @@ -border.left: 10 -border.top: 12 -border.bottom: 12 -border.right: 10 -source: titlebar.png diff --git a/examples/declarative/canvas/contents/images/toolbutton.png b/examples/declarative/canvas/contents/images/toolbutton.png deleted file mode 100755 index 11310013ee..0000000000 Binary files a/examples/declarative/canvas/contents/images/toolbutton.png and /dev/null differ diff --git a/examples/declarative/canvas/contents/images/toolbutton.sci b/examples/declarative/canvas/contents/images/toolbutton.sci deleted file mode 100644 index 9e4f965307..0000000000 --- a/examples/declarative/canvas/contents/images/toolbutton.sci +++ /dev/null @@ -1,5 +0,0 @@ -border.left: 15 -border.top: 4 -border.bottom: 4 -border.right: 15 -source: toolbutton.png diff --git a/examples/declarative/canvas/contents/qt-logo.png b/examples/declarative/canvas/contents/qt-logo.png deleted file mode 100644 index 5ab3a1b0c4..0000000000 Binary files a/examples/declarative/canvas/contents/qt-logo.png and /dev/null differ diff --git a/examples/declarative/canvas/quadraticCurveTo/quadraticCurveTo.qml b/examples/declarative/canvas/quadraticCurveTo/quadraticCurveTo.qml deleted file mode 100644 index bc3ca0071a..0000000000 --- a/examples/declarative/canvas/quadraticCurveTo/quadraticCurveTo.qml +++ /dev/null @@ -1,128 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 -import "../contents" -Item { - id:container - width:360 - height:600 - - Column { - spacing:5 - anchors.fill:parent - Text { font.pointSize:25; text:"Quadratic Curve"; anchors.horizontalCenter:parent.horizontalCenter} - - Canvas { - id:canvas - width:360 - height:360 - property string strokeStyle:"steelblue" - property string fillStyle:"yellow" - property int lineWidth:lineWidthCtrl.value - property bool fill:true - property bool stroke:true - property real alpha:alphaCtrl.value - property real scaleX : scaleXCtrl.value - property real scaleY : scaleYCtrl.value - property real rotate : rotateCtrl.value - smooth:true - renderTarget:Canvas.Image - renderStrategy: Canvas.Immediate - - onLineWidthChanged:requestPaint(); - onFillChanged:requestPaint(); - onStrokeChanged:requestPaint(); - onAlphaChanged:requestPaint(); - onScaleXChanged:requestPaint(); - onScaleYChanged:requestPaint(); - onRotateChanged:requestPaint(); - Behavior on scaleX { SpringAnimation { spring: 2; damping: 0.2; loops:Animation.Infinite } } - Behavior on scaleY { SpringAnimation { spring: 2; damping: 0.2; loops:Animation.Infinite} } - Behavior on rotate { SpringAnimation { spring: 2; damping: 0.2; loops:Animation.Infinite} } - - onPaint: { - var ctx = canvas.getContext('2d'); - ctx.save(); - ctx.clearRect(0, 0, canvas.width, canvas.height); - ctx.globalAlpha = canvas.alpha; - ctx.strokeStyle = canvas.strokeStyle; - ctx.fillStyle = canvas.fillStyle; - ctx.lineWidth = canvas.lineWidth; - ctx.scale(canvas.scaleX, canvas.scaleY); - ctx.rotate(canvas.rotate); - ctx.beginPath(); - ctx.moveTo(75,25); - ctx.quadraticCurveTo(25,25,25,62.5); - ctx.quadraticCurveTo(25,100,50,100); - ctx.quadraticCurveTo(50,120,30,125); - ctx.quadraticCurveTo(60,120,65,100); - ctx.quadraticCurveTo(125,100,125,62.5); - ctx.quadraticCurveTo(125,25,75,25); - ctx.closePath(); - if (canvas.fill) - ctx.fill(); - if (canvas.stroke) - ctx.stroke(); - - - ctx.fillStyle="green"; - ctx.font = "Bold 15px"; - - ctx.fillText("QML酷毙了", 30, 60); - ctx.restore(); - } - } - - Rectangle { - id:controls - width:360 - height:160 - Column { - spacing:3 - Slider {id:lineWidthCtrl; width:300; height:30; min:1; max:10; init:2; name:"Line width"} - Slider {id:scaleXCtrl; width:300; height:30; min:0.1; max:10; init:1; name:"ScaleX"} - Slider {id:scaleYCtrl; width:300; height:30; min:0.1; max:10; init:1; name:"ScaleY"} - Slider {id:rotateCtrl; width:300; height:30; min:0; max:Math.PI*2; init:0; name:"Rotate"} - Slider {id:alphaCtrl; width:300; height:30; min:0; max:1; init:1; name:"Alpha"} - } - } - } -} diff --git a/examples/declarative/canvas/roundedrect/roundedrect.qml b/examples/declarative/canvas/roundedrect/roundedrect.qml deleted file mode 100644 index fd86c63a3b..0000000000 --- a/examples/declarative/canvas/roundedrect/roundedrect.qml +++ /dev/null @@ -1,125 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 -import "../contents" -Item { - id:container - width:360 - height:600 - - Column { - spacing:5 - anchors.fill:parent - Text { font.pointSize:25; text:"Rounded rectangle"; anchors.horizontalCenter:parent.horizontalCenter} - Canvas { - id:canvas - width:360 - height:360 - smooth:true - renderTarget:Canvas.Image - renderStrategy: Canvas.Immediate - - property int radius: rCtrl.value - property int rectx: rxCtrl.value - property int recty: ryCtrl.value - property int rectWidth: width - 2*rectx - property int rectHeight: height - 2*recty - property string strokeStyle:"blue" - property string fillStyle:"steelblue" - property int lineWidth:lineWidthCtrl.value - property bool fill:true - property bool stroke:true - property real alpha:alphaCtrl.value - - onLineWidthChanged:requestPaint(); - onFillChanged:requestPaint(); - onStrokeChanged:requestPaint(); - onRadiusChanged:requestPaint(); - onRectxChanged:requestPaint(); - onRectyChanged:requestPaint(); - onAlphaChanged:requestPaint(); - - onPaint: { - var ctx = getContext("2d"); - ctx.save(); - ctx.clearRect(0,0,canvas.width, canvas.height); - ctx.strokeStyle = canvas.strokeStyle; - ctx.lineWidth = canvas.lineWidth - ctx.fillStyle = canvas.fillStyle - ctx.globalAlpha = canvas.alpha - ctx.beginPath(); - ctx.moveTo(rectx+radius,recty); // top side - ctx.lineTo(rectx+rectWidth-radius,recty); - // draw top right corner - ctx.arcTo(rectx+rectWidth,recty,rectx+rectWidth,recty+radius,radius); - ctx.lineTo(rectx+rectWidth,recty+rectHeight-radius); // right side - // draw bottom right corner - ctx.arcTo(rectx+rectWidth,recty+rectHeight,rectx+rectWidth-radius,recty+rectHeight,radius); - ctx.lineTo(rectx+radius,recty+rectHeight); // bottom side - // draw bottom left corner - ctx.arcTo(rectx,recty+rectHeight,rectx,recty+rectHeight-radius,radius); - ctx.lineTo(rectx,recty+radius); // left side - // draw top left corner - ctx.arcTo(rectx,recty,rectx+radius,recty,radius); - ctx.closePath(); - if (canvas.fill) - ctx.fill(); - if (canvas.stroke) - ctx.stroke(); - ctx.restore(); - } - } - - Rectangle { - id:controls - width:360 - height:160 - Column { - spacing:3 - Slider {id:lineWidthCtrl; width:300; height:30; min:1; max:10; init:2; name:"Line width"} - Slider {id:rxCtrl; width:300; height:30; min:5; max:30; init:10; name:"rectx"} - Slider {id:ryCtrl; width:300; height:30; min:5; max:30; init:10; name:"recty"} - Slider {id:rCtrl; width:300; height:30; min:10; max:100; init:40; name:"Radius"} - Slider {id:alphaCtrl; width:300; height:30; min:0; max:1; init:1; name:"Alpha"} - } - } - } -} diff --git a/examples/declarative/canvas/smile/smile.qml b/examples/declarative/canvas/smile/smile.qml deleted file mode 100644 index 28a48a6c81..0000000000 --- a/examples/declarative/canvas/smile/smile.qml +++ /dev/null @@ -1,128 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 -import "../contents" -Item { - id:container - width:360 - height:600 - - Column { - spacing:5 - anchors.fill:parent - Text { font.pointSize:25; text:"Smile with arcs"; anchors.horizontalCenter:parent.horizontalCenter} - - Canvas { - id:canvas - width:360 - height:360 - smooth:true - renderTarget:Canvas.Image - renderStrategy: Canvas.Immediate - - property string strokeStyle:"green" - property string fillStyle:"yellow" - property int lineWidth:lineWidthCtrl.value - property bool fill:true - property bool stroke:true - property real alpha:alphaCtrl.value - property real scaleX : scaleXCtrl.value - property real scaleY : scaleYCtrl.value - property real rotate : rotateCtrl.value - - onLineWidthChanged:requestPaint(); - onFillChanged:requestPaint(); - onStrokeChanged:requestPaint(); - onAlphaChanged:requestPaint(); - onScaleXChanged:requestPaint(); - onScaleYChanged:requestPaint(); - onRotateChanged:requestPaint(); - - Behavior on scaleX { SpringAnimation { spring: 2; damping: 0.2; loops:Animation.Infinite } } - Behavior on scaleY { SpringAnimation { spring: 2; damping: 0.2; loops:Animation.Infinite} } - Behavior on rotate { SpringAnimation { spring: 2; damping: 0.2; loops:Animation.Infinite} } - - onPaint: { - var ctx = canvas.getContext('2d'); - ctx.save(); - ctx.clearRect(0, 0, canvas.width, canvas.height); - ctx.globalAlpha = canvas.alpha; - ctx.strokeStyle = canvas.strokeStyle; - ctx.fillStyle = canvas.fillStyle; - ctx.lineWidth = canvas.lineWidth; - ctx.scale(canvas.scaleX, canvas.scaleY); - ctx.rotate(canvas.rotate); - ctx.beginPath(); - ctx.moveTo(75 + 50 * Math.cos(0), - 75 - 50 * Math.sin(Math.PI*2)); - ctx.arc(75,75,50,0,Math.PI*2,true); // Outer circle - ctx.moveTo(75,70); - ctx.arc(75,70,35,0,Math.PI,false); // Mouth (clockwise) - ctx.moveTo(60,65); - ctx.arc(60,65,5,0,Math.PI*2,true); // Left eye - ctx.moveTo(90 + 5 * Math.cos(0), - 65 - 5 * Math.sin(Math.PI*2)); - ctx.moveTo(90,65); - ctx.arc(90,65,5,0,Math.PI*2,true); // Right eye - ctx.closePath(); - if (canvas.fill) - ctx.fill(); - if (canvas.stroke) - ctx.stroke(); - ctx.restore(); - } - } - - Rectangle { - id:controls - width:360 - height:160 - Column { - spacing:3 - Slider {id:lineWidthCtrl; width:300; height:30; min:1; max:10; init:2; name:"Line width"} - Slider {id:scaleXCtrl; width:300; height:30; min:0.1; max:10; init:1; name:"ScaleX"} - Slider {id:scaleYCtrl; width:300; height:30; min:0.1; max:10; init:1; name:"ScaleY"} - Slider {id:rotateCtrl; width:300; height:30; min:0; max:Math.PI*2; init:0; name:"Rotate"} - Slider {id:alphaCtrl; width:300; height:30; min:0; max:1; init:1; name:"Alpha"} - } - } - } -} diff --git a/examples/declarative/canvas/squircle/squircle.png b/examples/declarative/canvas/squircle/squircle.png deleted file mode 100644 index 86c69d945f..0000000000 Binary files a/examples/declarative/canvas/squircle/squircle.png and /dev/null differ diff --git a/examples/declarative/canvas/squircle/squircle.qml b/examples/declarative/canvas/squircle/squircle.qml deleted file mode 100644 index 2fc65b67b3..0000000000 --- a/examples/declarative/canvas/squircle/squircle.qml +++ /dev/null @@ -1,155 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 -import "../contents" -Item { - id:container - width:360 - height:600 - - Column { - spacing:5 - anchors.fill:parent - Text { font.pointSize:25; text:"Squircles"; anchors.horizontalCenter:parent.horizontalCenter} - Image { - anchors.horizontalCenter:parent.horizontalCenter - source:"squircle.png" - width:250 - height:25 - } - Canvas { - id:canvas - width:360 - height:360 - smooth:true - renderTarget:Canvas.Image - renderStrategy: Canvas.Immediate - - property string strokeStyle:"blue" - property string fillStyle:"steelblue" - property int lineWidth:2 - property int nSize:nCtrl.value - property real radius:rCtrl.value - property bool fill:true - property bool stroke:false - property real px:xCtrl.value - property real py:yCtrl.value - property real alpha:alphaCtrl.value - - onAlphaChanged:requestPaint(); - onRadiusChanged:requestPaint(); - onLineWidthChanged:requestPaint(); - onNSizeChanged:requestPaint(); - onFillChanged:requestPaint(); - onStrokeChanged:requestPaint(); - onPxChanged:requestPaint(); - onPyChanged:requestPaint(); - - - onPaint: squcirle(); - - function squcirle() { - var ctx = canvas.getContext("2d"); - var N = canvas.nSize; - var R = canvas.radius; - - N=Math.abs(N); - var M=N; - if (N>100) M=100; - if (N<0.00000000001) M=0.00000000001; - - ctx.save(); - ctx.globalAlpha =canvas.alpha; - ctx.fillStyle = "gray"; - ctx.fillRect(0, 0, canvas.width, canvas.height); - - ctx.strokeStyle = canvas.strokeStyle; - ctx.fillStyle = canvas.fillStyle; - ctx.lineWidth = canvas.lineWidth; - - ctx.beginPath(); - var i = 0, x, y; - for (i=0; i<(2*R+1); i++){ - x = Math.round(i-R) + canvas.px; - y = Math.round(Math.pow(Math.abs(Math.pow(R,M)-Math.pow(Math.abs(i-R),M)),1/M)) + canvas.py; - - if (i == 0) - ctx.moveTo(x, y); - else - ctx.lineTo(x, y); - } - - for (i=(2*R); i<(4*R+1); i++){ - x =Math.round(3*R-i)+canvas.px; - y = Math.round(-Math.pow(Math.abs(Math.pow(R,M)-Math.pow(Math.abs(3*R-i),M)),1/M)) + canvas.py; - ctx.lineTo(x, y); - } - ctx.closePath(); - if (canvas.stroke) { - ctx.stroke(); - } - - if (canvas.fill) { - ctx.fill(); - } - - ctx.fillStyle = "yellow"; - ctx.font = "Helvetica 16px"; - ctx.fillText("|X-" + Math.round(canvas.px) + "|^" + N + " + |Y-"+Math.round(canvas.py)+"|^" + N + " = |" + Math.round(R) + "|^" + N, canvas.px - 125, canvas.py); - ctx.restore(); - } - } - - Rectangle { - id:controls - width:360 - height:160 - Column { - spacing:3 - Slider {id:nCtrl; width:300; height:30; min:1; max:10; init:4; name:"N"} - Slider {id:rCtrl; width:300; height:30; min:30; max:180; init:100; name:"Radius"} - Slider {id:xCtrl; width:300; height:30; min:50; max:300; init:180; name:"X"} - Slider {id:yCtrl; width:300; height:30; min:30; max:300; init:220; name:"Y"} - Slider {id:alphaCtrl; width:300; height:30; min:0; max:1; init:1; name:"Alpha"} - } - } - } -} diff --git a/examples/declarative/canvas/stockchart/README b/examples/declarative/canvas/stockchart/README deleted file mode 100644 index 2652866ed6..0000000000 --- a/examples/declarative/canvas/stockchart/README +++ /dev/null @@ -1,5 +0,0 @@ -To run: - - make install - QML_IMPORT_PATH=$PWD qmlscene stock.qml - diff --git a/examples/declarative/canvas/stockchart/com/nokia/StockChartExample/qmldir b/examples/declarative/canvas/stockchart/com/nokia/StockChartExample/qmldir deleted file mode 100644 index 4c60e556d4..0000000000 --- a/examples/declarative/canvas/stockchart/com/nokia/StockChartExample/qmldir +++ /dev/null @@ -1 +0,0 @@ -plugin qmlstockchartexampleplugin diff --git a/examples/declarative/canvas/stockchart/model.cpp b/examples/declarative/canvas/stockchart/model.cpp deleted file mode 100644 index 42eb2d592f..0000000000 --- a/examples/declarative/canvas/stockchart/model.cpp +++ /dev/null @@ -1,255 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include "model.h" - -#include -#include -#include -#include -#include - -#include -#include - -StockModel::StockModel(QObject *parent) - : QAbstractListModel(parent) - , _startDate(QDate(1995, 4, 25)) - , _endDate(QDate::currentDate()) - , _dataCycle(StockModel::Daily) - , _manager(0) - , _updating(false) -{ - QHash roles; - roles[StockModel::DateRole] = "date"; - roles[StockModel::SectionRole] = "year"; - roles[StockModel::OpenPriceRole] = "openPrice"; - roles[StockModel::ClosePriceRole] = "closePrice"; - roles[StockModel::HighPriceRole] = "highPrice"; - roles[StockModel::LowPriceRole] = "lowPrice"; - roles[StockModel::VolumeRole] = "volume"; - roles[StockModel::AdjustedPriceRole] = "adjustedPrice"; - setRoleNames(roles); - - connect(this, SIGNAL(stockNameChanged()), SLOT(requestData())); - connect(this, SIGNAL(startDateChanged()), SLOT(requestData())); - connect(this, SIGNAL(endDateChanged()), SLOT(requestData())); - connect(this, SIGNAL(dataCycleChanged()), SLOT(requestData())); - - _manager = new QNetworkAccessManager(this); - connect(_manager, SIGNAL(finished(QNetworkReply*)), this, SLOT(update(QNetworkReply*))); - -} - -int StockModel::rowCount(const QModelIndex & parent) const { - Q_UNUSED(parent); - return _prices.count(); -} - -StockPrice* StockModel::stockPriceAtIndex(int idx) const -{ - if (idx >=0 && idx < _prices.size()) { - return _prices[idx]; - } - return 0; -} - - -void StockModel::requestData() -{ - if (!_updating) { - _updating = true; - QMetaObject::invokeMethod(this, "doRequest", Qt::QueuedConnection); - } -} - -void StockModel::doRequest() -{ - /* - Fetch stock data from yahoo finance: - url: http://ichart.finance.yahoo.com/table.csv?s=NOK&a=5&b=11&c=2010&d=7&e=23&f=2010&g=d&ignore=.csv - s:stock name/id, a:start day, b:start month, c:start year default: 25 April 1995, oldest c= 1962 - d:end day, e:end month, f:end year, default:today (data only available 3 days before today) - g:data cycle(d daily, w weekly, m monthly, v Dividend) - */ - if (_manager && !_stockName.isEmpty() && _endDate > _startDate) { - QString query("http://ichart.finance.yahoo.com/table.csv?s=%1&a=%2&b=%3&c=%4&d=%5&e=%6&f=%7&g=%8&ignore=.csv"); - query = query.arg(_stockName) - .arg(_startDate.day()).arg(_startDate.month()).arg(_startDate.year()) - .arg(_endDate.day()).arg(_endDate.month()).arg(_endDate.year()) - .arg(dataCycleString()); - - qDebug() << "request stock data:" << query; - QNetworkReply* reply = _manager->get(QNetworkRequest(QUrl(query))); - connect(reply, SIGNAL(downloadProgress(qint64,qint64)), SIGNAL(downloadProgress(qint64,qint64))); - } -} - -void StockModel::update(QNetworkReply *reply) -{ - _updating = false; - - if (reply) { - if (reply->error() == QNetworkReply::NoError) { - beginResetModel(); - - foreach (StockPrice* p, _prices) { - p->deleteLater(); - } - - _prices.clear(); - - while (!reply->atEnd()) { - QString line = reply->readLine(); - QStringList fields = line.split(','); - - //data format:Date,Open,High,Low,Close,Volume,Adjusted close price - //example: 2011-06-24,6.03,6.04,5.88,5.88,20465200,5.88 - if (fields.size() == 7) { - StockPrice* price = new StockPrice(this); - price->setDate(QDate::fromString(fields[0], Qt::ISODate)); - price->setOpenPrice(fields[1].toFloat()); - price->setHighPrice(fields[2].toFloat()); - price->setLowPrice(fields[3].toFloat()); - price->setClosePrice(fields[4].toFloat()); - price->setVolume(fields[5].toInt()); - price->setAdjustedPrice(fields[6].toFloat()); - _prices.prepend(price); - } - } - qDebug() << "get stock data successfully, total:" << _prices.count() << "records."; - } else { - qDebug() << "get stock data failed:" << reply->errorString(); - } - reply->deleteLater(); - endResetModel(); - emit dataChanged(QModelIndex(), QModelIndex()); - } -} - -QVariant StockModel::data(const QModelIndex & index, int role) const { - if (index.row() < 0 || index.row() > _prices.count()) - return QVariant(); - - const StockPrice* price = _prices[index.row()]; - if (role == StockModel::DateRole) - return price->date(); - else if (role == StockModel::OpenPriceRole) - return price->openPrice(); - else if (role == StockModel::ClosePriceRole) - return price->closePrice(); - else if (role == StockModel::HighPriceRole) - return price->highPrice(); - else if (role == StockModel::LowPriceRole) - return price->lowPrice(); - else if (role == StockModel::AdjustedPriceRole) - return price->adjustedPrice(); - else if (role == StockModel::VolumeRole) - return price->volume(); - else if (role == StockModel::SectionRole) - return price->date().year(); - return QVariant(); -} - -QString StockModel::stockName() const -{ - return _stockName; -} -void StockModel::setStockName(const QString& name) -{ - if (_stockName != name) { - _stockName = name; - emit stockNameChanged(); - } -} - -QDate StockModel::startDate() const -{ - return _startDate; -} -void StockModel::setStartDate(const QDate& date) -{ - if (_startDate.isValid() && _startDate != date) { - _startDate = date; - emit startDateChanged(); - } -} - -QDate StockModel::endDate() const -{ - return _endDate; -} -void StockModel::setEndDate(const QDate& date) -{ - if (_endDate.isValid() && _endDate != date) { - _endDate = date; - emit endDateChanged(); - } -} - -StockModel::StockDataCycle StockModel::dataCycle() const -{ - return _dataCycle; -} - -QString StockModel::dataCycleString() const -{ - switch (_dataCycle) { - case StockModel::Daily: - return QString('d'); - break; - case StockModel::Weekly: - return QString('w'); - case StockModel::Monthly: - return QString('m'); - case StockModel::Dividend: - return QString('v'); - } - - return QString('d'); -} - - -void StockModel::setDataCycle(StockModel::StockDataCycle cycle) -{ - if (_dataCycle != cycle) { - _dataCycle = cycle; - emit dataCycleChanged(); - } -} diff --git a/examples/declarative/canvas/stockchart/model.h b/examples/declarative/canvas/stockchart/model.h deleted file mode 100644 index 95e6f4891c..0000000000 --- a/examples/declarative/canvas/stockchart/model.h +++ /dev/null @@ -1,166 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include -#include - -class StockPrice : public QObject -{ - Q_OBJECT - Q_PROPERTY(QDate date READ date) - Q_PROPERTY(qreal openPrice READ openPrice) - Q_PROPERTY(qreal closePrice READ closePrice) - Q_PROPERTY(qreal highPrice READ highPrice) - Q_PROPERTY(qreal lowPrice READ lowPrice) - Q_PROPERTY(qint32 volume READ volume) - Q_PROPERTY(qreal adjustedPrice READ adjustedPrice) -public: - - StockPrice(QObject *parent = 0) - : QObject(parent) - , _openPrice(-1) - , _closePrice(-1) - , _highPrice(-1) - , _lowPrice(-1) - , _volume(-1) - , _adjustedPrice(-1) - { - } - QDate date() const {return _date;} - qreal openPrice() const {return _openPrice; } - qreal closePrice() const {return _closePrice;} - qreal highPrice() const {return _highPrice;} - qreal lowPrice() const{return _lowPrice;} - qreal adjustedPrice() const{return _adjustedPrice;} - qint32 volume() const{return _volume;} - - void setDate(const QDate& date){_date = date;} - void setOpenPrice(qreal price){_openPrice = price;} - void setClosePrice(qreal price){_closePrice = price;} - void setHighPrice(qreal price){_highPrice = price;} - void setLowPrice(qreal price){_lowPrice = price;} - void setAdjustedPrice(qreal price) {_adjustedPrice = price;} - void setVolume(qint32 volume) {_volume = volume;} - -private: - QDate _date; - qreal _openPrice; - qreal _closePrice; - qreal _highPrice; - qreal _lowPrice; - qint32 _volume; - qreal _adjustedPrice; -}; - -class QNetworkReply; -class QNetworkAccessManager; -class StockModel : public QAbstractListModel -{ - Q_OBJECT - - Q_PROPERTY(QString stockName READ stockName WRITE setStockName NOTIFY stockNameChanged) - Q_PROPERTY(QDate startDate READ startDate WRITE setStartDate NOTIFY startDateChanged) - Q_PROPERTY(QDate endDate READ endDate WRITE setEndDate NOTIFY endDateChanged) - Q_PROPERTY(StockDataCycle dataCycle READ dataCycle WRITE setDataCycle NOTIFY dataCycleChanged) - - Q_ENUMS(StockDataCycle) -public: - enum StockDataCycle { - Daily, - Weekly, - Monthly, - Dividend - }; - - enum StockModelRoles { - DateRole = Qt::UserRole + 1, - SectionRole, - OpenPriceRole, - ClosePriceRole, - HighPriceRole, - LowPriceRole, - VolumeRole, - AdjustedPriceRole - }; - - StockModel(QObject *parent = 0); - - QString stockName() const; - void setStockName(const QString& name); - - QDate startDate() const; - void setStartDate(const QDate& date); - - QDate endDate() const; - void setEndDate(const QDate& date); - - StockDataCycle dataCycle() const; - void setDataCycle(StockDataCycle cycle); - - int rowCount(const QModelIndex & parent = QModelIndex()) const; - - QVariant data(const QModelIndex & index, int role = Qt::DisplayRole) const; - -signals: - void stockNameChanged(); - void startDateChanged(); - void endDateChanged(); - void dataCycleChanged(); - void downloadProgress(qint64 bytesReceived, qint64 bytesTotal); - -public slots: - void requestData(); - StockPrice* stockPriceAtIndex(int idx) const; -private slots: - void doRequest(); - void update(QNetworkReply* reply); -private: - QString dataCycleString() const; - QList _prices; - QString _stockName; - QDate _startDate; - QDate _endDate; - StockDataCycle _dataCycle; - QNetworkAccessManager* _manager; - bool _updating; -}; - - - - diff --git a/examples/declarative/canvas/stockchart/plugin.cpp b/examples/declarative/canvas/stockchart/plugin.cpp deleted file mode 100644 index af64af4da8..0000000000 --- a/examples/declarative/canvas/stockchart/plugin.cpp +++ /dev/null @@ -1,60 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include -#include -#include -#include "model.h" - -class QStockChartExampleQmlPlugin : public QDeclarativeExtensionPlugin -{ - Q_OBJECT -public: - void registerTypes(const char *uri) - { - Q_ASSERT(uri == QLatin1String("com.nokia.StockChartExample")); - qmlRegisterType(uri, 1, 0, "StockModel"); - qmlRegisterType(uri, 1, 0, "StockPrice"); - } -}; - -#include "plugin.moc" - -Q_EXPORT_PLUGIN2(qmlstockchartexampleplugin, QStockChartExampleQmlPlugin); diff --git a/examples/declarative/canvas/stockchart/stock.qml b/examples/declarative/canvas/stockchart/stock.qml deleted file mode 100644 index 1c95fde2ce..0000000000 --- a/examples/declarative/canvas/stockchart/stock.qml +++ /dev/null @@ -1,726 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -import QtQuick 2.0 -import com.nokia.StockChartExample 1.0 -import "../contents" - -Rectangle { - id:container - width: 360; height: 600 - color: "#343434"; - Image { source: "contents/images/stripes.png"; fillMode: Image.Tile; anchors.fill: parent; opacity: 1 } - - - TitleBar { - id: titleBar - width: parent.width - anchors.top : container.top - height: 40 - opacity: 0.9 - } - - StockModel { - id:stockModel - dataCycle: StockModel.Daily - function dataCycleName() { - if (dataCycle === StockModel.Weekly) - return "Weekly"; - else if (dataCycle === StockModel.Monthly) - return "Monthly"; - return "Daily"; - } - - onDataChanged: { - if (view.viewType == "chart") { - canvas.requestPaint(); - } - } - onDownloadProgress: { - if (bytesReceived == bytesTotal && bytesTotal != -1) { - progress.opacity = 0; - } else { - progress.opacity = 0.8; - progress.text = "downloading " + stockModel.dataCycleName() + " data ..."+ Math.round(bytesReceived/1000) + " KB"; - } - } - - property string description:""; - } - - Stocks {id:stocks} - - Rectangle { - id: header - width: parent.width - height: 20 - color: "steelblue" - opacity: 0 - Row { - spacing: 2 - Text { - id:t - font.pointSize:15 - horizontalAlignment:Text.AlignHCenter - font.bold: true - font.underline:true - } - Rectangle { - height:20 - width:50 - Text {text:"Stock list"; font.pointSize:15; font.bold: true} - } - } - } - - ListView { - id:stockList - width: parent.width - anchors.bottom: container.bottom - anchors.top : titleBar.bottom - focus: true - keyNavigationWraps: true - spacing:1 - opacity: 1 - model: stocks - - Component.onCompleted: opacity = 0.9; - onOpacityChanged: { - titleBar.title = "Top 100 NASDAQ stocks" - } - - - delegate : Rectangle { - height: 30 - width: view.width - color: { - if (ListView.isCurrentItem) - return focus ? "lightyellow" : "pink"; - return index % 2 == 0 ? "lightblue" : "lightsteelblue" - } - Text { - font.pointSize:20 - text: index + ". " + stockId + " \t(" + name + ")"; - } - MouseArea { - anchors.fill: parent; - onDoubleClicked: { - stockList.opacity = 0; - stockModel.stockName = stockId; - stockModel.description = "NASDAQ:" + stockId + " (" + name + ")"; - view.opacity = 1; - view.viewType = "chart"; - canvas.opacity = 0.7; - } - onClicked: stockList.currentIndex = index - }//mousearea - }//delegate - } - - ListView { - id:view - width: container.width - height: container.height - 50 - anchors.bottom: container.bottom - focus: true - keyNavigationWraps: true - - spacing:1 - opacity: 0 - model: stockModel - highlightFollowsCurrentItem: false - highlightRangeMode: ListView.StrictlyEnforceRange - preferredHighlightBegin:50 - preferredHighlightEnd : height - 50 - highlight: listHighlight - - //header : Text {} - delegate: listDelegate - snapMode: ListView.SnapToItem - - property string viewType : "list" - property int topIndex:indexAt(0,contentY); - property int bottomIndex:indexAt(0, contentY+height); - - onCountChanged: { - - titleBar.title = stockModel.description + " " + Qt.formatDate(stockModel.startDate, "yyyy-MM-dd") + " - " + - Qt.formatDate(stockModel.endDate, "yyyy-MM-dd") + " " + stockModel.dataCycleName() + - " records:" + view.count; - - } - - Component { - id: listDelegate - Rectangle { - height: 20 - width: view.width - border.color: "lightsteelblue" - border.width: 1 - color: { - if (ListView.isCurrentItem) - return focus ? "lightyellow" : "pink"; - - return index % 2 == 0 ? "lightblue" : "lightsteelblue" - } - Text { - font.pointSize:13 - text: index + ". " + Qt.formatDate(date, "yyyy-MM-dd") - + "\t " + Math.round(openPrice*100)/100 - + "\t " + Math.round(highPrice*100)/100 - + "\t " + Math.round(lowPrice*100)/100 - + "\t " + Math.round(closePrice*100)/100 - + "\t " + volume + "\t " - + Math.round(adjustedPrice*100)/100; - } - MouseArea {anchors.fill: parent; onClicked: view.currentIndex = index} - } - } - - Component { - id: chartDelegate - Rectangle { - height: 20 - width: view.width/view.count * canvas.scaleX - border.color: "lightsteelblue" - border.width: 1 - color: { - if (ListView.isCurrentItem) - return focus ? "lightyellow" : "pink"; - - return index % 2 == 0 ? "lightblue" : "lightsteelblue" - } - - Text { - anchors.bottom: parent.bottom - font.pointSize: { - if (parent.width <= 4) - return 1; - if (parent.width <= 50) - return parent.width/4; - return 15; - } - horizontalAlignment:Text.AlignHCenter - verticalAlignment:Text.AlignBottom - text:font.pointSize > 1 ? Qt.formatDate(date, "d/M/yy") : "" - } - MouseArea {anchors.fill: parent; onClicked: view.currentIndex = index} - } - } - - Component { - id:chartHighlight - Rectangle { radius: 5; width:40; height: 20; color: "lightsteelblue" } - } - - Component { - id:listHighlight - Rectangle { radius: 5; width:container.width; height: 20; color: "lightsteelblue" } - } - - - - - onViewTypeChanged : { - if (viewType == "list") { - view.orientation = ListView.Vertical; - view.delegate = listDelegate; -// view.section.property = "year"; -// view.section.criteria = ViewSection.FullString; -// view.section.delegate = sectionHeading; - view.highlight = listHighlight; - view.opacity = 1; - canvas.opacity = 0; - // comment.opacity = 0; - - } else if (viewType == "chart") { - view.orientation = ListView.Horizontal; - view.delegate = chartDelegate; - //comment.opacity = 0.6; - - view.opacity = 1; - view.height = 30 - - canvas.opacity = 0.7; - canvas.requestPaint(); - } else { - viewType = "list"; - } - } - - - onCurrentIndexChanged: { - //header.updateCurrent(stockModel.stockPriceAtIndex(view.currentIndex)); - if (viewType == "chart") { - canvas.first = Math.round(view.currentIndex - view.currentIndex / canvas.scaleX); - canvas.last = Math.round(view.currentIndex + (view.count - view.currentIndex) / canvas.scaleX); - - canvas.requestPaint(); - } - } - onContentYChanged: { // keep "current" item visible - topIndex = indexAt(0,contentY); - bottomIndex = indexAt(0, contentY+height); - - if (topIndex != -1 && currentIndex <= topIndex) - currentIndex = topIndex+1; - else if (bottomIndex != -1 && currentIndex >= bottomIndex) - currentIndex = bottomIndex-1; - if (viewType == "chart") - canvas.requestPaint(); - } - - onContentXChanged: { // keep "current" item visible - topIndex = indexAt(contentX,0); - bottomIndex = indexAt(contentX+width, 0); - - if (topIndex != -1 && currentIndex <= topIndex) - currentIndex = topIndex+1; - else if (bottomIndex != -1 && currentIndex >= bottomIndex) - currentIndex = bottomIndex-1; - if (viewType == "chart") - canvas.requestPaint(); - } - - MouseArea { - anchors.fill: parent - onDoubleClicked: { - if (view.viewType == "list") - view.viewType = "chart"; - else - view.viewType = "list"; - } - } - } - - - - Canvas { - id:canvas - anchors.top : titleBar.bottom - anchors.bottom : view.top - width:container.width; - opacity:0 - renderTarget: Canvas.Image - renderStrategy: Canvas.Immediate - property bool running:false - property int frames:first - property int mouseX:0; - property int mouseY:0; - property int mousePressedX:0; - property int mousePressedY:0; - property int movedY:0 - property real scaleX:1.0; - property real scaleY:1.0; - property int first:0; - property int last:view.count - 1; - - onOpacityChanged: { - if (opacity > 0) - requestPaint(); - } - Text { - id:comment - x:100 - y:50 - font.pointSize: 20 - color:"white" - opacity: 0.7 - focus:false - text: stockModel.description - function updateCurrent(price) - { - if (price !== undefined) { - text =stockModel.description + "\n" - + Qt.formatDate(price.date, "yyyy-MM-dd") + " OPEN:" - + Math.round(price.openPrice*100)/100 + " HIGH:" - + Math.round(price.highPrice*100)/100 + " LOW:" - + Math.round(price.lowPrice*100)/100 + " CLOSE:" - + Math.round(price.closePrice*100)/100 + " VOLUME:" - + price.volume; - } - } - } - - Text { - id:priceAxis - x:25 - y:25 - font.pointSize: 15 - color:"yellow" - opacity: 0.7 - focus: false - } - Text { - id:volumeAxis - x:canvas.width - 200 - y:25 - font.pointSize: 15 - color:"yellow" - opacity: 0.7 - } - - Rectangle { - id:progress - x:canvas.width/2 - 100 - y:canvas.height/2 - width:childrenRect.width - height: childrenRect.height - opacity: 0 - color:"white" - property string text; - Text { - text:parent.text - font.pointSize: 20 - } - } - - Button { - id:runButton - text:"Run this chart" - y:0 - x:canvas.width/2 - 50 - opacity: 0.5 - onClicked: { - if (canvas.running) { - canvas.running = false; - canvas.frames = canvas.first; - canvas.requestPaint(); - text = "Run this chart"; - comment.text = stockModel.description; - } else { - text = " Stop running "; - canvas.runChart(); - } - } - } - Button { - id:returnButton - text:"Stocks" - y:0 - anchors.left : runButton.right - anchors.leftMargin : 20 - opacity: 0.5 - onClicked: { - stockList.opacity = 1; - canvas.opacity = 0; - } - } - PinchArea { - anchors.fill: parent - onPinchUpdated : { - var current = pinch.center; - var scale = pinch.scale; - console.log("center:" + pinch.center + " scale:" + pinch.scale); - //canvas.requestPaint(); - } - } - - MouseArea { - anchors.fill: parent - - onDoubleClicked: { - if (stockModel.dataCycle == StockModel.Daily) - stockModel.dataCycle = StockModel.Weekly; - else if (stockModel.dataCycle == StockModel.Weekly) - stockModel.dataCycle = StockModel.Monthly; - else - stockModel.dataCycle = StockModel.Daily; - } - - onPositionChanged: { - if (mouse.modifiers & Qt.ControlModifier) { - if (canvas.mouseX == 0 && canvas.mouseY == 0) { - canvas.mouseX = mouse.x; - canvas.mouseY = mouse.y; - } - } else{ - var w = (view.width/view.count)*canvas.scaleX; - - //canvas.movedY += Math.round((canvas.mousePressedY - mouse.y)/2); - - var movedX = Math.round((canvas.mousePressedX - mouse.x)/w); - if (movedX != 0 || canvas.movedY != 0) { - if (canvas.first + movedX >= 0 && canvas.last + movedX < view.count) { - canvas.first += movedX; - canvas.last += movedX; - } - canvas.requestPaint(); - } - } - } - - onPressed: { - canvas.mousePressedX = mouse.x; - canvas.mousePressedY = mouse.y; - } - - onReleased : { - if (mouse.modifiers & Qt.ControlModifier) { - var sx = mouse.x - canvas.mouseX; - var sy = canvas.mouseY - mouse.y; - - if (Math.abs(sx) < 50) sx = 0; - if (Math.abs(sy) < 50) sy = 0; - - if (sx > 0) - canvas.scaleX *= sx/100 +1; - else - canvas.scaleX *= 1/(-sx/100 + 1); - - if (sy > 0) - canvas.scaleY *= sy/100 +1; - else - canvas.scaleY *= 1/(-sy/100 + 1); - - if (canvas.scaleX < 1) - canvas.scaleX = 1; - - //console.log("scaleX:" + canvas.scaleX + ", scaleY:" + canvas.scaleY); - - canvas.first = Math.round(view.currentIndex - view.currentIndex / canvas.scaleX); - canvas.last = Math.round(view.currentIndex + (view.count - view.currentIndex) / canvas.scaleX); - - canvas.mouseX = 0; - canvas.mouseY = 0; - canvas.mousePressedX = 0; - canvas.mousePressedY = 0; - canvas.requestPaint(); - } - } - } - - function runChart() { - canvas.running = true; - requestPaint(); - } - - function showPriceAt(x) { - var w = (view.width/view.count)*canvas.scaleX; - //header.updateCurrent(stockModel.stockPriceAtIndex(canvas.first + Math.round(x/w))); - //console.log("x:" + x + " w:" + w + " index:" + (canvas.first + Math.round(x/w))); - } - - function drawPrice(ctx, from, to, color, price, points, highest) - { - ctx.globalAlpha = 0.7; - ctx.strokeStyle = color; - ctx.lineWidth = 1; - ctx.beginPath(); - - //price x axis - priceAxis.text = "price:" + Math.round(highest); - ctx.font = "bold 12px sans-serif"; - - ctx.strokeText("price", 25, 25); - for (var j = 1; j < 30; j++) { - var val = (highest * j) / 30; - val = canvas.height * (1 - val/highest); - ctx.beginPath(); - - ctx.moveTo(10, val); - if (j % 5) - ctx.lineTo(15, val); - else - ctx.lineTo(20, val); - ctx.stroke(); - } - - ctx.beginPath(); - ctx.moveTo(10, 0); - ctx.lineTo(10, canvas.height); - ctx.stroke(); - - - var w = canvas.width/points.length; - var end = canvas.running? canvas.frames - canvas.first :points.length; - for (var i = 0; i < end; i++) { - var x = points[i].x; - var y = points[i][price]; - y += canvas.movedY; - - y = canvas.height * (1 - y/highest); - if (i == 0) { - ctx.moveTo(x+w/2, y); - } else { - ctx.lineTo(x+w/2, y); - } - } - ctx.stroke(); - } - - function drawKLine(ctx, from, to, points, highest) - { - ctx.globalAlpha = 0.4; - ctx.lineWidth = 2; - var end = canvas.running? canvas.frames - canvas.first :points.length; - for (var i = 0; i < end; i++) { - var x = points[i].x; - var open = canvas.height * (1 - points[i].open/highest) - canvas.movedY; - var close = canvas.height * (1 - points[i].close/highest) - canvas.movedY; - var high = canvas.height * (1 - points[i].high/highest) - canvas.movedY; - var low = canvas.height * (1 - points[i].low/highest) - canvas.movedY; - - var top, bottom; - if (close <= open) { - ctx.fillStyle = Qt.rgba(1, 0, 0, 1); - ctx.strokeStyle = Qt.rgba(1, 0, 0, 1); - top = close; - bottom = open; - } else { - ctx.fillStyle = Qt.rgba(0, 1, 0, 1); - ctx.strokeStyle = Qt.rgba(0, 1, 0, 1); - top = open; - bottom = close; - } - - var w1, w2; - w1 = canvas.width/points.length; - w2 = w1 > 10 ? w1/2 : w1; - - ctx.fillRect(x + (w1 - w2)/2, top, w2, bottom - top); - ctx.beginPath(); - ctx.moveTo(x+w1/2, high); - ctx.lineTo(x+w1/2, low); - ctx.stroke(); - } - ctx.globalAlpha = 1; - - } - - function drawVolume(ctx, from, to, color, price, points, highest) - { - ctx.fillStyle = color; - ctx.globalAlpha = 0.6; - ctx.strokeStyle = Qt.rgba(0.8, 0.8, 0.8, 1); - ctx.lineWidth = 1; - - //volume x axis - volumeAxis.text = "volume:" + Math.round(highest/(1000*100)) + "M"; - for (var j = 1; j < 30; j++) { - var val = (highest * j) / 30; - val = canvas.height * (1 - val/highest); - ctx.beginPath(); - if (j % 5) - ctx.moveTo(canvas.width - 15, val); - else - ctx.moveTo(canvas.width - 20, val); - ctx.lineTo(canvas.width - 10, val); - ctx.stroke(); - } - - ctx.beginPath(); - ctx.moveTo(canvas.width - 10, 0); - ctx.lineTo(canvas.width - 10, canvas.height); - ctx.stroke(); - - var end = canvas.running? canvas.frames - canvas.first :points.length; - for (var i = 0; i < end; i++) { - var x = points[i].x; - var y = points[i][price]; - y = canvas.height * (1 - y/highest); - ctx.fillRect(x, y, canvas.width/points.length, canvas.height - y); - } - } -/* - onPainted : { - if (canvas.running) { - if (frames >= last) { - canvas.running = false; - canvas.frames = first; - runButton.text = "Run this chart"; - comment.text = stockModel.description; - requestPaint(); - } else { - frames += Math.round(view.count / 100); - if (frames > last) frames = last; - var price = stockModel.stockPriceAtIndex(frames); - if (price) { - comment.updateCurrent(price); - } - - requestPaint(); - } - } - } -*/ - onPaint: { - if (view.currentIndex <= 0) - first = 0; - if (last >= view.count) - last = view.count - 1; - - //console.log("painting... first:" + first + ", last:" + last + " current:" + view.currentIndex); - var ctx = canvas.getContext("2d"); - ctx.save(); - - ctx.globalCompositeOperation = "source-over"; - ctx.lineWidth = 1; - ctx.lineJoin = "round"; - ctx.fillStyle = "rgba(0,0,0,0)"; - - ctx.fillRect(0, 0, canvas.width, canvas.height); - - - - var highestPrice = 500/canvas.scaleY; - var highestValume = 600 * 1000 * 1000/canvas.scaleY; - var points = []; - for (var i = 0; i <= last - first; i++) { - var price = stockModel.stockPriceAtIndex(i + first); - points.push({ - x: i*canvas.width/(last-first+1), - open: price.openPrice, - close: price.closePrice, - high:price.highPrice, - low:price.lowPrice, - volume:price.volume - }); - } - - drawPrice(ctx, first, last, Qt.rgba(1, 0, 0, 1),"high", points, highestPrice); - drawPrice(ctx, first, last, Qt.rgba(0, 1, 0, 1),"low", points, highestPrice); - drawPrice(ctx, first, last, Qt.rgba(0, 0, 1, 1),"open", points, highestPrice); - drawPrice(ctx, first, last, Qt.rgba(0.5, 0.5, 0.5, 1),"close", points, highestPrice); - drawVolume(ctx, first, last, Qt.rgba(0.3, 0.5, 0.7, 1),"volume", points, highestValume); - drawKLine(ctx, first, last, points, highestPrice); - ctx.restore(); - } - } -} diff --git a/examples/declarative/canvas/stockchart/stockchart.pro b/examples/declarative/canvas/stockchart/stockchart.pro deleted file mode 100644 index 4006b5dccf..0000000000 --- a/examples/declarative/canvas/stockchart/stockchart.pro +++ /dev/null @@ -1,20 +0,0 @@ -TEMPLATE = lib -CONFIG += qt plugin -QT += declarative network - -DESTDIR = com/nokia/StockChartExample -TARGET = qmlstockchartexampleplugin - -SOURCES += model.cpp plugin.cpp -HEADERS += model.h -qdeclarativesources.files += \ - com/nokia/StockChartExample/qmldir \ - stock.qml - -qdeclarativesources.path += $$[QT_INSTALL_EXAMPLES]/qtdeclarative/declarative/plugins/com/nokia/StockChartExample - -sources.files += stockchart.pro model.h model.cpp plugin.cpp README -sources.path += $$[QT_INSTALL_EXAMPLES]/qtdeclarative/declarative/plugins -target.path += $$[QT_INSTALL_EXAMPLES]/qtdeclarative/declarative/plugins/com/nokia/StockChartExample - -INSTALLS += qdeclarativesources sources target diff --git a/examples/declarative/canvas/tiger/tiger.js b/examples/declarative/canvas/tiger/tiger.js deleted file mode 100644 index 4be0d26c9d..0000000000 --- a/examples/declarative/canvas/tiger/tiger.js +++ /dev/null @@ -1,721 +0,0 @@ -var tiger = [ - {"fill": "#ffffff", "stroke":"#000000", "width":0.172, - "path":"M-122.304 84.285C-122.304 84.285 -122.203 86.179 -123.027 86.16C-123.851 86.141 -140.305 38.066 -160.833 40.309C-160.833 40.309 -143.05 32.956 -122.304 84.285z"} - , - {"fill": "#ffffff", "stroke":"#000000", "width":0.172, - "path":"M-118.774 81.262C-118.774 81.262 -119.323 83.078 -120.092 82.779C-120.86 82.481 -119.977 31.675 -140.043 26.801C-140.043 26.801 -120.82 25.937 -118.774 81.262z"} - , - {"fill": "#ffffff", "stroke":"#000000", "width":0.172, - "path":"M-91.284 123.59C-91.284 123.59 -89.648 124.55 -90.118 125.227C-90.589 125.904 -139.763 113.102 -149.218 131.459C-149.218 131.459 -145.539 112.572 -91.284 123.59z"} - , - {"fill": "#ffffff", "stroke":"#000000", "width":0.172, - "path":"M-94.093 133.801C-94.093 133.801 -92.237 134.197 -92.471 134.988C-92.704 135.779 -143.407 139.121 -146.597 159.522C-146.597 159.522 -149.055 140.437 -94.093 133.801z"} - , - {"fill": "#ffffff", "stroke":"#000000", "width":0.172, - "path":"M-98.304 128.276C-98.304 128.276 -96.526 128.939 -96.872 129.687C-97.218 130.435 -147.866 126.346 -153.998 146.064C-153.998 146.064 -153.646 126.825 -98.304 128.276z"} - , - {"fill": "#ffffff", "stroke":"#000000", "width":0.172, - "path":"M-109.009 110.072C-109.009 110.072 -107.701 111.446 -108.34 111.967C-108.979 112.488 -152.722 86.634 -166.869 101.676C-166.869 101.676 -158.128 84.533 -109.009 110.072z"} - , - {"fill": "#ffffff", "stroke":"#000000", "width":0.172, - "path":"M-116.554 114.263C-116.554 114.263 -115.098 115.48 -115.674 116.071C-116.25 116.661 -162.638 95.922 -174.992 112.469C-174.992 112.469 -168.247 94.447 -116.554 114.263z"} - , - {"fill": "#ffffff", "stroke":"#000000", "width":0.172, - "path":"M-119.154 118.335C-119.154 118.335 -117.546 119.343 -118.036 120.006C-118.526 120.669 -167.308 106.446 -177.291 124.522C-177.291 124.522 -173.066 105.749 -119.154 118.335z"} - , - {"fill": "#ffffff", "stroke":"#000000", "width":0.172, - "path":"M-108.42 118.949C-108.42 118.949 -107.298 120.48 -107.999 120.915C-108.7 121.35 -148.769 90.102 -164.727 103.207C-164.727 103.207 -153.862 87.326 -108.42 118.949z"} - , - {"fill": "#ffffff", "stroke":"#000000", "width":0.172, - "path":"M-128.2 90C-128.2 90 -127.6 91.8 -128.4 92C-129.2 92.2 -157.8 50.2 -177.001 57.8C-177.001 57.8 -161.8 46 -128.2 90z"} - , - {"fill": "#ffffff", "stroke":"#000000", "width":0.172, - "path":"M-127.505 96.979C-127.505 96.979 -126.53 98.608 -127.269 98.975C-128.007 99.343 -164.992 64.499 -182.101 76.061C-182.101 76.061 -169.804 61.261 -127.505 96.979z"} - , - {"fill": "#ffffff", "stroke":"#000000", "width":0.172, - "path":"M-127.62 101.349C-127.62 101.349 -126.498 102.88 -127.199 103.315C-127.9 103.749 -167.969 72.502 -183.927 85.607C-183.927 85.607 -173.062 69.726 -127.62 101.349z"} - , - {"fill": "#ffffff", "stroke":"#000000", - "path":"M-129.83 103.065C-129.327 109.113 -128.339 115.682 -126.6 118.801C-126.6 118.801 -130.2 131.201 -121.4 144.401C-121.4 144.401 -121.8 151.601 -120.2 154.801C-120.2 154.801 -116.2 163.201 -111.4 164.001C-107.516 164.648 -98.793 167.717 -88.932 169.121C-88.932 169.121 -71.8 183.201 -75 196.001C-75 196.001 -75.4 212.401 -79 214.001C-79 214.001 -67.4 202.801 -77 219.601L-81.4 238.401C-81.4 238.401 -55.8 216.801 -71.4 235.201L-81.4 261.201C-81.4 261.201 -61.8 242.801 -69 251.201L-72.2 260.001C-72.2 260.001 -29 232.801 -59.8 262.401C-59.8 262.401 -51.8 258.801 -47.4 261.601C-47.4 261.601 -40.6 260.401 -41.4 262.001C-41.4 262.001 -62.2 272.401 -65.8 290.801C-65.8 290.801 -57.4 280.801 -60.6 291.601L-60.2 303.201C-60.2 303.201 -56.2 281.601 -56.6 319.201C-56.6 319.201 -37.4 301.201 -49 322.001L-49 338.801C-49 338.801 -33.8 322.401 -40.2 335.201C-40.2 335.201 -30.2 326.401 -34.2 341.601C-34.2 341.601 -35 352.001 -30.6 340.801C-30.6 340.801 -14.6 310.201 -20.6 336.401C-20.6 336.401 -21.4 355.601 -16.6 340.801C-16.6 340.801 -16.2 351.201 -7 358.401C-7 358.401 -8.2 307.601 4.6 343.601L8.6 360.001C8.6 360.001 11.4 350.801 11 345.601C11 345.601 25.8 329.201 19 353.601C19 353.601 34.2 330.801 31 344.001C31 344.001 23.4 360.001 25 364.801C25 364.801 41.8 330.001 43 328.401C43 328.401 41 370.802 51.8 334.801C51.8 334.801 57.4 346.801 54.6 351.201C54.6 351.201 62.6 343.201 61.8 340.001C61.8 340.001 66.4 331.801 69.2 345.401C69.2 345.401 71 354.801 72.6 351.601C72.6 351.601 76.6 375.602 77.8 352.801C77.8 352.801 79.4 339.201 72.2 327.601C72.2 327.601 73 324.401 70.2 320.401C70.2 320.401 83.8 342.001 76.6 313.201C76.6 313.201 87.801 321.201 89.001 321.201C89.001 321.201 75.4 298.001 84.2 302.801C84.2 302.801 79 292.401 97.001 304.401C97.001 304.401 81 288.401 98.601 298.001C98.601 298.001 106.601 304.401 99.001 294.401C99.001 294.401 84.6 278.401 106.601 296.401C106.601 296.401 118.201 312.801 119.001 315.601C119.001 315.601 109.001 286.401 104.601 283.601C104.601 283.601 113.001 247.201 154.201 262.801C154.201 262.801 161.001 280.001 165.401 261.601C165.401 261.601 178.201 255.201 189.401 282.801C189.401 282.801 193.401 269.201 192.601 266.401C192.601 266.401 199.401 267.601 198.601 266.401C198.601 266.401 211.801 270.801 213.001 270.001C213.001 270.001 219.801 276.801 220.201 273.201C220.201 273.201 229.401 276.001 227.401 272.401C227.401 272.401 236.201 288.001 236.601 291.601L239.001 277.601L241.001 280.401C241.001 280.401 242.601 272.801 241.801 271.601C241.001 270.401 261.801 278.401 266.601 299.201L268.601 307.601C268.601 307.601 274.601 292.801 273.001 288.801C273.001 288.801 278.201 289.601 278.601 294.001C278.601 294.001 282.601 270.801 277.801 264.801C277.801 264.801 282.201 264.001 283.401 267.601L283.401 260.401C283.401 260.401 290.601 261.201 290.601 258.801C290.601 258.801 295.001 254.801 297.001 259.601C297.001 259.601 284.601 224.401 303.001 243.601C303.001 243.601 310.201 254.401 306.601 235.601C303.001 216.801 299.001 215.201 303.801 214.801C303.801 214.801 304.601 211.201 302.601 209.601C300.601 208.001 303.801 209.601 303.801 209.601C303.801 209.601 308.601 213.601 303.401 191.601C303.401 191.601 309.801 193.201 297.801 164.001C297.801 164.001 300.601 161.601 296.601 153.201C296.601 153.201 304.601 157.601 307.401 156.001C307.401 156.001 307.001 154.401 303.801 150.401C303.801 150.401 282.201 95.6 302.601 117.601C302.601 117.601 314.451 131.151 308.051 108.351C308.051 108.351 298.94 84.341 299.717 80.045L-129.83 103.065z"} - , - {"fill": "#cc7226", "stroke":"#000000", - "path":"M299.717 80.245C300.345 80.426 302.551 81.55 303.801 83.2C303.801 83.2 310.601 94 305.401 75.6C305.401 75.6 296.201 46.8 305.001 58C305.001 58 311.001 65.2 307.801 51.6C303.936 35.173 301.401 28.8 301.401 28.8C301.401 28.8 313.001 33.6 286.201 -6L295.001 -2.4C295.001 -2.4 275.401 -42 253.801 -47.2L245.801 -53.2C245.801 -53.2 284.201 -91.2 271.401 -128C271.401 -128 264.601 -133.2 255.001 -124C255.001 -124 248.601 -119.2 242.601 -120.8C242.601 -120.8 211.801 -119.6 209.801 -119.6C207.801 -119.6 173.001 -156.8 107.401 -139.2C107.401 -139.2 102.201 -137.2 97.801 -138.4C97.801 -138.4 79.4 -154.4 30.6 -131.6C30.6 -131.6 20.6 -129.6 19 -129.6C17.4 -129.6 14.6 -129.6 6.6 -123.2C-1.4 -116.8 -1.8 -116 -3.8 -114.4C-3.8 -114.4 -20.2 -103.2 -25 -102.4C-25 -102.4 -36.6 -96 -41 -86L-44.6 -84.8C-44.6 -84.8 -46.2 -77.6 -46.6 -76.4C-46.6 -76.4 -51.4 -72.8 -52.2 -67.2C-52.2 -67.2 -61 -61.2 -60.6 -56.8C-60.6 -56.8 -62.2 -51.6 -63 -46.8C-63 -46.8 -70.2 -42 -69.4 -39.2C-69.4 -39.2 -77 -25.2 -75.8 -18.4C-75.8 -18.4 -82.2 -18.8 -85 -16.4C-85 -16.4 -85.8 -11.6 -87.4 -11.2C-87.4 -11.2 -90.2 -10 -87.8 -6C-87.8 -6 -89.4 -3.2 -89.8 -1.6C-89.8 -1.6 -89 1.2 -93.4 6.8C-93.4 6.8 -99.8 25.6 -97.8 30.8C-97.8 30.8 -97.4 35.6 -100.2 37.2C-100.2 37.2 -103.8 36.8 -95.4 48.8C-95.4 48.8 -94.6 50 -97.8 52.4C-97.8 52.4 -115 56 -117.4 72.4C-117.4 72.4 -131 87.2 -131 92.4C-131 94.705 -130.729 97.852 -130.03 102.465C-130.03 102.465 -130.6 110.801 -103 111.601C-75.4 112.401 299.717 80.245 299.717 80.245z"} - , - {"fill": "#cc7226", - "path":"M-115.6 102.6C-140.6 63.2 -126.2 119.601 -126.2 119.601C-117.4 154.001 12.2 116.401 12.2 116.401C12.2 116.401 181.001 86 192.201 82C203.401 78 298.601 84.4 298.601 84.4L293.001 67.6C228.201 21.2 209.001 44.4 195.401 40.4C181.801 36.4 184.201 46 181.001 46.8C177.801 47.6 138.601 22.8 132.201 23.6C125.801 24.4 100.459 0.649 115.401 32.4C131.401 66.4 57 71.6 40.2 60.4C23.4 49.2 47.4 78.8 47.4 78.8C65.8 98.8 31.4 82 31.4 82C-3 69.2 -27 94.8 -30.2 95.6C-33.4 96.4 -38.2 99.6 -39 93.2C-39.8 86.8 -47.31 70.099 -79 96.4C-99 113.001 -112.8 91 -112.8 91L-115.6 102.6z"} - , - {"fill": "#e87f3a", - "path":"M133.51 25.346C127.11 26.146 101.743 2.407 116.71 34.146C133.31 69.346 58.31 73.346 41.51 62.146C24.709 50.946 48.71 80.546 48.71 80.546C67.11 100.546 32.709 83.746 32.709 83.746C-1.691 70.946 -25.691 96.546 -28.891 97.346C-32.091 98.146 -36.891 101.346 -37.691 94.946C-38.491 88.546 -45.87 72.012 -77.691 98.146C-98.927 115.492 -112.418 94.037 -112.418 94.037L-115.618 104.146C-140.618 64.346 -125.546 122.655 -125.546 122.655C-116.745 157.056 13.509 118.146 13.509 118.146C13.509 118.146 182.31 87.746 193.51 83.746C204.71 79.746 299.038 86.073 299.038 86.073L293.51 68.764C228.71 22.364 210.31 46.146 196.71 42.146C183.11 38.146 185.51 47.746 182.31 48.546C179.11 49.346 139.91 24.546 133.51 25.346z"} - , - {"fill": "#ea8c4d", - "path":"M134.819 27.091C128.419 27.891 103.685 3.862 118.019 35.891C134.219 72.092 59.619 75.092 42.819 63.892C26.019 52.692 50.019 82.292 50.019 82.292C68.419 102.292 34.019 85.492 34.019 85.492C-0.381 72.692 -24.382 98.292 -27.582 99.092C-30.782 99.892 -35.582 103.092 -36.382 96.692C-37.182 90.292 -44.43 73.925 -76.382 99.892C-98.855 117.983 -112.036 97.074 -112.036 97.074L-115.636 105.692C-139.436 66.692 -124.891 125.71 -124.891 125.71C-116.091 160.11 14.819 119.892 14.819 119.892C14.819 119.892 183.619 89.492 194.819 85.492C206.019 81.492 299.474 87.746 299.474 87.746L294.02 69.928C229.219 23.528 211.619 47.891 198.019 43.891C184.419 39.891 186.819 49.491 183.619 50.292C180.419 51.092 141.219 26.291 134.819 27.091z"} - , - {"fill": "#ec9961", - "path":"M136.128 28.837C129.728 29.637 104.999 5.605 119.328 37.637C136.128 75.193 60.394 76.482 44.128 65.637C27.328 54.437 51.328 84.037 51.328 84.037C69.728 104.037 35.328 87.237 35.328 87.237C0.928 74.437 -23.072 100.037 -26.272 100.837C-29.472 101.637 -34.272 104.837 -35.072 98.437C-35.872 92.037 -42.989 75.839 -75.073 101.637C-98.782 120.474 -111.655 100.11 -111.655 100.11L-115.655 107.237C-137.455 70.437 -124.236 128.765 -124.236 128.765C-115.436 163.165 16.128 121.637 16.128 121.637C16.128 121.637 184.928 91.237 196.129 87.237C207.329 83.237 299.911 89.419 299.911 89.419L294.529 71.092C229.729 24.691 212.929 49.637 199.329 45.637C185.728 41.637 188.128 51.237 184.928 52.037C181.728 52.837 142.528 28.037 136.128 28.837z"} - , - {"fill": "#eea575", - "path":"M137.438 30.583C131.037 31.383 106.814 7.129 120.637 39.383C137.438 78.583 62.237 78.583 45.437 67.383C28.637 56.183 52.637 85.783 52.637 85.783C71.037 105.783 36.637 88.983 36.637 88.983C2.237 76.183 -21.763 101.783 -24.963 102.583C-28.163 103.383 -32.963 106.583 -33.763 100.183C-34.563 93.783 -41.548 77.752 -73.763 103.383C-98.709 122.965 -111.273 103.146 -111.273 103.146L-115.673 108.783C-135.473 73.982 -123.582 131.819 -123.582 131.819C-114.782 166.22 17.437 123.383 17.437 123.383C17.437 123.383 186.238 92.983 197.438 88.983C208.638 84.983 300.347 91.092 300.347 91.092L295.038 72.255C230.238 25.855 214.238 51.383 200.638 47.383C187.038 43.383 189.438 52.983 186.238 53.783C183.038 54.583 143.838 29.783 137.438 30.583z"} - , - {"fill": "#f1b288", - "path":"M138.747 32.328C132.347 33.128 106.383 9.677 121.947 41.128C141.147 79.928 63.546 80.328 46.746 69.128C29.946 57.928 53.946 87.528 53.946 87.528C72.346 107.528 37.946 90.728 37.946 90.728C3.546 77.928 -20.454 103.528 -23.654 104.328C-26.854 105.128 -31.654 108.328 -32.454 101.928C-33.254 95.528 -40.108 79.665 -72.454 105.128C-98.636 125.456 -110.891 106.183 -110.891 106.183L-115.691 110.328C-133.691 77.128 -122.927 134.874 -122.927 134.874C-114.127 169.274 18.746 125.128 18.746 125.128C18.746 125.128 187.547 94.728 198.747 90.728C209.947 86.728 300.783 92.764 300.783 92.764L295.547 73.419C230.747 27.019 215.547 53.128 201.947 49.128C188.347 45.128 190.747 54.728 187.547 55.528C184.347 56.328 145.147 31.528 138.747 32.328z"} - , - {"fill": "#f3bf9c", - "path":"M140.056 34.073C133.655 34.873 107.313 11.613 123.255 42.873C143.656 82.874 64.855 82.074 48.055 70.874C31.255 59.674 55.255 89.274 55.255 89.274C73.655 109.274 39.255 92.474 39.255 92.474C4.855 79.674 -19.145 105.274 -22.345 106.074C-25.545 106.874 -30.345 110.074 -31.145 103.674C-31.945 97.274 -38.668 81.578 -71.145 106.874C-98.564 127.947 -110.509 109.219 -110.509 109.219L-115.709 111.874C-131.709 81.674 -122.273 137.929 -122.273 137.929C-113.473 172.329 20.055 126.874 20.055 126.874C20.055 126.874 188.856 96.474 200.056 92.474C211.256 88.474 301.22 94.437 301.22 94.437L296.056 74.583C231.256 28.183 216.856 54.874 203.256 50.874C189.656 46.873 192.056 56.474 188.856 57.274C185.656 58.074 146.456 33.273 140.056 34.073z"} - , - {"fill": "#f5ccb0", - "path":"M141.365 35.819C134.965 36.619 107.523 13.944 124.565 44.619C146.565 84.219 66.164 83.819 49.364 72.619C32.564 61.419 56.564 91.019 56.564 91.019C74.964 111.019 40.564 94.219 40.564 94.219C6.164 81.419 -17.836 107.019 -21.036 107.819C-24.236 108.619 -29.036 111.819 -29.836 105.419C-30.636 99.019 -37.227 83.492 -69.836 108.619C-98.491 130.438 -110.127 112.256 -110.127 112.256L-115.727 113.419C-130.128 85.019 -121.618 140.983 -121.618 140.983C-112.818 175.384 21.364 128.619 21.364 128.619C21.364 128.619 190.165 98.219 201.365 94.219C212.565 90.219 301.656 96.11 301.656 96.11L296.565 75.746C231.765 29.346 218.165 56.619 204.565 52.619C190.965 48.619 193.365 58.219 190.165 59.019C186.965 59.819 147.765 35.019 141.365 35.819z"} - , - {"fill": "#f8d8c4", - "path":"M142.674 37.565C136.274 38.365 108.832 15.689 125.874 46.365C147.874 85.965 67.474 85.565 50.674 74.365C33.874 63.165 57.874 92.765 57.874 92.765C76.274 112.765 41.874 95.965 41.874 95.965C7.473 83.165 -16.527 108.765 -19.727 109.565C-22.927 110.365 -27.727 113.565 -28.527 107.165C-29.327 100.765 -35.786 85.405 -68.527 110.365C-98.418 132.929 -109.745 115.293 -109.745 115.293L-115.745 114.965C-129.346 88.564 -120.963 144.038 -120.963 144.038C-112.163 178.438 22.673 130.365 22.673 130.365C22.673 130.365 191.474 99.965 202.674 95.965C213.874 91.965 302.093 97.783 302.093 97.783L297.075 76.91C232.274 30.51 219.474 58.365 205.874 54.365C192.274 50.365 194.674 59.965 191.474 60.765C188.274 61.565 149.074 36.765 142.674 37.565z"} - , - {"fill": "#fae5d7", - "path":"M143.983 39.31C137.583 40.11 110.529 17.223 127.183 48.11C149.183 88.91 68.783 87.31 51.983 76.11C35.183 64.91 59.183 94.51 59.183 94.51C77.583 114.51 43.183 97.71 43.183 97.71C8.783 84.91 -15.217 110.51 -18.417 111.31C-21.618 112.11 -26.418 115.31 -27.218 108.91C-28.018 102.51 -34.346 87.318 -67.218 112.11C-98.345 135.42 -109.363 118.329 -109.363 118.329L-115.764 116.51C-128.764 92.51 -120.309 147.093 -120.309 147.093C-111.509 181.493 23.983 132.11 23.983 132.11C23.983 132.11 192.783 101.71 203.983 97.71C215.183 93.71 302.529 99.456 302.529 99.456L297.583 78.074C232.783 31.673 220.783 60.11 207.183 56.11C193.583 52.11 195.983 61.71 192.783 62.51C189.583 63.31 150.383 38.51 143.983 39.31z"} - , - {"fill": "#fcf2eb", - "path":"M145.292 41.055C138.892 41.855 112.917 18.411 128.492 49.855C149.692 92.656 70.092 89.056 53.292 77.856C36.492 66.656 60.492 96.256 60.492 96.256C78.892 116.256 44.492 99.456 44.492 99.456C10.092 86.656 -13.908 112.256 -17.108 113.056C-20.308 113.856 -25.108 117.056 -25.908 110.656C-26.708 104.256 -32.905 89.232 -65.908 113.856C-98.273 137.911 -108.982 121.365 -108.982 121.365L-115.782 118.056C-128.582 94.856 -119.654 150.147 -119.654 150.147C-110.854 184.547 25.292 133.856 25.292 133.856C25.292 133.856 194.093 103.456 205.293 99.456C216.493 95.456 302.965 101.128 302.965 101.128L298.093 79.237C233.292 32.837 222.093 61.856 208.493 57.856C194.893 53.855 197.293 63.456 194.093 64.256C190.892 65.056 151.692 40.255 145.292 41.055z"} - , - {"fill": "#ffffff", - "path":"M-115.8 119.601C-128.6 97.6 -119 153.201 -119 153.201C-110.2 187.601 26.6 135.601 26.6 135.601C26.6 135.601 195.401 105.2 206.601 101.2C217.801 97.2 303.401 102.8 303.401 102.8L298.601 80.4C233.801 34 223.401 63.6 209.801 59.6C196.201 55.6 198.601 65.2 195.401 66C192.201 66.8 153.001 42 146.601 42.8C140.201 43.6 114.981 19.793 129.801 51.6C152.028 99.307 69.041 89.227 54.6 79.6C37.8 68.4 61.8 98 61.8 98C80.2 118.001 45.8 101.2 45.8 101.2C11.4 88.4 -12.6 114.001 -15.8 114.801C-19 115.601 -23.8 118.801 -24.6 112.401C-25.4 106 -31.465 91.144 -64.6 115.601C-98.2 140.401 -108.6 124.401 -108.6 124.401L-115.8 119.601z"} - , - {"fill": "#000000", - "path":"M-74.2 149.601C-74.2 149.601 -81.4 161.201 -60.6 174.401C-60.6 174.401 -59.2 175.801 -77.2 171.601C-77.2 171.601 -83.4 169.601 -85 159.201C-85 159.201 -89.8 154.801 -94.6 149.201C-99.4 143.601 -74.2 149.601 -74.2 149.601z"} - , - {"fill": "#cccccc", - "path":"M65.8 102C65.8 102 83.498 128.821 82.9 133.601C81.6 144.001 81.4 153.601 84.6 157.601C87.801 161.601 96.601 194.801 96.601 194.801C96.601 194.801 96.201 196.001 108.601 158.001C108.601 158.001 120.201 142.001 100.201 123.601C100.201 123.601 65 94.8 65.8 102z"} - , - {"fill": "#000000", - "path":"M-54.2 176.401C-54.2 176.401 -43 183.601 -57.4 214.801L-51 212.401C-51 212.401 -51.8 223.601 -55 226.001L-47.8 222.801C-47.8 222.801 -43 230.801 -47 235.601C-47 235.601 -30.2 243.601 -31 250.001C-31 250.001 -24.6 242.001 -28.6 235.601C-32.6 229.201 -39.8 233.201 -39 214.801L-47.8 218.001C-47.8 218.001 -42.2 209.201 -42.2 202.801L-50.2 205.201C-50.2 205.201 -34.731 178.623 -45.4 177.201C-51.4 176.401 -54.2 176.401 -54.2 176.401z"} - , - {"fill": "#cccccc", - "path":"M-21.8 193.201C-21.8 193.201 -19 188.801 -21.8 189.601C-24.6 190.401 -55.8 205.201 -61.8 214.801C-61.8 214.801 -27.4 190.401 -21.8 193.201z"} - , - {"fill": "#cccccc", - "path":"M-11.4 201.201C-11.4 201.201 -8.6 196.801 -11.4 197.601C-14.2 198.401 -45.4 213.201 -51.4 222.801C-51.4 222.801 -17 198.401 -11.4 201.201z"} - , - {"fill": "#cccccc", - "path":"M1.8 186.001C1.8 186.001 4.6 181.601 1.8 182.401C-1 183.201 -32.2 198.001 -38.2 207.601C-38.2 207.601 -3.8 183.201 1.8 186.001z"} - , - {"fill": "#cccccc", - "path":"M-21.4 229.601C-21.4 229.601 -21.4 223.601 -24.2 224.401C-27 225.201 -63 242.801 -69 252.401C-69 252.401 -27 226.801 -21.4 229.601z"} - , - {"fill": "#cccccc", - "path":"M-20.2 218.801C-20.2 218.801 -19 214.001 -21.8 214.801C-23.8 214.801 -50.2 226.401 -56.2 236.001C-56.2 236.001 -26.6 214.401 -20.2 218.801z"} - , - {"fill": "#cccccc", - "path":"M-34.6 266.401L-44.6 274.001C-44.6 274.001 -34.2 266.401 -30.6 267.601C-30.6 267.601 -37.4 278.801 -38.2 284.001C-38.2 284.001 -27.8 271.201 -22.2 271.601C-22.2 271.601 -14.6 272.001 -14.6 282.801C-14.6 282.801 -9 272.401 -5.8 272.801C-5.8 272.801 -4.6 279.201 -5.8 286.001C-5.8 286.001 -1.8 278.401 2.2 280.001C2.2 280.001 8.6 278.001 7.8 289.601C7.8 289.601 7.8 300.001 7 302.801C7 302.801 12.6 276.401 15 276.001C15 276.001 23 274.801 27.8 283.601C27.8 283.601 23.8 276.001 28.6 278.001C28.6 278.001 39.4 279.601 42.6 286.401C42.6 286.401 35.8 274.401 41.4 277.601C41.4 277.601 48.2 277.601 49.4 284.001C49.4 284.001 57.8 305.201 59.8 306.801C59.8 306.801 52.2 285.201 53.8 285.201C53.8 285.201 51.8 273.201 57 288.001C57 288.001 53.8 274.001 59.4 274.801C65 275.601 69.4 285.601 77.8 283.201C77.8 283.201 87.401 288.801 89.401 219.601L-34.6 266.401z"} - , - {"fill": "#000000", - "path":"M-29.8 173.601C-29.8 173.601 -15 167.601 25 173.601C25 173.601 32.2 174.001 39 165.201C45.8 156.401 72.6 149.201 79 151.201L88.601 157.601L89.401 158.801C89.401 158.801 101.801 169.201 102.201 176.801C102.601 184.401 87.801 232.401 78.2 248.401C68.6 264.401 59 276.801 39.8 274.401C39.8 274.401 19 270.401 -6.6 274.401C-6.6 274.401 -35.8 272.801 -38.6 264.801C-41.4 256.801 -27.4 241.601 -27.4 241.601C-27.4 241.601 -23 233.201 -24.2 218.801C-25.4 204.401 -25 176.401 -29.8 173.601z"} - , - {"fill": "#e5668c", - "path":"M-7.8 175.601C0.6 194.001 -29 259.201 -29 259.201C-31 260.801 -16.34 266.846 -6.2 264.401C4.746 261.763 45 266.001 45 266.001C68.6 250.401 81.4 206.001 81.4 206.001C81.4 206.001 91.801 182.001 74.2 178.801C56.6 175.601 -7.8 175.601 -7.8 175.601z"} - , - {"fill": "#b23259", - "path":"M-9.831 206.497C-6.505 193.707 -4.921 181.906 -7.8 175.601C-7.8 175.601 54.6 182.001 65.8 161.201C70.041 153.326 84.801 184.001 84.4 193.601C84.4 193.601 21.4 208.001 6.6 196.801L-9.831 206.497z"} - , - {"fill": "#a5264c", - "path":"M-5.4 222.801C-5.4 222.801 -3.4 230.001 -5.8 234.001C-5.8 234.001 -7.4 234.801 -8.6 235.201C-8.6 235.201 -7.4 238.801 -1.4 240.401C-1.4 240.401 0.6 244.801 3 245.201C5.4 245.601 10.2 251.201 14.2 250.001C18.2 248.801 29.4 244.801 29.4 244.801C29.4 244.801 35 241.601 43.8 245.201C43.8 245.201 46.175 244.399 46.6 240.401C47.1 235.701 50.2 232.001 52.2 230.001C54.2 228.001 63.8 215.201 62.6 214.801C61.4 214.401 -5.4 222.801 -5.4 222.801z"} - , - {"fill": "#ff727f", "stroke":"#000000", - "path":"M-9.8 174.401C-9.8 174.401 -12.6 196.801 -9.4 205.201C-6.2 213.601 -7 215.601 -7.8 219.601C-8.6 223.601 -4.2 233.601 1.4 239.601L13.4 241.201C13.4 241.201 28.6 237.601 37.8 240.401C37.8 240.401 46.794 241.744 50.2 226.801C50.2 226.801 55 220.401 62.2 217.601C69.4 214.801 76.6 173.201 72.6 165.201C68.6 157.201 54.2 152.801 38.2 168.401C22.2 184.001 20.2 167.201 -9.8 174.401z"} - , - {"fill": "#ffffcc", "stroke":"#000000", "width":0.5, - "path":"M-8.2 249.201C-8.2 249.201 -9 247.201 -13.4 246.801C-13.4 246.801 -35.8 243.201 -44.2 230.801C-44.2 230.801 -51 225.201 -46.6 236.801C-46.6 236.801 -36.2 257.201 -29.4 260.001C-29.4 260.001 -13 264.001 -8.2 249.201z"} - , - {"fill": "#cc3f4c", - "path":"M71.742 185.229C72.401 177.323 74.354 168.709 72.6 165.201C66.154 152.307 49.181 157.695 38.2 168.401C22.2 184.001 20.2 167.201 -9.8 174.401C-9.8 174.401 -11.545 188.364 -10.705 198.376C-10.705 198.376 26.6 186.801 27.4 192.401C27.4 192.401 29 189.201 38.2 189.201C47.4 189.201 70.142 188.029 71.742 185.229z"} - , - {"stroke":"#a51926", "width":2, - "path":"M28.6 175.201C28.6 175.201 33.4 180.001 29.8 189.601C29.8 189.601 15.4 205.601 17.4 219.601"} - , - {"fill": "#ffffcc", "stroke":"#000000", "width":0.5, - "path":"M-19.4 260.001C-19.4 260.001 -23.8 247.201 -15 254.001C-15 254.001 -10.2 256.001 -11.4 257.601C-12.6 259.201 -18.2 263.201 -19.4 260.001z"} - , - {"fill": "#ffffcc", "stroke":"#000000", "width":0.5, - "path":"M-14.36 261.201C-14.36 261.201 -17.88 250.961 -10.84 256.401C-10.84 256.401 -6.419 258.849 -7.96 259.281C-12.52 260.561 -7.96 263.121 -14.36 261.201z"} - , - {"fill": "#ffffcc", "stroke":"#000000", "width":0.5, - "path":"M-9.56 261.201C-9.56 261.201 -13.08 250.961 -6.04 256.401C-6.04 256.401 -1.665 258.711 -3.16 259.281C-6.52 260.561 -3.16 263.121 -9.56 261.201z"} - , - {"fill": "#ffffcc", "stroke":"#000000", "width":0.5, - "path":"M-2.96 261.401C-2.96 261.401 -6.48 251.161 0.56 256.601C0.56 256.601 4.943 258.933 3.441 259.481C0.48 260.561 3.441 263.321 -2.96 261.401z"} - , - {"fill": "#ffffcc", "stroke":"#000000", "width":0.5, - "path":"M3.52 261.321C3.52 261.321 0 251.081 7.041 256.521C7.041 256.521 10.881 258.121 9.921 259.401C8.961 260.681 9.921 263.241 3.52 261.321z"} - , - {"fill": "#ffffcc", "stroke":"#000000", "width":0.5, - "path":"M10.2 262.001C10.2 262.001 5.4 249.601 14.6 256.001C14.6 256.001 19.4 258.001 18.2 259.601C17 261.201 18.2 264.401 10.2 262.001z"} - , - {"stroke":"#a5264c", "width":2, - "path":"M-18.2 244.801C-18.2 244.801 -5 242.001 1 245.201C1 245.201 7 246.401 8.2 246.001C9.4 245.601 12.6 245.201 12.6 245.201"} - , - {"stroke":"#a5264c", "width":2, - "path":"M15.8 253.601C15.8 253.601 27.8 240.001 39.8 244.401C46.816 246.974 45.8 243.601 46.6 240.801C47.4 238.001 47.6 233.801 52.6 230.801"} - , - {"fill": "#ffffcc", "stroke":"#000000", "width":0.5, - "path":"M33 237.601C33 237.601 29 226.801 26.2 239.601C23.4 252.401 20.2 256.001 18.6 258.801C18.6 258.801 18.6 264.001 27 263.601C27 263.601 37.8 263.201 38.2 260.401C38.6 257.601 37 246.001 33 237.601z"} - , - {"stroke":"#a5264c", "width":2, - "path":"M47 244.801C47 244.801 50.6 242.401 53 243.601"} - , - {"stroke":"#a5264c", "width":2, - "path":"M53.5 228.401C53.5 228.401 56.4 223.501 61.2 222.701"} - , - {"fill": "#b2b2b2", - "path":"M-25.8 265.201C-25.8 265.201 -7.8 268.401 -3.4 266.801C-3.4 266.801 5.4 266.801 -3 268.801C-3 268.801 -15.8 268.801 -23.8 267.601C-23.8 267.601 -35.4 262.001 -25.8 265.201z"} - , - {"fill": "#ffffcc", "stroke":"#000000", "width":0.5, - "path":"M-11.8 172.001C-11.8 172.001 5.8 172.001 7.8 172.801C7.8 172.801 15 203.601 11.4 211.201C11.4 211.201 10.2 214.001 7.4 208.401C7.4 208.401 -11 175.601 -14.2 173.601C-17.4 171.601 -13 172.001 -11.8 172.001z"} - , - {"fill": "#ffffcc", "stroke":"#000000", "width":0.5, - "path":"M-88.9 169.301C-88.9 169.301 -80 171.001 -67.4 173.601C-67.4 173.601 -62.6 196.001 -59.4 200.801C-56.2 205.601 -59.8 205.601 -63.4 202.801C-67 200.001 -81.8 186.001 -83.8 181.601C-85.8 177.201 -88.9 169.301 -88.9 169.301z"} - , - {"fill": "#ffffcc", "stroke":"#000000", "width":0.5, - "path":"M-67.039 173.818C-67.039 173.818 -61.239 175.366 -60.23 177.581C-59.222 179.795 -61.432 183.092 -61.432 183.092C-61.432 183.092 -62.432 186.397 -63.634 184.235C-64.836 182.072 -67.708 174.412 -67.039 173.818z"} - , - {"fill": "#000000", - "path":"M-67 173.601C-67 173.601 -63.4 178.801 -59.8 178.801C-56.2 178.801 -55.818 178.388 -53 179.001C-48.4 180.001 -48.8 178.001 -42.2 179.201C-39.56 179.681 -37 178.801 -34.2 180.001C-31.4 181.201 -28.2 180.401 -27 178.401C-25.8 176.401 -21 172.201 -21 172.201C-21 172.201 -33.8 174.001 -36.6 174.801C-36.6 174.801 -59 176.001 -67 173.601z"} - , - {"fill": "#ffffcc", "stroke":"#000000", "width":0.5, - "path":"M-22.4 173.801C-22.4 173.801 -28.85 177.301 -29.25 179.701C-29.65 182.101 -24 185.801 -24 185.801C-24 185.801 -21.25 190.401 -20.65 188.001C-20.05 185.601 -21.6 174.201 -22.4 173.801z"} - , - {"fill": "#ffffcc", "stroke":"#000000", "width":0.5, - "path":"M-59.885 179.265C-59.885 179.265 -52.878 190.453 -52.661 179.242C-52.661 179.242 -52.104 177.984 -53.864 177.962C-59.939 177.886 -58.418 173.784 -59.885 179.265z"} - , - {"fill": "#ffffcc", "stroke":"#000000", "width":0.5, - "path":"M-52.707 179.514C-52.707 179.514 -44.786 190.701 -45.422 179.421C-45.422 179.421 -45.415 179.089 -47.168 178.936C-51.915 178.522 -51.57 174.004 -52.707 179.514z"} - , - {"fill": "#ffffcc", "stroke":"#000000", "width":0.5, - "path":"M-45.494 179.522C-45.494 179.522 -37.534 190.15 -38.203 180.484C-38.203 180.484 -38.084 179.251 -39.738 178.95C-43.63 178.244 -43.841 174.995 -45.494 179.522z"} - , - {"fill": "#ffffcc", "stroke":"#000000", "width":0.5, - "path":"M-38.618 179.602C-38.618 179.602 -30.718 191.163 -30.37 181.382C-30.37 181.382 -28.726 180.004 -30.472 179.782C-36.29 179.042 -35.492 174.588 -38.618 179.602z"} - , - {"fill": "#e5e5b2", - "path":"M-74.792 183.132L-82.45 181.601C-85.05 176.601 -87.15 170.451 -87.15 170.451C-87.15 170.451 -80.8 171.451 -68.3 174.251C-68.3 174.251 -67.424 177.569 -65.952 183.364L-74.792 183.132z"} - , - {"fill": "#e5e5b2", - "path":"M-9.724 178.47C-11.39 175.964 -12.707 174.206 -13.357 173.8C-16.37 171.917 -12.227 172.294 -11.098 172.294C-11.098 172.294 5.473 172.294 7.356 173.047C7.356 173.047 7.88 175.289 8.564 178.68C8.564 178.68 -1.524 176.67 -9.724 178.47z"} - , - {"fill": "#cc7226", - "path":"M43.88 40.321C71.601 44.281 97.121 8.641 98.881 -1.04C100.641 -10.72 90.521 -22.6 90.521 -22.6C91.841 -25.68 87.001 -39.76 81.721 -49C76.441 -58.24 60.54 -57.266 43 -58.24C27.16 -59.12 8.68 -35.8 7.36 -34.04C6.04 -32.28 12.2 6.001 13.52 11.721C14.84 17.441 12.2 43.841 12.2 43.841C46.44 34.741 16.16 36.361 43.88 40.321z"} - , - {"fill": "#ea8e51", - "path":"M8.088 -33.392C6.792 -31.664 12.84 5.921 14.136 11.537C15.432 17.153 12.84 43.073 12.84 43.073C45.512 34.193 16.728 35.729 43.944 39.617C71.161 43.505 96.217 8.513 97.945 -0.992C99.673 -10.496 89.737 -22.16 89.737 -22.16C91.033 -25.184 86.281 -39.008 81.097 -48.08C75.913 -57.152 60.302 -56.195 43.08 -57.152C27.528 -58.016 9.384 -35.12 8.088 -33.392z"} - , - {"fill": "#efaa7c", - "path":"M8.816 -32.744C7.544 -31.048 13.48 5.841 14.752 11.353C16.024 16.865 13.48 42.305 13.48 42.305C44.884 33.145 17.296 35.097 44.008 38.913C70.721 42.729 95.313 8.385 97.009 -0.944C98.705 -10.272 88.953 -21.72 88.953 -21.72C90.225 -24.688 85.561 -38.256 80.473 -47.16C75.385 -56.064 60.063 -55.125 43.16 -56.064C27.896 -56.912 10.088 -34.44 8.816 -32.744z"} - , - {"fill": "#f4c6a8", - "path":"M9.544 -32.096C8.296 -30.432 14.12 5.761 15.368 11.169C16.616 16.577 14.12 41.537 14.12 41.537C43.556 32.497 17.864 34.465 44.072 38.209C70.281 41.953 94.409 8.257 96.073 -0.895C97.737 -10.048 88.169 -21.28 88.169 -21.28C89.417 -24.192 84.841 -37.504 79.849 -46.24C74.857 -54.976 59.824 -54.055 43.24 -54.976C28.264 -55.808 10.792 -33.76 9.544 -32.096z"} - , - {"fill": "#f9e2d3", - "path":"M10.272 -31.448C9.048 -29.816 14.76 5.681 15.984 10.985C17.208 16.289 14.76 40.769 14.76 40.769C42.628 31.849 18.432 33.833 44.136 37.505C69.841 41.177 93.505 8.129 95.137 -0.848C96.769 -9.824 87.385 -20.84 87.385 -20.84C88.609 -23.696 84.121 -36.752 79.225 -45.32C74.329 -53.888 59.585 -52.985 43.32 -53.888C28.632 -54.704 11.496 -33.08 10.272 -31.448z"} - , - {"fill": "#ffffff", - "path":"M44.2 36.8C69.4 40.4 92.601 8 94.201 -0.8C95.801 -9.6 86.601 -20.4 86.601 -20.4C87.801 -23.2 83.4 -36 78.6 -44.4C73.8 -52.8 59.346 -51.914 43.4 -52.8C29 -53.6 12.2 -32.4 11 -30.8C9.8 -29.2 15.4 5.6 16.6 10.8C17.8 16 15.4 40 15.4 40C40.9 31.4 19 33.2 44.2 36.8z"} - , - {"fill": "#cccccc", - "path":"M90.601 2.8C90.601 2.8 62.8 10.4 51.2 8.8C51.2 8.8 35.4 2.2 26.6 24C26.6 24 23 31.2 21 33.2C19 35.2 90.601 2.8 90.601 2.8z"} - , - {"fill": "#000000", - "path":"M94.401 0.6C94.401 0.6 65.4 12.8 55.4 12.4C55.4 12.4 39 7.8 30.6 22.4C30.6 22.4 22.2 31.6 19 33.2C19 33.2 18.6 34.8 25 30.8L35.4 36C35.4 36 50.2 45.6 59.8 29.6C59.8 29.6 63.8 18.4 63.8 16.4C63.8 14.4 85 8.8 86.601 8.4C88.201 8 94.801 3.8 94.401 0.6z"} - , - {"fill": "#99cc32", - "path":"M47 36.514C40.128 36.514 31.755 32.649 31.755 26.4C31.755 20.152 40.128 13.887 47 13.887C53.874 13.887 59.446 18.952 59.446 25.2C59.446 31.449 53.874 36.514 47 36.514z"} - , - {"fill": "#659900", - "path":"M43.377 19.83C38.531 20.552 33.442 22.055 33.514 21.839C35.054 17.22 41.415 13.887 47 13.887C51.296 13.887 55.084 15.865 57.32 18.875C57.32 18.875 52.004 18.545 43.377 19.83z"} - , - {"fill": "#ffffff", - "path":"M55.4 19.6C55.4 19.6 51 16.4 51 18.6C51 18.6 54.6 23 55.4 19.6z"} - , - {"fill": "#000000", - "path":"M45.4 27.726C42.901 27.726 40.875 25.7 40.875 23.2C40.875 20.701 42.901 18.675 45.4 18.675C47.9 18.675 49.926 20.701 49.926 23.2C49.926 25.7 47.9 27.726 45.4 27.726z"} - , - {"fill": "#cc7226", - "path":"M-58.6 14.4C-58.6 14.4 -61.8 -6.8 -59.4 -11.2C-59.4 -11.2 -48.6 -21.2 -49 -24.8C-49 -24.8 -49.4 -42.8 -50.6 -43.6C-51.8 -44.4 -59.4 -50.4 -65.4 -44C-65.4 -44 -75.8 -26 -75 -19.6L-75 -17.6C-75 -17.6 -82.6 -18 -84.2 -16C-84.2 -16 -85.4 -10.8 -86.6 -10.4C-86.6 -10.4 -89.4 -8 -87.4 -5.2C-87.4 -5.2 -89.4 -2.8 -89 1.2L-81.4 5.2C-81.4 5.2 -79.4 19.6 -68.6 24.8C-63.764 27.129 -60.6 20.4 -58.6 14.4z"} - , - {"fill": "#ffffff", - "path":"M-59.6 12.56C-59.6 12.56 -62.48 -6.52 -60.32 -10.48C-60.32 -10.48 -50.6 -19.48 -50.96 -22.72C-50.96 -22.72 -51.32 -38.92 -52.4 -39.64C-53.48 -40.36 -60.32 -45.76 -65.72 -40C-65.72 -40 -75.08 -23.8 -74.36 -18.04L-74.36 -16.24C-74.36 -16.24 -81.2 -16.6 -82.64 -14.8C-82.64 -14.8 -83.72 -10.12 -84.8 -9.76C-84.8 -9.76 -87.32 -7.6 -85.52 -5.08C-85.52 -5.08 -87.32 -2.92 -86.96 0.68L-80.12 4.28C-80.12 4.28 -78.32 17.24 -68.6 21.92C-64.248 24.015 -61.4 17.96 -59.6 12.56z"} - , - {"fill": "#eb955c", - "path":"M-51.05 -42.61C-52.14 -43.47 -59.63 -49.24 -65.48 -43C-65.48 -43 -75.62 -25.45 -74.84 -19.21L-74.84 -17.26C-74.84 -17.26 -82.25 -17.65 -83.81 -15.7C-83.81 -15.7 -84.98 -10.63 -86.15 -10.24C-86.15 -10.24 -88.88 -7.9 -86.93 -5.17C-86.93 -5.17 -88.88 -2.83 -88.49 1.07L-81.08 4.97C-81.08 4.97 -79.13 19.01 -68.6 24.08C-63.886 26.35 -60.8 19.79 -58.85 13.94C-58.85 13.94 -61.97 -6.73 -59.63 -11.02C-59.63 -11.02 -49.1 -20.77 -49.49 -24.28C-49.49 -24.28 -49.88 -41.83 -51.05 -42.61z"} - , - {"fill": "#f2b892", - "path":"M-51.5 -41.62C-52.48 -42.54 -59.86 -48.08 -65.56 -42C-65.56 -42 -75.44 -24.9 -74.68 -18.82L-74.68 -16.92C-74.68 -16.92 -81.9 -17.3 -83.42 -15.4C-83.42 -15.4 -84.56 -10.46 -85.7 -10.08C-85.7 -10.08 -88.36 -7.8 -86.46 -5.14C-86.46 -5.14 -88.36 -2.86 -87.98 0.94L-80.76 4.74C-80.76 4.74 -78.86 18.42 -68.6 23.36C-64.006 25.572 -61 19.18 -59.1 13.48C-59.1 13.48 -62.14 -6.66 -59.86 -10.84C-59.86 -10.84 -49.6 -20.34 -49.98 -23.76C-49.98 -23.76 -50.36 -40.86 -51.5 -41.62z"} - , - {"fill": "#f8dcc8", - "path":"M-51.95 -40.63C-52.82 -41.61 -60.09 -46.92 -65.64 -41C-65.64 -41 -75.26 -24.35 -74.52 -18.43L-74.52 -16.58C-74.52 -16.58 -81.55 -16.95 -83.03 -15.1C-83.03 -15.1 -84.14 -10.29 -85.25 -9.92C-85.25 -9.92 -87.84 -7.7 -85.99 -5.11C-85.99 -5.11 -87.84 -2.89 -87.47 0.81L-80.44 4.51C-80.44 4.51 -78.59 17.83 -68.6 22.64C-64.127 24.794 -61.2 18.57 -59.35 13.02C-59.35 13.02 -62.31 -6.59 -60.09 -10.66C-60.09 -10.66 -50.1 -19.91 -50.47 -23.24C-50.47 -23.24 -50.84 -39.89 -51.95 -40.63z"} - , - {"fill": "#ffffff", - "path":"M-59.6 12.46C-59.6 12.46 -62.48 -6.52 -60.32 -10.48C-60.32 -10.48 -50.6 -19.48 -50.96 -22.72C-50.96 -22.72 -51.32 -38.92 -52.4 -39.64C-53.16 -40.68 -60.32 -45.76 -65.72 -40C-65.72 -40 -75.08 -23.8 -74.36 -18.04L-74.36 -16.24C-74.36 -16.24 -81.2 -16.6 -82.64 -14.8C-82.64 -14.8 -83.72 -10.12 -84.8 -9.76C-84.8 -9.76 -87.32 -7.6 -85.52 -5.08C-85.52 -5.08 -87.32 -2.92 -86.96 0.68L-80.12 4.28C-80.12 4.28 -78.32 17.24 -68.6 21.92C-64.248 24.015 -61.4 17.86 -59.6 12.46z"} - , - {"fill": "#cccccc", - "path":"M-62.7 6.2C-62.7 6.2 -84.3 -4 -85.2 -4.8C-85.2 -4.8 -76.1 3.4 -75.3 3.4C-74.5 3.4 -62.7 6.2 -62.7 6.2z"} - , - {"fill": "#000000", - "path":"M-79.8 0C-79.8 0 -61.4 3.6 -61.4 8C-61.4 10.912 -61.643 24.331 -67 22.8C-75.4 20.4 -71.8 6 -79.8 0z"} - , - {"fill": "#99cc32", - "path":"M-71.4 3.8C-71.4 3.8 -62.422 5.274 -61.4 8C-60.8 9.6 -60.137 17.908 -65.6 19C-70.152 19.911 -72.382 9.69 -71.4 3.8z"} - , - {"fill": "#000000", - "path":"M14.595 46.349C14.098 44.607 15.409 44.738 17.2 44.2C19.2 43.6 31.4 39.8 32.2 37.2C33 34.6 46.2 39 46.2 39C48 39.8 52.4 42.4 52.4 42.4C57.2 43.6 63.8 44 63.8 44C66.2 45 69.6 47.8 69.6 47.8C84.2 58 96.601 50.8 96.601 50.8C116.601 44.2 110.601 27 110.601 27C107.601 18 110.801 14.6 110.801 14.6C111.001 10.8 118.201 17.2 118.201 17.2C120.801 21.4 121.601 26.4 121.601 26.4C129.601 37.6 126.201 19.8 126.201 19.8C126.401 18.8 123.601 15.2 123.601 14C123.601 12.8 121.801 9.4 121.801 9.4C118.801 6 121.201 -1 121.201 -1C123.001 -14.8 120.801 -13 120.801 -13C119.601 -14.8 110.401 -4.8 110.401 -4.8C108.201 -1.4 102.201 0.2 102.201 0.2C99.401 2 96.001 0.6 96.001 0.6C93.401 0.2 87.801 7.2 87.801 7.2C90.601 7 93.001 11.4 95.401 11.6C97.801 11.8 99.601 9.2 101.201 8.6C102.801 8 105.601 13.8 105.601 13.8C106.001 16.4 100.401 21.2 100.401 21.2C100.001 25.8 98.401 24.2 98.401 24.2C95.401 23.6 94.201 27.4 93.201 32C92.201 36.6 88.001 37 88.001 37C86.401 44.4 85.2 41.4 85.2 41.4C85 35.8 79 41.6 79 41.6C77.8 43.6 73.2 41.4 73.2 41.4C66.4 39.4 68.8 37.4 68.8 37.4C70.6 35.2 81.8 37.4 81.8 37.4C84 35.8 76 31.8 76 31.8C75.4 30 76.4 25.6 76.4 25.6C77.6 22.4 84.4 16.8 84.4 16.8C93.801 15.6 91.001 14 91.001 14C84.801 8.8 79 16.4 79 16.4C76.8 22.6 59.4 37.6 59.4 37.6C54.6 41 57.2 34.2 53.2 37.6C49.2 41 28.6 32 28.6 32C17.038 30.807 14.306 46.549 10.777 43.429C10.777 43.429 16.195 51.949 14.595 46.349z"} - , - {"fill": "#000000", - "path":"M209.401 -120C209.401 -120 183.801 -112 181.001 -93.2C181.001 -93.2 178.601 -70.4 199.001 -52.8C199.001 -52.8 199.401 -46.4 201.401 -43.2C201.401 -43.2 199.801 -38.4 218.601 -46L245.801 -54.4C245.801 -54.4 252.201 -56.8 257.401 -65.6C262.601 -74.4 277.801 -93.2 274.201 -118.4C274.201 -118.4 275.401 -129.6 269.401 -130C269.401 -130 261.001 -131.6 253.801 -124C253.801 -124 247.001 -120.8 244.601 -121.2L209.401 -120z"} - , - {"fill": "#000000", - "path":"M264.022 -120.99C264.022 -120.99 266.122 -129.92 261.282 -125.08C261.282 -125.08 254.242 -119.36 246.761 -119.36C246.761 -119.36 232.241 -117.16 227.841 -103.96C227.841 -103.96 223.881 -77.12 231.801 -71.4C231.801 -71.4 236.641 -63.92 243.681 -70.52C250.722 -77.12 266.222 -107.35 264.022 -120.99z"} - , - {"fill": "#323232", - "path":"M263.648 -120.632C263.648 -120.632 265.738 -129.376 260.986 -124.624C260.986 -124.624 254.074 -119.008 246.729 -119.008C246.729 -119.008 232.473 -116.848 228.153 -103.888C228.153 -103.888 224.265 -77.536 232.041 -71.92C232.041 -71.92 236.793 -64.576 243.705 -71.056C250.618 -77.536 265.808 -107.24 263.648 -120.632z"} - , - {"fill": "#666666", - "path":"M263.274 -120.274C263.274 -120.274 265.354 -128.832 260.69 -124.168C260.69 -124.168 253.906 -118.656 246.697 -118.656C246.697 -118.656 232.705 -116.536 228.465 -103.816C228.465 -103.816 224.649 -77.952 232.281 -72.44C232.281 -72.44 236.945 -65.232 243.729 -71.592C250.514 -77.952 265.394 -107.13 263.274 -120.274z"} - , - {"fill": "#999999", - "path":"M262.9 -119.916C262.9 -119.916 264.97 -128.288 260.394 -123.712C260.394 -123.712 253.738 -118.304 246.665 -118.304C246.665 -118.304 232.937 -116.224 228.777 -103.744C228.777 -103.744 225.033 -78.368 232.521 -72.96C232.521 -72.96 237.097 -65.888 243.753 -72.128C250.41 -78.368 264.98 -107.02 262.9 -119.916z"} - , - {"fill": "#cccccc", - "path":"M262.526 -119.558C262.526 -119.558 264.586 -127.744 260.098 -123.256C260.098 -123.256 253.569 -117.952 246.633 -117.952C246.633 -117.952 233.169 -115.912 229.089 -103.672C229.089 -103.672 225.417 -78.784 232.761 -73.48C232.761 -73.48 237.249 -66.544 243.777 -72.664C250.305 -78.784 264.566 -106.91 262.526 -119.558z"} - , - {"fill": "#ffffff", - "path":"M262.151 -119.2C262.151 -119.2 264.201 -127.2 259.801 -122.8C259.801 -122.8 253.401 -117.6 246.601 -117.6C246.601 -117.6 233.401 -115.6 229.401 -103.6C229.401 -103.6 225.801 -79.2 233.001 -74C233.001 -74 237.401 -67.2 243.801 -73.2C250.201 -79.2 264.151 -106.8 262.151 -119.2z"} - , - {"fill": "#992600", - "path":"M50.6 84C50.6 84 30.2 64.8 22.2 64C22.2 64 -12.2 60 -27 78C-27 78 -9.4 57.6 18.2 63.2C18.2 63.2 -3.4 58.8 -15.8 62C-15.8 62 -32.6 62 -42.2 76L-45 80.8C-45 80.8 -41 66 -22.6 60C-22.6 60 0.2 55.2 11 60C11 60 -10.6 53.2 -20.6 55.2C-20.6 55.2 -51 52.8 -63.8 79.2C-63.8 79.2 -59.8 64.8 -45 57.6C-45 57.6 -31.4 48.8 -11 51.6C-11 51.6 3.4 54.8 8.6 57.2C13.8 59.6 12.6 56.8 4.2 52C4.2 52 -1.4 42 -15.4 42.4C-15.4 42.4 -58.2 46 -68.6 58C-68.6 58 -55 46.8 -44.6 44C-44.6 44 -22.2 36 -13.8 36.8C-13.8 36.8 11 37.8 18.6 33.8C18.6 33.8 7.4 38.8 10.6 42C13.8 45.2 20.6 52.8 20.6 54C20.6 55.2 44.8 77.3 48.4 81.7L50.6 84z"} - , - {"fill": "#cccccc", - "path":"M189 278C189 278 173.5 241.5 161 232C161 232 187 248 190.5 266C190.5 266 190.5 276 189 278z"} - , - {"fill": "#cccccc", - "path":"M236 285.5C236 285.5 209.5 230.5 191 206.5C191 206.5 234.5 244 239.5 270.5L240 276L237 273.5C237 273.5 236.5 282.5 236 285.5z"} - , - {"fill": "#cccccc", - "path":"M292.5 237C292.5 237 230 177.5 228.5 175C228.5 175 289 241 292 248.5C292 248.5 290 239.5 292.5 237z"} - , - {"fill": "#cccccc", - "path":"M104 280.5C104 280.5 123.5 228.5 142.5 251C142.5 251 157.5 261 157 264C157 264 153 257.5 135 258C135 258 116 255 104 280.5z"} - , - {"fill": "#cccccc", - "path":"M294.5 153C294.5 153 249.5 124.5 242 123C230.193 120.639 291.5 152 296.5 162.5C296.5 162.5 298.5 160 294.5 153z"} - , - {"fill": "#000000", - "path":"M143.801 259.601C143.801 259.601 164.201 257.601 171.001 250.801L175.401 254.401L193.001 216.001L196.601 221.201C196.601 221.201 211.001 206.401 210.201 198.401C209.401 190.401 223.001 204.401 223.001 204.401C223.001 204.401 222.201 192.801 229.401 199.601C229.401 199.601 227.001 184.001 235.401 192.001C235.401 192.001 224.864 161.844 247.401 187.601C253.001 194.001 248.601 187.201 248.601 187.201C248.601 187.201 222.601 139.201 244.201 153.601C244.201 153.601 246.201 130.801 245.001 126.401C243.801 122.001 241.801 99.6 237.001 94.4C232.201 89.2 237.401 87.6 243.001 92.8C243.001 92.8 231.801 68.8 245.001 80.8C245.001 80.8 241.401 65.6 237.001 62.8C237.001 62.8 231.401 45.6 246.601 56.4C246.601 56.4 242.201 44 239.001 40.8C239.001 40.8 227.401 13.2 234.601 18L239.001 21.6C239.001 21.6 232.201 7.6 238.601 12C245.001 16.4 245.001 16 245.001 16C245.001 16 223.801 -17.2 244.201 0.4C244.201 0.4 236.042 -13.518 232.601 -20.4C232.601 -20.4 213.801 -40.8 228.201 -34.4L233.001 -32.8C233.001 -32.8 224.201 -42.8 216.201 -44.4C208.201 -46 218.601 -52.4 225.001 -50.4C231.401 -48.4 247.001 -40.8 247.001 -40.8C247.001 -40.8 259.801 -22 263.801 -21.6C263.801 -21.6 243.801 -29.2 249.801 -21.2C249.801 -21.2 264.201 -7.2 257.001 -7.6C257.001 -7.6 251.001 -0.4 255.801 8.4C255.801 8.4 237.342 -9.991 252.201 15.6L259.001 32C259.001 32 234.601 7.2 245.801 29.2C245.801 29.2 263.001 52.8 265.001 53.2C267.001 53.6 271.401 62.4 271.401 62.4L267.001 60.4L272.201 69.2C272.201 69.2 261.001 57.2 267.001 70.4L272.601 84.8C272.601 84.8 252.201 62.8 265.801 92.4C265.801 92.4 249.401 87.2 258.201 104.4C258.201 104.4 256.601 120.401 257.001 125.601C257.401 130.801 258.601 159.201 254.201 167.201C249.801 175.201 260.201 194.401 262.201 198.401C264.201 202.401 267.801 213.201 259.001 204.001C250.201 194.801 254.601 200.401 256.601 209.201C258.601 218.001 264.601 233.601 263.801 239.201C263.801 239.201 262.601 240.401 259.401 236.801C259.401 236.801 244.601 214.001 246.201 228.401C246.201 228.401 245.001 236.401 241.801 245.201C241.801 245.201 238.601 256.001 238.601 247.201C238.601 247.201 235.401 230.401 232.601 238.001C229.801 245.601 226.201 251.601 223.401 254.001C220.601 256.401 215.401 233.601 214.201 244.001C214.201 244.001 202.201 231.601 197.401 248.001L185.801 264.401C185.801 264.401 185.401 252.001 184.201 258.001C184.201 258.001 154.201 264.001 143.801 259.601z"} - , - {"fill": "#000000", - "path":"M109.401 -97.2C109.401 -97.2 97.801 -105.2 93.801 -104.8C89.801 -104.4 121.401 -113.6 162.601 -86C162.601 -86 167.401 -83.2 171.001 -83.6C171.001 -83.6 174.201 -81.2 171.401 -77.6C171.401 -77.6 162.601 -68 173.801 -56.8C173.801 -56.8 192.201 -50 186.601 -58.8C186.601 -58.8 197.401 -54.8 199.801 -50.8C202.201 -46.8 201.001 -50.8 201.001 -50.8C201.001 -50.8 194.601 -58 188.601 -63.2C188.601 -63.2 183.401 -65.2 180.601 -73.6C177.801 -82 175.401 -92 179.801 -95.2C179.801 -95.2 175.801 -90.8 176.601 -94.8C177.401 -98.8 181.001 -102.4 182.601 -102.8C184.201 -103.2 200.601 -119 207.401 -119.4C207.401 -119.4 198.201 -118 195.201 -119C192.201 -120 165.601 -131.4 159.601 -132.6C159.601 -132.6 142.801 -139.2 154.801 -137.2C154.801 -137.2 190.601 -133.4 208.801 -120.2C208.801 -120.2 201.601 -128.6 183.201 -135.6C183.201 -135.6 161.001 -148.2 125.801 -143.2C125.801 -143.2 108.001 -140 100.201 -138.2C100.201 -138.2 97.601 -138.8 97.001 -139.2C96.401 -139.6 84.6 -148.6 57 -141.6C57 -141.6 40 -137 31.4 -132.2C31.4 -132.2 16.2 -131 12.6 -127.8C12.6 -127.8 -6 -113.2 -8 -112.4C-10 -111.6 -21.4 -104 -22.2 -103.6C-22.2 -103.6 2.4 -110.2 4.8 -112.6C7.2 -115 24.6 -117.6 27 -116.2C29.4 -114.8 37.8 -115.4 28.2 -114.8C28.2 -114.8 103.801 -100 104.601 -98C105.401 -96 109.401 -97.2 109.401 -97.2z"} - , - {"fill": "#cc7226", - "path":"M180.801 -106.4C180.801 -106.4 170.601 -113.8 168.601 -113.8C166.601 -113.8 154.201 -124 150.001 -123.6C145.801 -123.2 133.601 -133.2 106.201 -125C106.201 -125 105.601 -127 109.201 -127.8C109.201 -127.8 115.601 -130 116.001 -130.6C116.001 -130.6 136.201 -134.8 143.401 -131.2C143.401 -131.2 152.601 -128.6 158.801 -122.4C158.801 -122.4 170.001 -119.2 173.201 -120.2C173.201 -120.2 182.001 -118 182.401 -116.2C182.401 -116.2 188.201 -113.2 186.401 -110.6C186.401 -110.6 186.801 -109 180.801 -106.4z"} - , - {"fill": "#cc7226", - "path":"M168.33 -108.509C169.137 -107.877 170.156 -107.779 170.761 -106.97C170.995 -106.656 170.706 -106.33 170.391 -106.233C169.348 -105.916 168.292 -106.486 167.15 -105.898C166.748 -105.691 166.106 -105.873 165.553 -106.022C163.921 -106.463 162.092 -106.488 160.401 -105.8C158.416 -106.929 156.056 -106.345 153.975 -107.346C153.917 -107.373 153.695 -107.027 153.621 -107.054C150.575 -108.199 146.832 -107.916 144.401 -110.2C141.973 -110.612 139.616 -111.074 137.188 -111.754C135.37 -112.263 133.961 -113.252 132.341 -114.084C130.964 -114.792 129.507 -115.314 127.973 -115.686C126.11 -116.138 124.279 -116.026 122.386 -116.546C122.293 -116.571 122.101 -116.227 122.019 -116.254C121.695 -116.362 121.405 -116.945 121.234 -116.892C119.553 -116.37 118.065 -117.342 116.401 -117C115.223 -118.224 113.495 -117.979 111.949 -118.421C108.985 -119.269 105.831 -117.999 102.801 -119C106.914 -120.842 111.601 -119.61 115.663 -121.679C117.991 -122.865 120.653 -121.763 123.223 -122.523C123.71 -122.667 124.401 -122.869 124.801 -122.2C124.935 -122.335 125.117 -122.574 125.175 -122.546C127.625 -121.389 129.94 -120.115 132.422 -119.049C132.763 -118.903 133.295 -119.135 133.547 -118.933C135.067 -117.717 137.01 -117.82 138.401 -116.6C140.099 -117.102 141.892 -116.722 143.621 -117.346C143.698 -117.373 143.932 -117.032 143.965 -117.054C145.095 -117.802 146.25 -117.531 147.142 -117.227C147.48 -117.112 148.143 -116.865 148.448 -116.791C149.574 -116.515 150.43 -116.035 151.609 -115.852C151.723 -115.834 151.908 -116.174 151.98 -116.146C153.103 -115.708 154.145 -115.764 154.801 -114.6C154.936 -114.735 155.101 -114.973 155.183 -114.946C156.21 -114.608 156.859 -113.853 157.96 -113.612C158.445 -113.506 159.057 -112.88 159.633 -112.704C162.025 -111.973 163.868 -110.444 166.062 -109.549C166.821 -109.239 167.697 -109.005 168.33 -108.509z"} - , - {"fill": "#cc7226", - "path":"M91.696 -122.739C89.178 -124.464 86.81 -125.57 84.368 -127.356C84.187 -127.489 83.827 -127.319 83.625 -127.441C82.618 -128.05 81.73 -128.631 80.748 -129.327C80.209 -129.709 79.388 -129.698 78.88 -129.956C76.336 -131.248 73.707 -131.806 71.2 -133C71.882 -133.638 73.004 -133.394 73.6 -134.2C73.795 -133.92 74.033 -133.636 74.386 -133.827C76.064 -134.731 77.914 -134.884 79.59 -134.794C81.294 -134.702 83.014 -134.397 84.789 -134.125C85.096 -134.078 85.295 -133.555 85.618 -133.458C87.846 -132.795 90.235 -133.32 92.354 -132.482C93.945 -131.853 95.515 -131.03 96.754 -129.755C97.006 -129.495 96.681 -129.194 96.401 -129C96.789 -129.109 97.062 -128.903 97.173 -128.59C97.257 -128.351 97.257 -128.049 97.173 -127.81C97.061 -127.498 96.782 -127.397 96.408 -127.346C95.001 -127.156 96.773 -128.536 96.073 -128.088C94.8 -127.274 95.546 -125.868 94.801 -124.6C94.521 -124.794 94.291 -125.012 94.401 -125.4C94.635 -124.878 94.033 -124.588 93.865 -124.272C93.48 -123.547 92.581 -122.132 91.696 -122.739z"} - , - {"fill": "#cc7226", - "path":"M59.198 -115.391C56.044 -116.185 52.994 -116.07 49.978 -117.346C49.911 -117.374 49.688 -117.027 49.624 -117.054C48.258 -117.648 47.34 -118.614 46.264 -119.66C45.351 -120.548 43.693 -120.161 42.419 -120.648C42.095 -120.772 41.892 -121.284 41.591 -121.323C40.372 -121.48 39.445 -122.429 38.4 -123C40.736 -123.795 43.147 -123.764 45.609 -124.148C45.722 -124.166 45.867 -123.845 46 -123.845C46.136 -123.845 46.266 -124.066 46.4 -124.2C46.595 -123.92 46.897 -123.594 47.154 -123.848C47.702 -124.388 48.258 -124.198 48.798 -124.158C48.942 -124.148 49.067 -123.845 49.2 -123.845C49.336 -123.845 49.467 -124.156 49.6 -124.156C49.736 -124.155 49.867 -123.845 50 -123.845C50.136 -123.845 50.266 -124.066 50.4 -124.2C51.092 -123.418 51.977 -123.972 52.799 -123.793C53.837 -123.566 54.104 -122.418 55.178 -122.12C59.893 -120.816 64.03 -118.671 68.393 -116.584C68.7 -116.437 68.91 -116.189 68.8 -115.8C69.067 -115.8 69.38 -115.888 69.57 -115.756C70.628 -115.024 71.669 -114.476 72.366 -113.378C72.582 -113.039 72.253 -112.632 72.02 -112.684C67.591 -113.679 63.585 -114.287 59.198 -115.391z"} - , - {"fill": "#cc7226", - "path":"M45.338 -71.179C43.746 -72.398 43.162 -74.429 42.034 -76.221C41.82 -76.561 42.094 -76.875 42.411 -76.964C42.971 -77.123 43.514 -76.645 43.923 -76.443C45.668 -75.581 47.203 -74.339 49.2 -74.2C51.19 -71.966 55.45 -71.581 55.457 -68.2C55.458 -67.341 54.03 -68.259 53.6 -67.4C51.149 -68.403 48.76 -68.3 46.38 -69.767C45.763 -70.148 46.093 -70.601 45.338 -71.179z"} - , - {"fill": "#cc7226", - "path":"M17.8 -123.756C17.935 -123.755 24.966 -123.522 24.949 -123.408C24.904 -123.099 17.174 -122.05 16.81 -122.22C16.646 -122.296 9.134 -119.866 9 -120C9.268 -120.135 17.534 -123.756 17.8 -123.756z"} - , - {"fill": "#000000", - "path":"M33.2 -114C33.2 -114 18.4 -112.2 14 -111C9.6 -109.8 -9 -102.2 -12 -100.2C-12 -100.2 -25.4 -94.8 -42.4 -74.8C-42.4 -74.8 -34.8 -78.2 -32.6 -81C-32.6 -81 -19 -93.6 -19.2 -91C-19.2 -91 -7 -99.6 -7.6 -97.4C-7.6 -97.4 16.8 -108.6 14.8 -105.4C14.8 -105.4 36.4 -110 35.4 -108C35.4 -108 54.2 -103.6 51.4 -103.4C51.4 -103.4 45.6 -102.2 52 -98.6C52 -98.6 48.6 -94.2 43.2 -98.2C37.8 -102.2 40.8 -100 35.8 -99C35.8 -99 33.2 -98.2 28.6 -102.2C28.6 -102.2 23 -106.8 14.2 -103.2C14.2 -103.2 -16.4 -90.6 -18.4 -90C-18.4 -90 -22 -87.2 -24.4 -83.6C-24.4 -83.6 -30.2 -79.2 -33.2 -77.8C-33.2 -77.8 -46 -66.2 -47.2 -64.8C-47.2 -64.8 -50.6 -59.6 -51.4 -59.2C-51.4 -59.2 -45 -63 -43 -65C-43 -65 -29 -75 -23.6 -75.8C-23.6 -75.8 -19.2 -78.8 -18.4 -80.2C-18.4 -80.2 -4 -89.4 0.2 -89.4C0.2 -89.4 9.4 -84.2 11.8 -91.2C11.8 -91.2 17.6 -93 23.2 -91.8C23.2 -91.8 26.4 -94.4 25.6 -96.6C25.6 -96.6 27.2 -98.4 28.2 -94.6C28.2 -94.6 31.6 -91 36.4 -93C36.4 -93 40.4 -93.2 38.4 -90.8C38.4 -90.8 34 -87 22.2 -86.8C22.2 -86.8 9.8 -86.2 -6.6 -78.6C-6.6 -78.6 -36.4 -68.2 -45.6 -57.8C-45.6 -57.8 -52 -49 -57.4 -47.8C-57.4 -47.8 -63.2 -47 -69.2 -39.6C-69.2 -39.6 -59.4 -45.4 -50.4 -45.4C-50.4 -45.4 -46.4 -47.8 -50.2 -44.2C-50.2 -44.2 -53.8 -36.6 -52.2 -31.2C-52.2 -31.2 -52.8 -26 -53.6 -24.4C-53.6 -24.4 -61.4 -11.6 -61.4 -9.2C-61.4 -6.8 -60.2 3 -59.8 3.6C-59.4 4.2 -60.8 2 -57 4.4C-53.2 6.8 -50.4 8.4 -49.6 11.2C-48.8 14 -51.6 5.8 -51.8 4C-52 2.2 -56.2 -5 -55.4 -7.4C-55.4 -7.4 -54.4 -6.4 -53.6 -5C-53.6 -5 -54.2 -5.6 -53.6 -9.2C-53.6 -9.2 -52.8 -14.4 -51.4 -17.6C-50 -20.8 -48 -24.6 -47.6 -25.4C-47.2 -26.2 -47.2 -32 -45.8 -29.4L-42.4 -26.8C-42.4 -26.8 -45.2 -29.4 -43 -31.6C-43 -31.6 -44 -37.2 -42.2 -39.8C-42.2 -39.8 -35.2 -48.2 -33.6 -49.2C-32 -50.2 -33.4 -49.8 -33.4 -49.8C-33.4 -49.8 -27.4 -54 -33.2 -52.4C-33.2 -52.4 -37.2 -50.8 -40.2 -50.8C-40.2 -50.8 -47.8 -48.8 -43.8 -53C-39.8 -57.2 -29.8 -62.6 -26 -62.4L-25.2 -60.8L-14 -63.2L-15.2 -62.4C-15.2 -62.4 -15.4 -62.6 -11.2 -63C-7 -63.4 -1.2 -62 0.2 -63.8C1.6 -65.6 5 -66.6 4.6 -65.2C4.2 -63.8 4 -61.8 4 -61.8C4 -61.8 9 -67.6 8.4 -65.4C7.8 -63.2 -0.4 -58 -1.8 -51.8L8.6 -60L12.2 -63C12.2 -63 15.8 -60.8 16 -62.4C16.2 -64 20.8 -69.8 22 -69.6C23.2 -69.4 25.2 -72.2 25 -69.6C24.8 -67 32.4 -61.6 32.4 -61.6C32.4 -61.6 35.6 -63.4 37 -62C38.4 -60.6 42.6 -81.8 42.6 -81.8L67.6 -92.4L111.201 -95.8L94.201 -102.6L33.2 -114z"} - , - {"stroke":"#4c0000", "width":2, - "path":"M51.4 85C51.4 85 36.4 68.2 28 65.6C28 65.6 14.6 58.8 -10 66.6"} - , - {"stroke":"#4c0000", "width":2, - "path":"M24.8 64.2C24.8 64.2 -0.4 56.2 -15.8 60.4C-15.8 60.4 -34.2 62.4 -42.6 76.2"} - , - {"stroke":"#4c0000", "width":2, - "path":"M21.2 63C21.2 63 4.2 55.8 -10.6 53.6C-10.6 53.6 -27.2 51 -43.8 58.2C-43.8 58.2 -56 64.2 -61.4 74.4"} - , - {"stroke":"#4c0000", "width":2, - "path":"M22.2 63.4C22.2 63.4 6.8 52.4 5.8 51C5.8 51 -1.2 40 -14.2 39.6C-14.2 39.6 -35.6 40.4 -52.8 48.4"} - , - {"fill": "#000000", - "path":"M20.895 54.407C22.437 55.87 49.4 84.8 49.4 84.8C84.6 121.401 56.6 87.2 56.6 87.2C49 82.4 39.8 63.6 39.8 63.6C38.6 60.8 53.8 70.8 53.8 70.8C57.8 71.6 71.4 90.8 71.4 90.8C64.6 88.4 69.4 95.6 69.4 95.6C72.2 97.6 92.601 113.201 92.601 113.201C96.201 117.201 100.201 118.801 100.201 118.801C114.201 113.601 107.801 126.801 107.801 126.801C110.201 133.601 115.801 122.001 115.801 122.001C127.001 105.2 110.601 107.601 110.601 107.601C80.6 110.401 73.8 94.4 73.8 94.4C71.4 92 80.2 94.4 80.2 94.4C88.601 96.4 73 82 73 82C75.4 82 84.6 88.8 84.6 88.8C95.001 98 97.001 96 97.001 96C115.001 87.2 125.401 94.8 125.401 94.8C127.401 96.4 121.801 103.2 123.401 108.401C125.001 113.601 129.801 126.001 129.801 126.001C127.401 127.601 127.801 138.401 127.801 138.401C144.601 161.601 135.001 159.601 135.001 159.601C119.401 159.201 134.201 166.801 134.201 166.801C137.401 168.801 146.201 176.001 146.201 176.001C143.401 174.801 141.801 180.001 141.801 180.001C146.601 184.001 143.801 188.801 143.801 188.801C137.801 190.001 136.601 194.001 136.601 194.001C143.401 202.001 133.401 202.401 133.401 202.401C137.001 206.801 132.201 218.801 132.201 218.801C127.401 218.801 121.001 224.401 121.001 224.401C123.401 229.201 113.001 234.801 113.001 234.801C104.601 236.401 107.401 243.201 107.401 243.201C99.401 249.201 97.001 265.201 97.001 265.201C96.201 275.601 93.801 278.801 99.001 276.801C104.201 274.801 103.401 262.401 103.401 262.401C98.601 246.801 141.401 230.801 141.401 230.801C145.401 229.201 146.201 224.001 146.201 224.001C148.201 224.401 157.001 232.001 157.001 232.001C164.601 243.201 165.001 234.001 165.001 234.001C166.201 230.401 164.601 224.401 164.601 224.401C170.601 202.801 156.601 196.401 156.601 196.401C146.601 162.801 160.601 171.201 160.601 171.201C163.401 176.801 174.201 182.001 174.201 182.001L177.801 179.601C176.201 174.801 184.601 168.801 184.601 168.801C187.401 175.201 193.401 167.201 193.401 167.201C197.001 142.801 209.401 157.201 209.401 157.201C213.401 158.401 214.601 151.601 214.601 151.601C218.201 141.201 214.601 127.601 214.601 127.601C218.201 127.201 227.801 133.201 227.801 133.201C230.601 129.601 221.401 112.801 225.401 115.201C229.401 117.601 233.801 119.201 233.801 119.201C234.601 117.201 224.601 104.801 224.601 104.801C220.201 102 215.001 81.6 215.001 81.6C222.201 85.2 212.201 70 212.201 70C212.201 66.8 218.201 55.6 218.201 55.6C217.401 48.8 218.201 49.2 218.201 49.2C221.001 50.4 229.001 52 222.201 45.6C215.401 39.2 223.001 34.4 223.001 34.4C227.401 31.6 213.801 32 213.801 32C208.601 27.6 209.001 23.6 209.001 23.6C217.001 25.6 202.601 11.2 200.201 7.6C197.801 4 207.401 -1.2 207.401 -1.2C220.601 -4.8 209.001 -8 209.001 -8C189.401 -7.6 200.201 -18.4 200.201 -18.4C206.201 -18 204.601 -20.4 204.601 -20.4C199.401 -21.6 189.801 -28 189.801 -28C185.801 -31.6 189.401 -30.8 189.401 -30.8C206.201 -29.6 177.401 -40.8 177.401 -40.8C185.401 -40.8 167.401 -51.2 167.401 -51.2C165.401 -52.8 162.201 -60.4 162.201 -60.4C156.201 -65.6 151.401 -72.4 151.401 -72.4C151.001 -76.8 146.201 -81.6 146.201 -81.6C134.601 -95.2 129.001 -94.8 129.001 -94.8C114.201 -98.4 109.001 -97.6 109.001 -97.6L56.2 -93.2C29.8 -80.4 37.6 -59.4 37.6 -59.4C44 -51 53.2 -54.8 53.2 -54.8C57.8 -61 69.4 -58.8 69.4 -58.8C89.801 -55.6 87.201 -59.2 87.201 -59.2C84.801 -63.8 68.6 -70 68.4 -70.6C68.2 -71.2 59.4 -74.6 59.4 -74.6C56.4 -75.8 52 -85 52 -85C48.8 -88.4 64.6 -82.6 64.6 -82.6C63.4 -81.6 70.8 -77.6 70.8 -77.6C88.201 -78.6 98.801 -67.8 98.801 -67.8C109.601 -51.2 109.801 -59.4 109.801 -59.4C112.601 -68.8 100.801 -90 100.801 -90C101.201 -92 109.401 -85.4 109.401 -85.4C110.801 -87.4 111.601 -81.6 111.601 -81.6C111.801 -79.2 115.601 -71.2 115.601 -71.2C118.401 -58.2 122.001 -65.6 122.001 -65.6L126.601 -56.2C128.001 -53.6 122.001 -46 122.001 -46C121.801 -43.2 122.601 -43.4 117.001 -35.8C111.401 -28.2 114.801 -23.8 114.801 -23.8C113.401 -17.2 122.201 -17.6 122.201 -17.6C124.801 -15.4 128.201 -15.4 128.201 -15.4C130.001 -13.4 132.401 -14 132.401 -14C134.001 -17.8 140.201 -15.8 140.201 -15.8C141.601 -18.2 149.801 -18.6 149.801 -18.6C150.801 -21.2 151.201 -22.8 154.601 -23.4C158.001 -24 133.401 -67 133.401 -67C139.801 -67.8 131.601 -80.2 131.601 -80.2C129.401 -86.8 140.801 -72.2 143.001 -70.8C145.201 -69.4 146.201 -67.2 144.601 -67.4C143.001 -67.6 141.201 -65.4 142.601 -65.2C144.001 -65 157.001 -50 160.401 -39.8C163.801 -29.6 169.801 -25.6 176.001 -19.6C182.201 -13.6 181.401 10.6 181.401 10.6C181.001 19.4 187.001 30 187.001 30C189.001 33.8 184.801 52 184.801 52C182.801 54.2 184.201 55 184.201 55C185.201 56.2 192.001 69.4 192.001 69.4C190.201 69.2 193.801 72.8 193.801 72.8C199.001 78.8 192.601 75.8 192.601 75.8C186.601 74.2 193.601 84 193.601 84C194.801 85.8 185.801 81.2 185.801 81.2C176.601 80.6 188.201 87.8 188.201 87.8C196.801 95 185.401 90.6 185.401 90.6C180.801 88.8 184.001 95.6 184.001 95.6C187.201 97.2 204.401 104.2 204.401 104.2C204.801 108.001 201.801 113.001 201.801 113.001C202.201 117.001 200.001 120.401 200.001 120.401C198.801 128.601 198.201 129.401 198.201 129.401C194.001 129.601 186.601 143.401 186.601 143.401C184.801 146.001 174.601 158.001 174.601 158.001C172.601 165.001 154.601 157.801 154.601 157.801C148.001 161.201 150.001 157.801 150.001 157.801C149.601 155.601 154.401 149.601 154.401 149.601C161.401 147.001 158.801 136.201 158.801 136.201C162.801 134.801 151.601 132.001 151.801 130.801C152.001 129.601 157.801 128.201 157.801 128.201C165.801 126.201 161.401 123.801 161.401 123.801C160.801 119.801 163.801 114.201 163.801 114.201C175.401 113.401 163.801 97.2 163.801 97.2C153.001 89.6 152.001 83.8 152.001 83.8C164.601 75.6 156.401 63.2 156.601 59.6C156.801 56 158.001 34.4 158.001 34.4C156.001 28.2 153.001 14.6 153.001 14.6C155.201 9.4 162.601 -3.2 162.601 -3.2C165.401 -7.4 174.201 -12.2 172.001 -15.2C169.801 -18.2 162.001 -16.4 162.001 -16.4C154.201 -17.8 154.801 -12.6 154.801 -12.6C153.201 -11.6 152.401 -6.6 152.401 -6.6C151.68 1.333 142.801 7.6 142.801 7.6C131.601 13.8 140.801 17.8 140.801 17.8C146.801 24.4 137.001 24.6 137.001 24.6C126.001 22.8 134.201 33 134.201 33C145.001 45.8 142.001 48.6 142.001 48.6C131.801 49.6 144.401 58.8 144.401 58.8C144.401 58.8 143.601 56.8 143.801 58.6C144.001 60.4 147.001 64.6 147.801 66.6C148.601 68.6 144.601 68.8 144.601 68.8C145.201 78.4 129.801 74.2 129.801 74.2C129.801 74.2 129.801 74.2 128.201 74.4C126.601 74.6 115.401 73.8 109.601 71.6C103.801 69.4 97.001 69.4 97.001 69.4C97.001 69.4 93.001 71.2 85.4 71C77.8 70.8 69.8 73.6 69.8 73.6C65.4 73.2 74 68.8 74.2 69C74.4 69.2 80 63.6 72 64.2C50.203 65.835 39.4 55.6 39.4 55.6C37.4 54.2 34.8 51.4 34.8 51.4C24.8 49.4 36.2 63.8 36.2 63.8C37.4 65.2 36 66.2 36 66.2C35.2 64.6 27.4 59.2 27.4 59.2C24.589 58.227 23.226 56.893 20.895 54.407z"} - , - {"fill": "#4c0000", - "path":"M-3 42.8C-3 42.8 8.6 48.4 11.2 51.2C13.8 54 27.8 65.4 27.8 65.4C27.8 65.4 22.4 63.4 19.8 61.6C17.2 59.8 6.4 51.6 6.4 51.6C6.4 51.6 2.6 45.6 -3 42.8z"} - , - {"fill": "#99cc32", - "path":"M-61.009 11.603C-60.672 11.455 -61.196 8.743 -61.4 8.2C-62.422 5.474 -71.4 4 -71.4 4C-71.627 5.365 -71.682 6.961 -71.576 8.599C-71.576 8.599 -66.708 14.118 -61.009 11.603z"} - , - {"fill": "#659900", - "path":"M-61.009 11.403C-61.458 11.561 -61.024 8.669 -61.2 8.2C-62.222 5.474 -71.4 3.9 -71.4 3.9C-71.627 5.265 -71.682 6.861 -71.576 8.499C-71.576 8.499 -67.308 13.618 -61.009 11.403z"} - , - {"fill": "#000000", - "path":"M-65.4 11.546C-66.025 11.546 -66.531 10.406 -66.531 9C-66.531 7.595 -66.025 6.455 -65.4 6.455C-64.775 6.455 -64.268 7.595 -64.268 9C-64.268 10.406 -64.775 11.546 -65.4 11.546z"} - , - {"fill": "#000000", - "path":"M-65.4 9z"} - , - {"fill": "#000000", - "path":"M-111 109.601C-111 109.601 -116.6 119.601 -91.8 113.601C-91.8 113.601 -77.8 112.401 -75.4 110.001C-74.2 110.801 -65.834 113.734 -63 114.401C-56.2 116.001 -47.8 106 -47.8 106C-47.8 106 -43.2 95.5 -40.4 95.5C-37.6 95.5 -40.8 97.1 -40.8 97.1C-40.8 97.1 -47.4 107.201 -47 108.801C-47 108.801 -52.2 128.801 -68.2 129.601C-68.2 129.601 -84.35 130.551 -83 136.401C-83 136.401 -74.2 134.001 -71.8 136.401C-71.8 136.401 -61 136.001 -69 142.401L-75.8 154.001C-75.8 154.001 -75.66 157.919 -85.8 154.401C-95.6 151.001 -105.9 138.101 -105.9 138.101C-105.9 138.101 -121.85 123.551 -111 109.601z"} - , - {"fill": "#e59999", - "path":"M-112.2 113.601C-112.2 113.601 -114.2 123.201 -77.4 112.801C-77.4 112.801 -73 112.801 -70.6 113.601C-68.2 114.401 -56.2 117.201 -54.2 116.001C-54.2 116.001 -61.4 129.601 -73 128.001C-73 128.001 -86.2 129.601 -85.8 134.401C-85.8 134.401 -81.8 141.601 -77 144.001C-77 144.001 -74.2 146.401 -74.6 149.601C-75 152.801 -77.8 154.401 -79.8 155.201C-81.8 156.001 -85 152.801 -86.6 152.801C-88.2 152.801 -96.6 146.401 -101 141.601C-105.4 136.801 -113.8 124.801 -113.4 122.001C-113 119.201 -112.2 113.601 -112.2 113.601z"} - , - {"fill": "#b26565", - "path":"M-109 131.051C-106.4 135.001 -103.2 139.201 -101 141.601C-96.6 146.401 -88.2 152.801 -86.6 152.801C-85 152.801 -81.8 156.001 -79.8 155.201C-77.8 154.401 -75 152.801 -74.6 149.601C-74.2 146.401 -77 144.001 -77 144.001C-80.066 142.468 -82.806 138.976 -84.385 136.653C-84.385 136.653 -84.2 139.201 -89.4 138.401C-94.6 137.601 -99.8 134.801 -101.4 131.601C-103 128.401 -105.4 126.001 -103.8 129.601C-102.2 133.201 -99.8 136.801 -98.2 137.201C-96.6 137.601 -97 138.801 -99.4 138.401C-101.8 138.001 -104.6 137.601 -109 132.401z"} - , - {"fill": "#992600", - "path":"M-111.6 110.001C-111.6 110.001 -109.8 96.4 -108.6 92.4C-108.6 92.4 -109.4 85.6 -107 81.4C-104.6 77.2 -102.6 71 -99.6 65.6C-96.6 60.2 -96.4 56.2 -92.4 54.6C-88.4 53 -82.4 44.4 -79.6 43.4C-76.8 42.4 -77 43.2 -77 43.2C-77 43.2 -70.2 28.4 -56.6 32.4C-56.6 32.4 -72.8 29.6 -57 20.2C-57 20.2 -61.8 21.3 -58.5 14.3C-56.299 9.632 -56.8 16.4 -67.8 28.2C-67.8 28.2 -72.8 36.8 -78 39.8C-83.2 42.8 -95.2 49.8 -96.4 53.6C-97.6 57.4 -100.8 63.2 -102.8 64.8C-104.8 66.4 -107.6 70.6 -108 74C-108 74 -109.2 78 -110.6 79.2C-112 80.4 -112.2 83.6 -112.2 85.6C-112.2 87.6 -114.2 90.4 -114 92.8C-114 92.8 -113.2 111.801 -113.6 113.801L-111.6 110.001z"} - , - {"fill": "#ffffff", - "path":"M-120.2 114.601C-120.2 114.601 -122.2 113.201 -126.6 119.201C-126.6 119.201 -119.3 152.201 -119.3 153.601C-119.3 153.601 -118.2 151.501 -119.5 144.301C-120.8 137.101 -121.7 124.401 -121.7 124.401L-120.2 114.601z"} - , - {"fill": "#992600", - "path":"M-98.6 54C-98.6 54 -116.2 57.2 -115.8 86.4L-116.6 111.201C-116.6 111.201 -117.8 85.6 -119 84C-120.2 82.4 -116.2 71.2 -119.4 77.2C-119.4 77.2 -133.4 91.2 -125.4 112.401C-125.4 112.401 -123.9 115.701 -126.9 111.101C-126.9 111.101 -131.5 98.5 -130.4 92.1C-130.4 92.1 -130.2 89.9 -128.3 87.1C-128.3 87.1 -119.7 75.4 -117 73.1C-117 73.1 -115.2 58.7 -99.8 53.5C-99.8 53.5 -94.1 51.2 -98.6 54z"} - , - {"fill": "#000000", - "path":"M40.8 -12.2C41.46 -12.554 41.451 -13.524 42.031 -13.697C43.18 -14.041 43.344 -15.108 43.862 -15.892C44.735 -17.211 44.928 -18.744 45.51 -20.235C45.782 -20.935 45.809 -21.89 45.496 -22.55C44.322 -25.031 43.62 -27.48 42.178 -29.906C41.91 -30.356 41.648 -31.15 41.447 -31.748C40.984 -33.132 39.727 -34.123 38.867 -35.443C38.579 -35.884 39.104 -36.809 38.388 -36.893C37.491 -36.998 36.042 -37.578 35.809 -36.552C35.221 -33.965 36.232 -31.442 37.2 -29C36.418 -28.308 36.752 -27.387 36.904 -26.62C37.614 -23.014 36.416 -19.662 35.655 -16.188C35.632 -16.084 35.974 -15.886 35.946 -15.824C34.724 -13.138 33.272 -10.693 31.453 -8.312C30.695 -7.32 29.823 -6.404 29.326 -5.341C28.958 -4.554 28.55 -3.588 28.8 -2.6C25.365 0.18 23.115 4.025 20.504 7.871C20.042 8.551 20.333 9.76 20.884 10.029C21.697 10.427 22.653 9.403 23.123 8.557C23.512 7.859 23.865 7.209 24.356 6.566C24.489 6.391 24.31 5.972 24.445 5.851C27.078 3.504 28.747 0.568 31.2 -1.8C33.15 -2.129 34.687 -3.127 36.435 -4.14C36.743 -4.319 37.267 -4.07 37.557 -4.265C39.31 -5.442 39.308 -7.478 39.414 -9.388C39.464 -10.272 39.66 -11.589 40.8 -12.2z"} - , - {"fill": "#000000", - "path":"M31.959 -16.666C32.083 -16.743 31.928 -17.166 32.037 -17.382C32.199 -17.706 32.602 -17.894 32.764 -18.218C32.873 -18.434 32.71 -18.814 32.846 -18.956C35.179 -21.403 35.436 -24.427 34.4 -27.4C35.424 -28.02 35.485 -29.282 35.06 -30.129C34.207 -31.829 34.014 -33.755 33.039 -35.298C32.237 -36.567 30.659 -37.811 29.288 -36.508C28.867 -36.108 28.546 -35.321 28.824 -34.609C28.888 -34.446 29.173 -34.3 29.146 -34.218C29.039 -33.894 28.493 -33.67 28.487 -33.398C28.457 -31.902 27.503 -30.391 28.133 -29.062C28.905 -27.433 29.724 -25.576 30.4 -23.8C29.166 -21.684 30.199 -19.235 28.446 -17.358C28.31 -17.212 28.319 -16.826 28.441 -16.624C28.733 -16.138 29.139 -15.732 29.625 -15.44C29.827 -15.319 30.175 -15.317 30.375 -15.441C30.953 -15.803 31.351 -16.29 31.959 -16.666z"} - , - {"fill": "#000000", - "path":"M94.771 -26.977C96.16 -25.185 96.45 -22.39 94.401 -21C94.951 -17.691 98.302 -19.67 100.401 -20.2C100.292 -20.588 100.519 -20.932 100.802 -20.937C101.859 -20.952 102.539 -21.984 103.601 -21.8C104.035 -23.357 105.673 -24.059 106.317 -25.439C108.043 -29.134 107.452 -33.407 104.868 -36.653C104.666 -36.907 104.883 -37.424 104.759 -37.786C104.003 -39.997 101.935 -40.312 100.001 -41C98.824 -44.875 98.163 -48.906 96.401 -52.6C94.787 -52.85 94.089 -54.589 92.752 -55.309C91.419 -56.028 90.851 -54.449 90.892 -53.403C90.899 -53.198 91.351 -52.974 91.181 -52.609C91.105 -52.445 90.845 -52.334 90.845 -52.2C90.846 -52.065 91.067 -51.934 91.201 -51.8C90.283 -50.98 88.86 -50.503 88.565 -49.358C87.611 -45.648 90.184 -42.523 91.852 -39.322C92.443 -38.187 91.707 -36.916 90.947 -35.708C90.509 -35.013 90.617 -33.886 90.893 -33.03C91.645 -30.699 93.236 -28.96 94.771 -26.977z"} - , - {"fill": "#000000", - "path":"M57.611 -8.591C56.124 -6.74 52.712 -4.171 55.629 -2.243C55.823 -2.114 56.193 -2.11 56.366 -2.244C58.387 -3.809 60.39 -4.712 62.826 -5.294C62.95 -5.323 63.224 -4.856 63.593 -5.017C65.206 -5.72 67.216 -5.662 68.4 -7C72.167 -6.776 75.732 -7.892 79.123 -9.2C80.284 -9.648 81.554 -10.207 82.755 -10.709C84.131 -11.285 85.335 -12.213 86.447 -13.354C86.58 -13.49 86.934 -13.4 87.201 -13.4C87.161 -14.263 88.123 -14.39 88.37 -15.012C88.462 -15.244 88.312 -15.64 88.445 -15.742C90.583 -17.372 91.503 -19.39 90.334 -21.767C90.049 -22.345 89.8 -22.963 89.234 -23.439C88.149 -24.35 87.047 -23.496 86 -23.8C85.841 -23.172 85.112 -23.344 84.726 -23.146C83.867 -22.707 82.534 -23.292 81.675 -22.854C80.313 -22.159 79.072 -21.99 77.65 -21.613C77.338 -21.531 76.56 -21.627 76.4 -21C76.266 -21.134 76.118 -21.368 76.012 -21.346C74.104 -20.95 72.844 -20.736 71.543 -19.044C71.44 -18.911 70.998 -19.09 70.839 -18.955C69.882 -18.147 69.477 -16.913 68.376 -16.241C68.175 -16.118 67.823 -16.286 67.629 -16.157C66.983 -15.726 66.616 -15.085 65.974 -14.638C65.645 -14.409 65.245 -14.734 65.277 -14.99C65.522 -16.937 66.175 -18.724 65.6 -20.6C67.677 -23.12 70.194 -25.069 72 -27.8C72.015 -29.966 72.707 -32.112 72.594 -34.189C72.584 -34.382 72.296 -35.115 72.17 -35.462C71.858 -36.316 72.764 -37.382 71.92 -38.106C70.516 -39.309 69.224 -38.433 68.4 -37C66.562 -36.61 64.496 -35.917 62.918 -37.151C61.911 -37.938 61.333 -38.844 60.534 -39.9C59.549 -41.202 59.884 -42.638 59.954 -44.202C59.96 -44.33 59.645 -44.466 59.645 -44.6C59.646 -44.735 59.866 -44.866 60 -45C59.294 -45.626 59.019 -46.684 58 -47C58.305 -48.092 57.629 -48.976 56.758 -49.278C54.763 -49.969 53.086 -48.057 51.194 -47.984C50.68 -47.965 50.213 -49.003 49.564 -49.328C49.132 -49.544 48.428 -49.577 48.066 -49.311C47.378 -48.807 46.789 -48.693 46.031 -48.488C44.414 -48.052 43.136 -46.958 41.656 -46.103C40.171 -45.246 39.216 -43.809 38.136 -42.489C37.195 -41.337 37.059 -38.923 38.479 -38.423C40.322 -37.773 41.626 -40.476 43.592 -40.15C43.904 -40.099 44.11 -39.788 44 -39.4C44.389 -39.291 44.607 -39.52 44.8 -39.8C45.658 -38.781 46.822 -38.444 47.76 -37.571C48.73 -36.667 50.476 -37.085 51.491 -36.088C53.02 -34.586 52.461 -31.905 54.4 -30.6C53.814 -29.287 53.207 -28.01 52.872 -26.583C52.59 -25.377 53.584 -24.18 54.795 -24.271C56.053 -24.365 56.315 -25.124 56.8 -26.2C57.067 -25.933 57.536 -25.636 57.495 -25.42C57.038 -23.033 56.011 -21.04 55.553 -18.609C55.494 -18.292 55.189 -18.09 54.8 -18.2C54.332 -14.051 50.28 -11.657 47.735 -8.492C47.332 -7.99 47.328 -6.741 47.737 -6.338C49.14 -4.951 51.1 -6.497 52.8 -7C53.013 -8.206 53.872 -9.148 55.204 -9.092C55.46 -9.082 55.695 -9.624 56.019 -9.754C56.367 -9.892 56.869 -9.668 57.155 -9.866C58.884 -11.061 60.292 -12.167 62.03 -13.356C62.222 -13.487 62.566 -13.328 62.782 -13.436C63.107 -13.598 63.294 -13.985 63.617 -14.17C63.965 -14.37 64.207 -14.08 64.4 -13.8C63.754 -13.451 63.75 -12.494 63.168 -12.292C62.393 -12.024 61.832 -11.511 61.158 -11.064C60.866 -10.871 60.207 -11.119 60.103 -10.94C59.505 -9.912 58.321 -9.474 57.611 -8.591z"} - , - {"fill": "#000000", - "path":"M2.2 -58C2.2 -58 -7.038 -60.872 -18.2 -35.2C-18.2 -35.2 -20.6 -30 -23 -28C-25.4 -26 -36.6 -22.4 -38.6 -18.4L-49 -2.4C-49 -2.4 -34.2 -18.4 -31 -20.8C-31 -20.8 -23 -29.2 -26.2 -22.4C-26.2 -22.4 -40.2 -11.6 -39 -2.4C-39 -2.4 -44.6 12 -45.4 14C-45.4 14 -29.4 -18 -27 -19.2C-24.6 -20.4 -23.4 -20.4 -24.6 -16.8C-25.8 -13.2 -26.2 3.2 -29 5.2C-29 5.2 -21 -15.2 -21.8 -18.4C-21.8 -18.4 -18.6 -22 -16.2 -16.8L-17.4 -0.8L-13 11.2C-13 11.2 -15.4 0 -13.8 -15.6C-13.8 -15.6 -15.8 -26 -11.8 -20.4C-7.8 -14.8 1.8 -8.8 1.8 -4C1.8 -4 -3.4 -21.6 -12.6 -26.4L-16.6 -20.4L-17.8 -22.4C-17.8 -22.4 -21.4 -23.2 -17 -30C-12.6 -36.8 -13 -37.6 -13 -37.6C-13 -37.6 -6.6 -30.4 -5 -30.4C-5 -30.4 8.2 -38 9.4 -13.6C9.4 -13.6 16.2 -28 7 -34.8C7 -34.8 -7.8 -36.8 -6.6 -42L0.6 -54.4C4.2 -59.6 2.6 -56.8 2.6 -56.8z"} - , - {"fill": "#000000", - "path":"M-17.8 -41.6C-17.8 -41.6 -30.6 -41.6 -33.8 -36.4L-41 -26.8C-41 -26.8 -23.8 -36.8 -19.8 -38C-15.8 -39.2 -17.8 -41.6 -17.8 -41.6z"} - , - {"fill": "#000000", - "path":"M-57.8 -35.2C-57.8 -35.2 -59.8 -34 -60.2 -31.2C-60.6 -28.4 -63 -28 -62.2 -25.2C-61.4 -22.4 -59.4 -20 -59.4 -24C-59.4 -28 -57.8 -30 -57 -31.2C-56.2 -32.4 -54.6 -36.8 -57.8 -35.2z"} - , - {"fill": "#000000", - "path":"M-66.6 26C-66.6 26 -75 22 -78.2 18.4C-81.4 14.8 -80.948 19.966 -85.8 19.6C-91.647 19.159 -90.6 3.2 -90.6 3.2L-94.6 10.8C-94.6 10.8 -95.8 25.2 -87.8 22.8C-83.893 21.628 -82.6 23.2 -84.2 24C-85.8 24.8 -78.6 25.2 -81.4 26.8C-84.2 28.4 -69.8 23.2 -72.2 33.6L-66.6 26z"} - , - {"fill": "#000000", - "path":"M-79.2 40.4C-79.2 40.4 -94.6 44.8 -98.2 35.2C-98.2 35.2 -103 37.6 -100.8 40.6C-98.6 43.6 -97.4 44 -97.4 44C-97.4 44 -92 45.2 -92.6 46C-93.2 46.8 -95.6 50.2 -95.6 50.2C-95.6 50.2 -85.4 44.2 -79.2 40.4z"} - , - {"fill": "#ffffff", - "path":"M149.201 118.601C148.774 120.735 147.103 121.536 145.201 122.201C143.284 121.243 140.686 118.137 138.801 120.201C138.327 119.721 137.548 119.661 137.204 118.999C136.739 118.101 137.011 117.055 136.669 116.257C136.124 114.985 135.415 113.619 135.601 112.201C137.407 111.489 138.002 109.583 137.528 107.82C137.459 107.563 137.03 107.366 137.23 107.017C137.416 106.694 137.734 106.467 138.001 106.2C137.866 106.335 137.721 106.568 137.61 106.548C137 106.442 137.124 105.805 137.254 105.418C137.839 103.672 139.853 103.408 141.201 104.6C141.457 104.035 141.966 104.229 142.401 104.2C142.351 103.621 142.759 103.094 142.957 102.674C143.475 101.576 145.104 102.682 145.901 102.07C146.977 101.245 148.04 100.546 149.118 101.149C150.927 102.162 152.636 103.374 153.835 105.115C154.41 105.949 154.65 107.23 154.592 108.188C154.554 108.835 153.173 108.483 152.83 109.412C152.185 111.16 154.016 111.679 154.772 113.017C154.97 113.366 154.706 113.67 154.391 113.768C153.98 113.896 153.196 113.707 153.334 114.16C154.306 117.353 151.55 118.031 149.201 118.601z"} - , - {"fill": "#ffffff", - "path":"M139.6 138.201C139.593 136.463 137.992 134.707 139.201 133.001C139.336 133.135 139.467 133.356 139.601 133.356C139.736 133.356 139.867 133.135 140.001 133.001C141.496 135.217 145.148 136.145 145.006 138.991C144.984 139.438 143.897 140.356 144.801 141.001C142.988 142.349 142.933 144.719 142.001 146.601C140.763 146.315 139.551 145.952 138.401 145.401C138.753 143.915 138.636 142.231 139.456 140.911C139.89 140.213 139.603 139.134 139.6 138.201z"} - , - {"fill": "#cccccc", - "path":"M-26.6 129.201C-26.6 129.201 -43.458 139.337 -29.4 124.001C-20.6 114.401 -10.6 108.801 -10.6 108.801C-10.6 108.801 -0.2 104.4 3.4 103.2C7 102 22.2 96.8 25.4 96.4C28.6 96 38.2 92 45 96C51.8 100 59.8 104.4 59.8 104.4C59.8 104.4 43.4 96 39.8 98.4C36.2 100.8 29 100.4 23 103.6C23 103.6 8.2 108.001 5 110.001C1.8 112.001 -8.6 123.601 -10.2 122.801C-11.8 122.001 -9.8 121.601 -8.6 118.801C-7.4 116.001 -9.4 114.401 -17.4 120.801C-25.4 127.201 -26.6 129.201 -26.6 129.201z"} - , - {"fill": "#000000", - "path":"M-19.195 123.234C-19.195 123.234 -17.785 110.194 -9.307 111.859C-9.307 111.859 -1.081 107.689 1.641 105.721C1.641 105.721 9.78 104.019 11.09 103.402C29.569 94.702 44.288 99.221 44.835 98.101C45.381 96.982 65.006 104.099 68.615 108.185C69.006 108.628 58.384 102.588 48.686 100.697C40.413 99.083 18.811 100.944 7.905 106.48C4.932 107.989 -4.013 113.773 -6.544 113.662C-9.075 113.55 -19.195 123.234 -19.195 123.234z"} - , - {"fill": "#cccccc", - "path":"M-23 148.801C-23 148.801 -38.2 146.401 -21.4 144.801C-21.4 144.801 -3.4 142.801 0.6 137.601C0.6 137.601 14.2 128.401 17 128.001C19.8 127.601 49.8 120.401 50.2 118.001C50.6 115.601 56.2 115.601 57.8 116.401C59.4 117.201 58.6 118.401 55.8 119.201C53 120.001 21.8 136.401 15.4 137.601C9 138.801 -2.6 146.401 -7.4 147.601C-12.2 148.801 -23 148.801 -23 148.801z"} - , - {"fill": "#000000", - "path":"M-3.48 141.403C-3.48 141.403 -12.062 140.574 -3.461 139.755C-3.461 139.755 5.355 136.331 7.403 133.668C7.403 133.668 14.367 128.957 15.8 128.753C17.234 128.548 31.194 124.861 31.399 123.633C31.604 122.404 65.67 109.823 70.09 113.013C73.001 115.114 63.1 113.437 53.466 117.847C52.111 118.467 18.258 133.054 14.981 133.668C11.704 134.283 5.765 138.174 3.307 138.788C0.85 139.403 -3.48 141.403 -3.48 141.403z"} - , - {"fill": "#000000", - "path":"M-11.4 143.601C-11.4 143.601 -6.2 143.201 -7.4 144.801C-8.6 146.401 -11 145.601 -11 145.601L-11.4 143.601z"} - , - {"fill": "#000000", - "path":"M-18.6 145.201C-18.6 145.201 -13.4 144.801 -14.6 146.401C-15.8 148.001 -18.2 147.201 -18.2 147.201L-18.6 145.201z"} - , - {"fill": "#000000", - "path":"M-29 146.801C-29 146.801 -23.8 146.401 -25 148.001C-26.2 149.601 -28.6 148.801 -28.6 148.801L-29 146.801z"} - , - {"fill": "#000000", - "path":"M-36.6 147.601C-36.6 147.601 -31.4 147.201 -32.6 148.801C-33.8 150.401 -36.2 149.601 -36.2 149.601L-36.6 147.601z"} - , - {"fill": "#000000", - "path":"M1.8 108.001C1.8 108.001 6.2 108.001 5 109.601C3.8 111.201 0.6 110.801 0.6 110.801L1.8 108.001z"} - , - {"fill": "#000000", - "path":"M-8.2 113.601C-8.2 113.601 -1.694 111.46 -4.2 114.801C-5.4 116.401 -7.8 115.601 -7.8 115.601L-8.2 113.601z"} - , - {"fill": "#000000", - "path":"M-19.4 118.401C-19.4 118.401 -14.2 118.001 -15.4 119.601C-16.6 121.201 -19 120.401 -19 120.401L-19.4 118.401z"} - , - {"fill": "#000000", - "path":"M-27 124.401C-27 124.401 -21.8 124.001 -23 125.601C-24.2 127.201 -26.6 126.401 -26.6 126.401L-27 124.401z"} - , - {"fill": "#000000", - "path":"M-33.8 129.201C-33.8 129.201 -28.6 128.801 -29.8 130.401C-31 132.001 -33.4 131.201 -33.4 131.201L-33.8 129.201z"} - , - {"fill": "#000000", - "path":"M5.282 135.598C5.282 135.598 12.203 135.066 10.606 137.195C9.009 139.325 5.814 138.26 5.814 138.26L5.282 135.598z"} - , - {"fill": "#000000", - "path":"M15.682 130.798C15.682 130.798 22.603 130.266 21.006 132.395C19.409 134.525 16.214 133.46 16.214 133.46L15.682 130.798z"} - , - {"fill": "#000000", - "path":"M26.482 126.398C26.482 126.398 33.403 125.866 31.806 127.995C30.209 130.125 27.014 129.06 27.014 129.06L26.482 126.398z"} - , - {"fill": "#000000", - "path":"M36.882 121.598C36.882 121.598 43.803 121.066 42.206 123.195C40.609 125.325 37.414 124.26 37.414 124.26L36.882 121.598z"} - , - {"fill": "#000000", - "path":"M9.282 103.598C9.282 103.598 16.203 103.066 14.606 105.195C13.009 107.325 9.014 107.06 9.014 107.06L9.282 103.598z"} - , - {"fill": "#000000", - "path":"M19.282 100.398C19.282 100.398 26.203 99.866 24.606 101.995C23.009 104.125 18.614 103.86 18.614 103.86L19.282 100.398z"} - , - {"fill": "#000000", - "path":"M-3.4 140.401C-3.4 140.401 1.8 140.001 0.6 141.601C-0.6 143.201 -3 142.401 -3 142.401L-3.4 140.401z"} - , - {"fill": "#992600", - "path":"M-76.6 41.2C-76.6 41.2 -81 50 -81.4 53.2C-81.4 53.2 -80.6 44.4 -79.4 42.4C-78.2 40.4 -76.6 41.2 -76.6 41.2z"} - , - {"fill": "#992600", - "path":"M-95 55.2C-95 55.2 -98.2 69.6 -97.8 72.4C-97.8 72.4 -99 60.8 -98.6 59.6C-98.2 58.4 -95 55.2 -95 55.2z"} - , - {"fill": "#cccccc", - "path":"M-74.2 -19.4L-74.4 -16.2L-76.6 -16C-76.6 -16 -62.4 -3.4 -61.8 4.2C-61.8 4.2 -61 -4 -74.2 -19.4z"} - , - {"fill": "#000000", - "path":"M-70.216 -18.135C-70.647 -18.551 -70.428 -19.296 -70.836 -19.556C-71.645 -20.072 -69.538 -20.129 -69.766 -20.845C-70.149 -22.051 -69.962 -22.072 -70.084 -23.348C-70.141 -23.946 -69.553 -25.486 -69.168 -25.926C-67.722 -27.578 -69.046 -30.51 -67.406 -32.061C-67.102 -32.35 -66.726 -32.902 -66.441 -33.32C-65.782 -34.283 -64.598 -34.771 -63.648 -35.599C-63.33 -35.875 -63.531 -36.702 -62.962 -36.61C-62.248 -36.495 -61.007 -36.625 -61.052 -35.784C-61.165 -33.664 -62.494 -31.944 -63.774 -30.276C-63.323 -29.572 -63.781 -28.937 -64.065 -28.38C-65.4 -25.76 -65.211 -22.919 -65.385 -20.079C-65.39 -19.994 -65.697 -19.916 -65.689 -19.863C-65.336 -17.528 -64.752 -15.329 -63.873 -13.1C-63.507 -12.17 -63.036 -11.275 -62.886 -10.348C-62.775 -9.662 -62.672 -8.829 -63.08 -8.124C-61.045 -5.234 -62.354 -2.583 -61.185 0.948C-60.978 1.573 -59.286 3.487 -59.749 3.326C-62.262 2.455 -62.374 2.057 -62.551 1.304C-62.697 0.681 -63.027 -0.696 -63.264 -1.298C-63.328 -1.462 -63.499 -3.346 -63.577 -3.468C-65.09 -5.85 -63.732 -5.674 -65.102 -8.032C-66.53 -8.712 -67.496 -9.816 -68.619 -10.978C-68.817 -11.182 -67.674 -11.906 -67.855 -12.119C-68.947 -13.408 -70.1 -14.175 -69.764 -15.668C-69.609 -16.358 -69.472 -17.415 -70.216 -18.135z"} - , - {"fill": "#000000", - "path":"M-73.8 -16.4C-73.8 -16.4 -73.4 -9.6 -71 -8C-68.6 -6.4 -69.8 -7.2 -73 -8.4C-76.2 -9.6 -75 -10.4 -75 -10.4C-75 -10.4 -77.8 -10 -75.4 -8C-73 -6 -69.4 -3.6 -71 -3.6C-72.6 -3.6 -80.2 -7.6 -80.2 -10.4C-80.2 -13.2 -81.2 -17.3 -81.2 -17.3C-81.2 -17.3 -80.1 -18.1 -75.3 -18C-75.3 -18 -73.9 -17.3 -73.8 -16.4z"} - , - {"fill": "#ffffff", "stroke":"#000000", "width":0.1, - "path":"M-74.6 2.2C-74.6 2.2 -83.12 -0.591 -101.6 2.8C-101.6 2.8 -92.569 0.722 -73.8 3C-63.5 4.25 -74.6 2.2 -74.6 2.2z"} - , - {"fill": "#ffffff", "stroke":"#000000", "width":0.1, - "path":"M-72.502 2.129C-72.502 2.129 -80.748 -1.389 -99.453 0.392C-99.453 0.392 -90.275 -0.897 -71.774 2.995C-61.62 5.131 -72.502 2.129 -72.502 2.129z"} - , - {"fill": "#ffffff", "stroke":"#000000", "width":0.1, - "path":"M-70.714 2.222C-70.714 2.222 -78.676 -1.899 -97.461 -1.514C-97.461 -1.514 -88.213 -2.118 -70.052 3.14C-60.086 6.025 -70.714 2.222 -70.714 2.222z"} - , - {"fill": "#ffffff", "stroke":"#000000", "width":0.1, - "path":"M-69.444 2.445C-69.444 2.445 -76.268 -1.862 -93.142 -2.96C-93.142 -2.96 -84.803 -2.79 -68.922 3.319C-60.206 6.672 -69.444 2.445 -69.444 2.445z"} - , - {"fill": "#ffffff", "stroke":"#000000", "width":0.1, - "path":"M45.84 12.961C45.84 12.961 44.91 13.605 45.124 12.424C45.339 11.243 73.547 -1.927 77.161 -1.677C77.161 -1.677 46.913 11.529 45.84 12.961z"} - , - {"fill": "#ffffff", "stroke":"#000000", "width":0.1, - "path":"M42.446 13.6C42.446 13.6 41.57 14.315 41.691 13.121C41.812 11.927 68.899 -3.418 72.521 -3.452C72.521 -3.452 43.404 12.089 42.446 13.6z"} - , - {"fill": "#ffffff", "stroke":"#000000", "width":0.1, - "path":"M39.16 14.975C39.16 14.975 38.332 15.747 38.374 14.547C38.416 13.348 58.233 -2.149 68.045 -4.023C68.045 -4.023 50.015 4.104 39.16 14.975z"} - , - {"fill": "#ffffff", "stroke":"#000000", "width":0.1, - "path":"M36.284 16.838C36.284 16.838 35.539 17.532 35.577 16.453C35.615 15.373 53.449 1.426 62.28 -0.26C62.28 -0.26 46.054 7.054 36.284 16.838z"} - , - {"fill": "#cccccc", - "path":"M4.6 164.801C4.6 164.801 -10.6 162.401 6.2 160.801C6.2 160.801 24.2 158.801 28.2 153.601C28.2 153.601 41.8 144.401 44.6 144.001C47.4 143.601 63.8 140.001 64.2 137.601C64.6 135.201 70.6 132.801 72.2 133.601C73.8 134.401 73.8 143.601 71 144.401C68.2 145.201 49.4 152.401 43 153.601C36.6 154.801 25 162.401 20.2 163.601C15.4 164.801 4.6 164.801 4.6 164.801z"} - , - {"fill": "#000000", - "path":"M77.6 127.401C77.6 127.401 74.6 129.001 73.4 131.601C73.4 131.601 67 142.201 52.8 145.401C52.8 145.401 29.8 154.401 22 156.401C22 156.401 8.6 161.401 1.2 160.601C1.2 160.601 -5.8 160.801 0.4 162.401C0.4 162.401 20.6 160.401 24 158.601C24 158.601 39.6 153.401 42.6 150.801C45.6 148.201 63.8 143.201 66 141.201C68.2 139.201 78 130.801 77.6 127.401z"} - , - {"fill": "#000000", - "path":"M18.882 158.911C18.882 158.911 24.111 158.685 22.958 160.234C21.805 161.784 19.357 160.91 19.357 160.91L18.882 158.911z"} - , - {"fill": "#000000", - "path":"M11.68 160.263C11.68 160.263 16.908 160.037 15.756 161.586C14.603 163.136 12.155 162.263 12.155 162.263L11.68 160.263z"} - , - {"fill": "#000000", - "path":"M1.251 161.511C1.251 161.511 6.48 161.284 5.327 162.834C4.174 164.383 1.726 163.51 1.726 163.51L1.251 161.511z"} - , - {"fill": "#000000", - "path":"M-6.383 162.055C-6.383 162.055 -1.154 161.829 -2.307 163.378C-3.46 164.928 -5.908 164.054 -5.908 164.054L-6.383 162.055z"} - , - {"fill": "#000000", - "path":"M35.415 151.513C35.415 151.513 42.375 151.212 40.84 153.274C39.306 155.336 36.047 154.174 36.047 154.174L35.415 151.513z"} - , - {"fill": "#000000", - "path":"M45.73 147.088C45.73 147.088 51.689 143.787 51.155 148.849C50.885 151.405 46.362 149.749 46.362 149.749L45.73 147.088z"} - , - {"fill": "#000000", - "path":"M54.862 144.274C54.862 144.274 62.021 140.573 60.287 146.035C59.509 148.485 55.493 146.935 55.493 146.935L54.862 144.274z"} - , - {"fill": "#000000", - "path":"M64.376 139.449C64.376 139.449 68.735 134.548 69.801 141.21C70.207 143.748 65.008 142.11 65.008 142.11L64.376 139.449z"} - , - {"fill": "#000000", - "path":"M26.834 155.997C26.834 155.997 32.062 155.77 30.91 157.32C29.757 158.869 27.308 157.996 27.308 157.996L26.834 155.997z"} - , - {"fill": "#ffffff", "stroke":"#000000", "width":0.1, - "path":"M62.434 34.603C62.434 34.603 61.708 35.268 61.707 34.197C61.707 33.127 79.191 19.863 88.034 18.479C88.034 18.479 71.935 25.208 62.434 34.603z"} - , - {"fill": "#000000", - "path":"M65.4 98.4C65.4 98.4 87.401 120.801 96.601 124.401C96.601 124.401 105.801 135.601 101.801 161.601C101.801 161.601 98.601 169.201 95.401 148.401C95.401 148.401 98.601 123.201 87.401 139.201C87.401 139.201 79 129.301 85.4 129.601C85.4 129.601 88.601 131.601 89.001 130.001C89.401 128.401 81.4 114.801 64.2 100.4C47 86 65.4 98.4 65.4 98.4z"} - , - {"fill": "#ffffff", "stroke":"#000000", "width":0.1, - "path":"M7 137.201C7 137.201 6.8 135.401 8.6 136.201C10.4 137.001 104.601 143.201 136.201 167.201C136.201 167.201 91.001 144.001 7 137.201z"} - , - {"fill": "#ffffff", "stroke":"#000000", "width":0.1, - "path":"M17.4 132.801C17.4 132.801 17.2 131.001 19 131.801C20.8 132.601 157.401 131.601 181.001 164.001C181.001 164.001 159.001 138.801 17.4 132.801z"} - , - {"fill": "#ffffff", "stroke":"#000000", "width":0.1, - "path":"M29 128.801C29 128.801 28.8 127.001 30.6 127.801C32.4 128.601 205.801 115.601 229.401 148.001C229.401 148.001 219.801 122.401 29 128.801z"} - , - {"fill": "#ffffff", "stroke":"#000000", "width":0.1, - "path":"M39 124.001C39 124.001 38.8 122.201 40.6 123.001C42.4 123.801 164.601 85.2 188.201 117.601C188.201 117.601 174.801 93 39 124.001z"} - , - {"fill": "#ffffff", "stroke":"#000000", "width":0.1, - "path":"M-19 146.801C-19 146.801 -19.2 145.001 -17.4 145.801C-15.6 146.601 2.2 148.801 4.2 187.601C4.2 187.601 -3 145.601 -19 146.801z"} - , - {"fill": "#ffffff", "stroke":"#000000", "width":0.1, - "path":"M-27.8 148.401C-27.8 148.401 -28 146.601 -26.2 147.401C-24.4 148.201 -10.2 143.601 -13 182.401C-13 182.401 -11.8 147.201 -27.8 148.401z"} - , - {"fill": "#ffffff", "stroke":"#000000", "width":0.1, - "path":"M-35.8 148.801C-35.8 148.801 -36 147.001 -34.2 147.801C-32.4 148.601 -17 149.201 -29.4 171.601C-29.4 171.601 -19.8 147.601 -35.8 148.801z"} - , - {"fill": "#ffffff", "stroke":"#000000", "width":0.1, - "path":"M11.526 104.465C11.526 104.465 11.082 106.464 12.631 105.247C28.699 92.622 61.141 33.72 116.826 28.086C116.826 28.086 78.518 15.976 11.526 104.465z"} - , - {"fill": "#ffffff", "stroke":"#000000", "width":0.1, - "path":"M22.726 102.665C22.726 102.665 21.363 101.472 23.231 100.847C25.099 100.222 137.541 27.72 176.826 35.686C176.826 35.686 149.719 28.176 22.726 102.665z"} - , - {"fill": "#ffffff", "stroke":"#000000", "width":0.1, - "path":"M1.885 108.767C1.885 108.767 1.376 110.366 3.087 109.39C12.062 104.27 15.677 47.059 59.254 45.804C59.254 45.804 26.843 31.09 1.885 108.767z"} - , - {"fill": "#ffffff", "stroke":"#000000", "width":0.1, - "path":"M-18.038 119.793C-18.038 119.793 -19.115 121.079 -17.162 120.825C-6.916 119.493 14.489 78.222 58.928 83.301C58.928 83.301 26.962 68.955 -18.038 119.793z"} - , - {"fill": "#ffffff", "stroke":"#000000", "width":0.1, - "path":"M-6.8 113.667C-6.8 113.667 -7.611 115.136 -5.742 114.511C4.057 111.237 17.141 66.625 61.729 63.078C61.729 63.078 27.603 55.135 -6.8 113.667z"} - , - {"fill": "#ffffff", "stroke":"#000000", "width":0.1, - "path":"M-25.078 124.912C-25.078 124.912 -25.951 125.954 -24.369 125.748C-16.07 124.669 1.268 91.24 37.264 95.354C37.264 95.354 11.371 83.734 -25.078 124.912z"} - , - {"fill": "#ffffff", "stroke":"#000000", "width":0.1, - "path":"M-32.677 130.821C-32.677 130.821 -33.682 131.866 -32.091 131.748C-27.923 131.439 2.715 98.36 21.183 113.862C21.183 113.862 9.168 95.139 -32.677 130.821z"} - , - {"fill": "#ffffff", "stroke":"#000000", "width":0.1, - "path":"M36.855 98.898C36.855 98.898 35.654 97.543 37.586 97.158C39.518 96.774 160.221 39.061 198.184 51.927C198.184 51.927 172.243 41.053 36.855 98.898z"} - , - {"fill": "#ffffff", "stroke":"#000000", "width":0.1, - "path":"M3.4 163.201C3.4 163.201 3.2 161.401 5 162.201C6.8 163.001 22.2 163.601 9.8 186.001C9.8 186.001 19.4 162.001 3.4 163.201z"} - , - {"fill": "#ffffff", "stroke":"#000000", "width":0.1, - "path":"M13.8 161.601C13.8 161.601 13.6 159.801 15.4 160.601C17.2 161.401 35 163.601 37 202.401C37 202.401 29.8 160.401 13.8 161.601z"} - , - {"fill": "#ffffff", "stroke":"#000000", "width":0.1, - "path":"M20.6 160.001C20.6 160.001 20.4 158.201 22.2 159.001C24 159.801 48.6 163.201 72.2 195.601C72.2 195.601 36.6 158.801 20.6 160.001z"} - , - {"fill": "#ffffff", "stroke":"#000000", "width":0.1, - "path":"M28.225 157.972C28.225 157.972 27.788 156.214 29.678 156.768C31.568 157.322 52.002 155.423 90.099 189.599C90.099 189.599 43.924 154.656 28.225 157.972z"} - , - {"fill": "#ffffff", "stroke":"#000000", "width":0.1, - "path":"M38.625 153.572C38.625 153.572 38.188 151.814 40.078 152.368C41.968 152.922 76.802 157.423 128.499 192.399C128.499 192.399 54.324 150.256 38.625 153.572z"} - , - {"fill": "#ffffff", "stroke":"#000000", "width":0.1, - "path":"M-1.8 142.001C-1.8 142.001 -2 140.201 -0.2 141.001C1.6 141.801 55 144.401 85.4 171.201C85.4 171.201 50.499 146.426 -1.8 142.001z"} - , - {"fill": "#ffffff", "stroke":"#000000", "width":0.1, - "path":"M-11.8 146.001C-11.8 146.001 -12 144.201 -10.2 145.001C-8.4 145.801 16.2 149.201 39.8 181.601C39.8 181.601 4.2 144.801 -11.8 146.001z"} - , - {"fill": "#ffffff", "stroke":"#000000", "width":0.1, - "path":"M49.503 148.962C49.503 148.962 48.938 147.241 50.864 147.655C52.79 148.068 87.86 150.004 141.981 181.098C141.981 181.098 64.317 146.704 49.503 148.962z"} - , - {"fill": "#ffffff", "stroke":"#000000", "width":0.1, - "path":"M57.903 146.562C57.903 146.562 57.338 144.841 59.264 145.255C61.19 145.668 96.26 147.604 150.381 178.698C150.381 178.698 73.317 143.904 57.903 146.562z"} - , - {"fill": "#ffffff", "stroke":"#000000", "width":0.1, - "path":"M67.503 141.562C67.503 141.562 66.938 139.841 68.864 140.255C70.79 140.668 113.86 145.004 203.582 179.298C203.582 179.298 82.917 138.904 67.503 141.562z"} - , - {"fill": "#000000", - "path":"M-43.8 148.401C-43.8 148.401 -38.6 148.001 -39.8 149.601C-41 151.201 -43.4 150.401 -43.4 150.401L-43.8 148.401z"} - , - {"fill": "#000000", - "path":"M-13 162.401C-13 162.401 -7.8 162.001 -9 163.601C-10.2 165.201 -12.6 164.401 -12.6 164.401L-13 162.401z"} - , - {"fill": "#000000", - "path":"M-21.8 162.001C-21.8 162.001 -16.6 161.601 -17.8 163.201C-19 164.801 -21.4 164.001 -21.4 164.001L-21.8 162.001z"} - , - {"fill": "#000000", - "path":"M-117.169 150.182C-117.169 150.182 -112.124 151.505 -113.782 152.624C-115.439 153.744 -117.446 152.202 -117.446 152.202L-117.169 150.182z"} - , - {"fill": "#000000", - "path":"M-115.169 140.582C-115.169 140.582 -110.124 141.905 -111.782 143.024C-113.439 144.144 -115.446 142.602 -115.446 142.602L-115.169 140.582z"} - , - {"fill": "#000000", - "path":"M-122.369 136.182C-122.369 136.182 -117.324 137.505 -118.982 138.624C-120.639 139.744 -122.646 138.202 -122.646 138.202L-122.369 136.182z"} - , - {"fill": "#cccccc", - "path":"M-42.6 211.201C-42.6 211.201 -44.2 211.201 -48.2 213.201C-50.2 213.201 -61.4 216.801 -67 226.801C-67 226.801 -54.6 217.201 -42.6 211.201z"} - , - {"fill": "#cccccc", - "path":"M45.116 303.847C45.257 304.105 45.312 304.525 45.604 304.542C46.262 304.582 47.495 304.883 47.37 304.247C46.522 299.941 45.648 295.004 41.515 293.197C40.876 292.918 39.434 293.331 39.36 294.215C39.233 295.739 39.116 297.088 39.425 298.554C39.725 299.975 41.883 299.985 42.8 298.601C43.736 300.273 44.168 302.116 45.116 303.847z"} - , - {"fill": "#cccccc", - "path":"M34.038 308.581C34.786 309.994 34.659 311.853 36.074 312.416C36.814 312.71 38.664 311.735 38.246 310.661C37.444 308.6 37.056 306.361 35.667 304.55C35.467 304.288 35.707 303.755 35.547 303.427C34.953 302.207 33.808 301.472 32.4 301.801C31.285 304.004 32.433 306.133 33.955 307.842C34.091 307.994 33.925 308.37 34.038 308.581z"} - , - {"fill": "#cccccc", - "path":"M-5.564 303.391C-5.672 303.014 -5.71 302.551 -5.545 302.23C-5.014 301.197 -4.221 300.075 -4.558 299.053C-4.906 297.997 -6.022 298.179 -6.672 298.748C-7.807 299.742 -7.856 301.568 -8.547 302.927C-8.743 303.313 -8.692 303.886 -9.133 304.277C-9.607 304.698 -10.047 306.222 -9.951 306.793C-9.898 307.106 -10.081 317.014 -9.859 316.751C-9.24 316.018 -6.19 306.284 -6.121 305.392C-6.064 304.661 -5.332 304.196 -5.564 303.391z"} - , - {"fill": "#cccccc", - "path":"M-31.202 296.599C-28.568 294.1 -25.778 291.139 -26.22 287.427C-26.336 286.451 -28.111 286.978 -28.298 287.824C-29.1 291.449 -31.139 294.11 -33.707 296.502C-35.903 298.549 -37.765 304.893 -38 305.401C-34.303 300.145 -32.046 297.399 -31.202 296.599z"} - , - {"fill": "#cccccc", - "path":"M-44.776 290.635C-44.253 290.265 -44.555 289.774 -44.338 289.442C-43.385 287.984 -42.084 286.738 -42.066 285C-42.063 284.723 -42.441 284.414 -42.776 284.638C-43.053 284.822 -43.395 284.952 -43.503 285.082C-45.533 287.531 -46.933 290.202 -48.376 293.014C-48.559 293.371 -49.703 297.862 -49.39 297.973C-49.151 298.058 -47.431 293.877 -47.221 293.763C-45.958 293.077 -45.946 291.462 -44.776 290.635z"} - , - {"fill": "#cccccc", - "path":"M-28.043 310.179C-27.599 309.31 -26.023 308.108 -26.136 307.219C-26.254 306.291 -25.786 304.848 -26.698 305.536C-27.955 306.484 -31.404 307.833 -31.674 313.641C-31.7 314.212 -28.726 311.519 -28.043 310.179z"} - , - {"fill": "#cccccc", - "path":"M-13.6 293.001C-13.2 292.333 -12.492 292.806 -12.033 292.543C-11.385 292.171 -10.774 291.613 -10.482 290.964C-9.512 288.815 -7.743 286.995 -7.6 284.601C-9.091 283.196 -9.77 285.236 -10.4 286.201C-11.723 284.554 -12.722 286.428 -14.022 286.947C-14.092 286.975 -14.305 286.628 -14.38 286.655C-15.557 287.095 -16.237 288.176 -17.235 288.957C-17.406 289.091 -17.811 288.911 -17.958 289.047C-18.61 289.65 -19.583 289.975 -19.863 290.657C-20.973 293.364 -24.113 295.459 -26 303.001C-25.619 303.91 -21.488 296.359 -21.001 295.661C-20.165 294.465 -20.047 297.322 -18.771 296.656C-18.72 296.629 -18.534 296.867 -18.4 297.001C-18.206 296.721 -17.988 296.492 -17.6 296.601C-17.6 296.201 -17.734 295.645 -17.533 295.486C-16.296 294.509 -16.38 293.441 -15.6 292.201C-15.142 292.99 -14.081 292.271 -13.6 293.001z"} - , - {"fill": "#cccccc", - "path":"M46.2 347.401C46.2 347.401 53.6 327.001 49.2 315.801C49.2 315.801 60.6 337.401 56 348.601C56 348.601 55.6 338.201 51.6 333.201C51.6 333.201 47.6 346.001 46.2 347.401z"} - , - {"fill": "#cccccc", - "path":"M31.4 344.801C31.4 344.801 36.8 336.001 28.8 317.601C28.8 317.601 28 338.001 21.2 349.001C21.2 349.001 35.4 328.801 31.4 344.801z"} - , - {"fill": "#cccccc", - "path":"M21.4 342.801C21.4 342.801 21.2 322.801 21.6 319.801C21.6 319.801 17.8 336.401 7.6 346.001C7.6 346.001 22 334.001 21.4 342.801z"} - , - {"fill": "#cccccc", - "path":"M11.8 310.801C11.8 310.801 17.8 324.401 7.8 342.801C7.8 342.801 14.2 330.601 9.4 323.601C9.4 323.601 12 320.201 11.8 310.801z"} - , - {"fill": "#cccccc", - "path":"M-7.4 342.401C-7.4 342.401 -8.4 326.801 -6.6 324.601C-6.6 324.601 -6.4 318.201 -6.8 317.201C-6.8 317.201 -2.8 311.001 -2.6 318.401C-2.6 318.401 -1.2 326.201 1.6 330.801C1.6 330.801 5.2 336.201 5 342.601C5 342.601 -5 312.401 -7.4 342.401z"} - , - {"fill": "#cccccc", - "path":"M-11 314.801C-11 314.801 -17.6 325.601 -19.4 344.601C-19.4 344.601 -20.8 338.401 -17 324.001C-17 324.001 -12.8 308.601 -11 314.801z"} - , - {"fill": "#cccccc", - "path":"M-32.8 334.601C-32.8 334.601 -27.8 329.201 -26.4 324.201C-26.4 324.201 -22.8 308.401 -29.2 317.001C-29.2 317.001 -29 325.001 -37.2 332.401C-37.2 332.401 -32.4 330.001 -32.8 334.601z"} - , - {"fill": "#cccccc", - "path":"M-38.6 329.601C-38.6 329.601 -35.2 312.201 -34.4 311.401C-34.4 311.401 -32.6 308.001 -35.4 311.201C-35.4 311.201 -44.2 330.401 -48.2 337.001C-48.2 337.001 -40.2 327.801 -38.6 329.601z"} - , - {"fill": "#cccccc", - "path":"M-44.4 313.001C-44.4 313.001 -32.8 290.601 -54.6 316.401C-54.6 316.401 -43.6 306.601 -44.4 313.001z"} - , - {"fill": "#cccccc", - "path":"M-59.8 298.401C-59.8 298.401 -55 279.601 -52.4 279.801C-52.4 279.801 -44.2 270.801 -50.8 281.401C-50.8 281.401 -56.8 291.001 -56.2 300.801C-56.2 300.801 -56.8 291.201 -59.8 298.401z"} - , - {"fill": "#cccccc", - "path":"M270.5 287C270.5 287 258.5 277 256 273.5C256 273.5 269.5 292 269.5 299C269.5 299 272 291.5 270.5 287z"} - , - {"fill": "#cccccc", - "path":"M276 265C276 265 255 250 251.5 242.5C251.5 242.5 278 272 278 276.5C278 276.5 278.5 267.5 276 265z"} - , - {"fill": "#cccccc", - "path":"M293 111C293 111 281 103 279.5 105C279.5 105 290 111.5 292.5 120C292.5 120 291 111 293 111z"} - , - {"fill": "#cccccc", - "path":"M301.5 191.5L284 179.5C284 179.5 303 196.5 303.5 200.5L301.5 191.5z"} - , - {"stroke":"#000000", - "path":"M-89.25 169L-67.25 173.75"} - , - {"stroke":"#000000", - "path":"M-39 331C-39 331 -39.5 327.5 -48.5 338"} - , - {"stroke":"#000000", - "path":"M-33.5 336C-33.5 336 -31.5 329.5 -38 334"} - , - {"stroke":"#000000", - "path":"M20.5 344.5C20.5 344.5 22 333.5 10.5 346.5"} -]; \ No newline at end of file diff --git a/examples/declarative/canvas/tiger/tiger.qml b/examples/declarative/canvas/tiger/tiger.qml deleted file mode 100644 index 2eb1bb2106..0000000000 --- a/examples/declarative/canvas/tiger/tiger.qml +++ /dev/null @@ -1,129 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 -import "../contents" -import "tiger.js" as Tiger -Item { - id:container - width:360 - height:600 - - Column { - spacing:5 - anchors.fill:parent - Text { font.pointSize:25; text:"Tiger with SVG path"; anchors.horizontalCenter:parent.horizontalCenter} - - Canvas { - id:canvas - width:360 - height:360 - smooth:true - renderTarget:Canvas.FramebufferObject - renderStrategy: Canvas.Cooperative - property string strokeStyle:"steelblue" - property string fillStyle:"yellow" - property bool fill:true - property bool stroke:true - property real alpha:alphaCtrl.value - property real scaleX : scaleXCtrl.value - property real scaleY : scaleYCtrl.value - property real rotate : rotateCtrl.value - property int frame:0 - - onFillChanged: requestPaint(); - onStrokeChanged: requestPaint(); - onAlphaChanged: requestPaint(); - onScaleXChanged: requestPaint(); - onScaleYChanged: requestPaint(); - onRotateChanged: requestPaint(); - - onPainted : { - canvas.frame++; - if (canvas.frame < Tiger.tiger.length) - requestPaint(); - } - onPaint: { - var ctx = canvas.getContext('2d'); - ctx.save(); - ctx.clearRect(0, 0, canvas.width, canvas.height); - ctx.globalAlpha = canvas.alpha; - ctx.scale(canvas.scaleX, canvas.scaleY); - ctx.rotate(canvas.rotate); - ctx.globalCompositeOperation = "source-over"; - ctx.translate(canvas.width/2, canvas.height/2); - ctx.strokeStyle = Qt.rgba(.3, .3, .3,1); - ctx.lineWidth = 1; - - - for (var i = 0; i < canvas.frame && i < Tiger.tiger.length; i++) { - if (Tiger.tiger[i].width != undefined) - ctx.lineWidth = Tiger.tiger[i].width; - - if (Tiger.tiger[i].path != undefined) - ctx.path = Tiger.tiger[i].path; - - if (Tiger.tiger[i].fill != undefined) { - ctx.fillStyle = Tiger.tiger[i].fill; - ctx.fill(); - } - - if (Tiger.tiger[i].stroke != undefined) { - ctx.strokeStyle = Tiger.tiger[i].stroke; - ctx.stroke(); - } - } - ctx.restore(); - } - } - Rectangle { - id:controls - width:360 - height:160 - Column { - spacing:3 - Slider {id:scaleXCtrl; width:300; height:30; min:0.1; max:10; init:0.5; name:"ScaleX"} - Slider {id:scaleYCtrl; width:300; height:30; min:0.1; max:10; init:0.5; name:"ScaleY"} - Slider {id:rotateCtrl; width:300; height:30; min:0; max:Math.PI*2; init:0; name:"Rotate"} - Slider {id:alphaCtrl; width:300; height:30; min:0; max:1; init:1; name:"Alpha"} - } - } - } -} diff --git a/examples/declarative/canvas/twitterfriends/TwitterUser.qml b/examples/declarative/canvas/twitterfriends/TwitterUser.qml deleted file mode 100644 index 8b906216ef..0000000000 --- a/examples/declarative/canvas/twitterfriends/TwitterUser.qml +++ /dev/null @@ -1,294 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -Item { - id:twitterUser - property variant friends : []; - property string name : ""; - property string twitterId : ""; - property string image : ""; - property string url : ""; - property string desc : ""; - width : 0; - height : 0; - property int posX:0; - property int posY:0; - property bool hasFocus : false; - property variant canvas; - property variant manager; - property variant linkColor; - property bool selected : false; - - Rectangle { - id:twitterStatus - x:twitterUser.width - y:twitterUser.height - width:250 - height:60 - opacity: 0 - border.color:"steelblue" - border.width:3 - Column { - spacing:2 - Text {color:"steelblue"; font.pointSize:15; width:250; height:30; text:twitterUser.name; wrapMode: Text.WrapAnywhere} - Text {color:"steelblue"; font.pointSize:8; width:250; height:30; text:twitterUser.url; wrapMode: Text.WrapAnywhere} - } - } - - function moved() { - twitterUser.posX = twitterUser.x; - twitterUser.posY = twitterUser.y; - twitterUser.canvas.requestPaint(); - } - - onXChanged: moved(); - onYChanged: moved(); - - MouseArea { - anchors.fill:parent - drag.target : twitterUser - drag.axis : Drag.XandYAxis - - onClicked: { - if (!twitterUser.selected) { - twitterUser.selected = true; - twitterStatus.opacity = 1; - twitterStatus.visible = true; - } else { - twitterUser.selected = false; - twitterStatus.opacity = 0; - } - } - - onDoubleClicked : { - twitterStatus.opacity = 0; - twitterUser.selected = false; - twitterUser.hasFocus = true; - twitterUser.canvas.twitterName = twitterUser.name; - twitterUser.canvas.twitterId = twitterUser.twitterId; - twitterUser.canvas.loading = true; - twitterUser.createFriends(); - } - } - - function show(ctx, layoutChanged) { - var w = canvas.width; - var h = canvas.height; - if (twitterUser.hasFocus) { - twitterUser.width = 60 - twitterUser.height = 60 - twitterUser.posX = w/2; - twitterUser.posY = h/2; - } else { - twitterUser.width = 40 - twitterUser.height = 40 - } - - - if (twitterUser.hasFocus) { - if (layoutChanged) - twitterUser.layoutFriends(); - twitterUser.linkFriends(ctx); - twitterUser.showFriends(ctx); - ctx.shadowOffsetX = 5; - ctx.shadowOffsetY = 5; - ctx.shadowBlur = 7; - ctx.shadowColor = "blue"; - ctx.globalAlpha = 1; - } else { - ctx.shadowOffsetX = 5; - ctx.shadowOffsetY = 5; - ctx.shadowBlur = 7; - ctx.shadowColor = twitterUser.linkColor; - ctx.globalAlpha = 0.6; - } - - if (twitterUser.canvas.isImageLoaded(twitterUser.image)) { - ctx.drawImage(twitterUser.image, twitterUser.posX, twitterUser.posY, twitterUser.width, twitterUser.height); - } -// ctx.font = "15px"; -// var nameSize = ctx.measureText(twitterUser.name).width; -// ctx.fillText(twitterUser.name, twitterUser.posX + nameSize/2 - twitterUser.width/2, twitterUser.posY + twitterUser.height/2 + 10); - } - function dump() { - console.log("name:" + twitterUser.name - + " x:" + twitterUser.posX - + " y:" + twitterUser.posY - + " width:" + twitterUser.width - + " height:" + twitterUser.height - + " id:" + twitterUser.twitterId - + " image:" + twitterUser.image - + " url:" + twitterUser.url + "\n" + twitterUser.desc); - } - - function layoutFriends() { - var w = canvas.width; - var h = canvas.height; - for (var i=0; i < twitterUser.friends.length; i++) { - var friend = manager.getById(twitterUser.friends[i]); - if (friend) { - friend.x = Math.random() *w; - friend.y = Math.random() *h; - } - } - } - - function showFriends(ctx) { - var w = canvas.width; - var h = canvas.height; - for (var i=0; i < twitterUser.friends.length && i < 15; i++) { - var friend = manager.getById(twitterUser.friends[i]); - if (friend && twitterUser.canvas.isImageLoaded(friend.image)) { - friend.hasFocus = false; - friend.show(ctx, false); - } - } - } - - function linkFriends(ctx) { - var w = canvas.width; - var h = canvas.height; - for (var i=0; i < twitterUser.friends.length && i < 15; i++) { - var friend = manager.getById(twitterUser.friends[i]); - if (friend && twitterUser.canvas.isImageLoaded(friend.image)) { - if (!friend.linkColor) - friend.linkColor = Qt.rgba( ((Math.random() * 200) +55)/255 - , ((Math.random() * 200) +55)/255 - , ((Math.random() * 200) +55)/255, 0.8); - ctx.strokeStyle = friend.linkColor; - ctx.lineWidth = 8; - ctx.beginPath(); - ctx.moveTo(twitterUser.posX + twitterUser.width/2, twitterUser.posY + twitterUser.height/2); - ctx.lineTo(friend.x + friend.width/2, friend.y + friend.height/2); - ctx.stroke(); - } - } - } - - - function create(url) { - var x = new XMLHttpRequest; - x.open("GET", url); - - x.onreadystatechange = function() { - if (x.readyState == XMLHttpRequest.DONE) { - var user = eval('(' + x.responseText +')')[0]; - twitterUser.name = user.name; - twitterUser.twitterId = user.id; - twitterUser.image = user.profile_image_url; - twitterUser.canvas.loadImage(twitterUser.image); - twitterUser.url = user.url; - twitterUser.desc = user.description; - twitterUser.createFriends(); - } - } - x.send(); - } - - function createByName(name) { - if (twitterUser.name === "" && twitterUser.twitterId === "") { - twitterUser.name = name; - var userUrl = "http://api.twitter.com/1/users/lookup.json?stringify_ids=true&screen_name=" + name; - twitterUser.create(userUrl); - } - } - - function createById(id) { - if (twitterUser.name === "" && twitterUser.twitterId === "") { - twitterUser.twitterId = id; - var userUrl = "http://api.twitter.com/1/users/lookup.json?stringify_ids=true&user_id=" + id; - twitterUser.create(userUrl); - } - } - - function createFriends() { - if (twitterUser.friends.length === 0) { - var x = new XMLHttpRequest; - var friendsUrl = "https://api.twitter.com/1/friends/ids.json?cursor=-1&stringify_ids=true&user_id=" + twitterUser.twitterId; - x.open("GET", friendsUrl); - - x.onreadystatechange = function() { - if (x.readyState == XMLHttpRequest.DONE) { - twitterUser.friends = eval('(' + x.responseText +')').ids; - var doRequest = false; - var userUrl = "http://api.twitter.com/1/users/lookup.json?stringify_ids=true&user_id="; - - for (var i=0; i - -#include -#include -#include -#include - -//![0] -class ColorImageProvider : public QDeclarativeImageProvider -{ -public: - ColorImageProvider() - : QDeclarativeImageProvider(QDeclarativeImageProvider::Pixmap) - { - } - - QPixmap requestPixmap(const QString &id, QSize *size, const QSize &requestedSize) - { - int width = 100; - int height = 50; - - if (size) - *size = QSize(width, height); - QPixmap pixmap(requestedSize.width() > 0 ? requestedSize.width() : width, - requestedSize.height() > 0 ? requestedSize.height() : height); - pixmap.fill(QColor(id).rgba()); -//![0] - - // write the color name - QPainter painter(&pixmap); - QFont f = painter.font(); - f.setPixelSize(20); - painter.setFont(f); - painter.setPen(Qt::black); - if (requestedSize.isValid()) - painter.scale(requestedSize.width() / width, requestedSize.height() / height); - painter.drawText(QRectF(0, 0, width, height), Qt::AlignCenter, id); - -//![1] - return pixmap; - } -}; -//![1] - - -class ImageProviderExtensionPlugin : public QDeclarativeExtensionPlugin -{ - Q_OBJECT -public: - void registerTypes(const char *uri) - { - Q_UNUSED(uri); - } - - void initializeEngine(QDeclarativeEngine *engine, const char *uri) - { - Q_UNUSED(uri); - engine->addImageProvider("colors", new ColorImageProvider); - } - -}; - -#include "imageprovider.moc" - -Q_EXPORT_PLUGIN(ImageProviderExtensionPlugin); - diff --git a/examples/declarative/cppextensions/imageprovider/imageprovider.pro b/examples/declarative/cppextensions/imageprovider/imageprovider.pro deleted file mode 100644 index cfa7923128..0000000000 --- a/examples/declarative/cppextensions/imageprovider/imageprovider.pro +++ /dev/null @@ -1,20 +0,0 @@ -TEMPLATE = lib -CONFIG += qt plugin -QT += declarative - -DESTDIR = ImageProviderCore -TARGET = qmlimageproviderplugin - -SOURCES += imageprovider.cpp - -sources.files = $$SOURCES imageprovider.qml imageprovider.pro -sources.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/declarative/imageprovider - -target.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/declarative/imageprovider/ImageProviderCore - -ImageProviderCore_sources.files = \ - ImageProviderCore/qmldir -ImageProviderCore_sources.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/declarative/imageprovider/ImageProviderCore - -INSTALLS = sources ImageProviderCore_sources target - diff --git a/examples/declarative/cppextensions/imageprovider/imageprovider.qmlproject b/examples/declarative/cppextensions/imageprovider/imageprovider.qmlproject deleted file mode 100644 index 2bb4016996..0000000000 --- a/examples/declarative/cppextensions/imageprovider/imageprovider.qmlproject +++ /dev/null @@ -1,14 +0,0 @@ -import QmlProject 1.0 - -Project { - /* Include .qml, .js, and image files from current directory and subdirectories */ - QmlFiles { - directory: "." - } - JavaScriptFiles { - directory: "." - } - ImageFiles { - directory: "." - } -} diff --git a/examples/declarative/cppextensions/networkaccessmanagerfactory/main.cpp b/examples/declarative/cppextensions/networkaccessmanagerfactory/main.cpp deleted file mode 100644 index 2bad2aa285..0000000000 --- a/examples/declarative/cppextensions/networkaccessmanagerfactory/main.cpp +++ /dev/null @@ -1,108 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the demonstration applications of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include -#include -#include - -#include -#include -#include - - -/* - This example illustrates using a QDeclarativeNetworkAccessManagerFactory to - create a QNetworkAccessManager with a proxy. - - Usage: - networkaccessmanagerfactory [-host -port ] [file] -*/ - -static QString proxyHost; -static int proxyPort = 0; - -class MyNetworkAccessManagerFactory : public QDeclarativeNetworkAccessManagerFactory -{ -public: - virtual QNetworkAccessManager *create(QObject *parent); -}; - -QNetworkAccessManager *MyNetworkAccessManagerFactory::create(QObject *parent) -{ - QNetworkAccessManager *nam = new QNetworkAccessManager(parent); - if (!proxyHost.isEmpty()) { - qDebug() << "Created QNetworkAccessManager using proxy" << (proxyHost + ":" + QString::number(proxyPort)); - QNetworkProxy proxy(QNetworkProxy::HttpCachingProxy, proxyHost, proxyPort); - nam->setProxy(proxy); - } - - return nam; -} - -int main(int argc, char ** argv) -{ - QUrl source("qrc:view.qml"); - - QGuiApplication app(argc, argv); - - for (int i = 1; i < argc; ++i) { - QString arg(argv[i]); - if (arg == "-host" && i < argc-1) { - proxyHost = argv[++i]; - } else if (arg == "-port" && i < argc-1) { - arg = argv[++i]; - proxyPort = arg.toInt(); - } else if (arg[0] != '-') { - source = QUrl::fromLocalFile(arg); - } else { - qWarning() << "Usage: networkaccessmanagerfactory [-host -port ] [file]"; - exit(1); - } - } - - QQuickView view; - view.engine()->setNetworkAccessManagerFactory(new MyNetworkAccessManagerFactory); - - view.setSource(source); - view.show(); - - return app.exec(); -} - diff --git a/examples/declarative/cppextensions/networkaccessmanagerfactory/networkaccessmanagerfactory.pro b/examples/declarative/cppextensions/networkaccessmanagerfactory/networkaccessmanagerfactory.pro deleted file mode 100644 index 479af364d0..0000000000 --- a/examples/declarative/cppextensions/networkaccessmanagerfactory/networkaccessmanagerfactory.pro +++ /dev/null @@ -1,4 +0,0 @@ -QT += declarative quick network - -SOURCES += main.cpp -RESOURCES += networkaccessmanagerfactory.qrc diff --git a/examples/declarative/cppextensions/networkaccessmanagerfactory/networkaccessmanagerfactory.qmlproject b/examples/declarative/cppextensions/networkaccessmanagerfactory/networkaccessmanagerfactory.qmlproject deleted file mode 100644 index 2bb4016996..0000000000 --- a/examples/declarative/cppextensions/networkaccessmanagerfactory/networkaccessmanagerfactory.qmlproject +++ /dev/null @@ -1,14 +0,0 @@ -import QmlProject 1.0 - -Project { - /* Include .qml, .js, and image files from current directory and subdirectories */ - QmlFiles { - directory: "." - } - JavaScriptFiles { - directory: "." - } - ImageFiles { - directory: "." - } -} diff --git a/examples/declarative/cppextensions/networkaccessmanagerfactory/networkaccessmanagerfactory.qrc b/examples/declarative/cppextensions/networkaccessmanagerfactory/networkaccessmanagerfactory.qrc deleted file mode 100644 index 17e9301471..0000000000 --- a/examples/declarative/cppextensions/networkaccessmanagerfactory/networkaccessmanagerfactory.qrc +++ /dev/null @@ -1,5 +0,0 @@ - - - view.qml - - diff --git a/examples/declarative/cppextensions/networkaccessmanagerfactory/view.qml b/examples/declarative/cppextensions/networkaccessmanagerfactory/view.qml deleted file mode 100644 index b2d46a991f..0000000000 --- a/examples/declarative/cppextensions/networkaccessmanagerfactory/view.qml +++ /dev/null @@ -1,47 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -Image { - width: 100 - height: 100 - source: "http://qt.nokia.com/logo.png" -} diff --git a/examples/declarative/cppextensions/plugins/README b/examples/declarative/cppextensions/plugins/README deleted file mode 100644 index f4f9074059..0000000000 --- a/examples/declarative/cppextensions/plugins/README +++ /dev/null @@ -1,9 +0,0 @@ -This example shows a module "com.nokia.TimeExample" that is implemented -by a C++ plugin (providing the "Time" type), and by QML files (providing the -"Clock" type). - -To run: - - make install - QML_IMPORT_PATH=$PWD qmlscene plugins.qml - diff --git a/examples/declarative/cppextensions/plugins/com/nokia/TimeExample/Clock.qml b/examples/declarative/cppextensions/plugins/com/nokia/TimeExample/Clock.qml deleted file mode 100644 index eac9226a00..0000000000 --- a/examples/declarative/cppextensions/plugins/com/nokia/TimeExample/Clock.qml +++ /dev/null @@ -1,90 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -Rectangle { - id: clock - width: 200; height: 200; color: "gray" - - property alias city: cityLabel.text - property variant hours - property variant minutes - property variant shift : 0 - - Image { id: background; source: "clock.png" } - - Image { - x: 92.5; y: 27 - source: "hour.png" - smooth: true - transform: Rotation { - id: hourRotation - origin.x: 7.5; origin.y: 73; - angle: (clock.hours * 30) + (clock.minutes * 0.5) - Behavior on angle { - SpringAnimation{ spring: 2; damping: 0.2; modulus: 360 } - } - } - } - - Image { - x: 93.5; y: 17 - source: "minute.png" - smooth: true - transform: Rotation { - id: minuteRotation - origin.x: 6.5; origin.y: 83; - angle: clock.minutes * 6 - Behavior on angle { - SpringAnimation{ spring: 2; damping: 0.2; modulus: 360 } - } - } - } - - Image { - anchors.centerIn: background; source: "center.png" - } - - Text { - id: cityLabel; font.bold: true; font.pixelSize: 14; y:200; color: "white" - anchors.horizontalCenter: parent.horizontalCenter - } -} diff --git a/examples/declarative/cppextensions/plugins/com/nokia/TimeExample/center.png b/examples/declarative/cppextensions/plugins/com/nokia/TimeExample/center.png deleted file mode 100644 index 7fbd802a44..0000000000 Binary files a/examples/declarative/cppextensions/plugins/com/nokia/TimeExample/center.png and /dev/null differ diff --git a/examples/declarative/cppextensions/plugins/com/nokia/TimeExample/clock.png b/examples/declarative/cppextensions/plugins/com/nokia/TimeExample/clock.png deleted file mode 100644 index 462edacc0e..0000000000 Binary files a/examples/declarative/cppextensions/plugins/com/nokia/TimeExample/clock.png and /dev/null differ diff --git a/examples/declarative/cppextensions/plugins/com/nokia/TimeExample/hour.png b/examples/declarative/cppextensions/plugins/com/nokia/TimeExample/hour.png deleted file mode 100644 index f8061a1235..0000000000 Binary files a/examples/declarative/cppextensions/plugins/com/nokia/TimeExample/hour.png and /dev/null differ diff --git a/examples/declarative/cppextensions/plugins/com/nokia/TimeExample/minute.png b/examples/declarative/cppextensions/plugins/com/nokia/TimeExample/minute.png deleted file mode 100644 index 1297ec7c2b..0000000000 Binary files a/examples/declarative/cppextensions/plugins/com/nokia/TimeExample/minute.png and /dev/null differ diff --git a/examples/declarative/cppextensions/plugins/com/nokia/TimeExample/qmldir b/examples/declarative/cppextensions/plugins/com/nokia/TimeExample/qmldir deleted file mode 100644 index e1288cfac0..0000000000 --- a/examples/declarative/cppextensions/plugins/com/nokia/TimeExample/qmldir +++ /dev/null @@ -1,2 +0,0 @@ -Clock 1.0 Clock.qml -plugin qmlqtimeexampleplugin diff --git a/examples/declarative/cppextensions/plugins/plugin.cpp b/examples/declarative/cppextensions/plugins/plugin.cpp deleted file mode 100644 index 6fbf962f4e..0000000000 --- a/examples/declarative/cppextensions/plugins/plugin.cpp +++ /dev/null @@ -1,157 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include -#include -#include -#include -#include -#include - -// Implements a "TimeModel" class with hour and minute properties -// that change on-the-minute yet efficiently sleep the rest -// of the time. - -class MinuteTimer : public QObject -{ - Q_OBJECT -public: - MinuteTimer(QObject *parent) : QObject(parent) - { - } - - void start() - { - if (!timer.isActive()) { - time = QTime::currentTime(); - timer.start(60000-time.second()*1000, this); - } - } - - void stop() - { - timer.stop(); - } - - int hour() const { return time.hour(); } - int minute() const { return time.minute(); } - -signals: - void timeChanged(); - -protected: - void timerEvent(QTimerEvent *) - { - QTime now = QTime::currentTime(); - if (now.second() == 59 && now.minute() == time.minute() && now.hour() == time.hour()) { - // just missed time tick over, force it, wait extra 0.5 seconds - time.addSecs(60); - timer.start(60500, this); - } else { - time = now; - timer.start(60000-time.second()*1000, this); - } - emit timeChanged(); - } - -private: - QTime time; - QBasicTimer timer; -}; - -//![0] -class TimeModel : public QObject -{ - Q_OBJECT - Q_PROPERTY(int hour READ hour NOTIFY timeChanged) - Q_PROPERTY(int minute READ minute NOTIFY timeChanged) -//![0] - -public: - TimeModel(QObject *parent=0) : QObject(parent) - { - if (++instances == 1) { - if (!timer) - timer = new MinuteTimer(QCoreApplication::instance()); - connect(timer, SIGNAL(timeChanged()), this, SIGNAL(timeChanged())); - timer->start(); - } - } - - ~TimeModel() - { - if (--instances == 0) { - timer->stop(); - } - } - - int minute() const { return timer->minute(); } - int hour() const { return timer->hour(); } - -signals: - void timeChanged(); - -private: - QTime t; - static MinuteTimer *timer; - static int instances; -}; - -int TimeModel::instances=0; -MinuteTimer *TimeModel::timer=0; - -//![plugin] -class QExampleQmlPlugin : public QDeclarativeExtensionPlugin -{ - Q_OBJECT -public: - void registerTypes(const char *uri) - { - Q_ASSERT(uri == QLatin1String("com.nokia.TimeExample")); - qmlRegisterType(uri, 1, 0, "Time"); - } -}; -//![plugin] - -#include "plugin.moc" - -//![export] -Q_EXPORT_PLUGIN2(qmlqtimeexampleplugin, QExampleQmlPlugin); -//![export] diff --git a/examples/declarative/cppextensions/plugins/plugins.pro b/examples/declarative/cppextensions/plugins/plugins.pro deleted file mode 100644 index bdcb62ca8a..0000000000 --- a/examples/declarative/cppextensions/plugins/plugins.pro +++ /dev/null @@ -1,25 +0,0 @@ -TEMPLATE = lib -CONFIG += qt plugin -QT += declarative - -DESTDIR = com/nokia/TimeExample -TARGET = qmlqtimeexampleplugin - -SOURCES += plugin.cpp - -qdeclarativesources.files += \ - com/nokia/TimeExample/qmldir \ - com/nokia/TimeExample/center.png \ - com/nokia/TimeExample/clock.png \ - com/nokia/TimeExample/Clock.qml \ - com/nokia/TimeExample/hour.png \ - com/nokia/TimeExample/minute.png - -qdeclarativesources.path += $$[QT_INSTALL_EXAMPLES]/qtdeclarative/declarative/plugins/com/nokia/TimeExample - -sources.files += plugins.pro plugin.cpp plugins.qml README -sources.path += $$[QT_INSTALL_EXAMPLES]/qtdeclarative/declarative/plugins -target.path += $$[QT_INSTALL_EXAMPLES]/qtdeclarative/declarative/plugins/com/nokia/TimeExample - -INSTALLS += qdeclarativesources sources target - diff --git a/examples/declarative/cppextensions/plugins/plugins.qml b/examples/declarative/cppextensions/plugins/plugins.qml deleted file mode 100644 index f1048ddd36..0000000000 --- a/examples/declarative/cppextensions/plugins/plugins.qml +++ /dev/null @@ -1,53 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -//![0] -import com.nokia.TimeExample 1.0 // import types from the plugin - -Clock { // this class is defined in QML (com/nokia/TimeExample/Clock.qml) - - Time { // this class is defined in C++ (plugin.cpp) - id: time - } - - hours: time.hour - minutes: time.minute - -} -//![0] diff --git a/examples/declarative/cppextensions/plugins/plugins.qmlproject b/examples/declarative/cppextensions/plugins/plugins.qmlproject deleted file mode 100644 index 771ab45b66..0000000000 --- a/examples/declarative/cppextensions/plugins/plugins.qmlproject +++ /dev/null @@ -1,16 +0,0 @@ -import QmlProject 1.1 - -Project { - mainFile: "plugins.qml" - - /* Include .qml, .js, and image files from current directory and subdirectories */ - QmlFiles { - directory: "." - } - JavaScriptFiles { - directory: "." - } - ImageFiles { - directory: "." - } -} diff --git a/examples/declarative/cppextensions/referenceexamples/adding/adding.pro b/examples/declarative/cppextensions/referenceexamples/adding/adding.pro deleted file mode 100644 index 1a972926b7..0000000000 --- a/examples/declarative/cppextensions/referenceexamples/adding/adding.pro +++ /dev/null @@ -1,11 +0,0 @@ -QT += declarative - -SOURCES += main.cpp \ - person.cpp -HEADERS += person.h -RESOURCES += adding.qrc - -target.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/declarative/extending/adding -sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS adding.pro -sources.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/declarative/extending/adding -INSTALLS += target sources diff --git a/examples/declarative/cppextensions/referenceexamples/adding/adding.qrc b/examples/declarative/cppextensions/referenceexamples/adding/adding.qrc deleted file mode 100644 index e2fa01d5e7..0000000000 --- a/examples/declarative/cppextensions/referenceexamples/adding/adding.qrc +++ /dev/null @@ -1,5 +0,0 @@ - - - example.qml - - diff --git a/examples/declarative/cppextensions/referenceexamples/adding/example.qml b/examples/declarative/cppextensions/referenceexamples/adding/example.qml deleted file mode 100644 index 3b2ca34d10..0000000000 --- a/examples/declarative/cppextensions/referenceexamples/adding/example.qml +++ /dev/null @@ -1,48 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -// ![0] -import People 1.0 - -Person { - name: "Bob Jones" - shoeSize: 12 -} -// ![0] diff --git a/examples/declarative/cppextensions/referenceexamples/adding/main.cpp b/examples/declarative/cppextensions/referenceexamples/adding/main.cpp deleted file mode 100644 index 4c1918b6de..0000000000 --- a/examples/declarative/cppextensions/referenceexamples/adding/main.cpp +++ /dev/null @@ -1,64 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include -#include -#include -#include -#include "person.h" - -int main(int argc, char ** argv) -{ - QCoreApplication app(argc, argv); -//![0] - qmlRegisterType("People", 1,0, "Person"); -//![0] - - QDeclarativeEngine engine; - QDeclarativeComponent component(&engine, QUrl("qrc:example.qml")); - Person *person = qobject_cast(component.create()); - if (person) { - qWarning() << "The person's name is" << person->name(); - qWarning() << "They wear a" << person->shoeSize() << "sized shoe"; - } else { - qWarning() << component.errors(); - } - - return 0; -} diff --git a/examples/declarative/cppextensions/referenceexamples/adding/person.cpp b/examples/declarative/cppextensions/referenceexamples/adding/person.cpp deleted file mode 100644 index 0e78b0b77b..0000000000 --- a/examples/declarative/cppextensions/referenceexamples/adding/person.cpp +++ /dev/null @@ -1,68 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include "person.h" - -// ![0] -Person::Person(QObject *parent) -: QObject(parent), m_shoeSize(0) -{ -} - -QString Person::name() const -{ - return m_name; -} - -void Person::setName(const QString &n) -{ - m_name = n; -} - -int Person::shoeSize() const -{ - return m_shoeSize; -} - -void Person::setShoeSize(int s) -{ - m_shoeSize = s; -} - -// ![0] diff --git a/examples/declarative/cppextensions/referenceexamples/adding/person.h b/examples/declarative/cppextensions/referenceexamples/adding/person.h deleted file mode 100644 index 45fb2f3297..0000000000 --- a/examples/declarative/cppextensions/referenceexamples/adding/person.h +++ /dev/null @@ -1,65 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#ifndef PERSON_H -#define PERSON_H - -#include -//![0] -class Person : public QObject -{ - Q_OBJECT - Q_PROPERTY(QString name READ name WRITE setName) - Q_PROPERTY(int shoeSize READ shoeSize WRITE setShoeSize) -public: - Person(QObject *parent = 0); - - QString name() const; - void setName(const QString &); - - int shoeSize() const; - void setShoeSize(int); - -private: - QString m_name; - int m_shoeSize; -}; -//![0] - -#endif // PERSON_H diff --git a/examples/declarative/cppextensions/referenceexamples/attached/attached.pro b/examples/declarative/cppextensions/referenceexamples/attached/attached.pro deleted file mode 100644 index 4cfd4e0aed..0000000000 --- a/examples/declarative/cppextensions/referenceexamples/attached/attached.pro +++ /dev/null @@ -1,13 +0,0 @@ -QT += declarative - -SOURCES += main.cpp \ - person.cpp \ - birthdayparty.cpp -HEADERS += person.h \ - birthdayparty.h -RESOURCES += attached.qrc - -target.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/declarative/extending/attached -sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS attached.pro -sources.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/declarative/extending/attached -INSTALLS += target sources diff --git a/examples/declarative/cppextensions/referenceexamples/attached/attached.qrc b/examples/declarative/cppextensions/referenceexamples/attached/attached.qrc deleted file mode 100644 index e2fa01d5e7..0000000000 --- a/examples/declarative/cppextensions/referenceexamples/attached/attached.qrc +++ /dev/null @@ -1,5 +0,0 @@ - - - example.qml - - diff --git a/examples/declarative/cppextensions/referenceexamples/attached/birthdayparty.cpp b/examples/declarative/cppextensions/referenceexamples/attached/birthdayparty.cpp deleted file mode 100644 index feefef4fe1..0000000000 --- a/examples/declarative/cppextensions/referenceexamples/attached/birthdayparty.cpp +++ /dev/null @@ -1,91 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include "birthdayparty.h" - -BirthdayPartyAttached::BirthdayPartyAttached(QObject *object) -: QObject(object) -{ -} - -QDate BirthdayPartyAttached::rsvp() const -{ - return m_rsvp; -} - -void BirthdayPartyAttached::setRsvp(const QDate &d) -{ - m_rsvp = d; -} - -BirthdayParty::BirthdayParty(QObject *parent) -: QObject(parent), m_host(0) -{ -} - -Person *BirthdayParty::host() const -{ - return m_host; -} - -void BirthdayParty::setHost(Person *c) -{ - m_host = c; -} - -QDeclarativeListProperty BirthdayParty::guests() -{ - return QDeclarativeListProperty(this, m_guests); -} - -int BirthdayParty::guestCount() const -{ - return m_guests.count(); -} - -Person *BirthdayParty::guest(int index) const -{ - return m_guests.at(index); -} - -BirthdayPartyAttached *BirthdayParty::qmlAttachedProperties(QObject *object) -{ - return new BirthdayPartyAttached(object); -} - diff --git a/examples/declarative/cppextensions/referenceexamples/attached/birthdayparty.h b/examples/declarative/cppextensions/referenceexamples/attached/birthdayparty.h deleted file mode 100644 index c789c0bd51..0000000000 --- a/examples/declarative/cppextensions/referenceexamples/attached/birthdayparty.h +++ /dev/null @@ -1,89 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#ifndef BIRTHDAYPARTY_H -#define BIRTHDAYPARTY_H - -#include -#include -#include -#include "person.h" - -class BirthdayPartyAttached : public QObject -{ - Q_OBJECT - Q_PROPERTY(QDate rsvp READ rsvp WRITE setRsvp) -public: - BirthdayPartyAttached(QObject *object); - - QDate rsvp() const; - void setRsvp(const QDate &); - -private: - QDate m_rsvp; -}; - -class BirthdayParty : public QObject -{ - Q_OBJECT - Q_PROPERTY(Person *host READ host WRITE setHost) - Q_PROPERTY(QDeclarativeListProperty guests READ guests) - Q_CLASSINFO("DefaultProperty", "guests") -public: - BirthdayParty(QObject *parent = 0); - - Person *host() const; - void setHost(Person *); - - QDeclarativeListProperty guests(); - int guestCount() const; - Person *guest(int) const; - - //! [static attached] - static BirthdayPartyAttached *qmlAttachedProperties(QObject *); - //! [static attached] -private: - Person *m_host; - QList m_guests; -}; - -//! [declare attached] -QML_DECLARE_TYPEINFO(BirthdayParty, QML_HAS_ATTACHED_PROPERTIES) -//! [declare attached] -#endif // BIRTHDAYPARTY_H diff --git a/examples/declarative/cppextensions/referenceexamples/attached/example.qml b/examples/declarative/cppextensions/referenceexamples/attached/example.qml deleted file mode 100644 index 6a83af2804..0000000000 --- a/examples/declarative/cppextensions/referenceexamples/attached/example.qml +++ /dev/null @@ -1,68 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import People 1.0 - -//! [begin] -BirthdayParty { -//! [begin] - -//! [rsvp] - Boy { - name: "Robert Campbell" - BirthdayParty.rsvp: "2009-07-01" - } -//! [rsvp] - // ![1] - Boy { - name: "Leo Hodges" - shoe { size: 10; color: "black"; brand: "Reebok"; price: 59.95 } - - BirthdayParty.rsvp: "2009-07-06" - } - // ![1] - Boy { - name: "Jack Smith" - shoe { size: 8; color: "blue"; brand: "Puma"; price: 19.95 } - } -//! [end] -} -//! [end] - diff --git a/examples/declarative/cppextensions/referenceexamples/attached/main.cpp b/examples/declarative/cppextensions/referenceexamples/attached/main.cpp deleted file mode 100644 index 4c2c3003fe..0000000000 --- a/examples/declarative/cppextensions/referenceexamples/attached/main.cpp +++ /dev/null @@ -1,91 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include -#include -#include -#include -#include "birthdayparty.h" -#include "person.h" - -int main(int argc, char ** argv) -{ - QCoreApplication app(argc, argv); - - qmlRegisterType(); - qmlRegisterType("People", 1,0, "BirthdayParty"); - qmlRegisterType(); - qmlRegisterType(); - qmlRegisterType("People", 1,0, "Boy"); - qmlRegisterType("People", 1,0, "Girl"); - - QDeclarativeEngine engine; - QDeclarativeComponent component(&engine, QUrl("qrc:example.qml")); - BirthdayParty *party = qobject_cast(component.create()); - - if (party && party->host()) { - qWarning() << party->host()->name() << "is having a birthday!"; - - if (qobject_cast(party->host())) - qWarning() << "He is inviting:"; - else - qWarning() << "She is inviting:"; - - for (int ii = 0; ii < party->guestCount(); ++ii) { - Person *guest = party->guest(ii); - - //! [query rsvp] - QDate rsvpDate; - QObject *attached = qmlAttachedPropertiesObject(guest, false); - - if (attached) - rsvpDate = attached->property("rsvp").toDate(); - //! [query rsvp] - if (rsvpDate.isNull()) - qWarning() << " " << guest->name() << "RSVP date: Hasn't RSVP'd"; - else - qWarning() << " " << guest->name() << "RSVP date:" << qPrintable(rsvpDate.toString()); - } - - } else { - qWarning() << component.errors(); - } - - return 0; -} diff --git a/examples/declarative/cppextensions/referenceexamples/attached/person.cpp b/examples/declarative/cppextensions/referenceexamples/attached/person.cpp deleted file mode 100644 index 7afcdc6ca6..0000000000 --- a/examples/declarative/cppextensions/referenceexamples/attached/person.cpp +++ /dev/null @@ -1,118 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include "person.h" - -ShoeDescription::ShoeDescription(QObject *parent) -: QObject(parent), m_size(0), m_price(0) -{ -} - -int ShoeDescription::size() const -{ - return m_size; -} - -void ShoeDescription::setSize(int s) -{ - m_size = s; -} - -QColor ShoeDescription::color() const -{ - return m_color; -} - -void ShoeDescription::setColor(const QColor &c) -{ - m_color = c; -} - -QString ShoeDescription::brand() const -{ - return m_brand; -} - -void ShoeDescription::setBrand(const QString &b) -{ - m_brand = b; -} - -qreal ShoeDescription::price() const -{ - return m_price; -} - -void ShoeDescription::setPrice(qreal p) -{ - m_price = p; -} - -Person::Person(QObject *parent) -: QObject(parent) -{ -} - -QString Person::name() const -{ - return m_name; -} - -void Person::setName(const QString &n) -{ - m_name = n; -} - -ShoeDescription *Person::shoe() -{ - return &m_shoe; -} - - -Boy::Boy(QObject * parent) -: Person(parent) -{ -} - - -Girl::Girl(QObject * parent) -: Person(parent) -{ -} - diff --git a/examples/declarative/cppextensions/referenceexamples/attached/person.h b/examples/declarative/cppextensions/referenceexamples/attached/person.h deleted file mode 100644 index 032eca3c17..0000000000 --- a/examples/declarative/cppextensions/referenceexamples/attached/person.h +++ /dev/null @@ -1,105 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#ifndef PERSON_H -#define PERSON_H - -#include -#include - -class ShoeDescription : public QObject -{ - Q_OBJECT - Q_PROPERTY(int size READ size WRITE setSize) - Q_PROPERTY(QColor color READ color WRITE setColor) - Q_PROPERTY(QString brand READ brand WRITE setBrand) - Q_PROPERTY(qreal price READ price WRITE setPrice) -public: - ShoeDescription(QObject *parent = 0); - - int size() const; - void setSize(int); - - QColor color() const; - void setColor(const QColor &); - - QString brand() const; - void setBrand(const QString &); - - qreal price() const; - void setPrice(qreal); -private: - int m_size; - QColor m_color; - QString m_brand; - qreal m_price; -}; - -class Person : public QObject -{ - Q_OBJECT - Q_PROPERTY(QString name READ name WRITE setName) - Q_PROPERTY(ShoeDescription *shoe READ shoe) -public: - Person(QObject *parent = 0); - - QString name() const; - void setName(const QString &); - - ShoeDescription *shoe(); -private: - QString m_name; - ShoeDescription m_shoe; -}; - -class Boy : public Person -{ - Q_OBJECT -public: - Boy(QObject * parent = 0); -}; - -class Girl : public Person -{ - Q_OBJECT -public: - Girl(QObject * parent = 0); -}; - -#endif // PERSON_H diff --git a/examples/declarative/cppextensions/referenceexamples/binding/binding.pro b/examples/declarative/cppextensions/referenceexamples/binding/binding.pro deleted file mode 100644 index 2add33fa47..0000000000 --- a/examples/declarative/cppextensions/referenceexamples/binding/binding.pro +++ /dev/null @@ -1,15 +0,0 @@ -QT += declarative - -SOURCES += main.cpp \ - person.cpp \ - birthdayparty.cpp \ - happybirthdaysong.cpp -HEADERS += person.h \ - birthdayparty.h \ - happybirthdaysong.h - -RESOURCES += binding.qrc -target.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/declarative/extending/binding -sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS binding.pro -sources.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/declarative/extending/binding -INSTALLS += target sources diff --git a/examples/declarative/cppextensions/referenceexamples/binding/binding.qrc b/examples/declarative/cppextensions/referenceexamples/binding/binding.qrc deleted file mode 100644 index e2fa01d5e7..0000000000 --- a/examples/declarative/cppextensions/referenceexamples/binding/binding.qrc +++ /dev/null @@ -1,5 +0,0 @@ - - - example.qml - - diff --git a/examples/declarative/cppextensions/referenceexamples/binding/birthdayparty.cpp b/examples/declarative/cppextensions/referenceexamples/binding/birthdayparty.cpp deleted file mode 100644 index 4f5acdfb75..0000000000 --- a/examples/declarative/cppextensions/referenceexamples/binding/birthdayparty.cpp +++ /dev/null @@ -1,113 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include "birthdayparty.h" - -BirthdayPartyAttached::BirthdayPartyAttached(QObject *object) -: QObject(object) -{ -} - -QDate BirthdayPartyAttached::rsvp() const -{ - return m_rsvp; -} - -void BirthdayPartyAttached::setRsvp(const QDate &d) -{ - if (d != m_rsvp) { - m_rsvp = d; - emit rsvpChanged(); - } -} - - -BirthdayParty::BirthdayParty(QObject *parent) -: QObject(parent), m_host(0) -{ -} - -Person *BirthdayParty::host() const -{ - return m_host; -} - -void BirthdayParty::setHost(Person *c) -{ - if (c == m_host) return; - m_host = c; - emit hostChanged(); -} - -QDeclarativeListProperty BirthdayParty::guests() -{ - return QDeclarativeListProperty(this, m_guests); -} - -int BirthdayParty::guestCount() const -{ - return m_guests.count(); -} - -Person *BirthdayParty::guest(int index) const -{ - return m_guests.at(index); -} - -void BirthdayParty::startParty() -{ - QTime time = QTime::currentTime(); - emit partyStarted(time); -} - -QString BirthdayParty::announcement() const -{ - return QString(); -} - -void BirthdayParty::setAnnouncement(const QString &speak) -{ - qWarning() << qPrintable(speak); -} - -BirthdayPartyAttached *BirthdayParty::qmlAttachedProperties(QObject *object) -{ - return new BirthdayPartyAttached(object); -} - diff --git a/examples/declarative/cppextensions/referenceexamples/binding/birthdayparty.h b/examples/declarative/cppextensions/referenceexamples/binding/birthdayparty.h deleted file mode 100644 index 376d107f26..0000000000 --- a/examples/declarative/cppextensions/referenceexamples/binding/birthdayparty.h +++ /dev/null @@ -1,102 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#ifndef BIRTHDAYPARTY_H -#define BIRTHDAYPARTY_H - -#include -#include -#include -#include -#include "person.h" - -class BirthdayPartyAttached : public QObject -{ - Q_OBJECT - Q_PROPERTY(QDate rsvp READ rsvp WRITE setRsvp NOTIFY rsvpChanged) -public: - BirthdayPartyAttached(QObject *object); - - QDate rsvp() const; - void setRsvp(const QDate &); - -signals: - void rsvpChanged(); - -private: - QDate m_rsvp; -}; - -class BirthdayParty : public QObject -{ - Q_OBJECT -// ![0] - Q_PROPERTY(Person *host READ host WRITE setHost NOTIFY hostChanged) -// ![0] - Q_PROPERTY(QDeclarativeListProperty guests READ guests) - Q_PROPERTY(QString announcement READ announcement WRITE setAnnouncement) - Q_CLASSINFO("DefaultProperty", "guests") -public: - BirthdayParty(QObject *parent = 0); - - Person *host() const; - void setHost(Person *); - - QDeclarativeListProperty guests(); - int guestCount() const; - Person *guest(int) const; - - QString announcement() const; - void setAnnouncement(const QString &); - - static BirthdayPartyAttached *qmlAttachedProperties(QObject *); - - void startParty(); -signals: - void partyStarted(const QTime &time); - void hostChanged(); - -private: - Person *m_host; - QList m_guests; -}; - -QML_DECLARE_TYPEINFO(BirthdayParty, QML_HAS_ATTACHED_PROPERTIES) - -#endif // BIRTHDAYPARTY_H diff --git a/examples/declarative/cppextensions/referenceexamples/binding/example.qml b/examples/declarative/cppextensions/referenceexamples/binding/example.qml deleted file mode 100644 index 99a0098ff6..0000000000 --- a/examples/declarative/cppextensions/referenceexamples/binding/example.qml +++ /dev/null @@ -1,77 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import People 1.0 - -// ![0] -BirthdayParty { - id: theParty - - HappyBirthdaySong on announcement { name: theParty.host.name } - - host: Boy { - name: "Bob Jones" - shoe { size: 12; color: "white"; brand: "Nike"; price: 90.0 } - } -// ![0] - onPartyStarted: console.log("This party started rockin' at " + time); - - - Boy { - name: "Leo Hodges" - BirthdayParty.rsvp: "2009-07-06" - shoe { size: 10; color: "black"; brand: "Reebok"; price: 59.95 } - } - Boy { - name: "Jack Smith" - shoe { size: 8; color: "blue"; brand: "Puma"; price: 19.95 } - } - Girl { - name: "Anne Brown" - BirthdayParty.rsvp: "2009-07-01" - shoe.size: 7 - shoe.color: "red" - shoe.brand: "Marc Jacobs" - shoe.price: 699.99 - } - -// ![1] -} -// ![1] diff --git a/examples/declarative/cppextensions/referenceexamples/binding/happybirthdaysong.cpp b/examples/declarative/cppextensions/referenceexamples/binding/happybirthdaysong.cpp deleted file mode 100644 index df4dbec9c4..0000000000 --- a/examples/declarative/cppextensions/referenceexamples/binding/happybirthdaysong.cpp +++ /dev/null @@ -1,85 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include "happybirthdaysong.h" -#include - -HappyBirthdaySong::HappyBirthdaySong(QObject *parent) -: QObject(parent), m_line(-1) -{ - setName(QString()); - QTimer *timer = new QTimer(this); - QObject::connect(timer, SIGNAL(timeout()), this, SLOT(advance())); - timer->start(1000); -} - -void HappyBirthdaySong::setTarget(const QDeclarativeProperty &p) -{ - m_target = p; -} - -QString HappyBirthdaySong::name() const -{ - return m_name; -} - -void HappyBirthdaySong::setName(const QString &name) -{ - if (m_name == name) - return; - - m_name = name; - - m_lyrics.clear(); - m_lyrics << "Happy birthday to you,"; - m_lyrics << "Happy birthday to you,"; - m_lyrics << "Happy birthday dear " + m_name + ","; - m_lyrics << "Happy birthday to you!"; - m_lyrics << ""; - - emit nameChanged(); -} - -void HappyBirthdaySong::advance() -{ - m_line = (m_line + 1) % m_lyrics.count(); - - m_target.write(m_lyrics.at(m_line)); -} - diff --git a/examples/declarative/cppextensions/referenceexamples/binding/happybirthdaysong.h b/examples/declarative/cppextensions/referenceexamples/binding/happybirthdaysong.h deleted file mode 100644 index a9f3a94544..0000000000 --- a/examples/declarative/cppextensions/referenceexamples/binding/happybirthdaysong.h +++ /dev/null @@ -1,74 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#ifndef HAPPYBIRTHDAYSONG_H -#define HAPPYBIRTHDAYSONG_H - -#include -#include - -#include - -class HappyBirthdaySong : public QObject, public QDeclarativePropertyValueSource -{ - Q_OBJECT - Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged) - Q_INTERFACES(QDeclarativePropertyValueSource) -public: - HappyBirthdaySong(QObject *parent = 0); - - virtual void setTarget(const QDeclarativeProperty &); - - QString name() const; - void setName(const QString &); - -private slots: - void advance(); - -signals: - void nameChanged(); -private: - int m_line; - QStringList m_lyrics; - QDeclarativeProperty m_target; - QString m_name; -}; - -#endif // HAPPYBIRTHDAYSONG_H - diff --git a/examples/declarative/cppextensions/referenceexamples/binding/main.cpp b/examples/declarative/cppextensions/referenceexamples/binding/main.cpp deleted file mode 100644 index 551d24b702..0000000000 --- a/examples/declarative/cppextensions/referenceexamples/binding/main.cpp +++ /dev/null @@ -1,92 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include -#include -#include -#include -#include "birthdayparty.h" -#include "happybirthdaysong.h" -#include "person.h" - -int main(int argc, char ** argv) -{ - QCoreApplication app(argc, argv); - qmlRegisterType(); - qmlRegisterType("People", 1,0, "BirthdayParty"); - qmlRegisterType("People", 1,0, "HappyBirthdaySong"); - qmlRegisterType(); - qmlRegisterType(); - qmlRegisterType("People", 1,0, "Boy"); - qmlRegisterType("People", 1,0, "Girl"); - - QDeclarativeEngine engine; - QDeclarativeComponent component(&engine, QUrl("qrc:example.qml")); - BirthdayParty *party = qobject_cast(component.create()); - - if (party && party->host()) { - qWarning() << party->host()->name() << "is having a birthday!"; - - if (qobject_cast(party->host())) - qWarning() << "He is inviting:"; - else - qWarning() << "She is inviting:"; - - for (int ii = 0; ii < party->guestCount(); ++ii) { - Person *guest = party->guest(ii); - - QDate rsvpDate; - QObject *attached = - qmlAttachedPropertiesObject(guest, false); - if (attached) - rsvpDate = attached->property("rsvp").toDate(); - - if (rsvpDate.isNull()) - qWarning() << " " << guest->name() << "RSVP date: Hasn't RSVP'd"; - else - qWarning() << " " << guest->name() << "RSVP date:" << qPrintable(rsvpDate.toString()); - } - - party->startParty(); - } else { - qWarning() << component.errors(); - } - - return app.exec(); -} diff --git a/examples/declarative/cppextensions/referenceexamples/binding/person.cpp b/examples/declarative/cppextensions/referenceexamples/binding/person.cpp deleted file mode 100644 index 89e7127caf..0000000000 --- a/examples/declarative/cppextensions/referenceexamples/binding/person.cpp +++ /dev/null @@ -1,138 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include "person.h" - -ShoeDescription::ShoeDescription(QObject *parent) -: QObject(parent), m_size(0), m_price(0) -{ -} - -int ShoeDescription::size() const -{ - return m_size; -} - -void ShoeDescription::setSize(int s) -{ - if (m_size == s) - return; - - m_size = s; - emit shoeChanged(); -} - -QColor ShoeDescription::color() const -{ - return m_color; -} - -void ShoeDescription::setColor(const QColor &c) -{ - if (m_color == c) - return; - - m_color = c; - emit shoeChanged(); -} - -QString ShoeDescription::brand() const -{ - return m_brand; -} - -void ShoeDescription::setBrand(const QString &b) -{ - if (m_brand == b) - return; - - m_brand = b; - emit shoeChanged(); -} - -qreal ShoeDescription::price() const -{ - return m_price; -} - -void ShoeDescription::setPrice(qreal p) -{ - if (m_price == p) - return; - - m_price = p; - emit shoeChanged(); -} - -Person::Person(QObject *parent) -: QObject(parent) -{ -} - -QString Person::name() const -{ - return m_name; -} - -void Person::setName(const QString &n) -{ - if (m_name == n) - return; - - m_name = n; - emit nameChanged(); -} - -ShoeDescription *Person::shoe() -{ - return &m_shoe; -} - - -Boy::Boy(QObject * parent) -: Person(parent) -{ -} - - -Girl::Girl(QObject * parent) -: Person(parent) -{ -} - diff --git a/examples/declarative/cppextensions/referenceexamples/binding/person.h b/examples/declarative/cppextensions/referenceexamples/binding/person.h deleted file mode 100644 index d0f196b95c..0000000000 --- a/examples/declarative/cppextensions/referenceexamples/binding/person.h +++ /dev/null @@ -1,113 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#ifndef PERSON_H -#define PERSON_H - -#include -#include - -class ShoeDescription : public QObject -{ - Q_OBJECT - Q_PROPERTY(int size READ size WRITE setSize NOTIFY shoeChanged) - Q_PROPERTY(QColor color READ color WRITE setColor NOTIFY shoeChanged) - Q_PROPERTY(QString brand READ brand WRITE setBrand NOTIFY shoeChanged) - Q_PROPERTY(qreal price READ price WRITE setPrice NOTIFY shoeChanged) -public: - ShoeDescription(QObject *parent = 0); - - int size() const; - void setSize(int); - - QColor color() const; - void setColor(const QColor &); - - QString brand() const; - void setBrand(const QString &); - - qreal price() const; - void setPrice(qreal); -signals: - void shoeChanged(); - -private: - int m_size; - QColor m_color; - QString m_brand; - qreal m_price; -}; - -class Person : public QObject -{ - Q_OBJECT - Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged) -// ![0] - Q_PROPERTY(ShoeDescription *shoe READ shoe CONSTANT) -// ![0] -public: - Person(QObject *parent = 0); - - QString name() const; - void setName(const QString &); - - ShoeDescription *shoe(); -signals: - void nameChanged(); - -private: - QString m_name; - ShoeDescription m_shoe; -}; - -class Boy : public Person -{ - Q_OBJECT -public: - Boy(QObject * parent = 0); -}; - -class Girl : public Person -{ - Q_OBJECT -public: - Girl(QObject * parent = 0); -}; - -#endif // PERSON_H diff --git a/examples/declarative/cppextensions/referenceexamples/coercion/birthdayparty.cpp b/examples/declarative/cppextensions/referenceexamples/coercion/birthdayparty.cpp deleted file mode 100644 index 1859ca9461..0000000000 --- a/examples/declarative/cppextensions/referenceexamples/coercion/birthdayparty.cpp +++ /dev/null @@ -1,71 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include "birthdayparty.h" - -BirthdayParty::BirthdayParty(QObject *parent) -: QObject(parent), m_host(0) -{ -} - -Person *BirthdayParty::host() const -{ - return m_host; -} - -void BirthdayParty::setHost(Person *c) -{ - m_host = c; -} - -QDeclarativeListProperty BirthdayParty::guests() -{ - return QDeclarativeListProperty(this, m_guests); -} - -int BirthdayParty::guestCount() const -{ - return m_guests.count(); -} - -Person *BirthdayParty::guest(int index) const -{ - return m_guests.at(index); -} - diff --git a/examples/declarative/cppextensions/referenceexamples/coercion/birthdayparty.h b/examples/declarative/cppextensions/referenceexamples/coercion/birthdayparty.h deleted file mode 100644 index 4315d3727e..0000000000 --- a/examples/declarative/cppextensions/referenceexamples/coercion/birthdayparty.h +++ /dev/null @@ -1,69 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#ifndef BIRTHDAYPARTY_H -#define BIRTHDAYPARTY_H - -#include -#include -#include "person.h" - -class BirthdayParty : public QObject -{ - Q_OBJECT -// ![0] - Q_PROPERTY(Person *host READ host WRITE setHost) - Q_PROPERTY(QDeclarativeListProperty guests READ guests) -// ![0] -public: - BirthdayParty(QObject *parent = 0); - - Person *host() const; - void setHost(Person *); - - QDeclarativeListProperty guests(); - int guestCount() const; - Person *guest(int) const; - -private: - Person *m_host; - QList m_guests; -}; - -#endif // BIRTHDAYPARTY_H diff --git a/examples/declarative/cppextensions/referenceexamples/coercion/coercion.pro b/examples/declarative/cppextensions/referenceexamples/coercion/coercion.pro deleted file mode 100644 index 742b85b683..0000000000 --- a/examples/declarative/cppextensions/referenceexamples/coercion/coercion.pro +++ /dev/null @@ -1,13 +0,0 @@ -QT += declarative - -SOURCES += main.cpp \ - person.cpp \ - birthdayparty.cpp -HEADERS += person.h \ - birthdayparty.h -RESOURCES += coercion.qrc - -target.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/declarative/extending/coercion -sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS coercion.pro -sources.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/declarative/extending/coercion -INSTALLS += target sources diff --git a/examples/declarative/cppextensions/referenceexamples/coercion/coercion.qrc b/examples/declarative/cppextensions/referenceexamples/coercion/coercion.qrc deleted file mode 100644 index e2fa01d5e7..0000000000 --- a/examples/declarative/cppextensions/referenceexamples/coercion/coercion.qrc +++ /dev/null @@ -1,5 +0,0 @@ - - - example.qml - - diff --git a/examples/declarative/cppextensions/referenceexamples/coercion/example.qml b/examples/declarative/cppextensions/referenceexamples/coercion/example.qml deleted file mode 100644 index 25791f38f8..0000000000 --- a/examples/declarative/cppextensions/referenceexamples/coercion/example.qml +++ /dev/null @@ -1,55 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import People 1.0 - -// ![0] -BirthdayParty { - host: Boy { - name: "Bob Jones" - shoeSize: 12 - } - guests: [ - Boy { name: "Leo Hodges" }, - Boy { name: "Jack Smith" }, - Girl { name: "Anne Brown" } - ] -} -// ![0] diff --git a/examples/declarative/cppextensions/referenceexamples/coercion/main.cpp b/examples/declarative/cppextensions/referenceexamples/coercion/main.cpp deleted file mode 100644 index 95b309de4c..0000000000 --- a/examples/declarative/cppextensions/referenceexamples/coercion/main.cpp +++ /dev/null @@ -1,80 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include -#include -#include -#include -#include "birthdayparty.h" -#include "person.h" - -int main(int argc, char ** argv) -{ - QCoreApplication app(argc, argv); - - qmlRegisterType("People", 1,0, "BirthdayParty"); - //![0] - qmlRegisterType(); - //![0] - - //![register boy girl] - qmlRegisterType("People", 1,0, "Boy"); - qmlRegisterType("People", 1,0, "Girl"); - //![register boy girl] - - QDeclarativeEngine engine; - QDeclarativeComponent component(&engine, QUrl("qrc:example.qml")); - BirthdayParty *party = qobject_cast(component.create()); - - if (party && party->host()) { - qWarning() << party->host()->name() << "is having a birthday!"; - - if (qobject_cast(party->host())) - qWarning() << "He is inviting:"; - else - qWarning() << "She is inviting:"; - - for (int ii = 0; ii < party->guestCount(); ++ii) - qWarning() << " " << party->guest(ii)->name(); - } else { - qWarning() << component.errors(); - } - - return 0; -} diff --git a/examples/declarative/cppextensions/referenceexamples/coercion/person.cpp b/examples/declarative/cppextensions/referenceexamples/coercion/person.cpp deleted file mode 100644 index b28d63216e..0000000000 --- a/examples/declarative/cppextensions/referenceexamples/coercion/person.cpp +++ /dev/null @@ -1,79 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include "person.h" - -Person::Person(QObject *parent) -: QObject(parent), m_shoeSize(0) -{ -} - -QString Person::name() const -{ - return m_name; -} - -void Person::setName(const QString &n) -{ - m_name = n; -} - -int Person::shoeSize() const -{ - return m_shoeSize; -} - -void Person::setShoeSize(int s) -{ - m_shoeSize = s; -} - -// ![1] -Boy::Boy(QObject * parent) -: Person(parent) -{ -} - - -Girl::Girl(QObject * parent) -: Person(parent) -{ -} - -// ![1] diff --git a/examples/declarative/cppextensions/referenceexamples/coercion/person.h b/examples/declarative/cppextensions/referenceexamples/coercion/person.h deleted file mode 100644 index dc4ae43dd6..0000000000 --- a/examples/declarative/cppextensions/referenceexamples/coercion/person.h +++ /dev/null @@ -1,83 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#ifndef PERSON_H -#define PERSON_H - -#include - -class Person : public QObject -{ - Q_OBJECT - Q_PROPERTY(QString name READ name WRITE setName) - Q_PROPERTY(int shoeSize READ shoeSize WRITE setShoeSize) -public: - Person(QObject *parent = 0); - - QString name() const; - void setName(const QString &); - - int shoeSize() const; - void setShoeSize(int); -private: - QString m_name; - int m_shoeSize; -}; - - -// ![0] -class Boy : public Person -{ - Q_OBJECT -public: - Boy(QObject * parent = 0); -}; - -//! [girl class] -class Girl : public Person -{ - Q_OBJECT -public: - Girl(QObject * parent = 0); -}; -//! [girl class] - -// ![0] - -#endif // PERSON_H diff --git a/examples/declarative/cppextensions/referenceexamples/default/birthdayparty.cpp b/examples/declarative/cppextensions/referenceexamples/default/birthdayparty.cpp deleted file mode 100644 index 1859ca9461..0000000000 --- a/examples/declarative/cppextensions/referenceexamples/default/birthdayparty.cpp +++ /dev/null @@ -1,71 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include "birthdayparty.h" - -BirthdayParty::BirthdayParty(QObject *parent) -: QObject(parent), m_host(0) -{ -} - -Person *BirthdayParty::host() const -{ - return m_host; -} - -void BirthdayParty::setHost(Person *c) -{ - m_host = c; -} - -QDeclarativeListProperty BirthdayParty::guests() -{ - return QDeclarativeListProperty(this, m_guests); -} - -int BirthdayParty::guestCount() const -{ - return m_guests.count(); -} - -Person *BirthdayParty::guest(int index) const -{ - return m_guests.at(index); -} - diff --git a/examples/declarative/cppextensions/referenceexamples/default/birthdayparty.h b/examples/declarative/cppextensions/referenceexamples/default/birthdayparty.h deleted file mode 100644 index cfca6689db..0000000000 --- a/examples/declarative/cppextensions/referenceexamples/default/birthdayparty.h +++ /dev/null @@ -1,70 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#ifndef BIRTHDAYPARTY_H -#define BIRTHDAYPARTY_H - -#include -#include -#include "person.h" - -// ![0] -class BirthdayParty : public QObject -{ - Q_OBJECT - Q_PROPERTY(Person *host READ host WRITE setHost) - Q_PROPERTY(QDeclarativeListProperty guests READ guests) - Q_CLASSINFO("DefaultProperty", "guests") -public: - BirthdayParty(QObject *parent = 0); - - Person *host() const; - void setHost(Person *); - - QDeclarativeListProperty guests(); - int guestCount() const; - Person *guest(int) const; - -private: - Person *m_host; - QList m_guests; -}; -// ![0] - -#endif // BIRTHDAYPARTY_H diff --git a/examples/declarative/cppextensions/referenceexamples/default/default.pro b/examples/declarative/cppextensions/referenceexamples/default/default.pro deleted file mode 100644 index 6533cdd7d3..0000000000 --- a/examples/declarative/cppextensions/referenceexamples/default/default.pro +++ /dev/null @@ -1,13 +0,0 @@ -QT += declarative - -SOURCES += main.cpp \ - person.cpp \ - birthdayparty.cpp -HEADERS += person.h \ - birthdayparty.h -RESOURCES += default.qrc - -target.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/declarative/extending/default -sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS default.pro -sources.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/declarative/extending/default -INSTALLS += target sources diff --git a/examples/declarative/cppextensions/referenceexamples/default/default.qrc b/examples/declarative/cppextensions/referenceexamples/default/default.qrc deleted file mode 100644 index e2fa01d5e7..0000000000 --- a/examples/declarative/cppextensions/referenceexamples/default/default.qrc +++ /dev/null @@ -1,5 +0,0 @@ - - - example.qml - - diff --git a/examples/declarative/cppextensions/referenceexamples/default/example.qml b/examples/declarative/cppextensions/referenceexamples/default/example.qml deleted file mode 100644 index 9ef24b59b7..0000000000 --- a/examples/declarative/cppextensions/referenceexamples/default/example.qml +++ /dev/null @@ -1,54 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import People 1.0 - -// ![0] -BirthdayParty { - host: Boy { - name: "Bob Jones" - shoeSize: 12 - } - - Boy { name: "Leo Hodges" } - Boy { name: "Jack Smith" } - Girl { name: "Anne Brown" } -} -// ![0] diff --git a/examples/declarative/cppextensions/referenceexamples/default/main.cpp b/examples/declarative/cppextensions/referenceexamples/default/main.cpp deleted file mode 100644 index 3a03279129..0000000000 --- a/examples/declarative/cppextensions/referenceexamples/default/main.cpp +++ /dev/null @@ -1,75 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include -#include -#include -#include -#include "birthdayparty.h" -#include "person.h" - -int main(int argc, char ** argv) -{ - QCoreApplication app(argc, argv); - - qmlRegisterType("People", 1,0, "BirthdayParty"); - qmlRegisterType(); - qmlRegisterType("People", 1,0, "Boy"); - qmlRegisterType("People", 1,0, "Girl"); - - QDeclarativeEngine engine; - QDeclarativeComponent component(&engine, QUrl("qrc:example.qml")); - BirthdayParty *party = qobject_cast(component.create()); - - if (party && party->host()) { - qWarning() << party->host()->name() << "is having a birthday!"; - - if (qobject_cast(party->host())) - qWarning() << "He is inviting:"; - else - qWarning() << "She is inviting:"; - - for (int ii = 0; ii < party->guestCount(); ++ii) - qWarning() << " " << party->guest(ii)->name(); - } else { - qWarning() << component.errors(); - } - - return 0; -} diff --git a/examples/declarative/cppextensions/referenceexamples/default/person.cpp b/examples/declarative/cppextensions/referenceexamples/default/person.cpp deleted file mode 100644 index 5a615a1ecd..0000000000 --- a/examples/declarative/cppextensions/referenceexamples/default/person.cpp +++ /dev/null @@ -1,78 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include "person.h" - -Person::Person(QObject *parent) -: QObject(parent), m_shoeSize(0) -{ -} - -QString Person::name() const -{ - return m_name; -} - -void Person::setName(const QString &n) -{ - m_name = n; -} - -int Person::shoeSize() const -{ - return m_shoeSize; -} - -void Person::setShoeSize(int s) -{ - m_shoeSize = s; -} - - -Boy::Boy(QObject * parent) -: Person(parent) -{ -} - - -Girl::Girl(QObject * parent) -: Person(parent) -{ -} - diff --git a/examples/declarative/cppextensions/referenceexamples/default/person.h b/examples/declarative/cppextensions/referenceexamples/default/person.h deleted file mode 100644 index d85672798c..0000000000 --- a/examples/declarative/cppextensions/referenceexamples/default/person.h +++ /dev/null @@ -1,77 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#ifndef PERSON_H -#define PERSON_H - -#include - -class Person : public QObject -{ - Q_OBJECT - Q_PROPERTY(QString name READ name WRITE setName) - Q_PROPERTY(int shoeSize READ shoeSize WRITE setShoeSize) -public: - Person(QObject *parent = 0); - - QString name() const; - void setName(const QString &); - - int shoeSize() const; - void setShoeSize(int); -private: - QString m_name; - int m_shoeSize; -}; - -class Boy : public Person -{ - Q_OBJECT -public: - Boy(QObject * parent = 0); -}; - -class Girl : public Person -{ - Q_OBJECT -public: - Girl(QObject * parent = 0); -}; - -#endif // PERSON_H diff --git a/examples/declarative/cppextensions/referenceexamples/extended/example.qml b/examples/declarative/cppextensions/referenceexamples/extended/example.qml deleted file mode 100644 index 642a95d443..0000000000 --- a/examples/declarative/cppextensions/referenceexamples/extended/example.qml +++ /dev/null @@ -1,47 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import People 1.0 - -// ![0] -QLineEdit { - leftMargin: 20 -} -// ![0] diff --git a/examples/declarative/cppextensions/referenceexamples/extended/extended.pro b/examples/declarative/cppextensions/referenceexamples/extended/extended.pro deleted file mode 100644 index 3d9f59c470..0000000000 --- a/examples/declarative/cppextensions/referenceexamples/extended/extended.pro +++ /dev/null @@ -1,11 +0,0 @@ -QT += declarative widgets - -SOURCES += main.cpp \ - lineedit.cpp -HEADERS += lineedit.h -RESOURCES += extended.qrc - -target.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/declarative/extending/extended -sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS extended.pro -sources.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/declarative/extending/extended -INSTALLS += target sources diff --git a/examples/declarative/cppextensions/referenceexamples/extended/extended.qrc b/examples/declarative/cppextensions/referenceexamples/extended/extended.qrc deleted file mode 100644 index e2fa01d5e7..0000000000 --- a/examples/declarative/cppextensions/referenceexamples/extended/extended.qrc +++ /dev/null @@ -1,5 +0,0 @@ - - - example.qml - - diff --git a/examples/declarative/cppextensions/referenceexamples/extended/lineedit.cpp b/examples/declarative/cppextensions/referenceexamples/extended/lineedit.cpp deleted file mode 100644 index 8f7fd8aa93..0000000000 --- a/examples/declarative/cppextensions/referenceexamples/extended/lineedit.cpp +++ /dev/null @@ -1,104 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include "lineedit.h" -#include - -LineEditExtension::LineEditExtension(QObject *object) -: QObject(object), m_lineedit(static_cast(object)) -{ -} - -int LineEditExtension::leftMargin() const -{ - int l, r, t, b; - m_lineedit->getTextMargins(&l, &t, &r, &b); - return l; -} - -void LineEditExtension::setLeftMargin(int m) -{ - int l, r, t, b; - m_lineedit->getTextMargins(&l, &t, &r, &b); - m_lineedit->setTextMargins(m, t, r, b); -} - -int LineEditExtension::rightMargin() const -{ - int l, r, t, b; - m_lineedit->getTextMargins(&l, &t, &r, &b); - return r; -} - -void LineEditExtension::setRightMargin(int m) -{ - int l, r, t, b; - m_lineedit->getTextMargins(&l, &t, &r, &b); - m_lineedit->setTextMargins(l, t, m, b); -} - -int LineEditExtension::topMargin() const -{ - int l, r, t, b; - m_lineedit->getTextMargins(&l, &t, &r, &b); - return t; -} - -void LineEditExtension::setTopMargin(int m) -{ - int l, r, t, b; - m_lineedit->getTextMargins(&l, &t, &r, &b); - m_lineedit->setTextMargins(l, m, r, b); -} - -int LineEditExtension::bottomMargin() const -{ - int l, r, t, b; - m_lineedit->getTextMargins(&l, &t, &r, &b); - return b; -} - -void LineEditExtension::setBottomMargin(int m) -{ - int l, r, t, b; - m_lineedit->getTextMargins(&l, &t, &r, &b); - m_lineedit->setTextMargins(l, t, r, m); -} - - diff --git a/examples/declarative/cppextensions/referenceexamples/extended/lineedit.h b/examples/declarative/cppextensions/referenceexamples/extended/lineedit.h deleted file mode 100644 index fa8c75df78..0000000000 --- a/examples/declarative/cppextensions/referenceexamples/extended/lineedit.h +++ /dev/null @@ -1,73 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#ifndef LINEEDIT_H -#define LINEEDIT_H - -#include - -class LineEditExtension : public QObject -{ - Q_OBJECT - Q_PROPERTY(int leftMargin READ leftMargin WRITE setLeftMargin NOTIFY marginsChanged) - Q_PROPERTY(int rightMargin READ rightMargin WRITE setRightMargin NOTIFY marginsChanged) - Q_PROPERTY(int topMargin READ topMargin WRITE setTopMargin NOTIFY marginsChanged) - Q_PROPERTY(int bottomMargin READ bottomMargin WRITE setBottomMargin NOTIFY marginsChanged) -public: - LineEditExtension(QObject *); - - int leftMargin() const; - void setLeftMargin(int); - - int rightMargin() const; - void setRightMargin(int); - - int topMargin() const; - void setTopMargin(int); - - int bottomMargin() const; - void setBottomMargin(int); -signals: - void marginsChanged(); - -private: - QLineEdit *m_lineedit; -}; - -#endif // LINEEDIT_H diff --git a/examples/declarative/cppextensions/referenceexamples/extended/main.cpp b/examples/declarative/cppextensions/referenceexamples/extended/main.cpp deleted file mode 100644 index 3c580396f2..0000000000 --- a/examples/declarative/cppextensions/referenceexamples/extended/main.cpp +++ /dev/null @@ -1,64 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include -#include -#include -#include -#include -#include "lineedit.h" - -int main(int argc, char ** argv) -{ - QApplication app(argc, argv); - - qmlRegisterExtendedType("People", 1,0, "QLineEdit"); - - QDeclarativeEngine engine; - QDeclarativeComponent component(&engine, QUrl("qrc:example.qml")); - QLineEdit *edit = qobject_cast(component.create()); - - if (edit) { - edit->show(); - return app.exec(); - } else { - qWarning() << component.errors(); - return 0; - } -} diff --git a/examples/declarative/cppextensions/referenceexamples/grouped/birthdayparty.cpp b/examples/declarative/cppextensions/referenceexamples/grouped/birthdayparty.cpp deleted file mode 100644 index 1859ca9461..0000000000 --- a/examples/declarative/cppextensions/referenceexamples/grouped/birthdayparty.cpp +++ /dev/null @@ -1,71 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include "birthdayparty.h" - -BirthdayParty::BirthdayParty(QObject *parent) -: QObject(parent), m_host(0) -{ -} - -Person *BirthdayParty::host() const -{ - return m_host; -} - -void BirthdayParty::setHost(Person *c) -{ - m_host = c; -} - -QDeclarativeListProperty BirthdayParty::guests() -{ - return QDeclarativeListProperty(this, m_guests); -} - -int BirthdayParty::guestCount() const -{ - return m_guests.count(); -} - -Person *BirthdayParty::guest(int index) const -{ - return m_guests.at(index); -} - diff --git a/examples/declarative/cppextensions/referenceexamples/grouped/birthdayparty.h b/examples/declarative/cppextensions/referenceexamples/grouped/birthdayparty.h deleted file mode 100644 index 491903adc5..0000000000 --- a/examples/declarative/cppextensions/referenceexamples/grouped/birthdayparty.h +++ /dev/null @@ -1,69 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#ifndef BIRTHDAYPARTY_H -#define BIRTHDAYPARTY_H - -#include -#include -#include "person.h" - -class BirthdayParty : public QObject -{ - Q_OBJECT - Q_PROPERTY(Person *host READ host WRITE setHost) - Q_PROPERTY(QDeclarativeListProperty guests READ guests) - Q_CLASSINFO("DefaultProperty", "guests") -public: - BirthdayParty(QObject *parent = 0); - - Person *host() const; - void setHost(Person *); - - QDeclarativeListProperty guests(); - int guestCount() const; - Person *guest(int) const; - -private: - Person *m_host; - QList m_guests; -}; - - -#endif // BIRTHDAYPARTY_H diff --git a/examples/declarative/cppextensions/referenceexamples/grouped/example.qml b/examples/declarative/cppextensions/referenceexamples/grouped/example.qml deleted file mode 100644 index 9ae80f222e..0000000000 --- a/examples/declarative/cppextensions/referenceexamples/grouped/example.qml +++ /dev/null @@ -1,77 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import People 1.0 - -// ![0] -BirthdayParty { - host: Boy { - name: "Bob Jones" - shoe { size: 12; color: "white"; brand: "Bikey"; price: 90.0 } - } - - Boy { - name: "Leo Hodges" -//![grouped] - shoe { size: 10; color: "black"; brand: "Thebok"; price: 59.95 } -//![grouped] - } - // ![1] - Boy { - name: "Jack Smith" - shoe { - size: 8 - color: "blue" - brand: "Luma" - price: 19.95 - } - } - // ![1] - Girl { - name: "Anne Brown" -//![ungrouped] - shoe.size: 7 - shoe.color: "red" - shoe.brand: "Job Macobs" - shoe.price: 699.99 -//![ungrouped] - } -} -// ![0] diff --git a/examples/declarative/cppextensions/referenceexamples/grouped/grouped.pro b/examples/declarative/cppextensions/referenceexamples/grouped/grouped.pro deleted file mode 100644 index aab0c8469a..0000000000 --- a/examples/declarative/cppextensions/referenceexamples/grouped/grouped.pro +++ /dev/null @@ -1,13 +0,0 @@ -QT += declarative - -SOURCES += main.cpp \ - person.cpp \ - birthdayparty.cpp -HEADERS += person.h \ - birthdayparty.h -RESOURCES += grouped.qrc - -target.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/declarative/extending/grouped -sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS grouped.pro -sources.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/declarative/extending/grouped -INSTALLS += target sources diff --git a/examples/declarative/cppextensions/referenceexamples/grouped/grouped.qrc b/examples/declarative/cppextensions/referenceexamples/grouped/grouped.qrc deleted file mode 100644 index e2fa01d5e7..0000000000 --- a/examples/declarative/cppextensions/referenceexamples/grouped/grouped.qrc +++ /dev/null @@ -1,5 +0,0 @@ - - - example.qml - - diff --git a/examples/declarative/cppextensions/referenceexamples/grouped/main.cpp b/examples/declarative/cppextensions/referenceexamples/grouped/main.cpp deleted file mode 100644 index de7d714c52..0000000000 --- a/examples/declarative/cppextensions/referenceexamples/grouped/main.cpp +++ /dev/null @@ -1,85 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include -#include -#include -#include -#include "birthdayparty.h" -#include "person.h" - -int main(int argc, char ** argv) -{ - QCoreApplication app(argc, argv); - - qmlRegisterType("People", 1,0, "BirthdayParty"); - qmlRegisterType(); - qmlRegisterType(); - qmlRegisterType("People", 1,0, "Boy"); - qmlRegisterType("People", 1,0, "Girl"); - - QDeclarativeEngine engine; - QDeclarativeComponent component(&engine, QUrl("qrc:example.qml")); - BirthdayParty *party = qobject_cast(component.create()); - - if (party && party->host()) { - qWarning() << party->host()->name() << "is having a birthday!"; - - if (qobject_cast(party->host())) - qWarning() << "He is inviting:"; - else - qWarning() << "She is inviting:"; - - Person *bestShoe = 0; - for (int ii = 0; ii < party->guestCount(); ++ii) { - Person *guest = party->guest(ii); - qWarning() << " " << guest->name(); - - if (!bestShoe || bestShoe->shoe()->price() < guest->shoe()->price()) - bestShoe = guest; - } - if (bestShoe) - qWarning() << bestShoe->name() << "is wearing the best shoes!"; - - } else { - qWarning() << component.errors(); - } - - return 0; -} diff --git a/examples/declarative/cppextensions/referenceexamples/grouped/person.cpp b/examples/declarative/cppextensions/referenceexamples/grouped/person.cpp deleted file mode 100644 index 7afcdc6ca6..0000000000 --- a/examples/declarative/cppextensions/referenceexamples/grouped/person.cpp +++ /dev/null @@ -1,118 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include "person.h" - -ShoeDescription::ShoeDescription(QObject *parent) -: QObject(parent), m_size(0), m_price(0) -{ -} - -int ShoeDescription::size() const -{ - return m_size; -} - -void ShoeDescription::setSize(int s) -{ - m_size = s; -} - -QColor ShoeDescription::color() const -{ - return m_color; -} - -void ShoeDescription::setColor(const QColor &c) -{ - m_color = c; -} - -QString ShoeDescription::brand() const -{ - return m_brand; -} - -void ShoeDescription::setBrand(const QString &b) -{ - m_brand = b; -} - -qreal ShoeDescription::price() const -{ - return m_price; -} - -void ShoeDescription::setPrice(qreal p) -{ - m_price = p; -} - -Person::Person(QObject *parent) -: QObject(parent) -{ -} - -QString Person::name() const -{ - return m_name; -} - -void Person::setName(const QString &n) -{ - m_name = n; -} - -ShoeDescription *Person::shoe() -{ - return &m_shoe; -} - - -Boy::Boy(QObject * parent) -: Person(parent) -{ -} - - -Girl::Girl(QObject * parent) -: Person(parent) -{ -} - diff --git a/examples/declarative/cppextensions/referenceexamples/grouped/person.h b/examples/declarative/cppextensions/referenceexamples/grouped/person.h deleted file mode 100644 index dea715bacb..0000000000 --- a/examples/declarative/cppextensions/referenceexamples/grouped/person.h +++ /dev/null @@ -1,107 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#ifndef PERSON_H -#define PERSON_H - -#include -#include - -class ShoeDescription : public QObject -{ - Q_OBJECT - Q_PROPERTY(int size READ size WRITE setSize) - Q_PROPERTY(QColor color READ color WRITE setColor) - Q_PROPERTY(QString brand READ brand WRITE setBrand) - Q_PROPERTY(qreal price READ price WRITE setPrice) -public: - ShoeDescription(QObject *parent = 0); - - int size() const; - void setSize(int); - - QColor color() const; - void setColor(const QColor &); - - QString brand() const; - void setBrand(const QString &); - - qreal price() const; - void setPrice(qreal); -private: - int m_size; - QColor m_color; - QString m_brand; - qreal m_price; -}; - -class Person : public QObject -{ - Q_OBJECT - Q_PROPERTY(QString name READ name WRITE setName) -// ![1] - Q_PROPERTY(ShoeDescription *shoe READ shoe) -// ![1] -public: - Person(QObject *parent = 0); - - QString name() const; - void setName(const QString &); - - ShoeDescription *shoe(); -private: - QString m_name; - ShoeDescription m_shoe; -}; - -class Boy : public Person -{ - Q_OBJECT -public: - Boy(QObject * parent = 0); -}; - -class Girl : public Person -{ - Q_OBJECT -public: - Girl(QObject * parent = 0); -}; - -#endif // PERSON_H diff --git a/examples/declarative/cppextensions/referenceexamples/methods/birthdayparty.cpp b/examples/declarative/cppextensions/referenceexamples/methods/birthdayparty.cpp deleted file mode 100644 index 35444f505a..0000000000 --- a/examples/declarative/cppextensions/referenceexamples/methods/birthdayparty.cpp +++ /dev/null @@ -1,80 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include "birthdayparty.h" - -BirthdayParty::BirthdayParty(QObject *parent) -: QObject(parent), m_host(0) -{ -} - -// ![0] -Person *BirthdayParty::host() const -{ - return m_host; -} - -void BirthdayParty::setHost(Person *c) -{ - m_host = c; -} - -QDeclarativeListProperty BirthdayParty::guests() -{ - return QDeclarativeListProperty(this, m_guests); -} - -int BirthdayParty::guestCount() const -{ - return m_guests.count(); -} - -Person *BirthdayParty::guest(int index) const -{ - return m_guests.at(index); -} - -void BirthdayParty::invite(const QString &name) -{ - Person *person = new Person(this); - person->setName(name); - m_guests.append(person); -} -// ![0] - diff --git a/examples/declarative/cppextensions/referenceexamples/methods/birthdayparty.h b/examples/declarative/cppextensions/referenceexamples/methods/birthdayparty.h deleted file mode 100644 index e49afdb78d..0000000000 --- a/examples/declarative/cppextensions/referenceexamples/methods/birthdayparty.h +++ /dev/null @@ -1,71 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#ifndef BIRTHDAYPARTY_H -#define BIRTHDAYPARTY_H - -#include -#include -#include "person.h" - -class BirthdayParty : public QObject -{ - Q_OBJECT - Q_PROPERTY(Person *host READ host WRITE setHost) - Q_PROPERTY(QDeclarativeListProperty guests READ guests) -public: - BirthdayParty(QObject *parent = 0); - - Person *host() const; - void setHost(Person *); - - QDeclarativeListProperty guests(); - int guestCount() const; - Person *guest(int) const; - -// ![0] - Q_INVOKABLE void invite(const QString &name); -// ![0] - -private: - Person *m_host; - QList m_guests; -}; - -#endif // BIRTHDAYPARTY_H diff --git a/examples/declarative/cppextensions/referenceexamples/methods/example.qml b/examples/declarative/cppextensions/referenceexamples/methods/example.qml deleted file mode 100644 index 9119835e04..0000000000 --- a/examples/declarative/cppextensions/referenceexamples/methods/example.qml +++ /dev/null @@ -1,58 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 -import People 1.0 - -BirthdayParty { - host: Person { - name: "Bob Jones" - shoeSize: 12 - } - guests: [ - Person { name: "Leo Hodges" }, - Person { name: "Jack Smith" }, - Person { name: "Anne Brown" } - ] - -// ![0] - Component.onCompleted: invite("William Green") -// ![0] -} diff --git a/examples/declarative/cppextensions/referenceexamples/methods/main.cpp b/examples/declarative/cppextensions/referenceexamples/methods/main.cpp deleted file mode 100644 index d037d88f20..0000000000 --- a/examples/declarative/cppextensions/referenceexamples/methods/main.cpp +++ /dev/null @@ -1,68 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include -#include -#include -#include -#include "birthdayparty.h" -#include "person.h" - -int main(int argc, char ** argv) -{ - QCoreApplication app(argc, argv); - - qmlRegisterType("People", 1,0, "BirthdayParty"); - qmlRegisterType("People", 1,0, "Person"); - - QDeclarativeEngine engine; - QDeclarativeComponent component(&engine, QUrl("qrc:example.qml")); - BirthdayParty *party = qobject_cast(component.create()); - - if (party && party->host()) { - qWarning() << party->host()->name() << "is having a birthday!"; - qWarning() << "They are inviting:"; - for (int ii = 0; ii < party->guestCount(); ++ii) - qWarning() << " " << party->guest(ii)->name(); - } else { - qWarning() << component.errors(); - } - - return 0; -} diff --git a/examples/declarative/cppextensions/referenceexamples/methods/methods.pro b/examples/declarative/cppextensions/referenceexamples/methods/methods.pro deleted file mode 100644 index ee28355188..0000000000 --- a/examples/declarative/cppextensions/referenceexamples/methods/methods.pro +++ /dev/null @@ -1,13 +0,0 @@ -QT += declarative - -SOURCES += main.cpp \ - person.cpp \ - birthdayparty.cpp -HEADERS += person.h \ - birthdayparty.h -RESOURCES += methods.qrc - -target.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/declarative/extending/methods -sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS methods.pro -sources.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/declarative/extending/methods -INSTALLS += target sources diff --git a/examples/declarative/cppextensions/referenceexamples/methods/methods.qrc b/examples/declarative/cppextensions/referenceexamples/methods/methods.qrc deleted file mode 100644 index e2fa01d5e7..0000000000 --- a/examples/declarative/cppextensions/referenceexamples/methods/methods.qrc +++ /dev/null @@ -1,5 +0,0 @@ - - - example.qml - - diff --git a/examples/declarative/cppextensions/referenceexamples/methods/person.cpp b/examples/declarative/cppextensions/referenceexamples/methods/person.cpp deleted file mode 100644 index 30d1e46e5a..0000000000 --- a/examples/declarative/cppextensions/referenceexamples/methods/person.cpp +++ /dev/null @@ -1,66 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include "person.h" - -Person::Person(QObject *parent) -: QObject(parent), m_shoeSize(0) -{ -} - -QString Person::name() const -{ - return m_name; -} - -void Person::setName(const QString &n) -{ - m_name = n; -} - -int Person::shoeSize() const -{ - return m_shoeSize; -} - -void Person::setShoeSize(int s) -{ - m_shoeSize = s; -} - diff --git a/examples/declarative/cppextensions/referenceexamples/methods/person.h b/examples/declarative/cppextensions/referenceexamples/methods/person.h deleted file mode 100644 index dd3ad4d188..0000000000 --- a/examples/declarative/cppextensions/referenceexamples/methods/person.h +++ /dev/null @@ -1,63 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#ifndef PERSON_H -#define PERSON_H - -#include - -class Person : public QObject -{ - Q_OBJECT - Q_PROPERTY(QString name READ name WRITE setName) - Q_PROPERTY(int shoeSize READ shoeSize WRITE setShoeSize) -public: - Person(QObject *parent = 0); - - QString name() const; - void setName(const QString &); - - int shoeSize() const; - void setShoeSize(int); -private: - QString m_name; - int m_shoeSize; -}; - -#endif // PERSON_H diff --git a/examples/declarative/cppextensions/referenceexamples/properties/birthdayparty.cpp b/examples/declarative/cppextensions/referenceexamples/properties/birthdayparty.cpp deleted file mode 100644 index 0038cd0a41..0000000000 --- a/examples/declarative/cppextensions/referenceexamples/properties/birthdayparty.cpp +++ /dev/null @@ -1,73 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include "birthdayparty.h" - -BirthdayParty::BirthdayParty(QObject *parent) -: QObject(parent), m_host(0) -{ -} - -// ![0] -Person *BirthdayParty::host() const -{ - return m_host; -} - -void BirthdayParty::setHost(Person *c) -{ - m_host = c; -} - -QDeclarativeListProperty BirthdayParty::guests() -{ - return QDeclarativeListProperty(this, m_guests); -} - -int BirthdayParty::guestCount() const -{ - return m_guests.count(); -} - -Person *BirthdayParty::guest(int index) const -{ - return m_guests.at(index); -} -// ![0] - diff --git a/examples/declarative/cppextensions/referenceexamples/properties/birthdayparty.h b/examples/declarative/cppextensions/referenceexamples/properties/birthdayparty.h deleted file mode 100644 index 2c3d128b6d..0000000000 --- a/examples/declarative/cppextensions/referenceexamples/properties/birthdayparty.h +++ /dev/null @@ -1,75 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#ifndef BIRTHDAYPARTY_H -#define BIRTHDAYPARTY_H - -#include -#include -#include "person.h" - -// ![0] -class BirthdayParty : public QObject -{ - Q_OBJECT -// ![0] -// ![1] - Q_PROPERTY(Person *host READ host WRITE setHost) -// ![1] -// ![2] - Q_PROPERTY(QDeclarativeListProperty guests READ guests) -// ![2] -// ![3] -public: - BirthdayParty(QObject *parent = 0); - - Person *host() const; - void setHost(Person *); - - QDeclarativeListProperty guests(); - int guestCount() const; - Person *guest(int) const; - -private: - Person *m_host; - QList m_guests; -}; -// ![3] - -#endif // BIRTHDAYPARTY_H diff --git a/examples/declarative/cppextensions/referenceexamples/properties/example.qml b/examples/declarative/cppextensions/referenceexamples/properties/example.qml deleted file mode 100644 index 36ee952243..0000000000 --- a/examples/declarative/cppextensions/referenceexamples/properties/example.qml +++ /dev/null @@ -1,55 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import People 1.0 - -// ![0] -BirthdayParty { - host: Person { - name: "Bob Jones" - shoeSize: 12 - } - guests: [ - Person { name: "Leo Hodges" }, - Person { name: "Jack Smith" }, - Person { name: "Anne Brown" } - ] -} -// ![0] diff --git a/examples/declarative/cppextensions/referenceexamples/properties/main.cpp b/examples/declarative/cppextensions/referenceexamples/properties/main.cpp deleted file mode 100644 index 421ce9fbaa..0000000000 --- a/examples/declarative/cppextensions/referenceexamples/properties/main.cpp +++ /dev/null @@ -1,70 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include -#include -#include -#include -#include "birthdayparty.h" -#include "person.h" - -int main(int argc, char ** argv) -{ - QCoreApplication app(argc, argv); - -//![register list] - qmlRegisterType("People", 1,0, "BirthdayParty"); - qmlRegisterType("People", 1,0, "Person"); -//![register list] - - QDeclarativeEngine engine; - QDeclarativeComponent component(&engine, QUrl("qrc:example.qml")); - BirthdayParty *party = qobject_cast(component.create()); - - if (party && party->host()) { - qWarning() << party->host()->name() << "is having a birthday!"; - qWarning() << "They are inviting:"; - for (int ii = 0; ii < party->guestCount(); ++ii) - qWarning() << " " << party->guest(ii)->name(); - } else { - qWarning() << component.errors(); - } - - return 0; -} diff --git a/examples/declarative/cppextensions/referenceexamples/properties/person.cpp b/examples/declarative/cppextensions/referenceexamples/properties/person.cpp deleted file mode 100644 index 30d1e46e5a..0000000000 --- a/examples/declarative/cppextensions/referenceexamples/properties/person.cpp +++ /dev/null @@ -1,66 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include "person.h" - -Person::Person(QObject *parent) -: QObject(parent), m_shoeSize(0) -{ -} - -QString Person::name() const -{ - return m_name; -} - -void Person::setName(const QString &n) -{ - m_name = n; -} - -int Person::shoeSize() const -{ - return m_shoeSize; -} - -void Person::setShoeSize(int s) -{ - m_shoeSize = s; -} - diff --git a/examples/declarative/cppextensions/referenceexamples/properties/person.h b/examples/declarative/cppextensions/referenceexamples/properties/person.h deleted file mode 100644 index dd3ad4d188..0000000000 --- a/examples/declarative/cppextensions/referenceexamples/properties/person.h +++ /dev/null @@ -1,63 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#ifndef PERSON_H -#define PERSON_H - -#include - -class Person : public QObject -{ - Q_OBJECT - Q_PROPERTY(QString name READ name WRITE setName) - Q_PROPERTY(int shoeSize READ shoeSize WRITE setShoeSize) -public: - Person(QObject *parent = 0); - - QString name() const; - void setName(const QString &); - - int shoeSize() const; - void setShoeSize(int); -private: - QString m_name; - int m_shoeSize; -}; - -#endif // PERSON_H diff --git a/examples/declarative/cppextensions/referenceexamples/properties/properties.pro b/examples/declarative/cppextensions/referenceexamples/properties/properties.pro deleted file mode 100644 index 936d0ea429..0000000000 --- a/examples/declarative/cppextensions/referenceexamples/properties/properties.pro +++ /dev/null @@ -1,13 +0,0 @@ -QT += declarative - -SOURCES += main.cpp \ - person.cpp \ - birthdayparty.cpp -HEADERS += person.h \ - birthdayparty.h -RESOURCES += properties.qrc - -target.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/declarative/extending/properties -sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS properties.pro -sources.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/declarative/extending/properties -INSTALLS += target sources diff --git a/examples/declarative/cppextensions/referenceexamples/properties/properties.qrc b/examples/declarative/cppextensions/referenceexamples/properties/properties.qrc deleted file mode 100644 index e2fa01d5e7..0000000000 --- a/examples/declarative/cppextensions/referenceexamples/properties/properties.qrc +++ /dev/null @@ -1,5 +0,0 @@ - - - example.qml - - diff --git a/examples/declarative/cppextensions/referenceexamples/referenceexamples.pro b/examples/declarative/cppextensions/referenceexamples/referenceexamples.pro deleted file mode 100644 index 505cefd331..0000000000 --- a/examples/declarative/cppextensions/referenceexamples/referenceexamples.pro +++ /dev/null @@ -1,14 +0,0 @@ -TEMPLATE = subdirs - -SUBDIRS += \ - adding \ - attached \ - binding \ - coercion \ - default \ - extended \ - grouped \ - properties \ - signal \ - valuesource \ - methods diff --git a/examples/declarative/cppextensions/referenceexamples/referenceexamples.qmlproject b/examples/declarative/cppextensions/referenceexamples/referenceexamples.qmlproject deleted file mode 100644 index 2bb4016996..0000000000 --- a/examples/declarative/cppextensions/referenceexamples/referenceexamples.qmlproject +++ /dev/null @@ -1,14 +0,0 @@ -import QmlProject 1.0 - -Project { - /* Include .qml, .js, and image files from current directory and subdirectories */ - QmlFiles { - directory: "." - } - JavaScriptFiles { - directory: "." - } - ImageFiles { - directory: "." - } -} diff --git a/examples/declarative/cppextensions/referenceexamples/signal/birthdayparty.cpp b/examples/declarative/cppextensions/referenceexamples/signal/birthdayparty.cpp deleted file mode 100644 index d576c2a278..0000000000 --- a/examples/declarative/cppextensions/referenceexamples/signal/birthdayparty.cpp +++ /dev/null @@ -1,98 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include "birthdayparty.h" - -BirthdayPartyAttached::BirthdayPartyAttached(QObject *object) -: QObject(object) -{ -} - -QDate BirthdayPartyAttached::rsvp() const -{ - return m_rsvp; -} - -void BirthdayPartyAttached::setRsvp(const QDate &d) -{ - m_rsvp = d; -} - - -BirthdayParty::BirthdayParty(QObject *parent) -: QObject(parent), m_host(0) -{ -} - -Person *BirthdayParty::host() const -{ - return m_host; -} - -void BirthdayParty::setHost(Person *c) -{ - m_host = c; -} - -QDeclarativeListProperty BirthdayParty::guests() -{ - return QDeclarativeListProperty(this, m_guests); -} - -int BirthdayParty::guestCount() const -{ - return m_guests.count(); -} - -Person *BirthdayParty::guest(int index) const -{ - return m_guests.at(index); -} - -void BirthdayParty::startParty() -{ - QTime time = QTime::currentTime(); - emit partyStarted(time); -} - -BirthdayPartyAttached *BirthdayParty::qmlAttachedProperties(QObject *object) -{ - return new BirthdayPartyAttached(object); -} - diff --git a/examples/declarative/cppextensions/referenceexamples/signal/birthdayparty.h b/examples/declarative/cppextensions/referenceexamples/signal/birthdayparty.h deleted file mode 100644 index 45ad4f0acf..0000000000 --- a/examples/declarative/cppextensions/referenceexamples/signal/birthdayparty.h +++ /dev/null @@ -1,92 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#ifndef BIRTHDAYPARTY_H -#define BIRTHDAYPARTY_H - -#include -#include -#include -#include "person.h" - -class BirthdayPartyAttached : public QObject -{ - Q_OBJECT - Q_PROPERTY(QDate rsvp READ rsvp WRITE setRsvp) -public: - BirthdayPartyAttached(QObject *object); - - QDate rsvp() const; - void setRsvp(const QDate &); - -private: - QDate m_rsvp; -}; - -class BirthdayParty : public QObject -{ - Q_OBJECT - Q_PROPERTY(Person *host READ host WRITE setHost) - Q_PROPERTY(QDeclarativeListProperty guests READ guests) - Q_CLASSINFO("DefaultProperty", "guests") -public: - BirthdayParty(QObject *parent = 0); - - Person *host() const; - void setHost(Person *); - - QDeclarativeListProperty guests(); - int guestCount() const; - Person *guest(int) const; - - static BirthdayPartyAttached *qmlAttachedProperties(QObject *); - - void startParty(); -// ![0] -signals: - void partyStarted(const QTime &time); -// ![0] - -private: - Person *m_host; - QList m_guests; -}; -QML_DECLARE_TYPEINFO(BirthdayParty, QML_HAS_ATTACHED_PROPERTIES) - -#endif // BIRTHDAYPARTY_H diff --git a/examples/declarative/cppextensions/referenceexamples/signal/example.qml b/examples/declarative/cppextensions/referenceexamples/signal/example.qml deleted file mode 100644 index 796c2f32a1..0000000000 --- a/examples/declarative/cppextensions/referenceexamples/signal/example.qml +++ /dev/null @@ -1,72 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import People 1.0 - -BirthdayParty { -// ![0] - onPartyStarted: console.log("This party started rockin' at " + time); -// ![0] - - host: Boy { - name: "Bob Jones" - shoe { size: 12; color: "white"; brand: "Nike"; price: 90.0 } - } - - Boy { - name: "Leo Hodges" - BirthdayParty.rsvp: "2009-07-06" - shoe { size: 10; color: "black"; brand: "Reebok"; price: 59.95 } - } - Boy { - name: "Jack Smith" - shoe { size: 8; color: "blue"; brand: "Puma"; price: 19.95 } - } - Girl { - name: "Anne Brown" - BirthdayParty.rsvp: "2009-07-01" - shoe.size: 7 - shoe.color: "red" - shoe.brand: "Marc Jacobs" - shoe.price: 699.99 - } -// ![1] -} -// ![1] diff --git a/examples/declarative/cppextensions/referenceexamples/signal/main.cpp b/examples/declarative/cppextensions/referenceexamples/signal/main.cpp deleted file mode 100644 index 5800cf450f..0000000000 --- a/examples/declarative/cppextensions/referenceexamples/signal/main.cpp +++ /dev/null @@ -1,91 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include -#include -#include -#include -#include "birthdayparty.h" -#include "person.h" - -int main(int argc, char ** argv) -{ - QCoreApplication app(argc, argv); - - qmlRegisterType(); - qmlRegisterType("People", 1,0, "BirthdayParty"); - qmlRegisterType(); - qmlRegisterType(); - qmlRegisterType("People", 1,0, "Boy"); - qmlRegisterType("People", 1,0, "Girl"); - - QDeclarativeEngine engine; - QDeclarativeComponent component(&engine, QUrl("qrc:example.qml")); - BirthdayParty *party = qobject_cast(component.create()); - - if (party && party->host()) { - qWarning() << party->host()->name() << "is having a birthday!"; - - if (qobject_cast(party->host())) - qWarning() << "He is inviting:"; - else - qWarning() << "She is inviting:"; - - for (int ii = 0; ii < party->guestCount(); ++ii) { - Person *guest = party->guest(ii); - - QDate rsvpDate; - QObject *attached = - qmlAttachedPropertiesObject(guest, false); - if (attached) - rsvpDate = attached->property("rsvp").toDate(); - - if (rsvpDate.isNull()) - qWarning() << " " << guest->name() << "RSVP date: Hasn't RSVP'd"; - else - qWarning() << " " << guest->name() << "RSVP date:" << qPrintable(rsvpDate.toString()); - } - - party->startParty(); - } else { - qWarning() << component.errors(); - } - - return 0; -} diff --git a/examples/declarative/cppextensions/referenceexamples/signal/person.cpp b/examples/declarative/cppextensions/referenceexamples/signal/person.cpp deleted file mode 100644 index 7afcdc6ca6..0000000000 --- a/examples/declarative/cppextensions/referenceexamples/signal/person.cpp +++ /dev/null @@ -1,118 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include "person.h" - -ShoeDescription::ShoeDescription(QObject *parent) -: QObject(parent), m_size(0), m_price(0) -{ -} - -int ShoeDescription::size() const -{ - return m_size; -} - -void ShoeDescription::setSize(int s) -{ - m_size = s; -} - -QColor ShoeDescription::color() const -{ - return m_color; -} - -void ShoeDescription::setColor(const QColor &c) -{ - m_color = c; -} - -QString ShoeDescription::brand() const -{ - return m_brand; -} - -void ShoeDescription::setBrand(const QString &b) -{ - m_brand = b; -} - -qreal ShoeDescription::price() const -{ - return m_price; -} - -void ShoeDescription::setPrice(qreal p) -{ - m_price = p; -} - -Person::Person(QObject *parent) -: QObject(parent) -{ -} - -QString Person::name() const -{ - return m_name; -} - -void Person::setName(const QString &n) -{ - m_name = n; -} - -ShoeDescription *Person::shoe() -{ - return &m_shoe; -} - - -Boy::Boy(QObject * parent) -: Person(parent) -{ -} - - -Girl::Girl(QObject * parent) -: Person(parent) -{ -} - diff --git a/examples/declarative/cppextensions/referenceexamples/signal/person.h b/examples/declarative/cppextensions/referenceexamples/signal/person.h deleted file mode 100644 index 032eca3c17..0000000000 --- a/examples/declarative/cppextensions/referenceexamples/signal/person.h +++ /dev/null @@ -1,105 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#ifndef PERSON_H -#define PERSON_H - -#include -#include - -class ShoeDescription : public QObject -{ - Q_OBJECT - Q_PROPERTY(int size READ size WRITE setSize) - Q_PROPERTY(QColor color READ color WRITE setColor) - Q_PROPERTY(QString brand READ brand WRITE setBrand) - Q_PROPERTY(qreal price READ price WRITE setPrice) -public: - ShoeDescription(QObject *parent = 0); - - int size() const; - void setSize(int); - - QColor color() const; - void setColor(const QColor &); - - QString brand() const; - void setBrand(const QString &); - - qreal price() const; - void setPrice(qreal); -private: - int m_size; - QColor m_color; - QString m_brand; - qreal m_price; -}; - -class Person : public QObject -{ - Q_OBJECT - Q_PROPERTY(QString name READ name WRITE setName) - Q_PROPERTY(ShoeDescription *shoe READ shoe) -public: - Person(QObject *parent = 0); - - QString name() const; - void setName(const QString &); - - ShoeDescription *shoe(); -private: - QString m_name; - ShoeDescription m_shoe; -}; - -class Boy : public Person -{ - Q_OBJECT -public: - Boy(QObject * parent = 0); -}; - -class Girl : public Person -{ - Q_OBJECT -public: - Girl(QObject * parent = 0); -}; - -#endif // PERSON_H diff --git a/examples/declarative/cppextensions/referenceexamples/signal/signal.pro b/examples/declarative/cppextensions/referenceexamples/signal/signal.pro deleted file mode 100644 index 8ffdb50f90..0000000000 --- a/examples/declarative/cppextensions/referenceexamples/signal/signal.pro +++ /dev/null @@ -1,13 +0,0 @@ -QT += declarative - -SOURCES += main.cpp \ - person.cpp \ - birthdayparty.cpp -HEADERS += person.h \ - birthdayparty.h -RESOURCES += signal.qrc - -target.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/declarative/extending/signal -sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS signal.pro -sources.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/declarative/extending/signal -INSTALLS += target sources diff --git a/examples/declarative/cppextensions/referenceexamples/signal/signal.qrc b/examples/declarative/cppextensions/referenceexamples/signal/signal.qrc deleted file mode 100644 index e2fa01d5e7..0000000000 --- a/examples/declarative/cppextensions/referenceexamples/signal/signal.qrc +++ /dev/null @@ -1,5 +0,0 @@ - - - example.qml - - diff --git a/examples/declarative/cppextensions/referenceexamples/valuesource/birthdayparty.cpp b/examples/declarative/cppextensions/referenceexamples/valuesource/birthdayparty.cpp deleted file mode 100644 index 09137c41a8..0000000000 --- a/examples/declarative/cppextensions/referenceexamples/valuesource/birthdayparty.cpp +++ /dev/null @@ -1,108 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include "birthdayparty.h" - -BirthdayPartyAttached::BirthdayPartyAttached(QObject *object) -: QObject(object) -{ -} - -QDate BirthdayPartyAttached::rsvp() const -{ - return m_rsvp; -} - -void BirthdayPartyAttached::setRsvp(const QDate &d) -{ - m_rsvp = d; -} - - -BirthdayParty::BirthdayParty(QObject *parent) -: QObject(parent), m_host(0) -{ -} - -Person *BirthdayParty::host() const -{ - return m_host; -} - -void BirthdayParty::setHost(Person *c) -{ - m_host = c; -} - -QDeclarativeListProperty BirthdayParty::guests() -{ - return QDeclarativeListProperty(this, m_guests); -} - -int BirthdayParty::guestCount() const -{ - return m_guests.count(); -} - -Person *BirthdayParty::guest(int index) const -{ - return m_guests.at(index); -} - -void BirthdayParty::startParty() -{ - QTime time = QTime::currentTime(); - emit partyStarted(time); -} - -QString BirthdayParty::announcement() const -{ - return QString(); -} - -void BirthdayParty::setAnnouncement(const QString &speak) -{ - qWarning() << qPrintable(speak); -} - -BirthdayPartyAttached *BirthdayParty::qmlAttachedProperties(QObject *object) -{ - return new BirthdayPartyAttached(object); -} - diff --git a/examples/declarative/cppextensions/referenceexamples/valuesource/birthdayparty.h b/examples/declarative/cppextensions/referenceexamples/valuesource/birthdayparty.h deleted file mode 100644 index 5d561da807..0000000000 --- a/examples/declarative/cppextensions/referenceexamples/valuesource/birthdayparty.h +++ /dev/null @@ -1,97 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#ifndef BIRTHDAYPARTY_H -#define BIRTHDAYPARTY_H - -#include -#include -#include -#include -#include "person.h" - -class BirthdayPartyAttached : public QObject -{ - Q_OBJECT - Q_PROPERTY(QDate rsvp READ rsvp WRITE setRsvp) -public: - BirthdayPartyAttached(QObject *object); - - QDate rsvp() const; - void setRsvp(const QDate &); - -private: - QDate m_rsvp; -}; - -class BirthdayParty : public QObject -{ - Q_OBJECT - Q_PROPERTY(Person *host READ host WRITE setHost) - Q_PROPERTY(QDeclarativeListProperty guests READ guests) -// ![0] - Q_PROPERTY(QString announcement READ announcement WRITE setAnnouncement) -// ![0] - Q_CLASSINFO("DefaultProperty", "guests") -public: - BirthdayParty(QObject *parent = 0); - - Person *host() const; - void setHost(Person *); - - QDeclarativeListProperty guests(); - int guestCount() const; - Person *guest(int) const; - - QString announcement() const; - void setAnnouncement(const QString &); - - static BirthdayPartyAttached *qmlAttachedProperties(QObject *); - - void startParty(); -signals: - void partyStarted(const QTime &time); - -private: - Person *m_host; - QList m_guests; -}; -QML_DECLARE_TYPEINFO(BirthdayParty, QML_HAS_ATTACHED_PROPERTIES) - -#endif // BIRTHDAYPARTY_H diff --git a/examples/declarative/cppextensions/referenceexamples/valuesource/example.qml b/examples/declarative/cppextensions/referenceexamples/valuesource/example.qml deleted file mode 100644 index 04c3048e9e..0000000000 --- a/examples/declarative/cppextensions/referenceexamples/valuesource/example.qml +++ /dev/null @@ -1,76 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import People 1.0 - -// ![0] -BirthdayParty { - HappyBirthdaySong on announcement { name: "Bob Jones" } -// ![0] - - onPartyStarted: console.log("This party started rockin' at " + time); - - - host: Boy { - name: "Bob Jones" - shoe { size: 12; color: "white"; brand: "Nike"; price: 90.0 } - } - - Boy { - name: "Leo Hodges" - BirthdayParty.rsvp: "2009-07-06" - shoe { size: 10; color: "black"; brand: "Reebok"; price: 59.95 } - } - Boy { - name: "Jack Smith" - shoe { size: 8; color: "blue"; brand: "Puma"; price: 19.95 } - } - Girl { - name: "Anne Brown" - BirthdayParty.rsvp: "2009-07-01" - shoe.size: 7 - shoe.color: "red" - shoe.brand: "Marc Jacobs" - shoe.price: 699.99 - } - -// ![1] -} -// ![1] diff --git a/examples/declarative/cppextensions/referenceexamples/valuesource/happybirthdaysong.cpp b/examples/declarative/cppextensions/referenceexamples/valuesource/happybirthdaysong.cpp deleted file mode 100644 index 629c354543..0000000000 --- a/examples/declarative/cppextensions/referenceexamples/valuesource/happybirthdaysong.cpp +++ /dev/null @@ -1,80 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include "happybirthdaysong.h" -#include - -HappyBirthdaySong::HappyBirthdaySong(QObject *parent) -: QObject(parent), m_line(-1) -{ - setName(QString()); - QTimer *timer = new QTimer(this); - QObject::connect(timer, SIGNAL(timeout()), this, SLOT(advance())); - timer->start(1000); -} - -void HappyBirthdaySong::setTarget(const QDeclarativeProperty &p) -{ - m_target = p; -} - -QString HappyBirthdaySong::name() const -{ - return m_name; -} - -void HappyBirthdaySong::setName(const QString &name) -{ - m_name = name; - - m_lyrics.clear(); - m_lyrics << "Happy birthday to you,"; - m_lyrics << "Happy birthday to you,"; - m_lyrics << "Happy birthday dear " + m_name + ","; - m_lyrics << "Happy birthday to you!"; - m_lyrics << ""; -} - -void HappyBirthdaySong::advance() -{ - m_line = (m_line + 1) % m_lyrics.count(); - - m_target.write(m_lyrics.at(m_line)); -} - diff --git a/examples/declarative/cppextensions/referenceexamples/valuesource/happybirthdaysong.h b/examples/declarative/cppextensions/referenceexamples/valuesource/happybirthdaysong.h deleted file mode 100644 index 9721350435..0000000000 --- a/examples/declarative/cppextensions/referenceexamples/valuesource/happybirthdaysong.h +++ /dev/null @@ -1,79 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#ifndef HAPPYBIRTHDAYSONG_H -#define HAPPYBIRTHDAYSONG_H - -#include -#include -#include - -#include - -// ![0] -class HappyBirthdaySong : public QObject, public QDeclarativePropertyValueSource -{ - Q_OBJECT - Q_INTERFACES(QDeclarativePropertyValueSource) -// ![0] - Q_PROPERTY(QString name READ name WRITE setName) -// ![1] -public: - HappyBirthdaySong(QObject *parent = 0); - - virtual void setTarget(const QDeclarativeProperty &); -// ![1] - - QString name() const; - void setName(const QString &); - -private slots: - void advance(); - -private: - int m_line; - QStringList m_lyrics; - QDeclarativeProperty m_target; - QString m_name; -// ![2] -}; -// ![2] - -#endif // HAPPYBIRTHDAYSONG_H - diff --git a/examples/declarative/cppextensions/referenceexamples/valuesource/main.cpp b/examples/declarative/cppextensions/referenceexamples/valuesource/main.cpp deleted file mode 100644 index 53d676dfbe..0000000000 --- a/examples/declarative/cppextensions/referenceexamples/valuesource/main.cpp +++ /dev/null @@ -1,93 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include -#include -#include -#include -#include "birthdayparty.h" -#include "happybirthdaysong.h" -#include "person.h" - -int main(int argc, char ** argv) -{ - QCoreApplication app(argc, argv); - - qmlRegisterType(); - qmlRegisterType("People", 1,0, "BirthdayParty"); - qmlRegisterType("People", 1,0, "HappyBirthdaySong"); - qmlRegisterType(); - qmlRegisterType(); - qmlRegisterType("People", 1,0, "Boy"); - qmlRegisterType("People", 1,0, "Girl"); - - QDeclarativeEngine engine; - QDeclarativeComponent component(&engine, QUrl("qrc:example.qml")); - BirthdayParty *party = qobject_cast(component.create()); - - if (party && party->host()) { - qWarning() << party->host()->name() << "is having a birthday!"; - - if (qobject_cast(party->host())) - qWarning() << "He is inviting:"; - else - qWarning() << "She is inviting:"; - - for (int ii = 0; ii < party->guestCount(); ++ii) { - Person *guest = party->guest(ii); - - QDate rsvpDate; - QObject *attached = - qmlAttachedPropertiesObject(guest, false); - if (attached) - rsvpDate = attached->property("rsvp").toDate(); - - if (rsvpDate.isNull()) - qWarning() << " " << guest->name() << "RSVP date: Hasn't RSVP'd"; - else - qWarning() << " " << guest->name() << "RSVP date:" << qPrintable(rsvpDate.toString()); - } - - party->startParty(); - } else { - qWarning() << component.errors(); - } - - return app.exec(); -} diff --git a/examples/declarative/cppextensions/referenceexamples/valuesource/person.cpp b/examples/declarative/cppextensions/referenceexamples/valuesource/person.cpp deleted file mode 100644 index 7afcdc6ca6..0000000000 --- a/examples/declarative/cppextensions/referenceexamples/valuesource/person.cpp +++ /dev/null @@ -1,118 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include "person.h" - -ShoeDescription::ShoeDescription(QObject *parent) -: QObject(parent), m_size(0), m_price(0) -{ -} - -int ShoeDescription::size() const -{ - return m_size; -} - -void ShoeDescription::setSize(int s) -{ - m_size = s; -} - -QColor ShoeDescription::color() const -{ - return m_color; -} - -void ShoeDescription::setColor(const QColor &c) -{ - m_color = c; -} - -QString ShoeDescription::brand() const -{ - return m_brand; -} - -void ShoeDescription::setBrand(const QString &b) -{ - m_brand = b; -} - -qreal ShoeDescription::price() const -{ - return m_price; -} - -void ShoeDescription::setPrice(qreal p) -{ - m_price = p; -} - -Person::Person(QObject *parent) -: QObject(parent) -{ -} - -QString Person::name() const -{ - return m_name; -} - -void Person::setName(const QString &n) -{ - m_name = n; -} - -ShoeDescription *Person::shoe() -{ - return &m_shoe; -} - - -Boy::Boy(QObject * parent) -: Person(parent) -{ -} - - -Girl::Girl(QObject * parent) -: Person(parent) -{ -} - diff --git a/examples/declarative/cppextensions/referenceexamples/valuesource/person.h b/examples/declarative/cppextensions/referenceexamples/valuesource/person.h deleted file mode 100644 index 032eca3c17..0000000000 --- a/examples/declarative/cppextensions/referenceexamples/valuesource/person.h +++ /dev/null @@ -1,105 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#ifndef PERSON_H -#define PERSON_H - -#include -#include - -class ShoeDescription : public QObject -{ - Q_OBJECT - Q_PROPERTY(int size READ size WRITE setSize) - Q_PROPERTY(QColor color READ color WRITE setColor) - Q_PROPERTY(QString brand READ brand WRITE setBrand) - Q_PROPERTY(qreal price READ price WRITE setPrice) -public: - ShoeDescription(QObject *parent = 0); - - int size() const; - void setSize(int); - - QColor color() const; - void setColor(const QColor &); - - QString brand() const; - void setBrand(const QString &); - - qreal price() const; - void setPrice(qreal); -private: - int m_size; - QColor m_color; - QString m_brand; - qreal m_price; -}; - -class Person : public QObject -{ - Q_OBJECT - Q_PROPERTY(QString name READ name WRITE setName) - Q_PROPERTY(ShoeDescription *shoe READ shoe) -public: - Person(QObject *parent = 0); - - QString name() const; - void setName(const QString &); - - ShoeDescription *shoe(); -private: - QString m_name; - ShoeDescription m_shoe; -}; - -class Boy : public Person -{ - Q_OBJECT -public: - Boy(QObject * parent = 0); -}; - -class Girl : public Person -{ - Q_OBJECT -public: - Girl(QObject * parent = 0); -}; - -#endif // PERSON_H diff --git a/examples/declarative/cppextensions/referenceexamples/valuesource/valuesource.pro b/examples/declarative/cppextensions/referenceexamples/valuesource/valuesource.pro deleted file mode 100644 index a978d8452a..0000000000 --- a/examples/declarative/cppextensions/referenceexamples/valuesource/valuesource.pro +++ /dev/null @@ -1,15 +0,0 @@ -QT += declarative - -SOURCES += main.cpp \ - person.cpp \ - birthdayparty.cpp \ - happybirthdaysong.cpp -HEADERS += person.h \ - birthdayparty.h \ - happybirthdaysong.h -RESOURCES += valuesource.qrc - -target.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/declarative/extending/valuesource -sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS valuesource.pro -sources.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/declarative/extending/valuesource -INSTALLS += target sources diff --git a/examples/declarative/cppextensions/referenceexamples/valuesource/valuesource.qrc b/examples/declarative/cppextensions/referenceexamples/valuesource/valuesource.qrc deleted file mode 100644 index e2fa01d5e7..0000000000 --- a/examples/declarative/cppextensions/referenceexamples/valuesource/valuesource.qrc +++ /dev/null @@ -1,5 +0,0 @@ - - - example.qml - - diff --git a/examples/declarative/declarative.pro b/examples/declarative/declarative.pro deleted file mode 100644 index 883c0afe2d..0000000000 --- a/examples/declarative/declarative.pro +++ /dev/null @@ -1,38 +0,0 @@ -TEMPLATE = subdirs - -# These examples contain some C++ and need to be built -SUBDIRS = \ - cppextensions \ - minehunt \ - modelviews \ - painteditem \ - tutorials \ - script - -# These examples contain no C++ and can simply be copied -sources.files = \ - animation \ - calculator \ - cppextensions \ - flickr \ - i18n \ - imageelements \ - keyinteraction \ - photoviewer \ - positioners \ - rssnews \ - samegame \ - snake \ - sqllocalstorage \ - text \ - threading \ - touchinteraction \ - toys \ - twitter \ - ui-components \ - webbrowser \ - xml - - -sources.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/declarative -INSTALLS += sources diff --git a/examples/declarative/draganddrop/dragtarget.qmlproject b/examples/declarative/draganddrop/dragtarget.qmlproject deleted file mode 100644 index 2bb4016996..0000000000 --- a/examples/declarative/draganddrop/dragtarget.qmlproject +++ /dev/null @@ -1,14 +0,0 @@ -import QmlProject 1.0 - -Project { - /* Include .qml, .js, and image files from current directory and subdirectories */ - QmlFiles { - directory: "." - } - JavaScriptFiles { - directory: "." - } - ImageFiles { - directory: "." - } -} diff --git a/examples/declarative/draganddrop/tiles/DragTile.qml b/examples/declarative/draganddrop/tiles/DragTile.qml deleted file mode 100644 index 2813fa8caf..0000000000 --- a/examples/declarative/draganddrop/tiles/DragTile.qml +++ /dev/null @@ -1,89 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -Item { - id: root - property string colorKey - - width: 100; height: 100 - - MouseArea { - id: mouseArea - - width: 100; height: 100 - anchors.centerIn: parent - - drag.target: tile - - onReleased: parent = tile.Drag.target !== null ? tile.Drag.target : root - - Rectangle { - id: tile - - width: 100; height: 100 - - anchors.horizontalCenter: parent.horizontalCenter; anchors.verticalCenter: parent.verticalCenter - color: colorKey - - Drag.keys: [ colorKey ] - Drag.active: mouseArea.drag.active - Drag.hotSpot.x: 50 - Drag.hotSpot.y: 50 - - Text { - anchors.fill: parent - color: "white" - font.pixelSize: 90 - text: modelData + 1 - horizontalAlignment:Text.AlignHCenter - verticalAlignment: Text.AlignVCenter - } - - states: State { - when: mouseArea.drag.active - ParentChange { target: tile; parent: root } - AnchorChanges { target: tile; anchors.verticalCenter: undefined; anchors.horizontalCenter: undefined } - } - } - } -} - diff --git a/examples/declarative/draganddrop/tiles/DropTile.qml b/examples/declarative/draganddrop/tiles/DropTile.qml deleted file mode 100644 index e8566f04cc..0000000000 --- a/examples/declarative/draganddrop/tiles/DropTile.qml +++ /dev/null @@ -1,68 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -DropArea { - id: dragTarget - - property string colorKey - property alias dropProxy: dragTarget - - width: 100; height: 100 - keys: [ colorKey ] - - Rectangle { - id: dropRectangle - - anchors.fill: parent - color: colorKey - - states: [ - State { - when: dragTarget.containsDrag - PropertyChanges { - target: dropRectangle - color: "grey" - } - } - ] - } -} diff --git a/examples/declarative/draganddrop/tiles/tiles.qml b/examples/declarative/draganddrop/tiles/tiles.qml deleted file mode 100644 index 31c87f8244..0000000000 --- a/examples/declarative/draganddrop/tiles/tiles.qml +++ /dev/null @@ -1,109 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -Rectangle { - id: root - - width: 620 - height: 410 - - color: "black" - - Grid { - id: redDestination - - anchors.left: redSource.right; anchors.top: parent.top; - anchors.margins: 5 - width: 300 - height: 300 - opacity: 0.5 - columns: 3 - - Repeater { - model: 9; - delegate: DropTile { colorKey: "red" } - } - } - - Grid { - anchors.right: blueSource.left; anchors.bottom: parent.bottom; - anchors.margins: 5 - width: 300 - height: 300 - - opacity: 0.5 - - columns: 3 - - Repeater { - model: 9 - delegate: DropTile { colorKey: "blue" } - } - } - - Column { - id: redSource - - anchors.left: parent.left; anchors.top: parent.top; anchors.bottom: parent.bottom - anchors.margins: 5 - width: 100 - spacing: -60 - - Repeater { - model: 9 - delegate: DragTile { colorKey: "red" } - } - } - Column { - id: blueSource - - anchors.right: parent.right; anchors.top: parent.top; anchors.bottom: parent.bottom - anchors.margins: 5 - width: 100 - spacing: -60 - - Repeater { - model: 9 - delegate: DragTile { colorKey: "blue" } - } - } -} diff --git a/examples/declarative/draganddrop/views/gridview.qml b/examples/declarative/draganddrop/views/gridview.qml deleted file mode 100644 index 375f3d2824..0000000000 --- a/examples/declarative/draganddrop/views/gridview.qml +++ /dev/null @@ -1,117 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -GridView { - id: root - width: 360; height: 360 - cellWidth: 90; cellHeight: 90 - - model: VisualDataModel { - id: visualModel - model: ListModel { - id: colorModel - ListElement { color: "blue" } - ListElement { color: "green" } - ListElement { color: "red" } - ListElement { color: "yellow" } - ListElement { color: "orange" } - ListElement { color: "purple" } - ListElement { color: "cyan" } - ListElement { color: "magenta" } - ListElement { color: "chartreuse" } - ListElement { color: "aquamarine" } - ListElement { color: "indigo" } - ListElement { color: "black" } - ListElement { color: "chartreuse" } - ListElement { color: "violet" } - ListElement { color: "grey" } - ListElement { color: "springgreen" } - } - - delegate: MouseArea { - id: delegateRoot - - property int visualIndex: VisualDataModel.itemsIndex - - width: 90; height: 90 - drag.target: icon - - Rectangle { - id: icon - width: 80; height: 80 - anchors { - horizontalCenter: parent.horizontalCenter; - verticalCenter: parent.verticalCenter - } - color: model.color - radius: 3 - - Drag.active: delegateRoot.pressed - Drag.source: delegateRoot - Drag.hotSpot.x: 40 - Drag.hotSpot.y: 40 - - states: [ - State { - when: icon.Drag.active - ParentChange { - target: icon - parent: root - } - - AnchorChanges { - target: icon; - anchors.horizontalCenter: undefined; - anchors.verticalCenter: undefined - } - } - ] - } - - DropArea { - anchors { fill: parent; margins: 15 } - - onEntered: visualModel.items.move(drag.source.visualIndex, delegateRoot.visualIndex) - } - } - } -} diff --git a/examples/declarative/flickr/content/Button.qml b/examples/declarative/flickr/content/Button.qml deleted file mode 100644 index d6a8d3e001..0000000000 --- a/examples/declarative/flickr/content/Button.qml +++ /dev/null @@ -1,79 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -Item { - id: container - - signal clicked - - property string text - - BorderImage { - id: buttonImage - source: "images/toolbutton.sci" - width: container.width; height: container.height - } - BorderImage { - id: pressed - opacity: 0 - source: "images/toolbutton.sci" - width: container.width; height: container.height - } - MouseArea { - id: mouseRegion - anchors.fill: buttonImage - onClicked: { container.clicked(); } - } - Text { - color: "white" - anchors.centerIn: buttonImage; font.bold: true; font.pixelSize: 15 - text: container.text; style: Text.Raised; styleColor: "black" - } - states: [ - State { - name: "Pressed" - when: mouseRegion.pressed == true - PropertyChanges { target: pressed; opacity: 1 } - } - ] -} diff --git a/examples/declarative/flickr/content/GridDelegate.qml b/examples/declarative/flickr/content/GridDelegate.qml deleted file mode 100644 index 794d768c74..0000000000 --- a/examples/declarative/flickr/content/GridDelegate.qml +++ /dev/null @@ -1,111 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -Item { - id: wrapper; width: GridView.view.cellWidth; height: GridView.view.cellHeight - - function photoClicked() { - imageDetails.photoTitle = title; - imageDetails.photoTags = tags; - imageDetails.photoWidth = photoWidth; - imageDetails.photoHeight = photoHeight; - imageDetails.photoType = photoType; - imageDetails.photoAuthor = photoAuthor; - imageDetails.photoDate = photoDate; - imageDetails.photoUrl = url; - imageDetails.rating = 0; - scaleMe.state = "Details"; - } - - Item { - anchors.centerIn: parent - scale: 0.0 - Behavior on scale { NumberAnimation { easing.type: Easing.InOutQuad} } - id: scaleMe - - Item { - width: 77; height: 77; anchors.centerIn: parent - Rectangle { - id: whiteRect; width: 77; height: 77; color: "#dddddd"; smooth: true - Image { id: thumb; source: imagePath; x: 1; y: 1; smooth: true } - Image { source: "images/gloss.png" } - } - } - - Connections { - target: toolBar - onButton2Clicked: if (scaleMe.state == 'Details' ) scaleMe.state = 'Show' - } - - states: [ - State { - name: "Show"; when: thumb.status == Image.Ready - PropertyChanges { target: scaleMe; scale: 1 } - }, - State { - name: "Details" - PropertyChanges { target: scaleMe; scale: 1 } - ParentChange { target: whiteRect; x: 10; y: 20; parent: imageDetails.frontContainer } - PropertyChanges { target: background; state: "DetailedView" } - } - ] - transitions: [ - Transition { - from: "Show"; to: "Details" - ParentAnimation { - via: foreground - NumberAnimation { properties: "x,y"; duration: 500; easing.type: Easing.InOutQuad } - } - }, - Transition { - from: "Details"; to: "Show" - ParentAnimation { - via: foreground - NumberAnimation { properties: "x,y"; duration: 500; easing.type: Easing.InOutQuad } - } - } - ] - } - MouseArea { anchors.fill: wrapper; onClicked: photoClicked() } -} - diff --git a/examples/declarative/flickr/content/ImageDetails.qml b/examples/declarative/flickr/content/ImageDetails.qml deleted file mode 100644 index 83f2537d65..0000000000 --- a/examples/declarative/flickr/content/ImageDetails.qml +++ /dev/null @@ -1,323 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 -import QtQuick.Particles 2.0 - -Flipable { - id: container - - property alias frontContainer: containerFront - property string photoTitle: "" - property string photoTags: "" - property int photoWidth - property int photoHeight - property string photoType - property string photoAuthor - property string photoDate - property string photoUrl - property int rating: 2 - property variant prevScale: 1.0 - - property int flipDuration: 1600 - - signal closed - - transform: Rotation { - id: itemRotation - origin.x: container.width / 2; - axis.y: 1; axis.z: 0 - } - - front: Item { - id: containerFront; anchors.fill: container - - Rectangle { - anchors.fill: parent - color: "black"; opacity: 0.4 - } - - Column { - spacing: 10 - anchors { - left: parent.left; leftMargin: 10 - right: parent.right; rightMargin: 10 - top: parent.top; topMargin: 120 - } - Text { font.bold: true; color: "white"; elide: Text.ElideRight; text: container.photoTitle; width: parent.width } - Text { color: "white"; elide: Text.ElideRight; text: "Size: " + container.photoWidth + 'x' + container.photoHeight; width: parent.width } - Text { color: "white"; elide: Text.ElideRight; text: "Type: " + container.photoType; width: parent.width } - Text { color: "white"; elide: Text.ElideRight; text: "Author: " + container.photoAuthor; width: parent.width } - Text { color: "white"; elide: Text.ElideRight; text: "Published: " + container.photoDate; width: parent.width } - Text { color: "white"; elide: Text.ElideRight; text: container.photoTags == "" ? "" : "Tags: "; width: parent.width } - Text { color: "white"; elide: Text.ElideRight; text: container.photoTags; width: parent.width } - } - } - - back: Item { - anchors.fill: container - - Rectangle { anchors.fill: parent; color: "black"; opacity: 0.4 } - - Progress { - anchors.centerIn: parent; width: 200; height: 22 - progress: bigImage.progress; visible: bigImage.status != Image.Ready - } - - Flickable { - id: flickable; anchors.fill: parent; clip: true - contentWidth: imageContainer.width; contentHeight: imageContainer.height - - function updateMinimumScale() { - if (bigImage.status == Image.Ready && bigImage.width != 0) { - slider.minimum = Math.min(flickable.width / bigImage.width, flickable.height / bigImage.height); - if (bigImage.width * slider.value > flickable.width) { - var xoff = (flickable.width/2 + flickable.contentX) * slider.value / prevScale; - flickable.contentX = xoff - flickable.width/2; - } - if (bigImage.height * slider.value > flickable.height) { - var yoff = (flickable.height/2 + flickable.contentY) * slider.value / prevScale; - flickable.contentY = yoff - flickable.height/2; - } - prevScale = slider.value; - } - } - - onWidthChanged: updateMinimumScale() - onHeightChanged: updateMinimumScale() - - Item { - id: imageContainer - width: Math.max(bigImage.width * bigImage.scale, flickable.width); - height: Math.max(bigImage.height * bigImage.scale, flickable.height); - Image { - id: bigImage; source: container.photoUrl; scale: slider.value - anchors.centerIn: parent; smooth: !flickable.movingVertically - onStatusChanged : { - // Default scale shows the entire image. - if (bigImage.status == Image.Ready && bigImage.width != 0) { - slider.minimum = Math.min(flickable.width / bigImage.width, flickable.height / bigImage.height); - prevScale = Math.min(slider.minimum, 1); - slider.value = prevScale; - } - if (inBackState && bigImage.status == Image.Ready) - effectBox.imageInAnim(); - } - property bool inBackState: false - onInBackStateChanged:{ - if(inBackState && bigImage.status == Image.Ready) - effectBox.imageInAnim(); - else if (!inBackState && bigImage.status == Image.Ready) - effectBox.imageOutAnim(); - } - } - ShaderEffectSource{ - id: pictureSource - sourceItem: bigImage - smooth: true - //Workaround: Doesn't work below lines - width: bigImage.width - height: bigImage.width - visible: false - } - Turbulence{//only fill visible rect - id: turbulence - system: imageSystem - anchors.fill: parent - strength: 240 - enabled: false - } - - Item{ - id: effectBox - width: bigImage.width * bigImage.scale - height: bigImage.height * bigImage.scale - anchors.centerIn: parent - function imageInAnim(){ - bigImage.visible = false; - noiseIn.visible = true; - endEffectTimer.start(); - } - function imageOutAnim(){ - bigImage.visible = false; - noiseIn.visible = false; - turbulence.enabled = true; - endEffectTimer.start(); - pixelEmitter.burst(2048); - } - Timer{ - id: endEffectTimer - interval: flipDuration - repeat: false - running: false - onTriggered:{ - turbulence.enabled = false; - noiseIn.visible = false; - bigImage.visible = true; - } - } - ShaderEffect{ - id: noiseIn - anchors.fill: parent - property real t: 0 - visible: false - onVisibleChanged: tAnim.start() - NumberAnimation{ - id: tAnim - target: noiseIn - property: "t" - from: 0.0 - to: 1.0 - duration: flipDuration - } - property variant source: pictureSource - property variant noise: ShaderEffectSource{ - sourceItem:Image{ - source: "images/noise.png" - } - hideSource: true - smooth: false - } - fragmentShader:" - uniform sampler2D noise; - uniform sampler2D source; - uniform highp float t; - uniform lowp float qt_Opacity; - varying highp vec2 qt_TexCoord0; - void main(){ - //Want to use noise2, but it always returns (0,0)? - if(texture2D(noise, qt_TexCoord0).w <= t) - gl_FragColor = texture2D(source, qt_TexCoord0) * qt_Opacity; - else - gl_FragColor = vec4(0.,0.,0.,0.); - } - " - } - ParticleSystem{ - id: imageSystem - } - Emitter{ - id: pixelEmitter - system: imageSystem - //anchors.fill: parent - width: Math.min(bigImage.width * bigImage.scale, flickable.width); - height: Math.min(bigImage.height * bigImage.scale, flickable.height); - anchors.centerIn: parent - size: 4 - lifeSpan: flipDuration - emitRate: 2048 - enabled: false - } - CustomParticle{ - id: blowOut - system: imageSystem - property real maxWidth: effectBox.width - property real maxHeight: effectBox.height - vertexShader:" - uniform highp float maxWidth; - uniform highp float maxHeight; - - varying highp vec2 fTex2; - - void main() { - defaultMain(); - fTex2 = vec2(qt_ParticlePos.x / maxWidth, qt_ParticlePos.y / maxHeight); - } - " - property variant pictureTexture: pictureSource - fragmentShader: " - uniform lowp float qt_Opacity; - uniform sampler2D pictureTexture; - varying highp vec2 fTex2; - void main() { - gl_FragColor = texture2D(pictureTexture, fTex2) * qt_Opacity; - }" - } - - - - } - } - } - - Text { - text: "Image Unavailable" - visible: bigImage.status == Image.Error - anchors.centerIn: parent; color: "white"; font.bold: true - } - - Slider { - id: slider; visible: { bigImage.status == Image.Ready && maximum > minimum } - anchors { - bottom: parent.bottom; bottomMargin: 65 - left: parent.left; leftMargin: 25 - right: parent.right; rightMargin: 25 - } - onValueChanged: { - if (bigImage.width * value > flickable.width) { - var xoff = (flickable.width/2 + flickable.contentX) * value / prevScale; - flickable.contentX = xoff - flickable.width/2; - } - if (bigImage.height * value > flickable.height) { - var yoff = (flickable.height/2 + flickable.contentY) * value / prevScale; - flickable.contentY = yoff - flickable.height/2; - } - prevScale = value; - } - } - } - - states: State { - name: "Back" - PropertyChanges { target: itemRotation; angle: 180 } - PropertyChanges { target: toolBar; button2Visible: false } - PropertyChanges { target: toolBar; button1Label: "Back" } - PropertyChanges { target: bigImage; inBackState: true } - } - - transitions: Transition { - SequentialAnimation { - PropertyAction { target: bigImage; property: "smooth"; value: false } - NumberAnimation { easing.type: Easing.InOutQuad; properties: "angle"; duration: flipDuration } - PropertyAction { target: bigImage; property: "smooth"; value: !flickable.movingVertically } - } - } -} diff --git a/examples/declarative/flickr/content/ListDelegate.qml b/examples/declarative/flickr/content/ListDelegate.qml deleted file mode 100644 index 9c239151f1..0000000000 --- a/examples/declarative/flickr/content/ListDelegate.qml +++ /dev/null @@ -1,64 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -Component { - Item { - id: wrapper; width: wrapper.ListView.view.width; height: 86 - Item { - id: moveMe - Rectangle { color: "black"; opacity: index % 2 ? 0.2 : 0.4; height: 84; width: wrapper.width; y: 1 } - Rectangle { - x: 6; y: 4; width: 77; height: 77; color: "white"; smooth: true - - Image { source: imagePath; x: 1; y: 1 } - Image { source: "images/gloss.png" } - } - Column { - x: 92; width: wrapper.ListView.view.width - 95; y: 15; spacing: 2 - Text { text: title; color: "white"; width: parent.width; font.pixelSize: 14; font.bold: true; elide: Text.ElideRight; style: Text.Raised; styleColor: "black" } - Text { text: photoAuthor; width: parent.width; font.pixelSize: 14; elide: Text.ElideLeft; color: "#cccccc"; style: Text.Raised; styleColor: "black" } - Text { text: photoDate; width: parent.width; font.pixelSize: 14; elide: Text.ElideRight; color: "#cccccc"; style: Text.Raised; styleColor: "black" } - } - } - } -} diff --git a/examples/declarative/flickr/content/Progress.qml b/examples/declarative/flickr/content/Progress.qml deleted file mode 100644 index 81f1e79ed6..0000000000 --- a/examples/declarative/flickr/content/Progress.qml +++ /dev/null @@ -1,88 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 -import QtQuick.Particles 2.0 - -Item{ - id: container - property variant progress: 0 - - Rectangle { - anchors.fill: parent; smooth: true - border.color: "white"; border.width: 0; radius: height/2 - 2 - gradient: Gradient { - GradientStop { position: 0; color: "#66343434" } - GradientStop { position: 1.0; color: "#66000000" } - } - } - - ParticleSystem{ - running: container.visible - id: barSys - } - ImageParticle{ - color: "lightsteelblue" - alpha: 0.1 - colorVariation: 0.05 - source: "images/particle.png" - system: barSys - } - Emitter{ - y: 2; height: parent.height-4; - x: 2; width: Math.max(parent.width * progress - 4, 0); - speed: AngleDirection{ angleVariation: 180; magnitudeVariation: 12 } - system: barSys - emitRate: width; - lifeSpan: 1000 - size: 20 - sizeVariation: 4 - endSize: 12 - maximumEmitted: parent.width; - } - - Text { - text: Math.round(progress * 100) + "%" - anchors.horizontalCenter: parent.horizontalCenter - anchors.verticalCenter: parent.verticalCenter - color: Qt.rgba(1.0, 1.0 - progress, 1.0 - progress,0.9); font.bold: true; font.pixelSize: 15 - } -} diff --git a/examples/declarative/flickr/content/RssModel.qml b/examples/declarative/flickr/content/RssModel.qml deleted file mode 100644 index f28a23d502..0000000000 --- a/examples/declarative/flickr/content/RssModel.qml +++ /dev/null @@ -1,64 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 -import QtQuick.XmlListModel 2.0 - -XmlListModel { - property string tags : "" - - function encodeTags(x) { return encodeURIComponent(x.replace(' ',',')); } - - source: "http://api.flickr.com/services/feeds/photos_public.gne?"+(tags ? "tags="+encodeTags(tags)+"&" : "")+"format=rss2" - query: "/rss/channel/item" - namespaceDeclarations: "declare namespace media=\"http://search.yahoo.com/mrss/\";" - - XmlRole { name: "title"; query: "title/string()" } - XmlRole { name: "imagePath"; query: "media:thumbnail/@url/string()" } - XmlRole { name: "url"; query: "media:content/@url/string()" } - XmlRole { name: "description"; query: "description/string()" } - XmlRole { name: "tags"; query: "media:category/string()" } - XmlRole { name: "photoWidth"; query: "media:content/@width/string()" } - XmlRole { name: "photoHeight"; query: "media:content/@height/string()" } - XmlRole { name: "photoType"; query: "media:content/@type/string()" } - XmlRole { name: "photoAuthor"; query: "author/string()" } - XmlRole { name: "photoDate"; query: "pubDate/string()" } -} diff --git a/examples/declarative/flickr/content/ScrollBar.qml b/examples/declarative/flickr/content/ScrollBar.qml deleted file mode 100644 index 388e43dc2d..0000000000 --- a/examples/declarative/flickr/content/ScrollBar.qml +++ /dev/null @@ -1,81 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -Item { - id: container - - property variant flickableArea - - Rectangle { - radius: 5 - color: "black" - opacity: 0.3 - border.color: "white" - border.width: 2 - x: 0 - y: flickableArea.visibleArea.yPosition * container.height - width: parent.width - height: flickableArea.visibleArea.heightRatio * container.height - } - states: [ - State { - name: "show" - when: flickableArea.movingVertically - PropertyChanges { - target: container - opacity: 1 - } - } - ] - transitions: [ - Transition { - from: "*" - to: "*" - NumberAnimation { - target: container - properties: "opacity" - duration: 400 - } - } - ] -} diff --git a/examples/declarative/flickr/content/Slider.qml b/examples/declarative/flickr/content/Slider.qml deleted file mode 100644 index 0f9e8b20f2..0000000000 --- a/examples/declarative/flickr/content/Slider.qml +++ /dev/null @@ -1,91 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -Item { - id: slider; width: 400; height: 16 - - // value is read/write. - property real value: 1 - onValueChanged: updatePos(); - property real maximum: 1 - property real minimum: 1 - property int xMax: width - handle.width - 4 - onXMaxChanged: updatePos(); - onMinimumChanged: updatePos(); - - function updatePos() { - if (maximum > minimum) { - var pos = 2 + (value - minimum) * slider.xMax / (maximum - minimum); - pos = Math.min(pos, width - handle.width - 2); - pos = Math.max(pos, 2); - handle.x = pos; - } else { - handle.x = 2; - } - } - - Rectangle { - anchors.fill: parent - border.color: "white"; border.width: 0; radius: 8 - gradient: Gradient { - GradientStop { position: 0.0; color: "#66343434" } - GradientStop { position: 1.0; color: "#66000000" } - } - } - - Rectangle { - id: handle; smooth: true - y: 2; width: 30; height: slider.height-4; radius: 6 - gradient: Gradient { - GradientStop { position: 0.0; color: "lightgray" } - GradientStop { position: 1.0; color: "gray" } - } - - MouseArea { - id: mouse - anchors.fill: parent; drag.target: parent - drag.axis: Drag.XAxis; drag.minimumX: 2; drag.maximumX: slider.xMax+2 - onPositionChanged: { value = (maximum - minimum) * (handle.x-2) / slider.xMax + minimum; } - } - } -} diff --git a/examples/declarative/flickr/content/TitleBar.qml b/examples/declarative/flickr/content/TitleBar.qml deleted file mode 100644 index 3dab005a11..0000000000 --- a/examples/declarative/flickr/content/TitleBar.qml +++ /dev/null @@ -1,128 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -Item { - id: titleBar - property string untaggedString: "Uploads from everyone" - property string taggedString: "Recent uploads tagged " - - BorderImage { source: "images/titlebar.sci"; width: parent.width; height: parent.height + 14; y: -7 } - - Item { - id: container - width: (parent.width * 2) - 55 ; height: parent.height - - function accept() { - imageDetails.closed() - titleBar.state = "" - background.state = "" - rssModel.tags = editor.text - } - - Image { - id: quitButton - anchors.left: parent.left//; anchors.leftMargin: 0 - anchors.verticalCenter: parent.verticalCenter - source: "images/quit.png" - MouseArea { - anchors.fill: parent - onClicked: Qt.quit() - } - } - - Text { - id: categoryText - anchors { - left: quitButton.right; right: tagButton.left; leftMargin: 10; rightMargin: 10 - verticalCenter: parent.verticalCenter - } - elide: Text.ElideLeft - text: (rssModel.tags=="" ? untaggedString : taggedString + rssModel.tags) - font.bold: true; font.pixelSize: 15; color: "White"; style: Text.Raised; styleColor: "Black" - } - - Button { - id: tagButton; x: titleBar.width - 50; width: 45; height: 32; text: "..." - onClicked: if (titleBar.state == "Tags") container.accept(); else titleBar.state = "Tags" - anchors.verticalCenter: parent.verticalCenter - } - - Item { - id: lineEdit - y: 4; height: parent.height - 9 - anchors { left: tagButton.right; leftMargin: 5; right: parent.right; rightMargin: 5 } - - BorderImage { source: "images/lineedit.sci"; anchors.fill: parent } - - TextInput { - id: editor - anchors { - left: parent.left; right: parent.right; leftMargin: 10; rightMargin: 10 - verticalCenter: parent.verticalCenter - } - cursorVisible: true; font.bold: true - color: "#151515"; selectionColor: "Green" - } - - Keys.forwardTo: [ (returnKey), (editor)] - - Item { - id: returnKey - Keys.onReturnPressed: container.accept() - Keys.onEnterPressed: container.accept() - Keys.onEscapePressed: titleBar.state = "" - } - } - } - - states: State { - name: "Tags" - PropertyChanges { target: container; x: -tagButton.x + 5 } - PropertyChanges { target: tagButton; text: "OK" } - PropertyChanges { target: editor; focus: true } - } - - transitions: Transition { - NumberAnimation { properties: "x"; easing.type: Easing.InOutQuad } - } -} diff --git a/examples/declarative/flickr/content/ToolBar.qml b/examples/declarative/flickr/content/ToolBar.qml deleted file mode 100644 index e82be63e7e..0000000000 --- a/examples/declarative/flickr/content/ToolBar.qml +++ /dev/null @@ -1,69 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -Item { - id: toolbar - - property alias button1Label: button1.text - property alias button2Label: button2.text - property alias button2Visible: button2.visible - - signal button1Clicked - signal button2Clicked - - BorderImage { source: "images/titlebar.sci"; width: parent.width; height: parent.height + 14; y: -7 } - - Row { - anchors.right: parent.right; anchors.rightMargin: 5; y: 3; height: 32; spacing: 30 - Button { - id: button1 - width: 140; height: 32 - onClicked: toolbar.button1Clicked() - } - - Button { - id: button2; width: 140; height: 32 - onClicked: toolbar.button2Clicked() - } - } -} diff --git a/examples/declarative/flickr/content/UnifiedDelegate.qml b/examples/declarative/flickr/content/UnifiedDelegate.qml deleted file mode 100644 index 00a777b0a1..0000000000 --- a/examples/declarative/flickr/content/UnifiedDelegate.qml +++ /dev/null @@ -1,154 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 -import QtQuick.Particles 2.0 - -Package { - function photoClicked() { - imageDetails.photoTitle = title; - imageDetails.photoTags = tags; - imageDetails.photoWidth = photoWidth; - imageDetails.photoHeight = photoHeight; - imageDetails.photoType = photoType; - imageDetails.photoAuthor = photoAuthor; - imageDetails.photoDate = photoDate; - imageDetails.photoUrl = url; - imageDetails.rating = 0; - scaleMe.state = "Details"; - } - - Item { - id: gridwrapper; - width: GridView.view.cellWidth; height: GridView.view.cellHeight - Package.name: "grid" - } - Item { - id: streamwrapper; - width: 80; height: 80 - Package.name: "stream" - } - Item { - //anchors.centerIn: parent//Doesn't animate :( - width: 80; height: 80 - scale: 0.0 - Behavior on scale { NumberAnimation { easing.type: Easing.InOutQuad} } - id: scaleMe - - Item { - id: whiteRectContainer - width: 77; height: 77; anchors.centerIn: parent - Rectangle { - id: whiteRect; width: 77; height: 77; color: "#dddddd"; smooth: true - x:0; y:0 - Image { id: thumb; source: imagePath; x: 1; y: 1; smooth: true } - Image { source: "images/gloss.png" } - MouseArea { anchors.fill: parent; onClicked: photoClicked() } - } - } - - Connections { - target: toolBar - onButton2Clicked: if (scaleMe.state == 'Details' ) scaleMe.state = 'Show' - } - - state: 'inStream' - states: [ - State { - name: "Show"; when: thumb.status == Image.Ready - PropertyChanges { target: scaleMe; scale: 1; } - }, - State { - name: "Details" - PropertyChanges { target: scaleMe; scale: 1 } - ParentChange { target: whiteRect; x: 10; y: 20; parent: imageDetails.frontContainer } - PropertyChanges { target: background; state: "DetailedView" } - } - ] - transitions: [ - Transition { - from: "Show"; to: "Details" - ParentAnimation { - via: foreground - NumberAnimation { properties: "x,y"; duration: 500; easing.type: Easing.InOutQuad } - } - }, - Transition { - from: "Details"; to: "Show" - SequentialAnimation{ - ParentAnimation { - via: foreground - NumberAnimation { properties: "x,y"; duration: 500; easing.type: Easing.InOutQuad } - } - } - } - ] - Item{ - id: stateContainer - states: [ - State { - name: 'inStream' - when: screen.inGridView == false - ParentChange { - target: scaleMe; parent: streamwrapper - x: 0; y: 0; - } - }, - State { - name: 'inGrid' - when: screen.inGridView == true - ParentChange { - target: scaleMe; parent: gridwrapper - x: 0; y: 0; - } - } - ] - - transitions: [ - Transition { - ParentAnimation { - NumberAnimation { target: scaleMe; properties: 'x,y,width,height'; duration: 300 } - } - } - ] - } - } -} diff --git a/examples/declarative/flickr/content/images/gloss.png b/examples/declarative/flickr/content/images/gloss.png deleted file mode 100644 index 5d370cd93d..0000000000 Binary files a/examples/declarative/flickr/content/images/gloss.png and /dev/null differ diff --git a/examples/declarative/flickr/content/images/lineedit.png b/examples/declarative/flickr/content/images/lineedit.png deleted file mode 100644 index 2cc38dc35b..0000000000 Binary files a/examples/declarative/flickr/content/images/lineedit.png and /dev/null differ diff --git a/examples/declarative/flickr/content/images/lineedit.sci b/examples/declarative/flickr/content/images/lineedit.sci deleted file mode 100644 index 054bff78be..0000000000 --- a/examples/declarative/flickr/content/images/lineedit.sci +++ /dev/null @@ -1,5 +0,0 @@ -border.left: 10 -border.top: 10 -border.bottom: 10 -border.right: 10 -source: lineedit.png diff --git a/examples/declarative/flickr/content/images/noise.png b/examples/declarative/flickr/content/images/noise.png deleted file mode 100644 index c5a5ba0053..0000000000 Binary files a/examples/declarative/flickr/content/images/noise.png and /dev/null differ diff --git a/examples/declarative/flickr/content/images/particle.png b/examples/declarative/flickr/content/images/particle.png deleted file mode 100644 index dbc39cb16e..0000000000 Binary files a/examples/declarative/flickr/content/images/particle.png and /dev/null differ diff --git a/examples/declarative/flickr/content/images/quit.png b/examples/declarative/flickr/content/images/quit.png deleted file mode 100644 index 5bda1b6e0d..0000000000 Binary files a/examples/declarative/flickr/content/images/quit.png and /dev/null differ diff --git a/examples/declarative/flickr/content/images/squareParticle.png b/examples/declarative/flickr/content/images/squareParticle.png deleted file mode 100644 index faf85c24e0..0000000000 Binary files a/examples/declarative/flickr/content/images/squareParticle.png and /dev/null differ diff --git a/examples/declarative/flickr/content/images/stripes.png b/examples/declarative/flickr/content/images/stripes.png deleted file mode 100644 index 9f36727ea4..0000000000 Binary files a/examples/declarative/flickr/content/images/stripes.png and /dev/null differ diff --git a/examples/declarative/flickr/content/images/titlebar.png b/examples/declarative/flickr/content/images/titlebar.png deleted file mode 100644 index 51c90082d0..0000000000 Binary files a/examples/declarative/flickr/content/images/titlebar.png and /dev/null differ diff --git a/examples/declarative/flickr/content/images/titlebar.sci b/examples/declarative/flickr/content/images/titlebar.sci deleted file mode 100644 index 0418d94cd6..0000000000 --- a/examples/declarative/flickr/content/images/titlebar.sci +++ /dev/null @@ -1,5 +0,0 @@ -border.left: 10 -border.top: 12 -border.bottom: 12 -border.right: 10 -source: titlebar.png diff --git a/examples/declarative/flickr/content/images/toolbutton.png b/examples/declarative/flickr/content/images/toolbutton.png deleted file mode 100644 index 11310013ee..0000000000 Binary files a/examples/declarative/flickr/content/images/toolbutton.png and /dev/null differ diff --git a/examples/declarative/flickr/content/images/toolbutton.sci b/examples/declarative/flickr/content/images/toolbutton.sci deleted file mode 100644 index 9e4f965307..0000000000 --- a/examples/declarative/flickr/content/images/toolbutton.sci +++ /dev/null @@ -1,5 +0,0 @@ -border.left: 15 -border.top: 4 -border.bottom: 4 -border.right: 15 -source: toolbutton.png diff --git a/examples/declarative/flickr/content/qmldir b/examples/declarative/flickr/content/qmldir deleted file mode 100644 index adc2479b9f..0000000000 --- a/examples/declarative/flickr/content/qmldir +++ /dev/null @@ -1,10 +0,0 @@ -ImageDetails ImageDetails.qml -LikeOMeter LikeOMeter.qml -Loading Loading.qml -MediaButton MediaButton.qml -MediaLineEdit MediaLineEdit.qml -Progress Progress.qml -RssModel RssModel.qml -ScrollBar ScrollBar.qml -Slider Slider.qml -Star Star.qml diff --git a/examples/declarative/flickr/flickr-90.qml b/examples/declarative/flickr/flickr-90.qml deleted file mode 100644 index ae06957649..0000000000 --- a/examples/declarative/flickr/flickr-90.qml +++ /dev/null @@ -1,52 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -Item { - width: 480; height: 320 - - Loader { - y: 320; rotation: -90 - transformOrigin: Item.TopLeft - source: "flickr.qml" - } -} diff --git a/examples/declarative/flickr/flickr.qml b/examples/declarative/flickr/flickr.qml deleted file mode 100644 index 74c41f185b..0000000000 --- a/examples/declarative/flickr/flickr.qml +++ /dev/null @@ -1,158 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 -import QtQuick.Particles 2.0 -import "content" - -Item { - id: screen; width: 320; height: 480 - property bool inGridView : true - - Rectangle { - id: background - anchors.fill: parent; color: "#343434"; - - Image { source: "content/images/stripes.png"; fillMode: Image.Tile; anchors.fill: parent; opacity: 0.3 } - ParticleSystem { - id: bgParticles - anchors.fill: parent - ImageParticle { - groups: ["trail"] - source: "content/images/particle.png" - color: "#1A1A6F" - alpha: 0.1 - colorVariation: 0.01 - blueVariation: 0.8 - } - Emitter { - group: "drops" - width: parent.width - emitRate: 0.5 - lifeSpan: 20000 - startTime: 16000 - speed: PointDirection{ - y: {screen.height/18} - } - } - TrailEmitter { - follow: "drops" - group: "trail" - emitRatePerParticle: 18 - size: 32 - endSize: 0 - sizeVariation: 4 - lifeSpan: 1200 - anchors.fill: parent - emitWidth: 16 - emitHeight: 16 - emitShape: EllipseShape{} - } - } - - VisualDataModel{ - id: vdm - delegate: UnifiedDelegate{} - model: RssModel { id: rssModel } - } - - Item { - id: views - width: parent.width - anchors.top: titleBar.bottom; anchors.bottom: toolBar.top - - GridView { - id: photoGridView; model: vdm.parts.grid - cacheBuffer: 1000 - cellWidth: (parent.width-2)/4; cellHeight: cellWidth; width: parent.width; height: parent.height - } - - states: State { - name: "GridView"; when: state.inGridView == true - } - - transitions: Transition { - NumberAnimation { properties: "x"; duration: 500; easing.type: Easing.InOutQuad } - } - - ImageDetails { id: imageDetails; width: parent.width; anchors.left: views.right; height: parent.height } - - Item { id: foreground; anchors.fill: parent } - } - - TitleBar { id: titleBar; width: parent.width; height: 40; opacity: 0.9 } - - ToolBar { - id: toolBar - height: 40; anchors.bottom: parent.bottom; width: parent.width; opacity: 0.9 - button1Label: "Update"; button2Label: "View mode" - onButton1Clicked: rssModel.reload() - onButton2Clicked: if (screen.inGridView == true) screen.inGridView = false; else screen.inGridView = true - } - - Connections { - target: imageDetails - onClosed: { - if (background.state == "DetailedView") { - background.state = ''; - imageDetails.photoUrl = ""; - } - } - } - - states: State { - name: "DetailedView" - PropertyChanges { target: views; x: -parent.width } - PropertyChanges { target: toolBar; button1Label: "View..." } - PropertyChanges { - target: toolBar - onButton1Clicked: if (imageDetails.state=='') imageDetails.state='Back'; else imageDetails.state='' - } - PropertyChanges { target: toolBar; button2Label: "Back" } - PropertyChanges { target: toolBar; onButton2Clicked: imageDetails.closed() } - } - - transitions: Transition { - NumberAnimation { properties: "x"; duration: 500; easing.type: Easing.InOutQuad } - } - - } -} diff --git a/examples/declarative/flickr/flickr.qmlproject b/examples/declarative/flickr/flickr.qmlproject deleted file mode 100644 index af5179d84b..0000000000 --- a/examples/declarative/flickr/flickr.qmlproject +++ /dev/null @@ -1,17 +0,0 @@ -import QmlProject 1.1 - -Project { - mainFile: "flickr.qml" - //mainFile: "flickr-90.qml" - - /* Include .qml, .js, and image files from current directory and subdirectories */ - QmlFiles { - directory: "." - } - JavaScriptFiles { - directory: "." - } - ImageFiles { - directory: "." - } -} diff --git a/examples/declarative/i18n/i18n.qml b/examples/declarative/i18n/i18n.qml deleted file mode 100644 index f8bf30d0f0..0000000000 --- a/examples/declarative/i18n/i18n.qml +++ /dev/null @@ -1,78 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -// -// The QML runtime automatically loads a translation from the i18n subdirectory of the root -// QML file, based on the system language. -// -// The files are created/updated by running: -// -// lupdate i18n.qml -ts i18n/base.ts -// -// Translations for new languages are created by copying i18n/base.ts to i18n/qml_.ts -// The .ts files can then be edited with Linguist: -// -// linguist i18n/qml_fr.ts -// -// The run-time translation files are then generated by running: -// -// lrelease i18n/*.ts -// - -Rectangle { - width: 640; height: 480 - - Column { - anchors.fill: parent; spacing: 20 - - Text { - text: "If a translation is available for the system language (eg. French) then the "+ - "string below will translated (eg. 'Bonjour'). Otherwise it will show 'Hello'." - width: parent.width; wrapMode: Text.WordWrap - } - - Text { - text: qsTr("Hello") - font.pointSize: 25; anchors.horizontalCenter: parent.horizontalCenter - } - } -} diff --git a/examples/declarative/i18n/i18n/base.ts b/examples/declarative/i18n/i18n/base.ts deleted file mode 100644 index 82547a1f93..0000000000 --- a/examples/declarative/i18n/i18n/base.ts +++ /dev/null @@ -1,12 +0,0 @@ - - - - - i18n - - - Hello - - - - diff --git a/examples/declarative/i18n/i18n/qml_en_AU.ts b/examples/declarative/i18n/i18n/qml_en_AU.ts deleted file mode 100644 index e991affe7f..0000000000 --- a/examples/declarative/i18n/i18n/qml_en_AU.ts +++ /dev/null @@ -1,12 +0,0 @@ - - - - - i18n - - - Hello - G'day - - - diff --git a/examples/declarative/i18n/i18n/qml_fr.ts b/examples/declarative/i18n/i18n/qml_fr.ts deleted file mode 100644 index 365abd95c2..0000000000 --- a/examples/declarative/i18n/i18n/qml_fr.ts +++ /dev/null @@ -1,12 +0,0 @@ - - - - - i18n - - - Hello - Bonjour - - - diff --git a/examples/declarative/imageelements/borderimage.qml b/examples/declarative/imageelements/borderimage.qml deleted file mode 100644 index 3dd5d1d9bb..0000000000 --- a/examples/declarative/imageelements/borderimage.qml +++ /dev/null @@ -1,97 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 -import "content" - -Rectangle { - id: page - width: 1030; height: 540 - - Grid { - anchors.centerIn: parent; spacing: 20 - - MyBorderImage { - minWidth: 120; maxWidth: 240; minHeight: 120; maxHeight: 240 - source: "content/colors.png"; margin: 30 - } - - MyBorderImage { - minWidth: 120; maxWidth: 240; minHeight: 120; maxHeight: 240 - source: "content/colors.png"; margin: 30 - horizontalMode: BorderImage.Repeat; verticalMode: BorderImage.Repeat - } - - MyBorderImage { - minWidth: 120; maxWidth: 240; minHeight: 120; maxHeight: 240 - source: "content/colors.png"; margin: 30 - horizontalMode: BorderImage.Stretch; verticalMode: BorderImage.Repeat - } - - MyBorderImage { - minWidth: 120; maxWidth: 240; minHeight: 120; maxHeight: 240 - source: "content/colors.png"; margin: 30 - horizontalMode: BorderImage.Round; verticalMode: BorderImage.Round - } - - MyBorderImage { - minWidth: 60; maxWidth: 200; minHeight: 40; maxHeight: 200 - source: "content/bw.png"; margin: 10 - } - - MyBorderImage { - minWidth: 60; maxWidth: 200; minHeight: 40; maxHeight: 200 - source: "content/bw.png"; margin: 10 - horizontalMode: BorderImage.Repeat; verticalMode: BorderImage.Repeat - } - - MyBorderImage { - minWidth: 60; maxWidth: 200; minHeight: 40; maxHeight: 200 - source: "content/bw.png"; margin: 10 - horizontalMode: BorderImage.Stretch; verticalMode: BorderImage.Repeat - } - - MyBorderImage { - minWidth: 60; maxWidth: 200; minHeight: 40; maxHeight: 200 - source: "content/bw.png"; margin: 10 - horizontalMode: BorderImage.Round; verticalMode: BorderImage.Round - } - } -} diff --git a/examples/declarative/imageelements/content/BearSheet.png b/examples/declarative/imageelements/content/BearSheet.png deleted file mode 100644 index a084bf0f1e..0000000000 Binary files a/examples/declarative/imageelements/content/BearSheet.png and /dev/null differ diff --git a/examples/declarative/imageelements/content/ImageCell.qml b/examples/declarative/imageelements/content/ImageCell.qml deleted file mode 100644 index fcc6b47af5..0000000000 --- a/examples/declarative/imageelements/content/ImageCell.qml +++ /dev/null @@ -1,60 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -import QtQuick 2.0 - -Item { - property alias mode: image.fillMode - property alias caption: captionItem.text - - width: parent.cellWidth; height: parent.cellHeight - - Image { - id: image - width: parent.width; height: parent.height - captionItem.height - source: "qt-logo.png" - clip: true // only makes a difference if mode is PreserveAspectCrop - smooth: true - } - - Text { - id: captionItem - anchors.horizontalCenter: parent.horizontalCenter; anchors.bottom: parent.bottom - } -} diff --git a/examples/declarative/imageelements/content/MyBorderImage.qml b/examples/declarative/imageelements/content/MyBorderImage.qml deleted file mode 100644 index 178e3706db..0000000000 --- a/examples/declarative/imageelements/content/MyBorderImage.qml +++ /dev/null @@ -1,90 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -Item { - id: container - - property alias horizontalMode: image.horizontalTileMode - property alias verticalMode: image.verticalTileMode - property alias source: image.source - - property int minWidth - property int minHeight - property int maxWidth - property int maxHeight - property int margin - - width: 240; height: 240 - - BorderImage { - id: image; anchors.centerIn: parent - - SequentialAnimation on width { - loops: Animation.Infinite - NumberAnimation { - from: container.minWidth; to: container.maxWidth - duration: 2000; easing.type: Easing.InOutQuad - } - NumberAnimation { - from: container.maxWidth; to: container.minWidth - duration: 2000; easing.type: Easing.InOutQuad - } - } - - SequentialAnimation on height { - loops: Animation.Infinite - NumberAnimation { - from: container.minHeight; to: container.maxHeight - duration: 2000; easing.type: Easing.InOutQuad - } - NumberAnimation { - from: container.maxHeight; to: container.minHeight - duration: 2000; easing.type: Easing.InOutQuad - } - } - - border.top: container.margin - border.left: container.margin - border.bottom: container.margin - border.right: container.margin - } -} diff --git a/examples/declarative/imageelements/content/ShadowRectangle.qml b/examples/declarative/imageelements/content/ShadowRectangle.qml deleted file mode 100644 index e6fd13bb26..0000000000 --- a/examples/declarative/imageelements/content/ShadowRectangle.qml +++ /dev/null @@ -1,54 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -Item { - property alias color : rectangle.color - - BorderImage { - anchors.fill: rectangle - anchors { leftMargin: -6; topMargin: -6; rightMargin: -8; bottomMargin: -8 } - border { left: 10; top: 10; right: 10; bottom: 10 } - source: "shadow.png"; smooth: true - } - - Rectangle { id: rectangle; anchors.fill: parent } -} diff --git a/examples/declarative/imageelements/content/bw.png b/examples/declarative/imageelements/content/bw.png deleted file mode 100644 index 486eaae96e..0000000000 Binary files a/examples/declarative/imageelements/content/bw.png and /dev/null differ diff --git a/examples/declarative/imageelements/content/colors-round.sci b/examples/declarative/imageelements/content/colors-round.sci deleted file mode 100644 index 506f6f5f99..0000000000 --- a/examples/declarative/imageelements/content/colors-round.sci +++ /dev/null @@ -1,7 +0,0 @@ -border.left:30 -border.top:30 -border.right:30 -border.bottom:30 -horizontalTileRule:Round -verticalTileRule:Round -source:colors.png diff --git a/examples/declarative/imageelements/content/colors-stretch.sci b/examples/declarative/imageelements/content/colors-stretch.sci deleted file mode 100644 index e4989a723c..0000000000 --- a/examples/declarative/imageelements/content/colors-stretch.sci +++ /dev/null @@ -1,5 +0,0 @@ -border.left:30 -border.top:30 -border.right:30 -border.bottom:30 -source:colors.png diff --git a/examples/declarative/imageelements/content/colors.png b/examples/declarative/imageelements/content/colors.png deleted file mode 100644 index dfb62f3d64..0000000000 Binary files a/examples/declarative/imageelements/content/colors.png and /dev/null differ diff --git a/examples/declarative/imageelements/content/qt-logo.png b/examples/declarative/imageelements/content/qt-logo.png deleted file mode 100644 index 14ddf2a028..0000000000 Binary files a/examples/declarative/imageelements/content/qt-logo.png and /dev/null differ diff --git a/examples/declarative/imageelements/content/shadow.png b/examples/declarative/imageelements/content/shadow.png deleted file mode 100644 index 431af8545d..0000000000 Binary files a/examples/declarative/imageelements/content/shadow.png and /dev/null differ diff --git a/examples/declarative/imageelements/content/speaker.png b/examples/declarative/imageelements/content/speaker.png deleted file mode 100644 index fb0e857859..0000000000 Binary files a/examples/declarative/imageelements/content/speaker.png and /dev/null differ diff --git a/examples/declarative/imageelements/image.qml b/examples/declarative/imageelements/image.qml deleted file mode 100644 index 4ca26c1630..0000000000 --- a/examples/declarative/imageelements/image.qml +++ /dev/null @@ -1,67 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 -import "content" - -Rectangle { - width: 490 - height: 285 - - Grid { - property int cellWidth: (width - (spacing * (columns - 1))) / columns - property int cellHeight: (height - (spacing * (rows - 1))) / rows - - anchors.fill: parent - anchors.margins: 30 - - columns: 3 - rows: 2 - spacing: 30 - - ImageCell { mode: Image.Stretch; caption: "Stretch" } - ImageCell { mode: Image.PreserveAspectFit; caption: "PreserveAspectFit" } - ImageCell { mode: Image.PreserveAspectCrop; caption: "PreserveAspectCrop" } - - ImageCell { mode: Image.Tile; caption: "Tile" } - ImageCell { mode: Image.TileHorizontally; caption: "TileHorizontally" } - ImageCell { mode: Image.TileVertically; caption: "TileVertically" } - } -} diff --git a/examples/declarative/imageelements/imageelements.qml b/examples/declarative/imageelements/imageelements.qml deleted file mode 100644 index 2ef5154968..0000000000 --- a/examples/declarative/imageelements/imageelements.qml +++ /dev/null @@ -1,58 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 -import "../shared" - -Item { - height: 480 - width: 640 - LauncherList { - id: ll - anchors.fill: parent - Component.onCompleted: { - addExample("BorderImage", "An image with scaled borders", Qt.resolvedUrl("borderimage.qml")); - addExample("Image", "A showcase of the options available to Image", Qt.resolvedUrl("image.qml")); - addExample("Shadows", "Rectangles with a drop-shadow effect", Qt.resolvedUrl("shadows.qml")); - addExample("Simple Sprite", "A simple sprite-based animation", Qt.resolvedUrl("simplesprite.qml")); - addExample("Sprite Image", "A sprite-based animation with complex transitions", Qt.resolvedUrl("spriteimage.qml")); - } - } -} diff --git a/examples/declarative/imageelements/imageelements.qmlproject b/examples/declarative/imageelements/imageelements.qmlproject deleted file mode 100644 index 4292a0c112..0000000000 --- a/examples/declarative/imageelements/imageelements.qmlproject +++ /dev/null @@ -1,16 +0,0 @@ -import QmlProject 1.1 - -Project { - mainFile: "imageelements.qml" - - /* Include .qml, .js, and image files from current directory and subdirectories */ - QmlFiles { - directory: "." - } - JavaScriptFiles { - directory: "." - } - ImageFiles { - directory: "." - } -} diff --git a/examples/declarative/imageelements/shadows.qml b/examples/declarative/imageelements/shadows.qml deleted file mode 100644 index aa5022ab36..0000000000 --- a/examples/declarative/imageelements/shadows.qml +++ /dev/null @@ -1,64 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 -import "content" - -Rectangle { - id: window - - width: 480; height: 320 - color: "gray" - - ShadowRectangle { - anchors.centerIn: parent; width: 250; height: 250 - color: "lightsteelblue" - } - - ShadowRectangle { - anchors.centerIn: parent; width: 200; height: 200 - color: "steelblue" - } - - ShadowRectangle { - anchors.centerIn: parent; width: 150; height: 150 - color: "thistle" - } -} diff --git a/examples/declarative/imageelements/simplesprite.qml b/examples/declarative/imageelements/simplesprite.qml deleted file mode 100644 index f619913bfc..0000000000 --- a/examples/declarative/imageelements/simplesprite.qml +++ /dev/null @@ -1,59 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -import QtQuick 2.0 - -Item { - width: 400 - height: 400 - Rectangle { - anchors.fill: parent - color: "white" - } - SpriteImage { - anchors.fill: parent - Sprite{ - source: "content/speaker.png" - frames: 60 - frameSync: true - frameWidth: 170 - frameHeight: 170 - } - } -} diff --git a/examples/declarative/imageelements/spriteimage.qml b/examples/declarative/imageelements/spriteimage.qml deleted file mode 100644 index 559bb10a50..0000000000 --- a/examples/declarative/imageelements/spriteimage.qml +++ /dev/null @@ -1,116 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -import QtQuick 2.0 - -Item { - width: 480 - height: 1280 - MouseArea { - onClicked: anim.start(); - anchors.fill: parent - } - SequentialAnimation { - id: anim - ScriptAction { script: image.goalSprite = "falling"; } - NumberAnimation { target: image; property: "y"; to: 1480; duration: 12000; } - ScriptAction { script: {image.goalSprite = ""; image.jumpTo("still");} } - PropertyAction { target: image; property: "y"; value: 0 } - } - SpriteImage { - id: image - width: 256 - height: 256 - anchors.horizontalCenter: parent.horizontalCenter - interpolate: false - goalSprite: "" - Sprite{ - name: "still" - source: "content/BearSheet.png" - frames: 1 - frameWidth: 256 - frameHeight: 256 - frameDuration: 100 - to: {"still":1, "blink":0.1, "floating":0} - } - Sprite{ - name: "blink" - source: "content/BearSheet.png" - frames: 3 - frameX: 256 - frameY: 1536 - frameWidth: 256 - frameHeight: 256 - frameDuration: 100 - to: {"still":1} - } - Sprite{ - name: "floating" - source: "content/BearSheet.png" - frames: 9 - frameX: 0 - frameY: 0 - frameWidth: 256 - frameHeight: 256 - frameDuration: 160 - to: {"still":0, "flailing":1} - } - Sprite{ - name: "flailing" - source: "content/BearSheet.png" - frames: 8 - frameX: 0 - frameY: 768 - frameWidth: 256 - frameHeight: 256 - frameDuration: 160 - to: {"falling":1} - } - Sprite{ - name: "falling" - source: "content/BearSheet.png" - frames: 5 - frameY: 1280 - frameWidth: 256 - frameHeight: 256 - frameDuration: 160 - to: {"falling":1} - } - } -} diff --git a/examples/declarative/keyinteraction/focus/Core/ContextMenu.qml b/examples/declarative/keyinteraction/focus/Core/ContextMenu.qml deleted file mode 100644 index dc68aa2b30..0000000000 --- a/examples/declarative/keyinteraction/focus/Core/ContextMenu.qml +++ /dev/null @@ -1,65 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -FocusScope { - id: container - - property bool open: false - - Item { - anchors.fill: parent - - Rectangle { - anchors.fill: parent - color: "#D1DBBD" - focus: true - Keys.onRightPressed: mainView.focus = true - - Text { - anchors { top: parent.top; horizontalCenter: parent.horizontalCenter; margins: 30 } - color: "black" - font.pixelSize: 14 - text: "Context Menu" - } - } - } -} diff --git a/examples/declarative/keyinteraction/focus/Core/GridMenu.qml b/examples/declarative/keyinteraction/focus/Core/GridMenu.qml deleted file mode 100644 index 75bbe682af..0000000000 --- a/examples/declarative/keyinteraction/focus/Core/GridMenu.qml +++ /dev/null @@ -1,105 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -FocusScope { - property alias interactive: gridView.interactive - - onActiveFocusChanged: { - if (activeFocus) - mainView.state = "" - } - - Rectangle { - anchors.fill: parent - clip: true - gradient: Gradient { - GradientStop { position: 0.0; color: "#193441" } - GradientStop { position: 1.0; color: Qt.darker("#193441") } - } - - GridView { - id: gridView - anchors.fill: parent; anchors.leftMargin: 20; anchors.rightMargin: 20 - cellWidth: 152; cellHeight: 152 - focus: true - model: 12 - - KeyNavigation.down: listMenu - KeyNavigation.left: contextMenu - - delegate: Item { - id: container - width: GridView.view.cellWidth; height: GridView.view.cellHeight - - Rectangle { - id: content - color: "transparent" - smooth: true - anchors.fill: parent; anchors.margins: 20; radius: 10 - - Rectangle { color: "#91AA9D"; anchors.fill: parent; anchors.margins: 3; radius: 8; smooth: true } - Image { source: "images/qt-logo.png"; anchors.centerIn: parent; smooth: true } - } - - MouseArea { - id: mouseArea - anchors.fill: parent - hoverEnabled: true - - onClicked: { - container.GridView.view.currentIndex = index - container.forceActiveFocus() - } - } - - states: State { - name: "active"; when: container.activeFocus - PropertyChanges { target: content; color: "#FCFFF5"; scale: 1.1 } - } - - transitions: Transition { - NumberAnimation { properties: "scale"; duration: 100 } - } - } - } - } -} diff --git a/examples/declarative/keyinteraction/focus/Core/ListMenu.qml b/examples/declarative/keyinteraction/focus/Core/ListMenu.qml deleted file mode 100644 index 7a62f33428..0000000000 --- a/examples/declarative/keyinteraction/focus/Core/ListMenu.qml +++ /dev/null @@ -1,105 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -FocusScope { - clip: true - - onActiveFocusChanged: { - if (activeFocus) - mainView.state = "showListViews" - } - - ListView { - id: list1 - y: activeFocus ? 10 : 40; width: parent.width / 3; height: parent.height - 20 - focus: true - KeyNavigation.up: gridMenu; KeyNavigation.left: contextMenu; KeyNavigation.right: list2 - model: 10; cacheBuffer: 200 - delegate: ListViewDelegate {} - - Behavior on y { - NumberAnimation { duration: 600; easing.type: Easing.OutQuint } - } - } - - ListView { - id: list2 - y: activeFocus ? 10 : 40; x: parseInt(parent.width / 3); width: parent.width / 3; height: parent.height - 20 - KeyNavigation.up: gridMenu; KeyNavigation.left: list1; KeyNavigation.right: list3 - model: 10; cacheBuffer: 200 - delegate: ListViewDelegate {} - - Behavior on y { - NumberAnimation { duration: 600; easing.type: Easing.OutQuint } - } - } - - ListView { - id: list3 - y: activeFocus ? 10 : 40; x: parseInt(2 * parent.width / 3); width: parent.width / 3; height: parent.height - 20 - KeyNavigation.up: gridMenu; KeyNavigation.left: list2 - model: 10; cacheBuffer: 200 - delegate: ListViewDelegate {} - - Behavior on y { - NumberAnimation { duration: 600; easing.type: Easing.OutQuint } - } - } - - Rectangle { width: parent.width; height: 1; color: "#D1DBBD" } - - Rectangle { - y: 1; width: parent.width; height: 10 - gradient: Gradient { - GradientStop { position: 0.0; color: "#3E606F" } - GradientStop { position: 1.0; color: "transparent" } - } - } - - Rectangle { - y: parent.height - 10; width: parent.width; height: 10 - gradient: Gradient { - GradientStop { position: 1.0; color: "#3E606F" } - GradientStop { position: 0.0; color: "transparent" } - } - } -} diff --git a/examples/declarative/keyinteraction/focus/Core/ListViewDelegate.qml b/examples/declarative/keyinteraction/focus/Core/ListViewDelegate.qml deleted file mode 100644 index b28b02616d..0000000000 --- a/examples/declarative/keyinteraction/focus/Core/ListViewDelegate.qml +++ /dev/null @@ -1,85 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -Item { - id: container - width: ListView.view.width; height: 60; anchors.leftMargin: 10; anchors.rightMargin: 10 - - Rectangle { - id: content - anchors.centerIn: parent; width: container.width - 40; height: container.height - 10 - color: "transparent" - smooth: true - radius: 10 - - Rectangle { anchors.fill: parent; anchors.margins: 3; color: "#91AA9D"; smooth: true; radius: 8 } - } - - Text { - id: label - anchors.centerIn: content - text: "List element " + (index + 1) - color: "#193441" - font.pixelSize: 14 - } - - MouseArea { - id: mouseArea - anchors.fill: parent - hoverEnabled: true - - onClicked: { - container.ListView.view.currentIndex = index - container.forceActiveFocus() - } - } - - states: State { - name: "active"; when: container.activeFocus - PropertyChanges { target: content; color: "#FCFFF5"; scale: 1.1 } - PropertyChanges { target: label; font.pixelSize: 16 } - } - - transitions: Transition { - NumberAnimation { properties: "scale"; duration: 100 } - } -} diff --git a/examples/declarative/keyinteraction/focus/Core/images/arrow.png b/examples/declarative/keyinteraction/focus/Core/images/arrow.png deleted file mode 100644 index 14978c2e56..0000000000 Binary files a/examples/declarative/keyinteraction/focus/Core/images/arrow.png and /dev/null differ diff --git a/examples/declarative/keyinteraction/focus/Core/images/qt-logo.png b/examples/declarative/keyinteraction/focus/Core/images/qt-logo.png deleted file mode 100644 index 14ddf2a028..0000000000 Binary files a/examples/declarative/keyinteraction/focus/Core/images/qt-logo.png and /dev/null differ diff --git a/examples/declarative/keyinteraction/focus/focus.qml b/examples/declarative/keyinteraction/focus/focus.qml deleted file mode 100644 index 9300ad4f6e..0000000000 --- a/examples/declarative/keyinteraction/focus/focus.qml +++ /dev/null @@ -1,111 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 -import "Core" - -Rectangle { - id: window - - width: 800; height: 480 - color: "#3E606F" - - FocusScope { - id: mainView - - width: parent.width; height: parent.height - focus: true - - GridMenu { - id: gridMenu - width: parent.width; height: 320 - - focus: true - interactive: parent.activeFocus - } - - ListMenu { - id: listMenu - y: 320; width: parent.width; height: 320 - } - - Rectangle { - id: shade - anchors.fill: parent - color: "black" - opacity: 0 - } - - states: State { - name: "showListViews" - PropertyChanges { target: gridMenu; y: -160 } - PropertyChanges { target: listMenu; y: 160 } - } - - transitions: Transition { - NumberAnimation { properties: "y"; duration: 600; easing.type: Easing.OutQuint } - } - } - - Image { - source: "Core/images/arrow.png" - rotation: 90 - anchors.verticalCenter: parent.verticalCenter - - MouseArea { - anchors.fill: parent; anchors.margins: -10 - onClicked: contextMenu.focus = true - } - } - - ContextMenu { id: contextMenu; x: -265; width: 260; height: parent.height } - - states: State { - name: "contextMenuOpen" - when: !mainView.activeFocus - PropertyChanges { target: contextMenu; x: 0; open: true } - PropertyChanges { target: mainView; x: 130 } - PropertyChanges { target: shade; opacity: 0.25 } - } - - transitions: Transition { - NumberAnimation { properties: "x,opacity"; duration: 600; easing.type: Easing.OutQuint } - } -} diff --git a/examples/declarative/locale/locale.qml b/examples/declarative/locale/locale.qml deleted file mode 100644 index 08d08d6bbd..0000000000 --- a/examples/declarative/locale/locale.qml +++ /dev/null @@ -1,132 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -Rectangle { - id: root - width: 320 - height: 480 - color: "lightgray" - - property string locale: view.currentItem.locale - - Text { - id: title - text: "Select locale:" - } - - Rectangle { - id: chooser - anchors.top: title.bottom - anchors.topMargin: 5 - width: parent.width-10 - x: 5 - height: parent.height/2 - 10 - color: "#40300030" - ListView { - id: view - clip: true - focus: true - anchors.fill: parent - model: [ - "en_US", - "en_GB", - "fi_FI", - "de_DE", - "ar_SA", - "hi_IN", - "zh_CN", - "th_TH", - "fr_FR", - "nb_NO", - "sv_SE" - ] - delegate: Text { - property string locale: modelData - height: 30 - width: view.width - text: Qt.locale(modelData).name + " ("+ Qt.locale(modelData).nativeCountryName + "/" + Qt.locale(modelData).nativeLanguageName + ")" - MouseArea { - anchors.fill: parent - onClicked: view.currentIndex = index - } - } - highlight: Rectangle { - height: 30 - color: "#60300030" - } - } - } - - Rectangle { - color: "white" - anchors.top: chooser.bottom - anchors.topMargin: 5 - anchors.bottom: parent.bottom - anchors.bottomMargin: 5 - x: 5; width: parent.width - 10 - - Column { - anchors.fill: parent - spacing: 5 - Text { - property var date: new Date() - text: "Date: " + date.toLocaleDateString(Qt.locale(root.locale)) - } - Text { - property var date: new Date() - text: "Time: " + date.toLocaleTimeString(Qt.locale(root.locale)) - } - Text { - property var dow: Qt.locale(root.locale).firstDayOfWeek - text: "First day of week: " + Qt.locale(root.locale).standaloneDayName(dow) - } - Text { - property var num: 10023823 - text: "Number: " + num.toLocaleString(Qt.locale(root.locale)) - } - Text { - property var num: 10023823 - text: "Currency: " + num.toLocaleCurrencyString(Qt.locale(root.locale)) - } - } - } -} diff --git a/examples/declarative/minehunt/MinehuntCore/Explosion.qml b/examples/declarative/minehunt/MinehuntCore/Explosion.qml deleted file mode 100644 index 0983b68db4..0000000000 --- a/examples/declarative/minehunt/MinehuntCore/Explosion.qml +++ /dev/null @@ -1,69 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 -import QtQuick.Particles 2.0 - -Item { - property bool explode : false - ParticleSystem { - width: 40 - height: 40 - ImageParticle { - groups: ["star"] - source: "file:MinehuntCore/pics/star.png" // TODO: Use qrc path once QTBUG-21129 is fixed - } - Emitter { - id: particles - enabled: false - anchors.centerIn: parent - group: "star" - speed: AngleDirection { angleVariation: 360; magnitude: 150; magnitudeVariation: 50 } - emitRate: 200 - z: 100 - lifeSpan: 1000 - } - } - states: State { name: "exploding"; when: explode - StateChangeScript { script: particles.burst(200); } - } - -} diff --git a/examples/declarative/minehunt/MinehuntCore/Tile.qml b/examples/declarative/minehunt/MinehuntCore/Tile.qml deleted file mode 100644 index 14c1f51f9e..0000000000 --- a/examples/declarative/minehunt/MinehuntCore/Tile.qml +++ /dev/null @@ -1,128 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -Flipable { - id: flipable - property int angle: 0 - - width: 40; height: 40 - transform: Rotation { origin.x: 20; origin.y: 20; axis.x: 1; axis.z: 0; angle: flipable.angle } - - front: Image { - source: "pics/front.png"; width: 40; height: 40 - - Image { - anchors.centerIn: parent - source: "pics/flag.png"; opacity: modelData.hasFlag - - Behavior on opacity { NumberAnimation {} } - } - } - - back: Image { - source: "pics/back.png" - width: 40; height: 40 - - Text { - anchors.centerIn: parent - text: modelData.hint; color: "white"; font.bold: true - opacity: !modelData.hasMine && modelData.hint > 0 - } - - Image { - anchors.centerIn: parent - source: "pics/bomb.png"; opacity: modelData.hasMine - } - - Explosion { id: expl } - } - - states: State { - name: "back"; when: modelData.flipped - PropertyChanges { target: flipable; angle: 180 } - } - - property real pauseDur: 250 - transitions: Transition { - SequentialAnimation { - ScriptAction { - script: { - var ret = Math.abs(flipable.x - field.clickx) - + Math.abs(flipable.y - field.clicky); - if (modelData.hasMine && modelData.flipped) - pauseDur = ret * 3 - else - pauseDur = ret - } - } - PauseAnimation { - duration: pauseDur - } - RotationAnimation { easing.type: Easing.InOutQuad } - ScriptAction { script: if (modelData.hasMine && modelData.flipped) { expl.explode = true } } - } - } - - MouseArea { - anchors.fill: parent - acceptedButtons: Qt.LeftButton | Qt.RightButton - onClicked: { - field.clickx = flipable.x - field.clicky = flipable.y - var row = Math.floor(index / 9) - var col = index - (Math.floor(index / 9) * 9) - if (mouse.button == undefined || mouse.button == Qt.RightButton) { - flag(row, col) - } else { - flip(row, col) - } - } - onPressAndHold: { - field.clickx = flipable.x - field.clicky = flipable.y - var row = Math.floor(index / 9) - var col = index - (Math.floor(index / 9) * 9) - flag(row, col) - } - } -} diff --git a/examples/declarative/minehunt/MinehuntCore/pics/back.png b/examples/declarative/minehunt/MinehuntCore/pics/back.png deleted file mode 100644 index f6b3f0b4d7..0000000000 Binary files a/examples/declarative/minehunt/MinehuntCore/pics/back.png and /dev/null differ diff --git a/examples/declarative/minehunt/MinehuntCore/pics/background.png b/examples/declarative/minehunt/MinehuntCore/pics/background.png deleted file mode 100644 index 3734a27744..0000000000 Binary files a/examples/declarative/minehunt/MinehuntCore/pics/background.png and /dev/null differ diff --git a/examples/declarative/minehunt/MinehuntCore/pics/bomb-color.png b/examples/declarative/minehunt/MinehuntCore/pics/bomb-color.png deleted file mode 100644 index 61ad0a928f..0000000000 Binary files a/examples/declarative/minehunt/MinehuntCore/pics/bomb-color.png and /dev/null differ diff --git a/examples/declarative/minehunt/MinehuntCore/pics/bomb.png b/examples/declarative/minehunt/MinehuntCore/pics/bomb.png deleted file mode 100644 index a992575518..0000000000 Binary files a/examples/declarative/minehunt/MinehuntCore/pics/bomb.png and /dev/null differ diff --git a/examples/declarative/minehunt/MinehuntCore/pics/face-sad.png b/examples/declarative/minehunt/MinehuntCore/pics/face-sad.png deleted file mode 100644 index cf00aafe1f..0000000000 Binary files a/examples/declarative/minehunt/MinehuntCore/pics/face-sad.png and /dev/null differ diff --git a/examples/declarative/minehunt/MinehuntCore/pics/face-smile-big.png b/examples/declarative/minehunt/MinehuntCore/pics/face-smile-big.png deleted file mode 100644 index f9c2335df5..0000000000 Binary files a/examples/declarative/minehunt/MinehuntCore/pics/face-smile-big.png and /dev/null differ diff --git a/examples/declarative/minehunt/MinehuntCore/pics/face-smile.png b/examples/declarative/minehunt/MinehuntCore/pics/face-smile.png deleted file mode 100644 index 3d66d72578..0000000000 Binary files a/examples/declarative/minehunt/MinehuntCore/pics/face-smile.png and /dev/null differ diff --git a/examples/declarative/minehunt/MinehuntCore/pics/flag-color.png b/examples/declarative/minehunt/MinehuntCore/pics/flag-color.png deleted file mode 100644 index aadad0f11a..0000000000 Binary files a/examples/declarative/minehunt/MinehuntCore/pics/flag-color.png and /dev/null differ diff --git a/examples/declarative/minehunt/MinehuntCore/pics/flag.png b/examples/declarative/minehunt/MinehuntCore/pics/flag.png deleted file mode 100644 index 39cde4df82..0000000000 Binary files a/examples/declarative/minehunt/MinehuntCore/pics/flag.png and /dev/null differ diff --git a/examples/declarative/minehunt/MinehuntCore/pics/front.png b/examples/declarative/minehunt/MinehuntCore/pics/front.png deleted file mode 100644 index 834331bd49..0000000000 Binary files a/examples/declarative/minehunt/MinehuntCore/pics/front.png and /dev/null differ diff --git a/examples/declarative/minehunt/MinehuntCore/pics/quit.png b/examples/declarative/minehunt/MinehuntCore/pics/quit.png deleted file mode 100644 index b822057d4e..0000000000 Binary files a/examples/declarative/minehunt/MinehuntCore/pics/quit.png and /dev/null differ diff --git a/examples/declarative/minehunt/MinehuntCore/pics/star.png b/examples/declarative/minehunt/MinehuntCore/pics/star.png deleted file mode 100644 index 3772359188..0000000000 Binary files a/examples/declarative/minehunt/MinehuntCore/pics/star.png and /dev/null differ diff --git a/examples/declarative/minehunt/MinehuntCore/qmldir b/examples/declarative/minehunt/MinehuntCore/qmldir deleted file mode 100644 index a0213a19c4..0000000000 --- a/examples/declarative/minehunt/MinehuntCore/qmldir +++ /dev/null @@ -1,2 +0,0 @@ -Explosion 2.0 Explosion.qml -Tile 2.0 Tile.qml diff --git a/examples/declarative/minehunt/README b/examples/declarative/minehunt/README deleted file mode 100644 index 3849ca5fbf..0000000000 --- a/examples/declarative/minehunt/README +++ /dev/null @@ -1,6 +0,0 @@ -Minehunt has to be compiled to run. - -To compile the C++ part, do 'qmake && make'. -To run, simply run the executable. -To deploy on a device, do 'make sis'. - diff --git a/examples/declarative/minehunt/main.cpp b/examples/declarative/minehunt/main.cpp deleted file mode 100644 index 47c0436969..0000000000 --- a/examples/declarative/minehunt/main.cpp +++ /dev/null @@ -1,64 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the demonstration applications of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include -#include -#include -#include - -#include "minehunt.h" - -int main(int argc, char *argv[]) -{ - QGuiApplication app(argc, argv); - QQuickView canvas; - - qmlRegisterType(); - MinehuntGame* game = new MinehuntGame(); - - canvas.setResizeMode(QQuickView::SizeRootObjectToView); - canvas.engine()->rootContext()->setContextObject(game); - canvas.setSource(QString("qrc:///minehunt.qml")); - QObject::connect(canvas.engine(), SIGNAL(quit()), &app, SLOT(quit())); - - canvas.show(); - return app.exec(); -} diff --git a/examples/declarative/minehunt/minehunt.cpp b/examples/declarative/minehunt/minehunt.cpp deleted file mode 100644 index facbec375a..0000000000 --- a/examples/declarative/minehunt/minehunt.cpp +++ /dev/null @@ -1,221 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the demonstration applications of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include -#include -#include - -#include "minehunt.h" - -void tilesPropAppend(QDeclarativeListProperty* prop, TileData* value) -{ - Q_UNUSED(prop); - Q_UNUSED(value); - return; //Append not supported -} - -int tilesPropCount(QDeclarativeListProperty* prop) -{ - return static_cast*>(prop->data)->count(); -} - -TileData* tilesPropAt(QDeclarativeListProperty* prop, int index) -{ - return static_cast*>(prop->data)->at(index); -} - -QDeclarativeListProperty MinehuntGame::tiles(){ - return QDeclarativeListProperty(this, &_tiles, &tilesPropAppend, - &tilesPropCount, &tilesPropAt, 0); -} - -MinehuntGame::MinehuntGame() -: numCols(9), numRows(9), playing(true), won(false) -{ - setObjectName("mainObject"); - srand(QTime(0,0,0).secsTo(QTime::currentTime())); - - //initialize array - for(int ii = 0; ii < numRows * numCols; ++ii) { - _tiles << new TileData; - } - reset(); - -} - -void MinehuntGame::setBoard() -{ - foreach(TileData* t, _tiles){ - t->setHasMine(false); - t->setHint(-1); - } - //place mines - int mines = nMines; - remaining = numRows*numCols-mines; - while ( mines ) { - int col = int((double(rand()) / double(RAND_MAX)) * numCols); - int row = int((double(rand()) / double(RAND_MAX)) * numRows); - - TileData* t = tile( row, col ); - - if (t && !t->hasMine()) { - t->setHasMine( true ); - mines--; - } - } - - //set hints - for (int r = 0; r < numRows; r++) - for (int c = 0; c < numCols; c++) { - TileData* t = tile(r, c); - if (t && !t->hasMine()) { - int hint = getHint(r,c); - t->setHint(hint); - } - } - - setPlaying(true); -} - -void MinehuntGame::reset() -{ - foreach(TileData* t, _tiles){ - t->unflip(); - t->setHasFlag(false); - } - nMines = 12; - nFlags = 0; - emit numMinesChanged(); - emit numFlagsChanged(); - setPlaying(false); - QTimer::singleShot(600,this, SLOT(setBoard())); -} - -int MinehuntGame::getHint(int row, int col) -{ - int hint = 0; - for (int c = col-1; c <= col+1; c++) - for (int r = row-1; r <= row+1; r++) { - TileData* t = tile(r, c); - if (t && t->hasMine()) - hint++; - } - return hint; -} - -bool MinehuntGame::flip(int row, int col) -{ - if(!playing) - return false; - - TileData *t = tile(row, col); - if (!t || t->hasFlag()) - return false; - - if(t->flipped()){ - int flags = 0; - for (int c = col-1; c <= col+1; c++) - for (int r = row-1; r <= row+1; r++) { - TileData *nearT = tile(r, c); - if(!nearT || nearT == t) - continue; - if(nearT->hasFlag()) - flags++; - } - if(!t->hint() || t->hint() != flags) - return false; - for (int c = col-1; c <= col+1; c++) - for (int r = row-1; r <= row+1; r++) { - TileData *nearT = tile(r, c); - if (nearT && !nearT->flipped() && !nearT->hasFlag()) { - flip( r, c ); - } - } - return true; - } - - t->flip(); - - if (t->hint() == 0) { - for (int c = col-1; c <= col+1; c++) - for (int r = row-1; r <= row+1; r++) { - TileData* t = tile(r, c); - if (t && !t->flipped()) { - flip( r, c ); - } - } - } - - if(t->hasMine()){ - for (int r = 0; r < numRows; r++)//Flip all other mines - for (int c = 0; c < numCols; c++) { - TileData* t = tile(r, c); - if (t && t->hasMine()) { - flip(r, c); - } - } - won = false; - hasWonChanged(); - setPlaying(false); - return true; - } - - remaining--; - if(!remaining){ - won = true; - hasWonChanged(); - setPlaying(false); - return true; - } - return true; -} - -bool MinehuntGame::flag(int row, int col) -{ - TileData *t = tile(row, col); - if(!t || !playing || t->flipped()) - return false; - - t->setHasFlag(!t->hasFlag()); - nFlags += (t->hasFlag()?1:-1); - emit numFlagsChanged(); - return true; -} diff --git a/examples/declarative/minehunt/minehunt.h b/examples/declarative/minehunt/minehunt.h deleted file mode 100644 index a0ae23fa8a..0000000000 --- a/examples/declarative/minehunt/minehunt.h +++ /dev/null @@ -1,129 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the demonstration applications of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - - -#include - -class TileData : public QObject -{ - Q_OBJECT -public: - TileData() : _hasFlag(false), _hasMine(false), _hint(-1), _flipped(false) {} - - Q_PROPERTY(bool hasFlag READ hasFlag WRITE setHasFlag NOTIFY hasFlagChanged) - bool hasFlag() const { return _hasFlag; } - - Q_PROPERTY(bool hasMine READ hasMine NOTIFY hasMineChanged) - bool hasMine() const { return _hasMine; } - - Q_PROPERTY(int hint READ hint NOTIFY hintChanged) - int hint() const { return _hint; } - - Q_PROPERTY(bool flipped READ flipped NOTIFY flippedChanged()) - bool flipped() const { return _flipped; } - - void setHasFlag(bool flag) {if(flag==_hasFlag) return; _hasFlag = flag; emit hasFlagChanged();} - void setHasMine(bool mine) {if(mine==_hasMine) return; _hasMine = mine; emit hasMineChanged();} - void setHint(int hint) { if(hint == _hint) return; _hint = hint; emit hintChanged(); } - void flip() { if (_flipped) return; _flipped = true; emit flippedChanged(); } - void unflip() { if(!_flipped) return; _flipped = false; emit flippedChanged(); } - -signals: - void flippedChanged(); - void hasFlagChanged(); - void hintChanged(); - void hasMineChanged(); - -private: - bool _hasFlag; - bool _hasMine; - int _hint; - bool _flipped; -}; - -class MinehuntGame : public QObject -{ - Q_OBJECT -public: - MinehuntGame(); - - Q_PROPERTY(QDeclarativeListProperty tiles READ tiles CONSTANT) - QDeclarativeListProperty tiles(); - - Q_PROPERTY(bool isPlaying READ isPlaying NOTIFY isPlayingChanged) - bool isPlaying() {return playing;} - - Q_PROPERTY(bool hasWon READ hasWon NOTIFY hasWonChanged) - bool hasWon() {return won;} - - Q_PROPERTY(int numMines READ numMines NOTIFY numMinesChanged) - int numMines() const{return nMines;} - - Q_PROPERTY(int numFlags READ numFlags NOTIFY numFlagsChanged) - int numFlags() const{return nFlags;} - -public slots: - Q_INVOKABLE bool flip(int row, int col); - Q_INVOKABLE bool flag(int row, int col); - void setBoard(); - void reset(); - -signals: - void isPlayingChanged(); - void hasWonChanged(); - void numMinesChanged(); - void numFlagsChanged(); - -private: - bool onBoard( int r, int c ) const { return r >= 0 && r < numRows && c >= 0 && c < numCols; } - TileData *tile( int row, int col ) { return onBoard(row, col) ? _tiles[col+numRows*row] : 0; } - int getHint(int row, int col); - void setPlaying(bool b){if(b==playing) return; playing=b; emit isPlayingChanged();} - - QList _tiles; - int numCols; - int numRows; - bool playing; - bool won; - int remaining; - int nMines; - int nFlags; -}; diff --git a/examples/declarative/minehunt/minehunt.pro b/examples/declarative/minehunt/minehunt.pro deleted file mode 100644 index 81b6b80486..0000000000 --- a/examples/declarative/minehunt/minehunt.pro +++ /dev/null @@ -1,5 +0,0 @@ -QT += declarative quick - -HEADERS += minehunt.h -SOURCES += main.cpp minehunt.cpp -RESOURCES = minehunt.qrc diff --git a/examples/declarative/minehunt/minehunt.qml b/examples/declarative/minehunt/minehunt.qml deleted file mode 100644 index 7c4948a3bb..0000000000 --- a/examples/declarative/minehunt/minehunt.qml +++ /dev/null @@ -1,112 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 -import "MinehuntCore" 2.0 - -Item { - id: field - property int clickx: 0 - property int clicky: 0 - - width: 450; height: 450 - - Image { source: "MinehuntCore/pics/background.png"; anchors.fill: parent; fillMode: Image.Tile } - - Grid { - anchors.horizontalCenter: parent.horizontalCenter - columns: 9; spacing: 1 - - Repeater { - id: repeater - model: tiles - delegate: Tile {} - } - } - - Row { - id: gamedata - x: 20; spacing: 20 - anchors.bottom: field.bottom; anchors.bottomMargin: 15 - - Image { - source: "MinehuntCore/pics/quit.png" - scale: quitMouse.pressed ? 0.8 : 1.0 - smooth: quitMouse.pressed - y: 10 - MouseArea { - id: quitMouse - anchors.fill: parent - anchors.margins: -20 - onClicked: Qt.quit() - } - } - Column { - spacing: 2 - Image { source: "MinehuntCore/pics/bomb-color.png" } - Text { anchors.horizontalCenter: parent.horizontalCenter; color: "white"; text: numMines } - } - - Column { - spacing: 2 - Image { source: "MinehuntCore/pics/flag-color.png" } - Text { anchors.horizontalCenter: parent.horizontalCenter; color: "white"; text: numFlags } - } - } - - Image { - anchors.bottom: field.bottom; anchors.bottomMargin: 15 - anchors.right: field.right; anchors.rightMargin: 20 - source: isPlaying ? 'MinehuntCore/pics/face-smile.png' : - hasWon ? 'MinehuntCore/pics/face-smile-big.png': 'MinehuntCore/pics/face-sad.png' - - MouseArea { anchors.fill: parent; onPressed: reset() } - } - Text { - anchors.centerIn: parent; width: parent.width - 20 - horizontalAlignment: Text.AlignHCenter - wrapMode: Text.WordWrap - text: "Minehunt demo has to be compiled to run.\n\nPlease see README." - color: "white"; font.bold: true; font.pixelSize: 14 - visible: tiles == undefined - } - -} diff --git a/examples/declarative/minehunt/minehunt.qmlproject b/examples/declarative/minehunt/minehunt.qmlproject deleted file mode 100644 index 5aeb78f1ea..0000000000 --- a/examples/declarative/minehunt/minehunt.qmlproject +++ /dev/null @@ -1,16 +0,0 @@ -import QmlProject 1.1 - -Project { - mainFile: "minehunt.qml" - - /* Include .qml, .js, and image files from current directory and subdirectories */ - QmlFiles { - directory: "." - } - JavaScriptFiles { - directory: "." - } - ImageFiles { - directory: "." - } -} diff --git a/examples/declarative/minehunt/minehunt.qrc b/examples/declarative/minehunt/minehunt.qrc deleted file mode 100644 index fa8e27d383..0000000000 --- a/examples/declarative/minehunt/minehunt.qrc +++ /dev/null @@ -1,20 +0,0 @@ - - - minehunt.qml - MinehuntCore/Explosion.qml - MinehuntCore/Tile.qml - MinehuntCore/qmldir - MinehuntCore/pics/background.png - MinehuntCore/pics/back.png - MinehuntCore/pics/bomb-color.png - MinehuntCore/pics/bomb.png - MinehuntCore/pics/face-sad.png - MinehuntCore/pics/face-smile-big.png - MinehuntCore/pics/face-smile.png - MinehuntCore/pics/flag-color.png - MinehuntCore/pics/flag.png - MinehuntCore/pics/front.png - MinehuntCore/pics/quit.png - MinehuntCore/pics/star.png - - diff --git a/examples/declarative/modelviews/abstractitemmodel/abstractitemmodel.pro b/examples/declarative/modelviews/abstractitemmodel/abstractitemmodel.pro deleted file mode 100644 index eaf2b30c89..0000000000 --- a/examples/declarative/modelviews/abstractitemmodel/abstractitemmodel.pro +++ /dev/null @@ -1,10 +0,0 @@ -TEMPLATE = app -TARGET = abstractitemmodel -DEPENDPATH += . -INCLUDEPATH += . -QT += declarative quick - -HEADERS = model.h -SOURCES = main.cpp \ - model.cpp -RESOURCES += abstractitemmodel.qrc diff --git a/examples/declarative/modelviews/abstractitemmodel/abstractitemmodel.qrc b/examples/declarative/modelviews/abstractitemmodel/abstractitemmodel.qrc deleted file mode 100644 index 4ae861cb3d..0000000000 --- a/examples/declarative/modelviews/abstractitemmodel/abstractitemmodel.qrc +++ /dev/null @@ -1,6 +0,0 @@ - - - view.qml - - - diff --git a/examples/declarative/modelviews/abstractitemmodel/main.cpp b/examples/declarative/modelviews/abstractitemmodel/main.cpp deleted file mode 100644 index b6ca2df26e..0000000000 --- a/examples/declarative/modelviews/abstractitemmodel/main.cpp +++ /dev/null @@ -1,70 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include "model.h" - -#include -#include -#include -#include -#include -#include - -//![0] -int main(int argc, char ** argv) -{ - QGuiApplication app(argc, argv); - - AnimalModel model; - model.addAnimal(Animal("Wolf", "Medium")); - model.addAnimal(Animal("Polar bear", "Large")); - model.addAnimal(Animal("Quoll", "Small")); - - QQuickView view; - view.setResizeMode(QQuickView::SizeRootObjectToView); - QDeclarativeContext *ctxt = view.rootContext(); - ctxt->setContextProperty("myModel", &model); -//![0] - - view.setSource(QUrl("qrc:view.qml")); - view.show(); - - return app.exec(); -} - diff --git a/examples/declarative/modelviews/abstractitemmodel/model.cpp b/examples/declarative/modelviews/abstractitemmodel/model.cpp deleted file mode 100644 index 8f7649c0d4..0000000000 --- a/examples/declarative/modelviews/abstractitemmodel/model.cpp +++ /dev/null @@ -1,90 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include "model.h" - -Animal::Animal(const QString &type, const QString &size) - : m_type(type), m_size(size) -{ -} - -QString Animal::type() const -{ - return m_type; -} - -QString Animal::size() const -{ - return m_size; -} - -//![0] -AnimalModel::AnimalModel(QObject *parent) - : QAbstractListModel(parent) -{ - QHash roles; - roles[TypeRole] = "type"; - roles[SizeRole] = "size"; - setRoleNames(roles); -} -//![0] - -void AnimalModel::addAnimal(const Animal &animal) -{ - beginInsertRows(QModelIndex(), rowCount(), rowCount()); - m_animals << animal; - endInsertRows(); -} - -int AnimalModel::rowCount(const QModelIndex & parent) const { - return m_animals.count(); -} - -QVariant AnimalModel::data(const QModelIndex & index, int role) const { - if (index.row() < 0 || index.row() >= m_animals.count()) - return QVariant(); - - const Animal &animal = m_animals[index.row()]; - if (role == TypeRole) - return animal.type(); - else if (role == SizeRole) - return animal.size(); - return QVariant(); -} - diff --git a/examples/declarative/modelviews/abstractitemmodel/model.h b/examples/declarative/modelviews/abstractitemmodel/model.h deleted file mode 100644 index 1378c4487e..0000000000 --- a/examples/declarative/modelviews/abstractitemmodel/model.h +++ /dev/null @@ -1,83 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include -#include - -//![0] -class Animal -{ -public: - Animal(const QString &type, const QString &size); -//![0] - - QString type() const; - QString size() const; - -private: - QString m_type; - QString m_size; -//![1] -}; - -class AnimalModel : public QAbstractListModel -{ - Q_OBJECT -public: - enum AnimalRoles { - TypeRole = Qt::UserRole + 1, - SizeRole - }; - - AnimalModel(QObject *parent = 0); -//![1] - - void addAnimal(const Animal &animal); - - int rowCount(const QModelIndex & parent = QModelIndex()) const; - - QVariant data(const QModelIndex & index, int role = Qt::DisplayRole) const; - -private: - QList m_animals; -//![2] -}; -//![2] - - diff --git a/examples/declarative/modelviews/abstractitemmodel/view.qml b/examples/declarative/modelviews/abstractitemmodel/view.qml deleted file mode 100644 index 64f5871d4b..0000000000 --- a/examples/declarative/modelviews/abstractitemmodel/view.qml +++ /dev/null @@ -1,50 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -import QtQuick 2.0 - -//![0] -ListView { - width: 200; height: 250 - - model: myModel - delegate: Text { text: "Animal: " + type + ", " + size } -} -//![0] - diff --git a/examples/declarative/modelviews/gridview/gridview-example.qml b/examples/declarative/modelviews/gridview/gridview-example.qml deleted file mode 100644 index ea3bb5cec9..0000000000 --- a/examples/declarative/modelviews/gridview/gridview-example.qml +++ /dev/null @@ -1,93 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -Rectangle { - width: 300; height: 400 - color: "white" - - ListModel { - id: appModel - ListElement { name: "Music"; icon: "pics/AudioPlayer_48.png" } - ListElement { name: "Movies"; icon: "pics/VideoPlayer_48.png" } - ListElement { name: "Camera"; icon: "pics/Camera_48.png" } - ListElement { name: "Calendar"; icon: "pics/DateBook_48.png" } - ListElement { name: "Messaging"; icon: "pics/EMail_48.png" } - ListElement { name: "Todo List"; icon: "pics/TodoList_48.png" } - ListElement { name: "Contacts"; icon: "pics/AddressBook_48.png" } - } - - Component { - id: appDelegate - - Item { - width: 100; height: 100 - - Image { - id: myIcon - y: 20; anchors.horizontalCenter: parent.horizontalCenter - source: icon - } - Text { - anchors { top: myIcon.bottom; horizontalCenter: parent.horizontalCenter } - text: name - } - MouseArea { - anchors.fill: parent - onClicked: parent.GridView.view.currentIndex = index - } - } - } - - Component { - id: appHighlight - Rectangle { width: 80; height: 80; color: "lightsteelblue" } - } - - GridView { - anchors.fill: parent - cellWidth: 100; cellHeight: 100 - highlight: appHighlight - focus: true - model: appModel - delegate: appDelegate - } -} diff --git a/examples/declarative/modelviews/gridview/pics/AddressBook_48.png b/examples/declarative/modelviews/gridview/pics/AddressBook_48.png deleted file mode 100644 index 1ab7c8eec1..0000000000 Binary files a/examples/declarative/modelviews/gridview/pics/AddressBook_48.png and /dev/null differ diff --git a/examples/declarative/modelviews/gridview/pics/AudioPlayer_48.png b/examples/declarative/modelviews/gridview/pics/AudioPlayer_48.png deleted file mode 100644 index f4b8689f87..0000000000 Binary files a/examples/declarative/modelviews/gridview/pics/AudioPlayer_48.png and /dev/null differ diff --git a/examples/declarative/modelviews/gridview/pics/Camera_48.png b/examples/declarative/modelviews/gridview/pics/Camera_48.png deleted file mode 100644 index c76b524945..0000000000 Binary files a/examples/declarative/modelviews/gridview/pics/Camera_48.png and /dev/null differ diff --git a/examples/declarative/modelviews/gridview/pics/DateBook_48.png b/examples/declarative/modelviews/gridview/pics/DateBook_48.png deleted file mode 100644 index 58f5787fb8..0000000000 Binary files a/examples/declarative/modelviews/gridview/pics/DateBook_48.png and /dev/null differ diff --git a/examples/declarative/modelviews/gridview/pics/EMail_48.png b/examples/declarative/modelviews/gridview/pics/EMail_48.png deleted file mode 100644 index d6d84a61be..0000000000 Binary files a/examples/declarative/modelviews/gridview/pics/EMail_48.png and /dev/null differ diff --git a/examples/declarative/modelviews/gridview/pics/TodoList_48.png b/examples/declarative/modelviews/gridview/pics/TodoList_48.png deleted file mode 100644 index 0988448d9b..0000000000 Binary files a/examples/declarative/modelviews/gridview/pics/TodoList_48.png and /dev/null differ diff --git a/examples/declarative/modelviews/gridview/pics/VideoPlayer_48.png b/examples/declarative/modelviews/gridview/pics/VideoPlayer_48.png deleted file mode 100644 index 52638c50a7..0000000000 Binary files a/examples/declarative/modelviews/gridview/pics/VideoPlayer_48.png and /dev/null differ diff --git a/examples/declarative/modelviews/listview/content/PetsModel.qml b/examples/declarative/modelviews/listview/content/PetsModel.qml deleted file mode 100644 index 4f2087d95e..0000000000 --- a/examples/declarative/modelviews/listview/content/PetsModel.qml +++ /dev/null @@ -1,98 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -ListModel { - ListElement { - name: "Polly" - type: "Parrot" - age: 12 - size: "Small" - } - ListElement { - name: "Penny" - type: "Turtle" - age: 4 - size: "Small" - } - ListElement { - name: "Warren" - type: "Rabbit" - age: 2 - size: "Small" - } - ListElement { - name: "Spot" - type: "Dog" - age: 9 - size: "Medium" - } - ListElement { - name: "Schrödinger" - type: "Cat" - age: 2 - size: "Medium" - } - ListElement { - name: "Joey" - type: "Kangaroo" - age: 1 - size: "Medium" - } - ListElement { - name: "Kimba" - type: "Bunny" - age: 65 - size: "Large" - } - ListElement { - name: "Rover" - type: "Dog" - age: 5 - size: "Large" - } - ListElement { - name: "Tiny" - type: "Elephant" - age: 15 - size: "Large" - } -} diff --git a/examples/declarative/modelviews/listview/content/PressAndHoldButton.qml b/examples/declarative/modelviews/listview/content/PressAndHoldButton.qml deleted file mode 100644 index b20d8f64f1..0000000000 --- a/examples/declarative/modelviews/listview/content/PressAndHoldButton.qml +++ /dev/null @@ -1,82 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -Image { - id: container - - property int repeatDelay: 300 - property int repeatDuration: 75 - property bool pressed: false - - signal clicked - - scale: pressed ? 0.9 : 1 - - function release() { - autoRepeatClicks.stop() - container.pressed = false - } - - SequentialAnimation on pressed { - id: autoRepeatClicks - running: false - - PropertyAction { target: container; property: "pressed"; value: true } - ScriptAction { script: container.clicked() } - PauseAnimation { duration: repeatDelay } - - SequentialAnimation { - loops: Animation.Infinite - ScriptAction { script: container.clicked() } - PauseAnimation { duration: repeatDuration } - } - } - - MouseArea { - anchors.fill: parent - - onPressed: autoRepeatClicks.start() - onReleased: container.release() - onCanceled: container.release() - } -} - diff --git a/examples/declarative/modelviews/listview/content/RecipesModel.qml b/examples/declarative/modelviews/listview/content/RecipesModel.qml deleted file mode 100644 index 86210ba436..0000000000 --- a/examples/declarative/modelviews/listview/content/RecipesModel.qml +++ /dev/null @@ -1,129 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -ListModel { - ListElement { - title: "Pancakes" - picture: "content/pics/pancakes.jpg" - ingredients: " -
    -
  • 1 cup (150g) self-raising flour -
  • 1 tbs caster sugar -
  • 3/4 cup (185ml) milk -
  • 1 egg -
- " - method: " -
    -
  1. Sift flour and sugar together into a bowl. Add a pinch of salt. -
  2. Beat milk and egg together, then add to dry ingredients. Beat until smooth. -
  3. Pour mixture into a pan on medium heat and cook until bubbles appear on the surface. -
  4. Turn over and cook other side until golden. -
- " - } - ListElement { - title: "Fruit Salad" - picture: "content/pics/fruit-salad.jpg" - ingredients: "* Seasonal Fruit" - method: "* Chop fruit and place in a bowl." - } - ListElement { - title: "Vegetable Soup" - picture: "content/pics/vegetable-soup.jpg" - ingredients: " -
    -
  • 1 onion -
  • 1 turnip -
  • 1 potato -
  • 1 carrot -
  • 1 head of celery -
  • 1 1/2 litres of water -
- " - method: " -
    -
  1. Chop vegetables. -
  2. Boil in water until vegetables soften. -
  3. Season with salt and pepper to taste. -
- " - } - ListElement { - title: "Hamburger" - picture: "content/pics/hamburger.jpg" - ingredients: " -
    -
  • 500g minced beef -
  • Seasoning -
  • lettuce, tomato, onion, cheese -
  • 1 hamburger bun for each burger -
- " - method: " -
    -
  1. Mix the beef, together with seasoning, in a food processor. -
  2. Shape the beef into burgers. -
  3. Grill the burgers for about 5 mins on each side (until cooked through) -
  4. Serve each burger on a bun with ketchup, cheese, lettuce, tomato and onion. -
- " - } - ListElement { - title: "Lemonade" - picture: "content/pics/lemonade.jpg" - ingredients: " -
    -
  • 1 cup Lemon Juice -
  • 1 cup Sugar -
  • 6 Cups of Water (2 cups warm water, 4 cups cold water) -
- " - method: " -
    -
  1. Pour 2 cups of warm water into a pitcher and stir in sugar until it dissolves. -
  2. Pour in lemon juice, stir again, and add 4 cups of cold water. -
  3. Chill or serve over ice cubes. -
- " - } -} diff --git a/examples/declarative/modelviews/listview/content/TextButton.qml b/examples/declarative/modelviews/listview/content/TextButton.qml deleted file mode 100644 index 980ee21553..0000000000 --- a/examples/declarative/modelviews/listview/content/TextButton.qml +++ /dev/null @@ -1,78 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -Rectangle { - id: container - - property alias text: label.text - - signal clicked - - width: label.width + 20; height: label.height + 6 - smooth: true - radius: 10 - - gradient: Gradient { - GradientStop { id: gradientStop; position: 0.0; color: palette.light } - GradientStop { position: 1.0; color: palette.button } - } - - SystemPalette { id: palette } - - MouseArea { - id: mouseArea - anchors.fill: parent - onClicked: { container.clicked() } - } - - Text { - id: label - anchors.centerIn: parent - } - - states: State { - name: "pressed" - when: mouseArea.pressed - PropertyChanges { target: gradientStop; color: palette.dark } - } -} - diff --git a/examples/declarative/modelviews/listview/content/ToggleButton.qml b/examples/declarative/modelviews/listview/content/ToggleButton.qml deleted file mode 100644 index 0754d9849b..0000000000 --- a/examples/declarative/modelviews/listview/content/ToggleButton.qml +++ /dev/null @@ -1,58 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -Rectangle { - id: root - property alias label: text.text - property bool active: false - signal toggled - width: 149 - height: 30 - radius: 3 - color: active ? "green" : "lightgray" - border.width: 1 - Text { id: text; anchors.centerIn: parent; font.pixelSize: 14 } - MouseArea { - anchors.fill: parent - onClicked: { active = !active; root.toggled() } - } -} diff --git a/examples/declarative/modelviews/listview/content/pics/arrow-down.png b/examples/declarative/modelviews/listview/content/pics/arrow-down.png deleted file mode 100644 index 29d1d4439a..0000000000 Binary files a/examples/declarative/modelviews/listview/content/pics/arrow-down.png and /dev/null differ diff --git a/examples/declarative/modelviews/listview/content/pics/arrow-up.png b/examples/declarative/modelviews/listview/content/pics/arrow-up.png deleted file mode 100644 index e437312217..0000000000 Binary files a/examples/declarative/modelviews/listview/content/pics/arrow-up.png and /dev/null differ diff --git a/examples/declarative/modelviews/listview/content/pics/fruit-salad.jpg b/examples/declarative/modelviews/listview/content/pics/fruit-salad.jpg deleted file mode 100644 index da5a6b10a2..0000000000 Binary files a/examples/declarative/modelviews/listview/content/pics/fruit-salad.jpg and /dev/null differ diff --git a/examples/declarative/modelviews/listview/content/pics/hamburger.jpg b/examples/declarative/modelviews/listview/content/pics/hamburger.jpg deleted file mode 100644 index d0a15be1bf..0000000000 Binary files a/examples/declarative/modelviews/listview/content/pics/hamburger.jpg and /dev/null differ diff --git a/examples/declarative/modelviews/listview/content/pics/lemonade.jpg b/examples/declarative/modelviews/listview/content/pics/lemonade.jpg deleted file mode 100644 index db445c9ac8..0000000000 Binary files a/examples/declarative/modelviews/listview/content/pics/lemonade.jpg and /dev/null differ diff --git a/examples/declarative/modelviews/listview/content/pics/list-delete.png b/examples/declarative/modelviews/listview/content/pics/list-delete.png deleted file mode 100644 index df2a147d24..0000000000 Binary files a/examples/declarative/modelviews/listview/content/pics/list-delete.png and /dev/null differ diff --git a/examples/declarative/modelviews/listview/content/pics/minus-sign.png b/examples/declarative/modelviews/listview/content/pics/minus-sign.png deleted file mode 100644 index d6f233d739..0000000000 Binary files a/examples/declarative/modelviews/listview/content/pics/minus-sign.png and /dev/null differ diff --git a/examples/declarative/modelviews/listview/content/pics/moreDown.png b/examples/declarative/modelviews/listview/content/pics/moreDown.png deleted file mode 100644 index 31a35d5c20..0000000000 Binary files a/examples/declarative/modelviews/listview/content/pics/moreDown.png and /dev/null differ diff --git a/examples/declarative/modelviews/listview/content/pics/moreUp.png b/examples/declarative/modelviews/listview/content/pics/moreUp.png deleted file mode 100644 index fefb9c9098..0000000000 Binary files a/examples/declarative/modelviews/listview/content/pics/moreUp.png and /dev/null differ diff --git a/examples/declarative/modelviews/listview/content/pics/pancakes.jpg b/examples/declarative/modelviews/listview/content/pics/pancakes.jpg deleted file mode 100644 index 60c439638e..0000000000 Binary files a/examples/declarative/modelviews/listview/content/pics/pancakes.jpg and /dev/null differ diff --git a/examples/declarative/modelviews/listview/content/pics/plus-sign.png b/examples/declarative/modelviews/listview/content/pics/plus-sign.png deleted file mode 100644 index 40df1134f8..0000000000 Binary files a/examples/declarative/modelviews/listview/content/pics/plus-sign.png and /dev/null differ diff --git a/examples/declarative/modelviews/listview/content/pics/vegetable-soup.jpg b/examples/declarative/modelviews/listview/content/pics/vegetable-soup.jpg deleted file mode 100644 index 9dce332041..0000000000 Binary files a/examples/declarative/modelviews/listview/content/pics/vegetable-soup.jpg and /dev/null differ diff --git a/examples/declarative/modelviews/listview/dynamiclist.qml b/examples/declarative/modelviews/listview/dynamiclist.qml deleted file mode 100644 index ee7c6329bc..0000000000 --- a/examples/declarative/modelviews/listview/dynamiclist.qml +++ /dev/null @@ -1,203 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -import QtQuick 2.0 -import "content" - -// This example shows how items can be dynamically added to and removed from -// a ListModel, and how these list modifications can be animated. - -Rectangle { - id: container - width: 500; height: 400 - color: "#343434" - - // The model: - ListModel { - id: fruitModel - - ListElement { - name: "Apple"; cost: 2.45 - attributes: [ - ListElement { description: "Core" }, - ListElement { description: "Deciduous" } - ] - } - ListElement { - name: "Banana"; cost: 1.95 - attributes: [ - ListElement { description: "Tropical" }, - ListElement { description: "Seedless" } - ] - } - ListElement { - name: "Cumquat"; cost: 3.25 - attributes: [ - ListElement { description: "Citrus" } - ] - } - ListElement { - name: "Durian"; cost: 9.95 - attributes: [ - ListElement { description: "Tropical" }, - ListElement { description: "Smelly" } - ] - } - } - - // The delegate for each fruit in the model: - Component { - id: listDelegate - - Item { - id: delegateItem - width: listView.width; height: 55 - clip: true - - Row { - anchors.verticalCenter: parent.verticalCenter - spacing: 10 - - Column { - Image { - source: "content/pics/arrow-up.png" - MouseArea { anchors.fill: parent; onClicked: fruitModel.move(index, index-1, 1) } - } - Image { source: "content/pics/arrow-down.png" - MouseArea { anchors.fill: parent; onClicked: fruitModel.move(index, index+1, 1) } - } - } - - Column { - anchors.verticalCenter: parent.verticalCenter - - Text { - text: name - font.pixelSize: 15 - color: "white" - } - Row { - spacing: 5 - Repeater { - model: attributes - Text { text: description; color: "White" } - } - } - } - } - - Row { - anchors.verticalCenter: parent.verticalCenter - anchors.right: parent.right - spacing: 10 - - PressAndHoldButton { - anchors.verticalCenter: parent.verticalCenter - source: "content/pics/plus-sign.png" - onClicked: fruitModel.setProperty(index, "cost", cost + 0.25) - } - - Text { - id: costText - anchors.verticalCenter: parent.verticalCenter - text: '$' + Number(cost).toFixed(2) - font.pixelSize: 15 - color: "white" - font.bold: true - } - - PressAndHoldButton { - anchors.verticalCenter: parent.verticalCenter - source: "content/pics/minus-sign.png" - onClicked: fruitModel.setProperty(index, "cost", Math.max(0,cost-0.25)) - } - - Image { - source: "content/pics/list-delete.png" - MouseArea { anchors.fill:parent; onClicked: fruitModel.remove(index) } - } - } - - // Animate adding and removing of items: - - ListView.onAdd: SequentialAnimation { - PropertyAction { target: delegateItem; property: "height"; value: 0 } - NumberAnimation { target: delegateItem; property: "height"; to: 55; duration: 250; easing.type: Easing.InOutQuad } - } - - ListView.onRemove: SequentialAnimation { - PropertyAction { target: delegateItem; property: "ListView.delayRemove"; value: true } - NumberAnimation { target: delegateItem; property: "height"; to: 0; duration: 250; easing.type: Easing.InOutQuad } - - // Make sure delayRemove is set back to false so that the item can be destroyed - PropertyAction { target: delegateItem; property: "ListView.delayRemove"; value: false } - } - } - } - - // The view: - ListView { - id: listView - anchors.fill: parent; anchors.margins: 20 - model: fruitModel - delegate: listDelegate - } - - Row { - anchors { left: parent.left; bottom: parent.bottom; margins: 20 } - spacing: 10 - - TextButton { - text: "Add an item" - onClicked: { - fruitModel.append({ - "name": "Pizza Margarita", - "cost": 5.95, - "attributes": [{"description": "Cheese"}, {"description": "Tomato"}] - }) - } - } - - TextButton { - text: "Remove all items" - onClicked: fruitModel.clear() - } - } -} - diff --git a/examples/declarative/modelviews/listview/expandingdelegates.qml b/examples/declarative/modelviews/listview/expandingdelegates.qml deleted file mode 100644 index 43a9662422..0000000000 --- a/examples/declarative/modelviews/listview/expandingdelegates.qml +++ /dev/null @@ -1,202 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 -import "content" - -// This example illustrates expanding a list item to show a more detailed view. - -Rectangle { - id: page - width: 400; height: 240 - color: "black" - - // Delegate for the recipes. This delegate has two modes: - // 1. List mode (default), which just shows the picture and title of the recipe. - // 2. Details mode, which also shows the ingredients and method. - Component { - id: recipeDelegate - - Item { - id: recipe - - // Create a property to contain the visibility of the details. - // We can bind multiple element's opacity to this one property, - // rather than having a "PropertyChanges" line for each element we - // want to fade. - property real detailsOpacity : 0 - - width: listView.width - height: 70 - - // A simple rounded rectangle for the background - Rectangle { - id: background - x: 2; y: 2; width: parent.width - x*2; height: parent.height - y*2 - color: "ivory" - border.color: "orange" - radius: 5 - } - - // This mouse region covers the entire delegate. - // When clicked it changes mode to 'Details'. If we are already - // in Details mode, then no change will happen. - MouseArea { - anchors.fill: parent - onClicked: recipe.state = 'Details'; - } - - // Lay out the page: picture, title and ingredients at the top, and method at the - // bottom. Note that elements that should not be visible in the list - // mode have their opacity set to recipe.detailsOpacity. - Row { - id: topLayout - x: 10; y: 10; height: recipeImage.height; width: parent.width - spacing: 10 - - Image { - id: recipeImage - width: 50; height: 50 - source: picture - } - - Column { - width: background.width - recipeImage.width - 20; height: recipeImage.height - spacing: 5 - - Text { - text: title - font.bold: true; font.pointSize: 16 - } - - Text { - text: "Ingredients" - font.pointSize: 12; font.bold: true - opacity: recipe.detailsOpacity - } - - Text { - text: ingredients - wrapMode: Text.WordWrap - width: parent.width - opacity: recipe.detailsOpacity - } - } - } - - Item { - id: details - x: 10; width: parent.width - 20 - anchors { top: topLayout.bottom; topMargin: 10; bottom: parent.bottom; bottomMargin: 10 } - opacity: recipe.detailsOpacity - - Text { - id: methodTitle - anchors.top: parent.top - text: "Method" - font.pointSize: 12; font.bold: true - } - - Flickable { - id: flick - width: parent.width - anchors { top: methodTitle.bottom; bottom: parent.bottom } - contentHeight: methodText.height - clip: true - - Text { id: methodText; text: method; wrapMode: Text.WordWrap; width: details.width } - } - - Image { - anchors { right: flick.right; top: flick.top } - source: "content/pics/moreUp.png" - opacity: flick.atYBeginning ? 0 : 1 - } - - Image { - anchors { right: flick.right; bottom: flick.bottom } - source: "content/pics/moreDown.png" - opacity: flick.atYEnd ? 0 : 1 - } - } - - // A button to close the detailed view, i.e. set the state back to default (''). - TextButton { - y: 10 - anchors { right: background.right; rightMargin: 10 } - opacity: recipe.detailsOpacity - text: "Close" - - onClicked: recipe.state = ''; - } - - states: State { - name: "Details" - - PropertyChanges { target: background; color: "white" } - PropertyChanges { target: recipeImage; width: 130; height: 130 } // Make picture bigger - PropertyChanges { target: recipe; detailsOpacity: 1; x: 0 } // Make details visible - PropertyChanges { target: recipe; height: listView.height } // Fill the entire list area with the detailed view - - // Move the list so that this item is at the top. - PropertyChanges { target: recipe.ListView.view; explicit: true; contentY: recipe.y } - - // Disallow flicking while we're in detailed view - PropertyChanges { target: recipe.ListView.view; interactive: false } - } - - transitions: Transition { - // Make the state changes smooth - ParallelAnimation { - ColorAnimation { property: "color"; duration: 500 } - NumberAnimation { duration: 300; properties: "detailsOpacity,x,contentY,height,width" } - } - } - } - } - - // The actual list - ListView { - id: listView - anchors.fill: parent - model: RecipesModel {} - delegate: recipeDelegate - } -} diff --git a/examples/declarative/modelviews/listview/highlight.qml b/examples/declarative/modelviews/listview/highlight.qml deleted file mode 100644 index d8f76080e6..0000000000 --- a/examples/declarative/modelviews/listview/highlight.qml +++ /dev/null @@ -1,99 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -// This example shows how to create your own highlight delegate for a ListView -// that uses a SpringAnimation to provide custom movement when the -// highlight bar is moved between items. - -import QtQuick 2.0 -import "content" - -Rectangle { - width: 200; height: 300 - - // Define a delegate component. A component will be - // instantiated for each visible item in the list. - Component { - id: petDelegate - Item { - id: wrapper - width: 200; height: 55 - Column { - Text { text: 'Name: ' + name } - Text { text: 'Type: ' + type } - Text { text: 'Age: ' + age } - } - // indent the item if it is the current item - states: State { - name: "Current" - when: wrapper.ListView.isCurrentItem - PropertyChanges { target: wrapper; x: 20 } - } - transitions: Transition { - NumberAnimation { properties: "x"; duration: 200 } - } - } - } - - // Define a highlight with customised movement between items. - Component { - id: highlightBar - Rectangle { - width: 200; height: 50 - color: "#FFFF88" - y: listView.currentItem.y; - Behavior on y { SpringAnimation { spring: 2; damping: 0.1 } } - } - } - - ListView { - id: listView - width: 200; height: parent.height - - model: PetsModel {} - delegate: petDelegate - focus: true - - // Set the highlight delegate. Note we must also set highlightFollowsCurrentItem - // to false so the highlight delegate can control how the highlight is moved. - highlight: highlightBar - highlightFollowsCurrentItem: false - } -} diff --git a/examples/declarative/modelviews/listview/highlightranges.qml b/examples/declarative/modelviews/listview/highlightranges.qml deleted file mode 100644 index a536ddcbb2..0000000000 --- a/examples/declarative/modelviews/listview/highlightranges.qml +++ /dev/null @@ -1,122 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 -import "content" - -Rectangle { - id: root - property int current: 0 - width: 600; height: 300 - - // This example shows the same model in three different ListView items, - // with different highlight ranges. The highlight ranges are set by the - // preferredHighlightBegin and preferredHighlightEnd properties in ListView. - // - // The first ListView does not set a highlight range, so its currentItem - // can move freely within the visible area. If it moves outside the - // visible area, the view is automatically scrolled to keep the current - // item visible. - // - // The second ListView sets a highlight range which attempts to keep the - // current item within the the bounds of the range. However, - // items will not scroll beyond the beginning or end of the view, - // forcing the highlight to move outside the range at the ends. - // - // The third ListView sets the highlightRangeMode to StrictlyEnforceRange - // and sets a range smaller than the height of an item. This - // forces the current item to change when the view is flicked, - // since the highlight is unable to move. - // - // All ListViews bind their currentIndex to the root.current property. - // The first ListView sets root.current whenever its currentIndex changes - // due to keyboard interaction. - // Flicking the third ListView with the mouse also changes root.current. - - ListView { - id: list1 - width: 200; height: parent.height - model: PetsModel {} - delegate: petDelegate - - highlight: Rectangle { color: "lightsteelblue" } - currentIndex: root.current - onCurrentIndexChanged: root.current = currentIndex - focus: true - } - - ListView { - id: list2 - x: list1.width - width: 200; height: parent.height - model: PetsModel {} - delegate: petDelegate - - highlight: Rectangle { color: "yellow" } - currentIndex: root.current - preferredHighlightBegin: 80; preferredHighlightEnd: 220 - highlightRangeMode: ListView.ApplyRange - } - - ListView { - id: list3 - x: list1.width + list2.width - width: 200; height: parent.height - model: PetsModel {} - delegate: petDelegate - - highlight: Rectangle { color: "yellow" } - currentIndex: root.current - onCurrentIndexChanged: root.current = currentIndex - preferredHighlightBegin: 125; preferredHighlightEnd: 125 - highlightRangeMode: ListView.StrictlyEnforceRange - } - - // The delegate for each list - Component { - id: petDelegate - Column { - width: 200 - Text { text: 'Name: ' + name } - Text { text: 'Type: ' + type } - Text { text: 'Age: ' + age } - } - } -} diff --git a/examples/declarative/modelviews/listview/sections.qml b/examples/declarative/modelviews/listview/sections.qml deleted file mode 100644 index 2e63a86bb6..0000000000 --- a/examples/declarative/modelviews/listview/sections.qml +++ /dev/null @@ -1,127 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -// This example shows how a ListView can be separated into sections using -// the ListView.section attached property. - -import QtQuick 2.0 -import "content" - -Rectangle { - id: container - width: 300 - height: 360 - - ListModel { - id: animalsModel - ListElement { name: "Ant"; size: "Tiny" } - ListElement { name: "Flea"; size: "Tiny" } - ListElement { name: "Parrot"; size: "Small" } - ListElement { name: "Guinea pig"; size: "Small" } - ListElement { name: "Rat"; size: "Small" } - ListElement { name: "Butterfly"; size: "Small" } - ListElement { name: "Dog"; size: "Medium" } - ListElement { name: "Cat"; size: "Medium" } - ListElement { name: "Pony"; size: "Medium" } - ListElement { name: "Koala"; size: "Medium" } - ListElement { name: "Horse"; size: "Large" } - ListElement { name: "Tiger"; size: "Large" } - ListElement { name: "Giraffe"; size: "Large" } - ListElement { name: "Elephant"; size: "Huge" } - ListElement { name: "Whale"; size: "Huge" } - } - -//! [0] - // The delegate for each section header - Component { - id: sectionHeading - Rectangle { - width: container.width - height: childrenRect.height - color: "lightsteelblue" - - Text { - text: section - font.bold: true - font.pixelSize: 20 - } - } - } - - ListView { - id: view - anchors.top: parent.top - anchors.bottom: buttonBar.top - width: parent.width - model: animalsModel - delegate: Text { text: name; font.pixelSize: 18 } - - section.property: "size" - section.criteria: ViewSection.FullString - section.delegate: sectionHeading - } -//! [0] - - Row { - id: buttonBar - anchors.bottom: parent.bottom - anchors.bottomMargin: 1 - spacing: 1 - ToggleButton { - label: "CurrentLabelAtStart" - onToggled: { - if (active) - view.section.labelPositioning |= ViewSection.CurrentLabelAtStart - else - view.section.labelPositioning &= ~ViewSection.CurrentLabelAtStart - } - } - ToggleButton { - label: "NextLabelAtEnd" - onToggled: { - if (active) - view.section.labelPositioning |= ViewSection.NextLabelAtEnd - else - view.section.labelPositioning &= ~ViewSection.NextLabelAtEnd - } - } - } -} - diff --git a/examples/declarative/modelviews/modelviews.pro b/examples/declarative/modelviews/modelviews.pro deleted file mode 100644 index 7748da0471..0000000000 --- a/examples/declarative/modelviews/modelviews.pro +++ /dev/null @@ -1,8 +0,0 @@ -TEMPLATE = subdirs - -SUBDIRS += \ - abstractitemmodel \ - objectlistmodel \ - stringlistmodel - - diff --git a/examples/declarative/modelviews/modelviews.qml b/examples/declarative/modelviews/modelviews.qml deleted file mode 100644 index 86b10ca4ba..0000000000 --- a/examples/declarative/modelviews/modelviews.qml +++ /dev/null @@ -1,64 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 -import "../shared" - -Item { - height: 480 - width: 480 - LauncherList { - id: ll - anchors.fill: parent - Component.onCompleted: { - addExample("Dynamic List", "A ListView harboring dynamic data", Qt.resolvedUrl("listview/dynamiclist.qml")); - addExample("Expanding Delegates", "Delegates that expand to fill the list when clicked", Qt.resolvedUrl("listview/expandingdelegates.qml")); - addExample("Highlight", "Adding a highlight to the current item", Qt.resolvedUrl("listview/highlight.qml")); - addExample("Sections", "A ListView with section headers", Qt.resolvedUrl("listview/sections.qml")); - addExample("GridView", "A view laid out in a grid", Qt.resolvedUrl("gridview/gridview-example.qml")); - addExample("PathView", "A view laid out along a path", Qt.resolvedUrl("pathview/pathview-example.qml")); - addExample("Package", "Using a package to transition items between views", Qt.resolvedUrl("package/view.qml")); - addExample("Parallax", "Adds a background and a parallax effect to a ListView", Qt.resolvedUrl("parallax/parallax.qml")); - addExample("Slideshow", "A model demonstrating delayed image loading", Qt.resolvedUrl("visualdatamodel/slideshow.qml")); - addExample("Sorted Model", "Two views on a model, one of which is sorted", Qt.resolvedUrl("visualdatamodel/sortedmodel.qml")); - addExample("VisualItemModel", "A model that consists of the actual Items", Qt.resolvedUrl("visualitemmodel/visualitemmodel.qml")); - } - } -} diff --git a/examples/declarative/modelviews/modelviews.qmlproject b/examples/declarative/modelviews/modelviews.qmlproject deleted file mode 100644 index 40f9e568fd..0000000000 --- a/examples/declarative/modelviews/modelviews.qmlproject +++ /dev/null @@ -1,16 +0,0 @@ -import QmlProject 1.1 - -Project { - mainFile: "modelviews.qml" - - /* Include .qml, .js, and image files from current directory and subdirectories */ - QmlFiles { - directory: "." - } - JavaScriptFiles { - directory: "." - } - ImageFiles { - directory: "." - } -} diff --git a/examples/declarative/modelviews/objectlistmodel/dataobject.cpp b/examples/declarative/modelviews/objectlistmodel/dataobject.cpp deleted file mode 100644 index 7216283616..0000000000 --- a/examples/declarative/modelviews/objectlistmodel/dataobject.cpp +++ /dev/null @@ -1,78 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include -#include "dataobject.h" - -DataObject::DataObject(QObject *parent) - : QObject(parent) -{ -} - -DataObject::DataObject(const QString &name, const QString &color, QObject *parent) - : QObject(parent), m_name(name), m_color(color) -{ -} - -QString DataObject::name() const -{ - return m_name; -} - -void DataObject::setName(const QString &name) -{ - if (name != m_name) { - m_name = name; - emit nameChanged(); - } -} - -QString DataObject::color() const -{ - return m_color; -} - -void DataObject::setColor(const QString &color) -{ - if (color != m_color) { - m_color = color; - emit colorChanged(); - } -} diff --git a/examples/declarative/modelviews/objectlistmodel/dataobject.h b/examples/declarative/modelviews/objectlistmodel/dataobject.h deleted file mode 100644 index bea92a273c..0000000000 --- a/examples/declarative/modelviews/objectlistmodel/dataobject.h +++ /dev/null @@ -1,76 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef DATAOBJECT_H -#define DATAOBJECT_H - -#include - -//![0] -class DataObject : public QObject -{ - Q_OBJECT - - Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged) - Q_PROPERTY(QString color READ color WRITE setColor NOTIFY colorChanged) -//![0] - -public: - DataObject(QObject *parent=0); - DataObject(const QString &name, const QString &color, QObject *parent=0); - - QString name() const; - void setName(const QString &name); - - QString color() const; - void setColor(const QString &color); - -signals: - void nameChanged(); - void colorChanged(); - -private: - QString m_name; - QString m_color; -//![1] -}; -//![1] - -#endif // DATAOBJECT_H diff --git a/examples/declarative/modelviews/objectlistmodel/main.cpp b/examples/declarative/modelviews/objectlistmodel/main.cpp deleted file mode 100644 index c8542976c3..0000000000 --- a/examples/declarative/modelviews/objectlistmodel/main.cpp +++ /dev/null @@ -1,78 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the demonstration applications of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include - -#include -#include -#include -#include -#include - -#include "dataobject.h" - -/* - This example illustrates exposing a QList as a - model in QML -*/ - -//![0] -int main(int argc, char ** argv) -{ - QGuiApplication app(argc, argv); - - QList dataList; - dataList.append(new DataObject("Item 1", "red")); - dataList.append(new DataObject("Item 2", "green")); - dataList.append(new DataObject("Item 3", "blue")); - dataList.append(new DataObject("Item 4", "yellow")); - - QQuickView view; - view.setResizeMode(QQuickView::SizeRootObjectToView); - QDeclarativeContext *ctxt = view.rootContext(); - ctxt->setContextProperty("myModel", QVariant::fromValue(dataList)); -//![0] - - view.setSource(QUrl("qrc:view.qml")); - view.show(); - - return app.exec(); -} - diff --git a/examples/declarative/modelviews/objectlistmodel/objectlistmodel.pro b/examples/declarative/modelviews/objectlistmodel/objectlistmodel.pro deleted file mode 100644 index 74dc5b1016..0000000000 --- a/examples/declarative/modelviews/objectlistmodel/objectlistmodel.pro +++ /dev/null @@ -1,6 +0,0 @@ -QT += declarative quick - -SOURCES += main.cpp \ - dataobject.cpp -HEADERS += dataobject.h -RESOURCES += objectlistmodel.qrc diff --git a/examples/declarative/modelviews/objectlistmodel/objectlistmodel.qmlproject b/examples/declarative/modelviews/objectlistmodel/objectlistmodel.qmlproject deleted file mode 100644 index 2bb4016996..0000000000 --- a/examples/declarative/modelviews/objectlistmodel/objectlistmodel.qmlproject +++ /dev/null @@ -1,14 +0,0 @@ -import QmlProject 1.0 - -Project { - /* Include .qml, .js, and image files from current directory and subdirectories */ - QmlFiles { - directory: "." - } - JavaScriptFiles { - directory: "." - } - ImageFiles { - directory: "." - } -} diff --git a/examples/declarative/modelviews/objectlistmodel/objectlistmodel.qrc b/examples/declarative/modelviews/objectlistmodel/objectlistmodel.qrc deleted file mode 100644 index 17e9301471..0000000000 --- a/examples/declarative/modelviews/objectlistmodel/objectlistmodel.qrc +++ /dev/null @@ -1,5 +0,0 @@ - - - view.qml - - diff --git a/examples/declarative/modelviews/objectlistmodel/view.qml b/examples/declarative/modelviews/objectlistmodel/view.qml deleted file mode 100644 index 3954e79829..0000000000 --- a/examples/declarative/modelviews/objectlistmodel/view.qml +++ /dev/null @@ -1,55 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -//![0] -ListView { - width: 100; height: 100 - - model: myModel - delegate: Rectangle { - height: 25 - width: 100 - color: model.modelData.color - Text { text: name } - } -} -//![0] diff --git a/examples/declarative/modelviews/package/Delegate.qml b/examples/declarative/modelviews/package/Delegate.qml deleted file mode 100644 index 97c7840cb4..0000000000 --- a/examples/declarative/modelviews/package/Delegate.qml +++ /dev/null @@ -1,88 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -//![0] -Package { - Text { id: listDelegate; width: 200; height: 25; text: 'Empty'; Package.name: 'list' } - Text { id: gridDelegate; width: 100; height: 50; text: 'Empty'; Package.name: 'grid' } - - Rectangle { - id: wrapper - width: 200; height: 25 - color: 'lightsteelblue' - - Text { text: display; anchors.centerIn: parent } - MouseArea { - anchors.fill: parent - onClicked: { - if (wrapper.state == 'inList') - wrapper.state = 'inGrid'; - else - wrapper.state = 'inList'; - } - } - - state: 'inList' - states: [ - State { - name: 'inList' - ParentChange { target: wrapper; parent: listDelegate } - }, - State { - name: 'inGrid' - ParentChange { - target: wrapper; parent: gridDelegate - x: 0; y: 0; width: gridDelegate.width; height: gridDelegate.height - } - } - ] - - transitions: [ - Transition { - ParentAnimation { - NumberAnimation { properties: 'x,y,width,height'; duration: 300 } - } - } - ] - } -} -//![0] diff --git a/examples/declarative/modelviews/package/view.qml b/examples/declarative/modelviews/package/view.qml deleted file mode 100644 index 5b2fd9481c..0000000000 --- a/examples/declarative/modelviews/package/view.qml +++ /dev/null @@ -1,76 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -Rectangle { - color: "white" - width: 400 - height: 200 - - ListModel { - id: myModel - ListElement { display: "One" } - ListElement { display: "Two" } - ListElement { display: "Three" } - ListElement { display: "Four" } - ListElement { display: "Five" } - ListElement { display: "Six" } - ListElement { display: "Seven" } - ListElement { display: "Eight" } - } - //![0] - VisualDataModel { - id: visualModel - delegate: Delegate {} - model: myModel - } - - ListView { - width: 200; height:200 - model: visualModel.parts.list - } - GridView { - x: 200; width: 200; height:200 - cellHeight: 50 - model: visualModel.parts.grid - } - //![0] -} diff --git a/examples/declarative/modelviews/parallax/content/ParallaxView.qml b/examples/declarative/modelviews/parallax/content/ParallaxView.qml deleted file mode 100644 index 2acf50dcef..0000000000 --- a/examples/declarative/modelviews/parallax/content/ParallaxView.qml +++ /dev/null @@ -1,123 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -Item { - id: root - - property alias background: background.source - property int currentIndex: 0 - default property alias content: visualModel.children - - Image { - id: background - fillMode: Image.TileHorizontally - x: -list.contentX / 2 - width: Math.max(list.contentWidth, parent.width) - } - - ListView { - id: list - anchors.fill: parent - - currentIndex: root.currentIndex - onCurrentIndexChanged: root.currentIndex = currentIndex - - orientation: Qt.Horizontal - boundsBehavior: Flickable.DragOverBounds - model: VisualItemModel { id: visualModel } - - highlightRangeMode: ListView.StrictlyEnforceRange - snapMode: ListView.SnapOneItem - } - - ListView { - id: selector - - height: 50 - anchors.bottom: parent.bottom - anchors.horizontalCenter: parent.horizontalCenter - width: Math.min(count * 50, parent.width - 20) - interactive: width == parent.width - 20 - orientation: Qt.Horizontal - - currentIndex: root.currentIndex - onCurrentIndexChanged: root.currentIndex = currentIndex - - model: visualModel.children - delegate: Item { - width: 50; height: 50 - id: delegateRoot - - Image { - id: image - source: modelData.icon - smooth: true - scale: 0.8 - } - - MouseArea { - anchors.fill: parent - onClicked: { root.currentIndex = index } - } - - states: State { - name: "Selected" - when: delegateRoot.ListView.isCurrentItem == true - PropertyChanges { - target: image - scale: 1 - y: -5 - } - } - transitions: Transition { - NumberAnimation { properties: "scale,y" } - } - } - - Rectangle { - color: "#60FFFFFF" - x: -10; y: -10; z: -1 - width: parent.width + 20; height: parent.height + 20 - radius: 10 - } - } -} diff --git a/examples/declarative/modelviews/parallax/content/Smiley.qml b/examples/declarative/modelviews/parallax/content/Smiley.qml deleted file mode 100644 index 982b6c5d2b..0000000000 --- a/examples/declarative/modelviews/parallax/content/Smiley.qml +++ /dev/null @@ -1,84 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -// This is taken from the declarative animation/basics/property-animation.qml -// example - -Item { - id: window - width: 320; height: 480 - - Image { - anchors.horizontalCenter: parent.horizontalCenter - y: smiley.minHeight + 58 - source: "pics/shadow.png" - - scale: smiley.y * 0.5 / (smiley.minHeight - smiley.maxHeight) - } - - Image { - id: smiley - property int maxHeight: window.height / 3 - property int minHeight: 2 * window.height / 3 - - anchors.horizontalCenter: parent.horizontalCenter - y: minHeight - source: "pics/face-smile.png" - - SequentialAnimation on y { - loops: Animation.Infinite - - NumberAnimation { - from: smiley.minHeight; to: smiley.maxHeight - easing.type: Easing.OutExpo; duration: 300 - } - - NumberAnimation { - from: smiley.maxHeight; to: smiley.minHeight - easing.type: Easing.OutBounce; duration: 1000 - } - - PauseAnimation { duration: 500 } - } - } -} - diff --git a/examples/declarative/modelviews/parallax/content/pics/background.jpg b/examples/declarative/modelviews/parallax/content/pics/background.jpg deleted file mode 100644 index 61cca2f138..0000000000 Binary files a/examples/declarative/modelviews/parallax/content/pics/background.jpg and /dev/null differ diff --git a/examples/declarative/modelviews/parallax/content/pics/face-smile.png b/examples/declarative/modelviews/parallax/content/pics/face-smile.png deleted file mode 100644 index 3d66d72578..0000000000 Binary files a/examples/declarative/modelviews/parallax/content/pics/face-smile.png and /dev/null differ diff --git a/examples/declarative/modelviews/parallax/content/pics/home-page.png b/examples/declarative/modelviews/parallax/content/pics/home-page.png deleted file mode 100644 index bd090c3708..0000000000 Binary files a/examples/declarative/modelviews/parallax/content/pics/home-page.png and /dev/null differ diff --git a/examples/declarative/modelviews/parallax/content/pics/home-page.svg b/examples/declarative/modelviews/parallax/content/pics/home-page.svg deleted file mode 100644 index 4f16958844..0000000000 --- a/examples/declarative/modelviews/parallax/content/pics/home-page.svg +++ /dev/null @@ -1,445 +0,0 @@ - -image/svg+xmlGo HomeJakub Steinerhttp://jimmac.musichall.czhomereturngodefaultuserdirectoryTuomas Kuosmanen - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/examples/declarative/modelviews/parallax/content/pics/shadow.png b/examples/declarative/modelviews/parallax/content/pics/shadow.png deleted file mode 100644 index 8270565e87..0000000000 Binary files a/examples/declarative/modelviews/parallax/content/pics/shadow.png and /dev/null differ diff --git a/examples/declarative/modelviews/parallax/content/pics/yast-joystick.png b/examples/declarative/modelviews/parallax/content/pics/yast-joystick.png deleted file mode 100644 index 858cea0301..0000000000 Binary files a/examples/declarative/modelviews/parallax/content/pics/yast-joystick.png and /dev/null differ diff --git a/examples/declarative/modelviews/parallax/content/pics/yast-wol.png b/examples/declarative/modelviews/parallax/content/pics/yast-wol.png deleted file mode 100644 index 7712180a3b..0000000000 Binary files a/examples/declarative/modelviews/parallax/content/pics/yast-wol.png and /dev/null differ diff --git a/examples/declarative/modelviews/parallax/parallax.qml b/examples/declarative/modelviews/parallax/parallax.qml deleted file mode 100644 index 6981095a80..0000000000 --- a/examples/declarative/modelviews/parallax/parallax.qml +++ /dev/null @@ -1,77 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 -import "../../toys/clocks/content" // for loading the Clock element -import "content" - -Rectangle { - width: 320; height: 480 - - ParallaxView { - id: parallax - anchors.fill: parent - background: "content/pics/background.jpg" - - Item { - property url icon: "content/pics/yast-wol.png" - width: 320; height: 480 - Clock { anchors.centerIn: parent } - } - - Item { - property url icon: "content/pics/home-page.png" - width: 320; height: 480 - Smiley { } - } - - Item { - property url icon: "content/pics/yast-joystick.png" - width: 320; height: 480 - - Loader { - anchors { top: parent.top; topMargin: 10; horizontalCenter: parent.horizontalCenter } - width: 300; height: 400 - clip: true; - source: "../../samegame/samegame.qml" - } - } - } -} diff --git a/examples/declarative/modelviews/pathview/pathview-example.qml b/examples/declarative/modelviews/pathview/pathview-example.qml deleted file mode 100644 index 6161343830..0000000000 --- a/examples/declarative/modelviews/pathview/pathview-example.qml +++ /dev/null @@ -1,107 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -Rectangle { - width: 400; height: 240 - color: "white" - - ListModel { - id: appModel - ListElement { name: "Music"; icon: "pics/AudioPlayer_48.png" } - ListElement { name: "Movies"; icon: "pics/VideoPlayer_48.png" } - ListElement { name: "Camera"; icon: "pics/Camera_48.png" } - ListElement { name: "Calendar"; icon: "pics/DateBook_48.png" } - ListElement { name: "Messaging"; icon: "pics/EMail_48.png" } - ListElement { name: "Todo List"; icon: "pics/TodoList_48.png" } - ListElement { name: "Contacts"; icon: "pics/AddressBook_48.png" } - } - - Component { - id: appDelegate - Item { - width: 100; height: 100 - scale: PathView.iconScale - - Image { - id: myIcon - y: 20; anchors.horizontalCenter: parent.horizontalCenter - source: icon - smooth: true - } - Text { - anchors { top: myIcon.bottom; horizontalCenter: parent.horizontalCenter } - text: name - smooth: true - } - - MouseArea { - anchors.fill: parent - onClicked: view.currentIndex = index - } - } - } - - Component { - id: appHighlight - Rectangle { width: 80; height: 80; color: "lightsteelblue" } - } - - PathView { - id: view - anchors.fill: parent - highlight: appHighlight - preferredHighlightBegin: 0.5 - preferredHighlightEnd: 0.5 - focus: true - model: appModel - delegate: appDelegate - path: Path { - startX: 10 - startY: 50 - PathAttribute { name: "iconScale"; value: 0.5 } - PathQuad { x: 200; y: 150; controlX: 50; controlY: 200 } - PathAttribute { name: "iconScale"; value: 1.0 } - PathQuad { x: 390; y: 50; controlX: 350; controlY: 200 } - PathAttribute { name: "iconScale"; value: 0.5 } - } - } -} diff --git a/examples/declarative/modelviews/pathview/pics/AddressBook_48.png b/examples/declarative/modelviews/pathview/pics/AddressBook_48.png deleted file mode 100644 index 1ab7c8eec1..0000000000 Binary files a/examples/declarative/modelviews/pathview/pics/AddressBook_48.png and /dev/null differ diff --git a/examples/declarative/modelviews/pathview/pics/AudioPlayer_48.png b/examples/declarative/modelviews/pathview/pics/AudioPlayer_48.png deleted file mode 100644 index f4b8689f87..0000000000 Binary files a/examples/declarative/modelviews/pathview/pics/AudioPlayer_48.png and /dev/null differ diff --git a/examples/declarative/modelviews/pathview/pics/Camera_48.png b/examples/declarative/modelviews/pathview/pics/Camera_48.png deleted file mode 100644 index c76b524945..0000000000 Binary files a/examples/declarative/modelviews/pathview/pics/Camera_48.png and /dev/null differ diff --git a/examples/declarative/modelviews/pathview/pics/DateBook_48.png b/examples/declarative/modelviews/pathview/pics/DateBook_48.png deleted file mode 100644 index 58f5787fb8..0000000000 Binary files a/examples/declarative/modelviews/pathview/pics/DateBook_48.png and /dev/null differ diff --git a/examples/declarative/modelviews/pathview/pics/EMail_48.png b/examples/declarative/modelviews/pathview/pics/EMail_48.png deleted file mode 100644 index d6d84a61be..0000000000 Binary files a/examples/declarative/modelviews/pathview/pics/EMail_48.png and /dev/null differ diff --git a/examples/declarative/modelviews/pathview/pics/TodoList_48.png b/examples/declarative/modelviews/pathview/pics/TodoList_48.png deleted file mode 100644 index 0988448d9b..0000000000 Binary files a/examples/declarative/modelviews/pathview/pics/TodoList_48.png and /dev/null differ diff --git a/examples/declarative/modelviews/pathview/pics/VideoPlayer_48.png b/examples/declarative/modelviews/pathview/pics/VideoPlayer_48.png deleted file mode 100644 index 52638c50a7..0000000000 Binary files a/examples/declarative/modelviews/pathview/pics/VideoPlayer_48.png and /dev/null differ diff --git a/examples/declarative/modelviews/stringlistmodel/main.cpp b/examples/declarative/modelviews/stringlistmodel/main.cpp deleted file mode 100644 index 47d7fdaa8c..0000000000 --- a/examples/declarative/modelviews/stringlistmodel/main.cpp +++ /dev/null @@ -1,77 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the demonstration applications of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include -#include - -#include -#include -#include -#include -#include - - -/* - This example illustrates exposing a QStringList as a - model in QML -*/ - -int main(int argc, char ** argv) -{ - QGuiApplication app(argc, argv); - -//![0] - QStringList dataList; - dataList.append("Item 1"); - dataList.append("Item 2"); - dataList.append("Item 3"); - dataList.append("Item 4"); - - QQuickView view; - QDeclarativeContext *ctxt = view.rootContext(); - ctxt->setContextProperty("myModel", QVariant::fromValue(dataList)); -//![0] - - view.setSource(QUrl("qrc:view.qml")); - view.show(); - - return app.exec(); -} - diff --git a/examples/declarative/modelviews/stringlistmodel/stringlistmodel.pro b/examples/declarative/modelviews/stringlistmodel/stringlistmodel.pro deleted file mode 100644 index 540d8c71f0..0000000000 --- a/examples/declarative/modelviews/stringlistmodel/stringlistmodel.pro +++ /dev/null @@ -1,4 +0,0 @@ -QT += declarative quick - -SOURCES += main.cpp -RESOURCES += stringlistmodel.qrc diff --git a/examples/declarative/modelviews/stringlistmodel/stringlistmodel.qrc b/examples/declarative/modelviews/stringlistmodel/stringlistmodel.qrc deleted file mode 100644 index 17e9301471..0000000000 --- a/examples/declarative/modelviews/stringlistmodel/stringlistmodel.qrc +++ /dev/null @@ -1,5 +0,0 @@ - - - view.qml - - diff --git a/examples/declarative/modelviews/stringlistmodel/view.qml b/examples/declarative/modelviews/stringlistmodel/view.qml deleted file mode 100644 index 945763c295..0000000000 --- a/examples/declarative/modelviews/stringlistmodel/view.qml +++ /dev/null @@ -1,54 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 -//![0] - -ListView { - width: 100; height: 100 - - model: myModel - delegate: Rectangle { - height: 25 - width: 100 - Text { text: modelData } - } -} -//![0] diff --git a/examples/declarative/modelviews/visualdatamodel/dragselection.qml b/examples/declarative/modelviews/visualdatamodel/dragselection.qml deleted file mode 100644 index c3186a5ad8..0000000000 --- a/examples/declarative/modelviews/visualdatamodel/dragselection.qml +++ /dev/null @@ -1,200 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -Item { - id: root - - width: 320 - height: 480 - - property bool dragging: false - - Component { - id: packageDelegate - Package { - id: packageRoot - - MouseArea { - id: visibleContainer - Package.name: "visible" - - width: 64 - height: 64 - enabled: packageRoot.VisualDataModel.inSelected - - drag.target: draggable - - Item { - id: draggable - - width: 64 - height: 64 - - Drag.active: visibleContainer.drag.active - - anchors { horizontalCenter: parent.horizontalCenter; verticalCenter: parent.verticalCenter } - - states: State { - when: visibleContainer.drag.active - AnchorChanges { target: draggable; anchors { horizontalCenter: undefined; verticalCenter: undefined} } - ParentChange { target: selectionView; parent: draggable; x: 0; y: 0 } - PropertyChanges { target: root; dragging: true } - ParentChange { target: draggable; parent: root } - } - } - DropArea { - anchors.fill: parent - onEntered: selectedItems.move(0, visualModel.items.get(packageRoot.VisualDataModel.itemsIndex), selectedItems.count) - } - } - Item { - id: selectionContainer - Package.name: "selection" - - width: 64 - height: 64 - - visible: PathView.onPath - } - Rectangle { - id: content - parent: visibleContainer - - width: 58 - height: 58 - - radius: 8 - - gradient: Gradient { - GradientStop { id: gradientStart; position: 0.0; color: "#8AC953" } - GradientStop { id: gradientEnd; position: 1.0; color: "#8BC953" } - } - - border.width: 2 - border.color: "#007423" - - state: root.dragging && packageRoot.VisualDataModel.inSelected ? "selected" : "visible" - - Text { - anchors.fill: parent - horizontalAlignment: Text.AlignHCenter - verticalAlignment: Text.AlignVCenter - color: "white" - text: modelData - font.pixelSize: 18 - } - - Rectangle { - anchors { right: parent.right; top: parent.top; margins: 3 } - width: 12; height: 12 - color: packageRoot.VisualDataModel.inSelected ? "black" : "white" - radius: 6 - - border.color: "white" - border.width: 2 - - MouseArea { - anchors.fill: parent - onClicked: packageRoot.VisualDataModel.inSelected = !packageRoot.VisualDataModel.inSelected - } - } - - states: [ - State { - name: "selected" - ParentChange { target: content; parent: selectionContainer; x: 3; y: 3 } - PropertyChanges { target: packageRoot; VisualDataModel.inItems: visibleContainer.drag.active } - PropertyChanges { target: gradientStart; color: "#017423" } - PropertyChanges { target: gradientStart; color: "#007423" } - }, State { - name: "visible" - PropertyChanges { target: packageRoot; VisualDataModel.inItems: true } - ParentChange { target: content; parent: visibleContainer; x: 3; y: 3 } - PropertyChanges { target: gradientStart; color: "#8AC953" } - PropertyChanges { target: gradientStart; color: "#8BC953" } - } - ] - transitions: Transition { - PropertyAction { target: packageRoot; properties: "VisualDataModel.inItems" } - ParentAnimation { - target: content - NumberAnimation { target: content; properties: "x,y"; duration: 500 } - } - ColorAnimation { targets: [gradientStart, gradientEnd]; duration: 500 } - } - } - } - } - - VisualDataModel { - id: visualModel - model: 35 - delegate: packageDelegate - - groups: VisualDataGroup { id: selectedItems; name: "selected" } - - Component.onCompleted: parts.selection.filterOnGroup = "selected" - } - - PathView { - id: selectionView - - height: 64 - width: 64 - - model: visualModel.parts.selection - - path: Path { - startX: 0 - startY: 0 - PathLine { x: 64; y: 64 } - } - } - - GridView { - id: itemsView - anchors { fill: parent } - cellWidth: 64 - cellHeight: 64 - model: visualModel.parts.visible - } -} diff --git a/examples/declarative/modelviews/visualdatamodel/slideshow.qml b/examples/declarative/modelviews/visualdatamodel/slideshow.qml deleted file mode 100644 index 040c6be307..0000000000 --- a/examples/declarative/modelviews/visualdatamodel/slideshow.qml +++ /dev/null @@ -1,156 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 -import QtQuick.XmlListModel 2.0 - -Rectangle { - id: root - - property Item displayItem: null - - width: 300; height: 400 - - color: "black" - - VisualDataModel { - id: visualModel - - model: XmlListModel { - source: "http://api.flickr.com/services/feeds/photos_public.gne?format=rss2" - query: "/rss/channel/item" - namespaceDeclarations: "declare namespace media=\"http://search.yahoo.com/mrss/\";" - - XmlRole { name: "imagePath"; query: "media:thumbnail/@url/string()" } - XmlRole { name: "url"; query: "media:content/@url/string()" } - } - - delegate: Item { - id: delegateItem - - width: 76; height: 76 - - Rectangle { - id: image - x: 0; y: 0; width: 76; height: 76 - border.width: 1 - border.color: "white" - color: "black" - - Image { - anchors.fill: parent - anchors.leftMargin: 1 - anchors.topMargin: 1 - - source: imagePath - fillMode: Image.PreserveAspectFit - - } - - MouseArea { - id: clickArea - anchors.fill: parent - - onClicked: root.displayItem = root.displayItem !== delegateItem ? delegateItem : null - } - - states: [ - State { - when: root.displayItem === delegateItem - name: "inDisplay"; - ParentChange { target: image; parent: imageContainer; x: 75; y: 75; width: 150; height: 150 } - PropertyChanges { target: image; z: 2 } - PropertyChanges { target: delegateItem; VisualDataModel.inItems: false } - }, - State { - when: root.displayItem !== delegateItem - name: "inList"; - ParentChange { target: image; parent: delegateItem; x: 2; y: 2; width: 75; height: 75 } - PropertyChanges { target: image; z: 1 } - PropertyChanges { target: delegateItem; VisualDataModel.inItems: true } - } - ] - - transitions: [ - Transition { - from: "inList" - SequentialAnimation { - PropertyAction { target: delegateItem; property: "VisualDataModel.inPersistedItems"; value: true } - ParentAnimation { - target: image; - via: root - NumberAnimation { target: image; properties: "x,y,width,height"; duration: 1000 } - } - } - }, Transition { - from: "inDisplay" - SequentialAnimation { - ParentAnimation { - target: image - NumberAnimation { target: image; properties: "x,y,width,height"; duration: 1000 } - } - PropertyAction { target: delegateItem; property: "VisualDataModel.inPersistedItems"; value: false } - } - } - ] - } - } - } - - - PathView { - id: imagePath - - anchors { left: parent.left; top: imageContainer.bottom; right: parent.right; bottom: parent.bottom } - model: visualModel - - pathItemCount: 7 - path: Path { - startX: -50; startY: 0 - PathQuad { x: 150; y: 50; controlX: 0; controlY: 50 } - PathQuad { x: 350; y: 0; controlX: 300; controlY: 50 } - } - } - - Item { - id: imageContainer - anchors { fill: parent; bottomMargin: 100 } - } -} diff --git a/examples/declarative/modelviews/visualdatamodel/sortedmodel.qml b/examples/declarative/modelviews/visualdatamodel/sortedmodel.qml deleted file mode 100644 index 8d3b0a58e5..0000000000 --- a/examples/declarative/modelviews/visualdatamodel/sortedmodel.qml +++ /dev/null @@ -1,141 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -Rectangle { - width: 480; height: 640 - - Component { - id: numberDelegate - - Text { - id: numberText - anchors { left: parent.left; right: parent.right } - text: number - - horizontalAlignment: Text.AlignHCenter - font.pixelSize: 18 - - Text { - anchors { left: parent.left; baseline: parent.baseline } - text: index - - horizontalAlignment: Text.AlignLeft - font.pixelSize: 12 - } - Text { - anchors { right: parent.right; baseline: parent.baseline } - text: numberText.VisualDataModel.itemsIndex - - horizontalAlignment: Text.AlignRight - font.pixelSize: 12 - } - } - } - - ListView { - anchors { - left: parent.left; top: parent.top; - right: parent.horizontalCenter; bottom: button.top - leftMargin: 2; topMargin: 2; rightMargin: 1; bottomMargin: 2 - } - - model: ListModel { - id: unsortedModel - } - delegate: numberDelegate - } - ListView { - anchors { - left: parent.horizontalCenter; top: parent.top; - right: parent.right; bottom: button.top - leftMargin: 1; topMargin: 2; rightMargin: 2; bottomMargin: 2 - } - model: VisualDataModel { - model: unsortedModel - delegate: numberDelegate - - items.onChanged: { - for (var i = 0; i < inserted.length; ++i) { - for (var j = inserted[i].index; j < inserted[i].index + inserted[i].count; ++j) { - var number = items.get(j).model.number - for (var l = 0, k = 0; l < unsortedModel.count; ++l) { - if (l == inserted[k].index) { - l += inserted[k].count - 1 - ++k - } else if (number < items.get(l).model.number) { - items.move(j, l, 1) - break - } - } - inserted[i].index += 1; - inserted[i].count -= 1; - } - } - } - } - } - - Rectangle { - id: button - - anchors { left: parent.left; right: parent.right; bottom: parent.bottom; margins: 2 } - height: moreText.implicitHeight + 4 - - color: "black" - - Text { - id: moreText - - anchors.fill: parent - text: "More" - color: "white" - font.pixelSize: 18 - horizontalAlignment: Text.AlignHCenter - verticalAlignment: Text.AlignVCenter - } - MouseArea { - anchors.fill: parent - - onClicked: unsortedModel.append({ "number": Math.floor(Math.random() * 100) }) - } - } -} diff --git a/examples/declarative/modelviews/visualdatamodel/visualdatamodel.qmlproject b/examples/declarative/modelviews/visualdatamodel/visualdatamodel.qmlproject deleted file mode 100644 index 2bb4016996..0000000000 --- a/examples/declarative/modelviews/visualdatamodel/visualdatamodel.qmlproject +++ /dev/null @@ -1,14 +0,0 @@ -import QmlProject 1.0 - -Project { - /* Include .qml, .js, and image files from current directory and subdirectories */ - QmlFiles { - directory: "." - } - JavaScriptFiles { - directory: "." - } - ImageFiles { - directory: "." - } -} diff --git a/examples/declarative/modelviews/visualitemmodel/visualitemmodel.qml b/examples/declarative/modelviews/visualitemmodel/visualitemmodel.qml deleted file mode 100644 index 3425150d9a..0000000000 --- a/examples/declarative/modelviews/visualitemmodel/visualitemmodel.qml +++ /dev/null @@ -1,115 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -// This example demonstrates placing items in a view using -// a VisualItemModel - -import QtQuick 2.0 - -Rectangle { - color: "lightgray" - width: 240 - height: 320 - property bool printDestruction: false - - VisualItemModel { - id: itemModel - - Rectangle { - width: view.width; height: view.height - color: "#FFFEF0" - Text { text: "Page 1"; font.bold: true; anchors.centerIn: parent } - - Component.onDestruction: if (printDestruction) print("destroyed 1") - } - Rectangle { - width: view.width; height: view.height - color: "#F0FFF7" - Text { text: "Page 2"; font.bold: true; anchors.centerIn: parent } - - Component.onDestruction: if (printDestruction) print("destroyed 2") - } - Rectangle { - width: view.width; height: view.height - color: "#F4F0FF" - Text { text: "Page 3"; font.bold: true; anchors.centerIn: parent } - - Component.onDestruction: if (printDestruction) print("destroyed 3") - } - } - - ListView { - id: view - anchors { fill: parent; bottomMargin: 30 } - model: itemModel - preferredHighlightBegin: 0; preferredHighlightEnd: 0 - highlightRangeMode: ListView.StrictlyEnforceRange - orientation: ListView.Horizontal - snapMode: ListView.SnapOneItem; flickDeceleration: 2000 - cacheBuffer: 200 - } - - Rectangle { - width: 240; height: 30 - anchors { top: view.bottom; bottom: parent.bottom } - color: "gray" - - Row { - anchors.centerIn: parent - spacing: 20 - - Repeater { - model: itemModel.count - - Rectangle { - width: 5; height: 5 - radius: 3 - color: view.currentIndex == index ? "blue" : "white" - - MouseArea { - width: 20; height: 20 - anchors.centerIn: parent - onClicked: view.currentIndex = index - } - } - } - } - } -} diff --git a/examples/declarative/openglunderqml/main.cpp b/examples/declarative/openglunderqml/main.cpp deleted file mode 100644 index 3b682deaec..0000000000 --- a/examples/declarative/openglunderqml/main.cpp +++ /dev/null @@ -1,60 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the demonstration applications of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include - -#include - -#include "squircle.h" - -int main(int argc, char **argv) -{ - QGuiApplication app(argc, argv); - - qmlRegisterType("QtQuick", 2, 0, "Squircle"); - - QQuickView view; - view.setSource(QUrl("main.qml")); - view.show(); - - return app.exec(); - -} diff --git a/examples/declarative/openglunderqml/main.qml b/examples/declarative/openglunderqml/main.qml deleted file mode 100644 index 1485cbbdb8..0000000000 --- a/examples/declarative/openglunderqml/main.qml +++ /dev/null @@ -1,78 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the demonstration applications of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -Item { - - width: 400 - height: 300 - - Squircle { - SequentialAnimation on t { - NumberAnimation { to: 1; duration: 2500; easing.type: Easing.InQuad } - NumberAnimation { to: 0; duration: 2500; easing.type: Easing.OutQuad } - loops: Animation.Infinite - running: true - } - } - - Rectangle { - color: Qt.rgba(1, 1, 1, 0.8); - radius: 10 - border.width: 1 - border.color: "white" - anchors.fill: label - anchors.margins: -10 - } - - Text { - id: label - color: "black" - wrapMode: Text.WordWrap - text: "The background here is a squircle rendered with raw OpenGL using the 'beforeRender()' signal in QQuickCanvas. This text label and its border is rendered using QML" - anchors.right: parent.right - anchors.left: parent.left - anchors.bottom: parent.bottom - anchors.margins: 20 - } - -} diff --git a/examples/declarative/openglunderqml/openglunderqml.pro b/examples/declarative/openglunderqml/openglunderqml.pro deleted file mode 100644 index 117ad0c33e..0000000000 --- a/examples/declarative/openglunderqml/openglunderqml.pro +++ /dev/null @@ -1,6 +0,0 @@ -QT += declarative quick - -HEADERS += squircle.h -SOURCES += squircle.cpp main.cpp - -OTHER_FILES += main.qml diff --git a/examples/declarative/openglunderqml/squircle.cpp b/examples/declarative/openglunderqml/squircle.cpp deleted file mode 100644 index b56f0baaf6..0000000000 --- a/examples/declarative/openglunderqml/squircle.cpp +++ /dev/null @@ -1,123 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the demonstration applications of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "squircle.h" - -#include -#include -#include - -Squircle::Squircle() - : m_program(0) -{ - setFlag(ItemHasContents); -} - -void Squircle::itemChange(ItemChange change, const ItemChangeData &) -{ - // The ItemSceneChange event is sent when we are first attached to a canvas. - if (change == ItemSceneChange) { - QQuickCanvas *c = canvas(); - - // Connect our the beforeRendering signal to our paint function. - // Since this call is executed on the rendering thread it must be - // a Qt::DirectConnection - connect(c, SIGNAL(beforeRendering()), this, SLOT(paint()), Qt::DirectConnection); - - // If we allow QML to do the clearing, they would clear what we paint - // and nothing would show. - c->setClearBeforeRendering(false); - } -} - - -void Squircle::paint() -{ - if (!m_program) { - m_program = new QOpenGLShaderProgram(); - m_program->addShaderFromSourceCode(QOpenGLShader::Vertex, - "attribute highp vec4 vertices;" - "varying highp vec2 coords;" - "void main() {" - " gl_Position = vertices;" - " coords = vertices.xy;" - "}"); - m_program->addShaderFromSourceCode(QOpenGLShader::Fragment, - "uniform lowp float t;" - "varying highp vec2 coords;" - "void main() {" - " lowp float i = 1. - (pow(coords.x, 4.) + pow(coords.y, 4.));" - " i = smoothstep(t - 0.3, t + 0.3, i);" - " gl_FragColor = vec4(coords / 2. + .5, i, i);" - "}"); - - m_program->bindAttributeLocation("vertices", 0); - m_program->link(); - } - - m_program->bind(); - - m_program->enableAttributeArray(0); - - float values[] = { - -1, -1, - 1, -1, - -1, 1, - 1, 1 - }; - m_program->setAttributeArray(0, GL_FLOAT, values, 2); - m_program->setUniformValue("t", (float) m_t); - - glDisable(GL_DEPTH_TEST); - - glClearColor(0, 0, 0, 1); - glClear(GL_COLOR_BUFFER_BIT); - - glEnable(GL_BLEND); - glBlendFunc(GL_SRC_ALPHA, GL_ONE); - - glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); - - m_program->disableAttributeArray(0); - m_program->release(); -} - - diff --git a/examples/declarative/openglunderqml/squircle.h b/examples/declarative/openglunderqml/squircle.h deleted file mode 100644 index 283131a662..0000000000 --- a/examples/declarative/openglunderqml/squircle.h +++ /dev/null @@ -1,76 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the demonstration applications of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef SQUIRCLE_H -#define SQUIRCLE_H - -#include -#include - -class Squircle : public QQuickItem -{ - Q_OBJECT - - Q_PROPERTY(qreal t READ t WRITE setT NOTIFY tChanged) - -public: - Squircle(); - - qreal t() const { return m_t; } - void setT(qreal t) { m_t = t; emit tChanged(); } - - void itemChange(ItemChange change, const ItemChangeData &); - -signals: - void tChanged(); - -public slots: - void paint(); - -private: - QOpenGLShaderProgram *m_program; - - qreal m_t; - bool m_render_under; - bool m_render_over; -}; - -#endif // SQUIRCLE_H diff --git a/examples/declarative/painteditem/painteditem.pro b/examples/declarative/painteditem/painteditem.pro deleted file mode 100644 index e3afd6b0f0..0000000000 --- a/examples/declarative/painteditem/painteditem.pro +++ /dev/null @@ -1,5 +0,0 @@ -TEMPLATE = subdirs - -SUBDIRS = \ - smile \ - textballoons diff --git a/examples/declarative/painteditem/smile/main.cpp b/examples/declarative/painteditem/smile/main.cpp deleted file mode 100644 index 1e6b42351d..0000000000 --- a/examples/declarative/painteditem/smile/main.cpp +++ /dev/null @@ -1,96 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include -#include -#include -#include -#include -class MyPaintItem : public QQuickPaintedItem -{ - Q_OBJECT - Q_PROPERTY(QString face READ face WRITE setFace NOTIFY faceChanged) -public: - MyPaintItem() - : QQuickPaintedItem() - , m_face(QLatin1String(":-)")) - { - setAntialiasing(true); - } - QString face() const {return m_face;} - void setFace(const QString &face) { - if (m_face != face) { - m_face = face; - emit faceChanged(); - } - } - virtual void paint(QPainter *p) - { - QRectF rect(0, 0, width(), height()); - rect.adjust(10, 10, -10, -10); - p->setPen(QPen(Qt::black, 20)); - p->setBrush(Qt::yellow); - p->drawEllipse(rect); - p->setPen(Qt::black); - p->setFont(QFont(QLatin1String("Times"), qRound(rect.height() / 2))); - p->drawText(rect, Qt::AlignCenter, m_face); - } -signals: - void faceChanged(); -private: - QString m_face; -}; - -int main(int argc, char ** argv) -{ - QGuiApplication app(argc, argv); - - qmlRegisterType("MyModule", 1, 0, "MyPaintItem"); - - QQuickView view; - view.setResizeMode(QQuickView::SizeRootObjectToView); - view.setSource(QUrl::fromLocalFile("smile.qml")); - view.show(); - view.raise(); - - return app.exec(); -} - -#include "main.moc" diff --git a/examples/declarative/painteditem/smile/smile.pro b/examples/declarative/painteditem/smile/smile.pro deleted file mode 100644 index 780d351fe6..0000000000 --- a/examples/declarative/painteditem/smile/smile.pro +++ /dev/null @@ -1,11 +0,0 @@ -TEMPLATE = app -TARGET = painteditem - -QT += declarative quick - -macx: CONFIG -= app_bundle - -SOURCES += main.cpp - -CONFIG += console - diff --git a/examples/declarative/painteditem/smile/smile.qml b/examples/declarative/painteditem/smile/smile.qml deleted file mode 100644 index 33919bc04f..0000000000 --- a/examples/declarative/painteditem/smile/smile.qml +++ /dev/null @@ -1,132 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 -import MyModule 1.0 - -Rectangle { - width: 500 - height: 500 - gradient: Gradient { - GradientStop { position: 0.0; color: "#00249a" } - GradientStop { position: 0.7; color: "#ffd94f" } - GradientStop { position: 1.0; color: "#ffa322" } - } - MyPaintItem { - renderTarget:PaintedItem.Image - clip:true - width:240 - height:240 - anchors.left : parent.left - anchors.top :parent.top - anchors.margins: 10 - smooth: true - MouseArea { - anchors.fill:parent - onClicked: { - if (parent.face == ":-)") - parent.face = ":-("; - else - parent.face = ":-)"; - parent.update() - } - } - } - MyPaintItem { - clip:true - renderTarget:PaintedItem.Image - width:240 - height:240 - anchors.right : parent.right - anchors.top :parent.top - anchors.margins: 10 - smooth: true - MouseArea { - anchors.fill:parent - onClicked: { - if (parent.face == ":-)") - parent.face = ":-("; - else - parent.face = ":-)"; - parent.update() - } - } - } - MyPaintItem { - clip:true - renderTarget:PaintedItem.Image - width:240 - height:240 - anchors.left : parent.left - anchors.bottom :parent.bottom - anchors.margins: 10 - smooth: true - MouseArea { - anchors.fill:parent - onClicked: { - if (parent.face == ":-)") - parent.face = ":-("; - else - parent.face = ":-)"; - parent.update() - } - } - } - MyPaintItem { - clip:true - renderTarget:PaintedItem.Image - width:240 - height:240 - anchors.right : parent.right - anchors.bottom :parent.bottom - anchors.margins: 10 - smooth: true - MouseArea { - anchors.fill:parent - onClicked: { - if (parent.face == ":-)") - parent.face = ":-("; - else - parent.face = ":-)"; - parent.update() - } - } - } -} \ No newline at end of file diff --git a/examples/declarative/painteditem/textballoons/TextBalloonPlugin/plugin.h b/examples/declarative/painteditem/textballoons/TextBalloonPlugin/plugin.h deleted file mode 100644 index 6be8611dfd..0000000000 --- a/examples/declarative/painteditem/textballoons/TextBalloonPlugin/plugin.h +++ /dev/null @@ -1,56 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the demonstration applications of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include - -#include "../textballoon.h" - -class TextBalloonPlugin : public QDeclarativeExtensionPlugin -{ - Q_OBJECT -public: - void registerTypes(const char *uri) - { - qmlRegisterType(uri, 1, 0, "TextBalloon"); - } -}; - -Q_EXPORT_PLUGIN2(qmltextballoonplugin, TextBalloonPlugin); diff --git a/examples/declarative/painteditem/textballoons/TextBalloonPlugin/qmldir b/examples/declarative/painteditem/textballoons/TextBalloonPlugin/qmldir deleted file mode 100644 index e8a08ae9d3..0000000000 --- a/examples/declarative/painteditem/textballoons/TextBalloonPlugin/qmldir +++ /dev/null @@ -1 +0,0 @@ -plugin qmltextballoonplugin diff --git a/examples/declarative/painteditem/textballoons/textballoon.cpp b/examples/declarative/painteditem/textballoons/textballoon.cpp deleted file mode 100644 index d097adfe1b..0000000000 --- a/examples/declarative/painteditem/textballoons/textballoon.cpp +++ /dev/null @@ -1,92 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the demonstration applications of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "textballoon.h" - -//! [0] -TextBalloon::TextBalloon(QQuickItem *parent) - : QQuickPaintedItem(parent) - , rightAligned(false) -{ -} -//! [0] - -//! [1] -void TextBalloon::paint(QPainter *painter) -{ - QBrush brush(QColor("#007430")); - - painter->setBrush(brush); - painter->setPen(Qt::NoPen); - painter->setRenderHint(QPainter::Antialiasing); - - painter->drawRoundedRect(0, 0, boundingRect().width(), boundingRect().height() - 10, 10, 10); - - if (rightAligned) - { - const QPointF points[3] = { - QPointF(boundingRect().width() - 10.0, boundingRect().height() - 10.0), - QPointF(boundingRect().width() - 20.0, boundingRect().height()), - QPointF(boundingRect().width() - 30.0, boundingRect().height() - 10.0), - }; - painter->drawConvexPolygon(points, 3); - } - else - { - const QPointF points[3] = { - QPointF(10.0, boundingRect().height() - 10.0), - QPointF(20.0, boundingRect().height()), - QPointF(30.0, boundingRect().height() - 10.0), - }; - painter->drawConvexPolygon(points, 3); - } -} -//! [1] - -bool TextBalloon::isRightAligned() -{ - return this->rightAligned; -} - -void TextBalloon::setRightAligned(bool rightAligned) -{ - this->rightAligned = rightAligned; -} diff --git a/examples/declarative/painteditem/textballoons/textballoon.h b/examples/declarative/painteditem/textballoons/textballoon.h deleted file mode 100644 index 93ed0a7105..0000000000 --- a/examples/declarative/painteditem/textballoons/textballoon.h +++ /dev/null @@ -1,68 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the demonstration applications of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef TEXTBALLOON_H -#define TEXTBALLOON_H - -#include - -//! [0] -class TextBalloon : public QQuickPaintedItem -{ - Q_OBJECT - Q_PROPERTY(bool rightAligned READ isRightAligned WRITE setRightAligned NOTIFY rightAlignedChanged) - - public: - TextBalloon(QQuickItem *parent = 0); - void paint(QPainter *painter); - - bool isRightAligned(); - void setRightAligned(bool rightAligned); - - private: - bool rightAligned; - - signals: - void rightAlignedChanged(); -}; -//! [0] - -#endif diff --git a/examples/declarative/painteditem/textballoons/textballoons.pro b/examples/declarative/painteditem/textballoons/textballoons.pro deleted file mode 100644 index 453a00336d..0000000000 --- a/examples/declarative/painteditem/textballoons/textballoons.pro +++ /dev/null @@ -1,23 +0,0 @@ -TEMPLATE = lib -CONFIG += qt plugin -QT += declarative quick - -TARGET = qmltextballoonplugin - -HEADERS += TextBalloonPlugin/plugin.h \ - textballoon.h - -SOURCES += textballoon.cpp - -DESTDIR = TextBalloonPlugin - -qdeclarativesources.files += \ - TextBalloonPlugin/qmldir - -qdeclarativesources.path += $$[QT_INSTALL_EXAMPLES]/qtdeclarative/declarative/painteditem/textballoons/TextBalloonPlugin - -sources.files = textballoons.qml -sources.path += $$[QT_INSTALL_EXAMPLES]/qtdeclarative/declarative/painteditem/textballoons -target.path += $$[QT_INSTALL_EXAMPLES]/qtdeclarative/declarative/painteditem/textballoons/TextBalloonPlugin - -INSTALLS = qdeclarativesources sources target diff --git a/examples/declarative/painteditem/textballoons/textballoons.qml b/examples/declarative/painteditem/textballoons/textballoons.qml deleted file mode 100644 index b00ce2bfed..0000000000 --- a/examples/declarative/painteditem/textballoons/textballoons.qml +++ /dev/null @@ -1,110 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the demonstration applications of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 -import TextBalloonPlugin 1.0 - -Item { - height: 480 - width: 640 - - //! [0] - ListModel { - id: balloonModel - ListElement { - balloonWidth: 200 - } - ListElement { - balloonWidth: 350 - } - } - - ListView { - anchors.bottom: controls.top - anchors.bottomMargin: 2 - anchors.top: parent.top - id: balloonView - delegate: TextBalloon { - anchors.right: index % 2 == 0 ? undefined : parent.right - height: 60 - rightAligned: index % 2 == 0 ? false : true - width: balloonWidth - } - model: balloonModel - spacing: 5 - width: parent.width - } - //! [0] - - //! [1] - Rectangle { - id: controls - - anchors.bottom: parent.bottom - anchors.left: parent.left - anchors.margins: 1 - anchors.right: parent.right - border.width: 2 - color: "white" - height: parent.height * 0.15 - - Text { - anchors.centerIn: parent - text: "Add another balloon" - } - - MouseArea { - anchors.fill: parent - hoverEnabled: true - onClicked: { - balloonModel.append({"balloonWidth": Math.floor(Math.random() * 300 + 100)}) - balloonView.positionViewAtIndex(balloonView.count -1, ListView.End) - } - onEntered: { - parent.color = "#8ac953" - } - onExited: { - parent.color = "white" - } - } - } - //! [1] -} diff --git a/examples/declarative/particles/affectors/age.qml b/examples/declarative/particles/affectors/age.qml deleted file mode 100644 index 1e7774b63b..0000000000 --- a/examples/declarative/particles/affectors/age.qml +++ /dev/null @@ -1,97 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 -import QtQuick.Particles 2.0 - -Rectangle { - id: root - width: 360 - height: 600 - color: "white" - - ParticleSystem { id: particles } - - ImageParticle { - system: particles - sprites: Sprite { - name: "snow" - source: "../images/snowflake.png" - frames: 51 - frameDuration: 40 - frameDurationVariation: 8 - } - } - - Emitter { - system: particles - emitRate: 20 - lifeSpan: 8000 - speed: PointDirection { y:80; yVariation: 40; } - acceleration: PointDirection { y: 4 } - size: 36 - endSize: 12 - sizeVariation: 8 - width: parent.width - height: 100 - } - - MouseArea { - id: ma - anchors.fill: parent - hoverEnabled: true - } - - Rectangle { - color: "#803333AA" - border.color: "black" - x: ma.mouseX - 36 - y: ma.mouseY - 36 - width: 72 - height: 72 - Age { - anchors.fill: parent - system: particles - once: true - lifeLeft: 1200 - advancePosition: false - } - } -} diff --git a/examples/declarative/particles/affectors/attractor.qml b/examples/declarative/particles/affectors/attractor.qml deleted file mode 100644 index 460a497a92..0000000000 --- a/examples/declarative/particles/affectors/attractor.qml +++ /dev/null @@ -1,213 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 -import QtQuick.Particles 2.0 - -Rectangle { - id: root - width: 360 - height: 540 - color: "black" - property bool spacePressed: false - focus: true - Image { - source: "../images/finalfrontier.png" - anchors.centerIn:parent - } - Keys.onPressed: { - if (event.key == Qt.Key_Space) { - spacePressed = true; - event.accepted = true; - } - } - Keys.onReleased: { - if (event.key == Qt.Key_Space) { - spacePressed = false; - event.accepted = true; - } - } - - Emitter { - group: "stars" - system: particles - emitRate: 40 - lifeSpan: 4000 - enabled: true - size: 30 - sizeVariation: 10 - speed: PointDirection { x: 220; xVariation: 40 } - height: parent.height - } - Emitter { - group: "roids" - system: particles - emitRate: 10 - lifeSpan: 4000 - enabled: true - size: 30 - sizeVariation: 10 - speed: PointDirection { x: 220; xVariation: 40 } - height: parent.height - } - ParticleSystem { - id: particles - anchors.fill: parent - } - ImageParticle { - id: stars - groups: ["stars"] - system: particles - source: "../images/star.png" - color: "white" - colorVariation: 0.1 - alpha: 0 - } - ImageParticle { - id: roids - groups: ["roids"] - system: particles - sprites: Sprite { - id: spinState - name: "spinning" - source: "../images/meteor.png" - frames: 35 - frameDuration: 60 - } - } - ImageParticle { - id: shot - groups: ["shot"] - system: particles - source: "../images/star.png" - - color: "#0FF06600" - colorVariation: 0.3 - } - ImageParticle { - id: engine - groups: ["engine"] - system: particles - source: "../images/particle4.png" - - color: "orange" - SequentialAnimation on color { - loops: Animation.Infinite - ColorAnimation { - from: "red" - to: "cyan" - duration: 1000 - } - ColorAnimation { - from: "cyan" - to: "red" - duration: 1000 - } - } - - colorVariation: 0.2 - } - Attractor { - id: gs; pointX: root.width/2; pointY: root.height/2; strength: 4000000; - system: particles - affectedParameter: Attractor.Acceleration - proportionalToDistance: Attractor.InverseQuadratic - } - Age { - system: particles - x: gs.pointX - 8; - y: gs.pointY - 8; - width: 16 - height: 16 - } - Rectangle { - color: "black" - width: 8 - height: 8 - radius: 4 - x: gs.pointX - 4 - y: gs.pointY - 4 - } - - Image { - source:"../images/rocket2.png" - id: ship - width: 45 - height: 22 - MouseArea { - id: ma - anchors.fill: parent; - drag.axis: Drag.XandYAxis - drag.target: ship - } - } - Emitter { - group: "engine" - system: particles - emitRate: 200 - lifeSpan: 1000 - size: 10 - endSize: 4 - sizeVariation: 4 - speed: PointDirection { x: -128; xVariation: 32 } - height: ship.height - y: ship.y - x: ship.x - width: 20 - } - Emitter { - group: "shot" - system: particles - emitRate: 32 - lifeSpan: 2000 - enabled: spacePressed - size: 40 - speed: PointDirection { x: 256; } - x: ship.x + ship.width - y: ship.y + ship.height/2 - } - - Text { - color: "white" - anchors.bottom: parent.bottom - text:"Drag the ship, Spacebar to fire." - } -} - diff --git a/examples/declarative/particles/affectors/customaffector.qml b/examples/declarative/particles/affectors/customaffector.qml deleted file mode 100644 index 3f98cd5b43..0000000000 --- a/examples/declarative/particles/affectors/customaffector.qml +++ /dev/null @@ -1,173 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 -import QtQuick.Particles 2.0 - -Item { - width: 360 - height: 600 - - Image { - source: "../images/backgroundLeaves.jpg" - anchors.fill: parent - } - ParticleSystem { - id: sys - } - Emitter { - system: sys - width: parent.width - emitRate: 4 - lifeSpan: 14000 - size: 80 - speed: PointDirection { y: 60 } - } - Wander { - system: sys - anchors.fill: parent - anchors.bottomMargin: 100 - xVariance: 60 - pace: 60 - } - - Affector { - system: sys - property real coefficient: 0.1 - property real speed: 1.5 - width: parent.width - height: parent.height - 100 - onAffectParticles: { - /* //Linear movement - if (particle.r == 0) { - particle.r = Math.random() > 0.5 ? -1 : 1; - }else if (particle.r == 1) { - particle.rotation += speed * dt; - if(particle.rotation >= maxAngle) - particle.r = -1; - }else if (particle.r == -1) { - particle.rotation -= speed * dt; - if(particle.rotation <= -1 * maxAngle) - particle.r = 1; - } - */ - //Wobbly movement - for (var i=0; i 1.) - currentSize = 0.; - - highp vec2 pos = qt_ParticlePos - - currentSize / 2. + currentSize * qt_ParticleTex // adjust size - + qt_ParticleVec.xy * t * qt_ParticleData.y // apply speed vector.. - + 0.5 * qt_ParticleVec.zw * pow(t * qt_ParticleData.y, 2.); - - gl_Position = qt_Matrix * vec4(pos.x, pos.y, 0, 1); - - highp float fadeIn = min(t * 20., 1.); - highp float fadeOut = 1. - max(0., min((t - 0.75) * 4., 1.)); - - fFade = fadeIn * fadeOut * qt_Opacity; - fPos = vec2(pos.x/1024., pos.y/768.); - } - " - fragmentShader: " - varying highp vec2 fPos; - varying lowp float fFade; - varying highp vec2 qt_TexCoord0; - void main() {//*2 because this generates dark colors mostly - highp vec2 circlePos = qt_TexCoord0*2.0 - vec2(1.0,1.0); - highp float dist = length(circlePos); - highp float circleFactor = max(min(1.0 - dist, 1.0), 0.0); - gl_FragColor = vec4(fPos.x*2.0 - fPos.y, fPos.y*2.0 - fPos.x, fPos.x*fPos.y*2.0, 0.0) * circleFactor * fFade; - }" - - } -} diff --git a/examples/declarative/particles/customparticle/imagecolors.qml b/examples/declarative/particles/customparticle/imagecolors.qml deleted file mode 100644 index 94e5123a0c..0000000000 --- a/examples/declarative/particles/customparticle/imagecolors.qml +++ /dev/null @@ -1,118 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 -import QtQuick.Particles 2.0 - -Rectangle { - width: 400 - height: 400 - Rectangle { - id: root - color: "white" - width: 310 - height: 300 - anchors.centerIn: parent - ParticleSystem { id: sys } - CustomParticle { - system: sys - property real maxWidth: root.width - property real maxHeight: root.height - ShaderEffectSource { - id: pictureSource - sourceItem: picture - hideSource: true - } - Image { - id: picture - source: "../images/starfish_3.png" - } - ShaderEffectSource { - id: particleSource - sourceItem: particle - hideSource: true - } - Image { - id: particle - source: "../images/particle4.png" - } - vertexShader:" - uniform highp float maxWidth; - uniform highp float maxHeight; - varying highp vec2 fTex2; - varying lowp float fFade; - uniform lowp float qt_Opacity; - - void main() { - fTex2 = vec2(qt_ParticlePos.x / maxWidth, qt_ParticlePos.y / maxHeight); - highp float t = (qt_Timestamp - qt_ParticleData.x) / qt_ParticleData.y; - fFade = min(t*4., (1.-t*t)*.75) * qt_Opacity; - defaultMain(); - } - " - property variant particleTexture: particleSource - property variant pictureTexture: pictureSource - fragmentShader: " - uniform sampler2D particleTexture; - uniform sampler2D pictureTexture; - varying highp vec2 qt_TexCoord0; - varying highp vec2 fTex2; - varying lowp float fFade; - void main() { - gl_FragColor = texture2D(pictureTexture, fTex2) * texture2D(particleTexture, qt_TexCoord0).w * fFade; - }" - } - - Emitter { - id: emitter - system: sys - enabled: false - lifeSpan: 8000 - maximumEmitted: 4000 - anchors.fill: parent - size: 16 - acceleration: PointDirection { xVariation: 12; yVariation: 12 } - } - MouseArea { - anchors.fill: parent - onClicked: emitter.burst(4000); - } - } -} diff --git a/examples/declarative/particles/emitters/burstandpulse.qml b/examples/declarative/particles/emitters/burstandpulse.qml deleted file mode 100644 index 1b1c2a60c9..0000000000 --- a/examples/declarative/particles/emitters/burstandpulse.qml +++ /dev/null @@ -1,84 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 -import QtQuick.Particles 2.0 - -Rectangle { - width: 360 - height: 540 - color: "black" - MouseArea { - id: ma - anchors.fill: parent - acceptedButtons: Qt.LeftButton | Qt.RightButton - onClicked: { - if (mouse.button == Qt.LeftButton) - emitter.burst(1000); - else - emitter.pulse(500); - } - } - - ParticleSystem { - id: particles - } - - ImageParticle { - anchors.fill: parent - system: particles - source: "../images/star.png" - alpha: 0 - colorVariation: 0.6 - } - - Emitter { - id: emitter - x: ma.mouseX - y: ma.mouseY - system: particles - emitRate: 2000 - lifeSpan: 2000 - enabled: false - speed: AngleDirection{magnitude: 64; angleVariation: 360} - size: 24 - sizeVariation: 8 - } -} diff --git a/examples/declarative/particles/emitters/customemitter.qml b/examples/declarative/particles/emitters/customemitter.qml deleted file mode 100644 index 757c836106..0000000000 --- a/examples/declarative/particles/emitters/customemitter.qml +++ /dev/null @@ -1,92 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 -import QtQuick.Particles 2.0 - -ParticleSystem { - id: sys - width: 360 - height: 600 - running: true - Rectangle { - z: -1 - anchors.fill: parent - color: "black" - } - - property real petalLength: 180 - property real petalRotation: 0 - NumberAnimation on petalRotation { - from: 0; - to: 360; - loops: -1; - running: true - duration: 24000 - } - - function convert(a) {return a*(Math.PI/180);} - Emitter { - lifeSpan: 4000 - emitRate: 120 - size: 12 - anchors.centerIn: parent - onEmitParticles: { - for (var i=0; i 400 ? 32 : 16 - } -} diff --git a/examples/declarative/particles/imageparticle/colored.qml b/examples/declarative/particles/imageparticle/colored.qml deleted file mode 100644 index ac760b6219..0000000000 --- a/examples/declarative/particles/imageparticle/colored.qml +++ /dev/null @@ -1,86 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 -import QtQuick.Particles 2.0 - -Rectangle { - width: 360 - height: 540 - color: "black" - ParticleSystem { - anchors.fill: parent - ImageParticle { - groups: ["stars"] - anchors.fill: parent - source: "../images/star.png" - } - Emitter { - group: "stars" - emitRate: 800 - lifeSpan: 2400 - size: 24 - sizeVariation: 8 - anchors.fill: parent - } - - ImageParticle { - anchors.fill: parent - source: "../images/star.png" - alpha: 0 - alphaVariation: 0.2 - colorVariation: 1.0 - } - - Emitter { - anchors.centerIn: parent - emitRate: 400 - lifeSpan: 2400 - size: 48 - sizeVariation: 8 - speed: AngleDirection {angleVariation: 180; magnitude: 60} - } - - Turbulence { - anchors.fill: parent - strength: 2 - } - } -} diff --git a/examples/declarative/particles/imageparticle/colortable.qml b/examples/declarative/particles/imageparticle/colortable.qml deleted file mode 100644 index 623029dae0..0000000000 --- a/examples/declarative/particles/imageparticle/colortable.qml +++ /dev/null @@ -1,84 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick.Particles 2.0 -import QtQuick 2.0 - -Rectangle { - id: root - width: 360 - height: 540 - color: "black" - - ParticleSystem { id: particles } - - ImageParticle { - system: particles - colorVariation: 0.5 - alpha: 0 - - source: "../images/particle.png" - colorTable: "../images/colortable.png" - sizeTable: "../images/colortable.png" - } - - Emitter { - system: particles - emitRate: 500 - lifeSpan: 2000 - - y: root.height / 2 + Math.sin(t * 2) * root.height * 0.3 - x: root.width / 2 + Math.cos(t) * root.width * 0.3 - property real t; - - NumberAnimation on t { - from: 0; to: Math.PI * 2; duration: 10000; loops: Animation.Infinite - } - - speedFromMovement: 20 - - speed: PointDirection { xVariation: 5; yVariation: 5;} - acceleration: PointDirection { xVariation: 5; yVariation: 5;} - - size: 16 - //endSize: 8 - //sizeVariation: 8 - } -} diff --git a/examples/declarative/particles/imageparticle/deformation.qml b/examples/declarative/particles/imageparticle/deformation.qml deleted file mode 100644 index e282927e78..0000000000 --- a/examples/declarative/particles/imageparticle/deformation.qml +++ /dev/null @@ -1,121 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 -import QtQuick.Particles 2.0 - -Rectangle { - color: "goldenrod" - width: 400 - height: 400 - ParticleSystem {id:sys} - - ImageParticle { - system: sys - groups: ["goingLeft", "goingRight"] - source: "../images/starfish_4.png" - rotation: 90 - rotationSpeed: 90 - autoRotation: true - } - ImageParticle { - system: sys - groups: ["goingDown"] - source: "../images/starfish_0.png" - rotation: 180 - yVector: PointDirection { y: 0.5; yVariation: 0.25; xVariation: 0.25; } - } - - Timer { - running: true - repeat: false - interval: 100 - onTriggered: emitA.enabled = true; - } - Timer { - running: true - repeat: false - interval: 4200 - onTriggered: emitB.enabled = true; - } - Timer { - running: true - repeat: false - interval: 8400 - onTriggered: emitC.enabled = true; - } - - Emitter { - id: emitA - x: 0 - y: 120 - system: sys - enabled: false - group: "goingRight" - speed: PointDirection { x: 100 } - lifeSpan: 4000 - emitRate: 1 - size: 128 - } - Emitter { - id: emitB - x: 400 - y: 240 - system: sys - enabled: false - group: "goingLeft" - speed: PointDirection { x: -100 } - lifeSpan: 4000 - emitRate: 1 - size: 128 - } - Emitter { - id: emitC - x: 0 - y: 360 - system: sys - enabled: false - group: "goingDown" - speed: PointDirection { x: 100 } - lifeSpan: 4000 - emitRate: 1 - size: 128 - } -} diff --git a/examples/declarative/particles/imageparticle/rotation.qml b/examples/declarative/particles/imageparticle/rotation.qml deleted file mode 100644 index 3a75c379ed..0000000000 --- a/examples/declarative/particles/imageparticle/rotation.qml +++ /dev/null @@ -1,71 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 -import QtQuick.Particles 2.0 - -Rectangle { - color: "goldenrod" - width: 2000 - height: 2000 - ParticleSystem {id: sys} - ImageParticle { - id: up - system: sys - source: "../images/starfish_2.png" - } - - Emitter { - anchors.centerIn: parent - system: sys - emitRate: 10 - size: 200 - lifeSpan: 10000 - speed: AngleDirection {angleVariation: 360; magnitudeVariation: 100;} - } - - MouseArea { - anchors.fill: parent - onClicked: { - up.autoRotation = !up.autoRotation - up.rotation = up.autoRotation ? -90 : 0 - } - } -} diff --git a/examples/declarative/particles/imageparticle/sharing.qml b/examples/declarative/particles/imageparticle/sharing.qml deleted file mode 100644 index 27e08322d9..0000000000 --- a/examples/declarative/particles/imageparticle/sharing.qml +++ /dev/null @@ -1,199 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -// This example shows how to create your own highlight delegate for a ListView -// that uses a SpringAnimation to provide custom movement when the -// highlight bar is moved between items. - -import QtQuick 2.0 -import QtQuick.Particles 2.0 - -Rectangle { - property real delegateHeight: 65 - width: 200; height: 300 - gradient: Gradient { - GradientStop { position: 0.0; color: "#EEEEFF" } - GradientStop { position: 1.0; color: "lightblue" } - } - - // Define a delegate component. A component will be - // instantiated for each visible item in the list. - Component { - id: petDelegate - Item { - id: wrapper - width: 200; height: delegateHeight - z: 10 - Column { - Text {color: "white"; text: name; font.pixelSize: 18 } - Text {color: "white"; text: 'Type: ' + type; font.pixelSize: 14 } - Text {color: "white"; text: 'Age: ' + age; font.pixelSize: 14 } - } - // indent the item if it is the current item - states: State { - name: "Current" - when: wrapper.ListView.isCurrentItem - PropertyChanges { target: wrapper; x: 20 } - } - transitions: Transition { - NumberAnimation { properties: "x"; duration: 200 } - } - } - } - - // Define a highlight with customised movement between items. - Component { - id: highlightBar - Rectangle { - z: 0 - width: 200; height: delegateHeight - gradient: Gradient { - GradientStop { position: 0.0; color: "#99FF99" } - GradientStop { position: 1.0; color: "#88FF88" } - } - y: listView.currentItem.y; - Behavior on y { SpringAnimation { spring: 2; damping: 0.2 } } - ImageParticle { - anchors.fill: parent - system: particles - source: "../images/flower.png" - color: "red" - clip: true - alpha: 1.0 - } - } - } - - ListView { - id: listView - width: 200; height: parent.height - - model: petsModel - delegate: petDelegate - focus: true - - // Set the highlight delegate. Note we must also set highlightFollowsCurrentItem - // to false so the highlight delegate can control how the highlight is moved. - highlight: highlightBar - highlightFollowsCurrentItem: false - - ParticleSystem { id: particles } - Emitter { - system: particles - anchors.fill: parent - emitRate: 1 - lifeSpan: 10000 - size: 24 - sizeVariation: 8 - speed: AngleDirection { angleVariation: 360; magnitude: 3 } - maximumEmitted: 10 - startTime: 5000 - } - - ImageParticle { - anchors.fill: parent - system: particles - source: "../images/flower.png" - alpha: 0.1 - color: "white" - rotationVariation: 180 - z: -1 - } - } - - ListModel { - id: petsModel - ListElement { - name: "Polly" - type: "Parrot" - age: 12 - size: "Small" - } - ListElement { - name: "Penny" - type: "Turtle" - age: 4 - size: "Small" - } - ListElement { - name: "Warren" - type: "Rabbit" - age: 2 - size: "Small" - } - ListElement { - name: "Spot" - type: "Dog" - age: 9 - size: "Medium" - } - ListElement { - name: "Schrödinger" - type: "Cat" - age: 2 - size: "Medium" - } - ListElement { - name: "Joey" - type: "Kangaroo" - age: 1 - size: "Medium" - } - ListElement { - name: "Kimba" - type: "Bunny" - age: 65 - size: "Large" - } - ListElement { - name: "Rover" - type: "Dog" - age: 5 - size: "Large" - } - ListElement { - name: "Tiny" - type: "Elephant" - age: 15 - size: "Large" - } - } - -} diff --git a/examples/declarative/particles/imageparticle/sprites.qml b/examples/declarative/particles/imageparticle/sprites.qml deleted file mode 100644 index 0fe4f31ea3..0000000000 --- a/examples/declarative/particles/imageparticle/sprites.qml +++ /dev/null @@ -1,116 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 -import QtQuick.Particles 2.0 - -Rectangle { - color: "lightsteelblue" - width: 800 - height: 800 - id: root - - SpriteImage { - sprites: Sprite { - name: "bear" - source: "../images/bear_tiles.png" - frames: 13 - frameDuration: 120 - } - width: 250 - height: 250 - x: 20 - anchors.bottom: parent.bottom - anchors.bottomMargin: 20 - z:4 - } - - ParticleSystem { id: sys } - - ImageParticle { - anchors.fill: parent - id: particles - system: sys - sprites: [Sprite { - name: "happy" - source: "../images/starfish_1.png" - frames: 1 - frameDuration: 260 - to: {"happy": 1, "silly": 1, "angry": 1} - }, Sprite { - name: "angry" - source: "../images/starfish_0.png" - frames: 1 - frameDuration: 260 - to: {"happy": 1, "silly": 1, "angry": 1} - }, Sprite { - name: "silly" - source: "../images/starfish_2.png" - frames: 1 - frameDuration: 260 - to: {"happy": 1, "silly": 1, "noticedbear": 0} - }, Sprite { - name: "noticedbear" - source: "../images/starfish_3.png" - frames: 1 - frameDuration: 2600 - }] - } - - Emitter { - system: sys - emitRate: 2 - lifeSpan: 10000 - speed: AngleDirection {angle: 90; magnitude: 60; angleVariation: 5} - acceleration: PointDirection { y: 10 } - size: 160 - sizeVariation: 40 - width: parent.width - height: 100 - } - - SpriteGoal { - system: sys - width: root.width; - height: root.height/2; - y: root.height/2; - goalState:"noticedbear" - } -} diff --git a/examples/declarative/particles/images/_explo.png b/examples/declarative/particles/images/_explo.png deleted file mode 100644 index 4297245d49..0000000000 Binary files a/examples/declarative/particles/images/_explo.png and /dev/null differ diff --git a/examples/declarative/particles/images/backgroundLeaves.jpg b/examples/declarative/particles/images/backgroundLeaves.jpg deleted file mode 100755 index 08be16751d..0000000000 Binary files a/examples/declarative/particles/images/backgroundLeaves.jpg and /dev/null differ diff --git a/examples/declarative/particles/images/bear_tiles.png b/examples/declarative/particles/images/bear_tiles.png deleted file mode 100644 index 6bbb2a9b6d..0000000000 Binary files a/examples/declarative/particles/images/bear_tiles.png and /dev/null differ diff --git a/examples/declarative/particles/images/candle.png b/examples/declarative/particles/images/candle.png deleted file mode 100644 index 8fa3193719..0000000000 Binary files a/examples/declarative/particles/images/candle.png and /dev/null differ diff --git a/examples/declarative/particles/images/colortable.png b/examples/declarative/particles/images/colortable.png deleted file mode 100644 index a62ceeb4a0..0000000000 Binary files a/examples/declarative/particles/images/colortable.png and /dev/null differ diff --git a/examples/declarative/particles/images/finalfrontier.png b/examples/declarative/particles/images/finalfrontier.png deleted file mode 100644 index 2ba1815230..0000000000 Binary files a/examples/declarative/particles/images/finalfrontier.png and /dev/null differ diff --git a/examples/declarative/particles/images/flower.png b/examples/declarative/particles/images/flower.png deleted file mode 100644 index b5c606210e..0000000000 Binary files a/examples/declarative/particles/images/flower.png and /dev/null differ diff --git a/examples/declarative/particles/images/launcherIcons/allatonce.png b/examples/declarative/particles/images/launcherIcons/allatonce.png deleted file mode 100644 index b61d2d50d8..0000000000 Binary files a/examples/declarative/particles/images/launcherIcons/allatonce.png and /dev/null differ diff --git a/examples/declarative/particles/images/launcherIcons/attractor.png b/examples/declarative/particles/images/launcherIcons/attractor.png deleted file mode 100644 index 4bd8040c3b..0000000000 Binary files a/examples/declarative/particles/images/launcherIcons/attractor.png and /dev/null differ diff --git a/examples/declarative/particles/images/launcherIcons/blurparticles.png b/examples/declarative/particles/images/launcherIcons/blurparticles.png deleted file mode 100644 index 4337f979cb..0000000000 Binary files a/examples/declarative/particles/images/launcherIcons/blurparticles.png and /dev/null differ diff --git a/examples/declarative/particles/images/launcherIcons/close.png b/examples/declarative/particles/images/launcherIcons/close.png deleted file mode 100644 index c37714ee8f..0000000000 Binary files a/examples/declarative/particles/images/launcherIcons/close.png and /dev/null differ diff --git a/examples/declarative/particles/images/launcherIcons/colortable.png b/examples/declarative/particles/images/launcherIcons/colortable.png deleted file mode 100644 index 8841ea30f9..0000000000 Binary files a/examples/declarative/particles/images/launcherIcons/colortable.png and /dev/null differ diff --git a/examples/declarative/particles/images/launcherIcons/customaffector.png b/examples/declarative/particles/images/launcherIcons/customaffector.png deleted file mode 100644 index d02e7918fa..0000000000 Binary files a/examples/declarative/particles/images/launcherIcons/customaffector.png and /dev/null differ diff --git a/examples/declarative/particles/images/launcherIcons/customemitter.png b/examples/declarative/particles/images/launcherIcons/customemitter.png deleted file mode 100644 index 6d492573d1..0000000000 Binary files a/examples/declarative/particles/images/launcherIcons/customemitter.png and /dev/null differ diff --git a/examples/declarative/particles/images/launcherIcons/deformation.png b/examples/declarative/particles/images/launcherIcons/deformation.png deleted file mode 100644 index d1b722df01..0000000000 Binary files a/examples/declarative/particles/images/launcherIcons/deformation.png and /dev/null differ diff --git a/examples/declarative/particles/images/launcherIcons/delegates.png b/examples/declarative/particles/images/launcherIcons/delegates.png deleted file mode 100644 index 929414cd0e..0000000000 Binary files a/examples/declarative/particles/images/launcherIcons/delegates.png and /dev/null differ diff --git a/examples/declarative/particles/images/launcherIcons/dynamicemitters.png b/examples/declarative/particles/images/launcherIcons/dynamicemitters.png deleted file mode 100644 index 0cdef9d21e..0000000000 Binary files a/examples/declarative/particles/images/launcherIcons/dynamicemitters.png and /dev/null differ diff --git a/examples/declarative/particles/images/launcherIcons/emitmask.png b/examples/declarative/particles/images/launcherIcons/emitmask.png deleted file mode 100644 index e943a4adb9..0000000000 Binary files a/examples/declarative/particles/images/launcherIcons/emitmask.png and /dev/null differ diff --git a/examples/declarative/particles/images/launcherIcons/flickr.png b/examples/declarative/particles/images/launcherIcons/flickr.png deleted file mode 100644 index 4de2650280..0000000000 Binary files a/examples/declarative/particles/images/launcherIcons/flickr.png and /dev/null differ diff --git a/examples/declarative/particles/images/launcherIcons/fragmentshader.png b/examples/declarative/particles/images/launcherIcons/fragmentshader.png deleted file mode 100644 index 7c6de498d5..0000000000 Binary files a/examples/declarative/particles/images/launcherIcons/fragmentshader.png and /dev/null differ diff --git a/examples/declarative/particles/images/launcherIcons/gridsplosion.png b/examples/declarative/particles/images/launcherIcons/gridsplosion.png deleted file mode 100644 index ec75453df6..0000000000 Binary files a/examples/declarative/particles/images/launcherIcons/gridsplosion.png and /dev/null differ diff --git a/examples/declarative/particles/images/launcherIcons/groupgoal.png b/examples/declarative/particles/images/launcherIcons/groupgoal.png deleted file mode 100644 index 69c6f64e54..0000000000 Binary files a/examples/declarative/particles/images/launcherIcons/groupgoal.png and /dev/null differ diff --git a/examples/declarative/particles/images/launcherIcons/imagecolors.png b/examples/declarative/particles/images/launcherIcons/imagecolors.png deleted file mode 100644 index 0ff13a346e..0000000000 Binary files a/examples/declarative/particles/images/launcherIcons/imagecolors.png and /dev/null differ diff --git a/examples/declarative/particles/images/launcherIcons/list.png b/examples/declarative/particles/images/launcherIcons/list.png deleted file mode 100644 index bc13263cff..0000000000 Binary files a/examples/declarative/particles/images/launcherIcons/list.png and /dev/null differ diff --git a/examples/declarative/particles/images/launcherIcons/maximumemitted.png b/examples/declarative/particles/images/launcherIcons/maximumemitted.png deleted file mode 100644 index 4ef0435991..0000000000 Binary files a/examples/declarative/particles/images/launcherIcons/maximumemitted.png and /dev/null differ diff --git a/examples/declarative/particles/images/launcherIcons/multiplepainters.png b/examples/declarative/particles/images/launcherIcons/multiplepainters.png deleted file mode 100644 index a28e3c4f02..0000000000 Binary files a/examples/declarative/particles/images/launcherIcons/multiplepainters.png and /dev/null differ diff --git a/examples/declarative/particles/images/launcherIcons/package.png b/examples/declarative/particles/images/launcherIcons/package.png deleted file mode 100644 index eba8951c26..0000000000 Binary files a/examples/declarative/particles/images/launcherIcons/package.png and /dev/null differ diff --git a/examples/declarative/particles/images/launcherIcons/particleview.png b/examples/declarative/particles/images/launcherIcons/particleview.png deleted file mode 100644 index a74f9a0340..0000000000 Binary files a/examples/declarative/particles/images/launcherIcons/particleview.png and /dev/null differ diff --git a/examples/declarative/particles/images/launcherIcons/plasmapatrol.png b/examples/declarative/particles/images/launcherIcons/plasmapatrol.png deleted file mode 100644 index fda852b420..0000000000 Binary files a/examples/declarative/particles/images/launcherIcons/plasmapatrol.png and /dev/null differ diff --git a/examples/declarative/particles/images/launcherIcons/remove.png b/examples/declarative/particles/images/launcherIcons/remove.png deleted file mode 100644 index c37714ee8f..0000000000 Binary files a/examples/declarative/particles/images/launcherIcons/remove.png and /dev/null differ diff --git a/examples/declarative/particles/images/launcherIcons/rotation.png b/examples/declarative/particles/images/launcherIcons/rotation.png deleted file mode 100644 index 6a8dbea236..0000000000 Binary files a/examples/declarative/particles/images/launcherIcons/rotation.png and /dev/null differ diff --git a/examples/declarative/particles/images/launcherIcons/samegame.png b/examples/declarative/particles/images/launcherIcons/samegame.png deleted file mode 100644 index d00698264b..0000000000 Binary files a/examples/declarative/particles/images/launcherIcons/samegame.png and /dev/null differ diff --git a/examples/declarative/particles/images/launcherIcons/shapeanddirection.png b/examples/declarative/particles/images/launcherIcons/shapeanddirection.png deleted file mode 100644 index 9c1f910d0c..0000000000 Binary files a/examples/declarative/particles/images/launcherIcons/shapeanddirection.png and /dev/null differ diff --git a/examples/declarative/particles/images/launcherIcons/spaceexplorer.png b/examples/declarative/particles/images/launcherIcons/spaceexplorer.png deleted file mode 100644 index 770584a0fa..0000000000 Binary files a/examples/declarative/particles/images/launcherIcons/spaceexplorer.png and /dev/null differ diff --git a/examples/declarative/particles/images/launcherIcons/spritegoal.png b/examples/declarative/particles/images/launcherIcons/spritegoal.png deleted file mode 100644 index 77480c6f09..0000000000 Binary files a/examples/declarative/particles/images/launcherIcons/spritegoal.png and /dev/null differ diff --git a/examples/declarative/particles/images/launcherIcons/sprites.png b/examples/declarative/particles/images/launcherIcons/sprites.png deleted file mode 100644 index 144216ac7c..0000000000 Binary files a/examples/declarative/particles/images/launcherIcons/sprites.png and /dev/null differ diff --git a/examples/declarative/particles/images/launcherIcons/spritevariedparticles.png b/examples/declarative/particles/images/launcherIcons/spritevariedparticles.png deleted file mode 100644 index 495bb6beee..0000000000 Binary files a/examples/declarative/particles/images/launcherIcons/spritevariedparticles.png and /dev/null differ diff --git a/examples/declarative/particles/images/launcherIcons/startstop.png b/examples/declarative/particles/images/launcherIcons/startstop.png deleted file mode 100644 index 0ff53196a6..0000000000 Binary files a/examples/declarative/particles/images/launcherIcons/startstop.png and /dev/null differ diff --git a/examples/declarative/particles/images/launcherIcons/timedgroupchanges.png b/examples/declarative/particles/images/launcherIcons/timedgroupchanges.png deleted file mode 100644 index ec9f826495..0000000000 Binary files a/examples/declarative/particles/images/launcherIcons/timedgroupchanges.png and /dev/null differ diff --git a/examples/declarative/particles/images/launcherIcons/trailemitter.png b/examples/declarative/particles/images/launcherIcons/trailemitter.png deleted file mode 100644 index 39acf8b40d..0000000000 Binary files a/examples/declarative/particles/images/launcherIcons/trailemitter.png and /dev/null differ diff --git a/examples/declarative/particles/images/launcherIcons/trails.png b/examples/declarative/particles/images/launcherIcons/trails.png deleted file mode 100644 index 0337ebcfd8..0000000000 Binary files a/examples/declarative/particles/images/launcherIcons/trails.png and /dev/null differ diff --git a/examples/declarative/particles/images/launcherIcons/turbulence.png b/examples/declarative/particles/images/launcherIcons/turbulence.png deleted file mode 100644 index 2b9446ea90..0000000000 Binary files a/examples/declarative/particles/images/launcherIcons/turbulence.png and /dev/null differ diff --git a/examples/declarative/particles/images/launcherIcons/velocityfrommotion.png b/examples/declarative/particles/images/launcherIcons/velocityfrommotion.png deleted file mode 100644 index 79baa08293..0000000000 Binary files a/examples/declarative/particles/images/launcherIcons/velocityfrommotion.png and /dev/null differ diff --git a/examples/declarative/particles/images/launcherIcons/wander.png b/examples/declarative/particles/images/launcherIcons/wander.png deleted file mode 100644 index d98e14b8ae..0000000000 Binary files a/examples/declarative/particles/images/launcherIcons/wander.png and /dev/null differ diff --git a/examples/declarative/particles/images/matchmask.png b/examples/declarative/particles/images/matchmask.png deleted file mode 100644 index e575875c55..0000000000 Binary files a/examples/declarative/particles/images/matchmask.png and /dev/null differ diff --git a/examples/declarative/particles/images/meteor.png b/examples/declarative/particles/images/meteor.png deleted file mode 100644 index e8c368aea7..0000000000 Binary files a/examples/declarative/particles/images/meteor.png and /dev/null differ diff --git a/examples/declarative/particles/images/meteor_explo.png b/examples/declarative/particles/images/meteor_explo.png deleted file mode 100644 index e659bfe2cf..0000000000 Binary files a/examples/declarative/particles/images/meteor_explo.png and /dev/null differ diff --git a/examples/declarative/particles/images/meteors.png b/examples/declarative/particles/images/meteors.png deleted file mode 100644 index bada8a1407..0000000000 Binary files a/examples/declarative/particles/images/meteors.png and /dev/null differ diff --git a/examples/declarative/particles/images/nullRock.png b/examples/declarative/particles/images/nullRock.png deleted file mode 100644 index 4076327a1a..0000000000 Binary files a/examples/declarative/particles/images/nullRock.png and /dev/null differ diff --git a/examples/declarative/particles/images/particle.png b/examples/declarative/particles/images/particle.png deleted file mode 100644 index 5c83896d22..0000000000 Binary files a/examples/declarative/particles/images/particle.png and /dev/null differ diff --git a/examples/declarative/particles/images/particle2.png b/examples/declarative/particles/images/particle2.png deleted file mode 100644 index 36349c6c6e..0000000000 Binary files a/examples/declarative/particles/images/particle2.png and /dev/null differ diff --git a/examples/declarative/particles/images/particle3.png b/examples/declarative/particles/images/particle3.png deleted file mode 100644 index 905d8f37b8..0000000000 Binary files a/examples/declarative/particles/images/particle3.png and /dev/null differ diff --git a/examples/declarative/particles/images/particle4.png b/examples/declarative/particles/images/particle4.png deleted file mode 100644 index bc95b703c1..0000000000 Binary files a/examples/declarative/particles/images/particle4.png and /dev/null differ diff --git a/examples/declarative/particles/images/particleA.png b/examples/declarative/particles/images/particleA.png deleted file mode 100644 index c63acdee1f..0000000000 Binary files a/examples/declarative/particles/images/particleA.png and /dev/null differ diff --git a/examples/declarative/particles/images/portal_bg.png b/examples/declarative/particles/images/portal_bg.png deleted file mode 100644 index 3c59eeabb9..0000000000 Binary files a/examples/declarative/particles/images/portal_bg.png and /dev/null differ diff --git a/examples/declarative/particles/images/realLeaf1.png b/examples/declarative/particles/images/realLeaf1.png deleted file mode 100644 index 6cabf29efd..0000000000 Binary files a/examples/declarative/particles/images/realLeaf1.png and /dev/null differ diff --git a/examples/declarative/particles/images/realLeaf2.png b/examples/declarative/particles/images/realLeaf2.png deleted file mode 100644 index bfeca861d5..0000000000 Binary files a/examples/declarative/particles/images/realLeaf2.png and /dev/null differ diff --git a/examples/declarative/particles/images/realLeaf3.png b/examples/declarative/particles/images/realLeaf3.png deleted file mode 100644 index b1071e862b..0000000000 Binary files a/examples/declarative/particles/images/realLeaf3.png and /dev/null differ diff --git a/examples/declarative/particles/images/realLeaf4.png b/examples/declarative/particles/images/realLeaf4.png deleted file mode 100644 index d61d53d10e..0000000000 Binary files a/examples/declarative/particles/images/realLeaf4.png and /dev/null differ diff --git a/examples/declarative/particles/images/rocket.png b/examples/declarative/particles/images/rocket.png deleted file mode 100644 index a171610b03..0000000000 Binary files a/examples/declarative/particles/images/rocket.png and /dev/null differ diff --git a/examples/declarative/particles/images/rocket2.png b/examples/declarative/particles/images/rocket2.png deleted file mode 100644 index 7110f8fdc6..0000000000 Binary files a/examples/declarative/particles/images/rocket2.png and /dev/null differ diff --git a/examples/declarative/particles/images/sizeInOut.png b/examples/declarative/particles/images/sizeInOut.png deleted file mode 100644 index 0a306ea21a..0000000000 Binary files a/examples/declarative/particles/images/sizeInOut.png and /dev/null differ diff --git a/examples/declarative/particles/images/snowflake.png b/examples/declarative/particles/images/snowflake.png deleted file mode 100644 index 490887a82f..0000000000 Binary files a/examples/declarative/particles/images/snowflake.png and /dev/null differ diff --git a/examples/declarative/particles/images/sparkleSize.png b/examples/declarative/particles/images/sparkleSize.png deleted file mode 100644 index 752056541b..0000000000 Binary files a/examples/declarative/particles/images/sparkleSize.png and /dev/null differ diff --git a/examples/declarative/particles/images/star.png b/examples/declarative/particles/images/star.png deleted file mode 100644 index 0d592cfa87..0000000000 Binary files a/examples/declarative/particles/images/star.png and /dev/null differ diff --git a/examples/declarative/particles/images/starfish_0.png b/examples/declarative/particles/images/starfish_0.png deleted file mode 100644 index 8747f0236e..0000000000 Binary files a/examples/declarative/particles/images/starfish_0.png and /dev/null differ diff --git a/examples/declarative/particles/images/starfish_1.png b/examples/declarative/particles/images/starfish_1.png deleted file mode 100644 index 1f3f159d5e..0000000000 Binary files a/examples/declarative/particles/images/starfish_1.png and /dev/null differ diff --git a/examples/declarative/particles/images/starfish_2.png b/examples/declarative/particles/images/starfish_2.png deleted file mode 100644 index c6c7e5a676..0000000000 Binary files a/examples/declarative/particles/images/starfish_2.png and /dev/null differ diff --git a/examples/declarative/particles/images/starfish_3.png b/examples/declarative/particles/images/starfish_3.png deleted file mode 100644 index 307a89f815..0000000000 Binary files a/examples/declarative/particles/images/starfish_3.png and /dev/null differ diff --git a/examples/declarative/particles/images/starfish_4.png b/examples/declarative/particles/images/starfish_4.png deleted file mode 100644 index d61c26545a..0000000000 Binary files a/examples/declarative/particles/images/starfish_4.png and /dev/null differ diff --git a/examples/declarative/particles/images/starfish_mask.png b/examples/declarative/particles/images/starfish_mask.png deleted file mode 100644 index 2ef74f902b..0000000000 Binary files a/examples/declarative/particles/images/starfish_mask.png and /dev/null differ diff --git a/examples/declarative/particles/itemparticle/content/Delegate.qml b/examples/declarative/particles/itemparticle/content/Delegate.qml deleted file mode 100644 index 97c7840cb4..0000000000 --- a/examples/declarative/particles/itemparticle/content/Delegate.qml +++ /dev/null @@ -1,88 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -//![0] -Package { - Text { id: listDelegate; width: 200; height: 25; text: 'Empty'; Package.name: 'list' } - Text { id: gridDelegate; width: 100; height: 50; text: 'Empty'; Package.name: 'grid' } - - Rectangle { - id: wrapper - width: 200; height: 25 - color: 'lightsteelblue' - - Text { text: display; anchors.centerIn: parent } - MouseArea { - anchors.fill: parent - onClicked: { - if (wrapper.state == 'inList') - wrapper.state = 'inGrid'; - else - wrapper.state = 'inList'; - } - } - - state: 'inList' - states: [ - State { - name: 'inList' - ParentChange { target: wrapper; parent: listDelegate } - }, - State { - name: 'inGrid' - ParentChange { - target: wrapper; parent: gridDelegate - x: 0; y: 0; width: gridDelegate.width; height: gridDelegate.height - } - } - ] - - transitions: [ - Transition { - ParentAnimation { - NumberAnimation { properties: 'x,y,width,height'; duration: 300 } - } - } - ] - } -} -//![0] diff --git a/examples/declarative/particles/itemparticle/content/Delegate2.qml b/examples/declarative/particles/itemparticle/content/Delegate2.qml deleted file mode 100644 index cf60d43dc2..0000000000 --- a/examples/declarative/particles/itemparticle/content/Delegate2.qml +++ /dev/null @@ -1,79 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -//![0] -Package { - Item { id: gridDelegate; width: w; height: h; Package.name: 'grid' } - Item { id: particleDelegate; width: w; height: h; Package.name: 'particles' - - Rectangle { - id: wrapper - width: w; height: h; - color: col - rotation: Math.random()*360 - Behavior on rotation {RotationAnimation {}} - - states: State { - name: "gridded" - when: root.inGrid - PropertyChanges { - target: wrapper - rotation: 0 - } - ParentChange { - target: wrapper - parent: gridDelegate - x:0 - y:0 - } - } - transitions: [ - Transition { - ParentAnimation { - NumberAnimation { properties: 'x,y,width,height'; duration: 300 } - } - } - ] - } - } -} -//![0] diff --git a/examples/declarative/particles/itemparticle/content/ExpandingDelegate.qml b/examples/declarative/particles/itemparticle/content/ExpandingDelegate.qml deleted file mode 100644 index 87f723d3f7..0000000000 --- a/examples/declarative/particles/itemparticle/content/ExpandingDelegate.qml +++ /dev/null @@ -1,204 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 -import "../../../modelviews/listview/content" - -// This example illustrates expanding a list item to show a more detailed view. - - // Delegate for the recipes. This delegate has two modes: - // 1. List mode (default), which just shows the picture and title of the recipe. - // 2. Details mode, which also shows the ingredients and method. - Component { - id: recipeDelegate - - Item { - id: recipe - - // Create a property to contain the visibility of the details. - // We can bind multiple element's opacity to this one property, - // rather than having a "PropertyChanges" line for each element we - // want to fade. - property real detailsOpacity : 0 - - //this bit changed for aesthetics - width: 70 - height: 70 - // A simple rounded rectangle for the background - Rectangle { - id: background - x: 2; y: 2; width: parent.width - x*2; height: parent.height - y*2 - color: "ivory" - border.color: "orange" - radius: 5 - } - Image { - anchors.fill:parent - anchors.margins: -32 - source: "bubble.png" - } - - - // This mouse region covers the entire delegate. - // When clicked it changes mode to 'Details'. If we are already - // in Details mode, then no change will happen. - MouseArea { - anchors.fill: parent - onClicked: recipe.state = 'Details'; - } - - // Lay out the page: picture, title and ingredients at the top, and method at the - // bottom. Note that elements that should not be visible in the list - // mode have their opacity set to recipe.detailsOpacity. - Row { - id: topLayout - x: 10; y: 10; height: recipeImage.height; width: parent.width - spacing: 10 - - Image { - id: recipeImage - width: 50; height: 50 - source: "../../modelviews/listview/" + picture - } - - Column { - width: background.width - recipeImage.width - 20; height: recipeImage.height - spacing: 5 - - Text { - text: title - font.bold: true; font.pointSize: 16 - } - - Text { - text: "Ingredients" - font.pointSize: 12; font.bold: true - opacity: recipe.detailsOpacity - } - - Text { - text: ingredients - wrapMode: Text.WordWrap - width: parent.width - opacity: recipe.detailsOpacity - } - } - } - - Item { - id: details - x: 10; width: parent.width - 20 - anchors { top: topLayout.bottom; topMargin: 10; bottom: parent.bottom; bottomMargin: 10 } - opacity: recipe.detailsOpacity - - Text { - id: methodTitle - anchors.top: parent.top - text: "Method" - font.pointSize: 12; font.bold: true - } - - Flickable { - id: flick - width: parent.width - anchors { top: methodTitle.bottom; bottom: parent.bottom } - contentHeight: methodText.height - clip: true - - Text { id: methodText; text: method; wrapMode: Text.WordWrap; width: details.width } - } - - Image { - anchors { right: flick.right; top: flick.top } - source: "../../modelviews/listview/" + "content/pics/moreUp.png" - opacity: flick.atYBeginning ? 0 : 1 - } - - Image { - anchors { right: flick.right; bottom: flick.bottom } - source: "../../modelviews/listview/" + "content/pics/moreDown.png" - opacity: flick.atYEnd ? 0 : 1 - } - } - - // A button to close the detailed view, i.e. set the state back to default (''). - TextButton { - y: 10 - anchors { right: background.right; rightMargin: 10 } - opacity: recipe.detailsOpacity - text: "Close" - - onClicked: recipe.state = ''; - } - - states: State { - name: "Details" - - PropertyChanges { target: background; color: "white" } - PropertyChanges { target: recipeImage; width: 130; height: 130 } // Make picture bigger - PropertyChanges { target: recipe; detailsOpacity: 1; x: 0; opacity: 1 } // Make details visible - PropertyChanges { target: recipe; height: root.height; width: root.height; x:0; y:0; z:100} // Fill the entire list area with the detailed view - - // Move the list so that this item is at the top. - //PropertyChanges { target: recipe.ListView.view; explicit: true; contentY: recipe.y } - - // Disallow flicking while we're in detailed view - //PropertyChanges { target: recipe.ListView.view; interactive: false } - } - - transitions: Transition { - //The only strictly necessary particle specific lines - to: "Details" - reversible: true - ScriptAction {script: { - if(state == "Details") - mp.freeze(index); - else - mp.unfreeze(index); - } - } - // Make the state changes smooth - ParallelAnimation { - ColorAnimation { property: "color"; duration: 500 } - NumberAnimation { duration: 300; properties: "detailsOpacity,opacity,x,y,height,width" } - } - } - } - } diff --git a/examples/declarative/particles/itemparticle/content/RssModel.qml b/examples/declarative/particles/itemparticle/content/RssModel.qml deleted file mode 100644 index 46027600b3..0000000000 --- a/examples/declarative/particles/itemparticle/content/RssModel.qml +++ /dev/null @@ -1,56 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 -import QtQuick.XmlListModel 2.0 - -XmlListModel { - property string tags : "" - - function encodeTags(x) { return encodeURIComponent(x.replace(' ',',')); } - - source: "http://api.flickr.com/services/feeds/photos_public.gne?"+(tags ? "tags="+encodeTags(tags)+"&" : "") - query: "/feed/entry" - namespaceDeclarations: "declare default element namespace 'http://www.w3.org/2005/Atom';" - - XmlRole { name: "title"; query: "title/string()" } - XmlRole { name: "content"; query: "content/string()" } - XmlRole { name: "hq"; query: "link[@rel='enclosure']/@href/string()" } -} diff --git a/examples/declarative/particles/itemparticle/content/bubble.png b/examples/declarative/particles/itemparticle/content/bubble.png deleted file mode 100644 index c7f479e9e3..0000000000 Binary files a/examples/declarative/particles/itemparticle/content/bubble.png and /dev/null differ diff --git a/examples/declarative/particles/itemparticle/content/script.js b/examples/declarative/particles/itemparticle/content/script.js deleted file mode 100644 index e8ef93a847..0000000000 --- a/examples/declarative/particles/itemparticle/content/script.js +++ /dev/null @@ -1,27 +0,0 @@ -.pragma library - -function getWidth(string) { - return (string.match(/width=\"([0-9]+)\"/))[1] -} - -function getHeight(string) { - return (string.match(/height=\"([0-9]+)\"/))[1] -} - -function getImagePath(string) { - var pattern = /src=\"http:\/\/(\S+)\"/ - return (string.match(pattern))[1] -} - -function calculateScale(width, height, cellSize) { - var widthScale = (cellSize * 1.0) / width - var heightScale = (cellSize * 1.0) / height - var scale = 0 - - if (widthScale <= heightScale) { - scale = widthScale; - } else if (heightScale < widthScale) { - scale = heightScale; - } - return scale; -} diff --git a/examples/declarative/particles/itemparticle/delegates.qml b/examples/declarative/particles/itemparticle/delegates.qml deleted file mode 100644 index 58734d320a..0000000000 --- a/examples/declarative/particles/itemparticle/delegates.qml +++ /dev/null @@ -1,91 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 -import QtQuick.Particles 2.0 - -Rectangle { - id: root; - width: 360 - height: 600 - color: "black" - - function newPithySaying() { - switch (Math.floor(Math.random()*16)) { - case 0: return "Hello World"; - case 1: return "G'day Mate"; - case 2: return "Code Less"; - case 3: return "Create More"; - case 4: return "Deploy Everywhere"; - case 5: return "Qt Meta-object Language"; - case 6: return "Qt Magic Language"; - case 7: return "Fluid UIs"; - case 8: return "Touchable"; - case 9: return "How's it going?"; - case 10: return "Do you like text?"; - case 11: return "Enjoy!"; - case 12: return "ERROR: Out of pith"; - case 13: return "Punctuation Failure"; - case 14: return "I can go faster"; - case 15: return "I can go slower"; - default: return "OMGWTFBBQ"; - } - } - - ParticleSystem { - anchors.fill: parent - id: syssy - Emitter { - anchors.centerIn: parent - emitRate: 1 - lifeSpan: 4800 - lifeSpanVariation: 1600 - speed: AngleDirection {angleVariation: 360; magnitude: 40; magnitudeVariation: 20} - } - ItemParticle { - delegate: Text { - text: root.newPithySaying(); - color: "white" - font.pixelSize: 18 - font.bold: true - } - } - } -} diff --git a/examples/declarative/particles/itemparticle/particleview.qml b/examples/declarative/particles/itemparticle/particleview.qml deleted file mode 100644 index 774539a958..0000000000 --- a/examples/declarative/particles/itemparticle/particleview.qml +++ /dev/null @@ -1,274 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 -import QtQuick.Particles 2.0 -import "content/script.js" as Script -import "content" - -Item { - id: root - width: 640 - height: 480 - Rectangle { - anchors.fill: parent - color: "black" - z: -1 - } - Item { - id: loading - Behavior on opacity {NumberAnimation {}} - anchors.fill: parent - Text { - anchors.centerIn: parent - text: "Loading" - color: "white" - } - } - ParticleSystem { - id: sys; - running: true - } - Emitter { - id: emitter - system: sys - height: parent.height - 132/2 - x: -132/2 - y: 132/2 - speed: PointDirection { x: 32; xVariation: 8 } - emitRate: 0.5 - lifeSpan: Emitter.InfiniteLife - group: "photos" - } - Age { - system: sys - x: parent.width + 132/2 - height: parent.height - width: 1000 - } - ImageParticle { - system: sys - groups: ["fireworks"] - source: "../trails/../images/star.png" - color: "lightsteelblue" - alpha: 0 - colorVariation: 0 - z: 1000 - } - ItemParticle { - id: mp - z: 0 - system: sys - fade: false - groups: ["photos"] - } - Component { - id: alertDelegate - Rectangle { - width: 132 - height: 132 - NumberAnimation on scale { - running: true - loops: 1 - from: 0.2 - to: 1 - } - Image { - source: "../asteroid/../images/rocket.png" - anchors.centerIn: parent - } - Text { - anchors.bottom: parent.bottom - anchors.horizontalCenter: parent.horizontalCenter - text: "A new ship has arrived!" - } - } - } - property Item alertItem; - function alert() { - //resetter.active = false - force.active = true; - alertItem = alertDelegate.createObject(root); - alertItem.x = root.width/2 - alertItem.width/2 - alertItem.y = root.height/2 - alertItem.height/2 - spawnFireworks.pulse(200); - stopAlert.start(); - } - focus: true - Keys.onSpacePressed: alert(); - Timer { - id: stopAlert - running: false - repeat: false - interval: 800 - onTriggered: { - force.active = false - //resetter.active = true; - mp.take(alertItem, true); - centerEmitter.burst(1); - } - } - Attractor { - id: force - system: sys - pointX: root.width/2 - pointY: root.height/2 - strength: -10000 - enabled: false - anchors.centerIn: parent - width: parent.width/2 - height: parent.height/2 - groups:["photos"] - affectedParameter: Attractor.Position - } - Emitter { - id: centerEmitter - speed: PointDirection { x: 32; xVariation: 8;} - emitRate: 0.5 - lifeSpan: 12000 //TODO: A -1 or something which does 'infinite'? (but need disable fade first) - maximumEmitted: 20 - group: "photos" - system: sys - anchors.centerIn: parent - enabled: false - - //TODO: Zoom in effect - } - Emitter { - id: spawnFireworks - group: "fireworks" - system: sys - maximumEmitted: 400 - emitRate: 400 - lifeSpan: 2800 - x: parent.width/2 - y: parent.height/2 - 64 - width: 8 - height: 8 - enabled: false - size: 32 - endSize: 8 - speed: AngleDirection { magnitude: 160; magnitudeVariation: 120; angleVariation: 90; angle: 270 } - acceleration: PointDirection { y: 160 } - } - Item { x: -1000; y: -1000 //offscreen - Repeater {//Load them here, add to system on completed - model: theModel - delegate: theDelegate - } - } - RssModel {id: theModel; tags:"particle,particles"} - Component { - id: theDelegate - Rectangle { - id: container - border.width: 2 - property real myRand: Math.random();//'depth' - z: Math.floor(myRand * 100) - scale: (myRand + 1.0)/2; - //TODO: Darken based on 'depth' - width: 132 - height: 132 - //ItemParticle.onAttached: console.log("I'm in" + x + "," + y + ":" + opacity); - ItemParticle.onDetached: mp.take(container);//respawns - function manage() - { - if (state == "selected") { - console.log("Taking " + index); - mp.freeze(container); - } else { - console.log("Returning " +index); - mp.unfreeze(container); - } - } - Image { - id: img - anchors.centerIn: parent - smooth: true; source: "http://" + Script.getImagePath(content); cache: true - fillMode: Image.PreserveAspectFit; - width: parent.width-4; height: parent.height-4 - onStatusChanged: if (img.status == Image.Ready) { - loading.opacity = 0; - mp.take(container); - } - } - Text { - anchors.bottom: parent.bottom - width: parent.width - horizontalAlignment: Text.AlignHCenter - elide: Text.ElideRight - text: title - color: "black" - } - MouseArea { - anchors.fill: parent - onClicked: container.state == "selected" ? container.state = "" : container.state = "selected" - } - states: State { - name: "selected" - ParentChange { - target: container - parent: root - x: 0 - y: 0 - } - PropertyChanges { - target: container - width: root.width - height: root.height - z: 101 - opacity: 1 - rotation: 0 - } - } - transitions: Transition { - to: "selected" - reversible: true - SequentialAnimation { - ScriptAction {script: container.manage();} - ParallelAnimation { - ParentAnimation {NumberAnimation { properties: "x,y" }}//Doesn't work, particles takes control of x,y instantly - NumberAnimation { properties: "width, height, z, rotation" } - } - } - } - } - } -} diff --git a/examples/declarative/particles/plasmapatrol/PlasmaPatrol.qmlproject b/examples/declarative/particles/plasmapatrol/PlasmaPatrol.qmlproject deleted file mode 100644 index 548295243d..0000000000 --- a/examples/declarative/particles/plasmapatrol/PlasmaPatrol.qmlproject +++ /dev/null @@ -1,19 +0,0 @@ -import QmlProject 1.1 - -Project { - mainFile: "plasmapatrol.qml" - - /* Include .qml, .js, and image files from current directory and subdirectories */ - QmlFiles { - directory: "." - } - JavaScriptFiles { - directory: "." - } - ImageFiles { - directory: "." - } - Files { - paths: ["TODO"] - } -} diff --git a/examples/declarative/particles/plasmapatrol/TODO b/examples/declarative/particles/plasmapatrol/TODO deleted file mode 100644 index ef9d21a73d..0000000000 --- a/examples/declarative/particles/plasmapatrol/TODO +++ /dev/null @@ -1,10 +0,0 @@ -Realistic Tasks: -Particle explosions on ship death. -Better help text (both content and styled a little nicer). -Hardpoint help showing them firing across the screen. -Endless Demo Mode - -Nice-but-i-doubt-it-will-get-done Tasks: -Particle Text for the winner. -Particle-based buttons. -Single player mode that is challenges (known opponents) to master the game with and earn achievements (in addition to 'skirmish'). diff --git a/examples/declarative/particles/plasmapatrol/content/BlasterHardpoint.qml b/examples/declarative/particles/plasmapatrol/content/BlasterHardpoint.qml deleted file mode 100644 index 4ac30d0202..0000000000 --- a/examples/declarative/particles/plasmapatrol/content/BlasterHardpoint.qml +++ /dev/null @@ -1,133 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -import QtQuick 2.0 -import QtQuick.Particles 2.0 - -Item { - id: container - property variant target: {"y": -90, "x":12} - property Item targetObj: container - property Item hardpoint: container - property ParticleSystem system - property int blasts: 16 - property int bonusBlasts: 12 - property bool show: true - - width: 24 - height: 24 - Emitter { - id: visualization - group: "blaster" - system: container.system - enabled: show - anchors.fill: parent - shape: EllipseShape {} - speed: TargetDirection { targetX: width/2; targetY: width/2; magnitude: -1; proportionalMagnitude: true} - lifeSpan: 1000 - emitRate: 64 - - size: 24 - sizeVariation: 24 - endSize: 0 - } - - property int blastsLeft: 0 - function fireAt(targetArg, container) { - target = container.mapFromItem(targetArg, targetArg.width/2, targetArg.height/2); - targetObj = targetArg; - hardpoint = container; - blastsLeft = blasts; - rofTimer.repeat = true; - rofTimer.start(); - } - Timer { - id: rofTimer - interval: 30;//Has to be greater than 1 frame or they stack up - running: false - repeat: false - onTriggered: { - if (targetObj.hp <= 0) - return; - //TODO: calculate hit and damage at target, which must be a Ship - var hit; - if (blastsLeft >= bonusBlasts) - hit = Math.random() > targetObj.dodge; - else - hit = false; //purely aesthetic shots, because the damage isn't that fine grained - if (hit == true) { - switch (targetObj.shipType) { - case 1: hardpoint.damageDealt += 4; break; - case 2: hardpoint.damageDealt += 5; break; - case 3: hardpoint.damageDealt += 1; break; - default: hardpoint.damageDealt += 100; - } - } - blastVector.targetX = target.x; - blastVector.targetY = target.y; - if (!hit) {//TODO: Actual targetVariation - blastVector.targetX += (128 * Math.random() - 64); - blastVector.targetY += (128 * Math.random() - 64); - } - emitter.burst(1); - blastsLeft--; - if (!blastsLeft) - rofTimer.repeat = false; - } - } - Emitter { - id: emitter - group: "blaster" - enabled: false - system: container.system - anchors.centerIn: parent - - lifeSpan: 1000 - emitRate: 16 - maximumEmitted: blasts - size: 24 - endSize:16 - sizeVariation: 8 - speed: TargetDirection { - id: blastVector - targetX: target.x; targetY: target.y; magnitude: 1.1; proportionalMagnitude: true - } - } -} diff --git a/examples/declarative/particles/plasmapatrol/content/Button.qml b/examples/declarative/particles/plasmapatrol/content/Button.qml deleted file mode 100644 index 405b99304f..0000000000 --- a/examples/declarative/particles/plasmapatrol/content/Button.qml +++ /dev/null @@ -1,66 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -import QtQuick 2.0 - -//TODO: Add particles to this component too -Rectangle { - id: container - property alias text: txt.text - signal clicked - //color: "lightsteelblue" - gradient: Gradient { - GradientStop { position: 0.0; color: "lightsteelblue" } - GradientStop { position: 1.0; color: "steelblue" } - } - height: 64 - radius: 16 - width: 128 - Text { - id: txt - anchors.centerIn: parent - font.pixelSize: 24 - color: "white" - } - MouseArea { - anchors.fill: parent - onClicked: container.clicked() - } -} diff --git a/examples/declarative/particles/plasmapatrol/content/CannonHardpoint.qml b/examples/declarative/particles/plasmapatrol/content/CannonHardpoint.qml deleted file mode 100644 index c4aa412760..0000000000 --- a/examples/declarative/particles/plasmapatrol/content/CannonHardpoint.qml +++ /dev/null @@ -1,97 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -import QtQuick 2.0 -import QtQuick.Particles 2.0 - -Item { - id: container - property variant target: {"y": -90, "x":12} - property ParticleSystem system - property bool show: true - - width: 24 - height: 24 - Emitter { - id: visualization - group: "cannon" - enabled: container.show - system: container.system - anchors.centerIn: parent - lifeSpan: 2000 - emitRate: 1 - - size: 4 - endSize: 0 - } - - function fireAt(targetArg, hardpoint) { - target = container.mapFromItem(targetArg, targetArg.width/2, targetArg.height/2); - if (container.hp <= 0 || targetArg.hp <= 0) - return; - //TODO: calculate hit and damage at target, which must be a Ship - var hit = Math.random() > targetArg.dodge - if (hit) { - switch (targetArg.shipType) { - case 1: hardpoint.damageDealt += 8; break; - case 2: hardpoint.damageDealt += 10; break; - case 3: hardpoint.damageDealt += 16; break; - default: hardpoint.damageDealt += 1000; - } - } - emitter.burst(1); - } - Emitter { - id: emitter - group: "cannon" - enabled: false - system: container.system - anchors.centerIn: parent - - lifeSpan: 1000 - emitRate: 1 - size: 8 - endSize: 4 - speed: TargetDirection { - id: blastVector - targetX: target.x; targetY: target.y; magnitude: 1.1; proportionalMagnitude: true - } - } -} diff --git a/examples/declarative/particles/plasmapatrol/content/ChoiceBox.qml b/examples/declarative/particles/plasmapatrol/content/ChoiceBox.qml deleted file mode 100644 index a678bc9dd4..0000000000 --- a/examples/declarative/particles/plasmapatrol/content/ChoiceBox.qml +++ /dev/null @@ -1,105 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -import QtQuick 2.0 -import QtQuick.Particles 2.0 - -Item { - id: container - width: 360 - height: 160 - property ParticleSystem system - Ship { - id: nully - system: system - } - property Item target: nully - /* - Component.onCompleted: { - container.target.shipType = 1 - container.target.gunType = 1 - } - */ - Row { - anchors.horizontalCenter: parent.horizontalCenter - height: parent.height - spacing: 8 - Button { - width: 80 - height: 80 - anchors.verticalCenter: parent.verticalCenter - text: "Cycle\nShip" - onClicked: { - var nextVal = container.target.shipType; - if(nextVal == 3) - nextVal = 1; - else - nextVal++; - container.target.shipType = nextVal; - } - } - Item { - width: 128 - height: 128 - anchors.verticalCenter: parent.verticalCenter - Ship { - hp: 20 - anchors.centerIn: parent - shipType: container.target.shipType - gunType: container.target.gunType - system: container.system - } - } - Button { - width: 80 - height: 80 - anchors.verticalCenter: parent.verticalCenter - text: "Cycle\nGun" - onClicked: { - var nextVal = container.target.gunType; - if(nextVal == 3) - nextVal = 1; - else - nextVal++; - container.target.gunType = nextVal; - } - } - } -} diff --git a/examples/declarative/particles/plasmapatrol/content/Cruiser.qml b/examples/declarative/particles/plasmapatrol/content/Cruiser.qml deleted file mode 100644 index c689879dce..0000000000 --- a/examples/declarative/particles/plasmapatrol/content/Cruiser.qml +++ /dev/null @@ -1,146 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -import QtQuick 2.0 -import QtQuick.Particles 2.0 - -Item { - id: container - property int maxHP: 100 - property int hp: maxHP - property real initialDodge: 0.01 - property real dodge: initialDodge - onHpChanged: if(hp <= 0) target = container; - property ParticleSystem system//TODO: Ship abstraction - property Item target: container - property string shipParticle: "default"//Per team colors? - property int gunType: 0 - width: 128 - height: 128 - Emitter { - //TODO: Cooler would be an 'orbiting' affector - //TODO: On the subject, opacity and size should be grouped type 'overLife' if we can cram that in the particles - system: container.system - group: container.shipParticle - anchors.centerIn: parent - width: 64 - height: 64 - shape: EllipseShape {} - - emitRate: hp > 0 ? hp * 1 + 20 : 0 - lifeSpan: 2400 - maximumEmitted: (maxHP * 1 + 20)*2.4 - - size: 48 - sizeVariation: 16 - endSize: 16 - - speed: AngleDirection {angleVariation:360; magnitudeVariation: 32} - } - Emitter { - system: container.system - group: "cruiserArmor" - anchors.fill: parent - shape: EllipseShape { fill: false } - enabled: hp>0 - - emitRate: 16 - lifeSpan: 2000 - - size: 48 - sizeVariation: 24 - - SpriteGoal { - id: destructor - system: container.system - enabled: container.hp <=0 - anchors.fill: parent - groups: ["cruiserArmor"] - goalState: "death" -// jump: true - once: true - } - } - - Timer { - id: fireControl - property int next: Math.floor(Math.random() * 3) + 1 - interval: 800 - running: root.readySetGo - repeat: true - onTriggered: { - if (next == 1) { - gun1.fireAt(container.target); - next = Math.floor(Math.random() * 3) + 1; - } else if (next == 2) { - gun2.fireAt(container.target); - next = Math.floor(Math.random() * 3) + 1; - } else if (next == 3) { - gun3.fireAt(container.target); - next = Math.floor(Math.random() * 3) + 1; - } - } - } - - Hardpoint {//TODO: Hardpoint abstraction - x: 112 - 12 - 8*2 - y: 128 - 12 - 12*2 - id: gun1 - system: container.system - show: hp > 0 - hardpointType: gunType - } - Hardpoint { - x: 64 - 12 - y: 0 - 12 + 12*2 - id: gun2 - system: container.system - show: hp > 0 - hardpointType: gunType - } - Hardpoint { - x: 16 - 12 + 8*2 - y: 128 - 12 - 12*2 - id: gun3 - system: container.system - show: hp > 0 - hardpointType: gunType - } -} diff --git a/examples/declarative/particles/plasmapatrol/content/Frigate.qml b/examples/declarative/particles/plasmapatrol/content/Frigate.qml deleted file mode 100644 index de099bed72..0000000000 --- a/examples/declarative/particles/plasmapatrol/content/Frigate.qml +++ /dev/null @@ -1,114 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -import QtQuick 2.0 -import QtQuick.Particles 2.0 - -Item { - id: container - property int maxHP: 100 - property int hp: maxHP - property real initialDodge: 0.2 - property real dodge: initialDodge - onHpChanged: if(hp <= 0) target = container; - property ParticleSystem system//TODO: Ship abstraction - property Item target: container - property string shipParticle: "default"//Per team colors? - property int gunType: 0 - width: 128 - height: 128 - Emitter { - system: container.system - group: "frigateShield" - anchors.centerIn: parent - size: 92 - emitRate: 1 - lifeSpan: 4800 - enabled: hp > 0 - } - Emitter { - system: container.system - group: container.shipParticle - anchors.centerIn: parent - width: 64 - height: 16 - shape: EllipseShape {} - - size: 16 - sizeVariation: 8 - endSize: 8 - emitRate: hp > 0 ? hp * 1 + 20 : 0 - lifeSpan: 1200 - maximumEmitted: (maxHP * 1 + 20)*2 - } - Timer { - id: fireControl - property int next: Math.floor(Math.random() * 2) + 1 - interval: 800 - running: root.readySetGo - repeat: true - onTriggered: { - if (next == 1) { - gun1.fireAt(container.target); - next = Math.floor(Math.random() * 2) + 1; - } else if (next == 2) { - gun2.fireAt(container.target); - next = Math.floor(Math.random() * 2) + 1; - } - } - } - - Hardpoint { - x: 128 - 32 - 12 - y: 64 - 12 - id: gun1 - system: container.system - show: hp > 0 - hardpointType: gunType - } - Hardpoint { - x: 0 + 32 - 12 - y: 64 - 12 - id: gun2 - system: container.system - show: hp > 0 - hardpointType: gunType - } -} diff --git a/examples/declarative/particles/plasmapatrol/content/Hardpoint.qml b/examples/declarative/particles/plasmapatrol/content/Hardpoint.qml deleted file mode 100644 index 5c7fb5521b..0000000000 --- a/examples/declarative/particles/plasmapatrol/content/Hardpoint.qml +++ /dev/null @@ -1,114 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -import QtQuick 2.0 -import QtQuick.Particles 2.0 - -Item { - id: container - //ReflectiveProperties - //TransferredProperties - property variant target: {"y": -90, "x":12} - property ParticleSystem system - property bool show: true - property int hardpointType: 0 //default is pea shooter - always bad. - - property Item targetObj: null - property int damageDealt: 0 - onDamageDealtChanged: dealDamageTimer.start(); - Timer { - id: dealDamageTimer - interval: 16 - running: false - repeat: false - onTriggered: {targetObj.hp -= damageDealt; damageDealt = 0;} - } - width: 24 - height: 24 - function fireAt(targetArg) {//Each implement own - if (targetArg != null) { - hardpointLoader.item.fireAt(targetArg, container); - targetObj = targetArg; - } - } - Loader { - id: hardpointLoader - sourceComponent: { - switch (hardpointType) { - case 1: laserComponent; break; - case 2: blasterComponent; break; - case 3: cannonComponent; break; - default: emptyComponent; - } - } - } - Component { - id: laserComponent - LaserHardpoint { - target: container.target - system: container.system - show: container.show - } - } - Component { - id: blasterComponent - BlasterHardpoint { - target: container.target - system: container.system - show: container.show - } - } - Component { - id: cannonComponent - CannonHardpoint { - target: container.target - system: container.system - show: container.show - } - } - Component { - id: emptyComponent - Item { - function fireAt(obj) { - console.log("Firing null weapon. It hurts."); - } - } - } -} diff --git a/examples/declarative/particles/plasmapatrol/content/HelpScreens.qml b/examples/declarative/particles/plasmapatrol/content/HelpScreens.qml deleted file mode 100644 index 9297f86f31..0000000000 --- a/examples/declarative/particles/plasmapatrol/content/HelpScreens.qml +++ /dev/null @@ -1,268 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -import QtQuick 2.0 -import QtQuick.Particles 2.0 - -SequentialLoader { - id: hLdr - signal exitDesired - Component.onCompleted: advance(); - ParticleSystem { id: helpSystem } - PlasmaPatrolParticles { sys: helpSystem } - pages: [ - Component {Item { - id: story - Text { - color: "white" - text: "Story" - font.pixelSize: 48 - } - /* - Flickable { - y: 60 - width: 360 - height: 500 - contentHeight: txt1.height - contentWidth: 360//TODO: Less magic numbers? - */ - Text { - id: txt1 - color: "white" - y: 60 - font.pixelSize: 18 - text: " -In a remote nebula, a race of energy beings formed and lived prosperous lives for millenia. Until the schism - when they became constantly at each other's energy-throats. War soon followed, crippling both sides, until a truce was formed. But while governments knew the desparate need for peace, the soldiers in the ion-field were still filled with rampant bloodlust. On the border, patrols are constantly engaging in minor skirmishes whenever they cross paths. - -You must select one such patrol unit for the border, heading into an inevitable skirmish, in Plasma Patrol: the game of energy being spaceship combat! - " - width: 360 - wrapMode: Text.WordWrap - } - // } - Button { - x: 20 - y: 560 - height: 40 - width: 120 - text: "Next" - onClicked: hLdr.advance(); - } - Button { - x: 220 - y: 560 - height: 40 - width: 120 - text: "Menu" - onClicked: hLdr.exitDesired(); - } - }}, - Component {Item { - id: ships - Text { - color: "white" - text: "Vessels" - font.pixelSize: 48 - } - Column { - spacing: 16 - y: 60 - Row { - height: 128 - Sloop { - system: helpSystem - } - Text { - text: "The nimble sloop" - color: "white" - font.pixelSize: 18 - } - } - Row { - height: 128 - Frigate { - system: helpSystem - } - Text { - text: "The versitile shield frigate" - color: "white" - font.pixelSize: 18 - } - } - Row { - height: 128 - Cruiser { - system: helpSystem - } - Text { - text: "The armored cruiser" - color: "white" - font.pixelSize: 18 - } - } - } - Button { - x: 20 - y: 560 - height: 40 - width: 120 - text: "Next" - onClicked: hLdr.advance(); - } - Button { - x: 220 - y: 560 - height: 40 - width: 120 - text: "Menu" - onClicked: hLdr.exitDesired(); - } - }}, - Component {Item { - id: guns - Text { - color: "white" - text: "Hardpoints" - font.pixelSize: 48 - } - Column { - spacing: 16 - y: 60 - Row { - height: 128 - LaserHardpoint { - system: helpSystem - } - Text { - text: "The laser hardpoint almost always hits the target, even the nimble sloop, but loses much of its potency against the frigate's shields" - width: 332 - wrapMode: Text.WordWrap - color: "white" - font.pixelSize: 18 - } - } - Row { - height: 128 - BlasterHardpoint { - system: helpSystem - } - Text { - text: "The blaster passes right through the frigate's shields but loses much of its impact against the armor of the cruiser" - width: 332 - wrapMode: Text.WordWrap - color: "white" - font.pixelSize: 18 - } - } - Row { - height: 128 - CannonHardpoint { - system: helpSystem - } - Text { - text: "The cannon has poor accuracy, often missing the nimble sloop, but can punch right through the armor of the cruiser" - width: 332 - wrapMode: Text.WordWrap - color: "white" - font.pixelSize: 18 - } - } - } - Button { - x: 20 - y: 560 - height: 40 - width: 120 - text: "Next" - onClicked: hLdr.advance(); - } - Button { - x: 220 - y: 560 - height: 40 - width: 120 - text: "Menu" - onClicked: hLdr.exitDesired(); - } - }}, - Component {Item { - id: strategy - Text { - color: "white" - text: "Strategy" - font.pixelSize: 48 - } - Flickable { - y: 60 - width: 360 - height: 500 - contentHeight: txt1.height - contentWidth: 360//TODO: Less magic numbers? - Text { - id: txt1 - color: "white" - font.pixelSize: 18 - text: " -Basic Strategy: Good luck, have fun - don't die. -More to come after thorough playtesting. - " - width: 360 - wrapMode: Text.WordWrap - } - } - Button { - x: 20 - y: 560 - height: 40 - width: 120 - text: "Story" - onClicked: {hLdr.at=0; hLdr.advance();} - } - Button { - x: 220 - y: 560 - height: 40 - width: 120 - text: "Menu" - onClicked: hLdr.exitDesired(); - } - }} - ] -} diff --git a/examples/declarative/particles/plasmapatrol/content/LaserHardpoint.qml b/examples/declarative/particles/plasmapatrol/content/LaserHardpoint.qml deleted file mode 100644 index 87ac3e9e62..0000000000 --- a/examples/declarative/particles/plasmapatrol/content/LaserHardpoint.qml +++ /dev/null @@ -1,108 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -import QtQuick 2.0 -import QtQuick.Particles 2.0 - -Item { - id: container - property variant target: {"y": -90, "x":12} - property ParticleSystem system - property bool show: true - - width: 24 - height: 24 - Emitter { - id: visualization - group: "laser" - system: container.system - anchors.fill: parent - enabled: container.show - shape: EllipseShape {} - speed: TargetDirection { targetX: width/2; targetY: width/2; magnitude: -1; proportionalMagnitude: true } - lifeSpan: 1000 - emitRate: 64 - - size: 24 - sizeVariation: 8 - endSize: 8 - } - - function fireAt(targetArg, hardpoint) { - if (targetArg.hp <= 0) - return; - //TODO: calculate hit and damage at target, which must be a Ship - var offset = 0; - if (Math.random() < 0.99) { - switch (targetArg.shipType) { - case 1: hardpoint.damageDealt += 16; break; - case 2: hardpoint.damageDealt += 4; break; - case 3: hardpoint.damageDealt += 8; break; - default: hardpoint.damageDealt += 500; //Really effective against unregistered vessels - } - } else {//Misses with Lasers are really rare - offset = Math.random() * 100; - } - target = container.mapFromItem(targetArg, offset + targetArg.width/2, offset + targetArg.height/2); - emitter.pulse(100); - // console.log("Fire box: " + Math.min(container.width/2, target.x) + "," + Math.min(container.height/2, target.y) + " " + (Math.max(container.width/2, target.x) - Math.min(container.width/2, target.x)) + "," + (Math.max(container.height/2, target.y) - Math.min(container.height/2, target.y))); - } - Emitter { - id: emitter - group: "laser" - enabled: false - system: container.system - x: Math.min(container.width/2, target.x); - width: Math.max(container.width/2, target.x) - x; - y: Math.min(container.height/2, target.y); - height: Math.max(container.height/2, target.y) - y; - shape: LineShape { - mirrored: (emitter.y < 0 || emitter.x < 0) && !(emitter.y < 0 && emitter.x < 0 )//I just want XOR - } - - lifeSpan: 1000 - emitRate: 8000 - maximumEmitted: 800 - size: 16 - endSize: 0 - - speed: PointDirection {xVariation: 4; yVariation: 4} - } -} diff --git a/examples/declarative/particles/plasmapatrol/content/PlasmaPatrolParticles.qml b/examples/declarative/particles/plasmapatrol/content/PlasmaPatrolParticles.qml deleted file mode 100644 index 95d4bcd2b9..0000000000 --- a/examples/declarative/particles/plasmapatrol/content/PlasmaPatrolParticles.qml +++ /dev/null @@ -1,173 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -import QtQuick 2.0 -import QtQuick.Particles 2.0 - -Item { - property ParticleSystem sys - ImageParticle { - system: sys - groups: ["default"] - source: "pics/blur-circle3.png" - color: "#003A3A3A" - colorVariation: 0.1 - z: 0 - } - ImageParticle { - system: sys - groups: ["redTeam"] - source: "pics/blur-circle3.png" - color: "#0028060A" - colorVariation: 0.1 - z: 0 - } - ImageParticle { - system: sys - groups: ["greenTeam"] - source: "pics/blur-circle3.png" - color: "#0006280A" - colorVariation: 0.1 - z: 0 - } - ImageParticle { - system: sys - groups: ["blaster"] - source: "pics/star2.png" - //color: "#0F282406" - color: "#0F484416" - colorVariation: 0.2 - z: 2 - } - ImageParticle { - system: sys - groups: ["laser"] - source: "pics/star3.png" - //color: "#00123F68" - color: "#00428FF8" - colorVariation: 0.2 - z: 2 - } - ImageParticle { - system: sys - groups: ["cannon"] - source: "pics/particle.png" - color: "#80FFAAFF" - colorVariation: 0.1 - z: 2 - } - ImageParticle { - system: sys - groups: ["cannonCore"] - source: "pics/particle.png" - color: "#00666666" - colorVariation: 0.8 - z: 1 - } - ImageParticle { - system: sys - groups: ["cannonWake"] - source: "pics/star.png" - color: "#00CCCCCC" - colorVariation: 0.2 - z: 1 - } - ImageParticle { - system: sys - groups: ["frigateShield"] - source: "pics/blur-circle2.png" - color: "#00000000" - colorVariation: 0.05 - blueVariation: 0.5 - greenVariation: 0.1 - z: 3 - } - ImageParticle { - system: sys - groups: ["cruiserArmor"] - z: 1 - sprites:[Sprite { - id: spinState - name: "spinning" - source: "pics/meteor.png" - frames: 35 - frameDuration: 40 - to: {"death":0, "spinning":1} - },Sprite { - name: "death" - source: "pics/meteor_explo.png" - frames: 22 - frameDuration: 40 - to: {"null":1} - }, Sprite { - name: "null" - source: "pics/nullRock.png" - frames: 1 - frameDuration: 1000 - } - ] - } - TrailEmitter { - system: sys - group: "cannonWake" - follow: "cannon" - emitRatePerParticle: 64 - lifeSpan: 600 - speed: AngleDirection { angleVariation: 360; magnitude: 48} - size: 16 - endSize: 8 - sizeVariation: 2 - enabled: true - width: 1000//XXX: Terrible hack - height: 1000 - } - TrailEmitter { - system: sys - group: "cannonCore" - follow: "cannon" - emitRatePerParticle: 256 - lifeSpan: 128 - size: 24 - endSize: 8 - enabled: true - width: 1000//XXX: Terrible hack - height: 1000 - } -} diff --git a/examples/declarative/particles/plasmapatrol/content/SequentialLoader.qml b/examples/declarative/particles/plasmapatrol/content/SequentialLoader.qml deleted file mode 100644 index eaef87fe57..0000000000 --- a/examples/declarative/particles/plasmapatrol/content/SequentialLoader.qml +++ /dev/null @@ -1,54 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -import QtQuick 2.0 - -Item { - id: container - //TODO: Somehow get particles into this? - property list pages - property Item cur: null - property int at: 0 - function advance() { - if(cur != null) - cur.destroy(); - cur = pages[at++].createObject(container); - } -} diff --git a/examples/declarative/particles/plasmapatrol/content/Ship.qml b/examples/declarative/particles/plasmapatrol/content/Ship.qml deleted file mode 100644 index a928cd2a2e..0000000000 --- a/examples/declarative/particles/plasmapatrol/content/Ship.qml +++ /dev/null @@ -1,114 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -import QtQuick 2.0 -import QtQuick.Particles 2.0 - -Item { - id: me - //Reflective Properties - width: shipLoader.width - height: shipLoader.height - //Transfered Properties - property int hp: 100//shipLoader.item.maxHP - property real dodge: shipLoader.item.initialDodge - property ParticleSystem system - property int targetIdx: 0 - property Item target: targets[targetIdx] == undefined?null:targets[targetIdx] - Connections { - target: me.target - onHpChanged: if (me.target.hp<=0) me.targetIdx++; - } - property list targets - property string shipParticle: "default"//Per team colors? - property int gunType: 0 - property int shipType: 0 - Component { - id: sloopComp - Sloop { - system: me.system - target: me.target - shipParticle: me.shipParticle - gunType: me.gunType - hp: me.hp - dodge: me.dodge - } - } - Component { - id: frigateComp - Frigate { - system: me.system - target: me.target - shipParticle: me.shipParticle - gunType: me.gunType - hp: me.hp - dodge: me.dodge - } - } - Component { - id: cruiserComp - Cruiser { - system: me.system - target: me.target - shipParticle: me.shipParticle - gunType: me.gunType - hp: me.hp - dodge: me.dodge - } - } - Component { - id: dumbComp - Item { - property int maxHP: 0 - property int initialDodge: 0 - } - } - Loader { - id: shipLoader - sourceComponent: { - switch (shipType) { - case 1: sloopComp; break; - case 2: frigateComp; break; - case 3: cruiserComp; break; - default: dumbComp; - } - } - } -} diff --git a/examples/declarative/particles/plasmapatrol/content/Sloop.qml b/examples/declarative/particles/plasmapatrol/content/Sloop.qml deleted file mode 100644 index c6b1183162..0000000000 --- a/examples/declarative/particles/plasmapatrol/content/Sloop.qml +++ /dev/null @@ -1,108 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -import QtQuick 2.0 -import QtQuick.Particles 2.0 - -Item { - id: container - property int maxHP: 100 - property int hp: maxHP - property real initialDodge: 0.5 - property real dodge: initialDodge - property int blinkInterval: 800 - onHpChanged: if(hp <= 0) target = container; - property ParticleSystem system//TODO: Ship abstraction - property Item target: container - property string shipParticle: "default"//Per team colors? - property int gunType: 0 - width: 128 - height: 128 - Emitter { - id: emitter - //TODO: Cooler would be an 'orbiting' affector - //TODO: On the subject, opacity and size should be grouped type 'overLife' if we can cram that in the particles - system: container.system - group: container.shipParticle - shape: EllipseShape {} - - emitRate: hp > 0 ? hp + 20 : 0 - lifeSpan: blinkInterval - maximumEmitted: (maxHP + 20) - - acceleration: AngleDirection {angleVariation: 360; magnitude: 8} - - size: 24 - endSize: 4 - sizeVariation: 8 - width: 16 - height: 16 - x: 64 - y: 64 - Behavior on x {NumberAnimation {duration:blinkInterval}} - Behavior on y {NumberAnimation {duration:blinkInterval}} - Timer { - interval: blinkInterval - running: true - repeat: true - onTriggered: { - emitter.x = Math.random() * 48 + 32 - emitter.y = Math.random() * 48 + 32 - } - } - } - Hardpoint { - anchors.centerIn: parent - id: gun2 - system: container.system - show: container.hp > 0 - hardpointType: gunType - } - Timer { - id: fireControl - interval: 800 - running: root.readySetGo - repeat: true - onTriggered: { - gun2.fireAt(container.target); - } - } - -} diff --git a/examples/declarative/particles/plasmapatrol/content/pics/TitleText.png b/examples/declarative/particles/plasmapatrol/content/pics/TitleText.png deleted file mode 100644 index dc3acebe39..0000000000 Binary files a/examples/declarative/particles/plasmapatrol/content/pics/TitleText.png and /dev/null differ diff --git a/examples/declarative/particles/plasmapatrol/content/pics/blur-circle2.png b/examples/declarative/particles/plasmapatrol/content/pics/blur-circle2.png deleted file mode 100644 index f7c9f3e98e..0000000000 Binary files a/examples/declarative/particles/plasmapatrol/content/pics/blur-circle2.png and /dev/null differ diff --git a/examples/declarative/particles/plasmapatrol/content/pics/blur-circle3.png b/examples/declarative/particles/plasmapatrol/content/pics/blur-circle3.png deleted file mode 100644 index dbc39cb16e..0000000000 Binary files a/examples/declarative/particles/plasmapatrol/content/pics/blur-circle3.png and /dev/null differ diff --git a/examples/declarative/particles/plasmapatrol/content/pics/finalfrontier.png b/examples/declarative/particles/plasmapatrol/content/pics/finalfrontier.png deleted file mode 100644 index 2ba1815230..0000000000 Binary files a/examples/declarative/particles/plasmapatrol/content/pics/finalfrontier.png and /dev/null differ diff --git a/examples/declarative/particles/plasmapatrol/content/pics/meteor.png b/examples/declarative/particles/plasmapatrol/content/pics/meteor.png deleted file mode 100644 index e8c368aea7..0000000000 Binary files a/examples/declarative/particles/plasmapatrol/content/pics/meteor.png and /dev/null differ diff --git a/examples/declarative/particles/plasmapatrol/content/pics/meteor_explo.png b/examples/declarative/particles/plasmapatrol/content/pics/meteor_explo.png deleted file mode 100644 index 4297245d49..0000000000 Binary files a/examples/declarative/particles/plasmapatrol/content/pics/meteor_explo.png and /dev/null differ diff --git a/examples/declarative/particles/plasmapatrol/content/pics/nullRock.png b/examples/declarative/particles/plasmapatrol/content/pics/nullRock.png deleted file mode 100644 index 4076327a1a..0000000000 Binary files a/examples/declarative/particles/plasmapatrol/content/pics/nullRock.png and /dev/null differ diff --git a/examples/declarative/particles/plasmapatrol/content/pics/particle.png b/examples/declarative/particles/plasmapatrol/content/pics/particle.png deleted file mode 100644 index 5c83896d22..0000000000 Binary files a/examples/declarative/particles/plasmapatrol/content/pics/particle.png and /dev/null differ diff --git a/examples/declarative/particles/plasmapatrol/content/pics/star.png b/examples/declarative/particles/plasmapatrol/content/pics/star.png deleted file mode 100644 index 0d592cfa87..0000000000 Binary files a/examples/declarative/particles/plasmapatrol/content/pics/star.png and /dev/null differ diff --git a/examples/declarative/particles/plasmapatrol/content/pics/star2.png b/examples/declarative/particles/plasmapatrol/content/pics/star2.png deleted file mode 100644 index bb55c44788..0000000000 Binary files a/examples/declarative/particles/plasmapatrol/content/pics/star2.png and /dev/null differ diff --git a/examples/declarative/particles/plasmapatrol/content/pics/star3.png b/examples/declarative/particles/plasmapatrol/content/pics/star3.png deleted file mode 100644 index 636a25f480..0000000000 Binary files a/examples/declarative/particles/plasmapatrol/content/pics/star3.png and /dev/null differ diff --git a/examples/declarative/particles/plasmapatrol/plasmapatrol.qml b/examples/declarative/particles/plasmapatrol/plasmapatrol.qml deleted file mode 100644 index 45f81c7222..0000000000 --- a/examples/declarative/particles/plasmapatrol/plasmapatrol.qml +++ /dev/null @@ -1,386 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -import QtQuick 2.0 -import QtQuick.Particles 2.0 -import "content" - -Rectangle { - id: root - property bool readySetGo: false - //Debugging - property int hits: 0 - property int misses: 0 - property real ratio: hits/(misses?misses:1) - //Move to JS file? - property Ship redVar1: Ship {shipType: 1; gunType: 1} - property Ship redVar2: Ship {shipType: 1; gunType: 2} - property Ship redVar3: Ship {shipType: 1; gunType: 3} - property Ship greenVar1: Ship {shipType: 3; gunType: 1} - property Ship greenVar2: Ship {shipType: 2; gunType: 2} - property Ship greenVar3: Ship {shipType: 1; gunType: 3} - property string winner: "0" - property int players: 0 - function aiSet(ship) { - ship.gunType = Math.floor(Math.random() * 3) + 1 - ship.shipType = Math.floor(Math.random() * 3) + 1 - } - - width: 360 - height: 600 - color: "black" - SequentialLoader { - anchors.fill: parent - //General Children - Image { - anchors.centerIn: parent - source: "../images/finalfrontier.png" - } - ParticleSystem { - id: particles - } - PlasmaPatrolParticles { sys: particles; z: 100 }//Renders all particles on the one plane - //Component parts - id: pageControl - Component.onCompleted: advance(); - pages:[ - Component {Item { - id: menu - width: root.width - height: root.height - Column { - anchors.verticalCenter: parent.verticalCenter - width: parent.width - spacing: 8 - Item { - id: title - width: root.width - height: 240 - Emitter { - anchors.fill: parent - system: particles - enabled: true - group: "default" - emitRate: 1200 - lifeSpan: 1200 - shape: MaskShape {source:"content/pics/TitleText.png"} - size: 16 - endSize: 0 - sizeVariation: 8 - speed: AngleDirection {angleVariation:360; magnitudeVariation: 6} - } - } - Button { - text: "1P" - onClicked: {root.players = 1; pageControl.advance();} - anchors.horizontalCenter: parent.horizontalCenter - } - Button { - text: "2P" - onClicked: {root.players = 2; pageControl.advance();} - anchors.horizontalCenter: parent.horizontalCenter - } - Button { - text: "Demo" - anchors.horizontalCenter: parent.horizontalCenter - onClicked: {root.players = 0; - aiSet(redVar1); - aiSet(redVar2); - aiSet(redVar3); - aiSet(greenVar1); - aiSet(greenVar2); - aiSet(greenVar3); - pageControl.at = 5;//TODO: Not a magic number - pageControl.advance();} - } - Button { - text: "Help" - anchors.horizontalCenter: parent.horizontalCenter - onClicked: { - pageControl.at = 7;//TODO: Not a magic number - pageControl.advance(); - } - } - Button { - text: "Quit" - anchors.horizontalCenter: parent.horizontalCenter - onClicked: Qt.quit(); - } - } - }}, - Component {Item { - id: p1Screen - z: 101 - width: root.width - height: root.height - Rectangle { - anchors.fill: parent - color: "red" - } - Text { - anchors.centerIn: parent - color: "white" - font.pixelSize: 64 - font.bold: true - text: "Player\n 1" - horizontalAlignment: Text.AlignHCenter - } - MouseArea { - anchors.fill: parent - onClicked: pageControl.advance() - } - }}, - Component {Item { - id: p1Choices - z: 3 - width: root.width - height: root.height - Rectangle { - color: "black" - anchors.fill: parent - } - Column { - spacing: 16 - width: root.width - anchors.horizontalCenter: parent.horizontalCenter - ChoiceBox { - target: redVar1 - system: particles - } - ChoiceBox { - target: redVar2 - system: particles - } - ChoiceBox { - target: redVar3 - system: particles - } - Button { - anchors.horizontalCenter: parent.horizontalCenter - text: "Next" - onClicked: { - if (root.players < 2) { - aiSet(greenVar1); - aiSet(greenVar2); - aiSet(greenVar3); - pageControl.at = 5;//TODO: Not a magic number - } - pageControl.advance(); - } - } - } - }}, - Component {Item { - id: p2Screen - z: 101 - width: root.width - height: root.height - Rectangle { - anchors.fill: parent - color: "green" - } - Text { - anchors.centerIn: parent - color: "white" - font.pixelSize: 64 - font.bold: true - text: "Player\n 2" - horizontalAlignment: Text.AlignHCenter - } - MouseArea { - anchors.fill: parent - onClicked: pageControl.advance() - } - }}, - Component {Item { - id: p2Choices - z: 1 - width: root.width - height: root.height - Rectangle { - color: "black" - anchors.fill: parent - } - Column { - spacing: 16 - width: root.width - anchors.horizontalCenter: parent.horizontalCenter - ChoiceBox { - target: greenVar1 - system: particles - } - ChoiceBox { - target: greenVar2 - system: particles - } - ChoiceBox { - target: greenVar3 - system: particles - } - Button { - anchors.horizontalCenter: parent.horizontalCenter - text: "Next" - onClicked: pageControl.advance() - } - } - }}, - Component {Item { - id: arena - width: root.width - height: root.height - z: 0 - Component.onCompleted: root.readySetGo = true - Component.onDestruction: root.readySetGo = false - property bool victory: redShip3.hp <= 0 || greenShip3.hp <=0 - onVictoryChanged: { - if (redShip3.hp <= 0) { - if (greenShip3.hp <= 0) { - root.winner = "1&2" - }else { - root.winner = "2" - } - } else { - root.winner = "1" - } - winTimer.start() - } - Timer { - id: winTimer - interval: 1200 - repeat: false - running: false - onTriggered: pageControl.advance(); - } - Ship { - id: redShip1 - shipParticle: "redTeam" - system: particles - x: 180-64 - y: 128 - shipType: redVar1.shipType - gunType: redVar1.gunType - targets: [greenShip1, greenShip2, greenShip3] - } - Ship { - id: redShip2 - shipParticle: "redTeam" - system: particles - x: 0 - y: 0 - shipType: redVar2.shipType - gunType: redVar2.gunType - targets: [greenShip1, greenShip2, greenShip3] - } - Ship { - id: redShip3 - shipParticle: "redTeam" - system: particles - x: 360-128 - y: 0 - shipType: redVar3.shipType - gunType: redVar3.gunType - targets: [greenShip1, greenShip2, greenShip3] - } - - Ship { - id: greenShip1 - shipParticle: "greenTeam" - system: particles - x: 180-64 - y: 600 - 128 - 128 - shipType: greenVar1.shipType - gunType: greenVar1.gunType - targets: [redShip1, redShip2, redShip3] - } - Ship { - id: greenShip2 - shipParticle: "greenTeam" - system: particles - x: 0 - y: 600-128 - shipType: greenVar2.shipType - gunType: greenVar2.gunType - targets: [redShip1, redShip2, redShip3] - } - Ship { - id: greenShip3 - shipParticle: "greenTeam" - system: particles - x: 360 - 128 - y: 600 - 128 - shipType: greenVar3.shipType - gunType: greenVar3.gunType - targets: [redShip1, redShip2, redShip3] - } - }}, - Component {Item { - id: winScreen - z: 101 - width: root.width - height: root.height - /* - Rectangle { - anchors.fill: parent - color: "black" - } - */ - Text {//TODO: Particle Text? - anchors.fill: parent - color: "white" - font.pixelSize: 64 - font.bold: true - text: "Player " + root.winner + " wins!" - wrapMode: Text.WordWrap - horizontalAlignment: Text.AlignHCenter - verticalAlignment: Text.AlignVCenter - } - MouseArea { - anchors.fill: parent - onClicked: {pageControl.at = 0; pageControl.advance();} - } - }}, - Component { - HelpScreens { - onExitDesired: {pageControl.at = 0; pageControl.advance();} - } - } - ] - } -} diff --git a/examples/declarative/particles/simple/dynamiccomparison.qml b/examples/declarative/particles/simple/dynamiccomparison.qml deleted file mode 100644 index a7cdb9b32a..0000000000 --- a/examples/declarative/particles/simple/dynamiccomparison.qml +++ /dev/null @@ -1,126 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 -import QtQuick.Particles 2.0 - -Rectangle { - id: root - color: "black" - width: 640 - height: 480 - ParticleSystem { - id: sys - } - - ImageParticle { - system: sys - source: "../images/particle.png" - color: "white" - colorVariation: 1.0 - alpha: 0.1 - entryEffect: ImageParticle.None - } - - Emitter { - id: emitter - system: sys - width: parent.width/2 - speed: PointDirection {y: 72; yVariation: 24} - lifeSpan: 10000 - emitRate: 1000 - enabled: false - size: 32 - } - - Item { - id: fakeEmitter - function burst(number) { - while (number > 0) { - var item = fakeParticle.createObject(root); - item.lifeSpan = Math.random() * 5000 + 5000; - item.x = Math.random() * 320 + 320; - item.y = 0; - number--; - } - } - - Component { - id: fakeParticle - Image { - id: container - property int lifeSpan: 10000 - width: 32 - height: 32 - source: "../images/particle.png" - y: 0 - PropertyAnimation on y {from: -16; to: 480-16; duration: container.lifeSpan; running: true} - SequentialAnimation on opacity { - running: true - NumberAnimation { from:0; to: 1; duration: 500} - PauseAnimation { duration: container.lifeSpan - 1000} - NumberAnimation { from:1; to: 0; duration: 500} - ScriptAction { script: container.destroy(); } - } - } - } - } - - Text { - anchors.left: parent.left - anchors.bottom: parent.bottom - text: "1000 particles" - color: "white" - MouseArea { - anchors.fill: parent - onClicked: emitter.burst(1000); - } - } - Text { - anchors.right: parent.right - anchors.bottom: parent.bottom - text: "1000 items" - color: "white" - MouseArea { - anchors.fill: parent - onClicked: fakeEmitter.burst(1000); - } - } -} diff --git a/examples/declarative/particles/simple/dynamicemitters.qml b/examples/declarative/particles/simple/dynamicemitters.qml deleted file mode 100644 index 4431ebe82e..0000000000 --- a/examples/declarative/particles/simple/dynamicemitters.qml +++ /dev/null @@ -1,122 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 -import QtQuick.Particles 2.0 - -Rectangle { - id: root - color: "black" - width: 640 - height: 480 - ParticleSystem { - id: sys - } - ImageParticle { - system: sys - source: "../images/particle.png" - color: "white" - colorVariation: 1.0 - alpha: 0.1 - } - - Component { - id: emitterComp - Emitter { - id: container - Emitter { - id: emitMore - system: sys - emitRate: 128 - lifeSpan: 600 - size: 16 - endSize: 8 - speed: AngleDirection {angleVariation:360; magnitude: 60} - } - - property int life: 2600 - property real targetX: 0 - property real targetY: 0 - function go() { - xAnim.start(); - yAnim.start(); - container.enabled = true - } - system: sys - emitRate: 32 - lifeSpan: 600 - size: 24 - endSize: 8 - NumberAnimation on x { - id: xAnim; - to: targetX - duration: life - running: false - } - NumberAnimation on y { - id: yAnim; - to: targetY - duration: life - running: false - } - Timer { - interval: life - running: true - onTriggered: container.destroy(); - } - } - } - - MouseArea { - anchors.fill: parent - onClicked: { - for (var i=0; i<8; i++) { - var obj = emitterComp.createObject(root); - obj.x = mouse.x - obj.y = mouse.y - obj.targetX = Math.random() * 240 - 120 + obj.x - obj.targetY = Math.random() * 240 - 120 + obj.y - obj.life = Math.round(Math.random() * 2400) + 200 - obj.emitRate = Math.round(Math.random() * 32) + 32 - obj.go(); - } - } - } -} diff --git a/examples/declarative/particles/simple/multiplepainters.qml b/examples/declarative/particles/simple/multiplepainters.qml deleted file mode 100644 index c1b85caa2d..0000000000 --- a/examples/declarative/particles/simple/multiplepainters.qml +++ /dev/null @@ -1,90 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 -import QtQuick.Particles 2.0 - -Rectangle { - id: root - width: 360 - height: 600 - color: "darkblue" - property bool cloneMode: false - ParticleSystem { - id: sys - } - MouseArea { - anchors.fill: parent - onClicked: cloneMode = !cloneMode; - } - Emitter { - system: sys - y:root.height + 20 - width: root.width - emitRate: 200 - lifeSpan: 4000 - startTime: 4000 - speed: PointDirection { y: -120; } - } - - ImageParticle { - system: sys - visible: !cloneMode - source: "../images/particle2.png" - } - - ImageParticle { - system: sys - visible: cloneMode - z: 0 - source: "../images/particle3.png" - } - - ImageParticle { - system: sys - clip: true - visible: cloneMode - y: 120 - height: 240 - width: root.width - z: 1 - source: "../images/particle.png" - } -} diff --git a/examples/declarative/particles/simple/startstop.qml b/examples/declarative/particles/simple/startstop.qml deleted file mode 100644 index 62105b28a0..0000000000 --- a/examples/declarative/particles/simple/startstop.qml +++ /dev/null @@ -1,81 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 -import QtQuick.Particles 2.0 - -Rectangle { - width: 360 - height: 540 - color: "black" - MouseArea { - anchors.fill: parent - acceptedButtons: Qt.LeftButton | Qt.RightButton - onClicked: { - if (mouse.button == Qt.LeftButton) - particles.running = !particles.running - else - particles.paused = !particles.paused; - } - } - - ParticleSystem { - id: particles - running: false - } - - ImageParticle { - anchors.fill: parent - system: particles - source: "../images/star.png" - sizeTable: "../images/sparkleSize.png" - alpha: 0 - colorVariation: 0.6 - } - - Emitter { - anchors.fill: parent - system: particles - emitRate: 2000 - lifeSpan: 2000 - size: 30 - sizeVariation: 10 - } -} diff --git a/examples/declarative/photoviewer/PhotoViewerCore/AlbumDelegate.qml b/examples/declarative/photoviewer/PhotoViewerCore/AlbumDelegate.qml deleted file mode 100644 index f183c4b2a0..0000000000 --- a/examples/declarative/photoviewer/PhotoViewerCore/AlbumDelegate.qml +++ /dev/null @@ -1,147 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 -import QtQuick.XmlListModel 2.0 - -Component { - id: albumDelegate - Package { - - Item { - Package.name: 'browser' - GridView { - id: photosGridView; model: visualModel.parts.grid; width: mainWindow.width; height: mainWindow.height - 21 - x: 0; y: 21; cellWidth: 160; cellHeight: 153; interactive: false - onCurrentIndexChanged: photosListView.positionViewAtIndex(currentIndex, ListView.Contain) - } - } - - Item { - Package.name: 'fullscreen' - ListView { - id: photosListView; model: visualModel.parts.list; orientation: Qt.Horizontal - width: mainWindow.width; height: mainWindow.height; interactive: false - onCurrentIndexChanged: photosGridView.positionViewAtIndex(currentIndex, GridView.Contain) - highlightRangeMode: ListView.StrictlyEnforceRange; snapMode: ListView.SnapOneItem - } - } - - Item { - Package.name: 'album' - id: albumWrapper; width: 210; height: 220 - - VisualDataModel { - id: visualModel; delegate: PhotoDelegate { } - model: RssModel { id: rssModel; tags: tag } - } - - BusyIndicator { - id: busyIndicator - anchors { centerIn: parent; verticalCenterOffset: -20 } - on: rssModel.status != XmlListModel.Ready - } - - PathView { - id: photosPathView; model: visualModel.parts.stack; pathItemCount: 5 - visible: !busyIndicator.visible - anchors.centerIn: parent; anchors.verticalCenterOffset: -30 - path: Path { - PathAttribute { name: 'z'; value: 9999.0 } - PathLine { x: 1; y: 1 } - PathAttribute { name: 'z'; value: 0.0 } - } - } - - MouseArea { - anchors.fill: parent - onClicked: mainWindow.editMode ? photosModel.remove(index) : albumWrapper.state = 'inGrid' - } - - Tag { - anchors { horizontalCenter: parent.horizontalCenter; bottom: parent.bottom; bottomMargin: 10 } - frontLabel: tag; backLabel: qsTr("Remove"); flipped: mainWindow.editMode - onTagChanged: rssModel.tags = tag - onBackClicked: if (mainWindow.editMode) photosModel.remove(index); - } - - states: [ - State { - name: 'inGrid' - PropertyChanges { target: photosGridView; interactive: true } - PropertyChanges { target: albumsShade; opacity: 1 } - PropertyChanges { target: backButton; onClicked: albumWrapper.state = ''; y: 6 } - }, - State { - name: 'fullscreen'; extend: 'inGrid' - PropertyChanges { target: photosGridView; interactive: false } - PropertyChanges { target: photosListView; interactive: true } - PropertyChanges { target: photosShade; opacity: 1 } - PropertyChanges { target: backButton; y: -backButton.height - 8 } - } - ] - - GridView.onAdd: NumberAnimation { - target: albumWrapper; properties: "scale"; from: 0.0; to: 1.0; easing.type: Easing.OutQuad - } - GridView.onRemove: SequentialAnimation { - PropertyAction { target: albumWrapper; property: "GridView.delayRemove"; value: true } - NumberAnimation { target: albumWrapper; property: "scale"; from: 1.0; to: 0.0; easing.type: Easing.OutQuad } - PropertyAction { target: albumWrapper; property: "GridView.delayRemove"; value: false } - } - - transitions: [ - Transition { - from: '*'; to: 'inGrid' - SequentialAnimation { - NumberAnimation { properties: 'opacity'; duration: 250 } - PauseAnimation { duration: 350 } - NumberAnimation { target: backButton; properties: "y"; duration: 200; easing.type: Easing.OutQuad } - } - }, - Transition { - from: 'inGrid'; to: '*' - NumberAnimation { properties: "y,opacity"; easing.type: Easing.OutQuad; duration: 300 } - } - ] - } - } -} diff --git a/examples/declarative/photoviewer/PhotoViewerCore/BusyIndicator.qml b/examples/declarative/photoviewer/PhotoViewerCore/BusyIndicator.qml deleted file mode 100644 index 2b1a75f369..0000000000 --- a/examples/declarative/photoviewer/PhotoViewerCore/BusyIndicator.qml +++ /dev/null @@ -1,50 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -Image { - id: container - property bool on: false - - source: "images/busy.png"; visible: container.on - NumberAnimation on rotation { running: container.on; from: 0; to: 360; loops: Animation.Infinite; duration: 1200 } -} diff --git a/examples/declarative/photoviewer/PhotoViewerCore/Button.qml b/examples/declarative/photoviewer/PhotoViewerCore/Button.qml deleted file mode 100644 index fcce969fbd..0000000000 --- a/examples/declarative/photoviewer/PhotoViewerCore/Button.qml +++ /dev/null @@ -1,72 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -Item { - id: container - - property alias label: labelText.text - property color tint: "transparent" - signal clicked - - width: labelText.width + 70 ; height: labelText.height + 18 - - BorderImage { - anchors { fill: container; leftMargin: -6; topMargin: -6; rightMargin: -8; bottomMargin: -8 } - source: 'images/box-shadow.png'; smooth: true - border.left: 10; border.top: 10; border.right: 10; border.bottom: 10 - } - - Image { anchors.fill: parent; source: "images/cardboard.png"; smooth: true } - - Rectangle { - anchors.fill: container; color: container.tint; visible: container.tint != "" - opacity: 0.25; smooth: true - } - - Text { id: labelText; font.pixelSize: 15; anchors.centerIn: parent; smooth: true } - - MouseArea { - anchors { fill: parent; leftMargin: -20; topMargin: -20; rightMargin: -20; bottomMargin: -20 } - onClicked: container.clicked() - } -} diff --git a/examples/declarative/photoviewer/PhotoViewerCore/EditableButton.qml b/examples/declarative/photoviewer/PhotoViewerCore/EditableButton.qml deleted file mode 100644 index 5d845938c7..0000000000 --- a/examples/declarative/photoviewer/PhotoViewerCore/EditableButton.qml +++ /dev/null @@ -1,86 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -Item { - id: container - - property string label - signal clicked - signal labelChanged(string label) - - width: textInput.width + 70 ; height: textInput.height + 18 - - BorderImage { - anchors { fill: container; leftMargin: -6; topMargin: -6; rightMargin: -8; bottomMargin: -8 } - source: 'images/box-shadow.png'; smooth: true - border.left: 10; border.top: 10; border.right: 10; border.bottom: 10 - } - - Image { anchors.fill: parent; source: "images/cardboard.png"; smooth: true } - - TextInput { - id: textInput; text: label; font.pixelSize: 15; anchors.centerIn: parent; smooth: true - Keys.onReturnPressed: { - container.labelChanged(textInput.text) - container.focus = true - } - Keys.onEnterPressed: { - container.labelChanged(textInput.text) - container.focus = true - } - Keys.onEscapePressed: { - textInput.text = container.label - container.focus = true - } - } - - Rectangle { - anchors.fill: container; border.color: "steelblue"; border.width: 4 - color: "transparent"; visible: textInput.focus; smooth: true - } - - MouseArea { - anchors { fill: parent; leftMargin: -20; topMargin: -20; rightMargin: -20; bottomMargin: -20 } - onClicked: { textInput.forceActiveFocus(); textInput.openSoftwareInputPanel(); } - } -} diff --git a/examples/declarative/photoviewer/PhotoViewerCore/PhotoDelegate.qml b/examples/declarative/photoviewer/PhotoViewerCore/PhotoDelegate.qml deleted file mode 100644 index b972c938eb..0000000000 --- a/examples/declarative/photoviewer/PhotoViewerCore/PhotoDelegate.qml +++ /dev/null @@ -1,188 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 -import "script/script.js" as Script - -Package { - Item { id: stackItem; Package.name: 'stack'; width: 160; height: 153; z: stackItem.PathView.z } - Item { id: listItem; Package.name: 'list'; width: mainWindow.width + 40; height: 153 } - Item { id: gridItem; Package.name: 'grid'; width: 160; height: 153 } - - Item { - width: 160; height: 153 - - Item { - id: photoWrapper - - property double randomAngle: Math.random() * (2 * 6 + 1) - 6 - property double randomAngle2: Math.random() * (2 * 6 + 1) - 6 - - x: 0; y: 0; width: 140; height: 133 - z: stackItem.PathView.z; rotation: photoWrapper.randomAngle - - BorderImage { - anchors { - fill: originalImage.status == Image.Ready ? border : placeHolder - leftMargin: -6; topMargin: -6; rightMargin: -8; bottomMargin: -8 - } - source: 'images/box-shadow.png'; smooth: true - border.left: 10; border.top: 10; border.right: 10; border.bottom: 10 - } - Rectangle { - id: placeHolder - - property int w: Script.getWidth(content) - property int h: Script.getHeight(content) - property double s: Script.calculateScale(w, h, photoWrapper.width) - - color: 'white'; anchors.centerIn: parent; smooth: true - width: w * s; height: h * s; visible: originalImage.status != Image.Ready - Rectangle { - color: "#878787"; smooth: true - anchors { fill: parent; topMargin: 3; bottomMargin: 3; leftMargin: 3; rightMargin: 3 } - } - } - Rectangle { - id: border; color: 'white'; anchors.centerIn: parent; smooth: true - width: originalImage.paintedWidth + 6; height: originalImage.paintedHeight + 6 - visible: !placeHolder.visible - } - BusyIndicator { anchors.centerIn: parent; on: originalImage.status != Image.Ready } - Image { - id: originalImage; smooth: true; source: "http://" + Script.getImagePath(content); cache: false - fillMode: Image.PreserveAspectFit; width: photoWrapper.width; height: photoWrapper.height - } - Image { - id: hqImage; smooth: true; source: ""; visible: false; cache: false - fillMode: Image.PreserveAspectFit; width: photoWrapper.width; height: photoWrapper.height - } - Binding { - target: mainWindow; property: "downloadProgress"; value: hqImage.progress - when: listItem.ListView.isCurrentItem - } - Binding { - target: mainWindow; property: "imageLoading" - value: (hqImage.status == Image.Loading) ? 1 : 0; when: listItem.ListView.isCurrentItem - } - MouseArea { - width: originalImage.paintedWidth; height: originalImage.paintedHeight; anchors.centerIn: originalImage - onClicked: { - if (albumWrapper.state == 'inGrid') { - gridItem.GridView.view.currentIndex = index; - albumWrapper.state = 'fullscreen' - } else { - gridItem.GridView.view.currentIndex = index; - albumWrapper.state = 'inGrid' - } - } - } - - states: [ - State { - name: 'stacked'; when: albumWrapper.state == '' - ParentChange { target: photoWrapper; parent: stackItem; x: 10; y: 10 } - PropertyChanges { target: photoWrapper; opacity: stackItem.PathView.onPath ? 1.0 : 0.0 } - }, - State { - name: 'inGrid'; when: albumWrapper.state == 'inGrid' - ParentChange { target: photoWrapper; parent: gridItem; x: 10; y: 10; rotation: photoWrapper.randomAngle2 } - }, - State { - name: 'fullscreen'; when: albumWrapper.state == 'fullscreen' - ParentChange { - target: photoWrapper; parent: listItem; x: 0; y: 0; rotation: 0 - width: mainWindow.width; height: mainWindow.height - } - PropertyChanges { target: border; opacity: 0 } - PropertyChanges { target: hqImage; source: listItem.ListView.isCurrentItem ? hq : ""; visible: true } - } - ] - - transitions: [ - Transition { - from: 'stacked'; to: 'inGrid' - SequentialAnimation { - PauseAnimation { duration: 10 * index } - ParentAnimation { - target: photoWrapper; via: foreground - NumberAnimation { - target: photoWrapper; properties: 'x,y,rotation,opacity'; duration: 600; easing.type: 'OutQuart' - } - } - } - }, - Transition { - from: 'inGrid'; to: 'stacked' - ParentAnimation { - target: photoWrapper; via: foreground - NumberAnimation { properties: 'x,y,rotation,opacity'; duration: 600; easing.type: 'OutQuart' } - } - }, - Transition { - from: 'inGrid'; to: 'fullscreen' - SequentialAnimation { - PauseAnimation { duration: gridItem.GridView.isCurrentItem ? 0 : 600 } - ParentAnimation { - target: photoWrapper; via: foreground - NumberAnimation { - targets: [ photoWrapper, border ] - properties: 'x,y,width,height,opacity,rotation' - duration: gridItem.GridView.isCurrentItem ? 600 : 1; easing.type: 'OutQuart' - } - } - } - }, - Transition { - from: 'fullscreen'; to: 'inGrid' - ParentAnimation { - target: photoWrapper; via: foreground - NumberAnimation { - targets: [ photoWrapper, border ] - properties: 'x,y,width,height,rotation,opacity' - duration: gridItem.GridView.isCurrentItem ? 600 : 1; easing.type: 'OutQuart' - } - } - } - ] - } - } -} diff --git a/examples/declarative/photoviewer/PhotoViewerCore/ProgressBar.qml b/examples/declarative/photoviewer/PhotoViewerCore/ProgressBar.qml deleted file mode 100644 index 43c936e342..0000000000 --- a/examples/declarative/photoviewer/PhotoViewerCore/ProgressBar.qml +++ /dev/null @@ -1,57 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -Item { - id: container - - property real progress: 0 - - Behavior on opacity { NumberAnimation { duration: 600 } } - - Rectangle { anchors.fill: parent; color: "black"; opacity: 0.5 } - - Rectangle { - id: fill; color: "white"; height: container.height - width: container.width * container.progress - } -} diff --git a/examples/declarative/photoviewer/PhotoViewerCore/RssModel.qml b/examples/declarative/photoviewer/PhotoViewerCore/RssModel.qml deleted file mode 100644 index ab818924ac..0000000000 --- a/examples/declarative/photoviewer/PhotoViewerCore/RssModel.qml +++ /dev/null @@ -1,57 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 -import QtQuick.XmlListModel 2.0 - -XmlListModel { - property string tags : "" - - function encodeTags(x) { return encodeURIComponent(x.replace(' ',',')); } - - source: "http://api.flickr.com/services/feeds/photos_public.gne?"+(tags ? "tags="+encodeTags(tags)+"&" : "") - query: "/feed/entry" - namespaceDeclarations: "declare default element namespace 'http://www.w3.org/2005/Atom';" - - XmlRole { name: "title"; query: "title/string()" } - XmlRole { name: "content"; query: "content/string()" } - XmlRole { name: "hq"; query: "link[@rel='enclosure']/@href/string()" } -} diff --git a/examples/declarative/photoviewer/PhotoViewerCore/Tag.qml b/examples/declarative/photoviewer/PhotoViewerCore/Tag.qml deleted file mode 100644 index 2b546a3ac6..0000000000 --- a/examples/declarative/photoviewer/PhotoViewerCore/Tag.qml +++ /dev/null @@ -1,91 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -Flipable { - id: flipable - - property alias frontLabel: frontButton.label - property alias backLabel: backButton.label - - property int angle: 0 - property int randomAngle: Math.random() * (2 * 6 + 1) - 6 - property bool flipped: false - - signal frontClicked - signal backClicked - signal tagChanged(string tag) - - front: EditableButton { - id: frontButton; rotation: flipable.randomAngle - anchors { centerIn: parent; verticalCenterOffset: -20 } - onClicked: flipable.frontClicked() - onLabelChanged: flipable.tagChanged(label) - } - - back: Button { - id: backButton; tint: "red"; rotation: flipable.randomAngle - anchors { centerIn: parent; verticalCenterOffset: -20 } - onClicked: flipable.backClicked() - } - - transform: Rotation { - origin.x: flipable.width / 2; origin.y: flipable.height / 2 - axis.x: 0; axis.y: 1; axis.z: 0 - angle: flipable.angle - } - - states: State { - name: "back"; when: flipable.flipped - PropertyChanges { target: flipable; angle: 180 } - } - - transitions: Transition { - ParallelAnimation { - NumberAnimation { properties: "angle"; duration: 400 } - SequentialAnimation { - NumberAnimation { target: flipable; property: "scale"; to: 0.8; duration: 200 } - NumberAnimation { target: flipable; property: "scale"; to: 1.0; duration: 200 } - } - } - } -} diff --git a/examples/declarative/photoviewer/PhotoViewerCore/images/box-shadow.png b/examples/declarative/photoviewer/PhotoViewerCore/images/box-shadow.png deleted file mode 100644 index 431af8545d..0000000000 Binary files a/examples/declarative/photoviewer/PhotoViewerCore/images/box-shadow.png and /dev/null differ diff --git a/examples/declarative/photoviewer/PhotoViewerCore/images/busy.png b/examples/declarative/photoviewer/PhotoViewerCore/images/busy.png deleted file mode 100644 index 664c2b1491..0000000000 Binary files a/examples/declarative/photoviewer/PhotoViewerCore/images/busy.png and /dev/null differ diff --git a/examples/declarative/photoviewer/PhotoViewerCore/images/cardboard.png b/examples/declarative/photoviewer/PhotoViewerCore/images/cardboard.png deleted file mode 100644 index 1847ab528d..0000000000 Binary files a/examples/declarative/photoviewer/PhotoViewerCore/images/cardboard.png and /dev/null differ diff --git a/examples/declarative/photoviewer/PhotoViewerCore/qmldir b/examples/declarative/photoviewer/PhotoViewerCore/qmldir deleted file mode 100644 index d3c247f21a..0000000000 --- a/examples/declarative/photoviewer/PhotoViewerCore/qmldir +++ /dev/null @@ -1,8 +0,0 @@ -AlbumDelegate AlbumDelegate.qml -PhotoDelegate PhotoDelegate.qml -ProgressBar ProgressBar.qml -RssModel RssModel.qml -BusyIndicator BusyIndicator.qml -EditableButton EditableButton.qml -Button Button.qml -Tag Tag.qml diff --git a/examples/declarative/photoviewer/PhotoViewerCore/script/script.js b/examples/declarative/photoviewer/PhotoViewerCore/script/script.js deleted file mode 100644 index e8ef93a847..0000000000 --- a/examples/declarative/photoviewer/PhotoViewerCore/script/script.js +++ /dev/null @@ -1,27 +0,0 @@ -.pragma library - -function getWidth(string) { - return (string.match(/width=\"([0-9]+)\"/))[1] -} - -function getHeight(string) { - return (string.match(/height=\"([0-9]+)\"/))[1] -} - -function getImagePath(string) { - var pattern = /src=\"http:\/\/(\S+)\"/ - return (string.match(pattern))[1] -} - -function calculateScale(width, height, cellSize) { - var widthScale = (cellSize * 1.0) / width - var heightScale = (cellSize * 1.0) / height - var scale = 0 - - if (widthScale <= heightScale) { - scale = widthScale; - } else if (heightScale < widthScale) { - scale = heightScale; - } - return scale; -} diff --git a/examples/declarative/photoviewer/i18n/base.ts b/examples/declarative/photoviewer/i18n/base.ts deleted file mode 100644 index 1accfd2f90..0000000000 --- a/examples/declarative/photoviewer/i18n/base.ts +++ /dev/null @@ -1,30 +0,0 @@ - - - - - AlbumDelegate - - - Remove - - - - - photoviewer - - - Add - - - - - Edit - - - - - Back - - - - diff --git a/examples/declarative/photoviewer/i18n/qml_fr.qm b/examples/declarative/photoviewer/i18n/qml_fr.qm deleted file mode 100644 index c24fcbc46c..0000000000 Binary files a/examples/declarative/photoviewer/i18n/qml_fr.qm and /dev/null differ diff --git a/examples/declarative/photoviewer/i18n/qml_fr.ts b/examples/declarative/photoviewer/i18n/qml_fr.ts deleted file mode 100644 index 9f892db616..0000000000 --- a/examples/declarative/photoviewer/i18n/qml_fr.ts +++ /dev/null @@ -1,30 +0,0 @@ - - - - - AlbumDelegate - - - Remove - Supprimer - - - - photoviewer - - - Add - Ajouter - - - - Edit - Éditer - - - - Back - Retour - - - diff --git a/examples/declarative/photoviewer/photoviewer.qml b/examples/declarative/photoviewer/photoviewer.qml deleted file mode 100644 index 918438832b..0000000000 --- a/examples/declarative/photoviewer/photoviewer.qml +++ /dev/null @@ -1,110 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 -import "PhotoViewerCore" - -Rectangle { - id: mainWindow - - property real downloadProgress: 0 - property bool imageLoading: false - property bool editMode: false - - width: 800; height: 480; color: "#d5d6d8" - - ListModel { - id: photosModel - ListElement { tag: "Flowers" } - ListElement { tag: "Wildlife" } - ListElement { tag: "Prague" } - } - - VisualDataModel { id: albumVisualModel; model: photosModel; delegate: AlbumDelegate {} } - - GridView { - id: albumView; width: parent.width; height: parent.height; cellWidth: 210; cellHeight: 220 - model: albumVisualModel.parts.album; visible: albumsShade.opacity != 1.0 - } - - Column { - spacing: 20; anchors { bottom: parent.bottom; right: parent.right; rightMargin: 20; bottomMargin: 20 } - Button { - id: newButton; label: qsTr("Add"); rotation: 3 - anchors.horizontalCenter: parent.horizontalCenter - onClicked: { - mainWindow.editMode = false - photosModel.append( { tag: "" } ) - albumView.positionViewAtIndex(albumView.count - 1, GridView.Contain) - } - } - Button { - id: deleteButton; label: qsTr("Edit"); rotation: -2; - onClicked: mainWindow.editMode = !mainWindow.editMode - anchors.horizontalCenter: parent.horizontalCenter - } - Button { - id: quitButton; label: qsTr("Quit"); rotation: -2; - onClicked: Qt.quit() - anchors.horizontalCenter: parent.horizontalCenter - } - } - - Rectangle { - id: albumsShade; color: mainWindow.color - width: parent.width; height: parent.height; opacity: 0.0 - } - - ListView { anchors.fill: parent; model: albumVisualModel.parts.browser; interactive: false } - - Button { id: backButton; label: qsTr("Back"); rotation: 3; x: parent.width - backButton.width - 6; y: -backButton.height - 8 } - - Rectangle { id: photosShade; color: 'black'; width: parent.width; height: parent.height; opacity: 0; visible: opacity != 0.0 } - - ListView { anchors.fill: parent; model: albumVisualModel.parts.fullscreen; interactive: false } - - Item { id: foreground; anchors.fill: parent } - - ProgressBar { - progress: mainWindow.downloadProgress; width: parent.width; height: 4 - anchors.bottom: parent.bottom; opacity: mainWindow.imageLoading; visible: opacity != 0.0 - } -} diff --git a/examples/declarative/photoviewer/photoviewer.qmlproject b/examples/declarative/photoviewer/photoviewer.qmlproject deleted file mode 100644 index 600bdb10f4..0000000000 --- a/examples/declarative/photoviewer/photoviewer.qmlproject +++ /dev/null @@ -1,20 +0,0 @@ -import QmlProject 1.1 - -Project { - mainFile: "photoviewer.qml" - - /* Include .qml, .js, and image files from current directory and subdirectories */ - QmlFiles { - directory: "." - } - JavaScriptFiles { - directory: "." - } - ImageFiles { - directory: "." - } - Files { - filter: "*.ts" - directory: "i18n" - } -} diff --git a/examples/declarative/positioners/content/Button.qml b/examples/declarative/positioners/content/Button.qml deleted file mode 100644 index ee3aa9057e..0000000000 --- a/examples/declarative/positioners/content/Button.qml +++ /dev/null @@ -1,78 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -Rectangle { - id: page - - property string text - property string icon - signal clicked - - border.color: "black"; color: "steelblue"; radius: 5 - width: pix.width + textelement.width + 13 - height: pix.height + 10 - - Image { id: pix; x: 5; y:5; source: parent.icon } - - Text { - id: textelement - text: page.text; color: "white" - x: pix.width + pix.x + 3 - anchors.verticalCenter: pix.verticalCenter - } - - MouseArea { - id: mr - anchors.fill: parent - onClicked: { parent.focus = true; page.clicked() } - } - - states: State { - name: "pressed"; when: mr.pressed - PropertyChanges { target: textelement; x: 5 } - PropertyChanges { target: pix; x: textelement.x + textelement.width + 3 } - } - - transitions: Transition { - NumberAnimation { properties: "x,left"; easing.type: Easing.InOutQuad; duration: 200 } - } -} diff --git a/examples/declarative/positioners/content/add.png b/examples/declarative/positioners/content/add.png deleted file mode 100644 index 1ee45423e3..0000000000 Binary files a/examples/declarative/positioners/content/add.png and /dev/null differ diff --git a/examples/declarative/positioners/content/del.png b/examples/declarative/positioners/content/del.png deleted file mode 100644 index 8d2eaed523..0000000000 Binary files a/examples/declarative/positioners/content/del.png and /dev/null differ diff --git a/examples/declarative/positioners/positioners-attachedproperties.qml b/examples/declarative/positioners/positioners-attachedproperties.qml deleted file mode 100644 index a05927f5ea..0000000000 --- a/examples/declarative/positioners/positioners-attachedproperties.qml +++ /dev/null @@ -1,106 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -Rectangle { - width: 400 - height: 100 - - // Create row with four rectangles, the fourth one is hidden - Row { - id: row - - Rectangle { - id: red - color: "red" - width: 100 - height: 100 - - // When mouse is clicked, display the values of the positioner - MouseArea { - anchors.fill: parent - onClicked: row.showInfo(red.Positioner) - } - } - - Rectangle { - id: green - color: "green" - width: 100 - height: 100 - - // When mouse is clicked, display the values of the positioner - MouseArea { - anchors.fill: parent - onClicked: row.showInfo(green.Positioner) - } - } - - Rectangle { - id: blue - color: "blue" - width: 100 - height: 100 - - // When mouse is clicked, display the values of the positioner - MouseArea { - anchors.fill: parent - onClicked: row.showInfo(blue.Positioner) - } - } - - // This rectangle is not visible, so it doesn't have a positioner value - Rectangle { - color: "black" - width: 100 - height: 100 - visible: false - } - - // Print the index of the child item in the positioner and convenience - // properties showing if it's the first or last item. - function showInfo(positioner) { - console.log("Item Index = " + positioner.index) - console.log(" isFirstItem = " + positioner.isFirstItem) - console.log(" isLastItem = " + positioner.isLastItem) - } - } -} diff --git a/examples/declarative/positioners/positioners.qml b/examples/declarative/positioners/positioners.qml deleted file mode 100644 index d9d16649ff..0000000000 --- a/examples/declarative/positioners/positioners.qml +++ /dev/null @@ -1,264 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 -import "content" - -Rectangle { - id: page - width: 420; height: 420 - - Column { - id: layout1 - y: 0 - move: Transition { - NumberAnimation { properties: "y"; easing.type: Easing.OutBounce } - } - add: Transition { - NumberAnimation { properties: "y"; easing.type: Easing.OutQuad } - } - - Rectangle { color: "red"; width: 100; height: 50; border.color: "black"; radius: 15 } - - Rectangle { - id: blueV1 - visible: opacity != 0 - width: 100; height: 50 - color: "lightsteelblue" - border.color: "black" - radius: 15 - Behavior on opacity { NumberAnimation {} } - } - - Rectangle { color: "green"; width: 100; height: 50; border.color: "black"; radius: 15 } - - Rectangle { - id: blueV2 - visible: opacity != 0 - width: 100; height: 50 - color: "lightsteelblue" - border.color: "black" - radius: 15 - Behavior on opacity { NumberAnimation {} } - } - - Rectangle { color: "orange"; width: 100; height: 50; border.color: "black"; radius: 15 } - } - - Row { - id: layout2 - y: 300 - move: Transition { - NumberAnimation { properties: "x"; easing.type: Easing.OutBounce } - } - add: Transition { - NumberAnimation { properties: "x"; easing.type: Easing.OutQuad } - } - - Rectangle { color: "red"; width: 50; height: 100; border.color: "black"; radius: 15 } - - Rectangle { - id: blueH1 - visible: opacity != 0 - width: 50; height: 100 - color: "lightsteelblue" - border.color: "black" - radius: 15 - Behavior on opacity { NumberAnimation {} } - } - - Rectangle { color: "green"; width: 50; height: 100; border.color: "black"; radius: 15 } - - Rectangle { - id: blueH2 - visible: opacity != 0 - width: 50; height: 100 - color: "lightsteelblue" - border.color: "black" - radius: 15 - Behavior on opacity { NumberAnimation {} } - } - - Rectangle { color: "orange"; width: 50; height: 100; border.color: "black"; radius: 15 } - } - - Button { - x: 135; y: 90 - text: "Remove" - icon: "del.png" - - onClicked: { - blueH2.opacity = 0 - blueH1.opacity = 0 - blueV1.opacity = 0 - blueV2.opacity = 0 - blueG1.opacity = 0 - blueG2.opacity = 0 - blueG3.opacity = 0 - blueF1.opacity = 0 - blueF2.opacity = 0 - blueF3.opacity = 0 - } - } - - Button { - x: 145; y: 140 - text: "Add" - icon: "add.png" - - onClicked: { - blueH2.opacity = 1 - blueH1.opacity = 1 - blueV1.opacity = 1 - blueV2.opacity = 1 - blueG1.opacity = 1 - blueG2.opacity = 1 - blueG3.opacity = 1 - blueF1.opacity = 1 - blueF2.opacity = 1 - blueF3.opacity = 1 - } - } - - Grid { - x: 260; y: 0 - columns: 3 - - move: Transition { - NumberAnimation { properties: "x,y"; easing.type: Easing.OutBounce } - } - - add: Transition { - NumberAnimation { properties: "x,y"; easing.type: Easing.OutBounce } - } - - Rectangle { color: "red"; width: 50; height: 50; border.color: "black"; radius: 15 } - - Rectangle { - id: blueG1 - visible: opacity != 0 - width: 50; height: 50 - color: "lightsteelblue" - border.color: "black" - radius: 15 - Behavior on opacity { NumberAnimation {} } - } - - Rectangle { color: "green"; width: 50; height: 50; border.color: "black"; radius: 15 } - - Rectangle { - id: blueG2 - visible: opacity != 0 - width: 50; height: 50 - color: "lightsteelblue" - border.color: "black" - radius: 15 - Behavior on opacity { NumberAnimation {} } - } - - Rectangle { color: "orange"; width: 50; height: 50; border.color: "black"; radius: 15 } - - Rectangle { - id: blueG3 - visible: opacity != 0 - width: 50; height: 50 - color: "lightsteelblue" - border.color: "black" - radius: 15 - Behavior on opacity { NumberAnimation {} } - } - - Rectangle { color: "red"; width: 50; height: 50; border.color: "black"; radius: 15 } - Rectangle { color: "green"; width: 50; height: 50; border.color: "black"; radius: 15 } - Rectangle { color: "orange"; width: 50; height: 50; border.color: "black"; radius: 15 } - } - - Flow { - id: layout4 - x: 260; y: 250; width: 150 - - move: Transition { - NumberAnimation { properties: "x,y"; easing.type: Easing.OutBounce } - } - - add: Transition { - NumberAnimation { properties: "x,y"; easing.type: Easing.OutBounce } - } - - Rectangle { color: "red"; width: 50; height: 50; border.color: "black"; radius: 15 } - - Rectangle { - id: blueF1 - visible: opacity != 0 - width: 60; height: 50 - color: "lightsteelblue" - border.color: "black" - radius: 15 - Behavior on opacity { NumberAnimation {} } - } - - Rectangle { color: "green"; width: 30; height: 50; border.color: "black"; radius: 15 } - - Rectangle { - id: blueF2 - visible: opacity != 0 - width: 60; height: 50 - color: "lightsteelblue" - border.color: "black" - radius: 15 - Behavior on opacity { NumberAnimation {} } - } - - Rectangle { color: "orange"; width: 50; height: 50; border.color: "black"; radius: 15 } - - Rectangle { - id: blueF3 - visible: opacity != 0 - width: 40; height: 50 - color: "lightsteelblue" - border.color: "black" - radius: 15 - Behavior on opacity { NumberAnimation {} } - } - - Rectangle { color: "red"; width: 80; height: 50; border.color: "black"; radius: 15 } - } - -} diff --git a/examples/declarative/righttoleft/layoutdirection/layoutdirection.qml b/examples/declarative/righttoleft/layoutdirection/layoutdirection.qml deleted file mode 100644 index 0c65647d5b..0000000000 --- a/examples/declarative/righttoleft/layoutdirection/layoutdirection.qml +++ /dev/null @@ -1,246 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -Rectangle { - id: root - property bool mirror - property int direction: Qt.application.layoutDirection - LayoutMirroring.enabled: mirror - LayoutMirroring.childrenInherit: true - width: column.width + 80 - height: column.height + 40 - Column { - id: column - width: 190 - spacing: 10 - anchors.centerIn: parent - - Text { - text: "Row" - anchors.horizontalCenter: parent.horizontalCenter - } - - Row { - layoutDirection: root.direction - spacing: 10 - move: Transition { - NumberAnimation { - properties: "x" - } - } - Repeater { - model: 4 - Loader { - property int value: index - sourceComponent: positionerDelegate - } - } - } - - Text { - text: "Grid" - anchors.horizontalCenter: parent.horizontalCenter - } - - Grid { - layoutDirection: root.direction - spacing: 10; columns: 4 - move: Transition { - NumberAnimation { - properties: "x" - } - } - Repeater { - model: 11 - Loader { - property int value: index - sourceComponent: positionerDelegate - } - } - } - - Text { - text: "Flow" - anchors.horizontalCenter: parent.horizontalCenter - } - - Flow { - layoutDirection: root.direction - spacing: 10; width: parent.width - move: Transition { - NumberAnimation { - properties: "x" - } - } - Repeater { - model: 10 - Loader { - property int value: index - sourceComponent: positionerDelegate - } - } - } - - Text { - text: "ListView" - anchors.horizontalCenter: parent.horizontalCenter - } - - ListView { - id: listView - clip: true - width: parent.width; height: 40 - layoutDirection: root.direction - orientation: Qt.Horizontal - model: 48 - delegate: viewDelegate - } - - Text { - text: "GridView" - anchors.horizontalCenter: parent.horizontalCenter - } - - GridView { - clip: true - width: 200; height: 160 - cellWidth: 50; cellHeight: 50 - layoutDirection: root.direction - model: 48 - delegate: viewDelegate - } - - Rectangle { - height: 50; width: parent.width - color: mouseArea.pressed ? "black" : "gray" - Column { - anchors.centerIn: parent - Text { - text: root.direction ? "Right to left" : "Left to right" - color: "white" - font.pixelSize: 16 - anchors.horizontalCenter: parent.horizontalCenter - } - Text { - text: "(click here to toggle)" - color: "white" - font.pixelSize: 10 - font.italic: true - anchors.horizontalCenter: parent.horizontalCenter - } - } - MouseArea { - id: mouseArea - anchors.fill: parent - onClicked: { - if (root.direction == Qt.LeftToRight) { - root.direction = Qt.RightToLeft; - } else { - root.direction = Qt.LeftToRight; - } - } - } - } - - Rectangle { - height: 50; width: parent.width - color: mouseArea2.pressed ? "black" : "gray" - Column { - anchors.centerIn: parent - Text { - text: root.mirror ? "Mirrored" : "Not mirrored" - color: "white" - font.pixelSize: 16 - anchors.horizontalCenter: parent.horizontalCenter - } - Text { - text: "(click here to toggle)" - color: "white" - font.pixelSize: 10 - font.italic: true - anchors.horizontalCenter: parent.horizontalCenter - } - } - MouseArea { - id: mouseArea2 - anchors.fill: parent - onClicked: { - root.mirror = !root.mirror; - } - } - } - } - - Component { - id: positionerDelegate - Rectangle { - width: 40; height: 40 - color: Qt.rgba(0.8/(parent.value+1),0.8/(parent.value+1),0.8/(parent.value+1),1.0) - Text { - text: parent.parent.value+1 - color: "white" - font.pixelSize: 18 - anchors.centerIn: parent - } - } - } - Component { - id: viewDelegate - Item { - width: (listView.effectiveLayoutDirection == Qt.LeftToRight ? (index == 48 - 1) : (index == 0)) ? 40 : 50 - Rectangle { - width: 40; height: 40 - color: Qt.rgba(0.5+(48 - index)*Math.random()/48, - 0.3+index*Math.random()/48, - 0.3*Math.random(), - 1.0) - Text { - text: index+1 - color: "white" - font.pixelSize: 18 - anchors.centerIn: parent - } - } - } - } -} - diff --git a/examples/declarative/righttoleft/layoutdirection/layoutdirection.qmlproject b/examples/declarative/righttoleft/layoutdirection/layoutdirection.qmlproject deleted file mode 100644 index 33cbb3c9e2..0000000000 --- a/examples/declarative/righttoleft/layoutdirection/layoutdirection.qmlproject +++ /dev/null @@ -1,16 +0,0 @@ -import QmlProject 1.1 - -Project { - mainFile: "layoutdirection.qml" - - /* Include .qml, .js, and image files from current directory and subdirectories */ - QmlFiles { - directory: "." - } - JavaScriptFiles { - directory: "." - } - ImageFiles { - directory: "." - } -} diff --git a/examples/declarative/righttoleft/layoutmirroring/layoutmirroring.qml b/examples/declarative/righttoleft/layoutmirroring/layoutmirroring.qml deleted file mode 100644 index 5c4739bd57..0000000000 --- a/examples/declarative/righttoleft/layoutmirroring/layoutmirroring.qml +++ /dev/null @@ -1,313 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -Rectangle { - id: root - property bool mirror: Qt.application.layoutDirection == Qt.RightToLeft - LayoutMirroring.enabled: mirror - LayoutMirroring.childrenInherit: true - width: 400 - height: 875 - color: "lightsteelblue" - - Column { - spacing: 10 - anchors { left: parent.left; right: parent.right; top: parent.top; margins: 10 } - - Text { - text: "Positioners" - anchors.left: parent.left - } - - Column { - id: positioners - spacing: 5 - anchors.left: parent.left - Row { - id: row - spacing: 4 - property string text: "THISISROW" - anchors.left: parent.left - Repeater { - model: parent.text.length - delegate: positionerDelegate - } - } - Flow { - id: flow - spacing: 4 - width: 90 - property string text: "THISISFLOW" - anchors.left: parent.left - Repeater { - model: parent.text.length - delegate: positionerDelegate - } - } - Grid { - id: grid - spacing: 4 - columns: 6 - property string text: "THISISGRID" - anchors.left: parent.left - Repeater { - model: parent.text.length - delegate: positionerDelegate - } - } - Component { - id: positionerDelegate - Text { - color: "white" - font.pixelSize: 20 - text: parent.text[index] - Rectangle { - z: -1 - opacity: 0.7 - color: "black" - anchors.fill: parent - } - } - } - } - - Text { - text: "Text alignment" - anchors.left: parent.left - } - - Rectangle { - id: textStrings - width: 148 - height: 85 - color: "white" - anchors.left: parent.left - Column { - spacing: 5 - width: parent.width - anchors { fill: parent; margins: 5 } - Text { - id: englishText - width: parent.width - text: "English text" - } - Text { - id: arabicText - width: parent.width - text: "النص العربي" - } - Text { - id: leftAlignedText - width: parent.width - text: "Text aligned to left" - horizontalAlignment: Text.AlignLeft - } - Text { - id: rightAlignedText - width: parent.width - text: "Text aligned to right" - horizontalAlignment: Text.AlignRight - } - } - } - - Text { - text: "Model views" - anchors.left: parent.left - } - - Column { - id: views - spacing: 10 - anchors.left: parent.left - ListView { - id: listView - z: -1 - clip: true - model: text.length - width: 360; height: 45 - orientation: Qt.Horizontal - property string text: "LISTVIEWLISTVIEWLISTVIEWLISTVIEWLISTVIEWLISTVIEW" - delegate: Rectangle { - color: "black" - width: 45; height: 45 - Rectangle { - anchors { fill: parent; margins: 1 } - color: "red" - } - Text { - text: listView.text[index] - font.pixelSize: 30 - anchors.centerIn: parent - } - } - } - GridView { - id: gridView - z: -1 - clip: true - model: text.length - width: 180; height: 90 - cellWidth: 45; cellHeight: 45 - property string text: "GRIDVIEWGRIDVIEWGRIDVIEWGRIDVIEWGRIDVIEWGRIDVIEW" - anchors.left: parent.left - delegate: Rectangle { - color: "black" - width: 45; height: 45 - Rectangle { - anchors { fill: parent; margins: 1 } - color: "red" - } - Text { - anchors.centerIn: parent - font.pixelSize: 30 - text: gridView.text[index] - } - } - } - } - - Text { - text: "Item x" - anchors.left: parent.left - } - Rectangle { - id: items - color: Qt.rgba(0.2, 0.2, 0.2, 0.6) - width: 275; height: 95 - anchors.left: parent.left - Rectangle { - y: 5; x: 5 - width: 130; height: 40 - Text { - text: "Item with x: 5\n(not mirrored)" - anchors.centerIn: parent - } - } - Rectangle { - color: Qt.rgba(0.7, 0.7, 0.7) - y: 50; x: mirror(5) - width: 130; height: 40 - function mirror(value) { - return LayoutMirroring.enabled ? (parent.width - width - value) : value; - } - Text { - text: "Item with x: " + parent.x + "\n(manually mirrored)" - anchors.centerIn: parent - } - } - } - Text { - text: "Item anchors" - anchors.left: parent.left - } - - Rectangle { - id: anchoredItems - color: Qt.rgba(0.2, 0.2, 0.2, 0.6) - width: 270; height: 170 - anchors.left: parent.left - Rectangle { - id: blackRectangle - color: "black" - width: 180; height: 90 - anchors { horizontalCenter: parent.horizontalCenter; horizontalCenterOffset: 30 } - Text { - text: "Horizontal center anchored\nwith offset 30\nto the horizontal center\nof the parent." - color: "white" - anchors.centerIn: parent - } - } - Rectangle { - id: whiteRectangle - color: "white" - width: 120; height: 70 - anchors { left: parent.left; bottom: parent.bottom } - Text { - text: "Left side anchored\nto the left side\nof the parent." - color: "black" - anchors.centerIn: parent - } - } - Rectangle { - id: grayRectangle - color: Qt.rgba(0.7, 0.7, 0.7) - width: 140; height: 90 - anchors { right: parent.right; bottom: parent.bottom } - Text { - text: "Right side anchored\nto the right side\nof the parent." - anchors.centerIn: parent - } - } - } - Rectangle { - id: mirrorButton - color: mouseArea2.pressed ? "black" : "gray" - height: 50; width: parent.width - anchors.left: parent.left - Column { - anchors.centerIn: parent - Text { - text: root.mirror ? "Mirrored" : "Not mirrored" - color: "white" - font.pixelSize: 16 - anchors.horizontalCenter: parent.horizontalCenter - } - Text { - text: "(click here to toggle)" - color: "white" - font.pixelSize: 10 - font.italic: true - anchors.horizontalCenter: parent.horizontalCenter - } - } - MouseArea { - id: mouseArea2 - anchors.fill: parent - onClicked: { - root.mirror = !root.mirror; - } - } - } - } -} - diff --git a/examples/declarative/righttoleft/layoutmirroring/layoutmirroring.qmlproject b/examples/declarative/righttoleft/layoutmirroring/layoutmirroring.qmlproject deleted file mode 100644 index 72bc04a8a9..0000000000 --- a/examples/declarative/righttoleft/layoutmirroring/layoutmirroring.qmlproject +++ /dev/null @@ -1,16 +0,0 @@ -import QmlProject 1.1 - -Project { - mainFile: "layoutmirroring.qml" - - /* Include .qml, .js, and image files from current directory and subdirectories */ - QmlFiles { - directory: "." - } - JavaScriptFiles { - directory: "." - } - ImageFiles { - directory: "." - } -} diff --git a/examples/declarative/righttoleft/textalignment/textalignment.qml b/examples/declarative/righttoleft/textalignment/textalignment.qml deleted file mode 100644 index ef5b97bb1a..0000000000 --- a/examples/declarative/righttoleft/textalignment/textalignment.qml +++ /dev/null @@ -1,427 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -Rectangle { - id: root - color: "white" - width: containerColumn.width - height: containerColumn.height + containerColumn.anchors.topMargin - - property bool mirror: false - property variant horizontalAlignment: undefined - - property variant editorType: ["Plain Text", "Styled Text", "Plain Rich Text", "Italic Rich Text", "Plain TextEdit", "Italic TextEdit", "TextInput"] - property variant text: ["", " ", "Hello world!", "مرحبا العالم!", "Hello world! Hello!\nHello world! Hello!", "مرحبا العالم! مرحبا! مرحبا العالم! مرحبا!" ,"مرحبا العالم! مرحبا! مرحبا Hello world!\nالعالم! مرحبا!"] - property variant description: ["empty text", "white-space-only text", "left-to-right text", "right-to-left text", "multi-line left-to-right text", "multi-line right-to-left text", "multi-line bidi text"] - property variant textComponents: [plainTextComponent, styledTextComponent, richTextComponent, italicRichTextComponent, plainTextEdit, italicTextEdit, textInput] - - function shortText(horizontalAlignment) { - - // all the different QML editors have - // the same alignment values - switch (horizontalAlignment) { - case Text.AlignLeft: - return "L"; - case Text.AlignRight: - return "R"; - case Text.AlignHCenter: - return "C"; - case Text.AlignJustify: - return "J"; - default: - return "Error"; - } - } - Column { - id: containerColumn - spacing: 10 - width: editorTypeRow.width - anchors { top: parent.top; topMargin: 5 } - Row { - id: editorTypeRow - Repeater { - model: editorType.length - Item { - width: editorColumn.width - height: editorColumn.height - Column { - id: editorColumn - spacing: 5 - width: textColumn.width+10 - Text { - text: root.editorType[index] - font.pixelSize: 16 - anchors.horizontalCenter: parent.horizontalCenter - } - Column { - id: textColumn - spacing: 5 - anchors.horizontalCenter: parent.horizontalCenter - Repeater { - model: textComponents.length - delegate: textComponents[index] - } - } - } - } - } - } - Column { - spacing: 2 - width: parent.width - Rectangle { - // button - height: 50; width: parent.width - color: mouseArea.pressed ? "black" : "lightgray" - Column { - anchors.centerIn: parent - Text { - text: root.mirror ? "Mirrored" : "Not mirrored" - color: "white" - font.pixelSize: 16 - anchors.horizontalCenter: parent.horizontalCenter - } - Text { - text: "(click here to toggle)" - color: "white" - font.pixelSize: 10 - font.italic: true - anchors.horizontalCenter: parent.horizontalCenter - } - } - MouseArea { - id: mouseArea - property int index: 0 - anchors.fill: parent - onClicked: root.mirror = !root.mirror - } - } - Rectangle { - // button - height: 50; width: parent.width - color: mouseArea2.pressed ? "black" : "gray" - Column { - anchors.centerIn: parent - Text { - text: { - if (root.horizontalAlignment == undefined) - return "Implict alignment"; - switch (root.horizontalAlignment) { - case Text.AlignLeft: - return "Left alignment"; - case Text.AlignRight: - return "Right alignment"; - case Text.AlignHCenter: - return "Center alignment"; - case Text.AlignJustify: - return "Justify alignment"; - } - } - color: "white" - font.pixelSize: 16 - anchors.horizontalCenter: parent.horizontalCenter - } - Text { - text: "(click here to toggle)" - color: "white" - font.pixelSize: 10 - font.italic: true - anchors.horizontalCenter: parent.horizontalCenter - } - } - MouseArea { - id: mouseArea2 - property int index: 0 - anchors.fill: parent - onClicked: { - if (index < 0) { - root.horizontalAlignment = undefined; - } else { - root.horizontalAlignment = Math.pow(2, index); - } - index = (index + 2) % 5 - 1; - } - } - } - } - } - - Component { - id: plainTextComponent - Text { - width: 180 - text: root.text[index] - font.pixelSize: 24 - wrapMode: Text.WordWrap - horizontalAlignment: root.horizontalAlignment - LayoutMirroring.enabled: root.mirror - textFormat: Text.RichText - Rectangle { - z: -1 - color: Qt.rgba(0.8, 0.2, 0.2, 0.3) - anchors.fill: parent - } - Text { - text: root.description[index] - color: Qt.rgba(1,1,1,1.0) - anchors.centerIn: parent - Rectangle { - z: -1 - color: Qt.rgba(0.3, 0, 0, 0.3) - anchors { fill: parent; margins: -3 } - } - } - Text { - color: "white" - text: shortText(parent.horizontalAlignment) - anchors { top: parent.top; right: parent.right; margins: 2 } - } - } - } - - Component { - id: styledTextComponent - Text { - width: 180 - text: root.text[index] - font.pixelSize: 24 - wrapMode: Text.WordWrap - horizontalAlignment: root.horizontalAlignment - LayoutMirroring.enabled: root.mirror - textFormat: Text.RichText - style: Text.Sunken - styleColor: "white" - Rectangle { - z: -1 - color: Qt.rgba(0.8, 0.2, 0.2, 0.3) - anchors.fill: parent - } - Text { - text: root.description[index] - color: Qt.rgba(1,1,1,1.0) - anchors.centerIn: parent - Rectangle { - z: -1 - color: Qt.rgba(0.3, 0, 0, 0.3) - anchors { fill: parent; margins: -3 } - } - } - Text { - color: "white" - text: shortText(parent.horizontalAlignment) - anchors { top: parent.top; right: parent.right; margins: 2 } - } - } - } - - Component { - id: richTextComponent - Text { - width: 180 - text: root.text[index] - font.pixelSize: 24 - wrapMode: Text.WordWrap - horizontalAlignment: root.horizontalAlignment - LayoutMirroring.enabled: root.mirror - textFormat: Text.RichText - Rectangle { - z: -1 - color: Qt.rgba(0.8, 0.2, 0.2, 0.3) - anchors.fill: parent - } - Text { - text: root.description[index] - color: Qt.rgba(1,1,1,1.0) - anchors.centerIn: parent - Rectangle { - z: -1 - color: Qt.rgba(0.3, 0, 0, 0.3) - anchors { fill: parent; margins: -3 } - } - } - Text { - color: "white" - text: shortText(parent.horizontalAlignment) - anchors { top: parent.top; right: parent.right; margins: 2 } - } - } - } - - Component { - id: italicRichTextComponent - Text { - width: 180 - text: "" + root.text[index] + "" - font.pixelSize: 24 - wrapMode: Text.WordWrap - horizontalAlignment: root.horizontalAlignment - LayoutMirroring.enabled: root.mirror - textFormat: Text.RichText - property variant backgroundColor: Qt.rgba(0.8, 0.2, 0.2, 0.3) - Rectangle { - z: -1 - color: parent.backgroundColor - anchors.fill: parent - } - Text { - text: root.description[index] - color: Qt.rgba(1,1,1,1.0) - anchors.centerIn: parent - Rectangle { - z: -1 - color: Qt.rgba(0.3, 0, 0, 0.3) - anchors { fill: parent; margins: -3 } - } - } - Text { - color: "white" - text: shortText(parent.horizontalAlignment) - anchors { top: parent.top; right: parent.right; margins: 2 } - } - } - } - - Component { - id: plainTextEdit - TextEdit { - width: 180 - text: root.text[index] - font.pixelSize: 24 - cursorVisible: true - wrapMode: TextEdit.WordWrap - horizontalAlignment: root.horizontalAlignment - LayoutMirroring.enabled: root.mirror - Rectangle { - z: -1 - color: Qt.rgba(0.5, 0.5, 0.2, 0.3) - anchors.fill: parent - } - Text { - text: root.description[index] - color: Qt.rgba(1,1,1,1.0) - anchors.centerIn: parent - Rectangle { - z: -1 - color: Qt.rgba(0.3, 0, 0, 0.3) - anchors { fill: parent; margins: -3 } - } - } - Text { - color: "white" - text: shortText(parent.horizontalAlignment) - anchors { top: parent.top; right: parent.right; margins: 2 } - } - } - } - - Component { - id: italicTextEdit - TextEdit { - width: 180 - text: "" + root.text[index] + "" - font.pixelSize: 24 - cursorVisible: true - wrapMode: TextEdit.WordWrap - textFormat: TextEdit.RichText - horizontalAlignment: root.horizontalAlignment - LayoutMirroring.enabled: root.mirror - Rectangle { - z: -1 - color: Qt.rgba(0.5, 0.5, 0.2, 0.3) - anchors.fill: parent - } - Text { - text: root.description[index] - color: Qt.rgba(1,1,1,1.0) - anchors.centerIn: parent - Rectangle { - z: -1 - color: Qt.rgba(0.3, 0, 0, 0.3) - anchors { fill: parent; margins: -3 } - } - } - Text { - color: "white" - text: shortText(parent.horizontalAlignment) - anchors { top: parent.top; right: parent.right; margins: 2 } - } - } - } - - Component { - id: textInput - Item { - width: 180 - height: textInput.text.length > 20 ? 3*textInput.height : textInput.height - TextInput { - id: textInput - width: 180 - text: root.text[index] - font.pixelSize: 24 - cursorVisible: true - horizontalAlignment: root.horizontalAlignment - LayoutMirroring.enabled: root.mirror - Rectangle { - z: -1 - color: Qt.rgba(0.6, 0.4, 0.2, 0.3) - anchors.fill: parent - } - Text { - text: root.description[index] - color: Qt.rgba(1,1,1,1.0) - anchors.centerIn: parent - Rectangle { - z: -1 - color: Qt.rgba(0.3, 0, 0, 0.3) - anchors { fill: parent; margins: -3 } - } - } - Text { - color: "white" - text: shortText(parent.horizontalAlignment) - anchors { top: parent.top; right: parent.right; margins: 2 } - } - } - } - } -} - diff --git a/examples/declarative/righttoleft/textalignment/textalignment.qmlproject b/examples/declarative/righttoleft/textalignment/textalignment.qmlproject deleted file mode 100644 index e4b5061364..0000000000 --- a/examples/declarative/righttoleft/textalignment/textalignment.qmlproject +++ /dev/null @@ -1,16 +0,0 @@ -import QmlProject 1.1 - -Project { - mainFile: "textalignment.qml" - - /* Include .qml, .js, and image files from current directory and subdirectories */ - QmlFiles { - directory: "." - } - JavaScriptFiles { - directory: "." - } - ImageFiles { - directory: "." - } -} diff --git a/examples/declarative/rssnews/content/BusyIndicator.qml b/examples/declarative/rssnews/content/BusyIndicator.qml deleted file mode 100644 index b6264ead92..0000000000 --- a/examples/declarative/rssnews/content/BusyIndicator.qml +++ /dev/null @@ -1,53 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -Image { - id: container - property bool on: false - - source: "images/busy.png"; visible: container.on - - NumberAnimation on rotation { - running: container.on; from: 0; to: 360; loops: Animation.Infinite; duration: 1200 - } -} diff --git a/examples/declarative/rssnews/content/CategoryDelegate.qml b/examples/declarative/rssnews/content/CategoryDelegate.qml deleted file mode 100644 index 1a56184489..0000000000 --- a/examples/declarative/rssnews/content/CategoryDelegate.qml +++ /dev/null @@ -1,82 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -Item { - id: delegate - - width: delegate.ListView.view.width; height: 60 - - Text { - text: name - color: delegate.ListView.isCurrentItem ? "white" : "black" - font { family: "Helvetica"; pixelSize: 16; bold: true } - anchors { - left: parent.left; leftMargin: 15 - verticalCenter: parent.verticalCenter - } - } - - BusyIndicator { - scale: 0.6 - on: delegate.ListView.isCurrentItem && window.loading - anchors { right: parent.right; rightMargin: 10; verticalCenter: parent.verticalCenter } - } - - Rectangle { - width: delegate.width; height: 1; color: "#cccccc" - anchors.bottom: delegate.bottom - visible: delegate.ListView.isCurrentItem ? false : true - } - Rectangle { - width: delegate.width; height: 1; color: "white" - visible: delegate.ListView.isCurrentItem ? false : true - } - - MouseArea { - anchors.fill: delegate - onClicked: { - delegate.ListView.view.currentIndex = index - window.currentFeed = feed - } - } -} diff --git a/examples/declarative/rssnews/content/NewsDelegate.qml b/examples/declarative/rssnews/content/NewsDelegate.qml deleted file mode 100644 index 84019a9179..0000000000 --- a/examples/declarative/rssnews/content/NewsDelegate.qml +++ /dev/null @@ -1,71 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -Item { - id: delegate - height: column.height + 40 - width: delegate.ListView.view.width - - Column { - id: column - x: 20; y: 20 - width: parent.width - 40 - - Text { - id: titleText - text: title; width: parent.width; wrapMode: Text.WordWrap - font { bold: true; family: "Helvetica"; pointSize: 16 } - } - - Text { - id: descriptionText - width: parent.width; text: description - wrapMode: Text.WordWrap; font.family: "Helvetica" - } - } - - Rectangle { - width: parent.width; height: 1; color: "#cccccc" - anchors.bottom: parent.bottom - } -} diff --git a/examples/declarative/rssnews/content/RssFeeds.qml b/examples/declarative/rssnews/content/RssFeeds.qml deleted file mode 100644 index 278f05752c..0000000000 --- a/examples/declarative/rssnews/content/RssFeeds.qml +++ /dev/null @@ -1,59 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -ListModel { - id: rssFeeds - - ListElement { name: "Top Stories"; feed: "rss.news.yahoo.com/rss/topstories" } - ListElement { name: "World"; feed: "rss.news.yahoo.com/rss/world" } - ListElement { name: "Europe"; feed: "rss.news.yahoo.com/rss/europe" } - ListElement { name: "Oceania"; feed: "rss.news.yahoo.com/rss/oceania" } - ListElement { name: "U.S. National"; feed: "rss.news.yahoo.com/rss/us" } - ListElement { name: "Politics"; feed: "rss.news.yahoo.com/rss/politics" } - ListElement { name: "Business"; feed: "rss.news.yahoo.com/rss/business" } - ListElement { name: "Technology"; feed: "rss.news.yahoo.com/rss/tech" } - ListElement { name: "Entertainment"; feed: "rss.news.yahoo.com/rss/entertainment" } - ListElement { name: "Health"; feed: "rss.news.yahoo.com/rss/health" } - ListElement { name: "Science"; feed: "rss.news.yahoo.com/rss/science" } - ListElement { name: "Sports"; feed: "rss.news.yahoo.com/rss/sports" } -} diff --git a/examples/declarative/rssnews/content/ScrollBar.qml b/examples/declarative/rssnews/content/ScrollBar.qml deleted file mode 100644 index 4ca4132c6b..0000000000 --- a/examples/declarative/rssnews/content/ScrollBar.qml +++ /dev/null @@ -1,107 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -Item { - id: container - - property variant scrollArea - property variant orientation: Qt.Vertical - - opacity: 0 - - function position() - { - var ny = 0; - if (container.orientation == Qt.Vertical) - ny = scrollArea.visibleArea.yPosition * container.height; - else - ny = scrollArea.visibleArea.xPosition * container.width; - if (ny > 2) return ny; else return 2; - } - - function size() - { - var nh, ny; - - if (container.orientation == Qt.Vertical) - nh = scrollArea.visibleArea.heightRatio * container.height; - else - nh = scrollArea.visibleArea.widthRatio * container.width; - - if (container.orientation == Qt.Vertical) - ny = scrollArea.visibleArea.yPosition * container.height; - else - ny = scrollArea.visibleArea.xPosition * container.width; - - if (ny > 3) { - var t; - if (container.orientation == Qt.Vertical) - t = Math.ceil(container.height - 3 - ny); - else - t = Math.ceil(container.width - 3 - ny); - if (nh > t) return t; else return nh; - } else return nh + ny; - } - - Rectangle { anchors.fill: parent; color: "Black"; opacity: 0.3 } - - BorderImage { - source: "images/scrollbar.png" - border { left: 1; right: 1; top: 1; bottom: 1 } - x: container.orientation == Qt.Vertical ? 2 : position() - width: container.orientation == Qt.Vertical ? container.width - 4 : size() - y: container.orientation == Qt.Vertical ? position() : 2 - height: container.orientation == Qt.Vertical ? size() : container.height - 4 - } - - states: State { - name: "visible" - when: container.orientation == Qt.Vertical ? scrollArea.movingVertically : scrollArea.movingHorizontally - PropertyChanges { target: container; opacity: 1.0 } - } - - transitions: Transition { - from: "visible"; to: "" - NumberAnimation { properties: "opacity"; duration: 600 } - } -} diff --git a/examples/declarative/rssnews/content/images/busy.png b/examples/declarative/rssnews/content/images/busy.png deleted file mode 100644 index 664c2b1491..0000000000 Binary files a/examples/declarative/rssnews/content/images/busy.png and /dev/null differ diff --git a/examples/declarative/rssnews/content/images/scrollbar.png b/examples/declarative/rssnews/content/images/scrollbar.png deleted file mode 100644 index 0228dcf9eb..0000000000 Binary files a/examples/declarative/rssnews/content/images/scrollbar.png and /dev/null differ diff --git a/examples/declarative/rssnews/rssnews.qml b/examples/declarative/rssnews/rssnews.qml deleted file mode 100644 index 491cefda07..0000000000 --- a/examples/declarative/rssnews/rssnews.qml +++ /dev/null @@ -1,112 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 -import QtQuick.XmlListModel 2.0 -import "content" - -Rectangle { - id: window - width: 800; height: 480 - - property string currentFeed: "rss.news.yahoo.com/rss/topstories" - property bool loading: feedModel.status == XmlListModel.Loading - - RssFeeds { id: rssFeeds } - - XmlListModel { - id: feedModel - source: "http://" + window.currentFeed - query: "/rss/channel/item" - - XmlRole { name: "title"; query: "title/string()" } - XmlRole { name: "link"; query: "link/string()" } - XmlRole { name: "description"; query: "description/string()" } - } - - Row { - Rectangle { - width: 220; height: window.height - color: "#efefef" - - ListView { - focus: true - id: categories - anchors.fill: parent - model: rssFeeds - footer: quitButtonDelegate - delegate: CategoryDelegate {} - highlight: Rectangle { color: "steelblue" } - highlightMoveSpeed: 9999999 - } - ScrollBar { - scrollArea: categories; height: categories.height; width: 8 - anchors.right: categories.right - } - } - ListView { - id: list - width: window.width - 220; height: window.height - model: feedModel - delegate: NewsDelegate {} - } - } - Component { - id: quitButtonDelegate - Item { - width: categories.width; height: 60 - Text { - text: "Quit" - font { family: "Helvetica"; pixelSize: 16; bold: true } - anchors { - left: parent.left; leftMargin: 15 - verticalCenter: parent.verticalCenter - } - } - MouseArea { - anchors.fill: parent - onClicked: Qt.quit() - } - } - } - ScrollBar { scrollArea: list; height: list.height; width: 8; anchors.right: window.right } - Rectangle { x: 220; height: window.height; width: 1; color: "#cccccc" } -} diff --git a/examples/declarative/rssnews/rssnews.qmlproject b/examples/declarative/rssnews/rssnews.qmlproject deleted file mode 100644 index 5becbdaed0..0000000000 --- a/examples/declarative/rssnews/rssnews.qmlproject +++ /dev/null @@ -1,16 +0,0 @@ -import QmlProject 1.1 - -Project { - mainFile: "rssnews.qml" - - /* Include .qml, .js, and image files from current directory and subdirectories */ - QmlFiles { - directory: "." - } - JavaScriptFiles { - directory: "." - } - ImageFiles { - directory: "." - } -} diff --git a/examples/declarative/samegame/content/BoomBlock.qml b/examples/declarative/samegame/content/BoomBlock.qml deleted file mode 100644 index 47f86bd81b..0000000000 --- a/examples/declarative/samegame/content/BoomBlock.qml +++ /dev/null @@ -1,112 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 -import QtQuick.Particles 2.0 - -Item { - id: block - property bool dying: false - property bool spawned: false - property int type: 0 - property ParticleSystem particleSystem - - Behavior on x { - enabled: spawned; - SpringAnimation{ spring: 2; damping: 0.2 } - } - Behavior on y { - SpringAnimation{ spring: 2; damping: 0.2 } - } - - Image { - id: img - source: { - if(type == 0){ - "pics/redStone.png"; - } else if(type == 1) { - "pics/blueStone.png"; - } else { - "pics/greenStone.png"; - } - } - opacity: 0 - Behavior on opacity { NumberAnimation { duration: 200 } } - anchors.fill: parent - } - Emitter { - id: particles - system: particleSystem - group: { - if(type == 0){ - "red"; - } else if (type == 1) { - "blue"; - } else { - "green"; - } - } - anchors.fill: parent - - speed: TargetDirection{targetX: block.width/2; targetY: block.height/2; magnitude: -60; magnitudeVariation: 60} - shape: EllipseShape{fill:true} - enabled: false; - lifeSpan: 700; lifeSpanVariation: 100 - emitRate: 1000 - maximumEmitted: 100 //only fires 0.1s bursts (still 2x old number) - size: 28 - endSize: 14 - } - - states: [ - State { - name: "AliveState"; when: spawned == true && dying == false - PropertyChanges { target: img; opacity: 1 } - }, - - State { - name: "DeathState"; when: dying == true - StateChangeScript { script: {particleSystem.paused = false; particles.pulse(100);} } - PropertyChanges { target: img; opacity: 0 } - StateChangeScript { script: block.destroy(1000); } - } - ] -} diff --git a/examples/declarative/samegame/content/Button.qml b/examples/declarative/samegame/content/Button.qml deleted file mode 100644 index b305455c92..0000000000 --- a/examples/declarative/samegame/content/Button.qml +++ /dev/null @@ -1,75 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -Rectangle { - id: container - - property string text: "Button" - - signal clicked - - width: buttonLabel.width + 20; height: buttonLabel.height + 20 - smooth: true - border { width: 1; color: Qt.darker(activePalette.button) } - radius: 8 - color: activePalette.button - - gradient: Gradient { - GradientStop { - position: 0.0 - color: { - if (mouseArea.pressed) - return activePalette.dark - else - return activePalette.light - } - } - GradientStop { position: 1.0; color: activePalette.button } - } - - MouseArea { id: mouseArea; anchors.fill: parent; onClicked: container.clicked() } - - Text { - id: buttonLabel; text: container.text; anchors.centerIn: container; color: activePalette.buttonText; font.pixelSize: 24 - } -} diff --git a/examples/declarative/samegame/content/Dialog.qml b/examples/declarative/samegame/content/Dialog.qml deleted file mode 100644 index 80e5984bfe..0000000000 --- a/examples/declarative/samegame/content/Dialog.qml +++ /dev/null @@ -1,81 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -Rectangle { - id: page - anchors.centerIn: parent - - property Item text: dialogText - property bool open: false - - signal closed - signal opened - function forceClose() { - if(!open) - return; //already closed - page.open = false; - page.closed(); - page.opacity = 0; - } - - function show(txt) { - page.open = true; - page.opened(); - dialogText.text = txt; - page.opacity = 1; - } - - width: dialogText.width + 20; height: dialogText.height + 20 - color: "white" - border.width: 1 - opacity: 0 - visible: opacity > 0 - Behavior on opacity { - NumberAnimation { duration: 1000 } - } - - Text { id: dialogText; anchors.centerIn: parent; text: "Hello World!" } - - MouseArea { anchors.fill: parent; onClicked: forceClose(); } -} - diff --git a/examples/declarative/samegame/content/GameArea.qml b/examples/declarative/samegame/content/GameArea.qml deleted file mode 100644 index a43d55117a..0000000000 --- a/examples/declarative/samegame/content/GameArea.qml +++ /dev/null @@ -1,92 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 -import QtQuick.Particles 2.0 -import "samegame.js" as Logic - -Item { - id: gameCanvas - property int score: 0 - property int blockSize: 40 - property ParticleSystem ps: particleSystem - Image { - id: background - anchors.fill: parent - z: -1 - source: "pics/background.png" - fillMode: Image.PreserveAspectCrop - } - - width: 480 - height: 800 - MouseArea { - anchors.fill: parent; onClicked: Logic.handleClick(mouse.x,mouse.y); - } - ParticleSystem{ - id: particleSystem; - onEmptyChanged: if (empty) paused = true; - z:2 - ImageParticle { - groups: ["red"] - color: Qt.darker("red");//Actually want desaturated... - source: "pics/particle.png" - colorVariation: 0.4 - alpha: 0.1 - } - ImageParticle { - groups: ["green"] - color: Qt.darker("green");//Actually want desaturated... - source: "pics/particle.png" - colorVariation: 0.4 - alpha: 0.1 - } - ImageParticle { - groups: ["blue"] - color: Qt.darker("blue");//Actually want desaturated... - source: "pics/particle.png" - colorVariation: 0.4 - alpha: 0.1 - } - anchors.fill: parent - } -} - diff --git a/examples/declarative/samegame/content/NameInputDialog.qml b/examples/declarative/samegame/content/NameInputDialog.qml deleted file mode 100644 index 602e69789a..0000000000 --- a/examples/declarative/samegame/content/NameInputDialog.qml +++ /dev/null @@ -1,93 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -import QtQuick 2.0 - -Dialog { - id: nameInputDialog - - property int initialWidth: 0 - property alias name: nameInputText.text - - anchors.centerIn: parent - z: 22; - - Behavior on width { - NumberAnimation {} - enabled: nameInputDialog.initialWidth != 0 - } - - signal accepted(string name) - onClosed: { - if (nameInputText.text != "") - accepted(name); - } - Text { - id: dialogText - anchors { left: nameInputDialog.left; leftMargin: 20; verticalCenter: parent.verticalCenter } - text: "You won! Please enter your name: " - } - MouseArea { - anchors.fill: parent - onClicked: { - if (nameInputText.text == "") - nameInputText.openSoftwareInputPanel(); - else - nameInputDialog.forceClose(); - } - } - - TextInput { - id: nameInputText - anchors { verticalCenter: parent.verticalCenter; left: dialogText.right } - focus: visible - autoScroll: false - maximumLength: 24 - onTextChanged: { - var newWidth = nameInputText.width + dialogText.width + 40; - if ( (newWidth > nameInputDialog.width && newWidth < screen.width) - || (nameInputDialog.width > nameInputDialog.initialWidth) ) - nameInputDialog.width = newWidth; - } - onAccepted: { - nameInputDialog.forceClose(); - } - } -} diff --git a/examples/declarative/samegame/content/pics/background.png b/examples/declarative/samegame/content/pics/background.png deleted file mode 100644 index 3734a27744..0000000000 Binary files a/examples/declarative/samegame/content/pics/background.png and /dev/null differ diff --git a/examples/declarative/samegame/content/pics/blueStone.png b/examples/declarative/samegame/content/pics/blueStone.png deleted file mode 100644 index 20e43c75b6..0000000000 Binary files a/examples/declarative/samegame/content/pics/blueStone.png and /dev/null differ diff --git a/examples/declarative/samegame/content/pics/greenStone.png b/examples/declarative/samegame/content/pics/greenStone.png deleted file mode 100644 index b568a1900c..0000000000 Binary files a/examples/declarative/samegame/content/pics/greenStone.png and /dev/null differ diff --git a/examples/declarative/samegame/content/pics/particle.png b/examples/declarative/samegame/content/pics/particle.png deleted file mode 100644 index 5c83896d22..0000000000 Binary files a/examples/declarative/samegame/content/pics/particle.png and /dev/null differ diff --git a/examples/declarative/samegame/content/pics/redStone.png b/examples/declarative/samegame/content/pics/redStone.png deleted file mode 100644 index 36b09a2686..0000000000 Binary files a/examples/declarative/samegame/content/pics/redStone.png and /dev/null differ diff --git a/examples/declarative/samegame/content/pics/yellowStone.png b/examples/declarative/samegame/content/pics/yellowStone.png deleted file mode 100644 index b1ce76212c..0000000000 Binary files a/examples/declarative/samegame/content/pics/yellowStone.png and /dev/null differ diff --git a/examples/declarative/samegame/content/samegame.js b/examples/declarative/samegame/content/samegame.js deleted file mode 100755 index 611767584b..0000000000 --- a/examples/declarative/samegame/content/samegame.js +++ /dev/null @@ -1,290 +0,0 @@ -/* This script file handles the game logic */ -.pragma library -.import QtQuick.LocalStorage 2.0 as Sql - -var maxColumn = 10; -var maxRow = 15; -var maxIndex = maxColumn*maxRow; -var board = new Array(maxIndex); -var blockSrc = "BoomBlock.qml"; -var scoresURL = ""; -var gameDuration; -var component = Qt.createComponent(blockSrc); -var highScoreBar = -1; -var gameCanvas; -var nameInputDialog = null; -var dialog = null; - -// Index function used instead of a 2D array -function index(column, row) -{ - return column + row * maxColumn; -} - -function timeStr(msecs) -{ - var secs = Math.floor(msecs/1000); - var m = Math.floor(secs/60); - var ret = "" + m + "m " + (secs%60) + "s"; - return ret; -} - -function startNewGame(gc) -{ - gameCanvas = gc; - // Delete blocks from previous game - for (var i = 0; i < maxIndex; i++) { - if (board[i] != null) - board[i].destroy(); - } - - // Calculate board size - maxColumn = Math.floor(gameCanvas.width/gameCanvas.blockSize); - maxRow = Math.floor(gameCanvas.height/gameCanvas.blockSize); - maxIndex = maxRow * maxColumn; - - // Close dialogs - if(nameInputDialog != null) - nameInputDialog.forceClose(); - if(dialog != null) - dialog.forceClose(); - - // Initialize Board - board = new Array(maxIndex); - gameCanvas.score = 0; - for (var column = 0; column < maxColumn; column++) { - for (var row = 0; row < maxRow; row++) { - board[index(column, row)] = null; - createBlock(column, row); - } - } - gameDuration = new Date(); -} - -var fillFound; // Set after a floodFill call to the number of blocks found -var floodBoard; // Set to 1 if the floodFill reaches off that node - -// NOTE: Be careful with vars named x,y, as the calling object's x,y are still in scope -function handleClick(x,y) -{ - if(gameCanvas == undefined){ - console.log("But the game hasn't started yet!"); - return; - } - var column = Math.floor(x/gameCanvas.blockSize); - var row = Math.floor(y/gameCanvas.blockSize); - if (column >= maxColumn || column < 0 || row >= maxRow || row < 0) - return; - if (board[index(column, row)] == null) - return; - // If it's a valid block, remove it and all connected (does nothing if it's not connected) - floodFill(column,row, -1); - if (fillFound <= 0) - return; - gameCanvas.score += (fillFound - 1) * (fillFound - 1); - shuffleDown(); - victoryCheck(); -} - -function floodFill(column,row,type) -{ - if (board[index(column, row)] == null) - return; - var first = false; - if (type == -1) { - first = true; - type = board[index(column,row)].type; - - // Flood fill initialization - fillFound = 0; - floodBoard = new Array(maxIndex); - } - if (column >= maxColumn || column < 0 || row >= maxRow || row < 0) - return; - if (floodBoard[index(column, row)] == 1 || (!first && type != board[index(column, row)].type)) - return; - floodBoard[index(column, row)] = 1; - floodFill(column + 1, row, type); - floodFill(column - 1, row, type); - floodFill(column, row + 1, type); - floodFill(column, row - 1, type); - if (first == true && fillFound == 0) - return; // Can't remove single blocks - board[index(column, row)].dying = true; - board[index(column, row)] = null; - fillFound += 1; -} - -function shuffleDown() -{ - // Fall down - for (var column = 0; column < maxColumn; column++) { - var fallDist = 0; - for (var row = maxRow - 1; row >= 0; row--) { - if (board[index(column,row)] == null) { - fallDist += 1; - } else { - if (fallDist > 0) { - var obj = board[index(column, row)]; - obj.y = (row + fallDist) * gameCanvas.blockSize; - board[index(column, row + fallDist)] = obj; - board[index(column, row)] = null; - } - } - } - } - // Fall to the left - fallDist = 0; - for (column = 0; column < maxColumn; column++) { - if (board[index(column, maxRow - 1)] == null) { - fallDist += 1; - } else { - if (fallDist > 0) { - for (row = 0; row < maxRow; row++) { - obj = board[index(column, row)]; - if (obj == null) - continue; - obj.x = (column - fallDist) * gameCanvas.blockSize; - board[index(column - fallDist,row)] = obj; - board[index(column, row)] = null; - } - } - } - } -} - -function victoryCheck() -{ - // Awards bonuses for no blocks left - var deservesBonus = true; - for (var column = maxColumn - 1; column >= 0; column--) - if (board[index(column, maxRow - 1)] != null) - deservesBonus = false; - if (deservesBonus) - gameCanvas.score += 500; - // Checks for game over - if (deservesBonus || !(floodMoveCheck(0, maxRow - 1, -1))) { - gameDuration = new Date() - gameDuration; - if(nameInputDialog == null){ - nameInputDialog = Qt.createQmlObject('import "."; import "samegame.js" as Logic; NameInputDialog{onAccepted: Logic.saveHighScore(name)}', gameCanvas, "highscoredialog.qml"); - } - if(dialog == null){ - dialog = Qt.createComponent("Dialog.qml").createObject(gameCanvas); - } - initHighScoreBar(); - if(gameCanvas.score > highScoreBar){ - nameInputDialog.show("You won! Please enter your name: "); - nameInputDialog.initialWidth = nameInputDialog.text.width + 20; - if (nameInputDialog.name == "") - nameInputDialog.width = nameInputDialog.initialWidth; - nameInputDialog.text.opacity = 0; // Just a spacer - }else{ - dialog.show("You won!"); - } - } -} - -// Only floods up and right, to see if it can find adjacent same-typed blocks -function floodMoveCheck(column, row, type) -{ - if (column >= maxColumn || column < 0 || row >= maxRow || row < 0) - return false; - if (board[index(column, row)] == null) - return false; - var myType = board[index(column, row)].type; - if (type == myType) - return true; - return floodMoveCheck(column + 1, row, myType) || - floodMoveCheck(column, row - 1, board[index(column, row)].type); -} - -function createBlock(column,row) -{ - // Note that we don't wait for the component to become ready. This will - // only work if the block QML is a local file. Otherwise the component will - // not be ready immediately. There is a statusChanged signal on the - // component you could use if you want to wait to load remote files. - if(component.status == 1){ - var dynamicObject = component.createObject(gameCanvas, - {"type": Math.floor(Math.random() * 3), - "x": column*gameCanvas.blockSize, - "width": gameCanvas.blockSize, - "height": gameCanvas.blockSize, - "particleSystem": gameCanvas.ps}); - if(dynamicObject == null){ - console.log("error creating block"); - console.log(component.errorString()); - return false; - } - dynamicObject.y = row*gameCanvas.blockSize; - dynamicObject.spawned = true; - - board[index(column,row)] = dynamicObject; - }else{ - console.log("error loading block component"); - console.log(component.errorString()); - return false; - } - return true; -} - -function initHighScoreBar() -{ - var db = Sql.openDatabaseSync( - "SameGameScores", - "1.0", - "Local SameGame High Scores", - 100 - ); - db.transaction( - function(tx) { - tx.executeSql('CREATE TABLE IF NOT EXISTS Scores(name TEXT, score NUMBER, gridSize TEXT, time NUMBER)'); - // Only show results for the current grid size - var rs = tx.executeSql('SELECT * FROM Scores WHERE gridSize = "' - + maxColumn + "x" + maxRow + '" ORDER BY score desc LIMIT 10'); - if(rs.rows.length < 10) - highScoreBar = 0; - else - highScoreBar = rs.rows.item(rs.rows.length - 1).score; - } - ); -} - -function saveHighScore(name) -{ - if (scoresURL != "") - sendHighScore(name); - // Offline storage - var db = Sql.openDatabaseSync( - "SameGameScores", - "1.0", - "Local SameGame High Scores", - 100 - ); - var dataStr = "INSERT INTO Scores VALUES(?, ?, ?, ?)"; - var data = [ - name, - gameCanvas.score, - maxColumn + "x" + maxRow, - Math.floor(gameDuration / 1000) - ]; - db.transaction( - function(tx) { - tx.executeSql('CREATE TABLE IF NOT EXISTS Scores(name TEXT, score NUMBER, gridSize TEXT, time NUMBER)'); - tx.executeSql(dataStr, data); - - // Only show results for the current grid size - var rs = tx.executeSql('SELECT * FROM Scores WHERE gridSize = "' - + maxColumn + "x" + maxRow + '" ORDER BY score desc LIMIT 10'); - var r = "\nHIGH SCORES for this grid size\n\n" - for (var i = 0; i < rs.rows.length; i++) { - r += (i+1) + ". " + rs.rows.item(i).name + ' got ' - + rs.rows.item(i).score + ' points in ' - + rs.rows.item(i).time + ' seconds.\n'; - } - if(rs.rows.length == 10) - highScoreBar = rs.rows.item(9).score; - dialog.show(r); - } - ); -} diff --git a/examples/declarative/samegame/samegame.qml b/examples/declarative/samegame/samegame.qml deleted file mode 100644 index 201f826a29..0000000000 --- a/examples/declarative/samegame/samegame.qml +++ /dev/null @@ -1,87 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 -import QtQuick.Particles 2.0 -import "content" -import "content/samegame.js" as Logic - -Rectangle { - id: screen - width: 480; height: 640 - - SystemPalette { id: activePalette } - - GameArea { - id: gameCanvas - width: parent.width - anchors { top: parent.top; bottom: toolBar.top } - } - - Rectangle { - id: toolBar - width: parent.width; height: 80 - color: activePalette.window - anchors.bottom: screen.bottom - - Button { - id: newGameButton - anchors { left: parent.left; leftMargin: 12; verticalCenter: parent.verticalCenter } - text: "New Game" - onClicked: Logic.startNewGame(gameCanvas) - } - - Button { - text: "Quit" - anchors { left: newGameButton.right; leftMargin: 12; verticalCenter: parent.verticalCenter } - onClicked: Qt.quit(); - } - - Text { - id: score - anchors { right: parent.right; rightMargin: 12; verticalCenter: parent.verticalCenter } - text: "Score: " + gameCanvas.score - font.bold: true - font.pixelSize: 24 - color: activePalette.windowText - } - } -} diff --git a/examples/declarative/samegame/samegame.qmlproject b/examples/declarative/samegame/samegame.qmlproject deleted file mode 100644 index 42ffacf4f8..0000000000 --- a/examples/declarative/samegame/samegame.qmlproject +++ /dev/null @@ -1,16 +0,0 @@ -import QmlProject 1.1 - -Project { - mainFile: "samegame.qml" - - /* Include .qml, .js, and image files from current directory and subdirectories */ - QmlFiles { - directory: "." - } - JavaScriptFiles { - directory: "." - } - ImageFiles { - directory: "." - } -} diff --git a/examples/declarative/script/script.pro b/examples/declarative/script/script.pro deleted file mode 100644 index 98c1bbc5ee..0000000000 --- a/examples/declarative/script/script.pro +++ /dev/null @@ -1,4 +0,0 @@ -TEMPLATE = subdirs - -SUBDIRS = \ - shell diff --git a/examples/declarative/script/shell/main.cpp b/examples/declarative/script/shell/main.cpp deleted file mode 100644 index 9f0edf4a25..0000000000 --- a/examples/declarative/script/shell/main.cpp +++ /dev/null @@ -1,153 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - - -#include -#include -#include -#include - -#include - -#include - -#include - - -class CommandInterface : public QObject -{ - Q_OBJECT -public: - Q_INVOKABLE void quit() { m_wantsToQuit = true; } - static bool wantsToQuit() { return m_wantsToQuit; } -private: - static bool m_wantsToQuit; -}; - -bool CommandInterface::m_wantsToQuit = false; - - -static void interactive(QJSEngine *eng) -{ - QTextStream qin(stdin, QFile::ReadOnly); - const char *prompt = "qs> "; - - forever { - QString line; - - printf("%s", prompt); - fflush(stdout); - - line = qin.readLine(); - if (line.isNull()) - break; - - if (line.trimmed().isEmpty()) - continue; - - line += QLatin1Char('\n'); - - QJSValue result = eng->evaluate(line, QLatin1String("typein")); - - fprintf(stderr, "%s\n", qPrintable(result.toString())); - - if (CommandInterface::wantsToQuit()) - break; - } -} - -int main(int argc, char *argv[]) -{ - QGuiApplication app(argc, argv); - QScopedPointer eng(new QJSEngine()); - { - QJSValue globalObject = eng->globalObject(); - QJSValue interface = eng->newQObject(new CommandInterface); - globalObject.setProperty("qt", interface); - } - - if (! *++argv) { - interactive(eng.data()); - return EXIT_SUCCESS; - } - - while (const char *arg = *argv++) { - QString fileName = QString::fromLocal8Bit(arg); - - if (fileName == QLatin1String("-i")) { - interactive(eng.data()); - break; - } - - QString contents; - int lineNumber = 1; - - if (fileName == QLatin1String("-")) { - QTextStream stream(stdin, QFile::ReadOnly); - contents = stream.readAll(); - } else { - QFile file(fileName); - if (file.open(QFile::ReadOnly)) { - QTextStream stream(&file); - contents = stream.readAll(); - file.close(); - - // strip off #!/usr/bin/env qjs line - if (contents.startsWith("#!")) { - contents.remove(0, contents.indexOf("\n")); - ++lineNumber; - } - } - } - - if (contents.isEmpty()) - continue; - - QJSValue result = eng->evaluate(contents, fileName, lineNumber); - if (eng->hasUncaughtException()) { - fprintf (stderr, " %s\n\n", qPrintable(result.toString())); - return EXIT_FAILURE; - } - } - - return EXIT_SUCCESS; -} - -#include diff --git a/examples/declarative/script/shell/shell.pro b/examples/declarative/script/shell/shell.pro deleted file mode 100644 index 00191ab3d0..0000000000 --- a/examples/declarative/script/shell/shell.pro +++ /dev/null @@ -1,7 +0,0 @@ -QT += declarative - -win32: CONFIG += console -mac:CONFIG -= app_bundle - -SOURCES += main.cpp - diff --git a/examples/declarative/shadereffects/content/Slider.qml b/examples/declarative/shadereffects/content/Slider.qml deleted file mode 100644 index 4ddc6d3432..0000000000 --- a/examples/declarative/shadereffects/content/Slider.qml +++ /dev/null @@ -1,93 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the Declarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -Item { - property real value: bar.x / (foo.width - bar.width) - Item { - id: foo - width: parent.width - 4 - height: 6 - anchors.centerIn: parent - - Rectangle { - height: parent.height - anchors.left: parent.left - anchors.right: bar.horizontalCenter - color: "blue" - radius: 3 - } - Rectangle { - height: parent.height - anchors.left: bar.horizontalCenter - anchors.right: parent.right - color: "gray" - radius: 3 - } - Rectangle { - anchors.fill: parent - color: "transparent" - radius: 3 - border.width: 2 - border.color: "black" - } - - Rectangle { - id: bar - y: -7 - width: 20 - height: 20 - radius: 15 - color: "white" - border.width: 2 - border.color: "black" - MouseArea { - anchors.fill: parent - drag.target: parent - drag.axis: Drag.XAxis - drag.minimumX: 0 - drag.maximumX: foo.width - parent.width - } - } - } -} - diff --git a/examples/declarative/shadereffects/content/face-smile.png b/examples/declarative/shadereffects/content/face-smile.png deleted file mode 100644 index 3d66d72578..0000000000 Binary files a/examples/declarative/shadereffects/content/face-smile.png and /dev/null differ diff --git a/examples/declarative/shadereffects/content/qt-logo.png b/examples/declarative/shadereffects/content/qt-logo.png deleted file mode 100644 index 7d3e97eb36..0000000000 Binary files a/examples/declarative/shadereffects/content/qt-logo.png and /dev/null differ diff --git a/examples/declarative/shadereffects/shadereffects.qml b/examples/declarative/shadereffects/shadereffects.qml deleted file mode 100644 index 842e42b89f..0000000000 --- a/examples/declarative/shadereffects/shadereffects.qml +++ /dev/null @@ -1,300 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the Declarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 -import "content" - -Image { - width: 640 - height: 360 - source: "../snake/content/pics/background.png" - - ShaderEffectSource { - id: theSource - sourceItem: theItem - smooth: true - } - - function saturate(x) { - return Math.min(Math.max(x, 0), 1) - } - - function sliderToColor(x) { - return Qt.rgba(saturate(Math.max(2 - 6 * x, 6 * x - 4)), - saturate(Math.min(6 * x, 4 - 6 * x)), - saturate(Math.min(6 * x - 2, 6 - 6 * x))) - } - - Grid { - anchors.centerIn: parent - columns: 3 - - Item { - id: theItem - width: 180 - height: 180 - ListView { - anchors.centerIn: parent - width: 160 - height: 140 - clip: true - snapMode: ListView.SnapOneItem - model: VisualItemModel { - Text { - width: 160 - height: 140 - horizontalAlignment: Text.AlignHCenter - verticalAlignment: Text.AlignVCenter - font.pixelSize: 120 - font.family: "Times" - color: "blue" - text: "Qt" - } - Image { - width: 160 - height: 140 - source: "content/qt-logo.png" - smooth: true - } - Image { - width: 160 - height: 140 - source: "content/face-smile.png" - smooth: true - } - } - } - } - ShaderEffect { - width: 180 - height: 180 - property variant source: theSource - property real amplitude: 0.04 * wobbleSlider.value - property real frequency: 20 - property real time: 0 - NumberAnimation on time { loops: Animation.Infinite; from: 0; to: Math.PI * 2; duration: 600 } - fragmentShader: - "uniform lowp float qt_Opacity;" + - "uniform highp float amplitude;" + - "uniform highp float frequency;" + - "uniform highp float time;" + - "uniform sampler2D source;" + - "varying highp vec2 qt_TexCoord0;" + - "void main() {" + - " highp vec2 p = sin(time + frequency * qt_TexCoord0);" + - " gl_FragColor = texture2D(source, qt_TexCoord0 + amplitude * vec2(p.y, -p.x)) * qt_Opacity;" + - "}" - Slider { - id: wobbleSlider - anchors.left: parent.left - anchors.right: parent.right - anchors.bottom: parent.bottom - height: 40 - } - } - ShaderEffect { - width: 180 - height: 180 - property variant source: theSource - property variant shadow: ShaderEffectSource { - smooth: true - sourceItem: ShaderEffect { - width: theItem.width - height: theItem.height - property variant delta: Qt.size(0.0, 1.0 / height) - property variant source: ShaderEffectSource { - smooth: true - sourceItem: ShaderEffect { - width: theItem.width - height: theItem.height - property variant delta: Qt.size(1.0 / width, 0.0) - property variant source: theSource - fragmentShader: " - uniform lowp float qt_Opacity; - uniform sampler2D source; - uniform highp vec2 delta; - varying highp vec2 qt_TexCoord0; - void main() { - gl_FragColor =(0.0538 * texture2D(source, qt_TexCoord0 - 3.182 * delta) - + 0.3229 * texture2D(source, qt_TexCoord0 - 1.364 * delta) - + 0.2466 * texture2D(source, qt_TexCoord0) - + 0.3229 * texture2D(source, qt_TexCoord0 + 1.364 * delta) - + 0.0538 * texture2D(source, qt_TexCoord0 + 3.182 * delta)) * qt_Opacity; - }" - } - } - fragmentShader: " - uniform lowp float qt_Opacity; - uniform sampler2D source; - uniform highp vec2 delta; - varying highp vec2 qt_TexCoord0; - void main() { - gl_FragColor =(0.0538 * texture2D(source, qt_TexCoord0 - 3.182 * delta) - + 0.3229 * texture2D(source, qt_TexCoord0 - 1.364 * delta) - + 0.2466 * texture2D(source, qt_TexCoord0) - + 0.3229 * texture2D(source, qt_TexCoord0 + 1.364 * delta) - + 0.0538 * texture2D(source, qt_TexCoord0 + 3.182 * delta)) * qt_Opacity; - }" - } - } - property real angle: 0 - property variant offset: Qt.point(15.0 * Math.cos(angle), 15.0 * Math.sin(angle)) - NumberAnimation on angle { loops: Animation.Infinite; from: 0; to: Math.PI * 2; duration: 6000 } - property variant delta: Qt.size(offset.x / width, offset.y / height) - property real darkness: shadowSlider.value - fragmentShader: " - uniform lowp float qt_Opacity; - uniform highp vec2 offset; - uniform sampler2D source; - uniform sampler2D shadow; - uniform highp float darkness; - uniform highp vec2 delta; - varying highp vec2 qt_TexCoord0; - void main() { - lowp vec4 fg = texture2D(source, qt_TexCoord0); - lowp vec4 bg = texture2D(shadow, qt_TexCoord0 + delta); - gl_FragColor = (fg + vec4(0., 0., 0., darkness * bg.a) * (1. - fg.a)) * qt_Opacity; - }" - Slider { - id: shadowSlider - anchors.left: parent.left - anchors.right: parent.right - anchors.bottom: parent.bottom - height: 40 - } - } - ShaderEffect { - width: 180 - height: 180 - property variant source: theSource - property variant delta: Qt.size(0.5 / width, 0.5 / height) - fragmentShader: " - uniform sampler2D source; - uniform highp vec2 delta; - uniform highp float qt_Opacity; - varying highp vec2 qt_TexCoord0; - void main() { - lowp vec4 tl = texture2D(source, qt_TexCoord0 - delta); - lowp vec4 tr = texture2D(source, qt_TexCoord0 + vec2(delta.x, -delta.y)); - lowp vec4 bl = texture2D(source, qt_TexCoord0 - vec2(delta.x, -delta.y)); - lowp vec4 br = texture2D(source, qt_TexCoord0 + delta); - lowp vec4 gx = (tl + bl) - (tr + br); - lowp vec4 gy = (tl + tr) - (bl + br); - gl_FragColor.xyz = vec3(0.); - gl_FragColor.w = clamp(dot(sqrt(gx * gx + gy * gy), vec4(1.)), 0., 1.) * qt_Opacity; - }" - } - ShaderEffect { - width: 180 - height: 180 - property variant source: theSource - property color tint: sliderToColor(colorizeSlider.value) - fragmentShader: " - uniform sampler2D source; - uniform lowp vec4 tint; - uniform lowp float qt_Opacity; - varying highp vec2 qt_TexCoord0; - void main() { - lowp vec4 c = texture2D(source, qt_TexCoord0); - lowp float lo = min(min(c.x, c.y), c.z); - lowp float hi = max(max(c.x, c.y), c.z); - gl_FragColor = qt_Opacity * vec4(mix(vec3(lo), vec3(hi), tint.xyz), c.w); - }" - Slider { - id: colorizeSlider - anchors.left: parent.left - anchors.right: parent.right - anchors.bottom: parent.bottom - height: 40 - } - } - ShaderEffect { - width: 180 - height: 180 - mesh: Qt.size(10, 10) - property variant source: theSource - property real bend: 0 - property real minimize: 0 - property real side: genieSlider.value - SequentialAnimation on bend { - loops: Animation.Infinite - NumberAnimation { to: 1; duration: 700; easing.type: Easing.InOutSine } - PauseAnimation { duration: 1600 } - NumberAnimation { to: 0; duration: 700; easing.type: Easing.InOutSine } - PauseAnimation { duration: 1000 } - } - SequentialAnimation on minimize { - loops: Animation.Infinite - PauseAnimation { duration: 300 } - NumberAnimation { to: 1; duration: 700; easing.type: Easing.InOutSine } - PauseAnimation { duration: 1000 } - NumberAnimation { to: 0; duration: 700; easing.type: Easing.InOutSine } - PauseAnimation { duration: 1300 } - } - vertexShader: " - uniform highp mat4 qt_Matrix; - uniform highp float bend; - uniform highp float minimize; - uniform highp float side; - uniform highp float width; - uniform highp float height; - attribute highp vec4 qt_Vertex; - attribute highp vec2 qt_MultiTexCoord0; - varying highp vec2 qt_TexCoord0; - void main() { - qt_TexCoord0 = qt_MultiTexCoord0; - highp vec4 pos = qt_Vertex; - pos.y = mix(qt_Vertex.y, height, minimize); - highp float t = pos.y / height; - t = (3. - 2. * t) * t * t; - pos.x = mix(qt_Vertex.x, side * width, t * bend); - gl_Position = qt_Matrix * pos; - }" - Slider { - id: genieSlider - anchors.left: parent.left - anchors.right: parent.right - anchors.bottom: parent.bottom - height: 40 - } - } - } -} diff --git a/examples/declarative/shared/Button.qml b/examples/declarative/shared/Button.qml deleted file mode 100644 index a899a1410b..0000000000 --- a/examples/declarative/shared/Button.qml +++ /dev/null @@ -1,64 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -Item { - id: container - - property string text: "Button" - property string subText: "Just a button" - signal clicked - - width: buttonLabel.width + 20; height: col.height + 12 - - MouseArea { id: mouseArea; anchors.fill: parent; onClicked: container.clicked() } - - Column { - spacing: 2 - id: col - Text { - id: buttonLabel; text: container.text; color: "black"; font.pixelSize: 24 - } - Text { - id: buttonLabel2; text: container.subText; color: "black"; font.pixelSize: 12 - } - } -} diff --git a/examples/declarative/shared/LauncherList.qml b/examples/declarative/shared/LauncherList.qml deleted file mode 100644 index 782fcc7ddd..0000000000 --- a/examples/declarative/shared/LauncherList.qml +++ /dev/null @@ -1,101 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -import QtQuick 2.0 - -ListView { - //model is a list of {"name":"somename", "url":"file:///some/url/mainfile.qml"} - //function used to add to model A) to enforce scheme B) to allow Qt.resolveUrl in url assignments - function addExample(name, desc, url) - { - myModel.append({"name":name, "description":desc, "url":url}) - } - function hideExample() - { - ei.visible = false; - } - - clip: true - delegate: SimpleLauncherDelegate{exampleItem: ei} - model: ListModel {id:myModel} - Item { - id: ei - visible: false - clip: true - property url exampleUrl - onExampleUrlChanged: visible = (exampleUrl == '' ? false : true);//Setting exampleUrl automatically shows example - anchors.fill: parent - anchors.bottomMargin: 40 - Rectangle { - id: bg - anchors.fill: parent - color: "white" - } - MouseArea{ - anchors.fill: parent - enabled: ei.visible - //Eats mouse events - } - Loader{ - source: ei.exampleUrl - anchors.fill: parent - } - } - Rectangle { - id: bar - visible: ei.visible - anchors.bottom: parent.bottom - width: parent.width - height: 40 - MouseArea{ - anchors.fill: parent - enabled: ei.visible - //Eats mouse events - } - Image { - source: "back.png" - anchors.verticalCenter: parent.verticalCenter - x: 4 - MouseArea { - anchors.fill: parent - onClicked: ei.exampleUrl = ""; - } - } - } -} diff --git a/examples/declarative/shared/README b/examples/declarative/shared/README deleted file mode 100644 index bf16f238c7..0000000000 --- a/examples/declarative/shared/README +++ /dev/null @@ -1,11 +0,0 @@ -These files are shared between multiple examples as a set of common and -reusuable components. While they do demonstrate the building of reusable -components in QML, they are not official examples themselves. -Consequently they do not have entries in the Qt documentation, and are -documented only through the code comments within the files. Developers -new to QML are strongly encouraged to go through the official examples -before delving into this directory. - -For most application use, see the Qt Quick Components project to find -ready-made Components you can use in your own projects. Qt Declarative -examples do not use them only to avoid external dependencies. diff --git a/examples/declarative/shared/SimpleLauncherDelegate.qml b/examples/declarative/shared/SimpleLauncherDelegate.qml deleted file mode 100644 index c3708fe259..0000000000 --- a/examples/declarative/shared/SimpleLauncherDelegate.qml +++ /dev/null @@ -1,53 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -import QtQuick 2.0 - -Item { - id: container - property Item exampleItem - width: ListView.view.width - height: 64 - Button { - anchors.fill: parent - text: name - subText: description - onClicked: exampleItem.exampleUrl = url; - } -} diff --git a/examples/declarative/shared/back.png b/examples/declarative/shared/back.png deleted file mode 100644 index 506ac42fcf..0000000000 Binary files a/examples/declarative/shared/back.png and /dev/null differ diff --git a/examples/declarative/snake/content/Button.qml b/examples/declarative/snake/content/Button.qml deleted file mode 100644 index dfac45049a..0000000000 --- a/examples/declarative/snake/content/Button.qml +++ /dev/null @@ -1,66 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -Rectangle { - id: container - - signal clicked - property string text: "Button" - - color: activePalette.button; smooth: true - width: txtItem.width + 20; height: txtItem.height + 6 - border.width: 1; border.color: Qt.darker(activePalette.button); radius: 8; - - gradient: Gradient { - GradientStop { - id: topGrad; position: 0.0 - color: if (mr.pressed) { activePalette.dark } else { activePalette.light } } - GradientStop { position: 1.0; color: activePalette.button } - } - - MouseArea { id: mr; anchors.fill: parent; onClicked: container.clicked() } - - Text { - id: txtItem; text: container.text; anchors.centerIn: container; color: activePalette.buttonText - } -} diff --git a/examples/declarative/snake/content/Cookie.qml b/examples/declarative/snake/content/Cookie.qml deleted file mode 100644 index cae53af525..0000000000 --- a/examples/declarative/snake/content/Cookie.qml +++ /dev/null @@ -1,102 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 -import QtQuick.Particles 2.0 - -Item { - id: root - property bool dying: false - property int row; - property int column; - x: margin + column * gridSize - y: margin + row * gridSize - - width: gridSize - height: gridSize - property int value : 1; - - Image { - id: img - anchors.fill: parent - source: "pics/cookie.png" - opacity: 0 - Text { - font.bold: true - anchors.verticalCenter: parent.verticalCenter - anchors.horizontalCenter: parent.horizontalCenter - text: value - } - } - - - ParticleSystem { - width:1; height:1; anchors.centerIn: parent; - ImageParticle { - groups: ["star"] - source: "pics/yellowStar.png" - } - Emitter { - id: particles - anchors.fill: parent - group: "star" - emitRate: 50 - enabled: false - lifeSpan: 700 - acceleration: AngleDirection { angleVariation: 360; magnitude: 200 } - } - } - - states: [ - State{ name: "AliveState"; when: dying == false - PropertyChanges { target: img; opacity: 1 } - }, - State{ name: "DeathState"; when: dying == true - StateChangeScript { script: particles.burst(50); } - PropertyChanges { target: img; opacity: 0 } - } - ] - transitions: [ - Transition { - NumberAnimation { target: img; property: "opacity"; duration: 100 } - } - ] -} diff --git a/examples/declarative/snake/content/HighScoreModel.qml b/examples/declarative/snake/content/HighScoreModel.qml deleted file mode 100644 index af66b99ede..0000000000 --- a/examples/declarative/snake/content/HighScoreModel.qml +++ /dev/null @@ -1,140 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 -import QtQuick.LocalStorage 2.0 as Sql - -// Models a high score table. -// -// Use this component like this: -// -// HighScoreModel { -// id: highScores -// game: "MyCoolGame" -// } -// -// Then use either use the top-score properties: -// -// Text { text: "HI: " + highScores.topScore } -// -// or, use the model in a view: -// -// ListView { -// model: highScore -// delegate: Component { -// ... player ... score ... -// } -// } -// -// Add new scores via: -// -// saveScore(newScore) -// -// or: -// -// savePlayerScore(playerName,newScore) -// -// The best maxScore scores added by this method will be retained in an SQL database, -// and presented in the model and in the topScore/topPlayer properties. -// - -ListModel { - id: model - property string game: "" - property int topScore: 0 - property string topPlayer: "" - property int maxScores: 10 - - function __db() - { - return Sql.openDatabaseSync("HighScoreModel", "1.0", "Generic High Score Functionality for QML", 1000000); - } - function __ensureTables(tx) - { - tx.executeSql('CREATE TABLE IF NOT EXISTS HighScores(game TEXT, score INT, player TEXT)', []); - } - - function fillModel() { - __db().transaction( - function(tx) { - __ensureTables(tx); - var rs = tx.executeSql("SELECT score,player FROM HighScores WHERE game=? ORDER BY score DESC", [game]); - model.clear(); - if (rs.rows.length > 0) { - topScore = rs.rows.item(0).score - topPlayer = rs.rows.item(0).player - for (var i=0; i maxScores) - tx.executeSql("DELETE FROM HighScores WHERE game=? AND score <= ?", - [game, rs.rows.item(maxScores).score]); - } - } - ) - } - - function savePlayerScore(player,score) { - __db().transaction( - function(tx) { - __ensureTables(tx); - tx.executeSql("INSERT INTO HighScores VALUES(?,?,?)", [game,score,player]); - fillModel(); - } - ) - } - - function saveScore(score) { - savePlayerScore("player",score); - } - - function clearScores() { - __db().transaction( - function(tx) { - tx.executeSql("DELETE FROM HighScores WHERE game=?", [game]); - fillModel(); - } - ) - } - - Component.onCompleted: { fillModel() } -} diff --git a/examples/declarative/snake/content/Link.qml b/examples/declarative/snake/content/Link.qml deleted file mode 100644 index 891adafe5e..0000000000 --- a/examples/declarative/snake/content/Link.qml +++ /dev/null @@ -1,129 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 -import QtQuick.Particles 2.0 - -Item { id:link - property bool dying: false - property bool spawned: false - property int type: 0 - property int row: 0 - property int column: 0 - property int rotation; - - width: 40; - height: 40 - - x: margin - 3 + gridSize * column - y: margin - 3 + gridSize * row - Behavior on x { NumberAnimation { duration: spawned ? heartbeatInterval : 0} } - Behavior on y { NumberAnimation { duration: spawned ? heartbeatInterval : 0 } } - - - Item { - id: img - anchors.fill: parent - Image { - source: { - if(type == 1) { - "pics/blueStone.png"; - } else if (type == 2) { - "pics/head.png"; - } else { - "pics/redStone.png"; - } - } - - transform: Rotation { - id: actualImageRotation - origin.x: width/2; origin.y: height/2; - angle: rotation * 90 - Behavior on angle { - RotationAnimation{ - direction: RotationAnimation.Shortest - duration: spawned ? 200 : 0 - } - } - } - } - - Image { - source: "pics/stoneShadow.png" - } - - opacity: 0 - } - - ParticleSystem { - width:1; height:1; anchors.centerIn: parent; - ImageParticle { - groups: ["star"] - source: type == 1 ? "pics/blueStar.png" : "pics/redStar.png" - } - Emitter { - id: particles - anchors.fill: parent - group: "star" - emitRate: 50 - enabled: false - lifeSpan: 700 - acceleration: AngleDirection { angleVariation: 360; magnitude: 200 } - } - } - - states: [ - State{ name: "AliveState"; when: spawned == true && dying == false - PropertyChanges { target: img; opacity: 1 } - }, - State{ name: "DeathState"; when: dying == true - StateChangeScript { script: particles.burst(50); } - PropertyChanges { target: img; opacity: 0 } - } - ] - - transitions: [ - Transition { - NumberAnimation { target: img; property: "opacity"; duration: 200 } - } - ] - -} diff --git a/examples/declarative/snake/content/Skull.qml b/examples/declarative/snake/content/Skull.qml deleted file mode 100644 index ce3d108e04..0000000000 --- a/examples/declarative/snake/content/Skull.qml +++ /dev/null @@ -1,62 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -Image { - property bool spawned: false - property int row; - property int column; - property int verticalMovement; - property int horizontalMovement; - - x: margin + column * gridSize + 2 - y: margin + row * gridSize - 3 - Behavior on x { NumberAnimation { duration: spawned ? halfbeatInterval : 0} } - Behavior on y { NumberAnimation { duration: spawned ? halfbeatInterval : 0 } } - - opacity: spawned ? 1 : 0 - Behavior on opacity { NumberAnimation { duration: 200 } } - - source: "pics/skull.png" - width: 24 - height: 40 -} diff --git a/examples/declarative/snake/content/pics/README b/examples/declarative/snake/content/pics/README deleted file mode 100644 index 0215132caa..0000000000 --- a/examples/declarative/snake/content/pics/README +++ /dev/null @@ -1 +0,0 @@ -snake.jpg: This image is based on the picture "Eastern Green Mamba.jpg" from the free media databse Wikimedia Commons and is published under the terms of the GNU Free Documentation License. The original picture was taken by Danleo. diff --git a/examples/declarative/snake/content/pics/background.png b/examples/declarative/snake/content/pics/background.png deleted file mode 100644 index 72dffaa843..0000000000 Binary files a/examples/declarative/snake/content/pics/background.png and /dev/null differ diff --git a/examples/declarative/snake/content/pics/blueStar.png b/examples/declarative/snake/content/pics/blueStar.png deleted file mode 100644 index ba7acabd26..0000000000 Binary files a/examples/declarative/snake/content/pics/blueStar.png and /dev/null differ diff --git a/examples/declarative/snake/content/pics/blueStone.png b/examples/declarative/snake/content/pics/blueStone.png deleted file mode 100644 index 356affdd95..0000000000 Binary files a/examples/declarative/snake/content/pics/blueStone.png and /dev/null differ diff --git a/examples/declarative/snake/content/pics/cookie.png b/examples/declarative/snake/content/pics/cookie.png deleted file mode 100644 index aec2957f34..0000000000 Binary files a/examples/declarative/snake/content/pics/cookie.png and /dev/null differ diff --git a/examples/declarative/snake/content/pics/eyes.svg b/examples/declarative/snake/content/pics/eyes.svg deleted file mode 100644 index 1078692725..0000000000 --- a/examples/declarative/snake/content/pics/eyes.svg +++ /dev/null @@ -1,118 +0,0 @@ - - - - - - - image/svg+xml - - - - - - - - - - - - - - diff --git a/examples/declarative/snake/content/pics/head.png b/examples/declarative/snake/content/pics/head.png deleted file mode 100644 index 550e002687..0000000000 Binary files a/examples/declarative/snake/content/pics/head.png and /dev/null differ diff --git a/examples/declarative/snake/content/pics/pause.png b/examples/declarative/snake/content/pics/pause.png deleted file mode 100644 index 056d97dd17..0000000000 Binary files a/examples/declarative/snake/content/pics/pause.png and /dev/null differ diff --git a/examples/declarative/snake/content/pics/redStar.png b/examples/declarative/snake/content/pics/redStar.png deleted file mode 100644 index cd06854719..0000000000 Binary files a/examples/declarative/snake/content/pics/redStar.png and /dev/null differ diff --git a/examples/declarative/snake/content/pics/redStone.png b/examples/declarative/snake/content/pics/redStone.png deleted file mode 100644 index 9bb7fe4277..0000000000 Binary files a/examples/declarative/snake/content/pics/redStone.png and /dev/null differ diff --git a/examples/declarative/snake/content/pics/skull.png b/examples/declarative/snake/content/pics/skull.png deleted file mode 100644 index 63186167bd..0000000000 Binary files a/examples/declarative/snake/content/pics/skull.png and /dev/null differ diff --git a/examples/declarative/snake/content/pics/snake.jpg b/examples/declarative/snake/content/pics/snake.jpg deleted file mode 100644 index e91a784f71..0000000000 Binary files a/examples/declarative/snake/content/pics/snake.jpg and /dev/null differ diff --git a/examples/declarative/snake/content/pics/star.png b/examples/declarative/snake/content/pics/star.png deleted file mode 100644 index defbde53ca..0000000000 Binary files a/examples/declarative/snake/content/pics/star.png and /dev/null differ diff --git a/examples/declarative/snake/content/pics/stoneShadow.png b/examples/declarative/snake/content/pics/stoneShadow.png deleted file mode 100644 index 1bd56afd04..0000000000 Binary files a/examples/declarative/snake/content/pics/stoneShadow.png and /dev/null differ diff --git a/examples/declarative/snake/content/pics/yellowStar.png b/examples/declarative/snake/content/pics/yellowStar.png deleted file mode 100644 index 52fb9c4b78..0000000000 Binary files a/examples/declarative/snake/content/pics/yellowStar.png and /dev/null differ diff --git a/examples/declarative/snake/content/pics/yellowStone.png b/examples/declarative/snake/content/pics/yellowStone.png deleted file mode 100644 index c56124a895..0000000000 Binary files a/examples/declarative/snake/content/pics/yellowStone.png and /dev/null differ diff --git a/examples/declarative/snake/content/snake.js b/examples/declarative/snake/content/snake.js deleted file mode 100644 index 107c9f4591..0000000000 --- a/examples/declarative/snake/content/snake.js +++ /dev/null @@ -1,316 +0,0 @@ - -var snake = new Array; -var board = new Array; -var links = new Array; -var scheduledDirections = new Array; -var numRows = 1; -var numColumns = 1; -var linkComponent = Qt.createComponent("Link.qml"); -var cookieComponent = Qt.createComponent("Cookie.qml"); -var cookie; -var linksToGrow = 0; -var linksToDie = 0; -var waitForCookie = 0; -var growType = 0; -var skullMovementsBeforeDirectionChange = 0; - - -function rand(n) -{ - return (Math.floor(Math.random() * n)); -} - -function scheduleDirection(dir) -{ - if (state == "starting") { - direction = dir; - headDirection = direction; - head.rotation = headDirection; - } else if (state == "running"){ - direction = dir; - if(scheduledDirections[scheduledDirections.length-1]!=direction) - scheduledDirections.push(direction); - } -} - -function startNewGame() -{ - if (state == "starting") { - return; - } - - if (activeGame) { - endGame(); - startNewGameTimer.running = true; - return; - } - - state = "starting"; - - numRows = numRowsAvailable; - numColumns = numColumnsAvailable; - board = new Array(numRows * numColumns); - snake = new Array; - scheduledDirections = new Array; - growType = 0; - - skull.z = numRows * numColumns + 1; - - for (var i = 0; i < numRows * numColumns; ++i) { - if (i < links.length) { - var link = links[i]; - link.spawned = false; - link.dying = false; - } else { - if(linkComponent.status != Component.Ready) { - if(linkComponent.status == Component.Error) - console.log(linkComponent.errorString()); - else - console.log("Still loading linkComponent"); - continue;//TODO: Better error handling? - } - var link = linkComponent.createObject(playfield); - link.z = numRows * numColumns + 1 - i; - link.type = i == 0 ? 2 : 0; - link.spawned = false; - link.dying = false; - links.push(link); - } - } - - head = links[0]; - snake.push(head); - head.row = numRows/2 -1; - head.column = numColumns/2 -1; - head.spawned = true; - - linksToGrow = 5; - linksToDie = 0; - waitForCookie = 5; - score = 0; - startHeartbeatTimer.running = true; -} - -function endGame() -{ - activeGame = false; - for(var i in snake) - snake[i].dying = true; - if (cookie) { - cookie.dying = true; - cookie = 0; - } - lastScore = score; - highScores.saveScore(lastScore); - state = ""; -} - -function move() { - - if (!head) - return; - - var dir = direction; - - if (scheduledDirections.length) { - dir = scheduledDirections.shift(); - } - - if (state == "starting") { - var turn = (dir - headDirection); - head.rotation += turn == -3 ? 1 : (turn == 3 ? -1 : turn ); - headDirection = dir; - return; - } - - var row = head.row; - var column = head.column; - - if (dir == 0) { - row = row - 1; - } else if (dir == 1) { - column = column + 1 - } else if (dir == 2) { - row = row + 1; - } else if (dir == 3) { - column = column - 1; - } - - //validate the new position - if (row < 0 || row >= numRows - || column < 0 || column >= numColumns - || (row == skull.row && column == skull.column) - || !isFree(row, column)) { - var turn = (dir - headDirection); - head.rotation += turn == -3 ? 1 : (turn == 3 ? -1 : turn ); - headDirection = dir; - endGame(); - return; - } - - var newLink; - if (linksToGrow > 0) { - --linksToGrow; - newLink = links[snake.length]; - newLink.spawned = false; - newLink.rotation = snake[snake.length-1].rotation; - newLink.type = growType; - newLink.dying = false; - snake.push(newLink); - } else { - var lastLink = snake[snake.length-1]; - board[lastLink.row * numColumns + lastLink.column] = undefined; - } - - if (waitForCookie > 0) { - if (--waitForCookie == 0) - createCookie(cookie? (cookie.value+1) : 1); - } - - for (var i = snake.length-1; i > 0; --i) { - snake[i].row = snake[i-1].row; - snake[i].column = snake[i-1].column; - snake[i].rotation = snake[i-1].rotation; - } - - if (newLink) { - newLink.spawned = true; - } - - // move the head - head.row = row; - head.column = column; - board[row * numColumns + column] = head; - - var turn = (dir - headDirection); - head.rotation += turn == -3 ? 1 : (turn == 3 ? -1 : turn ); - headDirection = dir; - - var value = testCookie(row, column); - if (value > 0) { - linksToGrow += value; - score += value; - } -} - -function isFree(row, column) -{ - return board[row * numColumns + column] == undefined; -} - -function isHead(row, column) -{ - return head.column == column && head.row == row; -} - -function testCookie(row, column) -{ - if (cookie && !cookie.dying && cookie.row == row && cookie.column == column) { - var value = cookie.value; - waitForCookie = value; - growType = snake[snake.length-1].type == 1 ? 0 : 1; - cookie.dying = true; - cookie.z = numRows * numColumns + 2; - return value; - } - return 0; -} - -function moveSkull() -{ - - if (linksToDie > 0) { - --linksToDie; - var link = snake.pop(); - link.dying = true; - board[link.row * numColumns + link.column] = undefined; - if (score > 0) - --score; - if (snake.length == 0) { - endGame(); - return; - } - } - - var row = skull.row; - var column = skull.column; - if (isHead(row, column)) { - endGame(); - return; - } - row += skull.verticalMovement; - column += skull.horizontalMovement; - - var attempts = 4; - - while (skullMovementsBeforeDirectionChange == 0 || row < 0 || row >= numRows - || column < 0 || column >= numColumns - || (!isFree(row, column) && !isHead(row, column))) { - var d = rand(8); - skull.verticalMovement = 0; - skull.horizontalMovement = 0; - skullMovementsBeforeDirectionChange = rand(20)+1; - if (d == 0) { - skull.verticalMovement = -1 - } else if (d == 1) { - skull.horizontalMovement = -1; - } else if (d == 2) { - skull.verticalMovement = 1 - } else if (d == 3){ - skull.horizontalMovement = 1; - } else if (cookie) { - var rd = cookie.row - skull.row; - var rc = cookie.column - skull.column; - if (Math.abs(rd) > Math.abs(rc)) { - skull.verticalMovement = rd > 0 ? 1 : -1; - skullMovementsBeforeDirectionChange = Math.abs(rd); - } else { - skull.horizontalMovement= rc > 0 ? 1 : -1; - skullMovementsBeforeDirectionChange = Math.abs(rc); - } - } - row = skull.row + skull.verticalMovement; - column = skull.column + skull.horizontalMovement; - if (--attempts == 0) - return; - } - - skull.row = row; - skull.column = column; - --skullMovementsBeforeDirectionChange; - var value = testCookie(row, column); - if (value > 0) - linksToDie += value/2; - - if (isHead(row, column)) - endGame(); -} - -function createCookie(value) { - if (numRows * numColumns - snake.length < 10) - return; - - var column = rand(numColumns); - var row = rand(numRows); - while (!isFree(row, column)) { - column++; - if (column == numColumns) { - column = 0; - row++; - if (row == numRows) - row = 0; - } - } - - if(cookieComponent.status != Component.Ready) { - if(cookieComponent.status == Component.Error) - console.log(cookieComponent.errorString()); - else - console.log("Still loading cookieComponent"); - return;//TODO: Better error handling? - } - cookie = cookieComponent.createObject(head.parent); - cookie.value = value; - cookie.row = row; - cookie.column = column; -} diff --git a/examples/declarative/snake/snake.qml b/examples/declarative/snake/snake.qml deleted file mode 100644 index f25b626d02..0000000000 --- a/examples/declarative/snake/snake.qml +++ /dev/null @@ -1,272 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 -import "content" as Content -import "content/snake.js" as Logic - -Rectangle { - id: screen; - SystemPalette { id: activePalette } - color: activePalette.window - property bool activeGame: false - - property int gridSize : 34 - property int margin: 4 - property int numRowsAvailable: Math.floor((height-32-2*margin)/gridSize) - property int numColumnsAvailable: Math.floor((width-2*margin)/gridSize) - - property int lastScore : 0 - - property int score: 0; - property int heartbeatInterval: 200 - property int halfbeatInterval: 160 - - width: 480 - height: 750 - - property int direction - property int headDirection - - property variant head; - - Content.HighScoreModel { - id: highScores - game: "Snake" - } - - Timer { - id: heartbeat; - interval: heartbeatInterval; - running: activeGame - repeat: true - onTriggered: { Logic.move() } - } - Timer { - id: halfbeat; - interval: halfbeatInterval; - repeat: true - running: heartbeat.running - onTriggered: { Logic.moveSkull() } - } - Timer { - id: startNewGameTimer; - interval: 700; - onTriggered: { Logic.startNewGame(); } - } - - Timer { - id: startHeartbeatTimer; - interval: 1000 ; - onTriggered: { state = "running"; activeGame = true; } - } - - Image{ - id: pauseDialog - z: 1 - source: "content/pics/pause.png" - anchors.centerIn: parent; - //opacity is deliberately not animated - opacity: 0 //Was !Qt.application.active && activeGame, but application doesn't work (QTBUG-23331) - } - - Image { - - Image { - id: title - source: "content/pics/snake.jpg" - fillMode: Image.PreserveAspectCrop - anchors.fill: parent - anchors.horizontalCenter: parent.horizontalCenter - anchors.verticalCenter: parent.verticalCenter - - Column { - spacing: 140 - anchors.verticalCenter: parent.verticalCenter; - anchors.left: parent.left; - anchors.right: parent.right; - - Text { - color: "white" - font.pointSize: 48 - font.italic: true; - font.bold: true; - text: "Snake" - anchors.horizontalCenter: parent.horizontalCenter; - } - - Text { - color: "white" - font.pointSize: 24 - anchors.horizontalCenter: parent.horizontalCenter; - //horizontalAlignment: Text.AlignHCenter - text: "Last Score:\t" + lastScore + "\nHighscore:\t" + highScores.topScore; - } - } - } - - source: "content/pics/background.png" - fillMode: Image.PreserveAspectCrop - - anchors.left: parent.left - anchors.right: parent.right - anchors.top: parent.top - anchors.bottom: toolbar.top - - Rectangle { - id: playfield - border.width: 1 - border.color: "white" - color: "transparent" - anchors.horizontalCenter: parent.horizontalCenter - y: (screen.height - 32 - height)/2; - width: numColumnsAvailable * gridSize + 2*margin - height: numRowsAvailable * gridSize + 2*margin - - - Content.Skull { - id: skull - } - - MouseArea { - anchors.fill: parent - onPressed: { - if (screen.state == "") { - Logic.startNewGame(); - return; - } - if (direction == 0 || direction == 2) - Logic.scheduleDirection((mouseX > (head.x + head.width/2)) ? 1 : 3); - else - Logic.scheduleDirection((mouseY > (head.y + head.height/2)) ? 2 : 0); - } - } - } - - } - - Rectangle { - id: progressBar - opacity: 0 - Behavior on opacity { NumberAnimation { duration: 200 } } - color: "transparent" - border.width: 2 - border.color: "#221edd" - x: 50 - y: 50 - width: 200 - height: 30 - anchors.horizontalCenter: parent.horizontalCenter - anchors.verticalCenter: parent.verticalCenter - anchors.verticalCenterOffset: 40 - - Rectangle { - id: progressIndicator - color: "#221edd"; - width: 0; - height: 30; - } - } - - Rectangle { - id: toolbar - color: activePalette.window - height: 32; width: parent.width - anchors.bottom: screen.bottom - - Content.Button { - id: btnA; text: "New Game"; onClicked: Logic.startNewGame(); - anchors.left: parent.left; anchors.leftMargin: 3 - anchors.verticalCenter: parent.verticalCenter - } - - Content.Button { - text: "Quit" - anchors { left: btnA.right; leftMargin: 3; verticalCenter: parent.verticalCenter } - onClicked: Qt.quit(); - } - - Text { - color: activePalette.text - text: "Score: " + score; font.bold: true - anchors.right: parent.right; anchors.rightMargin: 3 - anchors.verticalCenter: parent.verticalCenter - } - } - - focus: true - Keys.onSpacePressed: Logic.startNewGame(); - Keys.onLeftPressed: if (state == "starting" || direction != 1) Logic.scheduleDirection(3); - Keys.onRightPressed: if (state == "starting" || direction != 3) Logic.scheduleDirection(1); - Keys.onUpPressed: if (state == "starting" || direction != 2) Logic.scheduleDirection(0); - Keys.onDownPressed: if (state == "starting" || direction != 0) Logic.scheduleDirection(2); - - states: [ - State { - name: "starting" - PropertyChanges {target: progressIndicator; width: 200} - PropertyChanges {target: title; opacity: 0} - PropertyChanges {target: progressBar; opacity: 1} - }, - State { - name: "running" - PropertyChanges {target: progressIndicator; width: 200} - PropertyChanges {target: title; opacity: 0} - PropertyChanges {target: skull; row: 0; column: 0; } - PropertyChanges {target: skull; spawned: 1} - } - ] - - transitions: [ - Transition { - from: "*" - to: "starting" - NumberAnimation { target: progressIndicator; property: "width"; duration: 1000 } - NumberAnimation { property: "opacity"; duration: 200 } - }, - Transition { - to: "starting" - NumberAnimation { target: progressIndicator; property: "width"; duration: 1000 } - NumberAnimation { property: "opacity"; duration: 200 } - } - ] - -} diff --git a/examples/declarative/snake/snake.qmlproject b/examples/declarative/snake/snake.qmlproject deleted file mode 100644 index fb015465d1..0000000000 --- a/examples/declarative/snake/snake.qmlproject +++ /dev/null @@ -1,16 +0,0 @@ -import QmlProject 1.1 - -Project { - mainFile: "snake.qml" - - /* Include .qml, .js, and image files from current directory and subdirectories */ - QmlFiles { - directory: "." - } - JavaScriptFiles { - directory: "." - } - ImageFiles { - directory: "." - } -} diff --git a/examples/declarative/sqllocalstorage/hello.qml b/examples/declarative/sqllocalstorage/hello.qml deleted file mode 100644 index 3496b86bd9..0000000000 --- a/examples/declarative/sqllocalstorage/hello.qml +++ /dev/null @@ -1,78 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -//![0] -import QtQuick 2.0 -import QtQuick.LocalStorage 2.0 as LS - -Rectangle { - color: "white" - width: 200 - height: 100 - - Text { - text: "?" - anchors.horizontalCenter: parent.horizontalCenter - function findGreetings() { - var db = LS.openDatabaseSync("QDeclarativeExampleDB", "1.0", "The Example QML SQL!", 1000000); - - db.transaction( - function(tx) { - // Create the database if it doesn't already exist - tx.executeSql('CREATE TABLE IF NOT EXISTS Greeting(salutation TEXT, salutee TEXT)'); - - // Add (another) greeting row - tx.executeSql('INSERT INTO Greeting VALUES(?, ?)', [ 'hello', 'world' ]); - - // Show all added greetings - var rs = tx.executeSql('SELECT * FROM Greeting'); - - var r = "" - for(var i = 0; i < rs.rows.length; i++) { - r += rs.rows.item(i).salutation + ", " + rs.rows.item(i).salutee + "\n" - } - text = r - } - ) - } - - Component.onCompleted: findGreetings() - } -} -//![0] diff --git a/examples/declarative/text/fonts/availableFonts.qml b/examples/declarative/text/fonts/availableFonts.qml deleted file mode 100644 index 0b87259556..0000000000 --- a/examples/declarative/text/fonts/availableFonts.qml +++ /dev/null @@ -1,57 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -Rectangle { - width: 480; height: 640; color: "steelblue" - - ListView { - anchors.fill: parent; model: Qt.fontFamilies() - - delegate: Item { - height: 40; width: ListView.view.width - Text { - anchors.centerIn: parent - text: modelData; font.family: modelData; font.pixelSize: 24; color: "white" - } - } - } -} diff --git a/examples/declarative/text/fonts/banner.qml b/examples/declarative/text/fonts/banner.qml deleted file mode 100644 index 6c9aa25fa1..0000000000 --- a/examples/declarative/text/fonts/banner.qml +++ /dev/null @@ -1,61 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -Rectangle { - id: screen - - property int pixelSize: screen.height * 1.25 - property color textColor: "lightsteelblue" - property string text: "Hello world! " - - width: 640; height: 320 - color: "steelblue" - - Row { - y: -screen.height / 4.5 - - NumberAnimation on x { from: 0; to: -text.width; duration: 6000; loops: Animation.Infinite } - Text { id: text; font.pixelSize: screen.pixelSize; color: screen.textColor; text: screen.text } - Text { font.pixelSize: screen.pixelSize; color: screen.textColor; text: screen.text } - Text { font.pixelSize: screen.pixelSize; color: screen.textColor; text: screen.text } - } -} diff --git a/examples/declarative/text/fonts/content/fonts/tarzeau_ocr_a.ttf b/examples/declarative/text/fonts/content/fonts/tarzeau_ocr_a.ttf deleted file mode 100644 index cf93f9651f..0000000000 Binary files a/examples/declarative/text/fonts/content/fonts/tarzeau_ocr_a.ttf and /dev/null differ diff --git a/examples/declarative/text/fonts/fonts.qml b/examples/declarative/text/fonts/fonts.qml deleted file mode 100644 index 78cef25eae..0000000000 --- a/examples/declarative/text/fonts/fonts.qml +++ /dev/null @@ -1,104 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -Rectangle { - property string myText: "The quick brown fox jumps over the lazy dog." - - width: 800; height: 480 - color: "steelblue" - - FontLoader { id: fixedFont; name: "Courier" } - FontLoader { id: localFont; source: "content/fonts/tarzeau_ocr_a.ttf" } - FontLoader { id: webFont; source: "http://www.princexml.com/fonts/steffmann/Starburst.ttf" } - - Column { - anchors { fill: parent; leftMargin: 10; rightMargin: 10 } - spacing: 15 - - Text { - text: myText - color: "lightsteelblue" - width: parent.width - elide: Text.ElideRight - font.family: "Times"; font.pointSize: 42 - } - Text { - text: myText - color: "lightsteelblue" - width: parent.width - elide: Text.ElideLeft - font { family: "Times"; pointSize: 42; capitalization: Font.AllUppercase } - } - Text { - text: myText - color: "lightsteelblue" - width: parent.width - elide: Text.ElideMiddle - font { family: fixedFont.name; pointSize: 42; weight: Font.Bold; capitalization: Font.AllLowercase } - } - Text { - text: myText - color: "lightsteelblue" - width: parent.width - elide: Text.ElideRight - font { family: fixedFont.name; pointSize: 42; italic: true; capitalization: Font.SmallCaps } - } - Text { - text: myText - color: "lightsteelblue" - width: parent.width - elide: Text.ElideLeft - font { family: localFont.name; pointSize: 42; capitalization: Font.Capitalize } - } - Text { - text: { - if (webFont.status == FontLoader.Ready) myText - else if (webFont.status == FontLoader.Loading) "Loading..." - else if (webFont.status == FontLoader.Error) "Error loading font" - } - color: "lightsteelblue" - width: parent.width - elide: Text.ElideMiddle - font.family: webFont.name; font.pointSize: 42 - } - } -} diff --git a/examples/declarative/text/fonts/hello.qml b/examples/declarative/text/fonts/hello.qml deleted file mode 100644 index d9479fb208..0000000000 --- a/examples/declarative/text/fonts/hello.qml +++ /dev/null @@ -1,79 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -Rectangle { - id: screen - - width: 800; height: 480 - color: "black" - - Item { - id: container - x: screen.width / 2; y: screen.height / 2 - - Text { - id: text - anchors.centerIn: parent - color: "white" - text: "Hello world!" - font.pixelSize: 60 - smooth: true - - SequentialAnimation on font.letterSpacing { - loops: Animation.Infinite; - NumberAnimation { from: 0; to: 150; easing.type: Easing.InQuad; duration: 3000 } - ScriptAction { - script: { - container.y = (screen.height / 4) + (Math.random() * screen.height / 2) - container.x = (screen.width / 4) + (Math.random() * screen.width / 2) - } - } - } - - SequentialAnimation on opacity { - loops: Animation.Infinite; - NumberAnimation { from: 1; to: 0; duration: 2600 } - PauseAnimation { duration: 400 } - } - } - } -} diff --git a/examples/declarative/text/imgtag/TextWithImage.qml b/examples/declarative/text/imgtag/TextWithImage.qml deleted file mode 100644 index bc09aa2a52..0000000000 --- a/examples/declarative/text/imgtag/TextWithImage.qml +++ /dev/null @@ -1,55 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -Text { - width: parent.width - font.pointSize: 14 - wrapMode: Text.WordWrap - textFormat: Text.StyledText - horizontalAlignment: main.hAlign - - Rectangle { - border.color: "#efefef" - color: "transparent" - anchors.fill: parent - } -} diff --git a/examples/declarative/text/imgtag/images/face-sad.png b/examples/declarative/text/imgtag/images/face-sad.png deleted file mode 100644 index 24188b7985..0000000000 Binary files a/examples/declarative/text/imgtag/images/face-sad.png and /dev/null differ diff --git a/examples/declarative/text/imgtag/images/face-smile-big.png b/examples/declarative/text/imgtag/images/face-smile-big.png deleted file mode 100644 index d05e0bf21e..0000000000 Binary files a/examples/declarative/text/imgtag/images/face-smile-big.png and /dev/null differ diff --git a/examples/declarative/text/imgtag/images/face-smile.png b/examples/declarative/text/imgtag/images/face-smile.png deleted file mode 100644 index e5e1d1353c..0000000000 Binary files a/examples/declarative/text/imgtag/images/face-smile.png and /dev/null differ diff --git a/examples/declarative/text/imgtag/images/heart200.png b/examples/declarative/text/imgtag/images/heart200.png deleted file mode 100644 index cedd3ea608..0000000000 Binary files a/examples/declarative/text/imgtag/images/heart200.png and /dev/null differ diff --git a/examples/declarative/text/imgtag/images/qtlogo.png b/examples/declarative/text/imgtag/images/qtlogo.png deleted file mode 100644 index 996719a4c6..0000000000 Binary files a/examples/declarative/text/imgtag/images/qtlogo.png and /dev/null differ diff --git a/examples/declarative/text/imgtag/images/starfish_2.png b/examples/declarative/text/imgtag/images/starfish_2.png deleted file mode 100644 index 132c20ffd0..0000000000 Binary files a/examples/declarative/text/imgtag/images/starfish_2.png and /dev/null differ diff --git a/examples/declarative/text/imgtag/imgtag.qml b/examples/declarative/text/imgtag/imgtag.qml deleted file mode 100644 index 9d181af2cb..0000000000 --- a/examples/declarative/text/imgtag/imgtag.qml +++ /dev/null @@ -1,101 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -Rectangle { - id: main - width: 320; height: 480 - focus: true - - property var hAlign: Text.AlignLeft - - Flickable { - anchors.fill: parent - contentWidth: parent.width - contentHeight: col.height + 20 - - Column { - id: col - x: 10; y: 10 - spacing: 20 - width: parent.width - 20 - - TextWithImage { - text: "This is a happy face" - } - TextWithImage { - text: "This is a veryhappy face aligned in the middle." - } - TextWithImage { - elide: Text.ElideRight - maximumLineCount: 2 - text: "This is a sad face aligned to the top. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nunc rutrum dui pretium ipsum malesuada venenatis. Nulla sed turpis risus. Integer sit amet odio quis mauris varius venenatisLorem ipsum dolor sit amet, consectetur adipiscing elit. Nunc rutrum dui pretium ipsum malesuada venenatis. Nulla sed turpis risus. Integer sit amet odio quis mauris varius venenatis." - } - TextWithImage { - text: "This is a tinyhappy face." - } - TextWithImage { - text: "This is a starfishaligned to the top and another onealigned to the bottom." - } - TextWithImage { - text: "Qt logosaligned in the middle with different sizes." - } - TextWithImage { - text: "Some hearts with different sizes." - } - TextWithImage { - text: "Resized imagefrom the internet." - } - TextWithImage { - text: "Imagefrom the internet." - } - TextWithImage { - height: 120 - verticalAlignment: Text.AlignVCenter - text: "This is a happy face with an explicit height." - } - } - } - - Keys.onUpPressed: main.hAlign = Text.AlignHCenter - Keys.onLeftPressed: main.hAlign = Text.AlignLeft - Keys.onRightPressed: main.hAlign = Text.AlignRight -} diff --git a/examples/declarative/text/styledtext-layout.qml b/examples/declarative/text/styledtext-layout.qml deleted file mode 100644 index 4571330568..0000000000 --- a/examples/declarative/text/styledtext-layout.qml +++ /dev/null @@ -1,107 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -Rectangle { - id: main - width: 320; height: 480 - focus: true - - property real offset: 0 - property real margin: 10 - - Keys.onLeftPressed: myText.horizontalAlignment = Text.AlignLeft - Keys.onUpPressed: myText.horizontalAlignment = Text.AlignHCenter - Keys.onRightPressed: myText.horizontalAlignment = Text.AlignRight - Keys.onDownPressed: myText.horizontalAlignment = Text.AlignJustify - - Text { - id: myText - anchors.fill: parent - anchors.margins: 10 - wrapMode: Text.WordWrap - font.family: "Times New Roman" - font.pixelSize: 13 - textFormat: Text.StyledText - horizontalAlignment: Text.AlignJustify - - text: "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer at ante dui sed eu egestas est facilis www.nokia.com.
Curabitur ante est, pulvinar quis adipiscing a, iaculis id ipsum. Phasellus id neque id velit facilisis cursus ac sit amet nibh. Donec enim arcu, pharetra non semper nec, iaculis eget elit. Nunc blandit condimentum odio vel egestas.
  • Coffee
    1. Espresso
    2. Cappuccino
    3. Flat White
    4. Latte
  • Juice
    1. Orange
    2. Apple
    3. Pineapple
    4. Tomato

Proin consectetur sapien in ipsum lacinia sit amet mattis orci interdum. Quisque vitae accumsan lectus. Ut nisi turpis, sollicitudin ut dignissim id, fermentum ac est. Maecenas nec libero leo. Sed ac leo eget ipsum ultricies viverra sit amet eu orci. Praesent et tortor risus, viverra accumsan sapien. Sed faucibus eleifend lectus, sed euismod urna porta eu. Aenean ultricies lectus ut orci dictum quis convallis nisi ultrices. Nunc elit mi, iaculis a porttitor rutrum, venenatis malesuada nisi. Suspendisse turpis quam, euismod non imperdiet et, rutrum nec ligula. Lorem ipsum dolor sit amet, consectetur adipiscing elit." - - onLineLaidOut: { - line.width = width / 2 - (2 * margin) - if (line.number === 30) { - main.offset = line.y - } - if (line.number >= 30) { - line.x = width / 2 + margin - line.y -= main.offset - } - if ((line.y + line.height) > rect.y && line.y < (rect.y + rect.height)) { - if (line.number < 30) - line.width = Math.min((rect.x - line.x), line.width) - else { - line.x = Math.max((rect.x + rect.width), width / 2 + margin) - line.width = Math.min((width - margin - line.x), line.width) - } - } - } - - Item { - id: rect - x: 28; y: 20 - width: 60; height: 60 - - Rectangle { - anchors { fill: parent; leftMargin: 2; rightMargin: 2 } - color: "lightsteelblue"; opacity: 0.3 - } - - MouseArea { - anchors.fill: parent - drag.target: rect - acceptedButtons: Qt.LeftButton | Qt.RightButton - onClicked: mouse.button == Qt.RightButton ? myText.font.pixelSize -= 1 : myText.font.pixelSize += 1 - onPositionChanged: myText.doLayout() - } - } - } - -} diff --git a/examples/declarative/text/text.qml b/examples/declarative/text/text.qml deleted file mode 100644 index 14a88d2e91..0000000000 --- a/examples/declarative/text/text.qml +++ /dev/null @@ -1,57 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 -import "../shared" - -Item { - height: 480 - width: 480 - LauncherList { - id: ll - anchors.fill: parent - Component.onCompleted: { - addExample("Hello", "An Animated Hello World", Qt.resolvedUrl("fonts/hello.qml")); - addExample("Fonts", "Using various fonts with a Text element", Qt.resolvedUrl("fonts/fonts.qml")); - addExample("Available Fonts", "A list of your available fonts", Qt.resolvedUrl("fonts/availableFonts.qml")); - addExample("Banner", "Large, scrolling text", Qt.resolvedUrl("fonts/banner.qml")); - } - } -} diff --git a/examples/declarative/text/text.qmlproject b/examples/declarative/text/text.qmlproject deleted file mode 100644 index c08d9b9a89..0000000000 --- a/examples/declarative/text/text.qmlproject +++ /dev/null @@ -1,16 +0,0 @@ -import QmlProject 1.1 - -Project { - mainFile: "text.qml" - - /* Include .qml, .js, and image files from current directory and subdirectories */ - QmlFiles { - directory: "." - } - JavaScriptFiles { - directory: "." - } - ImageFiles { - directory: "." - } -} diff --git a/examples/declarative/text/textselection/pics/endHandle.png b/examples/declarative/text/textselection/pics/endHandle.png deleted file mode 100644 index 1a4bc5d7a0..0000000000 Binary files a/examples/declarative/text/textselection/pics/endHandle.png and /dev/null differ diff --git a/examples/declarative/text/textselection/pics/endHandle.sci b/examples/declarative/text/textselection/pics/endHandle.sci deleted file mode 100644 index 4f51f24278..0000000000 --- a/examples/declarative/text/textselection/pics/endHandle.sci +++ /dev/null @@ -1,5 +0,0 @@ -border.left: 0 -border.top: 6 -border.bottom: 6 -border.right: 6 -source: endHandle.png diff --git a/examples/declarative/text/textselection/pics/startHandle.png b/examples/declarative/text/textselection/pics/startHandle.png deleted file mode 100644 index deedcd5c91..0000000000 Binary files a/examples/declarative/text/textselection/pics/startHandle.png and /dev/null differ diff --git a/examples/declarative/text/textselection/pics/startHandle.sci b/examples/declarative/text/textselection/pics/startHandle.sci deleted file mode 100644 index f9eae204c1..0000000000 --- a/examples/declarative/text/textselection/pics/startHandle.sci +++ /dev/null @@ -1,5 +0,0 @@ -border.left: 6 -border.top: 6 -border.bottom: 6 -border.right: 0 -source: startHandle.png diff --git a/examples/declarative/text/textselection/textselection.qml b/examples/declarative/text/textselection/textselection.qml deleted file mode 100644 index 7938ce5bf7..0000000000 --- a/examples/declarative/text/textselection/textselection.qml +++ /dev/null @@ -1,211 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -import QtQuick 2.0 - -Rectangle { - id: editor - color: "lightGrey" - width: 640; height: 480 - - Rectangle { - color: "white" - anchors.fill: parent - anchors.margins: 20 - - BorderImage { - id: startHandle - source: "pics/startHandle.sci" - opacity: 0.0 - width: 10 - x: edit.positionToRectangle(edit.selectionStart).x - flick.contentX-width - y: edit.positionToRectangle(edit.selectionStart).y - flick.contentY - height: edit.positionToRectangle(edit.selectionStart).height - } - - BorderImage { - id: endHandle - source: "pics/endHandle.sci" - opacity: 0.0 - width: 10 - x: edit.positionToRectangle(edit.selectionEnd).x - flick.contentX - y: edit.positionToRectangle(edit.selectionEnd).y - flick.contentY - height: edit.positionToRectangle(edit.selectionEnd).height - } - - Flickable { - id: flick - - anchors.fill: parent - contentWidth: edit.paintedWidth - contentHeight: edit.paintedHeight - interactive: true - clip: true - - function ensureVisible(r) { - if (contentX >= r.x) - contentX = r.x; - else if (contentX+width <= r.x+r.width) - contentX = r.x+r.width-width; - if (contentY >= r.y) - contentY = r.y; - else if (contentY+height <= r.y+r.height) - contentY = r.y+r.height-height; - } - - TextEdit { - id: edit - width: flick.width - height: flick.height - focus: true - wrapMode: TextEdit.Wrap - textFormat: TextEdit.RichText - - onCursorRectangleChanged: flick.ensureVisible(cursorRectangle) - - text: "

Text Selection

" - +"

This example is a whacky text selection mechanisms, showing how these can be implemented in the TextEdit element, to cater for whatever style is appropriate for the target platform." - +"

Press-and-hold to select a word, then drag the selection handles." - +"

Drag outside the selection to scroll the text." - +"

Click inside the selection to cut/copy/paste/cancel selection." - +"

It's too whacky to let you paste if there is no current selection." - - } - } - - Item { - id: menu - opacity: 0.0 - width: 100 - height: 120 - anchors.centerIn: parent - - Rectangle { - border.width: 1 - border.color: "darkBlue" - radius: 15 - color: "#806080FF" - anchors.fill: parent - } - - Column { - anchors.centerIn: parent - spacing: 8 - - Rectangle { - border.width: 1 - border.color: "darkBlue" - color: "#ff7090FF" - width: 60 - height: 16 - - Text { anchors.centerIn: parent; text: "Cut" } - - MouseArea { - anchors.fill: parent - onClicked: { edit.cut(); editor.state = "" } - } - } - - Rectangle { - border.width: 1 - border.color: "darkBlue" - color: "#ff7090FF" - width: 60 - height: 16 - - Text { anchors.centerIn: parent; text: "Copy" } - - MouseArea { - anchors.fill: parent - onClicked: { edit.copy(); editor.state = "selection" } - } - } - - Rectangle { - border.width: 1 - border.color: "darkBlue" - color: "#ff7090FF" - width: 60 - height: 16 - - Text { anchors.centerIn: parent; text: "Paste" } - - MouseArea { - anchors.fill: parent - onClicked: { edit.paste(); edit.cursorPosition = edit.selectionEnd; editor.state = "" } - } - } - - Rectangle { - border.width: 1 - border.color: "darkBlue" - color: "#ff7090FF" - width: 60 - height: 16 - - Text { anchors.centerIn: parent; text: "Deselect" } - - MouseArea { - anchors.fill: parent - onClicked: { - edit.cursorPosition = edit.selectionEnd; - edit.deselect(); - editor.state = "" - } - } - } - } - } - } - - states: [ - State { - name: "selection" - PropertyChanges { target: startHandle; opacity: 1.0 } - PropertyChanges { target: endHandle; opacity: 1.0 } - }, - State { - name: "menu" - PropertyChanges { target: startHandle; opacity: 0.5 } - PropertyChanges { target: endHandle; opacity: 0.5 } - PropertyChanges { target: menu; opacity: 1.0 } - } - ] -} diff --git a/examples/declarative/threading/threadedlistmodel/dataloader.js b/examples/declarative/threading/threadedlistmodel/dataloader.js deleted file mode 100644 index 4d2aab323d..0000000000 --- a/examples/declarative/threading/threadedlistmodel/dataloader.js +++ /dev/null @@ -1,49 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -// ![0] -WorkerScript.onMessage = function(msg) { - if (msg.action == 'appendCurrentTime') { - var data = {'time': new Date().toTimeString()}; - msg.model.append(data); - msg.model.sync(); // updates the changes to the list - } -} -// ![0] diff --git a/examples/declarative/threading/threadedlistmodel/threadedlistmodel.qmlproject b/examples/declarative/threading/threadedlistmodel/threadedlistmodel.qmlproject deleted file mode 100644 index e7c8e69f14..0000000000 --- a/examples/declarative/threading/threadedlistmodel/threadedlistmodel.qmlproject +++ /dev/null @@ -1,56 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QmlProject 1.1 - -Project { - mainFile: "timedisplay.qml" - - /* Include .qml, .js, and image files from current directory and subdirectories */ - QmlFiles { - directory: "." - } - JavaScriptFiles { - directory: "." - } - ImageFiles { - directory: "." - } -} diff --git a/examples/declarative/threading/threadedlistmodel/timedisplay.qml b/examples/declarative/threading/threadedlistmodel/timedisplay.qml deleted file mode 100644 index 48d0f659e5..0000000000 --- a/examples/declarative/threading/threadedlistmodel/timedisplay.qml +++ /dev/null @@ -1,76 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -// ![0] -import QtQuick 2.0 - -Rectangle { - color: "white" - width: 200 - height: 300 - - ListView { - anchors.fill: parent - model: listModel - delegate: Component { - Text { text: time } - } - - ListModel { id: listModel } - - WorkerScript { - id: worker - source: "dataloader.js" - } - - Timer { - id: timer - interval: 2000; repeat: true - running: true - triggeredOnStart: true - - onTriggered: { - var msg = {'action': 'appendCurrentTime', 'model': listModel}; - worker.sendMessage(msg); - } - } - } -} -// ![0] diff --git a/examples/declarative/threading/workerscript/workerscript.js b/examples/declarative/threading/workerscript/workerscript.js deleted file mode 100644 index f76471f920..0000000000 --- a/examples/declarative/threading/workerscript/workerscript.js +++ /dev/null @@ -1,15 +0,0 @@ -var lastx = 0; -var lasty = 0; - -WorkerScript.onMessage = function(message) { - var ydiff = message.y - lasty; - var xdiff = message.x - lastx; - - var total = Math.sqrt(ydiff * ydiff + xdiff * xdiff); - - lastx = message.x; - lasty = message.y; - - WorkerScript.sendMessage( {xmove: xdiff, ymove: ydiff, move: total} ); -} - diff --git a/examples/declarative/threading/workerscript/workerscript.qml b/examples/declarative/threading/workerscript/workerscript.qml deleted file mode 100644 index 7fced8166c..0000000000 --- a/examples/declarative/threading/workerscript/workerscript.qml +++ /dev/null @@ -1,83 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -Rectangle { - width: 480; height: 320 - - WorkerScript { - id: myWorker - source: "workerscript.js" - - onMessage: { - console.log("Moved " + messageObject.xmove + " along the X axis."); - console.log("Moved " + messageObject.ymove + " along the Y axis."); - console.log("Moved " + messageObject.move + " pixels."); - } - } - - Rectangle { - width: 200; height: 200 - anchors.left: parent.left; anchors.leftMargin: 20 - color: "red" - - MouseArea { - anchors.fill: parent - onClicked: myWorker.sendMessage( { rectangle: "red", x: mouse.x, y: mouse.y } ); - } - } - - Rectangle { - width: 200; height: 200 - anchors.right: parent.right; anchors.rightMargin: 20 - color: "blue" - - MouseArea { - anchors.fill: parent - onClicked: myWorker.sendMessage( { rectangle: "blue", x: mouse.x, y: mouse.y } ); - } - } - - Text { - text: "Click a Rectangle!" - anchors { horizontalCenter: parent.horizontalCenter; bottom: parent.bottom; bottomMargin: 50 } - } -} diff --git a/examples/declarative/threading/workerscript/workerscript.qmlproject b/examples/declarative/threading/workerscript/workerscript.qmlproject deleted file mode 100644 index 6d7a91feeb..0000000000 --- a/examples/declarative/threading/workerscript/workerscript.qmlproject +++ /dev/null @@ -1,16 +0,0 @@ -import QmlProject 1.1 - -Project { - mainFile: "workerscript.qml" - - /* Include .qml, .js, and image files from current directory and subdirectories */ - QmlFiles { - directory: "." - } - JavaScriptFiles { - directory: "." - } - ImageFiles { - directory: "." - } -} diff --git a/examples/declarative/touchinteraction/mousearea/mousearea-example.qml b/examples/declarative/touchinteraction/mousearea/mousearea-example.qml deleted file mode 100644 index 30e3e62864..0000000000 --- a/examples/declarative/touchinteraction/mousearea/mousearea-example.qml +++ /dev/null @@ -1,176 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -Rectangle { - id: box - width: 400; height: 300 - - Rectangle { - id: redSquare - width: 120; height: 120 - anchors.top: parent.top; anchors.left: parent.left; anchors.margins: 10 - color: "red" - - Text { text: "Click"; font.pixelSize: 16; anchors.centerIn: parent } - - MouseArea { - anchors.fill: parent - hoverEnabled: true - property string buttonID - - acceptedButtons: Qt.AllButtons - // Value 'All.Buttons' is eqivalent to: - // 'Qt::LeftButton | Qt::RightButton | Qt::MiddleButton .... | Qt::ExtraButton24' - - onEntered: info.text = 'Entered' - onExited: info.text = 'Exited (pressed=' + pressed + ')' - - onPressed: { - if (mouse.button == Qt.LeftButton) - buttonID = 'LeftButton' - else if (mouse.button == Qt.RightButton) - buttonID = 'RightButton' - else if (mouse.button == Qt.MidButton) - buttonID = 'MiddleButton' - else if (mouse.button == Qt.BackButton) - buttonID = 'BackButton' - else if (mouse.button == Qt.ForwardButton) - buttonID = 'ForwardButton' - else if (mouse.button == Qt.TaskButton) - buttonID = 'TaskButton' - else if (mouse.button == Qt.ExtraButton4) - buttonID = 'ExtraButton4' - else if (mouse.button == Qt.ExtraButton5) - buttonID = 'ExtraButton5' - else if (mouse.button == Qt.ExtraButton6) - buttonID = 'ExtraButton6' - else if (mouse.button == Qt.ExtraButton7) - buttonID = 'ExtraButton7' - else if (mouse.button == Qt.ExtraButton8) - buttonID = 'ExtraButton8' - else if (mouse.button == Qt.ExtraButton9) - buttonID = 'ExtraButton9' - else if (mouse.button == Qt.ExtraButton10) - buttonID = 'ExtraButton10' - else if (mouse.button == Qt.ExtraButton11) - buttonID = 'ExtraButton11' - else if (mouse.button == Qt.ExtraButton12) - buttonID = 'ExtraButton12' - else if (mouse.button == Qt.ExtraButton13) - buttonID = 'ExtraButton13' - else if (mouse.button == Qt.ExtraButton14) - buttonID = 'ExtraButton14' - else if (mouse.button == Qt.ExtraButton15) - buttonID = 'ExtraButton15' - else if (mouse.button == Qt.ExtraButton16) - buttonID = 'ExtraButton16' - else if (mouse.button == Qt.ExtraButton17) - buttonID = 'ExtraButton17' - else if (mouse.button == Qt.ExtraButton18) - buttonID = 'ExtraButton18' - else if (mouse.button == Qt.ExtraButton19) - buttonID = 'ExtraButton19' - else if (mouse.button == Qt.ExtraButton20) - buttonID = 'ExtraButton20' - else if (mouse.button == Qt.ExtraButton21) - buttonID = 'ExtraButton21' - else if (mouse.button == Qt.ExtraButton22) - buttonID = 'ExtraButton22' - else if (mouse.button == Qt.ExtraButton23) - buttonID = 'ExtraButton23' - else if (mouse.button == Qt.ExtraButton24) - buttonID = 'ExtraButton24' - - info.text = 'Pressed (' + buttonID + ' shift=' - + (mouse.modifiers & Qt.ShiftModifier ? 'true' : 'false') + ')' - var posInBox = redSquare.mapToItem(box, mouse.x, mouse.y) - posInfo.text = + mouse.x + ',' + mouse.y + ' in square' - + ' (' + posInBox.x + ',' + posInBox.y + ' in window)' - } - - onReleased: { - btn.text = 'Released (isClick=' + mouse.isClick + ' wasHeld=' + mouse.wasHeld + ')' - posInfo.text = '' - } - - onPressAndHold: btn.text = 'Press and hold' - onClicked: btn.text = 'Clicked (wasHeld=' + mouse.wasHeld + ')' - onDoubleClicked: btn.text = 'Double clicked' - } - } - - Rectangle { - id: blueSquare - width: 120; height: 120 - x: box.width - width - 10; y: 10 // making this item draggable, so don't use anchors - color: "blue" - - Text { text: "Drag"; font.pixelSize: 16; color: "white"; anchors.centerIn: parent } - - MouseArea { - anchors.fill: parent - drag.target: blueSquare - drag.axis: Drag.XandYAxis - drag.minimumX: 0 - drag.maximumX: box.width - parent.width - drag.minimumY: 0 - drag.maximumY: box.height - parent.width - } - } - - Text { - id: info - anchors.bottom: btn.top; anchors.horizontalCenter: parent.horizontalCenter; anchors.margins: 20 - - onTextChanged: console.log(text) - } - - Text { - id: btn - anchors.bottom: posInfo.top; anchors.horizontalCenter: parent.horizontalCenter; anchors.margins: 20 - } - - Text { - id: posInfo - anchors.bottom: parent.bottom; anchors.horizontalCenter: parent.horizontalCenter; anchors.margins: 20 - } -} diff --git a/examples/declarative/touchinteraction/multipointtouch/bearwhack.qml b/examples/declarative/touchinteraction/multipointtouch/bearwhack.qml deleted file mode 100644 index db46473c05..0000000000 --- a/examples/declarative/touchinteraction/multipointtouch/bearwhack.qml +++ /dev/null @@ -1,133 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -import QtQuick 2.0 -import QtQuick.Particles 2.0 -import "content" - -Item { - id: root - height: 640 - width: 320 - Item { - id: startScreen - anchors.fill: parent - z: 1000 - Image { - source: "content/title.png" - anchors.centerIn: parent - } - MouseArea{ - anchors.fill: parent - onClicked: {//Game Start - parent.visible = false; - } - } - } - Rectangle { - id: bg - anchors.fill: parent - gradient: Gradient { - GradientStop { position: 0.0; color: "DarkBlue" } - GradientStop { position: 0.8; color: "SkyBlue" } - GradientStop { position: 0.81; color: "ForestGreen" } - GradientStop { position: 1.0; color: "DarkGreen" } - } - } - - BearWhackParticleSystem { - id: particleSystem - anchors.fill: parent - running: !startScreen.visible - } - - property int score: 0 - - Text { - anchors.right: parent.right - anchors.margins: 4 - anchors.top: parent.top - color: "white" - function padded(num) { - var ret = num.toString(); - while (ret.length < 6) - ret = "0" + ret; - return ret; - } - text: "Score: " + padded(score) - } - MultiPointTouchArea { - anchors.fill: parent - touchPoints: [//Support up to 4 touches at once? - AugmentedTouchPoint{ system: particleSystem }, - AugmentedTouchPoint{ system: particleSystem }, - AugmentedTouchPoint{ system: particleSystem }, - AugmentedTouchPoint{ system: particleSystem } - ] - } - MouseArea{ - anchors.fill: parent - id: ma - onPressedChanged: { - if (pressed) { - timer.restart(); - sgoal.enabled = true; - particleSystem.explode(mouseX,mouseY); - } - } - Timer { - id: timer - interval: 100 - running: false - repeat: false - onTriggered: sgoal.enabled = false - } - SpriteGoal { - id: sgoal - x: ma.mouseX - 16 - y: ma.mouseY - 16 - width: 32 - height: 32 - system: particleSystem - parent: particleSystem - goalState: "falling" - enabled: false - } - } -} diff --git a/examples/declarative/touchinteraction/multipointtouch/content/AugmentedTouchPoint.qml b/examples/declarative/touchinteraction/multipointtouch/content/AugmentedTouchPoint.qml deleted file mode 100644 index aede1a8f4e..0000000000 --- a/examples/declarative/touchinteraction/multipointtouch/content/AugmentedTouchPoint.qml +++ /dev/null @@ -1,70 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -import QtQuick 2.0 -import QtQuick.Particles 2.0 - -TouchPoint { - id: container - property ParticleSystem system - onPressedChanged: { - if (pressed) { - timer.restart(); - child.enabled = true; - system.explode(x,y); - } - } - property QtObject obj: Timer { - id: timer - interval: 100 - running: false - repeat: false - onTriggered: child.enabled = false - } - property Item child: SpriteGoal { - enabled: false - x: container.area.x - 16 - y: container.area.y - 16 - width: container.area.width + 32 - height: container.area.height + 32 //+32 so it doesn't have to hit the exact center - system: container.system - parent: container.system - goalState: "falling" - } -} diff --git a/examples/declarative/touchinteraction/multipointtouch/content/Bear0.png b/examples/declarative/touchinteraction/multipointtouch/content/Bear0.png deleted file mode 100644 index 64a02cec8e..0000000000 Binary files a/examples/declarative/touchinteraction/multipointtouch/content/Bear0.png and /dev/null differ diff --git a/examples/declarative/touchinteraction/multipointtouch/content/Bear1.png b/examples/declarative/touchinteraction/multipointtouch/content/Bear1.png deleted file mode 100644 index 3b88f3b32e..0000000000 Binary files a/examples/declarative/touchinteraction/multipointtouch/content/Bear1.png and /dev/null differ diff --git a/examples/declarative/touchinteraction/multipointtouch/content/Bear2.png b/examples/declarative/touchinteraction/multipointtouch/content/Bear2.png deleted file mode 100644 index 337b636070..0000000000 Binary files a/examples/declarative/touchinteraction/multipointtouch/content/Bear2.png and /dev/null differ diff --git a/examples/declarative/touchinteraction/multipointtouch/content/Bear3.png b/examples/declarative/touchinteraction/multipointtouch/content/Bear3.png deleted file mode 100644 index f0e68590f4..0000000000 Binary files a/examples/declarative/touchinteraction/multipointtouch/content/Bear3.png and /dev/null differ diff --git a/examples/declarative/touchinteraction/multipointtouch/content/BearB.png b/examples/declarative/touchinteraction/multipointtouch/content/BearB.png deleted file mode 100644 index c9a84ae1d4..0000000000 Binary files a/examples/declarative/touchinteraction/multipointtouch/content/BearB.png and /dev/null differ diff --git a/examples/declarative/touchinteraction/multipointtouch/content/BearWhackParticleSystem.qml b/examples/declarative/touchinteraction/multipointtouch/content/BearWhackParticleSystem.qml deleted file mode 100644 index 05d74ab0ea..0000000000 --- a/examples/declarative/touchinteraction/multipointtouch/content/BearWhackParticleSystem.qml +++ /dev/null @@ -1,180 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -import QtQuick 2.0 -import QtQuick.Particles 2.0 - -ParticleSystem { - id: particleSystem - function explode(x,y) { - fireEmitter.burst(100,x,y); - } - - Emitter { - id: emitter - group: "bears" - width: parent.width - emitRate: 1 - NumberAnimation on emitRate { - id: goFaster - from: 1 - to: 16 - running: particleSystem.running - loops: 1 - duration: 60000 * 5 - easing.type: Easing.Linear - } - lifeSpan: 4000 + 800*(16-emitRate) - maximumEmitted: 128 - size: 64 - speed: PointDirection{ y: 40 + 10 * emitter.emitRate } - } - - Emitter { - id: fireEmitter - enabled: false - maximumEmitted: 6000 - group: "flame" - emitRate: 1000 - size: 16 - endSize: 8 - speed: CumulativeDirection { AngleDirection {angleVariation: 180; magnitudeVariation: 120;} PointDirection { y: -60 }} - lifeSpan: 400 - } - Emitter { - id: heartEmitter - enabled: false - maximumEmitted: 6000 - group: "hearts" - emitRate: 1000 - size: 16 - endSize: 8 - speed: AngleDirection {angleVariation: 180; magnitudeVariation: 180;} - lifeSpan: 600 - } - Emitter { - id: bloodEmitter - enabled: false - maximumEmitted: 6000 - group: "blood" - emitRate: 1000 - size: 16 - endSize: 8 - speed: CumulativeDirection { AngleDirection {angleVariation: 180; magnitudeVariation: 80;} PointDirection { y: 40 }} - lifeSpan: 600 - } - - Affector { - width: parent.width - height: 64 - once: true - y: parent.height - 32 - groups: "bears" - onAffectParticles: { - for (var i=0;i= 200) - return ListView.view.width / Math.floor(ListView.view.width / 200.0); - else - return 200; - } - - height: { - if (ListView.view && ListView.view.height >= 240) - return ListView.view.height; - else - return 240; - } - - property alias city: cityLabel.text - property int hours - property int minutes - property int seconds - property real shift - property bool night: false - property bool internationalTime: true //Unset for local time - - function timeChanged() { - var date = new Date; - hours = internationalTime ? date.getUTCHours() + Math.floor(clock.shift) : date.getHours() - night = ( hours < 7 || hours > 19 ) - minutes = internationalTime ? date.getUTCMinutes() + ((clock.shift % 1) * 60) : date.getMinutes() - seconds = date.getUTCSeconds(); - } - - Timer { - interval: 100; running: true; repeat: true; - onTriggered: clock.timeChanged() - } - - Item { - anchors.centerIn: parent - width: 200; height: 240 - - Image { id: background; source: "clock.png"; visible: clock.night == false } - Image { source: "clock-night.png"; visible: clock.night == true } - - - Image { - x: 92.5; y: 27 - source: "hour.png" - smooth: true - transform: Rotation { - id: hourRotation - origin.x: 7.5; origin.y: 73; - angle: (clock.hours * 30) + (clock.minutes * 0.5) - Behavior on angle { - SpringAnimation { spring: 2; damping: 0.2; modulus: 360 } - } - } - } - - Image { - x: 93.5; y: 17 - source: "minute.png" - smooth: true - transform: Rotation { - id: minuteRotation - origin.x: 6.5; origin.y: 83; - angle: clock.minutes * 6 - Behavior on angle { - SpringAnimation { spring: 2; damping: 0.2; modulus: 360 } - } - } - } - - Image { - x: 97.5; y: 20 - source: "second.png" - smooth: true - transform: Rotation { - id: secondRotation - origin.x: 2.5; origin.y: 80; - angle: clock.seconds * 6 - Behavior on angle { - SpringAnimation { spring: 2; damping: 0.2; modulus: 360 } - } - } - } - - Image { - anchors.centerIn: background; source: "center.png" - } - - Text { - id: cityLabel - y: 210; anchors.horizontalCenter: parent.horizontalCenter - color: "white" - font.family: "Helvetica" - font.bold: true; font.pixelSize: 16 - style: Text.Raised; styleColor: "black" - } - } -} diff --git a/examples/declarative/toys/clocks/content/QuitButton.qml b/examples/declarative/toys/clocks/content/QuitButton.qml deleted file mode 100644 index 702b892d23..0000000000 --- a/examples/declarative/toys/clocks/content/QuitButton.qml +++ /dev/null @@ -1,52 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 -Image { - source: "quit.png" - scale: quitMouse.pressed ? 0.8 : 1.0 - smooth: quitMouse.pressed - MouseArea { - id: quitMouse - anchors.fill: parent - anchors.margins: -10 - onClicked: Qt.quit() - } -} diff --git a/examples/declarative/toys/clocks/content/arrow.png b/examples/declarative/toys/clocks/content/arrow.png deleted file mode 100644 index e437312217..0000000000 Binary files a/examples/declarative/toys/clocks/content/arrow.png and /dev/null differ diff --git a/examples/declarative/toys/clocks/content/background.png b/examples/declarative/toys/clocks/content/background.png deleted file mode 100644 index a885950862..0000000000 Binary files a/examples/declarative/toys/clocks/content/background.png and /dev/null differ diff --git a/examples/declarative/toys/clocks/content/center.png b/examples/declarative/toys/clocks/content/center.png deleted file mode 100644 index 7fbd802a44..0000000000 Binary files a/examples/declarative/toys/clocks/content/center.png and /dev/null differ diff --git a/examples/declarative/toys/clocks/content/clock-night.png b/examples/declarative/toys/clocks/content/clock-night.png deleted file mode 100644 index cc7151a397..0000000000 Binary files a/examples/declarative/toys/clocks/content/clock-night.png and /dev/null differ diff --git a/examples/declarative/toys/clocks/content/clock.png b/examples/declarative/toys/clocks/content/clock.png deleted file mode 100644 index 462edacc0e..0000000000 Binary files a/examples/declarative/toys/clocks/content/clock.png and /dev/null differ diff --git a/examples/declarative/toys/clocks/content/hour.png b/examples/declarative/toys/clocks/content/hour.png deleted file mode 100644 index f8061a1235..0000000000 Binary files a/examples/declarative/toys/clocks/content/hour.png and /dev/null differ diff --git a/examples/declarative/toys/clocks/content/minute.png b/examples/declarative/toys/clocks/content/minute.png deleted file mode 100644 index 1297ec7c2b..0000000000 Binary files a/examples/declarative/toys/clocks/content/minute.png and /dev/null differ diff --git a/examples/declarative/toys/clocks/content/quit.png b/examples/declarative/toys/clocks/content/quit.png deleted file mode 100644 index b822057d4e..0000000000 Binary files a/examples/declarative/toys/clocks/content/quit.png and /dev/null differ diff --git a/examples/declarative/toys/clocks/content/second.png b/examples/declarative/toys/clocks/content/second.png deleted file mode 100644 index 4aa9fb5e8e..0000000000 Binary files a/examples/declarative/toys/clocks/content/second.png and /dev/null differ diff --git a/examples/declarative/toys/corkboards/content/Day.qml b/examples/declarative/toys/corkboards/content/Day.qml deleted file mode 100644 index 7fe625c305..0000000000 --- a/examples/declarative/toys/corkboards/content/Day.qml +++ /dev/null @@ -1,153 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -Component { - Item { - property variant stickies - - id: page - width: ListView.view.width+40; height: ListView.view.height - - - Image { - source: "cork.jpg" - width: page.ListView.view.width - height: page.ListView.view.height - fillMode: Image.PreserveAspectCrop - clip: true - } - - MouseArea { - anchors.fill: parent - onClicked: page.focus = false; - } - - Text { - text: name; x: 15; y: 8; height: 40; width: 370 - font.pixelSize: 18; font.bold: true; color: "white" - style: Text.Outline; styleColor: "black" - } - - Repeater { - model: notes - Item { - id: stickyPage - - property int randomX: Math.random() * (page.ListView.view.width-0.5*stickyImage.width) +100 - property int randomY: Math.random() * (page.ListView.view.height-0.5*stickyImage.height) +50 - - x: randomX; y: randomY - - rotation: -flickable.horizontalVelocity / 100; - Behavior on rotation { - SpringAnimation { spring: 2.0; damping: 0.15 } - } - - Item { - id: sticky - scale: 0.7 - - Image { - id: stickyImage - x: 8 + -width * 0.6 / 2; y: -20 - source: "note-yellow.png" - scale: 0.6; transformOrigin: Item.TopLeft - smooth: true - } - - TextEdit { - id: myText - x: -104; y: 36; width: 215; height: 200 - smooth: true - font.pixelSize: 24 - readOnly: false - rotation: -8 - text: noteText - } - - Item { - x: stickyImage.x; y: -20 - width: stickyImage.width * stickyImage.scale - height: stickyImage.height * stickyImage.scale - - MouseArea { - id: mouse - anchors.fill: parent - drag.target: stickyPage - drag.axis: Drag.XandYAxis - drag.minimumY: 0 - drag.maximumY: page.height - 80 - drag.minimumX: 100 - drag.maximumX: page.width - 140 - onClicked: { myText.focus = true; myText.openSoftwareInputPanel(); } - } - } - } - - Image { - x: -width / 2; y: -height * 0.5 / 2 - source: "tack.png" - scale: 0.7; transformOrigin: Item.TopLeft - } - - states: State { - name: "pressed" - when: mouse.pressed - PropertyChanges { target: sticky; rotation: 8; scale: 1 } - PropertyChanges { target: page; z: 8 } - } - - transitions: Transition { - NumberAnimation { properties: "rotation,scale"; duration: 200 } - } - } - } - } -} - - - - - - - - diff --git a/examples/declarative/toys/corkboards/content/cork.jpg b/examples/declarative/toys/corkboards/content/cork.jpg deleted file mode 100644 index 160bc002bf..0000000000 Binary files a/examples/declarative/toys/corkboards/content/cork.jpg and /dev/null differ diff --git a/examples/declarative/toys/corkboards/content/note-yellow.png b/examples/declarative/toys/corkboards/content/note-yellow.png deleted file mode 100644 index 8ddecc8b03..0000000000 Binary files a/examples/declarative/toys/corkboards/content/note-yellow.png and /dev/null differ diff --git a/examples/declarative/toys/corkboards/content/tack.png b/examples/declarative/toys/corkboards/content/tack.png deleted file mode 100644 index cef2d1cd23..0000000000 Binary files a/examples/declarative/toys/corkboards/content/tack.png and /dev/null differ diff --git a/examples/declarative/toys/corkboards/corkboards.qml b/examples/declarative/toys/corkboards/corkboards.qml deleted file mode 100644 index dc3aa6b378..0000000000 --- a/examples/declarative/toys/corkboards/corkboards.qml +++ /dev/null @@ -1,116 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 -import "content" - -Rectangle { - width: 800; height: 480 - color: "#464646" - - ListModel { - id: list - - ListElement { - name: "Sunday" - notes: [ - ListElement { noteText: "Lunch" }, - ListElement { noteText: "Birthday Party" } - ] - } - - ListElement { - name: "Monday" - notes: [ - ListElement { noteText: "Pickup kids from\nschool\n4.30pm" }, - ListElement { noteText: "Checkout Qt" }, ListElement { noteText: "Read email" } - ] - } - - ListElement { - name: "Tuesday" - notes: [ - ListElement { noteText: "Walk dog" }, - ListElement { noteText: "Buy newspaper" } - ] - } - - ListElement { - name: "Wednesday" - notes: [ ListElement { noteText: "Cook dinner" } ] - } - - ListElement { - name: "Thursday" - notes: [ - ListElement { noteText: "Meeting\n5.30pm" }, - ListElement { noteText: "Weed garden" } - ] - } - - ListElement { - name: "Friday" - notes: [ - ListElement { noteText: "More work" }, - ListElement { noteText: "Grocery shopping" } - ] - } - - ListElement { - name: "Saturday" - notes: [ - ListElement { noteText: "Drink" }, - ListElement { noteText: "Download Qt\nPlay with QML" } - ] - } - } - - ListView { - id: flickable - - anchors.fill: parent - focus: true - highlightRangeMode: ListView.StrictlyEnforceRange - orientation: ListView.Horizontal - snapMode: ListView.SnapOneItem - model: list - delegate: Day { } - } -} diff --git a/examples/declarative/toys/dynamicscene/content/Button.qml b/examples/declarative/toys/dynamicscene/content/Button.qml deleted file mode 100644 index 014692274a..0000000000 --- a/examples/declarative/toys/dynamicscene/content/Button.qml +++ /dev/null @@ -1,80 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -Rectangle { - id: container - - property variant text - signal clicked - - height: text.height + 10; width: text.width + 20 - border.width: 1 - radius: 4 - smooth: true - - gradient: Gradient { - GradientStop { - position: 0.0 - color: !mouseArea.pressed ? activePalette.light : activePalette.button - } - GradientStop { - position: 1.0 - color: !mouseArea.pressed ? activePalette.button : activePalette.dark - } - } - - SystemPalette { id: activePalette } - - MouseArea { - id: mouseArea - anchors.fill: parent - onClicked: container.clicked() - } - - Text { - id: text - anchors.centerIn:parent - font.pointSize: 10 - text: parent.text - color: activePalette.buttonText - } -} diff --git a/examples/declarative/toys/dynamicscene/content/GenericSceneItem.qml b/examples/declarative/toys/dynamicscene/content/GenericSceneItem.qml deleted file mode 100644 index 0408aa87fb..0000000000 --- a/examples/declarative/toys/dynamicscene/content/GenericSceneItem.qml +++ /dev/null @@ -1,49 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -Image { - property bool created: false - property string image - - source: image - -} diff --git a/examples/declarative/toys/dynamicscene/content/PaletteItem.qml b/examples/declarative/toys/dynamicscene/content/PaletteItem.qml deleted file mode 100644 index e993f89989..0000000000 --- a/examples/declarative/toys/dynamicscene/content/PaletteItem.qml +++ /dev/null @@ -1,59 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 -import "itemCreation.js" as Code - -Image { - id: paletteItem - - property string componentFile - property string image - - source: image - - MouseArea { - anchors.fill: parent - - onPressed: Code.startDrag(mouse); - onPositionChanged: Code.continueDrag(mouse); - onReleased: Code.endDrag(mouse); - } -} diff --git a/examples/declarative/toys/dynamicscene/content/PerspectiveItem.qml b/examples/declarative/toys/dynamicscene/content/PerspectiveItem.qml deleted file mode 100644 index f651369452..0000000000 --- a/examples/declarative/toys/dynamicscene/content/PerspectiveItem.qml +++ /dev/null @@ -1,65 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -Image { - id: rootItem - - property bool created: false - property string image - - property double scaledBottom: y + (height + height*scale) / 2 - property bool onLand: scaledBottom > (window.height / 2 + window.centerOffset) - - source: image - opacity: onLand ? 1 : 0.25 - scale: Math.max((y + height - 250) * 0.01, 0.3) - smooth: true - - onCreatedChanged: { - if (created && !onLand) - rootItem.destroy(); - else - z = scaledBottom; - } - - onYChanged: z = scaledBottom; -} diff --git a/examples/declarative/toys/dynamicscene/content/Sun.qml b/examples/declarative/toys/dynamicscene/content/Sun.qml deleted file mode 100644 index b84516eecc..0000000000 --- a/examples/declarative/toys/dynamicscene/content/Sun.qml +++ /dev/null @@ -1,78 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -Image { - id: sun - - property bool created: false - property string image: "images/sun.png" - - source: image - - // once item is created, start moving offscreen - NumberAnimation on y { - to: (window.height / 2) + window.centerOffset - running: created - onRunningChanged: { - if (running) - duration = (window.height + window.centerOffset - sun.y) * 10; - else - state = "OffScreen" - } - } - - states: State { - name: "OffScreen" - StateChangeScript { - script: { sun.created = false; sun.destroy() } - } - } - - onCreatedChanged: { - if (created) { - sun.z = 1; // above the sky but below the ground layer - window.activeSuns++; - } else { - window.activeSuns--; - } - } -} diff --git a/examples/declarative/toys/dynamicscene/content/images/NOTE b/examples/declarative/toys/dynamicscene/content/images/NOTE deleted file mode 100644 index fcd87f9132..0000000000 --- a/examples/declarative/toys/dynamicscene/content/images/NOTE +++ /dev/null @@ -1 +0,0 @@ -Images (except star.png) are from the KDE project. diff --git a/examples/declarative/toys/dynamicscene/content/images/face-smile.png b/examples/declarative/toys/dynamicscene/content/images/face-smile.png deleted file mode 100644 index 3d66d72578..0000000000 Binary files a/examples/declarative/toys/dynamicscene/content/images/face-smile.png and /dev/null differ diff --git a/examples/declarative/toys/dynamicscene/content/images/moon.png b/examples/declarative/toys/dynamicscene/content/images/moon.png deleted file mode 100644 index 1c0d6066a8..0000000000 Binary files a/examples/declarative/toys/dynamicscene/content/images/moon.png and /dev/null differ diff --git a/examples/declarative/toys/dynamicscene/content/images/rabbit_brown.png b/examples/declarative/toys/dynamicscene/content/images/rabbit_brown.png deleted file mode 100644 index ebfdeed332..0000000000 Binary files a/examples/declarative/toys/dynamicscene/content/images/rabbit_brown.png and /dev/null differ diff --git a/examples/declarative/toys/dynamicscene/content/images/rabbit_bw.png b/examples/declarative/toys/dynamicscene/content/images/rabbit_bw.png deleted file mode 100644 index 7bff9b92ca..0000000000 Binary files a/examples/declarative/toys/dynamicscene/content/images/rabbit_bw.png and /dev/null differ diff --git a/examples/declarative/toys/dynamicscene/content/images/star.png b/examples/declarative/toys/dynamicscene/content/images/star.png deleted file mode 100644 index 27ef924267..0000000000 Binary files a/examples/declarative/toys/dynamicscene/content/images/star.png and /dev/null differ diff --git a/examples/declarative/toys/dynamicscene/content/images/sun.png b/examples/declarative/toys/dynamicscene/content/images/sun.png deleted file mode 100644 index 7713ca5ce7..0000000000 Binary files a/examples/declarative/toys/dynamicscene/content/images/sun.png and /dev/null differ diff --git a/examples/declarative/toys/dynamicscene/content/images/tree_s.png b/examples/declarative/toys/dynamicscene/content/images/tree_s.png deleted file mode 100644 index 6eac35a729..0000000000 Binary files a/examples/declarative/toys/dynamicscene/content/images/tree_s.png and /dev/null differ diff --git a/examples/declarative/toys/dynamicscene/content/itemCreation.js b/examples/declarative/toys/dynamicscene/content/itemCreation.js deleted file mode 100644 index 40f5415f9f..0000000000 --- a/examples/declarative/toys/dynamicscene/content/itemCreation.js +++ /dev/null @@ -1,62 +0,0 @@ -var itemComponent = null; -var draggedItem = null; -var startingMouse; -var posnInWindow; - -function startDrag(mouse) -{ - posnInWindow = paletteItem.mapToItem(window, 0, 0); - startingMouse = { x: mouse.x, y: mouse.y } - loadComponent(); -} - -//Creation is split into two functions due to an asynchronous wait while -//possible external files are loaded. - -function loadComponent() { - if (itemComponent != null) { // component has been previously loaded - createItem(); - return; - } - - itemComponent = Qt.createComponent(paletteItem.componentFile); - if (itemComponent.status == Component.Loading) //Depending on the content, it can be ready or error immediately - component.statusChanged.connect(createItem); - else - createItem(); -} - -function createItem() { - if (itemComponent.status == Component.Ready && draggedItem == null) { - draggedItem = itemComponent.createObject(window, {"image": paletteItem.image, "x": posnInWindow.x, "y": posnInWindow.y, "z": 3}); - // make sure created item is above the ground layer - } else if (itemComponent.status == Component.Error) { - draggedItem = null; - console.log("error creating component"); - console.log(itemComponent.errorString()); - } -} - -function continueDrag(mouse) -{ - if (draggedItem == null) - return; - - draggedItem.x = mouse.x + posnInWindow.x - startingMouse.x; - draggedItem.y = mouse.y + posnInWindow.y - startingMouse.y; -} - -function endDrag(mouse) -{ - if (draggedItem == null) - return; - - if (draggedItem.y < toolbox.height) { //Don't drop it in the toolbox - draggedItem.destroy(); - draggedItem = null; - } else { - draggedItem.created = true; - draggedItem = null; - } -} - diff --git a/examples/declarative/toys/dynamicscene/dynamicscene.qml b/examples/declarative/toys/dynamicscene/dynamicscene.qml deleted file mode 100644 index e64eb0fd0f..0000000000 --- a/examples/declarative/toys/dynamicscene/dynamicscene.qml +++ /dev/null @@ -1,275 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 -import QtQuick.Particles 2.0 -import "content" - -Item { - id: window - - property int activeSuns: 0 - property int centerOffset: 72 - - height: 480; width: 360 - - - MouseArea { - anchors.fill: parent - onClicked: window.focus = false; - } - - //This is the message box that pops up when there's an error - Rectangle { - id: dialog - - opacity: 0 - anchors.centerIn: parent - width: dialogText.width + 6; height: dialogText.height + 6 - border.color: 'black' - color: 'lightsteelblue' - z: 65535 //Arbitrary number chosen to be above all the items, including the scaled perspective ones. - - function show(str){ - dialogText.text = str; - dialogAnim.start(); - } - - Text { - id: dialogText - x: 3; y: 3 - font.pixelSize: 14 - } - - SequentialAnimation { - id: dialogAnim - NumberAnimation { target: dialog; property:"opacity"; to: 1; duration: 1000 } - PauseAnimation { duration: 5000 } - NumberAnimation { target: dialog; property:"opacity"; to: 0; duration: 1000 } - } - } - - Item { - id: scene - anchors { top: sky.top; bottom: ground.bottom; left: parent.left; right: parent.right} - z: 10 - } - - // sky - Rectangle { - id: sky - anchors { left: parent.left; top: toolbox.bottom; right: parent.right; bottomMargin: -centerOffset; bottom: parent.verticalCenter } - gradient: Gradient { - GradientStop { id: gradientStopA; position: 0.0; color: "#0E1533" } - GradientStop { id: gradientStopB; position: 1.0; color: "#437284" } - } - } - - // stars (when there's no sun) - ParticleSystem { - id: particlesystem - anchors.fill: sky - - ImageParticle { - id: stars - source: "content/images/star.png" - groups: ["stars"] - opacity: .5 - } - - Emitter { - id: starsemitter - anchors.fill: parent - emitRate: parent.width / 50 - lifeSpan: 5000 - group: "stars" - } - } - - // ground - Rectangle { - id: ground - z: 2 // just above the sun so that the sun can set behind it - anchors { left: parent.left; top: parent.verticalCenter; topMargin: centerOffset; right: parent.right; bottom: parent.bottom } - gradient: Gradient { - GradientStop { position: 0.0; color: "ForestGreen" } - GradientStop { position: 1.0; color: "DarkGreen" } - } - } - - SystemPalette { id: activePalette } - - // right-hand panel - Rectangle { - id: toolbox - - height: centerOffset * 2 - color: activePalette.window - anchors { right: parent.right; top: parent.top; left: parent.left} - - Column { - anchors.centerIn: parent - spacing: 8 - - Text { text: "Drag an item into the scene." } - - Rectangle { - width: palette.width + 10; height: palette.height + 10 - border.color: "black" - - Row { - id: palette - anchors.centerIn: parent - spacing: 8 - - PaletteItem { - anchors.verticalCenter: parent.verticalCenter - componentFile: "Sun.qml" - source: "content/images/sun.png" - image: "images/sun.png" - } - PaletteItem { - anchors.verticalCenter: parent.verticalCenter - componentFile: "GenericSceneItem.qml" - source: "content/images/moon.png" - image: "images/moon.png" - } - PaletteItem { - anchors.verticalCenter: parent.verticalCenter - componentFile: "PerspectiveItem.qml" - source: "content/images/tree_s.png" - image: "images/tree_s.png" - } - PaletteItem { - anchors.verticalCenter: parent.verticalCenter - componentFile: "PerspectiveItem.qml" - source: "content/images/rabbit_brown.png" - image: "images/rabbit_brown.png" - } - PaletteItem { - anchors.verticalCenter: parent.verticalCenter - componentFile: "PerspectiveItem.qml" - source: "content/images/rabbit_bw.png" - image: "images/rabbit_bw.png" - } - } - } - - Text { text: "Active Suns: " + activeSuns } - } - } - - //Popup toolbox down the bottom - Rectangle { - id: popupToolbox - z: 1000 - width: parent.width - height: popupColumn.height + 16 - color: activePalette.window - - property bool poppedUp: false - property int downY: window.height - (createButton.height + 16) - property int upY: window.height - (popupColumn.height + 16) - y: poppedUp ? upY : downY - Behavior on y { NumberAnimation {}} - - Column { - id: popupColumn - y: 8 - anchors.centerIn: parent - spacing: 8 - - Row { - height: createButton.height - spacing: 8 - Text { text: "Custom QML:"; anchors.verticalCenter: parent.verticalCenter } - Button { - id: popupButton - text: popupToolbox.poppedUp ? "Hide" : "Show" - onClicked: popupToolbox.poppedUp = !popupToolbox.poppedUp - } - Button { - id: createButton - text: "Create" - onClicked: { - try { - Qt.createQmlObject(qmlText.text, scene, 'CustomObject'); - } catch(err) { - dialog.show('Error on line ' + err.qmlErrors[0].lineNumber + '\n' + err.qmlErrors[0].message); - } - } - } - - } - - Rectangle { - width: 360; height: 240 - - TextEdit { - id: qmlText - anchors.fill: parent; anchors.margins: 5 - readOnly: false - font.pixelSize: 14 - selectByMouse: true - wrapMode: TextEdit.WordWrap - - text: "import QtQuick 2.0\nImage {\n id: smile\n x: 360 * Math.random()\n y: 180 * Math.random() \n source: 'content/images/face-smile.png'\n NumberAnimation on opacity { \n to: 0; duration: 1500\n }\n Component.onCompleted: smile.destroy(1500);\n}" - } - } - } - } - - //Day state, for when a sun is added to the scene - states: State { - name: "Day" - when: window.activeSuns > 0 - - PropertyChanges { target: gradientStopA; color: "DeepSkyBlue" } - PropertyChanges { target: gradientStopB; color: "SkyBlue" } - PropertyChanges { target: stars; opacity: 0 } - } - - //! [top-level transitions] - transitions: Transition { - PropertyAnimation { duration: 3000 } - ColorAnimation { duration: 3000 } - } - //! [top-level transitions] -} diff --git a/examples/declarative/toys/tic-tac-toe/content/Button.qml b/examples/declarative/toys/tic-tac-toe/content/Button.qml deleted file mode 100644 index 6dd141f838..0000000000 --- a/examples/declarative/toys/tic-tac-toe/content/Button.qml +++ /dev/null @@ -1,79 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -Rectangle { - id: container - - property string text - property bool pressed: false - - signal clicked - - width: buttonLabel.width + 20; height: buttonLabel.height + 6 - border { width: 1; color: Qt.darker(container.color) } - radius: 8 - color: "lightgray" - smooth: true - - gradient: Gradient { - GradientStop { - position: 0.0 - color: container.pressed ? "darkgray" : "white" - } - GradientStop { - position: 1.0 - color: container.color - } - } - - MouseArea { - anchors.fill: parent - onClicked: container.clicked() - } - - Text { - id: buttonLabel - anchors.centerIn: container - text: container.text - font.pixelSize: 14 - } -} diff --git a/examples/declarative/toys/tic-tac-toe/content/TicTac.qml b/examples/declarative/toys/tic-tac-toe/content/TicTac.qml deleted file mode 100644 index e74bc6bcda..0000000000 --- a/examples/declarative/toys/tic-tac-toe/content/TicTac.qml +++ /dev/null @@ -1,60 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -Item { - signal clicked - - states: [ - State { name: "X"; PropertyChanges { target: image; source: "pics/x.png" } }, - State { name: "O"; PropertyChanges { target: image; source: "pics/o.png" } } - ] - - Image { - id: image - anchors.centerIn: parent - } - - MouseArea { - anchors.fill: parent - onClicked: parent.clicked() - } -} diff --git a/examples/declarative/toys/tic-tac-toe/content/pics/board.png b/examples/declarative/toys/tic-tac-toe/content/pics/board.png deleted file mode 100644 index 7e5b7ba27c..0000000000 Binary files a/examples/declarative/toys/tic-tac-toe/content/pics/board.png and /dev/null differ diff --git a/examples/declarative/toys/tic-tac-toe/content/pics/o.png b/examples/declarative/toys/tic-tac-toe/content/pics/o.png deleted file mode 100644 index abc7ee020b..0000000000 Binary files a/examples/declarative/toys/tic-tac-toe/content/pics/o.png and /dev/null differ diff --git a/examples/declarative/toys/tic-tac-toe/content/pics/x.png b/examples/declarative/toys/tic-tac-toe/content/pics/x.png deleted file mode 100644 index ddc65c83b8..0000000000 Binary files a/examples/declarative/toys/tic-tac-toe/content/pics/x.png and /dev/null differ diff --git a/examples/declarative/toys/tic-tac-toe/content/tic-tac-toe.js b/examples/declarative/toys/tic-tac-toe/content/tic-tac-toe.js deleted file mode 100644 index 5a166b750f..0000000000 --- a/examples/declarative/toys/tic-tac-toe/content/tic-tac-toe.js +++ /dev/null @@ -1,149 +0,0 @@ -function winner(board) -{ - for (var i=0; i<3; ++i) { - if (board.children[i].state != "" - && board.children[i].state == board.children[i+3].state - && board.children[i].state == board.children[i+6].state) - return true - - if (board.children[i*3].state != "" - && board.children[i*3].state == board.children[i*3+1].state - && board.children[i*3].state == board.children[i*3+2].state) - return true - } - - if (board.children[0].state != "" - && board.children[0].state == board.children[4].state != "" - && board.children[0].state == board.children[8].state != "") - return true - - if (board.children[2].state != "" - && board.children[2].state == board.children[4].state != "" - && board.children[2].state == board.children[6].state != "") - return true - - return false -} - -function restartGame() -{ - game.running = true - - for (var i=0; i<9; ++i) - board.children[i].state = "" -} - -function makeMove(pos, player) -{ - board.children[pos].state = player - if (winner(board)) { - gameFinished(player + " wins") - return true - } else { - return false - } -} - -function canPlayAtPos(pos) -{ - return board.children[pos].state == "" -} - -function computerTurn() -{ - var r = Math.random(); - if (r < game.difficulty) - smartAI(); - else - randomAI(); -} - -function smartAI() -{ - function boardCopy(a) { - var ret = new Object; - ret.children = new Array(9); - for (var i = 0; i<9; i++) { - ret.children[i] = new Object; - ret.children[i].state = a.children[i].state; - } - return ret; - } - - for (var i=0; i<9; i++) { - var simpleBoard = boardCopy(board); - if (canPlayAtPos(i)) { - simpleBoard.children[i].state = "O"; - if (winner(simpleBoard)) { - makeMove(i, "O") - return - } - } - } - for (var i=0; i<9; i++) { - var simpleBoard = boardCopy(board); - if (canPlayAtPos(i)) { - simpleBoard.children[i].state = "X"; - if (winner(simpleBoard)) { - makeMove(i, "O") - return - } - } - } - - function thwart(a,b,c) { //If they are at a, try b or c - if (board.children[a].state == "X") { - if (canPlayAtPos(b)) { - makeMove(b, "O") - return true - } else if (canPlayAtPos(c)) { - makeMove(c, "O") - return true - } - } - return false; - } - - if (thwart(4,0,2)) return; - if (thwart(0,4,3)) return; - if (thwart(2,4,1)) return; - if (thwart(6,4,7)) return; - if (thwart(8,4,5)) return; - if (thwart(1,4,2)) return; - if (thwart(3,4,0)) return; - if (thwart(5,4,8)) return; - if (thwart(7,4,6)) return; - - for (var i =0; i<9; i++) { - if (canPlayAtPos(i)) { - makeMove(i, "O") - return - } - } - restartGame(); -} - -function randomAI() -{ - var unfilledPosns = new Array(); - - for (var i=0; i<9; ++i) { - if (canPlayAtPos(i)) - unfilledPosns.push(i); - } - - if (unfilledPosns.length == 0) { - restartGame(); - } else { - var choice = unfilledPosns[Math.floor(Math.random() * unfilledPosns.length)]; - makeMove(choice, "O"); - } -} - -function gameFinished(message) -{ - messageDisplay.text = message - messageDisplay.visible = true - game.running = false -} - diff --git a/examples/declarative/toys/tic-tac-toe/tic-tac-toe.qml b/examples/declarative/toys/tic-tac-toe/tic-tac-toe.qml deleted file mode 100644 index 8d15233eaa..0000000000 --- a/examples/declarative/toys/tic-tac-toe/tic-tac-toe.qml +++ /dev/null @@ -1,123 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 -import "content" -import "content/tic-tac-toe.js" as Logic - -Rectangle { - id: game - - property bool running: true - property real difficulty: 1.0 //chance it will actually think - - width: display.width; height: display.height + 10 - - Image { - id: boardImage - source: "content/pics/board.png" - } - - - Column { - id: display - - Grid { - id: board - width: boardImage.width; height: boardImage.height - columns: 3 - - Repeater { - model: 9 - - TicTac { - width: board.width/3 - height: board.height/3 - - onClicked: { - if (game.running && Logic.canPlayAtPos(index)) { - if (!Logic.makeMove(index, "X")) - Logic.computerTurn(); - } - } - } - } - } - - Row { - spacing: 4 - anchors.horizontalCenter: parent.horizontalCenter - - Button { - text: "Hard" - pressed: game.difficulty == 1.0 - onClicked: { game.difficulty = 1.0 } - } - Button { - text: "Moderate" - pressed: game.difficulty == 0.8 - onClicked: { game.difficulty = 0.8 } - } - Button { - text: "Easy" - pressed: game.difficulty == 0.2 - onClicked: { game.difficulty = 0.2 } - } - } - } - - - Text { - id: messageDisplay - anchors.centerIn: parent - color: "blue" - style: Text.Outline; styleColor: "white" - font.pixelSize: 50; font.bold: true - visible: false - - Timer { - running: messageDisplay.visible - onTriggered: { - messageDisplay.visible = false; - Logic.restartGame(); - } - } - } -} diff --git a/examples/declarative/toys/tvtennis/tvtennis.qml b/examples/declarative/toys/tvtennis/tvtennis.qml deleted file mode 100644 index 63866e3ce6..0000000000 --- a/examples/declarative/toys/tvtennis/tvtennis.qml +++ /dev/null @@ -1,109 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -Rectangle { - id: page - width: 640; height: 480 - color: "Black" - - // Make a ball to bounce - Rectangle { - id: ball - - // Add a property for the target y coordinate - property variant direction : "right" - - x: 20; width: 20; height: 20; z: 1 - color: "Lime" - - // Move the ball to the right and back to the left repeatedly - SequentialAnimation on x { - loops: Animation.Infinite - NumberAnimation { to: page.width - 40; duration: 2000 } - PropertyAction { target: ball; property: "direction"; value: "left" } - NumberAnimation { to: 20; duration: 2000 } - PropertyAction { target: ball; property: "direction"; value: "right" } - } - - // Make y move with a velocity of 200 - Behavior on y { SpringAnimation{ velocity: 200; } - } - - Component.onCompleted: y = page.height-10; // start the ball motion - - // Detect the ball hitting the top or bottom of the view and bounce it - onYChanged: { - if (y <= 0) { - y = page.height - 20; - } else if (y >= page.height - 20) { - y = 0; - } - } - } - - // Place bats to the left and right of the view, following the y - // coordinates of the ball. - Rectangle { - id: leftBat - color: "Lime" - x: 2; width: 20; height: 90 - y: ball.direction == 'left' ? ball.y - 45 : page.height/2 -45; - Behavior on y { SpringAnimation{ velocity: 300 } } - } - Rectangle { - id: rightBat - color: "Lime" - x: page.width - 22; width: 20; height: 90 - y: ball.direction == 'right' ? ball.y - 45 : page.height/2 -45; - Behavior on y { SpringAnimation{ velocity: 300 } } - } - - // The rest, to make it look realistic, if neither ever scores... - Rectangle { color: "Lime"; x: page.width/2-80; y: 0; width: 40; height: 60 } - Rectangle { color: "Black"; x: page.width/2-70; y: 10; width: 20; height: 40 } - Rectangle { color: "Lime"; x: page.width/2+40; y: 0; width: 40; height: 60 } - Rectangle { color: "Black"; x: page.width/2+50; y: 10; width: 20; height: 40 } - Repeater { - model: page.height / 20 - Rectangle { color: "Lime"; x: page.width/2-5; y: index * 20; width: 10; height: 10 } - } -} diff --git a/examples/declarative/tutorials/dynamicview/dynamicview1/PetsModel.qml b/examples/declarative/tutorials/dynamicview/dynamicview1/PetsModel.qml deleted file mode 100644 index f07613c968..0000000000 --- a/examples/declarative/tutorials/dynamicview/dynamicview1/PetsModel.qml +++ /dev/null @@ -1,102 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -//![0] -import QtQuick 2.0 - -ListModel { - ListElement { - name: "Polly" - type: "Parrot" - age: 12 - size: "Small" - } - ListElement { - name: "Penny" - type: "Turtle" - age: 4 - size: "Small" - } -//![0] - ListElement { - name: "Warren" - type: "Rabbit" - age: 2 - size: "Small" - } - ListElement { - name: "Spot" - type: "Dog" - age: 9 - size: "Medium" - } - ListElement { - name: "Schrödinger" - type: "Cat" - age: 2 - size: "Medium" - } - ListElement { - name: "Joey" - type: "Kangaroo" - age: 1 - size: "Medium" - } - ListElement { - name: "Kimba" - type: "Bunny" - age: 65 - size: "Large" - } - ListElement { - name: "Rover" - type: "Dog" - age: 5 - size: "Large" - } - ListElement { - name: "Tiny" - type: "Elephant" - age: 15 - size: "Large" - } -//![1] -} -//![1] diff --git a/examples/declarative/tutorials/dynamicview/dynamicview1/dynamicview.qml b/examples/declarative/tutorials/dynamicview/dynamicview1/dynamicview.qml deleted file mode 100644 index 1a9dd453ce..0000000000 --- a/examples/declarative/tutorials/dynamicview/dynamicview1/dynamicview.qml +++ /dev/null @@ -1,90 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -//![0] -import QtQuick 2.0 - -Rectangle { - id: root - - width: 300; height: 400 - -//![1] - Component { - id: dragDelegate - - Rectangle { - id: content - - anchors { left: parent.left; right: parent.right } - height: column.implicitHeight + 4 - - border.width: 1 - border.color: "lightsteelblue" - - radius: 2 - - Column { - id: column - anchors { fill: parent; margins: 2 } - - Text { text: 'Name: ' + name } - Text { text: 'Type: ' + type } - Text { text: 'Age: ' + age } - Text { text: 'Size: ' + size } - } - } - } -//![1] -//![2] - ListView { - id: view - - anchors { fill: parent; margins: 2 } - - model: PetsModel {} - delegate: dragDelegate - - spacing: 4 - cacheBuffer: 50 - } -//![2] -} -//![0] diff --git a/examples/declarative/tutorials/dynamicview/dynamicview2/PetsModel.qml b/examples/declarative/tutorials/dynamicview/dynamicview2/PetsModel.qml deleted file mode 100644 index 4f2087d95e..0000000000 --- a/examples/declarative/tutorials/dynamicview/dynamicview2/PetsModel.qml +++ /dev/null @@ -1,98 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -ListModel { - ListElement { - name: "Polly" - type: "Parrot" - age: 12 - size: "Small" - } - ListElement { - name: "Penny" - type: "Turtle" - age: 4 - size: "Small" - } - ListElement { - name: "Warren" - type: "Rabbit" - age: 2 - size: "Small" - } - ListElement { - name: "Spot" - type: "Dog" - age: 9 - size: "Medium" - } - ListElement { - name: "Schrödinger" - type: "Cat" - age: 2 - size: "Medium" - } - ListElement { - name: "Joey" - type: "Kangaroo" - age: 1 - size: "Medium" - } - ListElement { - name: "Kimba" - type: "Bunny" - age: 65 - size: "Large" - } - ListElement { - name: "Rover" - type: "Dog" - age: 5 - size: "Large" - } - ListElement { - name: "Tiny" - type: "Elephant" - age: 15 - size: "Large" - } -} diff --git a/examples/declarative/tutorials/dynamicview/dynamicview2/dynamicview.qml b/examples/declarative/tutorials/dynamicview/dynamicview2/dynamicview.qml deleted file mode 100644 index 9e654a685c..0000000000 --- a/examples/declarative/tutorials/dynamicview/dynamicview2/dynamicview.qml +++ /dev/null @@ -1,121 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -Rectangle { - id: root - - width: 300; height: 400 - -//![0] - Component { - id: dragDelegate - -//![1] - MouseArea { - id: dragArea - - property bool held: false - - anchors { left: parent.left; right: parent.right } - height: content.height - - drag.target: held ? content : undefined - drag.axis: Drag.YAxis - - onPressAndHold: held = true - onReleased: held = false - - Rectangle { - id: content -//![1] - anchors { - horizontalCenter: parent.horizontalCenter - verticalCenter: parent.verticalCenter - } - width: dragArea.width; height: column.implicitHeight + 4 - - border.width: 1 - border.color: "lightsteelblue" -//![3] - color: dragArea.held ? "lightsteelblue" : "white" - Behavior on color { ColorAnimation { duration: 100 } } -//![3] - radius: 2 -//![4] - states: State { - when: dragArea.held - - ParentChange { target: content; parent: root } - AnchorChanges { - target: content - anchors { horizontalCenter: undefined; verticalCenter: undefined } - } - } -//![4] - Column { - id: column - anchors { fill: parent; margins: 2 } - - Text { text: 'Name: ' + name } - Text { text: 'Type: ' + type } - Text { text: 'Age: ' + age } - Text { text: 'Size: ' + size } - } -//![2] - } - } -//![2] - } -//![0] - - ListView { - id: view - - anchors { fill: parent; margins: 2 } - - model: PetsModel {} - delegate: dragDelegate - - spacing: 4 - cacheBuffer: 50 - } -} diff --git a/examples/declarative/tutorials/dynamicview/dynamicview3/PetsModel.qml b/examples/declarative/tutorials/dynamicview/dynamicview3/PetsModel.qml deleted file mode 100644 index 4f2087d95e..0000000000 --- a/examples/declarative/tutorials/dynamicview/dynamicview3/PetsModel.qml +++ /dev/null @@ -1,98 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -ListModel { - ListElement { - name: "Polly" - type: "Parrot" - age: 12 - size: "Small" - } - ListElement { - name: "Penny" - type: "Turtle" - age: 4 - size: "Small" - } - ListElement { - name: "Warren" - type: "Rabbit" - age: 2 - size: "Small" - } - ListElement { - name: "Spot" - type: "Dog" - age: 9 - size: "Medium" - } - ListElement { - name: "Schrödinger" - type: "Cat" - age: 2 - size: "Medium" - } - ListElement { - name: "Joey" - type: "Kangaroo" - age: 1 - size: "Medium" - } - ListElement { - name: "Kimba" - type: "Bunny" - age: 65 - size: "Large" - } - ListElement { - name: "Rover" - type: "Dog" - age: 5 - size: "Large" - } - ListElement { - name: "Tiny" - type: "Elephant" - age: 15 - size: "Large" - } -} diff --git a/examples/declarative/tutorials/dynamicview/dynamicview3/dynamicview.qml b/examples/declarative/tutorials/dynamicview/dynamicview3/dynamicview.qml deleted file mode 100644 index 5a579f78d9..0000000000 --- a/examples/declarative/tutorials/dynamicview/dynamicview3/dynamicview.qml +++ /dev/null @@ -1,143 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 -//![0] -Rectangle { - id: root - - width: 300; height: 400 - - Component { - id: dragDelegate - - MouseArea { - id: dragArea - - property bool held: false - - anchors { left: parent.left; right: parent.right } - height: content.height - - drag.target: held ? content : undefined - drag.axis: Drag.YAxis - - onPressAndHold: held = true - onReleased: held = false - - Rectangle { - id: content -//![0] - anchors { - horizontalCenter: parent.horizontalCenter - verticalCenter: parent.verticalCenter - } - width: dragArea.width; height: column.implicitHeight + 4 - - border.width: 1 - border.color: "lightsteelblue" - - color: dragArea.held ? "lightsteelblue" : "white" - Behavior on color { ColorAnimation { duration: 100 } } - - radius: 2 -//![1] - Drag.active: dragArea.held - Drag.source: dragArea - Drag.hotSpot.x: width / 2 - Drag.hotSpot.y: height / 2 -//![1] - states: State { - when: dragArea.held - - ParentChange { target: content; parent: root } - AnchorChanges { - target: content - anchors { horizontalCenter: undefined; verticalCenter: undefined } - } - } - - Column { - id: column - anchors { fill: parent; margins: 2 } - - Text { text: 'Name: ' + name } - Text { text: 'Type: ' + type } - Text { text: 'Age: ' + age } - Text { text: 'Size: ' + size } - } -//![2] - } -//![3] - DropArea { - anchors { fill: parent; margins: 10 } - - onEntered: { - visualModel.items.move( - drag.source.VisualDataModel.itemsIndex, - dragArea.VisualDataModel.itemsIndex) - } - } -//![3] - } - } -//![2] -//![4] - VisualDataModel { - id: visualModel - - model: PetsModel {} - delegate: dragDelegate - } - - ListView { - id: view - - anchors { fill: parent; margins: 2 } - - model: visualModel - - spacing: 4 - cacheBuffer: 50 - } -//![4] -//![5] -} -//![5] diff --git a/examples/declarative/tutorials/dynamicview/dynamicview4/ListSelector.qml b/examples/declarative/tutorials/dynamicview/dynamicview4/ListSelector.qml deleted file mode 100644 index c6b8287beb..0000000000 --- a/examples/declarative/tutorials/dynamicview/dynamicview4/ListSelector.qml +++ /dev/null @@ -1,120 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -Item { - id: selector - - property alias list: view.model - property alias selectedIndex: view.currentIndex - property alias label: labelText.text - property bool expanded - - width: 100; height: labelText.implicitHeight + 26 - - Rectangle { - anchors { left: parent.left; right: parent.right; bottom: parent.bottom; } - - height: labelText.implicitHeight + 4 + (expanded ? 20 * view.count : 20) - Behavior on height { NumberAnimation { duration: 300 } } - - radius: 2 - border.width: 1 - border.color: "yellow" - color: "yellow" - - MouseArea { - anchors.fill: parent - - onClicked: selector.expanded = !selector.expanded - - Text { - id: labelText - anchors { left: parent.left; top: parent.top; margins: 2 } - } - - Rectangle { - anchors { - left: parent.left; top: labelText.bottom; - right: parent.right; bottom: parent.bottom; - margins: 2 - leftMargin: 10 - } - - radius: 2 - color: "white" - - ListView { - id: view - - anchors.fill: parent - - clip: true - - delegate: Text { - anchors { left: parent.left; right: parent.right } - height: 20 - - verticalAlignment: Text.AlignVCenter - - text: modelData - - MouseArea { - anchors.fill: parent - - onClicked: { - view.currentIndex = index - selector.expanded = !selector.expanded - } - } - } - highlight: Rectangle { - anchors { left: parent.left; right: parent.right } - height: 20 - radius: 2 - - color: "yellow" - } - } - } - } - } -} diff --git a/examples/declarative/tutorials/dynamicview/dynamicview4/PetsModel.qml b/examples/declarative/tutorials/dynamicview/dynamicview4/PetsModel.qml deleted file mode 100644 index 4f2087d95e..0000000000 --- a/examples/declarative/tutorials/dynamicview/dynamicview4/PetsModel.qml +++ /dev/null @@ -1,98 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -ListModel { - ListElement { - name: "Polly" - type: "Parrot" - age: 12 - size: "Small" - } - ListElement { - name: "Penny" - type: "Turtle" - age: 4 - size: "Small" - } - ListElement { - name: "Warren" - type: "Rabbit" - age: 2 - size: "Small" - } - ListElement { - name: "Spot" - type: "Dog" - age: 9 - size: "Medium" - } - ListElement { - name: "Schrödinger" - type: "Cat" - age: 2 - size: "Medium" - } - ListElement { - name: "Joey" - type: "Kangaroo" - age: 1 - size: "Medium" - } - ListElement { - name: "Kimba" - type: "Bunny" - age: 65 - size: "Large" - } - ListElement { - name: "Rover" - type: "Dog" - age: 5 - size: "Large" - } - ListElement { - name: "Tiny" - type: "Elephant" - age: 15 - size: "Large" - } -} diff --git a/examples/declarative/tutorials/dynamicview/dynamicview4/dynamicview.qml b/examples/declarative/tutorials/dynamicview/dynamicview4/dynamicview.qml deleted file mode 100644 index 9bd4e0c438..0000000000 --- a/examples/declarative/tutorials/dynamicview/dynamicview4/dynamicview.qml +++ /dev/null @@ -1,219 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -Rectangle { - id: root - - width: 300; height: 400 - - Component { - id: dragDelegate - - MouseArea { - id: dragArea - - property bool held: false - - anchors { left: parent.left; right: parent.right } - height: content.height - - enabled: visualModel.sortOrder == visualModel.lessThan.length - - drag.target: held ? content : undefined - drag.axis: Drag.YAxis - - onPressAndHold: held = true - onReleased: held = false - - Rectangle { - id: content - - anchors { - horizontalCenter: parent.horizontalCenter - verticalCenter: parent.verticalCenter - } - width: dragArea.width; height: column.implicitHeight + 4 - - border.width: 1 - border.color: "lightsteelblue" - - color: dragArea.held ? "lightsteelblue" : "white" - Behavior on color { ColorAnimation { duration: 100 } } - - radius: 2 - - Drag.active: dragArea.held - Drag.source: dragArea - Drag.hotSpot.x: width / 2 - Drag.hotSpot.y: height / 2 - - states: State { - when: dragArea.held - - ParentChange { target: content; parent: root } - AnchorChanges { - target: content - anchors { horizontalCenter: undefined; verticalCenter: undefined } - } - } - - Column { - id: column - anchors { fill: parent; margins: 2 } - - Text { text: 'Name: ' + name } - Text { text: 'Type: ' + type } - Text { text: 'Age: ' + age } - Text { text: 'Size: ' + size } - } - } - - DropArea { - anchors { fill: parent; margins: 10 } - - onEntered: { - visualModel.items.move( - drag.source.VisualDataModel.itemsIndex, - dragArea.VisualDataModel.itemsIndex) - } - } - } - } -//![0] - VisualDataModel { - id: visualModel -//![4] - property var lessThan: [ - function(left, right) { return left.name < right.name }, - function(left, right) { return left.type < right.type }, - function(left, right) { return left.age < right.age }, - function(left, right) { - if (left.size == "Small") - return true - else if (right.size == "Small") - return false - else if (left.size == "Medium") - return true - else - return false - } - ] -//![4] -//![6] - - property int sortOrder: orderSelector.selectedIndex - onSortOrderChanged: items.setGroups(0, items.count, "unsorted") - -//![6] -//![3] - function insertPosition(lessThan, item) { - var lower = 0 - var upper = items.count - while (lower < upper) { - var middle = Math.floor(lower + (upper - lower) / 2) - var result = lessThan(item.model, items.get(middle).model); - if (result) { - upper = middle - } else { - lower = middle + 1 - } - } - return lower - } - - function sort(lessThan) { - while (unsortedItems.count > 0) { - var item = unsortedItems.get(0) - var index = insertPosition(lessThan, item) - - item.groups = "items" - items.move(item.itemsIndex, index) - } - } -//![3] - -//![1] - items.includeByDefault: false -//![5] - groups: VisualDataGroup { - id: unsortedItems - name: "unsorted" - - includeByDefault: true -//![1] - onChanged: { - if (visualModel.sortOrder == visualModel.lessThan.length) - setGroups(0, count, "items") - else - visualModel.sort(visualModel.lessThan[visualModel.sortOrder]) - } -//![2] - } -//![2] -//![5] - model: PetsModel {} - delegate: dragDelegate - } -//![0] - ListView { - id: view - - anchors { - left: parent.left; top: parent.top; right: parent.right; bottom: orderSelector.top; - margins: 2 - } - - model: visualModel - - spacing: 4 - cacheBuffer: 50 - } - - ListSelector { - id: orderSelector - - anchors { left: parent.left; right: parent.right; bottom: parent.bottom; margins: 2 } - - label: "Sort By" - list: [ "Name", "Type", "Age", "Size", "Custom" ] - } -} diff --git a/examples/declarative/tutorials/extending/chapter1-basics/app.qml b/examples/declarative/tutorials/extending/chapter1-basics/app.qml deleted file mode 100644 index 6f0c1d3a23..0000000000 --- a/examples/declarative/tutorials/extending/chapter1-basics/app.qml +++ /dev/null @@ -1,60 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -//![0] -import Charts 1.0 -import QtQuick 2.0 - -Item { - width: 300; height: 200 - - PieChart { - id: aPieChart - anchors.centerIn: parent - width: 100; height: 100 - name: "A simple pie chart" - color: "red" - } - - Text { - anchors { bottom: parent.bottom; horizontalCenter: parent.horizontalCenter; bottomMargin: 20 } - text: aPieChart.name - } -} -//![0] diff --git a/examples/declarative/tutorials/extending/chapter1-basics/chapter1-basics.pro b/examples/declarative/tutorials/extending/chapter1-basics/chapter1-basics.pro deleted file mode 100644 index affc57ce1f..0000000000 --- a/examples/declarative/tutorials/extending/chapter1-basics/chapter1-basics.pro +++ /dev/null @@ -1,5 +0,0 @@ -QT += declarative quick - -HEADERS += piechart.h -SOURCES += piechart.cpp \ - main.cpp diff --git a/examples/declarative/tutorials/extending/chapter1-basics/main.cpp b/examples/declarative/tutorials/extending/chapter1-basics/main.cpp deleted file mode 100644 index ed9e412bd6..0000000000 --- a/examples/declarative/tutorials/extending/chapter1-basics/main.cpp +++ /dev/null @@ -1,57 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -//![0] -#include "piechart.h" -#include -#include - -int main(int argc, char *argv[]) -{ - QGuiApplication app(argc, argv); - - qmlRegisterType("Charts", 1, 0, "PieChart"); - - QQuickView view; - view.setResizeMode(QQuickView::SizeRootObjectToView); - view.setSource(QUrl::fromLocalFile("app.qml")); - view.show(); - return app.exec(); -} -//![0] diff --git a/examples/declarative/tutorials/extending/chapter1-basics/piechart.cpp b/examples/declarative/tutorials/extending/chapter1-basics/piechart.cpp deleted file mode 100644 index bc81d6a3a0..0000000000 --- a/examples/declarative/tutorials/extending/chapter1-basics/piechart.cpp +++ /dev/null @@ -1,79 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include "piechart.h" -#include - -//![0] -PieChart::PieChart(QQuickItem *parent) - : QQuickPaintedItem(parent) -{ -} -//![0] - -QString PieChart::name() const -{ - return m_name; -} - -void PieChart::setName(const QString &name) -{ - m_name = name; -} - -QColor PieChart::color() const -{ - return m_color; -} - -void PieChart::setColor(const QColor &color) -{ - m_color = color; -} - -//![1] -void PieChart::paint(QPainter *painter) -{ - QPen pen(m_color, 2); - painter->setPen(pen); - painter->setRenderHints(QPainter::HighQualityAntialiasing, true); - painter->drawPie(boundingRect(), 90 * 16, 290 * 16); -} -//![1] - diff --git a/examples/declarative/tutorials/extending/chapter1-basics/piechart.h b/examples/declarative/tutorials/extending/chapter1-basics/piechart.h deleted file mode 100644 index 71a8786e7d..0000000000 --- a/examples/declarative/tutorials/extending/chapter1-basics/piechart.h +++ /dev/null @@ -1,71 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#ifndef PIECHART_H -#define PIECHART_H - -//![0] -#include -#include - -class PieChart : public QQuickPaintedItem -{ - Q_OBJECT - Q_PROPERTY(QString name READ name WRITE setName) - Q_PROPERTY(QColor color READ color WRITE setColor) - -public: - PieChart(QQuickItem *parent = 0); - - QString name() const; - void setName(const QString &name); - - QColor color() const; - void setColor(const QColor &color); - - void paint(QPainter *painter); - -private: - QString m_name; - QColor m_color; -}; -//![0] - -#endif - diff --git a/examples/declarative/tutorials/extending/chapter2-methods/app.qml b/examples/declarative/tutorials/extending/chapter2-methods/app.qml deleted file mode 100644 index eee0933734..0000000000 --- a/examples/declarative/tutorials/extending/chapter2-methods/app.qml +++ /dev/null @@ -1,66 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -//![0] -import Charts 1.0 -import QtQuick 2.0 - -Item { - width: 300; height: 200 - - PieChart { - id: aPieChart - anchors.centerIn: parent - width: 100; height: 100 - color: "red" - - onChartCleared: console.log("The chart has been cleared") - } - - MouseArea { - anchors.fill: parent - onClicked: aPieChart.clearChart() - } - - Text { - anchors { bottom: parent.bottom; horizontalCenter: parent.horizontalCenter; bottomMargin: 20 } - text: "Click anywhere to clear the chart" - } -} -//![0] diff --git a/examples/declarative/tutorials/extending/chapter2-methods/chapter2-methods.pro b/examples/declarative/tutorials/extending/chapter2-methods/chapter2-methods.pro deleted file mode 100644 index affc57ce1f..0000000000 --- a/examples/declarative/tutorials/extending/chapter2-methods/chapter2-methods.pro +++ /dev/null @@ -1,5 +0,0 @@ -QT += declarative quick - -HEADERS += piechart.h -SOURCES += piechart.cpp \ - main.cpp diff --git a/examples/declarative/tutorials/extending/chapter2-methods/main.cpp b/examples/declarative/tutorials/extending/chapter2-methods/main.cpp deleted file mode 100644 index ed9e412bd6..0000000000 --- a/examples/declarative/tutorials/extending/chapter2-methods/main.cpp +++ /dev/null @@ -1,57 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -//![0] -#include "piechart.h" -#include -#include - -int main(int argc, char *argv[]) -{ - QGuiApplication app(argc, argv); - - qmlRegisterType("Charts", 1, 0, "PieChart"); - - QQuickView view; - view.setResizeMode(QQuickView::SizeRootObjectToView); - view.setSource(QUrl::fromLocalFile("app.qml")); - view.show(); - return app.exec(); -} -//![0] diff --git a/examples/declarative/tutorials/extending/chapter2-methods/piechart.cpp b/examples/declarative/tutorials/extending/chapter2-methods/piechart.cpp deleted file mode 100644 index 71be74e943..0000000000 --- a/examples/declarative/tutorials/extending/chapter2-methods/piechart.cpp +++ /dev/null @@ -1,84 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include "piechart.h" -#include - -PieChart::PieChart(QQuickItem *parent) - : QQuickPaintedItem(parent) -{ -} - -QString PieChart::name() const -{ - return m_name; -} - -void PieChart::setName(const QString &name) -{ - m_name = name; -} - -QColor PieChart::color() const -{ - return m_color; -} - -void PieChart::setColor(const QColor &color) -{ - m_color = color; -} - -void PieChart::paint(QPainter *painter) -{ - QPen pen(m_color, 2); - painter->setPen(pen); - painter->setRenderHints(QPainter::HighQualityAntialiasing, true); - painter->drawPie(boundingRect(), 90 * 16, 290 * 16); -} - -//![0] -void PieChart::clearChart() -{ - setColor(QColor(Qt::transparent)); - update(); - - emit chartCleared(); -} -//![0] diff --git a/examples/declarative/tutorials/extending/chapter2-methods/piechart.h b/examples/declarative/tutorials/extending/chapter2-methods/piechart.h deleted file mode 100644 index 7650d6e8d7..0000000000 --- a/examples/declarative/tutorials/extending/chapter2-methods/piechart.h +++ /dev/null @@ -1,84 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#ifndef PIECHART_H -#define PIECHART_H - -#include -#include - -//![0] -class PieChart : public QQuickPaintedItem -{ -//![0] - Q_OBJECT - Q_PROPERTY(QString name READ name WRITE setName) - Q_PROPERTY(QColor color READ color WRITE setColor) - -//![1] -public: -//![1] - - PieChart(QQuickItem *parent = 0); - - QString name() const; - void setName(const QString &name); - - QColor color() const; - void setColor(const QColor &color); - - void paint(QPainter *painter); - -//![2] - Q_INVOKABLE void clearChart(); - -signals: - void chartCleared(); -//![2] - -private: - QString m_name; - QColor m_color; - -//![3] -}; -//![3] - -#endif - diff --git a/examples/declarative/tutorials/extending/chapter3-bindings/app.qml b/examples/declarative/tutorials/extending/chapter3-bindings/app.qml deleted file mode 100644 index 4ad929132c..0000000000 --- a/examples/declarative/tutorials/extending/chapter3-bindings/app.qml +++ /dev/null @@ -1,74 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -//![0] -import Charts 1.0 -import QtQuick 2.0 - -Item { - width: 300; height: 200 - - Row { - anchors.centerIn: parent - spacing: 20 - - PieChart { - id: chartA - width: 100; height: 100 - color: "red" - } - - PieChart { - id: chartB - width: 100; height: 100 - color: chartA.color - } - } - - MouseArea { - anchors.fill: parent - onClicked: { chartA.color = "blue" } - } - - Text { - anchors { bottom: parent.bottom; horizontalCenter: parent.horizontalCenter; bottomMargin: 20 } - text: "Click anywhere to change the chart color" - } -} -//![0] diff --git a/examples/declarative/tutorials/extending/chapter3-bindings/chapter3-bindings.pro b/examples/declarative/tutorials/extending/chapter3-bindings/chapter3-bindings.pro deleted file mode 100644 index affc57ce1f..0000000000 --- a/examples/declarative/tutorials/extending/chapter3-bindings/chapter3-bindings.pro +++ /dev/null @@ -1,5 +0,0 @@ -QT += declarative quick - -HEADERS += piechart.h -SOURCES += piechart.cpp \ - main.cpp diff --git a/examples/declarative/tutorials/extending/chapter3-bindings/main.cpp b/examples/declarative/tutorials/extending/chapter3-bindings/main.cpp deleted file mode 100644 index ed9e412bd6..0000000000 --- a/examples/declarative/tutorials/extending/chapter3-bindings/main.cpp +++ /dev/null @@ -1,57 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -//![0] -#include "piechart.h" -#include -#include - -int main(int argc, char *argv[]) -{ - QGuiApplication app(argc, argv); - - qmlRegisterType("Charts", 1, 0, "PieChart"); - - QQuickView view; - view.setResizeMode(QQuickView::SizeRootObjectToView); - view.setSource(QUrl::fromLocalFile("app.qml")); - view.show(); - return app.exec(); -} -//![0] diff --git a/examples/declarative/tutorials/extending/chapter3-bindings/piechart.cpp b/examples/declarative/tutorials/extending/chapter3-bindings/piechart.cpp deleted file mode 100644 index 2a392125da..0000000000 --- a/examples/declarative/tutorials/extending/chapter3-bindings/piechart.cpp +++ /dev/null @@ -1,86 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include "piechart.h" -#include - -PieChart::PieChart(QQuickItem *parent) - : QQuickPaintedItem(parent) -{ -} - -QString PieChart::name() const -{ - return m_name; -} - -void PieChart::setName(const QString &name) -{ - m_name = name; -} - -QColor PieChart::color() const -{ - return m_color; -} - -//![0] -void PieChart::setColor(const QColor &color) -{ - if (color != m_color) { - m_color = color; - update(); // repaint with the new color - emit colorChanged(); - } -} -//![0] - -void PieChart::paint(QPainter *painter) -{ - QPen pen(m_color, 2); - painter->setPen(pen); - painter->setRenderHints(QPainter::HighQualityAntialiasing, true); - painter->drawPie(boundingRect(), 90 * 16, 290 * 16); -} - -void PieChart::clearChart() -{ - setColor(QColor(Qt::transparent)); - update(); -} diff --git a/examples/declarative/tutorials/extending/chapter3-bindings/piechart.h b/examples/declarative/tutorials/extending/chapter3-bindings/piechart.h deleted file mode 100644 index 77075b5727..0000000000 --- a/examples/declarative/tutorials/extending/chapter3-bindings/piechart.h +++ /dev/null @@ -1,84 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#ifndef PIECHART_H -#define PIECHART_H - -#include -#include - -//![0] -class PieChart : public QQuickPaintedItem -{ -//![0] - Q_OBJECT - Q_PROPERTY(QString name READ name WRITE setName) - -//![1] - Q_PROPERTY(QColor color READ color WRITE setColor NOTIFY colorChanged) -public: -//![1] - - PieChart(QQuickItem *parent = 0); - - QString name() const; - void setName(const QString &name); - - QColor color() const; - void setColor(const QColor &color); - - void paint(QPainter *painter); - - Q_INVOKABLE void clearChart(); - -//![2] -signals: - void colorChanged(); -//![2] - -private: - QString m_name; - QColor m_color; - -//![3] -}; -//![3] - -#endif - diff --git a/examples/declarative/tutorials/extending/chapter4-customPropertyTypes/app.qml b/examples/declarative/tutorials/extending/chapter4-customPropertyTypes/app.qml deleted file mode 100644 index 06490773f4..0000000000 --- a/examples/declarative/tutorials/extending/chapter4-customPropertyTypes/app.qml +++ /dev/null @@ -1,60 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -//![0] -import Charts 1.0 -import QtQuick 2.0 - -Item { - width: 300; height: 200 - - PieChart { - id: chart - anchors.centerIn: parent - width: 100; height: 100 - - pieSlice: PieSlice { - anchors.fill: parent - color: "red" - } - } - - Component.onCompleted: console.log("The pie is colored " + chart.pieSlice.color) -} -//![0] diff --git a/examples/declarative/tutorials/extending/chapter4-customPropertyTypes/chapter4-customPropertyTypes.pro b/examples/declarative/tutorials/extending/chapter4-customPropertyTypes/chapter4-customPropertyTypes.pro deleted file mode 100644 index 6724fa0375..0000000000 --- a/examples/declarative/tutorials/extending/chapter4-customPropertyTypes/chapter4-customPropertyTypes.pro +++ /dev/null @@ -1,7 +0,0 @@ -QT += declarative quick - -HEADERS += piechart.h \ - pieslice.h -SOURCES += piechart.cpp \ - pieslice.cpp \ - main.cpp diff --git a/examples/declarative/tutorials/extending/chapter4-customPropertyTypes/main.cpp b/examples/declarative/tutorials/extending/chapter4-customPropertyTypes/main.cpp deleted file mode 100644 index 537ea766fc..0000000000 --- a/examples/declarative/tutorials/extending/chapter4-customPropertyTypes/main.cpp +++ /dev/null @@ -1,66 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include "piechart.h" -#include "pieslice.h" - -#include -#include - -//![0] -int main(int argc, char *argv[]) -{ -//![0] - QGuiApplication app(argc, argv); - - qmlRegisterType("Charts", 1, 0, "PieChart"); - -//![1] - qmlRegisterType("Charts", 1, 0, "PieSlice"); -//![1] - - QQuickView view; - view.setResizeMode(QQuickView::SizeRootObjectToView); - view.setSource(QUrl::fromLocalFile("app.qml")); - view.show(); - return app.exec(); - -//![2] -} -//![2] diff --git a/examples/declarative/tutorials/extending/chapter4-customPropertyTypes/piechart.cpp b/examples/declarative/tutorials/extending/chapter4-customPropertyTypes/piechart.cpp deleted file mode 100644 index 3cf9bdc00c..0000000000 --- a/examples/declarative/tutorials/extending/chapter4-customPropertyTypes/piechart.cpp +++ /dev/null @@ -1,70 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include "piechart.h" -#include "pieslice.h" - -PieChart::PieChart(QQuickItem *parent) - : QQuickItem(parent) -{ -} - -QString PieChart::name() const -{ - return m_name; -} - -void PieChart::setName(const QString &name) -{ - m_name = name; -} - -PieSlice *PieChart::pieSlice() const -{ - return m_pieSlice; -} - -//![0] -void PieChart::setPieSlice(PieSlice *pieSlice) -{ - m_pieSlice = pieSlice; - pieSlice->setParentItem(this); -} -//![0] - diff --git a/examples/declarative/tutorials/extending/chapter4-customPropertyTypes/piechart.h b/examples/declarative/tutorials/extending/chapter4-customPropertyTypes/piechart.h deleted file mode 100644 index b89db5a2b1..0000000000 --- a/examples/declarative/tutorials/extending/chapter4-customPropertyTypes/piechart.h +++ /dev/null @@ -1,78 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#ifndef PIECHART_H -#define PIECHART_H - -#include - -class PieSlice; - -//![0] -class PieChart : public QQuickItem -{ - Q_OBJECT - Q_PROPERTY(PieSlice* pieSlice READ pieSlice WRITE setPieSlice) -//![0] - Q_PROPERTY(QString name READ name WRITE setName) - -//![1] -public: -//![1] - - PieChart(QQuickItem *parent = 0); - - QString name() const; - void setName(const QString &name); - -//![2] - PieSlice *pieSlice() const; - void setPieSlice(PieSlice *pieSlice); -//![2] - -private: - QString m_name; - PieSlice *m_pieSlice; - -//![3] -}; -//![3] - -#endif - diff --git a/examples/declarative/tutorials/extending/chapter4-customPropertyTypes/pieslice.cpp b/examples/declarative/tutorials/extending/chapter4-customPropertyTypes/pieslice.cpp deleted file mode 100644 index 654a46fc8d..0000000000 --- a/examples/declarative/tutorials/extending/chapter4-customPropertyTypes/pieslice.cpp +++ /dev/null @@ -1,66 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include "pieslice.h" - -#include - -PieSlice::PieSlice(QQuickItem *parent) - : QQuickPaintedItem(parent) -{ -} - -QColor PieSlice::color() const -{ - return m_color; -} - -void PieSlice::setColor(const QColor &color) -{ - m_color = color; -} - -void PieSlice::paint(QPainter *painter) -{ - QPen pen(m_color, 2); - painter->setPen(pen); - painter->setRenderHints(QPainter::HighQualityAntialiasing, true); - painter->drawPie(boundingRect(), 90 * 16, 290 * 16); -} - diff --git a/examples/declarative/tutorials/extending/chapter4-customPropertyTypes/pieslice.h b/examples/declarative/tutorials/extending/chapter4-customPropertyTypes/pieslice.h deleted file mode 100644 index 8fc445d471..0000000000 --- a/examples/declarative/tutorials/extending/chapter4-customPropertyTypes/pieslice.h +++ /dev/null @@ -1,66 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#ifndef PIESLICE_H -#define PIESLICE_H - -#include -#include - -//![0] -class PieSlice : public QQuickPaintedItem -{ - Q_OBJECT - Q_PROPERTY(QColor color READ color WRITE setColor) - -public: - PieSlice(QQuickItem *parent = 0); - - QColor color() const; - void setColor(const QColor &color); - - void paint(QPainter *painter); - -private: - QColor m_color; -}; -//![0] - -#endif - diff --git a/examples/declarative/tutorials/extending/chapter5-listproperties/app.qml b/examples/declarative/tutorials/extending/chapter5-listproperties/app.qml deleted file mode 100644 index 37b0626948..0000000000 --- a/examples/declarative/tutorials/extending/chapter5-listproperties/app.qml +++ /dev/null @@ -1,70 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -//![0] -import Charts 1.0 -import QtQuick 2.0 - -Item { - width: 300; height: 200 - - PieChart { - anchors.centerIn: parent - width: 100; height: 100 - - slices: [ - PieSlice { - anchors.fill: parent - color: "red" - fromAngle: 0; angleSpan: 110 - }, - PieSlice { - anchors.fill: parent - color: "black" - fromAngle: 110; angleSpan: 50 - }, - PieSlice { - anchors.fill: parent - color: "blue" - fromAngle: 160; angleSpan: 100 - } - ] - } -} -//![0] diff --git a/examples/declarative/tutorials/extending/chapter5-listproperties/chapter5-listproperties.pro b/examples/declarative/tutorials/extending/chapter5-listproperties/chapter5-listproperties.pro deleted file mode 100644 index 6724fa0375..0000000000 --- a/examples/declarative/tutorials/extending/chapter5-listproperties/chapter5-listproperties.pro +++ /dev/null @@ -1,7 +0,0 @@ -QT += declarative quick - -HEADERS += piechart.h \ - pieslice.h -SOURCES += piechart.cpp \ - pieslice.cpp \ - main.cpp diff --git a/examples/declarative/tutorials/extending/chapter5-listproperties/main.cpp b/examples/declarative/tutorials/extending/chapter5-listproperties/main.cpp deleted file mode 100644 index 59587733eb..0000000000 --- a/examples/declarative/tutorials/extending/chapter5-listproperties/main.cpp +++ /dev/null @@ -1,58 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include "piechart.h" -#include "pieslice.h" - -#include -#include - -int main(int argc, char *argv[]) -{ - QGuiApplication app(argc, argv); - - qmlRegisterType("Charts", 1, 0, "PieChart"); - qmlRegisterType("Charts", 1, 0, "PieSlice"); - - QQuickView view; - view.setResizeMode(QQuickView::SizeRootObjectToView); - view.setSource(QUrl::fromLocalFile("app.qml")); - view.show(); - return app.exec(); -} diff --git a/examples/declarative/tutorials/extending/chapter5-listproperties/piechart.cpp b/examples/declarative/tutorials/extending/chapter5-listproperties/piechart.cpp deleted file mode 100644 index bfcb607e60..0000000000 --- a/examples/declarative/tutorials/extending/chapter5-listproperties/piechart.cpp +++ /dev/null @@ -1,72 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include "piechart.h" -#include "pieslice.h" - -PieChart::PieChart(QQuickItem *parent) - : QQuickItem(parent) -{ -} - -QString PieChart::name() const -{ - return m_name; -} - -void PieChart::setName(const QString &name) -{ - m_name = name; -} - -//![0] -QDeclarativeListProperty PieChart::slices() -{ - return QDeclarativeListProperty(this, 0, &PieChart::append_slice); -} - -void PieChart::append_slice(QDeclarativeListProperty *list, PieSlice *slice) -{ - PieChart *chart = qobject_cast(list->object); - if (chart) { - slice->setParentItem(chart); - chart->m_slices.append(slice); - } -} -//![0] diff --git a/examples/declarative/tutorials/extending/chapter5-listproperties/piechart.h b/examples/declarative/tutorials/extending/chapter5-listproperties/piechart.h deleted file mode 100644 index 9beabda5f3..0000000000 --- a/examples/declarative/tutorials/extending/chapter5-listproperties/piechart.h +++ /dev/null @@ -1,75 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#ifndef PIECHART_H -#define PIECHART_H - -#include - -class PieSlice; - -//![0] -class PieChart : public QQuickItem -{ - Q_OBJECT - Q_PROPERTY(QDeclarativeListProperty slices READ slices) -//![0] - Q_PROPERTY(QString name READ name WRITE setName) - -//![1] -public: -//![1] - PieChart(QQuickItem *parent = 0); - - QString name() const; - void setName(const QString &name); - -//![2] - QDeclarativeListProperty slices(); - -private: - static void append_slice(QDeclarativeListProperty *list, PieSlice *slice); - - QString m_name; - QList m_slices; -}; -//![2] - -#endif - diff --git a/examples/declarative/tutorials/extending/chapter5-listproperties/pieslice.cpp b/examples/declarative/tutorials/extending/chapter5-listproperties/pieslice.cpp deleted file mode 100644 index 5bca2d58d8..0000000000 --- a/examples/declarative/tutorials/extending/chapter5-listproperties/pieslice.cpp +++ /dev/null @@ -1,86 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include "pieslice.h" - -#include - -PieSlice::PieSlice(QQuickItem *parent) - : QQuickPaintedItem(parent) -{ -} - -QColor PieSlice::color() const -{ - return m_color; -} - -void PieSlice::setColor(const QColor &color) -{ - m_color = color; -} - -int PieSlice::fromAngle() const -{ - return m_fromAngle; -} - -void PieSlice::setFromAngle(int angle) -{ - m_fromAngle = angle; -} - -int PieSlice::angleSpan() const -{ - return m_angleSpan; -} - -void PieSlice::setAngleSpan(int angle) -{ - m_angleSpan = angle; -} - -void PieSlice::paint(QPainter *painter) -{ - QPen pen(m_color, 2); - painter->setPen(pen); - painter->setRenderHints(QPainter::HighQualityAntialiasing, true); - painter->drawPie(boundingRect(), m_fromAngle * 16, m_angleSpan * 16); -} - diff --git a/examples/declarative/tutorials/extending/chapter5-listproperties/pieslice.h b/examples/declarative/tutorials/extending/chapter5-listproperties/pieslice.h deleted file mode 100644 index f6497fcbae..0000000000 --- a/examples/declarative/tutorials/extending/chapter5-listproperties/pieslice.h +++ /dev/null @@ -1,76 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#ifndef PIESLICE_H -#define PIESLICE_H - -#include -#include - -//![0] -class PieSlice : public QQuickPaintedItem -{ - Q_OBJECT - Q_PROPERTY(QColor color READ color WRITE setColor) - Q_PROPERTY(int fromAngle READ fromAngle WRITE setFromAngle) - Q_PROPERTY(int angleSpan READ angleSpan WRITE setAngleSpan) -//![0] - -public: - PieSlice(QQuickItem *parent = 0); - - QColor color() const; - void setColor(const QColor &color); - - int fromAngle() const; - void setFromAngle(int angle); - - int angleSpan() const; - void setAngleSpan(int span); - - void paint(QPainter *painter); - -private: - QColor m_color; - int m_fromAngle; - int m_angleSpan; -}; - -#endif - diff --git a/examples/declarative/tutorials/extending/chapter6-plugins/ChartsPlugin/qmldir b/examples/declarative/tutorials/extending/chapter6-plugins/ChartsPlugin/qmldir deleted file mode 100644 index 72650d8243..0000000000 --- a/examples/declarative/tutorials/extending/chapter6-plugins/ChartsPlugin/qmldir +++ /dev/null @@ -1 +0,0 @@ -plugin chartsplugin \ No newline at end of file diff --git a/examples/declarative/tutorials/extending/chapter6-plugins/app.qml b/examples/declarative/tutorials/extending/chapter6-plugins/app.qml deleted file mode 100644 index b6eac44e27..0000000000 --- a/examples/declarative/tutorials/extending/chapter6-plugins/app.qml +++ /dev/null @@ -1,69 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -import QtQuick 2.0 -import "ChartsPlugin" 1.0 - -Item { - width: 300; height: 200 - - PieChart { - anchors.centerIn: parent - width: 100; height: 100 - - slices: [ - PieSlice { - anchors.fill: parent - color: "red" - fromAngle: 0; angleSpan: 110 - }, - PieSlice { - anchors.fill: parent - color: "black" - fromAngle: 110; angleSpan: 50 - }, - PieSlice { - anchors.fill: parent - color: "blue" - fromAngle: 160; angleSpan: 100 - } - ] - } -} - diff --git a/examples/declarative/tutorials/extending/chapter6-plugins/chapter6-plugins.pro b/examples/declarative/tutorials/extending/chapter6-plugins/chapter6-plugins.pro deleted file mode 100644 index c243ec4572..0000000000 --- a/examples/declarative/tutorials/extending/chapter6-plugins/chapter6-plugins.pro +++ /dev/null @@ -1,18 +0,0 @@ -TEMPLATE = lib -CONFIG += qt plugin -QT += declarative quick - -DESTDIR = ChartsPlugin -TARGET = chartsplugin - -OBJECTS_DIR = tmp -MOC_DIR = tmp - -HEADERS += piechart.h \ - pieslice.h \ - chartsplugin.h - -SOURCES += piechart.cpp \ - pieslice.cpp \ - chartsplugin.cpp - diff --git a/examples/declarative/tutorials/extending/chapter6-plugins/chartsplugin.cpp b/examples/declarative/tutorials/extending/chapter6-plugins/chartsplugin.cpp deleted file mode 100644 index 9c4027de8a..0000000000 --- a/examples/declarative/tutorials/extending/chapter6-plugins/chartsplugin.cpp +++ /dev/null @@ -1,54 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include "chartsplugin.h" -//![0] -#include "piechart.h" -#include "pieslice.h" -#include - -void ChartsPlugin::registerTypes(const char *uri) -{ - qmlRegisterType(uri, 1, 0, "PieChart"); - qmlRegisterType(uri, 1, 0, "PieSlice"); -} - -Q_EXPORT_PLUGIN2(chartsplugin, ChartsPlugin); -//![0] - diff --git a/examples/declarative/tutorials/extending/chapter6-plugins/chartsplugin.h b/examples/declarative/tutorials/extending/chapter6-plugins/chartsplugin.h deleted file mode 100644 index bffcf000fd..0000000000 --- a/examples/declarative/tutorials/extending/chapter6-plugins/chartsplugin.h +++ /dev/null @@ -1,55 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#ifndef CHARTSPLUGIN_H -#define CHARTSPLUGIN_H - -//![0] -#include - -class ChartsPlugin : public QDeclarativeExtensionPlugin -{ - Q_OBJECT -public: - void registerTypes(const char *uri); -}; -//![0] - -#endif - diff --git a/examples/declarative/tutorials/extending/chapter6-plugins/piechart.cpp b/examples/declarative/tutorials/extending/chapter6-plugins/piechart.cpp deleted file mode 100644 index 2a8f40289e..0000000000 --- a/examples/declarative/tutorials/extending/chapter6-plugins/piechart.cpp +++ /dev/null @@ -1,71 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include "piechart.h" -#include "pieslice.h" - -PieChart::PieChart(QQuickItem *parent) - : QQuickItem(parent) -{ -} - -QString PieChart::name() const -{ - return m_name; -} - -void PieChart::setName(const QString &name) -{ - m_name = name; -} - -QDeclarativeListProperty PieChart::slices() -{ - return QDeclarativeListProperty(this, 0, &PieChart::append_slice); -} - -void PieChart::append_slice(QDeclarativeListProperty *list, PieSlice *slice) -{ - PieChart *chart = qobject_cast(list->object); - if (chart) { - slice->setParentItem(chart); - chart->m_slices.append(slice); - } -} - diff --git a/examples/declarative/tutorials/extending/chapter6-plugins/piechart.h b/examples/declarative/tutorials/extending/chapter6-plugins/piechart.h deleted file mode 100644 index fe6b96afdc..0000000000 --- a/examples/declarative/tutorials/extending/chapter6-plugins/piechart.h +++ /dev/null @@ -1,69 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#ifndef PIECHART_H -#define PIECHART_H - -#include - -class PieSlice; - -class PieChart : public QQuickItem -{ - Q_OBJECT - Q_PROPERTY(QDeclarativeListProperty slices READ slices) - Q_PROPERTY(QString name READ name WRITE setName) - -public: - PieChart(QQuickItem *parent = 0); - - QString name() const; - void setName(const QString &name); - - QDeclarativeListProperty slices(); - -private: - static void append_slice(QDeclarativeListProperty *list, PieSlice *slice); - - QString m_name; - QList m_slices; -}; - -#endif - diff --git a/examples/declarative/tutorials/extending/chapter6-plugins/pieslice.cpp b/examples/declarative/tutorials/extending/chapter6-plugins/pieslice.cpp deleted file mode 100644 index 5bca2d58d8..0000000000 --- a/examples/declarative/tutorials/extending/chapter6-plugins/pieslice.cpp +++ /dev/null @@ -1,86 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include "pieslice.h" - -#include - -PieSlice::PieSlice(QQuickItem *parent) - : QQuickPaintedItem(parent) -{ -} - -QColor PieSlice::color() const -{ - return m_color; -} - -void PieSlice::setColor(const QColor &color) -{ - m_color = color; -} - -int PieSlice::fromAngle() const -{ - return m_fromAngle; -} - -void PieSlice::setFromAngle(int angle) -{ - m_fromAngle = angle; -} - -int PieSlice::angleSpan() const -{ - return m_angleSpan; -} - -void PieSlice::setAngleSpan(int angle) -{ - m_angleSpan = angle; -} - -void PieSlice::paint(QPainter *painter) -{ - QPen pen(m_color, 2); - painter->setPen(pen); - painter->setRenderHints(QPainter::HighQualityAntialiasing, true); - painter->drawPie(boundingRect(), m_fromAngle * 16, m_angleSpan * 16); -} - diff --git a/examples/declarative/tutorials/extending/chapter6-plugins/pieslice.h b/examples/declarative/tutorials/extending/chapter6-plugins/pieslice.h deleted file mode 100644 index 8a636fb3e7..0000000000 --- a/examples/declarative/tutorials/extending/chapter6-plugins/pieslice.h +++ /dev/null @@ -1,74 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#ifndef PIESLICE_H -#define PIESLICE_H - -#include -#include - -class PieSlice : public QQuickPaintedItem -{ - Q_OBJECT - Q_PROPERTY(QColor color READ color WRITE setColor) - Q_PROPERTY(int fromAngle READ fromAngle WRITE setFromAngle) - Q_PROPERTY(int angleSpan READ angleSpan WRITE setAngleSpan) - -public: - PieSlice(QQuickItem *parent = 0); - - QColor color() const; - void setColor(const QColor &color); - - int fromAngle() const; - void setFromAngle(int angle); - - int angleSpan() const; - void setAngleSpan(int span); - - void paint(QPainter *painter); - -private: - QColor m_color; - int m_fromAngle; - int m_angleSpan; -}; - -#endif - diff --git a/examples/declarative/tutorials/extending/extending.pro b/examples/declarative/tutorials/extending/extending.pro deleted file mode 100644 index 967473fda0..0000000000 --- a/examples/declarative/tutorials/extending/extending.pro +++ /dev/null @@ -1,10 +0,0 @@ -TEMPLATE = subdirs - -SUBDIRS += \ - chapter1-basics \ - chapter2-methods \ - chapter3-bindings \ - chapter4-customPropertyTypes \ - chapter5-listproperties \ - chapter6-plugins - diff --git a/examples/declarative/tutorials/helloworld/Cell.qml b/examples/declarative/tutorials/helloworld/Cell.qml deleted file mode 100644 index 7140dcb2c1..0000000000 --- a/examples/declarative/tutorials/helloworld/Cell.qml +++ /dev/null @@ -1,72 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -//![0] -import QtQuick 2.0 - -//![1] -Item { - id: container -//![4] - property alias cellColor: rectangle.color -//![4] -//![5] - signal clicked(color cellColor) -//![5] - - width: 40; height: 25 -//![1] - -//![2] - Rectangle { - id: rectangle - border.color: "white" - anchors.fill: parent - } -//![2] - -//![3] - MouseArea { - anchors.fill: parent - onClicked: container.clicked(container.cellColor) - } -//![3] -} -//![0] diff --git a/examples/declarative/tutorials/helloworld/tutorial1.qml b/examples/declarative/tutorials/helloworld/tutorial1.qml deleted file mode 100644 index f0eb42d696..0000000000 --- a/examples/declarative/tutorials/helloworld/tutorial1.qml +++ /dev/null @@ -1,63 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -//![0] -//![3] -import QtQuick 2.0 -//![3] - -//![1] -Rectangle { - id: page - width: 500; height: 200 - color: "lightgray" -//![1] - -//![2] - Text { - id: helloText - text: "Hello world!" - y: 30 - anchors.horizontalCenter: page.horizontalCenter - font.pointSize: 24; font.bold: true - } -//![2] -} -//![0] diff --git a/examples/declarative/tutorials/helloworld/tutorial2.qml b/examples/declarative/tutorials/helloworld/tutorial2.qml deleted file mode 100644 index c5c045aace..0000000000 --- a/examples/declarative/tutorials/helloworld/tutorial2.qml +++ /dev/null @@ -1,72 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -//![0] -import QtQuick 2.0 - -Rectangle { - id: page - width: 500; height: 200 - color: "lightgray" - - Text { - id: helloText - text: "Hello world!" - y: 30 - anchors.horizontalCenter: page.horizontalCenter - font.pointSize: 24; font.bold: true - } - - Grid { - id: colorPicker - x: 4; anchors.bottom: page.bottom; anchors.bottomMargin: 4 - rows: 2; columns: 3; spacing: 3 - -//![1] - Cell { cellColor: "red"; onClicked: helloText.color = cellColor } -//![1] - Cell { cellColor: "green"; onClicked: helloText.color = cellColor } - Cell { cellColor: "blue"; onClicked: helloText.color = cellColor } - Cell { cellColor: "yellow"; onClicked: helloText.color = cellColor } - Cell { cellColor: "steelblue"; onClicked: helloText.color = cellColor } - Cell { cellColor: "black"; onClicked: helloText.color = cellColor } - } -} -//![0] diff --git a/examples/declarative/tutorials/helloworld/tutorial3.qml b/examples/declarative/tutorials/helloworld/tutorial3.qml deleted file mode 100644 index c804bfca1d..0000000000 --- a/examples/declarative/tutorials/helloworld/tutorial3.qml +++ /dev/null @@ -1,91 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -//![0] -import QtQuick 2.0 - -Rectangle { - id: page - width: 500; height: 200 - color: "lightgray" - - Text { - id: helloText - text: "Hello world!" - y: 30 - anchors.horizontalCenter: page.horizontalCenter - font.pointSize: 24; font.bold: true - -//![1] - MouseArea { id: mouseArea; anchors.fill: parent } -//![1] - -//![2] - states: State { - name: "down"; when: mouseArea.pressed == true - PropertyChanges { target: helloText; y: 160; rotation: 180; color: "red" } - } -//![2] - -//![3] - transitions: Transition { - from: ""; to: "down"; reversible: true - ParallelAnimation { - NumberAnimation { properties: "y,rotation"; duration: 500; easing.type: Easing.InOutQuad } - ColorAnimation { duration: 500 } - } - } -//![3] - } - - Grid { - id: colorPicker - x: 4; anchors.bottom: page.bottom; anchors.bottomMargin: 4 - rows: 2; columns: 3; spacing: 3 - - Cell { cellColor: "red"; onClicked: helloText.color = cellColor } - Cell { cellColor: "green"; onClicked: helloText.color = cellColor } - Cell { cellColor: "blue"; onClicked: helloText.color = cellColor } - Cell { cellColor: "yellow"; onClicked: helloText.color = cellColor } - Cell { cellColor: "steelblue"; onClicked: helloText.color = cellColor } - Cell { cellColor: "black"; onClicked: helloText.color = cellColor } - } -} -//![0] diff --git a/examples/declarative/tutorials/samegame/samegame1/Block.qml b/examples/declarative/tutorials/samegame/samegame1/Block.qml deleted file mode 100644 index 32ef8c2bba..0000000000 --- a/examples/declarative/tutorials/samegame/samegame1/Block.qml +++ /dev/null @@ -1,53 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -//![0] -import QtQuick 2.0 - -Item { - id: block - - Image { - id: img - anchors.fill: parent - source: "../shared/pics/redStone.png" - } -} -//![0] diff --git a/examples/declarative/tutorials/samegame/samegame1/Button.qml b/examples/declarative/tutorials/samegame/samegame1/Button.qml deleted file mode 100644 index 6d1d1268de..0000000000 --- a/examples/declarative/tutorials/samegame/samegame1/Button.qml +++ /dev/null @@ -1,83 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -//![0] -import QtQuick 2.0 - -Rectangle { - id: container - - property string text: "Button" - - signal clicked - - width: buttonLabel.width + 20; height: buttonLabel.height + 5 - border { width: 1; color: Qt.darker(activePalette.button) } - smooth: true - radius: 8 - - // color the button with a gradient - gradient: Gradient { - GradientStop { - position: 0.0 - color: { - if (mouseArea.pressed) - return activePalette.dark - else - return activePalette.light - } - } - GradientStop { position: 1.0; color: activePalette.button } - } - - MouseArea { - id: mouseArea - anchors.fill: parent - onClicked: container.clicked(); - } - - Text { - id: buttonLabel - anchors.centerIn: container - color: activePalette.buttonText - text: container.text - } -} -//![0] diff --git a/examples/declarative/tutorials/samegame/samegame1/samegame.qml b/examples/declarative/tutorials/samegame/samegame1/samegame.qml deleted file mode 100644 index 73e2cc31fd..0000000000 --- a/examples/declarative/tutorials/samegame/samegame1/samegame.qml +++ /dev/null @@ -1,82 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -//![0] -import QtQuick 2.0 - -Rectangle { - id: screen - - width: 490; height: 720 - - SystemPalette { id: activePalette } - - Item { - width: parent.width - anchors { top: parent.top; bottom: toolBar.top } - - Image { - id: background - anchors.fill: parent - source: "../shared/pics/background.jpg" - fillMode: Image.PreserveAspectCrop - } - } - - Rectangle { - id: toolBar - width: parent.width; height: 30 - color: activePalette.window - anchors.bottom: screen.bottom - - Button { - anchors { left: parent.left; verticalCenter: parent.verticalCenter } - text: "New Game" - onClicked: console.log("This doesn't do anything yet...") - } - - Text { - id: score - anchors { right: parent.right; verticalCenter: parent.verticalCenter } - text: "Score: Who knows?" - } - } -} -//![0] diff --git a/examples/declarative/tutorials/samegame/samegame1/samegame1.qmlproject b/examples/declarative/tutorials/samegame/samegame1/samegame1.qmlproject deleted file mode 100644 index 42ffacf4f8..0000000000 --- a/examples/declarative/tutorials/samegame/samegame1/samegame1.qmlproject +++ /dev/null @@ -1,16 +0,0 @@ -import QmlProject 1.1 - -Project { - mainFile: "samegame.qml" - - /* Include .qml, .js, and image files from current directory and subdirectories */ - QmlFiles { - directory: "." - } - JavaScriptFiles { - directory: "." - } - ImageFiles { - directory: "." - } -} diff --git a/examples/declarative/tutorials/samegame/samegame2/Block.qml b/examples/declarative/tutorials/samegame/samegame2/Block.qml deleted file mode 100644 index 8056b39480..0000000000 --- a/examples/declarative/tutorials/samegame/samegame2/Block.qml +++ /dev/null @@ -1,51 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -Item { - id: block - - Image { - id: img - anchors.fill: parent - source: "../shared/pics/redStone.png" - } -} diff --git a/examples/declarative/tutorials/samegame/samegame2/Button.qml b/examples/declarative/tutorials/samegame/samegame2/Button.qml deleted file mode 100644 index 248c20cf0f..0000000000 --- a/examples/declarative/tutorials/samegame/samegame2/Button.qml +++ /dev/null @@ -1,81 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -Rectangle { - id: container - - property string text: "Button" - - signal clicked - - width: buttonLabel.width + 20; height: buttonLabel.height + 5 - border { width: 1; color: Qt.darker(activePalette.button) } - smooth: true - radius: 8 - - // color the button with a gradient - gradient: Gradient { - GradientStop { - position: 0.0 - color: { - if (mouseArea.pressed) - return activePalette.dark - else - return activePalette.light - } - } - GradientStop { position: 1.0; color: activePalette.button } - } - - MouseArea { - id: mouseArea - anchors.fill: parent - onClicked: container.clicked(); - } - - Text { - id: buttonLabel - anchors.centerIn: container - color: activePalette.buttonText - text: container.text - } -} diff --git a/examples/declarative/tutorials/samegame/samegame2/samegame.js b/examples/declarative/tutorials/samegame/samegame2/samegame.js deleted file mode 100644 index c749dc17b1..0000000000 --- a/examples/declarative/tutorials/samegame/samegame2/samegame.js +++ /dev/null @@ -1,63 +0,0 @@ -//![0] -var blockSize = 40; -var maxColumn = 10; -var maxRow = 15; -var maxIndex = maxColumn * maxRow; -var board = new Array(maxIndex); -var component; - -//Index function used instead of a 2D array -function index(column, row) { - return column + (row * maxColumn); -} - -function startNewGame() { - //Delete blocks from previous game - for (var i = 0; i < maxIndex; i++) { - if (board[i] != null) - board[i].destroy(); - } - - //Calculate board size - maxColumn = Math.floor(background.width / blockSize); - maxRow = Math.floor(background.height / blockSize); - maxIndex = maxRow * maxColumn; - - //Initialize Board - board = new Array(maxIndex); - for (var column = 0; column < maxColumn; column++) { - for (var row = 0; row < maxRow; row++) { - board[index(column, row)] = null; - createBlock(column, row); - } - } -} - -function createBlock(column, row) { - if (component == null) - component = Qt.createComponent("Block.qml"); - - // Note that if Block.qml was not a local file, component.status would be - // Loading and we should wait for the component's statusChanged() signal to - // know when the file is downloaded and ready before calling createObject(). - if (component.status == Component.Ready) { - var dynamicObject = component.createObject(background); - if (dynamicObject == null) { - console.log("error creating block"); - console.log(component.errorString()); - return false; - } - dynamicObject.x = column * blockSize; - dynamicObject.y = row * blockSize; - dynamicObject.width = blockSize; - dynamicObject.height = blockSize; - board[index(column, row)] = dynamicObject; - } else { - console.log("error loading block component"); - console.log(component.errorString()); - return false; - } - return true; -} -//![0] - diff --git a/examples/declarative/tutorials/samegame/samegame2/samegame.qml b/examples/declarative/tutorials/samegame/samegame2/samegame.qml deleted file mode 100644 index c50010e97d..0000000000 --- a/examples/declarative/tutorials/samegame/samegame2/samegame.qml +++ /dev/null @@ -1,85 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 -//![2] -import "samegame.js" as SameGame -//![2] - -Rectangle { - id: screen - - width: 490; height: 720 - - SystemPalette { id: activePalette } - - Item { - width: parent.width - anchors { top: parent.top; bottom: toolBar.top } - - Image { - id: background - anchors.fill: parent - source: "../shared/pics/background.jpg" - fillMode: Image.PreserveAspectCrop - } - } - - Rectangle { - id: toolBar - width: parent.width; height: 32 - color: activePalette.window - anchors.bottom: screen.bottom - -//![1] - Button { - anchors { left: parent.left; verticalCenter: parent.verticalCenter } - text: "New Game" - onClicked: SameGame.startNewGame() - } -//![1] - - Text { - id: score - anchors { right: parent.right; verticalCenter: parent.verticalCenter } - text: "Score: Who knows?" - } - } -} diff --git a/examples/declarative/tutorials/samegame/samegame2/samegame2.qmlproject b/examples/declarative/tutorials/samegame/samegame2/samegame2.qmlproject deleted file mode 100644 index 42ffacf4f8..0000000000 --- a/examples/declarative/tutorials/samegame/samegame2/samegame2.qmlproject +++ /dev/null @@ -1,16 +0,0 @@ -import QmlProject 1.1 - -Project { - mainFile: "samegame.qml" - - /* Include .qml, .js, and image files from current directory and subdirectories */ - QmlFiles { - directory: "." - } - JavaScriptFiles { - directory: "." - } - ImageFiles { - directory: "." - } -} diff --git a/examples/declarative/tutorials/samegame/samegame3/Block.qml b/examples/declarative/tutorials/samegame/samegame3/Block.qml deleted file mode 100644 index 9c41048fcb..0000000000 --- a/examples/declarative/tutorials/samegame/samegame3/Block.qml +++ /dev/null @@ -1,63 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -//![0] -import QtQuick 2.0 - -Item { - id: block - - property int type: 0 - - Image { - id: img - - anchors.fill: parent - source: { - if (type == 0) - return "../shared/pics/redStone.png"; - else if (type == 1) - return "../shared/pics/blueStone.png"; - else - return "../shared/pics/greenStone.png"; - } - } -} -//![0] diff --git a/examples/declarative/tutorials/samegame/samegame3/Button.qml b/examples/declarative/tutorials/samegame/samegame3/Button.qml deleted file mode 100644 index 248c20cf0f..0000000000 --- a/examples/declarative/tutorials/samegame/samegame3/Button.qml +++ /dev/null @@ -1,81 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -Rectangle { - id: container - - property string text: "Button" - - signal clicked - - width: buttonLabel.width + 20; height: buttonLabel.height + 5 - border { width: 1; color: Qt.darker(activePalette.button) } - smooth: true - radius: 8 - - // color the button with a gradient - gradient: Gradient { - GradientStop { - position: 0.0 - color: { - if (mouseArea.pressed) - return activePalette.dark - else - return activePalette.light - } - } - GradientStop { position: 1.0; color: activePalette.button } - } - - MouseArea { - id: mouseArea - anchors.fill: parent - onClicked: container.clicked(); - } - - Text { - id: buttonLabel - anchors.centerIn: container - color: activePalette.buttonText - text: container.text - } -} diff --git a/examples/declarative/tutorials/samegame/samegame3/Dialog.qml b/examples/declarative/tutorials/samegame/samegame3/Dialog.qml deleted file mode 100644 index df1fa37d6a..0000000000 --- a/examples/declarative/tutorials/samegame/samegame3/Dialog.qml +++ /dev/null @@ -1,71 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -//![0] -import QtQuick 2.0 - -Rectangle { - id: container - - function show(text) { - dialogText.text = text; - container.opacity = 1; - } - - function hide() { - container.opacity = 0; - } - - width: dialogText.width + 20 - height: dialogText.height + 20 - opacity: 0 - - Text { - id: dialogText - anchors.centerIn: parent - text: "" - } - - MouseArea { - anchors.fill: parent - onClicked: hide(); - } -} -//![0] diff --git a/examples/declarative/tutorials/samegame/samegame3/samegame.js b/examples/declarative/tutorials/samegame/samegame3/samegame.js deleted file mode 100644 index df5bdfb049..0000000000 --- a/examples/declarative/tutorials/samegame/samegame3/samegame.js +++ /dev/null @@ -1,174 +0,0 @@ -/* This script file handles the game logic */ -var maxColumn = 10; -var maxRow = 15; -var maxIndex = maxColumn * maxRow; -var board = new Array(maxIndex); -var component; - -//Index function used instead of a 2D array -function index(column, row) { - return column + (row * maxColumn); -} - -function startNewGame() { - //Calculate board size - maxColumn = Math.floor(gameCanvas.width / gameCanvas.blockSize); - maxRow = Math.floor(gameCanvas.height / gameCanvas.blockSize); - maxIndex = maxRow * maxColumn; - - //Close dialogs - dialog.hide(); - - //Initialize Board - board = new Array(maxIndex); - gameCanvas.score = 0; - for (var column = 0; column < maxColumn; column++) { - for (var row = 0; row < maxRow; row++) { - board[index(column, row)] = null; - createBlock(column, row); - } - } -} - -function createBlock(column, row) { - if (component == null) - component = Qt.createComponent("Block.qml"); - - // Note that if Block.qml was not a local file, component.status would be - // Loading and we should wait for the component's statusChanged() signal to - // know when the file is downloaded and ready before calling createObject(). - if (component.status == Component.Ready) { - var dynamicObject = component.createObject(gameCanvas); - if (dynamicObject == null) { - console.log("error creating block"); - console.log(component.errorString()); - return false; - } - dynamicObject.type = Math.floor(Math.random() * 3); - dynamicObject.x = column * gameCanvas.blockSize; - dynamicObject.y = row * gameCanvas.blockSize; - dynamicObject.width = gameCanvas.blockSize; - dynamicObject.height = gameCanvas.blockSize; - board[index(column, row)] = dynamicObject; - } else { - console.log("error loading block component"); - console.log(component.errorString()); - return false; - } - return true; -} - -var fillFound; //Set after a floodFill call to the number of blocks found -var floodBoard; //Set to 1 if the floodFill reaches off that node - -//![1] -function handleClick(xPos, yPos) { - var column = Math.floor(xPos / gameCanvas.blockSize); - var row = Math.floor(yPos / gameCanvas.blockSize); - if (column >= maxColumn || column < 0 || row >= maxRow || row < 0) - return; - if (board[index(column, row)] == null) - return; - //If it's a valid block, remove it and all connected (does nothing if it's not connected) - floodFill(column, row, -1); - if (fillFound <= 0) - return; - gameCanvas.score += (fillFound - 1) * (fillFound - 1); - shuffleDown(); - victoryCheck(); -} -//![1] - -function floodFill(column, row, type) { - if (board[index(column, row)] == null) - return; - var first = false; - if (type == -1) { - first = true; - type = board[index(column, row)].type; - - //Flood fill initialization - fillFound = 0; - floodBoard = new Array(maxIndex); - } - if (column >= maxColumn || column < 0 || row >= maxRow || row < 0) - return; - if (floodBoard[index(column, row)] == 1 || (!first && type != board[index(column, row)].type)) - return; - floodBoard[index(column, row)] = 1; - floodFill(column + 1, row, type); - floodFill(column - 1, row, type); - floodFill(column, row + 1, type); - floodFill(column, row - 1, type); - if (first == true && fillFound == 0) - return; //Can't remove single blocks - board[index(column, row)].opacity = 0; - board[index(column, row)] = null; - fillFound += 1; -} - -function shuffleDown() { - //Fall down - for (var column = 0; column < maxColumn; column++) { - var fallDist = 0; - for (var row = maxRow - 1; row >= 0; row--) { - if (board[index(column, row)] == null) { - fallDist += 1; - } else { - if (fallDist > 0) { - var obj = board[index(column, row)]; - obj.y += fallDist * gameCanvas.blockSize; - board[index(column, row + fallDist)] = obj; - board[index(column, row)] = null; - } - } - } - } - //Fall to the left - var fallDist = 0; - for (var column = 0; column < maxColumn; column++) { - if (board[index(column, maxRow - 1)] == null) { - fallDist += 1; - } else { - if (fallDist > 0) { - for (var row = 0; row < maxRow; row++) { - var obj = board[index(column, row)]; - if (obj == null) - continue; - obj.x -= fallDist * gameCanvas.blockSize; - board[index(column - fallDist, row)] = obj; - board[index(column, row)] = null; - } - } - } - } -} - -//![2] -function victoryCheck() { - //Award bonus points if no blocks left - var deservesBonus = true; - for (var column = maxColumn - 1; column >= 0; column--) - if (board[index(column, maxRow - 1)] != null) - deservesBonus = false; - if (deservesBonus) - gameCanvas.score += 500; - - //Check whether game has finished - if (deservesBonus || !(floodMoveCheck(0, maxRow - 1, -1))) - dialog.show("Game Over. Your score is " + gameCanvas.score); -} -//![2] - -//only floods up and right, to see if it can find adjacent same-typed blocks -function floodMoveCheck(column, row, type) { - if (column >= maxColumn || column < 0 || row >= maxRow || row < 0) - return false; - if (board[index(column, row)] == null) - return false; - var myType = board[index(column, row)].type; - if (type == myType) - return true; - return floodMoveCheck(column + 1, row, myType) || floodMoveCheck(column, row - 1, board[index(column, row)].type); -} - diff --git a/examples/declarative/tutorials/samegame/samegame3/samegame.qml b/examples/declarative/tutorials/samegame/samegame3/samegame.qml deleted file mode 100644 index f14829ef63..0000000000 --- a/examples/declarative/tutorials/samegame/samegame3/samegame.qml +++ /dev/null @@ -1,109 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -//![0] -import QtQuick 2.0 -import "samegame.js" as SameGame - -Rectangle { - id: screen - - width: 490; height: 720 - - SystemPalette { id: activePalette } - - Item { - width: parent.width - anchors { top: parent.top; bottom: toolBar.top } - - Image { - id: background - anchors.fill: parent - source: "../shared/pics/background.jpg" - fillMode: Image.PreserveAspectCrop - } - -//![1] - Item { - id: gameCanvas - - property int score: 0 - property int blockSize: 40 - - width: parent.width - (parent.width % blockSize) - height: parent.height - (parent.height % blockSize) - anchors.centerIn: parent - - MouseArea { - anchors.fill: parent - onClicked: SameGame.handleClick(mouse.x, mouse.y) - } - } -//![1] - } - -//![2] - Dialog { - id: dialog - anchors.centerIn: parent - z: 100 - } -//![2] - - Rectangle { - id: toolBar - width: parent.width; height: 30 - color: activePalette.window - anchors.bottom: screen.bottom - - Button { - anchors { left: parent.left; verticalCenter: parent.verticalCenter } - text: "New Game" - onClicked: SameGame.startNewGame() - } - - Text { - id: score - anchors { right: parent.right; verticalCenter: parent.verticalCenter } - text: "Score: Who knows?" - } - } -} -//![0] diff --git a/examples/declarative/tutorials/samegame/samegame3/samegame3.qmlproject b/examples/declarative/tutorials/samegame/samegame3/samegame3.qmlproject deleted file mode 100644 index 42ffacf4f8..0000000000 --- a/examples/declarative/tutorials/samegame/samegame3/samegame3.qmlproject +++ /dev/null @@ -1,16 +0,0 @@ -import QmlProject 1.1 - -Project { - mainFile: "samegame.qml" - - /* Include .qml, .js, and image files from current directory and subdirectories */ - QmlFiles { - directory: "." - } - JavaScriptFiles { - directory: "." - } - ImageFiles { - directory: "." - } -} diff --git a/examples/declarative/tutorials/samegame/samegame4/content/BoomBlock.qml b/examples/declarative/tutorials/samegame/samegame4/content/BoomBlock.qml deleted file mode 100644 index 3786b9c0d1..0000000000 --- a/examples/declarative/tutorials/samegame/samegame4/content/BoomBlock.qml +++ /dev/null @@ -1,122 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 -import Qt.labs.particles 1.0 - -Item { - id: block - - property int type: 0 - property bool dying: false - - //![1] - property bool spawned: false - - Behavior on x { - enabled: spawned; - SpringAnimation{ spring: 2; damping: 0.2 } - } - Behavior on y { - SpringAnimation{ spring: 2; damping: 0.2 } - } - //![1] - - //![2] - Image { - id: img - - anchors.fill: parent - source: { - if (type == 0) - return "../../shared/pics/redStone.png"; - else if (type == 1) - return "../../shared/pics/blueStone.png"; - else - return "../../shared/pics/greenStone.png"; - } - opacity: 0 - - Behavior on opacity { - NumberAnimation { properties:"opacity"; duration: 200 } - } - } - //![2] - - //![3] - Particles { - id: particles - - width: 1; height: 1 - anchors.centerIn: parent - - emissionRate: 0 - lifeSpan: 700; lifeSpanDeviation: 600 - angle: 0; angleDeviation: 360; - velocity: 100; velocityDeviation: 30 - source: { - if (type == 0) - return "../../shared/pics/redStar.png"; - else if (type == 1) - return "../../shared/pics/blueStar.png"; - else - return "../../shared/pics/greenStar.png"; - } - } - //![3] - - //![4] - states: [ - State { - name: "AliveState" - when: spawned == true && dying == false - PropertyChanges { target: img; opacity: 1 } - }, - - State { - name: "DeathState" - when: dying == true - StateChangeScript { script: particles.burst(50); } - PropertyChanges { target: img; opacity: 0 } - StateChangeScript { script: block.destroy(1000); } - } - ] - //![4] -} diff --git a/examples/declarative/tutorials/samegame/samegame4/content/Button.qml b/examples/declarative/tutorials/samegame/samegame4/content/Button.qml deleted file mode 100644 index 248c20cf0f..0000000000 --- a/examples/declarative/tutorials/samegame/samegame4/content/Button.qml +++ /dev/null @@ -1,81 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -Rectangle { - id: container - - property string text: "Button" - - signal clicked - - width: buttonLabel.width + 20; height: buttonLabel.height + 5 - border { width: 1; color: Qt.darker(activePalette.button) } - smooth: true - radius: 8 - - // color the button with a gradient - gradient: Gradient { - GradientStop { - position: 0.0 - color: { - if (mouseArea.pressed) - return activePalette.dark - else - return activePalette.light - } - } - GradientStop { position: 1.0; color: activePalette.button } - } - - MouseArea { - id: mouseArea - anchors.fill: parent - onClicked: container.clicked(); - } - - Text { - id: buttonLabel - anchors.centerIn: container - color: activePalette.buttonText - text: container.text - } -} diff --git a/examples/declarative/tutorials/samegame/samegame4/content/Dialog.qml b/examples/declarative/tutorials/samegame/samegame4/content/Dialog.qml deleted file mode 100644 index 984b3ddb6a..0000000000 --- a/examples/declarative/tutorials/samegame/samegame4/content/Dialog.qml +++ /dev/null @@ -1,107 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -//![0] -Rectangle { - id: container -//![0] - -//![1] - property string inputText: textInput.text - signal closed - - function show(text) { - dialogText.text = text; - container.opacity = 1; - textInput.opacity = 0; - } - - function showWithInput(text) { - show(text); - textInput.opacity = 1; - textInput.focus = true; - textInput.text = "" - } - - function hide() { - textInput.focus = false; - container.opacity = 0; - container.closed(); - } -//![1] - - width: dialogText.width + textInput.width + 20 - height: dialogText.height + 20 - opacity: 0 - visible: opacity > 0 - - Text { - id: dialogText - anchors { verticalCenter: parent.verticalCenter; left: parent.left; leftMargin: 10 } - text: "" - } - -//![2] - TextInput { - id: textInput - anchors { verticalCenter: parent.verticalCenter; left: dialogText.right } - width: 80 - text: "" - - onAccepted: container.hide() // close dialog when Enter is pressed - } -//![2] - - MouseArea { - anchors.fill: parent - - onClicked: { - if (textInput.text == "" && textInput.opacity > 0) - textInput.openSoftwareInputPanel(); - else - hide(); - } - } - -//![3] -} -//![3] diff --git a/examples/declarative/tutorials/samegame/samegame4/content/samegame.js b/examples/declarative/tutorials/samegame/samegame4/content/samegame.js deleted file mode 100755 index 7bb7243914..0000000000 --- a/examples/declarative/tutorials/samegame/samegame4/content/samegame.js +++ /dev/null @@ -1,226 +0,0 @@ -/* This script file handles the game logic */ -.import QtQuick.LocalStorage 2.0 as Sql - -var maxColumn = 10; -var maxRow = 15; -var maxIndex = maxColumn * maxRow; -var board = new Array(maxIndex); -var component; -var scoresURL = ""; -var gameDuration; - -//Index function used instead of a 2D array -function index(column, row) { - return column + (row * maxColumn); -} - -function startNewGame() { - //Delete blocks from previous game - for (var i = 0; i < maxIndex; i++) { - if (board[i] != null) - board[i].destroy(); - } - - //Calculate board size - maxColumn = Math.floor(gameCanvas.width / gameCanvas.blockSize); - maxRow = Math.floor(gameCanvas.height / gameCanvas.blockSize); - maxIndex = maxRow * maxColumn; - - //Close dialogs - nameInputDialog.hide(); - dialog.hide(); - - //Initialize Board - board = new Array(maxIndex); - gameCanvas.score = 0; - for (var column = 0; column < maxColumn; column++) { - for (var row = 0; row < maxRow; row++) { - board[index(column, row)] = null; - createBlock(column, row); - } - } - - gameDuration = new Date(); -} - -function createBlock(column, row) { - if (component == null) - component = Qt.createComponent("content/BoomBlock.qml"); - - // Note that if Block.qml was not a local file, component.status would be - // Loading and we should wait for the component's statusChanged() signal to - // know when the file is downloaded and ready before calling createObject(). - if (component.status == Component.Ready) { - var dynamicObject = component.createObject(gameCanvas); - if (dynamicObject == null) { - console.log("error creating block"); - console.log(component.errorString()); - return false; - } - dynamicObject.type = Math.floor(Math.random() * 3); - dynamicObject.x = column * gameCanvas.blockSize; - dynamicObject.y = row * gameCanvas.blockSize; - dynamicObject.width = gameCanvas.blockSize; - dynamicObject.height = gameCanvas.blockSize; - dynamicObject.spawned = true; - board[index(column, row)] = dynamicObject; - } else { - console.log("error loading block component"); - console.log(component.errorString()); - return false; - } - return true; -} - -var fillFound; //Set after a floodFill call to the number of blocks found -var floodBoard; //Set to 1 if the floodFill reaches off that node - -function handleClick(xPos, yPos) { - var column = Math.floor(xPos / gameCanvas.blockSize); - var row = Math.floor(yPos / gameCanvas.blockSize); - if (column >= maxColumn || column < 0 || row >= maxRow || row < 0) - return; - if (board[index(column, row)] == null) - return; - //If it's a valid block, remove it and all connected (does nothing if it's not connected) - floodFill(column, row, -1); - if (fillFound <= 0) - return; - gameCanvas.score += (fillFound - 1) * (fillFound - 1); - shuffleDown(); - victoryCheck(); -} - -function floodFill(column, row, type) { - if (board[index(column, row)] == null) - return; - var first = false; - if (type == -1) { - first = true; - type = board[index(column, row)].type; - - //Flood fill initialization - fillFound = 0; - floodBoard = new Array(maxIndex); - } - if (column >= maxColumn || column < 0 || row >= maxRow || row < 0) - return; - if (floodBoard[index(column, row)] == 1 || (!first && type != board[index(column, row)].type)) - return; - floodBoard[index(column, row)] = 1; - floodFill(column + 1, row, type); - floodFill(column - 1, row, type); - floodFill(column, row + 1, type); - floodFill(column, row - 1, type); - if (first == true && fillFound == 0) - return; //Can't remove single blocks - board[index(column, row)].dying = true; - board[index(column, row)] = null; - fillFound += 1; -} - -function shuffleDown() { - //Fall down - for (var column = 0; column < maxColumn; column++) { - var fallDist = 0; - for (var row = maxRow - 1; row >= 0; row--) { - if (board[index(column, row)] == null) { - fallDist += 1; - } else { - if (fallDist > 0) { - var obj = board[index(column, row)]; - obj.y = (row + fallDist) * gameCanvas.blockSize; - board[index(column, row + fallDist)] = obj; - board[index(column, row)] = null; - } - } - } - } - //Fall to the left - fallDist = 0; - for (column = 0; column < maxColumn; column++) { - if (board[index(column, maxRow - 1)] == null) { - fallDist += 1; - } else { - if (fallDist > 0) { - for (row = 0; row < maxRow; row++) { - obj = board[index(column, row)]; - if (obj == null) - continue; - obj.x = (column - fallDist) * gameCanvas.blockSize; - board[index(column - fallDist, row)] = obj; - board[index(column, row)] = null; - } - } - } - } -} - -//![3] -function victoryCheck() { -//![3] - //Award bonus points if no blocks left - var deservesBonus = true; - for (var column = maxColumn - 1; column >= 0; column--) - if (board[index(column, maxRow - 1)] != null) - deservesBonus = false; - if (deservesBonus) - gameCanvas.score += 500; - -//![4] - //Check whether game has finished - if (deservesBonus || !(floodMoveCheck(0, maxRow - 1, -1))) { - gameDuration = new Date() - gameDuration; - nameInputDialog.showWithInput("You won! Please enter your name: "); - } -} -//![4] - -//only floods up and right, to see if it can find adjacent same-typed blocks -function floodMoveCheck(column, row, type) { - if (column >= maxColumn || column < 0 || row >= maxRow || row < 0) - return false; - if (board[index(column, row)] == null) - return false; - var myType = board[index(column, row)].type; - if (type == myType) - return true; - return floodMoveCheck(column + 1, row, myType) || floodMoveCheck(column, row - 1, board[index(column, row)].type); -} - -//![2] -function saveHighScore(name) { - if (scoresURL != "") - sendHighScore(name); - - var db = Sql.openDatabaseSync("SameGameScores", "1.0", "Local SameGame High Scores", 100); - var dataStr = "INSERT INTO Scores VALUES(?, ?, ?, ?)"; - var data = [name, gameCanvas.score, maxColumn + "x" + maxRow, Math.floor(gameDuration / 1000)]; - db.transaction(function(tx) { - tx.executeSql('CREATE TABLE IF NOT EXISTS Scores(name TEXT, score NUMBER, gridSize TEXT, time NUMBER)'); - tx.executeSql(dataStr, data); - - var rs = tx.executeSql('SELECT * FROM Scores WHERE gridSize = "12x17" ORDER BY score desc LIMIT 10'); - var r = "\nHIGH SCORES for a standard sized grid\n\n" - for (var i = 0; i < rs.rows.length; i++) { - r += (i + 1) + ". " + rs.rows.item(i).name + ' got ' + rs.rows.item(i).score + ' points in ' + rs.rows.item(i).time + ' seconds.\n'; - } - dialog.show(r); - }); -} -//![2] - -//![1] -function sendHighScore(name) { - var postman = new XMLHttpRequest() - var postData = "name=" + name + "&score=" + gameCanvas.score + "&gridSize=" + maxColumn + "x" + maxRow + "&time=" + Math.floor(gameDuration / 1000); - postman.open("POST", scoresURL, true); - postman.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); - postman.onreadystatechange = function() { - if (postman.readyState == postman.DONE) { - dialog.show("Your score has been uploaded."); - } - } - postman.send(postData); -} -//![1] diff --git a/examples/declarative/tutorials/samegame/samegame4/highscores/README b/examples/declarative/tutorials/samegame/samegame4/highscores/README deleted file mode 100644 index eaa00fae37..0000000000 --- a/examples/declarative/tutorials/samegame/samegame4/highscores/README +++ /dev/null @@ -1 +0,0 @@ -The SameGame example can interface with a simple PHP script to store XML high score data on a remote server. We do not have a publically accessible server available for this use, but if you have access to a PHP capable webserver you can copy the files (score_data.xml, score.php, score_style.xsl) to it and alter the highscore_server variable at the top of the samegame.js file to point to it. diff --git a/examples/declarative/tutorials/samegame/samegame4/highscores/score_data.xml b/examples/declarative/tutorials/samegame/samegame4/highscores/score_data.xml deleted file mode 100755 index c3fd90d9cf..0000000000 --- a/examples/declarative/tutorials/samegame/samegame4/highscores/score_data.xml +++ /dev/null @@ -1,2 +0,0 @@ -1000000Alan the Tester0x00 -6213Alan12x1751 diff --git a/examples/declarative/tutorials/samegame/samegame4/highscores/score_style.xsl b/examples/declarative/tutorials/samegame/samegame4/highscores/score_style.xsl deleted file mode 100755 index 670354c965..0000000000 --- a/examples/declarative/tutorials/samegame/samegame4/highscores/score_style.xsl +++ /dev/null @@ -1,28 +0,0 @@ - - - - - SameGame High Scores - -

SameGame High Scores

- - - - - - - - - - - - - - - - -
NameScoreGrid SizeTime, s
- - - - diff --git a/examples/declarative/tutorials/samegame/samegame4/highscores/scores.php b/examples/declarative/tutorials/samegame/samegame4/highscores/scores.php deleted file mode 100755 index daf480e21b..0000000000 --- a/examples/declarative/tutorials/samegame/samegame4/highscores/scores.php +++ /dev/null @@ -1,31 +0,0 @@ -"; - echo "SameGame High Scores"; - if($score > 0){#Sending in a new high score - $name = $_POST["name"]; - $grid = $_POST["gridSize"]; - $time = $_POST["time"]; - if($name == "") - $name = "Anonymous"; - $file = fopen("score_data.xml", "a"); - $ret = fwrite($file, "". $score . "" - . $name . "" . $grid . "" - . $time . "\n"); - echo "Your score has been recorded. Thanks for playing!"; - if($ret == False) - echo "
There was an error though, so don't expect to see that score again."; - }else{#Read high score list - #Now uses XSLT to display. So just print the file. With XML cruft added. - #Note that firefox at least won't apply the XSLT on a php file. So redirecting - $file = fopen("scores.xml", "w"); - $ret = fwrite($file, '' . "\n" - . '' . "\n" - . "\n" . file_get_contents("score_data.xml") . "\n"); - if($ret == False) - echo "There was an internal error. Sorry."; - else - echo ''; - } - echo ""; -?> diff --git a/examples/declarative/tutorials/samegame/samegame4/samegame.qml b/examples/declarative/tutorials/samegame/samegame4/samegame.qml deleted file mode 100644 index c21b8de8bd..0000000000 --- a/examples/declarative/tutorials/samegame/samegame4/samegame.qml +++ /dev/null @@ -1,115 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 -import "content" -import "content/samegame.js" as SameGame - -Rectangle { - id: screen - - width: 490; height: 720 - - SystemPalette { id: activePalette } - - Item { - width: parent.width - anchors { top: parent.top; bottom: toolBar.top } - - Image { - id: background - anchors.fill: parent - source: "../shared/pics/background.jpg" - fillMode: Image.PreserveAspectCrop - } - - Item { - id: gameCanvas - property int score: 0 - property int blockSize: 40 - - anchors.centerIn: parent - width: parent.width - (parent.width % blockSize); - height: parent.height - (parent.height % blockSize); - - MouseArea { - anchors.fill: parent; onClicked: SameGame.handleClick(mouse.x,mouse.y); - } - } - } - - Dialog { - id: dialog - anchors.centerIn: parent - z: 100 - } - - //![0] - Dialog { - id: nameInputDialog - anchors.centerIn: parent - z: 100 - - onClosed: { - if (nameInputDialog.inputText != "") - SameGame.saveHighScore(nameInputDialog.inputText); - } - } - //![0] - - Rectangle { - id: toolBar - width: parent.width; height: 30 - color: activePalette.window - anchors.bottom: screen.bottom - - Button { - anchors { left: parent.left; verticalCenter: parent.verticalCenter } - text: "New Game" - onClicked: SameGame.startNewGame() - } - - Text { - id: score - anchors { right: parent.right; verticalCenter: parent.verticalCenter } - text: "Score: " + gameCanvas.score - } - } -} diff --git a/examples/declarative/tutorials/samegame/samegame4/samegame4.qmlproject b/examples/declarative/tutorials/samegame/samegame4/samegame4.qmlproject deleted file mode 100644 index 42ffacf4f8..0000000000 --- a/examples/declarative/tutorials/samegame/samegame4/samegame4.qmlproject +++ /dev/null @@ -1,16 +0,0 @@ -import QmlProject 1.1 - -Project { - mainFile: "samegame.qml" - - /* Include .qml, .js, and image files from current directory and subdirectories */ - QmlFiles { - directory: "." - } - JavaScriptFiles { - directory: "." - } - ImageFiles { - directory: "." - } -} diff --git a/examples/declarative/tutorials/samegame/shared/pics/background.jpg b/examples/declarative/tutorials/samegame/shared/pics/background.jpg deleted file mode 100644 index 903d395c8d..0000000000 Binary files a/examples/declarative/tutorials/samegame/shared/pics/background.jpg and /dev/null differ diff --git a/examples/declarative/tutorials/samegame/shared/pics/blueStar.png b/examples/declarative/tutorials/samegame/shared/pics/blueStar.png deleted file mode 100644 index ff9588f80a..0000000000 Binary files a/examples/declarative/tutorials/samegame/shared/pics/blueStar.png and /dev/null differ diff --git a/examples/declarative/tutorials/samegame/shared/pics/blueStone.png b/examples/declarative/tutorials/samegame/shared/pics/blueStone.png deleted file mode 100644 index 20e43c75b6..0000000000 Binary files a/examples/declarative/tutorials/samegame/shared/pics/blueStone.png and /dev/null differ diff --git a/examples/declarative/tutorials/samegame/shared/pics/greenStar.png b/examples/declarative/tutorials/samegame/shared/pics/greenStar.png deleted file mode 100644 index cd06854719..0000000000 Binary files a/examples/declarative/tutorials/samegame/shared/pics/greenStar.png and /dev/null differ diff --git a/examples/declarative/tutorials/samegame/shared/pics/greenStone.png b/examples/declarative/tutorials/samegame/shared/pics/greenStone.png deleted file mode 100644 index b568a1900c..0000000000 Binary files a/examples/declarative/tutorials/samegame/shared/pics/greenStone.png and /dev/null differ diff --git a/examples/declarative/tutorials/samegame/shared/pics/redStar.png b/examples/declarative/tutorials/samegame/shared/pics/redStar.png deleted file mode 100644 index 0a4dffe583..0000000000 Binary files a/examples/declarative/tutorials/samegame/shared/pics/redStar.png and /dev/null differ diff --git a/examples/declarative/tutorials/samegame/shared/pics/redStone.png b/examples/declarative/tutorials/samegame/shared/pics/redStone.png deleted file mode 100644 index 36b09a2686..0000000000 Binary files a/examples/declarative/tutorials/samegame/shared/pics/redStone.png and /dev/null differ diff --git a/examples/declarative/tutorials/samegame/shared/pics/star.png b/examples/declarative/tutorials/samegame/shared/pics/star.png deleted file mode 100644 index defbde53ca..0000000000 Binary files a/examples/declarative/tutorials/samegame/shared/pics/star.png and /dev/null differ diff --git a/examples/declarative/tutorials/samegame/shared/pics/yellowStone.png b/examples/declarative/tutorials/samegame/shared/pics/yellowStone.png deleted file mode 100644 index b1ce76212c..0000000000 Binary files a/examples/declarative/tutorials/samegame/shared/pics/yellowStone.png and /dev/null differ diff --git a/examples/declarative/tutorials/tutorials.pro b/examples/declarative/tutorials/tutorials.pro deleted file mode 100644 index 0a82c1e704..0000000000 --- a/examples/declarative/tutorials/tutorials.pro +++ /dev/null @@ -1,5 +0,0 @@ -TEMPLATE = subdirs - -SUBDIRS += \ - extending - diff --git a/examples/declarative/tutorials/tutorials.qmlproject b/examples/declarative/tutorials/tutorials.qmlproject deleted file mode 100644 index 2bb4016996..0000000000 --- a/examples/declarative/tutorials/tutorials.qmlproject +++ /dev/null @@ -1,14 +0,0 @@ -import QmlProject 1.0 - -Project { - /* Include .qml, .js, and image files from current directory and subdirectories */ - QmlFiles { - directory: "." - } - JavaScriptFiles { - directory: "." - } - ImageFiles { - directory: "." - } -} diff --git a/examples/declarative/twitter/TwitterCore/Button.qml b/examples/declarative/twitter/TwitterCore/Button.qml deleted file mode 100644 index 064fd4b277..0000000000 --- a/examples/declarative/twitter/TwitterCore/Button.qml +++ /dev/null @@ -1,90 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -Item { - id: container - - signal clicked - - property string text - property bool keyUsing: false - - BorderImage { - id: buttonImage - source: "images/toolbutton.sci" - width: container.width; height: container.height - } - BorderImage { - id: pressed - opacity: 0 - source: "images/toolbutton.sci" - width: container.width; height: container.height - } - MouseArea { - id: mouseRegion - anchors.fill: buttonImage - onClicked: { container.clicked(); } - } - Text { - id: btnText - color: if(container.keyUsing){"#D0D0D0";} else {"#FFFFFF";} - anchors.centerIn: buttonImage; font.bold: true - text: container.text; style: Text.Raised; styleColor: "black" - font.pixelSize: 12 - } - states: [ - State { - name: "Pressed" - when: mouseRegion.pressed == true - PropertyChanges { target: pressed; opacity: 1 } - }, - State { - name: "Focused" - when: container.activeFocus == true - PropertyChanges { target: btnText; color: "#FFFFFF" } - } - ] - transitions: Transition { - ColorAnimation { target: btnText; } - } -} diff --git a/examples/declarative/twitter/TwitterCore/FatDelegate.qml b/examples/declarative/twitter/TwitterCore/FatDelegate.qml deleted file mode 100644 index 5fd0d1622b..0000000000 --- a/examples/declarative/twitter/TwitterCore/FatDelegate.qml +++ /dev/null @@ -1,105 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -Component { - id: listDelegate - Item { - id: wrapper; width: wrapper.ListView.view.width; height: if(txt.height > 60){txt.height+10}else{60} //50+5+5 - function handleLink(link){ - if(link.slice(0,3) == 'app'){ - screen.setUser(link.slice(7)); - }else if(link.slice(0,4) == 'http'){ - Qt.openUrlExternally(link); - } - } - function addTags(str){ - var ret = str.replace(/@[a-zA-Z0-9_]+/g, '$&');//click to jump to user? - var ret2 = ret.replace(/http:\/\/[^ \n\t]+/g, '$&');//surrounds http links with html link tags - return ret2; - } - - // Strip away paranthesis - function userName(str) { - var user = str.replace(/\([\S|\s]*\)/gi, ""); - return user.trim(); - } - - Item { - id: moveMe; height: parent.height - Rectangle { - id: blackRect - color: "black"; opacity: wrapper.ListView.index % 2 ? 0.2 : 0.3; height: wrapper.height-2; width: wrapper.width; y: 1 - } - Item { - id: image; x: 6; width: 48; height: 48; smooth: true - anchors.verticalCenter: parent.verticalCenter - - Loading { x: 1; y: 1; width: 48; height: 48; visible: realImage.status != Image.Ready } - Image { - id: realImage; - source: userImage; x: 1; y: 1; - width:48; height:48; opacity:0 ; - onStatusChanged: { - if(status==Image.Ready) - image.state="loaded" - } - } - states: State { - name: "loaded"; - PropertyChanges { target: realImage ; opacity:1 } - } - transitions: Transition { NumberAnimation { target: realImage; property: "opacity"; duration: 200 } } - - } - Text { id:txt; y:4; x: 56 - text: '' - + ''+userName(name) + " from " +source - + "
" + statusText + ""; - textFormat: Text.StyledText - color: "#cccccc"; style: Text.Raised; styleColor: "black"; wrapMode: Text.WordWrap; linkColor: "#aaccaa" - anchors.left: image.right; anchors.right: blackRect.right; anchors.leftMargin: 6; anchors.rightMargin: 6 - onLinkActivated: wrapper.handleLink(link) - } - } - } -} diff --git a/examples/declarative/twitter/TwitterCore/Input.qml b/examples/declarative/twitter/TwitterCore/Input.qml deleted file mode 100644 index 2987b9e5d8..0000000000 --- a/examples/declarative/twitter/TwitterCore/Input.qml +++ /dev/null @@ -1,65 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -FocusScope { - id:container - width: 220 - height: 28 - BorderImage { source: "images/lineedit.sci"; anchors.fill: parent } - signal accepted - property alias text: input.text - property alias item:input - TextInput{ - id: input - width: parent.width - 12 - anchors.centerIn: parent - maximumLength:21 - font.pixelSize: 16; - font.bold: true - color: "#151515"; selectionColor: "mediumseagreen" - focus: true - onAccepted:{container.accepted()} - text: "" - selectByMouse: true - } -} diff --git a/examples/declarative/twitter/TwitterCore/Loading.qml b/examples/declarative/twitter/TwitterCore/Loading.qml deleted file mode 100644 index 8f7c868bee..0000000000 --- a/examples/declarative/twitter/TwitterCore/Loading.qml +++ /dev/null @@ -1,49 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -Image { - id: loading; source: "images/loading.png" - NumberAnimation on rotation { - from: 0; to: 360; running: loading.visible == true; loops: Animation.Infinite; duration: 900 - } -} diff --git a/examples/declarative/twitter/TwitterCore/MultiTitleBar.qml b/examples/declarative/twitter/TwitterCore/MultiTitleBar.qml deleted file mode 100644 index f52ce5be26..0000000000 --- a/examples/declarative/twitter/TwitterCore/MultiTitleBar.qml +++ /dev/null @@ -1,60 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -Item { - TitleBar { id: titleBar; width: parent.width; height: 60; - y: -80 - untaggedString: "Latest tweets from everyone" - taggedString: "Latest tweets from " - } - states: [ - State { - name: "search"; when: screen.state!="search" - PropertyChanges { target: titleBar; y: 0 } - } - ] - transitions: [ - Transition { NumberAnimation { properties: "x,y"; duration: 500; easing.type: Easing.InOutQuad } } - ] -} - diff --git a/examples/declarative/twitter/TwitterCore/RssModel.qml b/examples/declarative/twitter/TwitterCore/RssModel.qml deleted file mode 100644 index c4050994e6..0000000000 --- a/examples/declarative/twitter/TwitterCore/RssModel.qml +++ /dev/null @@ -1,80 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 -import QtQuick.XmlListModel 2.0 - -Item { id: wrapper - property variant model: xmlModel - property string from : "" - property string to : "" - property string phrase : "" - - property string mode : "everyone" - property int status: xmlModel.status - function reload() { xmlModel.reload(); } - - XmlListModel { - id: xmlModel - - function encodePhrase(x) { return encodeURIComponent(x); } - - source: (from=="" && to=="" && phrase=="") ? "" : - 'http://search.twitter.com/search.atom?from='+from+"&to="+to+"&phrase="+encodePhrase(phrase) - - namespaceDeclarations: "declare default element namespace 'http://www.w3.org/2005/Atom'; " + - "declare namespace twitter=\"http://api.twitter.com/\";"; - - query: "/feed/entry" - - XmlRole { name: "statusText"; query: "content/string()" } - XmlRole { name: "timestamp"; query: "published/string()" } - XmlRole { name: "source"; query: "twitter:source/string()" } - XmlRole { name: "name"; query: "author/name/string()" } - XmlRole { name: "userImage"; query: "link[@rel = 'image']/@href/string()" } - - } - Binding { - property: "mode" - target: wrapper - value: {if(wrapper.tags==''){"everyone";}else if(wrapper.tags=='my timeline'){"self";}else{"user";}} - } -} diff --git a/examples/declarative/twitter/TwitterCore/SearchView.qml b/examples/declarative/twitter/TwitterCore/SearchView.qml deleted file mode 100644 index 82a8559889..0000000000 --- a/examples/declarative/twitter/TwitterCore/SearchView.qml +++ /dev/null @@ -1,124 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -FocusScope { - id: wrapper - Column { - anchors.centerIn: parent - spacing: 20 - Column{ - spacing: 4 - Text { - text: "Posted by:" - font.pixelSize: 16; font.bold: true; color: "white"; style: Text.Raised; styleColor: "black" - horizontalAlignment: Qt.AlignRight - } - Input{ - id: fromIn - KeyNavigation.backtab: searchbutton - KeyNavigation.tab:toIn - onAccepted:searchbutton.doSearch(); - focus: true - } - Text { - text: "In reply to:" - font.pixelSize: 16; font.bold: true; color: "white"; style: Text.Raised; styleColor: "black" - horizontalAlignment: Qt.AlignRight - } - Input{ - id: toIn - KeyNavigation.backtab: fromIn - KeyNavigation.tab:phraseIn - onAccepted:searchbutton.doSearch(); - } - Text { - text: "Search phrase:" - font.pixelSize: 16; font.bold: true; color: "white"; style: Text.Raised; styleColor: "black" - horizontalAlignment: Qt.AlignRight - } - Input{ - id: phraseIn - KeyNavigation.backtab: toIn - KeyNavigation.tab:searchbutton - onAccepted:searchbutton.doSearch(); - text: "Qt Quick" - } - } - Button { - width: 100 - height: 32 - id: searchbutton - keyUsing: true; - opacity: 1 - text: "Search" - KeyNavigation.tab: fromIn - Keys.onReturnPressed: searchbutton.doSearch(); - Keys.onEnterPressed: searchbutton.doSearch(); - Keys.onSelectPressed: searchbutton.doSearch(); - Keys.onSpacePressed: searchbutton.doSearch(); - onClicked: searchbutton.doSearch(); - - function doSearch() { - // Search ! allowed - if (wrapper.state=="invalidinput") - return; - - rssModel.from=fromIn.text; - rssModel.to= toIn.text; - rssModel.phrase = phraseIn.text; - screen.focus = true; - screen.state = "" - } - } - } - states: - State { - name: "invalidinput" - when: fromIn.text=="" && toIn.text=="" && phraseIn.text=="" - PropertyChanges { target: searchbutton ; opacity: 0.6 ; } - } - transitions: - Transition { - NumberAnimation { target: searchbutton; property: "opacity"; duration: 200 } - } -} diff --git a/examples/declarative/twitter/TwitterCore/TitleBar.qml b/examples/declarative/twitter/TwitterCore/TitleBar.qml deleted file mode 100644 index 3624048c4d..0000000000 --- a/examples/declarative/twitter/TwitterCore/TitleBar.qml +++ /dev/null @@ -1,130 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -Item { - id: titleBar - property string untaggedString: "Uploads from everyone" - property string taggedString: "Recent uploads tagged " - - BorderImage { source: "images/titlebar.sci"; width: parent.width; height: parent.height + 14; y: -7 } - - Item { - id: container - width: (parent.width * 2) - 55 ; height: parent.height - - function accept() { - titleBar.state = "" - background.state = "" - rssModel.tags = editor.text - } - - Item { - id:imageBox - x: 6; width: 0; height: 50; smooth: true - anchors.verticalCenter: parent.verticalCenter - - UserModel { user: rssModel.from; id: userModel } - Component { - id: imgDelegate; - Item { - id:imageitem - visible:true - Loading { width:48; height:48; visible: realImage.status != Image.Ready } - Image { id: realImage; source: image; width:48; height:48; opacity:0; } - states: - State { - name: "loaded" - when: (realImage.status == Image.Ready) - PropertyChanges { target: realImage; opacity:1 } - } - transitions: Transition { - NumberAnimation { target: realImage; property: "opacity"; duration: 200 } - } - } - } - ListView { id:view; model: userModel.model; x:1; y:1; delegate: imgDelegate } - states: - State { - when: !userModel.user=="" - PropertyChanges { target: imageBox; width: 50; } - } - transitions: - Transition { - NumberAnimation { target: imageBox; property: "width"; duration: 200 } - } - } - - Image { - id: quitButton - x: 5 - anchors.verticalCenter: parent.verticalCenter - source: "images/quit.png" - MouseArea { - anchors.fill: parent - onClicked: Qt.quit() - } - } - - Text { - id: categoryText - anchors { - left: quitButton.right; right: parent.right; leftMargin: 10; rightMargin: 10 - verticalCenter: parent.verticalCenter - } - elide: Text.ElideLeft - text: (rssModel.from=="" ? untaggedString : taggedString + rssModel.from) - font.bold: true; color: "White"; style: Text.Raised; styleColor: "Black" - font.pixelSize: 12 - } - } - - states: State { - name: "Tags" - PropertyChanges { target: container; x: -tagButton.x + 5 } - PropertyChanges { target: editor; focus: true } - } - - transitions: Transition { - NumberAnimation { properties: "x"; easing.type: Easing.InOutQuad } - } -} diff --git a/examples/declarative/twitter/TwitterCore/ToolBar.qml b/examples/declarative/twitter/TwitterCore/ToolBar.qml deleted file mode 100644 index 06d3324ee3..0000000000 --- a/examples/declarative/twitter/TwitterCore/ToolBar.qml +++ /dev/null @@ -1,64 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -Item { - id: toolbar - - property alias button1Label: button1.text - property alias button2Label: button2.text - signal button1Clicked - signal button2Clicked - focus:true - BorderImage { source: "images/titlebar.sci"; width: parent.width; height: parent.height + 14; y: -7 } - Button { - id: button1 - anchors.left: parent.left; anchors.leftMargin: 5; y: 3; width: 140; height: 32 - onClicked: toolbar.button1Clicked() - focus:true - } - Button { - id: button2 - anchors.right: parent.right; anchors.rightMargin: 5; y: 3; width: 140; height: 32 - onClicked: toolbar.button2Clicked() - } -} diff --git a/examples/declarative/twitter/TwitterCore/UserModel.qml b/examples/declarative/twitter/TwitterCore/UserModel.qml deleted file mode 100644 index f88837c344..0000000000 --- a/examples/declarative/twitter/TwitterCore/UserModel.qml +++ /dev/null @@ -1,66 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 -import QtQuick.XmlListModel 2.0 - -//This "model" gets the user information about the searched user. Mainly for the icon. - -Item { id: wrapper - property variant model: xmlModel - property string user : "" - property int status: xmlModel.status - function reload() { xmlModel.reload(); } - XmlListModel { - id: xmlModel - - source: user!= "" ? "http://twitter.com/users/show.xml?screen_name="+user : "" - query: "/user" - - XmlRole { name: "name"; query: "name/string()" } - XmlRole { name: "screenName"; query: "screen_name/string()" } - XmlRole { name: "image"; query: "profile_image_url/string()" } - XmlRole { name: "location"; query: "location/string()" } - XmlRole { name: "description"; query: "description/string()" } - XmlRole { name: "followers"; query: "followers_count/string()" } - //TODO: Could also get the user's color scheme, timezone and a few other things - } -} diff --git a/examples/declarative/twitter/TwitterCore/images/gloss.png b/examples/declarative/twitter/TwitterCore/images/gloss.png deleted file mode 100644 index 5d370cd93d..0000000000 Binary files a/examples/declarative/twitter/TwitterCore/images/gloss.png and /dev/null differ diff --git a/examples/declarative/twitter/TwitterCore/images/lineedit.png b/examples/declarative/twitter/TwitterCore/images/lineedit.png deleted file mode 100644 index 2cc38dc35b..0000000000 Binary files a/examples/declarative/twitter/TwitterCore/images/lineedit.png and /dev/null differ diff --git a/examples/declarative/twitter/TwitterCore/images/lineedit.sci b/examples/declarative/twitter/TwitterCore/images/lineedit.sci deleted file mode 100644 index 054bff78be..0000000000 --- a/examples/declarative/twitter/TwitterCore/images/lineedit.sci +++ /dev/null @@ -1,5 +0,0 @@ -border.left: 10 -border.top: 10 -border.bottom: 10 -border.right: 10 -source: lineedit.png diff --git a/examples/declarative/twitter/TwitterCore/images/loading.png b/examples/declarative/twitter/TwitterCore/images/loading.png deleted file mode 100644 index 47a1589c5d..0000000000 Binary files a/examples/declarative/twitter/TwitterCore/images/loading.png and /dev/null differ diff --git a/examples/declarative/twitter/TwitterCore/images/quit.png b/examples/declarative/twitter/TwitterCore/images/quit.png deleted file mode 100644 index 5bda1b6e0d..0000000000 Binary files a/examples/declarative/twitter/TwitterCore/images/quit.png and /dev/null differ diff --git a/examples/declarative/twitter/TwitterCore/images/stripes.png b/examples/declarative/twitter/TwitterCore/images/stripes.png deleted file mode 100644 index 9f36727ea4..0000000000 Binary files a/examples/declarative/twitter/TwitterCore/images/stripes.png and /dev/null differ diff --git a/examples/declarative/twitter/TwitterCore/images/titlebar.png b/examples/declarative/twitter/TwitterCore/images/titlebar.png deleted file mode 100644 index 51c90082d0..0000000000 Binary files a/examples/declarative/twitter/TwitterCore/images/titlebar.png and /dev/null differ diff --git a/examples/declarative/twitter/TwitterCore/images/titlebar.sci b/examples/declarative/twitter/TwitterCore/images/titlebar.sci deleted file mode 100644 index 0418d94cd6..0000000000 --- a/examples/declarative/twitter/TwitterCore/images/titlebar.sci +++ /dev/null @@ -1,5 +0,0 @@ -border.left: 10 -border.top: 12 -border.bottom: 12 -border.right: 10 -source: titlebar.png diff --git a/examples/declarative/twitter/TwitterCore/images/toolbutton.png b/examples/declarative/twitter/TwitterCore/images/toolbutton.png deleted file mode 100644 index 11310013ee..0000000000 Binary files a/examples/declarative/twitter/TwitterCore/images/toolbutton.png and /dev/null differ diff --git a/examples/declarative/twitter/TwitterCore/images/toolbutton.sci b/examples/declarative/twitter/TwitterCore/images/toolbutton.sci deleted file mode 100644 index 9e4f965307..0000000000 --- a/examples/declarative/twitter/TwitterCore/images/toolbutton.sci +++ /dev/null @@ -1,5 +0,0 @@ -border.left: 15 -border.top: 4 -border.bottom: 4 -border.right: 15 -source: toolbutton.png diff --git a/examples/declarative/twitter/TwitterCore/qmldir b/examples/declarative/twitter/TwitterCore/qmldir deleted file mode 100644 index 452a648b23..0000000000 --- a/examples/declarative/twitter/TwitterCore/qmldir +++ /dev/null @@ -1,10 +0,0 @@ -SearchView 2.0 SearchView.qml -Button 2.0 Button.qml -Input 2.0 Input.qml -FatDelegate 2.0 FatDelegate.qml -Loading 2.0 Loading.qml -MultiTitleBar 2.0 MultiTitleBar.qml -TitleBar 2.0 TitleBar.qml -RssModel 2.0 RssModel.qml -UserModel 2.0 UserModel.qml -ToolBar 2.0 ToolBar.qml diff --git a/examples/declarative/twitter/twitter.qml b/examples/declarative/twitter/twitter.qml deleted file mode 100644 index 26e4a7079b..0000000000 --- a/examples/declarative/twitter/twitter.qml +++ /dev/null @@ -1,135 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 -import QtQuick.XmlListModel 2.0 -import "TwitterCore" 2.0 as Twitter - -Item { - id: screen; width: 320; height: 480 - property bool userView : false - property variant tmpStr - function setUser(str){hack.running = true; tmpStr = str} - function reallySetUser(){rssModel.from = tmpStr;rssModel.to = ""; rssModel.phrase = ""} - state:"searchquery" - //Workaround for bug 260266 - Timer{ interval: 1; running: false; repeat: false; onTriggered: screen.reallySetUser(); id:hack } - Keys.onEscapePressed: screen.state="searchquery" - Keys.onBacktabPressed: screen.state="searchquery" - Rectangle { - id: background - anchors.fill: parent; color: "#343434"; - - state:"searchquery" - Image { source: "TwitterCore/images/stripes.png"; fillMode: Image.Tile; anchors.fill: parent; opacity: 0.3 } - - MouseArea { - anchors.fill: parent - onClicked: screen.focus = false; - } - - Twitter.RssModel { id: rssModel } - Twitter.Loading { anchors.centerIn: parent; visible: rssModel.status==XmlListModel.Loading && state!='unauthed'} - Text { - width: 180 - text: "Could not access twitter using this screen name and password pair."; - color: "#cccccc"; style: Text.Raised; styleColor: "black"; wrapMode: Text.WordWrap - visible: rssModel.status==XmlListModel.Error; anchors.centerIn: parent - } - - Item { - id: views - x: 2; width: parent.width - 4 - y:60 //Below the title bars - height: parent.height - 100 - - Text { - id:title - text: "Search Twitter" - anchors.horizontalCenter: parent.horizontalCenter - font.pixelSize: 20; font.bold: true; color: "#bbb"; style: Text.Raised; styleColor: "black" - opacity:0 - } - - Twitter.SearchView{ - id: searchView - anchors.verticalCenter: parent.verticalCenter - width: parent.width; height: parent.height-60; - x: -(screen.width * 1.5) - } - - Twitter.FatDelegate { id: fatDelegate } - ListView { - id: mainView; model: rssModel.model; delegate: fatDelegate; - width: parent.width; height: parent.height; x: 0; cacheBuffer: 100; - } - } - - Twitter.MultiTitleBar { id: titleBar; width: parent.width } - Twitter.ToolBar { id: toolBar; height: 40; - //anchors.bottom: parent.bottom; - //TODO: Use anchor changes instead of hard coding - y: screen.height - 40 - width: parent.width; opacity: 0.9 - button1Label: "New Search" - button2Label: "Update" - onButton1Clicked: - { - screen.state="searchquery" - } - onButton2Clicked: rssModel.reload(); - } - } - states: [ - State { - name: "searchquery"; - PropertyChanges { target: searchView; x: 0; focus:true} - PropertyChanges { target: mainView; x: -(parent.width * 1.5) } - PropertyChanges { target: titleBar; y: -80 } - PropertyChanges { target: toolBar; y: screen.height } - PropertyChanges { target: toolBar } - PropertyChanges { target: title; opacity:1} - } - ] - transitions: [ - Transition { NumberAnimation { properties: "x,y,opacity"; duration: 500; easing.type: Easing.InOutQuad } } - ] -} diff --git a/examples/declarative/twitter/twitter.qmlproject b/examples/declarative/twitter/twitter.qmlproject deleted file mode 100644 index b14f71fdfd..0000000000 --- a/examples/declarative/twitter/twitter.qmlproject +++ /dev/null @@ -1,16 +0,0 @@ -import QmlProject 1.1 - -Project { - mainFile: "twitter.qml" - - /* Include .qml, .js, and image files from current directory and subdirectories */ - QmlFiles { - directory: "." - } - JavaScriptFiles { - directory: "." - } - ImageFiles { - directory: "." - } -} diff --git a/examples/declarative/ui-components/dialcontrol/content/Dial.qml b/examples/declarative/ui-components/dialcontrol/content/Dial.qml deleted file mode 100644 index c61adee364..0000000000 --- a/examples/declarative/ui-components/dialcontrol/content/Dial.qml +++ /dev/null @@ -1,86 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -Item { - id: root - property real value : 0 - - width: 210; height: 210 - - Image { source: "background.png" } - -//! [needle_shadow] - Image { - x: 96 - y: 35 - source: "needle_shadow.png" - transform: Rotation { - origin.x: 9; origin.y: 67 - angle: needleRotation.angle - } - } -//! [needle_shadow] -//! [needle] - Image { - id: needle - x: 98; y: 33 - smooth: true - source: "needle.png" - transform: Rotation { - id: needleRotation - origin.x: 5; origin.y: 65 - //! [needle angle] - angle: Math.min(Math.max(-130, root.value*2.6 - 130), 133) - Behavior on angle { - SpringAnimation { - spring: 1.4 - damping: .15 - } - } - //! [needle angle] - } - } -//! [needle] -//! [overlay] - Image { x: 21; y: 18; source: "overlay.png" } -//! [overlay] -} diff --git a/examples/declarative/ui-components/dialcontrol/content/QuitButton.qml b/examples/declarative/ui-components/dialcontrol/content/QuitButton.qml deleted file mode 100644 index 702b892d23..0000000000 --- a/examples/declarative/ui-components/dialcontrol/content/QuitButton.qml +++ /dev/null @@ -1,52 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 -Image { - source: "quit.png" - scale: quitMouse.pressed ? 0.8 : 1.0 - smooth: quitMouse.pressed - MouseArea { - id: quitMouse - anchors.fill: parent - anchors.margins: -10 - onClicked: Qt.quit() - } -} diff --git a/examples/declarative/ui-components/dialcontrol/content/background.png b/examples/declarative/ui-components/dialcontrol/content/background.png deleted file mode 100644 index 75d555d7ab..0000000000 Binary files a/examples/declarative/ui-components/dialcontrol/content/background.png and /dev/null differ diff --git a/examples/declarative/ui-components/dialcontrol/content/needle.png b/examples/declarative/ui-components/dialcontrol/content/needle.png deleted file mode 100644 index 2d19f75039..0000000000 Binary files a/examples/declarative/ui-components/dialcontrol/content/needle.png and /dev/null differ diff --git a/examples/declarative/ui-components/dialcontrol/content/needle_shadow.png b/examples/declarative/ui-components/dialcontrol/content/needle_shadow.png deleted file mode 100644 index 8d8a928cc5..0000000000 Binary files a/examples/declarative/ui-components/dialcontrol/content/needle_shadow.png and /dev/null differ diff --git a/examples/declarative/ui-components/dialcontrol/content/overlay.png b/examples/declarative/ui-components/dialcontrol/content/overlay.png deleted file mode 100644 index 3860a7b590..0000000000 Binary files a/examples/declarative/ui-components/dialcontrol/content/overlay.png and /dev/null differ diff --git a/examples/declarative/ui-components/dialcontrol/content/quit.png b/examples/declarative/ui-components/dialcontrol/content/quit.png deleted file mode 100644 index b822057d4e..0000000000 Binary files a/examples/declarative/ui-components/dialcontrol/content/quit.png and /dev/null differ diff --git a/examples/declarative/ui-components/dialcontrol/dialcontrol.qml b/examples/declarative/ui-components/dialcontrol/dialcontrol.qml deleted file mode 100644 index d645b34aa4..0000000000 --- a/examples/declarative/ui-components/dialcontrol/dialcontrol.qml +++ /dev/null @@ -1,98 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -//! [imports] -import QtQuick 2.0 -import "content" -//! [imports] - -//! [0] -Rectangle { - color: "#545454" - width: 300; height: 300 - - // Dial with a slider to adjust it - Dial { - id: dial - anchors.centerIn: parent - value: slider.x * 100 / (container.width - 34) - } - - Rectangle { - id: container - anchors { bottom: parent.bottom; left: parent.left - right: parent.right; leftMargin: 20; rightMargin: 20 - bottomMargin: 10 - } - height: 16 - - radius: 8 - opacity: 0.7 - smooth: true - gradient: Gradient { - GradientStop { position: 0.0; color: "gray" } - GradientStop { position: 1.0; color: "white" } - } - - Rectangle { - id: slider - x: 1; y: 1; width: 30; height: 14 - radius: 6 - smooth: true - gradient: Gradient { - GradientStop { position: 0.0; color: "#424242" } - GradientStop { position: 1.0; color: "black" } - } - - MouseArea { - anchors.fill: parent - anchors.margins: -16 // Increase mouse area a lot outside the slider - drag.target: parent; drag.axis: Drag.XAxis - drag.minimumX: 2; drag.maximumX: container.width - 32 - } - } - } - QuitButton { - anchors.right: parent.right - anchors.top: parent.top - anchors.margins: 10 - } -} -//! [0] diff --git a/examples/declarative/ui-components/flipable/content/5_heart.png b/examples/declarative/ui-components/flipable/content/5_heart.png deleted file mode 100644 index fb59d81453..0000000000 Binary files a/examples/declarative/ui-components/flipable/content/5_heart.png and /dev/null differ diff --git a/examples/declarative/ui-components/flipable/content/9_club.png b/examples/declarative/ui-components/flipable/content/9_club.png deleted file mode 100644 index 2545001904..0000000000 Binary files a/examples/declarative/ui-components/flipable/content/9_club.png and /dev/null differ diff --git a/examples/declarative/ui-components/flipable/content/Card.qml b/examples/declarative/ui-components/flipable/content/Card.qml deleted file mode 100644 index 6006ea14fc..0000000000 --- a/examples/declarative/ui-components/flipable/content/Card.qml +++ /dev/null @@ -1,80 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -Flipable { - id: container - - property alias source: frontImage.source - property bool flipped: true - property int xAxis: 0 - property int yAxis: 0 - property int angle: 0 - - width: front.width; height: front.height - - front: Image { id: frontImage; smooth: true } - back: Image { source: "back.png"; smooth: true } - - state: "back" - - MouseArea { anchors.fill: parent; onClicked: container.flipped = !container.flipped } - - transform: Rotation { - id: rotation; origin.x: container.width / 2; origin.y: container.height / 2 - axis.x: container.xAxis; axis.y: container.yAxis; axis.z: 0 - } - - states: State { - name: "back"; when: container.flipped - PropertyChanges { target: rotation; angle: container.angle } - } - - transitions: Transition { - ParallelAnimation { - NumberAnimation { target: rotation; properties: "angle"; duration: 600 } - SequentialAnimation { - NumberAnimation { target: container; property: "scale"; to: 0.75; duration: 300 } - NumberAnimation { target: container; property: "scale"; to: 1.0; duration: 300 } - } - } - } -} diff --git a/examples/declarative/ui-components/flipable/content/back.png b/examples/declarative/ui-components/flipable/content/back.png deleted file mode 100644 index f715d7487e..0000000000 Binary files a/examples/declarative/ui-components/flipable/content/back.png and /dev/null differ diff --git a/examples/declarative/ui-components/flipable/flipable.qml b/examples/declarative/ui-components/flipable/flipable.qml deleted file mode 100644 index 4af64afc53..0000000000 --- a/examples/declarative/ui-components/flipable/flipable.qml +++ /dev/null @@ -1,55 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 -import "content" - -Rectangle { - id: window - - width: 480; height: 320 - color: "darkgreen" - - Row { - anchors.centerIn: parent; spacing: 30 - Card { source: "content/9_club.png"; angle: 180; yAxis: 1 } - Card { source: "content/5_heart.png"; angle: 540; xAxis: 1 } - } -} diff --git a/examples/declarative/ui-components/progressbar/content/ProgressBar.qml b/examples/declarative/ui-components/progressbar/content/ProgressBar.qml deleted file mode 100644 index c9be8d7336..0000000000 --- a/examples/declarative/ui-components/progressbar/content/ProgressBar.qml +++ /dev/null @@ -1,83 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -Item { - id: progressbar - - property int minimum: 0 - property int maximum: 100 - property int value: 0 - property alias color: gradient1.color - property alias secondColor: gradient2.color - - width: 250; height: 23 - clip: true - - BorderImage { - source: "background.png" - width: parent.width; height: parent.height - border { left: 4; top: 4; right: 4; bottom: 4 } - } - - Rectangle { - id: highlight - - property int widthDest: ((progressbar.width * (value - minimum)) / (maximum - minimum) - 6) - - width: highlight.widthDest - Behavior on width { SmoothedAnimation { velocity: 1200 } } - - anchors { left: parent.left; top: parent.top; bottom: parent.bottom; margins: 3 } - radius: 1 - gradient: Gradient { - GradientStop { id: gradient1; position: 0.0 } - GradientStop { id: gradient2; position: 1.0 } - } - - } - Text { - anchors { right: highlight.right; rightMargin: 6; verticalCenter: parent.verticalCenter } - color: "white" - font.bold: true - text: Math.floor((value - minimum) / (maximum - minimum) * 100) + '%' - } -} diff --git a/examples/declarative/ui-components/progressbar/content/background.png b/examples/declarative/ui-components/progressbar/content/background.png deleted file mode 100644 index 9044226f85..0000000000 Binary files a/examples/declarative/ui-components/progressbar/content/background.png and /dev/null differ diff --git a/examples/declarative/ui-components/progressbar/main.qml b/examples/declarative/ui-components/progressbar/main.qml deleted file mode 100644 index 367e4c1265..0000000000 --- a/examples/declarative/ui-components/progressbar/main.qml +++ /dev/null @@ -1,73 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 -import "content" - -Rectangle { - id: main - - width: 600; height: 405 - color: "#edecec" - - Flickable { - anchors.fill: parent - contentHeight: column.height + 20 - - Column { - id: column - x: 10; y: 10 - spacing: 10 - - Repeater { - model: 25 - - ProgressBar { - property int r: Math.floor(Math.random() * 5000 + 1000) - width: main.width - 20 - - NumberAnimation on value { duration: r; from: 0; to: 100; loops: Animation.Infinite } - ColorAnimation on color { duration: r; from: "lightsteelblue"; to: "thistle"; loops: Animation.Infinite } - ColorAnimation on secondColor { duration: r; from: "steelblue"; to: "#CD96CD"; loops: Animation.Infinite } - } - } - } - } -} diff --git a/examples/declarative/ui-components/scrollbar/ScrollBar.qml b/examples/declarative/ui-components/scrollbar/ScrollBar.qml deleted file mode 100644 index a3d0d3841c..0000000000 --- a/examples/declarative/ui-components/scrollbar/ScrollBar.qml +++ /dev/null @@ -1,74 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -Item { - id: scrollBar - - // The properties that define the scrollbar's state. - // position and pageSize are in the range 0.0 - 1.0. They are relative to the - // height of the page, i.e. a pageSize of 0.5 means that you can see 50% - // of the height of the view. - // orientation can be either Qt.Vertical or Qt.Horizontal - property real position - property real pageSize - property variant orientation : Qt.Vertical - - // A light, semi-transparent background - Rectangle { - id: background - anchors.fill: parent - radius: orientation == Qt.Vertical ? (width/2 - 1) : (height/2 - 1) - color: "white" - opacity: 0.3 - } - - // Size the bar to the required size, depending upon the orientation. - Rectangle { - x: orientation == Qt.Vertical ? 1 : (scrollBar.position * (scrollBar.width-2) + 1) - y: orientation == Qt.Vertical ? (scrollBar.position * (scrollBar.height-2) + 1) : 1 - width: orientation == Qt.Vertical ? (parent.width-2) : (scrollBar.pageSize * (scrollBar.width-2)) - height: orientation == Qt.Vertical ? (scrollBar.pageSize * (scrollBar.height-2)) : (parent.height-2) - radius: orientation == Qt.Vertical ? (width/2 - 1) : (height/2 - 1) - color: "black" - opacity: 0.7 - } -} diff --git a/examples/declarative/ui-components/scrollbar/main.qml b/examples/declarative/ui-components/scrollbar/main.qml deleted file mode 100644 index a7d602b437..0000000000 --- a/examples/declarative/ui-components/scrollbar/main.qml +++ /dev/null @@ -1,93 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -Rectangle { - width: 640 - height: 480 - - // Create a flickable to view a large image. - Flickable { - id: view - anchors.fill: parent - contentWidth: picture.width - contentHeight: picture.height - - Image { - id: picture - source: "pics/niagara_falls.jpg" - asynchronous: true - } - - // Only show the scrollbars when the view is moving. - states: State { - name: "ShowBars" - when: view.movingVertically || view.movingHorizontally - PropertyChanges { target: verticalScrollBar; opacity: 1 } - PropertyChanges { target: horizontalScrollBar; opacity: 1 } - } - - transitions: Transition { - NumberAnimation { properties: "opacity"; duration: 400 } - } - } - - // Attach scrollbars to the right and bottom edges of the view. - ScrollBar { - id: verticalScrollBar - width: 12; height: view.height-12 - anchors.right: view.right - opacity: 0 - orientation: Qt.Vertical - position: view.visibleArea.yPosition - pageSize: view.visibleArea.heightRatio - } - - ScrollBar { - id: horizontalScrollBar - width: view.width-12; height: 12 - anchors.bottom: view.bottom - opacity: 0 - orientation: Qt.Horizontal - position: view.visibleArea.xPosition - pageSize: view.visibleArea.widthRatio - } -} diff --git a/examples/declarative/ui-components/scrollbar/pics/niagara_falls.jpg b/examples/declarative/ui-components/scrollbar/pics/niagara_falls.jpg deleted file mode 100644 index e625c0d3e6..0000000000 Binary files a/examples/declarative/ui-components/scrollbar/pics/niagara_falls.jpg and /dev/null differ diff --git a/examples/declarative/ui-components/scrollbar/scrollbar.qmlproject b/examples/declarative/ui-components/scrollbar/scrollbar.qmlproject deleted file mode 100644 index e5a8bf02ca..0000000000 --- a/examples/declarative/ui-components/scrollbar/scrollbar.qmlproject +++ /dev/null @@ -1,16 +0,0 @@ -import QmlProject 1.1 - -Project { - mainFile: "main.qml" - - /* Include .qml, .js, and image files from current directory and subdirectories */ - QmlFiles { - directory: "." - } - JavaScriptFiles { - directory: "." - } - ImageFiles { - directory: "." - } -} diff --git a/examples/declarative/ui-components/searchbox/SearchBox.qml b/examples/declarative/ui-components/searchbox/SearchBox.qml deleted file mode 100644 index 6f6f486412..0000000000 --- a/examples/declarative/ui-components/searchbox/SearchBox.qml +++ /dev/null @@ -1,109 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -FocusScope { - id: focusScope - width: 250; height: 28 - - BorderImage { - source: "images/lineedit-bg.png" - width: parent.width; height: parent.height - border { left: 4; top: 4; right: 4; bottom: 4 } - } - - BorderImage { - source: "images/lineedit-bg-focus.png" - width: parent.width; height: parent.height - border { left: 4; top: 4; right: 4; bottom: 4 } - visible: parent.activeFocus ? true : false - } - - Text { - id: typeSomething - anchors.fill: parent; anchors.leftMargin: 8 - verticalAlignment: Text.AlignVCenter - text: "Type something..." - color: "gray" - font.italic: true - } - - MouseArea { - anchors.fill: parent - onClicked: { focusScope.focus = true; textInput.openSoftwareInputPanel(); } - } - - TextInput { - id: textInput - anchors { left: parent.left; leftMargin: 8; right: clear.left; rightMargin: 8; verticalCenter: parent.verticalCenter } - focus: true - selectByMouse: true - } - - Image { - id: clear - anchors { right: parent.right; rightMargin: 8; verticalCenter: parent.verticalCenter } - source: "images/clear.png" - opacity: 0 - - MouseArea { - anchors.fill: parent - onClicked: { textInput.text = ''; focusScope.focus = true; textInput.openSoftwareInputPanel(); } - } - } - - states: State { - name: "hasText"; when: textInput.text != '' - PropertyChanges { target: typeSomething; opacity: 0 } - PropertyChanges { target: clear; opacity: 1 } - } - - transitions: [ - Transition { - from: ""; to: "hasText" - NumberAnimation { exclude: typeSomething; properties: "opacity" } - }, - Transition { - from: "hasText"; to: "" - NumberAnimation { properties: "opacity" } - } - ] -} diff --git a/examples/declarative/ui-components/searchbox/images/clear.png b/examples/declarative/ui-components/searchbox/images/clear.png deleted file mode 100644 index 91eb270695..0000000000 Binary files a/examples/declarative/ui-components/searchbox/images/clear.png and /dev/null differ diff --git a/examples/declarative/ui-components/searchbox/images/lineedit-bg-focus.png b/examples/declarative/ui-components/searchbox/images/lineedit-bg-focus.png deleted file mode 100644 index bbfac38d2d..0000000000 Binary files a/examples/declarative/ui-components/searchbox/images/lineedit-bg-focus.png and /dev/null differ diff --git a/examples/declarative/ui-components/searchbox/images/lineedit-bg.png b/examples/declarative/ui-components/searchbox/images/lineedit-bg.png deleted file mode 100644 index 9044226f85..0000000000 Binary files a/examples/declarative/ui-components/searchbox/images/lineedit-bg.png and /dev/null differ diff --git a/examples/declarative/ui-components/searchbox/main.qml b/examples/declarative/ui-components/searchbox/main.qml deleted file mode 100644 index 6e9731cf9c..0000000000 --- a/examples/declarative/ui-components/searchbox/main.qml +++ /dev/null @@ -1,60 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -Rectangle { - id: page - width: 500; height: 250 - color: "#edecec" - - MouseArea { - anchors.fill: parent - onClicked: page.focus = false; - } - Column { - anchors { horizontalCenter: parent.horizontalCenter; verticalCenter: parent.verticalCenter } - spacing: 10 - - SearchBox { id: search1; KeyNavigation.tab: search2; KeyNavigation.backtab: search3; focus: true } - SearchBox { id: search2; KeyNavigation.tab: search3; KeyNavigation.backtab: search1 } - SearchBox { id: search3; KeyNavigation.tab: search1; KeyNavigation.backtab: search2 } - } -} diff --git a/examples/declarative/ui-components/searchbox/searchbox.qmlproject b/examples/declarative/ui-components/searchbox/searchbox.qmlproject deleted file mode 100644 index e5a8bf02ca..0000000000 --- a/examples/declarative/ui-components/searchbox/searchbox.qmlproject +++ /dev/null @@ -1,16 +0,0 @@ -import QmlProject 1.1 - -Project { - mainFile: "main.qml" - - /* Include .qml, .js, and image files from current directory and subdirectories */ - QmlFiles { - directory: "." - } - JavaScriptFiles { - directory: "." - } - ImageFiles { - directory: "." - } -} diff --git a/examples/declarative/ui-components/slideswitch/content/Switch.qml b/examples/declarative/ui-components/slideswitch/content/Switch.qml deleted file mode 100644 index 981fc16673..0000000000 --- a/examples/declarative/ui-components/slideswitch/content/Switch.qml +++ /dev/null @@ -1,117 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -//![0] -import QtQuick 2.0 - -Item { - id: toggleswitch - width: background.width; height: background.height - -//![1] - property bool on: false -//![1] - -//![2] - function toggle() { - if (toggleswitch.state == "on") - toggleswitch.state = "off"; - else - toggleswitch.state = "on"; - } -//![2] - -//![3] - function releaseSwitch() { - if (knob.x == 1) { - if (toggleswitch.state == "off") return; - } - if (knob.x == 78) { - if (toggleswitch.state == "on") return; - } - toggle(); - } -//![3] - -//![4] - Image { - id: background - source: "background.png" - MouseArea { anchors.fill: parent; onClicked: toggle() } - } -//![4] - -//![5] - Image { - id: knob - x: 1; y: 2 - source: "knob.png" - - MouseArea { - anchors.fill: parent - drag.target: knob; drag.axis: Drag.XAxis; drag.minimumX: 1; drag.maximumX: 78 - onClicked: toggle() - onReleased: releaseSwitch() - } - } -//![5] - -//![6] - states: [ - State { - name: "on" - PropertyChanges { target: knob; x: 78 } - PropertyChanges { target: toggleswitch; on: true } - }, - State { - name: "off" - PropertyChanges { target: knob; x: 1 } - PropertyChanges { target: toggleswitch; on: false } - } - ] -//![6] - -//![7] - transitions: Transition { - NumberAnimation { properties: "x"; easing.type: Easing.InOutQuad; duration: 200 } - } -//![7] -} -//![0] diff --git a/examples/declarative/ui-components/slideswitch/content/background.png b/examples/declarative/ui-components/slideswitch/content/background.png deleted file mode 100644 index d736815870..0000000000 Binary files a/examples/declarative/ui-components/slideswitch/content/background.png and /dev/null differ diff --git a/examples/declarative/ui-components/slideswitch/content/background.svg b/examples/declarative/ui-components/slideswitch/content/background.svg deleted file mode 100644 index f920d3e47a..0000000000 --- a/examples/declarative/ui-components/slideswitch/content/background.svg +++ /dev/null @@ -1,23 +0,0 @@ - - - -]> - - - - - - - - - - - - - - diff --git a/examples/declarative/ui-components/slideswitch/content/knob.png b/examples/declarative/ui-components/slideswitch/content/knob.png deleted file mode 100644 index ee0a436f84..0000000000 Binary files a/examples/declarative/ui-components/slideswitch/content/knob.png and /dev/null differ diff --git a/examples/declarative/ui-components/slideswitch/content/knob.svg b/examples/declarative/ui-components/slideswitch/content/knob.svg deleted file mode 100644 index fb6933718e..0000000000 --- a/examples/declarative/ui-components/slideswitch/content/knob.svg +++ /dev/null @@ -1,867 +0,0 @@ - - -image/svg+xml - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/examples/declarative/ui-components/slideswitch/slideswitch.qml b/examples/declarative/ui-components/slideswitch/slideswitch.qml deleted file mode 100644 index 60a331407c..0000000000 --- a/examples/declarative/ui-components/slideswitch/slideswitch.qml +++ /dev/null @@ -1,51 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 -import "content" - -Rectangle { - color: "white" - width: 400; height: 250 - -//![0] - Switch { anchors.centerIn: parent; on: false } -//![0] -} diff --git a/examples/declarative/ui-components/spinner/content/Spinner.qml b/examples/declarative/ui-components/spinner/content/Spinner.qml deleted file mode 100644 index d7bbeb33ee..0000000000 --- a/examples/declarative/ui-components/spinner/content/Spinner.qml +++ /dev/null @@ -1,70 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -Image { - property alias model: view.model - property alias delegate: view.delegate - property alias currentIndex: view.currentIndex - property real itemHeight: 30 - - source: "spinner-bg.png" - clip: true - - PathView { - id: view - anchors.fill: parent - - pathItemCount: height/itemHeight - preferredHighlightBegin: 0.5 - preferredHighlightEnd: 0.5 - highlight: Image { source: "spinner-select.png"; width: view.width; height: itemHeight+4 } - dragMargin: view.width/2 - - path: Path { - startX: view.width/2; startY: -itemHeight/2 - PathLine { x: view.width/2; y: view.pathItemCount*itemHeight + itemHeight } - } - } - - Keys.onDownPressed: view.incrementCurrentIndex() - Keys.onUpPressed: view.decrementCurrentIndex() -} diff --git a/examples/declarative/ui-components/spinner/content/spinner-bg.png b/examples/declarative/ui-components/spinner/content/spinner-bg.png deleted file mode 100644 index b3556f1f9f..0000000000 Binary files a/examples/declarative/ui-components/spinner/content/spinner-bg.png and /dev/null differ diff --git a/examples/declarative/ui-components/spinner/content/spinner-select.png b/examples/declarative/ui-components/spinner/content/spinner-select.png deleted file mode 100644 index 95a17a1fe2..0000000000 Binary files a/examples/declarative/ui-components/spinner/content/spinner-select.png and /dev/null differ diff --git a/examples/declarative/ui-components/spinner/main.qml b/examples/declarative/ui-components/spinner/main.qml deleted file mode 100644 index 7584c98396..0000000000 --- a/examples/declarative/ui-components/spinner/main.qml +++ /dev/null @@ -1,61 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 -import "content" - -Rectangle { - width: 240; height: 320 - - Column { - y: 20; x: 20; spacing: 20 - - Spinner { - id: spinner - width: 200; height: 240 - focus: true - model: 20 - itemHeight: 30 - delegate: Text { font.pixelSize: 25; text: index; height: 30 } - } - - Text { text: "Current item index: " + spinner.currentIndex } - } -} diff --git a/examples/declarative/ui-components/spinner/spinner.qmlproject b/examples/declarative/ui-components/spinner/spinner.qmlproject deleted file mode 100644 index e5a8bf02ca..0000000000 --- a/examples/declarative/ui-components/spinner/spinner.qmlproject +++ /dev/null @@ -1,16 +0,0 @@ -import QmlProject 1.1 - -Project { - mainFile: "main.qml" - - /* Include .qml, .js, and image files from current directory and subdirectories */ - QmlFiles { - directory: "." - } - JavaScriptFiles { - directory: "." - } - ImageFiles { - directory: "." - } -} diff --git a/examples/declarative/ui-components/tabwidget/TabWidget.qml b/examples/declarative/ui-components/tabwidget/TabWidget.qml deleted file mode 100644 index 560ed1f58a..0000000000 --- a/examples/declarative/ui-components/tabwidget/TabWidget.qml +++ /dev/null @@ -1,102 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -Item { - id: tabWidget - - // Setting the default property to stack.children means any child items - // of the TabWidget are actually added to the 'stack' item's children. - // See the "Property Binding" - // documentation for details on default properties. - default property alias content: stack.children - - property int current: 0 - - onCurrentChanged: setOpacities() - Component.onCompleted: setOpacities() - - function setOpacities() { - for (var i = 0; i < stack.children.length; ++i) { - stack.children[i].opacity = (i == current ? 1 : 0) - } - } - - Row { - id: header - - Repeater { - model: stack.children.length - delegate: Rectangle { - width: tabWidget.width / stack.children.length; height: 36 - - Rectangle { - width: parent.width; height: 1 - anchors { bottom: parent.bottom; bottomMargin: 1 } - color: "#acb2c2" - } - BorderImage { - anchors { fill: parent; leftMargin: 2; topMargin: 5; rightMargin: 1 } - border { left: 7; right: 7 } - source: "tab.png" - visible: tabWidget.current == index - } - Text { - horizontalAlignment: Qt.AlignHCenter; verticalAlignment: Qt.AlignVCenter - anchors.fill: parent - text: stack.children[index].title - elide: Text.ElideRight - font.bold: tabWidget.current == index - } - MouseArea { - anchors.fill: parent - onClicked: tabWidget.current = index - } - } - } - } - - Item { - id: stack - width: tabWidget.width - anchors.top: header.bottom; anchors.bottom: tabWidget.bottom - } -} diff --git a/examples/declarative/ui-components/tabwidget/main.qml b/examples/declarative/ui-components/tabwidget/main.qml deleted file mode 100644 index df99c11b7d..0000000000 --- a/examples/declarative/ui-components/tabwidget/main.qml +++ /dev/null @@ -1,99 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -TabWidget { - id: tabs - width: 640; height: 480 - - Rectangle { - property string title: "Red" - anchors.fill: parent - color: "#e3e3e3" - - Rectangle { - anchors.fill: parent; anchors.margins: 20 - color: "#ff7f7f" - Text { - width: parent.width - 20 - anchors.centerIn: parent; horizontalAlignment: Qt.AlignHCenter - text: "Roses are red" - font.pixelSize: 20 - wrapMode: Text.WordWrap - } - } - } - - Rectangle { - property string title: "Green" - anchors.fill: parent - color: "#e3e3e3" - - Rectangle { - anchors.fill: parent; anchors.margins: 20 - color: "#7fff7f" - Text { - width: parent.width - 20 - anchors.centerIn: parent; horizontalAlignment: Qt.AlignHCenter - text: "Flower stems are green" - font.pixelSize: 20 - wrapMode: Text.WordWrap - } - } - } - - Rectangle { - property string title: "Blue" - anchors.fill: parent; color: "#e3e3e3" - - Rectangle { - anchors.fill: parent; anchors.margins: 20 - color: "#7f7fff" - Text { - width: parent.width - 20 - anchors.centerIn: parent; horizontalAlignment: Qt.AlignHCenter - text: "Violets are blue" - font.pixelSize: 20 - wrapMode: Text.WordWrap - } - } - } -} diff --git a/examples/declarative/ui-components/tabwidget/tab.png b/examples/declarative/ui-components/tabwidget/tab.png deleted file mode 100644 index ad8021605f..0000000000 Binary files a/examples/declarative/ui-components/tabwidget/tab.png and /dev/null differ diff --git a/examples/declarative/ui-components/tabwidget/tabwidget.qmlproject b/examples/declarative/ui-components/tabwidget/tabwidget.qmlproject deleted file mode 100644 index e5a8bf02ca..0000000000 --- a/examples/declarative/ui-components/tabwidget/tabwidget.qmlproject +++ /dev/null @@ -1,16 +0,0 @@ -import QmlProject 1.1 - -Project { - mainFile: "main.qml" - - /* Include .qml, .js, and image files from current directory and subdirectories */ - QmlFiles { - directory: "." - } - JavaScriptFiles { - directory: "." - } - ImageFiles { - directory: "." - } -} diff --git a/examples/declarative/window/Window.qml b/examples/declarative/window/Window.qml deleted file mode 100644 index 48478458c6..0000000000 --- a/examples/declarative/window/Window.qml +++ /dev/null @@ -1,58 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 -import QtQuick.Window 2.0 as Window - -Window.Window { - width: 640 - height: 480 - visible: true //It's false by default - property Component self - Component.onCompleted: self = Qt.createComponent("Window.qml") - Text{ - text: "Hello World!" - anchors.centerIn: parent - } - MouseArea{ - anchors.fill: parent - onClicked: self.createObject(); - } -} diff --git a/examples/declarative/window/screen/screenInfo.qml b/examples/declarative/window/screen/screenInfo.qml deleted file mode 100644 index 54299ba4e0..0000000000 --- a/examples/declarative/window/screen/screenInfo.qml +++ /dev/null @@ -1,90 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 -import QtQuick.Window 2.0 as Window - -Item { - id: root - width: 400 - height: 200 - Item { - id: main - state: "orientation " + Window.Screen.orientation - - property bool landscapeWindow: Window.Screen.primaryOrientation == Qt.LandscapeOrientation - property real baseWidth: landscapeWindow ? root.height : root.width - property real baseHeight: landscapeWindow ? root.width : root.height - property real rotationDelta: landscapeWindow ? -90 : 0 - - rotation: rotationDelta - width: main.baseWidth - height: main.baseHeight - anchors.centerIn: parent - - Text { - text: "Screen is " + Window.Screen.width + "x" + Window.Screen.height + " and primarily orientation " + Window.Screen.primaryOrientation - anchors.centerIn:parent - } - - - states: [ - State { - name: "orientation " + Qt.LandscapeOrientation - PropertyChanges { target: main; rotation: 90 + rotationDelta; width: main.baseHeight; height: main.baseWidth } - }, - State { - name: "orientation " + Qt.InvertedPortraitOrientation - PropertyChanges { target: main; rotation: 180 + rotationDelta; } - }, - State { - name: "orientation " + Qt.InvertedLandscapeOrientation - PropertyChanges { target: main; rotation: 270 + rotationDelta; width: main.baseHeight; height: main.baseWidth } - } - ] - - transitions: Transition { - SequentialAnimation { - RotationAnimation { direction: RotationAnimation.Shortest; duration: 300; easing.type: Easing.InOutQuint } - NumberAnimation { properties: "x,y,width,height"; duration: 300; easing.type: Easing.InOutQuint } - } - } - } -} diff --git a/examples/declarative/window/standalone.qml b/examples/declarative/window/standalone.qml deleted file mode 100644 index 335cf7b635..0000000000 --- a/examples/declarative/window/standalone.qml +++ /dev/null @@ -1,71 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 -import QtQuick.Window 2.0 as Window - -Item { - width: 640 - height: 480 - Text { - anchors.centerIn: parent - text: "First Window" - } - MouseArea { - anchors.fill: parent - onClicked: Qt.quit() - } - Window.Window { - width: 640 - height: 480 - x: 640 - y: 480 - visible: true - color: "green" - Text { - anchors.centerIn: parent - text: "Second Window" - } - MouseArea{ - anchors.fill: parent - onClicked: Qt.quit() - } - } -} diff --git a/examples/declarative/window/window.cpp b/examples/declarative/window/window.cpp deleted file mode 100644 index 4854256190..0000000000 --- a/examples/declarative/window/window.cpp +++ /dev/null @@ -1,58 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include -#include -#include -#include -#include - -int main(int argc, char* argv[]) -{ - QGuiApplication app(argc, argv); - QDeclarativeEngine engine; - QDeclarativeComponent component(&engine); - component.loadUrl(QUrl::fromLocalFile("Window.qml")); - if ( component.isReady() ) - component.create(); - else - qWarning() << component.errorString(); - return app.exec(); -} diff --git a/examples/declarative/window/window.pro b/examples/declarative/window/window.pro deleted file mode 100644 index 74804bd776..0000000000 --- a/examples/declarative/window/window.pro +++ /dev/null @@ -1,5 +0,0 @@ -TEMPLATE = app -CONFIG += qt -QT += declarative - -SOURCES += window.cpp diff --git a/examples/declarative/xml/xmlhttprequest/data.xml b/examples/declarative/xml/xmlhttprequest/data.xml deleted file mode 100644 index 8b7f1e116d..0000000000 --- a/examples/declarative/xml/xmlhttprequest/data.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - - - diff --git a/examples/declarative/xml/xmlhttprequest/xmlhttprequest-example.qml b/examples/declarative/xml/xmlhttprequest/xmlhttprequest-example.qml deleted file mode 100644 index 28ba078160..0000000000 --- a/examples/declarative/xml/xmlhttprequest/xmlhttprequest-example.qml +++ /dev/null @@ -1,95 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -Rectangle { - width: 350; height: 400 - - function showRequestInfo(text) { - log.text = log.text + "\n" + text - console.log(text) - } - - Text { id: log; anchors.fill: parent; anchors.margins: 10 } - - Rectangle { - id: button - anchors.horizontalCenter: parent.horizontalCenter; anchors.bottom: parent.bottom; anchors.margins: 10 - width: buttonText.width + 10; height: buttonText.height + 10 - border.width: mouseArea.pressed ? 2 : 1 - radius : 5; smooth: true - - Text { id: buttonText; anchors.centerIn: parent; text: "Request data.xml" } - - MouseArea { - id: mouseArea - anchors.fill: parent - onClicked: { - log.text = "" - console.log("\n") - - var doc = new XMLHttpRequest(); - doc.onreadystatechange = function() { - if (doc.readyState == XMLHttpRequest.HEADERS_RECEIVED) { - showRequestInfo("Headers -->"); - showRequestInfo(doc.getAllResponseHeaders ()); - showRequestInfo("Last modified -->"); - showRequestInfo(doc.getResponseHeader ("Last-Modified")); - - } else if (doc.readyState == XMLHttpRequest.DONE) { - var a = doc.responseXML.documentElement; - for (var ii = 0; ii < a.childNodes.length; ++ii) { - showRequestInfo(a.childNodes[ii].nodeName); - } - showRequestInfo("Headers -->"); - showRequestInfo(doc.getAllResponseHeaders ()); - showRequestInfo("Last modified -->"); - showRequestInfo(doc.getResponseHeader ("Last-Modified")); - } - } - - doc.open("GET", "data.xml"); - doc.send(); - } - } - } -} - diff --git a/examples/embedded/qmlcalculator/deployment.pri b/examples/embedded/qmlcalculator/deployment.pri index a3627b8fa2..4286bb6e24 100644 --- a/examples/embedded/qmlcalculator/deployment.pri +++ b/examples/embedded/qmlcalculator/deployment.pri @@ -1,4 +1,4 @@ -qmlcalculator_src = $$PWD/../../declarative/calculator +qmlcalculator_src = $$PWD/../../qml/calculator qmlcalculator_files.files = $$qmlcalculator_src/calculator.qml $$qmlcalculator_src/Core DEPLOYMENT += qmlcalculator_files diff --git a/examples/embedded/qmlcalculator/qmlcalculator.cpp b/examples/embedded/qmlcalculator/qmlcalculator.cpp index 4be7bc462d..17bf0f14f2 100644 --- a/examples/embedded/qmlcalculator/qmlcalculator.cpp +++ b/examples/embedded/qmlcalculator/qmlcalculator.cpp @@ -41,17 +41,17 @@ #include #include -#include -#include +#include +#include int main(int argc, char *argv[]) { QApplication application(argc, argv); const QString mainQmlApp = QLatin1String("calculator.qml"); - QDeclarativeView view; + QQuickView view; view.setSource(QUrl(mainQmlApp)); - view.setResizeMode(QDeclarativeView::SizeRootObjectToView); + view.setResizeMode(QQuickView::SizeRootObjectToView); QObject::connect(view.engine(), SIGNAL(quit()), &application, SLOT(quit())); #if defined(QT_KEYPAD_NAVIGATION) diff --git a/examples/embedded/qmlcalculator/qmlcalculator.pro b/examples/embedded/qmlcalculator/qmlcalculator.pro index 25c16ca78a..4ebf2d5972 100644 --- a/examples/embedded/qmlcalculator/qmlcalculator.pro +++ b/examples/embedded/qmlcalculator/qmlcalculator.pro @@ -1,5 +1,5 @@ !wince*:warning("DEPLOYMENT support required. This project only works on WinCE.") -QT += declarative +QT += qml SOURCES += $$PWD/qmlcalculator.cpp include($$PWD/deployment.pri) diff --git a/examples/embedded/qmlclocks/deployment.pri b/examples/embedded/qmlclocks/deployment.pri index 771a4dba76..75b39ac48f 100644 --- a/examples/embedded/qmlclocks/deployment.pri +++ b/examples/embedded/qmlclocks/deployment.pri @@ -1,4 +1,4 @@ -qmlclocks_src = $$PWD/../../../examples/declarative/toys/clocks +qmlclocks_src = $$PWD/../../../examples/qml/toys/clocks qmlclocks_files.files = $$qmlclocks_src/clocks.qml $$qmlclocks_src/content DEPLOYMENT += qmlclocks_files diff --git a/examples/embedded/qmlclocks/qmlclocks.cpp b/examples/embedded/qmlclocks/qmlclocks.cpp index ce42ec7b18..1f9a553944 100644 --- a/examples/embedded/qmlclocks/qmlclocks.cpp +++ b/examples/embedded/qmlclocks/qmlclocks.cpp @@ -41,17 +41,17 @@ #include #include -#include -#include +#include +#include int main(int argc, char *argv[]) { QApplication application(argc, argv); const QString mainQmlApp = QLatin1String("clocks.qml"); - QDeclarativeView view; + QQuickView view; view.setSource(QUrl(mainQmlApp)); - view.setResizeMode(QDeclarativeView::SizeRootObjectToView); + view.setResizeMode(QQuickView::SizeRootObjectToView); QObject::connect(view.engine(), SIGNAL(quit()), &application, SLOT(quit())); #if defined(QT_KEYPAD_NAVIGATION) diff --git a/examples/embedded/qmlclocks/qmlclocks.pro b/examples/embedded/qmlclocks/qmlclocks.pro index 8e9dcdf87c..43a9e31972 100644 --- a/examples/embedded/qmlclocks/qmlclocks.pro +++ b/examples/embedded/qmlclocks/qmlclocks.pro @@ -1,5 +1,5 @@ !wince*:warning("DEPLOYMENT support required. This project only works on WinCE.") -QT += declarative +QT += qml SOURCES += $$PWD/qmlclocks.cpp include($$PWD/deployment.pri) diff --git a/examples/embedded/qmldialcontrol/deployment.pri b/examples/embedded/qmldialcontrol/deployment.pri index d845120923..58c815e1e5 100644 --- a/examples/embedded/qmldialcontrol/deployment.pri +++ b/examples/embedded/qmldialcontrol/deployment.pri @@ -1,4 +1,4 @@ -qmldialcontrol_src = $$PWD/../../../examples/declarative/ui-components/dialcontrol +qmldialcontrol_src = $$PWD/../../../examples/qml/ui-components/dialcontrol qmldialcontrol_files.files = $$qmldialcontrol_src/dialcontrol.qml $$qmldialcontrol_src/content DEPLOYMENT += qmldialcontrol_files diff --git a/examples/embedded/qmldialcontrol/qmldialcontrol.cpp b/examples/embedded/qmldialcontrol/qmldialcontrol.cpp index e66f6f6c56..6f81e5f8a0 100644 --- a/examples/embedded/qmldialcontrol/qmldialcontrol.cpp +++ b/examples/embedded/qmldialcontrol/qmldialcontrol.cpp @@ -41,17 +41,17 @@ #include #include -#include -#include +#include +#include int main(int argc, char *argv[]) { QApplication application(argc, argv); const QString mainQmlApp = QLatin1String("dialcontrol.qml"); - QDeclarativeView view; + QQuickView view; view.setSource(QUrl(mainQmlApp)); - view.setResizeMode(QDeclarativeView::SizeRootObjectToView); + view.setResizeMode(QQuickView::SizeRootObjectToView); QObject::connect(view.engine(), SIGNAL(quit()), &application, SLOT(quit())); #if defined(QT_KEYPAD_NAVIGATION) diff --git a/examples/embedded/qmldialcontrol/qmldialcontrol.pro b/examples/embedded/qmldialcontrol/qmldialcontrol.pro index 08f876b926..58ed7cabb8 100644 --- a/examples/embedded/qmldialcontrol/qmldialcontrol.pro +++ b/examples/embedded/qmldialcontrol/qmldialcontrol.pro @@ -1,5 +1,5 @@ !wince*:warning("DEPLOYMENT support required. This project only works on WinCE.") -QT += declarative +QT += qml SOURCES += $$PWD/qmldialcontrol.cpp include($$PWD/deployment.pri) diff --git a/examples/embedded/qmleasing/deployment.pri b/examples/embedded/qmleasing/deployment.pri index 7a5d0401cb..427259b816 100644 --- a/examples/embedded/qmleasing/deployment.pri +++ b/examples/embedded/qmleasing/deployment.pri @@ -1,4 +1,4 @@ -qmleasing_src = $$PWD/../../../examples/declarative/animation/easing +qmleasing_src = $$PWD/../../../examples/qml/animation/easing qmleasing_files.files = $$qmleasing_src/easing.qml $$qmleasing_src/content DEPLOYMENT += qmleasing_files diff --git a/examples/embedded/qmleasing/qmleasing.cpp b/examples/embedded/qmleasing/qmleasing.cpp index 8220e03cff..d516825d9a 100644 --- a/examples/embedded/qmleasing/qmleasing.cpp +++ b/examples/embedded/qmleasing/qmleasing.cpp @@ -41,17 +41,17 @@ #include #include -#include -#include +#include +#include int main(int argc, char *argv[]) { QApplication application(argc, argv); const QString mainQmlApp = QLatin1String("easing.qml"); - QDeclarativeView view; + QQuickView view; view.setSource(QUrl(mainQmlApp)); - view.setResizeMode(QDeclarativeView::SizeRootObjectToView); + view.setResizeMode(QQuickView::SizeRootObjectToView); QObject::connect(view.engine(), SIGNAL(quit()), &application, SLOT(quit())); #if defined(QT_KEYPAD_NAVIGATION) diff --git a/examples/embedded/qmleasing/qmleasing.pro b/examples/embedded/qmleasing/qmleasing.pro index c9f008d42e..6e0383502b 100644 --- a/examples/embedded/qmleasing/qmleasing.pro +++ b/examples/embedded/qmleasing/qmleasing.pro @@ -1,5 +1,5 @@ !wince*:warning("DEPLOYMENT support required. This project only works on WinCE.") -QT += declarative +QT += qml SOURCES += $$PWD/qmleasing.cpp include($$PWD/deployment.pri) diff --git a/examples/embedded/qmlflickr/deployment.pri b/examples/embedded/qmlflickr/deployment.pri index 0d76ddc1db..7b9b62b459 100644 --- a/examples/embedded/qmlflickr/deployment.pri +++ b/examples/embedded/qmlflickr/deployment.pri @@ -1,4 +1,4 @@ -qmlflickr_src = $$PWD/../../declarative/flickr +qmlflickr_src = $$PWD/../../qml/flickr qmlflickr_files.files = $$qmlflickr_src/flickr.qml $$qmlflickr_src/common $$qmlflickr_src/mobile DEPLOYMENT += qmlflickr_files diff --git a/examples/embedded/qmlflickr/qmlflickr.cpp b/examples/embedded/qmlflickr/qmlflickr.cpp index 93b28f7cec..268542e61b 100644 --- a/examples/embedded/qmlflickr/qmlflickr.cpp +++ b/examples/embedded/qmlflickr/qmlflickr.cpp @@ -42,17 +42,17 @@ #include #include #include -#include -#include -#include +#include +#include +#include #include #include #include -#include +#include // Factory to create QNetworkAccessManagers that use the saved network configuration; otherwise // the system default. -class NetworkAccessManagerFactory : public QDeclarativeNetworkAccessManagerFactory +class NetworkAccessManagerFactory : public QQmlNetworkAccessManagerFactory { public: ~NetworkAccessManagerFactory() { } @@ -92,10 +92,10 @@ int main(int argc, char *argv[]) NetworkAccessManagerFactory networkAccessManagerFactory; const QString mainQmlApp = QLatin1String("flickr.qml"); - QDeclarativeView view; + QQuickView view; view.engine()->setNetworkAccessManagerFactory(&networkAccessManagerFactory); view.setSource(QUrl(mainQmlApp)); - view.setResizeMode(QDeclarativeView::SizeRootObjectToView); + view.setResizeMode(QQuickView::SizeRootObjectToView); QObject::connect(view.engine(), SIGNAL(quit()), &application, SLOT(quit())); view.setGeometry(QRect(100, 100, 360, 640)); view.show(); diff --git a/examples/embedded/qmlflickr/qmlflickr.pro b/examples/embedded/qmlflickr/qmlflickr.pro index 869d651b05..141c02d3fe 100644 --- a/examples/embedded/qmlflickr/qmlflickr.pro +++ b/examples/embedded/qmlflickr/qmlflickr.pro @@ -1,5 +1,5 @@ !wince*:warning("DEPLOYMENT support required. This project only works on WinCE.") -QT += declarative network +QT += qml network SOURCES += $$PWD/qmlflickr.cpp include($$PWD/deployment.pri) diff --git a/examples/embedded/qmlphotoviewer/deployment.pri b/examples/embedded/qmlphotoviewer/deployment.pri index 504373914a..ea9a052b4b 100644 --- a/examples/embedded/qmlphotoviewer/deployment.pri +++ b/examples/embedded/qmlphotoviewer/deployment.pri @@ -1,4 +1,4 @@ -qmlphotoviewer_src = $$PWD/../../declarative/photoviewer +qmlphotoviewer_src = $$PWD/../../qml/photoviewer qmlphotoviewer_files.files = $$qmlphotoviewer_src/photoviewer.qml $$qmlphotoviewer_src/PhotoViewerCore DEPLOYMENT += qmlphotoviewer_files diff --git a/examples/embedded/qmlphotoviewer/qmlphotoviewer.cpp b/examples/embedded/qmlphotoviewer/qmlphotoviewer.cpp index 32c9d24eaa..18bf1ae094 100644 --- a/examples/embedded/qmlphotoviewer/qmlphotoviewer.cpp +++ b/examples/embedded/qmlphotoviewer/qmlphotoviewer.cpp @@ -42,16 +42,16 @@ #include #include #include -#include -#include -#include +#include +#include +#include #include #include #include // Factory to create QNetworkAccessManagers that use the saved network configuration; otherwise // the system default. -class NetworkAccessManagerFactory : public QDeclarativeNetworkAccessManagerFactory +class NetworkAccessManagerFactory : public QQmlNetworkAccessManagerFactory { public: ~NetworkAccessManagerFactory() { } @@ -91,10 +91,10 @@ int main(int argc, char *argv[]) NetworkAccessManagerFactory networkAccessManagerFactory; const QString mainQmlApp = QLatin1String("photoviewer.qml"); - QDeclarativeView view; + QQuickView view; view.engine()->setNetworkAccessManagerFactory(&networkAccessManagerFactory); view.setSource(QUrl(mainQmlApp)); - view.setResizeMode(QDeclarativeView::SizeRootObjectToView); + view.setResizeMode(QQuickView::SizeRootObjectToView); QObject::connect(view.engine(), SIGNAL(quit()), &application, SLOT(quit())); view.setGeometry(QRect(100, 100, 360, 640)); diff --git a/examples/embedded/qmlphotoviewer/qmlphotoviewer.pro b/examples/embedded/qmlphotoviewer/qmlphotoviewer.pro index 9941b2e226..1c0301118e 100644 --- a/examples/embedded/qmlphotoviewer/qmlphotoviewer.pro +++ b/examples/embedded/qmlphotoviewer/qmlphotoviewer.pro @@ -1,5 +1,5 @@ !wince*:warning("DEPLOYMENT support required. This project only works on WinCE.") -QT += declarative network +QT += qml network SOURCES += $$PWD/qmlphotoviewer.cpp include($$PWD/deployment.pri) diff --git a/examples/embedded/qmltwitter/deployment.pri b/examples/embedded/qmltwitter/deployment.pri index a3c045ca54..2f3066bc72 100644 --- a/examples/embedded/qmltwitter/deployment.pri +++ b/examples/embedded/qmltwitter/deployment.pri @@ -1,4 +1,4 @@ -qmltwitter_src = $$PWD/../../declarative/twitter +qmltwitter_src = $$PWD/../../qml/twitter qmltwitter_files.files = $$qmltwitter_src/twitter.qml $$qmltwitter_src/TwitterCore DEPLOYMENT += qmltwitter_files diff --git a/examples/embedded/qmltwitter/qmltwitter.cpp b/examples/embedded/qmltwitter/qmltwitter.cpp index 19b187bc82..a3a5c40f34 100644 --- a/examples/embedded/qmltwitter/qmltwitter.cpp +++ b/examples/embedded/qmltwitter/qmltwitter.cpp @@ -42,16 +42,16 @@ #include #include #include -#include -#include -#include +#include +#include +#include #include #include #include // Factory to create QNetworkAccessManagers that use the saved network configuration; otherwise // the system default. -class NetworkAccessManagerFactory : public QDeclarativeNetworkAccessManagerFactory +class NetworkAccessManagerFactory : public QQmlNetworkAccessManagerFactory { public: ~NetworkAccessManagerFactory() { } @@ -91,10 +91,10 @@ int main(int argc, char *argv[]) NetworkAccessManagerFactory networkAccessManagerFactory; const QString mainQmlApp = QLatin1String("twitter.qml"); - QDeclarativeView view; + QQuickView view; view.engine()->setNetworkAccessManagerFactory(&networkAccessManagerFactory); view.setSource(QUrl(mainQmlApp)); - view.setResizeMode(QDeclarativeView::SizeRootObjectToView); + view.setResizeMode(QQuickView::SizeRootObjectToView); QObject::connect(view.engine(), SIGNAL(quit()), &application, SLOT(quit())); view.setGeometry(QRect(100, 100, 360, 640)); view.show(); diff --git a/examples/embedded/qmltwitter/qmltwitter.pro b/examples/embedded/qmltwitter/qmltwitter.pro index ce40cd7489..eca46f9f97 100644 --- a/examples/embedded/qmltwitter/qmltwitter.pro +++ b/examples/embedded/qmltwitter/qmltwitter.pro @@ -1,5 +1,5 @@ !wince*:warning("DEPLOYMENT support required. This project only works on WinCE.") -QT += declarative network +QT += qml network SOURCES += $$PWD/qmltwitter.cpp include($$PWD/deployment.pri) diff --git a/examples/examples.pro b/examples/examples.pro index 2c9497dde0..3e5c4d08a5 100644 --- a/examples/examples.pro +++ b/examples/examples.pro @@ -1,3 +1,3 @@ TEMPLATE = subdirs -SUBDIRS += declarative tutorials +SUBDIRS += qml tutorials contains(QT_CONFIG, qmltest): SUBDIRS += qmltest diff --git a/examples/qml/README b/examples/qml/README new file mode 100644 index 0000000000..56c48d71fb --- /dev/null +++ b/examples/qml/README @@ -0,0 +1,13 @@ +The Qt Declarative module provides the ability to specify and implement +your user interface declaratively, using the Qt Meta-Object Language (QML). This +language is very expressive and human readable, and can be used by +designers to actually implement their UI vision. QML UIs can integrate +with C++ code in many ways, including being loaded as a part of a C++ UI +and loading data models from C++ and interacting with them. + +Mostof these examples can be viewed directly with the +QML viewer utility, without requiring compilation. + + +Documentation for these examples can be found via the Examples +link in the main Qt documentation. diff --git a/examples/qml/accessibility/accessibility.qml b/examples/qml/accessibility/accessibility.qml new file mode 100644 index 0000000000..e0152f065b --- /dev/null +++ b/examples/qml/accessibility/accessibility.qml @@ -0,0 +1,105 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtQml module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import QtQuick.Window 2.0 +import "widgets" + +Rectangle { + id: window + + width: 360; height: 300 + color: "white" + + Column { + id: column + spacing: 6 + anchors.fill: parent + width: parent.width + Row { + spacing: 6 + width: column.width + Button { width: 100; height: column.h + 20; text: "Send" } + Button { width: 100; height: column.h + 20; text: "Discard" } + } + + Row { + spacing: 6 + width: column.width + height: column.h + Text { + id: subjectLabel + Accessible.role: Accessible.StaticText + Accessible.name: text + text: "Subject:" + width: 50 + } + Rectangle { + id: subjectBorder + Accessible.role: Accessible.EditableText + Accessible.name: subjectEdit.text + border.width: 1 + border.color: "black" + height: subjectEdit.height + width: 304 + TextInput { + id: subjectEdit + text: "Vacation plans" + } + } + } + Rectangle { + id: textBorder + Accessible.role: Accessible.EditableText + property alias text : textEdit.text + border.width: 1 + border.color: "black" + width: parent.width + height: textEdit.height + TextEdit { + id: textEdit + text: "Hi, we're going to the Dolomites this summer. Weren't you also going to northern Italy? \n\nbest wishes, your friend Luke" + width: parent.width + wrapMode: TextEdit.WordWrap + } + } + } +} diff --git a/examples/qml/accessibility/widgets/Button.qml b/examples/qml/accessibility/widgets/Button.qml new file mode 100644 index 0000000000..793f895c57 --- /dev/null +++ b/examples/qml/accessibility/widgets/Button.qml @@ -0,0 +1,79 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtQml module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Rectangle { + id: button + + property alias text : buttonText.text + Accessible.name: text + Accessible.description: "This button does " + text + Accessible.role: Accessible.Button + + signal clicked + + width: buttonText.width + 20 + height: 30 + gradient: Gradient { + GradientStop { position: 0.0; color: "lightsteelblue" } + GradientStop { position: 1.0; color: "blue" } + } + border.width: 2 + border.color: "black"; + radius: 10 + + Text { + id: buttonText + text: parent.description + anchors.centerIn: parent + font.pixelSize: parent.height * .5 + style: Text.Sunken; color: "white"; styleColor: "black"; smooth: true + } + + MouseArea { + id: mouseArea + anchors.fill: parent + onClicked: { + checked = !checked; + } + } +} diff --git a/examples/qml/animation/animation.qml b/examples/qml/animation/animation.qml new file mode 100644 index 0000000000..7c5829e790 --- /dev/null +++ b/examples/qml/animation/animation.qml @@ -0,0 +1,62 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import "../shared" + +Item { + height: 480 + width: 320 + LauncherList { + id: ll + anchors.fill: parent + Component.onCompleted: { + addExample("ColorAnimation", "Interpolates between colors", Qt.resolvedUrl("basics/color-animation.qml")); + addExample("PropertyAnimation", "Interpolates between numbers", Qt.resolvedUrl("basics/property-animation.qml")); + addExample("Behaviors", "Animates procedural movement", Qt.resolvedUrl("behaviors/behavior-example.qml")); + addExample("WigglyText", "Text that wiggles as you drag it", Qt.resolvedUrl("behaviors/wigglytext.qml")); + addExample("Easing Curves", "Compare available easing curves", Qt.resolvedUrl("easing/easing.qml")); + addExample("States", "Simple states", Qt.resolvedUrl("states/states.qml")); + addExample("Transitions", "Simple states with animated transitions", Qt.resolvedUrl("states/transitions.qml")); + addExample("PathAnimation", "Animate along a path", Qt.resolvedUrl("pathanimation/pathanimation.qml")); + addExample("PathInterpolator", "Interpolates along a path", Qt.resolvedUrl("pathinterpolator/pathinterpolator.qml")); + } + } +} diff --git a/examples/qml/animation/animation.qmlproject b/examples/qml/animation/animation.qmlproject new file mode 100644 index 0000000000..2e96daa881 --- /dev/null +++ b/examples/qml/animation/animation.qmlproject @@ -0,0 +1,16 @@ +import QmlProject 1.1 + +Project { + mainFile: "animation.qml" + + /* Include .qml, .js, and image files from current directory and subdirectories */ + QmlFiles { + directory: "." + } + JavaScriptFiles { + directory: "." + } + ImageFiles { + directory: "." + } +} diff --git a/examples/qml/animation/basics/color-animation.qml b/examples/qml/animation/basics/color-animation.qml new file mode 100644 index 0000000000..a54091d7dd --- /dev/null +++ b/examples/qml/animation/basics/color-animation.qml @@ -0,0 +1,121 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import QtQuick.Particles 2.0 + +Item { + id: window + width: 640; height: 480 + + // Let's draw the sky... + Rectangle { + anchors { left: parent.left; top: parent.top; right: parent.right; bottom: parent.verticalCenter } + gradient: Gradient { + GradientStop { + position: 0.0 + SequentialAnimation on color { + loops: Animation.Infinite + ColorAnimation { from: "DeepSkyBlue"; to: "#0E1533"; duration: 5000 } + ColorAnimation { from: "#0E1533"; to: "DeepSkyBlue"; duration: 5000 } + } + } + GradientStop { + position: 1.0 + SequentialAnimation on color { + loops: Animation.Infinite + ColorAnimation { from: "SkyBlue"; to: "#437284"; duration: 5000 } + ColorAnimation { from: "#437284"; to: "SkyBlue"; duration: 5000 } + } + } + } + } + + // the sun, moon, and stars + Item { + width: parent.width; height: 2 * parent.height + NumberAnimation on rotation { from: 0; to: 360; duration: 10000; loops: Animation.Infinite } + Image { + source: "images/sun.png"; y: 10; anchors.horizontalCenter: parent.horizontalCenter + rotation: -3 * parent.rotation + } + Image { + source: "images/moon.png"; y: parent.height - 74; anchors.horizontalCenter: parent.horizontalCenter + rotation: -parent.rotation + } + ParticleSystem { + id: particlesystem + x: 0; y: parent.height/2 + width: parent.width; height: parent.height/2 + ImageParticle { + source: "images/star.png" + groups: ["star"] + color: "#00333333" + SequentialAnimation on opacity { + loops: Animation.Infinite + NumberAnimation { from: 0; to: 1; duration: 5000 } + NumberAnimation { from: 1; to: 0; duration: 5000 } + } + } + Emitter { + group: "star" + anchors.fill: parent + emitRate: parent.width / 50 + lifeSpan: 5000 + } + } + } + + // ...and the ground. + Rectangle { + anchors { left: parent.left; top: parent.verticalCenter; right: parent.right; bottom: parent.bottom } + gradient: Gradient { + GradientStop { + position: 0.0 + SequentialAnimation on color { + loops: Animation.Infinite + ColorAnimation { from: "ForestGreen"; to: "#001600"; duration: 5000 } + ColorAnimation { from: "#001600"; to: "ForestGreen"; duration: 5000 } + } + } + GradientStop { position: 1.0; color: "DarkGreen" } + } + } +} diff --git a/examples/qml/animation/basics/images/face-smile.png b/examples/qml/animation/basics/images/face-smile.png new file mode 100644 index 0000000000..3d66d72578 Binary files /dev/null and b/examples/qml/animation/basics/images/face-smile.png differ diff --git a/examples/qml/animation/basics/images/moon.png b/examples/qml/animation/basics/images/moon.png new file mode 100644 index 0000000000..9407b2b4f0 Binary files /dev/null and b/examples/qml/animation/basics/images/moon.png differ diff --git a/examples/qml/animation/basics/images/shadow.png b/examples/qml/animation/basics/images/shadow.png new file mode 100644 index 0000000000..8270565e87 Binary files /dev/null and b/examples/qml/animation/basics/images/shadow.png differ diff --git a/examples/qml/animation/basics/images/star.png b/examples/qml/animation/basics/images/star.png new file mode 100644 index 0000000000..27ef924267 Binary files /dev/null and b/examples/qml/animation/basics/images/star.png differ diff --git a/examples/qml/animation/basics/images/sun.png b/examples/qml/animation/basics/images/sun.png new file mode 100644 index 0000000000..7713ca5ce7 Binary files /dev/null and b/examples/qml/animation/basics/images/sun.png differ diff --git a/examples/qml/animation/basics/property-animation.qml b/examples/qml/animation/basics/property-animation.qml new file mode 100644 index 0000000000..4a4d3e3b2a --- /dev/null +++ b/examples/qml/animation/basics/property-animation.qml @@ -0,0 +1,105 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Item { + id: window + width: 320; height: 480 + + // Let's draw the sky... + Rectangle { + anchors { left: parent.left; top: parent.top; right: parent.right; bottom: parent.verticalCenter } + gradient: Gradient { + GradientStop { position: 0.0; color: "DeepSkyBlue" } + GradientStop { position: 1.0; color: "LightSkyBlue" } + } + } + + // ...and the ground. + Rectangle { + anchors { left: parent.left; top: parent.verticalCenter; right: parent.right; bottom: parent.bottom } + gradient: Gradient { + GradientStop { position: 0.0; color: "ForestGreen" } + GradientStop { position: 1.0; color: "DarkGreen" } + } + } + + // The shadow for the smiley face + Image { + anchors.horizontalCenter: parent.horizontalCenter + y: smiley.minHeight + 58 + source: "images/shadow.png" + + // The scale property depends on the y position of the smiley face. + scale: smiley.y * 0.5 / (smiley.minHeight - smiley.maxHeight) + } + + Image { + id: smiley + property int maxHeight: window.height / 3 + property int minHeight: 2 * window.height / 3 + + anchors.horizontalCenter: parent.horizontalCenter + y: minHeight + source: "images/face-smile.png" + + // Animate the y property. Setting loops to Animation.Infinite makes the + // animation repeat indefinitely, otherwise it would only run once. + SequentialAnimation on y { + loops: Animation.Infinite + + // Move from minHeight to maxHeight in 300ms, using the OutExpo easing function + NumberAnimation { + from: smiley.minHeight; to: smiley.maxHeight + easing.type: Easing.OutExpo; duration: 300 + } + + // Then move back to minHeight in 1 second, using the OutBounce easing function + NumberAnimation { + from: smiley.maxHeight; to: smiley.minHeight + easing.type: Easing.OutBounce; duration: 1000 + } + + // Then pause for 500ms + PauseAnimation { duration: 500 } + } + } +} diff --git a/examples/qml/animation/behaviors/SideRect.qml b/examples/qml/animation/behaviors/SideRect.qml new file mode 100644 index 0000000000..623c6965d8 --- /dev/null +++ b/examples/qml/animation/behaviors/SideRect.qml @@ -0,0 +1,62 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Rectangle { + id: myRect + + property string text + + width: 75; height: 50 + radius: 6 + color: "#646464" + border.width: 4; border.color: "white" + + MouseArea { + anchors.fill: parent + hoverEnabled: true + onEntered: { + focusRect.x = myRect.x; + focusRect.y = myRect.y; + focusRect.text = myRect.text; + } + } +} diff --git a/examples/qml/animation/behaviors/behavior-example.qml b/examples/qml/animation/behaviors/behavior-example.qml new file mode 100644 index 0000000000..89fc9992b6 --- /dev/null +++ b/examples/qml/animation/behaviors/behavior-example.qml @@ -0,0 +1,118 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Rectangle { + width: 600; height: 400 + color: "#343434" + + Rectangle { + anchors.centerIn: parent + width: 200; height: 200 + radius: 30 + color: "transparent" + border.width: 4; border.color: "white" + + + SideRect { + id: leftRect + anchors { verticalCenter: parent.verticalCenter; horizontalCenter: parent.left } + text: "Left" + } + + SideRect { + id: rightRect + anchors { verticalCenter: parent.verticalCenter; horizontalCenter: parent.right } + text: "Right" + } + + SideRect { + id: topRect + anchors { verticalCenter: parent.top; horizontalCenter: parent.horizontalCenter } + text: "Top" + } + + SideRect { + id: bottomRect + anchors { verticalCenter: parent.bottom; horizontalCenter: parent.horizontalCenter } + text: "Bottom" + } + + + Rectangle { + id: focusRect + + property string text + + x: 62; y: 75; width: 75; height: 50 + radius: 6 + border.width: 4; border.color: "white" + color: "firebrick" + + // Set an 'elastic' behavior on the focusRect's x property. + Behavior on x { + NumberAnimation { easing.type: Easing.OutElastic; easing.amplitude: 3.0; easing.period: 2.0; duration: 300 } + } + + // Set an 'elastic' behavior on the focusRect's y property. + Behavior on y { + NumberAnimation { easing.type: Easing.OutElastic; easing.amplitude: 3.0; easing.period: 2.0; duration: 300 } + } + + Text { + id: focusText + text: focusRect.text + anchors.centerIn: parent + color: "white" + font.pixelSize: 16; font.bold: true + + // Set a behavior on the focusText's x property: + // Set the opacity to 0, set the new text value, then set the opacity back to 1. + Behavior on text { + SequentialAnimation { + NumberAnimation { target: focusText; property: "opacity"; to: 0; duration: 150 } + NumberAnimation { target: focusText; property: "opacity"; to: 1; duration: 150 } + } + } + } + } + } +} diff --git a/examples/qml/animation/behaviors/wigglytext.qml b/examples/qml/animation/behaviors/wigglytext.qml new file mode 100644 index 0000000000..e2ed472088 --- /dev/null +++ b/examples/qml/animation/behaviors/wigglytext.qml @@ -0,0 +1,108 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Rectangle { + id: container + + property string text: "Drag this text..." + property bool animated: true + + width: 640; height: 480; color: "#474747"; focus: true + + Keys.onPressed: { + if (event.key == Qt.Key_Delete || event.key == Qt.Key_Backspace) + container.remove() + else if (event.text != "") { + container.append(event.text) + } + } + + function append(text) { + container.animated = false + var lastLetter = container.children[container.children.length - 1] + var newLetter = letterComponent.createObject(container) + newLetter.text = text + newLetter.follow = lastLetter + container.animated = true + } + + function remove() { + if (container.children.length) + container.children[container.children.length - 1].destroy() + } + + function doLayout() { + var follow = null + for (var i = 0; i < container.text.length; ++i) { + var newLetter = letterComponent.createObject(container) + newLetter.text = container.text[i] + newLetter.follow = follow + follow = newLetter + } + } + + Component { + id: letterComponent + Text { + id: letter + property variant follow + + x: follow ? follow.x + follow.width : container.width / 3 + y: follow ? follow.y : container.height / 2 + + font.pixelSize: 40; font.bold: true + color: "#999999"; styleColor: "#222222"; style: Text.Raised + + MouseArea { + anchors.fill: parent + drag.target: letter; drag.axis: Drag.XandYAxis + onPressed: letter.color = "#dddddd" + onReleased: letter.color = "#999999" + } + + Behavior on x { enabled: container.animated; SpringAnimation { spring: 3; damping: 0.3; mass: 1.0 } } + Behavior on y { enabled: container.animated; SpringAnimation { spring: 3; damping: 0.3; mass: 1.0 } } + } + } + + Component.onCompleted: doLayout() +} diff --git a/examples/qml/animation/easing/content/QuitButton.qml b/examples/qml/animation/easing/content/QuitButton.qml new file mode 100644 index 0000000000..702b892d23 --- /dev/null +++ b/examples/qml/animation/easing/content/QuitButton.qml @@ -0,0 +1,52 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +Image { + source: "quit.png" + scale: quitMouse.pressed ? 0.8 : 1.0 + smooth: quitMouse.pressed + MouseArea { + id: quitMouse + anchors.fill: parent + anchors.margins: -10 + onClicked: Qt.quit() + } +} diff --git a/examples/qml/animation/easing/content/quit.png b/examples/qml/animation/easing/content/quit.png new file mode 100644 index 0000000000..b822057d4e Binary files /dev/null and b/examples/qml/animation/easing/content/quit.png differ diff --git a/examples/qml/animation/easing/easing.qml b/examples/qml/animation/easing/easing.qml new file mode 100644 index 0000000000..207b653d6e --- /dev/null +++ b/examples/qml/animation/easing/easing.qml @@ -0,0 +1,170 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import "content" + +Rectangle { + id: window + width: 600; height: 460; color: "#232323" + + property var easingCurve: [ 0.2, 0.2, 0.13, 0.65, 0.2, 0.8, + 0.624, 0.98, 0.93, 0.95, 1, 1 ] + + ListModel { + id: easingTypes + ListElement { name: "Easing.Linear"; type: Easing.Linear; ballColor: "DarkRed" } + ListElement { name: "Easing.InQuad"; type: Easing.InQuad; ballColor: "IndianRed" } + ListElement { name: "Easing.OutQuad"; type: Easing.OutQuad; ballColor: "Salmon" } + ListElement { name: "Easing.InOutQuad"; type: Easing.InOutQuad; ballColor: "Tomato" } + ListElement { name: "Easing.OutInQuad"; type: Easing.OutInQuad; ballColor: "DarkOrange" } + ListElement { name: "Easing.InCubic"; type: Easing.InCubic; ballColor: "Gold" } + ListElement { name: "Easing.OutCubic"; type: Easing.OutCubic; ballColor: "Yellow" } + ListElement { name: "Easing.InOutCubic"; type: Easing.InOutCubic; ballColor: "PeachPuff" } + ListElement { name: "Easing.OutInCubic"; type: Easing.OutInCubic; ballColor: "Thistle" } + ListElement { name: "Easing.InQuart"; type: Easing.InQuart; ballColor: "Orchid" } + ListElement { name: "Easing.OutQuart"; type: Easing.OutQuart; ballColor: "Purple" } + ListElement { name: "Easing.InOutQuart"; type: Easing.InOutQuart; ballColor: "SlateBlue" } + ListElement { name: "Easing.OutInQuart"; type: Easing.OutInQuart; ballColor: "Chartreuse" } + ListElement { name: "Easing.InQuint"; type: Easing.InQuint; ballColor: "LimeGreen" } + ListElement { name: "Easing.OutQuint"; type: Easing.OutQuint; ballColor: "SeaGreen" } + ListElement { name: "Easing.InOutQuint"; type: Easing.InOutQuint; ballColor: "DarkGreen" } + ListElement { name: "Easing.OutInQuint"; type: Easing.OutInQuint; ballColor: "Olive" } + ListElement { name: "Easing.InSine"; type: Easing.InSine; ballColor: "DarkSeaGreen" } + ListElement { name: "Easing.OutSine"; type: Easing.OutSine; ballColor: "Teal" } + ListElement { name: "Easing.InOutSine"; type: Easing.InOutSine; ballColor: "Turquoise" } + ListElement { name: "Easing.OutInSine"; type: Easing.OutInSine; ballColor: "SteelBlue" } + ListElement { name: "Easing.InExpo"; type: Easing.InExpo; ballColor: "SkyBlue" } + ListElement { name: "Easing.OutExpo"; type: Easing.OutExpo; ballColor: "RoyalBlue" } + ListElement { name: "Easing.InOutExpo"; type: Easing.InOutExpo; ballColor: "MediumBlue" } + ListElement { name: "Easing.OutInExpo"; type: Easing.OutInExpo; ballColor: "MidnightBlue" } + ListElement { name: "Easing.InCirc"; type: Easing.InCirc; ballColor: "CornSilk" } + ListElement { name: "Easing.OutCirc"; type: Easing.OutCirc; ballColor: "Bisque" } + ListElement { name: "Easing.InOutCirc"; type: Easing.InOutCirc; ballColor: "RosyBrown" } + ListElement { name: "Easing.OutInCirc"; type: Easing.OutInCirc; ballColor: "SandyBrown" } + ListElement { name: "Easing.InElastic"; type: Easing.InElastic; ballColor: "DarkGoldenRod" } + ListElement { name: "Easing.OutElastic"; type: Easing.OutElastic; ballColor: "Chocolate" } + ListElement { name: "Easing.InOutElastic"; type: Easing.InOutElastic; ballColor: "SaddleBrown" } + ListElement { name: "Easing.OutInElastic"; type: Easing.OutInElastic; ballColor: "Brown" } + ListElement { name: "Easing.InBack"; type: Easing.InBack; ballColor: "Maroon" } + ListElement { name: "Easing.OutBack"; type: Easing.OutBack; ballColor: "LavenderBlush" } + ListElement { name: "Easing.InOutBack"; type: Easing.InOutBack; ballColor: "MistyRose" } + ListElement { name: "Easing.OutInBack"; type: Easing.OutInBack; ballColor: "Gainsboro" } + ListElement { name: "Easing.OutBounce"; type: Easing.OutBounce; ballColor: "Silver" } + ListElement { name: "Easing.InBounce"; type: Easing.InBounce; ballColor: "DimGray" } + ListElement { name: "Easing.InOutBounce"; type: Easing.InOutBounce; ballColor: "SlateGray" } + ListElement { name: "Easing.OutInBounce"; type: Easing.OutInBounce; ballColor: "DarkSlateGray" } + ListElement { name: "Easing.Bezier"; type: Easing.Bezier; ballColor: "Chartreuse"; } + } + + Component { + id: delegate + + Item { + height: 56; width: window.width + + Text { text: name; anchors.centerIn: parent; color: "White" } + + Rectangle { + id: slot1; color: "#121212"; x: 30; height: 46; width: 46 + border.color: "#343434"; border.width: 1; radius: 12 + anchors.verticalCenter: parent.verticalCenter + } + + Rectangle { + id: slot2; color: "#121212"; x: window.width - 76; height: 46; width: 46 + border.color: "#343434"; border.width: 1; radius: 12 + anchors.verticalCenter: parent.verticalCenter + } + + Rectangle { + id: rect; x: 30; color: "#454545" + border.color: "White"; border.width: 2 + height: 46; width: 46; radius: 12 + anchors.verticalCenter: parent.verticalCenter + + MouseArea { + onClicked: if (rect.state == '') rect.state = "right"; else rect.state = '' + anchors.fill: parent + anchors.margins: -5 // Make MouseArea bigger than the rectangle, itself + } + + states : State { + name: "right" + PropertyChanges { target: rect; x: window.width - 76; color: ballColor } + } + + transitions: Transition { + NumberAnimation { properties: "x"; easing.type: type; easing.bezierCurve: getBezierCurve(name); duration: 1000 } + ColorAnimation { properties: "color"; easing.type: type; easing.bezierCurve: getBezierCurve(name); duration: 1000 } + } + } + } + } + + Flickable { + anchors.fill: parent + contentHeight: layout.height+50 + Rectangle { + id: titlePane + color: "#444444" + height: 35 + anchors { top: parent.top; left: parent.left; right: parent.right } + QuitButton { + id: quitButton + anchors.verticalCenter: parent.verticalCenter + anchors.right: parent.right + anchors.rightMargin: 10 + } + } + Column { + id: layout + anchors { top: titlePane.bottom; topMargin: 10; left: parent.left; right: parent.right } + Repeater { model: easingTypes; delegate: delegate } + } + } + + function getBezierCurve(name) + { + if (name === "Easing.Bezier") + return easingCurve; + return []; + } +} diff --git a/examples/qml/animation/pathanimation/pathanimation.qml b/examples/qml/animation/pathanimation/pathanimation.qml new file mode 100644 index 0000000000..4d0a31bdf8 --- /dev/null +++ b/examples/qml/animation/pathanimation/pathanimation.qml @@ -0,0 +1,108 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Rectangle { + id: window + width: 400 + height: 400 + + Canvas { + id: canvas + anchors.fill: parent + smooth: true + + onPaint: { + context.clearRect(0, 0, width, height) + context.strokeStyle = "black" + context.path = pathAnim.path + context.stroke() + } + } + + PathAnimation { + id: pathAnim + + duration: 2000 + easing.type: Easing.InQuad + + target: box + orientation: PathAnimation.RightFirst + anchorPoint: Qt.point(box.width/2, box.height/2) + path: Path { + startX: 50; startY: 50 + + PathCubic { + x: window.width - 50 + y: window.height - 50 + + control1X: x; control1Y: 50 + control2X: 50; control2Y: y + } + + onChanged: canvas.requestPaint() + } + } + + Rectangle { + id: box + + x: 25; y: 25 + width: 50; height: 50 + border.width: 1 + smooth: true + + Text { + anchors.centerIn: parent + text: "Box" + } + } + + MouseArea { + anchors.fill: parent + onClicked: pathAnim.restart() + } + + Text { + text: "Click anywhere to animate along the path" + anchors.horizontalCenter: parent.horizontalCenter + } +} diff --git a/examples/qml/animation/pathinterpolator/pathinterpolator.qml b/examples/qml/animation/pathinterpolator/pathinterpolator.qml new file mode 100644 index 0000000000..67a34ce582 --- /dev/null +++ b/examples/qml/animation/pathinterpolator/pathinterpolator.qml @@ -0,0 +1,115 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Rectangle { + id: window + width: 400 + height: 400 + + Canvas { + id: canvas + anchors.fill: parent + smooth: true + + onPaint: { + context.clearRect(0, 0, width, height) + context.strokeStyle = "black" + context.path = motionPath.path + context.stroke() + } + } + + PathInterpolator { + id: motionPath + + path: Path { + startX: 50; startY: 50 + + PathCubic { + x: window.width - 50 + y: window.height - 50 + + control1X: x; control1Y: 50 + control2X: 50; control2Y: y + } + + onChanged: canvas.requestPaint() + } + + NumberAnimation on progress { + id: progressAnim + running: false + from: 0; to: 1 + duration: 2000 + easing.type: Easing.InQuad + } + } + + Rectangle { + id: box + + width: 50; height: 50 + border.width: 1 + smooth: true + + //bind our attributes to follow the path as progress changes + x: motionPath.x + y: motionPath.y + rotation: motionPath.angle + transform: Translate { x: -box.width/2; y: -box.height/2 } + + Text { + anchors.centerIn: parent + text: "Box" + } + } + + MouseArea { + anchors.fill: parent + onClicked: progressAnim.restart() + } + + Text { + text: "Click anywhere to animate along the path" + anchors.horizontalCenter: parent.horizontalCenter + } +} diff --git a/examples/qml/animation/states/qt-logo.png b/examples/qml/animation/states/qt-logo.png new file mode 100644 index 0000000000..14ddf2a028 Binary files /dev/null and b/examples/qml/animation/states/qt-logo.png differ diff --git a/examples/qml/animation/states/states.qml b/examples/qml/animation/states/states.qml new file mode 100644 index 0000000000..7ca56a9295 --- /dev/null +++ b/examples/qml/animation/states/states.qml @@ -0,0 +1,101 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Rectangle { + id: page + width: 640; height: 480 + color: "#343434" + + Image { + id: userIcon + x: topLeftRect.x; y: topLeftRect.y + source: "qt-logo.png" + } + + Rectangle { + id: topLeftRect + + anchors { left: parent.left; top: parent.top; leftMargin: 10; topMargin: 20 } + width: 46; height: 54 + color: "Transparent"; border.color: "Gray"; radius: 6 + + // Clicking in here sets the state to the default state, returning the image to + // its initial position + MouseArea { anchors.fill: parent; onClicked: page.state = '' } + } + + Rectangle { + id: middleRightRect + + anchors { right: parent.right; verticalCenter: parent.verticalCenter; rightMargin: 20 } + width: 46; height: 54 + color: "Transparent"; border.color: "Gray"; radius: 6 + + // Clicking in here sets the state to 'middleRight' + MouseArea { anchors.fill: parent; onClicked: page.state = 'middleRight' } + } + + Rectangle { + id: bottomLeftRect + + anchors { left: parent.left; bottom: parent.bottom; leftMargin: 10; bottomMargin: 20 } + width: 46; height: 54 + color: "Transparent"; border.color: "Gray"; radius: 6 + + // Clicking in here sets the state to 'bottomLeft' + MouseArea { anchors.fill: parent; onClicked: page.state = 'bottomLeft' } + } + + states: [ + // In state 'middleRight', move the image to middleRightRect + State { + name: "middleRight" + PropertyChanges { target: userIcon; x: middleRightRect.x; y: middleRightRect.y } + }, + + // In state 'bottomLeft', move the image to bottomLeftRect + State { + name: "bottomLeft" + PropertyChanges { target: userIcon; x: bottomLeftRect.x; y: bottomLeftRect.y } + } + ] +} diff --git a/examples/qml/animation/states/transitions.qml b/examples/qml/animation/states/transitions.qml new file mode 100644 index 0000000000..d57924d6d2 --- /dev/null +++ b/examples/qml/animation/states/transitions.qml @@ -0,0 +1,130 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +/* + This is exactly the same as states.qml, except that we have appended + a set of transitions to apply animations when the item changes + between each state. +*/ + +Rectangle { + id: page + width: 640; height: 480 + color: "#343434" + + Image { + id: userIcon + x: topLeftRect.x; y: topLeftRect.y + source: "qt-logo.png" + } + + Rectangle { + id: topLeftRect + + anchors { left: parent.left; top: parent.top; leftMargin: 10; topMargin: 20 } + width: 46; height: 54 + color: "Transparent"; border.color: "Gray"; radius: 6 + + // Clicking in here sets the state to the default state, returning the image to + // its initial position + MouseArea { anchors.fill: parent; onClicked: page.state = '' } + } + + Rectangle { + id: middleRightRect + + anchors { right: parent.right; verticalCenter: parent.verticalCenter; rightMargin: 20 } + width: 46; height: 54 + color: "Transparent"; border.color: "Gray"; radius: 6 + + // Clicking in here sets the state to 'middleRight' + MouseArea { anchors.fill: parent; onClicked: page.state = 'middleRight' } + } + + Rectangle { + id: bottomLeftRect + + anchors { left: parent.left; bottom: parent.bottom; leftMargin: 10; bottomMargin: 20 } + width: 46; height: 54 + color: "Transparent"; border.color: "Gray"; radius: 6 + + // Clicking in here sets the state to 'bottomLeft' + MouseArea { anchors.fill: parent; onClicked: page.state = 'bottomLeft' } + } + + states: [ + // In state 'middleRight', move the image to middleRightRect + State { + name: "middleRight" + PropertyChanges { target: userIcon; x: middleRightRect.x; y: middleRightRect.y } + }, + + // In state 'bottomLeft', move the image to bottomLeftRect + State { + name: "bottomLeft" + PropertyChanges { target: userIcon; x: bottomLeftRect.x; y: bottomLeftRect.y } + } + ] + + // Transitions define how the properties change when the item moves between each state + transitions: [ + + // When transitioning to 'middleRight' move x,y over a duration of 1 second, + // with OutBounce easing function. + Transition { + from: "*"; to: "middleRight" + NumberAnimation { properties: "x,y"; easing.type: Easing.OutBounce; duration: 1000 } + }, + + // When transitioning to 'bottomLeft' move x,y over a duration of 2 seconds, + // with InOutQuad easing function. + Transition { + from: "*"; to: "bottomLeft" + NumberAnimation { properties: "x,y"; easing.type: Easing.InOutQuad; duration: 2000 } + }, + + // For any other state changes move x,y linearly over duration of 200ms. + Transition { + NumberAnimation { properties: "x,y"; duration: 200 } + } + ] +} diff --git a/examples/qml/calculator/calculator.qml b/examples/qml/calculator/calculator.qml new file mode 100644 index 0000000000..913643a93b --- /dev/null +++ b/examples/qml/calculator/calculator.qml @@ -0,0 +1,163 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtQml module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import QtQuick.Window 2.0 +import "content" +import "content/calculator.js" as CalcEngine + +Rectangle { + id: window + + width: 360; height: 480 + color: "#282828" + + property string rotateLeft: "\u2939" + property string rotateRight: "\u2935" + property string leftArrow: "\u2190" + property string division : "\u00f7" + property string multiplication : "\u00d7" + property string squareRoot : "\u221a" + property string plusminus : "\u00b1" + + function doOp(operation) { CalcEngine.doOperation(operation) } + + Item { + id: main + state: "orientation " + Screen.orientation + + property bool landscapeWindow: window.width > window.height + property real baseWidth: landscapeWindow ? window.height : window.width + property real baseHeight: landscapeWindow ? window.width : window.height + property real rotationDelta: landscapeWindow ? -90 : 0 + + rotation: rotationDelta + width: main.baseWidth + height: main.baseHeight + anchors.centerIn: parent + + Column { + id: box; spacing: 8 + + anchors { fill: parent; topMargin: 6; bottomMargin: 6; leftMargin: 6; rightMargin: 6 } + + Display { + id: display + width: box.width-3 + height: 64 + } + + Column { + id: column; spacing: 6 + + property real h: ((box.height - 72) / 6) - ((spacing * (6 - 1)) / 6) + property real w: (box.width / 4) - ((spacing * (4 - 1)) / 4) + + Row { + spacing: 6 + Button { width: column.w; height: column.h; color: 'purple'; operation: "Off" } + Button { width: column.w; height: column.h; color: 'purple'; operation: leftArrow } + Button { width: column.w; height: column.h; color: 'purple'; operation: "C" } + Button { width: column.w; height: column.h; color: 'purple'; operation: "AC" } + } + + Row { + spacing: 6 + property real w: (box.width / 4) - ((spacing * (4 - 1)) / 4) + + Button { width: column.w; height: column.h; color: 'green'; operation: "mc" } + Button { width: column.w; height: column.h; color: 'green'; operation: "m+" } + Button { width: column.w; height: column.h; color: 'green'; operation: "m-" } + Button { width: column.w; height: column.h; color: 'green'; operation: "mr" } + } + + Grid { + id: grid; rows: 5; columns: 5; spacing: 6 + + property real w: (box.width / columns) - ((spacing * (columns - 1)) / columns) + + Button { width: grid.w; height: column.h; operation: "7"; color: 'blue' } + Button { width: grid.w; height: column.h; operation: "8"; color: 'blue' } + Button { width: grid.w; height: column.h; operation: "9"; color: 'blue' } + Button { width: grid.w; height: column.h; operation: division } + Button { width: grid.w; height: column.h; operation: squareRoot } + Button { width: grid.w; height: column.h; operation: "4"; color: 'blue' } + Button { width: grid.w; height: column.h; operation: "5"; color: 'blue' } + Button { width: grid.w; height: column.h; operation: "6"; color: 'blue' } + Button { width: grid.w; height: column.h; operation: multiplication } + Button { width: grid.w; height: column.h; operation: "x^2" } + Button { width: grid.w; height: column.h; operation: "1"; color: 'blue' } + Button { width: grid.w; height: column.h; operation: "2"; color: 'blue' } + Button { width: grid.w; height: column.h; operation: "3"; color: 'blue' } + Button { width: grid.w; height: column.h; operation: "-" } + Button { width: grid.w; height: column.h; operation: "1/x" } + Button { width: grid.w; height: column.h; operation: "0"; color: 'blue' } + Button { width: grid.w; height: column.h; operation: "." } + Button { width: grid.w; height: column.h; operation: plusminus } + Button { width: grid.w; height: column.h; operation: "+" } + Button { width: grid.w; height: column.h; operation: "="; color: 'red' } + } + } + } + + states: [ + State { + name: "orientation " + Qt.LandscapeOrientation + PropertyChanges { target: main; rotation: 90 + rotationDelta; width: main.baseHeight; height: main.baseWidth } + }, + State { + name: "orientation " + Qt.InvertedPortraitOrientation + PropertyChanges { target: main; rotation: 180 + rotationDelta; } + }, + State { + name: "orientation " + Qt.InvertedLandscapeOrientation + PropertyChanges { target: main; rotation: 270 + rotationDelta; width: main.baseHeight; height: main.baseWidth } + } + ] + + transitions: Transition { + SequentialAnimation { + RotationAnimation { direction: RotationAnimation.Shortest; duration: 300; easing.type: Easing.InOutQuint } + NumberAnimation { properties: "x,y,width,height"; duration: 300; easing.type: Easing.InOutQuint } + } + } + } +} diff --git a/examples/qml/calculator/content/Button.qml b/examples/qml/calculator/content/Button.qml new file mode 100644 index 0000000000..feaa5e7df3 --- /dev/null +++ b/examples/qml/calculator/content/Button.qml @@ -0,0 +1,84 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtQml module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +BorderImage { + id: button + + property alias operation: buttonText.text + property string color: "" + + Accessible.name: operation + Accessible.description: "This button does " + operation + Accessible.role: Accessible.Button + + signal clicked + + source: "images/button-" + color + ".png"; clip: true + border { left: 10; top: 10; right: 10; bottom: 10 } + + Rectangle { + id: shade + anchors.fill: button; radius: 10; color: "black"; opacity: 0 + } + + Text { + id: buttonText + anchors.centerIn: parent; anchors.verticalCenterOffset: -1 + font.pixelSize: parent.width > parent.height ? parent.height * .5 : parent.width * .5 + style: Text.Sunken; color: "white"; styleColor: "black"; smooth: true + } + + MouseArea { + id: mouseArea + anchors.fill: parent + onClicked: { + doOp(operation) + button.clicked() + } + } + + states: State { + name: "pressed"; when: mouseArea.pressed == true + PropertyChanges { target: shade; opacity: .4 } + } +} diff --git a/examples/qml/calculator/content/Display.qml b/examples/qml/calculator/content/Display.qml new file mode 100644 index 0000000000..3dceeab169 --- /dev/null +++ b/examples/qml/calculator/content/Display.qml @@ -0,0 +1,68 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtQml module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +BorderImage { + id: image + + property alias text : displayText.text + property alias currentOperation : operationText + + source: "images/display.png" + border { left: 10; top: 10; right: 10; bottom: 10 } + + Text { + id: displayText + anchors { + right: parent.right; verticalCenter: parent.verticalCenter; verticalCenterOffset: -1 + rightMargin: 6; left: operationText.right + } + font.pixelSize: parent.height * .6; text: "0"; horizontalAlignment: Text.AlignRight; elide: Text.ElideRight + color: "#343434"; smooth: true; font.bold: true + } + Text { + id: operationText + font.bold: true; font.pixelSize: parent.height * .7 + color: "#343434"; smooth: true + anchors { left: parent.left; leftMargin: 6; verticalCenterOffset: -3; verticalCenter: parent.verticalCenter } + } +} diff --git a/examples/qml/calculator/content/calculator.js b/examples/qml/calculator/content/calculator.js new file mode 100644 index 0000000000..7c363c7f30 --- /dev/null +++ b/examples/qml/calculator/content/calculator.js @@ -0,0 +1,91 @@ + +var curVal = 0 +var memory = 0 +var lastOp = "" +var timer = 0 + +function disabled(op) { + if (op == "." && display.text.toString().search(/\./) != -1) { + return true + } else if (op == squareRoot && display.text.toString().search(/-/) != -1) { + return true + } else { + return false + } +} + +function doOperation(op) { + if (disabled(op)) { + return + } + + if (op.toString().length==1 && ((op >= "0" && op <= "9") || op==".") ) { + if (display.text.toString().length >= 14) + return; // No arbitrary length numbers + if (lastOp.toString().length == 1 && ((lastOp >= "0" && lastOp <= "9") || lastOp == ".") ) { + display.text = display.text + op.toString() + } else { + display.text = op + } + lastOp = op + return + } + lastOp = op + + if (display.currentOperation.text == "+") { + display.text = Number(display.text.valueOf()) + Number(curVal.valueOf()) + } else if (display.currentOperation.text == "-") { + display.text = Number(curVal) - Number(display.text.valueOf()) + } else if (display.currentOperation.text == multiplication) { + display.text = Number(curVal) * Number(display.text.valueOf()) + } else if (display.currentOperation.text == division) { + display.text = Number(Number(curVal) / Number(display.text.valueOf())).toString() + } else if (display.currentOperation.text == "=") { + } + + if (op == "+" || op == "-" || op == multiplication || op == division) { + display.currentOperation.text = op + curVal = display.text.valueOf() + return + } + + curVal = 0 + display.currentOperation.text = "" + + if (op == "1/x") { + display.text = (1 / display.text.valueOf()).toString() + } else if (op == "x^2") { + display.text = (display.text.valueOf() * display.text.valueOf()).toString() + } else if (op == "Abs") { + display.text = (Math.abs(display.text.valueOf())).toString() + } else if (op == "Int") { + display.text = (Math.floor(display.text.valueOf())).toString() + } else if (op == plusminus) { + display.text = (display.text.valueOf() * -1).toString() + } else if (op == squareRoot) { + display.text = (Math.sqrt(display.text.valueOf())).toString() + } else if (op == "mc") { + memory = 0; + } else if (op == "m+") { + memory += display.text.valueOf() + } else if (op == "mr") { + display.text = memory.toString() + } else if (op == "m-") { + memory = display.text.valueOf() + } else if (op == leftArrow) { + display.text = display.text.toString().slice(0, -1) + if (display.text.length == 0) { + display.text = "0" + } + } else if (op == "Off") { + Qt.quit(); + } else if (op == "C") { + display.text = "0" + } else if (op == "AC") { + curVal = 0 + memory = 0 + lastOp = "" + display.text ="0" + } +} + diff --git a/examples/qml/calculator/content/images/button-.png b/examples/qml/calculator/content/images/button-.png new file mode 100644 index 0000000000..544e514536 Binary files /dev/null and b/examples/qml/calculator/content/images/button-.png differ diff --git a/examples/qml/calculator/content/images/button-blue.png b/examples/qml/calculator/content/images/button-blue.png new file mode 100644 index 0000000000..5f92de32d0 Binary files /dev/null and b/examples/qml/calculator/content/images/button-blue.png differ diff --git a/examples/qml/calculator/content/images/button-green.png b/examples/qml/calculator/content/images/button-green.png new file mode 100644 index 0000000000..36c93914c7 Binary files /dev/null and b/examples/qml/calculator/content/images/button-green.png differ diff --git a/examples/qml/calculator/content/images/button-purple.png b/examples/qml/calculator/content/images/button-purple.png new file mode 100644 index 0000000000..347cbbea9d Binary files /dev/null and b/examples/qml/calculator/content/images/button-purple.png differ diff --git a/examples/qml/calculator/content/images/button-red.png b/examples/qml/calculator/content/images/button-red.png new file mode 100644 index 0000000000..3b335891ae Binary files /dev/null and b/examples/qml/calculator/content/images/button-red.png differ diff --git a/examples/qml/calculator/content/images/display.png b/examples/qml/calculator/content/images/display.png new file mode 100644 index 0000000000..9507f4382e Binary files /dev/null and b/examples/qml/calculator/content/images/display.png differ diff --git a/examples/qml/calculator/content/qmldir b/examples/qml/calculator/content/qmldir new file mode 100644 index 0000000000..a926b93fac --- /dev/null +++ b/examples/qml/calculator/content/qmldir @@ -0,0 +1,2 @@ +Button Button.qml +Display Display.qml diff --git a/examples/qml/canvas/bezierCurve/bezierCurve.qml b/examples/qml/canvas/bezierCurve/bezierCurve.qml new file mode 100644 index 0000000000..f57839b0a5 --- /dev/null +++ b/examples/qml/canvas/bezierCurve/bezierCurve.qml @@ -0,0 +1,124 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import "../contents" +Item { + id:container + width:360 + height:600 + + Column { + spacing:5 + anchors.fill:parent + Text { font.pointSize:25; text:"Bezier Curve"; anchors.horizontalCenter:parent.horizontalCenter} + + Canvas { + id:canvas + width:360 + height:360 + property string strokeStyle:"red" + property string fillStyle:"red" + property int lineWidth:lineWidthCtrl.value + property bool fill:true + property bool stroke:true + property real alpha:alphaCtrl.value + property real scaleX : scaleXCtrl.value + property real scaleY : scaleYCtrl.value + property real rotate : rotateCtrl.value + smooth:true + renderTarget:Canvas.Image + renderStrategy: Canvas.Immediate + + + Behavior on scaleX { SpringAnimation { spring: 2; damping: 0.2; loops:Animation.Infinite } } + Behavior on scaleY { SpringAnimation { spring: 2; damping: 0.2; loops:Animation.Infinite} } + Behavior on rotate { SpringAnimation { spring: 2; damping: 0.2; loops:Animation.Infinite} } + + onLineWidthChanged:requestPaint(); + onFillChanged:requestPaint(); + onStrokeChanged:requestPaint(); + onAlphaChanged:requestPaint(); + onScaleXChanged:requestPaint(); + onScaleYChanged:requestPaint(); + onRotateChanged:requestPaint(); + + onPaint: { + var ctx = canvas.getContext('2d'); + ctx.save(); + ctx.clearRect(0, 0, canvas.width, canvas.height); + ctx.globalAlpha = canvas.alpha; + ctx.strokeStyle = canvas.strokeStyle; + ctx.fillStyle = canvas.fillStyle; + ctx.lineWidth = canvas.lineWidth; + ctx.scale(canvas.scaleX, canvas.scaleY); + ctx.rotate(canvas.rotate); + ctx.beginPath(); + ctx.moveTo(75,40); + ctx.bezierCurveTo(75,37,70,25,50,25); + ctx.bezierCurveTo(20,25,20,62.5,20,62.5); + ctx.bezierCurveTo(20,80,40,102,75,120); + ctx.bezierCurveTo(110,102,130,80,130,62.5); + ctx.bezierCurveTo(130,62.5,130,25,100,25); + ctx.bezierCurveTo(85,25,75,37,75,40); + ctx.closePath(); + if (canvas.fill) + ctx.fill(); + if (canvas.stroke) + ctx.stroke(); + ctx.restore(); + } + } + + Rectangle { + id:controls + width:360 + height:160 + Column { + spacing:3 + Slider {id:lineWidthCtrl; width:300; height:30; min:1; max:10; init:2; name:"Line width"} + Slider {id:scaleXCtrl; width:300; height:30; min:0.1; max:10; init:1; name:"ScaleX"} + Slider {id:scaleYCtrl; width:300; height:30; min:0.1; max:10; init:1; name:"ScaleY"} + Slider {id:rotateCtrl; width:300; height:30; min:0; max:Math.PI*2; init:0; name:"Rotate"} + Slider {id:alphaCtrl; width:300; height:30; min:0; max:1; init:1; name:"Alpha"} + } + } + } +} diff --git a/examples/qml/canvas/clip/clip.qml b/examples/qml/canvas/clip/clip.qml new file mode 100644 index 0000000000..d861ff0a46 --- /dev/null +++ b/examples/qml/canvas/clip/clip.qml @@ -0,0 +1,150 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import "../contents" +Item { + id:container + width:360 + height:600 + + Column { + spacing:5 + anchors.fill:parent + Text { font.pointSize:25; text:"Makes squircle icon with clip"; anchors.horizontalCenter:parent.horizontalCenter} + Canvas { + id:canvas + width:360 + height:360 + property string strokeStyle:"blue" + property string fillStyle:"steelblue" + property int lineWidth:2 + property int nSize:nCtrl.value + property real radius:rCtrl.value + property bool fill:true + property bool stroke:false + property real px:xCtrl.value + property real py:yCtrl.value + property real alpha:alphaCtrl.value + property string imagefile:"../contents/qt-logo.png" + smooth:true + renderTarget:Canvas.Image + renderStrategy: Canvas.Immediate + Component.onCompleted:loadImage(canvas.imagefile); + + onAlphaChanged:requestPaint(); + onRadiusChanged:requestPaint(); + onLineWidthChanged:requestPaint(); + onNSizeChanged:requestPaint(); + onFillChanged:requestPaint(); + onStrokeChanged:requestPaint(); + onPxChanged:requestPaint(); + onPyChanged:requestPaint(); + + onImageLoaded : requestPaint(); + + onPaint: squcirle(); + + function squcirle() { + var ctx = canvas.getContext("2d"); + var N = canvas.nSize; + var R = canvas.radius; + + N=Math.abs(N); + var M=N; + if (N>100) M=100; + if (N<0.00000000001) M=0.00000000001; + + ctx.save(); + ctx.globalAlpha =canvas.alpha; + ctx.fillStyle = "gray"; + ctx.fillRect(0, 0, canvas.width, canvas.height); + + ctx.strokeStyle = canvas.strokeStyle; + ctx.fillStyle = canvas.fillStyle; + ctx.lineWidth = canvas.lineWidth; + + ctx.beginPath(); + var i = 0, x, y; + for (i=0; i<(2*R+1); i++){ + x = Math.round(i-R) + canvas.px; + y = Math.round(Math.pow(Math.abs(Math.pow(R,M)-Math.pow(Math.abs(i-R),M)),1/M)) + canvas.py; + + if (i == 0) + ctx.moveTo(x, y); + else + ctx.lineTo(x, y); + } + + for (i=(2*R); i<(4*R+1); i++){ + x =Math.round(3*R-i)+canvas.px; + y = Math.round(-Math.pow(Math.abs(Math.pow(R,M)-Math.pow(Math.abs(3*R-i),M)),1/M)) + canvas.py; + ctx.lineTo(x, y); + } + ctx.closePath(); + if (canvas.stroke) { + ctx.stroke(); + } + + if (canvas.fill) { + ctx.fill(); + } + ctx.clip(); + + ctx.drawImage(canvas.imagefile, 0, 0); + ctx.restore(); + } + } + + Rectangle { + id:controls + width:360 + height:160 + Column { + spacing:3 + Slider {id:nCtrl; width:300; height:30; min:1; max:10; init:4; name:"N"} + Slider {id:rCtrl; width:300; height:30; min:30; max:180; init:100; name:"Radius"} + Slider {id:xCtrl; width:300; height:30; min:50; max:300; init:180; name:"X"} + Slider {id:yCtrl; width:300; height:30; min:30; max:300; init:220; name:"Y"} + Slider {id:alphaCtrl; width:300; height:30; min:0; max:1; init:1; name:"Alpha"} + } + } + } +} diff --git a/examples/qml/canvas/contents/Button.qml b/examples/qml/canvas/contents/Button.qml new file mode 100644 index 0000000000..1413cdb9fa --- /dev/null +++ b/examples/qml/canvas/contents/Button.qml @@ -0,0 +1,87 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Item { + id: container + + signal clicked + + property string text + width: buttonText.width + 28 + height: buttonText.height + 14 + + BorderImage { + id: buttonImage + source: "images/toolbutton.sci" + width: container.width - 10 + height: container.height + } + BorderImage { + id: pressed + opacity: 0 + source: "images/toolbutton.sci" + width: container.width - 10 + height: container.height + } + MouseArea { + id: mouseRegion + anchors.fill: buttonImage + onClicked: { container.clicked(); } + } + Text { + id: buttonText + color: "white" + anchors.centerIn: buttonImage + font.bold: true + font.pointSize: 15 + text: container.text + style: Text.Raised + styleColor: "black" + } + states: [ + State { + name: "Pressed" + when: mouseRegion.pressed == true + PropertyChanges { target: pressed; opacity: 1 } + } + ] +} \ No newline at end of file diff --git a/examples/qml/canvas/contents/ScrollBar.qml b/examples/qml/canvas/contents/ScrollBar.qml new file mode 100644 index 0000000000..98b8efee4a --- /dev/null +++ b/examples/qml/canvas/contents/ScrollBar.qml @@ -0,0 +1,74 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the Qt Mobility Components. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Item { + id: scrollBar + // The properties that define the scrollbar's state. + // position and pageSize are in the range 0.0 - 1.0. They are relative to the + // height of the page, i.e. a pageSize of 0.5 means that you can see 50% + // of the height of the view. + // orientation can be either 'Vertical' or 'Horizontal' + property real position + property real pageSize + property string orientation : "Vertical" + property alias bgColor: background.color + property alias fgColor: thumb.color + + // A light, semi-transparent background + Rectangle { + id: background + radius: orientation == 'Vertical' ? (width/2 - 1) : (height/2 - 1) + color: "white"; opacity: 0.3 + anchors.fill: parent + } + // Size the bar to the required size, depending upon the orientation. + Rectangle { + id: thumb + opacity: 0.7 + color: "black" + radius: orientation == 'Vertical' ? (width/2 - 1) : (height/2 - 1) + x: orientation == 'Vertical' ? 1 : (scrollBar.position * (scrollBar.width-2) + 1) + y: orientation == 'Vertical' ? (scrollBar.position * (scrollBar.height-2) + 1) : 1 + width: orientation == 'Vertical' ? (parent.width-2) : (scrollBar.pageSize * (scrollBar.width-2)) + height: orientation == 'Vertical' ? (scrollBar.pageSize * (scrollBar.height-2)) : (parent.height-2) + } +} diff --git a/examples/qml/canvas/contents/Slider.qml b/examples/qml/canvas/contents/Slider.qml new file mode 100644 index 0000000000..1050e307f6 --- /dev/null +++ b/examples/qml/canvas/contents/Slider.qml @@ -0,0 +1,115 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the Declarative module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Item { + id:slider + property real min:0 + property real max:1 + property real value: min + (max - min) * (bar.x / (foo.width - bar.width)) + property real init:min+(max-min)/2 + property string name:"Slider" + + Component.onCompleted: setValue(init) + function setValue(v) { + if (min < max) + bar.x = v/(max - min) * (foo.width - bar.width); + } + Rectangle { + id:sliderName + anchors.left:parent.left + height: childrenRect.height + width:childrenRect.width + anchors.verticalCenter:parent.verticalCenter + Text { + text:slider.name + font.pointSize:12 + } + } + Item { + id: foo + height: 6 + width: parent.width - 4 - sliderName.width + anchors.verticalCenter:parent.verticalCenter + anchors.left:sliderName.right + anchors.leftMargin:5 + Rectangle { + height: parent.height + anchors.left: parent.left + anchors.right: bar.horizontalCenter + color: "blue" + radius: 3 + } + Rectangle { + height: parent.height + anchors.left: bar.horizontalCenter + anchors.right: parent.right + color: "gray" + radius: 3 + } + Rectangle { + anchors.fill: parent + color: "transparent" + radius: 3 + border.width: 2 + border.color: "black" + } + + Rectangle { + id: bar + y: -7 + width: 20 + height: 20 + radius: 15 + color: "white" + border.width: 2 + border.color: "black" + MouseArea { + anchors.fill: parent + drag.target: parent + drag.axis: Drag.XAxis + drag.minimumX: 0 + drag.maximumX: foo.width - parent.width + } + } + } +} diff --git a/examples/qml/canvas/contents/Stocks.qml b/examples/qml/canvas/contents/Stocks.qml new file mode 100644 index 0000000000..043bca132e --- /dev/null +++ b/examples/qml/canvas/contents/Stocks.qml @@ -0,0 +1,147 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +ListModel { + id:stocks + //Data from : http://en.wikipedia.org/wiki/NASDAQ-100 + + ListElement {name:"Activision Blizzard"; stockId:"ATVI"} + ListElement {name:"Adobe Systems Incorporated"; stockId:"ADBE"} + ListElement {name:"Akamai Technologies, Inc"; stockId:"AKAM"} + ListElement {name:"Alexion Pharmaceuticals"; stockId:"ALXN"} + ListElement {name:"Altera Corporation"; stockId:"ALTR"} + ListElement {name:"Amazon.com, Inc."; stockId:"AMZN"} + ListElement {name:"Amgen Inc."; stockId:"AMGN"} + ListElement {name:"Apollo Group, Inc."; stockId:"APOL"} + ListElement {name:"Apple Inc."; stockId:"AAPL"} + ListElement {name:"Applied Materials, Inc."; stockId:"AMAT"} + ListElement {name:"Autodesk, Inc."; stockId:"ADSK"} + ListElement {name:"Automatic Data Processing, Inc."; stockId:"ADP"} + ListElement {name:"Baidu.com, Inc."; stockId:"BIDU"} + ListElement {name:"Bed Bath & Beyond Inc."; stockId:"BBBY"} + ListElement {name:"Biogen Idec, Inc"; stockId:"BIIB"} + ListElement {name:"BMC Software, Inc."; stockId:"BMC"} + ListElement {name:"Broadcom Corporation"; stockId:"BRCM"} + ListElement {name:"C. H. Robinson Worldwide, Inc."; stockId:"CHRW"} + ListElement {name:"CA, Inc."; stockId:"CA"} + ListElement {name:"Celgene Corporation"; stockId:"CELG"} + ListElement {name:"Cephalon, Inc."; stockId:"CEPH"} + ListElement {name:"Cerner Corporation"; stockId:"CERN"} + ListElement {name:"Check Point Software Technologies Ltd."; stockId:"CHKP"} + ListElement {name:"Cisco Systems, Inc."; stockId:"CSCO"} + ListElement {name:"Citrix Systems, Inc."; stockId:"CTXS"} + ListElement {name:"Cognizant Technology Solutions Corporation"; stockId:"CTSH"} + ListElement {name:"Comcast Corporation"; stockId:"CMCSA"} + ListElement {name:"Costco Wholesale Corporation"; stockId:"COST"} + ListElement {name:"Ctrip.com International, Ltd."; stockId:"CTRP"} + ListElement {name:"Dell Inc."; stockId:"DELL"} + ListElement {name:"DENTSPLY International Inc."; stockId:"XRAY"} + ListElement {name:"DirecTV"; stockId:"DTV"} + ListElement {name:"Dollar Tree, Inc."; stockId:"DLTR"} + ListElement {name:"eBay Inc."; stockId:"EBAY"} + ListElement {name:"Electronic Arts Inc."; stockId:"ERTS"} + ListElement {name:"Expedia, Inc."; stockId:"EXPE"} + ListElement {name:"Expeditors International of Washington, Inc."; stockId:"EXPD"} + ListElement {name:"Express Scripts, Inc."; stockId:"ESRX"} + ListElement {name:"F5 Networks, Inc."; stockId:"FFIV"} + ListElement {name:"Fastenal Company"; stockId:"FAST"} + ListElement {name:"First Solar, Inc."; stockId:"FSLR"} + ListElement {name:"Fiserv, Inc."; stockId:"FISV"} + ListElement {name:"Flextronics International Ltd."; stockId:"FLEX"} + ListElement {name:"FLIR Systems, Inc."; stockId:"FLIR"} + ListElement {name:"Garmin Ltd."; stockId:"GRMN"} + ListElement {name:"Gilead Sciences, Inc."; stockId:"GILD"} + ListElement {name:"Google Inc."; stockId:"GOOG"} + ListElement {name:"Green Mountain Coffee Roasters, Inc."; stockId:"GMCR"} + ListElement {name:"Henry Schein, Inc."; stockId:"HSIC"} + ListElement {name:"Illumina, Inc."; stockId:"ILMN"} + ListElement {name:"Infosys Technologies"; stockId:"INFY"} + ListElement {name:"Intel Corporation"; stockId:"INTC"} + ListElement {name:"Intuit, Inc."; stockId:"INTU"} + ListElement {name:"Intuitive Surgical Inc."; stockId:"ISRG"} + ListElement {name:"Joy Global Inc."; stockId:"JOYG"} + ListElement {name:"KLA Tencor Corporation"; stockId:"KLAC"} + ListElement {name:"Lam Research Corporation"; stockId:"LRCX"} + ListElement {name:"Liberty Media Corporation, Interactive Series A"; stockId:"LINTA"} + ListElement {name:"Life Technologies Corporation"; stockId:"LIFE"} + ListElement {name:"Linear Technology Corporation"; stockId:"LLTC"} + ListElement {name:"Marvell Technology Group, Ltd."; stockId:"MRVL"} + ListElement {name:"Mattel, Inc."; stockId:"MAT"} + ListElement {name:"Maxim Integrated Products"; stockId:"MXIM"} + ListElement {name:"Microchip Technology Incorporated"; stockId:"MCHP"} + ListElement {name:"Micron Technology, Inc."; stockId:"MU"} + ListElement {name:"Microsoft Corporation"; stockId:"MSFT"} + ListElement {name:"Mylan, Inc."; stockId:"MYL"} + ListElement {name:"NetApp, Inc."; stockId:"NTAP"} + ListElement {name:"Netflix, Inc."; stockId:"NFLX"} + ListElement {name:"News Corporation, Ltd."; stockId:"NWSA"} + ListElement {name:"NII Holdings, Inc."; stockId:"NIHD"} + ListElement {name:"NVIDIA Corporation"; stockId:"NVDA"} + ListElement {name:"O'Reilly Automotive, Inc."; stockId:"ORLY"} + ListElement {name:"Oracle Corporation"; stockId:"ORCL"} + ListElement {name:"PACCAR Inc."; stockId:"PCAR"} + ListElement {name:"Paychex, Inc."; stockId:"PAYX"} + ListElement {name:"Priceline.com, Incorporated"; stockId:"PCLN"} + ListElement {name:"Qiagen N.V."; stockId:"QGEN"} + ListElement {name:"QUALCOMM Incorporated"; stockId:"QCOM"} + ListElement {name:"Research in Motion Limited"; stockId:"RIMM"} + ListElement {name:"Ross Stores Inc."; stockId:"ROST"} + ListElement {name:"SanDisk Corporation"; stockId:"SNDK"} + ListElement {name:"Seagate Technology Holdings"; stockId:"STX"} + ListElement {name:"Sears Holdings Corporation"; stockId:"SHLD"} + ListElement {name:"Sigma-Aldrich Corporation"; stockId:"SIAL"} + ListElement {name:"Staples Inc."; stockId:"SPLS"} + ListElement {name:"Starbucks Corporation"; stockId:"SBUX"} + ListElement {name:"Stericycle, Inc"; stockId:"SRCL"} + ListElement {name:"Symantec Corporation"; stockId:"SYMC"} + ListElement {name:"Teva Pharmaceutical Industries Ltd."; stockId:"TEVA"} + ListElement {name:"Urban Outfitters, Inc."; stockId:"URBN"} + ListElement {name:"VeriSign, Inc."; stockId:"VRSN"} + ListElement {name:"Vertex Pharmaceuticals"; stockId:"VRTX"} + ListElement {name:"Virgin Media, Inc."; stockId:"VMED"} + ListElement {name:"Vodafone Group, plc."; stockId:"VOD"} + ListElement {name:"Warner Chilcott, Ltd."; stockId:"WCRX"} + ListElement {name:"Whole Foods Market, Inc."; stockId:"WFM"} + ListElement {name:"Wynn Resorts Ltd."; stockId:"WYNN"} + ListElement {name:"Xilinx, Inc."; stockId:"XLNX"} + ListElement {name:"Yahoo! Inc."; stockId:"YHOO"} +} diff --git a/examples/qml/canvas/contents/TitleBar.qml b/examples/qml/canvas/contents/TitleBar.qml new file mode 100644 index 0000000000..28edda2ae7 --- /dev/null +++ b/examples/qml/canvas/contents/TitleBar.qml @@ -0,0 +1,70 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Item { + id: titleBar + property string title: "" + + BorderImage { source: "images/titlebar.sci"; width: parent.width; height: parent.height + 14; y: -7 } + + Image { + id: quitButton + anchors.left: parent.left//; anchors.leftMargin: 0 + anchors.verticalCenter: parent.verticalCenter + source: "images/quit.png" + MouseArea { + anchors.fill: parent + onClicked: Qt.quit() + } + } + + Text { + id: categoryText + anchors { + left: quitButton.right; right: parent.right; //leftMargin: 10; rightMargin: 10 + verticalCenter: parent.verticalCenter + } + elide: Text.ElideLeft + text: title + font.bold: true; font.pointSize: 20; color: "White"; style: Text.Raised; styleColor: "Black" + } +} diff --git a/examples/qml/canvas/contents/ToolBar.qml b/examples/qml/canvas/contents/ToolBar.qml new file mode 100644 index 0000000000..7ae7391ddf --- /dev/null +++ b/examples/qml/canvas/contents/ToolBar.qml @@ -0,0 +1,69 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Item { + id: toolbar + + property variant labels + signal buttonClicked(int index) + + BorderImage { + source: "images/titlebar.sci" + width: parent.width + height: parent.height + 14 + y: -7 + } + + Row { + y: 3 + anchors.horizontalCenter: parent.horizontalCenter + Repeater { + model: toolbar.labels + delegate: + Button { + text: modelData + onClicked: toolbar.buttonClicked(model.index) + } + } + } + +} diff --git a/examples/qml/canvas/contents/images/button-pressed.png b/examples/qml/canvas/contents/images/button-pressed.png new file mode 100644 index 0000000000..e434d327f2 Binary files /dev/null and b/examples/qml/canvas/contents/images/button-pressed.png differ diff --git a/examples/qml/canvas/contents/images/button.png b/examples/qml/canvas/contents/images/button.png new file mode 100644 index 0000000000..56a63ce641 Binary files /dev/null and b/examples/qml/canvas/contents/images/button.png differ diff --git a/examples/qml/canvas/contents/images/default.svg b/examples/qml/canvas/contents/images/default.svg new file mode 100644 index 0000000000..248199cc4e --- /dev/null +++ b/examples/qml/canvas/contents/images/default.svg @@ -0,0 +1,82 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + weather-clear + January 2006 + + + Ryan Collier (pseudo) + + + + + http://www.tango-project.org + + + http://www.pseudocode.org + + + weather + applet + notification + + + + + + Garrett LeSage + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/examples/qml/canvas/contents/images/gloss.png b/examples/qml/canvas/contents/images/gloss.png new file mode 100755 index 0000000000..5d370cd93d Binary files /dev/null and b/examples/qml/canvas/contents/images/gloss.png differ diff --git a/examples/qml/canvas/contents/images/lineedit.png b/examples/qml/canvas/contents/images/lineedit.png new file mode 100755 index 0000000000..2cc38dc35b Binary files /dev/null and b/examples/qml/canvas/contents/images/lineedit.png differ diff --git a/examples/qml/canvas/contents/images/lineedit.sci b/examples/qml/canvas/contents/images/lineedit.sci new file mode 100644 index 0000000000..054bff78be --- /dev/null +++ b/examples/qml/canvas/contents/images/lineedit.sci @@ -0,0 +1,5 @@ +border.left: 10 +border.top: 10 +border.bottom: 10 +border.right: 10 +source: lineedit.png diff --git a/examples/qml/canvas/contents/images/quit.png b/examples/qml/canvas/contents/images/quit.png new file mode 100755 index 0000000000..5bda1b6e0d Binary files /dev/null and b/examples/qml/canvas/contents/images/quit.png differ diff --git a/examples/qml/canvas/contents/images/stripes.png b/examples/qml/canvas/contents/images/stripes.png new file mode 100755 index 0000000000..9f36727ea4 Binary files /dev/null and b/examples/qml/canvas/contents/images/stripes.png differ diff --git a/examples/qml/canvas/contents/images/titlebar.png b/examples/qml/canvas/contents/images/titlebar.png new file mode 100755 index 0000000000..51c90082d0 Binary files /dev/null and b/examples/qml/canvas/contents/images/titlebar.png differ diff --git a/examples/qml/canvas/contents/images/titlebar.sci b/examples/qml/canvas/contents/images/titlebar.sci new file mode 100644 index 0000000000..0418d94cd6 --- /dev/null +++ b/examples/qml/canvas/contents/images/titlebar.sci @@ -0,0 +1,5 @@ +border.left: 10 +border.top: 12 +border.bottom: 12 +border.right: 10 +source: titlebar.png diff --git a/examples/qml/canvas/contents/images/toolbutton.png b/examples/qml/canvas/contents/images/toolbutton.png new file mode 100755 index 0000000000..11310013ee Binary files /dev/null and b/examples/qml/canvas/contents/images/toolbutton.png differ diff --git a/examples/qml/canvas/contents/images/toolbutton.sci b/examples/qml/canvas/contents/images/toolbutton.sci new file mode 100644 index 0000000000..9e4f965307 --- /dev/null +++ b/examples/qml/canvas/contents/images/toolbutton.sci @@ -0,0 +1,5 @@ +border.left: 15 +border.top: 4 +border.bottom: 4 +border.right: 15 +source: toolbutton.png diff --git a/examples/qml/canvas/contents/qt-logo.png b/examples/qml/canvas/contents/qt-logo.png new file mode 100644 index 0000000000..5ab3a1b0c4 Binary files /dev/null and b/examples/qml/canvas/contents/qt-logo.png differ diff --git a/examples/qml/canvas/quadraticCurveTo/quadraticCurveTo.qml b/examples/qml/canvas/quadraticCurveTo/quadraticCurveTo.qml new file mode 100644 index 0000000000..bc3ca0071a --- /dev/null +++ b/examples/qml/canvas/quadraticCurveTo/quadraticCurveTo.qml @@ -0,0 +1,128 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import "../contents" +Item { + id:container + width:360 + height:600 + + Column { + spacing:5 + anchors.fill:parent + Text { font.pointSize:25; text:"Quadratic Curve"; anchors.horizontalCenter:parent.horizontalCenter} + + Canvas { + id:canvas + width:360 + height:360 + property string strokeStyle:"steelblue" + property string fillStyle:"yellow" + property int lineWidth:lineWidthCtrl.value + property bool fill:true + property bool stroke:true + property real alpha:alphaCtrl.value + property real scaleX : scaleXCtrl.value + property real scaleY : scaleYCtrl.value + property real rotate : rotateCtrl.value + smooth:true + renderTarget:Canvas.Image + renderStrategy: Canvas.Immediate + + onLineWidthChanged:requestPaint(); + onFillChanged:requestPaint(); + onStrokeChanged:requestPaint(); + onAlphaChanged:requestPaint(); + onScaleXChanged:requestPaint(); + onScaleYChanged:requestPaint(); + onRotateChanged:requestPaint(); + Behavior on scaleX { SpringAnimation { spring: 2; damping: 0.2; loops:Animation.Infinite } } + Behavior on scaleY { SpringAnimation { spring: 2; damping: 0.2; loops:Animation.Infinite} } + Behavior on rotate { SpringAnimation { spring: 2; damping: 0.2; loops:Animation.Infinite} } + + onPaint: { + var ctx = canvas.getContext('2d'); + ctx.save(); + ctx.clearRect(0, 0, canvas.width, canvas.height); + ctx.globalAlpha = canvas.alpha; + ctx.strokeStyle = canvas.strokeStyle; + ctx.fillStyle = canvas.fillStyle; + ctx.lineWidth = canvas.lineWidth; + ctx.scale(canvas.scaleX, canvas.scaleY); + ctx.rotate(canvas.rotate); + ctx.beginPath(); + ctx.moveTo(75,25); + ctx.quadraticCurveTo(25,25,25,62.5); + ctx.quadraticCurveTo(25,100,50,100); + ctx.quadraticCurveTo(50,120,30,125); + ctx.quadraticCurveTo(60,120,65,100); + ctx.quadraticCurveTo(125,100,125,62.5); + ctx.quadraticCurveTo(125,25,75,25); + ctx.closePath(); + if (canvas.fill) + ctx.fill(); + if (canvas.stroke) + ctx.stroke(); + + + ctx.fillStyle="green"; + ctx.font = "Bold 15px"; + + ctx.fillText("QML酷毙了", 30, 60); + ctx.restore(); + } + } + + Rectangle { + id:controls + width:360 + height:160 + Column { + spacing:3 + Slider {id:lineWidthCtrl; width:300; height:30; min:1; max:10; init:2; name:"Line width"} + Slider {id:scaleXCtrl; width:300; height:30; min:0.1; max:10; init:1; name:"ScaleX"} + Slider {id:scaleYCtrl; width:300; height:30; min:0.1; max:10; init:1; name:"ScaleY"} + Slider {id:rotateCtrl; width:300; height:30; min:0; max:Math.PI*2; init:0; name:"Rotate"} + Slider {id:alphaCtrl; width:300; height:30; min:0; max:1; init:1; name:"Alpha"} + } + } + } +} diff --git a/examples/qml/canvas/roundedrect/roundedrect.qml b/examples/qml/canvas/roundedrect/roundedrect.qml new file mode 100644 index 0000000000..fd86c63a3b --- /dev/null +++ b/examples/qml/canvas/roundedrect/roundedrect.qml @@ -0,0 +1,125 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import "../contents" +Item { + id:container + width:360 + height:600 + + Column { + spacing:5 + anchors.fill:parent + Text { font.pointSize:25; text:"Rounded rectangle"; anchors.horizontalCenter:parent.horizontalCenter} + Canvas { + id:canvas + width:360 + height:360 + smooth:true + renderTarget:Canvas.Image + renderStrategy: Canvas.Immediate + + property int radius: rCtrl.value + property int rectx: rxCtrl.value + property int recty: ryCtrl.value + property int rectWidth: width - 2*rectx + property int rectHeight: height - 2*recty + property string strokeStyle:"blue" + property string fillStyle:"steelblue" + property int lineWidth:lineWidthCtrl.value + property bool fill:true + property bool stroke:true + property real alpha:alphaCtrl.value + + onLineWidthChanged:requestPaint(); + onFillChanged:requestPaint(); + onStrokeChanged:requestPaint(); + onRadiusChanged:requestPaint(); + onRectxChanged:requestPaint(); + onRectyChanged:requestPaint(); + onAlphaChanged:requestPaint(); + + onPaint: { + var ctx = getContext("2d"); + ctx.save(); + ctx.clearRect(0,0,canvas.width, canvas.height); + ctx.strokeStyle = canvas.strokeStyle; + ctx.lineWidth = canvas.lineWidth + ctx.fillStyle = canvas.fillStyle + ctx.globalAlpha = canvas.alpha + ctx.beginPath(); + ctx.moveTo(rectx+radius,recty); // top side + ctx.lineTo(rectx+rectWidth-radius,recty); + // draw top right corner + ctx.arcTo(rectx+rectWidth,recty,rectx+rectWidth,recty+radius,radius); + ctx.lineTo(rectx+rectWidth,recty+rectHeight-radius); // right side + // draw bottom right corner + ctx.arcTo(rectx+rectWidth,recty+rectHeight,rectx+rectWidth-radius,recty+rectHeight,radius); + ctx.lineTo(rectx+radius,recty+rectHeight); // bottom side + // draw bottom left corner + ctx.arcTo(rectx,recty+rectHeight,rectx,recty+rectHeight-radius,radius); + ctx.lineTo(rectx,recty+radius); // left side + // draw top left corner + ctx.arcTo(rectx,recty,rectx+radius,recty,radius); + ctx.closePath(); + if (canvas.fill) + ctx.fill(); + if (canvas.stroke) + ctx.stroke(); + ctx.restore(); + } + } + + Rectangle { + id:controls + width:360 + height:160 + Column { + spacing:3 + Slider {id:lineWidthCtrl; width:300; height:30; min:1; max:10; init:2; name:"Line width"} + Slider {id:rxCtrl; width:300; height:30; min:5; max:30; init:10; name:"rectx"} + Slider {id:ryCtrl; width:300; height:30; min:5; max:30; init:10; name:"recty"} + Slider {id:rCtrl; width:300; height:30; min:10; max:100; init:40; name:"Radius"} + Slider {id:alphaCtrl; width:300; height:30; min:0; max:1; init:1; name:"Alpha"} + } + } + } +} diff --git a/examples/qml/canvas/smile/smile.qml b/examples/qml/canvas/smile/smile.qml new file mode 100644 index 0000000000..28a48a6c81 --- /dev/null +++ b/examples/qml/canvas/smile/smile.qml @@ -0,0 +1,128 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import "../contents" +Item { + id:container + width:360 + height:600 + + Column { + spacing:5 + anchors.fill:parent + Text { font.pointSize:25; text:"Smile with arcs"; anchors.horizontalCenter:parent.horizontalCenter} + + Canvas { + id:canvas + width:360 + height:360 + smooth:true + renderTarget:Canvas.Image + renderStrategy: Canvas.Immediate + + property string strokeStyle:"green" + property string fillStyle:"yellow" + property int lineWidth:lineWidthCtrl.value + property bool fill:true + property bool stroke:true + property real alpha:alphaCtrl.value + property real scaleX : scaleXCtrl.value + property real scaleY : scaleYCtrl.value + property real rotate : rotateCtrl.value + + onLineWidthChanged:requestPaint(); + onFillChanged:requestPaint(); + onStrokeChanged:requestPaint(); + onAlphaChanged:requestPaint(); + onScaleXChanged:requestPaint(); + onScaleYChanged:requestPaint(); + onRotateChanged:requestPaint(); + + Behavior on scaleX { SpringAnimation { spring: 2; damping: 0.2; loops:Animation.Infinite } } + Behavior on scaleY { SpringAnimation { spring: 2; damping: 0.2; loops:Animation.Infinite} } + Behavior on rotate { SpringAnimation { spring: 2; damping: 0.2; loops:Animation.Infinite} } + + onPaint: { + var ctx = canvas.getContext('2d'); + ctx.save(); + ctx.clearRect(0, 0, canvas.width, canvas.height); + ctx.globalAlpha = canvas.alpha; + ctx.strokeStyle = canvas.strokeStyle; + ctx.fillStyle = canvas.fillStyle; + ctx.lineWidth = canvas.lineWidth; + ctx.scale(canvas.scaleX, canvas.scaleY); + ctx.rotate(canvas.rotate); + ctx.beginPath(); + ctx.moveTo(75 + 50 * Math.cos(0), + 75 - 50 * Math.sin(Math.PI*2)); + ctx.arc(75,75,50,0,Math.PI*2,true); // Outer circle + ctx.moveTo(75,70); + ctx.arc(75,70,35,0,Math.PI,false); // Mouth (clockwise) + ctx.moveTo(60,65); + ctx.arc(60,65,5,0,Math.PI*2,true); // Left eye + ctx.moveTo(90 + 5 * Math.cos(0), + 65 - 5 * Math.sin(Math.PI*2)); + ctx.moveTo(90,65); + ctx.arc(90,65,5,0,Math.PI*2,true); // Right eye + ctx.closePath(); + if (canvas.fill) + ctx.fill(); + if (canvas.stroke) + ctx.stroke(); + ctx.restore(); + } + } + + Rectangle { + id:controls + width:360 + height:160 + Column { + spacing:3 + Slider {id:lineWidthCtrl; width:300; height:30; min:1; max:10; init:2; name:"Line width"} + Slider {id:scaleXCtrl; width:300; height:30; min:0.1; max:10; init:1; name:"ScaleX"} + Slider {id:scaleYCtrl; width:300; height:30; min:0.1; max:10; init:1; name:"ScaleY"} + Slider {id:rotateCtrl; width:300; height:30; min:0; max:Math.PI*2; init:0; name:"Rotate"} + Slider {id:alphaCtrl; width:300; height:30; min:0; max:1; init:1; name:"Alpha"} + } + } + } +} diff --git a/examples/qml/canvas/squircle/squircle.png b/examples/qml/canvas/squircle/squircle.png new file mode 100644 index 0000000000..86c69d945f Binary files /dev/null and b/examples/qml/canvas/squircle/squircle.png differ diff --git a/examples/qml/canvas/squircle/squircle.qml b/examples/qml/canvas/squircle/squircle.qml new file mode 100644 index 0000000000..2fc65b67b3 --- /dev/null +++ b/examples/qml/canvas/squircle/squircle.qml @@ -0,0 +1,155 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import "../contents" +Item { + id:container + width:360 + height:600 + + Column { + spacing:5 + anchors.fill:parent + Text { font.pointSize:25; text:"Squircles"; anchors.horizontalCenter:parent.horizontalCenter} + Image { + anchors.horizontalCenter:parent.horizontalCenter + source:"squircle.png" + width:250 + height:25 + } + Canvas { + id:canvas + width:360 + height:360 + smooth:true + renderTarget:Canvas.Image + renderStrategy: Canvas.Immediate + + property string strokeStyle:"blue" + property string fillStyle:"steelblue" + property int lineWidth:2 + property int nSize:nCtrl.value + property real radius:rCtrl.value + property bool fill:true + property bool stroke:false + property real px:xCtrl.value + property real py:yCtrl.value + property real alpha:alphaCtrl.value + + onAlphaChanged:requestPaint(); + onRadiusChanged:requestPaint(); + onLineWidthChanged:requestPaint(); + onNSizeChanged:requestPaint(); + onFillChanged:requestPaint(); + onStrokeChanged:requestPaint(); + onPxChanged:requestPaint(); + onPyChanged:requestPaint(); + + + onPaint: squcirle(); + + function squcirle() { + var ctx = canvas.getContext("2d"); + var N = canvas.nSize; + var R = canvas.radius; + + N=Math.abs(N); + var M=N; + if (N>100) M=100; + if (N<0.00000000001) M=0.00000000001; + + ctx.save(); + ctx.globalAlpha =canvas.alpha; + ctx.fillStyle = "gray"; + ctx.fillRect(0, 0, canvas.width, canvas.height); + + ctx.strokeStyle = canvas.strokeStyle; + ctx.fillStyle = canvas.fillStyle; + ctx.lineWidth = canvas.lineWidth; + + ctx.beginPath(); + var i = 0, x, y; + for (i=0; i<(2*R+1); i++){ + x = Math.round(i-R) + canvas.px; + y = Math.round(Math.pow(Math.abs(Math.pow(R,M)-Math.pow(Math.abs(i-R),M)),1/M)) + canvas.py; + + if (i == 0) + ctx.moveTo(x, y); + else + ctx.lineTo(x, y); + } + + for (i=(2*R); i<(4*R+1); i++){ + x =Math.round(3*R-i)+canvas.px; + y = Math.round(-Math.pow(Math.abs(Math.pow(R,M)-Math.pow(Math.abs(3*R-i),M)),1/M)) + canvas.py; + ctx.lineTo(x, y); + } + ctx.closePath(); + if (canvas.stroke) { + ctx.stroke(); + } + + if (canvas.fill) { + ctx.fill(); + } + + ctx.fillStyle = "yellow"; + ctx.font = "Helvetica 16px"; + ctx.fillText("|X-" + Math.round(canvas.px) + "|^" + N + " + |Y-"+Math.round(canvas.py)+"|^" + N + " = |" + Math.round(R) + "|^" + N, canvas.px - 125, canvas.py); + ctx.restore(); + } + } + + Rectangle { + id:controls + width:360 + height:160 + Column { + spacing:3 + Slider {id:nCtrl; width:300; height:30; min:1; max:10; init:4; name:"N"} + Slider {id:rCtrl; width:300; height:30; min:30; max:180; init:100; name:"Radius"} + Slider {id:xCtrl; width:300; height:30; min:50; max:300; init:180; name:"X"} + Slider {id:yCtrl; width:300; height:30; min:30; max:300; init:220; name:"Y"} + Slider {id:alphaCtrl; width:300; height:30; min:0; max:1; init:1; name:"Alpha"} + } + } + } +} diff --git a/examples/qml/canvas/stockchart/README b/examples/qml/canvas/stockchart/README new file mode 100644 index 0000000000..2652866ed6 --- /dev/null +++ b/examples/qml/canvas/stockchart/README @@ -0,0 +1,5 @@ +To run: + + make install + QML_IMPORT_PATH=$PWD qmlscene stock.qml + diff --git a/examples/qml/canvas/stockchart/com/nokia/StockChartExample/qmldir b/examples/qml/canvas/stockchart/com/nokia/StockChartExample/qmldir new file mode 100644 index 0000000000..4c60e556d4 --- /dev/null +++ b/examples/qml/canvas/stockchart/com/nokia/StockChartExample/qmldir @@ -0,0 +1 @@ +plugin qmlstockchartexampleplugin diff --git a/examples/qml/canvas/stockchart/model.cpp b/examples/qml/canvas/stockchart/model.cpp new file mode 100644 index 0000000000..42eb2d592f --- /dev/null +++ b/examples/qml/canvas/stockchart/model.cpp @@ -0,0 +1,255 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include "model.h" + +#include +#include +#include +#include +#include + +#include +#include + +StockModel::StockModel(QObject *parent) + : QAbstractListModel(parent) + , _startDate(QDate(1995, 4, 25)) + , _endDate(QDate::currentDate()) + , _dataCycle(StockModel::Daily) + , _manager(0) + , _updating(false) +{ + QHash roles; + roles[StockModel::DateRole] = "date"; + roles[StockModel::SectionRole] = "year"; + roles[StockModel::OpenPriceRole] = "openPrice"; + roles[StockModel::ClosePriceRole] = "closePrice"; + roles[StockModel::HighPriceRole] = "highPrice"; + roles[StockModel::LowPriceRole] = "lowPrice"; + roles[StockModel::VolumeRole] = "volume"; + roles[StockModel::AdjustedPriceRole] = "adjustedPrice"; + setRoleNames(roles); + + connect(this, SIGNAL(stockNameChanged()), SLOT(requestData())); + connect(this, SIGNAL(startDateChanged()), SLOT(requestData())); + connect(this, SIGNAL(endDateChanged()), SLOT(requestData())); + connect(this, SIGNAL(dataCycleChanged()), SLOT(requestData())); + + _manager = new QNetworkAccessManager(this); + connect(_manager, SIGNAL(finished(QNetworkReply*)), this, SLOT(update(QNetworkReply*))); + +} + +int StockModel::rowCount(const QModelIndex & parent) const { + Q_UNUSED(parent); + return _prices.count(); +} + +StockPrice* StockModel::stockPriceAtIndex(int idx) const +{ + if (idx >=0 && idx < _prices.size()) { + return _prices[idx]; + } + return 0; +} + + +void StockModel::requestData() +{ + if (!_updating) { + _updating = true; + QMetaObject::invokeMethod(this, "doRequest", Qt::QueuedConnection); + } +} + +void StockModel::doRequest() +{ + /* + Fetch stock data from yahoo finance: + url: http://ichart.finance.yahoo.com/table.csv?s=NOK&a=5&b=11&c=2010&d=7&e=23&f=2010&g=d&ignore=.csv + s:stock name/id, a:start day, b:start month, c:start year default: 25 April 1995, oldest c= 1962 + d:end day, e:end month, f:end year, default:today (data only available 3 days before today) + g:data cycle(d daily, w weekly, m monthly, v Dividend) + */ + if (_manager && !_stockName.isEmpty() && _endDate > _startDate) { + QString query("http://ichart.finance.yahoo.com/table.csv?s=%1&a=%2&b=%3&c=%4&d=%5&e=%6&f=%7&g=%8&ignore=.csv"); + query = query.arg(_stockName) + .arg(_startDate.day()).arg(_startDate.month()).arg(_startDate.year()) + .arg(_endDate.day()).arg(_endDate.month()).arg(_endDate.year()) + .arg(dataCycleString()); + + qDebug() << "request stock data:" << query; + QNetworkReply* reply = _manager->get(QNetworkRequest(QUrl(query))); + connect(reply, SIGNAL(downloadProgress(qint64,qint64)), SIGNAL(downloadProgress(qint64,qint64))); + } +} + +void StockModel::update(QNetworkReply *reply) +{ + _updating = false; + + if (reply) { + if (reply->error() == QNetworkReply::NoError) { + beginResetModel(); + + foreach (StockPrice* p, _prices) { + p->deleteLater(); + } + + _prices.clear(); + + while (!reply->atEnd()) { + QString line = reply->readLine(); + QStringList fields = line.split(','); + + //data format:Date,Open,High,Low,Close,Volume,Adjusted close price + //example: 2011-06-24,6.03,6.04,5.88,5.88,20465200,5.88 + if (fields.size() == 7) { + StockPrice* price = new StockPrice(this); + price->setDate(QDate::fromString(fields[0], Qt::ISODate)); + price->setOpenPrice(fields[1].toFloat()); + price->setHighPrice(fields[2].toFloat()); + price->setLowPrice(fields[3].toFloat()); + price->setClosePrice(fields[4].toFloat()); + price->setVolume(fields[5].toInt()); + price->setAdjustedPrice(fields[6].toFloat()); + _prices.prepend(price); + } + } + qDebug() << "get stock data successfully, total:" << _prices.count() << "records."; + } else { + qDebug() << "get stock data failed:" << reply->errorString(); + } + reply->deleteLater(); + endResetModel(); + emit dataChanged(QModelIndex(), QModelIndex()); + } +} + +QVariant StockModel::data(const QModelIndex & index, int role) const { + if (index.row() < 0 || index.row() > _prices.count()) + return QVariant(); + + const StockPrice* price = _prices[index.row()]; + if (role == StockModel::DateRole) + return price->date(); + else if (role == StockModel::OpenPriceRole) + return price->openPrice(); + else if (role == StockModel::ClosePriceRole) + return price->closePrice(); + else if (role == StockModel::HighPriceRole) + return price->highPrice(); + else if (role == StockModel::LowPriceRole) + return price->lowPrice(); + else if (role == StockModel::AdjustedPriceRole) + return price->adjustedPrice(); + else if (role == StockModel::VolumeRole) + return price->volume(); + else if (role == StockModel::SectionRole) + return price->date().year(); + return QVariant(); +} + +QString StockModel::stockName() const +{ + return _stockName; +} +void StockModel::setStockName(const QString& name) +{ + if (_stockName != name) { + _stockName = name; + emit stockNameChanged(); + } +} + +QDate StockModel::startDate() const +{ + return _startDate; +} +void StockModel::setStartDate(const QDate& date) +{ + if (_startDate.isValid() && _startDate != date) { + _startDate = date; + emit startDateChanged(); + } +} + +QDate StockModel::endDate() const +{ + return _endDate; +} +void StockModel::setEndDate(const QDate& date) +{ + if (_endDate.isValid() && _endDate != date) { + _endDate = date; + emit endDateChanged(); + } +} + +StockModel::StockDataCycle StockModel::dataCycle() const +{ + return _dataCycle; +} + +QString StockModel::dataCycleString() const +{ + switch (_dataCycle) { + case StockModel::Daily: + return QString('d'); + break; + case StockModel::Weekly: + return QString('w'); + case StockModel::Monthly: + return QString('m'); + case StockModel::Dividend: + return QString('v'); + } + + return QString('d'); +} + + +void StockModel::setDataCycle(StockModel::StockDataCycle cycle) +{ + if (_dataCycle != cycle) { + _dataCycle = cycle; + emit dataCycleChanged(); + } +} diff --git a/examples/qml/canvas/stockchart/model.h b/examples/qml/canvas/stockchart/model.h new file mode 100644 index 0000000000..95e6f4891c --- /dev/null +++ b/examples/qml/canvas/stockchart/model.h @@ -0,0 +1,166 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include +#include + +class StockPrice : public QObject +{ + Q_OBJECT + Q_PROPERTY(QDate date READ date) + Q_PROPERTY(qreal openPrice READ openPrice) + Q_PROPERTY(qreal closePrice READ closePrice) + Q_PROPERTY(qreal highPrice READ highPrice) + Q_PROPERTY(qreal lowPrice READ lowPrice) + Q_PROPERTY(qint32 volume READ volume) + Q_PROPERTY(qreal adjustedPrice READ adjustedPrice) +public: + + StockPrice(QObject *parent = 0) + : QObject(parent) + , _openPrice(-1) + , _closePrice(-1) + , _highPrice(-1) + , _lowPrice(-1) + , _volume(-1) + , _adjustedPrice(-1) + { + } + QDate date() const {return _date;} + qreal openPrice() const {return _openPrice; } + qreal closePrice() const {return _closePrice;} + qreal highPrice() const {return _highPrice;} + qreal lowPrice() const{return _lowPrice;} + qreal adjustedPrice() const{return _adjustedPrice;} + qint32 volume() const{return _volume;} + + void setDate(const QDate& date){_date = date;} + void setOpenPrice(qreal price){_openPrice = price;} + void setClosePrice(qreal price){_closePrice = price;} + void setHighPrice(qreal price){_highPrice = price;} + void setLowPrice(qreal price){_lowPrice = price;} + void setAdjustedPrice(qreal price) {_adjustedPrice = price;} + void setVolume(qint32 volume) {_volume = volume;} + +private: + QDate _date; + qreal _openPrice; + qreal _closePrice; + qreal _highPrice; + qreal _lowPrice; + qint32 _volume; + qreal _adjustedPrice; +}; + +class QNetworkReply; +class QNetworkAccessManager; +class StockModel : public QAbstractListModel +{ + Q_OBJECT + + Q_PROPERTY(QString stockName READ stockName WRITE setStockName NOTIFY stockNameChanged) + Q_PROPERTY(QDate startDate READ startDate WRITE setStartDate NOTIFY startDateChanged) + Q_PROPERTY(QDate endDate READ endDate WRITE setEndDate NOTIFY endDateChanged) + Q_PROPERTY(StockDataCycle dataCycle READ dataCycle WRITE setDataCycle NOTIFY dataCycleChanged) + + Q_ENUMS(StockDataCycle) +public: + enum StockDataCycle { + Daily, + Weekly, + Monthly, + Dividend + }; + + enum StockModelRoles { + DateRole = Qt::UserRole + 1, + SectionRole, + OpenPriceRole, + ClosePriceRole, + HighPriceRole, + LowPriceRole, + VolumeRole, + AdjustedPriceRole + }; + + StockModel(QObject *parent = 0); + + QString stockName() const; + void setStockName(const QString& name); + + QDate startDate() const; + void setStartDate(const QDate& date); + + QDate endDate() const; + void setEndDate(const QDate& date); + + StockDataCycle dataCycle() const; + void setDataCycle(StockDataCycle cycle); + + int rowCount(const QModelIndex & parent = QModelIndex()) const; + + QVariant data(const QModelIndex & index, int role = Qt::DisplayRole) const; + +signals: + void stockNameChanged(); + void startDateChanged(); + void endDateChanged(); + void dataCycleChanged(); + void downloadProgress(qint64 bytesReceived, qint64 bytesTotal); + +public slots: + void requestData(); + StockPrice* stockPriceAtIndex(int idx) const; +private slots: + void doRequest(); + void update(QNetworkReply* reply); +private: + QString dataCycleString() const; + QList _prices; + QString _stockName; + QDate _startDate; + QDate _endDate; + StockDataCycle _dataCycle; + QNetworkAccessManager* _manager; + bool _updating; +}; + + + + diff --git a/examples/qml/canvas/stockchart/plugin.cpp b/examples/qml/canvas/stockchart/plugin.cpp new file mode 100644 index 0000000000..3b354e2b31 --- /dev/null +++ b/examples/qml/canvas/stockchart/plugin.cpp @@ -0,0 +1,60 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include +#include +#include "model.h" + +class QStockChartExampleQmlPlugin : public QQmlExtensionPlugin +{ + Q_OBJECT +public: + void registerTypes(const char *uri) + { + Q_ASSERT(uri == QLatin1String("com.nokia.StockChartExample")); + qmlRegisterType(uri, 1, 0, "StockModel"); + qmlRegisterType(uri, 1, 0, "StockPrice"); + } +}; + +#include "plugin.moc" + +Q_EXPORT_PLUGIN2(qmlstockchartexampleplugin, QStockChartExampleQmlPlugin); diff --git a/examples/qml/canvas/stockchart/stock.qml b/examples/qml/canvas/stockchart/stock.qml new file mode 100644 index 0000000000..1c95fde2ce --- /dev/null +++ b/examples/qml/canvas/stockchart/stock.qml @@ -0,0 +1,726 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +import QtQuick 2.0 +import com.nokia.StockChartExample 1.0 +import "../contents" + +Rectangle { + id:container + width: 360; height: 600 + color: "#343434"; + Image { source: "contents/images/stripes.png"; fillMode: Image.Tile; anchors.fill: parent; opacity: 1 } + + + TitleBar { + id: titleBar + width: parent.width + anchors.top : container.top + height: 40 + opacity: 0.9 + } + + StockModel { + id:stockModel + dataCycle: StockModel.Daily + function dataCycleName() { + if (dataCycle === StockModel.Weekly) + return "Weekly"; + else if (dataCycle === StockModel.Monthly) + return "Monthly"; + return "Daily"; + } + + onDataChanged: { + if (view.viewType == "chart") { + canvas.requestPaint(); + } + } + onDownloadProgress: { + if (bytesReceived == bytesTotal && bytesTotal != -1) { + progress.opacity = 0; + } else { + progress.opacity = 0.8; + progress.text = "downloading " + stockModel.dataCycleName() + " data ..."+ Math.round(bytesReceived/1000) + " KB"; + } + } + + property string description:""; + } + + Stocks {id:stocks} + + Rectangle { + id: header + width: parent.width + height: 20 + color: "steelblue" + opacity: 0 + Row { + spacing: 2 + Text { + id:t + font.pointSize:15 + horizontalAlignment:Text.AlignHCenter + font.bold: true + font.underline:true + } + Rectangle { + height:20 + width:50 + Text {text:"Stock list"; font.pointSize:15; font.bold: true} + } + } + } + + ListView { + id:stockList + width: parent.width + anchors.bottom: container.bottom + anchors.top : titleBar.bottom + focus: true + keyNavigationWraps: true + spacing:1 + opacity: 1 + model: stocks + + Component.onCompleted: opacity = 0.9; + onOpacityChanged: { + titleBar.title = "Top 100 NASDAQ stocks" + } + + + delegate : Rectangle { + height: 30 + width: view.width + color: { + if (ListView.isCurrentItem) + return focus ? "lightyellow" : "pink"; + return index % 2 == 0 ? "lightblue" : "lightsteelblue" + } + Text { + font.pointSize:20 + text: index + ". " + stockId + " \t(" + name + ")"; + } + MouseArea { + anchors.fill: parent; + onDoubleClicked: { + stockList.opacity = 0; + stockModel.stockName = stockId; + stockModel.description = "NASDAQ:" + stockId + " (" + name + ")"; + view.opacity = 1; + view.viewType = "chart"; + canvas.opacity = 0.7; + } + onClicked: stockList.currentIndex = index + }//mousearea + }//delegate + } + + ListView { + id:view + width: container.width + height: container.height - 50 + anchors.bottom: container.bottom + focus: true + keyNavigationWraps: true + + spacing:1 + opacity: 0 + model: stockModel + highlightFollowsCurrentItem: false + highlightRangeMode: ListView.StrictlyEnforceRange + preferredHighlightBegin:50 + preferredHighlightEnd : height - 50 + highlight: listHighlight + + //header : Text {} + delegate: listDelegate + snapMode: ListView.SnapToItem + + property string viewType : "list" + property int topIndex:indexAt(0,contentY); + property int bottomIndex:indexAt(0, contentY+height); + + onCountChanged: { + + titleBar.title = stockModel.description + " " + Qt.formatDate(stockModel.startDate, "yyyy-MM-dd") + " - " + + Qt.formatDate(stockModel.endDate, "yyyy-MM-dd") + " " + stockModel.dataCycleName() + + " records:" + view.count; + + } + + Component { + id: listDelegate + Rectangle { + height: 20 + width: view.width + border.color: "lightsteelblue" + border.width: 1 + color: { + if (ListView.isCurrentItem) + return focus ? "lightyellow" : "pink"; + + return index % 2 == 0 ? "lightblue" : "lightsteelblue" + } + Text { + font.pointSize:13 + text: index + ". " + Qt.formatDate(date, "yyyy-MM-dd") + + "\t " + Math.round(openPrice*100)/100 + + "\t " + Math.round(highPrice*100)/100 + + "\t " + Math.round(lowPrice*100)/100 + + "\t " + Math.round(closePrice*100)/100 + + "\t " + volume + "\t " + + Math.round(adjustedPrice*100)/100; + } + MouseArea {anchors.fill: parent; onClicked: view.currentIndex = index} + } + } + + Component { + id: chartDelegate + Rectangle { + height: 20 + width: view.width/view.count * canvas.scaleX + border.color: "lightsteelblue" + border.width: 1 + color: { + if (ListView.isCurrentItem) + return focus ? "lightyellow" : "pink"; + + return index % 2 == 0 ? "lightblue" : "lightsteelblue" + } + + Text { + anchors.bottom: parent.bottom + font.pointSize: { + if (parent.width <= 4) + return 1; + if (parent.width <= 50) + return parent.width/4; + return 15; + } + horizontalAlignment:Text.AlignHCenter + verticalAlignment:Text.AlignBottom + text:font.pointSize > 1 ? Qt.formatDate(date, "d/M/yy") : "" + } + MouseArea {anchors.fill: parent; onClicked: view.currentIndex = index} + } + } + + Component { + id:chartHighlight + Rectangle { radius: 5; width:40; height: 20; color: "lightsteelblue" } + } + + Component { + id:listHighlight + Rectangle { radius: 5; width:container.width; height: 20; color: "lightsteelblue" } + } + + + + + onViewTypeChanged : { + if (viewType == "list") { + view.orientation = ListView.Vertical; + view.delegate = listDelegate; +// view.section.property = "year"; +// view.section.criteria = ViewSection.FullString; +// view.section.delegate = sectionHeading; + view.highlight = listHighlight; + view.opacity = 1; + canvas.opacity = 0; + // comment.opacity = 0; + + } else if (viewType == "chart") { + view.orientation = ListView.Horizontal; + view.delegate = chartDelegate; + //comment.opacity = 0.6; + + view.opacity = 1; + view.height = 30 + + canvas.opacity = 0.7; + canvas.requestPaint(); + } else { + viewType = "list"; + } + } + + + onCurrentIndexChanged: { + //header.updateCurrent(stockModel.stockPriceAtIndex(view.currentIndex)); + if (viewType == "chart") { + canvas.first = Math.round(view.currentIndex - view.currentIndex / canvas.scaleX); + canvas.last = Math.round(view.currentIndex + (view.count - view.currentIndex) / canvas.scaleX); + + canvas.requestPaint(); + } + } + onContentYChanged: { // keep "current" item visible + topIndex = indexAt(0,contentY); + bottomIndex = indexAt(0, contentY+height); + + if (topIndex != -1 && currentIndex <= topIndex) + currentIndex = topIndex+1; + else if (bottomIndex != -1 && currentIndex >= bottomIndex) + currentIndex = bottomIndex-1; + if (viewType == "chart") + canvas.requestPaint(); + } + + onContentXChanged: { // keep "current" item visible + topIndex = indexAt(contentX,0); + bottomIndex = indexAt(contentX+width, 0); + + if (topIndex != -1 && currentIndex <= topIndex) + currentIndex = topIndex+1; + else if (bottomIndex != -1 && currentIndex >= bottomIndex) + currentIndex = bottomIndex-1; + if (viewType == "chart") + canvas.requestPaint(); + } + + MouseArea { + anchors.fill: parent + onDoubleClicked: { + if (view.viewType == "list") + view.viewType = "chart"; + else + view.viewType = "list"; + } + } + } + + + + Canvas { + id:canvas + anchors.top : titleBar.bottom + anchors.bottom : view.top + width:container.width; + opacity:0 + renderTarget: Canvas.Image + renderStrategy: Canvas.Immediate + property bool running:false + property int frames:first + property int mouseX:0; + property int mouseY:0; + property int mousePressedX:0; + property int mousePressedY:0; + property int movedY:0 + property real scaleX:1.0; + property real scaleY:1.0; + property int first:0; + property int last:view.count - 1; + + onOpacityChanged: { + if (opacity > 0) + requestPaint(); + } + Text { + id:comment + x:100 + y:50 + font.pointSize: 20 + color:"white" + opacity: 0.7 + focus:false + text: stockModel.description + function updateCurrent(price) + { + if (price !== undefined) { + text =stockModel.description + "\n" + + Qt.formatDate(price.date, "yyyy-MM-dd") + " OPEN:" + + Math.round(price.openPrice*100)/100 + " HIGH:" + + Math.round(price.highPrice*100)/100 + " LOW:" + + Math.round(price.lowPrice*100)/100 + " CLOSE:" + + Math.round(price.closePrice*100)/100 + " VOLUME:" + + price.volume; + } + } + } + + Text { + id:priceAxis + x:25 + y:25 + font.pointSize: 15 + color:"yellow" + opacity: 0.7 + focus: false + } + Text { + id:volumeAxis + x:canvas.width - 200 + y:25 + font.pointSize: 15 + color:"yellow" + opacity: 0.7 + } + + Rectangle { + id:progress + x:canvas.width/2 - 100 + y:canvas.height/2 + width:childrenRect.width + height: childrenRect.height + opacity: 0 + color:"white" + property string text; + Text { + text:parent.text + font.pointSize: 20 + } + } + + Button { + id:runButton + text:"Run this chart" + y:0 + x:canvas.width/2 - 50 + opacity: 0.5 + onClicked: { + if (canvas.running) { + canvas.running = false; + canvas.frames = canvas.first; + canvas.requestPaint(); + text = "Run this chart"; + comment.text = stockModel.description; + } else { + text = " Stop running "; + canvas.runChart(); + } + } + } + Button { + id:returnButton + text:"Stocks" + y:0 + anchors.left : runButton.right + anchors.leftMargin : 20 + opacity: 0.5 + onClicked: { + stockList.opacity = 1; + canvas.opacity = 0; + } + } + PinchArea { + anchors.fill: parent + onPinchUpdated : { + var current = pinch.center; + var scale = pinch.scale; + console.log("center:" + pinch.center + " scale:" + pinch.scale); + //canvas.requestPaint(); + } + } + + MouseArea { + anchors.fill: parent + + onDoubleClicked: { + if (stockModel.dataCycle == StockModel.Daily) + stockModel.dataCycle = StockModel.Weekly; + else if (stockModel.dataCycle == StockModel.Weekly) + stockModel.dataCycle = StockModel.Monthly; + else + stockModel.dataCycle = StockModel.Daily; + } + + onPositionChanged: { + if (mouse.modifiers & Qt.ControlModifier) { + if (canvas.mouseX == 0 && canvas.mouseY == 0) { + canvas.mouseX = mouse.x; + canvas.mouseY = mouse.y; + } + } else{ + var w = (view.width/view.count)*canvas.scaleX; + + //canvas.movedY += Math.round((canvas.mousePressedY - mouse.y)/2); + + var movedX = Math.round((canvas.mousePressedX - mouse.x)/w); + if (movedX != 0 || canvas.movedY != 0) { + if (canvas.first + movedX >= 0 && canvas.last + movedX < view.count) { + canvas.first += movedX; + canvas.last += movedX; + } + canvas.requestPaint(); + } + } + } + + onPressed: { + canvas.mousePressedX = mouse.x; + canvas.mousePressedY = mouse.y; + } + + onReleased : { + if (mouse.modifiers & Qt.ControlModifier) { + var sx = mouse.x - canvas.mouseX; + var sy = canvas.mouseY - mouse.y; + + if (Math.abs(sx) < 50) sx = 0; + if (Math.abs(sy) < 50) sy = 0; + + if (sx > 0) + canvas.scaleX *= sx/100 +1; + else + canvas.scaleX *= 1/(-sx/100 + 1); + + if (sy > 0) + canvas.scaleY *= sy/100 +1; + else + canvas.scaleY *= 1/(-sy/100 + 1); + + if (canvas.scaleX < 1) + canvas.scaleX = 1; + + //console.log("scaleX:" + canvas.scaleX + ", scaleY:" + canvas.scaleY); + + canvas.first = Math.round(view.currentIndex - view.currentIndex / canvas.scaleX); + canvas.last = Math.round(view.currentIndex + (view.count - view.currentIndex) / canvas.scaleX); + + canvas.mouseX = 0; + canvas.mouseY = 0; + canvas.mousePressedX = 0; + canvas.mousePressedY = 0; + canvas.requestPaint(); + } + } + } + + function runChart() { + canvas.running = true; + requestPaint(); + } + + function showPriceAt(x) { + var w = (view.width/view.count)*canvas.scaleX; + //header.updateCurrent(stockModel.stockPriceAtIndex(canvas.first + Math.round(x/w))); + //console.log("x:" + x + " w:" + w + " index:" + (canvas.first + Math.round(x/w))); + } + + function drawPrice(ctx, from, to, color, price, points, highest) + { + ctx.globalAlpha = 0.7; + ctx.strokeStyle = color; + ctx.lineWidth = 1; + ctx.beginPath(); + + //price x axis + priceAxis.text = "price:" + Math.round(highest); + ctx.font = "bold 12px sans-serif"; + + ctx.strokeText("price", 25, 25); + for (var j = 1; j < 30; j++) { + var val = (highest * j) / 30; + val = canvas.height * (1 - val/highest); + ctx.beginPath(); + + ctx.moveTo(10, val); + if (j % 5) + ctx.lineTo(15, val); + else + ctx.lineTo(20, val); + ctx.stroke(); + } + + ctx.beginPath(); + ctx.moveTo(10, 0); + ctx.lineTo(10, canvas.height); + ctx.stroke(); + + + var w = canvas.width/points.length; + var end = canvas.running? canvas.frames - canvas.first :points.length; + for (var i = 0; i < end; i++) { + var x = points[i].x; + var y = points[i][price]; + y += canvas.movedY; + + y = canvas.height * (1 - y/highest); + if (i == 0) { + ctx.moveTo(x+w/2, y); + } else { + ctx.lineTo(x+w/2, y); + } + } + ctx.stroke(); + } + + function drawKLine(ctx, from, to, points, highest) + { + ctx.globalAlpha = 0.4; + ctx.lineWidth = 2; + var end = canvas.running? canvas.frames - canvas.first :points.length; + for (var i = 0; i < end; i++) { + var x = points[i].x; + var open = canvas.height * (1 - points[i].open/highest) - canvas.movedY; + var close = canvas.height * (1 - points[i].close/highest) - canvas.movedY; + var high = canvas.height * (1 - points[i].high/highest) - canvas.movedY; + var low = canvas.height * (1 - points[i].low/highest) - canvas.movedY; + + var top, bottom; + if (close <= open) { + ctx.fillStyle = Qt.rgba(1, 0, 0, 1); + ctx.strokeStyle = Qt.rgba(1, 0, 0, 1); + top = close; + bottom = open; + } else { + ctx.fillStyle = Qt.rgba(0, 1, 0, 1); + ctx.strokeStyle = Qt.rgba(0, 1, 0, 1); + top = open; + bottom = close; + } + + var w1, w2; + w1 = canvas.width/points.length; + w2 = w1 > 10 ? w1/2 : w1; + + ctx.fillRect(x + (w1 - w2)/2, top, w2, bottom - top); + ctx.beginPath(); + ctx.moveTo(x+w1/2, high); + ctx.lineTo(x+w1/2, low); + ctx.stroke(); + } + ctx.globalAlpha = 1; + + } + + function drawVolume(ctx, from, to, color, price, points, highest) + { + ctx.fillStyle = color; + ctx.globalAlpha = 0.6; + ctx.strokeStyle = Qt.rgba(0.8, 0.8, 0.8, 1); + ctx.lineWidth = 1; + + //volume x axis + volumeAxis.text = "volume:" + Math.round(highest/(1000*100)) + "M"; + for (var j = 1; j < 30; j++) { + var val = (highest * j) / 30; + val = canvas.height * (1 - val/highest); + ctx.beginPath(); + if (j % 5) + ctx.moveTo(canvas.width - 15, val); + else + ctx.moveTo(canvas.width - 20, val); + ctx.lineTo(canvas.width - 10, val); + ctx.stroke(); + } + + ctx.beginPath(); + ctx.moveTo(canvas.width - 10, 0); + ctx.lineTo(canvas.width - 10, canvas.height); + ctx.stroke(); + + var end = canvas.running? canvas.frames - canvas.first :points.length; + for (var i = 0; i < end; i++) { + var x = points[i].x; + var y = points[i][price]; + y = canvas.height * (1 - y/highest); + ctx.fillRect(x, y, canvas.width/points.length, canvas.height - y); + } + } +/* + onPainted : { + if (canvas.running) { + if (frames >= last) { + canvas.running = false; + canvas.frames = first; + runButton.text = "Run this chart"; + comment.text = stockModel.description; + requestPaint(); + } else { + frames += Math.round(view.count / 100); + if (frames > last) frames = last; + var price = stockModel.stockPriceAtIndex(frames); + if (price) { + comment.updateCurrent(price); + } + + requestPaint(); + } + } + } +*/ + onPaint: { + if (view.currentIndex <= 0) + first = 0; + if (last >= view.count) + last = view.count - 1; + + //console.log("painting... first:" + first + ", last:" + last + " current:" + view.currentIndex); + var ctx = canvas.getContext("2d"); + ctx.save(); + + ctx.globalCompositeOperation = "source-over"; + ctx.lineWidth = 1; + ctx.lineJoin = "round"; + ctx.fillStyle = "rgba(0,0,0,0)"; + + ctx.fillRect(0, 0, canvas.width, canvas.height); + + + + var highestPrice = 500/canvas.scaleY; + var highestValume = 600 * 1000 * 1000/canvas.scaleY; + var points = []; + for (var i = 0; i <= last - first; i++) { + var price = stockModel.stockPriceAtIndex(i + first); + points.push({ + x: i*canvas.width/(last-first+1), + open: price.openPrice, + close: price.closePrice, + high:price.highPrice, + low:price.lowPrice, + volume:price.volume + }); + } + + drawPrice(ctx, first, last, Qt.rgba(1, 0, 0, 1),"high", points, highestPrice); + drawPrice(ctx, first, last, Qt.rgba(0, 1, 0, 1),"low", points, highestPrice); + drawPrice(ctx, first, last, Qt.rgba(0, 0, 1, 1),"open", points, highestPrice); + drawPrice(ctx, first, last, Qt.rgba(0.5, 0.5, 0.5, 1),"close", points, highestPrice); + drawVolume(ctx, first, last, Qt.rgba(0.3, 0.5, 0.7, 1),"volume", points, highestValume); + drawKLine(ctx, first, last, points, highestPrice); + ctx.restore(); + } + } +} diff --git a/examples/qml/canvas/stockchart/stockchart.pro b/examples/qml/canvas/stockchart/stockchart.pro new file mode 100644 index 0000000000..0e3ca82c44 --- /dev/null +++ b/examples/qml/canvas/stockchart/stockchart.pro @@ -0,0 +1,20 @@ +TEMPLATE = lib +CONFIG += qt plugin +QT += qml network + +DESTDIR = com/nokia/StockChartExample +TARGET = qmlstockchartexampleplugin + +SOURCES += model.cpp plugin.cpp +HEADERS += model.h +qqmlsources.files += \ + com/nokia/StockChartExample/qmldir \ + stock.qml + +qqmlsources.path += $$[QT_INSTALL_EXAMPLES]/qtdeclarative/qml/plugins/com/nokia/StockChartExample + +sources.files += stockchart.pro model.h model.cpp plugin.cpp README +sources.path += $$[QT_INSTALL_EXAMPLES]/qtdeclarative/qml/plugins +target.path += $$[QT_INSTALL_EXAMPLES]/qtdeclarative/qml/plugins/com/nokia/StockChartExample + +INSTALLS += qqmlsources sources target diff --git a/examples/qml/canvas/tiger/tiger.js b/examples/qml/canvas/tiger/tiger.js new file mode 100644 index 0000000000..4be0d26c9d --- /dev/null +++ b/examples/qml/canvas/tiger/tiger.js @@ -0,0 +1,721 @@ +var tiger = [ + {"fill": "#ffffff", "stroke":"#000000", "width":0.172, + "path":"M-122.304 84.285C-122.304 84.285 -122.203 86.179 -123.027 86.16C-123.851 86.141 -140.305 38.066 -160.833 40.309C-160.833 40.309 -143.05 32.956 -122.304 84.285z"} + , + {"fill": "#ffffff", "stroke":"#000000", "width":0.172, + "path":"M-118.774 81.262C-118.774 81.262 -119.323 83.078 -120.092 82.779C-120.86 82.481 -119.977 31.675 -140.043 26.801C-140.043 26.801 -120.82 25.937 -118.774 81.262z"} + , + {"fill": "#ffffff", "stroke":"#000000", "width":0.172, + "path":"M-91.284 123.59C-91.284 123.59 -89.648 124.55 -90.118 125.227C-90.589 125.904 -139.763 113.102 -149.218 131.459C-149.218 131.459 -145.539 112.572 -91.284 123.59z"} + , + {"fill": "#ffffff", "stroke":"#000000", "width":0.172, + "path":"M-94.093 133.801C-94.093 133.801 -92.237 134.197 -92.471 134.988C-92.704 135.779 -143.407 139.121 -146.597 159.522C-146.597 159.522 -149.055 140.437 -94.093 133.801z"} + , + {"fill": "#ffffff", "stroke":"#000000", "width":0.172, + "path":"M-98.304 128.276C-98.304 128.276 -96.526 128.939 -96.872 129.687C-97.218 130.435 -147.866 126.346 -153.998 146.064C-153.998 146.064 -153.646 126.825 -98.304 128.276z"} + , + {"fill": "#ffffff", "stroke":"#000000", "width":0.172, + "path":"M-109.009 110.072C-109.009 110.072 -107.701 111.446 -108.34 111.967C-108.979 112.488 -152.722 86.634 -166.869 101.676C-166.869 101.676 -158.128 84.533 -109.009 110.072z"} + , + {"fill": "#ffffff", "stroke":"#000000", "width":0.172, + "path":"M-116.554 114.263C-116.554 114.263 -115.098 115.48 -115.674 116.071C-116.25 116.661 -162.638 95.922 -174.992 112.469C-174.992 112.469 -168.247 94.447 -116.554 114.263z"} + , + {"fill": "#ffffff", "stroke":"#000000", "width":0.172, + "path":"M-119.154 118.335C-119.154 118.335 -117.546 119.343 -118.036 120.006C-118.526 120.669 -167.308 106.446 -177.291 124.522C-177.291 124.522 -173.066 105.749 -119.154 118.335z"} + , + {"fill": "#ffffff", "stroke":"#000000", "width":0.172, + "path":"M-108.42 118.949C-108.42 118.949 -107.298 120.48 -107.999 120.915C-108.7 121.35 -148.769 90.102 -164.727 103.207C-164.727 103.207 -153.862 87.326 -108.42 118.949z"} + , + {"fill": "#ffffff", "stroke":"#000000", "width":0.172, + "path":"M-128.2 90C-128.2 90 -127.6 91.8 -128.4 92C-129.2 92.2 -157.8 50.2 -177.001 57.8C-177.001 57.8 -161.8 46 -128.2 90z"} + , + {"fill": "#ffffff", "stroke":"#000000", "width":0.172, + "path":"M-127.505 96.979C-127.505 96.979 -126.53 98.608 -127.269 98.975C-128.007 99.343 -164.992 64.499 -182.101 76.061C-182.101 76.061 -169.804 61.261 -127.505 96.979z"} + , + {"fill": "#ffffff", "stroke":"#000000", "width":0.172, + "path":"M-127.62 101.349C-127.62 101.349 -126.498 102.88 -127.199 103.315C-127.9 103.749 -167.969 72.502 -183.927 85.607C-183.927 85.607 -173.062 69.726 -127.62 101.349z"} + , + {"fill": "#ffffff", "stroke":"#000000", + "path":"M-129.83 103.065C-129.327 109.113 -128.339 115.682 -126.6 118.801C-126.6 118.801 -130.2 131.201 -121.4 144.401C-121.4 144.401 -121.8 151.601 -120.2 154.801C-120.2 154.801 -116.2 163.201 -111.4 164.001C-107.516 164.648 -98.793 167.717 -88.932 169.121C-88.932 169.121 -71.8 183.201 -75 196.001C-75 196.001 -75.4 212.401 -79 214.001C-79 214.001 -67.4 202.801 -77 219.601L-81.4 238.401C-81.4 238.401 -55.8 216.801 -71.4 235.201L-81.4 261.201C-81.4 261.201 -61.8 242.801 -69 251.201L-72.2 260.001C-72.2 260.001 -29 232.801 -59.8 262.401C-59.8 262.401 -51.8 258.801 -47.4 261.601C-47.4 261.601 -40.6 260.401 -41.4 262.001C-41.4 262.001 -62.2 272.401 -65.8 290.801C-65.8 290.801 -57.4 280.801 -60.6 291.601L-60.2 303.201C-60.2 303.201 -56.2 281.601 -56.6 319.201C-56.6 319.201 -37.4 301.201 -49 322.001L-49 338.801C-49 338.801 -33.8 322.401 -40.2 335.201C-40.2 335.201 -30.2 326.401 -34.2 341.601C-34.2 341.601 -35 352.001 -30.6 340.801C-30.6 340.801 -14.6 310.201 -20.6 336.401C-20.6 336.401 -21.4 355.601 -16.6 340.801C-16.6 340.801 -16.2 351.201 -7 358.401C-7 358.401 -8.2 307.601 4.6 343.601L8.6 360.001C8.6 360.001 11.4 350.801 11 345.601C11 345.601 25.8 329.201 19 353.601C19 353.601 34.2 330.801 31 344.001C31 344.001 23.4 360.001 25 364.801C25 364.801 41.8 330.001 43 328.401C43 328.401 41 370.802 51.8 334.801C51.8 334.801 57.4 346.801 54.6 351.201C54.6 351.201 62.6 343.201 61.8 340.001C61.8 340.001 66.4 331.801 69.2 345.401C69.2 345.401 71 354.801 72.6 351.601C72.6 351.601 76.6 375.602 77.8 352.801C77.8 352.801 79.4 339.201 72.2 327.601C72.2 327.601 73 324.401 70.2 320.401C70.2 320.401 83.8 342.001 76.6 313.201C76.6 313.201 87.801 321.201 89.001 321.201C89.001 321.201 75.4 298.001 84.2 302.801C84.2 302.801 79 292.401 97.001 304.401C97.001 304.401 81 288.401 98.601 298.001C98.601 298.001 106.601 304.401 99.001 294.401C99.001 294.401 84.6 278.401 106.601 296.401C106.601 296.401 118.201 312.801 119.001 315.601C119.001 315.601 109.001 286.401 104.601 283.601C104.601 283.601 113.001 247.201 154.201 262.801C154.201 262.801 161.001 280.001 165.401 261.601C165.401 261.601 178.201 255.201 189.401 282.801C189.401 282.801 193.401 269.201 192.601 266.401C192.601 266.401 199.401 267.601 198.601 266.401C198.601 266.401 211.801 270.801 213.001 270.001C213.001 270.001 219.801 276.801 220.201 273.201C220.201 273.201 229.401 276.001 227.401 272.401C227.401 272.401 236.201 288.001 236.601 291.601L239.001 277.601L241.001 280.401C241.001 280.401 242.601 272.801 241.801 271.601C241.001 270.401 261.801 278.401 266.601 299.201L268.601 307.601C268.601 307.601 274.601 292.801 273.001 288.801C273.001 288.801 278.201 289.601 278.601 294.001C278.601 294.001 282.601 270.801 277.801 264.801C277.801 264.801 282.201 264.001 283.401 267.601L283.401 260.401C283.401 260.401 290.601 261.201 290.601 258.801C290.601 258.801 295.001 254.801 297.001 259.601C297.001 259.601 284.601 224.401 303.001 243.601C303.001 243.601 310.201 254.401 306.601 235.601C303.001 216.801 299.001 215.201 303.801 214.801C303.801 214.801 304.601 211.201 302.601 209.601C300.601 208.001 303.801 209.601 303.801 209.601C303.801 209.601 308.601 213.601 303.401 191.601C303.401 191.601 309.801 193.201 297.801 164.001C297.801 164.001 300.601 161.601 296.601 153.201C296.601 153.201 304.601 157.601 307.401 156.001C307.401 156.001 307.001 154.401 303.801 150.401C303.801 150.401 282.201 95.6 302.601 117.601C302.601 117.601 314.451 131.151 308.051 108.351C308.051 108.351 298.94 84.341 299.717 80.045L-129.83 103.065z"} + , + {"fill": "#cc7226", "stroke":"#000000", + "path":"M299.717 80.245C300.345 80.426 302.551 81.55 303.801 83.2C303.801 83.2 310.601 94 305.401 75.6C305.401 75.6 296.201 46.8 305.001 58C305.001 58 311.001 65.2 307.801 51.6C303.936 35.173 301.401 28.8 301.401 28.8C301.401 28.8 313.001 33.6 286.201 -6L295.001 -2.4C295.001 -2.4 275.401 -42 253.801 -47.2L245.801 -53.2C245.801 -53.2 284.201 -91.2 271.401 -128C271.401 -128 264.601 -133.2 255.001 -124C255.001 -124 248.601 -119.2 242.601 -120.8C242.601 -120.8 211.801 -119.6 209.801 -119.6C207.801 -119.6 173.001 -156.8 107.401 -139.2C107.401 -139.2 102.201 -137.2 97.801 -138.4C97.801 -138.4 79.4 -154.4 30.6 -131.6C30.6 -131.6 20.6 -129.6 19 -129.6C17.4 -129.6 14.6 -129.6 6.6 -123.2C-1.4 -116.8 -1.8 -116 -3.8 -114.4C-3.8 -114.4 -20.2 -103.2 -25 -102.4C-25 -102.4 -36.6 -96 -41 -86L-44.6 -84.8C-44.6 -84.8 -46.2 -77.6 -46.6 -76.4C-46.6 -76.4 -51.4 -72.8 -52.2 -67.2C-52.2 -67.2 -61 -61.2 -60.6 -56.8C-60.6 -56.8 -62.2 -51.6 -63 -46.8C-63 -46.8 -70.2 -42 -69.4 -39.2C-69.4 -39.2 -77 -25.2 -75.8 -18.4C-75.8 -18.4 -82.2 -18.8 -85 -16.4C-85 -16.4 -85.8 -11.6 -87.4 -11.2C-87.4 -11.2 -90.2 -10 -87.8 -6C-87.8 -6 -89.4 -3.2 -89.8 -1.6C-89.8 -1.6 -89 1.2 -93.4 6.8C-93.4 6.8 -99.8 25.6 -97.8 30.8C-97.8 30.8 -97.4 35.6 -100.2 37.2C-100.2 37.2 -103.8 36.8 -95.4 48.8C-95.4 48.8 -94.6 50 -97.8 52.4C-97.8 52.4 -115 56 -117.4 72.4C-117.4 72.4 -131 87.2 -131 92.4C-131 94.705 -130.729 97.852 -130.03 102.465C-130.03 102.465 -130.6 110.801 -103 111.601C-75.4 112.401 299.717 80.245 299.717 80.245z"} + , + {"fill": "#cc7226", + "path":"M-115.6 102.6C-140.6 63.2 -126.2 119.601 -126.2 119.601C-117.4 154.001 12.2 116.401 12.2 116.401C12.2 116.401 181.001 86 192.201 82C203.401 78 298.601 84.4 298.601 84.4L293.001 67.6C228.201 21.2 209.001 44.4 195.401 40.4C181.801 36.4 184.201 46 181.001 46.8C177.801 47.6 138.601 22.8 132.201 23.6C125.801 24.4 100.459 0.649 115.401 32.4C131.401 66.4 57 71.6 40.2 60.4C23.4 49.2 47.4 78.8 47.4 78.8C65.8 98.8 31.4 82 31.4 82C-3 69.2 -27 94.8 -30.2 95.6C-33.4 96.4 -38.2 99.6 -39 93.2C-39.8 86.8 -47.31 70.099 -79 96.4C-99 113.001 -112.8 91 -112.8 91L-115.6 102.6z"} + , + {"fill": "#e87f3a", + "path":"M133.51 25.346C127.11 26.146 101.743 2.407 116.71 34.146C133.31 69.346 58.31 73.346 41.51 62.146C24.709 50.946 48.71 80.546 48.71 80.546C67.11 100.546 32.709 83.746 32.709 83.746C-1.691 70.946 -25.691 96.546 -28.891 97.346C-32.091 98.146 -36.891 101.346 -37.691 94.946C-38.491 88.546 -45.87 72.012 -77.691 98.146C-98.927 115.492 -112.418 94.037 -112.418 94.037L-115.618 104.146C-140.618 64.346 -125.546 122.655 -125.546 122.655C-116.745 157.056 13.509 118.146 13.509 118.146C13.509 118.146 182.31 87.746 193.51 83.746C204.71 79.746 299.038 86.073 299.038 86.073L293.51 68.764C228.71 22.364 210.31 46.146 196.71 42.146C183.11 38.146 185.51 47.746 182.31 48.546C179.11 49.346 139.91 24.546 133.51 25.346z"} + , + {"fill": "#ea8c4d", + "path":"M134.819 27.091C128.419 27.891 103.685 3.862 118.019 35.891C134.219 72.092 59.619 75.092 42.819 63.892C26.019 52.692 50.019 82.292 50.019 82.292C68.419 102.292 34.019 85.492 34.019 85.492C-0.381 72.692 -24.382 98.292 -27.582 99.092C-30.782 99.892 -35.582 103.092 -36.382 96.692C-37.182 90.292 -44.43 73.925 -76.382 99.892C-98.855 117.983 -112.036 97.074 -112.036 97.074L-115.636 105.692C-139.436 66.692 -124.891 125.71 -124.891 125.71C-116.091 160.11 14.819 119.892 14.819 119.892C14.819 119.892 183.619 89.492 194.819 85.492C206.019 81.492 299.474 87.746 299.474 87.746L294.02 69.928C229.219 23.528 211.619 47.891 198.019 43.891C184.419 39.891 186.819 49.491 183.619 50.292C180.419 51.092 141.219 26.291 134.819 27.091z"} + , + {"fill": "#ec9961", + "path":"M136.128 28.837C129.728 29.637 104.999 5.605 119.328 37.637C136.128 75.193 60.394 76.482 44.128 65.637C27.328 54.437 51.328 84.037 51.328 84.037C69.728 104.037 35.328 87.237 35.328 87.237C0.928 74.437 -23.072 100.037 -26.272 100.837C-29.472 101.637 -34.272 104.837 -35.072 98.437C-35.872 92.037 -42.989 75.839 -75.073 101.637C-98.782 120.474 -111.655 100.11 -111.655 100.11L-115.655 107.237C-137.455 70.437 -124.236 128.765 -124.236 128.765C-115.436 163.165 16.128 121.637 16.128 121.637C16.128 121.637 184.928 91.237 196.129 87.237C207.329 83.237 299.911 89.419 299.911 89.419L294.529 71.092C229.729 24.691 212.929 49.637 199.329 45.637C185.728 41.637 188.128 51.237 184.928 52.037C181.728 52.837 142.528 28.037 136.128 28.837z"} + , + {"fill": "#eea575", + "path":"M137.438 30.583C131.037 31.383 106.814 7.129 120.637 39.383C137.438 78.583 62.237 78.583 45.437 67.383C28.637 56.183 52.637 85.783 52.637 85.783C71.037 105.783 36.637 88.983 36.637 88.983C2.237 76.183 -21.763 101.783 -24.963 102.583C-28.163 103.383 -32.963 106.583 -33.763 100.183C-34.563 93.783 -41.548 77.752 -73.763 103.383C-98.709 122.965 -111.273 103.146 -111.273 103.146L-115.673 108.783C-135.473 73.982 -123.582 131.819 -123.582 131.819C-114.782 166.22 17.437 123.383 17.437 123.383C17.437 123.383 186.238 92.983 197.438 88.983C208.638 84.983 300.347 91.092 300.347 91.092L295.038 72.255C230.238 25.855 214.238 51.383 200.638 47.383C187.038 43.383 189.438 52.983 186.238 53.783C183.038 54.583 143.838 29.783 137.438 30.583z"} + , + {"fill": "#f1b288", + "path":"M138.747 32.328C132.347 33.128 106.383 9.677 121.947 41.128C141.147 79.928 63.546 80.328 46.746 69.128C29.946 57.928 53.946 87.528 53.946 87.528C72.346 107.528 37.946 90.728 37.946 90.728C3.546 77.928 -20.454 103.528 -23.654 104.328C-26.854 105.128 -31.654 108.328 -32.454 101.928C-33.254 95.528 -40.108 79.665 -72.454 105.128C-98.636 125.456 -110.891 106.183 -110.891 106.183L-115.691 110.328C-133.691 77.128 -122.927 134.874 -122.927 134.874C-114.127 169.274 18.746 125.128 18.746 125.128C18.746 125.128 187.547 94.728 198.747 90.728C209.947 86.728 300.783 92.764 300.783 92.764L295.547 73.419C230.747 27.019 215.547 53.128 201.947 49.128C188.347 45.128 190.747 54.728 187.547 55.528C184.347 56.328 145.147 31.528 138.747 32.328z"} + , + {"fill": "#f3bf9c", + "path":"M140.056 34.073C133.655 34.873 107.313 11.613 123.255 42.873C143.656 82.874 64.855 82.074 48.055 70.874C31.255 59.674 55.255 89.274 55.255 89.274C73.655 109.274 39.255 92.474 39.255 92.474C4.855 79.674 -19.145 105.274 -22.345 106.074C-25.545 106.874 -30.345 110.074 -31.145 103.674C-31.945 97.274 -38.668 81.578 -71.145 106.874C-98.564 127.947 -110.509 109.219 -110.509 109.219L-115.709 111.874C-131.709 81.674 -122.273 137.929 -122.273 137.929C-113.473 172.329 20.055 126.874 20.055 126.874C20.055 126.874 188.856 96.474 200.056 92.474C211.256 88.474 301.22 94.437 301.22 94.437L296.056 74.583C231.256 28.183 216.856 54.874 203.256 50.874C189.656 46.873 192.056 56.474 188.856 57.274C185.656 58.074 146.456 33.273 140.056 34.073z"} + , + {"fill": "#f5ccb0", + "path":"M141.365 35.819C134.965 36.619 107.523 13.944 124.565 44.619C146.565 84.219 66.164 83.819 49.364 72.619C32.564 61.419 56.564 91.019 56.564 91.019C74.964 111.019 40.564 94.219 40.564 94.219C6.164 81.419 -17.836 107.019 -21.036 107.819C-24.236 108.619 -29.036 111.819 -29.836 105.419C-30.636 99.019 -37.227 83.492 -69.836 108.619C-98.491 130.438 -110.127 112.256 -110.127 112.256L-115.727 113.419C-130.128 85.019 -121.618 140.983 -121.618 140.983C-112.818 175.384 21.364 128.619 21.364 128.619C21.364 128.619 190.165 98.219 201.365 94.219C212.565 90.219 301.656 96.11 301.656 96.11L296.565 75.746C231.765 29.346 218.165 56.619 204.565 52.619C190.965 48.619 193.365 58.219 190.165 59.019C186.965 59.819 147.765 35.019 141.365 35.819z"} + , + {"fill": "#f8d8c4", + "path":"M142.674 37.565C136.274 38.365 108.832 15.689 125.874 46.365C147.874 85.965 67.474 85.565 50.674 74.365C33.874 63.165 57.874 92.765 57.874 92.765C76.274 112.765 41.874 95.965 41.874 95.965C7.473 83.165 -16.527 108.765 -19.727 109.565C-22.927 110.365 -27.727 113.565 -28.527 107.165C-29.327 100.765 -35.786 85.405 -68.527 110.365C-98.418 132.929 -109.745 115.293 -109.745 115.293L-115.745 114.965C-129.346 88.564 -120.963 144.038 -120.963 144.038C-112.163 178.438 22.673 130.365 22.673 130.365C22.673 130.365 191.474 99.965 202.674 95.965C213.874 91.965 302.093 97.783 302.093 97.783L297.075 76.91C232.274 30.51 219.474 58.365 205.874 54.365C192.274 50.365 194.674 59.965 191.474 60.765C188.274 61.565 149.074 36.765 142.674 37.565z"} + , + {"fill": "#fae5d7", + "path":"M143.983 39.31C137.583 40.11 110.529 17.223 127.183 48.11C149.183 88.91 68.783 87.31 51.983 76.11C35.183 64.91 59.183 94.51 59.183 94.51C77.583 114.51 43.183 97.71 43.183 97.71C8.783 84.91 -15.217 110.51 -18.417 111.31C-21.618 112.11 -26.418 115.31 -27.218 108.91C-28.018 102.51 -34.346 87.318 -67.218 112.11C-98.345 135.42 -109.363 118.329 -109.363 118.329L-115.764 116.51C-128.764 92.51 -120.309 147.093 -120.309 147.093C-111.509 181.493 23.983 132.11 23.983 132.11C23.983 132.11 192.783 101.71 203.983 97.71C215.183 93.71 302.529 99.456 302.529 99.456L297.583 78.074C232.783 31.673 220.783 60.11 207.183 56.11C193.583 52.11 195.983 61.71 192.783 62.51C189.583 63.31 150.383 38.51 143.983 39.31z"} + , + {"fill": "#fcf2eb", + "path":"M145.292 41.055C138.892 41.855 112.917 18.411 128.492 49.855C149.692 92.656 70.092 89.056 53.292 77.856C36.492 66.656 60.492 96.256 60.492 96.256C78.892 116.256 44.492 99.456 44.492 99.456C10.092 86.656 -13.908 112.256 -17.108 113.056C-20.308 113.856 -25.108 117.056 -25.908 110.656C-26.708 104.256 -32.905 89.232 -65.908 113.856C-98.273 137.911 -108.982 121.365 -108.982 121.365L-115.782 118.056C-128.582 94.856 -119.654 150.147 -119.654 150.147C-110.854 184.547 25.292 133.856 25.292 133.856C25.292 133.856 194.093 103.456 205.293 99.456C216.493 95.456 302.965 101.128 302.965 101.128L298.093 79.237C233.292 32.837 222.093 61.856 208.493 57.856C194.893 53.855 197.293 63.456 194.093 64.256C190.892 65.056 151.692 40.255 145.292 41.055z"} + , + {"fill": "#ffffff", + "path":"M-115.8 119.601C-128.6 97.6 -119 153.201 -119 153.201C-110.2 187.601 26.6 135.601 26.6 135.601C26.6 135.601 195.401 105.2 206.601 101.2C217.801 97.2 303.401 102.8 303.401 102.8L298.601 80.4C233.801 34 223.401 63.6 209.801 59.6C196.201 55.6 198.601 65.2 195.401 66C192.201 66.8 153.001 42 146.601 42.8C140.201 43.6 114.981 19.793 129.801 51.6C152.028 99.307 69.041 89.227 54.6 79.6C37.8 68.4 61.8 98 61.8 98C80.2 118.001 45.8 101.2 45.8 101.2C11.4 88.4 -12.6 114.001 -15.8 114.801C-19 115.601 -23.8 118.801 -24.6 112.401C-25.4 106 -31.465 91.144 -64.6 115.601C-98.2 140.401 -108.6 124.401 -108.6 124.401L-115.8 119.601z"} + , + {"fill": "#000000", + "path":"M-74.2 149.601C-74.2 149.601 -81.4 161.201 -60.6 174.401C-60.6 174.401 -59.2 175.801 -77.2 171.601C-77.2 171.601 -83.4 169.601 -85 159.201C-85 159.201 -89.8 154.801 -94.6 149.201C-99.4 143.601 -74.2 149.601 -74.2 149.601z"} + , + {"fill": "#cccccc", + "path":"M65.8 102C65.8 102 83.498 128.821 82.9 133.601C81.6 144.001 81.4 153.601 84.6 157.601C87.801 161.601 96.601 194.801 96.601 194.801C96.601 194.801 96.201 196.001 108.601 158.001C108.601 158.001 120.201 142.001 100.201 123.601C100.201 123.601 65 94.8 65.8 102z"} + , + {"fill": "#000000", + "path":"M-54.2 176.401C-54.2 176.401 -43 183.601 -57.4 214.801L-51 212.401C-51 212.401 -51.8 223.601 -55 226.001L-47.8 222.801C-47.8 222.801 -43 230.801 -47 235.601C-47 235.601 -30.2 243.601 -31 250.001C-31 250.001 -24.6 242.001 -28.6 235.601C-32.6 229.201 -39.8 233.201 -39 214.801L-47.8 218.001C-47.8 218.001 -42.2 209.201 -42.2 202.801L-50.2 205.201C-50.2 205.201 -34.731 178.623 -45.4 177.201C-51.4 176.401 -54.2 176.401 -54.2 176.401z"} + , + {"fill": "#cccccc", + "path":"M-21.8 193.201C-21.8 193.201 -19 188.801 -21.8 189.601C-24.6 190.401 -55.8 205.201 -61.8 214.801C-61.8 214.801 -27.4 190.401 -21.8 193.201z"} + , + {"fill": "#cccccc", + "path":"M-11.4 201.201C-11.4 201.201 -8.6 196.801 -11.4 197.601C-14.2 198.401 -45.4 213.201 -51.4 222.801C-51.4 222.801 -17 198.401 -11.4 201.201z"} + , + {"fill": "#cccccc", + "path":"M1.8 186.001C1.8 186.001 4.6 181.601 1.8 182.401C-1 183.201 -32.2 198.001 -38.2 207.601C-38.2 207.601 -3.8 183.201 1.8 186.001z"} + , + {"fill": "#cccccc", + "path":"M-21.4 229.601C-21.4 229.601 -21.4 223.601 -24.2 224.401C-27 225.201 -63 242.801 -69 252.401C-69 252.401 -27 226.801 -21.4 229.601z"} + , + {"fill": "#cccccc", + "path":"M-20.2 218.801C-20.2 218.801 -19 214.001 -21.8 214.801C-23.8 214.801 -50.2 226.401 -56.2 236.001C-56.2 236.001 -26.6 214.401 -20.2 218.801z"} + , + {"fill": "#cccccc", + "path":"M-34.6 266.401L-44.6 274.001C-44.6 274.001 -34.2 266.401 -30.6 267.601C-30.6 267.601 -37.4 278.801 -38.2 284.001C-38.2 284.001 -27.8 271.201 -22.2 271.601C-22.2 271.601 -14.6 272.001 -14.6 282.801C-14.6 282.801 -9 272.401 -5.8 272.801C-5.8 272.801 -4.6 279.201 -5.8 286.001C-5.8 286.001 -1.8 278.401 2.2 280.001C2.2 280.001 8.6 278.001 7.8 289.601C7.8 289.601 7.8 300.001 7 302.801C7 302.801 12.6 276.401 15 276.001C15 276.001 23 274.801 27.8 283.601C27.8 283.601 23.8 276.001 28.6 278.001C28.6 278.001 39.4 279.601 42.6 286.401C42.6 286.401 35.8 274.401 41.4 277.601C41.4 277.601 48.2 277.601 49.4 284.001C49.4 284.001 57.8 305.201 59.8 306.801C59.8 306.801 52.2 285.201 53.8 285.201C53.8 285.201 51.8 273.201 57 288.001C57 288.001 53.8 274.001 59.4 274.801C65 275.601 69.4 285.601 77.8 283.201C77.8 283.201 87.401 288.801 89.401 219.601L-34.6 266.401z"} + , + {"fill": "#000000", + "path":"M-29.8 173.601C-29.8 173.601 -15 167.601 25 173.601C25 173.601 32.2 174.001 39 165.201C45.8 156.401 72.6 149.201 79 151.201L88.601 157.601L89.401 158.801C89.401 158.801 101.801 169.201 102.201 176.801C102.601 184.401 87.801 232.401 78.2 248.401C68.6 264.401 59 276.801 39.8 274.401C39.8 274.401 19 270.401 -6.6 274.401C-6.6 274.401 -35.8 272.801 -38.6 264.801C-41.4 256.801 -27.4 241.601 -27.4 241.601C-27.4 241.601 -23 233.201 -24.2 218.801C-25.4 204.401 -25 176.401 -29.8 173.601z"} + , + {"fill": "#e5668c", + "path":"M-7.8 175.601C0.6 194.001 -29 259.201 -29 259.201C-31 260.801 -16.34 266.846 -6.2 264.401C4.746 261.763 45 266.001 45 266.001C68.6 250.401 81.4 206.001 81.4 206.001C81.4 206.001 91.801 182.001 74.2 178.801C56.6 175.601 -7.8 175.601 -7.8 175.601z"} + , + {"fill": "#b23259", + "path":"M-9.831 206.497C-6.505 193.707 -4.921 181.906 -7.8 175.601C-7.8 175.601 54.6 182.001 65.8 161.201C70.041 153.326 84.801 184.001 84.4 193.601C84.4 193.601 21.4 208.001 6.6 196.801L-9.831 206.497z"} + , + {"fill": "#a5264c", + "path":"M-5.4 222.801C-5.4 222.801 -3.4 230.001 -5.8 234.001C-5.8 234.001 -7.4 234.801 -8.6 235.201C-8.6 235.201 -7.4 238.801 -1.4 240.401C-1.4 240.401 0.6 244.801 3 245.201C5.4 245.601 10.2 251.201 14.2 250.001C18.2 248.801 29.4 244.801 29.4 244.801C29.4 244.801 35 241.601 43.8 245.201C43.8 245.201 46.175 244.399 46.6 240.401C47.1 235.701 50.2 232.001 52.2 230.001C54.2 228.001 63.8 215.201 62.6 214.801C61.4 214.401 -5.4 222.801 -5.4 222.801z"} + , + {"fill": "#ff727f", "stroke":"#000000", + "path":"M-9.8 174.401C-9.8 174.401 -12.6 196.801 -9.4 205.201C-6.2 213.601 -7 215.601 -7.8 219.601C-8.6 223.601 -4.2 233.601 1.4 239.601L13.4 241.201C13.4 241.201 28.6 237.601 37.8 240.401C37.8 240.401 46.794 241.744 50.2 226.801C50.2 226.801 55 220.401 62.2 217.601C69.4 214.801 76.6 173.201 72.6 165.201C68.6 157.201 54.2 152.801 38.2 168.401C22.2 184.001 20.2 167.201 -9.8 174.401z"} + , + {"fill": "#ffffcc", "stroke":"#000000", "width":0.5, + "path":"M-8.2 249.201C-8.2 249.201 -9 247.201 -13.4 246.801C-13.4 246.801 -35.8 243.201 -44.2 230.801C-44.2 230.801 -51 225.201 -46.6 236.801C-46.6 236.801 -36.2 257.201 -29.4 260.001C-29.4 260.001 -13 264.001 -8.2 249.201z"} + , + {"fill": "#cc3f4c", + "path":"M71.742 185.229C72.401 177.323 74.354 168.709 72.6 165.201C66.154 152.307 49.181 157.695 38.2 168.401C22.2 184.001 20.2 167.201 -9.8 174.401C-9.8 174.401 -11.545 188.364 -10.705 198.376C-10.705 198.376 26.6 186.801 27.4 192.401C27.4 192.401 29 189.201 38.2 189.201C47.4 189.201 70.142 188.029 71.742 185.229z"} + , + {"stroke":"#a51926", "width":2, + "path":"M28.6 175.201C28.6 175.201 33.4 180.001 29.8 189.601C29.8 189.601 15.4 205.601 17.4 219.601"} + , + {"fill": "#ffffcc", "stroke":"#000000", "width":0.5, + "path":"M-19.4 260.001C-19.4 260.001 -23.8 247.201 -15 254.001C-15 254.001 -10.2 256.001 -11.4 257.601C-12.6 259.201 -18.2 263.201 -19.4 260.001z"} + , + {"fill": "#ffffcc", "stroke":"#000000", "width":0.5, + "path":"M-14.36 261.201C-14.36 261.201 -17.88 250.961 -10.84 256.401C-10.84 256.401 -6.419 258.849 -7.96 259.281C-12.52 260.561 -7.96 263.121 -14.36 261.201z"} + , + {"fill": "#ffffcc", "stroke":"#000000", "width":0.5, + "path":"M-9.56 261.201C-9.56 261.201 -13.08 250.961 -6.04 256.401C-6.04 256.401 -1.665 258.711 -3.16 259.281C-6.52 260.561 -3.16 263.121 -9.56 261.201z"} + , + {"fill": "#ffffcc", "stroke":"#000000", "width":0.5, + "path":"M-2.96 261.401C-2.96 261.401 -6.48 251.161 0.56 256.601C0.56 256.601 4.943 258.933 3.441 259.481C0.48 260.561 3.441 263.321 -2.96 261.401z"} + , + {"fill": "#ffffcc", "stroke":"#000000", "width":0.5, + "path":"M3.52 261.321C3.52 261.321 0 251.081 7.041 256.521C7.041 256.521 10.881 258.121 9.921 259.401C8.961 260.681 9.921 263.241 3.52 261.321z"} + , + {"fill": "#ffffcc", "stroke":"#000000", "width":0.5, + "path":"M10.2 262.001C10.2 262.001 5.4 249.601 14.6 256.001C14.6 256.001 19.4 258.001 18.2 259.601C17 261.201 18.2 264.401 10.2 262.001z"} + , + {"stroke":"#a5264c", "width":2, + "path":"M-18.2 244.801C-18.2 244.801 -5 242.001 1 245.201C1 245.201 7 246.401 8.2 246.001C9.4 245.601 12.6 245.201 12.6 245.201"} + , + {"stroke":"#a5264c", "width":2, + "path":"M15.8 253.601C15.8 253.601 27.8 240.001 39.8 244.401C46.816 246.974 45.8 243.601 46.6 240.801C47.4 238.001 47.6 233.801 52.6 230.801"} + , + {"fill": "#ffffcc", "stroke":"#000000", "width":0.5, + "path":"M33 237.601C33 237.601 29 226.801 26.2 239.601C23.4 252.401 20.2 256.001 18.6 258.801C18.6 258.801 18.6 264.001 27 263.601C27 263.601 37.8 263.201 38.2 260.401C38.6 257.601 37 246.001 33 237.601z"} + , + {"stroke":"#a5264c", "width":2, + "path":"M47 244.801C47 244.801 50.6 242.401 53 243.601"} + , + {"stroke":"#a5264c", "width":2, + "path":"M53.5 228.401C53.5 228.401 56.4 223.501 61.2 222.701"} + , + {"fill": "#b2b2b2", + "path":"M-25.8 265.201C-25.8 265.201 -7.8 268.401 -3.4 266.801C-3.4 266.801 5.4 266.801 -3 268.801C-3 268.801 -15.8 268.801 -23.8 267.601C-23.8 267.601 -35.4 262.001 -25.8 265.201z"} + , + {"fill": "#ffffcc", "stroke":"#000000", "width":0.5, + "path":"M-11.8 172.001C-11.8 172.001 5.8 172.001 7.8 172.801C7.8 172.801 15 203.601 11.4 211.201C11.4 211.201 10.2 214.001 7.4 208.401C7.4 208.401 -11 175.601 -14.2 173.601C-17.4 171.601 -13 172.001 -11.8 172.001z"} + , + {"fill": "#ffffcc", "stroke":"#000000", "width":0.5, + "path":"M-88.9 169.301C-88.9 169.301 -80 171.001 -67.4 173.601C-67.4 173.601 -62.6 196.001 -59.4 200.801C-56.2 205.601 -59.8 205.601 -63.4 202.801C-67 200.001 -81.8 186.001 -83.8 181.601C-85.8 177.201 -88.9 169.301 -88.9 169.301z"} + , + {"fill": "#ffffcc", "stroke":"#000000", "width":0.5, + "path":"M-67.039 173.818C-67.039 173.818 -61.239 175.366 -60.23 177.581C-59.222 179.795 -61.432 183.092 -61.432 183.092C-61.432 183.092 -62.432 186.397 -63.634 184.235C-64.836 182.072 -67.708 174.412 -67.039 173.818z"} + , + {"fill": "#000000", + "path":"M-67 173.601C-67 173.601 -63.4 178.801 -59.8 178.801C-56.2 178.801 -55.818 178.388 -53 179.001C-48.4 180.001 -48.8 178.001 -42.2 179.201C-39.56 179.681 -37 178.801 -34.2 180.001C-31.4 181.201 -28.2 180.401 -27 178.401C-25.8 176.401 -21 172.201 -21 172.201C-21 172.201 -33.8 174.001 -36.6 174.801C-36.6 174.801 -59 176.001 -67 173.601z"} + , + {"fill": "#ffffcc", "stroke":"#000000", "width":0.5, + "path":"M-22.4 173.801C-22.4 173.801 -28.85 177.301 -29.25 179.701C-29.65 182.101 -24 185.801 -24 185.801C-24 185.801 -21.25 190.401 -20.65 188.001C-20.05 185.601 -21.6 174.201 -22.4 173.801z"} + , + {"fill": "#ffffcc", "stroke":"#000000", "width":0.5, + "path":"M-59.885 179.265C-59.885 179.265 -52.878 190.453 -52.661 179.242C-52.661 179.242 -52.104 177.984 -53.864 177.962C-59.939 177.886 -58.418 173.784 -59.885 179.265z"} + , + {"fill": "#ffffcc", "stroke":"#000000", "width":0.5, + "path":"M-52.707 179.514C-52.707 179.514 -44.786 190.701 -45.422 179.421C-45.422 179.421 -45.415 179.089 -47.168 178.936C-51.915 178.522 -51.57 174.004 -52.707 179.514z"} + , + {"fill": "#ffffcc", "stroke":"#000000", "width":0.5, + "path":"M-45.494 179.522C-45.494 179.522 -37.534 190.15 -38.203 180.484C-38.203 180.484 -38.084 179.251 -39.738 178.95C-43.63 178.244 -43.841 174.995 -45.494 179.522z"} + , + {"fill": "#ffffcc", "stroke":"#000000", "width":0.5, + "path":"M-38.618 179.602C-38.618 179.602 -30.718 191.163 -30.37 181.382C-30.37 181.382 -28.726 180.004 -30.472 179.782C-36.29 179.042 -35.492 174.588 -38.618 179.602z"} + , + {"fill": "#e5e5b2", + "path":"M-74.792 183.132L-82.45 181.601C-85.05 176.601 -87.15 170.451 -87.15 170.451C-87.15 170.451 -80.8 171.451 -68.3 174.251C-68.3 174.251 -67.424 177.569 -65.952 183.364L-74.792 183.132z"} + , + {"fill": "#e5e5b2", + "path":"M-9.724 178.47C-11.39 175.964 -12.707 174.206 -13.357 173.8C-16.37 171.917 -12.227 172.294 -11.098 172.294C-11.098 172.294 5.473 172.294 7.356 173.047C7.356 173.047 7.88 175.289 8.564 178.68C8.564 178.68 -1.524 176.67 -9.724 178.47z"} + , + {"fill": "#cc7226", + "path":"M43.88 40.321C71.601 44.281 97.121 8.641 98.881 -1.04C100.641 -10.72 90.521 -22.6 90.521 -22.6C91.841 -25.68 87.001 -39.76 81.721 -49C76.441 -58.24 60.54 -57.266 43 -58.24C27.16 -59.12 8.68 -35.8 7.36 -34.04C6.04 -32.28 12.2 6.001 13.52 11.721C14.84 17.441 12.2 43.841 12.2 43.841C46.44 34.741 16.16 36.361 43.88 40.321z"} + , + {"fill": "#ea8e51", + "path":"M8.088 -33.392C6.792 -31.664 12.84 5.921 14.136 11.537C15.432 17.153 12.84 43.073 12.84 43.073C45.512 34.193 16.728 35.729 43.944 39.617C71.161 43.505 96.217 8.513 97.945 -0.992C99.673 -10.496 89.737 -22.16 89.737 -22.16C91.033 -25.184 86.281 -39.008 81.097 -48.08C75.913 -57.152 60.302 -56.195 43.08 -57.152C27.528 -58.016 9.384 -35.12 8.088 -33.392z"} + , + {"fill": "#efaa7c", + "path":"M8.816 -32.744C7.544 -31.048 13.48 5.841 14.752 11.353C16.024 16.865 13.48 42.305 13.48 42.305C44.884 33.145 17.296 35.097 44.008 38.913C70.721 42.729 95.313 8.385 97.009 -0.944C98.705 -10.272 88.953 -21.72 88.953 -21.72C90.225 -24.688 85.561 -38.256 80.473 -47.16C75.385 -56.064 60.063 -55.125 43.16 -56.064C27.896 -56.912 10.088 -34.44 8.816 -32.744z"} + , + {"fill": "#f4c6a8", + "path":"M9.544 -32.096C8.296 -30.432 14.12 5.761 15.368 11.169C16.616 16.577 14.12 41.537 14.12 41.537C43.556 32.497 17.864 34.465 44.072 38.209C70.281 41.953 94.409 8.257 96.073 -0.895C97.737 -10.048 88.169 -21.28 88.169 -21.28C89.417 -24.192 84.841 -37.504 79.849 -46.24C74.857 -54.976 59.824 -54.055 43.24 -54.976C28.264 -55.808 10.792 -33.76 9.544 -32.096z"} + , + {"fill": "#f9e2d3", + "path":"M10.272 -31.448C9.048 -29.816 14.76 5.681 15.984 10.985C17.208 16.289 14.76 40.769 14.76 40.769C42.628 31.849 18.432 33.833 44.136 37.505C69.841 41.177 93.505 8.129 95.137 -0.848C96.769 -9.824 87.385 -20.84 87.385 -20.84C88.609 -23.696 84.121 -36.752 79.225 -45.32C74.329 -53.888 59.585 -52.985 43.32 -53.888C28.632 -54.704 11.496 -33.08 10.272 -31.448z"} + , + {"fill": "#ffffff", + "path":"M44.2 36.8C69.4 40.4 92.601 8 94.201 -0.8C95.801 -9.6 86.601 -20.4 86.601 -20.4C87.801 -23.2 83.4 -36 78.6 -44.4C73.8 -52.8 59.346 -51.914 43.4 -52.8C29 -53.6 12.2 -32.4 11 -30.8C9.8 -29.2 15.4 5.6 16.6 10.8C17.8 16 15.4 40 15.4 40C40.9 31.4 19 33.2 44.2 36.8z"} + , + {"fill": "#cccccc", + "path":"M90.601 2.8C90.601 2.8 62.8 10.4 51.2 8.8C51.2 8.8 35.4 2.2 26.6 24C26.6 24 23 31.2 21 33.2C19 35.2 90.601 2.8 90.601 2.8z"} + , + {"fill": "#000000", + "path":"M94.401 0.6C94.401 0.6 65.4 12.8 55.4 12.4C55.4 12.4 39 7.8 30.6 22.4C30.6 22.4 22.2 31.6 19 33.2C19 33.2 18.6 34.8 25 30.8L35.4 36C35.4 36 50.2 45.6 59.8 29.6C59.8 29.6 63.8 18.4 63.8 16.4C63.8 14.4 85 8.8 86.601 8.4C88.201 8 94.801 3.8 94.401 0.6z"} + , + {"fill": "#99cc32", + "path":"M47 36.514C40.128 36.514 31.755 32.649 31.755 26.4C31.755 20.152 40.128 13.887 47 13.887C53.874 13.887 59.446 18.952 59.446 25.2C59.446 31.449 53.874 36.514 47 36.514z"} + , + {"fill": "#659900", + "path":"M43.377 19.83C38.531 20.552 33.442 22.055 33.514 21.839C35.054 17.22 41.415 13.887 47 13.887C51.296 13.887 55.084 15.865 57.32 18.875C57.32 18.875 52.004 18.545 43.377 19.83z"} + , + {"fill": "#ffffff", + "path":"M55.4 19.6C55.4 19.6 51 16.4 51 18.6C51 18.6 54.6 23 55.4 19.6z"} + , + {"fill": "#000000", + "path":"M45.4 27.726C42.901 27.726 40.875 25.7 40.875 23.2C40.875 20.701 42.901 18.675 45.4 18.675C47.9 18.675 49.926 20.701 49.926 23.2C49.926 25.7 47.9 27.726 45.4 27.726z"} + , + {"fill": "#cc7226", + "path":"M-58.6 14.4C-58.6 14.4 -61.8 -6.8 -59.4 -11.2C-59.4 -11.2 -48.6 -21.2 -49 -24.8C-49 -24.8 -49.4 -42.8 -50.6 -43.6C-51.8 -44.4 -59.4 -50.4 -65.4 -44C-65.4 -44 -75.8 -26 -75 -19.6L-75 -17.6C-75 -17.6 -82.6 -18 -84.2 -16C-84.2 -16 -85.4 -10.8 -86.6 -10.4C-86.6 -10.4 -89.4 -8 -87.4 -5.2C-87.4 -5.2 -89.4 -2.8 -89 1.2L-81.4 5.2C-81.4 5.2 -79.4 19.6 -68.6 24.8C-63.764 27.129 -60.6 20.4 -58.6 14.4z"} + , + {"fill": "#ffffff", + "path":"M-59.6 12.56C-59.6 12.56 -62.48 -6.52 -60.32 -10.48C-60.32 -10.48 -50.6 -19.48 -50.96 -22.72C-50.96 -22.72 -51.32 -38.92 -52.4 -39.64C-53.48 -40.36 -60.32 -45.76 -65.72 -40C-65.72 -40 -75.08 -23.8 -74.36 -18.04L-74.36 -16.24C-74.36 -16.24 -81.2 -16.6 -82.64 -14.8C-82.64 -14.8 -83.72 -10.12 -84.8 -9.76C-84.8 -9.76 -87.32 -7.6 -85.52 -5.08C-85.52 -5.08 -87.32 -2.92 -86.96 0.68L-80.12 4.28C-80.12 4.28 -78.32 17.24 -68.6 21.92C-64.248 24.015 -61.4 17.96 -59.6 12.56z"} + , + {"fill": "#eb955c", + "path":"M-51.05 -42.61C-52.14 -43.47 -59.63 -49.24 -65.48 -43C-65.48 -43 -75.62 -25.45 -74.84 -19.21L-74.84 -17.26C-74.84 -17.26 -82.25 -17.65 -83.81 -15.7C-83.81 -15.7 -84.98 -10.63 -86.15 -10.24C-86.15 -10.24 -88.88 -7.9 -86.93 -5.17C-86.93 -5.17 -88.88 -2.83 -88.49 1.07L-81.08 4.97C-81.08 4.97 -79.13 19.01 -68.6 24.08C-63.886 26.35 -60.8 19.79 -58.85 13.94C-58.85 13.94 -61.97 -6.73 -59.63 -11.02C-59.63 -11.02 -49.1 -20.77 -49.49 -24.28C-49.49 -24.28 -49.88 -41.83 -51.05 -42.61z"} + , + {"fill": "#f2b892", + "path":"M-51.5 -41.62C-52.48 -42.54 -59.86 -48.08 -65.56 -42C-65.56 -42 -75.44 -24.9 -74.68 -18.82L-74.68 -16.92C-74.68 -16.92 -81.9 -17.3 -83.42 -15.4C-83.42 -15.4 -84.56 -10.46 -85.7 -10.08C-85.7 -10.08 -88.36 -7.8 -86.46 -5.14C-86.46 -5.14 -88.36 -2.86 -87.98 0.94L-80.76 4.74C-80.76 4.74 -78.86 18.42 -68.6 23.36C-64.006 25.572 -61 19.18 -59.1 13.48C-59.1 13.48 -62.14 -6.66 -59.86 -10.84C-59.86 -10.84 -49.6 -20.34 -49.98 -23.76C-49.98 -23.76 -50.36 -40.86 -51.5 -41.62z"} + , + {"fill": "#f8dcc8", + "path":"M-51.95 -40.63C-52.82 -41.61 -60.09 -46.92 -65.64 -41C-65.64 -41 -75.26 -24.35 -74.52 -18.43L-74.52 -16.58C-74.52 -16.58 -81.55 -16.95 -83.03 -15.1C-83.03 -15.1 -84.14 -10.29 -85.25 -9.92C-85.25 -9.92 -87.84 -7.7 -85.99 -5.11C-85.99 -5.11 -87.84 -2.89 -87.47 0.81L-80.44 4.51C-80.44 4.51 -78.59 17.83 -68.6 22.64C-64.127 24.794 -61.2 18.57 -59.35 13.02C-59.35 13.02 -62.31 -6.59 -60.09 -10.66C-60.09 -10.66 -50.1 -19.91 -50.47 -23.24C-50.47 -23.24 -50.84 -39.89 -51.95 -40.63z"} + , + {"fill": "#ffffff", + "path":"M-59.6 12.46C-59.6 12.46 -62.48 -6.52 -60.32 -10.48C-60.32 -10.48 -50.6 -19.48 -50.96 -22.72C-50.96 -22.72 -51.32 -38.92 -52.4 -39.64C-53.16 -40.68 -60.32 -45.76 -65.72 -40C-65.72 -40 -75.08 -23.8 -74.36 -18.04L-74.36 -16.24C-74.36 -16.24 -81.2 -16.6 -82.64 -14.8C-82.64 -14.8 -83.72 -10.12 -84.8 -9.76C-84.8 -9.76 -87.32 -7.6 -85.52 -5.08C-85.52 -5.08 -87.32 -2.92 -86.96 0.68L-80.12 4.28C-80.12 4.28 -78.32 17.24 -68.6 21.92C-64.248 24.015 -61.4 17.86 -59.6 12.46z"} + , + {"fill": "#cccccc", + "path":"M-62.7 6.2C-62.7 6.2 -84.3 -4 -85.2 -4.8C-85.2 -4.8 -76.1 3.4 -75.3 3.4C-74.5 3.4 -62.7 6.2 -62.7 6.2z"} + , + {"fill": "#000000", + "path":"M-79.8 0C-79.8 0 -61.4 3.6 -61.4 8C-61.4 10.912 -61.643 24.331 -67 22.8C-75.4 20.4 -71.8 6 -79.8 0z"} + , + {"fill": "#99cc32", + "path":"M-71.4 3.8C-71.4 3.8 -62.422 5.274 -61.4 8C-60.8 9.6 -60.137 17.908 -65.6 19C-70.152 19.911 -72.382 9.69 -71.4 3.8z"} + , + {"fill": "#000000", + "path":"M14.595 46.349C14.098 44.607 15.409 44.738 17.2 44.2C19.2 43.6 31.4 39.8 32.2 37.2C33 34.6 46.2 39 46.2 39C48 39.8 52.4 42.4 52.4 42.4C57.2 43.6 63.8 44 63.8 44C66.2 45 69.6 47.8 69.6 47.8C84.2 58 96.601 50.8 96.601 50.8C116.601 44.2 110.601 27 110.601 27C107.601 18 110.801 14.6 110.801 14.6C111.001 10.8 118.201 17.2 118.201 17.2C120.801 21.4 121.601 26.4 121.601 26.4C129.601 37.6 126.201 19.8 126.201 19.8C126.401 18.8 123.601 15.2 123.601 14C123.601 12.8 121.801 9.4 121.801 9.4C118.801 6 121.201 -1 121.201 -1C123.001 -14.8 120.801 -13 120.801 -13C119.601 -14.8 110.401 -4.8 110.401 -4.8C108.201 -1.4 102.201 0.2 102.201 0.2C99.401 2 96.001 0.6 96.001 0.6C93.401 0.2 87.801 7.2 87.801 7.2C90.601 7 93.001 11.4 95.401 11.6C97.801 11.8 99.601 9.2 101.201 8.6C102.801 8 105.601 13.8 105.601 13.8C106.001 16.4 100.401 21.2 100.401 21.2C100.001 25.8 98.401 24.2 98.401 24.2C95.401 23.6 94.201 27.4 93.201 32C92.201 36.6 88.001 37 88.001 37C86.401 44.4 85.2 41.4 85.2 41.4C85 35.8 79 41.6 79 41.6C77.8 43.6 73.2 41.4 73.2 41.4C66.4 39.4 68.8 37.4 68.8 37.4C70.6 35.2 81.8 37.4 81.8 37.4C84 35.8 76 31.8 76 31.8C75.4 30 76.4 25.6 76.4 25.6C77.6 22.4 84.4 16.8 84.4 16.8C93.801 15.6 91.001 14 91.001 14C84.801 8.8 79 16.4 79 16.4C76.8 22.6 59.4 37.6 59.4 37.6C54.6 41 57.2 34.2 53.2 37.6C49.2 41 28.6 32 28.6 32C17.038 30.807 14.306 46.549 10.777 43.429C10.777 43.429 16.195 51.949 14.595 46.349z"} + , + {"fill": "#000000", + "path":"M209.401 -120C209.401 -120 183.801 -112 181.001 -93.2C181.001 -93.2 178.601 -70.4 199.001 -52.8C199.001 -52.8 199.401 -46.4 201.401 -43.2C201.401 -43.2 199.801 -38.4 218.601 -46L245.801 -54.4C245.801 -54.4 252.201 -56.8 257.401 -65.6C262.601 -74.4 277.801 -93.2 274.201 -118.4C274.201 -118.4 275.401 -129.6 269.401 -130C269.401 -130 261.001 -131.6 253.801 -124C253.801 -124 247.001 -120.8 244.601 -121.2L209.401 -120z"} + , + {"fill": "#000000", + "path":"M264.022 -120.99C264.022 -120.99 266.122 -129.92 261.282 -125.08C261.282 -125.08 254.242 -119.36 246.761 -119.36C246.761 -119.36 232.241 -117.16 227.841 -103.96C227.841 -103.96 223.881 -77.12 231.801 -71.4C231.801 -71.4 236.641 -63.92 243.681 -70.52C250.722 -77.12 266.222 -107.35 264.022 -120.99z"} + , + {"fill": "#323232", + "path":"M263.648 -120.632C263.648 -120.632 265.738 -129.376 260.986 -124.624C260.986 -124.624 254.074 -119.008 246.729 -119.008C246.729 -119.008 232.473 -116.848 228.153 -103.888C228.153 -103.888 224.265 -77.536 232.041 -71.92C232.041 -71.92 236.793 -64.576 243.705 -71.056C250.618 -77.536 265.808 -107.24 263.648 -120.632z"} + , + {"fill": "#666666", + "path":"M263.274 -120.274C263.274 -120.274 265.354 -128.832 260.69 -124.168C260.69 -124.168 253.906 -118.656 246.697 -118.656C246.697 -118.656 232.705 -116.536 228.465 -103.816C228.465 -103.816 224.649 -77.952 232.281 -72.44C232.281 -72.44 236.945 -65.232 243.729 -71.592C250.514 -77.952 265.394 -107.13 263.274 -120.274z"} + , + {"fill": "#999999", + "path":"M262.9 -119.916C262.9 -119.916 264.97 -128.288 260.394 -123.712C260.394 -123.712 253.738 -118.304 246.665 -118.304C246.665 -118.304 232.937 -116.224 228.777 -103.744C228.777 -103.744 225.033 -78.368 232.521 -72.96C232.521 -72.96 237.097 -65.888 243.753 -72.128C250.41 -78.368 264.98 -107.02 262.9 -119.916z"} + , + {"fill": "#cccccc", + "path":"M262.526 -119.558C262.526 -119.558 264.586 -127.744 260.098 -123.256C260.098 -123.256 253.569 -117.952 246.633 -117.952C246.633 -117.952 233.169 -115.912 229.089 -103.672C229.089 -103.672 225.417 -78.784 232.761 -73.48C232.761 -73.48 237.249 -66.544 243.777 -72.664C250.305 -78.784 264.566 -106.91 262.526 -119.558z"} + , + {"fill": "#ffffff", + "path":"M262.151 -119.2C262.151 -119.2 264.201 -127.2 259.801 -122.8C259.801 -122.8 253.401 -117.6 246.601 -117.6C246.601 -117.6 233.401 -115.6 229.401 -103.6C229.401 -103.6 225.801 -79.2 233.001 -74C233.001 -74 237.401 -67.2 243.801 -73.2C250.201 -79.2 264.151 -106.8 262.151 -119.2z"} + , + {"fill": "#992600", + "path":"M50.6 84C50.6 84 30.2 64.8 22.2 64C22.2 64 -12.2 60 -27 78C-27 78 -9.4 57.6 18.2 63.2C18.2 63.2 -3.4 58.8 -15.8 62C-15.8 62 -32.6 62 -42.2 76L-45 80.8C-45 80.8 -41 66 -22.6 60C-22.6 60 0.2 55.2 11 60C11 60 -10.6 53.2 -20.6 55.2C-20.6 55.2 -51 52.8 -63.8 79.2C-63.8 79.2 -59.8 64.8 -45 57.6C-45 57.6 -31.4 48.8 -11 51.6C-11 51.6 3.4 54.8 8.6 57.2C13.8 59.6 12.6 56.8 4.2 52C4.2 52 -1.4 42 -15.4 42.4C-15.4 42.4 -58.2 46 -68.6 58C-68.6 58 -55 46.8 -44.6 44C-44.6 44 -22.2 36 -13.8 36.8C-13.8 36.8 11 37.8 18.6 33.8C18.6 33.8 7.4 38.8 10.6 42C13.8 45.2 20.6 52.8 20.6 54C20.6 55.2 44.8 77.3 48.4 81.7L50.6 84z"} + , + {"fill": "#cccccc", + "path":"M189 278C189 278 173.5 241.5 161 232C161 232 187 248 190.5 266C190.5 266 190.5 276 189 278z"} + , + {"fill": "#cccccc", + "path":"M236 285.5C236 285.5 209.5 230.5 191 206.5C191 206.5 234.5 244 239.5 270.5L240 276L237 273.5C237 273.5 236.5 282.5 236 285.5z"} + , + {"fill": "#cccccc", + "path":"M292.5 237C292.5 237 230 177.5 228.5 175C228.5 175 289 241 292 248.5C292 248.5 290 239.5 292.5 237z"} + , + {"fill": "#cccccc", + "path":"M104 280.5C104 280.5 123.5 228.5 142.5 251C142.5 251 157.5 261 157 264C157 264 153 257.5 135 258C135 258 116 255 104 280.5z"} + , + {"fill": "#cccccc", + "path":"M294.5 153C294.5 153 249.5 124.5 242 123C230.193 120.639 291.5 152 296.5 162.5C296.5 162.5 298.5 160 294.5 153z"} + , + {"fill": "#000000", + "path":"M143.801 259.601C143.801 259.601 164.201 257.601 171.001 250.801L175.401 254.401L193.001 216.001L196.601 221.201C196.601 221.201 211.001 206.401 210.201 198.401C209.401 190.401 223.001 204.401 223.001 204.401C223.001 204.401 222.201 192.801 229.401 199.601C229.401 199.601 227.001 184.001 235.401 192.001C235.401 192.001 224.864 161.844 247.401 187.601C253.001 194.001 248.601 187.201 248.601 187.201C248.601 187.201 222.601 139.201 244.201 153.601C244.201 153.601 246.201 130.801 245.001 126.401C243.801 122.001 241.801 99.6 237.001 94.4C232.201 89.2 237.401 87.6 243.001 92.8C243.001 92.8 231.801 68.8 245.001 80.8C245.001 80.8 241.401 65.6 237.001 62.8C237.001 62.8 231.401 45.6 246.601 56.4C246.601 56.4 242.201 44 239.001 40.8C239.001 40.8 227.401 13.2 234.601 18L239.001 21.6C239.001 21.6 232.201 7.6 238.601 12C245.001 16.4 245.001 16 245.001 16C245.001 16 223.801 -17.2 244.201 0.4C244.201 0.4 236.042 -13.518 232.601 -20.4C232.601 -20.4 213.801 -40.8 228.201 -34.4L233.001 -32.8C233.001 -32.8 224.201 -42.8 216.201 -44.4C208.201 -46 218.601 -52.4 225.001 -50.4C231.401 -48.4 247.001 -40.8 247.001 -40.8C247.001 -40.8 259.801 -22 263.801 -21.6C263.801 -21.6 243.801 -29.2 249.801 -21.2C249.801 -21.2 264.201 -7.2 257.001 -7.6C257.001 -7.6 251.001 -0.4 255.801 8.4C255.801 8.4 237.342 -9.991 252.201 15.6L259.001 32C259.001 32 234.601 7.2 245.801 29.2C245.801 29.2 263.001 52.8 265.001 53.2C267.001 53.6 271.401 62.4 271.401 62.4L267.001 60.4L272.201 69.2C272.201 69.2 261.001 57.2 267.001 70.4L272.601 84.8C272.601 84.8 252.201 62.8 265.801 92.4C265.801 92.4 249.401 87.2 258.201 104.4C258.201 104.4 256.601 120.401 257.001 125.601C257.401 130.801 258.601 159.201 254.201 167.201C249.801 175.201 260.201 194.401 262.201 198.401C264.201 202.401 267.801 213.201 259.001 204.001C250.201 194.801 254.601 200.401 256.601 209.201C258.601 218.001 264.601 233.601 263.801 239.201C263.801 239.201 262.601 240.401 259.401 236.801C259.401 236.801 244.601 214.001 246.201 228.401C246.201 228.401 245.001 236.401 241.801 245.201C241.801 245.201 238.601 256.001 238.601 247.201C238.601 247.201 235.401 230.401 232.601 238.001C229.801 245.601 226.201 251.601 223.401 254.001C220.601 256.401 215.401 233.601 214.201 244.001C214.201 244.001 202.201 231.601 197.401 248.001L185.801 264.401C185.801 264.401 185.401 252.001 184.201 258.001C184.201 258.001 154.201 264.001 143.801 259.601z"} + , + {"fill": "#000000", + "path":"M109.401 -97.2C109.401 -97.2 97.801 -105.2 93.801 -104.8C89.801 -104.4 121.401 -113.6 162.601 -86C162.601 -86 167.401 -83.2 171.001 -83.6C171.001 -83.6 174.201 -81.2 171.401 -77.6C171.401 -77.6 162.601 -68 173.801 -56.8C173.801 -56.8 192.201 -50 186.601 -58.8C186.601 -58.8 197.401 -54.8 199.801 -50.8C202.201 -46.8 201.001 -50.8 201.001 -50.8C201.001 -50.8 194.601 -58 188.601 -63.2C188.601 -63.2 183.401 -65.2 180.601 -73.6C177.801 -82 175.401 -92 179.801 -95.2C179.801 -95.2 175.801 -90.8 176.601 -94.8C177.401 -98.8 181.001 -102.4 182.601 -102.8C184.201 -103.2 200.601 -119 207.401 -119.4C207.401 -119.4 198.201 -118 195.201 -119C192.201 -120 165.601 -131.4 159.601 -132.6C159.601 -132.6 142.801 -139.2 154.801 -137.2C154.801 -137.2 190.601 -133.4 208.801 -120.2C208.801 -120.2 201.601 -128.6 183.201 -135.6C183.201 -135.6 161.001 -148.2 125.801 -143.2C125.801 -143.2 108.001 -140 100.201 -138.2C100.201 -138.2 97.601 -138.8 97.001 -139.2C96.401 -139.6 84.6 -148.6 57 -141.6C57 -141.6 40 -137 31.4 -132.2C31.4 -132.2 16.2 -131 12.6 -127.8C12.6 -127.8 -6 -113.2 -8 -112.4C-10 -111.6 -21.4 -104 -22.2 -103.6C-22.2 -103.6 2.4 -110.2 4.8 -112.6C7.2 -115 24.6 -117.6 27 -116.2C29.4 -114.8 37.8 -115.4 28.2 -114.8C28.2 -114.8 103.801 -100 104.601 -98C105.401 -96 109.401 -97.2 109.401 -97.2z"} + , + {"fill": "#cc7226", + "path":"M180.801 -106.4C180.801 -106.4 170.601 -113.8 168.601 -113.8C166.601 -113.8 154.201 -124 150.001 -123.6C145.801 -123.2 133.601 -133.2 106.201 -125C106.201 -125 105.601 -127 109.201 -127.8C109.201 -127.8 115.601 -130 116.001 -130.6C116.001 -130.6 136.201 -134.8 143.401 -131.2C143.401 -131.2 152.601 -128.6 158.801 -122.4C158.801 -122.4 170.001 -119.2 173.201 -120.2C173.201 -120.2 182.001 -118 182.401 -116.2C182.401 -116.2 188.201 -113.2 186.401 -110.6C186.401 -110.6 186.801 -109 180.801 -106.4z"} + , + {"fill": "#cc7226", + "path":"M168.33 -108.509C169.137 -107.877 170.156 -107.779 170.761 -106.97C170.995 -106.656 170.706 -106.33 170.391 -106.233C169.348 -105.916 168.292 -106.486 167.15 -105.898C166.748 -105.691 166.106 -105.873 165.553 -106.022C163.921 -106.463 162.092 -106.488 160.401 -105.8C158.416 -106.929 156.056 -106.345 153.975 -107.346C153.917 -107.373 153.695 -107.027 153.621 -107.054C150.575 -108.199 146.832 -107.916 144.401 -110.2C141.973 -110.612 139.616 -111.074 137.188 -111.754C135.37 -112.263 133.961 -113.252 132.341 -114.084C130.964 -114.792 129.507 -115.314 127.973 -115.686C126.11 -116.138 124.279 -116.026 122.386 -116.546C122.293 -116.571 122.101 -116.227 122.019 -116.254C121.695 -116.362 121.405 -116.945 121.234 -116.892C119.553 -116.37 118.065 -117.342 116.401 -117C115.223 -118.224 113.495 -117.979 111.949 -118.421C108.985 -119.269 105.831 -117.999 102.801 -119C106.914 -120.842 111.601 -119.61 115.663 -121.679C117.991 -122.865 120.653 -121.763 123.223 -122.523C123.71 -122.667 124.401 -122.869 124.801 -122.2C124.935 -122.335 125.117 -122.574 125.175 -122.546C127.625 -121.389 129.94 -120.115 132.422 -119.049C132.763 -118.903 133.295 -119.135 133.547 -118.933C135.067 -117.717 137.01 -117.82 138.401 -116.6C140.099 -117.102 141.892 -116.722 143.621 -117.346C143.698 -117.373 143.932 -117.032 143.965 -117.054C145.095 -117.802 146.25 -117.531 147.142 -117.227C147.48 -117.112 148.143 -116.865 148.448 -116.791C149.574 -116.515 150.43 -116.035 151.609 -115.852C151.723 -115.834 151.908 -116.174 151.98 -116.146C153.103 -115.708 154.145 -115.764 154.801 -114.6C154.936 -114.735 155.101 -114.973 155.183 -114.946C156.21 -114.608 156.859 -113.853 157.96 -113.612C158.445 -113.506 159.057 -112.88 159.633 -112.704C162.025 -111.973 163.868 -110.444 166.062 -109.549C166.821 -109.239 167.697 -109.005 168.33 -108.509z"} + , + {"fill": "#cc7226", + "path":"M91.696 -122.739C89.178 -124.464 86.81 -125.57 84.368 -127.356C84.187 -127.489 83.827 -127.319 83.625 -127.441C82.618 -128.05 81.73 -128.631 80.748 -129.327C80.209 -129.709 79.388 -129.698 78.88 -129.956C76.336 -131.248 73.707 -131.806 71.2 -133C71.882 -133.638 73.004 -133.394 73.6 -134.2C73.795 -133.92 74.033 -133.636 74.386 -133.827C76.064 -134.731 77.914 -134.884 79.59 -134.794C81.294 -134.702 83.014 -134.397 84.789 -134.125C85.096 -134.078 85.295 -133.555 85.618 -133.458C87.846 -132.795 90.235 -133.32 92.354 -132.482C93.945 -131.853 95.515 -131.03 96.754 -129.755C97.006 -129.495 96.681 -129.194 96.401 -129C96.789 -129.109 97.062 -128.903 97.173 -128.59C97.257 -128.351 97.257 -128.049 97.173 -127.81C97.061 -127.498 96.782 -127.397 96.408 -127.346C95.001 -127.156 96.773 -128.536 96.073 -128.088C94.8 -127.274 95.546 -125.868 94.801 -124.6C94.521 -124.794 94.291 -125.012 94.401 -125.4C94.635 -124.878 94.033 -124.588 93.865 -124.272C93.48 -123.547 92.581 -122.132 91.696 -122.739z"} + , + {"fill": "#cc7226", + "path":"M59.198 -115.391C56.044 -116.185 52.994 -116.07 49.978 -117.346C49.911 -117.374 49.688 -117.027 49.624 -117.054C48.258 -117.648 47.34 -118.614 46.264 -119.66C45.351 -120.548 43.693 -120.161 42.419 -120.648C42.095 -120.772 41.892 -121.284 41.591 -121.323C40.372 -121.48 39.445 -122.429 38.4 -123C40.736 -123.795 43.147 -123.764 45.609 -124.148C45.722 -124.166 45.867 -123.845 46 -123.845C46.136 -123.845 46.266 -124.066 46.4 -124.2C46.595 -123.92 46.897 -123.594 47.154 -123.848C47.702 -124.388 48.258 -124.198 48.798 -124.158C48.942 -124.148 49.067 -123.845 49.2 -123.845C49.336 -123.845 49.467 -124.156 49.6 -124.156C49.736 -124.155 49.867 -123.845 50 -123.845C50.136 -123.845 50.266 -124.066 50.4 -124.2C51.092 -123.418 51.977 -123.972 52.799 -123.793C53.837 -123.566 54.104 -122.418 55.178 -122.12C59.893 -120.816 64.03 -118.671 68.393 -116.584C68.7 -116.437 68.91 -116.189 68.8 -115.8C69.067 -115.8 69.38 -115.888 69.57 -115.756C70.628 -115.024 71.669 -114.476 72.366 -113.378C72.582 -113.039 72.253 -112.632 72.02 -112.684C67.591 -113.679 63.585 -114.287 59.198 -115.391z"} + , + {"fill": "#cc7226", + "path":"M45.338 -71.179C43.746 -72.398 43.162 -74.429 42.034 -76.221C41.82 -76.561 42.094 -76.875 42.411 -76.964C42.971 -77.123 43.514 -76.645 43.923 -76.443C45.668 -75.581 47.203 -74.339 49.2 -74.2C51.19 -71.966 55.45 -71.581 55.457 -68.2C55.458 -67.341 54.03 -68.259 53.6 -67.4C51.149 -68.403 48.76 -68.3 46.38 -69.767C45.763 -70.148 46.093 -70.601 45.338 -71.179z"} + , + {"fill": "#cc7226", + "path":"M17.8 -123.756C17.935 -123.755 24.966 -123.522 24.949 -123.408C24.904 -123.099 17.174 -122.05 16.81 -122.22C16.646 -122.296 9.134 -119.866 9 -120C9.268 -120.135 17.534 -123.756 17.8 -123.756z"} + , + {"fill": "#000000", + "path":"M33.2 -114C33.2 -114 18.4 -112.2 14 -111C9.6 -109.8 -9 -102.2 -12 -100.2C-12 -100.2 -25.4 -94.8 -42.4 -74.8C-42.4 -74.8 -34.8 -78.2 -32.6 -81C-32.6 -81 -19 -93.6 -19.2 -91C-19.2 -91 -7 -99.6 -7.6 -97.4C-7.6 -97.4 16.8 -108.6 14.8 -105.4C14.8 -105.4 36.4 -110 35.4 -108C35.4 -108 54.2 -103.6 51.4 -103.4C51.4 -103.4 45.6 -102.2 52 -98.6C52 -98.6 48.6 -94.2 43.2 -98.2C37.8 -102.2 40.8 -100 35.8 -99C35.8 -99 33.2 -98.2 28.6 -102.2C28.6 -102.2 23 -106.8 14.2 -103.2C14.2 -103.2 -16.4 -90.6 -18.4 -90C-18.4 -90 -22 -87.2 -24.4 -83.6C-24.4 -83.6 -30.2 -79.2 -33.2 -77.8C-33.2 -77.8 -46 -66.2 -47.2 -64.8C-47.2 -64.8 -50.6 -59.6 -51.4 -59.2C-51.4 -59.2 -45 -63 -43 -65C-43 -65 -29 -75 -23.6 -75.8C-23.6 -75.8 -19.2 -78.8 -18.4 -80.2C-18.4 -80.2 -4 -89.4 0.2 -89.4C0.2 -89.4 9.4 -84.2 11.8 -91.2C11.8 -91.2 17.6 -93 23.2 -91.8C23.2 -91.8 26.4 -94.4 25.6 -96.6C25.6 -96.6 27.2 -98.4 28.2 -94.6C28.2 -94.6 31.6 -91 36.4 -93C36.4 -93 40.4 -93.2 38.4 -90.8C38.4 -90.8 34 -87 22.2 -86.8C22.2 -86.8 9.8 -86.2 -6.6 -78.6C-6.6 -78.6 -36.4 -68.2 -45.6 -57.8C-45.6 -57.8 -52 -49 -57.4 -47.8C-57.4 -47.8 -63.2 -47 -69.2 -39.6C-69.2 -39.6 -59.4 -45.4 -50.4 -45.4C-50.4 -45.4 -46.4 -47.8 -50.2 -44.2C-50.2 -44.2 -53.8 -36.6 -52.2 -31.2C-52.2 -31.2 -52.8 -26 -53.6 -24.4C-53.6 -24.4 -61.4 -11.6 -61.4 -9.2C-61.4 -6.8 -60.2 3 -59.8 3.6C-59.4 4.2 -60.8 2 -57 4.4C-53.2 6.8 -50.4 8.4 -49.6 11.2C-48.8 14 -51.6 5.8 -51.8 4C-52 2.2 -56.2 -5 -55.4 -7.4C-55.4 -7.4 -54.4 -6.4 -53.6 -5C-53.6 -5 -54.2 -5.6 -53.6 -9.2C-53.6 -9.2 -52.8 -14.4 -51.4 -17.6C-50 -20.8 -48 -24.6 -47.6 -25.4C-47.2 -26.2 -47.2 -32 -45.8 -29.4L-42.4 -26.8C-42.4 -26.8 -45.2 -29.4 -43 -31.6C-43 -31.6 -44 -37.2 -42.2 -39.8C-42.2 -39.8 -35.2 -48.2 -33.6 -49.2C-32 -50.2 -33.4 -49.8 -33.4 -49.8C-33.4 -49.8 -27.4 -54 -33.2 -52.4C-33.2 -52.4 -37.2 -50.8 -40.2 -50.8C-40.2 -50.8 -47.8 -48.8 -43.8 -53C-39.8 -57.2 -29.8 -62.6 -26 -62.4L-25.2 -60.8L-14 -63.2L-15.2 -62.4C-15.2 -62.4 -15.4 -62.6 -11.2 -63C-7 -63.4 -1.2 -62 0.2 -63.8C1.6 -65.6 5 -66.6 4.6 -65.2C4.2 -63.8 4 -61.8 4 -61.8C4 -61.8 9 -67.6 8.4 -65.4C7.8 -63.2 -0.4 -58 -1.8 -51.8L8.6 -60L12.2 -63C12.2 -63 15.8 -60.8 16 -62.4C16.2 -64 20.8 -69.8 22 -69.6C23.2 -69.4 25.2 -72.2 25 -69.6C24.8 -67 32.4 -61.6 32.4 -61.6C32.4 -61.6 35.6 -63.4 37 -62C38.4 -60.6 42.6 -81.8 42.6 -81.8L67.6 -92.4L111.201 -95.8L94.201 -102.6L33.2 -114z"} + , + {"stroke":"#4c0000", "width":2, + "path":"M51.4 85C51.4 85 36.4 68.2 28 65.6C28 65.6 14.6 58.8 -10 66.6"} + , + {"stroke":"#4c0000", "width":2, + "path":"M24.8 64.2C24.8 64.2 -0.4 56.2 -15.8 60.4C-15.8 60.4 -34.2 62.4 -42.6 76.2"} + , + {"stroke":"#4c0000", "width":2, + "path":"M21.2 63C21.2 63 4.2 55.8 -10.6 53.6C-10.6 53.6 -27.2 51 -43.8 58.2C-43.8 58.2 -56 64.2 -61.4 74.4"} + , + {"stroke":"#4c0000", "width":2, + "path":"M22.2 63.4C22.2 63.4 6.8 52.4 5.8 51C5.8 51 -1.2 40 -14.2 39.6C-14.2 39.6 -35.6 40.4 -52.8 48.4"} + , + {"fill": "#000000", + "path":"M20.895 54.407C22.437 55.87 49.4 84.8 49.4 84.8C84.6 121.401 56.6 87.2 56.6 87.2C49 82.4 39.8 63.6 39.8 63.6C38.6 60.8 53.8 70.8 53.8 70.8C57.8 71.6 71.4 90.8 71.4 90.8C64.6 88.4 69.4 95.6 69.4 95.6C72.2 97.6 92.601 113.201 92.601 113.201C96.201 117.201 100.201 118.801 100.201 118.801C114.201 113.601 107.801 126.801 107.801 126.801C110.201 133.601 115.801 122.001 115.801 122.001C127.001 105.2 110.601 107.601 110.601 107.601C80.6 110.401 73.8 94.4 73.8 94.4C71.4 92 80.2 94.4 80.2 94.4C88.601 96.4 73 82 73 82C75.4 82 84.6 88.8 84.6 88.8C95.001 98 97.001 96 97.001 96C115.001 87.2 125.401 94.8 125.401 94.8C127.401 96.4 121.801 103.2 123.401 108.401C125.001 113.601 129.801 126.001 129.801 126.001C127.401 127.601 127.801 138.401 127.801 138.401C144.601 161.601 135.001 159.601 135.001 159.601C119.401 159.201 134.201 166.801 134.201 166.801C137.401 168.801 146.201 176.001 146.201 176.001C143.401 174.801 141.801 180.001 141.801 180.001C146.601 184.001 143.801 188.801 143.801 188.801C137.801 190.001 136.601 194.001 136.601 194.001C143.401 202.001 133.401 202.401 133.401 202.401C137.001 206.801 132.201 218.801 132.201 218.801C127.401 218.801 121.001 224.401 121.001 224.401C123.401 229.201 113.001 234.801 113.001 234.801C104.601 236.401 107.401 243.201 107.401 243.201C99.401 249.201 97.001 265.201 97.001 265.201C96.201 275.601 93.801 278.801 99.001 276.801C104.201 274.801 103.401 262.401 103.401 262.401C98.601 246.801 141.401 230.801 141.401 230.801C145.401 229.201 146.201 224.001 146.201 224.001C148.201 224.401 157.001 232.001 157.001 232.001C164.601 243.201 165.001 234.001 165.001 234.001C166.201 230.401 164.601 224.401 164.601 224.401C170.601 202.801 156.601 196.401 156.601 196.401C146.601 162.801 160.601 171.201 160.601 171.201C163.401 176.801 174.201 182.001 174.201 182.001L177.801 179.601C176.201 174.801 184.601 168.801 184.601 168.801C187.401 175.201 193.401 167.201 193.401 167.201C197.001 142.801 209.401 157.201 209.401 157.201C213.401 158.401 214.601 151.601 214.601 151.601C218.201 141.201 214.601 127.601 214.601 127.601C218.201 127.201 227.801 133.201 227.801 133.201C230.601 129.601 221.401 112.801 225.401 115.201C229.401 117.601 233.801 119.201 233.801 119.201C234.601 117.201 224.601 104.801 224.601 104.801C220.201 102 215.001 81.6 215.001 81.6C222.201 85.2 212.201 70 212.201 70C212.201 66.8 218.201 55.6 218.201 55.6C217.401 48.8 218.201 49.2 218.201 49.2C221.001 50.4 229.001 52 222.201 45.6C215.401 39.2 223.001 34.4 223.001 34.4C227.401 31.6 213.801 32 213.801 32C208.601 27.6 209.001 23.6 209.001 23.6C217.001 25.6 202.601 11.2 200.201 7.6C197.801 4 207.401 -1.2 207.401 -1.2C220.601 -4.8 209.001 -8 209.001 -8C189.401 -7.6 200.201 -18.4 200.201 -18.4C206.201 -18 204.601 -20.4 204.601 -20.4C199.401 -21.6 189.801 -28 189.801 -28C185.801 -31.6 189.401 -30.8 189.401 -30.8C206.201 -29.6 177.401 -40.8 177.401 -40.8C185.401 -40.8 167.401 -51.2 167.401 -51.2C165.401 -52.8 162.201 -60.4 162.201 -60.4C156.201 -65.6 151.401 -72.4 151.401 -72.4C151.001 -76.8 146.201 -81.6 146.201 -81.6C134.601 -95.2 129.001 -94.8 129.001 -94.8C114.201 -98.4 109.001 -97.6 109.001 -97.6L56.2 -93.2C29.8 -80.4 37.6 -59.4 37.6 -59.4C44 -51 53.2 -54.8 53.2 -54.8C57.8 -61 69.4 -58.8 69.4 -58.8C89.801 -55.6 87.201 -59.2 87.201 -59.2C84.801 -63.8 68.6 -70 68.4 -70.6C68.2 -71.2 59.4 -74.6 59.4 -74.6C56.4 -75.8 52 -85 52 -85C48.8 -88.4 64.6 -82.6 64.6 -82.6C63.4 -81.6 70.8 -77.6 70.8 -77.6C88.201 -78.6 98.801 -67.8 98.801 -67.8C109.601 -51.2 109.801 -59.4 109.801 -59.4C112.601 -68.8 100.801 -90 100.801 -90C101.201 -92 109.401 -85.4 109.401 -85.4C110.801 -87.4 111.601 -81.6 111.601 -81.6C111.801 -79.2 115.601 -71.2 115.601 -71.2C118.401 -58.2 122.001 -65.6 122.001 -65.6L126.601 -56.2C128.001 -53.6 122.001 -46 122.001 -46C121.801 -43.2 122.601 -43.4 117.001 -35.8C111.401 -28.2 114.801 -23.8 114.801 -23.8C113.401 -17.2 122.201 -17.6 122.201 -17.6C124.801 -15.4 128.201 -15.4 128.201 -15.4C130.001 -13.4 132.401 -14 132.401 -14C134.001 -17.8 140.201 -15.8 140.201 -15.8C141.601 -18.2 149.801 -18.6 149.801 -18.6C150.801 -21.2 151.201 -22.8 154.601 -23.4C158.001 -24 133.401 -67 133.401 -67C139.801 -67.8 131.601 -80.2 131.601 -80.2C129.401 -86.8 140.801 -72.2 143.001 -70.8C145.201 -69.4 146.201 -67.2 144.601 -67.4C143.001 -67.6 141.201 -65.4 142.601 -65.2C144.001 -65 157.001 -50 160.401 -39.8C163.801 -29.6 169.801 -25.6 176.001 -19.6C182.201 -13.6 181.401 10.6 181.401 10.6C181.001 19.4 187.001 30 187.001 30C189.001 33.8 184.801 52 184.801 52C182.801 54.2 184.201 55 184.201 55C185.201 56.2 192.001 69.4 192.001 69.4C190.201 69.2 193.801 72.8 193.801 72.8C199.001 78.8 192.601 75.8 192.601 75.8C186.601 74.2 193.601 84 193.601 84C194.801 85.8 185.801 81.2 185.801 81.2C176.601 80.6 188.201 87.8 188.201 87.8C196.801 95 185.401 90.6 185.401 90.6C180.801 88.8 184.001 95.6 184.001 95.6C187.201 97.2 204.401 104.2 204.401 104.2C204.801 108.001 201.801 113.001 201.801 113.001C202.201 117.001 200.001 120.401 200.001 120.401C198.801 128.601 198.201 129.401 198.201 129.401C194.001 129.601 186.601 143.401 186.601 143.401C184.801 146.001 174.601 158.001 174.601 158.001C172.601 165.001 154.601 157.801 154.601 157.801C148.001 161.201 150.001 157.801 150.001 157.801C149.601 155.601 154.401 149.601 154.401 149.601C161.401 147.001 158.801 136.201 158.801 136.201C162.801 134.801 151.601 132.001 151.801 130.801C152.001 129.601 157.801 128.201 157.801 128.201C165.801 126.201 161.401 123.801 161.401 123.801C160.801 119.801 163.801 114.201 163.801 114.201C175.401 113.401 163.801 97.2 163.801 97.2C153.001 89.6 152.001 83.8 152.001 83.8C164.601 75.6 156.401 63.2 156.601 59.6C156.801 56 158.001 34.4 158.001 34.4C156.001 28.2 153.001 14.6 153.001 14.6C155.201 9.4 162.601 -3.2 162.601 -3.2C165.401 -7.4 174.201 -12.2 172.001 -15.2C169.801 -18.2 162.001 -16.4 162.001 -16.4C154.201 -17.8 154.801 -12.6 154.801 -12.6C153.201 -11.6 152.401 -6.6 152.401 -6.6C151.68 1.333 142.801 7.6 142.801 7.6C131.601 13.8 140.801 17.8 140.801 17.8C146.801 24.4 137.001 24.6 137.001 24.6C126.001 22.8 134.201 33 134.201 33C145.001 45.8 142.001 48.6 142.001 48.6C131.801 49.6 144.401 58.8 144.401 58.8C144.401 58.8 143.601 56.8 143.801 58.6C144.001 60.4 147.001 64.6 147.801 66.6C148.601 68.6 144.601 68.8 144.601 68.8C145.201 78.4 129.801 74.2 129.801 74.2C129.801 74.2 129.801 74.2 128.201 74.4C126.601 74.6 115.401 73.8 109.601 71.6C103.801 69.4 97.001 69.4 97.001 69.4C97.001 69.4 93.001 71.2 85.4 71C77.8 70.8 69.8 73.6 69.8 73.6C65.4 73.2 74 68.8 74.2 69C74.4 69.2 80 63.6 72 64.2C50.203 65.835 39.4 55.6 39.4 55.6C37.4 54.2 34.8 51.4 34.8 51.4C24.8 49.4 36.2 63.8 36.2 63.8C37.4 65.2 36 66.2 36 66.2C35.2 64.6 27.4 59.2 27.4 59.2C24.589 58.227 23.226 56.893 20.895 54.407z"} + , + {"fill": "#4c0000", + "path":"M-3 42.8C-3 42.8 8.6 48.4 11.2 51.2C13.8 54 27.8 65.4 27.8 65.4C27.8 65.4 22.4 63.4 19.8 61.6C17.2 59.8 6.4 51.6 6.4 51.6C6.4 51.6 2.6 45.6 -3 42.8z"} + , + {"fill": "#99cc32", + "path":"M-61.009 11.603C-60.672 11.455 -61.196 8.743 -61.4 8.2C-62.422 5.474 -71.4 4 -71.4 4C-71.627 5.365 -71.682 6.961 -71.576 8.599C-71.576 8.599 -66.708 14.118 -61.009 11.603z"} + , + {"fill": "#659900", + "path":"M-61.009 11.403C-61.458 11.561 -61.024 8.669 -61.2 8.2C-62.222 5.474 -71.4 3.9 -71.4 3.9C-71.627 5.265 -71.682 6.861 -71.576 8.499C-71.576 8.499 -67.308 13.618 -61.009 11.403z"} + , + {"fill": "#000000", + "path":"M-65.4 11.546C-66.025 11.546 -66.531 10.406 -66.531 9C-66.531 7.595 -66.025 6.455 -65.4 6.455C-64.775 6.455 -64.268 7.595 -64.268 9C-64.268 10.406 -64.775 11.546 -65.4 11.546z"} + , + {"fill": "#000000", + "path":"M-65.4 9z"} + , + {"fill": "#000000", + "path":"M-111 109.601C-111 109.601 -116.6 119.601 -91.8 113.601C-91.8 113.601 -77.8 112.401 -75.4 110.001C-74.2 110.801 -65.834 113.734 -63 114.401C-56.2 116.001 -47.8 106 -47.8 106C-47.8 106 -43.2 95.5 -40.4 95.5C-37.6 95.5 -40.8 97.1 -40.8 97.1C-40.8 97.1 -47.4 107.201 -47 108.801C-47 108.801 -52.2 128.801 -68.2 129.601C-68.2 129.601 -84.35 130.551 -83 136.401C-83 136.401 -74.2 134.001 -71.8 136.401C-71.8 136.401 -61 136.001 -69 142.401L-75.8 154.001C-75.8 154.001 -75.66 157.919 -85.8 154.401C-95.6 151.001 -105.9 138.101 -105.9 138.101C-105.9 138.101 -121.85 123.551 -111 109.601z"} + , + {"fill": "#e59999", + "path":"M-112.2 113.601C-112.2 113.601 -114.2 123.201 -77.4 112.801C-77.4 112.801 -73 112.801 -70.6 113.601C-68.2 114.401 -56.2 117.201 -54.2 116.001C-54.2 116.001 -61.4 129.601 -73 128.001C-73 128.001 -86.2 129.601 -85.8 134.401C-85.8 134.401 -81.8 141.601 -77 144.001C-77 144.001 -74.2 146.401 -74.6 149.601C-75 152.801 -77.8 154.401 -79.8 155.201C-81.8 156.001 -85 152.801 -86.6 152.801C-88.2 152.801 -96.6 146.401 -101 141.601C-105.4 136.801 -113.8 124.801 -113.4 122.001C-113 119.201 -112.2 113.601 -112.2 113.601z"} + , + {"fill": "#b26565", + "path":"M-109 131.051C-106.4 135.001 -103.2 139.201 -101 141.601C-96.6 146.401 -88.2 152.801 -86.6 152.801C-85 152.801 -81.8 156.001 -79.8 155.201C-77.8 154.401 -75 152.801 -74.6 149.601C-74.2 146.401 -77 144.001 -77 144.001C-80.066 142.468 -82.806 138.976 -84.385 136.653C-84.385 136.653 -84.2 139.201 -89.4 138.401C-94.6 137.601 -99.8 134.801 -101.4 131.601C-103 128.401 -105.4 126.001 -103.8 129.601C-102.2 133.201 -99.8 136.801 -98.2 137.201C-96.6 137.601 -97 138.801 -99.4 138.401C-101.8 138.001 -104.6 137.601 -109 132.401z"} + , + {"fill": "#992600", + "path":"M-111.6 110.001C-111.6 110.001 -109.8 96.4 -108.6 92.4C-108.6 92.4 -109.4 85.6 -107 81.4C-104.6 77.2 -102.6 71 -99.6 65.6C-96.6 60.2 -96.4 56.2 -92.4 54.6C-88.4 53 -82.4 44.4 -79.6 43.4C-76.8 42.4 -77 43.2 -77 43.2C-77 43.2 -70.2 28.4 -56.6 32.4C-56.6 32.4 -72.8 29.6 -57 20.2C-57 20.2 -61.8 21.3 -58.5 14.3C-56.299 9.632 -56.8 16.4 -67.8 28.2C-67.8 28.2 -72.8 36.8 -78 39.8C-83.2 42.8 -95.2 49.8 -96.4 53.6C-97.6 57.4 -100.8 63.2 -102.8 64.8C-104.8 66.4 -107.6 70.6 -108 74C-108 74 -109.2 78 -110.6 79.2C-112 80.4 -112.2 83.6 -112.2 85.6C-112.2 87.6 -114.2 90.4 -114 92.8C-114 92.8 -113.2 111.801 -113.6 113.801L-111.6 110.001z"} + , + {"fill": "#ffffff", + "path":"M-120.2 114.601C-120.2 114.601 -122.2 113.201 -126.6 119.201C-126.6 119.201 -119.3 152.201 -119.3 153.601C-119.3 153.601 -118.2 151.501 -119.5 144.301C-120.8 137.101 -121.7 124.401 -121.7 124.401L-120.2 114.601z"} + , + {"fill": "#992600", + "path":"M-98.6 54C-98.6 54 -116.2 57.2 -115.8 86.4L-116.6 111.201C-116.6 111.201 -117.8 85.6 -119 84C-120.2 82.4 -116.2 71.2 -119.4 77.2C-119.4 77.2 -133.4 91.2 -125.4 112.401C-125.4 112.401 -123.9 115.701 -126.9 111.101C-126.9 111.101 -131.5 98.5 -130.4 92.1C-130.4 92.1 -130.2 89.9 -128.3 87.1C-128.3 87.1 -119.7 75.4 -117 73.1C-117 73.1 -115.2 58.7 -99.8 53.5C-99.8 53.5 -94.1 51.2 -98.6 54z"} + , + {"fill": "#000000", + "path":"M40.8 -12.2C41.46 -12.554 41.451 -13.524 42.031 -13.697C43.18 -14.041 43.344 -15.108 43.862 -15.892C44.735 -17.211 44.928 -18.744 45.51 -20.235C45.782 -20.935 45.809 -21.89 45.496 -22.55C44.322 -25.031 43.62 -27.48 42.178 -29.906C41.91 -30.356 41.648 -31.15 41.447 -31.748C40.984 -33.132 39.727 -34.123 38.867 -35.443C38.579 -35.884 39.104 -36.809 38.388 -36.893C37.491 -36.998 36.042 -37.578 35.809 -36.552C35.221 -33.965 36.232 -31.442 37.2 -29C36.418 -28.308 36.752 -27.387 36.904 -26.62C37.614 -23.014 36.416 -19.662 35.655 -16.188C35.632 -16.084 35.974 -15.886 35.946 -15.824C34.724 -13.138 33.272 -10.693 31.453 -8.312C30.695 -7.32 29.823 -6.404 29.326 -5.341C28.958 -4.554 28.55 -3.588 28.8 -2.6C25.365 0.18 23.115 4.025 20.504 7.871C20.042 8.551 20.333 9.76 20.884 10.029C21.697 10.427 22.653 9.403 23.123 8.557C23.512 7.859 23.865 7.209 24.356 6.566C24.489 6.391 24.31 5.972 24.445 5.851C27.078 3.504 28.747 0.568 31.2 -1.8C33.15 -2.129 34.687 -3.127 36.435 -4.14C36.743 -4.319 37.267 -4.07 37.557 -4.265C39.31 -5.442 39.308 -7.478 39.414 -9.388C39.464 -10.272 39.66 -11.589 40.8 -12.2z"} + , + {"fill": "#000000", + "path":"M31.959 -16.666C32.083 -16.743 31.928 -17.166 32.037 -17.382C32.199 -17.706 32.602 -17.894 32.764 -18.218C32.873 -18.434 32.71 -18.814 32.846 -18.956C35.179 -21.403 35.436 -24.427 34.4 -27.4C35.424 -28.02 35.485 -29.282 35.06 -30.129C34.207 -31.829 34.014 -33.755 33.039 -35.298C32.237 -36.567 30.659 -37.811 29.288 -36.508C28.867 -36.108 28.546 -35.321 28.824 -34.609C28.888 -34.446 29.173 -34.3 29.146 -34.218C29.039 -33.894 28.493 -33.67 28.487 -33.398C28.457 -31.902 27.503 -30.391 28.133 -29.062C28.905 -27.433 29.724 -25.576 30.4 -23.8C29.166 -21.684 30.199 -19.235 28.446 -17.358C28.31 -17.212 28.319 -16.826 28.441 -16.624C28.733 -16.138 29.139 -15.732 29.625 -15.44C29.827 -15.319 30.175 -15.317 30.375 -15.441C30.953 -15.803 31.351 -16.29 31.959 -16.666z"} + , + {"fill": "#000000", + "path":"M94.771 -26.977C96.16 -25.185 96.45 -22.39 94.401 -21C94.951 -17.691 98.302 -19.67 100.401 -20.2C100.292 -20.588 100.519 -20.932 100.802 -20.937C101.859 -20.952 102.539 -21.984 103.601 -21.8C104.035 -23.357 105.673 -24.059 106.317 -25.439C108.043 -29.134 107.452 -33.407 104.868 -36.653C104.666 -36.907 104.883 -37.424 104.759 -37.786C104.003 -39.997 101.935 -40.312 100.001 -41C98.824 -44.875 98.163 -48.906 96.401 -52.6C94.787 -52.85 94.089 -54.589 92.752 -55.309C91.419 -56.028 90.851 -54.449 90.892 -53.403C90.899 -53.198 91.351 -52.974 91.181 -52.609C91.105 -52.445 90.845 -52.334 90.845 -52.2C90.846 -52.065 91.067 -51.934 91.201 -51.8C90.283 -50.98 88.86 -50.503 88.565 -49.358C87.611 -45.648 90.184 -42.523 91.852 -39.322C92.443 -38.187 91.707 -36.916 90.947 -35.708C90.509 -35.013 90.617 -33.886 90.893 -33.03C91.645 -30.699 93.236 -28.96 94.771 -26.977z"} + , + {"fill": "#000000", + "path":"M57.611 -8.591C56.124 -6.74 52.712 -4.171 55.629 -2.243C55.823 -2.114 56.193 -2.11 56.366 -2.244C58.387 -3.809 60.39 -4.712 62.826 -5.294C62.95 -5.323 63.224 -4.856 63.593 -5.017C65.206 -5.72 67.216 -5.662 68.4 -7C72.167 -6.776 75.732 -7.892 79.123 -9.2C80.284 -9.648 81.554 -10.207 82.755 -10.709C84.131 -11.285 85.335 -12.213 86.447 -13.354C86.58 -13.49 86.934 -13.4 87.201 -13.4C87.161 -14.263 88.123 -14.39 88.37 -15.012C88.462 -15.244 88.312 -15.64 88.445 -15.742C90.583 -17.372 91.503 -19.39 90.334 -21.767C90.049 -22.345 89.8 -22.963 89.234 -23.439C88.149 -24.35 87.047 -23.496 86 -23.8C85.841 -23.172 85.112 -23.344 84.726 -23.146C83.867 -22.707 82.534 -23.292 81.675 -22.854C80.313 -22.159 79.072 -21.99 77.65 -21.613C77.338 -21.531 76.56 -21.627 76.4 -21C76.266 -21.134 76.118 -21.368 76.012 -21.346C74.104 -20.95 72.844 -20.736 71.543 -19.044C71.44 -18.911 70.998 -19.09 70.839 -18.955C69.882 -18.147 69.477 -16.913 68.376 -16.241C68.175 -16.118 67.823 -16.286 67.629 -16.157C66.983 -15.726 66.616 -15.085 65.974 -14.638C65.645 -14.409 65.245 -14.734 65.277 -14.99C65.522 -16.937 66.175 -18.724 65.6 -20.6C67.677 -23.12 70.194 -25.069 72 -27.8C72.015 -29.966 72.707 -32.112 72.594 -34.189C72.584 -34.382 72.296 -35.115 72.17 -35.462C71.858 -36.316 72.764 -37.382 71.92 -38.106C70.516 -39.309 69.224 -38.433 68.4 -37C66.562 -36.61 64.496 -35.917 62.918 -37.151C61.911 -37.938 61.333 -38.844 60.534 -39.9C59.549 -41.202 59.884 -42.638 59.954 -44.202C59.96 -44.33 59.645 -44.466 59.645 -44.6C59.646 -44.735 59.866 -44.866 60 -45C59.294 -45.626 59.019 -46.684 58 -47C58.305 -48.092 57.629 -48.976 56.758 -49.278C54.763 -49.969 53.086 -48.057 51.194 -47.984C50.68 -47.965 50.213 -49.003 49.564 -49.328C49.132 -49.544 48.428 -49.577 48.066 -49.311C47.378 -48.807 46.789 -48.693 46.031 -48.488C44.414 -48.052 43.136 -46.958 41.656 -46.103C40.171 -45.246 39.216 -43.809 38.136 -42.489C37.195 -41.337 37.059 -38.923 38.479 -38.423C40.322 -37.773 41.626 -40.476 43.592 -40.15C43.904 -40.099 44.11 -39.788 44 -39.4C44.389 -39.291 44.607 -39.52 44.8 -39.8C45.658 -38.781 46.822 -38.444 47.76 -37.571C48.73 -36.667 50.476 -37.085 51.491 -36.088C53.02 -34.586 52.461 -31.905 54.4 -30.6C53.814 -29.287 53.207 -28.01 52.872 -26.583C52.59 -25.377 53.584 -24.18 54.795 -24.271C56.053 -24.365 56.315 -25.124 56.8 -26.2C57.067 -25.933 57.536 -25.636 57.495 -25.42C57.038 -23.033 56.011 -21.04 55.553 -18.609C55.494 -18.292 55.189 -18.09 54.8 -18.2C54.332 -14.051 50.28 -11.657 47.735 -8.492C47.332 -7.99 47.328 -6.741 47.737 -6.338C49.14 -4.951 51.1 -6.497 52.8 -7C53.013 -8.206 53.872 -9.148 55.204 -9.092C55.46 -9.082 55.695 -9.624 56.019 -9.754C56.367 -9.892 56.869 -9.668 57.155 -9.866C58.884 -11.061 60.292 -12.167 62.03 -13.356C62.222 -13.487 62.566 -13.328 62.782 -13.436C63.107 -13.598 63.294 -13.985 63.617 -14.17C63.965 -14.37 64.207 -14.08 64.4 -13.8C63.754 -13.451 63.75 -12.494 63.168 -12.292C62.393 -12.024 61.832 -11.511 61.158 -11.064C60.866 -10.871 60.207 -11.119 60.103 -10.94C59.505 -9.912 58.321 -9.474 57.611 -8.591z"} + , + {"fill": "#000000", + "path":"M2.2 -58C2.2 -58 -7.038 -60.872 -18.2 -35.2C-18.2 -35.2 -20.6 -30 -23 -28C-25.4 -26 -36.6 -22.4 -38.6 -18.4L-49 -2.4C-49 -2.4 -34.2 -18.4 -31 -20.8C-31 -20.8 -23 -29.2 -26.2 -22.4C-26.2 -22.4 -40.2 -11.6 -39 -2.4C-39 -2.4 -44.6 12 -45.4 14C-45.4 14 -29.4 -18 -27 -19.2C-24.6 -20.4 -23.4 -20.4 -24.6 -16.8C-25.8 -13.2 -26.2 3.2 -29 5.2C-29 5.2 -21 -15.2 -21.8 -18.4C-21.8 -18.4 -18.6 -22 -16.2 -16.8L-17.4 -0.8L-13 11.2C-13 11.2 -15.4 0 -13.8 -15.6C-13.8 -15.6 -15.8 -26 -11.8 -20.4C-7.8 -14.8 1.8 -8.8 1.8 -4C1.8 -4 -3.4 -21.6 -12.6 -26.4L-16.6 -20.4L-17.8 -22.4C-17.8 -22.4 -21.4 -23.2 -17 -30C-12.6 -36.8 -13 -37.6 -13 -37.6C-13 -37.6 -6.6 -30.4 -5 -30.4C-5 -30.4 8.2 -38 9.4 -13.6C9.4 -13.6 16.2 -28 7 -34.8C7 -34.8 -7.8 -36.8 -6.6 -42L0.6 -54.4C4.2 -59.6 2.6 -56.8 2.6 -56.8z"} + , + {"fill": "#000000", + "path":"M-17.8 -41.6C-17.8 -41.6 -30.6 -41.6 -33.8 -36.4L-41 -26.8C-41 -26.8 -23.8 -36.8 -19.8 -38C-15.8 -39.2 -17.8 -41.6 -17.8 -41.6z"} + , + {"fill": "#000000", + "path":"M-57.8 -35.2C-57.8 -35.2 -59.8 -34 -60.2 -31.2C-60.6 -28.4 -63 -28 -62.2 -25.2C-61.4 -22.4 -59.4 -20 -59.4 -24C-59.4 -28 -57.8 -30 -57 -31.2C-56.2 -32.4 -54.6 -36.8 -57.8 -35.2z"} + , + {"fill": "#000000", + "path":"M-66.6 26C-66.6 26 -75 22 -78.2 18.4C-81.4 14.8 -80.948 19.966 -85.8 19.6C-91.647 19.159 -90.6 3.2 -90.6 3.2L-94.6 10.8C-94.6 10.8 -95.8 25.2 -87.8 22.8C-83.893 21.628 -82.6 23.2 -84.2 24C-85.8 24.8 -78.6 25.2 -81.4 26.8C-84.2 28.4 -69.8 23.2 -72.2 33.6L-66.6 26z"} + , + {"fill": "#000000", + "path":"M-79.2 40.4C-79.2 40.4 -94.6 44.8 -98.2 35.2C-98.2 35.2 -103 37.6 -100.8 40.6C-98.6 43.6 -97.4 44 -97.4 44C-97.4 44 -92 45.2 -92.6 46C-93.2 46.8 -95.6 50.2 -95.6 50.2C-95.6 50.2 -85.4 44.2 -79.2 40.4z"} + , + {"fill": "#ffffff", + "path":"M149.201 118.601C148.774 120.735 147.103 121.536 145.201 122.201C143.284 121.243 140.686 118.137 138.801 120.201C138.327 119.721 137.548 119.661 137.204 118.999C136.739 118.101 137.011 117.055 136.669 116.257C136.124 114.985 135.415 113.619 135.601 112.201C137.407 111.489 138.002 109.583 137.528 107.82C137.459 107.563 137.03 107.366 137.23 107.017C137.416 106.694 137.734 106.467 138.001 106.2C137.866 106.335 137.721 106.568 137.61 106.548C137 106.442 137.124 105.805 137.254 105.418C137.839 103.672 139.853 103.408 141.201 104.6C141.457 104.035 141.966 104.229 142.401 104.2C142.351 103.621 142.759 103.094 142.957 102.674C143.475 101.576 145.104 102.682 145.901 102.07C146.977 101.245 148.04 100.546 149.118 101.149C150.927 102.162 152.636 103.374 153.835 105.115C154.41 105.949 154.65 107.23 154.592 108.188C154.554 108.835 153.173 108.483 152.83 109.412C152.185 111.16 154.016 111.679 154.772 113.017C154.97 113.366 154.706 113.67 154.391 113.768C153.98 113.896 153.196 113.707 153.334 114.16C154.306 117.353 151.55 118.031 149.201 118.601z"} + , + {"fill": "#ffffff", + "path":"M139.6 138.201C139.593 136.463 137.992 134.707 139.201 133.001C139.336 133.135 139.467 133.356 139.601 133.356C139.736 133.356 139.867 133.135 140.001 133.001C141.496 135.217 145.148 136.145 145.006 138.991C144.984 139.438 143.897 140.356 144.801 141.001C142.988 142.349 142.933 144.719 142.001 146.601C140.763 146.315 139.551 145.952 138.401 145.401C138.753 143.915 138.636 142.231 139.456 140.911C139.89 140.213 139.603 139.134 139.6 138.201z"} + , + {"fill": "#cccccc", + "path":"M-26.6 129.201C-26.6 129.201 -43.458 139.337 -29.4 124.001C-20.6 114.401 -10.6 108.801 -10.6 108.801C-10.6 108.801 -0.2 104.4 3.4 103.2C7 102 22.2 96.8 25.4 96.4C28.6 96 38.2 92 45 96C51.8 100 59.8 104.4 59.8 104.4C59.8 104.4 43.4 96 39.8 98.4C36.2 100.8 29 100.4 23 103.6C23 103.6 8.2 108.001 5 110.001C1.8 112.001 -8.6 123.601 -10.2 122.801C-11.8 122.001 -9.8 121.601 -8.6 118.801C-7.4 116.001 -9.4 114.401 -17.4 120.801C-25.4 127.201 -26.6 129.201 -26.6 129.201z"} + , + {"fill": "#000000", + "path":"M-19.195 123.234C-19.195 123.234 -17.785 110.194 -9.307 111.859C-9.307 111.859 -1.081 107.689 1.641 105.721C1.641 105.721 9.78 104.019 11.09 103.402C29.569 94.702 44.288 99.221 44.835 98.101C45.381 96.982 65.006 104.099 68.615 108.185C69.006 108.628 58.384 102.588 48.686 100.697C40.413 99.083 18.811 100.944 7.905 106.48C4.932 107.989 -4.013 113.773 -6.544 113.662C-9.075 113.55 -19.195 123.234 -19.195 123.234z"} + , + {"fill": "#cccccc", + "path":"M-23 148.801C-23 148.801 -38.2 146.401 -21.4 144.801C-21.4 144.801 -3.4 142.801 0.6 137.601C0.6 137.601 14.2 128.401 17 128.001C19.8 127.601 49.8 120.401 50.2 118.001C50.6 115.601 56.2 115.601 57.8 116.401C59.4 117.201 58.6 118.401 55.8 119.201C53 120.001 21.8 136.401 15.4 137.601C9 138.801 -2.6 146.401 -7.4 147.601C-12.2 148.801 -23 148.801 -23 148.801z"} + , + {"fill": "#000000", + "path":"M-3.48 141.403C-3.48 141.403 -12.062 140.574 -3.461 139.755C-3.461 139.755 5.355 136.331 7.403 133.668C7.403 133.668 14.367 128.957 15.8 128.753C17.234 128.548 31.194 124.861 31.399 123.633C31.604 122.404 65.67 109.823 70.09 113.013C73.001 115.114 63.1 113.437 53.466 117.847C52.111 118.467 18.258 133.054 14.981 133.668C11.704 134.283 5.765 138.174 3.307 138.788C0.85 139.403 -3.48 141.403 -3.48 141.403z"} + , + {"fill": "#000000", + "path":"M-11.4 143.601C-11.4 143.601 -6.2 143.201 -7.4 144.801C-8.6 146.401 -11 145.601 -11 145.601L-11.4 143.601z"} + , + {"fill": "#000000", + "path":"M-18.6 145.201C-18.6 145.201 -13.4 144.801 -14.6 146.401C-15.8 148.001 -18.2 147.201 -18.2 147.201L-18.6 145.201z"} + , + {"fill": "#000000", + "path":"M-29 146.801C-29 146.801 -23.8 146.401 -25 148.001C-26.2 149.601 -28.6 148.801 -28.6 148.801L-29 146.801z"} + , + {"fill": "#000000", + "path":"M-36.6 147.601C-36.6 147.601 -31.4 147.201 -32.6 148.801C-33.8 150.401 -36.2 149.601 -36.2 149.601L-36.6 147.601z"} + , + {"fill": "#000000", + "path":"M1.8 108.001C1.8 108.001 6.2 108.001 5 109.601C3.8 111.201 0.6 110.801 0.6 110.801L1.8 108.001z"} + , + {"fill": "#000000", + "path":"M-8.2 113.601C-8.2 113.601 -1.694 111.46 -4.2 114.801C-5.4 116.401 -7.8 115.601 -7.8 115.601L-8.2 113.601z"} + , + {"fill": "#000000", + "path":"M-19.4 118.401C-19.4 118.401 -14.2 118.001 -15.4 119.601C-16.6 121.201 -19 120.401 -19 120.401L-19.4 118.401z"} + , + {"fill": "#000000", + "path":"M-27 124.401C-27 124.401 -21.8 124.001 -23 125.601C-24.2 127.201 -26.6 126.401 -26.6 126.401L-27 124.401z"} + , + {"fill": "#000000", + "path":"M-33.8 129.201C-33.8 129.201 -28.6 128.801 -29.8 130.401C-31 132.001 -33.4 131.201 -33.4 131.201L-33.8 129.201z"} + , + {"fill": "#000000", + "path":"M5.282 135.598C5.282 135.598 12.203 135.066 10.606 137.195C9.009 139.325 5.814 138.26 5.814 138.26L5.282 135.598z"} + , + {"fill": "#000000", + "path":"M15.682 130.798C15.682 130.798 22.603 130.266 21.006 132.395C19.409 134.525 16.214 133.46 16.214 133.46L15.682 130.798z"} + , + {"fill": "#000000", + "path":"M26.482 126.398C26.482 126.398 33.403 125.866 31.806 127.995C30.209 130.125 27.014 129.06 27.014 129.06L26.482 126.398z"} + , + {"fill": "#000000", + "path":"M36.882 121.598C36.882 121.598 43.803 121.066 42.206 123.195C40.609 125.325 37.414 124.26 37.414 124.26L36.882 121.598z"} + , + {"fill": "#000000", + "path":"M9.282 103.598C9.282 103.598 16.203 103.066 14.606 105.195C13.009 107.325 9.014 107.06 9.014 107.06L9.282 103.598z"} + , + {"fill": "#000000", + "path":"M19.282 100.398C19.282 100.398 26.203 99.866 24.606 101.995C23.009 104.125 18.614 103.86 18.614 103.86L19.282 100.398z"} + , + {"fill": "#000000", + "path":"M-3.4 140.401C-3.4 140.401 1.8 140.001 0.6 141.601C-0.6 143.201 -3 142.401 -3 142.401L-3.4 140.401z"} + , + {"fill": "#992600", + "path":"M-76.6 41.2C-76.6 41.2 -81 50 -81.4 53.2C-81.4 53.2 -80.6 44.4 -79.4 42.4C-78.2 40.4 -76.6 41.2 -76.6 41.2z"} + , + {"fill": "#992600", + "path":"M-95 55.2C-95 55.2 -98.2 69.6 -97.8 72.4C-97.8 72.4 -99 60.8 -98.6 59.6C-98.2 58.4 -95 55.2 -95 55.2z"} + , + {"fill": "#cccccc", + "path":"M-74.2 -19.4L-74.4 -16.2L-76.6 -16C-76.6 -16 -62.4 -3.4 -61.8 4.2C-61.8 4.2 -61 -4 -74.2 -19.4z"} + , + {"fill": "#000000", + "path":"M-70.216 -18.135C-70.647 -18.551 -70.428 -19.296 -70.836 -19.556C-71.645 -20.072 -69.538 -20.129 -69.766 -20.845C-70.149 -22.051 -69.962 -22.072 -70.084 -23.348C-70.141 -23.946 -69.553 -25.486 -69.168 -25.926C-67.722 -27.578 -69.046 -30.51 -67.406 -32.061C-67.102 -32.35 -66.726 -32.902 -66.441 -33.32C-65.782 -34.283 -64.598 -34.771 -63.648 -35.599C-63.33 -35.875 -63.531 -36.702 -62.962 -36.61C-62.248 -36.495 -61.007 -36.625 -61.052 -35.784C-61.165 -33.664 -62.494 -31.944 -63.774 -30.276C-63.323 -29.572 -63.781 -28.937 -64.065 -28.38C-65.4 -25.76 -65.211 -22.919 -65.385 -20.079C-65.39 -19.994 -65.697 -19.916 -65.689 -19.863C-65.336 -17.528 -64.752 -15.329 -63.873 -13.1C-63.507 -12.17 -63.036 -11.275 -62.886 -10.348C-62.775 -9.662 -62.672 -8.829 -63.08 -8.124C-61.045 -5.234 -62.354 -2.583 -61.185 0.948C-60.978 1.573 -59.286 3.487 -59.749 3.326C-62.262 2.455 -62.374 2.057 -62.551 1.304C-62.697 0.681 -63.027 -0.696 -63.264 -1.298C-63.328 -1.462 -63.499 -3.346 -63.577 -3.468C-65.09 -5.85 -63.732 -5.674 -65.102 -8.032C-66.53 -8.712 -67.496 -9.816 -68.619 -10.978C-68.817 -11.182 -67.674 -11.906 -67.855 -12.119C-68.947 -13.408 -70.1 -14.175 -69.764 -15.668C-69.609 -16.358 -69.472 -17.415 -70.216 -18.135z"} + , + {"fill": "#000000", + "path":"M-73.8 -16.4C-73.8 -16.4 -73.4 -9.6 -71 -8C-68.6 -6.4 -69.8 -7.2 -73 -8.4C-76.2 -9.6 -75 -10.4 -75 -10.4C-75 -10.4 -77.8 -10 -75.4 -8C-73 -6 -69.4 -3.6 -71 -3.6C-72.6 -3.6 -80.2 -7.6 -80.2 -10.4C-80.2 -13.2 -81.2 -17.3 -81.2 -17.3C-81.2 -17.3 -80.1 -18.1 -75.3 -18C-75.3 -18 -73.9 -17.3 -73.8 -16.4z"} + , + {"fill": "#ffffff", "stroke":"#000000", "width":0.1, + "path":"M-74.6 2.2C-74.6 2.2 -83.12 -0.591 -101.6 2.8C-101.6 2.8 -92.569 0.722 -73.8 3C-63.5 4.25 -74.6 2.2 -74.6 2.2z"} + , + {"fill": "#ffffff", "stroke":"#000000", "width":0.1, + "path":"M-72.502 2.129C-72.502 2.129 -80.748 -1.389 -99.453 0.392C-99.453 0.392 -90.275 -0.897 -71.774 2.995C-61.62 5.131 -72.502 2.129 -72.502 2.129z"} + , + {"fill": "#ffffff", "stroke":"#000000", "width":0.1, + "path":"M-70.714 2.222C-70.714 2.222 -78.676 -1.899 -97.461 -1.514C-97.461 -1.514 -88.213 -2.118 -70.052 3.14C-60.086 6.025 -70.714 2.222 -70.714 2.222z"} + , + {"fill": "#ffffff", "stroke":"#000000", "width":0.1, + "path":"M-69.444 2.445C-69.444 2.445 -76.268 -1.862 -93.142 -2.96C-93.142 -2.96 -84.803 -2.79 -68.922 3.319C-60.206 6.672 -69.444 2.445 -69.444 2.445z"} + , + {"fill": "#ffffff", "stroke":"#000000", "width":0.1, + "path":"M45.84 12.961C45.84 12.961 44.91 13.605 45.124 12.424C45.339 11.243 73.547 -1.927 77.161 -1.677C77.161 -1.677 46.913 11.529 45.84 12.961z"} + , + {"fill": "#ffffff", "stroke":"#000000", "width":0.1, + "path":"M42.446 13.6C42.446 13.6 41.57 14.315 41.691 13.121C41.812 11.927 68.899 -3.418 72.521 -3.452C72.521 -3.452 43.404 12.089 42.446 13.6z"} + , + {"fill": "#ffffff", "stroke":"#000000", "width":0.1, + "path":"M39.16 14.975C39.16 14.975 38.332 15.747 38.374 14.547C38.416 13.348 58.233 -2.149 68.045 -4.023C68.045 -4.023 50.015 4.104 39.16 14.975z"} + , + {"fill": "#ffffff", "stroke":"#000000", "width":0.1, + "path":"M36.284 16.838C36.284 16.838 35.539 17.532 35.577 16.453C35.615 15.373 53.449 1.426 62.28 -0.26C62.28 -0.26 46.054 7.054 36.284 16.838z"} + , + {"fill": "#cccccc", + "path":"M4.6 164.801C4.6 164.801 -10.6 162.401 6.2 160.801C6.2 160.801 24.2 158.801 28.2 153.601C28.2 153.601 41.8 144.401 44.6 144.001C47.4 143.601 63.8 140.001 64.2 137.601C64.6 135.201 70.6 132.801 72.2 133.601C73.8 134.401 73.8 143.601 71 144.401C68.2 145.201 49.4 152.401 43 153.601C36.6 154.801 25 162.401 20.2 163.601C15.4 164.801 4.6 164.801 4.6 164.801z"} + , + {"fill": "#000000", + "path":"M77.6 127.401C77.6 127.401 74.6 129.001 73.4 131.601C73.4 131.601 67 142.201 52.8 145.401C52.8 145.401 29.8 154.401 22 156.401C22 156.401 8.6 161.401 1.2 160.601C1.2 160.601 -5.8 160.801 0.4 162.401C0.4 162.401 20.6 160.401 24 158.601C24 158.601 39.6 153.401 42.6 150.801C45.6 148.201 63.8 143.201 66 141.201C68.2 139.201 78 130.801 77.6 127.401z"} + , + {"fill": "#000000", + "path":"M18.882 158.911C18.882 158.911 24.111 158.685 22.958 160.234C21.805 161.784 19.357 160.91 19.357 160.91L18.882 158.911z"} + , + {"fill": "#000000", + "path":"M11.68 160.263C11.68 160.263 16.908 160.037 15.756 161.586C14.603 163.136 12.155 162.263 12.155 162.263L11.68 160.263z"} + , + {"fill": "#000000", + "path":"M1.251 161.511C1.251 161.511 6.48 161.284 5.327 162.834C4.174 164.383 1.726 163.51 1.726 163.51L1.251 161.511z"} + , + {"fill": "#000000", + "path":"M-6.383 162.055C-6.383 162.055 -1.154 161.829 -2.307 163.378C-3.46 164.928 -5.908 164.054 -5.908 164.054L-6.383 162.055z"} + , + {"fill": "#000000", + "path":"M35.415 151.513C35.415 151.513 42.375 151.212 40.84 153.274C39.306 155.336 36.047 154.174 36.047 154.174L35.415 151.513z"} + , + {"fill": "#000000", + "path":"M45.73 147.088C45.73 147.088 51.689 143.787 51.155 148.849C50.885 151.405 46.362 149.749 46.362 149.749L45.73 147.088z"} + , + {"fill": "#000000", + "path":"M54.862 144.274C54.862 144.274 62.021 140.573 60.287 146.035C59.509 148.485 55.493 146.935 55.493 146.935L54.862 144.274z"} + , + {"fill": "#000000", + "path":"M64.376 139.449C64.376 139.449 68.735 134.548 69.801 141.21C70.207 143.748 65.008 142.11 65.008 142.11L64.376 139.449z"} + , + {"fill": "#000000", + "path":"M26.834 155.997C26.834 155.997 32.062 155.77 30.91 157.32C29.757 158.869 27.308 157.996 27.308 157.996L26.834 155.997z"} + , + {"fill": "#ffffff", "stroke":"#000000", "width":0.1, + "path":"M62.434 34.603C62.434 34.603 61.708 35.268 61.707 34.197C61.707 33.127 79.191 19.863 88.034 18.479C88.034 18.479 71.935 25.208 62.434 34.603z"} + , + {"fill": "#000000", + "path":"M65.4 98.4C65.4 98.4 87.401 120.801 96.601 124.401C96.601 124.401 105.801 135.601 101.801 161.601C101.801 161.601 98.601 169.201 95.401 148.401C95.401 148.401 98.601 123.201 87.401 139.201C87.401 139.201 79 129.301 85.4 129.601C85.4 129.601 88.601 131.601 89.001 130.001C89.401 128.401 81.4 114.801 64.2 100.4C47 86 65.4 98.4 65.4 98.4z"} + , + {"fill": "#ffffff", "stroke":"#000000", "width":0.1, + "path":"M7 137.201C7 137.201 6.8 135.401 8.6 136.201C10.4 137.001 104.601 143.201 136.201 167.201C136.201 167.201 91.001 144.001 7 137.201z"} + , + {"fill": "#ffffff", "stroke":"#000000", "width":0.1, + "path":"M17.4 132.801C17.4 132.801 17.2 131.001 19 131.801C20.8 132.601 157.401 131.601 181.001 164.001C181.001 164.001 159.001 138.801 17.4 132.801z"} + , + {"fill": "#ffffff", "stroke":"#000000", "width":0.1, + "path":"M29 128.801C29 128.801 28.8 127.001 30.6 127.801C32.4 128.601 205.801 115.601 229.401 148.001C229.401 148.001 219.801 122.401 29 128.801z"} + , + {"fill": "#ffffff", "stroke":"#000000", "width":0.1, + "path":"M39 124.001C39 124.001 38.8 122.201 40.6 123.001C42.4 123.801 164.601 85.2 188.201 117.601C188.201 117.601 174.801 93 39 124.001z"} + , + {"fill": "#ffffff", "stroke":"#000000", "width":0.1, + "path":"M-19 146.801C-19 146.801 -19.2 145.001 -17.4 145.801C-15.6 146.601 2.2 148.801 4.2 187.601C4.2 187.601 -3 145.601 -19 146.801z"} + , + {"fill": "#ffffff", "stroke":"#000000", "width":0.1, + "path":"M-27.8 148.401C-27.8 148.401 -28 146.601 -26.2 147.401C-24.4 148.201 -10.2 143.601 -13 182.401C-13 182.401 -11.8 147.201 -27.8 148.401z"} + , + {"fill": "#ffffff", "stroke":"#000000", "width":0.1, + "path":"M-35.8 148.801C-35.8 148.801 -36 147.001 -34.2 147.801C-32.4 148.601 -17 149.201 -29.4 171.601C-29.4 171.601 -19.8 147.601 -35.8 148.801z"} + , + {"fill": "#ffffff", "stroke":"#000000", "width":0.1, + "path":"M11.526 104.465C11.526 104.465 11.082 106.464 12.631 105.247C28.699 92.622 61.141 33.72 116.826 28.086C116.826 28.086 78.518 15.976 11.526 104.465z"} + , + {"fill": "#ffffff", "stroke":"#000000", "width":0.1, + "path":"M22.726 102.665C22.726 102.665 21.363 101.472 23.231 100.847C25.099 100.222 137.541 27.72 176.826 35.686C176.826 35.686 149.719 28.176 22.726 102.665z"} + , + {"fill": "#ffffff", "stroke":"#000000", "width":0.1, + "path":"M1.885 108.767C1.885 108.767 1.376 110.366 3.087 109.39C12.062 104.27 15.677 47.059 59.254 45.804C59.254 45.804 26.843 31.09 1.885 108.767z"} + , + {"fill": "#ffffff", "stroke":"#000000", "width":0.1, + "path":"M-18.038 119.793C-18.038 119.793 -19.115 121.079 -17.162 120.825C-6.916 119.493 14.489 78.222 58.928 83.301C58.928 83.301 26.962 68.955 -18.038 119.793z"} + , + {"fill": "#ffffff", "stroke":"#000000", "width":0.1, + "path":"M-6.8 113.667C-6.8 113.667 -7.611 115.136 -5.742 114.511C4.057 111.237 17.141 66.625 61.729 63.078C61.729 63.078 27.603 55.135 -6.8 113.667z"} + , + {"fill": "#ffffff", "stroke":"#000000", "width":0.1, + "path":"M-25.078 124.912C-25.078 124.912 -25.951 125.954 -24.369 125.748C-16.07 124.669 1.268 91.24 37.264 95.354C37.264 95.354 11.371 83.734 -25.078 124.912z"} + , + {"fill": "#ffffff", "stroke":"#000000", "width":0.1, + "path":"M-32.677 130.821C-32.677 130.821 -33.682 131.866 -32.091 131.748C-27.923 131.439 2.715 98.36 21.183 113.862C21.183 113.862 9.168 95.139 -32.677 130.821z"} + , + {"fill": "#ffffff", "stroke":"#000000", "width":0.1, + "path":"M36.855 98.898C36.855 98.898 35.654 97.543 37.586 97.158C39.518 96.774 160.221 39.061 198.184 51.927C198.184 51.927 172.243 41.053 36.855 98.898z"} + , + {"fill": "#ffffff", "stroke":"#000000", "width":0.1, + "path":"M3.4 163.201C3.4 163.201 3.2 161.401 5 162.201C6.8 163.001 22.2 163.601 9.8 186.001C9.8 186.001 19.4 162.001 3.4 163.201z"} + , + {"fill": "#ffffff", "stroke":"#000000", "width":0.1, + "path":"M13.8 161.601C13.8 161.601 13.6 159.801 15.4 160.601C17.2 161.401 35 163.601 37 202.401C37 202.401 29.8 160.401 13.8 161.601z"} + , + {"fill": "#ffffff", "stroke":"#000000", "width":0.1, + "path":"M20.6 160.001C20.6 160.001 20.4 158.201 22.2 159.001C24 159.801 48.6 163.201 72.2 195.601C72.2 195.601 36.6 158.801 20.6 160.001z"} + , + {"fill": "#ffffff", "stroke":"#000000", "width":0.1, + "path":"M28.225 157.972C28.225 157.972 27.788 156.214 29.678 156.768C31.568 157.322 52.002 155.423 90.099 189.599C90.099 189.599 43.924 154.656 28.225 157.972z"} + , + {"fill": "#ffffff", "stroke":"#000000", "width":0.1, + "path":"M38.625 153.572C38.625 153.572 38.188 151.814 40.078 152.368C41.968 152.922 76.802 157.423 128.499 192.399C128.499 192.399 54.324 150.256 38.625 153.572z"} + , + {"fill": "#ffffff", "stroke":"#000000", "width":0.1, + "path":"M-1.8 142.001C-1.8 142.001 -2 140.201 -0.2 141.001C1.6 141.801 55 144.401 85.4 171.201C85.4 171.201 50.499 146.426 -1.8 142.001z"} + , + {"fill": "#ffffff", "stroke":"#000000", "width":0.1, + "path":"M-11.8 146.001C-11.8 146.001 -12 144.201 -10.2 145.001C-8.4 145.801 16.2 149.201 39.8 181.601C39.8 181.601 4.2 144.801 -11.8 146.001z"} + , + {"fill": "#ffffff", "stroke":"#000000", "width":0.1, + "path":"M49.503 148.962C49.503 148.962 48.938 147.241 50.864 147.655C52.79 148.068 87.86 150.004 141.981 181.098C141.981 181.098 64.317 146.704 49.503 148.962z"} + , + {"fill": "#ffffff", "stroke":"#000000", "width":0.1, + "path":"M57.903 146.562C57.903 146.562 57.338 144.841 59.264 145.255C61.19 145.668 96.26 147.604 150.381 178.698C150.381 178.698 73.317 143.904 57.903 146.562z"} + , + {"fill": "#ffffff", "stroke":"#000000", "width":0.1, + "path":"M67.503 141.562C67.503 141.562 66.938 139.841 68.864 140.255C70.79 140.668 113.86 145.004 203.582 179.298C203.582 179.298 82.917 138.904 67.503 141.562z"} + , + {"fill": "#000000", + "path":"M-43.8 148.401C-43.8 148.401 -38.6 148.001 -39.8 149.601C-41 151.201 -43.4 150.401 -43.4 150.401L-43.8 148.401z"} + , + {"fill": "#000000", + "path":"M-13 162.401C-13 162.401 -7.8 162.001 -9 163.601C-10.2 165.201 -12.6 164.401 -12.6 164.401L-13 162.401z"} + , + {"fill": "#000000", + "path":"M-21.8 162.001C-21.8 162.001 -16.6 161.601 -17.8 163.201C-19 164.801 -21.4 164.001 -21.4 164.001L-21.8 162.001z"} + , + {"fill": "#000000", + "path":"M-117.169 150.182C-117.169 150.182 -112.124 151.505 -113.782 152.624C-115.439 153.744 -117.446 152.202 -117.446 152.202L-117.169 150.182z"} + , + {"fill": "#000000", + "path":"M-115.169 140.582C-115.169 140.582 -110.124 141.905 -111.782 143.024C-113.439 144.144 -115.446 142.602 -115.446 142.602L-115.169 140.582z"} + , + {"fill": "#000000", + "path":"M-122.369 136.182C-122.369 136.182 -117.324 137.505 -118.982 138.624C-120.639 139.744 -122.646 138.202 -122.646 138.202L-122.369 136.182z"} + , + {"fill": "#cccccc", + "path":"M-42.6 211.201C-42.6 211.201 -44.2 211.201 -48.2 213.201C-50.2 213.201 -61.4 216.801 -67 226.801C-67 226.801 -54.6 217.201 -42.6 211.201z"} + , + {"fill": "#cccccc", + "path":"M45.116 303.847C45.257 304.105 45.312 304.525 45.604 304.542C46.262 304.582 47.495 304.883 47.37 304.247C46.522 299.941 45.648 295.004 41.515 293.197C40.876 292.918 39.434 293.331 39.36 294.215C39.233 295.739 39.116 297.088 39.425 298.554C39.725 299.975 41.883 299.985 42.8 298.601C43.736 300.273 44.168 302.116 45.116 303.847z"} + , + {"fill": "#cccccc", + "path":"M34.038 308.581C34.786 309.994 34.659 311.853 36.074 312.416C36.814 312.71 38.664 311.735 38.246 310.661C37.444 308.6 37.056 306.361 35.667 304.55C35.467 304.288 35.707 303.755 35.547 303.427C34.953 302.207 33.808 301.472 32.4 301.801C31.285 304.004 32.433 306.133 33.955 307.842C34.091 307.994 33.925 308.37 34.038 308.581z"} + , + {"fill": "#cccccc", + "path":"M-5.564 303.391C-5.672 303.014 -5.71 302.551 -5.545 302.23C-5.014 301.197 -4.221 300.075 -4.558 299.053C-4.906 297.997 -6.022 298.179 -6.672 298.748C-7.807 299.742 -7.856 301.568 -8.547 302.927C-8.743 303.313 -8.692 303.886 -9.133 304.277C-9.607 304.698 -10.047 306.222 -9.951 306.793C-9.898 307.106 -10.081 317.014 -9.859 316.751C-9.24 316.018 -6.19 306.284 -6.121 305.392C-6.064 304.661 -5.332 304.196 -5.564 303.391z"} + , + {"fill": "#cccccc", + "path":"M-31.202 296.599C-28.568 294.1 -25.778 291.139 -26.22 287.427C-26.336 286.451 -28.111 286.978 -28.298 287.824C-29.1 291.449 -31.139 294.11 -33.707 296.502C-35.903 298.549 -37.765 304.893 -38 305.401C-34.303 300.145 -32.046 297.399 -31.202 296.599z"} + , + {"fill": "#cccccc", + "path":"M-44.776 290.635C-44.253 290.265 -44.555 289.774 -44.338 289.442C-43.385 287.984 -42.084 286.738 -42.066 285C-42.063 284.723 -42.441 284.414 -42.776 284.638C-43.053 284.822 -43.395 284.952 -43.503 285.082C-45.533 287.531 -46.933 290.202 -48.376 293.014C-48.559 293.371 -49.703 297.862 -49.39 297.973C-49.151 298.058 -47.431 293.877 -47.221 293.763C-45.958 293.077 -45.946 291.462 -44.776 290.635z"} + , + {"fill": "#cccccc", + "path":"M-28.043 310.179C-27.599 309.31 -26.023 308.108 -26.136 307.219C-26.254 306.291 -25.786 304.848 -26.698 305.536C-27.955 306.484 -31.404 307.833 -31.674 313.641C-31.7 314.212 -28.726 311.519 -28.043 310.179z"} + , + {"fill": "#cccccc", + "path":"M-13.6 293.001C-13.2 292.333 -12.492 292.806 -12.033 292.543C-11.385 292.171 -10.774 291.613 -10.482 290.964C-9.512 288.815 -7.743 286.995 -7.6 284.601C-9.091 283.196 -9.77 285.236 -10.4 286.201C-11.723 284.554 -12.722 286.428 -14.022 286.947C-14.092 286.975 -14.305 286.628 -14.38 286.655C-15.557 287.095 -16.237 288.176 -17.235 288.957C-17.406 289.091 -17.811 288.911 -17.958 289.047C-18.61 289.65 -19.583 289.975 -19.863 290.657C-20.973 293.364 -24.113 295.459 -26 303.001C-25.619 303.91 -21.488 296.359 -21.001 295.661C-20.165 294.465 -20.047 297.322 -18.771 296.656C-18.72 296.629 -18.534 296.867 -18.4 297.001C-18.206 296.721 -17.988 296.492 -17.6 296.601C-17.6 296.201 -17.734 295.645 -17.533 295.486C-16.296 294.509 -16.38 293.441 -15.6 292.201C-15.142 292.99 -14.081 292.271 -13.6 293.001z"} + , + {"fill": "#cccccc", + "path":"M46.2 347.401C46.2 347.401 53.6 327.001 49.2 315.801C49.2 315.801 60.6 337.401 56 348.601C56 348.601 55.6 338.201 51.6 333.201C51.6 333.201 47.6 346.001 46.2 347.401z"} + , + {"fill": "#cccccc", + "path":"M31.4 344.801C31.4 344.801 36.8 336.001 28.8 317.601C28.8 317.601 28 338.001 21.2 349.001C21.2 349.001 35.4 328.801 31.4 344.801z"} + , + {"fill": "#cccccc", + "path":"M21.4 342.801C21.4 342.801 21.2 322.801 21.6 319.801C21.6 319.801 17.8 336.401 7.6 346.001C7.6 346.001 22 334.001 21.4 342.801z"} + , + {"fill": "#cccccc", + "path":"M11.8 310.801C11.8 310.801 17.8 324.401 7.8 342.801C7.8 342.801 14.2 330.601 9.4 323.601C9.4 323.601 12 320.201 11.8 310.801z"} + , + {"fill": "#cccccc", + "path":"M-7.4 342.401C-7.4 342.401 -8.4 326.801 -6.6 324.601C-6.6 324.601 -6.4 318.201 -6.8 317.201C-6.8 317.201 -2.8 311.001 -2.6 318.401C-2.6 318.401 -1.2 326.201 1.6 330.801C1.6 330.801 5.2 336.201 5 342.601C5 342.601 -5 312.401 -7.4 342.401z"} + , + {"fill": "#cccccc", + "path":"M-11 314.801C-11 314.801 -17.6 325.601 -19.4 344.601C-19.4 344.601 -20.8 338.401 -17 324.001C-17 324.001 -12.8 308.601 -11 314.801z"} + , + {"fill": "#cccccc", + "path":"M-32.8 334.601C-32.8 334.601 -27.8 329.201 -26.4 324.201C-26.4 324.201 -22.8 308.401 -29.2 317.001C-29.2 317.001 -29 325.001 -37.2 332.401C-37.2 332.401 -32.4 330.001 -32.8 334.601z"} + , + {"fill": "#cccccc", + "path":"M-38.6 329.601C-38.6 329.601 -35.2 312.201 -34.4 311.401C-34.4 311.401 -32.6 308.001 -35.4 311.201C-35.4 311.201 -44.2 330.401 -48.2 337.001C-48.2 337.001 -40.2 327.801 -38.6 329.601z"} + , + {"fill": "#cccccc", + "path":"M-44.4 313.001C-44.4 313.001 -32.8 290.601 -54.6 316.401C-54.6 316.401 -43.6 306.601 -44.4 313.001z"} + , + {"fill": "#cccccc", + "path":"M-59.8 298.401C-59.8 298.401 -55 279.601 -52.4 279.801C-52.4 279.801 -44.2 270.801 -50.8 281.401C-50.8 281.401 -56.8 291.001 -56.2 300.801C-56.2 300.801 -56.8 291.201 -59.8 298.401z"} + , + {"fill": "#cccccc", + "path":"M270.5 287C270.5 287 258.5 277 256 273.5C256 273.5 269.5 292 269.5 299C269.5 299 272 291.5 270.5 287z"} + , + {"fill": "#cccccc", + "path":"M276 265C276 265 255 250 251.5 242.5C251.5 242.5 278 272 278 276.5C278 276.5 278.5 267.5 276 265z"} + , + {"fill": "#cccccc", + "path":"M293 111C293 111 281 103 279.5 105C279.5 105 290 111.5 292.5 120C292.5 120 291 111 293 111z"} + , + {"fill": "#cccccc", + "path":"M301.5 191.5L284 179.5C284 179.5 303 196.5 303.5 200.5L301.5 191.5z"} + , + {"stroke":"#000000", + "path":"M-89.25 169L-67.25 173.75"} + , + {"stroke":"#000000", + "path":"M-39 331C-39 331 -39.5 327.5 -48.5 338"} + , + {"stroke":"#000000", + "path":"M-33.5 336C-33.5 336 -31.5 329.5 -38 334"} + , + {"stroke":"#000000", + "path":"M20.5 344.5C20.5 344.5 22 333.5 10.5 346.5"} +]; \ No newline at end of file diff --git a/examples/qml/canvas/tiger/tiger.qml b/examples/qml/canvas/tiger/tiger.qml new file mode 100644 index 0000000000..2eb1bb2106 --- /dev/null +++ b/examples/qml/canvas/tiger/tiger.qml @@ -0,0 +1,129 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import "../contents" +import "tiger.js" as Tiger +Item { + id:container + width:360 + height:600 + + Column { + spacing:5 + anchors.fill:parent + Text { font.pointSize:25; text:"Tiger with SVG path"; anchors.horizontalCenter:parent.horizontalCenter} + + Canvas { + id:canvas + width:360 + height:360 + smooth:true + renderTarget:Canvas.FramebufferObject + renderStrategy: Canvas.Cooperative + property string strokeStyle:"steelblue" + property string fillStyle:"yellow" + property bool fill:true + property bool stroke:true + property real alpha:alphaCtrl.value + property real scaleX : scaleXCtrl.value + property real scaleY : scaleYCtrl.value + property real rotate : rotateCtrl.value + property int frame:0 + + onFillChanged: requestPaint(); + onStrokeChanged: requestPaint(); + onAlphaChanged: requestPaint(); + onScaleXChanged: requestPaint(); + onScaleYChanged: requestPaint(); + onRotateChanged: requestPaint(); + + onPainted : { + canvas.frame++; + if (canvas.frame < Tiger.tiger.length) + requestPaint(); + } + onPaint: { + var ctx = canvas.getContext('2d'); + ctx.save(); + ctx.clearRect(0, 0, canvas.width, canvas.height); + ctx.globalAlpha = canvas.alpha; + ctx.scale(canvas.scaleX, canvas.scaleY); + ctx.rotate(canvas.rotate); + ctx.globalCompositeOperation = "source-over"; + ctx.translate(canvas.width/2, canvas.height/2); + ctx.strokeStyle = Qt.rgba(.3, .3, .3,1); + ctx.lineWidth = 1; + + + for (var i = 0; i < canvas.frame && i < Tiger.tiger.length; i++) { + if (Tiger.tiger[i].width != undefined) + ctx.lineWidth = Tiger.tiger[i].width; + + if (Tiger.tiger[i].path != undefined) + ctx.path = Tiger.tiger[i].path; + + if (Tiger.tiger[i].fill != undefined) { + ctx.fillStyle = Tiger.tiger[i].fill; + ctx.fill(); + } + + if (Tiger.tiger[i].stroke != undefined) { + ctx.strokeStyle = Tiger.tiger[i].stroke; + ctx.stroke(); + } + } + ctx.restore(); + } + } + Rectangle { + id:controls + width:360 + height:160 + Column { + spacing:3 + Slider {id:scaleXCtrl; width:300; height:30; min:0.1; max:10; init:0.5; name:"ScaleX"} + Slider {id:scaleYCtrl; width:300; height:30; min:0.1; max:10; init:0.5; name:"ScaleY"} + Slider {id:rotateCtrl; width:300; height:30; min:0; max:Math.PI*2; init:0; name:"Rotate"} + Slider {id:alphaCtrl; width:300; height:30; min:0; max:1; init:1; name:"Alpha"} + } + } + } +} diff --git a/examples/qml/canvas/twitterfriends/TwitterUser.qml b/examples/qml/canvas/twitterfriends/TwitterUser.qml new file mode 100644 index 0000000000..8b906216ef --- /dev/null +++ b/examples/qml/canvas/twitterfriends/TwitterUser.qml @@ -0,0 +1,294 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Item { + id:twitterUser + property variant friends : []; + property string name : ""; + property string twitterId : ""; + property string image : ""; + property string url : ""; + property string desc : ""; + width : 0; + height : 0; + property int posX:0; + property int posY:0; + property bool hasFocus : false; + property variant canvas; + property variant manager; + property variant linkColor; + property bool selected : false; + + Rectangle { + id:twitterStatus + x:twitterUser.width + y:twitterUser.height + width:250 + height:60 + opacity: 0 + border.color:"steelblue" + border.width:3 + Column { + spacing:2 + Text {color:"steelblue"; font.pointSize:15; width:250; height:30; text:twitterUser.name; wrapMode: Text.WrapAnywhere} + Text {color:"steelblue"; font.pointSize:8; width:250; height:30; text:twitterUser.url; wrapMode: Text.WrapAnywhere} + } + } + + function moved() { + twitterUser.posX = twitterUser.x; + twitterUser.posY = twitterUser.y; + twitterUser.canvas.requestPaint(); + } + + onXChanged: moved(); + onYChanged: moved(); + + MouseArea { + anchors.fill:parent + drag.target : twitterUser + drag.axis : Drag.XandYAxis + + onClicked: { + if (!twitterUser.selected) { + twitterUser.selected = true; + twitterStatus.opacity = 1; + twitterStatus.visible = true; + } else { + twitterUser.selected = false; + twitterStatus.opacity = 0; + } + } + + onDoubleClicked : { + twitterStatus.opacity = 0; + twitterUser.selected = false; + twitterUser.hasFocus = true; + twitterUser.canvas.twitterName = twitterUser.name; + twitterUser.canvas.twitterId = twitterUser.twitterId; + twitterUser.canvas.loading = true; + twitterUser.createFriends(); + } + } + + function show(ctx, layoutChanged) { + var w = canvas.width; + var h = canvas.height; + if (twitterUser.hasFocus) { + twitterUser.width = 60 + twitterUser.height = 60 + twitterUser.posX = w/2; + twitterUser.posY = h/2; + } else { + twitterUser.width = 40 + twitterUser.height = 40 + } + + + if (twitterUser.hasFocus) { + if (layoutChanged) + twitterUser.layoutFriends(); + twitterUser.linkFriends(ctx); + twitterUser.showFriends(ctx); + ctx.shadowOffsetX = 5; + ctx.shadowOffsetY = 5; + ctx.shadowBlur = 7; + ctx.shadowColor = "blue"; + ctx.globalAlpha = 1; + } else { + ctx.shadowOffsetX = 5; + ctx.shadowOffsetY = 5; + ctx.shadowBlur = 7; + ctx.shadowColor = twitterUser.linkColor; + ctx.globalAlpha = 0.6; + } + + if (twitterUser.canvas.isImageLoaded(twitterUser.image)) { + ctx.drawImage(twitterUser.image, twitterUser.posX, twitterUser.posY, twitterUser.width, twitterUser.height); + } +// ctx.font = "15px"; +// var nameSize = ctx.measureText(twitterUser.name).width; +// ctx.fillText(twitterUser.name, twitterUser.posX + nameSize/2 - twitterUser.width/2, twitterUser.posY + twitterUser.height/2 + 10); + } + function dump() { + console.log("name:" + twitterUser.name + + " x:" + twitterUser.posX + + " y:" + twitterUser.posY + + " width:" + twitterUser.width + + " height:" + twitterUser.height + + " id:" + twitterUser.twitterId + + " image:" + twitterUser.image + + " url:" + twitterUser.url + "\n" + twitterUser.desc); + } + + function layoutFriends() { + var w = canvas.width; + var h = canvas.height; + for (var i=0; i < twitterUser.friends.length; i++) { + var friend = manager.getById(twitterUser.friends[i]); + if (friend) { + friend.x = Math.random() *w; + friend.y = Math.random() *h; + } + } + } + + function showFriends(ctx) { + var w = canvas.width; + var h = canvas.height; + for (var i=0; i < twitterUser.friends.length && i < 15; i++) { + var friend = manager.getById(twitterUser.friends[i]); + if (friend && twitterUser.canvas.isImageLoaded(friend.image)) { + friend.hasFocus = false; + friend.show(ctx, false); + } + } + } + + function linkFriends(ctx) { + var w = canvas.width; + var h = canvas.height; + for (var i=0; i < twitterUser.friends.length && i < 15; i++) { + var friend = manager.getById(twitterUser.friends[i]); + if (friend && twitterUser.canvas.isImageLoaded(friend.image)) { + if (!friend.linkColor) + friend.linkColor = Qt.rgba( ((Math.random() * 200) +55)/255 + , ((Math.random() * 200) +55)/255 + , ((Math.random() * 200) +55)/255, 0.8); + ctx.strokeStyle = friend.linkColor; + ctx.lineWidth = 8; + ctx.beginPath(); + ctx.moveTo(twitterUser.posX + twitterUser.width/2, twitterUser.posY + twitterUser.height/2); + ctx.lineTo(friend.x + friend.width/2, friend.y + friend.height/2); + ctx.stroke(); + } + } + } + + + function create(url) { + var x = new XMLHttpRequest; + x.open("GET", url); + + x.onreadystatechange = function() { + if (x.readyState == XMLHttpRequest.DONE) { + var user = eval('(' + x.responseText +')')[0]; + twitterUser.name = user.name; + twitterUser.twitterId = user.id; + twitterUser.image = user.profile_image_url; + twitterUser.canvas.loadImage(twitterUser.image); + twitterUser.url = user.url; + twitterUser.desc = user.description; + twitterUser.createFriends(); + } + } + x.send(); + } + + function createByName(name) { + if (twitterUser.name === "" && twitterUser.twitterId === "") { + twitterUser.name = name; + var userUrl = "http://api.twitter.com/1/users/lookup.json?stringify_ids=true&screen_name=" + name; + twitterUser.create(userUrl); + } + } + + function createById(id) { + if (twitterUser.name === "" && twitterUser.twitterId === "") { + twitterUser.twitterId = id; + var userUrl = "http://api.twitter.com/1/users/lookup.json?stringify_ids=true&user_id=" + id; + twitterUser.create(userUrl); + } + } + + function createFriends() { + if (twitterUser.friends.length === 0) { + var x = new XMLHttpRequest; + var friendsUrl = "https://api.twitter.com/1/friends/ids.json?cursor=-1&stringify_ids=true&user_id=" + twitterUser.twitterId; + x.open("GET", friendsUrl); + + x.onreadystatechange = function() { + if (x.readyState == XMLHttpRequest.DONE) { + twitterUser.friends = eval('(' + x.responseText +')').ids; + var doRequest = false; + var userUrl = "http://api.twitter.com/1/users/lookup.json?stringify_ids=true&user_id="; + + for (var i=0; i + +#include +#include +#include +#include + +//![0] +class ColorImageProvider : public QQmlImageProvider +{ +public: + ColorImageProvider() + : QQmlImageProvider(QQmlImageProvider::Pixmap) + { + } + + QPixmap requestPixmap(const QString &id, QSize *size, const QSize &requestedSize) + { + int width = 100; + int height = 50; + + if (size) + *size = QSize(width, height); + QPixmap pixmap(requestedSize.width() > 0 ? requestedSize.width() : width, + requestedSize.height() > 0 ? requestedSize.height() : height); + pixmap.fill(QColor(id).rgba()); +//![0] + + // write the color name + QPainter painter(&pixmap); + QFont f = painter.font(); + f.setPixelSize(20); + painter.setFont(f); + painter.setPen(Qt::black); + if (requestedSize.isValid()) + painter.scale(requestedSize.width() / width, requestedSize.height() / height); + painter.drawText(QRectF(0, 0, width, height), Qt::AlignCenter, id); + +//![1] + return pixmap; + } +}; +//![1] + + +class ImageProviderExtensionPlugin : public QQmlExtensionPlugin +{ + Q_OBJECT +public: + void registerTypes(const char *uri) + { + Q_UNUSED(uri); + } + + void initializeEngine(QQmlEngine *engine, const char *uri) + { + Q_UNUSED(uri); + engine->addImageProvider("colors", new ColorImageProvider); + } + +}; + +#include "imageprovider.moc" + +Q_EXPORT_PLUGIN(ImageProviderExtensionPlugin); + diff --git a/examples/qml/cppextensions/imageprovider/imageprovider.pro b/examples/qml/cppextensions/imageprovider/imageprovider.pro new file mode 100644 index 0000000000..f75a6ebd89 --- /dev/null +++ b/examples/qml/cppextensions/imageprovider/imageprovider.pro @@ -0,0 +1,20 @@ +TEMPLATE = lib +CONFIG += qt plugin +QT += qml + +DESTDIR = ImageProviderCore +TARGET = qmlimageproviderplugin + +SOURCES += imageprovider.cpp + +sources.files = $$SOURCES imageprovider.qml imageprovider.pro +sources.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/qml/imageprovider + +target.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/qml/imageprovider/ImageProviderCore + +ImageProviderCore_sources.files = \ + ImageProviderCore/qmldir +ImageProviderCore_sources.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/qml/imageprovider/ImageProviderCore + +INSTALLS = sources ImageProviderCore_sources target + diff --git a/examples/qml/cppextensions/imageprovider/imageprovider.qmlproject b/examples/qml/cppextensions/imageprovider/imageprovider.qmlproject new file mode 100644 index 0000000000..2bb4016996 --- /dev/null +++ b/examples/qml/cppextensions/imageprovider/imageprovider.qmlproject @@ -0,0 +1,14 @@ +import QmlProject 1.0 + +Project { + /* Include .qml, .js, and image files from current directory and subdirectories */ + QmlFiles { + directory: "." + } + JavaScriptFiles { + directory: "." + } + ImageFiles { + directory: "." + } +} diff --git a/examples/qml/cppextensions/networkaccessmanagerfactory/main.cpp b/examples/qml/cppextensions/networkaccessmanagerfactory/main.cpp new file mode 100644 index 0000000000..6ebded0512 --- /dev/null +++ b/examples/qml/cppextensions/networkaccessmanagerfactory/main.cpp @@ -0,0 +1,108 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the demonstration applications of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include +#include + +#include +#include +#include + + +/* + This example illustrates using a QQmlNetworkAccessManagerFactory to + create a QNetworkAccessManager with a proxy. + + Usage: + networkaccessmanagerfactory [-host -port ] [file] +*/ + +static QString proxyHost; +static int proxyPort = 0; + +class MyNetworkAccessManagerFactory : public QQmlNetworkAccessManagerFactory +{ +public: + virtual QNetworkAccessManager *create(QObject *parent); +}; + +QNetworkAccessManager *MyNetworkAccessManagerFactory::create(QObject *parent) +{ + QNetworkAccessManager *nam = new QNetworkAccessManager(parent); + if (!proxyHost.isEmpty()) { + qDebug() << "Created QNetworkAccessManager using proxy" << (proxyHost + ":" + QString::number(proxyPort)); + QNetworkProxy proxy(QNetworkProxy::HttpCachingProxy, proxyHost, proxyPort); + nam->setProxy(proxy); + } + + return nam; +} + +int main(int argc, char ** argv) +{ + QUrl source("qrc:view.qml"); + + QGuiApplication app(argc, argv); + + for (int i = 1; i < argc; ++i) { + QString arg(argv[i]); + if (arg == "-host" && i < argc-1) { + proxyHost = argv[++i]; + } else if (arg == "-port" && i < argc-1) { + arg = argv[++i]; + proxyPort = arg.toInt(); + } else if (arg[0] != '-') { + source = QUrl::fromLocalFile(arg); + } else { + qWarning() << "Usage: networkaccessmanagerfactory [-host -port ] [file]"; + exit(1); + } + } + + QQuickView view; + view.engine()->setNetworkAccessManagerFactory(new MyNetworkAccessManagerFactory); + + view.setSource(source); + view.show(); + + return app.exec(); +} + diff --git a/examples/qml/cppextensions/networkaccessmanagerfactory/networkaccessmanagerfactory.pro b/examples/qml/cppextensions/networkaccessmanagerfactory/networkaccessmanagerfactory.pro new file mode 100644 index 0000000000..6cbc24a7b8 --- /dev/null +++ b/examples/qml/cppextensions/networkaccessmanagerfactory/networkaccessmanagerfactory.pro @@ -0,0 +1,4 @@ +QT += qml quick network + +SOURCES += main.cpp +RESOURCES += networkaccessmanagerfactory.qrc diff --git a/examples/qml/cppextensions/networkaccessmanagerfactory/networkaccessmanagerfactory.qmlproject b/examples/qml/cppextensions/networkaccessmanagerfactory/networkaccessmanagerfactory.qmlproject new file mode 100644 index 0000000000..2bb4016996 --- /dev/null +++ b/examples/qml/cppextensions/networkaccessmanagerfactory/networkaccessmanagerfactory.qmlproject @@ -0,0 +1,14 @@ +import QmlProject 1.0 + +Project { + /* Include .qml, .js, and image files from current directory and subdirectories */ + QmlFiles { + directory: "." + } + JavaScriptFiles { + directory: "." + } + ImageFiles { + directory: "." + } +} diff --git a/examples/qml/cppextensions/networkaccessmanagerfactory/networkaccessmanagerfactory.qrc b/examples/qml/cppextensions/networkaccessmanagerfactory/networkaccessmanagerfactory.qrc new file mode 100644 index 0000000000..17e9301471 --- /dev/null +++ b/examples/qml/cppextensions/networkaccessmanagerfactory/networkaccessmanagerfactory.qrc @@ -0,0 +1,5 @@ + + + view.qml + + diff --git a/examples/qml/cppextensions/networkaccessmanagerfactory/view.qml b/examples/qml/cppextensions/networkaccessmanagerfactory/view.qml new file mode 100644 index 0000000000..b2d46a991f --- /dev/null +++ b/examples/qml/cppextensions/networkaccessmanagerfactory/view.qml @@ -0,0 +1,47 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Image { + width: 100 + height: 100 + source: "http://qt.nokia.com/logo.png" +} diff --git a/examples/qml/cppextensions/plugins/README b/examples/qml/cppextensions/plugins/README new file mode 100644 index 0000000000..f4f9074059 --- /dev/null +++ b/examples/qml/cppextensions/plugins/README @@ -0,0 +1,9 @@ +This example shows a module "com.nokia.TimeExample" that is implemented +by a C++ plugin (providing the "Time" type), and by QML files (providing the +"Clock" type). + +To run: + + make install + QML_IMPORT_PATH=$PWD qmlscene plugins.qml + diff --git a/examples/qml/cppextensions/plugins/com/nokia/TimeExample/Clock.qml b/examples/qml/cppextensions/plugins/com/nokia/TimeExample/Clock.qml new file mode 100644 index 0000000000..eac9226a00 --- /dev/null +++ b/examples/qml/cppextensions/plugins/com/nokia/TimeExample/Clock.qml @@ -0,0 +1,90 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Rectangle { + id: clock + width: 200; height: 200; color: "gray" + + property alias city: cityLabel.text + property variant hours + property variant minutes + property variant shift : 0 + + Image { id: background; source: "clock.png" } + + Image { + x: 92.5; y: 27 + source: "hour.png" + smooth: true + transform: Rotation { + id: hourRotation + origin.x: 7.5; origin.y: 73; + angle: (clock.hours * 30) + (clock.minutes * 0.5) + Behavior on angle { + SpringAnimation{ spring: 2; damping: 0.2; modulus: 360 } + } + } + } + + Image { + x: 93.5; y: 17 + source: "minute.png" + smooth: true + transform: Rotation { + id: minuteRotation + origin.x: 6.5; origin.y: 83; + angle: clock.minutes * 6 + Behavior on angle { + SpringAnimation{ spring: 2; damping: 0.2; modulus: 360 } + } + } + } + + Image { + anchors.centerIn: background; source: "center.png" + } + + Text { + id: cityLabel; font.bold: true; font.pixelSize: 14; y:200; color: "white" + anchors.horizontalCenter: parent.horizontalCenter + } +} diff --git a/examples/qml/cppextensions/plugins/com/nokia/TimeExample/center.png b/examples/qml/cppextensions/plugins/com/nokia/TimeExample/center.png new file mode 100644 index 0000000000..7fbd802a44 Binary files /dev/null and b/examples/qml/cppextensions/plugins/com/nokia/TimeExample/center.png differ diff --git a/examples/qml/cppextensions/plugins/com/nokia/TimeExample/clock.png b/examples/qml/cppextensions/plugins/com/nokia/TimeExample/clock.png new file mode 100644 index 0000000000..462edacc0e Binary files /dev/null and b/examples/qml/cppextensions/plugins/com/nokia/TimeExample/clock.png differ diff --git a/examples/qml/cppextensions/plugins/com/nokia/TimeExample/hour.png b/examples/qml/cppextensions/plugins/com/nokia/TimeExample/hour.png new file mode 100644 index 0000000000..f8061a1235 Binary files /dev/null and b/examples/qml/cppextensions/plugins/com/nokia/TimeExample/hour.png differ diff --git a/examples/qml/cppextensions/plugins/com/nokia/TimeExample/minute.png b/examples/qml/cppextensions/plugins/com/nokia/TimeExample/minute.png new file mode 100644 index 0000000000..1297ec7c2b Binary files /dev/null and b/examples/qml/cppextensions/plugins/com/nokia/TimeExample/minute.png differ diff --git a/examples/qml/cppextensions/plugins/com/nokia/TimeExample/qmldir b/examples/qml/cppextensions/plugins/com/nokia/TimeExample/qmldir new file mode 100644 index 0000000000..e1288cfac0 --- /dev/null +++ b/examples/qml/cppextensions/plugins/com/nokia/TimeExample/qmldir @@ -0,0 +1,2 @@ +Clock 1.0 Clock.qml +plugin qmlqtimeexampleplugin diff --git a/examples/qml/cppextensions/plugins/plugin.cpp b/examples/qml/cppextensions/plugins/plugin.cpp new file mode 100644 index 0000000000..b53ef2ccb3 --- /dev/null +++ b/examples/qml/cppextensions/plugins/plugin.cpp @@ -0,0 +1,157 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include +#include +#include +#include +#include + +// Implements a "TimeModel" class with hour and minute properties +// that change on-the-minute yet efficiently sleep the rest +// of the time. + +class MinuteTimer : public QObject +{ + Q_OBJECT +public: + MinuteTimer(QObject *parent) : QObject(parent) + { + } + + void start() + { + if (!timer.isActive()) { + time = QTime::currentTime(); + timer.start(60000-time.second()*1000, this); + } + } + + void stop() + { + timer.stop(); + } + + int hour() const { return time.hour(); } + int minute() const { return time.minute(); } + +signals: + void timeChanged(); + +protected: + void timerEvent(QTimerEvent *) + { + QTime now = QTime::currentTime(); + if (now.second() == 59 && now.minute() == time.minute() && now.hour() == time.hour()) { + // just missed time tick over, force it, wait extra 0.5 seconds + time.addSecs(60); + timer.start(60500, this); + } else { + time = now; + timer.start(60000-time.second()*1000, this); + } + emit timeChanged(); + } + +private: + QTime time; + QBasicTimer timer; +}; + +//![0] +class TimeModel : public QObject +{ + Q_OBJECT + Q_PROPERTY(int hour READ hour NOTIFY timeChanged) + Q_PROPERTY(int minute READ minute NOTIFY timeChanged) +//![0] + +public: + TimeModel(QObject *parent=0) : QObject(parent) + { + if (++instances == 1) { + if (!timer) + timer = new MinuteTimer(QCoreApplication::instance()); + connect(timer, SIGNAL(timeChanged()), this, SIGNAL(timeChanged())); + timer->start(); + } + } + + ~TimeModel() + { + if (--instances == 0) { + timer->stop(); + } + } + + int minute() const { return timer->minute(); } + int hour() const { return timer->hour(); } + +signals: + void timeChanged(); + +private: + QTime t; + static MinuteTimer *timer; + static int instances; +}; + +int TimeModel::instances=0; +MinuteTimer *TimeModel::timer=0; + +//![plugin] +class QExampleQmlPlugin : public QQmlExtensionPlugin +{ + Q_OBJECT +public: + void registerTypes(const char *uri) + { + Q_ASSERT(uri == QLatin1String("com.nokia.TimeExample")); + qmlRegisterType(uri, 1, 0, "Time"); + } +}; +//![plugin] + +#include "plugin.moc" + +//![export] +Q_EXPORT_PLUGIN2(qmlqtimeexampleplugin, QExampleQmlPlugin); +//![export] diff --git a/examples/qml/cppextensions/plugins/plugins.pro b/examples/qml/cppextensions/plugins/plugins.pro new file mode 100644 index 0000000000..e6c7fe64a0 --- /dev/null +++ b/examples/qml/cppextensions/plugins/plugins.pro @@ -0,0 +1,25 @@ +TEMPLATE = lib +CONFIG += qt plugin +QT += qml + +DESTDIR = com/nokia/TimeExample +TARGET = qmlqtimeexampleplugin + +SOURCES += plugin.cpp + +qqmlsources.files += \ + com/nokia/TimeExample/qmldir \ + com/nokia/TimeExample/center.png \ + com/nokia/TimeExample/clock.png \ + com/nokia/TimeExample/Clock.qml \ + com/nokia/TimeExample/hour.png \ + com/nokia/TimeExample/minute.png + +qqmlsources.path += $$[QT_INSTALL_EXAMPLES]/qtdeclarative/qml/plugins/com/nokia/TimeExample + +sources.files += plugins.pro plugin.cpp plugins.qml README +sources.path += $$[QT_INSTALL_EXAMPLES]/qtdeclarative/qml/plugins +target.path += $$[QT_INSTALL_EXAMPLES]/qtdeclarative/qml/plugins/com/nokia/TimeExample + +INSTALLS += qqmlsources sources target + diff --git a/examples/qml/cppextensions/plugins/plugins.qml b/examples/qml/cppextensions/plugins/plugins.qml new file mode 100644 index 0000000000..f1048ddd36 --- /dev/null +++ b/examples/qml/cppextensions/plugins/plugins.qml @@ -0,0 +1,53 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +//![0] +import com.nokia.TimeExample 1.0 // import types from the plugin + +Clock { // this class is defined in QML (com/nokia/TimeExample/Clock.qml) + + Time { // this class is defined in C++ (plugin.cpp) + id: time + } + + hours: time.hour + minutes: time.minute + +} +//![0] diff --git a/examples/qml/cppextensions/plugins/plugins.qmlproject b/examples/qml/cppextensions/plugins/plugins.qmlproject new file mode 100644 index 0000000000..771ab45b66 --- /dev/null +++ b/examples/qml/cppextensions/plugins/plugins.qmlproject @@ -0,0 +1,16 @@ +import QmlProject 1.1 + +Project { + mainFile: "plugins.qml" + + /* Include .qml, .js, and image files from current directory and subdirectories */ + QmlFiles { + directory: "." + } + JavaScriptFiles { + directory: "." + } + ImageFiles { + directory: "." + } +} diff --git a/examples/qml/cppextensions/referenceexamples/adding/adding.pro b/examples/qml/cppextensions/referenceexamples/adding/adding.pro new file mode 100644 index 0000000000..706322e9ff --- /dev/null +++ b/examples/qml/cppextensions/referenceexamples/adding/adding.pro @@ -0,0 +1,11 @@ +QT += qml + +SOURCES += main.cpp \ + person.cpp +HEADERS += person.h +RESOURCES += adding.qrc + +target.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/qml/extending/adding +sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS adding.pro +sources.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/qml/extending/adding +INSTALLS += target sources diff --git a/examples/qml/cppextensions/referenceexamples/adding/adding.qrc b/examples/qml/cppextensions/referenceexamples/adding/adding.qrc new file mode 100644 index 0000000000..e2fa01d5e7 --- /dev/null +++ b/examples/qml/cppextensions/referenceexamples/adding/adding.qrc @@ -0,0 +1,5 @@ + + + example.qml + + diff --git a/examples/qml/cppextensions/referenceexamples/adding/example.qml b/examples/qml/cppextensions/referenceexamples/adding/example.qml new file mode 100644 index 0000000000..3b2ca34d10 --- /dev/null +++ b/examples/qml/cppextensions/referenceexamples/adding/example.qml @@ -0,0 +1,48 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +// ![0] +import People 1.0 + +Person { + name: "Bob Jones" + shoeSize: 12 +} +// ![0] diff --git a/examples/qml/cppextensions/referenceexamples/adding/main.cpp b/examples/qml/cppextensions/referenceexamples/adding/main.cpp new file mode 100644 index 0000000000..c3a0ab6812 --- /dev/null +++ b/examples/qml/cppextensions/referenceexamples/adding/main.cpp @@ -0,0 +1,64 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include +#include +#include +#include +#include "person.h" + +int main(int argc, char ** argv) +{ + QCoreApplication app(argc, argv); +//![0] + qmlRegisterType("People", 1,0, "Person"); +//![0] + + QQmlEngine engine; + QQmlComponent component(&engine, QUrl("qrc:example.qml")); + Person *person = qobject_cast(component.create()); + if (person) { + qWarning() << "The person's name is" << person->name(); + qWarning() << "They wear a" << person->shoeSize() << "sized shoe"; + } else { + qWarning() << component.errors(); + } + + return 0; +} diff --git a/examples/qml/cppextensions/referenceexamples/adding/person.cpp b/examples/qml/cppextensions/referenceexamples/adding/person.cpp new file mode 100644 index 0000000000..0e78b0b77b --- /dev/null +++ b/examples/qml/cppextensions/referenceexamples/adding/person.cpp @@ -0,0 +1,68 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include "person.h" + +// ![0] +Person::Person(QObject *parent) +: QObject(parent), m_shoeSize(0) +{ +} + +QString Person::name() const +{ + return m_name; +} + +void Person::setName(const QString &n) +{ + m_name = n; +} + +int Person::shoeSize() const +{ + return m_shoeSize; +} + +void Person::setShoeSize(int s) +{ + m_shoeSize = s; +} + +// ![0] diff --git a/examples/qml/cppextensions/referenceexamples/adding/person.h b/examples/qml/cppextensions/referenceexamples/adding/person.h new file mode 100644 index 0000000000..45fb2f3297 --- /dev/null +++ b/examples/qml/cppextensions/referenceexamples/adding/person.h @@ -0,0 +1,65 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#ifndef PERSON_H +#define PERSON_H + +#include +//![0] +class Person : public QObject +{ + Q_OBJECT + Q_PROPERTY(QString name READ name WRITE setName) + Q_PROPERTY(int shoeSize READ shoeSize WRITE setShoeSize) +public: + Person(QObject *parent = 0); + + QString name() const; + void setName(const QString &); + + int shoeSize() const; + void setShoeSize(int); + +private: + QString m_name; + int m_shoeSize; +}; +//![0] + +#endif // PERSON_H diff --git a/examples/qml/cppextensions/referenceexamples/attached/attached.pro b/examples/qml/cppextensions/referenceexamples/attached/attached.pro new file mode 100644 index 0000000000..f4385e1a30 --- /dev/null +++ b/examples/qml/cppextensions/referenceexamples/attached/attached.pro @@ -0,0 +1,13 @@ +QT += qml + +SOURCES += main.cpp \ + person.cpp \ + birthdayparty.cpp +HEADERS += person.h \ + birthdayparty.h +RESOURCES += attached.qrc + +target.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/qml/extending/attached +sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS attached.pro +sources.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/qml/extending/attached +INSTALLS += target sources diff --git a/examples/qml/cppextensions/referenceexamples/attached/attached.qrc b/examples/qml/cppextensions/referenceexamples/attached/attached.qrc new file mode 100644 index 0000000000..e2fa01d5e7 --- /dev/null +++ b/examples/qml/cppextensions/referenceexamples/attached/attached.qrc @@ -0,0 +1,5 @@ + + + example.qml + + diff --git a/examples/qml/cppextensions/referenceexamples/attached/birthdayparty.cpp b/examples/qml/cppextensions/referenceexamples/attached/birthdayparty.cpp new file mode 100644 index 0000000000..6b784fdccd --- /dev/null +++ b/examples/qml/cppextensions/referenceexamples/attached/birthdayparty.cpp @@ -0,0 +1,91 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include "birthdayparty.h" + +BirthdayPartyAttached::BirthdayPartyAttached(QObject *object) +: QObject(object) +{ +} + +QDate BirthdayPartyAttached::rsvp() const +{ + return m_rsvp; +} + +void BirthdayPartyAttached::setRsvp(const QDate &d) +{ + m_rsvp = d; +} + +BirthdayParty::BirthdayParty(QObject *parent) +: QObject(parent), m_host(0) +{ +} + +Person *BirthdayParty::host() const +{ + return m_host; +} + +void BirthdayParty::setHost(Person *c) +{ + m_host = c; +} + +QQmlListProperty BirthdayParty::guests() +{ + return QQmlListProperty(this, m_guests); +} + +int BirthdayParty::guestCount() const +{ + return m_guests.count(); +} + +Person *BirthdayParty::guest(int index) const +{ + return m_guests.at(index); +} + +BirthdayPartyAttached *BirthdayParty::qmlAttachedProperties(QObject *object) +{ + return new BirthdayPartyAttached(object); +} + diff --git a/examples/qml/cppextensions/referenceexamples/attached/birthdayparty.h b/examples/qml/cppextensions/referenceexamples/attached/birthdayparty.h new file mode 100644 index 0000000000..1da6c34026 --- /dev/null +++ b/examples/qml/cppextensions/referenceexamples/attached/birthdayparty.h @@ -0,0 +1,89 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#ifndef BIRTHDAYPARTY_H +#define BIRTHDAYPARTY_H + +#include +#include +#include +#include "person.h" + +class BirthdayPartyAttached : public QObject +{ + Q_OBJECT + Q_PROPERTY(QDate rsvp READ rsvp WRITE setRsvp) +public: + BirthdayPartyAttached(QObject *object); + + QDate rsvp() const; + void setRsvp(const QDate &); + +private: + QDate m_rsvp; +}; + +class BirthdayParty : public QObject +{ + Q_OBJECT + Q_PROPERTY(Person *host READ host WRITE setHost) + Q_PROPERTY(QQmlListProperty guests READ guests) + Q_CLASSINFO("DefaultProperty", "guests") +public: + BirthdayParty(QObject *parent = 0); + + Person *host() const; + void setHost(Person *); + + QQmlListProperty guests(); + int guestCount() const; + Person *guest(int) const; + + //! [static attached] + static BirthdayPartyAttached *qmlAttachedProperties(QObject *); + //! [static attached] +private: + Person *m_host; + QList m_guests; +}; + +//! [declare attached] +QML_DECLARE_TYPEINFO(BirthdayParty, QML_HAS_ATTACHED_PROPERTIES) +//! [declare attached] +#endif // BIRTHDAYPARTY_H diff --git a/examples/qml/cppextensions/referenceexamples/attached/example.qml b/examples/qml/cppextensions/referenceexamples/attached/example.qml new file mode 100644 index 0000000000..6a83af2804 --- /dev/null +++ b/examples/qml/cppextensions/referenceexamples/attached/example.qml @@ -0,0 +1,68 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import People 1.0 + +//! [begin] +BirthdayParty { +//! [begin] + +//! [rsvp] + Boy { + name: "Robert Campbell" + BirthdayParty.rsvp: "2009-07-01" + } +//! [rsvp] + // ![1] + Boy { + name: "Leo Hodges" + shoe { size: 10; color: "black"; brand: "Reebok"; price: 59.95 } + + BirthdayParty.rsvp: "2009-07-06" + } + // ![1] + Boy { + name: "Jack Smith" + shoe { size: 8; color: "blue"; brand: "Puma"; price: 19.95 } + } +//! [end] +} +//! [end] + diff --git a/examples/qml/cppextensions/referenceexamples/attached/main.cpp b/examples/qml/cppextensions/referenceexamples/attached/main.cpp new file mode 100644 index 0000000000..ce067bbbf7 --- /dev/null +++ b/examples/qml/cppextensions/referenceexamples/attached/main.cpp @@ -0,0 +1,91 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include +#include +#include +#include +#include "birthdayparty.h" +#include "person.h" + +int main(int argc, char ** argv) +{ + QCoreApplication app(argc, argv); + + qmlRegisterType(); + qmlRegisterType("People", 1,0, "BirthdayParty"); + qmlRegisterType(); + qmlRegisterType(); + qmlRegisterType("People", 1,0, "Boy"); + qmlRegisterType("People", 1,0, "Girl"); + + QQmlEngine engine; + QQmlComponent component(&engine, QUrl("qrc:example.qml")); + BirthdayParty *party = qobject_cast(component.create()); + + if (party && party->host()) { + qWarning() << party->host()->name() << "is having a birthday!"; + + if (qobject_cast(party->host())) + qWarning() << "He is inviting:"; + else + qWarning() << "She is inviting:"; + + for (int ii = 0; ii < party->guestCount(); ++ii) { + Person *guest = party->guest(ii); + + //! [query rsvp] + QDate rsvpDate; + QObject *attached = qmlAttachedPropertiesObject(guest, false); + + if (attached) + rsvpDate = attached->property("rsvp").toDate(); + //! [query rsvp] + if (rsvpDate.isNull()) + qWarning() << " " << guest->name() << "RSVP date: Hasn't RSVP'd"; + else + qWarning() << " " << guest->name() << "RSVP date:" << qPrintable(rsvpDate.toString()); + } + + } else { + qWarning() << component.errors(); + } + + return 0; +} diff --git a/examples/qml/cppextensions/referenceexamples/attached/person.cpp b/examples/qml/cppextensions/referenceexamples/attached/person.cpp new file mode 100644 index 0000000000..7afcdc6ca6 --- /dev/null +++ b/examples/qml/cppextensions/referenceexamples/attached/person.cpp @@ -0,0 +1,118 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include "person.h" + +ShoeDescription::ShoeDescription(QObject *parent) +: QObject(parent), m_size(0), m_price(0) +{ +} + +int ShoeDescription::size() const +{ + return m_size; +} + +void ShoeDescription::setSize(int s) +{ + m_size = s; +} + +QColor ShoeDescription::color() const +{ + return m_color; +} + +void ShoeDescription::setColor(const QColor &c) +{ + m_color = c; +} + +QString ShoeDescription::brand() const +{ + return m_brand; +} + +void ShoeDescription::setBrand(const QString &b) +{ + m_brand = b; +} + +qreal ShoeDescription::price() const +{ + return m_price; +} + +void ShoeDescription::setPrice(qreal p) +{ + m_price = p; +} + +Person::Person(QObject *parent) +: QObject(parent) +{ +} + +QString Person::name() const +{ + return m_name; +} + +void Person::setName(const QString &n) +{ + m_name = n; +} + +ShoeDescription *Person::shoe() +{ + return &m_shoe; +} + + +Boy::Boy(QObject * parent) +: Person(parent) +{ +} + + +Girl::Girl(QObject * parent) +: Person(parent) +{ +} + diff --git a/examples/qml/cppextensions/referenceexamples/attached/person.h b/examples/qml/cppextensions/referenceexamples/attached/person.h new file mode 100644 index 0000000000..032eca3c17 --- /dev/null +++ b/examples/qml/cppextensions/referenceexamples/attached/person.h @@ -0,0 +1,105 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#ifndef PERSON_H +#define PERSON_H + +#include +#include + +class ShoeDescription : public QObject +{ + Q_OBJECT + Q_PROPERTY(int size READ size WRITE setSize) + Q_PROPERTY(QColor color READ color WRITE setColor) + Q_PROPERTY(QString brand READ brand WRITE setBrand) + Q_PROPERTY(qreal price READ price WRITE setPrice) +public: + ShoeDescription(QObject *parent = 0); + + int size() const; + void setSize(int); + + QColor color() const; + void setColor(const QColor &); + + QString brand() const; + void setBrand(const QString &); + + qreal price() const; + void setPrice(qreal); +private: + int m_size; + QColor m_color; + QString m_brand; + qreal m_price; +}; + +class Person : public QObject +{ + Q_OBJECT + Q_PROPERTY(QString name READ name WRITE setName) + Q_PROPERTY(ShoeDescription *shoe READ shoe) +public: + Person(QObject *parent = 0); + + QString name() const; + void setName(const QString &); + + ShoeDescription *shoe(); +private: + QString m_name; + ShoeDescription m_shoe; +}; + +class Boy : public Person +{ + Q_OBJECT +public: + Boy(QObject * parent = 0); +}; + +class Girl : public Person +{ + Q_OBJECT +public: + Girl(QObject * parent = 0); +}; + +#endif // PERSON_H diff --git a/examples/qml/cppextensions/referenceexamples/binding/binding.pro b/examples/qml/cppextensions/referenceexamples/binding/binding.pro new file mode 100644 index 0000000000..0379f93ea7 --- /dev/null +++ b/examples/qml/cppextensions/referenceexamples/binding/binding.pro @@ -0,0 +1,15 @@ +QT += qml + +SOURCES += main.cpp \ + person.cpp \ + birthdayparty.cpp \ + happybirthdaysong.cpp +HEADERS += person.h \ + birthdayparty.h \ + happybirthdaysong.h + +RESOURCES += binding.qrc +target.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/qml/extending/binding +sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS binding.pro +sources.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/qml/extending/binding +INSTALLS += target sources diff --git a/examples/qml/cppextensions/referenceexamples/binding/binding.qrc b/examples/qml/cppextensions/referenceexamples/binding/binding.qrc new file mode 100644 index 0000000000..e2fa01d5e7 --- /dev/null +++ b/examples/qml/cppextensions/referenceexamples/binding/binding.qrc @@ -0,0 +1,5 @@ + + + example.qml + + diff --git a/examples/qml/cppextensions/referenceexamples/binding/birthdayparty.cpp b/examples/qml/cppextensions/referenceexamples/binding/birthdayparty.cpp new file mode 100644 index 0000000000..9a38c3b646 --- /dev/null +++ b/examples/qml/cppextensions/referenceexamples/binding/birthdayparty.cpp @@ -0,0 +1,113 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include "birthdayparty.h" + +BirthdayPartyAttached::BirthdayPartyAttached(QObject *object) +: QObject(object) +{ +} + +QDate BirthdayPartyAttached::rsvp() const +{ + return m_rsvp; +} + +void BirthdayPartyAttached::setRsvp(const QDate &d) +{ + if (d != m_rsvp) { + m_rsvp = d; + emit rsvpChanged(); + } +} + + +BirthdayParty::BirthdayParty(QObject *parent) +: QObject(parent), m_host(0) +{ +} + +Person *BirthdayParty::host() const +{ + return m_host; +} + +void BirthdayParty::setHost(Person *c) +{ + if (c == m_host) return; + m_host = c; + emit hostChanged(); +} + +QQmlListProperty BirthdayParty::guests() +{ + return QQmlListProperty(this, m_guests); +} + +int BirthdayParty::guestCount() const +{ + return m_guests.count(); +} + +Person *BirthdayParty::guest(int index) const +{ + return m_guests.at(index); +} + +void BirthdayParty::startParty() +{ + QTime time = QTime::currentTime(); + emit partyStarted(time); +} + +QString BirthdayParty::announcement() const +{ + return QString(); +} + +void BirthdayParty::setAnnouncement(const QString &speak) +{ + qWarning() << qPrintable(speak); +} + +BirthdayPartyAttached *BirthdayParty::qmlAttachedProperties(QObject *object) +{ + return new BirthdayPartyAttached(object); +} + diff --git a/examples/qml/cppextensions/referenceexamples/binding/birthdayparty.h b/examples/qml/cppextensions/referenceexamples/binding/birthdayparty.h new file mode 100644 index 0000000000..195e9cd9cf --- /dev/null +++ b/examples/qml/cppextensions/referenceexamples/binding/birthdayparty.h @@ -0,0 +1,102 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#ifndef BIRTHDAYPARTY_H +#define BIRTHDAYPARTY_H + +#include +#include +#include +#include +#include "person.h" + +class BirthdayPartyAttached : public QObject +{ + Q_OBJECT + Q_PROPERTY(QDate rsvp READ rsvp WRITE setRsvp NOTIFY rsvpChanged) +public: + BirthdayPartyAttached(QObject *object); + + QDate rsvp() const; + void setRsvp(const QDate &); + +signals: + void rsvpChanged(); + +private: + QDate m_rsvp; +}; + +class BirthdayParty : public QObject +{ + Q_OBJECT +// ![0] + Q_PROPERTY(Person *host READ host WRITE setHost NOTIFY hostChanged) +// ![0] + Q_PROPERTY(QQmlListProperty guests READ guests) + Q_PROPERTY(QString announcement READ announcement WRITE setAnnouncement) + Q_CLASSINFO("DefaultProperty", "guests") +public: + BirthdayParty(QObject *parent = 0); + + Person *host() const; + void setHost(Person *); + + QQmlListProperty guests(); + int guestCount() const; + Person *guest(int) const; + + QString announcement() const; + void setAnnouncement(const QString &); + + static BirthdayPartyAttached *qmlAttachedProperties(QObject *); + + void startParty(); +signals: + void partyStarted(const QTime &time); + void hostChanged(); + +private: + Person *m_host; + QList m_guests; +}; + +QML_DECLARE_TYPEINFO(BirthdayParty, QML_HAS_ATTACHED_PROPERTIES) + +#endif // BIRTHDAYPARTY_H diff --git a/examples/qml/cppextensions/referenceexamples/binding/example.qml b/examples/qml/cppextensions/referenceexamples/binding/example.qml new file mode 100644 index 0000000000..99a0098ff6 --- /dev/null +++ b/examples/qml/cppextensions/referenceexamples/binding/example.qml @@ -0,0 +1,77 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import People 1.0 + +// ![0] +BirthdayParty { + id: theParty + + HappyBirthdaySong on announcement { name: theParty.host.name } + + host: Boy { + name: "Bob Jones" + shoe { size: 12; color: "white"; brand: "Nike"; price: 90.0 } + } +// ![0] + onPartyStarted: console.log("This party started rockin' at " + time); + + + Boy { + name: "Leo Hodges" + BirthdayParty.rsvp: "2009-07-06" + shoe { size: 10; color: "black"; brand: "Reebok"; price: 59.95 } + } + Boy { + name: "Jack Smith" + shoe { size: 8; color: "blue"; brand: "Puma"; price: 19.95 } + } + Girl { + name: "Anne Brown" + BirthdayParty.rsvp: "2009-07-01" + shoe.size: 7 + shoe.color: "red" + shoe.brand: "Marc Jacobs" + shoe.price: 699.99 + } + +// ![1] +} +// ![1] diff --git a/examples/qml/cppextensions/referenceexamples/binding/happybirthdaysong.cpp b/examples/qml/cppextensions/referenceexamples/binding/happybirthdaysong.cpp new file mode 100644 index 0000000000..90220e15ae --- /dev/null +++ b/examples/qml/cppextensions/referenceexamples/binding/happybirthdaysong.cpp @@ -0,0 +1,85 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include "happybirthdaysong.h" +#include + +HappyBirthdaySong::HappyBirthdaySong(QObject *parent) +: QObject(parent), m_line(-1) +{ + setName(QString()); + QTimer *timer = new QTimer(this); + QObject::connect(timer, SIGNAL(timeout()), this, SLOT(advance())); + timer->start(1000); +} + +void HappyBirthdaySong::setTarget(const QQmlProperty &p) +{ + m_target = p; +} + +QString HappyBirthdaySong::name() const +{ + return m_name; +} + +void HappyBirthdaySong::setName(const QString &name) +{ + if (m_name == name) + return; + + m_name = name; + + m_lyrics.clear(); + m_lyrics << "Happy birthday to you,"; + m_lyrics << "Happy birthday to you,"; + m_lyrics << "Happy birthday dear " + m_name + ","; + m_lyrics << "Happy birthday to you!"; + m_lyrics << ""; + + emit nameChanged(); +} + +void HappyBirthdaySong::advance() +{ + m_line = (m_line + 1) % m_lyrics.count(); + + m_target.write(m_lyrics.at(m_line)); +} + diff --git a/examples/qml/cppextensions/referenceexamples/binding/happybirthdaysong.h b/examples/qml/cppextensions/referenceexamples/binding/happybirthdaysong.h new file mode 100644 index 0000000000..ace48b2af0 --- /dev/null +++ b/examples/qml/cppextensions/referenceexamples/binding/happybirthdaysong.h @@ -0,0 +1,74 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#ifndef HAPPYBIRTHDAYSONG_H +#define HAPPYBIRTHDAYSONG_H + +#include +#include + +#include + +class HappyBirthdaySong : public QObject, public QQmlPropertyValueSource +{ + Q_OBJECT + Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged) + Q_INTERFACES(QQmlPropertyValueSource) +public: + HappyBirthdaySong(QObject *parent = 0); + + virtual void setTarget(const QQmlProperty &); + + QString name() const; + void setName(const QString &); + +private slots: + void advance(); + +signals: + void nameChanged(); +private: + int m_line; + QStringList m_lyrics; + QQmlProperty m_target; + QString m_name; +}; + +#endif // HAPPYBIRTHDAYSONG_H + diff --git a/examples/qml/cppextensions/referenceexamples/binding/main.cpp b/examples/qml/cppextensions/referenceexamples/binding/main.cpp new file mode 100644 index 0000000000..389cb7609b --- /dev/null +++ b/examples/qml/cppextensions/referenceexamples/binding/main.cpp @@ -0,0 +1,92 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include +#include +#include +#include +#include "birthdayparty.h" +#include "happybirthdaysong.h" +#include "person.h" + +int main(int argc, char ** argv) +{ + QCoreApplication app(argc, argv); + qmlRegisterType(); + qmlRegisterType("People", 1,0, "BirthdayParty"); + qmlRegisterType("People", 1,0, "HappyBirthdaySong"); + qmlRegisterType(); + qmlRegisterType(); + qmlRegisterType("People", 1,0, "Boy"); + qmlRegisterType("People", 1,0, "Girl"); + + QQmlEngine engine; + QQmlComponent component(&engine, QUrl("qrc:example.qml")); + BirthdayParty *party = qobject_cast(component.create()); + + if (party && party->host()) { + qWarning() << party->host()->name() << "is having a birthday!"; + + if (qobject_cast(party->host())) + qWarning() << "He is inviting:"; + else + qWarning() << "She is inviting:"; + + for (int ii = 0; ii < party->guestCount(); ++ii) { + Person *guest = party->guest(ii); + + QDate rsvpDate; + QObject *attached = + qmlAttachedPropertiesObject(guest, false); + if (attached) + rsvpDate = attached->property("rsvp").toDate(); + + if (rsvpDate.isNull()) + qWarning() << " " << guest->name() << "RSVP date: Hasn't RSVP'd"; + else + qWarning() << " " << guest->name() << "RSVP date:" << qPrintable(rsvpDate.toString()); + } + + party->startParty(); + } else { + qWarning() << component.errors(); + } + + return app.exec(); +} diff --git a/examples/qml/cppextensions/referenceexamples/binding/person.cpp b/examples/qml/cppextensions/referenceexamples/binding/person.cpp new file mode 100644 index 0000000000..89e7127caf --- /dev/null +++ b/examples/qml/cppextensions/referenceexamples/binding/person.cpp @@ -0,0 +1,138 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include "person.h" + +ShoeDescription::ShoeDescription(QObject *parent) +: QObject(parent), m_size(0), m_price(0) +{ +} + +int ShoeDescription::size() const +{ + return m_size; +} + +void ShoeDescription::setSize(int s) +{ + if (m_size == s) + return; + + m_size = s; + emit shoeChanged(); +} + +QColor ShoeDescription::color() const +{ + return m_color; +} + +void ShoeDescription::setColor(const QColor &c) +{ + if (m_color == c) + return; + + m_color = c; + emit shoeChanged(); +} + +QString ShoeDescription::brand() const +{ + return m_brand; +} + +void ShoeDescription::setBrand(const QString &b) +{ + if (m_brand == b) + return; + + m_brand = b; + emit shoeChanged(); +} + +qreal ShoeDescription::price() const +{ + return m_price; +} + +void ShoeDescription::setPrice(qreal p) +{ + if (m_price == p) + return; + + m_price = p; + emit shoeChanged(); +} + +Person::Person(QObject *parent) +: QObject(parent) +{ +} + +QString Person::name() const +{ + return m_name; +} + +void Person::setName(const QString &n) +{ + if (m_name == n) + return; + + m_name = n; + emit nameChanged(); +} + +ShoeDescription *Person::shoe() +{ + return &m_shoe; +} + + +Boy::Boy(QObject * parent) +: Person(parent) +{ +} + + +Girl::Girl(QObject * parent) +: Person(parent) +{ +} + diff --git a/examples/qml/cppextensions/referenceexamples/binding/person.h b/examples/qml/cppextensions/referenceexamples/binding/person.h new file mode 100644 index 0000000000..d0f196b95c --- /dev/null +++ b/examples/qml/cppextensions/referenceexamples/binding/person.h @@ -0,0 +1,113 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#ifndef PERSON_H +#define PERSON_H + +#include +#include + +class ShoeDescription : public QObject +{ + Q_OBJECT + Q_PROPERTY(int size READ size WRITE setSize NOTIFY shoeChanged) + Q_PROPERTY(QColor color READ color WRITE setColor NOTIFY shoeChanged) + Q_PROPERTY(QString brand READ brand WRITE setBrand NOTIFY shoeChanged) + Q_PROPERTY(qreal price READ price WRITE setPrice NOTIFY shoeChanged) +public: + ShoeDescription(QObject *parent = 0); + + int size() const; + void setSize(int); + + QColor color() const; + void setColor(const QColor &); + + QString brand() const; + void setBrand(const QString &); + + qreal price() const; + void setPrice(qreal); +signals: + void shoeChanged(); + +private: + int m_size; + QColor m_color; + QString m_brand; + qreal m_price; +}; + +class Person : public QObject +{ + Q_OBJECT + Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged) +// ![0] + Q_PROPERTY(ShoeDescription *shoe READ shoe CONSTANT) +// ![0] +public: + Person(QObject *parent = 0); + + QString name() const; + void setName(const QString &); + + ShoeDescription *shoe(); +signals: + void nameChanged(); + +private: + QString m_name; + ShoeDescription m_shoe; +}; + +class Boy : public Person +{ + Q_OBJECT +public: + Boy(QObject * parent = 0); +}; + +class Girl : public Person +{ + Q_OBJECT +public: + Girl(QObject * parent = 0); +}; + +#endif // PERSON_H diff --git a/examples/qml/cppextensions/referenceexamples/coercion/birthdayparty.cpp b/examples/qml/cppextensions/referenceexamples/coercion/birthdayparty.cpp new file mode 100644 index 0000000000..d697ac22b6 --- /dev/null +++ b/examples/qml/cppextensions/referenceexamples/coercion/birthdayparty.cpp @@ -0,0 +1,71 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include "birthdayparty.h" + +BirthdayParty::BirthdayParty(QObject *parent) +: QObject(parent), m_host(0) +{ +} + +Person *BirthdayParty::host() const +{ + return m_host; +} + +void BirthdayParty::setHost(Person *c) +{ + m_host = c; +} + +QQmlListProperty BirthdayParty::guests() +{ + return QQmlListProperty(this, m_guests); +} + +int BirthdayParty::guestCount() const +{ + return m_guests.count(); +} + +Person *BirthdayParty::guest(int index) const +{ + return m_guests.at(index); +} + diff --git a/examples/qml/cppextensions/referenceexamples/coercion/birthdayparty.h b/examples/qml/cppextensions/referenceexamples/coercion/birthdayparty.h new file mode 100644 index 0000000000..43611693d9 --- /dev/null +++ b/examples/qml/cppextensions/referenceexamples/coercion/birthdayparty.h @@ -0,0 +1,69 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#ifndef BIRTHDAYPARTY_H +#define BIRTHDAYPARTY_H + +#include +#include +#include "person.h" + +class BirthdayParty : public QObject +{ + Q_OBJECT +// ![0] + Q_PROPERTY(Person *host READ host WRITE setHost) + Q_PROPERTY(QQmlListProperty guests READ guests) +// ![0] +public: + BirthdayParty(QObject *parent = 0); + + Person *host() const; + void setHost(Person *); + + QQmlListProperty guests(); + int guestCount() const; + Person *guest(int) const; + +private: + Person *m_host; + QList m_guests; +}; + +#endif // BIRTHDAYPARTY_H diff --git a/examples/qml/cppextensions/referenceexamples/coercion/coercion.pro b/examples/qml/cppextensions/referenceexamples/coercion/coercion.pro new file mode 100644 index 0000000000..60e8532bab --- /dev/null +++ b/examples/qml/cppextensions/referenceexamples/coercion/coercion.pro @@ -0,0 +1,13 @@ +QT += qml + +SOURCES += main.cpp \ + person.cpp \ + birthdayparty.cpp +HEADERS += person.h \ + birthdayparty.h +RESOURCES += coercion.qrc + +target.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/qml/extending/coercion +sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS coercion.pro +sources.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/qml/extending/coercion +INSTALLS += target sources diff --git a/examples/qml/cppextensions/referenceexamples/coercion/coercion.qrc b/examples/qml/cppextensions/referenceexamples/coercion/coercion.qrc new file mode 100644 index 0000000000..e2fa01d5e7 --- /dev/null +++ b/examples/qml/cppextensions/referenceexamples/coercion/coercion.qrc @@ -0,0 +1,5 @@ + + + example.qml + + diff --git a/examples/qml/cppextensions/referenceexamples/coercion/example.qml b/examples/qml/cppextensions/referenceexamples/coercion/example.qml new file mode 100644 index 0000000000..25791f38f8 --- /dev/null +++ b/examples/qml/cppextensions/referenceexamples/coercion/example.qml @@ -0,0 +1,55 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import People 1.0 + +// ![0] +BirthdayParty { + host: Boy { + name: "Bob Jones" + shoeSize: 12 + } + guests: [ + Boy { name: "Leo Hodges" }, + Boy { name: "Jack Smith" }, + Girl { name: "Anne Brown" } + ] +} +// ![0] diff --git a/examples/qml/cppextensions/referenceexamples/coercion/main.cpp b/examples/qml/cppextensions/referenceexamples/coercion/main.cpp new file mode 100644 index 0000000000..15e41ca597 --- /dev/null +++ b/examples/qml/cppextensions/referenceexamples/coercion/main.cpp @@ -0,0 +1,80 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include +#include +#include +#include +#include "birthdayparty.h" +#include "person.h" + +int main(int argc, char ** argv) +{ + QCoreApplication app(argc, argv); + + qmlRegisterType("People", 1,0, "BirthdayParty"); + //![0] + qmlRegisterType(); + //![0] + + //![register boy girl] + qmlRegisterType("People", 1,0, "Boy"); + qmlRegisterType("People", 1,0, "Girl"); + //![register boy girl] + + QQmlEngine engine; + QQmlComponent component(&engine, QUrl("qrc:example.qml")); + BirthdayParty *party = qobject_cast(component.create()); + + if (party && party->host()) { + qWarning() << party->host()->name() << "is having a birthday!"; + + if (qobject_cast(party->host())) + qWarning() << "He is inviting:"; + else + qWarning() << "She is inviting:"; + + for (int ii = 0; ii < party->guestCount(); ++ii) + qWarning() << " " << party->guest(ii)->name(); + } else { + qWarning() << component.errors(); + } + + return 0; +} diff --git a/examples/qml/cppextensions/referenceexamples/coercion/person.cpp b/examples/qml/cppextensions/referenceexamples/coercion/person.cpp new file mode 100644 index 0000000000..b28d63216e --- /dev/null +++ b/examples/qml/cppextensions/referenceexamples/coercion/person.cpp @@ -0,0 +1,79 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include "person.h" + +Person::Person(QObject *parent) +: QObject(parent), m_shoeSize(0) +{ +} + +QString Person::name() const +{ + return m_name; +} + +void Person::setName(const QString &n) +{ + m_name = n; +} + +int Person::shoeSize() const +{ + return m_shoeSize; +} + +void Person::setShoeSize(int s) +{ + m_shoeSize = s; +} + +// ![1] +Boy::Boy(QObject * parent) +: Person(parent) +{ +} + + +Girl::Girl(QObject * parent) +: Person(parent) +{ +} + +// ![1] diff --git a/examples/qml/cppextensions/referenceexamples/coercion/person.h b/examples/qml/cppextensions/referenceexamples/coercion/person.h new file mode 100644 index 0000000000..dc4ae43dd6 --- /dev/null +++ b/examples/qml/cppextensions/referenceexamples/coercion/person.h @@ -0,0 +1,83 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#ifndef PERSON_H +#define PERSON_H + +#include + +class Person : public QObject +{ + Q_OBJECT + Q_PROPERTY(QString name READ name WRITE setName) + Q_PROPERTY(int shoeSize READ shoeSize WRITE setShoeSize) +public: + Person(QObject *parent = 0); + + QString name() const; + void setName(const QString &); + + int shoeSize() const; + void setShoeSize(int); +private: + QString m_name; + int m_shoeSize; +}; + + +// ![0] +class Boy : public Person +{ + Q_OBJECT +public: + Boy(QObject * parent = 0); +}; + +//! [girl class] +class Girl : public Person +{ + Q_OBJECT +public: + Girl(QObject * parent = 0); +}; +//! [girl class] + +// ![0] + +#endif // PERSON_H diff --git a/examples/qml/cppextensions/referenceexamples/default/birthdayparty.cpp b/examples/qml/cppextensions/referenceexamples/default/birthdayparty.cpp new file mode 100644 index 0000000000..d697ac22b6 --- /dev/null +++ b/examples/qml/cppextensions/referenceexamples/default/birthdayparty.cpp @@ -0,0 +1,71 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include "birthdayparty.h" + +BirthdayParty::BirthdayParty(QObject *parent) +: QObject(parent), m_host(0) +{ +} + +Person *BirthdayParty::host() const +{ + return m_host; +} + +void BirthdayParty::setHost(Person *c) +{ + m_host = c; +} + +QQmlListProperty BirthdayParty::guests() +{ + return QQmlListProperty(this, m_guests); +} + +int BirthdayParty::guestCount() const +{ + return m_guests.count(); +} + +Person *BirthdayParty::guest(int index) const +{ + return m_guests.at(index); +} + diff --git a/examples/qml/cppextensions/referenceexamples/default/birthdayparty.h b/examples/qml/cppextensions/referenceexamples/default/birthdayparty.h new file mode 100644 index 0000000000..3ee635039d --- /dev/null +++ b/examples/qml/cppextensions/referenceexamples/default/birthdayparty.h @@ -0,0 +1,70 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#ifndef BIRTHDAYPARTY_H +#define BIRTHDAYPARTY_H + +#include +#include +#include "person.h" + +// ![0] +class BirthdayParty : public QObject +{ + Q_OBJECT + Q_PROPERTY(Person *host READ host WRITE setHost) + Q_PROPERTY(QQmlListProperty guests READ guests) + Q_CLASSINFO("DefaultProperty", "guests") +public: + BirthdayParty(QObject *parent = 0); + + Person *host() const; + void setHost(Person *); + + QQmlListProperty guests(); + int guestCount() const; + Person *guest(int) const; + +private: + Person *m_host; + QList m_guests; +}; +// ![0] + +#endif // BIRTHDAYPARTY_H diff --git a/examples/qml/cppextensions/referenceexamples/default/default.pro b/examples/qml/cppextensions/referenceexamples/default/default.pro new file mode 100644 index 0000000000..36ef39fc55 --- /dev/null +++ b/examples/qml/cppextensions/referenceexamples/default/default.pro @@ -0,0 +1,13 @@ +QT += qml + +SOURCES += main.cpp \ + person.cpp \ + birthdayparty.cpp +HEADERS += person.h \ + birthdayparty.h +RESOURCES += default.qrc + +target.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/qml/extending/default +sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS default.pro +sources.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/qml/extending/default +INSTALLS += target sources diff --git a/examples/qml/cppextensions/referenceexamples/default/default.qrc b/examples/qml/cppextensions/referenceexamples/default/default.qrc new file mode 100644 index 0000000000..e2fa01d5e7 --- /dev/null +++ b/examples/qml/cppextensions/referenceexamples/default/default.qrc @@ -0,0 +1,5 @@ + + + example.qml + + diff --git a/examples/qml/cppextensions/referenceexamples/default/example.qml b/examples/qml/cppextensions/referenceexamples/default/example.qml new file mode 100644 index 0000000000..9ef24b59b7 --- /dev/null +++ b/examples/qml/cppextensions/referenceexamples/default/example.qml @@ -0,0 +1,54 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import People 1.0 + +// ![0] +BirthdayParty { + host: Boy { + name: "Bob Jones" + shoeSize: 12 + } + + Boy { name: "Leo Hodges" } + Boy { name: "Jack Smith" } + Girl { name: "Anne Brown" } +} +// ![0] diff --git a/examples/qml/cppextensions/referenceexamples/default/main.cpp b/examples/qml/cppextensions/referenceexamples/default/main.cpp new file mode 100644 index 0000000000..175945fc5d --- /dev/null +++ b/examples/qml/cppextensions/referenceexamples/default/main.cpp @@ -0,0 +1,75 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include +#include +#include +#include +#include "birthdayparty.h" +#include "person.h" + +int main(int argc, char ** argv) +{ + QCoreApplication app(argc, argv); + + qmlRegisterType("People", 1,0, "BirthdayParty"); + qmlRegisterType(); + qmlRegisterType("People", 1,0, "Boy"); + qmlRegisterType("People", 1,0, "Girl"); + + QQmlEngine engine; + QQmlComponent component(&engine, QUrl("qrc:example.qml")); + BirthdayParty *party = qobject_cast(component.create()); + + if (party && party->host()) { + qWarning() << party->host()->name() << "is having a birthday!"; + + if (qobject_cast(party->host())) + qWarning() << "He is inviting:"; + else + qWarning() << "She is inviting:"; + + for (int ii = 0; ii < party->guestCount(); ++ii) + qWarning() << " " << party->guest(ii)->name(); + } else { + qWarning() << component.errors(); + } + + return 0; +} diff --git a/examples/qml/cppextensions/referenceexamples/default/person.cpp b/examples/qml/cppextensions/referenceexamples/default/person.cpp new file mode 100644 index 0000000000..5a615a1ecd --- /dev/null +++ b/examples/qml/cppextensions/referenceexamples/default/person.cpp @@ -0,0 +1,78 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include "person.h" + +Person::Person(QObject *parent) +: QObject(parent), m_shoeSize(0) +{ +} + +QString Person::name() const +{ + return m_name; +} + +void Person::setName(const QString &n) +{ + m_name = n; +} + +int Person::shoeSize() const +{ + return m_shoeSize; +} + +void Person::setShoeSize(int s) +{ + m_shoeSize = s; +} + + +Boy::Boy(QObject * parent) +: Person(parent) +{ +} + + +Girl::Girl(QObject * parent) +: Person(parent) +{ +} + diff --git a/examples/qml/cppextensions/referenceexamples/default/person.h b/examples/qml/cppextensions/referenceexamples/default/person.h new file mode 100644 index 0000000000..d85672798c --- /dev/null +++ b/examples/qml/cppextensions/referenceexamples/default/person.h @@ -0,0 +1,77 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#ifndef PERSON_H +#define PERSON_H + +#include + +class Person : public QObject +{ + Q_OBJECT + Q_PROPERTY(QString name READ name WRITE setName) + Q_PROPERTY(int shoeSize READ shoeSize WRITE setShoeSize) +public: + Person(QObject *parent = 0); + + QString name() const; + void setName(const QString &); + + int shoeSize() const; + void setShoeSize(int); +private: + QString m_name; + int m_shoeSize; +}; + +class Boy : public Person +{ + Q_OBJECT +public: + Boy(QObject * parent = 0); +}; + +class Girl : public Person +{ + Q_OBJECT +public: + Girl(QObject * parent = 0); +}; + +#endif // PERSON_H diff --git a/examples/qml/cppextensions/referenceexamples/extended/example.qml b/examples/qml/cppextensions/referenceexamples/extended/example.qml new file mode 100644 index 0000000000..642a95d443 --- /dev/null +++ b/examples/qml/cppextensions/referenceexamples/extended/example.qml @@ -0,0 +1,47 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import People 1.0 + +// ![0] +QLineEdit { + leftMargin: 20 +} +// ![0] diff --git a/examples/qml/cppextensions/referenceexamples/extended/extended.pro b/examples/qml/cppextensions/referenceexamples/extended/extended.pro new file mode 100644 index 0000000000..206ea19c61 --- /dev/null +++ b/examples/qml/cppextensions/referenceexamples/extended/extended.pro @@ -0,0 +1,11 @@ +QT += qml widgets + +SOURCES += main.cpp \ + lineedit.cpp +HEADERS += lineedit.h +RESOURCES += extended.qrc + +target.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/qml/extending/extended +sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS extended.pro +sources.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/qml/extending/extended +INSTALLS += target sources diff --git a/examples/qml/cppextensions/referenceexamples/extended/extended.qrc b/examples/qml/cppextensions/referenceexamples/extended/extended.qrc new file mode 100644 index 0000000000..e2fa01d5e7 --- /dev/null +++ b/examples/qml/cppextensions/referenceexamples/extended/extended.qrc @@ -0,0 +1,5 @@ + + + example.qml + + diff --git a/examples/qml/cppextensions/referenceexamples/extended/lineedit.cpp b/examples/qml/cppextensions/referenceexamples/extended/lineedit.cpp new file mode 100644 index 0000000000..a3b1d0d54e --- /dev/null +++ b/examples/qml/cppextensions/referenceexamples/extended/lineedit.cpp @@ -0,0 +1,104 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include "lineedit.h" +#include + +LineEditExtension::LineEditExtension(QObject *object) +: QObject(object), m_lineedit(static_cast(object)) +{ +} + +int LineEditExtension::leftMargin() const +{ + int l, r, t, b; + m_lineedit->getTextMargins(&l, &t, &r, &b); + return l; +} + +void LineEditExtension::setLeftMargin(int m) +{ + int l, r, t, b; + m_lineedit->getTextMargins(&l, &t, &r, &b); + m_lineedit->setTextMargins(m, t, r, b); +} + +int LineEditExtension::rightMargin() const +{ + int l, r, t, b; + m_lineedit->getTextMargins(&l, &t, &r, &b); + return r; +} + +void LineEditExtension::setRightMargin(int m) +{ + int l, r, t, b; + m_lineedit->getTextMargins(&l, &t, &r, &b); + m_lineedit->setTextMargins(l, t, m, b); +} + +int LineEditExtension::topMargin() const +{ + int l, r, t, b; + m_lineedit->getTextMargins(&l, &t, &r, &b); + return t; +} + +void LineEditExtension::setTopMargin(int m) +{ + int l, r, t, b; + m_lineedit->getTextMargins(&l, &t, &r, &b); + m_lineedit->setTextMargins(l, m, r, b); +} + +int LineEditExtension::bottomMargin() const +{ + int l, r, t, b; + m_lineedit->getTextMargins(&l, &t, &r, &b); + return b; +} + +void LineEditExtension::setBottomMargin(int m) +{ + int l, r, t, b; + m_lineedit->getTextMargins(&l, &t, &r, &b); + m_lineedit->setTextMargins(l, t, r, m); +} + + diff --git a/examples/qml/cppextensions/referenceexamples/extended/lineedit.h b/examples/qml/cppextensions/referenceexamples/extended/lineedit.h new file mode 100644 index 0000000000..fa8c75df78 --- /dev/null +++ b/examples/qml/cppextensions/referenceexamples/extended/lineedit.h @@ -0,0 +1,73 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#ifndef LINEEDIT_H +#define LINEEDIT_H + +#include + +class LineEditExtension : public QObject +{ + Q_OBJECT + Q_PROPERTY(int leftMargin READ leftMargin WRITE setLeftMargin NOTIFY marginsChanged) + Q_PROPERTY(int rightMargin READ rightMargin WRITE setRightMargin NOTIFY marginsChanged) + Q_PROPERTY(int topMargin READ topMargin WRITE setTopMargin NOTIFY marginsChanged) + Q_PROPERTY(int bottomMargin READ bottomMargin WRITE setBottomMargin NOTIFY marginsChanged) +public: + LineEditExtension(QObject *); + + int leftMargin() const; + void setLeftMargin(int); + + int rightMargin() const; + void setRightMargin(int); + + int topMargin() const; + void setTopMargin(int); + + int bottomMargin() const; + void setBottomMargin(int); +signals: + void marginsChanged(); + +private: + QLineEdit *m_lineedit; +}; + +#endif // LINEEDIT_H diff --git a/examples/qml/cppextensions/referenceexamples/extended/main.cpp b/examples/qml/cppextensions/referenceexamples/extended/main.cpp new file mode 100644 index 0000000000..de7c450169 --- /dev/null +++ b/examples/qml/cppextensions/referenceexamples/extended/main.cpp @@ -0,0 +1,64 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include +#include +#include +#include +#include +#include "lineedit.h" + +int main(int argc, char ** argv) +{ + QApplication app(argc, argv); + + qmlRegisterExtendedType("People", 1,0, "QLineEdit"); + + QQmlEngine engine; + QQmlComponent component(&engine, QUrl("qrc:example.qml")); + QLineEdit *edit = qobject_cast(component.create()); + + if (edit) { + edit->show(); + return app.exec(); + } else { + qWarning() << component.errors(); + return 0; + } +} diff --git a/examples/qml/cppextensions/referenceexamples/grouped/birthdayparty.cpp b/examples/qml/cppextensions/referenceexamples/grouped/birthdayparty.cpp new file mode 100644 index 0000000000..d697ac22b6 --- /dev/null +++ b/examples/qml/cppextensions/referenceexamples/grouped/birthdayparty.cpp @@ -0,0 +1,71 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include "birthdayparty.h" + +BirthdayParty::BirthdayParty(QObject *parent) +: QObject(parent), m_host(0) +{ +} + +Person *BirthdayParty::host() const +{ + return m_host; +} + +void BirthdayParty::setHost(Person *c) +{ + m_host = c; +} + +QQmlListProperty BirthdayParty::guests() +{ + return QQmlListProperty(this, m_guests); +} + +int BirthdayParty::guestCount() const +{ + return m_guests.count(); +} + +Person *BirthdayParty::guest(int index) const +{ + return m_guests.at(index); +} + diff --git a/examples/qml/cppextensions/referenceexamples/grouped/birthdayparty.h b/examples/qml/cppextensions/referenceexamples/grouped/birthdayparty.h new file mode 100644 index 0000000000..5ca0e9b982 --- /dev/null +++ b/examples/qml/cppextensions/referenceexamples/grouped/birthdayparty.h @@ -0,0 +1,69 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#ifndef BIRTHDAYPARTY_H +#define BIRTHDAYPARTY_H + +#include +#include +#include "person.h" + +class BirthdayParty : public QObject +{ + Q_OBJECT + Q_PROPERTY(Person *host READ host WRITE setHost) + Q_PROPERTY(QQmlListProperty guests READ guests) + Q_CLASSINFO("DefaultProperty", "guests") +public: + BirthdayParty(QObject *parent = 0); + + Person *host() const; + void setHost(Person *); + + QQmlListProperty guests(); + int guestCount() const; + Person *guest(int) const; + +private: + Person *m_host; + QList m_guests; +}; + + +#endif // BIRTHDAYPARTY_H diff --git a/examples/qml/cppextensions/referenceexamples/grouped/example.qml b/examples/qml/cppextensions/referenceexamples/grouped/example.qml new file mode 100644 index 0000000000..9ae80f222e --- /dev/null +++ b/examples/qml/cppextensions/referenceexamples/grouped/example.qml @@ -0,0 +1,77 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import People 1.0 + +// ![0] +BirthdayParty { + host: Boy { + name: "Bob Jones" + shoe { size: 12; color: "white"; brand: "Bikey"; price: 90.0 } + } + + Boy { + name: "Leo Hodges" +//![grouped] + shoe { size: 10; color: "black"; brand: "Thebok"; price: 59.95 } +//![grouped] + } + // ![1] + Boy { + name: "Jack Smith" + shoe { + size: 8 + color: "blue" + brand: "Luma" + price: 19.95 + } + } + // ![1] + Girl { + name: "Anne Brown" +//![ungrouped] + shoe.size: 7 + shoe.color: "red" + shoe.brand: "Job Macobs" + shoe.price: 699.99 +//![ungrouped] + } +} +// ![0] diff --git a/examples/qml/cppextensions/referenceexamples/grouped/grouped.pro b/examples/qml/cppextensions/referenceexamples/grouped/grouped.pro new file mode 100644 index 0000000000..d32a98f79b --- /dev/null +++ b/examples/qml/cppextensions/referenceexamples/grouped/grouped.pro @@ -0,0 +1,13 @@ +QT += qml + +SOURCES += main.cpp \ + person.cpp \ + birthdayparty.cpp +HEADERS += person.h \ + birthdayparty.h +RESOURCES += grouped.qrc + +target.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/qml/extending/grouped +sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS grouped.pro +sources.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/qml/extending/grouped +INSTALLS += target sources diff --git a/examples/qml/cppextensions/referenceexamples/grouped/grouped.qrc b/examples/qml/cppextensions/referenceexamples/grouped/grouped.qrc new file mode 100644 index 0000000000..e2fa01d5e7 --- /dev/null +++ b/examples/qml/cppextensions/referenceexamples/grouped/grouped.qrc @@ -0,0 +1,5 @@ + + + example.qml + + diff --git a/examples/qml/cppextensions/referenceexamples/grouped/main.cpp b/examples/qml/cppextensions/referenceexamples/grouped/main.cpp new file mode 100644 index 0000000000..55be3b715b --- /dev/null +++ b/examples/qml/cppextensions/referenceexamples/grouped/main.cpp @@ -0,0 +1,85 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include +#include +#include +#include +#include "birthdayparty.h" +#include "person.h" + +int main(int argc, char ** argv) +{ + QCoreApplication app(argc, argv); + + qmlRegisterType("People", 1,0, "BirthdayParty"); + qmlRegisterType(); + qmlRegisterType(); + qmlRegisterType("People", 1,0, "Boy"); + qmlRegisterType("People", 1,0, "Girl"); + + QQmlEngine engine; + QQmlComponent component(&engine, QUrl("qrc:example.qml")); + BirthdayParty *party = qobject_cast(component.create()); + + if (party && party->host()) { + qWarning() << party->host()->name() << "is having a birthday!"; + + if (qobject_cast(party->host())) + qWarning() << "He is inviting:"; + else + qWarning() << "She is inviting:"; + + Person *bestShoe = 0; + for (int ii = 0; ii < party->guestCount(); ++ii) { + Person *guest = party->guest(ii); + qWarning() << " " << guest->name(); + + if (!bestShoe || bestShoe->shoe()->price() < guest->shoe()->price()) + bestShoe = guest; + } + if (bestShoe) + qWarning() << bestShoe->name() << "is wearing the best shoes!"; + + } else { + qWarning() << component.errors(); + } + + return 0; +} diff --git a/examples/qml/cppextensions/referenceexamples/grouped/person.cpp b/examples/qml/cppextensions/referenceexamples/grouped/person.cpp new file mode 100644 index 0000000000..7afcdc6ca6 --- /dev/null +++ b/examples/qml/cppextensions/referenceexamples/grouped/person.cpp @@ -0,0 +1,118 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include "person.h" + +ShoeDescription::ShoeDescription(QObject *parent) +: QObject(parent), m_size(0), m_price(0) +{ +} + +int ShoeDescription::size() const +{ + return m_size; +} + +void ShoeDescription::setSize(int s) +{ + m_size = s; +} + +QColor ShoeDescription::color() const +{ + return m_color; +} + +void ShoeDescription::setColor(const QColor &c) +{ + m_color = c; +} + +QString ShoeDescription::brand() const +{ + return m_brand; +} + +void ShoeDescription::setBrand(const QString &b) +{ + m_brand = b; +} + +qreal ShoeDescription::price() const +{ + return m_price; +} + +void ShoeDescription::setPrice(qreal p) +{ + m_price = p; +} + +Person::Person(QObject *parent) +: QObject(parent) +{ +} + +QString Person::name() const +{ + return m_name; +} + +void Person::setName(const QString &n) +{ + m_name = n; +} + +ShoeDescription *Person::shoe() +{ + return &m_shoe; +} + + +Boy::Boy(QObject * parent) +: Person(parent) +{ +} + + +Girl::Girl(QObject * parent) +: Person(parent) +{ +} + diff --git a/examples/qml/cppextensions/referenceexamples/grouped/person.h b/examples/qml/cppextensions/referenceexamples/grouped/person.h new file mode 100644 index 0000000000..dea715bacb --- /dev/null +++ b/examples/qml/cppextensions/referenceexamples/grouped/person.h @@ -0,0 +1,107 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#ifndef PERSON_H +#define PERSON_H + +#include +#include + +class ShoeDescription : public QObject +{ + Q_OBJECT + Q_PROPERTY(int size READ size WRITE setSize) + Q_PROPERTY(QColor color READ color WRITE setColor) + Q_PROPERTY(QString brand READ brand WRITE setBrand) + Q_PROPERTY(qreal price READ price WRITE setPrice) +public: + ShoeDescription(QObject *parent = 0); + + int size() const; + void setSize(int); + + QColor color() const; + void setColor(const QColor &); + + QString brand() const; + void setBrand(const QString &); + + qreal price() const; + void setPrice(qreal); +private: + int m_size; + QColor m_color; + QString m_brand; + qreal m_price; +}; + +class Person : public QObject +{ + Q_OBJECT + Q_PROPERTY(QString name READ name WRITE setName) +// ![1] + Q_PROPERTY(ShoeDescription *shoe READ shoe) +// ![1] +public: + Person(QObject *parent = 0); + + QString name() const; + void setName(const QString &); + + ShoeDescription *shoe(); +private: + QString m_name; + ShoeDescription m_shoe; +}; + +class Boy : public Person +{ + Q_OBJECT +public: + Boy(QObject * parent = 0); +}; + +class Girl : public Person +{ + Q_OBJECT +public: + Girl(QObject * parent = 0); +}; + +#endif // PERSON_H diff --git a/examples/qml/cppextensions/referenceexamples/methods/birthdayparty.cpp b/examples/qml/cppextensions/referenceexamples/methods/birthdayparty.cpp new file mode 100644 index 0000000000..0935d708a7 --- /dev/null +++ b/examples/qml/cppextensions/referenceexamples/methods/birthdayparty.cpp @@ -0,0 +1,80 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include "birthdayparty.h" + +BirthdayParty::BirthdayParty(QObject *parent) +: QObject(parent), m_host(0) +{ +} + +// ![0] +Person *BirthdayParty::host() const +{ + return m_host; +} + +void BirthdayParty::setHost(Person *c) +{ + m_host = c; +} + +QQmlListProperty BirthdayParty::guests() +{ + return QQmlListProperty(this, m_guests); +} + +int BirthdayParty::guestCount() const +{ + return m_guests.count(); +} + +Person *BirthdayParty::guest(int index) const +{ + return m_guests.at(index); +} + +void BirthdayParty::invite(const QString &name) +{ + Person *person = new Person(this); + person->setName(name); + m_guests.append(person); +} +// ![0] + diff --git a/examples/qml/cppextensions/referenceexamples/methods/birthdayparty.h b/examples/qml/cppextensions/referenceexamples/methods/birthdayparty.h new file mode 100644 index 0000000000..df8a859972 --- /dev/null +++ b/examples/qml/cppextensions/referenceexamples/methods/birthdayparty.h @@ -0,0 +1,71 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#ifndef BIRTHDAYPARTY_H +#define BIRTHDAYPARTY_H + +#include +#include +#include "person.h" + +class BirthdayParty : public QObject +{ + Q_OBJECT + Q_PROPERTY(Person *host READ host WRITE setHost) + Q_PROPERTY(QQmlListProperty guests READ guests) +public: + BirthdayParty(QObject *parent = 0); + + Person *host() const; + void setHost(Person *); + + QQmlListProperty guests(); + int guestCount() const; + Person *guest(int) const; + +// ![0] + Q_INVOKABLE void invite(const QString &name); +// ![0] + +private: + Person *m_host; + QList m_guests; +}; + +#endif // BIRTHDAYPARTY_H diff --git a/examples/qml/cppextensions/referenceexamples/methods/example.qml b/examples/qml/cppextensions/referenceexamples/methods/example.qml new file mode 100644 index 0000000000..9119835e04 --- /dev/null +++ b/examples/qml/cppextensions/referenceexamples/methods/example.qml @@ -0,0 +1,58 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import People 1.0 + +BirthdayParty { + host: Person { + name: "Bob Jones" + shoeSize: 12 + } + guests: [ + Person { name: "Leo Hodges" }, + Person { name: "Jack Smith" }, + Person { name: "Anne Brown" } + ] + +// ![0] + Component.onCompleted: invite("William Green") +// ![0] +} diff --git a/examples/qml/cppextensions/referenceexamples/methods/main.cpp b/examples/qml/cppextensions/referenceexamples/methods/main.cpp new file mode 100644 index 0000000000..1e502c3943 --- /dev/null +++ b/examples/qml/cppextensions/referenceexamples/methods/main.cpp @@ -0,0 +1,68 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include +#include +#include +#include +#include "birthdayparty.h" +#include "person.h" + +int main(int argc, char ** argv) +{ + QCoreApplication app(argc, argv); + + qmlRegisterType("People", 1,0, "BirthdayParty"); + qmlRegisterType("People", 1,0, "Person"); + + QQmlEngine engine; + QQmlComponent component(&engine, QUrl("qrc:example.qml")); + BirthdayParty *party = qobject_cast(component.create()); + + if (party && party->host()) { + qWarning() << party->host()->name() << "is having a birthday!"; + qWarning() << "They are inviting:"; + for (int ii = 0; ii < party->guestCount(); ++ii) + qWarning() << " " << party->guest(ii)->name(); + } else { + qWarning() << component.errors(); + } + + return 0; +} diff --git a/examples/qml/cppextensions/referenceexamples/methods/methods.pro b/examples/qml/cppextensions/referenceexamples/methods/methods.pro new file mode 100644 index 0000000000..f4c63bfa29 --- /dev/null +++ b/examples/qml/cppextensions/referenceexamples/methods/methods.pro @@ -0,0 +1,13 @@ +QT += qml + +SOURCES += main.cpp \ + person.cpp \ + birthdayparty.cpp +HEADERS += person.h \ + birthdayparty.h +RESOURCES += methods.qrc + +target.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/qml/extending/methods +sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS methods.pro +sources.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/qml/extending/methods +INSTALLS += target sources diff --git a/examples/qml/cppextensions/referenceexamples/methods/methods.qrc b/examples/qml/cppextensions/referenceexamples/methods/methods.qrc new file mode 100644 index 0000000000..e2fa01d5e7 --- /dev/null +++ b/examples/qml/cppextensions/referenceexamples/methods/methods.qrc @@ -0,0 +1,5 @@ + + + example.qml + + diff --git a/examples/qml/cppextensions/referenceexamples/methods/person.cpp b/examples/qml/cppextensions/referenceexamples/methods/person.cpp new file mode 100644 index 0000000000..30d1e46e5a --- /dev/null +++ b/examples/qml/cppextensions/referenceexamples/methods/person.cpp @@ -0,0 +1,66 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include "person.h" + +Person::Person(QObject *parent) +: QObject(parent), m_shoeSize(0) +{ +} + +QString Person::name() const +{ + return m_name; +} + +void Person::setName(const QString &n) +{ + m_name = n; +} + +int Person::shoeSize() const +{ + return m_shoeSize; +} + +void Person::setShoeSize(int s) +{ + m_shoeSize = s; +} + diff --git a/examples/qml/cppextensions/referenceexamples/methods/person.h b/examples/qml/cppextensions/referenceexamples/methods/person.h new file mode 100644 index 0000000000..dd3ad4d188 --- /dev/null +++ b/examples/qml/cppextensions/referenceexamples/methods/person.h @@ -0,0 +1,63 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#ifndef PERSON_H +#define PERSON_H + +#include + +class Person : public QObject +{ + Q_OBJECT + Q_PROPERTY(QString name READ name WRITE setName) + Q_PROPERTY(int shoeSize READ shoeSize WRITE setShoeSize) +public: + Person(QObject *parent = 0); + + QString name() const; + void setName(const QString &); + + int shoeSize() const; + void setShoeSize(int); +private: + QString m_name; + int m_shoeSize; +}; + +#endif // PERSON_H diff --git a/examples/qml/cppextensions/referenceexamples/properties/birthdayparty.cpp b/examples/qml/cppextensions/referenceexamples/properties/birthdayparty.cpp new file mode 100644 index 0000000000..f7280560ab --- /dev/null +++ b/examples/qml/cppextensions/referenceexamples/properties/birthdayparty.cpp @@ -0,0 +1,73 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include "birthdayparty.h" + +BirthdayParty::BirthdayParty(QObject *parent) +: QObject(parent), m_host(0) +{ +} + +// ![0] +Person *BirthdayParty::host() const +{ + return m_host; +} + +void BirthdayParty::setHost(Person *c) +{ + m_host = c; +} + +QQmlListProperty BirthdayParty::guests() +{ + return QQmlListProperty(this, m_guests); +} + +int BirthdayParty::guestCount() const +{ + return m_guests.count(); +} + +Person *BirthdayParty::guest(int index) const +{ + return m_guests.at(index); +} +// ![0] + diff --git a/examples/qml/cppextensions/referenceexamples/properties/birthdayparty.h b/examples/qml/cppextensions/referenceexamples/properties/birthdayparty.h new file mode 100644 index 0000000000..84eefa52ae --- /dev/null +++ b/examples/qml/cppextensions/referenceexamples/properties/birthdayparty.h @@ -0,0 +1,75 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#ifndef BIRTHDAYPARTY_H +#define BIRTHDAYPARTY_H + +#include +#include +#include "person.h" + +// ![0] +class BirthdayParty : public QObject +{ + Q_OBJECT +// ![0] +// ![1] + Q_PROPERTY(Person *host READ host WRITE setHost) +// ![1] +// ![2] + Q_PROPERTY(QQmlListProperty guests READ guests) +// ![2] +// ![3] +public: + BirthdayParty(QObject *parent = 0); + + Person *host() const; + void setHost(Person *); + + QQmlListProperty guests(); + int guestCount() const; + Person *guest(int) const; + +private: + Person *m_host; + QList m_guests; +}; +// ![3] + +#endif // BIRTHDAYPARTY_H diff --git a/examples/qml/cppextensions/referenceexamples/properties/example.qml b/examples/qml/cppextensions/referenceexamples/properties/example.qml new file mode 100644 index 0000000000..36ee952243 --- /dev/null +++ b/examples/qml/cppextensions/referenceexamples/properties/example.qml @@ -0,0 +1,55 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import People 1.0 + +// ![0] +BirthdayParty { + host: Person { + name: "Bob Jones" + shoeSize: 12 + } + guests: [ + Person { name: "Leo Hodges" }, + Person { name: "Jack Smith" }, + Person { name: "Anne Brown" } + ] +} +// ![0] diff --git a/examples/qml/cppextensions/referenceexamples/properties/main.cpp b/examples/qml/cppextensions/referenceexamples/properties/main.cpp new file mode 100644 index 0000000000..cc0de89221 --- /dev/null +++ b/examples/qml/cppextensions/referenceexamples/properties/main.cpp @@ -0,0 +1,70 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include +#include +#include +#include +#include "birthdayparty.h" +#include "person.h" + +int main(int argc, char ** argv) +{ + QCoreApplication app(argc, argv); + +//![register list] + qmlRegisterType("People", 1,0, "BirthdayParty"); + qmlRegisterType("People", 1,0, "Person"); +//![register list] + + QQmlEngine engine; + QQmlComponent component(&engine, QUrl("qrc:example.qml")); + BirthdayParty *party = qobject_cast(component.create()); + + if (party && party->host()) { + qWarning() << party->host()->name() << "is having a birthday!"; + qWarning() << "They are inviting:"; + for (int ii = 0; ii < party->guestCount(); ++ii) + qWarning() << " " << party->guest(ii)->name(); + } else { + qWarning() << component.errors(); + } + + return 0; +} diff --git a/examples/qml/cppextensions/referenceexamples/properties/person.cpp b/examples/qml/cppextensions/referenceexamples/properties/person.cpp new file mode 100644 index 0000000000..30d1e46e5a --- /dev/null +++ b/examples/qml/cppextensions/referenceexamples/properties/person.cpp @@ -0,0 +1,66 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include "person.h" + +Person::Person(QObject *parent) +: QObject(parent), m_shoeSize(0) +{ +} + +QString Person::name() const +{ + return m_name; +} + +void Person::setName(const QString &n) +{ + m_name = n; +} + +int Person::shoeSize() const +{ + return m_shoeSize; +} + +void Person::setShoeSize(int s) +{ + m_shoeSize = s; +} + diff --git a/examples/qml/cppextensions/referenceexamples/properties/person.h b/examples/qml/cppextensions/referenceexamples/properties/person.h new file mode 100644 index 0000000000..dd3ad4d188 --- /dev/null +++ b/examples/qml/cppextensions/referenceexamples/properties/person.h @@ -0,0 +1,63 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#ifndef PERSON_H +#define PERSON_H + +#include + +class Person : public QObject +{ + Q_OBJECT + Q_PROPERTY(QString name READ name WRITE setName) + Q_PROPERTY(int shoeSize READ shoeSize WRITE setShoeSize) +public: + Person(QObject *parent = 0); + + QString name() const; + void setName(const QString &); + + int shoeSize() const; + void setShoeSize(int); +private: + QString m_name; + int m_shoeSize; +}; + +#endif // PERSON_H diff --git a/examples/qml/cppextensions/referenceexamples/properties/properties.pro b/examples/qml/cppextensions/referenceexamples/properties/properties.pro new file mode 100644 index 0000000000..e079b1f79e --- /dev/null +++ b/examples/qml/cppextensions/referenceexamples/properties/properties.pro @@ -0,0 +1,13 @@ +QT += qml + +SOURCES += main.cpp \ + person.cpp \ + birthdayparty.cpp +HEADERS += person.h \ + birthdayparty.h +RESOURCES += properties.qrc + +target.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/qml/extending/properties +sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS properties.pro +sources.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/qml/extending/properties +INSTALLS += target sources diff --git a/examples/qml/cppextensions/referenceexamples/properties/properties.qrc b/examples/qml/cppextensions/referenceexamples/properties/properties.qrc new file mode 100644 index 0000000000..e2fa01d5e7 --- /dev/null +++ b/examples/qml/cppextensions/referenceexamples/properties/properties.qrc @@ -0,0 +1,5 @@ + + + example.qml + + diff --git a/examples/qml/cppextensions/referenceexamples/referenceexamples.pro b/examples/qml/cppextensions/referenceexamples/referenceexamples.pro new file mode 100644 index 0000000000..505cefd331 --- /dev/null +++ b/examples/qml/cppextensions/referenceexamples/referenceexamples.pro @@ -0,0 +1,14 @@ +TEMPLATE = subdirs + +SUBDIRS += \ + adding \ + attached \ + binding \ + coercion \ + default \ + extended \ + grouped \ + properties \ + signal \ + valuesource \ + methods diff --git a/examples/qml/cppextensions/referenceexamples/referenceexamples.qmlproject b/examples/qml/cppextensions/referenceexamples/referenceexamples.qmlproject new file mode 100644 index 0000000000..2bb4016996 --- /dev/null +++ b/examples/qml/cppextensions/referenceexamples/referenceexamples.qmlproject @@ -0,0 +1,14 @@ +import QmlProject 1.0 + +Project { + /* Include .qml, .js, and image files from current directory and subdirectories */ + QmlFiles { + directory: "." + } + JavaScriptFiles { + directory: "." + } + ImageFiles { + directory: "." + } +} diff --git a/examples/qml/cppextensions/referenceexamples/signal/birthdayparty.cpp b/examples/qml/cppextensions/referenceexamples/signal/birthdayparty.cpp new file mode 100644 index 0000000000..078c5f9a2d --- /dev/null +++ b/examples/qml/cppextensions/referenceexamples/signal/birthdayparty.cpp @@ -0,0 +1,98 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include "birthdayparty.h" + +BirthdayPartyAttached::BirthdayPartyAttached(QObject *object) +: QObject(object) +{ +} + +QDate BirthdayPartyAttached::rsvp() const +{ + return m_rsvp; +} + +void BirthdayPartyAttached::setRsvp(const QDate &d) +{ + m_rsvp = d; +} + + +BirthdayParty::BirthdayParty(QObject *parent) +: QObject(parent), m_host(0) +{ +} + +Person *BirthdayParty::host() const +{ + return m_host; +} + +void BirthdayParty::setHost(Person *c) +{ + m_host = c; +} + +QQmlListProperty BirthdayParty::guests() +{ + return QQmlListProperty(this, m_guests); +} + +int BirthdayParty::guestCount() const +{ + return m_guests.count(); +} + +Person *BirthdayParty::guest(int index) const +{ + return m_guests.at(index); +} + +void BirthdayParty::startParty() +{ + QTime time = QTime::currentTime(); + emit partyStarted(time); +} + +BirthdayPartyAttached *BirthdayParty::qmlAttachedProperties(QObject *object) +{ + return new BirthdayPartyAttached(object); +} + diff --git a/examples/qml/cppextensions/referenceexamples/signal/birthdayparty.h b/examples/qml/cppextensions/referenceexamples/signal/birthdayparty.h new file mode 100644 index 0000000000..3f1b020b5a --- /dev/null +++ b/examples/qml/cppextensions/referenceexamples/signal/birthdayparty.h @@ -0,0 +1,92 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#ifndef BIRTHDAYPARTY_H +#define BIRTHDAYPARTY_H + +#include +#include +#include +#include "person.h" + +class BirthdayPartyAttached : public QObject +{ + Q_OBJECT + Q_PROPERTY(QDate rsvp READ rsvp WRITE setRsvp) +public: + BirthdayPartyAttached(QObject *object); + + QDate rsvp() const; + void setRsvp(const QDate &); + +private: + QDate m_rsvp; +}; + +class BirthdayParty : public QObject +{ + Q_OBJECT + Q_PROPERTY(Person *host READ host WRITE setHost) + Q_PROPERTY(QQmlListProperty guests READ guests) + Q_CLASSINFO("DefaultProperty", "guests") +public: + BirthdayParty(QObject *parent = 0); + + Person *host() const; + void setHost(Person *); + + QQmlListProperty guests(); + int guestCount() const; + Person *guest(int) const; + + static BirthdayPartyAttached *qmlAttachedProperties(QObject *); + + void startParty(); +// ![0] +signals: + void partyStarted(const QTime &time); +// ![0] + +private: + Person *m_host; + QList m_guests; +}; +QML_DECLARE_TYPEINFO(BirthdayParty, QML_HAS_ATTACHED_PROPERTIES) + +#endif // BIRTHDAYPARTY_H diff --git a/examples/qml/cppextensions/referenceexamples/signal/example.qml b/examples/qml/cppextensions/referenceexamples/signal/example.qml new file mode 100644 index 0000000000..796c2f32a1 --- /dev/null +++ b/examples/qml/cppextensions/referenceexamples/signal/example.qml @@ -0,0 +1,72 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import People 1.0 + +BirthdayParty { +// ![0] + onPartyStarted: console.log("This party started rockin' at " + time); +// ![0] + + host: Boy { + name: "Bob Jones" + shoe { size: 12; color: "white"; brand: "Nike"; price: 90.0 } + } + + Boy { + name: "Leo Hodges" + BirthdayParty.rsvp: "2009-07-06" + shoe { size: 10; color: "black"; brand: "Reebok"; price: 59.95 } + } + Boy { + name: "Jack Smith" + shoe { size: 8; color: "blue"; brand: "Puma"; price: 19.95 } + } + Girl { + name: "Anne Brown" + BirthdayParty.rsvp: "2009-07-01" + shoe.size: 7 + shoe.color: "red" + shoe.brand: "Marc Jacobs" + shoe.price: 699.99 + } +// ![1] +} +// ![1] diff --git a/examples/qml/cppextensions/referenceexamples/signal/main.cpp b/examples/qml/cppextensions/referenceexamples/signal/main.cpp new file mode 100644 index 0000000000..21a26d9b67 --- /dev/null +++ b/examples/qml/cppextensions/referenceexamples/signal/main.cpp @@ -0,0 +1,91 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include +#include +#include +#include +#include "birthdayparty.h" +#include "person.h" + +int main(int argc, char ** argv) +{ + QCoreApplication app(argc, argv); + + qmlRegisterType(); + qmlRegisterType("People", 1,0, "BirthdayParty"); + qmlRegisterType(); + qmlRegisterType(); + qmlRegisterType("People", 1,0, "Boy"); + qmlRegisterType("People", 1,0, "Girl"); + + QQmlEngine engine; + QQmlComponent component(&engine, QUrl("qrc:example.qml")); + BirthdayParty *party = qobject_cast(component.create()); + + if (party && party->host()) { + qWarning() << party->host()->name() << "is having a birthday!"; + + if (qobject_cast(party->host())) + qWarning() << "He is inviting:"; + else + qWarning() << "She is inviting:"; + + for (int ii = 0; ii < party->guestCount(); ++ii) { + Person *guest = party->guest(ii); + + QDate rsvpDate; + QObject *attached = + qmlAttachedPropertiesObject(guest, false); + if (attached) + rsvpDate = attached->property("rsvp").toDate(); + + if (rsvpDate.isNull()) + qWarning() << " " << guest->name() << "RSVP date: Hasn't RSVP'd"; + else + qWarning() << " " << guest->name() << "RSVP date:" << qPrintable(rsvpDate.toString()); + } + + party->startParty(); + } else { + qWarning() << component.errors(); + } + + return 0; +} diff --git a/examples/qml/cppextensions/referenceexamples/signal/person.cpp b/examples/qml/cppextensions/referenceexamples/signal/person.cpp new file mode 100644 index 0000000000..7afcdc6ca6 --- /dev/null +++ b/examples/qml/cppextensions/referenceexamples/signal/person.cpp @@ -0,0 +1,118 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include "person.h" + +ShoeDescription::ShoeDescription(QObject *parent) +: QObject(parent), m_size(0), m_price(0) +{ +} + +int ShoeDescription::size() const +{ + return m_size; +} + +void ShoeDescription::setSize(int s) +{ + m_size = s; +} + +QColor ShoeDescription::color() const +{ + return m_color; +} + +void ShoeDescription::setColor(const QColor &c) +{ + m_color = c; +} + +QString ShoeDescription::brand() const +{ + return m_brand; +} + +void ShoeDescription::setBrand(const QString &b) +{ + m_brand = b; +} + +qreal ShoeDescription::price() const +{ + return m_price; +} + +void ShoeDescription::setPrice(qreal p) +{ + m_price = p; +} + +Person::Person(QObject *parent) +: QObject(parent) +{ +} + +QString Person::name() const +{ + return m_name; +} + +void Person::setName(const QString &n) +{ + m_name = n; +} + +ShoeDescription *Person::shoe() +{ + return &m_shoe; +} + + +Boy::Boy(QObject * parent) +: Person(parent) +{ +} + + +Girl::Girl(QObject * parent) +: Person(parent) +{ +} + diff --git a/examples/qml/cppextensions/referenceexamples/signal/person.h b/examples/qml/cppextensions/referenceexamples/signal/person.h new file mode 100644 index 0000000000..032eca3c17 --- /dev/null +++ b/examples/qml/cppextensions/referenceexamples/signal/person.h @@ -0,0 +1,105 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#ifndef PERSON_H +#define PERSON_H + +#include +#include + +class ShoeDescription : public QObject +{ + Q_OBJECT + Q_PROPERTY(int size READ size WRITE setSize) + Q_PROPERTY(QColor color READ color WRITE setColor) + Q_PROPERTY(QString brand READ brand WRITE setBrand) + Q_PROPERTY(qreal price READ price WRITE setPrice) +public: + ShoeDescription(QObject *parent = 0); + + int size() const; + void setSize(int); + + QColor color() const; + void setColor(const QColor &); + + QString brand() const; + void setBrand(const QString &); + + qreal price() const; + void setPrice(qreal); +private: + int m_size; + QColor m_color; + QString m_brand; + qreal m_price; +}; + +class Person : public QObject +{ + Q_OBJECT + Q_PROPERTY(QString name READ name WRITE setName) + Q_PROPERTY(ShoeDescription *shoe READ shoe) +public: + Person(QObject *parent = 0); + + QString name() const; + void setName(const QString &); + + ShoeDescription *shoe(); +private: + QString m_name; + ShoeDescription m_shoe; +}; + +class Boy : public Person +{ + Q_OBJECT +public: + Boy(QObject * parent = 0); +}; + +class Girl : public Person +{ + Q_OBJECT +public: + Girl(QObject * parent = 0); +}; + +#endif // PERSON_H diff --git a/examples/qml/cppextensions/referenceexamples/signal/signal.pro b/examples/qml/cppextensions/referenceexamples/signal/signal.pro new file mode 100644 index 0000000000..d426e398a5 --- /dev/null +++ b/examples/qml/cppextensions/referenceexamples/signal/signal.pro @@ -0,0 +1,13 @@ +QT += qml + +SOURCES += main.cpp \ + person.cpp \ + birthdayparty.cpp +HEADERS += person.h \ + birthdayparty.h +RESOURCES += signal.qrc + +target.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/qml/extending/signal +sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS signal.pro +sources.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/qml/extending/signal +INSTALLS += target sources diff --git a/examples/qml/cppextensions/referenceexamples/signal/signal.qrc b/examples/qml/cppextensions/referenceexamples/signal/signal.qrc new file mode 100644 index 0000000000..e2fa01d5e7 --- /dev/null +++ b/examples/qml/cppextensions/referenceexamples/signal/signal.qrc @@ -0,0 +1,5 @@ + + + example.qml + + diff --git a/examples/qml/cppextensions/referenceexamples/valuesource/birthdayparty.cpp b/examples/qml/cppextensions/referenceexamples/valuesource/birthdayparty.cpp new file mode 100644 index 0000000000..a69a58557e --- /dev/null +++ b/examples/qml/cppextensions/referenceexamples/valuesource/birthdayparty.cpp @@ -0,0 +1,108 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include "birthdayparty.h" + +BirthdayPartyAttached::BirthdayPartyAttached(QObject *object) +: QObject(object) +{ +} + +QDate BirthdayPartyAttached::rsvp() const +{ + return m_rsvp; +} + +void BirthdayPartyAttached::setRsvp(const QDate &d) +{ + m_rsvp = d; +} + + +BirthdayParty::BirthdayParty(QObject *parent) +: QObject(parent), m_host(0) +{ +} + +Person *BirthdayParty::host() const +{ + return m_host; +} + +void BirthdayParty::setHost(Person *c) +{ + m_host = c; +} + +QQmlListProperty BirthdayParty::guests() +{ + return QQmlListProperty(this, m_guests); +} + +int BirthdayParty::guestCount() const +{ + return m_guests.count(); +} + +Person *BirthdayParty::guest(int index) const +{ + return m_guests.at(index); +} + +void BirthdayParty::startParty() +{ + QTime time = QTime::currentTime(); + emit partyStarted(time); +} + +QString BirthdayParty::announcement() const +{ + return QString(); +} + +void BirthdayParty::setAnnouncement(const QString &speak) +{ + qWarning() << qPrintable(speak); +} + +BirthdayPartyAttached *BirthdayParty::qmlAttachedProperties(QObject *object) +{ + return new BirthdayPartyAttached(object); +} + diff --git a/examples/qml/cppextensions/referenceexamples/valuesource/birthdayparty.h b/examples/qml/cppextensions/referenceexamples/valuesource/birthdayparty.h new file mode 100644 index 0000000000..f3635e899b --- /dev/null +++ b/examples/qml/cppextensions/referenceexamples/valuesource/birthdayparty.h @@ -0,0 +1,97 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#ifndef BIRTHDAYPARTY_H +#define BIRTHDAYPARTY_H + +#include +#include +#include +#include +#include "person.h" + +class BirthdayPartyAttached : public QObject +{ + Q_OBJECT + Q_PROPERTY(QDate rsvp READ rsvp WRITE setRsvp) +public: + BirthdayPartyAttached(QObject *object); + + QDate rsvp() const; + void setRsvp(const QDate &); + +private: + QDate m_rsvp; +}; + +class BirthdayParty : public QObject +{ + Q_OBJECT + Q_PROPERTY(Person *host READ host WRITE setHost) + Q_PROPERTY(QQmlListProperty guests READ guests) +// ![0] + Q_PROPERTY(QString announcement READ announcement WRITE setAnnouncement) +// ![0] + Q_CLASSINFO("DefaultProperty", "guests") +public: + BirthdayParty(QObject *parent = 0); + + Person *host() const; + void setHost(Person *); + + QQmlListProperty guests(); + int guestCount() const; + Person *guest(int) const; + + QString announcement() const; + void setAnnouncement(const QString &); + + static BirthdayPartyAttached *qmlAttachedProperties(QObject *); + + void startParty(); +signals: + void partyStarted(const QTime &time); + +private: + Person *m_host; + QList m_guests; +}; +QML_DECLARE_TYPEINFO(BirthdayParty, QML_HAS_ATTACHED_PROPERTIES) + +#endif // BIRTHDAYPARTY_H diff --git a/examples/qml/cppextensions/referenceexamples/valuesource/example.qml b/examples/qml/cppextensions/referenceexamples/valuesource/example.qml new file mode 100644 index 0000000000..04c3048e9e --- /dev/null +++ b/examples/qml/cppextensions/referenceexamples/valuesource/example.qml @@ -0,0 +1,76 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import People 1.0 + +// ![0] +BirthdayParty { + HappyBirthdaySong on announcement { name: "Bob Jones" } +// ![0] + + onPartyStarted: console.log("This party started rockin' at " + time); + + + host: Boy { + name: "Bob Jones" + shoe { size: 12; color: "white"; brand: "Nike"; price: 90.0 } + } + + Boy { + name: "Leo Hodges" + BirthdayParty.rsvp: "2009-07-06" + shoe { size: 10; color: "black"; brand: "Reebok"; price: 59.95 } + } + Boy { + name: "Jack Smith" + shoe { size: 8; color: "blue"; brand: "Puma"; price: 19.95 } + } + Girl { + name: "Anne Brown" + BirthdayParty.rsvp: "2009-07-01" + shoe.size: 7 + shoe.color: "red" + shoe.brand: "Marc Jacobs" + shoe.price: 699.99 + } + +// ![1] +} +// ![1] diff --git a/examples/qml/cppextensions/referenceexamples/valuesource/happybirthdaysong.cpp b/examples/qml/cppextensions/referenceexamples/valuesource/happybirthdaysong.cpp new file mode 100644 index 0000000000..d69154b57a --- /dev/null +++ b/examples/qml/cppextensions/referenceexamples/valuesource/happybirthdaysong.cpp @@ -0,0 +1,80 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include "happybirthdaysong.h" +#include + +HappyBirthdaySong::HappyBirthdaySong(QObject *parent) +: QObject(parent), m_line(-1) +{ + setName(QString()); + QTimer *timer = new QTimer(this); + QObject::connect(timer, SIGNAL(timeout()), this, SLOT(advance())); + timer->start(1000); +} + +void HappyBirthdaySong::setTarget(const QQmlProperty &p) +{ + m_target = p; +} + +QString HappyBirthdaySong::name() const +{ + return m_name; +} + +void HappyBirthdaySong::setName(const QString &name) +{ + m_name = name; + + m_lyrics.clear(); + m_lyrics << "Happy birthday to you,"; + m_lyrics << "Happy birthday to you,"; + m_lyrics << "Happy birthday dear " + m_name + ","; + m_lyrics << "Happy birthday to you!"; + m_lyrics << ""; +} + +void HappyBirthdaySong::advance() +{ + m_line = (m_line + 1) % m_lyrics.count(); + + m_target.write(m_lyrics.at(m_line)); +} + diff --git a/examples/qml/cppextensions/referenceexamples/valuesource/happybirthdaysong.h b/examples/qml/cppextensions/referenceexamples/valuesource/happybirthdaysong.h new file mode 100644 index 0000000000..19e47c28ac --- /dev/null +++ b/examples/qml/cppextensions/referenceexamples/valuesource/happybirthdaysong.h @@ -0,0 +1,79 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#ifndef HAPPYBIRTHDAYSONG_H +#define HAPPYBIRTHDAYSONG_H + +#include +#include +#include + +#include + +// ![0] +class HappyBirthdaySong : public QObject, public QQmlPropertyValueSource +{ + Q_OBJECT + Q_INTERFACES(QQmlPropertyValueSource) +// ![0] + Q_PROPERTY(QString name READ name WRITE setName) +// ![1] +public: + HappyBirthdaySong(QObject *parent = 0); + + virtual void setTarget(const QQmlProperty &); +// ![1] + + QString name() const; + void setName(const QString &); + +private slots: + void advance(); + +private: + int m_line; + QStringList m_lyrics; + QQmlProperty m_target; + QString m_name; +// ![2] +}; +// ![2] + +#endif // HAPPYBIRTHDAYSONG_H + diff --git a/examples/qml/cppextensions/referenceexamples/valuesource/main.cpp b/examples/qml/cppextensions/referenceexamples/valuesource/main.cpp new file mode 100644 index 0000000000..e119e719af --- /dev/null +++ b/examples/qml/cppextensions/referenceexamples/valuesource/main.cpp @@ -0,0 +1,93 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include +#include +#include +#include +#include "birthdayparty.h" +#include "happybirthdaysong.h" +#include "person.h" + +int main(int argc, char ** argv) +{ + QCoreApplication app(argc, argv); + + qmlRegisterType(); + qmlRegisterType("People", 1,0, "BirthdayParty"); + qmlRegisterType("People", 1,0, "HappyBirthdaySong"); + qmlRegisterType(); + qmlRegisterType(); + qmlRegisterType("People", 1,0, "Boy"); + qmlRegisterType("People", 1,0, "Girl"); + + QQmlEngine engine; + QQmlComponent component(&engine, QUrl("qrc:example.qml")); + BirthdayParty *party = qobject_cast(component.create()); + + if (party && party->host()) { + qWarning() << party->host()->name() << "is having a birthday!"; + + if (qobject_cast(party->host())) + qWarning() << "He is inviting:"; + else + qWarning() << "She is inviting:"; + + for (int ii = 0; ii < party->guestCount(); ++ii) { + Person *guest = party->guest(ii); + + QDate rsvpDate; + QObject *attached = + qmlAttachedPropertiesObject(guest, false); + if (attached) + rsvpDate = attached->property("rsvp").toDate(); + + if (rsvpDate.isNull()) + qWarning() << " " << guest->name() << "RSVP date: Hasn't RSVP'd"; + else + qWarning() << " " << guest->name() << "RSVP date:" << qPrintable(rsvpDate.toString()); + } + + party->startParty(); + } else { + qWarning() << component.errors(); + } + + return app.exec(); +} diff --git a/examples/qml/cppextensions/referenceexamples/valuesource/person.cpp b/examples/qml/cppextensions/referenceexamples/valuesource/person.cpp new file mode 100644 index 0000000000..7afcdc6ca6 --- /dev/null +++ b/examples/qml/cppextensions/referenceexamples/valuesource/person.cpp @@ -0,0 +1,118 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include "person.h" + +ShoeDescription::ShoeDescription(QObject *parent) +: QObject(parent), m_size(0), m_price(0) +{ +} + +int ShoeDescription::size() const +{ + return m_size; +} + +void ShoeDescription::setSize(int s) +{ + m_size = s; +} + +QColor ShoeDescription::color() const +{ + return m_color; +} + +void ShoeDescription::setColor(const QColor &c) +{ + m_color = c; +} + +QString ShoeDescription::brand() const +{ + return m_brand; +} + +void ShoeDescription::setBrand(const QString &b) +{ + m_brand = b; +} + +qreal ShoeDescription::price() const +{ + return m_price; +} + +void ShoeDescription::setPrice(qreal p) +{ + m_price = p; +} + +Person::Person(QObject *parent) +: QObject(parent) +{ +} + +QString Person::name() const +{ + return m_name; +} + +void Person::setName(const QString &n) +{ + m_name = n; +} + +ShoeDescription *Person::shoe() +{ + return &m_shoe; +} + + +Boy::Boy(QObject * parent) +: Person(parent) +{ +} + + +Girl::Girl(QObject * parent) +: Person(parent) +{ +} + diff --git a/examples/qml/cppextensions/referenceexamples/valuesource/person.h b/examples/qml/cppextensions/referenceexamples/valuesource/person.h new file mode 100644 index 0000000000..032eca3c17 --- /dev/null +++ b/examples/qml/cppextensions/referenceexamples/valuesource/person.h @@ -0,0 +1,105 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#ifndef PERSON_H +#define PERSON_H + +#include +#include + +class ShoeDescription : public QObject +{ + Q_OBJECT + Q_PROPERTY(int size READ size WRITE setSize) + Q_PROPERTY(QColor color READ color WRITE setColor) + Q_PROPERTY(QString brand READ brand WRITE setBrand) + Q_PROPERTY(qreal price READ price WRITE setPrice) +public: + ShoeDescription(QObject *parent = 0); + + int size() const; + void setSize(int); + + QColor color() const; + void setColor(const QColor &); + + QString brand() const; + void setBrand(const QString &); + + qreal price() const; + void setPrice(qreal); +private: + int m_size; + QColor m_color; + QString m_brand; + qreal m_price; +}; + +class Person : public QObject +{ + Q_OBJECT + Q_PROPERTY(QString name READ name WRITE setName) + Q_PROPERTY(ShoeDescription *shoe READ shoe) +public: + Person(QObject *parent = 0); + + QString name() const; + void setName(const QString &); + + ShoeDescription *shoe(); +private: + QString m_name; + ShoeDescription m_shoe; +}; + +class Boy : public Person +{ + Q_OBJECT +public: + Boy(QObject * parent = 0); +}; + +class Girl : public Person +{ + Q_OBJECT +public: + Girl(QObject * parent = 0); +}; + +#endif // PERSON_H diff --git a/examples/qml/cppextensions/referenceexamples/valuesource/valuesource.pro b/examples/qml/cppextensions/referenceexamples/valuesource/valuesource.pro new file mode 100644 index 0000000000..afc1784d71 --- /dev/null +++ b/examples/qml/cppextensions/referenceexamples/valuesource/valuesource.pro @@ -0,0 +1,15 @@ +QT += qml + +SOURCES += main.cpp \ + person.cpp \ + birthdayparty.cpp \ + happybirthdaysong.cpp +HEADERS += person.h \ + birthdayparty.h \ + happybirthdaysong.h +RESOURCES += valuesource.qrc + +target.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/qml/extending/valuesource +sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS valuesource.pro +sources.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/qml/extending/valuesource +INSTALLS += target sources diff --git a/examples/qml/cppextensions/referenceexamples/valuesource/valuesource.qrc b/examples/qml/cppextensions/referenceexamples/valuesource/valuesource.qrc new file mode 100644 index 0000000000..e2fa01d5e7 --- /dev/null +++ b/examples/qml/cppextensions/referenceexamples/valuesource/valuesource.qrc @@ -0,0 +1,5 @@ + + + example.qml + + diff --git a/examples/qml/draganddrop/dragtarget.qmlproject b/examples/qml/draganddrop/dragtarget.qmlproject new file mode 100644 index 0000000000..2bb4016996 --- /dev/null +++ b/examples/qml/draganddrop/dragtarget.qmlproject @@ -0,0 +1,14 @@ +import QmlProject 1.0 + +Project { + /* Include .qml, .js, and image files from current directory and subdirectories */ + QmlFiles { + directory: "." + } + JavaScriptFiles { + directory: "." + } + ImageFiles { + directory: "." + } +} diff --git a/examples/qml/draganddrop/tiles/DragTile.qml b/examples/qml/draganddrop/tiles/DragTile.qml new file mode 100644 index 0000000000..2813fa8caf --- /dev/null +++ b/examples/qml/draganddrop/tiles/DragTile.qml @@ -0,0 +1,89 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Item { + id: root + property string colorKey + + width: 100; height: 100 + + MouseArea { + id: mouseArea + + width: 100; height: 100 + anchors.centerIn: parent + + drag.target: tile + + onReleased: parent = tile.Drag.target !== null ? tile.Drag.target : root + + Rectangle { + id: tile + + width: 100; height: 100 + + anchors.horizontalCenter: parent.horizontalCenter; anchors.verticalCenter: parent.verticalCenter + color: colorKey + + Drag.keys: [ colorKey ] + Drag.active: mouseArea.drag.active + Drag.hotSpot.x: 50 + Drag.hotSpot.y: 50 + + Text { + anchors.fill: parent + color: "white" + font.pixelSize: 90 + text: modelData + 1 + horizontalAlignment:Text.AlignHCenter + verticalAlignment: Text.AlignVCenter + } + + states: State { + when: mouseArea.drag.active + ParentChange { target: tile; parent: root } + AnchorChanges { target: tile; anchors.verticalCenter: undefined; anchors.horizontalCenter: undefined } + } + } + } +} + diff --git a/examples/qml/draganddrop/tiles/DropTile.qml b/examples/qml/draganddrop/tiles/DropTile.qml new file mode 100644 index 0000000000..e8566f04cc --- /dev/null +++ b/examples/qml/draganddrop/tiles/DropTile.qml @@ -0,0 +1,68 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +DropArea { + id: dragTarget + + property string colorKey + property alias dropProxy: dragTarget + + width: 100; height: 100 + keys: [ colorKey ] + + Rectangle { + id: dropRectangle + + anchors.fill: parent + color: colorKey + + states: [ + State { + when: dragTarget.containsDrag + PropertyChanges { + target: dropRectangle + color: "grey" + } + } + ] + } +} diff --git a/examples/qml/draganddrop/tiles/tiles.qml b/examples/qml/draganddrop/tiles/tiles.qml new file mode 100644 index 0000000000..31c87f8244 --- /dev/null +++ b/examples/qml/draganddrop/tiles/tiles.qml @@ -0,0 +1,109 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Rectangle { + id: root + + width: 620 + height: 410 + + color: "black" + + Grid { + id: redDestination + + anchors.left: redSource.right; anchors.top: parent.top; + anchors.margins: 5 + width: 300 + height: 300 + opacity: 0.5 + columns: 3 + + Repeater { + model: 9; + delegate: DropTile { colorKey: "red" } + } + } + + Grid { + anchors.right: blueSource.left; anchors.bottom: parent.bottom; + anchors.margins: 5 + width: 300 + height: 300 + + opacity: 0.5 + + columns: 3 + + Repeater { + model: 9 + delegate: DropTile { colorKey: "blue" } + } + } + + Column { + id: redSource + + anchors.left: parent.left; anchors.top: parent.top; anchors.bottom: parent.bottom + anchors.margins: 5 + width: 100 + spacing: -60 + + Repeater { + model: 9 + delegate: DragTile { colorKey: "red" } + } + } + Column { + id: blueSource + + anchors.right: parent.right; anchors.top: parent.top; anchors.bottom: parent.bottom + anchors.margins: 5 + width: 100 + spacing: -60 + + Repeater { + model: 9 + delegate: DragTile { colorKey: "blue" } + } + } +} diff --git a/examples/qml/draganddrop/views/gridview.qml b/examples/qml/draganddrop/views/gridview.qml new file mode 100644 index 0000000000..375f3d2824 --- /dev/null +++ b/examples/qml/draganddrop/views/gridview.qml @@ -0,0 +1,117 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +GridView { + id: root + width: 360; height: 360 + cellWidth: 90; cellHeight: 90 + + model: VisualDataModel { + id: visualModel + model: ListModel { + id: colorModel + ListElement { color: "blue" } + ListElement { color: "green" } + ListElement { color: "red" } + ListElement { color: "yellow" } + ListElement { color: "orange" } + ListElement { color: "purple" } + ListElement { color: "cyan" } + ListElement { color: "magenta" } + ListElement { color: "chartreuse" } + ListElement { color: "aquamarine" } + ListElement { color: "indigo" } + ListElement { color: "black" } + ListElement { color: "chartreuse" } + ListElement { color: "violet" } + ListElement { color: "grey" } + ListElement { color: "springgreen" } + } + + delegate: MouseArea { + id: delegateRoot + + property int visualIndex: VisualDataModel.itemsIndex + + width: 90; height: 90 + drag.target: icon + + Rectangle { + id: icon + width: 80; height: 80 + anchors { + horizontalCenter: parent.horizontalCenter; + verticalCenter: parent.verticalCenter + } + color: model.color + radius: 3 + + Drag.active: delegateRoot.pressed + Drag.source: delegateRoot + Drag.hotSpot.x: 40 + Drag.hotSpot.y: 40 + + states: [ + State { + when: icon.Drag.active + ParentChange { + target: icon + parent: root + } + + AnchorChanges { + target: icon; + anchors.horizontalCenter: undefined; + anchors.verticalCenter: undefined + } + } + ] + } + + DropArea { + anchors { fill: parent; margins: 15 } + + onEntered: visualModel.items.move(drag.source.visualIndex, delegateRoot.visualIndex) + } + } + } +} diff --git a/examples/qml/flickr/content/Button.qml b/examples/qml/flickr/content/Button.qml new file mode 100644 index 0000000000..57f846aec3 --- /dev/null +++ b/examples/qml/flickr/content/Button.qml @@ -0,0 +1,79 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtQml module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Item { + id: container + + signal clicked + + property string text + + BorderImage { + id: buttonImage + source: "images/toolbutton.sci" + width: container.width; height: container.height + } + BorderImage { + id: pressed + opacity: 0 + source: "images/toolbutton.sci" + width: container.width; height: container.height + } + MouseArea { + id: mouseRegion + anchors.fill: buttonImage + onClicked: { container.clicked(); } + } + Text { + color: "white" + anchors.centerIn: buttonImage; font.bold: true; font.pixelSize: 15 + text: container.text; style: Text.Raised; styleColor: "black" + } + states: [ + State { + name: "Pressed" + when: mouseRegion.pressed == true + PropertyChanges { target: pressed; opacity: 1 } + } + ] +} diff --git a/examples/qml/flickr/content/GridDelegate.qml b/examples/qml/flickr/content/GridDelegate.qml new file mode 100644 index 0000000000..f8838bd609 --- /dev/null +++ b/examples/qml/flickr/content/GridDelegate.qml @@ -0,0 +1,111 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtQml module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Item { + id: wrapper; width: GridView.view.cellWidth; height: GridView.view.cellHeight + + function photoClicked() { + imageDetails.photoTitle = title; + imageDetails.photoTags = tags; + imageDetails.photoWidth = photoWidth; + imageDetails.photoHeight = photoHeight; + imageDetails.photoType = photoType; + imageDetails.photoAuthor = photoAuthor; + imageDetails.photoDate = photoDate; + imageDetails.photoUrl = url; + imageDetails.rating = 0; + scaleMe.state = "Details"; + } + + Item { + anchors.centerIn: parent + scale: 0.0 + Behavior on scale { NumberAnimation { easing.type: Easing.InOutQuad} } + id: scaleMe + + Item { + width: 77; height: 77; anchors.centerIn: parent + Rectangle { + id: whiteRect; width: 77; height: 77; color: "#dddddd"; smooth: true + Image { id: thumb; source: imagePath; x: 1; y: 1; smooth: true } + Image { source: "images/gloss.png" } + } + } + + Connections { + target: toolBar + onButton2Clicked: if (scaleMe.state == 'Details' ) scaleMe.state = 'Show' + } + + states: [ + State { + name: "Show"; when: thumb.status == Image.Ready + PropertyChanges { target: scaleMe; scale: 1 } + }, + State { + name: "Details" + PropertyChanges { target: scaleMe; scale: 1 } + ParentChange { target: whiteRect; x: 10; y: 20; parent: imageDetails.frontContainer } + PropertyChanges { target: background; state: "DetailedView" } + } + ] + transitions: [ + Transition { + from: "Show"; to: "Details" + ParentAnimation { + via: foreground + NumberAnimation { properties: "x,y"; duration: 500; easing.type: Easing.InOutQuad } + } + }, + Transition { + from: "Details"; to: "Show" + ParentAnimation { + via: foreground + NumberAnimation { properties: "x,y"; duration: 500; easing.type: Easing.InOutQuad } + } + } + ] + } + MouseArea { anchors.fill: wrapper; onClicked: photoClicked() } +} + diff --git a/examples/qml/flickr/content/ImageDetails.qml b/examples/qml/flickr/content/ImageDetails.qml new file mode 100644 index 0000000000..42b5e845ea --- /dev/null +++ b/examples/qml/flickr/content/ImageDetails.qml @@ -0,0 +1,323 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtQml module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import QtQuick.Particles 2.0 + +Flipable { + id: container + + property alias frontContainer: containerFront + property string photoTitle: "" + property string photoTags: "" + property int photoWidth + property int photoHeight + property string photoType + property string photoAuthor + property string photoDate + property string photoUrl + property int rating: 2 + property variant prevScale: 1.0 + + property int flipDuration: 1600 + + signal closed + + transform: Rotation { + id: itemRotation + origin.x: container.width / 2; + axis.y: 1; axis.z: 0 + } + + front: Item { + id: containerFront; anchors.fill: container + + Rectangle { + anchors.fill: parent + color: "black"; opacity: 0.4 + } + + Column { + spacing: 10 + anchors { + left: parent.left; leftMargin: 10 + right: parent.right; rightMargin: 10 + top: parent.top; topMargin: 120 + } + Text { font.bold: true; color: "white"; elide: Text.ElideRight; text: container.photoTitle; width: parent.width } + Text { color: "white"; elide: Text.ElideRight; text: "Size: " + container.photoWidth + 'x' + container.photoHeight; width: parent.width } + Text { color: "white"; elide: Text.ElideRight; text: "Type: " + container.photoType; width: parent.width } + Text { color: "white"; elide: Text.ElideRight; text: "Author: " + container.photoAuthor; width: parent.width } + Text { color: "white"; elide: Text.ElideRight; text: "Published: " + container.photoDate; width: parent.width } + Text { color: "white"; elide: Text.ElideRight; text: container.photoTags == "" ? "" : "Tags: "; width: parent.width } + Text { color: "white"; elide: Text.ElideRight; text: container.photoTags; width: parent.width } + } + } + + back: Item { + anchors.fill: container + + Rectangle { anchors.fill: parent; color: "black"; opacity: 0.4 } + + Progress { + anchors.centerIn: parent; width: 200; height: 22 + progress: bigImage.progress; visible: bigImage.status != Image.Ready + } + + Flickable { + id: flickable; anchors.fill: parent; clip: true + contentWidth: imageContainer.width; contentHeight: imageContainer.height + + function updateMinimumScale() { + if (bigImage.status == Image.Ready && bigImage.width != 0) { + slider.minimum = Math.min(flickable.width / bigImage.width, flickable.height / bigImage.height); + if (bigImage.width * slider.value > flickable.width) { + var xoff = (flickable.width/2 + flickable.contentX) * slider.value / prevScale; + flickable.contentX = xoff - flickable.width/2; + } + if (bigImage.height * slider.value > flickable.height) { + var yoff = (flickable.height/2 + flickable.contentY) * slider.value / prevScale; + flickable.contentY = yoff - flickable.height/2; + } + prevScale = slider.value; + } + } + + onWidthChanged: updateMinimumScale() + onHeightChanged: updateMinimumScale() + + Item { + id: imageContainer + width: Math.max(bigImage.width * bigImage.scale, flickable.width); + height: Math.max(bigImage.height * bigImage.scale, flickable.height); + Image { + id: bigImage; source: container.photoUrl; scale: slider.value + anchors.centerIn: parent; smooth: !flickable.movingVertically + onStatusChanged : { + // Default scale shows the entire image. + if (bigImage.status == Image.Ready && bigImage.width != 0) { + slider.minimum = Math.min(flickable.width / bigImage.width, flickable.height / bigImage.height); + prevScale = Math.min(slider.minimum, 1); + slider.value = prevScale; + } + if (inBackState && bigImage.status == Image.Ready) + effectBox.imageInAnim(); + } + property bool inBackState: false + onInBackStateChanged:{ + if(inBackState && bigImage.status == Image.Ready) + effectBox.imageInAnim(); + else if (!inBackState && bigImage.status == Image.Ready) + effectBox.imageOutAnim(); + } + } + ShaderEffectSource{ + id: pictureSource + sourceItem: bigImage + smooth: true + //Workaround: Doesn't work below lines + width: bigImage.width + height: bigImage.width + visible: false + } + Turbulence{//only fill visible rect + id: turbulence + system: imageSystem + anchors.fill: parent + strength: 240 + enabled: false + } + + Item{ + id: effectBox + width: bigImage.width * bigImage.scale + height: bigImage.height * bigImage.scale + anchors.centerIn: parent + function imageInAnim(){ + bigImage.visible = false; + noiseIn.visible = true; + endEffectTimer.start(); + } + function imageOutAnim(){ + bigImage.visible = false; + noiseIn.visible = false; + turbulence.enabled = true; + endEffectTimer.start(); + pixelEmitter.burst(2048); + } + Timer{ + id: endEffectTimer + interval: flipDuration + repeat: false + running: false + onTriggered:{ + turbulence.enabled = false; + noiseIn.visible = false; + bigImage.visible = true; + } + } + ShaderEffect{ + id: noiseIn + anchors.fill: parent + property real t: 0 + visible: false + onVisibleChanged: tAnim.start() + NumberAnimation{ + id: tAnim + target: noiseIn + property: "t" + from: 0.0 + to: 1.0 + duration: flipDuration + } + property variant source: pictureSource + property variant noise: ShaderEffectSource{ + sourceItem:Image{ + source: "images/noise.png" + } + hideSource: true + smooth: false + } + fragmentShader:" + uniform sampler2D noise; + uniform sampler2D source; + uniform highp float t; + uniform lowp float qt_Opacity; + varying highp vec2 qt_TexCoord0; + void main(){ + //Want to use noise2, but it always returns (0,0)? + if(texture2D(noise, qt_TexCoord0).w <= t) + gl_FragColor = texture2D(source, qt_TexCoord0) * qt_Opacity; + else + gl_FragColor = vec4(0.,0.,0.,0.); + } + " + } + ParticleSystem{ + id: imageSystem + } + Emitter{ + id: pixelEmitter + system: imageSystem + //anchors.fill: parent + width: Math.min(bigImage.width * bigImage.scale, flickable.width); + height: Math.min(bigImage.height * bigImage.scale, flickable.height); + anchors.centerIn: parent + size: 4 + lifeSpan: flipDuration + emitRate: 2048 + enabled: false + } + CustomParticle{ + id: blowOut + system: imageSystem + property real maxWidth: effectBox.width + property real maxHeight: effectBox.height + vertexShader:" + uniform highp float maxWidth; + uniform highp float maxHeight; + + varying highp vec2 fTex2; + + void main() { + defaultMain(); + fTex2 = vec2(qt_ParticlePos.x / maxWidth, qt_ParticlePos.y / maxHeight); + } + " + property variant pictureTexture: pictureSource + fragmentShader: " + uniform lowp float qt_Opacity; + uniform sampler2D pictureTexture; + varying highp vec2 fTex2; + void main() { + gl_FragColor = texture2D(pictureTexture, fTex2) * qt_Opacity; + }" + } + + + + } + } + } + + Text { + text: "Image Unavailable" + visible: bigImage.status == Image.Error + anchors.centerIn: parent; color: "white"; font.bold: true + } + + Slider { + id: slider; visible: { bigImage.status == Image.Ready && maximum > minimum } + anchors { + bottom: parent.bottom; bottomMargin: 65 + left: parent.left; leftMargin: 25 + right: parent.right; rightMargin: 25 + } + onValueChanged: { + if (bigImage.width * value > flickable.width) { + var xoff = (flickable.width/2 + flickable.contentX) * value / prevScale; + flickable.contentX = xoff - flickable.width/2; + } + if (bigImage.height * value > flickable.height) { + var yoff = (flickable.height/2 + flickable.contentY) * value / prevScale; + flickable.contentY = yoff - flickable.height/2; + } + prevScale = value; + } + } + } + + states: State { + name: "Back" + PropertyChanges { target: itemRotation; angle: 180 } + PropertyChanges { target: toolBar; button2Visible: false } + PropertyChanges { target: toolBar; button1Label: "Back" } + PropertyChanges { target: bigImage; inBackState: true } + } + + transitions: Transition { + SequentialAnimation { + PropertyAction { target: bigImage; property: "smooth"; value: false } + NumberAnimation { easing.type: Easing.InOutQuad; properties: "angle"; duration: flipDuration } + PropertyAction { target: bigImage; property: "smooth"; value: !flickable.movingVertically } + } + } +} diff --git a/examples/qml/flickr/content/ListDelegate.qml b/examples/qml/flickr/content/ListDelegate.qml new file mode 100644 index 0000000000..00f837f862 --- /dev/null +++ b/examples/qml/flickr/content/ListDelegate.qml @@ -0,0 +1,64 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtQml module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Component { + Item { + id: wrapper; width: wrapper.ListView.view.width; height: 86 + Item { + id: moveMe + Rectangle { color: "black"; opacity: index % 2 ? 0.2 : 0.4; height: 84; width: wrapper.width; y: 1 } + Rectangle { + x: 6; y: 4; width: 77; height: 77; color: "white"; smooth: true + + Image { source: imagePath; x: 1; y: 1 } + Image { source: "images/gloss.png" } + } + Column { + x: 92; width: wrapper.ListView.view.width - 95; y: 15; spacing: 2 + Text { text: title; color: "white"; width: parent.width; font.pixelSize: 14; font.bold: true; elide: Text.ElideRight; style: Text.Raised; styleColor: "black" } + Text { text: photoAuthor; width: parent.width; font.pixelSize: 14; elide: Text.ElideLeft; color: "#cccccc"; style: Text.Raised; styleColor: "black" } + Text { text: photoDate; width: parent.width; font.pixelSize: 14; elide: Text.ElideRight; color: "#cccccc"; style: Text.Raised; styleColor: "black" } + } + } + } +} diff --git a/examples/qml/flickr/content/Progress.qml b/examples/qml/flickr/content/Progress.qml new file mode 100644 index 0000000000..ed2629b48a --- /dev/null +++ b/examples/qml/flickr/content/Progress.qml @@ -0,0 +1,88 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtQml module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import QtQuick.Particles 2.0 + +Item{ + id: container + property variant progress: 0 + + Rectangle { + anchors.fill: parent; smooth: true + border.color: "white"; border.width: 0; radius: height/2 - 2 + gradient: Gradient { + GradientStop { position: 0; color: "#66343434" } + GradientStop { position: 1.0; color: "#66000000" } + } + } + + ParticleSystem{ + running: container.visible + id: barSys + } + ImageParticle{ + color: "lightsteelblue" + alpha: 0.1 + colorVariation: 0.05 + source: "images/particle.png" + system: barSys + } + Emitter{ + y: 2; height: parent.height-4; + x: 2; width: Math.max(parent.width * progress - 4, 0); + speed: AngleDirection{ angleVariation: 180; magnitudeVariation: 12 } + system: barSys + emitRate: width; + lifeSpan: 1000 + size: 20 + sizeVariation: 4 + endSize: 12 + maximumEmitted: parent.width; + } + + Text { + text: Math.round(progress * 100) + "%" + anchors.horizontalCenter: parent.horizontalCenter + anchors.verticalCenter: parent.verticalCenter + color: Qt.rgba(1.0, 1.0 - progress, 1.0 - progress,0.9); font.bold: true; font.pixelSize: 15 + } +} diff --git a/examples/qml/flickr/content/RssModel.qml b/examples/qml/flickr/content/RssModel.qml new file mode 100644 index 0000000000..51cea498e6 --- /dev/null +++ b/examples/qml/flickr/content/RssModel.qml @@ -0,0 +1,64 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtQml module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import QtQuick.XmlListModel 2.0 + +XmlListModel { + property string tags : "" + + function encodeTags(x) { return encodeURIComponent(x.replace(' ',',')); } + + source: "http://api.flickr.com/services/feeds/photos_public.gne?"+(tags ? "tags="+encodeTags(tags)+"&" : "")+"format=rss2" + query: "/rss/channel/item" + namespaceDeclarations: "declare namespace media=\"http://search.yahoo.com/mrss/\";" + + XmlRole { name: "title"; query: "title/string()" } + XmlRole { name: "imagePath"; query: "media:thumbnail/@url/string()" } + XmlRole { name: "url"; query: "media:content/@url/string()" } + XmlRole { name: "description"; query: "description/string()" } + XmlRole { name: "tags"; query: "media:category/string()" } + XmlRole { name: "photoWidth"; query: "media:content/@width/string()" } + XmlRole { name: "photoHeight"; query: "media:content/@height/string()" } + XmlRole { name: "photoType"; query: "media:content/@type/string()" } + XmlRole { name: "photoAuthor"; query: "author/string()" } + XmlRole { name: "photoDate"; query: "pubDate/string()" } +} diff --git a/examples/qml/flickr/content/ScrollBar.qml b/examples/qml/flickr/content/ScrollBar.qml new file mode 100644 index 0000000000..7c62ad088f --- /dev/null +++ b/examples/qml/flickr/content/ScrollBar.qml @@ -0,0 +1,81 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtQml module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Item { + id: container + + property variant flickableArea + + Rectangle { + radius: 5 + color: "black" + opacity: 0.3 + border.color: "white" + border.width: 2 + x: 0 + y: flickableArea.visibleArea.yPosition * container.height + width: parent.width + height: flickableArea.visibleArea.heightRatio * container.height + } + states: [ + State { + name: "show" + when: flickableArea.movingVertically + PropertyChanges { + target: container + opacity: 1 + } + } + ] + transitions: [ + Transition { + from: "*" + to: "*" + NumberAnimation { + target: container + properties: "opacity" + duration: 400 + } + } + ] +} diff --git a/examples/qml/flickr/content/Slider.qml b/examples/qml/flickr/content/Slider.qml new file mode 100644 index 0000000000..c4e743641f --- /dev/null +++ b/examples/qml/flickr/content/Slider.qml @@ -0,0 +1,91 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtQml module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Item { + id: slider; width: 400; height: 16 + + // value is read/write. + property real value: 1 + onValueChanged: updatePos(); + property real maximum: 1 + property real minimum: 1 + property int xMax: width - handle.width - 4 + onXMaxChanged: updatePos(); + onMinimumChanged: updatePos(); + + function updatePos() { + if (maximum > minimum) { + var pos = 2 + (value - minimum) * slider.xMax / (maximum - minimum); + pos = Math.min(pos, width - handle.width - 2); + pos = Math.max(pos, 2); + handle.x = pos; + } else { + handle.x = 2; + } + } + + Rectangle { + anchors.fill: parent + border.color: "white"; border.width: 0; radius: 8 + gradient: Gradient { + GradientStop { position: 0.0; color: "#66343434" } + GradientStop { position: 1.0; color: "#66000000" } + } + } + + Rectangle { + id: handle; smooth: true + y: 2; width: 30; height: slider.height-4; radius: 6 + gradient: Gradient { + GradientStop { position: 0.0; color: "lightgray" } + GradientStop { position: 1.0; color: "gray" } + } + + MouseArea { + id: mouse + anchors.fill: parent; drag.target: parent + drag.axis: Drag.XAxis; drag.minimumX: 2; drag.maximumX: slider.xMax+2 + onPositionChanged: { value = (maximum - minimum) * (handle.x-2) / slider.xMax + minimum; } + } + } +} diff --git a/examples/qml/flickr/content/TitleBar.qml b/examples/qml/flickr/content/TitleBar.qml new file mode 100644 index 0000000000..223939f81a --- /dev/null +++ b/examples/qml/flickr/content/TitleBar.qml @@ -0,0 +1,128 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtQml module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Item { + id: titleBar + property string untaggedString: "Uploads from everyone" + property string taggedString: "Recent uploads tagged " + + BorderImage { source: "images/titlebar.sci"; width: parent.width; height: parent.height + 14; y: -7 } + + Item { + id: container + width: (parent.width * 2) - 55 ; height: parent.height + + function accept() { + imageDetails.closed() + titleBar.state = "" + background.state = "" + rssModel.tags = editor.text + } + + Image { + id: quitButton + anchors.left: parent.left//; anchors.leftMargin: 0 + anchors.verticalCenter: parent.verticalCenter + source: "images/quit.png" + MouseArea { + anchors.fill: parent + onClicked: Qt.quit() + } + } + + Text { + id: categoryText + anchors { + left: quitButton.right; right: tagButton.left; leftMargin: 10; rightMargin: 10 + verticalCenter: parent.verticalCenter + } + elide: Text.ElideLeft + text: (rssModel.tags=="" ? untaggedString : taggedString + rssModel.tags) + font.bold: true; font.pixelSize: 15; color: "White"; style: Text.Raised; styleColor: "Black" + } + + Button { + id: tagButton; x: titleBar.width - 50; width: 45; height: 32; text: "..." + onClicked: if (titleBar.state == "Tags") container.accept(); else titleBar.state = "Tags" + anchors.verticalCenter: parent.verticalCenter + } + + Item { + id: lineEdit + y: 4; height: parent.height - 9 + anchors { left: tagButton.right; leftMargin: 5; right: parent.right; rightMargin: 5 } + + BorderImage { source: "images/lineedit.sci"; anchors.fill: parent } + + TextInput { + id: editor + anchors { + left: parent.left; right: parent.right; leftMargin: 10; rightMargin: 10 + verticalCenter: parent.verticalCenter + } + cursorVisible: true; font.bold: true + color: "#151515"; selectionColor: "Green" + } + + Keys.forwardTo: [ (returnKey), (editor)] + + Item { + id: returnKey + Keys.onReturnPressed: container.accept() + Keys.onEnterPressed: container.accept() + Keys.onEscapePressed: titleBar.state = "" + } + } + } + + states: State { + name: "Tags" + PropertyChanges { target: container; x: -tagButton.x + 5 } + PropertyChanges { target: tagButton; text: "OK" } + PropertyChanges { target: editor; focus: true } + } + + transitions: Transition { + NumberAnimation { properties: "x"; easing.type: Easing.InOutQuad } + } +} diff --git a/examples/qml/flickr/content/ToolBar.qml b/examples/qml/flickr/content/ToolBar.qml new file mode 100644 index 0000000000..356993b41a --- /dev/null +++ b/examples/qml/flickr/content/ToolBar.qml @@ -0,0 +1,69 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtQml module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Item { + id: toolbar + + property alias button1Label: button1.text + property alias button2Label: button2.text + property alias button2Visible: button2.visible + + signal button1Clicked + signal button2Clicked + + BorderImage { source: "images/titlebar.sci"; width: parent.width; height: parent.height + 14; y: -7 } + + Row { + anchors.right: parent.right; anchors.rightMargin: 5; y: 3; height: 32; spacing: 30 + Button { + id: button1 + width: 140; height: 32 + onClicked: toolbar.button1Clicked() + } + + Button { + id: button2; width: 140; height: 32 + onClicked: toolbar.button2Clicked() + } + } +} diff --git a/examples/qml/flickr/content/UnifiedDelegate.qml b/examples/qml/flickr/content/UnifiedDelegate.qml new file mode 100644 index 0000000000..0b068c0abe --- /dev/null +++ b/examples/qml/flickr/content/UnifiedDelegate.qml @@ -0,0 +1,154 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtQml module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import QtQuick.Particles 2.0 + +Package { + function photoClicked() { + imageDetails.photoTitle = title; + imageDetails.photoTags = tags; + imageDetails.photoWidth = photoWidth; + imageDetails.photoHeight = photoHeight; + imageDetails.photoType = photoType; + imageDetails.photoAuthor = photoAuthor; + imageDetails.photoDate = photoDate; + imageDetails.photoUrl = url; + imageDetails.rating = 0; + scaleMe.state = "Details"; + } + + Item { + id: gridwrapper; + width: GridView.view.cellWidth; height: GridView.view.cellHeight + Package.name: "grid" + } + Item { + id: streamwrapper; + width: 80; height: 80 + Package.name: "stream" + } + Item { + //anchors.centerIn: parent//Doesn't animate :( + width: 80; height: 80 + scale: 0.0 + Behavior on scale { NumberAnimation { easing.type: Easing.InOutQuad} } + id: scaleMe + + Item { + id: whiteRectContainer + width: 77; height: 77; anchors.centerIn: parent + Rectangle { + id: whiteRect; width: 77; height: 77; color: "#dddddd"; smooth: true + x:0; y:0 + Image { id: thumb; source: imagePath; x: 1; y: 1; smooth: true } + Image { source: "images/gloss.png" } + MouseArea { anchors.fill: parent; onClicked: photoClicked() } + } + } + + Connections { + target: toolBar + onButton2Clicked: if (scaleMe.state == 'Details' ) scaleMe.state = 'Show' + } + + state: 'inStream' + states: [ + State { + name: "Show"; when: thumb.status == Image.Ready + PropertyChanges { target: scaleMe; scale: 1; } + }, + State { + name: "Details" + PropertyChanges { target: scaleMe; scale: 1 } + ParentChange { target: whiteRect; x: 10; y: 20; parent: imageDetails.frontContainer } + PropertyChanges { target: background; state: "DetailedView" } + } + ] + transitions: [ + Transition { + from: "Show"; to: "Details" + ParentAnimation { + via: foreground + NumberAnimation { properties: "x,y"; duration: 500; easing.type: Easing.InOutQuad } + } + }, + Transition { + from: "Details"; to: "Show" + SequentialAnimation{ + ParentAnimation { + via: foreground + NumberAnimation { properties: "x,y"; duration: 500; easing.type: Easing.InOutQuad } + } + } + } + ] + Item{ + id: stateContainer + states: [ + State { + name: 'inStream' + when: screen.inGridView == false + ParentChange { + target: scaleMe; parent: streamwrapper + x: 0; y: 0; + } + }, + State { + name: 'inGrid' + when: screen.inGridView == true + ParentChange { + target: scaleMe; parent: gridwrapper + x: 0; y: 0; + } + } + ] + + transitions: [ + Transition { + ParentAnimation { + NumberAnimation { target: scaleMe; properties: 'x,y,width,height'; duration: 300 } + } + } + ] + } + } +} diff --git a/examples/qml/flickr/content/images/gloss.png b/examples/qml/flickr/content/images/gloss.png new file mode 100644 index 0000000000..5d370cd93d Binary files /dev/null and b/examples/qml/flickr/content/images/gloss.png differ diff --git a/examples/qml/flickr/content/images/lineedit.png b/examples/qml/flickr/content/images/lineedit.png new file mode 100644 index 0000000000..2cc38dc35b Binary files /dev/null and b/examples/qml/flickr/content/images/lineedit.png differ diff --git a/examples/qml/flickr/content/images/lineedit.sci b/examples/qml/flickr/content/images/lineedit.sci new file mode 100644 index 0000000000..054bff78be --- /dev/null +++ b/examples/qml/flickr/content/images/lineedit.sci @@ -0,0 +1,5 @@ +border.left: 10 +border.top: 10 +border.bottom: 10 +border.right: 10 +source: lineedit.png diff --git a/examples/qml/flickr/content/images/noise.png b/examples/qml/flickr/content/images/noise.png new file mode 100644 index 0000000000..c5a5ba0053 Binary files /dev/null and b/examples/qml/flickr/content/images/noise.png differ diff --git a/examples/qml/flickr/content/images/particle.png b/examples/qml/flickr/content/images/particle.png new file mode 100644 index 0000000000..dbc39cb16e Binary files /dev/null and b/examples/qml/flickr/content/images/particle.png differ diff --git a/examples/qml/flickr/content/images/quit.png b/examples/qml/flickr/content/images/quit.png new file mode 100644 index 0000000000..5bda1b6e0d Binary files /dev/null and b/examples/qml/flickr/content/images/quit.png differ diff --git a/examples/qml/flickr/content/images/squareParticle.png b/examples/qml/flickr/content/images/squareParticle.png new file mode 100644 index 0000000000..faf85c24e0 Binary files /dev/null and b/examples/qml/flickr/content/images/squareParticle.png differ diff --git a/examples/qml/flickr/content/images/stripes.png b/examples/qml/flickr/content/images/stripes.png new file mode 100644 index 0000000000..9f36727ea4 Binary files /dev/null and b/examples/qml/flickr/content/images/stripes.png differ diff --git a/examples/qml/flickr/content/images/titlebar.png b/examples/qml/flickr/content/images/titlebar.png new file mode 100644 index 0000000000..51c90082d0 Binary files /dev/null and b/examples/qml/flickr/content/images/titlebar.png differ diff --git a/examples/qml/flickr/content/images/titlebar.sci b/examples/qml/flickr/content/images/titlebar.sci new file mode 100644 index 0000000000..0418d94cd6 --- /dev/null +++ b/examples/qml/flickr/content/images/titlebar.sci @@ -0,0 +1,5 @@ +border.left: 10 +border.top: 12 +border.bottom: 12 +border.right: 10 +source: titlebar.png diff --git a/examples/qml/flickr/content/images/toolbutton.png b/examples/qml/flickr/content/images/toolbutton.png new file mode 100644 index 0000000000..11310013ee Binary files /dev/null and b/examples/qml/flickr/content/images/toolbutton.png differ diff --git a/examples/qml/flickr/content/images/toolbutton.sci b/examples/qml/flickr/content/images/toolbutton.sci new file mode 100644 index 0000000000..9e4f965307 --- /dev/null +++ b/examples/qml/flickr/content/images/toolbutton.sci @@ -0,0 +1,5 @@ +border.left: 15 +border.top: 4 +border.bottom: 4 +border.right: 15 +source: toolbutton.png diff --git a/examples/qml/flickr/content/qmldir b/examples/qml/flickr/content/qmldir new file mode 100644 index 0000000000..adc2479b9f --- /dev/null +++ b/examples/qml/flickr/content/qmldir @@ -0,0 +1,10 @@ +ImageDetails ImageDetails.qml +LikeOMeter LikeOMeter.qml +Loading Loading.qml +MediaButton MediaButton.qml +MediaLineEdit MediaLineEdit.qml +Progress Progress.qml +RssModel RssModel.qml +ScrollBar ScrollBar.qml +Slider Slider.qml +Star Star.qml diff --git a/examples/qml/flickr/flickr-90.qml b/examples/qml/flickr/flickr-90.qml new file mode 100644 index 0000000000..b95b1c9872 --- /dev/null +++ b/examples/qml/flickr/flickr-90.qml @@ -0,0 +1,52 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtQml module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Item { + width: 480; height: 320 + + Loader { + y: 320; rotation: -90 + transformOrigin: Item.TopLeft + source: "flickr.qml" + } +} diff --git a/examples/qml/flickr/flickr.qml b/examples/qml/flickr/flickr.qml new file mode 100644 index 0000000000..98ca5197ab --- /dev/null +++ b/examples/qml/flickr/flickr.qml @@ -0,0 +1,158 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtQml module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import QtQuick.Particles 2.0 +import "content" + +Item { + id: screen; width: 320; height: 480 + property bool inGridView : true + + Rectangle { + id: background + anchors.fill: parent; color: "#343434"; + + Image { source: "content/images/stripes.png"; fillMode: Image.Tile; anchors.fill: parent; opacity: 0.3 } + ParticleSystem { + id: bgParticles + anchors.fill: parent + ImageParticle { + groups: ["trail"] + source: "content/images/particle.png" + color: "#1A1A6F" + alpha: 0.1 + colorVariation: 0.01 + blueVariation: 0.8 + } + Emitter { + group: "drops" + width: parent.width + emitRate: 0.5 + lifeSpan: 20000 + startTime: 16000 + speed: PointDirection{ + y: {screen.height/18} + } + } + TrailEmitter { + follow: "drops" + group: "trail" + emitRatePerParticle: 18 + size: 32 + endSize: 0 + sizeVariation: 4 + lifeSpan: 1200 + anchors.fill: parent + emitWidth: 16 + emitHeight: 16 + emitShape: EllipseShape{} + } + } + + VisualDataModel{ + id: vdm + delegate: UnifiedDelegate{} + model: RssModel { id: rssModel } + } + + Item { + id: views + width: parent.width + anchors.top: titleBar.bottom; anchors.bottom: toolBar.top + + GridView { + id: photoGridView; model: vdm.parts.grid + cacheBuffer: 1000 + cellWidth: (parent.width-2)/4; cellHeight: cellWidth; width: parent.width; height: parent.height + } + + states: State { + name: "GridView"; when: state.inGridView == true + } + + transitions: Transition { + NumberAnimation { properties: "x"; duration: 500; easing.type: Easing.InOutQuad } + } + + ImageDetails { id: imageDetails; width: parent.width; anchors.left: views.right; height: parent.height } + + Item { id: foreground; anchors.fill: parent } + } + + TitleBar { id: titleBar; width: parent.width; height: 40; opacity: 0.9 } + + ToolBar { + id: toolBar + height: 40; anchors.bottom: parent.bottom; width: parent.width; opacity: 0.9 + button1Label: "Update"; button2Label: "View mode" + onButton1Clicked: rssModel.reload() + onButton2Clicked: if (screen.inGridView == true) screen.inGridView = false; else screen.inGridView = true + } + + Connections { + target: imageDetails + onClosed: { + if (background.state == "DetailedView") { + background.state = ''; + imageDetails.photoUrl = ""; + } + } + } + + states: State { + name: "DetailedView" + PropertyChanges { target: views; x: -parent.width } + PropertyChanges { target: toolBar; button1Label: "View..." } + PropertyChanges { + target: toolBar + onButton1Clicked: if (imageDetails.state=='') imageDetails.state='Back'; else imageDetails.state='' + } + PropertyChanges { target: toolBar; button2Label: "Back" } + PropertyChanges { target: toolBar; onButton2Clicked: imageDetails.closed() } + } + + transitions: Transition { + NumberAnimation { properties: "x"; duration: 500; easing.type: Easing.InOutQuad } + } + + } +} diff --git a/examples/qml/flickr/flickr.qmlproject b/examples/qml/flickr/flickr.qmlproject new file mode 100644 index 0000000000..af5179d84b --- /dev/null +++ b/examples/qml/flickr/flickr.qmlproject @@ -0,0 +1,17 @@ +import QmlProject 1.1 + +Project { + mainFile: "flickr.qml" + //mainFile: "flickr-90.qml" + + /* Include .qml, .js, and image files from current directory and subdirectories */ + QmlFiles { + directory: "." + } + JavaScriptFiles { + directory: "." + } + ImageFiles { + directory: "." + } +} diff --git a/examples/qml/i18n/i18n.qml b/examples/qml/i18n/i18n.qml new file mode 100644 index 0000000000..f8bf30d0f0 --- /dev/null +++ b/examples/qml/i18n/i18n.qml @@ -0,0 +1,78 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +// +// The QML runtime automatically loads a translation from the i18n subdirectory of the root +// QML file, based on the system language. +// +// The files are created/updated by running: +// +// lupdate i18n.qml -ts i18n/base.ts +// +// Translations for new languages are created by copying i18n/base.ts to i18n/qml_.ts +// The .ts files can then be edited with Linguist: +// +// linguist i18n/qml_fr.ts +// +// The run-time translation files are then generated by running: +// +// lrelease i18n/*.ts +// + +Rectangle { + width: 640; height: 480 + + Column { + anchors.fill: parent; spacing: 20 + + Text { + text: "If a translation is available for the system language (eg. French) then the "+ + "string below will translated (eg. 'Bonjour'). Otherwise it will show 'Hello'." + width: parent.width; wrapMode: Text.WordWrap + } + + Text { + text: qsTr("Hello") + font.pointSize: 25; anchors.horizontalCenter: parent.horizontalCenter + } + } +} diff --git a/examples/qml/i18n/i18n/base.ts b/examples/qml/i18n/i18n/base.ts new file mode 100644 index 0000000000..82547a1f93 --- /dev/null +++ b/examples/qml/i18n/i18n/base.ts @@ -0,0 +1,12 @@ + + + + + i18n + + + Hello + + + + diff --git a/examples/qml/i18n/i18n/qml_en_AU.ts b/examples/qml/i18n/i18n/qml_en_AU.ts new file mode 100644 index 0000000000..e991affe7f --- /dev/null +++ b/examples/qml/i18n/i18n/qml_en_AU.ts @@ -0,0 +1,12 @@ + + + + + i18n + + + Hello + G'day + + + diff --git a/examples/qml/i18n/i18n/qml_fr.ts b/examples/qml/i18n/i18n/qml_fr.ts new file mode 100644 index 0000000000..365abd95c2 --- /dev/null +++ b/examples/qml/i18n/i18n/qml_fr.ts @@ -0,0 +1,12 @@ + + + + + i18n + + + Hello + Bonjour + + + diff --git a/examples/qml/imageelements/borderimage.qml b/examples/qml/imageelements/borderimage.qml new file mode 100644 index 0000000000..3dd5d1d9bb --- /dev/null +++ b/examples/qml/imageelements/borderimage.qml @@ -0,0 +1,97 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import "content" + +Rectangle { + id: page + width: 1030; height: 540 + + Grid { + anchors.centerIn: parent; spacing: 20 + + MyBorderImage { + minWidth: 120; maxWidth: 240; minHeight: 120; maxHeight: 240 + source: "content/colors.png"; margin: 30 + } + + MyBorderImage { + minWidth: 120; maxWidth: 240; minHeight: 120; maxHeight: 240 + source: "content/colors.png"; margin: 30 + horizontalMode: BorderImage.Repeat; verticalMode: BorderImage.Repeat + } + + MyBorderImage { + minWidth: 120; maxWidth: 240; minHeight: 120; maxHeight: 240 + source: "content/colors.png"; margin: 30 + horizontalMode: BorderImage.Stretch; verticalMode: BorderImage.Repeat + } + + MyBorderImage { + minWidth: 120; maxWidth: 240; minHeight: 120; maxHeight: 240 + source: "content/colors.png"; margin: 30 + horizontalMode: BorderImage.Round; verticalMode: BorderImage.Round + } + + MyBorderImage { + minWidth: 60; maxWidth: 200; minHeight: 40; maxHeight: 200 + source: "content/bw.png"; margin: 10 + } + + MyBorderImage { + minWidth: 60; maxWidth: 200; minHeight: 40; maxHeight: 200 + source: "content/bw.png"; margin: 10 + horizontalMode: BorderImage.Repeat; verticalMode: BorderImage.Repeat + } + + MyBorderImage { + minWidth: 60; maxWidth: 200; minHeight: 40; maxHeight: 200 + source: "content/bw.png"; margin: 10 + horizontalMode: BorderImage.Stretch; verticalMode: BorderImage.Repeat + } + + MyBorderImage { + minWidth: 60; maxWidth: 200; minHeight: 40; maxHeight: 200 + source: "content/bw.png"; margin: 10 + horizontalMode: BorderImage.Round; verticalMode: BorderImage.Round + } + } +} diff --git a/examples/qml/imageelements/content/BearSheet.png b/examples/qml/imageelements/content/BearSheet.png new file mode 100644 index 0000000000..a084bf0f1e Binary files /dev/null and b/examples/qml/imageelements/content/BearSheet.png differ diff --git a/examples/qml/imageelements/content/ImageCell.qml b/examples/qml/imageelements/content/ImageCell.qml new file mode 100644 index 0000000000..fcc6b47af5 --- /dev/null +++ b/examples/qml/imageelements/content/ImageCell.qml @@ -0,0 +1,60 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +import QtQuick 2.0 + +Item { + property alias mode: image.fillMode + property alias caption: captionItem.text + + width: parent.cellWidth; height: parent.cellHeight + + Image { + id: image + width: parent.width; height: parent.height - captionItem.height + source: "qt-logo.png" + clip: true // only makes a difference if mode is PreserveAspectCrop + smooth: true + } + + Text { + id: captionItem + anchors.horizontalCenter: parent.horizontalCenter; anchors.bottom: parent.bottom + } +} diff --git a/examples/qml/imageelements/content/MyBorderImage.qml b/examples/qml/imageelements/content/MyBorderImage.qml new file mode 100644 index 0000000000..178e3706db --- /dev/null +++ b/examples/qml/imageelements/content/MyBorderImage.qml @@ -0,0 +1,90 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Item { + id: container + + property alias horizontalMode: image.horizontalTileMode + property alias verticalMode: image.verticalTileMode + property alias source: image.source + + property int minWidth + property int minHeight + property int maxWidth + property int maxHeight + property int margin + + width: 240; height: 240 + + BorderImage { + id: image; anchors.centerIn: parent + + SequentialAnimation on width { + loops: Animation.Infinite + NumberAnimation { + from: container.minWidth; to: container.maxWidth + duration: 2000; easing.type: Easing.InOutQuad + } + NumberAnimation { + from: container.maxWidth; to: container.minWidth + duration: 2000; easing.type: Easing.InOutQuad + } + } + + SequentialAnimation on height { + loops: Animation.Infinite + NumberAnimation { + from: container.minHeight; to: container.maxHeight + duration: 2000; easing.type: Easing.InOutQuad + } + NumberAnimation { + from: container.maxHeight; to: container.minHeight + duration: 2000; easing.type: Easing.InOutQuad + } + } + + border.top: container.margin + border.left: container.margin + border.bottom: container.margin + border.right: container.margin + } +} diff --git a/examples/qml/imageelements/content/ShadowRectangle.qml b/examples/qml/imageelements/content/ShadowRectangle.qml new file mode 100644 index 0000000000..e6fd13bb26 --- /dev/null +++ b/examples/qml/imageelements/content/ShadowRectangle.qml @@ -0,0 +1,54 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Item { + property alias color : rectangle.color + + BorderImage { + anchors.fill: rectangle + anchors { leftMargin: -6; topMargin: -6; rightMargin: -8; bottomMargin: -8 } + border { left: 10; top: 10; right: 10; bottom: 10 } + source: "shadow.png"; smooth: true + } + + Rectangle { id: rectangle; anchors.fill: parent } +} diff --git a/examples/qml/imageelements/content/bw.png b/examples/qml/imageelements/content/bw.png new file mode 100644 index 0000000000..486eaae96e Binary files /dev/null and b/examples/qml/imageelements/content/bw.png differ diff --git a/examples/qml/imageelements/content/colors-round.sci b/examples/qml/imageelements/content/colors-round.sci new file mode 100644 index 0000000000..506f6f5f99 --- /dev/null +++ b/examples/qml/imageelements/content/colors-round.sci @@ -0,0 +1,7 @@ +border.left:30 +border.top:30 +border.right:30 +border.bottom:30 +horizontalTileRule:Round +verticalTileRule:Round +source:colors.png diff --git a/examples/qml/imageelements/content/colors-stretch.sci b/examples/qml/imageelements/content/colors-stretch.sci new file mode 100644 index 0000000000..e4989a723c --- /dev/null +++ b/examples/qml/imageelements/content/colors-stretch.sci @@ -0,0 +1,5 @@ +border.left:30 +border.top:30 +border.right:30 +border.bottom:30 +source:colors.png diff --git a/examples/qml/imageelements/content/colors.png b/examples/qml/imageelements/content/colors.png new file mode 100644 index 0000000000..dfb62f3d64 Binary files /dev/null and b/examples/qml/imageelements/content/colors.png differ diff --git a/examples/qml/imageelements/content/qt-logo.png b/examples/qml/imageelements/content/qt-logo.png new file mode 100644 index 0000000000..14ddf2a028 Binary files /dev/null and b/examples/qml/imageelements/content/qt-logo.png differ diff --git a/examples/qml/imageelements/content/shadow.png b/examples/qml/imageelements/content/shadow.png new file mode 100644 index 0000000000..431af8545d Binary files /dev/null and b/examples/qml/imageelements/content/shadow.png differ diff --git a/examples/qml/imageelements/content/speaker.png b/examples/qml/imageelements/content/speaker.png new file mode 100644 index 0000000000..fb0e857859 Binary files /dev/null and b/examples/qml/imageelements/content/speaker.png differ diff --git a/examples/qml/imageelements/image.qml b/examples/qml/imageelements/image.qml new file mode 100644 index 0000000000..4ca26c1630 --- /dev/null +++ b/examples/qml/imageelements/image.qml @@ -0,0 +1,67 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import "content" + +Rectangle { + width: 490 + height: 285 + + Grid { + property int cellWidth: (width - (spacing * (columns - 1))) / columns + property int cellHeight: (height - (spacing * (rows - 1))) / rows + + anchors.fill: parent + anchors.margins: 30 + + columns: 3 + rows: 2 + spacing: 30 + + ImageCell { mode: Image.Stretch; caption: "Stretch" } + ImageCell { mode: Image.PreserveAspectFit; caption: "PreserveAspectFit" } + ImageCell { mode: Image.PreserveAspectCrop; caption: "PreserveAspectCrop" } + + ImageCell { mode: Image.Tile; caption: "Tile" } + ImageCell { mode: Image.TileHorizontally; caption: "TileHorizontally" } + ImageCell { mode: Image.TileVertically; caption: "TileVertically" } + } +} diff --git a/examples/qml/imageelements/imageelements.qml b/examples/qml/imageelements/imageelements.qml new file mode 100644 index 0000000000..2ef5154968 --- /dev/null +++ b/examples/qml/imageelements/imageelements.qml @@ -0,0 +1,58 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import "../shared" + +Item { + height: 480 + width: 640 + LauncherList { + id: ll + anchors.fill: parent + Component.onCompleted: { + addExample("BorderImage", "An image with scaled borders", Qt.resolvedUrl("borderimage.qml")); + addExample("Image", "A showcase of the options available to Image", Qt.resolvedUrl("image.qml")); + addExample("Shadows", "Rectangles with a drop-shadow effect", Qt.resolvedUrl("shadows.qml")); + addExample("Simple Sprite", "A simple sprite-based animation", Qt.resolvedUrl("simplesprite.qml")); + addExample("Sprite Image", "A sprite-based animation with complex transitions", Qt.resolvedUrl("spriteimage.qml")); + } + } +} diff --git a/examples/qml/imageelements/imageelements.qmlproject b/examples/qml/imageelements/imageelements.qmlproject new file mode 100644 index 0000000000..4292a0c112 --- /dev/null +++ b/examples/qml/imageelements/imageelements.qmlproject @@ -0,0 +1,16 @@ +import QmlProject 1.1 + +Project { + mainFile: "imageelements.qml" + + /* Include .qml, .js, and image files from current directory and subdirectories */ + QmlFiles { + directory: "." + } + JavaScriptFiles { + directory: "." + } + ImageFiles { + directory: "." + } +} diff --git a/examples/qml/imageelements/shadows.qml b/examples/qml/imageelements/shadows.qml new file mode 100644 index 0000000000..aa5022ab36 --- /dev/null +++ b/examples/qml/imageelements/shadows.qml @@ -0,0 +1,64 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import "content" + +Rectangle { + id: window + + width: 480; height: 320 + color: "gray" + + ShadowRectangle { + anchors.centerIn: parent; width: 250; height: 250 + color: "lightsteelblue" + } + + ShadowRectangle { + anchors.centerIn: parent; width: 200; height: 200 + color: "steelblue" + } + + ShadowRectangle { + anchors.centerIn: parent; width: 150; height: 150 + color: "thistle" + } +} diff --git a/examples/qml/imageelements/simplesprite.qml b/examples/qml/imageelements/simplesprite.qml new file mode 100644 index 0000000000..f619913bfc --- /dev/null +++ b/examples/qml/imageelements/simplesprite.qml @@ -0,0 +1,59 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +import QtQuick 2.0 + +Item { + width: 400 + height: 400 + Rectangle { + anchors.fill: parent + color: "white" + } + SpriteImage { + anchors.fill: parent + Sprite{ + source: "content/speaker.png" + frames: 60 + frameSync: true + frameWidth: 170 + frameHeight: 170 + } + } +} diff --git a/examples/qml/imageelements/spriteimage.qml b/examples/qml/imageelements/spriteimage.qml new file mode 100644 index 0000000000..559bb10a50 --- /dev/null +++ b/examples/qml/imageelements/spriteimage.qml @@ -0,0 +1,116 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +import QtQuick 2.0 + +Item { + width: 480 + height: 1280 + MouseArea { + onClicked: anim.start(); + anchors.fill: parent + } + SequentialAnimation { + id: anim + ScriptAction { script: image.goalSprite = "falling"; } + NumberAnimation { target: image; property: "y"; to: 1480; duration: 12000; } + ScriptAction { script: {image.goalSprite = ""; image.jumpTo("still");} } + PropertyAction { target: image; property: "y"; value: 0 } + } + SpriteImage { + id: image + width: 256 + height: 256 + anchors.horizontalCenter: parent.horizontalCenter + interpolate: false + goalSprite: "" + Sprite{ + name: "still" + source: "content/BearSheet.png" + frames: 1 + frameWidth: 256 + frameHeight: 256 + frameDuration: 100 + to: {"still":1, "blink":0.1, "floating":0} + } + Sprite{ + name: "blink" + source: "content/BearSheet.png" + frames: 3 + frameX: 256 + frameY: 1536 + frameWidth: 256 + frameHeight: 256 + frameDuration: 100 + to: {"still":1} + } + Sprite{ + name: "floating" + source: "content/BearSheet.png" + frames: 9 + frameX: 0 + frameY: 0 + frameWidth: 256 + frameHeight: 256 + frameDuration: 160 + to: {"still":0, "flailing":1} + } + Sprite{ + name: "flailing" + source: "content/BearSheet.png" + frames: 8 + frameX: 0 + frameY: 768 + frameWidth: 256 + frameHeight: 256 + frameDuration: 160 + to: {"falling":1} + } + Sprite{ + name: "falling" + source: "content/BearSheet.png" + frames: 5 + frameY: 1280 + frameWidth: 256 + frameHeight: 256 + frameDuration: 160 + to: {"falling":1} + } + } +} diff --git a/examples/qml/keyinteraction/focus/Core/ContextMenu.qml b/examples/qml/keyinteraction/focus/Core/ContextMenu.qml new file mode 100644 index 0000000000..dc68aa2b30 --- /dev/null +++ b/examples/qml/keyinteraction/focus/Core/ContextMenu.qml @@ -0,0 +1,65 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +FocusScope { + id: container + + property bool open: false + + Item { + anchors.fill: parent + + Rectangle { + anchors.fill: parent + color: "#D1DBBD" + focus: true + Keys.onRightPressed: mainView.focus = true + + Text { + anchors { top: parent.top; horizontalCenter: parent.horizontalCenter; margins: 30 } + color: "black" + font.pixelSize: 14 + text: "Context Menu" + } + } + } +} diff --git a/examples/qml/keyinteraction/focus/Core/GridMenu.qml b/examples/qml/keyinteraction/focus/Core/GridMenu.qml new file mode 100644 index 0000000000..75bbe682af --- /dev/null +++ b/examples/qml/keyinteraction/focus/Core/GridMenu.qml @@ -0,0 +1,105 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +FocusScope { + property alias interactive: gridView.interactive + + onActiveFocusChanged: { + if (activeFocus) + mainView.state = "" + } + + Rectangle { + anchors.fill: parent + clip: true + gradient: Gradient { + GradientStop { position: 0.0; color: "#193441" } + GradientStop { position: 1.0; color: Qt.darker("#193441") } + } + + GridView { + id: gridView + anchors.fill: parent; anchors.leftMargin: 20; anchors.rightMargin: 20 + cellWidth: 152; cellHeight: 152 + focus: true + model: 12 + + KeyNavigation.down: listMenu + KeyNavigation.left: contextMenu + + delegate: Item { + id: container + width: GridView.view.cellWidth; height: GridView.view.cellHeight + + Rectangle { + id: content + color: "transparent" + smooth: true + anchors.fill: parent; anchors.margins: 20; radius: 10 + + Rectangle { color: "#91AA9D"; anchors.fill: parent; anchors.margins: 3; radius: 8; smooth: true } + Image { source: "images/qt-logo.png"; anchors.centerIn: parent; smooth: true } + } + + MouseArea { + id: mouseArea + anchors.fill: parent + hoverEnabled: true + + onClicked: { + container.GridView.view.currentIndex = index + container.forceActiveFocus() + } + } + + states: State { + name: "active"; when: container.activeFocus + PropertyChanges { target: content; color: "#FCFFF5"; scale: 1.1 } + } + + transitions: Transition { + NumberAnimation { properties: "scale"; duration: 100 } + } + } + } + } +} diff --git a/examples/qml/keyinteraction/focus/Core/ListMenu.qml b/examples/qml/keyinteraction/focus/Core/ListMenu.qml new file mode 100644 index 0000000000..7a62f33428 --- /dev/null +++ b/examples/qml/keyinteraction/focus/Core/ListMenu.qml @@ -0,0 +1,105 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +FocusScope { + clip: true + + onActiveFocusChanged: { + if (activeFocus) + mainView.state = "showListViews" + } + + ListView { + id: list1 + y: activeFocus ? 10 : 40; width: parent.width / 3; height: parent.height - 20 + focus: true + KeyNavigation.up: gridMenu; KeyNavigation.left: contextMenu; KeyNavigation.right: list2 + model: 10; cacheBuffer: 200 + delegate: ListViewDelegate {} + + Behavior on y { + NumberAnimation { duration: 600; easing.type: Easing.OutQuint } + } + } + + ListView { + id: list2 + y: activeFocus ? 10 : 40; x: parseInt(parent.width / 3); width: parent.width / 3; height: parent.height - 20 + KeyNavigation.up: gridMenu; KeyNavigation.left: list1; KeyNavigation.right: list3 + model: 10; cacheBuffer: 200 + delegate: ListViewDelegate {} + + Behavior on y { + NumberAnimation { duration: 600; easing.type: Easing.OutQuint } + } + } + + ListView { + id: list3 + y: activeFocus ? 10 : 40; x: parseInt(2 * parent.width / 3); width: parent.width / 3; height: parent.height - 20 + KeyNavigation.up: gridMenu; KeyNavigation.left: list2 + model: 10; cacheBuffer: 200 + delegate: ListViewDelegate {} + + Behavior on y { + NumberAnimation { duration: 600; easing.type: Easing.OutQuint } + } + } + + Rectangle { width: parent.width; height: 1; color: "#D1DBBD" } + + Rectangle { + y: 1; width: parent.width; height: 10 + gradient: Gradient { + GradientStop { position: 0.0; color: "#3E606F" } + GradientStop { position: 1.0; color: "transparent" } + } + } + + Rectangle { + y: parent.height - 10; width: parent.width; height: 10 + gradient: Gradient { + GradientStop { position: 1.0; color: "#3E606F" } + GradientStop { position: 0.0; color: "transparent" } + } + } +} diff --git a/examples/qml/keyinteraction/focus/Core/ListViewDelegate.qml b/examples/qml/keyinteraction/focus/Core/ListViewDelegate.qml new file mode 100644 index 0000000000..b28b02616d --- /dev/null +++ b/examples/qml/keyinteraction/focus/Core/ListViewDelegate.qml @@ -0,0 +1,85 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Item { + id: container + width: ListView.view.width; height: 60; anchors.leftMargin: 10; anchors.rightMargin: 10 + + Rectangle { + id: content + anchors.centerIn: parent; width: container.width - 40; height: container.height - 10 + color: "transparent" + smooth: true + radius: 10 + + Rectangle { anchors.fill: parent; anchors.margins: 3; color: "#91AA9D"; smooth: true; radius: 8 } + } + + Text { + id: label + anchors.centerIn: content + text: "List element " + (index + 1) + color: "#193441" + font.pixelSize: 14 + } + + MouseArea { + id: mouseArea + anchors.fill: parent + hoverEnabled: true + + onClicked: { + container.ListView.view.currentIndex = index + container.forceActiveFocus() + } + } + + states: State { + name: "active"; when: container.activeFocus + PropertyChanges { target: content; color: "#FCFFF5"; scale: 1.1 } + PropertyChanges { target: label; font.pixelSize: 16 } + } + + transitions: Transition { + NumberAnimation { properties: "scale"; duration: 100 } + } +} diff --git a/examples/qml/keyinteraction/focus/Core/images/arrow.png b/examples/qml/keyinteraction/focus/Core/images/arrow.png new file mode 100644 index 0000000000..14978c2e56 Binary files /dev/null and b/examples/qml/keyinteraction/focus/Core/images/arrow.png differ diff --git a/examples/qml/keyinteraction/focus/Core/images/qt-logo.png b/examples/qml/keyinteraction/focus/Core/images/qt-logo.png new file mode 100644 index 0000000000..14ddf2a028 Binary files /dev/null and b/examples/qml/keyinteraction/focus/Core/images/qt-logo.png differ diff --git a/examples/qml/keyinteraction/focus/focus.qml b/examples/qml/keyinteraction/focus/focus.qml new file mode 100644 index 0000000000..9300ad4f6e --- /dev/null +++ b/examples/qml/keyinteraction/focus/focus.qml @@ -0,0 +1,111 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import "Core" + +Rectangle { + id: window + + width: 800; height: 480 + color: "#3E606F" + + FocusScope { + id: mainView + + width: parent.width; height: parent.height + focus: true + + GridMenu { + id: gridMenu + width: parent.width; height: 320 + + focus: true + interactive: parent.activeFocus + } + + ListMenu { + id: listMenu + y: 320; width: parent.width; height: 320 + } + + Rectangle { + id: shade + anchors.fill: parent + color: "black" + opacity: 0 + } + + states: State { + name: "showListViews" + PropertyChanges { target: gridMenu; y: -160 } + PropertyChanges { target: listMenu; y: 160 } + } + + transitions: Transition { + NumberAnimation { properties: "y"; duration: 600; easing.type: Easing.OutQuint } + } + } + + Image { + source: "Core/images/arrow.png" + rotation: 90 + anchors.verticalCenter: parent.verticalCenter + + MouseArea { + anchors.fill: parent; anchors.margins: -10 + onClicked: contextMenu.focus = true + } + } + + ContextMenu { id: contextMenu; x: -265; width: 260; height: parent.height } + + states: State { + name: "contextMenuOpen" + when: !mainView.activeFocus + PropertyChanges { target: contextMenu; x: 0; open: true } + PropertyChanges { target: mainView; x: 130 } + PropertyChanges { target: shade; opacity: 0.25 } + } + + transitions: Transition { + NumberAnimation { properties: "x,opacity"; duration: 600; easing.type: Easing.OutQuint } + } +} diff --git a/examples/qml/locale/locale.qml b/examples/qml/locale/locale.qml new file mode 100644 index 0000000000..08d08d6bbd --- /dev/null +++ b/examples/qml/locale/locale.qml @@ -0,0 +1,132 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Rectangle { + id: root + width: 320 + height: 480 + color: "lightgray" + + property string locale: view.currentItem.locale + + Text { + id: title + text: "Select locale:" + } + + Rectangle { + id: chooser + anchors.top: title.bottom + anchors.topMargin: 5 + width: parent.width-10 + x: 5 + height: parent.height/2 - 10 + color: "#40300030" + ListView { + id: view + clip: true + focus: true + anchors.fill: parent + model: [ + "en_US", + "en_GB", + "fi_FI", + "de_DE", + "ar_SA", + "hi_IN", + "zh_CN", + "th_TH", + "fr_FR", + "nb_NO", + "sv_SE" + ] + delegate: Text { + property string locale: modelData + height: 30 + width: view.width + text: Qt.locale(modelData).name + " ("+ Qt.locale(modelData).nativeCountryName + "/" + Qt.locale(modelData).nativeLanguageName + ")" + MouseArea { + anchors.fill: parent + onClicked: view.currentIndex = index + } + } + highlight: Rectangle { + height: 30 + color: "#60300030" + } + } + } + + Rectangle { + color: "white" + anchors.top: chooser.bottom + anchors.topMargin: 5 + anchors.bottom: parent.bottom + anchors.bottomMargin: 5 + x: 5; width: parent.width - 10 + + Column { + anchors.fill: parent + spacing: 5 + Text { + property var date: new Date() + text: "Date: " + date.toLocaleDateString(Qt.locale(root.locale)) + } + Text { + property var date: new Date() + text: "Time: " + date.toLocaleTimeString(Qt.locale(root.locale)) + } + Text { + property var dow: Qt.locale(root.locale).firstDayOfWeek + text: "First day of week: " + Qt.locale(root.locale).standaloneDayName(dow) + } + Text { + property var num: 10023823 + text: "Number: " + num.toLocaleString(Qt.locale(root.locale)) + } + Text { + property var num: 10023823 + text: "Currency: " + num.toLocaleCurrencyString(Qt.locale(root.locale)) + } + } + } +} diff --git a/examples/qml/minehunt/MinehuntCore/Explosion.qml b/examples/qml/minehunt/MinehuntCore/Explosion.qml new file mode 100644 index 0000000000..a1b4292bcf --- /dev/null +++ b/examples/qml/minehunt/MinehuntCore/Explosion.qml @@ -0,0 +1,69 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtQml module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import QtQuick.Particles 2.0 + +Item { + property bool explode : false + ParticleSystem { + width: 40 + height: 40 + ImageParticle { + groups: ["star"] + source: "file:MinehuntCore/pics/star.png" // TODO: Use qrc path once QTBUG-21129 is fixed + } + Emitter { + id: particles + enabled: false + anchors.centerIn: parent + group: "star" + speed: AngleDirection { angleVariation: 360; magnitude: 150; magnitudeVariation: 50 } + emitRate: 200 + z: 100 + lifeSpan: 1000 + } + } + states: State { name: "exploding"; when: explode + StateChangeScript { script: particles.burst(200); } + } + +} diff --git a/examples/qml/minehunt/MinehuntCore/Tile.qml b/examples/qml/minehunt/MinehuntCore/Tile.qml new file mode 100644 index 0000000000..1180b6f584 --- /dev/null +++ b/examples/qml/minehunt/MinehuntCore/Tile.qml @@ -0,0 +1,128 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtQml module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Flipable { + id: flipable + property int angle: 0 + + width: 40; height: 40 + transform: Rotation { origin.x: 20; origin.y: 20; axis.x: 1; axis.z: 0; angle: flipable.angle } + + front: Image { + source: "pics/front.png"; width: 40; height: 40 + + Image { + anchors.centerIn: parent + source: "pics/flag.png"; opacity: modelData.hasFlag + + Behavior on opacity { NumberAnimation {} } + } + } + + back: Image { + source: "pics/back.png" + width: 40; height: 40 + + Text { + anchors.centerIn: parent + text: modelData.hint; color: "white"; font.bold: true + opacity: !modelData.hasMine && modelData.hint > 0 + } + + Image { + anchors.centerIn: parent + source: "pics/bomb.png"; opacity: modelData.hasMine + } + + Explosion { id: expl } + } + + states: State { + name: "back"; when: modelData.flipped + PropertyChanges { target: flipable; angle: 180 } + } + + property real pauseDur: 250 + transitions: Transition { + SequentialAnimation { + ScriptAction { + script: { + var ret = Math.abs(flipable.x - field.clickx) + + Math.abs(flipable.y - field.clicky); + if (modelData.hasMine && modelData.flipped) + pauseDur = ret * 3 + else + pauseDur = ret + } + } + PauseAnimation { + duration: pauseDur + } + RotationAnimation { easing.type: Easing.InOutQuad } + ScriptAction { script: if (modelData.hasMine && modelData.flipped) { expl.explode = true } } + } + } + + MouseArea { + anchors.fill: parent + acceptedButtons: Qt.LeftButton | Qt.RightButton + onClicked: { + field.clickx = flipable.x + field.clicky = flipable.y + var row = Math.floor(index / 9) + var col = index - (Math.floor(index / 9) * 9) + if (mouse.button == undefined || mouse.button == Qt.RightButton) { + flag(row, col) + } else { + flip(row, col) + } + } + onPressAndHold: { + field.clickx = flipable.x + field.clicky = flipable.y + var row = Math.floor(index / 9) + var col = index - (Math.floor(index / 9) * 9) + flag(row, col) + } + } +} diff --git a/examples/qml/minehunt/MinehuntCore/pics/back.png b/examples/qml/minehunt/MinehuntCore/pics/back.png new file mode 100644 index 0000000000..f6b3f0b4d7 Binary files /dev/null and b/examples/qml/minehunt/MinehuntCore/pics/back.png differ diff --git a/examples/qml/minehunt/MinehuntCore/pics/background.png b/examples/qml/minehunt/MinehuntCore/pics/background.png new file mode 100644 index 0000000000..3734a27744 Binary files /dev/null and b/examples/qml/minehunt/MinehuntCore/pics/background.png differ diff --git a/examples/qml/minehunt/MinehuntCore/pics/bomb-color.png b/examples/qml/minehunt/MinehuntCore/pics/bomb-color.png new file mode 100644 index 0000000000..61ad0a928f Binary files /dev/null and b/examples/qml/minehunt/MinehuntCore/pics/bomb-color.png differ diff --git a/examples/qml/minehunt/MinehuntCore/pics/bomb.png b/examples/qml/minehunt/MinehuntCore/pics/bomb.png new file mode 100644 index 0000000000..a992575518 Binary files /dev/null and b/examples/qml/minehunt/MinehuntCore/pics/bomb.png differ diff --git a/examples/qml/minehunt/MinehuntCore/pics/face-sad.png b/examples/qml/minehunt/MinehuntCore/pics/face-sad.png new file mode 100644 index 0000000000..cf00aafe1f Binary files /dev/null and b/examples/qml/minehunt/MinehuntCore/pics/face-sad.png differ diff --git a/examples/qml/minehunt/MinehuntCore/pics/face-smile-big.png b/examples/qml/minehunt/MinehuntCore/pics/face-smile-big.png new file mode 100644 index 0000000000..f9c2335df5 Binary files /dev/null and b/examples/qml/minehunt/MinehuntCore/pics/face-smile-big.png differ diff --git a/examples/qml/minehunt/MinehuntCore/pics/face-smile.png b/examples/qml/minehunt/MinehuntCore/pics/face-smile.png new file mode 100644 index 0000000000..3d66d72578 Binary files /dev/null and b/examples/qml/minehunt/MinehuntCore/pics/face-smile.png differ diff --git a/examples/qml/minehunt/MinehuntCore/pics/flag-color.png b/examples/qml/minehunt/MinehuntCore/pics/flag-color.png new file mode 100644 index 0000000000..aadad0f11a Binary files /dev/null and b/examples/qml/minehunt/MinehuntCore/pics/flag-color.png differ diff --git a/examples/qml/minehunt/MinehuntCore/pics/flag.png b/examples/qml/minehunt/MinehuntCore/pics/flag.png new file mode 100644 index 0000000000..39cde4df82 Binary files /dev/null and b/examples/qml/minehunt/MinehuntCore/pics/flag.png differ diff --git a/examples/qml/minehunt/MinehuntCore/pics/front.png b/examples/qml/minehunt/MinehuntCore/pics/front.png new file mode 100644 index 0000000000..834331bd49 Binary files /dev/null and b/examples/qml/minehunt/MinehuntCore/pics/front.png differ diff --git a/examples/qml/minehunt/MinehuntCore/pics/quit.png b/examples/qml/minehunt/MinehuntCore/pics/quit.png new file mode 100644 index 0000000000..b822057d4e Binary files /dev/null and b/examples/qml/minehunt/MinehuntCore/pics/quit.png differ diff --git a/examples/qml/minehunt/MinehuntCore/pics/star.png b/examples/qml/minehunt/MinehuntCore/pics/star.png new file mode 100644 index 0000000000..3772359188 Binary files /dev/null and b/examples/qml/minehunt/MinehuntCore/pics/star.png differ diff --git a/examples/qml/minehunt/MinehuntCore/qmldir b/examples/qml/minehunt/MinehuntCore/qmldir new file mode 100644 index 0000000000..a0213a19c4 --- /dev/null +++ b/examples/qml/minehunt/MinehuntCore/qmldir @@ -0,0 +1,2 @@ +Explosion 2.0 Explosion.qml +Tile 2.0 Tile.qml diff --git a/examples/qml/minehunt/README b/examples/qml/minehunt/README new file mode 100644 index 0000000000..3849ca5fbf --- /dev/null +++ b/examples/qml/minehunt/README @@ -0,0 +1,6 @@ +Minehunt has to be compiled to run. + +To compile the C++ part, do 'qmake && make'. +To run, simply run the executable. +To deploy on a device, do 'make sis'. + diff --git a/examples/qml/minehunt/main.cpp b/examples/qml/minehunt/main.cpp new file mode 100644 index 0000000000..0aa11a1d7a --- /dev/null +++ b/examples/qml/minehunt/main.cpp @@ -0,0 +1,64 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the demonstration applications of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include +#include +#include + +#include "minehunt.h" + +int main(int argc, char *argv[]) +{ + QGuiApplication app(argc, argv); + QQuickView canvas; + + qmlRegisterType(); + MinehuntGame* game = new MinehuntGame(); + + canvas.setResizeMode(QQuickView::SizeRootObjectToView); + canvas.engine()->rootContext()->setContextObject(game); + canvas.setSource(QString("qrc:///minehunt.qml")); + QObject::connect(canvas.engine(), SIGNAL(quit()), &app, SLOT(quit())); + + canvas.show(); + return app.exec(); +} diff --git a/examples/qml/minehunt/minehunt.cpp b/examples/qml/minehunt/minehunt.cpp new file mode 100644 index 0000000000..cde30278b3 --- /dev/null +++ b/examples/qml/minehunt/minehunt.cpp @@ -0,0 +1,221 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the demonstration applications of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include +#include + +#include "minehunt.h" + +void tilesPropAppend(QQmlListProperty* prop, TileData* value) +{ + Q_UNUSED(prop); + Q_UNUSED(value); + return; //Append not supported +} + +int tilesPropCount(QQmlListProperty* prop) +{ + return static_cast*>(prop->data)->count(); +} + +TileData* tilesPropAt(QQmlListProperty* prop, int index) +{ + return static_cast*>(prop->data)->at(index); +} + +QQmlListProperty MinehuntGame::tiles(){ + return QQmlListProperty(this, &_tiles, &tilesPropAppend, + &tilesPropCount, &tilesPropAt, 0); +} + +MinehuntGame::MinehuntGame() +: numCols(9), numRows(9), playing(true), won(false) +{ + setObjectName("mainObject"); + srand(QTime(0,0,0).secsTo(QTime::currentTime())); + + //initialize array + for(int ii = 0; ii < numRows * numCols; ++ii) { + _tiles << new TileData; + } + reset(); + +} + +void MinehuntGame::setBoard() +{ + foreach(TileData* t, _tiles){ + t->setHasMine(false); + t->setHint(-1); + } + //place mines + int mines = nMines; + remaining = numRows*numCols-mines; + while ( mines ) { + int col = int((double(rand()) / double(RAND_MAX)) * numCols); + int row = int((double(rand()) / double(RAND_MAX)) * numRows); + + TileData* t = tile( row, col ); + + if (t && !t->hasMine()) { + t->setHasMine( true ); + mines--; + } + } + + //set hints + for (int r = 0; r < numRows; r++) + for (int c = 0; c < numCols; c++) { + TileData* t = tile(r, c); + if (t && !t->hasMine()) { + int hint = getHint(r,c); + t->setHint(hint); + } + } + + setPlaying(true); +} + +void MinehuntGame::reset() +{ + foreach(TileData* t, _tiles){ + t->unflip(); + t->setHasFlag(false); + } + nMines = 12; + nFlags = 0; + emit numMinesChanged(); + emit numFlagsChanged(); + setPlaying(false); + QTimer::singleShot(600,this, SLOT(setBoard())); +} + +int MinehuntGame::getHint(int row, int col) +{ + int hint = 0; + for (int c = col-1; c <= col+1; c++) + for (int r = row-1; r <= row+1; r++) { + TileData* t = tile(r, c); + if (t && t->hasMine()) + hint++; + } + return hint; +} + +bool MinehuntGame::flip(int row, int col) +{ + if(!playing) + return false; + + TileData *t = tile(row, col); + if (!t || t->hasFlag()) + return false; + + if(t->flipped()){ + int flags = 0; + for (int c = col-1; c <= col+1; c++) + for (int r = row-1; r <= row+1; r++) { + TileData *nearT = tile(r, c); + if(!nearT || nearT == t) + continue; + if(nearT->hasFlag()) + flags++; + } + if(!t->hint() || t->hint() != flags) + return false; + for (int c = col-1; c <= col+1; c++) + for (int r = row-1; r <= row+1; r++) { + TileData *nearT = tile(r, c); + if (nearT && !nearT->flipped() && !nearT->hasFlag()) { + flip( r, c ); + } + } + return true; + } + + t->flip(); + + if (t->hint() == 0) { + for (int c = col-1; c <= col+1; c++) + for (int r = row-1; r <= row+1; r++) { + TileData* t = tile(r, c); + if (t && !t->flipped()) { + flip( r, c ); + } + } + } + + if(t->hasMine()){ + for (int r = 0; r < numRows; r++)//Flip all other mines + for (int c = 0; c < numCols; c++) { + TileData* t = tile(r, c); + if (t && t->hasMine()) { + flip(r, c); + } + } + won = false; + hasWonChanged(); + setPlaying(false); + return true; + } + + remaining--; + if(!remaining){ + won = true; + hasWonChanged(); + setPlaying(false); + return true; + } + return true; +} + +bool MinehuntGame::flag(int row, int col) +{ + TileData *t = tile(row, col); + if(!t || !playing || t->flipped()) + return false; + + t->setHasFlag(!t->hasFlag()); + nFlags += (t->hasFlag()?1:-1); + emit numFlagsChanged(); + return true; +} diff --git a/examples/qml/minehunt/minehunt.h b/examples/qml/minehunt/minehunt.h new file mode 100644 index 0000000000..34bab71218 --- /dev/null +++ b/examples/qml/minehunt/minehunt.h @@ -0,0 +1,129 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the demonstration applications of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + + +#include + +class TileData : public QObject +{ + Q_OBJECT +public: + TileData() : _hasFlag(false), _hasMine(false), _hint(-1), _flipped(false) {} + + Q_PROPERTY(bool hasFlag READ hasFlag WRITE setHasFlag NOTIFY hasFlagChanged) + bool hasFlag() const { return _hasFlag; } + + Q_PROPERTY(bool hasMine READ hasMine NOTIFY hasMineChanged) + bool hasMine() const { return _hasMine; } + + Q_PROPERTY(int hint READ hint NOTIFY hintChanged) + int hint() const { return _hint; } + + Q_PROPERTY(bool flipped READ flipped NOTIFY flippedChanged()) + bool flipped() const { return _flipped; } + + void setHasFlag(bool flag) {if(flag==_hasFlag) return; _hasFlag = flag; emit hasFlagChanged();} + void setHasMine(bool mine) {if(mine==_hasMine) return; _hasMine = mine; emit hasMineChanged();} + void setHint(int hint) { if(hint == _hint) return; _hint = hint; emit hintChanged(); } + void flip() { if (_flipped) return; _flipped = true; emit flippedChanged(); } + void unflip() { if(!_flipped) return; _flipped = false; emit flippedChanged(); } + +signals: + void flippedChanged(); + void hasFlagChanged(); + void hintChanged(); + void hasMineChanged(); + +private: + bool _hasFlag; + bool _hasMine; + int _hint; + bool _flipped; +}; + +class MinehuntGame : public QObject +{ + Q_OBJECT +public: + MinehuntGame(); + + Q_PROPERTY(QQmlListProperty tiles READ tiles CONSTANT) + QQmlListProperty tiles(); + + Q_PROPERTY(bool isPlaying READ isPlaying NOTIFY isPlayingChanged) + bool isPlaying() {return playing;} + + Q_PROPERTY(bool hasWon READ hasWon NOTIFY hasWonChanged) + bool hasWon() {return won;} + + Q_PROPERTY(int numMines READ numMines NOTIFY numMinesChanged) + int numMines() const{return nMines;} + + Q_PROPERTY(int numFlags READ numFlags NOTIFY numFlagsChanged) + int numFlags() const{return nFlags;} + +public slots: + Q_INVOKABLE bool flip(int row, int col); + Q_INVOKABLE bool flag(int row, int col); + void setBoard(); + void reset(); + +signals: + void isPlayingChanged(); + void hasWonChanged(); + void numMinesChanged(); + void numFlagsChanged(); + +private: + bool onBoard( int r, int c ) const { return r >= 0 && r < numRows && c >= 0 && c < numCols; } + TileData *tile( int row, int col ) { return onBoard(row, col) ? _tiles[col+numRows*row] : 0; } + int getHint(int row, int col); + void setPlaying(bool b){if(b==playing) return; playing=b; emit isPlayingChanged();} + + QList _tiles; + int numCols; + int numRows; + bool playing; + bool won; + int remaining; + int nMines; + int nFlags; +}; diff --git a/examples/qml/minehunt/minehunt.pro b/examples/qml/minehunt/minehunt.pro new file mode 100644 index 0000000000..78e874d805 --- /dev/null +++ b/examples/qml/minehunt/minehunt.pro @@ -0,0 +1,5 @@ +QT += qml quick + +HEADERS += minehunt.h +SOURCES += main.cpp minehunt.cpp +RESOURCES = minehunt.qrc diff --git a/examples/qml/minehunt/minehunt.qml b/examples/qml/minehunt/minehunt.qml new file mode 100644 index 0000000000..42dc408fff --- /dev/null +++ b/examples/qml/minehunt/minehunt.qml @@ -0,0 +1,112 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtQml module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import "MinehuntCore" 2.0 + +Item { + id: field + property int clickx: 0 + property int clicky: 0 + + width: 450; height: 450 + + Image { source: "MinehuntCore/pics/background.png"; anchors.fill: parent; fillMode: Image.Tile } + + Grid { + anchors.horizontalCenter: parent.horizontalCenter + columns: 9; spacing: 1 + + Repeater { + id: repeater + model: tiles + delegate: Tile {} + } + } + + Row { + id: gamedata + x: 20; spacing: 20 + anchors.bottom: field.bottom; anchors.bottomMargin: 15 + + Image { + source: "MinehuntCore/pics/quit.png" + scale: quitMouse.pressed ? 0.8 : 1.0 + smooth: quitMouse.pressed + y: 10 + MouseArea { + id: quitMouse + anchors.fill: parent + anchors.margins: -20 + onClicked: Qt.quit() + } + } + Column { + spacing: 2 + Image { source: "MinehuntCore/pics/bomb-color.png" } + Text { anchors.horizontalCenter: parent.horizontalCenter; color: "white"; text: numMines } + } + + Column { + spacing: 2 + Image { source: "MinehuntCore/pics/flag-color.png" } + Text { anchors.horizontalCenter: parent.horizontalCenter; color: "white"; text: numFlags } + } + } + + Image { + anchors.bottom: field.bottom; anchors.bottomMargin: 15 + anchors.right: field.right; anchors.rightMargin: 20 + source: isPlaying ? 'MinehuntCore/pics/face-smile.png' : + hasWon ? 'MinehuntCore/pics/face-smile-big.png': 'MinehuntCore/pics/face-sad.png' + + MouseArea { anchors.fill: parent; onPressed: reset() } + } + Text { + anchors.centerIn: parent; width: parent.width - 20 + horizontalAlignment: Text.AlignHCenter + wrapMode: Text.WordWrap + text: "Minehunt demo has to be compiled to run.\n\nPlease see README." + color: "white"; font.bold: true; font.pixelSize: 14 + visible: tiles == undefined + } + +} diff --git a/examples/qml/minehunt/minehunt.qmlproject b/examples/qml/minehunt/minehunt.qmlproject new file mode 100644 index 0000000000..5aeb78f1ea --- /dev/null +++ b/examples/qml/minehunt/minehunt.qmlproject @@ -0,0 +1,16 @@ +import QmlProject 1.1 + +Project { + mainFile: "minehunt.qml" + + /* Include .qml, .js, and image files from current directory and subdirectories */ + QmlFiles { + directory: "." + } + JavaScriptFiles { + directory: "." + } + ImageFiles { + directory: "." + } +} diff --git a/examples/qml/minehunt/minehunt.qrc b/examples/qml/minehunt/minehunt.qrc new file mode 100644 index 0000000000..fa8e27d383 --- /dev/null +++ b/examples/qml/minehunt/minehunt.qrc @@ -0,0 +1,20 @@ + + + minehunt.qml + MinehuntCore/Explosion.qml + MinehuntCore/Tile.qml + MinehuntCore/qmldir + MinehuntCore/pics/background.png + MinehuntCore/pics/back.png + MinehuntCore/pics/bomb-color.png + MinehuntCore/pics/bomb.png + MinehuntCore/pics/face-sad.png + MinehuntCore/pics/face-smile-big.png + MinehuntCore/pics/face-smile.png + MinehuntCore/pics/flag-color.png + MinehuntCore/pics/flag.png + MinehuntCore/pics/front.png + MinehuntCore/pics/quit.png + MinehuntCore/pics/star.png + + diff --git a/examples/qml/modelviews/abstractitemmodel/abstractitemmodel.pro b/examples/qml/modelviews/abstractitemmodel/abstractitemmodel.pro new file mode 100644 index 0000000000..f786d9356f --- /dev/null +++ b/examples/qml/modelviews/abstractitemmodel/abstractitemmodel.pro @@ -0,0 +1,10 @@ +TEMPLATE = app +TARGET = abstractitemmodel +DEPENDPATH += . +INCLUDEPATH += . +QT += qml quick + +HEADERS = model.h +SOURCES = main.cpp \ + model.cpp +RESOURCES += abstractitemmodel.qrc diff --git a/examples/qml/modelviews/abstractitemmodel/abstractitemmodel.qrc b/examples/qml/modelviews/abstractitemmodel/abstractitemmodel.qrc new file mode 100644 index 0000000000..4ae861cb3d --- /dev/null +++ b/examples/qml/modelviews/abstractitemmodel/abstractitemmodel.qrc @@ -0,0 +1,6 @@ + + + view.qml + + + diff --git a/examples/qml/modelviews/abstractitemmodel/main.cpp b/examples/qml/modelviews/abstractitemmodel/main.cpp new file mode 100644 index 0000000000..f5930ce840 --- /dev/null +++ b/examples/qml/modelviews/abstractitemmodel/main.cpp @@ -0,0 +1,70 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include "model.h" + +#include +#include +#include +#include +#include +#include + +//![0] +int main(int argc, char ** argv) +{ + QGuiApplication app(argc, argv); + + AnimalModel model; + model.addAnimal(Animal("Wolf", "Medium")); + model.addAnimal(Animal("Polar bear", "Large")); + model.addAnimal(Animal("Quoll", "Small")); + + QQuickView view; + view.setResizeMode(QQuickView::SizeRootObjectToView); + QQmlContext *ctxt = view.rootContext(); + ctxt->setContextProperty("myModel", &model); +//![0] + + view.setSource(QUrl("qrc:view.qml")); + view.show(); + + return app.exec(); +} + diff --git a/examples/qml/modelviews/abstractitemmodel/model.cpp b/examples/qml/modelviews/abstractitemmodel/model.cpp new file mode 100644 index 0000000000..8f7649c0d4 --- /dev/null +++ b/examples/qml/modelviews/abstractitemmodel/model.cpp @@ -0,0 +1,90 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include "model.h" + +Animal::Animal(const QString &type, const QString &size) + : m_type(type), m_size(size) +{ +} + +QString Animal::type() const +{ + return m_type; +} + +QString Animal::size() const +{ + return m_size; +} + +//![0] +AnimalModel::AnimalModel(QObject *parent) + : QAbstractListModel(parent) +{ + QHash roles; + roles[TypeRole] = "type"; + roles[SizeRole] = "size"; + setRoleNames(roles); +} +//![0] + +void AnimalModel::addAnimal(const Animal &animal) +{ + beginInsertRows(QModelIndex(), rowCount(), rowCount()); + m_animals << animal; + endInsertRows(); +} + +int AnimalModel::rowCount(const QModelIndex & parent) const { + return m_animals.count(); +} + +QVariant AnimalModel::data(const QModelIndex & index, int role) const { + if (index.row() < 0 || index.row() >= m_animals.count()) + return QVariant(); + + const Animal &animal = m_animals[index.row()]; + if (role == TypeRole) + return animal.type(); + else if (role == SizeRole) + return animal.size(); + return QVariant(); +} + diff --git a/examples/qml/modelviews/abstractitemmodel/model.h b/examples/qml/modelviews/abstractitemmodel/model.h new file mode 100644 index 0000000000..1378c4487e --- /dev/null +++ b/examples/qml/modelviews/abstractitemmodel/model.h @@ -0,0 +1,83 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include +#include + +//![0] +class Animal +{ +public: + Animal(const QString &type, const QString &size); +//![0] + + QString type() const; + QString size() const; + +private: + QString m_type; + QString m_size; +//![1] +}; + +class AnimalModel : public QAbstractListModel +{ + Q_OBJECT +public: + enum AnimalRoles { + TypeRole = Qt::UserRole + 1, + SizeRole + }; + + AnimalModel(QObject *parent = 0); +//![1] + + void addAnimal(const Animal &animal); + + int rowCount(const QModelIndex & parent = QModelIndex()) const; + + QVariant data(const QModelIndex & index, int role = Qt::DisplayRole) const; + +private: + QList m_animals; +//![2] +}; +//![2] + + diff --git a/examples/qml/modelviews/abstractitemmodel/view.qml b/examples/qml/modelviews/abstractitemmodel/view.qml new file mode 100644 index 0000000000..64f5871d4b --- /dev/null +++ b/examples/qml/modelviews/abstractitemmodel/view.qml @@ -0,0 +1,50 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +import QtQuick 2.0 + +//![0] +ListView { + width: 200; height: 250 + + model: myModel + delegate: Text { text: "Animal: " + type + ", " + size } +} +//![0] + diff --git a/examples/qml/modelviews/gridview/gridview-example.qml b/examples/qml/modelviews/gridview/gridview-example.qml new file mode 100644 index 0000000000..ea3bb5cec9 --- /dev/null +++ b/examples/qml/modelviews/gridview/gridview-example.qml @@ -0,0 +1,93 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Rectangle { + width: 300; height: 400 + color: "white" + + ListModel { + id: appModel + ListElement { name: "Music"; icon: "pics/AudioPlayer_48.png" } + ListElement { name: "Movies"; icon: "pics/VideoPlayer_48.png" } + ListElement { name: "Camera"; icon: "pics/Camera_48.png" } + ListElement { name: "Calendar"; icon: "pics/DateBook_48.png" } + ListElement { name: "Messaging"; icon: "pics/EMail_48.png" } + ListElement { name: "Todo List"; icon: "pics/TodoList_48.png" } + ListElement { name: "Contacts"; icon: "pics/AddressBook_48.png" } + } + + Component { + id: appDelegate + + Item { + width: 100; height: 100 + + Image { + id: myIcon + y: 20; anchors.horizontalCenter: parent.horizontalCenter + source: icon + } + Text { + anchors { top: myIcon.bottom; horizontalCenter: parent.horizontalCenter } + text: name + } + MouseArea { + anchors.fill: parent + onClicked: parent.GridView.view.currentIndex = index + } + } + } + + Component { + id: appHighlight + Rectangle { width: 80; height: 80; color: "lightsteelblue" } + } + + GridView { + anchors.fill: parent + cellWidth: 100; cellHeight: 100 + highlight: appHighlight + focus: true + model: appModel + delegate: appDelegate + } +} diff --git a/examples/qml/modelviews/gridview/pics/AddressBook_48.png b/examples/qml/modelviews/gridview/pics/AddressBook_48.png new file mode 100644 index 0000000000..1ab7c8eec1 Binary files /dev/null and b/examples/qml/modelviews/gridview/pics/AddressBook_48.png differ diff --git a/examples/qml/modelviews/gridview/pics/AudioPlayer_48.png b/examples/qml/modelviews/gridview/pics/AudioPlayer_48.png new file mode 100644 index 0000000000..f4b8689f87 Binary files /dev/null and b/examples/qml/modelviews/gridview/pics/AudioPlayer_48.png differ diff --git a/examples/qml/modelviews/gridview/pics/Camera_48.png b/examples/qml/modelviews/gridview/pics/Camera_48.png new file mode 100644 index 0000000000..c76b524945 Binary files /dev/null and b/examples/qml/modelviews/gridview/pics/Camera_48.png differ diff --git a/examples/qml/modelviews/gridview/pics/DateBook_48.png b/examples/qml/modelviews/gridview/pics/DateBook_48.png new file mode 100644 index 0000000000..58f5787fb8 Binary files /dev/null and b/examples/qml/modelviews/gridview/pics/DateBook_48.png differ diff --git a/examples/qml/modelviews/gridview/pics/EMail_48.png b/examples/qml/modelviews/gridview/pics/EMail_48.png new file mode 100644 index 0000000000..d6d84a61be Binary files /dev/null and b/examples/qml/modelviews/gridview/pics/EMail_48.png differ diff --git a/examples/qml/modelviews/gridview/pics/TodoList_48.png b/examples/qml/modelviews/gridview/pics/TodoList_48.png new file mode 100644 index 0000000000..0988448d9b Binary files /dev/null and b/examples/qml/modelviews/gridview/pics/TodoList_48.png differ diff --git a/examples/qml/modelviews/gridview/pics/VideoPlayer_48.png b/examples/qml/modelviews/gridview/pics/VideoPlayer_48.png new file mode 100644 index 0000000000..52638c50a7 Binary files /dev/null and b/examples/qml/modelviews/gridview/pics/VideoPlayer_48.png differ diff --git a/examples/qml/modelviews/listview/content/PetsModel.qml b/examples/qml/modelviews/listview/content/PetsModel.qml new file mode 100644 index 0000000000..4f2087d95e --- /dev/null +++ b/examples/qml/modelviews/listview/content/PetsModel.qml @@ -0,0 +1,98 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +ListModel { + ListElement { + name: "Polly" + type: "Parrot" + age: 12 + size: "Small" + } + ListElement { + name: "Penny" + type: "Turtle" + age: 4 + size: "Small" + } + ListElement { + name: "Warren" + type: "Rabbit" + age: 2 + size: "Small" + } + ListElement { + name: "Spot" + type: "Dog" + age: 9 + size: "Medium" + } + ListElement { + name: "Schrödinger" + type: "Cat" + age: 2 + size: "Medium" + } + ListElement { + name: "Joey" + type: "Kangaroo" + age: 1 + size: "Medium" + } + ListElement { + name: "Kimba" + type: "Bunny" + age: 65 + size: "Large" + } + ListElement { + name: "Rover" + type: "Dog" + age: 5 + size: "Large" + } + ListElement { + name: "Tiny" + type: "Elephant" + age: 15 + size: "Large" + } +} diff --git a/examples/qml/modelviews/listview/content/PressAndHoldButton.qml b/examples/qml/modelviews/listview/content/PressAndHoldButton.qml new file mode 100644 index 0000000000..b20d8f64f1 --- /dev/null +++ b/examples/qml/modelviews/listview/content/PressAndHoldButton.qml @@ -0,0 +1,82 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Image { + id: container + + property int repeatDelay: 300 + property int repeatDuration: 75 + property bool pressed: false + + signal clicked + + scale: pressed ? 0.9 : 1 + + function release() { + autoRepeatClicks.stop() + container.pressed = false + } + + SequentialAnimation on pressed { + id: autoRepeatClicks + running: false + + PropertyAction { target: container; property: "pressed"; value: true } + ScriptAction { script: container.clicked() } + PauseAnimation { duration: repeatDelay } + + SequentialAnimation { + loops: Animation.Infinite + ScriptAction { script: container.clicked() } + PauseAnimation { duration: repeatDuration } + } + } + + MouseArea { + anchors.fill: parent + + onPressed: autoRepeatClicks.start() + onReleased: container.release() + onCanceled: container.release() + } +} + diff --git a/examples/qml/modelviews/listview/content/RecipesModel.qml b/examples/qml/modelviews/listview/content/RecipesModel.qml new file mode 100644 index 0000000000..86210ba436 --- /dev/null +++ b/examples/qml/modelviews/listview/content/RecipesModel.qml @@ -0,0 +1,129 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +ListModel { + ListElement { + title: "Pancakes" + picture: "content/pics/pancakes.jpg" + ingredients: " +
    +
  • 1 cup (150g) self-raising flour +
  • 1 tbs caster sugar +
  • 3/4 cup (185ml) milk +
  • 1 egg +
+ " + method: " +
    +
  1. Sift flour and sugar together into a bowl. Add a pinch of salt. +
  2. Beat milk and egg together, then add to dry ingredients. Beat until smooth. +
  3. Pour mixture into a pan on medium heat and cook until bubbles appear on the surface. +
  4. Turn over and cook other side until golden. +
+ " + } + ListElement { + title: "Fruit Salad" + picture: "content/pics/fruit-salad.jpg" + ingredients: "* Seasonal Fruit" + method: "* Chop fruit and place in a bowl." + } + ListElement { + title: "Vegetable Soup" + picture: "content/pics/vegetable-soup.jpg" + ingredients: " +
    +
  • 1 onion +
  • 1 turnip +
  • 1 potato +
  • 1 carrot +
  • 1 head of celery +
  • 1 1/2 litres of water +
+ " + method: " +
    +
  1. Chop vegetables. +
  2. Boil in water until vegetables soften. +
  3. Season with salt and pepper to taste. +
+ " + } + ListElement { + title: "Hamburger" + picture: "content/pics/hamburger.jpg" + ingredients: " +
    +
  • 500g minced beef +
  • Seasoning +
  • lettuce, tomato, onion, cheese +
  • 1 hamburger bun for each burger +
+ " + method: " +
    +
  1. Mix the beef, together with seasoning, in a food processor. +
  2. Shape the beef into burgers. +
  3. Grill the burgers for about 5 mins on each side (until cooked through) +
  4. Serve each burger on a bun with ketchup, cheese, lettuce, tomato and onion. +
+ " + } + ListElement { + title: "Lemonade" + picture: "content/pics/lemonade.jpg" + ingredients: " +
    +
  • 1 cup Lemon Juice +
  • 1 cup Sugar +
  • 6 Cups of Water (2 cups warm water, 4 cups cold water) +
+ " + method: " +
    +
  1. Pour 2 cups of warm water into a pitcher and stir in sugar until it dissolves. +
  2. Pour in lemon juice, stir again, and add 4 cups of cold water. +
  3. Chill or serve over ice cubes. +
+ " + } +} diff --git a/examples/qml/modelviews/listview/content/TextButton.qml b/examples/qml/modelviews/listview/content/TextButton.qml new file mode 100644 index 0000000000..980ee21553 --- /dev/null +++ b/examples/qml/modelviews/listview/content/TextButton.qml @@ -0,0 +1,78 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Rectangle { + id: container + + property alias text: label.text + + signal clicked + + width: label.width + 20; height: label.height + 6 + smooth: true + radius: 10 + + gradient: Gradient { + GradientStop { id: gradientStop; position: 0.0; color: palette.light } + GradientStop { position: 1.0; color: palette.button } + } + + SystemPalette { id: palette } + + MouseArea { + id: mouseArea + anchors.fill: parent + onClicked: { container.clicked() } + } + + Text { + id: label + anchors.centerIn: parent + } + + states: State { + name: "pressed" + when: mouseArea.pressed + PropertyChanges { target: gradientStop; color: palette.dark } + } +} + diff --git a/examples/qml/modelviews/listview/content/ToggleButton.qml b/examples/qml/modelviews/listview/content/ToggleButton.qml new file mode 100644 index 0000000000..52f4988f03 --- /dev/null +++ b/examples/qml/modelviews/listview/content/ToggleButton.qml @@ -0,0 +1,58 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtQml module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Rectangle { + id: root + property alias label: text.text + property bool active: false + signal toggled + width: 149 + height: 30 + radius: 3 + color: active ? "green" : "lightgray" + border.width: 1 + Text { id: text; anchors.centerIn: parent; font.pixelSize: 14 } + MouseArea { + anchors.fill: parent + onClicked: { active = !active; root.toggled() } + } +} diff --git a/examples/qml/modelviews/listview/content/pics/arrow-down.png b/examples/qml/modelviews/listview/content/pics/arrow-down.png new file mode 100644 index 0000000000..29d1d4439a Binary files /dev/null and b/examples/qml/modelviews/listview/content/pics/arrow-down.png differ diff --git a/examples/qml/modelviews/listview/content/pics/arrow-up.png b/examples/qml/modelviews/listview/content/pics/arrow-up.png new file mode 100644 index 0000000000..e437312217 Binary files /dev/null and b/examples/qml/modelviews/listview/content/pics/arrow-up.png differ diff --git a/examples/qml/modelviews/listview/content/pics/fruit-salad.jpg b/examples/qml/modelviews/listview/content/pics/fruit-salad.jpg new file mode 100644 index 0000000000..da5a6b10a2 Binary files /dev/null and b/examples/qml/modelviews/listview/content/pics/fruit-salad.jpg differ diff --git a/examples/qml/modelviews/listview/content/pics/hamburger.jpg b/examples/qml/modelviews/listview/content/pics/hamburger.jpg new file mode 100644 index 0000000000..d0a15be1bf Binary files /dev/null and b/examples/qml/modelviews/listview/content/pics/hamburger.jpg differ diff --git a/examples/qml/modelviews/listview/content/pics/lemonade.jpg b/examples/qml/modelviews/listview/content/pics/lemonade.jpg new file mode 100644 index 0000000000..db445c9ac8 Binary files /dev/null and b/examples/qml/modelviews/listview/content/pics/lemonade.jpg differ diff --git a/examples/qml/modelviews/listview/content/pics/list-delete.png b/examples/qml/modelviews/listview/content/pics/list-delete.png new file mode 100644 index 0000000000..df2a147d24 Binary files /dev/null and b/examples/qml/modelviews/listview/content/pics/list-delete.png differ diff --git a/examples/qml/modelviews/listview/content/pics/minus-sign.png b/examples/qml/modelviews/listview/content/pics/minus-sign.png new file mode 100644 index 0000000000..d6f233d739 Binary files /dev/null and b/examples/qml/modelviews/listview/content/pics/minus-sign.png differ diff --git a/examples/qml/modelviews/listview/content/pics/moreDown.png b/examples/qml/modelviews/listview/content/pics/moreDown.png new file mode 100644 index 0000000000..31a35d5c20 Binary files /dev/null and b/examples/qml/modelviews/listview/content/pics/moreDown.png differ diff --git a/examples/qml/modelviews/listview/content/pics/moreUp.png b/examples/qml/modelviews/listview/content/pics/moreUp.png new file mode 100644 index 0000000000..fefb9c9098 Binary files /dev/null and b/examples/qml/modelviews/listview/content/pics/moreUp.png differ diff --git a/examples/qml/modelviews/listview/content/pics/pancakes.jpg b/examples/qml/modelviews/listview/content/pics/pancakes.jpg new file mode 100644 index 0000000000..60c439638e Binary files /dev/null and b/examples/qml/modelviews/listview/content/pics/pancakes.jpg differ diff --git a/examples/qml/modelviews/listview/content/pics/plus-sign.png b/examples/qml/modelviews/listview/content/pics/plus-sign.png new file mode 100644 index 0000000000..40df1134f8 Binary files /dev/null and b/examples/qml/modelviews/listview/content/pics/plus-sign.png differ diff --git a/examples/qml/modelviews/listview/content/pics/vegetable-soup.jpg b/examples/qml/modelviews/listview/content/pics/vegetable-soup.jpg new file mode 100644 index 0000000000..9dce332041 Binary files /dev/null and b/examples/qml/modelviews/listview/content/pics/vegetable-soup.jpg differ diff --git a/examples/qml/modelviews/listview/dynamiclist.qml b/examples/qml/modelviews/listview/dynamiclist.qml new file mode 100644 index 0000000000..ee7c6329bc --- /dev/null +++ b/examples/qml/modelviews/listview/dynamiclist.qml @@ -0,0 +1,203 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +import QtQuick 2.0 +import "content" + +// This example shows how items can be dynamically added to and removed from +// a ListModel, and how these list modifications can be animated. + +Rectangle { + id: container + width: 500; height: 400 + color: "#343434" + + // The model: + ListModel { + id: fruitModel + + ListElement { + name: "Apple"; cost: 2.45 + attributes: [ + ListElement { description: "Core" }, + ListElement { description: "Deciduous" } + ] + } + ListElement { + name: "Banana"; cost: 1.95 + attributes: [ + ListElement { description: "Tropical" }, + ListElement { description: "Seedless" } + ] + } + ListElement { + name: "Cumquat"; cost: 3.25 + attributes: [ + ListElement { description: "Citrus" } + ] + } + ListElement { + name: "Durian"; cost: 9.95 + attributes: [ + ListElement { description: "Tropical" }, + ListElement { description: "Smelly" } + ] + } + } + + // The delegate for each fruit in the model: + Component { + id: listDelegate + + Item { + id: delegateItem + width: listView.width; height: 55 + clip: true + + Row { + anchors.verticalCenter: parent.verticalCenter + spacing: 10 + + Column { + Image { + source: "content/pics/arrow-up.png" + MouseArea { anchors.fill: parent; onClicked: fruitModel.move(index, index-1, 1) } + } + Image { source: "content/pics/arrow-down.png" + MouseArea { anchors.fill: parent; onClicked: fruitModel.move(index, index+1, 1) } + } + } + + Column { + anchors.verticalCenter: parent.verticalCenter + + Text { + text: name + font.pixelSize: 15 + color: "white" + } + Row { + spacing: 5 + Repeater { + model: attributes + Text { text: description; color: "White" } + } + } + } + } + + Row { + anchors.verticalCenter: parent.verticalCenter + anchors.right: parent.right + spacing: 10 + + PressAndHoldButton { + anchors.verticalCenter: parent.verticalCenter + source: "content/pics/plus-sign.png" + onClicked: fruitModel.setProperty(index, "cost", cost + 0.25) + } + + Text { + id: costText + anchors.verticalCenter: parent.verticalCenter + text: '$' + Number(cost).toFixed(2) + font.pixelSize: 15 + color: "white" + font.bold: true + } + + PressAndHoldButton { + anchors.verticalCenter: parent.verticalCenter + source: "content/pics/minus-sign.png" + onClicked: fruitModel.setProperty(index, "cost", Math.max(0,cost-0.25)) + } + + Image { + source: "content/pics/list-delete.png" + MouseArea { anchors.fill:parent; onClicked: fruitModel.remove(index) } + } + } + + // Animate adding and removing of items: + + ListView.onAdd: SequentialAnimation { + PropertyAction { target: delegateItem; property: "height"; value: 0 } + NumberAnimation { target: delegateItem; property: "height"; to: 55; duration: 250; easing.type: Easing.InOutQuad } + } + + ListView.onRemove: SequentialAnimation { + PropertyAction { target: delegateItem; property: "ListView.delayRemove"; value: true } + NumberAnimation { target: delegateItem; property: "height"; to: 0; duration: 250; easing.type: Easing.InOutQuad } + + // Make sure delayRemove is set back to false so that the item can be destroyed + PropertyAction { target: delegateItem; property: "ListView.delayRemove"; value: false } + } + } + } + + // The view: + ListView { + id: listView + anchors.fill: parent; anchors.margins: 20 + model: fruitModel + delegate: listDelegate + } + + Row { + anchors { left: parent.left; bottom: parent.bottom; margins: 20 } + spacing: 10 + + TextButton { + text: "Add an item" + onClicked: { + fruitModel.append({ + "name": "Pizza Margarita", + "cost": 5.95, + "attributes": [{"description": "Cheese"}, {"description": "Tomato"}] + }) + } + } + + TextButton { + text: "Remove all items" + onClicked: fruitModel.clear() + } + } +} + diff --git a/examples/qml/modelviews/listview/expandingdelegates.qml b/examples/qml/modelviews/listview/expandingdelegates.qml new file mode 100644 index 0000000000..43a9662422 --- /dev/null +++ b/examples/qml/modelviews/listview/expandingdelegates.qml @@ -0,0 +1,202 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import "content" + +// This example illustrates expanding a list item to show a more detailed view. + +Rectangle { + id: page + width: 400; height: 240 + color: "black" + + // Delegate for the recipes. This delegate has two modes: + // 1. List mode (default), which just shows the picture and title of the recipe. + // 2. Details mode, which also shows the ingredients and method. + Component { + id: recipeDelegate + + Item { + id: recipe + + // Create a property to contain the visibility of the details. + // We can bind multiple element's opacity to this one property, + // rather than having a "PropertyChanges" line for each element we + // want to fade. + property real detailsOpacity : 0 + + width: listView.width + height: 70 + + // A simple rounded rectangle for the background + Rectangle { + id: background + x: 2; y: 2; width: parent.width - x*2; height: parent.height - y*2 + color: "ivory" + border.color: "orange" + radius: 5 + } + + // This mouse region covers the entire delegate. + // When clicked it changes mode to 'Details'. If we are already + // in Details mode, then no change will happen. + MouseArea { + anchors.fill: parent + onClicked: recipe.state = 'Details'; + } + + // Lay out the page: picture, title and ingredients at the top, and method at the + // bottom. Note that elements that should not be visible in the list + // mode have their opacity set to recipe.detailsOpacity. + Row { + id: topLayout + x: 10; y: 10; height: recipeImage.height; width: parent.width + spacing: 10 + + Image { + id: recipeImage + width: 50; height: 50 + source: picture + } + + Column { + width: background.width - recipeImage.width - 20; height: recipeImage.height + spacing: 5 + + Text { + text: title + font.bold: true; font.pointSize: 16 + } + + Text { + text: "Ingredients" + font.pointSize: 12; font.bold: true + opacity: recipe.detailsOpacity + } + + Text { + text: ingredients + wrapMode: Text.WordWrap + width: parent.width + opacity: recipe.detailsOpacity + } + } + } + + Item { + id: details + x: 10; width: parent.width - 20 + anchors { top: topLayout.bottom; topMargin: 10; bottom: parent.bottom; bottomMargin: 10 } + opacity: recipe.detailsOpacity + + Text { + id: methodTitle + anchors.top: parent.top + text: "Method" + font.pointSize: 12; font.bold: true + } + + Flickable { + id: flick + width: parent.width + anchors { top: methodTitle.bottom; bottom: parent.bottom } + contentHeight: methodText.height + clip: true + + Text { id: methodText; text: method; wrapMode: Text.WordWrap; width: details.width } + } + + Image { + anchors { right: flick.right; top: flick.top } + source: "content/pics/moreUp.png" + opacity: flick.atYBeginning ? 0 : 1 + } + + Image { + anchors { right: flick.right; bottom: flick.bottom } + source: "content/pics/moreDown.png" + opacity: flick.atYEnd ? 0 : 1 + } + } + + // A button to close the detailed view, i.e. set the state back to default (''). + TextButton { + y: 10 + anchors { right: background.right; rightMargin: 10 } + opacity: recipe.detailsOpacity + text: "Close" + + onClicked: recipe.state = ''; + } + + states: State { + name: "Details" + + PropertyChanges { target: background; color: "white" } + PropertyChanges { target: recipeImage; width: 130; height: 130 } // Make picture bigger + PropertyChanges { target: recipe; detailsOpacity: 1; x: 0 } // Make details visible + PropertyChanges { target: recipe; height: listView.height } // Fill the entire list area with the detailed view + + // Move the list so that this item is at the top. + PropertyChanges { target: recipe.ListView.view; explicit: true; contentY: recipe.y } + + // Disallow flicking while we're in detailed view + PropertyChanges { target: recipe.ListView.view; interactive: false } + } + + transitions: Transition { + // Make the state changes smooth + ParallelAnimation { + ColorAnimation { property: "color"; duration: 500 } + NumberAnimation { duration: 300; properties: "detailsOpacity,x,contentY,height,width" } + } + } + } + } + + // The actual list + ListView { + id: listView + anchors.fill: parent + model: RecipesModel {} + delegate: recipeDelegate + } +} diff --git a/examples/qml/modelviews/listview/highlight.qml b/examples/qml/modelviews/listview/highlight.qml new file mode 100644 index 0000000000..d8f76080e6 --- /dev/null +++ b/examples/qml/modelviews/listview/highlight.qml @@ -0,0 +1,99 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +// This example shows how to create your own highlight delegate for a ListView +// that uses a SpringAnimation to provide custom movement when the +// highlight bar is moved between items. + +import QtQuick 2.0 +import "content" + +Rectangle { + width: 200; height: 300 + + // Define a delegate component. A component will be + // instantiated for each visible item in the list. + Component { + id: petDelegate + Item { + id: wrapper + width: 200; height: 55 + Column { + Text { text: 'Name: ' + name } + Text { text: 'Type: ' + type } + Text { text: 'Age: ' + age } + } + // indent the item if it is the current item + states: State { + name: "Current" + when: wrapper.ListView.isCurrentItem + PropertyChanges { target: wrapper; x: 20 } + } + transitions: Transition { + NumberAnimation { properties: "x"; duration: 200 } + } + } + } + + // Define a highlight with customised movement between items. + Component { + id: highlightBar + Rectangle { + width: 200; height: 50 + color: "#FFFF88" + y: listView.currentItem.y; + Behavior on y { SpringAnimation { spring: 2; damping: 0.1 } } + } + } + + ListView { + id: listView + width: 200; height: parent.height + + model: PetsModel {} + delegate: petDelegate + focus: true + + // Set the highlight delegate. Note we must also set highlightFollowsCurrentItem + // to false so the highlight delegate can control how the highlight is moved. + highlight: highlightBar + highlightFollowsCurrentItem: false + } +} diff --git a/examples/qml/modelviews/listview/highlightranges.qml b/examples/qml/modelviews/listview/highlightranges.qml new file mode 100644 index 0000000000..a536ddcbb2 --- /dev/null +++ b/examples/qml/modelviews/listview/highlightranges.qml @@ -0,0 +1,122 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import "content" + +Rectangle { + id: root + property int current: 0 + width: 600; height: 300 + + // This example shows the same model in three different ListView items, + // with different highlight ranges. The highlight ranges are set by the + // preferredHighlightBegin and preferredHighlightEnd properties in ListView. + // + // The first ListView does not set a highlight range, so its currentItem + // can move freely within the visible area. If it moves outside the + // visible area, the view is automatically scrolled to keep the current + // item visible. + // + // The second ListView sets a highlight range which attempts to keep the + // current item within the the bounds of the range. However, + // items will not scroll beyond the beginning or end of the view, + // forcing the highlight to move outside the range at the ends. + // + // The third ListView sets the highlightRangeMode to StrictlyEnforceRange + // and sets a range smaller than the height of an item. This + // forces the current item to change when the view is flicked, + // since the highlight is unable to move. + // + // All ListViews bind their currentIndex to the root.current property. + // The first ListView sets root.current whenever its currentIndex changes + // due to keyboard interaction. + // Flicking the third ListView with the mouse also changes root.current. + + ListView { + id: list1 + width: 200; height: parent.height + model: PetsModel {} + delegate: petDelegate + + highlight: Rectangle { color: "lightsteelblue" } + currentIndex: root.current + onCurrentIndexChanged: root.current = currentIndex + focus: true + } + + ListView { + id: list2 + x: list1.width + width: 200; height: parent.height + model: PetsModel {} + delegate: petDelegate + + highlight: Rectangle { color: "yellow" } + currentIndex: root.current + preferredHighlightBegin: 80; preferredHighlightEnd: 220 + highlightRangeMode: ListView.ApplyRange + } + + ListView { + id: list3 + x: list1.width + list2.width + width: 200; height: parent.height + model: PetsModel {} + delegate: petDelegate + + highlight: Rectangle { color: "yellow" } + currentIndex: root.current + onCurrentIndexChanged: root.current = currentIndex + preferredHighlightBegin: 125; preferredHighlightEnd: 125 + highlightRangeMode: ListView.StrictlyEnforceRange + } + + // The delegate for each list + Component { + id: petDelegate + Column { + width: 200 + Text { text: 'Name: ' + name } + Text { text: 'Type: ' + type } + Text { text: 'Age: ' + age } + } + } +} diff --git a/examples/qml/modelviews/listview/sections.qml b/examples/qml/modelviews/listview/sections.qml new file mode 100644 index 0000000000..2e63a86bb6 --- /dev/null +++ b/examples/qml/modelviews/listview/sections.qml @@ -0,0 +1,127 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +// This example shows how a ListView can be separated into sections using +// the ListView.section attached property. + +import QtQuick 2.0 +import "content" + +Rectangle { + id: container + width: 300 + height: 360 + + ListModel { + id: animalsModel + ListElement { name: "Ant"; size: "Tiny" } + ListElement { name: "Flea"; size: "Tiny" } + ListElement { name: "Parrot"; size: "Small" } + ListElement { name: "Guinea pig"; size: "Small" } + ListElement { name: "Rat"; size: "Small" } + ListElement { name: "Butterfly"; size: "Small" } + ListElement { name: "Dog"; size: "Medium" } + ListElement { name: "Cat"; size: "Medium" } + ListElement { name: "Pony"; size: "Medium" } + ListElement { name: "Koala"; size: "Medium" } + ListElement { name: "Horse"; size: "Large" } + ListElement { name: "Tiger"; size: "Large" } + ListElement { name: "Giraffe"; size: "Large" } + ListElement { name: "Elephant"; size: "Huge" } + ListElement { name: "Whale"; size: "Huge" } + } + +//! [0] + // The delegate for each section header + Component { + id: sectionHeading + Rectangle { + width: container.width + height: childrenRect.height + color: "lightsteelblue" + + Text { + text: section + font.bold: true + font.pixelSize: 20 + } + } + } + + ListView { + id: view + anchors.top: parent.top + anchors.bottom: buttonBar.top + width: parent.width + model: animalsModel + delegate: Text { text: name; font.pixelSize: 18 } + + section.property: "size" + section.criteria: ViewSection.FullString + section.delegate: sectionHeading + } +//! [0] + + Row { + id: buttonBar + anchors.bottom: parent.bottom + anchors.bottomMargin: 1 + spacing: 1 + ToggleButton { + label: "CurrentLabelAtStart" + onToggled: { + if (active) + view.section.labelPositioning |= ViewSection.CurrentLabelAtStart + else + view.section.labelPositioning &= ~ViewSection.CurrentLabelAtStart + } + } + ToggleButton { + label: "NextLabelAtEnd" + onToggled: { + if (active) + view.section.labelPositioning |= ViewSection.NextLabelAtEnd + else + view.section.labelPositioning &= ~ViewSection.NextLabelAtEnd + } + } + } +} + diff --git a/examples/qml/modelviews/modelviews.pro b/examples/qml/modelviews/modelviews.pro new file mode 100644 index 0000000000..7748da0471 --- /dev/null +++ b/examples/qml/modelviews/modelviews.pro @@ -0,0 +1,8 @@ +TEMPLATE = subdirs + +SUBDIRS += \ + abstractitemmodel \ + objectlistmodel \ + stringlistmodel + + diff --git a/examples/qml/modelviews/modelviews.qml b/examples/qml/modelviews/modelviews.qml new file mode 100644 index 0000000000..86b10ca4ba --- /dev/null +++ b/examples/qml/modelviews/modelviews.qml @@ -0,0 +1,64 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import "../shared" + +Item { + height: 480 + width: 480 + LauncherList { + id: ll + anchors.fill: parent + Component.onCompleted: { + addExample("Dynamic List", "A ListView harboring dynamic data", Qt.resolvedUrl("listview/dynamiclist.qml")); + addExample("Expanding Delegates", "Delegates that expand to fill the list when clicked", Qt.resolvedUrl("listview/expandingdelegates.qml")); + addExample("Highlight", "Adding a highlight to the current item", Qt.resolvedUrl("listview/highlight.qml")); + addExample("Sections", "A ListView with section headers", Qt.resolvedUrl("listview/sections.qml")); + addExample("GridView", "A view laid out in a grid", Qt.resolvedUrl("gridview/gridview-example.qml")); + addExample("PathView", "A view laid out along a path", Qt.resolvedUrl("pathview/pathview-example.qml")); + addExample("Package", "Using a package to transition items between views", Qt.resolvedUrl("package/view.qml")); + addExample("Parallax", "Adds a background and a parallax effect to a ListView", Qt.resolvedUrl("parallax/parallax.qml")); + addExample("Slideshow", "A model demonstrating delayed image loading", Qt.resolvedUrl("visualdatamodel/slideshow.qml")); + addExample("Sorted Model", "Two views on a model, one of which is sorted", Qt.resolvedUrl("visualdatamodel/sortedmodel.qml")); + addExample("VisualItemModel", "A model that consists of the actual Items", Qt.resolvedUrl("visualitemmodel/visualitemmodel.qml")); + } + } +} diff --git a/examples/qml/modelviews/modelviews.qmlproject b/examples/qml/modelviews/modelviews.qmlproject new file mode 100644 index 0000000000..40f9e568fd --- /dev/null +++ b/examples/qml/modelviews/modelviews.qmlproject @@ -0,0 +1,16 @@ +import QmlProject 1.1 + +Project { + mainFile: "modelviews.qml" + + /* Include .qml, .js, and image files from current directory and subdirectories */ + QmlFiles { + directory: "." + } + JavaScriptFiles { + directory: "." + } + ImageFiles { + directory: "." + } +} diff --git a/examples/qml/modelviews/objectlistmodel/dataobject.cpp b/examples/qml/modelviews/objectlistmodel/dataobject.cpp new file mode 100644 index 0000000000..7216283616 --- /dev/null +++ b/examples/qml/modelviews/objectlistmodel/dataobject.cpp @@ -0,0 +1,78 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include "dataobject.h" + +DataObject::DataObject(QObject *parent) + : QObject(parent) +{ +} + +DataObject::DataObject(const QString &name, const QString &color, QObject *parent) + : QObject(parent), m_name(name), m_color(color) +{ +} + +QString DataObject::name() const +{ + return m_name; +} + +void DataObject::setName(const QString &name) +{ + if (name != m_name) { + m_name = name; + emit nameChanged(); + } +} + +QString DataObject::color() const +{ + return m_color; +} + +void DataObject::setColor(const QString &color) +{ + if (color != m_color) { + m_color = color; + emit colorChanged(); + } +} diff --git a/examples/qml/modelviews/objectlistmodel/dataobject.h b/examples/qml/modelviews/objectlistmodel/dataobject.h new file mode 100644 index 0000000000..bea92a273c --- /dev/null +++ b/examples/qml/modelviews/objectlistmodel/dataobject.h @@ -0,0 +1,76 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef DATAOBJECT_H +#define DATAOBJECT_H + +#include + +//![0] +class DataObject : public QObject +{ + Q_OBJECT + + Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged) + Q_PROPERTY(QString color READ color WRITE setColor NOTIFY colorChanged) +//![0] + +public: + DataObject(QObject *parent=0); + DataObject(const QString &name, const QString &color, QObject *parent=0); + + QString name() const; + void setName(const QString &name); + + QString color() const; + void setColor(const QString &color); + +signals: + void nameChanged(); + void colorChanged(); + +private: + QString m_name; + QString m_color; +//![1] +}; +//![1] + +#endif // DATAOBJECT_H diff --git a/examples/qml/modelviews/objectlistmodel/main.cpp b/examples/qml/modelviews/objectlistmodel/main.cpp new file mode 100644 index 0000000000..bb3895f7c0 --- /dev/null +++ b/examples/qml/modelviews/objectlistmodel/main.cpp @@ -0,0 +1,78 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the demonstration applications of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include + +#include +#include +#include +#include +#include + +#include "dataobject.h" + +/* + This example illustrates exposing a QList as a + model in QML +*/ + +//![0] +int main(int argc, char ** argv) +{ + QGuiApplication app(argc, argv); + + QList dataList; + dataList.append(new DataObject("Item 1", "red")); + dataList.append(new DataObject("Item 2", "green")); + dataList.append(new DataObject("Item 3", "blue")); + dataList.append(new DataObject("Item 4", "yellow")); + + QQuickView view; + view.setResizeMode(QQuickView::SizeRootObjectToView); + QQmlContext *ctxt = view.rootContext(); + ctxt->setContextProperty("myModel", QVariant::fromValue(dataList)); +//![0] + + view.setSource(QUrl("qrc:view.qml")); + view.show(); + + return app.exec(); +} + diff --git a/examples/qml/modelviews/objectlistmodel/objectlistmodel.pro b/examples/qml/modelviews/objectlistmodel/objectlistmodel.pro new file mode 100644 index 0000000000..7f323c3999 --- /dev/null +++ b/examples/qml/modelviews/objectlistmodel/objectlistmodel.pro @@ -0,0 +1,6 @@ +QT += qml quick + +SOURCES += main.cpp \ + dataobject.cpp +HEADERS += dataobject.h +RESOURCES += objectlistmodel.qrc diff --git a/examples/qml/modelviews/objectlistmodel/objectlistmodel.qmlproject b/examples/qml/modelviews/objectlistmodel/objectlistmodel.qmlproject new file mode 100644 index 0000000000..2bb4016996 --- /dev/null +++ b/examples/qml/modelviews/objectlistmodel/objectlistmodel.qmlproject @@ -0,0 +1,14 @@ +import QmlProject 1.0 + +Project { + /* Include .qml, .js, and image files from current directory and subdirectories */ + QmlFiles { + directory: "." + } + JavaScriptFiles { + directory: "." + } + ImageFiles { + directory: "." + } +} diff --git a/examples/qml/modelviews/objectlistmodel/objectlistmodel.qrc b/examples/qml/modelviews/objectlistmodel/objectlistmodel.qrc new file mode 100644 index 0000000000..17e9301471 --- /dev/null +++ b/examples/qml/modelviews/objectlistmodel/objectlistmodel.qrc @@ -0,0 +1,5 @@ + + + view.qml + + diff --git a/examples/qml/modelviews/objectlistmodel/view.qml b/examples/qml/modelviews/objectlistmodel/view.qml new file mode 100644 index 0000000000..3954e79829 --- /dev/null +++ b/examples/qml/modelviews/objectlistmodel/view.qml @@ -0,0 +1,55 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +//![0] +ListView { + width: 100; height: 100 + + model: myModel + delegate: Rectangle { + height: 25 + width: 100 + color: model.modelData.color + Text { text: name } + } +} +//![0] diff --git a/examples/qml/modelviews/package/Delegate.qml b/examples/qml/modelviews/package/Delegate.qml new file mode 100644 index 0000000000..97c7840cb4 --- /dev/null +++ b/examples/qml/modelviews/package/Delegate.qml @@ -0,0 +1,88 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +//![0] +Package { + Text { id: listDelegate; width: 200; height: 25; text: 'Empty'; Package.name: 'list' } + Text { id: gridDelegate; width: 100; height: 50; text: 'Empty'; Package.name: 'grid' } + + Rectangle { + id: wrapper + width: 200; height: 25 + color: 'lightsteelblue' + + Text { text: display; anchors.centerIn: parent } + MouseArea { + anchors.fill: parent + onClicked: { + if (wrapper.state == 'inList') + wrapper.state = 'inGrid'; + else + wrapper.state = 'inList'; + } + } + + state: 'inList' + states: [ + State { + name: 'inList' + ParentChange { target: wrapper; parent: listDelegate } + }, + State { + name: 'inGrid' + ParentChange { + target: wrapper; parent: gridDelegate + x: 0; y: 0; width: gridDelegate.width; height: gridDelegate.height + } + } + ] + + transitions: [ + Transition { + ParentAnimation { + NumberAnimation { properties: 'x,y,width,height'; duration: 300 } + } + } + ] + } +} +//![0] diff --git a/examples/qml/modelviews/package/view.qml b/examples/qml/modelviews/package/view.qml new file mode 100644 index 0000000000..5b2fd9481c --- /dev/null +++ b/examples/qml/modelviews/package/view.qml @@ -0,0 +1,76 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Rectangle { + color: "white" + width: 400 + height: 200 + + ListModel { + id: myModel + ListElement { display: "One" } + ListElement { display: "Two" } + ListElement { display: "Three" } + ListElement { display: "Four" } + ListElement { display: "Five" } + ListElement { display: "Six" } + ListElement { display: "Seven" } + ListElement { display: "Eight" } + } + //![0] + VisualDataModel { + id: visualModel + delegate: Delegate {} + model: myModel + } + + ListView { + width: 200; height:200 + model: visualModel.parts.list + } + GridView { + x: 200; width: 200; height:200 + cellHeight: 50 + model: visualModel.parts.grid + } + //![0] +} diff --git a/examples/qml/modelviews/parallax/content/ParallaxView.qml b/examples/qml/modelviews/parallax/content/ParallaxView.qml new file mode 100644 index 0000000000..2acf50dcef --- /dev/null +++ b/examples/qml/modelviews/parallax/content/ParallaxView.qml @@ -0,0 +1,123 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Item { + id: root + + property alias background: background.source + property int currentIndex: 0 + default property alias content: visualModel.children + + Image { + id: background + fillMode: Image.TileHorizontally + x: -list.contentX / 2 + width: Math.max(list.contentWidth, parent.width) + } + + ListView { + id: list + anchors.fill: parent + + currentIndex: root.currentIndex + onCurrentIndexChanged: root.currentIndex = currentIndex + + orientation: Qt.Horizontal + boundsBehavior: Flickable.DragOverBounds + model: VisualItemModel { id: visualModel } + + highlightRangeMode: ListView.StrictlyEnforceRange + snapMode: ListView.SnapOneItem + } + + ListView { + id: selector + + height: 50 + anchors.bottom: parent.bottom + anchors.horizontalCenter: parent.horizontalCenter + width: Math.min(count * 50, parent.width - 20) + interactive: width == parent.width - 20 + orientation: Qt.Horizontal + + currentIndex: root.currentIndex + onCurrentIndexChanged: root.currentIndex = currentIndex + + model: visualModel.children + delegate: Item { + width: 50; height: 50 + id: delegateRoot + + Image { + id: image + source: modelData.icon + smooth: true + scale: 0.8 + } + + MouseArea { + anchors.fill: parent + onClicked: { root.currentIndex = index } + } + + states: State { + name: "Selected" + when: delegateRoot.ListView.isCurrentItem == true + PropertyChanges { + target: image + scale: 1 + y: -5 + } + } + transitions: Transition { + NumberAnimation { properties: "scale,y" } + } + } + + Rectangle { + color: "#60FFFFFF" + x: -10; y: -10; z: -1 + width: parent.width + 20; height: parent.height + 20 + radius: 10 + } + } +} diff --git a/examples/qml/modelviews/parallax/content/Smiley.qml b/examples/qml/modelviews/parallax/content/Smiley.qml new file mode 100644 index 0000000000..982b6c5d2b --- /dev/null +++ b/examples/qml/modelviews/parallax/content/Smiley.qml @@ -0,0 +1,84 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +// This is taken from the declarative animation/basics/property-animation.qml +// example + +Item { + id: window + width: 320; height: 480 + + Image { + anchors.horizontalCenter: parent.horizontalCenter + y: smiley.minHeight + 58 + source: "pics/shadow.png" + + scale: smiley.y * 0.5 / (smiley.minHeight - smiley.maxHeight) + } + + Image { + id: smiley + property int maxHeight: window.height / 3 + property int minHeight: 2 * window.height / 3 + + anchors.horizontalCenter: parent.horizontalCenter + y: minHeight + source: "pics/face-smile.png" + + SequentialAnimation on y { + loops: Animation.Infinite + + NumberAnimation { + from: smiley.minHeight; to: smiley.maxHeight + easing.type: Easing.OutExpo; duration: 300 + } + + NumberAnimation { + from: smiley.maxHeight; to: smiley.minHeight + easing.type: Easing.OutBounce; duration: 1000 + } + + PauseAnimation { duration: 500 } + } + } +} + diff --git a/examples/qml/modelviews/parallax/content/pics/background.jpg b/examples/qml/modelviews/parallax/content/pics/background.jpg new file mode 100644 index 0000000000..61cca2f138 Binary files /dev/null and b/examples/qml/modelviews/parallax/content/pics/background.jpg differ diff --git a/examples/qml/modelviews/parallax/content/pics/face-smile.png b/examples/qml/modelviews/parallax/content/pics/face-smile.png new file mode 100644 index 0000000000..3d66d72578 Binary files /dev/null and b/examples/qml/modelviews/parallax/content/pics/face-smile.png differ diff --git a/examples/qml/modelviews/parallax/content/pics/home-page.png b/examples/qml/modelviews/parallax/content/pics/home-page.png new file mode 100644 index 0000000000..bd090c3708 Binary files /dev/null and b/examples/qml/modelviews/parallax/content/pics/home-page.png differ diff --git a/examples/qml/modelviews/parallax/content/pics/home-page.svg b/examples/qml/modelviews/parallax/content/pics/home-page.svg new file mode 100644 index 0000000000..4f16958844 --- /dev/null +++ b/examples/qml/modelviews/parallax/content/pics/home-page.svg @@ -0,0 +1,445 @@ + +image/svg+xmlGo HomeJakub Steinerhttp://jimmac.musichall.czhomereturngodefaultuserdirectoryTuomas Kuosmanen + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/examples/qml/modelviews/parallax/content/pics/shadow.png b/examples/qml/modelviews/parallax/content/pics/shadow.png new file mode 100644 index 0000000000..8270565e87 Binary files /dev/null and b/examples/qml/modelviews/parallax/content/pics/shadow.png differ diff --git a/examples/qml/modelviews/parallax/content/pics/yast-joystick.png b/examples/qml/modelviews/parallax/content/pics/yast-joystick.png new file mode 100644 index 0000000000..858cea0301 Binary files /dev/null and b/examples/qml/modelviews/parallax/content/pics/yast-joystick.png differ diff --git a/examples/qml/modelviews/parallax/content/pics/yast-wol.png b/examples/qml/modelviews/parallax/content/pics/yast-wol.png new file mode 100644 index 0000000000..7712180a3b Binary files /dev/null and b/examples/qml/modelviews/parallax/content/pics/yast-wol.png differ diff --git a/examples/qml/modelviews/parallax/parallax.qml b/examples/qml/modelviews/parallax/parallax.qml new file mode 100644 index 0000000000..6981095a80 --- /dev/null +++ b/examples/qml/modelviews/parallax/parallax.qml @@ -0,0 +1,77 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import "../../toys/clocks/content" // for loading the Clock element +import "content" + +Rectangle { + width: 320; height: 480 + + ParallaxView { + id: parallax + anchors.fill: parent + background: "content/pics/background.jpg" + + Item { + property url icon: "content/pics/yast-wol.png" + width: 320; height: 480 + Clock { anchors.centerIn: parent } + } + + Item { + property url icon: "content/pics/home-page.png" + width: 320; height: 480 + Smiley { } + } + + Item { + property url icon: "content/pics/yast-joystick.png" + width: 320; height: 480 + + Loader { + anchors { top: parent.top; topMargin: 10; horizontalCenter: parent.horizontalCenter } + width: 300; height: 400 + clip: true; + source: "../../samegame/samegame.qml" + } + } + } +} diff --git a/examples/qml/modelviews/pathview/pathview-example.qml b/examples/qml/modelviews/pathview/pathview-example.qml new file mode 100644 index 0000000000..6161343830 --- /dev/null +++ b/examples/qml/modelviews/pathview/pathview-example.qml @@ -0,0 +1,107 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Rectangle { + width: 400; height: 240 + color: "white" + + ListModel { + id: appModel + ListElement { name: "Music"; icon: "pics/AudioPlayer_48.png" } + ListElement { name: "Movies"; icon: "pics/VideoPlayer_48.png" } + ListElement { name: "Camera"; icon: "pics/Camera_48.png" } + ListElement { name: "Calendar"; icon: "pics/DateBook_48.png" } + ListElement { name: "Messaging"; icon: "pics/EMail_48.png" } + ListElement { name: "Todo List"; icon: "pics/TodoList_48.png" } + ListElement { name: "Contacts"; icon: "pics/AddressBook_48.png" } + } + + Component { + id: appDelegate + Item { + width: 100; height: 100 + scale: PathView.iconScale + + Image { + id: myIcon + y: 20; anchors.horizontalCenter: parent.horizontalCenter + source: icon + smooth: true + } + Text { + anchors { top: myIcon.bottom; horizontalCenter: parent.horizontalCenter } + text: name + smooth: true + } + + MouseArea { + anchors.fill: parent + onClicked: view.currentIndex = index + } + } + } + + Component { + id: appHighlight + Rectangle { width: 80; height: 80; color: "lightsteelblue" } + } + + PathView { + id: view + anchors.fill: parent + highlight: appHighlight + preferredHighlightBegin: 0.5 + preferredHighlightEnd: 0.5 + focus: true + model: appModel + delegate: appDelegate + path: Path { + startX: 10 + startY: 50 + PathAttribute { name: "iconScale"; value: 0.5 } + PathQuad { x: 200; y: 150; controlX: 50; controlY: 200 } + PathAttribute { name: "iconScale"; value: 1.0 } + PathQuad { x: 390; y: 50; controlX: 350; controlY: 200 } + PathAttribute { name: "iconScale"; value: 0.5 } + } + } +} diff --git a/examples/qml/modelviews/pathview/pics/AddressBook_48.png b/examples/qml/modelviews/pathview/pics/AddressBook_48.png new file mode 100644 index 0000000000..1ab7c8eec1 Binary files /dev/null and b/examples/qml/modelviews/pathview/pics/AddressBook_48.png differ diff --git a/examples/qml/modelviews/pathview/pics/AudioPlayer_48.png b/examples/qml/modelviews/pathview/pics/AudioPlayer_48.png new file mode 100644 index 0000000000..f4b8689f87 Binary files /dev/null and b/examples/qml/modelviews/pathview/pics/AudioPlayer_48.png differ diff --git a/examples/qml/modelviews/pathview/pics/Camera_48.png b/examples/qml/modelviews/pathview/pics/Camera_48.png new file mode 100644 index 0000000000..c76b524945 Binary files /dev/null and b/examples/qml/modelviews/pathview/pics/Camera_48.png differ diff --git a/examples/qml/modelviews/pathview/pics/DateBook_48.png b/examples/qml/modelviews/pathview/pics/DateBook_48.png new file mode 100644 index 0000000000..58f5787fb8 Binary files /dev/null and b/examples/qml/modelviews/pathview/pics/DateBook_48.png differ diff --git a/examples/qml/modelviews/pathview/pics/EMail_48.png b/examples/qml/modelviews/pathview/pics/EMail_48.png new file mode 100644 index 0000000000..d6d84a61be Binary files /dev/null and b/examples/qml/modelviews/pathview/pics/EMail_48.png differ diff --git a/examples/qml/modelviews/pathview/pics/TodoList_48.png b/examples/qml/modelviews/pathview/pics/TodoList_48.png new file mode 100644 index 0000000000..0988448d9b Binary files /dev/null and b/examples/qml/modelviews/pathview/pics/TodoList_48.png differ diff --git a/examples/qml/modelviews/pathview/pics/VideoPlayer_48.png b/examples/qml/modelviews/pathview/pics/VideoPlayer_48.png new file mode 100644 index 0000000000..52638c50a7 Binary files /dev/null and b/examples/qml/modelviews/pathview/pics/VideoPlayer_48.png differ diff --git a/examples/qml/modelviews/stringlistmodel/main.cpp b/examples/qml/modelviews/stringlistmodel/main.cpp new file mode 100644 index 0000000000..12859316a3 --- /dev/null +++ b/examples/qml/modelviews/stringlistmodel/main.cpp @@ -0,0 +1,77 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the demonstration applications of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include + +#include +#include +#include +#include +#include + + +/* + This example illustrates exposing a QStringList as a + model in QML +*/ + +int main(int argc, char ** argv) +{ + QGuiApplication app(argc, argv); + +//![0] + QStringList dataList; + dataList.append("Item 1"); + dataList.append("Item 2"); + dataList.append("Item 3"); + dataList.append("Item 4"); + + QQuickView view; + QQmlContext *ctxt = view.rootContext(); + ctxt->setContextProperty("myModel", QVariant::fromValue(dataList)); +//![0] + + view.setSource(QUrl("qrc:view.qml")); + view.show(); + + return app.exec(); +} + diff --git a/examples/qml/modelviews/stringlistmodel/stringlistmodel.pro b/examples/qml/modelviews/stringlistmodel/stringlistmodel.pro new file mode 100644 index 0000000000..19e62cd1b7 --- /dev/null +++ b/examples/qml/modelviews/stringlistmodel/stringlistmodel.pro @@ -0,0 +1,4 @@ +QT += qml quick + +SOURCES += main.cpp +RESOURCES += stringlistmodel.qrc diff --git a/examples/qml/modelviews/stringlistmodel/stringlistmodel.qrc b/examples/qml/modelviews/stringlistmodel/stringlistmodel.qrc new file mode 100644 index 0000000000..17e9301471 --- /dev/null +++ b/examples/qml/modelviews/stringlistmodel/stringlistmodel.qrc @@ -0,0 +1,5 @@ + + + view.qml + + diff --git a/examples/qml/modelviews/stringlistmodel/view.qml b/examples/qml/modelviews/stringlistmodel/view.qml new file mode 100644 index 0000000000..945763c295 --- /dev/null +++ b/examples/qml/modelviews/stringlistmodel/view.qml @@ -0,0 +1,54 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +//![0] + +ListView { + width: 100; height: 100 + + model: myModel + delegate: Rectangle { + height: 25 + width: 100 + Text { text: modelData } + } +} +//![0] diff --git a/examples/qml/modelviews/visualdatamodel/dragselection.qml b/examples/qml/modelviews/visualdatamodel/dragselection.qml new file mode 100644 index 0000000000..c3186a5ad8 --- /dev/null +++ b/examples/qml/modelviews/visualdatamodel/dragselection.qml @@ -0,0 +1,200 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Item { + id: root + + width: 320 + height: 480 + + property bool dragging: false + + Component { + id: packageDelegate + Package { + id: packageRoot + + MouseArea { + id: visibleContainer + Package.name: "visible" + + width: 64 + height: 64 + enabled: packageRoot.VisualDataModel.inSelected + + drag.target: draggable + + Item { + id: draggable + + width: 64 + height: 64 + + Drag.active: visibleContainer.drag.active + + anchors { horizontalCenter: parent.horizontalCenter; verticalCenter: parent.verticalCenter } + + states: State { + when: visibleContainer.drag.active + AnchorChanges { target: draggable; anchors { horizontalCenter: undefined; verticalCenter: undefined} } + ParentChange { target: selectionView; parent: draggable; x: 0; y: 0 } + PropertyChanges { target: root; dragging: true } + ParentChange { target: draggable; parent: root } + } + } + DropArea { + anchors.fill: parent + onEntered: selectedItems.move(0, visualModel.items.get(packageRoot.VisualDataModel.itemsIndex), selectedItems.count) + } + } + Item { + id: selectionContainer + Package.name: "selection" + + width: 64 + height: 64 + + visible: PathView.onPath + } + Rectangle { + id: content + parent: visibleContainer + + width: 58 + height: 58 + + radius: 8 + + gradient: Gradient { + GradientStop { id: gradientStart; position: 0.0; color: "#8AC953" } + GradientStop { id: gradientEnd; position: 1.0; color: "#8BC953" } + } + + border.width: 2 + border.color: "#007423" + + state: root.dragging && packageRoot.VisualDataModel.inSelected ? "selected" : "visible" + + Text { + anchors.fill: parent + horizontalAlignment: Text.AlignHCenter + verticalAlignment: Text.AlignVCenter + color: "white" + text: modelData + font.pixelSize: 18 + } + + Rectangle { + anchors { right: parent.right; top: parent.top; margins: 3 } + width: 12; height: 12 + color: packageRoot.VisualDataModel.inSelected ? "black" : "white" + radius: 6 + + border.color: "white" + border.width: 2 + + MouseArea { + anchors.fill: parent + onClicked: packageRoot.VisualDataModel.inSelected = !packageRoot.VisualDataModel.inSelected + } + } + + states: [ + State { + name: "selected" + ParentChange { target: content; parent: selectionContainer; x: 3; y: 3 } + PropertyChanges { target: packageRoot; VisualDataModel.inItems: visibleContainer.drag.active } + PropertyChanges { target: gradientStart; color: "#017423" } + PropertyChanges { target: gradientStart; color: "#007423" } + }, State { + name: "visible" + PropertyChanges { target: packageRoot; VisualDataModel.inItems: true } + ParentChange { target: content; parent: visibleContainer; x: 3; y: 3 } + PropertyChanges { target: gradientStart; color: "#8AC953" } + PropertyChanges { target: gradientStart; color: "#8BC953" } + } + ] + transitions: Transition { + PropertyAction { target: packageRoot; properties: "VisualDataModel.inItems" } + ParentAnimation { + target: content + NumberAnimation { target: content; properties: "x,y"; duration: 500 } + } + ColorAnimation { targets: [gradientStart, gradientEnd]; duration: 500 } + } + } + } + } + + VisualDataModel { + id: visualModel + model: 35 + delegate: packageDelegate + + groups: VisualDataGroup { id: selectedItems; name: "selected" } + + Component.onCompleted: parts.selection.filterOnGroup = "selected" + } + + PathView { + id: selectionView + + height: 64 + width: 64 + + model: visualModel.parts.selection + + path: Path { + startX: 0 + startY: 0 + PathLine { x: 64; y: 64 } + } + } + + GridView { + id: itemsView + anchors { fill: parent } + cellWidth: 64 + cellHeight: 64 + model: visualModel.parts.visible + } +} diff --git a/examples/qml/modelviews/visualdatamodel/slideshow.qml b/examples/qml/modelviews/visualdatamodel/slideshow.qml new file mode 100644 index 0000000000..040c6be307 --- /dev/null +++ b/examples/qml/modelviews/visualdatamodel/slideshow.qml @@ -0,0 +1,156 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import QtQuick.XmlListModel 2.0 + +Rectangle { + id: root + + property Item displayItem: null + + width: 300; height: 400 + + color: "black" + + VisualDataModel { + id: visualModel + + model: XmlListModel { + source: "http://api.flickr.com/services/feeds/photos_public.gne?format=rss2" + query: "/rss/channel/item" + namespaceDeclarations: "declare namespace media=\"http://search.yahoo.com/mrss/\";" + + XmlRole { name: "imagePath"; query: "media:thumbnail/@url/string()" } + XmlRole { name: "url"; query: "media:content/@url/string()" } + } + + delegate: Item { + id: delegateItem + + width: 76; height: 76 + + Rectangle { + id: image + x: 0; y: 0; width: 76; height: 76 + border.width: 1 + border.color: "white" + color: "black" + + Image { + anchors.fill: parent + anchors.leftMargin: 1 + anchors.topMargin: 1 + + source: imagePath + fillMode: Image.PreserveAspectFit + + } + + MouseArea { + id: clickArea + anchors.fill: parent + + onClicked: root.displayItem = root.displayItem !== delegateItem ? delegateItem : null + } + + states: [ + State { + when: root.displayItem === delegateItem + name: "inDisplay"; + ParentChange { target: image; parent: imageContainer; x: 75; y: 75; width: 150; height: 150 } + PropertyChanges { target: image; z: 2 } + PropertyChanges { target: delegateItem; VisualDataModel.inItems: false } + }, + State { + when: root.displayItem !== delegateItem + name: "inList"; + ParentChange { target: image; parent: delegateItem; x: 2; y: 2; width: 75; height: 75 } + PropertyChanges { target: image; z: 1 } + PropertyChanges { target: delegateItem; VisualDataModel.inItems: true } + } + ] + + transitions: [ + Transition { + from: "inList" + SequentialAnimation { + PropertyAction { target: delegateItem; property: "VisualDataModel.inPersistedItems"; value: true } + ParentAnimation { + target: image; + via: root + NumberAnimation { target: image; properties: "x,y,width,height"; duration: 1000 } + } + } + }, Transition { + from: "inDisplay" + SequentialAnimation { + ParentAnimation { + target: image + NumberAnimation { target: image; properties: "x,y,width,height"; duration: 1000 } + } + PropertyAction { target: delegateItem; property: "VisualDataModel.inPersistedItems"; value: false } + } + } + ] + } + } + } + + + PathView { + id: imagePath + + anchors { left: parent.left; top: imageContainer.bottom; right: parent.right; bottom: parent.bottom } + model: visualModel + + pathItemCount: 7 + path: Path { + startX: -50; startY: 0 + PathQuad { x: 150; y: 50; controlX: 0; controlY: 50 } + PathQuad { x: 350; y: 0; controlX: 300; controlY: 50 } + } + } + + Item { + id: imageContainer + anchors { fill: parent; bottomMargin: 100 } + } +} diff --git a/examples/qml/modelviews/visualdatamodel/sortedmodel.qml b/examples/qml/modelviews/visualdatamodel/sortedmodel.qml new file mode 100644 index 0000000000..8d3b0a58e5 --- /dev/null +++ b/examples/qml/modelviews/visualdatamodel/sortedmodel.qml @@ -0,0 +1,141 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Rectangle { + width: 480; height: 640 + + Component { + id: numberDelegate + + Text { + id: numberText + anchors { left: parent.left; right: parent.right } + text: number + + horizontalAlignment: Text.AlignHCenter + font.pixelSize: 18 + + Text { + anchors { left: parent.left; baseline: parent.baseline } + text: index + + horizontalAlignment: Text.AlignLeft + font.pixelSize: 12 + } + Text { + anchors { right: parent.right; baseline: parent.baseline } + text: numberText.VisualDataModel.itemsIndex + + horizontalAlignment: Text.AlignRight + font.pixelSize: 12 + } + } + } + + ListView { + anchors { + left: parent.left; top: parent.top; + right: parent.horizontalCenter; bottom: button.top + leftMargin: 2; topMargin: 2; rightMargin: 1; bottomMargin: 2 + } + + model: ListModel { + id: unsortedModel + } + delegate: numberDelegate + } + ListView { + anchors { + left: parent.horizontalCenter; top: parent.top; + right: parent.right; bottom: button.top + leftMargin: 1; topMargin: 2; rightMargin: 2; bottomMargin: 2 + } + model: VisualDataModel { + model: unsortedModel + delegate: numberDelegate + + items.onChanged: { + for (var i = 0; i < inserted.length; ++i) { + for (var j = inserted[i].index; j < inserted[i].index + inserted[i].count; ++j) { + var number = items.get(j).model.number + for (var l = 0, k = 0; l < unsortedModel.count; ++l) { + if (l == inserted[k].index) { + l += inserted[k].count - 1 + ++k + } else if (number < items.get(l).model.number) { + items.move(j, l, 1) + break + } + } + inserted[i].index += 1; + inserted[i].count -= 1; + } + } + } + } + } + + Rectangle { + id: button + + anchors { left: parent.left; right: parent.right; bottom: parent.bottom; margins: 2 } + height: moreText.implicitHeight + 4 + + color: "black" + + Text { + id: moreText + + anchors.fill: parent + text: "More" + color: "white" + font.pixelSize: 18 + horizontalAlignment: Text.AlignHCenter + verticalAlignment: Text.AlignVCenter + } + MouseArea { + anchors.fill: parent + + onClicked: unsortedModel.append({ "number": Math.floor(Math.random() * 100) }) + } + } +} diff --git a/examples/qml/modelviews/visualdatamodel/visualdatamodel.qmlproject b/examples/qml/modelviews/visualdatamodel/visualdatamodel.qmlproject new file mode 100644 index 0000000000..2bb4016996 --- /dev/null +++ b/examples/qml/modelviews/visualdatamodel/visualdatamodel.qmlproject @@ -0,0 +1,14 @@ +import QmlProject 1.0 + +Project { + /* Include .qml, .js, and image files from current directory and subdirectories */ + QmlFiles { + directory: "." + } + JavaScriptFiles { + directory: "." + } + ImageFiles { + directory: "." + } +} diff --git a/examples/qml/modelviews/visualitemmodel/visualitemmodel.qml b/examples/qml/modelviews/visualitemmodel/visualitemmodel.qml new file mode 100644 index 0000000000..3425150d9a --- /dev/null +++ b/examples/qml/modelviews/visualitemmodel/visualitemmodel.qml @@ -0,0 +1,115 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +// This example demonstrates placing items in a view using +// a VisualItemModel + +import QtQuick 2.0 + +Rectangle { + color: "lightgray" + width: 240 + height: 320 + property bool printDestruction: false + + VisualItemModel { + id: itemModel + + Rectangle { + width: view.width; height: view.height + color: "#FFFEF0" + Text { text: "Page 1"; font.bold: true; anchors.centerIn: parent } + + Component.onDestruction: if (printDestruction) print("destroyed 1") + } + Rectangle { + width: view.width; height: view.height + color: "#F0FFF7" + Text { text: "Page 2"; font.bold: true; anchors.centerIn: parent } + + Component.onDestruction: if (printDestruction) print("destroyed 2") + } + Rectangle { + width: view.width; height: view.height + color: "#F4F0FF" + Text { text: "Page 3"; font.bold: true; anchors.centerIn: parent } + + Component.onDestruction: if (printDestruction) print("destroyed 3") + } + } + + ListView { + id: view + anchors { fill: parent; bottomMargin: 30 } + model: itemModel + preferredHighlightBegin: 0; preferredHighlightEnd: 0 + highlightRangeMode: ListView.StrictlyEnforceRange + orientation: ListView.Horizontal + snapMode: ListView.SnapOneItem; flickDeceleration: 2000 + cacheBuffer: 200 + } + + Rectangle { + width: 240; height: 30 + anchors { top: view.bottom; bottom: parent.bottom } + color: "gray" + + Row { + anchors.centerIn: parent + spacing: 20 + + Repeater { + model: itemModel.count + + Rectangle { + width: 5; height: 5 + radius: 3 + color: view.currentIndex == index ? "blue" : "white" + + MouseArea { + width: 20; height: 20 + anchors.centerIn: parent + onClicked: view.currentIndex = index + } + } + } + } + } +} diff --git a/examples/qml/openglunderqml/main.cpp b/examples/qml/openglunderqml/main.cpp new file mode 100644 index 0000000000..3b682deaec --- /dev/null +++ b/examples/qml/openglunderqml/main.cpp @@ -0,0 +1,60 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the demonstration applications of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include + +#include + +#include "squircle.h" + +int main(int argc, char **argv) +{ + QGuiApplication app(argc, argv); + + qmlRegisterType("QtQuick", 2, 0, "Squircle"); + + QQuickView view; + view.setSource(QUrl("main.qml")); + view.show(); + + return app.exec(); + +} diff --git a/examples/qml/openglunderqml/main.qml b/examples/qml/openglunderqml/main.qml new file mode 100644 index 0000000000..1485cbbdb8 --- /dev/null +++ b/examples/qml/openglunderqml/main.qml @@ -0,0 +1,78 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the demonstration applications of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Item { + + width: 400 + height: 300 + + Squircle { + SequentialAnimation on t { + NumberAnimation { to: 1; duration: 2500; easing.type: Easing.InQuad } + NumberAnimation { to: 0; duration: 2500; easing.type: Easing.OutQuad } + loops: Animation.Infinite + running: true + } + } + + Rectangle { + color: Qt.rgba(1, 1, 1, 0.8); + radius: 10 + border.width: 1 + border.color: "white" + anchors.fill: label + anchors.margins: -10 + } + + Text { + id: label + color: "black" + wrapMode: Text.WordWrap + text: "The background here is a squircle rendered with raw OpenGL using the 'beforeRender()' signal in QQuickCanvas. This text label and its border is rendered using QML" + anchors.right: parent.right + anchors.left: parent.left + anchors.bottom: parent.bottom + anchors.margins: 20 + } + +} diff --git a/examples/qml/openglunderqml/openglunderqml.pro b/examples/qml/openglunderqml/openglunderqml.pro new file mode 100644 index 0000000000..64a58b3729 --- /dev/null +++ b/examples/qml/openglunderqml/openglunderqml.pro @@ -0,0 +1,6 @@ +QT += qml quick + +HEADERS += squircle.h +SOURCES += squircle.cpp main.cpp + +OTHER_FILES += main.qml diff --git a/examples/qml/openglunderqml/squircle.cpp b/examples/qml/openglunderqml/squircle.cpp new file mode 100644 index 0000000000..b56f0baaf6 --- /dev/null +++ b/examples/qml/openglunderqml/squircle.cpp @@ -0,0 +1,123 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the demonstration applications of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "squircle.h" + +#include +#include +#include + +Squircle::Squircle() + : m_program(0) +{ + setFlag(ItemHasContents); +} + +void Squircle::itemChange(ItemChange change, const ItemChangeData &) +{ + // The ItemSceneChange event is sent when we are first attached to a canvas. + if (change == ItemSceneChange) { + QQuickCanvas *c = canvas(); + + // Connect our the beforeRendering signal to our paint function. + // Since this call is executed on the rendering thread it must be + // a Qt::DirectConnection + connect(c, SIGNAL(beforeRendering()), this, SLOT(paint()), Qt::DirectConnection); + + // If we allow QML to do the clearing, they would clear what we paint + // and nothing would show. + c->setClearBeforeRendering(false); + } +} + + +void Squircle::paint() +{ + if (!m_program) { + m_program = new QOpenGLShaderProgram(); + m_program->addShaderFromSourceCode(QOpenGLShader::Vertex, + "attribute highp vec4 vertices;" + "varying highp vec2 coords;" + "void main() {" + " gl_Position = vertices;" + " coords = vertices.xy;" + "}"); + m_program->addShaderFromSourceCode(QOpenGLShader::Fragment, + "uniform lowp float t;" + "varying highp vec2 coords;" + "void main() {" + " lowp float i = 1. - (pow(coords.x, 4.) + pow(coords.y, 4.));" + " i = smoothstep(t - 0.3, t + 0.3, i);" + " gl_FragColor = vec4(coords / 2. + .5, i, i);" + "}"); + + m_program->bindAttributeLocation("vertices", 0); + m_program->link(); + } + + m_program->bind(); + + m_program->enableAttributeArray(0); + + float values[] = { + -1, -1, + 1, -1, + -1, 1, + 1, 1 + }; + m_program->setAttributeArray(0, GL_FLOAT, values, 2); + m_program->setUniformValue("t", (float) m_t); + + glDisable(GL_DEPTH_TEST); + + glClearColor(0, 0, 0, 1); + glClear(GL_COLOR_BUFFER_BIT); + + glEnable(GL_BLEND); + glBlendFunc(GL_SRC_ALPHA, GL_ONE); + + glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); + + m_program->disableAttributeArray(0); + m_program->release(); +} + + diff --git a/examples/qml/openglunderqml/squircle.h b/examples/qml/openglunderqml/squircle.h new file mode 100644 index 0000000000..283131a662 --- /dev/null +++ b/examples/qml/openglunderqml/squircle.h @@ -0,0 +1,76 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the demonstration applications of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef SQUIRCLE_H +#define SQUIRCLE_H + +#include +#include + +class Squircle : public QQuickItem +{ + Q_OBJECT + + Q_PROPERTY(qreal t READ t WRITE setT NOTIFY tChanged) + +public: + Squircle(); + + qreal t() const { return m_t; } + void setT(qreal t) { m_t = t; emit tChanged(); } + + void itemChange(ItemChange change, const ItemChangeData &); + +signals: + void tChanged(); + +public slots: + void paint(); + +private: + QOpenGLShaderProgram *m_program; + + qreal m_t; + bool m_render_under; + bool m_render_over; +}; + +#endif // SQUIRCLE_H diff --git a/examples/qml/painteditem/painteditem.pro b/examples/qml/painteditem/painteditem.pro new file mode 100644 index 0000000000..e3afd6b0f0 --- /dev/null +++ b/examples/qml/painteditem/painteditem.pro @@ -0,0 +1,5 @@ +TEMPLATE = subdirs + +SUBDIRS = \ + smile \ + textballoons diff --git a/examples/qml/painteditem/smile/main.cpp b/examples/qml/painteditem/smile/main.cpp new file mode 100644 index 0000000000..1c7888b10b --- /dev/null +++ b/examples/qml/painteditem/smile/main.cpp @@ -0,0 +1,96 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include +#include +#include +#include +class MyPaintItem : public QQuickPaintedItem +{ + Q_OBJECT + Q_PROPERTY(QString face READ face WRITE setFace NOTIFY faceChanged) +public: + MyPaintItem() + : QQuickPaintedItem() + , m_face(QLatin1String(":-)")) + { + setAntialiasing(true); + } + QString face() const {return m_face;} + void setFace(const QString &face) { + if (m_face != face) { + m_face = face; + emit faceChanged(); + } + } + virtual void paint(QPainter *p) + { + QRectF rect(0, 0, width(), height()); + rect.adjust(10, 10, -10, -10); + p->setPen(QPen(Qt::black, 20)); + p->setBrush(Qt::yellow); + p->drawEllipse(rect); + p->setPen(Qt::black); + p->setFont(QFont(QLatin1String("Times"), qRound(rect.height() / 2))); + p->drawText(rect, Qt::AlignCenter, m_face); + } +signals: + void faceChanged(); +private: + QString m_face; +}; + +int main(int argc, char ** argv) +{ + QGuiApplication app(argc, argv); + + qmlRegisterType("MyModule", 1, 0, "MyPaintItem"); + + QQuickView view; + view.setResizeMode(QQuickView::SizeRootObjectToView); + view.setSource(QUrl::fromLocalFile("smile.qml")); + view.show(); + view.raise(); + + return app.exec(); +} + +#include "main.moc" diff --git a/examples/qml/painteditem/smile/smile.pro b/examples/qml/painteditem/smile/smile.pro new file mode 100644 index 0000000000..b1af4ee0ad --- /dev/null +++ b/examples/qml/painteditem/smile/smile.pro @@ -0,0 +1,11 @@ +TEMPLATE = app +TARGET = painteditem + +QT += qml quick + +macx: CONFIG -= app_bundle + +SOURCES += main.cpp + +CONFIG += console + diff --git a/examples/qml/painteditem/smile/smile.qml b/examples/qml/painteditem/smile/smile.qml new file mode 100644 index 0000000000..33919bc04f --- /dev/null +++ b/examples/qml/painteditem/smile/smile.qml @@ -0,0 +1,132 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import MyModule 1.0 + +Rectangle { + width: 500 + height: 500 + gradient: Gradient { + GradientStop { position: 0.0; color: "#00249a" } + GradientStop { position: 0.7; color: "#ffd94f" } + GradientStop { position: 1.0; color: "#ffa322" } + } + MyPaintItem { + renderTarget:PaintedItem.Image + clip:true + width:240 + height:240 + anchors.left : parent.left + anchors.top :parent.top + anchors.margins: 10 + smooth: true + MouseArea { + anchors.fill:parent + onClicked: { + if (parent.face == ":-)") + parent.face = ":-("; + else + parent.face = ":-)"; + parent.update() + } + } + } + MyPaintItem { + clip:true + renderTarget:PaintedItem.Image + width:240 + height:240 + anchors.right : parent.right + anchors.top :parent.top + anchors.margins: 10 + smooth: true + MouseArea { + anchors.fill:parent + onClicked: { + if (parent.face == ":-)") + parent.face = ":-("; + else + parent.face = ":-)"; + parent.update() + } + } + } + MyPaintItem { + clip:true + renderTarget:PaintedItem.Image + width:240 + height:240 + anchors.left : parent.left + anchors.bottom :parent.bottom + anchors.margins: 10 + smooth: true + MouseArea { + anchors.fill:parent + onClicked: { + if (parent.face == ":-)") + parent.face = ":-("; + else + parent.face = ":-)"; + parent.update() + } + } + } + MyPaintItem { + clip:true + renderTarget:PaintedItem.Image + width:240 + height:240 + anchors.right : parent.right + anchors.bottom :parent.bottom + anchors.margins: 10 + smooth: true + MouseArea { + anchors.fill:parent + onClicked: { + if (parent.face == ":-)") + parent.face = ":-("; + else + parent.face = ":-)"; + parent.update() + } + } + } +} \ No newline at end of file diff --git a/examples/qml/painteditem/textballoons/TextBalloonPlugin/plugin.h b/examples/qml/painteditem/textballoons/TextBalloonPlugin/plugin.h new file mode 100644 index 0000000000..e6523e15a9 --- /dev/null +++ b/examples/qml/painteditem/textballoons/TextBalloonPlugin/plugin.h @@ -0,0 +1,56 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the demonstration applications of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include + +#include "../textballoon.h" + +class TextBalloonPlugin : public QQmlExtensionPlugin +{ + Q_OBJECT +public: + void registerTypes(const char *uri) + { + qmlRegisterType(uri, 1, 0, "TextBalloon"); + } +}; + +Q_EXPORT_PLUGIN2(qmltextballoonplugin, TextBalloonPlugin); diff --git a/examples/qml/painteditem/textballoons/TextBalloonPlugin/qmldir b/examples/qml/painteditem/textballoons/TextBalloonPlugin/qmldir new file mode 100644 index 0000000000..e8a08ae9d3 --- /dev/null +++ b/examples/qml/painteditem/textballoons/TextBalloonPlugin/qmldir @@ -0,0 +1 @@ +plugin qmltextballoonplugin diff --git a/examples/qml/painteditem/textballoons/textballoon.cpp b/examples/qml/painteditem/textballoons/textballoon.cpp new file mode 100644 index 0000000000..d097adfe1b --- /dev/null +++ b/examples/qml/painteditem/textballoons/textballoon.cpp @@ -0,0 +1,92 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the demonstration applications of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "textballoon.h" + +//! [0] +TextBalloon::TextBalloon(QQuickItem *parent) + : QQuickPaintedItem(parent) + , rightAligned(false) +{ +} +//! [0] + +//! [1] +void TextBalloon::paint(QPainter *painter) +{ + QBrush brush(QColor("#007430")); + + painter->setBrush(brush); + painter->setPen(Qt::NoPen); + painter->setRenderHint(QPainter::Antialiasing); + + painter->drawRoundedRect(0, 0, boundingRect().width(), boundingRect().height() - 10, 10, 10); + + if (rightAligned) + { + const QPointF points[3] = { + QPointF(boundingRect().width() - 10.0, boundingRect().height() - 10.0), + QPointF(boundingRect().width() - 20.0, boundingRect().height()), + QPointF(boundingRect().width() - 30.0, boundingRect().height() - 10.0), + }; + painter->drawConvexPolygon(points, 3); + } + else + { + const QPointF points[3] = { + QPointF(10.0, boundingRect().height() - 10.0), + QPointF(20.0, boundingRect().height()), + QPointF(30.0, boundingRect().height() - 10.0), + }; + painter->drawConvexPolygon(points, 3); + } +} +//! [1] + +bool TextBalloon::isRightAligned() +{ + return this->rightAligned; +} + +void TextBalloon::setRightAligned(bool rightAligned) +{ + this->rightAligned = rightAligned; +} diff --git a/examples/qml/painteditem/textballoons/textballoon.h b/examples/qml/painteditem/textballoons/textballoon.h new file mode 100644 index 0000000000..93ed0a7105 --- /dev/null +++ b/examples/qml/painteditem/textballoons/textballoon.h @@ -0,0 +1,68 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the demonstration applications of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef TEXTBALLOON_H +#define TEXTBALLOON_H + +#include + +//! [0] +class TextBalloon : public QQuickPaintedItem +{ + Q_OBJECT + Q_PROPERTY(bool rightAligned READ isRightAligned WRITE setRightAligned NOTIFY rightAlignedChanged) + + public: + TextBalloon(QQuickItem *parent = 0); + void paint(QPainter *painter); + + bool isRightAligned(); + void setRightAligned(bool rightAligned); + + private: + bool rightAligned; + + signals: + void rightAlignedChanged(); +}; +//! [0] + +#endif diff --git a/examples/qml/painteditem/textballoons/textballoons.pro b/examples/qml/painteditem/textballoons/textballoons.pro new file mode 100644 index 0000000000..9bc0f3c04a --- /dev/null +++ b/examples/qml/painteditem/textballoons/textballoons.pro @@ -0,0 +1,23 @@ +TEMPLATE = lib +CONFIG += qt plugin +QT += qml quick + +TARGET = qmltextballoonplugin + +HEADERS += TextBalloonPlugin/plugin.h \ + textballoon.h + +SOURCES += textballoon.cpp + +DESTDIR = TextBalloonPlugin + +qqmlsources.files += \ + TextBalloonPlugin/qmldir + +qqmlsources.path += $$[QT_INSTALL_EXAMPLES]/qtdeclarative/qml/painteditem/textballoons/TextBalloonPlugin + +sources.files = textballoons.qml +sources.path += $$[QT_INSTALL_EXAMPLES]/qtdeclarative/qml/painteditem/textballoons +target.path += $$[QT_INSTALL_EXAMPLES]/qtdeclarative/qml/painteditem/textballoons/TextBalloonPlugin + +INSTALLS = qqmlsources sources target diff --git a/examples/qml/painteditem/textballoons/textballoons.qml b/examples/qml/painteditem/textballoons/textballoons.qml new file mode 100644 index 0000000000..b00ce2bfed --- /dev/null +++ b/examples/qml/painteditem/textballoons/textballoons.qml @@ -0,0 +1,110 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the demonstration applications of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import TextBalloonPlugin 1.0 + +Item { + height: 480 + width: 640 + + //! [0] + ListModel { + id: balloonModel + ListElement { + balloonWidth: 200 + } + ListElement { + balloonWidth: 350 + } + } + + ListView { + anchors.bottom: controls.top + anchors.bottomMargin: 2 + anchors.top: parent.top + id: balloonView + delegate: TextBalloon { + anchors.right: index % 2 == 0 ? undefined : parent.right + height: 60 + rightAligned: index % 2 == 0 ? false : true + width: balloonWidth + } + model: balloonModel + spacing: 5 + width: parent.width + } + //! [0] + + //! [1] + Rectangle { + id: controls + + anchors.bottom: parent.bottom + anchors.left: parent.left + anchors.margins: 1 + anchors.right: parent.right + border.width: 2 + color: "white" + height: parent.height * 0.15 + + Text { + anchors.centerIn: parent + text: "Add another balloon" + } + + MouseArea { + anchors.fill: parent + hoverEnabled: true + onClicked: { + balloonModel.append({"balloonWidth": Math.floor(Math.random() * 300 + 100)}) + balloonView.positionViewAtIndex(balloonView.count -1, ListView.End) + } + onEntered: { + parent.color = "#8ac953" + } + onExited: { + parent.color = "white" + } + } + } + //! [1] +} diff --git a/examples/qml/particles/affectors/age.qml b/examples/qml/particles/affectors/age.qml new file mode 100644 index 0000000000..1e7774b63b --- /dev/null +++ b/examples/qml/particles/affectors/age.qml @@ -0,0 +1,97 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import QtQuick.Particles 2.0 + +Rectangle { + id: root + width: 360 + height: 600 + color: "white" + + ParticleSystem { id: particles } + + ImageParticle { + system: particles + sprites: Sprite { + name: "snow" + source: "../images/snowflake.png" + frames: 51 + frameDuration: 40 + frameDurationVariation: 8 + } + } + + Emitter { + system: particles + emitRate: 20 + lifeSpan: 8000 + speed: PointDirection { y:80; yVariation: 40; } + acceleration: PointDirection { y: 4 } + size: 36 + endSize: 12 + sizeVariation: 8 + width: parent.width + height: 100 + } + + MouseArea { + id: ma + anchors.fill: parent + hoverEnabled: true + } + + Rectangle { + color: "#803333AA" + border.color: "black" + x: ma.mouseX - 36 + y: ma.mouseY - 36 + width: 72 + height: 72 + Age { + anchors.fill: parent + system: particles + once: true + lifeLeft: 1200 + advancePosition: false + } + } +} diff --git a/examples/qml/particles/affectors/attractor.qml b/examples/qml/particles/affectors/attractor.qml new file mode 100644 index 0000000000..460a497a92 --- /dev/null +++ b/examples/qml/particles/affectors/attractor.qml @@ -0,0 +1,213 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import QtQuick.Particles 2.0 + +Rectangle { + id: root + width: 360 + height: 540 + color: "black" + property bool spacePressed: false + focus: true + Image { + source: "../images/finalfrontier.png" + anchors.centerIn:parent + } + Keys.onPressed: { + if (event.key == Qt.Key_Space) { + spacePressed = true; + event.accepted = true; + } + } + Keys.onReleased: { + if (event.key == Qt.Key_Space) { + spacePressed = false; + event.accepted = true; + } + } + + Emitter { + group: "stars" + system: particles + emitRate: 40 + lifeSpan: 4000 + enabled: true + size: 30 + sizeVariation: 10 + speed: PointDirection { x: 220; xVariation: 40 } + height: parent.height + } + Emitter { + group: "roids" + system: particles + emitRate: 10 + lifeSpan: 4000 + enabled: true + size: 30 + sizeVariation: 10 + speed: PointDirection { x: 220; xVariation: 40 } + height: parent.height + } + ParticleSystem { + id: particles + anchors.fill: parent + } + ImageParticle { + id: stars + groups: ["stars"] + system: particles + source: "../images/star.png" + color: "white" + colorVariation: 0.1 + alpha: 0 + } + ImageParticle { + id: roids + groups: ["roids"] + system: particles + sprites: Sprite { + id: spinState + name: "spinning" + source: "../images/meteor.png" + frames: 35 + frameDuration: 60 + } + } + ImageParticle { + id: shot + groups: ["shot"] + system: particles + source: "../images/star.png" + + color: "#0FF06600" + colorVariation: 0.3 + } + ImageParticle { + id: engine + groups: ["engine"] + system: particles + source: "../images/particle4.png" + + color: "orange" + SequentialAnimation on color { + loops: Animation.Infinite + ColorAnimation { + from: "red" + to: "cyan" + duration: 1000 + } + ColorAnimation { + from: "cyan" + to: "red" + duration: 1000 + } + } + + colorVariation: 0.2 + } + Attractor { + id: gs; pointX: root.width/2; pointY: root.height/2; strength: 4000000; + system: particles + affectedParameter: Attractor.Acceleration + proportionalToDistance: Attractor.InverseQuadratic + } + Age { + system: particles + x: gs.pointX - 8; + y: gs.pointY - 8; + width: 16 + height: 16 + } + Rectangle { + color: "black" + width: 8 + height: 8 + radius: 4 + x: gs.pointX - 4 + y: gs.pointY - 4 + } + + Image { + source:"../images/rocket2.png" + id: ship + width: 45 + height: 22 + MouseArea { + id: ma + anchors.fill: parent; + drag.axis: Drag.XandYAxis + drag.target: ship + } + } + Emitter { + group: "engine" + system: particles + emitRate: 200 + lifeSpan: 1000 + size: 10 + endSize: 4 + sizeVariation: 4 + speed: PointDirection { x: -128; xVariation: 32 } + height: ship.height + y: ship.y + x: ship.x + width: 20 + } + Emitter { + group: "shot" + system: particles + emitRate: 32 + lifeSpan: 2000 + enabled: spacePressed + size: 40 + speed: PointDirection { x: 256; } + x: ship.x + ship.width + y: ship.y + ship.height/2 + } + + Text { + color: "white" + anchors.bottom: parent.bottom + text:"Drag the ship, Spacebar to fire." + } +} + diff --git a/examples/qml/particles/affectors/customaffector.qml b/examples/qml/particles/affectors/customaffector.qml new file mode 100644 index 0000000000..3f98cd5b43 --- /dev/null +++ b/examples/qml/particles/affectors/customaffector.qml @@ -0,0 +1,173 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import QtQuick.Particles 2.0 + +Item { + width: 360 + height: 600 + + Image { + source: "../images/backgroundLeaves.jpg" + anchors.fill: parent + } + ParticleSystem { + id: sys + } + Emitter { + system: sys + width: parent.width + emitRate: 4 + lifeSpan: 14000 + size: 80 + speed: PointDirection { y: 60 } + } + Wander { + system: sys + anchors.fill: parent + anchors.bottomMargin: 100 + xVariance: 60 + pace: 60 + } + + Affector { + system: sys + property real coefficient: 0.1 + property real speed: 1.5 + width: parent.width + height: parent.height - 100 + onAffectParticles: { + /* //Linear movement + if (particle.r == 0) { + particle.r = Math.random() > 0.5 ? -1 : 1; + }else if (particle.r == 1) { + particle.rotation += speed * dt; + if(particle.rotation >= maxAngle) + particle.r = -1; + }else if (particle.r == -1) { + particle.rotation -= speed * dt; + if(particle.rotation <= -1 * maxAngle) + particle.r = 1; + } + */ + //Wobbly movement + for (var i=0; i 1.) + currentSize = 0.; + + highp vec2 pos = qt_ParticlePos + - currentSize / 2. + currentSize * qt_ParticleTex // adjust size + + qt_ParticleVec.xy * t * qt_ParticleData.y // apply speed vector.. + + 0.5 * qt_ParticleVec.zw * pow(t * qt_ParticleData.y, 2.); + + gl_Position = qt_Matrix * vec4(pos.x, pos.y, 0, 1); + + highp float fadeIn = min(t * 20., 1.); + highp float fadeOut = 1. - max(0., min((t - 0.75) * 4., 1.)); + + fFade = fadeIn * fadeOut * qt_Opacity; + fPos = vec2(pos.x/1024., pos.y/768.); + } + " + fragmentShader: " + varying highp vec2 fPos; + varying lowp float fFade; + varying highp vec2 qt_TexCoord0; + void main() {//*2 because this generates dark colors mostly + highp vec2 circlePos = qt_TexCoord0*2.0 - vec2(1.0,1.0); + highp float dist = length(circlePos); + highp float circleFactor = max(min(1.0 - dist, 1.0), 0.0); + gl_FragColor = vec4(fPos.x*2.0 - fPos.y, fPos.y*2.0 - fPos.x, fPos.x*fPos.y*2.0, 0.0) * circleFactor * fFade; + }" + + } +} diff --git a/examples/qml/particles/customparticle/imagecolors.qml b/examples/qml/particles/customparticle/imagecolors.qml new file mode 100644 index 0000000000..94e5123a0c --- /dev/null +++ b/examples/qml/particles/customparticle/imagecolors.qml @@ -0,0 +1,118 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import QtQuick.Particles 2.0 + +Rectangle { + width: 400 + height: 400 + Rectangle { + id: root + color: "white" + width: 310 + height: 300 + anchors.centerIn: parent + ParticleSystem { id: sys } + CustomParticle { + system: sys + property real maxWidth: root.width + property real maxHeight: root.height + ShaderEffectSource { + id: pictureSource + sourceItem: picture + hideSource: true + } + Image { + id: picture + source: "../images/starfish_3.png" + } + ShaderEffectSource { + id: particleSource + sourceItem: particle + hideSource: true + } + Image { + id: particle + source: "../images/particle4.png" + } + vertexShader:" + uniform highp float maxWidth; + uniform highp float maxHeight; + varying highp vec2 fTex2; + varying lowp float fFade; + uniform lowp float qt_Opacity; + + void main() { + fTex2 = vec2(qt_ParticlePos.x / maxWidth, qt_ParticlePos.y / maxHeight); + highp float t = (qt_Timestamp - qt_ParticleData.x) / qt_ParticleData.y; + fFade = min(t*4., (1.-t*t)*.75) * qt_Opacity; + defaultMain(); + } + " + property variant particleTexture: particleSource + property variant pictureTexture: pictureSource + fragmentShader: " + uniform sampler2D particleTexture; + uniform sampler2D pictureTexture; + varying highp vec2 qt_TexCoord0; + varying highp vec2 fTex2; + varying lowp float fFade; + void main() { + gl_FragColor = texture2D(pictureTexture, fTex2) * texture2D(particleTexture, qt_TexCoord0).w * fFade; + }" + } + + Emitter { + id: emitter + system: sys + enabled: false + lifeSpan: 8000 + maximumEmitted: 4000 + anchors.fill: parent + size: 16 + acceleration: PointDirection { xVariation: 12; yVariation: 12 } + } + MouseArea { + anchors.fill: parent + onClicked: emitter.burst(4000); + } + } +} diff --git a/examples/qml/particles/emitters/burstandpulse.qml b/examples/qml/particles/emitters/burstandpulse.qml new file mode 100644 index 0000000000..1b1c2a60c9 --- /dev/null +++ b/examples/qml/particles/emitters/burstandpulse.qml @@ -0,0 +1,84 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import QtQuick.Particles 2.0 + +Rectangle { + width: 360 + height: 540 + color: "black" + MouseArea { + id: ma + anchors.fill: parent + acceptedButtons: Qt.LeftButton | Qt.RightButton + onClicked: { + if (mouse.button == Qt.LeftButton) + emitter.burst(1000); + else + emitter.pulse(500); + } + } + + ParticleSystem { + id: particles + } + + ImageParticle { + anchors.fill: parent + system: particles + source: "../images/star.png" + alpha: 0 + colorVariation: 0.6 + } + + Emitter { + id: emitter + x: ma.mouseX + y: ma.mouseY + system: particles + emitRate: 2000 + lifeSpan: 2000 + enabled: false + speed: AngleDirection{magnitude: 64; angleVariation: 360} + size: 24 + sizeVariation: 8 + } +} diff --git a/examples/qml/particles/emitters/customemitter.qml b/examples/qml/particles/emitters/customemitter.qml new file mode 100644 index 0000000000..757c836106 --- /dev/null +++ b/examples/qml/particles/emitters/customemitter.qml @@ -0,0 +1,92 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import QtQuick.Particles 2.0 + +ParticleSystem { + id: sys + width: 360 + height: 600 + running: true + Rectangle { + z: -1 + anchors.fill: parent + color: "black" + } + + property real petalLength: 180 + property real petalRotation: 0 + NumberAnimation on petalRotation { + from: 0; + to: 360; + loops: -1; + running: true + duration: 24000 + } + + function convert(a) {return a*(Math.PI/180);} + Emitter { + lifeSpan: 4000 + emitRate: 120 + size: 12 + anchors.centerIn: parent + onEmitParticles: { + for (var i=0; i 400 ? 32 : 16 + } +} diff --git a/examples/qml/particles/imageparticle/colored.qml b/examples/qml/particles/imageparticle/colored.qml new file mode 100644 index 0000000000..ac760b6219 --- /dev/null +++ b/examples/qml/particles/imageparticle/colored.qml @@ -0,0 +1,86 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import QtQuick.Particles 2.0 + +Rectangle { + width: 360 + height: 540 + color: "black" + ParticleSystem { + anchors.fill: parent + ImageParticle { + groups: ["stars"] + anchors.fill: parent + source: "../images/star.png" + } + Emitter { + group: "stars" + emitRate: 800 + lifeSpan: 2400 + size: 24 + sizeVariation: 8 + anchors.fill: parent + } + + ImageParticle { + anchors.fill: parent + source: "../images/star.png" + alpha: 0 + alphaVariation: 0.2 + colorVariation: 1.0 + } + + Emitter { + anchors.centerIn: parent + emitRate: 400 + lifeSpan: 2400 + size: 48 + sizeVariation: 8 + speed: AngleDirection {angleVariation: 180; magnitude: 60} + } + + Turbulence { + anchors.fill: parent + strength: 2 + } + } +} diff --git a/examples/qml/particles/imageparticle/colortable.qml b/examples/qml/particles/imageparticle/colortable.qml new file mode 100644 index 0000000000..623029dae0 --- /dev/null +++ b/examples/qml/particles/imageparticle/colortable.qml @@ -0,0 +1,84 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick.Particles 2.0 +import QtQuick 2.0 + +Rectangle { + id: root + width: 360 + height: 540 + color: "black" + + ParticleSystem { id: particles } + + ImageParticle { + system: particles + colorVariation: 0.5 + alpha: 0 + + source: "../images/particle.png" + colorTable: "../images/colortable.png" + sizeTable: "../images/colortable.png" + } + + Emitter { + system: particles + emitRate: 500 + lifeSpan: 2000 + + y: root.height / 2 + Math.sin(t * 2) * root.height * 0.3 + x: root.width / 2 + Math.cos(t) * root.width * 0.3 + property real t; + + NumberAnimation on t { + from: 0; to: Math.PI * 2; duration: 10000; loops: Animation.Infinite + } + + speedFromMovement: 20 + + speed: PointDirection { xVariation: 5; yVariation: 5;} + acceleration: PointDirection { xVariation: 5; yVariation: 5;} + + size: 16 + //endSize: 8 + //sizeVariation: 8 + } +} diff --git a/examples/qml/particles/imageparticle/deformation.qml b/examples/qml/particles/imageparticle/deformation.qml new file mode 100644 index 0000000000..e282927e78 --- /dev/null +++ b/examples/qml/particles/imageparticle/deformation.qml @@ -0,0 +1,121 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import QtQuick.Particles 2.0 + +Rectangle { + color: "goldenrod" + width: 400 + height: 400 + ParticleSystem {id:sys} + + ImageParticle { + system: sys + groups: ["goingLeft", "goingRight"] + source: "../images/starfish_4.png" + rotation: 90 + rotationSpeed: 90 + autoRotation: true + } + ImageParticle { + system: sys + groups: ["goingDown"] + source: "../images/starfish_0.png" + rotation: 180 + yVector: PointDirection { y: 0.5; yVariation: 0.25; xVariation: 0.25; } + } + + Timer { + running: true + repeat: false + interval: 100 + onTriggered: emitA.enabled = true; + } + Timer { + running: true + repeat: false + interval: 4200 + onTriggered: emitB.enabled = true; + } + Timer { + running: true + repeat: false + interval: 8400 + onTriggered: emitC.enabled = true; + } + + Emitter { + id: emitA + x: 0 + y: 120 + system: sys + enabled: false + group: "goingRight" + speed: PointDirection { x: 100 } + lifeSpan: 4000 + emitRate: 1 + size: 128 + } + Emitter { + id: emitB + x: 400 + y: 240 + system: sys + enabled: false + group: "goingLeft" + speed: PointDirection { x: -100 } + lifeSpan: 4000 + emitRate: 1 + size: 128 + } + Emitter { + id: emitC + x: 0 + y: 360 + system: sys + enabled: false + group: "goingDown" + speed: PointDirection { x: 100 } + lifeSpan: 4000 + emitRate: 1 + size: 128 + } +} diff --git a/examples/qml/particles/imageparticle/rotation.qml b/examples/qml/particles/imageparticle/rotation.qml new file mode 100644 index 0000000000..3a75c379ed --- /dev/null +++ b/examples/qml/particles/imageparticle/rotation.qml @@ -0,0 +1,71 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import QtQuick.Particles 2.0 + +Rectangle { + color: "goldenrod" + width: 2000 + height: 2000 + ParticleSystem {id: sys} + ImageParticle { + id: up + system: sys + source: "../images/starfish_2.png" + } + + Emitter { + anchors.centerIn: parent + system: sys + emitRate: 10 + size: 200 + lifeSpan: 10000 + speed: AngleDirection {angleVariation: 360; magnitudeVariation: 100;} + } + + MouseArea { + anchors.fill: parent + onClicked: { + up.autoRotation = !up.autoRotation + up.rotation = up.autoRotation ? -90 : 0 + } + } +} diff --git a/examples/qml/particles/imageparticle/sharing.qml b/examples/qml/particles/imageparticle/sharing.qml new file mode 100644 index 0000000000..27e08322d9 --- /dev/null +++ b/examples/qml/particles/imageparticle/sharing.qml @@ -0,0 +1,199 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +// This example shows how to create your own highlight delegate for a ListView +// that uses a SpringAnimation to provide custom movement when the +// highlight bar is moved between items. + +import QtQuick 2.0 +import QtQuick.Particles 2.0 + +Rectangle { + property real delegateHeight: 65 + width: 200; height: 300 + gradient: Gradient { + GradientStop { position: 0.0; color: "#EEEEFF" } + GradientStop { position: 1.0; color: "lightblue" } + } + + // Define a delegate component. A component will be + // instantiated for each visible item in the list. + Component { + id: petDelegate + Item { + id: wrapper + width: 200; height: delegateHeight + z: 10 + Column { + Text {color: "white"; text: name; font.pixelSize: 18 } + Text {color: "white"; text: 'Type: ' + type; font.pixelSize: 14 } + Text {color: "white"; text: 'Age: ' + age; font.pixelSize: 14 } + } + // indent the item if it is the current item + states: State { + name: "Current" + when: wrapper.ListView.isCurrentItem + PropertyChanges { target: wrapper; x: 20 } + } + transitions: Transition { + NumberAnimation { properties: "x"; duration: 200 } + } + } + } + + // Define a highlight with customised movement between items. + Component { + id: highlightBar + Rectangle { + z: 0 + width: 200; height: delegateHeight + gradient: Gradient { + GradientStop { position: 0.0; color: "#99FF99" } + GradientStop { position: 1.0; color: "#88FF88" } + } + y: listView.currentItem.y; + Behavior on y { SpringAnimation { spring: 2; damping: 0.2 } } + ImageParticle { + anchors.fill: parent + system: particles + source: "../images/flower.png" + color: "red" + clip: true + alpha: 1.0 + } + } + } + + ListView { + id: listView + width: 200; height: parent.height + + model: petsModel + delegate: petDelegate + focus: true + + // Set the highlight delegate. Note we must also set highlightFollowsCurrentItem + // to false so the highlight delegate can control how the highlight is moved. + highlight: highlightBar + highlightFollowsCurrentItem: false + + ParticleSystem { id: particles } + Emitter { + system: particles + anchors.fill: parent + emitRate: 1 + lifeSpan: 10000 + size: 24 + sizeVariation: 8 + speed: AngleDirection { angleVariation: 360; magnitude: 3 } + maximumEmitted: 10 + startTime: 5000 + } + + ImageParticle { + anchors.fill: parent + system: particles + source: "../images/flower.png" + alpha: 0.1 + color: "white" + rotationVariation: 180 + z: -1 + } + } + + ListModel { + id: petsModel + ListElement { + name: "Polly" + type: "Parrot" + age: 12 + size: "Small" + } + ListElement { + name: "Penny" + type: "Turtle" + age: 4 + size: "Small" + } + ListElement { + name: "Warren" + type: "Rabbit" + age: 2 + size: "Small" + } + ListElement { + name: "Spot" + type: "Dog" + age: 9 + size: "Medium" + } + ListElement { + name: "Schrödinger" + type: "Cat" + age: 2 + size: "Medium" + } + ListElement { + name: "Joey" + type: "Kangaroo" + age: 1 + size: "Medium" + } + ListElement { + name: "Kimba" + type: "Bunny" + age: 65 + size: "Large" + } + ListElement { + name: "Rover" + type: "Dog" + age: 5 + size: "Large" + } + ListElement { + name: "Tiny" + type: "Elephant" + age: 15 + size: "Large" + } + } + +} diff --git a/examples/qml/particles/imageparticle/sprites.qml b/examples/qml/particles/imageparticle/sprites.qml new file mode 100644 index 0000000000..0fe4f31ea3 --- /dev/null +++ b/examples/qml/particles/imageparticle/sprites.qml @@ -0,0 +1,116 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import QtQuick.Particles 2.0 + +Rectangle { + color: "lightsteelblue" + width: 800 + height: 800 + id: root + + SpriteImage { + sprites: Sprite { + name: "bear" + source: "../images/bear_tiles.png" + frames: 13 + frameDuration: 120 + } + width: 250 + height: 250 + x: 20 + anchors.bottom: parent.bottom + anchors.bottomMargin: 20 + z:4 + } + + ParticleSystem { id: sys } + + ImageParticle { + anchors.fill: parent + id: particles + system: sys + sprites: [Sprite { + name: "happy" + source: "../images/starfish_1.png" + frames: 1 + frameDuration: 260 + to: {"happy": 1, "silly": 1, "angry": 1} + }, Sprite { + name: "angry" + source: "../images/starfish_0.png" + frames: 1 + frameDuration: 260 + to: {"happy": 1, "silly": 1, "angry": 1} + }, Sprite { + name: "silly" + source: "../images/starfish_2.png" + frames: 1 + frameDuration: 260 + to: {"happy": 1, "silly": 1, "noticedbear": 0} + }, Sprite { + name: "noticedbear" + source: "../images/starfish_3.png" + frames: 1 + frameDuration: 2600 + }] + } + + Emitter { + system: sys + emitRate: 2 + lifeSpan: 10000 + speed: AngleDirection {angle: 90; magnitude: 60; angleVariation: 5} + acceleration: PointDirection { y: 10 } + size: 160 + sizeVariation: 40 + width: parent.width + height: 100 + } + + SpriteGoal { + system: sys + width: root.width; + height: root.height/2; + y: root.height/2; + goalState:"noticedbear" + } +} diff --git a/examples/qml/particles/images/_explo.png b/examples/qml/particles/images/_explo.png new file mode 100644 index 0000000000..4297245d49 Binary files /dev/null and b/examples/qml/particles/images/_explo.png differ diff --git a/examples/qml/particles/images/backgroundLeaves.jpg b/examples/qml/particles/images/backgroundLeaves.jpg new file mode 100755 index 0000000000..08be16751d Binary files /dev/null and b/examples/qml/particles/images/backgroundLeaves.jpg differ diff --git a/examples/qml/particles/images/bear_tiles.png b/examples/qml/particles/images/bear_tiles.png new file mode 100644 index 0000000000..6bbb2a9b6d Binary files /dev/null and b/examples/qml/particles/images/bear_tiles.png differ diff --git a/examples/qml/particles/images/candle.png b/examples/qml/particles/images/candle.png new file mode 100644 index 0000000000..8fa3193719 Binary files /dev/null and b/examples/qml/particles/images/candle.png differ diff --git a/examples/qml/particles/images/colortable.png b/examples/qml/particles/images/colortable.png new file mode 100644 index 0000000000..a62ceeb4a0 Binary files /dev/null and b/examples/qml/particles/images/colortable.png differ diff --git a/examples/qml/particles/images/finalfrontier.png b/examples/qml/particles/images/finalfrontier.png new file mode 100644 index 0000000000..2ba1815230 Binary files /dev/null and b/examples/qml/particles/images/finalfrontier.png differ diff --git a/examples/qml/particles/images/flower.png b/examples/qml/particles/images/flower.png new file mode 100644 index 0000000000..b5c606210e Binary files /dev/null and b/examples/qml/particles/images/flower.png differ diff --git a/examples/qml/particles/images/launcherIcons/allatonce.png b/examples/qml/particles/images/launcherIcons/allatonce.png new file mode 100644 index 0000000000..b61d2d50d8 Binary files /dev/null and b/examples/qml/particles/images/launcherIcons/allatonce.png differ diff --git a/examples/qml/particles/images/launcherIcons/attractor.png b/examples/qml/particles/images/launcherIcons/attractor.png new file mode 100644 index 0000000000..4bd8040c3b Binary files /dev/null and b/examples/qml/particles/images/launcherIcons/attractor.png differ diff --git a/examples/qml/particles/images/launcherIcons/blurparticles.png b/examples/qml/particles/images/launcherIcons/blurparticles.png new file mode 100644 index 0000000000..4337f979cb Binary files /dev/null and b/examples/qml/particles/images/launcherIcons/blurparticles.png differ diff --git a/examples/qml/particles/images/launcherIcons/close.png b/examples/qml/particles/images/launcherIcons/close.png new file mode 100644 index 0000000000..c37714ee8f Binary files /dev/null and b/examples/qml/particles/images/launcherIcons/close.png differ diff --git a/examples/qml/particles/images/launcherIcons/colortable.png b/examples/qml/particles/images/launcherIcons/colortable.png new file mode 100644 index 0000000000..8841ea30f9 Binary files /dev/null and b/examples/qml/particles/images/launcherIcons/colortable.png differ diff --git a/examples/qml/particles/images/launcherIcons/customaffector.png b/examples/qml/particles/images/launcherIcons/customaffector.png new file mode 100644 index 0000000000..d02e7918fa Binary files /dev/null and b/examples/qml/particles/images/launcherIcons/customaffector.png differ diff --git a/examples/qml/particles/images/launcherIcons/customemitter.png b/examples/qml/particles/images/launcherIcons/customemitter.png new file mode 100644 index 0000000000..6d492573d1 Binary files /dev/null and b/examples/qml/particles/images/launcherIcons/customemitter.png differ diff --git a/examples/qml/particles/images/launcherIcons/deformation.png b/examples/qml/particles/images/launcherIcons/deformation.png new file mode 100644 index 0000000000..d1b722df01 Binary files /dev/null and b/examples/qml/particles/images/launcherIcons/deformation.png differ diff --git a/examples/qml/particles/images/launcherIcons/delegates.png b/examples/qml/particles/images/launcherIcons/delegates.png new file mode 100644 index 0000000000..929414cd0e Binary files /dev/null and b/examples/qml/particles/images/launcherIcons/delegates.png differ diff --git a/examples/qml/particles/images/launcherIcons/dynamicemitters.png b/examples/qml/particles/images/launcherIcons/dynamicemitters.png new file mode 100644 index 0000000000..0cdef9d21e Binary files /dev/null and b/examples/qml/particles/images/launcherIcons/dynamicemitters.png differ diff --git a/examples/qml/particles/images/launcherIcons/emitmask.png b/examples/qml/particles/images/launcherIcons/emitmask.png new file mode 100644 index 0000000000..e943a4adb9 Binary files /dev/null and b/examples/qml/particles/images/launcherIcons/emitmask.png differ diff --git a/examples/qml/particles/images/launcherIcons/flickr.png b/examples/qml/particles/images/launcherIcons/flickr.png new file mode 100644 index 0000000000..4de2650280 Binary files /dev/null and b/examples/qml/particles/images/launcherIcons/flickr.png differ diff --git a/examples/qml/particles/images/launcherIcons/fragmentshader.png b/examples/qml/particles/images/launcherIcons/fragmentshader.png new file mode 100644 index 0000000000..7c6de498d5 Binary files /dev/null and b/examples/qml/particles/images/launcherIcons/fragmentshader.png differ diff --git a/examples/qml/particles/images/launcherIcons/gridsplosion.png b/examples/qml/particles/images/launcherIcons/gridsplosion.png new file mode 100644 index 0000000000..ec75453df6 Binary files /dev/null and b/examples/qml/particles/images/launcherIcons/gridsplosion.png differ diff --git a/examples/qml/particles/images/launcherIcons/groupgoal.png b/examples/qml/particles/images/launcherIcons/groupgoal.png new file mode 100644 index 0000000000..69c6f64e54 Binary files /dev/null and b/examples/qml/particles/images/launcherIcons/groupgoal.png differ diff --git a/examples/qml/particles/images/launcherIcons/imagecolors.png b/examples/qml/particles/images/launcherIcons/imagecolors.png new file mode 100644 index 0000000000..0ff13a346e Binary files /dev/null and b/examples/qml/particles/images/launcherIcons/imagecolors.png differ diff --git a/examples/qml/particles/images/launcherIcons/list.png b/examples/qml/particles/images/launcherIcons/list.png new file mode 100644 index 0000000000..bc13263cff Binary files /dev/null and b/examples/qml/particles/images/launcherIcons/list.png differ diff --git a/examples/qml/particles/images/launcherIcons/maximumemitted.png b/examples/qml/particles/images/launcherIcons/maximumemitted.png new file mode 100644 index 0000000000..4ef0435991 Binary files /dev/null and b/examples/qml/particles/images/launcherIcons/maximumemitted.png differ diff --git a/examples/qml/particles/images/launcherIcons/multiplepainters.png b/examples/qml/particles/images/launcherIcons/multiplepainters.png new file mode 100644 index 0000000000..a28e3c4f02 Binary files /dev/null and b/examples/qml/particles/images/launcherIcons/multiplepainters.png differ diff --git a/examples/qml/particles/images/launcherIcons/package.png b/examples/qml/particles/images/launcherIcons/package.png new file mode 100644 index 0000000000..eba8951c26 Binary files /dev/null and b/examples/qml/particles/images/launcherIcons/package.png differ diff --git a/examples/qml/particles/images/launcherIcons/particleview.png b/examples/qml/particles/images/launcherIcons/particleview.png new file mode 100644 index 0000000000..a74f9a0340 Binary files /dev/null and b/examples/qml/particles/images/launcherIcons/particleview.png differ diff --git a/examples/qml/particles/images/launcherIcons/plasmapatrol.png b/examples/qml/particles/images/launcherIcons/plasmapatrol.png new file mode 100644 index 0000000000..fda852b420 Binary files /dev/null and b/examples/qml/particles/images/launcherIcons/plasmapatrol.png differ diff --git a/examples/qml/particles/images/launcherIcons/remove.png b/examples/qml/particles/images/launcherIcons/remove.png new file mode 100644 index 0000000000..c37714ee8f Binary files /dev/null and b/examples/qml/particles/images/launcherIcons/remove.png differ diff --git a/examples/qml/particles/images/launcherIcons/rotation.png b/examples/qml/particles/images/launcherIcons/rotation.png new file mode 100644 index 0000000000..6a8dbea236 Binary files /dev/null and b/examples/qml/particles/images/launcherIcons/rotation.png differ diff --git a/examples/qml/particles/images/launcherIcons/samegame.png b/examples/qml/particles/images/launcherIcons/samegame.png new file mode 100644 index 0000000000..d00698264b Binary files /dev/null and b/examples/qml/particles/images/launcherIcons/samegame.png differ diff --git a/examples/qml/particles/images/launcherIcons/shapeanddirection.png b/examples/qml/particles/images/launcherIcons/shapeanddirection.png new file mode 100644 index 0000000000..9c1f910d0c Binary files /dev/null and b/examples/qml/particles/images/launcherIcons/shapeanddirection.png differ diff --git a/examples/qml/particles/images/launcherIcons/spaceexplorer.png b/examples/qml/particles/images/launcherIcons/spaceexplorer.png new file mode 100644 index 0000000000..770584a0fa Binary files /dev/null and b/examples/qml/particles/images/launcherIcons/spaceexplorer.png differ diff --git a/examples/qml/particles/images/launcherIcons/spritegoal.png b/examples/qml/particles/images/launcherIcons/spritegoal.png new file mode 100644 index 0000000000..77480c6f09 Binary files /dev/null and b/examples/qml/particles/images/launcherIcons/spritegoal.png differ diff --git a/examples/qml/particles/images/launcherIcons/sprites.png b/examples/qml/particles/images/launcherIcons/sprites.png new file mode 100644 index 0000000000..144216ac7c Binary files /dev/null and b/examples/qml/particles/images/launcherIcons/sprites.png differ diff --git a/examples/qml/particles/images/launcherIcons/spritevariedparticles.png b/examples/qml/particles/images/launcherIcons/spritevariedparticles.png new file mode 100644 index 0000000000..495bb6beee Binary files /dev/null and b/examples/qml/particles/images/launcherIcons/spritevariedparticles.png differ diff --git a/examples/qml/particles/images/launcherIcons/startstop.png b/examples/qml/particles/images/launcherIcons/startstop.png new file mode 100644 index 0000000000..0ff53196a6 Binary files /dev/null and b/examples/qml/particles/images/launcherIcons/startstop.png differ diff --git a/examples/qml/particles/images/launcherIcons/timedgroupchanges.png b/examples/qml/particles/images/launcherIcons/timedgroupchanges.png new file mode 100644 index 0000000000..ec9f826495 Binary files /dev/null and b/examples/qml/particles/images/launcherIcons/timedgroupchanges.png differ diff --git a/examples/qml/particles/images/launcherIcons/trailemitter.png b/examples/qml/particles/images/launcherIcons/trailemitter.png new file mode 100644 index 0000000000..39acf8b40d Binary files /dev/null and b/examples/qml/particles/images/launcherIcons/trailemitter.png differ diff --git a/examples/qml/particles/images/launcherIcons/trails.png b/examples/qml/particles/images/launcherIcons/trails.png new file mode 100644 index 0000000000..0337ebcfd8 Binary files /dev/null and b/examples/qml/particles/images/launcherIcons/trails.png differ diff --git a/examples/qml/particles/images/launcherIcons/turbulence.png b/examples/qml/particles/images/launcherIcons/turbulence.png new file mode 100644 index 0000000000..2b9446ea90 Binary files /dev/null and b/examples/qml/particles/images/launcherIcons/turbulence.png differ diff --git a/examples/qml/particles/images/launcherIcons/velocityfrommotion.png b/examples/qml/particles/images/launcherIcons/velocityfrommotion.png new file mode 100644 index 0000000000..79baa08293 Binary files /dev/null and b/examples/qml/particles/images/launcherIcons/velocityfrommotion.png differ diff --git a/examples/qml/particles/images/launcherIcons/wander.png b/examples/qml/particles/images/launcherIcons/wander.png new file mode 100644 index 0000000000..d98e14b8ae Binary files /dev/null and b/examples/qml/particles/images/launcherIcons/wander.png differ diff --git a/examples/qml/particles/images/matchmask.png b/examples/qml/particles/images/matchmask.png new file mode 100644 index 0000000000..e575875c55 Binary files /dev/null and b/examples/qml/particles/images/matchmask.png differ diff --git a/examples/qml/particles/images/meteor.png b/examples/qml/particles/images/meteor.png new file mode 100644 index 0000000000..e8c368aea7 Binary files /dev/null and b/examples/qml/particles/images/meteor.png differ diff --git a/examples/qml/particles/images/meteor_explo.png b/examples/qml/particles/images/meteor_explo.png new file mode 100644 index 0000000000..e659bfe2cf Binary files /dev/null and b/examples/qml/particles/images/meteor_explo.png differ diff --git a/examples/qml/particles/images/meteors.png b/examples/qml/particles/images/meteors.png new file mode 100644 index 0000000000..bada8a1407 Binary files /dev/null and b/examples/qml/particles/images/meteors.png differ diff --git a/examples/qml/particles/images/nullRock.png b/examples/qml/particles/images/nullRock.png new file mode 100644 index 0000000000..4076327a1a Binary files /dev/null and b/examples/qml/particles/images/nullRock.png differ diff --git a/examples/qml/particles/images/particle.png b/examples/qml/particles/images/particle.png new file mode 100644 index 0000000000..5c83896d22 Binary files /dev/null and b/examples/qml/particles/images/particle.png differ diff --git a/examples/qml/particles/images/particle2.png b/examples/qml/particles/images/particle2.png new file mode 100644 index 0000000000..36349c6c6e Binary files /dev/null and b/examples/qml/particles/images/particle2.png differ diff --git a/examples/qml/particles/images/particle3.png b/examples/qml/particles/images/particle3.png new file mode 100644 index 0000000000..905d8f37b8 Binary files /dev/null and b/examples/qml/particles/images/particle3.png differ diff --git a/examples/qml/particles/images/particle4.png b/examples/qml/particles/images/particle4.png new file mode 100644 index 0000000000..bc95b703c1 Binary files /dev/null and b/examples/qml/particles/images/particle4.png differ diff --git a/examples/qml/particles/images/particleA.png b/examples/qml/particles/images/particleA.png new file mode 100644 index 0000000000..c63acdee1f Binary files /dev/null and b/examples/qml/particles/images/particleA.png differ diff --git a/examples/qml/particles/images/portal_bg.png b/examples/qml/particles/images/portal_bg.png new file mode 100644 index 0000000000..3c59eeabb9 Binary files /dev/null and b/examples/qml/particles/images/portal_bg.png differ diff --git a/examples/qml/particles/images/realLeaf1.png b/examples/qml/particles/images/realLeaf1.png new file mode 100644 index 0000000000..6cabf29efd Binary files /dev/null and b/examples/qml/particles/images/realLeaf1.png differ diff --git a/examples/qml/particles/images/realLeaf2.png b/examples/qml/particles/images/realLeaf2.png new file mode 100644 index 0000000000..bfeca861d5 Binary files /dev/null and b/examples/qml/particles/images/realLeaf2.png differ diff --git a/examples/qml/particles/images/realLeaf3.png b/examples/qml/particles/images/realLeaf3.png new file mode 100644 index 0000000000..b1071e862b Binary files /dev/null and b/examples/qml/particles/images/realLeaf3.png differ diff --git a/examples/qml/particles/images/realLeaf4.png b/examples/qml/particles/images/realLeaf4.png new file mode 100644 index 0000000000..d61d53d10e Binary files /dev/null and b/examples/qml/particles/images/realLeaf4.png differ diff --git a/examples/qml/particles/images/rocket.png b/examples/qml/particles/images/rocket.png new file mode 100644 index 0000000000..a171610b03 Binary files /dev/null and b/examples/qml/particles/images/rocket.png differ diff --git a/examples/qml/particles/images/rocket2.png b/examples/qml/particles/images/rocket2.png new file mode 100644 index 0000000000..7110f8fdc6 Binary files /dev/null and b/examples/qml/particles/images/rocket2.png differ diff --git a/examples/qml/particles/images/sizeInOut.png b/examples/qml/particles/images/sizeInOut.png new file mode 100644 index 0000000000..0a306ea21a Binary files /dev/null and b/examples/qml/particles/images/sizeInOut.png differ diff --git a/examples/qml/particles/images/snowflake.png b/examples/qml/particles/images/snowflake.png new file mode 100644 index 0000000000..490887a82f Binary files /dev/null and b/examples/qml/particles/images/snowflake.png differ diff --git a/examples/qml/particles/images/sparkleSize.png b/examples/qml/particles/images/sparkleSize.png new file mode 100644 index 0000000000..752056541b Binary files /dev/null and b/examples/qml/particles/images/sparkleSize.png differ diff --git a/examples/qml/particles/images/star.png b/examples/qml/particles/images/star.png new file mode 100644 index 0000000000..0d592cfa87 Binary files /dev/null and b/examples/qml/particles/images/star.png differ diff --git a/examples/qml/particles/images/starfish_0.png b/examples/qml/particles/images/starfish_0.png new file mode 100644 index 0000000000..8747f0236e Binary files /dev/null and b/examples/qml/particles/images/starfish_0.png differ diff --git a/examples/qml/particles/images/starfish_1.png b/examples/qml/particles/images/starfish_1.png new file mode 100644 index 0000000000..1f3f159d5e Binary files /dev/null and b/examples/qml/particles/images/starfish_1.png differ diff --git a/examples/qml/particles/images/starfish_2.png b/examples/qml/particles/images/starfish_2.png new file mode 100644 index 0000000000..c6c7e5a676 Binary files /dev/null and b/examples/qml/particles/images/starfish_2.png differ diff --git a/examples/qml/particles/images/starfish_3.png b/examples/qml/particles/images/starfish_3.png new file mode 100644 index 0000000000..307a89f815 Binary files /dev/null and b/examples/qml/particles/images/starfish_3.png differ diff --git a/examples/qml/particles/images/starfish_4.png b/examples/qml/particles/images/starfish_4.png new file mode 100644 index 0000000000..d61c26545a Binary files /dev/null and b/examples/qml/particles/images/starfish_4.png differ diff --git a/examples/qml/particles/images/starfish_mask.png b/examples/qml/particles/images/starfish_mask.png new file mode 100644 index 0000000000..2ef74f902b Binary files /dev/null and b/examples/qml/particles/images/starfish_mask.png differ diff --git a/examples/qml/particles/itemparticle/content/Delegate.qml b/examples/qml/particles/itemparticle/content/Delegate.qml new file mode 100644 index 0000000000..97c7840cb4 --- /dev/null +++ b/examples/qml/particles/itemparticle/content/Delegate.qml @@ -0,0 +1,88 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +//![0] +Package { + Text { id: listDelegate; width: 200; height: 25; text: 'Empty'; Package.name: 'list' } + Text { id: gridDelegate; width: 100; height: 50; text: 'Empty'; Package.name: 'grid' } + + Rectangle { + id: wrapper + width: 200; height: 25 + color: 'lightsteelblue' + + Text { text: display; anchors.centerIn: parent } + MouseArea { + anchors.fill: parent + onClicked: { + if (wrapper.state == 'inList') + wrapper.state = 'inGrid'; + else + wrapper.state = 'inList'; + } + } + + state: 'inList' + states: [ + State { + name: 'inList' + ParentChange { target: wrapper; parent: listDelegate } + }, + State { + name: 'inGrid' + ParentChange { + target: wrapper; parent: gridDelegate + x: 0; y: 0; width: gridDelegate.width; height: gridDelegate.height + } + } + ] + + transitions: [ + Transition { + ParentAnimation { + NumberAnimation { properties: 'x,y,width,height'; duration: 300 } + } + } + ] + } +} +//![0] diff --git a/examples/qml/particles/itemparticle/content/Delegate2.qml b/examples/qml/particles/itemparticle/content/Delegate2.qml new file mode 100644 index 0000000000..cf60d43dc2 --- /dev/null +++ b/examples/qml/particles/itemparticle/content/Delegate2.qml @@ -0,0 +1,79 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +//![0] +Package { + Item { id: gridDelegate; width: w; height: h; Package.name: 'grid' } + Item { id: particleDelegate; width: w; height: h; Package.name: 'particles' + + Rectangle { + id: wrapper + width: w; height: h; + color: col + rotation: Math.random()*360 + Behavior on rotation {RotationAnimation {}} + + states: State { + name: "gridded" + when: root.inGrid + PropertyChanges { + target: wrapper + rotation: 0 + } + ParentChange { + target: wrapper + parent: gridDelegate + x:0 + y:0 + } + } + transitions: [ + Transition { + ParentAnimation { + NumberAnimation { properties: 'x,y,width,height'; duration: 300 } + } + } + ] + } + } +} +//![0] diff --git a/examples/qml/particles/itemparticle/content/ExpandingDelegate.qml b/examples/qml/particles/itemparticle/content/ExpandingDelegate.qml new file mode 100644 index 0000000000..87f723d3f7 --- /dev/null +++ b/examples/qml/particles/itemparticle/content/ExpandingDelegate.qml @@ -0,0 +1,204 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import "../../../modelviews/listview/content" + +// This example illustrates expanding a list item to show a more detailed view. + + // Delegate for the recipes. This delegate has two modes: + // 1. List mode (default), which just shows the picture and title of the recipe. + // 2. Details mode, which also shows the ingredients and method. + Component { + id: recipeDelegate + + Item { + id: recipe + + // Create a property to contain the visibility of the details. + // We can bind multiple element's opacity to this one property, + // rather than having a "PropertyChanges" line for each element we + // want to fade. + property real detailsOpacity : 0 + + //this bit changed for aesthetics + width: 70 + height: 70 + // A simple rounded rectangle for the background + Rectangle { + id: background + x: 2; y: 2; width: parent.width - x*2; height: parent.height - y*2 + color: "ivory" + border.color: "orange" + radius: 5 + } + Image { + anchors.fill:parent + anchors.margins: -32 + source: "bubble.png" + } + + + // This mouse region covers the entire delegate. + // When clicked it changes mode to 'Details'. If we are already + // in Details mode, then no change will happen. + MouseArea { + anchors.fill: parent + onClicked: recipe.state = 'Details'; + } + + // Lay out the page: picture, title and ingredients at the top, and method at the + // bottom. Note that elements that should not be visible in the list + // mode have their opacity set to recipe.detailsOpacity. + Row { + id: topLayout + x: 10; y: 10; height: recipeImage.height; width: parent.width + spacing: 10 + + Image { + id: recipeImage + width: 50; height: 50 + source: "../../modelviews/listview/" + picture + } + + Column { + width: background.width - recipeImage.width - 20; height: recipeImage.height + spacing: 5 + + Text { + text: title + font.bold: true; font.pointSize: 16 + } + + Text { + text: "Ingredients" + font.pointSize: 12; font.bold: true + opacity: recipe.detailsOpacity + } + + Text { + text: ingredients + wrapMode: Text.WordWrap + width: parent.width + opacity: recipe.detailsOpacity + } + } + } + + Item { + id: details + x: 10; width: parent.width - 20 + anchors { top: topLayout.bottom; topMargin: 10; bottom: parent.bottom; bottomMargin: 10 } + opacity: recipe.detailsOpacity + + Text { + id: methodTitle + anchors.top: parent.top + text: "Method" + font.pointSize: 12; font.bold: true + } + + Flickable { + id: flick + width: parent.width + anchors { top: methodTitle.bottom; bottom: parent.bottom } + contentHeight: methodText.height + clip: true + + Text { id: methodText; text: method; wrapMode: Text.WordWrap; width: details.width } + } + + Image { + anchors { right: flick.right; top: flick.top } + source: "../../modelviews/listview/" + "content/pics/moreUp.png" + opacity: flick.atYBeginning ? 0 : 1 + } + + Image { + anchors { right: flick.right; bottom: flick.bottom } + source: "../../modelviews/listview/" + "content/pics/moreDown.png" + opacity: flick.atYEnd ? 0 : 1 + } + } + + // A button to close the detailed view, i.e. set the state back to default (''). + TextButton { + y: 10 + anchors { right: background.right; rightMargin: 10 } + opacity: recipe.detailsOpacity + text: "Close" + + onClicked: recipe.state = ''; + } + + states: State { + name: "Details" + + PropertyChanges { target: background; color: "white" } + PropertyChanges { target: recipeImage; width: 130; height: 130 } // Make picture bigger + PropertyChanges { target: recipe; detailsOpacity: 1; x: 0; opacity: 1 } // Make details visible + PropertyChanges { target: recipe; height: root.height; width: root.height; x:0; y:0; z:100} // Fill the entire list area with the detailed view + + // Move the list so that this item is at the top. + //PropertyChanges { target: recipe.ListView.view; explicit: true; contentY: recipe.y } + + // Disallow flicking while we're in detailed view + //PropertyChanges { target: recipe.ListView.view; interactive: false } + } + + transitions: Transition { + //The only strictly necessary particle specific lines + to: "Details" + reversible: true + ScriptAction {script: { + if(state == "Details") + mp.freeze(index); + else + mp.unfreeze(index); + } + } + // Make the state changes smooth + ParallelAnimation { + ColorAnimation { property: "color"; duration: 500 } + NumberAnimation { duration: 300; properties: "detailsOpacity,opacity,x,y,height,width" } + } + } + } + } diff --git a/examples/qml/particles/itemparticle/content/RssModel.qml b/examples/qml/particles/itemparticle/content/RssModel.qml new file mode 100644 index 0000000000..46027600b3 --- /dev/null +++ b/examples/qml/particles/itemparticle/content/RssModel.qml @@ -0,0 +1,56 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import QtQuick.XmlListModel 2.0 + +XmlListModel { + property string tags : "" + + function encodeTags(x) { return encodeURIComponent(x.replace(' ',',')); } + + source: "http://api.flickr.com/services/feeds/photos_public.gne?"+(tags ? "tags="+encodeTags(tags)+"&" : "") + query: "/feed/entry" + namespaceDeclarations: "declare default element namespace 'http://www.w3.org/2005/Atom';" + + XmlRole { name: "title"; query: "title/string()" } + XmlRole { name: "content"; query: "content/string()" } + XmlRole { name: "hq"; query: "link[@rel='enclosure']/@href/string()" } +} diff --git a/examples/qml/particles/itemparticle/content/bubble.png b/examples/qml/particles/itemparticle/content/bubble.png new file mode 100644 index 0000000000..c7f479e9e3 Binary files /dev/null and b/examples/qml/particles/itemparticle/content/bubble.png differ diff --git a/examples/qml/particles/itemparticle/content/script.js b/examples/qml/particles/itemparticle/content/script.js new file mode 100644 index 0000000000..e8ef93a847 --- /dev/null +++ b/examples/qml/particles/itemparticle/content/script.js @@ -0,0 +1,27 @@ +.pragma library + +function getWidth(string) { + return (string.match(/width=\"([0-9]+)\"/))[1] +} + +function getHeight(string) { + return (string.match(/height=\"([0-9]+)\"/))[1] +} + +function getImagePath(string) { + var pattern = /src=\"http:\/\/(\S+)\"/ + return (string.match(pattern))[1] +} + +function calculateScale(width, height, cellSize) { + var widthScale = (cellSize * 1.0) / width + var heightScale = (cellSize * 1.0) / height + var scale = 0 + + if (widthScale <= heightScale) { + scale = widthScale; + } else if (heightScale < widthScale) { + scale = heightScale; + } + return scale; +} diff --git a/examples/qml/particles/itemparticle/delegates.qml b/examples/qml/particles/itemparticle/delegates.qml new file mode 100644 index 0000000000..58734d320a --- /dev/null +++ b/examples/qml/particles/itemparticle/delegates.qml @@ -0,0 +1,91 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import QtQuick.Particles 2.0 + +Rectangle { + id: root; + width: 360 + height: 600 + color: "black" + + function newPithySaying() { + switch (Math.floor(Math.random()*16)) { + case 0: return "Hello World"; + case 1: return "G'day Mate"; + case 2: return "Code Less"; + case 3: return "Create More"; + case 4: return "Deploy Everywhere"; + case 5: return "Qt Meta-object Language"; + case 6: return "Qt Magic Language"; + case 7: return "Fluid UIs"; + case 8: return "Touchable"; + case 9: return "How's it going?"; + case 10: return "Do you like text?"; + case 11: return "Enjoy!"; + case 12: return "ERROR: Out of pith"; + case 13: return "Punctuation Failure"; + case 14: return "I can go faster"; + case 15: return "I can go slower"; + default: return "OMGWTFBBQ"; + } + } + + ParticleSystem { + anchors.fill: parent + id: syssy + Emitter { + anchors.centerIn: parent + emitRate: 1 + lifeSpan: 4800 + lifeSpanVariation: 1600 + speed: AngleDirection {angleVariation: 360; magnitude: 40; magnitudeVariation: 20} + } + ItemParticle { + delegate: Text { + text: root.newPithySaying(); + color: "white" + font.pixelSize: 18 + font.bold: true + } + } + } +} diff --git a/examples/qml/particles/itemparticle/particleview.qml b/examples/qml/particles/itemparticle/particleview.qml new file mode 100644 index 0000000000..774539a958 --- /dev/null +++ b/examples/qml/particles/itemparticle/particleview.qml @@ -0,0 +1,274 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import QtQuick.Particles 2.0 +import "content/script.js" as Script +import "content" + +Item { + id: root + width: 640 + height: 480 + Rectangle { + anchors.fill: parent + color: "black" + z: -1 + } + Item { + id: loading + Behavior on opacity {NumberAnimation {}} + anchors.fill: parent + Text { + anchors.centerIn: parent + text: "Loading" + color: "white" + } + } + ParticleSystem { + id: sys; + running: true + } + Emitter { + id: emitter + system: sys + height: parent.height - 132/2 + x: -132/2 + y: 132/2 + speed: PointDirection { x: 32; xVariation: 8 } + emitRate: 0.5 + lifeSpan: Emitter.InfiniteLife + group: "photos" + } + Age { + system: sys + x: parent.width + 132/2 + height: parent.height + width: 1000 + } + ImageParticle { + system: sys + groups: ["fireworks"] + source: "../trails/../images/star.png" + color: "lightsteelblue" + alpha: 0 + colorVariation: 0 + z: 1000 + } + ItemParticle { + id: mp + z: 0 + system: sys + fade: false + groups: ["photos"] + } + Component { + id: alertDelegate + Rectangle { + width: 132 + height: 132 + NumberAnimation on scale { + running: true + loops: 1 + from: 0.2 + to: 1 + } + Image { + source: "../asteroid/../images/rocket.png" + anchors.centerIn: parent + } + Text { + anchors.bottom: parent.bottom + anchors.horizontalCenter: parent.horizontalCenter + text: "A new ship has arrived!" + } + } + } + property Item alertItem; + function alert() { + //resetter.active = false + force.active = true; + alertItem = alertDelegate.createObject(root); + alertItem.x = root.width/2 - alertItem.width/2 + alertItem.y = root.height/2 - alertItem.height/2 + spawnFireworks.pulse(200); + stopAlert.start(); + } + focus: true + Keys.onSpacePressed: alert(); + Timer { + id: stopAlert + running: false + repeat: false + interval: 800 + onTriggered: { + force.active = false + //resetter.active = true; + mp.take(alertItem, true); + centerEmitter.burst(1); + } + } + Attractor { + id: force + system: sys + pointX: root.width/2 + pointY: root.height/2 + strength: -10000 + enabled: false + anchors.centerIn: parent + width: parent.width/2 + height: parent.height/2 + groups:["photos"] + affectedParameter: Attractor.Position + } + Emitter { + id: centerEmitter + speed: PointDirection { x: 32; xVariation: 8;} + emitRate: 0.5 + lifeSpan: 12000 //TODO: A -1 or something which does 'infinite'? (but need disable fade first) + maximumEmitted: 20 + group: "photos" + system: sys + anchors.centerIn: parent + enabled: false + + //TODO: Zoom in effect + } + Emitter { + id: spawnFireworks + group: "fireworks" + system: sys + maximumEmitted: 400 + emitRate: 400 + lifeSpan: 2800 + x: parent.width/2 + y: parent.height/2 - 64 + width: 8 + height: 8 + enabled: false + size: 32 + endSize: 8 + speed: AngleDirection { magnitude: 160; magnitudeVariation: 120; angleVariation: 90; angle: 270 } + acceleration: PointDirection { y: 160 } + } + Item { x: -1000; y: -1000 //offscreen + Repeater {//Load them here, add to system on completed + model: theModel + delegate: theDelegate + } + } + RssModel {id: theModel; tags:"particle,particles"} + Component { + id: theDelegate + Rectangle { + id: container + border.width: 2 + property real myRand: Math.random();//'depth' + z: Math.floor(myRand * 100) + scale: (myRand + 1.0)/2; + //TODO: Darken based on 'depth' + width: 132 + height: 132 + //ItemParticle.onAttached: console.log("I'm in" + x + "," + y + ":" + opacity); + ItemParticle.onDetached: mp.take(container);//respawns + function manage() + { + if (state == "selected") { + console.log("Taking " + index); + mp.freeze(container); + } else { + console.log("Returning " +index); + mp.unfreeze(container); + } + } + Image { + id: img + anchors.centerIn: parent + smooth: true; source: "http://" + Script.getImagePath(content); cache: true + fillMode: Image.PreserveAspectFit; + width: parent.width-4; height: parent.height-4 + onStatusChanged: if (img.status == Image.Ready) { + loading.opacity = 0; + mp.take(container); + } + } + Text { + anchors.bottom: parent.bottom + width: parent.width + horizontalAlignment: Text.AlignHCenter + elide: Text.ElideRight + text: title + color: "black" + } + MouseArea { + anchors.fill: parent + onClicked: container.state == "selected" ? container.state = "" : container.state = "selected" + } + states: State { + name: "selected" + ParentChange { + target: container + parent: root + x: 0 + y: 0 + } + PropertyChanges { + target: container + width: root.width + height: root.height + z: 101 + opacity: 1 + rotation: 0 + } + } + transitions: Transition { + to: "selected" + reversible: true + SequentialAnimation { + ScriptAction {script: container.manage();} + ParallelAnimation { + ParentAnimation {NumberAnimation { properties: "x,y" }}//Doesn't work, particles takes control of x,y instantly + NumberAnimation { properties: "width, height, z, rotation" } + } + } + } + } + } +} diff --git a/examples/qml/particles/plasmapatrol/PlasmaPatrol.qmlproject b/examples/qml/particles/plasmapatrol/PlasmaPatrol.qmlproject new file mode 100644 index 0000000000..548295243d --- /dev/null +++ b/examples/qml/particles/plasmapatrol/PlasmaPatrol.qmlproject @@ -0,0 +1,19 @@ +import QmlProject 1.1 + +Project { + mainFile: "plasmapatrol.qml" + + /* Include .qml, .js, and image files from current directory and subdirectories */ + QmlFiles { + directory: "." + } + JavaScriptFiles { + directory: "." + } + ImageFiles { + directory: "." + } + Files { + paths: ["TODO"] + } +} diff --git a/examples/qml/particles/plasmapatrol/TODO b/examples/qml/particles/plasmapatrol/TODO new file mode 100644 index 0000000000..ef9d21a73d --- /dev/null +++ b/examples/qml/particles/plasmapatrol/TODO @@ -0,0 +1,10 @@ +Realistic Tasks: +Particle explosions on ship death. +Better help text (both content and styled a little nicer). +Hardpoint help showing them firing across the screen. +Endless Demo Mode + +Nice-but-i-doubt-it-will-get-done Tasks: +Particle Text for the winner. +Particle-based buttons. +Single player mode that is challenges (known opponents) to master the game with and earn achievements (in addition to 'skirmish'). diff --git a/examples/qml/particles/plasmapatrol/content/BlasterHardpoint.qml b/examples/qml/particles/plasmapatrol/content/BlasterHardpoint.qml new file mode 100644 index 0000000000..10c50d43c8 --- /dev/null +++ b/examples/qml/particles/plasmapatrol/content/BlasterHardpoint.qml @@ -0,0 +1,133 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtQml module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +import QtQuick 2.0 +import QtQuick.Particles 2.0 + +Item { + id: container + property variant target: {"y": -90, "x":12} + property Item targetObj: container + property Item hardpoint: container + property ParticleSystem system + property int blasts: 16 + property int bonusBlasts: 12 + property bool show: true + + width: 24 + height: 24 + Emitter { + id: visualization + group: "blaster" + system: container.system + enabled: show + anchors.fill: parent + shape: EllipseShape {} + speed: TargetDirection { targetX: width/2; targetY: width/2; magnitude: -1; proportionalMagnitude: true} + lifeSpan: 1000 + emitRate: 64 + + size: 24 + sizeVariation: 24 + endSize: 0 + } + + property int blastsLeft: 0 + function fireAt(targetArg, container) { + target = container.mapFromItem(targetArg, targetArg.width/2, targetArg.height/2); + targetObj = targetArg; + hardpoint = container; + blastsLeft = blasts; + rofTimer.repeat = true; + rofTimer.start(); + } + Timer { + id: rofTimer + interval: 30;//Has to be greater than 1 frame or they stack up + running: false + repeat: false + onTriggered: { + if (targetObj.hp <= 0) + return; + //TODO: calculate hit and damage at target, which must be a Ship + var hit; + if (blastsLeft >= bonusBlasts) + hit = Math.random() > targetObj.dodge; + else + hit = false; //purely aesthetic shots, because the damage isn't that fine grained + if (hit == true) { + switch (targetObj.shipType) { + case 1: hardpoint.damageDealt += 4; break; + case 2: hardpoint.damageDealt += 5; break; + case 3: hardpoint.damageDealt += 1; break; + default: hardpoint.damageDealt += 100; + } + } + blastVector.targetX = target.x; + blastVector.targetY = target.y; + if (!hit) {//TODO: Actual targetVariation + blastVector.targetX += (128 * Math.random() - 64); + blastVector.targetY += (128 * Math.random() - 64); + } + emitter.burst(1); + blastsLeft--; + if (!blastsLeft) + rofTimer.repeat = false; + } + } + Emitter { + id: emitter + group: "blaster" + enabled: false + system: container.system + anchors.centerIn: parent + + lifeSpan: 1000 + emitRate: 16 + maximumEmitted: blasts + size: 24 + endSize:16 + sizeVariation: 8 + speed: TargetDirection { + id: blastVector + targetX: target.x; targetY: target.y; magnitude: 1.1; proportionalMagnitude: true + } + } +} diff --git a/examples/qml/particles/plasmapatrol/content/Button.qml b/examples/qml/particles/plasmapatrol/content/Button.qml new file mode 100644 index 0000000000..992be295fc --- /dev/null +++ b/examples/qml/particles/plasmapatrol/content/Button.qml @@ -0,0 +1,66 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtQml module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +import QtQuick 2.0 + +//TODO: Add particles to this component too +Rectangle { + id: container + property alias text: txt.text + signal clicked + //color: "lightsteelblue" + gradient: Gradient { + GradientStop { position: 0.0; color: "lightsteelblue" } + GradientStop { position: 1.0; color: "steelblue" } + } + height: 64 + radius: 16 + width: 128 + Text { + id: txt + anchors.centerIn: parent + font.pixelSize: 24 + color: "white" + } + MouseArea { + anchors.fill: parent + onClicked: container.clicked() + } +} diff --git a/examples/qml/particles/plasmapatrol/content/CannonHardpoint.qml b/examples/qml/particles/plasmapatrol/content/CannonHardpoint.qml new file mode 100644 index 0000000000..48eb9d171a --- /dev/null +++ b/examples/qml/particles/plasmapatrol/content/CannonHardpoint.qml @@ -0,0 +1,97 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtQml module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +import QtQuick 2.0 +import QtQuick.Particles 2.0 + +Item { + id: container + property variant target: {"y": -90, "x":12} + property ParticleSystem system + property bool show: true + + width: 24 + height: 24 + Emitter { + id: visualization + group: "cannon" + enabled: container.show + system: container.system + anchors.centerIn: parent + lifeSpan: 2000 + emitRate: 1 + + size: 4 + endSize: 0 + } + + function fireAt(targetArg, hardpoint) { + target = container.mapFromItem(targetArg, targetArg.width/2, targetArg.height/2); + if (container.hp <= 0 || targetArg.hp <= 0) + return; + //TODO: calculate hit and damage at target, which must be a Ship + var hit = Math.random() > targetArg.dodge + if (hit) { + switch (targetArg.shipType) { + case 1: hardpoint.damageDealt += 8; break; + case 2: hardpoint.damageDealt += 10; break; + case 3: hardpoint.damageDealt += 16; break; + default: hardpoint.damageDealt += 1000; + } + } + emitter.burst(1); + } + Emitter { + id: emitter + group: "cannon" + enabled: false + system: container.system + anchors.centerIn: parent + + lifeSpan: 1000 + emitRate: 1 + size: 8 + endSize: 4 + speed: TargetDirection { + id: blastVector + targetX: target.x; targetY: target.y; magnitude: 1.1; proportionalMagnitude: true + } + } +} diff --git a/examples/qml/particles/plasmapatrol/content/ChoiceBox.qml b/examples/qml/particles/plasmapatrol/content/ChoiceBox.qml new file mode 100644 index 0000000000..6e21101f2e --- /dev/null +++ b/examples/qml/particles/plasmapatrol/content/ChoiceBox.qml @@ -0,0 +1,105 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtQml module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +import QtQuick 2.0 +import QtQuick.Particles 2.0 + +Item { + id: container + width: 360 + height: 160 + property ParticleSystem system + Ship { + id: nully + system: system + } + property Item target: nully + /* + Component.onCompleted: { + container.target.shipType = 1 + container.target.gunType = 1 + } + */ + Row { + anchors.horizontalCenter: parent.horizontalCenter + height: parent.height + spacing: 8 + Button { + width: 80 + height: 80 + anchors.verticalCenter: parent.verticalCenter + text: "Cycle\nShip" + onClicked: { + var nextVal = container.target.shipType; + if(nextVal == 3) + nextVal = 1; + else + nextVal++; + container.target.shipType = nextVal; + } + } + Item { + width: 128 + height: 128 + anchors.verticalCenter: parent.verticalCenter + Ship { + hp: 20 + anchors.centerIn: parent + shipType: container.target.shipType + gunType: container.target.gunType + system: container.system + } + } + Button { + width: 80 + height: 80 + anchors.verticalCenter: parent.verticalCenter + text: "Cycle\nGun" + onClicked: { + var nextVal = container.target.gunType; + if(nextVal == 3) + nextVal = 1; + else + nextVal++; + container.target.gunType = nextVal; + } + } + } +} diff --git a/examples/qml/particles/plasmapatrol/content/Cruiser.qml b/examples/qml/particles/plasmapatrol/content/Cruiser.qml new file mode 100644 index 0000000000..c469eb46d2 --- /dev/null +++ b/examples/qml/particles/plasmapatrol/content/Cruiser.qml @@ -0,0 +1,146 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtQml module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +import QtQuick 2.0 +import QtQuick.Particles 2.0 + +Item { + id: container + property int maxHP: 100 + property int hp: maxHP + property real initialDodge: 0.01 + property real dodge: initialDodge + onHpChanged: if(hp <= 0) target = container; + property ParticleSystem system//TODO: Ship abstraction + property Item target: container + property string shipParticle: "default"//Per team colors? + property int gunType: 0 + width: 128 + height: 128 + Emitter { + //TODO: Cooler would be an 'orbiting' affector + //TODO: On the subject, opacity and size should be grouped type 'overLife' if we can cram that in the particles + system: container.system + group: container.shipParticle + anchors.centerIn: parent + width: 64 + height: 64 + shape: EllipseShape {} + + emitRate: hp > 0 ? hp * 1 + 20 : 0 + lifeSpan: 2400 + maximumEmitted: (maxHP * 1 + 20)*2.4 + + size: 48 + sizeVariation: 16 + endSize: 16 + + speed: AngleDirection {angleVariation:360; magnitudeVariation: 32} + } + Emitter { + system: container.system + group: "cruiserArmor" + anchors.fill: parent + shape: EllipseShape { fill: false } + enabled: hp>0 + + emitRate: 16 + lifeSpan: 2000 + + size: 48 + sizeVariation: 24 + + SpriteGoal { + id: destructor + system: container.system + enabled: container.hp <=0 + anchors.fill: parent + groups: ["cruiserArmor"] + goalState: "death" +// jump: true + once: true + } + } + + Timer { + id: fireControl + property int next: Math.floor(Math.random() * 3) + 1 + interval: 800 + running: root.readySetGo + repeat: true + onTriggered: { + if (next == 1) { + gun1.fireAt(container.target); + next = Math.floor(Math.random() * 3) + 1; + } else if (next == 2) { + gun2.fireAt(container.target); + next = Math.floor(Math.random() * 3) + 1; + } else if (next == 3) { + gun3.fireAt(container.target); + next = Math.floor(Math.random() * 3) + 1; + } + } + } + + Hardpoint {//TODO: Hardpoint abstraction + x: 112 - 12 - 8*2 + y: 128 - 12 - 12*2 + id: gun1 + system: container.system + show: hp > 0 + hardpointType: gunType + } + Hardpoint { + x: 64 - 12 + y: 0 - 12 + 12*2 + id: gun2 + system: container.system + show: hp > 0 + hardpointType: gunType + } + Hardpoint { + x: 16 - 12 + 8*2 + y: 128 - 12 - 12*2 + id: gun3 + system: container.system + show: hp > 0 + hardpointType: gunType + } +} diff --git a/examples/qml/particles/plasmapatrol/content/Frigate.qml b/examples/qml/particles/plasmapatrol/content/Frigate.qml new file mode 100644 index 0000000000..92c63b87d1 --- /dev/null +++ b/examples/qml/particles/plasmapatrol/content/Frigate.qml @@ -0,0 +1,114 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtQml module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +import QtQuick 2.0 +import QtQuick.Particles 2.0 + +Item { + id: container + property int maxHP: 100 + property int hp: maxHP + property real initialDodge: 0.2 + property real dodge: initialDodge + onHpChanged: if(hp <= 0) target = container; + property ParticleSystem system//TODO: Ship abstraction + property Item target: container + property string shipParticle: "default"//Per team colors? + property int gunType: 0 + width: 128 + height: 128 + Emitter { + system: container.system + group: "frigateShield" + anchors.centerIn: parent + size: 92 + emitRate: 1 + lifeSpan: 4800 + enabled: hp > 0 + } + Emitter { + system: container.system + group: container.shipParticle + anchors.centerIn: parent + width: 64 + height: 16 + shape: EllipseShape {} + + size: 16 + sizeVariation: 8 + endSize: 8 + emitRate: hp > 0 ? hp * 1 + 20 : 0 + lifeSpan: 1200 + maximumEmitted: (maxHP * 1 + 20)*2 + } + Timer { + id: fireControl + property int next: Math.floor(Math.random() * 2) + 1 + interval: 800 + running: root.readySetGo + repeat: true + onTriggered: { + if (next == 1) { + gun1.fireAt(container.target); + next = Math.floor(Math.random() * 2) + 1; + } else if (next == 2) { + gun2.fireAt(container.target); + next = Math.floor(Math.random() * 2) + 1; + } + } + } + + Hardpoint { + x: 128 - 32 - 12 + y: 64 - 12 + id: gun1 + system: container.system + show: hp > 0 + hardpointType: gunType + } + Hardpoint { + x: 0 + 32 - 12 + y: 64 - 12 + id: gun2 + system: container.system + show: hp > 0 + hardpointType: gunType + } +} diff --git a/examples/qml/particles/plasmapatrol/content/Hardpoint.qml b/examples/qml/particles/plasmapatrol/content/Hardpoint.qml new file mode 100644 index 0000000000..9e6057057d --- /dev/null +++ b/examples/qml/particles/plasmapatrol/content/Hardpoint.qml @@ -0,0 +1,114 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtQml module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +import QtQuick 2.0 +import QtQuick.Particles 2.0 + +Item { + id: container + //ReflectiveProperties + //TransferredProperties + property variant target: {"y": -90, "x":12} + property ParticleSystem system + property bool show: true + property int hardpointType: 0 //default is pea shooter - always bad. + + property Item targetObj: null + property int damageDealt: 0 + onDamageDealtChanged: dealDamageTimer.start(); + Timer { + id: dealDamageTimer + interval: 16 + running: false + repeat: false + onTriggered: {targetObj.hp -= damageDealt; damageDealt = 0;} + } + width: 24 + height: 24 + function fireAt(targetArg) {//Each implement own + if (targetArg != null) { + hardpointLoader.item.fireAt(targetArg, container); + targetObj = targetArg; + } + } + Loader { + id: hardpointLoader + sourceComponent: { + switch (hardpointType) { + case 1: laserComponent; break; + case 2: blasterComponent; break; + case 3: cannonComponent; break; + default: emptyComponent; + } + } + } + Component { + id: laserComponent + LaserHardpoint { + target: container.target + system: container.system + show: container.show + } + } + Component { + id: blasterComponent + BlasterHardpoint { + target: container.target + system: container.system + show: container.show + } + } + Component { + id: cannonComponent + CannonHardpoint { + target: container.target + system: container.system + show: container.show + } + } + Component { + id: emptyComponent + Item { + function fireAt(obj) { + console.log("Firing null weapon. It hurts."); + } + } + } +} diff --git a/examples/qml/particles/plasmapatrol/content/HelpScreens.qml b/examples/qml/particles/plasmapatrol/content/HelpScreens.qml new file mode 100644 index 0000000000..db70c6ee90 --- /dev/null +++ b/examples/qml/particles/plasmapatrol/content/HelpScreens.qml @@ -0,0 +1,268 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtQml module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +import QtQuick 2.0 +import QtQuick.Particles 2.0 + +SequentialLoader { + id: hLdr + signal exitDesired + Component.onCompleted: advance(); + ParticleSystem { id: helpSystem } + PlasmaPatrolParticles { sys: helpSystem } + pages: [ + Component {Item { + id: story + Text { + color: "white" + text: "Story" + font.pixelSize: 48 + } + /* + Flickable { + y: 60 + width: 360 + height: 500 + contentHeight: txt1.height + contentWidth: 360//TODO: Less magic numbers? + */ + Text { + id: txt1 + color: "white" + y: 60 + font.pixelSize: 18 + text: " +In a remote nebula, a race of energy beings formed and lived prosperous lives for millenia. Until the schism - when they became constantly at each other's energy-throats. War soon followed, crippling both sides, until a truce was formed. But while governments knew the desparate need for peace, the soldiers in the ion-field were still filled with rampant bloodlust. On the border, patrols are constantly engaging in minor skirmishes whenever they cross paths. + +You must select one such patrol unit for the border, heading into an inevitable skirmish, in Plasma Patrol: the game of energy being spaceship combat! + " + width: 360 + wrapMode: Text.WordWrap + } + // } + Button { + x: 20 + y: 560 + height: 40 + width: 120 + text: "Next" + onClicked: hLdr.advance(); + } + Button { + x: 220 + y: 560 + height: 40 + width: 120 + text: "Menu" + onClicked: hLdr.exitDesired(); + } + }}, + Component {Item { + id: ships + Text { + color: "white" + text: "Vessels" + font.pixelSize: 48 + } + Column { + spacing: 16 + y: 60 + Row { + height: 128 + Sloop { + system: helpSystem + } + Text { + text: "The nimble sloop" + color: "white" + font.pixelSize: 18 + } + } + Row { + height: 128 + Frigate { + system: helpSystem + } + Text { + text: "The versitile shield frigate" + color: "white" + font.pixelSize: 18 + } + } + Row { + height: 128 + Cruiser { + system: helpSystem + } + Text { + text: "The armored cruiser" + color: "white" + font.pixelSize: 18 + } + } + } + Button { + x: 20 + y: 560 + height: 40 + width: 120 + text: "Next" + onClicked: hLdr.advance(); + } + Button { + x: 220 + y: 560 + height: 40 + width: 120 + text: "Menu" + onClicked: hLdr.exitDesired(); + } + }}, + Component {Item { + id: guns + Text { + color: "white" + text: "Hardpoints" + font.pixelSize: 48 + } + Column { + spacing: 16 + y: 60 + Row { + height: 128 + LaserHardpoint { + system: helpSystem + } + Text { + text: "The laser hardpoint almost always hits the target, even the nimble sloop, but loses much of its potency against the frigate's shields" + width: 332 + wrapMode: Text.WordWrap + color: "white" + font.pixelSize: 18 + } + } + Row { + height: 128 + BlasterHardpoint { + system: helpSystem + } + Text { + text: "The blaster passes right through the frigate's shields but loses much of its impact against the armor of the cruiser" + width: 332 + wrapMode: Text.WordWrap + color: "white" + font.pixelSize: 18 + } + } + Row { + height: 128 + CannonHardpoint { + system: helpSystem + } + Text { + text: "The cannon has poor accuracy, often missing the nimble sloop, but can punch right through the armor of the cruiser" + width: 332 + wrapMode: Text.WordWrap + color: "white" + font.pixelSize: 18 + } + } + } + Button { + x: 20 + y: 560 + height: 40 + width: 120 + text: "Next" + onClicked: hLdr.advance(); + } + Button { + x: 220 + y: 560 + height: 40 + width: 120 + text: "Menu" + onClicked: hLdr.exitDesired(); + } + }}, + Component {Item { + id: strategy + Text { + color: "white" + text: "Strategy" + font.pixelSize: 48 + } + Flickable { + y: 60 + width: 360 + height: 500 + contentHeight: txt1.height + contentWidth: 360//TODO: Less magic numbers? + Text { + id: txt1 + color: "white" + font.pixelSize: 18 + text: " +Basic Strategy: Good luck, have fun - don't die. +More to come after thorough playtesting. + " + width: 360 + wrapMode: Text.WordWrap + } + } + Button { + x: 20 + y: 560 + height: 40 + width: 120 + text: "Story" + onClicked: {hLdr.at=0; hLdr.advance();} + } + Button { + x: 220 + y: 560 + height: 40 + width: 120 + text: "Menu" + onClicked: hLdr.exitDesired(); + } + }} + ] +} diff --git a/examples/qml/particles/plasmapatrol/content/LaserHardpoint.qml b/examples/qml/particles/plasmapatrol/content/LaserHardpoint.qml new file mode 100644 index 0000000000..a7baed604b --- /dev/null +++ b/examples/qml/particles/plasmapatrol/content/LaserHardpoint.qml @@ -0,0 +1,108 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtQml module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +import QtQuick 2.0 +import QtQuick.Particles 2.0 + +Item { + id: container + property variant target: {"y": -90, "x":12} + property ParticleSystem system + property bool show: true + + width: 24 + height: 24 + Emitter { + id: visualization + group: "laser" + system: container.system + anchors.fill: parent + enabled: container.show + shape: EllipseShape {} + speed: TargetDirection { targetX: width/2; targetY: width/2; magnitude: -1; proportionalMagnitude: true } + lifeSpan: 1000 + emitRate: 64 + + size: 24 + sizeVariation: 8 + endSize: 8 + } + + function fireAt(targetArg, hardpoint) { + if (targetArg.hp <= 0) + return; + //TODO: calculate hit and damage at target, which must be a Ship + var offset = 0; + if (Math.random() < 0.99) { + switch (targetArg.shipType) { + case 1: hardpoint.damageDealt += 16; break; + case 2: hardpoint.damageDealt += 4; break; + case 3: hardpoint.damageDealt += 8; break; + default: hardpoint.damageDealt += 500; //Really effective against unregistered vessels + } + } else {//Misses with Lasers are really rare + offset = Math.random() * 100; + } + target = container.mapFromItem(targetArg, offset + targetArg.width/2, offset + targetArg.height/2); + emitter.pulse(100); + // console.log("Fire box: " + Math.min(container.width/2, target.x) + "," + Math.min(container.height/2, target.y) + " " + (Math.max(container.width/2, target.x) - Math.min(container.width/2, target.x)) + "," + (Math.max(container.height/2, target.y) - Math.min(container.height/2, target.y))); + } + Emitter { + id: emitter + group: "laser" + enabled: false + system: container.system + x: Math.min(container.width/2, target.x); + width: Math.max(container.width/2, target.x) - x; + y: Math.min(container.height/2, target.y); + height: Math.max(container.height/2, target.y) - y; + shape: LineShape { + mirrored: (emitter.y < 0 || emitter.x < 0) && !(emitter.y < 0 && emitter.x < 0 )//I just want XOR + } + + lifeSpan: 1000 + emitRate: 8000 + maximumEmitted: 800 + size: 16 + endSize: 0 + + speed: PointDirection {xVariation: 4; yVariation: 4} + } +} diff --git a/examples/qml/particles/plasmapatrol/content/PlasmaPatrolParticles.qml b/examples/qml/particles/plasmapatrol/content/PlasmaPatrolParticles.qml new file mode 100644 index 0000000000..87809965b2 --- /dev/null +++ b/examples/qml/particles/plasmapatrol/content/PlasmaPatrolParticles.qml @@ -0,0 +1,173 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtQml module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +import QtQuick 2.0 +import QtQuick.Particles 2.0 + +Item { + property ParticleSystem sys + ImageParticle { + system: sys + groups: ["default"] + source: "pics/blur-circle3.png" + color: "#003A3A3A" + colorVariation: 0.1 + z: 0 + } + ImageParticle { + system: sys + groups: ["redTeam"] + source: "pics/blur-circle3.png" + color: "#0028060A" + colorVariation: 0.1 + z: 0 + } + ImageParticle { + system: sys + groups: ["greenTeam"] + source: "pics/blur-circle3.png" + color: "#0006280A" + colorVariation: 0.1 + z: 0 + } + ImageParticle { + system: sys + groups: ["blaster"] + source: "pics/star2.png" + //color: "#0F282406" + color: "#0F484416" + colorVariation: 0.2 + z: 2 + } + ImageParticle { + system: sys + groups: ["laser"] + source: "pics/star3.png" + //color: "#00123F68" + color: "#00428FF8" + colorVariation: 0.2 + z: 2 + } + ImageParticle { + system: sys + groups: ["cannon"] + source: "pics/particle.png" + color: "#80FFAAFF" + colorVariation: 0.1 + z: 2 + } + ImageParticle { + system: sys + groups: ["cannonCore"] + source: "pics/particle.png" + color: "#00666666" + colorVariation: 0.8 + z: 1 + } + ImageParticle { + system: sys + groups: ["cannonWake"] + source: "pics/star.png" + color: "#00CCCCCC" + colorVariation: 0.2 + z: 1 + } + ImageParticle { + system: sys + groups: ["frigateShield"] + source: "pics/blur-circle2.png" + color: "#00000000" + colorVariation: 0.05 + blueVariation: 0.5 + greenVariation: 0.1 + z: 3 + } + ImageParticle { + system: sys + groups: ["cruiserArmor"] + z: 1 + sprites:[Sprite { + id: spinState + name: "spinning" + source: "pics/meteor.png" + frames: 35 + frameDuration: 40 + to: {"death":0, "spinning":1} + },Sprite { + name: "death" + source: "pics/meteor_explo.png" + frames: 22 + frameDuration: 40 + to: {"null":1} + }, Sprite { + name: "null" + source: "pics/nullRock.png" + frames: 1 + frameDuration: 1000 + } + ] + } + TrailEmitter { + system: sys + group: "cannonWake" + follow: "cannon" + emitRatePerParticle: 64 + lifeSpan: 600 + speed: AngleDirection { angleVariation: 360; magnitude: 48} + size: 16 + endSize: 8 + sizeVariation: 2 + enabled: true + width: 1000//XXX: Terrible hack + height: 1000 + } + TrailEmitter { + system: sys + group: "cannonCore" + follow: "cannon" + emitRatePerParticle: 256 + lifeSpan: 128 + size: 24 + endSize: 8 + enabled: true + width: 1000//XXX: Terrible hack + height: 1000 + } +} diff --git a/examples/qml/particles/plasmapatrol/content/SequentialLoader.qml b/examples/qml/particles/plasmapatrol/content/SequentialLoader.qml new file mode 100644 index 0000000000..3707759ce3 --- /dev/null +++ b/examples/qml/particles/plasmapatrol/content/SequentialLoader.qml @@ -0,0 +1,54 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtQml module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +import QtQuick 2.0 + +Item { + id: container + //TODO: Somehow get particles into this? + property list pages + property Item cur: null + property int at: 0 + function advance() { + if(cur != null) + cur.destroy(); + cur = pages[at++].createObject(container); + } +} diff --git a/examples/qml/particles/plasmapatrol/content/Ship.qml b/examples/qml/particles/plasmapatrol/content/Ship.qml new file mode 100644 index 0000000000..bd023b1dc2 --- /dev/null +++ b/examples/qml/particles/plasmapatrol/content/Ship.qml @@ -0,0 +1,114 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtQml module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +import QtQuick 2.0 +import QtQuick.Particles 2.0 + +Item { + id: me + //Reflective Properties + width: shipLoader.width + height: shipLoader.height + //Transfered Properties + property int hp: 100//shipLoader.item.maxHP + property real dodge: shipLoader.item.initialDodge + property ParticleSystem system + property int targetIdx: 0 + property Item target: targets[targetIdx] == undefined?null:targets[targetIdx] + Connections { + target: me.target + onHpChanged: if (me.target.hp<=0) me.targetIdx++; + } + property list targets + property string shipParticle: "default"//Per team colors? + property int gunType: 0 + property int shipType: 0 + Component { + id: sloopComp + Sloop { + system: me.system + target: me.target + shipParticle: me.shipParticle + gunType: me.gunType + hp: me.hp + dodge: me.dodge + } + } + Component { + id: frigateComp + Frigate { + system: me.system + target: me.target + shipParticle: me.shipParticle + gunType: me.gunType + hp: me.hp + dodge: me.dodge + } + } + Component { + id: cruiserComp + Cruiser { + system: me.system + target: me.target + shipParticle: me.shipParticle + gunType: me.gunType + hp: me.hp + dodge: me.dodge + } + } + Component { + id: dumbComp + Item { + property int maxHP: 0 + property int initialDodge: 0 + } + } + Loader { + id: shipLoader + sourceComponent: { + switch (shipType) { + case 1: sloopComp; break; + case 2: frigateComp; break; + case 3: cruiserComp; break; + default: dumbComp; + } + } + } +} diff --git a/examples/qml/particles/plasmapatrol/content/Sloop.qml b/examples/qml/particles/plasmapatrol/content/Sloop.qml new file mode 100644 index 0000000000..3bc58a28b0 --- /dev/null +++ b/examples/qml/particles/plasmapatrol/content/Sloop.qml @@ -0,0 +1,108 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtQml module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +import QtQuick 2.0 +import QtQuick.Particles 2.0 + +Item { + id: container + property int maxHP: 100 + property int hp: maxHP + property real initialDodge: 0.5 + property real dodge: initialDodge + property int blinkInterval: 800 + onHpChanged: if(hp <= 0) target = container; + property ParticleSystem system//TODO: Ship abstraction + property Item target: container + property string shipParticle: "default"//Per team colors? + property int gunType: 0 + width: 128 + height: 128 + Emitter { + id: emitter + //TODO: Cooler would be an 'orbiting' affector + //TODO: On the subject, opacity and size should be grouped type 'overLife' if we can cram that in the particles + system: container.system + group: container.shipParticle + shape: EllipseShape {} + + emitRate: hp > 0 ? hp + 20 : 0 + lifeSpan: blinkInterval + maximumEmitted: (maxHP + 20) + + acceleration: AngleDirection {angleVariation: 360; magnitude: 8} + + size: 24 + endSize: 4 + sizeVariation: 8 + width: 16 + height: 16 + x: 64 + y: 64 + Behavior on x {NumberAnimation {duration:blinkInterval}} + Behavior on y {NumberAnimation {duration:blinkInterval}} + Timer { + interval: blinkInterval + running: true + repeat: true + onTriggered: { + emitter.x = Math.random() * 48 + 32 + emitter.y = Math.random() * 48 + 32 + } + } + } + Hardpoint { + anchors.centerIn: parent + id: gun2 + system: container.system + show: container.hp > 0 + hardpointType: gunType + } + Timer { + id: fireControl + interval: 800 + running: root.readySetGo + repeat: true + onTriggered: { + gun2.fireAt(container.target); + } + } + +} diff --git a/examples/qml/particles/plasmapatrol/content/pics/TitleText.png b/examples/qml/particles/plasmapatrol/content/pics/TitleText.png new file mode 100644 index 0000000000..dc3acebe39 Binary files /dev/null and b/examples/qml/particles/plasmapatrol/content/pics/TitleText.png differ diff --git a/examples/qml/particles/plasmapatrol/content/pics/blur-circle2.png b/examples/qml/particles/plasmapatrol/content/pics/blur-circle2.png new file mode 100644 index 0000000000..f7c9f3e98e Binary files /dev/null and b/examples/qml/particles/plasmapatrol/content/pics/blur-circle2.png differ diff --git a/examples/qml/particles/plasmapatrol/content/pics/blur-circle3.png b/examples/qml/particles/plasmapatrol/content/pics/blur-circle3.png new file mode 100644 index 0000000000..dbc39cb16e Binary files /dev/null and b/examples/qml/particles/plasmapatrol/content/pics/blur-circle3.png differ diff --git a/examples/qml/particles/plasmapatrol/content/pics/finalfrontier.png b/examples/qml/particles/plasmapatrol/content/pics/finalfrontier.png new file mode 100644 index 0000000000..2ba1815230 Binary files /dev/null and b/examples/qml/particles/plasmapatrol/content/pics/finalfrontier.png differ diff --git a/examples/qml/particles/plasmapatrol/content/pics/meteor.png b/examples/qml/particles/plasmapatrol/content/pics/meteor.png new file mode 100644 index 0000000000..e8c368aea7 Binary files /dev/null and b/examples/qml/particles/plasmapatrol/content/pics/meteor.png differ diff --git a/examples/qml/particles/plasmapatrol/content/pics/meteor_explo.png b/examples/qml/particles/plasmapatrol/content/pics/meteor_explo.png new file mode 100644 index 0000000000..4297245d49 Binary files /dev/null and b/examples/qml/particles/plasmapatrol/content/pics/meteor_explo.png differ diff --git a/examples/qml/particles/plasmapatrol/content/pics/nullRock.png b/examples/qml/particles/plasmapatrol/content/pics/nullRock.png new file mode 100644 index 0000000000..4076327a1a Binary files /dev/null and b/examples/qml/particles/plasmapatrol/content/pics/nullRock.png differ diff --git a/examples/qml/particles/plasmapatrol/content/pics/particle.png b/examples/qml/particles/plasmapatrol/content/pics/particle.png new file mode 100644 index 0000000000..5c83896d22 Binary files /dev/null and b/examples/qml/particles/plasmapatrol/content/pics/particle.png differ diff --git a/examples/qml/particles/plasmapatrol/content/pics/star.png b/examples/qml/particles/plasmapatrol/content/pics/star.png new file mode 100644 index 0000000000..0d592cfa87 Binary files /dev/null and b/examples/qml/particles/plasmapatrol/content/pics/star.png differ diff --git a/examples/qml/particles/plasmapatrol/content/pics/star2.png b/examples/qml/particles/plasmapatrol/content/pics/star2.png new file mode 100644 index 0000000000..bb55c44788 Binary files /dev/null and b/examples/qml/particles/plasmapatrol/content/pics/star2.png differ diff --git a/examples/qml/particles/plasmapatrol/content/pics/star3.png b/examples/qml/particles/plasmapatrol/content/pics/star3.png new file mode 100644 index 0000000000..636a25f480 Binary files /dev/null and b/examples/qml/particles/plasmapatrol/content/pics/star3.png differ diff --git a/examples/qml/particles/plasmapatrol/plasmapatrol.qml b/examples/qml/particles/plasmapatrol/plasmapatrol.qml new file mode 100644 index 0000000000..b14ac6385b --- /dev/null +++ b/examples/qml/particles/plasmapatrol/plasmapatrol.qml @@ -0,0 +1,386 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtQml module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +import QtQuick 2.0 +import QtQuick.Particles 2.0 +import "content" + +Rectangle { + id: root + property bool readySetGo: false + //Debugging + property int hits: 0 + property int misses: 0 + property real ratio: hits/(misses?misses:1) + //Move to JS file? + property Ship redVar1: Ship {shipType: 1; gunType: 1} + property Ship redVar2: Ship {shipType: 1; gunType: 2} + property Ship redVar3: Ship {shipType: 1; gunType: 3} + property Ship greenVar1: Ship {shipType: 3; gunType: 1} + property Ship greenVar2: Ship {shipType: 2; gunType: 2} + property Ship greenVar3: Ship {shipType: 1; gunType: 3} + property string winner: "0" + property int players: 0 + function aiSet(ship) { + ship.gunType = Math.floor(Math.random() * 3) + 1 + ship.shipType = Math.floor(Math.random() * 3) + 1 + } + + width: 360 + height: 600 + color: "black" + SequentialLoader { + anchors.fill: parent + //General Children + Image { + anchors.centerIn: parent + source: "../images/finalfrontier.png" + } + ParticleSystem { + id: particles + } + PlasmaPatrolParticles { sys: particles; z: 100 }//Renders all particles on the one plane + //Component parts + id: pageControl + Component.onCompleted: advance(); + pages:[ + Component {Item { + id: menu + width: root.width + height: root.height + Column { + anchors.verticalCenter: parent.verticalCenter + width: parent.width + spacing: 8 + Item { + id: title + width: root.width + height: 240 + Emitter { + anchors.fill: parent + system: particles + enabled: true + group: "default" + emitRate: 1200 + lifeSpan: 1200 + shape: MaskShape {source:"content/pics/TitleText.png"} + size: 16 + endSize: 0 + sizeVariation: 8 + speed: AngleDirection {angleVariation:360; magnitudeVariation: 6} + } + } + Button { + text: "1P" + onClicked: {root.players = 1; pageControl.advance();} + anchors.horizontalCenter: parent.horizontalCenter + } + Button { + text: "2P" + onClicked: {root.players = 2; pageControl.advance();} + anchors.horizontalCenter: parent.horizontalCenter + } + Button { + text: "Demo" + anchors.horizontalCenter: parent.horizontalCenter + onClicked: {root.players = 0; + aiSet(redVar1); + aiSet(redVar2); + aiSet(redVar3); + aiSet(greenVar1); + aiSet(greenVar2); + aiSet(greenVar3); + pageControl.at = 5;//TODO: Not a magic number + pageControl.advance();} + } + Button { + text: "Help" + anchors.horizontalCenter: parent.horizontalCenter + onClicked: { + pageControl.at = 7;//TODO: Not a magic number + pageControl.advance(); + } + } + Button { + text: "Quit" + anchors.horizontalCenter: parent.horizontalCenter + onClicked: Qt.quit(); + } + } + }}, + Component {Item { + id: p1Screen + z: 101 + width: root.width + height: root.height + Rectangle { + anchors.fill: parent + color: "red" + } + Text { + anchors.centerIn: parent + color: "white" + font.pixelSize: 64 + font.bold: true + text: "Player\n 1" + horizontalAlignment: Text.AlignHCenter + } + MouseArea { + anchors.fill: parent + onClicked: pageControl.advance() + } + }}, + Component {Item { + id: p1Choices + z: 3 + width: root.width + height: root.height + Rectangle { + color: "black" + anchors.fill: parent + } + Column { + spacing: 16 + width: root.width + anchors.horizontalCenter: parent.horizontalCenter + ChoiceBox { + target: redVar1 + system: particles + } + ChoiceBox { + target: redVar2 + system: particles + } + ChoiceBox { + target: redVar3 + system: particles + } + Button { + anchors.horizontalCenter: parent.horizontalCenter + text: "Next" + onClicked: { + if (root.players < 2) { + aiSet(greenVar1); + aiSet(greenVar2); + aiSet(greenVar3); + pageControl.at = 5;//TODO: Not a magic number + } + pageControl.advance(); + } + } + } + }}, + Component {Item { + id: p2Screen + z: 101 + width: root.width + height: root.height + Rectangle { + anchors.fill: parent + color: "green" + } + Text { + anchors.centerIn: parent + color: "white" + font.pixelSize: 64 + font.bold: true + text: "Player\n 2" + horizontalAlignment: Text.AlignHCenter + } + MouseArea { + anchors.fill: parent + onClicked: pageControl.advance() + } + }}, + Component {Item { + id: p2Choices + z: 1 + width: root.width + height: root.height + Rectangle { + color: "black" + anchors.fill: parent + } + Column { + spacing: 16 + width: root.width + anchors.horizontalCenter: parent.horizontalCenter + ChoiceBox { + target: greenVar1 + system: particles + } + ChoiceBox { + target: greenVar2 + system: particles + } + ChoiceBox { + target: greenVar3 + system: particles + } + Button { + anchors.horizontalCenter: parent.horizontalCenter + text: "Next" + onClicked: pageControl.advance() + } + } + }}, + Component {Item { + id: arena + width: root.width + height: root.height + z: 0 + Component.onCompleted: root.readySetGo = true + Component.onDestruction: root.readySetGo = false + property bool victory: redShip3.hp <= 0 || greenShip3.hp <=0 + onVictoryChanged: { + if (redShip3.hp <= 0) { + if (greenShip3.hp <= 0) { + root.winner = "1&2" + }else { + root.winner = "2" + } + } else { + root.winner = "1" + } + winTimer.start() + } + Timer { + id: winTimer + interval: 1200 + repeat: false + running: false + onTriggered: pageControl.advance(); + } + Ship { + id: redShip1 + shipParticle: "redTeam" + system: particles + x: 180-64 + y: 128 + shipType: redVar1.shipType + gunType: redVar1.gunType + targets: [greenShip1, greenShip2, greenShip3] + } + Ship { + id: redShip2 + shipParticle: "redTeam" + system: particles + x: 0 + y: 0 + shipType: redVar2.shipType + gunType: redVar2.gunType + targets: [greenShip1, greenShip2, greenShip3] + } + Ship { + id: redShip3 + shipParticle: "redTeam" + system: particles + x: 360-128 + y: 0 + shipType: redVar3.shipType + gunType: redVar3.gunType + targets: [greenShip1, greenShip2, greenShip3] + } + + Ship { + id: greenShip1 + shipParticle: "greenTeam" + system: particles + x: 180-64 + y: 600 - 128 - 128 + shipType: greenVar1.shipType + gunType: greenVar1.gunType + targets: [redShip1, redShip2, redShip3] + } + Ship { + id: greenShip2 + shipParticle: "greenTeam" + system: particles + x: 0 + y: 600-128 + shipType: greenVar2.shipType + gunType: greenVar2.gunType + targets: [redShip1, redShip2, redShip3] + } + Ship { + id: greenShip3 + shipParticle: "greenTeam" + system: particles + x: 360 - 128 + y: 600 - 128 + shipType: greenVar3.shipType + gunType: greenVar3.gunType + targets: [redShip1, redShip2, redShip3] + } + }}, + Component {Item { + id: winScreen + z: 101 + width: root.width + height: root.height + /* + Rectangle { + anchors.fill: parent + color: "black" + } + */ + Text {//TODO: Particle Text? + anchors.fill: parent + color: "white" + font.pixelSize: 64 + font.bold: true + text: "Player " + root.winner + " wins!" + wrapMode: Text.WordWrap + horizontalAlignment: Text.AlignHCenter + verticalAlignment: Text.AlignVCenter + } + MouseArea { + anchors.fill: parent + onClicked: {pageControl.at = 0; pageControl.advance();} + } + }}, + Component { + HelpScreens { + onExitDesired: {pageControl.at = 0; pageControl.advance();} + } + } + ] + } +} diff --git a/examples/qml/particles/simple/dynamiccomparison.qml b/examples/qml/particles/simple/dynamiccomparison.qml new file mode 100644 index 0000000000..a7cdb9b32a --- /dev/null +++ b/examples/qml/particles/simple/dynamiccomparison.qml @@ -0,0 +1,126 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import QtQuick.Particles 2.0 + +Rectangle { + id: root + color: "black" + width: 640 + height: 480 + ParticleSystem { + id: sys + } + + ImageParticle { + system: sys + source: "../images/particle.png" + color: "white" + colorVariation: 1.0 + alpha: 0.1 + entryEffect: ImageParticle.None + } + + Emitter { + id: emitter + system: sys + width: parent.width/2 + speed: PointDirection {y: 72; yVariation: 24} + lifeSpan: 10000 + emitRate: 1000 + enabled: false + size: 32 + } + + Item { + id: fakeEmitter + function burst(number) { + while (number > 0) { + var item = fakeParticle.createObject(root); + item.lifeSpan = Math.random() * 5000 + 5000; + item.x = Math.random() * 320 + 320; + item.y = 0; + number--; + } + } + + Component { + id: fakeParticle + Image { + id: container + property int lifeSpan: 10000 + width: 32 + height: 32 + source: "../images/particle.png" + y: 0 + PropertyAnimation on y {from: -16; to: 480-16; duration: container.lifeSpan; running: true} + SequentialAnimation on opacity { + running: true + NumberAnimation { from:0; to: 1; duration: 500} + PauseAnimation { duration: container.lifeSpan - 1000} + NumberAnimation { from:1; to: 0; duration: 500} + ScriptAction { script: container.destroy(); } + } + } + } + } + + Text { + anchors.left: parent.left + anchors.bottom: parent.bottom + text: "1000 particles" + color: "white" + MouseArea { + anchors.fill: parent + onClicked: emitter.burst(1000); + } + } + Text { + anchors.right: parent.right + anchors.bottom: parent.bottom + text: "1000 items" + color: "white" + MouseArea { + anchors.fill: parent + onClicked: fakeEmitter.burst(1000); + } + } +} diff --git a/examples/qml/particles/simple/dynamicemitters.qml b/examples/qml/particles/simple/dynamicemitters.qml new file mode 100644 index 0000000000..4431ebe82e --- /dev/null +++ b/examples/qml/particles/simple/dynamicemitters.qml @@ -0,0 +1,122 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import QtQuick.Particles 2.0 + +Rectangle { + id: root + color: "black" + width: 640 + height: 480 + ParticleSystem { + id: sys + } + ImageParticle { + system: sys + source: "../images/particle.png" + color: "white" + colorVariation: 1.0 + alpha: 0.1 + } + + Component { + id: emitterComp + Emitter { + id: container + Emitter { + id: emitMore + system: sys + emitRate: 128 + lifeSpan: 600 + size: 16 + endSize: 8 + speed: AngleDirection {angleVariation:360; magnitude: 60} + } + + property int life: 2600 + property real targetX: 0 + property real targetY: 0 + function go() { + xAnim.start(); + yAnim.start(); + container.enabled = true + } + system: sys + emitRate: 32 + lifeSpan: 600 + size: 24 + endSize: 8 + NumberAnimation on x { + id: xAnim; + to: targetX + duration: life + running: false + } + NumberAnimation on y { + id: yAnim; + to: targetY + duration: life + running: false + } + Timer { + interval: life + running: true + onTriggered: container.destroy(); + } + } + } + + MouseArea { + anchors.fill: parent + onClicked: { + for (var i=0; i<8; i++) { + var obj = emitterComp.createObject(root); + obj.x = mouse.x + obj.y = mouse.y + obj.targetX = Math.random() * 240 - 120 + obj.x + obj.targetY = Math.random() * 240 - 120 + obj.y + obj.life = Math.round(Math.random() * 2400) + 200 + obj.emitRate = Math.round(Math.random() * 32) + 32 + obj.go(); + } + } + } +} diff --git a/examples/qml/particles/simple/multiplepainters.qml b/examples/qml/particles/simple/multiplepainters.qml new file mode 100644 index 0000000000..c1b85caa2d --- /dev/null +++ b/examples/qml/particles/simple/multiplepainters.qml @@ -0,0 +1,90 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import QtQuick.Particles 2.0 + +Rectangle { + id: root + width: 360 + height: 600 + color: "darkblue" + property bool cloneMode: false + ParticleSystem { + id: sys + } + MouseArea { + anchors.fill: parent + onClicked: cloneMode = !cloneMode; + } + Emitter { + system: sys + y:root.height + 20 + width: root.width + emitRate: 200 + lifeSpan: 4000 + startTime: 4000 + speed: PointDirection { y: -120; } + } + + ImageParticle { + system: sys + visible: !cloneMode + source: "../images/particle2.png" + } + + ImageParticle { + system: sys + visible: cloneMode + z: 0 + source: "../images/particle3.png" + } + + ImageParticle { + system: sys + clip: true + visible: cloneMode + y: 120 + height: 240 + width: root.width + z: 1 + source: "../images/particle.png" + } +} diff --git a/examples/qml/particles/simple/startstop.qml b/examples/qml/particles/simple/startstop.qml new file mode 100644 index 0000000000..62105b28a0 --- /dev/null +++ b/examples/qml/particles/simple/startstop.qml @@ -0,0 +1,81 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import QtQuick.Particles 2.0 + +Rectangle { + width: 360 + height: 540 + color: "black" + MouseArea { + anchors.fill: parent + acceptedButtons: Qt.LeftButton | Qt.RightButton + onClicked: { + if (mouse.button == Qt.LeftButton) + particles.running = !particles.running + else + particles.paused = !particles.paused; + } + } + + ParticleSystem { + id: particles + running: false + } + + ImageParticle { + anchors.fill: parent + system: particles + source: "../images/star.png" + sizeTable: "../images/sparkleSize.png" + alpha: 0 + colorVariation: 0.6 + } + + Emitter { + anchors.fill: parent + system: particles + emitRate: 2000 + lifeSpan: 2000 + size: 30 + sizeVariation: 10 + } +} diff --git a/examples/qml/photoviewer/PhotoViewerCore/AlbumDelegate.qml b/examples/qml/photoviewer/PhotoViewerCore/AlbumDelegate.qml new file mode 100644 index 0000000000..164f47faa9 --- /dev/null +++ b/examples/qml/photoviewer/PhotoViewerCore/AlbumDelegate.qml @@ -0,0 +1,147 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtQml module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import QtQuick.XmlListModel 2.0 + +Component { + id: albumDelegate + Package { + + Item { + Package.name: 'browser' + GridView { + id: photosGridView; model: visualModel.parts.grid; width: mainWindow.width; height: mainWindow.height - 21 + x: 0; y: 21; cellWidth: 160; cellHeight: 153; interactive: false + onCurrentIndexChanged: photosListView.positionViewAtIndex(currentIndex, ListView.Contain) + } + } + + Item { + Package.name: 'fullscreen' + ListView { + id: photosListView; model: visualModel.parts.list; orientation: Qt.Horizontal + width: mainWindow.width; height: mainWindow.height; interactive: false + onCurrentIndexChanged: photosGridView.positionViewAtIndex(currentIndex, GridView.Contain) + highlightRangeMode: ListView.StrictlyEnforceRange; snapMode: ListView.SnapOneItem + } + } + + Item { + Package.name: 'album' + id: albumWrapper; width: 210; height: 220 + + VisualDataModel { + id: visualModel; delegate: PhotoDelegate { } + model: RssModel { id: rssModel; tags: tag } + } + + BusyIndicator { + id: busyIndicator + anchors { centerIn: parent; verticalCenterOffset: -20 } + on: rssModel.status != XmlListModel.Ready + } + + PathView { + id: photosPathView; model: visualModel.parts.stack; pathItemCount: 5 + visible: !busyIndicator.visible + anchors.centerIn: parent; anchors.verticalCenterOffset: -30 + path: Path { + PathAttribute { name: 'z'; value: 9999.0 } + PathLine { x: 1; y: 1 } + PathAttribute { name: 'z'; value: 0.0 } + } + } + + MouseArea { + anchors.fill: parent + onClicked: mainWindow.editMode ? photosModel.remove(index) : albumWrapper.state = 'inGrid' + } + + Tag { + anchors { horizontalCenter: parent.horizontalCenter; bottom: parent.bottom; bottomMargin: 10 } + frontLabel: tag; backLabel: qsTr("Remove"); flipped: mainWindow.editMode + onTagChanged: rssModel.tags = tag + onBackClicked: if (mainWindow.editMode) photosModel.remove(index); + } + + states: [ + State { + name: 'inGrid' + PropertyChanges { target: photosGridView; interactive: true } + PropertyChanges { target: albumsShade; opacity: 1 } + PropertyChanges { target: backButton; onClicked: albumWrapper.state = ''; y: 6 } + }, + State { + name: 'fullscreen'; extend: 'inGrid' + PropertyChanges { target: photosGridView; interactive: false } + PropertyChanges { target: photosListView; interactive: true } + PropertyChanges { target: photosShade; opacity: 1 } + PropertyChanges { target: backButton; y: -backButton.height - 8 } + } + ] + + GridView.onAdd: NumberAnimation { + target: albumWrapper; properties: "scale"; from: 0.0; to: 1.0; easing.type: Easing.OutQuad + } + GridView.onRemove: SequentialAnimation { + PropertyAction { target: albumWrapper; property: "GridView.delayRemove"; value: true } + NumberAnimation { target: albumWrapper; property: "scale"; from: 1.0; to: 0.0; easing.type: Easing.OutQuad } + PropertyAction { target: albumWrapper; property: "GridView.delayRemove"; value: false } + } + + transitions: [ + Transition { + from: '*'; to: 'inGrid' + SequentialAnimation { + NumberAnimation { properties: 'opacity'; duration: 250 } + PauseAnimation { duration: 350 } + NumberAnimation { target: backButton; properties: "y"; duration: 200; easing.type: Easing.OutQuad } + } + }, + Transition { + from: 'inGrid'; to: '*' + NumberAnimation { properties: "y,opacity"; easing.type: Easing.OutQuad; duration: 300 } + } + ] + } + } +} diff --git a/examples/qml/photoviewer/PhotoViewerCore/BusyIndicator.qml b/examples/qml/photoviewer/PhotoViewerCore/BusyIndicator.qml new file mode 100644 index 0000000000..867c268399 --- /dev/null +++ b/examples/qml/photoviewer/PhotoViewerCore/BusyIndicator.qml @@ -0,0 +1,50 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtQml module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Image { + id: container + property bool on: false + + source: "images/busy.png"; visible: container.on + NumberAnimation on rotation { running: container.on; from: 0; to: 360; loops: Animation.Infinite; duration: 1200 } +} diff --git a/examples/qml/photoviewer/PhotoViewerCore/Button.qml b/examples/qml/photoviewer/PhotoViewerCore/Button.qml new file mode 100644 index 0000000000..8f4177c097 --- /dev/null +++ b/examples/qml/photoviewer/PhotoViewerCore/Button.qml @@ -0,0 +1,72 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtQml module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Item { + id: container + + property alias label: labelText.text + property color tint: "transparent" + signal clicked + + width: labelText.width + 70 ; height: labelText.height + 18 + + BorderImage { + anchors { fill: container; leftMargin: -6; topMargin: -6; rightMargin: -8; bottomMargin: -8 } + source: 'images/box-shadow.png'; smooth: true + border.left: 10; border.top: 10; border.right: 10; border.bottom: 10 + } + + Image { anchors.fill: parent; source: "images/cardboard.png"; smooth: true } + + Rectangle { + anchors.fill: container; color: container.tint; visible: container.tint != "" + opacity: 0.25; smooth: true + } + + Text { id: labelText; font.pixelSize: 15; anchors.centerIn: parent; smooth: true } + + MouseArea { + anchors { fill: parent; leftMargin: -20; topMargin: -20; rightMargin: -20; bottomMargin: -20 } + onClicked: container.clicked() + } +} diff --git a/examples/qml/photoviewer/PhotoViewerCore/EditableButton.qml b/examples/qml/photoviewer/PhotoViewerCore/EditableButton.qml new file mode 100644 index 0000000000..435ad2644f --- /dev/null +++ b/examples/qml/photoviewer/PhotoViewerCore/EditableButton.qml @@ -0,0 +1,86 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtQml module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Item { + id: container + + property string label + signal clicked + signal labelChanged(string label) + + width: textInput.width + 70 ; height: textInput.height + 18 + + BorderImage { + anchors { fill: container; leftMargin: -6; topMargin: -6; rightMargin: -8; bottomMargin: -8 } + source: 'images/box-shadow.png'; smooth: true + border.left: 10; border.top: 10; border.right: 10; border.bottom: 10 + } + + Image { anchors.fill: parent; source: "images/cardboard.png"; smooth: true } + + TextInput { + id: textInput; text: label; font.pixelSize: 15; anchors.centerIn: parent; smooth: true + Keys.onReturnPressed: { + container.labelChanged(textInput.text) + container.focus = true + } + Keys.onEnterPressed: { + container.labelChanged(textInput.text) + container.focus = true + } + Keys.onEscapePressed: { + textInput.text = container.label + container.focus = true + } + } + + Rectangle { + anchors.fill: container; border.color: "steelblue"; border.width: 4 + color: "transparent"; visible: textInput.focus; smooth: true + } + + MouseArea { + anchors { fill: parent; leftMargin: -20; topMargin: -20; rightMargin: -20; bottomMargin: -20 } + onClicked: { textInput.forceActiveFocus(); textInput.openSoftwareInputPanel(); } + } +} diff --git a/examples/qml/photoviewer/PhotoViewerCore/PhotoDelegate.qml b/examples/qml/photoviewer/PhotoViewerCore/PhotoDelegate.qml new file mode 100644 index 0000000000..5d4e5aee5d --- /dev/null +++ b/examples/qml/photoviewer/PhotoViewerCore/PhotoDelegate.qml @@ -0,0 +1,188 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtQml module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import "script/script.js" as Script + +Package { + Item { id: stackItem; Package.name: 'stack'; width: 160; height: 153; z: stackItem.PathView.z } + Item { id: listItem; Package.name: 'list'; width: mainWindow.width + 40; height: 153 } + Item { id: gridItem; Package.name: 'grid'; width: 160; height: 153 } + + Item { + width: 160; height: 153 + + Item { + id: photoWrapper + + property double randomAngle: Math.random() * (2 * 6 + 1) - 6 + property double randomAngle2: Math.random() * (2 * 6 + 1) - 6 + + x: 0; y: 0; width: 140; height: 133 + z: stackItem.PathView.z; rotation: photoWrapper.randomAngle + + BorderImage { + anchors { + fill: originalImage.status == Image.Ready ? border : placeHolder + leftMargin: -6; topMargin: -6; rightMargin: -8; bottomMargin: -8 + } + source: 'images/box-shadow.png'; smooth: true + border.left: 10; border.top: 10; border.right: 10; border.bottom: 10 + } + Rectangle { + id: placeHolder + + property int w: Script.getWidth(content) + property int h: Script.getHeight(content) + property double s: Script.calculateScale(w, h, photoWrapper.width) + + color: 'white'; anchors.centerIn: parent; smooth: true + width: w * s; height: h * s; visible: originalImage.status != Image.Ready + Rectangle { + color: "#878787"; smooth: true + anchors { fill: parent; topMargin: 3; bottomMargin: 3; leftMargin: 3; rightMargin: 3 } + } + } + Rectangle { + id: border; color: 'white'; anchors.centerIn: parent; smooth: true + width: originalImage.paintedWidth + 6; height: originalImage.paintedHeight + 6 + visible: !placeHolder.visible + } + BusyIndicator { anchors.centerIn: parent; on: originalImage.status != Image.Ready } + Image { + id: originalImage; smooth: true; source: "http://" + Script.getImagePath(content); cache: false + fillMode: Image.PreserveAspectFit; width: photoWrapper.width; height: photoWrapper.height + } + Image { + id: hqImage; smooth: true; source: ""; visible: false; cache: false + fillMode: Image.PreserveAspectFit; width: photoWrapper.width; height: photoWrapper.height + } + Binding { + target: mainWindow; property: "downloadProgress"; value: hqImage.progress + when: listItem.ListView.isCurrentItem + } + Binding { + target: mainWindow; property: "imageLoading" + value: (hqImage.status == Image.Loading) ? 1 : 0; when: listItem.ListView.isCurrentItem + } + MouseArea { + width: originalImage.paintedWidth; height: originalImage.paintedHeight; anchors.centerIn: originalImage + onClicked: { + if (albumWrapper.state == 'inGrid') { + gridItem.GridView.view.currentIndex = index; + albumWrapper.state = 'fullscreen' + } else { + gridItem.GridView.view.currentIndex = index; + albumWrapper.state = 'inGrid' + } + } + } + + states: [ + State { + name: 'stacked'; when: albumWrapper.state == '' + ParentChange { target: photoWrapper; parent: stackItem; x: 10; y: 10 } + PropertyChanges { target: photoWrapper; opacity: stackItem.PathView.onPath ? 1.0 : 0.0 } + }, + State { + name: 'inGrid'; when: albumWrapper.state == 'inGrid' + ParentChange { target: photoWrapper; parent: gridItem; x: 10; y: 10; rotation: photoWrapper.randomAngle2 } + }, + State { + name: 'fullscreen'; when: albumWrapper.state == 'fullscreen' + ParentChange { + target: photoWrapper; parent: listItem; x: 0; y: 0; rotation: 0 + width: mainWindow.width; height: mainWindow.height + } + PropertyChanges { target: border; opacity: 0 } + PropertyChanges { target: hqImage; source: listItem.ListView.isCurrentItem ? hq : ""; visible: true } + } + ] + + transitions: [ + Transition { + from: 'stacked'; to: 'inGrid' + SequentialAnimation { + PauseAnimation { duration: 10 * index } + ParentAnimation { + target: photoWrapper; via: foreground + NumberAnimation { + target: photoWrapper; properties: 'x,y,rotation,opacity'; duration: 600; easing.type: 'OutQuart' + } + } + } + }, + Transition { + from: 'inGrid'; to: 'stacked' + ParentAnimation { + target: photoWrapper; via: foreground + NumberAnimation { properties: 'x,y,rotation,opacity'; duration: 600; easing.type: 'OutQuart' } + } + }, + Transition { + from: 'inGrid'; to: 'fullscreen' + SequentialAnimation { + PauseAnimation { duration: gridItem.GridView.isCurrentItem ? 0 : 600 } + ParentAnimation { + target: photoWrapper; via: foreground + NumberAnimation { + targets: [ photoWrapper, border ] + properties: 'x,y,width,height,opacity,rotation' + duration: gridItem.GridView.isCurrentItem ? 600 : 1; easing.type: 'OutQuart' + } + } + } + }, + Transition { + from: 'fullscreen'; to: 'inGrid' + ParentAnimation { + target: photoWrapper; via: foreground + NumberAnimation { + targets: [ photoWrapper, border ] + properties: 'x,y,width,height,rotation,opacity' + duration: gridItem.GridView.isCurrentItem ? 600 : 1; easing.type: 'OutQuart' + } + } + } + ] + } + } +} diff --git a/examples/qml/photoviewer/PhotoViewerCore/ProgressBar.qml b/examples/qml/photoviewer/PhotoViewerCore/ProgressBar.qml new file mode 100644 index 0000000000..58beef57f3 --- /dev/null +++ b/examples/qml/photoviewer/PhotoViewerCore/ProgressBar.qml @@ -0,0 +1,57 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtQml module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Item { + id: container + + property real progress: 0 + + Behavior on opacity { NumberAnimation { duration: 600 } } + + Rectangle { anchors.fill: parent; color: "black"; opacity: 0.5 } + + Rectangle { + id: fill; color: "white"; height: container.height + width: container.width * container.progress + } +} diff --git a/examples/qml/photoviewer/PhotoViewerCore/RssModel.qml b/examples/qml/photoviewer/PhotoViewerCore/RssModel.qml new file mode 100644 index 0000000000..1598977bb1 --- /dev/null +++ b/examples/qml/photoviewer/PhotoViewerCore/RssModel.qml @@ -0,0 +1,57 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtQml module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import QtQuick.XmlListModel 2.0 + +XmlListModel { + property string tags : "" + + function encodeTags(x) { return encodeURIComponent(x.replace(' ',',')); } + + source: "http://api.flickr.com/services/feeds/photos_public.gne?"+(tags ? "tags="+encodeTags(tags)+"&" : "") + query: "/feed/entry" + namespaceDeclarations: "declare default element namespace 'http://www.w3.org/2005/Atom';" + + XmlRole { name: "title"; query: "title/string()" } + XmlRole { name: "content"; query: "content/string()" } + XmlRole { name: "hq"; query: "link[@rel='enclosure']/@href/string()" } +} diff --git a/examples/qml/photoviewer/PhotoViewerCore/Tag.qml b/examples/qml/photoviewer/PhotoViewerCore/Tag.qml new file mode 100644 index 0000000000..ed4a248a7b --- /dev/null +++ b/examples/qml/photoviewer/PhotoViewerCore/Tag.qml @@ -0,0 +1,91 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtQml module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Flipable { + id: flipable + + property alias frontLabel: frontButton.label + property alias backLabel: backButton.label + + property int angle: 0 + property int randomAngle: Math.random() * (2 * 6 + 1) - 6 + property bool flipped: false + + signal frontClicked + signal backClicked + signal tagChanged(string tag) + + front: EditableButton { + id: frontButton; rotation: flipable.randomAngle + anchors { centerIn: parent; verticalCenterOffset: -20 } + onClicked: flipable.frontClicked() + onLabelChanged: flipable.tagChanged(label) + } + + back: Button { + id: backButton; tint: "red"; rotation: flipable.randomAngle + anchors { centerIn: parent; verticalCenterOffset: -20 } + onClicked: flipable.backClicked() + } + + transform: Rotation { + origin.x: flipable.width / 2; origin.y: flipable.height / 2 + axis.x: 0; axis.y: 1; axis.z: 0 + angle: flipable.angle + } + + states: State { + name: "back"; when: flipable.flipped + PropertyChanges { target: flipable; angle: 180 } + } + + transitions: Transition { + ParallelAnimation { + NumberAnimation { properties: "angle"; duration: 400 } + SequentialAnimation { + NumberAnimation { target: flipable; property: "scale"; to: 0.8; duration: 200 } + NumberAnimation { target: flipable; property: "scale"; to: 1.0; duration: 200 } + } + } + } +} diff --git a/examples/qml/photoviewer/PhotoViewerCore/images/box-shadow.png b/examples/qml/photoviewer/PhotoViewerCore/images/box-shadow.png new file mode 100644 index 0000000000..431af8545d Binary files /dev/null and b/examples/qml/photoviewer/PhotoViewerCore/images/box-shadow.png differ diff --git a/examples/qml/photoviewer/PhotoViewerCore/images/busy.png b/examples/qml/photoviewer/PhotoViewerCore/images/busy.png new file mode 100644 index 0000000000..664c2b1491 Binary files /dev/null and b/examples/qml/photoviewer/PhotoViewerCore/images/busy.png differ diff --git a/examples/qml/photoviewer/PhotoViewerCore/images/cardboard.png b/examples/qml/photoviewer/PhotoViewerCore/images/cardboard.png new file mode 100644 index 0000000000..1847ab528d Binary files /dev/null and b/examples/qml/photoviewer/PhotoViewerCore/images/cardboard.png differ diff --git a/examples/qml/photoviewer/PhotoViewerCore/qmldir b/examples/qml/photoviewer/PhotoViewerCore/qmldir new file mode 100644 index 0000000000..d3c247f21a --- /dev/null +++ b/examples/qml/photoviewer/PhotoViewerCore/qmldir @@ -0,0 +1,8 @@ +AlbumDelegate AlbumDelegate.qml +PhotoDelegate PhotoDelegate.qml +ProgressBar ProgressBar.qml +RssModel RssModel.qml +BusyIndicator BusyIndicator.qml +EditableButton EditableButton.qml +Button Button.qml +Tag Tag.qml diff --git a/examples/qml/photoviewer/PhotoViewerCore/script/script.js b/examples/qml/photoviewer/PhotoViewerCore/script/script.js new file mode 100644 index 0000000000..e8ef93a847 --- /dev/null +++ b/examples/qml/photoviewer/PhotoViewerCore/script/script.js @@ -0,0 +1,27 @@ +.pragma library + +function getWidth(string) { + return (string.match(/width=\"([0-9]+)\"/))[1] +} + +function getHeight(string) { + return (string.match(/height=\"([0-9]+)\"/))[1] +} + +function getImagePath(string) { + var pattern = /src=\"http:\/\/(\S+)\"/ + return (string.match(pattern))[1] +} + +function calculateScale(width, height, cellSize) { + var widthScale = (cellSize * 1.0) / width + var heightScale = (cellSize * 1.0) / height + var scale = 0 + + if (widthScale <= heightScale) { + scale = widthScale; + } else if (heightScale < widthScale) { + scale = heightScale; + } + return scale; +} diff --git a/examples/qml/photoviewer/i18n/base.ts b/examples/qml/photoviewer/i18n/base.ts new file mode 100644 index 0000000000..1accfd2f90 --- /dev/null +++ b/examples/qml/photoviewer/i18n/base.ts @@ -0,0 +1,30 @@ + + + + + AlbumDelegate + + + Remove + + + + + photoviewer + + + Add + + + + + Edit + + + + + Back + + + + diff --git a/examples/qml/photoviewer/i18n/qml_fr.qm b/examples/qml/photoviewer/i18n/qml_fr.qm new file mode 100644 index 0000000000..c24fcbc46c Binary files /dev/null and b/examples/qml/photoviewer/i18n/qml_fr.qm differ diff --git a/examples/qml/photoviewer/i18n/qml_fr.ts b/examples/qml/photoviewer/i18n/qml_fr.ts new file mode 100644 index 0000000000..9f892db616 --- /dev/null +++ b/examples/qml/photoviewer/i18n/qml_fr.ts @@ -0,0 +1,30 @@ + + + + + AlbumDelegate + + + Remove + Supprimer + + + + photoviewer + + + Add + Ajouter + + + + Edit + Éditer + + + + Back + Retour + + + diff --git a/examples/qml/photoviewer/photoviewer.qml b/examples/qml/photoviewer/photoviewer.qml new file mode 100644 index 0000000000..208720b9e6 --- /dev/null +++ b/examples/qml/photoviewer/photoviewer.qml @@ -0,0 +1,110 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtQml module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import "PhotoViewerCore" + +Rectangle { + id: mainWindow + + property real downloadProgress: 0 + property bool imageLoading: false + property bool editMode: false + + width: 800; height: 480; color: "#d5d6d8" + + ListModel { + id: photosModel + ListElement { tag: "Flowers" } + ListElement { tag: "Wildlife" } + ListElement { tag: "Prague" } + } + + VisualDataModel { id: albumVisualModel; model: photosModel; delegate: AlbumDelegate {} } + + GridView { + id: albumView; width: parent.width; height: parent.height; cellWidth: 210; cellHeight: 220 + model: albumVisualModel.parts.album; visible: albumsShade.opacity != 1.0 + } + + Column { + spacing: 20; anchors { bottom: parent.bottom; right: parent.right; rightMargin: 20; bottomMargin: 20 } + Button { + id: newButton; label: qsTr("Add"); rotation: 3 + anchors.horizontalCenter: parent.horizontalCenter + onClicked: { + mainWindow.editMode = false + photosModel.append( { tag: "" } ) + albumView.positionViewAtIndex(albumView.count - 1, GridView.Contain) + } + } + Button { + id: deleteButton; label: qsTr("Edit"); rotation: -2; + onClicked: mainWindow.editMode = !mainWindow.editMode + anchors.horizontalCenter: parent.horizontalCenter + } + Button { + id: quitButton; label: qsTr("Quit"); rotation: -2; + onClicked: Qt.quit() + anchors.horizontalCenter: parent.horizontalCenter + } + } + + Rectangle { + id: albumsShade; color: mainWindow.color + width: parent.width; height: parent.height; opacity: 0.0 + } + + ListView { anchors.fill: parent; model: albumVisualModel.parts.browser; interactive: false } + + Button { id: backButton; label: qsTr("Back"); rotation: 3; x: parent.width - backButton.width - 6; y: -backButton.height - 8 } + + Rectangle { id: photosShade; color: 'black'; width: parent.width; height: parent.height; opacity: 0; visible: opacity != 0.0 } + + ListView { anchors.fill: parent; model: albumVisualModel.parts.fullscreen; interactive: false } + + Item { id: foreground; anchors.fill: parent } + + ProgressBar { + progress: mainWindow.downloadProgress; width: parent.width; height: 4 + anchors.bottom: parent.bottom; opacity: mainWindow.imageLoading; visible: opacity != 0.0 + } +} diff --git a/examples/qml/photoviewer/photoviewer.qmlproject b/examples/qml/photoviewer/photoviewer.qmlproject new file mode 100644 index 0000000000..600bdb10f4 --- /dev/null +++ b/examples/qml/photoviewer/photoviewer.qmlproject @@ -0,0 +1,20 @@ +import QmlProject 1.1 + +Project { + mainFile: "photoviewer.qml" + + /* Include .qml, .js, and image files from current directory and subdirectories */ + QmlFiles { + directory: "." + } + JavaScriptFiles { + directory: "." + } + ImageFiles { + directory: "." + } + Files { + filter: "*.ts" + directory: "i18n" + } +} diff --git a/examples/qml/positioners/content/Button.qml b/examples/qml/positioners/content/Button.qml new file mode 100644 index 0000000000..ee3aa9057e --- /dev/null +++ b/examples/qml/positioners/content/Button.qml @@ -0,0 +1,78 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Rectangle { + id: page + + property string text + property string icon + signal clicked + + border.color: "black"; color: "steelblue"; radius: 5 + width: pix.width + textelement.width + 13 + height: pix.height + 10 + + Image { id: pix; x: 5; y:5; source: parent.icon } + + Text { + id: textelement + text: page.text; color: "white" + x: pix.width + pix.x + 3 + anchors.verticalCenter: pix.verticalCenter + } + + MouseArea { + id: mr + anchors.fill: parent + onClicked: { parent.focus = true; page.clicked() } + } + + states: State { + name: "pressed"; when: mr.pressed + PropertyChanges { target: textelement; x: 5 } + PropertyChanges { target: pix; x: textelement.x + textelement.width + 3 } + } + + transitions: Transition { + NumberAnimation { properties: "x,left"; easing.type: Easing.InOutQuad; duration: 200 } + } +} diff --git a/examples/qml/positioners/content/add.png b/examples/qml/positioners/content/add.png new file mode 100644 index 0000000000..1ee45423e3 Binary files /dev/null and b/examples/qml/positioners/content/add.png differ diff --git a/examples/qml/positioners/content/del.png b/examples/qml/positioners/content/del.png new file mode 100644 index 0000000000..8d2eaed523 Binary files /dev/null and b/examples/qml/positioners/content/del.png differ diff --git a/examples/qml/positioners/positioners-attachedproperties.qml b/examples/qml/positioners/positioners-attachedproperties.qml new file mode 100644 index 0000000000..a05927f5ea --- /dev/null +++ b/examples/qml/positioners/positioners-attachedproperties.qml @@ -0,0 +1,106 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Rectangle { + width: 400 + height: 100 + + // Create row with four rectangles, the fourth one is hidden + Row { + id: row + + Rectangle { + id: red + color: "red" + width: 100 + height: 100 + + // When mouse is clicked, display the values of the positioner + MouseArea { + anchors.fill: parent + onClicked: row.showInfo(red.Positioner) + } + } + + Rectangle { + id: green + color: "green" + width: 100 + height: 100 + + // When mouse is clicked, display the values of the positioner + MouseArea { + anchors.fill: parent + onClicked: row.showInfo(green.Positioner) + } + } + + Rectangle { + id: blue + color: "blue" + width: 100 + height: 100 + + // When mouse is clicked, display the values of the positioner + MouseArea { + anchors.fill: parent + onClicked: row.showInfo(blue.Positioner) + } + } + + // This rectangle is not visible, so it doesn't have a positioner value + Rectangle { + color: "black" + width: 100 + height: 100 + visible: false + } + + // Print the index of the child item in the positioner and convenience + // properties showing if it's the first or last item. + function showInfo(positioner) { + console.log("Item Index = " + positioner.index) + console.log(" isFirstItem = " + positioner.isFirstItem) + console.log(" isLastItem = " + positioner.isLastItem) + } + } +} diff --git a/examples/qml/positioners/positioners.qml b/examples/qml/positioners/positioners.qml new file mode 100644 index 0000000000..d9d16649ff --- /dev/null +++ b/examples/qml/positioners/positioners.qml @@ -0,0 +1,264 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import "content" + +Rectangle { + id: page + width: 420; height: 420 + + Column { + id: layout1 + y: 0 + move: Transition { + NumberAnimation { properties: "y"; easing.type: Easing.OutBounce } + } + add: Transition { + NumberAnimation { properties: "y"; easing.type: Easing.OutQuad } + } + + Rectangle { color: "red"; width: 100; height: 50; border.color: "black"; radius: 15 } + + Rectangle { + id: blueV1 + visible: opacity != 0 + width: 100; height: 50 + color: "lightsteelblue" + border.color: "black" + radius: 15 + Behavior on opacity { NumberAnimation {} } + } + + Rectangle { color: "green"; width: 100; height: 50; border.color: "black"; radius: 15 } + + Rectangle { + id: blueV2 + visible: opacity != 0 + width: 100; height: 50 + color: "lightsteelblue" + border.color: "black" + radius: 15 + Behavior on opacity { NumberAnimation {} } + } + + Rectangle { color: "orange"; width: 100; height: 50; border.color: "black"; radius: 15 } + } + + Row { + id: layout2 + y: 300 + move: Transition { + NumberAnimation { properties: "x"; easing.type: Easing.OutBounce } + } + add: Transition { + NumberAnimation { properties: "x"; easing.type: Easing.OutQuad } + } + + Rectangle { color: "red"; width: 50; height: 100; border.color: "black"; radius: 15 } + + Rectangle { + id: blueH1 + visible: opacity != 0 + width: 50; height: 100 + color: "lightsteelblue" + border.color: "black" + radius: 15 + Behavior on opacity { NumberAnimation {} } + } + + Rectangle { color: "green"; width: 50; height: 100; border.color: "black"; radius: 15 } + + Rectangle { + id: blueH2 + visible: opacity != 0 + width: 50; height: 100 + color: "lightsteelblue" + border.color: "black" + radius: 15 + Behavior on opacity { NumberAnimation {} } + } + + Rectangle { color: "orange"; width: 50; height: 100; border.color: "black"; radius: 15 } + } + + Button { + x: 135; y: 90 + text: "Remove" + icon: "del.png" + + onClicked: { + blueH2.opacity = 0 + blueH1.opacity = 0 + blueV1.opacity = 0 + blueV2.opacity = 0 + blueG1.opacity = 0 + blueG2.opacity = 0 + blueG3.opacity = 0 + blueF1.opacity = 0 + blueF2.opacity = 0 + blueF3.opacity = 0 + } + } + + Button { + x: 145; y: 140 + text: "Add" + icon: "add.png" + + onClicked: { + blueH2.opacity = 1 + blueH1.opacity = 1 + blueV1.opacity = 1 + blueV2.opacity = 1 + blueG1.opacity = 1 + blueG2.opacity = 1 + blueG3.opacity = 1 + blueF1.opacity = 1 + blueF2.opacity = 1 + blueF3.opacity = 1 + } + } + + Grid { + x: 260; y: 0 + columns: 3 + + move: Transition { + NumberAnimation { properties: "x,y"; easing.type: Easing.OutBounce } + } + + add: Transition { + NumberAnimation { properties: "x,y"; easing.type: Easing.OutBounce } + } + + Rectangle { color: "red"; width: 50; height: 50; border.color: "black"; radius: 15 } + + Rectangle { + id: blueG1 + visible: opacity != 0 + width: 50; height: 50 + color: "lightsteelblue" + border.color: "black" + radius: 15 + Behavior on opacity { NumberAnimation {} } + } + + Rectangle { color: "green"; width: 50; height: 50; border.color: "black"; radius: 15 } + + Rectangle { + id: blueG2 + visible: opacity != 0 + width: 50; height: 50 + color: "lightsteelblue" + border.color: "black" + radius: 15 + Behavior on opacity { NumberAnimation {} } + } + + Rectangle { color: "orange"; width: 50; height: 50; border.color: "black"; radius: 15 } + + Rectangle { + id: blueG3 + visible: opacity != 0 + width: 50; height: 50 + color: "lightsteelblue" + border.color: "black" + radius: 15 + Behavior on opacity { NumberAnimation {} } + } + + Rectangle { color: "red"; width: 50; height: 50; border.color: "black"; radius: 15 } + Rectangle { color: "green"; width: 50; height: 50; border.color: "black"; radius: 15 } + Rectangle { color: "orange"; width: 50; height: 50; border.color: "black"; radius: 15 } + } + + Flow { + id: layout4 + x: 260; y: 250; width: 150 + + move: Transition { + NumberAnimation { properties: "x,y"; easing.type: Easing.OutBounce } + } + + add: Transition { + NumberAnimation { properties: "x,y"; easing.type: Easing.OutBounce } + } + + Rectangle { color: "red"; width: 50; height: 50; border.color: "black"; radius: 15 } + + Rectangle { + id: blueF1 + visible: opacity != 0 + width: 60; height: 50 + color: "lightsteelblue" + border.color: "black" + radius: 15 + Behavior on opacity { NumberAnimation {} } + } + + Rectangle { color: "green"; width: 30; height: 50; border.color: "black"; radius: 15 } + + Rectangle { + id: blueF2 + visible: opacity != 0 + width: 60; height: 50 + color: "lightsteelblue" + border.color: "black" + radius: 15 + Behavior on opacity { NumberAnimation {} } + } + + Rectangle { color: "orange"; width: 50; height: 50; border.color: "black"; radius: 15 } + + Rectangle { + id: blueF3 + visible: opacity != 0 + width: 40; height: 50 + color: "lightsteelblue" + border.color: "black" + radius: 15 + Behavior on opacity { NumberAnimation {} } + } + + Rectangle { color: "red"; width: 80; height: 50; border.color: "black"; radius: 15 } + } + +} diff --git a/examples/qml/qml.pro b/examples/qml/qml.pro new file mode 100644 index 0000000000..23d33bd653 --- /dev/null +++ b/examples/qml/qml.pro @@ -0,0 +1,38 @@ +TEMPLATE = subdirs + +# These examples contain some C++ and need to be built +SUBDIRS = \ + cppextensions \ + minehunt \ + modelviews \ + painteditem \ + tutorials \ + script + +# These examples contain no C++ and can simply be copied +sources.files = \ + animation \ + calculator \ + cppextensions \ + flickr \ + i18n \ + imageelements \ + keyinteraction \ + photoviewer \ + positioners \ + rssnews \ + samegame \ + snake \ + sqllocalstorage \ + text \ + threading \ + touchinteraction \ + toys \ + twitter \ + ui-components \ + webbrowser \ + xml + + +sources.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/qml +INSTALLS += sources diff --git a/examples/qml/righttoleft/layoutdirection/layoutdirection.qml b/examples/qml/righttoleft/layoutdirection/layoutdirection.qml new file mode 100644 index 0000000000..0c65647d5b --- /dev/null +++ b/examples/qml/righttoleft/layoutdirection/layoutdirection.qml @@ -0,0 +1,246 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Rectangle { + id: root + property bool mirror + property int direction: Qt.application.layoutDirection + LayoutMirroring.enabled: mirror + LayoutMirroring.childrenInherit: true + width: column.width + 80 + height: column.height + 40 + Column { + id: column + width: 190 + spacing: 10 + anchors.centerIn: parent + + Text { + text: "Row" + anchors.horizontalCenter: parent.horizontalCenter + } + + Row { + layoutDirection: root.direction + spacing: 10 + move: Transition { + NumberAnimation { + properties: "x" + } + } + Repeater { + model: 4 + Loader { + property int value: index + sourceComponent: positionerDelegate + } + } + } + + Text { + text: "Grid" + anchors.horizontalCenter: parent.horizontalCenter + } + + Grid { + layoutDirection: root.direction + spacing: 10; columns: 4 + move: Transition { + NumberAnimation { + properties: "x" + } + } + Repeater { + model: 11 + Loader { + property int value: index + sourceComponent: positionerDelegate + } + } + } + + Text { + text: "Flow" + anchors.horizontalCenter: parent.horizontalCenter + } + + Flow { + layoutDirection: root.direction + spacing: 10; width: parent.width + move: Transition { + NumberAnimation { + properties: "x" + } + } + Repeater { + model: 10 + Loader { + property int value: index + sourceComponent: positionerDelegate + } + } + } + + Text { + text: "ListView" + anchors.horizontalCenter: parent.horizontalCenter + } + + ListView { + id: listView + clip: true + width: parent.width; height: 40 + layoutDirection: root.direction + orientation: Qt.Horizontal + model: 48 + delegate: viewDelegate + } + + Text { + text: "GridView" + anchors.horizontalCenter: parent.horizontalCenter + } + + GridView { + clip: true + width: 200; height: 160 + cellWidth: 50; cellHeight: 50 + layoutDirection: root.direction + model: 48 + delegate: viewDelegate + } + + Rectangle { + height: 50; width: parent.width + color: mouseArea.pressed ? "black" : "gray" + Column { + anchors.centerIn: parent + Text { + text: root.direction ? "Right to left" : "Left to right" + color: "white" + font.pixelSize: 16 + anchors.horizontalCenter: parent.horizontalCenter + } + Text { + text: "(click here to toggle)" + color: "white" + font.pixelSize: 10 + font.italic: true + anchors.horizontalCenter: parent.horizontalCenter + } + } + MouseArea { + id: mouseArea + anchors.fill: parent + onClicked: { + if (root.direction == Qt.LeftToRight) { + root.direction = Qt.RightToLeft; + } else { + root.direction = Qt.LeftToRight; + } + } + } + } + + Rectangle { + height: 50; width: parent.width + color: mouseArea2.pressed ? "black" : "gray" + Column { + anchors.centerIn: parent + Text { + text: root.mirror ? "Mirrored" : "Not mirrored" + color: "white" + font.pixelSize: 16 + anchors.horizontalCenter: parent.horizontalCenter + } + Text { + text: "(click here to toggle)" + color: "white" + font.pixelSize: 10 + font.italic: true + anchors.horizontalCenter: parent.horizontalCenter + } + } + MouseArea { + id: mouseArea2 + anchors.fill: parent + onClicked: { + root.mirror = !root.mirror; + } + } + } + } + + Component { + id: positionerDelegate + Rectangle { + width: 40; height: 40 + color: Qt.rgba(0.8/(parent.value+1),0.8/(parent.value+1),0.8/(parent.value+1),1.0) + Text { + text: parent.parent.value+1 + color: "white" + font.pixelSize: 18 + anchors.centerIn: parent + } + } + } + Component { + id: viewDelegate + Item { + width: (listView.effectiveLayoutDirection == Qt.LeftToRight ? (index == 48 - 1) : (index == 0)) ? 40 : 50 + Rectangle { + width: 40; height: 40 + color: Qt.rgba(0.5+(48 - index)*Math.random()/48, + 0.3+index*Math.random()/48, + 0.3*Math.random(), + 1.0) + Text { + text: index+1 + color: "white" + font.pixelSize: 18 + anchors.centerIn: parent + } + } + } + } +} + diff --git a/examples/qml/righttoleft/layoutdirection/layoutdirection.qmlproject b/examples/qml/righttoleft/layoutdirection/layoutdirection.qmlproject new file mode 100644 index 0000000000..33cbb3c9e2 --- /dev/null +++ b/examples/qml/righttoleft/layoutdirection/layoutdirection.qmlproject @@ -0,0 +1,16 @@ +import QmlProject 1.1 + +Project { + mainFile: "layoutdirection.qml" + + /* Include .qml, .js, and image files from current directory and subdirectories */ + QmlFiles { + directory: "." + } + JavaScriptFiles { + directory: "." + } + ImageFiles { + directory: "." + } +} diff --git a/examples/qml/righttoleft/layoutmirroring/layoutmirroring.qml b/examples/qml/righttoleft/layoutmirroring/layoutmirroring.qml new file mode 100644 index 0000000000..5c4739bd57 --- /dev/null +++ b/examples/qml/righttoleft/layoutmirroring/layoutmirroring.qml @@ -0,0 +1,313 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Rectangle { + id: root + property bool mirror: Qt.application.layoutDirection == Qt.RightToLeft + LayoutMirroring.enabled: mirror + LayoutMirroring.childrenInherit: true + width: 400 + height: 875 + color: "lightsteelblue" + + Column { + spacing: 10 + anchors { left: parent.left; right: parent.right; top: parent.top; margins: 10 } + + Text { + text: "Positioners" + anchors.left: parent.left + } + + Column { + id: positioners + spacing: 5 + anchors.left: parent.left + Row { + id: row + spacing: 4 + property string text: "THISISROW" + anchors.left: parent.left + Repeater { + model: parent.text.length + delegate: positionerDelegate + } + } + Flow { + id: flow + spacing: 4 + width: 90 + property string text: "THISISFLOW" + anchors.left: parent.left + Repeater { + model: parent.text.length + delegate: positionerDelegate + } + } + Grid { + id: grid + spacing: 4 + columns: 6 + property string text: "THISISGRID" + anchors.left: parent.left + Repeater { + model: parent.text.length + delegate: positionerDelegate + } + } + Component { + id: positionerDelegate + Text { + color: "white" + font.pixelSize: 20 + text: parent.text[index] + Rectangle { + z: -1 + opacity: 0.7 + color: "black" + anchors.fill: parent + } + } + } + } + + Text { + text: "Text alignment" + anchors.left: parent.left + } + + Rectangle { + id: textStrings + width: 148 + height: 85 + color: "white" + anchors.left: parent.left + Column { + spacing: 5 + width: parent.width + anchors { fill: parent; margins: 5 } + Text { + id: englishText + width: parent.width + text: "English text" + } + Text { + id: arabicText + width: parent.width + text: "النص العربي" + } + Text { + id: leftAlignedText + width: parent.width + text: "Text aligned to left" + horizontalAlignment: Text.AlignLeft + } + Text { + id: rightAlignedText + width: parent.width + text: "Text aligned to right" + horizontalAlignment: Text.AlignRight + } + } + } + + Text { + text: "Model views" + anchors.left: parent.left + } + + Column { + id: views + spacing: 10 + anchors.left: parent.left + ListView { + id: listView + z: -1 + clip: true + model: text.length + width: 360; height: 45 + orientation: Qt.Horizontal + property string text: "LISTVIEWLISTVIEWLISTVIEWLISTVIEWLISTVIEWLISTVIEW" + delegate: Rectangle { + color: "black" + width: 45; height: 45 + Rectangle { + anchors { fill: parent; margins: 1 } + color: "red" + } + Text { + text: listView.text[index] + font.pixelSize: 30 + anchors.centerIn: parent + } + } + } + GridView { + id: gridView + z: -1 + clip: true + model: text.length + width: 180; height: 90 + cellWidth: 45; cellHeight: 45 + property string text: "GRIDVIEWGRIDVIEWGRIDVIEWGRIDVIEWGRIDVIEWGRIDVIEW" + anchors.left: parent.left + delegate: Rectangle { + color: "black" + width: 45; height: 45 + Rectangle { + anchors { fill: parent; margins: 1 } + color: "red" + } + Text { + anchors.centerIn: parent + font.pixelSize: 30 + text: gridView.text[index] + } + } + } + } + + Text { + text: "Item x" + anchors.left: parent.left + } + Rectangle { + id: items + color: Qt.rgba(0.2, 0.2, 0.2, 0.6) + width: 275; height: 95 + anchors.left: parent.left + Rectangle { + y: 5; x: 5 + width: 130; height: 40 + Text { + text: "Item with x: 5\n(not mirrored)" + anchors.centerIn: parent + } + } + Rectangle { + color: Qt.rgba(0.7, 0.7, 0.7) + y: 50; x: mirror(5) + width: 130; height: 40 + function mirror(value) { + return LayoutMirroring.enabled ? (parent.width - width - value) : value; + } + Text { + text: "Item with x: " + parent.x + "\n(manually mirrored)" + anchors.centerIn: parent + } + } + } + Text { + text: "Item anchors" + anchors.left: parent.left + } + + Rectangle { + id: anchoredItems + color: Qt.rgba(0.2, 0.2, 0.2, 0.6) + width: 270; height: 170 + anchors.left: parent.left + Rectangle { + id: blackRectangle + color: "black" + width: 180; height: 90 + anchors { horizontalCenter: parent.horizontalCenter; horizontalCenterOffset: 30 } + Text { + text: "Horizontal center anchored\nwith offset 30\nto the horizontal center\nof the parent." + color: "white" + anchors.centerIn: parent + } + } + Rectangle { + id: whiteRectangle + color: "white" + width: 120; height: 70 + anchors { left: parent.left; bottom: parent.bottom } + Text { + text: "Left side anchored\nto the left side\nof the parent." + color: "black" + anchors.centerIn: parent + } + } + Rectangle { + id: grayRectangle + color: Qt.rgba(0.7, 0.7, 0.7) + width: 140; height: 90 + anchors { right: parent.right; bottom: parent.bottom } + Text { + text: "Right side anchored\nto the right side\nof the parent." + anchors.centerIn: parent + } + } + } + Rectangle { + id: mirrorButton + color: mouseArea2.pressed ? "black" : "gray" + height: 50; width: parent.width + anchors.left: parent.left + Column { + anchors.centerIn: parent + Text { + text: root.mirror ? "Mirrored" : "Not mirrored" + color: "white" + font.pixelSize: 16 + anchors.horizontalCenter: parent.horizontalCenter + } + Text { + text: "(click here to toggle)" + color: "white" + font.pixelSize: 10 + font.italic: true + anchors.horizontalCenter: parent.horizontalCenter + } + } + MouseArea { + id: mouseArea2 + anchors.fill: parent + onClicked: { + root.mirror = !root.mirror; + } + } + } + } +} + diff --git a/examples/qml/righttoleft/layoutmirroring/layoutmirroring.qmlproject b/examples/qml/righttoleft/layoutmirroring/layoutmirroring.qmlproject new file mode 100644 index 0000000000..72bc04a8a9 --- /dev/null +++ b/examples/qml/righttoleft/layoutmirroring/layoutmirroring.qmlproject @@ -0,0 +1,16 @@ +import QmlProject 1.1 + +Project { + mainFile: "layoutmirroring.qml" + + /* Include .qml, .js, and image files from current directory and subdirectories */ + QmlFiles { + directory: "." + } + JavaScriptFiles { + directory: "." + } + ImageFiles { + directory: "." + } +} diff --git a/examples/qml/righttoleft/textalignment/textalignment.qml b/examples/qml/righttoleft/textalignment/textalignment.qml new file mode 100644 index 0000000000..ef5b97bb1a --- /dev/null +++ b/examples/qml/righttoleft/textalignment/textalignment.qml @@ -0,0 +1,427 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Rectangle { + id: root + color: "white" + width: containerColumn.width + height: containerColumn.height + containerColumn.anchors.topMargin + + property bool mirror: false + property variant horizontalAlignment: undefined + + property variant editorType: ["Plain Text", "Styled Text", "Plain Rich Text", "Italic Rich Text", "Plain TextEdit", "Italic TextEdit", "TextInput"] + property variant text: ["", " ", "Hello world!", "مرحبا العالم!", "Hello world! Hello!\nHello world! Hello!", "مرحبا العالم! مرحبا! مرحبا العالم! مرحبا!" ,"مرحبا العالم! مرحبا! مرحبا Hello world!\nالعالم! مرحبا!"] + property variant description: ["empty text", "white-space-only text", "left-to-right text", "right-to-left text", "multi-line left-to-right text", "multi-line right-to-left text", "multi-line bidi text"] + property variant textComponents: [plainTextComponent, styledTextComponent, richTextComponent, italicRichTextComponent, plainTextEdit, italicTextEdit, textInput] + + function shortText(horizontalAlignment) { + + // all the different QML editors have + // the same alignment values + switch (horizontalAlignment) { + case Text.AlignLeft: + return "L"; + case Text.AlignRight: + return "R"; + case Text.AlignHCenter: + return "C"; + case Text.AlignJustify: + return "J"; + default: + return "Error"; + } + } + Column { + id: containerColumn + spacing: 10 + width: editorTypeRow.width + anchors { top: parent.top; topMargin: 5 } + Row { + id: editorTypeRow + Repeater { + model: editorType.length + Item { + width: editorColumn.width + height: editorColumn.height + Column { + id: editorColumn + spacing: 5 + width: textColumn.width+10 + Text { + text: root.editorType[index] + font.pixelSize: 16 + anchors.horizontalCenter: parent.horizontalCenter + } + Column { + id: textColumn + spacing: 5 + anchors.horizontalCenter: parent.horizontalCenter + Repeater { + model: textComponents.length + delegate: textComponents[index] + } + } + } + } + } + } + Column { + spacing: 2 + width: parent.width + Rectangle { + // button + height: 50; width: parent.width + color: mouseArea.pressed ? "black" : "lightgray" + Column { + anchors.centerIn: parent + Text { + text: root.mirror ? "Mirrored" : "Not mirrored" + color: "white" + font.pixelSize: 16 + anchors.horizontalCenter: parent.horizontalCenter + } + Text { + text: "(click here to toggle)" + color: "white" + font.pixelSize: 10 + font.italic: true + anchors.horizontalCenter: parent.horizontalCenter + } + } + MouseArea { + id: mouseArea + property int index: 0 + anchors.fill: parent + onClicked: root.mirror = !root.mirror + } + } + Rectangle { + // button + height: 50; width: parent.width + color: mouseArea2.pressed ? "black" : "gray" + Column { + anchors.centerIn: parent + Text { + text: { + if (root.horizontalAlignment == undefined) + return "Implict alignment"; + switch (root.horizontalAlignment) { + case Text.AlignLeft: + return "Left alignment"; + case Text.AlignRight: + return "Right alignment"; + case Text.AlignHCenter: + return "Center alignment"; + case Text.AlignJustify: + return "Justify alignment"; + } + } + color: "white" + font.pixelSize: 16 + anchors.horizontalCenter: parent.horizontalCenter + } + Text { + text: "(click here to toggle)" + color: "white" + font.pixelSize: 10 + font.italic: true + anchors.horizontalCenter: parent.horizontalCenter + } + } + MouseArea { + id: mouseArea2 + property int index: 0 + anchors.fill: parent + onClicked: { + if (index < 0) { + root.horizontalAlignment = undefined; + } else { + root.horizontalAlignment = Math.pow(2, index); + } + index = (index + 2) % 5 - 1; + } + } + } + } + } + + Component { + id: plainTextComponent + Text { + width: 180 + text: root.text[index] + font.pixelSize: 24 + wrapMode: Text.WordWrap + horizontalAlignment: root.horizontalAlignment + LayoutMirroring.enabled: root.mirror + textFormat: Text.RichText + Rectangle { + z: -1 + color: Qt.rgba(0.8, 0.2, 0.2, 0.3) + anchors.fill: parent + } + Text { + text: root.description[index] + color: Qt.rgba(1,1,1,1.0) + anchors.centerIn: parent + Rectangle { + z: -1 + color: Qt.rgba(0.3, 0, 0, 0.3) + anchors { fill: parent; margins: -3 } + } + } + Text { + color: "white" + text: shortText(parent.horizontalAlignment) + anchors { top: parent.top; right: parent.right; margins: 2 } + } + } + } + + Component { + id: styledTextComponent + Text { + width: 180 + text: root.text[index] + font.pixelSize: 24 + wrapMode: Text.WordWrap + horizontalAlignment: root.horizontalAlignment + LayoutMirroring.enabled: root.mirror + textFormat: Text.RichText + style: Text.Sunken + styleColor: "white" + Rectangle { + z: -1 + color: Qt.rgba(0.8, 0.2, 0.2, 0.3) + anchors.fill: parent + } + Text { + text: root.description[index] + color: Qt.rgba(1,1,1,1.0) + anchors.centerIn: parent + Rectangle { + z: -1 + color: Qt.rgba(0.3, 0, 0, 0.3) + anchors { fill: parent; margins: -3 } + } + } + Text { + color: "white" + text: shortText(parent.horizontalAlignment) + anchors { top: parent.top; right: parent.right; margins: 2 } + } + } + } + + Component { + id: richTextComponent + Text { + width: 180 + text: root.text[index] + font.pixelSize: 24 + wrapMode: Text.WordWrap + horizontalAlignment: root.horizontalAlignment + LayoutMirroring.enabled: root.mirror + textFormat: Text.RichText + Rectangle { + z: -1 + color: Qt.rgba(0.8, 0.2, 0.2, 0.3) + anchors.fill: parent + } + Text { + text: root.description[index] + color: Qt.rgba(1,1,1,1.0) + anchors.centerIn: parent + Rectangle { + z: -1 + color: Qt.rgba(0.3, 0, 0, 0.3) + anchors { fill: parent; margins: -3 } + } + } + Text { + color: "white" + text: shortText(parent.horizontalAlignment) + anchors { top: parent.top; right: parent.right; margins: 2 } + } + } + } + + Component { + id: italicRichTextComponent + Text { + width: 180 + text: "" + root.text[index] + "" + font.pixelSize: 24 + wrapMode: Text.WordWrap + horizontalAlignment: root.horizontalAlignment + LayoutMirroring.enabled: root.mirror + textFormat: Text.RichText + property variant backgroundColor: Qt.rgba(0.8, 0.2, 0.2, 0.3) + Rectangle { + z: -1 + color: parent.backgroundColor + anchors.fill: parent + } + Text { + text: root.description[index] + color: Qt.rgba(1,1,1,1.0) + anchors.centerIn: parent + Rectangle { + z: -1 + color: Qt.rgba(0.3, 0, 0, 0.3) + anchors { fill: parent; margins: -3 } + } + } + Text { + color: "white" + text: shortText(parent.horizontalAlignment) + anchors { top: parent.top; right: parent.right; margins: 2 } + } + } + } + + Component { + id: plainTextEdit + TextEdit { + width: 180 + text: root.text[index] + font.pixelSize: 24 + cursorVisible: true + wrapMode: TextEdit.WordWrap + horizontalAlignment: root.horizontalAlignment + LayoutMirroring.enabled: root.mirror + Rectangle { + z: -1 + color: Qt.rgba(0.5, 0.5, 0.2, 0.3) + anchors.fill: parent + } + Text { + text: root.description[index] + color: Qt.rgba(1,1,1,1.0) + anchors.centerIn: parent + Rectangle { + z: -1 + color: Qt.rgba(0.3, 0, 0, 0.3) + anchors { fill: parent; margins: -3 } + } + } + Text { + color: "white" + text: shortText(parent.horizontalAlignment) + anchors { top: parent.top; right: parent.right; margins: 2 } + } + } + } + + Component { + id: italicTextEdit + TextEdit { + width: 180 + text: "" + root.text[index] + "" + font.pixelSize: 24 + cursorVisible: true + wrapMode: TextEdit.WordWrap + textFormat: TextEdit.RichText + horizontalAlignment: root.horizontalAlignment + LayoutMirroring.enabled: root.mirror + Rectangle { + z: -1 + color: Qt.rgba(0.5, 0.5, 0.2, 0.3) + anchors.fill: parent + } + Text { + text: root.description[index] + color: Qt.rgba(1,1,1,1.0) + anchors.centerIn: parent + Rectangle { + z: -1 + color: Qt.rgba(0.3, 0, 0, 0.3) + anchors { fill: parent; margins: -3 } + } + } + Text { + color: "white" + text: shortText(parent.horizontalAlignment) + anchors { top: parent.top; right: parent.right; margins: 2 } + } + } + } + + Component { + id: textInput + Item { + width: 180 + height: textInput.text.length > 20 ? 3*textInput.height : textInput.height + TextInput { + id: textInput + width: 180 + text: root.text[index] + font.pixelSize: 24 + cursorVisible: true + horizontalAlignment: root.horizontalAlignment + LayoutMirroring.enabled: root.mirror + Rectangle { + z: -1 + color: Qt.rgba(0.6, 0.4, 0.2, 0.3) + anchors.fill: parent + } + Text { + text: root.description[index] + color: Qt.rgba(1,1,1,1.0) + anchors.centerIn: parent + Rectangle { + z: -1 + color: Qt.rgba(0.3, 0, 0, 0.3) + anchors { fill: parent; margins: -3 } + } + } + Text { + color: "white" + text: shortText(parent.horizontalAlignment) + anchors { top: parent.top; right: parent.right; margins: 2 } + } + } + } + } +} + diff --git a/examples/qml/righttoleft/textalignment/textalignment.qmlproject b/examples/qml/righttoleft/textalignment/textalignment.qmlproject new file mode 100644 index 0000000000..e4b5061364 --- /dev/null +++ b/examples/qml/righttoleft/textalignment/textalignment.qmlproject @@ -0,0 +1,16 @@ +import QmlProject 1.1 + +Project { + mainFile: "textalignment.qml" + + /* Include .qml, .js, and image files from current directory and subdirectories */ + QmlFiles { + directory: "." + } + JavaScriptFiles { + directory: "." + } + ImageFiles { + directory: "." + } +} diff --git a/examples/qml/rssnews/content/BusyIndicator.qml b/examples/qml/rssnews/content/BusyIndicator.qml new file mode 100644 index 0000000000..f1abd1119c --- /dev/null +++ b/examples/qml/rssnews/content/BusyIndicator.qml @@ -0,0 +1,53 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtQml module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Image { + id: container + property bool on: false + + source: "images/busy.png"; visible: container.on + + NumberAnimation on rotation { + running: container.on; from: 0; to: 360; loops: Animation.Infinite; duration: 1200 + } +} diff --git a/examples/qml/rssnews/content/CategoryDelegate.qml b/examples/qml/rssnews/content/CategoryDelegate.qml new file mode 100644 index 0000000000..fe64238adb --- /dev/null +++ b/examples/qml/rssnews/content/CategoryDelegate.qml @@ -0,0 +1,82 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtQml module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Item { + id: delegate + + width: delegate.ListView.view.width; height: 60 + + Text { + text: name + color: delegate.ListView.isCurrentItem ? "white" : "black" + font { family: "Helvetica"; pixelSize: 16; bold: true } + anchors { + left: parent.left; leftMargin: 15 + verticalCenter: parent.verticalCenter + } + } + + BusyIndicator { + scale: 0.6 + on: delegate.ListView.isCurrentItem && window.loading + anchors { right: parent.right; rightMargin: 10; verticalCenter: parent.verticalCenter } + } + + Rectangle { + width: delegate.width; height: 1; color: "#cccccc" + anchors.bottom: delegate.bottom + visible: delegate.ListView.isCurrentItem ? false : true + } + Rectangle { + width: delegate.width; height: 1; color: "white" + visible: delegate.ListView.isCurrentItem ? false : true + } + + MouseArea { + anchors.fill: delegate + onClicked: { + delegate.ListView.view.currentIndex = index + window.currentFeed = feed + } + } +} diff --git a/examples/qml/rssnews/content/NewsDelegate.qml b/examples/qml/rssnews/content/NewsDelegate.qml new file mode 100644 index 0000000000..59ab269d3b --- /dev/null +++ b/examples/qml/rssnews/content/NewsDelegate.qml @@ -0,0 +1,71 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtQml module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Item { + id: delegate + height: column.height + 40 + width: delegate.ListView.view.width + + Column { + id: column + x: 20; y: 20 + width: parent.width - 40 + + Text { + id: titleText + text: title; width: parent.width; wrapMode: Text.WordWrap + font { bold: true; family: "Helvetica"; pointSize: 16 } + } + + Text { + id: descriptionText + width: parent.width; text: description + wrapMode: Text.WordWrap; font.family: "Helvetica" + } + } + + Rectangle { + width: parent.width; height: 1; color: "#cccccc" + anchors.bottom: parent.bottom + } +} diff --git a/examples/qml/rssnews/content/RssFeeds.qml b/examples/qml/rssnews/content/RssFeeds.qml new file mode 100644 index 0000000000..ed58ef3852 --- /dev/null +++ b/examples/qml/rssnews/content/RssFeeds.qml @@ -0,0 +1,59 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtQml module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +ListModel { + id: rssFeeds + + ListElement { name: "Top Stories"; feed: "rss.news.yahoo.com/rss/topstories" } + ListElement { name: "World"; feed: "rss.news.yahoo.com/rss/world" } + ListElement { name: "Europe"; feed: "rss.news.yahoo.com/rss/europe" } + ListElement { name: "Oceania"; feed: "rss.news.yahoo.com/rss/oceania" } + ListElement { name: "U.S. National"; feed: "rss.news.yahoo.com/rss/us" } + ListElement { name: "Politics"; feed: "rss.news.yahoo.com/rss/politics" } + ListElement { name: "Business"; feed: "rss.news.yahoo.com/rss/business" } + ListElement { name: "Technology"; feed: "rss.news.yahoo.com/rss/tech" } + ListElement { name: "Entertainment"; feed: "rss.news.yahoo.com/rss/entertainment" } + ListElement { name: "Health"; feed: "rss.news.yahoo.com/rss/health" } + ListElement { name: "Science"; feed: "rss.news.yahoo.com/rss/science" } + ListElement { name: "Sports"; feed: "rss.news.yahoo.com/rss/sports" } +} diff --git a/examples/qml/rssnews/content/ScrollBar.qml b/examples/qml/rssnews/content/ScrollBar.qml new file mode 100644 index 0000000000..7b1a2ac3e5 --- /dev/null +++ b/examples/qml/rssnews/content/ScrollBar.qml @@ -0,0 +1,107 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtQml module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Item { + id: container + + property variant scrollArea + property variant orientation: Qt.Vertical + + opacity: 0 + + function position() + { + var ny = 0; + if (container.orientation == Qt.Vertical) + ny = scrollArea.visibleArea.yPosition * container.height; + else + ny = scrollArea.visibleArea.xPosition * container.width; + if (ny > 2) return ny; else return 2; + } + + function size() + { + var nh, ny; + + if (container.orientation == Qt.Vertical) + nh = scrollArea.visibleArea.heightRatio * container.height; + else + nh = scrollArea.visibleArea.widthRatio * container.width; + + if (container.orientation == Qt.Vertical) + ny = scrollArea.visibleArea.yPosition * container.height; + else + ny = scrollArea.visibleArea.xPosition * container.width; + + if (ny > 3) { + var t; + if (container.orientation == Qt.Vertical) + t = Math.ceil(container.height - 3 - ny); + else + t = Math.ceil(container.width - 3 - ny); + if (nh > t) return t; else return nh; + } else return nh + ny; + } + + Rectangle { anchors.fill: parent; color: "Black"; opacity: 0.3 } + + BorderImage { + source: "images/scrollbar.png" + border { left: 1; right: 1; top: 1; bottom: 1 } + x: container.orientation == Qt.Vertical ? 2 : position() + width: container.orientation == Qt.Vertical ? container.width - 4 : size() + y: container.orientation == Qt.Vertical ? position() : 2 + height: container.orientation == Qt.Vertical ? size() : container.height - 4 + } + + states: State { + name: "visible" + when: container.orientation == Qt.Vertical ? scrollArea.movingVertically : scrollArea.movingHorizontally + PropertyChanges { target: container; opacity: 1.0 } + } + + transitions: Transition { + from: "visible"; to: "" + NumberAnimation { properties: "opacity"; duration: 600 } + } +} diff --git a/examples/qml/rssnews/content/images/busy.png b/examples/qml/rssnews/content/images/busy.png new file mode 100644 index 0000000000..664c2b1491 Binary files /dev/null and b/examples/qml/rssnews/content/images/busy.png differ diff --git a/examples/qml/rssnews/content/images/scrollbar.png b/examples/qml/rssnews/content/images/scrollbar.png new file mode 100644 index 0000000000..0228dcf9eb Binary files /dev/null and b/examples/qml/rssnews/content/images/scrollbar.png differ diff --git a/examples/qml/rssnews/rssnews.qml b/examples/qml/rssnews/rssnews.qml new file mode 100644 index 0000000000..d26b94b6d3 --- /dev/null +++ b/examples/qml/rssnews/rssnews.qml @@ -0,0 +1,112 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtQml module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import QtQuick.XmlListModel 2.0 +import "content" + +Rectangle { + id: window + width: 800; height: 480 + + property string currentFeed: "rss.news.yahoo.com/rss/topstories" + property bool loading: feedModel.status == XmlListModel.Loading + + RssFeeds { id: rssFeeds } + + XmlListModel { + id: feedModel + source: "http://" + window.currentFeed + query: "/rss/channel/item" + + XmlRole { name: "title"; query: "title/string()" } + XmlRole { name: "link"; query: "link/string()" } + XmlRole { name: "description"; query: "description/string()" } + } + + Row { + Rectangle { + width: 220; height: window.height + color: "#efefef" + + ListView { + focus: true + id: categories + anchors.fill: parent + model: rssFeeds + footer: quitButtonDelegate + delegate: CategoryDelegate {} + highlight: Rectangle { color: "steelblue" } + highlightMoveSpeed: 9999999 + } + ScrollBar { + scrollArea: categories; height: categories.height; width: 8 + anchors.right: categories.right + } + } + ListView { + id: list + width: window.width - 220; height: window.height + model: feedModel + delegate: NewsDelegate {} + } + } + Component { + id: quitButtonDelegate + Item { + width: categories.width; height: 60 + Text { + text: "Quit" + font { family: "Helvetica"; pixelSize: 16; bold: true } + anchors { + left: parent.left; leftMargin: 15 + verticalCenter: parent.verticalCenter + } + } + MouseArea { + anchors.fill: parent + onClicked: Qt.quit() + } + } + } + ScrollBar { scrollArea: list; height: list.height; width: 8; anchors.right: window.right } + Rectangle { x: 220; height: window.height; width: 1; color: "#cccccc" } +} diff --git a/examples/qml/rssnews/rssnews.qmlproject b/examples/qml/rssnews/rssnews.qmlproject new file mode 100644 index 0000000000..5becbdaed0 --- /dev/null +++ b/examples/qml/rssnews/rssnews.qmlproject @@ -0,0 +1,16 @@ +import QmlProject 1.1 + +Project { + mainFile: "rssnews.qml" + + /* Include .qml, .js, and image files from current directory and subdirectories */ + QmlFiles { + directory: "." + } + JavaScriptFiles { + directory: "." + } + ImageFiles { + directory: "." + } +} diff --git a/examples/qml/samegame/content/BoomBlock.qml b/examples/qml/samegame/content/BoomBlock.qml new file mode 100644 index 0000000000..a348368ae1 --- /dev/null +++ b/examples/qml/samegame/content/BoomBlock.qml @@ -0,0 +1,112 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtQml module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import QtQuick.Particles 2.0 + +Item { + id: block + property bool dying: false + property bool spawned: false + property int type: 0 + property ParticleSystem particleSystem + + Behavior on x { + enabled: spawned; + SpringAnimation{ spring: 2; damping: 0.2 } + } + Behavior on y { + SpringAnimation{ spring: 2; damping: 0.2 } + } + + Image { + id: img + source: { + if(type == 0){ + "pics/redStone.png"; + } else if(type == 1) { + "pics/blueStone.png"; + } else { + "pics/greenStone.png"; + } + } + opacity: 0 + Behavior on opacity { NumberAnimation { duration: 200 } } + anchors.fill: parent + } + Emitter { + id: particles + system: particleSystem + group: { + if(type == 0){ + "red"; + } else if (type == 1) { + "blue"; + } else { + "green"; + } + } + anchors.fill: parent + + speed: TargetDirection{targetX: block.width/2; targetY: block.height/2; magnitude: -60; magnitudeVariation: 60} + shape: EllipseShape{fill:true} + enabled: false; + lifeSpan: 700; lifeSpanVariation: 100 + emitRate: 1000 + maximumEmitted: 100 //only fires 0.1s bursts (still 2x old number) + size: 28 + endSize: 14 + } + + states: [ + State { + name: "AliveState"; when: spawned == true && dying == false + PropertyChanges { target: img; opacity: 1 } + }, + + State { + name: "DeathState"; when: dying == true + StateChangeScript { script: {particleSystem.paused = false; particles.pulse(100);} } + PropertyChanges { target: img; opacity: 0 } + StateChangeScript { script: block.destroy(1000); } + } + ] +} diff --git a/examples/qml/samegame/content/Button.qml b/examples/qml/samegame/content/Button.qml new file mode 100644 index 0000000000..2d1a993226 --- /dev/null +++ b/examples/qml/samegame/content/Button.qml @@ -0,0 +1,75 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtQml module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Rectangle { + id: container + + property string text: "Button" + + signal clicked + + width: buttonLabel.width + 20; height: buttonLabel.height + 20 + smooth: true + border { width: 1; color: Qt.darker(activePalette.button) } + radius: 8 + color: activePalette.button + + gradient: Gradient { + GradientStop { + position: 0.0 + color: { + if (mouseArea.pressed) + return activePalette.dark + else + return activePalette.light + } + } + GradientStop { position: 1.0; color: activePalette.button } + } + + MouseArea { id: mouseArea; anchors.fill: parent; onClicked: container.clicked() } + + Text { + id: buttonLabel; text: container.text; anchors.centerIn: container; color: activePalette.buttonText; font.pixelSize: 24 + } +} diff --git a/examples/qml/samegame/content/Dialog.qml b/examples/qml/samegame/content/Dialog.qml new file mode 100644 index 0000000000..c81580e6a5 --- /dev/null +++ b/examples/qml/samegame/content/Dialog.qml @@ -0,0 +1,81 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtQml module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Rectangle { + id: page + anchors.centerIn: parent + + property Item text: dialogText + property bool open: false + + signal closed + signal opened + function forceClose() { + if(!open) + return; //already closed + page.open = false; + page.closed(); + page.opacity = 0; + } + + function show(txt) { + page.open = true; + page.opened(); + dialogText.text = txt; + page.opacity = 1; + } + + width: dialogText.width + 20; height: dialogText.height + 20 + color: "white" + border.width: 1 + opacity: 0 + visible: opacity > 0 + Behavior on opacity { + NumberAnimation { duration: 1000 } + } + + Text { id: dialogText; anchors.centerIn: parent; text: "Hello World!" } + + MouseArea { anchors.fill: parent; onClicked: forceClose(); } +} + diff --git a/examples/qml/samegame/content/GameArea.qml b/examples/qml/samegame/content/GameArea.qml new file mode 100644 index 0000000000..3422582b21 --- /dev/null +++ b/examples/qml/samegame/content/GameArea.qml @@ -0,0 +1,92 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtQml module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import QtQuick.Particles 2.0 +import "samegame.js" as Logic + +Item { + id: gameCanvas + property int score: 0 + property int blockSize: 40 + property ParticleSystem ps: particleSystem + Image { + id: background + anchors.fill: parent + z: -1 + source: "pics/background.png" + fillMode: Image.PreserveAspectCrop + } + + width: 480 + height: 800 + MouseArea { + anchors.fill: parent; onClicked: Logic.handleClick(mouse.x,mouse.y); + } + ParticleSystem{ + id: particleSystem; + onEmptyChanged: if (empty) paused = true; + z:2 + ImageParticle { + groups: ["red"] + color: Qt.darker("red");//Actually want desaturated... + source: "pics/particle.png" + colorVariation: 0.4 + alpha: 0.1 + } + ImageParticle { + groups: ["green"] + color: Qt.darker("green");//Actually want desaturated... + source: "pics/particle.png" + colorVariation: 0.4 + alpha: 0.1 + } + ImageParticle { + groups: ["blue"] + color: Qt.darker("blue");//Actually want desaturated... + source: "pics/particle.png" + colorVariation: 0.4 + alpha: 0.1 + } + anchors.fill: parent + } +} + diff --git a/examples/qml/samegame/content/NameInputDialog.qml b/examples/qml/samegame/content/NameInputDialog.qml new file mode 100644 index 0000000000..7c3bfa274a --- /dev/null +++ b/examples/qml/samegame/content/NameInputDialog.qml @@ -0,0 +1,93 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtQml module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +import QtQuick 2.0 + +Dialog { + id: nameInputDialog + + property int initialWidth: 0 + property alias name: nameInputText.text + + anchors.centerIn: parent + z: 22; + + Behavior on width { + NumberAnimation {} + enabled: nameInputDialog.initialWidth != 0 + } + + signal accepted(string name) + onClosed: { + if (nameInputText.text != "") + accepted(name); + } + Text { + id: dialogText + anchors { left: nameInputDialog.left; leftMargin: 20; verticalCenter: parent.verticalCenter } + text: "You won! Please enter your name: " + } + MouseArea { + anchors.fill: parent + onClicked: { + if (nameInputText.text == "") + nameInputText.openSoftwareInputPanel(); + else + nameInputDialog.forceClose(); + } + } + + TextInput { + id: nameInputText + anchors { verticalCenter: parent.verticalCenter; left: dialogText.right } + focus: visible + autoScroll: false + maximumLength: 24 + onTextChanged: { + var newWidth = nameInputText.width + dialogText.width + 40; + if ( (newWidth > nameInputDialog.width && newWidth < screen.width) + || (nameInputDialog.width > nameInputDialog.initialWidth) ) + nameInputDialog.width = newWidth; + } + onAccepted: { + nameInputDialog.forceClose(); + } + } +} diff --git a/examples/qml/samegame/content/pics/background.png b/examples/qml/samegame/content/pics/background.png new file mode 100644 index 0000000000..3734a27744 Binary files /dev/null and b/examples/qml/samegame/content/pics/background.png differ diff --git a/examples/qml/samegame/content/pics/blueStone.png b/examples/qml/samegame/content/pics/blueStone.png new file mode 100644 index 0000000000..20e43c75b6 Binary files /dev/null and b/examples/qml/samegame/content/pics/blueStone.png differ diff --git a/examples/qml/samegame/content/pics/greenStone.png b/examples/qml/samegame/content/pics/greenStone.png new file mode 100644 index 0000000000..b568a1900c Binary files /dev/null and b/examples/qml/samegame/content/pics/greenStone.png differ diff --git a/examples/qml/samegame/content/pics/particle.png b/examples/qml/samegame/content/pics/particle.png new file mode 100644 index 0000000000..5c83896d22 Binary files /dev/null and b/examples/qml/samegame/content/pics/particle.png differ diff --git a/examples/qml/samegame/content/pics/redStone.png b/examples/qml/samegame/content/pics/redStone.png new file mode 100644 index 0000000000..36b09a2686 Binary files /dev/null and b/examples/qml/samegame/content/pics/redStone.png differ diff --git a/examples/qml/samegame/content/pics/yellowStone.png b/examples/qml/samegame/content/pics/yellowStone.png new file mode 100644 index 0000000000..b1ce76212c Binary files /dev/null and b/examples/qml/samegame/content/pics/yellowStone.png differ diff --git a/examples/qml/samegame/content/samegame.js b/examples/qml/samegame/content/samegame.js new file mode 100755 index 0000000000..611767584b --- /dev/null +++ b/examples/qml/samegame/content/samegame.js @@ -0,0 +1,290 @@ +/* This script file handles the game logic */ +.pragma library +.import QtQuick.LocalStorage 2.0 as Sql + +var maxColumn = 10; +var maxRow = 15; +var maxIndex = maxColumn*maxRow; +var board = new Array(maxIndex); +var blockSrc = "BoomBlock.qml"; +var scoresURL = ""; +var gameDuration; +var component = Qt.createComponent(blockSrc); +var highScoreBar = -1; +var gameCanvas; +var nameInputDialog = null; +var dialog = null; + +// Index function used instead of a 2D array +function index(column, row) +{ + return column + row * maxColumn; +} + +function timeStr(msecs) +{ + var secs = Math.floor(msecs/1000); + var m = Math.floor(secs/60); + var ret = "" + m + "m " + (secs%60) + "s"; + return ret; +} + +function startNewGame(gc) +{ + gameCanvas = gc; + // Delete blocks from previous game + for (var i = 0; i < maxIndex; i++) { + if (board[i] != null) + board[i].destroy(); + } + + // Calculate board size + maxColumn = Math.floor(gameCanvas.width/gameCanvas.blockSize); + maxRow = Math.floor(gameCanvas.height/gameCanvas.blockSize); + maxIndex = maxRow * maxColumn; + + // Close dialogs + if(nameInputDialog != null) + nameInputDialog.forceClose(); + if(dialog != null) + dialog.forceClose(); + + // Initialize Board + board = new Array(maxIndex); + gameCanvas.score = 0; + for (var column = 0; column < maxColumn; column++) { + for (var row = 0; row < maxRow; row++) { + board[index(column, row)] = null; + createBlock(column, row); + } + } + gameDuration = new Date(); +} + +var fillFound; // Set after a floodFill call to the number of blocks found +var floodBoard; // Set to 1 if the floodFill reaches off that node + +// NOTE: Be careful with vars named x,y, as the calling object's x,y are still in scope +function handleClick(x,y) +{ + if(gameCanvas == undefined){ + console.log("But the game hasn't started yet!"); + return; + } + var column = Math.floor(x/gameCanvas.blockSize); + var row = Math.floor(y/gameCanvas.blockSize); + if (column >= maxColumn || column < 0 || row >= maxRow || row < 0) + return; + if (board[index(column, row)] == null) + return; + // If it's a valid block, remove it and all connected (does nothing if it's not connected) + floodFill(column,row, -1); + if (fillFound <= 0) + return; + gameCanvas.score += (fillFound - 1) * (fillFound - 1); + shuffleDown(); + victoryCheck(); +} + +function floodFill(column,row,type) +{ + if (board[index(column, row)] == null) + return; + var first = false; + if (type == -1) { + first = true; + type = board[index(column,row)].type; + + // Flood fill initialization + fillFound = 0; + floodBoard = new Array(maxIndex); + } + if (column >= maxColumn || column < 0 || row >= maxRow || row < 0) + return; + if (floodBoard[index(column, row)] == 1 || (!first && type != board[index(column, row)].type)) + return; + floodBoard[index(column, row)] = 1; + floodFill(column + 1, row, type); + floodFill(column - 1, row, type); + floodFill(column, row + 1, type); + floodFill(column, row - 1, type); + if (first == true && fillFound == 0) + return; // Can't remove single blocks + board[index(column, row)].dying = true; + board[index(column, row)] = null; + fillFound += 1; +} + +function shuffleDown() +{ + // Fall down + for (var column = 0; column < maxColumn; column++) { + var fallDist = 0; + for (var row = maxRow - 1; row >= 0; row--) { + if (board[index(column,row)] == null) { + fallDist += 1; + } else { + if (fallDist > 0) { + var obj = board[index(column, row)]; + obj.y = (row + fallDist) * gameCanvas.blockSize; + board[index(column, row + fallDist)] = obj; + board[index(column, row)] = null; + } + } + } + } + // Fall to the left + fallDist = 0; + for (column = 0; column < maxColumn; column++) { + if (board[index(column, maxRow - 1)] == null) { + fallDist += 1; + } else { + if (fallDist > 0) { + for (row = 0; row < maxRow; row++) { + obj = board[index(column, row)]; + if (obj == null) + continue; + obj.x = (column - fallDist) * gameCanvas.blockSize; + board[index(column - fallDist,row)] = obj; + board[index(column, row)] = null; + } + } + } + } +} + +function victoryCheck() +{ + // Awards bonuses for no blocks left + var deservesBonus = true; + for (var column = maxColumn - 1; column >= 0; column--) + if (board[index(column, maxRow - 1)] != null) + deservesBonus = false; + if (deservesBonus) + gameCanvas.score += 500; + // Checks for game over + if (deservesBonus || !(floodMoveCheck(0, maxRow - 1, -1))) { + gameDuration = new Date() - gameDuration; + if(nameInputDialog == null){ + nameInputDialog = Qt.createQmlObject('import "."; import "samegame.js" as Logic; NameInputDialog{onAccepted: Logic.saveHighScore(name)}', gameCanvas, "highscoredialog.qml"); + } + if(dialog == null){ + dialog = Qt.createComponent("Dialog.qml").createObject(gameCanvas); + } + initHighScoreBar(); + if(gameCanvas.score > highScoreBar){ + nameInputDialog.show("You won! Please enter your name: "); + nameInputDialog.initialWidth = nameInputDialog.text.width + 20; + if (nameInputDialog.name == "") + nameInputDialog.width = nameInputDialog.initialWidth; + nameInputDialog.text.opacity = 0; // Just a spacer + }else{ + dialog.show("You won!"); + } + } +} + +// Only floods up and right, to see if it can find adjacent same-typed blocks +function floodMoveCheck(column, row, type) +{ + if (column >= maxColumn || column < 0 || row >= maxRow || row < 0) + return false; + if (board[index(column, row)] == null) + return false; + var myType = board[index(column, row)].type; + if (type == myType) + return true; + return floodMoveCheck(column + 1, row, myType) || + floodMoveCheck(column, row - 1, board[index(column, row)].type); +} + +function createBlock(column,row) +{ + // Note that we don't wait for the component to become ready. This will + // only work if the block QML is a local file. Otherwise the component will + // not be ready immediately. There is a statusChanged signal on the + // component you could use if you want to wait to load remote files. + if(component.status == 1){ + var dynamicObject = component.createObject(gameCanvas, + {"type": Math.floor(Math.random() * 3), + "x": column*gameCanvas.blockSize, + "width": gameCanvas.blockSize, + "height": gameCanvas.blockSize, + "particleSystem": gameCanvas.ps}); + if(dynamicObject == null){ + console.log("error creating block"); + console.log(component.errorString()); + return false; + } + dynamicObject.y = row*gameCanvas.blockSize; + dynamicObject.spawned = true; + + board[index(column,row)] = dynamicObject; + }else{ + console.log("error loading block component"); + console.log(component.errorString()); + return false; + } + return true; +} + +function initHighScoreBar() +{ + var db = Sql.openDatabaseSync( + "SameGameScores", + "1.0", + "Local SameGame High Scores", + 100 + ); + db.transaction( + function(tx) { + tx.executeSql('CREATE TABLE IF NOT EXISTS Scores(name TEXT, score NUMBER, gridSize TEXT, time NUMBER)'); + // Only show results for the current grid size + var rs = tx.executeSql('SELECT * FROM Scores WHERE gridSize = "' + + maxColumn + "x" + maxRow + '" ORDER BY score desc LIMIT 10'); + if(rs.rows.length < 10) + highScoreBar = 0; + else + highScoreBar = rs.rows.item(rs.rows.length - 1).score; + } + ); +} + +function saveHighScore(name) +{ + if (scoresURL != "") + sendHighScore(name); + // Offline storage + var db = Sql.openDatabaseSync( + "SameGameScores", + "1.0", + "Local SameGame High Scores", + 100 + ); + var dataStr = "INSERT INTO Scores VALUES(?, ?, ?, ?)"; + var data = [ + name, + gameCanvas.score, + maxColumn + "x" + maxRow, + Math.floor(gameDuration / 1000) + ]; + db.transaction( + function(tx) { + tx.executeSql('CREATE TABLE IF NOT EXISTS Scores(name TEXT, score NUMBER, gridSize TEXT, time NUMBER)'); + tx.executeSql(dataStr, data); + + // Only show results for the current grid size + var rs = tx.executeSql('SELECT * FROM Scores WHERE gridSize = "' + + maxColumn + "x" + maxRow + '" ORDER BY score desc LIMIT 10'); + var r = "\nHIGH SCORES for this grid size\n\n" + for (var i = 0; i < rs.rows.length; i++) { + r += (i+1) + ". " + rs.rows.item(i).name + ' got ' + + rs.rows.item(i).score + ' points in ' + + rs.rows.item(i).time + ' seconds.\n'; + } + if(rs.rows.length == 10) + highScoreBar = rs.rows.item(9).score; + dialog.show(r); + } + ); +} diff --git a/examples/qml/samegame/samegame.qml b/examples/qml/samegame/samegame.qml new file mode 100644 index 0000000000..b98b6a0074 --- /dev/null +++ b/examples/qml/samegame/samegame.qml @@ -0,0 +1,87 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtQml module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import QtQuick.Particles 2.0 +import "content" +import "content/samegame.js" as Logic + +Rectangle { + id: screen + width: 480; height: 640 + + SystemPalette { id: activePalette } + + GameArea { + id: gameCanvas + width: parent.width + anchors { top: parent.top; bottom: toolBar.top } + } + + Rectangle { + id: toolBar + width: parent.width; height: 80 + color: activePalette.window + anchors.bottom: screen.bottom + + Button { + id: newGameButton + anchors { left: parent.left; leftMargin: 12; verticalCenter: parent.verticalCenter } + text: "New Game" + onClicked: Logic.startNewGame(gameCanvas) + } + + Button { + text: "Quit" + anchors { left: newGameButton.right; leftMargin: 12; verticalCenter: parent.verticalCenter } + onClicked: Qt.quit(); + } + + Text { + id: score + anchors { right: parent.right; rightMargin: 12; verticalCenter: parent.verticalCenter } + text: "Score: " + gameCanvas.score + font.bold: true + font.pixelSize: 24 + color: activePalette.windowText + } + } +} diff --git a/examples/qml/samegame/samegame.qmlproject b/examples/qml/samegame/samegame.qmlproject new file mode 100644 index 0000000000..42ffacf4f8 --- /dev/null +++ b/examples/qml/samegame/samegame.qmlproject @@ -0,0 +1,16 @@ +import QmlProject 1.1 + +Project { + mainFile: "samegame.qml" + + /* Include .qml, .js, and image files from current directory and subdirectories */ + QmlFiles { + directory: "." + } + JavaScriptFiles { + directory: "." + } + ImageFiles { + directory: "." + } +} diff --git a/examples/qml/script/script.pro b/examples/qml/script/script.pro new file mode 100644 index 0000000000..98c1bbc5ee --- /dev/null +++ b/examples/qml/script/script.pro @@ -0,0 +1,4 @@ +TEMPLATE = subdirs + +SUBDIRS = \ + shell diff --git a/examples/qml/script/shell/main.cpp b/examples/qml/script/shell/main.cpp new file mode 100644 index 0000000000..a4059122bf --- /dev/null +++ b/examples/qml/script/shell/main.cpp @@ -0,0 +1,153 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + + +#include +#include +#include +#include + +#include + +#include + +#include + + +class CommandInterface : public QObject +{ + Q_OBJECT +public: + Q_INVOKABLE void quit() { m_wantsToQuit = true; } + static bool wantsToQuit() { return m_wantsToQuit; } +private: + static bool m_wantsToQuit; +}; + +bool CommandInterface::m_wantsToQuit = false; + + +static void interactive(QJSEngine *eng) +{ + QTextStream qin(stdin, QFile::ReadOnly); + const char *prompt = "qs> "; + + forever { + QString line; + + printf("%s", prompt); + fflush(stdout); + + line = qin.readLine(); + if (line.isNull()) + break; + + if (line.trimmed().isEmpty()) + continue; + + line += QLatin1Char('\n'); + + QJSValue result = eng->evaluate(line, QLatin1String("typein")); + + fprintf(stderr, "%s\n", qPrintable(result.toString())); + + if (CommandInterface::wantsToQuit()) + break; + } +} + +int main(int argc, char *argv[]) +{ + QGuiApplication app(argc, argv); + QScopedPointer eng(new QJSEngine()); + { + QJSValue globalObject = eng->globalObject(); + QJSValue interface = eng->newQObject(new CommandInterface); + globalObject.setProperty("qt", interface); + } + + if (! *++argv) { + interactive(eng.data()); + return EXIT_SUCCESS; + } + + while (const char *arg = *argv++) { + QString fileName = QString::fromLocal8Bit(arg); + + if (fileName == QLatin1String("-i")) { + interactive(eng.data()); + break; + } + + QString contents; + int lineNumber = 1; + + if (fileName == QLatin1String("-")) { + QTextStream stream(stdin, QFile::ReadOnly); + contents = stream.readAll(); + } else { + QFile file(fileName); + if (file.open(QFile::ReadOnly)) { + QTextStream stream(&file); + contents = stream.readAll(); + file.close(); + + // strip off #!/usr/bin/env qjs line + if (contents.startsWith("#!")) { + contents.remove(0, contents.indexOf("\n")); + ++lineNumber; + } + } + } + + if (contents.isEmpty()) + continue; + + QJSValue result = eng->evaluate(contents, fileName, lineNumber); + if (eng->hasUncaughtException()) { + fprintf (stderr, " %s\n\n", qPrintable(result.toString())); + return EXIT_FAILURE; + } + } + + return EXIT_SUCCESS; +} + +#include diff --git a/examples/qml/script/shell/shell.pro b/examples/qml/script/shell/shell.pro new file mode 100644 index 0000000000..5f6b23862b --- /dev/null +++ b/examples/qml/script/shell/shell.pro @@ -0,0 +1,7 @@ +QT += qml + +win32: CONFIG += console +mac:CONFIG -= app_bundle + +SOURCES += main.cpp + diff --git a/examples/qml/shadereffects/content/Slider.qml b/examples/qml/shadereffects/content/Slider.qml new file mode 100644 index 0000000000..4ddc6d3432 --- /dev/null +++ b/examples/qml/shadereffects/content/Slider.qml @@ -0,0 +1,93 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the Declarative module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Item { + property real value: bar.x / (foo.width - bar.width) + Item { + id: foo + width: parent.width - 4 + height: 6 + anchors.centerIn: parent + + Rectangle { + height: parent.height + anchors.left: parent.left + anchors.right: bar.horizontalCenter + color: "blue" + radius: 3 + } + Rectangle { + height: parent.height + anchors.left: bar.horizontalCenter + anchors.right: parent.right + color: "gray" + radius: 3 + } + Rectangle { + anchors.fill: parent + color: "transparent" + radius: 3 + border.width: 2 + border.color: "black" + } + + Rectangle { + id: bar + y: -7 + width: 20 + height: 20 + radius: 15 + color: "white" + border.width: 2 + border.color: "black" + MouseArea { + anchors.fill: parent + drag.target: parent + drag.axis: Drag.XAxis + drag.minimumX: 0 + drag.maximumX: foo.width - parent.width + } + } + } +} + diff --git a/examples/qml/shadereffects/content/face-smile.png b/examples/qml/shadereffects/content/face-smile.png new file mode 100644 index 0000000000..3d66d72578 Binary files /dev/null and b/examples/qml/shadereffects/content/face-smile.png differ diff --git a/examples/qml/shadereffects/content/qt-logo.png b/examples/qml/shadereffects/content/qt-logo.png new file mode 100644 index 0000000000..7d3e97eb36 Binary files /dev/null and b/examples/qml/shadereffects/content/qt-logo.png differ diff --git a/examples/qml/shadereffects/shadereffects.qml b/examples/qml/shadereffects/shadereffects.qml new file mode 100644 index 0000000000..842e42b89f --- /dev/null +++ b/examples/qml/shadereffects/shadereffects.qml @@ -0,0 +1,300 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the Declarative module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import "content" + +Image { + width: 640 + height: 360 + source: "../snake/content/pics/background.png" + + ShaderEffectSource { + id: theSource + sourceItem: theItem + smooth: true + } + + function saturate(x) { + return Math.min(Math.max(x, 0), 1) + } + + function sliderToColor(x) { + return Qt.rgba(saturate(Math.max(2 - 6 * x, 6 * x - 4)), + saturate(Math.min(6 * x, 4 - 6 * x)), + saturate(Math.min(6 * x - 2, 6 - 6 * x))) + } + + Grid { + anchors.centerIn: parent + columns: 3 + + Item { + id: theItem + width: 180 + height: 180 + ListView { + anchors.centerIn: parent + width: 160 + height: 140 + clip: true + snapMode: ListView.SnapOneItem + model: VisualItemModel { + Text { + width: 160 + height: 140 + horizontalAlignment: Text.AlignHCenter + verticalAlignment: Text.AlignVCenter + font.pixelSize: 120 + font.family: "Times" + color: "blue" + text: "Qt" + } + Image { + width: 160 + height: 140 + source: "content/qt-logo.png" + smooth: true + } + Image { + width: 160 + height: 140 + source: "content/face-smile.png" + smooth: true + } + } + } + } + ShaderEffect { + width: 180 + height: 180 + property variant source: theSource + property real amplitude: 0.04 * wobbleSlider.value + property real frequency: 20 + property real time: 0 + NumberAnimation on time { loops: Animation.Infinite; from: 0; to: Math.PI * 2; duration: 600 } + fragmentShader: + "uniform lowp float qt_Opacity;" + + "uniform highp float amplitude;" + + "uniform highp float frequency;" + + "uniform highp float time;" + + "uniform sampler2D source;" + + "varying highp vec2 qt_TexCoord0;" + + "void main() {" + + " highp vec2 p = sin(time + frequency * qt_TexCoord0);" + + " gl_FragColor = texture2D(source, qt_TexCoord0 + amplitude * vec2(p.y, -p.x)) * qt_Opacity;" + + "}" + Slider { + id: wobbleSlider + anchors.left: parent.left + anchors.right: parent.right + anchors.bottom: parent.bottom + height: 40 + } + } + ShaderEffect { + width: 180 + height: 180 + property variant source: theSource + property variant shadow: ShaderEffectSource { + smooth: true + sourceItem: ShaderEffect { + width: theItem.width + height: theItem.height + property variant delta: Qt.size(0.0, 1.0 / height) + property variant source: ShaderEffectSource { + smooth: true + sourceItem: ShaderEffect { + width: theItem.width + height: theItem.height + property variant delta: Qt.size(1.0 / width, 0.0) + property variant source: theSource + fragmentShader: " + uniform lowp float qt_Opacity; + uniform sampler2D source; + uniform highp vec2 delta; + varying highp vec2 qt_TexCoord0; + void main() { + gl_FragColor =(0.0538 * texture2D(source, qt_TexCoord0 - 3.182 * delta) + + 0.3229 * texture2D(source, qt_TexCoord0 - 1.364 * delta) + + 0.2466 * texture2D(source, qt_TexCoord0) + + 0.3229 * texture2D(source, qt_TexCoord0 + 1.364 * delta) + + 0.0538 * texture2D(source, qt_TexCoord0 + 3.182 * delta)) * qt_Opacity; + }" + } + } + fragmentShader: " + uniform lowp float qt_Opacity; + uniform sampler2D source; + uniform highp vec2 delta; + varying highp vec2 qt_TexCoord0; + void main() { + gl_FragColor =(0.0538 * texture2D(source, qt_TexCoord0 - 3.182 * delta) + + 0.3229 * texture2D(source, qt_TexCoord0 - 1.364 * delta) + + 0.2466 * texture2D(source, qt_TexCoord0) + + 0.3229 * texture2D(source, qt_TexCoord0 + 1.364 * delta) + + 0.0538 * texture2D(source, qt_TexCoord0 + 3.182 * delta)) * qt_Opacity; + }" + } + } + property real angle: 0 + property variant offset: Qt.point(15.0 * Math.cos(angle), 15.0 * Math.sin(angle)) + NumberAnimation on angle { loops: Animation.Infinite; from: 0; to: Math.PI * 2; duration: 6000 } + property variant delta: Qt.size(offset.x / width, offset.y / height) + property real darkness: shadowSlider.value + fragmentShader: " + uniform lowp float qt_Opacity; + uniform highp vec2 offset; + uniform sampler2D source; + uniform sampler2D shadow; + uniform highp float darkness; + uniform highp vec2 delta; + varying highp vec2 qt_TexCoord0; + void main() { + lowp vec4 fg = texture2D(source, qt_TexCoord0); + lowp vec4 bg = texture2D(shadow, qt_TexCoord0 + delta); + gl_FragColor = (fg + vec4(0., 0., 0., darkness * bg.a) * (1. - fg.a)) * qt_Opacity; + }" + Slider { + id: shadowSlider + anchors.left: parent.left + anchors.right: parent.right + anchors.bottom: parent.bottom + height: 40 + } + } + ShaderEffect { + width: 180 + height: 180 + property variant source: theSource + property variant delta: Qt.size(0.5 / width, 0.5 / height) + fragmentShader: " + uniform sampler2D source; + uniform highp vec2 delta; + uniform highp float qt_Opacity; + varying highp vec2 qt_TexCoord0; + void main() { + lowp vec4 tl = texture2D(source, qt_TexCoord0 - delta); + lowp vec4 tr = texture2D(source, qt_TexCoord0 + vec2(delta.x, -delta.y)); + lowp vec4 bl = texture2D(source, qt_TexCoord0 - vec2(delta.x, -delta.y)); + lowp vec4 br = texture2D(source, qt_TexCoord0 + delta); + lowp vec4 gx = (tl + bl) - (tr + br); + lowp vec4 gy = (tl + tr) - (bl + br); + gl_FragColor.xyz = vec3(0.); + gl_FragColor.w = clamp(dot(sqrt(gx * gx + gy * gy), vec4(1.)), 0., 1.) * qt_Opacity; + }" + } + ShaderEffect { + width: 180 + height: 180 + property variant source: theSource + property color tint: sliderToColor(colorizeSlider.value) + fragmentShader: " + uniform sampler2D source; + uniform lowp vec4 tint; + uniform lowp float qt_Opacity; + varying highp vec2 qt_TexCoord0; + void main() { + lowp vec4 c = texture2D(source, qt_TexCoord0); + lowp float lo = min(min(c.x, c.y), c.z); + lowp float hi = max(max(c.x, c.y), c.z); + gl_FragColor = qt_Opacity * vec4(mix(vec3(lo), vec3(hi), tint.xyz), c.w); + }" + Slider { + id: colorizeSlider + anchors.left: parent.left + anchors.right: parent.right + anchors.bottom: parent.bottom + height: 40 + } + } + ShaderEffect { + width: 180 + height: 180 + mesh: Qt.size(10, 10) + property variant source: theSource + property real bend: 0 + property real minimize: 0 + property real side: genieSlider.value + SequentialAnimation on bend { + loops: Animation.Infinite + NumberAnimation { to: 1; duration: 700; easing.type: Easing.InOutSine } + PauseAnimation { duration: 1600 } + NumberAnimation { to: 0; duration: 700; easing.type: Easing.InOutSine } + PauseAnimation { duration: 1000 } + } + SequentialAnimation on minimize { + loops: Animation.Infinite + PauseAnimation { duration: 300 } + NumberAnimation { to: 1; duration: 700; easing.type: Easing.InOutSine } + PauseAnimation { duration: 1000 } + NumberAnimation { to: 0; duration: 700; easing.type: Easing.InOutSine } + PauseAnimation { duration: 1300 } + } + vertexShader: " + uniform highp mat4 qt_Matrix; + uniform highp float bend; + uniform highp float minimize; + uniform highp float side; + uniform highp float width; + uniform highp float height; + attribute highp vec4 qt_Vertex; + attribute highp vec2 qt_MultiTexCoord0; + varying highp vec2 qt_TexCoord0; + void main() { + qt_TexCoord0 = qt_MultiTexCoord0; + highp vec4 pos = qt_Vertex; + pos.y = mix(qt_Vertex.y, height, minimize); + highp float t = pos.y / height; + t = (3. - 2. * t) * t * t; + pos.x = mix(qt_Vertex.x, side * width, t * bend); + gl_Position = qt_Matrix * pos; + }" + Slider { + id: genieSlider + anchors.left: parent.left + anchors.right: parent.right + anchors.bottom: parent.bottom + height: 40 + } + } + } +} diff --git a/examples/qml/shared/Button.qml b/examples/qml/shared/Button.qml new file mode 100644 index 0000000000..a899a1410b --- /dev/null +++ b/examples/qml/shared/Button.qml @@ -0,0 +1,64 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Item { + id: container + + property string text: "Button" + property string subText: "Just a button" + signal clicked + + width: buttonLabel.width + 20; height: col.height + 12 + + MouseArea { id: mouseArea; anchors.fill: parent; onClicked: container.clicked() } + + Column { + spacing: 2 + id: col + Text { + id: buttonLabel; text: container.text; color: "black"; font.pixelSize: 24 + } + Text { + id: buttonLabel2; text: container.subText; color: "black"; font.pixelSize: 12 + } + } +} diff --git a/examples/qml/shared/LauncherList.qml b/examples/qml/shared/LauncherList.qml new file mode 100644 index 0000000000..782fcc7ddd --- /dev/null +++ b/examples/qml/shared/LauncherList.qml @@ -0,0 +1,101 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +import QtQuick 2.0 + +ListView { + //model is a list of {"name":"somename", "url":"file:///some/url/mainfile.qml"} + //function used to add to model A) to enforce scheme B) to allow Qt.resolveUrl in url assignments + function addExample(name, desc, url) + { + myModel.append({"name":name, "description":desc, "url":url}) + } + function hideExample() + { + ei.visible = false; + } + + clip: true + delegate: SimpleLauncherDelegate{exampleItem: ei} + model: ListModel {id:myModel} + Item { + id: ei + visible: false + clip: true + property url exampleUrl + onExampleUrlChanged: visible = (exampleUrl == '' ? false : true);//Setting exampleUrl automatically shows example + anchors.fill: parent + anchors.bottomMargin: 40 + Rectangle { + id: bg + anchors.fill: parent + color: "white" + } + MouseArea{ + anchors.fill: parent + enabled: ei.visible + //Eats mouse events + } + Loader{ + source: ei.exampleUrl + anchors.fill: parent + } + } + Rectangle { + id: bar + visible: ei.visible + anchors.bottom: parent.bottom + width: parent.width + height: 40 + MouseArea{ + anchors.fill: parent + enabled: ei.visible + //Eats mouse events + } + Image { + source: "back.png" + anchors.verticalCenter: parent.verticalCenter + x: 4 + MouseArea { + anchors.fill: parent + onClicked: ei.exampleUrl = ""; + } + } + } +} diff --git a/examples/qml/shared/README b/examples/qml/shared/README new file mode 100644 index 0000000000..bf16f238c7 --- /dev/null +++ b/examples/qml/shared/README @@ -0,0 +1,11 @@ +These files are shared between multiple examples as a set of common and +reusuable components. While they do demonstrate the building of reusable +components in QML, they are not official examples themselves. +Consequently they do not have entries in the Qt documentation, and are +documented only through the code comments within the files. Developers +new to QML are strongly encouraged to go through the official examples +before delving into this directory. + +For most application use, see the Qt Quick Components project to find +ready-made Components you can use in your own projects. Qt Declarative +examples do not use them only to avoid external dependencies. diff --git a/examples/qml/shared/SimpleLauncherDelegate.qml b/examples/qml/shared/SimpleLauncherDelegate.qml new file mode 100644 index 0000000000..c3708fe259 --- /dev/null +++ b/examples/qml/shared/SimpleLauncherDelegate.qml @@ -0,0 +1,53 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +import QtQuick 2.0 + +Item { + id: container + property Item exampleItem + width: ListView.view.width + height: 64 + Button { + anchors.fill: parent + text: name + subText: description + onClicked: exampleItem.exampleUrl = url; + } +} diff --git a/examples/qml/shared/back.png b/examples/qml/shared/back.png new file mode 100644 index 0000000000..506ac42fcf Binary files /dev/null and b/examples/qml/shared/back.png differ diff --git a/examples/qml/snake/content/Button.qml b/examples/qml/snake/content/Button.qml new file mode 100644 index 0000000000..4f294556b3 --- /dev/null +++ b/examples/qml/snake/content/Button.qml @@ -0,0 +1,66 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtQml module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Rectangle { + id: container + + signal clicked + property string text: "Button" + + color: activePalette.button; smooth: true + width: txtItem.width + 20; height: txtItem.height + 6 + border.width: 1; border.color: Qt.darker(activePalette.button); radius: 8; + + gradient: Gradient { + GradientStop { + id: topGrad; position: 0.0 + color: if (mr.pressed) { activePalette.dark } else { activePalette.light } } + GradientStop { position: 1.0; color: activePalette.button } + } + + MouseArea { id: mr; anchors.fill: parent; onClicked: container.clicked() } + + Text { + id: txtItem; text: container.text; anchors.centerIn: container; color: activePalette.buttonText + } +} diff --git a/examples/qml/snake/content/Cookie.qml b/examples/qml/snake/content/Cookie.qml new file mode 100644 index 0000000000..35ffe400b8 --- /dev/null +++ b/examples/qml/snake/content/Cookie.qml @@ -0,0 +1,102 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtQml module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import QtQuick.Particles 2.0 + +Item { + id: root + property bool dying: false + property int row; + property int column; + x: margin + column * gridSize + y: margin + row * gridSize + + width: gridSize + height: gridSize + property int value : 1; + + Image { + id: img + anchors.fill: parent + source: "pics/cookie.png" + opacity: 0 + Text { + font.bold: true + anchors.verticalCenter: parent.verticalCenter + anchors.horizontalCenter: parent.horizontalCenter + text: value + } + } + + + ParticleSystem { + width:1; height:1; anchors.centerIn: parent; + ImageParticle { + groups: ["star"] + source: "pics/yellowStar.png" + } + Emitter { + id: particles + anchors.fill: parent + group: "star" + emitRate: 50 + enabled: false + lifeSpan: 700 + acceleration: AngleDirection { angleVariation: 360; magnitude: 200 } + } + } + + states: [ + State{ name: "AliveState"; when: dying == false + PropertyChanges { target: img; opacity: 1 } + }, + State{ name: "DeathState"; when: dying == true + StateChangeScript { script: particles.burst(50); } + PropertyChanges { target: img; opacity: 0 } + } + ] + transitions: [ + Transition { + NumberAnimation { target: img; property: "opacity"; duration: 100 } + } + ] +} diff --git a/examples/qml/snake/content/HighScoreModel.qml b/examples/qml/snake/content/HighScoreModel.qml new file mode 100644 index 0000000000..734a661f5b --- /dev/null +++ b/examples/qml/snake/content/HighScoreModel.qml @@ -0,0 +1,140 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtQml module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import QtQuick.LocalStorage 2.0 as Sql + +// Models a high score table. +// +// Use this component like this: +// +// HighScoreModel { +// id: highScores +// game: "MyCoolGame" +// } +// +// Then use either use the top-score properties: +// +// Text { text: "HI: " + highScores.topScore } +// +// or, use the model in a view: +// +// ListView { +// model: highScore +// delegate: Component { +// ... player ... score ... +// } +// } +// +// Add new scores via: +// +// saveScore(newScore) +// +// or: +// +// savePlayerScore(playerName,newScore) +// +// The best maxScore scores added by this method will be retained in an SQL database, +// and presented in the model and in the topScore/topPlayer properties. +// + +ListModel { + id: model + property string game: "" + property int topScore: 0 + property string topPlayer: "" + property int maxScores: 10 + + function __db() + { + return Sql.openDatabaseSync("HighScoreModel", "1.0", "Generic High Score Functionality for QML", 1000000); + } + function __ensureTables(tx) + { + tx.executeSql('CREATE TABLE IF NOT EXISTS HighScores(game TEXT, score INT, player TEXT)', []); + } + + function fillModel() { + __db().transaction( + function(tx) { + __ensureTables(tx); + var rs = tx.executeSql("SELECT score,player FROM HighScores WHERE game=? ORDER BY score DESC", [game]); + model.clear(); + if (rs.rows.length > 0) { + topScore = rs.rows.item(0).score + topPlayer = rs.rows.item(0).player + for (var i=0; i maxScores) + tx.executeSql("DELETE FROM HighScores WHERE game=? AND score <= ?", + [game, rs.rows.item(maxScores).score]); + } + } + ) + } + + function savePlayerScore(player,score) { + __db().transaction( + function(tx) { + __ensureTables(tx); + tx.executeSql("INSERT INTO HighScores VALUES(?,?,?)", [game,score,player]); + fillModel(); + } + ) + } + + function saveScore(score) { + savePlayerScore("player",score); + } + + function clearScores() { + __db().transaction( + function(tx) { + tx.executeSql("DELETE FROM HighScores WHERE game=?", [game]); + fillModel(); + } + ) + } + + Component.onCompleted: { fillModel() } +} diff --git a/examples/qml/snake/content/Link.qml b/examples/qml/snake/content/Link.qml new file mode 100644 index 0000000000..aab005afd5 --- /dev/null +++ b/examples/qml/snake/content/Link.qml @@ -0,0 +1,129 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtQml module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import QtQuick.Particles 2.0 + +Item { id:link + property bool dying: false + property bool spawned: false + property int type: 0 + property int row: 0 + property int column: 0 + property int rotation; + + width: 40; + height: 40 + + x: margin - 3 + gridSize * column + y: margin - 3 + gridSize * row + Behavior on x { NumberAnimation { duration: spawned ? heartbeatInterval : 0} } + Behavior on y { NumberAnimation { duration: spawned ? heartbeatInterval : 0 } } + + + Item { + id: img + anchors.fill: parent + Image { + source: { + if(type == 1) { + "pics/blueStone.png"; + } else if (type == 2) { + "pics/head.png"; + } else { + "pics/redStone.png"; + } + } + + transform: Rotation { + id: actualImageRotation + origin.x: width/2; origin.y: height/2; + angle: rotation * 90 + Behavior on angle { + RotationAnimation{ + direction: RotationAnimation.Shortest + duration: spawned ? 200 : 0 + } + } + } + } + + Image { + source: "pics/stoneShadow.png" + } + + opacity: 0 + } + + ParticleSystem { + width:1; height:1; anchors.centerIn: parent; + ImageParticle { + groups: ["star"] + source: type == 1 ? "pics/blueStar.png" : "pics/redStar.png" + } + Emitter { + id: particles + anchors.fill: parent + group: "star" + emitRate: 50 + enabled: false + lifeSpan: 700 + acceleration: AngleDirection { angleVariation: 360; magnitude: 200 } + } + } + + states: [ + State{ name: "AliveState"; when: spawned == true && dying == false + PropertyChanges { target: img; opacity: 1 } + }, + State{ name: "DeathState"; when: dying == true + StateChangeScript { script: particles.burst(50); } + PropertyChanges { target: img; opacity: 0 } + } + ] + + transitions: [ + Transition { + NumberAnimation { target: img; property: "opacity"; duration: 200 } + } + ] + +} diff --git a/examples/qml/snake/content/Skull.qml b/examples/qml/snake/content/Skull.qml new file mode 100644 index 0000000000..e3f77fdac6 --- /dev/null +++ b/examples/qml/snake/content/Skull.qml @@ -0,0 +1,62 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtQml module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Image { + property bool spawned: false + property int row; + property int column; + property int verticalMovement; + property int horizontalMovement; + + x: margin + column * gridSize + 2 + y: margin + row * gridSize - 3 + Behavior on x { NumberAnimation { duration: spawned ? halfbeatInterval : 0} } + Behavior on y { NumberAnimation { duration: spawned ? halfbeatInterval : 0 } } + + opacity: spawned ? 1 : 0 + Behavior on opacity { NumberAnimation { duration: 200 } } + + source: "pics/skull.png" + width: 24 + height: 40 +} diff --git a/examples/qml/snake/content/pics/README b/examples/qml/snake/content/pics/README new file mode 100644 index 0000000000..0215132caa --- /dev/null +++ b/examples/qml/snake/content/pics/README @@ -0,0 +1 @@ +snake.jpg: This image is based on the picture "Eastern Green Mamba.jpg" from the free media databse Wikimedia Commons and is published under the terms of the GNU Free Documentation License. The original picture was taken by Danleo. diff --git a/examples/qml/snake/content/pics/background.png b/examples/qml/snake/content/pics/background.png new file mode 100644 index 0000000000..72dffaa843 Binary files /dev/null and b/examples/qml/snake/content/pics/background.png differ diff --git a/examples/qml/snake/content/pics/blueStar.png b/examples/qml/snake/content/pics/blueStar.png new file mode 100644 index 0000000000..ba7acabd26 Binary files /dev/null and b/examples/qml/snake/content/pics/blueStar.png differ diff --git a/examples/qml/snake/content/pics/blueStone.png b/examples/qml/snake/content/pics/blueStone.png new file mode 100644 index 0000000000..356affdd95 Binary files /dev/null and b/examples/qml/snake/content/pics/blueStone.png differ diff --git a/examples/qml/snake/content/pics/cookie.png b/examples/qml/snake/content/pics/cookie.png new file mode 100644 index 0000000000..aec2957f34 Binary files /dev/null and b/examples/qml/snake/content/pics/cookie.png differ diff --git a/examples/qml/snake/content/pics/eyes.svg b/examples/qml/snake/content/pics/eyes.svg new file mode 100644 index 0000000000..1078692725 --- /dev/null +++ b/examples/qml/snake/content/pics/eyes.svg @@ -0,0 +1,118 @@ + + + + + + + image/svg+xml + + + + + + + + + + + + + + diff --git a/examples/qml/snake/content/pics/head.png b/examples/qml/snake/content/pics/head.png new file mode 100644 index 0000000000..550e002687 Binary files /dev/null and b/examples/qml/snake/content/pics/head.png differ diff --git a/examples/qml/snake/content/pics/pause.png b/examples/qml/snake/content/pics/pause.png new file mode 100644 index 0000000000..056d97dd17 Binary files /dev/null and b/examples/qml/snake/content/pics/pause.png differ diff --git a/examples/qml/snake/content/pics/redStar.png b/examples/qml/snake/content/pics/redStar.png new file mode 100644 index 0000000000..cd06854719 Binary files /dev/null and b/examples/qml/snake/content/pics/redStar.png differ diff --git a/examples/qml/snake/content/pics/redStone.png b/examples/qml/snake/content/pics/redStone.png new file mode 100644 index 0000000000..9bb7fe4277 Binary files /dev/null and b/examples/qml/snake/content/pics/redStone.png differ diff --git a/examples/qml/snake/content/pics/skull.png b/examples/qml/snake/content/pics/skull.png new file mode 100644 index 0000000000..63186167bd Binary files /dev/null and b/examples/qml/snake/content/pics/skull.png differ diff --git a/examples/qml/snake/content/pics/snake.jpg b/examples/qml/snake/content/pics/snake.jpg new file mode 100644 index 0000000000..e91a784f71 Binary files /dev/null and b/examples/qml/snake/content/pics/snake.jpg differ diff --git a/examples/qml/snake/content/pics/star.png b/examples/qml/snake/content/pics/star.png new file mode 100644 index 0000000000..defbde53ca Binary files /dev/null and b/examples/qml/snake/content/pics/star.png differ diff --git a/examples/qml/snake/content/pics/stoneShadow.png b/examples/qml/snake/content/pics/stoneShadow.png new file mode 100644 index 0000000000..1bd56afd04 Binary files /dev/null and b/examples/qml/snake/content/pics/stoneShadow.png differ diff --git a/examples/qml/snake/content/pics/yellowStar.png b/examples/qml/snake/content/pics/yellowStar.png new file mode 100644 index 0000000000..52fb9c4b78 Binary files /dev/null and b/examples/qml/snake/content/pics/yellowStar.png differ diff --git a/examples/qml/snake/content/pics/yellowStone.png b/examples/qml/snake/content/pics/yellowStone.png new file mode 100644 index 0000000000..c56124a895 Binary files /dev/null and b/examples/qml/snake/content/pics/yellowStone.png differ diff --git a/examples/qml/snake/content/snake.js b/examples/qml/snake/content/snake.js new file mode 100644 index 0000000000..107c9f4591 --- /dev/null +++ b/examples/qml/snake/content/snake.js @@ -0,0 +1,316 @@ + +var snake = new Array; +var board = new Array; +var links = new Array; +var scheduledDirections = new Array; +var numRows = 1; +var numColumns = 1; +var linkComponent = Qt.createComponent("Link.qml"); +var cookieComponent = Qt.createComponent("Cookie.qml"); +var cookie; +var linksToGrow = 0; +var linksToDie = 0; +var waitForCookie = 0; +var growType = 0; +var skullMovementsBeforeDirectionChange = 0; + + +function rand(n) +{ + return (Math.floor(Math.random() * n)); +} + +function scheduleDirection(dir) +{ + if (state == "starting") { + direction = dir; + headDirection = direction; + head.rotation = headDirection; + } else if (state == "running"){ + direction = dir; + if(scheduledDirections[scheduledDirections.length-1]!=direction) + scheduledDirections.push(direction); + } +} + +function startNewGame() +{ + if (state == "starting") { + return; + } + + if (activeGame) { + endGame(); + startNewGameTimer.running = true; + return; + } + + state = "starting"; + + numRows = numRowsAvailable; + numColumns = numColumnsAvailable; + board = new Array(numRows * numColumns); + snake = new Array; + scheduledDirections = new Array; + growType = 0; + + skull.z = numRows * numColumns + 1; + + for (var i = 0; i < numRows * numColumns; ++i) { + if (i < links.length) { + var link = links[i]; + link.spawned = false; + link.dying = false; + } else { + if(linkComponent.status != Component.Ready) { + if(linkComponent.status == Component.Error) + console.log(linkComponent.errorString()); + else + console.log("Still loading linkComponent"); + continue;//TODO: Better error handling? + } + var link = linkComponent.createObject(playfield); + link.z = numRows * numColumns + 1 - i; + link.type = i == 0 ? 2 : 0; + link.spawned = false; + link.dying = false; + links.push(link); + } + } + + head = links[0]; + snake.push(head); + head.row = numRows/2 -1; + head.column = numColumns/2 -1; + head.spawned = true; + + linksToGrow = 5; + linksToDie = 0; + waitForCookie = 5; + score = 0; + startHeartbeatTimer.running = true; +} + +function endGame() +{ + activeGame = false; + for(var i in snake) + snake[i].dying = true; + if (cookie) { + cookie.dying = true; + cookie = 0; + } + lastScore = score; + highScores.saveScore(lastScore); + state = ""; +} + +function move() { + + if (!head) + return; + + var dir = direction; + + if (scheduledDirections.length) { + dir = scheduledDirections.shift(); + } + + if (state == "starting") { + var turn = (dir - headDirection); + head.rotation += turn == -3 ? 1 : (turn == 3 ? -1 : turn ); + headDirection = dir; + return; + } + + var row = head.row; + var column = head.column; + + if (dir == 0) { + row = row - 1; + } else if (dir == 1) { + column = column + 1 + } else if (dir == 2) { + row = row + 1; + } else if (dir == 3) { + column = column - 1; + } + + //validate the new position + if (row < 0 || row >= numRows + || column < 0 || column >= numColumns + || (row == skull.row && column == skull.column) + || !isFree(row, column)) { + var turn = (dir - headDirection); + head.rotation += turn == -3 ? 1 : (turn == 3 ? -1 : turn ); + headDirection = dir; + endGame(); + return; + } + + var newLink; + if (linksToGrow > 0) { + --linksToGrow; + newLink = links[snake.length]; + newLink.spawned = false; + newLink.rotation = snake[snake.length-1].rotation; + newLink.type = growType; + newLink.dying = false; + snake.push(newLink); + } else { + var lastLink = snake[snake.length-1]; + board[lastLink.row * numColumns + lastLink.column] = undefined; + } + + if (waitForCookie > 0) { + if (--waitForCookie == 0) + createCookie(cookie? (cookie.value+1) : 1); + } + + for (var i = snake.length-1; i > 0; --i) { + snake[i].row = snake[i-1].row; + snake[i].column = snake[i-1].column; + snake[i].rotation = snake[i-1].rotation; + } + + if (newLink) { + newLink.spawned = true; + } + + // move the head + head.row = row; + head.column = column; + board[row * numColumns + column] = head; + + var turn = (dir - headDirection); + head.rotation += turn == -3 ? 1 : (turn == 3 ? -1 : turn ); + headDirection = dir; + + var value = testCookie(row, column); + if (value > 0) { + linksToGrow += value; + score += value; + } +} + +function isFree(row, column) +{ + return board[row * numColumns + column] == undefined; +} + +function isHead(row, column) +{ + return head.column == column && head.row == row; +} + +function testCookie(row, column) +{ + if (cookie && !cookie.dying && cookie.row == row && cookie.column == column) { + var value = cookie.value; + waitForCookie = value; + growType = snake[snake.length-1].type == 1 ? 0 : 1; + cookie.dying = true; + cookie.z = numRows * numColumns + 2; + return value; + } + return 0; +} + +function moveSkull() +{ + + if (linksToDie > 0) { + --linksToDie; + var link = snake.pop(); + link.dying = true; + board[link.row * numColumns + link.column] = undefined; + if (score > 0) + --score; + if (snake.length == 0) { + endGame(); + return; + } + } + + var row = skull.row; + var column = skull.column; + if (isHead(row, column)) { + endGame(); + return; + } + row += skull.verticalMovement; + column += skull.horizontalMovement; + + var attempts = 4; + + while (skullMovementsBeforeDirectionChange == 0 || row < 0 || row >= numRows + || column < 0 || column >= numColumns + || (!isFree(row, column) && !isHead(row, column))) { + var d = rand(8); + skull.verticalMovement = 0; + skull.horizontalMovement = 0; + skullMovementsBeforeDirectionChange = rand(20)+1; + if (d == 0) { + skull.verticalMovement = -1 + } else if (d == 1) { + skull.horizontalMovement = -1; + } else if (d == 2) { + skull.verticalMovement = 1 + } else if (d == 3){ + skull.horizontalMovement = 1; + } else if (cookie) { + var rd = cookie.row - skull.row; + var rc = cookie.column - skull.column; + if (Math.abs(rd) > Math.abs(rc)) { + skull.verticalMovement = rd > 0 ? 1 : -1; + skullMovementsBeforeDirectionChange = Math.abs(rd); + } else { + skull.horizontalMovement= rc > 0 ? 1 : -1; + skullMovementsBeforeDirectionChange = Math.abs(rc); + } + } + row = skull.row + skull.verticalMovement; + column = skull.column + skull.horizontalMovement; + if (--attempts == 0) + return; + } + + skull.row = row; + skull.column = column; + --skullMovementsBeforeDirectionChange; + var value = testCookie(row, column); + if (value > 0) + linksToDie += value/2; + + if (isHead(row, column)) + endGame(); +} + +function createCookie(value) { + if (numRows * numColumns - snake.length < 10) + return; + + var column = rand(numColumns); + var row = rand(numRows); + while (!isFree(row, column)) { + column++; + if (column == numColumns) { + column = 0; + row++; + if (row == numRows) + row = 0; + } + } + + if(cookieComponent.status != Component.Ready) { + if(cookieComponent.status == Component.Error) + console.log(cookieComponent.errorString()); + else + console.log("Still loading cookieComponent"); + return;//TODO: Better error handling? + } + cookie = cookieComponent.createObject(head.parent); + cookie.value = value; + cookie.row = row; + cookie.column = column; +} diff --git a/examples/qml/snake/snake.qml b/examples/qml/snake/snake.qml new file mode 100644 index 0000000000..d389077bde --- /dev/null +++ b/examples/qml/snake/snake.qml @@ -0,0 +1,272 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtQml module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import "content" as Content +import "content/snake.js" as Logic + +Rectangle { + id: screen; + SystemPalette { id: activePalette } + color: activePalette.window + property bool activeGame: false + + property int gridSize : 34 + property int margin: 4 + property int numRowsAvailable: Math.floor((height-32-2*margin)/gridSize) + property int numColumnsAvailable: Math.floor((width-2*margin)/gridSize) + + property int lastScore : 0 + + property int score: 0; + property int heartbeatInterval: 200 + property int halfbeatInterval: 160 + + width: 480 + height: 750 + + property int direction + property int headDirection + + property variant head; + + Content.HighScoreModel { + id: highScores + game: "Snake" + } + + Timer { + id: heartbeat; + interval: heartbeatInterval; + running: activeGame + repeat: true + onTriggered: { Logic.move() } + } + Timer { + id: halfbeat; + interval: halfbeatInterval; + repeat: true + running: heartbeat.running + onTriggered: { Logic.moveSkull() } + } + Timer { + id: startNewGameTimer; + interval: 700; + onTriggered: { Logic.startNewGame(); } + } + + Timer { + id: startHeartbeatTimer; + interval: 1000 ; + onTriggered: { state = "running"; activeGame = true; } + } + + Image{ + id: pauseDialog + z: 1 + source: "content/pics/pause.png" + anchors.centerIn: parent; + //opacity is deliberately not animated + opacity: 0 //Was !Qt.application.active && activeGame, but application doesn't work (QTBUG-23331) + } + + Image { + + Image { + id: title + source: "content/pics/snake.jpg" + fillMode: Image.PreserveAspectCrop + anchors.fill: parent + anchors.horizontalCenter: parent.horizontalCenter + anchors.verticalCenter: parent.verticalCenter + + Column { + spacing: 140 + anchors.verticalCenter: parent.verticalCenter; + anchors.left: parent.left; + anchors.right: parent.right; + + Text { + color: "white" + font.pointSize: 48 + font.italic: true; + font.bold: true; + text: "Snake" + anchors.horizontalCenter: parent.horizontalCenter; + } + + Text { + color: "white" + font.pointSize: 24 + anchors.horizontalCenter: parent.horizontalCenter; + //horizontalAlignment: Text.AlignHCenter + text: "Last Score:\t" + lastScore + "\nHighscore:\t" + highScores.topScore; + } + } + } + + source: "content/pics/background.png" + fillMode: Image.PreserveAspectCrop + + anchors.left: parent.left + anchors.right: parent.right + anchors.top: parent.top + anchors.bottom: toolbar.top + + Rectangle { + id: playfield + border.width: 1 + border.color: "white" + color: "transparent" + anchors.horizontalCenter: parent.horizontalCenter + y: (screen.height - 32 - height)/2; + width: numColumnsAvailable * gridSize + 2*margin + height: numRowsAvailable * gridSize + 2*margin + + + Content.Skull { + id: skull + } + + MouseArea { + anchors.fill: parent + onPressed: { + if (screen.state == "") { + Logic.startNewGame(); + return; + } + if (direction == 0 || direction == 2) + Logic.scheduleDirection((mouseX > (head.x + head.width/2)) ? 1 : 3); + else + Logic.scheduleDirection((mouseY > (head.y + head.height/2)) ? 2 : 0); + } + } + } + + } + + Rectangle { + id: progressBar + opacity: 0 + Behavior on opacity { NumberAnimation { duration: 200 } } + color: "transparent" + border.width: 2 + border.color: "#221edd" + x: 50 + y: 50 + width: 200 + height: 30 + anchors.horizontalCenter: parent.horizontalCenter + anchors.verticalCenter: parent.verticalCenter + anchors.verticalCenterOffset: 40 + + Rectangle { + id: progressIndicator + color: "#221edd"; + width: 0; + height: 30; + } + } + + Rectangle { + id: toolbar + color: activePalette.window + height: 32; width: parent.width + anchors.bottom: screen.bottom + + Content.Button { + id: btnA; text: "New Game"; onClicked: Logic.startNewGame(); + anchors.left: parent.left; anchors.leftMargin: 3 + anchors.verticalCenter: parent.verticalCenter + } + + Content.Button { + text: "Quit" + anchors { left: btnA.right; leftMargin: 3; verticalCenter: parent.verticalCenter } + onClicked: Qt.quit(); + } + + Text { + color: activePalette.text + text: "Score: " + score; font.bold: true + anchors.right: parent.right; anchors.rightMargin: 3 + anchors.verticalCenter: parent.verticalCenter + } + } + + focus: true + Keys.onSpacePressed: Logic.startNewGame(); + Keys.onLeftPressed: if (state == "starting" || direction != 1) Logic.scheduleDirection(3); + Keys.onRightPressed: if (state == "starting" || direction != 3) Logic.scheduleDirection(1); + Keys.onUpPressed: if (state == "starting" || direction != 2) Logic.scheduleDirection(0); + Keys.onDownPressed: if (state == "starting" || direction != 0) Logic.scheduleDirection(2); + + states: [ + State { + name: "starting" + PropertyChanges {target: progressIndicator; width: 200} + PropertyChanges {target: title; opacity: 0} + PropertyChanges {target: progressBar; opacity: 1} + }, + State { + name: "running" + PropertyChanges {target: progressIndicator; width: 200} + PropertyChanges {target: title; opacity: 0} + PropertyChanges {target: skull; row: 0; column: 0; } + PropertyChanges {target: skull; spawned: 1} + } + ] + + transitions: [ + Transition { + from: "*" + to: "starting" + NumberAnimation { target: progressIndicator; property: "width"; duration: 1000 } + NumberAnimation { property: "opacity"; duration: 200 } + }, + Transition { + to: "starting" + NumberAnimation { target: progressIndicator; property: "width"; duration: 1000 } + NumberAnimation { property: "opacity"; duration: 200 } + } + ] + +} diff --git a/examples/qml/snake/snake.qmlproject b/examples/qml/snake/snake.qmlproject new file mode 100644 index 0000000000..fb015465d1 --- /dev/null +++ b/examples/qml/snake/snake.qmlproject @@ -0,0 +1,16 @@ +import QmlProject 1.1 + +Project { + mainFile: "snake.qml" + + /* Include .qml, .js, and image files from current directory and subdirectories */ + QmlFiles { + directory: "." + } + JavaScriptFiles { + directory: "." + } + ImageFiles { + directory: "." + } +} diff --git a/examples/qml/sqllocalstorage/hello.qml b/examples/qml/sqllocalstorage/hello.qml new file mode 100644 index 0000000000..3496b86bd9 --- /dev/null +++ b/examples/qml/sqllocalstorage/hello.qml @@ -0,0 +1,78 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +//![0] +import QtQuick 2.0 +import QtQuick.LocalStorage 2.0 as LS + +Rectangle { + color: "white" + width: 200 + height: 100 + + Text { + text: "?" + anchors.horizontalCenter: parent.horizontalCenter + function findGreetings() { + var db = LS.openDatabaseSync("QDeclarativeExampleDB", "1.0", "The Example QML SQL!", 1000000); + + db.transaction( + function(tx) { + // Create the database if it doesn't already exist + tx.executeSql('CREATE TABLE IF NOT EXISTS Greeting(salutation TEXT, salutee TEXT)'); + + // Add (another) greeting row + tx.executeSql('INSERT INTO Greeting VALUES(?, ?)', [ 'hello', 'world' ]); + + // Show all added greetings + var rs = tx.executeSql('SELECT * FROM Greeting'); + + var r = "" + for(var i = 0; i < rs.rows.length; i++) { + r += rs.rows.item(i).salutation + ", " + rs.rows.item(i).salutee + "\n" + } + text = r + } + ) + } + + Component.onCompleted: findGreetings() + } +} +//![0] diff --git a/examples/qml/text/fonts/availableFonts.qml b/examples/qml/text/fonts/availableFonts.qml new file mode 100644 index 0000000000..0b87259556 --- /dev/null +++ b/examples/qml/text/fonts/availableFonts.qml @@ -0,0 +1,57 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Rectangle { + width: 480; height: 640; color: "steelblue" + + ListView { + anchors.fill: parent; model: Qt.fontFamilies() + + delegate: Item { + height: 40; width: ListView.view.width + Text { + anchors.centerIn: parent + text: modelData; font.family: modelData; font.pixelSize: 24; color: "white" + } + } + } +} diff --git a/examples/qml/text/fonts/banner.qml b/examples/qml/text/fonts/banner.qml new file mode 100644 index 0000000000..6c9aa25fa1 --- /dev/null +++ b/examples/qml/text/fonts/banner.qml @@ -0,0 +1,61 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Rectangle { + id: screen + + property int pixelSize: screen.height * 1.25 + property color textColor: "lightsteelblue" + property string text: "Hello world! " + + width: 640; height: 320 + color: "steelblue" + + Row { + y: -screen.height / 4.5 + + NumberAnimation on x { from: 0; to: -text.width; duration: 6000; loops: Animation.Infinite } + Text { id: text; font.pixelSize: screen.pixelSize; color: screen.textColor; text: screen.text } + Text { font.pixelSize: screen.pixelSize; color: screen.textColor; text: screen.text } + Text { font.pixelSize: screen.pixelSize; color: screen.textColor; text: screen.text } + } +} diff --git a/examples/qml/text/fonts/content/fonts/tarzeau_ocr_a.ttf b/examples/qml/text/fonts/content/fonts/tarzeau_ocr_a.ttf new file mode 100644 index 0000000000..cf93f9651f Binary files /dev/null and b/examples/qml/text/fonts/content/fonts/tarzeau_ocr_a.ttf differ diff --git a/examples/qml/text/fonts/fonts.qml b/examples/qml/text/fonts/fonts.qml new file mode 100644 index 0000000000..78cef25eae --- /dev/null +++ b/examples/qml/text/fonts/fonts.qml @@ -0,0 +1,104 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Rectangle { + property string myText: "The quick brown fox jumps over the lazy dog." + + width: 800; height: 480 + color: "steelblue" + + FontLoader { id: fixedFont; name: "Courier" } + FontLoader { id: localFont; source: "content/fonts/tarzeau_ocr_a.ttf" } + FontLoader { id: webFont; source: "http://www.princexml.com/fonts/steffmann/Starburst.ttf" } + + Column { + anchors { fill: parent; leftMargin: 10; rightMargin: 10 } + spacing: 15 + + Text { + text: myText + color: "lightsteelblue" + width: parent.width + elide: Text.ElideRight + font.family: "Times"; font.pointSize: 42 + } + Text { + text: myText + color: "lightsteelblue" + width: parent.width + elide: Text.ElideLeft + font { family: "Times"; pointSize: 42; capitalization: Font.AllUppercase } + } + Text { + text: myText + color: "lightsteelblue" + width: parent.width + elide: Text.ElideMiddle + font { family: fixedFont.name; pointSize: 42; weight: Font.Bold; capitalization: Font.AllLowercase } + } + Text { + text: myText + color: "lightsteelblue" + width: parent.width + elide: Text.ElideRight + font { family: fixedFont.name; pointSize: 42; italic: true; capitalization: Font.SmallCaps } + } + Text { + text: myText + color: "lightsteelblue" + width: parent.width + elide: Text.ElideLeft + font { family: localFont.name; pointSize: 42; capitalization: Font.Capitalize } + } + Text { + text: { + if (webFont.status == FontLoader.Ready) myText + else if (webFont.status == FontLoader.Loading) "Loading..." + else if (webFont.status == FontLoader.Error) "Error loading font" + } + color: "lightsteelblue" + width: parent.width + elide: Text.ElideMiddle + font.family: webFont.name; font.pointSize: 42 + } + } +} diff --git a/examples/qml/text/fonts/hello.qml b/examples/qml/text/fonts/hello.qml new file mode 100644 index 0000000000..d9479fb208 --- /dev/null +++ b/examples/qml/text/fonts/hello.qml @@ -0,0 +1,79 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Rectangle { + id: screen + + width: 800; height: 480 + color: "black" + + Item { + id: container + x: screen.width / 2; y: screen.height / 2 + + Text { + id: text + anchors.centerIn: parent + color: "white" + text: "Hello world!" + font.pixelSize: 60 + smooth: true + + SequentialAnimation on font.letterSpacing { + loops: Animation.Infinite; + NumberAnimation { from: 0; to: 150; easing.type: Easing.InQuad; duration: 3000 } + ScriptAction { + script: { + container.y = (screen.height / 4) + (Math.random() * screen.height / 2) + container.x = (screen.width / 4) + (Math.random() * screen.width / 2) + } + } + } + + SequentialAnimation on opacity { + loops: Animation.Infinite; + NumberAnimation { from: 1; to: 0; duration: 2600 } + PauseAnimation { duration: 400 } + } + } + } +} diff --git a/examples/qml/text/imgtag/TextWithImage.qml b/examples/qml/text/imgtag/TextWithImage.qml new file mode 100644 index 0000000000..bc09aa2a52 --- /dev/null +++ b/examples/qml/text/imgtag/TextWithImage.qml @@ -0,0 +1,55 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Text { + width: parent.width + font.pointSize: 14 + wrapMode: Text.WordWrap + textFormat: Text.StyledText + horizontalAlignment: main.hAlign + + Rectangle { + border.color: "#efefef" + color: "transparent" + anchors.fill: parent + } +} diff --git a/examples/qml/text/imgtag/images/face-sad.png b/examples/qml/text/imgtag/images/face-sad.png new file mode 100644 index 0000000000..24188b7985 Binary files /dev/null and b/examples/qml/text/imgtag/images/face-sad.png differ diff --git a/examples/qml/text/imgtag/images/face-smile-big.png b/examples/qml/text/imgtag/images/face-smile-big.png new file mode 100644 index 0000000000..d05e0bf21e Binary files /dev/null and b/examples/qml/text/imgtag/images/face-smile-big.png differ diff --git a/examples/qml/text/imgtag/images/face-smile.png b/examples/qml/text/imgtag/images/face-smile.png new file mode 100644 index 0000000000..e5e1d1353c Binary files /dev/null and b/examples/qml/text/imgtag/images/face-smile.png differ diff --git a/examples/qml/text/imgtag/images/heart200.png b/examples/qml/text/imgtag/images/heart200.png new file mode 100644 index 0000000000..cedd3ea608 Binary files /dev/null and b/examples/qml/text/imgtag/images/heart200.png differ diff --git a/examples/qml/text/imgtag/images/qtlogo.png b/examples/qml/text/imgtag/images/qtlogo.png new file mode 100644 index 0000000000..996719a4c6 Binary files /dev/null and b/examples/qml/text/imgtag/images/qtlogo.png differ diff --git a/examples/qml/text/imgtag/images/starfish_2.png b/examples/qml/text/imgtag/images/starfish_2.png new file mode 100644 index 0000000000..132c20ffd0 Binary files /dev/null and b/examples/qml/text/imgtag/images/starfish_2.png differ diff --git a/examples/qml/text/imgtag/imgtag.qml b/examples/qml/text/imgtag/imgtag.qml new file mode 100644 index 0000000000..9d181af2cb --- /dev/null +++ b/examples/qml/text/imgtag/imgtag.qml @@ -0,0 +1,101 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Rectangle { + id: main + width: 320; height: 480 + focus: true + + property var hAlign: Text.AlignLeft + + Flickable { + anchors.fill: parent + contentWidth: parent.width + contentHeight: col.height + 20 + + Column { + id: col + x: 10; y: 10 + spacing: 20 + width: parent.width - 20 + + TextWithImage { + text: "This is a happy face" + } + TextWithImage { + text: "This is a veryhappy face aligned in the middle." + } + TextWithImage { + elide: Text.ElideRight + maximumLineCount: 2 + text: "This is a sad face aligned to the top. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nunc rutrum dui pretium ipsum malesuada venenatis. Nulla sed turpis risus. Integer sit amet odio quis mauris varius venenatisLorem ipsum dolor sit amet, consectetur adipiscing elit. Nunc rutrum dui pretium ipsum malesuada venenatis. Nulla sed turpis risus. Integer sit amet odio quis mauris varius venenatis." + } + TextWithImage { + text: "This is a tinyhappy face." + } + TextWithImage { + text: "This is a starfishaligned to the top and another onealigned to the bottom." + } + TextWithImage { + text: "Qt logosaligned in the middle with different sizes." + } + TextWithImage { + text: "Some hearts with different sizes." + } + TextWithImage { + text: "Resized imagefrom the internet." + } + TextWithImage { + text: "Imagefrom the internet." + } + TextWithImage { + height: 120 + verticalAlignment: Text.AlignVCenter + text: "This is a happy face with an explicit height." + } + } + } + + Keys.onUpPressed: main.hAlign = Text.AlignHCenter + Keys.onLeftPressed: main.hAlign = Text.AlignLeft + Keys.onRightPressed: main.hAlign = Text.AlignRight +} diff --git a/examples/qml/text/styledtext-layout.qml b/examples/qml/text/styledtext-layout.qml new file mode 100644 index 0000000000..4571330568 --- /dev/null +++ b/examples/qml/text/styledtext-layout.qml @@ -0,0 +1,107 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Rectangle { + id: main + width: 320; height: 480 + focus: true + + property real offset: 0 + property real margin: 10 + + Keys.onLeftPressed: myText.horizontalAlignment = Text.AlignLeft + Keys.onUpPressed: myText.horizontalAlignment = Text.AlignHCenter + Keys.onRightPressed: myText.horizontalAlignment = Text.AlignRight + Keys.onDownPressed: myText.horizontalAlignment = Text.AlignJustify + + Text { + id: myText + anchors.fill: parent + anchors.margins: 10 + wrapMode: Text.WordWrap + font.family: "Times New Roman" + font.pixelSize: 13 + textFormat: Text.StyledText + horizontalAlignment: Text.AlignJustify + + text: "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer at ante dui sed eu egestas est facilis www.nokia.com.
Curabitur ante est, pulvinar quis adipiscing a, iaculis id ipsum. Phasellus id neque id velit facilisis cursus ac sit amet nibh. Donec enim arcu, pharetra non semper nec, iaculis eget elit. Nunc blandit condimentum odio vel egestas.
  • Coffee
    1. Espresso
    2. Cappuccino
    3. Flat White
    4. Latte
  • Juice
    1. Orange
    2. Apple
    3. Pineapple
    4. Tomato

Proin consectetur sapien in ipsum lacinia sit amet mattis orci interdum. Quisque vitae accumsan lectus. Ut nisi turpis, sollicitudin ut dignissim id, fermentum ac est. Maecenas nec libero leo. Sed ac leo eget ipsum ultricies viverra sit amet eu orci. Praesent et tortor risus, viverra accumsan sapien. Sed faucibus eleifend lectus, sed euismod urna porta eu. Aenean ultricies lectus ut orci dictum quis convallis nisi ultrices. Nunc elit mi, iaculis a porttitor rutrum, venenatis malesuada nisi. Suspendisse turpis quam, euismod non imperdiet et, rutrum nec ligula. Lorem ipsum dolor sit amet, consectetur adipiscing elit." + + onLineLaidOut: { + line.width = width / 2 - (2 * margin) + if (line.number === 30) { + main.offset = line.y + } + if (line.number >= 30) { + line.x = width / 2 + margin + line.y -= main.offset + } + if ((line.y + line.height) > rect.y && line.y < (rect.y + rect.height)) { + if (line.number < 30) + line.width = Math.min((rect.x - line.x), line.width) + else { + line.x = Math.max((rect.x + rect.width), width / 2 + margin) + line.width = Math.min((width - margin - line.x), line.width) + } + } + } + + Item { + id: rect + x: 28; y: 20 + width: 60; height: 60 + + Rectangle { + anchors { fill: parent; leftMargin: 2; rightMargin: 2 } + color: "lightsteelblue"; opacity: 0.3 + } + + MouseArea { + anchors.fill: parent + drag.target: rect + acceptedButtons: Qt.LeftButton | Qt.RightButton + onClicked: mouse.button == Qt.RightButton ? myText.font.pixelSize -= 1 : myText.font.pixelSize += 1 + onPositionChanged: myText.doLayout() + } + } + } + +} diff --git a/examples/qml/text/text.qml b/examples/qml/text/text.qml new file mode 100644 index 0000000000..14a88d2e91 --- /dev/null +++ b/examples/qml/text/text.qml @@ -0,0 +1,57 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import "../shared" + +Item { + height: 480 + width: 480 + LauncherList { + id: ll + anchors.fill: parent + Component.onCompleted: { + addExample("Hello", "An Animated Hello World", Qt.resolvedUrl("fonts/hello.qml")); + addExample("Fonts", "Using various fonts with a Text element", Qt.resolvedUrl("fonts/fonts.qml")); + addExample("Available Fonts", "A list of your available fonts", Qt.resolvedUrl("fonts/availableFonts.qml")); + addExample("Banner", "Large, scrolling text", Qt.resolvedUrl("fonts/banner.qml")); + } + } +} diff --git a/examples/qml/text/text.qmlproject b/examples/qml/text/text.qmlproject new file mode 100644 index 0000000000..c08d9b9a89 --- /dev/null +++ b/examples/qml/text/text.qmlproject @@ -0,0 +1,16 @@ +import QmlProject 1.1 + +Project { + mainFile: "text.qml" + + /* Include .qml, .js, and image files from current directory and subdirectories */ + QmlFiles { + directory: "." + } + JavaScriptFiles { + directory: "." + } + ImageFiles { + directory: "." + } +} diff --git a/examples/qml/text/textselection/pics/endHandle.png b/examples/qml/text/textselection/pics/endHandle.png new file mode 100644 index 0000000000..1a4bc5d7a0 Binary files /dev/null and b/examples/qml/text/textselection/pics/endHandle.png differ diff --git a/examples/qml/text/textselection/pics/endHandle.sci b/examples/qml/text/textselection/pics/endHandle.sci new file mode 100644 index 0000000000..4f51f24278 --- /dev/null +++ b/examples/qml/text/textselection/pics/endHandle.sci @@ -0,0 +1,5 @@ +border.left: 0 +border.top: 6 +border.bottom: 6 +border.right: 6 +source: endHandle.png diff --git a/examples/qml/text/textselection/pics/startHandle.png b/examples/qml/text/textselection/pics/startHandle.png new file mode 100644 index 0000000000..deedcd5c91 Binary files /dev/null and b/examples/qml/text/textselection/pics/startHandle.png differ diff --git a/examples/qml/text/textselection/pics/startHandle.sci b/examples/qml/text/textselection/pics/startHandle.sci new file mode 100644 index 0000000000..f9eae204c1 --- /dev/null +++ b/examples/qml/text/textselection/pics/startHandle.sci @@ -0,0 +1,5 @@ +border.left: 6 +border.top: 6 +border.bottom: 6 +border.right: 0 +source: startHandle.png diff --git a/examples/qml/text/textselection/textselection.qml b/examples/qml/text/textselection/textselection.qml new file mode 100644 index 0000000000..7938ce5bf7 --- /dev/null +++ b/examples/qml/text/textselection/textselection.qml @@ -0,0 +1,211 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +import QtQuick 2.0 + +Rectangle { + id: editor + color: "lightGrey" + width: 640; height: 480 + + Rectangle { + color: "white" + anchors.fill: parent + anchors.margins: 20 + + BorderImage { + id: startHandle + source: "pics/startHandle.sci" + opacity: 0.0 + width: 10 + x: edit.positionToRectangle(edit.selectionStart).x - flick.contentX-width + y: edit.positionToRectangle(edit.selectionStart).y - flick.contentY + height: edit.positionToRectangle(edit.selectionStart).height + } + + BorderImage { + id: endHandle + source: "pics/endHandle.sci" + opacity: 0.0 + width: 10 + x: edit.positionToRectangle(edit.selectionEnd).x - flick.contentX + y: edit.positionToRectangle(edit.selectionEnd).y - flick.contentY + height: edit.positionToRectangle(edit.selectionEnd).height + } + + Flickable { + id: flick + + anchors.fill: parent + contentWidth: edit.paintedWidth + contentHeight: edit.paintedHeight + interactive: true + clip: true + + function ensureVisible(r) { + if (contentX >= r.x) + contentX = r.x; + else if (contentX+width <= r.x+r.width) + contentX = r.x+r.width-width; + if (contentY >= r.y) + contentY = r.y; + else if (contentY+height <= r.y+r.height) + contentY = r.y+r.height-height; + } + + TextEdit { + id: edit + width: flick.width + height: flick.height + focus: true + wrapMode: TextEdit.Wrap + textFormat: TextEdit.RichText + + onCursorRectangleChanged: flick.ensureVisible(cursorRectangle) + + text: "

Text Selection

" + +"

This example is a whacky text selection mechanisms, showing how these can be implemented in the TextEdit element, to cater for whatever style is appropriate for the target platform." + +"

Press-and-hold to select a word, then drag the selection handles." + +"

Drag outside the selection to scroll the text." + +"

Click inside the selection to cut/copy/paste/cancel selection." + +"

It's too whacky to let you paste if there is no current selection." + + } + } + + Item { + id: menu + opacity: 0.0 + width: 100 + height: 120 + anchors.centerIn: parent + + Rectangle { + border.width: 1 + border.color: "darkBlue" + radius: 15 + color: "#806080FF" + anchors.fill: parent + } + + Column { + anchors.centerIn: parent + spacing: 8 + + Rectangle { + border.width: 1 + border.color: "darkBlue" + color: "#ff7090FF" + width: 60 + height: 16 + + Text { anchors.centerIn: parent; text: "Cut" } + + MouseArea { + anchors.fill: parent + onClicked: { edit.cut(); editor.state = "" } + } + } + + Rectangle { + border.width: 1 + border.color: "darkBlue" + color: "#ff7090FF" + width: 60 + height: 16 + + Text { anchors.centerIn: parent; text: "Copy" } + + MouseArea { + anchors.fill: parent + onClicked: { edit.copy(); editor.state = "selection" } + } + } + + Rectangle { + border.width: 1 + border.color: "darkBlue" + color: "#ff7090FF" + width: 60 + height: 16 + + Text { anchors.centerIn: parent; text: "Paste" } + + MouseArea { + anchors.fill: parent + onClicked: { edit.paste(); edit.cursorPosition = edit.selectionEnd; editor.state = "" } + } + } + + Rectangle { + border.width: 1 + border.color: "darkBlue" + color: "#ff7090FF" + width: 60 + height: 16 + + Text { anchors.centerIn: parent; text: "Deselect" } + + MouseArea { + anchors.fill: parent + onClicked: { + edit.cursorPosition = edit.selectionEnd; + edit.deselect(); + editor.state = "" + } + } + } + } + } + } + + states: [ + State { + name: "selection" + PropertyChanges { target: startHandle; opacity: 1.0 } + PropertyChanges { target: endHandle; opacity: 1.0 } + }, + State { + name: "menu" + PropertyChanges { target: startHandle; opacity: 0.5 } + PropertyChanges { target: endHandle; opacity: 0.5 } + PropertyChanges { target: menu; opacity: 1.0 } + } + ] +} diff --git a/examples/qml/threading/threadedlistmodel/dataloader.js b/examples/qml/threading/threadedlistmodel/dataloader.js new file mode 100644 index 0000000000..4d2aab323d --- /dev/null +++ b/examples/qml/threading/threadedlistmodel/dataloader.js @@ -0,0 +1,49 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +// ![0] +WorkerScript.onMessage = function(msg) { + if (msg.action == 'appendCurrentTime') { + var data = {'time': new Date().toTimeString()}; + msg.model.append(data); + msg.model.sync(); // updates the changes to the list + } +} +// ![0] diff --git a/examples/qml/threading/threadedlistmodel/threadedlistmodel.qmlproject b/examples/qml/threading/threadedlistmodel/threadedlistmodel.qmlproject new file mode 100644 index 0000000000..e7c8e69f14 --- /dev/null +++ b/examples/qml/threading/threadedlistmodel/threadedlistmodel.qmlproject @@ -0,0 +1,56 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QmlProject 1.1 + +Project { + mainFile: "timedisplay.qml" + + /* Include .qml, .js, and image files from current directory and subdirectories */ + QmlFiles { + directory: "." + } + JavaScriptFiles { + directory: "." + } + ImageFiles { + directory: "." + } +} diff --git a/examples/qml/threading/threadedlistmodel/timedisplay.qml b/examples/qml/threading/threadedlistmodel/timedisplay.qml new file mode 100644 index 0000000000..48d0f659e5 --- /dev/null +++ b/examples/qml/threading/threadedlistmodel/timedisplay.qml @@ -0,0 +1,76 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +// ![0] +import QtQuick 2.0 + +Rectangle { + color: "white" + width: 200 + height: 300 + + ListView { + anchors.fill: parent + model: listModel + delegate: Component { + Text { text: time } + } + + ListModel { id: listModel } + + WorkerScript { + id: worker + source: "dataloader.js" + } + + Timer { + id: timer + interval: 2000; repeat: true + running: true + triggeredOnStart: true + + onTriggered: { + var msg = {'action': 'appendCurrentTime', 'model': listModel}; + worker.sendMessage(msg); + } + } + } +} +// ![0] diff --git a/examples/qml/threading/workerscript/workerscript.js b/examples/qml/threading/workerscript/workerscript.js new file mode 100644 index 0000000000..f76471f920 --- /dev/null +++ b/examples/qml/threading/workerscript/workerscript.js @@ -0,0 +1,15 @@ +var lastx = 0; +var lasty = 0; + +WorkerScript.onMessage = function(message) { + var ydiff = message.y - lasty; + var xdiff = message.x - lastx; + + var total = Math.sqrt(ydiff * ydiff + xdiff * xdiff); + + lastx = message.x; + lasty = message.y; + + WorkerScript.sendMessage( {xmove: xdiff, ymove: ydiff, move: total} ); +} + diff --git a/examples/qml/threading/workerscript/workerscript.qml b/examples/qml/threading/workerscript/workerscript.qml new file mode 100644 index 0000000000..7fced8166c --- /dev/null +++ b/examples/qml/threading/workerscript/workerscript.qml @@ -0,0 +1,83 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Rectangle { + width: 480; height: 320 + + WorkerScript { + id: myWorker + source: "workerscript.js" + + onMessage: { + console.log("Moved " + messageObject.xmove + " along the X axis."); + console.log("Moved " + messageObject.ymove + " along the Y axis."); + console.log("Moved " + messageObject.move + " pixels."); + } + } + + Rectangle { + width: 200; height: 200 + anchors.left: parent.left; anchors.leftMargin: 20 + color: "red" + + MouseArea { + anchors.fill: parent + onClicked: myWorker.sendMessage( { rectangle: "red", x: mouse.x, y: mouse.y } ); + } + } + + Rectangle { + width: 200; height: 200 + anchors.right: parent.right; anchors.rightMargin: 20 + color: "blue" + + MouseArea { + anchors.fill: parent + onClicked: myWorker.sendMessage( { rectangle: "blue", x: mouse.x, y: mouse.y } ); + } + } + + Text { + text: "Click a Rectangle!" + anchors { horizontalCenter: parent.horizontalCenter; bottom: parent.bottom; bottomMargin: 50 } + } +} diff --git a/examples/qml/threading/workerscript/workerscript.qmlproject b/examples/qml/threading/workerscript/workerscript.qmlproject new file mode 100644 index 0000000000..6d7a91feeb --- /dev/null +++ b/examples/qml/threading/workerscript/workerscript.qmlproject @@ -0,0 +1,16 @@ +import QmlProject 1.1 + +Project { + mainFile: "workerscript.qml" + + /* Include .qml, .js, and image files from current directory and subdirectories */ + QmlFiles { + directory: "." + } + JavaScriptFiles { + directory: "." + } + ImageFiles { + directory: "." + } +} diff --git a/examples/qml/touchinteraction/mousearea/mousearea-example.qml b/examples/qml/touchinteraction/mousearea/mousearea-example.qml new file mode 100644 index 0000000000..30e3e62864 --- /dev/null +++ b/examples/qml/touchinteraction/mousearea/mousearea-example.qml @@ -0,0 +1,176 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Rectangle { + id: box + width: 400; height: 300 + + Rectangle { + id: redSquare + width: 120; height: 120 + anchors.top: parent.top; anchors.left: parent.left; anchors.margins: 10 + color: "red" + + Text { text: "Click"; font.pixelSize: 16; anchors.centerIn: parent } + + MouseArea { + anchors.fill: parent + hoverEnabled: true + property string buttonID + + acceptedButtons: Qt.AllButtons + // Value 'All.Buttons' is eqivalent to: + // 'Qt::LeftButton | Qt::RightButton | Qt::MiddleButton .... | Qt::ExtraButton24' + + onEntered: info.text = 'Entered' + onExited: info.text = 'Exited (pressed=' + pressed + ')' + + onPressed: { + if (mouse.button == Qt.LeftButton) + buttonID = 'LeftButton' + else if (mouse.button == Qt.RightButton) + buttonID = 'RightButton' + else if (mouse.button == Qt.MidButton) + buttonID = 'MiddleButton' + else if (mouse.button == Qt.BackButton) + buttonID = 'BackButton' + else if (mouse.button == Qt.ForwardButton) + buttonID = 'ForwardButton' + else if (mouse.button == Qt.TaskButton) + buttonID = 'TaskButton' + else if (mouse.button == Qt.ExtraButton4) + buttonID = 'ExtraButton4' + else if (mouse.button == Qt.ExtraButton5) + buttonID = 'ExtraButton5' + else if (mouse.button == Qt.ExtraButton6) + buttonID = 'ExtraButton6' + else if (mouse.button == Qt.ExtraButton7) + buttonID = 'ExtraButton7' + else if (mouse.button == Qt.ExtraButton8) + buttonID = 'ExtraButton8' + else if (mouse.button == Qt.ExtraButton9) + buttonID = 'ExtraButton9' + else if (mouse.button == Qt.ExtraButton10) + buttonID = 'ExtraButton10' + else if (mouse.button == Qt.ExtraButton11) + buttonID = 'ExtraButton11' + else if (mouse.button == Qt.ExtraButton12) + buttonID = 'ExtraButton12' + else if (mouse.button == Qt.ExtraButton13) + buttonID = 'ExtraButton13' + else if (mouse.button == Qt.ExtraButton14) + buttonID = 'ExtraButton14' + else if (mouse.button == Qt.ExtraButton15) + buttonID = 'ExtraButton15' + else if (mouse.button == Qt.ExtraButton16) + buttonID = 'ExtraButton16' + else if (mouse.button == Qt.ExtraButton17) + buttonID = 'ExtraButton17' + else if (mouse.button == Qt.ExtraButton18) + buttonID = 'ExtraButton18' + else if (mouse.button == Qt.ExtraButton19) + buttonID = 'ExtraButton19' + else if (mouse.button == Qt.ExtraButton20) + buttonID = 'ExtraButton20' + else if (mouse.button == Qt.ExtraButton21) + buttonID = 'ExtraButton21' + else if (mouse.button == Qt.ExtraButton22) + buttonID = 'ExtraButton22' + else if (mouse.button == Qt.ExtraButton23) + buttonID = 'ExtraButton23' + else if (mouse.button == Qt.ExtraButton24) + buttonID = 'ExtraButton24' + + info.text = 'Pressed (' + buttonID + ' shift=' + + (mouse.modifiers & Qt.ShiftModifier ? 'true' : 'false') + ')' + var posInBox = redSquare.mapToItem(box, mouse.x, mouse.y) + posInfo.text = + mouse.x + ',' + mouse.y + ' in square' + + ' (' + posInBox.x + ',' + posInBox.y + ' in window)' + } + + onReleased: { + btn.text = 'Released (isClick=' + mouse.isClick + ' wasHeld=' + mouse.wasHeld + ')' + posInfo.text = '' + } + + onPressAndHold: btn.text = 'Press and hold' + onClicked: btn.text = 'Clicked (wasHeld=' + mouse.wasHeld + ')' + onDoubleClicked: btn.text = 'Double clicked' + } + } + + Rectangle { + id: blueSquare + width: 120; height: 120 + x: box.width - width - 10; y: 10 // making this item draggable, so don't use anchors + color: "blue" + + Text { text: "Drag"; font.pixelSize: 16; color: "white"; anchors.centerIn: parent } + + MouseArea { + anchors.fill: parent + drag.target: blueSquare + drag.axis: Drag.XandYAxis + drag.minimumX: 0 + drag.maximumX: box.width - parent.width + drag.minimumY: 0 + drag.maximumY: box.height - parent.width + } + } + + Text { + id: info + anchors.bottom: btn.top; anchors.horizontalCenter: parent.horizontalCenter; anchors.margins: 20 + + onTextChanged: console.log(text) + } + + Text { + id: btn + anchors.bottom: posInfo.top; anchors.horizontalCenter: parent.horizontalCenter; anchors.margins: 20 + } + + Text { + id: posInfo + anchors.bottom: parent.bottom; anchors.horizontalCenter: parent.horizontalCenter; anchors.margins: 20 + } +} diff --git a/examples/qml/touchinteraction/multipointtouch/bearwhack.qml b/examples/qml/touchinteraction/multipointtouch/bearwhack.qml new file mode 100644 index 0000000000..db46473c05 --- /dev/null +++ b/examples/qml/touchinteraction/multipointtouch/bearwhack.qml @@ -0,0 +1,133 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +import QtQuick 2.0 +import QtQuick.Particles 2.0 +import "content" + +Item { + id: root + height: 640 + width: 320 + Item { + id: startScreen + anchors.fill: parent + z: 1000 + Image { + source: "content/title.png" + anchors.centerIn: parent + } + MouseArea{ + anchors.fill: parent + onClicked: {//Game Start + parent.visible = false; + } + } + } + Rectangle { + id: bg + anchors.fill: parent + gradient: Gradient { + GradientStop { position: 0.0; color: "DarkBlue" } + GradientStop { position: 0.8; color: "SkyBlue" } + GradientStop { position: 0.81; color: "ForestGreen" } + GradientStop { position: 1.0; color: "DarkGreen" } + } + } + + BearWhackParticleSystem { + id: particleSystem + anchors.fill: parent + running: !startScreen.visible + } + + property int score: 0 + + Text { + anchors.right: parent.right + anchors.margins: 4 + anchors.top: parent.top + color: "white" + function padded(num) { + var ret = num.toString(); + while (ret.length < 6) + ret = "0" + ret; + return ret; + } + text: "Score: " + padded(score) + } + MultiPointTouchArea { + anchors.fill: parent + touchPoints: [//Support up to 4 touches at once? + AugmentedTouchPoint{ system: particleSystem }, + AugmentedTouchPoint{ system: particleSystem }, + AugmentedTouchPoint{ system: particleSystem }, + AugmentedTouchPoint{ system: particleSystem } + ] + } + MouseArea{ + anchors.fill: parent + id: ma + onPressedChanged: { + if (pressed) { + timer.restart(); + sgoal.enabled = true; + particleSystem.explode(mouseX,mouseY); + } + } + Timer { + id: timer + interval: 100 + running: false + repeat: false + onTriggered: sgoal.enabled = false + } + SpriteGoal { + id: sgoal + x: ma.mouseX - 16 + y: ma.mouseY - 16 + width: 32 + height: 32 + system: particleSystem + parent: particleSystem + goalState: "falling" + enabled: false + } + } +} diff --git a/examples/qml/touchinteraction/multipointtouch/content/AugmentedTouchPoint.qml b/examples/qml/touchinteraction/multipointtouch/content/AugmentedTouchPoint.qml new file mode 100644 index 0000000000..aede1a8f4e --- /dev/null +++ b/examples/qml/touchinteraction/multipointtouch/content/AugmentedTouchPoint.qml @@ -0,0 +1,70 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +import QtQuick 2.0 +import QtQuick.Particles 2.0 + +TouchPoint { + id: container + property ParticleSystem system + onPressedChanged: { + if (pressed) { + timer.restart(); + child.enabled = true; + system.explode(x,y); + } + } + property QtObject obj: Timer { + id: timer + interval: 100 + running: false + repeat: false + onTriggered: child.enabled = false + } + property Item child: SpriteGoal { + enabled: false + x: container.area.x - 16 + y: container.area.y - 16 + width: container.area.width + 32 + height: container.area.height + 32 //+32 so it doesn't have to hit the exact center + system: container.system + parent: container.system + goalState: "falling" + } +} diff --git a/examples/qml/touchinteraction/multipointtouch/content/Bear0.png b/examples/qml/touchinteraction/multipointtouch/content/Bear0.png new file mode 100644 index 0000000000..64a02cec8e Binary files /dev/null and b/examples/qml/touchinteraction/multipointtouch/content/Bear0.png differ diff --git a/examples/qml/touchinteraction/multipointtouch/content/Bear1.png b/examples/qml/touchinteraction/multipointtouch/content/Bear1.png new file mode 100644 index 0000000000..3b88f3b32e Binary files /dev/null and b/examples/qml/touchinteraction/multipointtouch/content/Bear1.png differ diff --git a/examples/qml/touchinteraction/multipointtouch/content/Bear2.png b/examples/qml/touchinteraction/multipointtouch/content/Bear2.png new file mode 100644 index 0000000000..337b636070 Binary files /dev/null and b/examples/qml/touchinteraction/multipointtouch/content/Bear2.png differ diff --git a/examples/qml/touchinteraction/multipointtouch/content/Bear3.png b/examples/qml/touchinteraction/multipointtouch/content/Bear3.png new file mode 100644 index 0000000000..f0e68590f4 Binary files /dev/null and b/examples/qml/touchinteraction/multipointtouch/content/Bear3.png differ diff --git a/examples/qml/touchinteraction/multipointtouch/content/BearB.png b/examples/qml/touchinteraction/multipointtouch/content/BearB.png new file mode 100644 index 0000000000..c9a84ae1d4 Binary files /dev/null and b/examples/qml/touchinteraction/multipointtouch/content/BearB.png differ diff --git a/examples/qml/touchinteraction/multipointtouch/content/BearWhackParticleSystem.qml b/examples/qml/touchinteraction/multipointtouch/content/BearWhackParticleSystem.qml new file mode 100644 index 0000000000..05d74ab0ea --- /dev/null +++ b/examples/qml/touchinteraction/multipointtouch/content/BearWhackParticleSystem.qml @@ -0,0 +1,180 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +import QtQuick 2.0 +import QtQuick.Particles 2.0 + +ParticleSystem { + id: particleSystem + function explode(x,y) { + fireEmitter.burst(100,x,y); + } + + Emitter { + id: emitter + group: "bears" + width: parent.width + emitRate: 1 + NumberAnimation on emitRate { + id: goFaster + from: 1 + to: 16 + running: particleSystem.running + loops: 1 + duration: 60000 * 5 + easing.type: Easing.Linear + } + lifeSpan: 4000 + 800*(16-emitRate) + maximumEmitted: 128 + size: 64 + speed: PointDirection{ y: 40 + 10 * emitter.emitRate } + } + + Emitter { + id: fireEmitter + enabled: false + maximumEmitted: 6000 + group: "flame" + emitRate: 1000 + size: 16 + endSize: 8 + speed: CumulativeDirection { AngleDirection {angleVariation: 180; magnitudeVariation: 120;} PointDirection { y: -60 }} + lifeSpan: 400 + } + Emitter { + id: heartEmitter + enabled: false + maximumEmitted: 6000 + group: "hearts" + emitRate: 1000 + size: 16 + endSize: 8 + speed: AngleDirection {angleVariation: 180; magnitudeVariation: 180;} + lifeSpan: 600 + } + Emitter { + id: bloodEmitter + enabled: false + maximumEmitted: 6000 + group: "blood" + emitRate: 1000 + size: 16 + endSize: 8 + speed: CumulativeDirection { AngleDirection {angleVariation: 180; magnitudeVariation: 80;} PointDirection { y: 40 }} + lifeSpan: 600 + } + + Affector { + width: parent.width + height: 64 + once: true + y: parent.height - 32 + groups: "bears" + onAffectParticles: { + for (var i=0;i= 200) + return ListView.view.width / Math.floor(ListView.view.width / 200.0); + else + return 200; + } + + height: { + if (ListView.view && ListView.view.height >= 240) + return ListView.view.height; + else + return 240; + } + + property alias city: cityLabel.text + property int hours + property int minutes + property int seconds + property real shift + property bool night: false + property bool internationalTime: true //Unset for local time + + function timeChanged() { + var date = new Date; + hours = internationalTime ? date.getUTCHours() + Math.floor(clock.shift) : date.getHours() + night = ( hours < 7 || hours > 19 ) + minutes = internationalTime ? date.getUTCMinutes() + ((clock.shift % 1) * 60) : date.getMinutes() + seconds = date.getUTCSeconds(); + } + + Timer { + interval: 100; running: true; repeat: true; + onTriggered: clock.timeChanged() + } + + Item { + anchors.centerIn: parent + width: 200; height: 240 + + Image { id: background; source: "clock.png"; visible: clock.night == false } + Image { source: "clock-night.png"; visible: clock.night == true } + + + Image { + x: 92.5; y: 27 + source: "hour.png" + smooth: true + transform: Rotation { + id: hourRotation + origin.x: 7.5; origin.y: 73; + angle: (clock.hours * 30) + (clock.minutes * 0.5) + Behavior on angle { + SpringAnimation { spring: 2; damping: 0.2; modulus: 360 } + } + } + } + + Image { + x: 93.5; y: 17 + source: "minute.png" + smooth: true + transform: Rotation { + id: minuteRotation + origin.x: 6.5; origin.y: 83; + angle: clock.minutes * 6 + Behavior on angle { + SpringAnimation { spring: 2; damping: 0.2; modulus: 360 } + } + } + } + + Image { + x: 97.5; y: 20 + source: "second.png" + smooth: true + transform: Rotation { + id: secondRotation + origin.x: 2.5; origin.y: 80; + angle: clock.seconds * 6 + Behavior on angle { + SpringAnimation { spring: 2; damping: 0.2; modulus: 360 } + } + } + } + + Image { + anchors.centerIn: background; source: "center.png" + } + + Text { + id: cityLabel + y: 210; anchors.horizontalCenter: parent.horizontalCenter + color: "white" + font.family: "Helvetica" + font.bold: true; font.pixelSize: 16 + style: Text.Raised; styleColor: "black" + } + } +} diff --git a/examples/qml/toys/clocks/content/QuitButton.qml b/examples/qml/toys/clocks/content/QuitButton.qml new file mode 100644 index 0000000000..702b892d23 --- /dev/null +++ b/examples/qml/toys/clocks/content/QuitButton.qml @@ -0,0 +1,52 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +Image { + source: "quit.png" + scale: quitMouse.pressed ? 0.8 : 1.0 + smooth: quitMouse.pressed + MouseArea { + id: quitMouse + anchors.fill: parent + anchors.margins: -10 + onClicked: Qt.quit() + } +} diff --git a/examples/qml/toys/clocks/content/arrow.png b/examples/qml/toys/clocks/content/arrow.png new file mode 100644 index 0000000000..e437312217 Binary files /dev/null and b/examples/qml/toys/clocks/content/arrow.png differ diff --git a/examples/qml/toys/clocks/content/background.png b/examples/qml/toys/clocks/content/background.png new file mode 100644 index 0000000000..a885950862 Binary files /dev/null and b/examples/qml/toys/clocks/content/background.png differ diff --git a/examples/qml/toys/clocks/content/center.png b/examples/qml/toys/clocks/content/center.png new file mode 100644 index 0000000000..7fbd802a44 Binary files /dev/null and b/examples/qml/toys/clocks/content/center.png differ diff --git a/examples/qml/toys/clocks/content/clock-night.png b/examples/qml/toys/clocks/content/clock-night.png new file mode 100644 index 0000000000..cc7151a397 Binary files /dev/null and b/examples/qml/toys/clocks/content/clock-night.png differ diff --git a/examples/qml/toys/clocks/content/clock.png b/examples/qml/toys/clocks/content/clock.png new file mode 100644 index 0000000000..462edacc0e Binary files /dev/null and b/examples/qml/toys/clocks/content/clock.png differ diff --git a/examples/qml/toys/clocks/content/hour.png b/examples/qml/toys/clocks/content/hour.png new file mode 100644 index 0000000000..f8061a1235 Binary files /dev/null and b/examples/qml/toys/clocks/content/hour.png differ diff --git a/examples/qml/toys/clocks/content/minute.png b/examples/qml/toys/clocks/content/minute.png new file mode 100644 index 0000000000..1297ec7c2b Binary files /dev/null and b/examples/qml/toys/clocks/content/minute.png differ diff --git a/examples/qml/toys/clocks/content/quit.png b/examples/qml/toys/clocks/content/quit.png new file mode 100644 index 0000000000..b822057d4e Binary files /dev/null and b/examples/qml/toys/clocks/content/quit.png differ diff --git a/examples/qml/toys/clocks/content/second.png b/examples/qml/toys/clocks/content/second.png new file mode 100644 index 0000000000..4aa9fb5e8e Binary files /dev/null and b/examples/qml/toys/clocks/content/second.png differ diff --git a/examples/qml/toys/corkboards/content/Day.qml b/examples/qml/toys/corkboards/content/Day.qml new file mode 100644 index 0000000000..7fe625c305 --- /dev/null +++ b/examples/qml/toys/corkboards/content/Day.qml @@ -0,0 +1,153 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Component { + Item { + property variant stickies + + id: page + width: ListView.view.width+40; height: ListView.view.height + + + Image { + source: "cork.jpg" + width: page.ListView.view.width + height: page.ListView.view.height + fillMode: Image.PreserveAspectCrop + clip: true + } + + MouseArea { + anchors.fill: parent + onClicked: page.focus = false; + } + + Text { + text: name; x: 15; y: 8; height: 40; width: 370 + font.pixelSize: 18; font.bold: true; color: "white" + style: Text.Outline; styleColor: "black" + } + + Repeater { + model: notes + Item { + id: stickyPage + + property int randomX: Math.random() * (page.ListView.view.width-0.5*stickyImage.width) +100 + property int randomY: Math.random() * (page.ListView.view.height-0.5*stickyImage.height) +50 + + x: randomX; y: randomY + + rotation: -flickable.horizontalVelocity / 100; + Behavior on rotation { + SpringAnimation { spring: 2.0; damping: 0.15 } + } + + Item { + id: sticky + scale: 0.7 + + Image { + id: stickyImage + x: 8 + -width * 0.6 / 2; y: -20 + source: "note-yellow.png" + scale: 0.6; transformOrigin: Item.TopLeft + smooth: true + } + + TextEdit { + id: myText + x: -104; y: 36; width: 215; height: 200 + smooth: true + font.pixelSize: 24 + readOnly: false + rotation: -8 + text: noteText + } + + Item { + x: stickyImage.x; y: -20 + width: stickyImage.width * stickyImage.scale + height: stickyImage.height * stickyImage.scale + + MouseArea { + id: mouse + anchors.fill: parent + drag.target: stickyPage + drag.axis: Drag.XandYAxis + drag.minimumY: 0 + drag.maximumY: page.height - 80 + drag.minimumX: 100 + drag.maximumX: page.width - 140 + onClicked: { myText.focus = true; myText.openSoftwareInputPanel(); } + } + } + } + + Image { + x: -width / 2; y: -height * 0.5 / 2 + source: "tack.png" + scale: 0.7; transformOrigin: Item.TopLeft + } + + states: State { + name: "pressed" + when: mouse.pressed + PropertyChanges { target: sticky; rotation: 8; scale: 1 } + PropertyChanges { target: page; z: 8 } + } + + transitions: Transition { + NumberAnimation { properties: "rotation,scale"; duration: 200 } + } + } + } + } +} + + + + + + + + diff --git a/examples/qml/toys/corkboards/content/cork.jpg b/examples/qml/toys/corkboards/content/cork.jpg new file mode 100644 index 0000000000..160bc002bf Binary files /dev/null and b/examples/qml/toys/corkboards/content/cork.jpg differ diff --git a/examples/qml/toys/corkboards/content/note-yellow.png b/examples/qml/toys/corkboards/content/note-yellow.png new file mode 100644 index 0000000000..8ddecc8b03 Binary files /dev/null and b/examples/qml/toys/corkboards/content/note-yellow.png differ diff --git a/examples/qml/toys/corkboards/content/tack.png b/examples/qml/toys/corkboards/content/tack.png new file mode 100644 index 0000000000..cef2d1cd23 Binary files /dev/null and b/examples/qml/toys/corkboards/content/tack.png differ diff --git a/examples/qml/toys/corkboards/corkboards.qml b/examples/qml/toys/corkboards/corkboards.qml new file mode 100644 index 0000000000..dc3aa6b378 --- /dev/null +++ b/examples/qml/toys/corkboards/corkboards.qml @@ -0,0 +1,116 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import "content" + +Rectangle { + width: 800; height: 480 + color: "#464646" + + ListModel { + id: list + + ListElement { + name: "Sunday" + notes: [ + ListElement { noteText: "Lunch" }, + ListElement { noteText: "Birthday Party" } + ] + } + + ListElement { + name: "Monday" + notes: [ + ListElement { noteText: "Pickup kids from\nschool\n4.30pm" }, + ListElement { noteText: "Checkout Qt" }, ListElement { noteText: "Read email" } + ] + } + + ListElement { + name: "Tuesday" + notes: [ + ListElement { noteText: "Walk dog" }, + ListElement { noteText: "Buy newspaper" } + ] + } + + ListElement { + name: "Wednesday" + notes: [ ListElement { noteText: "Cook dinner" } ] + } + + ListElement { + name: "Thursday" + notes: [ + ListElement { noteText: "Meeting\n5.30pm" }, + ListElement { noteText: "Weed garden" } + ] + } + + ListElement { + name: "Friday" + notes: [ + ListElement { noteText: "More work" }, + ListElement { noteText: "Grocery shopping" } + ] + } + + ListElement { + name: "Saturday" + notes: [ + ListElement { noteText: "Drink" }, + ListElement { noteText: "Download Qt\nPlay with QML" } + ] + } + } + + ListView { + id: flickable + + anchors.fill: parent + focus: true + highlightRangeMode: ListView.StrictlyEnforceRange + orientation: ListView.Horizontal + snapMode: ListView.SnapOneItem + model: list + delegate: Day { } + } +} diff --git a/examples/qml/toys/dynamicscene/content/Button.qml b/examples/qml/toys/dynamicscene/content/Button.qml new file mode 100644 index 0000000000..014692274a --- /dev/null +++ b/examples/qml/toys/dynamicscene/content/Button.qml @@ -0,0 +1,80 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Rectangle { + id: container + + property variant text + signal clicked + + height: text.height + 10; width: text.width + 20 + border.width: 1 + radius: 4 + smooth: true + + gradient: Gradient { + GradientStop { + position: 0.0 + color: !mouseArea.pressed ? activePalette.light : activePalette.button + } + GradientStop { + position: 1.0 + color: !mouseArea.pressed ? activePalette.button : activePalette.dark + } + } + + SystemPalette { id: activePalette } + + MouseArea { + id: mouseArea + anchors.fill: parent + onClicked: container.clicked() + } + + Text { + id: text + anchors.centerIn:parent + font.pointSize: 10 + text: parent.text + color: activePalette.buttonText + } +} diff --git a/examples/qml/toys/dynamicscene/content/GenericSceneItem.qml b/examples/qml/toys/dynamicscene/content/GenericSceneItem.qml new file mode 100644 index 0000000000..0408aa87fb --- /dev/null +++ b/examples/qml/toys/dynamicscene/content/GenericSceneItem.qml @@ -0,0 +1,49 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Image { + property bool created: false + property string image + + source: image + +} diff --git a/examples/qml/toys/dynamicscene/content/PaletteItem.qml b/examples/qml/toys/dynamicscene/content/PaletteItem.qml new file mode 100644 index 0000000000..e993f89989 --- /dev/null +++ b/examples/qml/toys/dynamicscene/content/PaletteItem.qml @@ -0,0 +1,59 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import "itemCreation.js" as Code + +Image { + id: paletteItem + + property string componentFile + property string image + + source: image + + MouseArea { + anchors.fill: parent + + onPressed: Code.startDrag(mouse); + onPositionChanged: Code.continueDrag(mouse); + onReleased: Code.endDrag(mouse); + } +} diff --git a/examples/qml/toys/dynamicscene/content/PerspectiveItem.qml b/examples/qml/toys/dynamicscene/content/PerspectiveItem.qml new file mode 100644 index 0000000000..f651369452 --- /dev/null +++ b/examples/qml/toys/dynamicscene/content/PerspectiveItem.qml @@ -0,0 +1,65 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Image { + id: rootItem + + property bool created: false + property string image + + property double scaledBottom: y + (height + height*scale) / 2 + property bool onLand: scaledBottom > (window.height / 2 + window.centerOffset) + + source: image + opacity: onLand ? 1 : 0.25 + scale: Math.max((y + height - 250) * 0.01, 0.3) + smooth: true + + onCreatedChanged: { + if (created && !onLand) + rootItem.destroy(); + else + z = scaledBottom; + } + + onYChanged: z = scaledBottom; +} diff --git a/examples/qml/toys/dynamicscene/content/Sun.qml b/examples/qml/toys/dynamicscene/content/Sun.qml new file mode 100644 index 0000000000..b84516eecc --- /dev/null +++ b/examples/qml/toys/dynamicscene/content/Sun.qml @@ -0,0 +1,78 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Image { + id: sun + + property bool created: false + property string image: "images/sun.png" + + source: image + + // once item is created, start moving offscreen + NumberAnimation on y { + to: (window.height / 2) + window.centerOffset + running: created + onRunningChanged: { + if (running) + duration = (window.height + window.centerOffset - sun.y) * 10; + else + state = "OffScreen" + } + } + + states: State { + name: "OffScreen" + StateChangeScript { + script: { sun.created = false; sun.destroy() } + } + } + + onCreatedChanged: { + if (created) { + sun.z = 1; // above the sky but below the ground layer + window.activeSuns++; + } else { + window.activeSuns--; + } + } +} diff --git a/examples/qml/toys/dynamicscene/content/images/NOTE b/examples/qml/toys/dynamicscene/content/images/NOTE new file mode 100644 index 0000000000..fcd87f9132 --- /dev/null +++ b/examples/qml/toys/dynamicscene/content/images/NOTE @@ -0,0 +1 @@ +Images (except star.png) are from the KDE project. diff --git a/examples/qml/toys/dynamicscene/content/images/face-smile.png b/examples/qml/toys/dynamicscene/content/images/face-smile.png new file mode 100644 index 0000000000..3d66d72578 Binary files /dev/null and b/examples/qml/toys/dynamicscene/content/images/face-smile.png differ diff --git a/examples/qml/toys/dynamicscene/content/images/moon.png b/examples/qml/toys/dynamicscene/content/images/moon.png new file mode 100644 index 0000000000..1c0d6066a8 Binary files /dev/null and b/examples/qml/toys/dynamicscene/content/images/moon.png differ diff --git a/examples/qml/toys/dynamicscene/content/images/rabbit_brown.png b/examples/qml/toys/dynamicscene/content/images/rabbit_brown.png new file mode 100644 index 0000000000..ebfdeed332 Binary files /dev/null and b/examples/qml/toys/dynamicscene/content/images/rabbit_brown.png differ diff --git a/examples/qml/toys/dynamicscene/content/images/rabbit_bw.png b/examples/qml/toys/dynamicscene/content/images/rabbit_bw.png new file mode 100644 index 0000000000..7bff9b92ca Binary files /dev/null and b/examples/qml/toys/dynamicscene/content/images/rabbit_bw.png differ diff --git a/examples/qml/toys/dynamicscene/content/images/star.png b/examples/qml/toys/dynamicscene/content/images/star.png new file mode 100644 index 0000000000..27ef924267 Binary files /dev/null and b/examples/qml/toys/dynamicscene/content/images/star.png differ diff --git a/examples/qml/toys/dynamicscene/content/images/sun.png b/examples/qml/toys/dynamicscene/content/images/sun.png new file mode 100644 index 0000000000..7713ca5ce7 Binary files /dev/null and b/examples/qml/toys/dynamicscene/content/images/sun.png differ diff --git a/examples/qml/toys/dynamicscene/content/images/tree_s.png b/examples/qml/toys/dynamicscene/content/images/tree_s.png new file mode 100644 index 0000000000..6eac35a729 Binary files /dev/null and b/examples/qml/toys/dynamicscene/content/images/tree_s.png differ diff --git a/examples/qml/toys/dynamicscene/content/itemCreation.js b/examples/qml/toys/dynamicscene/content/itemCreation.js new file mode 100644 index 0000000000..40f5415f9f --- /dev/null +++ b/examples/qml/toys/dynamicscene/content/itemCreation.js @@ -0,0 +1,62 @@ +var itemComponent = null; +var draggedItem = null; +var startingMouse; +var posnInWindow; + +function startDrag(mouse) +{ + posnInWindow = paletteItem.mapToItem(window, 0, 0); + startingMouse = { x: mouse.x, y: mouse.y } + loadComponent(); +} + +//Creation is split into two functions due to an asynchronous wait while +//possible external files are loaded. + +function loadComponent() { + if (itemComponent != null) { // component has been previously loaded + createItem(); + return; + } + + itemComponent = Qt.createComponent(paletteItem.componentFile); + if (itemComponent.status == Component.Loading) //Depending on the content, it can be ready or error immediately + component.statusChanged.connect(createItem); + else + createItem(); +} + +function createItem() { + if (itemComponent.status == Component.Ready && draggedItem == null) { + draggedItem = itemComponent.createObject(window, {"image": paletteItem.image, "x": posnInWindow.x, "y": posnInWindow.y, "z": 3}); + // make sure created item is above the ground layer + } else if (itemComponent.status == Component.Error) { + draggedItem = null; + console.log("error creating component"); + console.log(itemComponent.errorString()); + } +} + +function continueDrag(mouse) +{ + if (draggedItem == null) + return; + + draggedItem.x = mouse.x + posnInWindow.x - startingMouse.x; + draggedItem.y = mouse.y + posnInWindow.y - startingMouse.y; +} + +function endDrag(mouse) +{ + if (draggedItem == null) + return; + + if (draggedItem.y < toolbox.height) { //Don't drop it in the toolbox + draggedItem.destroy(); + draggedItem = null; + } else { + draggedItem.created = true; + draggedItem = null; + } +} + diff --git a/examples/qml/toys/dynamicscene/dynamicscene.qml b/examples/qml/toys/dynamicscene/dynamicscene.qml new file mode 100644 index 0000000000..e64eb0fd0f --- /dev/null +++ b/examples/qml/toys/dynamicscene/dynamicscene.qml @@ -0,0 +1,275 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import QtQuick.Particles 2.0 +import "content" + +Item { + id: window + + property int activeSuns: 0 + property int centerOffset: 72 + + height: 480; width: 360 + + + MouseArea { + anchors.fill: parent + onClicked: window.focus = false; + } + + //This is the message box that pops up when there's an error + Rectangle { + id: dialog + + opacity: 0 + anchors.centerIn: parent + width: dialogText.width + 6; height: dialogText.height + 6 + border.color: 'black' + color: 'lightsteelblue' + z: 65535 //Arbitrary number chosen to be above all the items, including the scaled perspective ones. + + function show(str){ + dialogText.text = str; + dialogAnim.start(); + } + + Text { + id: dialogText + x: 3; y: 3 + font.pixelSize: 14 + } + + SequentialAnimation { + id: dialogAnim + NumberAnimation { target: dialog; property:"opacity"; to: 1; duration: 1000 } + PauseAnimation { duration: 5000 } + NumberAnimation { target: dialog; property:"opacity"; to: 0; duration: 1000 } + } + } + + Item { + id: scene + anchors { top: sky.top; bottom: ground.bottom; left: parent.left; right: parent.right} + z: 10 + } + + // sky + Rectangle { + id: sky + anchors { left: parent.left; top: toolbox.bottom; right: parent.right; bottomMargin: -centerOffset; bottom: parent.verticalCenter } + gradient: Gradient { + GradientStop { id: gradientStopA; position: 0.0; color: "#0E1533" } + GradientStop { id: gradientStopB; position: 1.0; color: "#437284" } + } + } + + // stars (when there's no sun) + ParticleSystem { + id: particlesystem + anchors.fill: sky + + ImageParticle { + id: stars + source: "content/images/star.png" + groups: ["stars"] + opacity: .5 + } + + Emitter { + id: starsemitter + anchors.fill: parent + emitRate: parent.width / 50 + lifeSpan: 5000 + group: "stars" + } + } + + // ground + Rectangle { + id: ground + z: 2 // just above the sun so that the sun can set behind it + anchors { left: parent.left; top: parent.verticalCenter; topMargin: centerOffset; right: parent.right; bottom: parent.bottom } + gradient: Gradient { + GradientStop { position: 0.0; color: "ForestGreen" } + GradientStop { position: 1.0; color: "DarkGreen" } + } + } + + SystemPalette { id: activePalette } + + // right-hand panel + Rectangle { + id: toolbox + + height: centerOffset * 2 + color: activePalette.window + anchors { right: parent.right; top: parent.top; left: parent.left} + + Column { + anchors.centerIn: parent + spacing: 8 + + Text { text: "Drag an item into the scene." } + + Rectangle { + width: palette.width + 10; height: palette.height + 10 + border.color: "black" + + Row { + id: palette + anchors.centerIn: parent + spacing: 8 + + PaletteItem { + anchors.verticalCenter: parent.verticalCenter + componentFile: "Sun.qml" + source: "content/images/sun.png" + image: "images/sun.png" + } + PaletteItem { + anchors.verticalCenter: parent.verticalCenter + componentFile: "GenericSceneItem.qml" + source: "content/images/moon.png" + image: "images/moon.png" + } + PaletteItem { + anchors.verticalCenter: parent.verticalCenter + componentFile: "PerspectiveItem.qml" + source: "content/images/tree_s.png" + image: "images/tree_s.png" + } + PaletteItem { + anchors.verticalCenter: parent.verticalCenter + componentFile: "PerspectiveItem.qml" + source: "content/images/rabbit_brown.png" + image: "images/rabbit_brown.png" + } + PaletteItem { + anchors.verticalCenter: parent.verticalCenter + componentFile: "PerspectiveItem.qml" + source: "content/images/rabbit_bw.png" + image: "images/rabbit_bw.png" + } + } + } + + Text { text: "Active Suns: " + activeSuns } + } + } + + //Popup toolbox down the bottom + Rectangle { + id: popupToolbox + z: 1000 + width: parent.width + height: popupColumn.height + 16 + color: activePalette.window + + property bool poppedUp: false + property int downY: window.height - (createButton.height + 16) + property int upY: window.height - (popupColumn.height + 16) + y: poppedUp ? upY : downY + Behavior on y { NumberAnimation {}} + + Column { + id: popupColumn + y: 8 + anchors.centerIn: parent + spacing: 8 + + Row { + height: createButton.height + spacing: 8 + Text { text: "Custom QML:"; anchors.verticalCenter: parent.verticalCenter } + Button { + id: popupButton + text: popupToolbox.poppedUp ? "Hide" : "Show" + onClicked: popupToolbox.poppedUp = !popupToolbox.poppedUp + } + Button { + id: createButton + text: "Create" + onClicked: { + try { + Qt.createQmlObject(qmlText.text, scene, 'CustomObject'); + } catch(err) { + dialog.show('Error on line ' + err.qmlErrors[0].lineNumber + '\n' + err.qmlErrors[0].message); + } + } + } + + } + + Rectangle { + width: 360; height: 240 + + TextEdit { + id: qmlText + anchors.fill: parent; anchors.margins: 5 + readOnly: false + font.pixelSize: 14 + selectByMouse: true + wrapMode: TextEdit.WordWrap + + text: "import QtQuick 2.0\nImage {\n id: smile\n x: 360 * Math.random()\n y: 180 * Math.random() \n source: 'content/images/face-smile.png'\n NumberAnimation on opacity { \n to: 0; duration: 1500\n }\n Component.onCompleted: smile.destroy(1500);\n}" + } + } + } + } + + //Day state, for when a sun is added to the scene + states: State { + name: "Day" + when: window.activeSuns > 0 + + PropertyChanges { target: gradientStopA; color: "DeepSkyBlue" } + PropertyChanges { target: gradientStopB; color: "SkyBlue" } + PropertyChanges { target: stars; opacity: 0 } + } + + //! [top-level transitions] + transitions: Transition { + PropertyAnimation { duration: 3000 } + ColorAnimation { duration: 3000 } + } + //! [top-level transitions] +} diff --git a/examples/qml/toys/tic-tac-toe/content/Button.qml b/examples/qml/toys/tic-tac-toe/content/Button.qml new file mode 100644 index 0000000000..6dd141f838 --- /dev/null +++ b/examples/qml/toys/tic-tac-toe/content/Button.qml @@ -0,0 +1,79 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Rectangle { + id: container + + property string text + property bool pressed: false + + signal clicked + + width: buttonLabel.width + 20; height: buttonLabel.height + 6 + border { width: 1; color: Qt.darker(container.color) } + radius: 8 + color: "lightgray" + smooth: true + + gradient: Gradient { + GradientStop { + position: 0.0 + color: container.pressed ? "darkgray" : "white" + } + GradientStop { + position: 1.0 + color: container.color + } + } + + MouseArea { + anchors.fill: parent + onClicked: container.clicked() + } + + Text { + id: buttonLabel + anchors.centerIn: container + text: container.text + font.pixelSize: 14 + } +} diff --git a/examples/qml/toys/tic-tac-toe/content/TicTac.qml b/examples/qml/toys/tic-tac-toe/content/TicTac.qml new file mode 100644 index 0000000000..e74bc6bcda --- /dev/null +++ b/examples/qml/toys/tic-tac-toe/content/TicTac.qml @@ -0,0 +1,60 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Item { + signal clicked + + states: [ + State { name: "X"; PropertyChanges { target: image; source: "pics/x.png" } }, + State { name: "O"; PropertyChanges { target: image; source: "pics/o.png" } } + ] + + Image { + id: image + anchors.centerIn: parent + } + + MouseArea { + anchors.fill: parent + onClicked: parent.clicked() + } +} diff --git a/examples/qml/toys/tic-tac-toe/content/pics/board.png b/examples/qml/toys/tic-tac-toe/content/pics/board.png new file mode 100644 index 0000000000..7e5b7ba27c Binary files /dev/null and b/examples/qml/toys/tic-tac-toe/content/pics/board.png differ diff --git a/examples/qml/toys/tic-tac-toe/content/pics/o.png b/examples/qml/toys/tic-tac-toe/content/pics/o.png new file mode 100644 index 0000000000..abc7ee020b Binary files /dev/null and b/examples/qml/toys/tic-tac-toe/content/pics/o.png differ diff --git a/examples/qml/toys/tic-tac-toe/content/pics/x.png b/examples/qml/toys/tic-tac-toe/content/pics/x.png new file mode 100644 index 0000000000..ddc65c83b8 Binary files /dev/null and b/examples/qml/toys/tic-tac-toe/content/pics/x.png differ diff --git a/examples/qml/toys/tic-tac-toe/content/tic-tac-toe.js b/examples/qml/toys/tic-tac-toe/content/tic-tac-toe.js new file mode 100644 index 0000000000..5a166b750f --- /dev/null +++ b/examples/qml/toys/tic-tac-toe/content/tic-tac-toe.js @@ -0,0 +1,149 @@ +function winner(board) +{ + for (var i=0; i<3; ++i) { + if (board.children[i].state != "" + && board.children[i].state == board.children[i+3].state + && board.children[i].state == board.children[i+6].state) + return true + + if (board.children[i*3].state != "" + && board.children[i*3].state == board.children[i*3+1].state + && board.children[i*3].state == board.children[i*3+2].state) + return true + } + + if (board.children[0].state != "" + && board.children[0].state == board.children[4].state != "" + && board.children[0].state == board.children[8].state != "") + return true + + if (board.children[2].state != "" + && board.children[2].state == board.children[4].state != "" + && board.children[2].state == board.children[6].state != "") + return true + + return false +} + +function restartGame() +{ + game.running = true + + for (var i=0; i<9; ++i) + board.children[i].state = "" +} + +function makeMove(pos, player) +{ + board.children[pos].state = player + if (winner(board)) { + gameFinished(player + " wins") + return true + } else { + return false + } +} + +function canPlayAtPos(pos) +{ + return board.children[pos].state == "" +} + +function computerTurn() +{ + var r = Math.random(); + if (r < game.difficulty) + smartAI(); + else + randomAI(); +} + +function smartAI() +{ + function boardCopy(a) { + var ret = new Object; + ret.children = new Array(9); + for (var i = 0; i<9; i++) { + ret.children[i] = new Object; + ret.children[i].state = a.children[i].state; + } + return ret; + } + + for (var i=0; i<9; i++) { + var simpleBoard = boardCopy(board); + if (canPlayAtPos(i)) { + simpleBoard.children[i].state = "O"; + if (winner(simpleBoard)) { + makeMove(i, "O") + return + } + } + } + for (var i=0; i<9; i++) { + var simpleBoard = boardCopy(board); + if (canPlayAtPos(i)) { + simpleBoard.children[i].state = "X"; + if (winner(simpleBoard)) { + makeMove(i, "O") + return + } + } + } + + function thwart(a,b,c) { //If they are at a, try b or c + if (board.children[a].state == "X") { + if (canPlayAtPos(b)) { + makeMove(b, "O") + return true + } else if (canPlayAtPos(c)) { + makeMove(c, "O") + return true + } + } + return false; + } + + if (thwart(4,0,2)) return; + if (thwart(0,4,3)) return; + if (thwart(2,4,1)) return; + if (thwart(6,4,7)) return; + if (thwart(8,4,5)) return; + if (thwart(1,4,2)) return; + if (thwart(3,4,0)) return; + if (thwart(5,4,8)) return; + if (thwart(7,4,6)) return; + + for (var i =0; i<9; i++) { + if (canPlayAtPos(i)) { + makeMove(i, "O") + return + } + } + restartGame(); +} + +function randomAI() +{ + var unfilledPosns = new Array(); + + for (var i=0; i<9; ++i) { + if (canPlayAtPos(i)) + unfilledPosns.push(i); + } + + if (unfilledPosns.length == 0) { + restartGame(); + } else { + var choice = unfilledPosns[Math.floor(Math.random() * unfilledPosns.length)]; + makeMove(choice, "O"); + } +} + +function gameFinished(message) +{ + messageDisplay.text = message + messageDisplay.visible = true + game.running = false +} + diff --git a/examples/qml/toys/tic-tac-toe/tic-tac-toe.qml b/examples/qml/toys/tic-tac-toe/tic-tac-toe.qml new file mode 100644 index 0000000000..8d15233eaa --- /dev/null +++ b/examples/qml/toys/tic-tac-toe/tic-tac-toe.qml @@ -0,0 +1,123 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import "content" +import "content/tic-tac-toe.js" as Logic + +Rectangle { + id: game + + property bool running: true + property real difficulty: 1.0 //chance it will actually think + + width: display.width; height: display.height + 10 + + Image { + id: boardImage + source: "content/pics/board.png" + } + + + Column { + id: display + + Grid { + id: board + width: boardImage.width; height: boardImage.height + columns: 3 + + Repeater { + model: 9 + + TicTac { + width: board.width/3 + height: board.height/3 + + onClicked: { + if (game.running && Logic.canPlayAtPos(index)) { + if (!Logic.makeMove(index, "X")) + Logic.computerTurn(); + } + } + } + } + } + + Row { + spacing: 4 + anchors.horizontalCenter: parent.horizontalCenter + + Button { + text: "Hard" + pressed: game.difficulty == 1.0 + onClicked: { game.difficulty = 1.0 } + } + Button { + text: "Moderate" + pressed: game.difficulty == 0.8 + onClicked: { game.difficulty = 0.8 } + } + Button { + text: "Easy" + pressed: game.difficulty == 0.2 + onClicked: { game.difficulty = 0.2 } + } + } + } + + + Text { + id: messageDisplay + anchors.centerIn: parent + color: "blue" + style: Text.Outline; styleColor: "white" + font.pixelSize: 50; font.bold: true + visible: false + + Timer { + running: messageDisplay.visible + onTriggered: { + messageDisplay.visible = false; + Logic.restartGame(); + } + } + } +} diff --git a/examples/qml/toys/tvtennis/tvtennis.qml b/examples/qml/toys/tvtennis/tvtennis.qml new file mode 100644 index 0000000000..63866e3ce6 --- /dev/null +++ b/examples/qml/toys/tvtennis/tvtennis.qml @@ -0,0 +1,109 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Rectangle { + id: page + width: 640; height: 480 + color: "Black" + + // Make a ball to bounce + Rectangle { + id: ball + + // Add a property for the target y coordinate + property variant direction : "right" + + x: 20; width: 20; height: 20; z: 1 + color: "Lime" + + // Move the ball to the right and back to the left repeatedly + SequentialAnimation on x { + loops: Animation.Infinite + NumberAnimation { to: page.width - 40; duration: 2000 } + PropertyAction { target: ball; property: "direction"; value: "left" } + NumberAnimation { to: 20; duration: 2000 } + PropertyAction { target: ball; property: "direction"; value: "right" } + } + + // Make y move with a velocity of 200 + Behavior on y { SpringAnimation{ velocity: 200; } + } + + Component.onCompleted: y = page.height-10; // start the ball motion + + // Detect the ball hitting the top or bottom of the view and bounce it + onYChanged: { + if (y <= 0) { + y = page.height - 20; + } else if (y >= page.height - 20) { + y = 0; + } + } + } + + // Place bats to the left and right of the view, following the y + // coordinates of the ball. + Rectangle { + id: leftBat + color: "Lime" + x: 2; width: 20; height: 90 + y: ball.direction == 'left' ? ball.y - 45 : page.height/2 -45; + Behavior on y { SpringAnimation{ velocity: 300 } } + } + Rectangle { + id: rightBat + color: "Lime" + x: page.width - 22; width: 20; height: 90 + y: ball.direction == 'right' ? ball.y - 45 : page.height/2 -45; + Behavior on y { SpringAnimation{ velocity: 300 } } + } + + // The rest, to make it look realistic, if neither ever scores... + Rectangle { color: "Lime"; x: page.width/2-80; y: 0; width: 40; height: 60 } + Rectangle { color: "Black"; x: page.width/2-70; y: 10; width: 20; height: 40 } + Rectangle { color: "Lime"; x: page.width/2+40; y: 0; width: 40; height: 60 } + Rectangle { color: "Black"; x: page.width/2+50; y: 10; width: 20; height: 40 } + Repeater { + model: page.height / 20 + Rectangle { color: "Lime"; x: page.width/2-5; y: index * 20; width: 10; height: 10 } + } +} diff --git a/examples/qml/tutorials/dynamicview/dynamicview1/PetsModel.qml b/examples/qml/tutorials/dynamicview/dynamicview1/PetsModel.qml new file mode 100644 index 0000000000..f07613c968 --- /dev/null +++ b/examples/qml/tutorials/dynamicview/dynamicview1/PetsModel.qml @@ -0,0 +1,102 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +//![0] +import QtQuick 2.0 + +ListModel { + ListElement { + name: "Polly" + type: "Parrot" + age: 12 + size: "Small" + } + ListElement { + name: "Penny" + type: "Turtle" + age: 4 + size: "Small" + } +//![0] + ListElement { + name: "Warren" + type: "Rabbit" + age: 2 + size: "Small" + } + ListElement { + name: "Spot" + type: "Dog" + age: 9 + size: "Medium" + } + ListElement { + name: "Schrödinger" + type: "Cat" + age: 2 + size: "Medium" + } + ListElement { + name: "Joey" + type: "Kangaroo" + age: 1 + size: "Medium" + } + ListElement { + name: "Kimba" + type: "Bunny" + age: 65 + size: "Large" + } + ListElement { + name: "Rover" + type: "Dog" + age: 5 + size: "Large" + } + ListElement { + name: "Tiny" + type: "Elephant" + age: 15 + size: "Large" + } +//![1] +} +//![1] diff --git a/examples/qml/tutorials/dynamicview/dynamicview1/dynamicview.qml b/examples/qml/tutorials/dynamicview/dynamicview1/dynamicview.qml new file mode 100644 index 0000000000..1a9dd453ce --- /dev/null +++ b/examples/qml/tutorials/dynamicview/dynamicview1/dynamicview.qml @@ -0,0 +1,90 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +//![0] +import QtQuick 2.0 + +Rectangle { + id: root + + width: 300; height: 400 + +//![1] + Component { + id: dragDelegate + + Rectangle { + id: content + + anchors { left: parent.left; right: parent.right } + height: column.implicitHeight + 4 + + border.width: 1 + border.color: "lightsteelblue" + + radius: 2 + + Column { + id: column + anchors { fill: parent; margins: 2 } + + Text { text: 'Name: ' + name } + Text { text: 'Type: ' + type } + Text { text: 'Age: ' + age } + Text { text: 'Size: ' + size } + } + } + } +//![1] +//![2] + ListView { + id: view + + anchors { fill: parent; margins: 2 } + + model: PetsModel {} + delegate: dragDelegate + + spacing: 4 + cacheBuffer: 50 + } +//![2] +} +//![0] diff --git a/examples/qml/tutorials/dynamicview/dynamicview2/PetsModel.qml b/examples/qml/tutorials/dynamicview/dynamicview2/PetsModel.qml new file mode 100644 index 0000000000..4f2087d95e --- /dev/null +++ b/examples/qml/tutorials/dynamicview/dynamicview2/PetsModel.qml @@ -0,0 +1,98 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +ListModel { + ListElement { + name: "Polly" + type: "Parrot" + age: 12 + size: "Small" + } + ListElement { + name: "Penny" + type: "Turtle" + age: 4 + size: "Small" + } + ListElement { + name: "Warren" + type: "Rabbit" + age: 2 + size: "Small" + } + ListElement { + name: "Spot" + type: "Dog" + age: 9 + size: "Medium" + } + ListElement { + name: "Schrödinger" + type: "Cat" + age: 2 + size: "Medium" + } + ListElement { + name: "Joey" + type: "Kangaroo" + age: 1 + size: "Medium" + } + ListElement { + name: "Kimba" + type: "Bunny" + age: 65 + size: "Large" + } + ListElement { + name: "Rover" + type: "Dog" + age: 5 + size: "Large" + } + ListElement { + name: "Tiny" + type: "Elephant" + age: 15 + size: "Large" + } +} diff --git a/examples/qml/tutorials/dynamicview/dynamicview2/dynamicview.qml b/examples/qml/tutorials/dynamicview/dynamicview2/dynamicview.qml new file mode 100644 index 0000000000..9e654a685c --- /dev/null +++ b/examples/qml/tutorials/dynamicview/dynamicview2/dynamicview.qml @@ -0,0 +1,121 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Rectangle { + id: root + + width: 300; height: 400 + +//![0] + Component { + id: dragDelegate + +//![1] + MouseArea { + id: dragArea + + property bool held: false + + anchors { left: parent.left; right: parent.right } + height: content.height + + drag.target: held ? content : undefined + drag.axis: Drag.YAxis + + onPressAndHold: held = true + onReleased: held = false + + Rectangle { + id: content +//![1] + anchors { + horizontalCenter: parent.horizontalCenter + verticalCenter: parent.verticalCenter + } + width: dragArea.width; height: column.implicitHeight + 4 + + border.width: 1 + border.color: "lightsteelblue" +//![3] + color: dragArea.held ? "lightsteelblue" : "white" + Behavior on color { ColorAnimation { duration: 100 } } +//![3] + radius: 2 +//![4] + states: State { + when: dragArea.held + + ParentChange { target: content; parent: root } + AnchorChanges { + target: content + anchors { horizontalCenter: undefined; verticalCenter: undefined } + } + } +//![4] + Column { + id: column + anchors { fill: parent; margins: 2 } + + Text { text: 'Name: ' + name } + Text { text: 'Type: ' + type } + Text { text: 'Age: ' + age } + Text { text: 'Size: ' + size } + } +//![2] + } + } +//![2] + } +//![0] + + ListView { + id: view + + anchors { fill: parent; margins: 2 } + + model: PetsModel {} + delegate: dragDelegate + + spacing: 4 + cacheBuffer: 50 + } +} diff --git a/examples/qml/tutorials/dynamicview/dynamicview3/PetsModel.qml b/examples/qml/tutorials/dynamicview/dynamicview3/PetsModel.qml new file mode 100644 index 0000000000..4f2087d95e --- /dev/null +++ b/examples/qml/tutorials/dynamicview/dynamicview3/PetsModel.qml @@ -0,0 +1,98 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +ListModel { + ListElement { + name: "Polly" + type: "Parrot" + age: 12 + size: "Small" + } + ListElement { + name: "Penny" + type: "Turtle" + age: 4 + size: "Small" + } + ListElement { + name: "Warren" + type: "Rabbit" + age: 2 + size: "Small" + } + ListElement { + name: "Spot" + type: "Dog" + age: 9 + size: "Medium" + } + ListElement { + name: "Schrödinger" + type: "Cat" + age: 2 + size: "Medium" + } + ListElement { + name: "Joey" + type: "Kangaroo" + age: 1 + size: "Medium" + } + ListElement { + name: "Kimba" + type: "Bunny" + age: 65 + size: "Large" + } + ListElement { + name: "Rover" + type: "Dog" + age: 5 + size: "Large" + } + ListElement { + name: "Tiny" + type: "Elephant" + age: 15 + size: "Large" + } +} diff --git a/examples/qml/tutorials/dynamicview/dynamicview3/dynamicview.qml b/examples/qml/tutorials/dynamicview/dynamicview3/dynamicview.qml new file mode 100644 index 0000000000..5a579f78d9 --- /dev/null +++ b/examples/qml/tutorials/dynamicview/dynamicview3/dynamicview.qml @@ -0,0 +1,143 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +//![0] +Rectangle { + id: root + + width: 300; height: 400 + + Component { + id: dragDelegate + + MouseArea { + id: dragArea + + property bool held: false + + anchors { left: parent.left; right: parent.right } + height: content.height + + drag.target: held ? content : undefined + drag.axis: Drag.YAxis + + onPressAndHold: held = true + onReleased: held = false + + Rectangle { + id: content +//![0] + anchors { + horizontalCenter: parent.horizontalCenter + verticalCenter: parent.verticalCenter + } + width: dragArea.width; height: column.implicitHeight + 4 + + border.width: 1 + border.color: "lightsteelblue" + + color: dragArea.held ? "lightsteelblue" : "white" + Behavior on color { ColorAnimation { duration: 100 } } + + radius: 2 +//![1] + Drag.active: dragArea.held + Drag.source: dragArea + Drag.hotSpot.x: width / 2 + Drag.hotSpot.y: height / 2 +//![1] + states: State { + when: dragArea.held + + ParentChange { target: content; parent: root } + AnchorChanges { + target: content + anchors { horizontalCenter: undefined; verticalCenter: undefined } + } + } + + Column { + id: column + anchors { fill: parent; margins: 2 } + + Text { text: 'Name: ' + name } + Text { text: 'Type: ' + type } + Text { text: 'Age: ' + age } + Text { text: 'Size: ' + size } + } +//![2] + } +//![3] + DropArea { + anchors { fill: parent; margins: 10 } + + onEntered: { + visualModel.items.move( + drag.source.VisualDataModel.itemsIndex, + dragArea.VisualDataModel.itemsIndex) + } + } +//![3] + } + } +//![2] +//![4] + VisualDataModel { + id: visualModel + + model: PetsModel {} + delegate: dragDelegate + } + + ListView { + id: view + + anchors { fill: parent; margins: 2 } + + model: visualModel + + spacing: 4 + cacheBuffer: 50 + } +//![4] +//![5] +} +//![5] diff --git a/examples/qml/tutorials/dynamicview/dynamicview4/ListSelector.qml b/examples/qml/tutorials/dynamicview/dynamicview4/ListSelector.qml new file mode 100644 index 0000000000..c6b8287beb --- /dev/null +++ b/examples/qml/tutorials/dynamicview/dynamicview4/ListSelector.qml @@ -0,0 +1,120 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Item { + id: selector + + property alias list: view.model + property alias selectedIndex: view.currentIndex + property alias label: labelText.text + property bool expanded + + width: 100; height: labelText.implicitHeight + 26 + + Rectangle { + anchors { left: parent.left; right: parent.right; bottom: parent.bottom; } + + height: labelText.implicitHeight + 4 + (expanded ? 20 * view.count : 20) + Behavior on height { NumberAnimation { duration: 300 } } + + radius: 2 + border.width: 1 + border.color: "yellow" + color: "yellow" + + MouseArea { + anchors.fill: parent + + onClicked: selector.expanded = !selector.expanded + + Text { + id: labelText + anchors { left: parent.left; top: parent.top; margins: 2 } + } + + Rectangle { + anchors { + left: parent.left; top: labelText.bottom; + right: parent.right; bottom: parent.bottom; + margins: 2 + leftMargin: 10 + } + + radius: 2 + color: "white" + + ListView { + id: view + + anchors.fill: parent + + clip: true + + delegate: Text { + anchors { left: parent.left; right: parent.right } + height: 20 + + verticalAlignment: Text.AlignVCenter + + text: modelData + + MouseArea { + anchors.fill: parent + + onClicked: { + view.currentIndex = index + selector.expanded = !selector.expanded + } + } + } + highlight: Rectangle { + anchors { left: parent.left; right: parent.right } + height: 20 + radius: 2 + + color: "yellow" + } + } + } + } + } +} diff --git a/examples/qml/tutorials/dynamicview/dynamicview4/PetsModel.qml b/examples/qml/tutorials/dynamicview/dynamicview4/PetsModel.qml new file mode 100644 index 0000000000..4f2087d95e --- /dev/null +++ b/examples/qml/tutorials/dynamicview/dynamicview4/PetsModel.qml @@ -0,0 +1,98 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +ListModel { + ListElement { + name: "Polly" + type: "Parrot" + age: 12 + size: "Small" + } + ListElement { + name: "Penny" + type: "Turtle" + age: 4 + size: "Small" + } + ListElement { + name: "Warren" + type: "Rabbit" + age: 2 + size: "Small" + } + ListElement { + name: "Spot" + type: "Dog" + age: 9 + size: "Medium" + } + ListElement { + name: "Schrödinger" + type: "Cat" + age: 2 + size: "Medium" + } + ListElement { + name: "Joey" + type: "Kangaroo" + age: 1 + size: "Medium" + } + ListElement { + name: "Kimba" + type: "Bunny" + age: 65 + size: "Large" + } + ListElement { + name: "Rover" + type: "Dog" + age: 5 + size: "Large" + } + ListElement { + name: "Tiny" + type: "Elephant" + age: 15 + size: "Large" + } +} diff --git a/examples/qml/tutorials/dynamicview/dynamicview4/dynamicview.qml b/examples/qml/tutorials/dynamicview/dynamicview4/dynamicview.qml new file mode 100644 index 0000000000..9bd4e0c438 --- /dev/null +++ b/examples/qml/tutorials/dynamicview/dynamicview4/dynamicview.qml @@ -0,0 +1,219 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Rectangle { + id: root + + width: 300; height: 400 + + Component { + id: dragDelegate + + MouseArea { + id: dragArea + + property bool held: false + + anchors { left: parent.left; right: parent.right } + height: content.height + + enabled: visualModel.sortOrder == visualModel.lessThan.length + + drag.target: held ? content : undefined + drag.axis: Drag.YAxis + + onPressAndHold: held = true + onReleased: held = false + + Rectangle { + id: content + + anchors { + horizontalCenter: parent.horizontalCenter + verticalCenter: parent.verticalCenter + } + width: dragArea.width; height: column.implicitHeight + 4 + + border.width: 1 + border.color: "lightsteelblue" + + color: dragArea.held ? "lightsteelblue" : "white" + Behavior on color { ColorAnimation { duration: 100 } } + + radius: 2 + + Drag.active: dragArea.held + Drag.source: dragArea + Drag.hotSpot.x: width / 2 + Drag.hotSpot.y: height / 2 + + states: State { + when: dragArea.held + + ParentChange { target: content; parent: root } + AnchorChanges { + target: content + anchors { horizontalCenter: undefined; verticalCenter: undefined } + } + } + + Column { + id: column + anchors { fill: parent; margins: 2 } + + Text { text: 'Name: ' + name } + Text { text: 'Type: ' + type } + Text { text: 'Age: ' + age } + Text { text: 'Size: ' + size } + } + } + + DropArea { + anchors { fill: parent; margins: 10 } + + onEntered: { + visualModel.items.move( + drag.source.VisualDataModel.itemsIndex, + dragArea.VisualDataModel.itemsIndex) + } + } + } + } +//![0] + VisualDataModel { + id: visualModel +//![4] + property var lessThan: [ + function(left, right) { return left.name < right.name }, + function(left, right) { return left.type < right.type }, + function(left, right) { return left.age < right.age }, + function(left, right) { + if (left.size == "Small") + return true + else if (right.size == "Small") + return false + else if (left.size == "Medium") + return true + else + return false + } + ] +//![4] +//![6] + + property int sortOrder: orderSelector.selectedIndex + onSortOrderChanged: items.setGroups(0, items.count, "unsorted") + +//![6] +//![3] + function insertPosition(lessThan, item) { + var lower = 0 + var upper = items.count + while (lower < upper) { + var middle = Math.floor(lower + (upper - lower) / 2) + var result = lessThan(item.model, items.get(middle).model); + if (result) { + upper = middle + } else { + lower = middle + 1 + } + } + return lower + } + + function sort(lessThan) { + while (unsortedItems.count > 0) { + var item = unsortedItems.get(0) + var index = insertPosition(lessThan, item) + + item.groups = "items" + items.move(item.itemsIndex, index) + } + } +//![3] + +//![1] + items.includeByDefault: false +//![5] + groups: VisualDataGroup { + id: unsortedItems + name: "unsorted" + + includeByDefault: true +//![1] + onChanged: { + if (visualModel.sortOrder == visualModel.lessThan.length) + setGroups(0, count, "items") + else + visualModel.sort(visualModel.lessThan[visualModel.sortOrder]) + } +//![2] + } +//![2] +//![5] + model: PetsModel {} + delegate: dragDelegate + } +//![0] + ListView { + id: view + + anchors { + left: parent.left; top: parent.top; right: parent.right; bottom: orderSelector.top; + margins: 2 + } + + model: visualModel + + spacing: 4 + cacheBuffer: 50 + } + + ListSelector { + id: orderSelector + + anchors { left: parent.left; right: parent.right; bottom: parent.bottom; margins: 2 } + + label: "Sort By" + list: [ "Name", "Type", "Age", "Size", "Custom" ] + } +} diff --git a/examples/qml/tutorials/extending/chapter1-basics/app.qml b/examples/qml/tutorials/extending/chapter1-basics/app.qml new file mode 100644 index 0000000000..6f0c1d3a23 --- /dev/null +++ b/examples/qml/tutorials/extending/chapter1-basics/app.qml @@ -0,0 +1,60 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +//![0] +import Charts 1.0 +import QtQuick 2.0 + +Item { + width: 300; height: 200 + + PieChart { + id: aPieChart + anchors.centerIn: parent + width: 100; height: 100 + name: "A simple pie chart" + color: "red" + } + + Text { + anchors { bottom: parent.bottom; horizontalCenter: parent.horizontalCenter; bottomMargin: 20 } + text: aPieChart.name + } +} +//![0] diff --git a/examples/qml/tutorials/extending/chapter1-basics/chapter1-basics.pro b/examples/qml/tutorials/extending/chapter1-basics/chapter1-basics.pro new file mode 100644 index 0000000000..8ed66f8b66 --- /dev/null +++ b/examples/qml/tutorials/extending/chapter1-basics/chapter1-basics.pro @@ -0,0 +1,5 @@ +QT += qml quick + +HEADERS += piechart.h +SOURCES += piechart.cpp \ + main.cpp diff --git a/examples/qml/tutorials/extending/chapter1-basics/main.cpp b/examples/qml/tutorials/extending/chapter1-basics/main.cpp new file mode 100644 index 0000000000..ed9e412bd6 --- /dev/null +++ b/examples/qml/tutorials/extending/chapter1-basics/main.cpp @@ -0,0 +1,57 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +//![0] +#include "piechart.h" +#include +#include + +int main(int argc, char *argv[]) +{ + QGuiApplication app(argc, argv); + + qmlRegisterType("Charts", 1, 0, "PieChart"); + + QQuickView view; + view.setResizeMode(QQuickView::SizeRootObjectToView); + view.setSource(QUrl::fromLocalFile("app.qml")); + view.show(); + return app.exec(); +} +//![0] diff --git a/examples/qml/tutorials/extending/chapter1-basics/piechart.cpp b/examples/qml/tutorials/extending/chapter1-basics/piechart.cpp new file mode 100644 index 0000000000..bc81d6a3a0 --- /dev/null +++ b/examples/qml/tutorials/extending/chapter1-basics/piechart.cpp @@ -0,0 +1,79 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include "piechart.h" +#include + +//![0] +PieChart::PieChart(QQuickItem *parent) + : QQuickPaintedItem(parent) +{ +} +//![0] + +QString PieChart::name() const +{ + return m_name; +} + +void PieChart::setName(const QString &name) +{ + m_name = name; +} + +QColor PieChart::color() const +{ + return m_color; +} + +void PieChart::setColor(const QColor &color) +{ + m_color = color; +} + +//![1] +void PieChart::paint(QPainter *painter) +{ + QPen pen(m_color, 2); + painter->setPen(pen); + painter->setRenderHints(QPainter::HighQualityAntialiasing, true); + painter->drawPie(boundingRect(), 90 * 16, 290 * 16); +} +//![1] + diff --git a/examples/qml/tutorials/extending/chapter1-basics/piechart.h b/examples/qml/tutorials/extending/chapter1-basics/piechart.h new file mode 100644 index 0000000000..71a8786e7d --- /dev/null +++ b/examples/qml/tutorials/extending/chapter1-basics/piechart.h @@ -0,0 +1,71 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#ifndef PIECHART_H +#define PIECHART_H + +//![0] +#include +#include + +class PieChart : public QQuickPaintedItem +{ + Q_OBJECT + Q_PROPERTY(QString name READ name WRITE setName) + Q_PROPERTY(QColor color READ color WRITE setColor) + +public: + PieChart(QQuickItem *parent = 0); + + QString name() const; + void setName(const QString &name); + + QColor color() const; + void setColor(const QColor &color); + + void paint(QPainter *painter); + +private: + QString m_name; + QColor m_color; +}; +//![0] + +#endif + diff --git a/examples/qml/tutorials/extending/chapter2-methods/app.qml b/examples/qml/tutorials/extending/chapter2-methods/app.qml new file mode 100644 index 0000000000..eee0933734 --- /dev/null +++ b/examples/qml/tutorials/extending/chapter2-methods/app.qml @@ -0,0 +1,66 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +//![0] +import Charts 1.0 +import QtQuick 2.0 + +Item { + width: 300; height: 200 + + PieChart { + id: aPieChart + anchors.centerIn: parent + width: 100; height: 100 + color: "red" + + onChartCleared: console.log("The chart has been cleared") + } + + MouseArea { + anchors.fill: parent + onClicked: aPieChart.clearChart() + } + + Text { + anchors { bottom: parent.bottom; horizontalCenter: parent.horizontalCenter; bottomMargin: 20 } + text: "Click anywhere to clear the chart" + } +} +//![0] diff --git a/examples/qml/tutorials/extending/chapter2-methods/chapter2-methods.pro b/examples/qml/tutorials/extending/chapter2-methods/chapter2-methods.pro new file mode 100644 index 0000000000..8ed66f8b66 --- /dev/null +++ b/examples/qml/tutorials/extending/chapter2-methods/chapter2-methods.pro @@ -0,0 +1,5 @@ +QT += qml quick + +HEADERS += piechart.h +SOURCES += piechart.cpp \ + main.cpp diff --git a/examples/qml/tutorials/extending/chapter2-methods/main.cpp b/examples/qml/tutorials/extending/chapter2-methods/main.cpp new file mode 100644 index 0000000000..ed9e412bd6 --- /dev/null +++ b/examples/qml/tutorials/extending/chapter2-methods/main.cpp @@ -0,0 +1,57 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +//![0] +#include "piechart.h" +#include +#include + +int main(int argc, char *argv[]) +{ + QGuiApplication app(argc, argv); + + qmlRegisterType("Charts", 1, 0, "PieChart"); + + QQuickView view; + view.setResizeMode(QQuickView::SizeRootObjectToView); + view.setSource(QUrl::fromLocalFile("app.qml")); + view.show(); + return app.exec(); +} +//![0] diff --git a/examples/qml/tutorials/extending/chapter2-methods/piechart.cpp b/examples/qml/tutorials/extending/chapter2-methods/piechart.cpp new file mode 100644 index 0000000000..71be74e943 --- /dev/null +++ b/examples/qml/tutorials/extending/chapter2-methods/piechart.cpp @@ -0,0 +1,84 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include "piechart.h" +#include + +PieChart::PieChart(QQuickItem *parent) + : QQuickPaintedItem(parent) +{ +} + +QString PieChart::name() const +{ + return m_name; +} + +void PieChart::setName(const QString &name) +{ + m_name = name; +} + +QColor PieChart::color() const +{ + return m_color; +} + +void PieChart::setColor(const QColor &color) +{ + m_color = color; +} + +void PieChart::paint(QPainter *painter) +{ + QPen pen(m_color, 2); + painter->setPen(pen); + painter->setRenderHints(QPainter::HighQualityAntialiasing, true); + painter->drawPie(boundingRect(), 90 * 16, 290 * 16); +} + +//![0] +void PieChart::clearChart() +{ + setColor(QColor(Qt::transparent)); + update(); + + emit chartCleared(); +} +//![0] diff --git a/examples/qml/tutorials/extending/chapter2-methods/piechart.h b/examples/qml/tutorials/extending/chapter2-methods/piechart.h new file mode 100644 index 0000000000..7650d6e8d7 --- /dev/null +++ b/examples/qml/tutorials/extending/chapter2-methods/piechart.h @@ -0,0 +1,84 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#ifndef PIECHART_H +#define PIECHART_H + +#include +#include + +//![0] +class PieChart : public QQuickPaintedItem +{ +//![0] + Q_OBJECT + Q_PROPERTY(QString name READ name WRITE setName) + Q_PROPERTY(QColor color READ color WRITE setColor) + +//![1] +public: +//![1] + + PieChart(QQuickItem *parent = 0); + + QString name() const; + void setName(const QString &name); + + QColor color() const; + void setColor(const QColor &color); + + void paint(QPainter *painter); + +//![2] + Q_INVOKABLE void clearChart(); + +signals: + void chartCleared(); +//![2] + +private: + QString m_name; + QColor m_color; + +//![3] +}; +//![3] + +#endif + diff --git a/examples/qml/tutorials/extending/chapter3-bindings/app.qml b/examples/qml/tutorials/extending/chapter3-bindings/app.qml new file mode 100644 index 0000000000..4ad929132c --- /dev/null +++ b/examples/qml/tutorials/extending/chapter3-bindings/app.qml @@ -0,0 +1,74 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +//![0] +import Charts 1.0 +import QtQuick 2.0 + +Item { + width: 300; height: 200 + + Row { + anchors.centerIn: parent + spacing: 20 + + PieChart { + id: chartA + width: 100; height: 100 + color: "red" + } + + PieChart { + id: chartB + width: 100; height: 100 + color: chartA.color + } + } + + MouseArea { + anchors.fill: parent + onClicked: { chartA.color = "blue" } + } + + Text { + anchors { bottom: parent.bottom; horizontalCenter: parent.horizontalCenter; bottomMargin: 20 } + text: "Click anywhere to change the chart color" + } +} +//![0] diff --git a/examples/qml/tutorials/extending/chapter3-bindings/chapter3-bindings.pro b/examples/qml/tutorials/extending/chapter3-bindings/chapter3-bindings.pro new file mode 100644 index 0000000000..8ed66f8b66 --- /dev/null +++ b/examples/qml/tutorials/extending/chapter3-bindings/chapter3-bindings.pro @@ -0,0 +1,5 @@ +QT += qml quick + +HEADERS += piechart.h +SOURCES += piechart.cpp \ + main.cpp diff --git a/examples/qml/tutorials/extending/chapter3-bindings/main.cpp b/examples/qml/tutorials/extending/chapter3-bindings/main.cpp new file mode 100644 index 0000000000..ed9e412bd6 --- /dev/null +++ b/examples/qml/tutorials/extending/chapter3-bindings/main.cpp @@ -0,0 +1,57 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +//![0] +#include "piechart.h" +#include +#include + +int main(int argc, char *argv[]) +{ + QGuiApplication app(argc, argv); + + qmlRegisterType("Charts", 1, 0, "PieChart"); + + QQuickView view; + view.setResizeMode(QQuickView::SizeRootObjectToView); + view.setSource(QUrl::fromLocalFile("app.qml")); + view.show(); + return app.exec(); +} +//![0] diff --git a/examples/qml/tutorials/extending/chapter3-bindings/piechart.cpp b/examples/qml/tutorials/extending/chapter3-bindings/piechart.cpp new file mode 100644 index 0000000000..2a392125da --- /dev/null +++ b/examples/qml/tutorials/extending/chapter3-bindings/piechart.cpp @@ -0,0 +1,86 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include "piechart.h" +#include + +PieChart::PieChart(QQuickItem *parent) + : QQuickPaintedItem(parent) +{ +} + +QString PieChart::name() const +{ + return m_name; +} + +void PieChart::setName(const QString &name) +{ + m_name = name; +} + +QColor PieChart::color() const +{ + return m_color; +} + +//![0] +void PieChart::setColor(const QColor &color) +{ + if (color != m_color) { + m_color = color; + update(); // repaint with the new color + emit colorChanged(); + } +} +//![0] + +void PieChart::paint(QPainter *painter) +{ + QPen pen(m_color, 2); + painter->setPen(pen); + painter->setRenderHints(QPainter::HighQualityAntialiasing, true); + painter->drawPie(boundingRect(), 90 * 16, 290 * 16); +} + +void PieChart::clearChart() +{ + setColor(QColor(Qt::transparent)); + update(); +} diff --git a/examples/qml/tutorials/extending/chapter3-bindings/piechart.h b/examples/qml/tutorials/extending/chapter3-bindings/piechart.h new file mode 100644 index 0000000000..77075b5727 --- /dev/null +++ b/examples/qml/tutorials/extending/chapter3-bindings/piechart.h @@ -0,0 +1,84 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#ifndef PIECHART_H +#define PIECHART_H + +#include +#include + +//![0] +class PieChart : public QQuickPaintedItem +{ +//![0] + Q_OBJECT + Q_PROPERTY(QString name READ name WRITE setName) + +//![1] + Q_PROPERTY(QColor color READ color WRITE setColor NOTIFY colorChanged) +public: +//![1] + + PieChart(QQuickItem *parent = 0); + + QString name() const; + void setName(const QString &name); + + QColor color() const; + void setColor(const QColor &color); + + void paint(QPainter *painter); + + Q_INVOKABLE void clearChart(); + +//![2] +signals: + void colorChanged(); +//![2] + +private: + QString m_name; + QColor m_color; + +//![3] +}; +//![3] + +#endif + diff --git a/examples/qml/tutorials/extending/chapter4-customPropertyTypes/app.qml b/examples/qml/tutorials/extending/chapter4-customPropertyTypes/app.qml new file mode 100644 index 0000000000..06490773f4 --- /dev/null +++ b/examples/qml/tutorials/extending/chapter4-customPropertyTypes/app.qml @@ -0,0 +1,60 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +//![0] +import Charts 1.0 +import QtQuick 2.0 + +Item { + width: 300; height: 200 + + PieChart { + id: chart + anchors.centerIn: parent + width: 100; height: 100 + + pieSlice: PieSlice { + anchors.fill: parent + color: "red" + } + } + + Component.onCompleted: console.log("The pie is colored " + chart.pieSlice.color) +} +//![0] diff --git a/examples/qml/tutorials/extending/chapter4-customPropertyTypes/chapter4-customPropertyTypes.pro b/examples/qml/tutorials/extending/chapter4-customPropertyTypes/chapter4-customPropertyTypes.pro new file mode 100644 index 0000000000..23eb222ea3 --- /dev/null +++ b/examples/qml/tutorials/extending/chapter4-customPropertyTypes/chapter4-customPropertyTypes.pro @@ -0,0 +1,7 @@ +QT += qml quick + +HEADERS += piechart.h \ + pieslice.h +SOURCES += piechart.cpp \ + pieslice.cpp \ + main.cpp diff --git a/examples/qml/tutorials/extending/chapter4-customPropertyTypes/main.cpp b/examples/qml/tutorials/extending/chapter4-customPropertyTypes/main.cpp new file mode 100644 index 0000000000..537ea766fc --- /dev/null +++ b/examples/qml/tutorials/extending/chapter4-customPropertyTypes/main.cpp @@ -0,0 +1,66 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include "piechart.h" +#include "pieslice.h" + +#include +#include + +//![0] +int main(int argc, char *argv[]) +{ +//![0] + QGuiApplication app(argc, argv); + + qmlRegisterType("Charts", 1, 0, "PieChart"); + +//![1] + qmlRegisterType("Charts", 1, 0, "PieSlice"); +//![1] + + QQuickView view; + view.setResizeMode(QQuickView::SizeRootObjectToView); + view.setSource(QUrl::fromLocalFile("app.qml")); + view.show(); + return app.exec(); + +//![2] +} +//![2] diff --git a/examples/qml/tutorials/extending/chapter4-customPropertyTypes/piechart.cpp b/examples/qml/tutorials/extending/chapter4-customPropertyTypes/piechart.cpp new file mode 100644 index 0000000000..3cf9bdc00c --- /dev/null +++ b/examples/qml/tutorials/extending/chapter4-customPropertyTypes/piechart.cpp @@ -0,0 +1,70 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include "piechart.h" +#include "pieslice.h" + +PieChart::PieChart(QQuickItem *parent) + : QQuickItem(parent) +{ +} + +QString PieChart::name() const +{ + return m_name; +} + +void PieChart::setName(const QString &name) +{ + m_name = name; +} + +PieSlice *PieChart::pieSlice() const +{ + return m_pieSlice; +} + +//![0] +void PieChart::setPieSlice(PieSlice *pieSlice) +{ + m_pieSlice = pieSlice; + pieSlice->setParentItem(this); +} +//![0] + diff --git a/examples/qml/tutorials/extending/chapter4-customPropertyTypes/piechart.h b/examples/qml/tutorials/extending/chapter4-customPropertyTypes/piechart.h new file mode 100644 index 0000000000..b89db5a2b1 --- /dev/null +++ b/examples/qml/tutorials/extending/chapter4-customPropertyTypes/piechart.h @@ -0,0 +1,78 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#ifndef PIECHART_H +#define PIECHART_H + +#include + +class PieSlice; + +//![0] +class PieChart : public QQuickItem +{ + Q_OBJECT + Q_PROPERTY(PieSlice* pieSlice READ pieSlice WRITE setPieSlice) +//![0] + Q_PROPERTY(QString name READ name WRITE setName) + +//![1] +public: +//![1] + + PieChart(QQuickItem *parent = 0); + + QString name() const; + void setName(const QString &name); + +//![2] + PieSlice *pieSlice() const; + void setPieSlice(PieSlice *pieSlice); +//![2] + +private: + QString m_name; + PieSlice *m_pieSlice; + +//![3] +}; +//![3] + +#endif + diff --git a/examples/qml/tutorials/extending/chapter4-customPropertyTypes/pieslice.cpp b/examples/qml/tutorials/extending/chapter4-customPropertyTypes/pieslice.cpp new file mode 100644 index 0000000000..654a46fc8d --- /dev/null +++ b/examples/qml/tutorials/extending/chapter4-customPropertyTypes/pieslice.cpp @@ -0,0 +1,66 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include "pieslice.h" + +#include + +PieSlice::PieSlice(QQuickItem *parent) + : QQuickPaintedItem(parent) +{ +} + +QColor PieSlice::color() const +{ + return m_color; +} + +void PieSlice::setColor(const QColor &color) +{ + m_color = color; +} + +void PieSlice::paint(QPainter *painter) +{ + QPen pen(m_color, 2); + painter->setPen(pen); + painter->setRenderHints(QPainter::HighQualityAntialiasing, true); + painter->drawPie(boundingRect(), 90 * 16, 290 * 16); +} + diff --git a/examples/qml/tutorials/extending/chapter4-customPropertyTypes/pieslice.h b/examples/qml/tutorials/extending/chapter4-customPropertyTypes/pieslice.h new file mode 100644 index 0000000000..8fc445d471 --- /dev/null +++ b/examples/qml/tutorials/extending/chapter4-customPropertyTypes/pieslice.h @@ -0,0 +1,66 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#ifndef PIESLICE_H +#define PIESLICE_H + +#include +#include + +//![0] +class PieSlice : public QQuickPaintedItem +{ + Q_OBJECT + Q_PROPERTY(QColor color READ color WRITE setColor) + +public: + PieSlice(QQuickItem *parent = 0); + + QColor color() const; + void setColor(const QColor &color); + + void paint(QPainter *painter); + +private: + QColor m_color; +}; +//![0] + +#endif + diff --git a/examples/qml/tutorials/extending/chapter5-listproperties/app.qml b/examples/qml/tutorials/extending/chapter5-listproperties/app.qml new file mode 100644 index 0000000000..37b0626948 --- /dev/null +++ b/examples/qml/tutorials/extending/chapter5-listproperties/app.qml @@ -0,0 +1,70 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +//![0] +import Charts 1.0 +import QtQuick 2.0 + +Item { + width: 300; height: 200 + + PieChart { + anchors.centerIn: parent + width: 100; height: 100 + + slices: [ + PieSlice { + anchors.fill: parent + color: "red" + fromAngle: 0; angleSpan: 110 + }, + PieSlice { + anchors.fill: parent + color: "black" + fromAngle: 110; angleSpan: 50 + }, + PieSlice { + anchors.fill: parent + color: "blue" + fromAngle: 160; angleSpan: 100 + } + ] + } +} +//![0] diff --git a/examples/qml/tutorials/extending/chapter5-listproperties/chapter5-listproperties.pro b/examples/qml/tutorials/extending/chapter5-listproperties/chapter5-listproperties.pro new file mode 100644 index 0000000000..23eb222ea3 --- /dev/null +++ b/examples/qml/tutorials/extending/chapter5-listproperties/chapter5-listproperties.pro @@ -0,0 +1,7 @@ +QT += qml quick + +HEADERS += piechart.h \ + pieslice.h +SOURCES += piechart.cpp \ + pieslice.cpp \ + main.cpp diff --git a/examples/qml/tutorials/extending/chapter5-listproperties/main.cpp b/examples/qml/tutorials/extending/chapter5-listproperties/main.cpp new file mode 100644 index 0000000000..59587733eb --- /dev/null +++ b/examples/qml/tutorials/extending/chapter5-listproperties/main.cpp @@ -0,0 +1,58 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include "piechart.h" +#include "pieslice.h" + +#include +#include + +int main(int argc, char *argv[]) +{ + QGuiApplication app(argc, argv); + + qmlRegisterType("Charts", 1, 0, "PieChart"); + qmlRegisterType("Charts", 1, 0, "PieSlice"); + + QQuickView view; + view.setResizeMode(QQuickView::SizeRootObjectToView); + view.setSource(QUrl::fromLocalFile("app.qml")); + view.show(); + return app.exec(); +} diff --git a/examples/qml/tutorials/extending/chapter5-listproperties/piechart.cpp b/examples/qml/tutorials/extending/chapter5-listproperties/piechart.cpp new file mode 100644 index 0000000000..9c2c6accf3 --- /dev/null +++ b/examples/qml/tutorials/extending/chapter5-listproperties/piechart.cpp @@ -0,0 +1,72 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include "piechart.h" +#include "pieslice.h" + +PieChart::PieChart(QQuickItem *parent) + : QQuickItem(parent) +{ +} + +QString PieChart::name() const +{ + return m_name; +} + +void PieChart::setName(const QString &name) +{ + m_name = name; +} + +//![0] +QQmlListProperty PieChart::slices() +{ + return QQmlListProperty(this, 0, &PieChart::append_slice); +} + +void PieChart::append_slice(QQmlListProperty *list, PieSlice *slice) +{ + PieChart *chart = qobject_cast(list->object); + if (chart) { + slice->setParentItem(chart); + chart->m_slices.append(slice); + } +} +//![0] diff --git a/examples/qml/tutorials/extending/chapter5-listproperties/piechart.h b/examples/qml/tutorials/extending/chapter5-listproperties/piechart.h new file mode 100644 index 0000000000..6c17bc1258 --- /dev/null +++ b/examples/qml/tutorials/extending/chapter5-listproperties/piechart.h @@ -0,0 +1,75 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#ifndef PIECHART_H +#define PIECHART_H + +#include + +class PieSlice; + +//![0] +class PieChart : public QQuickItem +{ + Q_OBJECT + Q_PROPERTY(QQmlListProperty slices READ slices) +//![0] + Q_PROPERTY(QString name READ name WRITE setName) + +//![1] +public: +//![1] + PieChart(QQuickItem *parent = 0); + + QString name() const; + void setName(const QString &name); + +//![2] + QQmlListProperty slices(); + +private: + static void append_slice(QQmlListProperty *list, PieSlice *slice); + + QString m_name; + QList m_slices; +}; +//![2] + +#endif + diff --git a/examples/qml/tutorials/extending/chapter5-listproperties/pieslice.cpp b/examples/qml/tutorials/extending/chapter5-listproperties/pieslice.cpp new file mode 100644 index 0000000000..5bca2d58d8 --- /dev/null +++ b/examples/qml/tutorials/extending/chapter5-listproperties/pieslice.cpp @@ -0,0 +1,86 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include "pieslice.h" + +#include + +PieSlice::PieSlice(QQuickItem *parent) + : QQuickPaintedItem(parent) +{ +} + +QColor PieSlice::color() const +{ + return m_color; +} + +void PieSlice::setColor(const QColor &color) +{ + m_color = color; +} + +int PieSlice::fromAngle() const +{ + return m_fromAngle; +} + +void PieSlice::setFromAngle(int angle) +{ + m_fromAngle = angle; +} + +int PieSlice::angleSpan() const +{ + return m_angleSpan; +} + +void PieSlice::setAngleSpan(int angle) +{ + m_angleSpan = angle; +} + +void PieSlice::paint(QPainter *painter) +{ + QPen pen(m_color, 2); + painter->setPen(pen); + painter->setRenderHints(QPainter::HighQualityAntialiasing, true); + painter->drawPie(boundingRect(), m_fromAngle * 16, m_angleSpan * 16); +} + diff --git a/examples/qml/tutorials/extending/chapter5-listproperties/pieslice.h b/examples/qml/tutorials/extending/chapter5-listproperties/pieslice.h new file mode 100644 index 0000000000..f6497fcbae --- /dev/null +++ b/examples/qml/tutorials/extending/chapter5-listproperties/pieslice.h @@ -0,0 +1,76 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#ifndef PIESLICE_H +#define PIESLICE_H + +#include +#include + +//![0] +class PieSlice : public QQuickPaintedItem +{ + Q_OBJECT + Q_PROPERTY(QColor color READ color WRITE setColor) + Q_PROPERTY(int fromAngle READ fromAngle WRITE setFromAngle) + Q_PROPERTY(int angleSpan READ angleSpan WRITE setAngleSpan) +//![0] + +public: + PieSlice(QQuickItem *parent = 0); + + QColor color() const; + void setColor(const QColor &color); + + int fromAngle() const; + void setFromAngle(int angle); + + int angleSpan() const; + void setAngleSpan(int span); + + void paint(QPainter *painter); + +private: + QColor m_color; + int m_fromAngle; + int m_angleSpan; +}; + +#endif + diff --git a/examples/qml/tutorials/extending/chapter6-plugins/ChartsPlugin/qmldir b/examples/qml/tutorials/extending/chapter6-plugins/ChartsPlugin/qmldir new file mode 100644 index 0000000000..72650d8243 --- /dev/null +++ b/examples/qml/tutorials/extending/chapter6-plugins/ChartsPlugin/qmldir @@ -0,0 +1 @@ +plugin chartsplugin \ No newline at end of file diff --git a/examples/qml/tutorials/extending/chapter6-plugins/app.qml b/examples/qml/tutorials/extending/chapter6-plugins/app.qml new file mode 100644 index 0000000000..b6eac44e27 --- /dev/null +++ b/examples/qml/tutorials/extending/chapter6-plugins/app.qml @@ -0,0 +1,69 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +import QtQuick 2.0 +import "ChartsPlugin" 1.0 + +Item { + width: 300; height: 200 + + PieChart { + anchors.centerIn: parent + width: 100; height: 100 + + slices: [ + PieSlice { + anchors.fill: parent + color: "red" + fromAngle: 0; angleSpan: 110 + }, + PieSlice { + anchors.fill: parent + color: "black" + fromAngle: 110; angleSpan: 50 + }, + PieSlice { + anchors.fill: parent + color: "blue" + fromAngle: 160; angleSpan: 100 + } + ] + } +} + diff --git a/examples/qml/tutorials/extending/chapter6-plugins/chapter6-plugins.pro b/examples/qml/tutorials/extending/chapter6-plugins/chapter6-plugins.pro new file mode 100644 index 0000000000..75f88b2eaa --- /dev/null +++ b/examples/qml/tutorials/extending/chapter6-plugins/chapter6-plugins.pro @@ -0,0 +1,18 @@ +TEMPLATE = lib +CONFIG += qt plugin +QT += qml quick + +DESTDIR = ChartsPlugin +TARGET = chartsplugin + +OBJECTS_DIR = tmp +MOC_DIR = tmp + +HEADERS += piechart.h \ + pieslice.h \ + chartsplugin.h + +SOURCES += piechart.cpp \ + pieslice.cpp \ + chartsplugin.cpp + diff --git a/examples/qml/tutorials/extending/chapter6-plugins/chartsplugin.cpp b/examples/qml/tutorials/extending/chapter6-plugins/chartsplugin.cpp new file mode 100644 index 0000000000..f95cf1003b --- /dev/null +++ b/examples/qml/tutorials/extending/chapter6-plugins/chartsplugin.cpp @@ -0,0 +1,54 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include "chartsplugin.h" +//![0] +#include "piechart.h" +#include "pieslice.h" +#include + +void ChartsPlugin::registerTypes(const char *uri) +{ + qmlRegisterType(uri, 1, 0, "PieChart"); + qmlRegisterType(uri, 1, 0, "PieSlice"); +} + +Q_EXPORT_PLUGIN2(chartsplugin, ChartsPlugin); +//![0] + diff --git a/examples/qml/tutorials/extending/chapter6-plugins/chartsplugin.h b/examples/qml/tutorials/extending/chapter6-plugins/chartsplugin.h new file mode 100644 index 0000000000..2dc477f794 --- /dev/null +++ b/examples/qml/tutorials/extending/chapter6-plugins/chartsplugin.h @@ -0,0 +1,55 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#ifndef CHARTSPLUGIN_H +#define CHARTSPLUGIN_H + +//![0] +#include + +class ChartsPlugin : public QQmlExtensionPlugin +{ + Q_OBJECT +public: + void registerTypes(const char *uri); +}; +//![0] + +#endif + diff --git a/examples/qml/tutorials/extending/chapter6-plugins/piechart.cpp b/examples/qml/tutorials/extending/chapter6-plugins/piechart.cpp new file mode 100644 index 0000000000..b00f4139be --- /dev/null +++ b/examples/qml/tutorials/extending/chapter6-plugins/piechart.cpp @@ -0,0 +1,71 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include "piechart.h" +#include "pieslice.h" + +PieChart::PieChart(QQuickItem *parent) + : QQuickItem(parent) +{ +} + +QString PieChart::name() const +{ + return m_name; +} + +void PieChart::setName(const QString &name) +{ + m_name = name; +} + +QQmlListProperty PieChart::slices() +{ + return QQmlListProperty(this, 0, &PieChart::append_slice); +} + +void PieChart::append_slice(QQmlListProperty *list, PieSlice *slice) +{ + PieChart *chart = qobject_cast(list->object); + if (chart) { + slice->setParentItem(chart); + chart->m_slices.append(slice); + } +} + diff --git a/examples/qml/tutorials/extending/chapter6-plugins/piechart.h b/examples/qml/tutorials/extending/chapter6-plugins/piechart.h new file mode 100644 index 0000000000..2ee8108784 --- /dev/null +++ b/examples/qml/tutorials/extending/chapter6-plugins/piechart.h @@ -0,0 +1,69 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#ifndef PIECHART_H +#define PIECHART_H + +#include + +class PieSlice; + +class PieChart : public QQuickItem +{ + Q_OBJECT + Q_PROPERTY(QQmlListProperty slices READ slices) + Q_PROPERTY(QString name READ name WRITE setName) + +public: + PieChart(QQuickItem *parent = 0); + + QString name() const; + void setName(const QString &name); + + QQmlListProperty slices(); + +private: + static void append_slice(QQmlListProperty *list, PieSlice *slice); + + QString m_name; + QList m_slices; +}; + +#endif + diff --git a/examples/qml/tutorials/extending/chapter6-plugins/pieslice.cpp b/examples/qml/tutorials/extending/chapter6-plugins/pieslice.cpp new file mode 100644 index 0000000000..5bca2d58d8 --- /dev/null +++ b/examples/qml/tutorials/extending/chapter6-plugins/pieslice.cpp @@ -0,0 +1,86 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include "pieslice.h" + +#include + +PieSlice::PieSlice(QQuickItem *parent) + : QQuickPaintedItem(parent) +{ +} + +QColor PieSlice::color() const +{ + return m_color; +} + +void PieSlice::setColor(const QColor &color) +{ + m_color = color; +} + +int PieSlice::fromAngle() const +{ + return m_fromAngle; +} + +void PieSlice::setFromAngle(int angle) +{ + m_fromAngle = angle; +} + +int PieSlice::angleSpan() const +{ + return m_angleSpan; +} + +void PieSlice::setAngleSpan(int angle) +{ + m_angleSpan = angle; +} + +void PieSlice::paint(QPainter *painter) +{ + QPen pen(m_color, 2); + painter->setPen(pen); + painter->setRenderHints(QPainter::HighQualityAntialiasing, true); + painter->drawPie(boundingRect(), m_fromAngle * 16, m_angleSpan * 16); +} + diff --git a/examples/qml/tutorials/extending/chapter6-plugins/pieslice.h b/examples/qml/tutorials/extending/chapter6-plugins/pieslice.h new file mode 100644 index 0000000000..8a636fb3e7 --- /dev/null +++ b/examples/qml/tutorials/extending/chapter6-plugins/pieslice.h @@ -0,0 +1,74 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#ifndef PIESLICE_H +#define PIESLICE_H + +#include +#include + +class PieSlice : public QQuickPaintedItem +{ + Q_OBJECT + Q_PROPERTY(QColor color READ color WRITE setColor) + Q_PROPERTY(int fromAngle READ fromAngle WRITE setFromAngle) + Q_PROPERTY(int angleSpan READ angleSpan WRITE setAngleSpan) + +public: + PieSlice(QQuickItem *parent = 0); + + QColor color() const; + void setColor(const QColor &color); + + int fromAngle() const; + void setFromAngle(int angle); + + int angleSpan() const; + void setAngleSpan(int span); + + void paint(QPainter *painter); + +private: + QColor m_color; + int m_fromAngle; + int m_angleSpan; +}; + +#endif + diff --git a/examples/qml/tutorials/extending/extending.pro b/examples/qml/tutorials/extending/extending.pro new file mode 100644 index 0000000000..967473fda0 --- /dev/null +++ b/examples/qml/tutorials/extending/extending.pro @@ -0,0 +1,10 @@ +TEMPLATE = subdirs + +SUBDIRS += \ + chapter1-basics \ + chapter2-methods \ + chapter3-bindings \ + chapter4-customPropertyTypes \ + chapter5-listproperties \ + chapter6-plugins + diff --git a/examples/qml/tutorials/helloworld/Cell.qml b/examples/qml/tutorials/helloworld/Cell.qml new file mode 100644 index 0000000000..7140dcb2c1 --- /dev/null +++ b/examples/qml/tutorials/helloworld/Cell.qml @@ -0,0 +1,72 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +//![0] +import QtQuick 2.0 + +//![1] +Item { + id: container +//![4] + property alias cellColor: rectangle.color +//![4] +//![5] + signal clicked(color cellColor) +//![5] + + width: 40; height: 25 +//![1] + +//![2] + Rectangle { + id: rectangle + border.color: "white" + anchors.fill: parent + } +//![2] + +//![3] + MouseArea { + anchors.fill: parent + onClicked: container.clicked(container.cellColor) + } +//![3] +} +//![0] diff --git a/examples/qml/tutorials/helloworld/tutorial1.qml b/examples/qml/tutorials/helloworld/tutorial1.qml new file mode 100644 index 0000000000..f0eb42d696 --- /dev/null +++ b/examples/qml/tutorials/helloworld/tutorial1.qml @@ -0,0 +1,63 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +//![0] +//![3] +import QtQuick 2.0 +//![3] + +//![1] +Rectangle { + id: page + width: 500; height: 200 + color: "lightgray" +//![1] + +//![2] + Text { + id: helloText + text: "Hello world!" + y: 30 + anchors.horizontalCenter: page.horizontalCenter + font.pointSize: 24; font.bold: true + } +//![2] +} +//![0] diff --git a/examples/qml/tutorials/helloworld/tutorial2.qml b/examples/qml/tutorials/helloworld/tutorial2.qml new file mode 100644 index 0000000000..c5c045aace --- /dev/null +++ b/examples/qml/tutorials/helloworld/tutorial2.qml @@ -0,0 +1,72 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +//![0] +import QtQuick 2.0 + +Rectangle { + id: page + width: 500; height: 200 + color: "lightgray" + + Text { + id: helloText + text: "Hello world!" + y: 30 + anchors.horizontalCenter: page.horizontalCenter + font.pointSize: 24; font.bold: true + } + + Grid { + id: colorPicker + x: 4; anchors.bottom: page.bottom; anchors.bottomMargin: 4 + rows: 2; columns: 3; spacing: 3 + +//![1] + Cell { cellColor: "red"; onClicked: helloText.color = cellColor } +//![1] + Cell { cellColor: "green"; onClicked: helloText.color = cellColor } + Cell { cellColor: "blue"; onClicked: helloText.color = cellColor } + Cell { cellColor: "yellow"; onClicked: helloText.color = cellColor } + Cell { cellColor: "steelblue"; onClicked: helloText.color = cellColor } + Cell { cellColor: "black"; onClicked: helloText.color = cellColor } + } +} +//![0] diff --git a/examples/qml/tutorials/helloworld/tutorial3.qml b/examples/qml/tutorials/helloworld/tutorial3.qml new file mode 100644 index 0000000000..c804bfca1d --- /dev/null +++ b/examples/qml/tutorials/helloworld/tutorial3.qml @@ -0,0 +1,91 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +//![0] +import QtQuick 2.0 + +Rectangle { + id: page + width: 500; height: 200 + color: "lightgray" + + Text { + id: helloText + text: "Hello world!" + y: 30 + anchors.horizontalCenter: page.horizontalCenter + font.pointSize: 24; font.bold: true + +//![1] + MouseArea { id: mouseArea; anchors.fill: parent } +//![1] + +//![2] + states: State { + name: "down"; when: mouseArea.pressed == true + PropertyChanges { target: helloText; y: 160; rotation: 180; color: "red" } + } +//![2] + +//![3] + transitions: Transition { + from: ""; to: "down"; reversible: true + ParallelAnimation { + NumberAnimation { properties: "y,rotation"; duration: 500; easing.type: Easing.InOutQuad } + ColorAnimation { duration: 500 } + } + } +//![3] + } + + Grid { + id: colorPicker + x: 4; anchors.bottom: page.bottom; anchors.bottomMargin: 4 + rows: 2; columns: 3; spacing: 3 + + Cell { cellColor: "red"; onClicked: helloText.color = cellColor } + Cell { cellColor: "green"; onClicked: helloText.color = cellColor } + Cell { cellColor: "blue"; onClicked: helloText.color = cellColor } + Cell { cellColor: "yellow"; onClicked: helloText.color = cellColor } + Cell { cellColor: "steelblue"; onClicked: helloText.color = cellColor } + Cell { cellColor: "black"; onClicked: helloText.color = cellColor } + } +} +//![0] diff --git a/examples/qml/tutorials/samegame/samegame1/Block.qml b/examples/qml/tutorials/samegame/samegame1/Block.qml new file mode 100644 index 0000000000..32ef8c2bba --- /dev/null +++ b/examples/qml/tutorials/samegame/samegame1/Block.qml @@ -0,0 +1,53 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +//![0] +import QtQuick 2.0 + +Item { + id: block + + Image { + id: img + anchors.fill: parent + source: "../shared/pics/redStone.png" + } +} +//![0] diff --git a/examples/qml/tutorials/samegame/samegame1/Button.qml b/examples/qml/tutorials/samegame/samegame1/Button.qml new file mode 100644 index 0000000000..6d1d1268de --- /dev/null +++ b/examples/qml/tutorials/samegame/samegame1/Button.qml @@ -0,0 +1,83 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +//![0] +import QtQuick 2.0 + +Rectangle { + id: container + + property string text: "Button" + + signal clicked + + width: buttonLabel.width + 20; height: buttonLabel.height + 5 + border { width: 1; color: Qt.darker(activePalette.button) } + smooth: true + radius: 8 + + // color the button with a gradient + gradient: Gradient { + GradientStop { + position: 0.0 + color: { + if (mouseArea.pressed) + return activePalette.dark + else + return activePalette.light + } + } + GradientStop { position: 1.0; color: activePalette.button } + } + + MouseArea { + id: mouseArea + anchors.fill: parent + onClicked: container.clicked(); + } + + Text { + id: buttonLabel + anchors.centerIn: container + color: activePalette.buttonText + text: container.text + } +} +//![0] diff --git a/examples/qml/tutorials/samegame/samegame1/samegame.qml b/examples/qml/tutorials/samegame/samegame1/samegame.qml new file mode 100644 index 0000000000..73e2cc31fd --- /dev/null +++ b/examples/qml/tutorials/samegame/samegame1/samegame.qml @@ -0,0 +1,82 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +//![0] +import QtQuick 2.0 + +Rectangle { + id: screen + + width: 490; height: 720 + + SystemPalette { id: activePalette } + + Item { + width: parent.width + anchors { top: parent.top; bottom: toolBar.top } + + Image { + id: background + anchors.fill: parent + source: "../shared/pics/background.jpg" + fillMode: Image.PreserveAspectCrop + } + } + + Rectangle { + id: toolBar + width: parent.width; height: 30 + color: activePalette.window + anchors.bottom: screen.bottom + + Button { + anchors { left: parent.left; verticalCenter: parent.verticalCenter } + text: "New Game" + onClicked: console.log("This doesn't do anything yet...") + } + + Text { + id: score + anchors { right: parent.right; verticalCenter: parent.verticalCenter } + text: "Score: Who knows?" + } + } +} +//![0] diff --git a/examples/qml/tutorials/samegame/samegame1/samegame1.qmlproject b/examples/qml/tutorials/samegame/samegame1/samegame1.qmlproject new file mode 100644 index 0000000000..42ffacf4f8 --- /dev/null +++ b/examples/qml/tutorials/samegame/samegame1/samegame1.qmlproject @@ -0,0 +1,16 @@ +import QmlProject 1.1 + +Project { + mainFile: "samegame.qml" + + /* Include .qml, .js, and image files from current directory and subdirectories */ + QmlFiles { + directory: "." + } + JavaScriptFiles { + directory: "." + } + ImageFiles { + directory: "." + } +} diff --git a/examples/qml/tutorials/samegame/samegame2/Block.qml b/examples/qml/tutorials/samegame/samegame2/Block.qml new file mode 100644 index 0000000000..8056b39480 --- /dev/null +++ b/examples/qml/tutorials/samegame/samegame2/Block.qml @@ -0,0 +1,51 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Item { + id: block + + Image { + id: img + anchors.fill: parent + source: "../shared/pics/redStone.png" + } +} diff --git a/examples/qml/tutorials/samegame/samegame2/Button.qml b/examples/qml/tutorials/samegame/samegame2/Button.qml new file mode 100644 index 0000000000..248c20cf0f --- /dev/null +++ b/examples/qml/tutorials/samegame/samegame2/Button.qml @@ -0,0 +1,81 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Rectangle { + id: container + + property string text: "Button" + + signal clicked + + width: buttonLabel.width + 20; height: buttonLabel.height + 5 + border { width: 1; color: Qt.darker(activePalette.button) } + smooth: true + radius: 8 + + // color the button with a gradient + gradient: Gradient { + GradientStop { + position: 0.0 + color: { + if (mouseArea.pressed) + return activePalette.dark + else + return activePalette.light + } + } + GradientStop { position: 1.0; color: activePalette.button } + } + + MouseArea { + id: mouseArea + anchors.fill: parent + onClicked: container.clicked(); + } + + Text { + id: buttonLabel + anchors.centerIn: container + color: activePalette.buttonText + text: container.text + } +} diff --git a/examples/qml/tutorials/samegame/samegame2/samegame.js b/examples/qml/tutorials/samegame/samegame2/samegame.js new file mode 100644 index 0000000000..c749dc17b1 --- /dev/null +++ b/examples/qml/tutorials/samegame/samegame2/samegame.js @@ -0,0 +1,63 @@ +//![0] +var blockSize = 40; +var maxColumn = 10; +var maxRow = 15; +var maxIndex = maxColumn * maxRow; +var board = new Array(maxIndex); +var component; + +//Index function used instead of a 2D array +function index(column, row) { + return column + (row * maxColumn); +} + +function startNewGame() { + //Delete blocks from previous game + for (var i = 0; i < maxIndex; i++) { + if (board[i] != null) + board[i].destroy(); + } + + //Calculate board size + maxColumn = Math.floor(background.width / blockSize); + maxRow = Math.floor(background.height / blockSize); + maxIndex = maxRow * maxColumn; + + //Initialize Board + board = new Array(maxIndex); + for (var column = 0; column < maxColumn; column++) { + for (var row = 0; row < maxRow; row++) { + board[index(column, row)] = null; + createBlock(column, row); + } + } +} + +function createBlock(column, row) { + if (component == null) + component = Qt.createComponent("Block.qml"); + + // Note that if Block.qml was not a local file, component.status would be + // Loading and we should wait for the component's statusChanged() signal to + // know when the file is downloaded and ready before calling createObject(). + if (component.status == Component.Ready) { + var dynamicObject = component.createObject(background); + if (dynamicObject == null) { + console.log("error creating block"); + console.log(component.errorString()); + return false; + } + dynamicObject.x = column * blockSize; + dynamicObject.y = row * blockSize; + dynamicObject.width = blockSize; + dynamicObject.height = blockSize; + board[index(column, row)] = dynamicObject; + } else { + console.log("error loading block component"); + console.log(component.errorString()); + return false; + } + return true; +} +//![0] + diff --git a/examples/qml/tutorials/samegame/samegame2/samegame.qml b/examples/qml/tutorials/samegame/samegame2/samegame.qml new file mode 100644 index 0000000000..c50010e97d --- /dev/null +++ b/examples/qml/tutorials/samegame/samegame2/samegame.qml @@ -0,0 +1,85 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +//![2] +import "samegame.js" as SameGame +//![2] + +Rectangle { + id: screen + + width: 490; height: 720 + + SystemPalette { id: activePalette } + + Item { + width: parent.width + anchors { top: parent.top; bottom: toolBar.top } + + Image { + id: background + anchors.fill: parent + source: "../shared/pics/background.jpg" + fillMode: Image.PreserveAspectCrop + } + } + + Rectangle { + id: toolBar + width: parent.width; height: 32 + color: activePalette.window + anchors.bottom: screen.bottom + +//![1] + Button { + anchors { left: parent.left; verticalCenter: parent.verticalCenter } + text: "New Game" + onClicked: SameGame.startNewGame() + } +//![1] + + Text { + id: score + anchors { right: parent.right; verticalCenter: parent.verticalCenter } + text: "Score: Who knows?" + } + } +} diff --git a/examples/qml/tutorials/samegame/samegame2/samegame2.qmlproject b/examples/qml/tutorials/samegame/samegame2/samegame2.qmlproject new file mode 100644 index 0000000000..42ffacf4f8 --- /dev/null +++ b/examples/qml/tutorials/samegame/samegame2/samegame2.qmlproject @@ -0,0 +1,16 @@ +import QmlProject 1.1 + +Project { + mainFile: "samegame.qml" + + /* Include .qml, .js, and image files from current directory and subdirectories */ + QmlFiles { + directory: "." + } + JavaScriptFiles { + directory: "." + } + ImageFiles { + directory: "." + } +} diff --git a/examples/qml/tutorials/samegame/samegame3/Block.qml b/examples/qml/tutorials/samegame/samegame3/Block.qml new file mode 100644 index 0000000000..9c41048fcb --- /dev/null +++ b/examples/qml/tutorials/samegame/samegame3/Block.qml @@ -0,0 +1,63 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +//![0] +import QtQuick 2.0 + +Item { + id: block + + property int type: 0 + + Image { + id: img + + anchors.fill: parent + source: { + if (type == 0) + return "../shared/pics/redStone.png"; + else if (type == 1) + return "../shared/pics/blueStone.png"; + else + return "../shared/pics/greenStone.png"; + } + } +} +//![0] diff --git a/examples/qml/tutorials/samegame/samegame3/Button.qml b/examples/qml/tutorials/samegame/samegame3/Button.qml new file mode 100644 index 0000000000..248c20cf0f --- /dev/null +++ b/examples/qml/tutorials/samegame/samegame3/Button.qml @@ -0,0 +1,81 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Rectangle { + id: container + + property string text: "Button" + + signal clicked + + width: buttonLabel.width + 20; height: buttonLabel.height + 5 + border { width: 1; color: Qt.darker(activePalette.button) } + smooth: true + radius: 8 + + // color the button with a gradient + gradient: Gradient { + GradientStop { + position: 0.0 + color: { + if (mouseArea.pressed) + return activePalette.dark + else + return activePalette.light + } + } + GradientStop { position: 1.0; color: activePalette.button } + } + + MouseArea { + id: mouseArea + anchors.fill: parent + onClicked: container.clicked(); + } + + Text { + id: buttonLabel + anchors.centerIn: container + color: activePalette.buttonText + text: container.text + } +} diff --git a/examples/qml/tutorials/samegame/samegame3/Dialog.qml b/examples/qml/tutorials/samegame/samegame3/Dialog.qml new file mode 100644 index 0000000000..df1fa37d6a --- /dev/null +++ b/examples/qml/tutorials/samegame/samegame3/Dialog.qml @@ -0,0 +1,71 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +//![0] +import QtQuick 2.0 + +Rectangle { + id: container + + function show(text) { + dialogText.text = text; + container.opacity = 1; + } + + function hide() { + container.opacity = 0; + } + + width: dialogText.width + 20 + height: dialogText.height + 20 + opacity: 0 + + Text { + id: dialogText + anchors.centerIn: parent + text: "" + } + + MouseArea { + anchors.fill: parent + onClicked: hide(); + } +} +//![0] diff --git a/examples/qml/tutorials/samegame/samegame3/samegame.js b/examples/qml/tutorials/samegame/samegame3/samegame.js new file mode 100644 index 0000000000..df5bdfb049 --- /dev/null +++ b/examples/qml/tutorials/samegame/samegame3/samegame.js @@ -0,0 +1,174 @@ +/* This script file handles the game logic */ +var maxColumn = 10; +var maxRow = 15; +var maxIndex = maxColumn * maxRow; +var board = new Array(maxIndex); +var component; + +//Index function used instead of a 2D array +function index(column, row) { + return column + (row * maxColumn); +} + +function startNewGame() { + //Calculate board size + maxColumn = Math.floor(gameCanvas.width / gameCanvas.blockSize); + maxRow = Math.floor(gameCanvas.height / gameCanvas.blockSize); + maxIndex = maxRow * maxColumn; + + //Close dialogs + dialog.hide(); + + //Initialize Board + board = new Array(maxIndex); + gameCanvas.score = 0; + for (var column = 0; column < maxColumn; column++) { + for (var row = 0; row < maxRow; row++) { + board[index(column, row)] = null; + createBlock(column, row); + } + } +} + +function createBlock(column, row) { + if (component == null) + component = Qt.createComponent("Block.qml"); + + // Note that if Block.qml was not a local file, component.status would be + // Loading and we should wait for the component's statusChanged() signal to + // know when the file is downloaded and ready before calling createObject(). + if (component.status == Component.Ready) { + var dynamicObject = component.createObject(gameCanvas); + if (dynamicObject == null) { + console.log("error creating block"); + console.log(component.errorString()); + return false; + } + dynamicObject.type = Math.floor(Math.random() * 3); + dynamicObject.x = column * gameCanvas.blockSize; + dynamicObject.y = row * gameCanvas.blockSize; + dynamicObject.width = gameCanvas.blockSize; + dynamicObject.height = gameCanvas.blockSize; + board[index(column, row)] = dynamicObject; + } else { + console.log("error loading block component"); + console.log(component.errorString()); + return false; + } + return true; +} + +var fillFound; //Set after a floodFill call to the number of blocks found +var floodBoard; //Set to 1 if the floodFill reaches off that node + +//![1] +function handleClick(xPos, yPos) { + var column = Math.floor(xPos / gameCanvas.blockSize); + var row = Math.floor(yPos / gameCanvas.blockSize); + if (column >= maxColumn || column < 0 || row >= maxRow || row < 0) + return; + if (board[index(column, row)] == null) + return; + //If it's a valid block, remove it and all connected (does nothing if it's not connected) + floodFill(column, row, -1); + if (fillFound <= 0) + return; + gameCanvas.score += (fillFound - 1) * (fillFound - 1); + shuffleDown(); + victoryCheck(); +} +//![1] + +function floodFill(column, row, type) { + if (board[index(column, row)] == null) + return; + var first = false; + if (type == -1) { + first = true; + type = board[index(column, row)].type; + + //Flood fill initialization + fillFound = 0; + floodBoard = new Array(maxIndex); + } + if (column >= maxColumn || column < 0 || row >= maxRow || row < 0) + return; + if (floodBoard[index(column, row)] == 1 || (!first && type != board[index(column, row)].type)) + return; + floodBoard[index(column, row)] = 1; + floodFill(column + 1, row, type); + floodFill(column - 1, row, type); + floodFill(column, row + 1, type); + floodFill(column, row - 1, type); + if (first == true && fillFound == 0) + return; //Can't remove single blocks + board[index(column, row)].opacity = 0; + board[index(column, row)] = null; + fillFound += 1; +} + +function shuffleDown() { + //Fall down + for (var column = 0; column < maxColumn; column++) { + var fallDist = 0; + for (var row = maxRow - 1; row >= 0; row--) { + if (board[index(column, row)] == null) { + fallDist += 1; + } else { + if (fallDist > 0) { + var obj = board[index(column, row)]; + obj.y += fallDist * gameCanvas.blockSize; + board[index(column, row + fallDist)] = obj; + board[index(column, row)] = null; + } + } + } + } + //Fall to the left + var fallDist = 0; + for (var column = 0; column < maxColumn; column++) { + if (board[index(column, maxRow - 1)] == null) { + fallDist += 1; + } else { + if (fallDist > 0) { + for (var row = 0; row < maxRow; row++) { + var obj = board[index(column, row)]; + if (obj == null) + continue; + obj.x -= fallDist * gameCanvas.blockSize; + board[index(column - fallDist, row)] = obj; + board[index(column, row)] = null; + } + } + } + } +} + +//![2] +function victoryCheck() { + //Award bonus points if no blocks left + var deservesBonus = true; + for (var column = maxColumn - 1; column >= 0; column--) + if (board[index(column, maxRow - 1)] != null) + deservesBonus = false; + if (deservesBonus) + gameCanvas.score += 500; + + //Check whether game has finished + if (deservesBonus || !(floodMoveCheck(0, maxRow - 1, -1))) + dialog.show("Game Over. Your score is " + gameCanvas.score); +} +//![2] + +//only floods up and right, to see if it can find adjacent same-typed blocks +function floodMoveCheck(column, row, type) { + if (column >= maxColumn || column < 0 || row >= maxRow || row < 0) + return false; + if (board[index(column, row)] == null) + return false; + var myType = board[index(column, row)].type; + if (type == myType) + return true; + return floodMoveCheck(column + 1, row, myType) || floodMoveCheck(column, row - 1, board[index(column, row)].type); +} + diff --git a/examples/qml/tutorials/samegame/samegame3/samegame.qml b/examples/qml/tutorials/samegame/samegame3/samegame.qml new file mode 100644 index 0000000000..f14829ef63 --- /dev/null +++ b/examples/qml/tutorials/samegame/samegame3/samegame.qml @@ -0,0 +1,109 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +//![0] +import QtQuick 2.0 +import "samegame.js" as SameGame + +Rectangle { + id: screen + + width: 490; height: 720 + + SystemPalette { id: activePalette } + + Item { + width: parent.width + anchors { top: parent.top; bottom: toolBar.top } + + Image { + id: background + anchors.fill: parent + source: "../shared/pics/background.jpg" + fillMode: Image.PreserveAspectCrop + } + +//![1] + Item { + id: gameCanvas + + property int score: 0 + property int blockSize: 40 + + width: parent.width - (parent.width % blockSize) + height: parent.height - (parent.height % blockSize) + anchors.centerIn: parent + + MouseArea { + anchors.fill: parent + onClicked: SameGame.handleClick(mouse.x, mouse.y) + } + } +//![1] + } + +//![2] + Dialog { + id: dialog + anchors.centerIn: parent + z: 100 + } +//![2] + + Rectangle { + id: toolBar + width: parent.width; height: 30 + color: activePalette.window + anchors.bottom: screen.bottom + + Button { + anchors { left: parent.left; verticalCenter: parent.verticalCenter } + text: "New Game" + onClicked: SameGame.startNewGame() + } + + Text { + id: score + anchors { right: parent.right; verticalCenter: parent.verticalCenter } + text: "Score: Who knows?" + } + } +} +//![0] diff --git a/examples/qml/tutorials/samegame/samegame3/samegame3.qmlproject b/examples/qml/tutorials/samegame/samegame3/samegame3.qmlproject new file mode 100644 index 0000000000..42ffacf4f8 --- /dev/null +++ b/examples/qml/tutorials/samegame/samegame3/samegame3.qmlproject @@ -0,0 +1,16 @@ +import QmlProject 1.1 + +Project { + mainFile: "samegame.qml" + + /* Include .qml, .js, and image files from current directory and subdirectories */ + QmlFiles { + directory: "." + } + JavaScriptFiles { + directory: "." + } + ImageFiles { + directory: "." + } +} diff --git a/examples/qml/tutorials/samegame/samegame4/content/BoomBlock.qml b/examples/qml/tutorials/samegame/samegame4/content/BoomBlock.qml new file mode 100644 index 0000000000..3786b9c0d1 --- /dev/null +++ b/examples/qml/tutorials/samegame/samegame4/content/BoomBlock.qml @@ -0,0 +1,122 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import Qt.labs.particles 1.0 + +Item { + id: block + + property int type: 0 + property bool dying: false + + //![1] + property bool spawned: false + + Behavior on x { + enabled: spawned; + SpringAnimation{ spring: 2; damping: 0.2 } + } + Behavior on y { + SpringAnimation{ spring: 2; damping: 0.2 } + } + //![1] + + //![2] + Image { + id: img + + anchors.fill: parent + source: { + if (type == 0) + return "../../shared/pics/redStone.png"; + else if (type == 1) + return "../../shared/pics/blueStone.png"; + else + return "../../shared/pics/greenStone.png"; + } + opacity: 0 + + Behavior on opacity { + NumberAnimation { properties:"opacity"; duration: 200 } + } + } + //![2] + + //![3] + Particles { + id: particles + + width: 1; height: 1 + anchors.centerIn: parent + + emissionRate: 0 + lifeSpan: 700; lifeSpanDeviation: 600 + angle: 0; angleDeviation: 360; + velocity: 100; velocityDeviation: 30 + source: { + if (type == 0) + return "../../shared/pics/redStar.png"; + else if (type == 1) + return "../../shared/pics/blueStar.png"; + else + return "../../shared/pics/greenStar.png"; + } + } + //![3] + + //![4] + states: [ + State { + name: "AliveState" + when: spawned == true && dying == false + PropertyChanges { target: img; opacity: 1 } + }, + + State { + name: "DeathState" + when: dying == true + StateChangeScript { script: particles.burst(50); } + PropertyChanges { target: img; opacity: 0 } + StateChangeScript { script: block.destroy(1000); } + } + ] + //![4] +} diff --git a/examples/qml/tutorials/samegame/samegame4/content/Button.qml b/examples/qml/tutorials/samegame/samegame4/content/Button.qml new file mode 100644 index 0000000000..248c20cf0f --- /dev/null +++ b/examples/qml/tutorials/samegame/samegame4/content/Button.qml @@ -0,0 +1,81 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Rectangle { + id: container + + property string text: "Button" + + signal clicked + + width: buttonLabel.width + 20; height: buttonLabel.height + 5 + border { width: 1; color: Qt.darker(activePalette.button) } + smooth: true + radius: 8 + + // color the button with a gradient + gradient: Gradient { + GradientStop { + position: 0.0 + color: { + if (mouseArea.pressed) + return activePalette.dark + else + return activePalette.light + } + } + GradientStop { position: 1.0; color: activePalette.button } + } + + MouseArea { + id: mouseArea + anchors.fill: parent + onClicked: container.clicked(); + } + + Text { + id: buttonLabel + anchors.centerIn: container + color: activePalette.buttonText + text: container.text + } +} diff --git a/examples/qml/tutorials/samegame/samegame4/content/Dialog.qml b/examples/qml/tutorials/samegame/samegame4/content/Dialog.qml new file mode 100644 index 0000000000..984b3ddb6a --- /dev/null +++ b/examples/qml/tutorials/samegame/samegame4/content/Dialog.qml @@ -0,0 +1,107 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +//![0] +Rectangle { + id: container +//![0] + +//![1] + property string inputText: textInput.text + signal closed + + function show(text) { + dialogText.text = text; + container.opacity = 1; + textInput.opacity = 0; + } + + function showWithInput(text) { + show(text); + textInput.opacity = 1; + textInput.focus = true; + textInput.text = "" + } + + function hide() { + textInput.focus = false; + container.opacity = 0; + container.closed(); + } +//![1] + + width: dialogText.width + textInput.width + 20 + height: dialogText.height + 20 + opacity: 0 + visible: opacity > 0 + + Text { + id: dialogText + anchors { verticalCenter: parent.verticalCenter; left: parent.left; leftMargin: 10 } + text: "" + } + +//![2] + TextInput { + id: textInput + anchors { verticalCenter: parent.verticalCenter; left: dialogText.right } + width: 80 + text: "" + + onAccepted: container.hide() // close dialog when Enter is pressed + } +//![2] + + MouseArea { + anchors.fill: parent + + onClicked: { + if (textInput.text == "" && textInput.opacity > 0) + textInput.openSoftwareInputPanel(); + else + hide(); + } + } + +//![3] +} +//![3] diff --git a/examples/qml/tutorials/samegame/samegame4/content/samegame.js b/examples/qml/tutorials/samegame/samegame4/content/samegame.js new file mode 100755 index 0000000000..7bb7243914 --- /dev/null +++ b/examples/qml/tutorials/samegame/samegame4/content/samegame.js @@ -0,0 +1,226 @@ +/* This script file handles the game logic */ +.import QtQuick.LocalStorage 2.0 as Sql + +var maxColumn = 10; +var maxRow = 15; +var maxIndex = maxColumn * maxRow; +var board = new Array(maxIndex); +var component; +var scoresURL = ""; +var gameDuration; + +//Index function used instead of a 2D array +function index(column, row) { + return column + (row * maxColumn); +} + +function startNewGame() { + //Delete blocks from previous game + for (var i = 0; i < maxIndex; i++) { + if (board[i] != null) + board[i].destroy(); + } + + //Calculate board size + maxColumn = Math.floor(gameCanvas.width / gameCanvas.blockSize); + maxRow = Math.floor(gameCanvas.height / gameCanvas.blockSize); + maxIndex = maxRow * maxColumn; + + //Close dialogs + nameInputDialog.hide(); + dialog.hide(); + + //Initialize Board + board = new Array(maxIndex); + gameCanvas.score = 0; + for (var column = 0; column < maxColumn; column++) { + for (var row = 0; row < maxRow; row++) { + board[index(column, row)] = null; + createBlock(column, row); + } + } + + gameDuration = new Date(); +} + +function createBlock(column, row) { + if (component == null) + component = Qt.createComponent("content/BoomBlock.qml"); + + // Note that if Block.qml was not a local file, component.status would be + // Loading and we should wait for the component's statusChanged() signal to + // know when the file is downloaded and ready before calling createObject(). + if (component.status == Component.Ready) { + var dynamicObject = component.createObject(gameCanvas); + if (dynamicObject == null) { + console.log("error creating block"); + console.log(component.errorString()); + return false; + } + dynamicObject.type = Math.floor(Math.random() * 3); + dynamicObject.x = column * gameCanvas.blockSize; + dynamicObject.y = row * gameCanvas.blockSize; + dynamicObject.width = gameCanvas.blockSize; + dynamicObject.height = gameCanvas.blockSize; + dynamicObject.spawned = true; + board[index(column, row)] = dynamicObject; + } else { + console.log("error loading block component"); + console.log(component.errorString()); + return false; + } + return true; +} + +var fillFound; //Set after a floodFill call to the number of blocks found +var floodBoard; //Set to 1 if the floodFill reaches off that node + +function handleClick(xPos, yPos) { + var column = Math.floor(xPos / gameCanvas.blockSize); + var row = Math.floor(yPos / gameCanvas.blockSize); + if (column >= maxColumn || column < 0 || row >= maxRow || row < 0) + return; + if (board[index(column, row)] == null) + return; + //If it's a valid block, remove it and all connected (does nothing if it's not connected) + floodFill(column, row, -1); + if (fillFound <= 0) + return; + gameCanvas.score += (fillFound - 1) * (fillFound - 1); + shuffleDown(); + victoryCheck(); +} + +function floodFill(column, row, type) { + if (board[index(column, row)] == null) + return; + var first = false; + if (type == -1) { + first = true; + type = board[index(column, row)].type; + + //Flood fill initialization + fillFound = 0; + floodBoard = new Array(maxIndex); + } + if (column >= maxColumn || column < 0 || row >= maxRow || row < 0) + return; + if (floodBoard[index(column, row)] == 1 || (!first && type != board[index(column, row)].type)) + return; + floodBoard[index(column, row)] = 1; + floodFill(column + 1, row, type); + floodFill(column - 1, row, type); + floodFill(column, row + 1, type); + floodFill(column, row - 1, type); + if (first == true && fillFound == 0) + return; //Can't remove single blocks + board[index(column, row)].dying = true; + board[index(column, row)] = null; + fillFound += 1; +} + +function shuffleDown() { + //Fall down + for (var column = 0; column < maxColumn; column++) { + var fallDist = 0; + for (var row = maxRow - 1; row >= 0; row--) { + if (board[index(column, row)] == null) { + fallDist += 1; + } else { + if (fallDist > 0) { + var obj = board[index(column, row)]; + obj.y = (row + fallDist) * gameCanvas.blockSize; + board[index(column, row + fallDist)] = obj; + board[index(column, row)] = null; + } + } + } + } + //Fall to the left + fallDist = 0; + for (column = 0; column < maxColumn; column++) { + if (board[index(column, maxRow - 1)] == null) { + fallDist += 1; + } else { + if (fallDist > 0) { + for (row = 0; row < maxRow; row++) { + obj = board[index(column, row)]; + if (obj == null) + continue; + obj.x = (column - fallDist) * gameCanvas.blockSize; + board[index(column - fallDist, row)] = obj; + board[index(column, row)] = null; + } + } + } + } +} + +//![3] +function victoryCheck() { +//![3] + //Award bonus points if no blocks left + var deservesBonus = true; + for (var column = maxColumn - 1; column >= 0; column--) + if (board[index(column, maxRow - 1)] != null) + deservesBonus = false; + if (deservesBonus) + gameCanvas.score += 500; + +//![4] + //Check whether game has finished + if (deservesBonus || !(floodMoveCheck(0, maxRow - 1, -1))) { + gameDuration = new Date() - gameDuration; + nameInputDialog.showWithInput("You won! Please enter your name: "); + } +} +//![4] + +//only floods up and right, to see if it can find adjacent same-typed blocks +function floodMoveCheck(column, row, type) { + if (column >= maxColumn || column < 0 || row >= maxRow || row < 0) + return false; + if (board[index(column, row)] == null) + return false; + var myType = board[index(column, row)].type; + if (type == myType) + return true; + return floodMoveCheck(column + 1, row, myType) || floodMoveCheck(column, row - 1, board[index(column, row)].type); +} + +//![2] +function saveHighScore(name) { + if (scoresURL != "") + sendHighScore(name); + + var db = Sql.openDatabaseSync("SameGameScores", "1.0", "Local SameGame High Scores", 100); + var dataStr = "INSERT INTO Scores VALUES(?, ?, ?, ?)"; + var data = [name, gameCanvas.score, maxColumn + "x" + maxRow, Math.floor(gameDuration / 1000)]; + db.transaction(function(tx) { + tx.executeSql('CREATE TABLE IF NOT EXISTS Scores(name TEXT, score NUMBER, gridSize TEXT, time NUMBER)'); + tx.executeSql(dataStr, data); + + var rs = tx.executeSql('SELECT * FROM Scores WHERE gridSize = "12x17" ORDER BY score desc LIMIT 10'); + var r = "\nHIGH SCORES for a standard sized grid\n\n" + for (var i = 0; i < rs.rows.length; i++) { + r += (i + 1) + ". " + rs.rows.item(i).name + ' got ' + rs.rows.item(i).score + ' points in ' + rs.rows.item(i).time + ' seconds.\n'; + } + dialog.show(r); + }); +} +//![2] + +//![1] +function sendHighScore(name) { + var postman = new XMLHttpRequest() + var postData = "name=" + name + "&score=" + gameCanvas.score + "&gridSize=" + maxColumn + "x" + maxRow + "&time=" + Math.floor(gameDuration / 1000); + postman.open("POST", scoresURL, true); + postman.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); + postman.onreadystatechange = function() { + if (postman.readyState == postman.DONE) { + dialog.show("Your score has been uploaded."); + } + } + postman.send(postData); +} +//![1] diff --git a/examples/qml/tutorials/samegame/samegame4/highscores/README b/examples/qml/tutorials/samegame/samegame4/highscores/README new file mode 100644 index 0000000000..eaa00fae37 --- /dev/null +++ b/examples/qml/tutorials/samegame/samegame4/highscores/README @@ -0,0 +1 @@ +The SameGame example can interface with a simple PHP script to store XML high score data on a remote server. We do not have a publically accessible server available for this use, but if you have access to a PHP capable webserver you can copy the files (score_data.xml, score.php, score_style.xsl) to it and alter the highscore_server variable at the top of the samegame.js file to point to it. diff --git a/examples/qml/tutorials/samegame/samegame4/highscores/score_data.xml b/examples/qml/tutorials/samegame/samegame4/highscores/score_data.xml new file mode 100755 index 0000000000..c3fd90d9cf --- /dev/null +++ b/examples/qml/tutorials/samegame/samegame4/highscores/score_data.xml @@ -0,0 +1,2 @@ +1000000Alan the Tester0x00 +6213Alan12x1751 diff --git a/examples/qml/tutorials/samegame/samegame4/highscores/score_style.xsl b/examples/qml/tutorials/samegame/samegame4/highscores/score_style.xsl new file mode 100755 index 0000000000..670354c965 --- /dev/null +++ b/examples/qml/tutorials/samegame/samegame4/highscores/score_style.xsl @@ -0,0 +1,28 @@ + + + + + SameGame High Scores + +

SameGame High Scores

+ + + + + + + + + + + + + + + + +
NameScoreGrid SizeTime, s
+ + + + diff --git a/examples/qml/tutorials/samegame/samegame4/highscores/scores.php b/examples/qml/tutorials/samegame/samegame4/highscores/scores.php new file mode 100755 index 0000000000..daf480e21b --- /dev/null +++ b/examples/qml/tutorials/samegame/samegame4/highscores/scores.php @@ -0,0 +1,31 @@ +"; + echo "SameGame High Scores"; + if($score > 0){#Sending in a new high score + $name = $_POST["name"]; + $grid = $_POST["gridSize"]; + $time = $_POST["time"]; + if($name == "") + $name = "Anonymous"; + $file = fopen("score_data.xml", "a"); + $ret = fwrite($file, "". $score . "" + . $name . "" . $grid . "" + . $time . "\n"); + echo "Your score has been recorded. Thanks for playing!"; + if($ret == False) + echo "
There was an error though, so don't expect to see that score again."; + }else{#Read high score list + #Now uses XSLT to display. So just print the file. With XML cruft added. + #Note that firefox at least won't apply the XSLT on a php file. So redirecting + $file = fopen("scores.xml", "w"); + $ret = fwrite($file, '' . "\n" + . '' . "\n" + . "\n" . file_get_contents("score_data.xml") . "\n"); + if($ret == False) + echo "There was an internal error. Sorry."; + else + echo ''; + } + echo ""; +?> diff --git a/examples/qml/tutorials/samegame/samegame4/samegame.qml b/examples/qml/tutorials/samegame/samegame4/samegame.qml new file mode 100644 index 0000000000..c21b8de8bd --- /dev/null +++ b/examples/qml/tutorials/samegame/samegame4/samegame.qml @@ -0,0 +1,115 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import "content" +import "content/samegame.js" as SameGame + +Rectangle { + id: screen + + width: 490; height: 720 + + SystemPalette { id: activePalette } + + Item { + width: parent.width + anchors { top: parent.top; bottom: toolBar.top } + + Image { + id: background + anchors.fill: parent + source: "../shared/pics/background.jpg" + fillMode: Image.PreserveAspectCrop + } + + Item { + id: gameCanvas + property int score: 0 + property int blockSize: 40 + + anchors.centerIn: parent + width: parent.width - (parent.width % blockSize); + height: parent.height - (parent.height % blockSize); + + MouseArea { + anchors.fill: parent; onClicked: SameGame.handleClick(mouse.x,mouse.y); + } + } + } + + Dialog { + id: dialog + anchors.centerIn: parent + z: 100 + } + + //![0] + Dialog { + id: nameInputDialog + anchors.centerIn: parent + z: 100 + + onClosed: { + if (nameInputDialog.inputText != "") + SameGame.saveHighScore(nameInputDialog.inputText); + } + } + //![0] + + Rectangle { + id: toolBar + width: parent.width; height: 30 + color: activePalette.window + anchors.bottom: screen.bottom + + Button { + anchors { left: parent.left; verticalCenter: parent.verticalCenter } + text: "New Game" + onClicked: SameGame.startNewGame() + } + + Text { + id: score + anchors { right: parent.right; verticalCenter: parent.verticalCenter } + text: "Score: " + gameCanvas.score + } + } +} diff --git a/examples/qml/tutorials/samegame/samegame4/samegame4.qmlproject b/examples/qml/tutorials/samegame/samegame4/samegame4.qmlproject new file mode 100644 index 0000000000..42ffacf4f8 --- /dev/null +++ b/examples/qml/tutorials/samegame/samegame4/samegame4.qmlproject @@ -0,0 +1,16 @@ +import QmlProject 1.1 + +Project { + mainFile: "samegame.qml" + + /* Include .qml, .js, and image files from current directory and subdirectories */ + QmlFiles { + directory: "." + } + JavaScriptFiles { + directory: "." + } + ImageFiles { + directory: "." + } +} diff --git a/examples/qml/tutorials/samegame/shared/pics/background.jpg b/examples/qml/tutorials/samegame/shared/pics/background.jpg new file mode 100644 index 0000000000..903d395c8d Binary files /dev/null and b/examples/qml/tutorials/samegame/shared/pics/background.jpg differ diff --git a/examples/qml/tutorials/samegame/shared/pics/blueStar.png b/examples/qml/tutorials/samegame/shared/pics/blueStar.png new file mode 100644 index 0000000000..ff9588f80a Binary files /dev/null and b/examples/qml/tutorials/samegame/shared/pics/blueStar.png differ diff --git a/examples/qml/tutorials/samegame/shared/pics/blueStone.png b/examples/qml/tutorials/samegame/shared/pics/blueStone.png new file mode 100644 index 0000000000..20e43c75b6 Binary files /dev/null and b/examples/qml/tutorials/samegame/shared/pics/blueStone.png differ diff --git a/examples/qml/tutorials/samegame/shared/pics/greenStar.png b/examples/qml/tutorials/samegame/shared/pics/greenStar.png new file mode 100644 index 0000000000..cd06854719 Binary files /dev/null and b/examples/qml/tutorials/samegame/shared/pics/greenStar.png differ diff --git a/examples/qml/tutorials/samegame/shared/pics/greenStone.png b/examples/qml/tutorials/samegame/shared/pics/greenStone.png new file mode 100644 index 0000000000..b568a1900c Binary files /dev/null and b/examples/qml/tutorials/samegame/shared/pics/greenStone.png differ diff --git a/examples/qml/tutorials/samegame/shared/pics/redStar.png b/examples/qml/tutorials/samegame/shared/pics/redStar.png new file mode 100644 index 0000000000..0a4dffe583 Binary files /dev/null and b/examples/qml/tutorials/samegame/shared/pics/redStar.png differ diff --git a/examples/qml/tutorials/samegame/shared/pics/redStone.png b/examples/qml/tutorials/samegame/shared/pics/redStone.png new file mode 100644 index 0000000000..36b09a2686 Binary files /dev/null and b/examples/qml/tutorials/samegame/shared/pics/redStone.png differ diff --git a/examples/qml/tutorials/samegame/shared/pics/star.png b/examples/qml/tutorials/samegame/shared/pics/star.png new file mode 100644 index 0000000000..defbde53ca Binary files /dev/null and b/examples/qml/tutorials/samegame/shared/pics/star.png differ diff --git a/examples/qml/tutorials/samegame/shared/pics/yellowStone.png b/examples/qml/tutorials/samegame/shared/pics/yellowStone.png new file mode 100644 index 0000000000..b1ce76212c Binary files /dev/null and b/examples/qml/tutorials/samegame/shared/pics/yellowStone.png differ diff --git a/examples/qml/tutorials/tutorials.pro b/examples/qml/tutorials/tutorials.pro new file mode 100644 index 0000000000..0a82c1e704 --- /dev/null +++ b/examples/qml/tutorials/tutorials.pro @@ -0,0 +1,5 @@ +TEMPLATE = subdirs + +SUBDIRS += \ + extending + diff --git a/examples/qml/tutorials/tutorials.qmlproject b/examples/qml/tutorials/tutorials.qmlproject new file mode 100644 index 0000000000..2bb4016996 --- /dev/null +++ b/examples/qml/tutorials/tutorials.qmlproject @@ -0,0 +1,14 @@ +import QmlProject 1.0 + +Project { + /* Include .qml, .js, and image files from current directory and subdirectories */ + QmlFiles { + directory: "." + } + JavaScriptFiles { + directory: "." + } + ImageFiles { + directory: "." + } +} diff --git a/examples/qml/twitter/TwitterCore/Button.qml b/examples/qml/twitter/TwitterCore/Button.qml new file mode 100644 index 0000000000..353b993742 --- /dev/null +++ b/examples/qml/twitter/TwitterCore/Button.qml @@ -0,0 +1,90 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtQml module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Item { + id: container + + signal clicked + + property string text + property bool keyUsing: false + + BorderImage { + id: buttonImage + source: "images/toolbutton.sci" + width: container.width; height: container.height + } + BorderImage { + id: pressed + opacity: 0 + source: "images/toolbutton.sci" + width: container.width; height: container.height + } + MouseArea { + id: mouseRegion + anchors.fill: buttonImage + onClicked: { container.clicked(); } + } + Text { + id: btnText + color: if(container.keyUsing){"#D0D0D0";} else {"#FFFFFF";} + anchors.centerIn: buttonImage; font.bold: true + text: container.text; style: Text.Raised; styleColor: "black" + font.pixelSize: 12 + } + states: [ + State { + name: "Pressed" + when: mouseRegion.pressed == true + PropertyChanges { target: pressed; opacity: 1 } + }, + State { + name: "Focused" + when: container.activeFocus == true + PropertyChanges { target: btnText; color: "#FFFFFF" } + } + ] + transitions: Transition { + ColorAnimation { target: btnText; } + } +} diff --git a/examples/qml/twitter/TwitterCore/FatDelegate.qml b/examples/qml/twitter/TwitterCore/FatDelegate.qml new file mode 100644 index 0000000000..4cb0dfc713 --- /dev/null +++ b/examples/qml/twitter/TwitterCore/FatDelegate.qml @@ -0,0 +1,105 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtQml module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Component { + id: listDelegate + Item { + id: wrapper; width: wrapper.ListView.view.width; height: if(txt.height > 60){txt.height+10}else{60} //50+5+5 + function handleLink(link){ + if(link.slice(0,3) == 'app'){ + screen.setUser(link.slice(7)); + }else if(link.slice(0,4) == 'http'){ + Qt.openUrlExternally(link); + } + } + function addTags(str){ + var ret = str.replace(/@[a-zA-Z0-9_]+/g, '$&');//click to jump to user? + var ret2 = ret.replace(/http:\/\/[^ \n\t]+/g, '$&');//surrounds http links with html link tags + return ret2; + } + + // Strip away paranthesis + function userName(str) { + var user = str.replace(/\([\S|\s]*\)/gi, ""); + return user.trim(); + } + + Item { + id: moveMe; height: parent.height + Rectangle { + id: blackRect + color: "black"; opacity: wrapper.ListView.index % 2 ? 0.2 : 0.3; height: wrapper.height-2; width: wrapper.width; y: 1 + } + Item { + id: image; x: 6; width: 48; height: 48; smooth: true + anchors.verticalCenter: parent.verticalCenter + + Loading { x: 1; y: 1; width: 48; height: 48; visible: realImage.status != Image.Ready } + Image { + id: realImage; + source: userImage; x: 1; y: 1; + width:48; height:48; opacity:0 ; + onStatusChanged: { + if(status==Image.Ready) + image.state="loaded" + } + } + states: State { + name: "loaded"; + PropertyChanges { target: realImage ; opacity:1 } + } + transitions: Transition { NumberAnimation { target: realImage; property: "opacity"; duration: 200 } } + + } + Text { id:txt; y:4; x: 56 + text: '' + + ''+userName(name) + " from " +source + + "
" + statusText + ""; + textFormat: Text.StyledText + color: "#cccccc"; style: Text.Raised; styleColor: "black"; wrapMode: Text.WordWrap; linkColor: "#aaccaa" + anchors.left: image.right; anchors.right: blackRect.right; anchors.leftMargin: 6; anchors.rightMargin: 6 + onLinkActivated: wrapper.handleLink(link) + } + } + } +} diff --git a/examples/qml/twitter/TwitterCore/Input.qml b/examples/qml/twitter/TwitterCore/Input.qml new file mode 100644 index 0000000000..68b1c6186a --- /dev/null +++ b/examples/qml/twitter/TwitterCore/Input.qml @@ -0,0 +1,65 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtQml module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +FocusScope { + id:container + width: 220 + height: 28 + BorderImage { source: "images/lineedit.sci"; anchors.fill: parent } + signal accepted + property alias text: input.text + property alias item:input + TextInput{ + id: input + width: parent.width - 12 + anchors.centerIn: parent + maximumLength:21 + font.pixelSize: 16; + font.bold: true + color: "#151515"; selectionColor: "mediumseagreen" + focus: true + onAccepted:{container.accepted()} + text: "" + selectByMouse: true + } +} diff --git a/examples/qml/twitter/TwitterCore/Loading.qml b/examples/qml/twitter/TwitterCore/Loading.qml new file mode 100644 index 0000000000..566857b8b2 --- /dev/null +++ b/examples/qml/twitter/TwitterCore/Loading.qml @@ -0,0 +1,49 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtQml module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Image { + id: loading; source: "images/loading.png" + NumberAnimation on rotation { + from: 0; to: 360; running: loading.visible == true; loops: Animation.Infinite; duration: 900 + } +} diff --git a/examples/qml/twitter/TwitterCore/MultiTitleBar.qml b/examples/qml/twitter/TwitterCore/MultiTitleBar.qml new file mode 100644 index 0000000000..3920520b7a --- /dev/null +++ b/examples/qml/twitter/TwitterCore/MultiTitleBar.qml @@ -0,0 +1,60 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtQml module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Item { + TitleBar { id: titleBar; width: parent.width; height: 60; + y: -80 + untaggedString: "Latest tweets from everyone" + taggedString: "Latest tweets from " + } + states: [ + State { + name: "search"; when: screen.state!="search" + PropertyChanges { target: titleBar; y: 0 } + } + ] + transitions: [ + Transition { NumberAnimation { properties: "x,y"; duration: 500; easing.type: Easing.InOutQuad } } + ] +} + diff --git a/examples/qml/twitter/TwitterCore/RssModel.qml b/examples/qml/twitter/TwitterCore/RssModel.qml new file mode 100644 index 0000000000..27f7495be2 --- /dev/null +++ b/examples/qml/twitter/TwitterCore/RssModel.qml @@ -0,0 +1,80 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtQml module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import QtQuick.XmlListModel 2.0 + +Item { id: wrapper + property variant model: xmlModel + property string from : "" + property string to : "" + property string phrase : "" + + property string mode : "everyone" + property int status: xmlModel.status + function reload() { xmlModel.reload(); } + + XmlListModel { + id: xmlModel + + function encodePhrase(x) { return encodeURIComponent(x); } + + source: (from=="" && to=="" && phrase=="") ? "" : + 'http://search.twitter.com/search.atom?from='+from+"&to="+to+"&phrase="+encodePhrase(phrase) + + namespaceDeclarations: "declare default element namespace 'http://www.w3.org/2005/Atom'; " + + "declare namespace twitter=\"http://api.twitter.com/\";"; + + query: "/feed/entry" + + XmlRole { name: "statusText"; query: "content/string()" } + XmlRole { name: "timestamp"; query: "published/string()" } + XmlRole { name: "source"; query: "twitter:source/string()" } + XmlRole { name: "name"; query: "author/name/string()" } + XmlRole { name: "userImage"; query: "link[@rel = 'image']/@href/string()" } + + } + Binding { + property: "mode" + target: wrapper + value: {if(wrapper.tags==''){"everyone";}else if(wrapper.tags=='my timeline'){"self";}else{"user";}} + } +} diff --git a/examples/qml/twitter/TwitterCore/SearchView.qml b/examples/qml/twitter/TwitterCore/SearchView.qml new file mode 100644 index 0000000000..7732e6f68d --- /dev/null +++ b/examples/qml/twitter/TwitterCore/SearchView.qml @@ -0,0 +1,124 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtQml module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +FocusScope { + id: wrapper + Column { + anchors.centerIn: parent + spacing: 20 + Column{ + spacing: 4 + Text { + text: "Posted by:" + font.pixelSize: 16; font.bold: true; color: "white"; style: Text.Raised; styleColor: "black" + horizontalAlignment: Qt.AlignRight + } + Input{ + id: fromIn + KeyNavigation.backtab: searchbutton + KeyNavigation.tab:toIn + onAccepted:searchbutton.doSearch(); + focus: true + } + Text { + text: "In reply to:" + font.pixelSize: 16; font.bold: true; color: "white"; style: Text.Raised; styleColor: "black" + horizontalAlignment: Qt.AlignRight + } + Input{ + id: toIn + KeyNavigation.backtab: fromIn + KeyNavigation.tab:phraseIn + onAccepted:searchbutton.doSearch(); + } + Text { + text: "Search phrase:" + font.pixelSize: 16; font.bold: true; color: "white"; style: Text.Raised; styleColor: "black" + horizontalAlignment: Qt.AlignRight + } + Input{ + id: phraseIn + KeyNavigation.backtab: toIn + KeyNavigation.tab:searchbutton + onAccepted:searchbutton.doSearch(); + text: "Qt Quick" + } + } + Button { + width: 100 + height: 32 + id: searchbutton + keyUsing: true; + opacity: 1 + text: "Search" + KeyNavigation.tab: fromIn + Keys.onReturnPressed: searchbutton.doSearch(); + Keys.onEnterPressed: searchbutton.doSearch(); + Keys.onSelectPressed: searchbutton.doSearch(); + Keys.onSpacePressed: searchbutton.doSearch(); + onClicked: searchbutton.doSearch(); + + function doSearch() { + // Search ! allowed + if (wrapper.state=="invalidinput") + return; + + rssModel.from=fromIn.text; + rssModel.to= toIn.text; + rssModel.phrase = phraseIn.text; + screen.focus = true; + screen.state = "" + } + } + } + states: + State { + name: "invalidinput" + when: fromIn.text=="" && toIn.text=="" && phraseIn.text=="" + PropertyChanges { target: searchbutton ; opacity: 0.6 ; } + } + transitions: + Transition { + NumberAnimation { target: searchbutton; property: "opacity"; duration: 200 } + } +} diff --git a/examples/qml/twitter/TwitterCore/TitleBar.qml b/examples/qml/twitter/TwitterCore/TitleBar.qml new file mode 100644 index 0000000000..3e0818b0dd --- /dev/null +++ b/examples/qml/twitter/TwitterCore/TitleBar.qml @@ -0,0 +1,130 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtQml module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Item { + id: titleBar + property string untaggedString: "Uploads from everyone" + property string taggedString: "Recent uploads tagged " + + BorderImage { source: "images/titlebar.sci"; width: parent.width; height: parent.height + 14; y: -7 } + + Item { + id: container + width: (parent.width * 2) - 55 ; height: parent.height + + function accept() { + titleBar.state = "" + background.state = "" + rssModel.tags = editor.text + } + + Item { + id:imageBox + x: 6; width: 0; height: 50; smooth: true + anchors.verticalCenter: parent.verticalCenter + + UserModel { user: rssModel.from; id: userModel } + Component { + id: imgDelegate; + Item { + id:imageitem + visible:true + Loading { width:48; height:48; visible: realImage.status != Image.Ready } + Image { id: realImage; source: image; width:48; height:48; opacity:0; } + states: + State { + name: "loaded" + when: (realImage.status == Image.Ready) + PropertyChanges { target: realImage; opacity:1 } + } + transitions: Transition { + NumberAnimation { target: realImage; property: "opacity"; duration: 200 } + } + } + } + ListView { id:view; model: userModel.model; x:1; y:1; delegate: imgDelegate } + states: + State { + when: !userModel.user=="" + PropertyChanges { target: imageBox; width: 50; } + } + transitions: + Transition { + NumberAnimation { target: imageBox; property: "width"; duration: 200 } + } + } + + Image { + id: quitButton + x: 5 + anchors.verticalCenter: parent.verticalCenter + source: "images/quit.png" + MouseArea { + anchors.fill: parent + onClicked: Qt.quit() + } + } + + Text { + id: categoryText + anchors { + left: quitButton.right; right: parent.right; leftMargin: 10; rightMargin: 10 + verticalCenter: parent.verticalCenter + } + elide: Text.ElideLeft + text: (rssModel.from=="" ? untaggedString : taggedString + rssModel.from) + font.bold: true; color: "White"; style: Text.Raised; styleColor: "Black" + font.pixelSize: 12 + } + } + + states: State { + name: "Tags" + PropertyChanges { target: container; x: -tagButton.x + 5 } + PropertyChanges { target: editor; focus: true } + } + + transitions: Transition { + NumberAnimation { properties: "x"; easing.type: Easing.InOutQuad } + } +} diff --git a/examples/qml/twitter/TwitterCore/ToolBar.qml b/examples/qml/twitter/TwitterCore/ToolBar.qml new file mode 100644 index 0000000000..d4265f3e98 --- /dev/null +++ b/examples/qml/twitter/TwitterCore/ToolBar.qml @@ -0,0 +1,64 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtQml module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Item { + id: toolbar + + property alias button1Label: button1.text + property alias button2Label: button2.text + signal button1Clicked + signal button2Clicked + focus:true + BorderImage { source: "images/titlebar.sci"; width: parent.width; height: parent.height + 14; y: -7 } + Button { + id: button1 + anchors.left: parent.left; anchors.leftMargin: 5; y: 3; width: 140; height: 32 + onClicked: toolbar.button1Clicked() + focus:true + } + Button { + id: button2 + anchors.right: parent.right; anchors.rightMargin: 5; y: 3; width: 140; height: 32 + onClicked: toolbar.button2Clicked() + } +} diff --git a/examples/qml/twitter/TwitterCore/UserModel.qml b/examples/qml/twitter/TwitterCore/UserModel.qml new file mode 100644 index 0000000000..428089b539 --- /dev/null +++ b/examples/qml/twitter/TwitterCore/UserModel.qml @@ -0,0 +1,66 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtQml module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import QtQuick.XmlListModel 2.0 + +//This "model" gets the user information about the searched user. Mainly for the icon. + +Item { id: wrapper + property variant model: xmlModel + property string user : "" + property int status: xmlModel.status + function reload() { xmlModel.reload(); } + XmlListModel { + id: xmlModel + + source: user!= "" ? "http://twitter.com/users/show.xml?screen_name="+user : "" + query: "/user" + + XmlRole { name: "name"; query: "name/string()" } + XmlRole { name: "screenName"; query: "screen_name/string()" } + XmlRole { name: "image"; query: "profile_image_url/string()" } + XmlRole { name: "location"; query: "location/string()" } + XmlRole { name: "description"; query: "description/string()" } + XmlRole { name: "followers"; query: "followers_count/string()" } + //TODO: Could also get the user's color scheme, timezone and a few other things + } +} diff --git a/examples/qml/twitter/TwitterCore/images/gloss.png b/examples/qml/twitter/TwitterCore/images/gloss.png new file mode 100644 index 0000000000..5d370cd93d Binary files /dev/null and b/examples/qml/twitter/TwitterCore/images/gloss.png differ diff --git a/examples/qml/twitter/TwitterCore/images/lineedit.png b/examples/qml/twitter/TwitterCore/images/lineedit.png new file mode 100644 index 0000000000..2cc38dc35b Binary files /dev/null and b/examples/qml/twitter/TwitterCore/images/lineedit.png differ diff --git a/examples/qml/twitter/TwitterCore/images/lineedit.sci b/examples/qml/twitter/TwitterCore/images/lineedit.sci new file mode 100644 index 0000000000..054bff78be --- /dev/null +++ b/examples/qml/twitter/TwitterCore/images/lineedit.sci @@ -0,0 +1,5 @@ +border.left: 10 +border.top: 10 +border.bottom: 10 +border.right: 10 +source: lineedit.png diff --git a/examples/qml/twitter/TwitterCore/images/loading.png b/examples/qml/twitter/TwitterCore/images/loading.png new file mode 100644 index 0000000000..47a1589c5d Binary files /dev/null and b/examples/qml/twitter/TwitterCore/images/loading.png differ diff --git a/examples/qml/twitter/TwitterCore/images/quit.png b/examples/qml/twitter/TwitterCore/images/quit.png new file mode 100644 index 0000000000..5bda1b6e0d Binary files /dev/null and b/examples/qml/twitter/TwitterCore/images/quit.png differ diff --git a/examples/qml/twitter/TwitterCore/images/stripes.png b/examples/qml/twitter/TwitterCore/images/stripes.png new file mode 100644 index 0000000000..9f36727ea4 Binary files /dev/null and b/examples/qml/twitter/TwitterCore/images/stripes.png differ diff --git a/examples/qml/twitter/TwitterCore/images/titlebar.png b/examples/qml/twitter/TwitterCore/images/titlebar.png new file mode 100644 index 0000000000..51c90082d0 Binary files /dev/null and b/examples/qml/twitter/TwitterCore/images/titlebar.png differ diff --git a/examples/qml/twitter/TwitterCore/images/titlebar.sci b/examples/qml/twitter/TwitterCore/images/titlebar.sci new file mode 100644 index 0000000000..0418d94cd6 --- /dev/null +++ b/examples/qml/twitter/TwitterCore/images/titlebar.sci @@ -0,0 +1,5 @@ +border.left: 10 +border.top: 12 +border.bottom: 12 +border.right: 10 +source: titlebar.png diff --git a/examples/qml/twitter/TwitterCore/images/toolbutton.png b/examples/qml/twitter/TwitterCore/images/toolbutton.png new file mode 100644 index 0000000000..11310013ee Binary files /dev/null and b/examples/qml/twitter/TwitterCore/images/toolbutton.png differ diff --git a/examples/qml/twitter/TwitterCore/images/toolbutton.sci b/examples/qml/twitter/TwitterCore/images/toolbutton.sci new file mode 100644 index 0000000000..9e4f965307 --- /dev/null +++ b/examples/qml/twitter/TwitterCore/images/toolbutton.sci @@ -0,0 +1,5 @@ +border.left: 15 +border.top: 4 +border.bottom: 4 +border.right: 15 +source: toolbutton.png diff --git a/examples/qml/twitter/TwitterCore/qmldir b/examples/qml/twitter/TwitterCore/qmldir new file mode 100644 index 0000000000..452a648b23 --- /dev/null +++ b/examples/qml/twitter/TwitterCore/qmldir @@ -0,0 +1,10 @@ +SearchView 2.0 SearchView.qml +Button 2.0 Button.qml +Input 2.0 Input.qml +FatDelegate 2.0 FatDelegate.qml +Loading 2.0 Loading.qml +MultiTitleBar 2.0 MultiTitleBar.qml +TitleBar 2.0 TitleBar.qml +RssModel 2.0 RssModel.qml +UserModel 2.0 UserModel.qml +ToolBar 2.0 ToolBar.qml diff --git a/examples/qml/twitter/twitter.qml b/examples/qml/twitter/twitter.qml new file mode 100644 index 0000000000..aca0968cfb --- /dev/null +++ b/examples/qml/twitter/twitter.qml @@ -0,0 +1,135 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtQml module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import QtQuick.XmlListModel 2.0 +import "TwitterCore" 2.0 as Twitter + +Item { + id: screen; width: 320; height: 480 + property bool userView : false + property variant tmpStr + function setUser(str){hack.running = true; tmpStr = str} + function reallySetUser(){rssModel.from = tmpStr;rssModel.to = ""; rssModel.phrase = ""} + state:"searchquery" + //Workaround for bug 260266 + Timer{ interval: 1; running: false; repeat: false; onTriggered: screen.reallySetUser(); id:hack } + Keys.onEscapePressed: screen.state="searchquery" + Keys.onBacktabPressed: screen.state="searchquery" + Rectangle { + id: background + anchors.fill: parent; color: "#343434"; + + state:"searchquery" + Image { source: "TwitterCore/images/stripes.png"; fillMode: Image.Tile; anchors.fill: parent; opacity: 0.3 } + + MouseArea { + anchors.fill: parent + onClicked: screen.focus = false; + } + + Twitter.RssModel { id: rssModel } + Twitter.Loading { anchors.centerIn: parent; visible: rssModel.status==XmlListModel.Loading && state!='unauthed'} + Text { + width: 180 + text: "Could not access twitter using this screen name and password pair."; + color: "#cccccc"; style: Text.Raised; styleColor: "black"; wrapMode: Text.WordWrap + visible: rssModel.status==XmlListModel.Error; anchors.centerIn: parent + } + + Item { + id: views + x: 2; width: parent.width - 4 + y:60 //Below the title bars + height: parent.height - 100 + + Text { + id:title + text: "Search Twitter" + anchors.horizontalCenter: parent.horizontalCenter + font.pixelSize: 20; font.bold: true; color: "#bbb"; style: Text.Raised; styleColor: "black" + opacity:0 + } + + Twitter.SearchView{ + id: searchView + anchors.verticalCenter: parent.verticalCenter + width: parent.width; height: parent.height-60; + x: -(screen.width * 1.5) + } + + Twitter.FatDelegate { id: fatDelegate } + ListView { + id: mainView; model: rssModel.model; delegate: fatDelegate; + width: parent.width; height: parent.height; x: 0; cacheBuffer: 100; + } + } + + Twitter.MultiTitleBar { id: titleBar; width: parent.width } + Twitter.ToolBar { id: toolBar; height: 40; + //anchors.bottom: parent.bottom; + //TODO: Use anchor changes instead of hard coding + y: screen.height - 40 + width: parent.width; opacity: 0.9 + button1Label: "New Search" + button2Label: "Update" + onButton1Clicked: + { + screen.state="searchquery" + } + onButton2Clicked: rssModel.reload(); + } + } + states: [ + State { + name: "searchquery"; + PropertyChanges { target: searchView; x: 0; focus:true} + PropertyChanges { target: mainView; x: -(parent.width * 1.5) } + PropertyChanges { target: titleBar; y: -80 } + PropertyChanges { target: toolBar; y: screen.height } + PropertyChanges { target: toolBar } + PropertyChanges { target: title; opacity:1} + } + ] + transitions: [ + Transition { NumberAnimation { properties: "x,y,opacity"; duration: 500; easing.type: Easing.InOutQuad } } + ] +} diff --git a/examples/qml/twitter/twitter.qmlproject b/examples/qml/twitter/twitter.qmlproject new file mode 100644 index 0000000000..b14f71fdfd --- /dev/null +++ b/examples/qml/twitter/twitter.qmlproject @@ -0,0 +1,16 @@ +import QmlProject 1.1 + +Project { + mainFile: "twitter.qml" + + /* Include .qml, .js, and image files from current directory and subdirectories */ + QmlFiles { + directory: "." + } + JavaScriptFiles { + directory: "." + } + ImageFiles { + directory: "." + } +} diff --git a/examples/qml/ui-components/dialcontrol/content/Dial.qml b/examples/qml/ui-components/dialcontrol/content/Dial.qml new file mode 100644 index 0000000000..c61adee364 --- /dev/null +++ b/examples/qml/ui-components/dialcontrol/content/Dial.qml @@ -0,0 +1,86 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Item { + id: root + property real value : 0 + + width: 210; height: 210 + + Image { source: "background.png" } + +//! [needle_shadow] + Image { + x: 96 + y: 35 + source: "needle_shadow.png" + transform: Rotation { + origin.x: 9; origin.y: 67 + angle: needleRotation.angle + } + } +//! [needle_shadow] +//! [needle] + Image { + id: needle + x: 98; y: 33 + smooth: true + source: "needle.png" + transform: Rotation { + id: needleRotation + origin.x: 5; origin.y: 65 + //! [needle angle] + angle: Math.min(Math.max(-130, root.value*2.6 - 130), 133) + Behavior on angle { + SpringAnimation { + spring: 1.4 + damping: .15 + } + } + //! [needle angle] + } + } +//! [needle] +//! [overlay] + Image { x: 21; y: 18; source: "overlay.png" } +//! [overlay] +} diff --git a/examples/qml/ui-components/dialcontrol/content/QuitButton.qml b/examples/qml/ui-components/dialcontrol/content/QuitButton.qml new file mode 100644 index 0000000000..702b892d23 --- /dev/null +++ b/examples/qml/ui-components/dialcontrol/content/QuitButton.qml @@ -0,0 +1,52 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +Image { + source: "quit.png" + scale: quitMouse.pressed ? 0.8 : 1.0 + smooth: quitMouse.pressed + MouseArea { + id: quitMouse + anchors.fill: parent + anchors.margins: -10 + onClicked: Qt.quit() + } +} diff --git a/examples/qml/ui-components/dialcontrol/content/background.png b/examples/qml/ui-components/dialcontrol/content/background.png new file mode 100644 index 0000000000..75d555d7ab Binary files /dev/null and b/examples/qml/ui-components/dialcontrol/content/background.png differ diff --git a/examples/qml/ui-components/dialcontrol/content/needle.png b/examples/qml/ui-components/dialcontrol/content/needle.png new file mode 100644 index 0000000000..2d19f75039 Binary files /dev/null and b/examples/qml/ui-components/dialcontrol/content/needle.png differ diff --git a/examples/qml/ui-components/dialcontrol/content/needle_shadow.png b/examples/qml/ui-components/dialcontrol/content/needle_shadow.png new file mode 100644 index 0000000000..8d8a928cc5 Binary files /dev/null and b/examples/qml/ui-components/dialcontrol/content/needle_shadow.png differ diff --git a/examples/qml/ui-components/dialcontrol/content/overlay.png b/examples/qml/ui-components/dialcontrol/content/overlay.png new file mode 100644 index 0000000000..3860a7b590 Binary files /dev/null and b/examples/qml/ui-components/dialcontrol/content/overlay.png differ diff --git a/examples/qml/ui-components/dialcontrol/content/quit.png b/examples/qml/ui-components/dialcontrol/content/quit.png new file mode 100644 index 0000000000..b822057d4e Binary files /dev/null and b/examples/qml/ui-components/dialcontrol/content/quit.png differ diff --git a/examples/qml/ui-components/dialcontrol/dialcontrol.qml b/examples/qml/ui-components/dialcontrol/dialcontrol.qml new file mode 100644 index 0000000000..d645b34aa4 --- /dev/null +++ b/examples/qml/ui-components/dialcontrol/dialcontrol.qml @@ -0,0 +1,98 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +//! [imports] +import QtQuick 2.0 +import "content" +//! [imports] + +//! [0] +Rectangle { + color: "#545454" + width: 300; height: 300 + + // Dial with a slider to adjust it + Dial { + id: dial + anchors.centerIn: parent + value: slider.x * 100 / (container.width - 34) + } + + Rectangle { + id: container + anchors { bottom: parent.bottom; left: parent.left + right: parent.right; leftMargin: 20; rightMargin: 20 + bottomMargin: 10 + } + height: 16 + + radius: 8 + opacity: 0.7 + smooth: true + gradient: Gradient { + GradientStop { position: 0.0; color: "gray" } + GradientStop { position: 1.0; color: "white" } + } + + Rectangle { + id: slider + x: 1; y: 1; width: 30; height: 14 + radius: 6 + smooth: true + gradient: Gradient { + GradientStop { position: 0.0; color: "#424242" } + GradientStop { position: 1.0; color: "black" } + } + + MouseArea { + anchors.fill: parent + anchors.margins: -16 // Increase mouse area a lot outside the slider + drag.target: parent; drag.axis: Drag.XAxis + drag.minimumX: 2; drag.maximumX: container.width - 32 + } + } + } + QuitButton { + anchors.right: parent.right + anchors.top: parent.top + anchors.margins: 10 + } +} +//! [0] diff --git a/examples/qml/ui-components/flipable/content/5_heart.png b/examples/qml/ui-components/flipable/content/5_heart.png new file mode 100644 index 0000000000..fb59d81453 Binary files /dev/null and b/examples/qml/ui-components/flipable/content/5_heart.png differ diff --git a/examples/qml/ui-components/flipable/content/9_club.png b/examples/qml/ui-components/flipable/content/9_club.png new file mode 100644 index 0000000000..2545001904 Binary files /dev/null and b/examples/qml/ui-components/flipable/content/9_club.png differ diff --git a/examples/qml/ui-components/flipable/content/Card.qml b/examples/qml/ui-components/flipable/content/Card.qml new file mode 100644 index 0000000000..6006ea14fc --- /dev/null +++ b/examples/qml/ui-components/flipable/content/Card.qml @@ -0,0 +1,80 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Flipable { + id: container + + property alias source: frontImage.source + property bool flipped: true + property int xAxis: 0 + property int yAxis: 0 + property int angle: 0 + + width: front.width; height: front.height + + front: Image { id: frontImage; smooth: true } + back: Image { source: "back.png"; smooth: true } + + state: "back" + + MouseArea { anchors.fill: parent; onClicked: container.flipped = !container.flipped } + + transform: Rotation { + id: rotation; origin.x: container.width / 2; origin.y: container.height / 2 + axis.x: container.xAxis; axis.y: container.yAxis; axis.z: 0 + } + + states: State { + name: "back"; when: container.flipped + PropertyChanges { target: rotation; angle: container.angle } + } + + transitions: Transition { + ParallelAnimation { + NumberAnimation { target: rotation; properties: "angle"; duration: 600 } + SequentialAnimation { + NumberAnimation { target: container; property: "scale"; to: 0.75; duration: 300 } + NumberAnimation { target: container; property: "scale"; to: 1.0; duration: 300 } + } + } + } +} diff --git a/examples/qml/ui-components/flipable/content/back.png b/examples/qml/ui-components/flipable/content/back.png new file mode 100644 index 0000000000..f715d7487e Binary files /dev/null and b/examples/qml/ui-components/flipable/content/back.png differ diff --git a/examples/qml/ui-components/flipable/flipable.qml b/examples/qml/ui-components/flipable/flipable.qml new file mode 100644 index 0000000000..4af64afc53 --- /dev/null +++ b/examples/qml/ui-components/flipable/flipable.qml @@ -0,0 +1,55 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import "content" + +Rectangle { + id: window + + width: 480; height: 320 + color: "darkgreen" + + Row { + anchors.centerIn: parent; spacing: 30 + Card { source: "content/9_club.png"; angle: 180; yAxis: 1 } + Card { source: "content/5_heart.png"; angle: 540; xAxis: 1 } + } +} diff --git a/examples/qml/ui-components/progressbar/content/ProgressBar.qml b/examples/qml/ui-components/progressbar/content/ProgressBar.qml new file mode 100644 index 0000000000..c9be8d7336 --- /dev/null +++ b/examples/qml/ui-components/progressbar/content/ProgressBar.qml @@ -0,0 +1,83 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Item { + id: progressbar + + property int minimum: 0 + property int maximum: 100 + property int value: 0 + property alias color: gradient1.color + property alias secondColor: gradient2.color + + width: 250; height: 23 + clip: true + + BorderImage { + source: "background.png" + width: parent.width; height: parent.height + border { left: 4; top: 4; right: 4; bottom: 4 } + } + + Rectangle { + id: highlight + + property int widthDest: ((progressbar.width * (value - minimum)) / (maximum - minimum) - 6) + + width: highlight.widthDest + Behavior on width { SmoothedAnimation { velocity: 1200 } } + + anchors { left: parent.left; top: parent.top; bottom: parent.bottom; margins: 3 } + radius: 1 + gradient: Gradient { + GradientStop { id: gradient1; position: 0.0 } + GradientStop { id: gradient2; position: 1.0 } + } + + } + Text { + anchors { right: highlight.right; rightMargin: 6; verticalCenter: parent.verticalCenter } + color: "white" + font.bold: true + text: Math.floor((value - minimum) / (maximum - minimum) * 100) + '%' + } +} diff --git a/examples/qml/ui-components/progressbar/content/background.png b/examples/qml/ui-components/progressbar/content/background.png new file mode 100644 index 0000000000..9044226f85 Binary files /dev/null and b/examples/qml/ui-components/progressbar/content/background.png differ diff --git a/examples/qml/ui-components/progressbar/main.qml b/examples/qml/ui-components/progressbar/main.qml new file mode 100644 index 0000000000..367e4c1265 --- /dev/null +++ b/examples/qml/ui-components/progressbar/main.qml @@ -0,0 +1,73 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import "content" + +Rectangle { + id: main + + width: 600; height: 405 + color: "#edecec" + + Flickable { + anchors.fill: parent + contentHeight: column.height + 20 + + Column { + id: column + x: 10; y: 10 + spacing: 10 + + Repeater { + model: 25 + + ProgressBar { + property int r: Math.floor(Math.random() * 5000 + 1000) + width: main.width - 20 + + NumberAnimation on value { duration: r; from: 0; to: 100; loops: Animation.Infinite } + ColorAnimation on color { duration: r; from: "lightsteelblue"; to: "thistle"; loops: Animation.Infinite } + ColorAnimation on secondColor { duration: r; from: "steelblue"; to: "#CD96CD"; loops: Animation.Infinite } + } + } + } + } +} diff --git a/examples/qml/ui-components/scrollbar/ScrollBar.qml b/examples/qml/ui-components/scrollbar/ScrollBar.qml new file mode 100644 index 0000000000..a3d0d3841c --- /dev/null +++ b/examples/qml/ui-components/scrollbar/ScrollBar.qml @@ -0,0 +1,74 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Item { + id: scrollBar + + // The properties that define the scrollbar's state. + // position and pageSize are in the range 0.0 - 1.0. They are relative to the + // height of the page, i.e. a pageSize of 0.5 means that you can see 50% + // of the height of the view. + // orientation can be either Qt.Vertical or Qt.Horizontal + property real position + property real pageSize + property variant orientation : Qt.Vertical + + // A light, semi-transparent background + Rectangle { + id: background + anchors.fill: parent + radius: orientation == Qt.Vertical ? (width/2 - 1) : (height/2 - 1) + color: "white" + opacity: 0.3 + } + + // Size the bar to the required size, depending upon the orientation. + Rectangle { + x: orientation == Qt.Vertical ? 1 : (scrollBar.position * (scrollBar.width-2) + 1) + y: orientation == Qt.Vertical ? (scrollBar.position * (scrollBar.height-2) + 1) : 1 + width: orientation == Qt.Vertical ? (parent.width-2) : (scrollBar.pageSize * (scrollBar.width-2)) + height: orientation == Qt.Vertical ? (scrollBar.pageSize * (scrollBar.height-2)) : (parent.height-2) + radius: orientation == Qt.Vertical ? (width/2 - 1) : (height/2 - 1) + color: "black" + opacity: 0.7 + } +} diff --git a/examples/qml/ui-components/scrollbar/main.qml b/examples/qml/ui-components/scrollbar/main.qml new file mode 100644 index 0000000000..a7d602b437 --- /dev/null +++ b/examples/qml/ui-components/scrollbar/main.qml @@ -0,0 +1,93 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Rectangle { + width: 640 + height: 480 + + // Create a flickable to view a large image. + Flickable { + id: view + anchors.fill: parent + contentWidth: picture.width + contentHeight: picture.height + + Image { + id: picture + source: "pics/niagara_falls.jpg" + asynchronous: true + } + + // Only show the scrollbars when the view is moving. + states: State { + name: "ShowBars" + when: view.movingVertically || view.movingHorizontally + PropertyChanges { target: verticalScrollBar; opacity: 1 } + PropertyChanges { target: horizontalScrollBar; opacity: 1 } + } + + transitions: Transition { + NumberAnimation { properties: "opacity"; duration: 400 } + } + } + + // Attach scrollbars to the right and bottom edges of the view. + ScrollBar { + id: verticalScrollBar + width: 12; height: view.height-12 + anchors.right: view.right + opacity: 0 + orientation: Qt.Vertical + position: view.visibleArea.yPosition + pageSize: view.visibleArea.heightRatio + } + + ScrollBar { + id: horizontalScrollBar + width: view.width-12; height: 12 + anchors.bottom: view.bottom + opacity: 0 + orientation: Qt.Horizontal + position: view.visibleArea.xPosition + pageSize: view.visibleArea.widthRatio + } +} diff --git a/examples/qml/ui-components/scrollbar/pics/niagara_falls.jpg b/examples/qml/ui-components/scrollbar/pics/niagara_falls.jpg new file mode 100644 index 0000000000..e625c0d3e6 Binary files /dev/null and b/examples/qml/ui-components/scrollbar/pics/niagara_falls.jpg differ diff --git a/examples/qml/ui-components/scrollbar/scrollbar.qmlproject b/examples/qml/ui-components/scrollbar/scrollbar.qmlproject new file mode 100644 index 0000000000..e5a8bf02ca --- /dev/null +++ b/examples/qml/ui-components/scrollbar/scrollbar.qmlproject @@ -0,0 +1,16 @@ +import QmlProject 1.1 + +Project { + mainFile: "main.qml" + + /* Include .qml, .js, and image files from current directory and subdirectories */ + QmlFiles { + directory: "." + } + JavaScriptFiles { + directory: "." + } + ImageFiles { + directory: "." + } +} diff --git a/examples/qml/ui-components/searchbox/SearchBox.qml b/examples/qml/ui-components/searchbox/SearchBox.qml new file mode 100644 index 0000000000..6f6f486412 --- /dev/null +++ b/examples/qml/ui-components/searchbox/SearchBox.qml @@ -0,0 +1,109 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +FocusScope { + id: focusScope + width: 250; height: 28 + + BorderImage { + source: "images/lineedit-bg.png" + width: parent.width; height: parent.height + border { left: 4; top: 4; right: 4; bottom: 4 } + } + + BorderImage { + source: "images/lineedit-bg-focus.png" + width: parent.width; height: parent.height + border { left: 4; top: 4; right: 4; bottom: 4 } + visible: parent.activeFocus ? true : false + } + + Text { + id: typeSomething + anchors.fill: parent; anchors.leftMargin: 8 + verticalAlignment: Text.AlignVCenter + text: "Type something..." + color: "gray" + font.italic: true + } + + MouseArea { + anchors.fill: parent + onClicked: { focusScope.focus = true; textInput.openSoftwareInputPanel(); } + } + + TextInput { + id: textInput + anchors { left: parent.left; leftMargin: 8; right: clear.left; rightMargin: 8; verticalCenter: parent.verticalCenter } + focus: true + selectByMouse: true + } + + Image { + id: clear + anchors { right: parent.right; rightMargin: 8; verticalCenter: parent.verticalCenter } + source: "images/clear.png" + opacity: 0 + + MouseArea { + anchors.fill: parent + onClicked: { textInput.text = ''; focusScope.focus = true; textInput.openSoftwareInputPanel(); } + } + } + + states: State { + name: "hasText"; when: textInput.text != '' + PropertyChanges { target: typeSomething; opacity: 0 } + PropertyChanges { target: clear; opacity: 1 } + } + + transitions: [ + Transition { + from: ""; to: "hasText" + NumberAnimation { exclude: typeSomething; properties: "opacity" } + }, + Transition { + from: "hasText"; to: "" + NumberAnimation { properties: "opacity" } + } + ] +} diff --git a/examples/qml/ui-components/searchbox/images/clear.png b/examples/qml/ui-components/searchbox/images/clear.png new file mode 100644 index 0000000000..91eb270695 Binary files /dev/null and b/examples/qml/ui-components/searchbox/images/clear.png differ diff --git a/examples/qml/ui-components/searchbox/images/lineedit-bg-focus.png b/examples/qml/ui-components/searchbox/images/lineedit-bg-focus.png new file mode 100644 index 0000000000..bbfac38d2d Binary files /dev/null and b/examples/qml/ui-components/searchbox/images/lineedit-bg-focus.png differ diff --git a/examples/qml/ui-components/searchbox/images/lineedit-bg.png b/examples/qml/ui-components/searchbox/images/lineedit-bg.png new file mode 100644 index 0000000000..9044226f85 Binary files /dev/null and b/examples/qml/ui-components/searchbox/images/lineedit-bg.png differ diff --git a/examples/qml/ui-components/searchbox/main.qml b/examples/qml/ui-components/searchbox/main.qml new file mode 100644 index 0000000000..6e9731cf9c --- /dev/null +++ b/examples/qml/ui-components/searchbox/main.qml @@ -0,0 +1,60 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Rectangle { + id: page + width: 500; height: 250 + color: "#edecec" + + MouseArea { + anchors.fill: parent + onClicked: page.focus = false; + } + Column { + anchors { horizontalCenter: parent.horizontalCenter; verticalCenter: parent.verticalCenter } + spacing: 10 + + SearchBox { id: search1; KeyNavigation.tab: search2; KeyNavigation.backtab: search3; focus: true } + SearchBox { id: search2; KeyNavigation.tab: search3; KeyNavigation.backtab: search1 } + SearchBox { id: search3; KeyNavigation.tab: search1; KeyNavigation.backtab: search2 } + } +} diff --git a/examples/qml/ui-components/searchbox/searchbox.qmlproject b/examples/qml/ui-components/searchbox/searchbox.qmlproject new file mode 100644 index 0000000000..e5a8bf02ca --- /dev/null +++ b/examples/qml/ui-components/searchbox/searchbox.qmlproject @@ -0,0 +1,16 @@ +import QmlProject 1.1 + +Project { + mainFile: "main.qml" + + /* Include .qml, .js, and image files from current directory and subdirectories */ + QmlFiles { + directory: "." + } + JavaScriptFiles { + directory: "." + } + ImageFiles { + directory: "." + } +} diff --git a/examples/qml/ui-components/slideswitch/content/Switch.qml b/examples/qml/ui-components/slideswitch/content/Switch.qml new file mode 100644 index 0000000000..981fc16673 --- /dev/null +++ b/examples/qml/ui-components/slideswitch/content/Switch.qml @@ -0,0 +1,117 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +//![0] +import QtQuick 2.0 + +Item { + id: toggleswitch + width: background.width; height: background.height + +//![1] + property bool on: false +//![1] + +//![2] + function toggle() { + if (toggleswitch.state == "on") + toggleswitch.state = "off"; + else + toggleswitch.state = "on"; + } +//![2] + +//![3] + function releaseSwitch() { + if (knob.x == 1) { + if (toggleswitch.state == "off") return; + } + if (knob.x == 78) { + if (toggleswitch.state == "on") return; + } + toggle(); + } +//![3] + +//![4] + Image { + id: background + source: "background.png" + MouseArea { anchors.fill: parent; onClicked: toggle() } + } +//![4] + +//![5] + Image { + id: knob + x: 1; y: 2 + source: "knob.png" + + MouseArea { + anchors.fill: parent + drag.target: knob; drag.axis: Drag.XAxis; drag.minimumX: 1; drag.maximumX: 78 + onClicked: toggle() + onReleased: releaseSwitch() + } + } +//![5] + +//![6] + states: [ + State { + name: "on" + PropertyChanges { target: knob; x: 78 } + PropertyChanges { target: toggleswitch; on: true } + }, + State { + name: "off" + PropertyChanges { target: knob; x: 1 } + PropertyChanges { target: toggleswitch; on: false } + } + ] +//![6] + +//![7] + transitions: Transition { + NumberAnimation { properties: "x"; easing.type: Easing.InOutQuad; duration: 200 } + } +//![7] +} +//![0] diff --git a/examples/qml/ui-components/slideswitch/content/background.png b/examples/qml/ui-components/slideswitch/content/background.png new file mode 100644 index 0000000000..d736815870 Binary files /dev/null and b/examples/qml/ui-components/slideswitch/content/background.png differ diff --git a/examples/qml/ui-components/slideswitch/content/background.svg b/examples/qml/ui-components/slideswitch/content/background.svg new file mode 100644 index 0000000000..f920d3e47a --- /dev/null +++ b/examples/qml/ui-components/slideswitch/content/background.svg @@ -0,0 +1,23 @@ + + + +]> + + + + + + + + + + + + + + diff --git a/examples/qml/ui-components/slideswitch/content/knob.png b/examples/qml/ui-components/slideswitch/content/knob.png new file mode 100644 index 0000000000..ee0a436f84 Binary files /dev/null and b/examples/qml/ui-components/slideswitch/content/knob.png differ diff --git a/examples/qml/ui-components/slideswitch/content/knob.svg b/examples/qml/ui-components/slideswitch/content/knob.svg new file mode 100644 index 0000000000..fb6933718e --- /dev/null +++ b/examples/qml/ui-components/slideswitch/content/knob.svg @@ -0,0 +1,867 @@ + + +image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/examples/qml/ui-components/slideswitch/slideswitch.qml b/examples/qml/ui-components/slideswitch/slideswitch.qml new file mode 100644 index 0000000000..60a331407c --- /dev/null +++ b/examples/qml/ui-components/slideswitch/slideswitch.qml @@ -0,0 +1,51 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import "content" + +Rectangle { + color: "white" + width: 400; height: 250 + +//![0] + Switch { anchors.centerIn: parent; on: false } +//![0] +} diff --git a/examples/qml/ui-components/spinner/content/Spinner.qml b/examples/qml/ui-components/spinner/content/Spinner.qml new file mode 100644 index 0000000000..d7bbeb33ee --- /dev/null +++ b/examples/qml/ui-components/spinner/content/Spinner.qml @@ -0,0 +1,70 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Image { + property alias model: view.model + property alias delegate: view.delegate + property alias currentIndex: view.currentIndex + property real itemHeight: 30 + + source: "spinner-bg.png" + clip: true + + PathView { + id: view + anchors.fill: parent + + pathItemCount: height/itemHeight + preferredHighlightBegin: 0.5 + preferredHighlightEnd: 0.5 + highlight: Image { source: "spinner-select.png"; width: view.width; height: itemHeight+4 } + dragMargin: view.width/2 + + path: Path { + startX: view.width/2; startY: -itemHeight/2 + PathLine { x: view.width/2; y: view.pathItemCount*itemHeight + itemHeight } + } + } + + Keys.onDownPressed: view.incrementCurrentIndex() + Keys.onUpPressed: view.decrementCurrentIndex() +} diff --git a/examples/qml/ui-components/spinner/content/spinner-bg.png b/examples/qml/ui-components/spinner/content/spinner-bg.png new file mode 100644 index 0000000000..b3556f1f9f Binary files /dev/null and b/examples/qml/ui-components/spinner/content/spinner-bg.png differ diff --git a/examples/qml/ui-components/spinner/content/spinner-select.png b/examples/qml/ui-components/spinner/content/spinner-select.png new file mode 100644 index 0000000000..95a17a1fe2 Binary files /dev/null and b/examples/qml/ui-components/spinner/content/spinner-select.png differ diff --git a/examples/qml/ui-components/spinner/main.qml b/examples/qml/ui-components/spinner/main.qml new file mode 100644 index 0000000000..7584c98396 --- /dev/null +++ b/examples/qml/ui-components/spinner/main.qml @@ -0,0 +1,61 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import "content" + +Rectangle { + width: 240; height: 320 + + Column { + y: 20; x: 20; spacing: 20 + + Spinner { + id: spinner + width: 200; height: 240 + focus: true + model: 20 + itemHeight: 30 + delegate: Text { font.pixelSize: 25; text: index; height: 30 } + } + + Text { text: "Current item index: " + spinner.currentIndex } + } +} diff --git a/examples/qml/ui-components/spinner/spinner.qmlproject b/examples/qml/ui-components/spinner/spinner.qmlproject new file mode 100644 index 0000000000..e5a8bf02ca --- /dev/null +++ b/examples/qml/ui-components/spinner/spinner.qmlproject @@ -0,0 +1,16 @@ +import QmlProject 1.1 + +Project { + mainFile: "main.qml" + + /* Include .qml, .js, and image files from current directory and subdirectories */ + QmlFiles { + directory: "." + } + JavaScriptFiles { + directory: "." + } + ImageFiles { + directory: "." + } +} diff --git a/examples/qml/ui-components/tabwidget/TabWidget.qml b/examples/qml/ui-components/tabwidget/TabWidget.qml new file mode 100644 index 0000000000..560ed1f58a --- /dev/null +++ b/examples/qml/ui-components/tabwidget/TabWidget.qml @@ -0,0 +1,102 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Item { + id: tabWidget + + // Setting the default property to stack.children means any child items + // of the TabWidget are actually added to the 'stack' item's children. + // See the "Property Binding" + // documentation for details on default properties. + default property alias content: stack.children + + property int current: 0 + + onCurrentChanged: setOpacities() + Component.onCompleted: setOpacities() + + function setOpacities() { + for (var i = 0; i < stack.children.length; ++i) { + stack.children[i].opacity = (i == current ? 1 : 0) + } + } + + Row { + id: header + + Repeater { + model: stack.children.length + delegate: Rectangle { + width: tabWidget.width / stack.children.length; height: 36 + + Rectangle { + width: parent.width; height: 1 + anchors { bottom: parent.bottom; bottomMargin: 1 } + color: "#acb2c2" + } + BorderImage { + anchors { fill: parent; leftMargin: 2; topMargin: 5; rightMargin: 1 } + border { left: 7; right: 7 } + source: "tab.png" + visible: tabWidget.current == index + } + Text { + horizontalAlignment: Qt.AlignHCenter; verticalAlignment: Qt.AlignVCenter + anchors.fill: parent + text: stack.children[index].title + elide: Text.ElideRight + font.bold: tabWidget.current == index + } + MouseArea { + anchors.fill: parent + onClicked: tabWidget.current = index + } + } + } + } + + Item { + id: stack + width: tabWidget.width + anchors.top: header.bottom; anchors.bottom: tabWidget.bottom + } +} diff --git a/examples/qml/ui-components/tabwidget/main.qml b/examples/qml/ui-components/tabwidget/main.qml new file mode 100644 index 0000000000..df99c11b7d --- /dev/null +++ b/examples/qml/ui-components/tabwidget/main.qml @@ -0,0 +1,99 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +TabWidget { + id: tabs + width: 640; height: 480 + + Rectangle { + property string title: "Red" + anchors.fill: parent + color: "#e3e3e3" + + Rectangle { + anchors.fill: parent; anchors.margins: 20 + color: "#ff7f7f" + Text { + width: parent.width - 20 + anchors.centerIn: parent; horizontalAlignment: Qt.AlignHCenter + text: "Roses are red" + font.pixelSize: 20 + wrapMode: Text.WordWrap + } + } + } + + Rectangle { + property string title: "Green" + anchors.fill: parent + color: "#e3e3e3" + + Rectangle { + anchors.fill: parent; anchors.margins: 20 + color: "#7fff7f" + Text { + width: parent.width - 20 + anchors.centerIn: parent; horizontalAlignment: Qt.AlignHCenter + text: "Flower stems are green" + font.pixelSize: 20 + wrapMode: Text.WordWrap + } + } + } + + Rectangle { + property string title: "Blue" + anchors.fill: parent; color: "#e3e3e3" + + Rectangle { + anchors.fill: parent; anchors.margins: 20 + color: "#7f7fff" + Text { + width: parent.width - 20 + anchors.centerIn: parent; horizontalAlignment: Qt.AlignHCenter + text: "Violets are blue" + font.pixelSize: 20 + wrapMode: Text.WordWrap + } + } + } +} diff --git a/examples/qml/ui-components/tabwidget/tab.png b/examples/qml/ui-components/tabwidget/tab.png new file mode 100644 index 0000000000..ad8021605f Binary files /dev/null and b/examples/qml/ui-components/tabwidget/tab.png differ diff --git a/examples/qml/ui-components/tabwidget/tabwidget.qmlproject b/examples/qml/ui-components/tabwidget/tabwidget.qmlproject new file mode 100644 index 0000000000..e5a8bf02ca --- /dev/null +++ b/examples/qml/ui-components/tabwidget/tabwidget.qmlproject @@ -0,0 +1,16 @@ +import QmlProject 1.1 + +Project { + mainFile: "main.qml" + + /* Include .qml, .js, and image files from current directory and subdirectories */ + QmlFiles { + directory: "." + } + JavaScriptFiles { + directory: "." + } + ImageFiles { + directory: "." + } +} diff --git a/examples/qml/window/Window.qml b/examples/qml/window/Window.qml new file mode 100644 index 0000000000..48478458c6 --- /dev/null +++ b/examples/qml/window/Window.qml @@ -0,0 +1,58 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import QtQuick.Window 2.0 as Window + +Window.Window { + width: 640 + height: 480 + visible: true //It's false by default + property Component self + Component.onCompleted: self = Qt.createComponent("Window.qml") + Text{ + text: "Hello World!" + anchors.centerIn: parent + } + MouseArea{ + anchors.fill: parent + onClicked: self.createObject(); + } +} diff --git a/examples/qml/window/screen/screenInfo.qml b/examples/qml/window/screen/screenInfo.qml new file mode 100644 index 0000000000..54299ba4e0 --- /dev/null +++ b/examples/qml/window/screen/screenInfo.qml @@ -0,0 +1,90 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import QtQuick.Window 2.0 as Window + +Item { + id: root + width: 400 + height: 200 + Item { + id: main + state: "orientation " + Window.Screen.orientation + + property bool landscapeWindow: Window.Screen.primaryOrientation == Qt.LandscapeOrientation + property real baseWidth: landscapeWindow ? root.height : root.width + property real baseHeight: landscapeWindow ? root.width : root.height + property real rotationDelta: landscapeWindow ? -90 : 0 + + rotation: rotationDelta + width: main.baseWidth + height: main.baseHeight + anchors.centerIn: parent + + Text { + text: "Screen is " + Window.Screen.width + "x" + Window.Screen.height + " and primarily orientation " + Window.Screen.primaryOrientation + anchors.centerIn:parent + } + + + states: [ + State { + name: "orientation " + Qt.LandscapeOrientation + PropertyChanges { target: main; rotation: 90 + rotationDelta; width: main.baseHeight; height: main.baseWidth } + }, + State { + name: "orientation " + Qt.InvertedPortraitOrientation + PropertyChanges { target: main; rotation: 180 + rotationDelta; } + }, + State { + name: "orientation " + Qt.InvertedLandscapeOrientation + PropertyChanges { target: main; rotation: 270 + rotationDelta; width: main.baseHeight; height: main.baseWidth } + } + ] + + transitions: Transition { + SequentialAnimation { + RotationAnimation { direction: RotationAnimation.Shortest; duration: 300; easing.type: Easing.InOutQuint } + NumberAnimation { properties: "x,y,width,height"; duration: 300; easing.type: Easing.InOutQuint } + } + } + } +} diff --git a/examples/qml/window/standalone.qml b/examples/qml/window/standalone.qml new file mode 100644 index 0000000000..335cf7b635 --- /dev/null +++ b/examples/qml/window/standalone.qml @@ -0,0 +1,71 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import QtQuick.Window 2.0 as Window + +Item { + width: 640 + height: 480 + Text { + anchors.centerIn: parent + text: "First Window" + } + MouseArea { + anchors.fill: parent + onClicked: Qt.quit() + } + Window.Window { + width: 640 + height: 480 + x: 640 + y: 480 + visible: true + color: "green" + Text { + anchors.centerIn: parent + text: "Second Window" + } + MouseArea{ + anchors.fill: parent + onClicked: Qt.quit() + } + } +} diff --git a/examples/qml/window/window.cpp b/examples/qml/window/window.cpp new file mode 100644 index 0000000000..2112ab8f45 --- /dev/null +++ b/examples/qml/window/window.cpp @@ -0,0 +1,58 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include +#include +#include +#include + +int main(int argc, char* argv[]) +{ + QGuiApplication app(argc, argv); + QQmlEngine engine; + QQmlComponent component(&engine); + component.loadUrl(QUrl::fromLocalFile("Window.qml")); + if ( component.isReady() ) + component.create(); + else + qWarning() << component.errorString(); + return app.exec(); +} diff --git a/examples/qml/window/window.pro b/examples/qml/window/window.pro new file mode 100644 index 0000000000..c4518418f6 --- /dev/null +++ b/examples/qml/window/window.pro @@ -0,0 +1,5 @@ +TEMPLATE = app +CONFIG += qt +QT += qml + +SOURCES += window.cpp diff --git a/examples/qml/xml/xmlhttprequest/data.xml b/examples/qml/xml/xmlhttprequest/data.xml new file mode 100644 index 0000000000..8b7f1e116d --- /dev/null +++ b/examples/qml/xml/xmlhttprequest/data.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/examples/qml/xml/xmlhttprequest/xmlhttprequest-example.qml b/examples/qml/xml/xmlhttprequest/xmlhttprequest-example.qml new file mode 100644 index 0000000000..28ba078160 --- /dev/null +++ b/examples/qml/xml/xmlhttprequest/xmlhttprequest-example.qml @@ -0,0 +1,95 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Rectangle { + width: 350; height: 400 + + function showRequestInfo(text) { + log.text = log.text + "\n" + text + console.log(text) + } + + Text { id: log; anchors.fill: parent; anchors.margins: 10 } + + Rectangle { + id: button + anchors.horizontalCenter: parent.horizontalCenter; anchors.bottom: parent.bottom; anchors.margins: 10 + width: buttonText.width + 10; height: buttonText.height + 10 + border.width: mouseArea.pressed ? 2 : 1 + radius : 5; smooth: true + + Text { id: buttonText; anchors.centerIn: parent; text: "Request data.xml" } + + MouseArea { + id: mouseArea + anchors.fill: parent + onClicked: { + log.text = "" + console.log("\n") + + var doc = new XMLHttpRequest(); + doc.onreadystatechange = function() { + if (doc.readyState == XMLHttpRequest.HEADERS_RECEIVED) { + showRequestInfo("Headers -->"); + showRequestInfo(doc.getAllResponseHeaders ()); + showRequestInfo("Last modified -->"); + showRequestInfo(doc.getResponseHeader ("Last-Modified")); + + } else if (doc.readyState == XMLHttpRequest.DONE) { + var a = doc.responseXML.documentElement; + for (var ii = 0; ii < a.childNodes.length; ++ii) { + showRequestInfo(a.childNodes[ii].nodeName); + } + showRequestInfo("Headers -->"); + showRequestInfo(doc.getAllResponseHeaders ()); + showRequestInfo("Last modified -->"); + showRequestInfo(doc.getResponseHeader ("Last-Modified")); + } + } + + doc.open("GET", "data.xml"); + doc.send(); + } + } + } +} + diff --git a/examples/tutorials/gettingStartedQml/core/Button.qml b/examples/tutorials/gettingStartedQml/core/Button.qml index 41be4134bd..9ea8c6dfff 100644 --- a/examples/tutorials/gettingStartedQml/core/Button.qml +++ b/examples/tutorials/gettingStartedQml/core/Button.qml @@ -3,7 +3,7 @@ ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/ ** -** This file is part of the QtDeclarative module of the Qt Toolkit. +** This file is part of the QtQml module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:BSD$ ** You may use this file under the terms of the BSD license as follows: diff --git a/examples/tutorials/gettingStartedQml/core/EditMenu.qml b/examples/tutorials/gettingStartedQml/core/EditMenu.qml index 7471669a37..dcac7bd29a 100644 --- a/examples/tutorials/gettingStartedQml/core/EditMenu.qml +++ b/examples/tutorials/gettingStartedQml/core/EditMenu.qml @@ -3,7 +3,7 @@ ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/ ** -** This file is part of the QtDeclarative module of the Qt Toolkit. +** This file is part of the QtQml module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:BSD$ ** You may use this file under the terms of the BSD license as follows: diff --git a/examples/tutorials/gettingStartedQml/core/FileDialog.qml b/examples/tutorials/gettingStartedQml/core/FileDialog.qml index 2d08e19bcf..0a4341b868 100644 --- a/examples/tutorials/gettingStartedQml/core/FileDialog.qml +++ b/examples/tutorials/gettingStartedQml/core/FileDialog.qml @@ -3,7 +3,7 @@ ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/ ** -** This file is part of the QtDeclarative module of the Qt Toolkit. +** This file is part of the QtQml module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:BSD$ ** You may use this file under the terms of the BSD license as follows: diff --git a/examples/tutorials/gettingStartedQml/core/FileMenu.qml b/examples/tutorials/gettingStartedQml/core/FileMenu.qml index 67d747d8fb..a4be5eff15 100644 --- a/examples/tutorials/gettingStartedQml/core/FileMenu.qml +++ b/examples/tutorials/gettingStartedQml/core/FileMenu.qml @@ -3,7 +3,7 @@ ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/ ** -** This file is part of the QtDeclarative module of the Qt Toolkit. +** This file is part of the QtQml module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:BSD$ ** You may use this file under the terms of the BSD license as follows: diff --git a/examples/tutorials/gettingStartedQml/core/MenuBar.qml b/examples/tutorials/gettingStartedQml/core/MenuBar.qml index 68e25899e3..8d7be29fdd 100644 --- a/examples/tutorials/gettingStartedQml/core/MenuBar.qml +++ b/examples/tutorials/gettingStartedQml/core/MenuBar.qml @@ -3,7 +3,7 @@ ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/ ** -** This file is part of the QtDeclarative module of the Qt Toolkit. +** This file is part of the QtQml module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:BSD$ ** You may use this file under the terms of the BSD license as follows: diff --git a/examples/tutorials/gettingStartedQml/core/TextArea.qml b/examples/tutorials/gettingStartedQml/core/TextArea.qml index 2ca145260c..99fb5ca60c 100644 --- a/examples/tutorials/gettingStartedQml/core/TextArea.qml +++ b/examples/tutorials/gettingStartedQml/core/TextArea.qml @@ -3,7 +3,7 @@ ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/ ** -** This file is part of the QtDeclarative module of the Qt Toolkit. +** This file is part of the QtQml module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:BSD$ ** You may use this file under the terms of the BSD license as follows: diff --git a/examples/tutorials/gettingStartedQml/filedialog/dialogPlugin.cpp b/examples/tutorials/gettingStartedQml/filedialog/dialogPlugin.cpp index 6bc3d4d006..c8538958ac 100644 --- a/examples/tutorials/gettingStartedQml/filedialog/dialogPlugin.cpp +++ b/examples/tutorials/gettingStartedQml/filedialog/dialogPlugin.cpp @@ -3,7 +3,7 @@ ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/ ** -** This file is part of the QtDeclarative module of the Qt Toolkit. +** This file is part of the QtQml module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:BSD$ ** You may use this file under the terms of the BSD license as follows: @@ -41,7 +41,7 @@ #include "dialogPlugin.h" #include "directory.h" #include "file.h" -#include +#include void DialogPlugin::registerTypes(const char *uri) { diff --git a/examples/tutorials/gettingStartedQml/filedialog/dialogPlugin.h b/examples/tutorials/gettingStartedQml/filedialog/dialogPlugin.h index 03bdc1a6e4..1aed6abc8e 100644 --- a/examples/tutorials/gettingStartedQml/filedialog/dialogPlugin.h +++ b/examples/tutorials/gettingStartedQml/filedialog/dialogPlugin.h @@ -3,7 +3,7 @@ ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/ ** -** This file is part of the QtDeclarative module of the Qt Toolkit. +** This file is part of the QtQml module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:BSD$ ** You may use this file under the terms of the BSD license as follows: @@ -41,14 +41,14 @@ #ifndef DIALOGPLUGIN_H #define DIALOGPLUGIN_H -#include +#include -class DialogPlugin : public QDeclarativeExtensionPlugin +class DialogPlugin : public QQmlExtensionPlugin { Q_OBJECT public: - //registerTypes is inherited from QDeclarativeExtensionPlugin + //registerTypes is inherited from QQmlExtensionPlugin void registerTypes(const char *uri); }; diff --git a/examples/tutorials/gettingStartedQml/filedialog/directory.cpp b/examples/tutorials/gettingStartedQml/filedialog/directory.cpp index 3253327cb4..eadc11e52f 100644 --- a/examples/tutorials/gettingStartedQml/filedialog/directory.cpp +++ b/examples/tutorials/gettingStartedQml/filedialog/directory.cpp @@ -3,7 +3,7 @@ ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/ ** -** This file is part of the QtDeclarative module of the Qt Toolkit. +** This file is part of the QtQml module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:BSD$ ** You may use this file under the terms of the BSD license as follows: @@ -72,7 +72,7 @@ int Directory::filesCount() const /* Function called to append data onto list property */ -void appendFiles(QDeclarativeListProperty * property, File * file) +void appendFiles(QQmlListProperty * property, File * file) { Q_UNUSED(property); Q_UNUSED(file); @@ -82,7 +82,7 @@ void appendFiles(QDeclarativeListProperty * property, File * file) /* Function called to retrieve file in the list using an index */ -File* fileAt(QDeclarativeListProperty * property, int index) +File* fileAt(QQmlListProperty * property, int index) { return static_cast< QList *>(property->data)->at(index); } @@ -90,7 +90,7 @@ File* fileAt(QDeclarativeListProperty * property, int index) /* Returns the number of files in the list */ -int filesSize(QDeclarativeListProperty * property) +int filesSize(QQmlListProperty * property) { return static_cast< QList *>(property->data)->size(); } @@ -98,18 +98,18 @@ int filesSize(QDeclarativeListProperty * property) /* Function called to empty the list property contents */ -void clearFilesPtr(QDeclarativeListProperty *property) +void clearFilesPtr(QQmlListProperty *property) { return static_cast< QList *>(property->data)->clear(); } /* -Returns the list of files as a QDeclarativeListProperty. +Returns the list of files as a QQmlListProperty. */ -QDeclarativeListProperty Directory::files() +QQmlListProperty Directory::files() { refresh(); - return QDeclarativeListProperty( this, &m_fileList, &appendFiles, &filesSize, &fileAt, &clearFilesPtr ); + return QQmlListProperty( this, &m_fileList, &appendFiles, &filesSize, &fileAt, &clearFilesPtr ); } /* diff --git a/examples/tutorials/gettingStartedQml/filedialog/directory.h b/examples/tutorials/gettingStartedQml/filedialog/directory.h index 04317707c3..30d6751bd2 100644 --- a/examples/tutorials/gettingStartedQml/filedialog/directory.h +++ b/examples/tutorials/gettingStartedQml/filedialog/directory.h @@ -3,7 +3,7 @@ ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/ ** -** This file is part of the QtDeclarative module of the Qt Toolkit. +** This file is part of the QtQml module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:BSD$ ** You may use this file under the terms of the BSD license as follows: @@ -46,7 +46,7 @@ #include #include #include -#include +#include #include class Directory : public QObject { @@ -57,7 +57,7 @@ class Directory : public QObject { Q_PROPERTY(int filesCount READ filesCount) //list property containing file names as QString - Q_PROPERTY(QDeclarativeListProperty files READ files CONSTANT ) + Q_PROPERTY(QQmlListProperty files READ files CONSTANT ) //file name of the text file to read/write Q_PROPERTY(QString filename READ filename WRITE setFilename NOTIFY filenameChanged) @@ -72,7 +72,7 @@ class Directory : public QObject { int filesCount() const; QString filename() const; QString fileContent() const; - QDeclarativeListProperty files(); + QQmlListProperty files(); //properties' write functions void setFilename(const QString &str); diff --git a/examples/tutorials/gettingStartedQml/filedialog/file.cpp b/examples/tutorials/gettingStartedQml/filedialog/file.cpp index 120486315b..e3b22027f5 100644 --- a/examples/tutorials/gettingStartedQml/filedialog/file.cpp +++ b/examples/tutorials/gettingStartedQml/filedialog/file.cpp @@ -3,7 +3,7 @@ ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/ ** -** This file is part of the QtDeclarative module of the Qt Toolkit. +** This file is part of the QtQml module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:BSD$ ** You may use this file under the terms of the BSD license as follows: diff --git a/examples/tutorials/gettingStartedQml/filedialog/file.h b/examples/tutorials/gettingStartedQml/filedialog/file.h index 6b8806ee32..d13638b414 100644 --- a/examples/tutorials/gettingStartedQml/filedialog/file.h +++ b/examples/tutorials/gettingStartedQml/filedialog/file.h @@ -3,7 +3,7 @@ ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/ ** -** This file is part of the QtDeclarative module of the Qt Toolkit. +** This file is part of the QtQml module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:BSD$ ** You may use this file under the terms of the BSD license as follows: diff --git a/examples/tutorials/gettingStartedQml/filedialog/filedialog.pro b/examples/tutorials/gettingStartedQml/filedialog/filedialog.pro index d85787d00c..85edb40257 100644 --- a/examples/tutorials/gettingStartedQml/filedialog/filedialog.pro +++ b/examples/tutorials/gettingStartedQml/filedialog/filedialog.pro @@ -1,6 +1,6 @@ TEMPLATE = lib CONFIG += qt plugin -QT += declarative +QT += qml DESTDIR += ../plugins OBJECTS_DIR = tmp diff --git a/examples/tutorials/gettingStartedQml/parts/part0/Button.qml b/examples/tutorials/gettingStartedQml/parts/part0/Button.qml index 3097a7615c..6cae3f3ab3 100644 --- a/examples/tutorials/gettingStartedQml/parts/part0/Button.qml +++ b/examples/tutorials/gettingStartedQml/parts/part0/Button.qml @@ -3,7 +3,7 @@ ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/ ** -** This file is part of the QtDeclarative module of the Qt Toolkit. +** This file is part of the QtQml module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:BSD$ ** You may use this file under the terms of the BSD license as follows: diff --git a/examples/tutorials/gettingStartedQml/parts/part1/Button.qml b/examples/tutorials/gettingStartedQml/parts/part1/Button.qml index 70f7508de3..118e6fc4d3 100644 --- a/examples/tutorials/gettingStartedQml/parts/part1/Button.qml +++ b/examples/tutorials/gettingStartedQml/parts/part1/Button.qml @@ -3,7 +3,7 @@ ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/ ** -** This file is part of the QtDeclarative module of the Qt Toolkit. +** This file is part of the QtQml module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:BSD$ ** You may use this file under the terms of the BSD license as follows: diff --git a/examples/tutorials/gettingStartedQml/parts/part1/EditMenu.qml b/examples/tutorials/gettingStartedQml/parts/part1/EditMenu.qml index 5d14fc4f69..231a20a3a2 100644 --- a/examples/tutorials/gettingStartedQml/parts/part1/EditMenu.qml +++ b/examples/tutorials/gettingStartedQml/parts/part1/EditMenu.qml @@ -3,7 +3,7 @@ ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/ ** -** This file is part of the QtDeclarative module of the Qt Toolkit. +** This file is part of the QtQml module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:BSD$ ** You may use this file under the terms of the BSD license as follows: diff --git a/examples/tutorials/gettingStartedQml/parts/part1/FileMenu.qml b/examples/tutorials/gettingStartedQml/parts/part1/FileMenu.qml index ddb6df438c..c36f6d4734 100644 --- a/examples/tutorials/gettingStartedQml/parts/part1/FileMenu.qml +++ b/examples/tutorials/gettingStartedQml/parts/part1/FileMenu.qml @@ -3,7 +3,7 @@ ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/ ** -** This file is part of the QtDeclarative module of the Qt Toolkit. +** This file is part of the QtQml module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:BSD$ ** You may use this file under the terms of the BSD license as follows: diff --git a/examples/tutorials/gettingStartedQml/parts/part1/SimpleButton.qml b/examples/tutorials/gettingStartedQml/parts/part1/SimpleButton.qml index e0f377cfe5..f43a56ea7a 100644 --- a/examples/tutorials/gettingStartedQml/parts/part1/SimpleButton.qml +++ b/examples/tutorials/gettingStartedQml/parts/part1/SimpleButton.qml @@ -3,7 +3,7 @@ ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/ ** -** This file is part of the QtDeclarative module of the Qt Toolkit. +** This file is part of the QtQml module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:BSD$ ** You may use this file under the terms of the BSD license as follows: diff --git a/examples/tutorials/gettingStartedQml/parts/part2/Button.qml b/examples/tutorials/gettingStartedQml/parts/part2/Button.qml index 65660b0cc1..aa178f8bf9 100644 --- a/examples/tutorials/gettingStartedQml/parts/part2/Button.qml +++ b/examples/tutorials/gettingStartedQml/parts/part2/Button.qml @@ -3,7 +3,7 @@ ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/ ** -** This file is part of the QtDeclarative module of the Qt Toolkit. +** This file is part of the QtQml module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:BSD$ ** You may use this file under the terms of the BSD license as follows: diff --git a/examples/tutorials/gettingStartedQml/parts/part2/EditMenu.qml b/examples/tutorials/gettingStartedQml/parts/part2/EditMenu.qml index 2a4c0a2834..fb2db7ade3 100644 --- a/examples/tutorials/gettingStartedQml/parts/part2/EditMenu.qml +++ b/examples/tutorials/gettingStartedQml/parts/part2/EditMenu.qml @@ -3,7 +3,7 @@ ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/ ** -** This file is part of the QtDeclarative module of the Qt Toolkit. +** This file is part of the QtQml module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:BSD$ ** You may use this file under the terms of the BSD license as follows: diff --git a/examples/tutorials/gettingStartedQml/parts/part2/FileMenu.qml b/examples/tutorials/gettingStartedQml/parts/part2/FileMenu.qml index 3f60bc6c2a..b715298147 100644 --- a/examples/tutorials/gettingStartedQml/parts/part2/FileMenu.qml +++ b/examples/tutorials/gettingStartedQml/parts/part2/FileMenu.qml @@ -3,7 +3,7 @@ ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/ ** -** This file is part of the QtDeclarative module of the Qt Toolkit. +** This file is part of the QtQml module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:BSD$ ** You may use this file under the terms of the BSD license as follows: diff --git a/examples/tutorials/gettingStartedQml/parts/part2/MenuBar.qml b/examples/tutorials/gettingStartedQml/parts/part2/MenuBar.qml index 99151ff9b0..408b561022 100644 --- a/examples/tutorials/gettingStartedQml/parts/part2/MenuBar.qml +++ b/examples/tutorials/gettingStartedQml/parts/part2/MenuBar.qml @@ -3,7 +3,7 @@ ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/ ** -** This file is part of the QtDeclarative module of the Qt Toolkit. +** This file is part of the QtQml module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:BSD$ ** You may use this file under the terms of the BSD license as follows: diff --git a/examples/tutorials/gettingStartedQml/parts/part3/Button.qml b/examples/tutorials/gettingStartedQml/parts/part3/Button.qml index 65660b0cc1..aa178f8bf9 100644 --- a/examples/tutorials/gettingStartedQml/parts/part3/Button.qml +++ b/examples/tutorials/gettingStartedQml/parts/part3/Button.qml @@ -3,7 +3,7 @@ ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/ ** -** This file is part of the QtDeclarative module of the Qt Toolkit. +** This file is part of the QtQml module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:BSD$ ** You may use this file under the terms of the BSD license as follows: diff --git a/examples/tutorials/gettingStartedQml/parts/part3/EditMenu.qml b/examples/tutorials/gettingStartedQml/parts/part3/EditMenu.qml index 2a4c0a2834..fb2db7ade3 100644 --- a/examples/tutorials/gettingStartedQml/parts/part3/EditMenu.qml +++ b/examples/tutorials/gettingStartedQml/parts/part3/EditMenu.qml @@ -3,7 +3,7 @@ ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/ ** -** This file is part of the QtDeclarative module of the Qt Toolkit. +** This file is part of the QtQml module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:BSD$ ** You may use this file under the terms of the BSD license as follows: diff --git a/examples/tutorials/gettingStartedQml/parts/part3/FileMenu.qml b/examples/tutorials/gettingStartedQml/parts/part3/FileMenu.qml index 3f60bc6c2a..b715298147 100644 --- a/examples/tutorials/gettingStartedQml/parts/part3/FileMenu.qml +++ b/examples/tutorials/gettingStartedQml/parts/part3/FileMenu.qml @@ -3,7 +3,7 @@ ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/ ** -** This file is part of the QtDeclarative module of the Qt Toolkit. +** This file is part of the QtQml module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:BSD$ ** You may use this file under the terms of the BSD license as follows: diff --git a/examples/tutorials/gettingStartedQml/parts/part3/MenuBar.qml b/examples/tutorials/gettingStartedQml/parts/part3/MenuBar.qml index 99151ff9b0..408b561022 100644 --- a/examples/tutorials/gettingStartedQml/parts/part3/MenuBar.qml +++ b/examples/tutorials/gettingStartedQml/parts/part3/MenuBar.qml @@ -3,7 +3,7 @@ ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/ ** -** This file is part of the QtDeclarative module of the Qt Toolkit. +** This file is part of the QtQml module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:BSD$ ** You may use this file under the terms of the BSD license as follows: diff --git a/examples/tutorials/gettingStartedQml/parts/part3/TextArea.qml b/examples/tutorials/gettingStartedQml/parts/part3/TextArea.qml index faee31e97c..279ae045c3 100644 --- a/examples/tutorials/gettingStartedQml/parts/part3/TextArea.qml +++ b/examples/tutorials/gettingStartedQml/parts/part3/TextArea.qml @@ -3,7 +3,7 @@ ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/ ** -** This file is part of the QtDeclarative module of the Qt Toolkit. +** This file is part of the QtQml module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:BSD$ ** You may use this file under the terms of the BSD license as follows: diff --git a/examples/tutorials/gettingStartedQml/parts/part3/TextEditor.qml b/examples/tutorials/gettingStartedQml/parts/part3/TextEditor.qml index c14437dcd0..54fa115aec 100644 --- a/examples/tutorials/gettingStartedQml/parts/part3/TextEditor.qml +++ b/examples/tutorials/gettingStartedQml/parts/part3/TextEditor.qml @@ -3,7 +3,7 @@ ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/ ** -** This file is part of the QtDeclarative module of the Qt Toolkit. +** This file is part of the QtQml module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:BSD$ ** You may use this file under the terms of the BSD license as follows: diff --git a/examples/tutorials/gettingStartedQml/parts/part4/Button.qml b/examples/tutorials/gettingStartedQml/parts/part4/Button.qml index 5572989f5d..7fb4f1e536 100644 --- a/examples/tutorials/gettingStartedQml/parts/part4/Button.qml +++ b/examples/tutorials/gettingStartedQml/parts/part4/Button.qml @@ -3,7 +3,7 @@ ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/ ** -** This file is part of the QtDeclarative module of the Qt Toolkit. +** This file is part of the QtQml module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:BSD$ ** You may use this file under the terms of the BSD license as follows: diff --git a/examples/tutorials/gettingStartedQml/parts/part4/EditMenu.qml b/examples/tutorials/gettingStartedQml/parts/part4/EditMenu.qml index 07282733f7..cdfbd30a06 100644 --- a/examples/tutorials/gettingStartedQml/parts/part4/EditMenu.qml +++ b/examples/tutorials/gettingStartedQml/parts/part4/EditMenu.qml @@ -3,7 +3,7 @@ ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/ ** -** This file is part of the QtDeclarative module of the Qt Toolkit. +** This file is part of the QtQml module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:BSD$ ** You may use this file under the terms of the BSD license as follows: diff --git a/examples/tutorials/gettingStartedQml/parts/part4/FileMenu.qml b/examples/tutorials/gettingStartedQml/parts/part4/FileMenu.qml index 1aa98a9498..a1d95bf87a 100644 --- a/examples/tutorials/gettingStartedQml/parts/part4/FileMenu.qml +++ b/examples/tutorials/gettingStartedQml/parts/part4/FileMenu.qml @@ -3,7 +3,7 @@ ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/ ** -** This file is part of the QtDeclarative module of the Qt Toolkit. +** This file is part of the QtQml module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:BSD$ ** You may use this file under the terms of the BSD license as follows: diff --git a/examples/tutorials/gettingStartedQml/parts/part4/MenuBar.qml b/examples/tutorials/gettingStartedQml/parts/part4/MenuBar.qml index ba1697f6f8..024c60f87c 100644 --- a/examples/tutorials/gettingStartedQml/parts/part4/MenuBar.qml +++ b/examples/tutorials/gettingStartedQml/parts/part4/MenuBar.qml @@ -3,7 +3,7 @@ ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/ ** -** This file is part of the QtDeclarative module of the Qt Toolkit. +** This file is part of the QtQml module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:BSD$ ** You may use this file under the terms of the BSD license as follows: diff --git a/examples/tutorials/gettingStartedQml/parts/part4/SimpleButton.qml b/examples/tutorials/gettingStartedQml/parts/part4/SimpleButton.qml index 11864d337e..0216131819 100644 --- a/examples/tutorials/gettingStartedQml/parts/part4/SimpleButton.qml +++ b/examples/tutorials/gettingStartedQml/parts/part4/SimpleButton.qml @@ -3,7 +3,7 @@ ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/ ** -** This file is part of the QtDeclarative module of the Qt Toolkit. +** This file is part of the QtQml module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:BSD$ ** You may use this file under the terms of the BSD license as follows: diff --git a/examples/tutorials/gettingStartedQml/parts/part4/TextArea.qml b/examples/tutorials/gettingStartedQml/parts/part4/TextArea.qml index b3b1e07294..de664a15fd 100644 --- a/examples/tutorials/gettingStartedQml/parts/part4/TextArea.qml +++ b/examples/tutorials/gettingStartedQml/parts/part4/TextArea.qml @@ -3,7 +3,7 @@ ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/ ** -** This file is part of the QtDeclarative module of the Qt Toolkit. +** This file is part of the QtQml module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:BSD$ ** You may use this file under the terms of the BSD license as follows: diff --git a/examples/tutorials/gettingStartedQml/parts/part4/TextEditor.qml b/examples/tutorials/gettingStartedQml/parts/part4/TextEditor.qml index 13735b35c9..43a6bc0eea 100644 --- a/examples/tutorials/gettingStartedQml/parts/part4/TextEditor.qml +++ b/examples/tutorials/gettingStartedQml/parts/part4/TextEditor.qml @@ -3,7 +3,7 @@ ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/ ** -** This file is part of the QtDeclarative module of the Qt Toolkit. +** This file is part of the QtQml module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:BSD$ ** You may use this file under the terms of the BSD license as follows: diff --git a/examples/tutorials/gettingStartedQml/parts/part5/TextEditor.qml b/examples/tutorials/gettingStartedQml/parts/part5/TextEditor.qml index b517971c55..50501ddadc 100644 --- a/examples/tutorials/gettingStartedQml/parts/part5/TextEditor.qml +++ b/examples/tutorials/gettingStartedQml/parts/part5/TextEditor.qml @@ -3,7 +3,7 @@ ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/ ** -** This file is part of the QtDeclarative module of the Qt Toolkit. +** This file is part of the QtQml module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:BSD$ ** You may use this file under the terms of the BSD license as follows: diff --git a/examples/tutorials/gettingStartedQml/parts/part5/core/Button.qml b/examples/tutorials/gettingStartedQml/parts/part5/core/Button.qml index 628af3a835..f6dd54ac9a 100644 --- a/examples/tutorials/gettingStartedQml/parts/part5/core/Button.qml +++ b/examples/tutorials/gettingStartedQml/parts/part5/core/Button.qml @@ -3,7 +3,7 @@ ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/ ** -** This file is part of the QtDeclarative module of the Qt Toolkit. +** This file is part of the QtQml module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:BSD$ ** You may use this file under the terms of the BSD license as follows: diff --git a/examples/tutorials/gettingStartedQml/parts/part5/core/EditMenu.qml b/examples/tutorials/gettingStartedQml/parts/part5/core/EditMenu.qml index a92e51eb94..fe4bbf4cb2 100644 --- a/examples/tutorials/gettingStartedQml/parts/part5/core/EditMenu.qml +++ b/examples/tutorials/gettingStartedQml/parts/part5/core/EditMenu.qml @@ -3,7 +3,7 @@ ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/ ** -** This file is part of the QtDeclarative module of the Qt Toolkit. +** This file is part of the QtQml module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:BSD$ ** You may use this file under the terms of the BSD license as follows: diff --git a/examples/tutorials/gettingStartedQml/parts/part5/core/FileDialog.qml b/examples/tutorials/gettingStartedQml/parts/part5/core/FileDialog.qml index eeea0d2304..af83ef5e63 100644 --- a/examples/tutorials/gettingStartedQml/parts/part5/core/FileDialog.qml +++ b/examples/tutorials/gettingStartedQml/parts/part5/core/FileDialog.qml @@ -3,7 +3,7 @@ ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/ ** -** This file is part of the QtDeclarative module of the Qt Toolkit. +** This file is part of the QtQml module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:BSD$ ** You may use this file under the terms of the BSD license as follows: diff --git a/examples/tutorials/gettingStartedQml/parts/part5/core/FileMenu.qml b/examples/tutorials/gettingStartedQml/parts/part5/core/FileMenu.qml index 2a33a30d43..57555010b6 100644 --- a/examples/tutorials/gettingStartedQml/parts/part5/core/FileMenu.qml +++ b/examples/tutorials/gettingStartedQml/parts/part5/core/FileMenu.qml @@ -3,7 +3,7 @@ ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/ ** -** This file is part of the QtDeclarative module of the Qt Toolkit. +** This file is part of the QtQml module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:BSD$ ** You may use this file under the terms of the BSD license as follows: diff --git a/examples/tutorials/gettingStartedQml/parts/part5/core/MenuBar.qml b/examples/tutorials/gettingStartedQml/parts/part5/core/MenuBar.qml index 81898ea86b..4a13f59dac 100644 --- a/examples/tutorials/gettingStartedQml/parts/part5/core/MenuBar.qml +++ b/examples/tutorials/gettingStartedQml/parts/part5/core/MenuBar.qml @@ -3,7 +3,7 @@ ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/ ** -** This file is part of the QtDeclarative module of the Qt Toolkit. +** This file is part of the QtQml module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:BSD$ ** You may use this file under the terms of the BSD license as follows: diff --git a/examples/tutorials/gettingStartedQml/parts/part5/core/TextArea.qml b/examples/tutorials/gettingStartedQml/parts/part5/core/TextArea.qml index 0d77c30317..0882633c59 100644 --- a/examples/tutorials/gettingStartedQml/parts/part5/core/TextArea.qml +++ b/examples/tutorials/gettingStartedQml/parts/part5/core/TextArea.qml @@ -3,7 +3,7 @@ ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/ ** -** This file is part of the QtDeclarative module of the Qt Toolkit. +** This file is part of the QtQml module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:BSD$ ** You may use this file under the terms of the BSD license as follows: diff --git a/examples/tutorials/gettingStartedQml/parts/part5/filedialog/dialogPlugin.cpp b/examples/tutorials/gettingStartedQml/parts/part5/filedialog/dialogPlugin.cpp index e4692b0a47..bd5c3f7428 100644 --- a/examples/tutorials/gettingStartedQml/parts/part5/filedialog/dialogPlugin.cpp +++ b/examples/tutorials/gettingStartedQml/parts/part5/filedialog/dialogPlugin.cpp @@ -3,7 +3,7 @@ ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/ ** -** This file is part of the QtDeclarative module of the Qt Toolkit. +** This file is part of the QtQml module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:BSD$ ** You may use this file under the terms of the BSD license as follows: @@ -41,7 +41,7 @@ #include "dialogPlugin.h" #include "directory.h" #include "file.h" -#include +#include void DialogPlugin::registerTypes(const char *uri){ @@ -49,7 +49,7 @@ void DialogPlugin::registerTypes(const char *uri){ qmlRegisterType(uri, 1, 0, "Directory"); qmlRegisterType(uri,1,0,"File"); - //qRegisterMetaType > ("QDeclarativeListProperty"); + //qRegisterMetaType > ("QQmlListProperty"); } diff --git a/examples/tutorials/gettingStartedQml/parts/part5/filedialog/dialogPlugin.h b/examples/tutorials/gettingStartedQml/parts/part5/filedialog/dialogPlugin.h index b46d252616..8d5459a543 100644 --- a/examples/tutorials/gettingStartedQml/parts/part5/filedialog/dialogPlugin.h +++ b/examples/tutorials/gettingStartedQml/parts/part5/filedialog/dialogPlugin.h @@ -3,7 +3,7 @@ ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/ ** -** This file is part of the QtDeclarative module of the Qt Toolkit. +** This file is part of the QtQml module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:BSD$ ** You may use this file under the terms of the BSD license as follows: @@ -41,14 +41,14 @@ #ifndef DIALOGPLUGIN_H #define DIALOGPLUGIN_H -#include +#include -class DialogPlugin : public QDeclarativeExtensionPlugin +class DialogPlugin : public QQmlExtensionPlugin { Q_OBJECT public: - //registerTypes is inherited from QDeclarativeExtensionPlugin + //registerTypes is inherited from QQmlExtensionPlugin void registerTypes(const char *uri); }; diff --git a/examples/tutorials/gettingStartedQml/parts/part5/filedialog/directory.cpp b/examples/tutorials/gettingStartedQml/parts/part5/filedialog/directory.cpp index b2984d3c2d..2247360017 100644 --- a/examples/tutorials/gettingStartedQml/parts/part5/filedialog/directory.cpp +++ b/examples/tutorials/gettingStartedQml/parts/part5/filedialog/directory.cpp @@ -3,7 +3,7 @@ ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/ ** -** This file is part of the QtDeclarative module of the Qt Toolkit. +** This file is part of the QtQml module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:BSD$ ** You may use this file under the terms of the BSD license as follows: @@ -74,39 +74,39 @@ int Directory:: filesCount() const{ /* Function called to append data onto list property */ -void appendFiles(QDeclarativeListProperty * property, File * file){ +void appendFiles(QQmlListProperty * property, File * file){ //Do nothing. can't add to a directory using this method } /* Function called to retrieve file in the list using an index */ -File* fileAt(QDeclarativeListProperty * property, int index){ +File* fileAt(QQmlListProperty * property, int index){ return static_cast< QList *>(property->data)->at(index); } /* Returns the number of files in the list */ -int filesSize(QDeclarativeListProperty * property){ +int filesSize(QQmlListProperty * property){ return static_cast< QList *>(property->data)->size(); } /* Function called to empty the list property contents */ -void clearFilesPtr(QDeclarativeListProperty *property){ +void clearFilesPtr(QQmlListProperty *property){ return static_cast< QList *>(property->data)->clear(); } /* -Returns the list of files as a QDeclarativeListProperty. +Returns the list of files as a QQmlListProperty. */ -QDeclarativeListProperty Directory::files(){ +QQmlListProperty Directory::files(){ refresh(); -// return QDeclarativeListProperty(this,m_filePtrList); //not recommended in the docs - return QDeclarativeListProperty( this, &m_fileList, &appendFiles, &filesSize, &fileAt, &clearFilesPtr ); +// return QQmlListProperty(this,m_filePtrList); //not recommended in the docs + return QQmlListProperty( this, &m_fileList, &appendFiles, &filesSize, &fileAt, &clearFilesPtr ); } /* diff --git a/examples/tutorials/gettingStartedQml/parts/part5/filedialog/directory.h b/examples/tutorials/gettingStartedQml/parts/part5/filedialog/directory.h index 53872f257b..a47e9e112f 100644 --- a/examples/tutorials/gettingStartedQml/parts/part5/filedialog/directory.h +++ b/examples/tutorials/gettingStartedQml/parts/part5/filedialog/directory.h @@ -3,7 +3,7 @@ ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/ ** -** This file is part of the QtDeclarative module of the Qt Toolkit. +** This file is part of the QtQml module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:BSD$ ** You may use this file under the terms of the BSD license as follows: @@ -46,7 +46,7 @@ #include #include #include -#include +#include #include class Directory : public QObject{ @@ -57,7 +57,7 @@ class Directory : public QObject{ Q_PROPERTY(int filesCount READ filesCount) //list property containing file names as QString - Q_PROPERTY(QDeclarativeListProperty files READ files CONSTANT ) + Q_PROPERTY(QQmlListProperty files READ files CONSTANT ) //file name of the text file to read/write Q_PROPERTY(QString filename READ filename WRITE setFilename NOTIFY filenameChanged) @@ -72,7 +72,7 @@ class Directory : public QObject{ int filesCount() const; QString filename() const; QString fileContent() const; - QDeclarativeListProperty files(); + QQmlListProperty files(); //properties' write functions void setFilename(const QString &str); diff --git a/examples/tutorials/gettingStartedQml/parts/part5/filedialog/file.cpp b/examples/tutorials/gettingStartedQml/parts/part5/filedialog/file.cpp index c1b57297cf..2385ed3240 100644 --- a/examples/tutorials/gettingStartedQml/parts/part5/filedialog/file.cpp +++ b/examples/tutorials/gettingStartedQml/parts/part5/filedialog/file.cpp @@ -3,7 +3,7 @@ ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/ ** -** This file is part of the QtDeclarative module of the Qt Toolkit. +** This file is part of the QtQml module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:BSD$ ** You may use this file under the terms of the BSD license as follows: diff --git a/examples/tutorials/gettingStartedQml/parts/part5/filedialog/file.h b/examples/tutorials/gettingStartedQml/parts/part5/filedialog/file.h index d57595607c..251b45282d 100644 --- a/examples/tutorials/gettingStartedQml/parts/part5/filedialog/file.h +++ b/examples/tutorials/gettingStartedQml/parts/part5/filedialog/file.h @@ -3,7 +3,7 @@ ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/ ** -** This file is part of the QtDeclarative module of the Qt Toolkit. +** This file is part of the QtQml module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:BSD$ ** You may use this file under the terms of the BSD license as follows: diff --git a/examples/tutorials/gettingStartedQml/parts/part5/filedialog/filedialog.pro b/examples/tutorials/gettingStartedQml/parts/part5/filedialog/filedialog.pro index 6247747003..71abddc7e3 100644 --- a/examples/tutorials/gettingStartedQml/parts/part5/filedialog/filedialog.pro +++ b/examples/tutorials/gettingStartedQml/parts/part5/filedialog/filedialog.pro @@ -1,6 +1,6 @@ TEMPLATE = lib CONFIG += qt plugin -QT += declarative +QT += qml DESTDIR += ../plugins OBJECTS_DIR = tmp diff --git a/examples/tutorials/gettingStartedQml/texteditor.qml b/examples/tutorials/gettingStartedQml/texteditor.qml index 76d79b6b90..05358294f5 100644 --- a/examples/tutorials/gettingStartedQml/texteditor.qml +++ b/examples/tutorials/gettingStartedQml/texteditor.qml @@ -3,7 +3,7 @@ ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/ ** -** This file is part of the QtDeclarative module of the Qt Toolkit. +** This file is part of the QtQml module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:BSD$ ** You may use this file under the terms of the BSD license as follows: diff --git a/modules/qt_declarative.pri b/modules/qt_declarative.pri deleted file mode 100644 index 54727d462a..0000000000 --- a/modules/qt_declarative.pri +++ /dev/null @@ -1,17 +0,0 @@ -QT.declarative.VERSION = 5.0.0 -QT.declarative.MAJOR_VERSION = 5 -QT.declarative.MINOR_VERSION = 0 -QT.declarative.PATCH_VERSION = 0 - -QT.declarative.name = QtDeclarative -QT.declarative.bins = $$QT_MODULE_BIN_BASE -QT.declarative.includes = $$QT_MODULE_INCLUDE_BASE $$QT_MODULE_INCLUDE_BASE/QtDeclarative -QT.declarative.private_includes = $$QT_MODULE_INCLUDE_BASE/QtDeclarative/$$QT.declarative.VERSION -QT.declarative.sources = $$QT_MODULE_BASE/src/declarative -QT.declarative.libs = $$QT_MODULE_LIB_BASE -QT.declarative.plugins = $$QT_MODULE_PLUGIN_BASE -QT.declarative.imports = $$QT_MODULE_IMPORT_BASE -QT.declarative.depends = gui network xmlpatterns -QT.declarative.DEFINES = QT_DECLARATIVE_LIB - -QT_CONFIG += declarative diff --git a/modules/qt_qml.pri b/modules/qt_qml.pri new file mode 100644 index 0000000000..82e70e3e93 --- /dev/null +++ b/modules/qt_qml.pri @@ -0,0 +1,17 @@ +QT.qml.VERSION = 5.0.0 +QT.qml.MAJOR_VERSION = 5 +QT.qml.MINOR_VERSION = 0 +QT.qml.PATCH_VERSION = 0 + +QT.qml.name = QtQml +QT.qml.bins = $$QT_MODULE_BIN_BASE +QT.qml.includes = $$QT_MODULE_INCLUDE_BASE $$QT_MODULE_INCLUDE_BASE/QtQml +QT.qml.private_includes = $$QT_MODULE_INCLUDE_BASE/QtQml/$$QT.qml.VERSION +QT.qml.sources = $$QT_MODULE_BASE/src/qml +QT.qml.libs = $$QT_MODULE_LIB_BASE +QT.qml.plugins = $$QT_MODULE_PLUGIN_BASE +QT.qml.imports = $$QT_MODULE_IMPORT_BASE +QT.qml.depends = gui network xmlpatterns +QT.qml.DEFINES = QT_QML_LIB + +QT_CONFIG += qml diff --git a/modules/qt_qmltest.pri b/modules/qt_qmltest.pri index d00f621237..e3d747f700 100644 --- a/modules/qt_qmltest.pri +++ b/modules/qt_qmltest.pri @@ -11,7 +11,7 @@ QT.qmltest.sources = $$QT_MODULE_BASE/src/qmltest QT.qmltest.libs = $$QT_MODULE_LIB_BASE QT.qmltest.plugins = $$QT_MODULE_PLUGIN_BASE QT.qmltest.imports = $$QT_MODULE_IMPORT_BASE -QT.qmltest.depends = declarative testlib +QT.qmltest.depends = qml testlib QT.qmltest.DEFINES = QT_QMLTEST_LIB QT_CONFIG += qmltest diff --git a/modules/qt_quick.pri b/modules/qt_quick.pri index 0dc827b732..dc71b31194 100644 --- a/modules/qt_quick.pri +++ b/modules/qt_quick.pri @@ -11,7 +11,7 @@ QT.quick.sources = $$QT_MODULE_BASE/src/quick QT.quick.libs = $$QT_MODULE_LIB_BASE QT.quick.plugins = $$QT_MODULE_PLUGIN_BASE QT.quick.imports = $$QT_MODULE_IMPORT_BASE -QT.quick.depends = declarative +QT.quick.depends = qml QT.quick.DEFINES = QT_QUICK_LIB QT_CONFIG += quick diff --git a/src/declarative/animations/animations.pri b/src/declarative/animations/animations.pri deleted file mode 100644 index 01ac25af46..0000000000 --- a/src/declarative/animations/animations.pri +++ /dev/null @@ -1,16 +0,0 @@ -INCLUDEPATH += $$PWD - -HEADERS += \ - $$PWD/qabstractanimationjob_p.h \ - $$PWD/qanimationgroupjob_p.h \ - $$PWD/qsequentialanimationgroupjob_p.h \ - $$PWD/qparallelanimationgroupjob_p.h \ - $$PWD/qpauseanimationjob_p.h \ - $$PWD/qanimationjobutil_p.h - -SOURCES += \ - $$PWD/qabstractanimationjob.cpp \ - $$PWD/qanimationgroupjob.cpp \ - $$PWD/qsequentialanimationgroupjob.cpp \ - $$PWD/qparallelanimationgroupjob.cpp \ - $$PWD/qpauseanimationjob.cpp diff --git a/src/declarative/animations/qabstractanimationjob.cpp b/src/declarative/animations/qabstractanimationjob.cpp deleted file mode 100644 index 4d149ce99a..0000000000 --- a/src/declarative/animations/qabstractanimationjob.cpp +++ /dev/null @@ -1,544 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include - -#include "private/qabstractanimationjob_p.h" -#include "private/qanimationgroupjob_p.h" -#include "private/qanimationjobutil_p.h" - -#define DEFAULT_TIMER_INTERVAL 16 - -QT_BEGIN_NAMESPACE - -#ifndef QT_NO_THREAD -Q_GLOBAL_STATIC(QThreadStorage, animationTimer) -#endif - -QDeclarativeAnimationTimer::QDeclarativeAnimationTimer() : - QAbstractAnimationTimer(), lastTick(0), lastDelta(0), - currentAnimationIdx(0), insideTick(false), - startAnimationPending(false), stopTimerPending(false), - runningLeafAnimations(0) -{ -} - -QDeclarativeAnimationTimer *QDeclarativeAnimationTimer::instance(bool create) -{ - QDeclarativeAnimationTimer *inst; -#ifndef QT_NO_THREAD - if (create && !animationTimer()->hasLocalData()) { - inst = new QDeclarativeAnimationTimer; - animationTimer()->setLocalData(inst); - } else { - inst = animationTimer() ? animationTimer()->localData() : 0; - } -#else - static QAnimationTimer unifiedTimer; - inst = &unifiedTimer; -#endif - return inst; -} - -QDeclarativeAnimationTimer *QDeclarativeAnimationTimer::instance() -{ - return instance(true); -} - -void QDeclarativeAnimationTimer::ensureTimerUpdate() -{ - QDeclarativeAnimationTimer *inst = QDeclarativeAnimationTimer::instance(false); - QUnifiedTimer *instU = QUnifiedTimer::instance(false); - if (instU && inst && inst->isPaused) - instU->updateAnimationTimers(-1); -} - -void QDeclarativeAnimationTimer::updateAnimationsTime(qint64 delta) -{ - //setCurrentTime can get this called again while we're the for loop. At least with pauseAnimations - if (insideTick) - return; - - lastTick += delta; - lastDelta = delta; - - //we make sure we only call update time if the time has actually changed - //it might happen in some cases that the time doesn't change because events are delayed - //when the CPU load is high - if (delta) { - insideTick = true; - for (currentAnimationIdx = 0; currentAnimationIdx < animations.count(); ++currentAnimationIdx) { - QAbstractAnimationJob *animation = animations.at(currentAnimationIdx); - int elapsed = animation->m_totalCurrentTime - + (animation->direction() == QAbstractAnimationJob::Forward ? delta : -delta); - animation->setCurrentTime(elapsed); - } - insideTick = false; - currentAnimationIdx = 0; - } -} - -void QDeclarativeAnimationTimer::updateAnimationTimer() -{ - QDeclarativeAnimationTimer *inst = QDeclarativeAnimationTimer::instance(false); - if (inst) - inst->restartAnimationTimer(); -} - -void QDeclarativeAnimationTimer::restartAnimationTimer() -{ - if (runningLeafAnimations == 0 && !runningPauseAnimations.isEmpty()) - QUnifiedTimer::pauseAnimationTimer(this, closestPauseAnimationTimeToFinish()); - else if (isPaused) - QUnifiedTimer::resumeAnimationTimer(this); - else if (!isRegistered) - QUnifiedTimer::startAnimationTimer(this); -} - -void QDeclarativeAnimationTimer::startAnimations() -{ - startAnimationPending = false; - //force timer to update, which prevents large deltas for our newly added animations - if (!animations.isEmpty()) - QUnifiedTimer::instance()->maybeUpdateAnimationsToCurrentTime(); - - //we transfer the waiting animations into the "really running" state - animations += animationsToStart; - animationsToStart.clear(); - if (!animations.isEmpty()) - restartAnimationTimer(); -} - -void QDeclarativeAnimationTimer::stopTimer() -{ - stopTimerPending = false; - if (animations.isEmpty()) { - QUnifiedTimer::resumeAnimationTimer(this); - QUnifiedTimer::stopAnimationTimer(this); - // invalidate the start reference time - lastTick = 0; - lastDelta = 0; - } -} - -void QDeclarativeAnimationTimer::registerAnimation(QAbstractAnimationJob *animation, bool isTopLevel) -{ - QDeclarativeAnimationTimer *inst = instance(true); //we create the instance if needed - inst->registerRunningAnimation(animation); - if (isTopLevel) { - Q_ASSERT(!animation->m_hasRegisteredTimer); - animation->m_hasRegisteredTimer = true; - inst->animationsToStart << animation; - if (!inst->startAnimationPending) { - inst->startAnimationPending = true; - QMetaObject::invokeMethod(inst, "startAnimations", Qt::QueuedConnection); - } - } -} - -void QDeclarativeAnimationTimer::unregisterAnimation(QAbstractAnimationJob *animation) -{ - QDeclarativeAnimationTimer *inst = QDeclarativeAnimationTimer::instance(false); - if (inst) { - //at this point the unified timer should have been created - //but it might also have been already destroyed in case the application is shutting down - - inst->unregisterRunningAnimation(animation); - - if (!animation->m_hasRegisteredTimer) - return; - - int idx = inst->animations.indexOf(animation); - if (idx != -1) { - inst->animations.removeAt(idx); - // this is needed if we unregister an animation while its running - if (idx <= inst->currentAnimationIdx) - --inst->currentAnimationIdx; - - if (inst->animations.isEmpty() && !inst->stopTimerPending) { - inst->stopTimerPending = true; - QMetaObject::invokeMethod(inst, "stopTimer", Qt::QueuedConnection); - } - } else { - inst->animationsToStart.removeOne(animation); - } - } - animation->m_hasRegisteredTimer = false; -} - -void QDeclarativeAnimationTimer::registerRunningAnimation(QAbstractAnimationJob *animation) -{ - if (animation->m_isGroup) - return; - - if (animation->m_isPause) { - runningPauseAnimations << animation; - } else - runningLeafAnimations++; -} - -void QDeclarativeAnimationTimer::unregisterRunningAnimation(QAbstractAnimationJob *animation) -{ - if (animation->m_isGroup) - return; - - if (animation->m_isPause) - runningPauseAnimations.removeOne(animation); - else - runningLeafAnimations--; - Q_ASSERT(runningLeafAnimations >= 0); -} - -int QDeclarativeAnimationTimer::closestPauseAnimationTimeToFinish() -{ - int closestTimeToFinish = INT_MAX; - for (int i = 0; i < runningPauseAnimations.size(); ++i) { - QAbstractAnimationJob *animation = runningPauseAnimations.at(i); - int timeToFinish; - - if (animation->direction() == QAbstractAnimationJob::Forward) - timeToFinish = animation->duration() - animation->currentLoopTime(); - else - timeToFinish = animation->currentLoopTime(); - - if (timeToFinish < closestTimeToFinish) - closestTimeToFinish = timeToFinish; - } - return closestTimeToFinish; -} - -///////////////////////////////////////////////////////////////////////////////////////////////////////// - -QAbstractAnimationJob::QAbstractAnimationJob() - : m_isPause(false) - , m_isGroup(false) - , m_loopCount(1) - , m_group(0) - , m_direction(QAbstractAnimationJob::Forward) - , m_state(QAbstractAnimationJob::Stopped) - , m_totalCurrentTime(0) - , m_currentTime(0) - , m_currentLoop(0) - , m_hasRegisteredTimer(false) - , m_uncontrolledFinishTime(-1) - , m_wasDeleted(0) - , m_nextSibling(0) - , m_previousSibling(0) -{ -} - -QAbstractAnimationJob::~QAbstractAnimationJob() -{ - if (m_wasDeleted) - *m_wasDeleted = true; - - //we can't call stop here. Otherwise we get pure virtual calls - if (m_state != Stopped) { - State oldState = m_state; - m_state = Stopped; - stateChanged(oldState, m_state); - if (oldState == Running) - QDeclarativeAnimationTimer::unregisterAnimation(this); - } - - if (m_group) - m_group->removeAnimation(this); -} - -void QAbstractAnimationJob::setState(QAbstractAnimationJob::State newState) -{ - if (m_state == newState) - return; - - if (m_loopCount == 0) - return; - - State oldState = m_state; - int oldCurrentTime = m_currentTime; - int oldCurrentLoop = m_currentLoop; - Direction oldDirection = m_direction; - - // check if we should Rewind - if ((newState == Paused || newState == Running) && oldState == Stopped) { - //here we reset the time if needed - //we don't call setCurrentTime because this might change the way the animation - //behaves: changing the state or changing the current value - m_totalCurrentTime = m_currentTime = (m_direction == Forward) ? - 0 : (m_loopCount == -1 ? duration() : totalDuration()); - } - - m_state = newState; - //(un)registration of the animation must always happen before calls to - //virtual function (updateState) to ensure a correct state of the timer - bool isTopLevel = !m_group || m_group->isStopped(); - if (oldState == Running) { - if (newState == Paused && m_hasRegisteredTimer) - QDeclarativeAnimationTimer::ensureTimerUpdate(); - //the animation, is not running any more - QDeclarativeAnimationTimer::unregisterAnimation(this); - } else if (newState == Running) { - QDeclarativeAnimationTimer::registerAnimation(this, isTopLevel); - } - - //starting an animation qualifies as a top level loop change - if (newState == Running && oldState == Stopped && !m_group) - topLevelAnimationLoopChanged(); - - RETURN_IF_DELETED(updateState(newState, oldState)); - - if (newState != m_state) //this is to be safe if updateState changes the state - return; - - // Notify state change - stateChanged(newState, oldState); - if (newState != m_state) //this is to be safe if updateState changes the state - return; - - switch (m_state) { - case Paused: - break; - case Running: - { - // this ensures that the value is updated now that the animation is running - if (oldState == Stopped) { - if (isTopLevel) { - // currentTime needs to be updated if pauseTimer is active - QDeclarativeAnimationTimer::ensureTimerUpdate(); - setCurrentTime(m_totalCurrentTime); - } - } - } - break; - case Stopped: - // Leave running state. - int dura = duration(); - - if (dura == -1 || m_loopCount < 0 - || (oldDirection == Forward && (oldCurrentTime * (oldCurrentLoop + 1)) == (dura * m_loopCount)) - || (oldDirection == Backward && oldCurrentTime == 0)) { - finished(); - } - break; - } -} - -void QAbstractAnimationJob::setDirection(Direction direction) -{ - if (m_direction == direction) - return; - - if (m_state == Stopped) { - if (m_direction == Backward) { - m_currentTime = duration(); - m_currentLoop = m_loopCount - 1; - } else { - m_currentTime = 0; - m_currentLoop = 0; - } - } - - // the commands order below is important: first we need to setCurrentTime with the old direction, - // then update the direction on this and all children and finally restart the pauseTimer if needed - if (m_hasRegisteredTimer) - QDeclarativeAnimationTimer::ensureTimerUpdate(); - - m_direction = direction; - updateDirection(direction); - - if (m_hasRegisteredTimer) - // needed to update the timer interval in case of a pause animation - QDeclarativeAnimationTimer::updateAnimationTimer(); -} - -void QAbstractAnimationJob::setLoopCount(int loopCount) -{ - m_loopCount = loopCount; -} - -int QAbstractAnimationJob::totalDuration() const -{ - int dura = duration(); - if (dura <= 0) - return dura; - int loopcount = loopCount(); - if (loopcount < 0) - return -1; - return dura * loopcount; -} - -void QAbstractAnimationJob::setCurrentTime(int msecs) -{ - msecs = qMax(msecs, 0); - // Calculate new time and loop. - int dura = duration(); - int totalDura = dura <= 0 ? dura : ((m_loopCount < 0) ? -1 : dura * m_loopCount); - if (totalDura != -1) - msecs = qMin(totalDura, msecs); - m_totalCurrentTime = msecs; - - // Update new values. - int oldLoop = m_currentLoop; - m_currentLoop = ((dura <= 0) ? 0 : (msecs / dura)); - if (m_currentLoop == m_loopCount) { - //we're at the end - m_currentTime = qMax(0, dura); - m_currentLoop = qMax(0, m_loopCount - 1); - } else { - if (m_direction == Forward) { - m_currentTime = (dura <= 0) ? msecs : (msecs % dura); - } else { - m_currentTime = (dura <= 0) ? msecs : ((msecs - 1) % dura) + 1; - if (m_currentTime == dura) - --m_currentLoop; - } - } - - if (m_currentLoop != oldLoop && !m_group) //### verify Running as well? - topLevelAnimationLoopChanged(); - - RETURN_IF_DELETED(updateCurrentTime(m_currentTime)); - - if (m_currentLoop != oldLoop) - currentLoopChanged(m_currentLoop); - - // All animations are responsible for stopping the animation when their - // own end state is reached; in this case the animation is time driven, - // and has reached the end. - if ((m_direction == Forward && m_totalCurrentTime == totalDura) - || (m_direction == Backward && m_totalCurrentTime == 0)) { - stop(); - } -} - -void QAbstractAnimationJob::start() -{ - if (m_state == Running) - return; - setState(Running); -} - -void QAbstractAnimationJob::stop() -{ - if (m_state == Stopped) - return; - setState(Stopped); -} - -void QAbstractAnimationJob::pause() -{ - if (m_state == Stopped) { - qWarning("QAbstractAnimationJob::pause: Cannot pause a stopped animation"); - return; - } - - setState(Paused); -} - -void QAbstractAnimationJob::resume() -{ - if (m_state != Paused) { - qWarning("QAbstractAnimationJob::resume: " - "Cannot resume an animation that is not paused"); - return; - } - setState(Running); -} - -void QAbstractAnimationJob::updateState(QAbstractAnimationJob::State newState, - QAbstractAnimationJob::State oldState) -{ - Q_UNUSED(oldState); - Q_UNUSED(newState); -} - -void QAbstractAnimationJob::updateDirection(QAbstractAnimationJob::Direction direction) -{ - Q_UNUSED(direction); -} - -void QAbstractAnimationJob::finished() -{ - //TODO: update this code so it is valid to delete the animation in animationFinished - for (int i = 0; i < changeListeners.count(); ++i) { - const QAbstractAnimationJob::ChangeListener &change = changeListeners.at(i); - if (change.types & QAbstractAnimationJob::Completion) - change.listener->animationFinished(this); - } - - if (m_group && (duration() == -1 || loopCount() < 0)) { - //this is an uncontrolled animation, need to notify the group animation we are finished - m_group->uncontrolledAnimationFinished(this); - } -} - -void QAbstractAnimationJob::stateChanged(QAbstractAnimationJob::State newState, QAbstractAnimationJob::State oldState) -{ - for (int i = 0; i < changeListeners.count(); ++i) { - const QAbstractAnimationJob::ChangeListener &change = changeListeners.at(i); - if (change.types & QAbstractAnimationJob::StateChange) - change.listener->animationStateChanged(this, newState, oldState); - } -} - -void QAbstractAnimationJob::currentLoopChanged(int currentLoop) -{ - Q_UNUSED(currentLoop); - for (int i = 0; i < changeListeners.count(); ++i) { - const QAbstractAnimationJob::ChangeListener &change = changeListeners.at(i); - if (change.types & QAbstractAnimationJob::CurrentLoop) - change.listener->animationCurrentLoopChanged(this); - } -} - -void QAbstractAnimationJob::addAnimationChangeListener(QAnimationJobChangeListener *listener, QAbstractAnimationJob::ChangeTypes changes) -{ - changeListeners.append(ChangeListener(listener, changes)); -} - -void QAbstractAnimationJob::removeAnimationChangeListener(QAnimationJobChangeListener *listener, QAbstractAnimationJob::ChangeTypes changes) -{ - changeListeners.removeOne(ChangeListener(listener, changes)); -} - - -QT_END_NAMESPACE - -//#include "moc_qabstractanimation2_p.cpp" diff --git a/src/declarative/animations/qabstractanimationjob_p.h b/src/declarative/animations/qabstractanimationjob_p.h deleted file mode 100644 index 675082f0b7..0000000000 --- a/src/declarative/animations/qabstractanimationjob_p.h +++ /dev/null @@ -1,232 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QABSTRACTANIMATIONJOB_P_H -#define QABSTRACTANIMATIONJOB_P_H - -#include -#include -#include "private/qpodvector_p.h" - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -QT_MODULE(Declarative) - -class QAnimationGroupJob; -class QAnimationJobChangeListener; -class Q_DECLARATIVE_EXPORT QAbstractAnimationJob -{ - Q_DISABLE_COPY(QAbstractAnimationJob) -public: - enum Direction { - Forward, - Backward - }; - - enum State { - Stopped, - Paused, - Running - }; - - QAbstractAnimationJob(); - virtual ~QAbstractAnimationJob(); - - //definition - inline QAnimationGroupJob *group() const {return m_group;} - - inline int loopCount() const {return m_loopCount;} - void setLoopCount(int loopCount); - - int totalDuration() const; - virtual int duration() const {return 0;} - - inline QAbstractAnimationJob::Direction direction() const {return m_direction;} - void setDirection(QAbstractAnimationJob::Direction direction); - - //state - inline int currentTime() const {return m_totalCurrentTime;} - inline int currentLoopTime() const {return m_currentTime;} - inline int currentLoop() const {return m_currentLoop;} - inline QAbstractAnimationJob::State state() const {return m_state;} - inline bool isRunning() { return m_state == Running; } - inline bool isStopped() { return m_state == Stopped; } - inline bool isPaused() { return m_state == Paused; } - - void setCurrentTime(int msecs); - - void start(); - void pause(); - void resume(); - void stop(); - - enum ChangeType { - Completion = 0x01, - StateChange = 0x02, - CurrentLoop = 0x04 - }; - Q_DECLARE_FLAGS(ChangeTypes, ChangeType) - - void addAnimationChangeListener(QAnimationJobChangeListener *listener, QAbstractAnimationJob::ChangeTypes); - void removeAnimationChangeListener(QAnimationJobChangeListener *listener, QAbstractAnimationJob::ChangeTypes); - - QAbstractAnimationJob *nextSibling() const { return m_nextSibling; } - QAbstractAnimationJob *previousSibling() const { return m_previousSibling; } - -protected: - virtual void updateCurrentTime(int) {} - virtual void updateState(QAbstractAnimationJob::State newState, QAbstractAnimationJob::State oldState); - virtual void updateDirection(QAbstractAnimationJob::Direction direction); - virtual void topLevelAnimationLoopChanged() {} - - void setState(QAbstractAnimationJob::State state); - - void finished(); - void stateChanged(QAbstractAnimationJob::State newState, QAbstractAnimationJob::State oldState); - void currentLoopChanged(int currentLoop); - void directionChanged(QAbstractAnimationJob::Direction); - - //definition - bool m_isPause; - bool m_isGroup; - int m_loopCount; - QAnimationGroupJob *m_group; - QAbstractAnimationJob::Direction m_direction; - - //state - QAbstractAnimationJob::State m_state; - int m_totalCurrentTime; - int m_currentTime; - int m_currentLoop; - bool m_hasRegisteredTimer; - //records the finish time for an uncontrolled animation (used by animation groups) - int m_uncontrolledFinishTime; - bool *m_wasDeleted; - - struct ChangeListener { - ChangeListener(QAnimationJobChangeListener *l, QAbstractAnimationJob::ChangeTypes t) : listener(l), types(t) {} - QAnimationJobChangeListener *listener; - QAbstractAnimationJob::ChangeTypes types; - bool operator==(const ChangeListener &other) const { return listener == other.listener && types == other.types; } - }; - QPODVector changeListeners; - - QAbstractAnimationJob *m_nextSibling; - QAbstractAnimationJob *m_previousSibling; - - friend class QDeclarativeAnimationTimer; - friend class QAnimationGroupJob; -}; - -class Q_AUTOTEST_EXPORT QAnimationJobChangeListener -{ -public: - virtual void animationFinished(QAbstractAnimationJob *) {} - virtual void animationStateChanged(QAbstractAnimationJob *, QAbstractAnimationJob::State, QAbstractAnimationJob::State) {} - virtual void animationCurrentLoopChanged(QAbstractAnimationJob *) {} -}; - -class Q_DECLARATIVE_EXPORT QDeclarativeAnimationTimer : public QAbstractAnimationTimer -{ - Q_OBJECT -private: - QDeclarativeAnimationTimer(); - -public: - static QDeclarativeAnimationTimer *instance(); - static QDeclarativeAnimationTimer *instance(bool create); - - static void registerAnimation(QAbstractAnimationJob *animation, bool isTopLevel); - static void unregisterAnimation(QAbstractAnimationJob *animation); - - /* - this is used for updating the currentTime of all animations in case the pause - timer is active or, otherwise, only of the animation passed as parameter. - */ - static void ensureTimerUpdate(); - - /* - this will evaluate the need of restarting the pause timer in case there is still - some pause animations running. - */ - static void updateAnimationTimer(); - - void restartAnimationTimer(); - void updateAnimationsTime(qint64 timeStep); - - int currentDelta() { return lastDelta; } - - //useful for profiling/debugging - int runningAnimationCount() { return animations.count(); } - -private Q_SLOTS: - void startAnimations(); - void stopTimer(); - -private: - qint64 lastTick; - int lastDelta; - int currentAnimationIdx; - bool insideTick; - bool startAnimationPending; - bool stopTimerPending; - - QList animations, animationsToStart; - - // this is the count of running animations that are not a group neither a pause animation - int runningLeafAnimations; - QList runningPauseAnimations; - - void registerRunningAnimation(QAbstractAnimationJob *animation); - void unregisterRunningAnimation(QAbstractAnimationJob *animation); - - int closestPauseAnimationTimeToFinish(); -}; - -Q_DECLARE_OPERATORS_FOR_FLAGS(QAbstractAnimationJob::ChangeTypes) - -QT_END_NAMESPACE - -QT_END_HEADER - -#endif // QABSTRACTANIMATIONJOB_P_H diff --git a/src/declarative/animations/qanimationgroupjob.cpp b/src/declarative/animations/qanimationgroupjob.cpp deleted file mode 100644 index 7e26f9778d..0000000000 --- a/src/declarative/animations/qanimationgroupjob.cpp +++ /dev/null @@ -1,164 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "private/qanimationgroupjob_p.h" - -QT_BEGIN_NAMESPACE - -QAnimationGroupJob::QAnimationGroupJob() - : QAbstractAnimationJob(), m_firstChild(0), m_lastChild(0) -{ - m_isGroup = true; -} - -QAnimationGroupJob::~QAnimationGroupJob() -{ - while (firstChild() != 0) - delete firstChild(); -} - -void QAnimationGroupJob::topLevelAnimationLoopChanged() -{ - for (QAbstractAnimationJob *animation = firstChild(); animation; animation = animation->nextSibling()) - animation->topLevelAnimationLoopChanged(); -} - -void QAnimationGroupJob::appendAnimation(QAbstractAnimationJob *animation) -{ - if (QAnimationGroupJob *oldGroup = animation->m_group) - oldGroup->removeAnimation(animation); - - Q_ASSERT(!animation->previousSibling() && !animation->nextSibling()); - - if (m_lastChild) - m_lastChild->m_nextSibling = animation; - else - m_firstChild = animation; - animation->m_previousSibling = m_lastChild; - m_lastChild = animation; - - animation->m_group = this; - animationInserted(animation); -} - -void QAnimationGroupJob::prependAnimation(QAbstractAnimationJob *animation) -{ - if (QAnimationGroupJob *oldGroup = animation->m_group) - oldGroup->removeAnimation(animation); - - Q_ASSERT(!previousSibling() && !nextSibling()); - - if (m_firstChild) - m_firstChild->m_previousSibling = animation; - else - m_lastChild = animation; - animation->m_nextSibling = m_firstChild; - m_firstChild = animation; - - animation->m_group = this; - animationInserted(animation); -} - -void QAnimationGroupJob::removeAnimation(QAbstractAnimationJob *animation) -{ - Q_ASSERT(animation); - Q_ASSERT(animation->m_group == this); - QAbstractAnimationJob *prev = animation->previousSibling(); - QAbstractAnimationJob *next = animation->nextSibling(); - - if (prev) - prev->m_nextSibling = next; - else - m_firstChild = next; - - if (next) - next->m_previousSibling = prev; - else - m_lastChild = prev; - - animation->m_previousSibling = 0; - animation->m_nextSibling = 0; - - animation->m_group = 0; - animationRemoved(animation, prev, next); -} - -void QAnimationGroupJob::clear() -{ - //### should this remove and delete, or just remove? - while (firstChild() != 0) - delete firstChild(); //removeAnimation(firstChild()); -} - -void QAnimationGroupJob::resetUncontrolledAnimationsFinishTime() -{ - for (QAbstractAnimationJob *animation = firstChild(); animation; animation = animation->nextSibling()) { - if (animation->duration() == -1 || animation->loopCount() < 0) { - resetUncontrolledAnimationFinishTime(animation); - } - } -} - -void QAnimationGroupJob::resetUncontrolledAnimationFinishTime(QAbstractAnimationJob *anim) -{ - setUncontrolledAnimationFinishTime(anim, -1); -} - -void QAnimationGroupJob::setUncontrolledAnimationFinishTime(QAbstractAnimationJob *anim, int time) -{ - anim->m_uncontrolledFinishTime = time; -} - -void QAnimationGroupJob::uncontrolledAnimationFinished(QAbstractAnimationJob *animation) -{ - Q_UNUSED(animation); -} - -void QAnimationGroupJob::animationRemoved(QAbstractAnimationJob* anim, QAbstractAnimationJob* , QAbstractAnimationJob* ) -{ - resetUncontrolledAnimationFinishTime(anim); - if (!firstChild()) { - m_currentTime = 0; - stop(); - } -} - -QT_END_NAMESPACE diff --git a/src/declarative/animations/qanimationgroupjob_p.h b/src/declarative/animations/qanimationgroupjob_p.h deleted file mode 100644 index d1917a5249..0000000000 --- a/src/declarative/animations/qanimationgroupjob_p.h +++ /dev/null @@ -1,93 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QANIMATIONGROUPJOB_P_H -#define QANIMATIONGROUPJOB_P_H - -#include "private/qabstractanimationjob_p.h" - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -QT_MODULE(Declarative) - -class Q_DECLARATIVE_EXPORT QAnimationGroupJob : public QAbstractAnimationJob -{ - Q_DISABLE_COPY(QAnimationGroupJob) -public: - QAnimationGroupJob(); - ~QAnimationGroupJob(); - - void appendAnimation(QAbstractAnimationJob *animation); - void prependAnimation(QAbstractAnimationJob *animation); - void removeAnimation(QAbstractAnimationJob *animation); - - QAbstractAnimationJob *firstChild() const { return m_firstChild; } - QAbstractAnimationJob *lastChild() const { return m_lastChild; } - - void clear(); - - //called by QAbstractAnimationJob - virtual void uncontrolledAnimationFinished(QAbstractAnimationJob *animation); -protected: - void topLevelAnimationLoopChanged(); - - virtual void animationInserted(QAbstractAnimationJob*) { } - virtual void animationRemoved(QAbstractAnimationJob*, QAbstractAnimationJob*, QAbstractAnimationJob*); - - //TODO: confirm location of these (should any be moved into QAbstractAnimationJob?) - void resetUncontrolledAnimationsFinishTime(); - void resetUncontrolledAnimationFinishTime(QAbstractAnimationJob *anim); - int uncontrolledAnimationFinishTime(QAbstractAnimationJob *anim) const { return anim->m_uncontrolledFinishTime; } - void setUncontrolledAnimationFinishTime(QAbstractAnimationJob *anim, int time); - -private: - //definition - QAbstractAnimationJob *m_firstChild; - QAbstractAnimationJob *m_lastChild; -}; - -QT_END_NAMESPACE - -QT_END_HEADER - -#endif //QANIMATIONGROUPJOB_P_H diff --git a/src/declarative/animations/qanimationjobutil_p.h b/src/declarative/animations/qanimationjobutil_p.h deleted file mode 100644 index b8a627e2da..0000000000 --- a/src/declarative/animations/qanimationjobutil_p.h +++ /dev/null @@ -1,59 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QANIMATIONJOBUTIL_P_H -#define QANIMATIONJOBUTIL_P_H - -#define RETURN_IF_DELETED(func) \ -{ \ - bool *prevWasDeleted = m_wasDeleted; \ - bool wasDeleted = false; \ - m_wasDeleted = &wasDeleted; \ - func; \ - if (wasDeleted) { \ - if (prevWasDeleted) \ - *prevWasDeleted = true; \ - return; \ - } \ - m_wasDeleted = prevWasDeleted; \ -} - -#endif // QANIMATIONJOBUTIL_P_H diff --git a/src/declarative/animations/qparallelanimationgroupjob.cpp b/src/declarative/animations/qparallelanimationgroupjob.cpp deleted file mode 100644 index 5a417dccf4..0000000000 --- a/src/declarative/animations/qparallelanimationgroupjob.cpp +++ /dev/null @@ -1,227 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "private/qparallelanimationgroupjob_p.h" -#include "private/qanimationjobutil_p.h" - -QT_BEGIN_NAMESPACE - -QParallelAnimationGroupJob::QParallelAnimationGroupJob() - : QAnimationGroupJob() - , m_previousLoop(0) - , m_previousCurrentTime(0) -{ -} - -QParallelAnimationGroupJob::~QParallelAnimationGroupJob() -{ -} - -int QParallelAnimationGroupJob::duration() const -{ - int ret = 0; - - for (QAbstractAnimationJob *animation = firstChild(); animation; animation = animation->nextSibling()) { - int currentDuration = animation->totalDuration(); - //this takes care of the case where a parallel animation group has controlled and uncontrolled - //animations, and the uncontrolled stop before the controlled - if (currentDuration == -1) - currentDuration = uncontrolledAnimationFinishTime(animation); - if (currentDuration == -1) - return -1; // Undetermined length - - ret = qMax(ret, currentDuration); - } - - return ret; -} - -void QParallelAnimationGroupJob::updateCurrentTime(int /*currentTime*/) -{ - if (!firstChild()) - return; - - if (m_currentLoop > m_previousLoop) { - // simulate completion of the loop - int dura = duration(); - if (dura > 0) { - for (QAbstractAnimationJob *animation = firstChild(); animation; animation = animation->nextSibling()) { - if (!animation->isStopped()) - RETURN_IF_DELETED(animation->setCurrentTime(dura)); // will stop - } - } - } else if (m_currentLoop < m_previousLoop) { - // simulate completion of the loop seeking backwards - for (QAbstractAnimationJob *animation = firstChild(); animation; animation = animation->nextSibling()) { - //we need to make sure the animation is in the right state - //and then rewind it - applyGroupState(animation); - RETURN_IF_DELETED(animation->setCurrentTime(0)); - animation->stop(); - } - } - - // finally move into the actual time of the current loop - for (QAbstractAnimationJob *animation = firstChild(); animation; animation = animation->nextSibling()) { - const int dura = animation->totalDuration(); - //if the loopcount is bigger we should always start all animations - if (m_currentLoop > m_previousLoop - //if we're at the end of the animation, we need to start it if it wasn't already started in this loop - //this happens in Backward direction where not all animations are started at the same time - || shouldAnimationStart(animation, m_previousCurrentTime > dura /*startIfAtEnd*/)) { - applyGroupState(animation); - } - - if (animation->state() == state()) { - RETURN_IF_DELETED(animation->setCurrentTime(m_currentTime)); - if (dura > 0 && m_currentTime > dura) - animation->stop(); - } - } - m_previousLoop = m_currentLoop; - m_previousCurrentTime = m_currentTime; -} - -void QParallelAnimationGroupJob::updateState(QAbstractAnimationJob::State newState, - QAbstractAnimationJob::State oldState) -{ - QAnimationGroupJob::updateState(newState, oldState); - - switch (newState) { - case Stopped: - for (QAbstractAnimationJob *animation = firstChild(); animation; animation = animation->nextSibling()) - animation->stop(); - break; - case Paused: - for (QAbstractAnimationJob *animation = firstChild(); animation; animation = animation->nextSibling()) - if (animation->isRunning()) - animation->pause(); - break; - case Running: - for (QAbstractAnimationJob *animation = firstChild(); animation; animation = animation->nextSibling()) { - if (oldState == Stopped) - animation->stop(); - resetUncontrolledAnimationFinishTime(animation); - animation->setDirection(m_direction); - if (shouldAnimationStart(animation, oldState == Stopped)) - animation->start(); - } - break; - } -} - -bool QParallelAnimationGroupJob::shouldAnimationStart(QAbstractAnimationJob *animation, bool startIfAtEnd) const -{ - const int dura = animation->totalDuration(); - - if (dura == -1) - return uncontrolledAnimationFinishTime(animation) == -1; - - if (startIfAtEnd) - return m_currentTime <= dura; - if (m_direction == Forward) - return m_currentTime < dura; - else //direction == Backward - return m_currentTime && m_currentTime <= dura; -} - -void QParallelAnimationGroupJob::applyGroupState(QAbstractAnimationJob *animation) -{ - switch (m_state) - { - case Running: - animation->start(); - break; - case Paused: - animation->pause(); - break; - case Stopped: - default: - break; - } -} - -void QParallelAnimationGroupJob::updateDirection(QAbstractAnimationJob::Direction direction) -{ - //we need to update the direction of the current animation - if (!isStopped()) { - for (QAbstractAnimationJob *animation = firstChild(); animation; animation = animation->nextSibling()) { - animation->setDirection(direction); - } - } else { - if (direction == Forward) { - m_previousLoop = 0; - m_previousCurrentTime = 0; - } else { - // Looping backwards with loopCount == -1 does not really work well... - m_previousLoop = (m_loopCount == -1 ? 0 : m_loopCount - 1); - m_previousCurrentTime = duration(); - } - } -} - -void QParallelAnimationGroupJob::uncontrolledAnimationFinished(QAbstractAnimationJob *animation) -{ - Q_ASSERT(animation && (animation->duration() == -1 || animation->loopCount() < 0)); - int uncontrolledRunningCount = 0; - - for (QAbstractAnimationJob *child = firstChild(); child; child = child->nextSibling()) { - if (child == animation) { - setUncontrolledAnimationFinishTime(animation, animation->currentTime()); - } else if (child->duration() == -1 || child->loopCount() < 0) { - if (uncontrolledAnimationFinishTime(child) == -1) - ++uncontrolledRunningCount; - } - } - - if (uncontrolledRunningCount > 0) - return; - - int maxDuration = 0; - for (QAbstractAnimationJob *animation = firstChild(); animation; animation = animation->nextSibling()) - maxDuration = qMax(maxDuration, animation->totalDuration()); - - if (m_currentTime >= maxDuration) - stop(); -} - -QT_END_NAMESPACE - diff --git a/src/declarative/animations/qparallelanimationgroupjob_p.h b/src/declarative/animations/qparallelanimationgroupjob_p.h deleted file mode 100644 index 42a96b50d5..0000000000 --- a/src/declarative/animations/qparallelanimationgroupjob_p.h +++ /dev/null @@ -1,81 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QPARALLELANIMATIONGROUPJOB_P_H -#define QPARALLELANIMATIONGROUPJOB_P_H - -#include "private/qanimationgroupjob_p.h" - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -QT_MODULE(Declarative) - -class Q_DECLARATIVE_EXPORT QParallelAnimationGroupJob : public QAnimationGroupJob -{ - Q_DISABLE_COPY(QParallelAnimationGroupJob) -public: - QParallelAnimationGroupJob(); - ~QParallelAnimationGroupJob(); - - int duration() const; - -protected: - void updateCurrentTime(int currentTime); - void updateState(QAbstractAnimationJob::State newState, QAbstractAnimationJob::State oldState); - void updateDirection(QAbstractAnimationJob::Direction direction); - void uncontrolledAnimationFinished(QAbstractAnimationJob *animation); - -private: - bool shouldAnimationStart(QAbstractAnimationJob *animation, bool startIfAtEnd) const; - void applyGroupState(QAbstractAnimationJob *animation); - - //state - int m_previousLoop; - int m_previousCurrentTime; -}; - -QT_END_NAMESPACE - -QT_END_HEADER - -#endif // QPARALLELANIMATIONGROUPJOB_P_H diff --git a/src/declarative/animations/qpauseanimationjob.cpp b/src/declarative/animations/qpauseanimationjob.cpp deleted file mode 100644 index c362f5ab58..0000000000 --- a/src/declarative/animations/qpauseanimationjob.cpp +++ /dev/null @@ -1,71 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "private/qpauseanimationjob_p.h" - -QT_BEGIN_NAMESPACE - -QPauseAnimationJob::QPauseAnimationJob(int duration) - : QAbstractAnimationJob() - , m_duration(duration) -{ - m_isPause = true; -} - -QPauseAnimationJob::~QPauseAnimationJob() -{ -} - -int QPauseAnimationJob::duration() const -{ - return m_duration; -} - -void QPauseAnimationJob::setDuration(int msecs) -{ - m_duration = msecs; -} - -void QPauseAnimationJob::updateCurrentTime(int) -{ -} - -QT_END_NAMESPACE diff --git a/src/declarative/animations/qpauseanimationjob_p.h b/src/declarative/animations/qpauseanimationjob_p.h deleted file mode 100644 index d4af832577..0000000000 --- a/src/declarative/animations/qpauseanimationjob_p.h +++ /dev/null @@ -1,75 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QPAUSEANIMATIONJOB_P_H -#define QPAUSEANIMATIONJOB_P_H - -#include - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -QT_MODULE(Declarative) - -class Q_DECLARATIVE_EXPORT QPauseAnimationJob : public QAbstractAnimationJob -{ - Q_DISABLE_COPY(QPauseAnimationJob) -public: - explicit QPauseAnimationJob(int duration = 250); - ~QPauseAnimationJob(); - - int duration() const; - void setDuration(int msecs); - -protected: - void updateCurrentTime(int); - -private: - //definition - int m_duration; -}; - -QT_END_NAMESPACE - -QT_END_HEADER - -#endif // QPAUSEANIMATIONJOB_P_H diff --git a/src/declarative/animations/qsequentialanimationgroupjob.cpp b/src/declarative/animations/qsequentialanimationgroupjob.cpp deleted file mode 100644 index f999ca34d7..0000000000 --- a/src/declarative/animations/qsequentialanimationgroupjob.cpp +++ /dev/null @@ -1,388 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "private/qsequentialanimationgroupjob_p.h" -#include "private/qpauseanimationjob_p.h" -#include "private/qanimationjobutil_p.h" - -QT_BEGIN_NAMESPACE - -QSequentialAnimationGroupJob::QSequentialAnimationGroupJob() - : QAnimationGroupJob() - , m_currentAnimation(0) - , m_previousLoop(0) -{ -} - -QSequentialAnimationGroupJob::~QSequentialAnimationGroupJob() -{ -} - -bool QSequentialAnimationGroupJob::atEnd() const -{ - // we try to detect if we're at the end of the group - //this is true if the following conditions are true: - // 1. we're in the last loop - // 2. the direction is forward - // 3. the current animation is the last one - // 4. the current animation has reached its end - const int animTotalCurrentTime = m_currentAnimation->currentTime(); - return (m_currentLoop == m_loopCount - 1 - && m_direction == Forward - && !m_currentAnimation->nextSibling() - && animTotalCurrentTime == animationActualTotalDuration(m_currentAnimation)); -} - -int QSequentialAnimationGroupJob::animationActualTotalDuration(QAbstractAnimationJob *anim) const -{ - int ret = anim->totalDuration(); - if (ret == -1) - ret = uncontrolledAnimationFinishTime(anim); //we can try the actual duration there - return ret; -} - -QSequentialAnimationGroupJob::AnimationIndex QSequentialAnimationGroupJob::indexForCurrentTime() const -{ - Q_ASSERT(firstChild()); - - AnimationIndex ret; - QAbstractAnimationJob *anim = 0; - int duration = 0; - - for (anim = firstChild(); anim; anim = anim->nextSibling()) { - duration = animationActualTotalDuration(anim); - - // 'animation' is the current animation if one of these reasons is true: - // 1. it's duration is undefined - // 2. it ends after msecs - // 3. it is the last animation (this can happen in case there is at least 1 uncontrolled animation) - // 4. it ends exactly in msecs and the direction is backwards - if (duration == -1 || m_currentTime < (ret.timeOffset + duration) - || (m_currentTime == (ret.timeOffset + duration) && m_direction == QAbstractAnimationJob::Backward)) { - ret.animation = anim; - return ret; - } - - if (anim == m_currentAnimation) - ret.afterCurrent = true; - - // 'animation' has a non-null defined duration and is not the one at time 'msecs'. - ret.timeOffset += duration; - } - - // this can only happen when one of those conditions is true: - // 1. the duration of the group is undefined and we passed its actual duration - // 2. there are only 0-duration animations in the group - ret.timeOffset -= duration; - ret.animation = lastChild(); - return ret; -} - -void QSequentialAnimationGroupJob::restart() -{ - // restarting the group by making the first/last animation the current one - if (m_direction == Forward) { - m_previousLoop = 0; - if (m_currentAnimation == firstChild()) - activateCurrentAnimation(); - else - setCurrentAnimation(firstChild()); - } - else { // direction == Backward - m_previousLoop = m_loopCount - 1; - if (m_currentAnimation == lastChild()) - activateCurrentAnimation(); - else - setCurrentAnimation(lastChild()); - } -} - -void QSequentialAnimationGroupJob::advanceForwards(const AnimationIndex &newAnimationIndex) -{ - if (m_previousLoop < m_currentLoop) { - // we need to fast forward to the end - for (QAbstractAnimationJob *anim = m_currentAnimation; anim; anim = anim->nextSibling()) { - setCurrentAnimation(anim, true); - RETURN_IF_DELETED(anim->setCurrentTime(animationActualTotalDuration(anim))); - } - // this will make sure the current animation is reset to the beginning - if (firstChild() && !firstChild()->nextSibling()) //count == 1 - // we need to force activation because setCurrentAnimation will have no effect - activateCurrentAnimation(); - else - setCurrentAnimation(firstChild(), true); - } - - // and now we need to fast forward from the current position to - for (QAbstractAnimationJob *anim = m_currentAnimation; anim && anim != newAnimationIndex.animation; anim = anim->nextSibling()) { //### WRONG, - setCurrentAnimation(anim, true); - RETURN_IF_DELETED(anim->setCurrentTime(animationActualTotalDuration(anim))); - } - // setting the new current animation will happen later -} - -void QSequentialAnimationGroupJob::rewindForwards(const AnimationIndex &newAnimationIndex) -{ - if (m_previousLoop > m_currentLoop) { - // we need to fast rewind to the beginning - for (QAbstractAnimationJob *anim = m_currentAnimation; anim; anim = anim->previousSibling()) { - setCurrentAnimation(anim, true); - RETURN_IF_DELETED(anim->setCurrentTime(0)); - } - // this will make sure the current animation is reset to the end - if (lastChild() && !lastChild()->previousSibling()) //count == 1 - // we need to force activation because setCurrentAnimation will have no effect - activateCurrentAnimation(); - else { - setCurrentAnimation(lastChild(), true); - } - } - - // and now we need to fast rewind from the current position to - for (QAbstractAnimationJob *anim = m_currentAnimation; anim && anim != newAnimationIndex.animation; anim = anim->previousSibling()) { - setCurrentAnimation(anim, true); - RETURN_IF_DELETED(anim->setCurrentTime(0)); - } - // setting the new current animation will happen later -} - -int QSequentialAnimationGroupJob::duration() const -{ - int ret = 0; - - for (QAbstractAnimationJob *anim = firstChild(); anim; anim = anim->nextSibling()) { - const int currentDuration = anim->totalDuration(); - if (currentDuration == -1) - return -1; // Undetermined length - - ret += currentDuration; - } - - return ret; -} - -void QSequentialAnimationGroupJob::updateCurrentTime(int currentTime) -{ - if (!m_currentAnimation) - return; - - const QSequentialAnimationGroupJob::AnimationIndex newAnimationIndex = indexForCurrentTime(); - - // newAnimationIndex.index is the new current animation - if (m_previousLoop < m_currentLoop - || (m_previousLoop == m_currentLoop && m_currentAnimation != newAnimationIndex.animation && newAnimationIndex.afterCurrent)) { - // advancing with forward direction is the same as rewinding with backwards direction - RETURN_IF_DELETED(advanceForwards(newAnimationIndex)); - } else if (m_previousLoop > m_currentLoop - || (m_previousLoop == m_currentLoop && m_currentAnimation != newAnimationIndex.animation && !newAnimationIndex.afterCurrent)) { - // rewinding with forward direction is the same as advancing with backwards direction - RETURN_IF_DELETED(rewindForwards(newAnimationIndex)); - } - - setCurrentAnimation(newAnimationIndex.animation); - - const int newCurrentTime = currentTime - newAnimationIndex.timeOffset; - - if (m_currentAnimation) { - RETURN_IF_DELETED(m_currentAnimation->setCurrentTime(newCurrentTime)); - if (atEnd()) { - //we make sure that we don't exceed the duration here - m_currentTime += m_currentAnimation->currentTime() - newCurrentTime; - stop(); - } - } else { - //the only case where currentAnimation could be null - //is when all animations have been removed - Q_ASSERT(!firstChild()); - m_currentTime = 0; - stop(); - } - - m_previousLoop = m_currentLoop; -} - -void QSequentialAnimationGroupJob::updateState(QAbstractAnimationJob::State newState, - QAbstractAnimationJob::State oldState) -{ - QAnimationGroupJob::updateState(newState, oldState); - - if (!m_currentAnimation) - return; - - switch (newState) { - case Stopped: - m_currentAnimation->stop(); - break; - case Paused: - if (oldState == m_currentAnimation->state() && oldState == Running) - m_currentAnimation->pause(); - else - restart(); - break; - case Running: - if (oldState == m_currentAnimation->state() && oldState == Paused) - m_currentAnimation->start(); - else - restart(); - break; - } -} - -void QSequentialAnimationGroupJob::updateDirection(QAbstractAnimationJob::Direction direction) -{ - // we need to update the direction of the current animation - if (!isStopped() && m_currentAnimation) - m_currentAnimation->setDirection(direction); -} - -void QSequentialAnimationGroupJob::setCurrentAnimation(QAbstractAnimationJob *anim, bool intermediate) -{ - if (!anim) { - Q_ASSERT(!firstChild()); - m_currentAnimation = 0; - return; - } - - if (anim == m_currentAnimation) - return; - - // stop the old current animation - if (m_currentAnimation) - m_currentAnimation->stop(); - - m_currentAnimation = anim; - - activateCurrentAnimation(intermediate); -} - -void QSequentialAnimationGroupJob::activateCurrentAnimation(bool intermediate) -{ - if (!m_currentAnimation || isStopped()) - return; - - m_currentAnimation->stop(); - - // we ensure the direction is consistent with the group's direction - m_currentAnimation->setDirection(m_direction); - - // reset the finish time of the animation if it is uncontrolled - if (m_currentAnimation->totalDuration() == -1) - resetUncontrolledAnimationFinishTime(m_currentAnimation); - - m_currentAnimation->start(); - if (!intermediate && isPaused()) - m_currentAnimation->pause(); -} - -void QSequentialAnimationGroupJob::uncontrolledAnimationFinished(QAbstractAnimationJob *animation) -{ - Q_UNUSED(animation); - Q_ASSERT(animation == m_currentAnimation); - - setUncontrolledAnimationFinishTime(m_currentAnimation, m_currentAnimation->currentTime()); - - if ((m_direction == Forward && m_currentAnimation == lastChild()) - || (m_direction == Backward && m_currentAnimation == firstChild())) { - // we don't handle looping of a group with undefined duration - stop(); - } else if (m_direction == Forward) { - // set the current animation to be the next one - setCurrentAnimation(m_currentAnimation->nextSibling()); - } else { - // set the current animation to be the previous one - setCurrentAnimation(m_currentAnimation->previousSibling()); - } -} - -void QSequentialAnimationGroupJob::animationInserted(QAbstractAnimationJob *anim) -{ - if (m_currentAnimation == 0) - setCurrentAnimation(firstChild()); // initialize the current animation - - if (m_currentAnimation == anim->nextSibling() - && m_currentAnimation->currentTime() == 0 && m_currentAnimation->currentLoop() == 0) { - //in this case we simply insert the animation before the current one has actually started - setCurrentAnimation(anim); - } - -// TODO -// if (index < m_currentAnimationIndex || m_currentLoop != 0) { -// qWarning("QSequentialGroup::insertAnimation only supports to add animations after the current one."); -// return; //we're not affected because it is added after the current one -// } -} - -void QSequentialAnimationGroupJob::animationRemoved(QAbstractAnimationJob *anim, QAbstractAnimationJob *prev, QAbstractAnimationJob *next) -{ - QAnimationGroupJob::animationRemoved(anim, prev, next); - - Q_ASSERT(m_currentAnimation); // currentAnimation should always be set - - bool removingCurrent = anim == m_currentAnimation; - if (removingCurrent) { - if (next) - setCurrentAnimation(next); //let's try to take the next one - else if (prev) - setCurrentAnimation(prev); - else// case all animations were removed - setCurrentAnimation(0); - } - - // duration of the previous animations up to the current animation - m_currentTime = 0; - for (QAbstractAnimationJob *anim = firstChild(); anim; anim = anim->nextSibling()) { - if (anim == m_currentAnimation) - break; - m_currentTime += animationActualTotalDuration(anim); - - } - - if (!removingCurrent) { - //the current animation is not the one being removed - //so we add its current time to the current time of this group - m_currentTime += m_currentAnimation->currentTime(); - } - - //let's also update the total current time - m_totalCurrentTime = m_currentTime + m_loopCount * duration(); -} - -QT_END_NAMESPACE diff --git a/src/declarative/animations/qsequentialanimationgroupjob_p.h b/src/declarative/animations/qsequentialanimationgroupjob_p.h deleted file mode 100644 index 4c1fb2d55a..0000000000 --- a/src/declarative/animations/qsequentialanimationgroupjob_p.h +++ /dev/null @@ -1,108 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QSEQUENTIALANIMATIONGROUPJOB_P_H -#define QSEQUENTIALANIMATIONGROUPJOB_P_H - -#include - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -QT_MODULE(Declarative) - -class QPauseAnimationJob; -class Q_DECLARATIVE_EXPORT QSequentialAnimationGroupJob : public QAnimationGroupJob -{ - Q_DISABLE_COPY(QSequentialAnimationGroupJob) -public: - QSequentialAnimationGroupJob(); - ~QSequentialAnimationGroupJob(); - - int duration() const; - - QAbstractAnimationJob *currentAnimation() const { return m_currentAnimation; } - -protected: - void updateCurrentTime(int); - void updateState(QAbstractAnimationJob::State newState, QAbstractAnimationJob::State oldState); - void updateDirection(QAbstractAnimationJob::Direction direction); - void uncontrolledAnimationFinished(QAbstractAnimationJob *animation); - -private: - struct AnimationIndex - { - AnimationIndex() : afterCurrent(false), timeOffset(0), animation(0) {} - // AnimationIndex points to the animation at timeOffset, skipping 0 duration animations. - // Note that the index semantic is slightly different depending on the direction. - bool afterCurrent; //whether animation is before or after m_currentAnimation //TODO: make enum Before/After/Same - int timeOffset; // time offset when the animation at index starts. - QAbstractAnimationJob *animation; //points to the animation at timeOffset - }; - - int animationActualTotalDuration(QAbstractAnimationJob *anim) const; - AnimationIndex indexForCurrentTime() const; - - void setCurrentAnimation(QAbstractAnimationJob *anim, bool intermediate = false); - void activateCurrentAnimation(bool intermediate = false); - - void animationInserted(QAbstractAnimationJob *anim); - void animationRemoved(QAbstractAnimationJob *anim,QAbstractAnimationJob*,QAbstractAnimationJob*); - - bool atEnd() const; - - void restart(); - - // handle time changes - void rewindForwards(const AnimationIndex &newAnimationIndex); - void advanceForwards(const AnimationIndex &newAnimationIndex); - - //state - QAbstractAnimationJob *m_currentAnimation; - int m_previousLoop; -}; - -QT_END_NAMESPACE - -QT_END_HEADER - -#endif //QSEQUENTIALANIMATIONGROUPJOB_P_H diff --git a/src/declarative/debugger/debugger.pri b/src/declarative/debugger/debugger.pri deleted file mode 100644 index 8e29e9fdf6..0000000000 --- a/src/declarative/debugger/debugger.pri +++ /dev/null @@ -1,32 +0,0 @@ -SOURCES += \ - $$PWD/qpacketprotocol.cpp \ - $$PWD/qdeclarativedebugservice.cpp \ - $$PWD/qdeclarativedebugclient.cpp \ - $$PWD/qdeclarativeenginedebug.cpp \ - $$PWD/qdeclarativeprofilerservice.cpp \ - $$PWD/qdeclarativedebughelper.cpp \ - $$PWD/qdeclarativedebugserver.cpp \ - $$PWD/qdeclarativeinspectorservice.cpp \ - $$PWD/qv8debugservice.cpp \ - $$PWD/qv8profilerservice.cpp \ - $$PWD/qdeclarativeenginedebugservice.cpp \ - $$PWD/qdebugmessageservice.cpp - -HEADERS += \ - $$PWD/qpacketprotocol_p.h \ - $$PWD/qdeclarativedebugservice_p.h \ - $$PWD/qdeclarativedebugservice_p_p.h \ - $$PWD/qdeclarativedebugclient_p.h \ - $$PWD/qdeclarativeenginedebug_p.h \ - $$PWD/qdeclarativeprofilerservice_p.h \ - $$PWD/qdeclarativedebughelper_p.h \ - $$PWD/qdeclarativedebugserver_p.h \ - $$PWD/qdeclarativedebugserverconnection_p.h \ - $$PWD/qdeclarativedebugstatesdelegate_p.h \ - $$PWD/qdeclarativeinspectorservice_p.h \ - $$PWD/qdeclarativeinspectorinterface_p.h \ - $$PWD/qv8debugservice_p.h \ - $$PWD/qv8profilerservice_p.h \ - $$PWD/qdeclarativeenginedebugservice_p.h \ - $$PWD/qdeclarativedebug.h \ - $$PWD/qdebugmessageservice_p.h diff --git a/src/declarative/debugger/qdebugmessageservice.cpp b/src/declarative/debugger/qdebugmessageservice.cpp deleted file mode 100644 index 3f18a0fe4b..0000000000 --- a/src/declarative/debugger/qdebugmessageservice.cpp +++ /dev/null @@ -1,124 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qdebugmessageservice_p.h" -#include "qdeclarativedebugservice_p_p.h" - -QT_BEGIN_NAMESPACE - -Q_GLOBAL_STATIC(QDebugMessageService, declarativeDebugMessageService) - -void DebugMessageHandler(QtMsgType type, const QMessageLogContext &ctxt, - const char *buf) -{ - QDebugMessageService::instance()->sendDebugMessage(type, ctxt, buf); -} - -class QDebugMessageServicePrivate : public QDeclarativeDebugServicePrivate -{ -public: - QDebugMessageServicePrivate() - : oldMsgHandler(0) - , prevState(QDeclarativeDebugService::NotConnected) - { - } - - QMessageHandler oldMsgHandler; - QDeclarativeDebugService::State prevState; -}; - -QDebugMessageService::QDebugMessageService(QObject *parent) : - QDeclarativeDebugService(*(new QDebugMessageServicePrivate()), - QLatin1String("DebugMessages"), 2, parent) -{ - Q_D(QDebugMessageService); - - registerService(); - if (state() == Enabled) { - d->oldMsgHandler = qInstallMessageHandler(DebugMessageHandler); - d->prevState = Enabled; - } -} - -QDebugMessageService *QDebugMessageService::instance() -{ - return declarativeDebugMessageService(); -} - -void QDebugMessageService::sendDebugMessage(QtMsgType type, - const QMessageLogContext &ctxt, - const char *buf) -{ - Q_D(QDebugMessageService); - - //We do not want to alter the message handling mechanism - //We just eavesdrop and forward the messages to a port - //only if a client is connected to it. - QByteArray message; - QDataStream ws(&message, QIODevice::WriteOnly); - ws << QByteArray("MESSAGE") << type << QString::fromLocal8Bit(buf).toUtf8(); - ws << QString::fromLatin1(ctxt.file).toUtf8(); - ws << ctxt.line << QString::fromLatin1(ctxt.function).toUtf8(); - - sendMessage(message); - if (d->oldMsgHandler) - (*d->oldMsgHandler)(type, ctxt, buf); -} - -void QDebugMessageService::stateChanged(State state) -{ - Q_D(QDebugMessageService); - - if (state != Enabled && d->prevState == Enabled) { - QMessageHandler handler = qInstallMessageHandler(d->oldMsgHandler); - // has our handler been overwritten in between? - if (handler != DebugMessageHandler) - qInstallMessageHandler(handler); - - } else if (state == Enabled && d->prevState != Enabled) { - d->oldMsgHandler = qInstallMessageHandler(DebugMessageHandler); - - } - - d->prevState = state; -} - -QT_END_NAMESPACE diff --git a/src/declarative/debugger/qdebugmessageservice_p.h b/src/declarative/debugger/qdebugmessageservice_p.h deleted file mode 100644 index b907341541..0000000000 --- a/src/declarative/debugger/qdebugmessageservice_p.h +++ /dev/null @@ -1,91 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QDEBUGMESSAGESERVICE_P_H -#define QDEBUGMESSAGESERVICE_P_H - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists purely as an -// implementation detail. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - -#include "qdeclarativedebugservice_p.h" - -#include - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -QT_MODULE(Declarative) - -class QDebugMessageServicePrivate; - -class QDebugMessageService : public QDeclarativeDebugService -{ - Q_OBJECT -public: - QDebugMessageService(QObject *parent = 0); - - static QDebugMessageService *instance(); - - void sendDebugMessage(QtMsgType type, const QMessageLogContext &ctxt, - const char *buf); - -protected: - void stateChanged(State); - -private: - Q_DISABLE_COPY(QDebugMessageService) - Q_DECLARE_PRIVATE(QDebugMessageService) -}; - -QT_END_NAMESPACE - -QT_END_HEADER - -#endif // QDEBUGMESSAGESERVICE_P_H diff --git a/src/declarative/debugger/qdeclarativedebug.h b/src/declarative/debugger/qdeclarativedebug.h deleted file mode 100644 index e23e4ff41a..0000000000 --- a/src/declarative/debugger/qdeclarativedebug.h +++ /dev/null @@ -1,66 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QDECLARATIVEDEBUG_H -#define QDECLARATIVEDEBUG_H - -#include - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - - -struct Q_DECLARATIVE_EXPORT QDeclarativeDebuggingEnabler -{ - QDeclarativeDebuggingEnabler(); -}; - -// Execute code in constructor before first QDeclarativeEngine is instantiated -#if defined(QT_DECLARATIVE_DEBUG) -static QDeclarativeDebuggingEnabler qmlEnableDebuggingHelper; -#endif - -QT_END_NAMESPACE - -QT_END_HEADER - -#endif // QDECLARATIVEDEBUG_H diff --git a/src/declarative/debugger/qdeclarativedebugclient.cpp b/src/declarative/debugger/qdeclarativedebugclient.cpp deleted file mode 100644 index df250f3ef6..0000000000 --- a/src/declarative/debugger/qdeclarativedebugclient.cpp +++ /dev/null @@ -1,421 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qdeclarativedebugclient_p.h" - -#include "qpacketprotocol_p.h" - -#include -#include -#include - -#include - -QT_BEGIN_NAMESPACE - -const int protocolVersion = 1; -const QString serverId = QLatin1String("QDeclarativeDebugServer"); -const QString clientId = QLatin1String("QDeclarativeDebugClient"); - -class QDeclarativeDebugClientPrivate : public QObjectPrivate -{ - Q_DECLARE_PUBLIC(QDeclarativeDebugClient) -public: - QDeclarativeDebugClientPrivate(); - - QString name; - QDeclarativeDebugConnection *connection; -}; - -class QDeclarativeDebugConnectionPrivate : public QObject -{ - Q_OBJECT -public: - QDeclarativeDebugConnectionPrivate(QDeclarativeDebugConnection *c); - QDeclarativeDebugConnection *q; - QPacketProtocol *protocol; - QIODevice *device; - - bool gotHello; - QHash serverPlugins; - QHash plugins; - - void advertisePlugins(); - void connectDeviceSignals(); - -public Q_SLOTS: - void connected(); - void readyRead(); - void deviceAboutToClose(); -}; - -QDeclarativeDebugConnectionPrivate::QDeclarativeDebugConnectionPrivate(QDeclarativeDebugConnection *c) - : QObject(c), q(c), protocol(0), device(0), gotHello(false) -{ - protocol = new QPacketProtocol(q, this); - QObject::connect(c, SIGNAL(connected()), this, SLOT(connected())); - QObject::connect(protocol, SIGNAL(readyRead()), this, SLOT(readyRead())); -} - -void QDeclarativeDebugConnectionPrivate::advertisePlugins() -{ - if (!q->isConnected()) - return; - - QPacket pack; - pack << serverId << 1 << plugins.keys(); - protocol->send(pack); - q->flush(); -} - -void QDeclarativeDebugConnectionPrivate::connected() -{ - QPacket pack; - pack << serverId << 0 << protocolVersion << plugins.keys(); - protocol->send(pack); - q->flush(); -} - -void QDeclarativeDebugConnectionPrivate::readyRead() -{ - if (!gotHello) { - QPacket pack = protocol->read(); - QString name; - - pack >> name; - - bool validHello = false; - if (name == clientId) { - int op = -1; - pack >> op; - if (op == 0) { - int version = -1; - pack >> version; - if (version == protocolVersion) { - QStringList pluginNames; - QList pluginVersions; - pack >> pluginNames; - if (!pack.isEmpty()) - pack >> pluginVersions; - - const int pluginNamesSize = pluginNames.size(); - const int pluginVersionsSize = pluginVersions.size(); - for (int i = 0; i < pluginNamesSize; ++i) { - float pluginVersion = 1.0; - if (i < pluginVersionsSize) - pluginVersion = pluginVersions.at(i); - serverPlugins.insert(pluginNames.at(i), pluginVersion); - } - - validHello = true; - } - } - } - - if (!validHello) { - qWarning("QDeclarativeDebugConnection: Invalid hello message"); - QObject::disconnect(protocol, SIGNAL(readyRead()), this, SLOT(readyRead())); - return; - } - gotHello = true; - - QHash::Iterator iter = plugins.begin(); - for (; iter != plugins.end(); ++iter) { - QDeclarativeDebugClient::State newState = QDeclarativeDebugClient::Unavailable; - if (serverPlugins.contains(iter.key())) - newState = QDeclarativeDebugClient::Enabled; - iter.value()->stateChanged(newState); - } - } - - while (protocol->packetsAvailable()) { - QPacket pack = protocol->read(); - QString name; - pack >> name; - - if (name == clientId) { - int op = -1; - pack >> op; - - if (op == 1) { - // Service Discovery - QHash oldServerPlugins = serverPlugins; - serverPlugins.clear(); - - QStringList pluginNames; - QList pluginVersions; - pack >> pluginNames; - if (!pack.isEmpty()) - pack >> pluginVersions; - - const int pluginNamesSize = pluginNames.size(); - const int pluginVersionsSize = pluginVersions.size(); - for (int i = 0; i < pluginNamesSize; ++i) { - float pluginVersion = 1.0; - if (i < pluginVersionsSize) - pluginVersion = pluginVersions.at(i); - serverPlugins.insert(pluginNames.at(i), pluginVersion); - } - - QHash::Iterator iter = plugins.begin(); - for (; iter != plugins.end(); ++iter) { - const QString pluginName = iter.key(); - QDeclarativeDebugClient::State newSate = QDeclarativeDebugClient::Unavailable; - if (serverPlugins.contains(pluginName)) - newSate = QDeclarativeDebugClient::Enabled; - - if (oldServerPlugins.contains(pluginName) - != serverPlugins.contains(pluginName)) { - iter.value()->stateChanged(newSate); - } - } - } else { - qWarning() << "QDeclarativeDebugConnection: Unknown control message id" << op; - } - } else { - QByteArray message; - pack >> message; - - QHash::Iterator iter = - plugins.find(name); - if (iter == plugins.end()) { - qWarning() << "QDeclarativeDebugConnection: Message received for missing plugin" << name; - } else { - (*iter)->messageReceived(message); - } - } - } -} - -void QDeclarativeDebugConnectionPrivate::deviceAboutToClose() -{ - // This is nasty syntax but we want to emit our own aboutToClose signal (by calling QIODevice::close()) - // without calling the underlying device close fn as that would cause an infinite loop - q->QIODevice::close(); -} - -QDeclarativeDebugConnection::QDeclarativeDebugConnection(QObject *parent) - : QIODevice(parent), d(new QDeclarativeDebugConnectionPrivate(this)) -{ -} - -QDeclarativeDebugConnection::~QDeclarativeDebugConnection() -{ - QHash::iterator iter = d->plugins.begin(); - for (; iter != d->plugins.end(); ++iter) { - iter.value()->d_func()->connection = 0; - iter.value()->stateChanged(QDeclarativeDebugClient::NotConnected); - } -} - -bool QDeclarativeDebugConnection::isConnected() const -{ - return state() == QAbstractSocket::ConnectedState; -} - -qint64 QDeclarativeDebugConnection::readData(char *data, qint64 maxSize) -{ - return d->device->read(data, maxSize); -} - -qint64 QDeclarativeDebugConnection::writeData(const char *data, qint64 maxSize) -{ - return d->device->write(data, maxSize); -} - -qint64 QDeclarativeDebugConnection::bytesAvailable() const -{ - return d->device->bytesAvailable(); -} - -bool QDeclarativeDebugConnection::isSequential() const -{ - return true; -} - -void QDeclarativeDebugConnection::close() -{ - if (isOpen()) { - QIODevice::close(); - d->device->close(); - emit stateChanged(QAbstractSocket::UnconnectedState); - - QHash::iterator iter = d->plugins.begin(); - for (; iter != d->plugins.end(); ++iter) { - iter.value()->stateChanged(QDeclarativeDebugClient::NotConnected); - } - } -} - -bool QDeclarativeDebugConnection::waitForConnected(int msecs) -{ - QAbstractSocket *socket = qobject_cast(d->device); - if (socket) - return socket->waitForConnected(msecs); - return false; -} - -QAbstractSocket::SocketState QDeclarativeDebugConnection::state() const -{ - QAbstractSocket *socket = qobject_cast(d->device); - if (socket) - return socket->state(); - - return QAbstractSocket::UnconnectedState; -} - -void QDeclarativeDebugConnection::flush() -{ - QAbstractSocket *socket = qobject_cast(d->device); - if (socket) { - socket->flush(); - return; - } -} - -void QDeclarativeDebugConnection::connectToHost(const QString &hostName, quint16 port) -{ - QTcpSocket *socket = new QTcpSocket(d); - socket->setProxy(QNetworkProxy::NoProxy); - d->device = socket; - d->connectDeviceSignals(); - d->gotHello = false; - connect(socket, SIGNAL(stateChanged(QAbstractSocket::SocketState)), this, SIGNAL(stateChanged(QAbstractSocket::SocketState))); - connect(socket, SIGNAL(error(QAbstractSocket::SocketError)), this, SIGNAL(error(QAbstractSocket::SocketError))); - connect(socket, SIGNAL(connected()), this, SIGNAL(connected())); - socket->connectToHost(hostName, port); - QIODevice::open(ReadWrite | Unbuffered); -} - -void QDeclarativeDebugConnectionPrivate::connectDeviceSignals() -{ - connect(device, SIGNAL(bytesWritten(qint64)), q, SIGNAL(bytesWritten(qint64))); - connect(device, SIGNAL(readyRead()), q, SIGNAL(readyRead())); - connect(device, SIGNAL(aboutToClose()), this, SLOT(deviceAboutToClose())); -} - -// - -QDeclarativeDebugClientPrivate::QDeclarativeDebugClientPrivate() - : connection(0) -{ -} - -QDeclarativeDebugClient::QDeclarativeDebugClient(const QString &name, - QDeclarativeDebugConnection *parent) - : QObject(*(new QDeclarativeDebugClientPrivate), parent) -{ - Q_D(QDeclarativeDebugClient); - d->name = name; - d->connection = parent; - - if (!d->connection) - return; - - if (d->connection->d->plugins.contains(name)) { - qWarning() << "QDeclarativeDebugClient: Conflicting plugin name" << name; - d->connection = 0; - } else { - d->connection->d->plugins.insert(name, this); - d->connection->d->advertisePlugins(); - } -} - -QDeclarativeDebugClient::~QDeclarativeDebugClient() -{ - Q_D(QDeclarativeDebugClient); - if (d->connection && d->connection->d) { - d->connection->d->plugins.remove(d->name); - d->connection->d->advertisePlugins(); - } -} - -QString QDeclarativeDebugClient::name() const -{ - Q_D(const QDeclarativeDebugClient); - return d->name; -} - -float QDeclarativeDebugClient::serviceVersion() const -{ - Q_D(const QDeclarativeDebugClient); - if (d->connection->d->serverPlugins.contains(d->name)) - return d->connection->d->serverPlugins.value(d->name); - return -1; -} - -QDeclarativeDebugClient::State QDeclarativeDebugClient::state() const -{ - Q_D(const QDeclarativeDebugClient); - if (!d->connection - || !d->connection->isConnected() - || !d->connection->d->gotHello) - return NotConnected; - - if (d->connection->d->serverPlugins.contains(d->name)) - return Enabled; - - return Unavailable; -} - -void QDeclarativeDebugClient::sendMessage(const QByteArray &message) -{ - Q_D(QDeclarativeDebugClient); - if (state() != Enabled) - return; - - QPacket pack; - pack << d->name << message; - d->connection->d->protocol->send(pack); - d->connection->flush(); -} - -void QDeclarativeDebugClient::stateChanged(State) -{ -} - -void QDeclarativeDebugClient::messageReceived(const QByteArray &) -{ -} - -QT_END_NAMESPACE - -#include diff --git a/src/declarative/debugger/qdeclarativedebugclient_p.h b/src/declarative/debugger/qdeclarativedebugclient_p.h deleted file mode 100644 index 93c5be9e44..0000000000 --- a/src/declarative/debugger/qdeclarativedebugclient_p.h +++ /dev/null @@ -1,131 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QDECLARATIVEDEBUGCLIENT_H -#define QDECLARATIVEDEBUGCLIENT_H - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists purely as an -// implementation detail. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - -#include - -#include - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - - -class QDeclarativeDebugConnectionPrivate; -class Q_DECLARATIVE_PRIVATE_EXPORT QDeclarativeDebugConnection : public QIODevice -{ - Q_OBJECT - Q_DISABLE_COPY(QDeclarativeDebugConnection) -public: - QDeclarativeDebugConnection(QObject * = 0); - ~QDeclarativeDebugConnection(); - - void connectToHost(const QString &hostName, quint16 port); - - qint64 bytesAvailable() const; - bool isConnected() const; - QAbstractSocket::SocketState state() const; - void flush(); - bool isSequential() const; - void close(); - bool waitForConnected(int msecs = 30000); - -signals: - void connected(); - void stateChanged(QAbstractSocket::SocketState socketState); - void error(QAbstractSocket::SocketError socketError); - -protected: - qint64 readData(char *data, qint64 maxSize); - qint64 writeData(const char *data, qint64 maxSize); - -private: - QDeclarativeDebugConnectionPrivate *d; - friend class QDeclarativeDebugClient; - friend class QDeclarativeDebugClientPrivate; -}; - -class QDeclarativeDebugClientPrivate; -class Q_DECLARATIVE_PRIVATE_EXPORT QDeclarativeDebugClient : public QObject -{ - Q_OBJECT - Q_DECLARE_PRIVATE(QDeclarativeDebugClient) - Q_DISABLE_COPY(QDeclarativeDebugClient) - -public: - enum State { NotConnected, Unavailable, Enabled }; - - QDeclarativeDebugClient(const QString &, QDeclarativeDebugConnection *parent); - ~QDeclarativeDebugClient(); - - QString name() const; - float serviceVersion() const; - State state() const; - - virtual void sendMessage(const QByteArray &); - -protected: - virtual void stateChanged(State); - virtual void messageReceived(const QByteArray &); - -private: - friend class QDeclarativeDebugConnection; - friend class QDeclarativeDebugConnectionPrivate; -}; - -QT_END_NAMESPACE - -QT_END_HEADER - -#endif // QDECLARATIVEDEBUGCLIENT_H diff --git a/src/declarative/debugger/qdeclarativedebughelper.cpp b/src/declarative/debugger/qdeclarativedebughelper.cpp deleted file mode 100644 index 45d488fe1b..0000000000 --- a/src/declarative/debugger/qdeclarativedebughelper.cpp +++ /dev/null @@ -1,70 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qdeclarativedebughelper_p.h" - -#include -#include - -#include -#include -#include - -QT_BEGIN_NAMESPACE - -void QDeclarativeDebugHelper::setAnimationSlowDownFactor(qreal factor) -{ - QUnifiedTimer *timer = QUnifiedTimer::instance(); - timer->setSlowModeEnabled(factor != 1.0); - timer->setSlowdownFactor(factor); -} - -void QDeclarativeDebugHelper::enableDebugging() { - qWarning("QDeclarativeDebugHelper::enableDebugging() is deprecated! Add CONFIG += declarative_debug to your .pro file instead."); -#ifndef QDECLARATIVE_NO_DEBUG_PROTOCOL - if (!QDeclarativeEnginePrivate::qml_debugging_enabled) { - qWarning("Qml debugging is enabled. Only use this in a safe environment!"); - } - QDeclarativeEnginePrivate::qml_debugging_enabled = true; -#endif -} - -QT_END_NAMESPACE diff --git a/src/declarative/debugger/qdeclarativedebughelper_p.h b/src/declarative/debugger/qdeclarativedebughelper_p.h deleted file mode 100644 index d24bc8c19f..0000000000 --- a/src/declarative/debugger/qdeclarativedebughelper_p.h +++ /dev/null @@ -1,86 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QDECLARATIVEDEBUGHELPER_P_H -#define QDECLARATIVEDEBUGHELPER_P_H - -#include - -#include - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists purely as an -// implementation detail. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -class QDeclarativeEngine; - -#ifndef QT_BUILD_DECLARATIVE_LIB -#warning Use of this header file is deprecated! Add CONFIG += declarative_debug to your .pro file instead. -#endif - -// Helper methods to access private API through a stable interface -// This is used in the qmljsdebugger library of QtCreator. -class Q_DECLARATIVE_EXPORT QDeclarativeDebugHelper -{ -public: - static void setAnimationSlowDownFactor(qreal factor); - - // Enables remote debugging functionality - // Only use this for debugging in a safe environment! - static void enableDebugging(); -}; - -QT_END_NAMESPACE - -QT_END_HEADER - -#endif // QDECLARATIVEDEBUGHELPER_P_H diff --git a/src/declarative/debugger/qdeclarativedebugserver.cpp b/src/declarative/debugger/qdeclarativedebugserver.cpp deleted file mode 100644 index 482847c7a7..0000000000 --- a/src/declarative/debugger/qdeclarativedebugserver.cpp +++ /dev/null @@ -1,539 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qdeclarativedebugserver_p.h" -#include "qdeclarativedebugservice_p.h" -#include "qdeclarativedebugservice_p_p.h" -#include - -#include -#include -#include -#include - -#include -#include - -QT_BEGIN_NAMESPACE - -/* - QDeclarativeDebug Protocol (Version 1): - - handshake: - 1. Client sends - "QDeclarativeDebugServer" 0 version pluginNames - version: an int representing the highest protocol version the client knows - pluginNames: plugins available on client side - 2. Server sends - "QDeclarativeDebugClient" 0 version pluginNames pluginVersions - version: an int representing the highest protocol version the client & server know - pluginNames: plugins available on server side. plugins both in the client and server message are enabled. - client plugin advertisement - 1. Client sends - "QDeclarativeDebugServer" 1 pluginNames - server plugin advertisement - 1. Server sends - "QDeclarativeDebugClient" 1 pluginNames pluginVersions - plugin communication: - Everything send with a header different to "QDeclarativeDebugServer" is sent to the appropriate plugin. - */ - -const int protocolVersion = 1; - -// print detailed information about loading of plugins -DEFINE_BOOL_CONFIG_OPTION(qmlDebugVerbose, QML_DEBUGGER_VERBOSE) - -class QDeclarativeDebugServerThread; - -class QDeclarativeDebugServerPrivate : public QObjectPrivate -{ - Q_DECLARE_PUBLIC(QDeclarativeDebugServer) -public: - QDeclarativeDebugServerPrivate(); - - void advertisePlugins(); - QDeclarativeDebugServerConnection *loadConnectionPlugin(const QString &pluginName); - - QDeclarativeDebugServerConnection *connection; - QHash plugins; - mutable QReadWriteLock pluginsLock; - QStringList clientPlugins; - bool gotHello; - - QMutex messageArrivedMutex; - QWaitCondition messageArrivedCondition; - QStringList waitingForMessageNames; - QDeclarativeDebugServerThread *thread; - QPluginLoader loader; - -private: - // private slot - void _q_sendMessages(const QList &messages); -}; - -class QDeclarativeDebugServerThread : public QThread -{ -public: - void setPluginName(const QString &pluginName) { - m_pluginName = pluginName; - } - - void setPort(int port, bool block) { - m_port = port; - m_block = block; - } - - void run(); - -private: - QString m_pluginName; - int m_port; - bool m_block; -}; - -QDeclarativeDebugServerPrivate::QDeclarativeDebugServerPrivate() : - connection(0), - gotHello(false), - thread(0) -{ - // used in _q_sendMessages - qRegisterMetaType >("QList"); -} - -void QDeclarativeDebugServerPrivate::advertisePlugins() -{ - Q_Q(QDeclarativeDebugServer); - - if (!gotHello) - return; - - QByteArray message; - { - QDataStream out(&message, QIODevice::WriteOnly); - QStringList pluginNames; - QList pluginVersions; - foreach (QDeclarativeDebugService *service, plugins.values()) { - pluginNames << service->name(); - pluginVersions << service->version(); - } - out << QString(QLatin1String("QDeclarativeDebugClient")) << 1 << pluginNames << pluginVersions; - } - - QMetaObject::invokeMethod(q, "_q_sendMessages", Qt::QueuedConnection, Q_ARG(QList, QList() << message)); -} - -QDeclarativeDebugServerConnection *QDeclarativeDebugServerPrivate::loadConnectionPlugin( - const QString &pluginName) -{ -#ifndef QT_NO_LIBRARY - QStringList pluginCandidates; - const QStringList paths = QCoreApplication::libraryPaths(); - foreach (const QString &libPath, paths) { - const QDir dir(libPath + QLatin1String("/qmltooling")); - if (dir.exists()) { - QStringList plugins(dir.entryList(QDir::Files)); - foreach (const QString &pluginPath, plugins) { - if (QFileInfo(pluginPath).fileName().contains(pluginName)) - pluginCandidates << dir.absoluteFilePath(pluginPath); - } - } - } - - foreach (const QString &pluginPath, pluginCandidates) { - if (qmlDebugVerbose()) - qDebug() << "QDeclarativeDebugServer: Trying to load plugin " << pluginPath << "..."; - - loader.setFileName(pluginPath); - if (!loader.load()) { - if (qmlDebugVerbose()) - qDebug() << "QDeclarativeDebugServer: Error while loading: " << loader.errorString(); - continue; - } - if (QObject *instance = loader.instance()) - connection = qobject_cast(instance); - - if (connection) { - if (qmlDebugVerbose()) - qDebug() << "QDeclarativeDebugServer: Plugin successfully loaded."; - - return connection; - } - - if (qmlDebugVerbose()) - qDebug() << "QDeclarativeDebugServer: Plugin does not implement interface QDeclarativeDebugServerConnection."; - - loader.unload(); - } -#endif - return 0; -} - -void QDeclarativeDebugServerThread::run() -{ - QDeclarativeDebugServer *server = QDeclarativeDebugServer::instance(); - QDeclarativeDebugServerConnection *connection - = server->d_func()->loadConnectionPlugin(m_pluginName); - if (connection) { - connection->setServer(QDeclarativeDebugServer::instance()); - connection->setPort(m_port, m_block); - } else { - QCoreApplicationPrivate *appD = static_cast(QObjectPrivate::get(qApp)); - qWarning() << QString::fromAscii("QDeclarativeDebugServer: Ignoring \"-qmljsdebugger=%1\". " - "Remote debugger plugin has not been found.").arg(appD->qmljsDebugArgumentsString()); - } - - exec(); - - // make sure events still waiting are processed - QEventLoop eventLoop; - eventLoop.processEvents(QEventLoop::AllEvents); -} - -bool QDeclarativeDebugServer::hasDebuggingClient() const -{ - Q_D(const QDeclarativeDebugServer); - return d->connection - && d->connection->isConnected() - && d->gotHello; -} - -static QDeclarativeDebugServer *qDeclarativeDebugServer = 0; - - -static void cleanup() -{ - delete qDeclarativeDebugServer; - qDeclarativeDebugServer = 0; -} - -QDeclarativeDebugServer *QDeclarativeDebugServer::instance() -{ - static bool commandLineTested = false; - - if (!commandLineTested) { - commandLineTested = true; - - QCoreApplicationPrivate *appD = static_cast(QObjectPrivate::get(qApp)); -#ifndef QDECLARATIVE_NO_DEBUG_PROTOCOL - // ### remove port definition when protocol is changed - int port = 0; - bool block = false; - bool ok = false; - - // format: qmljsdebugger=port:3768[,block] OR qmljsdebugger=ost[,block] - if (!appD->qmljsDebugArgumentsString().isEmpty()) { - if (!QDeclarativeEnginePrivate::qml_debugging_enabled) { - qWarning() << QString::fromLatin1( - "QDeclarativeDebugServer: Ignoring \"-qmljsdebugger=%1\". " - "Debugging has not been enabled.").arg( - appD->qmljsDebugArgumentsString()); - return 0; - } - - QString pluginName; - if (appD->qmljsDebugArgumentsString().indexOf(QLatin1String("port:")) == 0) { - int separatorIndex = appD->qmljsDebugArgumentsString().indexOf(QLatin1Char(',')); - port = appD->qmljsDebugArgumentsString().mid(5, separatorIndex - 5).toInt(&ok); - pluginName = QLatin1String("qmldbg_tcp"); - } else if (appD->qmljsDebugArgumentsString().contains(QLatin1String("ost"))) { - pluginName = QLatin1String("qmldbg_ost"); - ok = true; - } - - block = appD->qmljsDebugArgumentsString().contains(QLatin1String("block")); - - if (ok) { - qDeclarativeDebugServer = new QDeclarativeDebugServer(); - QDeclarativeDebugServerThread *thread = new QDeclarativeDebugServerThread; - qDeclarativeDebugServer->d_func()->thread = thread; - qDeclarativeDebugServer->moveToThread(thread); - thread->setPluginName(pluginName); - thread->setPort(port, block); - thread->start(); - - if (block) { - QDeclarativeDebugServerPrivate *d = qDeclarativeDebugServer->d_func(); - d->messageArrivedMutex.lock(); - d->messageArrivedCondition.wait(&d->messageArrivedMutex); - d->messageArrivedMutex.unlock(); - } - - } else { - qWarning() << QString::fromLatin1( - "QDeclarativeDebugServer: Ignoring \"-qmljsdebugger=%1\". " - "Format is -qmljsdebugger=port:[,block]").arg( - appD->qmljsDebugArgumentsString()); - } - } -#else - if (!appD->qmljsDebugArgumentsString().isEmpty()) { - qWarning() << QString::fromLatin1( - "QDeclarativeDebugServer: Ignoring \"-qmljsdebugger=%1\". " - "QtDeclarative is not configured for debugging.").arg( - appD->qmljsDebugArgumentsString()); - } -#endif - } - - return qDeclarativeDebugServer; -} - -QDeclarativeDebugServer::QDeclarativeDebugServer() - : QObject(*(new QDeclarativeDebugServerPrivate)) -{ - qAddPostRoutine(cleanup); -} - -QDeclarativeDebugServer::~QDeclarativeDebugServer() -{ - Q_D(QDeclarativeDebugServer); - - QReadLocker(&d->pluginsLock); - { - foreach (QDeclarativeDebugService *service, d->plugins.values()) { - service->stateAboutToBeChanged(QDeclarativeDebugService::NotConnected); - service->d_func()->server = 0; - service->d_func()->state = QDeclarativeDebugService::NotConnected; - service->stateChanged(QDeclarativeDebugService::NotConnected); - } - } - - if (d->thread) { - d->thread->exit(); - d->thread->wait(); - delete d->thread; - } - delete d->connection; -} - -void QDeclarativeDebugServer::receiveMessage(const QByteArray &message) -{ - Q_D(QDeclarativeDebugServer); - - QDataStream in(message); - - QString name; - - in >> name; - if (name == QLatin1String("QDeclarativeDebugServer")) { - int op = -1; - in >> op; - if (op == 0) { - int version; - in >> version >> d->clientPlugins; - - // Send the hello answer immediately, since it needs to arrive before - // the plugins below start sending messages. - QByteArray helloAnswer; - { - QDataStream out(&helloAnswer, QIODevice::WriteOnly); - QStringList pluginNames; - QList pluginVersions; - foreach (QDeclarativeDebugService *service, d->plugins.values()) { - pluginNames << service->name(); - pluginVersions << service->version(); - } - - out << QString(QLatin1String("QDeclarativeDebugClient")) << 0 << protocolVersion << pluginNames << pluginVersions; - } - d->connection->send(QList() << helloAnswer); - - d->gotHello = true; - - QReadLocker(&d->pluginsLock); - QHash::ConstIterator iter = d->plugins.constBegin(); - for (; iter != d->plugins.constEnd(); ++iter) { - QDeclarativeDebugService::State newState = QDeclarativeDebugService::Unavailable; - if (d->clientPlugins.contains(iter.key())) - newState = QDeclarativeDebugService::Enabled; - iter.value()->d_func()->state = newState; - iter.value()->stateChanged(newState); - } - - qWarning("QDeclarativeDebugServer: Connection established"); - d->messageArrivedCondition.wakeAll(); - - } else if (op == 1) { - - // Service Discovery - QStringList oldClientPlugins = d->clientPlugins; - in >> d->clientPlugins; - - QReadLocker(&d->pluginsLock); - QHash::ConstIterator iter = d->plugins.constBegin(); - for (; iter != d->plugins.constEnd(); ++iter) { - const QString pluginName = iter.key(); - QDeclarativeDebugService::State newState = QDeclarativeDebugService::Unavailable; - if (d->clientPlugins.contains(pluginName)) - newState = QDeclarativeDebugService::Enabled; - - if (oldClientPlugins.contains(pluginName) - != d->clientPlugins.contains(pluginName)) { - iter.value()->d_func()->state = newState; - iter.value()->stateChanged(newState); - } - } - - } else { - qWarning("QDeclarativeDebugServer: Invalid control message %d", op); - d->connection->disconnect(); - return; - } - - } else { - if (d->gotHello) { - QByteArray message; - in >> message; - - QReadLocker(&d->pluginsLock); - QHash::Iterator iter = d->plugins.find(name); - if (iter == d->plugins.end()) { - qWarning() << "QDeclarativeDebugServer: Message received for missing plugin" << name; - } else { - (*iter)->messageReceived(message); - - if (d->waitingForMessageNames.removeOne(name)) - d->messageArrivedCondition.wakeAll(); - } - } else { - qWarning("QDeclarativeDebugServer: Invalid hello message"); - } - - } -} - -void QDeclarativeDebugServerPrivate::_q_sendMessages(const QList &messages) -{ - if (connection) - connection->send(messages); -} - -QList QDeclarativeDebugServer::services() const -{ - const Q_D(QDeclarativeDebugServer); - QReadLocker(&d->pluginsLock); - return d->plugins.values(); -} - -QStringList QDeclarativeDebugServer::serviceNames() const -{ - const Q_D(QDeclarativeDebugServer); - QReadLocker(&d->pluginsLock); - return d->plugins.keys(); -} - -bool QDeclarativeDebugServer::addService(QDeclarativeDebugService *service) -{ - Q_D(QDeclarativeDebugServer); - { - QWriteLocker(&d->pluginsLock); - if (!service || d->plugins.contains(service->name())) - return false; - d->plugins.insert(service->name(), service); - } - { - QReadLocker(&d->pluginsLock); - d->advertisePlugins(); - QDeclarativeDebugService::State newState = QDeclarativeDebugService::Unavailable; - if (d->clientPlugins.contains(service->name())) - newState = QDeclarativeDebugService::Enabled; - service->d_func()->state = newState; - } - return true; -} - -bool QDeclarativeDebugServer::removeService(QDeclarativeDebugService *service) -{ - Q_D(QDeclarativeDebugServer); - { - QWriteLocker(&d->pluginsLock); - if (!service || !d->plugins.contains(service->name())) - return false; - d->plugins.remove(service->name()); - } - { - QReadLocker(&d->pluginsLock); - QDeclarativeDebugService::State newState = QDeclarativeDebugService::NotConnected; - service->stateAboutToBeChanged(newState); - d->advertisePlugins(); - service->d_func()->server = 0; - service->d_func()->state = newState; - service->stateChanged(newState); - } - - return true; -} - -void QDeclarativeDebugServer::sendMessages(QDeclarativeDebugService *service, - const QList &messages) -{ - QList prefixedMessages; - foreach (const QByteArray &message, messages) { - QByteArray prefixed; - QDataStream out(&prefixed, QIODevice::WriteOnly); - out << service->name() << message; - prefixedMessages << prefixed; - } - - QMetaObject::invokeMethod(this, "_q_sendMessages", Qt::QueuedConnection, Q_ARG(QList, prefixedMessages)); -} - -bool QDeclarativeDebugServer::waitForMessage(QDeclarativeDebugService *service) -{ - Q_D(QDeclarativeDebugServer); - QReadLocker(&d->pluginsLock); - - if (!service - || !d->plugins.contains(service->name())) - return false; - - d->messageArrivedMutex.lock(); - d->waitingForMessageNames << service->name(); - do { - d->messageArrivedCondition.wait(&d->messageArrivedMutex); - } while (d->waitingForMessageNames.contains(service->name())); - d->messageArrivedMutex.unlock(); - return true; -} - -QT_END_NAMESPACE - -#include "moc_qdeclarativedebugserver_p.cpp" diff --git a/src/declarative/debugger/qdeclarativedebugserver_p.h b/src/declarative/debugger/qdeclarativedebugserver_p.h deleted file mode 100644 index 8f7f748761..0000000000 --- a/src/declarative/debugger/qdeclarativedebugserver_p.h +++ /dev/null @@ -1,105 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QDECLARATIVEDEBUGSERVER_H -#define QDECLARATIVEDEBUGSERVER_H - -#include -#include - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists purely as an -// implementation detail. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - - -class QDeclarativeDebugService; - -class QDeclarativeDebugServerPrivate; -class Q_DECLARATIVE_EXPORT QDeclarativeDebugServer : public QObject -{ - Q_OBJECT - Q_DECLARE_PRIVATE(QDeclarativeDebugServer) - Q_DISABLE_COPY(QDeclarativeDebugServer) -public: - ~QDeclarativeDebugServer(); - - static QDeclarativeDebugServer *instance(); - - void setConnection(QDeclarativeDebugServerConnection *connection); - - bool hasDebuggingClient() const; - - QList services() const; - QStringList serviceNames() const; - - - bool addService(QDeclarativeDebugService *service); - bool removeService(QDeclarativeDebugService *service); - - void receiveMessage(const QByteArray &message); - - bool waitForMessage(QDeclarativeDebugService *service); - void sendMessages(QDeclarativeDebugService *service, const QList &messages); - -private: - friend class QDeclarativeDebugService; - friend class QDeclarativeDebugServicePrivate; - friend class QDeclarativeDebugServerThread; - QDeclarativeDebugServer(); - Q_PRIVATE_SLOT(d_func(), void _q_sendMessages(QList)) -}; - -QT_END_NAMESPACE - -QT_END_HEADER - -#endif // QDECLARATIVEDEBUGSERVICE_H diff --git a/src/declarative/debugger/qdeclarativedebugserverconnection_p.h b/src/declarative/debugger/qdeclarativedebugserverconnection_p.h deleted file mode 100644 index aa1c8aa0f1..0000000000 --- a/src/declarative/debugger/qdeclarativedebugserverconnection_p.h +++ /dev/null @@ -1,84 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QDECLARATIVEDEBUGSERVERCONNECTION_H -#define QDECLARATIVEDEBUGSERVERCONNECTION_H - -#include - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists purely as an -// implementation detail. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - - -class QDeclarativeDebugServer; -class Q_DECLARATIVE_EXPORT QDeclarativeDebugServerConnection -{ -public: - QDeclarativeDebugServerConnection() {} - virtual ~QDeclarativeDebugServerConnection() {} - - virtual void setServer(QDeclarativeDebugServer *server) = 0; - virtual void setPort(int port, bool bock) = 0; - virtual bool isConnected() const = 0; - virtual void send(const QList &messages) = 0; - virtual void disconnect() = 0; - virtual bool waitForMessage() = 0; -}; - -Q_DECLARE_INTERFACE(QDeclarativeDebugServerConnection, "com.trolltech.Qt.QDeclarativeDebugServerConnection/1.0") - -QT_END_NAMESPACE - -QT_END_HEADER - -#endif // QDECLARATIVEDEBUGSERVERCONNECTION_H diff --git a/src/declarative/debugger/qdeclarativedebugservice.cpp b/src/declarative/debugger/qdeclarativedebugservice.cpp deleted file mode 100644 index 96344d7717..0000000000 --- a/src/declarative/debugger/qdeclarativedebugservice.cpp +++ /dev/null @@ -1,268 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qdeclarativedebugservice_p.h" -#include "qdeclarativedebugservice_p_p.h" -#include "qdeclarativedebugserver_p.h" - -#include -#include - -QT_BEGIN_NAMESPACE - -QDeclarativeDebugServicePrivate::QDeclarativeDebugServicePrivate() - : server(0) -{ -} - -QDeclarativeDebugService::QDeclarativeDebugService(const QString &name, float version, QObject *parent) - : QObject(*(new QDeclarativeDebugServicePrivate), parent) -{ - Q_D(QDeclarativeDebugService); - d->name = name; - d->version = version; - d->server = QDeclarativeDebugServer::instance(); - d->state = QDeclarativeDebugService::NotConnected; - - -} - -QDeclarativeDebugService::QDeclarativeDebugService(QDeclarativeDebugServicePrivate &dd, - const QString &name, float version, QObject *parent) - : QObject(dd, parent) -{ - Q_D(QDeclarativeDebugService); - d->name = name; - d->version = version; - d->server = QDeclarativeDebugServer::instance(); - d->state = QDeclarativeDebugService::NotConnected; -} - -/** - Registers the service. This should be called in the constructor of the inherited class. From - then on the service might get asynchronous calls to messageReceived(). - */ -QDeclarativeDebugService::State QDeclarativeDebugService::registerService() -{ - Q_D(QDeclarativeDebugService); - if (!d->server) - return NotConnected; - - if (d->server->serviceNames().contains(d->name)) { - qWarning() << "QDeclarativeDebugService: Conflicting plugin name" << d->name; - d->server = 0; - } else { - d->server->addService(this); - } - return state(); -} - -QDeclarativeDebugService::~QDeclarativeDebugService() -{ - Q_D(const QDeclarativeDebugService); - if (d->server) { - d->server->removeService(this); - } -} - -QString QDeclarativeDebugService::name() const -{ - Q_D(const QDeclarativeDebugService); - return d->name; -} - -float QDeclarativeDebugService::version() const -{ - Q_D(const QDeclarativeDebugService); - return d->version; -} - -QDeclarativeDebugService::State QDeclarativeDebugService::state() const -{ - Q_D(const QDeclarativeDebugService); - return d->state; -} - -namespace { - -struct ObjectReference -{ - QPointer object; - int id; -}; - -struct ObjectReferenceHash -{ - ObjectReferenceHash() : nextId(0) {} - - QHash objects; - QHash ids; - - int nextId; -}; - -} -Q_GLOBAL_STATIC(ObjectReferenceHash, objectReferenceHash); - - -/*! - Returns a unique id for \a object. Calling this method multiple times - for the same object will return the same id. -*/ -int QDeclarativeDebugService::idForObject(QObject *object) -{ - if (!object) - return -1; - - ObjectReferenceHash *hash = objectReferenceHash(); - QHash::Iterator iter = - hash->objects.find(object); - - if (iter == hash->objects.end()) { - int id = hash->nextId++; - - hash->ids.insert(id, object); - iter = hash->objects.insert(object, ObjectReference()); - iter->object = object; - iter->id = id; - } else if (iter->object != object) { - int id = hash->nextId++; - - hash->ids.remove(iter->id); - - hash->ids.insert(id, object); - iter->object = object; - iter->id = id; - } - return iter->id; -} - -/*! - Returns the object for unique \a id. If the object has not previously been - assigned an id, through idForObject(), then 0 is returned. If the object - has been destroyed, 0 is returned. -*/ -QObject *QDeclarativeDebugService::objectForId(int id) -{ - ObjectReferenceHash *hash = objectReferenceHash(); - - QHash::Iterator iter = hash->ids.find(id); - if (iter == hash->ids.end()) - return 0; - - - QHash::Iterator objIter = - hash->objects.find(*iter); - Q_ASSERT(objIter != hash->objects.end()); - - if (objIter->object == 0) { - hash->ids.erase(iter); - hash->objects.erase(objIter); - return 0; - } else { - return *iter; - } -} - -bool QDeclarativeDebugService::isDebuggingEnabled() -{ - return QDeclarativeDebugServer::instance() != 0; -} - -bool QDeclarativeDebugService::hasDebuggingClient() -{ - return QDeclarativeDebugServer::instance() != 0 - && QDeclarativeDebugServer::instance()->hasDebuggingClient(); -} - -QString QDeclarativeDebugService::objectToString(QObject *obj) -{ - if(!obj) - return QLatin1String("NULL"); - - QString objectName = obj->objectName(); - if(objectName.isEmpty()) - objectName = QLatin1String(""); - - QString rv = QString::fromUtf8(obj->metaObject()->className()) + - QLatin1String(": ") + objectName; - - return rv; -} - -void QDeclarativeDebugService::sendMessage(const QByteArray &message) -{ - sendMessages(QList() << message); -} - -void QDeclarativeDebugService::sendMessages(const QList &messages) -{ - Q_D(QDeclarativeDebugService); - - if (state() != Enabled) - return; - - d->server->sendMessages(this, messages); -} - -bool QDeclarativeDebugService::waitForMessage() -{ - Q_D(QDeclarativeDebugService); - - if (state() != Enabled) - return false; - - return d->server->waitForMessage(this); -} - -void QDeclarativeDebugService::stateAboutToBeChanged(State) -{ -} - -void QDeclarativeDebugService::stateChanged(State) -{ -} - -void QDeclarativeDebugService::messageReceived(const QByteArray &) -{ -} - -QT_END_NAMESPACE diff --git a/src/declarative/debugger/qdeclarativedebugservice_p.h b/src/declarative/debugger/qdeclarativedebugservice_p.h deleted file mode 100644 index 203e27ad09..0000000000 --- a/src/declarative/debugger/qdeclarativedebugservice_p.h +++ /dev/null @@ -1,113 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QDECLARATIVEDEBUGSERVICE_H -#define QDECLARATIVEDEBUGSERVICE_H - -#include - -#include - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists purely as an -// implementation detail. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - - -class QDeclarativeDebugServicePrivate; -class Q_DECLARATIVE_PRIVATE_EXPORT QDeclarativeDebugService : public QObject -{ - Q_OBJECT - Q_DECLARE_PRIVATE(QDeclarativeDebugService) - Q_DISABLE_COPY(QDeclarativeDebugService) - -public: - explicit QDeclarativeDebugService(const QString &, float version, QObject *parent = 0); - ~QDeclarativeDebugService(); - - QString name() const; - float version() const; - - enum State { NotConnected, Unavailable, Enabled }; - State state() const; - - void sendMessage(const QByteArray &); - void sendMessages(const QList &); - bool waitForMessage(); - - static int idForObject(QObject *); - static QObject *objectForId(int); - - static QString objectToString(QObject *obj); - - static bool isDebuggingEnabled(); - static bool hasDebuggingClient(); - -protected: - QDeclarativeDebugService(QDeclarativeDebugServicePrivate &dd, const QString &name, float version, QObject *parent = 0); - - State registerService(); - - virtual void stateAboutToBeChanged(State); - virtual void stateChanged(State); - virtual void messageReceived(const QByteArray &); - -private: - friend class QDeclarativeDebugServer; - friend class QDeclarativeDebugServerPrivate; -}; - -QT_END_NAMESPACE - -QT_END_HEADER - -#endif // QDECLARATIVEDEBUGSERVICE_H - diff --git a/src/declarative/debugger/qdeclarativedebugservice_p_p.h b/src/declarative/debugger/qdeclarativedebugservice_p_p.h deleted file mode 100644 index 6638ccbec7..0000000000 --- a/src/declarative/debugger/qdeclarativedebugservice_p_p.h +++ /dev/null @@ -1,82 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QDECLARATIVEDEBUGSERVICE_P_H -#define QDECLARATIVEDEBUGSERVICE_P_H - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists purely as an -// implementation detail. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - -#include -#include - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - - -class QDeclarativeDebugServer; - -class QDeclarativeDebugServicePrivate : public QObjectPrivate -{ - Q_DECLARE_PUBLIC(QDeclarativeDebugService) -public: - QDeclarativeDebugServicePrivate(); - - QString name; - float version; - QDeclarativeDebugServer *server; - QDeclarativeDebugService::State state; -}; - -QT_END_NAMESPACE - -QT_END_HEADER - -#endif // QDECLARATIVEDEBUGSERVICE_P_H diff --git a/src/declarative/debugger/qdeclarativedebugstatesdelegate_p.h b/src/declarative/debugger/qdeclarativedebugstatesdelegate_p.h deleted file mode 100644 index 868357723d..0000000000 --- a/src/declarative/debugger/qdeclarativedebugstatesdelegate_p.h +++ /dev/null @@ -1,98 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QDECLARATIVEDEBUGSTATESDELEGATE_P_H -#define QDECLARATIVEDEBUGSTATESDELEGATE_P_H - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists purely as an -// implementation detail. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - -#include - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - - -class QDeclarativeContext; -class QDeclarativeProperty; -class QObject; -class QString; -class QVariant; - -class QDeclarativeDebugStatesDelegate -{ -protected: - QDeclarativeDebugStatesDelegate() {} - -public: - virtual ~QDeclarativeDebugStatesDelegate() {} - - virtual void buildStatesList(QDeclarativeContext *ctxt, bool cleanList) = 0; - virtual void updateBinding(QDeclarativeContext *context, - const QDeclarativeProperty &property, - const QVariant &expression, bool isLiteralValue, - const QString &fileName, int line, int column, - bool *inBaseState) = 0; - virtual bool setBindingForInvalidProperty(QObject *object, - const QString &propertyName, - const QVariant &expression, - bool isLiteralValue) = 0; - virtual void resetBindingForInvalidProperty(QObject *object, - const QString &propertyName) = 0; - -private: - Q_DISABLE_COPY(QDeclarativeDebugStatesDelegate) -}; - -QT_END_NAMESPACE - -QT_END_HEADER - -#endif // QDECLARATIVEDEBUGSTATESDELEGATE_P_H diff --git a/src/declarative/debugger/qdeclarativeenginedebug.cpp b/src/declarative/debugger/qdeclarativeenginedebug.cpp deleted file mode 100644 index 462f99937e..0000000000 --- a/src/declarative/debugger/qdeclarativeenginedebug.cpp +++ /dev/null @@ -1,1072 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qdeclarativeenginedebug_p.h" - -#include "qdeclarativedebugclient_p.h" - -#include "qdeclarativeenginedebugservice_p.h" - -#include - -QT_BEGIN_NAMESPACE - -class QDeclarativeEngineDebugClient : public QDeclarativeDebugClient -{ -public: - QDeclarativeEngineDebugClient(QDeclarativeDebugConnection *client, QDeclarativeEngineDebugPrivate *p); - -protected: - virtual void stateChanged(State state); - virtual void messageReceived(const QByteArray &); - -private: - QDeclarativeEngineDebugPrivate *priv; - friend class QDeclarativeEngineDebugPrivate; -}; - -class QDeclarativeEngineDebugPrivate : public QObjectPrivate -{ - Q_DECLARE_PUBLIC(QDeclarativeEngineDebug) -public: - QDeclarativeEngineDebugPrivate(QDeclarativeDebugConnection *); - ~QDeclarativeEngineDebugPrivate(); - - void stateChanged(QDeclarativeEngineDebug::State status); - void message(const QByteArray &); - - QDeclarativeEngineDebugClient *client; - int nextId; - int getId(); - - void decode(QDataStream &, QDeclarativeDebugContextReference &); - void decode(QDataStream &, QDeclarativeDebugObjectReference &, bool simple); - - static void remove(QDeclarativeEngineDebug *, QDeclarativeDebugEnginesQuery *); - static void remove(QDeclarativeEngineDebug *, QDeclarativeDebugRootContextQuery *); - static void remove(QDeclarativeEngineDebug *, QDeclarativeDebugObjectQuery *); - static void remove(QDeclarativeEngineDebug *, QDeclarativeDebugExpressionQuery *); - static void remove(QDeclarativeEngineDebug *, QDeclarativeDebugWatch *); - - QHash enginesQuery; - QHash rootContextQuery; - QHash objectQuery; - QHash expressionQuery; - - QHash watched; -}; - -QDeclarativeEngineDebugClient::QDeclarativeEngineDebugClient(QDeclarativeDebugConnection *client, - QDeclarativeEngineDebugPrivate *p) - : QDeclarativeDebugClient(QLatin1String("QDeclarativeEngine"), client), priv(p) -{ -} - -void QDeclarativeEngineDebugClient::stateChanged(State status) -{ - if (priv) - priv->stateChanged(static_cast(status)); -} - -void QDeclarativeEngineDebugClient::messageReceived(const QByteArray &data) -{ - if (priv) - priv->message(data); -} - -QDeclarativeEngineDebugPrivate::QDeclarativeEngineDebugPrivate(QDeclarativeDebugConnection *c) - : client(new QDeclarativeEngineDebugClient(c, this)), nextId(0) -{ -} - -QDeclarativeEngineDebugPrivate::~QDeclarativeEngineDebugPrivate() -{ - if (client) - client->priv = 0; - delete client; - - QHash::iterator enginesIter = enginesQuery.begin(); - for (; enginesIter != enginesQuery.end(); ++enginesIter) { - enginesIter.value()->m_client = 0; - if (enginesIter.value()->state() == QDeclarativeDebugQuery::Waiting) - enginesIter.value()->setState(QDeclarativeDebugQuery::Error); - } - - QHash::iterator rootContextIter = rootContextQuery.begin(); - for (; rootContextIter != rootContextQuery.end(); ++rootContextIter) { - rootContextIter.value()->m_client = 0; - if (rootContextIter.value()->state() == QDeclarativeDebugQuery::Waiting) - rootContextIter.value()->setState(QDeclarativeDebugQuery::Error); - } - - QHash::iterator objectIter = objectQuery.begin(); - for (; objectIter != objectQuery.end(); ++objectIter) { - objectIter.value()->m_client = 0; - if (objectIter.value()->state() == QDeclarativeDebugQuery::Waiting) - objectIter.value()->setState(QDeclarativeDebugQuery::Error); - } - - QHash::iterator exprIter = expressionQuery.begin(); - for (; exprIter != expressionQuery.end(); ++exprIter) { - exprIter.value()->m_client = 0; - if (exprIter.value()->state() == QDeclarativeDebugQuery::Waiting) - exprIter.value()->setState(QDeclarativeDebugQuery::Error); - } - - QHash::iterator watchIter = watched.begin(); - for (; watchIter != watched.end(); ++watchIter) { - watchIter.value()->m_client = 0; - watchIter.value()->setState(QDeclarativeDebugWatch::Dead); - } -} - -int QDeclarativeEngineDebugPrivate::getId() -{ - return nextId++; -} - -void QDeclarativeEngineDebugPrivate::remove(QDeclarativeEngineDebug *c, QDeclarativeDebugEnginesQuery *q) -{ - if (c && q) { - QDeclarativeEngineDebugPrivate *p = (QDeclarativeEngineDebugPrivate *)QObjectPrivate::get(c); - p->enginesQuery.remove(q->m_queryId); - } -} - -void QDeclarativeEngineDebugPrivate::remove(QDeclarativeEngineDebug *c, - QDeclarativeDebugRootContextQuery *q) -{ - if (c && q) { - QDeclarativeEngineDebugPrivate *p = (QDeclarativeEngineDebugPrivate *)QObjectPrivate::get(c); - p->rootContextQuery.remove(q->m_queryId); - } -} - -void QDeclarativeEngineDebugPrivate::remove(QDeclarativeEngineDebug *c, QDeclarativeDebugObjectQuery *q) -{ - if (c && q) { - QDeclarativeEngineDebugPrivate *p = (QDeclarativeEngineDebugPrivate *)QObjectPrivate::get(c); - p->objectQuery.remove(q->m_queryId); - } -} - -void QDeclarativeEngineDebugPrivate::remove(QDeclarativeEngineDebug *c, QDeclarativeDebugExpressionQuery *q) -{ - if (c && q) { - QDeclarativeEngineDebugPrivate *p = (QDeclarativeEngineDebugPrivate *)QObjectPrivate::get(c); - p->expressionQuery.remove(q->m_queryId); - } -} - -void QDeclarativeEngineDebugPrivate::remove(QDeclarativeEngineDebug *c, QDeclarativeDebugWatch *w) -{ - if (c && w) { - QDeclarativeEngineDebugPrivate *p = (QDeclarativeEngineDebugPrivate *)QObjectPrivate::get(c); - p->watched.remove(w->m_queryId); - } -} - -void QDeclarativeEngineDebugPrivate::decode(QDataStream &ds, QDeclarativeDebugObjectReference &o, - bool simple) -{ - QDeclarativeEngineDebugService::QDeclarativeObjectData data; - ds >> data; - o.m_debugId = data.objectId; - o.m_class = data.objectType; - o.m_idString = data.idString; - o.m_name = data.objectName; - o.m_source.m_url = data.url; - o.m_source.m_lineNumber = data.lineNumber; - o.m_source.m_columnNumber = data.columnNumber; - o.m_contextDebugId = data.contextId; - - if (simple) - return; - - int childCount; - bool recur; - ds >> childCount >> recur; - - for (int ii = 0; ii < childCount; ++ii) { - o.m_children.append(QDeclarativeDebugObjectReference()); - decode(ds, o.m_children.last(), !recur); - } - - int propCount; - ds >> propCount; - - for (int ii = 0; ii < propCount; ++ii) { - QDeclarativeEngineDebugService::QDeclarativeObjectProperty data; - ds >> data; - QDeclarativeDebugPropertyReference prop; - prop.m_objectDebugId = o.m_debugId; - prop.m_name = data.name; - prop.m_binding = data.binding; - prop.m_hasNotifySignal = data.hasNotifySignal; - prop.m_valueTypeName = data.valueTypeName; - switch (data.type) { - case QDeclarativeEngineDebugService::QDeclarativeObjectProperty::Basic: - case QDeclarativeEngineDebugService::QDeclarativeObjectProperty::List: - case QDeclarativeEngineDebugService::QDeclarativeObjectProperty::SignalProperty: - { - prop.m_value = data.value; - break; - } - case QDeclarativeEngineDebugService::QDeclarativeObjectProperty::Object: - { - QDeclarativeDebugObjectReference obj; - obj.m_debugId = prop.m_value.toInt(); - prop.m_value = QVariant::fromValue(obj); - break; - } - case QDeclarativeEngineDebugService::QDeclarativeObjectProperty::Unknown: - break; - } - o.m_properties << prop; - } -} - -void QDeclarativeEngineDebugPrivate::decode(QDataStream &ds, QDeclarativeDebugContextReference &c) -{ - ds >> c.m_name >> c.m_debugId; - - int contextCount; - ds >> contextCount; - - for (int ii = 0; ii < contextCount; ++ii) { - c.m_contexts.append(QDeclarativeDebugContextReference()); - decode(ds, c.m_contexts.last()); - } - - int objectCount; - ds >> objectCount; - - for (int ii = 0; ii < objectCount; ++ii) { - QDeclarativeDebugObjectReference obj; - decode(ds, obj, true); - - obj.m_contextDebugId = c.m_debugId; - c.m_objects << obj; - } -} - -void QDeclarativeEngineDebugPrivate::stateChanged(QDeclarativeEngineDebug::State status) -{ - emit q_func()->stateChanged(status); -} - -void QDeclarativeEngineDebugPrivate::message(const QByteArray &data) -{ - QDataStream ds(data); - - QByteArray type; - ds >> type; - - //qDebug() << "QDeclarativeEngineDebugPrivate::message()" << type; - - if (type == "LIST_ENGINES_R") { - int queryId; - ds >> queryId; - - QDeclarativeDebugEnginesQuery *query = enginesQuery.value(queryId); - if (!query) - return; - enginesQuery.remove(queryId); - - int count; - ds >> count; - - for (int ii = 0; ii < count; ++ii) { - QDeclarativeDebugEngineReference ref; - ds >> ref.m_name; - ds >> ref.m_debugId; - query->m_engines << ref; - } - - query->m_client = 0; - query->setState(QDeclarativeDebugQuery::Completed); - } else if (type == "LIST_OBJECTS_R") { - int queryId; - ds >> queryId; - - QDeclarativeDebugRootContextQuery *query = rootContextQuery.value(queryId); - if (!query) - return; - rootContextQuery.remove(queryId); - - if (!ds.atEnd()) - decode(ds, query->m_context); - - query->m_client = 0; - query->setState(QDeclarativeDebugQuery::Completed); - } else if (type == "FETCH_OBJECT_R") { - int queryId; - ds >> queryId; - - QDeclarativeDebugObjectQuery *query = objectQuery.value(queryId); - if (!query) - return; - objectQuery.remove(queryId); - - if (!ds.atEnd()) - decode(ds, query->m_object, false); - - query->m_client = 0; - query->setState(QDeclarativeDebugQuery::Completed); - } else if (type == "EVAL_EXPRESSION_R") { - int queryId; - QVariant result; - ds >> queryId >> result; - - QDeclarativeDebugExpressionQuery *query = expressionQuery.value(queryId); - if (!query) - return; - expressionQuery.remove(queryId); - - query->m_result = result; - query->m_client = 0; - query->setState(QDeclarativeDebugQuery::Completed); - } else if (type == "WATCH_PROPERTY_R") { - int queryId; - bool ok; - ds >> queryId >> ok; - - QDeclarativeDebugWatch *watch = watched.value(queryId); - if (!watch) - return; - - watch->setState(ok ? QDeclarativeDebugWatch::Active : QDeclarativeDebugWatch::Inactive); - } else if (type == "WATCH_OBJECT_R") { - int queryId; - bool ok; - ds >> queryId >> ok; - - QDeclarativeDebugWatch *watch = watched.value(queryId); - if (!watch) - return; - - watch->setState(ok ? QDeclarativeDebugWatch::Active : QDeclarativeDebugWatch::Inactive); - } else if (type == "WATCH_EXPR_OBJECT_R") { - int queryId; - bool ok; - ds >> queryId >> ok; - - QDeclarativeDebugWatch *watch = watched.value(queryId); - if (!watch) - return; - - watch->setState(ok ? QDeclarativeDebugWatch::Active : QDeclarativeDebugWatch::Inactive); - } else if (type == "UPDATE_WATCH") { - int queryId; - int debugId; - QByteArray name; - QVariant value; - ds >> queryId >> debugId >> name >> value; - - QDeclarativeDebugWatch *watch = watched.value(queryId, 0); - if (!watch) - return; - emit watch->valueChanged(name, value); - } else if (type == "OBJECT_CREATED") { - emit q_func()->newObjects(); - } -} - -QDeclarativeEngineDebug::QDeclarativeEngineDebug(QDeclarativeDebugConnection *client, QObject *parent) - : QObject(*(new QDeclarativeEngineDebugPrivate(client)), parent) -{ -} - -QDeclarativeEngineDebug::~QDeclarativeEngineDebug() -{ -} - -QDeclarativeEngineDebug::State QDeclarativeEngineDebug::state() const -{ - Q_D(const QDeclarativeEngineDebug); - - return static_cast(d->client->state()); -} - -QDeclarativeDebugPropertyWatch *QDeclarativeEngineDebug::addWatch(const QDeclarativeDebugPropertyReference &property, QObject *parent) -{ - Q_D(QDeclarativeEngineDebug); - - QDeclarativeDebugPropertyWatch *watch = new QDeclarativeDebugPropertyWatch(parent); - if (d->client->state() == QDeclarativeDebugClient::Enabled) { - int queryId = d->getId(); - watch->m_queryId = queryId; - watch->m_client = this; - watch->m_objectDebugId = property.objectDebugId(); - watch->m_name = property.name(); - d->watched.insert(queryId, watch); - - QByteArray message; - QDataStream ds(&message, QIODevice::WriteOnly); - ds << QByteArray("WATCH_PROPERTY") << queryId << property.objectDebugId() << property.name().toUtf8(); - d->client->sendMessage(message); - } else { - watch->m_state = QDeclarativeDebugWatch::Dead; - } - - return watch; -} - -QDeclarativeDebugWatch *QDeclarativeEngineDebug::addWatch(const QDeclarativeDebugContextReference &, const QString &, QObject *) -{ - qWarning("QDeclarativeEngineDebug::addWatch(): Not implemented"); - return 0; -} - -QDeclarativeDebugObjectExpressionWatch *QDeclarativeEngineDebug::addWatch(const QDeclarativeDebugObjectReference &object, const QString &expr, QObject *parent) -{ - Q_D(QDeclarativeEngineDebug); - QDeclarativeDebugObjectExpressionWatch *watch = new QDeclarativeDebugObjectExpressionWatch(parent); - if (d->client->state() == QDeclarativeDebugClient::Enabled) { - int queryId = d->getId(); - watch->m_queryId = queryId; - watch->m_client = this; - watch->m_objectDebugId = object.debugId(); - watch->m_expr = expr; - d->watched.insert(queryId, watch); - - QByteArray message; - QDataStream ds(&message, QIODevice::WriteOnly); - ds << QByteArray("WATCH_EXPR_OBJECT") << queryId << object.debugId() << expr; - d->client->sendMessage(message); - } else { - watch->m_state = QDeclarativeDebugWatch::Dead; - } - return watch; -} - -QDeclarativeDebugWatch *QDeclarativeEngineDebug::addWatch(const QDeclarativeDebugObjectReference &object, QObject *parent) -{ - Q_D(QDeclarativeEngineDebug); - - QDeclarativeDebugWatch *watch = new QDeclarativeDebugWatch(parent); - if (d->client->state() == QDeclarativeDebugClient::Enabled) { - int queryId = d->getId(); - watch->m_queryId = queryId; - watch->m_client = this; - watch->m_objectDebugId = object.debugId(); - d->watched.insert(queryId, watch); - - QByteArray message; - QDataStream ds(&message, QIODevice::WriteOnly); - ds << QByteArray("WATCH_OBJECT") << queryId << object.debugId(); - d->client->sendMessage(message); - } else { - watch->m_state = QDeclarativeDebugWatch::Dead; - } - - return watch; -} - -QDeclarativeDebugWatch *QDeclarativeEngineDebug::addWatch(const QDeclarativeDebugFileReference &, QObject *) -{ - qWarning("QDeclarativeEngineDebug::addWatch(): Not implemented"); - return 0; -} - -void QDeclarativeEngineDebug::removeWatch(QDeclarativeDebugWatch *watch) -{ - Q_D(QDeclarativeEngineDebug); - - if (!watch || !watch->m_client) - return; - - watch->m_client = 0; - watch->setState(QDeclarativeDebugWatch::Inactive); - - d->watched.remove(watch->queryId()); - - if (d->client && d->client->state() == QDeclarativeDebugClient::Enabled) { - QByteArray message; - QDataStream ds(&message, QIODevice::WriteOnly); - ds << QByteArray("NO_WATCH") << watch->queryId(); - d->client->sendMessage(message); - } -} - -QDeclarativeDebugEnginesQuery *QDeclarativeEngineDebug::queryAvailableEngines(QObject *parent) -{ - Q_D(QDeclarativeEngineDebug); - - QDeclarativeDebugEnginesQuery *query = new QDeclarativeDebugEnginesQuery(parent); - if (d->client->state() == QDeclarativeDebugClient::Enabled) { - query->m_client = this; - int queryId = d->getId(); - query->m_queryId = queryId; - d->enginesQuery.insert(queryId, query); - - QByteArray message; - QDataStream ds(&message, QIODevice::WriteOnly); - ds << QByteArray("LIST_ENGINES") << queryId; - d->client->sendMessage(message); - } else { - query->m_state = QDeclarativeDebugQuery::Error; - } - - return query; -} - -QDeclarativeDebugRootContextQuery *QDeclarativeEngineDebug::queryRootContexts(const QDeclarativeDebugEngineReference &engine, QObject *parent) -{ - Q_D(QDeclarativeEngineDebug); - - QDeclarativeDebugRootContextQuery *query = new QDeclarativeDebugRootContextQuery(parent); - if (d->client->state() == QDeclarativeDebugClient::Enabled && engine.debugId() != -1) { - query->m_client = this; - int queryId = d->getId(); - query->m_queryId = queryId; - d->rootContextQuery.insert(queryId, query); - - QByteArray message; - QDataStream ds(&message, QIODevice::WriteOnly); - ds << QByteArray("LIST_OBJECTS") << queryId << engine.debugId(); - d->client->sendMessage(message); - } else { - query->m_state = QDeclarativeDebugQuery::Error; - } - - return query; -} - -QDeclarativeDebugObjectQuery *QDeclarativeEngineDebug::queryObject(const QDeclarativeDebugObjectReference &object, QObject *parent) -{ - Q_D(QDeclarativeEngineDebug); - - QDeclarativeDebugObjectQuery *query = new QDeclarativeDebugObjectQuery(parent); - if (d->client->state() == QDeclarativeDebugClient::Enabled && object.debugId() != -1) { - query->m_client = this; - int queryId = d->getId(); - query->m_queryId = queryId; - d->objectQuery.insert(queryId, query); - - QByteArray message; - QDataStream ds(&message, QIODevice::WriteOnly); - ds << QByteArray("FETCH_OBJECT") << queryId << object.debugId() - << false << true; - d->client->sendMessage(message); - } else { - query->m_state = QDeclarativeDebugQuery::Error; - } - - return query; -} - -QDeclarativeDebugObjectQuery *QDeclarativeEngineDebug::queryObjectRecursive(const QDeclarativeDebugObjectReference &object, QObject *parent) -{ - Q_D(QDeclarativeEngineDebug); - - QDeclarativeDebugObjectQuery *query = new QDeclarativeDebugObjectQuery(parent); - if (d->client->state() == QDeclarativeDebugClient::Enabled && object.debugId() != -1) { - query->m_client = this; - int queryId = d->getId(); - query->m_queryId = queryId; - d->objectQuery.insert(queryId, query); - - QByteArray message; - QDataStream ds(&message, QIODevice::WriteOnly); - ds << QByteArray("FETCH_OBJECT") << queryId << object.debugId() - << true << true; - d->client->sendMessage(message); - } else { - query->m_state = QDeclarativeDebugQuery::Error; - } - - return query; -} - -QDeclarativeDebugExpressionQuery *QDeclarativeEngineDebug::queryExpressionResult(int objectDebugId, const QString &expr, QObject *parent) -{ - Q_D(QDeclarativeEngineDebug); - - QDeclarativeDebugExpressionQuery *query = new QDeclarativeDebugExpressionQuery(parent); - if (d->client->state() == QDeclarativeDebugClient::Enabled && objectDebugId != -1) { - query->m_client = this; - query->m_expr = expr; - int queryId = d->getId(); - query->m_queryId = queryId; - d->expressionQuery.insert(queryId, query); - - QByteArray message; - QDataStream ds(&message, QIODevice::WriteOnly); - ds << QByteArray("EVAL_EXPRESSION") << queryId << objectDebugId << expr; - d->client->sendMessage(message); - } else { - query->m_state = QDeclarativeDebugQuery::Error; - } - - return query; -} - -bool QDeclarativeEngineDebug::setBindingForObject(int objectDebugId, const QString &propertyName, - const QVariant &bindingExpression, - bool isLiteralValue, - QString source, int line) -{ - Q_D(QDeclarativeEngineDebug); - - if (d->client->state() == QDeclarativeDebugClient::Enabled && objectDebugId != -1) { - QByteArray message; - QDataStream ds(&message, QIODevice::WriteOnly); - ds << QByteArray("SET_BINDING") << objectDebugId << propertyName << bindingExpression << isLiteralValue << source << line; - d->client->sendMessage(message); - return true; - } else { - return false; - } -} - -bool QDeclarativeEngineDebug::resetBindingForObject(int objectDebugId, const QString &propertyName) -{ - Q_D(QDeclarativeEngineDebug); - - if (d->client->state() == QDeclarativeDebugClient::Enabled && objectDebugId != -1) { - QByteArray message; - QDataStream ds(&message, QIODevice::WriteOnly); - ds << QByteArray("RESET_BINDING") << objectDebugId << propertyName; - d->client->sendMessage(message); - return true; - } else { - return false; - } -} - -bool QDeclarativeEngineDebug::setMethodBody(int objectDebugId, const QString &methodName, - const QString &methodBody) -{ - Q_D(QDeclarativeEngineDebug); - - if (d->client->state() == QDeclarativeDebugClient::Enabled && objectDebugId != -1) { - QByteArray message; - QDataStream ds(&message, QIODevice::WriteOnly); - ds << QByteArray("SET_METHOD_BODY") << objectDebugId << methodName << methodBody; - d->client->sendMessage(message); - return true; - } else { - return false; - } -} - -QDeclarativeDebugWatch::QDeclarativeDebugWatch(QObject *parent) - : QObject(parent), m_state(Waiting), m_queryId(-1), m_client(0), m_objectDebugId(-1) -{ -} - -QDeclarativeDebugWatch::~QDeclarativeDebugWatch() -{ - if (m_client && m_queryId != -1) - QDeclarativeEngineDebugPrivate::remove(m_client, this); -} - -int QDeclarativeDebugWatch::queryId() const -{ - return m_queryId; -} - -int QDeclarativeDebugWatch::objectDebugId() const -{ - return m_objectDebugId; -} - -QDeclarativeDebugWatch::State QDeclarativeDebugWatch::state() const -{ - return m_state; -} - -void QDeclarativeDebugWatch::setState(State s) -{ - if (m_state == s) - return; - m_state = s; - emit stateChanged(m_state); -} - -QDeclarativeDebugPropertyWatch::QDeclarativeDebugPropertyWatch(QObject *parent) - : QDeclarativeDebugWatch(parent) -{ -} - -QString QDeclarativeDebugPropertyWatch::name() const -{ - return m_name; -} - - -QDeclarativeDebugObjectExpressionWatch::QDeclarativeDebugObjectExpressionWatch(QObject *parent) - : QDeclarativeDebugWatch(parent) -{ -} - -QString QDeclarativeDebugObjectExpressionWatch::expression() const -{ - return m_expr; -} - - -QDeclarativeDebugQuery::QDeclarativeDebugQuery(QObject *parent) - : QObject(parent), m_state(Waiting) -{ -} - -QDeclarativeDebugQuery::State QDeclarativeDebugQuery::state() const -{ - return m_state; -} - -bool QDeclarativeDebugQuery::isWaiting() const -{ - return m_state == Waiting; -} - -void QDeclarativeDebugQuery::setState(State s) -{ - if (m_state == s) - return; - m_state = s; - emit stateChanged(m_state); -} - -QDeclarativeDebugEnginesQuery::QDeclarativeDebugEnginesQuery(QObject *parent) - : QDeclarativeDebugQuery(parent), m_client(0), m_queryId(-1) -{ -} - -QDeclarativeDebugEnginesQuery::~QDeclarativeDebugEnginesQuery() -{ - if (m_client && m_queryId != -1) - QDeclarativeEngineDebugPrivate::remove(m_client, this); -} - -QList QDeclarativeDebugEnginesQuery::engines() const -{ - return m_engines; -} - -QDeclarativeDebugRootContextQuery::QDeclarativeDebugRootContextQuery(QObject *parent) - : QDeclarativeDebugQuery(parent), m_client(0), m_queryId(-1) -{ -} - -QDeclarativeDebugRootContextQuery::~QDeclarativeDebugRootContextQuery() -{ - if (m_client && m_queryId != -1) - QDeclarativeEngineDebugPrivate::remove(m_client, this); -} - -QDeclarativeDebugContextReference QDeclarativeDebugRootContextQuery::rootContext() const -{ - return m_context; -} - -QDeclarativeDebugObjectQuery::QDeclarativeDebugObjectQuery(QObject *parent) - : QDeclarativeDebugQuery(parent), m_client(0), m_queryId(-1) -{ -} - -QDeclarativeDebugObjectQuery::~QDeclarativeDebugObjectQuery() -{ - if (m_client && m_queryId != -1) - QDeclarativeEngineDebugPrivate::remove(m_client, this); -} - -QDeclarativeDebugObjectReference QDeclarativeDebugObjectQuery::object() const -{ - return m_object; -} - -QDeclarativeDebugExpressionQuery::QDeclarativeDebugExpressionQuery(QObject *parent) - : QDeclarativeDebugQuery(parent), m_client(0), m_queryId(-1) -{ -} - -QDeclarativeDebugExpressionQuery::~QDeclarativeDebugExpressionQuery() -{ - if (m_client && m_queryId != -1) - QDeclarativeEngineDebugPrivate::remove(m_client, this); -} - -QVariant QDeclarativeDebugExpressionQuery::expression() const -{ - return m_expr; -} - -QVariant QDeclarativeDebugExpressionQuery::result() const -{ - return m_result; -} - -QDeclarativeDebugEngineReference::QDeclarativeDebugEngineReference() - : m_debugId(-1) -{ -} - -QDeclarativeDebugEngineReference::QDeclarativeDebugEngineReference(int debugId) - : m_debugId(debugId) -{ -} - -QDeclarativeDebugEngineReference::QDeclarativeDebugEngineReference(const QDeclarativeDebugEngineReference &o) - : m_debugId(o.m_debugId), m_name(o.m_name) -{ -} - -QDeclarativeDebugEngineReference & -QDeclarativeDebugEngineReference::operator=(const QDeclarativeDebugEngineReference &o) -{ - m_debugId = o.m_debugId; m_name = o.m_name; - return *this; -} - -int QDeclarativeDebugEngineReference::debugId() const -{ - return m_debugId; -} - -QString QDeclarativeDebugEngineReference::name() const -{ - return m_name; -} - -QDeclarativeDebugObjectReference::QDeclarativeDebugObjectReference() - : m_debugId(-1), m_contextDebugId(-1) -{ -} - -QDeclarativeDebugObjectReference::QDeclarativeDebugObjectReference(int debugId) - : m_debugId(debugId), m_contextDebugId(-1) -{ -} - -QDeclarativeDebugObjectReference::QDeclarativeDebugObjectReference(const QDeclarativeDebugObjectReference &o) - : m_debugId(o.m_debugId), m_class(o.m_class), m_idString(o.m_idString), - m_name(o.m_name), m_source(o.m_source), m_contextDebugId(o.m_contextDebugId), - m_properties(o.m_properties), m_children(o.m_children) -{ -} - -QDeclarativeDebugObjectReference & -QDeclarativeDebugObjectReference::operator=(const QDeclarativeDebugObjectReference &o) -{ - m_debugId = o.m_debugId; m_class = o.m_class; m_idString = o.m_idString; - m_name = o.m_name; m_source = o.m_source; m_contextDebugId = o.m_contextDebugId; - m_properties = o.m_properties; m_children = o.m_children; - return *this; -} - -int QDeclarativeDebugObjectReference::debugId() const -{ - return m_debugId; -} - -QString QDeclarativeDebugObjectReference::className() const -{ - return m_class; -} - -QString QDeclarativeDebugObjectReference::idString() const -{ - return m_idString; -} - -QString QDeclarativeDebugObjectReference::name() const -{ - return m_name; -} - -QDeclarativeDebugFileReference QDeclarativeDebugObjectReference::source() const -{ - return m_source; -} - -int QDeclarativeDebugObjectReference::contextDebugId() const -{ - return m_contextDebugId; -} - -QList QDeclarativeDebugObjectReference::properties() const -{ - return m_properties; -} - -QList QDeclarativeDebugObjectReference::children() const -{ - return m_children; -} - -QDeclarativeDebugContextReference::QDeclarativeDebugContextReference() - : m_debugId(-1) -{ -} - -QDeclarativeDebugContextReference::QDeclarativeDebugContextReference(const QDeclarativeDebugContextReference &o) - : m_debugId(o.m_debugId), m_name(o.m_name), m_objects(o.m_objects), m_contexts(o.m_contexts) -{ -} - -QDeclarativeDebugContextReference &QDeclarativeDebugContextReference::operator=(const QDeclarativeDebugContextReference &o) -{ - m_debugId = o.m_debugId; m_name = o.m_name; m_objects = o.m_objects; - m_contexts = o.m_contexts; - return *this; -} - -int QDeclarativeDebugContextReference::debugId() const -{ - return m_debugId; -} - -QString QDeclarativeDebugContextReference::name() const -{ - return m_name; -} - -QList QDeclarativeDebugContextReference::objects() const -{ - return m_objects; -} - -QList QDeclarativeDebugContextReference::contexts() const -{ - return m_contexts; -} - -QDeclarativeDebugFileReference::QDeclarativeDebugFileReference() - : m_lineNumber(-1), m_columnNumber(-1) -{ -} - -QDeclarativeDebugFileReference::QDeclarativeDebugFileReference(const QDeclarativeDebugFileReference &o) - : m_url(o.m_url), m_lineNumber(o.m_lineNumber), m_columnNumber(o.m_columnNumber) -{ -} - -QDeclarativeDebugFileReference &QDeclarativeDebugFileReference::operator=(const QDeclarativeDebugFileReference &o) -{ - m_url = o.m_url; m_lineNumber = o.m_lineNumber; m_columnNumber = o.m_columnNumber; - return *this; -} - -QUrl QDeclarativeDebugFileReference::url() const -{ - return m_url; -} - -void QDeclarativeDebugFileReference::setUrl(const QUrl &u) -{ - m_url = u; -} - -int QDeclarativeDebugFileReference::lineNumber() const -{ - return m_lineNumber; -} - -void QDeclarativeDebugFileReference::setLineNumber(int l) -{ - m_lineNumber = l; -} - -int QDeclarativeDebugFileReference::columnNumber() const -{ - return m_columnNumber; -} - -void QDeclarativeDebugFileReference::setColumnNumber(int c) -{ - m_columnNumber = c; -} - -QDeclarativeDebugPropertyReference::QDeclarativeDebugPropertyReference() - : m_objectDebugId(-1), m_hasNotifySignal(false) -{ -} - -QDeclarativeDebugPropertyReference::QDeclarativeDebugPropertyReference(const QDeclarativeDebugPropertyReference &o) - : m_objectDebugId(o.m_objectDebugId), m_name(o.m_name), m_value(o.m_value), - m_valueTypeName(o.m_valueTypeName), m_binding(o.m_binding), - m_hasNotifySignal(o.m_hasNotifySignal) -{ -} - -QDeclarativeDebugPropertyReference &QDeclarativeDebugPropertyReference::operator=(const QDeclarativeDebugPropertyReference &o) -{ - m_objectDebugId = o.m_objectDebugId; m_name = o.m_name; m_value = o.m_value; - m_valueTypeName = o.m_valueTypeName; m_binding = o.m_binding; - m_hasNotifySignal = o.m_hasNotifySignal; - return *this; -} - -int QDeclarativeDebugPropertyReference::objectDebugId() const -{ - return m_objectDebugId; -} - -QString QDeclarativeDebugPropertyReference::name() const -{ - return m_name; -} - -QString QDeclarativeDebugPropertyReference::valueTypeName() const -{ - return m_valueTypeName; -} - -QVariant QDeclarativeDebugPropertyReference::value() const -{ - return m_value; -} - -QString QDeclarativeDebugPropertyReference::binding() const -{ - return m_binding; -} - -bool QDeclarativeDebugPropertyReference::hasNotifySignal() const -{ - return m_hasNotifySignal; -} - -QT_END_NAMESPACE - diff --git a/src/declarative/debugger/qdeclarativeenginedebug_p.h b/src/declarative/debugger/qdeclarativeenginedebug_p.h deleted file mode 100644 index 5ca2987da3..0000000000 --- a/src/declarative/debugger/qdeclarativeenginedebug_p.h +++ /dev/null @@ -1,397 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QDECLARATIVEENGINEDEBUG_H -#define QDECLARATIVEENGINEDEBUG_H - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists purely as an -// implementation detail. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - -#include -#include -#include - -#include - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - - -class QDeclarativeDebugConnection; -class QDeclarativeDebugWatch; -class QDeclarativeDebugPropertyWatch; -class QDeclarativeDebugObjectExpressionWatch; -class QDeclarativeDebugEnginesQuery; -class QDeclarativeDebugRootContextQuery; -class QDeclarativeDebugObjectQuery; -class QDeclarativeDebugExpressionQuery; -class QDeclarativeDebugPropertyReference; -class QDeclarativeDebugContextReference; -class QDeclarativeDebugObjectReference; -class QDeclarativeDebugFileReference; -class QDeclarativeDebugEngineReference; -class QDeclarativeEngineDebugPrivate; -class Q_DECLARATIVE_PRIVATE_EXPORT QDeclarativeEngineDebug : public QObject -{ - Q_OBJECT -public: - enum State { NotConnected, Unavailable, Enabled }; - - explicit QDeclarativeEngineDebug(QDeclarativeDebugConnection *, QObject * = 0); - ~QDeclarativeEngineDebug(); - - State state() const; - - QDeclarativeDebugPropertyWatch *addWatch(const QDeclarativeDebugPropertyReference &, - QObject *parent = 0); - QDeclarativeDebugWatch *addWatch(const QDeclarativeDebugContextReference &, const QString &, - QObject *parent = 0); - QDeclarativeDebugObjectExpressionWatch *addWatch(const QDeclarativeDebugObjectReference &, const QString &, - QObject *parent = 0); - QDeclarativeDebugWatch *addWatch(const QDeclarativeDebugObjectReference &, - QObject *parent = 0); - QDeclarativeDebugWatch *addWatch(const QDeclarativeDebugFileReference &, - QObject *parent = 0); - - void removeWatch(QDeclarativeDebugWatch *watch); - - QDeclarativeDebugEnginesQuery *queryAvailableEngines(QObject *parent = 0); - QDeclarativeDebugRootContextQuery *queryRootContexts(const QDeclarativeDebugEngineReference &, - QObject *parent = 0); - QDeclarativeDebugObjectQuery *queryObject(const QDeclarativeDebugObjectReference &, - QObject *parent = 0); - QDeclarativeDebugObjectQuery *queryObjectRecursive(const QDeclarativeDebugObjectReference &, - QObject *parent = 0); - QDeclarativeDebugExpressionQuery *queryExpressionResult(int objectDebugId, - const QString &expr, - QObject *parent = 0); - bool setBindingForObject(int objectDebugId, const QString &propertyName, - const QVariant &bindingExpression, bool isLiteralValue, - QString source = QString(), int line = -1); - bool resetBindingForObject(int objectDebugId, const QString &propertyName); - bool setMethodBody(int objectDebugId, const QString &methodName, const QString &methodBody); - -Q_SIGNALS: - void newObjects(); - void stateChanged(State state); - -private: - Q_DECLARE_PRIVATE(QDeclarativeEngineDebug) -}; - -class Q_DECLARATIVE_PRIVATE_EXPORT QDeclarativeDebugWatch : public QObject -{ - Q_OBJECT -public: - enum State { Waiting, Active, Inactive, Dead }; - - QDeclarativeDebugWatch(QObject *); - ~QDeclarativeDebugWatch(); - - int queryId() const; - int objectDebugId() const; - State state() const; - -Q_SIGNALS: - void stateChanged(QDeclarativeDebugWatch::State); - //void objectChanged(int, const QDeclarativeDebugObjectReference &); - //void valueChanged(int, const QVariant &); - - // Server sends value as string if it is a user-type variant - void valueChanged(const QByteArray &name, const QVariant &value); - -private: - friend class QDeclarativeEngineDebug; - friend class QDeclarativeEngineDebugPrivate; - void setState(State); - State m_state; - int m_queryId; - QDeclarativeEngineDebug *m_client; - int m_objectDebugId; -}; - -class Q_DECLARATIVE_PRIVATE_EXPORT QDeclarativeDebugPropertyWatch : public QDeclarativeDebugWatch -{ - Q_OBJECT -public: - QDeclarativeDebugPropertyWatch(QObject *parent); - - QString name() const; - -private: - friend class QDeclarativeEngineDebug; - QString m_name; -}; - -class Q_DECLARATIVE_PRIVATE_EXPORT QDeclarativeDebugObjectExpressionWatch : public QDeclarativeDebugWatch -{ - Q_OBJECT -public: - QDeclarativeDebugObjectExpressionWatch(QObject *parent); - - QString expression() const; - -private: - friend class QDeclarativeEngineDebug; - QString m_expr; - int m_debugId; -}; - - -class Q_DECLARATIVE_PRIVATE_EXPORT QDeclarativeDebugQuery : public QObject -{ - Q_OBJECT -public: - enum State { Waiting, Error, Completed }; - - State state() const; - bool isWaiting() const; - -Q_SIGNALS: - void stateChanged(QDeclarativeDebugQuery::State); - -protected: - QDeclarativeDebugQuery(QObject *); - -private: - friend class QDeclarativeEngineDebug; - friend class QDeclarativeEngineDebugPrivate; - void setState(State); - State m_state; -}; - -class Q_DECLARATIVE_PRIVATE_EXPORT QDeclarativeDebugFileReference -{ -public: - QDeclarativeDebugFileReference(); - QDeclarativeDebugFileReference(const QDeclarativeDebugFileReference &); - QDeclarativeDebugFileReference &operator=(const QDeclarativeDebugFileReference &); - - QUrl url() const; - void setUrl(const QUrl &); - int lineNumber() const; - void setLineNumber(int); - int columnNumber() const; - void setColumnNumber(int); - -private: - friend class QDeclarativeEngineDebugPrivate; - QUrl m_url; - int m_lineNumber; - int m_columnNumber; -}; - -class Q_DECLARATIVE_PRIVATE_EXPORT QDeclarativeDebugEngineReference -{ -public: - QDeclarativeDebugEngineReference(); - QDeclarativeDebugEngineReference(int); - QDeclarativeDebugEngineReference(const QDeclarativeDebugEngineReference &); - QDeclarativeDebugEngineReference &operator=(const QDeclarativeDebugEngineReference &); - - int debugId() const; - QString name() const; - -private: - friend class QDeclarativeEngineDebugPrivate; - int m_debugId; - QString m_name; -}; - -class Q_DECLARATIVE_PRIVATE_EXPORT QDeclarativeDebugObjectReference -{ -public: - QDeclarativeDebugObjectReference(); - QDeclarativeDebugObjectReference(int); - QDeclarativeDebugObjectReference(const QDeclarativeDebugObjectReference &); - QDeclarativeDebugObjectReference &operator=(const QDeclarativeDebugObjectReference &); - - int debugId() const; - QString className() const; - QString idString() const; - QString name() const; - - QDeclarativeDebugFileReference source() const; - int contextDebugId() const; - - QList properties() const; - QList children() const; - -private: - friend class QDeclarativeEngineDebugPrivate; - int m_debugId; - QString m_class; - QString m_idString; - QString m_name; - QDeclarativeDebugFileReference m_source; - int m_contextDebugId; - QList m_properties; - QList m_children; -}; - -class Q_DECLARATIVE_PRIVATE_EXPORT QDeclarativeDebugContextReference -{ -public: - QDeclarativeDebugContextReference(); - QDeclarativeDebugContextReference(const QDeclarativeDebugContextReference &); - QDeclarativeDebugContextReference &operator=(const QDeclarativeDebugContextReference &); - - int debugId() const; - QString name() const; - - QList objects() const; - QList contexts() const; - -private: - friend class QDeclarativeEngineDebugPrivate; - int m_debugId; - QString m_name; - QList m_objects; - QList m_contexts; -}; - -class Q_DECLARATIVE_PRIVATE_EXPORT QDeclarativeDebugPropertyReference -{ -public: - QDeclarativeDebugPropertyReference(); - QDeclarativeDebugPropertyReference(const QDeclarativeDebugPropertyReference &); - QDeclarativeDebugPropertyReference &operator=(const QDeclarativeDebugPropertyReference &); - - int objectDebugId() const; - QString name() const; - QVariant value() const; - QString valueTypeName() const; - QString binding() const; - bool hasNotifySignal() const; - -private: - friend class QDeclarativeEngineDebugPrivate; - int m_objectDebugId; - QString m_name; - QVariant m_value; - QString m_valueTypeName; - QString m_binding; - bool m_hasNotifySignal; -}; - - -class Q_DECLARATIVE_PRIVATE_EXPORT QDeclarativeDebugEnginesQuery : public QDeclarativeDebugQuery -{ - Q_OBJECT -public: - virtual ~QDeclarativeDebugEnginesQuery(); - QList engines() const; -private: - friend class QDeclarativeEngineDebug; - friend class QDeclarativeEngineDebugPrivate; - QDeclarativeDebugEnginesQuery(QObject *); - QDeclarativeEngineDebug *m_client; - int m_queryId; - QList m_engines; -}; - -class Q_DECLARATIVE_PRIVATE_EXPORT QDeclarativeDebugRootContextQuery : public QDeclarativeDebugQuery -{ - Q_OBJECT -public: - virtual ~QDeclarativeDebugRootContextQuery(); - QDeclarativeDebugContextReference rootContext() const; -private: - friend class QDeclarativeEngineDebug; - friend class QDeclarativeEngineDebugPrivate; - QDeclarativeDebugRootContextQuery(QObject *); - QDeclarativeEngineDebug *m_client; - int m_queryId; - QDeclarativeDebugContextReference m_context; -}; - -class Q_DECLARATIVE_PRIVATE_EXPORT QDeclarativeDebugObjectQuery : public QDeclarativeDebugQuery -{ - Q_OBJECT -public: - virtual ~QDeclarativeDebugObjectQuery(); - QDeclarativeDebugObjectReference object() const; -private: - friend class QDeclarativeEngineDebug; - friend class QDeclarativeEngineDebugPrivate; - QDeclarativeDebugObjectQuery(QObject *); - QDeclarativeEngineDebug *m_client; - int m_queryId; - QDeclarativeDebugObjectReference m_object; - -}; - -class Q_DECLARATIVE_PRIVATE_EXPORT QDeclarativeDebugExpressionQuery : public QDeclarativeDebugQuery -{ - Q_OBJECT -public: - virtual ~QDeclarativeDebugExpressionQuery(); - QVariant expression() const; - QVariant result() const; -private: - friend class QDeclarativeEngineDebug; - friend class QDeclarativeEngineDebugPrivate; - QDeclarativeDebugExpressionQuery(QObject *); - QDeclarativeEngineDebug *m_client; - int m_queryId; - QVariant m_expr; - QVariant m_result; -}; - -QT_END_NAMESPACE - -Q_DECLARE_METATYPE(QDeclarativeDebugEngineReference) -Q_DECLARE_METATYPE(QDeclarativeDebugObjectReference) -Q_DECLARE_METATYPE(QDeclarativeDebugContextReference) -Q_DECLARE_METATYPE(QDeclarativeDebugPropertyReference) - -QT_END_HEADER - -#endif // QDECLARATIVEENGINEDEBUG_H diff --git a/src/declarative/debugger/qdeclarativeenginedebugservice.cpp b/src/declarative/debugger/qdeclarativeenginedebugservice.cpp deleted file mode 100644 index 4943959c33..0000000000 --- a/src/declarative/debugger/qdeclarativeenginedebugservice.cpp +++ /dev/null @@ -1,733 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qdeclarativeenginedebugservice_p.h" - -#include "qdeclarativedebugstatesdelegate_p.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -QT_BEGIN_NAMESPACE - -Q_GLOBAL_STATIC(QDeclarativeEngineDebugService, qmlEngineDebugService); - -QDeclarativeEngineDebugService *QDeclarativeEngineDebugService::instance() -{ - return qmlEngineDebugService(); -} - -QDeclarativeEngineDebugService::QDeclarativeEngineDebugService(QObject *parent) - : QDeclarativeDebugService(QLatin1String("QDeclarativeEngine"), 1, parent), - m_watch(new QDeclarativeWatcher(this)), - m_statesDelegate(0) -{ - QObject::connect(m_watch, SIGNAL(propertyChanged(int,int,QMetaProperty,QVariant)), - this, SLOT(propertyChanged(int,int,QMetaProperty,QVariant))); - - registerService(); -} - -QDeclarativeEngineDebugService::~QDeclarativeEngineDebugService() -{ - delete m_statesDelegate; -} - -QDataStream &operator<<(QDataStream &ds, - const QDeclarativeEngineDebugService::QDeclarativeObjectData &data) -{ - ds << data.url << data.lineNumber << data.columnNumber << data.idString - << data.objectName << data.objectType << data.objectId << data.contextId; - return ds; -} - -QDataStream &operator>>(QDataStream &ds, - QDeclarativeEngineDebugService::QDeclarativeObjectData &data) -{ - ds >> data.url >> data.lineNumber >> data.columnNumber >> data.idString - >> data.objectName >> data.objectType >> data.objectId >> data.contextId; - return ds; -} - -QDataStream &operator<<(QDataStream &ds, - const QDeclarativeEngineDebugService::QDeclarativeObjectProperty &data) -{ - ds << (int)data.type << data.name << data.value << data.valueTypeName - << data.binding << data.hasNotifySignal; - return ds; -} - -QDataStream &operator>>(QDataStream &ds, - QDeclarativeEngineDebugService::QDeclarativeObjectProperty &data) -{ - int type; - ds >> type >> data.name >> data.value >> data.valueTypeName - >> data.binding >> data.hasNotifySignal; - data.type = (QDeclarativeEngineDebugService::QDeclarativeObjectProperty::Type)type; - return ds; -} - -static inline bool isSignalPropertyName(const QString &signalName) -{ - // see QmlCompiler::isSignalPropertyName - return signalName.length() >= 3 && signalName.startsWith(QLatin1String("on")) && - signalName.at(2).isLetter() && signalName.at(2).isUpper(); -} - -static bool hasValidSignal(QObject *object, const QString &propertyName) -{ - if (!isSignalPropertyName(propertyName)) - return false; - - QString signalName = propertyName.mid(2); - signalName[0] = signalName.at(0).toLower(); - - int sigIdx = QDeclarativePropertyPrivate::findSignalByName(object->metaObject(), signalName.toLatin1()).methodIndex(); - - if (sigIdx == -1) - return false; - - return true; -} - -QDeclarativeEngineDebugService::QDeclarativeObjectProperty -QDeclarativeEngineDebugService::propertyData(QObject *obj, int propIdx) -{ - QDeclarativeObjectProperty rv; - - QMetaProperty prop = obj->metaObject()->property(propIdx); - - rv.type = QDeclarativeObjectProperty::Unknown; - rv.valueTypeName = QString::fromUtf8(prop.typeName()); - rv.name = QString::fromUtf8(prop.name()); - rv.hasNotifySignal = prop.hasNotifySignal(); - QDeclarativeAbstractBinding *binding = - QDeclarativePropertyPrivate::binding(QDeclarativeProperty(obj, rv.name)); - if (binding) - rv.binding = binding->expression(); - - if (QDeclarativeValueTypeFactory::isValueType(prop.userType())) { - rv.type = QDeclarativeObjectProperty::Basic; - } else if (QDeclarativeMetaType::isQObject(prop.userType())) { - rv.type = QDeclarativeObjectProperty::Object; - } else if (QDeclarativeMetaType::isList(prop.userType())) { - rv.type = QDeclarativeObjectProperty::List; - } - - QVariant value; - if (rv.type != QDeclarativeObjectProperty::Unknown && prop.userType() != 0) { - value = prop.read(obj); - } - rv.value = valueContents(value); - - return rv; -} - -QVariant QDeclarativeEngineDebugService::valueContents(const QVariant &value) const -{ - int userType = value.userType(); - - //QObject * is not streamable. - //Convert all such instances to a String value - - if (value.type() == QVariant::List) { - QVariantList contents; - QVariantList list = value.toList(); - int count = list.size(); - for (int i = 0; i < count; i++) - contents << valueContents(list.at(i)); - return contents; - } - - if (value.type() == QVariant::Map) { - QVariantMap contents; - QMapIterator i(value.toMap()); - while (i.hasNext()) { - i.next(); - contents.insert(i.key(), valueContents(i.value())); - } - return contents; - } - - if (QDeclarativeValueTypeFactory::isValueType(userType)) - return value; - - if (QDeclarativeMetaType::isQObject(userType)) { - QObject *o = QDeclarativeMetaType::toQObject(value); - if (o) { - QString name = o->objectName(); - if (name.isEmpty()) - name = QLatin1String(""); - return name; - } - } - - return QLatin1String(""); -} - -void QDeclarativeEngineDebugService::buildObjectDump(QDataStream &message, - QObject *object, bool recur, bool dumpProperties) -{ - message << objectData(object); - - QObjectList children = object->children(); - - int childrenCount = children.count(); - for (int ii = 0; ii < children.count(); ++ii) { - if (qobject_cast(children[ii]) || QDeclarativeBoundSignal::cast(children[ii])) - --childrenCount; - } - - message << childrenCount << recur; - - QList fakeProperties; - - for (int ii = 0; ii < children.count(); ++ii) { - QObject *child = children.at(ii); - if (qobject_cast(child)) - continue; - QDeclarativeBoundSignal *signal = QDeclarativeBoundSignal::cast(child); - if (signal) { - if (!dumpProperties) - continue; - QDeclarativeObjectProperty prop; - prop.type = QDeclarativeObjectProperty::SignalProperty; - prop.hasNotifySignal = false; - QDeclarativeExpression *expr = signal->expression(); - if (expr) { - prop.value = expr->expression(); - QObject *scope = expr->scopeObject(); - if (scope) { - QString sig = QLatin1String(scope->metaObject()->method(signal->index()).signature()); - int lparen = sig.indexOf(QLatin1Char('(')); - if (lparen >= 0) { - QString methodName = sig.mid(0, lparen); - prop.name = QLatin1String("on") + methodName[0].toUpper() - + methodName.mid(1); - } - } - } - fakeProperties << prop; - } else { - if (recur) - buildObjectDump(message, child, recur, dumpProperties); - else - message << objectData(child); - } - } - - if (!dumpProperties) { - message << 0; - return; - } - - QList propertyIndexes; - for (int ii = 0; ii < object->metaObject()->propertyCount(); ++ii) { - if (object->metaObject()->property(ii).isScriptable()) - propertyIndexes << ii; - } - - message << propertyIndexes.size() + fakeProperties.count(); - - for (int ii = 0; ii < propertyIndexes.size(); ++ii) - message << propertyData(object, propertyIndexes.at(ii)); - - for (int ii = 0; ii < fakeProperties.count(); ++ii) - message << fakeProperties[ii]; -} - -void QDeclarativeEngineDebugService::prepareDeferredObjects(QObject *obj) -{ - qmlExecuteDeferred(obj); - - QObjectList children = obj->children(); - for (int ii = 0; ii < children.count(); ++ii) { - QObject *child = children.at(ii); - prepareDeferredObjects(child); - } - -} - -void QDeclarativeEngineDebugService::buildObjectList(QDataStream &message, QDeclarativeContext *ctxt) -{ - QDeclarativeContextData *p = QDeclarativeContextData::get(ctxt); - - QString ctxtName = ctxt->objectName(); - int ctxtId = QDeclarativeDebugService::idForObject(ctxt); - - message << ctxtName << ctxtId; - - int count = 0; - - QDeclarativeContextData *child = p->childContexts; - while (child) { - ++count; - child = child->nextChild; - } - - message << count; - - child = p->childContexts; - while (child) { - buildObjectList(message, child->asQDeclarativeContext()); - child = child->nextChild; - } - - // Clean deleted objects - QDeclarativeContextPrivate *ctxtPriv = QDeclarativeContextPrivate::get(ctxt); - for (int ii = 0; ii < ctxtPriv->instances.count(); ++ii) { - if (!ctxtPriv->instances.at(ii)) { - ctxtPriv->instances.removeAt(ii); - --ii; - } - } - - message << ctxtPriv->instances.count(); - for (int ii = 0; ii < ctxtPriv->instances.count(); ++ii) { - message << objectData(ctxtPriv->instances.at(ii)); - } -} - -void QDeclarativeEngineDebugService::buildStatesList(QDeclarativeContext *ctxt, bool cleanList) -{ - if (m_statesDelegate) - m_statesDelegate->buildStatesList(ctxt, cleanList); -} - -QDeclarativeEngineDebugService::QDeclarativeObjectData -QDeclarativeEngineDebugService::objectData(QObject *object) -{ - QDeclarativeData *ddata = QDeclarativeData::get(object); - QDeclarativeObjectData rv; - if (ddata && ddata->outerContext) { - rv.url = ddata->outerContext->url; - rv.lineNumber = ddata->lineNumber; - rv.columnNumber = ddata->columnNumber; - } else { - rv.lineNumber = -1; - rv.columnNumber = -1; - } - - QDeclarativeContext *context = qmlContext(object); - if (context) { - QDeclarativeContextData *cdata = QDeclarativeContextData::get(context); - if (cdata) - rv.idString = cdata->findObjectId(object); - } - - rv.objectName = object->objectName(); - rv.objectId = QDeclarativeDebugService::idForObject(object); - rv.contextId = QDeclarativeDebugService::idForObject(qmlContext(object)); - - QDeclarativeType *type = QDeclarativeMetaType::qmlType(object->metaObject()); - if (type) { - QString typeName = type->qmlTypeName(); - int lastSlash = typeName.lastIndexOf(QLatin1Char('/')); - rv.objectType = lastSlash < 0 ? typeName : typeName.mid(lastSlash+1); - } else { - rv.objectType = QString::fromUtf8(object->metaObject()->className()); - int marker = rv.objectType.indexOf(QLatin1String("_QMLTYPE_")); - if (marker != -1) - rv.objectType = rv.objectType.left(marker); - } - - return rv; -} - -void QDeclarativeEngineDebugService::messageReceived(const QByteArray &message) -{ - QMetaObject::invokeMethod(this, "processMessage", Qt::QueuedConnection, Q_ARG(QByteArray, message)); -} - -void QDeclarativeEngineDebugService::processMessage(const QByteArray &message) -{ - QDataStream ds(message); - - QByteArray type; - ds >> type; - - if (type == "LIST_ENGINES") { - int queryId; - ds >> queryId; - - QByteArray reply; - QDataStream rs(&reply, QIODevice::WriteOnly); - rs << QByteArray("LIST_ENGINES_R"); - rs << queryId << m_engines.count(); - - for (int ii = 0; ii < m_engines.count(); ++ii) { - QDeclarativeEngine *engine = m_engines.at(ii); - - QString engineName = engine->objectName(); - int engineId = QDeclarativeDebugService::idForObject(engine); - - rs << engineName << engineId; - } - - sendMessage(reply); - } else if (type == "LIST_OBJECTS") { - int queryId; - int engineId = -1; - ds >> queryId >> engineId; - - QDeclarativeEngine *engine = - qobject_cast(QDeclarativeDebugService::objectForId(engineId)); - - QByteArray reply; - QDataStream rs(&reply, QIODevice::WriteOnly); - rs << QByteArray("LIST_OBJECTS_R") << queryId; - - if (engine) { - buildObjectList(rs, engine->rootContext()); - buildStatesList(engine->rootContext(), true); - } - - sendMessage(reply); - } else if (type == "FETCH_OBJECT") { - int queryId; - int objectId; - bool recurse; - bool dumpProperties = true; - - ds >> queryId >> objectId >> recurse >> dumpProperties; - - QObject *object = QDeclarativeDebugService::objectForId(objectId); - - QByteArray reply; - QDataStream rs(&reply, QIODevice::WriteOnly); - rs << QByteArray("FETCH_OBJECT_R") << queryId; - - if (object) { - if (recurse) - prepareDeferredObjects(object); - buildObjectDump(rs, object, recurse, dumpProperties); - } - - sendMessage(reply); - } else if (type == "WATCH_OBJECT") { - int queryId; - int objectId; - - ds >> queryId >> objectId; - bool ok = m_watch->addWatch(queryId, objectId); - - QByteArray reply; - QDataStream rs(&reply, QIODevice::WriteOnly); - rs << QByteArray("WATCH_OBJECT_R") << queryId << ok; - - sendMessage(reply); - } else if (type == "WATCH_PROPERTY") { - int queryId; - int objectId; - QByteArray property; - - ds >> queryId >> objectId >> property; - bool ok = m_watch->addWatch(queryId, objectId, property); - - QByteArray reply; - QDataStream rs(&reply, QIODevice::WriteOnly); - rs << QByteArray("WATCH_PROPERTY_R") << queryId << ok; - - sendMessage(reply); - } else if (type == "WATCH_EXPR_OBJECT") { - int queryId; - int debugId; - QString expr; - - ds >> queryId >> debugId >> expr; - bool ok = m_watch->addWatch(queryId, debugId, expr); - - QByteArray reply; - QDataStream rs(&reply, QIODevice::WriteOnly); - rs << QByteArray("WATCH_EXPR_OBJECT_R") << queryId << ok; - sendMessage(reply); - } else if (type == "NO_WATCH") { - int queryId; - - ds >> queryId; - m_watch->removeWatch(queryId); - } else if (type == "EVAL_EXPRESSION") { - int queryId; - int objectId; - QString expr; - - ds >> queryId >> objectId >> expr; - - QObject *object = QDeclarativeDebugService::objectForId(objectId); - QDeclarativeContext *context = qmlContext(object); - QVariant result; - if (object && context) { - QDeclarativeExpression exprObj(context, object, expr); - bool undefined = false; - QVariant value = exprObj.evaluate(&undefined); - if (undefined) - result = QLatin1String(""); - else - result = valueContents(value); - } else { - result = QLatin1String(""); - } - - QByteArray reply; - QDataStream rs(&reply, QIODevice::WriteOnly); - rs << QByteArray("EVAL_EXPRESSION_R") << queryId << result; - - sendMessage(reply); - } else if (type == "SET_BINDING") { - int objectId; - QString propertyName; - QVariant expr; - bool isLiteralValue; - QString filename; - int line; - ds >> objectId >> propertyName >> expr >> isLiteralValue; - if (!ds.atEnd()) { // backward compatibility from 2.1, 2.2 - ds >> filename >> line; - } - setBinding(objectId, propertyName, expr, isLiteralValue, filename, line); - } else if (type == "RESET_BINDING") { - int objectId; - QString propertyName; - ds >> objectId >> propertyName; - resetBinding(objectId, propertyName); - } else if (type == "SET_METHOD_BODY") { - int objectId; - QString methodName; - QString methodBody; - ds >> objectId >> methodName >> methodBody; - setMethodBody(objectId, methodName, methodBody); - } -} - -void QDeclarativeEngineDebugService::setBinding(int objectId, - const QString &propertyName, - const QVariant &expression, - bool isLiteralValue, - QString filename, - int line, - int column) -{ - QObject *object = objectForId(objectId); - QDeclarativeContext *context = qmlContext(object); - - if (object && context) { - QDeclarativeProperty property(object, propertyName, context); - if (property.isValid()) { - - bool inBaseState = true; - if (m_statesDelegate) { - m_statesDelegate->updateBinding(context, property, expression, isLiteralValue, - filename, line, column, &inBaseState); - } - - if (inBaseState) { - if (isLiteralValue) { - property.write(expression); - } else if (hasValidSignal(object, propertyName)) { - QDeclarativeExpression *declarativeExpression = new QDeclarativeExpression(context, object, expression.toString()); - QDeclarativePropertyPrivate::setSignalExpression(property, declarativeExpression); - declarativeExpression->setSourceLocation(filename, line, column); - } else if (property.isProperty()) { - QDeclarativeBinding *binding = new QDeclarativeBinding(expression.toString(), object, context); - binding->setTarget(property); - binding->setSourceLocation(filename, line, column); - binding->setNotifyOnValueChanged(true); - QDeclarativeAbstractBinding *oldBinding = QDeclarativePropertyPrivate::setBinding(property, binding); - if (oldBinding) - oldBinding->destroy(); - binding->update(); - } else { - qWarning() << "QDeclarativeEngineDebugService::setBinding: unable to set property" << propertyName << "on object" << object; - } - } - - } else { - // not a valid property - bool ok = false; - if (m_statesDelegate) - ok = m_statesDelegate->setBindingForInvalidProperty(object, propertyName, expression, isLiteralValue); - if (!ok) - qWarning() << "QDeclarativeEngineDebugService::setBinding: unable to set property" << propertyName << "on object" << object; - } - } -} - -void QDeclarativeEngineDebugService::resetBinding(int objectId, const QString &propertyName) -{ - QObject *object = objectForId(objectId); - QDeclarativeContext *context = qmlContext(object); - - if (object && context) { - if (object->property(propertyName.toLatin1()).isValid()) { - QDeclarativeProperty property(object, propertyName); - QDeclarativeAbstractBinding *oldBinding = QDeclarativePropertyPrivate::binding(property); - if (oldBinding) { - QDeclarativeAbstractBinding *oldBinding = QDeclarativePropertyPrivate::setBinding(property, 0); - if (oldBinding) - oldBinding->destroy(); - } - if (property.isResettable()) { - // Note: this will reset the property in any case, without regard to states - // Right now almost no QDeclarativeItem has reset methods for its properties (with the - // notable exception of QDeclarativeAnchors), so this is not a big issue - // later on, setBinding does take states into account - property.reset(); - } else { - // overwrite with default value - if (QDeclarativeType *objType = QDeclarativeMetaType::qmlType(object->metaObject())) { - if (QObject *emptyObject = objType->create()) { - if (emptyObject->property(propertyName.toLatin1()).isValid()) { - QVariant defaultValue = QDeclarativeProperty(emptyObject, propertyName).read(); - if (defaultValue.isValid()) { - setBinding(objectId, propertyName, defaultValue, true); - } - } - delete emptyObject; - } - } - } - } else if (hasValidSignal(object, propertyName)) { - QDeclarativeProperty property(object, propertyName, context); - QDeclarativePropertyPrivate::setSignalExpression(property, 0); - } else { - if (m_statesDelegate) - m_statesDelegate->resetBindingForInvalidProperty(object, propertyName); - } - } -} - -void QDeclarativeEngineDebugService::setMethodBody(int objectId, const QString &method, const QString &body) -{ - QObject *object = objectForId(objectId); - QDeclarativeContext *context = qmlContext(object); - if (!object || !context || !context->engine()) - return; - QDeclarativeContextData *contextData = QDeclarativeContextData::get(context); - if (!contextData) - return; - - QDeclarativePropertyData dummy; - QDeclarativePropertyData *prop = - QDeclarativePropertyCache::property(context->engine(), object, method, dummy); - - if (!prop || !prop->isVMEFunction()) - return; - - QMetaMethod metaMethod = object->metaObject()->method(prop->coreIndex); - QList paramNames = metaMethod.parameterNames(); - - QString paramStr; - for (int ii = 0; ii < paramNames.count(); ++ii) { - if (ii != 0) paramStr.append(QLatin1String(",")); - paramStr.append(QString::fromUtf8(paramNames.at(ii))); - } - - QString jsfunction = QLatin1String("(function ") + method + QLatin1String("(") + paramStr + - QLatin1String(") {"); - jsfunction += body; - jsfunction += QLatin1String("\n})"); - - QDeclarativeVMEMetaObject *vmeMetaObject = - static_cast(QObjectPrivate::get(object)->metaObject); - Q_ASSERT(vmeMetaObject); // the fact we found the property above should guarentee this - - int lineNumber = vmeMetaObject->vmeMethodLineNumber(prop->coreIndex); - vmeMetaObject->setVmeMethod(prop->coreIndex, QDeclarativeExpressionPrivate::evalFunction(contextData, object, jsfunction, contextData->url.toString(), lineNumber)); -} - -void QDeclarativeEngineDebugService::propertyChanged(int id, int objectId, const QMetaProperty &property, const QVariant &value) -{ - QByteArray reply; - QDataStream rs(&reply, QIODevice::WriteOnly); - - rs << QByteArray("UPDATE_WATCH") << id << objectId << QByteArray(property.name()) << valueContents(value); - - sendMessage(reply); -} - -void QDeclarativeEngineDebugService::addEngine(QDeclarativeEngine *engine) -{ - Q_ASSERT(engine); - Q_ASSERT(!m_engines.contains(engine)); - - m_engines.append(engine); -} - -void QDeclarativeEngineDebugService::remEngine(QDeclarativeEngine *engine) -{ - Q_ASSERT(engine); - Q_ASSERT(m_engines.contains(engine)); - - m_engines.removeAll(engine); -} - -void QDeclarativeEngineDebugService::objectCreated(QDeclarativeEngine *engine, QObject *object) -{ - Q_ASSERT(engine); - Q_ASSERT(m_engines.contains(engine)); - - int engineId = QDeclarativeDebugService::idForObject(engine); - int objectId = QDeclarativeDebugService::idForObject(object); - - QByteArray reply; - QDataStream rs(&reply, QIODevice::WriteOnly); - - rs << QByteArray("OBJECT_CREATED") << engineId << objectId; - sendMessage(reply); -} - -void QDeclarativeEngineDebugService::setStatesDelegate(QDeclarativeDebugStatesDelegate *delegate) -{ - m_statesDelegate = delegate; -} - -QT_END_NAMESPACE diff --git a/src/declarative/debugger/qdeclarativeenginedebugservice_p.h b/src/declarative/debugger/qdeclarativeenginedebugservice_p.h deleted file mode 100644 index d252654492..0000000000 --- a/src/declarative/debugger/qdeclarativeenginedebugservice_p.h +++ /dev/null @@ -1,136 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QDECLARATIVEENGINEDEBUGSERVICE_P_H -#define QDECLARATIVEENGINEDEBUGSERVICE_P_H - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists purely as an -// implementation detail. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - -#include - -#include -#include - -QT_BEGIN_NAMESPACE - -class QDeclarativeEngine; -class QDeclarativeContext; -class QDeclarativeWatcher; -class QDataStream; -class QDeclarativeDebugStatesDelegate; - -class Q_DECLARATIVE_PRIVATE_EXPORT QDeclarativeEngineDebugService : public QDeclarativeDebugService -{ - Q_OBJECT -public: - QDeclarativeEngineDebugService(QObject * = 0); - ~QDeclarativeEngineDebugService(); - - struct QDeclarativeObjectData { - QUrl url; - int lineNumber; - int columnNumber; - QString idString; - QString objectName; - QString objectType; - int objectId; - int contextId; - }; - - struct QDeclarativeObjectProperty { - enum Type { Unknown, Basic, Object, List, SignalProperty }; - Type type; - QString name; - QVariant value; - QString valueTypeName; - QString binding; - bool hasNotifySignal; - }; - - void addEngine(QDeclarativeEngine *); - void remEngine(QDeclarativeEngine *); - void objectCreated(QDeclarativeEngine *, QObject *); - - void setStatesDelegate(QDeclarativeDebugStatesDelegate *); - - static QDeclarativeEngineDebugService *instance(); - -protected: - virtual void messageReceived(const QByteArray &); - -private Q_SLOTS: - void processMessage(const QByteArray &msg); - void propertyChanged(int id, int objectId, const QMetaProperty &property, const QVariant &value); - -private: - void prepareDeferredObjects(QObject *); - void buildObjectList(QDataStream &, QDeclarativeContext *); - void buildObjectDump(QDataStream &, QObject *, bool, bool); - void buildStatesList(QDeclarativeContext *, bool); - QDeclarativeObjectData objectData(QObject *); - QDeclarativeObjectProperty propertyData(QObject *, int); - QVariant valueContents(const QVariant &defaultValue) const; - void setBinding(int objectId, const QString &propertyName, const QVariant &expression, bool isLiteralValue, QString filename = QString(), int line = -1, int column = 0); - void resetBinding(int objectId, const QString &propertyName); - void setMethodBody(int objectId, const QString &method, const QString &body); - - QList m_engines; - QDeclarativeWatcher *m_watch; - QDeclarativeDebugStatesDelegate *m_statesDelegate; -}; -Q_DECLARATIVE_PRIVATE_EXPORT QDataStream &operator<<(QDataStream &, const QDeclarativeEngineDebugService::QDeclarativeObjectData &); -Q_DECLARATIVE_PRIVATE_EXPORT QDataStream &operator>>(QDataStream &, QDeclarativeEngineDebugService::QDeclarativeObjectData &); -Q_DECLARATIVE_PRIVATE_EXPORT QDataStream &operator<<(QDataStream &, const QDeclarativeEngineDebugService::QDeclarativeObjectProperty &); -Q_DECLARATIVE_PRIVATE_EXPORT QDataStream &operator>>(QDataStream &, QDeclarativeEngineDebugService::QDeclarativeObjectProperty &); - -QT_END_NAMESPACE - -#endif // QDECLARATIVEENGINEDEBUGSERVICE_P_H - diff --git a/src/declarative/debugger/qdeclarativeinspectorinterface_p.h b/src/declarative/debugger/qdeclarativeinspectorinterface_p.h deleted file mode 100644 index e109fc015e..0000000000 --- a/src/declarative/debugger/qdeclarativeinspectorinterface_p.h +++ /dev/null @@ -1,83 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QDECLARATIVEINSPECTORINTERFACE_H -#define QDECLARATIVEINSPECTORINTERFACE_H - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists purely as an -// implementation detail. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - -#include - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - - -class Q_DECLARATIVE_EXPORT QDeclarativeInspectorInterface -{ -public: - QDeclarativeInspectorInterface() {} - virtual ~QDeclarativeInspectorInterface() {} - - virtual bool canHandleView(QObject *view) = 0; - - virtual void activate(QObject *view) = 0; - virtual void deactivate() = 0; - - virtual void clientMessage(const QByteArray &message) = 0; -}; - -Q_DECLARE_INTERFACE(QDeclarativeInspectorInterface, "com.trolltech.Qt.QDeclarativeInspectorInterface/1.0") - -QT_END_NAMESPACE - -QT_END_HEADER - -#endif // QDECLARATIVEINSPECTORINTERFACE_H diff --git a/src/declarative/debugger/qdeclarativeinspectorservice.cpp b/src/declarative/debugger/qdeclarativeinspectorservice.cpp deleted file mode 100644 index 94b04985ba..0000000000 --- a/src/declarative/debugger/qdeclarativeinspectorservice.cpp +++ /dev/null @@ -1,184 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qdeclarativeinspectorservice_p.h" -#include "qdeclarativeinspectorinterface_p.h" -#include "qdeclarativedebugserver_p.h" - -#include -#include -#include -#include - -// print detailed information about loading of plugins -DEFINE_BOOL_CONFIG_OPTION(qmlDebugVerbose, QML_DEBUGGER_VERBOSE) - -QT_BEGIN_NAMESPACE - -Q_GLOBAL_STATIC(QDeclarativeInspectorService, serviceInstance) - -QDeclarativeInspectorService::QDeclarativeInspectorService() - : QDeclarativeDebugService(QLatin1String("QDeclarativeObserverMode"), 1) - , m_currentInspectorPlugin(0) -{ - registerService(); -} - -QDeclarativeInspectorService *QDeclarativeInspectorService::instance() -{ - return serviceInstance(); -} - -void QDeclarativeInspectorService::addView(QObject *view) -{ - m_views.append(view); - updateState(); -} - -void QDeclarativeInspectorService::removeView(QObject *view) -{ - m_views.removeAll(view); - updateState(); -} - -void QDeclarativeInspectorService::sendMessage(const QByteArray &message) -{ - if (state() != Enabled) - return; - - QDeclarativeDebugService::sendMessage(message); -} - -void QDeclarativeInspectorService::stateChanged(State /*state*/) -{ - QMetaObject::invokeMethod(this, "updateState", Qt::QueuedConnection); -} - -void QDeclarativeInspectorService::updateState() -{ - if (m_views.isEmpty()) { - if (m_currentInspectorPlugin) { - m_currentInspectorPlugin->deactivate(); - m_currentInspectorPlugin = 0; - } - return; - } - - if (state() == Enabled) { - if (m_inspectorPlugins.isEmpty()) - loadInspectorPlugins(); - - if (m_inspectorPlugins.isEmpty()) { - qWarning() << "QDeclarativeInspector: No plugins found."; - QDeclarativeDebugServer::instance()->removeService(this); - return; - } - - foreach (QDeclarativeInspectorInterface *inspector, m_inspectorPlugins) { - if (inspector->canHandleView(m_views.first())) { - m_currentInspectorPlugin = inspector; - break; - } - } - - if (!m_currentInspectorPlugin) { - qWarning() << "QDeclarativeInspector: No plugin available for view '" << m_views.first()->metaObject()->className() << "'."; - return; - } - m_currentInspectorPlugin->activate(m_views.first()); - } else { - if (m_currentInspectorPlugin) { - m_currentInspectorPlugin->deactivate(); - m_currentInspectorPlugin = 0; - } - } -} - -void QDeclarativeInspectorService::messageReceived(const QByteArray &message) -{ - QMetaObject::invokeMethod(this, "processMessage", Qt::QueuedConnection, Q_ARG(QByteArray, message)); -} - -void QDeclarativeInspectorService::processMessage(const QByteArray &message) -{ - if (m_currentInspectorPlugin) - m_currentInspectorPlugin->clientMessage(message); -} - -void QDeclarativeInspectorService::loadInspectorPlugins() -{ - QStringList pluginCandidates; - const QStringList paths = QCoreApplication::libraryPaths(); - foreach (const QString &libPath, paths) { - const QDir dir(libPath + QLatin1String("/qmltooling")); - if (dir.exists()) - foreach (const QString &pluginPath, dir.entryList(QDir::Files)) - pluginCandidates << dir.absoluteFilePath(pluginPath); - } - - foreach (const QString &pluginPath, pluginCandidates) { - if (qmlDebugVerbose()) - qDebug() << "QDeclarativeInspector: Trying to load plugin " << pluginPath << "..."; - - QPluginLoader loader(pluginPath); - if (!loader.load()) { - if (qmlDebugVerbose()) - qDebug() << "QDeclarativeInspector: Error while loading: " << loader.errorString(); - - continue; - } - - QDeclarativeInspectorInterface *inspector = - qobject_cast(loader.instance()); - if (inspector) { - if (qmlDebugVerbose()) - qDebug() << "QDeclarativeInspector: Plugin successfully loaded."; - m_inspectorPlugins << inspector; - } else { - if (qmlDebugVerbose()) - qDebug() << "QDeclarativeInspector: Plugin does not implement interface QDeclarativeInspectorInterface."; - - loader.unload(); - } - } -} - -QT_END_NAMESPACE diff --git a/src/declarative/debugger/qdeclarativeinspectorservice_p.h b/src/declarative/debugger/qdeclarativeinspectorservice_p.h deleted file mode 100644 index 7ed530adc0..0000000000 --- a/src/declarative/debugger/qdeclarativeinspectorservice_p.h +++ /dev/null @@ -1,101 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QDECLARATIVEINSPECTORSERVICE_H -#define QDECLARATIVEINSPECTORSERVICE_H - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists purely as an -// implementation detail. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - -#include "qdeclarativedebugservice_p.h" -#include - -#include - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - - -class QDeclarativeInspectorInterface; - -class Q_DECLARATIVE_EXPORT QDeclarativeInspectorService : public QDeclarativeDebugService -{ - Q_OBJECT - -public: - QDeclarativeInspectorService(); - static QDeclarativeInspectorService *instance(); - - void addView(QObject *); - void removeView(QObject *); - - void sendMessage(const QByteArray &message); - -protected: - virtual void stateChanged(State state); - virtual void messageReceived(const QByteArray &); - -private slots: - void processMessage(const QByteArray &message); - void updateState(); - -private: - void loadInspectorPlugins(); - - QList m_views; - QDeclarativeInspectorInterface *m_currentInspectorPlugin; - QList m_inspectorPlugins; -}; - -QT_END_NAMESPACE - -QT_END_HEADER - -#endif // QDECLARATIVEINSPECTORSERVICE_H diff --git a/src/declarative/debugger/qdeclarativeprofilerservice.cpp b/src/declarative/debugger/qdeclarativeprofilerservice.cpp deleted file mode 100644 index 17ee3e5836..0000000000 --- a/src/declarative/debugger/qdeclarativeprofilerservice.cpp +++ /dev/null @@ -1,357 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qdeclarativeprofilerservice_p.h" - -#include -#include -#include -#include -#include - -// this contains QUnifiedTimer -#include - -QT_BEGIN_NAMESPACE - -Q_GLOBAL_STATIC(QDeclarativeProfilerService, profilerInstance) - -QDeclarativeBindingProfiler::QDeclarativeBindingProfiler(const QString &url, int line, int column) -{ - QDeclarativeProfilerService::startRange(QDeclarativeProfilerService::Binding); - QDeclarativeProfilerService::rangeLocation(QDeclarativeProfilerService::Binding, url, line, column); -} - -QDeclarativeBindingProfiler::~QDeclarativeBindingProfiler() -{ - QDeclarativeProfilerService::endRange(QDeclarativeProfilerService::Binding); -} - -void QDeclarativeBindingProfiler::addDetail(const QString &details) -{ - QDeclarativeProfilerService::rangeData(QDeclarativeProfilerService::Binding, details); -} - -// convert to a QByteArray that can be sent to the debug client -// use of QDataStream can skew results -// (see tst_qdeclarativedebugtrace::trace() benchmark) -QByteArray QDeclarativeProfilerData::toByteArray() const -{ - QByteArray data; - //### using QDataStream is relatively expensive - QDataStream ds(&data, QIODevice::WriteOnly); - ds << time << messageType << detailType; - if (messageType == (int)QDeclarativeProfilerService::RangeData) - ds << detailData; - if (messageType == (int)QDeclarativeProfilerService::RangeLocation) - ds << detailData << line << column; - if (messageType == (int)QDeclarativeProfilerService::Event && - detailType == (int)QDeclarativeProfilerService::AnimationFrame) - ds << framerate << animationcount; - return data; -} - -QDeclarativeProfilerService::QDeclarativeProfilerService() - : QDeclarativeDebugService(QLatin1String("CanvasFrameRate"), 1), - m_enabled(false), m_messageReceived(false) -{ - m_timer.start(); - - if (registerService() == Enabled) { - // wait for first message indicating whether to trace or not - while (!m_messageReceived) - waitForMessage(); - - QUnifiedTimer::instance()->registerProfilerCallback( &animationFrame ); - } -} - -QDeclarativeProfilerService::~QDeclarativeProfilerService() -{ -} - -void QDeclarativeProfilerService::initialize() -{ - // just make sure that the service is properly registered - profilerInstance(); -} - -bool QDeclarativeProfilerService::startProfiling() -{ - return profilerInstance()->startProfilingImpl(); -} - -bool QDeclarativeProfilerService::stopProfiling() -{ - return profilerInstance()->stopProfilingImpl(); -} - -void QDeclarativeProfilerService::sendStartedProfilingMessage() -{ - profilerInstance()->sendStartedProfilingMessageImpl(); -} - -void QDeclarativeProfilerService::addEvent(EventType t) -{ - profilerInstance()->addEventImpl(t); -} - -void QDeclarativeProfilerService::startRange(RangeType t) -{ - profilerInstance()->startRangeImpl(t); -} - -void QDeclarativeProfilerService::rangeData(RangeType t, const QString &data) -{ - profilerInstance()->rangeDataImpl(t, data); -} - -void QDeclarativeProfilerService::rangeData(RangeType t, const QUrl &data) -{ - profilerInstance()->rangeDataImpl(t, data); -} - -void QDeclarativeProfilerService::rangeLocation(RangeType t, const QString &fileName, int line, int column) -{ - profilerInstance()->rangeLocationImpl(t, fileName, line, column); -} - -void QDeclarativeProfilerService::rangeLocation(RangeType t, const QUrl &fileName, int line, int column) -{ - profilerInstance()->rangeLocationImpl(t, fileName, line, column); -} - -void QDeclarativeProfilerService::endRange(RangeType t) -{ - profilerInstance()->endRangeImpl(t); -} - -void QDeclarativeProfilerService::animationFrame(qint64 delta) -{ - profilerInstance()->animationFrameImpl(delta); -} - -void QDeclarativeProfilerService::sendProfilingData() -{ - profilerInstance()->sendMessages(); -} - -bool QDeclarativeProfilerService::startProfilingImpl() -{ - bool success = false; - if (!profilingEnabled()) { - setProfilingEnabled(true); - sendStartedProfilingMessageImpl(); - success = true; - } - return success; -} - -bool QDeclarativeProfilerService::stopProfilingImpl() -{ - bool success = false; - if (profilingEnabled()) { - addEventImpl(EndTrace); - setProfilingEnabled(false); - success = true; - } - return success; -} - -void QDeclarativeProfilerService::sendStartedProfilingMessageImpl() -{ - if (!QDeclarativeDebugService::isDebuggingEnabled() || !m_enabled) - return; - - QDeclarativeProfilerData ed = {m_timer.nsecsElapsed(), (int)Event, (int)StartTrace, QString(), -1, -1, 0, 0}; - QDeclarativeDebugService::sendMessage(ed.toByteArray()); -} - -void QDeclarativeProfilerService::addEventImpl(EventType event) -{ - if (!QDeclarativeDebugService::isDebuggingEnabled() || !m_enabled) - return; - - QDeclarativeProfilerData ed = {m_timer.nsecsElapsed(), (int)Event, (int)event, QString(), -1, -1, 0, 0}; - processMessage(ed); -} - -void QDeclarativeProfilerService::startRangeImpl(RangeType range) -{ - if (!QDeclarativeDebugService::isDebuggingEnabled() || !m_enabled) - return; - - QDeclarativeProfilerData rd = {m_timer.nsecsElapsed(), (int)RangeStart, (int)range, QString(), -1, -1, 0, 0}; - processMessage(rd); -} - -void QDeclarativeProfilerService::rangeDataImpl(RangeType range, const QString &rData) -{ - if (!QDeclarativeDebugService::isDebuggingEnabled() || !m_enabled) - return; - - QDeclarativeProfilerData rd = {m_timer.nsecsElapsed(), (int)RangeData, (int)range, rData, -1, -1, 0, 0}; - processMessage(rd); -} - -void QDeclarativeProfilerService::rangeDataImpl(RangeType range, const QUrl &rData) -{ - if (!QDeclarativeDebugService::isDebuggingEnabled() || !m_enabled) - return; - - QDeclarativeProfilerData rd = {m_timer.nsecsElapsed(), (int)RangeData, (int)range, rData.toString(QUrl::FormattingOption(0x100)), -1, -1, 0, 0}; - processMessage(rd); -} - -void QDeclarativeProfilerService::rangeLocationImpl(RangeType range, const QString &fileName, int line, int column) -{ - if (!QDeclarativeDebugService::isDebuggingEnabled() || !m_enabled) - return; - - QDeclarativeProfilerData rd = {m_timer.nsecsElapsed(), (int)RangeLocation, (int)range, fileName, line, column, 0, 0}; - processMessage(rd); -} - -void QDeclarativeProfilerService::rangeLocationImpl(RangeType range, const QUrl &fileName, int line, int column) -{ - if (!QDeclarativeDebugService::isDebuggingEnabled() || !m_enabled) - return; - - QDeclarativeProfilerData rd = {m_timer.nsecsElapsed(), (int)RangeLocation, (int)range, fileName.toString(QUrl::FormattingOption(0x100)), line, column, 0, 0}; - processMessage(rd); -} - -void QDeclarativeProfilerService::endRangeImpl(RangeType range) -{ - if (!QDeclarativeDebugService::isDebuggingEnabled() || !m_enabled) - return; - - QDeclarativeProfilerData rd = {m_timer.nsecsElapsed(), (int)RangeEnd, (int)range, QString(), -1, -1, 0, 0}; - processMessage(rd); -} - -void QDeclarativeProfilerService::animationFrameImpl(qint64 delta) -{ - Q_ASSERT(QDeclarativeDebugService::isDebuggingEnabled()); - if (!m_enabled) - return; - - int animCount = QUnifiedTimer::instance()->runningAnimationCount(); - - if (animCount > 0 && delta > 0) { - // trim fps to integer - int fps = 1000 / delta; - QDeclarativeProfilerData ed = {m_timer.nsecsElapsed(), (int)Event, (int)AnimationFrame, QString(), -1, -1, fps, animCount}; - processMessage(ed); - } -} - -/* - Either send the message directly, or queue up - a list of messages to send later (via sendMessages) -*/ -void QDeclarativeProfilerService::processMessage(const QDeclarativeProfilerData &message) -{ - QMutexLocker locker(&m_mutex); - m_data.append(message); -} - -bool QDeclarativeProfilerService::profilingEnabled() -{ - return m_enabled; -} - -void QDeclarativeProfilerService::setProfilingEnabled(bool enable) -{ - m_enabled = enable; -} - -/* - Send the messages queued up by processMessage -*/ -void QDeclarativeProfilerService::sendMessages() -{ - QMutexLocker locker(&m_mutex); - QList messages; - for (int i = 0; i < m_data.count(); ++i) - messages << m_data.at(i).toByteArray(); - m_data.clear(); - - //indicate completion - QByteArray data; - QDataStream ds(&data, QIODevice::WriteOnly); - ds << (qint64)-1 << (int)Complete; - messages << data; - - QDeclarativeDebugService::sendMessages(messages); -} - -void QDeclarativeProfilerService::stateAboutToBeChanged(QDeclarativeDebugService::State newState) -{ - if (state() == newState) - return; - - if (state() == Enabled - && m_enabled) { - stopProfilingImpl(); - sendMessages(); - } -} - -void QDeclarativeProfilerService::messageReceived(const QByteArray &message) -{ - QByteArray rwData = message; - QDataStream stream(&rwData, QIODevice::ReadOnly); - - bool enabled; - stream >> enabled; - - m_messageReceived = true; - - if (enabled) { - startProfilingImpl(); - } else { - if (stopProfilingImpl()) - sendMessages(); - } -} - -QT_END_NAMESPACE diff --git a/src/declarative/debugger/qdeclarativeprofilerservice_p.h b/src/declarative/debugger/qdeclarativeprofilerservice_p.h deleted file mode 100644 index d29690b6d6..0000000000 --- a/src/declarative/debugger/qdeclarativeprofilerservice_p.h +++ /dev/null @@ -1,183 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QDECLARATIVEPROFILERSERVICE_P_H -#define QDECLARATIVEPROFILERSERVICE_P_H - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists purely as an -// implementation detail. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - -#include -#include -#include -#include - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -struct Q_AUTOTEST_EXPORT QDeclarativeProfilerData -{ - qint64 time; - int messageType; - int detailType; - - //### - QString detailData; //used by RangeData and RangeLocation - int line; //used by RangeLocation - int column; //used by RangeLocation - int framerate; //used by animation events - int animationcount; //used by animation events - - QByteArray toByteArray() const; -}; - -Q_DECLARE_TYPEINFO(QDeclarativeProfilerData, Q_MOVABLE_TYPE); - -class QUrl; -class QDeclarativeEngine; - -// RAII -class Q_AUTOTEST_EXPORT QDeclarativeBindingProfiler { -public: - QDeclarativeBindingProfiler(const QString &url, int line, int column); - ~QDeclarativeBindingProfiler(); - void addDetail(const QString &details); -}; - -class Q_DECLARATIVE_EXPORT QDeclarativeProfilerService : public QDeclarativeDebugService -{ -public: - enum Message { - Event, - RangeStart, - RangeData, - RangeLocation, - RangeEnd, - Complete, // end of transmission - - MaximumMessage - }; - - enum EventType { - FramePaint, - Mouse, - Key, - AnimationFrame, - EndTrace, - StartTrace, - - MaximumEventType - }; - - enum RangeType { - Painting, - Compiling, - Creating, - Binding, //running a binding - HandlingSignal, //running a signal handler - - MaximumRangeType - }; - - static void initialize(); - - static bool startProfiling(); - static bool stopProfiling(); - static void sendStartedProfilingMessage(); - static void addEvent(EventType); - static void startRange(RangeType); - static void rangeData(RangeType, const QString &); - static void rangeData(RangeType, const QUrl &); - static void rangeLocation(RangeType, const QString &, int, int); - static void rangeLocation(RangeType, const QUrl &, int, int); - static void endRange(RangeType); - static void animationFrame(qint64); - - static void sendProfilingData(); - - QDeclarativeProfilerService(); - ~QDeclarativeProfilerService(); - -protected: - virtual void stateAboutToBeChanged(State state); - virtual void messageReceived(const QByteArray &); - -private: - bool startProfilingImpl(); - bool stopProfilingImpl(); - void sendStartedProfilingMessageImpl(); - void addEventImpl(EventType); - void startRangeImpl(RangeType); - void rangeDataImpl(RangeType, const QString &); - void rangeDataImpl(RangeType, const QUrl &); - void rangeLocationImpl(RangeType, const QString &, int, int); - void rangeLocationImpl(RangeType, const QUrl &, int, int); - void endRangeImpl(RangeType); - void animationFrameImpl(qint64); - - bool profilingEnabled(); - void setProfilingEnabled(bool enable); - void sendMessages(); - void processMessage(const QDeclarativeProfilerData &); - -private: - QElapsedTimer m_timer; - bool m_enabled; - bool m_messageReceived; - QVector m_data; - QMutex m_mutex; -}; - -QT_END_NAMESPACE - -QT_END_HEADER - -#endif // QDECLARATIVEPROFILERSERVICE_P_H - diff --git a/src/declarative/debugger/qpacketprotocol.cpp b/src/declarative/debugger/qpacketprotocol.cpp deleted file mode 100644 index fa5d676e0a..0000000000 --- a/src/declarative/debugger/qpacketprotocol.cpp +++ /dev/null @@ -1,550 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qpacketprotocol_p.h" - -#include -#include - -QT_BEGIN_NAMESPACE - -static const unsigned int MAX_PACKET_SIZE = 0x7FFFFFFF; - -/*! - \class QPacketProtocol - \internal - - \brief The QPacketProtocol class encapsulates communicating discrete packets - across fragmented IO channels, such as TCP sockets. - - QPacketProtocol makes it simple to send arbitrary sized data "packets" across - fragmented transports such as TCP and UDP. - - As transmission boundaries are not respected, sending packets over protocols - like TCP frequently involves "stitching" them back together at the receiver. - QPacketProtocol makes this easier by performing this task for you. Packet - data sent using QPacketProtocol is prepended with a 4-byte size header - allowing the receiving QPacketProtocol to buffer the packet internally until - it has all been received. QPacketProtocol does not perform any sanity - checking on the size or on the data, so this class should only be used in - prototyping or trusted situations where DOS attacks are unlikely. - - QPacketProtocol does not perform any communications itself. Instead it can - operate on any QIODevice that supports the QIODevice::readyRead() signal. A - logical "packet" is encapsulated by the companion QPacket class. The - following example shows two ways to send data using QPacketProtocol. The - transmitted data is equivalent in both. - - \code - QTcpSocket socket; - // ... connect socket ... - - QPacketProtocol protocol(&socket); - - // Send packet the quick way - protocol.send() << "Hello world" << 123; - - // Send packet the longer way - QPacket packet; - packet << "Hello world" << 123; - protocol.send(packet); - \endcode - - Likewise, the following shows how to read data from QPacketProtocol, assuming - that the QPacketProtocol::readyRead() signal has been emitted. - - \code - // ... QPacketProtocol::readyRead() is emitted ... - - int a; - QByteArray b; - - // Receive packet the quick way - protocol.read() >> a >> b; - - // Receive packet the longer way - QPacket packet = protocol.read(); - p >> a >> b; - \endcode - - \ingroup io - \sa QPacket -*/ - -class QPacketProtocolPrivate : public QObject -{ - Q_OBJECT -public: - QPacketProtocolPrivate(QPacketProtocol *parent, QIODevice *_dev) - : QObject(parent), inProgressSize(-1), maxPacketSize(MAX_PACKET_SIZE), - waitingForPacket(false), dev(_dev) - { - Q_ASSERT(4 == sizeof(qint32)); - - QObject::connect(this, SIGNAL(readyRead()), - parent, SIGNAL(readyRead())); - QObject::connect(this, SIGNAL(packetWritten()), - parent, SIGNAL(packetWritten())); - QObject::connect(this, SIGNAL(invalidPacket()), - parent, SIGNAL(invalidPacket())); - QObject::connect(dev, SIGNAL(readyRead()), - this, SLOT(readyToRead())); - QObject::connect(dev, SIGNAL(aboutToClose()), - this, SLOT(aboutToClose())); - QObject::connect(dev, SIGNAL(bytesWritten(qint64)), - this, SLOT(bytesWritten(qint64))); - } - -Q_SIGNALS: - void readyRead(); - void packetWritten(); - void invalidPacket(); - -public Q_SLOTS: - void aboutToClose() - { - inProgress.clear(); - sendingPackets.clear(); - inProgressSize = -1; - } - - void bytesWritten(qint64 bytes) - { - Q_ASSERT(!sendingPackets.isEmpty()); - - while (bytes) { - if (sendingPackets.at(0) > bytes) { - sendingPackets[0] -= bytes; - bytes = 0; - } else { - bytes -= sendingPackets.at(0); - sendingPackets.removeFirst(); - emit packetWritten(); - } - } - } - - void readyToRead() - { - while (true) { - // Need to get trailing data - if (-1 == inProgressSize) { - // We need a size header of sizeof(qint32) - if (sizeof(qint32) > (uint)dev->bytesAvailable()) - return; - - // Read size header - int read = dev->read((char *)&inProgressSize, sizeof(qint32)); - Q_ASSERT(read == sizeof(qint32)); - Q_UNUSED(read); - - // Check sizing constraints - if (inProgressSize > maxPacketSize) { - QObject::disconnect(dev, SIGNAL(readyRead()), - this, SLOT(readyToRead())); - QObject::disconnect(dev, SIGNAL(aboutToClose()), - this, SLOT(aboutToClose())); - QObject::disconnect(dev, SIGNAL(bytesWritten(qint64)), - this, SLOT(bytesWritten(qint64))); - dev = 0; - emit invalidPacket(); - return; - } - - inProgressSize -= sizeof(qint32); - } else { - inProgress.append(dev->read(inProgressSize - inProgress.size())); - - if (inProgressSize == inProgress.size()) { - // Packet has arrived! - packets.append(inProgress); - inProgressSize = -1; - inProgress.clear(); - - waitingForPacket = false; - emit readyRead(); - } else - return; - } - } - } - -public: - QList sendingPackets; - QList packets; - QByteArray inProgress; - qint32 inProgressSize; - qint32 maxPacketSize; - bool waitingForPacket; - QIODevice *dev; -}; - -/*! - Construct a QPacketProtocol instance that works on \a dev with the - specified \a parent. - */ -QPacketProtocol::QPacketProtocol(QIODevice *dev, QObject *parent) - : QObject(parent), d(new QPacketProtocolPrivate(this, dev)) -{ - Q_ASSERT(dev); -} - -/*! - Destroys the QPacketProtocol instance. - */ -QPacketProtocol::~QPacketProtocol() -{ -} - -/*! - Returns the maximum packet size allowed. By default this is - 2,147,483,647 bytes. - - If a packet claiming to be larger than the maximum packet size is received, - the QPacketProtocol::invalidPacket() signal is emitted. - - \sa QPacketProtocol::setMaximumPacketSize() - */ -qint32 QPacketProtocol::maximumPacketSize() const -{ - return d->maxPacketSize; -} - -/*! - Sets the maximum allowable packet size to \a max. - - \sa QPacketProtocol::maximumPacketSize() - */ -qint32 QPacketProtocol::setMaximumPacketSize(qint32 max) -{ - if (max > (signed)sizeof(qint32)) - d->maxPacketSize = max; - return d->maxPacketSize; -} - -/*! - Returns a streamable object that is transmitted on destruction. For example - - \code - protocol.send() << "Hello world" << 123; - \endcode - - will send a packet containing "Hello world" and 123. To construct more - complex packets, explicitly construct a QPacket instance. - */ -QPacketAutoSend QPacketProtocol::send() -{ - return QPacketAutoSend(this); -} - -/*! - \fn void QPacketProtocol::send(const QPacket & packet) - - Transmit the \a packet. - */ -void QPacketProtocol::send(const QPacket & p) -{ - if (p.b.isEmpty()) - return; // We don't send empty packets - - qint64 sendSize = p.b.size() + sizeof(qint32); - - d->sendingPackets.append(sendSize); - qint32 sendSize32 = sendSize; - qint64 writeBytes = d->dev->write((char *)&sendSize32, sizeof(qint32)); - Q_ASSERT(writeBytes == sizeof(qint32)); - writeBytes = d->dev->write(p.b); - Q_ASSERT(writeBytes == p.b.size()); -} - -/*! - Returns the number of received packets yet to be read. - */ -qint64 QPacketProtocol::packetsAvailable() const -{ - return d->packets.count(); -} - -/*! - Discard any unread packets. - */ -void QPacketProtocol::clear() -{ - d->packets.clear(); -} - -/*! - Return the next unread packet, or an invalid QPacket instance if no packets - are available. This method does NOT block. - */ -QPacket QPacketProtocol::read() -{ - if (0 == d->packets.count()) - return QPacket(); - - QPacket rv(d->packets.at(0)); - d->packets.removeFirst(); - return rv; -} - -/* - Returns the difference between msecs and elapsed. If msecs is -1, - however, -1 is returned. -*/ -static int qt_timeout_value(int msecs, int elapsed) -{ - if (msecs == -1) - return -1; - - int timeout = msecs - elapsed; - return timeout < 0 ? 0 : timeout; -} - -/*! - This function locks until a new packet is available for reading and the - \l{QIODevice::}{readyRead()} signal has been emitted. The function - will timeout after \a msecs milliseconds; the default timeout is - 30000 milliseconds. - - The function returns true if the readyRead() signal is emitted and - there is new data available for reading; otherwise it returns false - (if an error occurred or the operation timed out). - */ - -bool QPacketProtocol::waitForReadyRead(int msecs) -{ - if (!d->packets.isEmpty()) - return true; - - QElapsedTimer stopWatch; - stopWatch.start(); - - d->waitingForPacket = true; - do { - if (!d->dev->waitForReadyRead(msecs)) - return false; - if (!d->waitingForPacket) - return true; - msecs = qt_timeout_value(msecs, stopWatch.elapsed()); - } while (true); -} - -/*! - Return the QIODevice passed to the QPacketProtocol constructor. -*/ -QIODevice *QPacketProtocol::device() -{ - return d->dev; -} - -/*! - \fn void QPacketProtocol::readyRead() - - Emitted whenever a new packet is received. Applications may use - QPacketProtocol::read() to retrieve this packet. - */ - -/*! - \fn void QPacketProtocol::invalidPacket() - - A packet larger than the maximum allowable packet size was received. The - packet will be discarded and, as it indicates corruption in the protocol, no - further packets will be received. - */ - -/*! - \fn void QPacketProtocol::packetWritten() - - Emitted each time a packet is completing written to the device. This signal - may be used for communications flow control. - */ - -/*! - \class QPacket - \internal - - \brief The QPacket class encapsulates an unfragmentable packet of data to be - transmitted by QPacketProtocol. - - The QPacket class works together with QPacketProtocol to make it simple to - send arbitrary sized data "packets" across fragmented transports such as TCP - and UDP. - - QPacket provides a QDataStream interface to an unfragmentable packet. - Applications should construct a QPacket, propagate it with data and then - transmit it over a QPacketProtocol instance. For example: - \code - QPacketProtocol protocol(...); - - QPacket myPacket; - myPacket << "Hello world!" << 123; - protocol.send(myPacket); - \endcode - - As long as both ends of the connection are using the QPacketProtocol class, - the data within this packet will be delivered unfragmented at the other end, - ready for extraction. - - \code - QByteArray greeting; - int count; - - QPacket myPacket = protocol.read(); - - myPacket >> greeting >> count; - \endcode - - Only packets returned from QPacketProtocol::read() may be read from. QPacket - instances constructed by directly by applications are for transmission only - and are considered "write only". Attempting to read data from them will - result in undefined behavior. - - \ingroup io - \sa QPacketProtocol - */ - -/*! - Constructs an empty write-only packet. - */ -QPacket::QPacket() - : QDataStream(), buf(0) -{ - buf = new QBuffer(&b); - buf->open(QIODevice::WriteOnly); - setDevice(buf); - setVersion(QDataStream::Qt_4_7); -} - -/*! - Destroys the QPacket instance. - */ -QPacket::~QPacket() -{ - if (buf) { - delete buf; - buf = 0; - } -} - -/*! - Creates a copy of \a other. The initial stream positions are shared, but the - two packets are otherwise independent. - */ -QPacket::QPacket(const QPacket & other) - : QDataStream(), b(other.b), buf(0) -{ - buf = new QBuffer(&b); - buf->open(other.buf->openMode()); - setDevice(buf); -} - -/*! - \internal - */ -QPacket::QPacket(const QByteArray & ba) - : QDataStream(), b(ba), buf(0) -{ - buf = new QBuffer(&b); - buf->open(QIODevice::ReadOnly); - setDevice(buf); -} - -/*! - Returns true if this packet is empty - that is, contains no data. - */ -bool QPacket::isEmpty() const -{ - return b.isEmpty(); -} - -/*! - Returns raw packet data. - */ -QByteArray QPacket::data() const -{ - return b; -} - -/*! - Clears data in the packet. This is useful for reusing one writable packet. - For example - \code - QPacketProtocol protocol(...); - - QPacket packet; - - packet << "Hello world!" << 123; - protocol.send(packet); - - packet.clear(); - packet << "Goodbyte world!" << 789; - protocol.send(packet); - \endcode - */ -void QPacket::clear() -{ - QBuffer::OpenMode oldMode = buf->openMode(); - buf->close(); - b.clear(); - buf->setBuffer(&b); // reset QBuffer internals with new size of b. - buf->open(oldMode); -} - -/*! - \class QPacketAutoSend - \internal - - \internal - */ -QPacketAutoSend::QPacketAutoSend(QPacketProtocol *_p) - : QPacket(), p(_p) -{ -} - -QPacketAutoSend::~QPacketAutoSend() -{ - if (!b.isEmpty()) - p->send(*this); -} - -QT_END_NAMESPACE - -#include diff --git a/src/declarative/debugger/qpacketprotocol_p.h b/src/declarative/debugger/qpacketprotocol_p.h deleted file mode 100644 index eda7bfbac9..0000000000 --- a/src/declarative/debugger/qpacketprotocol_p.h +++ /dev/null @@ -1,137 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QPACKETPROTOCOL_H -#define QPACKETPROTOCOL_H - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists purely as an -// implementation detail. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - -#include -#include - -#include - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - - -class QIODevice; -class QBuffer; -class QPacket; -class QPacketAutoSend; -class QPacketProtocolPrivate; - -class Q_DECLARATIVE_PRIVATE_EXPORT QPacketProtocol : public QObject -{ - Q_OBJECT -public: - explicit QPacketProtocol(QIODevice *dev, QObject *parent = 0); - virtual ~QPacketProtocol(); - - qint32 maximumPacketSize() const; - qint32 setMaximumPacketSize(qint32); - - QPacketAutoSend send(); - void send(const QPacket &); - - qint64 packetsAvailable() const; - QPacket read(); - - bool waitForReadyRead(int msecs = 3000); - - void clear(); - - QIODevice *device(); - -Q_SIGNALS: - void readyRead(); - void invalidPacket(); - void packetWritten(); - -private: - QPacketProtocolPrivate *d; -}; - - -class Q_DECLARATIVE_PRIVATE_EXPORT QPacket : public QDataStream -{ -public: - QPacket(); - QPacket(const QPacket &); - virtual ~QPacket(); - - void clear(); - bool isEmpty() const; - QByteArray data() const; - -protected: - friend class QPacketProtocol; - QPacket(const QByteArray &ba); - QByteArray b; - QBuffer *buf; -}; - -class Q_DECLARATIVE_PRIVATE_EXPORT QPacketAutoSend : public QPacket -{ -public: - virtual ~QPacketAutoSend(); - -private: - friend class QPacketProtocol; - QPacketAutoSend(QPacketProtocol *); - QPacketProtocol *p; -}; - -QT_END_NAMESPACE - -QT_END_HEADER - -#endif diff --git a/src/declarative/debugger/qv8debugservice.cpp b/src/declarative/debugger/qv8debugservice.cpp deleted file mode 100644 index 389c465420..0000000000 --- a/src/declarative/debugger/qv8debugservice.cpp +++ /dev/null @@ -1,294 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qv8debugservice_p.h" -#include "qdeclarativedebugservice_p_p.h" -#include -#include - -#include -#include -#include - -//V8 DEBUG SERVICE PROTOCOL -//
-//
: "V8DEBUG" -// : ["connect", "disconnect", "interrupt", -// "v8request", "v8message", "breakonsignal", -// "breakaftercompile"] -// : connect, disconnect, interrupt: empty -// v8request, v8message: -// breakonsignal: -// breakaftercompile: - -const char *V8_DEBUGGER_KEY_VERSION = "version"; -const char *V8_DEBUGGER_KEY_CONNECT = "connect"; -const char *V8_DEBUGGER_KEY_INTERRUPT = "interrupt"; -const char *V8_DEBUGGER_KEY_DISCONNECT = "disconnect"; -const char *V8_DEBUGGER_KEY_REQUEST = "v8request"; -const char *V8_DEBUGGER_KEY_V8MESSAGE = "v8message"; -const char *V8_DEBUGGER_KEY_BREAK_ON_SIGNAL = "breakonsignal"; -const char *V8_DEBUGGER_KEY_BREAK_AFTER_COMPILE = "breakaftercompile"; - -QT_BEGIN_NAMESPACE - -struct SignalHandlerData -{ - QString functionName; - bool enabled; -}; - -Q_GLOBAL_STATIC(QV8DebugService, v8ServiceInstance) - -// DebugMessageHandler will call back already when the QV8DebugService constructor is -// running, we therefore need a plain pointer. -static QV8DebugService *v8ServiceInstancePtr = 0; - -void DebugMessageDispatchHandler() -{ - QMetaObject::invokeMethod(v8ServiceInstancePtr, "processDebugMessages", Qt::QueuedConnection); -} - -void DebugMessageHandler(const v8::Debug::Message& message) -{ - v8::DebugEvent event = message.GetEvent(); - - if (event != v8::Break && event != v8::Exception && - event != v8::AfterCompile && event != v8::BeforeCompile) - return; - v8ServiceInstancePtr->debugMessageHandler(QJSConverter::toString(message.GetJSON()), event); -} - -class QV8DebugServicePrivate : public QDeclarativeDebugServicePrivate -{ -public: - QV8DebugServicePrivate() - : connectReceived(false) - , breakAfterCompile(false) - , engine(0) - { - } - - void initializeDebuggerThread(); - - static QByteArray packMessage(const QString &type, const QString &message = QString()); - - bool connectReceived; - bool breakAfterCompile; - QMutex initializeMutex; - QStringList breakOnSignals; - const QV8Engine *engine; -}; - -QV8DebugService::QV8DebugService(QObject *parent) - : QDeclarativeDebugService(*(new QV8DebugServicePrivate()), - QLatin1String("V8Debugger"), 2, parent) -{ - Q_D(QV8DebugService); - v8ServiceInstancePtr = this; - // wait for stateChanged() -> initialize() - d->initializeMutex.lock(); - if (registerService() == Enabled) { - init(); - // ,block mode, client attached - while (!d->connectReceived) { - waitForMessage(); - } - } else { - d->initializeMutex.unlock(); - } -} - -QV8DebugService::~QV8DebugService() -{ -} - -QV8DebugService *QV8DebugService::instance() -{ - return v8ServiceInstance(); -} - -void QV8DebugService::initialize(const QV8Engine *engine) -{ - // just make sure that the service is properly registered - v8ServiceInstance()->setEngine(engine); -} - -void QV8DebugService::setEngine(const QV8Engine *engine) -{ - Q_D(QV8DebugService); - - d->engine = engine; -} - -void QV8DebugService::debugMessageHandler(const QString &message, const v8::DebugEvent &event) -{ - Q_D(QV8DebugService); - sendMessage(QV8DebugServicePrivate::packMessage(QLatin1String(V8_DEBUGGER_KEY_V8MESSAGE), message)); - if (event == v8::AfterCompile && d->breakAfterCompile) - scheduledDebugBreak(true); -} - -void QV8DebugService::signalEmitted(const QString &signal) -{ - //This function is only called by QDeclarativeBoundSignal - //only if there is a slot connected to the signal. Hence, there - //is no need for additional check. - Q_D(QV8DebugService); - - //Parse just the name and remove the class info - //Normalize to Lower case. - QString signalName = signal.left(signal.indexOf(QLatin1String("("))).toLower(); - - foreach (const QString &signal, d->breakOnSignals) { - if (signal == signalName) { - scheduledDebugBreak(true); - break; - } - } -} - -// executed in the gui thread -void QV8DebugService::init() -{ - Q_D(QV8DebugService); - v8::Debug::SetMessageHandler2(DebugMessageHandler); - v8::Debug::SetDebugMessageDispatchHandler(DebugMessageDispatchHandler); - d->initializeMutex.unlock(); -} - -// executed in the gui thread -void QV8DebugService::scheduledDebugBreak(bool schedule) -{ - if (schedule) - v8::Debug::DebugBreak(); - else - v8::Debug::CancelDebugBreak(); -} - -// executed in the debugger thread -void QV8DebugService::stateChanged(QDeclarativeDebugService::State newState) -{ - Q_D(QV8DebugService); - if (newState == Enabled) { - // execute in GUI thread - d->initializeMutex.lock(); - QMetaObject::invokeMethod(this, "init", Qt::QueuedConnection); - } -} - -// executed in the debugger thread -void QV8DebugService::messageReceived(const QByteArray &message) -{ - Q_D(QV8DebugService); - - QDataStream ds(message); - QByteArray header; - ds >> header; - - if (header == "V8DEBUG") { - QByteArray command; - QByteArray data; - ds >> command >> data; - - if (command == V8_DEBUGGER_KEY_CONNECT) { - QMutexLocker locker(&d->initializeMutex); - d->connectReceived = true; - sendMessage(QV8DebugServicePrivate::packMessage(QLatin1String(V8_DEBUGGER_KEY_CONNECT))); - - } else if (command == V8_DEBUGGER_KEY_INTERRUPT) { - // break has to be executed in gui thread - QMetaObject::invokeMethod(this, "scheduledDebugBreak", Qt::QueuedConnection, Q_ARG(bool, true)); - sendMessage(QV8DebugServicePrivate::packMessage(QLatin1String(V8_DEBUGGER_KEY_INTERRUPT))); - - } else if (command == V8_DEBUGGER_KEY_DISCONNECT) { - // cancel break has to be executed in gui thread - QMetaObject::invokeMethod(this, "scheduledDebugBreak", Qt::QueuedConnection, Q_ARG(bool, false)); - sendDebugMessage(QString::fromUtf8(data)); - - } else if (command == V8_DEBUGGER_KEY_REQUEST) { - sendDebugMessage(QString::fromUtf8(data)); - - } else if (command == V8_DEBUGGER_KEY_BREAK_ON_SIGNAL) { - QDataStream rs(data); - QByteArray signal; - bool enabled; - rs >> signal >> enabled; - //Normalize to lower case. - QString signalName(QString::fromUtf8(signal).toLower()); - if (enabled) - d->breakOnSignals.append(signalName); - else - d->breakOnSignals.removeOne(signalName); - sendMessage(QV8DebugServicePrivate::packMessage(QLatin1String(V8_DEBUGGER_KEY_BREAK_ON_SIGNAL))); - - } else if (command == V8_DEBUGGER_KEY_BREAK_AFTER_COMPILE) { - QDataStream rs(data); - rs >> d->breakAfterCompile; - sendMessage(QV8DebugServicePrivate::packMessage(QLatin1String(V8_DEBUGGER_KEY_BREAK_AFTER_COMPILE))); - - } - } -} - -void QV8DebugService::sendDebugMessage(const QString &message) -{ - v8::Debug::SendCommand(message.utf16(), message.size()); -} - -void QV8DebugService::processDebugMessages() -{ - Q_D(QV8DebugService); - v8::HandleScope handleScope; - v8::Context::Scope contextScope(d->engine->context()); - v8::Debug::ProcessDebugMessages(); -} - -QByteArray QV8DebugServicePrivate::packMessage(const QString &type, const QString &message) -{ - QByteArray reply; - QDataStream rs(&reply, QIODevice::WriteOnly); - QByteArray cmd("V8DEBUG"); - rs << cmd << type.toUtf8() << message.toUtf8(); - return reply; -} - -QT_END_NAMESPACE diff --git a/src/declarative/debugger/qv8debugservice_p.h b/src/declarative/debugger/qv8debugservice_p.h deleted file mode 100644 index 3f1d1ca177..0000000000 --- a/src/declarative/debugger/qv8debugservice_p.h +++ /dev/null @@ -1,105 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QV8DEBUGSERVICE_P_H -#define QV8DEBUGSERVICE_P_H - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists purely as an -// implementation detail. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - -#include "qdeclarativedebugservice_p.h" -#include - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - - -class QV8Engine; -class QV8DebugServicePrivate; - -class QV8DebugService : public QDeclarativeDebugService -{ - Q_OBJECT -public: - QV8DebugService(QObject *parent = 0); - ~QV8DebugService(); - - static QV8DebugService *instance(); - static void initialize(const QV8Engine *engine); - - void debugMessageHandler(const QString &message, const v8::DebugEvent &event); - - void signalEmitted(const QString &signal); - -public slots: - void processDebugMessages(); - -private slots: - void scheduledDebugBreak(bool schedule); - void sendDebugMessage(const QString &message); - void init(); - -protected: - void stateChanged(State newState); - void messageReceived(const QByteArray &); - -private: - void setEngine(const QV8Engine *engine); - -private: - Q_DISABLE_COPY(QV8DebugService) - Q_DECLARE_PRIVATE(QV8DebugService) -}; - -QT_END_NAMESPACE - -QT_END_HEADER - -#endif // QV8DEBUGSERVICE_P_H diff --git a/src/declarative/debugger/qv8profilerservice.cpp b/src/declarative/debugger/qv8profilerservice.cpp deleted file mode 100644 index 5ae2d01cc2..0000000000 --- a/src/declarative/debugger/qv8profilerservice.cpp +++ /dev/null @@ -1,287 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qv8profilerservice_p.h" -#include "qdeclarativedebugservice_p_p.h" -#include "private/qjsconverter_impl_p.h" -#include - -#include - -QT_BEGIN_NAMESPACE - -Q_GLOBAL_STATIC(QV8ProfilerService, v8ProfilerInstance) - -class DebugServiceOutputStream : public v8::OutputStream -{ - QDeclarativeDebugService &_service; -public: - DebugServiceOutputStream(QDeclarativeDebugService &service) - : v8::OutputStream(), - _service(service) {} - void EndOfStream() {} - WriteResult WriteAsciiChunk(char *rawData, int size) - { - QByteArray data; - QDataStream ds(&data, QIODevice::WriteOnly); - ds << QV8ProfilerService::V8SnapshotChunk << QByteArray(rawData, size); - _service.sendMessage(data); - return kContinue; - } -}; - -// convert to a QByteArray that can be sent to the debug client -QByteArray QV8ProfilerData::toByteArray() const -{ - QByteArray data; - //### using QDataStream is relatively expensive - QDataStream ds(&data, QIODevice::WriteOnly); - ds << messageType << filename << functionname << lineNumber << totalTime << selfTime << treeLevel; - - return data; -} - -class QV8ProfilerServicePrivate : public QDeclarativeDebugServicePrivate -{ - Q_DECLARE_PUBLIC(QV8ProfilerService) - -public: - QV8ProfilerServicePrivate() - :initialized(false) - { - } - - void takeSnapshot(v8::HeapSnapshot::Type); - - void printProfileTree(const v8::CpuProfileNode *node, int level = 0); - void sendMessages(); - - QList m_data; - - bool initialized; - QList m_ongoing; -}; - -QV8ProfilerService::QV8ProfilerService(QObject *parent) - : QDeclarativeDebugService(*(new QV8ProfilerServicePrivate()), QLatin1String("V8Profiler"), 1, parent) -{ - Q_D(QV8ProfilerService); - - if (registerService() == Enabled) { - // ,block mode, client attached - while (!d->initialized) - waitForMessage(); - } -} - -QV8ProfilerService::~QV8ProfilerService() -{ -} - -QV8ProfilerService *QV8ProfilerService::instance() -{ - return v8ProfilerInstance(); -} - -void QV8ProfilerService::initialize() -{ - // just make sure that the service is properly registered - v8ProfilerInstance(); -} - -void QV8ProfilerService::stateAboutToBeChanged(QDeclarativeDebugService::State newState) -{ - Q_D(QV8ProfilerService); - - if (state() == newState) - return; - - if (state() == Enabled) { - foreach (const QString &title, d->m_ongoing) - QMetaObject::invokeMethod(this, "stopProfiling", Qt::QueuedConnection, Q_ARG(QString, title)); - sendProfilingData(); - } -} - -void QV8ProfilerService::messageReceived(const QByteArray &message) -{ - Q_D(QV8ProfilerService); - - QDataStream ds(message); - QByteArray command; - QByteArray option; - QByteArray title; - ds >> command >> option; - - if (command == "V8PROFILER") { - ds >> title; - QString titleStr = QString::fromUtf8(title); - if (option == "start") { - QMetaObject::invokeMethod(this, "startProfiling", Qt::QueuedConnection, Q_ARG(QString, titleStr)); - } else if (option == "stop" && d->initialized) { - QMetaObject::invokeMethod(this, "stopProfiling", Qt::QueuedConnection, Q_ARG(QString, titleStr)); - QMetaObject::invokeMethod(this, "sendProfilingData", Qt::QueuedConnection); - } - d->initialized = true; - } - - if (command == "V8SNAPSHOT") { - if (option == "full") - QMetaObject::invokeMethod(this, "takeSnapshot", Qt::QueuedConnection); - else if (option == "delete") { - QMetaObject::invokeMethod(this, "deleteSnapshots", Qt::QueuedConnection); - } - } - - QDeclarativeDebugService::messageReceived(message); -} - -void QV8ProfilerService::startProfiling(const QString &title) -{ - Q_D(QV8ProfilerService); - // Start Profiling - - if (d->m_ongoing.contains(title)) - return; - - v8::HandleScope handle_scope; - v8::Handle v8title = v8::String::New(reinterpret_cast(title.data()), title.size()); - v8::CpuProfiler::StartProfiling(v8title); - - d->m_ongoing.append(title); -} - -void QV8ProfilerService::stopProfiling(const QString &title) -{ - Q_D(QV8ProfilerService); - // Stop profiling - - if (!d->m_ongoing.contains(title)) - return; - d->m_ongoing.removeOne(title); - - v8::HandleScope handle_scope; - v8::Handle v8title = v8::String::New(reinterpret_cast(title.data()), title.size()); - const v8::CpuProfile *cpuProfile = v8::CpuProfiler::StopProfiling(v8title); - if (cpuProfile) { - // can happen at start - const v8::CpuProfileNode *rootNode = cpuProfile->GetTopDownRoot(); - d->printProfileTree(rootNode); - } -} - -void QV8ProfilerService::takeSnapshot() -{ - Q_D(QV8ProfilerService); - d->takeSnapshot(v8::HeapSnapshot::kFull); -} - -void QV8ProfilerService::deleteSnapshots() -{ - v8::HeapProfiler::DeleteAllSnapshots(); -} - -void QV8ProfilerService::sendProfilingData() -{ - Q_D(QV8ProfilerService); - // Send messages to client - d->sendMessages(); -} - -void QV8ProfilerServicePrivate::printProfileTree(const v8::CpuProfileNode *node, int level) -{ - for (int index = 0 ; index < node->GetChildrenCount() ; index++) { - const v8::CpuProfileNode* childNode = node->GetChild(index); - QString scriptResourceName = QJSConverter::toString(childNode->GetScriptResourceName()); - if (scriptResourceName.length() > 0) { - - QV8ProfilerData rd = {(int)QV8ProfilerService::V8Entry, scriptResourceName, - QJSConverter::toString(childNode->GetFunctionName()), - childNode->GetLineNumber(), childNode->GetTotalTime(), childNode->GetSelfTime(), level}; - m_data.append(rd); - - // different nodes might have common children: fix at client side - if (childNode->GetChildrenCount() > 0) { - printProfileTree(childNode, level+1); - } - } - } -} - -void QV8ProfilerServicePrivate::takeSnapshot(v8::HeapSnapshot::Type snapshotType) -{ - Q_Q(QV8ProfilerService); - - v8::HandleScope scope; - v8::Local title = v8::String::New(""); - - DebugServiceOutputStream outputStream(*q); - const v8::HeapSnapshot *snapshot = v8::HeapProfiler::TakeSnapshot(title, snapshotType); - snapshot->Serialize(&outputStream, v8::HeapSnapshot::kJSON); - - //indicate completion - QByteArray data; - QDataStream ds(&data, QIODevice::WriteOnly); - ds << (int)QV8ProfilerService::V8SnapshotComplete; - - q->sendMessage(data); -} - -void QV8ProfilerServicePrivate::sendMessages() -{ - Q_Q(QV8ProfilerService); - - QList messages; - for (int i = 0; i < m_data.count(); ++i) - messages << m_data.at(i).toByteArray(); - q->sendMessages(messages); - m_data.clear(); - - //indicate completion - QByteArray data; - QDataStream ds(&data, QIODevice::WriteOnly); - ds << (int)QV8ProfilerService::V8Complete; - - q->sendMessage(data); -} - - -QT_END_NAMESPACE diff --git a/src/declarative/debugger/qv8profilerservice_p.h b/src/declarative/debugger/qv8profilerservice_p.h deleted file mode 100644 index 706907ae23..0000000000 --- a/src/declarative/debugger/qv8profilerservice_p.h +++ /dev/null @@ -1,119 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QV8PROFILERSERVICE_P_H -#define QV8PROFILERSERVICE_P_H - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists purely as an -// implementation detail. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - -#include - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - - -struct Q_AUTOTEST_EXPORT QV8ProfilerData -{ - int messageType; - QString filename; - QString functionname; - int lineNumber; - double totalTime; - double selfTime; - int treeLevel; - - QByteArray toByteArray() const; -}; - -class QDeclarativeEngine; -class QV8ProfilerServicePrivate; - -class Q_AUTOTEST_EXPORT QV8ProfilerService : public QDeclarativeDebugService -{ - Q_OBJECT -public: - enum MessageType { - V8Entry, - V8Complete, - V8SnapshotChunk, - V8SnapshotComplete, - - V8MaximumMessage - }; - - QV8ProfilerService(QObject *parent = 0); - ~QV8ProfilerService(); - - static QV8ProfilerService *instance(); - static void initialize(); - -public slots: - void startProfiling(const QString &title); - void stopProfiling(const QString &title); - void takeSnapshot(); - void deleteSnapshots(); - - void sendProfilingData(); - -protected: - void stateAboutToBeChanged(State state); - void messageReceived(const QByteArray &); - -private: - Q_DISABLE_COPY(QV8ProfilerService) - Q_DECLARE_PRIVATE(QV8ProfilerService) -}; - -QT_END_NAMESPACE - -QT_END_HEADER - -#endif // QV8PROFILERSERVICE_P_H diff --git a/src/declarative/declarative.pro b/src/declarative/declarative.pro deleted file mode 100644 index 1da58ce5d9..0000000000 --- a/src/declarative/declarative.pro +++ /dev/null @@ -1,34 +0,0 @@ -load(qt_module) - -TARGET = QtDeclarative -QPRO_PWD = $$PWD - -CONFIG += module -MODULE_PRI += ../../modules/qt_declarative.pri - -QT = core-private gui gui-private network v8-private - -DEFINES += QT_BUILD_DECLARATIVE_LIB QT_NO_URL_CAST_FROM_STRING QT_NO_INTEGER_EVENT_COORDINATES -win32-msvc*|win32-icc:QMAKE_LFLAGS += /BASE:0x66000000 -win32-msvc*:DEFINES *= _CRT_SECURE_NO_WARNINGS -solaris-cc*:QMAKE_CXXFLAGS_RELEASE -= -O2 - -unix|win32-g++*:QMAKE_PKGCONFIG_REQUIRES = QtCore QtGui - -exists("qdeclarative_enable_gcov") { - QMAKE_CXXFLAGS = -fprofile-arcs -ftest-coverage -fno-elide-constructors - LIBS += -lgcov -} - -load(qt_module_config) - -HEADERS += qtdeclarativeversion.h - -#INCLUDEPATH -= $$QMAKE_INCDIR_QT/$$TARGET -#DESTDIR=. - -#modules -include(util/util.pri) -include(qml/qml.pri) -include(debugger/debugger.pri) -include(animations/animations.pri) \ No newline at end of file diff --git a/src/declarative/qml/ftw/ftw.pri b/src/declarative/qml/ftw/ftw.pri deleted file mode 100644 index 26343422c5..0000000000 --- a/src/declarative/qml/ftw/ftw.pri +++ /dev/null @@ -1,29 +0,0 @@ -HEADERS += \ - $$PWD/qbitfield_p.h \ - $$PWD/qintrusivelist_p.h \ - $$PWD/qpodvector_p.h \ - $$PWD/qhashedstring_p.h \ - $$PWD/qdeclarativerefcount_p.h \ - $$PWD/qdeclarativepool_p.h \ - $$PWD/qfieldlist_p.h \ - $$PWD/qfastmetabuilder_p.h \ - $$PWD/qhashfield_p.h \ - $$PWD/qdeclarativethread_p.h \ - $$PWD/qfinitestack_p.h \ - $$PWD/qrecursionwatcher_p.h \ - $$PWD/qdeletewatcher_p.h \ - $$PWD/qrecyclepool_p.h \ - $$PWD/qflagpointer_p.h \ - $$PWD/qdeclarativetrace_p.h \ - $$PWD/qpointervaluepair_p.h \ - $$PWD/qlazilyallocated_p.h \ - -SOURCES += \ - $$PWD/qintrusivelist.cpp \ - $$PWD/qhashedstring.cpp \ - $$PWD/qdeclarativepool.cpp \ - $$PWD/qfastmetabuilder.cpp \ - $$PWD/qdeclarativethread.cpp \ - $$PWD/qdeclarativetrace.cpp \ - -contains(QT_CONFIG, clock-gettime):include($$QT_SOURCE_TREE/config.tests/unix/clock-gettime/clock-gettime.pri) diff --git a/src/declarative/qml/ftw/qbitfield_p.h b/src/declarative/qml/ftw/qbitfield_p.h deleted file mode 100644 index addd21c96d..0000000000 --- a/src/declarative/qml/ftw/qbitfield_p.h +++ /dev/null @@ -1,165 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QBITFIELD_P_H -#define QBITFIELD_P_H - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists purely as an -// implementation detail. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - -#include - -QT_BEGIN_NAMESPACE - -class QBitField -{ -public: - inline QBitField(); - inline QBitField(const quint32 *, int bits); - inline QBitField(const QBitField &); - inline ~QBitField(); - - inline QBitField &operator=(const QBitField &); - - inline quint32 size() const; - inline QBitField united(const QBitField &); - inline bool testBit(int) const; - -private: - quint32 bits:31; - quint32 *ownData; - const quint32 *data; -}; - -QBitField::QBitField() -: bits(0), ownData(0), data(0) -{ -} - -QBitField::QBitField(const quint32 *bitData, int bitCount) -: bits((quint32)bitCount), ownData(0), data(bitData) -{ -} - -QBitField::QBitField(const QBitField &other) -: bits(other.bits), ownData(other.ownData), data(other.data) -{ - if (ownData) - ++(*ownData); -} - -QBitField::~QBitField() -{ - if (ownData) - if(0 == --(*ownData)) delete [] ownData; -} - -QBitField &QBitField::operator=(const QBitField &other) -{ - if (other.data == data) - return *this; - - if (ownData) - if(0 == --(*ownData)) delete [] ownData; - - bits = other.bits; - ownData = other.ownData; - data = other.data; - - if (ownData) - ++(*ownData); - - return *this; -} - -inline quint32 QBitField::size() const -{ - return bits; -} - -QBitField QBitField::united(const QBitField &o) -{ - if (o.bits == 0) { - return *this; - } else if (bits == 0) { - return o; - } else { - int max = (bits > o.bits)?bits:o.bits; - int length = (max + 31) / 32; - QBitField rv; - rv.bits = max; - rv.ownData = new quint32[length + 1]; - *(rv.ownData) = 1; - rv.data = rv.ownData + 1; - if (bits > o.bits) { - ::memcpy((quint32 *)rv.data, data, length * sizeof(quint32)); - for (quint32 ii = 0; ii < (o.bits + quint32(31)) / 32; ++ii) - ((quint32 *)rv.data)[ii] |= o.data[ii]; - } else { - ::memcpy((quint32 *)rv.data, o.data, length * sizeof(quint32)); - for (quint32 ii = 0; ii < (bits + quint32(31)) / 32; ++ii) - ((quint32 *)rv.data)[ii] |= data[ii]; - } - return rv; - } -} - -bool QBitField::testBit(int b) const -{ - Q_ASSERT(b >= 0); - if ((quint32)b < bits) { - return data[b / 32] & (1 << (b % 32)); - } else { - return false; - } -} - -QT_END_NAMESPACE - -#endif // QBITFIELD_P_H diff --git a/src/declarative/qml/ftw/qdeclarativepool.cpp b/src/declarative/qml/ftw/qdeclarativepool.cpp deleted file mode 100644 index d816e5bb95..0000000000 --- a/src/declarative/qml/ftw/qdeclarativepool.cpp +++ /dev/null @@ -1,92 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qdeclarativepool_p.h" - -// #define POOL_DEBUG - -QT_BEGIN_NAMESPACE - -void QDeclarativePool::newpage() -{ -#ifdef POOL_DEBUG - qWarning("QDeclarativePool: Allocating page"); -#endif - - Page *page = (Page *)malloc(sizeof(Page)); - page->header.next = _page; - page->header.free = page->memory; - _page = page; -} - -void QDeclarativePool::clear() -{ -#ifdef POOL_DEBUG - int count = 0; -#endif - - Class *c = _classList; - while (c) { - Class *n = c->_next; - c->_destroy(c); -#ifdef POOL_DEBUG - ++count; -#endif - c = n; - } - -#ifdef POOL_DEBUG - qWarning("QDeclarativePool: Destroyed %d objects", count); -#endif - - Page *p = _page; - while (p) { - Page *n = p->header.next; - free(p); - p = n; - } - - _classList = 0; - _page = 0; -} - - -QT_END_NAMESPACE diff --git a/src/declarative/qml/ftw/qdeclarativepool_p.h b/src/declarative/qml/ftw/qdeclarativepool_p.h deleted file mode 100644 index d04c0e9eef..0000000000 --- a/src/declarative/qml/ftw/qdeclarativepool_p.h +++ /dev/null @@ -1,278 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QDECLARATIVEPOOL_P_H -#define QDECLARATIVEPOOL_P_H - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists purely as an -// implementation detail. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - -#include -#include -#include - -QT_BEGIN_NAMESPACE - -// Exported for QtQuick1 -class Q_DECLARATIVE_EXPORT QDeclarativePool -{ -public: - // The class has a destructor that needs to be called - class Class { - public: - inline QDeclarativePool *pool() const; - - private: - void *operator new(size_t); - void *operator new(size_t, void *m) { return m; } - friend class QDeclarativePool; - - QDeclarativePool *_pool; - Class *_next; - void (*_destroy)(Class *); - }; - - // The class is plain old data and no destructor needs to - // be called - class POD { - public: - inline QDeclarativePool *pool() const; - - private: - void *operator new(size_t); - void *operator new(size_t, void *m) { return m; } - friend class QDeclarativePool; - - QDeclarativePool *_pool; - }; - - inline QDeclarativePool(); - inline ~QDeclarativePool(); - - void clear(); - - template - inline T *New(); - template - inline T *NewRaw(); - template - inline T *NewRawArray(int length); - - inline QString *NewString(const QString &); - inline QByteArray *NewByteArray(const QByteArray &); - inline QUrl *NewUrl(const QUrl &); - - template - struct List { - List() : m_length(0), m_data(0) {} - List(const List &o) : m_length(o.m_length), m_data(o.m_data) {} - List &operator=(const List &o) { - m_length = o.m_length; - m_data = o.m_data; - return *this; - } - - int count() const { - return m_length; - } - int length() const { - return m_length; - } - const T &at(int index) const { - Q_ASSERT(index < m_length); - return m_data[index]; - }; - T &operator[](int index) { - Q_ASSERT(index < m_length); - return m_data[index]; - }; - private: - friend class QDeclarativePool; - List(T *d, int l) : m_length(l), m_data(d) {} - int m_length; - T *m_data; - }; - - template - inline List NewRawList(int length); - -private: - struct StringClass : public QString, public Class { - }; - struct ByteArrayClass : public QByteArray, public Class { - }; - struct UrlClass : public QUrl, public Class { - }; - - inline void *allocate(int size); - void newpage(); - - template - inline void initialize(POD *); - template - inline void initialize(Class *); - template - static void destroy(Class *c); - - struct Page { - struct Header { - Page *next; - char *free; - } header; - - static const int pageSize = 4 * 4096 - sizeof(Header); - - char memory[pageSize]; - }; - - Page *_page; - Class *_classList; -}; - -QDeclarativePool::QDeclarativePool() -: _page(0), _classList(0) -{ -} - -QDeclarativePool::~QDeclarativePool() -{ - clear(); -} - -template -T *QDeclarativePool::New() -{ - T *rv = new (allocate(sizeof(T))) T; - initialize(rv); - rv->_pool = this; - return rv; -} - -template -T *QDeclarativePool::NewRaw() -{ - return (T*)allocate(sizeof(T)); -} - -template -T *QDeclarativePool::NewRawArray(int length) -{ - return (T*)allocate(length * sizeof(T)); -} - -template -QDeclarativePool::List QDeclarativePool::NewRawList(int length) -{ - return List(NewRawArray(length), length); -} - -QString *QDeclarativePool::NewString(const QString &s) -{ - QString *rv = New(); - *rv = s; - return rv; -} - -QByteArray *QDeclarativePool::NewByteArray(const QByteArray &s) -{ - QByteArray *rv = New(); - *rv = s; - return rv; -} - -QUrl *QDeclarativePool::NewUrl(const QUrl &s) -{ - QUrl *rv = New(); - *rv = s; - return rv; -} - -void *QDeclarativePool::allocate(int size) -{ - if (!_page || (_page->header.free + size) > (_page->memory + Page::pageSize)) - newpage(); - - void *rv = _page->header.free; - _page->header.free += size + ((8 - size) & 7); // ensure 8 byte alignment; - return rv; -} - -template -void QDeclarativePool::initialize(QDeclarativePool::POD *) -{ -} - -template -void QDeclarativePool::initialize(QDeclarativePool::Class *c) -{ - c->_next = _classList; - c->_destroy = &destroy; - _classList = c; -} - -template -void QDeclarativePool::destroy(Class *c) -{ - static_cast(c)->~T(); -} - -QDeclarativePool *QDeclarativePool::Class::pool() const -{ - return _pool; -} - -QDeclarativePool *QDeclarativePool::POD::pool() const -{ - return _pool; -} - -QT_END_NAMESPACE - -#endif // QDECLARATIVEPOOL_P_H - diff --git a/src/declarative/qml/ftw/qdeclarativerefcount_p.h b/src/declarative/qml/ftw/qdeclarativerefcount_p.h deleted file mode 100644 index 05aede4534..0000000000 --- a/src/declarative/qml/ftw/qdeclarativerefcount_p.h +++ /dev/null @@ -1,192 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QDECLARATIVEREFCOUNT_P_H -#define QDECLARATIVEREFCOUNT_P_H - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists purely as an -// implementation detail. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - -#include -#include - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - - -class QDeclarativeRefCount -{ -public: - inline QDeclarativeRefCount(); - inline virtual ~QDeclarativeRefCount(); - inline void addref(); - inline void release(); - -protected: - inline virtual void destroy(); - -private: - QAtomicInt refCount; -}; - -template -class QDeclarativeRefPointer -{ -public: - inline QDeclarativeRefPointer(); - inline QDeclarativeRefPointer(T *); - inline QDeclarativeRefPointer(const QDeclarativeRefPointer &); - inline ~QDeclarativeRefPointer(); - - inline QDeclarativeRefPointer &operator=(const QDeclarativeRefPointer &o); - inline QDeclarativeRefPointer &operator=(T *); - - inline bool isNull() const { return !o; } - - inline T* operator->() const { return o; } - inline T& operator*() const { return *o; } - inline operator T*() const { return o; } - inline T* data() const { return o; } - - inline QDeclarativeRefPointer &take(T *); - -private: - T *o; -}; - -QDeclarativeRefCount::QDeclarativeRefCount() -: refCount(1) -{ -} - -QDeclarativeRefCount::~QDeclarativeRefCount() -{ - Q_ASSERT(refCount.load() == 0); -} - -void QDeclarativeRefCount::addref() -{ - Q_ASSERT(refCount.load() > 0); - refCount.ref(); -} - -void QDeclarativeRefCount::release() -{ - Q_ASSERT(refCount.load() > 0); - if (!refCount.deref()) - destroy(); -} - -void QDeclarativeRefCount::destroy() -{ - delete this; -} - -template -QDeclarativeRefPointer::QDeclarativeRefPointer() -: o(0) -{ -} - -template -QDeclarativeRefPointer::QDeclarativeRefPointer(T *o) -: o(o) -{ - if (o) o->addref(); -} - -template -QDeclarativeRefPointer::QDeclarativeRefPointer(const QDeclarativeRefPointer &other) -: o(other.o) -{ - if (o) o->addref(); -} - -template -QDeclarativeRefPointer::~QDeclarativeRefPointer() -{ - if (o) o->release(); -} - -template -QDeclarativeRefPointer &QDeclarativeRefPointer::operator=(const QDeclarativeRefPointer &other) -{ - if (other.o) other.o->addref(); - if (o) o->release(); - o = other.o; - return *this; -} - -template -QDeclarativeRefPointer &QDeclarativeRefPointer::operator=(T *other) -{ - if (other) other->addref(); - if (o) o->release(); - o = other; - return *this; -} - -/*! -Takes ownership of \a other. take() does *not* add a reference, as it assumes ownership -of the callers reference of other. -*/ -template -QDeclarativeRefPointer &QDeclarativeRefPointer::take(T *other) -{ - if (o) o->release(); - o = other; - return *this; -} - -QT_END_NAMESPACE - -QT_END_HEADER - -#endif // QDECLARATIVEREFCOUNT_P_H diff --git a/src/declarative/qml/ftw/qdeclarativethread.cpp b/src/declarative/qml/ftw/qdeclarativethread.cpp deleted file mode 100644 index be51a09f8d..0000000000 --- a/src/declarative/qml/ftw/qdeclarativethread.cpp +++ /dev/null @@ -1,359 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qdeclarativethread_p.h" - -#include - -#include -#include -#include -#include -#include - -QT_BEGIN_NAMESPACE - -class QDeclarativeThreadPrivate : public QThread -{ -public: - QDeclarativeThreadPrivate(QDeclarativeThread *); - QDeclarativeThread *q; - - virtual void run(); - - inline void lock() { _mutex.lock(); } - inline void unlock() { _mutex.unlock(); } - inline void wait() { _wait.wait(&_mutex); } - inline void wakeOne() { _wait.wakeOne(); } - inline void wakeAll() { _wait.wakeAll(); } - - quint32 m_threadProcessing:1; // Set when the thread is processing messages - quint32 m_mainProcessing:1; // Set when the main thread is processing messages - quint32 m_shutdown:1; // Set by main thread to request a shutdown - quint32 m_mainThreadWaiting:1; // Set by main thread if it is waiting for the message queue to empty - - typedef QFieldList MessageList; - MessageList threadList; - MessageList mainList; - - QDeclarativeThread::Message *mainSync; - - void triggerMainEvent(); - void triggerThreadEvent(); - - void mainEvent(); - void threadEvent(); - -protected: - virtual bool event(QEvent *); - -private: - struct MainObject : public QObject { - MainObject(QDeclarativeThreadPrivate *p); - virtual bool event(QEvent *e); - QDeclarativeThreadPrivate *p; - }; - MainObject m_mainObject; - - QMutex _mutex; - QWaitCondition _wait; -}; - -QDeclarativeThreadPrivate::MainObject::MainObject(QDeclarativeThreadPrivate *p) -: p(p) -{ -} - -// Trigger mainEvent in main thread. Must be called from thread. -void QDeclarativeThreadPrivate::triggerMainEvent() -{ - Q_ASSERT(q->isThisThread()); - QCoreApplication::postEvent(&m_mainObject, new QEvent(QEvent::User)); -} - -// Trigger even in thread. Must be called from main thread. -void QDeclarativeThreadPrivate::triggerThreadEvent() -{ - Q_ASSERT(!q->isThisThread()); - QCoreApplication::postEvent(this, new QEvent(QEvent::User)); -} - -bool QDeclarativeThreadPrivate::MainObject::event(QEvent *e) -{ - if (e->type() == QEvent::User) - p->mainEvent(); - return QObject::event(e); -} - -QDeclarativeThreadPrivate::QDeclarativeThreadPrivate(QDeclarativeThread *q) -: q(q), m_threadProcessing(false), m_mainProcessing(false), m_shutdown(false), - m_mainThreadWaiting(false), mainSync(0), m_mainObject(this) -{ -} - -bool QDeclarativeThreadPrivate::event(QEvent *e) -{ - if (e->type() == QEvent::User) - threadEvent(); - return QThread::event(e); -} - -void QDeclarativeThreadPrivate::run() -{ - lock(); - - wakeOne(); - - unlock(); - - q->startupThread(); - exec(); -} - -void QDeclarativeThreadPrivate::mainEvent() -{ - lock(); - - m_mainProcessing = true; - - while (!mainList.isEmpty() || mainSync) { - bool isSync = mainSync != 0; - QDeclarativeThread::Message *message = isSync?mainSync:mainList.takeFirst(); - unlock(); - - message->call(q); - delete message; - - lock(); - - if (isSync) { - mainSync = 0; - wakeOne(); - } - } - - m_mainProcessing = false; - - unlock(); -} - -void QDeclarativeThreadPrivate::threadEvent() -{ - lock(); - - if (m_shutdown) { - quit(); - wakeOne(); - unlock(); - q->shutdownThread(); - } else { - m_threadProcessing = true; - - while (!threadList.isEmpty()) { - QDeclarativeThread::Message *message = threadList.first(); - - unlock(); - - message->call(q); - - lock(); - - delete threadList.takeFirst(); - } - - wakeOne(); - - m_threadProcessing = false; - - unlock(); - } -} - -QDeclarativeThread::QDeclarativeThread() -: d(new QDeclarativeThreadPrivate(this)) -{ - d->lock(); - d->start(); - d->wait(); - d->unlock(); - d->moveToThread(d); - -} - -QDeclarativeThread::~QDeclarativeThread() -{ - delete d; -} - -void QDeclarativeThread::shutdown() -{ - d->lock(); - Q_ASSERT(!d->m_shutdown); - d->m_shutdown = true; - if (d->threadList.isEmpty() && d->m_threadProcessing == false) - d->triggerThreadEvent(); - d->wait(); - d->unlock(); - d->QThread::wait(); -} - -void QDeclarativeThread::lock() -{ - d->lock(); -} - -void QDeclarativeThread::unlock() -{ - d->unlock(); -} - -void QDeclarativeThread::wakeOne() -{ - d->wakeOne(); -} - -void QDeclarativeThread::wakeAll() -{ - d->wakeAll(); -} - -void QDeclarativeThread::wait() -{ - d->wait(); -} - -bool QDeclarativeThread::isThisThread() const -{ - return QThread::currentThread() == d; -} - -QThread *QDeclarativeThread::thread() const -{ - return const_cast(static_cast(d)); -} - -// Called when the thread starts. Do startup stuff in here. -void QDeclarativeThread::startupThread() -{ -} - -// Called when the thread shuts down. Do cleanup in here. -void QDeclarativeThread::shutdownThread() -{ -} - -void QDeclarativeThread::internalCallMethodInThread(Message *message) -{ - Q_ASSERT(!isThisThread()); - d->lock(); - Q_ASSERT(d->m_mainThreadWaiting == false); - - bool wasEmpty = d->threadList.isEmpty(); - d->threadList.append(message); - if (wasEmpty && d->m_threadProcessing == false) - d->triggerThreadEvent(); - - d->m_mainThreadWaiting = true; - - do { - if (d->mainSync) { - QDeclarativeThread::Message *message = d->mainSync; - unlock(); - message->call(this); - delete message; - lock(); - d->mainSync = 0; - wakeOne(); - } else { - d->wait(); - } - } while (d->mainSync || !d->threadList.isEmpty()); - - d->m_mainThreadWaiting = false; - d->unlock(); -} - -void QDeclarativeThread::internalCallMethodInMain(Message *message) -{ - Q_ASSERT(isThisThread()); - - d->lock(); - - Q_ASSERT(d->mainSync == 0); - d->mainSync = message; - - if (d->m_mainThreadWaiting) { - d->wakeOne(); - } else if (d->m_mainProcessing) { - // Do nothing - it is already looping - } else { - d->triggerMainEvent(); - } - - while (d->mainSync && !d->m_shutdown) - d->wait(); - - d->unlock(); -} - -void QDeclarativeThread::internalPostMethodToThread(Message *message) -{ - Q_ASSERT(!isThisThread()); - d->lock(); - bool wasEmpty = d->threadList.isEmpty(); - d->threadList.append(message); - if (wasEmpty && d->m_threadProcessing == false) - d->triggerThreadEvent(); - d->unlock(); -} - -void QDeclarativeThread::internalPostMethodToMain(Message *message) -{ - Q_ASSERT(isThisThread()); - d->lock(); - bool wasEmpty = d->mainList.isEmpty(); - d->mainList.append(message); - if (wasEmpty && d->m_mainProcessing == false) - d->triggerMainEvent(); - d->unlock(); -} - -QT_END_NAMESPACE diff --git a/src/declarative/qml/ftw/qdeclarativethread_p.h b/src/declarative/qml/ftw/qdeclarativethread_p.h deleted file mode 100644 index ce9eb1d88f..0000000000 --- a/src/declarative/qml/ftw/qdeclarativethread_p.h +++ /dev/null @@ -1,318 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QDECLARATIVETHREAD_P_H -#define QDECLARATIVETHREAD_P_H - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists purely as an -// implementation detail. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - - -#include - -#include - -QT_BEGIN_NAMESPACE - -class QThread; - -class QDeclarativeThreadPrivate; -class QDeclarativeThread -{ -public: - QDeclarativeThread(); - virtual ~QDeclarativeThread(); - void shutdown(); - - void lock(); - void unlock(); - void wakeOne(); - void wakeAll(); - void wait(); - - QThread *thread() const; - bool isThisThread() const; - - // Synchronously invoke a method in the thread - template - inline void callMethodInThread(void (O::*Member)()); - template - inline void callMethodInThread(void (O::*Member)(V), const T &); - template - inline void callMethodInThread(void (O::*Member)(V, V2), const T &, const T2 &); - - // Synchronously invoke a method in the main thread. If the main thread is - // blocked in a callMethodInThread() call, the call is made from within that - // call. - template - inline void callMethodInMain(void (O::*Member)()); - template - inline void callMethodInMain(void (O::*Member)(V), const T &); - template - inline void callMethodInMain(void (O::*Member)(V, V2), const T &, const T2 &); - - // Asynchronously invoke a method in the thread. - template - inline void postMethodToThread(void (O::*Member)()); - template - inline void postMethodToThread(void (O::*Member)(V), const T &); - template - inline void postMethodToThread(void (O::*Member)(V, V2), const T &, const T2 &); - - // Asynchronously invoke a method in the main thread. - template - inline void postMethodToMain(void (O::*Member)()); - template - inline void postMethodToMain(void (O::*Member)(V), const T &); - template - inline void postMethodToMain(void (O::*Member)(V, V2), const T &, const T2 &); - -protected: - virtual void startupThread(); - virtual void shutdownThread(); - -private: - friend class QDeclarativeThreadPrivate; - - struct Message { - Message() : next(0) {} - virtual ~Message() {} - Message *next; - virtual void call(QDeclarativeThread *) = 0; - }; - void internalCallMethodInThread(Message *); - void internalCallMethodInMain(Message *); - void internalPostMethodToThread(Message *); - void internalPostMethodToMain(Message *); - QDeclarativeThreadPrivate *d; -}; - -template -void QDeclarativeThread::callMethodInThread(void (O::*Member)()) -{ - struct I : public Message { - void (O::*Member)(); - I(void (O::*Member)()) : Member(Member) {} - virtual void call(QDeclarativeThread *thread) { - O *me = static_cast(thread); - (me->*Member)(); - } - }; - internalCallMethodInThread(new I(Member)); -} - -template -void QDeclarativeThread::callMethodInThread(void (O::*Member)(V), const T &arg) -{ - struct I : public Message { - void (O::*Member)(V); - T arg; - I(void (O::*Member)(V), const T &arg) : Member(Member), arg(arg) {} - virtual void call(QDeclarativeThread *thread) { - O *me = static_cast(thread); - (me->*Member)(arg); - } - }; - internalCallMethodInThread(new I(Member, arg)); -} - -template -void QDeclarativeThread::callMethodInThread(void (O::*Member)(V, V2), const T &arg, const T2 &arg2) -{ - struct I : public Message { - void (O::*Member)(V, V2); - T arg; - T2 arg2; - I(void (O::*Member)(V, V2), const T &arg, const T2 &arg2) : Member(Member), arg(arg), arg2(arg2) {} - virtual void call(QDeclarativeThread *thread) { - O *me = static_cast(thread); - (me->*Member)(arg, arg2); - } - }; - internalCallMethodInThread(new I(Member, arg, arg2)); -} - -template -void QDeclarativeThread::callMethodInMain(void (O::*Member)()) -{ - struct I : public Message { - void (O::*Member)(); - I(void (O::*Member)()) : Member(Member) {} - virtual void call(QDeclarativeThread *thread) { - O *me = static_cast(thread); - (me->*Member)(); - } - }; - internalCallMethodInMain(new I(Member)); -} - -template -void QDeclarativeThread::callMethodInMain(void (O::*Member)(V), const T &arg) -{ - struct I : public Message { - void (O::*Member)(V); - T arg; - I(void (O::*Member)(V), const T &arg) : Member(Member), arg(arg) {} - virtual void call(QDeclarativeThread *thread) { - O *me = static_cast(thread); - (me->*Member)(arg); - } - }; - internalCallMethodInMain(new I(Member, arg)); -} - -template -void QDeclarativeThread::callMethodInMain(void (O::*Member)(V, V2), const T &arg, const T2 &arg2) -{ - struct I : public Message { - void (O::*Member)(V, V2); - T arg; - T2 arg2; - I(void (O::*Member)(V, V2), const T &arg, const T2 &arg2) : Member(Member), arg(arg), arg2(arg2) {} - virtual void call(QDeclarativeThread *thread) { - O *me = static_cast(thread); - (me->*Member)(arg, arg2); - } - }; - internalCallMethodInMain(new I(Member, arg, arg2)); -} - -template -void QDeclarativeThread::postMethodToThread(void (O::*Member)()) -{ - struct I : public Message { - void (O::*Member)(); - I(void (O::*Member)()) : Member(Member) {} - virtual void call(QDeclarativeThread *thread) { - O *me = static_cast(thread); - (me->*Member)(); - } - }; - internalPostMethodToThread(new I(Member)); -} - -template -void QDeclarativeThread::postMethodToThread(void (O::*Member)(V), const T &arg) -{ - struct I : public Message { - void (O::*Member)(V); - T arg; - I(void (O::*Member)(V), const T &arg) : Member(Member), arg(arg) {} - virtual void call(QDeclarativeThread *thread) { - O *me = static_cast(thread); - (me->*Member)(arg); - } - }; - internalPostMethodToThread(new I(Member, arg)); -} - -template -void QDeclarativeThread::postMethodToThread(void (O::*Member)(V, V2), const T &arg, const T2 &arg2) -{ - struct I : public Message { - void (O::*Member)(V, V2); - T arg; - T2 arg2; - I(void (O::*Member)(V, V2), const T &arg, const T2 &arg2) : Member(Member), arg(arg), arg2(arg2) {} - virtual void call(QDeclarativeThread *thread) { - O *me = static_cast(thread); - (me->*Member)(arg, arg2); - } - }; - internalPostMethodToThread(new I(Member, arg, arg2)); -} - -template -void QDeclarativeThread::postMethodToMain(void (O::*Member)()) -{ - struct I : public Message { - void (O::*Member)(); - I(void (O::*Member)()) : Member(Member) {} - virtual void call(QDeclarativeThread *thread) { - O *me = static_cast(thread); - (me->*Member)(); - } - }; - internalPostMethodToMain(new I(Member)); -} - -template -void QDeclarativeThread::postMethodToMain(void (O::*Member)(V), const T &arg) -{ - struct I : public Message { - void (O::*Member)(V); - T arg; - I(void (O::*Member)(V), const T &arg) : Member(Member), arg(arg) {} - virtual void call(QDeclarativeThread *thread) { - O *me = static_cast(thread); - (me->*Member)(arg); - } - }; - internalPostMethodToMain(new I(Member, arg)); -} - -template -void QDeclarativeThread::postMethodToMain(void (O::*Member)(V, V2), const T &arg, const T2 &arg2) -{ - struct I : public Message { - void (O::*Member)(V, V2); - T arg; - T2 arg2; - I(void (O::*Member)(V, V2), const T &arg, const T2 &arg2) : Member(Member), arg(arg), arg2(arg2) {} - virtual void call(QDeclarativeThread *thread) { - O *me = static_cast(thread); - (me->*Member)(arg, arg2); - } - }; - internalPostMethodToMain(new I(Member, arg, arg2)); -} - -QT_END_NAMESPACE - -#endif // QDECLARATIVETHREAD_P_H diff --git a/src/declarative/qml/ftw/qdeclarativetrace.cpp b/src/declarative/qml/ftw/qdeclarativetrace.cpp deleted file mode 100644 index 7c814e37c1..0000000000 --- a/src/declarative/qml/ftw/qdeclarativetrace.cpp +++ /dev/null @@ -1,154 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qdeclarativetrace_p.h" - -#ifdef QML_ENABLE_TRACE -#include -#endif - -QT_BEGIN_NAMESPACE - -#ifdef QML_ENABLE_TRACE - -QDeclarativeTrace::Pool QDeclarativeTrace::logPool; -QDeclarativeTrace::Entry *QDeclarativeTrace::first = 0; -QDeclarativeTrace::Entry *QDeclarativeTrace::last = 0; - -static qint64 toNsecs(QDeclarativeTrace::TimeType time) -{ -#ifdef Q_OS_MAC - static mach_timebase_info_data_t info = {0,0}; - if (info.denom == 0) - mach_timebase_info(&info); - return time * info.numer / info.denom; -#else - qint64 rv = time.tv_sec * 1000000000 + time.tv_nsec; - return rv; -#endif -} - -QDeclarativeTrace::Pool::Pool() -{ - first = New(); - last = first; -} - -QDeclarativeTrace::Pool::~Pool() -{ - char buffer[128]; - sprintf(buffer, "qml.%d.log", ::getpid()); - FILE *out = fopen(buffer, "w"); - if (!out) { - fprintf (stderr, "QML Log: Could not open %s\n", buffer); - return; - } else { - fprintf (stderr, "QML Log: Writing log to %s\n", buffer); - } - - QDeclarativeTrace::Entry *cur = QDeclarativeTrace::first; - QByteArray indent; - int depth = -1; - - qint64 firstTime = -1; - - while (cur) { - - switch (cur->type) { - case QDeclarativeTrace::Entry::RangeStart: { - RangeStart *rs = static_cast(cur); - - qint64 nsecs = toNsecs(rs->time); - - if (firstTime == -1) - firstTime = nsecs; - - nsecs -= firstTime; - - depth++; - indent = QByteArray(depth * 4, ' '); - fprintf(out, "%s%s @%lld (%lld ns)\n", indent.constData(), - rs->description, nsecs, toNsecs(rs->end->time) - nsecs - firstTime); - } break; - case QDeclarativeTrace::Entry::RangeEnd: - depth--; - indent = QByteArray(depth * 4, ' '); - break; - case QDeclarativeTrace::Entry::Detail: - fprintf(out, "%s %s\n", indent.constData(), - static_cast(cur)->description); - break; - case QDeclarativeTrace::Entry::IntDetail: - fprintf(out, "%s %s: %d\n", indent.constData(), - static_cast(cur)->description, - static_cast(cur)->value); - break; - case QDeclarativeTrace::Entry::StringDetail: { - QByteArray vLatin1 = static_cast(cur)->value->toLatin1(); - fprintf(out, "%s %s: %s\n", indent.constData(), - static_cast(cur)->description, - vLatin1.constData()); - } break; - case QDeclarativeTrace::Entry::UrlDetail: { - QByteArray vLatin1 = static_cast(cur)->value->toString().toLatin1(); - fprintf(out, "%s %s: %s\n", indent.constData(), - static_cast(cur)->description, - vLatin1.constData()); - } break; - case QDeclarativeTrace::Entry::Event: { - Event *ev = static_cast(cur); - qint64 nsecs = toNsecs(ev->time) - firstTime; - fprintf(out, "%s + %s @%lld +%lld ns\n", indent.constData(), - ev->description, nsecs, nsecs - (toNsecs(ev->start->time) - firstTime)); - } break; - case QDeclarativeTrace::Entry::Null: - default: - break; - } - cur = cur->next; - } - fclose(out); -} - -#endif - -QT_END_NAMESPACE - diff --git a/src/declarative/qml/ftw/qdeclarativetrace_p.h b/src/declarative/qml/ftw/qdeclarativetrace_p.h deleted file mode 100644 index 89ed26e925..0000000000 --- a/src/declarative/qml/ftw/qdeclarativetrace_p.h +++ /dev/null @@ -1,294 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QDECLARATIVETRACE_P_H -#define QDECLARATIVETRACE_P_H - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists purely as an -// implementation detail. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - -#include -#include - -// #define QML_ENABLE_TRACE - -#if defined(QML_ENABLE_TRACE) && defined(Q_OS_MAC) -#include -#endif - -QT_BEGIN_NAMESPACE - -class QUrl; -class QDeclarativeTrace -{ -public: - inline QDeclarativeTrace(const char *desc); - inline ~QDeclarativeTrace(); - - inline void addDetail(const char *); - inline void addDetail(const char *, int); - inline void addDetail(const char *, const QString &); - inline void addDetail(const char *, const QUrl &); - - inline void event(const char *desc); - -#ifdef QML_ENABLE_TRACE - -#ifdef Q_OS_MAC - typedef uint64_t TimeType; -#else - typedef timespec TimeType; -#endif - - struct Entry : public QDeclarativePool::POD { - enum Type { Null, RangeStart, RangeEnd, Detail, IntDetail, StringDetail, UrlDetail, Event }; - inline Entry(); - inline Entry(Type); - Type type; - Entry *next; - }; - struct RangeEnd : public Entry { - inline RangeEnd(); - TimeType time; - }; - struct RangeStart : public Entry { - inline RangeStart(); - const char *description; - TimeType time; - QDeclarativeTrace::RangeEnd *end; - }; - struct Detail : public Entry { - inline Detail(); - inline Detail(Type t); - const char *description; - }; - struct IntDetail : public Detail { - inline IntDetail(); - int value; - }; - struct StringDetail : public Detail { - inline StringDetail(); - QString *value; - }; - struct UrlDetail : public Detail { - inline UrlDetail(); - QUrl *value; - }; - struct Event : public Entry { - inline Event(); - const char *description; - TimeType time; - QDeclarativeTrace::RangeStart *start; - }; - - struct Pool : public QDeclarativePool { - Pool(); - ~Pool(); - }; - - static Pool logPool; - static Entry *first; - static Entry *last; - -private: - RangeStart *start; - - static TimeType gettime() { -#ifdef Q_OS_MAC - return mach_absolute_time(); -#else - TimeType ts; - clock_gettime(CLOCK_MONOTONIC, &ts); - return ts; -#endif - } -#endif -}; - -#ifdef QML_ENABLE_TRACE -QDeclarativeTrace::Entry::Entry() -: type(Null), next(0) -{ -} - -QDeclarativeTrace::Entry::Entry(Type type) -: type(type), next(0) -{ - QDeclarativeTrace::last->next = this; - QDeclarativeTrace::last = this; -} - -QDeclarativeTrace::RangeEnd::RangeEnd() -: QDeclarativeTrace::Entry(QDeclarativeTrace::Entry::RangeEnd), - time(gettime()) -{ -} - -QDeclarativeTrace::RangeStart::RangeStart() -: QDeclarativeTrace::Entry(QDeclarativeTrace::Entry::RangeStart), - description(0), time(gettime()) -{ -} - -QDeclarativeTrace::Detail::Detail() -: QDeclarativeTrace::Entry(QDeclarativeTrace::Entry::Detail), - description(0) -{ -} - -QDeclarativeTrace::Detail::Detail(Type type) -: QDeclarativeTrace::Entry(type), description(0) -{ -} - -QDeclarativeTrace::IntDetail::IntDetail() -: QDeclarativeTrace::Detail(QDeclarativeTrace::Entry::IntDetail), - value(0) -{ -} - -QDeclarativeTrace::StringDetail::StringDetail() -: QDeclarativeTrace::Detail(QDeclarativeTrace::Entry::StringDetail), - value(0) -{ -} - -QDeclarativeTrace::UrlDetail::UrlDetail() -: QDeclarativeTrace::Detail(QDeclarativeTrace::Entry::UrlDetail), - value(0) -{ -} - -QDeclarativeTrace::Event::Event() -: QDeclarativeTrace::Entry(QDeclarativeTrace::Entry::Event), - description(0), time(gettime()), start(0) -{ -} -#endif - -QDeclarativeTrace::QDeclarativeTrace(const char *desc) -{ -#ifdef QML_ENABLE_TRACE - RangeStart *e = logPool.New(); - e->description = desc; - e->end = 0; - start = e; -#else - Q_UNUSED(desc); -#endif -} - -QDeclarativeTrace::~QDeclarativeTrace() -{ -#ifdef QML_ENABLE_TRACE - RangeEnd *e = logPool.New(); - start->end = e; -#endif -} - -void QDeclarativeTrace::addDetail(const char *desc) -{ -#ifdef QML_ENABLE_TRACE - Detail *e = logPool.New(); - e->description = desc; -#else - Q_UNUSED(desc); -#endif -} - -void QDeclarativeTrace::addDetail(const char *desc, int v) -{ -#ifdef QML_ENABLE_TRACE - IntDetail *e = logPool.New(); - e->description = desc; - e->value = v; -#else - Q_UNUSED(desc); - Q_UNUSED(v); -#endif -} - -void QDeclarativeTrace::addDetail(const char *desc, const QString &v) -{ -#ifdef QML_ENABLE_TRACE - StringDetail *e = logPool.New(); - e->description = desc; - e->value = logPool.NewString(v); -#else - Q_UNUSED(desc); - Q_UNUSED(v); -#endif -} - -void QDeclarativeTrace::addDetail(const char *desc, const QUrl &v) -{ -#ifdef QML_ENABLE_TRACE - UrlDetail *e = logPool.New(); - e->description = desc; - e->value = logPool.NewUrl(v); -#else - Q_UNUSED(desc); - Q_UNUSED(v); -#endif -} - -void QDeclarativeTrace::event(const char *desc) -{ -#ifdef QML_ENABLE_TRACE - Event *e = logPool.New(); - e->start = start; - e->description = desc; -#else - Q_UNUSED(desc); -#endif -} - -QT_END_NAMESPACE - -#endif // QDECLARATIVETRACE_P_H diff --git a/src/declarative/qml/ftw/qdeletewatcher_p.h b/src/declarative/qml/ftw/qdeletewatcher_p.h deleted file mode 100644 index 020907aa65..0000000000 --- a/src/declarative/qml/ftw/qdeletewatcher_p.h +++ /dev/null @@ -1,113 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QDELETEWATCHER_P_H -#define QDELETEWATCHER_P_H - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists purely as an -// implementation detail. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - -#include - -QT_BEGIN_NAMESPACE - -class QDeleteWatchable -{ -public: - inline QDeleteWatchable(); - inline ~QDeleteWatchable(); -private: - friend class QDeleteWatcher; - bool *_w; -}; - -class QDeleteWatcher { -public: - inline QDeleteWatcher(QDeleteWatchable *data); - inline ~QDeleteWatcher(); - inline bool wasDeleted() const; -private: - void *operator new(size_t); - bool *_w; - bool _s; - QDeleteWatchable *m_d; -}; - -QDeleteWatchable::QDeleteWatchable() -: _w(0) -{ -} - -QDeleteWatchable::~QDeleteWatchable() -{ - if (_w) *_w = true; -} - -QDeleteWatcher::QDeleteWatcher(QDeleteWatchable *data) -: _s(false), m_d(data) -{ - if (!m_d->_w) - m_d->_w = &_s; - _w = m_d->_w; -} - -QDeleteWatcher::~QDeleteWatcher() -{ - if (false == *_w && &_s == m_d->_w) - m_d->_w = 0; -} - -bool QDeleteWatcher::wasDeleted() const -{ - return *_w; -} - -QT_END_NAMESPACE - -#endif // QDELETEWATCHER_P_H diff --git a/src/declarative/qml/ftw/qfastmetabuilder.cpp b/src/declarative/qml/ftw/qfastmetabuilder.cpp deleted file mode 100644 index 0395ab3309..0000000000 --- a/src/declarative/qml/ftw/qfastmetabuilder.cpp +++ /dev/null @@ -1,369 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qfastmetabuilder_p.h" - -#include - -QT_BEGIN_NAMESPACE - -struct QFastMetaBuilderHeader -{ - int fieldCount; -}; - -struct QMetaObjectPrivate -{ - int revision; - int className; - int classInfoCount, classInfoData; - int methodCount, methodData; - int propertyCount, propertyData; - int enumeratorCount, enumeratorData; - int constructorCount, constructorData; //since revision 2 - int flags; //since revision 3 - int signalCount; //since revision 4 -}; - -enum MetaObjectFlag { - DynamicMetaObject = 0x01 -}; - -enum PropertyFlags { - Invalid = 0x00000000, - Readable = 0x00000001, - Writable = 0x00000002, - Resettable = 0x00000004, - EnumOrFlag = 0x00000008, - StdCppSet = 0x00000100, -// Override = 0x00000200, - Constant = 0x00000400, - Final = 0x00000800, - Designable = 0x00001000, - ResolveDesignable = 0x00002000, - Scriptable = 0x00004000, - ResolveScriptable = 0x00008000, - Stored = 0x00010000, - ResolveStored = 0x00020000, - Editable = 0x00040000, - ResolveEditable = 0x00080000, - User = 0x00100000, - ResolveUser = 0x00200000, - Notify = 0x00400000, - Revisioned = 0x00800000 -}; - -enum MethodFlags { - AccessPrivate = 0x00, - AccessProtected = 0x01, - AccessPublic = 0x02, - AccessMask = 0x03, //mask - - MethodMethod = 0x00, - MethodSignal = 0x04, - MethodSlot = 0x08, - MethodConstructor = 0x0c, - MethodTypeMask = 0x0c, - - MethodCompatibility = 0x10, - MethodCloned = 0x20, - MethodScriptable = 0x40, - MethodRevisioned = 0x80 -}; - -#define FMBHEADER_FIELD_COUNT 1 - -#define HEADER_FIELD_COUNT 14 -#define CLASSINFO_FIELD_COUNT 2 -#define METHOD_FIELD_COUNT 5 -#define PROPERTY_FIELD_COUNT 3 -#define PROPERTY_NOTIFY_FIELD_COUNT 1 - -static inline uint *fieldPointer(QByteArray &data) -{ return reinterpret_cast(data.data()) + FMBHEADER_FIELD_COUNT; } - -static inline const uint *fieldPointer(const QByteArray &data) -{ return reinterpret_cast(data.constData()) + FMBHEADER_FIELD_COUNT; } - -static inline QMetaObjectPrivate *priv(QByteArray &data) -{ return reinterpret_cast(fieldPointer(data)); } - -static inline const QMetaObjectPrivate *priv(const QByteArray &data) -{ return reinterpret_cast(fieldPointer(data)); } - -static inline QFastMetaBuilderHeader *header(QByteArray &data) -{ return reinterpret_cast(data.data()); } - -static inline const QFastMetaBuilderHeader *header(const QByteArray &data) -{ return reinterpret_cast(data.constData()); } - -QFastMetaBuilder::QFastMetaBuilder() -: m_zeroPtr(0), m_stringData(0), m_stringDataLength(0), m_stringDataAllocated(0) -{ -} - -QFastMetaBuilder::~QFastMetaBuilder() -{ -} - -QFastMetaBuilder::StringRef QFastMetaBuilder::init(int classNameLength, - int propertyCount, int methodCount, - int signalCount, int classInfoCount) -{ - Q_ASSERT(m_data.isEmpty()); - Q_ASSERT(classNameLength > 0); - Q_ASSERT(propertyCount >= 0); - Q_ASSERT(methodCount >= 0); - Q_ASSERT(signalCount >= 0); - Q_ASSERT(classInfoCount >= 0); - - int fieldCount = FMBHEADER_FIELD_COUNT + - HEADER_FIELD_COUNT + - propertyCount * (PROPERTY_FIELD_COUNT + PROPERTY_NOTIFY_FIELD_COUNT) + - methodCount * (METHOD_FIELD_COUNT) + - signalCount * (METHOD_FIELD_COUNT) + - classInfoCount * CLASSINFO_FIELD_COUNT; - - m_data.resize(fieldCount * sizeof(uint) + classNameLength + 1); - m_stringData = m_data.data() + m_data.size() - classNameLength - 1; - m_stringDataLength = classNameLength + 1; - m_stringDataAllocated = classNameLength + 1; - m_stringData[classNameLength] = 0; - m_zeroPtr = classNameLength; - - header(m_data)->fieldCount = fieldCount; - - QMetaObjectPrivate *p = priv(m_data); - - int dataIndex = HEADER_FIELD_COUNT; - - p->revision = 4; - p->className = 0; - - // Class infos - p->classInfoCount = classInfoCount; - if (p->classInfoCount) { - p->classInfoData = dataIndex; - dataIndex += p->classInfoCount * CLASSINFO_FIELD_COUNT; - } else { - p->classInfoData = 0; - } - - // Methods - p->methodCount = methodCount + signalCount; - if (p->methodCount) { - p->methodData = dataIndex; - dataIndex += p->methodCount * METHOD_FIELD_COUNT; - } else { - p->methodData = 0; - } - p->signalCount = signalCount; - - // Properties - p->propertyCount = propertyCount; - if (p->propertyCount) { - p->propertyData = dataIndex; - dataIndex += p->propertyCount * (PROPERTY_FIELD_COUNT + PROPERTY_NOTIFY_FIELD_COUNT); - } else { - p->propertyData = 0; - } - - // Flags - p->flags = DynamicMetaObject; // Always dynamic - - // Enums and constructors not supported - p->enumeratorCount = 0; - p->enumeratorData = 0; - p->constructorCount = 0; - p->constructorData = 0; - - StringRef className; - className._b = this; - className._o = 0; - className._l = classNameLength; - return className; -} - -// Allocate a string of \a length. \a length should *not* include the null terminator. -QFastMetaBuilder::StringRef QFastMetaBuilder::newString(int length) -{ - Q_ASSERT(length > 0); - - StringRef sr; - sr._b = this; - sr._o = m_stringDataLength; - sr._l = length; - - m_stringDataLength += length + 1 /* for null terminator */; - - return sr; -} - -void QFastMetaBuilder::setClassInfo(int index, const StringRef &key, const StringRef &value) -{ - Q_ASSERT(!m_data.isEmpty()); - Q_ASSERT(!key.isEmpty() && !value.isEmpty()); - - QMetaObjectPrivate *p = priv(m_data); - Q_ASSERT(index < p->classInfoCount); - - uint *ptr = fieldPointer(m_data) + p->classInfoData + index * CLASSINFO_FIELD_COUNT; - // classinfo: key, value - ptr[0] = key.offset(); ptr[1] = value.offset(); -} - -void QFastMetaBuilder::setProperty(int index, const StringRef &name, const StringRef &type, - QMetaType::Type mtype, PropertyFlag flags, int notifySignal) -{ - Q_ASSERT(!m_data.isEmpty()); - Q_ASSERT(!name.isEmpty() && !type.isEmpty()); - - QMetaObjectPrivate *p = priv(m_data); - Q_ASSERT(index < p->propertyCount); - - uint *ptr = fieldPointer(m_data) + p->propertyData + index * PROPERTY_FIELD_COUNT; - // properties: name, type, flags - ptr[0] = name.offset(); - ptr[1] = type.offset(); - if (notifySignal == -1) { - ptr[2] = mtype << 24; - ptr[2] |= flags | Scriptable | Readable; - *(fieldPointer(m_data) + p->propertyData + p->propertyCount * PROPERTY_FIELD_COUNT + index) = 0; - } else { - ptr[2] = mtype << 24; - ptr[2] |= flags | Scriptable | Readable | Notify; - *(fieldPointer(m_data) + p->propertyData + p->propertyCount * PROPERTY_FIELD_COUNT + index) = notifySignal; - } -} - -void QFastMetaBuilder::setProperty(int index, const StringRef &name, const StringRef &type, - QFastMetaBuilder::PropertyFlag flags, int notifySignal) -{ - Q_ASSERT(!m_data.isEmpty()); - Q_ASSERT(!name.isEmpty() && !type.isEmpty()); - - QMetaObjectPrivate *p = priv(m_data); - Q_ASSERT(index < p->propertyCount); - - uint *ptr = fieldPointer(m_data) + p->propertyData + index * PROPERTY_FIELD_COUNT; - // properties: name, type, flags - ptr[0] = name.offset(); - ptr[1] = type.offset(); - if (notifySignal == -1) { - ptr[2] = flags | Scriptable | Readable; - *(fieldPointer(m_data) + p->propertyData + p->propertyCount * PROPERTY_FIELD_COUNT + index) = 0; - } else { - ptr[2] = flags | Scriptable | Readable | Notify; - *(fieldPointer(m_data) + p->propertyData + p->propertyCount * PROPERTY_FIELD_COUNT + index) = notifySignal; - } -} - -void QFastMetaBuilder::setSignal(int index, const StringRef &signature, - const StringRef ¶meterNames, - const StringRef &type) -{ - Q_ASSERT(!m_data.isEmpty()); - Q_ASSERT(!signature.isEmpty()); - - QMetaObjectPrivate *p = priv(m_data); - int mindex = metaObjectIndexForSignal(index); - - uint *ptr = fieldPointer(m_data) + p->methodData + mindex * METHOD_FIELD_COUNT; - // methods: signature, parameters, type, tag, flags - ptr[0] = signature.offset(); - ptr[1] = parameterNames.isEmpty()?m_zeroPtr:parameterNames.offset(); - ptr[2] = type.isEmpty()?m_zeroPtr:type.offset(); - ptr[3] = m_zeroPtr; - ptr[4] = AccessProtected | MethodSignal; -} - -void QFastMetaBuilder::setMethod(int index, const StringRef &signature, - const StringRef ¶meterNames, - const StringRef &type) -{ - Q_ASSERT(!m_data.isEmpty()); - Q_ASSERT(!signature.isEmpty()); - - QMetaObjectPrivate *p = priv(m_data); - int mindex = metaObjectIndexForMethod(index); - - uint *ptr = fieldPointer(m_data) + p->methodData + mindex * METHOD_FIELD_COUNT; - // methods: signature, parameters, type, tag, flags - ptr[0] = signature.offset(); - ptr[1] = parameterNames.isEmpty()?m_zeroPtr:parameterNames.offset(); - ptr[2] = type.isEmpty()?m_zeroPtr:type.offset(); - ptr[3] = m_zeroPtr; - ptr[4] = AccessProtected | MethodSlot; -} - -int QFastMetaBuilder::metaObjectIndexForSignal(int index) const -{ - Q_ASSERT(!m_data.isEmpty()); - Q_ASSERT(index < priv(m_data)->signalCount); - return index; -} - -int QFastMetaBuilder::metaObjectIndexForMethod(int index) const -{ - Q_ASSERT(!m_data.isEmpty()); - - const QMetaObjectPrivate *p = priv(m_data); - Q_ASSERT(index < (p->methodCount - p->signalCount)); - return index + p->signalCount; -} - -void QFastMetaBuilder::allocateStringData() -{ - if (m_stringDataAllocated < m_stringDataLength) { - m_data.resize(m_data.size() + m_stringDataLength - m_stringDataAllocated); - m_stringDataAllocated = m_stringDataLength; - m_stringData = m_data.data() + header(m_data)->fieldCount * sizeof(uint); - } -} - -void QFastMetaBuilder::fromData(QMetaObject *output, const QMetaObject *parent, const QByteArray &data) -{ - output->d.superdata = parent; - output->d.stringdata = data.constData() + header(data)->fieldCount * sizeof(uint); - output->d.data = fieldPointer(data); -} - -QT_END_NAMESPACE diff --git a/src/declarative/qml/ftw/qfastmetabuilder_p.h b/src/declarative/qml/ftw/qfastmetabuilder_p.h deleted file mode 100644 index e8b7394fe4..0000000000 --- a/src/declarative/qml/ftw/qfastmetabuilder_p.h +++ /dev/null @@ -1,206 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QFASTMETABUILDER_P_H -#define QFASTMETABUILDER_P_H - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists for the convenience -// of moc. This header file may change from version to version without notice, -// or even be removed. -// -// We mean it. -// - -#include -#include -#include - -#include - -QT_BEGIN_NAMESPACE - -struct QMetaObject; -class QFastMetaBuilder -{ -public: - QFastMetaBuilder(); - ~QFastMetaBuilder(); - - struct StringRef { - public: - inline StringRef(); - inline StringRef(const StringRef &); - inline StringRef &operator=(const StringRef &); - - inline void load(const QHashedStringRef &); - inline void load(const QByteArray &); - inline void load(const char *); - - inline bool isEmpty() const; - inline QFastMetaBuilder *builder() const; - inline int offset() const; - inline char *data(); - inline int length() const; - private: - friend class QFastMetaBuilder; - - QFastMetaBuilder *_b; - int _o; - int _l; - }; - StringRef newString(int length); - - // Returns class name - StringRef init(int classNameLength, - int propertyCount, int methodCount, - int signalCount, int classInfoCount); - - void setClassInfo(int index, const StringRef &key, const StringRef &value); - - enum PropertyFlag { - None = 0x00000000, - Writable = 0x00000002, - Resettable = 0x00000004, - Constant = 0x00000400, - Final = 0x00000800 - }; - // void setProperty(int index, const StringRef &name, QMetaType::Type type, int notifySignal = -1); - void setProperty(int index, const StringRef &name, const StringRef &type, - QMetaType::Type mtype, PropertyFlag flags, int notifySignal = -1); - void setProperty(int index, const StringRef &name, const StringRef &type, - PropertyFlag flags, int notifySignal = -1); - void setMethod(int index, const StringRef &signature, - const StringRef ¶meterNames = StringRef(), - const StringRef &type = StringRef()); - void setSignal(int index, const StringRef &signature, - const StringRef ¶meterNames = StringRef(), - const StringRef &type = StringRef()); - - int metaObjectIndexForSignal(int) const; - int metaObjectIndexForMethod(int) const; - - QByteArray toData() const { return m_data; } - static void fromData(QMetaObject *, const QMetaObject *parent, const QByteArray &); -private: - friend struct StringRef; - - QByteArray m_data; - int m_zeroPtr; - - void allocateStringData(); - char *m_stringData; - int m_stringDataLength; - int m_stringDataAllocated; -}; - -QFastMetaBuilder::StringRef::StringRef() -: _b(0), _o(0), _l(0) -{ -} - -QFastMetaBuilder::StringRef::StringRef(const StringRef &o) -: _b(o._b), _o(o._o), _l(o._l) -{ -} - -QFastMetaBuilder::StringRef &QFastMetaBuilder::StringRef::operator=(const StringRef &o) -{ - _b = o._b; - _o = o._o; - _l = o._l; - return *this; -} - -bool QFastMetaBuilder::StringRef::isEmpty() const -{ - return _l == 0; -} - -QFastMetaBuilder *QFastMetaBuilder::StringRef::builder() const -{ - return _b; -} - -int QFastMetaBuilder::StringRef::offset() const -{ - return _o; -} - -char *QFastMetaBuilder::StringRef::data() -{ - Q_ASSERT(_b); - if (_b->m_stringDataLength != _b->m_stringDataAllocated) - _b->allocateStringData(); - return _b->m_stringData + _o; -} - -int QFastMetaBuilder::StringRef::length() const -{ - return _l; -} - -void QFastMetaBuilder::StringRef::load(const QHashedStringRef &str) -{ - Q_ASSERT(str.utf8length() == _l); - str.writeUtf8(data()); - *(data() + _l) = 0; -} - -void QFastMetaBuilder::StringRef::load(const QByteArray &str) -{ - Q_ASSERT(str.length() == _l); - strcpy(data(), str.constData()); -} - -void QFastMetaBuilder::StringRef::load(const char *str) -{ - Q_ASSERT(strlen(str) == (uint)_l); - strcpy(data(), str); -} - -QT_END_NAMESPACE - -#endif // QFASTMETABUILDER_P_H - diff --git a/src/declarative/qml/ftw/qfieldlist_p.h b/src/declarative/qml/ftw/qfieldlist_p.h deleted file mode 100644 index 4253779e78..0000000000 --- a/src/declarative/qml/ftw/qfieldlist_p.h +++ /dev/null @@ -1,426 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QFIELDLIST_P_H -#define QFIELDLIST_P_H - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists purely as an -// implementation detail. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - -#include - -#include - -// QForwardFieldList is a super simple linked list that can only prepend -template -class QForwardFieldList -{ -public: - inline QForwardFieldList(); - inline N *first() const; - inline N *takeFirst(); - - inline void prepend(N *); - - inline bool isEmpty() const; - inline bool isOne() const; - inline bool isMany() const; - - static inline N *next(N *v); - - inline bool flag() const; - inline void setFlag(); - inline void clearFlag(); - inline void setFlagValue(bool); - - inline bool flag2() const; - inline void setFlag2(); - inline void clearFlag2(); - inline void setFlag2Value(bool); -private: - QFlagPointer _first; -}; - -// QFieldList is a simple linked list, that can append and prepend and also -// maintains a count -template -class QFieldList -{ -public: - inline QFieldList(); - inline N *first() const; - inline N *takeFirst(); - - inline void append(N *); - inline void prepend(N *); - - inline bool isEmpty() const; - inline bool isOne() const; - inline bool isMany() const; - inline int count() const; - - inline void append(QFieldList &); - inline void prepend(QFieldList &); - inline void insertAfter(N *, QFieldList &); - - inline void copyAndClear(QFieldList &); - inline void copyAndClearAppend(QForwardFieldList &); - inline void copyAndClearPrepend(QForwardFieldList &); - - static inline N *next(N *v); - - inline bool flag() const; - inline void setFlag(); - inline void clearFlag(); - inline void setFlagValue(bool); -private: - N *_first; - N *_last; - quint32 _flag:1; - quint32 _count:31; -}; - -template -QForwardFieldList::QForwardFieldList() -{ -} - -template -N *QForwardFieldList::first() const -{ - return *_first; -} - -template -N *QForwardFieldList::takeFirst() -{ - N *value = *_first; - if (value) { - _first = next(value); - value->*nextMember = 0; - } - return value; -} - -template -void QForwardFieldList::prepend(N *v) -{ - Q_ASSERT(v->*nextMember == 0); - v->*nextMember = *_first; - _first = v; -} - -template -bool QForwardFieldList::isEmpty() const -{ - return _first.isNull(); -} - -template -bool QForwardFieldList::isOne() const -{ - return *_first && _first->*nextMember == 0; -} - -template -bool QForwardFieldList::isMany() const -{ - return *_first && _first->*nextMember != 0; -} - -template -N *QForwardFieldList::next(N *v) -{ - Q_ASSERT(v); - return v->*nextMember; -} - -template -bool QForwardFieldList::flag() const -{ - return _first.flag(); -} - -template -void QForwardFieldList::setFlag() -{ - _first.setFlag(); -} - -template -void QForwardFieldList::clearFlag() -{ - _first.clearFlag(); -} - -template -void QForwardFieldList::setFlagValue(bool v) -{ - _first.setFlagValue(v); -} - -template -bool QForwardFieldList::flag2() const -{ - return _first.flag2(); -} - -template -void QForwardFieldList::setFlag2() -{ - _first.setFlag2(); -} - -template -void QForwardFieldList::clearFlag2() -{ - _first.clearFlag2(); -} - -template -void QForwardFieldList::setFlag2Value(bool v) -{ - _first.setFlag2Value(v); -} - -template -QFieldList::QFieldList() -: _first(0), _last(0), _flag(0), _count(0) -{ -} - -template -N *QFieldList::first() const -{ - return _first; -} - -template -N *QFieldList::takeFirst() -{ - N *value = _first; - if (value) { - _first = next(value); - if (_last == value) { - Q_ASSERT(_first == 0); - _last = 0; - } - value->*nextMember = 0; - --_count; - } - return value; -} - -template -void QFieldList::append(N *v) -{ - Q_ASSERT(v->*nextMember == 0); - if (isEmpty()) { - _first = v; - _last = v; - } else { - _last->*nextMember = v; - _last = v; - } - ++_count; -} - -template -void QFieldList::prepend(N *v) -{ - Q_ASSERT(v->*nextMember == 0); - if (isEmpty()) { - _first = v; - _last = v; - } else { - v->*nextMember = _first; - _first = v; - } - ++_count; -} - -template -bool QFieldList::isEmpty() const -{ - return _count == 0; -} - -template -bool QFieldList::isOne() const -{ - return _count == 1; -} - -template -bool QFieldList::isMany() const -{ - return _count > 1; -} - -template -int QFieldList::count() const -{ - return _count; -} - -template -N *QFieldList::next(N *v) -{ - Q_ASSERT(v); - return v->*nextMember; -} - -template -void QFieldList::append(QFieldList &o) -{ - if (!o.isEmpty()) { - if (isEmpty()) { - _first = o._first; - _last = o._last; - _count = o._count; - } else { - _last->*nextMember = o._first; - _last = o._last; - _count += o._count; - } - o._first = o._last = 0; o._count = 0; - } -} - -template -void QFieldList::prepend(QFieldList &o) -{ - if (!o.isEmpty()) { - if (isEmpty()) { - _first = o._first; - _last = o._last; - _count = o._count; - } else { - o._last->*nextMember = _first; - _first = o._first; - _count += o._count; - } - o._first = o._last = 0; o._count = 0; - } -} - -template -void QFieldList::insertAfter(N *after, QFieldList &o) -{ - if (after == 0) { - prepend(o); - } else if (after == _last) { - append(o); - } else if (!o.isEmpty()) { - if (isEmpty()) { - _first = o._first; - _last = o._last; - _count = o._count; - } else { - o._last->*nextMember = after->*nextMember; - after->*nextMember = o._first; - _count += o._count; - } - o._first = o._last = 0; o._count = 0; - } -} - -template -void QFieldList::copyAndClear(QFieldList &o) -{ - _first = o._first; - _last = o._last; - _count = o._count; - o._first = o._last = 0; - o._count = 0; -} - -template -void QFieldList::copyAndClearAppend(QForwardFieldList &o) -{ - _first = 0; - _last = 0; - _count = 0; - while (N *n = o.takeFirst()) append(n); -} - -template -void QFieldList::copyAndClearPrepend(QForwardFieldList &o) -{ - _first = 0; - _last = 0; - _count = 0; - while (N *n = o.takeFirst()) prepend(n); -} - -template -bool QFieldList::flag() const -{ - return _flag; -} - -template -void QFieldList::setFlag() -{ - _flag = true; -} - -template -void QFieldList::clearFlag() -{ - _flag = false; -} - -template -void QFieldList::setFlagValue(bool v) -{ - _flag = v; -} - -#endif // QFIELDLIST_P_H diff --git a/src/declarative/qml/ftw/qfinitestack_p.h b/src/declarative/qml/ftw/qfinitestack_p.h deleted file mode 100644 index 8161b042c2..0000000000 --- a/src/declarative/qml/ftw/qfinitestack_p.h +++ /dev/null @@ -1,186 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QFINITESTACK_P_H -#define QFINITESTACK_P_H - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists purely as an -// implementation detail. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - -#include - -QT_BEGIN_NAMESPACE - -template -struct QFiniteStack { - inline QFiniteStack(); - inline ~QFiniteStack(); - - inline void deallocate(); - inline void allocate(int size); - - inline bool isEmpty() const; - inline const T &top() const; - inline T &top(); - inline void push(const T &o); - inline T pop(); - inline int count() const; - inline const T &at(int index) const; - inline T &operator[](int index); -private: - T *_array; - int _alloc; - int _size; -}; - -template -QFiniteStack::QFiniteStack() -: _array(0), _alloc(0), _size(0) -{ -} - -template -QFiniteStack::~QFiniteStack() -{ - deallocate(); -} - -template -bool QFiniteStack::isEmpty() const -{ - return _size == 0; -} - -template -const T &QFiniteStack::top() const -{ - return _array[_size - 1]; -} - -template -T &QFiniteStack::top() -{ - return _array[_size - 1]; -} - -template -void QFiniteStack::push(const T &o) -{ - if (QTypeInfo::isComplex) { - new (_array + _size++) T(o); - } else { - _array[_size++] = o; - } -} - -template -T QFiniteStack::pop() -{ - --_size; - - if (QTypeInfo::isComplex) { - T rv = _array[_size]; - (_array + _size)->~T(); - return rv; - } else { - return _array[_size]; - } -} - -template -int QFiniteStack::count() const -{ - return _size; -} - -template -const T &QFiniteStack::at(int index) const -{ - return _array[index]; -} - -template -T &QFiniteStack::operator[](int index) -{ - return _array[index]; -} - -template -void QFiniteStack::allocate(int size) -{ - Q_ASSERT(_array == 0); - Q_ASSERT(_alloc == 0); - Q_ASSERT(_size == 0); - - if (!size) return; - - _array = (T *)qMalloc(size * sizeof(T)); - _alloc = size; -} - -template -void QFiniteStack::deallocate() -{ - if (QTypeInfo::isComplex) { - T *i = _array + _size; - while (i != _array) - (--i)->~T(); - } - - qFree(_array); - - _array = 0; - _alloc = 0; - _size = 0; -} - -QT_END_NAMESPACE - -#endif // QFINITESTACK_P_H - diff --git a/src/declarative/qml/ftw/qflagpointer_p.h b/src/declarative/qml/ftw/qflagpointer_p.h deleted file mode 100644 index ac462cbe30..0000000000 --- a/src/declarative/qml/ftw/qflagpointer_p.h +++ /dev/null @@ -1,338 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QFLAGPOINTER_P_H -#define QFLAGPOINTER_P_H - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists purely as an -// implementation detail. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - -#include - -QT_BEGIN_NAMESPACE - -template -class QFlagPointer { -public: - inline QFlagPointer(); - inline QFlagPointer(T *); - inline QFlagPointer(const QFlagPointer &o); - - inline bool isNull() const; - - inline bool flag() const; - inline void setFlag(); - inline void clearFlag(); - inline void setFlagValue(bool); - - inline bool flag2() const; - inline void setFlag2(); - inline void clearFlag2(); - inline void setFlag2Value(bool); - - inline QFlagPointer &operator=(const QFlagPointer &o); - inline QFlagPointer &operator=(T *); - - inline T *operator->() const; - inline T *operator*() const; - -private: - quintptr ptr_value; - - static const quintptr FlagBit = 0x1; - static const quintptr Flag2Bit = 0x2; - static const quintptr FlagsMask = FlagBit | Flag2Bit; -}; - -template -class QBiPointer { -public: - inline QBiPointer(); - inline QBiPointer(T *); - inline QBiPointer(T2 *); - inline QBiPointer(const QBiPointer &o); - - inline bool isNull() const; - inline bool isT1() const; - inline bool isT2() const; - - inline bool flag() const; - inline void setFlag(); - inline void clearFlag(); - inline void setFlagValue(bool); - - inline QBiPointer &operator=(const QBiPointer &o); - inline QBiPointer &operator=(T *); - inline QBiPointer &operator=(T2 *); - - inline T *asT1() const; - inline T2 *asT2() const; - -private: - quintptr ptr_value; - - static const quintptr FlagBit = 0x1; - static const quintptr Flag2Bit = 0x2; - static const quintptr FlagsMask = FlagBit | Flag2Bit; -}; - -template -QFlagPointer::QFlagPointer() -: ptr_value(0) -{ -} - -template -QFlagPointer::QFlagPointer(T *v) -: ptr_value(quintptr(v)) -{ - Q_ASSERT((ptr_value & FlagsMask) == 0); -} - -template -QFlagPointer::QFlagPointer(const QFlagPointer &o) -: ptr_value(o.ptr_value) -{ -} - -template -bool QFlagPointer::isNull() const -{ - return 0 == (ptr_value & (~FlagsMask)); -} - -template -bool QFlagPointer::flag() const -{ - return ptr_value & FlagBit; -} - -template -void QFlagPointer::setFlag() -{ - ptr_value |= FlagBit; -} - -template -void QFlagPointer::clearFlag() -{ - ptr_value &= ~FlagBit; -} - -template -void QFlagPointer::setFlagValue(bool v) -{ - if (v) setFlag(); - else clearFlag(); -} - -template -bool QFlagPointer::flag2() const -{ - return ptr_value & Flag2Bit; -} - -template -void QFlagPointer::setFlag2() -{ - ptr_value|= Flag2Bit; -} - -template -void QFlagPointer::clearFlag2() -{ - ptr_value &= ~Flag2Bit; -} - -template -void QFlagPointer::setFlag2Value(bool v) -{ - if (v) setFlag2(); - else clearFlag2(); -} - -template -QFlagPointer &QFlagPointer::operator=(const QFlagPointer &o) -{ - ptr_value = o.ptr_value; - return *this; -} - -template -QFlagPointer &QFlagPointer::operator=(T *o) -{ - Q_ASSERT((quintptr(o) & FlagsMask) == 0); - - ptr_value = quintptr(o) | (ptr_value & FlagsMask); - return *this; -} - -template -T *QFlagPointer::operator->() const -{ - return (T *)(ptr_value & ~FlagsMask); -} - -template -T *QFlagPointer::operator*() const -{ - return (T *)(ptr_value & ~FlagsMask); -} - -template -QBiPointer::QBiPointer() -: ptr_value(0) -{ -} - -template -QBiPointer::QBiPointer(T *v) -: ptr_value(quintptr(v)) -{ - Q_ASSERT((quintptr(v) & FlagsMask) == 0); -} - -template -QBiPointer::QBiPointer(T2 *v) -: ptr_value(quintptr(v) | Flag2Bit) -{ - Q_ASSERT((quintptr(v) & FlagsMask) == 0); -} - -template -QBiPointer::QBiPointer(const QBiPointer &o) -: ptr_value(o.ptr_value) -{ -} - -template -bool QBiPointer::isNull() const -{ - return 0 == (ptr_value & (~FlagsMask)); -} - -template -bool QBiPointer::isT1() const -{ - return !(ptr_value & Flag2Bit); -} - -template -bool QBiPointer::isT2() const -{ - return ptr_value & Flag2Bit; -} - -template -bool QBiPointer::flag() const -{ - return ptr_value & FlagBit; -} - -template -void QBiPointer::setFlag() -{ - ptr_value |= FlagBit; -} - -template -void QBiPointer::clearFlag() -{ - ptr_value &= ~FlagBit; -} - -template -void QBiPointer::setFlagValue(bool v) -{ - if (v) setFlag(); - else clearFlag(); -} - -template -QBiPointer &QBiPointer::operator=(const QBiPointer &o) -{ - ptr_value = o.ptr_value; - return *this; -} - -template -QBiPointer &QBiPointer::operator=(T *o) -{ - Q_ASSERT((quintptr(o) & FlagsMask) == 0); - - ptr_value = quintptr(o) | (ptr_value & FlagBit); - return *this; -} - -template -QBiPointer &QBiPointer::operator=(T2 *o) -{ - Q_ASSERT((quintptr(o) & FlagsMask) == 0); - - ptr_value = quintptr(o) | (ptr_value & FlagBit) | Flag2Bit; - return *this; -} - -template -T *QBiPointer::asT1() const -{ - Q_ASSERT(isT1()); - return (T *)(ptr_value & ~FlagsMask); -} - -template -T2 *QBiPointer::asT2() const -{ - Q_ASSERT(isT2()); - return (T2 *)(ptr_value & ~FlagsMask); -} - -QT_END_NAMESPACE - -#endif // QFLAGPOINTER_P_H diff --git a/src/declarative/qml/ftw/qhashedstring.cpp b/src/declarative/qml/ftw/qhashedstring.cpp deleted file mode 100644 index f3b5a9ebc9..0000000000 --- a/src/declarative/qml/ftw/qhashedstring.cpp +++ /dev/null @@ -1,490 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qhashedstring_p.h" - -// This is a reimplementation of V8's string hash algorithm. It is significantly -// faster to do it here than call into V8, but it adds the maintainence burden of -// ensuring that the two hashes are identical. We Q_ASSERT() that the two return -// the same value. If these asserts start to fail, the hash code needs to be -// synced with V8. -namespace String { - static const int kMaxArrayIndexSize = 10; - static const int kMaxHashCalcLength = 16383; - static const int kNofHashBitFields = 2; - static const int kHashShift = kNofHashBitFields; - static const int kIsNotArrayIndexMask = 1 << 1; - static const int kArrayIndexValueBits = 24; - static const int kArrayIndexHashLengthShift = kArrayIndexValueBits + kNofHashBitFields; - static const int kMaxCachedArrayIndexLength = 7; -}; - -template -uint32_t calculateHash(const schar* chars, int length) { - if (length > String::kMaxHashCalcLength) { - // V8 trivial hash - return (length << String::kHashShift) | String::kIsNotArrayIndexMask; - } - - uint32_t raw_running_hash = 0; - uint32_t array_index = 0; - bool is_array_index = (0 < length && length <= String::kMaxArrayIndexSize); - bool is_first_char = true; - - int ii = 0; - for (;is_array_index && ii < length; ++ii) { - quint32 c = *chars++; - - raw_running_hash += c; - raw_running_hash += (raw_running_hash << 10); - raw_running_hash ^= (raw_running_hash >> 6); - - if (c < '0' || c > '9') { - is_array_index = false; - } else { - int d = c - '0'; - if (is_first_char) { - is_first_char = false; - if (c == '0' && length > 1) { - is_array_index = false; - continue; - } - } - if (array_index > 429496729U - ((d + 2) >> 3)) { - is_array_index = false; - } else { - array_index = array_index * 10 + d; - } - } - } - - for (;ii < length; ++ii) { - raw_running_hash += *chars++; - raw_running_hash += (raw_running_hash << 10); - raw_running_hash ^= (raw_running_hash >> 6); - } - - if (is_array_index) { - array_index <<= String::kHashShift; - array_index |= length << String::kArrayIndexHashLengthShift; - return array_index; - } else { - raw_running_hash += (raw_running_hash << 3); - raw_running_hash ^= (raw_running_hash >> 11); - raw_running_hash += (raw_running_hash << 15); - if (raw_running_hash == 0) { - raw_running_hash = 27; - } - - return (raw_running_hash << String::kHashShift) | String::kIsNotArrayIndexMask; - } -} - -inline quint32 stringHash(const QChar* data, int length) -{ - quint32 rv = calculateHash((quint16*)data, length) >> String::kHashShift; - Q_ASSERT(rv == v8::String::ComputeHash((uint16_t*)data, length)); - return rv; -} - -inline quint32 stringHash(const char *data, int length) -{ - quint32 rv = calculateHash((quint8*)data, length) >> String::kHashShift; - Q_ASSERT(rv == v8::String::ComputeHash((char *)data, length)); - return rv; -} - -void QHashedString::computeHash() const -{ - m_hash = stringHash(constData(), length()); -} - -void QHashedStringRef::computeHash() const -{ - m_hash = stringHash(m_data, m_length); -} - -void QHashedCStringRef::computeHash() const -{ - m_hash = stringHash(m_data, m_length); -} - -/* - A QHash has initially around pow(2, MinNumBits) buckets. For - example, if MinNumBits is 4, it has 17 buckets. -*/ -const int MinNumBits = 4; - -/* - The prime_deltas array is a table of selected prime values, even - though it doesn't look like one. The primes we are using are 1, - 2, 5, 11, 17, 37, 67, 131, 257, ..., i.e. primes in the immediate - surrounding of a power of two. - - The primeForNumBits() function returns the prime associated to a - power of two. For example, primeForNumBits(8) returns 257. -*/ - -static const uchar prime_deltas[] = { - 0, 0, 1, 3, 1, 5, 3, 3, 1, 9, 7, 5, 3, 9, 25, 3, - 1, 21, 3, 21, 7, 15, 9, 5, 3, 29, 15, 0, 0, 0, 0, 0 -}; - -static inline int primeForNumBits(int numBits) -{ - return (1 << numBits) + prime_deltas[numBits]; -} - -void QStringHashData::rehashToSize(int size, IteratorData first, - IteratorData (*Iterate)(const IteratorData &), - QStringHashNode *skip) -{ - short bits = qMax(MinNumBits, (int)numBits); - while (primeForNumBits(bits) < size) bits++; - - if (bits > numBits) - rehashToBits(bits, first, Iterate, skip); -} - -void QStringHashData::rehashToBits(short bits, IteratorData first, - IteratorData (*Iterate)(const IteratorData &), - QStringHashNode *skip) -{ - numBits = qMax(MinNumBits, (int)bits); - - int nb = primeForNumBits(numBits); - if (nb == numBuckets && buckets) - return; - - numBuckets = nb; - -#ifdef QSTRINGHASH_LINK_DEBUG - if (linkCount) - qFatal("QStringHash: Illegal attempt to rehash a linked hash."); -#endif - - delete [] buckets; - buckets = new QStringHashNode *[numBuckets]; - ::memset(buckets, 0, sizeof(QStringHashNode *) * numBuckets); - - IteratorData nodeList = first; - while (nodeList.n) { - if (nodeList.n != skip) { - int bucket = nodeList.n->hash % numBuckets; - nodeList.n->next = buckets[bucket]; - buckets[bucket] = nodeList.n; - } - - nodeList = Iterate(nodeList); - } -} - -// Copy of QString's qMemCompare -bool QHashedString::compare(const QChar *lhs, const QChar *rhs, int length) -{ - Q_ASSERT(lhs && rhs); - const quint16 *a = (const quint16 *)lhs; - const quint16 *b = (const quint16 *)rhs; - - if (a == b || !length) - return true; - - register union { - const quint16 *w; - const quint32 *d; - quintptr value; - } sa, sb; - sa.w = a; - sb.w = b; - - // check alignment - if ((sa.value & 2) == (sb.value & 2)) { - // both addresses have the same alignment - if (sa.value & 2) { - // both addresses are not aligned to 4-bytes boundaries - // compare the first character - if (*sa.w != *sb.w) - return false; - --length; - ++sa.w; - ++sb.w; - - // now both addresses are 4-bytes aligned - } - - // both addresses are 4-bytes aligned - // do a fast 32-bit comparison - register const quint32 *e = sa.d + (length >> 1); - for ( ; sa.d != e; ++sa.d, ++sb.d) { - if (*sa.d != *sb.d) - return false; - } - - // do we have a tail? - return (length & 1) ? *sa.w == *sb.w : true; - } else { - // one of the addresses isn't 4-byte aligned but the other is - register const quint16 *e = sa.w + length; - for ( ; sa.w != e; ++sa.w, ++sb.w) { - if (*sa.w != *sb.w) - return false; - } - } - return true; -} - -// Unicode stuff -static inline bool isUnicodeNonCharacter(uint ucs4) -{ - // Unicode has a couple of "non-characters" that one can use internally, - // but are not allowed to be used for text interchange. - // - // Those are the last two entries each Unicode Plane (U+FFFE, U+FFFF, - // U+1FFFE, U+1FFFF, etc.) as well as the entries between U+FDD0 and - // U+FDEF (inclusive) - - return (ucs4 & 0xfffe) == 0xfffe - || (ucs4 - 0xfdd0U) < 16; -} - -static int utf8LengthFromUtf16(const QChar *uc, int len) -{ - int length = 0; - - int surrogate_high = -1; - - const QChar *ch = uc; - int invalid = 0; - - const QChar *end = ch + len; - while (ch < end) { - uint u = ch->unicode(); - if (surrogate_high >= 0) { - if (u >= 0xdc00 && u < 0xe000) { - u = (surrogate_high - 0xd800)*0x400 + (u - 0xdc00) + 0x10000; - surrogate_high = -1; - } else { - // high surrogate without low - ++ch; - ++invalid; - surrogate_high = -1; - continue; - } - } else if (u >= 0xdc00 && u < 0xe000) { - // low surrogate without high - ++ch; - ++invalid; - continue; - } else if (u >= 0xd800 && u < 0xdc00) { - surrogate_high = u; - ++ch; - continue; - } - - if (u < 0x80) { - ++length; - } else { - if (u < 0x0800) { - ++length; - } else { - // is it one of the Unicode non-characters? - if (isUnicodeNonCharacter(u)) { - ++length; - ++ch; - ++invalid; - continue; - } - - if (u > 0xffff) { - ++length; - ++length; - } else { - ++length; - } - ++length; - } - ++length; - } - ++ch; - } - - return length; -} - -// Writes the utf8 version of uc to output. uc is of length len. -// There must be at least utf8LengthFromUtf16(uc, len) bytes in output. -// A null terminator is not written. -static void utf8FromUtf16(char *output, const QChar *uc, int len) -{ - uchar replacement = '?'; - int surrogate_high = -1; - - uchar* cursor = (uchar*)output; - const QChar *ch = uc; - int invalid = 0; - - const QChar *end = ch + len; - while (ch < end) { - uint u = ch->unicode(); - if (surrogate_high >= 0) { - if (u >= 0xdc00 && u < 0xe000) { - u = (surrogate_high - 0xd800)*0x400 + (u - 0xdc00) + 0x10000; - surrogate_high = -1; - } else { - // high surrogate without low - *cursor = replacement; - ++ch; - ++invalid; - surrogate_high = -1; - continue; - } - } else if (u >= 0xdc00 && u < 0xe000) { - // low surrogate without high - *cursor = replacement; - ++ch; - ++invalid; - continue; - } else if (u >= 0xd800 && u < 0xdc00) { - surrogate_high = u; - ++ch; - continue; - } - - if (u < 0x80) { - *cursor++ = (uchar)u; - } else { - if (u < 0x0800) { - *cursor++ = 0xc0 | ((uchar) (u >> 6)); - } else { - // is it one of the Unicode non-characters? - if (isUnicodeNonCharacter(u)) { - *cursor++ = replacement; - ++ch; - ++invalid; - continue; - } - - if (u > 0xffff) { - *cursor++ = 0xf0 | ((uchar) (u >> 18)); - *cursor++ = 0x80 | (((uchar) (u >> 12)) & 0x3f); - } else { - *cursor++ = 0xe0 | (((uchar) (u >> 12)) & 0x3f); - } - *cursor++ = 0x80 | (((uchar) (u >> 6)) & 0x3f); - } - *cursor++ = 0x80 | ((uchar) (u&0x3f)); - } - ++ch; - } -} - -void QHashedStringRef::computeUtf8Length() const -{ - if (m_length) - m_utf8length = utf8LengthFromUtf16(m_data, m_length); - else - m_utf8length = 0; -} - -QHashedStringRef QHashedStringRef::mid(int offset, int length) const -{ - Q_ASSERT(offset < m_length); - return QHashedStringRef(m_data + offset, - (length == -1 || (offset + length) > m_length)?(m_length - offset):length); -} - -bool QHashedStringRef::endsWith(const QString &s) const -{ - return s.length() < m_length && - QHashedString::compare(s.constData(), m_data + m_length - s.length(), s.length()); -} - -bool QHashedStringRef::startsWith(const QString &s) const -{ - return s.length() < m_length && - QHashedString::compare(s.constData(), m_data, s.length()); -} - -QString QHashedStringRef::toString() const -{ - if (m_length == 0) - return QString(); - return QString(m_data, m_length); -} - -QByteArray QHashedStringRef::toUtf8() const -{ - if (m_length == 0) - return QByteArray(); - - QByteArray result; - result.resize(utf8length()); - writeUtf8(result.data()); - return result; -} - -void QHashedStringRef::writeUtf8(char *output) const -{ - if (m_length) { - int ulen = utf8length(); - if (ulen == m_length) { - // Must be a latin1 string - uchar *o = (uchar *)output; - const QChar *c = m_data; - while (ulen--) - *o++ = (uchar)((*c++).unicode()); - } else { - utf8FromUtf16(output, m_data, m_length); - } - } -} - -QString QHashedCStringRef::toUtf16() const -{ - if (m_length == 0) - return QString(); - - QString rv; - rv.resize(m_length); - writeUtf16((uint16_t*)rv.data()); - return rv; -} - diff --git a/src/declarative/qml/ftw/qhashedstring_p.h b/src/declarative/qml/ftw/qhashedstring_p.h deleted file mode 100644 index b778dd4df2..0000000000 --- a/src/declarative/qml/ftw/qhashedstring_p.h +++ /dev/null @@ -1,1418 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QHASHEDSTRING_P_H -#define QHASHEDSTRING_P_H - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists purely as an -// implementation detail. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - -#include -#include -#include - -#include - -QT_BEGIN_NAMESPACE - -// Enable this to debug hash linking assumptions. -// #define QSTRINGHASH_LINK_DEBUG - -class QHashedStringRef; -class Q_AUTOTEST_EXPORT QHashedString : public QString -{ -public: - inline QHashedString(); - inline QHashedString(const QString &string); - inline QHashedString(const QString &string, quint32); - inline QHashedString(const QHashedString &string); - - inline QHashedString &operator=(const QHashedString &string); - inline bool operator==(const QHashedString &string) const; - inline bool operator==(const QHashedStringRef &string) const; - - inline quint32 hash() const; - inline quint32 existingHash() const; - - static inline bool isUpper(const QChar &); - - static bool compare(const QChar *lhs, const QChar *rhs, int length); - static inline bool compare(const QChar *lhs, const char *rhs, int length); - static inline bool compare(const char *lhs, const char *rhs, int length); -private: - friend class QHashedStringRef; - friend class QStringHashNode; - - void computeHash() const; - mutable quint32 m_hash; -}; - -class Q_AUTOTEST_EXPORT QHashedV8String -{ -public: - inline QHashedV8String(); - explicit inline QHashedV8String(v8::Handle); - inline QHashedV8String(const QHashedV8String &string); - inline QHashedV8String &operator=(const QHashedV8String &other); - - inline bool operator==(const QHashedV8String &string); - - inline quint32 hash() const; - inline int length() const; - inline quint32 symbolId() const; - - inline v8::Handle string() const; - - inline QString toString() const; - -private: - v8::String::CompleteHashData m_hash; - v8::Handle m_string; -}; - -class QHashedCStringRef; -class Q_AUTOTEST_EXPORT QHashedStringRef -{ -public: - inline QHashedStringRef(); - inline QHashedStringRef(const QString &); - inline QHashedStringRef(const QStringRef &); - inline QHashedStringRef(const QChar *, int); - inline QHashedStringRef(const QChar *, int, quint32); - inline QHashedStringRef(const QHashedString &); - inline QHashedStringRef(const QHashedStringRef &); - inline QHashedStringRef &operator=(const QHashedStringRef &); - - inline bool operator==(const QString &string) const; - inline bool operator==(const QHashedString &string) const; - inline bool operator==(const QHashedStringRef &string) const; - inline bool operator==(const QHashedCStringRef &string) const; - inline bool operator!=(const QString &string) const; - inline bool operator!=(const QHashedString &string) const; - inline bool operator!=(const QHashedStringRef &string) const; - inline bool operator!=(const QHashedCStringRef &string) const; - - inline quint32 hash() const; - - inline const QChar &at(int) const; - inline const QChar *constData() const; - bool startsWith(const QString &) const; - bool endsWith(const QString &) const; - QHashedStringRef mid(int, int) const; - - inline bool isEmpty() const; - inline int length() const; - inline bool startsWithUpper() const; - - QString toString() const; - - inline int utf8length() const; - QByteArray toUtf8() const; - void writeUtf8(char *) const; -private: - friend class QHashedString; - - void computeHash() const; - void computeUtf8Length() const; - - const QChar *m_data; - int m_length; - mutable int m_utf8length; - mutable quint32 m_hash; -}; - -class Q_AUTOTEST_EXPORT QHashedCStringRef -{ -public: - inline QHashedCStringRef(); - inline QHashedCStringRef(const char *, int); - inline QHashedCStringRef(const char *, int, quint32); - inline QHashedCStringRef(const QHashedCStringRef &); - - inline quint32 hash() const; - - inline const char *constData() const; - inline int length() const; - - QString toUtf16() const; - inline int utf16length() const; - inline void writeUtf16(QChar *) const; - inline void writeUtf16(uint16_t *) const; -private: - friend class QHashedStringRef; - - void computeHash() const; - - const char *m_data; - int m_length; - mutable quint32 m_hash; -}; - -class QStringHashData; -class Q_AUTOTEST_EXPORT QStringHashNode -{ -public: - QStringHashNode() - : length(0), hash(0), symbolId(0), ckey(0) - { - } - - QStringHashNode(const QHashedString &key) - : length(key.length()), hash(key.hash()), symbolId(0) - { - strData = const_cast(key).data_ptr(); - setQString(true); - strData->ref.ref(); - } - - QStringHashNode(const QHashedCStringRef &key) - : length(key.length()), hash(key.hash()), symbolId(0), ckey(key.constData()) - { - } - - QStringHashNode(const QStringHashNode &o) - : length(o.length), hash(o.hash), symbolId(o.symbolId), ckey(o.ckey) - { - setQString(o.isQString()); - if (isQString()) { strData->ref.ref(); } - } - - ~QStringHashNode() - { - if (isQString()) { if (!strData->ref.deref()) free(strData); } - } - - QFlagPointer next; - - qint32 length; - quint32 hash; - quint32 symbolId; - - union { - const char *ckey; - QStringData *strData; - }; - - bool isQString() const { return next.flag(); } - void setQString(bool v) { if (v) next.setFlag(); else next.clearFlag(); } - - inline char *cStrData() const { return (char *)ckey; } - inline uint16_t *utf16Data() const { return (uint16_t *)strData->data(); } - - inline bool equals(v8::Handle string) { - return isQString()?string->Equals(utf16Data(), length): - string->Equals(cStrData(), length); - } - - inline bool symbolEquals(const QHashedV8String &string) { - Q_ASSERT(string.symbolId() != 0); - return length == string.length() && hash == string.hash() && - (string.symbolId() == symbolId || equals(string.string())); - } - - inline bool equals(const QHashedV8String &string) { - return length == string.length() && hash == string.hash() && - equals(string.string()); - } - - inline bool equals(const QHashedStringRef &string) { - return length == string.length() && - hash == string.hash() && - (isQString()?QHashedString::compare(string.constData(), (QChar *)utf16Data(), length): - QHashedString::compare(string.constData(), cStrData(), length)); - } - - inline bool equals(const QHashedCStringRef &string) { - return length == string.length() && - hash == string.hash() && - (isQString()?QHashedString::compare((QChar *)utf16Data(), string.constData(), length): - QHashedString::compare(string.constData(), cStrData(), length)); - } -}; - -class Q_AUTOTEST_EXPORT QStringHashData -{ -public: - QStringHashData() - : buckets(0), numBuckets(0), size(0), numBits(0) -#ifdef QSTRINGHASH_LINK_DEBUG - , linkCount(0) -#endif - {} - - QStringHashNode **buckets; - int numBuckets; - int size; - short numBits; -#ifdef QSTRINGHASH_LINK_DEBUG - int linkCount; -#endif - - struct IteratorData { - IteratorData() : n(0), p(0) {} - QStringHashNode *n; - void *p; - }; - void rehashToBits(short, IteratorData, IteratorData (*Iterate)(const IteratorData &), - QStringHashNode *skip = 0); - void rehashToSize(int, IteratorData, IteratorData (*Iterate)(const IteratorData &), - QStringHashNode *skip = 0); - -private: - QStringHashData(const QStringHashData &); - QStringHashData &operator=(const QStringHashData &); -}; - -template -class QStringHash -{ -public: - struct Node : public QStringHashNode { - Node(const QHashedString &key, const T &value) : QStringHashNode(key), value(value) {} - Node(const QHashedCStringRef &key, const T &value) : QStringHashNode(key), value(value) {} - Node(const Node &o) : QStringHashNode(o), value(o.value) {} - Node() {} - T value; - }; - struct NewedNode : public Node { - NewedNode(const QHashedString &key, const T &value) : Node(key, value), nextNewed(0) {} - NewedNode(const QHashedCStringRef &key, const T &value) : Node(key, value), nextNewed(0) {} - NewedNode(const Node &o) : Node(o), nextNewed(0) {} - NewedNode *nextNewed; - }; - struct ReservedNodePool - { - ReservedNodePool() : count(0), used(0), nodes(0) {} - ~ReservedNodePool() { delete [] nodes; } - int count; - int used; - Node *nodes; - }; - - QStringHashData data; - NewedNode *newedNodes; - ReservedNodePool *nodePool; - const QStringHash *link; - - inline Node *findNode(const QString &) const; - inline Node *findNode(const QHashedString &) const; - inline Node *findNode(const QHashedStringRef &) const; - inline Node *findNode(const QHashedCStringRef &) const; - inline Node *findNode(const QHashedV8String &) const; - inline Node *findSymbolNode(const QHashedV8String &) const; - inline Node *createNode(const Node &o); - inline Node *createNode(const QHashedString &, const T &); - inline Node *createNode(const QHashedCStringRef &, const T &); - - inline Node *takeNode(const QHashedString &key, const T &value); - inline Node *takeNode(const QHashedCStringRef &key, const T &value); - inline Node *takeNode(const Node &o); - - inline void copy(const QStringHash &); - - inline QStringHashData::IteratorData iterateFirst() const; - static inline QStringHashData::IteratorData iterateNext(const QStringHashData::IteratorData &); - -public: - inline QStringHash(); - inline QStringHash(const QStringHash &); - inline ~QStringHash(); - - QStringHash &operator=(const QStringHash &); - - void copyAndReserve(const QStringHash &other, int additionalReserve); - void linkAndReserve(const QStringHash &other, int additionalReserve); - - inline bool isEmpty() const; - inline void clear(); - inline int count() const; - - inline int numBuckets() const; - inline bool isLinked() const; - - class ConstIterator { - public: - inline ConstIterator(); - inline ConstIterator(const QStringHashData::IteratorData &); - - inline ConstIterator &operator++(); - - inline bool operator==(const ConstIterator &o) const; - inline bool operator!=(const ConstIterator &o) const; - - inline QHashedString key() const; - inline const T &value() const; - inline const T &operator*() const; - - inline Node *node() const; - private: - QStringHashData::IteratorData d; - }; - - inline void insert(const QString &, const T &); - inline void insert(const QHashedString &, const T &); - inline void insert(const QHashedStringRef &, const T &); - inline void insert(const QHashedCStringRef &, const T &); - inline void insert(const ConstIterator &); - - inline T *value(const QString &) const; - inline T *value(const QHashedString &) const; - inline T *value(const QHashedStringRef &) const; - inline T *value(const QHashedV8String &) const; - inline T *value(const QHashedCStringRef &) const; - inline T *value(const ConstIterator &) const; - - inline bool contains(const QString &) const; - inline bool contains(const QHashedString &) const; - inline bool contains(const QHashedStringRef &) const; - inline bool contains(const QHashedCStringRef &) const; - inline bool contains(const ConstIterator &) const; - - inline T &operator[](const QString &); - inline T &operator[](const QHashedString &); - inline T &operator[](const QHashedStringRef &); - inline T &operator[](const QHashedCStringRef &); - - inline ConstIterator begin() const; - inline ConstIterator end() const; - - inline void reserve(int); -}; - -template -QStringHash::QStringHash() -: newedNodes(0), nodePool(0), link(0) -{ -} - -template -QStringHash::QStringHash(const QStringHash &other) -: newedNodes(0), nodePool(0), link(0) -{ - data.numBits = other.data.numBits; - data.size = other.data.size; - reserve(other.count()); - copy(other); -} - -template -QStringHash &QStringHash::operator=(const QStringHash &other) -{ - if (&other == this) - return *this; - - clear(); - - data.numBits = other.data.numBits; - data.size = other.data.size; - reserve(other.count()); - copy(other); - - return *this; -} - -template -void QStringHash::copyAndReserve(const QStringHash &other, int additionalReserve) -{ - clear(); - data.numBits = other.data.numBits; - reserve(other.count() + additionalReserve); - copy(other); -} - -template -void QStringHash::linkAndReserve(const QStringHash &other, int additionalReserve) -{ - clear(); - - if (other.count()) { - data.size = other.data.size; - data.rehashToSize(other.count() + additionalReserve, iterateFirst(), iterateNext); - - if (data.numBuckets == other.data.numBuckets) { - nodePool = new ReservedNodePool; - nodePool->count = additionalReserve; - nodePool->used = 0; - nodePool->nodes = new Node[additionalReserve]; - -#ifdef QSTRINGHASH_LINK_DEBUG - data.linkCount++; - const_cast&>(other).data.linkCount++; -#endif - - for (int ii = 0; ii < data.numBuckets; ++ii) { - data.buckets[ii] = 0; - Node *n = (Node *)other.data.buckets[ii]; - data.buckets[ii] = n; - } - - link = &other; - return; - } - - data.size = 0; - } - - data.numBits = other.data.numBits; - reserve(other.count() + additionalReserve); - copy(other); -} - -template -QStringHash::~QStringHash() -{ - clear(); -} - -template -void QStringHash::clear() -{ -#ifdef QSTRINGHASH_LINK_DEBUG - if (link) { - data.linkCount--; - const_cast *>(link)->data.linkCount--; - } - - if (data.linkCount) - qFatal("QStringHash: Illegal attempt to clear a linked hash."); -#endif - - // Delete the individually allocated nodes - NewedNode *n = newedNodes; - while (n) { - NewedNode *c = n; - n = c->nextNewed; - delete c; - } - // Delete the pool allocated nodes - if (nodePool) delete nodePool; - delete [] data.buckets; - - data.buckets = 0; - data.numBuckets = 0; - data.numBits = 0; - data.size = 0; - - newedNodes = 0; - nodePool = 0; - link = 0; -} - -template -bool QStringHash::isEmpty() const -{ - return data.size== 0; -} - -template -int QStringHash::count() const -{ - return data.size; -} - -template -int QStringHash::numBuckets() const -{ - return data.numBuckets; -} - -template -bool QStringHash::isLinked() const -{ - return link != 0; -} - -template -typename QStringHash::Node *QStringHash::takeNode(const QHashedString &key, const T &value) -{ - if (nodePool && nodePool->used != nodePool->count) { - Node *rv = nodePool->nodes + nodePool->used++; - rv->length = key.length(); - rv->hash = key.hash(); - rv->strData = const_cast(key).data_ptr(); - rv->strData->ref.ref(); - rv->setQString(true); - rv->value = value; - return rv; - } else { - NewedNode *rv = new NewedNode(key, value); - rv->nextNewed = newedNodes; - newedNodes = rv; - return rv; - } -} - -template -typename QStringHash::Node *QStringHash::takeNode(const QHashedCStringRef &key, const T &value) -{ - if (nodePool && nodePool->used != nodePool->count) { - Node *rv = nodePool->nodes + nodePool->used++; - rv->length = key.length(); - rv->hash = key.hash(); - rv->ckey = key.constData(); - rv->value = value; - return rv; - } else { - NewedNode *rv = new NewedNode(key, value); - rv->nextNewed = newedNodes; - newedNodes = rv; - return rv; - } -} - -template -typename QStringHash::Node *QStringHash::takeNode(const Node &o) -{ - if (nodePool && nodePool->used != nodePool->count) { - Node *rv = nodePool->nodes + nodePool->used++; - rv->length = o.length; - rv->hash = o.hash; - if (o.isQString()) { - rv->strData = o.strData; - rv->strData->ref.ref(); - rv->setQString(true); - } else { - rv->ckey = o.ckey; - } - rv->symbolId = o.symbolId; - rv->value = o.value; - return rv; - } else { - NewedNode *rv = new NewedNode(o); - rv->nextNewed = newedNodes; - newedNodes = rv; - return rv; - } -} - -template -void QStringHash::copy(const QStringHash &other) -{ - Q_ASSERT(data.size == 0); - - data.size = other.data.size; - - // Ensure buckets array is created - data.rehashToBits(data.numBits, iterateFirst(), iterateNext); - - if (other.link) { - for (ConstIterator iter = other.begin(); iter != other.end(); ++iter) { - Node *o = iter.node(); - Node *n = o->isQString()?findNode(QHashedStringRef((QChar *)o->strData->data(), o->length, o->hash)): - findNode(QHashedCStringRef(o->ckey, o->length, o->hash)); - if (!n) { - Node *mynode = takeNode(*o); - int bucket = mynode->hash % data.numBuckets; - mynode->next = data.buckets[bucket]; - data.buckets[bucket] = mynode; - } - } - } else { - for (ConstIterator iter = other.begin(); iter != other.end(); ++iter) { - Node *o = iter.node(); - Node *mynode = takeNode(*o); - int bucket = mynode->hash % data.numBuckets; - mynode->next = data.buckets[bucket]; - data.buckets[bucket] = mynode; - } - } -} - -template -QStringHashData::IteratorData -QStringHash::iterateNext(const QStringHashData::IteratorData &d) -{ - QStringHash *This = (QStringHash *)d.p; - Node *node = (Node *)d.n; - - if (This->nodePool && node >= This->nodePool->nodes && - node < (This->nodePool->nodes + This->nodePool->used)) { - node--; - if (node < This->nodePool->nodes) - node = 0; - } else { - NewedNode *nn = (NewedNode *)node; - node = nn->nextNewed; - - if (node == 0 && This->nodePool && This->nodePool->used) - node = This->nodePool->nodes + This->nodePool->used - 1; - } - - if (node == 0 && This->link) - return This->link->iterateFirst(); - - QStringHashData::IteratorData rv; - rv.n = node; - rv.p = d.p; - return rv; -} - -template -QStringHashData::IteratorData QStringHash::iterateFirst() const -{ - Node *n = 0; - if (newedNodes) - n = newedNodes; - else if (nodePool && nodePool->used) - n = nodePool->nodes + nodePool->used - 1; - - if (n == 0 && link) - return link->iterateFirst(); - - QStringHashData::IteratorData rv; - rv.n = n; - rv.p = const_cast *>(this); - return rv; -} - -template -typename QStringHash::Node *QStringHash::createNode(const Node &o) -{ - Node *n = takeNode(o); - - if (data.size >= data.numBuckets) - data.rehashToBits(data.numBits + 1, iterateFirst(), iterateNext, n); - - int bucket = n->hash % data.numBuckets; - n->next = data.buckets[bucket]; - data.buckets[bucket] = n; - - data.size++; - - return n; -} - -template -typename QStringHash::Node *QStringHash::createNode(const QHashedString &key, const T &value) -{ - Node *n = takeNode(key, value); - - if (data.size >= data.numBuckets) - data.rehashToBits(data.numBits + 1, iterateFirst(), iterateNext, n); - - int bucket = key.hash() % data.numBuckets; - n->next = data.buckets[bucket]; - data.buckets[bucket] = n; - - data.size++; - - return n; -} - -template -typename QStringHash::Node *QStringHash::createNode(const QHashedCStringRef &key, const T &value) -{ - Node *n = takeNode(key, value); - - if (data.size >= data.numBuckets) - data.rehashToBits(data.numBits + 1, iterateFirst(), iterateNext, n); - - int bucket = key.hash() % data.numBuckets; - n->next = data.buckets[bucket]; - data.buckets[bucket] = n; - - data.size++; - - return n; -} - -template -void QStringHash::insert(const QString &key, const T &value) -{ - QHashedStringRef ch(key); - // If this is a linked hash, we can't rely on owning the node, so we always - // create a new one. - Node *n = link?0:findNode(key); - if (n) n->value = value; - else createNode(QHashedString(key, ch.hash()), value); -} - -template -void QStringHash::insert(const QHashedString &key, const T &value) -{ - // If this is a linked hash, we can't rely on owning the node, so we always - // create a new one. - Node *n = link?0:findNode(key); - if (n) n->value = value; - else createNode(key, value); -} - -template -void QStringHash::insert(const QHashedStringRef &key, const T &value) -{ - // If this is a linked hash, we can't rely on owning the node, so we always - // create a new one. - Node *n = link?0:findNode(key); - if (n) n->value = value; - else createNode(key, value); -} - -template -void QStringHash::insert(const QHashedCStringRef &key, const T &value) -{ - // If this is a linked hash, we can't rely on owning the node, so we always - // create a new one. - Node *n = link?0:findNode(key); - if (n) n->value = value; - else createNode(key, value); -} - -template -void QStringHash::insert(const ConstIterator &key) -{ - // If this is a linked hash, we can't rely on owning the node, so we always - // create a new one. - if (key.node()->isQString()) { - QHashedStringRef str((QChar *)key.node()->strData->data(), key.node()->length, - key.node()->hash); - - Node *n = link?0:findNode(str); - if (n) n->value = key.node()->value; - else createNode(*key.node()); - } else { - QHashedCStringRef str(key.node()->ckey, key.node()->length, key.node()->hash); - - Node *n = link?0:findNode(str); - if (n) n->value = key.node()->value; - else createNode(str, key.node()->value); - } -} - -template -typename QStringHash::Node *QStringHash::findNode(const QString &string) const -{ - return findNode(QHashedStringRef(string)); -} - -template -typename QStringHash::Node *QStringHash::findNode(const QHashedString &string) const -{ - return findNode(QHashedStringRef(string.constData(), string.length(), string.hash())); -} - -template -typename QStringHash::Node *QStringHash::findNode(const QHashedStringRef &string) const -{ - QStringHashNode *node = data.numBuckets?data.buckets[string.hash() % data.numBuckets]:0; - while (node && !node->equals(string)) - node = (*node->next); - - return (Node *)node; -} - -template -typename QStringHash::Node *QStringHash::findNode(const QHashedCStringRef &string) const -{ - QStringHashNode *node = data.numBuckets?data.buckets[string.hash() % data.numBuckets]:0; - while (node && !node->equals(string)) - node = (*node->next); - - return (Node *)node; -} - -template -typename QStringHash::Node *QStringHash::findNode(const QHashedV8String &string) const -{ - QStringHashNode *node = data.numBuckets?data.buckets[string.hash() % data.numBuckets]:0; - while (node && !node->equals(string)) - node = (*node->next); - - return (Node *)node; -} - -template -typename QStringHash::Node *QStringHash::findSymbolNode(const QHashedV8String &string) const -{ - Q_ASSERT(string.symbolId() != 0); - - QStringHashNode *node = data.numBuckets?data.buckets[string.hash() % data.numBuckets]:0; - while (node && !node->symbolEquals(string)) - node = (*node->next); - - if (node) - node->symbolId = string.symbolId(); - - return (Node *)node; -} - -template -T *QStringHash::value(const QString &key) const -{ - Node *n = findNode(key); - return n?&n->value:0; -} - -template -T *QStringHash::value(const QHashedString &key) const -{ - Node *n = findNode(key); - return n?&n->value:0; -} - -template -T *QStringHash::value(const QHashedStringRef &key) const -{ - Node *n = findNode(key); - return n?&n->value:0; -} - -template -T *QStringHash::value(const QHashedCStringRef &key) const -{ - Node *n = findNode(key); - return n?&n->value:0; -} - -template -T *QStringHash::value(const ConstIterator &iter) const -{ - Node *n = iter.node(); - if (n->isQString()) - return value(QHashedStringRef((QChar *)n->strData->data(), n->length, n->hash)); - else - return value(QHashedCStringRef(n->ckey, n->length, n->hash)); -} - -template -T *QStringHash::value(const QHashedV8String &string) const -{ - Node *n = string.symbolId()?findSymbolNode(string):findNode(string); - return n?&n->value:0; -} - -template -bool QStringHash::contains(const QString &s) const -{ - return 0 != value(s); -} - -template -bool QStringHash::contains(const QHashedString &s) const -{ - return 0 != value(s); -} - -template -bool QStringHash::contains(const QHashedStringRef &s) const -{ - return 0 != value(s); -} - -template -bool QStringHash::contains(const QHashedCStringRef &s) const -{ - return 0 != value(s); -} - -template -bool QStringHash::contains(const ConstIterator &s) const -{ - return 0 != value(s); -} - -template -T &QStringHash::operator[](const QString &key) -{ - QHashedStringRef cs(key); - Node *n = findNode(cs); - if (n) return n->value; - else return createNode(QHashedString(key, cs.hash()), T())->value; -} - -template -T &QStringHash::operator[](const QHashedString &key) -{ - Node *n = findNode(key); - if (n) return n->value; - else return createNode(key, T())->value; -} - -template -T &QStringHash::operator[](const QHashedStringRef &key) -{ - Node *n = findNode(key); - if (n) return n->value; - else return createNode(key, T())->value; -} - -template -T &QStringHash::operator[](const QHashedCStringRef &key) -{ - Node *n = findNode(key); - if (n) return n->value; - else return createNode(key, T())->value; -} - -template -void QStringHash::reserve(int n) -{ - if (nodePool || 0 == n) - return; - - nodePool = new ReservedNodePool; - nodePool->count = n; - nodePool->used = 0; - nodePool->nodes = new Node[n]; - - data.rehashToSize(n, iterateFirst(), iterateNext); -} - -template -QStringHash::ConstIterator::ConstIterator() -{ -} - -template -QStringHash::ConstIterator::ConstIterator(const QStringHashData::IteratorData &d) -: d(d) -{ -} - -template -typename QStringHash::ConstIterator &QStringHash::ConstIterator::operator++() -{ - d = QStringHash::iterateNext(d); - return *this; -} - -template -bool QStringHash::ConstIterator::operator==(const ConstIterator &o) const -{ - return d.n == o.d.n; -} - -template -bool QStringHash::ConstIterator::operator!=(const ConstIterator &o) const -{ - return d.n != o.d.n; -} - -template -QHashedString QStringHash::ConstIterator::key() const -{ - Node *n = (Node *)d.n; - if (n->isQString()) { - return QHashedString(QString((QChar *)n->strData->data(), n->length), n->hash); - } else { - return QHashedString(QString::fromLatin1(n->ckey, n->length), n->hash); - } -} -template -const T &QStringHash::ConstIterator::value() const -{ - Node *n = (Node *)d.n; - return n->value; -} - -template -const T &QStringHash::ConstIterator::operator*() const -{ - Node *n = (Node *)d.n; - return n->value; -} - -template -typename QStringHash::Node *QStringHash::ConstIterator::node() const -{ - Node *n = (Node *)d.n; - return n; -} - -template -typename QStringHash::ConstIterator QStringHash::begin() const -{ - return ConstIterator(iterateFirst()); -} - -template -typename QStringHash::ConstIterator QStringHash::end() const -{ - return ConstIterator(); -} - -inline uint qHash(const QHashedString &string) -{ - return uint(string.hash()); -} - -inline uint qHash(const QHashedStringRef &string) -{ - return uint(string.hash()); -} - -QHashedString::QHashedString() -: QString(), m_hash(0) -{ -} - -QHashedString::QHashedString(const QString &string) -: QString(string), m_hash(0) -{ -} - -QHashedString::QHashedString(const QString &string, quint32 hash) -: QString(string), m_hash(hash) -{ -} - -QHashedString::QHashedString(const QHashedString &string) -: QString(string), m_hash(string.m_hash) -{ -} - -QHashedString &QHashedString::operator=(const QHashedString &string) -{ - static_cast(*this) = string; - m_hash = string.m_hash; - return *this; -} - -bool QHashedString::operator==(const QHashedString &string) const -{ - return (string.m_hash == m_hash || !string.m_hash || !m_hash) && - static_cast(*this) == static_cast(string); -} - -bool QHashedString::operator==(const QHashedStringRef &string) const -{ - return length() == string.m_length && - (string.m_hash == m_hash || !string.m_hash || !m_hash) && - QHashedString::compare(constData(), string.m_data, string.m_length); -} - -quint32 QHashedString::hash() const -{ - if (!m_hash) computeHash(); - return m_hash; -} - -quint32 QHashedString::existingHash() const -{ - return m_hash; -} - -bool QHashedString::isUpper(const QChar &qc) -{ - ushort c = qc.unicode(); - // Optimize for _, a-z and A-Z. - return ((c != '_' ) && (!(c >= 'a' && c <= 'z')) && - ((c >= 'A' && c <= 'Z') || QChar::category(c) == QChar::Letter_Uppercase)); -} - -QHashedV8String::QHashedV8String() -{ -} - -QHashedV8String::QHashedV8String(v8::Handle string) -: m_hash(string->CompleteHash()), m_string(string) -{ - Q_ASSERT(!m_string.IsEmpty()); -} - -QHashedV8String::QHashedV8String(const QHashedV8String &string) -: m_hash(string.m_hash), m_string(string.m_string) -{ -} - -QHashedV8String &QHashedV8String::operator=(const QHashedV8String &other) -{ - m_hash = other.m_hash; - m_string = other.m_string; - return *this; -} - -bool QHashedV8String::operator==(const QHashedV8String &string) -{ - return m_hash.hash == string.m_hash.hash && m_hash.length == string.m_hash.length && - m_string.IsEmpty() == m_string.IsEmpty() && - (m_string.IsEmpty() || m_string->StrictEquals(string.m_string)); -} - -quint32 QHashedV8String::hash() const -{ - return m_hash.hash; -} - -int QHashedV8String::length() const -{ - return m_hash.length; -} - -quint32 QHashedV8String::symbolId() const -{ - return m_hash.symbol_id; -} - -v8::Handle QHashedV8String::string() const -{ - return m_string; -} - -QString QHashedV8String::toString() const -{ - QString result; - result.reserve(m_hash.length); - - for (int i = 0; i < m_hash.length; ++i) - result.append(m_string->GetCharacter(i)); - - return result; -} - -QHashedStringRef::QHashedStringRef() -: m_data(0), m_length(0), m_utf8length(-1), m_hash(0) -{ -} - -QHashedStringRef::QHashedStringRef(const QString &str) -: m_data(str.constData()), m_length(str.length()), m_utf8length(0), m_hash(0) -{ -} - -QHashedStringRef::QHashedStringRef(const QStringRef &str) -: m_data(str.constData()), m_length(str.length()), m_utf8length(0), m_hash(0) -{ -} - -QHashedStringRef::QHashedStringRef(const QChar *data, int length) -: m_data(data), m_length(length), m_utf8length(0), m_hash(0) -{ -} - -QHashedStringRef::QHashedStringRef(const QChar *data, int length, quint32 hash) -: m_data(data), m_length(length), m_utf8length(0), m_hash(hash) -{ -} - -QHashedStringRef::QHashedStringRef(const QHashedString &string) -: m_data(string.constData()), m_length(string.length()), m_utf8length(0), m_hash(string.m_hash) -{ -} - -QHashedStringRef::QHashedStringRef(const QHashedStringRef &string) -: m_data(string.m_data), m_length(string.m_length), m_utf8length(string.m_utf8length), - m_hash(string.m_hash) -{ -} - -QHashedStringRef &QHashedStringRef::operator=(const QHashedStringRef &o) -{ - m_data = o.m_data; - m_length = o.m_length; - m_utf8length = o.m_utf8length; - m_hash = o.m_hash; - return *this; -} - -bool QHashedStringRef::operator==(const QString &string) const -{ - return m_length == string.length() && - QHashedString::compare(string.constData(), m_data, m_length); -} - -bool QHashedStringRef::operator==(const QHashedString &string) const -{ - return m_length == string.length() && - (m_hash == string.m_hash || !m_hash || !string.m_hash) && - QHashedString::compare(string.constData(), m_data, m_length); -} - -bool QHashedStringRef::operator==(const QHashedStringRef &string) const -{ - return m_length == string.m_length && - (m_hash == string.m_hash || !m_hash || !string.m_hash) && - QHashedString::compare(string.m_data, m_data, m_length); -} - -bool QHashedStringRef::operator==(const QHashedCStringRef &string) const -{ - return m_length == string.m_length && - (m_hash == string.m_hash || !m_hash || !string.m_hash) && - QHashedString::compare(m_data, string.m_data, m_length); -} - -bool QHashedStringRef::operator!=(const QString &string) const -{ - return m_length != string.length() || - !QHashedString::compare(string.constData(), m_data, m_length); -} - -bool QHashedStringRef::operator!=(const QHashedString &string) const -{ - return m_length != string.length() || - (m_hash != string.m_hash && m_hash && string.m_hash) || - !QHashedString::compare(string.constData(), m_data, m_length); -} - -bool QHashedStringRef::operator!=(const QHashedStringRef &string) const -{ - return m_length != string.m_length || - (m_hash != string.m_hash && m_hash && string.m_hash) || - QHashedString::compare(string.m_data, m_data, m_length); -} - -bool QHashedStringRef::operator!=(const QHashedCStringRef &string) const -{ - return m_length != string.m_length || - (m_hash != string.m_hash && m_hash && string.m_hash) || - QHashedString::compare(m_data, string.m_data, m_length); -} - -const QChar &QHashedStringRef::at(int index) const -{ - Q_ASSERT(index < m_length); - return m_data[index]; -} - -const QChar *QHashedStringRef::constData() const -{ - return m_data; -} - -bool QHashedStringRef::isEmpty() const -{ - return m_length == 0; -} - -int QHashedStringRef::length() const -{ - return m_length; -} - -int QHashedStringRef::utf8length() const -{ - if (m_utf8length < m_length) - computeUtf8Length(); - return m_utf8length; -} - -bool QHashedStringRef::startsWithUpper() const -{ - if (m_length < 1) return false; - return QHashedString::isUpper(m_data[0]); -} - -quint32 QHashedStringRef::hash() const -{ - if (!m_hash) computeHash(); - return m_hash; -} - -QHashedCStringRef::QHashedCStringRef() -: m_data(0), m_length(0), m_hash(0) -{ -} - -QHashedCStringRef::QHashedCStringRef(const char *data, int length) -: m_data(data), m_length(length), m_hash(0) -{ -} - -QHashedCStringRef::QHashedCStringRef(const char *data, int length, quint32 hash) -: m_data(data), m_length(length), m_hash(hash) -{ -} - -QHashedCStringRef::QHashedCStringRef(const QHashedCStringRef &o) -: m_data(o.m_data), m_length(o.m_length), m_hash(o.m_hash) -{ -} - -quint32 QHashedCStringRef::hash() const -{ - if (!m_hash) computeHash(); - return m_hash; -} - -const char *QHashedCStringRef::constData() const -{ - return m_data; -} - -int QHashedCStringRef::length() const -{ - return m_length; -} - -int QHashedCStringRef::utf16length() const -{ - return m_length; -} - -void QHashedCStringRef::writeUtf16(QChar *output) const -{ - writeUtf16((uint16_t *)output); -} - -void QHashedCStringRef::writeUtf16(uint16_t *output) const -{ - int l = m_length; - const char *d = m_data; - while (l--) - *output++ = *d++; -} - -bool QHashedString::compare(const QChar *lhs, const char *rhs, int length) -{ - Q_ASSERT(lhs && rhs); - const quint16 *l = (const quint16*)lhs; - while (length--) - if (*l++ != *rhs++) return false; - return true; -} - -bool QHashedString::compare(const char *lhs, const char *rhs, int length) -{ - Q_ASSERT(lhs && rhs); - return 0 == ::memcmp(lhs, rhs, length); -} - -QT_END_NAMESPACE - -#endif // QHASHEDSTRING_P_H diff --git a/src/declarative/qml/ftw/qhashfield_p.h b/src/declarative/qml/ftw/qhashfield_p.h deleted file mode 100644 index a11e8d9486..0000000000 --- a/src/declarative/qml/ftw/qhashfield_p.h +++ /dev/null @@ -1,120 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QHASHFIELD_P_H -#define QHASHFIELD_P_H - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists purely as an -// implementation detail. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - - -#include - -QT_BEGIN_NAMESPACE - -// QHashField can be used for doing coarse grained set testing, in -// cases where you do not expect the set to contain the item. For -// example where you would write: -// QSet strings; -// for (int ii = 0; ii < mystrings.count(); ++ii) { -// if (strings.contains(mystrings.at(ii))) -// qFatal("Duplication!"); -// strings.insert(mystrings); -// } -// You may write: -// QHashField strings; -// for (int ii = 0; ii < mystrings.count(); ++ii) { -// if (strings.testAndSet(qHash(mystrings.at(ii)))) { -// // The string *might* be duplicated -// for (int jj = 0; jj < ii; ++jj) { -// if (mystrings.at(ii) == mystrings.at(jj)) -// qFatal("Duplication!"); -// } -// } -// } -// For small lists of things, where the hash is cheap to calculate -// and you don't expect duplication this will be much faster. -class QHashField { -public: - inline QHashField(); - - inline void clear(); - - inline bool test(quint32 hash); - inline bool testAndSet(quint32 hash); -private: - quint32 m_field; -}; - -QHashField::QHashField() -: m_field(0) -{ -} - -void QHashField::clear() -{ - m_field = 0; -} - -bool QHashField::test(quint32 hash) -{ - return m_field & (1 << (hash % 31)); -} - -bool QHashField::testAndSet(quint32 hash) -{ - quint32 mask = 1 << (hash % 31); - bool rv = m_field & mask; - m_field |= mask; - return rv; -} - -QT_END_NAMESPACE - -#endif // QHASHFIELD_P_H diff --git a/src/declarative/qml/ftw/qintrusivelist.cpp b/src/declarative/qml/ftw/qintrusivelist.cpp deleted file mode 100644 index 1893eef8cd..0000000000 --- a/src/declarative/qml/ftw/qintrusivelist.cpp +++ /dev/null @@ -1,179 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qintrusivelist_p.h" - -/*! -\class QIntrusiveList -\brief The QIntrusiveList class is a template class that provides a list of objects using static storage. -\internal - -QIntrusiveList creates a linked list of objects. Adding and removing objects from the -QIntrusiveList is a constant time operation and is very quick. The list performs no memory -allocations, but does require the objects being added to the list to contain a QIntrusiveListNode -instance for the list's use. Even so, for small lists QIntrusiveList uses less memory than Qt's -other list classes. - -As QIntrusiveList uses storage inside the objects in the list, each object can only be in one -list at a time. Objects are inserted by the insert() method. If the object is already -in a list (including the one it is being inserted into) it is first removed, and then inserted -at the head of the list. QIntrusiveList is a last-in-first-out list. That is, following an -insert() the inserted object becomes the list's first() object. - -\code -struct MyObject { - MyObject(int value) : value(value) {} - - int value; - QIntrusiveListNode node; -}; -typedef QIntrusiveList MyObjectList; - -void foo() { - MyObjectList list; - - MyObject m0(0); - MyObject m1(1); - MyObject m2(2); - - list.insert(&m0); - list.insert(&m1); - list.insert(&m2); - - // QIntrusiveList is LIFO, so will print: 2... 1... 0... - for (MyObjectList::iterator iter = list.begin(); iter != list.end(); ++iter) { - qWarning() << iter->value; - } -} -\endcode -*/ - - -/*! -\fn QIntrusiveList::QIntrusiveList(); - -Construct an empty list. -*/ - -/*! -\fn QIntrusiveList::~QIntrusiveList(); - -Destroy the list. All entries are removed. -*/ - -/*! -\fn void QIntrusiveList::insert(N *object); - -Insert \a object into the list. If \a object is a member of this, or another list, it will be -removed and inserted at the head of this list. -*/ - -/*! -\fn void QIntrusiveList::remove(N *object); - -Remove \a object from the list. \a object must not be null. -*/ - -/*! -\fn bool QIntrusiveList::contains(N *object) const - -Returns true if the list contains \a object; otherwise returns false. -*/ - -/*! -\fn N *QIntrusiveList::first() const - -Returns the first entry in this list, or null if the list is empty. -*/ - -/*! -\fn N *QIntrusiveList::next(N *current) - -Returns the next object after \a current, or null if \a current is the last object. \a current cannot be null. -*/ - -/*! -\fn iterator QIntrusiveList::begin() - -Returns an STL-style interator pointing to the first item in the list. - -\sa end() -*/ - -/*! -\fn iterator QIntrusiveList::end() - -Returns an STL-style iterator pointing to the imaginary item after the last item in the list. - -\sa begin() -*/ - -/*! -iterator &QInplacelist::iterator::erase() - -Remove the current object from the list, and return an iterator to the next element. -*/ - - -/*! -\fn QIntrusiveListNode::QIntrusiveListNode() - -Create a QIntrusiveListNode. -*/ - -/*! -\fn QIntrusiveListNode::~QIntrusiveListNode() - -Destroy the QIntrusiveListNode. If the node is in a list, it is removed. -*/ - -/*! -\fn void QIntrusiveListNode::remove() - -If in a list, remove this node otherwise do nothing. -*/ - -/*! -\fn bool QIntrusiveListNode::isInList() const - -Returns true if this node is in a list, false otherwise. -*/ - diff --git a/src/declarative/qml/ftw/qintrusivelist_p.h b/src/declarative/qml/ftw/qintrusivelist_p.h deleted file mode 100644 index fb7524c6ab..0000000000 --- a/src/declarative/qml/ftw/qintrusivelist_p.h +++ /dev/null @@ -1,274 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QINTRUSIVELIST_P_H -#define QINTRUSIVELIST_P_H - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists purely as an -// implementation detail. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - -#include - -QT_BEGIN_NAMESPACE - -class QIntrusiveListNode; -template -class QIntrusiveList -{ -public: - inline QIntrusiveList(); - inline ~QIntrusiveList(); - - inline bool isEmpty() const; - inline void insert(N *n); - inline void remove(N *n); - inline bool contains(N *) const; - - class iterator { - public: - inline iterator(); - inline iterator(N *value); - - inline N *operator*() const; - inline N *operator->() const; - inline bool operator==(const iterator &other) const; - inline bool operator!=(const iterator &other) const; - inline iterator &operator++(); - - inline iterator &erase(); - - private: - N *_value; - }; - typedef iterator Iterator; - - inline N *first() const; - static inline N *next(N *current); - - inline iterator begin(); - inline iterator end(); - -private: - static inline N *nodeToN(QIntrusiveListNode *node); - - QIntrusiveListNode *__first; -}; - -class QIntrusiveListNode -{ -public: - inline QIntrusiveListNode(); - inline ~QIntrusiveListNode(); - - inline void remove(); - inline bool isInList() const; - - QIntrusiveListNode *_next; - QIntrusiveListNode**_prev; -}; - -template -QIntrusiveList::iterator::iterator() -: _value(0) -{ -} - -template -QIntrusiveList::iterator::iterator(N *value) -: _value(value) -{ -} - -template -N *QIntrusiveList::iterator::operator*() const -{ - return _value; -} - -template -N *QIntrusiveList::iterator::operator->() const -{ - return _value; -} - -template -bool QIntrusiveList::iterator::operator==(const iterator &other) const -{ - return other._value == _value; -} - -template -bool QIntrusiveList::iterator::operator!=(const iterator &other) const -{ - return other._value != _value; -} - -template -typename QIntrusiveList::iterator &QIntrusiveList::iterator::operator++() -{ - _value = QIntrusiveList::next(_value); - return *this; -} - -template -typename QIntrusiveList::iterator &QIntrusiveList::iterator::erase() -{ - N *old = _value; - _value = QIntrusiveList::next(_value); - (old->*member).remove(); - return *this; -} - -template -QIntrusiveList::QIntrusiveList() -: __first(0) -{ -} - -template -QIntrusiveList::~QIntrusiveList() -{ - while (__first) __first->remove(); -} - -template -bool QIntrusiveList::isEmpty() const -{ - return __first == 0; -} - -template -void QIntrusiveList::insert(N *n) -{ - QIntrusiveListNode *nnode = &(n->*member); - nnode->remove(); - - nnode->_next = __first; - if (nnode->_next) nnode->_next->_prev = &nnode->_next; - __first = nnode; - nnode->_prev = &__first; -} - -template -void QIntrusiveList::remove(N *n) -{ - QIntrusiveListNode *nnode = &(n->*member); - nnode->remove(); -} - -template -bool QIntrusiveList::contains(N *n) const -{ - QIntrusiveListNode *nnode = __first; - while (nnode) { - if (nodeToN(nnode) == n) - return true; - nnode = nnode->_next; - } - return false; -} - -template -N *QIntrusiveList::first() const -{ - return __first?nodeToN(__first):0; -} - -template -N *QIntrusiveList::next(N *current) -{ - QIntrusiveListNode *nextnode = (current->*member)._next; - N *nextstruct = nextnode?nodeToN(nextnode):0; - return nextstruct; -} - -template -typename QIntrusiveList::iterator QIntrusiveList::begin() -{ - return __first?iterator(nodeToN(__first)):iterator(); -} - -template -typename QIntrusiveList::iterator QIntrusiveList::end() -{ - return iterator(); -} - -template -N *QIntrusiveList::nodeToN(QIntrusiveListNode *node) -{ - return (N *)((char *)node - ((char *)&(((N *)0)->*member) - (char *)0)); -} - -QIntrusiveListNode::QIntrusiveListNode() -: _next(0), _prev(0) -{ -} - -QIntrusiveListNode::~QIntrusiveListNode() -{ - remove(); -} - -void QIntrusiveListNode::remove() -{ - if (_prev) *_prev = _next; - if (_next) _next->_prev = _prev; - _prev = 0; - _next = 0; -} - -bool QIntrusiveListNode::isInList() const -{ - return _prev != 0; -} - -QT_END_NAMESPACE - -#endif // QINTRUSIVELIST_P_H diff --git a/src/declarative/qml/ftw/qlazilyallocated_p.h b/src/declarative/qml/ftw/qlazilyallocated_p.h deleted file mode 100644 index d5a9dcc3ec..0000000000 --- a/src/declarative/qml/ftw/qlazilyallocated_p.h +++ /dev/null @@ -1,146 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QLAZILYALLOCATED_P_H -#define QLAZILYALLOCATED_P_H - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists purely as an -// implementation detail. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - -#include - -#include - -QT_BEGIN_NAMESPACE - -template -class QLazilyAllocated { -public: - inline QLazilyAllocated(); - inline ~QLazilyAllocated(); - - inline bool isAllocated() const; - - inline T *operator->() const; - - inline T &value(); - inline const T &value() const; - - inline bool flag() const; - inline void setFlag(); - inline void clearFlag(); - inline void setFlagValue(bool); -private: - mutable QFlagPointer d; -}; - -template -QLazilyAllocated::QLazilyAllocated() -{ -} - -template -QLazilyAllocated::~QLazilyAllocated() -{ - delete *d; -} - -template -bool QLazilyAllocated::isAllocated() const -{ - return !d.isNull(); -} - -template -T &QLazilyAllocated::value() -{ - if (d.isNull()) d = new T; - return *(*d); -} - -template -const T &QLazilyAllocated::value() const -{ - if (d.isNull()) d = new T; - return *(*d); -} - -template -T *QLazilyAllocated::operator->() const -{ - return *d; -} - -template -bool QLazilyAllocated::flag() const -{ - return d.flag(); -} - -template -void QLazilyAllocated::setFlag() -{ - d.setFlag(); -} - -template -void QLazilyAllocated::clearFlag() -{ - d.clearFlag(); -} - -template -void QLazilyAllocated::setFlagValue(bool v) -{ - d.setFlagValue(v); -} - -QT_END_NAMESPACE - -#endif // QLAZILYALLOCATED_P_H diff --git a/src/declarative/qml/ftw/qpodvector_p.h b/src/declarative/qml/ftw/qpodvector_p.h deleted file mode 100644 index 66f970f100..0000000000 --- a/src/declarative/qml/ftw/qpodvector_p.h +++ /dev/null @@ -1,173 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QPODVECTOR_P_H -#define QPODVECTOR_P_H - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists purely as an -// implementation detail. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - -#include -#include - -QT_BEGIN_NAMESPACE - -template -class QPODVector -{ -public: - QPODVector() - : m_count(0), m_capacity(0), m_data(0) {} - ~QPODVector() { if (m_data) ::free(m_data); } - - const T &at(int idx) const { - return m_data[idx]; - } - - T &operator[](int idx) { - return m_data[idx]; - } - - void clear() { - m_count = 0; - } - - void prepend(const T &v) { - insert(0, v); - } - - void append(const T &v) { - insert(m_count, v); - } - - void insert(int idx, const T &v) { - if (m_count == m_capacity) { - m_capacity += Increment; - m_data = (T *)realloc(m_data, m_capacity * sizeof(T)); - } - int moveCount = m_count - idx; - if (moveCount) - ::memmove(m_data + idx + 1, m_data + idx, moveCount * sizeof(T)); - m_count++; - m_data[idx] = v; - } - - void reserve(int count) { - if (count >= m_capacity) { - m_capacity = (count + (Increment-1)) & (0xFFFFFFFF - Increment + 1); - m_data = (T *)realloc(m_data, m_capacity * sizeof(T)); - } - } - - void insertBlank(int idx, int count) { - int newSize = m_count + count; - reserve(newSize); - int moveCount = m_count - idx; - if (moveCount) - ::memmove(m_data + idx + count, m_data + idx, - moveCount * sizeof(T)); - m_count = newSize; - } - - void remove(int idx, int count = 1) { - int moveCount = m_count - (idx + count); - if (moveCount) - ::memmove(m_data + idx, m_data + idx + count, - moveCount * sizeof(T)); - m_count -= count; - } - - void removeOne(const T &v) { - int idx = 0; - while (idx < m_count) { - if (m_data[idx] == v) { - remove(idx); - return; - } - ++idx; - } - } - - int find(const T &v) { - for (int idx = 0; idx < m_count; ++idx) - if (m_data[idx] == v) - return idx; - return -1; - } - - bool contains(const T &v) { - return find(v) != -1; - } - - int count() const { - return m_count; - } - - void copyAndClear(QPODVector &other) { - if (other.m_data) ::free(other.m_data); - other.m_count = m_count; - other.m_capacity = m_capacity; - other.m_data = m_data; - m_count = 0; - m_capacity = 0; - m_data = 0; - } - - QPODVector &operator<<(const T &v) { append(v); return *this; } -private: - QPODVector(const QPODVector &); - QPODVector &operator=(const QPODVector &); - int m_count; - int m_capacity; - T *m_data; -}; - -QT_END_NAMESPACE - -#endif diff --git a/src/declarative/qml/ftw/qpointervaluepair_p.h b/src/declarative/qml/ftw/qpointervaluepair_p.h deleted file mode 100644 index fd1a77004e..0000000000 --- a/src/declarative/qml/ftw/qpointervaluepair_p.h +++ /dev/null @@ -1,196 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QPOINTERVALUEPAIR_P_H -#define QPOINTERVALUEPAIR_P_H - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists purely as an -// implementation detail. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - -#include -#include - -QT_BEGIN_NAMESPACE - -// QPointerValuePair is intended to help reduce the memory consumption of a class. -// In the common case, QPointerValuePair behaves like a pointer. In this mode, it -// consumes the same memory as a regular pointer. -// Additionally, QPointerValuePair can store an arbitrary value type in *addition* -// to the pointer. In this case, it uses slightly more memory than the pointer and -// value type combined. -// Consequently, this class is most useful in cases where a pointer is always stored -// and a value type is rarely stored. -template -class QPointerValuePair { -public: - inline QPointerValuePair(); - inline QPointerValuePair(P *); - inline ~QPointerValuePair(); - - inline bool isNull() const; - - inline bool flag() const; - inline void setFlag(); - inline void clearFlag(); - inline void setFlagValue(bool); - - inline QPointerValuePair &operator=(P *); - - inline P *operator->() const; - inline P *operator*() const; - - inline bool hasValue() const; - inline V &value(); - inline const V *constValue() const; - -private: - struct Value { P *pointer; V value; }; - QBiPointer d; -}; - -template -QPointerValuePair::QPointerValuePair() -{ -} - -template -QPointerValuePair::QPointerValuePair(P *p) -: d(p) -{ -} - -template -QPointerValuePair::~QPointerValuePair() -{ - if (d.isT2()) delete d.asT2(); -} - -template -bool QPointerValuePair::isNull() const -{ - if (d.isT1()) return 0 == d.asT1(); - else return d.asT2()->pointer == 0; -} - -template -bool QPointerValuePair::flag() const -{ - return d.flag(); -} - -template -void QPointerValuePair::setFlag() -{ - d.setFlag(); -} - -template -void QPointerValuePair::clearFlag() -{ - d.clearFlag(); -} - -template -void QPointerValuePair::setFlagValue(bool v) -{ - d.setFlagValue(v); -} - -template -QPointerValuePair &QPointerValuePair::operator=(P *o) -{ - if (d.isT1()) d = o; - else d.asT2()->pointer = o; - return *this; -} - -template -P *QPointerValuePair::operator->() const -{ - if (d.isT1()) return d.asT1(); - else return d.asT2()->pointer; -} - -template -P *QPointerValuePair::operator*() const -{ - if (d.isT1()) return d.asT1(); - else return d.asT2()->pointer; -} - -template -bool QPointerValuePair::hasValue() const -{ - return d.isT2(); -} - -template -V &QPointerValuePair::value() -{ - if (d.isT1()) { - P *p = d.asT1(); - Value *value = new Value; - value->pointer = p; - d = value; - } - - return d.asT2()->value; -} - -// Will return null if hasValue() == false -template -const V *QPointerValuePair::constValue() const -{ - if (d.isT2()) return &d.asT2()->value; - else return 0; -} - -QT_END_NAMESPACE - -#endif // QPOINTERVALUEPAIR_P_H diff --git a/src/declarative/qml/ftw/qrecursionwatcher_p.h b/src/declarative/qml/ftw/qrecursionwatcher_p.h deleted file mode 100644 index e68ec424aa..0000000000 --- a/src/declarative/qml/ftw/qrecursionwatcher_p.h +++ /dev/null @@ -1,105 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QRECURSIONWATCHER_P_H -#define QRECURSIONWATCHER_P_H - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists purely as an -// implementation detail. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - -#include - -QT_BEGIN_NAMESPACE - -class QRecursionNode; -class QRecursionNode { -public: - inline QRecursionNode(); - bool *_r; -}; - -template -class QRecursionWatcher { -public: - inline QRecursionWatcher(T *); - inline ~QRecursionWatcher(); - inline bool hasRecursed() const; -private: - T *_t; - bool _r; -}; - -QRecursionNode::QRecursionNode() -: _r(0) -{ -} - -template -QRecursionWatcher::QRecursionWatcher(T *t) -: _t(t), _r(false) -{ - if ((_t->*Node)._r) *(_t->*Node)._r = true; - (_t->*Node)._r = &_r; -} - -template -QRecursionWatcher::~QRecursionWatcher() -{ - if ((_t->*Node)._r == &_r) (_t->*Node)._r = 0; -} - -template -bool QRecursionWatcher::hasRecursed() const -{ - return _r; -} - -QT_END_NAMESPACE - -#endif // QRECURSIONWATCHER_P_H diff --git a/src/declarative/qml/ftw/qrecyclepool_p.h b/src/declarative/qml/ftw/qrecyclepool_p.h deleted file mode 100644 index ed0bbbdd27..0000000000 --- a/src/declarative/qml/ftw/qrecyclepool_p.h +++ /dev/null @@ -1,220 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QRECYCLEPOOL_P_H -#define QRECYCLEPOOL_P_H - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists purely as an -// implementation detail. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - -QT_BEGIN_NAMESPACE - -#define QRECYCLEPOOLCOOKIE 0x33218ADF - -template -class QRecyclePoolPrivate -{ -public: - QRecyclePoolPrivate() - : recyclePoolHold(true), outstandingItems(0), cookie(QRECYCLEPOOLCOOKIE), - currentPage(0), nextAllocated(0) - { - } - - bool recyclePoolHold; - int outstandingItems; - quint32 cookie; - - struct PoolType : public T { - union { - QRecyclePoolPrivate *pool; - PoolType *nextAllocated; - }; - }; - - struct Page { - Page *nextPage; - unsigned int free; - union { - char array[Step * sizeof(PoolType)]; - qint64 q_for_alignment_1; - double q_for_alignment_2; - }; - }; - - Page *currentPage; - PoolType *nextAllocated; - - inline T *allocate(); - static inline void dispose(T *); - inline void releaseIfPossible(); -}; - -template -class QRecyclePool -{ -public: - inline QRecyclePool(); - inline ~QRecyclePool(); - - inline T *New(); - template - inline T *New(const T1 &); - template - inline T *New(T1 &); - - static inline void Delete(T *); - -private: - QRecyclePoolPrivate *d; -}; - -template -QRecyclePool::QRecyclePool() -: d(new QRecyclePoolPrivate()) -{ -} - -template -QRecyclePool::~QRecyclePool() -{ - d->recyclePoolHold = false; - d->releaseIfPossible(); -} - -template -T *QRecyclePool::New() -{ - T *rv = d->allocate(); - new (rv) T; - return rv; -} - -template -template -T *QRecyclePool::New(const T1 &a) -{ - T *rv = d->allocate(); - new (rv) T(a); - return rv; -} - -template -template -T *QRecyclePool::New(T1 &a) -{ - T *rv = d->allocate(); - new (rv) T(a); - return rv; -} - -template -void QRecyclePool::Delete(T *t) -{ - t->~T(); - QRecyclePoolPrivate::dispose(t); -} - -template -void QRecyclePoolPrivate::releaseIfPossible() -{ - if (recyclePoolHold || outstandingItems) - return; - - Page *p = currentPage; - while (p) { - Page *n = p->nextPage; - qFree(p); - p = n; - } - - delete this; -} - -template -T *QRecyclePoolPrivate::allocate() -{ - PoolType *rv = 0; - if (nextAllocated) { - rv = nextAllocated; - nextAllocated = rv->nextAllocated; - } else if (currentPage && currentPage->free) { - rv = (PoolType *)(currentPage->array + (Step - currentPage->free) * sizeof(PoolType)); - currentPage->free--; - } else { - Page *p = (Page *)qMalloc(sizeof(Page)); - p->nextPage = currentPage; - p->free = Step; - currentPage = p; - - rv = (PoolType *)currentPage->array; - currentPage->free--; - } - - rv->pool = this; - ++outstandingItems; - return rv; -} - -template -void QRecyclePoolPrivate::dispose(T *t) -{ - PoolType *pt = static_cast(t); - Q_ASSERT(pt->pool && pt->pool->cookie == QRECYCLEPOOLCOOKIE); - - QRecyclePoolPrivate *This = pt->pool; - pt->nextAllocated = This->nextAllocated; - This->nextAllocated = pt; - --This->outstandingItems; - This->releaseIfPossible(); -} - -QT_END_NAMESPACE - -#endif // QRECYCLEPOOL_P_H diff --git a/src/declarative/qml/parser/parser.pri b/src/declarative/qml/parser/parser.pri deleted file mode 100644 index 3ae0a6d8eb..0000000000 --- a/src/declarative/qml/parser/parser.pri +++ /dev/null @@ -1,19 +0,0 @@ -HEADERS += \ - $$PWD/qdeclarativejsast_p.h \ - $$PWD/qdeclarativejsastfwd_p.h \ - $$PWD/qdeclarativejsastvisitor_p.h \ - $$PWD/qdeclarativejsengine_p.h \ - $$PWD/qdeclarativejsgrammar_p.h \ - $$PWD/qdeclarativejslexer_p.h \ - $$PWD/qdeclarativejsmemorypool_p.h \ - $$PWD/qdeclarativejsparser_p.h \ - $$PWD/qdeclarativejsglobal_p.h \ - $$PWD/qdeclarativejskeywords_p.h - -SOURCES += \ - $$PWD/qdeclarativejsast.cpp \ - $$PWD/qdeclarativejsastvisitor.cpp \ - $$PWD/qdeclarativejsengine_p.cpp \ - $$PWD/qdeclarativejsgrammar.cpp \ - $$PWD/qdeclarativejslexer.cpp \ - $$PWD/qdeclarativejsparser.cpp diff --git a/src/declarative/qml/parser/qdeclarativejs.g b/src/declarative/qml/parser/qdeclarativejs.g deleted file mode 100644 index b87f9f8a65..0000000000 --- a/src/declarative/qml/parser/qdeclarativejs.g +++ /dev/null @@ -1,3016 +0,0 @@ ----------------------------------------------------------------------------- --- --- Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). --- Contact: http://www.qt-project.org/ --- --- This file is part of the QtDeclarative module of the Qt Toolkit. --- --- $QT_BEGIN_LICENSE:LGPL-ONLY$ --- GNU Lesser General Public License Usage --- This file may be used under the terms of the GNU Lesser --- General Public License version 2.1 as published by the Free Software --- Foundation and appearing in the file LICENSE.LGPL included in the --- packaging of this file. Please review the following information to --- ensure the GNU Lesser General Public License version 2.1 requirements --- will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. --- --- If you have questions regarding the use of this file, please contact --- us via http://www.qt-project.org/. --- --- $QT_END_LICENSE$ --- ----------------------------------------------------------------------------- - -%parser QDeclarativeJSGrammar -%decl qdeclarativejsparser_p.h -%impl qdeclarativejsparser.cpp -%expect 2 -%expect-rr 2 - -%token T_AND "&" T_AND_AND "&&" T_AND_EQ "&=" -%token T_BREAK "break" T_CASE "case" T_CATCH "catch" -%token T_COLON ":" T_COMMA "," T_CONTINUE "continue" -%token T_DEFAULT "default" T_DELETE "delete" T_DIVIDE_ "/" -%token T_DIVIDE_EQ "/=" T_DO "do" T_DOT "." -%token T_ELSE "else" T_EQ "=" T_EQ_EQ "==" -%token T_EQ_EQ_EQ "===" T_FINALLY "finally" T_FOR "for" -%token T_FUNCTION "function" T_GE ">=" T_GT ">" -%token T_GT_GT ">>" T_GT_GT_EQ ">>=" T_GT_GT_GT ">>>" -%token T_GT_GT_GT_EQ ">>>=" T_IDENTIFIER "identifier" T_IF "if" -%token T_IN "in" T_INSTANCEOF "instanceof" T_LBRACE "{" -%token T_LBRACKET "[" T_LE "<=" T_LPAREN "(" -%token T_LT "<" T_LT_LT "<<" T_LT_LT_EQ "<<=" -%token T_MINUS "-" T_MINUS_EQ "-=" T_MINUS_MINUS "--" -%token T_NEW "new" T_NOT "!" T_NOT_EQ "!=" -%token T_NOT_EQ_EQ "!==" T_NUMERIC_LITERAL "numeric literal" T_OR "|" -%token T_OR_EQ "|=" T_OR_OR "||" T_PLUS "+" -%token T_PLUS_EQ "+=" T_PLUS_PLUS "++" T_QUESTION "?" -%token T_RBRACE "}" T_RBRACKET "]" T_REMAINDER "%" -%token T_REMAINDER_EQ "%=" T_RETURN "return" T_RPAREN ")" -%token T_SEMICOLON ";" T_AUTOMATIC_SEMICOLON T_STAR "*" -%token T_STAR_EQ "*=" T_STRING_LITERAL "string literal" -%token T_PROPERTY "property" T_SIGNAL "signal" T_READONLY "readonly" -%token T_SWITCH "switch" T_THIS "this" T_THROW "throw" -%token T_TILDE "~" T_TRY "try" T_TYPEOF "typeof" -%token T_VAR "var" T_VOID "void" T_WHILE "while" -%token T_WITH "with" T_XOR "^" T_XOR_EQ "^=" -%token T_NULL "null" T_TRUE "true" T_FALSE "false" -%token T_CONST "const" -%token T_DEBUGGER "debugger" -%token T_RESERVED_WORD "reserved word" -%token T_MULTILINE_STRING_LITERAL "multiline string literal" -%token T_COMMENT "comment" - ---- context keywords. -%token T_PUBLIC "public" -%token T_IMPORT "import" -%token T_AS "as" -%token T_ON "on" - -%token T_ERROR - ---- feed tokens -%token T_FEED_UI_PROGRAM -%token T_FEED_UI_OBJECT_MEMBER -%token T_FEED_JS_STATEMENT -%token T_FEED_JS_EXPRESSION -%token T_FEED_JS_SOURCE_ELEMENT -%token T_FEED_JS_PROGRAM - -%nonassoc SHIFT_THERE -%nonassoc T_IDENTIFIER T_COLON T_SIGNAL T_PROPERTY T_READONLY -%nonassoc REDUCE_HERE - -%start TopLevel - -/./**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include -#include - -#include - -#include "qdeclarativejsengine_p.h" -#include "qdeclarativejslexer_p.h" -#include "qdeclarativejsast_p.h" -#include "qdeclarativejsmemorypool_p.h" - -./ - -/:/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists purely as an -// implementation detail. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - -// -// This file is automatically generated from qmljs.g. -// Changes will be lost. -// - -#ifndef QDECLARATIVEJSPARSER_P_H -#define QDECLARATIVEJSPARSER_P_H - -#include "qdeclarativejsglobal_p.h" -#include "qdeclarativejsgrammar_p.h" -#include "qdeclarativejsast_p.h" -#include "qdeclarativejsengine_p.h" - -#include -#include - -QT_QML_BEGIN_NAMESPACE - -namespace QDeclarativeJS { - -class Engine; - -class QML_PARSER_EXPORT Parser: protected $table -{ -public: - union Value { - int ival; - double dval; - AST::ArgumentList *ArgumentList; - AST::CaseBlock *CaseBlock; - AST::CaseClause *CaseClause; - AST::CaseClauses *CaseClauses; - AST::Catch *Catch; - AST::DefaultClause *DefaultClause; - AST::ElementList *ElementList; - AST::Elision *Elision; - AST::ExpressionNode *Expression; - AST::Finally *Finally; - AST::FormalParameterList *FormalParameterList; - AST::FunctionBody *FunctionBody; - AST::FunctionDeclaration *FunctionDeclaration; - AST::Node *Node; - AST::PropertyName *PropertyName; - AST::PropertyNameAndValueList *PropertyNameAndValueList; - AST::SourceElement *SourceElement; - AST::SourceElements *SourceElements; - AST::Statement *Statement; - AST::StatementList *StatementList; - AST::Block *Block; - AST::VariableDeclaration *VariableDeclaration; - AST::VariableDeclarationList *VariableDeclarationList; - - AST::UiProgram *UiProgram; - AST::UiImportList *UiImportList; - AST::UiImport *UiImport; - AST::UiParameterList *UiParameterList; - AST::UiPublicMember *UiPublicMember; - AST::UiObjectDefinition *UiObjectDefinition; - AST::UiObjectInitializer *UiObjectInitializer; - AST::UiObjectBinding *UiObjectBinding; - AST::UiScriptBinding *UiScriptBinding; - AST::UiArrayBinding *UiArrayBinding; - AST::UiObjectMember *UiObjectMember; - AST::UiObjectMemberList *UiObjectMemberList; - AST::UiArrayMemberList *UiArrayMemberList; - AST::UiQualifiedId *UiQualifiedId; - }; - -public: - Parser(Engine *engine); - ~Parser(); - - // parse a UI program - bool parse() { return parse(T_FEED_UI_PROGRAM); } - bool parseStatement() { return parse(T_FEED_JS_STATEMENT); } - bool parseExpression() { return parse(T_FEED_JS_EXPRESSION); } - bool parseSourceElement() { return parse(T_FEED_JS_SOURCE_ELEMENT); } - bool parseUiObjectMember() { return parse(T_FEED_UI_OBJECT_MEMBER); } - bool parseProgram() { return parse(T_FEED_JS_PROGRAM); } - - AST::UiProgram *ast() const - { return AST::cast(program); } - - AST::Statement *statement() const - { - if (! program) - return 0; - - return program->statementCast(); - } - - AST::ExpressionNode *expression() const - { - if (! program) - return 0; - - return program->expressionCast(); - } - - AST::UiObjectMember *uiObjectMember() const - { - if (! program) - return 0; - - return program->uiObjectMemberCast(); - } - - AST::Node *rootNode() const - { return program; } - - QList diagnosticMessages() const - { return diagnostic_messages; } - - inline DiagnosticMessage diagnosticMessage() const - { - foreach (const DiagnosticMessage &d, diagnostic_messages) { - if (! d.kind == DiagnosticMessage::Warning) - return d; - } - - return DiagnosticMessage(); - } - - inline QString errorMessage() const - { return diagnosticMessage().message; } - - inline int errorLineNumber() const - { return diagnosticMessage().loc.startLine; } - - inline int errorColumnNumber() const - { return diagnosticMessage().loc.startColumn; } - -protected: - bool parse(int startToken); - - void reallocateStack(); - - inline Value &sym(int index) - { return sym_stack [tos + index - 1]; } - - inline QStringRef &stringRef(int index) - { return string_stack [tos + index - 1]; } - - inline AST::SourceLocation &loc(int index) - { return location_stack [tos + index - 1]; } - - AST::UiQualifiedId *reparseAsQualifiedId(AST::ExpressionNode *expr); - -protected: - Engine *driver; - MemoryPool *pool; - int tos; - int stack_size; - Value *sym_stack; - int *state_stack; - AST::SourceLocation *location_stack; - QStringRef *string_stack; - - AST::Node *program; - - // error recovery - enum { TOKEN_BUFFER_SIZE = 3 }; - - struct SavedToken { - int token; - double dval; - AST::SourceLocation loc; - QStringRef spell; - }; - - double yylval; - QStringRef yytokenspell; - AST::SourceLocation yylloc; - AST::SourceLocation yyprevlloc; - - SavedToken token_buffer[TOKEN_BUFFER_SIZE]; - SavedToken *first_token; - SavedToken *last_token; - - QList diagnostic_messages; -}; - -} // end of namespace QDeclarativeJS - - -:/ - - -/. - -#include "qdeclarativejsparser_p.h" -#include - -// -// This file is automatically generated from qmljs.g. -// Changes will be lost. -// - -using namespace QDeclarativeJS; - -QT_QML_BEGIN_NAMESPACE - -void Parser::reallocateStack() -{ - if (! stack_size) - stack_size = 128; - else - stack_size <<= 1; - - sym_stack = reinterpret_cast (realloc(sym_stack, stack_size * sizeof(Value))); - state_stack = reinterpret_cast (realloc(state_stack, stack_size * sizeof(int))); - location_stack = reinterpret_cast (realloc(location_stack, stack_size * sizeof(AST::SourceLocation))); - string_stack = reinterpret_cast (realloc(string_stack, stack_size * sizeof(QStringRef))); -} - -Parser::Parser(Engine *engine): - driver(engine), - pool(engine->pool()), - tos(0), - stack_size(0), - sym_stack(0), - state_stack(0), - location_stack(0), - string_stack(0), - first_token(0), - last_token(0) -{ -} - -Parser::~Parser() -{ - if (stack_size) { - free(sym_stack); - free(state_stack); - free(location_stack); - free(string_stack); - } -} - -static inline AST::SourceLocation location(Lexer *lexer) -{ - AST::SourceLocation loc; - loc.offset = lexer->tokenOffset(); - loc.length = lexer->tokenLength(); - loc.startLine = lexer->tokenStartLine(); - loc.startColumn = lexer->tokenStartColumn(); - return loc; -} - -AST::UiQualifiedId *Parser::reparseAsQualifiedId(AST::ExpressionNode *expr) -{ - QVarLengthArray nameIds; - QVarLengthArray locations; - - AST::ExpressionNode *it = expr; - while (AST::FieldMemberExpression *m = AST::cast(it)) { - nameIds.append(m->name); - locations.append(m->identifierToken); - it = m->base; - } - - if (AST::IdentifierExpression *idExpr = AST::cast(it)) { - AST::UiQualifiedId *q = new (pool) AST::UiQualifiedId(idExpr->name); - q->identifierToken = idExpr->identifierToken; - - AST::UiQualifiedId *currentId = q; - for (int i = nameIds.size() - 1; i != -1; --i) { - currentId = new (pool) AST::UiQualifiedId(currentId, nameIds[i]); - currentId->identifierToken = locations[i]; - } - - return currentId->finish(); - } - - return 0; -} - -bool Parser::parse(int startToken) -{ - Lexer *lexer = driver->lexer(); - bool hadErrors = false; - int yytoken = -1; - int action = 0; - - token_buffer[0].token = startToken; - first_token = &token_buffer[0]; - last_token = &token_buffer[1]; - - tos = -1; - program = 0; - - do { - if (++tos == stack_size) - reallocateStack(); - - state_stack[tos] = action; - - _Lcheck_token: - if (yytoken == -1 && -TERMINAL_COUNT != action_index[action]) { - yyprevlloc = yylloc; - - if (first_token == last_token) { - yytoken = lexer->lex(); - yylval = lexer->tokenValue(); - yytokenspell = lexer->tokenSpell(); - yylloc = location(lexer); - } else { - yytoken = first_token->token; - yylval = first_token->dval; - yytokenspell = first_token->spell; - yylloc = first_token->loc; - ++first_token; - } - } - - action = t_action(action, yytoken); - if (action > 0) { - if (action != ACCEPT_STATE) { - yytoken = -1; - sym(1).dval = yylval; - stringRef(1) = yytokenspell; - loc(1) = yylloc; - } else { - --tos; - return ! hadErrors; - } - } else if (action < 0) { - const int r = -action - 1; - tos -= rhs[r]; - - switch (r) { -./ - --------------------------------------------------------------------------------------------------------- --- Declarative UI --------------------------------------------------------------------------------------------------------- - -TopLevel: T_FEED_UI_PROGRAM UiProgram ; -/. -case $rule_number: { - sym(1).Node = sym(2).Node; - program = sym(1).Node; -} break; -./ - -TopLevel: T_FEED_JS_STATEMENT Statement ; -/. -case $rule_number: { - sym(1).Node = sym(2).Node; - program = sym(1).Node; -} break; -./ - -TopLevel: T_FEED_JS_EXPRESSION Expression ; -/. -case $rule_number: { - sym(1).Node = sym(2).Node; - program = sym(1).Node; -} break; -./ - -TopLevel: T_FEED_JS_SOURCE_ELEMENT SourceElement ; -/. -case $rule_number: { - sym(1).Node = sym(2).Node; - program = sym(1).Node; -} break; -./ - -TopLevel: T_FEED_UI_OBJECT_MEMBER UiObjectMember ; -/. -case $rule_number: { - sym(1).Node = sym(2).Node; - program = sym(1).Node; -} break; -./ - -TopLevel: T_FEED_JS_PROGRAM Program ; -/. -case $rule_number: { - sym(1).Node = sym(2).Node; - program = sym(1).Node; -} break; -./ - -UiProgram: UiImportListOpt UiRootMember ; -/. -case $rule_number: { - sym(1).UiProgram = new (pool) AST::UiProgram(sym(1).UiImportList, - sym(2).UiObjectMemberList->finish()); -} break; -./ - -UiImportListOpt: Empty ; -UiImportListOpt: UiImportList ; -/. -case $rule_number: { - sym(1).Node = sym(1).UiImportList->finish(); -} break; -./ - -UiImportList: UiImport ; -/. -case $rule_number: { - sym(1).Node = new (pool) AST::UiImportList(sym(1).UiImport); -} break; -./ - -UiImportList: UiImportList UiImport ; -/. -case $rule_number: { - sym(1).Node = new (pool) AST::UiImportList(sym(1).UiImportList, sym(2).UiImport); -} break; -./ - -ImportId: MemberExpression ; - -UiImport: UiImportHead T_AUTOMATIC_SEMICOLON ; -UiImport: UiImportHead T_SEMICOLON ; -/. -case $rule_number: { - sym(1).UiImport->semicolonToken = loc(2); -} break; -./ - -UiImport: UiImportHead T_NUMERIC_LITERAL T_AUTOMATIC_SEMICOLON ; -UiImport: UiImportHead T_NUMERIC_LITERAL T_SEMICOLON ; -/. -case $rule_number: { - sym(1).UiImport->versionToken = loc(2); - sym(1).UiImport->semicolonToken = loc(3); -} break; -./ - -UiImport: UiImportHead T_NUMERIC_LITERAL T_AS JsIdentifier T_AUTOMATIC_SEMICOLON ; -UiImport: UiImportHead T_NUMERIC_LITERAL T_AS JsIdentifier T_SEMICOLON ; -/. -case $rule_number: { - sym(1).UiImport->versionToken = loc(2); - sym(1).UiImport->asToken = loc(3); - sym(1).UiImport->importIdToken = loc(4); - sym(1).UiImport->importId = stringRef(4); - sym(1).UiImport->semicolonToken = loc(5); -} break; -./ - -UiImport: UiImportHead T_AS JsIdentifier T_AUTOMATIC_SEMICOLON ; -UiImport: UiImportHead T_AS JsIdentifier T_SEMICOLON ; -/. -case $rule_number: { - sym(1).UiImport->asToken = loc(2); - sym(1).UiImport->importIdToken = loc(3); - sym(1).UiImport->importId = stringRef(3); - sym(1).UiImport->semicolonToken = loc(4); -} break; -./ - - -UiImportHead: T_IMPORT ImportId ; -/. -case $rule_number: { - AST::UiImport *node = 0; - - if (AST::StringLiteral *importIdLiteral = AST::cast(sym(2).Expression)) { - node = new (pool) AST::UiImport(importIdLiteral->value); - node->fileNameToken = loc(2); - } else if (AST::UiQualifiedId *qualifiedId = reparseAsQualifiedId(sym(2).Expression)) { - node = new (pool) AST::UiImport(qualifiedId); - node->fileNameToken = loc(2); - } - - sym(1).Node = node; - - if (node) { - node->importToken = loc(1); - } else { - diagnostic_messages.append(DiagnosticMessage(DiagnosticMessage::Error, loc(1), - QLatin1String("Expected a qualified name id or a string literal"))); - - return false; // ### remove me - } -} break; -./ - -Empty: ; -/. -case $rule_number: { - sym(1).Node = 0; -} break; -./ - -UiRootMember: UiObjectDefinition ; -/. -case $rule_number: { - sym(1).Node = new (pool) AST::UiObjectMemberList(sym(1).UiObjectMember); -} break; -./ - -UiObjectMemberList: UiObjectMember ; -/. -case $rule_number: { - sym(1).Node = new (pool) AST::UiObjectMemberList(sym(1).UiObjectMember); -} break; -./ - -UiObjectMemberList: UiObjectMemberList UiObjectMember ; -/. -case $rule_number: { - AST::UiObjectMemberList *node = new (pool) AST:: UiObjectMemberList( - sym(1).UiObjectMemberList, sym(2).UiObjectMember); - sym(1).Node = node; -} break; -./ - -UiArrayMemberList: UiObjectDefinition ; -/. -case $rule_number: { - sym(1).Node = new (pool) AST::UiArrayMemberList(sym(1).UiObjectMember); -} break; -./ - -UiArrayMemberList: UiArrayMemberList T_COMMA UiObjectDefinition ; -/. -case $rule_number: { - AST::UiArrayMemberList *node = new (pool) AST::UiArrayMemberList( - sym(1).UiArrayMemberList, sym(3).UiObjectMember); - node->commaToken = loc(2); - sym(1).Node = node; -} break; -./ - -UiObjectInitializer: T_LBRACE T_RBRACE ; -/. -case $rule_number: { - AST::UiObjectInitializer *node = new (pool) AST::UiObjectInitializer((AST::UiObjectMemberList*)0); - node->lbraceToken = loc(1); - node->rbraceToken = loc(2); - sym(1).Node = node; -} break; -./ - -UiObjectInitializer: T_LBRACE UiObjectMemberList T_RBRACE ; -/. -case $rule_number: { - AST::UiObjectInitializer *node = new (pool) AST::UiObjectInitializer(sym(2).UiObjectMemberList->finish()); - node->lbraceToken = loc(1); - node->rbraceToken = loc(3); - sym(1).Node = node; -} break; -./ - -UiObjectDefinition: UiQualifiedId UiObjectInitializer ; -/. -case $rule_number: { - AST::UiObjectDefinition *node = new (pool) AST::UiObjectDefinition(sym(1).UiQualifiedId, - sym(2).UiObjectInitializer); - sym(1).Node = node; -} break; -./ - -UiObjectMember: UiObjectDefinition ; - -UiObjectMember: UiQualifiedId T_COLON T_LBRACKET UiArrayMemberList T_RBRACKET ; -/. -case $rule_number: { - AST::UiArrayBinding *node = new (pool) AST::UiArrayBinding( - sym(1).UiQualifiedId, sym(4).UiArrayMemberList->finish()); - node->colonToken = loc(2); - node->lbracketToken = loc(3); - node->rbracketToken = loc(5); - sym(1).Node = node; -} break; -./ - -UiObjectMember: UiQualifiedId T_COLON UiQualifiedId UiObjectInitializer ; -/. -case $rule_number: { - AST::UiObjectBinding *node = new (pool) AST::UiObjectBinding( - sym(1).UiQualifiedId, sym(3).UiQualifiedId, sym(4).UiObjectInitializer); - node->colonToken = loc(2); - sym(1).Node = node; -} break; -./ - -UiObjectMember: UiQualifiedId T_ON UiQualifiedId UiObjectInitializer ; -/. -case $rule_number: { - AST::UiObjectBinding *node = new (pool) AST::UiObjectBinding( - sym(3).UiQualifiedId, sym(1).UiQualifiedId, sym(4).UiObjectInitializer); - node->colonToken = loc(2); - node->hasOnToken = true; - sym(1).Node = node; -} break; -./ - -UiScriptStatement: Block ; -UiScriptStatement: EmptyStatement ; -UiScriptStatement: ExpressionStatement ; -UiScriptStatement: IfStatement ; -UiScriptStatement: WithStatement ; -UiScriptStatement: SwitchStatement ; -UiScriptStatement: TryStatement ; - -UiObjectMember: UiQualifiedId T_COLON UiScriptStatement ; -/. -case $rule_number: -{ - AST::UiScriptBinding *node = new (pool) AST::UiScriptBinding( - sym(1).UiQualifiedId, sym(3).Statement); - node->colonToken = loc(2); - sym(1).Node = node; -} break; -./ - -UiPropertyType: T_VAR ; -UiPropertyType: T_RESERVED_WORD ; -UiPropertyType: T_IDENTIFIER ; - -UiParameterListOpt: ; -/. -case $rule_number: { - sym(1).Node = 0; -} break; -./ - -UiParameterListOpt: UiParameterList ; -/. -case $rule_number: { - sym(1).Node = sym(1).UiParameterList->finish (); -} break; -./ - -UiParameterList: UiPropertyType JsIdentifier ; -/. -case $rule_number: { - AST::UiParameterList *node = new (pool) AST::UiParameterList(stringRef(1), stringRef(2)); - node->propertyTypeToken = loc(1); - node->identifierToken = loc(2); - sym(1).Node = node; -} break; -./ - -UiParameterList: UiParameterList T_COMMA UiPropertyType JsIdentifier ; -/. -case $rule_number: { - AST::UiParameterList *node = new (pool) AST::UiParameterList(sym(1).UiParameterList, stringRef(3), stringRef(4)); - node->commaToken = loc(2); - node->identifierToken = loc(4); - sym(1).Node = node; -} break; -./ - -UiObjectMember: T_SIGNAL T_IDENTIFIER T_LPAREN UiParameterListOpt T_RPAREN T_AUTOMATIC_SEMICOLON ; -UiObjectMember: T_SIGNAL T_IDENTIFIER T_LPAREN UiParameterListOpt T_RPAREN T_SEMICOLON ; -/. -case $rule_number: { - AST::UiPublicMember *node = new (pool) AST::UiPublicMember(QStringRef(), stringRef(2)); - node->type = AST::UiPublicMember::Signal; - node->propertyToken = loc(1); - node->typeToken = loc(2); - node->identifierToken = loc(2); - node->parameters = sym(4).UiParameterList; - node->semicolonToken = loc(6); - sym(1).Node = node; -} break; -./ - -UiObjectMember: T_SIGNAL T_IDENTIFIER T_AUTOMATIC_SEMICOLON ; -UiObjectMember: T_SIGNAL T_IDENTIFIER T_SEMICOLON ; -/. -case $rule_number: { - AST::UiPublicMember *node = new (pool) AST::UiPublicMember(QStringRef(), stringRef(2)); - node->type = AST::UiPublicMember::Signal; - node->propertyToken = loc(1); - node->typeToken = loc(2); - node->identifierToken = loc(2); - node->semicolonToken = loc(3); - sym(1).Node = node; -} break; -./ - -UiObjectMember: T_PROPERTY T_IDENTIFIER T_LT UiPropertyType T_GT JsIdentifier T_AUTOMATIC_SEMICOLON ; -UiObjectMember: T_PROPERTY T_IDENTIFIER T_LT UiPropertyType T_GT JsIdentifier T_SEMICOLON ; -/. -case $rule_number: { - AST::UiPublicMember *node = new (pool) AST::UiPublicMember(stringRef(4), stringRef(6)); - node->typeModifier = stringRef(2); - node->propertyToken = loc(1); - node->typeModifierToken = loc(2); - node->typeToken = loc(4); - node->identifierToken = loc(6); - node->semicolonToken = loc(7); - sym(1).Node = node; -} break; -./ - -UiObjectMember: T_PROPERTY UiPropertyType JsIdentifier T_AUTOMATIC_SEMICOLON ; -UiObjectMember: T_PROPERTY UiPropertyType JsIdentifier T_SEMICOLON ; -/. -case $rule_number: { - AST::UiPublicMember *node = new (pool) AST::UiPublicMember(stringRef(2), stringRef(3)); - node->propertyToken = loc(1); - node->typeToken = loc(2); - node->identifierToken = loc(3); - node->semicolonToken = loc(4); - sym(1).Node = node; -} break; -./ - -UiObjectMember: T_DEFAULT T_PROPERTY UiPropertyType JsIdentifier T_AUTOMATIC_SEMICOLON ; -UiObjectMember: T_DEFAULT T_PROPERTY UiPropertyType JsIdentifier T_SEMICOLON ; -/. -case $rule_number: { - AST::UiPublicMember *node = new (pool) AST::UiPublicMember(stringRef(3), stringRef(4)); - node->isDefaultMember = true; - node->defaultToken = loc(1); - node->propertyToken = loc(2); - node->typeToken = loc(3); - node->identifierToken = loc(4); - node->semicolonToken = loc(5); - sym(1).Node = node; -} break; -./ - -UiObjectMember: T_PROPERTY UiPropertyType JsIdentifier T_COLON UiScriptStatement ; -/. -case $rule_number: { - AST::UiPublicMember *node = new (pool) AST::UiPublicMember(stringRef(2), stringRef(3), - sym(5).Statement); - node->propertyToken = loc(1); - node->typeToken = loc(2); - node->identifierToken = loc(3); - node->colonToken = loc(4); - sym(1).Node = node; -} break; -./ - -UiObjectMember: T_READONLY T_PROPERTY UiPropertyType JsIdentifier T_COLON UiScriptStatement ; -/. -case $rule_number: { - AST::UiPublicMember *node = new (pool) AST::UiPublicMember(stringRef(3), stringRef(4), - sym(6).Statement); - node->isReadonlyMember = true; - node->readonlyToken = loc(1); - node->propertyToken = loc(2); - node->typeToken = loc(3); - node->identifierToken = loc(4); - node->colonToken = loc(5); - sym(1).Node = node; -} break; -./ - -UiObjectMember: T_DEFAULT T_PROPERTY UiPropertyType JsIdentifier T_COLON UiScriptStatement ; -/. -case $rule_number: { - AST::UiPublicMember *node = new (pool) AST::UiPublicMember(stringRef(3), stringRef(4), - sym(6).Statement); - node->isDefaultMember = true; - node->defaultToken = loc(1); - node->propertyToken = loc(2); - node->typeToken = loc(3); - node->identifierToken = loc(4); - node->colonToken = loc(5); - sym(1).Node = node; -} break; -./ - -UiObjectMember: T_PROPERTY T_IDENTIFIER T_LT UiPropertyType T_GT JsIdentifier T_COLON T_LBRACKET UiArrayMemberList T_RBRACKET ; -/. -case $rule_number: { - AST::UiPublicMember *node = new (pool) AST::UiPublicMember(stringRef(4), stringRef(6)); - node->typeModifier = stringRef(2); - node->propertyToken = loc(1); - node->typeModifierToken = loc(2); - node->typeToken = loc(4); - node->identifierToken = loc(6); - node->semicolonToken = loc(7); // insert a fake ';' before ':' - - AST::UiQualifiedId *propertyName = new (pool) AST::UiQualifiedId(stringRef(6)); - propertyName->identifierToken = loc(6); - propertyName->next = 0; - - AST::UiArrayBinding *binding = new (pool) AST::UiArrayBinding( - propertyName, sym(9).UiArrayMemberList->finish()); - binding->colonToken = loc(7); - binding->lbracketToken = loc(8); - binding->rbracketToken = loc(10); - - node->binding = binding; - - sym(1).Node = node; -} break; -./ - -UiObjectMember: T_PROPERTY UiPropertyType JsIdentifier T_COLON UiQualifiedId UiObjectInitializer ; -/. -case $rule_number: { - AST::UiPublicMember *node = new (pool) AST::UiPublicMember(stringRef(2), stringRef(3)); - node->propertyToken = loc(1); - node->typeToken = loc(2); - node->identifierToken = loc(3); - node->semicolonToken = loc(4); // insert a fake ';' before ':' - - AST::UiQualifiedId *propertyName = new (pool) AST::UiQualifiedId(stringRef(3)); - propertyName->identifierToken = loc(3); - propertyName->next = 0; - - AST::UiObjectBinding *binding = new (pool) AST::UiObjectBinding( - propertyName, sym(5).UiQualifiedId, sym(6).UiObjectInitializer); - binding->colonToken = loc(4); - - node->binding = binding; - - sym(1).Node = node; -} break; -./ - -UiObjectMember: FunctionDeclaration ; -/. -case $rule_number: { - sym(1).Node = new (pool) AST::UiSourceElement(sym(1).Node); -} break; -./ - -UiObjectMember: VariableStatement ; -/. -case $rule_number: { - sym(1).Node = new (pool) AST::UiSourceElement(sym(1).Node); -} break; -./ - -JsIdentifier: T_IDENTIFIER; - -JsIdentifier: T_PROPERTY ; -JsIdentifier: T_SIGNAL ; -JsIdentifier: T_READONLY ; -JsIdentifier: T_ON ; - --------------------------------------------------------------------------------------------------------- --- Expressions --------------------------------------------------------------------------------------------------------- - -PrimaryExpression: T_THIS ; -/. -case $rule_number: { - AST::ThisExpression *node = new (pool) AST::ThisExpression(); - node->thisToken = loc(1); - sym(1).Node = node; -} break; -./ - -PrimaryExpression: JsIdentifier ; -/. -case $rule_number: { - AST::IdentifierExpression *node = new (pool) AST::IdentifierExpression(stringRef(1)); - node->identifierToken = loc(1); - sym(1).Node = node; -} break; -./ - -PrimaryExpression: T_NULL ; -/. -case $rule_number: { - AST::NullExpression *node = new (pool) AST::NullExpression(); - node->nullToken = loc(1); - sym(1).Node = node; -} break; -./ - -PrimaryExpression: T_TRUE ; -/. -case $rule_number: { - AST::TrueLiteral *node = new (pool) AST::TrueLiteral(); - node->trueToken = loc(1); - sym(1).Node = node; -} break; -./ - -PrimaryExpression: T_FALSE ; -/. -case $rule_number: { - AST::FalseLiteral *node = new (pool) AST::FalseLiteral(); - node->falseToken = loc(1); - sym(1).Node = node; -} break; -./ - -PrimaryExpression: T_NUMERIC_LITERAL ; -/. -case $rule_number: { - AST::NumericLiteral *node = new (pool) AST::NumericLiteral(sym(1).dval); - node->literalToken = loc(1); - sym(1).Node = node; -} break; -./ - -PrimaryExpression: T_MULTILINE_STRING_LITERAL ; -/.case $rule_number:./ - -PrimaryExpression: T_STRING_LITERAL ; -/. -case $rule_number: { - AST::StringLiteral *node = new (pool) AST::StringLiteral(stringRef(1)); - node->literalToken = loc(1); - sym(1).Node = node; -} break; -./ - -PrimaryExpression: T_DIVIDE_ ; -/: -#define J_SCRIPT_REGEXPLITERAL_RULE1 $rule_number -:/ -/. -case $rule_number: { - bool rx = lexer->scanRegExp(Lexer::NoPrefix); - if (!rx) { - diagnostic_messages.append(DiagnosticMessage(DiagnosticMessage::Error, location(lexer), lexer->errorMessage())); - return false; // ### remove me - } - - loc(1).length = lexer->tokenLength(); - yylloc = loc(1); // adjust the location of the current token - - AST::RegExpLiteral *node = new (pool) AST::RegExpLiteral( - driver->newStringRef(lexer->regExpPattern()), lexer->regExpFlags()); - node->literalToken = loc(1); - sym(1).Node = node; -} break; -./ - -PrimaryExpression: T_DIVIDE_EQ ; -/: -#define J_SCRIPT_REGEXPLITERAL_RULE2 $rule_number -:/ -/. -case $rule_number: { - bool rx = lexer->scanRegExp(Lexer::EqualPrefix); - if (!rx) { - diagnostic_messages.append(DiagnosticMessage(DiagnosticMessage::Error, location(lexer), lexer->errorMessage())); - return false; - } - - loc(1).length = lexer->tokenLength(); - yylloc = loc(1); // adjust the location of the current token - - AST::RegExpLiteral *node = new (pool) AST::RegExpLiteral( - driver->newStringRef(lexer->regExpPattern()), lexer->regExpFlags()); - node->literalToken = loc(1); - sym(1).Node = node; -} break; -./ - -PrimaryExpression: T_LBRACKET T_RBRACKET ; -/. -case $rule_number: { - AST::ArrayLiteral *node = new (pool) AST::ArrayLiteral((AST::Elision *) 0); - node->lbracketToken = loc(1); - node->rbracketToken = loc(2); - sym(1).Node = node; -} break; -./ - -PrimaryExpression: T_LBRACKET Elision T_RBRACKET ; -/. -case $rule_number: { - AST::ArrayLiteral *node = new (pool) AST::ArrayLiteral(sym(2).Elision->finish()); - node->lbracketToken = loc(1); - node->rbracketToken = loc(3); - sym(1).Node = node; -} break; -./ - -PrimaryExpression: T_LBRACKET ElementList T_RBRACKET ; -/. -case $rule_number: { - AST::ArrayLiteral *node = new (pool) AST::ArrayLiteral(sym(2).ElementList->finish ()); - node->lbracketToken = loc(1); - node->rbracketToken = loc(3); - sym(1).Node = node; -} break; -./ - -PrimaryExpression: T_LBRACKET ElementList T_COMMA T_RBRACKET ; -/. -case $rule_number: { - AST::ArrayLiteral *node = new (pool) AST::ArrayLiteral(sym(2).ElementList->finish (), - (AST::Elision *) 0); - node->lbracketToken = loc(1); - node->commaToken = loc(3); - node->rbracketToken = loc(4); - sym(1).Node = node; -} break; -./ - -PrimaryExpression: T_LBRACKET ElementList T_COMMA Elision T_RBRACKET ; -/. -case $rule_number: { - AST::ArrayLiteral *node = new (pool) AST::ArrayLiteral(sym(2).ElementList->finish (), - sym(4).Elision->finish()); - node->lbracketToken = loc(1); - node->commaToken = loc(3); - node->rbracketToken = loc(5); - sym(1).Node = node; -} break; -./ - --- PrimaryExpression: T_LBRACE T_RBRACE ; --- /. --- case $rule_number: { --- sym(1).Node = new (pool) AST::ObjectLiteral(); --- } break; --- ./ - -PrimaryExpression: T_LBRACE PropertyNameAndValueListOpt T_RBRACE ; -/. -case $rule_number: { - AST::ObjectLiteral *node = 0; - if (sym(2).Node) - node = new (pool) AST::ObjectLiteral( - sym(2).PropertyNameAndValueList->finish ()); - else - node = new (pool) AST::ObjectLiteral(); - node->lbraceToken = loc(1); - node->rbraceToken = loc(3); - sym(1).Node = node; -} break; -./ - -PrimaryExpression: T_LBRACE PropertyNameAndValueList T_COMMA T_RBRACE ; -/. -case $rule_number: { - AST::ObjectLiteral *node = new (pool) AST::ObjectLiteral( - sym(2).PropertyNameAndValueList->finish ()); - node->lbraceToken = loc(1); - node->rbraceToken = loc(4); - sym(1).Node = node; -} break; -./ - -PrimaryExpression: T_LPAREN Expression T_RPAREN ; -/. -case $rule_number: { - AST::NestedExpression *node = new (pool) AST::NestedExpression(sym(2).Expression); - node->lparenToken = loc(1); - node->rparenToken = loc(3); - sym(1).Node = node; -} break; -./ - -UiQualifiedId: MemberExpression ; -/. -case $rule_number: { - if (AST::ArrayMemberExpression *mem = AST::cast(sym(1).Expression)) { - diagnostic_messages.append(DiagnosticMessage(DiagnosticMessage::Warning, mem->lbracketToken, - QLatin1String("Ignored annotation"))); - - sym(1).Expression = mem->base; - } - - if (AST::UiQualifiedId *qualifiedId = reparseAsQualifiedId(sym(1).Expression)) { - sym(1).UiQualifiedId = qualifiedId; - } else { - sym(1).UiQualifiedId = 0; - - diagnostic_messages.append(DiagnosticMessage(DiagnosticMessage::Error, loc(1), - QLatin1String("Expected a qualified name id"))); - - return false; // ### recover - } -} break; -./ - -ElementList: AssignmentExpression ; -/. -case $rule_number: { - sym(1).Node = new (pool) AST::ElementList((AST::Elision *) 0, sym(1).Expression); -} break; -./ - -ElementList: Elision AssignmentExpression ; -/. -case $rule_number: { - sym(1).Node = new (pool) AST::ElementList(sym(1).Elision->finish(), sym(2).Expression); -} break; -./ - -ElementList: ElementList T_COMMA AssignmentExpression ; -/. -case $rule_number: { - AST::ElementList *node = new (pool) AST::ElementList(sym(1).ElementList, - (AST::Elision *) 0, sym(3).Expression); - node->commaToken = loc(2); - sym(1).Node = node; -} break; -./ - -ElementList: ElementList T_COMMA Elision AssignmentExpression ; -/. -case $rule_number: { - AST::ElementList *node = new (pool) AST::ElementList(sym(1).ElementList, sym(3).Elision->finish(), - sym(4).Expression); - node->commaToken = loc(2); - sym(1).Node = node; -} break; -./ - -Elision: T_COMMA ; -/. -case $rule_number: { - AST::Elision *node = new (pool) AST::Elision(); - node->commaToken = loc(1); - sym(1).Node = node; -} break; -./ - -Elision: Elision T_COMMA ; -/. -case $rule_number: { - AST::Elision *node = new (pool) AST::Elision(sym(1).Elision); - node->commaToken = loc(2); - sym(1).Node = node; -} break; -./ - -PropertyNameAndValueList: PropertyName T_COLON AssignmentExpression ; -/. -case $rule_number: { - AST::PropertyNameAndValueList *node = new (pool) AST::PropertyNameAndValueList( - sym(1).PropertyName, sym(3).Expression); - node->colonToken = loc(2); - sym(1).Node = node; -} break; -./ - -PropertyNameAndValueList: PropertyNameAndValueList T_COMMA PropertyName T_COLON AssignmentExpression ; -/. -case $rule_number: { - AST::PropertyNameAndValueList *node = new (pool) AST::PropertyNameAndValueList( - sym(1).PropertyNameAndValueList, sym(3).PropertyName, sym(5).Expression); - node->commaToken = loc(2); - node->colonToken = loc(4); - sym(1).Node = node; -} break; -./ - -PropertyName: T_IDENTIFIER %prec SHIFT_THERE ; -/. -case $rule_number: { - AST::IdentifierPropertyName *node = new (pool) AST::IdentifierPropertyName(stringRef(1)); - node->propertyNameToken = loc(1); - sym(1).Node = node; -} break; -./ - -PropertyName: T_SIGNAL ; -/.case $rule_number:./ - -PropertyName: T_PROPERTY ; -/. -case $rule_number: { - AST::IdentifierPropertyName *node = new (pool) AST::IdentifierPropertyName(stringRef(1)); - node->propertyNameToken = loc(1); - sym(1).Node = node; -} break; -./ - -PropertyName: T_STRING_LITERAL ; -/. -case $rule_number: { - AST::StringLiteralPropertyName *node = new (pool) AST::StringLiteralPropertyName(stringRef(1)); - node->propertyNameToken = loc(1); - sym(1).Node = node; -} break; -./ - -PropertyName: T_NUMERIC_LITERAL ; -/. -case $rule_number: { - AST::NumericLiteralPropertyName *node = new (pool) AST::NumericLiteralPropertyName(sym(1).dval); - node->propertyNameToken = loc(1); - sym(1).Node = node; -} break; -./ - -PropertyName: ReservedIdentifier ; -/. -case $rule_number: { - AST::IdentifierPropertyName *node = new (pool) AST::IdentifierPropertyName(stringRef(1)); - node->propertyNameToken = loc(1); - sym(1).Node = node; -} break; -./ - -ReservedIdentifier: T_BREAK ; -ReservedIdentifier: T_CASE ; -ReservedIdentifier: T_CATCH ; -ReservedIdentifier: T_CONTINUE ; -ReservedIdentifier: T_DEFAULT ; -ReservedIdentifier: T_DELETE ; -ReservedIdentifier: T_DO ; -ReservedIdentifier: T_ELSE ; -ReservedIdentifier: T_FALSE ; -ReservedIdentifier: T_FINALLY ; -ReservedIdentifier: T_FOR ; -ReservedIdentifier: T_FUNCTION ; -ReservedIdentifier: T_IF ; -ReservedIdentifier: T_IN ; -ReservedIdentifier: T_INSTANCEOF ; -ReservedIdentifier: T_NEW ; -ReservedIdentifier: T_NULL ; -ReservedIdentifier: T_RETURN ; -ReservedIdentifier: T_SWITCH ; -ReservedIdentifier: T_THIS ; -ReservedIdentifier: T_THROW ; -ReservedIdentifier: T_TRUE ; -ReservedIdentifier: T_TRY ; -ReservedIdentifier: T_TYPEOF ; -ReservedIdentifier: T_VAR ; -ReservedIdentifier: T_VOID ; -ReservedIdentifier: T_WHILE ; -ReservedIdentifier: T_CONST ; -ReservedIdentifier: T_DEBUGGER ; -ReservedIdentifier: T_RESERVED_WORD ; -ReservedIdentifier: T_WITH ; - -PropertyIdentifier: JsIdentifier ; -PropertyIdentifier: ReservedIdentifier ; - -MemberExpression: PrimaryExpression ; -MemberExpression: FunctionExpression ; - -MemberExpression: MemberExpression T_LBRACKET Expression T_RBRACKET ; -/. -case $rule_number: { - AST::ArrayMemberExpression *node = new (pool) AST::ArrayMemberExpression(sym(1).Expression, sym(3).Expression); - node->lbracketToken = loc(2); - node->rbracketToken = loc(4); - sym(1).Node = node; -} break; -./ - -MemberExpression: MemberExpression T_DOT PropertyIdentifier ; -/. -case $rule_number: { - AST::FieldMemberExpression *node = new (pool) AST::FieldMemberExpression(sym(1).Expression, stringRef(3)); - node->dotToken = loc(2); - node->identifierToken = loc(3); - sym(1).Node = node; -} break; -./ - -MemberExpression: T_NEW MemberExpression T_LPAREN ArgumentListOpt T_RPAREN ; -/. -case $rule_number: { - AST::NewMemberExpression *node = new (pool) AST::NewMemberExpression(sym(2).Expression, sym(4).ArgumentList); - node->newToken = loc(1); - node->lparenToken = loc(3); - node->rparenToken = loc(5); - sym(1).Node = node; -} break; -./ - -NewExpression: MemberExpression ; - -NewExpression: T_NEW NewExpression ; -/. -case $rule_number: { - AST::NewExpression *node = new (pool) AST::NewExpression(sym(2).Expression); - node->newToken = loc(1); - sym(1).Node = node; -} break; -./ - -CallExpression: MemberExpression T_LPAREN ArgumentListOpt T_RPAREN ; -/. -case $rule_number: { - AST::CallExpression *node = new (pool) AST::CallExpression(sym(1).Expression, sym(3).ArgumentList); - node->lparenToken = loc(2); - node->rparenToken = loc(4); - sym(1).Node = node; -} break; -./ - -CallExpression: CallExpression T_LPAREN ArgumentListOpt T_RPAREN ; -/. -case $rule_number: { - AST::CallExpression *node = new (pool) AST::CallExpression(sym(1).Expression, sym(3).ArgumentList); - node->lparenToken = loc(2); - node->rparenToken = loc(4); - sym(1).Node = node; -} break; -./ - -CallExpression: CallExpression T_LBRACKET Expression T_RBRACKET ; -/. -case $rule_number: { - AST::ArrayMemberExpression *node = new (pool) AST::ArrayMemberExpression(sym(1).Expression, sym(3).Expression); - node->lbracketToken = loc(2); - node->rbracketToken = loc(4); - sym(1).Node = node; -} break; -./ - -CallExpression: CallExpression T_DOT PropertyIdentifier ; -/. -case $rule_number: { - AST::FieldMemberExpression *node = new (pool) AST::FieldMemberExpression(sym(1).Expression, stringRef(3)); - node->dotToken = loc(2); - node->identifierToken = loc(3); - sym(1).Node = node; -} break; -./ - -ArgumentListOpt: ; -/. -case $rule_number: { - sym(1).Node = 0; -} break; -./ - -ArgumentListOpt: ArgumentList ; -/. -case $rule_number: { - sym(1).Node = sym(1).ArgumentList->finish(); -} break; -./ - -ArgumentList: AssignmentExpression ; -/. -case $rule_number: { - sym(1).Node = new (pool) AST::ArgumentList(sym(1).Expression); -} break; -./ - -ArgumentList: ArgumentList T_COMMA AssignmentExpression ; -/. -case $rule_number: { - AST::ArgumentList *node = new (pool) AST::ArgumentList(sym(1).ArgumentList, sym(3).Expression); - node->commaToken = loc(2); - sym(1).Node = node; -} break; -./ - -LeftHandSideExpression: NewExpression ; -LeftHandSideExpression: CallExpression ; -PostfixExpression: LeftHandSideExpression ; - -PostfixExpression: LeftHandSideExpression T_PLUS_PLUS ; -/. -case $rule_number: { - AST::PostIncrementExpression *node = new (pool) AST::PostIncrementExpression(sym(1).Expression); - node->incrementToken = loc(2); - sym(1).Node = node; -} break; -./ - -PostfixExpression: LeftHandSideExpression T_MINUS_MINUS ; -/. -case $rule_number: { - AST::PostDecrementExpression *node = new (pool) AST::PostDecrementExpression(sym(1).Expression); - node->decrementToken = loc(2); - sym(1).Node = node; -} break; -./ - -UnaryExpression: PostfixExpression ; - -UnaryExpression: T_DELETE UnaryExpression ; -/. -case $rule_number: { - AST::DeleteExpression *node = new (pool) AST::DeleteExpression(sym(2).Expression); - node->deleteToken = loc(1); - sym(1).Node = node; -} break; -./ - -UnaryExpression: T_VOID UnaryExpression ; -/. -case $rule_number: { - AST::VoidExpression *node = new (pool) AST::VoidExpression(sym(2).Expression); - node->voidToken = loc(1); - sym(1).Node = node; -} break; -./ - -UnaryExpression: T_TYPEOF UnaryExpression ; -/. -case $rule_number: { - AST::TypeOfExpression *node = new (pool) AST::TypeOfExpression(sym(2).Expression); - node->typeofToken = loc(1); - sym(1).Node = node; -} break; -./ - -UnaryExpression: T_PLUS_PLUS UnaryExpression ; -/. -case $rule_number: { - AST::PreIncrementExpression *node = new (pool) AST::PreIncrementExpression(sym(2).Expression); - node->incrementToken = loc(1); - sym(1).Node = node; -} break; -./ - -UnaryExpression: T_MINUS_MINUS UnaryExpression ; -/. -case $rule_number: { - AST::PreDecrementExpression *node = new (pool) AST::PreDecrementExpression(sym(2).Expression); - node->decrementToken = loc(1); - sym(1).Node = node; -} break; -./ - -UnaryExpression: T_PLUS UnaryExpression ; -/. -case $rule_number: { - AST::UnaryPlusExpression *node = new (pool) AST::UnaryPlusExpression(sym(2).Expression); - node->plusToken = loc(1); - sym(1).Node = node; -} break; -./ - -UnaryExpression: T_MINUS UnaryExpression ; -/. -case $rule_number: { - AST::UnaryMinusExpression *node = new (pool) AST::UnaryMinusExpression(sym(2).Expression); - node->minusToken = loc(1); - sym(1).Node = node; -} break; -./ - -UnaryExpression: T_TILDE UnaryExpression ; -/. -case $rule_number: { - AST::TildeExpression *node = new (pool) AST::TildeExpression(sym(2).Expression); - node->tildeToken = loc(1); - sym(1).Node = node; -} break; -./ - -UnaryExpression: T_NOT UnaryExpression ; -/. -case $rule_number: { - AST::NotExpression *node = new (pool) AST::NotExpression(sym(2).Expression); - node->notToken = loc(1); - sym(1).Node = node; -} break; -./ - -MultiplicativeExpression: UnaryExpression ; - -MultiplicativeExpression: MultiplicativeExpression T_STAR UnaryExpression ; -/. -case $rule_number: { - AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, - QSOperator::Mul, sym(3).Expression); - node->operatorToken = loc(2); - sym(1).Node = node; -} break; -./ - -MultiplicativeExpression: MultiplicativeExpression T_DIVIDE_ UnaryExpression ; -/. -case $rule_number: { - AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, - QSOperator::Div, sym(3).Expression); - node->operatorToken = loc(2); - sym(1).Node = node; -} break; -./ - -MultiplicativeExpression: MultiplicativeExpression T_REMAINDER UnaryExpression ; -/. -case $rule_number: { - AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, - QSOperator::Mod, sym(3).Expression); - node->operatorToken = loc(2); - sym(1).Node = node; -} break; -./ - -AdditiveExpression: MultiplicativeExpression ; - -AdditiveExpression: AdditiveExpression T_PLUS MultiplicativeExpression ; -/. -case $rule_number: { - AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, - QSOperator::Add, sym(3).Expression); - node->operatorToken = loc(2); - sym(1).Node = node; -} break; -./ - -AdditiveExpression: AdditiveExpression T_MINUS MultiplicativeExpression ; -/. -case $rule_number: { - AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, - QSOperator::Sub, sym(3).Expression); - node->operatorToken = loc(2); - sym(1).Node = node; -} break; -./ - -ShiftExpression: AdditiveExpression ; - -ShiftExpression: ShiftExpression T_LT_LT AdditiveExpression ; -/. -case $rule_number: { - AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, - QSOperator::LShift, sym(3).Expression); - node->operatorToken = loc(2); - sym(1).Node = node; -} break; -./ - -ShiftExpression: ShiftExpression T_GT_GT AdditiveExpression ; -/. -case $rule_number: { - AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, - QSOperator::RShift, sym(3).Expression); - node->operatorToken = loc(2); - sym(1).Node = node; -} break; -./ - -ShiftExpression: ShiftExpression T_GT_GT_GT AdditiveExpression ; -/. -case $rule_number: { - AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, - QSOperator::URShift, sym(3).Expression); - node->operatorToken = loc(2); - sym(1).Node = node; -} break; -./ - -RelationalExpression: ShiftExpression ; - -RelationalExpression: RelationalExpression T_LT ShiftExpression ; -/. -case $rule_number: { - AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, - QSOperator::Lt, sym(3).Expression); - node->operatorToken = loc(2); - sym(1).Node = node; -} break; -./ - -RelationalExpression: RelationalExpression T_GT ShiftExpression ; -/. -case $rule_number: { - AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, - QSOperator::Gt, sym(3).Expression); - node->operatorToken = loc(2); - sym(1).Node = node; -} break; -./ - -RelationalExpression: RelationalExpression T_LE ShiftExpression ; -/. -case $rule_number: { - AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, - QSOperator::Le, sym(3).Expression); - node->operatorToken = loc(2); - sym(1).Node = node; -} break; -./ - -RelationalExpression: RelationalExpression T_GE ShiftExpression ; -/. -case $rule_number: { - AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, - QSOperator::Ge, sym(3).Expression); - node->operatorToken = loc(2); - sym(1).Node = node; -} break; -./ - -RelationalExpression: RelationalExpression T_INSTANCEOF ShiftExpression ; -/. -case $rule_number: { - AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, - QSOperator::InstanceOf, sym(3).Expression); - node->operatorToken = loc(2); - sym(1).Node = node; -} break; -./ - -RelationalExpression: RelationalExpression T_IN ShiftExpression ; -/. -case $rule_number: { - AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, - QSOperator::In, sym(3).Expression); - node->operatorToken = loc(2); - sym(1).Node = node; -} break; -./ - -RelationalExpressionNotIn: ShiftExpression ; - -RelationalExpressionNotIn: RelationalExpressionNotIn T_LT ShiftExpression ; -/. -case $rule_number: { - AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, - QSOperator::Lt, sym(3).Expression); - node->operatorToken = loc(2); - sym(1).Node = node; -} break; -./ - -RelationalExpressionNotIn: RelationalExpressionNotIn T_GT ShiftExpression ; -/. -case $rule_number: { - AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, - QSOperator::Gt, sym(3).Expression); - node->operatorToken = loc(2); - sym(1).Node = node; -} break; -./ - -RelationalExpressionNotIn: RelationalExpressionNotIn T_LE ShiftExpression ; -/. -case $rule_number: { - AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, - QSOperator::Le, sym(3).Expression); - node->operatorToken = loc(2); - sym(1).Node = node; -} break; -./ - -RelationalExpressionNotIn: RelationalExpressionNotIn T_GE ShiftExpression ; -/. -case $rule_number: { - AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, - QSOperator::Ge, sym(3).Expression); - node->operatorToken = loc(2); - sym(1).Node = node; -} break; -./ - -RelationalExpressionNotIn: RelationalExpressionNotIn T_INSTANCEOF ShiftExpression ; -/. -case $rule_number: { - AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, - QSOperator::InstanceOf, sym(3).Expression); - node->operatorToken = loc(2); - sym(1).Node = node; -} break; -./ - -EqualityExpression: RelationalExpression ; - -EqualityExpression: EqualityExpression T_EQ_EQ RelationalExpression ; -/. -case $rule_number: { - AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, - QSOperator::Equal, sym(3).Expression); - node->operatorToken = loc(2); - sym(1).Node = node; -} break; -./ - -EqualityExpression: EqualityExpression T_NOT_EQ RelationalExpression ; -/. -case $rule_number: { - AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, - QSOperator::NotEqual, sym(3).Expression); - node->operatorToken = loc(2); - sym(1).Node = node; -} break; -./ - -EqualityExpression: EqualityExpression T_EQ_EQ_EQ RelationalExpression ; -/. -case $rule_number: { - AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, - QSOperator::StrictEqual, sym(3).Expression); - node->operatorToken = loc(2); - sym(1).Node = node; -} break; -./ - -EqualityExpression: EqualityExpression T_NOT_EQ_EQ RelationalExpression ; -/. -case $rule_number: { - AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, - QSOperator::StrictNotEqual, sym(3).Expression); - node->operatorToken = loc(2); - sym(1).Node = node; -} break; -./ - -EqualityExpressionNotIn: RelationalExpressionNotIn ; - -EqualityExpressionNotIn: EqualityExpressionNotIn T_EQ_EQ RelationalExpressionNotIn ; -/. -case $rule_number: { - AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, - QSOperator::Equal, sym(3).Expression); - node->operatorToken = loc(2); - sym(1).Node = node; -} break; -./ - -EqualityExpressionNotIn: EqualityExpressionNotIn T_NOT_EQ RelationalExpressionNotIn; -/. -case $rule_number: { - AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, - QSOperator::NotEqual, sym(3).Expression); - node->operatorToken = loc(2); - sym(1).Node = node; -} break; -./ - -EqualityExpressionNotIn: EqualityExpressionNotIn T_EQ_EQ_EQ RelationalExpressionNotIn ; -/. -case $rule_number: { - AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, - QSOperator::StrictEqual, sym(3).Expression); - node->operatorToken = loc(2); - sym(1).Node = node; -} break; -./ - -EqualityExpressionNotIn: EqualityExpressionNotIn T_NOT_EQ_EQ RelationalExpressionNotIn ; -/. -case $rule_number: { - AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, - QSOperator::StrictNotEqual, sym(3).Expression); - node->operatorToken = loc(2); - sym(1).Node = node; -} break; -./ - -BitwiseANDExpression: EqualityExpression ; - -BitwiseANDExpression: BitwiseANDExpression T_AND EqualityExpression ; -/. -case $rule_number: { - AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, - QSOperator::BitAnd, sym(3).Expression); - node->operatorToken = loc(2); - sym(1).Node = node; -} break; -./ - -BitwiseANDExpressionNotIn: EqualityExpressionNotIn ; - -BitwiseANDExpressionNotIn: BitwiseANDExpressionNotIn T_AND EqualityExpressionNotIn ; -/. -case $rule_number: { - AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, - QSOperator::BitAnd, sym(3).Expression); - node->operatorToken = loc(2); - sym(1).Node = node; -} break; -./ - -BitwiseXORExpression: BitwiseANDExpression ; - -BitwiseXORExpression: BitwiseXORExpression T_XOR BitwiseANDExpression ; -/. -case $rule_number: { - AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, - QSOperator::BitXor, sym(3).Expression); - node->operatorToken = loc(2); - sym(1).Node = node; -} break; -./ - -BitwiseXORExpressionNotIn: BitwiseANDExpressionNotIn ; - -BitwiseXORExpressionNotIn: BitwiseXORExpressionNotIn T_XOR BitwiseANDExpressionNotIn ; -/. -case $rule_number: { - AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, - QSOperator::BitXor, sym(3).Expression); - node->operatorToken = loc(2); - sym(1).Node = node; -} break; -./ - -BitwiseORExpression: BitwiseXORExpression ; - -BitwiseORExpression: BitwiseORExpression T_OR BitwiseXORExpression ; -/. -case $rule_number: { - AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, - QSOperator::BitOr, sym(3).Expression); - node->operatorToken = loc(2); - sym(1).Node = node; -} break; -./ - -BitwiseORExpressionNotIn: BitwiseXORExpressionNotIn ; - -BitwiseORExpressionNotIn: BitwiseORExpressionNotIn T_OR BitwiseXORExpressionNotIn ; -/. -case $rule_number: { - AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, - QSOperator::BitOr, sym(3).Expression); - node->operatorToken = loc(2); - sym(1).Node = node; -} break; -./ - -LogicalANDExpression: BitwiseORExpression ; - -LogicalANDExpression: LogicalANDExpression T_AND_AND BitwiseORExpression ; -/. -case $rule_number: { - AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, - QSOperator::And, sym(3).Expression); - node->operatorToken = loc(2); - sym(1).Node = node; -} break; -./ - -LogicalANDExpressionNotIn: BitwiseORExpressionNotIn ; - -LogicalANDExpressionNotIn: LogicalANDExpressionNotIn T_AND_AND BitwiseORExpressionNotIn ; -/. -case $rule_number: { - AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, - QSOperator::And, sym(3).Expression); - node->operatorToken = loc(2); - sym(1).Node = node; -} break; -./ - -LogicalORExpression: LogicalANDExpression ; - -LogicalORExpression: LogicalORExpression T_OR_OR LogicalANDExpression ; -/. -case $rule_number: { - AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, - QSOperator::Or, sym(3).Expression); - node->operatorToken = loc(2); - sym(1).Node = node; -} break; -./ - -LogicalORExpressionNotIn: LogicalANDExpressionNotIn ; - -LogicalORExpressionNotIn: LogicalORExpressionNotIn T_OR_OR LogicalANDExpressionNotIn ; -/. -case $rule_number: { - AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, - QSOperator::Or, sym(3).Expression); - node->operatorToken = loc(2); - sym(1).Node = node; -} break; -./ - -ConditionalExpression: LogicalORExpression ; - -ConditionalExpression: LogicalORExpression T_QUESTION AssignmentExpression T_COLON AssignmentExpression ; -/. -case $rule_number: { - AST::ConditionalExpression *node = new (pool) AST::ConditionalExpression(sym(1).Expression, - sym(3).Expression, sym(5).Expression); - node->questionToken = loc(2); - node->colonToken = loc(4); - sym(1).Node = node; -} break; -./ - -ConditionalExpressionNotIn: LogicalORExpressionNotIn ; - -ConditionalExpressionNotIn: LogicalORExpressionNotIn T_QUESTION AssignmentExpressionNotIn T_COLON AssignmentExpressionNotIn ; -/. -case $rule_number: { - AST::ConditionalExpression *node = new (pool) AST::ConditionalExpression(sym(1).Expression, - sym(3).Expression, sym(5).Expression); - node->questionToken = loc(2); - node->colonToken = loc(4); - sym(1).Node = node; -} break; -./ - -AssignmentExpression: ConditionalExpression ; - -AssignmentExpression: LeftHandSideExpression AssignmentOperator AssignmentExpression ; -/. -case $rule_number: { - AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, - sym(2).ival, sym(3).Expression); - node->operatorToken = loc(2); - sym(1).Node = node; -} break; -./ - -AssignmentExpressionNotIn: ConditionalExpressionNotIn ; - -AssignmentExpressionNotIn: LeftHandSideExpression AssignmentOperator AssignmentExpressionNotIn ; -/. -case $rule_number: { - AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, - sym(2).ival, sym(3).Expression); - node->operatorToken = loc(2); - sym(1).Node = node; -} break; -./ - -AssignmentOperator: T_EQ ; -/. -case $rule_number: { - sym(1).ival = QSOperator::Assign; -} break; -./ - -AssignmentOperator: T_STAR_EQ ; -/. -case $rule_number: { - sym(1).ival = QSOperator::InplaceMul; -} break; -./ - -AssignmentOperator: T_DIVIDE_EQ ; -/. -case $rule_number: { - sym(1).ival = QSOperator::InplaceDiv; -} break; -./ - -AssignmentOperator: T_REMAINDER_EQ ; -/. -case $rule_number: { - sym(1).ival = QSOperator::InplaceMod; -} break; -./ - -AssignmentOperator: T_PLUS_EQ ; -/. -case $rule_number: { - sym(1).ival = QSOperator::InplaceAdd; -} break; -./ - -AssignmentOperator: T_MINUS_EQ ; -/. -case $rule_number: { - sym(1).ival = QSOperator::InplaceSub; -} break; -./ - -AssignmentOperator: T_LT_LT_EQ ; -/. -case $rule_number: { - sym(1).ival = QSOperator::InplaceLeftShift; -} break; -./ - -AssignmentOperator: T_GT_GT_EQ ; -/. -case $rule_number: { - sym(1).ival = QSOperator::InplaceRightShift; -} break; -./ - -AssignmentOperator: T_GT_GT_GT_EQ ; -/. -case $rule_number: { - sym(1).ival = QSOperator::InplaceURightShift; -} break; -./ - -AssignmentOperator: T_AND_EQ ; -/. -case $rule_number: { - sym(1).ival = QSOperator::InplaceAnd; -} break; -./ - -AssignmentOperator: T_XOR_EQ ; -/. -case $rule_number: { - sym(1).ival = QSOperator::InplaceXor; -} break; -./ - -AssignmentOperator: T_OR_EQ ; -/. -case $rule_number: { - sym(1).ival = QSOperator::InplaceOr; -} break; -./ - -Expression: AssignmentExpression ; - -Expression: Expression T_COMMA AssignmentExpression ; -/. -case $rule_number: { - AST::Expression *node = new (pool) AST::Expression(sym(1).Expression, sym(3).Expression); - node->commaToken = loc(2); - sym(1).Node = node; -} break; -./ - -ExpressionOpt: ; -/. -case $rule_number: { - sym(1).Node = 0; -} break; -./ - -ExpressionOpt: Expression ; - -ExpressionNotIn: AssignmentExpressionNotIn ; - -ExpressionNotIn: ExpressionNotIn T_COMMA AssignmentExpressionNotIn ; -/. -case $rule_number: { - AST::Expression *node = new (pool) AST::Expression(sym(1).Expression, sym(3).Expression); - node->commaToken = loc(2); - sym(1).Node = node; -} break; -./ - -ExpressionNotInOpt: ; -/. -case $rule_number: { - sym(1).Node = 0; -} break; -./ - -ExpressionNotInOpt: ExpressionNotIn ; - -Statement: Block ; -Statement: VariableStatement ; -Statement: EmptyStatement ; -Statement: ExpressionStatement ; -Statement: IfStatement ; -Statement: IterationStatement ; -Statement: ContinueStatement ; -Statement: BreakStatement ; -Statement: ReturnStatement ; -Statement: WithStatement ; -Statement: LabelledStatement ; -Statement: SwitchStatement ; -Statement: ThrowStatement ; -Statement: TryStatement ; -Statement: DebuggerStatement ; - - -Block: T_LBRACE StatementListOpt T_RBRACE ; -/. -case $rule_number: { - AST::Block *node = new (pool) AST::Block(sym(2).StatementList); - node->lbraceToken = loc(1); - node->rbraceToken = loc(3); - sym(1).Node = node; -} break; -./ - -StatementList: Statement ; -/. -case $rule_number: { - sym(1).Node = new (pool) AST::StatementList(sym(1).Statement); -} break; -./ - -StatementList: StatementList Statement ; -/. -case $rule_number: { - sym(1).Node = new (pool) AST::StatementList(sym(1).StatementList, sym(2).Statement); -} break; -./ - -StatementListOpt: ; -/. -case $rule_number: { - sym(1).Node = 0; -} break; -./ - -StatementListOpt: StatementList ; -/. -case $rule_number: { - sym(1).Node = sym(1).StatementList->finish (); -} break; -./ - -VariableStatement: VariableDeclarationKind VariableDeclarationList T_AUTOMATIC_SEMICOLON ; -- automatic semicolon -VariableStatement: VariableDeclarationKind VariableDeclarationList T_SEMICOLON ; -/. -case $rule_number: { - AST::VariableStatement *node = new (pool) AST::VariableStatement( - sym(2).VariableDeclarationList->finish (/*readOnly=*/sym(1).ival == T_CONST)); - node->declarationKindToken = loc(1); - node->semicolonToken = loc(3); - sym(1).Node = node; -} break; -./ - -VariableDeclarationKind: T_CONST ; -/. -case $rule_number: { - sym(1).ival = T_CONST; -} break; -./ - -VariableDeclarationKind: T_VAR ; -/. -case $rule_number: { - sym(1).ival = T_VAR; -} break; -./ - -VariableDeclarationList: VariableDeclaration ; -/. -case $rule_number: { - sym(1).Node = new (pool) AST::VariableDeclarationList(sym(1).VariableDeclaration); -} break; -./ - -VariableDeclarationList: VariableDeclarationList T_COMMA VariableDeclaration ; -/. -case $rule_number: { - AST::VariableDeclarationList *node = new (pool) AST::VariableDeclarationList( - sym(1).VariableDeclarationList, sym(3).VariableDeclaration); - node->commaToken = loc(2); - sym(1).Node = node; -} break; -./ - -VariableDeclarationListNotIn: VariableDeclarationNotIn ; -/. -case $rule_number: { - sym(1).Node = new (pool) AST::VariableDeclarationList(sym(1).VariableDeclaration); -} break; -./ - -VariableDeclarationListNotIn: VariableDeclarationListNotIn T_COMMA VariableDeclarationNotIn ; -/. -case $rule_number: { - sym(1).Node = new (pool) AST::VariableDeclarationList(sym(1).VariableDeclarationList, sym(3).VariableDeclaration); -} break; -./ - -VariableDeclaration: JsIdentifier InitialiserOpt ; -/. -case $rule_number: { - AST::VariableDeclaration *node = new (pool) AST::VariableDeclaration(stringRef(1), sym(2).Expression); - node->identifierToken = loc(1); - sym(1).Node = node; -} break; -./ - -VariableDeclarationNotIn: JsIdentifier InitialiserNotInOpt ; -/. -case $rule_number: { - AST::VariableDeclaration *node = new (pool) AST::VariableDeclaration(stringRef(1), sym(2).Expression); - node->identifierToken = loc(1); - sym(1).Node = node; -} break; -./ - -Initialiser: T_EQ AssignmentExpression ; -/. -case $rule_number: { - // ### TODO: AST for initializer - sym(1) = sym(2); -} break; -./ - -InitialiserOpt: ; -/. -case $rule_number: { - sym(1).Node = 0; -} break; -./ - -InitialiserOpt: Initialiser ; - -InitialiserNotIn: T_EQ AssignmentExpressionNotIn ; -/. -case $rule_number: { - // ### TODO: AST for initializer - sym(1) = sym(2); -} break; -./ - -InitialiserNotInOpt: ; -/. -case $rule_number: { - sym(1).Node = 0; -} break; -./ - -InitialiserNotInOpt: InitialiserNotIn ; - -EmptyStatement: T_SEMICOLON ; -/. -case $rule_number: { - AST::EmptyStatement *node = new (pool) AST::EmptyStatement(); - node->semicolonToken = loc(1); - sym(1).Node = node; -} break; -./ - -ExpressionStatement: Expression T_AUTOMATIC_SEMICOLON ; -- automatic semicolon -ExpressionStatement: Expression T_SEMICOLON ; -/. -case $rule_number: { - AST::ExpressionStatement *node = new (pool) AST::ExpressionStatement(sym(1).Expression); - node->semicolonToken = loc(2); - sym(1).Node = node; -} break; -./ - -IfStatement: T_IF T_LPAREN Expression T_RPAREN Statement T_ELSE Statement ; -/. -case $rule_number: { - AST::IfStatement *node = new (pool) AST::IfStatement(sym(3).Expression, sym(5).Statement, sym(7).Statement); - node->ifToken = loc(1); - node->lparenToken = loc(2); - node->rparenToken = loc(4); - node->elseToken = loc(6); - sym(1).Node = node; -} break; -./ - -IfStatement: T_IF T_LPAREN Expression T_RPAREN Statement ; -/. -case $rule_number: { - AST::IfStatement *node = new (pool) AST::IfStatement(sym(3).Expression, sym(5).Statement); - node->ifToken = loc(1); - node->lparenToken = loc(2); - node->rparenToken = loc(4); - sym(1).Node = node; -} break; -./ - - -IterationStatement: T_DO Statement T_WHILE T_LPAREN Expression T_RPAREN T_AUTOMATIC_SEMICOLON ; -- automatic semicolon -IterationStatement: T_DO Statement T_WHILE T_LPAREN Expression T_RPAREN T_SEMICOLON ; -/. -case $rule_number: { - AST::DoWhileStatement *node = new (pool) AST::DoWhileStatement(sym(2).Statement, sym(5).Expression); - node->doToken = loc(1); - node->whileToken = loc(3); - node->lparenToken = loc(4); - node->rparenToken = loc(6); - node->semicolonToken = loc(7); - sym(1).Node = node; -} break; -./ - -IterationStatement: T_WHILE T_LPAREN Expression T_RPAREN Statement ; -/. -case $rule_number: { - AST::WhileStatement *node = new (pool) AST::WhileStatement(sym(3).Expression, sym(5).Statement); - node->whileToken = loc(1); - node->lparenToken = loc(2); - node->rparenToken = loc(4); - sym(1).Node = node; -} break; -./ - -IterationStatement: T_FOR T_LPAREN ExpressionNotInOpt T_SEMICOLON ExpressionOpt T_SEMICOLON ExpressionOpt T_RPAREN Statement ; -/. -case $rule_number: { - AST::ForStatement *node = new (pool) AST::ForStatement(sym(3).Expression, - sym(5).Expression, sym(7).Expression, sym(9).Statement); - node->forToken = loc(1); - node->lparenToken = loc(2); - node->firstSemicolonToken = loc(4); - node->secondSemicolonToken = loc(6); - node->rparenToken = loc(8); - sym(1).Node = node; -} break; -./ - -IterationStatement: T_FOR T_LPAREN T_VAR VariableDeclarationListNotIn T_SEMICOLON ExpressionOpt T_SEMICOLON ExpressionOpt T_RPAREN Statement ; -/. -case $rule_number: { - AST::LocalForStatement *node = new (pool) AST::LocalForStatement( - sym(4).VariableDeclarationList->finish (/*readOnly=*/false), sym(6).Expression, - sym(8).Expression, sym(10).Statement); - node->forToken = loc(1); - node->lparenToken = loc(2); - node->varToken = loc(3); - node->firstSemicolonToken = loc(5); - node->secondSemicolonToken = loc(7); - node->rparenToken = loc(9); - sym(1).Node = node; -} break; -./ - -IterationStatement: T_FOR T_LPAREN LeftHandSideExpression T_IN Expression T_RPAREN Statement ; -/. -case $rule_number: { - AST:: ForEachStatement *node = new (pool) AST::ForEachStatement(sym(3).Expression, - sym(5).Expression, sym(7).Statement); - node->forToken = loc(1); - node->lparenToken = loc(2); - node->inToken = loc(4); - node->rparenToken = loc(6); - sym(1).Node = node; -} break; -./ - -IterationStatement: T_FOR T_LPAREN T_VAR VariableDeclarationNotIn T_IN Expression T_RPAREN Statement ; -/. -case $rule_number: { - AST::LocalForEachStatement *node = new (pool) AST::LocalForEachStatement( - sym(4).VariableDeclaration, sym(6).Expression, sym(8).Statement); - node->forToken = loc(1); - node->lparenToken = loc(2); - node->varToken = loc(3); - node->inToken = loc(5); - node->rparenToken = loc(7); - sym(1).Node = node; -} break; -./ - -ContinueStatement: T_CONTINUE T_AUTOMATIC_SEMICOLON ; -- automatic semicolon -ContinueStatement: T_CONTINUE T_SEMICOLON ; -/. -case $rule_number: { - AST::ContinueStatement *node = new (pool) AST::ContinueStatement(); - node->continueToken = loc(1); - node->semicolonToken = loc(2); - sym(1).Node = node; -} break; -./ - -ContinueStatement: T_CONTINUE JsIdentifier T_AUTOMATIC_SEMICOLON ; -- automatic semicolon -ContinueStatement: T_CONTINUE JsIdentifier T_SEMICOLON ; -/. -case $rule_number: { - AST::ContinueStatement *node = new (pool) AST::ContinueStatement(stringRef(2)); - node->continueToken = loc(1); - node->identifierToken = loc(2); - node->semicolonToken = loc(3); - sym(1).Node = node; -} break; -./ - -BreakStatement: T_BREAK T_AUTOMATIC_SEMICOLON ; -- automatic semicolon -BreakStatement: T_BREAK T_SEMICOLON ; -/. -case $rule_number: { - AST::BreakStatement *node = new (pool) AST::BreakStatement(QStringRef()); - node->breakToken = loc(1); - node->semicolonToken = loc(2); - sym(1).Node = node; -} break; -./ - -BreakStatement: T_BREAK JsIdentifier T_AUTOMATIC_SEMICOLON ; -- automatic semicolon -BreakStatement: T_BREAK JsIdentifier T_SEMICOLON ; -/. -case $rule_number: { - AST::BreakStatement *node = new (pool) AST::BreakStatement(stringRef(2)); - node->breakToken = loc(1); - node->identifierToken = loc(2); - node->semicolonToken = loc(3); - sym(1).Node = node; -} break; -./ - -ReturnStatement: T_RETURN ExpressionOpt T_AUTOMATIC_SEMICOLON ; -- automatic semicolon -ReturnStatement: T_RETURN ExpressionOpt T_SEMICOLON ; -/. -case $rule_number: { - AST::ReturnStatement *node = new (pool) AST::ReturnStatement(sym(2).Expression); - node->returnToken = loc(1); - node->semicolonToken = loc(3); - sym(1).Node = node; -} break; -./ - -WithStatement: T_WITH T_LPAREN Expression T_RPAREN Statement ; -/. -case $rule_number: { - AST::WithStatement *node = new (pool) AST::WithStatement(sym(3).Expression, sym(5).Statement); - node->withToken = loc(1); - node->lparenToken = loc(2); - node->rparenToken = loc(4); - sym(1).Node = node; -} break; -./ - -SwitchStatement: T_SWITCH T_LPAREN Expression T_RPAREN CaseBlock ; -/. -case $rule_number: { - AST::SwitchStatement *node = new (pool) AST::SwitchStatement(sym(3).Expression, sym(5).CaseBlock); - node->switchToken = loc(1); - node->lparenToken = loc(2); - node->rparenToken = loc(4); - sym(1).Node = node; -} break; -./ - -CaseBlock: T_LBRACE CaseClausesOpt T_RBRACE ; -/. -case $rule_number: { - AST::CaseBlock *node = new (pool) AST::CaseBlock(sym(2).CaseClauses); - node->lbraceToken = loc(1); - node->rbraceToken = loc(3); - sym(1).Node = node; -} break; -./ - -CaseBlock: T_LBRACE CaseClausesOpt DefaultClause CaseClausesOpt T_RBRACE ; -/. -case $rule_number: { - AST::CaseBlock *node = new (pool) AST::CaseBlock(sym(2).CaseClauses, sym(3).DefaultClause, sym(4).CaseClauses); - node->lbraceToken = loc(1); - node->rbraceToken = loc(5); - sym(1).Node = node; -} break; -./ - -CaseClauses: CaseClause ; -/. -case $rule_number: { - sym(1).Node = new (pool) AST::CaseClauses(sym(1).CaseClause); -} break; -./ - -CaseClauses: CaseClauses CaseClause ; -/. -case $rule_number: { - sym(1).Node = new (pool) AST::CaseClauses(sym(1).CaseClauses, sym(2).CaseClause); -} break; -./ - -CaseClausesOpt: ; -/. -case $rule_number: { - sym(1).Node = 0; -} break; -./ - -CaseClausesOpt: CaseClauses ; -/. -case $rule_number: { - sym(1).Node = sym(1).CaseClauses->finish (); -} break; -./ - -CaseClause: T_CASE Expression T_COLON StatementListOpt ; -/. -case $rule_number: { - AST::CaseClause *node = new (pool) AST::CaseClause(sym(2).Expression, sym(4).StatementList); - node->caseToken = loc(1); - node->colonToken = loc(3); - sym(1).Node = node; -} break; -./ - -DefaultClause: T_DEFAULT T_COLON StatementListOpt ; -/. -case $rule_number: { - AST::DefaultClause *node = new (pool) AST::DefaultClause(sym(3).StatementList); - node->defaultToken = loc(1); - node->colonToken = loc(2); - sym(1).Node = node; -} break; -./ - -LabelledStatement: T_SIGNAL T_COLON Statement ; -/.case $rule_number:./ - -LabelledStatement: T_PROPERTY T_COLON Statement ; -/. -case $rule_number: { - AST::LabelledStatement *node = new (pool) AST::LabelledStatement(stringRef(1), sym(3).Statement); - node->identifierToken = loc(1); - node->colonToken = loc(2); - sym(1).Node = node; -} break; -./ - -LabelledStatement: T_IDENTIFIER T_COLON Statement ; -/. -case $rule_number: { - AST::LabelledStatement *node = new (pool) AST::LabelledStatement(stringRef(1), sym(3).Statement); - node->identifierToken = loc(1); - node->colonToken = loc(2); - sym(1).Node = node; -} break; -./ - -ThrowStatement: T_THROW Expression T_AUTOMATIC_SEMICOLON ; -- automatic semicolon -ThrowStatement: T_THROW Expression T_SEMICOLON ; -/. -case $rule_number: { - AST::ThrowStatement *node = new (pool) AST::ThrowStatement(sym(2).Expression); - node->throwToken = loc(1); - node->semicolonToken = loc(3); - sym(1).Node = node; -} break; -./ - -TryStatement: T_TRY Block Catch ; -/. -case $rule_number: { - AST::TryStatement *node = new (pool) AST::TryStatement(sym(2).Statement, sym(3).Catch); - node->tryToken = loc(1); - sym(1).Node = node; -} break; -./ - -TryStatement: T_TRY Block Finally ; -/. -case $rule_number: { - AST::TryStatement *node = new (pool) AST::TryStatement(sym(2).Statement, sym(3).Finally); - node->tryToken = loc(1); - sym(1).Node = node; -} break; -./ - -TryStatement: T_TRY Block Catch Finally ; -/. -case $rule_number: { - AST::TryStatement *node = new (pool) AST::TryStatement(sym(2).Statement, sym(3).Catch, sym(4).Finally); - node->tryToken = loc(1); - sym(1).Node = node; -} break; -./ - -Catch: T_CATCH T_LPAREN JsIdentifier T_RPAREN Block ; -/. -case $rule_number: { - AST::Catch *node = new (pool) AST::Catch(stringRef(3), sym(5).Block); - node->catchToken = loc(1); - node->lparenToken = loc(2); - node->identifierToken = loc(3); - node->rparenToken = loc(4); - sym(1).Node = node; -} break; -./ - -Finally: T_FINALLY Block ; -/. -case $rule_number: { - AST::Finally *node = new (pool) AST::Finally(sym(2).Block); - node->finallyToken = loc(1); - sym(1).Node = node; -} break; -./ - -DebuggerStatement: T_DEBUGGER T_AUTOMATIC_SEMICOLON ; -- automatic semicolon -DebuggerStatement: T_DEBUGGER T_SEMICOLON ; -/. -case $rule_number: { - AST::DebuggerStatement *node = new (pool) AST::DebuggerStatement(); - node->debuggerToken = loc(1); - node->semicolonToken = loc(2); - sym(1).Node = node; -} break; -./ - -FunctionDeclaration: T_FUNCTION JsIdentifier T_LPAREN FormalParameterListOpt T_RPAREN T_LBRACE FunctionBodyOpt T_RBRACE ; -/. -case $rule_number: { - AST::FunctionDeclaration *node = new (pool) AST::FunctionDeclaration(stringRef(2), sym(4).FormalParameterList, sym(7).FunctionBody); - node->functionToken = loc(1); - node->identifierToken = loc(2); - node->lparenToken = loc(3); - node->rparenToken = loc(5); - node->lbraceToken = loc(6); - node->rbraceToken = loc(8); - sym(1).Node = node; -} break; -./ - -FunctionExpression: T_FUNCTION IdentifierOpt T_LPAREN FormalParameterListOpt T_RPAREN T_LBRACE FunctionBodyOpt T_RBRACE ; -/. -case $rule_number: { - AST::FunctionExpression *node = new (pool) AST::FunctionExpression(stringRef(2), sym(4).FormalParameterList, sym(7).FunctionBody); - node->functionToken = loc(1); - if (! stringRef(2).isNull()) - node->identifierToken = loc(2); - node->lparenToken = loc(3); - node->rparenToken = loc(5); - node->lbraceToken = loc(6); - node->rbraceToken = loc(8); - sym(1).Node = node; -} break; -./ - -FormalParameterList: JsIdentifier ; -/. -case $rule_number: { - AST::FormalParameterList *node = new (pool) AST::FormalParameterList(stringRef(1)); - node->identifierToken = loc(1); - sym(1).Node = node; -} break; -./ - -FormalParameterList: FormalParameterList T_COMMA JsIdentifier ; -/. -case $rule_number: { - AST::FormalParameterList *node = new (pool) AST::FormalParameterList(sym(1).FormalParameterList, stringRef(3)); - node->commaToken = loc(2); - node->identifierToken = loc(3); - sym(1).Node = node; -} break; -./ - -FormalParameterListOpt: ; -/. -case $rule_number: { - sym(1).Node = 0; -} break; -./ - -FormalParameterListOpt: FormalParameterList ; -/. -case $rule_number: { - sym(1).Node = sym(1).FormalParameterList->finish (); -} break; -./ - -FunctionBodyOpt: ; -/. -case $rule_number: { - sym(1).Node = 0; -} break; -./ - -FunctionBodyOpt: FunctionBody ; - -FunctionBody: SourceElements ; -/. -case $rule_number: { - sym(1).Node = new (pool) AST::FunctionBody(sym(1).SourceElements->finish ()); -} break; -./ - -Program: Empty ; - -Program: SourceElements ; -/. -case $rule_number: { - sym(1).Node = new (pool) AST::Program(sym(1).SourceElements->finish ()); -} break; -./ - -SourceElements: SourceElement ; -/. -case $rule_number: { - sym(1).Node = new (pool) AST::SourceElements(sym(1).SourceElement); -} break; -./ - -SourceElements: SourceElements SourceElement ; -/. -case $rule_number: { - sym(1).Node = new (pool) AST::SourceElements(sym(1).SourceElements, sym(2).SourceElement); -} break; -./ - -SourceElement: Statement ; -/. -case $rule_number: { - sym(1).Node = new (pool) AST::StatementSourceElement(sym(1).Statement); -} break; -./ - -SourceElement: FunctionDeclaration ; -/. -case $rule_number: { - sym(1).Node = new (pool) AST::FunctionSourceElement(sym(1).FunctionDeclaration); -} break; -./ - -IdentifierOpt: ; -/. -case $rule_number: { - stringRef(1) = QStringRef(); -} break; -./ - -IdentifierOpt: JsIdentifier ; - -PropertyNameAndValueListOpt: ; -/. -case $rule_number: { - sym(1).Node = 0; -} break; -./ - -PropertyNameAndValueListOpt: PropertyNameAndValueList ; - -/. - } // switch - action = nt_action(state_stack[tos], lhs[r] - TERMINAL_COUNT); - } // if - } while (action != 0); - - if (first_token == last_token) { - const int errorState = state_stack[tos]; - - // automatic insertion of `;' - if (yytoken != -1 && t_action(errorState, T_AUTOMATIC_SEMICOLON) && lexer->canInsertAutomaticSemicolon(yytoken)) { - SavedToken &tk = token_buffer[0]; - tk.token = yytoken; - tk.dval = yylval; - tk.spell = yytokenspell; - tk.loc = yylloc; - - yylloc = yyprevlloc; - yylloc.offset += yylloc.length; - yylloc.startColumn += yylloc.length; - yylloc.length = 0; - - //const QString msg = qApp->translate("QDeclarativeParser", "Missing `;'"); - //diagnostic_messages.append(DiagnosticMessage(DiagnosticMessage::Warning, yylloc, msg)); - - first_token = &token_buffer[0]; - last_token = &token_buffer[1]; - - yytoken = T_SEMICOLON; - yylval = 0; - - action = errorState; - - goto _Lcheck_token; - } - - hadErrors = true; - - token_buffer[0].token = yytoken; - token_buffer[0].dval = yylval; - token_buffer[0].spell = yytokenspell; - token_buffer[0].loc = yylloc; - - token_buffer[1].token = yytoken = lexer->lex(); - token_buffer[1].dval = yylval = lexer->tokenValue(); - token_buffer[1].spell = yytokenspell = lexer->tokenSpell(); - token_buffer[1].loc = yylloc = location(lexer); - - if (t_action(errorState, yytoken)) { - QString msg; - int token = token_buffer[0].token; - if (token < 0 || token >= TERMINAL_COUNT) - msg = qApp->translate("QDeclarativeParser", "Syntax error"); - else - msg = qApp->translate("QDeclarativeParser", "Unexpected token `%1'").arg(QLatin1String(spell[token])); - diagnostic_messages.append(DiagnosticMessage(DiagnosticMessage::Error, token_buffer[0].loc, msg)); - - action = errorState; - goto _Lcheck_token; - } - - static int tokens[] = { - T_PLUS, - T_EQ, - - T_COMMA, - T_COLON, - T_SEMICOLON, - - T_RPAREN, T_RBRACKET, T_RBRACE, - - T_NUMERIC_LITERAL, - T_IDENTIFIER, - - T_LPAREN, T_LBRACKET, T_LBRACE, - - EOF_SYMBOL - }; - - for (int *tk = tokens; *tk != EOF_SYMBOL; ++tk) { - int a = t_action(errorState, *tk); - if (a > 0 && t_action(a, yytoken)) { - const QString msg = qApp->translate("QDeclarativeParser", "Expected token `%1'").arg(QLatin1String(spell[*tk])); - diagnostic_messages.append(DiagnosticMessage(DiagnosticMessage::Error, token_buffer[0].loc, msg)); - - yytoken = *tk; - yylval = 0; - yylloc = token_buffer[0].loc; - yylloc.length = 0; - - first_token = &token_buffer[0]; - last_token = &token_buffer[2]; - - action = errorState; - goto _Lcheck_token; - } - } - - for (int tk = 1; tk < TERMINAL_COUNT; ++tk) { - if (tk == T_AUTOMATIC_SEMICOLON || tk == T_FEED_UI_PROGRAM || - tk == T_FEED_JS_STATEMENT || tk == T_FEED_JS_EXPRESSION || - tk == T_FEED_JS_SOURCE_ELEMENT) - continue; - - int a = t_action(errorState, tk); - if (a > 0 && t_action(a, yytoken)) { - const QString msg = qApp->translate("QDeclarativeParser", "Expected token `%1'").arg(QLatin1String(spell[tk])); - diagnostic_messages.append(DiagnosticMessage(DiagnosticMessage::Error, token_buffer[0].loc, msg)); - - yytoken = tk; - yylval = 0; - yylloc = token_buffer[0].loc; - yylloc.length = 0; - - action = errorState; - goto _Lcheck_token; - } - } - - const QString msg = qApp->translate("QDeclarativeParser", "Syntax error"); - diagnostic_messages.append(DiagnosticMessage(DiagnosticMessage::Error, token_buffer[0].loc, msg)); - } - - return false; -} - -QT_QML_END_NAMESPACE - - -./ -/: -QT_QML_END_NAMESPACE - - - -#endif // QDECLARATIVEJSPARSER_P_H -:/ diff --git a/src/declarative/qml/parser/qdeclarativejsast.cpp b/src/declarative/qml/parser/qdeclarativejsast.cpp deleted file mode 100644 index 8654c4392f..0000000000 --- a/src/declarative/qml/parser/qdeclarativejsast.cpp +++ /dev/null @@ -1,931 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qdeclarativejsast_p.h" - -#include "qdeclarativejsastvisitor_p.h" - -QT_QML_BEGIN_NAMESPACE - -namespace QDeclarativeJS { namespace AST { - -void Node::accept(Visitor *visitor) -{ - if (visitor->preVisit(this)) { - accept0(visitor); - } - visitor->postVisit(this); -} - -void Node::accept(Node *node, Visitor *visitor) -{ - if (node) - node->accept(visitor); -} - -ExpressionNode *Node::expressionCast() -{ - return 0; -} - -BinaryExpression *Node::binaryExpressionCast() -{ - return 0; -} - -Statement *Node::statementCast() -{ - return 0; -} - -UiObjectMember *Node::uiObjectMemberCast() -{ - return 0; -} - -ExpressionNode *ExpressionNode::expressionCast() -{ - return this; -} - -BinaryExpression *BinaryExpression::binaryExpressionCast() -{ - return this; -} - -Statement *Statement::statementCast() -{ - return this; -} - -UiObjectMember *UiObjectMember::uiObjectMemberCast() -{ - return this; -} - -void NestedExpression::accept0(Visitor *visitor) -{ - if (visitor->visit(this)) { - accept(expression, visitor); - } - visitor->endVisit(this); -} - -void ThisExpression::accept0(Visitor *visitor) -{ - if (visitor->visit(this)) { - } - - visitor->endVisit(this); -} - -void IdentifierExpression::accept0(Visitor *visitor) -{ - if (visitor->visit(this)) { - } - - visitor->endVisit(this); -} - -void NullExpression::accept0(Visitor *visitor) -{ - if (visitor->visit(this)) { - } - - visitor->endVisit(this); -} - -void TrueLiteral::accept0(Visitor *visitor) -{ - if (visitor->visit(this)) { - } - - visitor->endVisit(this); -} - -void FalseLiteral::accept0(Visitor *visitor) -{ - if (visitor->visit(this)) { - } - - visitor->endVisit(this); -} - -void StringLiteral::accept0(Visitor *visitor) -{ - if (visitor->visit(this)) { - } - - visitor->endVisit(this); -} - -void NumericLiteral::accept0(Visitor *visitor) -{ - if (visitor->visit(this)) { - } - - visitor->endVisit(this); -} - -void RegExpLiteral::accept0(Visitor *visitor) -{ - if (visitor->visit(this)) { - } - - visitor->endVisit(this); -} - -void ArrayLiteral::accept0(Visitor *visitor) -{ - if (visitor->visit(this)) { - accept(elements, visitor); - accept(elision, visitor); - } - - visitor->endVisit(this); -} - -void ObjectLiteral::accept0(Visitor *visitor) -{ - if (visitor->visit(this)) { - accept(properties, visitor); - } - - visitor->endVisit(this); -} - -void ElementList::accept0(Visitor *visitor) -{ - if (visitor->visit(this)) { - for (ElementList *it = this; it; it = it->next) { - accept(it->elision, visitor); - accept(it->expression, visitor); - } - } - - visitor->endVisit(this); -} - -void Elision::accept0(Visitor *visitor) -{ - if (visitor->visit(this)) { - // ### - } - - visitor->endVisit(this); -} - -void PropertyNameAndValueList::accept0(Visitor *visitor) -{ - if (visitor->visit(this)) { - for (PropertyNameAndValueList *it = this; it; it = it->next) { - accept(it->name, visitor); - accept(it->value, visitor); - } - } - - visitor->endVisit(this); -} - -void IdentifierPropertyName::accept0(Visitor *visitor) -{ - if (visitor->visit(this)) { - } - - visitor->endVisit(this); -} - -void StringLiteralPropertyName::accept0(Visitor *visitor) -{ - if (visitor->visit(this)) { - } - - visitor->endVisit(this); -} - -void NumericLiteralPropertyName::accept0(Visitor *visitor) -{ - if (visitor->visit(this)) { - } - - visitor->endVisit(this); -} - -void ArrayMemberExpression::accept0(Visitor *visitor) -{ - if (visitor->visit(this)) { - accept(base, visitor); - accept(expression, visitor); - } - - visitor->endVisit(this); -} - -void FieldMemberExpression::accept0(Visitor *visitor) -{ - if (visitor->visit(this)) { - accept(base, visitor); - } - - visitor->endVisit(this); -} - -void NewMemberExpression::accept0(Visitor *visitor) -{ - if (visitor->visit(this)) { - accept(base, visitor); - accept(arguments, visitor); - } - - visitor->endVisit(this); -} - -void NewExpression::accept0(Visitor *visitor) -{ - if (visitor->visit(this)) { - accept(expression, visitor); - } - - visitor->endVisit(this); -} - -void CallExpression::accept0(Visitor *visitor) -{ - if (visitor->visit(this)) { - accept(base, visitor); - accept(arguments, visitor); - } - - visitor->endVisit(this); -} - -void ArgumentList::accept0(Visitor *visitor) -{ - if (visitor->visit(this)) { - for (ArgumentList *it = this; it; it = it->next) { - accept(it->expression, visitor); - } - } - - visitor->endVisit(this); -} - -void PostIncrementExpression::accept0(Visitor *visitor) -{ - if (visitor->visit(this)) { - accept(base, visitor); - } - - visitor->endVisit(this); -} - -void PostDecrementExpression::accept0(Visitor *visitor) -{ - if (visitor->visit(this)) { - accept(base, visitor); - } - - visitor->endVisit(this); -} - -void DeleteExpression::accept0(Visitor *visitor) -{ - if (visitor->visit(this)) { - accept(expression, visitor); - } - - visitor->endVisit(this); -} - -void VoidExpression::accept0(Visitor *visitor) -{ - if (visitor->visit(this)) { - accept(expression, visitor); - } - - visitor->endVisit(this); -} - -void TypeOfExpression::accept0(Visitor *visitor) -{ - if (visitor->visit(this)) { - accept(expression, visitor); - } - - visitor->endVisit(this); -} - -void PreIncrementExpression::accept0(Visitor *visitor) -{ - if (visitor->visit(this)) { - accept(expression, visitor); - } - - visitor->endVisit(this); -} - -void PreDecrementExpression::accept0(Visitor *visitor) -{ - if (visitor->visit(this)) { - accept(expression, visitor); - } - - visitor->endVisit(this); -} - -void UnaryPlusExpression::accept0(Visitor *visitor) -{ - if (visitor->visit(this)) { - accept(expression, visitor); - } - - visitor->endVisit(this); -} - -void UnaryMinusExpression::accept0(Visitor *visitor) -{ - if (visitor->visit(this)) { - accept(expression, visitor); - } - - visitor->endVisit(this); -} - -void TildeExpression::accept0(Visitor *visitor) -{ - if (visitor->visit(this)) { - accept(expression, visitor); - } - - visitor->endVisit(this); -} - -void NotExpression::accept0(Visitor *visitor) -{ - if (visitor->visit(this)) { - accept(expression, visitor); - } - - visitor->endVisit(this); -} - -void BinaryExpression::accept0(Visitor *visitor) -{ - if (visitor->visit(this)) { - accept(left, visitor); - accept(right, visitor); - } - - visitor->endVisit(this); -} - -void ConditionalExpression::accept0(Visitor *visitor) -{ - if (visitor->visit(this)) { - accept(expression, visitor); - accept(ok, visitor); - accept(ko, visitor); - } - - visitor->endVisit(this); -} - -void Expression::accept0(Visitor *visitor) -{ - if (visitor->visit(this)) { - accept(left, visitor); - accept(right, visitor); - } - - visitor->endVisit(this); -} - -void Block::accept0(Visitor *visitor) -{ - if (visitor->visit(this)) { - accept(statements, visitor); - } - - visitor->endVisit(this); -} - -void StatementList::accept0(Visitor *visitor) -{ - if (visitor->visit(this)) { - for (StatementList *it = this; it; it = it->next) { - accept(it->statement, visitor); - } - } - - visitor->endVisit(this); -} - -void VariableStatement::accept0(Visitor *visitor) -{ - if (visitor->visit(this)) { - accept(declarations, visitor); - } - - visitor->endVisit(this); -} - -void VariableDeclarationList::accept0(Visitor *visitor) -{ - if (visitor->visit(this)) { - for (VariableDeclarationList *it = this; it; it = it->next) { - accept(it->declaration, visitor); - } - } - - visitor->endVisit(this); -} - -void VariableDeclaration::accept0(Visitor *visitor) -{ - if (visitor->visit(this)) { - accept(expression, visitor); - } - - visitor->endVisit(this); -} - -void EmptyStatement::accept0(Visitor *visitor) -{ - if (visitor->visit(this)) { - } - - visitor->endVisit(this); -} - -void ExpressionStatement::accept0(Visitor *visitor) -{ - if (visitor->visit(this)) { - accept(expression, visitor); - } - - visitor->endVisit(this); -} - -void IfStatement::accept0(Visitor *visitor) -{ - if (visitor->visit(this)) { - accept(expression, visitor); - accept(ok, visitor); - accept(ko, visitor); - } - - visitor->endVisit(this); -} - -void DoWhileStatement::accept0(Visitor *visitor) -{ - if (visitor->visit(this)) { - accept(statement, visitor); - accept(expression, visitor); - } - - visitor->endVisit(this); -} - -void WhileStatement::accept0(Visitor *visitor) -{ - if (visitor->visit(this)) { - accept(expression, visitor); - accept(statement, visitor); - } - - visitor->endVisit(this); -} - -void ForStatement::accept0(Visitor *visitor) -{ - if (visitor->visit(this)) { - accept(initialiser, visitor); - accept(condition, visitor); - accept(expression, visitor); - accept(statement, visitor); - } - - visitor->endVisit(this); -} - -void LocalForStatement::accept0(Visitor *visitor) -{ - if (visitor->visit(this)) { - accept(declarations, visitor); - accept(condition, visitor); - accept(expression, visitor); - accept(statement, visitor); - } - - visitor->endVisit(this); -} - -void ForEachStatement::accept0(Visitor *visitor) -{ - if (visitor->visit(this)) { - accept(initialiser, visitor); - accept(expression, visitor); - accept(statement, visitor); - } - - visitor->endVisit(this); -} - -void LocalForEachStatement::accept0(Visitor *visitor) -{ - if (visitor->visit(this)) { - accept(declaration, visitor); - accept(expression, visitor); - accept(statement, visitor); - } - - visitor->endVisit(this); -} - -void ContinueStatement::accept0(Visitor *visitor) -{ - if (visitor->visit(this)) { - } - - visitor->endVisit(this); -} - -void BreakStatement::accept0(Visitor *visitor) -{ - if (visitor->visit(this)) { - } - - visitor->endVisit(this); -} - -void ReturnStatement::accept0(Visitor *visitor) -{ - if (visitor->visit(this)) { - accept(expression, visitor); - } - - visitor->endVisit(this); -} - -void WithStatement::accept0(Visitor *visitor) -{ - if (visitor->visit(this)) { - accept(expression, visitor); - accept(statement, visitor); - } - - visitor->endVisit(this); -} - -void SwitchStatement::accept0(Visitor *visitor) -{ - if (visitor->visit(this)) { - accept(expression, visitor); - accept(block, visitor); - } - - visitor->endVisit(this); -} - -void CaseBlock::accept0(Visitor *visitor) -{ - if (visitor->visit(this)) { - accept(clauses, visitor); - accept(defaultClause, visitor); - accept(moreClauses, visitor); - } - - visitor->endVisit(this); -} - -void CaseClauses::accept0(Visitor *visitor) -{ - if (visitor->visit(this)) { - for (CaseClauses *it = this; it; it = it->next) { - accept(it->clause, visitor); - } - } - - visitor->endVisit(this); -} - -void CaseClause::accept0(Visitor *visitor) -{ - if (visitor->visit(this)) { - accept(expression, visitor); - accept(statements, visitor); - } - - visitor->endVisit(this); -} - -void DefaultClause::accept0(Visitor *visitor) -{ - if (visitor->visit(this)) { - accept(statements, visitor); - } - - visitor->endVisit(this); -} - -void LabelledStatement::accept0(Visitor *visitor) -{ - if (visitor->visit(this)) { - accept(statement, visitor); - } - - visitor->endVisit(this); -} - -void ThrowStatement::accept0(Visitor *visitor) -{ - if (visitor->visit(this)) { - accept(expression, visitor); - } - - visitor->endVisit(this); -} - -void TryStatement::accept0(Visitor *visitor) -{ - if (visitor->visit(this)) { - accept(statement, visitor); - accept(catchExpression, visitor); - accept(finallyExpression, visitor); - } - - visitor->endVisit(this); -} - -void Catch::accept0(Visitor *visitor) -{ - if (visitor->visit(this)) { - accept(statement, visitor); - } - - visitor->endVisit(this); -} - -void Finally::accept0(Visitor *visitor) -{ - if (visitor->visit(this)) { - accept(statement, visitor); - } - - visitor->endVisit(this); -} - -void FunctionDeclaration::accept0(Visitor *visitor) -{ - if (visitor->visit(this)) { - accept(formals, visitor); - accept(body, visitor); - } - - visitor->endVisit(this); -} - -void FunctionExpression::accept0(Visitor *visitor) -{ - if (visitor->visit(this)) { - accept(formals, visitor); - accept(body, visitor); - } - - visitor->endVisit(this); -} - -void FormalParameterList::accept0(Visitor *visitor) -{ - if (visitor->visit(this)) { - // ### - } - - visitor->endVisit(this); -} - -void FunctionBody::accept0(Visitor *visitor) -{ - if (visitor->visit(this)) { - accept(elements, visitor); - } - - visitor->endVisit(this); -} - -void Program::accept0(Visitor *visitor) -{ - if (visitor->visit(this)) { - accept(elements, visitor); - } - - visitor->endVisit(this); -} - -void SourceElements::accept0(Visitor *visitor) -{ - if (visitor->visit(this)) { - for (SourceElements *it = this; it; it = it->next) { - accept(it->element, visitor); - } - } - - visitor->endVisit(this); -} - -void FunctionSourceElement::accept0(Visitor *visitor) -{ - if (visitor->visit(this)) { - accept(declaration, visitor); - } - - visitor->endVisit(this); -} - -void StatementSourceElement::accept0(Visitor *visitor) -{ - if (visitor->visit(this)) { - accept(statement, visitor); - } - - visitor->endVisit(this); -} - -void DebuggerStatement::accept0(Visitor *visitor) -{ - if (visitor->visit(this)) { - } - - visitor->endVisit(this); -} - -void UiProgram::accept0(Visitor *visitor) -{ - if (visitor->visit(this)) { - accept(imports, visitor); - accept(members, visitor); - } - - visitor->endVisit(this); -} - -void UiPublicMember::accept0(Visitor *visitor) -{ - if (visitor->visit(this)) { - accept(statement, visitor); - accept(binding, visitor); - } - - visitor->endVisit(this); -} - -void UiObjectDefinition::accept0(Visitor *visitor) -{ - if (visitor->visit(this)) { - accept(qualifiedTypeNameId, visitor); - accept(initializer, visitor); - } - - visitor->endVisit(this); -} - -void UiObjectInitializer::accept0(Visitor *visitor) -{ - if (visitor->visit(this)) { - accept(members, visitor); - } - - visitor->endVisit(this); -} - -void UiObjectBinding::accept0(Visitor *visitor) -{ - if (visitor->visit(this)) { - accept(qualifiedId, visitor); - accept(qualifiedTypeNameId, visitor); - accept(initializer, visitor); - } - - visitor->endVisit(this); -} - -void UiScriptBinding::accept0(Visitor *visitor) -{ - if (visitor->visit(this)) { - accept(qualifiedId, visitor); - accept(statement, visitor); - } - - visitor->endVisit(this); -} - -void UiArrayBinding::accept0(Visitor *visitor) -{ - if (visitor->visit(this)) { - accept(qualifiedId, visitor); - accept(members, visitor); - } - - visitor->endVisit(this); -} - -void UiObjectMemberList::accept0(Visitor *visitor) -{ - if (visitor->visit(this)) { - for (UiObjectMemberList *it = this; it; it = it->next) - accept(it->member, visitor); - } - - visitor->endVisit(this); -} - -void UiArrayMemberList::accept0(Visitor *visitor) -{ - if (visitor->visit(this)) { - for (UiArrayMemberList *it = this; it; it = it->next) - accept(it->member, visitor); - } - - visitor->endVisit(this); -} - -void UiQualifiedId::accept0(Visitor *visitor) -{ - if (visitor->visit(this)) { - } - - visitor->endVisit(this); -} - -void UiImport::accept0(Visitor *visitor) -{ - if (visitor->visit(this)) { - accept(importUri, visitor); - } - - visitor->endVisit(this); -} - -void UiImportList::accept0(Visitor *visitor) -{ - if (visitor->visit(this)) { - accept(import, visitor); - accept(next, visitor); - } - - visitor->endVisit(this); -} - -void UiSourceElement::accept0(Visitor *visitor) -{ - if (visitor->visit(this)) { - accept(sourceElement, visitor); - } - - visitor->endVisit(this); -} - -} } // namespace QDeclarativeJS::AST - -QT_QML_END_NAMESPACE - - diff --git a/src/declarative/qml/parser/qdeclarativejsast_p.h b/src/declarative/qml/parser/qdeclarativejsast_p.h deleted file mode 100644 index 04bf3ce122..0000000000 --- a/src/declarative/qml/parser/qdeclarativejsast_p.h +++ /dev/null @@ -1,2640 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QDECLARATIVEJSAST_P_H -#define QDECLARATIVEJSAST_P_H - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists purely as an -// implementation detail. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - -#include "qdeclarativejsastvisitor_p.h" -#include "qdeclarativejsglobal_p.h" -#include "qdeclarativejsmemorypool_p.h" - -#include - -QT_QML_BEGIN_NAMESPACE - -#define QDECLARATIVEJS_DECLARE_AST_NODE(name) \ - enum { K = Kind_##name }; - -namespace QSOperator // ### rename -{ - -enum Op { - Add, - And, - InplaceAnd, - Assign, - BitAnd, - BitOr, - BitXor, - InplaceSub, - Div, - InplaceDiv, - Equal, - Ge, - Gt, - In, - InplaceAdd, - InstanceOf, - Le, - LShift, - InplaceLeftShift, - Lt, - Mod, - InplaceMod, - Mul, - InplaceMul, - NotEqual, - Or, - InplaceOr, - RShift, - InplaceRightShift, - StrictEqual, - StrictNotEqual, - Sub, - URShift, - InplaceURightShift, - InplaceXor -}; - -} // namespace QSOperator - -namespace QDeclarativeJS { - -namespace AST { - -template -_T1 cast(_T2 *ast) -{ - if (ast && ast->kind == static_cast<_T1>(0)->K) - return static_cast<_T1>(ast); - - return 0; -} - -class QML_PARSER_EXPORT Node: public Managed -{ -public: - enum Kind { - Kind_Undefined, - - Kind_ArgumentList, - Kind_ArrayLiteral, - Kind_ArrayMemberExpression, - Kind_BinaryExpression, - Kind_Block, - Kind_BreakStatement, - Kind_CallExpression, - Kind_CaseBlock, - Kind_CaseClause, - Kind_CaseClauses, - Kind_Catch, - Kind_ConditionalExpression, - Kind_ContinueStatement, - Kind_DebuggerStatement, - Kind_DefaultClause, - Kind_DeleteExpression, - Kind_DoWhileStatement, - Kind_ElementList, - Kind_Elision, - Kind_EmptyStatement, - Kind_Expression, - Kind_ExpressionStatement, - Kind_FalseLiteral, - Kind_FieldMemberExpression, - Kind_Finally, - Kind_ForEachStatement, - Kind_ForStatement, - Kind_FormalParameterList, - Kind_FunctionBody, - Kind_FunctionDeclaration, - Kind_FunctionExpression, - Kind_FunctionSourceElement, - Kind_IdentifierExpression, - Kind_IdentifierPropertyName, - Kind_IfStatement, - Kind_LabelledStatement, - Kind_LocalForEachStatement, - Kind_LocalForStatement, - Kind_NewExpression, - Kind_NewMemberExpression, - Kind_NotExpression, - Kind_NullExpression, - Kind_NumericLiteral, - Kind_NumericLiteralPropertyName, - Kind_ObjectLiteral, - Kind_PostDecrementExpression, - Kind_PostIncrementExpression, - Kind_PreDecrementExpression, - Kind_PreIncrementExpression, - Kind_Program, - Kind_PropertyName, - Kind_PropertyNameAndValueList, - Kind_RegExpLiteral, - Kind_ReturnStatement, - Kind_SourceElement, - Kind_SourceElements, - Kind_StatementList, - Kind_StatementSourceElement, - Kind_StringLiteral, - Kind_StringLiteralPropertyName, - Kind_SwitchStatement, - Kind_ThisExpression, - Kind_ThrowStatement, - Kind_TildeExpression, - Kind_TrueLiteral, - Kind_TryStatement, - Kind_TypeOfExpression, - Kind_UnaryMinusExpression, - Kind_UnaryPlusExpression, - Kind_VariableDeclaration, - Kind_VariableDeclarationList, - Kind_VariableStatement, - Kind_VoidExpression, - Kind_WhileStatement, - Kind_WithStatement, - Kind_NestedExpression, - - Kind_UiArrayBinding, - Kind_UiImport, - Kind_UiImportList, - Kind_UiObjectBinding, - Kind_UiObjectDefinition, - Kind_UiObjectInitializer, - Kind_UiObjectMemberList, - Kind_UiArrayMemberList, - Kind_UiProgram, - Kind_UiParameterList, - Kind_UiPublicMember, - Kind_UiQualifiedId, - Kind_UiScriptBinding, - Kind_UiSourceElement - }; - - inline Node() - : kind(Kind_Undefined) {} - - // NOTE: node destructors are never called, - // instead we block free the memory - // (see the NodePool class) - virtual ~Node() {} - - virtual ExpressionNode *expressionCast(); - virtual BinaryExpression *binaryExpressionCast(); - virtual Statement *statementCast(); - virtual UiObjectMember *uiObjectMemberCast(); - - void accept(Visitor *visitor); - static void accept(Node *node, Visitor *visitor); - - inline static void acceptChild(Node *node, Visitor *visitor) - { return accept(node, visitor); } // ### remove - - virtual void accept0(Visitor *visitor) = 0; - virtual SourceLocation firstSourceLocation() const = 0; - virtual SourceLocation lastSourceLocation() const = 0; - -// attributes - int kind; -}; - -class QML_PARSER_EXPORT ExpressionNode: public Node -{ -public: - ExpressionNode() {} - - virtual ExpressionNode *expressionCast(); -}; - -class QML_PARSER_EXPORT Statement: public Node -{ -public: - Statement() {} - - virtual Statement *statementCast(); -}; - -class QML_PARSER_EXPORT NestedExpression: public ExpressionNode -{ -public: - QDECLARATIVEJS_DECLARE_AST_NODE(NestedExpression) - - NestedExpression(ExpressionNode *expression) - : expression(expression) - { kind = K; } - - virtual void accept0(Visitor *visitor); - - virtual SourceLocation firstSourceLocation() const - { return lparenToken; } - - virtual SourceLocation lastSourceLocation() const - { return rparenToken; } - -// attributes - ExpressionNode *expression; - SourceLocation lparenToken; - SourceLocation rparenToken; -}; - -class QML_PARSER_EXPORT ThisExpression: public ExpressionNode -{ -public: - QDECLARATIVEJS_DECLARE_AST_NODE(ThisExpression) - - ThisExpression() { kind = K; } - - virtual void accept0(Visitor *visitor); - - virtual SourceLocation firstSourceLocation() const - { return thisToken; } - - virtual SourceLocation lastSourceLocation() const - { return thisToken; } - -// attributes - SourceLocation thisToken; -}; - -class QML_PARSER_EXPORT IdentifierExpression: public ExpressionNode -{ -public: - QDECLARATIVEJS_DECLARE_AST_NODE(IdentifierExpression) - - IdentifierExpression(const QStringRef &n): - name (n) { kind = K; } - - virtual void accept0(Visitor *visitor); - - virtual SourceLocation firstSourceLocation() const - { return identifierToken; } - - virtual SourceLocation lastSourceLocation() const - { return identifierToken; } - -// attributes - QStringRef name; - SourceLocation identifierToken; -}; - -class QML_PARSER_EXPORT NullExpression: public ExpressionNode -{ -public: - QDECLARATIVEJS_DECLARE_AST_NODE(NullExpression) - - NullExpression() { kind = K; } - - virtual void accept0(Visitor *visitor); - - virtual SourceLocation firstSourceLocation() const - { return nullToken; } - - virtual SourceLocation lastSourceLocation() const - { return nullToken; } - -// attributes - SourceLocation nullToken; -}; - -class QML_PARSER_EXPORT TrueLiteral: public ExpressionNode -{ -public: - QDECLARATIVEJS_DECLARE_AST_NODE(TrueLiteral) - - TrueLiteral() { kind = K; } - - virtual void accept0(Visitor *visitor); - - virtual SourceLocation firstSourceLocation() const - { return trueToken; } - - virtual SourceLocation lastSourceLocation() const - { return trueToken; } - -// attributes - SourceLocation trueToken; -}; - -class QML_PARSER_EXPORT FalseLiteral: public ExpressionNode -{ -public: - QDECLARATIVEJS_DECLARE_AST_NODE(FalseLiteral) - - FalseLiteral() { kind = K; } - - virtual void accept0(Visitor *visitor); - - virtual SourceLocation firstSourceLocation() const - { return falseToken; } - - virtual SourceLocation lastSourceLocation() const - { return falseToken; } - -// attributes - SourceLocation falseToken; -}; - -class QML_PARSER_EXPORT NumericLiteral: public ExpressionNode -{ -public: - QDECLARATIVEJS_DECLARE_AST_NODE(NumericLiteral) - - NumericLiteral(double v): - value(v) { kind = K; } - - virtual void accept0(Visitor *visitor); - - virtual SourceLocation firstSourceLocation() const - { return literalToken; } - - virtual SourceLocation lastSourceLocation() const - { return literalToken; } - -// attributes: - double value; - SourceLocation literalToken; -}; - -class QML_PARSER_EXPORT StringLiteral: public ExpressionNode -{ -public: - QDECLARATIVEJS_DECLARE_AST_NODE(StringLiteral) - - StringLiteral(const QStringRef &v): - value (v) { kind = K; } - - virtual void accept0(Visitor *visitor); - - virtual SourceLocation firstSourceLocation() const - { return literalToken; } - - virtual SourceLocation lastSourceLocation() const - { return literalToken; } - -// attributes: - QStringRef value; - SourceLocation literalToken; -}; - -class QML_PARSER_EXPORT RegExpLiteral: public ExpressionNode -{ -public: - QDECLARATIVEJS_DECLARE_AST_NODE(RegExpLiteral) - - RegExpLiteral(const QStringRef &p, int f): - pattern (p), flags (f) { kind = K; } - - virtual void accept0(Visitor *visitor); - - virtual SourceLocation firstSourceLocation() const - { return literalToken; } - - virtual SourceLocation lastSourceLocation() const - { return literalToken; } - -// attributes: - QStringRef pattern; - int flags; - SourceLocation literalToken; -}; - -class QML_PARSER_EXPORT ArrayLiteral: public ExpressionNode -{ -public: - QDECLARATIVEJS_DECLARE_AST_NODE(ArrayLiteral) - - ArrayLiteral(Elision *e): - elements (0), elision (e) - { kind = K; } - - ArrayLiteral(ElementList *elts): - elements (elts), elision (0) - { kind = K; } - - ArrayLiteral(ElementList *elts, Elision *e): - elements (elts), elision (e) - { kind = K; } - - virtual void accept0(Visitor *visitor); - - virtual SourceLocation firstSourceLocation() const - { return lbracketToken; } - - virtual SourceLocation lastSourceLocation() const - { return rbracketToken; } - -// attributes - ElementList *elements; - Elision *elision; - SourceLocation lbracketToken; - SourceLocation commaToken; - SourceLocation rbracketToken; -}; - -class QML_PARSER_EXPORT ObjectLiteral: public ExpressionNode -{ -public: - QDECLARATIVEJS_DECLARE_AST_NODE(ObjectLiteral) - - ObjectLiteral(): - properties (0) { kind = K; } - - ObjectLiteral(PropertyNameAndValueList *plist): - properties (plist) { kind = K; } - - virtual void accept0(Visitor *visitor); - - virtual SourceLocation firstSourceLocation() const - { return lbraceToken; } - - virtual SourceLocation lastSourceLocation() const - { return rbraceToken; } - -// attributes - PropertyNameAndValueList *properties; - SourceLocation lbraceToken; - SourceLocation rbraceToken; -}; - -class QML_PARSER_EXPORT Elision: public Node -{ -public: - QDECLARATIVEJS_DECLARE_AST_NODE(Elision) - - Elision(): - next (this) { kind = K; } - - Elision(Elision *previous) - { - kind = K; - next = previous->next; - previous->next = this; - } - - virtual void accept0(Visitor *visitor); - - virtual SourceLocation firstSourceLocation() const - { return commaToken; } - - virtual SourceLocation lastSourceLocation() const - { return next ? next->lastSourceLocation() : commaToken; } - - inline Elision *finish () - { - Elision *front = next; - next = 0; - return front; - } - -// attributes - Elision *next; - SourceLocation commaToken; -}; - -class QML_PARSER_EXPORT ElementList: public Node -{ -public: - QDECLARATIVEJS_DECLARE_AST_NODE(ElementList) - - ElementList(Elision *e, ExpressionNode *expr): - elision (e), expression (expr), next (this) - { kind = K; } - - ElementList(ElementList *previous, Elision *e, ExpressionNode *expr): - elision (e), expression (expr) - { - kind = K; - next = previous->next; - previous->next = this; - } - - inline ElementList *finish () - { - ElementList *front = next; - next = 0; - return front; - } - - virtual void accept0(Visitor *visitor); - - virtual SourceLocation firstSourceLocation() const - { - if (elision) - return elision->firstSourceLocation(); - return expression->firstSourceLocation(); - } - - virtual SourceLocation lastSourceLocation() const - { - if (next) - return next->lastSourceLocation(); - return expression->lastSourceLocation(); - } - -// attributes - Elision *elision; - ExpressionNode *expression; - ElementList *next; - SourceLocation commaToken; -}; - -class QML_PARSER_EXPORT PropertyName: public Node -{ -public: - QDECLARATIVEJS_DECLARE_AST_NODE(PropertyName) - - PropertyName() { kind = K; } - - virtual SourceLocation firstSourceLocation() const - { return propertyNameToken; } - - virtual SourceLocation lastSourceLocation() const - { return propertyNameToken; } - -// attributes - SourceLocation propertyNameToken; -}; - -class QML_PARSER_EXPORT PropertyNameAndValueList: public Node -{ -public: - QDECLARATIVEJS_DECLARE_AST_NODE(PropertyNameAndValueList) - - PropertyNameAndValueList(PropertyName *n, ExpressionNode *v): - name (n), value (v), next (this) - { kind = K; } - - PropertyNameAndValueList(PropertyNameAndValueList *previous, PropertyName *n, ExpressionNode *v): - name (n), value (v) - { - kind = K; - next = previous->next; - previous->next = this; - } - - virtual void accept0(Visitor *visitor); - - virtual SourceLocation firstSourceLocation() const - { return name->firstSourceLocation(); } - - virtual SourceLocation lastSourceLocation() const - { - if (next) - return next->lastSourceLocation(); - return value->lastSourceLocation(); - } - - inline PropertyNameAndValueList *finish () - { - PropertyNameAndValueList *front = next; - next = 0; - return front; - } - -// attributes - PropertyName *name; - ExpressionNode *value; - PropertyNameAndValueList *next; - SourceLocation colonToken; - SourceLocation commaToken; -}; - -class QML_PARSER_EXPORT IdentifierPropertyName: public PropertyName -{ -public: - QDECLARATIVEJS_DECLARE_AST_NODE(IdentifierPropertyName) - - IdentifierPropertyName(const QStringRef &n): - id (n) { kind = K; } - - virtual void accept0(Visitor *visitor); - -// attributes - QStringRef id; -}; - -class QML_PARSER_EXPORT StringLiteralPropertyName: public PropertyName -{ -public: - QDECLARATIVEJS_DECLARE_AST_NODE(StringLiteralPropertyName) - - StringLiteralPropertyName(const QStringRef &n): - id (n) { kind = K; } - - virtual void accept0(Visitor *visitor); - -// attributes - QStringRef id; -}; - -class QML_PARSER_EXPORT NumericLiteralPropertyName: public PropertyName -{ -public: - QDECLARATIVEJS_DECLARE_AST_NODE(NumericLiteralPropertyName) - - NumericLiteralPropertyName(double n): - id (n) { kind = K; } - - virtual void accept0(Visitor *visitor); - -// attributes - double id; -}; - -class QML_PARSER_EXPORT ArrayMemberExpression: public ExpressionNode -{ -public: - QDECLARATIVEJS_DECLARE_AST_NODE(ArrayMemberExpression) - - ArrayMemberExpression(ExpressionNode *b, ExpressionNode *e): - base (b), expression (e) - { kind = K; } - - virtual void accept0(Visitor *visitor); - - virtual SourceLocation firstSourceLocation() const - { return base->firstSourceLocation(); } - - virtual SourceLocation lastSourceLocation() const - { return rbracketToken; } - -// attributes - ExpressionNode *base; - ExpressionNode *expression; - SourceLocation lbracketToken; - SourceLocation rbracketToken; -}; - -class QML_PARSER_EXPORT FieldMemberExpression: public ExpressionNode -{ -public: - QDECLARATIVEJS_DECLARE_AST_NODE(FieldMemberExpression) - - FieldMemberExpression(ExpressionNode *b, const QStringRef &n): - base (b), name (n) - { kind = K; } - - virtual void accept0(Visitor *visitor); - - virtual SourceLocation firstSourceLocation() const - { return base->firstSourceLocation(); } - - virtual SourceLocation lastSourceLocation() const - { return identifierToken; } - - // attributes - ExpressionNode *base; - QStringRef name; - SourceLocation dotToken; - SourceLocation identifierToken; -}; - -class QML_PARSER_EXPORT NewMemberExpression: public ExpressionNode -{ -public: - QDECLARATIVEJS_DECLARE_AST_NODE(NewMemberExpression) - - NewMemberExpression(ExpressionNode *b, ArgumentList *a): - base (b), arguments (a) - { kind = K; } - - virtual void accept0(Visitor *visitor); - - virtual SourceLocation firstSourceLocation() const - { return newToken; } - - virtual SourceLocation lastSourceLocation() const - { return rparenToken; } - - // attributes - ExpressionNode *base; - ArgumentList *arguments; - SourceLocation newToken; - SourceLocation lparenToken; - SourceLocation rparenToken; -}; - -class QML_PARSER_EXPORT NewExpression: public ExpressionNode -{ -public: - QDECLARATIVEJS_DECLARE_AST_NODE(NewExpression) - - NewExpression(ExpressionNode *e): - expression (e) { kind = K; } - - virtual void accept0(Visitor *visitor); - - virtual SourceLocation firstSourceLocation() const - { return newToken; } - - virtual SourceLocation lastSourceLocation() const - { return expression->lastSourceLocation(); } - -// attributes - ExpressionNode *expression; - SourceLocation newToken; -}; - -class QML_PARSER_EXPORT CallExpression: public ExpressionNode -{ -public: - QDECLARATIVEJS_DECLARE_AST_NODE(CallExpression) - - CallExpression(ExpressionNode *b, ArgumentList *a): - base (b), arguments (a) - { kind = K; } - - virtual void accept0(Visitor *visitor); - - virtual SourceLocation firstSourceLocation() const - { return base->firstSourceLocation(); } - - virtual SourceLocation lastSourceLocation() const - { return rparenToken; } - -// attributes - ExpressionNode *base; - ArgumentList *arguments; - SourceLocation lparenToken; - SourceLocation rparenToken; -}; - -class QML_PARSER_EXPORT ArgumentList: public Node -{ -public: - QDECLARATIVEJS_DECLARE_AST_NODE(ArgumentList) - - ArgumentList(ExpressionNode *e): - expression (e), next (this) - { kind = K; } - - ArgumentList(ArgumentList *previous, ExpressionNode *e): - expression (e) - { - kind = K; - next = previous->next; - previous->next = this; - } - - virtual void accept0(Visitor *visitor); - - virtual SourceLocation firstSourceLocation() const - { return expression->firstSourceLocation(); } - - virtual SourceLocation lastSourceLocation() const - { - if (next) - return next->lastSourceLocation(); - return expression->lastSourceLocation(); - } - - inline ArgumentList *finish () - { - ArgumentList *front = next; - next = 0; - return front; - } - -// attributes - ExpressionNode *expression; - ArgumentList *next; - SourceLocation commaToken; -}; - -class QML_PARSER_EXPORT PostIncrementExpression: public ExpressionNode -{ -public: - QDECLARATIVEJS_DECLARE_AST_NODE(PostIncrementExpression) - - PostIncrementExpression(ExpressionNode *b): - base (b) { kind = K; } - - virtual void accept0(Visitor *visitor); - - virtual SourceLocation firstSourceLocation() const - { return base->firstSourceLocation(); } - - virtual SourceLocation lastSourceLocation() const - { return incrementToken; } - -// attributes - ExpressionNode *base; - SourceLocation incrementToken; -}; - -class QML_PARSER_EXPORT PostDecrementExpression: public ExpressionNode -{ -public: - QDECLARATIVEJS_DECLARE_AST_NODE(PostDecrementExpression) - - PostDecrementExpression(ExpressionNode *b): - base (b) { kind = K; } - - virtual void accept0(Visitor *visitor); - - virtual SourceLocation firstSourceLocation() const - { return base->firstSourceLocation(); } - - virtual SourceLocation lastSourceLocation() const - { return decrementToken; } - -// attributes - ExpressionNode *base; - SourceLocation decrementToken; -}; - -class QML_PARSER_EXPORT DeleteExpression: public ExpressionNode -{ -public: - QDECLARATIVEJS_DECLARE_AST_NODE(DeleteExpression) - - DeleteExpression(ExpressionNode *e): - expression (e) { kind = K; } - - virtual void accept0(Visitor *visitor); - - virtual SourceLocation firstSourceLocation() const - { return deleteToken; } - - virtual SourceLocation lastSourceLocation() const - { return expression->lastSourceLocation(); } - -// attributes - ExpressionNode *expression; - SourceLocation deleteToken; -}; - -class QML_PARSER_EXPORT VoidExpression: public ExpressionNode -{ -public: - QDECLARATIVEJS_DECLARE_AST_NODE(VoidExpression) - - VoidExpression(ExpressionNode *e): - expression (e) { kind = K; } - - virtual void accept0(Visitor *visitor); - - virtual SourceLocation firstSourceLocation() const - { return voidToken; } - - virtual SourceLocation lastSourceLocation() const - { return expression->lastSourceLocation(); } - -// attributes - ExpressionNode *expression; - SourceLocation voidToken; -}; - -class QML_PARSER_EXPORT TypeOfExpression: public ExpressionNode -{ -public: - QDECLARATIVEJS_DECLARE_AST_NODE(TypeOfExpression) - - TypeOfExpression(ExpressionNode *e): - expression (e) { kind = K; } - - virtual void accept0(Visitor *visitor); - - virtual SourceLocation firstSourceLocation() const - { return typeofToken; } - - virtual SourceLocation lastSourceLocation() const - { return expression->lastSourceLocation(); } - -// attributes - ExpressionNode *expression; - SourceLocation typeofToken; -}; - -class QML_PARSER_EXPORT PreIncrementExpression: public ExpressionNode -{ -public: - QDECLARATIVEJS_DECLARE_AST_NODE(PreIncrementExpression) - - PreIncrementExpression(ExpressionNode *e): - expression (e) { kind = K; } - - virtual void accept0(Visitor *visitor); - - virtual SourceLocation firstSourceLocation() const - { return incrementToken; } - - virtual SourceLocation lastSourceLocation() const - { return expression->lastSourceLocation(); } - -// attributes - ExpressionNode *expression; - SourceLocation incrementToken; -}; - -class QML_PARSER_EXPORT PreDecrementExpression: public ExpressionNode -{ -public: - QDECLARATIVEJS_DECLARE_AST_NODE(PreDecrementExpression) - - PreDecrementExpression(ExpressionNode *e): - expression (e) { kind = K; } - - virtual void accept0(Visitor *visitor); - - virtual SourceLocation firstSourceLocation() const - { return decrementToken; } - - virtual SourceLocation lastSourceLocation() const - { return expression->lastSourceLocation(); } - -// attributes - ExpressionNode *expression; - SourceLocation decrementToken; -}; - -class QML_PARSER_EXPORT UnaryPlusExpression: public ExpressionNode -{ -public: - QDECLARATIVEJS_DECLARE_AST_NODE(UnaryPlusExpression) - - UnaryPlusExpression(ExpressionNode *e): - expression (e) { kind = K; } - - virtual void accept0(Visitor *visitor); - - virtual SourceLocation firstSourceLocation() const - { return plusToken; } - - virtual SourceLocation lastSourceLocation() const - { return expression->lastSourceLocation(); } - -// attributes - ExpressionNode *expression; - SourceLocation plusToken; -}; - -class QML_PARSER_EXPORT UnaryMinusExpression: public ExpressionNode -{ -public: - QDECLARATIVEJS_DECLARE_AST_NODE(UnaryMinusExpression) - - UnaryMinusExpression(ExpressionNode *e): - expression (e) { kind = K; } - - virtual void accept0(Visitor *visitor); - - virtual SourceLocation firstSourceLocation() const - { return minusToken; } - - virtual SourceLocation lastSourceLocation() const - { return expression->lastSourceLocation(); } - -// attributes - ExpressionNode *expression; - SourceLocation minusToken; -}; - -class QML_PARSER_EXPORT TildeExpression: public ExpressionNode -{ -public: - QDECLARATIVEJS_DECLARE_AST_NODE(TildeExpression) - - TildeExpression(ExpressionNode *e): - expression (e) { kind = K; } - - virtual void accept0(Visitor *visitor); - - virtual SourceLocation firstSourceLocation() const - { return tildeToken; } - - virtual SourceLocation lastSourceLocation() const - { return expression->lastSourceLocation(); } - -// attributes - ExpressionNode *expression; - SourceLocation tildeToken; -}; - -class QML_PARSER_EXPORT NotExpression: public ExpressionNode -{ -public: - QDECLARATIVEJS_DECLARE_AST_NODE(NotExpression) - - NotExpression(ExpressionNode *e): - expression (e) { kind = K; } - - virtual void accept0(Visitor *visitor); - - virtual SourceLocation firstSourceLocation() const - { return notToken; } - - virtual SourceLocation lastSourceLocation() const - { return expression->lastSourceLocation(); } - -// attributes - ExpressionNode *expression; - SourceLocation notToken; -}; - -class QML_PARSER_EXPORT BinaryExpression: public ExpressionNode -{ -public: - QDECLARATIVEJS_DECLARE_AST_NODE(BinaryExpression) - - BinaryExpression(ExpressionNode *l, int o, ExpressionNode *r): - left (l), op (o), right (r) - { kind = K; } - - virtual BinaryExpression *binaryExpressionCast(); - - virtual void accept0(Visitor *visitor); - - virtual SourceLocation firstSourceLocation() const - { return left->firstSourceLocation(); } - - virtual SourceLocation lastSourceLocation() const - { return right->lastSourceLocation(); } - -// attributes - ExpressionNode *left; - int op; - ExpressionNode *right; - SourceLocation operatorToken; -}; - -class QML_PARSER_EXPORT ConditionalExpression: public ExpressionNode -{ -public: - QDECLARATIVEJS_DECLARE_AST_NODE(ConditionalExpression) - - ConditionalExpression(ExpressionNode *e, ExpressionNode *t, ExpressionNode *f): - expression (e), ok (t), ko (f) - { kind = K; } - - virtual void accept0(Visitor *visitor); - - virtual SourceLocation firstSourceLocation() const - { return expression->firstSourceLocation(); } - - virtual SourceLocation lastSourceLocation() const - { return ko->lastSourceLocation(); } - -// attributes - ExpressionNode *expression; - ExpressionNode *ok; - ExpressionNode *ko; - SourceLocation questionToken; - SourceLocation colonToken; -}; - -class QML_PARSER_EXPORT Expression: public ExpressionNode // ### rename -{ -public: - QDECLARATIVEJS_DECLARE_AST_NODE(Expression) - - Expression(ExpressionNode *l, ExpressionNode *r): - left (l), right (r) { kind = K; } - - virtual void accept0(Visitor *visitor); - - virtual SourceLocation firstSourceLocation() const - { return left->firstSourceLocation(); } - - virtual SourceLocation lastSourceLocation() const - { return right->lastSourceLocation(); } - -// attributes - ExpressionNode *left; - ExpressionNode *right; - SourceLocation commaToken; -}; - -class QML_PARSER_EXPORT Block: public Statement -{ -public: - QDECLARATIVEJS_DECLARE_AST_NODE(Block) - - Block(StatementList *slist): - statements (slist) { kind = K; } - - virtual void accept0(Visitor *visitor); - - virtual SourceLocation firstSourceLocation() const - { return lbraceToken; } - - virtual SourceLocation lastSourceLocation() const - { return rbraceToken; } - - // attributes - StatementList *statements; - SourceLocation lbraceToken; - SourceLocation rbraceToken; -}; - -class QML_PARSER_EXPORT StatementList: public Node -{ -public: - QDECLARATIVEJS_DECLARE_AST_NODE(StatementList) - - StatementList(Statement *stmt): - statement (stmt), next (this) - { kind = K; } - - StatementList(StatementList *previous, Statement *stmt): - statement (stmt) - { - kind = K; - next = previous->next; - previous->next = this; - } - - virtual void accept0(Visitor *visitor); - - virtual SourceLocation firstSourceLocation() const - { return statement->firstSourceLocation(); } - - virtual SourceLocation lastSourceLocation() const - { return next ? next->lastSourceLocation() : statement->lastSourceLocation(); } - - inline StatementList *finish () - { - StatementList *front = next; - next = 0; - return front; - } - -// attributes - Statement *statement; - StatementList *next; -}; - -class QML_PARSER_EXPORT VariableStatement: public Statement -{ -public: - QDECLARATIVEJS_DECLARE_AST_NODE(VariableStatement) - - VariableStatement(VariableDeclarationList *vlist): - declarations (vlist) - { kind = K; } - - virtual void accept0(Visitor *visitor); - - virtual SourceLocation firstSourceLocation() const - { return declarationKindToken; } - - virtual SourceLocation lastSourceLocation() const - { return semicolonToken; } - -// attributes - VariableDeclarationList *declarations; - SourceLocation declarationKindToken; - SourceLocation semicolonToken; -}; - -class QML_PARSER_EXPORT VariableDeclaration: public Node -{ -public: - QDECLARATIVEJS_DECLARE_AST_NODE(VariableDeclaration) - - VariableDeclaration(const QStringRef &n, ExpressionNode *e): - name (n), expression (e), readOnly(false) - { kind = K; } - - virtual void accept0(Visitor *visitor); - - virtual SourceLocation firstSourceLocation() const - { return identifierToken; } - - virtual SourceLocation lastSourceLocation() const - { return expression ? expression->lastSourceLocation() : identifierToken; } - -// attributes - QStringRef name; - ExpressionNode *expression; - bool readOnly; - SourceLocation identifierToken; -}; - -class QML_PARSER_EXPORT VariableDeclarationList: public Node -{ -public: - QDECLARATIVEJS_DECLARE_AST_NODE(VariableDeclarationList) - - VariableDeclarationList(VariableDeclaration *decl): - declaration (decl), next (this) - { kind = K; } - - VariableDeclarationList(VariableDeclarationList *previous, VariableDeclaration *decl): - declaration (decl) - { - kind = K; - next = previous->next; - previous->next = this; - } - - virtual void accept0(Visitor *visitor); - - virtual SourceLocation firstSourceLocation() const - { return declaration->firstSourceLocation(); } - - virtual SourceLocation lastSourceLocation() const - { - if (next) - return next->lastSourceLocation(); - return declaration->lastSourceLocation(); - } - - inline VariableDeclarationList *finish (bool readOnly) - { - VariableDeclarationList *front = next; - next = 0; - if (readOnly) { - VariableDeclarationList *vdl; - for (vdl = front; vdl != 0; vdl = vdl->next) - vdl->declaration->readOnly = true; - } - return front; - } - -// attributes - VariableDeclaration *declaration; - VariableDeclarationList *next; - SourceLocation commaToken; -}; - -class QML_PARSER_EXPORT EmptyStatement: public Statement -{ -public: - QDECLARATIVEJS_DECLARE_AST_NODE(EmptyStatement) - - EmptyStatement() { kind = K; } - - virtual void accept0(Visitor *visitor); - - virtual SourceLocation firstSourceLocation() const - { return semicolonToken; } - - virtual SourceLocation lastSourceLocation() const - { return semicolonToken; } - -// attributes - SourceLocation semicolonToken; -}; - -class QML_PARSER_EXPORT ExpressionStatement: public Statement -{ -public: - QDECLARATIVEJS_DECLARE_AST_NODE(ExpressionStatement) - - ExpressionStatement(ExpressionNode *e): - expression (e) { kind = K; } - - virtual void accept0(Visitor *visitor); - - virtual SourceLocation firstSourceLocation() const - { return expression->firstSourceLocation(); } - - virtual SourceLocation lastSourceLocation() const - { return semicolonToken; } - -// attributes - ExpressionNode *expression; - SourceLocation semicolonToken; -}; - -class QML_PARSER_EXPORT IfStatement: public Statement -{ -public: - QDECLARATIVEJS_DECLARE_AST_NODE(IfStatement) - - IfStatement(ExpressionNode *e, Statement *t, Statement *f = 0): - expression (e), ok (t), ko (f) - { kind = K; } - - virtual void accept0(Visitor *visitor); - - virtual SourceLocation firstSourceLocation() const - { return ifToken; } - - virtual SourceLocation lastSourceLocation() const - { - if (ko) - return ko->lastSourceLocation(); - - return ok->lastSourceLocation(); - } - -// attributes - ExpressionNode *expression; - Statement *ok; - Statement *ko; - SourceLocation ifToken; - SourceLocation lparenToken; - SourceLocation rparenToken; - SourceLocation elseToken; -}; - -class QML_PARSER_EXPORT DoWhileStatement: public Statement -{ -public: - QDECLARATIVEJS_DECLARE_AST_NODE(DoWhileStatement) - - DoWhileStatement(Statement *stmt, ExpressionNode *e): - statement (stmt), expression (e) - { kind = K; } - - virtual void accept0(Visitor *visitor); - - virtual SourceLocation firstSourceLocation() const - { return doToken; } - - virtual SourceLocation lastSourceLocation() const - { return semicolonToken; } - -// attributes - Statement *statement; - ExpressionNode *expression; - SourceLocation doToken; - SourceLocation whileToken; - SourceLocation lparenToken; - SourceLocation rparenToken; - SourceLocation semicolonToken; -}; - -class QML_PARSER_EXPORT WhileStatement: public Statement -{ -public: - QDECLARATIVEJS_DECLARE_AST_NODE(WhileStatement) - - WhileStatement(ExpressionNode *e, Statement *stmt): - expression (e), statement (stmt) - { kind = K; } - - virtual void accept0(Visitor *visitor); - - virtual SourceLocation firstSourceLocation() const - { return whileToken; } - - virtual SourceLocation lastSourceLocation() const - { return statement->lastSourceLocation(); } - -// attributes - ExpressionNode *expression; - Statement *statement; - SourceLocation whileToken; - SourceLocation lparenToken; - SourceLocation rparenToken; -}; - -class QML_PARSER_EXPORT ForStatement: public Statement -{ -public: - QDECLARATIVEJS_DECLARE_AST_NODE(ForStatement) - - ForStatement(ExpressionNode *i, ExpressionNode *c, ExpressionNode *e, Statement *stmt): - initialiser (i), condition (c), expression (e), statement (stmt) - { kind = K; } - - virtual void accept0(Visitor *visitor); - - virtual SourceLocation firstSourceLocation() const - { return forToken; } - - virtual SourceLocation lastSourceLocation() const - { return statement->lastSourceLocation(); } - -// attributes - ExpressionNode *initialiser; - ExpressionNode *condition; - ExpressionNode *expression; - Statement *statement; - SourceLocation forToken; - SourceLocation lparenToken; - SourceLocation firstSemicolonToken; - SourceLocation secondSemicolonToken; - SourceLocation rparenToken; -}; - -class QML_PARSER_EXPORT LocalForStatement: public Statement -{ -public: - QDECLARATIVEJS_DECLARE_AST_NODE(LocalForStatement) - - LocalForStatement(VariableDeclarationList *vlist, ExpressionNode *c, ExpressionNode *e, Statement *stmt): - declarations (vlist), condition (c), expression (e), statement (stmt) - { kind = K; } - - virtual void accept0(Visitor *visitor); - - virtual SourceLocation firstSourceLocation() const - { return forToken; } - - virtual SourceLocation lastSourceLocation() const - { return statement->lastSourceLocation(); } - -// attributes - VariableDeclarationList *declarations; - ExpressionNode *condition; - ExpressionNode *expression; - Statement *statement; - SourceLocation forToken; - SourceLocation lparenToken; - SourceLocation varToken; - SourceLocation firstSemicolonToken; - SourceLocation secondSemicolonToken; - SourceLocation rparenToken; -}; - -class QML_PARSER_EXPORT ForEachStatement: public Statement -{ -public: - QDECLARATIVEJS_DECLARE_AST_NODE(ForEachStatement) - - ForEachStatement(ExpressionNode *i, ExpressionNode *e, Statement *stmt): - initialiser (i), expression (e), statement (stmt) - { kind = K; } - - virtual void accept0(Visitor *visitor); - - virtual SourceLocation firstSourceLocation() const - { return forToken; } - - virtual SourceLocation lastSourceLocation() const - { return statement->lastSourceLocation(); } - -// attributes - ExpressionNode *initialiser; - ExpressionNode *expression; - Statement *statement; - SourceLocation forToken; - SourceLocation lparenToken; - SourceLocation inToken; - SourceLocation rparenToken; -}; - -class QML_PARSER_EXPORT LocalForEachStatement: public Statement -{ -public: - QDECLARATIVEJS_DECLARE_AST_NODE(LocalForEachStatement) - - LocalForEachStatement(VariableDeclaration *v, ExpressionNode *e, Statement *stmt): - declaration (v), expression (e), statement (stmt) - { kind = K; } - - virtual void accept0(Visitor *visitor); - - virtual SourceLocation firstSourceLocation() const - { return forToken; } - - virtual SourceLocation lastSourceLocation() const - { return statement->lastSourceLocation(); } - -// attributes - VariableDeclaration *declaration; - ExpressionNode *expression; - Statement *statement; - SourceLocation forToken; - SourceLocation lparenToken; - SourceLocation varToken; - SourceLocation inToken; - SourceLocation rparenToken; -}; - -class QML_PARSER_EXPORT ContinueStatement: public Statement -{ -public: - QDECLARATIVEJS_DECLARE_AST_NODE(ContinueStatement) - - ContinueStatement(const QStringRef &l = QStringRef()): - label (l) { kind = K; } - - virtual void accept0(Visitor *visitor); - - virtual SourceLocation firstSourceLocation() const - { return continueToken; } - - virtual SourceLocation lastSourceLocation() const - { return semicolonToken; } - -// attributes - QStringRef label; - SourceLocation continueToken; - SourceLocation identifierToken; - SourceLocation semicolonToken; -}; - -class QML_PARSER_EXPORT BreakStatement: public Statement -{ -public: - QDECLARATIVEJS_DECLARE_AST_NODE(BreakStatement) - - BreakStatement(const QStringRef &l): - label (l) { kind = K; } - - virtual void accept0(Visitor *visitor); - - virtual SourceLocation firstSourceLocation() const - { return breakToken; } - - virtual SourceLocation lastSourceLocation() const - { return semicolonToken; } - - // attributes - QStringRef label; - SourceLocation breakToken; - SourceLocation identifierToken; - SourceLocation semicolonToken; -}; - -class QML_PARSER_EXPORT ReturnStatement: public Statement -{ -public: - QDECLARATIVEJS_DECLARE_AST_NODE(ReturnStatement) - - ReturnStatement(ExpressionNode *e): - expression (e) { kind = K; } - - virtual void accept0(Visitor *visitor); - - virtual SourceLocation firstSourceLocation() const - { return returnToken; } - - virtual SourceLocation lastSourceLocation() const - { return semicolonToken; } - -// attributes - ExpressionNode *expression; - SourceLocation returnToken; - SourceLocation semicolonToken; -}; - -class QML_PARSER_EXPORT WithStatement: public Statement -{ -public: - QDECLARATIVEJS_DECLARE_AST_NODE(WithStatement) - - WithStatement(ExpressionNode *e, Statement *stmt): - expression (e), statement (stmt) - { kind = K; } - - virtual void accept0(Visitor *visitor); - - virtual SourceLocation firstSourceLocation() const - { return withToken; } - - virtual SourceLocation lastSourceLocation() const - { return statement->lastSourceLocation(); } - -// attributes - ExpressionNode *expression; - Statement *statement; - SourceLocation withToken; - SourceLocation lparenToken; - SourceLocation rparenToken; -}; - -class QML_PARSER_EXPORT CaseBlock: public Node -{ -public: - QDECLARATIVEJS_DECLARE_AST_NODE(CaseBlock) - - CaseBlock(CaseClauses *c, DefaultClause *d = 0, CaseClauses *r = 0): - clauses (c), defaultClause (d), moreClauses (r) - { kind = K; } - - virtual void accept0(Visitor *visitor); - - virtual SourceLocation firstSourceLocation() const - { return lbraceToken; } - - virtual SourceLocation lastSourceLocation() const - { return rbraceToken; } - -// attributes - CaseClauses *clauses; - DefaultClause *defaultClause; - CaseClauses *moreClauses; - SourceLocation lbraceToken; - SourceLocation rbraceToken; -}; - -class QML_PARSER_EXPORT SwitchStatement: public Statement -{ -public: - QDECLARATIVEJS_DECLARE_AST_NODE(SwitchStatement) - - SwitchStatement(ExpressionNode *e, CaseBlock *b): - expression (e), block (b) - { kind = K; } - - virtual void accept0(Visitor *visitor); - - virtual SourceLocation firstSourceLocation() const - { return switchToken; } - - virtual SourceLocation lastSourceLocation() const - { return block->rbraceToken; } - -// attributes - ExpressionNode *expression; - CaseBlock *block; - SourceLocation switchToken; - SourceLocation lparenToken; - SourceLocation rparenToken; -}; - -class QML_PARSER_EXPORT CaseClause: public Node -{ -public: - QDECLARATIVEJS_DECLARE_AST_NODE(CaseClause) - - CaseClause(ExpressionNode *e, StatementList *slist): - expression (e), statements (slist) - { kind = K; } - - virtual void accept0(Visitor *visitor); - - virtual SourceLocation firstSourceLocation() const - { return caseToken; } - - virtual SourceLocation lastSourceLocation() const - { return statements ? statements->lastSourceLocation() : colonToken; } - -// attributes - ExpressionNode *expression; - StatementList *statements; - SourceLocation caseToken; - SourceLocation colonToken; -}; - -class QML_PARSER_EXPORT CaseClauses: public Node -{ -public: - QDECLARATIVEJS_DECLARE_AST_NODE(CaseClauses) - - CaseClauses(CaseClause *c): - clause (c), next (this) - { kind = K; } - - CaseClauses(CaseClauses *previous, CaseClause *c): - clause (c) - { - kind = K; - next = previous->next; - previous->next = this; - } - - virtual void accept0(Visitor *visitor); - - virtual SourceLocation firstSourceLocation() const - { return clause->firstSourceLocation(); } - - virtual SourceLocation lastSourceLocation() const - { return next ? next->lastSourceLocation() : clause->lastSourceLocation(); } - - inline CaseClauses *finish () - { - CaseClauses *front = next; - next = 0; - return front; - } - -//attributes - CaseClause *clause; - CaseClauses *next; -}; - -class QML_PARSER_EXPORT DefaultClause: public Node -{ -public: - QDECLARATIVEJS_DECLARE_AST_NODE(DefaultClause) - - DefaultClause(StatementList *slist): - statements (slist) - { kind = K; } - - virtual void accept0(Visitor *visitor); - - virtual SourceLocation firstSourceLocation() const - { return defaultToken; } - - virtual SourceLocation lastSourceLocation() const - { return statements ? statements->lastSourceLocation() : colonToken; } - -// attributes - StatementList *statements; - SourceLocation defaultToken; - SourceLocation colonToken; -}; - -class QML_PARSER_EXPORT LabelledStatement: public Statement -{ -public: - QDECLARATIVEJS_DECLARE_AST_NODE(LabelledStatement) - - LabelledStatement(const QStringRef &l, Statement *stmt): - label (l), statement (stmt) - { kind = K; } - - virtual void accept0(Visitor *visitor); - - virtual SourceLocation firstSourceLocation() const - { return identifierToken; } - - virtual SourceLocation lastSourceLocation() const - { return statement->lastSourceLocation(); } - -// attributes - QStringRef label; - Statement *statement; - SourceLocation identifierToken; - SourceLocation colonToken; -}; - -class QML_PARSER_EXPORT ThrowStatement: public Statement -{ -public: - QDECLARATIVEJS_DECLARE_AST_NODE(ThrowStatement) - - ThrowStatement(ExpressionNode *e): - expression (e) { kind = K; } - - virtual void accept0(Visitor *visitor); - - virtual SourceLocation firstSourceLocation() const - { return throwToken; } - - virtual SourceLocation lastSourceLocation() const - { return semicolonToken; } - - // attributes - ExpressionNode *expression; - SourceLocation throwToken; - SourceLocation semicolonToken; -}; - -class QML_PARSER_EXPORT Catch: public Node -{ -public: - QDECLARATIVEJS_DECLARE_AST_NODE(Catch) - - Catch(const QStringRef &n, Block *stmt): - name (n), statement (stmt) - { kind = K; } - - virtual void accept0(Visitor *visitor); - - virtual SourceLocation firstSourceLocation() const - { return catchToken; } - - virtual SourceLocation lastSourceLocation() const - { return statement->lastSourceLocation(); } - -// attributes - QStringRef name; - Block *statement; - SourceLocation catchToken; - SourceLocation lparenToken; - SourceLocation identifierToken; - SourceLocation rparenToken; -}; - -class QML_PARSER_EXPORT Finally: public Node -{ -public: - QDECLARATIVEJS_DECLARE_AST_NODE(Finally) - - Finally(Block *stmt): - statement (stmt) - { kind = K; } - - virtual void accept0(Visitor *visitor); - - virtual SourceLocation firstSourceLocation() const - { return finallyToken; } - - virtual SourceLocation lastSourceLocation() const - { return statement ? statement->lastSourceLocation() : finallyToken; } - -// attributes - Block *statement; - SourceLocation finallyToken; -}; - -class QML_PARSER_EXPORT TryStatement: public Statement -{ -public: - QDECLARATIVEJS_DECLARE_AST_NODE(TryStatement) - - TryStatement(Statement *stmt, Catch *c, Finally *f): - statement (stmt), catchExpression (c), finallyExpression (f) - { kind = K; } - - TryStatement(Statement *stmt, Finally *f): - statement (stmt), catchExpression (0), finallyExpression (f) - { kind = K; } - - TryStatement(Statement *stmt, Catch *c): - statement (stmt), catchExpression (c), finallyExpression (0) - { kind = K; } - - virtual void accept0(Visitor *visitor); - - virtual SourceLocation firstSourceLocation() const - { return tryToken; } - - virtual SourceLocation lastSourceLocation() const - { - if (finallyExpression) - return finallyExpression->statement->rbraceToken; - else if (catchExpression) - return catchExpression->statement->rbraceToken; - - return statement->lastSourceLocation(); - } - -// attributes - Statement *statement; - Catch *catchExpression; - Finally *finallyExpression; - SourceLocation tryToken; -}; - -class QML_PARSER_EXPORT FunctionExpression: public ExpressionNode -{ -public: - QDECLARATIVEJS_DECLARE_AST_NODE(FunctionExpression) - - FunctionExpression(const QStringRef &n, FormalParameterList *f, FunctionBody *b): - name (n), formals (f), body (b) - { kind = K; } - - virtual void accept0(Visitor *visitor); - - virtual SourceLocation firstSourceLocation() const - { return functionToken; } - - virtual SourceLocation lastSourceLocation() const - { return rbraceToken; } - -// attributes - QStringRef name; - FormalParameterList *formals; - FunctionBody *body; - SourceLocation functionToken; - SourceLocation identifierToken; - SourceLocation lparenToken; - SourceLocation rparenToken; - SourceLocation lbraceToken; - SourceLocation rbraceToken; -}; - -class QML_PARSER_EXPORT FunctionDeclaration: public FunctionExpression -{ -public: - QDECLARATIVEJS_DECLARE_AST_NODE(FunctionDeclaration) - - FunctionDeclaration(const QStringRef &n, FormalParameterList *f, FunctionBody *b): - FunctionExpression(n, f, b) - { kind = K; } - - virtual void accept0(Visitor *visitor); -}; - -class QML_PARSER_EXPORT FormalParameterList: public Node -{ -public: - QDECLARATIVEJS_DECLARE_AST_NODE(FormalParameterList) - - FormalParameterList(const QStringRef &n): - name (n), next (this) - { kind = K; } - - FormalParameterList(FormalParameterList *previous, const QStringRef &n): - name (n) - { - kind = K; - next = previous->next; - previous->next = this; - } - - virtual void accept0(Visitor *visitor); - - virtual SourceLocation firstSourceLocation() const - { return identifierToken; } - - virtual SourceLocation lastSourceLocation() const - { return next ? next->lastSourceLocation() : identifierToken; } - - inline FormalParameterList *finish () - { - FormalParameterList *front = next; - next = 0; - return front; - } - -// attributes - QStringRef name; - FormalParameterList *next; - SourceLocation commaToken; - SourceLocation identifierToken; -}; - -class QML_PARSER_EXPORT SourceElement: public Node -{ -public: - QDECLARATIVEJS_DECLARE_AST_NODE(SourceElement) - - inline SourceElement() - { kind = K; } -}; - -class QML_PARSER_EXPORT SourceElements: public Node -{ -public: - QDECLARATIVEJS_DECLARE_AST_NODE(SourceElements) - - SourceElements(SourceElement *elt): - element (elt), next (this) - { kind = K; } - - SourceElements(SourceElements *previous, SourceElement *elt): - element (elt) - { - kind = K; - next = previous->next; - previous->next = this; - } - - virtual void accept0(Visitor *visitor); - - virtual SourceLocation firstSourceLocation() const - { return element->firstSourceLocation(); } - - virtual SourceLocation lastSourceLocation() const - { return next ? next->lastSourceLocation() : element->lastSourceLocation(); } - - inline SourceElements *finish () - { - SourceElements *front = next; - next = 0; - return front; - } - -// attributes - SourceElement *element; - SourceElements *next; -}; - -class QML_PARSER_EXPORT FunctionBody: public Node -{ -public: - QDECLARATIVEJS_DECLARE_AST_NODE(FunctionBody) - - FunctionBody(SourceElements *elts): - elements (elts) - { kind = K; } - - virtual void accept0(Visitor *visitor); - - virtual SourceLocation firstSourceLocation() const - { return elements ? elements->firstSourceLocation() : SourceLocation(); } - - virtual SourceLocation lastSourceLocation() const - { return elements ? elements->lastSourceLocation() : SourceLocation(); } - -// attributes - SourceElements *elements; -}; - -class QML_PARSER_EXPORT Program: public Node -{ -public: - QDECLARATIVEJS_DECLARE_AST_NODE(Program) - - Program(SourceElements *elts): - elements (elts) - { kind = K; } - - virtual void accept0(Visitor *visitor); - - virtual SourceLocation firstSourceLocation() const - { return elements ? elements->firstSourceLocation() : SourceLocation(); } - - virtual SourceLocation lastSourceLocation() const - { return elements ? elements->lastSourceLocation() : SourceLocation(); } - -// attributes - SourceElements *elements; -}; - -class QML_PARSER_EXPORT FunctionSourceElement: public SourceElement -{ -public: - QDECLARATIVEJS_DECLARE_AST_NODE(FunctionSourceElement) - - FunctionSourceElement(FunctionDeclaration *f): - declaration (f) - { kind = K; } - - virtual void accept0(Visitor *visitor); - - virtual SourceLocation firstSourceLocation() const - { return declaration->firstSourceLocation(); } - - virtual SourceLocation lastSourceLocation() const - { return declaration->lastSourceLocation(); } - -// attributes - FunctionDeclaration *declaration; -}; - -class QML_PARSER_EXPORT StatementSourceElement: public SourceElement -{ -public: - QDECLARATIVEJS_DECLARE_AST_NODE(StatementSourceElement) - - StatementSourceElement(Statement *stmt): - statement (stmt) - { kind = K; } - - virtual void accept0(Visitor *visitor); - - virtual SourceLocation firstSourceLocation() const - { return statement->firstSourceLocation(); } - - virtual SourceLocation lastSourceLocation() const - { return statement->lastSourceLocation(); } - -// attributes - Statement *statement; -}; - -class QML_PARSER_EXPORT DebuggerStatement: public Statement -{ -public: - QDECLARATIVEJS_DECLARE_AST_NODE(DebuggerStatement) - - DebuggerStatement() - { kind = K; } - - virtual void accept0(Visitor *visitor); - - virtual SourceLocation firstSourceLocation() const - { return debuggerToken; } - - virtual SourceLocation lastSourceLocation() const - { return semicolonToken; } - -// attributes - SourceLocation debuggerToken; - SourceLocation semicolonToken; -}; - -class QML_PARSER_EXPORT UiQualifiedId: public Node -{ -public: - QDECLARATIVEJS_DECLARE_AST_NODE(UiQualifiedId) - - UiQualifiedId(const QStringRef &name) - : next(this), name(name) - { kind = K; } - - UiQualifiedId(UiQualifiedId *previous, const QStringRef &name) - : name(name) - { - kind = K; - next = previous->next; - previous->next = this; - } - - UiQualifiedId *finish() - { - UiQualifiedId *head = next; - next = 0; - return head; - } - - virtual void accept0(Visitor *visitor); - - virtual SourceLocation firstSourceLocation() const - { return identifierToken; } - - virtual SourceLocation lastSourceLocation() const - { return next ? next->lastSourceLocation() : identifierToken; } - -// attributes - UiQualifiedId *next; - QStringRef name; - SourceLocation identifierToken; -}; - -class QML_PARSER_EXPORT UiImport: public Node -{ -public: - QDECLARATIVEJS_DECLARE_AST_NODE(UiImport) - - UiImport(const QStringRef &fileName) - : fileName(fileName), importUri(0) - { kind = K; } - - UiImport(UiQualifiedId *uri) - : importUri(uri) - { kind = K; } - - virtual void accept0(Visitor *visitor); - - virtual SourceLocation firstSourceLocation() const - { return importToken; } - - virtual SourceLocation lastSourceLocation() const - { return semicolonToken; } - -// attributes - QStringRef fileName; - UiQualifiedId *importUri; - QStringRef importId; - SourceLocation importToken; - SourceLocation fileNameToken; - SourceLocation versionToken; - SourceLocation asToken; - SourceLocation importIdToken; - SourceLocation semicolonToken; -}; - -class QML_PARSER_EXPORT UiImportList: public Node -{ -public: - QDECLARATIVEJS_DECLARE_AST_NODE(UiImportList) - - UiImportList(UiImport *import) - : import(import), - next(this) - { kind = K; } - - UiImportList(UiImportList *previous, UiImport *import) - : import(import) - { - kind = K; - next = previous->next; - previous->next = this; - } - - UiImportList *finish() - { - UiImportList *head = next; - next = 0; - return head; - } - - virtual void accept0(Visitor *visitor); - - virtual SourceLocation firstSourceLocation() const - { return import->firstSourceLocation(); } - - virtual SourceLocation lastSourceLocation() const - { return next ? next->lastSourceLocation() : import->lastSourceLocation(); } - -// attributes - UiImport *import; - UiImportList *next; -}; - -class QML_PARSER_EXPORT UiObjectMember: public Node -{ -public: - virtual SourceLocation firstSourceLocation() const = 0; - virtual SourceLocation lastSourceLocation() const = 0; - - virtual UiObjectMember *uiObjectMemberCast(); -}; - -class QML_PARSER_EXPORT UiObjectMemberList: public Node -{ -public: - QDECLARATIVEJS_DECLARE_AST_NODE(UiObjectMemberList) - - UiObjectMemberList(UiObjectMember *member) - : next(this), member(member) - { kind = K; } - - UiObjectMemberList(UiObjectMemberList *previous, UiObjectMember *member) - : member(member) - { - kind = K; - next = previous->next; - previous->next = this; - } - - virtual void accept0(Visitor *visitor); - - virtual SourceLocation firstSourceLocation() const - { return member->firstSourceLocation(); } - - virtual SourceLocation lastSourceLocation() const - { return next ? next->lastSourceLocation() : member->lastSourceLocation(); } - - UiObjectMemberList *finish() - { - UiObjectMemberList *head = next; - next = 0; - return head; - } - -// attributes - UiObjectMemberList *next; - UiObjectMember *member; -}; - -class QML_PARSER_EXPORT UiProgram: public Node -{ -public: - QDECLARATIVEJS_DECLARE_AST_NODE(UiProgram) - - UiProgram(UiImportList *imports, UiObjectMemberList *members) - : imports(imports), members(members) - { kind = K; } - - virtual void accept0(Visitor *visitor); - - virtual SourceLocation firstSourceLocation() const - { - if (imports) - return imports->firstSourceLocation(); - else if (members) - return members->firstSourceLocation(); - return SourceLocation(); - } - - virtual SourceLocation lastSourceLocation() const - { - if (members) - return members->lastSourceLocation(); - else if (imports) - return imports->lastSourceLocation(); - return SourceLocation(); - } - -// attributes - UiImportList *imports; - UiObjectMemberList *members; -}; - -class QML_PARSER_EXPORT UiArrayMemberList: public Node -{ -public: - QDECLARATIVEJS_DECLARE_AST_NODE(UiArrayMemberList) - - UiArrayMemberList(UiObjectMember *member) - : next(this), member(member) - { kind = K; } - - UiArrayMemberList(UiArrayMemberList *previous, UiObjectMember *member) - : member(member) - { - kind = K; - next = previous->next; - previous->next = this; - } - - virtual void accept0(Visitor *visitor); - - virtual SourceLocation firstSourceLocation() const - { return member->firstSourceLocation(); } - - virtual SourceLocation lastSourceLocation() const - { return next ? next->lastSourceLocation() : member->lastSourceLocation(); } - - UiArrayMemberList *finish() - { - UiArrayMemberList *head = next; - next = 0; - return head; - } - -// attributes - UiArrayMemberList *next; - UiObjectMember *member; - SourceLocation commaToken; -}; - -class QML_PARSER_EXPORT UiObjectInitializer: public Node -{ -public: - QDECLARATIVEJS_DECLARE_AST_NODE(UiObjectInitializer) - - UiObjectInitializer(UiObjectMemberList *members) - : members(members) - { kind = K; } - - virtual void accept0(Visitor *visitor); - - virtual SourceLocation firstSourceLocation() const - { return lbraceToken; } - - virtual SourceLocation lastSourceLocation() const - { return rbraceToken; } - -// attributes - SourceLocation lbraceToken; - UiObjectMemberList *members; - SourceLocation rbraceToken; -}; - -class QML_PARSER_EXPORT UiParameterList: public Node -{ -public: - QDECLARATIVEJS_DECLARE_AST_NODE(UiParameterList) - - UiParameterList(const QStringRef &t, const QStringRef &n): - type (t), name (n), next (this) - { kind = K; } - - UiParameterList(UiParameterList *previous, const QStringRef &t, const QStringRef &n): - type (t), name (n) - { - kind = K; - next = previous->next; - previous->next = this; - } - - virtual void accept0(Visitor *) {} - - virtual SourceLocation firstSourceLocation() const - { return propertyTypeToken; } - - virtual SourceLocation lastSourceLocation() const - { return next ? next->lastSourceLocation() : identifierToken; } - - inline UiParameterList *finish () - { - UiParameterList *front = next; - next = 0; - return front; - } - -// attributes - QStringRef type; - QStringRef name; - UiParameterList *next; - SourceLocation commaToken; - SourceLocation propertyTypeToken; - SourceLocation identifierToken; -}; - -class QML_PARSER_EXPORT UiPublicMember: public UiObjectMember -{ -public: - QDECLARATIVEJS_DECLARE_AST_NODE(UiPublicMember) - - UiPublicMember(const QStringRef &memberType, - const QStringRef &name) - : type(Property), memberType(memberType), name(name), statement(0), binding(0), isDefaultMember(false), isReadonlyMember(false), parameters(0) - { kind = K; } - - UiPublicMember(const QStringRef &memberType, - const QStringRef &name, - Statement *statement) - : type(Property), memberType(memberType), name(name), statement(statement), binding(0), isDefaultMember(false), isReadonlyMember(false), parameters(0) - { kind = K; } - - virtual void accept0(Visitor *visitor); - - virtual SourceLocation firstSourceLocation() const - { - if (defaultToken.isValid()) - return defaultToken; - else if (readonlyToken.isValid()) - return readonlyToken; - - return propertyToken; - } - - virtual SourceLocation lastSourceLocation() const - { - if (binding) - return binding->lastSourceLocation(); - if (statement) - return statement->lastSourceLocation(); - - return semicolonToken; - } - -// attributes - enum { Signal, Property } type; - QStringRef typeModifier; - QStringRef memberType; - QStringRef name; - Statement *statement; // initialized with a JS expression - UiObjectMember *binding; // initialized with a QML object or array. - bool isDefaultMember; - bool isReadonlyMember; - UiParameterList *parameters; - SourceLocation defaultToken; - SourceLocation readonlyToken; - SourceLocation propertyToken; - SourceLocation typeModifierToken; - SourceLocation typeToken; - SourceLocation identifierToken; - SourceLocation colonToken; - SourceLocation semicolonToken; -}; - -class QML_PARSER_EXPORT UiObjectDefinition: public UiObjectMember -{ -public: - QDECLARATIVEJS_DECLARE_AST_NODE(UiObjectDefinition) - - UiObjectDefinition(UiQualifiedId *qualifiedTypeNameId, - UiObjectInitializer *initializer) - : qualifiedTypeNameId(qualifiedTypeNameId), initializer(initializer) - { kind = K; } - - virtual void accept0(Visitor *visitor); - - virtual SourceLocation firstSourceLocation() const - { return qualifiedTypeNameId->identifierToken; } - - virtual SourceLocation lastSourceLocation() const - { return initializer->rbraceToken; } - -// attributes - UiQualifiedId *qualifiedTypeNameId; - UiObjectInitializer *initializer; -}; - -class QML_PARSER_EXPORT UiSourceElement: public UiObjectMember -{ -public: - QDECLARATIVEJS_DECLARE_AST_NODE(UiSourceElement) - - UiSourceElement(Node *sourceElement) - : sourceElement(sourceElement) - { kind = K; } - - virtual SourceLocation firstSourceLocation() const - { - if (FunctionDeclaration *funDecl = cast(sourceElement)) - return funDecl->firstSourceLocation(); - else if (VariableStatement *varStmt = cast(sourceElement)) - return varStmt->firstSourceLocation(); - - return SourceLocation(); - } - - virtual SourceLocation lastSourceLocation() const - { - if (FunctionDeclaration *funDecl = cast(sourceElement)) - return funDecl->lastSourceLocation(); - else if (VariableStatement *varStmt = cast(sourceElement)) - return varStmt->lastSourceLocation(); - - return SourceLocation(); - } - - virtual void accept0(Visitor *visitor); - - -// attributes - Node *sourceElement; -}; - -class QML_PARSER_EXPORT UiObjectBinding: public UiObjectMember -{ -public: - QDECLARATIVEJS_DECLARE_AST_NODE(UiObjectBinding) - - UiObjectBinding(UiQualifiedId *qualifiedId, - UiQualifiedId *qualifiedTypeNameId, - UiObjectInitializer *initializer) - : qualifiedId(qualifiedId), - qualifiedTypeNameId(qualifiedTypeNameId), - initializer(initializer), - hasOnToken(false) - { kind = K; } - - virtual SourceLocation firstSourceLocation() const - { - if (hasOnToken && qualifiedTypeNameId) - return qualifiedTypeNameId->identifierToken; - - return qualifiedId->identifierToken; - } - - virtual SourceLocation lastSourceLocation() const - { return initializer->rbraceToken; } - - virtual void accept0(Visitor *visitor); - - -// attributes - UiQualifiedId *qualifiedId; - UiQualifiedId *qualifiedTypeNameId; - UiObjectInitializer *initializer; - SourceLocation colonToken; - bool hasOnToken; -}; - -class QML_PARSER_EXPORT UiScriptBinding: public UiObjectMember -{ -public: - QDECLARATIVEJS_DECLARE_AST_NODE(UiScriptBinding) - - UiScriptBinding(UiQualifiedId *qualifiedId, - Statement *statement) - : qualifiedId(qualifiedId), - statement(statement) - { kind = K; } - - virtual SourceLocation firstSourceLocation() const - { return qualifiedId->identifierToken; } - - virtual SourceLocation lastSourceLocation() const - { return statement->lastSourceLocation(); } - - virtual void accept0(Visitor *visitor); - -// attributes - UiQualifiedId *qualifiedId; - Statement *statement; - SourceLocation colonToken; -}; - -class QML_PARSER_EXPORT UiArrayBinding: public UiObjectMember -{ -public: - QDECLARATIVEJS_DECLARE_AST_NODE(UiArrayBinding) - - UiArrayBinding(UiQualifiedId *qualifiedId, - UiArrayMemberList *members) - : qualifiedId(qualifiedId), - members(members) - { kind = K; } - - virtual SourceLocation firstSourceLocation() const - { return qualifiedId->identifierToken; } - - virtual SourceLocation lastSourceLocation() const - { return rbracketToken; } - - virtual void accept0(Visitor *visitor); - -// attributes - UiQualifiedId *qualifiedId; - UiArrayMemberList *members; - SourceLocation colonToken; - SourceLocation lbracketToken; - SourceLocation rbracketToken; -}; - -} } // namespace AST - - - -QT_QML_END_NAMESPACE - -#endif diff --git a/src/declarative/qml/parser/qdeclarativejsastfwd_p.h b/src/declarative/qml/parser/qdeclarativejsastfwd_p.h deleted file mode 100644 index 9c7d0a51e6..0000000000 --- a/src/declarative/qml/parser/qdeclarativejsastfwd_p.h +++ /dev/null @@ -1,186 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QDECLARATIVEJSAST_FWD_P_H -#define QDECLARATIVEJSAST_FWD_P_H - -#include "qdeclarativejsglobal_p.h" - -#include - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists purely as an -// implementation detail. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - -QT_QML_BEGIN_NAMESPACE - -namespace QDeclarativeJS { namespace AST { - -class SourceLocation -{ -public: - SourceLocation(quint32 offset = 0, quint32 length = 0, quint32 line = 0, quint32 column = 0) - : offset(offset), length(length), - startLine(line), startColumn(column) - { } - - bool isValid() const { return length != 0; } - - quint32 begin() const { return offset; } - quint32 end() const { return offset + length; } - -// attributes - // ### encode - quint32 offset; - quint32 length; - quint32 startLine; - quint32 startColumn; -}; - -class Visitor; -class Node; -class ExpressionNode; -class Statement; -class ThisExpression; -class IdentifierExpression; -class NullExpression; -class TrueLiteral; -class FalseLiteral; -class NumericLiteral; -class StringLiteral; -class RegExpLiteral; -class ArrayLiteral; -class ObjectLiteral; -class ElementList; -class Elision; -class PropertyNameAndValueList; -class PropertyName; -class IdentifierPropertyName; -class StringLiteralPropertyName; -class NumericLiteralPropertyName; -class ArrayMemberExpression; -class FieldMemberExpression; -class NewMemberExpression; -class NewExpression; -class CallExpression; -class ArgumentList; -class PostIncrementExpression; -class PostDecrementExpression; -class DeleteExpression; -class VoidExpression; -class TypeOfExpression; -class PreIncrementExpression; -class PreDecrementExpression; -class UnaryPlusExpression; -class UnaryMinusExpression; -class TildeExpression; -class NotExpression; -class BinaryExpression; -class ConditionalExpression; -class Expression; // ### rename -class Block; -class StatementList; -class VariableStatement; -class VariableDeclarationList; -class VariableDeclaration; -class EmptyStatement; -class ExpressionStatement; -class IfStatement; -class DoWhileStatement; -class WhileStatement; -class ForStatement; -class LocalForStatement; -class ForEachStatement; -class LocalForEachStatement; -class ContinueStatement; -class BreakStatement; -class ReturnStatement; -class WithStatement; -class SwitchStatement; -class CaseBlock; -class CaseClauses; -class CaseClause; -class DefaultClause; -class LabelledStatement; -class ThrowStatement; -class TryStatement; -class Catch; -class Finally; -class FunctionDeclaration; -class FunctionExpression; -class FormalParameterList; -class FunctionBody; -class Program; -class SourceElements; -class SourceElement; -class FunctionSourceElement; -class StatementSourceElement; -class DebuggerStatement; -class NestedExpression; - -// ui elements -class UiProgram; -class UiImportList; -class UiImport; -class UiPublicMember; -class UiObjectDefinition; -class UiObjectInitializer; -class UiObjectBinding; -class UiScriptBinding; -class UiSourceElement; -class UiArrayBinding; -class UiObjectMember; -class UiObjectMemberList; -class UiArrayMemberList; -class UiQualifiedId; - -} } // namespace AST - -QT_QML_END_NAMESPACE - -#endif diff --git a/src/declarative/qml/parser/qdeclarativejsastvisitor.cpp b/src/declarative/qml/parser/qdeclarativejsastvisitor.cpp deleted file mode 100644 index 671abd76db..0000000000 --- a/src/declarative/qml/parser/qdeclarativejsastvisitor.cpp +++ /dev/null @@ -1,58 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qdeclarativejsastvisitor_p.h" - -QT_QML_BEGIN_NAMESPACE - -namespace QDeclarativeJS { namespace AST { - -Visitor::Visitor() -{ -} - -Visitor::~Visitor() -{ -} - -} } // namespace QDeclarativeJS::AST - -QT_QML_END_NAMESPACE diff --git a/src/declarative/qml/parser/qdeclarativejsastvisitor_p.h b/src/declarative/qml/parser/qdeclarativejsastvisitor_p.h deleted file mode 100644 index 639cb33d49..0000000000 --- a/src/declarative/qml/parser/qdeclarativejsastvisitor_p.h +++ /dev/null @@ -1,329 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QDECLARATIVEJSASTVISITOR_P_H -#define QDECLARATIVEJSASTVISITOR_P_H - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists purely as an -// implementation detail. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - -#include "qdeclarativejsastfwd_p.h" -#include "qdeclarativejsglobal_p.h" - -QT_QML_BEGIN_NAMESPACE - -namespace QDeclarativeJS { namespace AST { - -class QML_PARSER_EXPORT Visitor -{ -public: - Visitor(); - virtual ~Visitor(); - - virtual bool preVisit(Node *) { return true; } - virtual void postVisit(Node *) {} - - // Ui - virtual bool visit(UiProgram *) { return true; } - virtual bool visit(UiImportList *) { return true; } - virtual bool visit(UiImport *) { return true; } - virtual bool visit(UiPublicMember *) { return true; } - virtual bool visit(UiSourceElement *) { return true; } - virtual bool visit(UiObjectDefinition *) { return true; } - virtual bool visit(UiObjectInitializer *) { return true; } - virtual bool visit(UiObjectBinding *) { return true; } - virtual bool visit(UiScriptBinding *) { return true; } - virtual bool visit(UiArrayBinding *) { return true; } - virtual bool visit(UiObjectMemberList *) { return true; } - virtual bool visit(UiArrayMemberList *) { return true; } - virtual bool visit(UiQualifiedId *) { return true; } - - virtual void endVisit(UiProgram *) {} - virtual void endVisit(UiImportList *) {} - virtual void endVisit(UiImport *) {} - virtual void endVisit(UiPublicMember *) {} - virtual void endVisit(UiSourceElement *) {} - virtual void endVisit(UiObjectDefinition *) {} - virtual void endVisit(UiObjectInitializer *) {} - virtual void endVisit(UiObjectBinding *) {} - virtual void endVisit(UiScriptBinding *) {} - virtual void endVisit(UiArrayBinding *) {} - virtual void endVisit(UiObjectMemberList *) {} - virtual void endVisit(UiArrayMemberList *) {} - virtual void endVisit(UiQualifiedId *) {} - - // QDeclarativeJS - virtual bool visit(ThisExpression *) { return true; } - virtual void endVisit(ThisExpression *) {} - - virtual bool visit(IdentifierExpression *) { return true; } - virtual void endVisit(IdentifierExpression *) {} - - virtual bool visit(NullExpression *) { return true; } - virtual void endVisit(NullExpression *) {} - - virtual bool visit(TrueLiteral *) { return true; } - virtual void endVisit(TrueLiteral *) {} - - virtual bool visit(FalseLiteral *) { return true; } - virtual void endVisit(FalseLiteral *) {} - - virtual bool visit(StringLiteral *) { return true; } - virtual void endVisit(StringLiteral *) {} - - virtual bool visit(NumericLiteral *) { return true; } - virtual void endVisit(NumericLiteral *) {} - - virtual bool visit(RegExpLiteral *) { return true; } - virtual void endVisit(RegExpLiteral *) {} - - virtual bool visit(ArrayLiteral *) { return true; } - virtual void endVisit(ArrayLiteral *) {} - - virtual bool visit(ObjectLiteral *) { return true; } - virtual void endVisit(ObjectLiteral *) {} - - virtual bool visit(ElementList *) { return true; } - virtual void endVisit(ElementList *) {} - - virtual bool visit(Elision *) { return true; } - virtual void endVisit(Elision *) {} - - virtual bool visit(PropertyNameAndValueList *) { return true; } - virtual void endVisit(PropertyNameAndValueList *) {} - - virtual bool visit(NestedExpression *) { return true; } - virtual void endVisit(NestedExpression *) {} - - virtual bool visit(IdentifierPropertyName *) { return true; } - virtual void endVisit(IdentifierPropertyName *) {} - - virtual bool visit(StringLiteralPropertyName *) { return true; } - virtual void endVisit(StringLiteralPropertyName *) {} - - virtual bool visit(NumericLiteralPropertyName *) { return true; } - virtual void endVisit(NumericLiteralPropertyName *) {} - - virtual bool visit(ArrayMemberExpression *) { return true; } - virtual void endVisit(ArrayMemberExpression *) {} - - virtual bool visit(FieldMemberExpression *) { return true; } - virtual void endVisit(FieldMemberExpression *) {} - - virtual bool visit(NewMemberExpression *) { return true; } - virtual void endVisit(NewMemberExpression *) {} - - virtual bool visit(NewExpression *) { return true; } - virtual void endVisit(NewExpression *) {} - - virtual bool visit(CallExpression *) { return true; } - virtual void endVisit(CallExpression *) {} - - virtual bool visit(ArgumentList *) { return true; } - virtual void endVisit(ArgumentList *) {} - - virtual bool visit(PostIncrementExpression *) { return true; } - virtual void endVisit(PostIncrementExpression *) {} - - virtual bool visit(PostDecrementExpression *) { return true; } - virtual void endVisit(PostDecrementExpression *) {} - - virtual bool visit(DeleteExpression *) { return true; } - virtual void endVisit(DeleteExpression *) {} - - virtual bool visit(VoidExpression *) { return true; } - virtual void endVisit(VoidExpression *) {} - - virtual bool visit(TypeOfExpression *) { return true; } - virtual void endVisit(TypeOfExpression *) {} - - virtual bool visit(PreIncrementExpression *) { return true; } - virtual void endVisit(PreIncrementExpression *) {} - - virtual bool visit(PreDecrementExpression *) { return true; } - virtual void endVisit(PreDecrementExpression *) {} - - virtual bool visit(UnaryPlusExpression *) { return true; } - virtual void endVisit(UnaryPlusExpression *) {} - - virtual bool visit(UnaryMinusExpression *) { return true; } - virtual void endVisit(UnaryMinusExpression *) {} - - virtual bool visit(TildeExpression *) { return true; } - virtual void endVisit(TildeExpression *) {} - - virtual bool visit(NotExpression *) { return true; } - virtual void endVisit(NotExpression *) {} - - virtual bool visit(BinaryExpression *) { return true; } - virtual void endVisit(BinaryExpression *) {} - - virtual bool visit(ConditionalExpression *) { return true; } - virtual void endVisit(ConditionalExpression *) {} - - virtual bool visit(Expression *) { return true; } - virtual void endVisit(Expression *) {} - - virtual bool visit(Block *) { return true; } - virtual void endVisit(Block *) {} - - virtual bool visit(StatementList *) { return true; } - virtual void endVisit(StatementList *) {} - - virtual bool visit(VariableStatement *) { return true; } - virtual void endVisit(VariableStatement *) {} - - virtual bool visit(VariableDeclarationList *) { return true; } - virtual void endVisit(VariableDeclarationList *) {} - - virtual bool visit(VariableDeclaration *) { return true; } - virtual void endVisit(VariableDeclaration *) {} - - virtual bool visit(EmptyStatement *) { return true; } - virtual void endVisit(EmptyStatement *) {} - - virtual bool visit(ExpressionStatement *) { return true; } - virtual void endVisit(ExpressionStatement *) {} - - virtual bool visit(IfStatement *) { return true; } - virtual void endVisit(IfStatement *) {} - - virtual bool visit(DoWhileStatement *) { return true; } - virtual void endVisit(DoWhileStatement *) {} - - virtual bool visit(WhileStatement *) { return true; } - virtual void endVisit(WhileStatement *) {} - - virtual bool visit(ForStatement *) { return true; } - virtual void endVisit(ForStatement *) {} - - virtual bool visit(LocalForStatement *) { return true; } - virtual void endVisit(LocalForStatement *) {} - - virtual bool visit(ForEachStatement *) { return true; } - virtual void endVisit(ForEachStatement *) {} - - virtual bool visit(LocalForEachStatement *) { return true; } - virtual void endVisit(LocalForEachStatement *) {} - - virtual bool visit(ContinueStatement *) { return true; } - virtual void endVisit(ContinueStatement *) {} - - virtual bool visit(BreakStatement *) { return true; } - virtual void endVisit(BreakStatement *) {} - - virtual bool visit(ReturnStatement *) { return true; } - virtual void endVisit(ReturnStatement *) {} - - virtual bool visit(WithStatement *) { return true; } - virtual void endVisit(WithStatement *) {} - - virtual bool visit(SwitchStatement *) { return true; } - virtual void endVisit(SwitchStatement *) {} - - virtual bool visit(CaseBlock *) { return true; } - virtual void endVisit(CaseBlock *) {} - - virtual bool visit(CaseClauses *) { return true; } - virtual void endVisit(CaseClauses *) {} - - virtual bool visit(CaseClause *) { return true; } - virtual void endVisit(CaseClause *) {} - - virtual bool visit(DefaultClause *) { return true; } - virtual void endVisit(DefaultClause *) {} - - virtual bool visit(LabelledStatement *) { return true; } - virtual void endVisit(LabelledStatement *) {} - - virtual bool visit(ThrowStatement *) { return true; } - virtual void endVisit(ThrowStatement *) {} - - virtual bool visit(TryStatement *) { return true; } - virtual void endVisit(TryStatement *) {} - - virtual bool visit(Catch *) { return true; } - virtual void endVisit(Catch *) {} - - virtual bool visit(Finally *) { return true; } - virtual void endVisit(Finally *) {} - - virtual bool visit(FunctionDeclaration *) { return true; } - virtual void endVisit(FunctionDeclaration *) {} - - virtual bool visit(FunctionExpression *) { return true; } - virtual void endVisit(FunctionExpression *) {} - - virtual bool visit(FormalParameterList *) { return true; } - virtual void endVisit(FormalParameterList *) {} - - virtual bool visit(FunctionBody *) { return true; } - virtual void endVisit(FunctionBody *) {} - - virtual bool visit(Program *) { return true; } - virtual void endVisit(Program *) {} - - virtual bool visit(SourceElements *) { return true; } - virtual void endVisit(SourceElements *) {} - - virtual bool visit(FunctionSourceElement *) { return true; } - virtual void endVisit(FunctionSourceElement *) {} - - virtual bool visit(StatementSourceElement *) { return true; } - virtual void endVisit(StatementSourceElement *) {} - - virtual bool visit(DebuggerStatement *) { return true; } - virtual void endVisit(DebuggerStatement *) {} -}; - -} } // namespace AST - -QT_QML_END_NAMESPACE - -#endif // QDECLARATIVEJSASTVISITOR_P_H diff --git a/src/declarative/qml/parser/qdeclarativejsengine_p.cpp b/src/declarative/qml/parser/qdeclarativejsengine_p.cpp deleted file mode 100644 index 534849cd53..0000000000 --- a/src/declarative/qml/parser/qdeclarativejsengine_p.cpp +++ /dev/null @@ -1,161 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qdeclarativejsengine_p.h" -#include "qdeclarativejsglobal_p.h" - -#include -#include -#include - -QT_QML_BEGIN_NAMESPACE - -namespace QDeclarativeJS { - -static int toDigit(char c) -{ - if ((c >= '0') && (c <= '9')) - return c - '0'; - else if ((c >= 'a') && (c <= 'z')) - return 10 + c - 'a'; - else if ((c >= 'A') && (c <= 'Z')) - return 10 + c - 'A'; - return -1; -} - -double integerFromString(const char *buf, int size, int radix) -{ - if (size == 0) - return qSNaN(); - - double sign = 1.0; - int i = 0; - if (buf[0] == '+') { - ++i; - } else if (buf[0] == '-') { - sign = -1.0; - ++i; - } - - if (((size-i) >= 2) && (buf[i] == '0')) { - if (((buf[i+1] == 'x') || (buf[i+1] == 'X')) - && (radix < 34)) { - if ((radix != 0) && (radix != 16)) - return 0; - radix = 16; - i += 2; - } else { - if (radix == 0) { - radix = 8; - ++i; - } - } - } else if (radix == 0) { - radix = 10; - } - - int j = i; - for ( ; i < size; ++i) { - int d = toDigit(buf[i]); - if ((d == -1) || (d >= radix)) - break; - } - double result; - if (j == i) { - if (!qstrcmp(buf, "Infinity")) - result = qInf(); - else - result = qSNaN(); - } else { - result = 0; - double multiplier = 1; - for (--i ; i >= j; --i, multiplier *= radix) - result += toDigit(buf[i]) * multiplier; - } - result *= sign; - return result; -} - -double integerFromString(const QString &str, int radix) -{ - QByteArray ba = str.trimmed().toLatin1(); - return integerFromString(ba.constData(), ba.size(), radix); -} - - -Engine::Engine() - : _lexer(0) -{ } - -Engine::~Engine() -{ } - -void Engine::setCode(const QString &code) -{ _code = code; } - -void Engine::addComment(int pos, int len, int line, int col) -{ if (len > 0) _comments.append(QDeclarativeJS::AST::SourceLocation(pos, len, line, col)); } - -QList Engine::comments() const -{ return _comments; } - -Lexer *Engine::lexer() const -{ return _lexer; } - -void Engine::setLexer(Lexer *lexer) -{ _lexer = lexer; } - -MemoryPool *Engine::pool() -{ return &_pool; } - -QStringRef Engine::newStringRef(const QString &text) -{ - const int pos = _extraCode.length(); - _extraCode += text; - return _extraCode.midRef(pos, text.length()); -} - -QStringRef Engine::newStringRef(const QChar *chars, int size) -{ return newStringRef(QString(chars, size)); } - -} // end of namespace QDeclarativeJS - -QT_QML_END_NAMESPACE diff --git a/src/declarative/qml/parser/qdeclarativejsengine_p.h b/src/declarative/qml/parser/qdeclarativejsengine_p.h deleted file mode 100644 index db8a462d3f..0000000000 --- a/src/declarative/qml/parser/qdeclarativejsengine_p.h +++ /dev/null @@ -1,126 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QDECLARATIVEJSENGINE_P_H -#define QDECLARATIVEJSENGINE_P_H - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists purely as an -// implementation detail. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - -#include "qdeclarativejsglobal_p.h" -#include "qdeclarativejsastfwd_p.h" -#include "qdeclarativejsmemorypool_p.h" - -#include -#include - -QT_QML_BEGIN_NAMESPACE - -namespace QDeclarativeJS { - -class Lexer; -class MemoryPool; - -class QML_PARSER_EXPORT DiagnosticMessage -{ -public: - enum Kind { Warning, Error }; - - DiagnosticMessage() - : kind(Error) {} - - DiagnosticMessage(Kind kind, const AST::SourceLocation &loc, const QString &message) - : kind(kind), loc(loc), message(message) {} - - bool isWarning() const - { return kind == Warning; } - - bool isError() const - { return kind == Error; } - - Kind kind; - AST::SourceLocation loc; - QString message; -}; - -class QML_PARSER_EXPORT Engine -{ - Lexer *_lexer; - MemoryPool _pool; - QList _comments; - QString _extraCode; - QString _code; - -public: - Engine(); - ~Engine(); - - void setCode(const QString &code); - - void addComment(int pos, int len, int line, int col); - QList comments() const; - - Lexer *lexer() const; - void setLexer(Lexer *lexer); - - MemoryPool *pool(); - - inline QStringRef midRef(int position, int size) { return _code.midRef(position, size); } - - QStringRef newStringRef(const QString &s); - QStringRef newStringRef(const QChar *chars, int size); -}; - -double integerFromString(const char *buf, int size, int radix); - -} // end of namespace QDeclarativeJS - -QT_QML_END_NAMESPACE - -#endif // QDECLARATIVEJSENGINE_P_H diff --git a/src/declarative/qml/parser/qdeclarativejsglobal_p.h b/src/declarative/qml/parser/qdeclarativejsglobal_p.h deleted file mode 100644 index 993f4ae3dc..0000000000 --- a/src/declarative/qml/parser/qdeclarativejsglobal_p.h +++ /dev/null @@ -1,69 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#ifndef QDECLARATIVEJSGLOBAL_P_H -#define QDECLARATIVEJSGLOBAL_P_H - -#include - -#ifdef QT_CREATOR -# define QT_QML_BEGIN_NAMESPACE -# define QT_QML_END_NAMESPACE - -# ifdef QDECLARATIVEJS_BUILD_DIR -# define QML_PARSER_EXPORT Q_DECL_EXPORT -# elif QML_BUILD_STATIC_LIB -# define QML_PARSER_EXPORT -# else -# define QML_PARSER_EXPORT Q_DECL_IMPORT -# endif // QDECLARATIVEJS_BUILD_DIR - -#else // !QT_CREATOR -# define QT_QML_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE -# define QT_QML_END_NAMESPACE QT_END_NAMESPACE -# if defined(QT_BUILD_QMLDEVTOOLS_LIB) || defined(QT_QMLDEVTOOLS_LIB) - // QmlDevTools is a static library -# define QML_PARSER_EXPORT -# else -# define QML_PARSER_EXPORT Q_AUTOTEST_EXPORT -# endif -#endif // QT_CREATOR - -#endif // QDECLARATIVEJSGLOBAL_P_H diff --git a/src/declarative/qml/parser/qdeclarativejsgrammar.cpp b/src/declarative/qml/parser/qdeclarativejsgrammar.cpp deleted file mode 100644 index 1e509e5651..0000000000 --- a/src/declarative/qml/parser/qdeclarativejsgrammar.cpp +++ /dev/null @@ -1,1013 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtCore module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -// This file was generated by qlalr - DO NOT EDIT! -#include "qdeclarativejsgrammar_p.h" - -QT_BEGIN_NAMESPACE - -const char *const QDeclarativeJSGrammar::spell [] = { - "end of file", "&", "&&", "&=", "break", "case", "catch", ":", ",", "continue", - "default", "delete", "/", "/=", "do", ".", "else", "=", "==", "===", - "finally", "for", "function", ">=", ">", ">>", ">>=", ">>>", ">>>=", "identifier", - "if", "in", "instanceof", "{", "[", "<=", "(", "<", "<<", "<<=", - "-", "-=", "--", "new", "!", "!=", "!==", "numeric literal", "|", "|=", - "||", "+", "+=", "++", "?", "}", "]", "%", "%=", "return", - ")", ";", 0, "*", "*=", "string literal", "property", "signal", "readonly", "switch", - "this", "throw", "~", "try", "typeof", "var", "void", "while", "with", "^", - "^=", "null", "true", "false", "const", "debugger", "reserved word", "multiline string literal", "comment", "public", - "import", "as", "on", 0, 0, 0, 0, 0, 0, 0, - 0, 0}; - -const short QDeclarativeJSGrammar::lhs [] = { - 102, 102, 102, 102, 102, 102, 103, 109, 109, 112, - 112, 114, 113, 113, 113, 113, 113, 113, 113, 113, - 116, 111, 110, 119, 119, 120, 120, 121, 121, 118, - 107, 107, 107, 107, 123, 123, 123, 123, 123, 123, - 123, 107, 131, 131, 131, 132, 132, 133, 133, 107, - 107, 107, 107, 107, 107, 107, 107, 107, 107, 107, - 107, 107, 107, 107, 107, 107, 117, 117, 117, 117, - 117, 136, 136, 136, 136, 136, 136, 136, 136, 136, - 136, 136, 136, 136, 136, 136, 136, 136, 136, 122, - 138, 138, 138, 138, 137, 137, 140, 140, 142, 142, - 142, 142, 142, 142, 143, 143, 143, 143, 143, 143, - 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, - 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, - 143, 143, 143, 143, 143, 144, 144, 115, 115, 115, - 115, 115, 147, 147, 148, 148, 148, 148, 146, 146, - 149, 149, 150, 150, 151, 151, 151, 152, 152, 152, - 152, 152, 152, 152, 152, 152, 152, 153, 153, 153, - 153, 154, 154, 154, 155, 155, 155, 155, 156, 156, - 156, 156, 156, 156, 156, 157, 157, 157, 157, 157, - 157, 158, 158, 158, 158, 158, 159, 159, 159, 159, - 159, 160, 160, 161, 161, 162, 162, 163, 163, 164, - 164, 165, 165, 166, 166, 167, 167, 168, 168, 169, - 169, 170, 170, 171, 171, 141, 141, 172, 172, 173, - 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, - 173, 105, 105, 174, 174, 175, 175, 176, 176, 104, - 104, 104, 104, 104, 104, 104, 104, 104, 104, 104, - 104, 104, 104, 104, 124, 185, 185, 184, 184, 135, - 135, 186, 186, 187, 187, 189, 189, 188, 190, 193, - 191, 191, 194, 192, 192, 125, 126, 126, 127, 127, - 177, 177, 177, 177, 177, 177, 177, 178, 178, 178, - 178, 179, 179, 179, 179, 180, 180, 128, 129, 195, - 195, 198, 198, 196, 196, 199, 197, 181, 181, 181, - 182, 182, 130, 130, 130, 200, 201, 183, 183, 134, - 145, 205, 205, 202, 202, 203, 203, 206, 108, 108, - 207, 207, 106, 106, 204, 204, 139, 139, 208}; - -const short QDeclarativeJSGrammar::rhs [] = { - 2, 2, 2, 2, 2, 2, 2, 1, 1, 1, - 2, 1, 2, 2, 3, 3, 5, 5, 4, 4, - 2, 0, 1, 1, 2, 1, 3, 2, 3, 2, - 1, 5, 4, 4, 1, 1, 1, 1, 1, 1, - 1, 3, 1, 1, 1, 0, 1, 2, 4, 6, - 6, 3, 3, 7, 7, 4, 4, 5, 5, 5, - 6, 6, 10, 6, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 2, 3, 3, 4, 5, 3, 4, 3, 1, - 1, 2, 3, 4, 1, 2, 3, 5, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 4, - 3, 5, 1, 2, 4, 4, 4, 3, 0, 1, - 1, 3, 1, 1, 1, 2, 2, 1, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 1, 3, 3, - 3, 1, 3, 3, 1, 3, 3, 3, 1, 3, - 3, 3, 3, 3, 3, 1, 3, 3, 3, 3, - 3, 1, 3, 3, 3, 3, 1, 3, 3, 3, - 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, - 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, - 3, 1, 5, 1, 5, 1, 3, 1, 3, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 3, 0, 1, 1, 3, 0, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 3, 1, 2, 0, 1, 3, - 3, 1, 1, 1, 3, 1, 3, 2, 2, 2, - 0, 1, 2, 0, 1, 1, 2, 2, 7, 5, - 7, 7, 5, 9, 10, 7, 8, 2, 2, 3, - 3, 2, 2, 3, 3, 3, 3, 5, 5, 3, - 5, 1, 2, 0, 1, 4, 3, 3, 3, 3, - 3, 3, 3, 3, 4, 5, 2, 2, 2, 8, - 8, 1, 3, 0, 1, 0, 1, 1, 1, 1, - 1, 2, 1, 1, 0, 1, 0, 1, 2}; - -const short QDeclarativeJSGrammar::action_default [] = { - 0, 0, 22, 0, 0, 0, 22, 0, 175, 242, - 206, 214, 210, 154, 226, 202, 3, 139, 73, 155, - 218, 222, 143, 172, 153, 158, 138, 192, 179, 0, - 80, 81, 76, 345, 67, 347, 0, 0, 0, 0, - 78, 0, 0, 74, 77, 71, 0, 0, 68, 70, - 69, 79, 72, 0, 75, 0, 0, 168, 0, 0, - 155, 174, 157, 156, 0, 0, 0, 170, 171, 169, - 173, 0, 203, 0, 0, 0, 0, 193, 0, 0, - 0, 0, 0, 0, 183, 0, 0, 0, 177, 178, - 176, 181, 185, 184, 182, 180, 195, 194, 196, 0, - 211, 0, 207, 0, 0, 149, 136, 148, 137, 105, - 106, 107, 132, 108, 133, 109, 110, 111, 112, 113, - 114, 115, 116, 117, 118, 119, 120, 121, 134, 122, - 123, 124, 125, 126, 127, 128, 129, 130, 131, 135, - 0, 0, 147, 243, 150, 0, 151, 0, 152, 146, - 0, 239, 232, 230, 237, 238, 236, 235, 241, 234, - 233, 231, 240, 227, 0, 215, 0, 0, 219, 0, - 0, 223, 0, 0, 149, 141, 0, 140, 0, 145, - 159, 0, 346, 334, 335, 0, 332, 0, 333, 0, - 336, 250, 257, 256, 264, 252, 0, 253, 337, 0, - 344, 254, 255, 260, 258, 341, 338, 343, 261, 0, - 272, 0, 0, 0, 0, 345, 67, 0, 347, 68, - 244, 286, 69, 0, 0, 0, 273, 0, 0, 262, - 263, 0, 251, 259, 287, 288, 331, 342, 0, 302, - 303, 304, 305, 0, 298, 299, 300, 301, 328, 329, - 0, 0, 0, 0, 0, 291, 292, 248, 246, 208, - 216, 212, 228, 204, 249, 0, 155, 220, 224, 197, - 186, 0, 0, 205, 0, 0, 0, 0, 198, 0, - 0, 0, 0, 0, 190, 188, 191, 189, 187, 200, - 199, 201, 0, 213, 0, 209, 0, 247, 155, 0, - 229, 244, 245, 0, 244, 0, 0, 294, 0, 0, - 0, 296, 0, 217, 0, 0, 221, 0, 0, 225, - 284, 0, 276, 285, 279, 0, 283, 0, 244, 277, - 0, 244, 0, 0, 295, 0, 0, 0, 297, 346, - 334, 0, 0, 336, 0, 330, 0, 320, 0, 0, - 0, 290, 0, 289, 0, 348, 0, 104, 266, 269, - 0, 105, 272, 108, 133, 110, 111, 76, 115, 116, - 67, 117, 120, 74, 77, 68, 244, 69, 79, 123, - 72, 125, 75, 127, 128, 273, 130, 131, 135, 0, - 97, 0, 0, 99, 103, 101, 88, 100, 102, 0, - 98, 87, 267, 265, 143, 144, 149, 0, 142, 0, - 319, 0, 306, 307, 0, 318, 0, 0, 0, 309, - 314, 312, 315, 0, 0, 313, 314, 0, 310, 0, - 311, 268, 317, 0, 268, 316, 0, 321, 322, 0, - 268, 323, 324, 0, 0, 325, 0, 0, 0, 326, - 327, 161, 160, 0, 0, 0, 293, 0, 0, 0, - 308, 281, 274, 0, 282, 278, 0, 280, 270, 0, - 271, 275, 91, 0, 0, 95, 82, 0, 84, 93, - 0, 85, 94, 96, 86, 92, 83, 0, 89, 165, - 163, 167, 164, 162, 166, 339, 6, 340, 4, 2, - 65, 90, 0, 0, 68, 70, 69, 31, 5, 0, - 66, 0, 45, 44, 43, 0, 0, 58, 0, 59, - 35, 36, 37, 38, 40, 41, 62, 39, 0, 45, - 0, 0, 0, 0, 0, 54, 0, 55, 0, 0, - 26, 0, 0, 63, 27, 0, 30, 28, 24, 0, - 29, 25, 0, 56, 0, 57, 143, 0, 60, 64, - 0, 0, 0, 0, 61, 0, 52, 46, 53, 47, - 0, 0, 0, 0, 49, 0, 50, 51, 48, 0, - 0, 143, 268, 0, 0, 42, 105, 272, 108, 133, - 110, 111, 76, 115, 116, 67, 117, 120, 74, 77, - 68, 244, 69, 79, 123, 72, 125, 75, 127, 128, - 273, 130, 131, 135, 0, 32, 33, 0, 34, 8, - 0, 10, 0, 9, 0, 1, 21, 12, 0, 13, - 0, 14, 0, 19, 20, 0, 15, 16, 0, 17, - 18, 11, 23, 7, 349}; - -const short QDeclarativeJSGrammar::goto_default [] = { - 7, 625, 207, 196, 205, 508, 496, 624, 643, 495, - 623, 621, 626, 22, 622, 18, 507, 549, 539, 546, - 541, 526, 191, 195, 197, 201, 233, 208, 230, 530, - 570, 569, 200, 232, 26, 474, 473, 356, 355, 9, - 354, 357, 107, 17, 145, 24, 13, 144, 19, 25, - 57, 23, 8, 28, 27, 269, 15, 263, 10, 259, - 12, 261, 11, 260, 20, 267, 21, 268, 14, 262, - 258, 299, 411, 264, 265, 202, 193, 192, 204, 203, - 229, 194, 360, 359, 231, 463, 462, 321, 322, 465, - 324, 464, 323, 419, 423, 426, 422, 421, 441, 442, - 185, 199, 181, 184, 198, 206, 0}; - -const short QDeclarativeJSGrammar::action_index [] = { - 404, 1275, 2411, 2411, 2509, 1000, 68, 92, 90, -102, - 88, 62, 60, 256, -102, 298, 86, -102, -102, 638, - 83, 134, 172, 219, -102, -102, -102, 454, 194, 1275, - -102, -102, -102, 381, -102, 2215, 1555, 1275, 1275, 1275, - -102, 790, 1275, -102, -102, -102, 1275, 1275, -102, -102, - -102, -102, -102, 1275, -102, 1275, 1275, -102, 1275, 1275, - 102, 217, -102, -102, 1275, 1275, 1275, -102, -102, -102, - 204, 1275, 304, 1275, 1275, 1275, 1275, 539, 1275, 1275, - 1275, 1275, 1275, 1275, 308, 1275, 1275, 1275, 103, 131, - 135, 308, 210, 225, 216, 308, 444, 390, 434, 1275, - 82, 1275, 100, 2117, 1275, 1275, -102, -102, -102, -102, - -102, -102, -102, -102, -102, -102, -102, -102, -102, -102, - -102, -102, -102, -102, -102, -102, -102, -102, -102, -102, - -102, -102, -102, -102, -102, -102, -102, -102, -102, -102, - 139, 1275, -102, -102, 91, 10, -102, 1275, -102, -102, - 1275, -102, -102, -102, -102, -102, -102, -102, -102, -102, - -102, -102, -102, -102, 1275, 26, 1275, 1275, 69, 66, - 1275, -102, 2117, 1275, 1275, -102, 97, -102, 44, -102, - -102, 67, -102, 297, 78, 24, -102, 291, -102, 36, - 2411, -102, -102, -102, -102, -102, 234, -102, -102, 12, - -102, -102, -102, -102, -102, -102, 2411, -102, -102, 464, - -102, 461, 115, 2509, 42, 381, 58, 46, 2705, 70, - 1275, -102, 74, 57, 1275, 65, -102, 59, 61, -102, - -102, 367, -102, -102, -102, -102, -102, -102, 106, -102, - -102, -102, -102, 87, -102, -102, -102, -102, -102, -102, - 56, 55, 1275, 99, 84, -102, -102, 1461, -102, 75, - 48, 52, -102, 306, 72, 53, 579, 77, 110, 370, - 230, 381, 1275, 286, 1275, 1275, 1275, 1275, 380, 1275, - 1275, 1275, 1275, 1275, 184, 169, 166, 190, 198, 460, - 363, 353, 1275, 50, 1275, 63, 1275, -102, 638, 1275, - -102, 1275, 64, 39, 1275, 30, 2509, -102, 1275, 173, - 2509, -102, 1275, 79, 1275, 1275, 81, 80, 1275, -102, - 71, 149, 32, -102, -102, 1275, -102, 381, 1275, -102, - 73, 1275, 76, 2509, -102, 1275, 142, 2509, -102, -16, - 381, -42, -12, 2411, -39, -102, 2509, -102, 1275, 154, - 2509, 14, 2509, -102, 20, 16, -32, -102, -102, 2509, - -51, 519, -4, 511, 136, 1275, 2509, -2, -35, 395, - -1, -27, 908, 4, 6, -102, 1370, -102, 0, -36, - 27, 1275, 47, 22, 1275, 45, 1275, 21, 17, 1275, - -102, 2313, 144, -102, -102, -102, -102, -102, -102, 1275, - -102, -102, -102, -102, 274, -102, 1275, -21, -102, 2509, - -102, 138, -102, -102, 2509, -102, 1275, 132, 5, -102, - 40, -102, 41, 101, 1275, -102, 38, 34, -102, -38, - -102, 2509, -102, 105, 2509, -102, 245, -102, -102, 96, - 2509, 11, -102, -7, -11, -102, 352, 8, 18, -102, - -102, -102, -102, 1275, 129, 2509, -102, 1275, 130, 2509, - -102, 49, -102, 226, -102, -102, 1275, -102, -102, 362, - -102, -102, -102, 107, 1837, -102, -102, 1649, -102, -102, - 1743, -102, -102, -102, -102, -102, -102, 114, -102, -102, - -102, -102, -102, -102, -102, -102, -102, 2411, -102, -102, - -102, 94, 9, 818, 189, -10, 31, -102, -102, 223, - -102, 191, -102, -102, -102, 300, 178, -102, 1928, -102, - -102, -102, -102, -102, -102, -102, -102, -102, 257, -25, - 381, 195, -22, 305, 240, -102, -6, -102, 818, 127, - -102, -18, 818, -102, -102, 1184, -102, -102, -102, 1092, - -102, -102, 237, -102, 1928, -102, 294, -8, -102, -102, - 176, 381, 19, 1928, -102, 165, -102, 174, -102, 2, - -52, 381, 183, 381, -102, 117, -102, -102, -102, 2019, - 880, 285, 2607, 1555, 3, -102, 522, 35, 453, 108, - 1275, 2509, 51, 23, 475, 54, -17, 700, 7, 43, - -102, 1370, -102, 28, -3, 33, 1275, 37, 15, 1275, - 25, 1275, 1, 13, 124, -102, -102, 29, -102, -102, - 728, -102, 250, -43, 627, -102, -102, 231, 372, -102, - 222, -102, 111, -102, -102, 381, -102, -102, 104, -102, - -102, -102, -102, -102, -102, - - -107, 9, -103, 2, 5, 266, 1, -107, -107, -107, - -107, -107, -107, -107, -107, -107, -107, -107, -107, -39, - -107, -107, -107, -107, -107, -107, -107, -107, -107, 86, - -107, -107, -107, 8, -107, -107, -22, 19, 71, 174, - -107, 186, 171, -107, -107, -107, 184, 178, -107, -107, - -107, -107, -107, 144, -107, 124, 150, -107, 165, 161, - -107, -107, -107, -107, 156, 160, 157, -107, -107, -107, - -107, 147, -107, 142, 135, 179, 166, -107, 177, 170, - 117, 72, 134, 92, -107, 75, 94, 66, -107, -107, - -107, -107, -107, -107, -107, -107, -107, -107, -107, 181, - -107, 106, -107, 143, 78, 55, -107, -107, -107, -107, - -107, -107, -107, -107, -107, -107, -107, -107, -107, -107, - -107, -107, -107, -107, -107, -107, -107, -107, -107, -107, - -107, -107, -107, -107, -107, -107, -107, -107, -107, -107, - -107, -5, -107, -107, -107, -107, -107, 54, -107, -107, - 51, -107, -107, -107, -107, -107, -107, -107, -107, -107, - -107, -107, -107, -107, 114, -107, 113, 38, -107, -107, - 41, -107, 231, 63, 112, -107, -107, -107, -107, -107, - -107, -107, -107, 30, -107, -107, -107, 52, -107, -107, - -107, -107, -107, -107, -107, -107, -107, -107, -107, -107, - -107, -107, -107, -107, -107, -107, 36, -107, -107, 45, - -107, 42, -107, 40, -107, 80, -107, -107, 77, -107, - 88, -107, -107, -107, 83, 74, -107, -107, -107, -107, - -107, -10, -107, -107, -107, -107, -107, -107, -107, -107, - -107, -107, -107, -107, -107, -107, -107, -107, -107, -107, - -107, -107, 23, -107, -107, -107, -107, 100, -107, -107, - -107, -107, -107, -107, -107, -107, -107, -107, -107, -107, - -107, 4, 223, -107, 230, 236, 222, 205, -107, 127, - 125, 115, 96, 102, -107, -107, -107, -107, -107, -107, - -107, -107, 234, -107, 215, -107, 199, -107, -107, 197, - -107, 190, -107, -107, 163, -107, 90, -107, 0, -107, - -1, -107, 203, -107, 189, 211, -107, -107, 195, -107, - -107, -107, -107, -107, -107, 191, -107, 98, 119, -107, - -107, 95, -107, 81, -107, 79, -107, 82, -107, -107, - 101, -107, -107, -16, -107, -107, 53, -107, 46, -107, - 57, -107, 59, -107, -107, -107, -107, -107, -107, 35, - -107, 33, -107, 39, -107, 89, 67, -107, -107, 58, - -107, -107, 84, -107, -107, -107, 73, -107, -107, -107, - -107, 65, -107, 43, 93, -107, 109, -107, -107, 49, - -107, 47, -107, -107, -107, -107, -107, -107, -107, 50, - -107, -107, -107, -107, -107, -107, 108, -107, -107, 61, - -107, -107, -107, -107, 62, -107, 68, -107, -107, -107, - -107, -107, -23, -107, 69, -107, -19, -107, -107, -107, - -107, 97, -107, -107, 99, -107, -107, -107, -107, -107, - 60, -61, -107, -107, 34, -107, 37, -107, 29, -107, - -107, -107, -107, 32, -107, 76, -107, 44, -107, 56, - -107, -107, -107, -107, -107, -107, 31, -107, -107, 116, - -107, -107, -107, -107, -6, -107, -107, 70, -107, -107, - 64, -107, -107, -107, -107, -107, -107, -107, -107, -107, - -107, -107, -107, -107, -107, -107, -107, 193, -107, -107, - -107, -107, -107, 7, -107, -107, -107, -107, -107, -107, - -107, -20, -107, -107, -107, -7, -107, -107, 290, -107, - -107, -107, -107, -107, -107, -107, -107, -107, -107, -107, - -2, -25, -107, -15, -107, -107, -107, -107, 172, -107, - -107, -107, 287, -107, -107, 288, -107, -107, -107, 291, - -107, -107, -107, -107, 336, -107, -107, 20, -107, -107, - 15, 3, -107, 304, -107, -107, -107, 24, -107, -107, - -107, 28, 21, 26, -107, -107, -107, -107, -107, 320, - 104, -107, 13, 381, -3, -107, 6, -107, 10, -107, - 167, 22, -107, -107, 12, -107, -107, 87, -107, -107, - -107, 25, -107, -107, -107, -107, 11, -107, 14, 85, - -107, 121, -107, -107, -107, -107, -107, 27, -107, -107, - 17, -107, -107, 18, 91, -107, -107, -107, 16, -107, - -107, -107, -107, -107, -107, -4, -107, -107, -107, -107, - -107, -107, -107, -107, -107}; - -const short QDeclarativeJSGrammar::action_info [] = { - 416, 257, 533, -132, 403, -113, 346, -102, 575, 348, - 572, -121, 531, -103, -121, 545, 345, 430, 342, 348, - 340, 343, 440, 401, 391, 545, 563, 389, 538, 446, - 352, 444, -129, 416, -124, -102, 545, 453, 420, 408, - -124, 431, -132, 424, -126, 424, 424, 620, 440, 457, - -103, 440, -129, 457, -126, 440, 560, 453, -113, 257, - 565, 346, 545, 335, 272, 346, 466, 236, 448, 190, - 149, 164, 141, 170, 99, 511, 272, 409, 257, 312, - 296, 414, 348, 312, 189, 164, 187, 318, 325, 71, - 306, 252, 644, 416, 141, 453, 292, 457, 440, 147, - 304, 71, 443, 183, 179, 141, 0, 141, 0, 172, - 99, 427, 434, 141, 301, 477, 444, 0, 0, 0, - 0, 0, 141, 0, 0, 0, 0, 292, 173, 294, - 58, 294, 542, 251, 331, 542, 333, 141, 141, 101, - 141, 59, 0, 58, 62, 256, 255, 141, 247, 246, - 141, 399, 0, 177, 59, 63, 428, 327, 620, 254, - 314, 101, 141, 478, 315, 640, 639, 242, 241, 249, - 248, 58, 634, 633, 488, 58, 249, 248, 577, 576, - 615, 141, 59, 543, 166, 518, 59, 172, 167, 455, - 459, 85, 418, 86, 85, 142, 86, 249, 248, 413, - 412, 567, 337, 512, 87, 512, 173, 87, 174, 85, - 328, 86, 512, 0, 350, 85, 64, 86, 529, 85, - 512, 86, 87, 85, 512, 86, 568, 566, 87, 64, - 579, 64, 87, 310, 469, 85, 87, 86, 0, 519, - 517, 85, 141, 86, 554, 0, 172, 536, 87, 514, - 85, 514, 86, 141, 87, 85, 545, 86, 514, 0, - 513, 65, 513, 87, 514, 173, 514, 66, 87, 513, - 514, 103, 172, 0, 65, 513, 65, 513, 0, 0, - 66, 513, 66, 637, 636, 0, 0, 470, 468, 172, - 104, 173, 105, 406, 0, 235, 234, 630, 555, 553, - 172, 537, 535, 0, 274, 275, 438, 437, 173, 172, - 406, 631, 629, 635, 0, 580, 73, 74, -90, 173, - 34, 174, 73, 74, 274, 275, 34, -90, 173, 34, - 174, 276, 277, 85, 34, 86, 0, 0, 0, 0, - 0, 628, 0, 75, 76, 0, 87, 0, 0, 75, - 76, 276, 277, 0, 0, 0, 0, 48, 50, 49, - 0, 0, 0, 48, 50, 49, 48, 50, 49, 0, - 0, 48, 50, 49, 0, 0, 279, 280, 0, 0, - 0, 34, 0, 45, 0, 281, 279, 280, 282, 45, - 283, 34, 45, 279, 280, 281, 34, 45, 282, 0, - 283, 34, 281, 279, 280, 282, 0, 283, 0, 0, - 34, 0, 281, 78, 79, 282, 0, 283, 48, 50, - 49, 80, 81, 0, 34, 82, 0, 83, 48, 50, - 49, -345, 0, 48, 50, 49, 0, 0, 48, 50, - 49, 0, 0, 0, 45, 0, 0, 48, 50, 49, - 0, 0, 0, 0, 45, 0, 0, 78, 79, 45, - 0, 48, 50, 49, 45, 80, 81, 78, 79, 82, - 0, 83, 0, 45, 0, 80, 81, 78, 79, 82, - 0, 83, 34, 279, 280, 80, 81, 45, 0, 82, - 34, 83, 281, 34, 0, 282, 0, 283, 6, 5, - 4, 1, 3, 2, 34, 0, 0, 0, 0, 0, - 0, -345, 0, 0, 245, 244, 0, 0, 0, 48, - 50, 49, 245, 244, 0, 240, 239, 48, 50, 49, - 48, 50, 49, 0, 0, 0, 0, 0, 0, 0, - 34, 48, 50, 49, 0, 45, 0, 0, 34, 0, - 0, 34, 0, 45, 0, 0, 45, 0, 0, 0, - 0, 0, 78, 79, 0, 0, 0, 45, 0, 0, - 80, 81, 245, 244, 82, 0, 83, 48, 50, 49, - 240, 239, 151, 240, 239, 48, 50, 49, 48, 50, - 49, 0, 152, 0, 0, 0, 153, 0, 0, 0, - 0, 0, 0, 45, 0, 154, 0, 155, 0, 0, - 308, 45, 0, 0, 45, 0, 0, 0, 156, 0, - 157, 62, 0, 0, 0, 0, 0, 0, 158, 0, - 0, 159, 63, 0, 0, 0, 0, 160, 0, 30, - 31, 151, 0, 161, 0, 0, 0, 0, 0, 33, - 0, 152, 0, 0, 0, 153, 34, 0, 0, 162, - 35, 36, 0, 37, 154, 0, 155, 0, 0, 0, - 503, 0, 0, 0, 44, 0, 0, 156, 0, 157, - 62, 0, 0, 0, 0, 0, 0, 158, 0, 0, - 159, 63, 51, 48, 50, 49, 160, 52, 0, 0, - 0, 0, 161, 0, 0, 0, 0, 0, 43, 54, - 32, 0, 30, 31, 40, 0, 0, 0, 162, 45, - 0, 0, 33, 0, 0, 0, 0, 0, 0, 34, - 0, 0, 0, 35, 36, 0, 37, 0, 0, 0, - 30, 31, 0, 41, 0, 0, 0, 44, 0, 0, - 33, 0, 0, 0, 0, 0, 0, 34, 0, 0, - 0, 35, 36, 0, 37, 51, 48, 50, 49, 0, - 52, 503, 0, 0, 0, 44, 0, 0, 0, 0, - 0, 43, 54, 32, 0, 0, 0, 40, 0, 0, - 0, 0, 45, 51, 48, 50, 49, 0, 52, 0, - 0, 0, 30, 31, 0, 0, 0, 0, 0, 43, - 54, 32, 33, 0, 0, 40, 0, 0, 0, 34, - 45, 0, 0, 35, 36, 0, 37, 0, 0, 0, - 30, 31, 0, 41, 0, 0, 0, 44, 0, 0, - 33, 0, 0, 0, 0, 0, 0, 34, 0, 0, - 0, 35, 36, 0, 37, 51, 48, 50, 49, 0, - 52, 503, 0, 0, 0, 44, 0, 0, 0, 0, - 0, 43, 54, 32, 0, 0, 0, 40, 0, 0, - 0, 0, 45, 51, 48, 50, 49, 0, 52, 0, - 0, 0, 30, 31, 0, 0, 0, 0, 0, 43, - 54, 32, 33, 0, 0, 40, 0, 0, 0, 34, - 45, 0, 0, 35, 36, 0, 37, 0, 0, 0, - 30, 31, 0, 503, 0, 0, 0, 44, 0, 0, - 33, 0, 0, 0, 0, 0, 0, 34, 0, 0, - 0, 35, 36, 0, 37, 51, 48, 50, 49, 0, - 52, 41, 0, 0, 0, 44, 0, 0, 0, 0, - 0, 43, 54, 32, 0, 0, 0, 40, 0, 0, - 0, 0, 45, 51, 48, 50, 49, 0, 52, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 43, - 54, 32, 0, 0, 0, 40, 0, 0, 0, 0, - 45, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 502, 0, 30, 31, 0, 0, 0, 0, 0, 0, - 0, 0, 215, 0, 0, 0, 0, 0, 0, 34, - 0, 0, 0, 35, 36, 0, 37, 0, 0, 0, - 0, 0, 0, 503, 0, 0, 0, 44, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 51, 504, 506, 505, 0, - 52, 0, 0, 0, 0, 226, 0, 0, 0, 0, - 0, 43, 54, 32, 210, 0, 0, 40, 0, 0, - 0, 0, 45, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 502, 0, 30, 31, 0, 0, 0, 0, - 0, 0, 0, 0, 215, 0, 0, 0, 0, 0, - 0, 34, 0, 0, 0, 35, 36, 0, 37, 0, - 0, 0, 0, 0, 0, 503, 0, 0, 0, 44, - 0, 0, 0, 0, 0, 0, 0, 550, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 51, 504, 506, - 505, 0, 52, 0, 0, 0, 0, 226, 0, 0, - 0, 0, 0, 43, 54, 32, 210, 0, 0, 40, - 0, 0, 0, 0, 45, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 502, 0, 30, 31, 0, 0, - 0, 0, 0, 0, 0, 0, 215, 0, 0, 0, - 0, 0, 0, 34, 0, 0, 0, 35, 36, 0, - 37, 0, 0, 0, 0, 0, 0, 503, 0, 0, - 0, 44, 0, 0, 0, 0, 0, 0, 0, 547, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 51, - 504, 506, 505, 0, 52, 0, 0, 0, 0, 226, - 0, 0, 0, 0, 0, 43, 54, 32, 210, 0, - 0, 40, 0, 0, 0, 0, 45, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 29, 30, 31, 0, - 0, 0, 0, 0, 0, 0, 0, 33, 0, 0, - 0, 0, 0, 0, 34, 0, 0, 0, 35, 36, - 0, 37, 0, 0, 0, 38, 0, 39, 41, 42, - 0, 0, 44, 0, 0, 0, 46, 0, 47, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 51, 48, 50, 49, 0, 52, 0, 53, 0, 55, - 0, 56, 0, 0, 0, 0, 43, 54, 32, 0, - 0, 0, 40, 0, 0, 0, 0, 45, 0, 0, - 0, 0, 0, 0, 0, 0, 0, -122, 0, 0, - 0, 29, 30, 31, 0, 0, 0, 0, 0, 0, - 0, 0, 33, 0, 0, 0, 0, 0, 0, 34, - 0, 0, 0, 35, 36, 0, 37, 0, 0, 0, - 38, 0, 39, 41, 42, 0, 0, 44, 0, 0, - 0, 46, 0, 47, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 51, 48, 50, 49, 0, - 52, 0, 53, 0, 55, 0, 56, 0, 0, 0, - 0, 43, 54, 32, 0, 0, 0, 40, 0, 0, - 0, 0, 45, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 29, 30, 31, 0, 0, 0, 0, 0, - 0, 0, 0, 33, 0, 0, 0, 0, 0, 0, - 34, 0, 0, 0, 35, 36, 0, 37, 0, 0, - 0, 38, 0, 39, 41, 42, 0, 0, 44, 0, - 0, 0, 46, 0, 47, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 51, 48, 50, 49, - 0, 52, 0, 53, 0, 55, 271, 56, 0, 0, - 0, 0, 43, 54, 32, 0, 0, 0, 40, 0, - 0, 0, 0, 45, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 475, 0, 0, 29, 30, 31, 0, - 0, 0, 0, 0, 0, 0, 0, 33, 0, 0, - 0, 0, 0, 0, 34, 0, 0, 0, 35, 36, - 0, 37, 0, 0, 0, 38, 0, 39, 41, 42, - 0, 0, 44, 0, 0, 0, 46, 0, 47, 0, - 0, 476, 0, 0, 0, 0, 0, 0, 0, 0, - 51, 48, 50, 49, 0, 52, 0, 53, 0, 55, - 0, 56, 0, 0, 0, 0, 43, 54, 32, 0, - 0, 0, 40, 0, 0, 0, 0, 45, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 475, 0, 0, - 29, 30, 31, 0, 0, 0, 0, 0, 0, 0, - 0, 33, 0, 0, 0, 0, 0, 0, 34, 0, - 0, 0, 35, 36, 0, 37, 0, 0, 0, 38, - 0, 39, 41, 42, 0, 0, 44, 0, 0, 0, - 46, 0, 47, 0, 0, 481, 0, 0, 0, 0, - 0, 0, 0, 0, 51, 48, 50, 49, 0, 52, - 0, 53, 0, 55, 0, 56, 0, 0, 0, 0, - 43, 54, 32, 0, 0, 0, 40, 0, 0, 0, - 0, 45, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 483, 0, 0, 29, 30, 31, 0, 0, 0, - 0, 0, 0, 0, 0, 33, 0, 0, 0, 0, - 0, 0, 34, 0, 0, 0, 35, 36, 0, 37, - 0, 0, 0, 38, 0, 39, 41, 42, 0, 0, - 44, 0, 0, 0, 46, 0, 47, 0, 0, 484, - 0, 0, 0, 0, 0, 0, 0, 0, 51, 48, - 50, 49, 0, 52, 0, 53, 0, 55, 0, 56, - 0, 0, 0, 0, 43, 54, 32, 0, 0, 0, - 40, 0, 0, 0, 0, 45, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 483, 0, 0, 29, 30, - 31, 0, 0, 0, 0, 0, 0, 0, 0, 33, - 0, 0, 0, 0, 0, 0, 34, 0, 0, 0, - 35, 36, 0, 37, 0, 0, 0, 38, 0, 39, - 41, 42, 0, 0, 44, 0, 0, 0, 46, 0, - 47, 0, 0, 486, 0, 0, 0, 0, 0, 0, - 0, 0, 51, 48, 50, 49, 0, 52, 0, 53, - 0, 55, 0, 56, 0, 0, 0, 0, 43, 54, - 32, 0, 0, 0, 40, 0, 0, 0, 0, 45, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 29, - 30, 31, 0, 0, 0, 0, 0, 0, 0, 0, - 33, 0, 0, 0, 0, 0, 0, 34, 217, 0, - 0, 218, 36, 0, 37, 0, 0, 0, 38, 0, - 39, 41, 42, 0, 0, 44, 0, 0, 0, 46, - 0, 47, 0, 0, 0, 0, 0, 0, 0, 221, - 0, 0, 0, 51, 48, 50, 49, 223, 52, 0, - 53, 225, 55, 0, 56, 0, 228, 0, 0, 43, - 54, 32, 0, 0, 0, 40, 0, 0, 0, 0, - 45, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 29, 30, 31, 0, 0, 0, 0, 0, 0, 0, - 0, 33, 0, 0, 0, 0, 0, 0, 34, 217, - 0, 0, 582, 583, 0, 37, 0, 0, 0, 38, - 0, 39, 41, 42, 0, 0, 44, 0, 0, 0, - 46, 0, 47, 0, 0, 0, 0, 0, 0, 0, - 221, 0, 0, 0, 51, 48, 50, 49, 223, 52, - 0, 53, 225, 55, 0, 56, 0, 228, 0, 0, - 43, 54, 32, 0, 0, 0, 40, 0, 0, 0, - 0, 45, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 109, 110, 111, 0, 0, 113, 115, 116, 0, - 0, 117, 0, 118, 0, 0, 0, 120, 121, 122, - 0, 0, 0, 0, 0, 0, 34, 123, 124, 125, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 126, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 129, 0, 0, 0, - 0, 0, 0, 48, 50, 49, 130, 131, 132, 0, - 134, 135, 136, 137, 138, 139, 0, 0, 127, 133, - 119, 112, 114, 128, 0, 0, 0, 0, 0, 45, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 109, - 110, 111, 0, 0, 113, 115, 116, 0, 0, 117, - 0, 118, 0, 0, 0, 120, 121, 122, 0, 0, - 0, 0, 0, 0, 393, 123, 124, 125, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 126, 0, - 0, 0, 394, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 129, 0, 0, 0, 0, 0, - 398, 395, 397, 0, 130, 131, 132, 0, 134, 135, - 136, 137, 138, 139, 0, 0, 127, 133, 119, 112, - 114, 128, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 109, 110, 111, - 0, 0, 113, 115, 116, 0, 0, 117, 0, 118, - 0, 0, 0, 120, 121, 122, 0, 0, 0, 0, - 0, 0, 393, 123, 124, 125, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 126, 0, 0, 0, - 394, 0, 0, 0, 0, 0, 0, 0, 396, 0, - 0, 0, 129, 0, 0, 0, 0, 0, 398, 395, - 397, 0, 130, 131, 132, 0, 134, 135, 136, 137, - 138, 139, 0, 0, 127, 133, 119, 112, 114, 128, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 209, 0, 0, 0, 0, - 211, 0, 29, 30, 31, 213, 0, 0, 0, 0, - 0, 0, 214, 215, 0, 0, 0, 0, 0, 0, - 216, 217, 0, 0, 218, 36, 0, 37, 0, 0, - 0, 38, 0, 39, 41, 42, 0, 0, 44, 0, - 0, 0, 46, 0, 47, 0, 0, 0, 0, 0, - 220, 0, 221, 0, 0, 0, 51, 219, 222, 49, - 223, 52, 224, 53, 225, 55, 226, 56, 227, 228, - 0, 0, 43, 54, 32, 210, 212, 0, 40, 0, - 0, 0, 0, 45, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 209, 0, 0, 0, 0, 211, 0, - 29, 30, 31, 213, 0, 0, 0, 0, 0, 0, - 214, 33, 0, 0, 0, 0, 0, 0, 216, 217, - 0, 0, 218, 36, 0, 37, 0, 0, 0, 38, - 0, 39, 41, 42, 0, 0, 44, 0, 0, 0, - 46, 0, 47, 0, 0, 0, 0, 0, 220, 0, - 221, 0, 0, 0, 51, 219, 222, 49, 223, 52, - 224, 53, 225, 55, 226, 56, 227, 228, 0, 0, - 43, 54, 32, 210, 212, 0, 40, 0, 0, 0, - 0, 45, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 586, 110, 111, 0, 0, 588, 115, 590, 30, - 31, 591, 0, 118, 0, 0, 0, 120, 593, 594, - 0, 0, 0, 0, 0, 0, 595, 596, 124, 125, - 218, 36, 0, 37, 0, 0, 0, 38, 0, 39, - 597, 42, 0, 0, 599, 0, 0, 0, 46, 0, - 47, 0, 0, 0, 0, 0, 601, 0, 221, 0, - 0, 0, 603, 600, 602, 49, 604, 605, 606, 53, - 608, 609, 610, 611, 612, 613, 0, 0, 598, 607, - 592, 587, 589, 128, 40, 0, 0, 0, 0, 45, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 361, - 110, 111, 0, 0, 363, 115, 365, 30, 31, 366, - 0, 118, 0, 0, 0, 120, 368, 369, 0, 0, - 0, 0, 0, 0, 370, 371, 124, 125, 218, 36, - 0, 37, 0, 0, 0, 38, 0, 39, 372, 42, - 0, 0, 374, 0, 0, 0, 46, 0, 47, 0, - -268, 0, 0, 0, 376, 0, 221, 0, 0, 0, - 378, 375, 377, 49, 379, 380, 381, 53, 383, 384, - 385, 386, 387, 388, 0, 0, 373, 382, 367, 362, - 364, 128, 40, 0, 0, 0, 0, 45, 0, 0, - 0, 0, 0, 0, 0, 0, 0, - - 534, 311, 497, 309, 532, 461, 498, 499, 516, 515, - 619, 638, 16, 552, 436, 358, 616, 472, 562, 320, - 528, 238, 487, 182, 250, 243, 253, 182, 302, 641, - 627, 632, 150, 485, 143, 454, 439, 402, 445, 559, - 237, 574, 250, 578, 561, 186, 618, 458, 238, 349, - 573, 449, 447, 571, 243, 347, 450, 243, 460, 351, - 238, 353, 358, 410, 415, 439, 176, 188, 436, 250, - 467, 417, 433, 182, 425, 429, 302, 169, 456, 358, - 171, 140, 336, 334, 338, 344, 436, 392, 390, 400, - 163, 302, 307, 148, 146, 339, 439, 404, 302, 358, - 404, 358, 0, 482, 501, 480, 0, 642, 0, 479, - 0, 0, 0, 320, 60, 0, 186, 501, 90, 60, - 60, 489, 302, 60, 617, 93, 0, 88, 0, 405, - 0, 461, 405, 60, 60, 451, 180, 60, 0, 180, - 60, 60, 60, 451, 60, 95, 89, 146, 266, 287, - 60, 146, 407, 270, 60, 288, 178, 60, 106, 452, - 0, 60, 60, 60, 102, 60, 302, 332, 286, 60, - 92, 452, 60, 60, 451, 60, 165, 168, 285, 432, - 284, 435, 60, 60, 108, 501, 329, 94, 540, 96, - 60, 330, 60, 302, 494, 60, 77, 237, 60, 404, - 452, 341, 471, 72, 60, 60, 67, 69, 60, 60, - 68, 0, 70, 60, 60, 60, 61, 180, 60, 60, - 98, 491, 60, 91, 490, 60, 60, 60, 493, 60, - 84, 405, 60, 97, 492, 305, 0, 60, 0, 298, - 0, 100, 270, 298, 270, 298, 106, 298, 270, 0, - 270, 60, 270, 60, 316, 0, 270, 0, 270, 298, - 291, 326, 303, 60, 270, 319, 313, 300, 270, 297, - 60, 60, 108, 175, 295, 270, 270, 290, 60, 501, - 273, 317, 60, 270, 60, 278, 509, 270, 0, 270, - 0, 289, 0, 548, 0, 293, 551, 0, 500, 510, - 501, 501, 0, 544, 501, 0, 0, 0, 509, 0, - 0, 509, 520, 521, 522, 523, 527, 524, 525, 0, - 500, 510, 0, 500, 510, 564, 520, 521, 522, 523, - 527, 524, 525, 581, 0, 0, 0, 0, 0, 0, - 584, 585, 520, 521, 522, 523, 527, 524, 525, 556, - 0, 0, 0, 0, 0, 0, 557, 558, 520, 521, - 522, 523, 527, 524, 525, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 556, 0, 0, 540, 0, 614, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 472, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0}; - -const short QDeclarativeJSGrammar::action_check [] = { - 36, 36, 24, 7, 55, 7, 7, 7, 60, 36, - 8, 7, 37, 7, 7, 33, 55, 55, 60, 36, - 36, 33, 33, 55, 8, 33, 7, 7, 34, 36, - 16, 20, 7, 36, 7, 7, 33, 36, 33, 60, - 7, 7, 7, 5, 7, 5, 5, 90, 33, 36, - 7, 33, 7, 36, 7, 33, 66, 36, 7, 36, - 29, 7, 33, 31, 1, 7, 17, 55, 60, 33, - 60, 2, 8, 7, 48, 66, 1, 7, 36, 2, - 8, 7, 36, 2, 60, 2, 8, 7, 17, 1, - 60, 36, 0, 36, 8, 36, 48, 36, 33, 8, - 61, 1, 6, 36, 60, 8, -1, 8, -1, 15, - 48, 10, 7, 8, 61, 8, 20, -1, -1, -1, - -1, -1, 8, -1, -1, -1, -1, 48, 34, 79, - 40, 79, 8, 77, 61, 8, 60, 8, 8, 79, - 8, 51, -1, 40, 42, 61, 62, 8, 61, 62, - 8, 7, -1, 56, 51, 53, 55, 8, 90, 60, - 50, 79, 8, 56, 54, 61, 62, 61, 62, 61, - 62, 40, 61, 62, 60, 40, 61, 62, 61, 62, - 56, 8, 51, 56, 50, 7, 51, 15, 54, 60, - 60, 25, 60, 27, 25, 56, 27, 61, 62, 61, - 62, 36, 60, 29, 38, 29, 34, 38, 36, 25, - 61, 27, 29, -1, 60, 25, 12, 27, 29, 25, - 29, 27, 38, 25, 29, 27, 61, 62, 38, 12, - 7, 12, 38, 60, 8, 25, 38, 27, -1, 61, - 62, 25, 8, 27, 7, -1, 15, 7, 38, 75, - 25, 75, 27, 8, 38, 25, 33, 27, 75, -1, - 86, 57, 86, 38, 75, 34, 75, 63, 38, 86, - 75, 15, 15, -1, 57, 86, 57, 86, -1, -1, - 63, 86, 63, 61, 62, -1, -1, 61, 62, 15, - 34, 34, 36, 36, -1, 61, 62, 47, 61, 62, - 15, 61, 62, -1, 18, 19, 61, 62, 34, 15, - 36, 61, 62, 91, -1, 92, 18, 19, 33, 34, - 29, 36, 18, 19, 18, 19, 29, 33, 34, 29, - 36, 45, 46, 25, 29, 27, -1, -1, -1, -1, - -1, 91, -1, 45, 46, -1, 38, -1, -1, 45, - 46, 45, 46, -1, -1, -1, -1, 66, 67, 68, - -1, -1, -1, 66, 67, 68, 66, 67, 68, -1, - -1, 66, 67, 68, -1, -1, 23, 24, -1, -1, - -1, 29, -1, 92, -1, 32, 23, 24, 35, 92, - 37, 29, 92, 23, 24, 32, 29, 92, 35, -1, - 37, 29, 32, 23, 24, 35, -1, 37, -1, -1, - 29, -1, 32, 23, 24, 35, -1, 37, 66, 67, - 68, 31, 32, -1, 29, 35, -1, 37, 66, 67, - 68, 36, -1, 66, 67, 68, -1, -1, 66, 67, - 68, -1, -1, -1, 92, -1, -1, 66, 67, 68, - -1, -1, -1, -1, 92, -1, -1, 23, 24, 92, - -1, 66, 67, 68, 92, 31, 32, 23, 24, 35, - -1, 37, -1, 92, -1, 31, 32, 23, 24, 35, - -1, 37, 29, 23, 24, 31, 32, 92, -1, 35, - 29, 37, 32, 29, -1, 35, -1, 37, 94, 95, - 96, 97, 98, 99, 29, -1, -1, -1, -1, -1, - -1, 36, -1, -1, 61, 62, -1, -1, -1, 66, - 67, 68, 61, 62, -1, 61, 62, 66, 67, 68, - 66, 67, 68, -1, -1, -1, -1, -1, -1, -1, - 29, 66, 67, 68, -1, 92, -1, -1, 29, -1, - -1, 29, -1, 92, -1, -1, 92, -1, -1, -1, - -1, -1, 23, 24, -1, -1, -1, 92, -1, -1, - 31, 32, 61, 62, 35, -1, 37, 66, 67, 68, - 61, 62, 3, 61, 62, 66, 67, 68, 66, 67, - 68, -1, 13, -1, -1, -1, 17, -1, -1, -1, - -1, -1, -1, 92, -1, 26, -1, 28, -1, -1, - 31, 92, -1, -1, 92, -1, -1, -1, 39, -1, - 41, 42, -1, -1, -1, -1, -1, -1, 49, -1, - -1, 52, 53, -1, -1, -1, -1, 58, -1, 12, - 13, 3, -1, 64, -1, -1, -1, -1, -1, 22, - -1, 13, -1, -1, -1, 17, 29, -1, -1, 80, - 33, 34, -1, 36, 26, -1, 28, -1, -1, -1, - 43, -1, -1, -1, 47, -1, -1, 39, -1, 41, - 42, -1, -1, -1, -1, -1, -1, 49, -1, -1, - 52, 53, 65, 66, 67, 68, 58, 70, -1, -1, - -1, -1, 64, -1, -1, -1, -1, -1, 81, 82, - 83, -1, 12, 13, 87, -1, -1, -1, 80, 92, - -1, -1, 22, -1, -1, -1, -1, -1, -1, 29, - -1, -1, -1, 33, 34, -1, 36, -1, -1, -1, - 12, 13, -1, 43, -1, -1, -1, 47, -1, -1, - 22, -1, -1, -1, -1, -1, -1, 29, -1, -1, - -1, 33, 34, -1, 36, 65, 66, 67, 68, -1, - 70, 43, -1, -1, -1, 47, -1, -1, -1, -1, - -1, 81, 82, 83, -1, -1, -1, 87, -1, -1, - -1, -1, 92, 65, 66, 67, 68, -1, 70, -1, - -1, -1, 12, 13, -1, -1, -1, -1, -1, 81, - 82, 83, 22, -1, -1, 87, -1, -1, -1, 29, - 92, -1, -1, 33, 34, -1, 36, -1, -1, -1, - 12, 13, -1, 43, -1, -1, -1, 47, -1, -1, - 22, -1, -1, -1, -1, -1, -1, 29, -1, -1, - -1, 33, 34, -1, 36, 65, 66, 67, 68, -1, - 70, 43, -1, -1, -1, 47, -1, -1, -1, -1, - -1, 81, 82, 83, -1, -1, -1, 87, -1, -1, - -1, -1, 92, 65, 66, 67, 68, -1, 70, -1, - -1, -1, 12, 13, -1, -1, -1, -1, -1, 81, - 82, 83, 22, -1, -1, 87, -1, -1, -1, 29, - 92, -1, -1, 33, 34, -1, 36, -1, -1, -1, - 12, 13, -1, 43, -1, -1, -1, 47, -1, -1, - 22, -1, -1, -1, -1, -1, -1, 29, -1, -1, - -1, 33, 34, -1, 36, 65, 66, 67, 68, -1, - 70, 43, -1, -1, -1, 47, -1, -1, -1, -1, - -1, 81, 82, 83, -1, -1, -1, 87, -1, -1, - -1, -1, 92, 65, 66, 67, 68, -1, 70, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, 81, - 82, 83, -1, -1, -1, 87, -1, -1, -1, -1, - 92, -1, -1, -1, -1, -1, -1, -1, -1, -1, - 10, -1, 12, 13, -1, -1, -1, -1, -1, -1, - -1, -1, 22, -1, -1, -1, -1, -1, -1, 29, - -1, -1, -1, 33, 34, -1, 36, -1, -1, -1, - -1, -1, -1, 43, -1, -1, -1, 47, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, 65, 66, 67, 68, -1, - 70, -1, -1, -1, -1, 75, -1, -1, -1, -1, - -1, 81, 82, 83, 84, -1, -1, 87, -1, -1, - -1, -1, 92, -1, -1, -1, -1, -1, -1, -1, - -1, -1, 10, -1, 12, 13, -1, -1, -1, -1, - -1, -1, -1, -1, 22, -1, -1, -1, -1, -1, - -1, 29, -1, -1, -1, 33, 34, -1, 36, -1, - -1, -1, -1, -1, -1, 43, -1, -1, -1, 47, - -1, -1, -1, -1, -1, -1, -1, 55, -1, -1, - -1, -1, -1, -1, -1, -1, -1, 65, 66, 67, - 68, -1, 70, -1, -1, -1, -1, 75, -1, -1, - -1, -1, -1, 81, 82, 83, 84, -1, -1, 87, - -1, -1, -1, -1, 92, -1, -1, -1, -1, -1, - -1, -1, -1, -1, 10, -1, 12, 13, -1, -1, - -1, -1, -1, -1, -1, -1, 22, -1, -1, -1, - -1, -1, -1, 29, -1, -1, -1, 33, 34, -1, - 36, -1, -1, -1, -1, -1, -1, 43, -1, -1, - -1, 47, -1, -1, -1, -1, -1, -1, -1, 55, - -1, -1, -1, -1, -1, -1, -1, -1, -1, 65, - 66, 67, 68, -1, 70, -1, -1, -1, -1, 75, - -1, -1, -1, -1, -1, 81, 82, 83, 84, -1, - -1, 87, -1, -1, -1, -1, 92, -1, -1, -1, - -1, -1, -1, -1, -1, -1, 11, 12, 13, -1, - -1, -1, -1, -1, -1, -1, -1, 22, -1, -1, - -1, -1, -1, -1, 29, -1, -1, -1, 33, 34, - -1, 36, -1, -1, -1, 40, -1, 42, 43, 44, - -1, -1, 47, -1, -1, -1, 51, -1, 53, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - 65, 66, 67, 68, -1, 70, -1, 72, -1, 74, - -1, 76, -1, -1, -1, -1, 81, 82, 83, -1, - -1, -1, 87, -1, -1, -1, -1, 92, -1, -1, - -1, -1, -1, -1, -1, -1, -1, 7, -1, -1, - -1, 11, 12, 13, -1, -1, -1, -1, -1, -1, - -1, -1, 22, -1, -1, -1, -1, -1, -1, 29, - -1, -1, -1, 33, 34, -1, 36, -1, -1, -1, - 40, -1, 42, 43, 44, -1, -1, 47, -1, -1, - -1, 51, -1, 53, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, 65, 66, 67, 68, -1, - 70, -1, 72, -1, 74, -1, 76, -1, -1, -1, - -1, 81, 82, 83, -1, -1, -1, 87, -1, -1, - -1, -1, 92, -1, -1, -1, -1, -1, -1, -1, - -1, -1, 11, 12, 13, -1, -1, -1, -1, -1, - -1, -1, -1, 22, -1, -1, -1, -1, -1, -1, - 29, -1, -1, -1, 33, 34, -1, 36, -1, -1, - -1, 40, -1, 42, 43, 44, -1, -1, 47, -1, - -1, -1, 51, -1, 53, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, 65, 66, 67, 68, - -1, 70, -1, 72, -1, 74, 75, 76, -1, -1, - -1, -1, 81, 82, 83, -1, -1, -1, 87, -1, - -1, -1, -1, 92, -1, -1, -1, -1, -1, -1, - -1, -1, -1, 8, -1, -1, 11, 12, 13, -1, - -1, -1, -1, -1, -1, -1, -1, 22, -1, -1, - -1, -1, -1, -1, 29, -1, -1, -1, 33, 34, - -1, 36, -1, -1, -1, 40, -1, 42, 43, 44, - -1, -1, 47, -1, -1, -1, 51, -1, 53, -1, - -1, 56, -1, -1, -1, -1, -1, -1, -1, -1, - 65, 66, 67, 68, -1, 70, -1, 72, -1, 74, - -1, 76, -1, -1, -1, -1, 81, 82, 83, -1, - -1, -1, 87, -1, -1, -1, -1, 92, -1, -1, - -1, -1, -1, -1, -1, -1, -1, 8, -1, -1, - 11, 12, 13, -1, -1, -1, -1, -1, -1, -1, - -1, 22, -1, -1, -1, -1, -1, -1, 29, -1, - -1, -1, 33, 34, -1, 36, -1, -1, -1, 40, - -1, 42, 43, 44, -1, -1, 47, -1, -1, -1, - 51, -1, 53, -1, -1, 56, -1, -1, -1, -1, - -1, -1, -1, -1, 65, 66, 67, 68, -1, 70, - -1, 72, -1, 74, -1, 76, -1, -1, -1, -1, - 81, 82, 83, -1, -1, -1, 87, -1, -1, -1, - -1, 92, -1, -1, -1, -1, -1, -1, -1, -1, - -1, 8, -1, -1, 11, 12, 13, -1, -1, -1, - -1, -1, -1, -1, -1, 22, -1, -1, -1, -1, - -1, -1, 29, -1, -1, -1, 33, 34, -1, 36, - -1, -1, -1, 40, -1, 42, 43, 44, -1, -1, - 47, -1, -1, -1, 51, -1, 53, -1, -1, 56, - -1, -1, -1, -1, -1, -1, -1, -1, 65, 66, - 67, 68, -1, 70, -1, 72, -1, 74, -1, 76, - -1, -1, -1, -1, 81, 82, 83, -1, -1, -1, - 87, -1, -1, -1, -1, 92, -1, -1, -1, -1, - -1, -1, -1, -1, -1, 8, -1, -1, 11, 12, - 13, -1, -1, -1, -1, -1, -1, -1, -1, 22, - -1, -1, -1, -1, -1, -1, 29, -1, -1, -1, - 33, 34, -1, 36, -1, -1, -1, 40, -1, 42, - 43, 44, -1, -1, 47, -1, -1, -1, 51, -1, - 53, -1, -1, 56, -1, -1, -1, -1, -1, -1, - -1, -1, 65, 66, 67, 68, -1, 70, -1, 72, - -1, 74, -1, 76, -1, -1, -1, -1, 81, 82, - 83, -1, -1, -1, 87, -1, -1, -1, -1, 92, - -1, -1, -1, -1, -1, -1, -1, -1, -1, 11, - 12, 13, -1, -1, -1, -1, -1, -1, -1, -1, - 22, -1, -1, -1, -1, -1, -1, 29, 30, -1, - -1, 33, 34, -1, 36, -1, -1, -1, 40, -1, - 42, 43, 44, -1, -1, 47, -1, -1, -1, 51, - -1, 53, -1, -1, -1, -1, -1, -1, -1, 61, - -1, -1, -1, 65, 66, 67, 68, 69, 70, -1, - 72, 73, 74, -1, 76, -1, 78, -1, -1, 81, - 82, 83, -1, -1, -1, 87, -1, -1, -1, -1, - 92, -1, -1, -1, -1, -1, -1, -1, -1, -1, - 11, 12, 13, -1, -1, -1, -1, -1, -1, -1, - -1, 22, -1, -1, -1, -1, -1, -1, 29, 30, - -1, -1, 33, 34, -1, 36, -1, -1, -1, 40, - -1, 42, 43, 44, -1, -1, 47, -1, -1, -1, - 51, -1, 53, -1, -1, -1, -1, -1, -1, -1, - 61, -1, -1, -1, 65, 66, 67, 68, 69, 70, - -1, 72, 73, 74, -1, 76, -1, 78, -1, -1, - 81, 82, 83, -1, -1, -1, 87, -1, -1, -1, - -1, 92, -1, -1, -1, -1, -1, -1, -1, -1, - -1, 4, 5, 6, -1, -1, 9, 10, 11, -1, - -1, 14, -1, 16, -1, -1, -1, 20, 21, 22, - -1, -1, -1, -1, -1, -1, 29, 30, 31, 32, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - 43, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, 59, -1, -1, -1, - -1, -1, -1, 66, 67, 68, 69, 70, 71, -1, - 73, 74, 75, 76, 77, 78, -1, -1, 81, 82, - 83, 84, 85, 86, -1, -1, -1, -1, -1, 92, - -1, -1, -1, -1, -1, -1, -1, -1, -1, 4, - 5, 6, -1, -1, 9, 10, 11, -1, -1, 14, - -1, 16, -1, -1, -1, 20, 21, 22, -1, -1, - -1, -1, -1, -1, 29, 30, 31, 32, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, 43, -1, - -1, -1, 47, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, 59, -1, -1, -1, -1, -1, - 65, 66, 67, -1, 69, 70, 71, -1, 73, 74, - 75, 76, 77, 78, -1, -1, 81, 82, 83, 84, - 85, 86, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, 4, 5, 6, - -1, -1, 9, 10, 11, -1, -1, 14, -1, 16, - -1, -1, -1, 20, 21, 22, -1, -1, -1, -1, - -1, -1, 29, 30, 31, 32, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, 43, -1, -1, -1, - 47, -1, -1, -1, -1, -1, -1, -1, 55, -1, - -1, -1, 59, -1, -1, -1, -1, -1, 65, 66, - 67, -1, 69, 70, 71, -1, 73, 74, 75, 76, - 77, 78, -1, -1, 81, 82, 83, 84, 85, 86, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, 4, -1, -1, -1, -1, - 9, -1, 11, 12, 13, 14, -1, -1, -1, -1, - -1, -1, 21, 22, -1, -1, -1, -1, -1, -1, - 29, 30, -1, -1, 33, 34, -1, 36, -1, -1, - -1, 40, -1, 42, 43, 44, -1, -1, 47, -1, - -1, -1, 51, -1, 53, -1, -1, -1, -1, -1, - 59, -1, 61, -1, -1, -1, 65, 66, 67, 68, - 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, - -1, -1, 81, 82, 83, 84, 85, -1, 87, -1, - -1, -1, -1, 92, -1, -1, -1, -1, -1, -1, - -1, -1, -1, 4, -1, -1, -1, -1, 9, -1, - 11, 12, 13, 14, -1, -1, -1, -1, -1, -1, - 21, 22, -1, -1, -1, -1, -1, -1, 29, 30, - -1, -1, 33, 34, -1, 36, -1, -1, -1, 40, - -1, 42, 43, 44, -1, -1, 47, -1, -1, -1, - 51, -1, 53, -1, -1, -1, -1, -1, 59, -1, - 61, -1, -1, -1, 65, 66, 67, 68, 69, 70, - 71, 72, 73, 74, 75, 76, 77, 78, -1, -1, - 81, 82, 83, 84, 85, -1, 87, -1, -1, -1, - -1, 92, -1, -1, -1, -1, -1, -1, -1, -1, - -1, 4, 5, 6, -1, -1, 9, 10, 11, 12, - 13, 14, -1, 16, -1, -1, -1, 20, 21, 22, - -1, -1, -1, -1, -1, -1, 29, 30, 31, 32, - 33, 34, -1, 36, -1, -1, -1, 40, -1, 42, - 43, 44, -1, -1, 47, -1, -1, -1, 51, -1, - 53, -1, -1, -1, -1, -1, 59, -1, 61, -1, - -1, -1, 65, 66, 67, 68, 69, 70, 71, 72, - 73, 74, 75, 76, 77, 78, -1, -1, 81, 82, - 83, 84, 85, 86, 87, -1, -1, -1, -1, 92, - -1, -1, -1, -1, -1, -1, -1, -1, -1, 4, - 5, 6, -1, -1, 9, 10, 11, 12, 13, 14, - -1, 16, -1, -1, -1, 20, 21, 22, -1, -1, - -1, -1, -1, -1, 29, 30, 31, 32, 33, 34, - -1, 36, -1, -1, -1, 40, -1, 42, 43, 44, - -1, -1, 47, -1, -1, -1, 51, -1, 53, -1, - 55, -1, -1, -1, 59, -1, 61, -1, -1, -1, - 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, - 75, 76, 77, 78, -1, -1, 81, 82, 83, 84, - 85, 86, 87, -1, -1, -1, -1, 92, -1, -1, - -1, -1, -1, -1, -1, -1, -1, - - 15, 2, 105, 3, 29, 15, 4, 2, 15, 29, - 9, 15, 3, 15, 3, 2, 19, 39, 15, 15, - 13, 15, 3, 15, 2, 15, 3, 15, 3, 11, - 13, 15, 71, 39, 39, 3, 22, 2, 99, 19, - 4, 15, 2, 15, 29, 15, 19, 3, 15, 3, - 29, 22, 15, 29, 15, 2, 22, 15, 2, 2, - 15, 2, 2, 2, 2, 22, 3, 15, 3, 2, - 39, 3, 3, 15, 97, 94, 3, 39, 2, 2, - 39, 3, 3, 2, 2, 101, 3, 40, 39, 39, - 39, 3, 2, 39, 39, 15, 22, 13, 3, 2, - 13, 2, -1, 39, 13, 35, -1, 16, -1, 39, - -1, -1, -1, 15, 48, -1, 15, 13, 52, 48, - 48, 50, 3, 48, 20, 53, -1, 52, -1, 45, - -1, 15, 45, 48, 48, 50, 50, 48, -1, 50, - 48, 48, 48, 50, 48, 53, 52, 39, 48, 53, - 48, 39, 44, 53, 48, 53, 44, 48, 15, 50, - -1, 48, 48, 48, 58, 48, 3, 72, 53, 48, - 53, 50, 48, 48, 50, 48, 62, 64, 53, 82, - 53, 82, 48, 48, 41, 13, 88, 53, 16, 54, - 48, 72, 48, 3, 50, 48, 54, 4, 48, 13, - 50, 100, 86, 56, 48, 48, 50, 50, 48, 48, - 50, -1, 51, 48, 48, 48, 51, 50, 48, 48, - 54, 50, 48, 53, 50, 48, 48, 48, 50, 48, - 53, 45, 48, 54, 50, 72, -1, 48, -1, 48, - -1, 60, 53, 48, 53, 48, 15, 48, 53, -1, - 53, 48, 53, 48, 65, -1, 53, -1, 53, 48, - 55, 70, 72, 48, 53, 70, 63, 70, 53, 70, - 48, 48, 41, 42, 59, 53, 53, 55, 48, 13, - 57, 70, 48, 53, 48, 55, 20, 53, -1, 53, - -1, 55, -1, 5, -1, 61, 5, -1, 32, 33, - 13, 13, -1, 16, 13, -1, -1, -1, 20, -1, - -1, 20, 22, 23, 24, 25, 26, 27, 28, -1, - 32, 33, -1, 32, 33, 21, 22, 23, 24, 25, - 26, 27, 28, 13, -1, -1, -1, -1, -1, -1, - 20, 21, 22, 23, 24, 25, 26, 27, 28, 13, - -1, -1, -1, -1, -1, -1, 20, 21, 22, 23, - 24, 25, 26, 27, 28, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, 13, -1, -1, 16, -1, 18, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - 39, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1}; - -QT_END_NAMESPACE diff --git a/src/declarative/qml/parser/qdeclarativejsgrammar_p.h b/src/declarative/qml/parser/qdeclarativejsgrammar_p.h deleted file mode 100644 index 5503ff763f..0000000000 --- a/src/declarative/qml/parser/qdeclarativejsgrammar_p.h +++ /dev/null @@ -1,211 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtCore module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists for the convenience -// of other Qt classes. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - -// This file was generated by qlalr - DO NOT EDIT! -#ifndef QDECLARATIVEJSGRAMMAR_P_H -#define QDECLARATIVEJSGRAMMAR_P_H - -#include - -QT_BEGIN_NAMESPACE - -class QDeclarativeJSGrammar -{ -public: - enum VariousConstants { - EOF_SYMBOL = 0, - REDUCE_HERE = 101, - SHIFT_THERE = 100, - T_AND = 1, - T_AND_AND = 2, - T_AND_EQ = 3, - T_AS = 91, - T_AUTOMATIC_SEMICOLON = 62, - T_BREAK = 4, - T_CASE = 5, - T_CATCH = 6, - T_COLON = 7, - T_COMMA = 8, - T_COMMENT = 88, - T_CONST = 84, - T_CONTINUE = 9, - T_DEBUGGER = 85, - T_DEFAULT = 10, - T_DELETE = 11, - T_DIVIDE_ = 12, - T_DIVIDE_EQ = 13, - T_DO = 14, - T_DOT = 15, - T_ELSE = 16, - T_EQ = 17, - T_EQ_EQ = 18, - T_EQ_EQ_EQ = 19, - T_ERROR = 93, - T_FALSE = 83, - T_FEED_JS_EXPRESSION = 97, - T_FEED_JS_PROGRAM = 99, - T_FEED_JS_SOURCE_ELEMENT = 98, - T_FEED_JS_STATEMENT = 96, - T_FEED_UI_OBJECT_MEMBER = 95, - T_FEED_UI_PROGRAM = 94, - T_FINALLY = 20, - T_FOR = 21, - T_FUNCTION = 22, - T_GE = 23, - T_GT = 24, - T_GT_GT = 25, - T_GT_GT_EQ = 26, - T_GT_GT_GT = 27, - T_GT_GT_GT_EQ = 28, - T_IDENTIFIER = 29, - T_IF = 30, - T_IMPORT = 90, - T_IN = 31, - T_INSTANCEOF = 32, - T_LBRACE = 33, - T_LBRACKET = 34, - T_LE = 35, - T_LPAREN = 36, - T_LT = 37, - T_LT_LT = 38, - T_LT_LT_EQ = 39, - T_MINUS = 40, - T_MINUS_EQ = 41, - T_MINUS_MINUS = 42, - T_MULTILINE_STRING_LITERAL = 87, - T_NEW = 43, - T_NOT = 44, - T_NOT_EQ = 45, - T_NOT_EQ_EQ = 46, - T_NULL = 81, - T_NUMERIC_LITERAL = 47, - T_ON = 92, - T_OR = 48, - T_OR_EQ = 49, - T_OR_OR = 50, - T_PLUS = 51, - T_PLUS_EQ = 52, - T_PLUS_PLUS = 53, - T_PROPERTY = 66, - T_PUBLIC = 89, - T_QUESTION = 54, - T_RBRACE = 55, - T_RBRACKET = 56, - T_READONLY = 68, - T_REMAINDER = 57, - T_REMAINDER_EQ = 58, - T_RESERVED_WORD = 86, - T_RETURN = 59, - T_RPAREN = 60, - T_SEMICOLON = 61, - T_SIGNAL = 67, - T_STAR = 63, - T_STAR_EQ = 64, - T_STRING_LITERAL = 65, - T_SWITCH = 69, - T_THIS = 70, - T_THROW = 71, - T_TILDE = 72, - T_TRUE = 82, - T_TRY = 73, - T_TYPEOF = 74, - T_VAR = 75, - T_VOID = 76, - T_WHILE = 77, - T_WITH = 78, - T_XOR = 79, - T_XOR_EQ = 80, - - ACCEPT_STATE = 644, - RULE_COUNT = 349, - STATE_COUNT = 645, - TERMINAL_COUNT = 102, - NON_TERMINAL_COUNT = 107, - - GOTO_INDEX_OFFSET = 645, - GOTO_INFO_OFFSET = 2807, - GOTO_CHECK_OFFSET = 2807 - }; - - static const char *const spell []; - static const short lhs []; - static const short rhs []; - static const short goto_default []; - static const short action_default []; - static const short action_index []; - static const short action_info []; - static const short action_check []; - - static inline int nt_action (int state, int nt) - { - const int yyn = action_index [GOTO_INDEX_OFFSET + state] + nt; - if (yyn < 0 || action_check [GOTO_CHECK_OFFSET + yyn] != nt) - return goto_default [nt]; - - return action_info [GOTO_INFO_OFFSET + yyn]; - } - - static inline int t_action (int state, int token) - { - const int yyn = action_index [state] + token; - - if (yyn < 0 || action_check [yyn] != token) - return - action_default [state]; - - return action_info [yyn]; - } -}; - - -QT_END_NAMESPACE -#endif // QDECLARATIVEJSGRAMMAR_P_H - diff --git a/src/declarative/qml/parser/qdeclarativejskeywords_p.h b/src/declarative/qml/parser/qdeclarativejskeywords_p.h deleted file mode 100644 index fac5b7b5f6..0000000000 --- a/src/declarative/qml/parser/qdeclarativejskeywords_p.h +++ /dev/null @@ -1,860 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QDECLARATIVEJSKEYWORDS_P_H -#define QDECLARATIVEJSKEYWORDS_P_H - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists purely as an -// implementation detail. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - -static inline int classify2(const QChar *s, bool qmlMode) { - if (s[0].unicode() == 'a') { - if (s[1].unicode() == 's') { - return qmlMode ? Lexer::T_AS : Lexer::T_RESERVED_WORD; - } - } - else if (s[0].unicode() == 'd') { - if (s[1].unicode() == 'o') { - return Lexer::T_DO; - } - } - else if (s[0].unicode() == 'i') { - if (s[1].unicode() == 'f') { - return Lexer::T_IF; - } - else if (s[1].unicode() == 'n') { - return Lexer::T_IN; - } - } - else if (qmlMode && s[0].unicode() == 'o') { - if (s[1].unicode() == 'n') { - return Lexer::T_ON; - } - } - return Lexer::T_IDENTIFIER; -} - -static inline int classify3(const QChar *s, bool /*qmlMode*/) { - if (s[0].unicode() == 'f') { - if (s[1].unicode() == 'o') { - if (s[2].unicode() == 'r') { - return Lexer::T_FOR; - } - } - } - else if (s[0].unicode() == 'i') { - if (s[1].unicode() == 'n') { - if (s[2].unicode() == 't') { - return Lexer::T_INT; - } - } - } - else if (s[0].unicode() == 'n') { - if (s[1].unicode() == 'e') { - if (s[2].unicode() == 'w') { - return Lexer::T_NEW; - } - } - } - else if (s[0].unicode() == 't') { - if (s[1].unicode() == 'r') { - if (s[2].unicode() == 'y') { - return Lexer::T_TRY; - } - } - } - else if (s[0].unicode() == 'v') { - if (s[1].unicode() == 'a') { - if (s[2].unicode() == 'r') { - return Lexer::T_VAR; - } - } - } - return Lexer::T_IDENTIFIER; -} - -static inline int classify4(const QChar *s, bool /*qmlMode*/) { - if (s[0].unicode() == 'b') { - if (s[1].unicode() == 'y') { - if (s[2].unicode() == 't') { - if (s[3].unicode() == 'e') { - return Lexer::T_BYTE; - } - } - } - } - else if (s[0].unicode() == 'c') { - if (s[1].unicode() == 'a') { - if (s[2].unicode() == 's') { - if (s[3].unicode() == 'e') { - return Lexer::T_CASE; - } - } - } - else if (s[1].unicode() == 'h') { - if (s[2].unicode() == 'a') { - if (s[3].unicode() == 'r') { - return Lexer::T_CHAR; - } - } - } - } - else if (s[0].unicode() == 'e') { - if (s[1].unicode() == 'l') { - if (s[2].unicode() == 's') { - if (s[3].unicode() == 'e') { - return Lexer::T_ELSE; - } - } - } - else if (s[1].unicode() == 'n') { - if (s[2].unicode() == 'u') { - if (s[3].unicode() == 'm') { - return Lexer::T_ENUM; - } - } - } - } - else if (s[0].unicode() == 'g') { - if (s[1].unicode() == 'o') { - if (s[2].unicode() == 't') { - if (s[3].unicode() == 'o') { - return Lexer::T_GOTO; - } - } - } - } - else if (s[0].unicode() == 'l') { - if (s[1].unicode() == 'o') { - if (s[2].unicode() == 'n') { - if (s[3].unicode() == 'g') { - return Lexer::T_LONG; - } - } - } - } - else if (s[0].unicode() == 'n') { - if (s[1].unicode() == 'u') { - if (s[2].unicode() == 'l') { - if (s[3].unicode() == 'l') { - return Lexer::T_NULL; - } - } - } - } - else if (s[0].unicode() == 't') { - if (s[1].unicode() == 'h') { - if (s[2].unicode() == 'i') { - if (s[3].unicode() == 's') { - return Lexer::T_THIS; - } - } - } - else if (s[1].unicode() == 'r') { - if (s[2].unicode() == 'u') { - if (s[3].unicode() == 'e') { - return Lexer::T_TRUE; - } - } - } - } - else if (s[0].unicode() == 'v') { - if (s[1].unicode() == 'o') { - if (s[2].unicode() == 'i') { - if (s[3].unicode() == 'd') { - return Lexer::T_VOID; - } - } - } - } - else if (s[0].unicode() == 'w') { - if (s[1].unicode() == 'i') { - if (s[2].unicode() == 't') { - if (s[3].unicode() == 'h') { - return Lexer::T_WITH; - } - } - } - } - return Lexer::T_IDENTIFIER; -} - -static inline int classify5(const QChar *s, bool /*qmlMode*/) { - if (s[0].unicode() == 'b') { - if (s[1].unicode() == 'r') { - if (s[2].unicode() == 'e') { - if (s[3].unicode() == 'a') { - if (s[4].unicode() == 'k') { - return Lexer::T_BREAK; - } - } - } - } - } - else if (s[0].unicode() == 'c') { - if (s[1].unicode() == 'a') { - if (s[2].unicode() == 't') { - if (s[3].unicode() == 'c') { - if (s[4].unicode() == 'h') { - return Lexer::T_CATCH; - } - } - } - } - else if (s[1].unicode() == 'l') { - if (s[2].unicode() == 'a') { - if (s[3].unicode() == 's') { - if (s[4].unicode() == 's') { - return Lexer::T_CLASS; - } - } - } - } - else if (s[1].unicode() == 'o') { - if (s[2].unicode() == 'n') { - if (s[3].unicode() == 's') { - if (s[4].unicode() == 't') { - return Lexer::T_CONST; - } - } - } - } - } - else if (s[0].unicode() == 'f') { - if (s[1].unicode() == 'a') { - if (s[2].unicode() == 'l') { - if (s[3].unicode() == 's') { - if (s[4].unicode() == 'e') { - return Lexer::T_FALSE; - } - } - } - } - else if (s[1].unicode() == 'i') { - if (s[2].unicode() == 'n') { - if (s[3].unicode() == 'a') { - if (s[4].unicode() == 'l') { - return Lexer::T_FINAL; - } - } - } - } - else if (s[1].unicode() == 'l') { - if (s[2].unicode() == 'o') { - if (s[3].unicode() == 'a') { - if (s[4].unicode() == 't') { - return Lexer::T_FLOAT; - } - } - } - } - } - else if (s[0].unicode() == 's') { - if (s[1].unicode() == 'h') { - if (s[2].unicode() == 'o') { - if (s[3].unicode() == 'r') { - if (s[4].unicode() == 't') { - return Lexer::T_SHORT; - } - } - } - } - else if (s[1].unicode() == 'u') { - if (s[2].unicode() == 'p') { - if (s[3].unicode() == 'e') { - if (s[4].unicode() == 'r') { - return Lexer::T_SUPER; - } - } - } - } - } - else if (s[0].unicode() == 't') { - if (s[1].unicode() == 'h') { - if (s[2].unicode() == 'r') { - if (s[3].unicode() == 'o') { - if (s[4].unicode() == 'w') { - return Lexer::T_THROW; - } - } - } - } - } - else if (s[0].unicode() == 'w') { - if (s[1].unicode() == 'h') { - if (s[2].unicode() == 'i') { - if (s[3].unicode() == 'l') { - if (s[4].unicode() == 'e') { - return Lexer::T_WHILE; - } - } - } - } - } - return Lexer::T_IDENTIFIER; -} - -static inline int classify6(const QChar *s, bool qmlMode) { - if (s[0].unicode() == 'd') { - if (s[1].unicode() == 'e') { - if (s[2].unicode() == 'l') { - if (s[3].unicode() == 'e') { - if (s[4].unicode() == 't') { - if (s[5].unicode() == 'e') { - return Lexer::T_DELETE; - } - } - } - } - } - else if (s[1].unicode() == 'o') { - if (s[2].unicode() == 'u') { - if (s[3].unicode() == 'b') { - if (s[4].unicode() == 'l') { - if (s[5].unicode() == 'e') { - return Lexer::T_DOUBLE; - } - } - } - } - } - } - else if (s[0].unicode() == 'e') { - if (s[1].unicode() == 'x') { - if (s[2].unicode() == 'p') { - if (s[3].unicode() == 'o') { - if (s[4].unicode() == 'r') { - if (s[5].unicode() == 't') { - return Lexer::T_EXPORT; - } - } - } - } - } - } - else if (s[0].unicode() == 'i') { - if (s[1].unicode() == 'm') { - if (s[2].unicode() == 'p') { - if (s[3].unicode() == 'o') { - if (s[4].unicode() == 'r') { - if (s[5].unicode() == 't') { - return qmlMode ? Lexer::T_IMPORT : Lexer::T_RESERVED_WORD; - } - } - } - } - } - } - else if (s[0].unicode() == 'n') { - if (s[1].unicode() == 'a') { - if (s[2].unicode() == 't') { - if (s[3].unicode() == 'i') { - if (s[4].unicode() == 'v') { - if (s[5].unicode() == 'e') { - return Lexer::T_NATIVE; - } - } - } - } - } - } - else if (s[0].unicode() == 'p') { - if (s[1].unicode() == 'u') { - if (s[2].unicode() == 'b') { - if (s[3].unicode() == 'l') { - if (s[4].unicode() == 'i') { - if (s[5].unicode() == 'c') { - return qmlMode ? Lexer::T_PUBLIC : Lexer::T_RESERVED_WORD; - } - } - } - } - } - } - else if (s[0].unicode() == 'r') { - if (s[1].unicode() == 'e') { - if (s[2].unicode() == 't') { - if (s[3].unicode() == 'u') { - if (s[4].unicode() == 'r') { - if (s[5].unicode() == 'n') { - return Lexer::T_RETURN; - } - } - } - } - } - } - else if (s[0].unicode() == 's') { - if (qmlMode && s[1].unicode() == 'i') { - if (s[2].unicode() == 'g') { - if (s[3].unicode() == 'n') { - if (s[4].unicode() == 'a') { - if (s[5].unicode() == 'l') { - return Lexer::T_SIGNAL; - } - } - } - } - } - else if (s[1].unicode() == 't') { - if (s[2].unicode() == 'a') { - if (s[3].unicode() == 't') { - if (s[4].unicode() == 'i') { - if (s[5].unicode() == 'c') { - return Lexer::T_STATIC; - } - } - } - } - } - else if (s[1].unicode() == 'w') { - if (s[2].unicode() == 'i') { - if (s[3].unicode() == 't') { - if (s[4].unicode() == 'c') { - if (s[5].unicode() == 'h') { - return Lexer::T_SWITCH; - } - } - } - } - } - } - else if (s[0].unicode() == 't') { - if (s[1].unicode() == 'h') { - if (s[2].unicode() == 'r') { - if (s[3].unicode() == 'o') { - if (s[4].unicode() == 'w') { - if (s[5].unicode() == 's') { - return Lexer::T_THROWS; - } - } - } - } - } - else if (s[1].unicode() == 'y') { - if (s[2].unicode() == 'p') { - if (s[3].unicode() == 'e') { - if (s[4].unicode() == 'o') { - if (s[5].unicode() == 'f') { - return Lexer::T_TYPEOF; - } - } - } - } - } - } - return Lexer::T_IDENTIFIER; -} - -static inline int classify7(const QChar *s, bool /*qmlMode*/) { - if (s[0].unicode() == 'b') { - if (s[1].unicode() == 'o') { - if (s[2].unicode() == 'o') { - if (s[3].unicode() == 'l') { - if (s[4].unicode() == 'e') { - if (s[5].unicode() == 'a') { - if (s[6].unicode() == 'n') { - return Lexer::T_BOOLEAN; - } - } - } - } - } - } - } - else if (s[0].unicode() == 'd') { - if (s[1].unicode() == 'e') { - if (s[2].unicode() == 'f') { - if (s[3].unicode() == 'a') { - if (s[4].unicode() == 'u') { - if (s[5].unicode() == 'l') { - if (s[6].unicode() == 't') { - return Lexer::T_DEFAULT; - } - } - } - } - } - } - } - else if (s[0].unicode() == 'e') { - if (s[1].unicode() == 'x') { - if (s[2].unicode() == 't') { - if (s[3].unicode() == 'e') { - if (s[4].unicode() == 'n') { - if (s[5].unicode() == 'd') { - if (s[6].unicode() == 's') { - return Lexer::T_EXTENDS; - } - } - } - } - } - } - } - else if (s[0].unicode() == 'f') { - if (s[1].unicode() == 'i') { - if (s[2].unicode() == 'n') { - if (s[3].unicode() == 'a') { - if (s[4].unicode() == 'l') { - if (s[5].unicode() == 'l') { - if (s[6].unicode() == 'y') { - return Lexer::T_FINALLY; - } - } - } - } - } - } - } - else if (s[0].unicode() == 'p') { - if (s[1].unicode() == 'a') { - if (s[2].unicode() == 'c') { - if (s[3].unicode() == 'k') { - if (s[4].unicode() == 'a') { - if (s[5].unicode() == 'g') { - if (s[6].unicode() == 'e') { - return Lexer::T_PACKAGE; - } - } - } - } - } - } - else if (s[1].unicode() == 'r') { - if (s[2].unicode() == 'i') { - if (s[3].unicode() == 'v') { - if (s[4].unicode() == 'a') { - if (s[5].unicode() == 't') { - if (s[6].unicode() == 'e') { - return Lexer::T_PRIVATE; - } - } - } - } - } - } - } - return Lexer::T_IDENTIFIER; -} - -static inline int classify8(const QChar *s, bool qmlMode) { - if (s[0].unicode() == 'a') { - if (s[1].unicode() == 'b') { - if (s[2].unicode() == 's') { - if (s[3].unicode() == 't') { - if (s[4].unicode() == 'r') { - if (s[5].unicode() == 'a') { - if (s[6].unicode() == 'c') { - if (s[7].unicode() == 't') { - return Lexer::T_ABSTRACT; - } - } - } - } - } - } - } - } - else if (s[0].unicode() == 'c') { - if (s[1].unicode() == 'o') { - if (s[2].unicode() == 'n') { - if (s[3].unicode() == 't') { - if (s[4].unicode() == 'i') { - if (s[5].unicode() == 'n') { - if (s[6].unicode() == 'u') { - if (s[7].unicode() == 'e') { - return Lexer::T_CONTINUE; - } - } - } - } - } - } - } - } - else if (s[0].unicode() == 'd') { - if (s[1].unicode() == 'e') { - if (s[2].unicode() == 'b') { - if (s[3].unicode() == 'u') { - if (s[4].unicode() == 'g') { - if (s[5].unicode() == 'g') { - if (s[6].unicode() == 'e') { - if (s[7].unicode() == 'r') { - return Lexer::T_DEBUGGER; - } - } - } - } - } - } - } - } - else if (s[0].unicode() == 'f') { - if (s[1].unicode() == 'u') { - if (s[2].unicode() == 'n') { - if (s[3].unicode() == 'c') { - if (s[4].unicode() == 't') { - if (s[5].unicode() == 'i') { - if (s[6].unicode() == 'o') { - if (s[7].unicode() == 'n') { - return Lexer::T_FUNCTION; - } - } - } - } - } - } - } - } - else if (qmlMode && s[0].unicode() == 'p') { - if (s[1].unicode() == 'r') { - if (s[2].unicode() == 'o') { - if (s[3].unicode() == 'p') { - if (s[4].unicode() == 'e') { - if (s[5].unicode() == 'r') { - if (s[6].unicode() == 't') { - if (s[7].unicode() == 'y') { - return Lexer::T_PROPERTY; - } - } - } - } - } - } - } - } - else if (qmlMode && s[0].unicode() == 'r') { - if (s[1].unicode() == 'e') { - if (s[2].unicode() == 'a') { - if (s[3].unicode() == 'd') { - if (s[4].unicode() == 'o') { - if (s[5].unicode() == 'n') { - if (s[6].unicode() == 'l') { - if (s[7].unicode() == 'y') { - return Lexer::T_READONLY; - } - } - } - } - } - } - } - } - else if (s[0].unicode() == 'v') { - if (s[1].unicode() == 'o') { - if (s[2].unicode() == 'l') { - if (s[3].unicode() == 'a') { - if (s[4].unicode() == 't') { - if (s[5].unicode() == 'i') { - if (s[6].unicode() == 'l') { - if (s[7].unicode() == 'e') { - return Lexer::T_VOLATILE; - } - } - } - } - } - } - } - } - return Lexer::T_IDENTIFIER; -} - -static inline int classify9(const QChar *s, bool /*qmlMode*/) { - if (s[0].unicode() == 'i') { - if (s[1].unicode() == 'n') { - if (s[2].unicode() == 't') { - if (s[3].unicode() == 'e') { - if (s[4].unicode() == 'r') { - if (s[5].unicode() == 'f') { - if (s[6].unicode() == 'a') { - if (s[7].unicode() == 'c') { - if (s[8].unicode() == 'e') { - return Lexer::T_INTERFACE; - } - } - } - } - } - } - } - } - } - else if (s[0].unicode() == 'p') { - if (s[1].unicode() == 'r') { - if (s[2].unicode() == 'o') { - if (s[3].unicode() == 't') { - if (s[4].unicode() == 'e') { - if (s[5].unicode() == 'c') { - if (s[6].unicode() == 't') { - if (s[7].unicode() == 'e') { - if (s[8].unicode() == 'd') { - return Lexer::T_PROTECTED; - } - } - } - } - } - } - } - } - } - else if (s[0].unicode() == 't') { - if (s[1].unicode() == 'r') { - if (s[2].unicode() == 'a') { - if (s[3].unicode() == 'n') { - if (s[4].unicode() == 's') { - if (s[5].unicode() == 'i') { - if (s[6].unicode() == 'e') { - if (s[7].unicode() == 'n') { - if (s[8].unicode() == 't') { - return Lexer::T_TRANSIENT; - } - } - } - } - } - } - } - } - } - return Lexer::T_IDENTIFIER; -} - -static inline int classify10(const QChar *s, bool /*qmlMode*/) { - if (s[0].unicode() == 'i') { - if (s[1].unicode() == 'm') { - if (s[2].unicode() == 'p') { - if (s[3].unicode() == 'l') { - if (s[4].unicode() == 'e') { - if (s[5].unicode() == 'm') { - if (s[6].unicode() == 'e') { - if (s[7].unicode() == 'n') { - if (s[8].unicode() == 't') { - if (s[9].unicode() == 's') { - return Lexer::T_IMPLEMENTS; - } - } - } - } - } - } - } - } - } - else if (s[1].unicode() == 'n') { - if (s[2].unicode() == 's') { - if (s[3].unicode() == 't') { - if (s[4].unicode() == 'a') { - if (s[5].unicode() == 'n') { - if (s[6].unicode() == 'c') { - if (s[7].unicode() == 'e') { - if (s[8].unicode() == 'o') { - if (s[9].unicode() == 'f') { - return Lexer::T_INSTANCEOF; - } - } - } - } - } - } - } - } - } - } - return Lexer::T_IDENTIFIER; -} - -static inline int classify12(const QChar *s, bool /*qmlMode*/) { - if (s[0].unicode() == 's') { - if (s[1].unicode() == 'y') { - if (s[2].unicode() == 'n') { - if (s[3].unicode() == 'c') { - if (s[4].unicode() == 'h') { - if (s[5].unicode() == 'r') { - if (s[6].unicode() == 'o') { - if (s[7].unicode() == 'n') { - if (s[8].unicode() == 'i') { - if (s[9].unicode() == 'z') { - if (s[10].unicode() == 'e') { - if (s[11].unicode() == 'd') { - return Lexer::T_SYNCHRONIZED; - } - } - } - } - } - } - } - } - } - } - } - } - return Lexer::T_IDENTIFIER; -} - -int Lexer::classify(const QChar *s, int n, bool qmlMode) { - switch (n) { - case 2: return classify2(s, qmlMode); - case 3: return classify3(s, qmlMode); - case 4: return classify4(s, qmlMode); - case 5: return classify5(s, qmlMode); - case 6: return classify6(s, qmlMode); - case 7: return classify7(s, qmlMode); - case 8: return classify8(s, qmlMode); - case 9: return classify9(s, qmlMode); - case 10: return classify10(s, qmlMode); - case 12: return classify12(s, qmlMode); - default: return Lexer::T_IDENTIFIER; - } // switch -} - -#endif // QDECLARATIVEJSKEYWORDS_P_H diff --git a/src/declarative/qml/parser/qdeclarativejslexer.cpp b/src/declarative/qml/parser/qdeclarativejslexer.cpp deleted file mode 100644 index e292490499..0000000000 --- a/src/declarative/qml/parser/qdeclarativejslexer.cpp +++ /dev/null @@ -1,1166 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qdeclarativejslexer_p.h" -#include "qdeclarativejsengine_p.h" -#include "qdeclarativejsmemorypool_p.h" - -#include -#include -#include - -QT_BEGIN_NAMESPACE -Q_CORE_EXPORT double qstrtod(const char *s00, char const **se, bool *ok); -QT_END_NAMESPACE - -using namespace QDeclarativeJS; - -static int regExpFlagFromChar(const QChar &ch) -{ - switch (ch.unicode()) { - case 'g': return Lexer::RegExp_Global; - case 'i': return Lexer::RegExp_IgnoreCase; - case 'm': return Lexer::RegExp_Multiline; - } - return 0; -} - -static unsigned char convertHex(ushort c) -{ - if (c >= '0' && c <= '9') - return (c - '0'); - else if (c >= 'a' && c <= 'f') - return (c - 'a' + 10); - else - return (c - 'A' + 10); -} - -static QChar convertHex(QChar c1, QChar c2) -{ - return QChar((convertHex(c1.unicode()) << 4) + convertHex(c2.unicode())); -} - -static QChar convertUnicode(QChar c1, QChar c2, QChar c3, QChar c4) -{ - return QChar((convertHex(c3.unicode()) << 4) + convertHex(c4.unicode()), - (convertHex(c1.unicode()) << 4) + convertHex(c2.unicode())); -} - -Lexer::Lexer(Engine *engine) - : _engine(engine) - , _codePtr(0) - , _lastLinePtr(0) - , _tokenLinePtr(0) - , _tokenStartPtr(0) - , _char(QLatin1Char('\n')) - , _errorCode(NoError) - , _currentLineNumber(0) - , _tokenValue(0) - , _parenthesesState(IgnoreParentheses) - , _parenthesesCount(0) - , _stackToken(-1) - , _patternFlags(0) - , _tokenKind(0) - , _tokenLength(0) - , _tokenLine(0) - , _validTokenText(false) - , _prohibitAutomaticSemicolon(false) - , _restrictedKeyword(false) - , _terminator(false) - , _followsClosingBrace(false) - , _delimited(true) - , _qmlMode(true) -{ - if (engine) - engine->setLexer(this); -} - -bool Lexer::qmlMode() const -{ - return _qmlMode; -} - -QString Lexer::code() const -{ - return _code; -} - -void Lexer::setCode(const QString &code, int lineno, bool qmlMode) -{ - if (_engine) - _engine->setCode(code); - - _qmlMode = qmlMode; - _code = code; - _tokenText.clear(); - _tokenText.reserve(1024); - _errorMessage.clear(); - _tokenSpell = QStringRef(); - - _codePtr = code.unicode(); - _lastLinePtr = _codePtr; - _tokenLinePtr = _codePtr; - _tokenStartPtr = _codePtr; - - _char = QLatin1Char('\n'); - _errorCode = NoError; - - _currentLineNumber = lineno; - _tokenValue = 0; - - // parentheses state - _parenthesesState = IgnoreParentheses; - _parenthesesCount = 0; - - _stackToken = -1; - - _patternFlags = 0; - _tokenLength = 0; - _tokenLine = lineno; - - _validTokenText = false; - _prohibitAutomaticSemicolon = false; - _restrictedKeyword = false; - _terminator = false; - _followsClosingBrace = false; - _delimited = true; -} - -void Lexer::scanChar() -{ - _char = *_codePtr++; - - if (_char == QLatin1Char('\n')) { - _lastLinePtr = _codePtr; // points to the first character after the newline - ++_currentLineNumber; - } -} - -int Lexer::lex() -{ - const int previousTokenKind = _tokenKind; - - _tokenSpell = QStringRef(); - _tokenKind = scanToken(); - _tokenLength = _codePtr - _tokenStartPtr - 1; - - _delimited = false; - _restrictedKeyword = false; - _followsClosingBrace = (previousTokenKind == T_RBRACE); - - // update the flags - switch (_tokenKind) { - case T_LBRACE: - case T_SEMICOLON: - case T_COLON: - _delimited = true; - break; - - case T_IF: - case T_FOR: - case T_WHILE: - case T_WITH: - _parenthesesState = CountParentheses; - _parenthesesCount = 0; - break; - - case T_DO: - _parenthesesState = BalancedParentheses; - break; - - case T_CONTINUE: - case T_BREAK: - case T_RETURN: - case T_THROW: - _restrictedKeyword = true; - break; - } // switch - - // update the parentheses state - switch (_parenthesesState) { - case IgnoreParentheses: - break; - - case CountParentheses: - if (_tokenKind == T_RPAREN) { - --_parenthesesCount; - if (_parenthesesCount == 0) - _parenthesesState = BalancedParentheses; - } else if (_tokenKind == T_LPAREN) { - ++_parenthesesCount; - } - break; - - case BalancedParentheses: - _parenthesesState = IgnoreParentheses; - break; - } // switch - - return _tokenKind; -} - -bool Lexer::isUnicodeEscapeSequence(const QChar *chars) -{ - if (isHexDigit(chars[0]) && isHexDigit(chars[1]) && isHexDigit(chars[2]) && isHexDigit(chars[3])) - return true; - - return false; -} - -QChar Lexer::decodeUnicodeEscapeCharacter(bool *ok) -{ - if (_char == QLatin1Char('u') && isUnicodeEscapeSequence(&_codePtr[0])) { - scanChar(); // skip u - - const QChar c1 = _char; - scanChar(); - - const QChar c2 = _char; - scanChar(); - - const QChar c3 = _char; - scanChar(); - - const QChar c4 = _char; - scanChar(); - - if (ok) - *ok = true; - - return convertUnicode(c1, c2, c3, c4); - } - - *ok = false; - return QChar(); -} - -int Lexer::scanToken() -{ - if (_stackToken != -1) { - int tk = _stackToken; - _stackToken = -1; - return tk; - } - - _terminator = false; - -again: - _validTokenText = false; - _tokenLinePtr = _lastLinePtr; - - while (_char.isSpace()) { - if (_char == QLatin1Char('\n')) { - _tokenLinePtr = _codePtr; - - if (_restrictedKeyword) { - // automatic semicolon insertion - _tokenLine = _currentLineNumber; - _tokenStartPtr = _codePtr - 1; // ### TODO: insert it before the optional \r sequence. - return T_SEMICOLON; - } else { - _terminator = true; - syncProhibitAutomaticSemicolon(); - } - } - - scanChar(); - } - - _tokenStartPtr = _codePtr - 1; - _tokenLine = _currentLineNumber; - - if (_char.isNull()) - return EOF_SYMBOL; - - const QChar ch = _char; - scanChar(); - - switch (ch.unicode()) { - case '~': return T_TILDE; - case '}': return T_RBRACE; - - case '|': - if (_char == QLatin1Char('|')) { - scanChar(); - return T_OR_OR; - } else if (_char == QLatin1Char('=')) { - scanChar(); - return T_OR_EQ; - } - return T_OR; - - case '{': return T_LBRACE; - - case '^': - if (_char == QLatin1Char('=')) { - scanChar(); - return T_XOR_EQ; - } - return T_XOR; - - case ']': return T_RBRACKET; - case '[': return T_LBRACKET; - case '?': return T_QUESTION; - - case '>': - if (_char == QLatin1Char('>')) { - scanChar(); - if (_char == QLatin1Char('>')) { - scanChar(); - if (_char == QLatin1Char('=')) { - scanChar(); - return T_GT_GT_GT_EQ; - } - return T_GT_GT_GT; - } else if (_char == QLatin1Char('=')) { - scanChar(); - return T_GT_GT_EQ; - } - return T_GT_GT; - } else if (_char == QLatin1Char('=')) { - scanChar(); - return T_GE; - } - return T_GT; - - case '=': - if (_char == QLatin1Char('=')) { - scanChar(); - if (_char == QLatin1Char('=')) { - scanChar(); - return T_EQ_EQ_EQ; - } - return T_EQ_EQ; - } - return T_EQ; - - case '<': - if (_char == QLatin1Char('=')) { - scanChar(); - return T_LE; - } else if (_char == QLatin1Char('<')) { - scanChar(); - if (_char == QLatin1Char('=')) { - scanChar(); - return T_LT_LT_EQ; - } - return T_LT_LT; - } - return T_LT; - - case ';': return T_SEMICOLON; - case ':': return T_COLON; - - case '/': - if (_char == QLatin1Char('*')) { - scanChar(); - while (!_char.isNull()) { - if (_char == QLatin1Char('*')) { - scanChar(); - if (_char == QLatin1Char('/')) { - scanChar(); - - if (_engine) { - _engine->addComment(tokenOffset() + 2, _codePtr - _tokenStartPtr - 1 - 4, - tokenStartLine(), tokenStartColumn() + 2); - } - - goto again; - } - } else { - scanChar(); - } - } - } else if (_char == QLatin1Char('/')) { - while (!_char.isNull() && _char != QLatin1Char('\n')) { - scanChar(); - } - if (_engine) { - _engine->addComment(tokenOffset() + 2, _codePtr - _tokenStartPtr - 1 - 2, - tokenStartLine(), tokenStartColumn() + 2); - } - goto again; - } if (_char == QLatin1Char('=')) { - scanChar(); - return T_DIVIDE_EQ; - } - return T_DIVIDE_; - - case '.': - if (_char.isDigit()) { - QVarLengthArray chars; - - chars.append(ch.unicode()); // append the `.' - - while (_char.isDigit()) { - chars.append(_char.unicode()); - scanChar(); - } - - if (_char == QLatin1Char('e') || _char == QLatin1Char('E')) { - if (_codePtr[0].isDigit() || ((_codePtr[0] == QLatin1Char('+') || _codePtr[0] == QLatin1Char('-')) && - _codePtr[1].isDigit())) { - - chars.append(_char.unicode()); - scanChar(); // consume `e' - - if (_char == QLatin1Char('+') || _char == QLatin1Char('-')) { - chars.append(_char.unicode()); - scanChar(); // consume the sign - } - - while (_char.isDigit()) { - chars.append(_char.unicode()); - scanChar(); - } - } - } - - chars.append('\0'); - - const char *begin = chars.constData(); - const char *end = 0; - bool ok = false; - - _tokenValue = qstrtod(begin, &end, &ok); - - if (end - begin != chars.size() - 1) { - _errorCode = IllegalExponentIndicator; - _errorMessage = QCoreApplication::translate("QDeclarativeParser", "Illegal syntax for exponential number"); - return T_ERROR; - } - - return T_NUMERIC_LITERAL; - } - return T_DOT; - - case '-': - if (_char == QLatin1Char('=')) { - scanChar(); - return T_MINUS_EQ; - } else if (_char == QLatin1Char('-')) { - scanChar(); - - if (_terminator && !_delimited && !_prohibitAutomaticSemicolon) { - _stackToken = T_MINUS_MINUS; - return T_SEMICOLON; - } - - return T_MINUS_MINUS; - } - return T_MINUS; - - case ',': return T_COMMA; - - case '+': - if (_char == QLatin1Char('=')) { - scanChar(); - return T_PLUS_EQ; - } else if (_char == QLatin1Char('+')) { - scanChar(); - - if (_terminator && !_delimited && !_prohibitAutomaticSemicolon) { - _stackToken = T_PLUS_PLUS; - return T_SEMICOLON; - } - - return T_PLUS_PLUS; - } - return T_PLUS; - - case '*': - if (_char == QLatin1Char('=')) { - scanChar(); - return T_STAR_EQ; - } - return T_STAR; - - case ')': return T_RPAREN; - case '(': return T_LPAREN; - - case '&': - if (_char == QLatin1Char('=')) { - scanChar(); - return T_AND_EQ; - } else if (_char == QLatin1Char('&')) { - scanChar(); - return T_AND_AND; - } - return T_AND; - - case '%': - if (_char == QLatin1Char('=')) { - scanChar(); - return T_REMAINDER_EQ; - } - return T_REMAINDER; - - case '!': - if (_char == QLatin1Char('=')) { - scanChar(); - if (_char == QLatin1Char('=')) { - scanChar(); - return T_NOT_EQ_EQ; - } - return T_NOT_EQ; - } - return T_NOT; - - case '\'': - case '"': { - const QChar quote = ch; - bool multilineStringLiteral = false; - - const QChar *startCode = _codePtr; - - if (_engine) { - while (!_char.isNull()) { - if (_char == QLatin1Char('\n') || _char == QLatin1Char('\\')) { - break; - } else if (_char == quote) { - _tokenSpell = _engine->midRef(startCode - _code.unicode() - 1, _codePtr - startCode); - scanChar(); - - return T_STRING_LITERAL; - } - scanChar(); - } - } - - _validTokenText = true; - _tokenText.resize(0); - startCode--; - while (startCode != _codePtr - 1) - _tokenText += *startCode++; - - while (! _char.isNull()) { - if (_char == QLatin1Char('\n')) { - multilineStringLiteral = true; - _tokenText += _char; - scanChar(); - } else if (_char == quote) { - scanChar(); - - if (_engine) - _tokenSpell = _engine->newStringRef(_tokenText); - - return multilineStringLiteral ? T_MULTILINE_STRING_LITERAL : T_STRING_LITERAL; - } else if (_char == QLatin1Char('\\')) { - scanChar(); - - QChar u; - bool ok = false; - - switch (_char.unicode()) { - // unicode escape sequence - case 'u': - u = decodeUnicodeEscapeCharacter(&ok); - if (! ok) - u = _char; - break; - - // hex escape sequence - case 'x': - case 'X': - if (isHexDigit(_codePtr[0]) && isHexDigit(_codePtr[1])) { - scanChar(); - - const QChar c1 = _char; - scanChar(); - - const QChar c2 = _char; - scanChar(); - - u = convertHex(c1, c2); - } else { - u = _char; - } - break; - - // single character escape sequence - case '\\': u = QLatin1Char('\\'); scanChar(); break; - case '\'': u = QLatin1Char('\''); scanChar(); break; - case '\"': u = QLatin1Char('\"'); scanChar(); break; - case 'b': u = QLatin1Char('\b'); scanChar(); break; - case 'f': u = QLatin1Char('\f'); scanChar(); break; - case 'n': u = QLatin1Char('\n'); scanChar(); break; - case 'r': u = QLatin1Char('\r'); scanChar(); break; - case 't': u = QLatin1Char('\t'); scanChar(); break; - case 'v': u = QLatin1Char('\v'); scanChar(); break; - - case '0': - if (! _codePtr[1].isDigit()) { - scanChar(); - u = QLatin1Char('\0'); - } else { - // ### parse deprecated octal escape sequence ? - u = _char; - } - break; - - case '\r': - while (_char == QLatin1Char('\r')) - scanChar(); - - if (_char == QLatin1Char('\n')) { - u = _char; - scanChar(); - } else { - u = QLatin1Char('\n'); - } - - break; - - case '\n': - u = _char; - scanChar(); - break; - - default: - // non escape character - u = _char; - scanChar(); - } - - _tokenText += u; - } else { - _tokenText += _char; - scanChar(); - } - } - - _errorCode = UnclosedStringLiteral; - _errorMessage = QCoreApplication::translate("QDeclarativeParser", "Unclosed string at end of line"); - return T_ERROR; - } - - default: - if (ch.isLetter() || ch == QLatin1Char('$') || ch == QLatin1Char('_') || (ch == QLatin1Char('\\') && _char == QLatin1Char('u'))) { - bool identifierWithEscapeChars = false; - if (ch == QLatin1Char('\\')) { - identifierWithEscapeChars = true; - _tokenText.resize(0); - bool ok = false; - _tokenText += decodeUnicodeEscapeCharacter(&ok); - _validTokenText = true; - if (! ok) { - _errorCode = IllegalUnicodeEscapeSequence; - _errorMessage = QCoreApplication::translate("QDeclarativeParser", "Illegal unicode escape sequence"); - return T_ERROR; - } - } - while (true) { - if (_char.isLetterOrNumber() || _char == QLatin1Char('$') || _char == QLatin1Char('_')) { - if (identifierWithEscapeChars) - _tokenText += _char; - - scanChar(); - } else if (_char == QLatin1Char('\\') && _codePtr[0] == QLatin1Char('u')) { - if (! identifierWithEscapeChars) { - identifierWithEscapeChars = true; - _tokenText.resize(0); - _tokenText.insert(0, _tokenStartPtr, _codePtr - _tokenStartPtr - 1); - _validTokenText = true; - } - - scanChar(); // skip '\\' - bool ok = false; - _tokenText += decodeUnicodeEscapeCharacter(&ok); - if (! ok) { - _errorCode = IllegalUnicodeEscapeSequence; - _errorMessage = QCoreApplication::translate("QDeclarativeParser", "Illegal unicode escape sequence"); - return T_ERROR; - } - } else { - _tokenLength = _codePtr - _tokenStartPtr - 1; - - int kind = T_IDENTIFIER; - - if (! identifierWithEscapeChars) - kind = classify(_tokenStartPtr, _tokenLength, _qmlMode); - - if (_engine) { - if (kind == T_IDENTIFIER && identifierWithEscapeChars) - _tokenSpell = _engine->newStringRef(_tokenText); - else - _tokenSpell = _engine->midRef(_tokenStartPtr - _code.unicode(), _tokenLength); - } - - return kind; - } - } - } else if (ch.isDigit()) { - if (ch != QLatin1Char('0')) { - double integer = ch.unicode() - '0'; - - QChar n = _char; - const QChar *code = _codePtr; - while (n.isDigit()) { - integer = integer * 10 + (n.unicode() - '0'); - n = *code++; - } - - if (n != QLatin1Char('.') && n != QLatin1Char('e') && n != QLatin1Char('E')) { - if (code != _codePtr) { - _codePtr = code - 1; - scanChar(); - } - _tokenValue = integer; - return T_NUMERIC_LITERAL; - } - } - - QVarLengthArray chars; - chars.append(ch.unicode()); - - if (ch == QLatin1Char('0') && (_char == QLatin1Char('x') || _char == QLatin1Char('X'))) { - // parse hex integer literal - - chars.append(_char.unicode()); - scanChar(); // consume `x' - - while (isHexDigit(_char)) { - chars.append(_char.unicode()); - scanChar(); - } - - _tokenValue = integerFromString(chars.constData(), chars.size(), 16); - return T_NUMERIC_LITERAL; - } - - // decimal integer literal - while (_char.isDigit()) { - chars.append(_char.unicode()); - scanChar(); // consume the digit - } - - if (_char == QLatin1Char('.')) { - chars.append(_char.unicode()); - scanChar(); // consume `.' - - while (_char.isDigit()) { - chars.append(_char.unicode()); - scanChar(); - } - - if (_char == QLatin1Char('e') || _char == QLatin1Char('E')) { - if (_codePtr[0].isDigit() || ((_codePtr[0] == QLatin1Char('+') || _codePtr[0] == QLatin1Char('-')) && - _codePtr[1].isDigit())) { - - chars.append(_char.unicode()); - scanChar(); // consume `e' - - if (_char == QLatin1Char('+') || _char == QLatin1Char('-')) { - chars.append(_char.unicode()); - scanChar(); // consume the sign - } - - while (_char.isDigit()) { - chars.append(_char.unicode()); - scanChar(); - } - } - } - } else if (_char == QLatin1Char('e') || _char == QLatin1Char('E')) { - if (_codePtr[0].isDigit() || ((_codePtr[0] == QLatin1Char('+') || _codePtr[0] == QLatin1Char('-')) && - _codePtr[1].isDigit())) { - - chars.append(_char.unicode()); - scanChar(); // consume `e' - - if (_char == QLatin1Char('+') || _char == QLatin1Char('-')) { - chars.append(_char.unicode()); - scanChar(); // consume the sign - } - - while (_char.isDigit()) { - chars.append(_char.unicode()); - scanChar(); - } - } - } - - chars.append('\0'); - - const char *begin = chars.constData(); - const char *end = 0; - bool ok = false; - - _tokenValue = qstrtod(begin, &end, &ok); - - if (end - begin != chars.size() - 1) { - _errorCode = IllegalExponentIndicator; - _errorMessage = QCoreApplication::translate("QDeclarativeParser", "Illegal syntax for exponential number"); - return T_ERROR; - } - - return T_NUMERIC_LITERAL; - } - - break; - } - - return T_ERROR; -} - -bool Lexer::scanRegExp(RegExpBodyPrefix prefix) -{ - _tokenText.resize(0); - _validTokenText = true; - _patternFlags = 0; - - if (prefix == EqualPrefix) - _tokenText += QLatin1Char('='); - - while (true) { - switch (_char.unicode()) { - case 0: // eof - case '\n': case '\r': // line terminator - _errorMessage = QCoreApplication::translate("QDeclarativeParser", "Unterminated regular expression literal"); - return false; - - case '/': - scanChar(); - - // scan the flags - _patternFlags = 0; - while (isIdentLetter(_char)) { - int flag = regExpFlagFromChar(_char); - if (flag == 0) { - _errorMessage = QCoreApplication::translate("QDeclarativeParser", "Invalid regular expression flag '%0'") - .arg(QChar(_char)); - return false; - } - _patternFlags |= flag; - scanChar(); - } - - _tokenLength = _codePtr - _tokenStartPtr - 1; - return true; - - case '\\': - // regular expression backslash sequence - _tokenText += _char; - scanChar(); - - if (_char.isNull() || isLineTerminator()) { - _errorMessage = QCoreApplication::translate("QDeclarativeParser", "Unterminated regular expression backslash sequence"); - return false; - } - - _tokenText += _char; - scanChar(); - break; - - case '[': - // regular expression class - _tokenText += _char; - scanChar(); - - while (! _char.isNull() && ! isLineTerminator()) { - if (_char == QLatin1Char(']')) - break; - else if (_char == QLatin1Char('\\')) { - // regular expression backslash sequence - _tokenText += _char; - scanChar(); - - if (_char.isNull() || isLineTerminator()) { - _errorMessage = QCoreApplication::translate("QDeclarativeParser", "Unterminated regular expression backslash sequence"); - return false; - } - - _tokenText += _char; - scanChar(); - } else { - _tokenText += _char; - scanChar(); - } - } - - if (_char != QLatin1Char(']')) { - _errorMessage = QCoreApplication::translate("QDeclarativeParser", "Unterminated regular expression class"); - return false; - } - - _tokenText += _char; - scanChar(); // skip ] - break; - - default: - _tokenText += _char; - scanChar(); - } // switch - } // while - - return false; -} - -bool Lexer::isLineTerminator() const -{ - return (_char == QLatin1Char('\n') || _char == QLatin1Char('\r')); -} - -bool Lexer::isIdentLetter(QChar ch) -{ - // ASCII-biased, since all reserved words are ASCII, aand hence the - // bulk of content to be parsed. - if ((ch >= QLatin1Char('a') && ch <= QLatin1Char('z')) - || (ch >= QLatin1Char('A') && ch <= QLatin1Char('Z')) - || ch == QLatin1Char('$') - || ch == QLatin1Char('_')) - return true; - if (ch.unicode() < 128) - return false; - return ch.isLetterOrNumber(); -} - -bool Lexer::isDecimalDigit(ushort c) -{ - return (c >= '0' && c <= '9'); -} - -bool Lexer::isHexDigit(QChar c) -{ - return ((c >= QLatin1Char('0') && c <= QLatin1Char('9')) - || (c >= QLatin1Char('a') && c <= QLatin1Char('f')) - || (c >= QLatin1Char('A') && c <= QLatin1Char('F'))); -} - -bool Lexer::isOctalDigit(ushort c) -{ - return (c >= '0' && c <= '7'); -} - -int Lexer::tokenKind() const -{ - return _tokenKind; -} - -int Lexer::tokenOffset() const -{ - return _tokenStartPtr - _code.unicode(); -} - -int Lexer::tokenLength() const -{ - return _tokenLength; -} - -int Lexer::tokenStartLine() const -{ - return _tokenLine; -} - -int Lexer::tokenStartColumn() const -{ - return _tokenStartPtr - _tokenLinePtr + 1; -} - -int Lexer::tokenEndLine() const -{ - return _currentLineNumber; -} - -int Lexer::tokenEndColumn() const -{ - return _codePtr - _lastLinePtr; -} - -QStringRef Lexer::tokenSpell() const -{ - return _tokenSpell; -} - -double Lexer::tokenValue() const -{ - return _tokenValue; -} - -QString Lexer::tokenText() const -{ - if (_validTokenText) - return _tokenText; - - if (_tokenKind == T_STRING_LITERAL) - return QString(_tokenStartPtr + 1, _tokenLength - 2); - - return QString(_tokenStartPtr, _tokenLength); -} - -Lexer::Error Lexer::errorCode() const -{ - return _errorCode; -} - -QString Lexer::errorMessage() const -{ - return _errorMessage; -} - -void Lexer::syncProhibitAutomaticSemicolon() -{ - if (_parenthesesState == BalancedParentheses) { - // we have seen something like "if (foo)", which means we should - // never insert an automatic semicolon at this point, since it would - // then be expanded into an empty statement (ECMA-262 7.9.1) - _prohibitAutomaticSemicolon = true; - _parenthesesState = IgnoreParentheses; - } else { - _prohibitAutomaticSemicolon = false; - } -} - -bool Lexer::prevTerminator() const -{ - return _terminator; -} - -bool Lexer::followsClosingBrace() const -{ - return _followsClosingBrace; -} - -bool Lexer::canInsertAutomaticSemicolon(int token) const -{ - return token == T_RBRACE - || token == EOF_SYMBOL - || _terminator - || _followsClosingBrace; -} - -bool Lexer::scanDirectives(Directives *directives) -{ - if (_qmlMode) { - // the directives are a Javascript-only extension. - return false; - } - - lex(); // fetch the first token - - if (_tokenKind != T_DOT) - return true; - - do { - lex(); // skip T_DOT - - const int lineNumber = tokenStartLine(); - - if (! (_tokenKind == T_IDENTIFIER || _tokenKind == T_RESERVED_WORD)) - return false; // expected a valid QML/JS directive - - const QString directiveName = tokenText(); - - if (! (directiveName == QLatin1String("pragma") || - directiveName == QLatin1String("import"))) - return false; // not a valid directive name - - // it must be a pragma or an import directive. - if (directiveName == QLatin1String("pragma")) { - // .pragma library - if (! (lex() == T_IDENTIFIER && tokenText() == QLatin1String("library"))) - return false; // expected `library - - // we found a .pragma library directive - directives->pragmaLibrary(); - - } else { - Q_ASSERT(directiveName == QLatin1String("import")); - lex(); // skip .import - - QString pathOrUri; - QString version; - bool fileImport = false; // file or uri import - - if (_tokenKind == T_STRING_LITERAL) { - // .import T_STRING_LITERAL as T_IDENTIFIER - - fileImport = true; - pathOrUri = tokenText(); - - } else if (_tokenKind == T_IDENTIFIER) { - // .import T_IDENTIFIER (. T_IDENTIFIER)* T_NUMERIC_LITERAL as T_IDENTIFIER - - pathOrUri = tokenText(); - - lex(); // skip the first T_IDENTIFIER - for (; _tokenKind == T_DOT; lex()) { - if (lex() != T_IDENTIFIER) - return false; - - pathOrUri += QLatin1Char('.'); - pathOrUri += tokenText(); - } - - if (_tokenKind != T_NUMERIC_LITERAL) - return false; // expected the module version number - - version = tokenText(); - } - - // - // recognize the mandatory `as' followed by the module name - // - if (! (lex() == T_RESERVED_WORD && tokenText() == QLatin1String("as"))) - return false; // expected `as' - - if (lex() != T_IDENTIFIER) - return false; // expected module name - - const QString module = tokenText(); - - if (fileImport) - directives->importFile(pathOrUri, module); - else - directives->importModule(pathOrUri, version, module); - } - - if (tokenStartLine() != lineNumber) - return false; // the directives cannot span over multiple lines - - // fetch the first token after the .pragma/.import directive - lex(); - } while (_tokenKind == T_DOT); - - return true; -} - -#include "qdeclarativejskeywords_p.h" diff --git a/src/declarative/qml/parser/qdeclarativejslexer_p.h b/src/declarative/qml/parser/qdeclarativejslexer_p.h deleted file mode 100644 index 806603e022..0000000000 --- a/src/declarative/qml/parser/qdeclarativejslexer_p.h +++ /dev/null @@ -1,248 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QDECLARATIVEJSLEXER_P_H -#define QDECLARATIVEJSLEXER_P_H - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists purely as an -// implementation detail. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - -#include "qdeclarativejsglobal_p.h" -#include "qdeclarativejsgrammar_p.h" -#include - -QT_QML_BEGIN_NAMESPACE - -namespace QDeclarativeJS { - -class Engine; - -class QML_PARSER_EXPORT Directives { -public: - virtual ~Directives() {} - - virtual void pragmaLibrary() - { - } - - virtual void importFile(const QString &jsfile, const QString &module) - { - Q_UNUSED(jsfile); - Q_UNUSED(module); - } - - virtual void importModule(const QString &uri, const QString &version, const QString &module) - { - Q_UNUSED(uri); - Q_UNUSED(version); - Q_UNUSED(module); - } -}; - -class QML_PARSER_EXPORT Lexer: public QDeclarativeJSGrammar -{ -public: - enum { - T_ABSTRACT = T_RESERVED_WORD, - T_BOOLEAN = T_RESERVED_WORD, - T_BYTE = T_RESERVED_WORD, - T_CHAR = T_RESERVED_WORD, - T_CLASS = T_RESERVED_WORD, - T_DOUBLE = T_RESERVED_WORD, - T_ENUM = T_RESERVED_WORD, - T_EXPORT = T_RESERVED_WORD, - T_EXTENDS = T_RESERVED_WORD, - T_FINAL = T_RESERVED_WORD, - T_FLOAT = T_RESERVED_WORD, - T_GOTO = T_RESERVED_WORD, - T_IMPLEMENTS = T_RESERVED_WORD, - T_INT = T_RESERVED_WORD, - T_INTERFACE = T_RESERVED_WORD, - T_LET = T_RESERVED_WORD, - T_LONG = T_RESERVED_WORD, - T_NATIVE = T_RESERVED_WORD, - T_PACKAGE = T_RESERVED_WORD, - T_PRIVATE = T_RESERVED_WORD, - T_PROTECTED = T_RESERVED_WORD, - T_SHORT = T_RESERVED_WORD, - T_STATIC = T_RESERVED_WORD, - T_SUPER = T_RESERVED_WORD, - T_SYNCHRONIZED = T_RESERVED_WORD, - T_THROWS = T_RESERVED_WORD, - T_TRANSIENT = T_RESERVED_WORD, - T_VOLATILE = T_RESERVED_WORD, - T_YIELD = T_RESERVED_WORD - }; - - enum Error { - NoError, - IllegalCharacter, - UnclosedStringLiteral, - IllegalEscapeSequence, - IllegalUnicodeEscapeSequence, - UnclosedComment, - IllegalExponentIndicator, - IllegalIdentifier - }; - - enum RegExpBodyPrefix { - NoPrefix, - EqualPrefix - }; - - enum RegExpFlag { - RegExp_Global = 0x01, - RegExp_IgnoreCase = 0x02, - RegExp_Multiline = 0x04 - }; - -public: - Lexer(Engine *engine); - - bool qmlMode() const; - - QString code() const; - void setCode(const QString &code, int lineno, bool qmlMode = true); - - int lex(); - - bool scanRegExp(RegExpBodyPrefix prefix = NoPrefix); - bool scanDirectives(Directives *directives); - - int regExpFlags() const { return _patternFlags; } - QString regExpPattern() const { return _tokenText; } - - int tokenKind() const; - int tokenOffset() const; - int tokenLength() const; - - int tokenStartLine() const; - int tokenStartColumn() const; - - int tokenEndLine() const; - int tokenEndColumn() const; - - QStringRef tokenSpell() const; - double tokenValue() const; - QString tokenText() const; - - Error errorCode() const; - QString errorMessage() const; - - bool prevTerminator() const; - bool followsClosingBrace() const; - bool canInsertAutomaticSemicolon(int token) const; - - enum ParenthesesState { - IgnoreParentheses, - CountParentheses, - BalancedParentheses - }; - -protected: - int classify(const QChar *s, int n, bool qmlMode); - -private: - inline void scanChar(); - int scanToken(); - - bool isLineTerminator() const; - static bool isIdentLetter(QChar c); - static bool isDecimalDigit(ushort c); - static bool isHexDigit(QChar c); - static bool isOctalDigit(ushort c); - static bool isUnicodeEscapeSequence(const QChar *chars); - - void syncProhibitAutomaticSemicolon(); - QChar decodeUnicodeEscapeCharacter(bool *ok); - -private: - Engine *_engine; - - QString _code; - QString _tokenText; - QString _errorMessage; - QStringRef _tokenSpell; - - const QChar *_codePtr; - const QChar *_lastLinePtr; - const QChar *_tokenLinePtr; - const QChar *_tokenStartPtr; - - QChar _char; - Error _errorCode; - - int _currentLineNumber; - double _tokenValue; - - // parentheses state - ParenthesesState _parenthesesState; - int _parenthesesCount; - - int _stackToken; - - int _patternFlags; - int _tokenKind; - int _tokenLength; - int _tokenLine; - - bool _validTokenText; - bool _prohibitAutomaticSemicolon; - bool _restrictedKeyword; - bool _terminator; - bool _followsClosingBrace; - bool _delimited; - bool _qmlMode; -}; - -} // end of namespace QDeclarativeJS - -QT_QML_END_NAMESPACE - -#endif // LEXER_H diff --git a/src/declarative/qml/parser/qdeclarativejsmemorypool_p.h b/src/declarative/qml/parser/qdeclarativejsmemorypool_p.h deleted file mode 100644 index 22baff2254..0000000000 --- a/src/declarative/qml/parser/qdeclarativejsmemorypool_p.h +++ /dev/null @@ -1,173 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QDECLARATIVEJSMEMORYPOOL_P_H -#define QDECLARATIVEJSMEMORYPOOL_P_H - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists purely as an -// implementation detail. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - -#include "qdeclarativejsglobal_p.h" - -#include -#include -#include - -#include - -QT_QML_BEGIN_NAMESPACE - -namespace QDeclarativeJS { - -class QML_PARSER_EXPORT MemoryPool : public QSharedData -{ - MemoryPool(const MemoryPool &other); - void operator =(const MemoryPool &other); - -public: - MemoryPool() - : _blocks(0), - _allocatedBlocks(0), - _blockCount(-1), - _ptr(0), - _end(0) - { } - - ~MemoryPool() - { - if (_blocks) { - for (int i = 0; i < _allocatedBlocks; ++i) { - if (char *b = _blocks[i]) - qFree(b); - } - - qFree(_blocks); - } - } - - inline void *allocate(size_t size) - { - size = (size + 7) & ~7; - if (_ptr && (_ptr + size < _end)) { - void *addr = _ptr; - _ptr += size; - return addr; - } - return allocate_helper(size); - } - - void reset() - { - _blockCount = -1; - _ptr = _end = 0; - } - -private: - void *allocate_helper(size_t size) - { - Q_ASSERT(size < BLOCK_SIZE); - - if (++_blockCount == _allocatedBlocks) { - if (! _allocatedBlocks) - _allocatedBlocks = DEFAULT_BLOCK_COUNT; - else - _allocatedBlocks *= 2; - - _blocks = (char **) qRealloc(_blocks, sizeof(char *) * _allocatedBlocks); - - for (int index = _blockCount; index < _allocatedBlocks; ++index) - _blocks[index] = 0; - } - - char *&block = _blocks[_blockCount]; - - if (! block) - block = (char *) qMalloc(BLOCK_SIZE); - - _ptr = block; - _end = _ptr + BLOCK_SIZE; - - void *addr = _ptr; - _ptr += size; - return addr; - } - -private: - char **_blocks; - int _allocatedBlocks; - int _blockCount; - char *_ptr; - char *_end; - - enum - { - BLOCK_SIZE = 8 * 1024, - DEFAULT_BLOCK_COUNT = 8 - }; -}; - -class QML_PARSER_EXPORT Managed -{ - Managed(const Managed &other); - void operator = (const Managed &other); - -public: - Managed() {} - ~Managed() {} - - void *operator new(size_t size, MemoryPool *pool) { return pool->allocate(size); } - void operator delete(void *) {} - void operator delete(void *, MemoryPool *) {} -}; - -} // namespace QDeclarativeJS - -QT_QML_END_NAMESPACE - -#endif diff --git a/src/declarative/qml/parser/qdeclarativejsparser.cpp b/src/declarative/qml/parser/qdeclarativejsparser.cpp deleted file mode 100644 index 384544afe4..0000000000 --- a/src/declarative/qml/parser/qdeclarativejsparser.cpp +++ /dev/null @@ -1,1812 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include -#include - -#include - -#include "qdeclarativejsengine_p.h" -#include "qdeclarativejslexer_p.h" -#include "qdeclarativejsast_p.h" -#include "qdeclarativejsmemorypool_p.h" - - - -#include "qdeclarativejsparser_p.h" -#include - -// -// This file is automatically generated from qmljs.g. -// Changes will be lost. -// - -using namespace QDeclarativeJS; - -QT_QML_BEGIN_NAMESPACE - -void Parser::reallocateStack() -{ - if (! stack_size) - stack_size = 128; - else - stack_size <<= 1; - - sym_stack = reinterpret_cast (realloc(sym_stack, stack_size * sizeof(Value))); - state_stack = reinterpret_cast (realloc(state_stack, stack_size * sizeof(int))); - location_stack = reinterpret_cast (realloc(location_stack, stack_size * sizeof(AST::SourceLocation))); - string_stack = reinterpret_cast (realloc(string_stack, stack_size * sizeof(QStringRef))); -} - -Parser::Parser(Engine *engine): - driver(engine), - pool(engine->pool()), - tos(0), - stack_size(0), - sym_stack(0), - state_stack(0), - location_stack(0), - string_stack(0), - first_token(0), - last_token(0) -{ -} - -Parser::~Parser() -{ - if (stack_size) { - free(sym_stack); - free(state_stack); - free(location_stack); - free(string_stack); - } -} - -static inline AST::SourceLocation location(Lexer *lexer) -{ - AST::SourceLocation loc; - loc.offset = lexer->tokenOffset(); - loc.length = lexer->tokenLength(); - loc.startLine = lexer->tokenStartLine(); - loc.startColumn = lexer->tokenStartColumn(); - return loc; -} - -AST::UiQualifiedId *Parser::reparseAsQualifiedId(AST::ExpressionNode *expr) -{ - QVarLengthArray nameIds; - QVarLengthArray locations; - - AST::ExpressionNode *it = expr; - while (AST::FieldMemberExpression *m = AST::cast(it)) { - nameIds.append(m->name); - locations.append(m->identifierToken); - it = m->base; - } - - if (AST::IdentifierExpression *idExpr = AST::cast(it)) { - AST::UiQualifiedId *q = new (pool) AST::UiQualifiedId(idExpr->name); - q->identifierToken = idExpr->identifierToken; - - AST::UiQualifiedId *currentId = q; - for (int i = nameIds.size() - 1; i != -1; --i) { - currentId = new (pool) AST::UiQualifiedId(currentId, nameIds[i]); - currentId->identifierToken = locations[i]; - } - - return currentId->finish(); - } - - return 0; -} - -bool Parser::parse(int startToken) -{ - Lexer *lexer = driver->lexer(); - bool hadErrors = false; - int yytoken = -1; - int action = 0; - - token_buffer[0].token = startToken; - first_token = &token_buffer[0]; - last_token = &token_buffer[1]; - - tos = -1; - program = 0; - - do { - if (++tos == stack_size) - reallocateStack(); - - state_stack[tos] = action; - - _Lcheck_token: - if (yytoken == -1 && -TERMINAL_COUNT != action_index[action]) { - yyprevlloc = yylloc; - - if (first_token == last_token) { - yytoken = lexer->lex(); - yylval = lexer->tokenValue(); - yytokenspell = lexer->tokenSpell(); - yylloc = location(lexer); - } else { - yytoken = first_token->token; - yylval = first_token->dval; - yytokenspell = first_token->spell; - yylloc = first_token->loc; - ++first_token; - } - } - - action = t_action(action, yytoken); - if (action > 0) { - if (action != ACCEPT_STATE) { - yytoken = -1; - sym(1).dval = yylval; - stringRef(1) = yytokenspell; - loc(1) = yylloc; - } else { - --tos; - return ! hadErrors; - } - } else if (action < 0) { - const int r = -action - 1; - tos -= rhs[r]; - - switch (r) { - -case 0: { - sym(1).Node = sym(2).Node; - program = sym(1).Node; -} break; - -case 1: { - sym(1).Node = sym(2).Node; - program = sym(1).Node; -} break; - -case 2: { - sym(1).Node = sym(2).Node; - program = sym(1).Node; -} break; - -case 3: { - sym(1).Node = sym(2).Node; - program = sym(1).Node; -} break; - -case 4: { - sym(1).Node = sym(2).Node; - program = sym(1).Node; -} break; - -case 5: { - sym(1).Node = sym(2).Node; - program = sym(1).Node; -} break; - -case 6: { - sym(1).UiProgram = new (pool) AST::UiProgram(sym(1).UiImportList, - sym(2).UiObjectMemberList->finish()); -} break; - -case 8: { - sym(1).Node = sym(1).UiImportList->finish(); -} break; - -case 9: { - sym(1).Node = new (pool) AST::UiImportList(sym(1).UiImport); -} break; - -case 10: { - sym(1).Node = new (pool) AST::UiImportList(sym(1).UiImportList, sym(2).UiImport); -} break; - -case 13: { - sym(1).UiImport->semicolonToken = loc(2); -} break; - -case 15: { - sym(1).UiImport->versionToken = loc(2); - sym(1).UiImport->semicolonToken = loc(3); -} break; - -case 17: { - sym(1).UiImport->versionToken = loc(2); - sym(1).UiImport->asToken = loc(3); - sym(1).UiImport->importIdToken = loc(4); - sym(1).UiImport->importId = stringRef(4); - sym(1).UiImport->semicolonToken = loc(5); -} break; - -case 19: { - sym(1).UiImport->asToken = loc(2); - sym(1).UiImport->importIdToken = loc(3); - sym(1).UiImport->importId = stringRef(3); - sym(1).UiImport->semicolonToken = loc(4); -} break; - -case 20: { - AST::UiImport *node = 0; - - if (AST::StringLiteral *importIdLiteral = AST::cast(sym(2).Expression)) { - node = new (pool) AST::UiImport(importIdLiteral->value); - node->fileNameToken = loc(2); - } else if (AST::UiQualifiedId *qualifiedId = reparseAsQualifiedId(sym(2).Expression)) { - node = new (pool) AST::UiImport(qualifiedId); - node->fileNameToken = loc(2); - } - - sym(1).Node = node; - - if (node) { - node->importToken = loc(1); - } else { - diagnostic_messages.append(DiagnosticMessage(DiagnosticMessage::Error, loc(1), - QLatin1String("Expected a qualified name id or a string literal"))); - - return false; // ### remove me - } -} break; - -case 21: { - sym(1).Node = 0; -} break; - -case 22: { - sym(1).Node = new (pool) AST::UiObjectMemberList(sym(1).UiObjectMember); -} break; - -case 23: { - sym(1).Node = new (pool) AST::UiObjectMemberList(sym(1).UiObjectMember); -} break; - -case 24: { - AST::UiObjectMemberList *node = new (pool) AST:: UiObjectMemberList( - sym(1).UiObjectMemberList, sym(2).UiObjectMember); - sym(1).Node = node; -} break; - -case 25: { - sym(1).Node = new (pool) AST::UiArrayMemberList(sym(1).UiObjectMember); -} break; - -case 26: { - AST::UiArrayMemberList *node = new (pool) AST::UiArrayMemberList( - sym(1).UiArrayMemberList, sym(3).UiObjectMember); - node->commaToken = loc(2); - sym(1).Node = node; -} break; - -case 27: { - AST::UiObjectInitializer *node = new (pool) AST::UiObjectInitializer((AST::UiObjectMemberList*)0); - node->lbraceToken = loc(1); - node->rbraceToken = loc(2); - sym(1).Node = node; -} break; - -case 28: { - AST::UiObjectInitializer *node = new (pool) AST::UiObjectInitializer(sym(2).UiObjectMemberList->finish()); - node->lbraceToken = loc(1); - node->rbraceToken = loc(3); - sym(1).Node = node; -} break; - -case 29: { - AST::UiObjectDefinition *node = new (pool) AST::UiObjectDefinition(sym(1).UiQualifiedId, - sym(2).UiObjectInitializer); - sym(1).Node = node; -} break; - -case 31: { - AST::UiArrayBinding *node = new (pool) AST::UiArrayBinding( - sym(1).UiQualifiedId, sym(4).UiArrayMemberList->finish()); - node->colonToken = loc(2); - node->lbracketToken = loc(3); - node->rbracketToken = loc(5); - sym(1).Node = node; -} break; - -case 32: { - AST::UiObjectBinding *node = new (pool) AST::UiObjectBinding( - sym(1).UiQualifiedId, sym(3).UiQualifiedId, sym(4).UiObjectInitializer); - node->colonToken = loc(2); - sym(1).Node = node; -} break; - -case 33: { - AST::UiObjectBinding *node = new (pool) AST::UiObjectBinding( - sym(3).UiQualifiedId, sym(1).UiQualifiedId, sym(4).UiObjectInitializer); - node->colonToken = loc(2); - node->hasOnToken = true; - sym(1).Node = node; -} break; - -case 41: -{ - AST::UiScriptBinding *node = new (pool) AST::UiScriptBinding( - sym(1).UiQualifiedId, sym(3).Statement); - node->colonToken = loc(2); - sym(1).Node = node; -} break; - -case 45: { - sym(1).Node = 0; -} break; - -case 46: { - sym(1).Node = sym(1).UiParameterList->finish (); -} break; - -case 47: { - AST::UiParameterList *node = new (pool) AST::UiParameterList(stringRef(1), stringRef(2)); - node->propertyTypeToken = loc(1); - node->identifierToken = loc(2); - sym(1).Node = node; -} break; - -case 48: { - AST::UiParameterList *node = new (pool) AST::UiParameterList(sym(1).UiParameterList, stringRef(3), stringRef(4)); - node->commaToken = loc(2); - node->identifierToken = loc(4); - sym(1).Node = node; -} break; - -case 50: { - AST::UiPublicMember *node = new (pool) AST::UiPublicMember(QStringRef(), stringRef(2)); - node->type = AST::UiPublicMember::Signal; - node->propertyToken = loc(1); - node->typeToken = loc(2); - node->identifierToken = loc(2); - node->parameters = sym(4).UiParameterList; - node->semicolonToken = loc(6); - sym(1).Node = node; -} break; - -case 52: { - AST::UiPublicMember *node = new (pool) AST::UiPublicMember(QStringRef(), stringRef(2)); - node->type = AST::UiPublicMember::Signal; - node->propertyToken = loc(1); - node->typeToken = loc(2); - node->identifierToken = loc(2); - node->semicolonToken = loc(3); - sym(1).Node = node; -} break; - -case 54: { - AST::UiPublicMember *node = new (pool) AST::UiPublicMember(stringRef(4), stringRef(6)); - node->typeModifier = stringRef(2); - node->propertyToken = loc(1); - node->typeModifierToken = loc(2); - node->typeToken = loc(4); - node->identifierToken = loc(6); - node->semicolonToken = loc(7); - sym(1).Node = node; -} break; - -case 56: { - AST::UiPublicMember *node = new (pool) AST::UiPublicMember(stringRef(2), stringRef(3)); - node->propertyToken = loc(1); - node->typeToken = loc(2); - node->identifierToken = loc(3); - node->semicolonToken = loc(4); - sym(1).Node = node; -} break; - -case 58: { - AST::UiPublicMember *node = new (pool) AST::UiPublicMember(stringRef(3), stringRef(4)); - node->isDefaultMember = true; - node->defaultToken = loc(1); - node->propertyToken = loc(2); - node->typeToken = loc(3); - node->identifierToken = loc(4); - node->semicolonToken = loc(5); - sym(1).Node = node; -} break; - -case 59: { - AST::UiPublicMember *node = new (pool) AST::UiPublicMember(stringRef(2), stringRef(3), - sym(5).Statement); - node->propertyToken = loc(1); - node->typeToken = loc(2); - node->identifierToken = loc(3); - node->colonToken = loc(4); - sym(1).Node = node; -} break; - -case 60: { - AST::UiPublicMember *node = new (pool) AST::UiPublicMember(stringRef(3), stringRef(4), - sym(6).Statement); - node->isReadonlyMember = true; - node->readonlyToken = loc(1); - node->propertyToken = loc(2); - node->typeToken = loc(3); - node->identifierToken = loc(4); - node->colonToken = loc(5); - sym(1).Node = node; -} break; - -case 61: { - AST::UiPublicMember *node = new (pool) AST::UiPublicMember(stringRef(3), stringRef(4), - sym(6).Statement); - node->isDefaultMember = true; - node->defaultToken = loc(1); - node->propertyToken = loc(2); - node->typeToken = loc(3); - node->identifierToken = loc(4); - node->colonToken = loc(5); - sym(1).Node = node; -} break; - -case 62: { - AST::UiPublicMember *node = new (pool) AST::UiPublicMember(stringRef(4), stringRef(6)); - node->typeModifier = stringRef(2); - node->propertyToken = loc(1); - node->typeModifierToken = loc(2); - node->typeToken = loc(4); - node->identifierToken = loc(6); - node->semicolonToken = loc(7); // insert a fake ';' before ':' - - AST::UiQualifiedId *propertyName = new (pool) AST::UiQualifiedId(stringRef(6)); - propertyName->identifierToken = loc(6); - propertyName->next = 0; - - AST::UiArrayBinding *binding = new (pool) AST::UiArrayBinding( - propertyName, sym(9).UiArrayMemberList->finish()); - binding->colonToken = loc(7); - binding->lbracketToken = loc(8); - binding->rbracketToken = loc(10); - - node->binding = binding; - - sym(1).Node = node; -} break; - -case 63: { - AST::UiPublicMember *node = new (pool) AST::UiPublicMember(stringRef(2), stringRef(3)); - node->propertyToken = loc(1); - node->typeToken = loc(2); - node->identifierToken = loc(3); - node->semicolonToken = loc(4); // insert a fake ';' before ':' - - AST::UiQualifiedId *propertyName = new (pool) AST::UiQualifiedId(stringRef(3)); - propertyName->identifierToken = loc(3); - propertyName->next = 0; - - AST::UiObjectBinding *binding = new (pool) AST::UiObjectBinding( - propertyName, sym(5).UiQualifiedId, sym(6).UiObjectInitializer); - binding->colonToken = loc(4); - - node->binding = binding; - - sym(1).Node = node; -} break; - -case 64: { - sym(1).Node = new (pool) AST::UiSourceElement(sym(1).Node); -} break; - -case 65: { - sym(1).Node = new (pool) AST::UiSourceElement(sym(1).Node); -} break; - -case 71: { - AST::ThisExpression *node = new (pool) AST::ThisExpression(); - node->thisToken = loc(1); - sym(1).Node = node; -} break; - -case 72: { - AST::IdentifierExpression *node = new (pool) AST::IdentifierExpression(stringRef(1)); - node->identifierToken = loc(1); - sym(1).Node = node; -} break; - -case 73: { - AST::NullExpression *node = new (pool) AST::NullExpression(); - node->nullToken = loc(1); - sym(1).Node = node; -} break; - -case 74: { - AST::TrueLiteral *node = new (pool) AST::TrueLiteral(); - node->trueToken = loc(1); - sym(1).Node = node; -} break; - -case 75: { - AST::FalseLiteral *node = new (pool) AST::FalseLiteral(); - node->falseToken = loc(1); - sym(1).Node = node; -} break; - -case 76: { - AST::NumericLiteral *node = new (pool) AST::NumericLiteral(sym(1).dval); - node->literalToken = loc(1); - sym(1).Node = node; -} break; -case 77: -case 78: { - AST::StringLiteral *node = new (pool) AST::StringLiteral(stringRef(1)); - node->literalToken = loc(1); - sym(1).Node = node; -} break; - -case 79: { - bool rx = lexer->scanRegExp(Lexer::NoPrefix); - if (!rx) { - diagnostic_messages.append(DiagnosticMessage(DiagnosticMessage::Error, location(lexer), lexer->errorMessage())); - return false; // ### remove me - } - - loc(1).length = lexer->tokenLength(); - yylloc = loc(1); // adjust the location of the current token - - AST::RegExpLiteral *node = new (pool) AST::RegExpLiteral( - driver->newStringRef(lexer->regExpPattern()), lexer->regExpFlags()); - node->literalToken = loc(1); - sym(1).Node = node; -} break; - -case 80: { - bool rx = lexer->scanRegExp(Lexer::EqualPrefix); - if (!rx) { - diagnostic_messages.append(DiagnosticMessage(DiagnosticMessage::Error, location(lexer), lexer->errorMessage())); - return false; - } - - loc(1).length = lexer->tokenLength(); - yylloc = loc(1); // adjust the location of the current token - - AST::RegExpLiteral *node = new (pool) AST::RegExpLiteral( - driver->newStringRef(lexer->regExpPattern()), lexer->regExpFlags()); - node->literalToken = loc(1); - sym(1).Node = node; -} break; - -case 81: { - AST::ArrayLiteral *node = new (pool) AST::ArrayLiteral((AST::Elision *) 0); - node->lbracketToken = loc(1); - node->rbracketToken = loc(2); - sym(1).Node = node; -} break; - -case 82: { - AST::ArrayLiteral *node = new (pool) AST::ArrayLiteral(sym(2).Elision->finish()); - node->lbracketToken = loc(1); - node->rbracketToken = loc(3); - sym(1).Node = node; -} break; - -case 83: { - AST::ArrayLiteral *node = new (pool) AST::ArrayLiteral(sym(2).ElementList->finish ()); - node->lbracketToken = loc(1); - node->rbracketToken = loc(3); - sym(1).Node = node; -} break; - -case 84: { - AST::ArrayLiteral *node = new (pool) AST::ArrayLiteral(sym(2).ElementList->finish (), - (AST::Elision *) 0); - node->lbracketToken = loc(1); - node->commaToken = loc(3); - node->rbracketToken = loc(4); - sym(1).Node = node; -} break; - -case 85: { - AST::ArrayLiteral *node = new (pool) AST::ArrayLiteral(sym(2).ElementList->finish (), - sym(4).Elision->finish()); - node->lbracketToken = loc(1); - node->commaToken = loc(3); - node->rbracketToken = loc(5); - sym(1).Node = node; -} break; - -case 86: { - AST::ObjectLiteral *node = 0; - if (sym(2).Node) - node = new (pool) AST::ObjectLiteral( - sym(2).PropertyNameAndValueList->finish ()); - else - node = new (pool) AST::ObjectLiteral(); - node->lbraceToken = loc(1); - node->rbraceToken = loc(3); - sym(1).Node = node; -} break; - -case 87: { - AST::ObjectLiteral *node = new (pool) AST::ObjectLiteral( - sym(2).PropertyNameAndValueList->finish ()); - node->lbraceToken = loc(1); - node->rbraceToken = loc(4); - sym(1).Node = node; -} break; - -case 88: { - AST::NestedExpression *node = new (pool) AST::NestedExpression(sym(2).Expression); - node->lparenToken = loc(1); - node->rparenToken = loc(3); - sym(1).Node = node; -} break; - -case 89: { - if (AST::ArrayMemberExpression *mem = AST::cast(sym(1).Expression)) { - diagnostic_messages.append(DiagnosticMessage(DiagnosticMessage::Warning, mem->lbracketToken, - QLatin1String("Ignored annotation"))); - - sym(1).Expression = mem->base; - } - - if (AST::UiQualifiedId *qualifiedId = reparseAsQualifiedId(sym(1).Expression)) { - sym(1).UiQualifiedId = qualifiedId; - } else { - sym(1).UiQualifiedId = 0; - - diagnostic_messages.append(DiagnosticMessage(DiagnosticMessage::Error, loc(1), - QLatin1String("Expected a qualified name id"))); - - return false; // ### recover - } -} break; - -case 90: { - sym(1).Node = new (pool) AST::ElementList((AST::Elision *) 0, sym(1).Expression); -} break; - -case 91: { - sym(1).Node = new (pool) AST::ElementList(sym(1).Elision->finish(), sym(2).Expression); -} break; - -case 92: { - AST::ElementList *node = new (pool) AST::ElementList(sym(1).ElementList, - (AST::Elision *) 0, sym(3).Expression); - node->commaToken = loc(2); - sym(1).Node = node; -} break; - -case 93: { - AST::ElementList *node = new (pool) AST::ElementList(sym(1).ElementList, sym(3).Elision->finish(), - sym(4).Expression); - node->commaToken = loc(2); - sym(1).Node = node; -} break; - -case 94: { - AST::Elision *node = new (pool) AST::Elision(); - node->commaToken = loc(1); - sym(1).Node = node; -} break; - -case 95: { - AST::Elision *node = new (pool) AST::Elision(sym(1).Elision); - node->commaToken = loc(2); - sym(1).Node = node; -} break; - -case 96: { - AST::PropertyNameAndValueList *node = new (pool) AST::PropertyNameAndValueList( - sym(1).PropertyName, sym(3).Expression); - node->colonToken = loc(2); - sym(1).Node = node; -} break; - -case 97: { - AST::PropertyNameAndValueList *node = new (pool) AST::PropertyNameAndValueList( - sym(1).PropertyNameAndValueList, sym(3).PropertyName, sym(5).Expression); - node->commaToken = loc(2); - node->colonToken = loc(4); - sym(1).Node = node; -} break; - -case 98: { - AST::IdentifierPropertyName *node = new (pool) AST::IdentifierPropertyName(stringRef(1)); - node->propertyNameToken = loc(1); - sym(1).Node = node; -} break; -case 99: -case 100: { - AST::IdentifierPropertyName *node = new (pool) AST::IdentifierPropertyName(stringRef(1)); - node->propertyNameToken = loc(1); - sym(1).Node = node; -} break; - -case 101: { - AST::StringLiteralPropertyName *node = new (pool) AST::StringLiteralPropertyName(stringRef(1)); - node->propertyNameToken = loc(1); - sym(1).Node = node; -} break; - -case 102: { - AST::NumericLiteralPropertyName *node = new (pool) AST::NumericLiteralPropertyName(sym(1).dval); - node->propertyNameToken = loc(1); - sym(1).Node = node; -} break; - -case 103: { - AST::IdentifierPropertyName *node = new (pool) AST::IdentifierPropertyName(stringRef(1)); - node->propertyNameToken = loc(1); - sym(1).Node = node; -} break; - -case 139: { - AST::ArrayMemberExpression *node = new (pool) AST::ArrayMemberExpression(sym(1).Expression, sym(3).Expression); - node->lbracketToken = loc(2); - node->rbracketToken = loc(4); - sym(1).Node = node; -} break; - -case 140: { - AST::FieldMemberExpression *node = new (pool) AST::FieldMemberExpression(sym(1).Expression, stringRef(3)); - node->dotToken = loc(2); - node->identifierToken = loc(3); - sym(1).Node = node; -} break; - -case 141: { - AST::NewMemberExpression *node = new (pool) AST::NewMemberExpression(sym(2).Expression, sym(4).ArgumentList); - node->newToken = loc(1); - node->lparenToken = loc(3); - node->rparenToken = loc(5); - sym(1).Node = node; -} break; - -case 143: { - AST::NewExpression *node = new (pool) AST::NewExpression(sym(2).Expression); - node->newToken = loc(1); - sym(1).Node = node; -} break; - -case 144: { - AST::CallExpression *node = new (pool) AST::CallExpression(sym(1).Expression, sym(3).ArgumentList); - node->lparenToken = loc(2); - node->rparenToken = loc(4); - sym(1).Node = node; -} break; - -case 145: { - AST::CallExpression *node = new (pool) AST::CallExpression(sym(1).Expression, sym(3).ArgumentList); - node->lparenToken = loc(2); - node->rparenToken = loc(4); - sym(1).Node = node; -} break; - -case 146: { - AST::ArrayMemberExpression *node = new (pool) AST::ArrayMemberExpression(sym(1).Expression, sym(3).Expression); - node->lbracketToken = loc(2); - node->rbracketToken = loc(4); - sym(1).Node = node; -} break; - -case 147: { - AST::FieldMemberExpression *node = new (pool) AST::FieldMemberExpression(sym(1).Expression, stringRef(3)); - node->dotToken = loc(2); - node->identifierToken = loc(3); - sym(1).Node = node; -} break; - -case 148: { - sym(1).Node = 0; -} break; - -case 149: { - sym(1).Node = sym(1).ArgumentList->finish(); -} break; - -case 150: { - sym(1).Node = new (pool) AST::ArgumentList(sym(1).Expression); -} break; - -case 151: { - AST::ArgumentList *node = new (pool) AST::ArgumentList(sym(1).ArgumentList, sym(3).Expression); - node->commaToken = loc(2); - sym(1).Node = node; -} break; - -case 155: { - AST::PostIncrementExpression *node = new (pool) AST::PostIncrementExpression(sym(1).Expression); - node->incrementToken = loc(2); - sym(1).Node = node; -} break; - -case 156: { - AST::PostDecrementExpression *node = new (pool) AST::PostDecrementExpression(sym(1).Expression); - node->decrementToken = loc(2); - sym(1).Node = node; -} break; - -case 158: { - AST::DeleteExpression *node = new (pool) AST::DeleteExpression(sym(2).Expression); - node->deleteToken = loc(1); - sym(1).Node = node; -} break; - -case 159: { - AST::VoidExpression *node = new (pool) AST::VoidExpression(sym(2).Expression); - node->voidToken = loc(1); - sym(1).Node = node; -} break; - -case 160: { - AST::TypeOfExpression *node = new (pool) AST::TypeOfExpression(sym(2).Expression); - node->typeofToken = loc(1); - sym(1).Node = node; -} break; - -case 161: { - AST::PreIncrementExpression *node = new (pool) AST::PreIncrementExpression(sym(2).Expression); - node->incrementToken = loc(1); - sym(1).Node = node; -} break; - -case 162: { - AST::PreDecrementExpression *node = new (pool) AST::PreDecrementExpression(sym(2).Expression); - node->decrementToken = loc(1); - sym(1).Node = node; -} break; - -case 163: { - AST::UnaryPlusExpression *node = new (pool) AST::UnaryPlusExpression(sym(2).Expression); - node->plusToken = loc(1); - sym(1).Node = node; -} break; - -case 164: { - AST::UnaryMinusExpression *node = new (pool) AST::UnaryMinusExpression(sym(2).Expression); - node->minusToken = loc(1); - sym(1).Node = node; -} break; - -case 165: { - AST::TildeExpression *node = new (pool) AST::TildeExpression(sym(2).Expression); - node->tildeToken = loc(1); - sym(1).Node = node; -} break; - -case 166: { - AST::NotExpression *node = new (pool) AST::NotExpression(sym(2).Expression); - node->notToken = loc(1); - sym(1).Node = node; -} break; - -case 168: { - AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, - QSOperator::Mul, sym(3).Expression); - node->operatorToken = loc(2); - sym(1).Node = node; -} break; - -case 169: { - AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, - QSOperator::Div, sym(3).Expression); - node->operatorToken = loc(2); - sym(1).Node = node; -} break; - -case 170: { - AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, - QSOperator::Mod, sym(3).Expression); - node->operatorToken = loc(2); - sym(1).Node = node; -} break; - -case 172: { - AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, - QSOperator::Add, sym(3).Expression); - node->operatorToken = loc(2); - sym(1).Node = node; -} break; - -case 173: { - AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, - QSOperator::Sub, sym(3).Expression); - node->operatorToken = loc(2); - sym(1).Node = node; -} break; - -case 175: { - AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, - QSOperator::LShift, sym(3).Expression); - node->operatorToken = loc(2); - sym(1).Node = node; -} break; - -case 176: { - AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, - QSOperator::RShift, sym(3).Expression); - node->operatorToken = loc(2); - sym(1).Node = node; -} break; - -case 177: { - AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, - QSOperator::URShift, sym(3).Expression); - node->operatorToken = loc(2); - sym(1).Node = node; -} break; - -case 179: { - AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, - QSOperator::Lt, sym(3).Expression); - node->operatorToken = loc(2); - sym(1).Node = node; -} break; - -case 180: { - AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, - QSOperator::Gt, sym(3).Expression); - node->operatorToken = loc(2); - sym(1).Node = node; -} break; - -case 181: { - AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, - QSOperator::Le, sym(3).Expression); - node->operatorToken = loc(2); - sym(1).Node = node; -} break; - -case 182: { - AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, - QSOperator::Ge, sym(3).Expression); - node->operatorToken = loc(2); - sym(1).Node = node; -} break; - -case 183: { - AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, - QSOperator::InstanceOf, sym(3).Expression); - node->operatorToken = loc(2); - sym(1).Node = node; -} break; - -case 184: { - AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, - QSOperator::In, sym(3).Expression); - node->operatorToken = loc(2); - sym(1).Node = node; -} break; - -case 186: { - AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, - QSOperator::Lt, sym(3).Expression); - node->operatorToken = loc(2); - sym(1).Node = node; -} break; - -case 187: { - AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, - QSOperator::Gt, sym(3).Expression); - node->operatorToken = loc(2); - sym(1).Node = node; -} break; - -case 188: { - AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, - QSOperator::Le, sym(3).Expression); - node->operatorToken = loc(2); - sym(1).Node = node; -} break; - -case 189: { - AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, - QSOperator::Ge, sym(3).Expression); - node->operatorToken = loc(2); - sym(1).Node = node; -} break; - -case 190: { - AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, - QSOperator::InstanceOf, sym(3).Expression); - node->operatorToken = loc(2); - sym(1).Node = node; -} break; - -case 192: { - AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, - QSOperator::Equal, sym(3).Expression); - node->operatorToken = loc(2); - sym(1).Node = node; -} break; - -case 193: { - AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, - QSOperator::NotEqual, sym(3).Expression); - node->operatorToken = loc(2); - sym(1).Node = node; -} break; - -case 194: { - AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, - QSOperator::StrictEqual, sym(3).Expression); - node->operatorToken = loc(2); - sym(1).Node = node; -} break; - -case 195: { - AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, - QSOperator::StrictNotEqual, sym(3).Expression); - node->operatorToken = loc(2); - sym(1).Node = node; -} break; - -case 197: { - AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, - QSOperator::Equal, sym(3).Expression); - node->operatorToken = loc(2); - sym(1).Node = node; -} break; - -case 198: { - AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, - QSOperator::NotEqual, sym(3).Expression); - node->operatorToken = loc(2); - sym(1).Node = node; -} break; - -case 199: { - AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, - QSOperator::StrictEqual, sym(3).Expression); - node->operatorToken = loc(2); - sym(1).Node = node; -} break; - -case 200: { - AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, - QSOperator::StrictNotEqual, sym(3).Expression); - node->operatorToken = loc(2); - sym(1).Node = node; -} break; - -case 202: { - AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, - QSOperator::BitAnd, sym(3).Expression); - node->operatorToken = loc(2); - sym(1).Node = node; -} break; - -case 204: { - AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, - QSOperator::BitAnd, sym(3).Expression); - node->operatorToken = loc(2); - sym(1).Node = node; -} break; - -case 206: { - AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, - QSOperator::BitXor, sym(3).Expression); - node->operatorToken = loc(2); - sym(1).Node = node; -} break; - -case 208: { - AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, - QSOperator::BitXor, sym(3).Expression); - node->operatorToken = loc(2); - sym(1).Node = node; -} break; - -case 210: { - AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, - QSOperator::BitOr, sym(3).Expression); - node->operatorToken = loc(2); - sym(1).Node = node; -} break; - -case 212: { - AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, - QSOperator::BitOr, sym(3).Expression); - node->operatorToken = loc(2); - sym(1).Node = node; -} break; - -case 214: { - AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, - QSOperator::And, sym(3).Expression); - node->operatorToken = loc(2); - sym(1).Node = node; -} break; - -case 216: { - AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, - QSOperator::And, sym(3).Expression); - node->operatorToken = loc(2); - sym(1).Node = node; -} break; - -case 218: { - AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, - QSOperator::Or, sym(3).Expression); - node->operatorToken = loc(2); - sym(1).Node = node; -} break; - -case 220: { - AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, - QSOperator::Or, sym(3).Expression); - node->operatorToken = loc(2); - sym(1).Node = node; -} break; - -case 222: { - AST::ConditionalExpression *node = new (pool) AST::ConditionalExpression(sym(1).Expression, - sym(3).Expression, sym(5).Expression); - node->questionToken = loc(2); - node->colonToken = loc(4); - sym(1).Node = node; -} break; - -case 224: { - AST::ConditionalExpression *node = new (pool) AST::ConditionalExpression(sym(1).Expression, - sym(3).Expression, sym(5).Expression); - node->questionToken = loc(2); - node->colonToken = loc(4); - sym(1).Node = node; -} break; - -case 226: { - AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, - sym(2).ival, sym(3).Expression); - node->operatorToken = loc(2); - sym(1).Node = node; -} break; - -case 228: { - AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, - sym(2).ival, sym(3).Expression); - node->operatorToken = loc(2); - sym(1).Node = node; -} break; - -case 229: { - sym(1).ival = QSOperator::Assign; -} break; - -case 230: { - sym(1).ival = QSOperator::InplaceMul; -} break; - -case 231: { - sym(1).ival = QSOperator::InplaceDiv; -} break; - -case 232: { - sym(1).ival = QSOperator::InplaceMod; -} break; - -case 233: { - sym(1).ival = QSOperator::InplaceAdd; -} break; - -case 234: { - sym(1).ival = QSOperator::InplaceSub; -} break; - -case 235: { - sym(1).ival = QSOperator::InplaceLeftShift; -} break; - -case 236: { - sym(1).ival = QSOperator::InplaceRightShift; -} break; - -case 237: { - sym(1).ival = QSOperator::InplaceURightShift; -} break; - -case 238: { - sym(1).ival = QSOperator::InplaceAnd; -} break; - -case 239: { - sym(1).ival = QSOperator::InplaceXor; -} break; - -case 240: { - sym(1).ival = QSOperator::InplaceOr; -} break; - -case 242: { - AST::Expression *node = new (pool) AST::Expression(sym(1).Expression, sym(3).Expression); - node->commaToken = loc(2); - sym(1).Node = node; -} break; - -case 243: { - sym(1).Node = 0; -} break; - -case 246: { - AST::Expression *node = new (pool) AST::Expression(sym(1).Expression, sym(3).Expression); - node->commaToken = loc(2); - sym(1).Node = node; -} break; - -case 247: { - sym(1).Node = 0; -} break; - -case 264: { - AST::Block *node = new (pool) AST::Block(sym(2).StatementList); - node->lbraceToken = loc(1); - node->rbraceToken = loc(3); - sym(1).Node = node; -} break; - -case 265: { - sym(1).Node = new (pool) AST::StatementList(sym(1).Statement); -} break; - -case 266: { - sym(1).Node = new (pool) AST::StatementList(sym(1).StatementList, sym(2).Statement); -} break; - -case 267: { - sym(1).Node = 0; -} break; - -case 268: { - sym(1).Node = sym(1).StatementList->finish (); -} break; - -case 270: { - AST::VariableStatement *node = new (pool) AST::VariableStatement( - sym(2).VariableDeclarationList->finish (/*readOnly=*/sym(1).ival == T_CONST)); - node->declarationKindToken = loc(1); - node->semicolonToken = loc(3); - sym(1).Node = node; -} break; - -case 271: { - sym(1).ival = T_CONST; -} break; - -case 272: { - sym(1).ival = T_VAR; -} break; - -case 273: { - sym(1).Node = new (pool) AST::VariableDeclarationList(sym(1).VariableDeclaration); -} break; - -case 274: { - AST::VariableDeclarationList *node = new (pool) AST::VariableDeclarationList( - sym(1).VariableDeclarationList, sym(3).VariableDeclaration); - node->commaToken = loc(2); - sym(1).Node = node; -} break; - -case 275: { - sym(1).Node = new (pool) AST::VariableDeclarationList(sym(1).VariableDeclaration); -} break; - -case 276: { - sym(1).Node = new (pool) AST::VariableDeclarationList(sym(1).VariableDeclarationList, sym(3).VariableDeclaration); -} break; - -case 277: { - AST::VariableDeclaration *node = new (pool) AST::VariableDeclaration(stringRef(1), sym(2).Expression); - node->identifierToken = loc(1); - sym(1).Node = node; -} break; - -case 278: { - AST::VariableDeclaration *node = new (pool) AST::VariableDeclaration(stringRef(1), sym(2).Expression); - node->identifierToken = loc(1); - sym(1).Node = node; -} break; - -case 279: { - // ### TODO: AST for initializer - sym(1) = sym(2); -} break; - -case 280: { - sym(1).Node = 0; -} break; - -case 282: { - // ### TODO: AST for initializer - sym(1) = sym(2); -} break; - -case 283: { - sym(1).Node = 0; -} break; - -case 285: { - AST::EmptyStatement *node = new (pool) AST::EmptyStatement(); - node->semicolonToken = loc(1); - sym(1).Node = node; -} break; - -case 287: { - AST::ExpressionStatement *node = new (pool) AST::ExpressionStatement(sym(1).Expression); - node->semicolonToken = loc(2); - sym(1).Node = node; -} break; - -case 288: { - AST::IfStatement *node = new (pool) AST::IfStatement(sym(3).Expression, sym(5).Statement, sym(7).Statement); - node->ifToken = loc(1); - node->lparenToken = loc(2); - node->rparenToken = loc(4); - node->elseToken = loc(6); - sym(1).Node = node; -} break; - -case 289: { - AST::IfStatement *node = new (pool) AST::IfStatement(sym(3).Expression, sym(5).Statement); - node->ifToken = loc(1); - node->lparenToken = loc(2); - node->rparenToken = loc(4); - sym(1).Node = node; -} break; - -case 291: { - AST::DoWhileStatement *node = new (pool) AST::DoWhileStatement(sym(2).Statement, sym(5).Expression); - node->doToken = loc(1); - node->whileToken = loc(3); - node->lparenToken = loc(4); - node->rparenToken = loc(6); - node->semicolonToken = loc(7); - sym(1).Node = node; -} break; - -case 292: { - AST::WhileStatement *node = new (pool) AST::WhileStatement(sym(3).Expression, sym(5).Statement); - node->whileToken = loc(1); - node->lparenToken = loc(2); - node->rparenToken = loc(4); - sym(1).Node = node; -} break; - -case 293: { - AST::ForStatement *node = new (pool) AST::ForStatement(sym(3).Expression, - sym(5).Expression, sym(7).Expression, sym(9).Statement); - node->forToken = loc(1); - node->lparenToken = loc(2); - node->firstSemicolonToken = loc(4); - node->secondSemicolonToken = loc(6); - node->rparenToken = loc(8); - sym(1).Node = node; -} break; - -case 294: { - AST::LocalForStatement *node = new (pool) AST::LocalForStatement( - sym(4).VariableDeclarationList->finish (/*readOnly=*/false), sym(6).Expression, - sym(8).Expression, sym(10).Statement); - node->forToken = loc(1); - node->lparenToken = loc(2); - node->varToken = loc(3); - node->firstSemicolonToken = loc(5); - node->secondSemicolonToken = loc(7); - node->rparenToken = loc(9); - sym(1).Node = node; -} break; - -case 295: { - AST:: ForEachStatement *node = new (pool) AST::ForEachStatement(sym(3).Expression, - sym(5).Expression, sym(7).Statement); - node->forToken = loc(1); - node->lparenToken = loc(2); - node->inToken = loc(4); - node->rparenToken = loc(6); - sym(1).Node = node; -} break; - -case 296: { - AST::LocalForEachStatement *node = new (pool) AST::LocalForEachStatement( - sym(4).VariableDeclaration, sym(6).Expression, sym(8).Statement); - node->forToken = loc(1); - node->lparenToken = loc(2); - node->varToken = loc(3); - node->inToken = loc(5); - node->rparenToken = loc(7); - sym(1).Node = node; -} break; - -case 298: { - AST::ContinueStatement *node = new (pool) AST::ContinueStatement(); - node->continueToken = loc(1); - node->semicolonToken = loc(2); - sym(1).Node = node; -} break; - -case 300: { - AST::ContinueStatement *node = new (pool) AST::ContinueStatement(stringRef(2)); - node->continueToken = loc(1); - node->identifierToken = loc(2); - node->semicolonToken = loc(3); - sym(1).Node = node; -} break; - -case 302: { - AST::BreakStatement *node = new (pool) AST::BreakStatement(QStringRef()); - node->breakToken = loc(1); - node->semicolonToken = loc(2); - sym(1).Node = node; -} break; - -case 304: { - AST::BreakStatement *node = new (pool) AST::BreakStatement(stringRef(2)); - node->breakToken = loc(1); - node->identifierToken = loc(2); - node->semicolonToken = loc(3); - sym(1).Node = node; -} break; - -case 306: { - AST::ReturnStatement *node = new (pool) AST::ReturnStatement(sym(2).Expression); - node->returnToken = loc(1); - node->semicolonToken = loc(3); - sym(1).Node = node; -} break; - -case 307: { - AST::WithStatement *node = new (pool) AST::WithStatement(sym(3).Expression, sym(5).Statement); - node->withToken = loc(1); - node->lparenToken = loc(2); - node->rparenToken = loc(4); - sym(1).Node = node; -} break; - -case 308: { - AST::SwitchStatement *node = new (pool) AST::SwitchStatement(sym(3).Expression, sym(5).CaseBlock); - node->switchToken = loc(1); - node->lparenToken = loc(2); - node->rparenToken = loc(4); - sym(1).Node = node; -} break; - -case 309: { - AST::CaseBlock *node = new (pool) AST::CaseBlock(sym(2).CaseClauses); - node->lbraceToken = loc(1); - node->rbraceToken = loc(3); - sym(1).Node = node; -} break; - -case 310: { - AST::CaseBlock *node = new (pool) AST::CaseBlock(sym(2).CaseClauses, sym(3).DefaultClause, sym(4).CaseClauses); - node->lbraceToken = loc(1); - node->rbraceToken = loc(5); - sym(1).Node = node; -} break; - -case 311: { - sym(1).Node = new (pool) AST::CaseClauses(sym(1).CaseClause); -} break; - -case 312: { - sym(1).Node = new (pool) AST::CaseClauses(sym(1).CaseClauses, sym(2).CaseClause); -} break; - -case 313: { - sym(1).Node = 0; -} break; - -case 314: { - sym(1).Node = sym(1).CaseClauses->finish (); -} break; - -case 315: { - AST::CaseClause *node = new (pool) AST::CaseClause(sym(2).Expression, sym(4).StatementList); - node->caseToken = loc(1); - node->colonToken = loc(3); - sym(1).Node = node; -} break; - -case 316: { - AST::DefaultClause *node = new (pool) AST::DefaultClause(sym(3).StatementList); - node->defaultToken = loc(1); - node->colonToken = loc(2); - sym(1).Node = node; -} break; -case 317: -case 318: { - AST::LabelledStatement *node = new (pool) AST::LabelledStatement(stringRef(1), sym(3).Statement); - node->identifierToken = loc(1); - node->colonToken = loc(2); - sym(1).Node = node; -} break; - -case 319: { - AST::LabelledStatement *node = new (pool) AST::LabelledStatement(stringRef(1), sym(3).Statement); - node->identifierToken = loc(1); - node->colonToken = loc(2); - sym(1).Node = node; -} break; - -case 321: { - AST::ThrowStatement *node = new (pool) AST::ThrowStatement(sym(2).Expression); - node->throwToken = loc(1); - node->semicolonToken = loc(3); - sym(1).Node = node; -} break; - -case 322: { - AST::TryStatement *node = new (pool) AST::TryStatement(sym(2).Statement, sym(3).Catch); - node->tryToken = loc(1); - sym(1).Node = node; -} break; - -case 323: { - AST::TryStatement *node = new (pool) AST::TryStatement(sym(2).Statement, sym(3).Finally); - node->tryToken = loc(1); - sym(1).Node = node; -} break; - -case 324: { - AST::TryStatement *node = new (pool) AST::TryStatement(sym(2).Statement, sym(3).Catch, sym(4).Finally); - node->tryToken = loc(1); - sym(1).Node = node; -} break; - -case 325: { - AST::Catch *node = new (pool) AST::Catch(stringRef(3), sym(5).Block); - node->catchToken = loc(1); - node->lparenToken = loc(2); - node->identifierToken = loc(3); - node->rparenToken = loc(4); - sym(1).Node = node; -} break; - -case 326: { - AST::Finally *node = new (pool) AST::Finally(sym(2).Block); - node->finallyToken = loc(1); - sym(1).Node = node; -} break; - -case 328: { - AST::DebuggerStatement *node = new (pool) AST::DebuggerStatement(); - node->debuggerToken = loc(1); - node->semicolonToken = loc(2); - sym(1).Node = node; -} break; - -case 329: { - AST::FunctionDeclaration *node = new (pool) AST::FunctionDeclaration(stringRef(2), sym(4).FormalParameterList, sym(7).FunctionBody); - node->functionToken = loc(1); - node->identifierToken = loc(2); - node->lparenToken = loc(3); - node->rparenToken = loc(5); - node->lbraceToken = loc(6); - node->rbraceToken = loc(8); - sym(1).Node = node; -} break; - -case 330: { - AST::FunctionExpression *node = new (pool) AST::FunctionExpression(stringRef(2), sym(4).FormalParameterList, sym(7).FunctionBody); - node->functionToken = loc(1); - if (! stringRef(2).isNull()) - node->identifierToken = loc(2); - node->lparenToken = loc(3); - node->rparenToken = loc(5); - node->lbraceToken = loc(6); - node->rbraceToken = loc(8); - sym(1).Node = node; -} break; - -case 331: { - AST::FormalParameterList *node = new (pool) AST::FormalParameterList(stringRef(1)); - node->identifierToken = loc(1); - sym(1).Node = node; -} break; - -case 332: { - AST::FormalParameterList *node = new (pool) AST::FormalParameterList(sym(1).FormalParameterList, stringRef(3)); - node->commaToken = loc(2); - node->identifierToken = loc(3); - sym(1).Node = node; -} break; - -case 333: { - sym(1).Node = 0; -} break; - -case 334: { - sym(1).Node = sym(1).FormalParameterList->finish (); -} break; - -case 335: { - sym(1).Node = 0; -} break; - -case 337: { - sym(1).Node = new (pool) AST::FunctionBody(sym(1).SourceElements->finish ()); -} break; - -case 339: { - sym(1).Node = new (pool) AST::Program(sym(1).SourceElements->finish ()); -} break; - -case 340: { - sym(1).Node = new (pool) AST::SourceElements(sym(1).SourceElement); -} break; - -case 341: { - sym(1).Node = new (pool) AST::SourceElements(sym(1).SourceElements, sym(2).SourceElement); -} break; - -case 342: { - sym(1).Node = new (pool) AST::StatementSourceElement(sym(1).Statement); -} break; - -case 343: { - sym(1).Node = new (pool) AST::FunctionSourceElement(sym(1).FunctionDeclaration); -} break; - -case 344: { - stringRef(1) = QStringRef(); -} break; - -case 346: { - sym(1).Node = 0; -} break; - - } // switch - action = nt_action(state_stack[tos], lhs[r] - TERMINAL_COUNT); - } // if - } while (action != 0); - - if (first_token == last_token) { - const int errorState = state_stack[tos]; - - // automatic insertion of `;' - if (yytoken != -1 && t_action(errorState, T_AUTOMATIC_SEMICOLON) && lexer->canInsertAutomaticSemicolon(yytoken)) { - SavedToken &tk = token_buffer[0]; - tk.token = yytoken; - tk.dval = yylval; - tk.spell = yytokenspell; - tk.loc = yylloc; - - yylloc = yyprevlloc; - yylloc.offset += yylloc.length; - yylloc.startColumn += yylloc.length; - yylloc.length = 0; - - //const QString msg = qApp->translate("QDeclarativeParser", "Missing `;'"); - //diagnostic_messages.append(DiagnosticMessage(DiagnosticMessage::Warning, yylloc, msg)); - - first_token = &token_buffer[0]; - last_token = &token_buffer[1]; - - yytoken = T_SEMICOLON; - yylval = 0; - - action = errorState; - - goto _Lcheck_token; - } - - hadErrors = true; - - token_buffer[0].token = yytoken; - token_buffer[0].dval = yylval; - token_buffer[0].spell = yytokenspell; - token_buffer[0].loc = yylloc; - - token_buffer[1].token = yytoken = lexer->lex(); - token_buffer[1].dval = yylval = lexer->tokenValue(); - token_buffer[1].spell = yytokenspell = lexer->tokenSpell(); - token_buffer[1].loc = yylloc = location(lexer); - - if (t_action(errorState, yytoken)) { - QString msg; - int token = token_buffer[0].token; - if (token < 0 || token >= TERMINAL_COUNT) - msg = qApp->translate("QDeclarativeParser", "Syntax error"); - else - msg = qApp->translate("QDeclarativeParser", "Unexpected token `%1'").arg(QLatin1String(spell[token])); - diagnostic_messages.append(DiagnosticMessage(DiagnosticMessage::Error, token_buffer[0].loc, msg)); - - action = errorState; - goto _Lcheck_token; - } - - static int tokens[] = { - T_PLUS, - T_EQ, - - T_COMMA, - T_COLON, - T_SEMICOLON, - - T_RPAREN, T_RBRACKET, T_RBRACE, - - T_NUMERIC_LITERAL, - T_IDENTIFIER, - - T_LPAREN, T_LBRACKET, T_LBRACE, - - EOF_SYMBOL - }; - - for (int *tk = tokens; *tk != EOF_SYMBOL; ++tk) { - int a = t_action(errorState, *tk); - if (a > 0 && t_action(a, yytoken)) { - const QString msg = qApp->translate("QDeclarativeParser", "Expected token `%1'").arg(QLatin1String(spell[*tk])); - diagnostic_messages.append(DiagnosticMessage(DiagnosticMessage::Error, token_buffer[0].loc, msg)); - - yytoken = *tk; - yylval = 0; - yylloc = token_buffer[0].loc; - yylloc.length = 0; - - first_token = &token_buffer[0]; - last_token = &token_buffer[2]; - - action = errorState; - goto _Lcheck_token; - } - } - - for (int tk = 1; tk < TERMINAL_COUNT; ++tk) { - if (tk == T_AUTOMATIC_SEMICOLON || tk == T_FEED_UI_PROGRAM || - tk == T_FEED_JS_STATEMENT || tk == T_FEED_JS_EXPRESSION || - tk == T_FEED_JS_SOURCE_ELEMENT) - continue; - - int a = t_action(errorState, tk); - if (a > 0 && t_action(a, yytoken)) { - const QString msg = qApp->translate("QDeclarativeParser", "Expected token `%1'").arg(QLatin1String(spell[tk])); - diagnostic_messages.append(DiagnosticMessage(DiagnosticMessage::Error, token_buffer[0].loc, msg)); - - yytoken = tk; - yylval = 0; - yylloc = token_buffer[0].loc; - yylloc.length = 0; - - action = errorState; - goto _Lcheck_token; - } - } - - const QString msg = qApp->translate("QDeclarativeParser", "Syntax error"); - diagnostic_messages.append(DiagnosticMessage(DiagnosticMessage::Error, token_buffer[0].loc, msg)); - } - - return false; -} - -QT_QML_END_NAMESPACE - - diff --git a/src/declarative/qml/parser/qdeclarativejsparser_p.h b/src/declarative/qml/parser/qdeclarativejsparser_p.h deleted file mode 100644 index 1e6da5944b..0000000000 --- a/src/declarative/qml/parser/qdeclarativejsparser_p.h +++ /dev/null @@ -1,248 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists purely as an -// implementation detail. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - -// -// This file is automatically generated from qmljs.g. -// Changes will be lost. -// - -#ifndef QDECLARATIVEJSPARSER_P_H -#define QDECLARATIVEJSPARSER_P_H - -#include "qdeclarativejsglobal_p.h" -#include "qdeclarativejsgrammar_p.h" -#include "qdeclarativejsast_p.h" -#include "qdeclarativejsengine_p.h" - -#include -#include - -QT_QML_BEGIN_NAMESPACE - -namespace QDeclarativeJS { - -class Engine; - -class QML_PARSER_EXPORT Parser: protected QDeclarativeJSGrammar -{ -public: - union Value { - int ival; - double dval; - AST::ArgumentList *ArgumentList; - AST::CaseBlock *CaseBlock; - AST::CaseClause *CaseClause; - AST::CaseClauses *CaseClauses; - AST::Catch *Catch; - AST::DefaultClause *DefaultClause; - AST::ElementList *ElementList; - AST::Elision *Elision; - AST::ExpressionNode *Expression; - AST::Finally *Finally; - AST::FormalParameterList *FormalParameterList; - AST::FunctionBody *FunctionBody; - AST::FunctionDeclaration *FunctionDeclaration; - AST::Node *Node; - AST::PropertyName *PropertyName; - AST::PropertyNameAndValueList *PropertyNameAndValueList; - AST::SourceElement *SourceElement; - AST::SourceElements *SourceElements; - AST::Statement *Statement; - AST::StatementList *StatementList; - AST::Block *Block; - AST::VariableDeclaration *VariableDeclaration; - AST::VariableDeclarationList *VariableDeclarationList; - - AST::UiProgram *UiProgram; - AST::UiImportList *UiImportList; - AST::UiImport *UiImport; - AST::UiParameterList *UiParameterList; - AST::UiPublicMember *UiPublicMember; - AST::UiObjectDefinition *UiObjectDefinition; - AST::UiObjectInitializer *UiObjectInitializer; - AST::UiObjectBinding *UiObjectBinding; - AST::UiScriptBinding *UiScriptBinding; - AST::UiArrayBinding *UiArrayBinding; - AST::UiObjectMember *UiObjectMember; - AST::UiObjectMemberList *UiObjectMemberList; - AST::UiArrayMemberList *UiArrayMemberList; - AST::UiQualifiedId *UiQualifiedId; - }; - -public: - Parser(Engine *engine); - ~Parser(); - - // parse a UI program - bool parse() { return parse(T_FEED_UI_PROGRAM); } - bool parseStatement() { return parse(T_FEED_JS_STATEMENT); } - bool parseExpression() { return parse(T_FEED_JS_EXPRESSION); } - bool parseSourceElement() { return parse(T_FEED_JS_SOURCE_ELEMENT); } - bool parseUiObjectMember() { return parse(T_FEED_UI_OBJECT_MEMBER); } - bool parseProgram() { return parse(T_FEED_JS_PROGRAM); } - - AST::UiProgram *ast() const - { return AST::cast(program); } - - AST::Statement *statement() const - { - if (! program) - return 0; - - return program->statementCast(); - } - - AST::ExpressionNode *expression() const - { - if (! program) - return 0; - - return program->expressionCast(); - } - - AST::UiObjectMember *uiObjectMember() const - { - if (! program) - return 0; - - return program->uiObjectMemberCast(); - } - - AST::Node *rootNode() const - { return program; } - - QList diagnosticMessages() const - { return diagnostic_messages; } - - inline DiagnosticMessage diagnosticMessage() const - { - foreach (const DiagnosticMessage &d, diagnostic_messages) { - if (! d.kind == DiagnosticMessage::Warning) - return d; - } - - return DiagnosticMessage(); - } - - inline QString errorMessage() const - { return diagnosticMessage().message; } - - inline int errorLineNumber() const - { return diagnosticMessage().loc.startLine; } - - inline int errorColumnNumber() const - { return diagnosticMessage().loc.startColumn; } - -protected: - bool parse(int startToken); - - void reallocateStack(); - - inline Value &sym(int index) - { return sym_stack [tos + index - 1]; } - - inline QStringRef &stringRef(int index) - { return string_stack [tos + index - 1]; } - - inline AST::SourceLocation &loc(int index) - { return location_stack [tos + index - 1]; } - - AST::UiQualifiedId *reparseAsQualifiedId(AST::ExpressionNode *expr); - -protected: - Engine *driver; - MemoryPool *pool; - int tos; - int stack_size; - Value *sym_stack; - int *state_stack; - AST::SourceLocation *location_stack; - QStringRef *string_stack; - - AST::Node *program; - - // error recovery - enum { TOKEN_BUFFER_SIZE = 3 }; - - struct SavedToken { - int token; - double dval; - AST::SourceLocation loc; - QStringRef spell; - }; - - double yylval; - QStringRef yytokenspell; - AST::SourceLocation yylloc; - AST::SourceLocation yyprevlloc; - - SavedToken token_buffer[TOKEN_BUFFER_SIZE]; - SavedToken *first_token; - SavedToken *last_token; - - QList diagnostic_messages; -}; - -} // end of namespace QDeclarativeJS - - - -#define J_SCRIPT_REGEXPLITERAL_RULE1 79 - -#define J_SCRIPT_REGEXPLITERAL_RULE2 80 - -QT_QML_END_NAMESPACE - - - -#endif // QDECLARATIVEJSPARSER_P_H diff --git a/src/declarative/qml/qdeclarative.h b/src/declarative/qml/qdeclarative.h deleted file mode 100644 index 2d199b79e6..0000000000 --- a/src/declarative/qml/qdeclarative.h +++ /dev/null @@ -1,451 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QDECLARATIVE_H -#define QDECLARATIVE_H - -#include -#include -#include -#include - -#include -#include - -QT_BEGIN_HEADER - -#define QML_VERSION 0x020000 -#define QML_VERSION_STR "2.0" - -#define QML_DECLARE_TYPE(TYPE) \ - Q_DECLARE_METATYPE(TYPE *) \ - Q_DECLARE_METATYPE(QDeclarativeListProperty) - -#define QML_DECLARE_TYPE_HASMETATYPE(TYPE) \ - Q_DECLARE_METATYPE(QDeclarativeListProperty) - -#define QML_DECLARE_INTERFACE(INTERFACE) \ - QML_DECLARE_TYPE(INTERFACE) - -#define QML_DECLARE_INTERFACE_HASMETATYPE(INTERFACE) \ - QML_DECLARE_TYPE_HASMETATYPE(INTERFACE) - -enum { /* TYPEINFO flags */ - QML_HAS_ATTACHED_PROPERTIES = 0x01 -}; - -#define QML_DECLARE_TYPEINFO(TYPE, FLAGS) \ -QT_BEGIN_NAMESPACE \ -template <> \ -class QDeclarativeTypeInfo \ -{ \ -public: \ - enum { \ - hasAttachedProperties = (((FLAGS) & QML_HAS_ATTACHED_PROPERTIES) == QML_HAS_ATTACHED_PROPERTIES) \ - }; \ -}; \ -QT_END_NAMESPACE - -QT_BEGIN_NAMESPACE - - -class QDeclarativePropertyValueInterceptor; - -template -int qmlRegisterType() -{ - QByteArray name(T::staticMetaObject.className()); - - QByteArray pointerName(name + '*'); - QByteArray listName("QDeclarativeListProperty<" + name + ">"); - - QDeclarativePrivate::RegisterType type = { - 0, - - qRegisterMetaType(pointerName.constData()), - qRegisterMetaType >(listName.constData()), - 0, 0, - QString(), - - 0, 0, 0, 0, &T::staticMetaObject, - - QDeclarativePrivate::attachedPropertiesFunc(), - QDeclarativePrivate::attachedPropertiesMetaObject(), - - QDeclarativePrivate::StaticCastSelector::cast(), - QDeclarativePrivate::StaticCastSelector::cast(), - QDeclarativePrivate::StaticCastSelector::cast(), - - 0, 0, - - 0, - 0 - }; - - return QDeclarativePrivate::qmlregister(QDeclarativePrivate::TypeRegistration, &type); -} - -int Q_DECLARATIVE_EXPORT qmlRegisterTypeNotAvailable(const char *uri, int versionMajor, int versionMinor, const char *qmlName, const QString& message); - -template -int qmlRegisterUncreatableType(const char *uri, int versionMajor, int versionMinor, const char *qmlName, const QString& reason) -{ - QByteArray name(T::staticMetaObject.className()); - - QByteArray pointerName(name + '*'); - QByteArray listName("QDeclarativeListProperty<" + name + ">"); - - QDeclarativePrivate::RegisterType type = { - 0, - - qRegisterMetaType(pointerName.constData()), - qRegisterMetaType >(listName.constData()), - 0, 0, - reason, - - uri, versionMajor, versionMinor, qmlName, &T::staticMetaObject, - - QDeclarativePrivate::attachedPropertiesFunc(), - QDeclarativePrivate::attachedPropertiesMetaObject(), - - QDeclarativePrivate::StaticCastSelector::cast(), - QDeclarativePrivate::StaticCastSelector::cast(), - QDeclarativePrivate::StaticCastSelector::cast(), - - 0, 0, - - 0, - 0 - }; - - return QDeclarativePrivate::qmlregister(QDeclarativePrivate::TypeRegistration, &type); -} - -template -int qmlRegisterType(const char *uri, int versionMajor, int versionMinor, const char *qmlName) -{ - QByteArray name(T::staticMetaObject.className()); - - QByteArray pointerName(name + '*'); - QByteArray listName("QDeclarativeListProperty<" + name + ">"); - - QDeclarativePrivate::RegisterType type = { - 0, - - qRegisterMetaType(pointerName.constData()), - qRegisterMetaType >(listName.constData()), - sizeof(T), QDeclarativePrivate::createInto, - QString(), - - uri, versionMajor, versionMinor, qmlName, &T::staticMetaObject, - - QDeclarativePrivate::attachedPropertiesFunc(), - QDeclarativePrivate::attachedPropertiesMetaObject(), - - QDeclarativePrivate::StaticCastSelector::cast(), - QDeclarativePrivate::StaticCastSelector::cast(), - QDeclarativePrivate::StaticCastSelector::cast(), - - 0, 0, - - 0, - 0 - }; - - return QDeclarativePrivate::qmlregister(QDeclarativePrivate::TypeRegistration, &type); -} - -template -int qmlRegisterType(const char *uri, int versionMajor, int versionMinor, const char *qmlName) -{ - QByteArray name(T::staticMetaObject.className()); - - QByteArray pointerName(name + '*'); - QByteArray listName("QDeclarativeListProperty<" + name + ">"); - - QDeclarativePrivate::RegisterType type = { - 1, - - qRegisterMetaType(pointerName.constData()), - qRegisterMetaType >(listName.constData()), - sizeof(T), QDeclarativePrivate::createInto, - QString(), - - uri, versionMajor, versionMinor, qmlName, &T::staticMetaObject, - - QDeclarativePrivate::attachedPropertiesFunc(), - QDeclarativePrivate::attachedPropertiesMetaObject(), - - QDeclarativePrivate::StaticCastSelector::cast(), - QDeclarativePrivate::StaticCastSelector::cast(), - QDeclarativePrivate::StaticCastSelector::cast(), - - 0, 0, - - 0, - metaObjectRevision - }; - - return QDeclarativePrivate::qmlregister(QDeclarativePrivate::TypeRegistration, &type); -} - -template -int qmlRegisterRevision(const char *uri, int versionMajor, int versionMinor) -{ - QByteArray name(T::staticMetaObject.className()); - - QByteArray pointerName(name + '*'); - QByteArray listName("QDeclarativeListProperty<" + name + ">"); - - QDeclarativePrivate::RegisterType type = { - 1, - - qRegisterMetaType(pointerName.constData()), - qRegisterMetaType >(listName.constData()), - sizeof(T), QDeclarativePrivate::createInto, - QString(), - - uri, versionMajor, versionMinor, 0, &T::staticMetaObject, - - QDeclarativePrivate::attachedPropertiesFunc(), - QDeclarativePrivate::attachedPropertiesMetaObject(), - - QDeclarativePrivate::StaticCastSelector::cast(), - QDeclarativePrivate::StaticCastSelector::cast(), - QDeclarativePrivate::StaticCastSelector::cast(), - - 0, 0, - - 0, - metaObjectRevision - }; - - return QDeclarativePrivate::qmlregister(QDeclarativePrivate::TypeRegistration, &type); -} - - -template -int qmlRegisterExtendedType() -{ - QByteArray name(T::staticMetaObject.className()); - - QByteArray pointerName(name + '*'); - QByteArray listName("QDeclarativeListProperty<" + name + ">"); - - QDeclarativePrivate::RegisterType type = { - 0, - - qRegisterMetaType(pointerName.constData()), - qRegisterMetaType >(listName.constData()), - 0, 0, - QString(), - - 0, 0, 0, 0, &T::staticMetaObject, - - QDeclarativePrivate::attachedPropertiesFunc(), - QDeclarativePrivate::attachedPropertiesMetaObject(), - - QDeclarativePrivate::StaticCastSelector::cast(), - QDeclarativePrivate::StaticCastSelector::cast(), - QDeclarativePrivate::StaticCastSelector::cast(), - - QDeclarativePrivate::createParent, &E::staticMetaObject, - - 0, - 0 - }; - - return QDeclarativePrivate::qmlregister(QDeclarativePrivate::TypeRegistration, &type); -} - -template -int qmlRegisterExtendedType(const char *uri, int versionMajor, int versionMinor, - const char *qmlName) -{ - QByteArray name(T::staticMetaObject.className()); - - QByteArray pointerName(name + '*'); - QByteArray listName("QDeclarativeListProperty<" + name + ">"); - - QDeclarativeAttachedPropertiesFunc attached = QDeclarativePrivate::attachedPropertiesFunc(); - const QMetaObject * attachedMetaObject = QDeclarativePrivate::attachedPropertiesMetaObject(); - if (!attached) { - attached = QDeclarativePrivate::attachedPropertiesFunc(); - attachedMetaObject = QDeclarativePrivate::attachedPropertiesMetaObject(); - } - - QDeclarativePrivate::RegisterType type = { - 0, - - qRegisterMetaType(pointerName.constData()), - qRegisterMetaType >(listName.constData()), - sizeof(T), QDeclarativePrivate::createInto, - QString(), - - uri, versionMajor, versionMinor, qmlName, &T::staticMetaObject, - - attached, - attachedMetaObject, - - QDeclarativePrivate::StaticCastSelector::cast(), - QDeclarativePrivate::StaticCastSelector::cast(), - QDeclarativePrivate::StaticCastSelector::cast(), - - QDeclarativePrivate::createParent, &E::staticMetaObject, - - 0, - 0 - }; - - return QDeclarativePrivate::qmlregister(QDeclarativePrivate::TypeRegistration, &type); -} - -template -int qmlRegisterInterface(const char *typeName) -{ - QByteArray name(typeName); - - QByteArray pointerName(name + '*'); - QByteArray listName("QDeclarativeListProperty<" + name + ">"); - - QDeclarativePrivate::RegisterInterface qmlInterface = { - 0, - - qRegisterMetaType(pointerName.constData()), - qRegisterMetaType >(listName.constData()), - - qobject_interface_iid() - }; - - return QDeclarativePrivate::qmlregister(QDeclarativePrivate::InterfaceRegistration, &qmlInterface); -} - -template -int qmlRegisterCustomType(const char *uri, int versionMajor, int versionMinor, - const char *qmlName, QDeclarativeCustomParser *parser) -{ - QByteArray name(T::staticMetaObject.className()); - - QByteArray pointerName(name + '*'); - QByteArray listName("QDeclarativeListProperty<" + name + ">"); - - QDeclarativePrivate::RegisterType type = { - 0, - - qRegisterMetaType(pointerName.constData()), - qRegisterMetaType >(listName.constData()), - sizeof(T), QDeclarativePrivate::createInto, - QString(), - - uri, versionMajor, versionMinor, qmlName, &T::staticMetaObject, - - QDeclarativePrivate::attachedPropertiesFunc(), - QDeclarativePrivate::attachedPropertiesMetaObject(), - - QDeclarativePrivate::StaticCastSelector::cast(), - QDeclarativePrivate::StaticCastSelector::cast(), - QDeclarativePrivate::StaticCastSelector::cast(), - - 0, 0, - - parser, - 0 - }; - - return QDeclarativePrivate::qmlregister(QDeclarativePrivate::TypeRegistration, &type); -} - -class QDeclarativeContext; -class QDeclarativeEngine; -class QJSValue; -class QJSEngine; -Q_DECLARATIVE_EXPORT void qmlExecuteDeferred(QObject *); -Q_DECLARATIVE_EXPORT QDeclarativeContext *qmlContext(const QObject *); -Q_DECLARATIVE_EXPORT QDeclarativeEngine *qmlEngine(const QObject *); -Q_DECLARATIVE_EXPORT QObject *qmlAttachedPropertiesObjectById(int, const QObject *, bool create = true); -Q_DECLARATIVE_EXPORT QObject *qmlAttachedPropertiesObject(int *, const QObject *, const QMetaObject *, bool create); - -template -QObject *qmlAttachedPropertiesObject(const QObject *obj, bool create = true) -{ - static int idx = -1; - return qmlAttachedPropertiesObject(&idx, obj, &T::staticMetaObject, create); -} - -// For the use of QtQuick1 module -Q_DECLARATIVE_EXPORT void qmlRegisterBaseTypes(const char *uri, int versionMajor, int versionMinor); - -inline int qmlRegisterModuleApi(const char *uri, int versionMajor, int versionMinor, - QJSValue (*callback)(QDeclarativeEngine *, QJSEngine *)) -{ - QDeclarativePrivate::RegisterModuleApi api = { - 0, - - uri, versionMajor, versionMinor, - - callback, 0 - }; - - return QDeclarativePrivate::qmlregister(QDeclarativePrivate::ModuleApiRegistration, &api); -} - -inline int qmlRegisterModuleApi(const char *uri, int versionMajor, int versionMinor, - QObject *(*callback)(QDeclarativeEngine *, QJSEngine *)) -{ - QDeclarativePrivate::RegisterModuleApi api = { - 0, - - uri, versionMajor, versionMinor, - - 0, callback - }; - - return QDeclarativePrivate::qmlregister(QDeclarativePrivate::ModuleApiRegistration, &api); -} - -QT_END_NAMESPACE - -QML_DECLARE_TYPE(QObject) -Q_DECLARE_METATYPE(QVariant) - -QT_END_HEADER - -#endif // QDECLARATIVE_H diff --git a/src/declarative/qml/qdeclarativeaccessors.cpp b/src/declarative/qml/qdeclarativeaccessors.cpp deleted file mode 100644 index 5659c2d550..0000000000 --- a/src/declarative/qml/qdeclarativeaccessors.cpp +++ /dev/null @@ -1,127 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qdeclarativeaccessors_p.h" - -#include "qdeclarativedata_p.h" -#include "qdeclarativenotifier_p.h" - -QT_BEGIN_NAMESPACE - -struct AccessorProperties { - AccessorProperties(); - - QReadWriteLock lock; - QHash properties; -}; - -Q_GLOBAL_STATIC(AccessorProperties, accessorProperties) - -QML_PRIVATE_ACCESSOR(QObject, QString, objectName, objectName) - -static void QObject_objectNameNotifier(QObject *object, intptr_t, QDeclarativeNotifier **notifier) -{ - *notifier = QDeclarativeData::get(object, true)->objectNameNotifier(); -} - -static QDeclarativeAccessors QObject_objectName = { QObject_objectNameRead, - QObject_objectNameNotifier }; - -QML_DECLARE_PROPERTIES(QObject) { - { QML_PROPERTY_NAME(objectName), 0, &QObject_objectName } -}; - -static void buildNameMask(QDeclarativeAccessorProperties::Properties &properties) -{ - quint32 mask = 0; - - for (int ii = 0; ii < properties.count; ++ii) { - Q_ASSERT(strlen(properties.properties[ii].name) == properties.properties[ii].nameLength); - Q_ASSERT(properties.properties[ii].nameLength > 0); - - mask |= (1 << qMin(31U, properties.properties[ii].nameLength - 1)); - } - - properties.nameMask = mask; -} - -AccessorProperties::AccessorProperties() -{ - // Pre-seed QObject::objectName accessor - typedef QDeclarativeAccessorProperties::Properties P; - properties.insert(&QObject::staticMetaObject, - P(qdeclarative_accessor_properties_QObject, - sizeof(qdeclarative_accessor_properties_QObject) / - sizeof(QDeclarativeAccessorProperties::Property))); -} - -QDeclarativeAccessorProperties::Properties::Properties(Property *properties, int count) -: count(count), properties(properties) -{ - buildNameMask(*this); -} - -QDeclarativeAccessorProperties::Properties -QDeclarativeAccessorProperties::properties(const QMetaObject *mo) -{ - AccessorProperties *This = accessorProperties(); - - QReadLocker lock(&This->lock); - return This->properties.value(mo); -} - -void QDeclarativeAccessorProperties::registerProperties(const QMetaObject *mo, int count, - Property *props) -{ - Q_ASSERT(count > 0); - - Properties properties(props, count); - - AccessorProperties *This = accessorProperties(); - - QWriteLocker lock(&This->lock); - - Q_ASSERT(!This->properties.contains(mo) || This->properties.value(mo) == properties); - - This->properties.insert(mo, properties); -} - -QT_END_NAMESPACE diff --git a/src/declarative/qml/qdeclarativeaccessors_p.h b/src/declarative/qml/qdeclarativeaccessors_p.h deleted file mode 100644 index c52dc537ef..0000000000 --- a/src/declarative/qml/qdeclarativeaccessors_p.h +++ /dev/null @@ -1,165 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QDECLARATIVEACCESSORS_P_H -#define QDECLARATIVEACCESSORS_P_H - -#include -#include -#include - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -class QObject; -class QDeclarativeNotifier; - -// QML "accessor properties" allow V4 and V8 to bypass Qt's meta system to read and, more -// importantly, subscribe to properties directly. Any property that is primarily read -// from bindings is a candidate for inclusion as an accessor property. -// -// To define accessor properties, use the QML_DECLARE_PROPERTIES() and QML_DEFINE_PROPERTIES() -// macros. The QML_DECLARE_PROPERTIES() macro is used to specify the properties, and the -// QML_DEFINE_PROPERTIES() macro to register the properties with the -// QDeclarativeAccessorProperties singleton. -// -// A class with accessor properties must also add the Q_CLASSINFO("qt_HasQmlAccessors", "true") -// tag to its declaration. This is essential for QML to maintain internal consistency, -// and forgetting to do so will probably cause your application to qFatal() with a -// helpful reminder of this requirement. -// -// It is important that QML_DEFINE_PROPERTIES() has been called before QML ever sees -// the type with the accessor properties. As QML_DEFINE_PROPERTIES() is idempotent, it is -// recommended to call it in the type's constructor as well as when the type is registered -// as a QML element (if it ever is). QML_DEFINE_PROPERTIES() is a very cheap operation -// if registration has already occurred. - -#define QML_DECLARE_PROPERTIES(type) \ - static volatile bool qdeclarative_accessor_properties_isregistered_ ## type = false; \ - static QDeclarativeAccessorProperties::Property qdeclarative_accessor_properties_ ## type[] = - -#define QML_DEFINE_PROPERTIES(type) \ - do { \ - if (!qdeclarative_accessor_properties_isregistered_ ## type) { \ - int count = sizeof(qdeclarative_accessor_properties_ ## type) / \ - sizeof(QDeclarativeAccessorProperties::Property); \ - QDeclarativeAccessorProperties::registerProperties(&type::staticMetaObject, count, \ - qdeclarative_accessor_properties_ ## type);\ - qdeclarative_accessor_properties_isregistered_ ## type = true; \ - } \ - } while (false); - -#define QML_PRIVATE_ACCESSOR(clazz, cpptype, name, variable) \ - static void clazz ## _ ## name ## Read(QObject *o, intptr_t, void *rv) \ - { \ - clazz ## Private *d = clazz ## Private::get(static_cast(o)); \ - *static_cast(rv) = d->variable; \ - } - -#define QML_PROPERTY_NAME(name) #name, sizeof #name - 1 - -class QDeclarativeAccessors -{ -public: - void (*read)(QObject *object, intptr_t property, void *output); - void (*notifier)(QObject *object, intptr_t property, QDeclarativeNotifier **notifier); -}; - -namespace QDeclarativeAccessorProperties { - struct Property { - const char *name; - unsigned int nameLength; - intptr_t data; - QDeclarativeAccessors *accessors; - }; - - struct Properties { - inline Properties(); - Properties(Property *, int); - - bool operator==(const Properties &o) const { - return count == o.count && properties == o.properties; - } - - inline Property *property(const char *name); - - int count; - Property *properties; - quint32 nameMask; - }; - - Properties properties(const QMetaObject *); - void Q_DECLARATIVE_EXPORT registerProperties(const QMetaObject *, int, Property *); -}; - -QDeclarativeAccessorProperties::Property * -QDeclarativeAccessorProperties::Properties::property(const char *name) -{ - if (count == 0) - return 0; - - unsigned int length = strlen(name); - - Q_ASSERT(length); - - if (nameMask & (1 << qMin(31U, length - 1))) { - - for (int ii = 0; ii < count; ++ii) { - if (properties[ii].nameLength == length && 0 == qstrcmp(name, properties[ii].name)) - return &properties[ii]; - } - - } - - return 0; -} - -QDeclarativeAccessorProperties::Properties::Properties() -: count(0), properties(0), nameMask(0) -{ -} - -QT_END_NAMESPACE - -QT_END_HEADER - -#endif // QDECLARATIVEACCESSORS_P_H diff --git a/src/declarative/qml/qdeclarativeapplication.cpp b/src/declarative/qml/qdeclarativeapplication.cpp deleted file mode 100644 index b5ceaf2550..0000000000 --- a/src/declarative/qml/qdeclarativeapplication.cpp +++ /dev/null @@ -1,124 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qdeclarativeapplication_p.h" -#include -#include -#include -#include - -QT_BEGIN_NAMESPACE - -class QDeclarativeApplicationPrivate : public QObjectPrivate -{ - Q_DECLARE_PUBLIC(QDeclarativeApplication) -public: - QDeclarativeApplicationPrivate() : active(QGuiApplication::activeWindow() != 0), - layoutDirection(QGuiApplication::layoutDirection()) {} - bool active; - Qt::LayoutDirection layoutDirection; -}; - -/* - This object and its properties are documented as part of the Qt object, - in qdeclarativengine.cpp -*/ - -QDeclarativeApplication::QDeclarativeApplication(QObject *parent) : QObject(*new QDeclarativeApplicationPrivate(), parent) -{ - if (qApp) - qApp->installEventFilter(this); -} - -QDeclarativeApplication::~QDeclarativeApplication() -{ -} - -bool QDeclarativeApplication::active() const -{ - Q_D(const QDeclarativeApplication); - return d->active; -} - -Qt::LayoutDirection QDeclarativeApplication::layoutDirection() const -{ - Q_D(const QDeclarativeApplication); - return d->layoutDirection; -} - -QObject *QDeclarativeApplication::inputPanel() const -{ - static bool warned = false; - if (!warned) { - qWarning() << "Qt.application.inputPanel is deprecated, use Qt.inputMethod instead"; - warned = true; - } - return qApp ? qApp->inputMethod() : 0; -} - -bool QDeclarativeApplication::eventFilter(QObject *obj, QEvent *event) -{ - Q_UNUSED(obj) - Q_D(QDeclarativeApplication); - if (event->type() == QEvent::ApplicationActivate - || event->type() == QEvent::ApplicationDeactivate) { - bool active = d->active; - if (event->type() == QEvent::ApplicationActivate) - active = true; - else if (event->type() == QEvent::ApplicationDeactivate) - active = false; - - if (d->active != active) { - d->active = active; - emit activeChanged(); - } - } - if (event->type() == QEvent::LayoutDirectionChange) { - Qt::LayoutDirection direction = QGuiApplication::layoutDirection(); - if (d->layoutDirection != direction) { - d->layoutDirection = direction; - emit layoutDirectionChanged(); - } - } - return false; -} - -QT_END_NAMESPACE diff --git a/src/declarative/qml/qdeclarativeapplication_p.h b/src/declarative/qml/qdeclarativeapplication_p.h deleted file mode 100644 index 4a0ff52d3e..0000000000 --- a/src/declarative/qml/qdeclarativeapplication_p.h +++ /dev/null @@ -1,87 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QDECLARATIVEAPPLICATION_P_H -#define QDECLARATIVEAPPLICATION_P_H - -#include -#include -#include - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - - -class QDeclarativeApplicationPrivate; -class Q_DECLARATIVE_PRIVATE_EXPORT QDeclarativeApplication : public QObject -{ - Q_OBJECT - Q_PROPERTY(bool active READ active NOTIFY activeChanged) - Q_PROPERTY(Qt::LayoutDirection layoutDirection READ layoutDirection NOTIFY layoutDirectionChanged) - Q_PROPERTY(QObject *inputPanel READ inputPanel CONSTANT) - -public: - explicit QDeclarativeApplication(QObject *parent = 0); - virtual ~QDeclarativeApplication(); - bool active() const; - Qt::LayoutDirection layoutDirection() const; - QT_DEPRECATED QObject *inputPanel() const; - -protected: - bool eventFilter(QObject *obj, QEvent *event); - -Q_SIGNALS: - void activeChanged(); - void layoutDirectionChanged(); - -private: - Q_DISABLE_COPY(QDeclarativeApplication) - Q_DECLARE_PRIVATE(QDeclarativeApplication) -}; - -QT_END_NAMESPACE - -QML_DECLARE_TYPE(QDeclarativeApplication) - -QT_END_HEADER - -#endif // QDECLARATIVEAPPLICATION_P_H diff --git a/src/declarative/qml/qdeclarativebinding.cpp b/src/declarative/qml/qdeclarativebinding.cpp deleted file mode 100644 index 39032e0ca6..0000000000 --- a/src/declarative/qml/qdeclarativebinding.cpp +++ /dev/null @@ -1,551 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qdeclarativebinding_p.h" -#include "qdeclarativebinding_p_p.h" - -#include "qdeclarative.h" -#include "qdeclarativecontext.h" -#include "qdeclarativeinfo.h" -#include "qdeclarativecompiler_p.h" -#include "qdeclarativedata_p.h" -#include -#include - -#include -#include - -QT_BEGIN_NAMESPACE - -QDeclarativeAbstractBinding::QDeclarativeAbstractBinding() -: m_prevBinding(0), m_nextBinding(0) -{ -} - -QDeclarativeAbstractBinding::~QDeclarativeAbstractBinding() -{ - Q_ASSERT(m_prevBinding == 0); - Q_ASSERT(*m_mePtr == 0); -} - -/*! -Destroy the binding. Use this instead of calling delete. - -Bindings are free to implement their own memory management, so the delete operator is not -necessarily safe. The default implementation clears the binding, removes it from the object -and calls delete. -*/ -void QDeclarativeAbstractBinding::destroy() -{ - removeFromObject(); - clear(); - - delete this; -} - -/*! -Add this binding to \a object. - -This transfers ownership of the binding to the object, marks the object's property as -being bound. - -However, it does not enable the binding itself or call update() on it. -*/ -void QDeclarativeAbstractBinding::addToObject() -{ - Q_ASSERT(!m_prevBinding); - - QObject *obj = object(); - Q_ASSERT(obj); - - int index = propertyIndex(); - - QDeclarativeData *data = QDeclarativeData::get(obj, true); - - if (index & 0xFF000000) { - // Value type - - int coreIndex = index & 0xFFFFFF; - - // Find the value type proxy (if there is one) - QDeclarativeValueTypeProxyBinding *proxy = 0; - if (data->hasBindingBit(coreIndex)) { - QDeclarativeAbstractBinding *b = data->bindings; - while (b && b->propertyIndex() != coreIndex) - b = b->m_nextBinding; - Q_ASSERT(b && b->bindingType() == QDeclarativeAbstractBinding::ValueTypeProxy); - proxy = static_cast(b); - } - - if (!proxy) { - proxy = new QDeclarativeValueTypeProxyBinding(obj, coreIndex); - - Q_ASSERT(proxy->propertyIndex() == coreIndex); - Q_ASSERT(proxy->object() == obj); - - proxy->addToObject(); - } - - m_nextBinding = proxy->m_bindings; - if (m_nextBinding) m_nextBinding->m_prevBinding = &m_nextBinding; - m_prevBinding = &proxy->m_bindings; - proxy->m_bindings = this; - - } else { - m_nextBinding = data->bindings; - if (m_nextBinding) m_nextBinding->m_prevBinding = &m_nextBinding; - m_prevBinding = &data->bindings; - data->bindings = this; - - data->setBindingBit(obj, index); - } -} - -/*! -Remove the binding from the object. -*/ -void QDeclarativeAbstractBinding::removeFromObject() -{ - if (m_prevBinding) { - int index = propertyIndex(); - - *m_prevBinding = m_nextBinding; - if (m_nextBinding) m_nextBinding->m_prevBinding = m_prevBinding; - m_prevBinding = 0; - m_nextBinding = 0; - - if (index & 0xFF000000) { - // Value type - we don't remove the proxy from the object. It will sit their happily - // doing nothing until it is removed by a write, a binding change or it is reused - // to hold more sub-bindings. - } else if (QObject *obj = object()) { - QDeclarativeData *data = QDeclarativeData::get(obj, false); - if (data) data->clearBindingBit(index); - } - } -} - -static void bindingDummyDeleter(QDeclarativeAbstractBinding *) -{ -} - -QDeclarativeAbstractBinding::Pointer QDeclarativeAbstractBinding::weakPointer() -{ - if (m_mePtr.value().isNull()) - m_mePtr.value() = QSharedPointer(this, bindingDummyDeleter); - - return m_mePtr.value().toWeakRef(); -} - -void QDeclarativeAbstractBinding::clear() -{ - if (!m_mePtr.isNull()) { - **m_mePtr = 0; - m_mePtr = 0; - } -} - -void QDeclarativeAbstractBinding::retargetBinding(QObject *, int) -{ - qFatal("QDeclarativeAbstractBinding::retargetBinding() called on illegal binding."); -} - -QString QDeclarativeAbstractBinding::expression() const -{ - return QLatin1String(""); -} - -void QDeclarativeAbstractBinding::setEnabled(bool enabled, QDeclarativePropertyPrivate::WriteFlags flags) -{ - if (enabled) update(flags); -} - -QDeclarativeBinding::Identifier QDeclarativeBinding::Invalid = -1; - -void QDeclarativeBindingPrivate::refresh() -{ - Q_Q(QDeclarativeBinding); - q->update(); -} - -QDeclarativeBindingPrivate::QDeclarativeBindingPrivate() -: updating(false), enabled(false), target(), targetProperty(0) -{ -} - -QDeclarativeBindingPrivate::~QDeclarativeBindingPrivate() -{ -} - -QDeclarativeBinding * -QDeclarativeBinding::createBinding(Identifier id, QObject *obj, QDeclarativeContext *ctxt, - const QString &url, int lineNumber, QObject *parent) -{ - if (id < 0) - return 0; - - QDeclarativeContextData *ctxtdata = QDeclarativeContextData::get(ctxt); - - QDeclarativeEnginePrivate *engine = QDeclarativeEnginePrivate::get(ctxt->engine()); - QDeclarativeCompiledData *cdata = 0; - QDeclarativeTypeData *typeData = 0; - if (engine && ctxtdata && !ctxtdata->url.isEmpty()) { - typeData = engine->typeLoader.get(ctxtdata->url); - cdata = typeData->compiledData(); - } - QDeclarativeBinding *rv = cdata ? new QDeclarativeBinding(cdata->primitives.at(id), true, obj, ctxtdata, url, lineNumber, 0, parent) : 0; - if (cdata) - cdata->release(); - if (typeData) - typeData->release(); - return rv; -} - -QDeclarativeBinding::QDeclarativeBinding(const QString &str, QObject *obj, QDeclarativeContext *ctxt, - QObject *parent) -: QDeclarativeExpression(QDeclarativeContextData::get(ctxt), obj, str, *new QDeclarativeBindingPrivate) -{ - setParent(parent); - setNotifyOnValueChanged(true); -} - -QDeclarativeBinding::QDeclarativeBinding(const QString &str, QObject *obj, QDeclarativeContextData *ctxt, - QObject *parent) -: QDeclarativeExpression(ctxt, obj, str, *new QDeclarativeBindingPrivate) -{ - setParent(parent); - setNotifyOnValueChanged(true); -} - -QDeclarativeBinding::QDeclarativeBinding(const QString &str, bool isRewritten, QObject *obj, - QDeclarativeContextData *ctxt, - const QString &url, int lineNumber, int columnNumber, - QObject *parent) -: QDeclarativeExpression(ctxt, obj, str, isRewritten, url, lineNumber, columnNumber, *new QDeclarativeBindingPrivate) -{ - setParent(parent); - setNotifyOnValueChanged(true); -} - -/*! - \internal - - To avoid exposing v8 in the public API, functionPtr must be a pointer to a v8::Handle. - For example: - v8::Handle function; - new QDeclarativeBinding(&function, scope, ctxt); - */ -QDeclarativeBinding::QDeclarativeBinding(void *functionPtr, QObject *obj, QDeclarativeContextData *ctxt, - QObject *parent) -: QDeclarativeExpression(ctxt, obj, functionPtr, *new QDeclarativeBindingPrivate) -{ - setParent(parent); - setNotifyOnValueChanged(true); -} - -QDeclarativeBinding::~QDeclarativeBinding() -{ -} - -void QDeclarativeBinding::setTarget(const QDeclarativeProperty &prop) -{ - Q_D(QDeclarativeBinding); - d->property = prop; - d->target = d->property.object(); - d->targetProperty = QDeclarativePropertyPrivate::get(d->property)->core.encodedIndex(); - - update(); -} - -void QDeclarativeBinding::setTarget(QObject *object, - const QDeclarativePropertyData &core, - QDeclarativeContextData *ctxt) -{ - Q_D(QDeclarativeBinding); - d->property = QDeclarativePropertyPrivate::restore(object, core, ctxt); - d->target = d->property.object(); - d->targetProperty = QDeclarativePropertyPrivate::get(d->property)->core.encodedIndex(); - - update(); -} - -QDeclarativeProperty QDeclarativeBinding::property() const -{ - Q_D(const QDeclarativeBinding); - return d->property; -} - -void QDeclarativeBinding::setEvaluateFlags(EvaluateFlags flags) -{ - Q_D(QDeclarativeBinding); - d->setRequiresThisObject(flags & RequiresThisObject); -} - -QDeclarativeBinding::EvaluateFlags QDeclarativeBinding::evaluateFlags() const -{ - Q_D(const QDeclarativeBinding); - return d->requiresThisObject()?RequiresThisObject:None; -} - -void QDeclarativeBinding::update(QDeclarativePropertyPrivate::WriteFlags flags) -{ - Q_D(QDeclarativeBinding); - - if (!d->enabled || !d->context() || !d->context()->isValid()) - return; - - QDeclarativeTrace trace("General Binding Update"); - trace.addDetail("URL", d->url); - trace.addDetail("Line", d->line); - trace.addDetail("Column", d->columnNumber); - - if (!d->updating) { - QDeclarativeBindingProfiler prof(d->url, d->line, d->column); - prof.addDetail(expression()); - d->updating = true; - - QDeclarativeAbstractExpression::DeleteWatcher watcher(d); - - if (d->property.propertyType() == qMetaTypeId()) { - - int idx = d->property.index(); - Q_ASSERT(idx != -1); - - QDeclarativeBinding *t = this; - int status = -1; - void *a[] = { &t, 0, &status, &flags }; - QMetaObject::metacall(d->property.object(), - QMetaObject::WriteProperty, - idx, a); - - } else { - QDeclarativeEnginePrivate *ep = QDeclarativeEnginePrivate::get(d->context()->engine); - ep->referenceScarceResources(); - - bool isUndefined = false; - - v8::HandleScope handle_scope; - v8::Context::Scope scope(ep->v8engine()->context()); - v8::Local result = d->v8value(0, &isUndefined); - - trace.event("writing binding result"); - - bool needsErrorData = false; - if (!watcher.wasDeleted() && !d->hasError()) - needsErrorData = !QDeclarativePropertyPrivate::writeBinding(d->property, d->context(), - d, result, - isUndefined, flags); - - if (!watcher.wasDeleted()) { - - if (needsErrorData) { - QUrl url = QUrl(d->url); - int line = d->line; - if (url.isEmpty()) url = QUrl(QLatin1String("")); - - d->delayedError()->error.setUrl(url); - d->delayedError()->error.setLine(line); - d->delayedError()->error.setColumn(-1); - } - - if (d->hasError()) { - if (!d->delayedError()->addError(ep)) ep->warning(this->error()); - } else { - d->clearError(); - } - - } - - ep->dereferenceScarceResources(); - } - - if (!watcher.wasDeleted()) - d->updating = false; - } else { - QDeclarativeBindingPrivate::printBindingLoopError(d->property); - } -} - -void QDeclarativeBindingPrivate::printBindingLoopError(QDeclarativeProperty &prop) -{ - qmlInfo(prop.object()) << QDeclarativeBinding::tr("Binding loop detected for property \"%1\"").arg(prop.name()); -} - -void QDeclarativeBindingPrivate::expressionChanged() -{ - Q_Q(QDeclarativeBinding); - q->update(); -} - -void QDeclarativeBinding::setEnabled(bool e, QDeclarativePropertyPrivate::WriteFlags flags) -{ - Q_D(QDeclarativeBinding); - d->enabled = e; - setNotifyOnValueChanged(e); - - if (e) - update(flags); -} - -bool QDeclarativeBinding::enabled() const -{ - Q_D(const QDeclarativeBinding); - - return d->enabled; -} - -QString QDeclarativeBinding::expression() const -{ - return QDeclarativeExpression::expression(); -} - -int QDeclarativeBinding::propertyIndex() const -{ - Q_D(const QDeclarativeBinding); - return d->targetProperty; -} - -QObject *QDeclarativeBinding::object() const -{ - Q_D(const QDeclarativeBinding); - return d->target; -} - -void QDeclarativeBinding::retargetBinding(QObject *t, int i) -{ - Q_D(QDeclarativeBinding); - d->target = t; - d->targetProperty = i; -} - -QDeclarativeValueTypeProxyBinding::QDeclarativeValueTypeProxyBinding(QObject *o, int index) -: m_object(o), m_index(index), m_bindings(0) -{ -} - -QDeclarativeValueTypeProxyBinding::~QDeclarativeValueTypeProxyBinding() -{ - while (m_bindings) { - QDeclarativeAbstractBinding *binding = m_bindings; - binding->setEnabled(false, 0); - binding->destroy(); - } -} - -void QDeclarativeValueTypeProxyBinding::setEnabled(bool e, QDeclarativePropertyPrivate::WriteFlags flags) -{ - if (e) { - QDeclarativeAbstractBinding *bindings = m_bindings; - recursiveEnable(bindings, flags); - } else { - QDeclarativeAbstractBinding *bindings = m_bindings; - recursiveDisable(bindings); - } -} - -void QDeclarativeValueTypeProxyBinding::recursiveEnable(QDeclarativeAbstractBinding *b, QDeclarativePropertyPrivate::WriteFlags flags) -{ - if (!b) - return; - - recursiveEnable(b->m_nextBinding, flags); - - if (b) - b->setEnabled(true, flags); -} - -void QDeclarativeValueTypeProxyBinding::recursiveDisable(QDeclarativeAbstractBinding *b) -{ - if (!b) - return; - - recursiveDisable(b->m_nextBinding); - - if (b) - b->setEnabled(false, 0); -} - -void QDeclarativeValueTypeProxyBinding::update(QDeclarativePropertyPrivate::WriteFlags) -{ -} - -QDeclarativeAbstractBinding *QDeclarativeValueTypeProxyBinding::binding(int propertyIndex) -{ - QDeclarativeAbstractBinding *binding = m_bindings; - - while (binding && binding->propertyIndex() != propertyIndex) - binding = binding->m_nextBinding; - - return binding; -} - -/*! -Removes a collection of bindings, corresponding to the set bits in \a mask. -*/ -void QDeclarativeValueTypeProxyBinding::removeBindings(quint32 mask) -{ - QDeclarativeAbstractBinding *binding = m_bindings; - while (binding) { - if (mask & (1 << (binding->propertyIndex() >> 24))) { - QDeclarativeAbstractBinding *remove = binding; - binding = remove->m_nextBinding; - *remove->m_prevBinding = remove->m_nextBinding; - if (remove->m_nextBinding) remove->m_nextBinding->m_prevBinding = remove->m_prevBinding; - remove->m_prevBinding = 0; - remove->m_nextBinding = 0; - remove->destroy(); - } else { - binding = binding->m_nextBinding; - } - } -} - -int QDeclarativeValueTypeProxyBinding::propertyIndex() const -{ - return m_index; -} - -QObject *QDeclarativeValueTypeProxyBinding::object() const -{ - return m_object; -} - -QT_END_NAMESPACE diff --git a/src/declarative/qml/qdeclarativebinding_p.h b/src/declarative/qml/qdeclarativebinding_p.h deleted file mode 100644 index 61cf7dd550..0000000000 --- a/src/declarative/qml/qdeclarativebinding_p.h +++ /dev/null @@ -1,219 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QDECLARATIVEBINDING_P_H -#define QDECLARATIVEBINDING_P_H - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists purely as an -// implementation detail. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - -#include "qdeclarative.h" -#include "qdeclarativepropertyvaluesource.h" -#include "qdeclarativeexpression.h" -#include "qdeclarativeproperty.h" -#include "qdeclarativeproperty_p.h" - -#include -#include - -#include - -QT_BEGIN_NAMESPACE - -class Q_DECLARATIVE_PRIVATE_EXPORT QDeclarativeAbstractBinding -{ -public: - typedef QWeakPointer Pointer; - - QDeclarativeAbstractBinding(); - - virtual void destroy(); - - virtual QString expression() const; - - enum Type { PropertyBinding, ValueTypeProxy }; - virtual Type bindingType() const { return PropertyBinding; } - - // Should return the encoded property index for the binding. Should return this value - // even if the binding is not enabled or added to an object. - // Encoding is: coreIndex | (valueTypeIndex << 24) - virtual int propertyIndex() const = 0; - // Should return the object for the binding. Should return this object even if the - // binding is not enabled or added to the object. - virtual QObject *object() const = 0; - - void setEnabled(bool e) { setEnabled(e, QDeclarativePropertyPrivate::DontRemoveBinding); } - virtual void setEnabled(bool, QDeclarativePropertyPrivate::WriteFlags) = 0; - - void update() { update(QDeclarativePropertyPrivate::DontRemoveBinding); } - virtual void update(QDeclarativePropertyPrivate::WriteFlags) = 0; - - void addToObject(); - void removeFromObject(); - - static inline Pointer getPointer(QDeclarativeAbstractBinding *p); - -protected: - virtual ~QDeclarativeAbstractBinding(); - void clear(); - - // Called by QDeclarativePropertyPrivate to "move" a binding to a different property. - // This is only used for alias properties, and only used by QDeclarativeBinding not - // V8 or V4 bindings. The default implementation qFatal()'s to ensure that the - // method is never called for V4 or V8 bindings. - virtual void retargetBinding(QObject *, int); -private: - Pointer weakPointer(); - - friend class QDeclarativeData; - friend class QDeclarativeComponentPrivate; - friend class QDeclarativeValueTypeProxyBinding; - friend class QDeclarativePropertyPrivate; - friend class QDeclarativeVME; - friend class QtSharedPointer::ExternalRefCount; - - typedef QSharedPointer SharedPointer; - // To save memory, we also store the rarely used weakPointer() instance in here - QPointerValuePair m_mePtr; - - QDeclarativeAbstractBinding **m_prevBinding; - QDeclarativeAbstractBinding *m_nextBinding; -}; - -class QDeclarativeValueTypeProxyBinding : public QDeclarativeAbstractBinding -{ -public: - QDeclarativeValueTypeProxyBinding(QObject *o, int coreIndex); - - virtual Type bindingType() const { return ValueTypeProxy; } - - virtual void setEnabled(bool, QDeclarativePropertyPrivate::WriteFlags); - virtual void update(QDeclarativePropertyPrivate::WriteFlags); - virtual int propertyIndex() const; - virtual QObject *object() const; - - QDeclarativeAbstractBinding *binding(int propertyIndex); - - void removeBindings(quint32 mask); - -protected: - ~QDeclarativeValueTypeProxyBinding(); - -private: - void recursiveEnable(QDeclarativeAbstractBinding *, QDeclarativePropertyPrivate::WriteFlags); - void recursiveDisable(QDeclarativeAbstractBinding *); - - friend class QDeclarativeAbstractBinding; - QObject *m_object; - int m_index; - QDeclarativeAbstractBinding *m_bindings; -}; - -class QDeclarativeContext; -class QDeclarativeBindingPrivate; -class Q_DECLARATIVE_PRIVATE_EXPORT QDeclarativeBinding : public QDeclarativeExpression, - public QDeclarativeAbstractBinding -{ -Q_OBJECT -public: - enum EvaluateFlag { None = 0x00, RequiresThisObject = 0x01 }; - Q_DECLARE_FLAGS(EvaluateFlags, EvaluateFlag) - - QDeclarativeBinding(const QString &, QObject *, QDeclarativeContext *, QObject *parent=0); - QDeclarativeBinding(const QString &, QObject *, QDeclarativeContextData *, QObject *parent=0); - QDeclarativeBinding(const QString &, bool isRewritten, QObject *, QDeclarativeContextData *, - const QString &url, int lineNumber, int columnNumber = 0, QObject *parent=0); - QDeclarativeBinding(void *, QObject *, QDeclarativeContextData *, QObject *parent=0); - - void setTarget(const QDeclarativeProperty &); - void setTarget(QObject *, const QDeclarativePropertyData &, QDeclarativeContextData *); - QDeclarativeProperty property() const; - - void setEvaluateFlags(EvaluateFlags flags); - EvaluateFlags evaluateFlags() const; - - bool enabled() const; - - // Inherited from QDeclarativeAbstractBinding - virtual void setEnabled(bool, QDeclarativePropertyPrivate::WriteFlags flags); - virtual void update(QDeclarativePropertyPrivate::WriteFlags flags); - virtual QString expression() const; - virtual int propertyIndex() const; - virtual QObject *object() const; - virtual void retargetBinding(QObject *, int); - - typedef int Identifier; - static Identifier Invalid; - static QDeclarativeBinding *createBinding(Identifier, QObject *, QDeclarativeContext *, - const QString &, int, QObject *parent=0); - - -public Q_SLOTS: - void update() { update(QDeclarativePropertyPrivate::DontRemoveBinding); } - -protected: - ~QDeclarativeBinding(); - -private: - Q_DECLARE_PRIVATE(QDeclarativeBinding) -}; - -Q_DECLARE_OPERATORS_FOR_FLAGS(QDeclarativeBinding::EvaluateFlags) - -QDeclarativeAbstractBinding::Pointer -QDeclarativeAbstractBinding::getPointer(QDeclarativeAbstractBinding *p) -{ - return p ? p->weakPointer() : Pointer(); -} - -QT_END_NAMESPACE - -Q_DECLARE_METATYPE(QDeclarativeBinding*) - -#endif // QDECLARATIVEBINDING_P_H diff --git a/src/declarative/qml/qdeclarativebinding_p_p.h b/src/declarative/qml/qdeclarativebinding_p_p.h deleted file mode 100644 index 030bd32ef3..0000000000 --- a/src/declarative/qml/qdeclarativebinding_p_p.h +++ /dev/null @@ -1,89 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QDECLARATIVEBINDING_P_P_H -#define QDECLARATIVEBINDING_P_P_H - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists purely as an -// implementation detail. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - -#include "qdeclarativebinding_p.h" - -#include "qdeclarativeproperty.h" -#include "qdeclarativeexpression_p.h" - -QT_BEGIN_NAMESPACE - -class QDeclarativeBindingPrivate : public QDeclarativeExpressionPrivate -{ - Q_DECLARE_PUBLIC(QDeclarativeBinding) -public: - QDeclarativeBindingPrivate(); - ~QDeclarativeBindingPrivate(); - - virtual void expressionChanged(); - - static void printBindingLoopError(QDeclarativeProperty &prop); - -protected: - virtual void refresh(); - -private: - bool updating:1; - bool enabled:1; - int columnNumber; - QDeclarativeProperty property; - - QObject *target; - int targetProperty; -}; - -QT_END_NAMESPACE - -#endif // QDECLARATIVEBINDING_P_P_H diff --git a/src/declarative/qml/qdeclarativeboundsignal.cpp b/src/declarative/qml/qdeclarativeboundsignal.cpp deleted file mode 100644 index 5d1c28b095..0000000000 --- a/src/declarative/qml/qdeclarativeboundsignal.cpp +++ /dev/null @@ -1,300 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qdeclarativeboundsignal_p.h" - -#include -#include "qdeclarativeengine_p.h" -#include "qdeclarativeexpression_p.h" -#include "qdeclarativecontext_p.h" -#include "qdeclarativemetatype_p.h" -#include "qdeclarative.h" -#include "qdeclarativecontext.h" -#include "qdeclarativeglobal_p.h" -#include -#include - -#include -#include - -QT_BEGIN_NAMESPACE - -class QDeclarativeBoundSignalParameters : public QObject -{ -Q_OBJECT -public: - QDeclarativeBoundSignalParameters(const QMetaMethod &, QObject * = 0); - ~QDeclarativeBoundSignalParameters(); - - void setValues(void **); - void clearValues(); - -private: - friend class MetaObject; - int metaCall(QMetaObject::Call, int _id, void **); - struct MetaObject : public QAbstractDynamicMetaObject { - MetaObject(QDeclarativeBoundSignalParameters *b) - : parent(b) {} - - int metaCall(QMetaObject::Call c, int id, void **a) { - return parent->metaCall(c, id, a); - } - QDeclarativeBoundSignalParameters *parent; - }; - - int *types; - void **values; - QMetaObject *myMetaObject; -}; - -static int evaluateIdx = -1; - -QDeclarativeAbstractBoundSignal::QDeclarativeAbstractBoundSignal(QObject *parent) -: QObject(parent) -{ -} - -QDeclarativeAbstractBoundSignal::~QDeclarativeAbstractBoundSignal() -{ -} - -QDeclarativeBoundSignal::QDeclarativeBoundSignal(QObject *scope, const QMetaMethod &signal, - QObject *parent) -: m_expression(0), m_signal(signal), m_paramsValid(false), m_isEvaluating(false), m_params(0) -{ - // This is thread safe. Although it may be updated by two threads, they - // will both set it to the same value - so the worst thing that can happen - // is that they both do the work to figure it out. Boo hoo. - if (evaluateIdx == -1) evaluateIdx = metaObject()->methodCount(); - - QDeclarative_setParent_noEvent(this, parent); - QDeclarativePropertyPrivate::connect(scope, m_signal.methodIndex(), this, evaluateIdx); -} - -QDeclarativeBoundSignal::QDeclarativeBoundSignal(QDeclarativeContext *ctxt, const QString &val, - QObject *scope, const QMetaMethod &signal, - QObject *parent) -: m_expression(0), m_signal(signal), m_paramsValid(false), m_isEvaluating(false), m_params(0) -{ - // This is thread safe. Although it may be updated by two threads, they - // will both set it to the same value - so the worst thing that can happen - // is that they both do the work to figure it out. Boo hoo. - if (evaluateIdx == -1) evaluateIdx = metaObject()->methodCount(); - - QDeclarative_setParent_noEvent(this, parent); - QDeclarativePropertyPrivate::connect(scope, m_signal.methodIndex(), this, evaluateIdx); - - m_expression = new QDeclarativeExpression(ctxt, scope, val); -} - -QDeclarativeBoundSignal::~QDeclarativeBoundSignal() -{ - delete m_expression; - m_expression = 0; -} - -int QDeclarativeBoundSignal::index() const -{ - return m_signal.methodIndex(); -} - -/*! - Returns the signal expression. -*/ -QDeclarativeExpression *QDeclarativeBoundSignal::expression() const -{ - return m_expression; -} - -/*! - Sets the signal expression to \a e. Returns the current signal expression, - or null if there is no signal expression. - - The QDeclarativeBoundSignal instance takes ownership of \a e. The caller is - assumes ownership of the returned QDeclarativeExpression. -*/ -QDeclarativeExpression *QDeclarativeBoundSignal::setExpression(QDeclarativeExpression *e) -{ - QDeclarativeExpression *rv = m_expression; - m_expression = e; - if (m_expression) m_expression->setNotifyOnValueChanged(false); - return rv; -} - -QDeclarativeBoundSignal *QDeclarativeBoundSignal::cast(QObject *o) -{ - QDeclarativeAbstractBoundSignal *s = qobject_cast(o); - return static_cast(s); -} - -int QDeclarativeBoundSignal::qt_metacall(QMetaObject::Call c, int id, void **a) -{ - if (c == QMetaObject::InvokeMetaMethod && id == evaluateIdx) { - if (!m_expression) - return -1; - if (QDeclarativeDebugService::isDebuggingEnabled()) { - QDeclarativeProfilerService::startRange(QDeclarativeProfilerService::HandlingSignal); - QDeclarativeProfilerService::rangeData(QDeclarativeProfilerService::HandlingSignal, QLatin1String(m_signal.signature()) % QLatin1String(": ") % m_expression->expression()); - QDeclarativeProfilerService::rangeLocation(QDeclarativeProfilerService::HandlingSignal, m_expression->sourceFile(), m_expression->lineNumber(), m_expression->columnNumber()); - QV8DebugService::instance()->signalEmitted(QString::fromAscii(m_signal.signature())); - } - m_isEvaluating = true; - if (!m_paramsValid) { - if (!m_signal.parameterTypes().isEmpty()) - m_params = new QDeclarativeBoundSignalParameters(m_signal, this); - m_paramsValid = true; - } - - if (m_params) m_params->setValues(a); - if (m_expression && m_expression->engine()) { - QDeclarativeExpressionPrivate::get(m_expression)->value(m_params); - if (m_expression && m_expression->hasError()) - QDeclarativeEnginePrivate::warning(m_expression->engine(), m_expression->error()); - } - if (m_params) m_params->clearValues(); - m_isEvaluating = false; - QDeclarativeProfilerService::endRange(QDeclarativeProfilerService::HandlingSignal); - return -1; - } else { - return QObject::qt_metacall(c, id, a); - } -} - -QDeclarativeBoundSignalParameters::QDeclarativeBoundSignalParameters(const QMetaMethod &method, - QObject *parent) -: QObject(parent), types(0), values(0) -{ - MetaObject *mo = new MetaObject(this); - - // ### Optimize! - QMetaObjectBuilder mob; - mob.setSuperClass(&QDeclarativeBoundSignalParameters::staticMetaObject); - mob.setClassName("QDeclarativeBoundSignalParameters"); - - QList paramTypes = method.parameterTypes(); - QList paramNames = method.parameterNames(); - types = new int[paramTypes.count()]; - for (int ii = 0; ii < paramTypes.count(); ++ii) { - const QByteArray &type = paramTypes.at(ii); - const QByteArray &name = paramNames.at(ii); - - if (name.isEmpty() || type.isEmpty()) { - types[ii] = 0; - continue; - } - - QVariant::Type t = (QVariant::Type)QMetaType::type(type.constData()); - if (QDeclarativeMetaType::isQObject(t)) { - types[ii] = QMetaType::QObjectStar; - QMetaPropertyBuilder prop = mob.addProperty(name, "QObject*"); - prop.setWritable(false); - } else { - QByteArray propType = type; - if (t >= QVariant::UserType || t == QVariant::Invalid) { - QByteArray scope; - QByteArray name; - int scopeIdx = propType.lastIndexOf("::"); - if (scopeIdx != -1) { - scope = propType.left(scopeIdx); - name = propType.mid(scopeIdx + 2); - } else { - name = propType; - } - const QMetaObject *meta; - if (scope == "Qt") - meta = &QObject::staticQtMetaObject; - else - meta = parent->parent()->metaObject(); //### assumes parent->parent() - for (int i = meta->enumeratorCount() - 1; i >= 0; --i) { - QMetaEnum m = meta->enumerator(i); - if ((m.name() == name) && (scope.isEmpty() || (m.scope() == scope))) { - t = QVariant::Int; - propType = "int"; - break; - } - } - } - types[ii] = t; - QMetaPropertyBuilder prop = mob.addProperty(name, propType); - prop.setWritable(false); - } - } - myMetaObject = mob.toMetaObject(); - *static_cast(mo) = *myMetaObject; - - d_ptr->metaObject = mo; -} - -QDeclarativeBoundSignalParameters::~QDeclarativeBoundSignalParameters() -{ - delete [] types; - free(myMetaObject); -} - -void QDeclarativeBoundSignalParameters::setValues(void **v) -{ - values = v; -} - -void QDeclarativeBoundSignalParameters::clearValues() -{ - values = 0; -} - -int QDeclarativeBoundSignalParameters::metaCall(QMetaObject::Call c, int id, void **a) -{ - if (!values) - return -1; - - if (c == QMetaObject::ReadProperty && id >= 1) { - int t = types[id - 1]; - void *p = a[0]; - QMetaType::destruct(t, p); - QMetaType::construct(t, p, values[id]); - return -1; - } else { - return qt_metacall(c, id, a); - } -} - -QT_END_NAMESPACE - -#include diff --git a/src/declarative/qml/qdeclarativeboundsignal_p.h b/src/declarative/qml/qdeclarativeboundsignal_p.h deleted file mode 100644 index b747d9d7a5..0000000000 --- a/src/declarative/qml/qdeclarativeboundsignal_p.h +++ /dev/null @@ -1,103 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QDECLARATIVEBOUNDSIGNAL_P_H -#define QDECLARATIVEBOUNDSIGNAL_P_H - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists purely as an -// implementation detail. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - -#include "qdeclarativeexpression.h" - -#include - -#include - -QT_BEGIN_NAMESPACE - -class Q_DECLARATIVE_EXPORT QDeclarativeAbstractBoundSignal : public QObject -{ - Q_OBJECT -public: - QDeclarativeAbstractBoundSignal(QObject *parent = 0); - virtual ~QDeclarativeAbstractBoundSignal() = 0; -}; - -class QDeclarativeBoundSignalParameters; -class Q_DECLARATIVE_EXPORT QDeclarativeBoundSignal : public QDeclarativeAbstractBoundSignal -{ -public: - QDeclarativeBoundSignal(QObject *scope, const QMetaMethod &signal, QObject *parent); - QDeclarativeBoundSignal(QDeclarativeContext *ctxt, const QString &val, QObject *scope, - const QMetaMethod &signal, QObject *parent); - virtual ~QDeclarativeBoundSignal(); - - int index() const; - - QDeclarativeExpression *expression() const; - QDeclarativeExpression *setExpression(QDeclarativeExpression *); - - bool isEvaluating() const { return m_isEvaluating; } - - static QDeclarativeBoundSignal *cast(QObject *); - -protected: - virtual int qt_metacall(QMetaObject::Call c, int id, void **a); - -private: - QDeclarativeExpression *m_expression; - QMetaMethod m_signal; - bool m_paramsValid : 1; - bool m_isEvaluating : 1; - QDeclarativeBoundSignalParameters *m_params; -}; - -QT_END_NAMESPACE - -#endif // QDECLARATIVEBOUNDSIGNAL_P_H diff --git a/src/declarative/qml/qdeclarativecleanup.cpp b/src/declarative/qml/qdeclarativecleanup.cpp deleted file mode 100644 index aa7a1e3254..0000000000 --- a/src/declarative/qml/qdeclarativecleanup.cpp +++ /dev/null @@ -1,118 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qdeclarativecleanup_p.h" - -#include "qdeclarativeengine_p.h" - -QT_BEGIN_NAMESPACE - -/*! -\internal -\class QDeclarativeCleanup -\brief The QDeclarativeCleanup provides a callback when a QDeclarativeEngine is deleted. - -Any object that needs cleanup to occur before the QDeclarativeEngine's V8 engine is -destroyed should inherit from QDeclarativeCleanup. The clear() virtual method will be -called by QDeclarativeEngine just before it destroys the context. -*/ - - -/* -Create a QDeclarativeCleanup that is not associated with any engine. -*/ -QDeclarativeCleanup::QDeclarativeCleanup() -: prev(0), next(0), engine(0) -{ -} - -/*! -Create a QDeclarativeCleanup for \a engine -*/ -QDeclarativeCleanup::QDeclarativeCleanup(QDeclarativeEngine *engine) -: prev(0), next(0), engine(0) -{ - if (!engine) - return; - - addToEngine(engine); -} - -/*! -Adds this object to \a engine's cleanup list. hasEngine() must be false -before calling this method. -*/ -void QDeclarativeCleanup::addToEngine(QDeclarativeEngine *engine) -{ - Q_ASSERT(engine); - Q_ASSERT(QDeclarativeEnginePrivate::isEngineThread(engine)); - - this->engine = engine; - - QDeclarativeEnginePrivate *p = QDeclarativeEnginePrivate::get(engine); - - if (p->cleanup) next = p->cleanup; - p->cleanup = this; - prev = &p->cleanup; - if (next) next->prev = &next; -} - -/*! -\fn bool QDeclarativeCleanup::hasEngine() const - -Returns true if this QDeclarativeCleanup is associated with an engine, otherwise false. -*/ - -/*! -\internal -*/ -QDeclarativeCleanup::~QDeclarativeCleanup() -{ - Q_ASSERT(!prev || engine); - Q_ASSERT(!prev || QDeclarativeEnginePrivate::isEngineThread(engine)); - - if (prev) *prev = next; - if (next) next->prev = prev; - prev = 0; - next = 0; -} - -QT_END_NAMESPACE diff --git a/src/declarative/qml/qdeclarativecleanup_p.h b/src/declarative/qml/qdeclarativecleanup_p.h deleted file mode 100644 index bf84269698..0000000000 --- a/src/declarative/qml/qdeclarativecleanup_p.h +++ /dev/null @@ -1,87 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QDECLARATIVECLEANUP_P_H -#define QDECLARATIVECLEANUP_P_H - -#include - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists purely as an -// implementation detail. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - -QT_BEGIN_NAMESPACE - -class QDeclarativeEngine; - -// Exported for QtQuick1 -class Q_DECLARATIVE_EXPORT QDeclarativeCleanup -{ -public: - QDeclarativeCleanup(); - QDeclarativeCleanup(QDeclarativeEngine *); - virtual ~QDeclarativeCleanup(); - - bool hasEngine() const { return prev != 0; } - void addToEngine(QDeclarativeEngine *); -protected: - virtual void clear() = 0; - -private: - friend class QDeclarativeEnginePrivate; - QDeclarativeCleanup **prev; - QDeclarativeCleanup *next; - - // Only used for asserts - QDeclarativeEngine *engine; -}; - -QT_END_NAMESPACE - -#endif // QDECLARATIVECLEANUP_P_H - diff --git a/src/declarative/qml/qdeclarativecompileddata.cpp b/src/declarative/qml/qdeclarativecompileddata.cpp deleted file mode 100644 index 6ace1d3042..0000000000 --- a/src/declarative/qml/qdeclarativecompileddata.cpp +++ /dev/null @@ -1,261 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qdeclarativecompiler_p.h" -#include "qdeclarativeengine.h" -#include "qdeclarativecomponent.h" -#include "qdeclarativecomponent_p.h" -#include "qdeclarativecontext.h" -#include "qdeclarativecontext_p.h" -#ifdef QML_THREADED_VME_INTERPRETER -#include "qdeclarativevme_p.h" -#endif - -#include - -#include - -QT_BEGIN_NAMESPACE - -int QDeclarativeCompiledData::pack(const char *data, size_t size) -{ - const char *p = packData.constData(); - unsigned int ps = packData.size(); - - for (unsigned int ii = 0; (ii + size) <= ps; ii += sizeof(int)) { - if (0 == ::memcmp(p + ii, data, size)) - return ii; - } - - int rv = packData.size(); - packData.append(data, size); - return rv; -} - -int QDeclarativeCompiledData::indexForString(const QString &data) -{ - int idx = primitives.indexOf(data); - if (idx == -1) { - idx = primitives.count(); - primitives << data; - } - return idx; -} - -int QDeclarativeCompiledData::indexForByteArray(const QByteArray &data) -{ - int idx = datas.indexOf(data); - if (idx == -1) { - idx = datas.count(); - datas << data; - } - return idx; -} - -int QDeclarativeCompiledData::indexForUrl(const QUrl &data) -{ - int idx = urls.indexOf(data); - if (idx == -1) { - idx = urls.count(); - urls << data; - } - return idx; -} - -QDeclarativeCompiledData::QDeclarativeCompiledData(QDeclarativeEngine *engine) -: engine(engine), importCache(0), root(0), rootPropertyCache(0) -{ - Q_ASSERT(engine); - - bytecode.reserve(1024); -} - -void QDeclarativeCompiledData::destroy() -{ - if (engine && hasEngine()) - QDeclarativeEnginePrivate::deleteInEngineThread(engine, this); - else - delete this; -} - -QDeclarativeCompiledData::~QDeclarativeCompiledData() -{ - clear(); - - for (int ii = 0; ii < types.count(); ++ii) { - if (types.at(ii).component) - types.at(ii).component->release(); - if (types.at(ii).typePropertyCache) - types.at(ii).typePropertyCache->release(); - } - - for (int ii = 0; ii < propertyCaches.count(); ++ii) - propertyCaches.at(ii)->release(); - - for (int ii = 0; ii < contextCaches.count(); ++ii) - contextCaches.at(ii)->release(); - - for (int ii = 0; ii < scripts.count(); ++ii) - scripts.at(ii)->release(); - - if (importCache) - importCache->release(); - - if (rootPropertyCache) - rootPropertyCache->release(); -} - -void QDeclarativeCompiledData::clear() -{ - for (int ii = 0; ii < programs.count(); ++ii) - qPersistentDispose(programs[ii].bindings); -} - -const QMetaObject *QDeclarativeCompiledData::TypeReference::metaObject() const -{ - if (type) { - return type->metaObject(); - } else { - Q_ASSERT(component); - return component->root; - } -} - -/*! -Returns the property cache, if one alread exists. The cache is not referenced. -*/ -QDeclarativePropertyCache *QDeclarativeCompiledData::TypeReference::propertyCache() const -{ - if (type) - return typePropertyCache; - else - return component->rootPropertyCache; -} - -/*! -Returns the property cache, creating one if it doesn't already exist. The cache is not referenced. -*/ -QDeclarativePropertyCache *QDeclarativeCompiledData::TypeReference::createPropertyCache(QDeclarativeEngine *engine) -{ - if (typePropertyCache) { - return typePropertyCache; - } else if (type) { - typePropertyCache = QDeclarativeEnginePrivate::get(engine)->cache(type->metaObject()); - typePropertyCache->addref(); - return typePropertyCache; - } else { - return component->rootPropertyCache; - } -} - - -void QDeclarativeCompiledData::dumpInstructions() -{ - if (!name.isEmpty()) - qWarning() << name; - qWarning().nospace() << "Index\tOperation\t\tData1\tData2\tData3\tComments"; - qWarning().nospace() << "-------------------------------------------------------------------------------"; - - const char *instructionStream = bytecode.constData(); - const char *endInstructionStream = bytecode.constData() + bytecode.size(); - - int instructionCount = 0; - while (instructionStream < endInstructionStream) { - QDeclarativeInstruction *instr = (QDeclarativeInstruction *)instructionStream; - dump(instr, instructionCount); - instructionStream += QDeclarativeInstruction::size(instructionType(instr)); - instructionCount++; - } - - qWarning().nospace() << "-------------------------------------------------------------------------------"; -} - -int QDeclarativeCompiledData::addInstructionHelper(QDeclarativeInstruction::Type type, QDeclarativeInstruction &instr) -{ -#ifdef QML_THREADED_VME_INTERPRETER - instr.common.code = QDeclarativeVME::instructionJumpTable()[static_cast(type)]; -#else - instr.common.instructionType = type; -#endif - int ptrOffset = bytecode.size(); - int size = QDeclarativeInstruction::size(type); - if (bytecode.capacity() <= bytecode.size() + size) - bytecode.reserve(bytecode.size() + size + 512); - bytecode.append(reinterpret_cast(&instr), size); - return ptrOffset; -} - -int QDeclarativeCompiledData::nextInstructionIndex() -{ - return bytecode.size(); -} - -QDeclarativeInstruction *QDeclarativeCompiledData::instruction(int index) -{ - return (QDeclarativeInstruction *)(bytecode.constData() + index); -} - -QDeclarativeInstruction::Type QDeclarativeCompiledData::instructionType(const QDeclarativeInstruction *instr) -{ -#ifdef QML_THREADED_VME_INTERPRETER - void **jumpTable = QDeclarativeVME::instructionJumpTable(); - void *code = instr->common.code; - -# define QML_CHECK_INSTR_CODE(I, FMT) \ - if (jumpTable[static_cast(QDeclarativeInstruction::I)] == code) \ - return QDeclarativeInstruction::I; - - FOR_EACH_QML_INSTR(QML_CHECK_INSTR_CODE) - Q_ASSERT_X(false, Q_FUNC_INFO, "Invalid instruction address"); - return static_cast(0); -# undef QML_CHECK_INSTR_CODE -#else - return static_cast(instr->common.instructionType); -#endif -} - -void QDeclarativeCompiledData::initialize(QDeclarativeEngine *engine) -{ - Q_ASSERT(!hasEngine()); - QDeclarativeCleanup::addToEngine(engine); -} - -QT_END_NAMESPACE diff --git a/src/declarative/qml/qdeclarativecompiler.cpp b/src/declarative/qml/qdeclarativecompiler.cpp deleted file mode 100644 index c4efc85461..0000000000 --- a/src/declarative/qml/qdeclarativecompiler.cpp +++ /dev/null @@ -1,3882 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qdeclarativecompiler_p.h" - -#include "qdeclarativepropertyvaluesource.h" -#include "qdeclarativecomponent.h" -#include -#include -#include "qdeclarativestringconverters_p.h" -#include "qdeclarativeengine_p.h" -#include "qdeclarativeengine.h" -#include "qdeclarativecontext.h" -#include "qdeclarativemetatype_p.h" -#include "qdeclarativecustomparser_p_p.h" -#include "qdeclarativecontext_p.h" -#include "qdeclarativecomponent_p.h" -#include -#include "qdeclarativevmemetaobject_p.h" -#include "qdeclarativeexpression_p.h" -#include "qdeclarativeproperty_p.h" -#include "qdeclarativerewrite_p.h" -#include "qdeclarativescriptstring.h" -#include "qdeclarativeglobal_p.h" -#include "qdeclarativebinding_p.h" -#include - -#include -#include -#include -#include -#include -#include -#include -#include - -Q_DECLARE_METATYPE(QList) -Q_DECLARE_METATYPE(QList) -Q_DECLARE_METATYPE(QList) -Q_DECLARE_METATYPE(QList) -Q_DECLARE_METATYPE(QList) - -QT_BEGIN_NAMESPACE - -DEFINE_BOOL_CONFIG_OPTION(compilerDump, QML_COMPILER_DUMP); -DEFINE_BOOL_CONFIG_OPTION(compilerStatDump, QML_COMPILER_STATS); - -using namespace QDeclarativeJS; -using namespace QDeclarativeScript; -using namespace QDeclarativeCompilerTypes; - -static QString id_string(QLatin1String("id")); -static QString on_string(QLatin1String("on")); -static QString Changed_string(QLatin1String("Changed")); -static QString Component_string(QLatin1String("Component")); -static QString Component_import_string(QLatin1String("QML/Component")); -static QString qsTr_string(QLatin1String("qsTr")); -static QString qsTrId_string(QLatin1String("qsTrId")); - -/*! - Instantiate a new QDeclarativeCompiler. -*/ -QDeclarativeCompiler::QDeclarativeCompiler(QDeclarativePool *pool) -: pool(pool), output(0), engine(0), unitRoot(0), unit(0), cachedComponentTypeRef(-1), - cachedTranslationContextIndex(-1), componentStats(0) -{ - if (compilerStatDump()) - componentStats = pool->New(); -} - -/*! - Returns true if the last call to compile() caused errors. - - \sa errors() -*/ -bool QDeclarativeCompiler::isError() const -{ - return !exceptions.isEmpty(); -} - -/*! - Return the list of errors from the last call to compile(), or an empty list - if there were no errors. -*/ -QList QDeclarativeCompiler::errors() const -{ - return exceptions; -} - -/*! - Returns true if \a name refers to an attached property, false otherwise. - - Attached property names are those that start with a capital letter. -*/ -bool QDeclarativeCompiler::isAttachedPropertyName(const QString &name) -{ - return isAttachedPropertyName(QHashedStringRef(&name)); -} - -bool QDeclarativeCompiler::isAttachedPropertyName(const QHashedStringRef &name) -{ - return !name.isEmpty() && name.at(0).isUpper(); -} - -/*! - Returns true if \a name refers to a signal property, false otherwise. - - Signal property names are those that start with "on", followed by a first - character which is either a capital letter or one or more underscores followed - by a capital letter, which is then followed by other allowed characters. - - Note that although ECMA-262r3 supports dollarsigns and escaped unicode - character codes in property names, for simplicity and performance reasons - QML only supports letters, numbers and underscores. -*/ -bool QDeclarativeCompiler::isSignalPropertyName(const QString &name) -{ - return isSignalPropertyName(QStringRef(&name)); -} - -bool QDeclarativeCompiler::isSignalPropertyName(const QHashedStringRef &name) -{ - if (name.length() < 3) return false; - if (!name.startsWith(on_string)) return false; - int ns = name.length(); - for (int i = 2; i < ns; ++i) { - const QChar curr = name.at(i); - if (curr.unicode() == '_') continue; - if (curr.isUpper()) return true; - return false; - } - return false; // consists solely of underscores - invalid. -} - -/*! - \macro COMPILE_EXCEPTION - \internal - Inserts an error into the QDeclarativeCompiler error list, and returns false - (failure). - - \a token is used to source the error line and column, and \a desc is the - error itself. \a desc can be an expression that can be piped into QDebug. - - For example: - - \code - COMPILE_EXCEPTION(property, tr("Error for property \"%1\"").arg(property->name)); - \endcode -*/ -#define COMPILE_EXCEPTION_LOCATION(line, column, desc) \ - { \ - QDeclarativeError error; \ - error.setUrl(output->url); \ - error.setLine(line); \ - error.setColumn(column); \ - error.setDescription(desc.trimmed()); \ - exceptions << error; \ - return false; \ - } - -#define COMPILE_EXCEPTION(token, desc) \ - COMPILE_EXCEPTION_LOCATION((token)->location.start.line, (token)->location.start.column, desc) - -/*! - \macro COMPILE_CHECK - \internal - Returns false if \a is false, otherwise does nothing. -*/ -#define COMPILE_CHECK(a) \ - { \ - if (!a) return false; \ - } - -/*! - Returns true if literal \a v can be assigned to property \a prop, otherwise - false. - - This test corresponds to action taken by genLiteralAssignment(). Any change - made here, must have a corresponding action in genLiteralAssigment(). -*/ -bool QDeclarativeCompiler::testLiteralAssignment(QDeclarativeScript::Property *prop, - QDeclarativeScript::Value *v) -{ - const QDeclarativeScript::Variant &value = v->value; - - if (!prop->core.isWritable() && !prop->isReadOnlyDeclaration) - COMPILE_EXCEPTION(v, tr("Invalid property assignment: \"%1\" is a read-only property").arg(prop->name().toString())); - - if (prop->core.isEnum()) { - QMetaProperty p = prop->parent->metaObject()->property(prop->index); - int enumValue; - bool ok; - if (p.isFlagType()) { - enumValue = p.enumerator().keysToValue(value.asString().toUtf8().constData(), &ok); - } else - enumValue = p.enumerator().keyToValue(value.asString().toUtf8().constData(), &ok); - - if (!ok) - COMPILE_EXCEPTION(v, tr("Invalid property assignment: unknown enumeration")); - - v->value = QDeclarativeScript::Variant((double)enumValue); - return true; - } - - int type = prop->type; - - switch(type) { - case QMetaType::QVariant: - break; - case QVariant::String: - if (!v->value.isString()) COMPILE_EXCEPTION(v, tr("Invalid property assignment: string expected")); - break; - case QVariant::StringList: // we expect a string literal. A string list is not a literal assignment. - if (!v->value.isString()) COMPILE_EXCEPTION(v, tr("Invalid property assignment: string or string list expected")); - break; - case QVariant::ByteArray: - if (!v->value.isString()) COMPILE_EXCEPTION(v, tr("Invalid property assignment: byte array expected")); - break; - case QVariant::Url: - if (!v->value.isString()) COMPILE_EXCEPTION(v, tr("Invalid property assignment: url expected")); - break; - case QVariant::RegExp: - COMPILE_EXCEPTION(v, tr("Invalid property assignment: regular expression expected; use /pattern/ syntax")); - break; - case QVariant::UInt: - { - bool ok = v->value.isNumber(); - if (ok) { - double n = v->value.asNumber(); - if (double(uint(n)) != n) - ok = false; - } - if (!ok) COMPILE_EXCEPTION(v, tr("Invalid property assignment: unsigned int expected")); - } - break; - case QVariant::Int: - { - bool ok = v->value.isNumber(); - if (ok) { - double n = v->value.asNumber(); - if (double(int(n)) != n) - ok = false; - } - if (!ok) COMPILE_EXCEPTION(v, tr("Invalid property assignment: int expected")); - } - break; - case QMetaType::Float: - if (!v->value.isNumber()) COMPILE_EXCEPTION(v, tr("Invalid property assignment: number expected")); - break; - case QVariant::Double: - if (!v->value.isNumber()) COMPILE_EXCEPTION(v, tr("Invalid property assignment: number expected")); - break; - case QVariant::Color: - { - bool ok; - QDeclarativeStringConverters::colorFromString(value.asString(), &ok); - if (!ok) COMPILE_EXCEPTION(v, tr("Invalid property assignment: color expected")); - } - break; -#ifndef QT_NO_DATESTRING - case QVariant::Date: - { - bool ok; - QDeclarativeStringConverters::dateFromString(value.asString(), &ok); - if (!ok) COMPILE_EXCEPTION(v, tr("Invalid property assignment: date expected")); - } - break; - case QVariant::Time: - { - bool ok; - QDeclarativeStringConverters::timeFromString(value.asString(), &ok); - if (!ok) COMPILE_EXCEPTION(v, tr("Invalid property assignment: time expected")); - } - break; - case QVariant::DateTime: - { - bool ok; - QDeclarativeStringConverters::dateTimeFromString(value.asString(), &ok); - if (!ok) COMPILE_EXCEPTION(v, tr("Invalid property assignment: datetime expected")); - } - break; -#endif // QT_NO_DATESTRING - case QVariant::Point: - case QVariant::PointF: - { - bool ok; - QDeclarativeStringConverters::pointFFromString(value.asString(), &ok); - if (!ok) COMPILE_EXCEPTION(v, tr("Invalid property assignment: point expected")); - } - break; - case QVariant::Size: - case QVariant::SizeF: - { - bool ok; - QDeclarativeStringConverters::sizeFFromString(value.asString(), &ok); - if (!ok) COMPILE_EXCEPTION(v, tr("Invalid property assignment: size expected")); - } - break; - case QVariant::Rect: - case QVariant::RectF: - { - bool ok; - QDeclarativeStringConverters::rectFFromString(value.asString(), &ok); - if (!ok) COMPILE_EXCEPTION(v, tr("Invalid property assignment: rect expected")); - } - break; - case QVariant::Bool: - { - if (!v->value.isBoolean()) COMPILE_EXCEPTION(v, tr("Invalid property assignment: boolean expected")); - } - break; - case QVariant::Vector3D: - { - bool ok; - QDeclarativeStringConverters::vector3DFromString(value.asString(), &ok); - if (!ok) COMPILE_EXCEPTION(v, tr("Invalid property assignment: 3D vector expected")); - } - break; - case QVariant::Vector4D: - { - bool ok; - QDeclarativeStringConverters::vector4DFromString(value.asString(), &ok); - if (!ok) COMPILE_EXCEPTION(v, tr("Invalid property assignment: 4D vector expected")); - } - break; - default: - { - // check if assigning a literal value to a list property. - // in each case, check the singular, since an Array of the specified type - // will not go via this literal assignment codepath. - if (type == qMetaTypeId >()) { - if (!v->value.isNumber()) { - COMPILE_EXCEPTION(v, tr("Invalid property assignment: real or array of reals expected")); - } - break; - } else if (type == qMetaTypeId >()) { - bool ok = v->value.isNumber(); - if (ok) { - double n = v->value.asNumber(); - if (double(int(n)) != n) - ok = false; - } - if (!ok) COMPILE_EXCEPTION(v, tr("Invalid property assignment: int or array of ints expected")); - break; - } else if (type == qMetaTypeId >()) { - if (!v->value.isBoolean()) { - COMPILE_EXCEPTION(v, tr("Invalid property assignment: bool or array of bools expected")); - } - break; - } else if (type == qMetaTypeId >()) { // we expect a string literal. A string list is not a literal assignment. - if (!v->value.isString()) { - COMPILE_EXCEPTION(v, tr("Invalid property assignment: string or array of strings expected")); - } - break; - } else if (type == qMetaTypeId >()) { - if (!v->value.isString()) { - COMPILE_EXCEPTION(v, tr("Invalid property assignment: url or array of urls expected")); - } - break; - } - - // otherwise, check for existence of string converter to custom type - QDeclarativeMetaType::StringConverter converter = QDeclarativeMetaType::customStringConverter(type); - if (!converter) - COMPILE_EXCEPTION(v, tr("Invalid property assignment: unsupported type \"%1\"").arg(QString::fromLatin1(QVariant::typeToName((QVariant::Type)type)))); - } - break; - } - return true; -} - -static QUrl urlFromUserString(const QString &data) -{ - QUrl u; - // Preserve any valid percent-encoded octets supplied by the source - u.setEncodedUrl(data.toUtf8(), QUrl::TolerantMode); - return u; -} - -/*! - Generate a store instruction for assigning literal \a v to property \a prop. - - Any literal assignment that is approved in testLiteralAssignment() must have - a corresponding action in this method. -*/ -void QDeclarativeCompiler::genLiteralAssignment(QDeclarativeScript::Property *prop, - QDeclarativeScript::Value *v) -{ - if (prop->core.isEnum()) { - Q_ASSERT(v->value.isNumber()); - // Preresolved value - int value = (int)v->value.asNumber(); - - Instruction::StoreInteger instr; - instr.propertyIndex = prop->index; - instr.value = value; - output->addInstruction(instr); - return; - } - - int type = prop->type; - switch(type) { - case QMetaType::QVariant: - { - if (v->value.isNumber()) { - double n = v->value.asNumber(); - if (double(int(n)) == n) { - if (prop->core.isVMEProperty()) { - Instruction::StoreVarInteger instr; - instr.propertyIndex = prop->index; - instr.value = int(n); - output->addInstruction(instr); - } else { - Instruction::StoreVariantInteger instr; - instr.propertyIndex = prop->index; - instr.value = int(n); - output->addInstruction(instr); - } - } else { - if (prop->core.isVMEProperty()) { - Instruction::StoreVarDouble instr; - instr.propertyIndex = prop->index; - instr.value = n; - output->addInstruction(instr); - } else { - Instruction::StoreVariantDouble instr; - instr.propertyIndex = prop->index; - instr.value = n; - output->addInstruction(instr); - } - } - } else if (v->value.isBoolean()) { - if (prop->core.isVMEProperty()) { - Instruction::StoreVarBool instr; - instr.propertyIndex = prop->index; - instr.value = v->value.asBoolean(); - output->addInstruction(instr); - } else { - Instruction::StoreVariantBool instr; - instr.propertyIndex = prop->index; - instr.value = v->value.asBoolean(); - output->addInstruction(instr); - } - } else { - if (prop->core.isVMEProperty()) { - Instruction::StoreVar instr; - instr.propertyIndex = prop->index; - instr.value = output->indexForString(v->value.asString()); - output->addInstruction(instr); - } else { - Instruction::StoreVariant instr; - instr.propertyIndex = prop->index; - instr.value = output->indexForString(v->value.asString()); - output->addInstruction(instr); - } - } - } - break; - case QVariant::String: - { - Instruction::StoreString instr; - instr.propertyIndex = prop->index; - instr.value = output->indexForString(v->value.asString()); - output->addInstruction(instr); - } - break; - case QVariant::StringList: - { - Instruction::StoreStringList instr; - instr.propertyIndex = prop->index; - instr.value = output->indexForString(v->value.asString()); - output->addInstruction(instr); - } - break; - case QVariant::ByteArray: - { - Instruction::StoreByteArray instr; - instr.propertyIndex = prop->index; - instr.value = output->indexForByteArray(v->value.asString().toLatin1()); - output->addInstruction(instr); - } - break; - case QVariant::Url: - { - Instruction::StoreUrl instr; - QString string = v->value.asString(); - QUrl u = string.isEmpty() ? QUrl() : output->url.resolved(urlFromUserString(string)); - instr.propertyIndex = prop->index; - instr.value = output->indexForUrl(u); - output->addInstruction(instr); - } - break; - case QVariant::UInt: - { - Instruction::StoreInteger instr; - instr.propertyIndex = prop->index; - instr.value = uint(v->value.asNumber()); - output->addInstruction(instr); - } - break; - case QVariant::Int: - { - Instruction::StoreInteger instr; - instr.propertyIndex = prop->index; - instr.value = int(v->value.asNumber()); - output->addInstruction(instr); - } - break; - case QMetaType::Float: - { - Instruction::StoreFloat instr; - instr.propertyIndex = prop->index; - instr.value = float(v->value.asNumber()); - output->addInstruction(instr); - } - break; - case QVariant::Double: - { - Instruction::StoreDouble instr; - instr.propertyIndex = prop->index; - instr.value = v->value.asNumber(); - output->addInstruction(instr); - } - break; - case QVariant::Color: - { - Instruction::StoreColor instr; - QColor c = QDeclarativeStringConverters::colorFromString(v->value.asString()); - instr.propertyIndex = prop->index; - instr.value = c.rgba(); - output->addInstruction(instr); - } - break; -#ifndef QT_NO_DATESTRING - case QVariant::Date: - { - Instruction::StoreDate instr; - QDate d = QDeclarativeStringConverters::dateFromString(v->value.asString()); - instr.propertyIndex = prop->index; - instr.value = d.toJulianDay(); - output->addInstruction(instr); - } - break; - case QVariant::Time: - { - Instruction::StoreTime instr; - QTime time = QDeclarativeStringConverters::timeFromString(v->value.asString()); - instr.propertyIndex = prop->index; - Q_ASSERT(sizeof(instr.time) == sizeof(QTime)); - ::memcpy(&instr.time, &time, sizeof(QTime)); - output->addInstruction(instr); - } - break; - case QVariant::DateTime: - { - Instruction::StoreDateTime instr; - QDateTime dateTime = QDeclarativeStringConverters::dateTimeFromString(v->value.asString()); - QTime time = dateTime.time(); - instr.propertyIndex = prop->index; - instr.date = dateTime.date().toJulianDay(); - Q_ASSERT(sizeof(instr.time) == sizeof(QTime)); - ::memcpy(&instr.time, &time, sizeof(QTime)); - output->addInstruction(instr); - } - break; -#endif // QT_NO_DATESTRING - case QVariant::Point: - { - Instruction::StorePoint instr; - bool ok; - QPoint point = QDeclarativeStringConverters::pointFFromString(v->value.asString(), &ok).toPoint(); - instr.propertyIndex = prop->index; - instr.point.xp = point.x(); - instr.point.yp = point.y(); - output->addInstruction(instr); - } - break; - case QVariant::PointF: - { - Instruction::StorePointF instr; - bool ok; - QPointF point = QDeclarativeStringConverters::pointFFromString(v->value.asString(), &ok); - instr.propertyIndex = prop->index; - instr.point.xp = point.x(); - instr.point.yp = point.y(); - output->addInstruction(instr); - } - break; - case QVariant::Size: - { - Instruction::StoreSize instr; - bool ok; - QSize size = QDeclarativeStringConverters::sizeFFromString(v->value.asString(), &ok).toSize(); - instr.propertyIndex = prop->index; - instr.size.wd = size.width(); - instr.size.ht = size.height(); - output->addInstruction(instr); - } - break; - case QVariant::SizeF: - { - Instruction::StoreSizeF instr; - bool ok; - QSizeF size = QDeclarativeStringConverters::sizeFFromString(v->value.asString(), &ok); - instr.propertyIndex = prop->index; - instr.size.wd = size.width(); - instr.size.ht = size.height(); - output->addInstruction(instr); - } - break; - case QVariant::Rect: - { - Instruction::StoreRect instr; - bool ok; - QRect rect = QDeclarativeStringConverters::rectFFromString(v->value.asString(), &ok).toRect(); - instr.propertyIndex = prop->index; - instr.rect.x1 = rect.left(); - instr.rect.y1 = rect.top(); - instr.rect.x2 = rect.right(); - instr.rect.y2 = rect.bottom(); - output->addInstruction(instr); - } - break; - case QVariant::RectF: - { - Instruction::StoreRectF instr; - bool ok; - QRectF rect = QDeclarativeStringConverters::rectFFromString(v->value.asString(), &ok); - instr.propertyIndex = prop->index; - instr.rect.xp = rect.left(); - instr.rect.yp = rect.top(); - instr.rect.w = rect.width(); - instr.rect.h = rect.height(); - output->addInstruction(instr); - } - break; - case QVariant::Bool: - { - Instruction::StoreBool instr; - bool b = v->value.asBoolean(); - instr.propertyIndex = prop->index; - instr.value = b; - output->addInstruction(instr); - } - break; - case QVariant::Vector3D: - { - Instruction::StoreVector3D instr; - bool ok; - QVector3D vector = QDeclarativeStringConverters::vector3DFromString(v->value.asString(), &ok); - instr.propertyIndex = prop->index; - instr.vector.xp = vector.x(); - instr.vector.yp = vector.y(); - instr.vector.zp = vector.z(); - output->addInstruction(instr); - } - break; - case QVariant::Vector4D: - { - Instruction::StoreVector4D instr; - bool ok; - QVector4D vector = QDeclarativeStringConverters::vector4DFromString(v->value.asString(), &ok); - instr.propertyIndex = prop->index; - instr.vector.xp = vector.x(); - instr.vector.yp = vector.y(); - instr.vector.zp = vector.z(); - instr.vector.wp = vector.w(); - output->addInstruction(instr); - } - break; - default: - { - // generate single literal value assignment to a list property if required - if (type == qMetaTypeId >()) { - Instruction::StoreDoubleQList instr; - instr.propertyIndex = prop->index; - instr.value = v->value.asNumber(); - output->addInstruction(instr); - break; - } else if (type == qMetaTypeId >()) { - Instruction::StoreIntegerQList instr; - instr.propertyIndex = prop->index; - instr.value = int(v->value.asNumber()); - output->addInstruction(instr); - break; - } else if (type == qMetaTypeId >()) { - Instruction::StoreBoolQList instr; - bool b = v->value.asBoolean(); - instr.propertyIndex = prop->index; - instr.value = b; - output->addInstruction(instr); - break; - } else if (type == qMetaTypeId >()) { - Instruction::StoreUrlQList instr; - QString string = v->value.asString(); - QUrl u = string.isEmpty() ? QUrl() : output->url.resolved(urlFromUserString(string)); - instr.propertyIndex = prop->index; - instr.value = output->indexForUrl(u); - output->addInstruction(instr); - break; - } else if (type == qMetaTypeId >()) { - Instruction::StoreStringQList instr; - instr.propertyIndex = prop->index; - instr.value = output->indexForString(v->value.asString()); - output->addInstruction(instr); - break; - } - - // otherwise, generate custom type literal assignment - Instruction::AssignCustomType instr; - instr.propertyIndex = prop->index; - instr.primitive = output->indexForString(v->value.asString()); - instr.type = type; - output->addInstruction(instr); - } - break; - } -} - -/*! - Resets data by clearing the lists that the QDeclarativeCompiler modifies. -*/ -void QDeclarativeCompiler::reset(QDeclarativeCompiledData *data) -{ - data->types.clear(); - data->primitives.clear(); - data->datas.clear(); - data->bytecode.resize(0); -} - -/*! - Compile \a unit, and store the output in \a out. \a engine is the QDeclarativeEngine - with which the QDeclarativeCompiledData will be associated. - - Returns true on success, false on failure. On failure, the compile errors - are available from errors(). - - If the environment variant QML_COMPILER_DUMP is set - (eg. QML_COMPILER_DUMP=1) the compiled instructions will be dumped to stderr - on a successful compiler. -*/ -bool QDeclarativeCompiler::compile(QDeclarativeEngine *engine, - QDeclarativeTypeData *unit, - QDeclarativeCompiledData *out) -{ - exceptions.clear(); - - Q_ASSERT(out); - reset(out); - - QDeclarativeScript::Object *root = unit->parser().tree(); - Q_ASSERT(root); - - this->engine = engine; - this->enginePrivate = QDeclarativeEnginePrivate::get(engine); - this->unit = unit; - this->unitRoot = root; - this->output = out; - - // Compile types - const QList &resolvedTypes = unit->resolvedTypes(); - QList referencedTypes = unit->parser().referencedTypes(); - - for (int ii = 0; ii < resolvedTypes.count(); ++ii) { - QDeclarativeCompiledData::TypeReference ref; - - const QDeclarativeTypeData::TypeReference &tref = resolvedTypes.at(ii); - QDeclarativeScript::TypeReference *parserRef = referencedTypes.at(ii); - - if (tref.type) { - ref.type = tref.type; - if (!ref.type->isCreatable()) { - QString err = ref.type->noCreationReason(); - if (err.isEmpty()) - err = tr( "Element is not creatable."); - COMPILE_EXCEPTION(parserRef->refObjects.first(), err); - } - - if (ref.type->containsRevisionedAttributes()) { - QDeclarativeError cacheError; - ref.typePropertyCache = enginePrivate->cache(ref.type, resolvedTypes.at(ii).minorVersion, - cacheError); - if (!ref.typePropertyCache) - COMPILE_EXCEPTION(parserRef->refObjects.first(), cacheError.description()); - ref.typePropertyCache->addref(); - } - - } else if (tref.typeData) { - ref.component = tref.typeData->compiledData(); - } - ref.className = parserRef->name; - out->types << ref; - } - - compileTree(root); - - if (!isError()) { - if (compilerDump()) - out->dumpInstructions(); - if (componentStats) - dumpStats(); - Q_ASSERT(out->rootPropertyCache); - } else { - reset(out); - } - - compileState = 0; - output = 0; - this->engine = 0; - this->enginePrivate = 0; - this->unit = 0; - this->cachedComponentTypeRef = -1; - this->cachedTranslationContextIndex = -1; - this->unitRoot = 0; - - return !isError(); -} - -void QDeclarativeCompiler::compileTree(QDeclarativeScript::Object *tree) -{ - compileState = pool->New(); - - compileState->root = tree; - if (componentStats) - componentStats->componentStat.lineNumber = tree->location.start.line; - - // We generate the importCache before we build the tree so that - // it can be used in the binding compiler. Given we "expect" the - // QML compilation to succeed, this isn't a waste. - output->importCache = new QDeclarativeTypeNameCache(); - foreach (const QString &ns, unit->namespaces()) { - output->importCache->add(ns); - } - - int scriptIndex = 0; - foreach (const QDeclarativeTypeData::ScriptReference &script, unit->resolvedScripts()) { - QString qualifier = script.qualifier; - QString enclosingNamespace; - - const int lastDotIndex = qualifier.lastIndexOf(QLatin1Char('.')); - if (lastDotIndex != -1) { - enclosingNamespace = qualifier.left(lastDotIndex); - qualifier = qualifier.mid(lastDotIndex+1); - } - - output->importCache->add(qualifier, scriptIndex++, enclosingNamespace); - } - - unit->imports().populateCache(output->importCache, engine); - - if (!buildObject(tree, BindingContext()) || !completeComponentBuild()) - return; - - Instruction::Init init; - init.bindingsSize = compileState->totalBindingsCount; - init.parserStatusSize = compileState->parserStatusCount; - init.contextCache = genContextCache(); - init.objectStackSize = compileState->objectDepth.maxDepth(); - init.listStackSize = compileState->listDepth.maxDepth(); - if (compileState->compiledBindingData.isEmpty()) - init.compiledBinding = -1; - else - init.compiledBinding = output->indexForByteArray(compileState->compiledBindingData); - output->addInstruction(init); - - foreach (const QDeclarativeTypeData::ScriptReference &script, unit->resolvedScripts()) { - Instruction::StoreImportedScript import; - import.value = output->scripts.count(); - - QDeclarativeScriptData *scriptData = script.script->scriptData(); - scriptData->addref(); - output->scripts << scriptData; - output->addInstruction(import); - } - - if (!compileState->v8BindingProgram.isEmpty()) { - Instruction::InitV8Bindings bindings; - int index = output->programs.count(); - - typedef QDeclarativeCompiledData::V8Program V8Program; - output->programs.append(V8Program(compileState->v8BindingProgram, output)); - - bindings.programIndex = index; - bindings.line = compileState->v8BindingProgramLine; - output->addInstruction(bindings); - } - - genObject(tree); - - Instruction::SetDefault def; - output->addInstruction(def); - - Instruction::Done done; - output->addInstruction(done); - - Q_ASSERT(tree->metatype); - - if (tree->metadata.isEmpty()) { - output->root = tree->metatype; - } else { - static_cast(output->rootData) = *tree->metaObject(); - output->root = &output->rootData; - } - if (!tree->metadata.isEmpty()) - enginePrivate->registerCompositeType(output); -} - -static bool QStringList_contains(const QStringList &list, const QHashedStringRef &string) -{ - for (int ii = 0; ii < list.count(); ++ii) - if (string == list.at(ii)) - return true; - - return false; -} - -bool QDeclarativeCompiler::buildObject(QDeclarativeScript::Object *obj, const BindingContext &ctxt) -{ - if (componentStats) - componentStats->componentStat.objects++; - - Q_ASSERT (obj->type != -1); - const QDeclarativeCompiledData::TypeReference &tr = output->types.at(obj->type); - obj->metatype = tr.metaObject(); - - if (tr.type) - obj->typeName = tr.type->qmlTypeName(); - - // This object is a "Component" element - if (tr.type && obj->metatype == &QDeclarativeComponent::staticMetaObject) { - COMPILE_CHECK(buildComponent(obj, ctxt)); - return true; - } - - if (tr.component) { - typedef QDeclarativeInstruction I; - const I *init = ((const I *)tr.component->bytecode.constData()); - Q_ASSERT(init && tr.component->instructionType(init) == QDeclarativeInstruction::Init); - - // Adjust stack depths to include nested components - compileState->objectDepth.pushPop(init->init.objectStackSize); - compileState->listDepth.pushPop(init->init.listStackSize); - compileState->parserStatusCount += init->init.parserStatusSize; - compileState->totalBindingsCount += init->init.bindingsSize; - } - - compileState->objectDepth.push(); - - // Object instantiations reset the binding context - BindingContext objCtxt(obj); - - // Create the synthesized meta object, ignoring aliases - COMPILE_CHECK(checkDynamicMeta(obj)); - COMPILE_CHECK(mergeDynamicMetaProperties(obj)); - COMPILE_CHECK(buildDynamicMeta(obj, IgnoreAliases)); - - // Find the native type and check for the QDeclarativeParserStatus interface - QDeclarativeType *type = toQmlType(obj); - Q_ASSERT(type); - obj->parserStatusCast = type->parserStatusCast(); - if (obj->parserStatusCast != -1) - compileState->parserStatusCount++; - - // Check if this is a custom parser type. Custom parser types allow - // assignments to non-existent properties. These assignments are then - // compiled by the type. - bool isCustomParser = output->types.at(obj->type).type && - output->types.at(obj->type).type->customParser() != 0; - QList customProps; - - // Fetch the list of deferred properties - QStringList deferredList = deferredProperties(obj); - - // Must do id property first. This is to ensure that the id given to any - // id reference created matches the order in which the objects are - // instantiated - for (Property *prop = obj->properties.first(); prop; prop = obj->properties.next(prop)) { - if (prop->name() == id_string) { - COMPILE_CHECK(buildProperty(prop, obj, objCtxt)); - break; - } - } - - // Merge - Property *defaultProperty = 0; - Property *skipProperty = 0; - if (obj->defaultProperty) { - defaultProperty = obj->defaultProperty; - - Property *explicitProperty = 0; - - const QMetaObject *mo = obj->metatype; - int idx = mo->indexOfClassInfo("DefaultProperty"); - if (idx != -1) { - QMetaClassInfo info = mo->classInfo(idx); - const char *p = info.value(); - if (p) { - int plen = 0; - char ord = 0; - while (char c = p[plen++]) { ord |= c; }; - --plen; - - if (ord & 0x80) { - // Utf8 - unoptimal, but seldom hit - QString *s = pool->NewString(QString::fromUtf8(p, plen)); - QHashedStringRef r(*s); - - if (obj->propertiesHashField.test(r.hash())) { - for (Property *ep = obj->properties.first(); ep; ep = obj->properties.next(ep)) { - if (ep->name() == r) { - explicitProperty = ep; - break; - } - } - } - - if (!explicitProperty) - defaultProperty->setName(r); - - } else { - QHashedCStringRef r(p, plen); - - if (obj->propertiesHashField.test(r.hash())) { - for (Property *ep = obj->properties.first(); ep; ep = obj->properties.next(ep)) { - if (ep->name() == r) { - explicitProperty = ep; - break; - } - } - } - - if (!explicitProperty) { - // Set the default property name - QChar *buffer = pool->NewRawArray(r.length()); - r.writeUtf16(buffer); - defaultProperty->setName(QHashedStringRef(buffer, r.length(), r.hash())); - } - } - } - } - - if (explicitProperty && !explicitProperty->value && !explicitProperty->values.isEmpty()) { - - skipProperty = explicitProperty; // We merge the values into defaultProperty - - // Find the correct insertion point - Value *insertPos = 0; - - for (Value *v = defaultProperty->values.first(); v; v = Property::ValueList::next(v)) { - if (!(v->location.start < explicitProperty->values.first()->location.start)) - break; - insertPos = v; - } - - defaultProperty->values.insertAfter(insertPos, explicitProperty->values); - } - } - - QDeclarativeCustomParser *cp = 0; - if (isCustomParser) - cp = output->types.at(obj->type).type->customParser(); - - // Build all explicit properties specified - for (Property *prop = obj->properties.first(); prop; prop = obj->properties.next(prop)) { - - if (prop == skipProperty) - continue; - if (prop->name() == id_string) - continue; - - bool canDefer = false; - if (isCustomParser) { - if (doesPropertyExist(prop, obj) && - (!(cp->flags() & QDeclarativeCustomParser::AcceptsAttachedProperties) || - !isAttachedPropertyName(prop->name()))) { - int ids = compileState->ids.count(); - COMPILE_CHECK(buildProperty(prop, obj, objCtxt)); - canDefer = ids == compileState->ids.count(); - } else if (isSignalPropertyName(prop->name()) && - (cp->flags() & QDeclarativeCustomParser::AcceptsSignalHandlers)) { - COMPILE_CHECK(buildSignal(prop,obj,objCtxt)); - } else { - customProps << QDeclarativeCustomParserNodePrivate::fromProperty(prop); - } - } else { - if (isSignalPropertyName(prop->name())) { - COMPILE_CHECK(buildSignal(prop,obj,objCtxt)); - } else { - int ids = compileState->ids.count(); - COMPILE_CHECK(buildProperty(prop, obj, objCtxt)); - canDefer = ids == compileState->ids.count(); - } - } - - if (canDefer && !deferredList.isEmpty() && QStringList_contains(deferredList, prop->name())) - prop->isDeferred = true; - - } - - // Build the default property - if (defaultProperty) { - Property *prop = defaultProperty; - - bool canDefer = false; - if (isCustomParser) { - if (doesPropertyExist(prop, obj)) { - int ids = compileState->ids.count(); - COMPILE_CHECK(buildProperty(prop, obj, objCtxt)); - canDefer = ids == compileState->ids.count(); - } else { - customProps << QDeclarativeCustomParserNodePrivate::fromProperty(prop); - } - } else { - int ids = compileState->ids.count(); - COMPILE_CHECK(buildProperty(prop, obj, objCtxt)); - canDefer = ids == compileState->ids.count(); - } - - if (canDefer && !deferredList.isEmpty() && QStringList_contains(deferredList, prop->name())) - prop->isDeferred = true; - } - - // Compile custom parser parts - if (isCustomParser && !customProps.isEmpty()) { - cp->clearErrors(); - cp->compiler = this; - cp->object = obj; - obj->custom = cp->compile(customProps); - cp->compiler = 0; - cp->object = 0; - foreach (QDeclarativeError err, cp->errors()) { - err.setUrl(output->url); - exceptions << err; - } - } - - compileState->objectDepth.pop(); - - return true; -} - -void QDeclarativeCompiler::genObject(QDeclarativeScript::Object *obj) -{ - QDeclarativeCompiledData::TypeReference &tr = output->types[obj->type]; - if (tr.type && obj->metatype == &QDeclarativeComponent::staticMetaObject) { - genComponent(obj); - return; - } - - // Create the object - if (obj->custom.isEmpty() && output->types.at(obj->type).type && - !output->types.at(obj->type).type->isExtendedType() && obj != compileState->root) { - - Instruction::CreateSimpleObject create; - create.create = output->types.at(obj->type).type->createFunction(); - create.typeSize = output->types.at(obj->type).type->createSize(); - create.type = obj->type; - create.line = obj->location.start.line; - create.column = obj->location.start.column; - output->addInstruction(create); - - } else { - - if (output->types.at(obj->type).type) { - Instruction::CreateCppObject create; - create.line = obj->location.start.line; - create.column = obj->location.start.column; - create.data = -1; - if (!obj->custom.isEmpty()) - create.data = output->indexForByteArray(obj->custom); - create.type = obj->type; - create.isRoot = (compileState->root == obj); - output->addInstruction(create); - } else { - Instruction::CreateQMLObject create; - create.type = obj->type; - create.isRoot = (compileState->root == obj); - - if (!obj->bindingBitmask.isEmpty()) { - Q_ASSERT(obj->bindingBitmask.size() % 4 == 0); - create.bindingBits = output->indexForByteArray(obj->bindingBitmask); - } else { - create.bindingBits = -1; - } - output->addInstruction(create); - - Instruction::CompleteQMLObject complete; - complete.line = obj->location.start.line; - complete.column = obj->location.start.column; - complete.isRoot = (compileState->root == obj); - output->addInstruction(complete); - } - } - - // Setup the synthesized meta object if necessary - if (!obj->metadata.isEmpty()) { - Instruction::StoreMetaObject meta; - meta.data = output->indexForByteArray(obj->metadata); - meta.aliasData = output->indexForByteArray(obj->synthdata); - meta.propertyCache = output->propertyCaches.count(); - - QDeclarativePropertyCache *propertyCache = obj->synthCache; - Q_ASSERT(propertyCache); - propertyCache->addref(); - - // Add flag for alias properties - if (!obj->synthdata.isEmpty()) { - const QDeclarativeVMEMetaData *vmeMetaData = - reinterpret_cast(obj->synthdata.constData()); - for (int ii = 0; ii < vmeMetaData->aliasCount; ++ii) { - int index = obj->metaObject()->propertyOffset() + vmeMetaData->propertyCount + ii; - QDeclarativePropertyData *data = propertyCache->property(index); - data->setFlags(data->getFlags() | QDeclarativePropertyData::IsAlias); - } - } - - if (obj == unitRoot) { - propertyCache->addref(); - output->rootPropertyCache = propertyCache; - } - - output->propertyCaches << propertyCache; - output->addInstruction(meta); - } else if (obj == unitRoot) { - output->rootPropertyCache = tr.createPropertyCache(engine); - output->rootPropertyCache->addref(); - } - - // Set the object id - if (!obj->id.isEmpty()) { - Instruction::SetId id; - id.value = output->indexForString(obj->id); - id.index = obj->idIndex; - output->addInstruction(id); - } - - // Begin the class - if (tr.type && obj->parserStatusCast != -1) { - Instruction::BeginObject begin; - begin.castValue = obj->parserStatusCast; - output->addInstruction(begin); - } - - genObjectBody(obj); -} - -void QDeclarativeCompiler::genObjectBody(QDeclarativeScript::Object *obj) -{ - for (Property *prop = obj->scriptStringProperties.first(); prop; prop = Object::PropertyList::next(prop)) { - Q_ASSERT(prop->scriptStringScope != -1); - const QString &script = prop->values.first()->value.asScript(); - Instruction::StoreScriptString ss; - ss.propertyIndex = prop->index; - ss.value = output->indexForString(script); - ss.scope = prop->scriptStringScope; -// ss.bindingId = rewriteBinding(script, prop->name()); - ss.bindingId = rewriteBinding(prop->values.first()->value, QString()); // XXX - ss.line = prop->location.start.line; - ss.column = prop->location.start.column; - output->addInstruction(ss); - } - - bool seenDefer = false; - for (Property *prop = obj->valueProperties.first(); prop; prop = Object::PropertyList::next(prop)) { - if (prop->isDeferred) { - seenDefer = true; - continue; - } - if (!prop->isAlias) - genValueProperty(prop, obj); - } - if (seenDefer) { - Instruction::Defer defer; - defer.deferCount = 0; - int deferIdx = output->addInstruction(defer); - int nextInstructionIndex = output->nextInstructionIndex(); - - Instruction::DeferInit dinit; - // XXX - these are now massive over allocations - dinit.bindingsSize = compileState->totalBindingsCount; - dinit.parserStatusSize = compileState->parserStatusCount; - dinit.objectStackSize = compileState->objectDepth.maxDepth(); - dinit.listStackSize = compileState->listDepth.maxDepth(); - output->addInstruction(dinit); - - for (Property *prop = obj->valueProperties.first(); prop; prop = Object::PropertyList::next(prop)) { - if (!prop->isDeferred) - continue; - genValueProperty(prop, obj); - } - - Instruction::Done done; - output->addInstruction(done); - - output->instruction(deferIdx)->defer.deferCount = output->nextInstructionIndex() - nextInstructionIndex; - } - - for (Property *prop = obj->signalProperties.first(); prop; prop = Object::PropertyList::next(prop)) { - - QDeclarativeScript::Value *v = prop->values.first(); - - if (v->type == Value::SignalObject) { - - genObject(v->object); - - Instruction::AssignSignalObject assign; - assign.line = v->location.start.line; - assign.signal = output->indexForString(prop->name().toString()); - output->addInstruction(assign); - - } else if (v->type == Value::SignalExpression) { - - Instruction::StoreSignal store; - store.signalIndex = prop->index; - const QString &rewrite = rewriteSignalHandler(v->value, prop->name().toString()); - store.value = output->indexForByteArray(rewrite.toUtf8()); - store.context = v->signalExpressionContextStack; - store.line = v->location.start.line; - store.column = v->location.start.column; - output->addInstruction(store); - - } - - } - - for (Property *prop = obj->attachedProperties.first(); prop; prop = Object::PropertyList::next(prop)) { - Instruction::FetchAttached fetch; - fetch.id = prop->index; - fetch.line = prop->location.start.line; - output->addInstruction(fetch); - - genObjectBody(prop->value); - - Instruction::PopFetchedObject pop; - output->addInstruction(pop); - } - - for (Property *prop = obj->groupedProperties.first(); prop; prop = Object::PropertyList::next(prop)) { - Instruction::FetchObject fetch; - fetch.property = prop->index; - fetch.line = prop->location.start.line; - output->addInstruction(fetch); - - if (!prop->value->metadata.isEmpty()) { - Instruction::StoreMetaObject meta; - meta.data = output->indexForByteArray(prop->value->metadata); - meta.aliasData = output->indexForByteArray(prop->value->synthdata); - meta.propertyCache = -1; - output->addInstruction(meta); - } - - genObjectBody(prop->value); - - Instruction::PopFetchedObject pop; - output->addInstruction(pop); - } - - for (Property *prop = obj->valueTypeProperties.first(); prop; prop = Object::PropertyList::next(prop)) { - if (!prop->isAlias) - genValueTypeProperty(obj, prop); - } - - for (Property *prop = obj->valueProperties.first(); prop; prop = Object::PropertyList::next(prop)) { - if (prop->isDeferred) - continue; - if (prop->isAlias) - genValueProperty(prop, obj); - } - - for (Property *prop = obj->valueTypeProperties.first(); prop; prop = Object::PropertyList::next(prop)) { - if (prop->isAlias) - genValueTypeProperty(obj, prop); - } -} - -void QDeclarativeCompiler::genValueTypeProperty(QDeclarativeScript::Object *obj,QDeclarativeScript::Property *prop) -{ - Instruction::FetchValueType fetch; - fetch.property = prop->index; - fetch.type = prop->type; - fetch.bindingSkipList = 0; - - if (obj->type == -1 || output->types.at(obj->type).component) { - // We only have to do this if this is a composite type. If it is a builtin - // type it can't possibly already have bindings that need to be cleared. - for (Property *vprop = prop->value->valueProperties.first(); vprop; vprop = Object::PropertyList::next(vprop)) { - if (!vprop->values.isEmpty()) { - Q_ASSERT(vprop->index >= 0 && vprop->index < 32); - fetch.bindingSkipList |= (1 << vprop->index); - } - } - } - - output->addInstruction(fetch); - - for (Property *vprop = prop->value->valueProperties.first(); vprop; vprop = Object::PropertyList::next(vprop)) { - genPropertyAssignment(vprop, prop->value, prop); - } - - Instruction::PopValueType pop; - pop.property = prop->index; - pop.type = prop->type; - pop.bindingSkipList = 0; - output->addInstruction(pop); -} - -void QDeclarativeCompiler::genComponent(QDeclarativeScript::Object *obj) -{ - QDeclarativeScript::Object *root = obj->defaultProperty->values.first()->object; - Q_ASSERT(root); - - Instruction::CreateComponent create; - create.line = root->location.start.line; - create.column = root->location.start.column; - create.endLine = root->location.end.line; - create.isRoot = (compileState->root == obj); - int createInstruction = output->addInstruction(create); - int nextInstructionIndex = output->nextInstructionIndex(); - - ComponentCompileState *oldCompileState = compileState; - compileState = componentState(root); - - Instruction::Init init; - init.bindingsSize = compileState->totalBindingsCount; - init.parserStatusSize = compileState->parserStatusCount; - init.contextCache = genContextCache(); - init.objectStackSize = compileState->objectDepth.maxDepth(); - init.listStackSize = compileState->listDepth.maxDepth(); - if (compileState->compiledBindingData.isEmpty()) - init.compiledBinding = -1; - else - init.compiledBinding = output->indexForByteArray(compileState->compiledBindingData); - output->addInstruction(init); - - if (!compileState->v8BindingProgram.isEmpty()) { - Instruction::InitV8Bindings bindings; - int index = output->programs.count(); - - typedef QDeclarativeCompiledData::V8Program V8Program; - output->programs.append(V8Program(compileState->v8BindingProgram, output)); - - bindings.programIndex = index; - bindings.line = compileState->v8BindingProgramLine; - output->addInstruction(bindings); - } - - genObject(root); - - Instruction::SetDefault def; - output->addInstruction(def); - - Instruction::Done done; - output->addInstruction(done); - - output->instruction(createInstruction)->createComponent.count = - output->nextInstructionIndex() - nextInstructionIndex; - - compileState = oldCompileState; - - if (!obj->id.isEmpty()) { - Instruction::SetId id; - id.value = output->indexForString(obj->id); - id.index = obj->idIndex; - output->addInstruction(id); - } - - if (obj == unitRoot) { - output->rootPropertyCache = output->types[obj->type].createPropertyCache(engine); - output->rootPropertyCache->addref(); - } -} - -bool QDeclarativeCompiler::buildComponent(QDeclarativeScript::Object *obj, - const BindingContext &ctxt) -{ - // The special "Component" element can only have the id property and a - // default property, that actually defines the component's tree - - compileState->objectDepth.push(); - - // Find, check and set the "id" property (if any) - Property *idProp = 0; - if (obj->properties.isMany() || - (obj->properties.isOne() && obj->properties.first()->name() != id_string)) - COMPILE_EXCEPTION(obj->properties.first(), tr("Component elements may not contain properties other than id")); - - if (!obj->properties.isEmpty()) - idProp = obj->properties.first(); - - if (idProp) { - if (idProp->value || idProp->values.isMany() || idProp->values.first()->object) - COMPILE_EXCEPTION(idProp, tr("Invalid component id specification")); - COMPILE_CHECK(checkValidId(idProp->values.first(), idProp->values.first()->primitive())) - - QString idVal = idProp->values.first()->primitive(); - - if (compileState->ids.value(idVal)) - COMPILE_EXCEPTION(idProp, tr("id is not unique")); - - obj->id = idVal; - addId(idVal, obj); - } - - // Check the Component tree is well formed - if (obj->defaultProperty && - (obj->defaultProperty->value || obj->defaultProperty->values.isMany() || - (obj->defaultProperty->values.isOne() && !obj->defaultProperty->values.first()->object))) - COMPILE_EXCEPTION(obj, tr("Invalid component body specification")); - - if (!obj->dynamicProperties.isEmpty()) - COMPILE_EXCEPTION(obj, tr("Component objects cannot declare new properties.")); - if (!obj->dynamicSignals.isEmpty()) - COMPILE_EXCEPTION(obj, tr("Component objects cannot declare new signals.")); - if (!obj->dynamicSlots.isEmpty()) - COMPILE_EXCEPTION(obj, tr("Component objects cannot declare new functions.")); - - QDeclarativeScript::Object *root = 0; - if (obj->defaultProperty && !obj->defaultProperty->values.isEmpty()) - root = obj->defaultProperty->values.first()->object; - - if (!root) - COMPILE_EXCEPTION(obj, tr("Cannot create empty component specification")); - - // Build the component tree - COMPILE_CHECK(buildComponentFromRoot(root, ctxt)); - - compileState->objectDepth.pop(); - - return true; -} - -bool QDeclarativeCompiler::buildComponentFromRoot(QDeclarativeScript::Object *obj, - const BindingContext &ctxt) -{ - ComponentCompileState *oldComponentCompileState = compileState; - compileState = pool->New(); - compileState->root = obj; - compileState->nested = true; - - if (componentStats) { - ComponentStat oldComponentStat = componentStats->componentStat; - - componentStats->componentStat = ComponentStat(); - componentStats->componentStat.lineNumber = obj->location.start.line; - - if (obj) - COMPILE_CHECK(buildObject(obj, ctxt)); - - COMPILE_CHECK(completeComponentBuild()); - - componentStats->componentStat = oldComponentStat; - } else { - if (obj) - COMPILE_CHECK(buildObject(obj, ctxt)); - - COMPILE_CHECK(completeComponentBuild()); - } - - compileState = oldComponentCompileState; - - return true; -} - - -// Build a sub-object. A sub-object is one that was not created directly by -// QML - such as a grouped property object, or an attached object. Sub-object's -// can't have an id, involve a custom parser, have attached properties etc. -bool QDeclarativeCompiler::buildSubObject(QDeclarativeScript::Object *obj, const BindingContext &ctxt) -{ - Q_ASSERT(obj->metatype); - Q_ASSERT(!obj->defaultProperty); - Q_ASSERT(ctxt.isSubContext()); // sub-objects must always be in a binding - // sub-context - - for (Property *prop = obj->properties.first(); prop; prop = obj->properties.next(prop)) { - if (isSignalPropertyName(prop->name())) { - COMPILE_CHECK(buildSignal(prop, obj, ctxt)); - } else { - COMPILE_CHECK(buildProperty(prop, obj, ctxt)); - } - } - - return true; -} - -int QDeclarativeCompiler::componentTypeRef() -{ - if (cachedComponentTypeRef == -1) { - QDeclarativeType *t = QDeclarativeMetaType::qmlType(Component_import_string,1,0); - for (int ii = output->types.count() - 1; ii >= 0; --ii) { - if (output->types.at(ii).type == t) { - cachedComponentTypeRef = ii; - return ii; - } - } - QDeclarativeCompiledData::TypeReference ref; - ref.className = Component_string; - ref.type = t; - output->types << ref; - cachedComponentTypeRef = output->types.count() - 1; - } - return cachedComponentTypeRef; -} - -int QDeclarativeCompiler::translationContextIndex() -{ - if (cachedTranslationContextIndex == -1) { - // This code must match that in the qsTr() implementation - const QString &path = output->name; - int lastSlash = path.lastIndexOf(QLatin1Char('/')); - QString context = (lastSlash > -1) ? path.mid(lastSlash + 1, path.length()-lastSlash-5) : - QString(); - QByteArray contextUtf8 = context.toUtf8(); - cachedTranslationContextIndex = output->indexForByteArray(contextUtf8); - } - return cachedTranslationContextIndex; -} - -bool QDeclarativeCompiler::buildSignal(QDeclarativeScript::Property *prop, QDeclarativeScript::Object *obj, - const BindingContext &ctxt) -{ - Q_ASSERT(obj->metaObject()); - - const QHashedStringRef &propName = prop->name(); - - Q_ASSERT(propName.startsWith(on_string)); - QString name = propName.mid(2, -1).toString(); - - // Note that the property name could start with any alpha or '_' or '$' character, - // so we need to do the lower-casing of the first alpha character. - for (int firstAlphaIndex = 0; firstAlphaIndex < name.size(); ++firstAlphaIndex) { - if (name.at(firstAlphaIndex).isUpper()) { - name[firstAlphaIndex] = name.at(firstAlphaIndex).toLower(); - break; - } - } - - bool notInRevision = false; - - QDeclarativePropertyData *sig = signal(obj, QStringRef(&name), ¬InRevision); - - if (sig == 0) { - - if (notInRevision && 0 == property(obj, propName, 0)) { - Q_ASSERT(obj->type != -1); - const QList &resolvedTypes = unit->resolvedTypes(); - const QDeclarativeTypeData::TypeReference &type = resolvedTypes.at(obj->type); - if (type.type) { - COMPILE_EXCEPTION(prop, tr("\"%1.%2\" is not available in %3 %4.%5.").arg(elementName(obj)).arg(prop->name().toString()).arg(type.type->module()).arg(type.majorVersion).arg(type.minorVersion)); - } else { - COMPILE_EXCEPTION(prop, tr("\"%1.%2\" is not available due to component versioning.").arg(elementName(obj)).arg(prop->name().toString())); - } - } - - // If the "on" name doesn't resolve into a signal, try it as a - // property. - COMPILE_CHECK(buildProperty(prop, obj, ctxt)); - - } else { - - if (prop->value || !prop->values.isOne()) - COMPILE_EXCEPTION(prop, tr("Incorrectly specified signal assignment")); - - prop->index = sig->coreIndex; - prop->core = *sig; - - obj->addSignalProperty(prop); - - if (prop->values.first()->object) { - COMPILE_CHECK(buildObject(prop->values.first()->object, ctxt)); - prop->values.first()->type = Value::SignalObject; - } else { - prop->values.first()->type = Value::SignalExpression; - - if (!prop->values.first()->value.isScript()) - COMPILE_EXCEPTION(prop, tr("Cannot assign a value to a signal (expecting a script to be run)")); - - QString script = prop->values.first()->value.asScript().trimmed(); - if (script.isEmpty()) - COMPILE_EXCEPTION(prop, tr("Empty signal assignment")); - - prop->values.first()->signalExpressionContextStack = ctxt.stack; - } - } - - return true; -} - - -/*! - Returns true if (value) property \a prop exists on obj, false otherwise. -*/ -bool QDeclarativeCompiler::doesPropertyExist(QDeclarativeScript::Property *prop, - QDeclarativeScript::Object *obj) -{ - if (prop->name().isEmpty()) - return false; - if(isAttachedPropertyName(prop->name()) || prop->name() == id_string) - return true; - - return property(obj, prop->name()) != 0; -} - -bool QDeclarativeCompiler::buildProperty(QDeclarativeScript::Property *prop, - QDeclarativeScript::Object *obj, - const BindingContext &ctxt) -{ - if (prop->isEmpty()) - COMPILE_EXCEPTION(prop, tr("Empty property assignment")); - - const QMetaObject *metaObject = obj->metaObject(); - Q_ASSERT(metaObject); - - if (isAttachedPropertyName(prop->name())) { - // Setup attached property data - - if (ctxt.isSubContext()) { - // Attached properties cannot be used on sub-objects. Sub-objects - // always exist in a binding sub-context, which is what we test - // for here. - COMPILE_EXCEPTION(prop, tr("Attached properties cannot be used here")); - } - - QDeclarativeType *type = 0; - QDeclarativeImportedNamespace *typeNamespace = 0; - unit->imports().resolveType(prop->name().toString(), &type, 0, 0, 0, &typeNamespace); - - if (typeNamespace) { - COMPILE_CHECK(buildPropertyInNamespace(typeNamespace, prop, obj, - ctxt)); - return true; - } else if (!type || !type->attachedPropertiesType()) { - COMPILE_EXCEPTION(prop, tr("Non-existent attached object")); - } - - if (!prop->value) - COMPILE_EXCEPTION(prop, tr("Invalid attached object assignment")); - - Q_ASSERT(type->attachedPropertiesFunction()); - prop->index = type->attachedPropertiesId(); - prop->value->metatype = type->attachedPropertiesType(); - } else { - // Setup regular property data - bool notInRevision = false; - QDeclarativePropertyData *d = - prop->name().isEmpty()?0:property(obj, prop->name(), ¬InRevision); - - if (d == 0 && notInRevision) { - const QList &resolvedTypes = unit->resolvedTypes(); - const QDeclarativeTypeData::TypeReference &type = resolvedTypes.at(obj->type); - if (type.type) { - COMPILE_EXCEPTION(prop, tr("\"%1.%2\" is not available in %3 %4.%5.").arg(elementName(obj)).arg(prop->name().toString()).arg(type.type->module()).arg(type.majorVersion).arg(type.minorVersion)); - } else { - COMPILE_EXCEPTION(prop, tr("\"%1.%2\" is not available due to component versioning.").arg(elementName(obj)).arg(prop->name().toString())); - } - } else if (d) { - prop->index = d->coreIndex; - prop->core = *d; - } else if (prop->isDefault) { - QMetaProperty p = QDeclarativeMetaType::defaultProperty(metaObject); - QDeclarativePropertyData defaultPropertyData; - defaultPropertyData.load(p, engine); - if (p.name()) - prop->setName(QLatin1String(p.name())); - prop->core = defaultPropertyData; - prop->index = prop->core.coreIndex; - } - - // We can't error here as the "id" property does not require a - // successful index resolution - if (prop->index != -1) - prop->type = prop->core.propType; - - // Check if this is an alias - if (prop->index != -1 && - prop->parent && - prop->parent->type != -1 && - output->types.at(prop->parent->type).component) { - - QDeclarativePropertyCache *cache = output->types.at(prop->parent->type).component->rootPropertyCache; - if (cache && cache->property(prop->index) && cache->property(prop->index)->isAlias()) - prop->isAlias = true; - } - - if (prop->index != -1 && !prop->values.isEmpty()) - prop->parent->setBindingBit(prop->index); - } - - if (!prop->isDefault && prop->name() == id_string && !ctxt.isSubContext()) { - - // The magic "id" behavior doesn't apply when "id" is resolved as a - // default property or to sub-objects (which are always in binding - // sub-contexts) - COMPILE_CHECK(buildIdProperty(prop, obj)); - if (prop->type == QVariant::String && - prop->values.first()->value.isString()) - COMPILE_CHECK(buildPropertyAssignment(prop, obj, ctxt)); - - } else if (isAttachedPropertyName(prop->name())) { - - COMPILE_CHECK(buildAttachedProperty(prop, obj, ctxt)); - - } else if (prop->index == -1) { - - if (prop->isDefault) { - COMPILE_EXCEPTION(prop->values.first(), tr("Cannot assign to non-existent default property")); - } else { - COMPILE_EXCEPTION(prop, tr("Cannot assign to non-existent property \"%1\"").arg(prop->name().toString())); - } - - } else if (prop->value) { - - COMPILE_CHECK(buildGroupedProperty(prop, obj, ctxt)); - - } else if (prop->core.isQList()) { - - COMPILE_CHECK(buildListProperty(prop, obj, ctxt)); - - } else if (prop->type == qMetaTypeId()) { - - COMPILE_CHECK(buildScriptStringProperty(prop, obj, ctxt)); - - } else { - - COMPILE_CHECK(buildPropertyAssignment(prop, obj, ctxt)); - - } - - return true; -} - -bool QDeclarativeCompiler::buildPropertyInNamespace(QDeclarativeImportedNamespace *ns, - QDeclarativeScript::Property *nsProp, - QDeclarativeScript::Object *obj, - const BindingContext &ctxt) -{ - if (!nsProp->value) - COMPILE_EXCEPTION(nsProp, tr("Invalid use of namespace")); - - for (Property *prop = nsProp->value->properties.first(); prop; prop = nsProp->value->properties.next(prop)) { - - if (!isAttachedPropertyName(prop->name())) - COMPILE_EXCEPTION(prop, tr("Not an attached property name")); - - // Setup attached property data - - QDeclarativeType *type = 0; - unit->imports().resolveType(ns, prop->name().toString(), &type, 0, 0, 0); - - if (!type || !type->attachedPropertiesType()) - COMPILE_EXCEPTION(prop, tr("Non-existent attached object")); - - if (!prop->value) - COMPILE_EXCEPTION(prop, tr("Invalid attached object assignment")); - - Q_ASSERT(type->attachedPropertiesFunction()); - prop->index = type->index(); - prop->value->metatype = type->attachedPropertiesType(); - - COMPILE_CHECK(buildAttachedProperty(prop, obj, ctxt)); - } - - return true; -} - -void QDeclarativeCompiler::genValueProperty(QDeclarativeScript::Property *prop, - QDeclarativeScript::Object *obj) -{ - if (prop->core.isQList()) { - genListProperty(prop, obj); - } else { - genPropertyAssignment(prop, obj); - } -} - -void QDeclarativeCompiler::genListProperty(QDeclarativeScript::Property *prop, - QDeclarativeScript::Object *obj) -{ - int listType = enginePrivate->listType(prop->type); - - Instruction::FetchQList fetch; - fetch.property = prop->index; - bool listTypeIsInterface = QDeclarativeMetaType::isInterface(listType); - fetch.type = listType; - output->addInstruction(fetch); - - for (Value *v = prop->values.first(); v; v = Property::ValueList::next(v)) { - - if (v->type == Value::CreatedObject) { - - genObject(v->object); - if (listTypeIsInterface) { - Instruction::AssignObjectList assign; - assign.line = prop->location.start.line; - output->addInstruction(assign); - } else { - Instruction::StoreObjectQList store; - output->addInstruction(store); - } - - } else if (v->type == Value::PropertyBinding) { - - genBindingAssignment(v, prop, obj); - - } - - } - - Instruction::PopQList pop; - output->addInstruction(pop); -} - -void QDeclarativeCompiler::genPropertyAssignment(QDeclarativeScript::Property *prop, - QDeclarativeScript::Object *obj, - QDeclarativeScript::Property *valueTypeProperty) -{ - for (Value *v = prop->values.first(); v; v = Property::ValueList::next(v)) { - - Q_ASSERT(v->type == Value::CreatedObject || - v->type == Value::PropertyBinding || - v->type == Value::Literal); - - if (v->type == Value::CreatedObject) { - - genObject(v->object); - - if (QDeclarativeMetaType::isInterface(prop->type)) { - - Instruction::StoreInterface store; - store.line = v->object->location.start.line; - store.propertyIndex = prop->index; - output->addInstruction(store); - - } else if (prop->type == QMetaType::QVariant) { - - if (prop->core.isVMEProperty()) { - Instruction::StoreVarObject store; - store.line = v->object->location.start.line; - store.propertyIndex = prop->index; - output->addInstruction(store); - } else { - Instruction::StoreVariantObject store; - store.line = v->object->location.start.line; - store.propertyIndex = prop->index; - output->addInstruction(store); - } - - - } else { - - Instruction::StoreObject store; - store.line = v->object->location.start.line; - store.propertyIndex = prop->index; - output->addInstruction(store); - - } - } else if (v->type == Value::PropertyBinding) { - - genBindingAssignment(v, prop, obj, valueTypeProperty); - - } else if (v->type == Value::Literal) { - - genLiteralAssignment(prop, v); - - } - - } - - for (Value *v = prop->onValues.first(); v; v = Property::ValueList::next(v)) { - - Q_ASSERT(v->type == Value::ValueSource || - v->type == Value::ValueInterceptor); - - if (v->type == Value::ValueSource) { - genObject(v->object); - - Instruction::StoreValueSource store; - if (valueTypeProperty) { - store.property = genValueTypeData(prop, valueTypeProperty); - store.owner = 1; - } else { - store.property = prop->core; - store.owner = 0; - } - QDeclarativeType *valueType = toQmlType(v->object); - store.castValue = valueType->propertyValueSourceCast(); - output->addInstruction(store); - - } else if (v->type == Value::ValueInterceptor) { - genObject(v->object); - - Instruction::StoreValueInterceptor store; - if (valueTypeProperty) { - store.property = genValueTypeData(prop, valueTypeProperty); - store.owner = 1; - } else { - store.property = prop->core; - store.owner = 0; - } - QDeclarativeType *valueType = toQmlType(v->object); - store.castValue = valueType->propertyValueInterceptorCast(); - output->addInstruction(store); - } - - } -} - -bool QDeclarativeCompiler::buildIdProperty(QDeclarativeScript::Property *prop, - QDeclarativeScript::Object *obj) -{ - if (prop->value || - prop->values.isMany() || - prop->values.first()->object) - COMPILE_EXCEPTION(prop, tr("Invalid use of id property")); - - QDeclarativeScript::Value *idValue = prop->values.first(); - QString val = idValue->primitive(); - - COMPILE_CHECK(checkValidId(idValue, val)); - - if (compileState->ids.value(val)) - COMPILE_EXCEPTION(prop, tr("id is not unique")); - - prop->values.first()->type = Value::Id; - - obj->id = val; - addId(val, obj); - - return true; -} - -void QDeclarativeCompiler::addId(const QString &id, QDeclarativeScript::Object *obj) -{ - Q_UNUSED(id); - Q_ASSERT(!compileState->ids.value(id)); - Q_ASSERT(obj->id == id); - obj->idIndex = compileState->ids.count(); - compileState->ids.append(obj); -} - -void QDeclarativeCompiler::addBindingReference(JSBindingReference *ref) -{ - Q_ASSERT(ref->value && !ref->value->bindingReference); - ref->value->bindingReference = ref; - compileState->totalBindingsCount++; - compileState->bindings.prepend(ref); -} - -void QDeclarativeCompiler::saveComponentState() -{ - Q_ASSERT(compileState->root); - Q_ASSERT(compileState->root->componentCompileState == 0); - - compileState->root->componentCompileState = compileState; - - if (componentStats) - componentStats->savedComponentStats.append(componentStats->componentStat); -} - -QDeclarativeCompilerTypes::ComponentCompileState * -QDeclarativeCompiler::componentState(QDeclarativeScript::Object *obj) -{ - Q_ASSERT(obj->componentCompileState); - return obj->componentCompileState; -} - -// Build attached property object. In this example, -// Text { -// GridView.row: 10 -// } -// GridView is an attached property object. -bool QDeclarativeCompiler::buildAttachedProperty(QDeclarativeScript::Property *prop, - QDeclarativeScript::Object *obj, - const BindingContext &ctxt) -{ - Q_ASSERT(prop->value); - Q_ASSERT(prop->index != -1); // This is set in buildProperty() - - compileState->objectDepth.push(); - - obj->addAttachedProperty(prop); - - COMPILE_CHECK(buildSubObject(prop->value, ctxt.incr())); - - compileState->objectDepth.pop(); - - return true; -} - - -// Build "grouped" properties. In this example: -// Text { -// font.pointSize: 12 -// font.family: "Helvetica" -// } -// font is a nested property. pointSize and family are not. -bool QDeclarativeCompiler::buildGroupedProperty(QDeclarativeScript::Property *prop, - QDeclarativeScript::Object *obj, - const BindingContext &ctxt) -{ - Q_ASSERT(prop->type != 0); - Q_ASSERT(prop->index != -1); - - if (QDeclarativeValueTypeFactory::isValueType(prop->type)) { - if (prop->type >= 0 && enginePrivate->valueTypes[prop->type]) { - - if (!prop->values.isEmpty()) { - if (prop->values.first()->location < prop->value->location) { - COMPILE_EXCEPTION(prop->value, tr( "Property has already been assigned a value")); - } else { - COMPILE_EXCEPTION(prop->values.first(), tr( "Property has already been assigned a value")); - } - } - - if (!prop->core.isWritable() && !prop->isReadOnlyDeclaration) { - COMPILE_EXCEPTION(prop, tr( "Invalid property assignment: \"%1\" is a read-only property").arg(prop->name().toString())); - } - - - if (prop->isAlias) { - for (Property *vtProp = prop->value->properties.first(); vtProp; vtProp = prop->value->properties.next(vtProp)) { - vtProp->isAlias = true; - } - } - - COMPILE_CHECK(buildValueTypeProperty(enginePrivate->valueTypes[prop->type], - prop->value, obj, ctxt.incr())); - obj->addValueTypeProperty(prop); - } else { - COMPILE_EXCEPTION(prop, tr("Invalid grouped property access")); - } - - } else { - // Load the nested property's meta type - prop->value->metatype = enginePrivate->metaObjectForType(prop->type); - if (!prop->value->metatype) - COMPILE_EXCEPTION(prop, tr("Invalid grouped property access")); - - if (!prop->values.isEmpty()) - COMPILE_EXCEPTION(prop->values.first(), tr( "Cannot assign a value directly to a grouped property")); - - obj->addGroupedProperty(prop); - - compileState->objectDepth.push(); - - COMPILE_CHECK(buildSubObject(prop->value, ctxt.incr())); - - compileState->objectDepth.pop(); - } - - return true; -} - -bool QDeclarativeCompiler::buildValueTypeProperty(QObject *type, - QDeclarativeScript::Object *obj, - QDeclarativeScript::Object *baseObj, - const BindingContext &ctxt) -{ - compileState->objectDepth.push(); - - if (obj->defaultProperty) - COMPILE_EXCEPTION(obj, tr("Invalid property use")); - obj->metatype = type->metaObject(); - - for (Property *prop = obj->properties.first(); prop; prop = obj->properties.next(prop)) { - - QDeclarativePropertyData *d = property(obj, prop->name()); - if (d == 0) - COMPILE_EXCEPTION(prop, tr("Cannot assign to non-existent property \"%1\"").arg(prop->name().toString())); - - prop->index = d->coreIndex; - prop->type = d->propType; - prop->core = *d; - prop->isValueTypeSubProperty = true; - - if (prop->value) - COMPILE_EXCEPTION(prop, tr("Property assignment expected")); - - if (prop->values.isMany()) { - COMPILE_EXCEPTION(prop, tr("Single property assignment expected")); - } else if (!prop->values.isEmpty()) { - QDeclarativeScript::Value *value = prop->values.first(); - - if (value->object) { - COMPILE_EXCEPTION(prop, tr("Unexpected object assignment")); - } else if (value->value.isScript()) { - // ### Check for writability - - //optimization for . enum assignments - bool isEnumAssignment = false; - - if (prop->core.isEnum()) - COMPILE_CHECK(testQualifiedEnumAssignment(prop, obj, value, &isEnumAssignment)); - - if (isEnumAssignment) { - value->type = Value::Literal; - } else { - JSBindingReference *reference = pool->New(); - reference->expression = value->value; - reference->property = prop; - reference->value = value; - reference->bindingContext = ctxt; - reference->bindingContext.owner++; - addBindingReference(reference); - value->type = Value::PropertyBinding; - } - } else { - COMPILE_CHECK(testLiteralAssignment(prop, value)); - value->type = Value::Literal; - } - } - - for (Value *v = prop->onValues.first(); v; v = Property::ValueList::next(v)) { - Q_ASSERT(v->object); - - COMPILE_CHECK(buildPropertyOnAssignment(prop, obj, baseObj, v, ctxt)); - } - - obj->addValueProperty(prop); - } - - compileState->objectDepth.pop(); - - return true; -} - -// Build assignments to QML lists. QML lists are properties of type -// QDeclarativeListProperty. List properties can accept a list of -// objects, or a single binding. -bool QDeclarativeCompiler::buildListProperty(QDeclarativeScript::Property *prop, - QDeclarativeScript::Object *obj, - const BindingContext &ctxt) -{ - Q_ASSERT(prop->core.isQList()); - - compileState->listDepth.push(); - - int t = prop->type; - - obj->addValueProperty(prop); - - int listType = enginePrivate->listType(t); - bool listTypeIsInterface = QDeclarativeMetaType::isInterface(listType); - - bool assignedBinding = false; - for (Value *v = prop->values.first(); v; v = Property::ValueList::next(v)) { - if (v->object) { - v->type = Value::CreatedObject; - COMPILE_CHECK(buildObject(v->object, ctxt)); - - // We check object coercian here. We check interface assignment - // at runtime. - if (!listTypeIsInterface) { - if (!canCoerce(listType, v->object)) { - COMPILE_EXCEPTION(v, tr("Cannot assign object to list")); - } - } - - } else if (v->value.isScript()) { - if (assignedBinding) - COMPILE_EXCEPTION(v, tr("Can only assign one binding to lists")); - - assignedBinding = true; - COMPILE_CHECK(buildBinding(v, prop, ctxt)); - v->type = Value::PropertyBinding; - } else { - COMPILE_EXCEPTION(v, tr("Cannot assign primitives to lists")); - } - } - - compileState->listDepth.pop(); - - return true; -} - -// Compiles an assignment to a QDeclarativeScriptString property -bool QDeclarativeCompiler::buildScriptStringProperty(QDeclarativeScript::Property *prop, - QDeclarativeScript::Object *obj, - const BindingContext &ctxt) -{ - if (prop->values.isMany()) - COMPILE_EXCEPTION(prop->values.first()->nextValue, tr( "Cannot assign multiple values to a script property")); - - if (prop->values.first()->object) - COMPILE_EXCEPTION(prop->values.first(), tr( "Invalid property assignment: script expected")); - - prop->scriptStringScope = ctxt.stack; - obj->addScriptStringProperty(prop); - - return true; -} - -// Compile regular property assignments of the form "property: " -bool QDeclarativeCompiler::buildPropertyAssignment(QDeclarativeScript::Property *prop, - QDeclarativeScript::Object *obj, - const BindingContext &ctxt) -{ - obj->addValueProperty(prop); - - if (prop->values.isMany()) - COMPILE_EXCEPTION(prop->values.first(), tr( "Cannot assign multiple values to a singular property") ); - - for (Value *v = prop->values.first(); v; v = Property::ValueList::next(v)) { - if (v->object) { - - COMPILE_CHECK(buildPropertyObjectAssignment(prop, obj, v, ctxt)); - - } else { - - COMPILE_CHECK(buildPropertyLiteralAssignment(prop, obj, v, ctxt)); - - } - } - - for (Value *v = prop->onValues.first(); v; v = Property::ValueList::next(v)) { - Q_ASSERT(v->object); - COMPILE_CHECK(buildPropertyOnAssignment(prop, obj, obj, v, ctxt)); - } - - return true; -} - -// Compile assigning a single object instance to a regular property -bool QDeclarativeCompiler::buildPropertyObjectAssignment(QDeclarativeScript::Property *prop, - QDeclarativeScript::Object *obj, - QDeclarativeScript::Value *v, - const BindingContext &ctxt) -{ - Q_ASSERT(prop->index != -1); - Q_ASSERT(v->object->type != -1); - - if (!prop->core.isWritable() && !prop->isReadOnlyDeclaration) - COMPILE_EXCEPTION(v, tr("Invalid property assignment: \"%1\" is a read-only property").arg(prop->name().toString())); - - if (QDeclarativeMetaType::isInterface(prop->type)) { - - // Assigning an object to an interface ptr property - COMPILE_CHECK(buildObject(v->object, ctxt)); - - v->type = Value::CreatedObject; - - } else if (prop->type == QMetaType::QVariant) { - - // Assigning an object to a QVariant - COMPILE_CHECK(buildObject(v->object, ctxt)); - - v->type = Value::CreatedObject; - } else { - // Normally buildObject() will set this up, but we need the static - // meta object earlier to test for assignability. It doesn't matter - // that there may still be outstanding synthesized meta object changes - // on this type, as they are not relevant for assignability testing - v->object->metatype = output->types.at(v->object->type).metaObject(); - Q_ASSERT(v->object->metaObject()); - - // We want to raw metaObject here as the raw metaobject is the - // actual property type before we applied any extensions that might - // effect the properties on the type, but don't effect assignability - const QMetaObject *propertyMetaObject = enginePrivate->rawMetaObjectForType(prop->type); - - // Will be true if the assgned type inherits propertyMetaObject - bool isAssignable = false; - // Determine isAssignable value - if (propertyMetaObject) { - const QMetaObject *c = v->object->metatype; - while(c) { - isAssignable |= (QDeclarativePropertyPrivate::equal(c, propertyMetaObject)); - c = c->superClass(); - } - } - - if (isAssignable) { - // Simple assignment - COMPILE_CHECK(buildObject(v->object, ctxt)); - - v->type = Value::CreatedObject; - } else if (propertyMetaObject == &QDeclarativeComponent::staticMetaObject) { - // Automatic "Component" insertion - QDeclarativeScript::Object *root = v->object; - QDeclarativeScript::Object *component = pool->New(); - component->type = componentTypeRef(); - component->typeName = QStringLiteral("Qt/Component"); - component->metatype = &QDeclarativeComponent::staticMetaObject; - component->location = root->location; - QDeclarativeScript::Value *componentValue = pool->New(); - componentValue->object = root; - component->getDefaultProperty()->addValue(componentValue); - v->object = component; - COMPILE_CHECK(buildPropertyObjectAssignment(prop, obj, v, ctxt)); - } else { - COMPILE_EXCEPTION(v->object, tr("Cannot assign object to property")); - } - } - - return true; -} - -// Compile assigning a single object instance to a regular property using the "on" syntax. -// -// For example: -// Item { -// NumberAnimation on x { } -// } -bool QDeclarativeCompiler::buildPropertyOnAssignment(QDeclarativeScript::Property *prop, - QDeclarativeScript::Object *obj, - QDeclarativeScript::Object *baseObj, - QDeclarativeScript::Value *v, - const BindingContext &ctxt) -{ - Q_ASSERT(prop->index != -1); - Q_ASSERT(v->object->type != -1); - - Q_UNUSED(obj); - - if (!prop->core.isWritable()) - COMPILE_EXCEPTION(v, tr("Invalid property assignment: \"%1\" is a read-only property").arg(prop->name().toString())); - - - // Normally buildObject() will set this up, but we need the static - // meta object earlier to test for assignability. It doesn't matter - // that there may still be outstanding synthesized meta object changes - // on this type, as they are not relevant for assignability testing - v->object->metatype = output->types.at(v->object->type).metaObject(); - Q_ASSERT(v->object->metaObject()); - - // Will be true if the assigned type inherits QDeclarativePropertyValueSource - bool isPropertyValue = false; - // Will be true if the assigned type inherits QDeclarativePropertyValueInterceptor - bool isPropertyInterceptor = false; - if (QDeclarativeType *valueType = toQmlType(v->object)) { - isPropertyValue = valueType->propertyValueSourceCast() != -1; - isPropertyInterceptor = valueType->propertyValueInterceptorCast() != -1; - } - - if (isPropertyValue || isPropertyInterceptor) { - // Assign as a property value source - COMPILE_CHECK(buildObject(v->object, ctxt)); - - if (isPropertyInterceptor && prop->parent->synthdata.isEmpty()) - buildDynamicMeta(baseObj, ForceCreation); - v->type = isPropertyValue ? Value::ValueSource : Value::ValueInterceptor; - } else { - COMPILE_EXCEPTION(v, tr("\"%1\" cannot operate on \"%2\"").arg(v->object->typeName).arg(prop->name().toString())); - } - - return true; -} - -// Compile assigning a literal or binding to a regular property -bool QDeclarativeCompiler::buildPropertyLiteralAssignment(QDeclarativeScript::Property *prop, - QDeclarativeScript::Object *obj, - QDeclarativeScript::Value *v, - const BindingContext &ctxt) -{ - Q_ASSERT(prop->index != -1); - - if (v->value.isScript()) { - - //optimization for . enum assignments - if (prop->core.isEnum()) { - bool isEnumAssignment = false; - COMPILE_CHECK(testQualifiedEnumAssignment(prop, obj, v, &isEnumAssignment)); - if (isEnumAssignment) { - v->type = Value::Literal; - return true; - } - } - - // Test for other binding optimizations - if (!buildLiteralBinding(v, prop, ctxt)) - COMPILE_CHECK(buildBinding(v, prop, ctxt)); - - v->type = Value::PropertyBinding; - - } else { - - COMPILE_CHECK(testLiteralAssignment(prop, v)); - - v->type = Value::Literal; - } - - return true; -} - -bool QDeclarativeCompiler::testQualifiedEnumAssignment(QDeclarativeScript::Property *prop, - QDeclarativeScript::Object *obj, - QDeclarativeScript::Value *v, - bool *isAssignment) -{ - *isAssignment = false; - if (!prop->core.isEnum()) - return true; - - QMetaProperty mprop = obj->metaObject()->property(prop->index); - - if (!prop->core.isWritable() && !prop->isReadOnlyDeclaration) - COMPILE_EXCEPTION(v, tr("Invalid property assignment: \"%1\" is a read-only property").arg(prop->name().toString())); - - QString string = v->value.asString(); - if (!string.at(0).isUpper()) - return true; - - QStringList parts = string.split(QLatin1Char('.')); - if (parts.count() != 2) - return true; - - QString typeName = parts.at(0); - QDeclarativeType *type = 0; - unit->imports().resolveType(typeName, &type, 0, 0, 0, 0); - - //handle enums on value types (where obj->typeName is empty) - QString objTypeName = obj->typeName; - if (objTypeName.isEmpty()) { - QDeclarativeType *objType = toQmlType(obj); - if (objType) - objTypeName = objType->qmlTypeName(); - } - - if (!type) - return true; - - QString enumValue = parts.at(1); - int value; - bool ok; - - if (objTypeName == type->qmlTypeName()) { - // When these two match, we can short cut the search - if (mprop.isFlagType()) { - value = mprop.enumerator().keysToValue(enumValue.toUtf8().constData(), &ok); - } else { - value = mprop.enumerator().keyToValue(enumValue.toUtf8().constData(), &ok); - } - } else { - // Otherwise we have to search the whole type - // This matches the logic in QV8TypeWrapper - QByteArray enumName = enumValue.toUtf8(); - const QMetaObject *metaObject = type->baseMetaObject(); - ok = false; - for (int ii = metaObject->enumeratorCount() - 1; !ok && ii >= 0; --ii) { - QMetaEnum e = metaObject->enumerator(ii); - value = e.keyToValue(enumName.constData(), &ok); - } - } - - if (!ok) - return true; - - v->type = Value::Literal; - v->value = QDeclarativeScript::Variant((double)value); - *isAssignment = true; - - return true; -} - -struct StaticQtMetaObject : public QObject -{ - static const QMetaObject *get() - { return &static_cast (0)->staticQtMetaObject; } -}; - -// Similar logic to above, but not knowing target property. -int QDeclarativeCompiler::evaluateEnum(const QByteArray& script) const -{ - int dot = script.indexOf('.'); - if (dot > 0) { - const QByteArray &scope = script.left(dot); - QDeclarativeType *type = 0; - unit->imports().resolveType(QString::fromUtf8(script.left(dot)), &type, 0, 0, 0, 0); - if (!type && scope != "Qt") - return -1; - const QMetaObject *mo = type ? type->metaObject() : StaticQtMetaObject::get(); - const char *key = script.constData() + dot+1; - int i = mo->enumeratorCount(); - while (i--) { - bool ok; - int v = mo->enumerator(i).keyToValue(key, &ok); - if (ok) - return v; - } - } - return -1; -} - -const QMetaObject *QDeclarativeCompiler::resolveType(const QString& name) const -{ - QDeclarativeType *qmltype = 0; - if (!unit->imports().resolveType(name, &qmltype, 0, 0, 0, 0)) - return 0; - if (!qmltype) - return 0; - return qmltype->metaObject(); -} - -// similar to logic of completeComponentBuild, but also sticks data -// into primitives at the end -int QDeclarativeCompiler::rewriteBinding(const QDeclarativeScript::Variant& value, const QString& name) -{ - QDeclarativeRewrite::RewriteBinding rewriteBinding; - rewriteBinding.setName(QLatin1Char('$') + name.mid(name.lastIndexOf(QLatin1Char('.')) + 1)); - - QString rewrite = rewriteBinding(value.asAST(), value.asScript(), 0); - - return output->indexForString(rewrite); -} - -QString QDeclarativeCompiler::rewriteSignalHandler(const QDeclarativeScript::Variant& value, const QString &name) -{ - QDeclarativeRewrite::RewriteSignalHandler rewriteSignalHandler; - return rewriteSignalHandler(value.asAST(), value.asScript(), name); -} - -// Ensures that the dynamic meta specification on obj is valid -bool QDeclarativeCompiler::checkDynamicMeta(QDeclarativeScript::Object *obj) -{ - bool seenDefaultProperty = false; - - // We use a coarse grain, 31 bit hash to check if there are duplicates. - // Calculating the hash for the names is not a waste as we have to test - // them against the illegalNames set anyway. - QHashField propNames; - QHashField methodNames; - - // Check properties - for (Object::DynamicProperty *p = obj->dynamicProperties.first(); p; p = obj->dynamicProperties.next(p)) { - const QDeclarativeScript::Object::DynamicProperty &prop = *p; - - if (prop.isDefaultProperty) { - if (seenDefaultProperty) - COMPILE_EXCEPTION(&prop, tr("Duplicate default property")); - seenDefaultProperty = true; - } - - if (propNames.testAndSet(prop.name.hash())) { - for (Object::DynamicProperty *p2 = obj->dynamicProperties.first(); p2 != p; - p2 = obj->dynamicProperties.next(p2)) { - if (p2->name == prop.name) { - COMPILE_EXCEPTION_LOCATION(prop.nameLocation.line, - prop.nameLocation.column, - tr("Duplicate property name")); - } - } - } - - if (prop.name.at(0).isUpper()) { - COMPILE_EXCEPTION_LOCATION(prop.nameLocation.line, - prop.nameLocation.column, - tr("Property names cannot begin with an upper case letter")); - } - - if (enginePrivate->v8engine()->illegalNames().contains(prop.name)) { - COMPILE_EXCEPTION_LOCATION(prop.nameLocation.line, - prop.nameLocation.column, - tr("Illegal property name")); - } - } - - for (Object::DynamicSignal *s = obj->dynamicSignals.first(); s; s = obj->dynamicSignals.next(s)) { - const QDeclarativeScript::Object::DynamicSignal &currSig = *s; - - if (methodNames.testAndSet(currSig.name.hash())) { - for (Object::DynamicSignal *s2 = obj->dynamicSignals.first(); s2 != s; - s2 = obj->dynamicSignals.next(s2)) { - if (s2->name == currSig.name) - COMPILE_EXCEPTION(&currSig, tr("Duplicate signal name")); - } - } - - if (currSig.name.at(0).isUpper()) - COMPILE_EXCEPTION(&currSig, tr("Signal names cannot begin with an upper case letter")); - if (enginePrivate->v8engine()->illegalNames().contains(currSig.name)) - COMPILE_EXCEPTION(&currSig, tr("Illegal signal name")); - } - - for (Object::DynamicSlot *s = obj->dynamicSlots.first(); s; s = obj->dynamicSlots.next(s)) { - const QDeclarativeScript::Object::DynamicSlot &currSlot = *s; - - if (methodNames.testAndSet(currSlot.name.hash())) { - for (Object::DynamicSignal *s2 = obj->dynamicSignals.first(); s2; - s2 = obj->dynamicSignals.next(s2)) { - if (s2->name == currSlot.name) - COMPILE_EXCEPTION(&currSlot, tr("Duplicate method name")); - } - for (Object::DynamicSlot *s2 = obj->dynamicSlots.first(); s2 != s; - s2 = obj->dynamicSlots.next(s2)) { - if (s2->name == currSlot.name) - COMPILE_EXCEPTION(&currSlot, tr("Duplicate method name")); - } - } - - if (currSlot.name.at(0).isUpper()) - COMPILE_EXCEPTION(&currSlot, tr("Method names cannot begin with an upper case letter")); - if (enginePrivate->v8engine()->illegalNames().contains(currSlot.name)) - COMPILE_EXCEPTION(&currSlot, tr("Illegal method name")); - } - - return true; -} - -bool QDeclarativeCompiler::mergeDynamicMetaProperties(QDeclarativeScript::Object *obj) -{ - for (Object::DynamicProperty *p = obj->dynamicProperties.first(); p; - p = obj->dynamicProperties.next(p)) { - - if (!p->defaultValue || p->type == Object::DynamicProperty::Alias) - continue; - - Property *property = 0; - if (p->isDefaultProperty) { - property = obj->getDefaultProperty(); - } else { - property = obj->getProperty(p->name); - if (!property->values.isEmpty()) - COMPILE_EXCEPTION(property, tr("Property value set multiple times")); - } - - if (p->isReadOnly) - property->isReadOnlyDeclaration = true; - - if (property->value) - COMPILE_EXCEPTION(property, tr("Invalid property nesting")); - - property->values.append(p->defaultValue->values); - } - return true; -} - -Q_GLOBAL_STATIC(QAtomicInt, classIndexCounter) - -bool QDeclarativeCompiler::buildDynamicMeta(QDeclarativeScript::Object *obj, DynamicMetaMode mode) -{ - Q_ASSERT(obj); - Q_ASSERT(obj->metatype); - - if (mode != ForceCreation && - obj->dynamicProperties.isEmpty() && - obj->dynamicSignals.isEmpty() && - obj->dynamicSlots.isEmpty()) - return true; - - bool resolveAlias = (mode == ResolveAliases); - - const Object::DynamicProperty *defaultProperty = 0; - int aliasCount = 0; - int varPropCount = 0; - int totalPropCount = 0; - int firstPropertyVarIndex = 0; - - for (Object::DynamicProperty *p = obj->dynamicProperties.first(); p; p = obj->dynamicProperties.next(p)) { - - if (p->type == Object::DynamicProperty::Alias) - aliasCount++; - if (p->type == Object::DynamicProperty::Var) - varPropCount++; - - if (p->isDefaultProperty && - (resolveAlias || p->type != Object::DynamicProperty::Alias)) - defaultProperty = p; - - if (!resolveAlias) { - // No point doing this for both the alias and non alias cases - QDeclarativePropertyData *d = property(obj, p->name); - if (d && d->isFinal()) - COMPILE_EXCEPTION(p, tr("Cannot override FINAL property")); - } - } - - bool buildData = resolveAlias || aliasCount == 0; - - QByteArray dynamicData; - if (buildData) { - typedef QDeclarativeVMEMetaData VMD; - - dynamicData = QByteArray(sizeof(QDeclarativeVMEMetaData) + - (obj->dynamicProperties.count() - aliasCount) * sizeof(VMD::PropertyData) + - obj->dynamicSlots.count() * sizeof(VMD::MethodData) + - aliasCount * sizeof(VMD::AliasData), 0); - } - - int uniqueClassId = classIndexCounter()->fetchAndAddRelaxed(1); - - QByteArray newClassName = obj->metatype->className(); - newClassName.append("_QML_"); - newClassName.append(QByteArray::number(uniqueClassId)); - - if (compileState->root == obj && !compileState->nested) { - QString path = output->url.path(); - int lastSlash = path.lastIndexOf(QLatin1Char('/')); - if (lastSlash > -1) { - QString nameBase = path.mid(lastSlash + 1, path.length()-lastSlash-5); - if (!nameBase.isEmpty() && nameBase.at(0).isUpper()) - newClassName = nameBase.toUtf8() + "_QMLTYPE_" + QByteArray::number(uniqueClassId); - } - } - - QFastMetaBuilder builder; - QFastMetaBuilder::StringRef classNameRef = builder.init(newClassName.length(), - obj->dynamicProperties.count() - (resolveAlias?0:aliasCount), - obj->dynamicSlots.count(), - obj->dynamicSignals.count() + obj->dynamicProperties.count(), - defaultProperty?1:0); - - struct TypeData { - Object::DynamicProperty::Type dtype; - int metaType; - const char *cppType; - } builtinTypes[] = { - { Object::DynamicProperty::Var, QMetaType::QVariant, "QVariant" }, - { Object::DynamicProperty::Variant, QMetaType::QVariant, "QVariant" }, - { Object::DynamicProperty::Int, QMetaType::Int, "int" }, - { Object::DynamicProperty::Bool, QMetaType::Bool, "bool" }, - { Object::DynamicProperty::Real, QMetaType::Double, "double" }, - { Object::DynamicProperty::String, QMetaType::QString, "QString" }, - { Object::DynamicProperty::Url, QMetaType::QUrl, "QUrl" }, - { Object::DynamicProperty::Color, QMetaType::QColor, "QColor" }, - { Object::DynamicProperty::Time, QMetaType::QTime, "QTime" }, - { Object::DynamicProperty::Date, QMetaType::QDate, "QDate" }, - { Object::DynamicProperty::DateTime, QMetaType::QDateTime, "QDateTime" }, - }; - static const int builtinTypeCount = sizeof(builtinTypes) / sizeof(TypeData); - QFastMetaBuilder::StringRef typeRefs[builtinTypeCount]; - - // Reserve dynamic properties - if (obj->dynamicProperties.count()) { - typedef QDeclarativeVMEMetaData VMD; - - int effectivePropertyIndex = 0; - for (Object::DynamicProperty *p = obj->dynamicProperties.first(); p; p = obj->dynamicProperties.next(p)) { - - // Reserve space for name - p->nameRef = builder.newString(p->name.utf8length()); - - int propertyType = 0; - bool readonly = false; - QFastMetaBuilder::StringRef typeRef; - - if (p->type == Object::DynamicProperty::Alias) { - continue; - } else if (p->type < builtinTypeCount) { - Q_ASSERT(builtinTypes[p->type].dtype == p->type); - propertyType = builtinTypes[p->type].metaType; - if (typeRefs[p->type].isEmpty()) - typeRefs[p->type] = builder.newString(strlen(builtinTypes[p->type].cppType)); - typeRef = typeRefs[p->type]; - - } else { - Q_ASSERT(p->type == Object::DynamicProperty::CustomList || - p->type == Object::DynamicProperty::Custom); - - // XXX don't double resolve this in the case of an alias run - - QByteArray customTypeName; - QDeclarativeType *qmltype = 0; - QString url; - if (!unit->imports().resolveType(p->customType.toString(), &qmltype, &url, 0, 0, 0)) - COMPILE_EXCEPTION(p, tr("Invalid property type")); - - if (!qmltype) { - QDeclarativeTypeData *tdata = enginePrivate->typeLoader.get(QUrl(url)); - Q_ASSERT(tdata); - Q_ASSERT(tdata->isComplete()); - - QDeclarativeCompiledData *data = tdata->compiledData(); - customTypeName = data->root->className(); - data->release(); - tdata->release(); - } else { - customTypeName = qmltype->typeName(); - } - - if (p->type == Object::DynamicProperty::Custom) { - customTypeName += '*'; - propertyType = QMetaType::QObjectStar; - } else { - readonly = true; - customTypeName = QByteArray("QDeclarativeListProperty<") + customTypeName + QByteArray(">"); - propertyType = qMetaTypeId >(); - } - - p->resolvedCustomTypeName = pool->NewByteArray(customTypeName); - p->typeRef = builder.newString(customTypeName.length()); - typeRef = p->typeRef; - } - - if (p->type == Object::DynamicProperty::Var) - continue; - - if (p->isReadOnly) - readonly = true; - - if (buildData) { - VMD *vmd = (QDeclarativeVMEMetaData *)dynamicData.data(); - vmd->propertyCount++; - (vmd->propertyData() + effectivePropertyIndex)->propertyType = propertyType; - } - - if (p->type < builtinTypeCount) - builder.setProperty(effectivePropertyIndex, p->nameRef, typeRef, (QMetaType::Type)propertyType, - readonly?QFastMetaBuilder::None:QFastMetaBuilder::Writable, - effectivePropertyIndex); - else - builder.setProperty(effectivePropertyIndex, p->nameRef, typeRef, - readonly?QFastMetaBuilder::None:QFastMetaBuilder::Writable, - effectivePropertyIndex); - - p->changedSignatureRef = builder.newString(p->name.utf8length() + strlen("Changed()")); - builder.setSignal(effectivePropertyIndex, p->changedSignatureRef); - - effectivePropertyIndex++; - } - - if (varPropCount) { - VMD *vmd = (QDeclarativeVMEMetaData *)dynamicData.data(); - if (buildData) - vmd->varPropertyCount = varPropCount; - firstPropertyVarIndex = effectivePropertyIndex; - totalPropCount = varPropCount + effectivePropertyIndex; - for (Object::DynamicProperty *p = obj->dynamicProperties.first(); p; p = obj->dynamicProperties.next(p)) { - if (p->type == Object::DynamicProperty::Var) { - QFastMetaBuilder::StringRef typeRef = typeRefs[p->type]; - if (buildData) { - vmd->propertyCount++; - (vmd->propertyData() + effectivePropertyIndex)->propertyType = QMetaType::QVariant; - } - - builder.setProperty(effectivePropertyIndex, p->nameRef, typeRef, - QMetaType::QVariant, - p->isReadOnly?QFastMetaBuilder::None:QFastMetaBuilder::Writable, - effectivePropertyIndex); - - p->changedSignatureRef = builder.newString(p->name.utf8length() + strlen("Changed()")); - builder.setSignal(effectivePropertyIndex, p->changedSignatureRef); - - effectivePropertyIndex++; - } - } - } - - if (aliasCount) { - int aliasIndex = 0; - for (Object::DynamicProperty *p = obj->dynamicProperties.first(); p; p = obj->dynamicProperties.next(p)) { - if (p->type == Object::DynamicProperty::Alias) { - if (resolveAlias) { - Q_ASSERT(buildData); - ((QDeclarativeVMEMetaData *)dynamicData.data())->aliasCount++; - COMPILE_CHECK(compileAlias(builder, dynamicData, obj, effectivePropertyIndex, - aliasIndex, *p)); - } - // Even if we aren't resolving the alias, we need a fake signal so that the - // metaobject remains consistent across the resolve and non-resolve alias runs - p->changedSignatureRef = builder.newString(p->name.utf8length() + strlen("Changed()")); - builder.setSignal(effectivePropertyIndex, p->changedSignatureRef); - effectivePropertyIndex++; - aliasIndex++; - } - } - } - } - - // Reserve default property - QFastMetaBuilder::StringRef defPropRef; - if (defaultProperty) { - defPropRef = builder.newString(strlen("DefaultProperty")); - builder.setClassInfo(0, defPropRef, defaultProperty->nameRef); - } - - // Reserve dynamic signals - int signalIndex = 0; - for (Object::DynamicSignal *s = obj->dynamicSignals.first(); s; s = obj->dynamicSignals.next(s)) { - - int paramCount = s->parameterNames.count(); - - int signatureSize = s->name.utf8length() + 2 /* paren */; - int namesSize = 0; - if (paramCount) signatureSize += s->parameterTypesLength() + (paramCount - 1) /* commas */; - if (paramCount) namesSize += s->parameterNamesLength() + (paramCount - 1) /* commas */; - - s->signatureRef = builder.newString(signatureSize); - if (namesSize) s->parameterNamesRef = builder.newString(namesSize); - - if (buildData) - ((QDeclarativeVMEMetaData *)dynamicData.data())->signalCount++; - - builder.setSignal(signalIndex + obj->dynamicProperties.count(), s->signatureRef, s->parameterNamesRef); - ++signalIndex; - } - - // Reserve dynamic slots - if (obj->dynamicSlots.count()) { - - // Allocate QVariant string - if (typeRefs[0].isEmpty()) - typeRefs[0] = builder.newString(strlen(builtinTypes[0].cppType)); - - typedef QDeclarativeVMEMetaData VMD; - - int methodIndex = 0; - for (Object::DynamicSlot *s = obj->dynamicSlots.first(); s; s = obj->dynamicSlots.next(s)) { - int paramCount = s->parameterNames.count(); - - int signatureSize = s->name.utf8length() + 2 /* paren */; - int namesSize = 0; - if (paramCount) signatureSize += (paramCount * strlen("QVariant") + (paramCount - 1)); - if (paramCount) namesSize += s->parameterNamesLength() + (paramCount - 1 /* commas */); - - s->signatureRef = builder.newString(signatureSize); - if (namesSize) s->parameterNamesRef = builder.newString(namesSize); - - builder.setMethod(methodIndex, s->signatureRef, s->parameterNamesRef, typeRefs[0]); - - if (buildData) { - QString funcScript; - funcScript.reserve(strlen("(function ") + s->name.length() + 1 /* lparen */ + - namesSize + 1 /* rparen */ + s->body.length() + 1 /* rparen */); - funcScript = QLatin1String("(function ") + s->name.toString() + QLatin1Char('('); - for (int jj = 0; jj < paramCount; ++jj) { - if (jj) funcScript.append(QLatin1Char(',')); - funcScript.append(QLatin1String(s->parameterNames.at(jj))); - } - funcScript += QLatin1Char(')') + s->body + QLatin1Char(')'); - - QByteArray utf8 = funcScript.toUtf8(); - VMD::MethodData methodData = { s->parameterNames.count(), 0, - utf8.length(), - s->location.start.line }; - - VMD *vmd = (QDeclarativeVMEMetaData *)dynamicData.data(); - vmd->methodCount++; - - VMD::MethodData &md = *(vmd->methodData() + methodIndex); - md = methodData; - md.bodyOffset = dynamicData.size(); - - dynamicData.append((const char *)utf8.constData(), utf8.length()); - } - - - methodIndex++; - } - } - - // Now allocate used builtin types - for (int ii = 0; ii < builtinTypeCount; ++ii) { - if (!typeRefs[ii].isEmpty()) - typeRefs[ii].load(builtinTypes[ii].cppType); - } - - // Now allocate properties - for (Object::DynamicProperty *p = obj->dynamicProperties.first(); p; p = obj->dynamicProperties.next(p)) { - - char *d = p->changedSignatureRef.data(); - p->name.writeUtf8(d); - strcpy(d + p->name.utf8length(), "Changed()"); - - if (p->type == Object::DynamicProperty::Alias && !resolveAlias) - continue; - - p->nameRef.load(p->name); - - if (p->type >= builtinTypeCount) { - Q_ASSERT(p->resolvedCustomTypeName); - p->typeRef.load(*p->resolvedCustomTypeName); - } - } - - // Allocate default property if necessary - if (defaultProperty) - strcpy(defPropRef.data(), "DefaultProperty"); - - // Now allocate signals - for (Object::DynamicSignal *s = obj->dynamicSignals.first(); s; s = obj->dynamicSignals.next(s)) { - - char *d = s->signatureRef.data(); - char *d2 = s->parameterNamesRef.isEmpty()?0:s->parameterNamesRef.data(); - s->name.writeUtf8(d); d += s->name.utf8length(); - *d++ = '('; - - for (int jj = 0; jj < s->parameterNames.count(); ++jj) { - if (jj != 0) { *d++ = ','; *d2++ = ','; } - strcpy(d, s->parameterTypes.at(jj).constData()); - d += s->parameterTypes.at(jj).length(); - s->parameterNames.at(jj).writeUtf8(d2); - d2 += s->parameterNames.at(jj).utf8length(); - } - *d++ = ')'; - *d = 0; - if (d2) *d2 = 0; - } - - // Now allocate methods - for (Object::DynamicSlot *s = obj->dynamicSlots.first(); s; s = obj->dynamicSlots.next(s)) { - char *d = s->signatureRef.data(); - char *d2 = s->parameterNamesRef.isEmpty()?0:s->parameterNamesRef.data(); - s->name.writeUtf8(d); d += s->name.utf8length(); - *d++ = '('; - for (int jj = 0; jj < s->parameterNames.count(); ++jj) { - if (jj != 0) { *d++ = ','; *d2++ = ','; } - strcpy(d, "QVariant"); - d += strlen("QVariant"); - strcpy(d2, s->parameterNames.at(jj).constData()); - d2 += s->parameterNames.at(jj).length(); - } - *d++ = ')'; - *d = 0; - if (d2) *d2 = 0; - } - - // Now allocate class name - classNameRef.load(newClassName); - - obj->metadata = builder.toData(); - builder.fromData(&obj->extObject, obj->metatype, obj->metadata); - - if (mode == IgnoreAliases && aliasCount) - compileState->aliasingObjects.append(obj); - - obj->synthdata = dynamicData; - - if (obj->synthCache) { - obj->synthCache->release(); - obj->synthCache = 0; - } - - if (obj->type != -1) { - QDeclarativePropertyCache *superCache = output->types[obj->type].createPropertyCache(engine); - QDeclarativePropertyCache *cache = - superCache->copyAndAppend(engine, &obj->extObject, - QDeclarativePropertyData::NoFlags, - QDeclarativePropertyData::IsVMEFunction, - QDeclarativePropertyData::IsVMESignal); - - // now we modify the flags appropriately for var properties. - int propertyOffset = obj->extObject.propertyOffset(); - QDeclarativePropertyData *currPropData = 0; - for (int pvi = firstPropertyVarIndex; pvi < totalPropCount; ++pvi) { - currPropData = cache->property(pvi + propertyOffset); - currPropData->setFlags(currPropData->getFlags() | QDeclarativePropertyData::IsVMEProperty); - } - - obj->synthCache = cache; - } - - return true; -} - -bool QDeclarativeCompiler::checkValidId(QDeclarativeScript::Value *v, const QString &val) -{ - if (val.isEmpty()) - COMPILE_EXCEPTION(v, tr( "Invalid empty ID")); - - QChar ch = val.at(0); - if (ch.isLetter() && !ch.isLower()) - COMPILE_EXCEPTION(v, tr( "IDs cannot start with an uppercase letter")); - - QChar u(QLatin1Char('_')); - if (!ch.isLetter() && ch != u) - COMPILE_EXCEPTION(v, tr( "IDs must start with a letter or underscore")); - - for (int ii = 1; ii < val.count(); ++ii) { - ch = val.at(ii); - if (!ch.isLetterOrNumber() && ch != u) - COMPILE_EXCEPTION(v, tr( "IDs must contain only letters, numbers, and underscores")); - } - - if (enginePrivate->v8engine()->illegalNames().contains(val)) - COMPILE_EXCEPTION(v, tr( "ID illegally masks global JavaScript property")); - - return true; -} - -#include - -static QStringList astNodeToStringList(QDeclarativeJS::AST::Node *node) -{ - if (node->kind == QDeclarativeJS::AST::Node::Kind_IdentifierExpression) { - QString name = - static_cast(node)->name.toString(); - return QStringList() << name; - } else if (node->kind == QDeclarativeJS::AST::Node::Kind_FieldMemberExpression) { - QDeclarativeJS::AST::FieldMemberExpression *expr = static_cast(node); - - QStringList rv = astNodeToStringList(expr->base); - if (rv.isEmpty()) - return rv; - rv.append(expr->name.toString()); - return rv; - } - return QStringList(); -} - -bool QDeclarativeCompiler::compileAlias(QFastMetaBuilder &builder, - QByteArray &data, - QDeclarativeScript::Object *obj, - int propIndex, int aliasIndex, - Object::DynamicProperty &prop) -{ - if (!prop.defaultValue) - COMPILE_EXCEPTION(obj, tr("No property alias location")); - - if (!prop.defaultValue->values.isOne() || - prop.defaultValue->values.first()->object || - !prop.defaultValue->values.first()->value.isScript()) - COMPILE_EXCEPTION(prop.defaultValue, tr("Invalid alias location")); - - QDeclarativeJS::AST::Node *node = prop.defaultValue->values.first()->value.asAST(); - if (!node) - COMPILE_EXCEPTION(obj, tr("No property alias location")); // ### Can this happen? - - QStringList alias = astNodeToStringList(node); - - if (alias.count() < 1 || alias.count() > 3) - COMPILE_EXCEPTION(prop.defaultValue, tr("Invalid alias reference. An alias reference must be specified as , . or ..")); - - QDeclarativeScript::Object *idObject = compileState->ids.value(alias.at(0)); - if (!idObject) - COMPILE_EXCEPTION(prop.defaultValue, tr("Invalid alias reference. Unable to find id \"%1\"").arg(alias.at(0))); - - QByteArray typeName; - - int propIdx = -1; - int flags = 0; - int type = 0; - bool writable = false; - bool resettable = false; - if (alias.count() == 2 || alias.count() == 3) { - propIdx = indexOfProperty(idObject, alias.at(1)); - - if (-1 == propIdx) { - COMPILE_EXCEPTION(prop.defaultValue, tr("Invalid alias location")); - } else if (propIdx > 0xFFFF) { - COMPILE_EXCEPTION(prop.defaultValue, tr("Alias property exceeds alias bounds")); - } - - QMetaProperty aliasProperty = idObject->metaObject()->property(propIdx); - if (!aliasProperty.isScriptable()) - COMPILE_EXCEPTION(prop.defaultValue, tr("Invalid alias location")); - - writable = aliasProperty.isWritable() && !prop.isReadOnly; - resettable = aliasProperty.isResettable() && !prop.isReadOnly; - - if (aliasProperty.type() < QVariant::UserType - || uint(aliasProperty.type()) == QMetaType::QVariant) - type = aliasProperty.type(); - - if (alias.count() == 3) { - QDeclarativeValueType *valueType = enginePrivate->valueTypes[aliasProperty.type()]; - if (!valueType) - COMPILE_EXCEPTION(prop.defaultValue, tr("Invalid alias location")); - - propIdx |= ((unsigned int)aliasProperty.type()) << 24; - - int valueTypeIndex = valueType->metaObject()->indexOfProperty(alias.at(2).toUtf8().constData()); - if (valueTypeIndex == -1) - COMPILE_EXCEPTION(prop.defaultValue, tr("Invalid alias location")); - Q_ASSERT(valueTypeIndex <= 0xFF); - - aliasProperty = valueType->metaObject()->property(valueTypeIndex); - propIdx |= (valueTypeIndex << 16); - - // update the property type - type = aliasProperty.type(); - if (type >= (int)QVariant::UserType) - type = 0; - } - - if (aliasProperty.isEnumType()) - typeName = "int"; // Avoid introducing a dependency on the aliased metaobject - else - typeName = aliasProperty.typeName(); - } else { - Q_ASSERT(idObject->type != -1); // How else did it get an id? - - const QDeclarativeCompiledData::TypeReference &ref = output->types.at(idObject->type); - if (ref.type) - typeName = ref.type->typeName(); - else - typeName = ref.component->root->className(); - - typeName += '*'; - } - - if (typeName.endsWith('*')) - flags |= QML_ALIAS_FLAG_PTR; - - QDeclarativeVMEMetaData::AliasData aliasData = { idObject->idIndex, propIdx, flags }; - - typedef QDeclarativeVMEMetaData VMD; - VMD *vmd = (QDeclarativeVMEMetaData *)data.data(); - *(vmd->aliasData() + aliasIndex) = aliasData; - - prop.nameRef = builder.newString(prop.name.utf8length()); - prop.resolvedCustomTypeName = pool->NewByteArray(typeName); - prop.typeRef = builder.newString(typeName.length()); - - int propertyFlags = 0; - if (writable) - propertyFlags |= QFastMetaBuilder::Writable; - if (resettable) - propertyFlags |= QFastMetaBuilder::Resettable; - - builder.setProperty(propIndex, prop.nameRef, prop.typeRef, (QMetaType::Type)type, - (QFastMetaBuilder::PropertyFlag)propertyFlags, - propIndex); - - return true; -} - -bool QDeclarativeCompiler::buildBinding(QDeclarativeScript::Value *value, - QDeclarativeScript::Property *prop, - const BindingContext &ctxt) -{ - Q_ASSERT(prop->index != -1); - Q_ASSERT(prop->parent); - Q_ASSERT(prop->parent->metaObject()); - - if (!prop->core.isWritable() && !prop->core.isQList() && !prop->isReadOnlyDeclaration) - COMPILE_EXCEPTION(prop, tr("Invalid property assignment: \"%1\" is a read-only property").arg(prop->name().toString())); - - JSBindingReference *reference = pool->New(); - reference->expression = value->value; - reference->property = prop; - reference->value = value; - reference->bindingContext = ctxt; - addBindingReference(reference); - - return true; -} - -bool QDeclarativeCompiler::buildLiteralBinding(QDeclarativeScript::Value *v, - QDeclarativeScript::Property *prop, - const QDeclarativeCompilerTypes::BindingContext &) -{ - Q_ASSERT(v->value.isScript()); - - if (!prop->core.isWritable()) - return false; - - AST::Node *binding = v->value.asAST(); - - if (prop->type == QVariant::String) { - if (AST::CallExpression *e = AST::cast(binding)) { - if (AST::IdentifierExpression *i = AST::cast(e->base)) { - if (i->name == qsTrId_string) { - AST::ArgumentList *arg1 = e->arguments?e->arguments:0; - AST::ArgumentList *arg2 = arg1?arg1->next:0; - - if (arg1 && arg1->expression->kind == AST::Node::Kind_StringLiteral && - (!arg2 || arg2->expression->kind == AST::Node::Kind_NumericLiteral) && - (!arg2 || !arg2->next)) { - - QStringRef text; - int n = -1; - - text = AST::cast(arg1->expression)->value; - if (arg2) n = (int)AST::cast(arg2->expression)->value; - - TrBindingReference *reference = pool->New(); - reference->dataType = BindingReference::TrId; - reference->text = text; - reference->n = n; - v->bindingReference = reference; - return true; - } - - } else if (i->name == qsTr_string) { - - AST::ArgumentList *arg1 = e->arguments?e->arguments:0; - AST::ArgumentList *arg2 = arg1?arg1->next:0; - AST::ArgumentList *arg3 = arg2?arg2->next:0; - - if (arg1 && arg1->expression->kind == AST::Node::Kind_StringLiteral && - (!arg2 || arg2->expression->kind == AST::Node::Kind_StringLiteral) && - (!arg3 || arg3->expression->kind == AST::Node::Kind_NumericLiteral) && - (!arg3 || !arg3->next)) { - - QStringRef text; - QStringRef comment; - int n = -1; - - text = AST::cast(arg1->expression)->value; - if (arg2) comment = AST::cast(arg2->expression)->value; - if (arg3) n = (int)AST::cast(arg3->expression)->value; - - TrBindingReference *reference = pool->New(); - reference->dataType = BindingReference::Tr; - reference->text = text; - reference->comment = comment; - reference->n = n; - v->bindingReference = reference; - return true; - } - - } - } - } - - } - - return false; -} - -void QDeclarativeCompiler::genBindingAssignment(QDeclarativeScript::Value *binding, - QDeclarativeScript::Property *prop, - QDeclarativeScript::Object *obj, - QDeclarativeScript::Property *valueTypeProperty) -{ - Q_UNUSED(obj); - Q_ASSERT(binding->bindingReference); - - const BindingReference &ref = *binding->bindingReference; - if (ref.dataType == BindingReference::TrId) { - const TrBindingReference &tr = static_cast(ref); - - Instruction::StoreTrIdString store; - store.propertyIndex = prop->core.coreIndex; - store.text = output->indexForByteArray(tr.text.toUtf8()); - store.n = tr.n; - output->addInstruction(store); - } else if (ref.dataType == BindingReference::Tr) { - const TrBindingReference &tr = static_cast(ref); - - Instruction::StoreTrString store; - store.propertyIndex = prop->core.coreIndex; - store.context = translationContextIndex(); - store.text = output->indexForByteArray(tr.text.toUtf8()); - store.comment = output->indexForByteArray(tr.comment.toUtf8()); - store.n = tr.n; - output->addInstruction(store); - } else if (ref.dataType == BindingReference::V4) { - const JSBindingReference &js = static_cast(ref); - - Instruction::StoreV4Binding store; - store.value = js.compiledIndex; - store.context = js.bindingContext.stack; - store.owner = js.bindingContext.owner; - if (valueTypeProperty) { - store.property = (valueTypeProperty->index & 0xFFFF) | - ((valueTypeProperty->type & 0xFF)) << 16 | - ((prop->index & 0xFF) << 24); - store.isRoot = (compileState->root == valueTypeProperty->parent); - } else { - store.property = prop->index; - store.isRoot = (compileState->root == obj); - } - store.line = binding->location.start.line; - store.column = binding->location.start.column; - output->addInstruction(store); - } else if (ref.dataType == BindingReference::V8) { - const JSBindingReference &js = static_cast(ref); - - Instruction::StoreV8Binding store; - store.value = js.compiledIndex; - store.context = js.bindingContext.stack; - store.owner = js.bindingContext.owner; - if (valueTypeProperty) { - store.isRoot = (compileState->root == valueTypeProperty->parent); - } else { - store.isRoot = (compileState->root == obj); - } - store.line = binding->location.start.line; - store.column = binding->location.start.column; - - Q_ASSERT(js.bindingContext.owner == 0 || - (js.bindingContext.owner != 0 && valueTypeProperty)); - if (js.bindingContext.owner) { - store.property = genValueTypeData(prop, valueTypeProperty); - } else { - store.property = prop->core; - } - - output->addInstruction(store); - } else if (ref.dataType == BindingReference::QtScript) { - const JSBindingReference &js = static_cast(ref); - - QDeclarativeInstruction store; - store.assignBinding.value = output->indexForString(js.rewrittenExpression); - store.assignBinding.context = js.bindingContext.stack; - store.assignBinding.owner = js.bindingContext.owner; - store.assignBinding.line = binding->location.start.line; - store.assignBinding.column = binding->location.start.column; - - if (valueTypeProperty) { - store.assignBinding.isRoot = (compileState->root == valueTypeProperty->parent); - } else { - store.assignBinding.isRoot = (compileState->root == obj); - } - - Q_ASSERT(js.bindingContext.owner == 0 || - (js.bindingContext.owner != 0 && valueTypeProperty)); - if (js.bindingContext.owner) { - store.assignBinding.property = genValueTypeData(prop, valueTypeProperty); - } else { - store.assignBinding.property = prop->core; - } - output->addInstructionHelper( - !prop->isAlias ? QDeclarativeInstruction::StoreBinding - : QDeclarativeInstruction::StoreBindingOnAlias - , store); - } else { - Q_ASSERT(!"Unhandled BindingReference::DataType type"); - } -} - -int QDeclarativeCompiler::genContextCache() -{ - if (compileState->ids.count() == 0) - return -1; - - QDeclarativeIntegerCache *cache = new QDeclarativeIntegerCache(); - cache->reserve(compileState->ids.count()); - for (Object *o = compileState->ids.first(); o; o = compileState->ids.next(o)) - cache->add(o->id, o->idIndex); - - output->contextCaches.append(cache); - return output->contextCaches.count() - 1; -} - -QDeclarativePropertyData -QDeclarativeCompiler::genValueTypeData(QDeclarativeScript::Property *valueTypeProp, - QDeclarativeScript::Property *prop) -{ - typedef QDeclarativePropertyPrivate QDPP; - return QDPP::saveValueType(prop->parent->metaObject(), prop->index, - enginePrivate->valueTypes[prop->type]->metaObject(), - valueTypeProp->index, engine); -} - -bool QDeclarativeCompiler::completeComponentBuild() -{ - if (componentStats) - componentStats->componentStat.ids = compileState->ids.count(); - - for (Object *aliasObject = compileState->aliasingObjects.first(); aliasObject; - aliasObject = compileState->aliasingObjects.next(aliasObject)) - COMPILE_CHECK(buildDynamicMeta(aliasObject, ResolveAliases)); - - QV4Compiler::Expression expr(unit->imports()); - expr.component = compileState->root; - expr.ids = &compileState->ids; - expr.importCache = output->importCache; - - QV4Compiler bindingCompiler; - - QList sharedBindings; - - for (JSBindingReference *b = compileState->bindings.first(); b; b = b->nextReference) { - - JSBindingReference &binding = *b; - - // ### We don't currently optimize for bindings on alias's - because - // of the solution to QTBUG-13719 - if (!binding.property->isAlias) { - expr.context = binding.bindingContext.object; - expr.property = binding.property; - expr.expression = binding.expression; - - int index = bindingCompiler.compile(expr, enginePrivate); - if (index != -1) { - binding.dataType = BindingReference::V4; - binding.compiledIndex = index; - if (componentStats) - componentStats->componentStat.optimizedBindings.append(b->value->location); - continue; - } - } - - // Pre-rewrite the expression - QString expression = binding.expression.asScript(); - - QDeclarativeRewrite::RewriteBinding rewriteBinding; - rewriteBinding.setName(QLatin1Char('$')+binding.property->name().toString()); - bool isSharable = false; - binding.rewrittenExpression = rewriteBinding(binding.expression.asAST(), expression, &isSharable); - - if (isSharable && !binding.property->isValueTypeSubProperty && !binding.property->isAlias /* See above re alias */ && - binding.property->type != qMetaTypeId()) { - binding.dataType = BindingReference::V8; - sharedBindings.append(b); - } else { - binding.dataType = BindingReference::QtScript; - } - - if (componentStats) - componentStats->componentStat.scriptBindings.append(b->value->location); - } - - if (!sharedBindings.isEmpty()) { - struct Sort { - static bool lt(const JSBindingReference *lhs, const JSBindingReference *rhs) - { - return lhs->value->location.start.line < rhs->value->location.start.line; - } - }; - - qSort(sharedBindings.begin(), sharedBindings.end(), Sort::lt); - - int startLineNumber = sharedBindings.at(0)->value->location.start.line; - int lineNumber = startLineNumber; - - QByteArray functionArray("[", 1); - for (int ii = 0; ii < sharedBindings.count(); ++ii) { - - JSBindingReference *reference = sharedBindings.at(ii); - QDeclarativeScript::Value *value = reference->value; - const QString &expression = reference->rewrittenExpression; - - if (ii != 0) functionArray.append(",", 1); - - while (lineNumber < value->location.start.line) { - lineNumber++; - functionArray.append("\n", 1); - } - - functionArray += expression.toUtf8(); - lineNumber += expression.count(QLatin1Char('\n')); - reference->compiledIndex = ii; - } - functionArray.append("]", 1); - - compileState->v8BindingProgram = functionArray; - compileState->v8BindingProgramLine = startLineNumber; - } - - if (bindingCompiler.isValid()) - compileState->compiledBindingData = bindingCompiler.program(); - - // Check pop()'s matched push()'s - Q_ASSERT(compileState->objectDepth.depth() == 0); - Q_ASSERT(compileState->listDepth.depth() == 0); - - saveComponentState(); - - return true; -} - -void QDeclarativeCompiler::dumpStats() -{ - Q_ASSERT(componentStats); - qWarning().nospace() << "QML Document: " << output->url.toString(); - for (int ii = 0; ii < componentStats->savedComponentStats.count(); ++ii) { - const ComponentStat &stat = componentStats->savedComponentStats.at(ii); - qWarning().nospace() << " Component Line " << stat.lineNumber; - qWarning().nospace() << " Total Objects: " << stat.objects; - qWarning().nospace() << " IDs Used: " << stat.ids; - qWarning().nospace() << " Optimized Bindings: " << stat.optimizedBindings.count(); - - { - QByteArray output; - for (int ii = 0; ii < stat.optimizedBindings.count(); ++ii) { - if (0 == (ii % 10)) { - if (ii) output.append("\n"); - output.append(" "); - } - - output.append("("); - output.append(QByteArray::number(stat.optimizedBindings.at(ii).start.line)); - output.append(":"); - output.append(QByteArray::number(stat.optimizedBindings.at(ii).start.column)); - output.append(") "); - } - if (!output.isEmpty()) - qWarning().nospace() << output.constData(); - } - - qWarning().nospace() << " QScript Bindings: " << stat.scriptBindings.count(); - { - QByteArray output; - for (int ii = 0; ii < stat.scriptBindings.count(); ++ii) { - if (0 == (ii % 10)) { - if (ii) output.append("\n"); - output.append(" "); - } - - output.append("("); - output.append(QByteArray::number(stat.scriptBindings.at(ii).start.line)); - output.append(":"); - output.append(QByteArray::number(stat.scriptBindings.at(ii).start.column)); - output.append(") "); - } - if (!output.isEmpty()) - qWarning().nospace() << output.constData(); - } - } -} - -/*! - Returns true if from can be assigned to a (QObject) property of type - to. -*/ -bool QDeclarativeCompiler::canCoerce(int to, QDeclarativeScript::Object *from) -{ - const QMetaObject *toMo = enginePrivate->rawMetaObjectForType(to); - const QMetaObject *fromMo = from->metaObject(); - - while (fromMo) { - if (QDeclarativePropertyPrivate::equal(fromMo, toMo)) - return true; - fromMo = fromMo->superClass(); - } - return false; -} - -/*! - Returns the element name, as written in the QML file, for o. -*/ -QString QDeclarativeCompiler::elementName(QDeclarativeScript::Object *o) -{ - Q_ASSERT(o); - if (o->type != -1) { - return output->types.at(o->type).className; - } else { - return QString(); - } -} - -QDeclarativeType *QDeclarativeCompiler::toQmlType(QDeclarativeScript::Object *from) -{ - // ### Optimize - const QMetaObject *mo = from->metatype; - QDeclarativeType *type = 0; - while (!type && mo) { - type = QDeclarativeMetaType::qmlType(mo); - mo = mo->superClass(); - } - return type; -} - -QStringList QDeclarativeCompiler::deferredProperties(QDeclarativeScript::Object *obj) -{ - const QMetaObject *mo = obj->metatype; - - int idx = mo->indexOfClassInfo("DeferredPropertyNames"); - if (idx == -1) - return QStringList(); - - QMetaClassInfo classInfo = mo->classInfo(idx); - QStringList rv = QString::fromUtf8(classInfo.value()).split(QLatin1Char(',')); - return rv; -} - -QDeclarativePropertyData * -QDeclarativeCompiler::property(QDeclarativeScript::Object *object, int index) -{ - QDeclarativePropertyCache *cache = 0; - - if (object->synthCache) - cache = object->synthCache; - else if (object->type != -1) - cache = output->types[object->type].createPropertyCache(engine); - else - cache = QDeclarativeEnginePrivate::get(engine)->cache(object->metaObject()); - - return cache->property(index); -} - -QDeclarativePropertyData * -QDeclarativeCompiler::property(QDeclarativeScript::Object *object, const QHashedStringRef &name, bool *notInRevision) -{ - if (notInRevision) *notInRevision = false; - - QDeclarativePropertyCache *cache = 0; - - if (object->synthCache) - cache = object->synthCache; - else if (object->type != -1) - cache = output->types[object->type].createPropertyCache(engine); - else - cache = QDeclarativeEnginePrivate::get(engine)->cache(object->metaObject()); - - QDeclarativePropertyData *d = cache->property(name); - - // Find the first property - while (d && d->isFunction()) - d = cache->overrideData(d); - - if (d && !cache->isAllowedInRevision(d)) { - if (notInRevision) *notInRevision = true; - return 0; - } else { - return d; - } -} - -// This code must match the semantics of QDeclarativePropertyPrivate::findSignalByName -QDeclarativePropertyData * -QDeclarativeCompiler::signal(QDeclarativeScript::Object *object, const QHashedStringRef &name, bool *notInRevision) -{ - if (notInRevision) *notInRevision = false; - - QDeclarativePropertyCache *cache = 0; - - if (object->synthCache) - cache = object->synthCache; - else if (object->type != -1) - cache = output->types[object->type].createPropertyCache(engine); - else - cache = QDeclarativeEnginePrivate::get(engine)->cache(object->metaObject()); - - - QDeclarativePropertyData *d = cache->property(name); - if (notInRevision) *notInRevision = false; - - while (d && !(d->isFunction())) - d = cache->overrideData(d); - - if (d && !cache->isAllowedInRevision(d)) { - if (notInRevision) *notInRevision = true; - return 0; - } else if (d) { - return d; - } - - if (name.endsWith(Changed_string)) { - QHashedStringRef propName = name.mid(0, name.length() - Changed_string.length()); - - d = property(object, propName, notInRevision); - if (d) - return cache->method(d->notifyIndex); - } - - return 0; -} - -// This code must match the semantics of QDeclarativePropertyPrivate::findSignalByName -int QDeclarativeCompiler::indexOfSignal(QDeclarativeScript::Object *object, const QString &name, - bool *notInRevision) -{ - QDeclarativePropertyData *d = signal(object, QStringRef(&name), notInRevision); - return d?d->coreIndex:-1; -} - -int QDeclarativeCompiler::indexOfProperty(QDeclarativeScript::Object *object, const QString &name, - bool *notInRevision) -{ - return indexOfProperty(object, QStringRef(&name), notInRevision); -} - -int QDeclarativeCompiler::indexOfProperty(QDeclarativeScript::Object *object, const QHashedStringRef &name, - bool *notInRevision) -{ - QDeclarativePropertyData *d = property(object, name, notInRevision); - return d?d->coreIndex:-1; -} - -QT_END_NAMESPACE diff --git a/src/declarative/qml/qdeclarativecompiler_p.h b/src/declarative/qml/qdeclarativecompiler_p.h deleted file mode 100644 index 637cd80569..0000000000 --- a/src/declarative/qml/qdeclarativecompiler_p.h +++ /dev/null @@ -1,466 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QDECLARATIVECOMPILER_P_H -#define QDECLARATIVECOMPILER_P_H - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists purely as an -// implementation detail. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - -#include "qdeclarative.h" -#include "qdeclarativeerror.h" -#include -#include "qdeclarativeinstruction_p.h" -#include "qdeclarativescript_p.h" -#include "qdeclarativeengine_p.h" -#include -#include "qdeclarativepropertycache_p.h" -#include "qdeclarativeintegercache_p.h" -#include "qdeclarativetypenamecache_p.h" -#include "qdeclarativetypeloader_p.h" - -#include -#include -#include - -QT_BEGIN_NAMESPACE - -class QDeclarativeEngine; -class QDeclarativeComponent; -class QDeclarativeContext; -class QDeclarativeContextData; - -class Q_AUTOTEST_EXPORT QDeclarativeCompiledData : public QDeclarativeRefCount, - public QDeclarativeCleanup -{ -public: - QDeclarativeCompiledData(QDeclarativeEngine *engine); - virtual ~QDeclarativeCompiledData(); - - QDeclarativeEngine *engine; - - QString name; - QUrl url; - QDeclarativeTypeNameCache *importCache; - - struct TypeReference - { - TypeReference() - : type(0), typePropertyCache(0), component(0) {} - - QString className; - QDeclarativeType *type; - QDeclarativePropertyCache *typePropertyCache; - QDeclarativeCompiledData *component; - - const QMetaObject *metaObject() const; - QDeclarativePropertyCache *propertyCache() const; - QDeclarativePropertyCache *createPropertyCache(QDeclarativeEngine *); - }; - QList types; - - struct V8Program { - V8Program(const QByteArray &p, QDeclarativeCompiledData *c) - : program(p), cdata(c) {} - - QByteArray program; - v8::Persistent bindings; - QDeclarativeCompiledData *cdata; - }; - - QList programs; - - const QMetaObject *root; - QAbstractDynamicMetaObject rootData; - QDeclarativePropertyCache *rootPropertyCache; - QList primitives; - QList datas; - QByteArray bytecode; - QList propertyCaches; - QList contextCaches; - QList scripts; - QList urls; - - struct Instruction { -#define QML_INSTR_DATA_TYPEDEF(I, FMT) typedef QDeclarativeInstructionData I; - FOR_EACH_QML_INSTR(QML_INSTR_DATA_TYPEDEF) -#undef QML_INSTR_DATA_TYPEDEF - private: - Instruction(); - }; - - void dumpInstructions(); - - template - int addInstruction(const QDeclarativeInstructionData &data) - { - QDeclarativeInstruction genericInstr; - QDeclarativeInstructionMeta::setData(genericInstr, data); - return addInstructionHelper(static_cast(Instr), genericInstr); - } - int nextInstructionIndex(); - QDeclarativeInstruction *instruction(int index); - QDeclarativeInstruction::Type instructionType(const QDeclarativeInstruction *instr); - - bool isInitialized() const { return hasEngine(); } - void initialize(QDeclarativeEngine *); - -protected: - virtual void destroy(); // From QDeclarativeRefCount - virtual void clear(); // From QDeclarativeCleanup - -private: - friend class QDeclarativeCompiler; - - int addInstructionHelper(QDeclarativeInstruction::Type type, QDeclarativeInstruction &instr); - void dump(QDeclarativeInstruction *, int idx = -1); - QDeclarativeCompiledData(const QDeclarativeCompiledData &other); - QDeclarativeCompiledData &operator=(const QDeclarativeCompiledData &other); - QByteArray packData; - int pack(const char *, size_t); - - int indexForString(const QString &); - int indexForByteArray(const QByteArray &); - int indexForUrl(const QUrl &); -}; - -namespace QDeclarativeCompilerTypes { - struct BindingContext - { - BindingContext() - : stack(0), owner(0), object(0) {} - BindingContext(QDeclarativeScript::Object *o) - : stack(0), owner(0), object(o) {} - BindingContext incr() const { - BindingContext rv(object); - rv.stack = stack + 1; - return rv; - } - bool isSubContext() const { return stack != 0; } - int stack; - int owner; - QDeclarativeScript::Object *object; - }; - - struct BindingReference - { - enum DataType { QtScript, V4, V8, - Tr, TrId }; - DataType dataType; - }; - - struct JSBindingReference : public QDeclarativePool::Class, - public BindingReference - { - JSBindingReference() : nextReference(0) {} - - QDeclarativeScript::Variant expression; - QDeclarativeScript::Property *property; - QDeclarativeScript::Value *value; - - int compiledIndex; - - QString rewrittenExpression; - BindingContext bindingContext; - - JSBindingReference *nextReference; - }; - - struct TrBindingReference : public QDeclarativePool::POD, - public BindingReference - { - QStringRef text; - QStringRef comment; - int n; - }; - - struct IdList : public QFieldList - { - QDeclarativeScript::Object *value(const QString &id) const { - for (QDeclarativeScript::Object *o = first(); o; o = next(o)) { - if (o->id == id) - return o; - } - return 0; - } - }; - - struct DepthStack { - DepthStack() : _depth(0), _maxDepth(0) {} - DepthStack(const DepthStack &o) : _depth(o._depth), _maxDepth(o._maxDepth) {} - DepthStack &operator=(const DepthStack &o) { _depth = o._depth; _maxDepth = o._maxDepth; return *this; } - - int depth() const { return _depth; } - int maxDepth() const { return _maxDepth; } - - void push() { ++_depth; _maxDepth = qMax(_depth, _maxDepth); } - void pop() { --_depth; Q_ASSERT(_depth >= 0); Q_ASSERT(_maxDepth > _depth); } - - void pushPop(int count) { _maxDepth = qMax(_depth + count, _maxDepth); } - private: - int _depth; - int _maxDepth; - }; - - // Contains all the incremental compiler state about a component. As - // a single QML file can have multiple components defined, there may be - // more than one of these for each compile - struct ComponentCompileState : public QDeclarativePool::Class - { - ComponentCompileState() - : parserStatusCount(0), totalBindingsCount(0), pushedProperties(0), nested(false), - v8BindingProgramLine(-1), root(0) {} - - IdList ids; - int parserStatusCount; - int totalBindingsCount; - int pushedProperties; - bool nested; - - QByteArray compiledBindingData; - QByteArray v8BindingProgram; - int v8BindingProgramLine; - - DepthStack objectDepth; - DepthStack listDepth; - - typedef QDeclarativeCompilerTypes::JSBindingReference B; - typedef QFieldList JSBindingReferenceList; - JSBindingReferenceList bindings; - typedef QDeclarativeScript::Object O; - typedef QFieldList AliasingObjectsList; - AliasingObjectsList aliasingObjects; - QDeclarativeScript::Object *root; - }; -}; - -class QMetaObjectBuilder; -class Q_AUTOTEST_EXPORT QDeclarativeCompiler -{ - Q_DECLARE_TR_FUNCTIONS(QDeclarativeCompiler) -public: - QDeclarativeCompiler(QDeclarativePool *); - - bool compile(QDeclarativeEngine *, QDeclarativeTypeData *, QDeclarativeCompiledData *); - - bool isError() const; - QList errors() const; - - static bool isAttachedPropertyName(const QString &); - static bool isSignalPropertyName(const QString &); - static bool isAttachedPropertyName(const QHashedStringRef &); - static bool isSignalPropertyName(const QHashedStringRef &); - - int evaluateEnum(const QByteArray& script) const; // for QDeclarativeCustomParser::evaluateEnum - const QMetaObject *resolveType(const QString& name) const; // for QDeclarativeCustomParser::resolveType - int rewriteBinding(const QDeclarativeScript::Variant& value, const QString& name); // for QDeclarativeCustomParser::rewriteBinding - QString rewriteSignalHandler(const QDeclarativeScript::Variant& value, const QString &name); // for QDeclarativeCustomParser::rewriteSignalHandler - -private: - typedef QDeclarativeCompiledData::Instruction Instruction; - - static void reset(QDeclarativeCompiledData *); - - void compileTree(QDeclarativeScript::Object *tree); - - - bool buildObject(QDeclarativeScript::Object *obj, const QDeclarativeCompilerTypes::BindingContext &); - bool buildComponent(QDeclarativeScript::Object *obj, const QDeclarativeCompilerTypes::BindingContext &); - bool buildSubObject(QDeclarativeScript::Object *obj, const QDeclarativeCompilerTypes::BindingContext &); - bool buildSignal(QDeclarativeScript::Property *prop, QDeclarativeScript::Object *obj, - const QDeclarativeCompilerTypes::BindingContext &); - bool buildProperty(QDeclarativeScript::Property *prop, QDeclarativeScript::Object *obj, - const QDeclarativeCompilerTypes::BindingContext &); - bool buildPropertyInNamespace(QDeclarativeImportedNamespace *ns, - QDeclarativeScript::Property *prop, - QDeclarativeScript::Object *obj, - const QDeclarativeCompilerTypes::BindingContext &); - bool buildIdProperty(QDeclarativeScript::Property *prop, QDeclarativeScript::Object *obj); - bool buildAttachedProperty(QDeclarativeScript::Property *prop, - QDeclarativeScript::Object *obj, - const QDeclarativeCompilerTypes::BindingContext &ctxt); - bool buildGroupedProperty(QDeclarativeScript::Property *prop, - QDeclarativeScript::Object *obj, - const QDeclarativeCompilerTypes::BindingContext &ctxt); - bool buildValueTypeProperty(QObject *type, - QDeclarativeScript::Object *obj, - QDeclarativeScript::Object *baseObj, - const QDeclarativeCompilerTypes::BindingContext &ctxt); - bool buildListProperty(QDeclarativeScript::Property *prop, - QDeclarativeScript::Object *obj, - const QDeclarativeCompilerTypes::BindingContext &ctxt); - bool buildScriptStringProperty(QDeclarativeScript::Property *prop, - QDeclarativeScript::Object *obj, - const QDeclarativeCompilerTypes::BindingContext &ctxt); - bool buildPropertyAssignment(QDeclarativeScript::Property *prop, - QDeclarativeScript::Object *obj, - const QDeclarativeCompilerTypes::BindingContext &ctxt); - bool buildPropertyObjectAssignment(QDeclarativeScript::Property *prop, - QDeclarativeScript::Object *obj, - QDeclarativeScript::Value *value, - const QDeclarativeCompilerTypes::BindingContext &ctxt); - bool buildPropertyOnAssignment(QDeclarativeScript::Property *prop, - QDeclarativeScript::Object *obj, - QDeclarativeScript::Object *baseObj, - QDeclarativeScript::Value *value, - const QDeclarativeCompilerTypes::BindingContext &ctxt); - bool buildPropertyLiteralAssignment(QDeclarativeScript::Property *prop, - QDeclarativeScript::Object *obj, - QDeclarativeScript::Value *value, - const QDeclarativeCompilerTypes::BindingContext &ctxt); - bool doesPropertyExist(QDeclarativeScript::Property *prop, QDeclarativeScript::Object *obj); - bool testLiteralAssignment(QDeclarativeScript::Property *prop, - QDeclarativeScript::Value *value); - bool testQualifiedEnumAssignment(QDeclarativeScript::Property *prop, - QDeclarativeScript::Object *obj, - QDeclarativeScript::Value *value, - bool *isAssignment); - enum DynamicMetaMode { IgnoreAliases, ResolveAliases, ForceCreation }; - bool mergeDynamicMetaProperties(QDeclarativeScript::Object *obj); - bool buildDynamicMeta(QDeclarativeScript::Object *obj, DynamicMetaMode mode); - bool checkDynamicMeta(QDeclarativeScript::Object *obj); - bool buildBinding(QDeclarativeScript::Value *, QDeclarativeScript::Property *prop, - const QDeclarativeCompilerTypes::BindingContext &ctxt); - bool buildLiteralBinding(QDeclarativeScript::Value *, QDeclarativeScript::Property *prop, - const QDeclarativeCompilerTypes::BindingContext &ctxt); - bool buildComponentFromRoot(QDeclarativeScript::Object *obj, const QDeclarativeCompilerTypes::BindingContext &); - bool compileAlias(QFastMetaBuilder &, - QByteArray &data, - QDeclarativeScript::Object *obj, - int propIndex, int aliasIndex, - QDeclarativeScript::Object::DynamicProperty &); - bool completeComponentBuild(); - bool checkValidId(QDeclarativeScript::Value *, const QString &); - - - void genObject(QDeclarativeScript::Object *obj); - void genObjectBody(QDeclarativeScript::Object *obj); - void genValueTypeProperty(QDeclarativeScript::Object *obj,QDeclarativeScript::Property *); - void genComponent(QDeclarativeScript::Object *obj); - void genValueProperty(QDeclarativeScript::Property *prop, QDeclarativeScript::Object *obj); - void genListProperty(QDeclarativeScript::Property *prop, QDeclarativeScript::Object *obj); - void genPropertyAssignment(QDeclarativeScript::Property *prop, - QDeclarativeScript::Object *obj, - QDeclarativeScript::Property *valueTypeProperty = 0); - void genLiteralAssignment(QDeclarativeScript::Property *prop, - QDeclarativeScript::Value *value); - void genBindingAssignment(QDeclarativeScript::Value *binding, - QDeclarativeScript::Property *prop, - QDeclarativeScript::Object *obj, - QDeclarativeScript::Property *valueTypeProperty = 0); - int genContextCache(); - - QDeclarativePropertyData genValueTypeData(QDeclarativeScript::Property *prop, - QDeclarativeScript::Property *valueTypeProp); - - int componentTypeRef(); - int translationContextIndex(); - - static QDeclarativeType *toQmlType(QDeclarativeScript::Object *from); - bool canCoerce(int to, QDeclarativeScript::Object *from); - - QString elementName(QDeclarativeScript::Object *); - - QStringList deferredProperties(QDeclarativeScript::Object *); - - QDeclarativePropertyData *property(QDeclarativeScript::Object *, int); - QDeclarativePropertyData *property(QDeclarativeScript::Object *, const QHashedStringRef &, - bool *notInRevision = 0); - QDeclarativePropertyData *signal(QDeclarativeScript::Object *, const QHashedStringRef &, - bool *notInRevision = 0); - int indexOfProperty(QDeclarativeScript::Object *, const QHashedStringRef &, bool *notInRevision = 0); - int indexOfProperty(QDeclarativeScript::Object *, const QString &, bool *notInRevision = 0); - int indexOfSignal(QDeclarativeScript::Object *, const QString &, bool *notInRevision = 0); - - void addId(const QString &, QDeclarativeScript::Object *); - - void dumpStats(); - - void addBindingReference(QDeclarativeCompilerTypes::JSBindingReference *); - - QDeclarativeCompilerTypes::ComponentCompileState *compileState; - - QDeclarativePool *pool; - - QDeclarativeCompilerTypes::ComponentCompileState *componentState(QDeclarativeScript::Object *); - void saveComponentState(); - - QList exceptions; - QDeclarativeCompiledData *output; - QDeclarativeEngine *engine; - QDeclarativeEnginePrivate *enginePrivate; - QDeclarativeScript::Object *unitRoot; - QDeclarativeTypeData *unit; - int cachedComponentTypeRef; - int cachedTranslationContextIndex; - - // Compiler component statistics. Only collected if QML_COMPILER_STATS=1 - struct ComponentStat - { - ComponentStat() : ids(0), objects(0) {} - - int lineNumber; - - int ids; - QList scriptBindings; - QList optimizedBindings; - int objects; - }; - struct ComponentStats : public QDeclarativePool::Class - { - ComponentStat componentStat; - QList savedComponentStats; - }; - ComponentStats *componentStats; -}; - -QT_END_NAMESPACE - -#endif // QDECLARATIVECOMPILER_P_H diff --git a/src/declarative/qml/qdeclarativecomponent.cpp b/src/declarative/qml/qdeclarativecomponent.cpp deleted file mode 100644 index c168c8f4eb..0000000000 --- a/src/declarative/qml/qdeclarativecomponent.cpp +++ /dev/null @@ -1,1351 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qdeclarativecomponent.h" -#include "qdeclarativecomponent_p.h" -#include "qdeclarativecomponentattached_p.h" - -#include "qdeclarativecompiler_p.h" -#include "qdeclarativecontext_p.h" -#include "qdeclarativeengine_p.h" -#include "qdeclarativevme_p.h" -#include "qdeclarative.h" -#include "qdeclarativeengine.h" -#include "qdeclarativebinding_p.h" -#include "qdeclarativebinding_p_p.h" -#include "qdeclarativeglobal_p.h" -#include "qdeclarativescript_p.h" -#include -#include -#include "qdeclarativeincubator.h" -#include "qdeclarativeincubator_p.h" - -#include -#include - -#include -#include -#include -#include - -QT_BEGIN_NAMESPACE - -class QDeclarativeComponentExtension : public QV8Engine::Deletable -{ -public: - QDeclarativeComponentExtension(QV8Engine *); - virtual ~QDeclarativeComponentExtension(); - - v8::Persistent incubationConstructor; - v8::Persistent initialProperties; - v8::Persistent forceCompletion; -}; -V8_DEFINE_EXTENSION(QDeclarativeComponentExtension, componentExtension); - -/* - Try to do what's necessary for a reasonable display of the type - name, but no more (just enough for the client to do more extensive cleanup). - - Should only be called when debugging is enabled. -*/ -static inline QString buildTypeNameForDebug(const QMetaObject *metaObject) -{ - static const QString qmlMarker(QLatin1String("_QML")); - static const QChar underscore(QLatin1Char('_')); - static const QChar asterisk(QLatin1Char('*')); - QDeclarativeType *type = QDeclarativeMetaType::qmlType(metaObject); - QString typeName = type ? type->qmlTypeName() : QString::fromUtf8(metaObject->className()); - if (!type) { - //### optimize further? - int marker = typeName.indexOf(qmlMarker); - if (marker != -1 && marker < typeName.count() - 1) { - if (typeName[marker + 1] == underscore) { - const QString className = typeName.left(marker) + asterisk; - type = QDeclarativeMetaType::qmlType(QMetaType::type(className.toUtf8())); - if (type) - typeName = type->qmlTypeName(); - } - } - } - return typeName; -} - -/*! - \class QDeclarativeComponent - \since 4.7 - \brief The QDeclarativeComponent class encapsulates a QML component definition. - \mainclass - - Components are reusable, encapsulated QML elements with well-defined interfaces. - They are often defined in \l {qdeclarativedocuments.html}{Component Files}. - - A QDeclarativeComponent instance can be created from a QML file. - For example, if there is a \c main.qml file like this: - - \qml - import QtQuick 2.0 - - Item { - width: 200 - height: 200 - } - \endqml - - The following code loads this QML file as a component, creates an instance of - this component using create(), and then queries the \l Item's \l {Item::}{width} - value: - - \code - QDeclarativeEngine *engine = new QDeclarativeEngine; - QDeclarativeComponent component(engine, QUrl::fromLocalFile("main.qml")); - - QObject *myObject = component.create(); - QDeclarativeItem *item = qobject_cast(myObject); - int width = item->width(); // width = 200 - \endcode - - - \section2 Network Components - - If the URL passed to QDeclarativeComponent is a network resource, or if the QML document references a - network resource, the QDeclarativeComponent has to fetch the network data before it is able to create - objects. In this case, the QDeclarativeComponent will have a \l {QDeclarativeComponent::Loading}{Loading} - \l {QDeclarativeComponent::status()}{status}. An application will have to wait until the component - is \l {QDeclarativeComponent::Ready}{Ready} before calling \l {QDeclarativeComponent::create()}. - - The following example shows how to load a QML file from a network resource. After creating - the QDeclarativeComponent, it tests whether the component is loading. If it is, it connects to the - QDeclarativeComponent::statusChanged() signal and otherwise calls the \c {continueLoading()} method - directly. Note that QDeclarativeComponent::isLoading() may be false for a network component if the - component has been cached and is ready immediately. - - \code - MyApplication::MyApplication() - { - // ... - component = new QDeclarativeComponent(engine, QUrl("http://www.example.com/main.qml")); - if (component->isLoading()) - QObject::connect(component, SIGNAL(statusChanged(QDeclarativeComponent::Status)), - this, SLOT(continueLoading())); - else - continueLoading(); - } - - void MyApplication::continueLoading() - { - if (component->isError()) { - qWarning() << component->errors(); - } else { - QObject *myObject = component->create(); - } - } - \endcode - - \sa {Using QML Bindings in C++ Applications}, {Integrating QML Code with Existing Qt UI Code} -*/ - -/*! - \qmlclass Component QDeclarativeComponent - \ingroup qml-utility-elements - \since 4.7 - \brief The Component element encapsulates a QML component definition. - - Components are reusable, encapsulated QML elements with well-defined interfaces. - - Components are often defined by \l {qdeclarativedocuments.html}{component files} - - that is, \c .qml files. The \e Component element essentially allows QML components - to be defined inline, within a \l {QML Document}{QML document}, rather than as a separate QML file. - This may be useful for reusing a small component within a QML file, or for defining - a component that logically belongs with other QML components within a file. - - For example, here is a component that is used by multiple \l Loader objects. - It contains a single item, a \l Rectangle: - - \snippet doc/src/snippets/declarative/component.qml 0 - - Notice that while a \l Rectangle by itself would be automatically - rendered and displayed, this is not the case for the above rectangle - because it is defined inside a \c Component. The component encapsulates the - QML elements within, as if they were defined in a separate QML - file, and is not loaded until requested (in this case, by the - two \l Loader objects). - - Defining a \c Component is similar to defining a \l {QML Document}{QML document}. - A QML document has a single top-level item that defines the behaviors and - properties of that component, and cannot define properties or behaviors outside - of that top-level item. In the same way, a \c Component definition contains a single - top level item (which in the above example is a \l Rectangle) and cannot define any - data outside of this item, with the exception of an \e id (which in the above example - is \e redSquare). - - The \c Component element is commonly used to provide graphical components - for views. For example, the ListView::delegate property requires a \c Component - to specify how each list item is to be displayed. - - \c Component objects can also be created dynamically using - \l{QML:Qt::createComponent()}{Qt.createComponent()}. -*/ - -/*! - \qmlattachedsignal Component::onCompleted() - - Emitted after component "startup" has completed. This can be used to - execute script code at startup, once the full QML environment has been - established. - - The \c {Component::onCompleted} attached property can be applied to - any element. The order of running the \c onCompleted scripts is - undefined. - - \qml - Rectangle { - Component.onCompleted: console.log("Completed Running!") - Rectangle { - Component.onCompleted: console.log("Nested Completed Running!") - } - } - \endqml -*/ - -/*! - \qmlattachedsignal Component::onDestruction() - - Emitted as the component begins destruction. This can be used to undo - work done in the onCompleted signal, or other imperative code in your - application. - - The \c {Component::onDestruction} attached property can be applied to - any element. However, it applies to the destruction of the component as - a whole, and not the destruction of the specific object. The order of - running the \c onDestruction scripts is undefined. - - \qml - Rectangle { - Component.onDestruction: console.log("Destruction Beginning!") - Rectangle { - Component.onDestruction: console.log("Nested Destruction Beginning!") - } - } - \endqml - - \sa QtDeclarative -*/ - -/*! - \enum QDeclarativeComponent::Status - - Specifies the loading status of the QDeclarativeComponent. - - \value Null This QDeclarativeComponent has no data. Call loadUrl() or setData() to add QML content. - \value Ready This QDeclarativeComponent is ready and create() may be called. - \value Loading This QDeclarativeComponent is loading network data. - \value Error An error has occurred. Call errors() to retrieve a list of \{QDeclarativeError}{errors}. -*/ - -void QDeclarativeComponentPrivate::typeDataReady(QDeclarativeTypeData *) -{ - Q_Q(QDeclarativeComponent); - - Q_ASSERT(typeData); - - fromTypeData(typeData); - typeData = 0; - - emit q->statusChanged(q->status()); -} - -void QDeclarativeComponentPrivate::typeDataProgress(QDeclarativeTypeData *, qreal p) -{ - Q_Q(QDeclarativeComponent); - - progress = p; - - emit q->progressChanged(p); -} - -void QDeclarativeComponentPrivate::fromTypeData(QDeclarativeTypeData *data) -{ - url = data->finalUrl(); - QDeclarativeCompiledData *c = data->compiledData(); - - if (!c) { - Q_ASSERT(data->isError()); - state.errors = data->errors(); - } else { - cc = c; - } - - data->release(); -} - -void QDeclarativeComponentPrivate::clear() -{ - if (typeData) { - typeData->unregisterCallback(this); - typeData->release(); - typeData = 0; - } - - if (cc) { - cc->release(); - cc = 0; - } -} - -/*! - \internal -*/ -QDeclarativeComponent::QDeclarativeComponent(QObject *parent) - : QObject(*(new QDeclarativeComponentPrivate), parent) -{ -} - -/*! - Destruct the QDeclarativeComponent. -*/ -QDeclarativeComponent::~QDeclarativeComponent() -{ - Q_D(QDeclarativeComponent); - - if (d->state.completePending) { - qWarning("QDeclarativeComponent: Component destroyed while completion pending"); - d->completeCreate(); - } - - if (d->typeData) { - d->typeData->unregisterCallback(d); - d->typeData->release(); - } - if (d->cc) - d->cc->release(); -} - -/*! - \qmlproperty enumeration Component::status - This property holds the status of component loading. It can be one of: - \list - \o Component.Null - no data is available for the component - \o Component.Ready - the component has been loaded, and can be used to create instances. - \o Component.Loading - the component is currently being loaded - \o Component.Error - an error occurred while loading the component. - Calling errorString() will provide a human-readable description of any errors. - \endlist - */ - -/*! - \property QDeclarativeComponent::status - The component's current \l{QDeclarativeComponent::Status} {status}. - */ -QDeclarativeComponent::Status QDeclarativeComponent::status() const -{ - Q_D(const QDeclarativeComponent); - - if (d->typeData) - return Loading; - else if (!d->state.errors.isEmpty()) - return Error; - else if (d->engine && d->cc) - return Ready; - else - return Null; -} - -/*! - Returns true if status() == QDeclarativeComponent::Null. -*/ -bool QDeclarativeComponent::isNull() const -{ - return status() == Null; -} - -/*! - Returns true if status() == QDeclarativeComponent::Ready. -*/ -bool QDeclarativeComponent::isReady() const -{ - return status() == Ready; -} - -/*! - Returns true if status() == QDeclarativeComponent::Error. -*/ -bool QDeclarativeComponent::isError() const -{ - return status() == Error; -} - -/*! - Returns true if status() == QDeclarativeComponent::Loading. -*/ -bool QDeclarativeComponent::isLoading() const -{ - return status() == Loading; -} - -/*! - \qmlproperty real Component::progress - The progress of loading the component, from 0.0 (nothing loaded) - to 1.0 (finished). -*/ - -/*! - \property QDeclarativeComponent::progress - The progress of loading the component, from 0.0 (nothing loaded) - to 1.0 (finished). -*/ -qreal QDeclarativeComponent::progress() const -{ - Q_D(const QDeclarativeComponent); - return d->progress; -} - -/*! - \fn void QDeclarativeComponent::progressChanged(qreal progress) - - Emitted whenever the component's loading progress changes. \a progress will be the - current progress between 0.0 (nothing loaded) and 1.0 (finished). -*/ - -/*! - \fn void QDeclarativeComponent::statusChanged(QDeclarativeComponent::Status status) - - Emitted whenever the component's status changes. \a status will be the - new status. -*/ - -/*! - Create a QDeclarativeComponent with no data and give it the specified - \a engine and \a parent. Set the data with setData(). -*/ -QDeclarativeComponent::QDeclarativeComponent(QDeclarativeEngine *engine, QObject *parent) - : QObject(*(new QDeclarativeComponentPrivate), parent) -{ - Q_D(QDeclarativeComponent); - d->engine = engine; -} - -/*! - Create a QDeclarativeComponent from the given \a url and give it the - specified \a parent and \a engine. - - Ensure that the URL provided is full and correct, in particular, use - \l QUrl::fromLocalFile() when loading a file from the local filesystem. - - \sa loadUrl() -*/ -QDeclarativeComponent::QDeclarativeComponent(QDeclarativeEngine *engine, const QUrl &url, QObject *parent) -: QObject(*(new QDeclarativeComponentPrivate), parent) -{ - Q_D(QDeclarativeComponent); - d->engine = engine; - loadUrl(url); -} - -/*! - Create a QDeclarativeComponent from the given \a fileName and give it the specified - \a parent and \a engine. - - \sa loadUrl() -*/ -QDeclarativeComponent::QDeclarativeComponent(QDeclarativeEngine *engine, const QString &fileName, - QObject *parent) -: QObject(*(new QDeclarativeComponentPrivate), parent) -{ - Q_D(QDeclarativeComponent); - d->engine = engine; - loadUrl(d->engine->baseUrl().resolved(QUrl::fromLocalFile(fileName))); -} - -/*! - \internal -*/ -QDeclarativeComponent::QDeclarativeComponent(QDeclarativeEngine *engine, QDeclarativeCompiledData *cc, int start, QObject *parent) - : QObject(*(new QDeclarativeComponentPrivate), parent) -{ - Q_D(QDeclarativeComponent); - d->engine = engine; - d->cc = cc; - cc->addref(); - d->start = start; - d->url = cc->url; - d->progress = 1.0; -} - -/*! - Sets the QDeclarativeComponent to use the given QML \a data. If \a url - is provided, it is used to set the component name and to provide - a base path for items resolved by this component. -*/ -void QDeclarativeComponent::setData(const QByteArray &data, const QUrl &url) -{ - Q_D(QDeclarativeComponent); - - d->clear(); - - d->url = url; - - QDeclarativeTypeData *typeData = QDeclarativeEnginePrivate::get(d->engine)->typeLoader.get(data, url); - - if (typeData->isCompleteOrError()) { - d->fromTypeData(typeData); - } else { - d->typeData = typeData; - d->typeData->registerCallback(d); - } - - d->progress = 1.0; - emit statusChanged(status()); - emit progressChanged(d->progress); -} - -/*! -Returns the QDeclarativeContext the component was created in. This is only -valid for components created directly from QML. -*/ -QDeclarativeContext *QDeclarativeComponent::creationContext() const -{ - Q_D(const QDeclarativeComponent); - if(d->creationContext) - return d->creationContext->asQDeclarativeContext(); - - return qmlContext(this); -} - -/*! - Load the QDeclarativeComponent from the provided \a url. - - Ensure that the URL provided is full and correct, in particular, use - \l QUrl::fromLocalFile() when loading a file from the local filesystem. -*/ -void QDeclarativeComponent::loadUrl(const QUrl &url) -{ - Q_D(QDeclarativeComponent); - - d->clear(); - - if ((url.isRelative() && !url.isEmpty()) - || url.scheme() == QLatin1String("file")) // Workaround QTBUG-11929 - d->url = d->engine->baseUrl().resolved(url); - else - d->url = url; - - if (url.isEmpty()) { - QDeclarativeError error; - error.setDescription(tr("Invalid empty URL")); - d->state.errors << error; - return; - } - - QDeclarativeTypeData *data = QDeclarativeEnginePrivate::get(d->engine)->typeLoader.get(d->url); - - if (data->isCompleteOrError()) { - d->fromTypeData(data); - d->progress = 1.0; - } else { - d->typeData = data; - d->typeData->registerCallback(d); - d->progress = data->progress(); - } - - emit statusChanged(status()); - emit progressChanged(d->progress); -} - -/*! - Return the list of errors that occurred during the last compile or create - operation. An empty list is returned if isError() is not set. -*/ -QList QDeclarativeComponent::errors() const -{ - Q_D(const QDeclarativeComponent); - if (isError()) - return d->state.errors; - else - return QList(); -} - -/*! - \qmlmethod string Component::errorString() - - Returns a human-readable description of any errors. - - The string includes the file, location, and description of each error. - If multiple errors are present they are separated by a newline character. - - If no errors are present, an empty string is returned. -*/ - -/*! - \internal - errorString is only meant as a way to get the errors in script -*/ -QString QDeclarativeComponent::errorString() const -{ - Q_D(const QDeclarativeComponent); - QString ret; - if(!isError()) - return ret; - foreach(const QDeclarativeError &e, d->state.errors) { - ret += e.url().toString() + QLatin1Char(':') + - QString::number(e.line()) + QLatin1Char(' ') + - e.description() + QLatin1Char('\n'); - } - return ret; -} - -/*! - \qmlproperty url Component::url - The component URL. This is the URL that was used to construct the component. -*/ - -/*! - \property QDeclarativeComponent::url - The component URL. This is the URL passed to either the constructor, - or the loadUrl() or setData() methods. -*/ -QUrl QDeclarativeComponent::url() const -{ - Q_D(const QDeclarativeComponent); - return d->url; -} - -/*! - \internal -*/ -QDeclarativeComponent::QDeclarativeComponent(QDeclarativeComponentPrivate &dd, QObject *parent) - : QObject(dd, parent) -{ -} - -/*! - Create an object instance from this component. Returns 0 if creation - failed. \a context specifies the context within which to create the object - instance. - - If \a context is 0 (the default), it will create the instance in the - engine' s \l {QDeclarativeEngine::rootContext()}{root context}. -*/ -QObject *QDeclarativeComponent::create(QDeclarativeContext *context) -{ - Q_D(QDeclarativeComponent); - - if (!context) - context = d->engine->rootContext(); - - QObject *rv = beginCreate(context); - completeCreate(); - return rv; -} - -/*! - This method provides more advanced control over component instance creation. - In general, programmers should use QDeclarativeComponent::create() to create a - component. - - Create an object instance from this component. Returns 0 if creation - failed. \a publicContext specifies the context within which to create the object - instance. - - When QDeclarativeComponent constructs an instance, it occurs in three steps: - \list 1 - \i The object hierarchy is created, and constant values are assigned. - \i Property bindings are evaluated for the the first time. - \i If applicable, QDeclarativeParserStatus::componentComplete() is called on objects. - \endlist - QDeclarativeComponent::beginCreate() differs from QDeclarativeComponent::create() in that it - only performs step 1. QDeclarativeComponent::completeCreate() must be called to - complete steps 2 and 3. - - This breaking point is sometimes useful when using attached properties to - communicate information to an instantiated component, as it allows their - initial values to be configured before property bindings take effect. -*/ -QObject *QDeclarativeComponent::beginCreate(QDeclarativeContext *publicContext) -{ - Q_D(QDeclarativeComponent); - - Q_ASSERT(publicContext); - QDeclarativeContextData *context = QDeclarativeContextData::get(publicContext); - - return d->beginCreate(context); -} - -QObject * -QDeclarativeComponentPrivate::beginCreate(QDeclarativeContextData *context) -{ - Q_Q(QDeclarativeComponent); - if (!context) { - qWarning("QDeclarativeComponent: Cannot create a component in a null context"); - return 0; - } - - if (!context->isValid()) { - qWarning("QDeclarativeComponent: Cannot create a component in an invalid context"); - return 0; - } - - if (context->engine != engine) { - qWarning("QDeclarativeComponent: Must create component in context from the same QDeclarativeEngine"); - return 0; - } - - if (state.completePending) { - qWarning("QDeclarativeComponent: Cannot create new component instance before completing the previous"); - return 0; - } - - if (!q->isReady()) { - qWarning("QDeclarativeComponent: Component is not ready"); - return 0; - } - - QDeclarativeEnginePrivate *enginePriv = QDeclarativeEnginePrivate::get(engine); - - bool isRoot = enginePriv->inProgressCreations == 0; - enginePriv->inProgressCreations++; - state.errors.clear(); - state.completePending = true; - - if (isRoot) - QDeclarativeProfilerService::startRange(QDeclarativeProfilerService::Creating); - - enginePriv->referenceScarceResources(); - state.vme.init(context, cc, start, creationContext); - QObject *rv = state.vme.execute(&state.errors); - enginePriv->dereferenceScarceResources(); - - if (rv) { - QDeclarativeData *ddata = QDeclarativeData::get(rv); - Q_ASSERT(ddata); - ddata->indestructible = true; - } - - if (enginePriv->isDebugging && rv) { - if (!context->isInternal) - context->asQDeclarativeContextPrivate()->instances.append(rv); - QDeclarativeEngineDebugService::instance()->objectCreated(engine, rv); - if (isRoot) { - QDeclarativeProfilerService::rangeData(QDeclarativeProfilerService::Creating, - buildTypeNameForDebug(rv->metaObject())); - QDeclarativeData *data = QDeclarativeData::get(rv); - Q_ASSERT(data); - QDeclarativeProfilerService::rangeLocation(QDeclarativeProfilerService::Creating, - cc->url, data->lineNumber, data->columnNumber); - } - } - - return rv; -} - -void QDeclarativeComponentPrivate::beginDeferred(QDeclarativeEnginePrivate *enginePriv, - QObject *object, ConstructionState *state) -{ - enginePriv->inProgressCreations++; - state->errors.clear(); - state->completePending = true; - - state->vme.initDeferred(object); - state->vme.execute(&state->errors); -} - -void QDeclarativeComponentPrivate::complete(QDeclarativeEnginePrivate *enginePriv, ConstructionState *state) -{ - if (state->completePending) { - state->vme.complete(); - - state->completePending = false; - - enginePriv->inProgressCreations--; - - if (0 == enginePriv->inProgressCreations) { - while (enginePriv->erroredBindings) { - enginePriv->warning(enginePriv->erroredBindings->error); - enginePriv->erroredBindings->removeError(); - } - } - } -} - -/*! - This method provides more advanced control over component instance creation. - In general, programmers should use QDeclarativeComponent::create() to create a - component. - - Complete a component creation begin with QDeclarativeComponent::beginCreate(). -*/ -void QDeclarativeComponent::completeCreate() -{ - Q_D(QDeclarativeComponent); - - d->completeCreate(); -} - -void QDeclarativeComponentPrivate::completeCreate() -{ - if (state.completePending) { - QDeclarativeEnginePrivate *ep = QDeclarativeEnginePrivate::get(engine); - complete(ep, &state); - - QDeclarativeProfilerService::endRange(QDeclarativeProfilerService::Creating); - } -} - -QDeclarativeComponentAttached::QDeclarativeComponentAttached(QObject *parent) -: QObject(parent), prev(0), next(0) -{ -} - -QDeclarativeComponentAttached::~QDeclarativeComponentAttached() -{ - if (prev) *prev = next; - if (next) next->prev = prev; - prev = 0; - next = 0; -} - -/*! - \internal -*/ -QDeclarativeComponentAttached *QDeclarativeComponent::qmlAttachedProperties(QObject *obj) -{ - QDeclarativeComponentAttached *a = new QDeclarativeComponentAttached(obj); - - QDeclarativeEngine *engine = qmlEngine(obj); - if (!engine) - return a; - - if (QDeclarativeEnginePrivate::get(engine)->activeVME) { // XXX should only be allowed during begin - QDeclarativeEnginePrivate *p = QDeclarativeEnginePrivate::get(engine); - a->add(&p->activeVME->componentAttached); - } else { - QDeclarativeData *d = QDeclarativeData::get(obj); - Q_ASSERT(d); - Q_ASSERT(d->context); - a->add(&d->context->componentAttached); - } - - return a; -} - -void QDeclarativeComponent::create(QDeclarativeIncubator &i, QDeclarativeContext *context, - QDeclarativeContext *forContext) -{ - Q_D(QDeclarativeComponent); - - if (!context) - context = d->engine->rootContext(); - - QDeclarativeContextData *contextData = QDeclarativeContextData::get(context); - QDeclarativeContextData *forContextData = contextData; - if (forContext) forContextData = QDeclarativeContextData::get(forContext); - - if (!contextData->isValid()) { - qWarning("QDeclarativeComponent: Cannot create a component in an invalid context"); - return; - } - - if (contextData->engine != d->engine) { - qWarning("QDeclarativeComponent: Must create component in context from the same QDeclarativeEngine"); - return; - } - - if (!isReady()) { - qWarning("QDeclarativeComponent: Component is not ready"); - return; - } - - i.clear(); - QDeclarativeIncubatorPrivate *p = i.d; - - QDeclarativeEnginePrivate *enginePriv = QDeclarativeEnginePrivate::get(d->engine); - - p->component = d->cc; p->component->addref(); - p->vme.init(contextData, d->cc, d->start, d->creationContext); - - enginePriv->incubate(i, forContextData); -} - -class QV8IncubatorResource : public QV8ObjectResource, - public QDeclarativeIncubator -{ -V8_RESOURCE_TYPE(IncubatorType) -public: - QV8IncubatorResource(QV8Engine *engine, IncubationMode = Asynchronous); - - static v8::Handle StatusChangedGetter(v8::Local, - const v8::AccessorInfo& info); - static v8::Handle StatusGetter(v8::Local, - const v8::AccessorInfo& info); - static v8::Handle ObjectGetter(v8::Local, - const v8::AccessorInfo& info); - static v8::Handle ForceCompletionGetter(v8::Local, - const v8::AccessorInfo& info); - static v8::Handle ForceCompletion(const v8::Arguments &args); - - static void StatusChangedSetter(v8::Local, v8::Local value, - const v8::AccessorInfo& info); - - void dispose(); - - v8::Persistent me; - QDeclarativeGuard parent; - v8::Persistent valuemap; - v8::Persistent qmlGlobal; -protected: - virtual void statusChanged(Status); - virtual void setInitialState(QObject *); -}; - -static void QDeclarativeComponent_setQmlParent(QObject *me, QObject *parent) -{ - if (parent) { - me->setParent(parent); - typedef QDeclarativePrivate::AutoParentFunction APF; - QList functions = QDeclarativeMetaType::parentFunctions(); - - bool needParent = false; - for (int ii = 0; ii < functions.count(); ++ii) { - QDeclarativePrivate::AutoParentResult res = functions.at(ii)(me, parent); - if (res == QDeclarativePrivate::Parented) { - needParent = false; - break; - } else if (res == QDeclarativePrivate::IncompatibleParent) { - needParent = true; - } - } - if (needParent) - qWarning("QDeclarativeComponent: Created graphical object was not " - "placed in the graphics scene."); - } -} - -/*! - \qmlmethod object Component::createObject(Item parent, object properties) - - Creates and returns an object instance of this component that will have - the given \a parent and \a properties. The \a properties argument is optional. - Returns null if object creation fails. - - The object will be created in the same context as the one in which the component - was created. This function will always return null when called on components - which were not created in QML. - - If you wish to create an object without setting a parent, specify \c null for - the \a parent value. Note that if the returned object is to be displayed, you - must provide a valid \a parent value or set the returned object's \l{Item::parent}{parent} - property, or else the object will not be visible. - - If a \a parent is not provided to createObject(), a reference to the returned object must be held so that - it is not destroyed by the garbage collector. This is true regardless of whether \l{Item::parent} is set afterwards, - since setting the Item parent does not change object ownership; only the graphical parent is changed. - - As of QtQuick 1.1, this method accepts an optional \a properties argument that specifies a - map of initial property values for the created object. These values are applied before object - creation is finalized. (This is more efficient than setting property values after object creation, - particularly where large sets of property values are defined, and also allows property bindings - to be set up before the object is created.) - - The \a properties argument is specified as a map of property-value items. For example, the code - below creates an object with initial \c x and \c y values of 100 and 200, respectively: - - \js - var component = Qt.createComponent("Button.qml"); - if (component.status == Component.Ready) - component.createObject(parent, {"x": 100, "y": 100}); - \endjs - - Dynamically created instances can be deleted with the \c destroy() method. - See \l {Dynamic Object Management in QML} for more information. -*/ -void QDeclarativeComponent::createObject(QDeclarativeV8Function *args) -{ - Q_D(QDeclarativeComponent); - Q_ASSERT(d->engine); - Q_ASSERT(args); - - QObject *parent = 0; - v8::Local valuemap; - - if (args->Length() >= 1) - parent = args->engine()->toQObject((*args)[0]); - - if (args->Length() >= 2) { - v8::Local v = (*args)[1]; - if (!v->IsObject() || v->IsArray()) { - qmlInfo(this) << tr("createObject: value is not an object"); - args->returnValue(v8::Null()); - return; - } - valuemap = v8::Local::Cast(v); - } - - QV8Engine *v8engine = args->engine(); - - QDeclarativeContext *ctxt = creationContext(); - if (!ctxt) ctxt = d->engine->rootContext(); - - QObject *rv = beginCreate(ctxt); - - if (!rv) { - args->returnValue(v8::Null()); - return; - } - - QDeclarativeComponent_setQmlParent(rv, parent); - - v8::Handle ov = v8engine->newQObject(rv); - Q_ASSERT(ov->IsObject()); - v8::Handle object = v8::Handle::Cast(ov); - - if (!valuemap.IsEmpty()) { - QDeclarativeComponentExtension *e = componentExtension(v8engine); - // Try catch isn't needed as the function itself is loaded with try/catch - v8::Handle function = e->initialProperties->Run(args->qmlGlobal()); - v8::Handle args[] = { object, valuemap }; - v8::Handle::Cast(function)->Call(v8engine->global(), 2, args); - } - - d->completeCreate(); - - Q_ASSERT(QDeclarativeData::get(rv)); - QDeclarativeData::get(rv)->setImplicitDestructible(); - - if (!rv) - args->returnValue(v8::Null()); - else - args->returnValue(object); -} - -/*! - \qmlmethod object Component::incubateObject(Item parent, object properties, enum mode) - - Creates an incubator for instance of this component. Incubators allow new component - instances to be instantiated asynchronously and not cause freezes in the UI. - - The \a parent argument specifies the parent the created instance will have. Omitting the - parameter or passing null will create anobject with no parent. In this case, a reference - to the created object must be maintained by the application of the object will eventually - be garbage collected. - - The \a properties argument is specified as a map of property-value items which will be - set on the created object during its construction. \a mode may be Qt.Synchronous or - Qt.Asynchronous and controls whether the instance is created synchronously or asynchronously. - The default is asynchronously. In some circumstances, even if Qt.Synchronous is specified, - the incubator may create the object asynchronously. This happens if the component calling - incubateObject() is itself being created asynchronously. - - All three arguments are optional. - - If successful, the method returns an incubator, otherwise null. The incubator has the following - properties: - - \list - \i status The status of the incubator. Valid values are Component.Ready, Component.Loading and - Component.Error. - \i object The created object instance. Will only be available once the incubator is in the - Ready status. - \i onStatusChanged Specifies a callback function to be invoked when the status changes. The - status is passed as a parameter to the callback. - \i forceCompletion() Call to complete incubation synchronously. - \endlist - - The following example demonstrates how to use an incubator: - - \js - var component = Qt.createComponent("Button.qml"); - - var incubator = component.incubateObject(parent, { x: 10, y: 10 }); - if (incubator.status != Component.Ready) { - incubator.onStatusChanged = function(status) { - if (status == Component.Ready) { - print ("Object", incubator.object, "is now ready!"); - } - } - } else { - print ("Object", incubator.object, "is ready immediately!"); - } - \endjs -*/ - -void QDeclarativeComponent::incubateObject(QDeclarativeV8Function *args) -{ - Q_D(QDeclarativeComponent); - Q_ASSERT(d->engine); - Q_UNUSED(d); - Q_ASSERT(args); - - QObject *parent = 0; - v8::Local valuemap; - QDeclarativeIncubator::IncubationMode mode = QDeclarativeIncubator::Asynchronous; - - if (args->Length() >= 1) - parent = args->engine()->toQObject((*args)[0]); - - if (args->Length() >= 2) { - v8::Local v = (*args)[1]; - if (v->IsNull()) { - } else if (!v->IsObject() || v->IsArray()) { - qmlInfo(this) << tr("createObject: value is not an object"); - args->returnValue(v8::Null()); - return; - } else { - valuemap = v8::Local::Cast(v); - } - } - - if (args->Length() >= 3) { - quint32 v = (*args)[2]->Uint32Value(); - if (v == 0) - mode = QDeclarativeIncubator::Asynchronous; - else if (v == 1) - mode = QDeclarativeIncubator::AsynchronousIfNested; - } - - QDeclarativeComponentExtension *e = componentExtension(args->engine()); - - QV8IncubatorResource *r = new QV8IncubatorResource(args->engine(), mode); - v8::Local o = e->incubationConstructor->NewInstance(); - o->SetExternalResource(r); - - if (!valuemap.IsEmpty()) { - r->valuemap = qPersistentNew(valuemap); - r->qmlGlobal = qPersistentNew(args->qmlGlobal()); - } - r->parent = parent; - r->me = qPersistentNew(o); - - create(*r, creationContext()); - - if (r->status() == QDeclarativeIncubator::Null) { - r->dispose(); - args->returnValue(v8::Null()); - } else { - args->returnValue(o); - } -} - -// XXX used by QSGLoader -void QDeclarativeComponentPrivate::initializeObjectWithInitialProperties(v8::Handle qmlGlobal, v8::Handle valuemap, QObject *toCreate) -{ - QDeclarativeEnginePrivate *ep = QDeclarativeEnginePrivate::get(engine); - QV8Engine *v8engine = ep->v8engine(); - - v8::HandleScope handle_scope; - v8::Context::Scope scope(v8engine->context()); - v8::Handle ov = v8engine->newQObject(toCreate); - Q_ASSERT(ov->IsObject()); - v8::Handle object = v8::Handle::Cast(ov); - - if (!valuemap.IsEmpty()) { - QDeclarativeComponentExtension *e = componentExtension(v8engine); - // Try catch isn't needed as the function itself is loaded with try/catch - v8::Handle function = e->initialProperties->Run(qmlGlobal); - v8::Handle args[] = { object, valuemap }; - v8::Handle::Cast(function)->Call(v8engine->global(), 2, args); - } - - QDeclarativeData *ddata = QDeclarativeData::get(toCreate); - Q_ASSERT(ddata); - ddata->setImplicitDestructible(); -} - - -QDeclarativeComponentExtension::QDeclarativeComponentExtension(QV8Engine *engine) -{ - v8::HandleScope handle_scope; - v8::Context::Scope scope(engine->context()); - - forceCompletion = qPersistentNew(V8FUNCTION(QV8IncubatorResource::ForceCompletion, engine)); - - { - v8::Local ft = v8::FunctionTemplate::New(); - ft->InstanceTemplate()->SetHasExternalResource(true); - ft->InstanceTemplate()->SetInternalFieldCount(1); - ft->InstanceTemplate()->SetAccessor(v8::String::New("onStatusChanged"), - QV8IncubatorResource::StatusChangedGetter, - QV8IncubatorResource::StatusChangedSetter); - ft->InstanceTemplate()->SetAccessor(v8::String::New("status"), - QV8IncubatorResource::StatusGetter); - ft->InstanceTemplate()->SetAccessor(v8::String::New("object"), - QV8IncubatorResource::ObjectGetter); - ft->InstanceTemplate()->SetAccessor(v8::String::New("forceCompletion"), - QV8IncubatorResource::ForceCompletionGetter); - incubationConstructor = qPersistentNew(ft->GetFunction()); - } - - { -#define INITIALPROPERTIES_SOURCE \ - "(function(object, values) {"\ - "try {"\ - "for(var property in values) {" \ - "try {"\ - "var properties = property.split(\".\");"\ - "var o = object;"\ - "for (var ii = 0; ii < properties.length - 1; ++ii) {"\ - "o = o[properties[ii]];"\ - "}"\ - "o[properties[properties.length - 1]] = values[property];"\ - "} catch(e) {}"\ - "}"\ - "} catch(e) {}"\ - "})" - initialProperties = qPersistentNew(engine->qmlModeCompile(QLatin1String(INITIALPROPERTIES_SOURCE))); -#undef INITIALPROPERTIES_SOURCE - } -} - -v8::Handle QV8IncubatorResource::ObjectGetter(v8::Local, - const v8::AccessorInfo& info) -{ - QV8IncubatorResource *r = v8_resource_check(info.This()); - return r->engine->newQObject(r->object()); -} - -v8::Handle QV8IncubatorResource::ForceCompletionGetter(v8::Local, - const v8::AccessorInfo& info) -{ - QV8IncubatorResource *r = v8_resource_check(info.This()); - return componentExtension(r->engine)->forceCompletion; -} - -v8::Handle QV8IncubatorResource::ForceCompletion(const v8::Arguments &args) -{ - QV8IncubatorResource *r = v8_resource_cast(args.This()); - if (!r) - V8THROW_TYPE("Not an incubator object"); - - r->forceCompletion(); - - return v8::Undefined(); -} - -v8::Handle QV8IncubatorResource::StatusGetter(v8::Local, - const v8::AccessorInfo& info) -{ - QV8IncubatorResource *r = v8_resource_check(info.This()); - return v8::Integer::NewFromUnsigned(r->status()); -} - -v8::Handle QV8IncubatorResource::StatusChangedGetter(v8::Local, - const v8::AccessorInfo& info) -{ - return info.This()->GetInternalField(0); -} - -void QV8IncubatorResource::StatusChangedSetter(v8::Local, v8::Local value, - const v8::AccessorInfo& info) -{ - info.This()->SetInternalField(0, value); -} - -QDeclarativeComponentExtension::~QDeclarativeComponentExtension() -{ - qPersistentDispose(incubationConstructor); - qPersistentDispose(initialProperties); - qPersistentDispose(forceCompletion); -} - -QV8IncubatorResource::QV8IncubatorResource(QV8Engine *engine, IncubationMode m) -: QV8ObjectResource(engine), QDeclarativeIncubator(m) -{ -} - -void QV8IncubatorResource::setInitialState(QObject *o) -{ - QDeclarativeComponent_setQmlParent(o, parent); - - if (!valuemap.IsEmpty()) { - QDeclarativeComponentExtension *e = componentExtension(engine); - - v8::HandleScope handle_scope; - v8::Context::Scope scope(engine->context()); - - v8::Handle function = e->initialProperties->Run(qmlGlobal); - v8::Handle args[] = { engine->newQObject(o), valuemap }; - v8::Handle::Cast(function)->Call(engine->global(), 2, args); - - qPersistentDispose(valuemap); - qPersistentDispose(qmlGlobal); - } -} - -void QV8IncubatorResource::dispose() -{ - qPersistentDispose(valuemap); - qPersistentDispose(qmlGlobal); - // No further status changes are forthcoming, so we no long need a self reference - qPersistentDispose(me); -} - -void QV8IncubatorResource::statusChanged(Status s) -{ - if (s == Ready) { - Q_ASSERT(QDeclarativeData::get(object())); - QDeclarativeData::get(object())->setImplicitDestructible(); - } - - if (!me.IsEmpty()) { // Will be false in synchronous mode - v8::HandleScope scope; - v8::Local callback = me->GetInternalField(0); - - if (!callback.IsEmpty() && !callback->IsUndefined()) { - - if (callback->IsFunction()) { - v8::Context::Scope context_scope(engine->context()); - v8::Local f = v8::Local::Cast(callback); - v8::Handle args[] = { v8::Integer::NewFromUnsigned(s) }; - v8::TryCatch tc; - f->Call(me, 1, args); - if (tc.HasCaught()) { - QDeclarativeError error; - QDeclarativeExpressionPrivate::exceptionToError(tc.Message(), error); - QDeclarativeEnginePrivate::warning(QDeclarativeEnginePrivate::get(engine->engine()), - error); - } - } - } - } - - if (s == Ready || s == Error) - dispose(); -} - -QT_END_NAMESPACE diff --git a/src/declarative/qml/qdeclarativecomponent.h b/src/declarative/qml/qdeclarativecomponent.h deleted file mode 100644 index 2bd292081c..0000000000 --- a/src/declarative/qml/qdeclarativecomponent.h +++ /dev/null @@ -1,138 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QDECLARATIVECOMPONENT_H -#define QDECLARATIVECOMPONENT_H - -#include -#include - -#include -#include -#include - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - - -class QByteArray; -class QDeclarativeEngine; -class QDeclarativeComponent; -class QDeclarativeIncubator; -class QDeclarativeV8Function; -class QDeclarativeCompiledData; -class QDeclarativeComponentPrivate; -class QDeclarativeComponentAttached; - -class Q_DECLARATIVE_EXPORT QDeclarativeComponent : public QObject -{ - Q_OBJECT - Q_DECLARE_PRIVATE(QDeclarativeComponent) - - Q_PROPERTY(qreal progress READ progress NOTIFY progressChanged) - Q_PROPERTY(Status status READ status NOTIFY statusChanged) - Q_PROPERTY(QUrl url READ url CONSTANT) - -public: - QDeclarativeComponent(QObject *parent = 0); - QDeclarativeComponent(QDeclarativeEngine *, QObject *parent=0); - QDeclarativeComponent(QDeclarativeEngine *, const QString &fileName, QObject *parent = 0); - QDeclarativeComponent(QDeclarativeEngine *, const QUrl &url, QObject *parent = 0); - virtual ~QDeclarativeComponent(); - - Q_ENUMS(Status) - enum Status { Null, Ready, Loading, Error }; - Status status() const; - - bool isNull() const; - bool isReady() const; - bool isError() const; - bool isLoading() const; - - QList errors() const; - Q_INVOKABLE QString errorString() const; - - qreal progress() const; - - QUrl url() const; - - virtual QObject *create(QDeclarativeContext *context = 0); - virtual QObject *beginCreate(QDeclarativeContext *); - virtual void completeCreate(); - - void create(QDeclarativeIncubator &, QDeclarativeContext *context = 0, - QDeclarativeContext *forContext = 0); - - QDeclarativeContext *creationContext() const; - - static QDeclarativeComponentAttached *qmlAttachedProperties(QObject *); - -public Q_SLOTS: - void loadUrl(const QUrl &url); - void setData(const QByteArray &, const QUrl &baseUrl); - -Q_SIGNALS: - void statusChanged(QDeclarativeComponent::Status); - void progressChanged(qreal); - -protected: - QDeclarativeComponent(QDeclarativeComponentPrivate &dd, QObject* parent); - Q_INVOKABLE void createObject(QDeclarativeV8Function *); - Q_INVOKABLE void incubateObject(QDeclarativeV8Function *); - -private: - QDeclarativeComponent(QDeclarativeEngine *, QDeclarativeCompiledData *, int, QObject *parent); - - Q_DISABLE_COPY(QDeclarativeComponent) - friend class QDeclarativeVME; - friend class QDeclarativeTypeData; -}; - -QT_END_NAMESPACE - -Q_DECLARE_METATYPE(QDeclarativeComponent::Status) -QML_DECLARE_TYPE(QDeclarativeComponent) -QML_DECLARE_TYPEINFO(QDeclarativeComponent, QML_HAS_ATTACHED_PROPERTIES) - -QT_END_HEADER - -#endif // QDECLARATIVECOMPONENT_H diff --git a/src/declarative/qml/qdeclarativecomponent_p.h b/src/declarative/qml/qdeclarativecomponent_p.h deleted file mode 100644 index 2a237366d8..0000000000 --- a/src/declarative/qml/qdeclarativecomponent_p.h +++ /dev/null @@ -1,129 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QDECLARATIVECOMPONENT_P_H -#define QDECLARATIVECOMPONENT_P_H - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists purely as an -// implementation detail. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - -#include "qdeclarativecomponent.h" - -#include -#include "qdeclarativeengine_p.h" -#include "qdeclarativetypeloader_p.h" -#include -#include "qdeclarativevme_p.h" -#include "qdeclarativeerror.h" -#include "qdeclarative.h" - -#include -#include -#include - -#include - -QT_BEGIN_NAMESPACE - -class QV8Engine; - -class QDeclarativeComponent; -class QDeclarativeEngine; -class QDeclarativeCompiledData; - -class QDeclarativeComponentAttached; -class Q_DECLARATIVE_PRIVATE_EXPORT QDeclarativeComponentPrivate : public QObjectPrivate, public QDeclarativeTypeData::TypeDataCallback -{ - Q_DECLARE_PUBLIC(QDeclarativeComponent) - -public: - QDeclarativeComponentPrivate() : typeData(0), progress(0.), start(-1), cc(0), engine(0), creationContext(0) {} - - QObject *beginCreate(QDeclarativeContextData *); - void completeCreate(); - void initializeObjectWithInitialProperties(v8::Handle qmlGlobal, v8::Handle valuemap, QObject *toCreate); - - QDeclarativeTypeData *typeData; - virtual void typeDataReady(QDeclarativeTypeData *); - virtual void typeDataProgress(QDeclarativeTypeData *, qreal); - - void fromTypeData(QDeclarativeTypeData *data); - - QUrl url; - qreal progress; - - int start; - QDeclarativeCompiledData *cc; - - struct ConstructionState { - ConstructionState() : completePending(false) {} - - QDeclarativeVME vme; - QList errors; - bool completePending; - }; - ConstructionState state; - - static void beginDeferred(QDeclarativeEnginePrivate *enginePriv, QObject *object, - ConstructionState *state); - static void complete(QDeclarativeEnginePrivate *enginePriv, ConstructionState *state); - - QDeclarativeEngine *engine; - QDeclarativeGuardedContextData creationContext; - - void clear(); - - static QDeclarativeComponentPrivate *get(QDeclarativeComponent *c) { - return static_cast(QObjectPrivate::get(c)); - } -}; - -QT_END_NAMESPACE - -#endif // QDECLARATIVECOMPONENT_P_H diff --git a/src/declarative/qml/qdeclarativecomponentattached_p.h b/src/declarative/qml/qdeclarativecomponentattached_p.h deleted file mode 100644 index cd21ea1dcb..0000000000 --- a/src/declarative/qml/qdeclarativecomponentattached_p.h +++ /dev/null @@ -1,85 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QDECLARATIVECOMPONENTATTACHED_P_H -#define QDECLARATIVECOMPONENTATTACHED_P_H - -#include -#include - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - - -class Q_AUTOTEST_EXPORT QDeclarativeComponentAttached : public QObject -{ - Q_OBJECT -public: - QDeclarativeComponentAttached(QObject *parent = 0); - ~QDeclarativeComponentAttached(); - - void add(QDeclarativeComponentAttached **a) { - prev = a; next = *a; *a = this; - if (next) next->prev = &next; - } - void rem() { - if (next) next->prev = prev; - *prev = next; - next = 0; prev = 0; - } - QDeclarativeComponentAttached **prev; - QDeclarativeComponentAttached *next; - -Q_SIGNALS: - void completed(); - void destruction(); - -private: - friend class QDeclarativeVME; - friend class QDeclarativeContextData; -}; - -QT_END_NAMESPACE - -QT_END_HEADER - -#endif // QDECLARATIVECOMPONENTATTACHED_P_H diff --git a/src/declarative/qml/qdeclarativecontext.cpp b/src/declarative/qml/qdeclarativecontext.cpp deleted file mode 100644 index 102992947e..0000000000 --- a/src/declarative/qml/qdeclarativecontext.cpp +++ /dev/null @@ -1,811 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qdeclarativecontext.h" -#include "qdeclarativecontext_p.h" -#include "qdeclarativecomponentattached_p.h" - -#include "qdeclarativecomponent_p.h" -#include "qdeclarativeexpression_p.h" -#include "qdeclarativeengine_p.h" -#include "qdeclarativeengine.h" -#include "qdeclarativeinfo.h" -#include -#include - -#include -#include -#include - -QT_BEGIN_NAMESPACE - -QDeclarativeContextPrivate::QDeclarativeContextPrivate() -: data(0), notifyIndex(-1) -{ -} - -/*! - \class QDeclarativeContext - \since 4.7 - \brief The QDeclarativeContext class defines a context within a QML engine. - \mainclass - - Contexts allow data to be exposed to the QML components instantiated by the - QML engine. - - Each QDeclarativeContext contains a set of properties, distinct from its QObject - properties, that allow data to be explicitly bound to a context by name. The - context properties are defined and updated by calling - QDeclarativeContext::setContextProperty(). The following example shows a Qt model - being bound to a context and then accessed from a QML file. - - \code - QDeclarativeEngine engine; - QStringListModel modelData; - QDeclarativeContext *context = new QDeclarativeContext(engine.rootContext()); - context->setContextProperty("myModel", &modelData); - - QDeclarativeComponent component(&engine); - component.setData("import QtQuick 2.0\nListView { model: myModel }", QUrl()); - QObject *window = component.create(context); - \endcode - - Note it is the responsibility of the creator to delete any QDeclarativeContext it - constructs. If the \c context object in the example is no longer needed when the - \c window component instance is destroyed, the \c context must be destroyed explicitly. - The simplest way to ensure this is to set \c window as the parent of \c context. - - To simplify binding and maintaining larger data sets, a context object can be set - on a QDeclarativeContext. All the properties of the context object are available - by name in the context, as though they were all individually added through calls - to QDeclarativeContext::setContextProperty(). Changes to the property's values are - detected through the property's notify signal. Setting a context object is both - faster and easier than manually adding and maintaing context property values. - - The following example has the same effect as the previous one, but it uses a context - object. - - \code - class MyDataSet : ... { - ... - Q_PROPERTY(QAbstractItemModel *myModel READ model NOTIFY modelChanged) - ... - }; - - MyDataSet myDataSet; - QDeclarativeEngine engine; - QDeclarativeContext *context = new QDeclarativeContext(engine.rootContext()); - context->setContextObject(&myDataSet); - - QDeclarativeComponent component(&engine); - component.setData("import QtQuick 2.0\nListView { model: myModel }", QUrl()); - component.create(context); - \endcode - - All properties added explicitly by QDeclarativeContext::setContextProperty() take - precedence over the context object's properties. - - \section2 The Context Hierarchy - - Contexts form a hierarchy. The root of this hierarchy is the QML engine's - \l {QDeclarativeEngine::rootContext()}{root context}. Child contexts inherit - the context properties of their parents; if a child context sets a context property - that already exists in its parent, the new context property overrides that of the - parent. - - The following example defines two contexts - \c context1 and \c context2. The - second context overrides the "b" context property inherited from the first with a - new value. - - \code - QDeclarativeEngine engine; - QDeclarativeContext *context1 = new QDeclarativeContext(engine.rootContext()); - QDeclarativeContext *context2 = new QDeclarativeContext(context1); - - context1->setContextProperty("a", 12); - context1->setContextProperty("b", 12); - - context2->setContextProperty("b", 15); - \endcode - - While QML objects instantiated in a context are not strictly owned by that - context, their bindings are. If a context is destroyed, the property bindings of - outstanding QML objects will stop evaluating. - - \warning Setting the context object or adding new context properties after an object - has been created in that context is an expensive operation (essentially forcing all bindings - to reevaluate). Thus whenever possible you should complete "setup" of the context - before using it to create any objects. - - \sa {Using QML Bindings in C++ Applications} -*/ - -/*! \internal */ -QDeclarativeContext::QDeclarativeContext(QDeclarativeEngine *e, bool) -: QObject(*(new QDeclarativeContextPrivate)) -{ - Q_D(QDeclarativeContext); - d->data = new QDeclarativeContextData(this); - - d->data->engine = e; -} - -/*! - Create a new QDeclarativeContext as a child of \a engine's root context, and the - QObject \a parent. -*/ -QDeclarativeContext::QDeclarativeContext(QDeclarativeEngine *engine, QObject *parent) -: QObject(*(new QDeclarativeContextPrivate), parent) -{ - Q_D(QDeclarativeContext); - d->data = new QDeclarativeContextData(this); - - d->data->setParent(engine?QDeclarativeContextData::get(engine->rootContext()):0); -} - -/*! - Create a new QDeclarativeContext with the given \a parentContext, and the - QObject \a parent. -*/ -QDeclarativeContext::QDeclarativeContext(QDeclarativeContext *parentContext, QObject *parent) -: QObject(*(new QDeclarativeContextPrivate), parent) -{ - Q_D(QDeclarativeContext); - d->data = new QDeclarativeContextData(this); - - d->data->setParent(parentContext?QDeclarativeContextData::get(parentContext):0); -} - -/*! - \internal -*/ -QDeclarativeContext::QDeclarativeContext(QDeclarativeContextData *data) -: QObject(*(new QDeclarativeContextPrivate), 0) -{ - Q_D(QDeclarativeContext); - d->data = data; -} - -/*! - Destroys the QDeclarativeContext. - - Any expressions, or sub-contexts dependent on this context will be - invalidated, but not destroyed (unless they are parented to the QDeclarativeContext - object). - */ -QDeclarativeContext::~QDeclarativeContext() -{ - Q_D(QDeclarativeContext); - - if (!d->data->isInternal) - d->data->destroy(); -} - -/*! - Returns whether the context is valid. - - To be valid, a context must have a engine, and it's contextObject(), if any, - must not have been deleted. -*/ -bool QDeclarativeContext::isValid() const -{ - Q_D(const QDeclarativeContext); - return d->data && d->data->isValid(); -} - -/*! - Return the context's QDeclarativeEngine, or 0 if the context has no QDeclarativeEngine or the - QDeclarativeEngine was destroyed. -*/ -QDeclarativeEngine *QDeclarativeContext::engine() const -{ - Q_D(const QDeclarativeContext); - return d->data->engine; -} - -/*! - Return the context's parent QDeclarativeContext, or 0 if this context has no - parent or if the parent has been destroyed. -*/ -QDeclarativeContext *QDeclarativeContext::parentContext() const -{ - Q_D(const QDeclarativeContext); - return d->data->parent?d->data->parent->asQDeclarativeContext():0; -} - -/*! - Return the context object, or 0 if there is no context object. -*/ -QObject *QDeclarativeContext::contextObject() const -{ - Q_D(const QDeclarativeContext); - return d->data->contextObject; -} - -/*! - Set the context \a object. -*/ -void QDeclarativeContext::setContextObject(QObject *object) -{ - Q_D(QDeclarativeContext); - - QDeclarativeContextData *data = d->data; - - if (data->isInternal) { - qWarning("QDeclarativeContext: Cannot set context object for internal context."); - return; - } - - if (!isValid()) { - qWarning("QDeclarativeContext: Cannot set context object on invalid context."); - return; - } - - data->contextObject = object; -} - -/*! - Set a the \a value of the \a name property on this context. -*/ -void QDeclarativeContext::setContextProperty(const QString &name, const QVariant &value) -{ - Q_D(QDeclarativeContext); - if (d->notifyIndex == -1) - d->notifyIndex = this->metaObject()->methodCount(); - - QDeclarativeContextData *data = d->data; - - if (data->isInternal) { - qWarning("QDeclarativeContext: Cannot set property on internal context."); - return; - } - - if (!isValid()) { - qWarning("QDeclarativeContext: Cannot set property on invalid context."); - return; - } - - if (data->engine) { - bool ok; - QObject *o = QDeclarativeEnginePrivate::get(data->engine)->toQObject(value, &ok); - if (ok) { - setContextProperty(name, o); - return; - } - } - - if (!data->propertyNames) data->propertyNames = new QDeclarativeIntegerCache(); - - int idx = data->propertyNames->value(name); - if (idx == -1) { - data->propertyNames->add(name, data->idValueCount + d->propertyValues.count()); - d->propertyValues.append(value); - - data->refreshExpressions(); - } else { - d->propertyValues[idx] = value; - QMetaObject::activate(this, idx + d->notifyIndex, 0); - } -} - -/*! - Set the \a value of the \a name property on this context. - - QDeclarativeContext does \bold not take ownership of \a value. -*/ -void QDeclarativeContext::setContextProperty(const QString &name, QObject *value) -{ - Q_D(QDeclarativeContext); - if (d->notifyIndex == -1) - d->notifyIndex = this->metaObject()->methodCount(); - - QDeclarativeContextData *data = d->data; - - if (data->isInternal) { - qWarning("QDeclarativeContext: Cannot set property on internal context."); - return; - } - - if (!isValid()) { - qWarning("QDeclarativeContext: Cannot set property on invalid context."); - return; - } - - if (!data->propertyNames) data->propertyNames = new QDeclarativeIntegerCache(); - int idx = data->propertyNames->value(name); - - if (idx == -1) { - data->propertyNames->add(name, data->idValueCount + d->propertyValues.count()); - d->propertyValues.append(QVariant::fromValue(value)); - - data->refreshExpressions(); - } else { - d->propertyValues[idx] = QVariant::fromValue(value); - QMetaObject::activate(this, idx + d->notifyIndex, 0); - } -} - -/*! - Returns the value of the \a name property for this context - as a QVariant. - */ -QVariant QDeclarativeContext::contextProperty(const QString &name) const -{ - Q_D(const QDeclarativeContext); - QVariant value; - int idx = -1; - - QDeclarativeContextData *data = d->data; - - if (data->propertyNames) - idx = data->propertyNames->value(name); - - if (idx == -1) { - QByteArray utf8Name = name.toUtf8(); - if (data->contextObject) { - QObject *obj = data->contextObject; - QDeclarativePropertyData local; - QDeclarativePropertyData *property = - QDeclarativePropertyCache::property(data->engine, obj, name, local); - - if (property) value = obj->metaObject()->property(property->coreIndex).read(obj); - } - if (!value.isValid() && parentContext()) - value = parentContext()->contextProperty(name); - } else { - if (idx >= d->propertyValues.count()) - value = QVariant::fromValue(data->idValues[idx - d->propertyValues.count()].data()); - else - value = d->propertyValues[idx]; - } - - return value; -} - -/*! -Returns the name of \a object in this context, or an empty string if \a object -is not named in the context. Objects are named by setContextProperty(), or by ids in -the case of QML created contexts. - -If the object has multiple names, the first is returned. -*/ -QString QDeclarativeContext::nameForObject(QObject *object) const -{ - Q_D(const QDeclarativeContext); - - return d->data->findObjectId(object); -} - -/*! - Resolves the URL \a src relative to the URL of the - containing component. - - \sa QDeclarativeEngine::baseUrl(), setBaseUrl() -*/ -QUrl QDeclarativeContext::resolvedUrl(const QUrl &src) -{ - Q_D(QDeclarativeContext); - return d->data->resolvedUrl(src); -} - -QUrl QDeclarativeContextData::resolvedUrl(const QUrl &src) -{ - QDeclarativeContextData *ctxt = this; - - if (src.isRelative() && !src.isEmpty()) { - if (ctxt) { - while(ctxt) { - if(ctxt->url.isValid()) - break; - else - ctxt = ctxt->parent; - } - - if (ctxt) - return ctxt->url.resolved(src); - else if (engine) - return engine->baseUrl().resolved(src); - } - return QUrl(); - } else { - return src; - } -} - - -/*! - Explicitly sets the url resolvedUrl() will use for relative references to \a baseUrl. - - Calling this function will override the url of the containing - component used by default. - - \sa resolvedUrl() -*/ -void QDeclarativeContext::setBaseUrl(const QUrl &baseUrl) -{ - Q_D(QDeclarativeContext); - - d->data->url = baseUrl; - d->data->urlString = baseUrl.toString(); -} - -/*! - Returns the base url of the component, or the containing component - if none is set. -*/ -QUrl QDeclarativeContext::baseUrl() const -{ - Q_D(const QDeclarativeContext); - const QDeclarativeContextData* data = d->data; - while (data && data->url.isEmpty()) - data = data->parent; - - if (data) - return data->url; - else - return QUrl(); -} - -int QDeclarativeContextPrivate::context_count(QDeclarativeListProperty *prop) -{ - QDeclarativeContext *context = static_cast(prop->object); - QDeclarativeContextPrivate *d = QDeclarativeContextPrivate::get(context); - int contextProperty = (int)(quintptr)prop->data; - - if (d->propertyValues.at(contextProperty).userType() != qMetaTypeId >()) { - return 0; - } else { - return ((const QList *)d->propertyValues.at(contextProperty).constData())->count(); - } -} - -QObject *QDeclarativeContextPrivate::context_at(QDeclarativeListProperty *prop, int index) -{ - QDeclarativeContext *context = static_cast(prop->object); - QDeclarativeContextPrivate *d = QDeclarativeContextPrivate::get(context); - int contextProperty = (int)(quintptr)prop->data; - - if (d->propertyValues.at(contextProperty).userType() != qMetaTypeId >()) { - return 0; - } else { - return ((const QList *)d->propertyValues.at(contextProperty).constData())->at(index); - } -} - - -QDeclarativeContextData::QDeclarativeContextData() -: parent(0), engine(0), isInternal(false), ownedByParent(false), isJSContext(false), - isPragmaLibraryContext(false), unresolvedNames(false), publicContext(0), activeVMEData(0), - propertyNames(0), contextObject(0), imports(0), childContexts(0), nextChild(0), prevChild(0), - expressions(0), contextObjects(0), contextGuards(0), idValues(0), idValueCount(0), linkedContext(0), - componentAttached(0), v4bindings(0), v8bindings(0) -{ -} - -QDeclarativeContextData::QDeclarativeContextData(QDeclarativeContext *ctxt) -: parent(0), engine(0), isInternal(false), ownedByParent(false), isJSContext(false), - isPragmaLibraryContext(false), unresolvedNames(false), publicContext(ctxt), activeVMEData(0), - propertyNames(0), contextObject(0), imports(0), childContexts(0), nextChild(0), prevChild(0), - expressions(0), contextObjects(0), contextGuards(0), idValues(0), idValueCount(0), linkedContext(0), - componentAttached(0), v4bindings(0), v8bindings(0) -{ -} - -void QDeclarativeContextData::invalidate() -{ - while (componentAttached) { - QDeclarativeComponentAttached *a = componentAttached; - componentAttached = a->next; - if (componentAttached) componentAttached->prev = &componentAttached; - - a->next = 0; - a->prev = 0; - - emit a->destruction(); - } - - while (childContexts) { - if (childContexts->ownedByParent) { - childContexts->destroy(); - } else { - childContexts->invalidate(); - } - } - - if (prevChild) { - *prevChild = nextChild; - if (nextChild) nextChild->prevChild = prevChild; - nextChild = 0; - prevChild = 0; - } - - engine = 0; - parent = 0; -} - -void QDeclarativeContextData::clearContext() -{ - if (engine) { - while (componentAttached) { - QDeclarativeComponentAttached *a = componentAttached; - componentAttached = a->next; - if (componentAttached) componentAttached->prev = &componentAttached; - - a->next = 0; - a->prev = 0; - - emit a->destruction(); - } - } - - QDeclarativeAbstractExpression *expression = expressions; - while (expression) { - QDeclarativeAbstractExpression *nextExpression = expression->m_nextExpression; - - expression->m_prevExpression = 0; - expression->m_nextExpression = 0; - - expression->setContext(0); - - expression = nextExpression; - } - expressions = 0; -} - -void QDeclarativeContextData::destroy() -{ - if (linkedContext) - linkedContext->destroy(); - - if (engine) invalidate(); - - clearContext(); - - while (contextObjects) { - QDeclarativeData *co = contextObjects; - contextObjects = contextObjects->nextContextObject; - - co->context = 0; - co->outerContext = 0; - co->nextContextObject = 0; - co->prevContextObject = 0; - } - - QDeclarativeGuardedContextData *contextGuard = contextGuards; - while (contextGuard) { - QDeclarativeGuardedContextData *next = contextGuard->m_next; - contextGuard->m_next = 0; - contextGuard->m_prev = 0; - contextGuard->m_contextData = 0; - contextGuard = next; - } - contextGuards = 0; - - if (propertyNames) - propertyNames->release(); - - if (imports) - imports->release(); - - if (v4bindings) - v4bindings->release(); - - if (v8bindings) - v8bindings->release(); - - for (int ii = 0; ii < importedScripts.count(); ++ii) { - qPersistentDispose(importedScripts[ii]); - } - - delete [] idValues; - - if (isInternal) - delete publicContext; - - delete this; -} - -void QDeclarativeContextData::setParent(QDeclarativeContextData *p, bool parentTakesOwnership) -{ - if (p) { - parent = p; - engine = p->engine; - nextChild = p->childContexts; - if (nextChild) nextChild->prevChild = &nextChild; - prevChild = &p->childContexts; - p->childContexts = this; - ownedByParent = parentTakesOwnership; - } -} - -void QDeclarativeContextData::refreshExpressionsRecursive(QDeclarativeAbstractExpression *expression) -{ - QDeclarativeAbstractExpression::DeleteWatcher w(expression); - - if (expression->m_nextExpression) - refreshExpressionsRecursive(expression->m_nextExpression); - - if (!w.wasDeleted()) - expression->refresh(); -} - -static inline bool expressions_to_run(QDeclarativeContextData *ctxt, bool isGlobalRefresh) -{ - return ctxt->expressions && (!isGlobalRefresh || ctxt->unresolvedNames); -} - -void QDeclarativeContextData::refreshExpressionsRecursive(bool isGlobal) -{ - // For efficiency, we try and minimize the number of guards we have to create - if (expressions_to_run(this, isGlobal) && (nextChild || childContexts)) { - QDeclarativeGuardedContextData guard(this); - - if (childContexts) - childContexts->refreshExpressionsRecursive(isGlobal); - - if (guard.isNull()) return; - - if (nextChild) - nextChild->refreshExpressionsRecursive(isGlobal); - - if (guard.isNull()) return; - - if (expressions_to_run(this, isGlobal)) - refreshExpressionsRecursive(expressions); - - } else if (expressions_to_run(this, isGlobal)) { - - refreshExpressionsRecursive(expressions); - - } else if (nextChild && childContexts) { - - QDeclarativeGuardedContextData guard(this); - - childContexts->refreshExpressionsRecursive(isGlobal); - - if (!guard.isNull() && nextChild) - nextChild->refreshExpressionsRecursive(isGlobal); - - } else if (nextChild) { - - nextChild->refreshExpressionsRecursive(isGlobal); - - } else if (childContexts) { - - childContexts->refreshExpressionsRecursive(isGlobal); - - } -} - -// Refreshes all expressions that could possibly depend on this context. Refreshing flushes all -// context-tree dependent caches in the expressions, and should occur every time the context tree -// *structure* (not values) changes. -void QDeclarativeContextData::refreshExpressions() -{ - bool isGlobal = (parent == 0); - - // For efficiency, we try and minimize the number of guards we have to create - if (expressions_to_run(this, isGlobal) && childContexts) { - QDeclarativeGuardedContextData guard(this); - - childContexts->refreshExpressionsRecursive(isGlobal); - - if (!guard.isNull() && expressions_to_run(this, isGlobal)) - refreshExpressionsRecursive(expressions); - - } else if (expressions_to_run(this, isGlobal)) { - - refreshExpressionsRecursive(expressions); - - } else if (childContexts) { - - childContexts->refreshExpressionsRecursive(isGlobal); - - } -} - -void QDeclarativeContextData::addObject(QObject *o) -{ - QDeclarativeData *data = QDeclarativeData::get(o, true); - - Q_ASSERT(data->context == 0); - - data->context = this; - data->outerContext = this; - - data->nextContextObject = contextObjects; - if (data->nextContextObject) - data->nextContextObject->prevContextObject = &data->nextContextObject; - data->prevContextObject = &contextObjects; - contextObjects = data; -} - -void QDeclarativeContextData::setIdProperty(int idx, QObject *obj) -{ - idValues[idx] = obj; - idValues[idx].context = this; -} - -void QDeclarativeContextData::setIdPropertyData(QDeclarativeIntegerCache *data) -{ - Q_ASSERT(!propertyNames); - propertyNames = data; - propertyNames->addref(); - - idValueCount = data->count(); - idValues = new ContextGuard[idValueCount]; -} - -QString QDeclarativeContextData::findObjectId(const QObject *obj) const -{ - if (!propertyNames) - return QString(); - - for (int ii = 0; ii < idValueCount; ii++) { - if (idValues[ii] == obj) - return propertyNames->findId(ii); - } - - if (publicContext) { - QDeclarativeContextPrivate *p = QDeclarativeContextPrivate::get(publicContext); - for (int ii = 0; ii < p->propertyValues.count(); ++ii) - if (p->propertyValues.at(ii) == QVariant::fromValue((QObject *)obj)) - return propertyNames->findId(ii); - } - - if (linkedContext) - return linkedContext->findObjectId(obj); - return QString(); -} - -QDeclarativeContext *QDeclarativeContextData::asQDeclarativeContext() -{ - if (!publicContext) - publicContext = new QDeclarativeContext(this); - return publicContext; -} - -QDeclarativeContextPrivate *QDeclarativeContextData::asQDeclarativeContextPrivate() -{ - return QDeclarativeContextPrivate::get(asQDeclarativeContext()); -} - -QT_END_NAMESPACE diff --git a/src/declarative/qml/qdeclarativecontext.h b/src/declarative/qml/qdeclarativecontext.h deleted file mode 100644 index b1a8362a3b..0000000000 --- a/src/declarative/qml/qdeclarativecontext.h +++ /dev/null @@ -1,113 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QDECLARATIVECONTEXT_H -#define QDECLARATIVECONTEXT_H - -#include -#include -#include -#include -#include - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - - -class QString; -class QDeclarativeEngine; -class QDeclarativeRefCount; -class QDeclarativeContextPrivate; -class QDeclarativeCompositeTypeData; -class QDeclarativeContextData; - -class Q_DECLARATIVE_EXPORT QDeclarativeContext : public QObject -{ - Q_OBJECT - Q_DECLARE_PRIVATE(QDeclarativeContext) - -public: - QDeclarativeContext(QDeclarativeEngine *parent, QObject *objParent=0); - QDeclarativeContext(QDeclarativeContext *parent, QObject *objParent=0); - virtual ~QDeclarativeContext(); - - bool isValid() const; - - QDeclarativeEngine *engine() const; - QDeclarativeContext *parentContext() const; - - QObject *contextObject() const; - void setContextObject(QObject *); - - QVariant contextProperty(const QString &) const; - void setContextProperty(const QString &, QObject *); - void setContextProperty(const QString &, const QVariant &); - - QString nameForObject(QObject *) const; - - QUrl resolvedUrl(const QUrl &); - - void setBaseUrl(const QUrl &); - QUrl baseUrl() const; - -private: - friend class QDeclarativeVME; - friend class QDeclarativeEngine; - friend class QDeclarativeEnginePrivate; - friend class QDeclarativeExpression; - friend class QDeclarativeExpressionPrivate; - friend class QDeclarativeComponent; - friend class QDeclarativeComponentPrivate; - friend class QDeclarativeScriptPrivate; - friend class QDeclarativeBoundSignalProxy; - friend class QDeclarativeContextData; - QDeclarativeContext(QDeclarativeContextData *); - QDeclarativeContext(QDeclarativeEngine *, bool); - Q_DISABLE_COPY(QDeclarativeContext) -}; -QT_END_NAMESPACE - -Q_DECLARE_METATYPE(QList) - -QT_END_HEADER - -#endif // QDECLARATIVECONTEXT_H diff --git a/src/declarative/qml/qdeclarativecontext_p.h b/src/declarative/qml/qdeclarativecontext_p.h deleted file mode 100644 index c53fc9cc21..0000000000 --- a/src/declarative/qml/qdeclarativecontext_p.h +++ /dev/null @@ -1,334 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QDECLARATIVECONTEXT_P_H -#define QDECLARATIVECONTEXT_P_H - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists purely as an -// implementation detail. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - -#include "qdeclarativecontext.h" - -#include "qdeclarativedata_p.h" -#include "qdeclarativeintegercache_p.h" -#include "qdeclarativetypenamecache_p.h" -#include "qdeclarativenotifier_p.h" -#include "qdeclarativelist.h" -#include "qdeclarativescript_p.h" - -#include -#include -#include - -#include -#include -#include - -#include - - -QT_BEGIN_NAMESPACE - -class QV8Bindings; -class QDeclarativeContext; -class QDeclarativeExpression; -class QDeclarativeEngine; -class QDeclarativeExpression; -class QDeclarativeExpressionPrivate; -class QDeclarativeAbstractExpression; -class QV4Bindings; -class QDeclarativeContextData; - -class QDeclarativeContextPrivate : public QObjectPrivate -{ - Q_DECLARE_PUBLIC(QDeclarativeContext) -public: - QDeclarativeContextPrivate(); - - QDeclarativeContextData *data; - - QList propertyValues; - int notifyIndex; - - static QDeclarativeContextPrivate *get(QDeclarativeContext *context) { - return static_cast(QObjectPrivate::get(context)); - } - static QDeclarativeContext *get(QDeclarativeContextPrivate *context) { - return static_cast(context->q_func()); - } - - // Only used for debugging - QList > instances; - - static int context_count(QDeclarativeListProperty *); - static QObject *context_at(QDeclarativeListProperty *, int); -}; - -class QDeclarativeVME; -class QDeclarativeComponentAttached; -class QDeclarativeGuardedContextData; -class Q_DECLARATIVE_EXPORT QDeclarativeContextData -{ -public: - QDeclarativeContextData(); - QDeclarativeContextData(QDeclarativeContext *); - void clearContext(); - void destroy(); - void invalidate(); - - inline bool isValid() const { - return engine && (!isInternal || !contextObject || !QObjectPrivate::get(contextObject)->wasDeleted); - } - - // My parent context and engine - QDeclarativeContextData *parent; - QDeclarativeEngine *engine; - - void setParent(QDeclarativeContextData *, bool parentTakesOwnership = false); - void refreshExpressions(); - - void addObject(QObject *); - - QUrl resolvedUrl(const QUrl &); - - // My containing QDeclarativeContext. If isInternal is true this owns publicContext. - // If internal is false publicContext owns this. - QDeclarativeContext *asQDeclarativeContext(); - QDeclarativeContextPrivate *asQDeclarativeContextPrivate(); - quint32 isInternal:1; - quint32 ownedByParent:1; // unrelated to isInternal; parent context deletes children if true. - quint32 isJSContext:1; - quint32 isPragmaLibraryContext:1; - quint32 unresolvedNames:1; // True if expressions in this context failed to resolve a toplevel name - quint32 dummy:28; - QDeclarativeContext *publicContext; - - // VME data that is constructing this context if any - void *activeVMEData; - - // Property name cache - QDeclarativeIntegerCache *propertyNames; - - // Context object - QObject *contextObject; - - // Any script blocks that exist on this context - QList > importedScripts; - - // Context base url - QUrl url; - QString urlString; - - // List of imports that apply to this context - QDeclarativeTypeNameCache *imports; - - // My children - QDeclarativeContextData *childContexts; - - // My peers in parent's childContexts list - QDeclarativeContextData *nextChild; - QDeclarativeContextData **prevChild; - - // Expressions that use this context - QDeclarativeAbstractExpression *expressions; - - // Doubly-linked list of objects that are owned by this context - QDeclarativeData *contextObjects; - - // Doubly-linked list of context guards (XXX merge with contextObjects) - QDeclarativeGuardedContextData *contextGuards; - - // id guards - struct ContextGuard : public QDeclarativeGuard - { - inline ContextGuard(); - inline ContextGuard &operator=(QObject *obj); - inline void objectDestroyed(QObject *); - - inline bool wasSet() const; - - QFlagPointer context; - QDeclarativeNotifier bindings; - }; - ContextGuard *idValues; - int idValueCount; - void setIdProperty(int, QObject *); - void setIdPropertyData(QDeclarativeIntegerCache *); - - // Linked contexts. this owns linkedContext. - QDeclarativeContextData *linkedContext; - - // Linked list of uses of the Component attached property in this - // context - QDeclarativeComponentAttached *componentAttached; - - // Optimized binding objects. Needed for deferred properties. - QV4Bindings *v4bindings; - QV8Bindings *v8bindings; - - // Return the outermost id for obj, if any. - QString findObjectId(const QObject *obj) const; - - static QDeclarativeContextData *get(QDeclarativeContext *context) { - return QDeclarativeContextPrivate::get(context)->data; - } - -private: - void refreshExpressionsRecursive(bool isGlobal); - void refreshExpressionsRecursive(QDeclarativeAbstractExpression *); - ~QDeclarativeContextData() {} -}; - -class QDeclarativeGuardedContextData -{ -public: - inline QDeclarativeGuardedContextData(); - inline QDeclarativeGuardedContextData(QDeclarativeContextData *); - inline ~QDeclarativeGuardedContextData(); - - inline QDeclarativeContextData *contextData(); - inline void setContextData(QDeclarativeContextData *); - - inline bool isNull() const { return !m_contextData; } - - inline operator QDeclarativeContextData*() const { return m_contextData; } - inline QDeclarativeContextData* operator->() const { return m_contextData; } - inline QDeclarativeGuardedContextData &operator=(QDeclarativeContextData *d); - -private: - QDeclarativeGuardedContextData &operator=(const QDeclarativeGuardedContextData &); - QDeclarativeGuardedContextData(const QDeclarativeGuardedContextData &); - friend class QDeclarativeContextData; - - inline void clear(); - - QDeclarativeContextData *m_contextData; - QDeclarativeGuardedContextData *m_next; - QDeclarativeGuardedContextData **m_prev; -}; - -QDeclarativeGuardedContextData::QDeclarativeGuardedContextData() -: m_contextData(0), m_next(0), m_prev(0) -{ -} - -QDeclarativeGuardedContextData::QDeclarativeGuardedContextData(QDeclarativeContextData *data) -: m_contextData(0), m_next(0), m_prev(0) -{ - setContextData(data); -} - -QDeclarativeGuardedContextData::~QDeclarativeGuardedContextData() -{ - clear(); -} - -void QDeclarativeGuardedContextData::setContextData(QDeclarativeContextData *contextData) -{ - clear(); - - if (contextData) { - m_contextData = contextData; - m_next = contextData->contextGuards; - if (m_next) m_next->m_prev = &m_next; - m_prev = &contextData->contextGuards; - contextData->contextGuards = this; - } -} - -QDeclarativeContextData *QDeclarativeGuardedContextData::contextData() -{ - return m_contextData; -} - -void QDeclarativeGuardedContextData::clear() -{ - if (m_prev) { - *m_prev = m_next; - if (m_next) m_next->m_prev = m_prev; - m_contextData = 0; - m_next = 0; - m_prev = 0; - } -} - -QDeclarativeGuardedContextData & -QDeclarativeGuardedContextData::operator=(QDeclarativeContextData *d) -{ - setContextData(d); - return *this; -} - -QDeclarativeContextData::ContextGuard::ContextGuard() -: context(0) -{ -} - -QDeclarativeContextData::ContextGuard &QDeclarativeContextData::ContextGuard::operator=(QObject *obj) -{ - QDeclarativeGuard::operator=(obj); - context.setFlag(); - bindings.notify(); // For alias connections - return *this; -} - -void QDeclarativeContextData::ContextGuard::objectDestroyed(QObject *) -{ - if (context->contextObject && !QObjectPrivate::get(context->contextObject)->wasDeleted) - bindings.notify(); -} - -bool QDeclarativeContextData::ContextGuard::wasSet() const -{ - return context.flag(); -} - -QT_END_NAMESPACE - -#endif // QDECLARATIVECONTEXT_P_H diff --git a/src/declarative/qml/qdeclarativecustomparser.cpp b/src/declarative/qml/qdeclarativecustomparser.cpp deleted file mode 100644 index a746700aa6..0000000000 --- a/src/declarative/qml/qdeclarativecustomparser.cpp +++ /dev/null @@ -1,319 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qdeclarativecustomparser_p.h" -#include "qdeclarativecustomparser_p_p.h" - -#include "qdeclarativecompiler_p.h" - -#include - -QT_BEGIN_NAMESPACE - -using namespace QDeclarativeScript; - -/*! - \class QDeclarativeCustomParser - \brief The QDeclarativeCustomParser class allows you to add new arbitrary types to QML. - \internal - - By subclassing QDeclarativeCustomParser, you can add a parser for - building a particular type. - - The subclass must implement compile() and setCustomData(), and register - itself in the meta type system by calling the macro: - - \code - QML_REGISTER_CUSTOM_TYPE(Module, MajorVersion, MinorVersion, Name, TypeClass, ParserClass) - \endcode -*/ - -/* - \fn QByteArray QDeclarativeCustomParser::compile(const QList & properties) - - The custom parser processes \a properties, and returns - a QByteArray containing data meaningful only to the - custom parser; the type engine will pass this same data to - setCustomData() when making an instance of the data. - - Errors must be reported via the error() functions. - - The QByteArray may be cached between executions of the system, so - it must contain correctly-serialized data (not, for example, - pointers to stack objects). -*/ - -/* - \fn void QDeclarativeCustomParser::setCustomData(QObject *object, const QByteArray &data) - - This function sets \a object to have the properties defined - by \a data, which is a block of data previously returned by a call - to compile(). - - Errors should be reported using qmlInfo(object). - - The \a object will be an instance of the TypeClass specified by QML_REGISTER_CUSTOM_TYPE. -*/ - -QDeclarativeCustomParserNode -QDeclarativeCustomParserNodePrivate::fromObject(QDeclarativeScript::Object *root) -{ - QDeclarativeCustomParserNode rootNode; - rootNode.d->name = root->typeName; - rootNode.d->location = root->location.start; - - for (Property *p = root->properties.first(); p; p = root->properties.next(p)) { - rootNode.d->properties << fromProperty(p); - } - - if (root->defaultProperty) - rootNode.d->properties << fromProperty(root->defaultProperty); - - return rootNode; -} - -QDeclarativeCustomParserProperty -QDeclarativeCustomParserNodePrivate::fromProperty(QDeclarativeScript::Property *p) -{ - QDeclarativeCustomParserProperty prop; - prop.d->name = p->name().toString(); - prop.d->isList = p->values.isMany(); - prop.d->location = p->location.start; - - if (p->value) { - QDeclarativeCustomParserNode node = fromObject(p->value); - QList props = node.properties(); - for (int ii = 0; ii < props.count(); ++ii) - prop.d->values << QVariant::fromValue(props.at(ii)); - } else { - for (QDeclarativeScript::Value *v = p->values.first(); v; v = p->values.next(v)) { - v->type = QDeclarativeScript::Value::Literal; - - if(v->object) { - QDeclarativeCustomParserNode node = fromObject(v->object); - prop.d->values << QVariant::fromValue(node); - } else { - prop.d->values << QVariant::fromValue(v->value); - } - - } - } - - return prop; -} - -QDeclarativeCustomParserNode::QDeclarativeCustomParserNode() -: d(new QDeclarativeCustomParserNodePrivate) -{ -} - -QDeclarativeCustomParserNode::QDeclarativeCustomParserNode(const QDeclarativeCustomParserNode &other) -: d(new QDeclarativeCustomParserNodePrivate) -{ - *this = other; -} - -QDeclarativeCustomParserNode &QDeclarativeCustomParserNode::operator=(const QDeclarativeCustomParserNode &other) -{ - d->name = other.d->name; - d->properties = other.d->properties; - d->location = other.d->location; - return *this; -} - -QDeclarativeCustomParserNode::~QDeclarativeCustomParserNode() -{ - delete d; d = 0; -} - -QString QDeclarativeCustomParserNode::name() const -{ - return d->name; -} - -QList QDeclarativeCustomParserNode::properties() const -{ - return d->properties; -} - -QDeclarativeScript::Location QDeclarativeCustomParserNode::location() const -{ - return d->location; -} - -QDeclarativeCustomParserProperty::QDeclarativeCustomParserProperty() -: d(new QDeclarativeCustomParserPropertyPrivate) -{ -} - -QDeclarativeCustomParserProperty::QDeclarativeCustomParserProperty(const QDeclarativeCustomParserProperty &other) -: d(new QDeclarativeCustomParserPropertyPrivate) -{ - *this = other; -} - -QDeclarativeCustomParserProperty &QDeclarativeCustomParserProperty::operator=(const QDeclarativeCustomParserProperty &other) -{ - d->name = other.d->name; - d->isList = other.d->isList; - d->values = other.d->values; - d->location = other.d->location; - return *this; -} - -QDeclarativeCustomParserProperty::~QDeclarativeCustomParserProperty() -{ - delete d; d = 0; -} - -QString QDeclarativeCustomParserProperty::name() const -{ - return d->name; -} - -bool QDeclarativeCustomParserProperty::isList() const -{ - return d->isList; -} - -QDeclarativeScript::Location QDeclarativeCustomParserProperty::location() const -{ - return d->location; -} - -QList QDeclarativeCustomParserProperty::assignedValues() const -{ - return d->values; -} - -void QDeclarativeCustomParser::clearErrors() -{ - exceptions.clear(); -} - -/*! - Reports an error with the given \a description. - - This can only be used during the compile() step. For errors during setCustomData(), use qmlInfo(). - - An error is generated referring to the position of the element in the source file. -*/ -void QDeclarativeCustomParser::error(const QString& description) -{ - Q_ASSERT(object); - QDeclarativeError error; - QString exceptionDescription; - error.setLine(object->location.start.line); - error.setColumn(object->location.start.column); - error.setDescription(description); - exceptions << error; -} - -/*! - Reports an error in parsing \a prop, with the given \a description. - - An error is generated referring to the position of \a node in the source file. -*/ -void QDeclarativeCustomParser::error(const QDeclarativeCustomParserProperty& prop, const QString& description) -{ - QDeclarativeError error; - QString exceptionDescription; - error.setLine(prop.location().line); - error.setColumn(prop.location().column); - error.setDescription(description); - exceptions << error; -} - -/*! - Reports an error in parsing \a node, with the given \a description. - - An error is generated referring to the position of \a node in the source file. -*/ -void QDeclarativeCustomParser::error(const QDeclarativeCustomParserNode& node, const QString& description) -{ - QDeclarativeError error; - QString exceptionDescription; - error.setLine(node.location().line); - error.setColumn(node.location().column); - error.setDescription(description); - exceptions << error; -} - -/*! - If \a script is a simply enum expression (eg. Text.AlignLeft), - returns the integer equivalent (eg. 1). - - Otherwise, returns -1. -*/ -int QDeclarativeCustomParser::evaluateEnum(const QByteArray& script) const -{ - return compiler->evaluateEnum(script); -} - -/*! - Resolves \a name to a type, or 0 if it is not a type. This can be used - to type-check object nodes. -*/ -const QMetaObject *QDeclarativeCustomParser::resolveType(const QString& name) const -{ - return compiler->resolveType(name); -} - -/*! - Rewrites \a value and returns an identifier that can be - used to construct the binding later. \a name - is used as the name of the rewritten function. -*/ -QDeclarativeBinding::Identifier QDeclarativeCustomParser::rewriteBinding(const QDeclarativeScript::Variant &value, const QString& name) -{ - return compiler->rewriteBinding(value, name); -} - -/*! - Returns a rewritten \a handler. \a name - is used as the name of the rewritten function. -*/ -QString QDeclarativeCustomParser::rewriteSignalHandler(const QDeclarativeScript::Variant &value, const QString &name) -{ - return compiler->rewriteSignalHandler(value , name); -} - -QT_END_NAMESPACE diff --git a/src/declarative/qml/qdeclarativecustomparser_p.h b/src/declarative/qml/qdeclarativecustomparser_p.h deleted file mode 100644 index 92d1ca7af2..0000000000 --- a/src/declarative/qml/qdeclarativecustomparser_p.h +++ /dev/null @@ -1,168 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QDECLARATIVECUSTOMPARSER_H -#define QDECLARATIVECUSTOMPARSER_H - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists purely as an -// implementation detail. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - -#include "qdeclarativemetatype_p.h" -#include "qdeclarativeerror.h" -#include "qdeclarativescript_p.h" -#include "qdeclarativebinding_p.h" - -#include -#include - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - - -class QDeclarativeCompiler; - -class QDeclarativeCustomParserPropertyPrivate; -class Q_DECLARATIVE_EXPORT QDeclarativeCustomParserProperty -{ -public: - QDeclarativeCustomParserProperty(); - QDeclarativeCustomParserProperty(const QDeclarativeCustomParserProperty &); - QDeclarativeCustomParserProperty &operator=(const QDeclarativeCustomParserProperty &); - ~QDeclarativeCustomParserProperty(); - - QString name() const; - QDeclarativeScript::Location location() const; - - bool isList() const; - // Will be one of QDeclarativeScript::Variant, QDeclarativeCustomParserProperty or - // QDeclarativeCustomParserNode - QList assignedValues() const; - -private: - friend class QDeclarativeCustomParserNodePrivate; - friend class QDeclarativeCustomParserPropertyPrivate; - QDeclarativeCustomParserPropertyPrivate *d; -}; - -class QDeclarativeCustomParserNodePrivate; -class Q_DECLARATIVE_EXPORT QDeclarativeCustomParserNode -{ -public: - QDeclarativeCustomParserNode(); - QDeclarativeCustomParserNode(const QDeclarativeCustomParserNode &); - QDeclarativeCustomParserNode &operator=(const QDeclarativeCustomParserNode &); - ~QDeclarativeCustomParserNode(); - - QString name() const; - QDeclarativeScript::Location location() const; - - QList properties() const; - -private: - friend class QDeclarativeCustomParserNodePrivate; - QDeclarativeCustomParserNodePrivate *d; -}; - -class Q_DECLARATIVE_EXPORT QDeclarativeCustomParser -{ -public: - enum Flag { - NoFlag = 0x00000000, - AcceptsAttachedProperties = 0x00000001, - AcceptsSignalHandlers = 0x00000002 - }; - Q_DECLARE_FLAGS(Flags, Flag) - - QDeclarativeCustomParser() : compiler(0), object(0), m_flags(NoFlag) {} - QDeclarativeCustomParser(Flags f) : compiler(0), object(0), m_flags(f) {} - virtual ~QDeclarativeCustomParser() {} - - void clearErrors(); - Flags flags() const { return m_flags; } - - virtual QByteArray compile(const QList &)=0; - virtual void setCustomData(QObject *, const QByteArray &)=0; - - QList errors() const { return exceptions; } - -protected: - void error(const QString& description); - void error(const QDeclarativeCustomParserProperty&, const QString& description); - void error(const QDeclarativeCustomParserNode&, const QString& description); - - int evaluateEnum(const QByteArray&) const; - - const QMetaObject *resolveType(const QString&) const; - - QDeclarativeBinding::Identifier rewriteBinding(const QDeclarativeScript::Variant&, const QString&); - QString rewriteSignalHandler(const QDeclarativeScript::Variant&, const QString&); - -private: - QList exceptions; - QDeclarativeCompiler *compiler; - QDeclarativeScript::Object *object; - Flags m_flags; - friend class QDeclarativeCompiler; -}; -Q_DECLARE_OPERATORS_FOR_FLAGS(QDeclarativeCustomParser::Flags); - -#if 0 -#define QML_REGISTER_CUSTOM_TYPE(URI, VERSION_MAJ, VERSION_MIN, NAME, TYPE, CUSTOMTYPE) \ - qmlRegisterCustomType(#URI, VERSION_MAJ, VERSION_MIN, #NAME, #TYPE, new CUSTOMTYPE) -#endif - -QT_END_NAMESPACE - -Q_DECLARE_METATYPE(QDeclarativeCustomParserProperty) -Q_DECLARE_METATYPE(QDeclarativeCustomParserNode) - -QT_END_HEADER - -#endif diff --git a/src/declarative/qml/qdeclarativecustomparser_p_p.h b/src/declarative/qml/qdeclarativecustomparser_p_p.h deleted file mode 100644 index e7228f07f0..0000000000 --- a/src/declarative/qml/qdeclarativecustomparser_p_p.h +++ /dev/null @@ -1,89 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QDECLARATIVECUSTOMPARSER_P_H -#define QDECLARATIVECUSTOMPARSER_P_H - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists purely as an -// implementation detail. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - -#include "qdeclarativecustomparser_p.h" - -#include "qdeclarativescript_p.h" - -#include - -QT_BEGIN_NAMESPACE - -class QDeclarativeCustomParserNodePrivate -{ -public: - QString name; - QList properties; - QDeclarativeScript::Location location; - - static QDeclarativeCustomParserNode fromObject(QDeclarativeScript::Object *); - static QDeclarativeCustomParserProperty fromProperty(QDeclarativeScript::Property *); -}; - -class QDeclarativeCustomParserPropertyPrivate -{ -public: - QDeclarativeCustomParserPropertyPrivate() - : isList(false) {} - - QString name; - bool isList; - QDeclarativeScript::Location location; - QList values; -}; - -QT_END_NAMESPACE - -#endif // QDECLARATIVECUSTOMPARSER_P_H diff --git a/src/declarative/qml/qdeclarativedata_p.h b/src/declarative/qml/qdeclarativedata_p.h deleted file mode 100644 index 0f75d620b8..0000000000 --- a/src/declarative/qml/qdeclarativedata_p.h +++ /dev/null @@ -1,207 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QDECLARATIVEDATA_P_H -#define QDECLARATIVEDATA_P_H - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists purely as an -// implementation detail. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - -#include - -#include - -QT_BEGIN_NAMESPACE - -template class QHash; -class QDeclarativeGuardImpl; -class QDeclarativeCompiledData; -class QDeclarativeAbstractBinding; -class QDeclarativeContext; -class QDeclarativePropertyCache; -class QDeclarativeContextData; -class QDeclarativeNotifier; -class QDeclarativeDataExtended; -class QDeclarativeNotifierEndpoint; -// This class is structured in such a way, that simply zero'ing it is the -// default state for elemental object allocations. This is crucial in the -// workings of the QDeclarativeInstruction::CreateSimpleObject instruction. -// Don't change anything here without first considering that case! -class Q_DECLARATIVE_EXPORT QDeclarativeData : public QAbstractDeclarativeData -{ -public: - QDeclarativeData() - : ownMemory(true), ownContext(false), indestructible(true), explicitIndestructibleSet(false), - hasTaintedV8Object(false), notifyList(0), context(0), outerContext(0), bindings(0), - nextContextObject(0), prevContextObject(0), bindingBitsSize(0), bindingBits(0), - lineNumber(0), columnNumber(0), deferredComponent(0), deferredIdx(0), v8objectid(0), - propertyCache(0), guards(0), extendedData(0) { - init(); - } - - static inline void init() { - QAbstractDeclarativeData::destroyed = destroyed; - QAbstractDeclarativeData::parentChanged = parentChanged; - QAbstractDeclarativeData::objectNameChanged = objectNameChanged; - QAbstractDeclarativeData::signalEmitted = signalEmitted; - } - - static void destroyed(QAbstractDeclarativeData *, QObject *); - static void parentChanged(QAbstractDeclarativeData *, QObject *, QObject *); - static void objectNameChanged(QAbstractDeclarativeData *, QObject *); - static void signalEmitted(QAbstractDeclarativeData *, QObject *, int, void **); - - void destroyed(QObject *); - void parentChanged(QObject *, QObject *); - void objectNameChanged(QObject *); - - void setImplicitDestructible() { - if (!explicitIndestructibleSet) indestructible = false; - } - - quint32 ownMemory:1; - quint32 ownContext:1; - quint32 indestructible:1; - quint32 explicitIndestructibleSet:1; - quint32 hasTaintedV8Object:1; - quint32 dummy:27; - - struct NotifyList { - quint64 connectionMask; - - quint16 maximumTodoIndex; - quint16 notifiesSize; - - QDeclarativeNotifierEndpoint *todo; - QDeclarativeNotifierEndpoint**notifies; - void layout(); - private: - void layout(QDeclarativeNotifierEndpoint*); - }; - NotifyList *notifyList; - - inline QDeclarativeNotifierEndpoint *notify(int index); - void addNotify(int index, QDeclarativeNotifierEndpoint *); - - // The context that created the C++ object - QDeclarativeContextData *context; - // The outermost context in which this object lives - QDeclarativeContextData *outerContext; - - QDeclarativeAbstractBinding *bindings; - - // Linked list for QDeclarativeContext::contextObjects - QDeclarativeData *nextContextObject; - QDeclarativeData**prevContextObject; - - int bindingBitsSize; - quint32 *bindingBits; - bool hasBindingBit(int) const; - void clearBindingBit(int); - void setBindingBit(QObject *obj, int); - - ushort lineNumber; - ushort columnNumber; - - QDeclarativeCompiledData *deferredComponent; // Can't this be found from the context? - unsigned int deferredIdx; - - quint32 v8objectid; - v8::Persistent v8object; - - QDeclarativePropertyCache *propertyCache; - - QDeclarativeGuardImpl *guards; - - static QDeclarativeData *get(const QObject *object, bool create = false) { - QObjectPrivate *priv = QObjectPrivate::get(const_cast(object)); - if (priv->wasDeleted) { - Q_ASSERT(!create); - return 0; - } else if (priv->declarativeData) { - return static_cast(priv->declarativeData); - } else if (create) { - priv->declarativeData = new QDeclarativeData; - return static_cast(priv->declarativeData); - } else { - return 0; - } - } - - bool hasExtendedData() const { return extendedData != 0; } - QDeclarativeNotifier *objectNameNotifier() const; - QHash *attachedProperties() const; - -private: - // For objectNameNotifier and attachedProperties - mutable QDeclarativeDataExtended *extendedData; -}; - -QDeclarativeNotifierEndpoint *QDeclarativeData::notify(int index) -{ - Q_ASSERT(index <= 0xFFFF); - - if (!notifyList || !(notifyList->connectionMask & (1ULL << quint64(index % 64)))) { - return 0; - } else if (index < notifyList->notifiesSize) { - return notifyList->notifies[index]; - } else if (index <= notifyList->maximumTodoIndex) { - notifyList->layout(); - } - - if (index < notifyList->notifiesSize) { - return notifyList->notifies[index]; - } else { - return 0; - } -} - -QT_END_NAMESPACE - -#endif // QDECLARATIVEDATA_P_H diff --git a/src/declarative/qml/qdeclarativedirparser.cpp b/src/declarative/qml/qdeclarativedirparser.cpp deleted file mode 100644 index f7d5be3601..0000000000 --- a/src/declarative/qml/qdeclarativedirparser.cpp +++ /dev/null @@ -1,298 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qdeclarativedirparser_p.h" -#include "qdeclarativeerror.h" -#include "qdeclarativeglobal_p.h" - -#include -#include -#include - -QT_BEGIN_NAMESPACE - -QDeclarativeDirParser::QDeclarativeDirParser() - : _isParsed(false) -{ -} - -QDeclarativeDirParser::~QDeclarativeDirParser() -{ -} - -QUrl QDeclarativeDirParser::url() const -{ - return _url; -} - -void QDeclarativeDirParser::setUrl(const QUrl &url) -{ - _url = url; -} - -QString QDeclarativeDirParser::fileSource() const -{ - return _filePathSouce; -} - -void QDeclarativeDirParser::setFileSource(const QString &filePath) -{ - _filePathSouce = filePath; -} - -QString QDeclarativeDirParser::source() const -{ - return _source; -} - -void QDeclarativeDirParser::setSource(const QString &source) -{ - _isParsed = false; - _source = source; -} - -bool QDeclarativeDirParser::isParsed() const -{ - return _isParsed; -} - -bool QDeclarativeDirParser::parse() -{ - if (_isParsed) - return true; - - _isParsed = true; - _errors.clear(); - _plugins.clear(); - _components.clear(); - _scripts.clear(); - - if (_source.isEmpty() && !_filePathSouce.isEmpty()) { - QFile file(_filePathSouce); - if (!QDeclarative_isFileCaseCorrect(_filePathSouce)) { - QDeclarativeError error; - error.setDescription(QString::fromUtf8("cannot load module \"$$URI$$\": File name case mismatch for \"%1\"").arg(_filePathSouce)); - _errors.prepend(error); - return false; - } else if (file.open(QFile::ReadOnly)) { - _source = QString::fromUtf8(file.readAll()); - } else { - QDeclarativeError error; - error.setDescription(QString::fromUtf8("module \"$$URI$$\" definition \"%1\" not readable").arg(_filePathSouce)); - _errors.prepend(error); - return false; - } - } - - QTextStream stream(&_source); - int lineNumber = 0; - - forever { - ++lineNumber; - - const QString line = stream.readLine(); - if (line.isNull()) - break; - - QString sections[3]; - int sectionCount = 0; - - int index = 0; - const int length = line.length(); - - while (index != length) { - const QChar ch = line.at(index); - - if (ch.isSpace()) { - do { ++index; } - while (index != length && line.at(index).isSpace()); - - } else if (ch == QLatin1Char('#')) { - // recognized a comment - break; - - } else { - const int start = index; - - do { ++index; } - while (index != length && !line.at(index).isSpace()); - - const QString lexeme = line.mid(start, index - start); - - if (sectionCount >= 3) { - reportError(lineNumber, start, QLatin1String("unexpected token")); - - } else { - sections[sectionCount++] = lexeme; - } - } - } - - if (sectionCount == 0) { - continue; // no sections, no party. - - } else if (sections[0] == QLatin1String("plugin")) { - if (sectionCount < 2) { - reportError(lineNumber, -1, - QString::fromUtf8("plugin directive requires one or two arguments, but %1 were provided").arg(sectionCount - 1)); - - continue; - } - - const Plugin entry(sections[1], sections[2]); - - _plugins.append(entry); - - } else if (sections[0] == QLatin1String("internal")) { - if (sectionCount != 3) { - reportError(lineNumber, -1, - QString::fromUtf8("internal types require 2 arguments, but %1 were provided").arg(sectionCount - 1)); - continue; - } - Component entry(sections[1], sections[2], -1, -1); - entry.internal = true; - _components.append(entry); - } else if (sections[0] == QLatin1String("typeinfo")) { - if (sectionCount != 2) { - reportError(lineNumber, -1, - QString::fromUtf8("typeinfo requires 1 argument, but %1 were provided").arg(sectionCount - 1)); - continue; - } -#ifdef QT_CREATOR - TypeInfo typeInfo(sections[1]); - _typeInfos.append(typeInfo); -#endif - - } else if (sectionCount == 2) { - // No version specified (should only be used for relative qmldir files) - const Component entry(sections[0], sections[1], -1, -1); - _components.append(entry); - } else if (sectionCount == 3) { - const QString &version = sections[1]; - const int dotIndex = version.indexOf(QLatin1Char('.')); - - if (dotIndex == -1) { - reportError(lineNumber, -1, QLatin1String("expected '.'")); - } else if (version.indexOf(QLatin1Char('.'), dotIndex + 1) != -1) { - reportError(lineNumber, -1, QLatin1String("unexpected '.'")); - } else { - bool validVersionNumber = false; - const int majorVersion = version.left(dotIndex).toInt(&validVersionNumber); - - if (validVersionNumber) { - const int minorVersion = version.mid(dotIndex + 1).toInt(&validVersionNumber); - - if (validVersionNumber) { - const QString &fileName = sections[2]; - - if (fileName.endsWith(QLatin1String(".js"))) { - // A 'js' extension indicates a namespaced script import - const Script entry(sections[0], fileName, majorVersion, minorVersion); - _scripts.append(entry); - } else { - const Component entry(sections[0], fileName, majorVersion, minorVersion); - _components.append(entry); - } - } - } - } - } else { - reportError(lineNumber, -1, - QString::fromUtf8("a component declaration requires two or three arguments, but %1 were provided").arg(sectionCount)); - } - } - - return hasError(); -} - -void QDeclarativeDirParser::reportError(int line, int column, const QString &description) -{ - QDeclarativeError error; - error.setUrl(_url); - error.setLine(line); - error.setColumn(column); - error.setDescription(description); - _errors.append(error); -} - -bool QDeclarativeDirParser::hasError() const -{ - if (! _errors.isEmpty()) - return true; - - return false; -} - -QList QDeclarativeDirParser::errors(const QString &uri) const -{ - QList errors = _errors; - for (int i = 0; i < errors.size(); ++i) { - QDeclarativeError &e = errors[i]; - QString description = e.description(); - description.replace(QLatin1String("$$URI$$"), uri); - e.setDescription(description); - } - return errors; -} - -QList QDeclarativeDirParser::plugins() const -{ - return _plugins; -} - -QList QDeclarativeDirParser::components() const -{ - return _components; -} - -QList QDeclarativeDirParser::scripts() const -{ - return _scripts; -} - -#ifdef QT_CREATOR -QList QDeclarativeDirParser::typeInfos() const -{ - return _typeInfos; -} -#endif - -QT_END_NAMESPACE diff --git a/src/declarative/qml/qdeclarativedirparser_p.h b/src/declarative/qml/qdeclarativedirparser_p.h deleted file mode 100644 index 40b4b57a12..0000000000 --- a/src/declarative/qml/qdeclarativedirparser_p.h +++ /dev/null @@ -1,166 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QDECLARATIVEDIRPARSER_P_H -#define QDECLARATIVEDIRPARSER_P_H - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists purely as an -// implementation detail. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - -#include -#include - -QT_BEGIN_NAMESPACE - -class QDeclarativeError; -class QDeclarativeDirParser -{ - Q_DISABLE_COPY(QDeclarativeDirParser) - -public: - QDeclarativeDirParser(); - ~QDeclarativeDirParser(); - - QUrl url() const; - void setUrl(const QUrl &url); - - QString fileSource() const; - void setFileSource(const QString &filePath); - - QString source() const; - void setSource(const QString &source); - - bool isParsed() const; - bool parse(); - - bool hasError() const; - QList errors(const QString &uri) const; - - struct Plugin - { - Plugin() {} - - Plugin(const QString &name, const QString &path) - : name(name), path(path) {} - - QString name; - QString path; - }; - - struct Component - { - Component() - : majorVersion(0), minorVersion(0), internal(false) {} - - Component(const QString &typeName, const QString &fileName, int majorVersion, int minorVersion) - : typeName(typeName), fileName(fileName), majorVersion(majorVersion), minorVersion(minorVersion), - internal(false) {} - - QString typeName; - QString fileName; - int majorVersion; - int minorVersion; - bool internal; - }; - - struct Script - { - Script() - : majorVersion(0), minorVersion(0) {} - - Script(const QString &nameSpace, const QString &fileName, int majorVersion, int minorVersion) - : nameSpace(nameSpace), fileName(fileName), majorVersion(majorVersion), minorVersion(minorVersion) {} - - QString nameSpace; - QString fileName; - int majorVersion; - int minorVersion; - }; - - QList components() const; - QList - * - * - */ - -/* - * The earlier versions of the test code used exceptions - * to terminate the test script in "negative" test cases - * before the failure reporting code could run. In order - * to be able to capture errors for the "negative" case - * where the exception is a sign the test actually passed, - * the err online handler will assume that any error is a - * failure unless gExceptionExpected is true. - */ - diff --git a/tests/auto/declarative/parserstress/tests/ecma/extensions/10.1.4-9.js b/tests/auto/declarative/parserstress/tests/ecma/extensions/10.1.4-9.js deleted file mode 100644 index 91982de20c..0000000000 --- a/tests/auto/declarative/parserstress/tests/ecma/extensions/10.1.4-9.js +++ /dev/null @@ -1,110 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is Mozilla Communicator client code, released - * March 31, 1998. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -gTestfile = '10.1.4-9.js'; - -/** - File Name: 10.1.4-9.js - ECMA Section: 10.1.4 Scope Chain and Identifier Resolution - Description: - Every execution context has associated with it a scope chain. This is - logically a list of objects that are searched when binding an Identifier. - When control enters an execution context, the scope chain is created and - is populated with an initial set of objects, depending on the type of - code. When control leaves the execution context, the scope chain is - destroyed. - - During execution, the scope chain of the execution context is affected - only by WithStatement. When execution enters a with block, the object - specified in the with statement is added to the front of the scope chain. - When execution leaves a with block, whether normally or via a break or - continue statement, the object is removed from the scope chain. The object - being removed will always be the first object in the scope chain. - - During execution, the syntactic production PrimaryExpression : Identifier - is evaluated using the following algorithm: - - 1. Get the next object in the scope chain. If there isn't one, go to step 5. - 2. Call the [[HasProperty]] method of Result(l), passing the Identifier as - the property. - 3. If Result(2) is true, return a value of type Reference whose base object - is Result(l) and whose property name is the Identifier. - 4. Go to step 1. - 5. Return a value of type Reference whose base object is null and whose - property name is the Identifier. - The result of binding an identifier is always a value of type Reference with - its member name component equal to the identifier string. - Author: christine@netscape.com - Date: 12 november 1997 -*/ -var SECTION = "10.1.4-9"; -var VERSION = "ECMA_2"; -startTest(); - -writeHeaderToLog( SECTION + " Scope Chain and Identifier Resolution"); - -new TestCase( SECTION, "NEW_PROPERTY = " ); - -test(); - -function test() { - for ( gTc=0; gTc < gTestcases.length; gTc++ ) { - - var MYOBJECT = new MyObject(); - var RESULT = "hello"; - - with ( MYOBJECT ) { - NEW_PROPERTY = RESULT; - } - gTestcases[gTc].actual = NEW_PROPERTY; - gTestcases[gTc].expect = RESULT; - - gTestcases[gTc].passed = writeTestCaseResult( - gTestcases[gTc].expect, - gTestcases[gTc].actual, - gTestcases[gTc].description +" = "+ - gTestcases[gTc].actual ); - - gTestcases[gTc].reason += ( gTestcases[gTc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( gTestcases ); -} -function MyObject( n ) { - this.__proto__ = Number.prototype; -} diff --git a/tests/auto/declarative/parserstress/tests/ecma/extensions/10.1.6.js b/tests/auto/declarative/parserstress/tests/ecma/extensions/10.1.6.js deleted file mode 100644 index 99fd4a7ff1..0000000000 --- a/tests/auto/declarative/parserstress/tests/ecma/extensions/10.1.6.js +++ /dev/null @@ -1,127 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is Mozilla Communicator client code, released - * March 31, 1998. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -gTestfile = '10.1.6.js'; - -/** - File Name: 10.1.6 - ECMA Section: Activation Object - Description: - - If the function object being invoked has an arguments property, let x be - the value of that property; the activation object is also given an internal - property [[OldArguments]] whose initial value is x; otherwise, an arguments - property is created for the function object but the activation object is - not given an [[OldArguments]] property. Next, arguments object described - below (the same one stored in the arguments property of the activation - object) is used as the new value of the arguments property of the function - object. This new value is installed even if the arguments property already - exists and has the ReadOnly attribute (as it will for native Function - objects). (These actions are taken to provide compatibility with a form of - program syntax that is now discouraged: to access the arguments object for - function f within the body of f by using the expression f.arguments. - The recommended way to access the arguments object for function f within - the body of f is simply to refer to the variable arguments.) - - Author: christine@netscape.com - Date: 12 november 1997 -*/ - -var SECTION = "10.1.6"; -var VERSION = "ECMA_1"; -startTest(); -var TITLE = "Activation Object"; - -writeHeaderToLog( SECTION + " "+ TITLE); - -var arguments = "FAILED!"; - -var ARG_STRING = "value of the argument property"; - -new TestCase( SECTION, - "(new TestObject(0,1,2,3,4,5)).length", - 6, - (new TestObject(0,1,2,3,4,5)).length ); - -for ( i = 0; i < 6; i++ ) { - - new TestCase( SECTION, - "(new TestObject(0,1,2,3,4,5))["+i+"]", - i, - (new TestObject(0,1,2,3,4,5))[i]); -} - - -// The current object already has an arguments property. - -new TestCase( SECTION, - "(new AnotherTestObject(1,2,3)).arguments", - ARG_STRING, - (new AnotherTestObject(1,2,3)).arguments ); - -// The function invoked with [[Call]] - -new TestCase( SECTION, - "TestFunction(1,2,3)", - ARG_STRING, - TestFunction() + '' ); - - -test(); - - - -function Prototype() { - this.arguments = ARG_STRING; -} -function TestObject() { - this.__proto__ = new Prototype(); - return arguments; -} -function AnotherTestObject() { - this.__proto__ = new Prototype(); - return this; -} -function TestFunction() { - arguments = ARG_STRING; - return arguments; -} -function AnotherTestFunction() { - this.__proto__ = new Prototype(); - return this; -} diff --git a/tests/auto/declarative/parserstress/tests/ecma/extensions/10.1.8-1.js b/tests/auto/declarative/parserstress/tests/ecma/extensions/10.1.8-1.js deleted file mode 100644 index adfc8d5df5..0000000000 --- a/tests/auto/declarative/parserstress/tests/ecma/extensions/10.1.8-1.js +++ /dev/null @@ -1,135 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is Mozilla Communicator client code, released - * March 31, 1998. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -gTestfile = '10.1.8-1.js'; - -/** - File Name: 10.1.8 - ECMA Section: Arguments Object - Description: - - When control enters an execution context for declared function code, - anonymous code, or implementation-supplied code, an arguments object is - created and initialized as follows: - - The [[Prototype]] of the arguments object is to the original Object - prototype object, the one that is the initial value of Object.prototype - (section 15.2.3.1). - - A property is created with name callee and property attributes {DontEnum}. - The initial value of this property is the function object being executed. - This allows anonymous functions to be recursive. - - A property is created with name length and property attributes {DontEnum}. - The initial value of this property is the number of actual parameter values - supplied by the caller. - - For each non-negative integer, iarg, less than the value of the length - property, a property is created with name ToString(iarg) and property - attributes { DontEnum }. The initial value of this property is the value - of the corresponding actual parameter supplied by the caller. The first - actual parameter value corresponds to iarg = 0, the second to iarg = 1 and - so on. In the case when iarg is less than the number of formal parameters - for the function object, this property shares its value with the - corresponding property of the activation object. This means that changing - this property changes the corresponding property of the activation object - and vice versa. The value sharing mechanism depends on the implementation. - - Author: christine@netscape.com - Date: 12 november 1997 -*/ - -var SECTION = "10.1.8"; -var VERSION = "ECMA_1"; -startTest(); -var TITLE = "Arguments Object"; - -writeHeaderToLog( SECTION + " "+ TITLE); - -var ARG_STRING = "value of the argument property"; - -new TestCase( SECTION, - "GetCallee()", - GetCallee, - GetCallee() ); - -var LIMIT = 100; - -for ( var i = 0, args = "" ; i < LIMIT; i++ ) { - args += String(i) + ( i+1 < LIMIT ? "," : "" ); - -} - -var LENGTH = eval( "GetLength("+ args +")" ); - -new TestCase( SECTION, - "GetLength("+args+")", - 100, - LENGTH ); - -var ARGUMENTS = eval( "GetArguments( " +args+")" ); - -for ( var i = 0; i < 100; i++ ) { - new TestCase( SECTION, - "GetArguments("+args+")["+i+"]", - i, - ARGUMENTS[i] ); -} - -test(); - -function TestFunction() { - var arg_proto = arguments.__proto__; -} -function GetCallee() { - var c = arguments.callee; - return c; -} -function GetArguments() { - var a = arguments; - return a; -} -function GetLength() { - var l = arguments.length; - return l; -} - -function AnotherTestFunction() { - this.__proto__ = new Prototype(); - return this; -} diff --git a/tests/auto/declarative/parserstress/tests/ecma/extensions/11.6.1-1.js b/tests/auto/declarative/parserstress/tests/ecma/extensions/11.6.1-1.js deleted file mode 100644 index e467157441..0000000000 --- a/tests/auto/declarative/parserstress/tests/ecma/extensions/11.6.1-1.js +++ /dev/null @@ -1,145 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is Mozilla Communicator client code, released - * March 31, 1998. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -gTestfile = '11.6.1-1.js'; - -/** - File Name: 11.6.1-1.js - ECMA Section: 11.6.1 The addition operator ( + ) - Description: - - The addition operator either performs string concatenation or numeric - addition. - - The production AdditiveExpression : AdditiveExpression + MultiplicativeExpression - is evaluated as follows: - - 1. Evaluate AdditiveExpression. - 2. Call GetValue(Result(1)). - 3. Evaluate MultiplicativeExpression. - 4. Call GetValue(Result(3)). - 5. Call ToPrimitive(Result(2)). - 6. Call ToPrimitive(Result(4)). - 7. If Type(Result(5)) is String or Type(Result(6)) is String, go to step 12. - (Note that this step differs from step 3 in the algorithm for comparison - for the relational operators in using or instead of and.) - 8. Call ToNumber(Result(5)). - 9. Call ToNumber(Result(6)). - 10. Apply the addition operation to Result(8) and Result(9). See the discussion below (11.6.3). - 11. Return Result(10). - 12. Call ToString(Result(5)). - 13. Call ToString(Result(6)). - 14. Concatenate Result(12) followed by Result(13). - 15. Return Result(14). - - Note that no hint is provided in the calls to ToPrimitive in steps 5 and 6. - All native ECMAScript objects except Date objects handle the absence of a - hint as if the hint Number were given; Date objects handle the absence of a - hint as if the hint String were given. Host objects may handle the absence - of a hint in some other manner. - - This test does not cover cases where the Additive or Mulplicative expression - ToPrimitive is string. - - Author: christine@netscape.com - Date: 12 november 1997 -*/ -var SECTION = "11.6.1-1"; -var VERSION = "ECMA_1"; -startTest(); - -writeHeaderToLog( SECTION + " The Addition operator ( + )"); - -// tests for "MyValuelessObject", where the value is -// set in the object's prototype, not the object itself. - -new TestCase( SECTION, - "var EXP_1 = new MyValuelessObject(true); var EXP_2 = new MyValuelessObject(false); EXP_1 + EXP_2", - 1, - eval("var EXP_1 = new MyValuelessObject(true); var EXP_2 = new MyValuelessObject(false); EXP_1 + EXP_2") ); - -new TestCase( SECTION, - "var EXP_1 = new MyValuelessObject(new Boolean(true)); var EXP_2 = new MyValuelessObject(new Boolean(false)); EXP_1 + EXP_2", - "truefalse", - eval("var EXP_1 = new MyValuelessObject(new Boolean(true)); var EXP_2 = new MyValuelessObject(new Boolean(false)); EXP_1 + EXP_2") ); - -// tests for "MyValuelessObject", where the value is -// set in the object's prototype, not the object itself. - - -new TestCase( SECTION, - "var EXP_1 = new MyValuelessObject(100); var EXP_2 = new MyValuelessObject(-1); EXP_1 + EXP_2", - 99, - eval("var EXP_1 = new MyValuelessObject(100); var EXP_2 = new MyValuelessObject(-1); EXP_1 + EXP_2") ); - -new TestCase( SECTION, - "var EXP_1 = new MyValuelessObject(new Number(100)); var EXP_2 = new MyValuelessObject(new Number(-1)); EXP_1 + EXP_2", - "100-1", - eval("var EXP_1 = new MyValuelessObject(new Number(100)); var EXP_2 = new MyValuelessObject(new Number(-1)); EXP_1 + EXP_2") ); - -new TestCase( SECTION, - "var EXP_1 = new MyValuelessObject( new MyValuelessObject( new Boolean(true) ) ); EXP_1 + EXP_1", - "truetrue", - eval("var EXP_1 = new MyValuelessObject( new MyValuelessObject( new Boolean(true) ) ); EXP_1 + EXP_1") ); - -test(); - -function MyProtoValuelessObject() { - this.valueOf = new Function ( "" ); - this.__proto__ = null; -} - -function MyProtolessObject( value ) { - this.valueOf = new Function( "return this.value" ); - this.__proto__ = null; - this.value = value; -} - -function MyValuelessObject(value) { - this.__proto__ = new MyPrototypeObject(value); -} -function MyPrototypeObject(value) { - this.valueOf = new Function( "return this.value;" ); - this.toString = new Function( "return (this.value + '');" ); - this.value = value; -} - -function MyObject( value ) { - this.valueOf = new Function( "return this.value" ); - this.value = value; -} diff --git a/tests/auto/declarative/parserstress/tests/ecma/extensions/11.6.1-2.js b/tests/auto/declarative/parserstress/tests/ecma/extensions/11.6.1-2.js deleted file mode 100644 index a486885b7f..0000000000 --- a/tests/auto/declarative/parserstress/tests/ecma/extensions/11.6.1-2.js +++ /dev/null @@ -1,136 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is Mozilla Communicator client code, released - * March 31, 1998. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -gTestfile = '11.6.1-2.js'; - -/** - File Name: 11.6.1-2.js - ECMA Section: 11.6.1 The addition operator ( + ) - Description: - - The addition operator either performs string concatenation or numeric - addition. - - The production AdditiveExpression : AdditiveExpression + MultiplicativeExpression - is evaluated as follows: - - 1. Evaluate AdditiveExpression. - 2. Call GetValue(Result(1)). - 3. Evaluate MultiplicativeExpression. - 4. Call GetValue(Result(3)). - 5. Call ToPrimitive(Result(2)). - 6. Call ToPrimitive(Result(4)). - 7. If Type(Result(5)) is String or Type(Result(6)) is String, go to step 12. - (Note that this step differs from step 3 in the algorithm for comparison - for the relational operators in using or instead of and.) - 8. Call ToNumber(Result(5)). - 9. Call ToNumber(Result(6)). - 10. Apply the addition operation to Result(8) and Result(9). See the discussion below (11.6.3). - 11. Return Result(10). - 12. Call ToString(Result(5)). - 13. Call ToString(Result(6)). - 14. Concatenate Result(12) followed by Result(13). - 15. Return Result(14). - - Note that no hint is provided in the calls to ToPrimitive in steps 5 and 6. - All native ECMAScript objects except Date objects handle the absence of a - hint as if the hint Number were given; Date objects handle the absence of a - hint as if the hint String were given. Host objects may handle the absence - of a hint in some other manner. - - This test does only covers cases where the Additive or Mulplicative expression - ToPrimitive is a string. - - Author: christine@netscape.com - Date: 12 november 1997 -*/ -var SECTION = "11.6.1-2"; -var VERSION = "ECMA_1"; -startTest(); - -writeHeaderToLog( SECTION + " The Addition operator ( + )"); - -// tests for "MyValuelessObject", where the value is -// set in the object's prototype, not the object itself. - -new TestCase( SECTION, - "var EXP_1 = new MyValuelessObject('string'); var EXP_2 = new MyValuelessObject(false); EXP_1 + EXP_2", - "stringfalse", - eval("var EXP_1 = new MyValuelessObject('string'); var EXP_2 = new MyValuelessObject(false); EXP_1 + EXP_2") ); - -new TestCase( SECTION, - "var EXP_1 = new MyValuelessObject(new String('string')); var EXP_2 = new MyValuelessObject(new Boolean(false)); EXP_1 + EXP_2", - "stringfalse", - eval("var EXP_1 = new MyValuelessObject(new String('string')); var EXP_2 = new MyValuelessObject(new Boolean(false)); EXP_1 + EXP_2") ); - -// tests for "MyValuelessObject", where the value is -// set in the object's prototype, not the object itself. - -new TestCase( SECTION, - "var EXP_1 = new MyValuelessObject(100); var EXP_2 = new MyValuelessObject('string'); EXP_1 + EXP_2", - "100string", - eval("var EXP_1 = new MyValuelessObject(100); var EXP_2 = new MyValuelessObject('string'); EXP_1 + EXP_2") ); - -new TestCase( SECTION, - "var EXP_1 = new MyValuelessObject(new String('string')); var EXP_2 = new MyValuelessObject(new Number(-1)); EXP_1 + EXP_2", - "string-1", - eval("var EXP_1 = new MyValuelessObject(new String('string')); var EXP_2 = new MyValuelessObject(new Number(-1)); EXP_1 + EXP_2") ); - -test(); - -function MyProtoValuelessObject() { - this.valueOf = new Function ( "" ); - this.__proto__ = null; -} -function MyProtolessObject( value ) { - this.valueOf = new Function( "return this.value" ); - this.__proto__ = null; - this.value = value; -} -function MyValuelessObject(value) { - this.__proto__ = new MyPrototypeObject(value); -} -function MyPrototypeObject(value) { - this.valueOf = new Function( "return this.value;" ); - this.toString = new Function( "return (this.value + '');" ); - this.value = value; -} -function MyObject( value ) { - this.valueOf = new Function( "return this.value" ); - this.value = value; -} diff --git a/tests/auto/declarative/parserstress/tests/ecma/extensions/11.6.1-3.js b/tests/auto/declarative/parserstress/tests/ecma/extensions/11.6.1-3.js deleted file mode 100644 index 7d66e58530..0000000000 --- a/tests/auto/declarative/parserstress/tests/ecma/extensions/11.6.1-3.js +++ /dev/null @@ -1,137 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is Mozilla Communicator client code, released - * March 31, 1998. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -gTestfile = '11.6.1-3.js'; - -/** - File Name: 11.6.1-3.js - ECMA Section: 11.6.1 The addition operator ( + ) - Description: - - The addition operator either performs string concatenation or numeric - addition. - - The production AdditiveExpression : AdditiveExpression + MultiplicativeExpression - is evaluated as follows: - - 1. Evaluate AdditiveExpression. - 2. Call GetValue(Result(1)). - 3. Evaluate MultiplicativeExpression. - 4. Call GetValue(Result(3)). - 5. Call ToPrimitive(Result(2)). - 6. Call ToPrimitive(Result(4)). - 7. If Type(Result(5)) is String or Type(Result(6)) is String, go to step 12. - (Note that this step differs from step 3 in the algorithm for comparison - for the relational operators in using or instead of and.) - 8. Call ToNumber(Result(5)). - 9. Call ToNumber(Result(6)). - 10. Apply the addition operation to Result(8) and Result(9). See the discussion below (11.6.3). - 11. Return Result(10). - 12. Call ToString(Result(5)). - 13. Call ToString(Result(6)). - 14. Concatenate Result(12) followed by Result(13). - 15. Return Result(14). - - Note that no hint is provided in the calls to ToPrimitive in steps 5 and 6. - All native ECMAScript objects except Date objects handle the absence of a - hint as if the hint Number were given; Date objects handle the absence of a - hint as if the hint String were given. Host objects may handle the absence - of a hint in some other manner. - - This test does only covers cases where the Additive or Mulplicative expression - is a Date. - - Author: christine@netscape.com - Date: 12 november 1997 -*/ -var SECTION = "11.6.1-3"; -var VERSION = "ECMA_1"; -startTest(); - -writeHeaderToLog( SECTION + " The Addition operator ( + )"); - -// tests for a boolean primitive and a boolean object, and -// "MyValuelessObject", where the value is set in the object's -// prototype, not the object itself. - -var DATE1 = new Date(); - -var MYOB1 = new MyObject( DATE1 ); -var MYOB2 = new MyValuelessObject( DATE1 ); -var MYOB3 = new MyProtolessObject( DATE1 ); -var MYOB4 = new MyProtoValuelessObject( DATE1 ); - -new TestCase( SECTION, - "MYOB2 = new MyValuelessObject(DATE1); MYOB3 + 'string'", - DATE1.toString() + "string", - MYOB2 + 'string' ); - -new TestCase( SECTION, - "MYOB2 = new MyValuelessObject(DATE1); MYOB3 + new String('string')", - DATE1.toString() + "string", - MYOB2 + new String('string') ); -/* - new TestCase( SECTION, - "MYOB3 = new MyProtolessObject(DATE1); MYOB3 + new Boolean(true)", - DATE1.toString() + "true", - MYOB3 + new Boolean(true) ); -*/ - -test(); - -function MyProtoValuelessObject() { - this.valueOf = new Function ( "" ); - this.__proto__ = null; -} -function MyProtolessObject( value ) { - this.valueOf = new Function( "return this.value" ); - this.__proto__ = null; - this.value = value; -} -function MyValuelessObject(value) { - this.__proto__ = new MyPrototypeObject(value); -} -function MyPrototypeObject(value) { - this.valueOf = new Function( "return this.value;" ); - this.toString = new Function( "return (this.value + '');" ); - this.value = value; -} -function MyObject( value ) { - this.valueOf = new Function( "return this.value" ); - this.value = value; -} diff --git a/tests/auto/declarative/parserstress/tests/ecma/extensions/11.6.2-1.js b/tests/auto/declarative/parserstress/tests/ecma/extensions/11.6.2-1.js deleted file mode 100644 index be8a6f6c98..0000000000 --- a/tests/auto/declarative/parserstress/tests/ecma/extensions/11.6.2-1.js +++ /dev/null @@ -1,124 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is Mozilla Communicator client code, released - * March 31, 1998. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -gTestfile = '11.6.2-1.js'; - -/** - File Name: 11.6.2-1.js - ECMA Section: 11.6.2 The Subtraction operator ( - ) - Description: - - The production AdditiveExpression : AdditiveExpression - - MultiplicativeExpression is evaluated as follows: - - 1. Evaluate AdditiveExpression. - 2. Call GetValue(Result(1)). - 3. Evaluate MultiplicativeExpression. - 4. Call GetValue(Result(3)). - 5. Call ToNumber(Result(2)). - 6. Call ToNumber(Result(4)). - 7. Apply the subtraction operation to Result(5) and Result(6). See the - discussion below (11.6.3). - 8. Return Result(7). - - Author: christine@netscape.com - Date: 12 november 1997 -*/ -var SECTION = "11.6.2-1"; -var VERSION = "ECMA_1"; -startTest(); - -writeHeaderToLog( SECTION + " The subtraction operator ( - )"); - -// tests "MyValuelessObject", where the value is -// set in the object's prototype, not the object itself. - - -new TestCase( SECTION, - "var EXP_1 = new MyValuelessObject(true); var EXP_2 = new MyValuelessObject(false); EXP_1 - EXP_2", - 1, - eval("var EXP_1 = new MyValuelessObject(true); var EXP_2 = new MyValuelessObject(false); EXP_1 - EXP_2") ); - -new TestCase( SECTION, - "var EXP_1 = new MyValuelessObject(new Boolean(true)); var EXP_2 = new MyValuelessObject(new Boolean(false)); EXP_1 - EXP_2", - Number.NaN, - eval("var EXP_1 = new MyValuelessObject(new Boolean(true)); var EXP_2 = new MyValuelessObject(new Boolean(false)); EXP_1 - EXP_2") ); - -// tests "MyValuelessObject", where the value is -// set in the object's prototype, not the object itself. - -new TestCase( SECTION, - "var EXP_1 = new MyValuelessObject(100); var EXP_2 = new MyValuelessObject(1); EXP_1 - EXP_2", - 99, - eval("var EXP_1 = new MyValuelessObject(100); var EXP_2 = new MyValuelessObject(1); EXP_1 - EXP_2") ); -/* - new TestCase( SECTION, - "var EXP_1 = new MyValuelessObject(new Number(100)); var EXP_2 = new MyValuelessObject(new Number(1)); EXP_1 - EXP_2", - Number.NaN, - eval("var EXP_1 = new MyValuelessObject(new Number(100)); var EXP_2 = new MyValuelessObject(new Number(1)); EXP_1 - EXP_2") ); -*/ -// same thing with string! - -test(); - -function MyProtoValuelessObject() { - this.valueOf = new Function ( "" ); - this.__proto__ = null; -} -function MyProtolessObject( value ) { - this.valueOf = new Function( "return this.value" ); - this.__proto__ = null; - this.value = value; -} -function MyValuelessObject(value) { - this.__proto__ = new MyPrototypeObject(value); -} -function MyPrototypeObject(value) { - this.valueOf = new Function( "return this.value;" ); - this.toString = new Function( "return (this.value + '');" ); - this.value = value; -} -function MyObject( value ) { - this.valueOf = new Function( "return this.value" ); - this.value = value; -} -function MyOtherObject( value ) { - this.valueOf = new Function( "return this.value" ); - this.toString = new Function ( "return this.value + ''" ); - this.value = value; -} diff --git a/tests/auto/declarative/parserstress/tests/ecma/extensions/15-1.js b/tests/auto/declarative/parserstress/tests/ecma/extensions/15-1.js deleted file mode 100644 index fc037873a5..0000000000 --- a/tests/auto/declarative/parserstress/tests/ecma/extensions/15-1.js +++ /dev/null @@ -1,94 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is Mozilla Communicator client code, released - * March 31, 1998. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -gTestfile = '15-1.js'; - -/** - File Name: 15.js - ECMA Section: 15 Native ECMAScript Objects - Description: Every built-in prototype object has the Object prototype - object, which is the value of the expression - Object.prototype (15.2.3.1) as the value of its internal - [[Prototype]] property, except the Object prototype - object itself. - - Every native object associated with a program-created - function also has the Object prototype object as the - value of its internal [[Prototype]] property. - - Author: christine@netscape.com - Date: 28 october 1997 - -*/ -var SECTION = "15-1"; -var VERSION = "ECMA_1"; -startTest(); -var TITLE = "Native ECMAScript Objects"; - -writeHeaderToLog( SECTION + " "+ TITLE); -/* - new TestCase( SECTION, "Function.prototype.__proto__", Object.prototype, Function.prototype.__proto__ ); - new TestCase( SECTION, "Array.prototype.__proto__", Object.prototype, Array.prototype.__proto__ ); - new TestCase( SECTION, "String.prototype.__proto__", Object.prototype, String.prototype.__proto__ ); - new TestCase( SECTION, "Boolean.prototype.__proto__", Object.prototype, Boolean.prototype.__proto__ ); - new TestCase( SECTION, "Number.prototype.__proto__", Object.prototype, Number.prototype.__proto__ ); -// new TestCase( SECTION, "Math.prototype.__proto__", Object.prototype, Math.prototype.__proto__ ); -new TestCase( SECTION, "Date.prototype.__proto__", Object.prototype, Date.prototype.__proto__ ); -new TestCase( SECTION, "TestCase.prototype.__proto__", Object.prototype, TestCase.prototype.__proto__ ); - -new TestCase( SECTION, "MyObject.prototype.__proto__", Object.prototype, MyObject.prototype.__proto__ ); -*/ -new TestCase( SECTION, "Function.prototype.__proto__ == Object.prototype", true, Function.prototype.__proto__ == Object.prototype ); -new TestCase( SECTION, "Array.prototype.__proto__ == Object.prototype", true, Array.prototype.__proto__ == Object.prototype ); -new TestCase( SECTION, "String.prototype.__proto__ == Object.prototype", true, String.prototype.__proto__ == Object.prototype ); -new TestCase( SECTION, "Boolean.prototype.__proto__ == Object.prototype", true, Boolean.prototype.__proto__ == Object.prototype ); -new TestCase( SECTION, "Number.prototype.__proto__ == Object.prototype", true, Number.prototype.__proto__ == Object.prototype ); -// new TestCase( SECTION, "Math.prototype.__proto__ == Object.prototype", true, Math.prototype.__proto__ == Object.prototype ); -new TestCase( SECTION, "Date.prototype.__proto__ == Object.prototype", true, Date.prototype.__proto__ == Object.prototype ); -new TestCase( SECTION, "TestCase.prototype.__proto__ == Object.prototype", true, TestCase.prototype.__proto__ == Object.prototype ); - -new TestCase( SECTION, "MyObject.prototype.__proto__ == Object.prototype", true, MyObject.prototype.__proto__ == Object.prototype ); - - -test(); - - -function MyObject( value ) { - this.value = value; - this.valueOf = new Function( "return this.value" ); -} diff --git a/tests/auto/declarative/parserstress/tests/ecma/extensions/15-2.js b/tests/auto/declarative/parserstress/tests/ecma/extensions/15-2.js deleted file mode 100644 index e403e46e8e..0000000000 --- a/tests/auto/declarative/parserstress/tests/ecma/extensions/15-2.js +++ /dev/null @@ -1,77 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is Mozilla Communicator client code, released - * March 31, 1998. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -gTestfile = '15-2.js'; - -/** - File Name: 15-2.js - ECMA Section: 15 Native ECMAScript Objects - - Description: Every built-in function and every built-in constructor - has the Function prototype object, which is the value of - the expression Function.prototype as the value of its - internal [[Prototype]] property, except the Function - prototype object itself. - - That is, the __proto__ property of builtin functions and - constructors should be the Function.prototype object. - - Author: christine@netscape.com - Date: 28 october 1997 - -*/ -var SECTION = "15-2"; -var VERSION = "ECMA_1"; -startTest(); -var TITLE = "Native ECMAScript Objects"; - -writeHeaderToLog( SECTION + " "+ TITLE); - -new TestCase( SECTION, "Object.__proto__", Function.prototype, Object.__proto__ ); -new TestCase( SECTION, "Array.__proto__", Function.prototype, Array.__proto__ ); -new TestCase( SECTION, "String.__proto__", Function.prototype, String.__proto__ ); -new TestCase( SECTION, "Boolean.__proto__", Function.prototype, Boolean.__proto__ ); -new TestCase( SECTION, "Number.__proto__", Function.prototype, Number.__proto__ ); -new TestCase( SECTION, "Date.__proto__", Function.prototype, Date.__proto__ ); -new TestCase( SECTION, "TestCase.__proto__", Function.prototype, TestCase.__proto__ ); - -new TestCase( SECTION, "eval.__proto__", Function.prototype, eval.__proto__ ); -new TestCase( SECTION, "Math.pow.__proto__", Function.prototype, Math.pow.__proto__ ); -new TestCase( SECTION, "String.prototype.indexOf.__proto__", Function.prototype, String.prototype.indexOf.__proto__ ); - -test(); diff --git a/tests/auto/declarative/parserstress/tests/ecma/extensions/15.1.2.1-1.js b/tests/auto/declarative/parserstress/tests/ecma/extensions/15.1.2.1-1.js deleted file mode 100644 index c3fe679e5e..0000000000 --- a/tests/auto/declarative/parserstress/tests/ecma/extensions/15.1.2.1-1.js +++ /dev/null @@ -1,88 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is Mozilla Communicator client code, released - * March 31, 1998. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -gTestfile = '15.1.2.1-1.js'; - -/** - File Name: 15.1.2.1-1.js - ECMA Section: 15.1.2.1 eval(x) - - if x is not a string object, return x. - Description: - Author: christine@netscape.com - Date: 16 september 1997 -*/ -var SECTION = "15.1.2.1-1"; -var VERSION = "ECMA_1"; -var TITLE = "eval(x)"; -var BUGNUMBER = "none"; - -startTest(); - -writeHeaderToLog( SECTION + " "+ TITLE); - -new TestCase( SECTION, "eval.length", 1, eval.length ); -new TestCase( SECTION, "delete eval.length", false, delete eval.length ); -new TestCase( SECTION, "var PROPS = ''; for ( p in eval ) { PROPS += p }; PROPS", "prototype", eval("var PROPS = ''; for ( p in eval ) { PROPS += p }; PROPS") ); -new TestCase( SECTION, "eval.length = null; eval.length", 1, eval( "eval.length = null; eval.length") ); -// new TestCase( SECTION, "eval.__proto__", Function.prototype, eval.__proto__ ); - -// test cases where argument is not a string. should return the argument. - -new TestCase( SECTION, "eval()", void 0, eval() ); -new TestCase( SECTION, "eval(void 0)", void 0, eval( void 0) ); -new TestCase( SECTION, "eval(null)", null, eval( null ) ); -new TestCase( SECTION, "eval(true)", true, eval( true ) ); -new TestCase( SECTION, "eval(false)", false, eval( false ) ); - -new TestCase( SECTION, "typeof eval(new String('Infinity/-0')", "object", typeof eval(new String('Infinity/-0')) ); - -new TestCase( SECTION, "eval([1,2,3,4,5,6])", "1,2,3,4,5,6", ""+eval([1,2,3,4,5,6]) ); -new TestCase( SECTION, "eval(new Array(0,1,2,3)", "1,2,3", ""+ eval(new Array(1,2,3)) ); -new TestCase( SECTION, "eval(1)", 1, eval(1) ); -new TestCase( SECTION, "eval(0)", 0, eval(0) ); -new TestCase( SECTION, "eval(-1)", -1, eval(-1) ); -new TestCase( SECTION, "eval(Number.NaN)", Number.NaN, eval(Number.NaN) ); -new TestCase( SECTION, "eval(Number.MIN_VALUE)", 5e-308, eval(Number.MIN_VALUE) ); -new TestCase( SECTION, "eval(-Number.MIN_VALUE)", -5e-308, eval(-Number.MIN_VALUE) ); -new TestCase( SECTION, "eval(Number.POSITIVE_INFINITY)", Number.POSITIVE_INFINITY, eval(Number.POSITIVE_INFINITY) ); -new TestCase( SECTION, "eval(Number.NEGATIVE_INFINITY)", Number.NEGATIVE_INFINITY, eval(Number.NEGATIVE_INFINITY) ); -new TestCase( SECTION, "eval( 4294967296 )", 4294967296, eval(4294967296) ); -new TestCase( SECTION, "eval( 2147483648 )", 2147483648, eval(2147483648) ); - -test(); diff --git a/tests/auto/declarative/parserstress/tests/ecma/extensions/15.2.1.1.js b/tests/auto/declarative/parserstress/tests/ecma/extensions/15.2.1.1.js deleted file mode 100644 index f4f821877d..0000000000 --- a/tests/auto/declarative/parserstress/tests/ecma/extensions/15.2.1.1.js +++ /dev/null @@ -1,82 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is Mozilla Communicator client code, released - * March 31, 1998. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -gTestfile = '15.2.1.1.js'; - -/** - File Name: 15.2.1.1.js - ECMA Section: 15.2.1.1 The Object Constructor Called as a Function: - Object(value) - Description: When Object is called as a function rather than as a - constructor, the following steps are taken: - - 1. If value is null or undefined, create and return a - new object with no properties other than internal - properties exactly as if the object constructor - had been called on that same value (15.2.2.1). - 2. Return ToObject (value), whose rules are: - - undefined generate a runtime error - null generate a runtime error - boolean create a new Boolean object whose default - value is the value of the boolean. - number Create a new Number object whose default - value is the value of the number. - string Create a new String object whose default - value is the value of the string. - object Return the input argument (no conversion). - - Author: christine@netscape.com - Date: 17 july 1997 -*/ - -var SECTION = "15.2.1.1"; -var VERSION = "ECMA_1"; -startTest(); -var TITLE = "Object( value )"; - -writeHeaderToLog( SECTION + " "+ TITLE); - - -var NULL_OBJECT = Object(null); - -new TestCase( SECTION, "Object(null).__proto__", Object.prototype, (Object(null)).__proto__ ); - -new TestCase( SECTION, "Object(void 0).__proto__", Object.prototype, (Object(void 0)).__proto__ ); - -test(); diff --git a/tests/auto/declarative/parserstress/tests/ecma/extensions/15.2.3-1.js b/tests/auto/declarative/parserstress/tests/ecma/extensions/15.2.3-1.js deleted file mode 100644 index 6d49db2481..0000000000 --- a/tests/auto/declarative/parserstress/tests/ecma/extensions/15.2.3-1.js +++ /dev/null @@ -1,64 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is Mozilla Communicator client code, released - * March 31, 1998. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -gTestfile = '15.2.3-1.js'; - -/** - File Name: 15.2.3-1.js - ECMA Section: 15.2.3 Properties of the Object Constructor - - Description: The value of the internal [[Prototype]] property of the - Object constructor is the Function prototype object. - - Besides the call and construct propreties and the length - property, the Object constructor has properties described - in 15.2.3.1. - - Author: christine@netscape.com - Date: 28 october 1997 - -*/ -var SECTION = "15.2.3"; -var VERSION = "ECMA_2"; -startTest(); - -writeHeaderToLog( SECTION + " Properties of the Object Constructor"); - -new TestCase( SECTION, "Object.__proto__", Function.prototype, Object.__proto__ ); - -test(); diff --git a/tests/auto/declarative/parserstress/tests/ecma/extensions/15.2.4.js b/tests/auto/declarative/parserstress/tests/ecma/extensions/15.2.4.js deleted file mode 100644 index df55e0894a..0000000000 --- a/tests/auto/declarative/parserstress/tests/ecma/extensions/15.2.4.js +++ /dev/null @@ -1,66 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is Mozilla Communicator client code, released - * March 31, 1998. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -gTestfile = '15.2.4.js'; - -/** - File Name: 15.2.4.js - ECMA Section: 15.2.4 Properties of the Object prototype object - - Description: The value of the internal [[Prototype]] property of - the Object prototype object is null - - Author: christine@netscape.com - Date: 28 october 1997 - -*/ - -var SECTION = "15.2.4"; -var VERSION = "ECMA_2"; -startTest(); -var TITLE = "Properties of the Object.prototype object"; - -writeHeaderToLog( SECTION + " "+ TITLE); - -new TestCase( SECTION, - "Object.prototype.__proto__", - null, - Object.prototype.__proto__ ); - -test(); - diff --git a/tests/auto/declarative/parserstress/tests/ecma/extensions/15.3.1.1-1.js b/tests/auto/declarative/parserstress/tests/ecma/extensions/15.3.1.1-1.js deleted file mode 100644 index 169cf50851..0000000000 --- a/tests/auto/declarative/parserstress/tests/ecma/extensions/15.3.1.1-1.js +++ /dev/null @@ -1,82 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is Mozilla Communicator client code, released - * March 31, 1998. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -gTestfile = '15.3.1.1-1.js'; - -/** - File Name: 15.3.1.1.js - ECMA Section: 15.3.1.1 The Function Constructor Called as a Function - - Description: - When the Function function is called with some arguments p1, p2, . . . , pn, body - (where n might be 0, that is, there are no "p" arguments, and where body might - also not be provided), the following steps are taken: - - 1. Create and return a new Function object exactly if the function constructor had - been called with the same arguments (15.3.2.1). - - Author: christine@netscape.com - Date: 28 october 1997 - -*/ -var SECTION = "15.3.1.1-1"; -var VERSION = "ECMA_1"; -startTest(); -var TITLE = "The Function Constructor Called as a Function"; - -writeHeaderToLog( SECTION + " "+ TITLE); - -var MyObject = Function( "value", "this.value = value; this.valueOf = Function( 'return this.value' ); this.toString = Function( 'return String(this.value);' )" ); - - -var myfunc = Function(); -myfunc.toString = Object.prototype.toString; - -// not going to test toString here since it is implementation dependent. -// new TestCase( SECTION, "myfunc.toString()", "function anonymous() { }", myfunc.toString() ); - -myfunc.toString = Object.prototype.toString; - -new TestCase( SECTION, - "MyObject.__proto__ == Function.prototype", - true, - MyObject.__proto__ == Function.prototype ); - -test(); - - diff --git a/tests/auto/declarative/parserstress/tests/ecma/extensions/15.3.1.1-2.js b/tests/auto/declarative/parserstress/tests/ecma/extensions/15.3.1.1-2.js deleted file mode 100644 index 42165465bc..0000000000 --- a/tests/auto/declarative/parserstress/tests/ecma/extensions/15.3.1.1-2.js +++ /dev/null @@ -1,82 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is Mozilla Communicator client code, released - * March 31, 1998. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -gTestfile = '15.3.1.1-2.js'; - -/** - File Name: 15.3.1.1-2.js - ECMA Section: 15.3.1.1 The Function Constructor Called as a Function - Function(p1, p2, ..., pn, body ) - - Description: - When the Function function is called with some arguments p1, p2, . . . , pn, - body (where n might be 0, that is, there are no "p" arguments, and where body - might also not be provided), the following steps are taken: - - 1. Create and return a new Function object exactly if the function constructor - had been called with the same arguments (15.3.2.1). - - Author: christine@netscape.com - Date: 28 october 1997 - -*/ -var SECTION = "15.3.1.1-2"; -var VERSION = "ECMA_1"; -startTest(); -var TITLE = "The Function Constructor Called as a Function"; - -writeHeaderToLog( SECTION + " "+ TITLE); - -var myfunc2 = Function("a, b, c", "return a+b+c" ); -var myfunc3 = Function("a,b", "c", "return a+b+c" ); - -myfunc2.toString = Object.prototype.toString; -myfunc3.toString = Object.prototype.toString; - - -new TestCase( SECTION, - "myfunc2.__proto__", - Function.prototype, - myfunc2.__proto__ ); - -new TestCase( SECTION, - "myfunc3.__proto__", - Function.prototype, - myfunc3.__proto__ ); - -test(); diff --git a/tests/auto/declarative/parserstress/tests/ecma/extensions/15.3.2.1-1.js b/tests/auto/declarative/parserstress/tests/ecma/extensions/15.3.2.1-1.js deleted file mode 100644 index fab359211f..0000000000 --- a/tests/auto/declarative/parserstress/tests/ecma/extensions/15.3.2.1-1.js +++ /dev/null @@ -1,72 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is Mozilla Communicator client code, released - * March 31, 1998. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -gTestfile = '15.3.2.1-1.js'; - -/** - File Name: 15.3.2.1.js - ECMA Section: 15.3.2.1 The Function Constructor - new Function(p1, p2, ..., pn, body ) - - Description: The last argument specifies the body (executable code) - of a function; any preceeding arguments sepcify formal - parameters. - - See the text for description of this section. - - This test examples from the specification. - - Author: christine@netscape.com - Date: 28 october 1997 - -*/ -var SECTION = "15.3.2.1"; -var VERSION = "ECMA_1"; -startTest(); -var TITLE = "The Function Constructor"; - -writeHeaderToLog( SECTION + " "+ TITLE); - -var MyObject = new Function( "value", "this.value = value; this.valueOf = new Function( 'return this.value' ); this.toString = new Function( 'return String(this.value);' )" ); - -new TestCase( SECTION, - "MyObject.__proto__ == Function.prototype", - true, - MyObject.__proto__ == Function.prototype ); - -test(); diff --git a/tests/auto/declarative/parserstress/tests/ecma/extensions/15.3.2.1-2.js b/tests/auto/declarative/parserstress/tests/ecma/extensions/15.3.2.1-2.js deleted file mode 100644 index 0b37e21028..0000000000 --- a/tests/auto/declarative/parserstress/tests/ecma/extensions/15.3.2.1-2.js +++ /dev/null @@ -1,72 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is Mozilla Communicator client code, released - * March 31, 1998. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -gTestfile = '15.3.2.1-2.js'; - -/** - File Name: 15.3.2.1.js - ECMA Section: 15.3.2.1 The Function Constructor - new Function(p1, p2, ..., pn, body ) - - Description: - Author: christine@netscape.com - Date: 28 october 1997 - -*/ -var SECTION = "15.3.2.1-2"; -var VERSION = "ECMA_1"; -startTest(); -var TITLE = "The Function Constructor"; - -writeHeaderToLog( SECTION + " "+ TITLE); - - -var myfunc1 = new Function("a","b","c", "return a+b+c" ); -var myfunc2 = new Function("a, b, c", "return a+b+c" ); -var myfunc3 = new Function("a,b", "c", "return a+b+c" ); - -myfunc1.toString = Object.prototype.toString; -myfunc2.toString = Object.prototype.toString; -myfunc3.toString = Object.prototype.toString; - - -new TestCase( SECTION, "myfunc2.__proto__", Function.prototype, myfunc2.__proto__ ); - -new TestCase( SECTION, "myfunc3.__proto__", Function.prototype, myfunc3.__proto__ ); - -test(); diff --git a/tests/auto/declarative/parserstress/tests/ecma/extensions/15.3.3.1-1.js b/tests/auto/declarative/parserstress/tests/ecma/extensions/15.3.3.1-1.js deleted file mode 100644 index d4f22ff257..0000000000 --- a/tests/auto/declarative/parserstress/tests/ecma/extensions/15.3.3.1-1.js +++ /dev/null @@ -1,67 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is Mozilla Communicator client code, released - * March 31, 1998. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -gTestfile = '15.3.3.1-1.js'; - -/** - File Name: 15.3.3.1-1.js - ECMA Section: 15.3.3.1 Properties of the Function Constructor - Function.prototype - - Description: The initial value of Function.prototype is the built-in - Function prototype object. - - This property shall have the attributes [DontEnum | - DontDelete | ReadOnly] - - This test the value of Function.prototype. - - Author: christine@netscape.com - Date: 28 october 1997 - -*/ -var SECTION = "15.3.3.1-1"; -var VERSION = "ECMA_2"; -startTest(); -var TITLE = "Function.prototype"; - -writeHeaderToLog( SECTION + " "+ TITLE); - -new TestCase( SECTION, "Function.prototype == Function.__proto__", true, Function.__proto__ == Function.prototype ); - -test(); diff --git a/tests/auto/declarative/parserstress/tests/ecma/extensions/15.4.3.js b/tests/auto/declarative/parserstress/tests/ecma/extensions/15.4.3.js deleted file mode 100644 index 8cbf949855..0000000000 --- a/tests/auto/declarative/parserstress/tests/ecma/extensions/15.4.3.js +++ /dev/null @@ -1,63 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is Mozilla Communicator client code, released - * March 31, 1998. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -gTestfile = '15.4.3.js'; - -/** - File Name: 15.4.3.js - ECMA Section: 15.4.3 Properties of the Array Constructor - Description: The value of the internal [[Prototype]] property of the - Array constructor is the Function prototype object. - - Author: christine@netscape.com - Date: 7 october 1997 -*/ - -var SECTION = "15.4.3"; -var VERSION = "ECMA_2"; -startTest(); -var TITLE = "Properties of the Array Constructor"; - -writeHeaderToLog( SECTION + " "+ TITLE); - -new TestCase( SECTION, - "Array.__proto__", - Function.prototype, - Array.__proto__ ); - -test(); diff --git a/tests/auto/declarative/parserstress/tests/ecma/extensions/15.5.3.js b/tests/auto/declarative/parserstress/tests/ecma/extensions/15.5.3.js deleted file mode 100644 index c25398c4f4..0000000000 --- a/tests/auto/declarative/parserstress/tests/ecma/extensions/15.5.3.js +++ /dev/null @@ -1,66 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is Mozilla Communicator client code, released - * March 31, 1998. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -gTestfile = '15.5.3.js'; - -/** - File Name: 15.5.3.1.js - ECMA Section: 15.5.3 Properties of the String Constructor - - Description: The value of the internal [[Prototype]] property of - the String constructor is the Function prototype - object. - - In addition to the internal [[Call]] and [[Construct]] - properties, the String constructor also has the length - property, as well as properties described in 15.5.3.1 - and 15.5.3.2. - - Author: christine@netscape.com - Date: 1 october 1997 -*/ - -var SECTION = "15.5.3"; -var VERSION = "ECMA_2"; -startTest(); -var passed = true; -writeHeaderToLog( SECTION + " Properties of the String Constructor" ); - -new TestCase( SECTION, "String.prototype", Function.prototype, String.__proto__ ); - -test(); diff --git a/tests/auto/declarative/parserstress/tests/ecma/extensions/15.5.4.2.js b/tests/auto/declarative/parserstress/tests/ecma/extensions/15.5.4.2.js deleted file mode 100644 index ebf4d03781..0000000000 --- a/tests/auto/declarative/parserstress/tests/ecma/extensions/15.5.4.2.js +++ /dev/null @@ -1,59 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is Mozilla Communicator client code, released - * March 31, 1998. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -gTestfile = '15.5.4.2.js'; - -/** - File Name: 15.5.4.2.js - ECMA Section: 15.5.4.2 String.prototype.toString - - Description: - Author: christine@netscape.com - Date: 28 october 1997 - -*/ -var SECTION = "15.5.4.2"; -var VERSION = "ECMA_1"; -startTest(); -var TITLE = "String.prototype.tostring"; - -writeHeaderToLog( SECTION + " "+ TITLE); - -new TestCase( SECTION, "String.prototype.toString.__proto__", Function.prototype, String.prototype.toString.__proto__ ); - -test(); diff --git a/tests/auto/declarative/parserstress/tests/ecma/extensions/15.5.4.4-4.js b/tests/auto/declarative/parserstress/tests/ecma/extensions/15.5.4.4-4.js deleted file mode 100644 index c2e115e0c6..0000000000 --- a/tests/auto/declarative/parserstress/tests/ecma/extensions/15.5.4.4-4.js +++ /dev/null @@ -1,107 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is Mozilla Communicator client code, released - * March 31, 1998. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -gTestfile = '15.5.4.4-4.js'; - -/** - File Name: 15.5.4.4-4.js - ECMA Section: 15.5.4.4 String.prototype.charAt(pos) - Description: Returns a string containing the character at position - pos in the string. If there is no character at that - string, the result is the empty string. The result is - a string value, not a String object. - - When the charAt method is called with one argument, - pos, the following steps are taken: - 1. Call ToString, with this value as its argument - 2. Call ToInteger pos - 3. Compute the number of characters in Result(1) - 4. If Result(2) is less than 0 is or not less than - Result(3), return the empty string - 5. Return a string of length 1 containing one character - from result (1), the character at position Result(2). - - Note that the charAt function is intentionally generic; - it does not require that its this value be a String - object. Therefore it can be transferred to other kinds - of objects for use as a method. - - This tests assiging charAt to primitive types.. - - Author: christine@netscape.com - Date: 2 october 1997 -*/ -var SECTION = "15.5.4.4-4"; -var VERSION = "ECMA_2"; -startTest(); -var TITLE = "String.prototype.charAt"; - -writeHeaderToLog( SECTION + " "+ TITLE); - -/* - new TestCase( SECTION, "x = null; x.__proto.charAt = String.prototype.charAt; x.charAt(0)", "n", eval("x=null; x.__proto__.charAt = String.prototype.charAt; x.charAt(0)") ); - new TestCase( SECTION, "x = null; x.__proto.charAt = String.prototype.charAt; x.charAt(1)", "u", eval("x=null; x.__proto__.charAt = String.prototype.charAt; x.charAt(1)") ); - new TestCase( SECTION, "x = null; x.__proto.charAt = String.prototype.charAt; x.charAt(2)", "l", eval("x=null; x.__proto__.charAt = String.prototype.charAt; x.charAt(2)") ); - new TestCase( SECTION, "x = null; x.__proto.charAt = String.prototype.charAt; x.charAt(3)", "l", eval("x=null; x.__proto__.charAt = String.prototype.charAt; x.charAt(3)") ); - - new TestCase( SECTION, "x = undefined; x.__proto.charAt = String.prototype.charAt; x.charAt(0)", "u", eval("x=undefined; x.__proto__.charAt = String.prototype.charAt; x.charAt(0)") ); - new TestCase( SECTION, "x = undefined; x.__proto.charAt = String.prototype.charAt; x.charAt(1)", "n", eval("x=undefined; x.__proto__.charAt = String.prototype.charAt; x.charAt(1)") ); - new TestCase( SECTION, "x = undefined; x.__proto.charAt = String.prototype.charAt; x.charAt(2)", "d", eval("x=undefined; x.__proto__.charAt = String.prototype.charAt; x.charAt(2)") ); - new TestCase( SECTION, "x = undefined; x.__proto.charAt = String.prototype.charAt; x.charAt(3)", "e", eval("x=undefined; x.__proto__.charAt = String.prototype.charAt; x.charAt(3)") ); -*/ -new TestCase( SECTION, "x = false; x.__proto.charAt = String.prototype.charAt; x.charAt(0)", "f", eval("x=false; x.__proto__.charAt = String.prototype.charAt; x.charAt(0)") ); -new TestCase( SECTION, "x = false; x.__proto.charAt = String.prototype.charAt; x.charAt(1)", "a", eval("x=false; x.__proto__.charAt = String.prototype.charAt; x.charAt(1)") ); -new TestCase( SECTION, "x = false; x.__proto.charAt = String.prototype.charAt; x.charAt(2)", "l", eval("x=false; x.__proto__.charAt = String.prototype.charAt; x.charAt(2)") ); -new TestCase( SECTION, "x = false; x.__proto.charAt = String.prototype.charAt; x.charAt(3)", "s", eval("x=false; x.__proto__.charAt = String.prototype.charAt; x.charAt(3)") ); -new TestCase( SECTION, "x = false; x.__proto.charAt = String.prototype.charAt; x.charAt(4)", "e", eval("x=false; x.__proto__.charAt = String.prototype.charAt; x.charAt(4)") ); - -new TestCase( SECTION, "x = true; x.__proto.charAt = String.prototype.charAt; x.charAt(0)", "t", eval("x=true; x.__proto__.charAt = String.prototype.charAt; x.charAt(0)") ); -new TestCase( SECTION, "x = true; x.__proto.charAt = String.prototype.charAt; x.charAt(1)", "r", eval("x=true; x.__proto__.charAt = String.prototype.charAt; x.charAt(1)") ); -new TestCase( SECTION, "x = true; x.__proto.charAt = String.prototype.charAt; x.charAt(2)", "u", eval("x=true; x.__proto__.charAt = String.prototype.charAt; x.charAt(2)") ); -new TestCase( SECTION, "x = true; x.__proto.charAt = String.prototype.charAt; x.charAt(3)", "e", eval("x=true; x.__proto__.charAt = String.prototype.charAt; x.charAt(3)") ); - -new TestCase( SECTION, "x = NaN; x.__proto.charAt = String.prototype.charAt; x.charAt(0)", "N", eval("x=NaN; x.__proto__.charAt = String.prototype.charAt; x.charAt(0)") ); -new TestCase( SECTION, "x = NaN; x.__proto.charAt = String.prototype.charAt; x.charAt(1)", "a", eval("x=NaN; x.__proto__.charAt = String.prototype.charAt; x.charAt(1)") ); -new TestCase( SECTION, "x = NaN; x.__proto.charAt = String.prototype.charAt; x.charAt(2)", "N", eval("x=NaN; x.__proto__.charAt = String.prototype.charAt; x.charAt(2)") ); - -new TestCase( SECTION, "x = 123; x.__proto.charAt = String.prototype.charAt; x.charAt(0)", "1", eval("x=123; x.__proto__.charAt = String.prototype.charAt; x.charAt(0)") ); -new TestCase( SECTION, "x = 123; x.__proto.charAt = String.prototype.charAt; x.charAt(1)", "2", eval("x=123; x.__proto__.charAt = String.prototype.charAt; x.charAt(1)") ); -new TestCase( SECTION, "x = 123; x.__proto.charAt = String.prototype.charAt; x.charAt(2)", "3", eval("x=123; x.__proto__.charAt = String.prototype.charAt; x.charAt(2)") ); - - -test(); diff --git a/tests/auto/declarative/parserstress/tests/ecma/extensions/15.5.4.5-6.js b/tests/auto/declarative/parserstress/tests/ecma/extensions/15.5.4.5-6.js deleted file mode 100644 index 4eadc66c04..0000000000 --- a/tests/auto/declarative/parserstress/tests/ecma/extensions/15.5.4.5-6.js +++ /dev/null @@ -1,94 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is Mozilla Communicator client code, released - * March 31, 1998. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -gTestfile = '15.5.4.5-6.js'; - -/** - File Name: 15.5.4.5-6.js - ECMA Section: 15.5.4.5 String.prototype.charCodeAt(pos) - Description: Returns a number (a nonnegative integer less than 2^16) - representing the Unicode encoding of the character at - position pos in this string. If there is no character - at that position, the number is NaN. - - When the charCodeAt method is called with one argument - pos, the following steps are taken: - 1. Call ToString, giving it the theis value as its - argument - 2. Call ToInteger(pos) - 3. Compute the number of characters in result(1). - 4. If Result(2) is less than 0 or is not less than - Result(3), return NaN. - 5. Return a value of Number type, of positive sign, whose - magnitude is the Unicode encoding of one character - from result 1, namely the characer at position Result - (2), where the first character in Result(1) is - considered to be at position 0. - - Note that the charCodeAt funciton is intentionally - generic; it does not require that its this value be a - String object. Therefore it can be transferred to other - kinds of objects for use as a method. - - Author: christine@netscape.com - Date: 2 october 1997 -*/ -var SECTION = "15.5.4.5-6"; -var VERSION = "ECMA_2"; -startTest(); -var TITLE = "String.prototype.charCodeAt"; - -writeHeaderToLog( SECTION + " "+ TITLE); - - -new TestCase( SECTION, - "var obj = true; obj.__proto__.charCodeAt = String.prototype.charCodeAt; var s = ''; for ( var i = 0; i < 4; i++ ) s+= String.fromCharCode( obj.charCodeAt(i) ); s", - "true", - eval("var obj = true; obj.__proto__.charCodeAt = String.prototype.charCodeAt; var s = ''; for ( var i = 0; i < 4; i++ ) s+= String.fromCharCode( obj.charCodeAt(i) ); s") ); - -new TestCase( SECTION, - "var obj = 1234; obj.__proto__.charCodeAt = String.prototype.charCodeAt; var s = ''; for ( var i = 0; i < 4; i++ ) s+= String.fromCharCode( obj.charCodeAt(i) ); s", - "1234", - eval("var obj = 1234; obj.__proto__.charCodeAt = String.prototype.charCodeAt; var s = ''; for ( var i = 0; i < 4; i++ ) s+= String.fromCharCode( obj.charCodeAt(i) ); s") ); - -new TestCase( SECTION, - "var obj = 'hello'; obj.__proto__.charCodeAt = String.prototype.charCodeAt; var s = ''; for ( var i = 0; i < 5; i++ ) s+= String.fromCharCode( obj.charCodeAt(i) ); s", - "hello", - eval("var obj = 'hello'; obj.__proto__.charCodeAt = String.prototype.charCodeAt; var s = ''; for ( var i = 0; i < 5; i++ ) s+= String.fromCharCode( obj.charCodeAt(i) ); s") ); - -test(); diff --git a/tests/auto/declarative/parserstress/tests/ecma/extensions/15.5.4.7-3.js b/tests/auto/declarative/parserstress/tests/ecma/extensions/15.5.4.7-3.js deleted file mode 100644 index c5832fd477..0000000000 --- a/tests/auto/declarative/parserstress/tests/ecma/extensions/15.5.4.7-3.js +++ /dev/null @@ -1,161 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is Mozilla Communicator client code, released - * March 31, 1998. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -gTestfile = '15.5.4.7-3.js'; - -/** - File Name: 15.5.4.7-3.js - ECMA Section: 15.5.4.7 String.prototype.lastIndexOf( searchString, pos) - Description: - - If the given searchString appears as a substring of the result of - converting this object to a string, at one or more positions that are - at or to the left of the specified position, then the index of the - rightmost such position is returned; otherwise -1 is returned. If position - is undefined or not supplied, the length of this string value is assumed, - so as to search all of the string. - - When the lastIndexOf method is called with two arguments searchString and - position, the following steps are taken: - - 1.Call ToString, giving it the this value as its argument. - 2.Call ToString(searchString). - 3.Call ToNumber(position). (If position is undefined or not supplied, this step produces the value NaN). - 4.If Result(3) is NaN, use +; otherwise, call ToInteger(Result(3)). - 5.Compute the number of characters in Result(1). - 6.Compute min(max(Result(4), 0), Result(5)). - 7.Compute the number of characters in the string that is Result(2). - 8.Compute the largest possible integer k not larger than Result(6) such that k+Result(7) is not greater - than Result(5), and for all nonnegative integers j less than Result(7), the character at position k+j of - Result(1) is the same as the character at position j of Result(2); but if there is no such integer k, then - compute the value -1. - - 1.Return Result(8). - - Note that the lastIndexOf function is intentionally generic; it does not require that its this value be a - String object. Therefore it can be transferred to other kinds of objects for use as a method. - - Author: christine@netscape.com - Date: 2 october 1997 -*/ -var SECTION = "15.5.4.7-3"; -var VERSION = "ECMA_2"; -startTest(); -var TITLE = "String.protoype.lastIndexOf"; - -writeHeaderToLog( SECTION + " "+ TITLE); - -new TestCase( SECTION, - "var b = true; b.__proto__.lastIndexOf = String.prototype.lastIndexOf; b.lastIndexOf('r', 0 )", - -1, - eval("var b = true; b.__proto__.lastIndexOf = String.prototype.lastIndexOf; b.lastIndexOf('r', 0 )") ); - -new TestCase( SECTION, - "var b = true; b.__proto__.lastIndexOf = String.prototype.lastIndexOf; b.lastIndexOf('r', 1 )", - 1, - eval("var b = true; b.__proto__.lastIndexOf = String.prototype.lastIndexOf; b.lastIndexOf('r', 1 )") ); - -new TestCase( SECTION, - "var b = true; b.__proto__.lastIndexOf = String.prototype.lastIndexOf; b.lastIndexOf('r', 2 )", - 1, - eval("var b = true; b.__proto__.lastIndexOf = String.prototype.lastIndexOf; b.lastIndexOf('r', 2 )") ); - -new TestCase( SECTION, - "var b = true; b.__proto__.lastIndexOf = String.prototype.lastIndexOf; b.lastIndexOf('r', 10 )", - 1, - eval("var b = true; b.__proto__.lastIndexOf = String.prototype.lastIndexOf; b.lastIndexOf('r', 10 )") ); - -new TestCase( SECTION, - "var b = true; b.__proto__.lastIndexOf = String.prototype.lastIndexOf; b.lastIndexOf('r' )", - 1, - eval("var b = true; b.__proto__.lastIndexOf = String.prototype.lastIndexOf; b.lastIndexOf('r' )") ); - -test(); - -function LastIndexOf( string, search, position ) { - string = String( string ); - search = String( search ); - - position = Number( position ) - - if ( isNaN( position ) ) { - position = Infinity; - } else { - position = ToInteger( position ); - } - - result5= string.length; - result6 = Math.min(Math.max(position, 0), result5); - result7 = search.length; - - if (result7 == 0) { - return Math.min(position, result5); - } - - result8 = -1; - - for ( k = 0; k <= result6; k++ ) { - if ( k+ result7 > result5 ) { - break; - } - for ( j = 0; j < result7; j++ ) { - if ( string.charAt(k+j) != search.charAt(j) ){ - break; - } else { - if ( j == result7 -1 ) { - result8 = k; - } - } - } - } - - return result8; -} -function ToInteger( n ) { - n = Number( n ); - if ( isNaN(n) ) { - return 0; - } - if ( Math.abs(n) == 0 || Math.abs(n) == Infinity ) { - return n; - } - - var sign = ( n < 0 ) ? -1 : 1; - - return ( sign * Math.floor(Math.abs(n)) ); -} diff --git a/tests/auto/declarative/parserstress/tests/ecma/extensions/15.6.3.1-5.js b/tests/auto/declarative/parserstress/tests/ecma/extensions/15.6.3.1-5.js deleted file mode 100644 index b9f35b8225..0000000000 --- a/tests/auto/declarative/parserstress/tests/ecma/extensions/15.6.3.1-5.js +++ /dev/null @@ -1,58 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is Mozilla Communicator client code, released - * March 31, 1998. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -gTestfile = '15.6.3.1-5.js'; - -/** - File Name: 15.6.3.1-5.js - ECMA Section: 15.6.3.1 Boolean.prototype - Description: - Author: christine@netscape.com - Date: 28 october 1997 - -*/ -var VERSION = "ECMA_2"; -startTest(); -var SECTION = "15.6.3.1-5"; -var TITLE = "Boolean.prototype" - - writeHeaderToLog( SECTION + " " + TITLE ); - -new TestCase( SECTION, "Function.prototype == Boolean.__proto__", true, Function.prototype == Boolean.__proto__ ); - -test(); diff --git a/tests/auto/declarative/parserstress/tests/ecma/extensions/15.6.3.js b/tests/auto/declarative/parserstress/tests/ecma/extensions/15.6.3.js deleted file mode 100644 index 0ae48c59f2..0000000000 --- a/tests/auto/declarative/parserstress/tests/ecma/extensions/15.6.3.js +++ /dev/null @@ -1,65 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is Mozilla Communicator client code, released - * March 31, 1998. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -gTestfile = '15.6.3.js'; - -/** - File Name: 15.6.3.js - ECMA Section: 15.6.3 Properties of the Boolean Constructor - - Description: The value of the internal prototype property is - the Function prototype object. - - It has the internal [[Call]] and [[Construct]] - properties, and the length property. - - Author: christine@netscape.com - Date: june 27, 1997 - -*/ -var SECTION = "15.6.3"; -var VERSION = "ECMA_2"; -startTest(); -var TITLE = "Properties of the Boolean Constructor" - writeHeaderToLog( SECTION + TITLE ); - - -new TestCase( SECTION, "Boolean.__proto__ == Function.prototype", true, Boolean.__proto__ == Function.prototype ); -new TestCase( SECTION, "Boolean.length", 1, Boolean.length ); - -test(); diff --git a/tests/auto/declarative/parserstress/tests/ecma/extensions/15.6.4-2.js b/tests/auto/declarative/parserstress/tests/ecma/extensions/15.6.4-2.js deleted file mode 100644 index 7ca222235f..0000000000 --- a/tests/auto/declarative/parserstress/tests/ecma/extensions/15.6.4-2.js +++ /dev/null @@ -1,66 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is Mozilla Communicator client code, released - * March 31, 1998. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -gTestfile = '15.6.4-2.js'; - -/** - File Name: 15.6.4-2.js - ECMA Section: 15.6.4 Properties of the Boolean Prototype Object - - Description: - The Boolean prototype object is itself a Boolean object (its [[Class]] is - "Boolean") whose value is false. - - The value of the internal [[Prototype]] property of the Boolean prototype object - is the Object prototype object (15.2.3.1). - - Author: christine@netscape.com - Date: 30 september 1997 - -*/ - - -var VERSION = "ECMA_2" - startTest(); -var SECTION = "15.6.4-2"; - -writeHeaderToLog( SECTION + " Properties of the Boolean Prototype Object"); - -new TestCase( SECTION, "Boolean.prototype.__proto__", Object.prototype, Boolean.prototype.__proto__ ); - -test(); diff --git a/tests/auto/declarative/parserstress/tests/ecma/extensions/15.7.3.js b/tests/auto/declarative/parserstress/tests/ecma/extensions/15.7.3.js deleted file mode 100644 index 84e362c2db..0000000000 --- a/tests/auto/declarative/parserstress/tests/ecma/extensions/15.7.3.js +++ /dev/null @@ -1,69 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is Mozilla Communicator client code, released - * March 31, 1998. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -gTestfile = '15.7.3.js'; - -/** - File Name: 15.7.3.js - 15.7.3 Properties of the Number Constructor - - Description: The value of the internal [[Prototype]] property - of the Number constructor is the Function prototype - object. The Number constructor also has the internal - [[Call]] and [[Construct]] properties, and the length - property. - - Other properties are in subsequent tests. - - Author: christine@netscape.com - Date: 29 september 1997 -*/ - -var SECTION = "15.7.3"; -var VERSION = "ECMA_2"; -startTest(); -var TITLE = "Properties of the Number Constructor"; - -writeHeaderToLog( SECTION + " "+ TITLE); - -new TestCase(SECTION, - "Number.__proto__", - Function.prototype, - Number.__proto__ ); - -test(); diff --git a/tests/auto/declarative/parserstress/tests/ecma/extensions/15.7.4.js b/tests/auto/declarative/parserstress/tests/ecma/extensions/15.7.4.js deleted file mode 100644 index 733b937e55..0000000000 --- a/tests/auto/declarative/parserstress/tests/ecma/extensions/15.7.4.js +++ /dev/null @@ -1,90 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is Mozilla Communicator client code, released - * March 31, 1998. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -gTestfile = '15.7.4.js'; - -/** - File Name: 15.7.4.js - ECMA Section: 15.7.4 - - Description: - - The Number prototype object is itself a Number object (its [[Class]] is - "Number") whose value is +0. - - The value of the internal [[Prototype]] property of the Number prototype - object is the Object prototype object (15.2.3.1). - - In following descriptions of functions that are properties of the Number - prototype object, the phrase "this Number object" refers to the object - that is the this value for the invocation of the function; it is an error - if this does not refer to an object for which the value of the internal - [[Class]] property is "Number". Also, the phrase "this number value" refers - to the number value represented by this Number object, that is, the value - of the internal [[Value]] property of this Number object. - - Author: christine@netscape.com - Date: 12 november 1997 -*/ -var SECTION = "15.7.4"; -var VERSION = "ECMA_1"; -startTest(); -var TITLE = "Properties of the Number Prototype Object"; - -writeHeaderToLog( SECTION + " "+TITLE); - -new TestCase( SECTION, - "Number.prototype.toString=Object.prototype.toString;Number.prototype.toString()", - "[object Number]", - eval("Number.prototype.toString=Object.prototype.toString;Number.prototype.toString()") ); - -new TestCase( SECTION, - "typeof Number.prototype", - "object", - typeof Number.prototype ); - -new TestCase( SECTION, - "Number.prototype.valueOf()", - 0, - Number.prototype.valueOf() ); - -// The __proto__ property cannot be used in ECMA_1 tests. -// new TestCase( SECTION, "Number.prototype.__proto__", Object.prototype, Number.prototype.__proto__ ); -// new TestCase( SECTION, "Number.prototype.__proto__ == Object.prototype", true, Number.prototype.__proto__ == Object.prototype ); - -test(); diff --git a/tests/auto/declarative/parserstress/tests/ecma/extensions/15.8-1.js b/tests/auto/declarative/parserstress/tests/ecma/extensions/15.8-1.js deleted file mode 100644 index 0f51cf5e61..0000000000 --- a/tests/auto/declarative/parserstress/tests/ecma/extensions/15.8-1.js +++ /dev/null @@ -1,84 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is Mozilla Communicator client code, released - * March 31, 1998. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -gTestfile = '15.8-1.js'; - -/** - File Name: 15.8-1.js - ECMA Section: 15.8 The Math Object - - Description: - - The Math object is merely a single object that has some named properties, - some of which are functions. - - The value of the internal [[Prototype]] property of the Math object is the - Object prototype object (15.2.3.1). - - The Math object does not have a [[Construct]] property; it is not possible - to use the Math object as a constructor with the new operator. - - The Math object does not have a [[Call]] property; it is not possible to - invoke the Math object as a function. - - Recall that, in this specification, the phrase "the number value for x" has - a technical meaning defined in section 8.5. - - Author: christine@netscape.com - Date: 12 november 1997 - -*/ - -var SECTION = "15.8-1"; -var VERSION = "ECMA_2"; -startTest(); -var TITLE = "The Math Object"; - -writeHeaderToLog( SECTION + " "+ TITLE); - -new TestCase( SECTION, - "Math.__proto__ == Object.prototype", - true, - Math.__proto__ == Object.prototype ); - -new TestCase( SECTION, - "Math.__proto__", - Object.prototype, - Math.__proto__ ); - -test(); diff --git a/tests/auto/declarative/parserstress/tests/ecma/extensions/15.9.5.js b/tests/auto/declarative/parserstress/tests/ecma/extensions/15.9.5.js deleted file mode 100644 index 54e6bb6f0f..0000000000 --- a/tests/auto/declarative/parserstress/tests/ecma/extensions/15.9.5.js +++ /dev/null @@ -1,76 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is Mozilla Communicator client code, released - * March 31, 1998. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -gTestfile = '15.9.5.js'; - -/** - File Name: 15.9.5.js - ECMA Section: 15.9.5 Properties of the Date prototype object - Description: - - The Date prototype object is itself a Date object (its [[Class]] is - "Date") whose value is NaN. - - The value of the internal [[Prototype]] property of the Date prototype - object is the Object prototype object (15.2.3.1). - - In following descriptions of functions that are properties of the Date - prototype object, the phrase "this Date object" refers to the object that - is the this value for the invocation of the function; it is an error if - this does not refer to an object for which the value of the internal - [[Class]] property is "Date". Also, the phrase "this time value" refers - to the number value for the time represented by this Date object, that is, - the value of the internal [[Value]] property of this Date object. - - Author: christine@netscape.com - Date: 12 november 1997 -*/ - -var SECTION = "15.9.5"; -var VERSION = "ECMA_1"; -startTest(); -var TITLE = "Properties of the Date Prototype Object"; - -writeHeaderToLog( SECTION + " "+ TITLE); - -new TestCase( SECTION, - "Date.prototype.__proto__ == Object.prototype", - true, - Date.prototype.__proto__ == Object.prototype ); -test(); - diff --git a/tests/auto/declarative/parserstress/tests/ecma/extensions/8.6.2.1-1.js b/tests/auto/declarative/parserstress/tests/ecma/extensions/8.6.2.1-1.js deleted file mode 100644 index a99bb01ee6..0000000000 --- a/tests/auto/declarative/parserstress/tests/ecma/extensions/8.6.2.1-1.js +++ /dev/null @@ -1,98 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is Mozilla Communicator client code, released - * March 31, 1998. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -gTestfile = '8.6.2.1-1.js'; - -/** - File Name: 8.6.2.1-1.js - ECMA Section: 8.6.2.1 Get (Value) - Description: - - When the [[Get]] method of O is called with property name P, the following - steps are taken: - - 1. If O doesn't have a property with name P, go to step 4. - 2. Get the value of the property. - 3. Return Result(2). - 4. If the [[Prototype]] of O is null, return undefined. - 5. Call the [[Get]] method of [[Prototype]] with property name P. - 6. Return Result(5). - - This tests [[Get]] (Value). - - Author: christine@netscape.com - Date: 12 november 1997 -*/ -var SECTION = "8.6.2.1-1"; -var VERSION = "ECMA_1"; -startTest(); - -writeHeaderToLog( SECTION + " [[Get]] (Value)"); - -new TestCase( SECTION, "var OBJ = new MyValuelessObject(true); OBJ.valueOf()", true, eval("var OBJ = new MyValuelessObject(true); OBJ.valueOf()") ); -// new TestCase( SECTION, "var OBJ = new MyProtoValuelessObject(true); OBJ + ''", "undefined", eval("var OBJ = new MyProtoValuelessObject(); OBJ + ''") ); -new TestCase( SECTION, "var OBJ = new MyProtolessObject(true); OBJ.valueOf()", true, eval("var OBJ = new MyProtolessObject(true); OBJ.valueOf()") ); - -new TestCase( SECTION, "var OBJ = new MyValuelessObject(Number.POSITIVE_INFINITY); OBJ.valueOf()", Number.POSITIVE_INFINITY, eval("var OBJ = new MyValuelessObject(Number.POSITIVE_INFINITY); OBJ.valueOf()") ); -// new TestCase( SECTION, "var OBJ = new MyProtoValuelessObject(Number.POSITIVE_INFINITY); OBJ + ''", "undefined", eval("var OBJ = new MyProtoValuelessObject(); OBJ + ''") ); -new TestCase( SECTION, "var OBJ = new MyProtolessObject(Number.POSITIVE_INFINITY); OBJ.valueOf()", Number.POSITIVE_INFINITY, eval("var OBJ = new MyProtolessObject(Number.POSITIVE_INFINITY); OBJ.valueOf()") ); - -new TestCase( SECTION, "var OBJ = new MyValuelessObject('string'); OBJ.valueOf()", 'string', eval("var OBJ = new MyValuelessObject('string'); OBJ.valueOf()") ); -// new TestCase( SECTION, "var OBJ = new MyProtoValuelessObject('string'); OJ + ''", "undefined", eval("var OBJ = new MyProtoValuelessObject(); OBJ + ''") ); -new TestCase( SECTION, "var OBJ = new MyProtolessObject('string'); OBJ.valueOf()", 'string', eval("var OBJ = new MyProtolessObject('string'); OBJ.valueOf()") ); - -test(); - -function MyProtoValuelessObject(value) { - this.valueOf = new Function ( "" ); - this.__proto__ = null; -} - -function MyProtolessObject( value ) { - this.valueOf = new Function( "return this.value" ); - this.__proto__ = null; - this.value = value; -} -function MyValuelessObject(value) { - this.__proto__ = new MyPrototypeObject(value); -} -function MyPrototypeObject(value) { - this.valueOf = new Function( "return this.value;" ); - this.toString = new Function( "return (this.value + '');" ); - this.value = value; -} diff --git a/tests/auto/declarative/parserstress/tests/ecma/extensions/9.9-1.js b/tests/auto/declarative/parserstress/tests/ecma/extensions/9.9-1.js deleted file mode 100644 index 0df44013cd..0000000000 --- a/tests/auto/declarative/parserstress/tests/ecma/extensions/9.9-1.js +++ /dev/null @@ -1,102 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is Mozilla Communicator client code, released - * March 31, 1998. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -gTestfile = '9.9-1.js'; - -/** - File Name: 9.9-1.js - ECMA Section: 9.9 Type Conversion: ToObject - Description: - - undefined generate a runtime error - null generate a runtime error - boolean create a new Boolean object whose default - value is the value of the boolean. - number Create a new Number object whose default - value is the value of the number. - string Create a new String object whose default - value is the value of the string. - object Return the input argument (no conversion). - Author: christine@netscape.com - Date: 17 july 1997 -*/ - -var VERSION = "ECMA_1"; -startTest(); -var SECTION = "9.9-1"; - -writeHeaderToLog( SECTION + " Type Conversion: ToObject" ); - -new TestCase( SECTION, "(Object(true)).__proto__", Boolean.prototype, (Object(true)).__proto__ ); - -new TestCase( SECTION, "(Object(true)).__proto__", Boolean.prototype, (Object(true)).__proto__ ); - -new TestCase( SECTION, "(Object(0)).__proto__", Number.prototype, (Object(0)).__proto__ ); - -new TestCase( SECTION, "(Object(-0)).__proto__", Number.prototype, (Object(-0)).__proto__ ); - -new TestCase( SECTION, "(Object(1)).__proto__", Number.prototype, (Object(1)).__proto__ ); - -new TestCase( SECTION, "(Object(-1)).__proto__", Number.prototype, (Object(-1)).__proto__ ); - -new TestCase( SECTION, "(Object(Number.MAX_VALUE)).__proto__", Number.prototype, (Object(Number.MAX_VALUE)).__proto__ ); - -new TestCase( SECTION, "(Object(Number.MIN_VALUE)).__proto__", Number.prototype, (Object(Number.MIN_VALUE)).__proto__ ); - -new TestCase( SECTION, "(Object(Number.POSITIVE_INFINITY)).__proto__", Number.prototype, (Object(Number.POSITIVE_INFINITY)).__proto__ ); - -new TestCase( SECTION, "(Object(Number.NEGATIVE_INFINITY)).__proto__", Number.prototype, (Object(Number.NEGATIVE_INFINITY)).__proto__ ); - -new TestCase( SECTION, "(Object(Number.NaN)).__proto__", Number.prototype, (Object(Number.NaN)).__proto__ ); - -new TestCase( SECTION, "(Object('a string')).__proto__", String.prototype, (Object("a string")).__proto__ ); - -new TestCase( SECTION, "(Object('')).__proto__", String.prototype, (Object("")).__proto__ ); - -new TestCase( SECTION, "(Object('\\r\\t\\b\\n\\v\\f')).__proto__", String.prototype, (Object("\\r\\t\\b\\n\\v\\f")).__proto__ ); - -new TestCase( SECTION, "Object( '\\\'\\\"\\' ).__proto__", String.prototype, (Object("\'\"\\")).__proto__ ); - -new TestCase( SECTION, "(Object( new MyObject(true) )).toString()", "[object Object]", eval("(Object( new MyObject(true) )).toString()") ); - -test(); - -function MyObject( value ) { - this.value = value; - this.valueOf = new Function ( "return this.value" ); -} diff --git a/tests/auto/declarative/parserstress/tests/ecma/extensions/browser.js b/tests/auto/declarative/parserstress/tests/ecma/extensions/browser.js deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/tests/auto/declarative/parserstress/tests/ecma/extensions/shell.js b/tests/auto/declarative/parserstress/tests/ecma/extensions/shell.js deleted file mode 100644 index 3f52cffbc0..0000000000 --- a/tests/auto/declarative/parserstress/tests/ecma/extensions/shell.js +++ /dev/null @@ -1 +0,0 @@ -gTestsubsuite = 'extensions'; diff --git a/tests/auto/declarative/parserstress/tests/ecma/jsref.js b/tests/auto/declarative/parserstress/tests/ecma/jsref.js deleted file mode 100644 index 1416643e1e..0000000000 --- a/tests/auto/declarative/parserstress/tests/ecma/jsref.js +++ /dev/null @@ -1,634 +0,0 @@ -var completed = false; -var testcases; -var tc = 0; - -SECTION = ""; -VERSION = ""; -BUGNUMBER = ""; -TITLE = ""; - -/* - * constant strings - */ -var GLOBAL = "[object global]"; -var PASSED = " PASSED!" -var FAILED = " FAILED! expected: "; -var DEBUG = false; - -TZ_DIFF = -8; - -var TT = ""; -var TT_ = ""; -var BR = ""; -var NBSP = " "; -var CR = "\n"; -var FONT = ""; -var FONT_ = ""; -var FONT_RED = ""; -var FONT_GREEN = ""; -var B = ""; -var B_ = "" -var H2 = ""; -var H2_ = ""; -var HR = ""; -var DEBUG = false; - -var PASSED = " PASSED!" -var FAILED = " FAILED! expected: "; - -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); -} -/* wrapper for test cas constructor that doesn't require the SECTION - * argument. - */ - -function AddTestCase( description, expect, actual ) { - testcases[tc++] = new TestCase( SECTION, description, expect, actual ); -} - -function TestCase( n, d, e, a ) { - this.name = n; - this.description = d; - this.expect = e; - this.actual = a; - this.passed = true; - this.reason = ""; - this.bugnumber = BUGNUMBER; - - this.passed = getTestCaseResult( this.expect, this.actual ); - if ( DEBUG ) { - print( "added " + this.description ); - } - - testcases[tc++] = this; -} - -/* - * Set up test environment. - * - */ -function startTest() { - if ( version ) { - // JavaScript 1.3 is supposed to be compliant ecma version 1.0 - if ( VERSION == "ECMA_1" ) { - version ( "130" ); - } - if ( VERSION == "JS_1.3" ) { - version ( "130" ); - } - if ( VERSION == "JS_1.2" ) { - version ( "120" ); - } - if ( VERSION == "JS_1.1" ) { - version ( "110" ); - } - // for ecma version 2.0, we will leave the javascript version to - // the default ( for now ). - } - - // print out bugnumber - - if ( BUGNUMBER ) { - print ("BUGNUMBER: " + BUGNUMBER ); - } - - testcases = new Array(); - tc = 0; -} - - -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ testcases[tc].actual ); - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); -} - - -function getTestCaseResult( expect, actual ) { - // because ( NaN == NaN ) always returns false, need to do - // a special compare to see if we got the right result. - if ( actual != actual ) { - if ( typeof actual == "object" ) { - actual = "NaN object"; - } else { - actual = "NaN number"; - } - } - if ( expect != expect ) { - if ( typeof expect == "object" ) { - expect = "NaN object"; - } else { - expect = "NaN number"; - } - } - - var passed = ( expect == actual ) ? true : false; - - // if both objects are numbers - // need to replace w/ IEEE standard for rounding - if ( !passed - && typeof(actual) == "number" - && typeof(expect) == "number" - ) { - if ( Math.abs(actual-expect) < 0.0000001 ) { - passed = true; - } - } - - // verify type is the same - if ( typeof(expect) != typeof(actual) ) { - passed = false; - } - - return passed; -} -function writeTestCaseResult( expect, actual, string ) { - var passed = getTestCaseResult( expect, actual ); - writeFormattedResult( expect, actual, string, passed ); - return passed; -} -function writeFormattedResult( expect, actual, string, passed ) { - var s = TT + string ; - - for ( k = 0; - k < (60 - string.length >= 0 ? 60 - string.length : 5) ; - k++ ) { - } - - s += B ; - s += ( passed ) ? FONT_GREEN + NBSP + PASSED : FONT_RED + NBSP + FAILED + expect + TT_ ; - - print( s + FONT_ + B_ + TT_ ); - - return passed; -} - -function writeHeaderToLog( string ) { - print( H2 + string + H2_ ); -} -function stopTest() -{ - var sizeTag = "<#TEST CASES SIZE>"; - var doneTag = "<#TEST CASES DONE>"; - var beginTag = "<#TEST CASE "; - var endTag = ">"; - - print(sizeTag); - print(testcases.length); - for (tc = 0; tc < testcases.length; tc++) - { - print(beginTag + 'PASSED' + endTag); - print(testcases[tc].passed); - print(beginTag + 'NAME' + endTag); - print(testcases[tc].name); - print(beginTag + 'EXPECTED' + endTag); - print(testcases[tc].expect); - print(beginTag + 'ACTUAL' + endTag); - print(testcases[tc].actual); - print(beginTag + 'DESCRIPTION' + endTag); - print(testcases[tc].description); - print(beginTag + 'REASON' + endTag); - print(( testcases[tc].passed ) ? "" : "wrong value "); - print(beginTag + 'BUGNUMBER' + endTag); - print( BUGNUMBER ); - } - print(doneTag); - print( HR ); - gc(); -} -function getFailedCases() { - for ( var i = 0; i < testcases.length; i++ ) { - if ( ! testcases[i].passed ) { - print( testcases[i].description +" = " +testcases[i].actual +" expected: "+ testcases[i].expect ); - } - } -} -function err( msg, page, line ) { - testcases[tc].actual = "error"; - testcases[tc].reason = msg; - writeTestCaseResult( testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ testcases[tc].actual + - ": " + testcases[tc].reason ); - stopTest(); - return true; -} - -/** - * Type Conversion functions used by Type Conversion - * - */ - - - - /* - * Date functions used by tests in Date suite - * - */ -var msPerDay = 86400000; -var HoursPerDay = 24; -var MinutesPerHour = 60; -var SecondsPerMinute = 60; -var msPerSecond = 1000; -var msPerMinute = 60000; // msPerSecond * SecondsPerMinute -var msPerHour = 3600000; // msPerMinute * MinutesPerHour - -var TIME_1970 = 0; -var TIME_2000 = 946684800000; -var TIME_1900 = -2208988800000; - -function Day( t ) { - return ( Math.floor(t/msPerDay ) ); -} -function DaysInYear( y ) { - if ( y % 4 != 0 ) { - return 365; - } - if ( (y % 4 == 0) && (y % 100 != 0) ) { - return 366; - } - if ( (y % 100 == 0) && (y % 400 != 0) ) { - return 365; - } - if ( (y % 400 == 0) ){ - return 366; - } else { - return "ERROR: DaysInYear(" + y + ") case not covered"; - } -} -function TimeInYear( y ) { - return ( DaysInYear(y) * msPerDay ); -} -function DayNumber( t ) { - return ( Math.floor( t / msPerDay ) ); -} -function TimeWithinDay( t ) { - if ( t < 0 ) { - return ( (t % msPerDay) + msPerDay ); - } else { - return ( t % msPerDay ); - } -} -function YearNumber( t ) { -} -function TimeFromYear( y ) { - return ( msPerDay * DayFromYear(y) ); -} -function DayFromYear( y ) { - return ( 365*(y-1970) + - Math.floor((y-1969)/4) - - Math.floor((y-1901)/100) + - Math.floor((y-1601)/400) ); -} -function InLeapYear( t ) { - if ( DaysInYear(YearFromTime(t)) == 365 ) { - return 0; - } - if ( DaysInYear(YearFromTime(t)) == 366 ) { - return 1; - } else { - return "ERROR: InLeapYear("+t+") case not covered"; - } -} -function YearFromTime( t ) { - t = Number( t ); - var sign = ( t < 0 ) ? -1 : 1; - var year = ( sign < 0 ) ? 1969 : 1970; - for ( var timeToTimeZero = t; ; ) { - // subtract the current year's time from the time that's left. - timeToTimeZero -= sign * TimeInYear(year) - - // if there's less than the current year's worth of time left, then break. - if ( sign < 0 ) { - if ( sign * timeToTimeZero <= 0 ) { - break; - } else { - year += sign; - } - } else { - if ( sign * timeToTimeZero < 0 ) { - break; - } else { - year += sign; - } - } - } - return ( year ); -} -function MonthFromTime( t ) { - // i know i could use switch but i'd rather not until it's part of ECMA - var day = DayWithinYear( t ); - var leap = InLeapYear(t); - - if ( (0 <= day) && (day < 31) ) { - return 0; - } - if ( (31 <= day) && (day < (59+leap)) ) { - return 1; - } - if ( ((59+leap) <= day) && (day < (90+leap)) ) { - return 2; - } - if ( ((90+leap) <= day) && (day < (120+leap)) ) { - return 3; - } - if ( ((120+leap) <= day) && (day < (151+leap)) ) { - return 4; - } - if ( ((151+leap) <= day) && (day < (181+leap)) ) { - return 5; - } - if ( ((181+leap) <= day) && (day < (212+leap)) ) { - return 6; - } - if ( ((212+leap) <= day) && (day < (243+leap)) ) { - return 7; - } - if ( ((243+leap) <= day) && (day < (273+leap)) ) { - return 8; - } - if ( ((273+leap) <= day) && (day < (304+leap)) ) { - return 9; - } - if ( ((304+leap) <= day) && (day < (334+leap)) ) { - return 10; - } - if ( ((334+leap) <= day) && (day < (365+leap)) ) { - return 11; - } else { - return "ERROR: MonthFromTime("+t+") not known"; - } -} -function DayWithinYear( t ) { - return( Day(t) - DayFromYear(YearFromTime(t))); -} -function DateFromTime( t ) { - var day = DayWithinYear(t); - var month = MonthFromTime(t); - - if ( month == 0 ) { - return ( day + 1 ); - } - if ( month == 1 ) { - return ( day - 30 ); - } - if ( month == 2 ) { - return ( day - 58 - InLeapYear(t) ); - } - if ( month == 3 ) { - return ( day - 89 - InLeapYear(t)); - } - if ( month == 4 ) { - return ( day - 119 - InLeapYear(t)); - } - if ( month == 5 ) { - return ( day - 150- InLeapYear(t)); - } - if ( month == 6 ) { - return ( day - 180- InLeapYear(t)); - } - if ( month == 7 ) { - return ( day - 211- InLeapYear(t)); - } - if ( month == 8 ) { - return ( day - 242- InLeapYear(t)); - } - if ( month == 9 ) { - return ( day - 272- InLeapYear(t)); - } - if ( month == 10 ) { - return ( day - 303- InLeapYear(t)); - } - if ( month == 11 ) { - return ( day - 333- InLeapYear(t)); - } - - return ("ERROR: DateFromTime("+t+") not known" ); -} -function WeekDay( t ) { - var weekday = (Day(t)+4) % 7; - return( weekday < 0 ? 7 + weekday : weekday ); -} - -// missing daylight savins time adjustment - -function HourFromTime( t ) { - var h = Math.floor( t / msPerHour ) % HoursPerDay; - return ( (h<0) ? HoursPerDay + h : h ); -} -function MinFromTime( t ) { - var min = Math.floor( t / msPerMinute ) % MinutesPerHour; - return( ( min < 0 ) ? MinutesPerHour + min : min ); -} -function SecFromTime( t ) { - var sec = Math.floor( t / msPerSecond ) % SecondsPerMinute; - return ( (sec < 0 ) ? SecondsPerMinute + sec : sec ); -} -function msFromTime( t ) { - var ms = t % msPerSecond; - return ( (ms < 0 ) ? msPerSecond + ms : ms ); -} -function LocalTZA() { - return ( TZ_DIFF * msPerHour ); -} -function UTC( t ) { - return ( t - LocalTZA() - DaylightSavingTA(t - LocalTZA()) ); -} -function DaylightSavingTA( t ) { - t = t - LocalTZA(); - - var dst_start = GetFirstSundayInApril(t) + 2*msPerHour; - var dst_end = GetLastSundayInOctober(t)+ 2*msPerHour; - - if ( t >= dst_start && t < dst_end ) { - return msPerHour; - } else { - return 0; - } - - // Daylight Savings Time starts on the first Sunday in April at 2:00AM in - // PST. Other time zones will need to override this function. - - print( new Date( UTC(dst_start + LocalTZA())) ); - - return UTC(dst_start + LocalTZA()); -} -function GetFirstSundayInApril( t ) { - var year = YearFromTime(t); - var leap = InLeapYear(t); - - var april = TimeFromYear(year) + TimeInMonth(0, leap) + TimeInMonth(1,leap) + - TimeInMonth(2,leap); - - for ( var first_sunday = april; WeekDay(first_sunday) > 0; - first_sunday += msPerDay ) - { - ; - } - - return first_sunday; -} -function GetLastSundayInOctober( t ) { - var year = YearFromTime(t); - var leap = InLeapYear(t); - - for ( var oct = TimeFromYear(year), m = 0; m < 9; m++ ) { - oct += TimeInMonth(m, leap); - } - for ( var last_sunday = oct + 30*msPerDay; WeekDay(last_sunday) > 0; - last_sunday -= msPerDay ) - { - ; - } - return last_sunday; -} -function LocalTime( t ) { - return ( t + LocalTZA() + DaylightSavingTA(t) ); -} -function MakeTime( hour, min, sec, ms ) { - if ( isNaN( hour ) || isNaN( min ) || isNaN( sec ) || isNaN( ms ) ) { - return Number.NaN; - } - - hour = ToInteger(hour); - min = ToInteger( min); - sec = ToInteger( sec); - ms = ToInteger( ms ); - - return( (hour*msPerHour) + (min*msPerMinute) + - (sec*msPerSecond) + ms ); -} -function MakeDay( year, month, date ) { - if ( isNaN(year) || isNaN(month) || isNaN(date) ) { - return Number.NaN; - } - year = ToInteger(year); - month = ToInteger(month); - date = ToInteger(date ); - - var sign = ( year < 1970 ) ? -1 : 1; - var t = ( year < 1970 ) ? 1 : 0; - var y = ( year < 1970 ) ? 1969 : 1970; - - var result5 = year + Math.floor( month/12 ); - var result6 = month % 12; - - if ( year < 1970 ) { - for ( y = 1969; y >= year; y += sign ) { - t += sign * TimeInYear(y); - } - } else { - for ( y = 1970 ; y < year; y += sign ) { - t += sign * TimeInYear(y); - } - } - - var leap = InLeapYear( t ); - - for ( var m = 0; m < month; m++ ) { - t += TimeInMonth( m, leap ); - } - - if ( YearFromTime(t) != result5 ) { - return Number.NaN; - } - if ( MonthFromTime(t) != result6 ) { - return Number.NaN; - } - if ( DateFromTime(t) != 1 ) { - return Number.NaN; - } - - return ( (Day(t)) + date - 1 ); -} -function TimeInMonth( month, leap ) { - // september april june november - // jan 0 feb 1 mar 2 apr 3 may 4 june 5 jul 6 - // aug 7 sep 8 oct 9 nov 10 dec 11 - - if ( month == 3 || month == 5 || month == 8 || month == 10 ) { - return ( 30*msPerDay ); - } - - // all the rest - if ( month == 0 || month == 2 || month == 4 || month == 6 || - month == 7 || month == 9 || month == 11 ) { - return ( 31*msPerDay ); - } - - // save february - return ( (leap == 0) ? 28*msPerDay : 29*msPerDay ); -} -function MakeDate( day, time ) { - if ( day == Number.POSITIVE_INFINITY || - day == Number.NEGATIVE_INFINITY || - day == Number.NaN ) { - return Number.NaN; - } - if ( time == Number.POSITIVE_INFINITY || - time == Number.POSITIVE_INFINITY || - day == Number.NaN) { - return Number.NaN; - } - return ( day * msPerDay ) + time; -} -function TimeClip( t ) { - if ( isNaN( t ) ) { - return ( Number.NaN ); - } - if ( Math.abs( t ) > 8.64e15 ) { - return ( Number.NaN ); - } - - return ( ToInteger( t ) ); -} -function ToInteger( t ) { - t = Number( t ); - - if ( isNaN( t ) ){ - return ( Number.NaN ); - } - if ( t == 0 || t == -0 || - t == Number.POSITIVE_INFINITY || t == Number.NEGATIVE_INFINITY ) { - return 0; - } - - var sign = ( t < 0 ) ? -1 : 1; - - return ( sign * Math.floor( Math.abs( t ) ) ); -} -function Enumerate ( o ) { - var properties = new Array(); - for ( p in o ) { - properties[ properties.length ] = new Array( p, o[p] ); - } - return properties; -} -function AddTestCase( description, expect, actual ) { - testcases[tc++] = new TestCase( SECTION, description, expect, actual ); -} - -function getFailedCases() { - for ( var i = 0; i < testcases.length; i++ ) { - if ( ! testcases[i].passed ) { - print( testcases[i].description +" = " +testcases[i].actual +" expected: "+ testcases[i].expect ); - } - } -} diff --git a/tests/auto/declarative/parserstress/tests/ecma/shell.js b/tests/auto/declarative/parserstress/tests/ecma/shell.js deleted file mode 100644 index 1c012601e6..0000000000 --- a/tests/auto/declarative/parserstress/tests/ecma/shell.js +++ /dev/null @@ -1,577 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is Mozilla Communicator client code, released - * March 31, 1998. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -gTestsuite = 'ecma'; - -/* - * Date functions used by tests in Date suite - * - */ -var msPerDay = 86400000; -var HoursPerDay = 24; -var MinutesPerHour = 60; -var SecondsPerMinute = 60; -var msPerSecond = 1000; -var msPerMinute = 60000; // msPerSecond * SecondsPerMinute -var msPerHour = 3600000; // msPerMinute * MinutesPerHour -var TZ_DIFF = getTimeZoneDiff(); // offset of tester's timezone from UTC -var TZ_ADJUST = TZ_DIFF * msPerHour; -var TZ_PST = -8; // offset of Pacific Standard Time from UTC -var PST_DIFF = TZ_DIFF - TZ_PST; // offset of tester's timezone from PST -var PST_ADJUST = TZ_PST * msPerHour; -var TIME_0000 = (function () - { // calculate time for year 0 - for ( var time = 0, year = 1969; year >= 0; year-- ) { - time -= TimeInYear(year); - } - return time; - })(); -var TIME_1970 = 0; -var TIME_2000 = 946684800000; -var TIME_1900 = -2208988800000; -var UTC_FEB_29_2000 = TIME_2000 + 31*msPerDay + 28*msPerDay; -var UTC_JAN_1_2005 = TIME_2000 + TimeInYear(2000) + TimeInYear(2001) + - TimeInYear(2002) + TimeInYear(2003) + TimeInYear(2004); -var now = new Date(); -var TIME_NOW = now.valueOf(); //valueOf() is to accurate to the millisecond - //Date.parse() is accurate only to the second - -/* - * Originally, the test suite used a hard-coded value TZ_DIFF = -8. - * But that was only valid for testers in the Pacific Standard Time Zone! - * We calculate the proper number dynamically for any tester. We just - * have to be careful not to use a date subject to Daylight Savings Time... - */ -function getTimeZoneDiff() -{ - return -((new Date(2000, 1, 1)).getTimezoneOffset())/60; -} - -/* - * Date test "ResultArrays" are hard-coded for Pacific Standard Time. - * We must adjust them for the tester's own timezone - - */ -function adjustResultArray(ResultArray, msMode) -{ - // If the tester's system clock is in PST, no need to continue - -// if (!PST_DIFF) {return;} - - /* The date gTestcases instantiate Date objects in two different ways: - * - * millisecond mode: e.g. dt = new Date(10000000); - * year-month-day mode: dt = new Date(2000, 5, 1, ...); - * - * In the first case, the date is measured from Time 0 in Greenwich (i.e. UTC). - * In the second case, it is measured with reference to the tester's local timezone. - * - * In the first case we must correct those values expected for local measurements, - * like dt.getHours() etc. No correction is necessary for dt.getUTCHours() etc. - * - * In the second case, it is exactly the other way around - - */ - if (msMode) - { - // The hard-coded UTC milliseconds from Time 0 derives from a UTC date. - // Shift to the right by the offset between UTC and the tester. - var t = ResultArray[TIME] + TZ_DIFF*msPerHour; - - // Use our date arithmetic functions to determine the local hour, day, etc. - ResultArray[HOURS] = HourFromTime(t); - ResultArray[DAY] = WeekDay(t); - ResultArray[DATE] = DateFromTime(t); - ResultArray[MONTH] = MonthFromTime(t); - ResultArray[YEAR] = YearFromTime(t); - } - else - { - // The hard-coded UTC milliseconds from Time 0 derives from a PST date. - // Shift to the left by the offset between PST and the tester. - var t = ResultArray[TIME] - PST_DIFF*msPerHour; - - // Use our date arithmetic functions to determine the UTC hour, day, etc. - ResultArray[TIME] = t; - ResultArray[UTC_HOURS] = HourFromTime(t); - ResultArray[UTC_DAY] = WeekDay(t); - ResultArray[UTC_DATE] = DateFromTime(t); - ResultArray[UTC_MONTH] = MonthFromTime(t); - ResultArray[UTC_YEAR] = YearFromTime(t); - } -} - -function Day( t ) { - return ( Math.floor(t/msPerDay ) ); -} -function DaysInYear( y ) { - if ( y % 4 != 0 ) { - return 365; - } - if ( (y % 4 == 0) && (y % 100 != 0) ) { - return 366; - } - if ( (y % 100 == 0) && (y % 400 != 0) ) { - return 365; - } - if ( (y % 400 == 0) ){ - return 366; - } else { - return "ERROR: DaysInYear(" + y + ") case not covered"; - } -} -function TimeInYear( y ) { - return ( DaysInYear(y) * msPerDay ); -} -function DayNumber( t ) { - return ( Math.floor( t / msPerDay ) ); -} -function TimeWithinDay( t ) { - if ( t < 0 ) { - return ( (t % msPerDay) + msPerDay ); - } else { - return ( t % msPerDay ); - } -} -function YearNumber( t ) { -} -function TimeFromYear( y ) { - return ( msPerDay * DayFromYear(y) ); -} -function DayFromYear( y ) { - return ( 365*(y-1970) + - Math.floor((y-1969)/4) - - Math.floor((y-1901)/100) + - Math.floor((y-1601)/400) ); -} -function InLeapYear( t ) { - if ( DaysInYear(YearFromTime(t)) == 365 ) { - return 0; - } - if ( DaysInYear(YearFromTime(t)) == 366 ) { - return 1; - } else { - return "ERROR: InLeapYear("+ t + ") case not covered"; - } -} -function YearFromTime( t ) { - t = Number( t ); - var sign = ( t < 0 ) ? -1 : 1; - var year = ( sign < 0 ) ? 1969 : 1970; - for ( var timeToTimeZero = t; ; ) { - // subtract the current year's time from the time that's left. - timeToTimeZero -= sign * TimeInYear(year) - - // if there's less than the current year's worth of time left, then break. - if ( sign < 0 ) { - if ( sign * timeToTimeZero <= 0 ) { - break; - } else { - year += sign; - } - } else { - if ( sign * timeToTimeZero < 0 ) { - break; - } else { - year += sign; - } - } - } - return ( year ); -} -function MonthFromTime( t ) { - // i know i could use switch but i'd rather not until it's part of ECMA - var day = DayWithinYear( t ); - var leap = InLeapYear(t); - - if ( (0 <= day) && (day < 31) ) { - return 0; - } - if ( (31 <= day) && (day < (59+leap)) ) { - return 1; - } - if ( ((59+leap) <= day) && (day < (90+leap)) ) { - return 2; - } - if ( ((90+leap) <= day) && (day < (120+leap)) ) { - return 3; - } - if ( ((120+leap) <= day) && (day < (151+leap)) ) { - return 4; - } - if ( ((151+leap) <= day) && (day < (181+leap)) ) { - return 5; - } - if ( ((181+leap) <= day) && (day < (212+leap)) ) { - return 6; - } - if ( ((212+leap) <= day) && (day < (243+leap)) ) { - return 7; - } - if ( ((243+leap) <= day) && (day < (273+leap)) ) { - return 8; - } - if ( ((273+leap) <= day) && (day < (304+leap)) ) { - return 9; - } - if ( ((304+leap) <= day) && (day < (334+leap)) ) { - return 10; - } - if ( ((334+leap) <= day) && (day < (365+leap)) ) { - return 11; - } else { - return "ERROR: MonthFromTime("+t+") not known"; - } -} -function DayWithinYear( t ) { - return( Day(t) - DayFromYear(YearFromTime(t))); -} -function DateFromTime( t ) { - var day = DayWithinYear(t); - var month = MonthFromTime(t); - - if ( month == 0 ) { - return ( day + 1 ); - } - if ( month == 1 ) { - return ( day - 30 ); - } - if ( month == 2 ) { - return ( day - 58 - InLeapYear(t) ); - } - if ( month == 3 ) { - return ( day - 89 - InLeapYear(t)); - } - if ( month == 4 ) { - return ( day - 119 - InLeapYear(t)); - } - if ( month == 5 ) { - return ( day - 150- InLeapYear(t)); - } - if ( month == 6 ) { - return ( day - 180- InLeapYear(t)); - } - if ( month == 7 ) { - return ( day - 211- InLeapYear(t)); - } - if ( month == 8 ) { - return ( day - 242- InLeapYear(t)); - } - if ( month == 9 ) { - return ( day - 272- InLeapYear(t)); - } - if ( month == 10 ) { - return ( day - 303- InLeapYear(t)); - } - if ( month == 11 ) { - return ( day - 333- InLeapYear(t)); - } - - return ("ERROR: DateFromTime("+t+") not known" ); -} -function WeekDay( t ) { - var weekday = (Day(t)+4) % 7; - return( weekday < 0 ? 7 + weekday : weekday ); -} - -// missing daylight savings time adjustment - -function HourFromTime( t ) { - var h = Math.floor( t / msPerHour ) % HoursPerDay; - return ( (h<0) ? HoursPerDay + h : h ); -} -function MinFromTime( t ) { - var min = Math.floor( t / msPerMinute ) % MinutesPerHour; - return( ( min < 0 ) ? MinutesPerHour + min : min ); -} -function SecFromTime( t ) { - var sec = Math.floor( t / msPerSecond ) % SecondsPerMinute; - return ( (sec < 0 ) ? SecondsPerMinute + sec : sec ); -} -function msFromTime( t ) { - var ms = t % msPerSecond; - return ( (ms < 0 ) ? msPerSecond + ms : ms ); -} -function LocalTZA() { - return ( TZ_DIFF * msPerHour ); -} -function UTC( t ) { - return ( t - LocalTZA() - DaylightSavingTA(t - LocalTZA()) ); -} -function LocalTime( t ) { - return ( t + LocalTZA() + DaylightSavingTA(t) ); -} -function DaylightSavingTA( t ) { - t = t - LocalTZA(); - - var dst_start = GetDSTStart(t); - var dst_end = GetDSTEnd(t); - - if ( t >= dst_start && t < dst_end ) - return msPerHour; - - return 0; -} - -function GetFirstSundayInMonth( t, m ) { - var year = YearFromTime(t); - var leap = InLeapYear(t); - -// month m 0..11 -// april == 3 -// march == 2 - - // set time to first day of month m - var time = TimeFromYear(year); - for (var i = 0; i < m; ++i) - { - time += TimeInMonth(i, leap); - } - - for ( var first_sunday = time; WeekDay(first_sunday) > 0; - first_sunday += msPerDay ) - { - ; - } - - return first_sunday; -} - -function GetLastSundayInMonth( t, m ) { - var year = YearFromTime(t); - var leap = InLeapYear(t); - -// month m 0..11 -// april == 3 -// march == 2 - - // first day of following month - var time = TimeFromYear(year); - for (var i = 0; i <= m; ++i) - { - time += TimeInMonth(i, leap); - } - // prev day == last day of month - time -= msPerDay; - - for ( var last_sunday = time; WeekDay(last_sunday) > 0; - last_sunday -= msPerDay ) - { - ; - } - return last_sunday; -} - -/* - 15.9.1.9 Daylight Saving Time Adjustment - - The implementation of ECMAScript should not try to determine whether - the exact time was subject to daylight saving time, but just whether - daylight saving time would have been in effect if the current - daylight saving time algorithm had been used at the time. This avoids - complications such as taking into account the years that the locale - observed daylight saving time year round. -*/ - -/* - US DST algorithm - - Before 2007, DST starts first Sunday in April at 2 AM and ends last - Sunday in October at 2 AM - - Starting in 2007, DST starts second Sunday in March at 2 AM and ends - first Sunday in November at 2 AM - - Note that different operating systems behave differently. - - Fully patched Windows XP uses the 2007 algorithm for all dates while - fully patched Fedora Core 6 and RHEL 4 Linux use the algorithm in - effect at the time. - - Since pre-2007 DST is a subset of 2007 DST rules, this only affects - tests that occur in the period Mar-Apr and Oct-Nov where the two - algorithms do not agree. - -*/ - -function GetDSTStart( t ) -{ - return (GetFirstSundayInMonth(t, 2) + 7*msPerDay + 2*msPerHour - LocalTZA()); -} - -function GetDSTEnd( t ) -{ - return (GetFirstSundayInMonth(t, 10) + 2*msPerHour - LocalTZA()); -} - -function GetOldDSTStart( t ) -{ - return (GetFirstSundayInMonth(t, 3) + 2*msPerHour - LocalTZA()); -} - -function GetOldDSTEnd( t ) -{ - return (GetLastSundayInMonth(t, 9) + 2*msPerHour - LocalTZA()); -} - -function MakeTime( hour, min, sec, ms ) { - if ( isNaN( hour ) || isNaN( min ) || isNaN( sec ) || isNaN( ms ) ) { - return Number.NaN; - } - - hour = ToInteger(hour); - min = ToInteger( min); - sec = ToInteger( sec); - ms = ToInteger( ms ); - - return( (hour*msPerHour) + (min*msPerMinute) + - (sec*msPerSecond) + ms ); -} -function MakeDay( year, month, date ) { - if ( isNaN(year) || isNaN(month) || isNaN(date) ) { - return Number.NaN; - } - year = ToInteger(year); - month = ToInteger(month); - date = ToInteger(date ); - - var sign = ( year < 1970 ) ? -1 : 1; - var t = ( year < 1970 ) ? 1 : 0; - var y = ( year < 1970 ) ? 1969 : 1970; - - var result5 = year + Math.floor( month/12 ); - var result6 = month % 12; - - if ( year < 1970 ) { - for ( y = 1969; y >= year; y += sign ) { - t += sign * TimeInYear(y); - } - } else { - for ( y = 1970 ; y < year; y += sign ) { - t += sign * TimeInYear(y); - } - } - - var leap = InLeapYear( t ); - - for ( var m = 0; m < month; m++ ) { - t += TimeInMonth( m, leap ); - } - - if ( YearFromTime(t) != result5 ) { - return Number.NaN; - } - if ( MonthFromTime(t) != result6 ) { - return Number.NaN; - } - if ( DateFromTime(t) != 1 ) { - return Number.NaN; - } - - return ( (Day(t)) + date - 1 ); -} -function TimeInMonth( month, leap ) { - // september april june november - // jan 0 feb 1 mar 2 apr 3 may 4 june 5 jul 6 - // aug 7 sep 8 oct 9 nov 10 dec 11 - - if ( month == 3 || month == 5 || month == 8 || month == 10 ) { - return ( 30*msPerDay ); - } - - // all the rest - if ( month == 0 || month == 2 || month == 4 || month == 6 || - month == 7 || month == 9 || month == 11 ) { - return ( 31*msPerDay ); - } - - // save february - return ( (leap == 0) ? 28*msPerDay : 29*msPerDay ); -} -function MakeDate( day, time ) { - if ( day == Number.POSITIVE_INFINITY || - day == Number.NEGATIVE_INFINITY ) { - return Number.NaN; - } - if ( time == Number.POSITIVE_INFINITY || - time == Number.NEGATIVE_INFINITY ) { - return Number.NaN; - } - return ( day * msPerDay ) + time; -} -function TimeClip( t ) { - if ( isNaN( t ) ) { - return ( Number.NaN ); - } - if ( Math.abs( t ) > 8.64e15 ) { - return ( Number.NaN ); - } - - return ( ToInteger( t ) ); -} -function ToInteger( t ) { - t = Number( t ); - - if ( isNaN( t ) ){ - return ( Number.NaN ); - } - if ( t == 0 || t == -0 || - t == Number.POSITIVE_INFINITY || t == Number.NEGATIVE_INFINITY ) { - return 0; - } - - var sign = ( t < 0 ) ? -1 : 1; - - return ( sign * Math.floor( Math.abs( t ) ) ); -} -function Enumerate ( o ) { - var p; - for ( p in o ) { - print( p +": " + o[p] ); - } -} - -/* these functions are useful for running tests manually in Rhino */ - -function GetContext() { - return Packages.com.netscape.javascript.Context.getCurrentContext(); -} -function OptLevel( i ) { - i = Number(i); - var cx = GetContext(); - cx.setOptimizationLevel(i); -} -/* end of Rhino functions */ - diff --git a/tests/auto/declarative/parserstress/tests/ecma/template.js b/tests/auto/declarative/parserstress/tests/ecma/template.js deleted file mode 100644 index 8f11686890..0000000000 --- a/tests/auto/declarative/parserstress/tests/ecma/template.js +++ /dev/null @@ -1,70 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is JavaScript Engine testing utilities. - * - * The Initial Developer of the Original Code is - * Mozilla Foundation. - * Portions created by the Initial Developer are Copyright (C) 2007 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -gTestfile = 'template.js'; - -/** - * File Name: template.js - * Reference: ** replace with bugzilla URL or document reference ** - * Description: ** replace with description of test ** - * Author: ** replace with your e-mail address ** - */ - -var SECTION = ""; // provide a document reference (ie, ECMA section) -var VERSION = "ECMA"; // Version of JavaScript or ECMA -var TITLE = ""; // Provide ECMA section title or a description -var BUGNUMBER = ""; // Provide URL to bugsplat or bugzilla report - -startTest(); // leave this alone - -/* - * Calls to AddTestCase here. AddTestCase is a function that is defined - * in shell.js and takes three arguments: - * - a string representation of what is being tested - * - the expected result - * - the actual result - * - * For example, a test might look like this: - * - * AddTestCase("** description", - * "** expected value", - * "** actual value"); - */ - -// leave this alone. this executes the test cases and -// displays results. -test(); diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/boolean-001.js b/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/boolean-001.js deleted file mode 100644 index 7462df2f98..0000000000 --- a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/boolean-001.js +++ /dev/null @@ -1,80 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is JavaScript Engine testing utilities. - * - * The Initial Developer of the Original Code is - * Netscape Communication Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -gTestfile = 'boolean-001.js'; - -/** - File Name: boolean-001.js - Description: Corresponds to ecma/Boolean/15.6.4.2-4-n.js - - The toString function is not generic; it generates - a runtime error if its this value is not a Boolean - object. Therefore it cannot be transferred to other - kinds of objects for use as a method. - - Author: christine@netscape.com - Date: june 27, 1997 -*/ -var SECTION = "boolean-001.js"; -var VERSION = "JS1_4"; -var TITLE = "Boolean.prototype.toString()"; -startTest(); -writeHeaderToLog( SECTION +" "+ TITLE ); - -var exception = "No exception thrown"; -var result = "Failed"; - -var TO_STRING = Boolean.prototype.toString; - -try { - var s = new String("Not a Boolean"); - s.toString = TO_STRING; - s.toString(); -} catch ( e ) { - result = "Passed!"; - exception = e.toString(); -} - -new TestCase( - SECTION, - "Assigning Boolean.prototype.toString to a String object "+ - "(threw " +exception +")", - "Passed!", - result ); - -test(); - diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/boolean-002.js b/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/boolean-002.js deleted file mode 100644 index 813e11cd39..0000000000 --- a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/boolean-002.js +++ /dev/null @@ -1,84 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is JavaScript Engine testing utilities. - * - * The Initial Developer of the Original Code is - * Netscape Communication Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -gTestfile = 'boolean-002.js'; - -/** - File Name: boolean-001.js - Description: Corresponds to ecma/Boolean/15.6.4.3-4-n.js - - 15.6.4.3 Boolean.prototype.valueOf() - Returns this boolean value. - - The valueOf function is not generic; it generates - a runtime error if its this value is not a Boolean - object. Therefore it cannot be transferred to other - kinds of objects for use as a method. - - Author: christine@netscape.com - Date: 09 september 1998 -*/ -var SECTION = "boolean-002.js"; -var VERSION = "JS1_4"; -var TITLE = "Boolean.prototype.valueOf()"; -startTest(); -writeHeaderToLog( SECTION +" "+ TITLE ); - - -var exception = "No exception thrown"; -var result = "Failed"; - -var VALUE_OF = Boolean.prototype.valueOf; - -try { - var s = new String("Not a Boolean"); - s.valueOf = VALUE_0F; - s.valueOf(); -} catch ( e ) { - result = "Passed!"; - exception = e.toString(); -} - -new TestCase( - SECTION, - "Assigning Boolean.prototype.valueOf to a String object "+ - "(threw " +exception +")", - "Passed!", - result ); - -test(); - diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/browser.js b/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/browser.js deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/date-001.js b/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/date-001.js deleted file mode 100644 index 041bbb523c..0000000000 --- a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/date-001.js +++ /dev/null @@ -1,93 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is JavaScript Engine testing utilities. - * - * The Initial Developer of the Original Code is - * Netscape Communication Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -gTestfile = 'date-001.js'; - -/** - File Name: date-001.js - Corresponds To: 15.9.5.2-2.js - ECMA Section: 15.9.5.2 Date.prototype.toString - Description: - This function returns a string value. The contents of the string are - implementation dependent, but are intended to represent the Date in a - convenient, human-readable form in the current time zone. - - The toString function is not generic; it generates a runtime error if its - this value is not a Date object. Therefore it cannot be transferred to - other kinds of objects for use as a method. - - - This verifies that calling toString on an object that is not a string - generates a runtime error. - - Author: christine@netscape.com - Date: 12 november 1997 -*/ -var SECTION = "date-001"; -var VERSION = "JS1_4"; -var TITLE = "Date.prototype.toString"; - -startTest(); -writeHeaderToLog( SECTION + " "+ TITLE); - -var result = "Failed"; -var exception = "No exception thrown"; -var expect = "Passed"; - -try { - var OBJ = new MyObject( new Date(0) ); - result = OBJ.toString(); -} catch ( e ) { - result = expect; - exception = e.toString(); -} - -new TestCase( - SECTION, - "OBJECT = new MyObject( new Date(0)) ; result = OBJ.toString()" + - " (threw " + exception +")", - expect, - result ); - -test(); - -function MyObject( value ) { - this.value = value; - this.valueOf = new Function( "return this.value" ); - this.toString = Date.prototype.toString; - return this; -} diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/date-002.js b/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/date-002.js deleted file mode 100644 index 4fb11b38d9..0000000000 --- a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/date-002.js +++ /dev/null @@ -1,87 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is JavaScript Engine testing utilities. - * - * The Initial Developer of the Original Code is - * Netscape Communication Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -gTestfile = 'date-002.js'; - -/** - File Name: date-002.js - Corresponds To: 15.9.5.23-3-n.js - ECMA Section: 15.9.5.23 - Description: Date.prototype.setTime - - 1. If the this value is not a Date object, generate a runtime error. - 2. Call ToNumber(time). - 3. Call TimeClip(Result(1)). - 4. Set the [[Value]] property of the this value to Result(2). - 5. Return the value of the [[Value]] property of the this value. - - Author: christine@netscape.com - Date: 12 november 1997 -*/ -var SECTION = "date-002"; -var VERSION = "JS1_4"; -var TITLE = "Date.prototype.setTime()"; - -startTest(); -writeHeaderToLog( SECTION + " "+ TITLE); - -var result = "Failed"; -var exception = "No exception thrown"; -var expect = "Passed"; - -try { - var MYDATE = new MyDate(); - result = MYDATE.setTime(0); -} catch ( e ) { - result = expect; - exception = e.toString(); -} - -new TestCase( - SECTION, - "MYDATE = new MyDate(); MYDATE.setTime(0)" + - " (threw " + exception +")", - expect, - result ); - -test(); - -function MyDate(value) { - this.value = value; - this.setTime = Date.prototype.setTime; - return this; -} diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/date-003.js b/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/date-003.js deleted file mode 100644 index 95129177c7..0000000000 --- a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/date-003.js +++ /dev/null @@ -1,89 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is JavaScript Engine testing utilities. - * - * The Initial Developer of the Original Code is - * Netscape Communication Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -gTestfile = 'date-003.js'; - -/** - File Name: date-003.js - Corresponds To 15.9.5.3-1.js - ECMA Section: 15.9.5.3-1 Date.prototype.valueOf - Description: - - The valueOf function returns a number, which is this time value. - - The valueOf function is not generic; it generates a runtime error if - its this value is not a Date object. Therefore it cannot be transferred - to other kinds of objects for use as a method. - - Author: christine@netscape.com - Date: 12 november 1997 -*/ -var SECTION = "date-003"; -var VERSION = "JS1_4"; -var TITLE = "Date.prototype.valueOf"; - -startTest(); -writeHeaderToLog( SECTION + " "+ TITLE); - -var result = "Failed"; -var exception = "No exception thrown"; -var expect = "Passed"; - -try { - var OBJ = new MyObject( new Date(0) ); - result = OBJ.valueOf(); -} catch ( e ) { - result = expect; - exception = e.toString(); -} - -new TestCase( - SECTION, - "OBJ = new MyObject( new Date(0)); OBJ.valueOf()" + - " (threw " + exception +")", - expect, - result ); - -test(); - -function MyObject( value ) { - this.value = value; - this.valueOf = Date.prototype.valueOf; -// The following line causes an infinte loop -// this.toString = new Function( "return this+\"\";"); - return this; -} diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/date-004.js b/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/date-004.js deleted file mode 100644 index d77bd1c272..0000000000 --- a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/date-004.js +++ /dev/null @@ -1,83 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is JavaScript Engine testing utilities. - * - * The Initial Developer of the Original Code is - * Netscape Communication Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -gTestfile = 'date-004.js'; - -/** - File Name: date-004.js - Corresponds To: 15.9.5.4-2-n.js - ECMA Section: 15.9.5.4-1 Date.prototype.getTime - Description: - - 1. If the this value is not an object whose [[Class]] property is "Date", - generate a runtime error. - 2. Return this time value. - Author: christine@netscape.com - Date: 12 november 1997 -*/ -var SECTION = "date-004"; -var VERSION = "JS1_4"; -var TITLE = "Date.prototype.getTime"; - -startTest(); -writeHeaderToLog( SECTION + " "+ TITLE); - -var result = "Failed"; -var exception = "No exception thrown"; -var expect = "Passed"; - -try { - var MYDATE = new MyDate(); - result = MYDATE.getTime(); -} catch ( e ) { - result = expect; - exception = e.toString(); -} - -new TestCase( - SECTION, - "MYDATE = new MyDate(); MYDATE.getTime()" + - " (threw " + exception +")", - expect, - result ); - -test(); - -function MyDate( value ) { - this.value = value; - this.getTime = Date.prototype.getTime; -} diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/exception-001.js b/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/exception-001.js deleted file mode 100644 index 3762c5b3c4..0000000000 --- a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/exception-001.js +++ /dev/null @@ -1,78 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is JavaScript Engine testing utilities. - * - * The Initial Developer of the Original Code is - * Netscape Communication Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -gTestfile = 'exception-001.js'; - -/** - * File Name: exception-001 - * ECMA Section: - * Description: Tests for JavaScript Standard Exceptions - * - * Call error. - * - * Author: christine@netscape.com - * Date: 31 August 1998 - */ -var SECTION = "exception-001"; -var VERSION = "js1_4"; -var TITLE = "Tests for JavaScript Standard Exceptions: CallError"; - -startTest(); -writeHeaderToLog( SECTION + " "+ TITLE); - -Call_1(); - -test(); - -function Call_1() { - result = "failed: no exception thrown"; - exception = null; - - try { - Math(); - } catch ( e ) { - result = "passed: threw exception", - exception = e.toString(); - } finally { - new TestCase( - SECTION, - "Math() [ exception is " + exception +" ]", - "passed: threw exception", - result ); - } -} - diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/exception-002.js b/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/exception-002.js deleted file mode 100644 index e5328b8b81..0000000000 --- a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/exception-002.js +++ /dev/null @@ -1,78 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is JavaScript Engine testing utilities. - * - * The Initial Developer of the Original Code is - * Netscape Communication Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -gTestfile = 'exception-002.js'; - -/** - * File Name: exception-002 - * ECMA Section: - * Description: Tests for JavaScript Standard Exceptions - * - * Construct error. - * - * Author: christine@netscape.com - * Date: 31 August 1998 - */ -var SECTION = "exception-002"; -var VERSION = "js1_4"; -var TITLE = "Tests for JavaScript Standard Exceptions: ConstructError"; - -startTest(); -writeHeaderToLog( SECTION + " "+ TITLE); - -Construct_1(); - -test(); - -function Construct_1() { - result = "failed: no exception thrown"; - exception = null; - - try { - result = new Math(); - } catch ( e ) { - result = "passed: threw exception", - exception = e.toString(); - } finally { - new TestCase( - SECTION, - "new Math() [ exception is " + exception +" ]", - "passed: threw exception", - result ); - } -} - diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/exception-003.js b/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/exception-003.js deleted file mode 100644 index c5956ffc95..0000000000 --- a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/exception-003.js +++ /dev/null @@ -1,82 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is JavaScript Engine testing utilities. - * - * The Initial Developer of the Original Code is - * Netscape Communication Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -gTestfile = 'exception-003.js'; - -/** - * File Name: exception-003 - * ECMA Section: - * Description: Tests for JavaScript Standard Exceptions - * - * Target error. - * - * Author: christine@netscape.com - * Date: 31 August 1998 - */ -var SECTION = "exception-003"; -var VERSION = "js1_4"; -var TITLE = "Tests for JavaScript Standard Exceptions: TargetError"; - -startTest(); -writeHeaderToLog( SECTION + " "+ TITLE); - -Target_1(); - -test(); - -function Target_1() { - result = "failed: no exception thrown"; - exception = null; - - try { - string = new String("hi"); - string.toString = Boolean.prototype.toString; - string.toString(); - } catch ( e ) { - result = "passed: threw exception", - exception = e.toString(); - } finally { - new TestCase( - SECTION, - "string = new String(\"hi\");"+ - "string.toString = Boolean.prototype.toString" + - "string.toString() [ exception is " + exception +" ]", - "passed: threw exception", - result ); - } -} - diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/exception-004.js b/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/exception-004.js deleted file mode 100644 index 15a07a806f..0000000000 --- a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/exception-004.js +++ /dev/null @@ -1,78 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is JavaScript Engine testing utilities. - * - * The Initial Developer of the Original Code is - * Netscape Communication Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -gTestfile = 'exception-004.js'; - -/** - * File Name: exception-004 - * ECMA Section: - * Description: Tests for JavaScript Standard Exceptions - * - * ToObject error. - * - * Author: christine@netscape.com - * Date: 31 August 1998 - */ -var SECTION = "exception-004"; -var VERSION = "js1_4"; -var TITLE = "Tests for JavaScript Standard Exceptions: ToObjectError"; - -startTest(); -writeHeaderToLog( SECTION + " "+ TITLE); - -ToObject_1(); - -test(); - -function ToObject_1() { - result = "failed: no exception thrown"; - exception = null; - - try { - result = foo["bar"]; - } catch ( e ) { - result = "passed: threw exception", - exception = e.toString(); - } finally { - new TestCase( - SECTION, - "foo[\"bar\"] [ exception is " + exception +" ]", - "passed: threw exception", - result ); - } -} - diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/exception-005.js b/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/exception-005.js deleted file mode 100644 index e5532ff40c..0000000000 --- a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/exception-005.js +++ /dev/null @@ -1,78 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is JavaScript Engine testing utilities. - * - * The Initial Developer of the Original Code is - * Netscape Communication Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -gTestfile = 'exception-005.js'; - -/** - * File Name: exception-005 - * ECMA Section: - * Description: Tests for JavaScript Standard Exceptions - * - * ToObject error. - * - * Author: christine@netscape.com - * Date: 31 August 1998 - */ -var SECTION = "exception-005"; -var VERSION = "js1_4"; -var TITLE = "Tests for JavaScript Standard Exceptions: ToObjectError"; - -startTest(); -writeHeaderToLog( SECTION + " "+ TITLE); - -ToObject_1(); - -test(); - -function ToObject_1() { - result = "failed: no exception thrown"; - exception = null; - - try { - result = foo["bar"]; - } catch ( e ) { - result = "passed: threw exception", - exception = e.toString(); - } finally { - new TestCase( - SECTION, - "foo[\"bar\"] [ exception is " + exception +" ]", - "passed: threw exception", - result ); - } -} - diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/exception-006.js b/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/exception-006.js deleted file mode 100644 index b37b52becb..0000000000 --- a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/exception-006.js +++ /dev/null @@ -1,89 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is JavaScript Engine testing utilities. - * - * The Initial Developer of the Original Code is - * Netscape Communication Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -gTestfile = 'exception-006.js'; - -/** - * File Name: exception-006 - * ECMA Section: - * Description: Tests for JavaScript Standard Exceptions - * - * ToPrimitive error. - * - * Author: christine@netscape.com - * Date: 31 August 1998 - */ -var SECTION = "exception-006"; -var VERSION = "js1_4"; -var TITLE = "Tests for JavaScript Standard Exceptions: TypeError"; - -startTest(); -writeHeaderToLog( SECTION + " "+ TITLE); - -ToPrimitive_1(); - -test(); - - -/** - * Getting the [[DefaultValue]] of any instances of MyObject - * should result in a runtime error in ToPrimitive. - */ - -function MyObject() { - this.toString = void 0; - this.valueOf = void 0; -} - -function ToPrimitive_1() { - result = "failed: no exception thrown"; - exception = null; - - try { - result = new MyObject() + new MyObject(); - } catch ( e ) { - result = "passed: threw exception", - exception = e.toString(); - } finally { - new TestCase( - SECTION, - "new MyObject() + new MyObject() [ exception is " + exception +" ]", - "passed: threw exception", - result ); - } -} - diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/exception-007.js b/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/exception-007.js deleted file mode 100644 index a63ed0e3f8..0000000000 --- a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/exception-007.js +++ /dev/null @@ -1,90 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is JavaScript Engine testing utilities. - * - * The Initial Developer of the Original Code is - * Netscape Communication Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -gTestfile = 'exception-007.js'; - -/** - * File Name: exception-007 - * ECMA Section: - * Description: Tests for JavaScript Standard Exceptions - * - * DefaultValue error. - * - * Author: christine@netscape.com - * Date: 31 August 1998 - */ -var SECTION = "exception-007"; -var VERSION = "js1_4"; -var TITLE = "Tests for JavaScript Standard Exceptions: TypeError"; -var BUGNUMBER="318250"; - -startTest(); -writeHeaderToLog( SECTION + " "+ TITLE); - -DefaultValue_1(); - -test(); - - -/** - * Getting the [[DefaultValue]] of any instances of MyObject - * should result in a runtime error in ToPrimitive. - */ - -function MyObject() { - this.toString = void 0; - this.valueOf = new Object(); -} - -function DefaultValue_1() { - result = "failed: no exception thrown"; - exception = null; - - try { - result = new MyObject() + new MyObject(); - } catch ( e ) { - result = "passed: threw exception", - exception = e.toString(); - } finally { - new TestCase( - SECTION, - "new MyObject() + new MyObject() [ exception is " + exception +" ]", - "passed: threw exception", - result ); - } -} - diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/exception-008.js b/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/exception-008.js deleted file mode 100644 index 39326183a4..0000000000 --- a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/exception-008.js +++ /dev/null @@ -1,77 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is JavaScript Engine testing utilities. - * - * The Initial Developer of the Original Code is - * Netscape Communication Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -gTestfile = 'exception-008.js'; - -/** - * File Name: exception-008 - * ECMA Section: - * Description: Tests for JavaScript Standard Exceptions - * - * SyntaxError. - * - * Author: christine@netscape.com - * Date: 31 August 1998 - */ -var SECTION = "exception-008"; -var VERSION = "js1_4"; -var TITLE = "Tests for JavaScript Standard Exceptions: SyntaxError"; - -startTest(); -writeHeaderToLog( SECTION + " "+ TITLE); - -Syntax_1(); - -test(); - -function Syntax_1() { - result = "failed: no exception thrown"; - exception = null; - - try { - result = eval("continue;"); - } catch ( e ) { - result = "passed: threw exception", - exception = e.toString(); - } finally { - new TestCase( - SECTION, - "eval(\"continue\") [ exception is " + exception +" ]", - "passed: threw exception", - result ); - } -} diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/exception-009.js b/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/exception-009.js deleted file mode 100644 index bd5cbe7f40..0000000000 --- a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/exception-009.js +++ /dev/null @@ -1,86 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is JavaScript Engine testing utilities. - * - * The Initial Developer of the Original Code is - * Netscape Communication Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -gTestfile = 'exception-009.js'; - -/** - * File Name: exception-009 - * ECMA Section: - * Description: Tests for JavaScript Standard Exceptions - * - * Regression test for nested try blocks. - * - * http://scopus.mcom.com/bugsplat/show_bug.cgi?id=312964 - * - * Author: christine@netscape.com - * Date: 31 August 1998 - */ -var SECTION = "exception-009"; -var VERSION = "JS1_4"; -var TITLE = "Tests for JavaScript Standard Exceptions: SyntaxError"; -var BUGNUMBER= "312964"; - -startTest(); -writeHeaderToLog( SECTION + " "+ TITLE); - -try { - expect = "passed: no exception thrown"; - result = expect; - Nested_1(); -} catch ( e ) { - result = "failed: threw " + e; -} finally { - new TestCase( - SECTION, - "nested try", - expect, - result ); -} - - -test(); - -function Nested_1() { - try { - try { - } catch (a) { - } finally { - } - } catch (b) { - } finally { - } -} diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/exception-010-n.js b/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/exception-010-n.js deleted file mode 100644 index cb28d635a6..0000000000 --- a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/exception-010-n.js +++ /dev/null @@ -1,61 +0,0 @@ -/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- - * - * ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is Mozilla Communicator client code, released - * March 31, 1998. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * Rob Ginda rginda@netscape.com - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -gTestfile = 'exception-010-n.js'; - -var SECTION = "exception-010"; -var VERSION = "ECMA_2"; -startTest(); -var TITLE = "Don't Crash throwing null"; - -writeHeaderToLog( SECTION + " "+ TITLE); -print("Null throw test."); -print("BUGNUMBER: 21799"); - -DESCRIPTION = "throw null"; -EXPECTED = "error"; - -new TestCase( SECTION, "throw null", "error", eval("throw null" )); - -test(); - -print("FAILED!: Should have exited with uncaught exception."); - - diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/exception-011-n.js b/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/exception-011-n.js deleted file mode 100644 index ec5302c247..0000000000 --- a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/exception-011-n.js +++ /dev/null @@ -1,62 +0,0 @@ -/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- - * - * ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is Mozilla Communicator client code, released - * March 31, 1998. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * Rob Ginda rginda@netscape.com - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -gTestfile = 'exception-011-n.js'; - -var SECTION = "exception-011"; -var VERSION = "ECMA_2"; -startTest(); -var TITLE = "Don't Crash throwing undefined"; - -writeHeaderToLog( SECTION + " "+ TITLE); - -print("Undefined throw test."); - -DESCRIPTION = "throw undefined"; -EXPECTED = "error"; - -new TestCase( SECTION, "throw undefined", "error", eval("throw (void 0)") ); - -test(); - -print("FAILED!: Should have exited with uncaught exception."); - - - diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/expression-001.js b/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/expression-001.js deleted file mode 100644 index c3ae4f21e6..0000000000 --- a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/expression-001.js +++ /dev/null @@ -1,83 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is JavaScript Engine testing utilities. - * - * The Initial Developer of the Original Code is - * Netscape Communication Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -gTestfile = 'expression-001.js'; - -/** - File Name: expression-001.js - Corresponds to: ecma/Expressions/11.12-2-n.js - ECMA Section: 11.12 - Description: - - The grammar for a ConditionalExpression in ECMAScript is a little bit - different from that in C and Java, which each allow the second - subexpression to be an Expression but restrict the third expression to - be a ConditionalExpression. The motivation for this difference in - ECMAScript is to allow an assignment expression to be governed by either - arm of a conditional and to eliminate the confusing and fairly useless - case of a comma expression as the center expression. - - Author: christine@netscape.com - Date: 09 september 1998 -*/ -var SECTION = "expression-001"; -var VERSION = "JS1_4"; -var TITLE = "Conditional operator ( ? : )" - startTest(); -writeHeaderToLog( SECTION + " " + TITLE ); - -// the following expression should be an error in JS. - -var result = "Failed" - var exception = "No exception was thrown"; - -try { - eval("var MY_VAR = true ? \"EXPR1\", \"EXPR2\" : \"EXPR3\""); -} catch ( e ) { - result = "Passed"; - exception = e.toString(); -} - -new TestCase( - SECTION, - "comma expression in a conditional statement "+ - "(threw "+ exception +")", - "Passed", - result ); - - -test(); diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/expression-002.js b/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/expression-002.js deleted file mode 100644 index 2f060936ae..0000000000 --- a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/expression-002.js +++ /dev/null @@ -1,93 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is JavaScript Engine testing utilities. - * - * The Initial Developer of the Original Code is - * Netscape Communication Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -gTestfile = 'expression-002.js'; - -/** - File Name: expressions-002.js - Corresponds to: ecma/Expressions/11.2.1-3-n.js - ECMA Section: 11.2.1 Property Accessors - Description: - - Try to access properties of an object whose value is undefined. - - Author: christine@netscape.com - Date: 09 september 1998 -*/ -var SECTION = "expressions-002.js"; -var VERSION = "JS1_4"; -var TITLE = "Property Accessors"; -writeHeaderToLog( SECTION + " "+TITLE ); - -startTest(); - -// go through all Native Function objects, methods, and properties and get their typeof. - -var PROPERTY = new Array(); -var p = 0; - -// try to access properties of primitive types - -OBJECT = new Property( "undefined", void 0, "undefined", NaN ); - -var result = "Failed"; -var exception = "No exception thrown"; -var expect = "Passed"; - -try { - result = OBJECT.value.valueOf(); -} catch ( e ) { - result = expect; - exception = e.toString(); -} - - -new TestCase( - SECTION, - "Get the value of an object whose value is undefined "+ - "(threw " + exception +")", - expect, - result ); - -test(); - -function Property( object, value, string, number ) { - this.object = object; - this.string = String(value); - this.number = Number(value); - this.valueOf = value; -} diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/expression-003.js b/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/expression-003.js deleted file mode 100644 index 5007b83adf..0000000000 --- a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/expression-003.js +++ /dev/null @@ -1,88 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is JavaScript Engine testing utilities. - * - * The Initial Developer of the Original Code is - * Netscape Communication Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -gTestfile = 'expression-003.js'; - -/** - File Name: expressions-003.js - Corresponds to: ecma/Expressions/11.2.1-3-n.js - ECMA Section: 11.2.1 Property Accessors - Description: - - Try to access properties of an object whose value is undefined. - - Author: christine@netscape.com - Date: 09 september 1998 -*/ -var SECTION = "expressions-003.js"; -var VERSION = "JS1_4"; -var TITLE = "Property Accessors"; -writeHeaderToLog( SECTION + " "+TITLE ); - -startTest(); - -// try to access properties of primitive types - -OBJECT = new Property( "undefined", void 0, "undefined", NaN ); - -var result = "Failed"; -var exception = "No exception thrown"; -var expect = "Passed"; - -try { - result = OBJECT.value.toString(); -} catch ( e ) { - result = expect; - exception = e.toString(); -} - - -new TestCase( - SECTION, - "Get the toString value of an object whose value is undefined "+ - "(threw " + exception +")", - expect, - result ); - -test(); - -function Property( object, value, string, number ) { - this.object = object; - this.string = String(value); - this.number = Number(value); - this.value = value; -} diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/expression-004.js b/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/expression-004.js deleted file mode 100644 index 2befdd10f3..0000000000 --- a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/expression-004.js +++ /dev/null @@ -1,82 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is JavaScript Engine testing utilities. - * - * The Initial Developer of the Original Code is - * Netscape Communication Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -gTestfile = 'expression-004.js'; - -/** - File Name: expression-004.js - Corresponds To: 11.2.1-4-n.js - ECMA Section: 11.2.1 Property Accessors - Description: - - Author: christine@netscape.com - Date: 09 september 1998 -*/ -var SECTION = "expression-004"; -var VERSION = "JS1_4"; -var TITLE = "Property Accessors"; -writeHeaderToLog( SECTION + " "+TITLE ); -startTest(); - -var OBJECT = new Property( "null", null, "null", 0 ); - -var result = "Failed"; -var exception = "No exception thrown"; -var expect = "Passed"; - -try { - result = OBJECT.value.toString(); -} catch ( e ) { - result = expect; - exception = e.toString(); -} - -new TestCase( - SECTION, - "Get the toString value of an object whose value is null "+ - "(threw " + exception +")", - expect, - result ); - -test(); - -function Property( object, value, string, number ) { - this.object = object; - this.string = String(value); - this.number = Number(value); - this.value = value; -} diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/expression-005.js b/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/expression-005.js deleted file mode 100644 index 2d76593ea2..0000000000 --- a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/expression-005.js +++ /dev/null @@ -1,74 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is JavaScript Engine testing utilities. - * - * The Initial Developer of the Original Code is - * Netscape Communication Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -gTestfile = 'expression-005.js'; - -/** - File Name: expression-005.js - Corresponds To: 11.2.2-10-n.js - ECMA Section: 11.2.2. The new operator - Description: - - Author: christine@netscape.com - Date: 12 november 1997 -*/ - -var SECTION = "expression-005"; -var VERSION = "JS1_4"; -var TITLE = "The new operator"; - -startTest(); -writeHeaderToLog( SECTION + " "+ TITLE); - -var result = "Failed"; -var expect = "Passed"; -var exception = "No exception thrown"; - -try { - result = new Math(); -} catch ( e ) { - result = expect; - exception = e.toString(); -} - -new TestCase( - SECTION, - "result= new Math() (threw " + exception + ")", - expect, - result ); - -test(); diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/expression-006.js b/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/expression-006.js deleted file mode 100644 index eb21e0308c..0000000000 --- a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/expression-006.js +++ /dev/null @@ -1,79 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is JavaScript Engine testing utilities. - * - * The Initial Developer of the Original Code is - * Netscape Communication Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -gTestfile = 'expression-006.js'; - -/** - File Name: expression-006.js - Corresponds to: 11.2.2-1-n.js - ECMA Section: 11.2.2. The new operator - Description: - - http://scopus/bugsplat/show_bug.cgi?id=327765 - - Author: christine@netscape.com - Date: 12 november 1997 -*/ -var SECTION = "expression-006.js"; -var VERSION = "JS1_4"; -var TITLE = "The new operator"; -var BUGNUMBER="327765"; - -startTest(); -writeHeaderToLog( SECTION + " "+ TITLE); - -var result = "Failed"; -var exception = "No exception thrown"; -var expect = "Passed"; - -try { - var OBJECT = new Object(); - result = new OBJECT(); -} catch ( e ) { - result = expect; - exception = e.toString(); -} - -new TestCase( - SECTION, - "OBJECT = new Object; result = new OBJECT()" + - " (threw " + exception +")", - expect, - result ); - -test(); - diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/expression-007.js b/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/expression-007.js deleted file mode 100644 index a2305be16d..0000000000 --- a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/expression-007.js +++ /dev/null @@ -1,77 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is JavaScript Engine testing utilities. - * - * The Initial Developer of the Original Code is - * Netscape Communication Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -gTestfile = 'expression-007.js'; - -/** - File Name: expression-007.js - Corresponds To: 11.2.2-2-n.js - ECMA Section: 11.2.2. The new operator - Description: - - - Author: christine@netscape.com - Date: 12 november 1997 -*/ -var SECTION = "expression-007"; -var VERSION = "JS1_4"; -var TITLE = "The new operator"; - -startTest(); -writeHeaderToLog( SECTION + " "+ TITLE); - -var result = "Failed"; -var exception = "No exception thrown"; -var expect = "Passed"; - -try { - UNDEFINED = void 0; - result = new UNDEFINED(); -} catch ( e ) { - result = expect; - exception = e.toString(); -} - -new TestCase( - SECTION, - "UNDEFINED = void 0; result = new UNDEFINED()" + - " (threw " + exception +")", - expect, - result ); - -test(); - diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/expression-008.js b/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/expression-008.js deleted file mode 100644 index c85310f957..0000000000 --- a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/expression-008.js +++ /dev/null @@ -1,74 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is JavaScript Engine testing utilities. - * - * The Initial Developer of the Original Code is - * Netscape Communication Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -gTestfile = 'expression-008.js'; - -/** - File Name: expression-008 - Corresponds To: 11.2.2-3-n.js - ECMA Section: 11.2.2. The new operator - Description: - Author: christine@netscape.com - Date: 12 november 1997 -*/ -var SECTION = "expression-008"; -var VERSION = "JS1_4"; -var TITLE = "The new operator"; - -startTest(); -writeHeaderToLog( SECTION + " "+ TITLE); - -var NULL = null; -var result = "Failed"; -var exception = "No exception thrown"; -var expect = "Passed"; - -try { - result = new NULL(); -} catch ( e ) { - result = expect; - exception = e.toString(); -} - -new TestCase( - SECTION, - "NULL = null; result = new NULL()" + - " (threw " + exception +")", - expect, - result ); - -test(); diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/expression-009.js b/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/expression-009.js deleted file mode 100644 index feec2cd052..0000000000 --- a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/expression-009.js +++ /dev/null @@ -1,75 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is JavaScript Engine testing utilities. - * - * The Initial Developer of the Original Code is - * Netscape Communication Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -gTestfile = 'expression-009.js'; - -/** - File Name: expression-009 - Corresponds to: ecma/Expressions/11.2.2-4-n.js - ECMA Section: 11.2.2. The new operator - Description: - Author: christine@netscape.com - Date: 12 november 1997 -*/ -var SECTION = "expression-009"; -var VERSION = "JS1_4"; -var TITLE = "The new operator"; - -startTest(); -writeHeaderToLog( SECTION + " "+ TITLE); - -var STRING = ""; - -var result = "Failed"; -var exception = "No exception thrown"; -var expect = "Passed"; - -try { - result = new STRING(); -} catch ( e ) { - result = expect; - exception = e.toString(); -} - -new TestCase( - SECTION, - "STRING = ''; result = new STRING()" + - " (threw " + exception +")", - expect, - result ); - -test(); diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/expression-010.js b/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/expression-010.js deleted file mode 100644 index e0b38a4838..0000000000 --- a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/expression-010.js +++ /dev/null @@ -1,76 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is JavaScript Engine testing utilities. - * - * The Initial Developer of the Original Code is - * Netscape Communication Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -gTestfile = 'expression-010.js'; - -/** - File Name: expression-010.js - Corresponds To: 11.2.2-5-n.js - ECMA Section: 11.2.2. The new operator - Description: - Author: christine@netscape.com - Date: 12 november 1997 -*/ -var SECTION = "expression-010"; -var VERSION = "JS1_4"; -var TITLE = "The new operator"; - -startTest(); -writeHeaderToLog( SECTION + " "+ TITLE); - -var NUMBER = 0; - -var result = "Failed"; -var exception = "No exception thrown"; -var expect = "Passed"; - -try { - result = new NUMBER(); -} catch ( e ) { - result = expect; - exception = e.toString(); -} - -new TestCase( - SECTION, - "NUMBER=0, result = new NUMBER()" + - " (threw " + exception +")", - expect, - result ); - -test(); - diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/expression-011.js b/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/expression-011.js deleted file mode 100644 index 75f872480d..0000000000 --- a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/expression-011.js +++ /dev/null @@ -1,76 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is JavaScript Engine testing utilities. - * - * The Initial Developer of the Original Code is - * Netscape Communication Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -gTestfile = 'expression-011.js'; - -/** - File Name: expression-011.js - Corresponds To: ecma/Expressions/11.2.2-6-n.js - ECMA Section: 11.2.2. The new operator - Description: - Author: christine@netscape.com - Date: 12 november 1997 -*/ -var SECTION = "expression-011"; -var VERSION = "JS1_4"; -var TITLE = "The new operator"; - -startTest(); -writeHeaderToLog( SECTION + " "+ TITLE); - -var BOOLEAN = true; - -var result = "Failed"; -var exception = "No exception thrown"; -var expect = "Passed"; - -try { - var OBJECT = new BOOLEAN(); -} catch ( e ) { - result = expect; - exception = e.toString(); -} - -new TestCase( - SECTION, - "BOOLEAN = true; result = new BOOLEAN()" + - " (threw " + exception +")", - expect, - result ); - -test(); - diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/expression-012.js b/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/expression-012.js deleted file mode 100644 index 5223abd480..0000000000 --- a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/expression-012.js +++ /dev/null @@ -1,77 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is JavaScript Engine testing utilities. - * - * The Initial Developer of the Original Code is - * Netscape Communication Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -gTestfile = 'expression-012.js'; - -/** - File Name: expression-012.js - Corresponds To: ecma/Expressions/11.2.2-6-n.js - ECMA Section: 11.2.2. The new operator - Description: - http://scopus/bugsplat/show_bug.cgi?id=327765 - Author: christine@netscape.com - Date: 12 november 1997 -*/ -var SECTION = "expression-012"; -var VERSION = "JS1_4"; -var TITLE = "The new operator"; -var BUGNUMBER= "327765"; - -startTest(); -writeHeaderToLog( SECTION + " "+ TITLE); - -var STRING = new String("hi"); -var result = "Failed"; -var exception = "No exception thrown"; -var expect = "Passed"; - -try { - result = new STRING(); -} catch ( e ) { - result = expect; - exception = e.toString(); -} - -new TestCase( - SECTION, - "STRING = new String(\"hi\"); result = new STRING()" + - " (threw " + exception +")", - expect, - result ); - -test(); - diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/expression-013.js b/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/expression-013.js deleted file mode 100644 index 10ad726653..0000000000 --- a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/expression-013.js +++ /dev/null @@ -1,77 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is JavaScript Engine testing utilities. - * - * The Initial Developer of the Original Code is - * Netscape Communication Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -gTestfile = 'expression-013.js'; - -/** - File Name: expression-013.js - Corresponds To: ecma/Expressions/11.2.2-8-n.js - ECMA Section: 11.2.2. The new operator - Description: - Author: christine@netscape.com - Date: 12 november 1997 -*/ -var SECTION = "expression-013"; -var VERSION = "JS1_4"; -var TITLE = "The new operator"; -var BUGNUMBER= "327765"; - -startTest(); -writeHeaderToLog( SECTION + " "+ TITLE); - -var NUMBER = new Number(1); - -var result = "Failed"; -var exception = "No exception thrown"; -var expect = "Passed"; - -try { - result = new NUMBER(); -} catch ( e ) { - result = expect; - exception = e.toString(); -} - -new TestCase( - SECTION, - "NUMBER = new Number(1); result = new NUMBER()" + - " (threw " + exception +")", - expect, - result ); - -test(); - diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/expression-014.js b/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/expression-014.js deleted file mode 100644 index fadca81c7a..0000000000 --- a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/expression-014.js +++ /dev/null @@ -1,79 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is JavaScript Engine testing utilities. - * - * The Initial Developer of the Original Code is - * Netscape Communication Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -gTestfile = 'expression-014.js'; - -/** - File Name: expression-014.js - Corresponds To: ecma/Expressions/11.2.2-9-n.js - ECMA Section: 11.2.2. The new operator - Description: - - Author: christine@netscape.com - Date: 12 november 1997 -*/ -var SECTION = "expression-014.js"; -var VERSION = "ECMA_1"; -var TITLE = "The new operator"; -var BUGNUMBER= "327765"; - -startTest(); -writeHeaderToLog( SECTION + " "+ TITLE); - -var BOOLEAN = new Boolean(); - - -var result = "Failed"; -var exception = "No exception thrown"; -var expect = "Passed"; - -try { - result = new BOOLEAN(); -} catch ( e ) { - result = expect; - exception = e.toString(); -} - -new TestCase( - SECTION, - "BOOLEAN = new Boolean(); result = new BOOLEAN()" + - " (threw " + exception +")", - expect, - result ); - -test(); - diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/expression-015.js b/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/expression-015.js deleted file mode 100644 index 2bd2b8d094..0000000000 --- a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/expression-015.js +++ /dev/null @@ -1,73 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is JavaScript Engine testing utilities. - * - * The Initial Developer of the Original Code is - * Netscape Communication Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -gTestfile = 'expression-015.js'; - -/** - File Name: expression-015.js - Corresponds To: ecma/Expressions/11.2.3-2-n.js - ECMA Section: 11.2.3. Function Calls - Description: - Author: christine@netscape.com - Date: 12 november 1997 -*/ -var SECTION = "expression-015"; -var VERSION = "JS1_4"; -var TITLE = "Function Calls"; - -startTest(); -writeHeaderToLog( SECTION + " "+ TITLE); - -var result = "Failed"; -var exception = "No exception thrown"; -var expect = "Passed"; - -try { - eval("result = 3.valueOf();"); -} catch ( e ) { - result = expect; - exception = e.toString(); -} - -new TestCase( - SECTION, - "3.valueOf()" + - " (threw " + exception +")", - expect, - result ); - -test(); diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/expression-016.js b/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/expression-016.js deleted file mode 100644 index 3c91495f3c..0000000000 --- a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/expression-016.js +++ /dev/null @@ -1,73 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is JavaScript Engine testing utilities. - * - * The Initial Developer of the Original Code is - * Netscape Communication Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -gTestfile = 'expression-016.js'; - -/** - File Name: expression-016.js - Corresponds To: ecma/Expressions/11.2.3-3-n.js - ECMA Section: 11.2.3. Function Calls - Description: - Author: christine@netscape.com - Date: 12 november 1997 -*/ -var SECTION = "expression-016"; -var VERSION = "JS1_4"; -var TITLE = "Function Calls"; - -startTest(); -writeHeaderToLog( SECTION + " "+ TITLE); - -var result = "Failed"; -var exception = "No exception thrown"; -var expect = "Passed"; - -try { - result = (void 0).valueOf(); -} catch ( e ) { - result = expect; - exception = e.toString(); -} - -new TestCase( - SECTION, - "(void 0).valueOf()" + - " (threw " + exception +")", - expect, - result ); - -test(); diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/expression-017.js b/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/expression-017.js deleted file mode 100644 index 4e762a54a9..0000000000 --- a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/expression-017.js +++ /dev/null @@ -1,73 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is JavaScript Engine testing utilities. - * - * The Initial Developer of the Original Code is - * Netscape Communication Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -gTestfile = 'expression-017.js'; - -/** - File Name: expression-07.js - Corresponds To: ecma/Expressions/11.2.3-4-n.js - ECMA Section: 11.2.3. Function Calls - Description: - Author: christine@netscape.com - Date: 12 november 1997 -*/ -var SECTION = "expression-017"; -var VERSION = "JS1_4"; -var TITLE = "Function Calls"; - -startTest(); -writeHeaderToLog( SECTION + " "+ TITLE); - -var result = "Failed"; -var exception = "No exception thrown"; -var expect = "Passed"; - -try { - result = nullvalueOf(); -} catch ( e ) { - result = expect; - exception = e.toString(); -} - -new TestCase( - SECTION, - "null.valueOf()" + - " (threw " + exception +")", - expect, - result ); - -test(); diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/expression-019.js b/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/expression-019.js deleted file mode 100644 index 11ee3a0063..0000000000 --- a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/expression-019.js +++ /dev/null @@ -1,77 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is JavaScript Engine testing utilities. - * - * The Initial Developer of the Original Code is - * Netscape Communication Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -gTestfile = 'expression-019.js'; - -/** - File Name: expression-019.js - Corresponds To: 11.2.2-7-n.js - ECMA Section: 11.2.2. The new operator - Description: - - Author: christine@netscape.com - Date: 12 november 1997 -*/ -var SECTION = "expression-019"; -var VERSION = "JS1_4"; -var TITLE = "The new operator"; -var BUGNUMBER= "327765"; - -startTest(); -writeHeaderToLog( SECTION + " "+ TITLE); - -var result = "Failed"; -var exception = "No exception thrown"; -var expect = "Passed"; - -try { - var STRING = new String("hi"); - result = new STRING(); -} catch ( e ) { - result = expect; - exception = e.toString(); -} - -new TestCase( - SECTION, - "var STRING = new String(\"hi\"); result = new STRING();" + - " (threw " + exception + ")", - expect, - result ); - -test(); - diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/function-001.js b/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/function-001.js deleted file mode 100644 index d5f7b452e2..0000000000 --- a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/function-001.js +++ /dev/null @@ -1,86 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is JavaScript Engine testing utilities. - * - * The Initial Developer of the Original Code is - * Netscape Communication Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -gTestfile = 'function-001.js'; - -/** - * File Name: boolean-001.js - * Description: - * - * http://scopus.mcom.com/bugsplat/show_bug.cgi?id=99232 - * - * eval("function f(){}function g(){}") at top level is an error for JS1.2 - * and above (missing ; between named function expressions), but declares f - * and g as functions below 1.2. - * - * Fails to produce error regardless of version: - * js> version(100) - * 120 - * js> eval("function f(){}function g(){}") - * js> version(120); - * 100 - * js> eval("function f(){}function g(){}") - * js> - * Author: christine@netscape.com - * Date: 11 August 1998 - */ -var SECTION = "function-001.js"; -var VERSION = "JS_12"; -var TITLE = "functions not separated by semicolons are errors in version 120 and higher"; -var BUGNUMBER="10278"; - -startTest(); -writeHeaderToLog( SECTION + " "+ TITLE); - -var result = "pass"; -var exception = "no exception thrown"; - -try { - eval("function f(){}function g(){}"); -} catch ( e ) { - result = "fail"; - exception = e.toString(); -} - -new TestCase( - SECTION, - "eval(\"function f(){}function g(){}\") (threw "+exception, - "pass", - result ); - -test(); - diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/global-001.js b/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/global-001.js deleted file mode 100644 index a186a51e64..0000000000 --- a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/global-001.js +++ /dev/null @@ -1,78 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is JavaScript Engine testing utilities. - * - * The Initial Developer of the Original Code is - * Netscape Communication Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -gTestfile = 'global-001.js'; - -/** - File Name: global-001 - Corresponds To: ecma/GlobalObject/15.1-1-n.js - ECMA Section: The global object - Description: - - The global object does not have a [[Construct]] property; it is not - possible to use the global object as a constructor with the new operator. - - - Author: christine@netscape.com - Date: 12 november 1997 -*/ -var SECTION = "global-001"; -var VERSION = "ECMA_1"; -var TITLE = "The Global Object"; - -startTest(); -writeHeaderToLog( SECTION + " "+ TITLE); - -var result = "Failed"; -var exception = "No exception thrown"; -var expect = "Passed"; - -try { - result = new this(); -} catch ( e ) { - result = expect; - exception = e.toString(); -} - -new TestCase( - SECTION, - "result = new this()" + - " (threw " + exception +")", - expect, - result ); - -test(); diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/global-002.js b/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/global-002.js deleted file mode 100644 index c4ef143529..0000000000 --- a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/global-002.js +++ /dev/null @@ -1,78 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is JavaScript Engine testing utilities. - * - * The Initial Developer of the Original Code is - * Netscape Communication Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -gTestfile = 'global-002.js'; - -/** - File Name: global-002 - Corresponds To: ecma/GlobalObject/15.1-2-n.js - ECMA Section: The global object - Description: - - The global object does not have a [[Construct]] property; it is not - possible to use the global object as a constructor with the new operator. - - - Author: christine@netscape.com - Date: 12 november 1997 -*/ -var SECTION = "global-002"; -var VERSION = "JS1_4"; -var TITLE = "The Global Object"; - -startTest(); -writeHeaderToLog( SECTION + " "+ TITLE); - -var result = "Failed"; -var exception = "No exception thrown"; -var expect = "Passed"; - -try { - result = this(); -} catch ( e ) { - result = expect; - exception = e.toString(); -} - -new TestCase( - SECTION, - "result = this()" + - " (threw " + exception +")", - expect, - result ); - -test(); diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-001.js b/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-001.js deleted file mode 100644 index cc2e3a46aa..0000000000 --- a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-001.js +++ /dev/null @@ -1,85 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is JavaScript Engine testing utilities. - * - * The Initial Developer of the Original Code is - * Netscape Communication Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -gTestfile = 'lexical-001.js'; - -/** - File Name: lexical-001.js - CorrespondsTo: ecma/LexicalConventions/7.2.js - ECMA Section: 7.2 Line Terminators - Description: - readability - - separate tokens - - may occur between any two tokens - - cannot occur within any token, not even a string - - affect the process of automatic semicolon insertion. - - white space characters are: - unicode name formal name string representation - \u000A line feed \n - \u000D carriage return \r - - this test uses onerror to capture line numbers. because - we use on error, we can only have one test case per file. - - Author: christine@netscape.com - Date: 11 september 1997 -*/ -var SECTION = "lexical-001"; -var VERSION = "JS1_4"; -var TITLE = "Line Terminators"; - -startTest(); -writeHeaderToLog( SECTION + " "+ TITLE); - -var result = "Failed"; -var exception = "No exception thrown"; -var expect = "Passed"; - -try { - result = eval("\r\n\expect"); -} catch ( e ) { - exception = e.toString(); -} - -new TestCase( - SECTION, - "OBJECT = new Object; result = new OBJECT()" + - " (threw " + exception +")", - expect, - result ); - -test(); diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-002.js b/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-002.js deleted file mode 100644 index f7f691a049..0000000000 --- a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-002.js +++ /dev/null @@ -1,85 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is JavaScript Engine testing utilities. - * - * The Initial Developer of the Original Code is - * Netscape Communication Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -gTestfile = 'lexical-002.js'; - -/** - File Name: lexical-002.js - Corresponds To: ecma/LexicalConventions/7.2-3-n.js - ECMA Section: 7.2 Line Terminators - Description: - readability - - separate tokens - - may occur between any two tokens - - cannot occur within any token, not even a string - - affect the process of automatic semicolon insertion. - - white space characters are: - unicode name formal name string representation - \u000A line feed \n - \u000D carriage return \r - - this test uses onerror to capture line numbers. because - we use on error, we can only have one test case per file. - - Author: christine@netscape.com - Date: 11 september 1997 -*/ -var SECTION = "lexical-002"; -var VERSION = "JS1_4"; -var TITLE = "Line Terminators"; - -startTest(); -writeHeaderToLog( SECTION + " "+ TITLE); - -var result = "Failed"; -var exception = "No exception thrown"; -var expect = "Passed"; - -try { - result = eval("\r\n\expect"); -} catch ( e ) { - exception = e.toString(); -} - -new TestCase( - SECTION, - "result=eval(\"\r\nexpect\")" + - " (threw " + exception +")", - expect, - result ); - -test(); diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-003.js b/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-003.js deleted file mode 100644 index 482382eeed..0000000000 --- a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-003.js +++ /dev/null @@ -1,76 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is JavaScript Engine testing utilities. - * - * The Initial Developer of the Original Code is - * Netscape Communication Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -gTestfile = 'lexical-003.js'; - -/** - File Name: lexical-003.js - Corresponds To: 7.3-13-n.js - ECMA Section: 7.3 Comments - Description: - - Author: christine@netscape.com - Date: 12 november 1997 - -*/ -var SECTION = "lexical-003.js"; -var VERSION = "JS1_4"; -var TITLE = "Comments"; - -startTest(); -writeHeaderToLog( SECTION + " "+ TITLE); - -var result = "Failed"; -var exception = "No exception thrown"; -var expect = "Passed"; - -try { - eval("/*\n/* nested comment */\n*/\n"); -} catch ( e ) { - result = expect; - exception = e.toString(); -} - -new TestCase( - SECTION, - "/*/*nested comment*/ */" + - " (threw " + exception +")", - expect, - result ); - -test(); - diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-004.js b/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-004.js deleted file mode 100644 index ccf6124109..0000000000 --- a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-004.js +++ /dev/null @@ -1,85 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is JavaScript Engine testing utilities. - * - * The Initial Developer of the Original Code is - * Netscape Communication Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -gTestfile = 'lexical-004.js'; - -/** - File Name: lexical-004.js - Corresponds To: ecma/LexicalExpressions/7.4.1-1-n.js - ECMA Section: 7.4.1 - - Description: - - Reserved words cannot be used as identifiers. - - ReservedWord :: - Keyword - FutureReservedWord - NullLiteral - BooleanLiteral - - Author: christine@netscape.com - Date: 12 november 1997 - -*/ -var SECTION = "lexical-004"; -var VERSION = "JS1_4"; -var TITLE = "Keywords"; - -startTest(); -writeHeaderToLog( SECTION + " "+ TITLE); - -var result = "Failed"; -var exception = "No exception thrown"; -var expect = "Passed"; - -try { - eval("var null = true;"); -} catch ( e ) { - result = expect; - exception = e.toString(); -} - -new TestCase( - SECTION, - "var null = true" + - " (threw " + exception +")", - expect, - result ); - -test(); - diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-005.js b/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-005.js deleted file mode 100644 index 44b2ea9c87..0000000000 --- a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-005.js +++ /dev/null @@ -1,85 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is JavaScript Engine testing utilities. - * - * The Initial Developer of the Original Code is - * Netscape Communication Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -gTestfile = 'lexical-005.js'; - -/** - File Name: lexical-005.js - Corresponds To: 7.4.1-2.js - ECMA Section: 7.4.1 - - Description: - - Reserved words cannot be used as identifiers. - - ReservedWord :: - Keyword - FutureReservedWord - NullLiteral - BooleanLiteral - - Author: christine@netscape.com - Date: 12 november 1997 - -*/ -var SECTION = "lexical-005"; -var VERSION = "JS1_4"; -var TITLE = "Keywords"; - -startTest(); -writeHeaderToLog( SECTION + " "+ TITLE); - -var result = "Failed"; -var exception = "No exception thrown"; -var expect = "Passed"; - -try { - eval("true = false;"); -} catch ( e ) { - result = expect; - exception = e.toString(); -} - -new TestCase( - SECTION, - "true = false" + - " (threw " + exception +")", - expect, - result ); - -test(); - diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-006.js b/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-006.js deleted file mode 100644 index 6f693d8ad2..0000000000 --- a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-006.js +++ /dev/null @@ -1,91 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is JavaScript Engine testing utilities. - * - * The Initial Developer of the Original Code is - * Netscape Communication Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -gTestfile = 'lexical-006.js'; - -/** - File Name: lexical-006.js - Corresponds To: 7.4.2-1.js - ECMA Section: 7.4.2 - - Description: - The following tokens are ECMAScript keywords and may not be used as - identifiers in ECMAScript programs. - - Syntax - - Keyword :: one of - break for new var - continue function return void - delete if this while - else in typeof with - - This test verifies that the keyword cannot be used as an identifier. - Functioinal tests of the keyword may be found in the section corresponding - to the function of the keyword. - - Author: christine@netscape.com - Date: 12 november 1997 - -*/ -var SECTION = "lexical-006"; -var VERSION = "JS1_4"; -var TITLE = "Keywords"; - -startTest(); -writeHeaderToLog( SECTION + " "+ TITLE); - -var result = "Failed"; -var exception = "No exception thrown"; -var expect = "Passed"; - -try { - eval("break = new Object();"); -} catch ( e ) { - result = expect; - exception = e.toString(); -} - -new TestCase( - SECTION, - "break = new Object()" + - " (threw " + exception +")", - expect, - result ); - -test(); - diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-007.js b/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-007.js deleted file mode 100644 index b6d5152ea0..0000000000 --- a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-007.js +++ /dev/null @@ -1,84 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is JavaScript Engine testing utilities. - * - * The Initial Developer of the Original Code is - * Netscape Communication Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -gTestfile = 'lexical-007.js'; - -/** - File Name: lexical-005.js - Corresponds To: 7.4.1-3-n.js - ECMA Section: 7.4.1 - - Description: - - Reserved words cannot be used as identifiers. - - ReservedWord :: - Keyword - FutureReservedWord - NullLiteral - BooleanLiteral - - Author: christine@netscape.com - Date: 12 november 1997 -*/ -var SECTION = "lexical-005"; -var VERSION = "JS1_4"; -var TITLE = "Keywords"; - -startTest(); -writeHeaderToLog( SECTION + " "+ TITLE); - -var result = "Failed"; -var exception = "No exception thrown"; -var expect = "Passed"; - -try { - eval("false = true;"); -} catch ( e ) { - result = expect; - exception = e.toString(); -} - -new TestCase( - SECTION, - "false = true" + - " (threw " + exception +")", - expect, - result ); - -test(); - diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-008.js b/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-008.js deleted file mode 100644 index eed455c243..0000000000 --- a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-008.js +++ /dev/null @@ -1,86 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is JavaScript Engine testing utilities. - * - * The Initial Developer of the Original Code is - * Netscape Communication Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -gTestfile = 'lexical-008.js'; - -/** - File Name: lexical-008.js - Corresponds To: 7.4.3-1-n.js - ECMA Section: 7.4.3 - - Description: - The following words are used as keywords in proposed extensions and are - therefore reserved to allow for the possibility of future adoption of - those extensions. - - FutureReservedWord :: one of - case debugger export super - catch default extends switch - class do finally throw - const enum import try - - Author: christine@netscape.com - Date: 12 november 1997 -*/ -var SECTION = "lexical-008.js"; -var VERSION = "JS1_4"; -var TITLE = "Future Reserved Words"; - -startTest(); -writeHeaderToLog( SECTION + " "+ TITLE); - -var result = "Failed"; -var exception = "No exception thrown"; -var expect = "Passed"; - -try { - eval("case = true;"); -} catch ( e ) { - result = expect; - exception = e.toString(); -} - -new TestCase( - SECTION, - "case = true" + - " (threw " + exception +")", - expect, - result ); - -test(); - - diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-009.js b/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-009.js deleted file mode 100644 index d796574809..0000000000 --- a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-009.js +++ /dev/null @@ -1,86 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is JavaScript Engine testing utilities. - * - * The Initial Developer of the Original Code is - * Netscape Communication Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -gTestfile = 'lexical-009.js'; - -/** - File Name: lexical-009 - Corresponds To: 7.4.3-2-n.js - ECMA Section: 7.4.3 - - Description: - The following words are used as keywords in proposed extensions and are - therefore reserved to allow for the possibility of future adoption of - those extensions. - - FutureReservedWord :: one of - case debugger export super - catch default extends switch - class do finally throw - const enum import try - - Author: christine@netscape.com - Date: 12 november 1997 -*/ -var SECTION = "lexical-009"; -var VERSION = "ECMA_1"; -var TITLE = "Future Reserved Words"; - -startTest(); -writeHeaderToLog( SECTION + " "+ TITLE); - -var result = "Failed"; -var exception = "No exception thrown"; -var expect = "Passed"; - -try { - eval("debugger = true;"); -} catch ( e ) { - result = expect; - exception = e.toString(); -} - -new TestCase( - SECTION, - "debugger = true" + - " (threw " + exception +")", - expect, - result ); - -test(); - - diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-010.js b/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-010.js deleted file mode 100644 index 059b5a06be..0000000000 --- a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-010.js +++ /dev/null @@ -1,84 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is JavaScript Engine testing utilities. - * - * The Initial Developer of the Original Code is - * Netscape Communication Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -gTestfile = 'lexical-010.js'; - -/** - File Name: lexical-010.js - Corresponds To: 7.4.3-3-n.js - ECMA Section: 7.4.3 - - Description: - The following words are used as keywords in proposed extensions and are - therefore reserved to allow for the possibility of future adoption of - those extensions. - - FutureReservedWord :: one of - case debugger export super - catch default extends switch - class do finally throw - const enum import try - - Author: christine@netscape.com - Date: 12 november 1997 -*/ -var SECTION = "lexical-010"; -var VERSION = "ECMA_1"; -var TITLE = "Future Reserved Words"; - -startTest(); -writeHeaderToLog( SECTION + " "+ TITLE); - -var result = "Failed"; -var exception = "No exception thrown"; -var expect = "Passed"; - -try { - eval("export = true;"); -} catch ( e ) { - result = expect; - exception = e.toString(); -} - -new TestCase( - SECTION, - "export = true" + - " (threw " + exception +")", - expect, - result ); - -test(); diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-011.js b/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-011.js deleted file mode 100644 index 7f01041c41..0000000000 --- a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-011.js +++ /dev/null @@ -1,95 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is JavaScript Engine testing utilities. - * - * The Initial Developer of the Original Code is - * Netscape Communication Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -gTestfile = 'lexical-011.js'; - -/** - File Name: lexical-011.js - Corresponds To: 7.4.3-4-n.js - ECMA Section: 7.4.3 - - Description: - The following words are used as keywords in proposed extensions and are - therefore reserved to allow for the possibility of future adoption of - those extensions. - - FutureReservedWord :: one of - case debugger export super - catch default extends switch - class do finally throw - const enum import try - - Author: christine@netscape.com - Date: 12 november 1997 -*/ -var SECTION = "lexical-011"; -var VERSION = "JS1_4"; -var TITLE = "Future Reserved Words"; - -startTest(); -writeHeaderToLog( SECTION + " "+ TITLE); - -print("This test requires option javascript.options.strict enabled"); - -if (!options().match(/strict/)) -{ - options('strict'); -} -if (!options().match(/werror/)) -{ - options('werror'); -} - -var result = "Failed"; -var exception = "No exception thrown"; -var expect = "Passed"; - -try { - eval("super = true;"); -} catch ( e ) { - result = expect; - exception = e.toString(); -} - -new TestCase( - SECTION, - "super = true" + - " (threw " + exception +")", - expect, - result ); - -test(); diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-012.js b/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-012.js deleted file mode 100644 index e55b6eb30f..0000000000 --- a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-012.js +++ /dev/null @@ -1,86 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is JavaScript Engine testing utilities. - * - * The Initial Developer of the Original Code is - * Netscape Communication Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -gTestfile = 'lexical-012.js'; - -/** - File Name: lexical-012.js - Corresponds To: 7.4.3-5-n.js - ECMA Section: 7.4.3 - - Description: - The following words are used as keywords in proposed extensions and are - therefore reserved to allow for the possibility of future adoption of - those extensions. - - FutureReservedWord :: one of - case debugger export super - catch default extends switch - class do finally throw - const enum import try - - Author: christine@netscape.com - Date: 12 november 1997 -*/ -var SECTION = "lexical-012"; -var VERSION = "JS1_4"; -var TITLE = "Future Reserved Words"; - -startTest(); -writeHeaderToLog( SECTION + " "+ TITLE); - -var result = "Failed"; -var exception = "No exception thrown"; -var expect = "Passed"; - -try { - eval("catch = true;"); -} catch ( e ) { - result = expect; - exception = e.toString(); -} - -new TestCase( - SECTION, - "catch = true" + - " (threw " + exception +")", - expect, - result ); - -test(); - - diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-013.js b/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-013.js deleted file mode 100644 index fbbf20b263..0000000000 --- a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-013.js +++ /dev/null @@ -1,86 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is JavaScript Engine testing utilities. - * - * The Initial Developer of the Original Code is - * Netscape Communication Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -gTestfile = 'lexical-013.js'; - -/** - File Name: lexical-013.js - Corresponds To: 7.4.3-6-n.js - ECMA Section: 7.4.3 - - Description: - The following words are used as keywords in proposed extensions and are - therefore reserved to allow for the possibility of future adoption of - those extensions. - - FutureReservedWord :: one of - case debugger export super - catch default extends switch - class do finally throw - const enum import try - - Author: christine@netscape.com - Date: 12 november 1997 -*/ -var SECTION = "lexical-013"; -var VERSION = "JS1_4"; -var TITLE = "Future Reserved Words"; - -startTest(); -writeHeaderToLog( SECTION + " "+ TITLE); - -var result = "Failed"; -var exception = "No exception thrown"; -var expect = "Passed"; - -try { - eval("default = true;"); -} catch ( e ) { - result = expect; - exception = e.toString(); -} - -new TestCase( - SECTION, - "default = true" + - " (threw " + exception +")", - expect, - result ); - -test(); - - diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-014.js b/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-014.js deleted file mode 100644 index 880d2800e5..0000000000 --- a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-014.js +++ /dev/null @@ -1,95 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is JavaScript Engine testing utilities. - * - * The Initial Developer of the Original Code is - * Netscape Communication Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -gTestfile = 'lexical-014.js'; - -/** - File Name: lexical-014.js - Corresponds To: 7.4.3-7-n.js - ECMA Section: 7.4.3 - - Description: - The following words are used as keywords in proposed extensions and are - therefore reserved to allow for the possibility of future adoption of - those extensions. - - FutureReservedWord :: one of - case debugger export super - catch default extends switch - class do finally throw - const enum import try - - Author: christine@netscape.com - Date: 12 november 1997 -*/ -var SECTION = "lexical-014.js"; -var VERSION = "JS1_4"; -var TITLE = "Future Reserved Words"; - -startTest(); -writeHeaderToLog( SECTION + " "+ TITLE); - -print("This test requires option javascript.options.strict enabled"); - -if (!options().match(/strict/)) -{ - options('strict'); -} -if (!options().match(/werror/)) -{ - options('werror'); -} - -var result = "Failed"; -var exception = "No exception thrown"; -var expect = "Passed"; - -try { - eval("extends = true;"); -} catch ( e ) { - result = expect; - exception = e.toString(); -} - -new TestCase( - SECTION, - "extends = true" + - " (threw " + exception +")", - expect, - result ); - -test(); diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-015.js b/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-015.js deleted file mode 100644 index a15a2be544..0000000000 --- a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-015.js +++ /dev/null @@ -1,86 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is JavaScript Engine testing utilities. - * - * The Initial Developer of the Original Code is - * Netscape Communication Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -gTestfile = 'lexical-015.js'; - -/** - File Name: lexical-015.js - Corresponds To: 7.4.3-8-n.js - ECMA Section: 7.4.3 - - Description: - The following words are used as keywords in proposed extensions and are - therefore reserved to allow for the possibility of future adoption of - those extensions. - - FutureReservedWord :: one of - case debugger export super - catch default extends switch - class do finally throw - const enum import try - - Author: christine@netscape.com - Date: 12 november 1997 -*/ -var SECTION = "lexical-015"; -var VERSION = "JS1_4"; -var TITLE = "Future Reserved Words"; - -startTest(); -writeHeaderToLog( SECTION + " "+ TITLE); - -var result = "Failed"; -var exception = "No exception thrown"; -var expect = "Passed"; - -try { - eval("switch = true;"); -} catch ( e ) { - result = expect; - exception = e.toString(); -} - -new TestCase( - SECTION, - "switch = true" + - " (threw " + exception +")", - expect, - result ); - -test(); - - diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-016.js b/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-016.js deleted file mode 100644 index 021594d052..0000000000 --- a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-016.js +++ /dev/null @@ -1,95 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is JavaScript Engine testing utilities. - * - * The Initial Developer of the Original Code is - * Netscape Communication Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -gTestfile = 'lexical-016.js'; - -/** - File Name: lexical-016 - Corresponds To: 7.4.3-9-n.js - ECMA Section: 7.4.3 - - Description: - The following words are used as keywords in proposed extensions and are - therefore reserved to allow for the possibility of future adoption of - those extensions. - - FutureReservedWord :: one of - case debugger export super - catch default extends switch - class do finally throw - const enum import try - - Author: christine@netscape.com - Date: 12 november 1997 -*/ -var SECTION = "lexical-016"; -var VERSION = "JS1_4"; -var TITLE = "Future Reserved Words"; - -startTest(); -writeHeaderToLog( SECTION + " "+ TITLE); - -print("This test requires option javascript.options.strict enabled"); - -if (!options().match(/strict/)) -{ - options('strict'); -} -if (!options().match(/werror/)) -{ - options('werror'); -} - -var result = "Failed"; -var exception = "No exception thrown"; -var expect = "Passed"; - -try { - eval("class = true;"); -} catch ( e ) { - result = expect; - exception = e.toString(); -} - -new TestCase( - SECTION, - "class = true" + - " (threw " + exception +")", - expect, - result ); - -test(); diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-017.js b/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-017.js deleted file mode 100644 index b89a526229..0000000000 --- a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-017.js +++ /dev/null @@ -1,87 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is JavaScript Engine testing utilities. - * - * The Initial Developer of the Original Code is - * Netscape Communication Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -gTestfile = 'lexical-017.js'; - -/** - File Name: lexical-017.js - Corresponds To: 7.4.3-10-n.js - ECMA Section: 7.4.3 - - Description: - The following words are used as keywords in proposed extensions and are - therefore reserved to allow for the possibility of future adoption of - those extensions. - - FutureReservedWord :: one of - case debugger export super - catch default extends switch - class do finally throw - const enum import try - - Author: christine@netscape.com - Date: 12 november 1997 -*/ -var SECTION = "lexical-017"; -var VERSION = "JS1_4"; -var TITLE = "Future Reserved Words"; - -startTest(); -writeHeaderToLog( SECTION + " "+ TITLE); - -var result = "Failed"; -var exception = "No exception thrown"; -var expect = "Passed"; - -try { - eval("do = true;"); -} catch ( e ) { - result = expect; - exception = e.toString(); -} - -new TestCase( - SECTION, - "do = true" + - " (threw " + exception +")", - expect, - result ); - -test(); - - - diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-018.js b/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-018.js deleted file mode 100644 index 18773dafe6..0000000000 --- a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-018.js +++ /dev/null @@ -1,86 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is JavaScript Engine testing utilities. - * - * The Initial Developer of the Original Code is - * Netscape Communication Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -gTestfile = 'lexical-018.js'; - -/** - File Name: lexical-018 - Corresponds To: 7.4.3-11-n.js - ECMA Section: 7.4.3 - - Description: - The following words are used as keywords in proposed extensions and are - therefore reserved to allow for the possibility of future adoption of - those extensions. - - FutureReservedWord :: one of - case debugger export super - catch default extends switch - class do finally throw - const enum import try - - Author: christine@netscape.com - Date: 12 november 1997 -*/ -var SECTION = "lexical-018"; -var VERSION = "JS1_4"; -var TITLE = "Future Reserved Words"; - -startTest(); -writeHeaderToLog( SECTION + " "+ TITLE); - -var result = "Failed"; -var exception = "No exception thrown"; -var expect = "Passed"; - -try { - eval("finally = true;"); -} catch ( e ) { - result = expect; - exception = e.toString(); -} - -new TestCase( - SECTION, - "finally = true" + - " (threw " + exception +")", - expect, - result ); - -test(); - - diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-019.js b/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-019.js deleted file mode 100644 index c1c34a93c1..0000000000 --- a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-019.js +++ /dev/null @@ -1,86 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is JavaScript Engine testing utilities. - * - * The Initial Developer of the Original Code is - * Netscape Communication Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -gTestfile = 'lexical-019.js'; - -/** - File Name: lexical-019.js - Corresponds To: 7.4.3-12-n.js - ECMA Section: 7.4.3 - - Description: - The following words are used as keywords in proposed extensions and are - therefore reserved to allow for the possibility of future adoption of - those extensions. - - FutureReservedWord :: one of - case debugger export super - catch default extends switch - class do finally throw - const enum import try - - Author: christine@netscape.com - Date: 12 november 1997 -*/ -var SECTION = "lexical-019"; -var VERSION = "JS1_4"; -var TITLE = "Future Reserved Words"; - -startTest(); -writeHeaderToLog( SECTION + " "+ TITLE); - -var result = "Failed"; -var exception = "No exception thrown"; -var expect = "Passed"; - -try { - eval("throw = true;"); -} catch ( e ) { - result = expect; - exception = e.toString(); -} - -new TestCase( - SECTION, - "throw = true" + - " (threw " + exception +")", - expect, - result ); - -test(); - - diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-020.js b/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-020.js deleted file mode 100644 index e82e1e50b9..0000000000 --- a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-020.js +++ /dev/null @@ -1,86 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is JavaScript Engine testing utilities. - * - * The Initial Developer of the Original Code is - * Netscape Communication Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -gTestfile = 'lexical-020.js'; - -/** - File Name: lexical-020.js - Corresponds To 7.4.3-13-n.js - ECMA Section: 7.4.3 - - Description: - The following words are used as keywords in proposed extensions and are - therefore reserved to allow for the possibility of future adoption of - those extensions. - - FutureReservedWord :: one of - case debugger export super - catch default extends switch - class do finally throw - const enum import try - - Author: christine@netscape.com - Date: 12 november 1997 -*/ -var SECTION = "lexical-020"; -var VERSION = "JS1_4"; -var TITLE = "Future Reserved Words"; - -startTest(); -writeHeaderToLog( SECTION + " "+ TITLE); - -var result = "Failed"; -var exception = "No exception thrown"; -var expect = "Passed"; - -try { - eval("const = true;"); -} catch ( e ) { - result = expect; - exception = e.toString(); -} - -new TestCase( - SECTION, - "const = true" + - " (threw " + exception +")", - expect, - result ); - -test(); - - diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-021.js b/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-021.js deleted file mode 100644 index 47a0725a09..0000000000 --- a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-021.js +++ /dev/null @@ -1,95 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is JavaScript Engine testing utilities. - * - * The Initial Developer of the Original Code is - * Netscape Communication Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -gTestfile = 'lexical-021.js'; - -/** - File Name: lexical-021.js - Corresponds To: 7.4.3-14-n.js - ECMA Section: 7.4.3 - - Description: - The following words are used as keywords in proposed extensions and are - therefore reserved to allow for the possibility of future adoption of - those extensions. - - FutureReservedWord :: one of - case debugger export super - catch default extends switch - class do finally throw - const enum import try - - Author: christine@netscape.com - Date: 12 november 1997 -*/ -var SECTION = "lexical-021.js"; -var VERSION = "ECMA_1"; -var TITLE = "Future Reserved Words"; - -startTest(); -writeHeaderToLog( SECTION + " "+ TITLE); - -print("This test requires option javascript.options.strict enabled"); - -if (!options().match(/strict/)) -{ - options('strict'); -} -if (!options().match(/werror/)) -{ - options('werror'); -} - -var result = "Failed"; -var exception = "No exception thrown"; -var expect = "Passed"; - -try { - eval("enum = true;"); -} catch ( e ) { - result = expect; - exception = e.toString(); -} - -new TestCase( - SECTION, - "enum = true" + - " (threw " + exception +")", - expect, - result ); - -test(); diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-022.js b/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-022.js deleted file mode 100644 index 75d72aa5b6..0000000000 --- a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-022.js +++ /dev/null @@ -1,86 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is JavaScript Engine testing utilities. - * - * The Initial Developer of the Original Code is - * Netscape Communication Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -gTestfile = 'lexical-022.js'; - -/** - File Name: lexical-022 - Corresponds To 7.4.3-15-n.js - ECMA Section: 7.4.3 - - Description: - The following words are used as keywords in proposed extensions and are - therefore reserved to allow for the possibility of future adoption of - those extensions. - - FutureReservedWord :: one of - case debugger export super - catch default extends switch - class do finally throw - const enum import try - - Author: christine@netscape.com - Date: 12 november 1997 -*/ -var SECTION = "lexical-022.js"; -var VERSION = "ECMA_1"; -var TITLE = "Future Reserved Words"; - -startTest(); -writeHeaderToLog( SECTION + " "+ TITLE); - -var result = "Failed"; -var exception = "No exception thrown"; -var expect = "Passed"; - -try { - eval("import = true;"); -} catch ( e ) { - result = expect; - exception = e.toString(); -} - -new TestCase( - SECTION, - "import = true" + - " (threw " + exception +")", - expect, - result ); - -test(); - - diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-023.js b/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-023.js deleted file mode 100644 index aa89c04782..0000000000 --- a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-023.js +++ /dev/null @@ -1,85 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is JavaScript Engine testing utilities. - * - * The Initial Developer of the Original Code is - * Netscape Communication Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -gTestfile = 'lexical-023.js'; - -/** - File Name: lexical-023.js - Corresponds To: 7.4.3-16-n.js - ECMA Section: 7.4.3 - Description: - The following words are used as keywords in proposed extensions and are - therefore reserved to allow for the possibility of future adoption of - those extensions. - - FutureReservedWord :: one of - case debugger export super - catch default extends switch - class do finally throw - const enum import try - - Author: christine@netscape.com - Date: 12 november 1997 -*/ -var SECTION = "lexical-023.js"; -var VERSION = "ECMA_1"; -var TITLE = "Future Reserved Words"; - -startTest(); -writeHeaderToLog( SECTION + " "+ TITLE); - -var result = "Failed"; -var exception = "No exception thrown"; -var expect = "Passed"; - -try { - eval("try = true;"); -} catch ( e ) { - result = expect; - exception = e.toString(); -} - -new TestCase( - SECTION, - "try = true" + - " (threw " + exception +")", - expect, - result ); - -test(); - - diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-024.js b/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-024.js deleted file mode 100644 index 7c1f22f745..0000000000 --- a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-024.js +++ /dev/null @@ -1,92 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is JavaScript Engine testing utilities. - * - * The Initial Developer of the Original Code is - * Netscape Communication Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -gTestfile = 'lexical-024.js'; - -/** - File Name: lexical-024 - Corresponds To: 7.4.2-1-n.js - ECMA Section: 7.4.2 - - Description: - The following tokens are ECMAScript keywords and may not be used as - identifiers in ECMAScript programs. - - Syntax - - Keyword :: one of - break for new var - continue function return void - delete if this while - else in typeof with - - This test verifies that the keyword cannot be used as an identifier. - Functioinal tests of the keyword may be found in the section corresponding - to the function of the keyword. - - Author: christine@netscape.com - Date: 12 november 1997 - -*/ -var SECTION = "lexical-024"; -var VERSION = "JS1_4"; -var TITLE = "Keywords"; - -startTest(); -writeHeaderToLog( SECTION + " "+ TITLE); - -var result = "Failed"; -var exception = "No exception thrown"; -var expect = "Passed"; - -try { - eval("var break;"); -} catch ( e ) { - result = expect; - exception = e.toString(); -} - -new TestCase( - SECTION, - "var break" + - " (threw " + exception +")", - expect, - result ); - -test(); - - diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-025.js b/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-025.js deleted file mode 100644 index f1c7b93daf..0000000000 --- a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-025.js +++ /dev/null @@ -1,92 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is JavaScript Engine testing utilities. - * - * The Initial Developer of the Original Code is - * Netscape Communication Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -gTestfile = 'lexical-025.js'; - -/** - File Name: lexical-025.js - Corresponds To 7.4.2-2-n.js - ECMA Section: 7.4.2 - - Description: - The following tokens are ECMAScript keywords and may not be used as - identifiers in ECMAScript programs. - - Syntax - - Keyword :: one of - break for new var - continue function return void - delete if this while - else in typeof with - - This test verifies that the keyword cannot be used as an identifier. - Functioinal tests of the keyword may be found in the section corresponding - to the function of the keyword. - - Author: christine@netscape.com - Date: 12 november 1997 - -*/ -var SECTION = "lexical-025"; -var VERSION = "JS1_4"; -var TITLE = "Keywords"; - -startTest(); -writeHeaderToLog( SECTION + " "+ TITLE); - -var result = "Failed"; -var exception = "No exception thrown"; -var expect = "Passed"; - -try { - eval("var for;"); -} catch ( e ) { - result = expect; - exception = e.toString(); -} - -new TestCase( - SECTION, - "var for" + - " (threw " + exception +")", - expect, - result ); - -test(); - - diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-026.js b/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-026.js deleted file mode 100644 index 31b5aaaf61..0000000000 --- a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-026.js +++ /dev/null @@ -1,92 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is JavaScript Engine testing utilities. - * - * The Initial Developer of the Original Code is - * Netscape Communication Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -gTestfile = 'lexical-026.js'; - -/** - File Name: lexical-026.js - Corresponds To: 7.4.2-3-n.js - ECMA Section: 7.4.2 - - Description: - The following tokens are ECMAScript keywords and may not be used as - identifiers in ECMAScript programs. - - Syntax - - Keyword :: one of - break for new var - continue function return void - delete if this while - else in typeof with - - This test verifies that the keyword cannot be used as an identifier. - Functioinal tests of the keyword may be found in the section corresponding - to the function of the keyword. - - Author: christine@netscape.com - Date: 12 november 1997 - -*/ -var SECTION = "lexical-026"; -var VERSION = "JS1_4"; -var TITLE = "Keywords"; - -startTest(); -writeHeaderToLog( SECTION + " "+ TITLE); - -var result = "Failed"; -var exception = "No exception thrown"; -var expect = "Passed"; - -try { - eval("var new;"); -} catch ( e ) { - result = expect; - exception = e.toString(); -} - -new TestCase( - SECTION, - "var new" + - " (threw " + exception +")", - expect, - result ); - -test(); - - diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-027.js b/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-027.js deleted file mode 100644 index 573025b591..0000000000 --- a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-027.js +++ /dev/null @@ -1,94 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is JavaScript Engine testing utilities. - * - * The Initial Developer of the Original Code is - * Netscape Communication Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -gTestfile = 'lexical-027.js'; - -/** - File Name: lexical-027.js - Corresponds To: 7.4.2-4-n.js - ECMA Section: 7.4.2 - - Description: - The following tokens are ECMAScript keywords and may not be used as - identifiers in ECMAScript programs. - - Syntax - - var - - Keyword :: one of - break for new var - continue function return void - delete if this while - else in typeof with - - This test verifies that the keyword cannot be used as an identifier. - Functioinal tests of the keyword may be found in the section corresponding - to the function of the keyword. - - Author: christine@netscape.com - Date: 12 november 1997 - -*/ -var SECTION = "lexical-027"; -var VERSION = "JS1_4"; -var TITLE = "Keywords"; - -startTest(); -writeHeaderToLog( SECTION + " "+ TITLE); - -var result = "Failed"; -var exception = "No exception thrown"; -var expect = "Passed"; - -try { - eval("var var;"); -} catch ( e ) { - result = expect; - exception = e.toString(); -} - -new TestCase( - SECTION, - "var var" + - " (threw " + exception +")", - expect, - result ); - -test(); - - diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-028.js b/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-028.js deleted file mode 100644 index 1b76a22169..0000000000 --- a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-028.js +++ /dev/null @@ -1,92 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is JavaScript Engine testing utilities. - * - * The Initial Developer of the Original Code is - * Netscape Communication Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -gTestfile = 'lexical-028.js'; - -/** - File Name: lexical-028.js - Corresponds To: 7.4.2-5-n.js - ECMA Section: 7.4.2 - - Description: - The following tokens are ECMAScript keywords and may not be used as - identifiers in ECMAScript programs. - - Syntax - - Keyword :: one of - break for new var - continue function return void - delete if this while - else in typeof with - - This test verifies that the keyword cannot be used as an identifier. - Functioinal tests of the keyword may be found in the section corresponding - to the function of the keyword. - - Author: christine@netscape.com - Date: 12 november 1997 - -*/ -var SECTION = "lexical-028"; -var VERSION = "JS1_4"; -var TITLE = "Keywords"; - -startTest(); -writeHeaderToLog( SECTION + " "+ TITLE); - -var result = "Failed"; -var exception = "No exception thrown"; -var expect = "Passed"; - -try { - eval("var continue=true;"); -} catch ( e ) { - result = expect; - exception = e.toString(); -} - -new TestCase( - SECTION, - "var continue=true" + - " (threw " + exception +")", - expect, - result ); - -test(); - - diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-029.js b/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-029.js deleted file mode 100644 index f978b8ef89..0000000000 --- a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-029.js +++ /dev/null @@ -1,92 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is JavaScript Engine testing utilities. - * - * The Initial Developer of the Original Code is - * Netscape Communication Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -gTestfile = 'lexical-029.js'; - -/** - File Name: lexical-029.js - Corresponds To: 7.4.2-6.js - ECMA Section: 7.4.2 - - Description: - The following tokens are ECMAScript keywords and may not be used as - identifiers in ECMAScript programs. - - Syntax - - Keyword :: one of - break for new var - continue function return void - delete if this while - else in typeof with - - This test verifies that the keyword cannot be used as an identifier. - Functioinal tests of the keyword may be found in the section corresponding - to the function of the keyword. - - Author: christine@netscape.com - Date: 12 november 1997 - -*/ -var SECTION = "lexical-029"; -var VERSION = "JS1_4"; -var TITLE = "Keywords"; - -startTest(); -writeHeaderToLog( SECTION + " "+ TITLE); - -var result = "Failed"; -var exception = "No exception thrown"; -var expect = "Passed"; - -try { - eval("var function = true;"); -} catch ( e ) { - result = expect; - exception = e.toString(); -} - -new TestCase( - SECTION, - "var function = true" + - " (threw " + exception +")", - expect, - result ); - -test(); - - diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-030.js b/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-030.js deleted file mode 100644 index 3796551698..0000000000 --- a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-030.js +++ /dev/null @@ -1,92 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is JavaScript Engine testing utilities. - * - * The Initial Developer of the Original Code is - * Netscape Communication Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -gTestfile = 'lexical-030.js'; - -/** - File Name: lexical-030.js - Corresponds To: 7.4.2-7-n.js - ECMA Section: 7.4.2 - - Description: - The following tokens are ECMAScript keywords and may not be used as - identifiers in ECMAScript programs. - - Syntax - - Keyword :: one of - break for new var - continue function return void - delete if this while - else in typeof with - - This test verifies that the keyword cannot be used as an identifier. - Functioinal tests of the keyword may be found in the section corresponding - to the function of the keyword. - - Author: christine@netscape.com - Date: 12 november 1997 - -*/ -var SECTION = "lexical-030"; -var VERSION = "JS1_4"; -var TITLE = "Keywords"; - -startTest(); -writeHeaderToLog( SECTION + " "+ TITLE); - -var result = "Failed"; -var exception = "No exception thrown"; -var expect = "Passed"; - -try { - eval("var return = true;"); -} catch ( e ) { - result = expect; - exception = e.toString(); -} - -new TestCase( - SECTION, - "var return = true" + - " (threw " + exception +")", - expect, - result ); - -test(); - - diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-031.js b/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-031.js deleted file mode 100644 index 13379fed01..0000000000 --- a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-031.js +++ /dev/null @@ -1,92 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is JavaScript Engine testing utilities. - * - * The Initial Developer of the Original Code is - * Netscape Communication Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -gTestfile = 'lexical-031.js'; - -/** - File Name: lexical-031.js - Corresponds To: 7.4.2-8-n.js - ECMA Section: 7.4.2 - - Description: - The following tokens are ECMAScript keywords and may not be used as - identifiers in ECMAScript programs. - - Syntax - - Keyword :: one of - break for new var - continue function return void - delete if this while - else in typeof with - - This test verifies that the keyword cannot be used as an identifier. - Functioinal tests of the keyword may be found in the section corresponding - to the function of the keyword. - - Author: christine@netscape.com - Date: 12 november 1997 - -*/ -var SECTION = "lexical-031"; -var VERSION = "JS1_4"; -var TITLE = "Keywords"; - -startTest(); -writeHeaderToLog( SECTION + " "+ TITLE); - -var result = "Failed"; -var exception = "No exception thrown"; -var expect = "Passed"; - -try { - eval("var return;"); -} catch ( e ) { - result = expect; - exception = e.toString(); -} - -new TestCase( - SECTION, - "var return" + - " (threw " + exception +")", - expect, - result ); - -test(); - - diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-032.js b/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-032.js deleted file mode 100644 index 48e6e9aac5..0000000000 --- a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-032.js +++ /dev/null @@ -1,92 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is JavaScript Engine testing utilities. - * - * The Initial Developer of the Original Code is - * Netscape Communication Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -gTestfile = 'lexical-032.js'; - -/** - File Name: lexical-032.js - Corresponds To: 7.4.2-9-n.js - ECMA Section: 7.4.2 - - Description: - The following tokens are ECMAScript keywords and may not be used as - identifiers in ECMAScript programs. - - Syntax - - Keyword :: one of - break for new var - continue function return void - delete if this while - else in typeof with - - This test verifies that the keyword cannot be used as an identifier. - Functioinal tests of the keyword may be found in the section corresponding - to the function of the keyword. - - Author: christine@netscape.com - Date: 12 november 1997 - -*/ -var SECTION = "lexical-032"; -var VERSION = "JS1_4"; -var TITLE = "Keywords"; - -startTest(); -writeHeaderToLog( SECTION + " "+ TITLE); - -var result = "Failed"; -var exception = "No exception thrown"; -var expect = "Passed"; - -try { - eval("delete = true;"); -} catch ( e ) { - result = expect; - exception = e.toString(); -} - -new TestCase( - SECTION, - "delete = true" + - " (threw " + exception +")", - expect, - result ); - -test(); - - diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-033.js b/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-033.js deleted file mode 100644 index cc223c2282..0000000000 --- a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-033.js +++ /dev/null @@ -1,92 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is JavaScript Engine testing utilities. - * - * The Initial Developer of the Original Code is - * Netscape Communication Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -gTestfile = 'lexical-033.js'; - -/** - File Name: lexical-033.js - Corresponds To: 7.4.2-10.js - ECMA Section: 7.4.2 - - Description: - The following tokens are ECMAScript keywords and may not be used as - identifiers in ECMAScript programs. - - Syntax - - Keyword :: one of - break for new var - continue function return void - delete if this while - else in typeof with - - This test verifies that the keyword cannot be used as an identifier. - Functioinal tests of the keyword may be found in the section corresponding - to the function of the keyword. - - Author: christine@netscape.com - Date: 12 november 1997 - -*/ -var SECTION = "lexical-033"; -var VERSION = "JS1_4"; -var TITLE = "Keywords"; - -startTest(); -writeHeaderToLog( SECTION + " "+ TITLE); - -var result = "Failed"; -var exception = "No exception thrown"; -var expect = "Passed"; - -try { - eval("if = true;"); -} catch ( e ) { - result = expect; - exception = e.toString(); -} - -new TestCase( - SECTION, - "if = true" + - " (threw " + exception +")", - expect, - result ); - -test(); - - diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-034.js b/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-034.js deleted file mode 100644 index 4d3c7d5fc0..0000000000 --- a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-034.js +++ /dev/null @@ -1,91 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is JavaScript Engine testing utilities. - * - * The Initial Developer of the Original Code is - * Netscape Communication Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -gTestfile = 'lexical-034.js'; - -/** - File Name: 7.4.2-11-n.js - ECMA Section: 7.4.2 - - Description: - The following tokens are ECMAScript keywords and may not be used as - identifiers in ECMAScript programs. - - Syntax - - Keyword :: one of - break for new var - continue function return void - delete if this while - else in typeof with - - This test verifies that the keyword cannot be used as an identifier. - Functioinal tests of the keyword may be found in the section corresponding - to the function of the keyword. - - Author: christine@netscape.com - Date: 12 november 1997 - -*/ -var SECTION = "lexical-034"; -var VERSION = "JS1_4"; -var TITLE = "Keywords"; - -startTest(); -writeHeaderToLog( SECTION + " "+ TITLE); - -var result = "Failed"; -var exception = "No exception thrown"; -var expect = "Passed"; - -try { - eval("this = true"); -} catch ( e ) { - result = expect; - exception = e.toString(); -} - -new TestCase( - SECTION, - "this = true" + - " (threw " + exception +")", - expect, - result ); - -test(); - - diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-035.js b/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-035.js deleted file mode 100644 index 2a61b437ba..0000000000 --- a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-035.js +++ /dev/null @@ -1,92 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is JavaScript Engine testing utilities. - * - * The Initial Developer of the Original Code is - * Netscape Communication Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -gTestfile = 'lexical-035.js'; - -/** - File Name: lexical-035.js - Correpsonds To: 7.4.2-12-n.js - ECMA Section: 7.4.2 - - Description: - The following tokens are ECMAScript keywords and may not be used as - identifiers in ECMAScript programs. - - Syntax - - Keyword :: one of - break for new var - continue function return void - delete if this while - else in typeof with - - This test verifies that the keyword cannot be used as an identifier. - Functioinal tests of the keyword may be found in the section corresponding - to the function of the keyword. - - Author: christine@netscape.com - Date: 12 november 1997 - -*/ -var SECTION = "lexical-035"; -var VERSION = "JS1_4"; -var TITLE = "Keywords"; - -startTest(); -writeHeaderToLog( SECTION + " "+ TITLE); - -var result = "Failed"; -var exception = "No exception thrown"; -var expect = "Passed"; - -try { - eval("var while"); -} catch ( e ) { - result = expect; - exception = e.toString(); -} - -new TestCase( - SECTION, - "var while" + - " (threw " + exception +")", - expect, - result ); - -test(); - - diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-036.js b/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-036.js deleted file mode 100644 index a1923b7303..0000000000 --- a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-036.js +++ /dev/null @@ -1,92 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is JavaScript Engine testing utilities. - * - * The Initial Developer of the Original Code is - * Netscape Communication Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -gTestfile = 'lexical-036.js'; - -/** - File Name: lexical-036.js - Corresponds To: 7.4.2-13-n.js - ECMA Section: 7.4.2 - - Description: - The following tokens are ECMAScript keywords and may not be used as - identifiers in ECMAScript programs. - - Syntax - - Keyword :: one of - break for new var - continue function return void - delete if this while - else in typeof with - - This test verifies that the keyword cannot be used as an identifier. - Functioinal tests of the keyword may be found in the section corresponding - to the function of the keyword. - - Author: christine@netscape.com - Date: 12 november 1997 - -*/ -var SECTION = "lexical-036"; -var VERSION = "JS1_4"; -var TITLE = "Keywords"; - -startTest(); -writeHeaderToLog( SECTION + " "+ TITLE); - -var result = "Failed"; -var exception = "No exception thrown"; -var expect = "Passed"; - -try { - eval("else = true;"); -} catch ( e ) { - result = expect; - exception = e.toString(); -} - -new TestCase( - SECTION, - "else = true" + - " (threw " + exception +")", - expect, - result ); - -test(); - - diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-037.js b/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-037.js deleted file mode 100644 index e3cd75bd60..0000000000 --- a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-037.js +++ /dev/null @@ -1,92 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is JavaScript Engine testing utilities. - * - * The Initial Developer of the Original Code is - * Netscape Communication Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -gTestfile = 'lexical-037.js'; - -/** - File Name: lexical-037.js - Corresponds To: 7.4.2-14-n.js - ECMA Section: 7.4.2 - - Description: - The following tokens are ECMAScript keywords and may not be used as - identifiers in ECMAScript programs. - - Syntax - - Keyword :: one of - break for new var - continue function return void - delete if this while - else in typeof with - - This test verifies that the keyword cannot be used as an identifier. - Functioinal tests of the keyword may be found in the section corresponding - to the function of the keyword. - - Author: christine@netscape.com - Date: 12 november 1997 - -*/ -var SECTION = "lexical-028"; -var VERSION = "JS1_4"; -var TITLE = "Keywords"; - -startTest(); -writeHeaderToLog( SECTION + " "+ TITLE); - -var result = "Failed"; -var exception = "No exception thrown"; -var expect = "Passed"; - -try { - eval("var in;"); -} catch ( e ) { - result = expect; - exception = e.toString(); -} - -new TestCase( - SECTION, - "var in" + - " (threw " + exception +")", - expect, - result ); - -test(); - - diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-038.js b/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-038.js deleted file mode 100644 index 1bf8c6c4e4..0000000000 --- a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-038.js +++ /dev/null @@ -1,92 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is JavaScript Engine testing utilities. - * - * The Initial Developer of the Original Code is - * Netscape Communication Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -gTestfile = 'lexical-038.js'; - -/** - File Name: lexical-038.js - Corresponds To: 7.4.2-15-n.js - ECMA Section: 7.4.2 - - Description: - The following tokens are ECMAScript keywords and may not be used as - identifiers in ECMAScript programs. - - Syntax - - Keyword :: one of - break for new var - continue function return void - delete if this while - else in typeof with - - This test verifies that the keyword cannot be used as an identifier. - Functioinal tests of the keyword may be found in the section corresponding - to the function of the keyword. - - Author: christine@netscape.com - Date: 12 november 1997 - -*/ -var SECTION = "lexical-038"; -var VERSION = "JS1_4"; -var TITLE = "Keywords"; - -startTest(); -writeHeaderToLog( SECTION + " "+ TITLE); - -var result = "Failed"; -var exception = "No exception thrown"; -var expect = "Passed"; - -try { - eval("typeof = true;"); -} catch ( e ) { - result = expect; - exception = e.toString(); -} - -new TestCase( - SECTION, - "typeof = true" + - " (threw " + exception +")", - expect, - result ); - -test(); - - diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-039.js b/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-039.js deleted file mode 100644 index 2f193af89a..0000000000 --- a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-039.js +++ /dev/null @@ -1,79 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is JavaScript Engine testing utilities. - * - * The Initial Developer of the Original Code is - * Netscape Communication Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -gTestfile = 'lexical-039.js'; - -/** - File Name: lexical-039 - Corresponds To: 7.5-2-n.js - ECMA Section: 7.5 Identifiers - Description: Identifiers are of unlimited length - - can contain letters, a decimal digit, _, or $ - - the first character cannot be a decimal digit - - identifiers are case sensitive - - Author: christine@netscape.com - Date: 11 september 1997 -*/ -var SECTION = "lexical-039"; -var VERSION = "JS1_4"; -var TITLE = "Identifiers"; - -startTest(); -writeHeaderToLog( SECTION + " "+ TITLE); - -var result = "Failed"; -var exception = "No exception thrown"; -var expect = "Passed"; - -try { - eval("var 0abc;"); -} catch ( e ) { - result = expect; - exception = e.toString(); -} - -new TestCase( - SECTION, - "var 0abc" + - " (threw " + exception +")", - expect, - result ); - -test(); - - diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-040.js b/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-040.js deleted file mode 100644 index f5ba3533dd..0000000000 --- a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-040.js +++ /dev/null @@ -1,79 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is JavaScript Engine testing utilities. - * - * The Initial Developer of the Original Code is - * Netscape Communication Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -gTestfile = 'lexical-040.js'; - -/** - File Name: lexical-040.js - Corresponds To: 7.5-2.js - ECMA Section: 7.5 Identifiers - Description: Identifiers are of unlimited length - - can contain letters, a decimal digit, _, or $ - - the first character cannot be a decimal digit - - identifiers are case sensitive - - Author: christine@netscape.com - Date: 11 september 1997 -*/ -var SECTION = "lexical-040"; -var VERSION = "JS1_4"; -var TITLE = "Identifiers"; - -startTest(); -writeHeaderToLog( SECTION + " "+ TITLE); - -var result = "Failed"; -var exception = "No exception thrown"; -var expect = "Passed"; - -try { - eval("var 1abc;"); -} catch ( e ) { - result = expect; - exception = e.toString(); -} - -new TestCase( - SECTION, - "var 1abc" + - " (threw " + exception +")", - expect, - result ); - -test(); - - diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-041.js b/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-041.js deleted file mode 100644 index 06d63bddb3..0000000000 --- a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-041.js +++ /dev/null @@ -1,81 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is JavaScript Engine testing utilities. - * - * The Initial Developer of the Original Code is - * Netscape Communication Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -gTestfile = 'lexical-041.js'; - -/** - File Name: lexical-041.js - Corresponds To: 7.5-8-n.js - ECMA Section: 7.5 Identifiers - Description: Identifiers are of unlimited length - - can contain letters, a decimal digit, _, or $ - - the first character cannot be a decimal digit - - identifiers are case sensitive - - Author: christine@netscape.com - Date: 11 september 1997 -*/ -var SECTION = "lexical-041"; -var VERSION = "ECMA_1"; -var TITLE = "Identifiers"; - -startTest(); -writeHeaderToLog( SECTION + " "+ TITLE); -startTest(); -writeHeaderToLog( SECTION + " "+ TITLE); - -var result = "Failed"; -var exception = "No exception thrown"; -var expect = "Passed"; - -try { - eval("var @abc;"); -} catch ( e ) { - result = expect; - exception = e.toString(); -} - -new TestCase( - SECTION, - "var @abc" + - " (threw " + exception +")", - expect, - result ); - -test(); - - diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-042.js b/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-042.js deleted file mode 100644 index c2cedb0b81..0000000000 --- a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-042.js +++ /dev/null @@ -1,82 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is JavaScript Engine testing utilities. - * - * The Initial Developer of the Original Code is - * Netscape Communication Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -gTestfile = 'lexical-042.js'; - -/** - File Name: lexical-042.js - Corresponds To: 7.5-9-n.js - ECMA Section: 7.5 Identifiers - Description: Identifiers are of unlimited length - - can contain letters, a decimal digit, _, or $ - - the first character cannot be a decimal digit - - identifiers are case sensitive - - Author: christine@netscape.com - Date: 11 september 1997 -*/ -var SECTION = "lexical-042"; -var VERSION = "JS1_4"; -var TITLE = "Identifiers"; - -startTest(); -writeHeaderToLog( SECTION + " "+ TITLE); - -startTest(); -writeHeaderToLog( SECTION + " "+ TITLE); - -var result = "Failed"; -var exception = "No exception thrown"; -var expect = "Passed"; - -try { - eval("var 123;"); -} catch ( e ) { - result = expect; - exception = e.toString(); -} - -new TestCase( - SECTION, - "var 123" + - " (threw " + exception +")", - expect, - result ); - -test(); - - diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-047.js b/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-047.js deleted file mode 100644 index e809c24149..0000000000 --- a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-047.js +++ /dev/null @@ -1,83 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is JavaScript Engine testing utilities. - * - * The Initial Developer of the Original Code is - * Netscape Communication Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -gTestfile = 'lexical-047.js'; - -/** - File Name: lexical-047.js - Corresponds To: 7.8.1-7-n.js - ECMA Section: 7.8.1 - Description: - Author: christine@netscape.com - Date: 15 september 1997 -*/ - -var SECTION = "lexical-047"; -var VERSION = "JS1_4"; -var TITLE = "for loops"; - -startTest(); -writeHeaderToLog( SECTION + " "+ TITLE); - -var result = "Failed"; -var exception = "No exception thrown"; -var expect = "Passed"; - -try { - var counter = 0; - eval("for ( counter = 0\n" - + "counter <= 1\n" - + "counter++ )\n" - + "{\n" - + "result += \": got to inner loop\";\n" - + "}\n"); - -} catch ( e ) { - result = expect; - exception = e.toString(); -} - -new TestCase( - SECTION, - "line breaks within a for expression" + - " (threw " + exception +")", - expect, - result ); - -test(); - - diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-048.js b/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-048.js deleted file mode 100644 index 18054d4328..0000000000 --- a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-048.js +++ /dev/null @@ -1,77 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is JavaScript Engine testing utilities. - * - * The Initial Developer of the Original Code is - * Netscape Communication Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -gTestfile = 'lexical-048.js'; - -/** - File Name: lexical-048.js - Corresponds To: 7.8.1-1.js - ECMA Section: 7.8.1 Rules of Automatic Semicolon Insertion - Description: - Author: christine@netscape.com - Date: 15 september 1997 -*/ - -var SECTION = "lexical-048"; -var VERSION = "JS1_4"; -var TITLE = "The Rules of Automatic Semicolon Insertion"; - -startTest(); -writeHeaderToLog( SECTION + " "+ TITLE); - -var result = "Failed"; -var exception = "No exception thrown"; -var expect = "Passed"; - -try { - var counter = 0; - eval( "for ( counter = 0;\ncounter <= 1\ncounter++ ) {\nresult += \": got inside for loop\")"); -} catch ( e ) { - result = expect; - exception = e.toString(); -} - -new TestCase( - SECTION, - "line breaks within a for expression" + - " (threw " + exception +")", - expect, - result ); - -test(); - - diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-049.js b/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-049.js deleted file mode 100644 index e4ce840829..0000000000 --- a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-049.js +++ /dev/null @@ -1,82 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is JavaScript Engine testing utilities. - * - * The Initial Developer of the Original Code is - * Netscape Communication Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -gTestfile = 'lexical-049.js'; - -/** - File Name: lexical-049 - Corresponds To: 7.8.1-1.js - ECMA Section: 7.8.1 Rules of Automatic Semicolon Insertioin - Description: - Author: christine@netscape.com - Date: 15 september 1997 -*/ -var SECTION = "lexical-049"; -var VERSION = "JS1_4"; -var TITLE = "The Rules of Automatic Semicolon Insertion"; - -startTest(); -writeHeaderToLog( SECTION + " "+ TITLE); - -var result = "Failed"; -var exception = "No exception thrown"; -var expect = "Passed"; - -try { - var counter = 0; - eval("for ( counter = 0\n" - + "counter <= 1;\n" - + "counter++ )\n" - + "{\n" - + "result += \": got inside for loop\";\n" - + "}\n"); - -} catch ( e ) { - result = expect; - exception = e.toString(); -} - -new TestCase( - SECTION, - "line breaks within a for expression" + - " (threw " + exception +")", - expect, - result ); - -test(); - - diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-050.js b/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-050.js deleted file mode 100644 index d9161c4b8f..0000000000 --- a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-050.js +++ /dev/null @@ -1,78 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is JavaScript Engine testing utilities. - * - * The Initial Developer of the Original Code is - * Netscape Communication Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -gTestfile = 'lexical-050.js'; - -/** - File Name: lexical-050.js - Corresponds to: 7.8.2-1-n.js - ECMA Section: 7.8.2 Examples of Automatic Semicolon Insertion - Description: compare some specific examples of the automatic - insertion rules in the EMCA specification. - Author: christine@netscape.com - Date: 15 september 1997 -*/ - -var SECTION = "lexical-050"; -var VERSION = "JS1_4"; -var TITLE = "Examples of Automatic Semicolon Insertion"; - -startTest(); -writeHeaderToLog( SECTION + " "+ TITLE); - -var result = "Failed"; -var exception = "No exception thrown"; -var expect = "Passed"; - -try { - eval("{ 1 2 } 3"); -} catch ( e ) { - result = expect; - exception = e.toString(); -} - -new TestCase( - SECTION, - "{ 1 2 } 3" + - " (threw " + exception +")", - expect, - result ); - -test(); - - - diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-051.js b/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-051.js deleted file mode 100644 index 97ccbc6b43..0000000000 --- a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-051.js +++ /dev/null @@ -1,78 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is JavaScript Engine testing utilities. - * - * The Initial Developer of the Original Code is - * Netscape Communication Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -gTestfile = 'lexical-051.js'; - -/** - File Name: lexical-051.js - Corresponds to: 7.8.2-3-n.js - ECMA Section: 7.8.2 Examples of Automatic Semicolon Insertion - Description: compare some specific examples of the automatic - insertion rules in the EMCA specification. - Author: christine@netscape.com - Date: 15 september 1997 -*/ - -var SECTION = "lexical-051"; -var VERSION = "JS1_4"; -var TITLE = "Examples of Automatic Semicolon Insertion"; - -startTest(); -writeHeaderToLog( SECTION + " "+ TITLE); - -var result = "Failed"; -var exception = "No exception thrown"; -var expect = "Passed"; - -try { - eval("for (a; b\n) result += \": got to inner loop\";") - } catch ( e ) { - result = expect; - exception = e.toString(); -} - -new TestCase( - SECTION, - "for (a; b\n)" + - " (threw " + exception +")", - expect, - result ); - -test(); - - - diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-052.js b/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-052.js deleted file mode 100644 index 20d2d3c254..0000000000 --- a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-052.js +++ /dev/null @@ -1,80 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is JavaScript Engine testing utilities. - * - * The Initial Developer of the Original Code is - * Netscape Communication Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -gTestfile = 'lexical-052.js'; - -/** - File Name: lexical-052.js - Corresponds to: 7.8.2-4-n.js - ECMA Section: 7.8.2 Examples of Automatic Semicolon Insertion - Description: compare some specific examples of the automatic - insertion rules in the EMCA specification. - Author: christine@netscape.com - Date: 15 september 1997 -*/ - -var SECTION = "lexical-052"; -var VERSION = "JS1_4"; -var TITLE = "Examples of Automatic Semicolon Insertion"; - -startTest(); -writeHeaderToLog( SECTION + " "+ TITLE); - -var result = "Failed"; -var exception = "No exception thrown"; -var expect = "Passed"; - -try { - MyFunction(); -} catch ( e ) { - result = expect; - exception = e.toString(); -} - -new TestCase( - SECTION, - "calling return indirectly" + - " (threw " + exception +")", - expect, - result ); - -test(); - -function MyFunction() { - var s = "return"; - eval(s); -} diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-053.js b/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-053.js deleted file mode 100644 index 4e64fa1322..0000000000 --- a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-053.js +++ /dev/null @@ -1,78 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is JavaScript Engine testing utilities. - * - * The Initial Developer of the Original Code is - * Netscape Communication Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -gTestfile = 'lexical-053.js'; - -/** - File Name: lexical-053.js - Corresponds to: 7.8.2-7-n.js - ECMA Section: 7.8.2 Examples of Automatic Semicolon Insertion - Description: compare some specific examples of the automatic - insertion rules in the EMCA specification. - Author: christine@netscape.com - Date: 15 september 1997 -*/ - -var SECTION = "lexical-053"; -var VERSION = "JS1_4"; -var TITLE = "Examples of Automatic Semicolon Insertion"; - -startTest(); -writeHeaderToLog( SECTION + " "+ TITLE); - -var result = "Failed"; -var exception = "No exception thrown"; -var expect = "Passed"; - -try { - a = true - b = false - - eval('if (a > b)\nelse result += ": got to else statement"'); -} catch ( e ) { - result = expect; - exception = e.toString(); -} - -new TestCase( - SECTION, - "calling return indirectly" + - " (threw " + exception +")", - expect, - result ); - -test(); diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-054.js b/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-054.js deleted file mode 100644 index 3e25c36ef8..0000000000 --- a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-054.js +++ /dev/null @@ -1,79 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is JavaScript Engine testing utilities. - * - * The Initial Developer of the Original Code is - * Netscape Communication Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -gTestfile = 'lexical-054.js'; - -/** - File Name: lexical-054.js - Corresponds to: 7.8.2-7-n.js - ECMA Section: 7.8.2 Examples of Automatic Semicolon Insertion - Description: compare some specific examples of the automatic - insertion rules in the EMCA specification. - Author: christine@netscape.com - Date: 15 september 1997 -*/ - -var SECTION = "lexical-054"; -var VERSION = "JS1_4"; -var TITLE = "Examples of Automatic Semicolon Insertion"; - -startTest(); -writeHeaderToLog( SECTION + " "+ TITLE); - -var result = "Failed"; -var exception = "No exception thrown"; -var expect = "Passed"; - -try { - a=0; - b=1; - c=2; - d=3; - eval("if (a > b)\nelse c = d"); -} catch ( e ) { - result = expect; - exception = e.toString(); -} - -new TestCase( - SECTION, - "if (a > b)\nelse c = d" + - " (threw " + exception +")", - expect, - result ); - -test(); diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/number-001.js b/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/number-001.js deleted file mode 100644 index eb49a5b9bd..0000000000 --- a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/number-001.js +++ /dev/null @@ -1,86 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is JavaScript Engine testing utilities. - * - * The Initial Developer of the Original Code is - * Netscape Communication Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -gTestfile = 'number-001.js'; - -/** - File Name: number-001 - Corresponds To: 15.7.4.2-2-n.js - ECMA Section: 15.7.4.2.2 Number.prototype.toString() - Description: - If the radix is the number 10 or not supplied, then this number value is - given as an argument to the ToString operator; the resulting string value - is returned. - - If the radix is supplied and is an integer from 2 to 36, but not 10, the - result is a string, the choice of which is implementation dependent. - - The toString function is not generic; it generates a runtime error if its - this value is not a Number object. Therefore it cannot be transferred to - other kinds of objects for use as a method. - - Author: christine@netscape.com - Date: 16 september 1997 -*/ -var SECTION = "number-001"; -var VERSION = "JS1_4"; -var TITLE = "Exceptions for Number.toString()"; - -startTest(); -writeHeaderToLog( SECTION + " Number.prototype.toString()"); - -var result = "Failed"; -var exception = "No exception thrown"; -var expect = "Passed"; - -try { - object= new Object(); - object.toString = Number.prototype.toString; - result = object.toString(); -} catch ( e ) { - result = expect; - exception = e.toString(); -} - -new TestCase( - SECTION, - "object = new Object(); object.toString = Number.prototype.toString; object.toString()" + - " (threw " + exception +")", - expect, - result ); - -test(); diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/number-002.js b/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/number-002.js deleted file mode 100644 index fef61fd527..0000000000 --- a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/number-002.js +++ /dev/null @@ -1,81 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is JavaScript Engine testing utilities. - * - * The Initial Developer of the Original Code is - * Netscape Communication Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -gTestfile = 'number-002.js'; - -/** - File Name: number-002.js - Corresponds To: ecma/Number/15.7.4.3-2-n.js - ECMA Section: 15.7.4.3.1 Number.prototype.valueOf() - Description: - Returns this number value. - - The valueOf function is not generic; it generates a runtime error if its - this value is not a Number object. Therefore it cannot be transferred to - other kinds of objects for use as a method. - - Author: christine@netscape.com - Date: 16 september 1997 -*/ -var SECTION = "number-002"; -var VERSION = "JS1_4"; -var TITLE = "Exceptions for Number.valueOf()"; - -startTest(); -writeHeaderToLog( SECTION + " Number.prototype.valueOf()"); - -var result = "Failed"; -var exception = "No exception thrown"; -var expect = "Passed"; - -try { - object= new Object(); - object.toString = Number.prototype.valueOf; - result = object.toString(); -} catch ( e ) { - result = expect; - exception = e.toString(); -} - -new TestCase( - SECTION, - "object = new Object(); object.valueOf = Number.prototype.valueOf; object.valueOf()" + - " (threw " + exception +")", - expect, - result ); - -test(); diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/number-003.js b/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/number-003.js deleted file mode 100644 index 46920b7072..0000000000 --- a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/number-003.js +++ /dev/null @@ -1,83 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is JavaScript Engine testing utilities. - * - * The Initial Developer of the Original Code is - * Netscape Communication Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -gTestfile = 'number-003.js'; - -/** - File Name: number-003.js - Corresponds To: 15.7.4.3-3.js - ECMA Section: 15.7.4.3.1 Number.prototype.valueOf() - Description: - Returns this number value. - - The valueOf function is not generic; it generates a runtime error if its - this value is not a Number object. Therefore it cannot be transferred to - other kinds of objects for use as a method. - - Author: christine@netscape.com - Date: 16 september 1997 -*/ -var SECTION = "number-003"; -var VERSION = "JS1_4"; -var TITLE = "Exceptions for Number.valueOf()"; - -startTest(); -writeHeaderToLog( SECTION + " Number.prototype.valueOf()"); - -var result = "Failed"; -var exception = "No exception thrown"; -var expect = "Passed"; - -try { - VALUE_OF = Number.prototype.valueOf; - OBJECT = new String("Infinity"); - OBJECT.valueOf = VALUE_OF; - result = OBJECT.valueOf(); -} catch ( e ) { - result = expect; - exception = e.toString(); -} - -new TestCase( - SECTION, - "Assigning Number.prototype.valueOf as the valueOf of a String object " + - " (threw " + exception +")", - expect, - result ); - -test(); - diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/shell.js b/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/shell.js deleted file mode 100644 index 6c671f1eea..0000000000 --- a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/shell.js +++ /dev/null @@ -1 +0,0 @@ -gTestsubsuite = 'Exceptions'; diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/statement-001.js b/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/statement-001.js deleted file mode 100644 index 98e3d61a0c..0000000000 --- a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/statement-001.js +++ /dev/null @@ -1,80 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is JavaScript Engine testing utilities. - * - * The Initial Developer of the Original Code is - * Netscape Communication Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -gTestfile = 'statement-001.js'; - -/** - File Name: statement-001.js - Corresponds To: 12.6.2-9-n.js - ECMA Section: 12.6.2 The for Statement - - 1. first expression is not present. - 2. second expression is not present - 3. third expression is not present - - - Author: christine@netscape.com - Date: 15 september 1997 -*/ - -var SECTION = "statement-001.js"; -// var SECTION = "12.6.2-9-n"; -var VERSION = "ECMA_1"; -var TITLE = "The for statement"; - -startTest(); -writeHeaderToLog( SECTION + " "+ TITLE); - -var result = "Failed"; -var exception = "No exception thrown"; -var expect = "Passed"; - -try { - eval("for (i) {\n}"); -} catch ( e ) { - result = expect; - exception = e.toString(); -} - -new TestCase( - SECTION, - "for(i) {}" + - " (threw " + exception +")", - expect, - result ); - -test(); diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/statement-002.js b/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/statement-002.js deleted file mode 100644 index da9931e9ab..0000000000 --- a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/statement-002.js +++ /dev/null @@ -1,102 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is JavaScript Engine testing utilities. - * - * The Initial Developer of the Original Code is - * Netscape Communication Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -gTestfile = 'statement-002.js'; - -/** - File Name: statement-002.js - Corresponds To: 12.6.3-1.js - ECMA Section: 12.6.3 The for...in Statement - Description: - The production IterationStatement : for ( LeftHandSideExpression in Expression ) - Statement is evaluated as follows: - - 1. Evaluate the Expression. - 2. Call GetValue(Result(1)). - 3. Call ToObject(Result(2)). - 4. Let C be "normal completion". - 5. Get the name of the next property of Result(3) that doesn't have the - DontEnum attribute. If there is no such property, go to step 14. - 6. Evaluate the LeftHandSideExpression ( it may be evaluated repeatedly). - 7. Call PutValue(Result(6), Result(5)). PutValue( V, W ): - 1. If Type(V) is not Reference, generate a runtime error. - 2. Call GetBase(V). - 3. If Result(2) is null, go to step 6. - 4. Call the [[Put]] method of Result(2), passing GetPropertyName(V) - for the property name and W for the value. - 5. Return. - 6. Call the [[Put]] method for the global object, passing - GetPropertyName(V) for the property name and W for the value. - 7. Return. - 8. Evaluate Statement. - 9. If Result(8) is a value completion, change C to be "normal completion - after value V" where V is the value carried by Result(8). - 10. If Result(8) is a break completion, go to step 14. - 11. If Result(8) is a continue completion, go to step 5. - 12. If Result(8) is a return completion, return Result(8). - 13. Go to step 5. - 14. Return C. - - Author: christine@netscape.com - Date: 11 september 1997 -*/ -var SECTION = "statement-002"; -var VERSION = "JS1_4"; -var TITLE = "The for..in statement"; - -startTest(); -writeHeaderToLog( SECTION + " "+ TITLE); - -var result = "Failed"; -var exception = "No exception thrown"; -var expect = "Passed"; - -try { - eval(" for ( var i, p in this) { result += this[p]; }"); -} catch ( e ) { - result = expect; - exception = e.toString(); -} - -new TestCase( - SECTION, - "more than one member expression" + - " (threw " + exception +")", - expect, - result ); - -test(); diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/statement-003.js b/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/statement-003.js deleted file mode 100644 index d51083c4cf..0000000000 --- a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/statement-003.js +++ /dev/null @@ -1,113 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is JavaScript Engine testing utilities. - * - * The Initial Developer of the Original Code is - * Netscape Communication Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -gTestfile = 'statement-003.js'; - -/** - File Name: statement-003 - Corresponds To: 12.6.3-7-n.js - ECMA Section: 12.6.3 The for...in Statement - Description: - The production IterationStatement : for ( LeftHandSideExpression in Expression ) - Statement is evaluated as follows: - - 1. Evaluate the Expression. - 2. Call GetValue(Result(1)). - 3. Call ToObject(Result(2)). - 4. Let C be "normal completion". - 5. Get the name of the next property of Result(3) that doesn't have the - DontEnum attribute. If there is no such property, go to step 14. - 6. Evaluate the LeftHandSideExpression ( it may be evaluated repeatedly). - 7. Call PutValue(Result(6), Result(5)). PutValue( V, W ): - 1. If Type(V) is not Reference, generate a runtime error. - 2. Call GetBase(V). - 3. If Result(2) is null, go to step 6. - 4. Call the [[Put]] method of Result(2), passing GetPropertyName(V) - for the property name and W for the value. - 5. Return. - 6. Call the [[Put]] method for the global object, passing - GetPropertyName(V) for the property name and W for the value. - 7. Return. - 8. Evaluate Statement. - 9. If Result(8) is a value completion, change C to be "normal completion - after value V" where V is the value carried by Result(8). - 10. If Result(8) is a break completion, go to step 14. - 11. If Result(8) is a continue completion, go to step 5. - 12. If Result(8) is a return completion, return Result(8). - 13. Go to step 5. - 14. Return C. - - Author: christine@netscape.com - Date: 11 september 1997 -*/ -var SECTION = "statement-003"; -var VERSION = "JS1_4"; -var TITLE = "The for..in statement"; - -startTest(); -writeHeaderToLog( SECTION + " "+ TITLE); - -var result = "Failed"; -var exception = "No exception thrown"; -var expect = "Passed"; - -try { - var o = new MyObject(); - var result = 0; - - eval("for ( this in o) {\n" - + "result += this[p];\n" - + "}\n"); -} catch ( e ) { - result = expect; - exception = e.toString(); -} - -new TestCase( - SECTION, - "bad left-hand side expression" + - " (threw " + exception +")", - expect, - result ); - -test(); - -function MyObject() { - this.value = 2; - this[0] = 4; - return this; -} diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/statement-004.js b/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/statement-004.js deleted file mode 100644 index 8b9789a929..0000000000 --- a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/statement-004.js +++ /dev/null @@ -1,85 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is JavaScript Engine testing utilities. - * - * The Initial Developer of the Original Code is - * Netscape Communication Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -gTestfile = 'statement-004.js'; - -/** - File Name: statement-004.js - Corresponds To: 12.6.3-1.js - ECMA Section: 12.6.3 The for...in Statement - Description: - Author: christine@netscape.com - Date: 11 september 1997 -*/ -var SECTION = "statement-004"; -var VERSION = "JS1_4"; -var TITLE = "The for..in statement"; - -startTest(); -writeHeaderToLog( SECTION + " "+ TITLE); - -var result = "Failed"; -var exception = "No exception thrown"; -var expect = "Passed"; - -try { - var o = new MyObject(); - - eval("for ( \"a\" in o) {\n" - + "result += this[p];\n" - + "}"); - -} catch ( e ) { - result = expect; - exception = e.toString(); -} - -new TestCase( - SECTION, - "bad left-hand side expression" + - " (threw " + exception +")", - expect, - result ); - -test(); - - -function MyObject() { - this.value = 2; - this[0] = 4; - return this; -} diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/statement-005.js b/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/statement-005.js deleted file mode 100644 index 62a8c45d92..0000000000 --- a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/statement-005.js +++ /dev/null @@ -1,84 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is JavaScript Engine testing utilities. - * - * The Initial Developer of the Original Code is - * Netscape Communication Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -gTestfile = 'statement-005.js'; - -/** - File Name: statement-005.js - Corresponds To: 12.6.3-8-n.js - ECMA Section: 12.6.3 The for...in Statement - Description: - Author: christine@netscape.com - Date: 11 september 1997 -*/ -var SECTION = "statement-005"; -var VERSION = "JS1_4"; -var TITLE = "The for..in statement"; - -startTest(); -writeHeaderToLog( SECTION + " "+ TITLE); - -var result = "Failed"; -var exception = "No exception thrown"; -var expect = "Passed"; - -try { - var o = new MyObject(); - result = 0; - - eval("for (1 in o) {\n" - + "result += this[p];" - + "}\n"); -} catch ( e ) { - result = expect; - exception = e.toString(); -} - -new TestCase( - SECTION, - "bad left-hand side expression" + - " (threw " + exception +")", - expect, - result ); - -test(); - -function MyObject() { - this.value = 2; - this[0] = 4; - return this; -} diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/statement-006.js b/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/statement-006.js deleted file mode 100644 index ec5ba97576..0000000000 --- a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/statement-006.js +++ /dev/null @@ -1,84 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is JavaScript Engine testing utilities. - * - * The Initial Developer of the Original Code is - * Netscape Communication Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -gTestfile = 'statement-006.js'; - -/** - File Name: statement-006.js - Corresponds To: 12.6.3-9-n.js - ECMA Section: 12.6.3 The for...in Statement - Description: - - Author: christine@netscape.com - Date: 11 september 1997 -*/ -var SECTION = "statement-006"; -var VERSION = "JS1_4"; -var TITLE = "The for..in statement"; - -startTest(); -writeHeaderToLog( SECTION + " "+ TITLE); - -var result = "Failed"; -var exception = "No exception thrown"; -var expect = "Passed"; - -try { - var o = new MyObject(); - var result = 0; - for ( var o in foo) { - result += this[o]; - } -} catch ( e ) { - result = expect; - exception = e.toString(); -} - -new TestCase( - SECTION, - "object is not defined" + - " (threw " + exception +")", - expect, - result ); - -test(); - -function MyObject() { - this.value = 2; - this[0] = 4; - return this; -} diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/statement-007.js b/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/statement-007.js deleted file mode 100644 index bb367c9924..0000000000 --- a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/statement-007.js +++ /dev/null @@ -1,75 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is JavaScript Engine testing utilities. - * - * The Initial Developer of the Original Code is - * Netscape Communication Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -gTestfile = 'statement-007.js'; - -/** - File Name: statement-007.js - Corresponds To: 12.7-1-n.js - ECMA Section: 12.7 The continue statement - Description: - - Author: christine@netscape.com - Date: 12 november 1997 -*/ -var SECTION = "statement-007"; -var VERSION = "JS1_4"; -var TITLE = "The continue statement"; - -startTest(); -writeHeaderToLog( SECTION + " "+ TITLE); - -var result = "Failed"; -var exception = "No exception thrown"; -var expect = "Passed"; - -try { - eval("continue;"); -} catch ( e ) { - result = expect; - exception = e.toString(); -} - -new TestCase( - SECTION, - "continue outside of an iteration statement" + - " (threw " + exception +")", - expect, - result ); - -test(); - diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/statement-008.js b/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/statement-008.js deleted file mode 100644 index 54ab39a9c9..0000000000 --- a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/statement-008.js +++ /dev/null @@ -1,75 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is JavaScript Engine testing utilities. - * - * The Initial Developer of the Original Code is - * Netscape Communication Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -gTestfile = 'statement-008.js'; - -/** - File Name: statement-008.js - Corresponds To: 12.8-1-n.js - ECMA Section: 12.8 The break statement - Description: - - Author: christine@netscape.com - Date: 12 november 1997 -*/ -var SECTION = "statement-008"; -var VERSION = "JS1_4"; -var TITLE = "The break in statement"; - -startTest(); -writeHeaderToLog( SECTION + " "+ TITLE); - -var result = "Failed"; -var exception = "No exception thrown"; -var expect = "Passed"; - -try { - eval("break;"); -} catch ( e ) { - result = expect; - exception = e.toString(); -} - -new TestCase( - SECTION, - "break outside of an iteration statement" + - " (threw " + exception +")", - expect, - result ); - -test(); - diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/statement-009.js b/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/statement-009.js deleted file mode 100644 index a63bd84e8e..0000000000 --- a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/statement-009.js +++ /dev/null @@ -1,74 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is JavaScript Engine testing utilities. - * - * The Initial Developer of the Original Code is - * Netscape Communication Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -gTestfile = 'statement-009.js'; - -/** - File Name: 12.9-1-n.js - ECMA Section: 12.9 The return statement - Description: - - Author: christine@netscape.com - Date: 12 november 1997 -*/ -var SECTION = "12.9-1-n"; -var VERSION = "ECMA_1"; -var TITLE = "The return statement"; - -startTest(); -writeHeaderToLog( SECTION + " The return statement"); - -var result = "Failed"; -var exception = "No exception thrown"; -var expect = "Passed"; - -try { - eval("return;"); -} catch ( e ) { - result = expect; - exception = e.toString(); -} - -new TestCase( - SECTION, - "return outside of a function" + - " (threw " + exception +")", - expect, - result ); - -test(); - diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/string-001.js b/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/string-001.js deleted file mode 100644 index 551030db33..0000000000 --- a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/string-001.js +++ /dev/null @@ -1,86 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is JavaScript Engine testing utilities. - * - * The Initial Developer of the Original Code is - * Netscape Communication Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -gTestfile = 'string-001.js'; - -/** - File Name: string-001.js - Corresponds To: 15.5.4.2-2-n.js - ECMA Section: 15.5.4.2 String.prototype.toString() - - Description: Returns this string value. Note that, for a String - object, the toString() method happens to return the same - thing as the valueOf() method. - - The toString function is not generic; it generates a - runtime error if its this value is not a String object. - Therefore it connot be transferred to the other kinds of - objects for use as a method. - - Author: christine@netscape.com - Date: 1 october 1997 -*/ -var SECTION = "string-001"; -var VERSION = "JS1_4"; -var TITLE = "String.prototype.toString"; - -startTest(); -writeHeaderToLog( SECTION + " "+ TITLE); - -var result = "Failed"; -var exception = "No exception thrown"; -var expect = "Passed"; - -try { - OBJECT = new Object(); - OBJECT.toString = String.prototype.toString(); - result = OBJECT.toString(); -} catch ( e ) { - result = expect; - exception = e.toString(); -} - -new TestCase( - SECTION, - "OBJECT = new Object; "+ - " OBJECT.toString = String.prototype.toString; OBJECT.toString()" + - " (threw " + exception +")", - expect, - result ); - -test(); - diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/string-002.js b/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/string-002.js deleted file mode 100644 index 785e339080..0000000000 --- a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/string-002.js +++ /dev/null @@ -1,85 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is JavaScript Engine testing utilities. - * - * The Initial Developer of the Original Code is - * Netscape Communication Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -gTestfile = 'string-002.js'; - -/** - File Name: string-002.js - Corresponds To: 15.5.4.3-3-n.js - ECMA Section: 15.5.4.3 String.prototype.valueOf() - - Description: Returns this string value. - - The valueOf function is not generic; it generates a - runtime error if its this value is not a String object. - Therefore it connot be transferred to the other kinds of - objects for use as a method. - - Author: christine@netscape.com - Date: 1 october 1997 -*/ -var SECTION = "string-002"; -var VERSION = "JS1_4"; -var TITLE = "String.prototype.valueOf"; - -startTest(); -writeHeaderToLog( SECTION + " "+ TITLE); - -var result = "Failed"; -var exception = "No exception thrown"; -var expect = "Passed"; - -try { - var OBJECT =new Object(); - OBJECT.valueOf = String.prototype.valueOf; - result = OBJECT.valueOf(); -} catch ( e ) { - result = expect; - exception = e.toString(); -} - -new TestCase( - SECTION, - "OBJECT = new Object; OBJECT.valueOf = String.prototype.valueOf;"+ - "result = OBJECT.valueOf();" + - " (threw " + exception +")", - expect, - result ); - -test(); - - diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Expressions/StrictEquality-001.js b/tests/auto/declarative/parserstress/tests/ecma_2/Expressions/StrictEquality-001.js deleted file mode 100644 index db5c403d3d..0000000000 --- a/tests/auto/declarative/parserstress/tests/ecma_2/Expressions/StrictEquality-001.js +++ /dev/null @@ -1,106 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is JavaScript Engine testing utilities. - * - * The Initial Developer of the Original Code is - * Netscape Communication Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -gTestfile = 'StrictEquality-001.js'; - -/** - * File Name: StrictEquality-001.js - * ECMA Section: 11.9.6.js - * Description: - * - * Author: christine@netscape.com - * Date: 4 september 1998 - */ -var SECTION = "StrictEquality-001 - 11.9.6"; -var VERSION = "ECMA_2"; -var TITLE = "The strict equality operator ( === )"; - -startTest(); -writeHeaderToLog( SECTION + " "+ TITLE); - - -// 1. If Type(x) is different from Type(y) return false - -StrictEquality( true, new Boolean(true), false ); -StrictEquality( new Boolean(), false, false ); -StrictEquality( "", new String(), false ); -StrictEquality( new String("hi"), "hi", false ); - -// 2. If Type(x) is not Number go to step 9. - -// 3. If x is NaN, return false -StrictEquality( NaN, NaN, false ); -StrictEquality( NaN, 0, false ); - -// 4. If y is NaN, return false. -StrictEquality( 0, NaN, false ); - -// 5. if x is the same number value as y, return true - -// 6. If x is +0 and y is -0, return true - -// 7. If x is -0 and y is +0, return true - -// 8. Return false. - - -// 9. If Type(x) is String, then return true if x and y are exactly -// the same sequence of characters ( same length and same characters -// in corresponding positions.) Otherwise return false. - -// 10. If Type(x) is Boolean, return true if x and y are both true or -// both false. otherwise return false. - - -// Return true if x and y refer to the same object. Otherwise return -// false. - -// Return false. - - -test(); - -function StrictEquality( x, y, expect ) { - result = ( x === y ); - - new TestCase( - SECTION, - x +" === " + y, - expect, - result ); -} - diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Expressions/browser.js b/tests/auto/declarative/parserstress/tests/ecma_2/Expressions/browser.js deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Expressions/shell.js b/tests/auto/declarative/parserstress/tests/ecma_2/Expressions/shell.js deleted file mode 100644 index 8f5d1129d5..0000000000 --- a/tests/auto/declarative/parserstress/tests/ecma_2/Expressions/shell.js +++ /dev/null @@ -1 +0,0 @@ -gTestsubsuite = 'Expressions'; diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/FunctionObjects/apply-001-n.js b/tests/auto/declarative/parserstress/tests/ecma_2/FunctionObjects/apply-001-n.js deleted file mode 100644 index e58d087121..0000000000 --- a/tests/auto/declarative/parserstress/tests/ecma_2/FunctionObjects/apply-001-n.js +++ /dev/null @@ -1,65 +0,0 @@ -/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- - * - * ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is Mozilla Communicator client code, released - * March 31, 1998. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * Rob Ginda rginda@netscape.com - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -gTestfile = 'apply-001-n.js'; - -print("STATUS: f.apply crash test."); - -print("BUGNUMBER: 21836"); - -function f () -{ -} - -var SECTION = "apply-001-n"; -var VERSION = "ECMA_1"; -startTest(); -var TITLE = "f.apply(2,2) doesn't crash"; - -writeHeaderToLog( SECTION + " "+ TITLE); - -DESCRIPTION = "f.apply(2,2) doesn't crash"; -EXPECTED = "error"; - -new TestCase( SECTION, "f.apply(2,2) doesn't crash", "error", eval("f.apply(2,2)") ); - -test(); - - diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/FunctionObjects/browser.js b/tests/auto/declarative/parserstress/tests/ecma_2/FunctionObjects/browser.js deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/FunctionObjects/call-1.js b/tests/auto/declarative/parserstress/tests/ecma_2/FunctionObjects/call-1.js deleted file mode 100644 index 283e323797..0000000000 --- a/tests/auto/declarative/parserstress/tests/ecma_2/FunctionObjects/call-1.js +++ /dev/null @@ -1,75 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is JavaScript Engine testing utilities. - * - * The Initial Developer of the Original Code is - * Netscape Communication Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -gTestfile = 'call-1.js'; - -/** - File Name: call-1.js - Section: Function.prototype.call - Description: - - - Author: christine@netscape.com - Date: 12 november 1997 -*/ -var SECTION = "call-1"; -var VERSION = "ECMA_2"; -var TITLE = "Function.prototype.call"; - -startTest(); -writeHeaderToLog( SECTION + " "+ TITLE); - -new TestCase( SECTION, - "ToString.call( this, this )", - GLOBAL, - ToString.call( this, this ) ); - -new TestCase( SECTION, - "ToString.call( Boolean, Boolean.prototype )", - "false", - ToString.call( Boolean, Boolean.prototype ) ); - -new TestCase( SECTION, - "ToString.call( Boolean, Boolean.prototype.valueOf() )", - "false", - ToString.call( Boolean, Boolean.prototype.valueOf() ) ); - -test(); - -function ToString( obj ) { - return obj +""; -} diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/FunctionObjects/shell.js b/tests/auto/declarative/parserstress/tests/ecma_2/FunctionObjects/shell.js deleted file mode 100644 index 27aa7b1318..0000000000 --- a/tests/auto/declarative/parserstress/tests/ecma_2/FunctionObjects/shell.js +++ /dev/null @@ -1 +0,0 @@ -gTestsubsuite = 'FunctionObjects'; diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/LexicalConventions/browser.js b/tests/auto/declarative/parserstress/tests/ecma_2/LexicalConventions/browser.js deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/LexicalConventions/keywords-001.js b/tests/auto/declarative/parserstress/tests/ecma_2/LexicalConventions/keywords-001.js deleted file mode 100644 index 7362613783..0000000000 --- a/tests/auto/declarative/parserstress/tests/ecma_2/LexicalConventions/keywords-001.js +++ /dev/null @@ -1,81 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is JavaScript Engine testing utilities. - * - * The Initial Developer of the Original Code is - * Netscape Communication Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -gTestfile = 'keywords-001.js'; - -/** - * File Name: - * ECMA Section: - * Description: - * - * - * Author: christine@netscape.com - * Date: 11 August 1998 - */ -var SECTION = ""; -var VERSION = "ECMA_2"; -var TITLE = "Keywords"; - -startTest(); - -print("This test requires option javascript.options.strict enabled"); - -if (!options().match(/strict/)) -{ - options('strict'); -} -if (!options().match(/werror/)) -{ - options('werror'); -} - -var result = "failed"; - -try { - eval("super;"); -} -catch (x) { - if (x instanceof SyntaxError) - result = x.name; -} - -AddTestCase( - "using the expression \"super\" shouldn't cause js to crash", - "SyntaxError", - result ); - -test(); diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/LexicalConventions/regexp-literals-001.js b/tests/auto/declarative/parserstress/tests/ecma_2/LexicalConventions/regexp-literals-001.js deleted file mode 100644 index caa50fe363..0000000000 --- a/tests/auto/declarative/parserstress/tests/ecma_2/LexicalConventions/regexp-literals-001.js +++ /dev/null @@ -1,77 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is JavaScript Engine testing utilities. - * - * The Initial Developer of the Original Code is - * Netscape Communication Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -gTestfile = 'regexp-literals-001.js'; - -/** - * File Name: LexicalConventions/regexp-literals-001.js - * ECMA Section: 7.8.5 - * Description: - * - * - * Author: christine@netscape.com - * Date: 11 August 1998 - */ -var SECTION = "LexicalConventions/regexp-literals-001.js"; -var VERSION = "ECMA_2"; -var TITLE = "Regular Expression Literals"; - -startTest(); - -// Regular Expression Literals may not be empty; // should be regarded -// as a comment, not a RegExp literal. - -s = //; - - "passed"; - -AddTestCase( - "// should be a comment, not a regular expression literal", - "passed", - String(s)); - -AddTestCase( - "// typeof object should be type of object declared on following line", - "passed", - (typeof s) == "string" ? "passed" : "failed" ); - -AddTestCase( - "// should not return an object of the type RegExp", - "passed", - (typeof s == "object") ? "failed" : "passed" ); - -test(); diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/LexicalConventions/regexp-literals-002.js b/tests/auto/declarative/parserstress/tests/ecma_2/LexicalConventions/regexp-literals-002.js deleted file mode 100644 index 911b5d117a..0000000000 --- a/tests/auto/declarative/parserstress/tests/ecma_2/LexicalConventions/regexp-literals-002.js +++ /dev/null @@ -1,61 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is JavaScript Engine testing utilities. - * - * The Initial Developer of the Original Code is - * Netscape Communication Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -gTestfile = 'regexp-literals-002.js'; - -/** - * File Name: LexicalConventions/regexp-literals-002.js - * ECMA Section: 7.8.5 - * Description: Based on ECMA 2 Draft 8 October 1999 - * - * Author: christine@netscape.com - * Date: 19 February 1999 - */ -var SECTION = "LexicalConventions/regexp-literals-002.js"; -var VERSION = "ECMA_2"; -var TITLE = "Regular Expression Literals"; - -startTest(); - -// A regular expression literal represents an object of type RegExp. - -AddTestCase( - "// A regular expression literal represents an object of type RegExp.", - "true", - (/x*/ instanceof RegExp).toString() ); - -test(); diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/LexicalConventions/shell.js b/tests/auto/declarative/parserstress/tests/ecma_2/LexicalConventions/shell.js deleted file mode 100644 index 4e1d61d68a..0000000000 --- a/tests/auto/declarative/parserstress/tests/ecma_2/LexicalConventions/shell.js +++ /dev/null @@ -1 +0,0 @@ -gTestsubsuite = 'LexicalConventions'; diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/README b/tests/auto/declarative/parserstress/tests/ecma_2/README deleted file mode 100755 index 6da6cdd514..0000000000 --- a/tests/auto/declarative/parserstress/tests/ecma_2/README +++ /dev/null @@ -1 +0,0 @@ -ECMA 262 Edition 2 diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/RegExp/browser.js b/tests/auto/declarative/parserstress/tests/ecma_2/RegExp/browser.js deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/RegExp/constructor-001.js b/tests/auto/declarative/parserstress/tests/ecma_2/RegExp/constructor-001.js deleted file mode 100644 index f1dba13b06..0000000000 --- a/tests/auto/declarative/parserstress/tests/ecma_2/RegExp/constructor-001.js +++ /dev/null @@ -1,99 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is JavaScript Engine testing utilities. - * - * The Initial Developer of the Original Code is - * Netscape Communication Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -gTestfile = 'constructor-001.js'; - -/** - * File Name: RegExp/constructor-001.js - * ECMA Section: 15.7.3.3 - * Description: Based on ECMA 2 Draft 7 February 1999 - * - * Author: christine@netscape.com - * Date: 19 February 1999 - */ -var SECTION = "RegExp/constructor-001"; -var VERSION = "ECMA_2"; -var TITLE = "new RegExp()"; - -startTest(); - -/* - * for each test case, verify: - * - verify that [[Class]] property is RegExp - * - prototype property should be set to RegExp.prototype - * - source is set to the empty string - * - global property is set to false - * - ignoreCase property is set to false - * - multiline property is set to false - * - lastIndex property is set to 0 - */ - -RegExp.prototype.getClassProperty = Object.prototype.toString; -var re = new RegExp(); - -AddTestCase( - "RegExp.prototype.getClassProperty = Object.prototype.toString; " + - "(new RegExp()).getClassProperty()", - "[object RegExp]", - re.getClassProperty() ); - -AddTestCase( - "(new RegExp()).source", - "", - re.source ); - -AddTestCase( - "(new RegExp()).global", - false, - re.global ); - -AddTestCase( - "(new RegExp()).ignoreCase", - false, - re.ignoreCase ); - -AddTestCase( - "(new RegExp()).multiline", - false, - re.multiline ); - -AddTestCase( - "(new RegExp()).lastIndex", - 0, - re.lastIndex ); - -test() diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/RegExp/exec-001.js b/tests/auto/declarative/parserstress/tests/ecma_2/RegExp/exec-001.js deleted file mode 100644 index 2d1bab472c..0000000000 --- a/tests/auto/declarative/parserstress/tests/ecma_2/RegExp/exec-001.js +++ /dev/null @@ -1,73 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is JavaScript Engine testing utilities. - * - * The Initial Developer of the Original Code is - * Netscape Communication Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -gTestfile = 'exec-001.js'; - -/** - * File Name: RegExp/exec-001.js - * ECMA Section: 15.7.5.3 - * Description: Based on ECMA 2 Draft 7 February 1999 - * - * Author: christine@netscape.com - * Date: 19 February 1999 - */ -var SECTION = "RegExp/exec-001"; -var VERSION = "ECMA_2"; -var TITLE = "RegExp.prototype.exec(string)"; - -startTest(); - -/* - * for each test case, verify: - * - type of object returned - * - length of the returned array - * - value of lastIndex - * - value of index - * - value of input - * - value of the array indices - */ - -// test cases without subpatterns -// test cases with subpatterns -// global property is true -// global property is false -// test cases in which the exec returns null - -AddTestCase("NO TESTS EXIST", "PASSED", "Test not implemented"); - -test(); - diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/RegExp/exec-002.js b/tests/auto/declarative/parserstress/tests/ecma_2/RegExp/exec-002.js deleted file mode 100644 index 026f27d9d4..0000000000 --- a/tests/auto/declarative/parserstress/tests/ecma_2/RegExp/exec-002.js +++ /dev/null @@ -1,221 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is JavaScript Engine testing utilities. - * - * The Initial Developer of the Original Code is - * Netscape Communication Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -gTestfile = 'exec-002.js'; - -/** - * File Name: RegExp/exec-002.js - * ECMA Section: 15.7.5.3 - * Description: Based on ECMA 2 Draft 7 February 1999 - * - * Test cases provided by rogerl@netscape.com - * - * Author: christine@netscape.com - * Date: 19 February 1999 - */ -var SECTION = "RegExp/exec-002"; -var VERSION = "ECMA_2"; -var TITLE = "RegExp.prototype.exec(string)"; - -startTest(); - -/* - * for each test case, verify: - * - type of object returned - * - length of the returned array - * - value of lastIndex - * - value of index - * - value of input - * - value of the array indices - */ - -AddRegExpCases( - /(a|d|q|)x/i, - "bcaDxqy", - 3, - ["Dx", "D"] ); - -AddRegExpCases( - /(a|(e|q))(x|y)/, - "bcaddxqy", - 6, - ["qy","q","q","y"] ); - - -AddRegExpCases( - /a+b+d/, - "aabbeeaabbs", - 0, - null ); - -AddRegExpCases( - /a*b/, - "aaadaabaaa", - 4, - ["aab"] ); - -AddRegExpCases( - /a*b/, - "dddb", - 3, - ["b"] ); - -AddRegExpCases( - /a*b/, - "xxx", - 0, - null ); - -AddRegExpCases( - /x\d\dy/, - "abcx45ysss235", - 3, - ["x45y"] ); - -AddRegExpCases( - /[^abc]def[abc]+/, - "abxdefbb", - 2, - ["xdefbb"] ); - -AddRegExpCases( - /(a*)baa/, - "ccdaaabaxaabaa", - 9, - ["aabaa", "aa"] ); - -AddRegExpCases( - /(a*)baa/, - "aabaa", - 0, - ["aabaa", "aa"] ); - -AddRegExpCases( - /q(a|b)*q/, - "xxqababqyy", - 2, - ["qababq", "b"] ); - -AddRegExpCases( - /(a(.|[^d])c)*/, - "adcaxc", - 0, - ["adcaxc", "axc", "x"] ); - -AddRegExpCases( - /(a*)b\1/, - "abaaaxaabaayy", - 0, - ["aba", "a"] ); - -AddRegExpCases( - /(a*)b\1/, - "abaaaxaabaayy", - 0, - ["aba", "a"] ); - -AddRegExpCases( - /(a*)b\1/, - "cccdaaabaxaabaayy", - 6, - ["aba", "a"] ); - -AddRegExpCases( - /(a*)b\1/, - "cccdaaabqxaabaayy", - 7, - ["b", ""] ); - -AddRegExpCases( - /"(.|[^"\\\\])*"/, - 'xx\"makudonarudo\"yy', - 2, - ["\"makudonarudo\"", "o"] ); - - AddRegExpCases( - /"(.|[^"\\\\])*"/, - "xx\"ma\"yy", - 2, - ["\"ma\"", "a"] ); - - test(); - - function AddRegExpCases( - regexp, pattern, index, matches_array ) { - -// prevent a runtime error - - if ( regexp.exec(pattern) == null || matches_array == null ) { - AddTestCase( - regexp + ".exec(" + pattern +")", - matches_array, - regexp.exec(pattern) ); - - return; - } - AddTestCase( - regexp + ".exec(" + pattern +").length", - matches_array.length, - regexp.exec(pattern).length ); - - AddTestCase( - regexp + ".exec(" + pattern +").index", - index, - regexp.exec(pattern).index ); - - AddTestCase( - regexp + ".exec(" + pattern +").input", - pattern, - regexp.exec(pattern).input ); - - AddTestCase( - regexp + ".exec(" + pattern +").toString()", - matches_array.toString(), - regexp.exec(pattern).toString() ); -/* - var limit = matches_array.length > regexp.exec(pattern).length - ? matches_array.length - : regexp.exec(pattern).length; - - for ( var matches = 0; matches < limit; matches++ ) { - AddTestCase( - regexp + ".exec(" + pattern +")[" + matches +"]", - matches_array[matches], - regexp.exec(pattern)[matches] ); - } -*/ - } diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/RegExp/function-001.js b/tests/auto/declarative/parserstress/tests/ecma_2/RegExp/function-001.js deleted file mode 100644 index 8b219b935b..0000000000 --- a/tests/auto/declarative/parserstress/tests/ecma_2/RegExp/function-001.js +++ /dev/null @@ -1,99 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is JavaScript Engine testing utilities. - * - * The Initial Developer of the Original Code is - * Netscape Communication Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -gTestfile = 'function-001.js'; - -/** - * File Name: RegExp/function-001.js - * ECMA Section: 15.7.2.1 - * Description: Based on ECMA 2 Draft 7 February 1999 - * - * Author: christine@netscape.com - * Date: 19 February 1999 - */ -var SECTION = "RegExp/function-001"; -var VERSION = "ECMA_2"; -var TITLE = "RegExp( pattern, flags )"; - -startTest(); - -/* - * for each test case, verify: - * - verify that [[Class]] property is RegExp - * - prototype property should be set to RegExp.prototype - * - source is set to the empty string - * - global property is set to false - * - ignoreCase property is set to false - * - multiline property is set to false - * - lastIndex property is set to 0 - */ - -RegExp.prototype.getClassProperty = Object.prototype.toString; -var re = new RegExp(); - -AddTestCase( - "RegExp.prototype.getClassProperty = Object.prototype.toString; " + - "(new RegExp()).getClassProperty()", - "[object RegExp]", - re.getClassProperty() ); - -AddTestCase( - "(new RegExp()).source", - "", - re.source ); - -AddTestCase( - "(new RegExp()).global", - false, - re.global ); - -AddTestCase( - "(new RegExp()).ignoreCase", - false, - re.ignoreCase ); - -AddTestCase( - "(new RegExp()).multiline", - false, - re.multiline ); - -AddTestCase( - "(new RegExp()).lastIndex", - 0, - re.lastIndex ); - -test() diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/RegExp/hex-001.js b/tests/auto/declarative/parserstress/tests/ecma_2/RegExp/hex-001.js deleted file mode 100644 index 3e85ac7abf..0000000000 --- a/tests/auto/declarative/parserstress/tests/ecma_2/RegExp/hex-001.js +++ /dev/null @@ -1,102 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is JavaScript Engine testing utilities. - * - * The Initial Developer of the Original Code is - * Netscape Communication Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -gTestfile = 'hex-001.js'; - -/** - * File Name: RegExp/hex-001.js - * ECMA Section: 15.7.3.1 - * Description: Based on ECMA 2 Draft 7 February 1999 - * Positive test cases for constructing a RegExp object - * Author: christine@netscape.com - * Date: 19 February 1999 - */ -var SECTION = "RegExp/hex-001"; -var VERSION = "ECMA_2"; -var TITLE = "RegExp patterns that contain HexicdecimalEscapeSequences"; - -startTest(); - -// These examples come from 15.7.1, HexidecimalEscapeSequence - -AddRegExpCases( new RegExp("\x41"), "new RegExp('\\x41')", "A", "A", 1, 0, ["A"] ); -AddRegExpCases( new RegExp("\x412"),"new RegExp('\\x412')", "A2", "A2", 1, 0, ["A2"] ); -AddRegExpCases( new RegExp("\x1g"), "new RegExp('\\x1g')", "x1g","x1g", 1, 0, ["x1g"] ); - -AddRegExpCases( new RegExp("A"), "new RegExp('A')", "\x41", "\\x41", 1, 0, ["A"] ); -AddRegExpCases( new RegExp("A"), "new RegExp('A')", "\x412", "\\x412", 1, 0, ["A"] ); -AddRegExpCases( new RegExp("^x"), "new RegExp('^x')", "x412", "x412", 1, 0, ["x"]); -AddRegExpCases( new RegExp("A"), "new RegExp('A')", "A2", "A2", 1, 0, ["A"] ); - -test(); - -function AddRegExpCases( - regexp, str_regexp, pattern, str_pattern, length, index, matches_array ) { - - // prevent a runtime error - - if ( regexp.exec(pattern) == null || matches_array == null ) { - AddTestCase( - str_regexp + ".exec(" + pattern +")", - matches_array, - regexp.exec(pattern) ); - - return; - } - - AddTestCase( - str_regexp + ".exec(" + str_pattern +").length", - length, - regexp.exec(pattern).length ); - - AddTestCase( - str_regexp + ".exec(" + str_pattern +").index", - index, - regexp.exec(pattern).index ); - - AddTestCase( - str_regexp + ".exec(" + str_pattern +").input", - pattern, - regexp.exec(pattern).input ); - - for ( var matches = 0; matches < matches_array.length; matches++ ) { - AddTestCase( - str_regexp + ".exec(" + str_pattern +")[" + matches +"]", - matches_array[matches], - regexp.exec(pattern)[matches] ); - } -} diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/RegExp/multiline-001.js b/tests/auto/declarative/parserstress/tests/ecma_2/RegExp/multiline-001.js deleted file mode 100644 index 102f91fcd4..0000000000 --- a/tests/auto/declarative/parserstress/tests/ecma_2/RegExp/multiline-001.js +++ /dev/null @@ -1,101 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is JavaScript Engine testing utilities. - * - * The Initial Developer of the Original Code is - * Netscape Communication Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -gTestfile = 'multiline-001.js'; - -/** - * File Name: RegExp/multiline-001.js - * ECMA Section: - * Description: Based on ECMA 2 Draft 7 February 1999 - * - * Date: 19 February 1999 - */ - -var SECTION = "RegExp/multiline-001"; -var VERSION = "ECMA_2"; -var TITLE = "RegExp: multiline flag"; -var BUGNUMBER="343901"; - -startTest(); - -var woodpeckers = "ivory-billed\ndowny\nhairy\nacorn\nyellow-bellied sapsucker\n" + - "northern flicker\npileated\n"; - -AddRegExpCases( /.*[y]$/m, woodpeckers, woodpeckers.indexOf("downy"), ["downy"] ); - -AddRegExpCases( /.*[d]$/m, woodpeckers, woodpeckers.indexOf("ivory-billed"), ["ivory-billed"] ); - -test(); - - -function AddRegExpCases -( regexp, pattern, index, matches_array ) { - - // prevent a runtime error - - if ( regexp.exec(pattern) == null || matches_array == null ) { - AddTestCase( - regexp + ".exec(" + pattern +")", - matches_array, - regexp.exec(pattern) ); - - return; - } - - AddTestCase( - regexp.toString() + ".exec(" + pattern +").length", - matches_array.length, - regexp.exec(pattern).length ); - - AddTestCase( - regexp.toString() + ".exec(" + pattern +").index", - index, - regexp.exec(pattern).index ); - - AddTestCase( - regexp + ".exec(" + pattern +").input", - pattern, - regexp.exec(pattern).input ); - - - for ( var matches = 0; matches < matches_array.length; matches++ ) { - AddTestCase( - regexp + ".exec(" + pattern +")[" + matches +"]", - matches_array[matches], - regexp.exec(pattern)[matches] ); - } -} diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/RegExp/octal-001.js b/tests/auto/declarative/parserstress/tests/ecma_2/RegExp/octal-001.js deleted file mode 100644 index 1c520750ce..0000000000 --- a/tests/auto/declarative/parserstress/tests/ecma_2/RegExp/octal-001.js +++ /dev/null @@ -1,111 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is JavaScript Engine testing utilities. - * - * The Initial Developer of the Original Code is - * Netscape Communication Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -gTestfile = 'octal-001.js'; - -/** - * File Name: RegExp/octal-001.js - * ECMA Section: 15.7.1 - * Description: Based on ECMA 2 Draft 7 February 1999 - * Simple test cases for matching OctalEscapeSequences. - * Author: christine@netscape.com - * Date: 19 February 1999 - */ -var SECTION = "RegExp/octal-001.js"; -var VERSION = "ECMA_2"; -var TITLE = "RegExp patterns that contain OctalEscapeSequences"; -var BUGNUMBER="http://scopus/bugsplat/show_bug.cgi?id=346196"; - -startTest(); - - -// backreference -AddRegExpCases( - /(.)\1/, - "/(.)\\1/", - "HI!!", - "HI!", - 2, - ["!!", "!"] ); - -test(); - -function AddRegExpCases( - regexp, str_regexp, pattern, str_pattern, index, matches_array ) { - - // prevent a runtime error - - if ( regexp.exec(pattern) == null || matches_array == null ) { - AddTestCase( - regexp + ".exec(" + str_pattern +")", - matches_array, - regexp.exec(pattern) ); - - return; - } - AddTestCase( - str_regexp + ".exec(" + str_pattern +").length", - matches_array.length, - regexp.exec(pattern).length ); - - AddTestCase( - str_regexp + ".exec(" + str_pattern +").index", - index, - regexp.exec(pattern).index ); - - AddTestCase( - str_regexp + ".exec(" + str_pattern +").input", - pattern, - regexp.exec(pattern).input ); - - AddTestCase( - str_regexp + ".exec(" + str_pattern +").toString()", - matches_array.toString(), - regexp.exec(pattern).toString() ); -/* - var limit = matches_array.length > regexp.exec(pattern).length - ? matches_array.length - : regexp.exec(pattern).length; - - for ( var matches = 0; matches < limit; matches++ ) { - AddTestCase( - str_regexp + ".exec(" + str_pattern +")[" + matches +"]", - matches_array[matches], - regexp.exec(pattern)[matches] ); - } -*/ -} diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/RegExp/octal-002.js b/tests/auto/declarative/parserstress/tests/ecma_2/RegExp/octal-002.js deleted file mode 100644 index b654e5e68a..0000000000 --- a/tests/auto/declarative/parserstress/tests/ecma_2/RegExp/octal-002.js +++ /dev/null @@ -1,126 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is JavaScript Engine testing utilities. - * - * The Initial Developer of the Original Code is - * Netscape Communication Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -gTestfile = 'octal-002.js'; - -/** - * File Name: RegExp/octal-002.js - * ECMA Section: 15.7.1 - * Description: Based on ECMA 2 Draft 7 February 1999 - * Simple test cases for matching OctalEscapeSequences. - * Author: christine@netscape.com - * Date: 19 February 1999 - */ -var SECTION = "RegExp/octal-002.js"; -var VERSION = "ECMA_2"; -var TITLE = "RegExp patterns that contain OctalEscapeSequences"; -var BUGNUMBER="http://scopus/bugsplat/show_bug.cgi?id=346189"; - -startTest(); - -// backreference -AddRegExpCases( - /(.)(.)(.)(.)(.)(.)(.)(.)\8/, - "/(.)(.)(.)(.)(.)(.)(.)(.)\\8", - "aabbccaaabbbccc", - "aabbccaaabbbccc", - 0, - ["aabbccaaa", "a", "a", "b", "b", "c", "c", "a", "a"] ); - -AddRegExpCases( - /(.)(.)(.)(.)(.)(.)(.)(.)(.)\9/, - "/(.)(.)(.)(.)(.)(.)(.)(.)\\9", - "aabbccaabbcc", - "aabbccaabbcc", - 0, - ["aabbccaabb", "a", "a", "b", "b", "c", "c", "a", "a", "b"] ); - -AddRegExpCases( - /(.)(.)(.)(.)(.)(.)(.)(.)(.)\8/, - "/(.)(.)(.)(.)(.)(.)(.)(.)(.)\\8", - "aabbccaababcc", - "aabbccaababcc", - 0, - ["aabbccaaba", "a", "a", "b", "b", "c", "c", "a", "a", "b"] ); - -test(); - -function AddRegExpCases( - regexp, str_regexp, pattern, str_pattern, index, matches_array ) { - - // prevent a runtime error - - if ( regexp.exec(pattern) == null || matches_array == null ) { - AddTestCase( - regexp + ".exec(" + str_pattern +")", - matches_array, - regexp.exec(pattern) ); - - return; - } - AddTestCase( - str_regexp + ".exec(" + str_pattern +").length", - matches_array.length, - regexp.exec(pattern).length ); - - AddTestCase( - str_regexp + ".exec(" + str_pattern +").index", - index, - regexp.exec(pattern).index ); - - AddTestCase( - str_regexp + ".exec(" + str_pattern +").input", - pattern, - regexp.exec(pattern).input ); - - AddTestCase( - str_regexp + ".exec(" + str_pattern +").toString()", - matches_array.toString(), - regexp.exec(pattern).toString() ); -/* - var limit = matches_array.length > regexp.exec(pattern).length - ? matches_array.length - : regexp.exec(pattern).length; - - for ( var matches = 0; matches < limit; matches++ ) { - AddTestCase( - str_regexp + ".exec(" + str_pattern +")[" + matches +"]", - matches_array[matches], - regexp.exec(pattern)[matches] ); - } -*/ -} diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/RegExp/octal-003.js b/tests/auto/declarative/parserstress/tests/ecma_2/RegExp/octal-003.js deleted file mode 100644 index ee07ca602b..0000000000 --- a/tests/auto/declarative/parserstress/tests/ecma_2/RegExp/octal-003.js +++ /dev/null @@ -1,120 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is JavaScript Engine testing utilities. - * - * The Initial Developer of the Original Code is - * Netscape Communication Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -gTestfile = 'octal-003.js'; - -/** - * File Name: RegExp/octal-003.js - * ECMA Section: 15.7.1 - * Description: Based on ECMA 2 Draft 7 February 1999 - * Simple test cases for matching OctalEscapeSequences. - * Author: christine@netscape.com - * Date: 19 February 1999 - * - * Revised: 02 August 2002 - * Author: pschwartau@netscape.com - * - * WHY: the original test expected the regexp /.\011/ - * to match 'a' + String.fromCharCode(0) + '11' - * - * This is incorrect: the string is a 4-character string consisting of - * the characters <'a'>, , <'1'>, <'1'>. By contrast, the \011 in the - * regexp should be parsed as a single token: it is the octal escape sequence - * for the horizontal tab character '\t' === '\u0009' === '\x09' === '\011'. - * - * So the regexp consists of 2 characters: , <'\t'>. - * There is no match between the regexp and the string. - * - * See the testcase ecma_3/RegExp/octal-002.js for an elaboration. - * - */ -var SECTION = "RegExp/octal-003.js"; -var VERSION = "ECMA_2"; -var TITLE = "RegExp patterns that contain OctalEscapeSequences"; -var BUGNUMBER="http://scopus/bugsplat/show_bug.cgi?id=346132"; - -startTest(); - -AddRegExpCases( /.\011/, "/\\011/", "a" + String.fromCharCode(0) + "11", "a\\011", 0, null ); - -test(); - -function AddRegExpCases( - regexp, str_regexp, pattern, str_pattern, index, matches_array ) { - - // prevent a runtime error - - if ( regexp.exec(pattern) == null || matches_array == null ) { - AddTestCase( - regexp + ".exec(" + str_pattern +")", - matches_array, - regexp.exec(pattern) ); - - return; - } - AddTestCase( - str_regexp + ".exec(" + str_pattern +").length", - matches_array.length, - regexp.exec(pattern).length ); - - AddTestCase( - str_regexp + ".exec(" + str_pattern +").index", - index, - regexp.exec(pattern).index ); - - AddTestCase( - str_regexp + ".exec(" + str_pattern +").input", - escape(pattern), - escape(regexp.exec(pattern).input) ); - - AddTestCase( - str_regexp + ".exec(" + str_pattern +").toString()", - matches_array.toString(), - escape(regexp.exec(pattern).toString()) ); - - var limit = matches_array.length > regexp.exec(pattern).length - ? matches_array.length - : regexp.exec(pattern).length; - - for ( var matches = 0; matches < limit; matches++ ) { - AddTestCase( - str_regexp + ".exec(" + str_pattern +")[" + matches +"]", - matches_array[matches], - escape(regexp.exec(pattern)[matches]) ); - } - -} diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/RegExp/properties-001.js b/tests/auto/declarative/parserstress/tests/ecma_2/RegExp/properties-001.js deleted file mode 100644 index 7d2913cc53..0000000000 --- a/tests/auto/declarative/parserstress/tests/ecma_2/RegExp/properties-001.js +++ /dev/null @@ -1,124 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is JavaScript Engine testing utilities. - * - * The Initial Developer of the Original Code is - * Netscape Communication Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -gTestfile = 'properties-001.js'; - -/** - * File Name: RegExp/properties-001.js - * ECMA Section: 15.7.6.js - * Description: Based on ECMA 2 Draft 7 February 1999 - * - * Author: christine@netscape.com - * Date: 19 February 1999 - */ -var SECTION = "RegExp/properties-001.js"; -var VERSION = "ECMA_2"; -var TITLE = "Properties of RegExp Instances"; -var BUGNUMBER =""; - -startTest(); - -AddRegExpCases( new RegExp, "", false, false, false, 0 ); -AddRegExpCases( /.*/, ".*", false, false, false, 0 ); -AddRegExpCases( /[\d]{5}/g, "[\\d]{5}", true, false, false, 0 ); -AddRegExpCases( /[\S]?$/i, "[\\S]?$", false, true, false, 0 ); -AddRegExpCases( /^([a-z]*)[^\w\s\f\n\r]+/m, "^([a-z]*)[^\\w\\s\\f\\n\\r]+", false, false, true, 0 ); -AddRegExpCases( /[\D]{1,5}[\ -][\d]/gi, "[\\D]{1,5}[\\ -][\\d]", true, true, false, 0 ); -AddRegExpCases( /[a-zA-Z0-9]*/gm, "[a-zA-Z0-9]*", true, false, true, 0 ); -AddRegExpCases( /x|y|z/gim, "x|y|z", true, true, true, 0 ); - -AddRegExpCases( /\u0051/im, "\\u0051", false, true, true, 0 ); -AddRegExpCases( /\x45/gm, "\\x45", true, false, true, 0 ); -AddRegExpCases( /\097/gi, "\\097", true, true, false, 0 ); - -test(); - -function AddRegExpCases( re, s, g, i, m, l ) { - - AddTestCase( re + ".test == RegExp.prototype.test", - true, - re.test == RegExp.prototype.test ); - - AddTestCase( re + ".toString == RegExp.prototype.toString", - true, - re.toString == RegExp.prototype.toString ); - - AddTestCase( re + ".contructor == RegExp.prototype.constructor", - true, - re.constructor == RegExp.prototype.constructor ); - - AddTestCase( re + ".compile == RegExp.prototype.compile", - true, - re.compile == RegExp.prototype.compile ); - - AddTestCase( re + ".exec == RegExp.prototype.exec", - true, - re.exec == RegExp.prototype.exec ); - - // properties - - AddTestCase( re + ".source", - s, - re.source ); - -/* - * http://bugzilla.mozilla.org/show_bug.cgi?id=225550 changed - * the behavior of toString() and toSource() on empty regexps. - * So branch if |s| is the empty string - - */ - var S = s? s : '(?:)'; - - AddTestCase( re + ".toString()", - "/" + S +"/" + (g?"g":"") + (i?"i":"") +(m?"m":""), - re.toString() ); - - AddTestCase( re + ".global", - g, - re.global ); - - AddTestCase( re + ".ignoreCase", - i, - re.ignoreCase ); - - AddTestCase( re + ".multiline", - m, - re.multiline); - - AddTestCase( re + ".lastIndex", - l, - re.lastIndex ); -} diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/RegExp/properties-002.js b/tests/auto/declarative/parserstress/tests/ecma_2/RegExp/properties-002.js deleted file mode 100644 index 1fcfd8d219..0000000000 --- a/tests/auto/declarative/parserstress/tests/ecma_2/RegExp/properties-002.js +++ /dev/null @@ -1,162 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is JavaScript Engine testing utilities. - * - * The Initial Developer of the Original Code is - * Netscape Communication Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -gTestfile = 'properties-002.js'; - -/** - * File Name: RegExp/properties-002.js - * ECMA Section: 15.7.6.js - * Description: Based on ECMA 2 Draft 7 February 1999 - * - * Author: christine@netscape.com - * Date: 19 February 1999 - */ -//----------------------------------------------------------------------------- -var SECTION = "RegExp/properties-002.js"; -var VERSION = "ECMA_2"; -var TITLE = "Properties of RegExp Instances"; -var BUGNUMBER ="124339"; - -startTest(); - -re_1 = /\cA?/g; -re_1.lastIndex = Math.pow(2,31); -AddRegExpCases( re_1, "\\cA?", true, false, false, Math.pow(2,31) ); - -re_2 = /\w*/i; -re_2.lastIndex = Math.pow(2,32) -1; -AddRegExpCases( re_2, "\\w*", false, true, false, Math.pow(2,32)-1 ); - -re_3 = /\*{0,80}/m; -re_3.lastIndex = Math.pow(2,31) -1; -AddRegExpCases( re_3, "\\*{0,80}", false, false, true, Math.pow(2,31) -1 ); - -re_4 = /^./gim; -re_4.lastIndex = Math.pow(2,30) -1; -AddRegExpCases( re_4, "^.", true, true, true, Math.pow(2,30) -1 ); - -re_5 = /\B/; -re_5.lastIndex = Math.pow(2,30); -AddRegExpCases( re_5, "\\B", false, false, false, Math.pow(2,30) ); - -/* - * Brendan: "need to test cases Math.pow(2,32) and greater to see - * whether they round-trip." Reason: thanks to the work done in - * http://bugzilla.mozilla.org/show_bug.cgi?id=124339, lastIndex - * is now stored as a double instead of a uint32 (unsigned integer). - * - * Note 2^32 -1 is the upper bound for uint32's, but doubles can go - * all the way up to Number.MAX_VALUE. So that's why we need cases - * between those two numbers. - * - */ -re_6 = /\B/; -re_6.lastIndex = Math.pow(2,32); -AddRegExpCases( re_6, "\\B", false, false, false, Math.pow(2,32) ); - -re_7 = /\B/; -re_7.lastIndex = Math.pow(2,32) + 1; -AddRegExpCases( re_7, "\\B", false, false, false, Math.pow(2,32) + 1 ); - -re_8 = /\B/; -re_8.lastIndex = Math.pow(2,32) * 2; -AddRegExpCases( re_8, "\\B", false, false, false, Math.pow(2,32) * 2 ); - -re_9 = /\B/; -re_9.lastIndex = Math.pow(2,40); -AddRegExpCases( re_9, "\\B", false, false, false, Math.pow(2,40) ); - -re_10 = /\B/; -re_10.lastIndex = Number.MAX_VALUE; -AddRegExpCases( re_10, "\\B", false, false, false, Number.MAX_VALUE ); - - - -//----------------------------------------------------------------------------- -test(); -//----------------------------------------------------------------------------- - - - -function AddRegExpCases( re, s, g, i, m, l ){ - - AddTestCase( re + ".test == RegExp.prototype.test", - true, - re.test == RegExp.prototype.test ); - - AddTestCase( re + ".toString == RegExp.prototype.toString", - true, - re.toString == RegExp.prototype.toString ); - - AddTestCase( re + ".contructor == RegExp.prototype.constructor", - true, - re.constructor == RegExp.prototype.constructor ); - - AddTestCase( re + ".compile == RegExp.prototype.compile", - true, - re.compile == RegExp.prototype.compile ); - - AddTestCase( re + ".exec == RegExp.prototype.exec", - true, - re.exec == RegExp.prototype.exec ); - - // properties - - AddTestCase( re + ".source", - s, - re.source ); - - AddTestCase( re + ".toString()", - "/" + s +"/" + (g?"g":"") + (i?"i":"") +(m?"m":""), - re.toString() ); - - AddTestCase( re + ".global", - g, - re.global ); - - AddTestCase( re + ".ignoreCase", - i, - re.ignoreCase ); - - AddTestCase( re + ".multiline", - m, - re.multiline); - - AddTestCase( re + ".lastIndex", - l, - re.lastIndex ); -} diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/RegExp/regexp-enumerate-001.js b/tests/auto/declarative/parserstress/tests/ecma_2/RegExp/regexp-enumerate-001.js deleted file mode 100644 index c26a1216ea..0000000000 --- a/tests/auto/declarative/parserstress/tests/ecma_2/RegExp/regexp-enumerate-001.js +++ /dev/null @@ -1,121 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is JavaScript Engine testing utilities. - * - * The Initial Developer of the Original Code is - * Netscape Communication Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -gTestfile = 'regexp-enumerate-001.js'; - -/** - File Name: regexp-enumerate-001.js - ECMA V2 Section: - Description: Regression Test. - - If instance Native Object have properties that are enumerable, - JavaScript enumerated through the properties twice. This only - happened if objects had been instantiated, but their properties - had not been enumerated. ie, the object inherited properties - from its prototype that are enumerated. - - In the core JavaScript, this is only a problem with RegExp - objects, since the inherited properties of most core JavaScript - objects are not enumerated. - - Author: christine@netscape.com, pschwartau@netscape.com - Date: 12 November 1997 - Modified: 14 July 2002 - Reason: See http://bugzilla.mozilla.org/show_bug.cgi?id=155291 - ECMA-262 Ed.3 Sections 15.10.7.1 through 15.10.7.5 - RegExp properties should be DontEnum - * - */ -// onerror = err; - -var SECTION = "regexp-enumerate-001"; -var VERSION = "ECMA_2"; -var TITLE = "Regression Test for Enumerating Properties"; - -var BUGNUMBER="339403"; - -startTest(); -writeHeaderToLog( SECTION + " "+ TITLE); - -/* - * This test expects RegExp instances to have four enumerated properties: - * source, global, ignoreCase, and lastIndex - * - * 99.01.25: now they also have a multiLine instance property. - * - */ - - -var r = new RegExp(); - -var e = new Array(); - -var t = new TestRegExp(); - -for ( p in r ) { e[e.length] = { property:p, value:r[p] }; t.addProperty( p, r[p]) }; - -new TestCase( SECTION, - "r = new RegExp(); e = new Array(); "+ - "for ( p in r ) { e[e.length] = { property:p, value:r[p] }; e.length", - 0, - e.length ); - -test(); - -function TestRegExp() { - this.addProperty = addProperty; -} -function addProperty(name, value) { - var pass = false; - - if ( eval("this."+name) != void 0 ) { - pass = true; - } else { - eval( "this."+ name+" = "+ false ); - } - - new TestCase( SECTION, - "Property: " + name +" already enumerated?", - false, - pass ); - - if ( gTestcases[ gTestcases.length-1].passed == false ) { - gTestcases[gTestcases.length-1].reason = "property already enumerated"; - - } - -} diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/RegExp/regress-001.js b/tests/auto/declarative/parserstress/tests/ecma_2/RegExp/regress-001.js deleted file mode 100644 index 219ce245ee..0000000000 --- a/tests/auto/declarative/parserstress/tests/ecma_2/RegExp/regress-001.js +++ /dev/null @@ -1,78 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is JavaScript Engine testing utilities. - * - * The Initial Developer of the Original Code is - * Netscape Communication Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -gTestfile = 'regress-001.js'; - -/** - * File Name: RegExp/regress-001.js - * ECMA Section: N/A - * Description: Regression test case: - * JS regexp anchoring on empty match bug - * http://bugzilla.mozilla.org/show_bug.cgi?id=2157 - * - * Author: christine@netscape.com - * Date: 19 February 1999 - */ -var SECTION = "RegExp/hex-001.js"; -var VERSION = "ECMA_2"; -var TITLE = "JS regexp anchoring on empty match bug"; -var BUGNUMBER = "2157"; - -startTest(); - -AddRegExpCases( /a||b/(''), - "//a||b/('')", - 1, - [''] ); - -test(); - -function AddRegExpCases( regexp, str_regexp, length, matches_array ) { - - AddTestCase( - "( " + str_regexp + " ).length", - regexp.length, - regexp.length ); - - - for ( var matches = 0; matches < matches_array.length; matches++ ) { - AddTestCase( - "( " + str_regexp + " )[" + matches +"]", - matches_array[matches], - regexp[matches] ); - } -} diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/RegExp/shell.js b/tests/auto/declarative/parserstress/tests/ecma_2/RegExp/shell.js deleted file mode 100644 index 9b4657d963..0000000000 --- a/tests/auto/declarative/parserstress/tests/ecma_2/RegExp/shell.js +++ /dev/null @@ -1 +0,0 @@ -gTestsubsuite = 'RegExp'; diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/RegExp/unicode-001.js b/tests/auto/declarative/parserstress/tests/ecma_2/RegExp/unicode-001.js deleted file mode 100644 index 79a3212a2e..0000000000 --- a/tests/auto/declarative/parserstress/tests/ecma_2/RegExp/unicode-001.js +++ /dev/null @@ -1,92 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is JavaScript Engine testing utilities. - * - * The Initial Developer of the Original Code is - * Netscape Communication Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -gTestfile = 'unicode-001.js'; - -/** - * File Name: RegExp/unicode-001.js - * ECMA Section: 15.7.3.1 - * Description: Based on ECMA 2 Draft 7 February 1999 - * Positive test cases for constructing a RegExp object - * Author: christine@netscape.com - * Date: 19 February 1999 - */ -var SECTION = "RegExp/unicode-001.js"; -var VERSION = "ECMA_2"; -var TITLE = "new RegExp( pattern, flags )"; - -startTest(); - -// These examples come from 15.7.1, UnicodeEscapeSequence - -AddRegExpCases( /\u0041/, "/\\u0041/", "A", "A", 1, 0, ["A"] ); -AddRegExpCases( /\u00412/, "/\\u00412/", "A2", "A2", 1, 0, ["A2"] ); -AddRegExpCases( /\u00412/, "/\\u00412/", "A2", "A2", 1, 0, ["A2"] ); -AddRegExpCases( /\u001g/, "/\\u001g/", "u001g", "u001g", 1, 0, ["u001g"] ); - -AddRegExpCases( /A/, "/A/", "\u0041", "\\u0041", 1, 0, ["A"] ); -AddRegExpCases( /A/, "/A/", "\u00412", "\\u00412", 1, 0, ["A"] ); -AddRegExpCases( /A2/, "/A2/", "\u00412", "\\u00412", 1, 0, ["A2"]); -AddRegExpCases( /A/, "/A/", "A2", "A2", 1, 0, ["A"] ); - -test(); - -function AddRegExpCases( - regexp, str_regexp, pattern, str_pattern, length, index, matches_array ) { - - AddTestCase( - str_regexp + " .exec(" + str_pattern +").length", - length, - regexp.exec(pattern).length ); - - AddTestCase( - str_regexp + " .exec(" + str_pattern +").index", - index, - regexp.exec(pattern).index ); - - AddTestCase( - str_regexp + " .exec(" + str_pattern +").input", - pattern, - regexp.exec(pattern).input ); - - for ( var matches = 0; matches < matches_array.length; matches++ ) { - AddTestCase( - str_regexp + " .exec(" + str_pattern +")[" + matches +"]", - matches_array[matches], - regexp.exec(pattern)[matches] ); - } -} diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Statements/browser.js b/tests/auto/declarative/parserstress/tests/ecma_2/Statements/browser.js deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Statements/dowhile-001.js b/tests/auto/declarative/parserstress/tests/ecma_2/Statements/dowhile-001.js deleted file mode 100644 index 8cfdc25dd6..0000000000 --- a/tests/auto/declarative/parserstress/tests/ecma_2/Statements/dowhile-001.js +++ /dev/null @@ -1,77 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is JavaScript Engine testing utilities. - * - * The Initial Developer of the Original Code is - * Netscape Communication Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -gTestfile = 'dowhile-001.js'; - -/** - * File Name: dowhile-001 - * ECMA Section: - * Description: do...while statements - * - * - * - * Author: christine@netscape.com - * Date: 11 August 1998 - */ -var SECTION = "dowhile-002"; -var VERSION = "ECMA_2"; -var TITLE = "do...while with a labeled continue statement"; - -startTest(); -writeHeaderToLog( SECTION + " "+ TITLE); - -LabeledContinue( 0, 1 ); -LabeledContinue( 1, 1 ); -LabeledContinue( -1, 1 ); -LabeledContinue( 5, 5 ); - -test(); - -function LabeledContinue( limit, expect ) { - i = 0; -woohoo: - do { - i++; - continue woohoo; - } while ( i < limit ); - - new TestCase( - SECTION, - "do while ( " + i +" < " + limit +" )", - expect, - i ); -} diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Statements/dowhile-002.js b/tests/auto/declarative/parserstress/tests/ecma_2/Statements/dowhile-002.js deleted file mode 100644 index ca53dff899..0000000000 --- a/tests/auto/declarative/parserstress/tests/ecma_2/Statements/dowhile-002.js +++ /dev/null @@ -1,104 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is JavaScript Engine testing utilities. - * - * The Initial Developer of the Original Code is - * Netscape Communication Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -gTestfile = 'dowhile-002.js'; - -/** - * File Name: dowhile-002 - * ECMA Section: - * Description: do...while statements - * - * Verify that code after a labeled break is not executed. Verify that - * a labeled break breaks you out of the whole labeled block, and not - * just the current iteration statement. - * - * Author: christine@netscape.com - * Date: 11 August 1998 - */ -var SECTION = "dowhile-002"; -var VERSION = "ECMA_2"; -var TITLE = "do...while with a labeled continue statement"; - -startTest(); -writeHeaderToLog( SECTION + " "+ TITLE); - -LabeledContinue( 0, 1 ); -LabeledContinue( 1, 1 ); -LabeledContinue( -1, 1 ); -LabeledContinue( 5, 5 ); - -test(); - -// The labeled statement contains statements after the labeled break. -// Verify that the statements after the break are not executed. - -function LabeledContinue( limit, expect ) { - i = 0; - result1 = "pass"; - result2 = "pass"; - -woohoo: { - do { - i++; - if ( ! (i < limit) ) { - break woohoo; - result1 = "fail: evaluated statement after a labeled break"; - } - } while ( true ); - - result2 = "failed: broke out of loop, but not out of labeled block"; - } - - new TestCase( - SECTION, - "do while ( " + i +" < " + limit +" )", - expect, - i ); - - new TestCase( - SECTION, - "breaking out of a do... while loop", - "pass", - result1 ); - - - new TestCase( - SECTION, - "breaking out of a labeled do...while loop", - "pass", - result2 ); -} diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Statements/dowhile-003.js b/tests/auto/declarative/parserstress/tests/ecma_2/Statements/dowhile-003.js deleted file mode 100644 index 598f655f8d..0000000000 --- a/tests/auto/declarative/parserstress/tests/ecma_2/Statements/dowhile-003.js +++ /dev/null @@ -1,96 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is JavaScript Engine testing utilities. - * - * The Initial Developer of the Original Code is - * Netscape Communication Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -gTestfile = 'dowhile-003.js'; - -/** - * File Name: dowhile-003 - * ECMA Section: - * Description: do...while statements - * - * Test do while, when the while expression is a JavaScript Number object. - * - * - * Author: christine@netscape.com - * Date: 11 August 1998 - */ -var SECTION = "dowhile-003"; -var VERSION = "ECMA_2"; -var TITLE = "do...while with a labeled continue statement"; - -startTest(); -writeHeaderToLog( SECTION + " "+ TITLE); - -DoWhile( new DoWhileObject( 1, 1, 0 )); -DoWhile( new DoWhileObject( 1000, 1000, 0 )); -DoWhile( new DoWhileObject( 1001, 1001, 0 )); -DoWhile( new DoWhileObject( 1002, 1001, 1 )); -DoWhile( new DoWhileObject( -1, 1001, -1002 )); - -test(); - -function DoWhileObject( value, iterations, endvalue ) { - this.value = value; - this.iterations = iterations; - this.endvalue = endvalue; -} - -function DoWhile( object ) { - var i = 0; - - do { - object.value = --object.value; - i++; - if ( i > 1000 ) - break; - } while( object.value ); - - new TestCase( - SECTION, - "loop iterations", - object.iterations, - i - ); - - new TestCase( - SECTION, - "object.value", - object.endvalue, - Number( object.value ) - ); - -} diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Statements/dowhile-004.js b/tests/auto/declarative/parserstress/tests/ecma_2/Statements/dowhile-004.js deleted file mode 100644 index eb8e0c1b72..0000000000 --- a/tests/auto/declarative/parserstress/tests/ecma_2/Statements/dowhile-004.js +++ /dev/null @@ -1,100 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is JavaScript Engine testing utilities. - * - * The Initial Developer of the Original Code is - * Netscape Communication Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -gTestfile = 'dowhile-004.js'; - -/** - * File Name: dowhile-004 - * ECMA Section: - * Description: do...while statements - * - * Test a labeled do...while. Break out of the loop with no label - * should break out of the loop, but not out of the label. - * - * Author: christine@netscape.com - * Date: 11 August 1998 - */ -var SECTION = "dowhile-004"; -var VERSION = "ECMA_2"; -var TITLE = "do...while with a labeled continue statement"; - -startTest(); -writeHeaderToLog( SECTION + " "+ TITLE); - -DoWhile( 0, 1 ); -DoWhile( 1, 1 ); -DoWhile( -1, 1 ); -DoWhile( 5, 5 ); - -test(); - -function DoWhile( limit, expect ) { - i = 0; - result1 = "pass"; - result2 = "failed: broke out of labeled statement unexpectedly"; - -foo: { - do { - i++; - if ( ! (i < limit) ) { - break; - result1 = "fail: evaluated statement after a labeled break"; - } - } while ( true ); - - result2 = "pass"; - } - - new TestCase( - SECTION, - "do while ( " + i +" < " + limit +" )", - expect, - i ); - - new TestCase( - SECTION, - "breaking out of a do... while loop", - "pass", - result1 ); - - - new TestCase( - SECTION, - "breaking out of a labeled do...while loop", - "pass", - result2 ); -} diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Statements/dowhile-005.js b/tests/auto/declarative/parserstress/tests/ecma_2/Statements/dowhile-005.js deleted file mode 100644 index e4096f0d25..0000000000 --- a/tests/auto/declarative/parserstress/tests/ecma_2/Statements/dowhile-005.js +++ /dev/null @@ -1,106 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is JavaScript Engine testing utilities. - * - * The Initial Developer of the Original Code is - * Netscape Communication Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -gTestfile = 'dowhile-005.js'; - -/** - * File Name: dowhile-005 - * ECMA Section: - * Description: do...while statements - * - * Test a labeled do...while. Break out of the loop with no label - * should break out of the loop, but not out of the label. - * - * Currently causes an infinite loop in the monkey. Uncomment the - * print statement below and it works OK. - * - * Author: christine@netscape.com - * Date: 26 August 1998 - */ -var SECTION = "dowhile-005"; -var VERSION = "ECMA_2"; -var TITLE = "do...while with a labeled continue statement"; -var BUGNUMBER = "316293"; - -startTest(); -writeHeaderToLog( SECTION + " "+ TITLE); - -NestedLabel(); - - -test(); - -function NestedLabel() { - i = 0; - result1 = "pass"; - result2 = "fail: did not hit code after inner loop"; - result3 = "pass"; - -outer: { - do { - inner: { -// print( i ); - break inner; - result1 = "fail: did break out of inner label"; - } - result2 = "pass"; - break outer; - print(i); - } while ( i++ < 100 ); - - } - - result3 = "fail: did not break out of outer label"; - - new TestCase( - SECTION, - "number of loop iterations", - 0, - i ); - - new TestCase( - SECTION, - "break out of inner loop", - "pass", - result1 ); - - new TestCase( - SECTION, - "break out of outer loop", - "pass", - result2 ); -} diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Statements/dowhile-006.js b/tests/auto/declarative/parserstress/tests/ecma_2/Statements/dowhile-006.js deleted file mode 100644 index c8ad46f629..0000000000 --- a/tests/auto/declarative/parserstress/tests/ecma_2/Statements/dowhile-006.js +++ /dev/null @@ -1,122 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is JavaScript Engine testing utilities. - * - * The Initial Developer of the Original Code is - * Netscape Communication Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -gTestfile = 'dowhile-006.js'; - -/** - * File Name: dowhile-006 - * ECMA Section: - * Description: do...while statements - * - * A general do...while test. - * - * Author: christine@netscape.com - * Date: 26 August 1998 - */ -var SECTION = "dowhile-006"; -var VERSION = "ECMA_2"; -var TITLE = "do...while"; - -startTest(); -writeHeaderToLog( SECTION + " "+ TITLE); - -DoWhile( new DoWhileObject( false, false, 10 ) ); -DoWhile( new DoWhileObject( true, false, 2 ) ); -DoWhile( new DoWhileObject( false, true, 3 ) ); -DoWhile( new DoWhileObject( true, true, 4 ) ); - -test(); - -function looping( object ) { - object.iterations--; - - if ( object.iterations <= 0 ) { - return false; - } else { - return true; - } -} -function DoWhileObject( breakOut, breakIn, iterations, loops ) { - this.iterations = iterations; - this.loops = loops; - this.breakOut = breakOut; - this.breakIn = breakIn; - this.looping = looping; -} -function DoWhile( object ) { - var result1 = false; - var result2 = false; - -outie: { - innie: { - do { - if ( object.breakOut ) - break outie; - - if ( object.breakIn ) - break innie; - - } while ( looping(object) ); - - // statements should be executed if: - // do...while exits normally - // do...while exits abruptly with no label - - result1 = true; - - } - -// statements should be executed if: -// do...while breaks out with label "innie" -// do...while exits normally -// do...while does not break out with "outie" - - result2 = true; - } - - new TestCase( - SECTION, - "hit code after loop in inner loop", - ( object.breakIn || object.breakOut ) ? false : true , - result1 ); - - new TestCase( - SECTION, - "hit code after loop in outer loop", - ( object.breakOut ) ? false : true, - result2 ); -} diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Statements/dowhile-007.js b/tests/auto/declarative/parserstress/tests/ecma_2/Statements/dowhile-007.js deleted file mode 100644 index 5d148095d1..0000000000 --- a/tests/auto/declarative/parserstress/tests/ecma_2/Statements/dowhile-007.js +++ /dev/null @@ -1,130 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is JavaScript Engine testing utilities. - * - * The Initial Developer of the Original Code is - * Netscape Communication Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -gTestfile = 'dowhile-007.js'; - -/** - * File Name: dowhile-007 - * ECMA Section: - * Description: do...while statements - * - * A general do...while test. - * - * Author: christine@netscape.com - * Date: 26 August 1998 - */ -var SECTION = "dowhile-007"; -var VERSION = "ECMA_2"; -var TITLE = "do...while"; - -startTest(); -writeHeaderToLog( SECTION + " "+ TITLE); - -DoWhile( new DoWhileObject( false, false, false, false )); -DoWhile( new DoWhileObject( true, false, false, false )); -DoWhile( new DoWhileObject( true, true, false, false )); -DoWhile( new DoWhileObject( true, true, true, false )); -DoWhile( new DoWhileObject( true, true, true, true )); -DoWhile( new DoWhileObject( false, false, false, true )); -DoWhile( new DoWhileObject( false, false, true, true )); -DoWhile( new DoWhileObject( false, true, true, true )); -DoWhile( new DoWhileObject( false, false, true, false )); - -test(); - -function DoWhileObject( out1, out2, out3, in1 ) { - this.breakOutOne = out1; - this.breakOutTwo = out2; - this.breakOutThree = out3; - this.breakIn = in1; -} -function DoWhile( object ) { - result1 = false; - result2 = false; - result3 = false; - result4 = false; - -outie: - do { - if ( object.breakOutOne ) { - break outie; - } - result1 = true; - - innie: - do { - if ( object.breakOutTwo ) { - break outie; - } - result2 = true; - - if ( object.breakIn ) { - break innie; - } - result3 = true; - - } while ( false ); - if ( object.breakOutThree ) { - break outie; - } - result4 = true; - } while ( false ); - - new TestCase( - SECTION, - "break one: ", - (object.breakOutOne) ? false : true, - result1 ); - - new TestCase( - SECTION, - "break two: ", - (object.breakOutOne||object.breakOutTwo) ? false : true, - result2 ); - - new TestCase( - SECTION, - "break three: ", - (object.breakOutOne||object.breakOutTwo||object.breakIn) ? false : true, - result3 ); - - new TestCase( - SECTION, - "break four: ", - (object.breakOutOne||object.breakOutTwo||object.breakOutThree) ? false: true, - result4 ); -} diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Statements/forin-001.js b/tests/auto/declarative/parserstress/tests/ecma_2/Statements/forin-001.js deleted file mode 100644 index 0f20f6e953..0000000000 --- a/tests/auto/declarative/parserstress/tests/ecma_2/Statements/forin-001.js +++ /dev/null @@ -1,330 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is JavaScript Engine testing utilities. - * - * The Initial Developer of the Original Code is - * Netscape Communication Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -gTestfile = 'forin-001.js'; - -/** - * File Name: forin-001.js - * ECMA Section: - * Description: The forin-001 statement - * - * Verify that the property name is assigned to the property on the left - * hand side of the for...in expression. - * - * Author: christine@netscape.com - * Date: 28 August 1998 - */ -var SECTION = "forin-001"; -var VERSION = "ECMA_2"; -var TITLE = "The for...in statement"; -var BUGNUMBER="330890"; -var BUGNUMBER="http://scopus.mcom.com/bugsplat/show_bug.cgi?id=344855"; - -startTest(); -writeHeaderToLog( SECTION + " "+ TITLE); - -ForIn_1( { length:4, company:"netscape", year:2000, 0:"zero" } ); -ForIn_2( { length:4, company:"netscape", year:2000, 0:"zero" } ); -ForIn_3( { length:4, company:"netscape", year:2000, 0:"zero" } ); - -// ForIn_6({ length:4, company:"netscape", year:2000, 0:"zero" }); -// ForIn_7({ length:4, company:"netscape", year:2000, 0:"zero" }); -ForIn_8({ length:4, company:"netscape", year:2000, 0:"zero" }); - -test(); - -/** - * Verify that the left side argument is evaluated with every iteration. - * Verify that the name of each property of the object is assigned to a - * a property. - * - */ -function ForIn_1( object ) { - PropertyArray = new Array(); - ValueArray = new Array(); - - for ( PropertyArray[PropertyArray.length] in object ) { - ValueArray[ValueArray.length] = - object[PropertyArray[PropertyArray.length-1]]; - } - - for ( var i = 0; i < PropertyArray.length; i++ ) { - new TestCase( - SECTION, - "object[" + PropertyArray[i] +"]", - object[PropertyArray[i]], - ValueArray[i] - ); - } - - new TestCase( - SECTION, - "object.length", - PropertyArray.length, - object.length ); -} - -/** - * Similar to ForIn_1, except it should increment the counter variable - * every time the left hand expression is evaluated. - */ -function ForIn_2( object ) { - PropertyArray = new Array(); - ValueArray = new Array(); - var i = 0; - - for ( PropertyArray[i++] in object ) { - ValueArray[ValueArray.length] = - object[PropertyArray[PropertyArray.length-1]]; - } - - for ( i = 0; i < PropertyArray.length; i++ ) { - new TestCase( - SECTION, - "object[" + PropertyArray[i] +"]", - object[PropertyArray[i]], - ValueArray[i] - ); - } - - new TestCase( - SECTION, - "object.length", - PropertyArray.length, - object.length ); -} - -/** - * Break out of a for...in loop - * - * - */ -function ForIn_3( object ) { - var checkBreak = "pass"; - var properties = new Array(); - var values = new Array(); - - for ( properties[properties.length] in object ) { - values[values.length] = object[properties[properties.length-1]]; - break; - checkBreak = "fail"; - } - - new TestCase( - SECTION, - "check break out of for...in", - "pass", - checkBreak ); - - new TestCase( - SECTION, - "properties.length", - 1, - properties.length ); - - new TestCase( - SECTION, - "object["+properties[0]+"]", - values[0], - object[properties[0]] ); -} - -/** - * Break out of a labeled for...in loop. - */ -function ForIn_4( object ) { - var result1 = 0; - var result2 = 0; - var result3 = 0; - var result4 = 0; - var i = 0; - var property = new Array(); - -butterbean: { - result1++; - - for ( property[i++] in object ) { - result2++; - break; - result4++; - } - result3++; - } - - new TestCase( - SECTION, - "verify labeled statement is only executed once", - true, - result1 == 1 ); - - new TestCase( - SECTION, - "verify statements in for loop are evaluated", - true, - result2 == i ); - - new TestCase( - SECTION, - "verify break out of labeled for...in loop", - true, - result4 == 0 ); - - new TestCase( - SECTION, - "verify break out of labeled block", - true, - result3 == 0 ); -} - -/** - * Labeled break out of a labeled for...in loop. - */ -function ForIn_5 (object) { - var result1 = 0; - var result2 = 0; - var result3 = 0; - var result4 = 0; - var i = 0; - var property = new Array(); - -bigredbird: { - result1++; - for ( property[i++] in object ) { - result2++; - break bigredbird; - result4++; - } - result3++; - } - - new TestCase( - SECTION, - "verify labeled statement is only executed once", - true, - result1 == 1 ); - - new TestCase( - SECTION, - "verify statements in for loop are evaluated", - true, - result2 == i ); - - new TestCase( - SECTION, - "verify break out of labeled for...in loop", - true, - result4 == 0 ); - - new TestCase( - SECTION, - "verify break out of labeled block", - true, - result3 == 0 ); -} - -/** - * Labeled continue from a labeled for...in loop - */ -function ForIn_7( object ) { - var result1 = 0; - var result2 = 0; - var result3 = 0; - var result4 = 0; - var i = 0; - var property = new Array(); - -bigredbird: - for ( property[i++] in object ) { - result2++; - continue bigredbird; - result4++; - } - - new TestCase( - SECTION, - "verify statements in for loop are evaluated", - true, - result2 == i ); - - new TestCase( - SECTION, - "verify break out of labeled for...in loop", - true, - result4 == 0 ); - - new TestCase( - SECTION, - "verify break out of labeled block", - true, - result3 == 1 ); -} - - -/** - * continue in a for...in loop - * - */ -function ForIn_8( object ) { - var checkBreak = "pass"; - var properties = new Array(); - var values = new Array(); - - for ( properties[properties.length] in object ) { - values[values.length] = object[properties[properties.length-1]]; - break; - checkBreak = "fail"; - } - - new TestCase( - SECTION, - "check break out of for...in", - "pass", - checkBreak ); - - new TestCase( - SECTION, - "properties.length", - 1, - properties.length ); - - new TestCase( - SECTION, - "object["+properties[0]+"]", - values[0], - object[properties[0]] ); -} - diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Statements/forin-002.js b/tests/auto/declarative/parserstress/tests/ecma_2/Statements/forin-002.js deleted file mode 100644 index 524bf38b9a..0000000000 --- a/tests/auto/declarative/parserstress/tests/ecma_2/Statements/forin-002.js +++ /dev/null @@ -1,109 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is JavaScript Engine testing utilities. - * - * The Initial Developer of the Original Code is - * Netscape Communication Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -gTestfile = 'forin-002.js'; - -/** - * File Name: forin-002.js - * ECMA Section: - * Description: The forin-001 statement - * - * Verify that the property name is assigned to the property on the left - * hand side of the for...in expression. - * - * Author: christine@netscape.com - * Date: 28 August 1998 - */ -var SECTION = "forin-002"; -var VERSION = "ECMA_2"; -var TITLE = "The for...in statement"; - -startTest(); -writeHeaderToLog( SECTION + " "+ TITLE); - -function MyObject( value ) { - this.value = value; - this.valueOf = new Function ( "return this.value" ); - this.toString = new Function ( "return this.value + \"\"" ); - this.toNumber = new Function ( "return this.value + 0" ); - this.toBoolean = new Function ( "return Boolean( this.value )" ); -} - -ForIn_1(this); -ForIn_2(this); - -ForIn_1(new MyObject(true)); -ForIn_2(new MyObject(new Boolean(true))); - -ForIn_2(3); - -test(); - -/** - * For ... In in a With Block - * - */ -function ForIn_1( object) { - with ( object ) { - for ( property in object ) { - new TestCase( - SECTION, - "with loop in a for...in loop. ("+object+")["+property +"] == "+ - "eval ( " + property +" )", - true, - object[property] == eval(property) ); - } - } -} - -/** - * With block in a For...In loop - * - */ -function ForIn_2(object) { - for ( property in object ) { - with ( object ) { - new TestCase( - SECTION, - "with loop in a for...in loop. ("+object+")["+property +"] == "+ - "eval ( " + property +" )", - true, - object[property] == eval(property) ); - } - } -} - diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Statements/if-001.js b/tests/auto/declarative/parserstress/tests/ecma_2/Statements/if-001.js deleted file mode 100644 index 439410c9a6..0000000000 --- a/tests/auto/declarative/parserstress/tests/ecma_2/Statements/if-001.js +++ /dev/null @@ -1,75 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is JavaScript Engine testing utilities. - * - * The Initial Developer of the Original Code is - * Netscape Communication Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -gTestfile = 'if-001.js'; - -/** - * File Name: if-001.js - * ECMA Section: - * Description: The if statement - * - * Verify that assignment in the if expression is evaluated correctly. - * Verifies the fix for bug http://scopus/bugsplat/show_bug.cgi?id=148822. - * - * Author: christine@netscape.com - * Date: 28 August 1998 - */ -var SECTION = "for-001"; -var VERSION = "ECMA_2"; -var TITLE = "The if statement"; -var BUGNUMBER="148822"; - -startTest(); -writeHeaderToLog( SECTION + " "+ TITLE); - -var a = 0; -var b = 0; -var result = "passed"; - -if ( a = b ) { - result = "failed: a = b should return 0"; -} - -new TestCase( - SECTION, - "if ( a = b ), where a and b are both equal to 0", - "passed", - result ); - - -test(); - diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Statements/label-001.js b/tests/auto/declarative/parserstress/tests/ecma_2/Statements/label-001.js deleted file mode 100644 index 07bdeb6b81..0000000000 --- a/tests/auto/declarative/parserstress/tests/ecma_2/Statements/label-001.js +++ /dev/null @@ -1,75 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is JavaScript Engine testing utilities. - * - * The Initial Developer of the Original Code is - * Netscape Communication Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -gTestfile = 'label-001.js'; - -/** - * File Name: label-001.js - * ECMA Section: - * Description: Labeled statements - * - * Labeled break and continue within a for loop. - * - * - * Author: christine@netscape.com - * Date: 11 August 1998 - */ -var SECTION = "label-003"; -var VERSION = "ECMA_2"; -var TITLE = "Labeled statements"; - -startTest(); -writeHeaderToLog( SECTION + " "+ TITLE); - -LabelTest(0, 0); -LabelTest(1, 1) - LabelTest(-1, 1000); -LabelTest(false, 0); -LabelTest(true, 1); - -test(); - -function LabelTest( limit, expect) { -woo: for ( var result = 0; result < 1000; result++ ) { if (result == limit) { break woo; } else { continue woo; } }; - - new TestCase( - SECTION, - "break out of a labeled for loop: "+ limit, - expect, - result ); -} - diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Statements/label-002.js b/tests/auto/declarative/parserstress/tests/ecma_2/Statements/label-002.js deleted file mode 100644 index 83b114d3f2..0000000000 --- a/tests/auto/declarative/parserstress/tests/ecma_2/Statements/label-002.js +++ /dev/null @@ -1,89 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is JavaScript Engine testing utilities. - * - * The Initial Developer of the Original Code is - * Netscape Communication Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -gTestfile = 'label-002.js'; - -/** - * File Name: label-002.js - * ECMA Section: - * Description: Labeled statements - * - * Labeled break and continue within a for-in loop. - * - * - * Author: christine@netscape.com - * Date: 11 August 1998 - */ -var SECTION = "label-002"; -var VERSION = "ECMA_2"; -var TITLE = "Labeled statements"; - -startTest(); -writeHeaderToLog( SECTION + " "+ TITLE); - -LabelTest( { p1:"hi,", p2:" norris" }, "hi, norris", " norrishi," ); -LabelTest( { 0:"zero", 1:"one" }, "zeroone", "onezero" ); - -LabelTest2( { p1:"hi,", p2:" norris" }, "hi,", " norris" ); -LabelTest2( { 0:"zero", 1:"one" }, "zero", "one" ); - -test(); - -function LabelTest( object, expect1, expect2 ) { - result = ""; - -yoohoo: { for ( property in object ) { result += object[property]; }; break yoohoo }; - - new TestCase( - SECTION, - "yoohoo: for ( property in object ) { result += object[property]; } break yoohoo }", - true, - result == expect1 || result == expect2 ); -} - -function LabelTest2( object, expect1, expect2 ) { - result = ""; - -yoohoo: { for ( property in object ) { result += object[property]; break yoohoo } }; ; - - new TestCase( - SECTION, - "yoohoo: for ( property in object ) { result += object[property]; break yoohoo }}", - true, - result == expect1 || result == expect2 ); -} - diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Statements/shell.js b/tests/auto/declarative/parserstress/tests/ecma_2/Statements/shell.js deleted file mode 100644 index 7346f697a5..0000000000 --- a/tests/auto/declarative/parserstress/tests/ecma_2/Statements/shell.js +++ /dev/null @@ -1 +0,0 @@ -gTestsubsuite = 'Statements'; diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Statements/switch-001.js b/tests/auto/declarative/parserstress/tests/ecma_2/Statements/switch-001.js deleted file mode 100644 index 22ab0a7b60..0000000000 --- a/tests/auto/declarative/parserstress/tests/ecma_2/Statements/switch-001.js +++ /dev/null @@ -1,98 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is JavaScript Engine testing utilities. - * - * The Initial Developer of the Original Code is - * Netscape Communication Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -gTestfile = 'switch-001.js'; - -/** - * File Name: switch-001.js - * ECMA Section: - * Description: The switch Statement - * - * A simple switch test with no abrupt completions. - * - * Author: christine@netscape.com - * Date: 11 August 1998 - * - */ -var SECTION = "switch-001"; -var VERSION = "ECMA_2"; -var TITLE = "The switch statement"; - -var BUGNUMBER="315767"; - -startTest(); -writeHeaderToLog( SECTION + " "+ TITLE); - -SwitchTest( 0, 126 ); -SwitchTest( 1, 124 ); -SwitchTest( 2, 120 ); -SwitchTest( 3, 112 ); -SwitchTest( 4, 64 ); -SwitchTest( 5, 96 ); -SwitchTest( true, 96 ); -SwitchTest( false, 96 ); -SwitchTest( null, 96 ); -SwitchTest( void 0, 96 ); -SwitchTest( "0", 96 ); - -test(); - -function SwitchTest( input, expect ) { - var result = 0; - - switch ( input ) { - case 0: - result += 2; - case 1: - result += 4; - case 2: - result += 8; - case 3: - result += 16; - default: - result += 32; - case 4: - result +=64; - } - - new TestCase( - SECTION, - "switch with no breaks, case expressions are numbers. input is "+ - input, - expect, - result ); -} diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Statements/switch-002.js b/tests/auto/declarative/parserstress/tests/ecma_2/Statements/switch-002.js deleted file mode 100644 index 6cb5491beb..0000000000 --- a/tests/auto/declarative/parserstress/tests/ecma_2/Statements/switch-002.js +++ /dev/null @@ -1,96 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is JavaScript Engine testing utilities. - * - * The Initial Developer of the Original Code is - * Netscape Communication Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -gTestfile = 'switch-002.js'; - -/** - * File Name: switch-002.js - * ECMA Section: - * Description: The switch Statement - * - * A simple switch test with no abrupt completions. - * - * Author: christine@netscape.com - * Date: 11 August 1998 - * - */ -var SECTION = "switch-002"; -var VERSION = "ECMA_2"; -var TITLE = "The switch statement"; - -startTest(); -writeHeaderToLog( SECTION + " "+ TITLE); - -SwitchTest( 0, 6 ); -SwitchTest( 1, 4 ); -SwitchTest( 2, 56 ); -SwitchTest( 3, 48 ); -SwitchTest( 4, 64 ); -SwitchTest( true, 32 ); -SwitchTest( false, 32 ); -SwitchTest( null, 32 ); -SwitchTest( void 0, 32 ); -SwitchTest( "0", 32 ); - -test(); - -function SwitchTest( input, expect ) { - var result = 0; - - switch ( input ) { - case 0: - result += 2; - case 1: - result += 4; - break; - case 2: - result += 8; - case 3: - result += 16; - default: - result += 32; - break; - case 4: - result += 64; - } - - new TestCase( - SECTION, - "switch with no breaks: input is " + input, - expect, - result ); -} diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Statements/switch-003.js b/tests/auto/declarative/parserstress/tests/ecma_2/Statements/switch-003.js deleted file mode 100644 index 27ed593bfe..0000000000 --- a/tests/auto/declarative/parserstress/tests/ecma_2/Statements/switch-003.js +++ /dev/null @@ -1,90 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is JavaScript Engine testing utilities. - * - * The Initial Developer of the Original Code is - * Netscape Communication Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -gTestfile = 'switch-003.js'; - -/** - * File Name: switch-003.js - * ECMA Section: - * Description: The switch Statement - * - * Attempt to verify that case statements are evaluated in source order - * - * Author: christine@netscape.com - * Date: 11 August 1998 - * - */ -var SECTION = "switch-003"; -var VERSION = "ECMA_2"; -var TITLE = "The switch statement"; - -startTest(); -writeHeaderToLog( SECTION + " "+ TITLE); - -SwitchTest( "a", "abc" ); -SwitchTest( "b", "bc" ); -SwitchTest( "c", "c" ); -SwitchTest( "d", "*abc" ); -SwitchTest( "v", "*abc" ); -SwitchTest( "w", "w*abc" ); -SwitchTest( "x", "xw*abc" ); -SwitchTest( "y", "yxw*abc" ); -SwitchTest( "z", "zyxw*abc" ); -// SwitchTest( new java.lang.String("z"), "*abc" ); - -test(); - -function SwitchTest( input, expect ) { - var result = ""; - - switch ( input ) { - case "z": result += "z"; - case "y": result += "y"; - case "x": result += "x"; - case "w": result += "w"; - default: result += "*"; - case "a": result += "a"; - case "b": result += "b"; - case "c": result += "c"; - } - - new TestCase( - SECTION, - "switch with no breaks: input is " + input, - expect, - result ); -} diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Statements/switch-004.js b/tests/auto/declarative/parserstress/tests/ecma_2/Statements/switch-004.js deleted file mode 100644 index e7605222d6..0000000000 --- a/tests/auto/declarative/parserstress/tests/ecma_2/Statements/switch-004.js +++ /dev/null @@ -1,127 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is JavaScript Engine testing utilities. - * - * The Initial Developer of the Original Code is - * Netscape Communication Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -gTestfile = 'switch-004.js'; - -/** - * File Name: switch-003.js - * ECMA Section: - * Description: The switch Statement - * - * This uses variables and objects as case expressions in switch statements. - * This verifies a bunch of bugs: - * - * http://scopus.mcom.com/bugsplat/show_bug.cgi?id=315988 - * http://scopus.mcom.com/bugsplat/show_bug.cgi?id=315975 - * http://scopus.mcom.com/bugsplat/show_bug.cgi?id=315954 - * - * Author: christine@netscape.com - * Date: 11 August 1998 - * - */ -var SECTION = "switch-003"; -var VERSION = "ECMA_2"; -var TITLE = "The switch statement"; -var BUGNUMBER= "315988"; - -startTest(); -writeHeaderToLog( SECTION + " "+ TITLE); - -ONE = new Number(1); -ZERO = new Number(0); -var A = new String("A"); -var B = new String("B"); -TRUE = new Boolean( true ); -FALSE = new Boolean( false ); -UNDEFINED = void 0; -NULL = null; - -SwitchTest( ZERO, "ZERO" ); -SwitchTest( NULL, "NULL" ); -SwitchTest( UNDEFINED, "UNDEFINED" ); -SwitchTest( FALSE, "FALSE" ); -SwitchTest( false, "false" ); -SwitchTest( 0, "0" ); - -SwitchTest ( TRUE, "TRUE" ); -SwitchTest( 1, "1" ); -SwitchTest( ONE, "ONE" ); -SwitchTest( true, "true" ); - -SwitchTest( "a", "a" ); -SwitchTest( A, "A" ); -SwitchTest( "b", "b" ); -SwitchTest( B, "B" ); - -SwitchTest( new Boolean( true ), "default" ); -SwitchTest( new Boolean(false ), "default" ); -SwitchTest( new String( "A" ), "default" ); -SwitchTest( new Number( 0 ), "default" ); - -test(); - -function SwitchTest( input, expect ) { - var result = ""; - - switch ( input ) { - default: result += "default"; break; - case "a": result += "a"; break; - case "b": result += "b"; break; - case A: result += "A"; break; - case B: result += "B"; break; - case new Boolean(true): result += "new TRUE"; break; - case new Boolean(false): result += "new FALSE"; break; - case NULL: result += "NULL"; break; - case UNDEFINED: result += "UNDEFINED"; break; - case true: result += "true"; break; - case false: result += "false"; break; - case TRUE: result += "TRUE"; break; - case FALSE: result += "FALSE"; break; - case 0: result += "0"; break; - case 1: result += "1"; break; - case new Number(0) : result += "new ZERO"; break; - case new Number(1) : result += "new ONE"; break; - case ONE: result += "ONE"; break; - case ZERO: result += "ZERO"; break; - } - - new TestCase( - SECTION, - "switch with no breaks: input is " + input, - expect, - result ); -} diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Statements/try-001.js b/tests/auto/declarative/parserstress/tests/ecma_2/Statements/try-001.js deleted file mode 100644 index c7b430dabe..0000000000 --- a/tests/auto/declarative/parserstress/tests/ecma_2/Statements/try-001.js +++ /dev/null @@ -1,118 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is JavaScript Engine testing utilities. - * - * The Initial Developer of the Original Code is - * Netscape Communication Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -gTestfile = 'try-001.js'; - -/** - * File Name: try-001.js - * ECMA Section: - * Description: The try statement - * - * This test contains try, catch, and finally blocks. An exception is - * sometimes thrown by a function called from within the try block. - * - * This test doesn't actually make any LiveConnect calls. - * - * - * Author: christine@netscape.com - * Date: 11 August 1998 - */ -var SECTION = ""; -var VERSION = "ECMA_2"; -var TITLE = "The try statement"; - -startTest(); -writeHeaderToLog( SECTION + " "+ TITLE); - -var INVALID_JAVA_INTEGER_VALUE = "Invalid value for java.lang.Integer constructor"; - -TryNewJavaInteger( "3.14159", INVALID_JAVA_INTEGER_VALUE ); -TryNewJavaInteger( NaN, INVALID_JAVA_INTEGER_VALUE ); -TryNewJavaInteger( 0, 0 ); -TryNewJavaInteger( -1, -1 ); -TryNewJavaInteger( 1, 1 ); -TryNewJavaInteger( Infinity, Infinity ); - -test(); - -/** - * Check to see if the input is valid for java.lang.Integer. If it is - * not valid, throw INVALID_JAVA_INTEGER_VALUE. If input is valid, - * return Number( v ) - * - */ - -function newJavaInteger( v ) { - value = Number( v ); - if ( Math.floor(value) != value || isNaN(value) ) { - throw ( INVALID_JAVA_INTEGER_VALUE ); - } else { - return value; - } -} - -/** - * Call newJavaInteger( value ) from within a try block. Catch any - * exception, and store it in result. Verify that we got the right - * return value from newJavaInteger in cases in which we do not expect - * exceptions, and that we got the exception in cases where an exception - * was expected. - */ -function TryNewJavaInteger( value, expect ) { - var finalTest = false; - - try { - result = newJavaInteger( value ); - } catch ( e ) { - result = String( e ); - } finally { - finalTest = true; - } - new TestCase( - SECTION, - "newJavaValue( " + value +" )", - expect, - result); - - new TestCase( - SECTION, - "newJavaValue( " + value +" ) hit finally block", - true, - finalTest); - -} - diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Statements/try-003.js b/tests/auto/declarative/parserstress/tests/ecma_2/Statements/try-003.js deleted file mode 100644 index 2c39aac243..0000000000 --- a/tests/auto/declarative/parserstress/tests/ecma_2/Statements/try-003.js +++ /dev/null @@ -1,115 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is JavaScript Engine testing utilities. - * - * The Initial Developer of the Original Code is - * Netscape Communication Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -gTestfile = 'try-003.js'; - -/** - * File Name: try-003.js - * ECMA Section: - * Description: The try statement - * - * This test has a try with no catch, and a finally. - * - * Author: christine@netscape.com - * Date: 11 August 1998 - */ -var SECTION = "try-003"; -var VERSION = "ECMA_2"; -var TITLE = "The try statement"; -var BUGNUMBER="http://scopus.mcom.com/bugsplat/show_bug.cgi?id=313585"; - -startTest(); -writeHeaderToLog( SECTION + " "+ TITLE); - -// Tests start here. - -TrySomething( "x = \"hi\"", false ); -TrySomething( "throw \"boo\"", true ); -TrySomething( "throw 3", true ); - -test(); - -/** - * This function contains a try block with no catch block, - * but it does have a finally block. Try to evaluate expressions - * that do and do not throw exceptions. - */ - -function TrySomething( expression, throwing ) { - innerFinally = "FAIL: DID NOT HIT INNER FINALLY BLOCK"; - if (throwing) { - outerCatch = "FAILED: NO EXCEPTION CAUGHT"; - } else { - outerCatch = "PASS"; - } - outerFinally = "FAIL: DID NOT HIT OUTER FINALLY BLOCK"; - - try { - try { - eval( expression ); - } finally { - innerFinally = "PASS"; - } - } catch ( e ) { - if (throwing) { - outerCatch = "PASS"; - } else { - outerCatch = "FAIL: HIT OUTER CATCH BLOCK"; - } - } finally { - outerFinally = "PASS"; - } - - - new TestCase( - SECTION, - "eval( " + expression +" )", - "PASS", - innerFinally ); - new TestCase( - SECTION, - "eval( " + expression +" )", - "PASS", - outerCatch ); - new TestCase( - SECTION, - "eval( " + expression +" )", - "PASS", - outerFinally ); - - -} diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Statements/try-004.js b/tests/auto/declarative/parserstress/tests/ecma_2/Statements/try-004.js deleted file mode 100644 index d41903de18..0000000000 --- a/tests/auto/declarative/parserstress/tests/ecma_2/Statements/try-004.js +++ /dev/null @@ -1,87 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is JavaScript Engine testing utilities. - * - * The Initial Developer of the Original Code is - * Netscape Communication Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -gTestfile = 'try-004.js'; - -/** - * File Name: try-004.js - * ECMA Section: - * Description: The try statement - * - * This test has a try with one catch block but no finally. - * - * Author: christine@netscape.com - * Date: 11 August 1998 - */ -var SECTION = "try-004"; -var VERSION = "ECMA_2"; -var TITLE = "The try statement"; - -startTest(); -writeHeaderToLog( SECTION + " "+ TITLE); - -TryToCatch( "Math.PI", Math.PI ); -TryToCatch( "Thrower(5)", "Caught 5" ); -TryToCatch( "Thrower(\"some random exception\")", "Caught some random exception" ); - -test(); - -function Thrower( v ) { - throw "Caught " + v; -} - -/** - * Evaluate a string. Catch any exceptions thrown. If no exception is - * expected, verify the result of the evaluation. If an exception is - * expected, verify that we got the right exception. - */ - -function TryToCatch( value, expect ) { - try { - result = eval( value ); - } catch ( e ) { - result = e; - } - - new TestCase( - SECTION, - "eval( " + value +" )", - expect, - result ); -} - - diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Statements/try-005.js b/tests/auto/declarative/parserstress/tests/ecma_2/Statements/try-005.js deleted file mode 100644 index 0b9a055325..0000000000 --- a/tests/auto/declarative/parserstress/tests/ecma_2/Statements/try-005.js +++ /dev/null @@ -1,90 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is JavaScript Engine testing utilities. - * - * The Initial Developer of the Original Code is - * Netscape Communication Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -gTestfile = 'try-005.js'; - -/** - * File Name: try-005.js - * ECMA Section: - * Description: The try statement - * - * This test has a try with one catch block but no finally. Same - * as try-004, but the eval statement is called from a function, not - * directly from within the try block. - * - * Author: christine@netscape.com - * Date: 11 August 1998 - */ -var SECTION = "try-005"; -var VERSION = "ECMA_2"; -var TITLE = "The try statement"; - -startTest(); -writeHeaderToLog( SECTION + " "+ TITLE); - -TryToCatch( "Math.PI", Math.PI ); -TryToCatch( "Thrower(5)", "Caught 5" ); -TryToCatch( "Thrower(\"some random exception\")", "Caught some random exception" ); - -test(); - -function Thrower( v ) { - throw "Caught " + v; -} -function Eval( v ) { - return eval( v ); -} - -/** - * Evaluate a string. Catch any exceptions thrown. If no exception is - * expected, verify the result of the evaluation. If an exception is - * expected, verify that we got the right exception. - */ - -function TryToCatch( value, expect ) { - try { - result = Eval( value ); - } catch ( e ) { - result = e; - } - - new TestCase( - SECTION, - "eval( " + value +" )", - expect, - result ); -} diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Statements/try-006.js b/tests/auto/declarative/parserstress/tests/ecma_2/Statements/try-006.js deleted file mode 100644 index 1cfbd28656..0000000000 --- a/tests/auto/declarative/parserstress/tests/ecma_2/Statements/try-006.js +++ /dev/null @@ -1,120 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is JavaScript Engine testing utilities. - * - * The Initial Developer of the Original Code is - * Netscape Communication Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -gTestfile = 'try-006.js'; - -/** - * File Name: try-006.js - * ECMA Section: - * Description: The try statement - * - * Throw an exception from within a With block in a try block. Verify - * that any expected exceptions are caught. - * - * Author: christine@netscape.com - * Date: 11 August 1998 - */ -var SECTION = "try-006"; -var VERSION = "ECMA_2"; -var TITLE = "The try statement"; - -startTest(); -writeHeaderToLog( SECTION + " "+ TITLE); - -/** - * This is the "check" function for test objects that will - * throw an exception. - */ -function throwException() { - throw EXCEPTION_STRING +": " + this.valueOf(); -} -var EXCEPTION_STRING = "Exception thrown:"; - -/** - * This is the "check" function for test objects that do not - * throw an exception - */ -function noException() { - return this.valueOf(); -} - -/** - * Add test cases here - */ -TryWith( new TryObject( "hello", throwException, true )); -TryWith( new TryObject( "hola", noException, false )); - -/** - * Run the test. - */ - -test(); - -/** - * This is the object that will be the "this" in a with block. - */ -function TryObject( value, fun, exception ) { - this.value = value; - this.exception = exception; - - this.valueOf = new Function ( "return this.value" ); - this.check = fun; -} - -/** - * This function has the try block that has a with block within it. - * Test cases are added in this function. Within the with block, the - * object's "check" function is called. If the test object's exception - * property is true, we expect the result to be the exception value. - * If exception is false, then we expect the result to be the value of - * the object. - */ -function TryWith( object ) { - try { - with ( object ) { - result = check(); - } - } catch ( e ) { - result = e; - } - - new TestCase( - SECTION, - "TryWith( " + object.value +" )", - (object.exception ? EXCEPTION_STRING +": " + object.valueOf() : object.valueOf()), - result ); -} diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Statements/try-007.js b/tests/auto/declarative/parserstress/tests/ecma_2/Statements/try-007.js deleted file mode 100644 index 566166755c..0000000000 --- a/tests/auto/declarative/parserstress/tests/ecma_2/Statements/try-007.js +++ /dev/null @@ -1,125 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is JavaScript Engine testing utilities. - * - * The Initial Developer of the Original Code is - * Netscape Communication Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -gTestfile = 'try-007.js'; - -/** - * File Name: try-007.js - * ECMA Section: - * Description: The try statement - * - * This test has a for-in statement within a try block. - * - * - * Author: christine@netscape.com - * Date: 11 August 1998 - */ -var SECTION = "try-007"; -var VERSION = "ECMA_2"; -var TITLE = "The try statement: for-in"; - -startTest(); -writeHeaderToLog( SECTION + " "+ TITLE); - -/** - * This is the "check" function for test objects that will - * throw an exception. - */ -function throwException() { - throw EXCEPTION_STRING +": " + this.valueOf(); -} -var EXCEPTION_STRING = "Exception thrown:"; - -/** - * This is the "check" function for test objects that do not - * throw an exception - */ -function noException() { - return this.valueOf(); -} - -/** - * Add test cases here - */ -TryForIn( new TryObject( "hello", throwException, true )); -TryForIn( new TryObject( "hola", noException, false )); - -/** - * Run the test. - */ - -test(); - -/** - * This is the object that will be the "this" in a with block. - * The check function is either throwException() or noException(). - * See above. - * - */ -function TryObject( value, fun, exception ) { - this.value = value; - this.exception = exception; - - this.check = fun; - this.valueOf = function () { return this.value; } -} - -/** - * This function has a for-in statement within a try block. Test cases - * are added after the try-catch-finally statement. Within the for-in - * block, call a function that can throw an exception. Verify that any - * exceptions are properly caught. - */ - -function TryForIn( object ) { - try { - for ( p in object ) { - if ( typeof object[p] == "function" ) { - result = object[p](); - } - } - } catch ( e ) { - result = e; - } - - new TestCase( - SECTION, - "TryForIn( " + object+ " )", - (object.exception ? EXCEPTION_STRING +": " + object.value : object.value), - result ); - -} diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Statements/try-008.js b/tests/auto/declarative/parserstress/tests/ecma_2/Statements/try-008.js deleted file mode 100644 index 016ab29a31..0000000000 --- a/tests/auto/declarative/parserstress/tests/ecma_2/Statements/try-008.js +++ /dev/null @@ -1,92 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is JavaScript Engine testing utilities. - * - * The Initial Developer of the Original Code is - * Netscape Communication Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -gTestfile = 'try-008.js'; - -/** - * File Name: try-008.js - * ECMA Section: - * Description: The try statement - * - * This test has a try block in a constructor. - * - * - * Author: christine@netscape.com - * Date: 11 August 1998 - */ -var SECTION = "try-008"; -var VERSION = "ECMA_2"; -var TITLE = "The try statement: try in a constructor"; - -startTest(); -writeHeaderToLog( SECTION + " "+ TITLE); - -function Integer( value, exception ) { - try { - this.value = checkValue( value ); - } catch ( e ) { - this.value = e.toString(); - } - - new TestCase( - SECTION, - "Integer( " + value +" )", - (exception ? INVALID_INTEGER_VALUE +": " + value : this.value), - this.value ); -} - -var INVALID_INTEGER_VALUE = "Invalid value for java.lang.Integer constructor"; - -function checkValue( value ) { - if ( Math.floor(value) != value || isNaN(value) ) { - throw ( INVALID_INTEGER_VALUE +": " + value ); - } else { - return value; - } -} - -// add test cases - -new Integer( 3, false ); -new Integer( NaN, true ); -new Integer( 0, false ); -new Integer( Infinity, false ); -new Integer( -2.12, true ); -new Integer( Math.LN2, true ); - - -test(); diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Statements/try-009.js b/tests/auto/declarative/parserstress/tests/ecma_2/Statements/try-009.js deleted file mode 100644 index d6ce368638..0000000000 --- a/tests/auto/declarative/parserstress/tests/ecma_2/Statements/try-009.js +++ /dev/null @@ -1,99 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is JavaScript Engine testing utilities. - * - * The Initial Developer of the Original Code is - * Netscape Communication Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -gTestfile = 'try-009.js'; - -/** - * File Name: try-009.js - * ECMA Section: - * Description: The try statement - * - * This test has a try block within a while block. Verify that an exception - * breaks out of the while. I don't really know why this is an interesting - * test case but Mike Shaver had two of these so what the hey. - * - * Author: christine@netscape.com - * Date: 11 August 1998 - */ -var SECTION = "try-009"; -var VERSION = "ECMA_2"; -var TITLE = "The try statement: try in a while block"; - -startTest(); -writeHeaderToLog( SECTION + " "+ TITLE); - -var EXCEPTION_STRING = "Exception thrown: "; -var NO_EXCEPTION_STRING = "No exception thrown: "; - - -TryInWhile( new TryObject( "hello", ThrowException, true ) ); -TryInWhile( new TryObject( "aloha", NoException, false )); - -test(); - -function TryObject( value, throwFunction, result ) { - this.value = value; - this.thrower = throwFunction; - this.result = result; -} -function ThrowException() { - throw EXCEPTION_STRING + this.value; -} -function NoException() { - return NO_EXCEPTION_STRING + this.value; -} -function TryInWhile( object ) { - result = null; - while ( true ) { - try { - object.thrower(); - result = NO_EXCEPTION_STRING + object.value; - break; - } catch ( e ) { - result = e; - break; - } - } - - new TestCase( - SECTION, - "( "+ object +".thrower() )", - (object.result - ? EXCEPTION_STRING + object.value : - NO_EXCEPTION_STRING + object.value), - result ); -} diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Statements/try-010.js b/tests/auto/declarative/parserstress/tests/ecma_2/Statements/try-010.js deleted file mode 100644 index 27e712c895..0000000000 --- a/tests/auto/declarative/parserstress/tests/ecma_2/Statements/try-010.js +++ /dev/null @@ -1,106 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is JavaScript Engine testing utilities. - * - * The Initial Developer of the Original Code is - * Netscape Communication Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -gTestfile = 'try-010.js'; - -/** - * File Name: try-010.js - * ECMA Section: - * Description: The try statement - * - * This has a try block nested in the try block. Verify that the - * exception is caught by the right try block, and all finally blocks - * are executed. - * - * Author: christine@netscape.com - * Date: 11 August 1998 - */ -var SECTION = "try-010"; -var VERSION = "ECMA_2"; -var TITLE = "The try statement: try in a tryblock"; - -startTest(); -writeHeaderToLog( SECTION + " "+ TITLE); - -var EXCEPTION_STRING = "Exception thrown: "; -var NO_EXCEPTION_STRING = "No exception thrown: "; - - -NestedTry( new TryObject( "No Exceptions Thrown", NoException, NoException, 43 ) ); -NestedTry( new TryObject( "Throw Exception in Outer Try", ThrowException, NoException, 48 )); -NestedTry( new TryObject( "Throw Exception in Inner Try", NoException, ThrowException, 45 )); -NestedTry( new TryObject( "Throw Exception in Both Trys", ThrowException, ThrowException, 48 )); - -test(); - -function TryObject( description, tryOne, tryTwo, result ) { - this.description = description; - this.tryOne = tryOne; - this.tryTwo = tryTwo; - this.result = result; -} -function ThrowException() { - throw EXCEPTION_STRING + this.value; -} -function NoException() { - return NO_EXCEPTION_STRING + this.value; -} -function NestedTry( object ) { - result = 0; - try { - object.tryOne(); - result += 1; - try { - object.tryTwo(); - result += 2; - } catch ( e ) { - result +=4; - } finally { - result += 8; - } - } catch ( e ) { - result += 16; - } finally { - result += 32; - } - - new TestCase( - SECTION, - object.description, - object.result, - result ); -} diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Statements/try-012.js b/tests/auto/declarative/parserstress/tests/ecma_2/Statements/try-012.js deleted file mode 100644 index 79dfca2f03..0000000000 --- a/tests/auto/declarative/parserstress/tests/ecma_2/Statements/try-012.js +++ /dev/null @@ -1,128 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is JavaScript Engine testing utilities. - * - * The Initial Developer of the Original Code is - * Netscape Communication Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -gTestfile = 'try-012.js'; - -/** - * File Name: try-012.js - * ECMA Section: - * Description: The try statement - * - * This test has a try with no catch, and a finally. This is like try-003, - * but throws from a finally block, not the try block. - * - * Author: christine@netscape.com - * Date: 11 August 1998 - */ -var SECTION = "try-012"; -var VERSION = "ECMA_2"; -var TITLE = "The try statement"; -var BUGNUMBER="336872"; - -startTest(); -writeHeaderToLog( SECTION + " "+ TITLE); - -// Tests start here. - -TrySomething( "x = \"hi\"", true ); -TrySomething( "throw \"boo\"", true ); -TrySomething( "throw 3", true ); - -test(); - -/** - * This function contains a try block with no catch block, - * but it does have a finally block. Try to evaluate expressions - * that do and do not throw exceptions. - * - * The productioni TryStatement Block Finally is evaluated as follows: - * 1. Evaluate Block - * 2. Evaluate Finally - * 3. If Result(2).type is normal return result 1 (in the test case, result 1 has - * the completion type throw) - * 4. return result 2 (does not get hit in this case) - * - */ - -function TrySomething( expression, throwing ) { - innerFinally = "FAIL: DID NOT HIT INNER FINALLY BLOCK"; - if (throwing) { - outerCatch = "FAILED: NO EXCEPTION CAUGHT"; - } else { - outerCatch = "PASS"; - } - outerFinally = "FAIL: DID NOT HIT OUTER FINALLY BLOCK"; - - - // If the inner finally does not throw an exception, the result - // of the try block should be returned. (Type of inner return - // value should be throw if finally executes correctly - - try { - try { - throw 0; - } finally { - innerFinally = "PASS"; - eval( expression ); - } - } catch ( e ) { - if (throwing) { - outerCatch = "PASS"; - } else { - outerCatch = "FAIL: HIT OUTER CATCH BLOCK"; - } - } finally { - outerFinally = "PASS"; - } - - - new TestCase( - SECTION, - "eval( " + expression +" ): evaluated inner finally block", - "PASS", - innerFinally ); - new TestCase( - SECTION, - "eval( " + expression +" ): evaluated outer catch block ", - "PASS", - outerCatch ); - new TestCase( - SECTION, - "eval( " + expression +" ): evaluated outer finally block", - "PASS", - outerFinally ); -} diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Statements/while-001.js b/tests/auto/declarative/parserstress/tests/ecma_2/Statements/while-001.js deleted file mode 100644 index 467efe7f02..0000000000 --- a/tests/auto/declarative/parserstress/tests/ecma_2/Statements/while-001.js +++ /dev/null @@ -1,75 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is JavaScript Engine testing utilities. - * - * The Initial Developer of the Original Code is - * Netscape Communication Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -gTestfile = 'while-001.js'; - -/** - * File Name: while-001 - * ECMA Section: - * Description: while statement - * - * Verify that the while statement is not executed if the while expression is - * false - * - * Author: christine@netscape.com - * Date: 11 August 1998 - */ -var SECTION = "while-001"; -var VERSION = "ECMA_2"; -var TITLE = "while statement"; - -startTest(); -writeHeaderToLog( SECTION + " "+ TITLE); - -DoWhile(); -test(); - -function DoWhile() { - result = "pass"; - - while (false) { - result = "fail"; - break; - } - - new TestCase( - SECTION, - "while statement: don't evaluate statement is expression is false", - "pass", - result ); - -} diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Statements/while-002.js b/tests/auto/declarative/parserstress/tests/ecma_2/Statements/while-002.js deleted file mode 100644 index c89e195497..0000000000 --- a/tests/auto/declarative/parserstress/tests/ecma_2/Statements/while-002.js +++ /dev/null @@ -1,119 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is JavaScript Engine testing utilities. - * - * The Initial Developer of the Original Code is - * Netscape Communication Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -gTestfile = 'while-002.js'; - -/** - * File Name: while-002 - * ECMA Section: - * Description: while statement - * - * Verify that the while statement is not executed if the while expression is - * false - * - * Author: christine@netscape.com - * Date: 11 August 1998 - */ -var SECTION = "while-002"; -var VERSION = "ECMA_2"; -var TITLE = "while statement"; - -startTest(); -writeHeaderToLog( SECTION + " "+ TITLE); - -DoWhile( new DoWhileObject( - "while expression is null", - null, - "result = \"fail: should not have evaluated statements in while block;break" - ) ); - -DoWhile( new DoWhileObject( - "while expression is undefined", - void 0, - "result = \"fail: should not have evaluated statements in while block; break" - )); - -DoWhile( new DoWhileObject( - "while expression is 0", - 0, - "result = \"fail: should not have evaluated statements in while block; break;" - )); - -DoWhile( new DoWhileObject( - "while expression is eval(\"\")", - eval(""), - "result = \"fail: should not have evaluated statements in while block; break" - )); - -DoWhile( new DoWhileObject( - "while expression is NaN", - NaN, - "result = \"fail: should not have evaluated statements in while block; break" - )); - -test(); - -function DoWhileObject( d, e, s ) { - this.description = d; - this.whileExpression = e; - this.statements = s; -} - -function DoWhile( object ) { - result = "pass"; - - while ( expression = object.whileExpression ) { - eval( object.statements ); - } - - // verify that the while expression was evaluated - - new TestCase( - SECTION, - "verify that while expression was evaluated (should be "+ - object.whileExpression +")", - "pass", - (object.whileExpression == expression || - ( isNaN(object.whileExpression) && isNaN(expression) ) - ) ? "pass" : "fail" ); - - new TestCase( - SECTION, - object.description, - "pass", - result ); -} diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Statements/while-003.js b/tests/auto/declarative/parserstress/tests/ecma_2/Statements/while-003.js deleted file mode 100644 index 5fb734cce6..0000000000 --- a/tests/auto/declarative/parserstress/tests/ecma_2/Statements/while-003.js +++ /dev/null @@ -1,120 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is JavaScript Engine testing utilities. - * - * The Initial Developer of the Original Code is - * Netscape Communication Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -gTestfile = 'while-003.js'; - -/** - * File Name: while-003 - * ECMA Section: - * Description: while statement - * - * The while expression evaluates to true, Statement returns abrupt completion. - * - * Author: christine@netscape.com - * Date: 11 August 1998 - */ -var SECTION = "while-003"; -var VERSION = "ECMA_2"; -var TITLE = "while statement"; - -startTest(); -writeHeaderToLog( SECTION + " "+ TITLE); - -DoWhile( new DoWhileObject( - "while expression is true", - true, - "result = \"pass\";" )); - -DoWhile( new DoWhileObject( - "while expression is 1", - 1, - "result = \"pass\";" )); - -DoWhile( new DoWhileObject( - "while expression is new Boolean(false)", - new Boolean(false), - "result = \"pass\";" )); - -DoWhile( new DoWhileObject( - "while expression is new Object()", - new Object(), - "result = \"pass\";" )); - -DoWhile( new DoWhileObject( - "while expression is \"hi\"", - "hi", - "result = \"pass\";" )); -/* - DoWhile( new DoWhileObject( - "while expression has a continue in it", - "true", - "if ( i == void 0 ) i = 0; result=\"pass\"; if ( ++i == 1 ) {continue;} else {break;} result=\"fail\";" - )); -*/ -test(); - -function DoWhileObject( d, e, s ) { - this.description = d; - this.whileExpression = e; - this.statements = s; -} - -function DoWhile( object ) { - result = "fail: statements in while block were not evaluated"; - - while ( expression = object.whileExpression ) { - eval( object.statements ); - break; - } - - // verify that the while expression was evaluated - - new TestCase( - SECTION, - "verify that while expression was evaluated (should be "+ - object.whileExpression +")", - "pass", - (object.whileExpression == expression || - ( isNaN(object.whileExpression) && isNaN(expression) ) - ) ? "pass" : "fail" ); - - new TestCase( - SECTION, - object.description, - "pass", - result ); -} diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Statements/while-004.js b/tests/auto/declarative/parserstress/tests/ecma_2/Statements/while-004.js deleted file mode 100644 index c5e2472816..0000000000 --- a/tests/auto/declarative/parserstress/tests/ecma_2/Statements/while-004.js +++ /dev/null @@ -1,250 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is JavaScript Engine testing utilities. - * - * The Initial Developer of the Original Code is - * Netscape Communication Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -gTestfile = 'while-004.js'; - -/** - * File Name: while-004 - * ECMA Section: - * Description: while statement - * - * Author: christine@netscape.com - * Date: 11 August 1998 - */ -var SECTION = "while-004"; -var VERSION = "ECMA_2"; -var TITLE = "while statement"; -var BUGNUMBER="316725"; - -startTest(); -writeHeaderToLog( SECTION + " "+ TITLE); - -DoWhile_1(); -DoWhile_2(); -DoWhile_3(); -DoWhile_4(); -DoWhile_5(); - -test(); - -/** - * Break out of a while by calling return. - * - * Tests: 12.6.2 step 6. - */ -function dowhile() { - result = "pass"; - - while (true) { - return result; - result = "fail: hit code after return statement"; - break; - } -} - -function DoWhile_1() { - description = "return statement in a while block"; - - result = dowhile(); - - new TestCase( - SECTION, - "DoWhile_1" + description, - "pass", - result ); -} - -/** - * While with a labeled continue statement. Verify that statements - * after the continue statement are not evaluated. - * - * Tests: 12.6.2 step 8. - * - */ -function DoWhile_2() { - var description = "while with a labeled continue statement"; - var result1 = "pass"; - var result2 = "fail: did not execute code after loop, but inside label"; - var i = 0; - var j = 0; - -theloop: - while( i++ < 10 ) { - j++; - continue theloop; - result1 = "failed: hit code after continue statement"; - } - result2 = "pass"; - - new TestCase( - SECTION, - "DoWhile_2: " +description + " - code inside the loop, before the continue should be executed ("+j+")", - true, - j == 10 ); - - new TestCase( - SECTION, - "DoWhile_2: " +description +" - code after labeled continue should not be executed", - "pass", - result1 ); - - new TestCase( - SECTION, - "DoWhile_2: " +description +" - code after loop but inside label should be executed", - "pass", - result2 ); -} - -/** - * While with a labeled break. - * - */ -function DoWhile_3() { - var description = "while with a labeled break statement"; - var result1 = "pass"; - var result2 = "pass"; - var result3 = "fail: did not get to code after label"; - -woohoo: { - while( true ) { - break woohoo; - result1 = "fail: got to code after a break"; - } - result2 = "fail: got to code outside of loop but inside label"; - } - - result3 = "pass"; - - new TestCase( - SECTION, - "DoWhile_3: " +description +" - verify break out of loop", - "pass", - result1 ); - - - new TestCase( - SECTION, - "DoWhile_3: " +description +" - verify break out of label", - "pass", - result2 ); - - new TestCase( - SECTION, - "DoWhile_3: " +description + " - verify correct exit from label", - "pass", - result3 ); -} - - -/** - * Labled while with an unlabeled break - * - */ -function DoWhile_4() { - var description = "labeled while with an unlabeled break"; - var result1 = "pass"; - var result2 = "pass"; - var result3 = "fail: did not evaluate statement after label"; - -woohooboy: { - while( true ) { - break woohooboy; - result1 = "fail: got to code after the break"; - } - result2 = "fail: broke out of while, but not out of label"; - } - result3 = "pass"; - - new TestCase( - SECTION, - "DoWhile_4: " +description +" - verify break out of while loop", - "pass", - result1 ); - - new TestCase( - SECTION, - "DoWhile_4: " +description + " - verify break out of label", - "pass", - result2 ); - - new TestCase( - SECTION, - "DoWhile_4: " +description +" - verify that statements after label are evaluated", - "pass", - result3 ); -} - -/** - * in this case, should behave the same way as - * - * - */ -function DoWhile_5() { - var description = "while with a labeled continue statement"; - var result1 = "pass"; - var result2 = "fail: did not execute code after loop, but inside label"; - var i = 0; - var j = 0; - -theloop: { - j++; - while( i++ < 10 ) { - continue; - result1 = "failed: hit code after continue statement"; - } - result2 = "pass"; - } - - new TestCase( - SECTION, - "DoWhile_5: " +description + " - continue should not execute statements above the loop", - true, - ( j == 1 ) ); - - new TestCase( - SECTION, - "DoWhile_5: " +description +" - code after labeled continue should not be executed", - "pass", - result1 ); - - new TestCase( - SECTION, - "DoWhile_5: " +description +" - code after loop but inside label should be executed", - "pass", - result2 ); -} - diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/String/browser.js b/tests/auto/declarative/parserstress/tests/ecma_2/String/browser.js deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/String/match-001.js b/tests/auto/declarative/parserstress/tests/ecma_2/String/match-001.js deleted file mode 100644 index de2275b5d6..0000000000 --- a/tests/auto/declarative/parserstress/tests/ecma_2/String/match-001.js +++ /dev/null @@ -1,139 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is JavaScript Engine testing utilities. - * - * The Initial Developer of the Original Code is - * Netscape Communication Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -gTestfile = 'match-001.js'; - -/** - * File Name: String/match-001.js - * ECMA Section: 15.6.4.9 - * Description: Based on ECMA 2 Draft 7 February 1999 - * - * Author: christine@netscape.com - * Date: 19 February 1999 - */ - -/* - * String.match( regexp ) - * - * If regexp is not an object of type RegExp, it is replaced with result - * of the expression new RegExp(regexp). Let string denote the result of - * converting the this value to a string. If regexp.global is false, - * return the result obtained by invoking RegExp.prototype.exec (see - * section 15.7.5.3) on regexp with string as parameter. - * - * Otherwise, set the regexp.lastIndex property to 0 and invoke - * RegExp.prototype.exec repeatedly until there is no match. If there is a - * match with an empty string (in other words, if the value of - * regexp.lastIndex is left unchanged) increment regexp.lastIndex by 1. - * The value returned is an array with the properties 0 through n-1 - * corresponding to the first element of the result of each matching - * invocation of RegExp.prototype.exec. - * - * Note that the match function is intentionally generic; it does not - * require that its this value be a string object. Therefore, it can be - * transferred to other kinds of objects for use as a method. - */ - -var SECTION = "String/match-001.js"; -var VERSION = "ECMA_2"; -var TITLE = "String.prototype.match( regexp )"; - -startTest(); - -// the regexp argument is not a RegExp object -// this is not a string object - -// cases in which the regexp global property is false - -AddRegExpCases( 3, "3", "1234567890", 1, 2, ["3"] ); - -// cases in which the regexp object global property is true - -AddGlobalRegExpCases( /34/g, "/34/g", "343443444", 3, ["34", "34", "34"] ); -AddGlobalRegExpCases( /\d{1}/g, "/d{1}/g", "123456abcde7890", 10, - ["1", "2", "3", "4", "5", "6", "7", "8", "9", "0"] ); - -AddGlobalRegExpCases( /\d{2}/g, "/d{2}/g", "123456abcde7890", 5, - ["12", "34", "56", "78", "90"] ); - -AddGlobalRegExpCases( /\D{2}/g, "/d{2}/g", "123456abcde7890", 2, - ["ab", "cd"] ); - -test(); - - -function AddRegExpCases( - regexp, str_regexp, string, length, index, matches_array ) { - - AddTestCase( - "( " + string + " ).match(" + str_regexp +").length", - length, - string.match(regexp).length ); - - AddTestCase( - "( " + string + " ).match(" + str_regexp +").index", - index, - string.match(regexp).index ); - - AddTestCase( - "( " + string + " ).match(" + str_regexp +").input", - string, - string.match(regexp).input ); - - for ( var matches = 0; matches < matches_array.length; matches++ ) { - AddTestCase( - "( " + string + " ).match(" + str_regexp +")[" + matches +"]", - matches_array[matches], - string.match(regexp)[matches] ); - } -} - -function AddGlobalRegExpCases( - regexp, str_regexp, string, length, matches_array ) { - - AddTestCase( - "( " + string + " ).match(" + str_regexp +").length", - length, - string.match(regexp).length ); - - for ( var matches = 0; matches < matches_array.length; matches++ ) { - AddTestCase( - "( " + string + " ).match(" + str_regexp +")[" + matches +"]", - matches_array[matches], - string.match(regexp)[matches] ); - } -} diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/String/match-002.js b/tests/auto/declarative/parserstress/tests/ecma_2/String/match-002.js deleted file mode 100644 index a57da2f77f..0000000000 --- a/tests/auto/declarative/parserstress/tests/ecma_2/String/match-002.js +++ /dev/null @@ -1,207 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is JavaScript Engine testing utilities. - * - * The Initial Developer of the Original Code is - * Netscape Communication Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -gTestfile = 'match-002.js'; - -/** - * File Name: String/match-002.js - * ECMA Section: 15.6.4.9 - * Description: Based on ECMA 2 Draft 7 February 1999 - * - * Author: christine@netscape.com - * Date: 19 February 1999 - */ - -/* - * String.match( regexp ) - * - * If regexp is not an object of type RegExp, it is replaced with result - * of the expression new RegExp(regexp). Let string denote the result of - * converting the this value to a string. If regexp.global is false, - * return the result obtained by invoking RegExp.prototype.exec (see - * section 15.7.5.3) on regexp with string as parameter. - * - * Otherwise, set the regexp.lastIndex property to 0 and invoke - * RegExp.prototype.exec repeatedly until there is no match. If there is a - * match with an empty string (in other words, if the value of - * regexp.lastIndex is left unchanged) increment regexp.lastIndex by 1. - * The value returned is an array with the properties 0 through n-1 - * corresponding to the first element of the result of each matching - * invocation of RegExp.prototype.exec. - * - * Note that the match function is intentionally generic; it does not - * require that its this value be a string object. Therefore, it can be - * transferred to other kinds of objects for use as a method. - * - * This file tests cases in which regexp.global is false. Therefore, - * results should behave as regexp.exec with string passed as a parameter. - * - */ - -var SECTION = "String/match-002.js"; -var VERSION = "ECMA_2"; -var TITLE = "String.prototype.match( regexp )"; - -startTest(); - -// the regexp argument is not a RegExp object -// this is not a string object - -AddRegExpCases( /([\d]{5})([-\ ]?[\d]{4})?$/, - "/([\d]{5})([-\ ]?[\d]{4})?$/", - "Boston, Mass. 02134", - 14, - ["02134", "02134", undefined]); - -AddGlobalRegExpCases( /([\d]{5})([-\ ]?[\d]{4})?$/g, - "/([\d]{5})([-\ ]?[\d]{4})?$/g", - "Boston, Mass. 02134", - ["02134"]); - -// set the value of lastIndex -re = /([\d]{5})([-\ ]?[\d]{4})?$/; -re.lastIndex = 0; - -s = "Boston, MA 02134"; - -AddRegExpCases( re, - "re = /([\d]{5})([-\ ]?[\d]{4})?$/; re.lastIndex =0", - s, - s.lastIndexOf("0"), - ["02134", "02134", undefined]); - - -re.lastIndex = s.length; - -AddRegExpCases( re, - "re = /([\d]{5})([-\ ]?[\d]{4})?$/; re.lastIndex = " + - s.length, - s, - s.lastIndexOf("0"), - ["02134", "02134", undefined] ); - -re.lastIndex = s.lastIndexOf("0"); - -AddRegExpCases( re, - "re = /([\d]{5})([-\ ]?[\d]{4})?$/; re.lastIndex = " + - s.lastIndexOf("0"), - s, - s.lastIndexOf("0"), - ["02134", "02134", undefined]); - -re.lastIndex = s.lastIndexOf("0") + 1; - -AddRegExpCases( re, - "re = /([\d]{5})([-\ ]?[\d]{4})?$/; re.lastIndex = " + - s.lastIndexOf("0") +1, - s, - s.lastIndexOf("0"), - ["02134", "02134", undefined]); - -test(); - -function AddRegExpCases( - regexp, str_regexp, string, index, matches_array ) { - - // prevent a runtime error - - if ( regexp.exec(string) == null || matches_array == null ) { - AddTestCase( - string + ".match(" + regexp +")", - matches_array, - string.match(regexp) ); - - return; - } - - AddTestCase( - "( " + string + " ).match(" + str_regexp +").length", - matches_array.length, - string.match(regexp).length ); - - AddTestCase( - "( " + string + " ).match(" + str_regexp +").index", - index, - string.match(regexp).index ); - - AddTestCase( - "( " + string + " ).match(" + str_regexp +").input", - string, - string.match(regexp).input ); - - var limit = matches_array.length > string.match(regexp).length ? - matches_array.length : - string.match(regexp).length; - - for ( var matches = 0; matches < limit; matches++ ) { - AddTestCase( - "( " + string + " ).match(" + str_regexp +")[" + matches +"]", - matches_array[matches], - string.match(regexp)[matches] ); - } -} - -function AddGlobalRegExpCases( - regexp, str_regexp, string, matches_array ) { - - // prevent a runtime error - - if ( regexp.exec(string) == null || matches_array == null ) { - AddTestCase( - regexp + ".exec(" + string +")", - matches_array, - regexp.exec(string) ); - - return; - } - - AddTestCase( - "( " + string + " ).match(" + str_regexp +").length", - matches_array.length, - string.match(regexp).length ); - - var limit = matches_array.length > string.match(regexp).length ? - matches_array.length : - string.match(regexp).length; - - for ( var matches = 0; matches < limit; matches++ ) { - AddTestCase( - "( " + string + " ).match(" + str_regexp +")[" + matches +"]", - matches_array[matches], - string.match(regexp)[matches] ); - } -} diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/String/match-003.js b/tests/auto/declarative/parserstress/tests/ecma_2/String/match-003.js deleted file mode 100644 index cd3d80c919..0000000000 --- a/tests/auto/declarative/parserstress/tests/ecma_2/String/match-003.js +++ /dev/null @@ -1,165 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is JavaScript Engine testing utilities. - * - * The Initial Developer of the Original Code is - * Netscape Communication Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -gTestfile = 'match-003.js'; - -/** - * File Name: String/match-003.js - * ECMA Section: 15.6.4.9 - * Description: Based on ECMA 2 Draft 7 February 1999 - * - * Author: christine@netscape.com - * Date: 19 February 1999 - */ - -/* - * String.match( regexp ) - * - * If regexp is not an object of type RegExp, it is replaced with result - * of the expression new RegExp(regexp). Let string denote the result of - * converting the this value to a string. If regexp.global is false, - * return the result obtained by invoking RegExp.prototype.exec (see - * section 15.7.5.3) on regexp with string as parameter. - * - * Otherwise, set the regexp.lastIndex property to 0 and invoke - * RegExp.prototype.exec repeatedly until there is no match. If there is a - * match with an empty string (in other words, if the value of - * regexp.lastIndex is left unchanged) increment regexp.lastIndex by 1. - * The value returned is an array with the properties 0 through n-1 - * corresponding to the first element of the result of each matching - * invocation of RegExp.prototype.exec. - * - * Note that the match function is intentionally generic; it does not - * require that its this value be a string object. Therefore, it can be - * transferred to other kinds of objects for use as a method. - */ - -var SECTION = "String/match-003.js"; -var VERSION = "ECMA_2"; -var TITLE = "String.prototype.match( regexp )"; - -startTest(); - -// the regexp argument is not a RegExp object -// this is not a string object - - -// [if regexp.global is true] set the regexp.lastIndex property to 0 and -// invoke RegExp.prototype.exec repeatedly until there is no match. If -// there is a match with an empty string (in other words, if the value of -// regexp.lastIndex is left unchanged) increment regexp.lastIndex by 1. -// The value returned is an array with the properties 0 through n-1 -// corresponding to the first element of the result of each matching invocation -// of RegExp.prototype.exec. - - -// set the value of lastIndex -re = /([\d]{5})([-\ ]?[\d]{4})?$/g; - - -s = "Boston, MA 02134"; - -AddGlobalRegExpCases( re, - "re = " + re, - s, - ["02134" ]); - -re.lastIndex = 0; - -AddGlobalRegExpCases( - re, - "re = " + re + "; re.lastIndex = 0 ", - s, - ["02134"]); - - -re.lastIndex = s.length; - -AddGlobalRegExpCases( - re, - "re = " + re + "; re.lastIndex = " + s.length, - s, - ["02134"] ); - -re.lastIndex = s.lastIndexOf("0"); - -AddGlobalRegExpCases( - re, - "re = "+ re +"; re.lastIndex = " + s.lastIndexOf("0"), - s, - ["02134"]); - -re.lastIndex = s.lastIndexOf("0") + 1; - -AddGlobalRegExpCases( - re, - "re = " +re+ "; re.lastIndex = " + (s.lastIndexOf("0") +1), - s, - ["02134"]); - -test(); - -function AddGlobalRegExpCases( - regexp, str_regexp, string, matches_array ) { - - // prevent a runtime error - - if ( string.match(regexp) == null || matches_array == null ) { - AddTestCase( - string + ".match(" + str_regexp +")", - matches_array, - string.match(regexp) ); - - return; - } - - AddTestCase( - "( " + string + " ).match(" + str_regexp +").length", - matches_array.length, - string.match(regexp).length ); - - var limit = matches_array.length > string.match(regexp).length ? - matches_array.length : - string.match(regexp).length; - - for ( var matches = 0; matches < limit; matches++ ) { - AddTestCase( - "( " + string + " ).match(" + str_regexp +")[" + matches +"]", - matches_array[matches], - string.match(regexp)[matches] ); - } -} diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/String/match-004.js b/tests/auto/declarative/parserstress/tests/ecma_2/String/match-004.js deleted file mode 100644 index 5c26de8b61..0000000000 --- a/tests/auto/declarative/parserstress/tests/ecma_2/String/match-004.js +++ /dev/null @@ -1,206 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is JavaScript Engine testing utilities. - * - * The Initial Developer of the Original Code is - * Netscape Communication Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -gTestfile = 'match-004.js'; - -/** - * File Name: String/match-004.js - * ECMA Section: 15.6.4.9 - * Description: Based on ECMA 2 Draft 7 February 1999 - * - * Author: christine@netscape.com - * Date: 19 February 1999 - */ - -/* - * String.match( regexp ) - * - * If regexp is not an object of type RegExp, it is replaced with result - * of the expression new RegExp(regexp). Let string denote the result of - * converting the this value to a string. If regexp.global is false, - * return the result obtained by invoking RegExp.prototype.exec (see - * section 15.7.5.3) on regexp with string as parameter. - * - * Otherwise, set the regexp.lastIndex property to 0 and invoke - * RegExp.prototype.exec repeatedly until there is no match. If there is a - * match with an empty string (in other words, if the value of - * regexp.lastIndex is left unchanged) increment regexp.lastIndex by 1. - * The value returned is an array with the properties 0 through n-1 - * corresponding to the first element of the result of each matching - * invocation of RegExp.prototype.exec. - * - * Note that the match function is intentionally generic; it does not - * require that its this value be a string object. Therefore, it can be - * transferred to other kinds of objects for use as a method. - * - * - * The match function should be intentionally generic, and not require - * this to be a string. - * - */ - -var SECTION = "String/match-004.js"; -var VERSION = "ECMA_2"; -var TITLE = "String.prototype.match( regexp )"; - -var BUGNUMBER="http://scopus/bugsplat/show_bug.cgi?id=345818"; - -startTest(); - -// set the value of lastIndex -re = /0./; -s = 10203040506070809000; - -Number.prototype.match = String.prototype.match; - -AddRegExpCases( re, - "re = " + re , - s, - String(s), - 1, - ["02"]); - - -re.lastIndex = 0; -AddRegExpCases( re, - "re = " + re +" [lastIndex is " + re.lastIndex+"]", - s, - String(s), - 1, - ["02"]); -/* - -re.lastIndex = s.length; - -AddRegExpCases( re, -"re = /([\d]{5})([-\ ]?[\d]{4})?$/; re.lastIndex = " + -s.length, -s, -s.lastIndexOf("0"), -null ); - -re.lastIndex = s.lastIndexOf("0"); - -AddRegExpCases( re, -"re = /([\d]{5})([-\ ]?[\d]{4})?$/; re.lastIndex = " + -s.lastIndexOf("0"), -s, -s.lastIndexOf("0"), -["02134"]); - -re.lastIndex = s.lastIndexOf("0") + 1; - -AddRegExpCases( re, -"re = /([\d]{5})([-\ ]?[\d]{4})?$/; re.lastIndex = " + -s.lastIndexOf("0") +1, -s, -0, -null); -*/ -test(); - -function AddRegExpCases( - regexp, str_regexp, string, str_string, index, matches_array ) { - - // prevent a runtime error - - if ( regexp.exec(string) == null || matches_array == null ) { - AddTestCase( - string + ".match(" + regexp +")", - matches_array, - string.match(regexp) ); - - return; - } - - AddTestCase( - "( " + string + " ).match(" + str_regexp +").length", - matches_array.length, - string.match(regexp).length ); - - AddTestCase( - "( " + string + " ).match(" + str_regexp +").index", - index, - string.match(regexp).index ); - - AddTestCase( - "( " + string + " ).match(" + str_regexp +").input", - str_string, - string.match(regexp).input ); - - var limit = matches_array.length > string.match(regexp).length ? - matches_array.length : - string.match(regexp).length; - - for ( var matches = 0; matches < limit; matches++ ) { - AddTestCase( - "( " + string + " ).match(" + str_regexp +")[" + matches +"]", - matches_array[matches], - string.match(regexp)[matches] ); - } -} - -function AddGlobalRegExpCases( - regexp, str_regexp, string, matches_array ) { - - // prevent a runtime error - - if ( regexp.exec(string) == null || matches_array == null ) { - AddTestCase( - regexp + ".exec(" + string +")", - matches_array, - regexp.exec(string) ); - - return; - } - - AddTestCase( - "( " + string + " ).match(" + str_regexp +").length", - matches_array.length, - string.match(regexp).length ); - - var limit = matches_array.length > string.match(regexp).length ? - matches_array.length : - string.match(regexp).length; - - for ( var matches = 0; matches < limit; matches++ ) { - AddTestCase( - "( " + string + " ).match(" + str_regexp +")[" + matches +"]", - matches_array[matches], - string.match(regexp)[matches] ); - } -} diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/String/replace-001.js b/tests/auto/declarative/parserstress/tests/ecma_2/String/replace-001.js deleted file mode 100644 index f0ae3cdbfa..0000000000 --- a/tests/auto/declarative/parserstress/tests/ecma_2/String/replace-001.js +++ /dev/null @@ -1,99 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is JavaScript Engine testing utilities. - * - * The Initial Developer of the Original Code is - * Netscape Communication Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -gTestfile = 'replace-001.js'; - -/** - * File Name: String/replace-001.js - * ECMA Section: 15.6.4.10 - * Description: Based on ECMA 2 Draft 7 February 1999 - * - * Author: christine@netscape.com - * Date: 19 February 1999 - */ - -var SECTION = "String/replace-001.js"; -var VERSION = "ECMA_2"; -var TITLE = "String.prototype.replace( regexp, replaceValue )"; - -startTest(); - -/* - * If regexp is not an object of type RegExp, it is replaced with the - * result of the expression new RegExp(regexp). Let string denote the - * result of converting the this value to a string. String is searched - * for the first occurrence of the regular expression pattern regexp if - * regexp.global is false, or all occurrences if regexp.global is true. - * - * The match is performed as in String.prototype.match, including the - * update of regexp.lastIndex. Let m be the number of matched - * parenthesized subexpressions as specified in section 15.7.5.3. - * - * If replaceValue is a function, then for each matched substring, call - * the function with the following m + 3 arguments. Argument 1 is the - * substring that matched. The next m arguments are all of the matched - * subexpressions. Argument m + 2 is the length of the left context, and - * argument m + 3 is string. - * - * The result is a string value derived from the original input by - * replacing each matched substring with the corresponding return value - * of the function call, converted to a string if need be. - * - * Otherwise, let newstring denote the result of converting replaceValue - * to a string. The result is a string value derived from the original - * input string by replacing each matched substring with a string derived - * from newstring by replacing characters in newstring by replacement text - * as specified in the following table: - * - * $& The matched substring. - * $‘ The portion of string that precedes the matched substring. - * $’ The portion of string that follows the matched substring. - * $+ The substring matched by the last parenthesized subexpressions in - * the regular expression. - * $n The corresponding matched parenthesized subexpression n, where n - * is a single digit 0-9. If there are fewer than n subexpressions, “$n - * is left unchanged. - * - * Note that the replace function is intentionally generic; it does not - * require that its this value be a string object. Therefore, it can be - * transferred to other kinds of objects for use as a method. - */ - - -AddTestCase( "NO TESTS EXIST", "PASSED", "Test not implemented"); - -test(); diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/String/shell.js b/tests/auto/declarative/parserstress/tests/ecma_2/String/shell.js deleted file mode 100644 index 7d850446cc..0000000000 --- a/tests/auto/declarative/parserstress/tests/ecma_2/String/shell.js +++ /dev/null @@ -1 +0,0 @@ -gTestsubsuite = 'String'; diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/String/split-001.js b/tests/auto/declarative/parserstress/tests/ecma_2/String/split-001.js deleted file mode 100644 index bbab3b0428..0000000000 --- a/tests/auto/declarative/parserstress/tests/ecma_2/String/split-001.js +++ /dev/null @@ -1,145 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is JavaScript Engine testing utilities. - * - * The Initial Developer of the Original Code is - * Netscape Communication Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -gTestfile = 'split-001.js'; - -/** - * File Name: String/split-001.js - * ECMA Section: 15.6.4.9 - * Description: Based on ECMA 2 Draft 7 February 1999 - * - * Author: christine@netscape.com - * Date: 19 February 1999 - */ - -/* - * Since regular expressions have been part of JavaScript since 1.2, there - * are already tests for regular expressions in the js1_2/regexp folder. - * - * These new tests try to supplement the existing tests, and verify that - * our implementation of RegExp conforms to the ECMA specification, but - * does not try to be as exhaustive as in previous tests. - * - * The [,limit] argument to String.split is new, and not covered in any - * existing tests. - * - * String.split cases are covered in ecma/String/15.5.4.8-*.js. - * String.split where separator is a RegExp are in - * js1_2/regexp/string_split.js - * - */ - -var SECTION = "ecma_2/String/split-001.js"; -var VERSION = "ECMA_2"; -var TITLE = "String.prototype.split( regexp, [,limit] )"; - -startTest(); - -// the separator is not supplied -// separator is undefined -// separator is an empty string - -AddSplitCases( "splitme", "", "''", ["s", "p", "l", "i", "t", "m", "e"] ); -AddSplitCases( "splitme", new RegExp(), "new RegExp()", ["s", "p", "l", "i", "t", "m", "e"] ); - -// separartor is a regexp -// separator regexp value global setting is set -// string is an empty string -// if separator is an empty string, split each by character - -// this is not a String object - -// limit is not a number -// limit is undefined -// limit is larger than 2^32-1 -// limit is a negative number - -test(); - -function AddSplitCases( string, separator, str_sep, split_array ) { - - // verify that the result of split is an object of type Array - AddTestCase( - "( " + string + " ).split(" + str_sep +").constructor == Array", - true, - string.split(separator).constructor == Array ); - - // check the number of items in the array - AddTestCase( - "( " + string + " ).split(" + str_sep +").length", - split_array.length, - string.split(separator).length ); - - // check the value of each array item - var limit = (split_array.length > string.split(separator).length ) - ? split_array.length : string.split(separator).length; - - for ( var matches = 0; matches < split_array.length; matches++ ) { - AddTestCase( - "( " + string + " ).split(" + str_sep +")[" + matches +"]", - split_array[matches], - string.split( separator )[matches] ); - } -} - -function AddLimitedSplitCases( - string, separator, str_sep, limit, str_limit, split_array ) { - - // verify that the result of split is an object of type Array - - AddTestCase( - "( " + string + " ).split(" + str_sep +", " + str_limit + - " ).constructor == Array", - true, - string.split(separator, limit).constructor == Array ); - - // check the length of the array - - AddTestCase( - "( " + string + " ).split(" + str_sep +", " + str_limit + " ).length", - length, - string.split(separator).length ); - - // check the value of each array item - - for ( var matches = 0; matches < split_array.length; matches++ ) { - AddTestCase( - "( " + string + " ).split(" + str_sep +", " + str_limit + " )[" + matches +"]", - split_array[matches], - string.split( separator )[matches] ); - } -} diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/String/split-002.js b/tests/auto/declarative/parserstress/tests/ecma_2/String/split-002.js deleted file mode 100644 index 9ae000790e..0000000000 --- a/tests/auto/declarative/parserstress/tests/ecma_2/String/split-002.js +++ /dev/null @@ -1,303 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is JavaScript Engine testing utilities. - * - * The Initial Developer of the Original Code is - * Netscape Communication Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -gTestfile = 'split-002.js'; - -/** - * File Name: String/split-002.js - * ECMA Section: 15.6.4.9 - * Description: Based on ECMA 2 Draft 7 February 1999 - * - * Author: christine@netscape.com - * Date: 19 February 1999 - */ - -/* - * Since regular expressions have been part of JavaScript since 1.2, there - * are already tests for regular expressions in the js1_2/regexp folder. - * - * These new tests try to supplement the existing tests, and verify that - * our implementation of RegExp conforms to the ECMA specification, but - * does not try to be as exhaustive as in previous tests. - * - * The [,limit] argument to String.split is new, and not covered in any - * existing tests. - * - * String.split cases are covered in ecma/String/15.5.4.8-*.js. - * String.split where separator is a RegExp are in - * js1_2/regexp/string_split.js - * - */ - -var SECTION = "ecma_2/String/split-002.js"; -var VERSION = "ECMA_2"; -var TITLE = "String.prototype.split( regexp, [,limit] )"; - -startTest(); - -// the separator is not supplied -// separator is undefined -// separator is an empty string - -// AddSplitCases( "splitme", "", "''", ["s", "p", "l", "i", "t", "m", "e"] ); -// AddSplitCases( "splitme", new RegExp(), "new RegExp()", ["s", "p", "l", "i", "t", "m", "e"] ); - -// separator is an empty regexp -// separator is not supplied - -CompareSplit( "hello", "ll" ); - -CompareSplit( "hello", "l" ); -CompareSplit( "hello", "x" ); -CompareSplit( "hello", "h" ); -CompareSplit( "hello", "o" ); -CompareSplit( "hello", "hello" ); -CompareSplit( "hello", undefined ); - -CompareSplit( "hello", ""); -CompareSplit( "hello", "hellothere" ); - -CompareSplit( new String("hello" ) ); - - -Number.prototype.split = String.prototype.split; - -CompareSplit( new Number(100111122133144155), 1 ); -CompareSplitWithLimit(new Number(100111122133144155), 1, 1 ); - -CompareSplitWithLimit(new Number(100111122133144155), 1, 2 ); -CompareSplitWithLimit(new Number(100111122133144155), 1, 0 ); -CompareSplitWithLimit(new Number(100111122133144155), 1, 100 ); -CompareSplitWithLimit(new Number(100111122133144155), 1, void 0 ); -CompareSplitWithLimit(new Number(100111122133144155), 1, Math.pow(2,32)-1 ); -CompareSplitWithLimit(new Number(100111122133144155), 1, "boo" ); -CompareSplitWithLimit(new Number(100111122133144155), 1, -(Math.pow(2,32)-1) ); -CompareSplitWithLimit( "hello", "l", NaN ); -CompareSplitWithLimit( "hello", "l", 0 ); -CompareSplitWithLimit( "hello", "l", 1 ); -CompareSplitWithLimit( "hello", "l", 2 ); -CompareSplitWithLimit( "hello", "l", 3 ); -CompareSplitWithLimit( "hello", "l", 4 ); - - -/* - CompareSplitWithLimit( "hello", "ll", 0 ); - CompareSplitWithLimit( "hello", "ll", 1 ); - CompareSplitWithLimit( "hello", "ll", 2 ); - CompareSplit( "", " " ); - CompareSplit( "" ); -*/ - -// separartor is a regexp -// separator regexp value global setting is set -// string is an empty string -// if separator is an empty string, split each by character - -// this is not a String object - -// limit is not a number -// limit is undefined -// limit is larger than 2^32-1 -// limit is a negative number - -test(); - -function CompareSplit( string, separator ) { - split_1 = string.split( separator ); - split_2 = string_split( string, separator ); - - AddTestCase( - "( " + string +".split(" + separator + ") ).length" , - split_2.length, - split_1.length ); - - var limit = split_1.length > split_2.length ? - split_1.length : split_2.length; - - for ( var split_item = 0; split_item < limit; split_item++ ) { - AddTestCase( - string + ".split(" + separator + ")["+split_item+"]", - split_2[split_item], - split_1[split_item] ); - } -} - -function CompareSplitWithLimit( string, separator, splitlimit ) { - split_1 = string.split( separator, splitlimit ); - split_2 = string_split( string, separator, splitlimit ); - - AddTestCase( - "( " + string +".split(" + separator + ", " + splitlimit+") ).length" , - split_2.length, - split_1.length ); - - var limit = split_1.length > split_2.length ? - split_1.length : split_2.length; - - for ( var split_item = 0; split_item < limit; split_item++ ) { - AddTestCase( - string + ".split(" + separator + ", " + splitlimit+")["+split_item+"]", - split_2[split_item], - split_1[split_item] ); - } -} - -function string_split ( __this, separator, limit ) { - var S = String(__this ); // 1 - - var A = new Array(); // 2 - - if ( limit == undefined ) { // 3 - lim = Math.pow(2, 31 ) -1; - } else { - lim = ToUint32( limit ); - } - - var s = S.length; // 4 - var p = 0; // 5 - - if ( separator == undefined ) { // 8 - A[0] = S; - return A; - } - - if ( separator.constructor == RegExp ) // 6 - R = separator; - else - R = separator.toString(); - - if (lim == 0) return A; // 7 - - if ( separator == undefined ) { // 8 - A[0] = S; - return A; - } - - if (s == 0) { // 9 - z = SplitMatch(R, S, 0); - if (z != false) return A; - A[0] = S; - return A; - } - - var q = p; // 10 -loop: - while (true ) { - - if ( q == s ) break; // 11 - - z = SplitMatch(R, S, q); // 12 - -//print("Returned ", z); - - if (z != false) { // 13 - e = z.endIndex; // 14 - cap = z.captures; // 14 - if (e != p) { // 15 -//print("S = ", S, ", p = ", p, ", q = ", q); - T = S.slice(p, q); // 16 -//print("T = ", T); - A[A.length] = T; // 17 - if (A.length == lim) return A; // 18 - p = e; // 19 - i = 0; // 20 - while (true) { // 25 - if (i == cap.length) { // 21 - q = p; // 10 - continue loop; - } - i = i + 1; // 22 - A[A.length] = cap[i] // 23 - if (A.length == lim) return A; // 24 - } - } - } - - q = q + 1; // 26 - } - - T = S.slice(p, q); - A[A.length] = T; - return A; -} - -function SplitMatch(R, S, q) -{ - if (R.constructor == RegExp) { // 1 - var reResult = R.match(S, q); // 8 - if (reResult == undefined) - return false; - else { - a = new Array(reResult.length - 1); - for (var i = 1; i < reResult.length; i++) - a[a.length] = reResult[i]; - return { endIndex : reResult.index + reResult[0].length, captures : cap }; - } - } - else { - var r = R.length; // 2 - s = S.length; // 3 - if ((q + r) > s) return false; // 4 - for (var i = 0; i < r; i++) { -//print("S.charAt(", q + i, ") = ", S.charAt(q + i), ", R.charAt(", i, ") = ", R.charAt(i)); - if (S.charAt(q + i) != R.charAt(i)) // 5 - return false; - } - cap = new Array(); // 6 - return { endIndex : q + r, captures : cap }; // 7 - } -} - -function ToUint32( n ) { - n = Number( n ); - var sign = ( n < 0 ) ? -1 : 1; - - if ( Math.abs( n ) == 0 - || Math.abs( n ) == Number.POSITIVE_INFINITY - || n != n) { - return 0; - } - n = sign * Math.floor( Math.abs(n) ) - - n = n % Math.pow(2,32); - - if ( n < 0 ){ - n += Math.pow(2,32); - } - - return ( n ); -} diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/String/split-003.js b/tests/auto/declarative/parserstress/tests/ecma_2/String/split-003.js deleted file mode 100644 index 5029fc98f9..0000000000 --- a/tests/auto/declarative/parserstress/tests/ecma_2/String/split-003.js +++ /dev/null @@ -1,156 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is JavaScript Engine testing utilities. - * - * The Initial Developer of the Original Code is - * Netscape Communication Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -gTestfile = 'split-003.js'; - -/** - * File Name: String/split-003.js - * ECMA Section: 15.6.4.9 - * Description: Based on ECMA 2 Draft 7 February 1999 - * - * Author: christine@netscape.com - * Date: 19 February 1999 - */ - -/* - * Since regular expressions have been part of JavaScript since 1.2, there - * are already tests for regular expressions in the js1_2/regexp folder. - * - * These new tests try to supplement the existing tests, and verify that - * our implementation of RegExp conforms to the ECMA specification, but - * does not try to be as exhaustive as in previous tests. - * - * The [,limit] argument to String.split is new, and not covered in any - * existing tests. - * - * String.split cases are covered in ecma/String/15.5.4.8-*.js. - * String.split where separator is a RegExp are in - * js1_2/regexp/string_split.js - * - */ - -var SECTION = "ecma_2/String/split-003.js"; -var VERSION = "ECMA_2"; -var TITLE = "String.prototype.split( regexp, [,limit] )"; - -startTest(); - -// separator is a regexp -// separator regexp value global setting is set -// string is an empty string -// if separator is an empty string, split each by character - - -AddSplitCases( "hello", new RegExp, "new RegExp", ["h","e","l","l","o"] ); - -AddSplitCases( "hello", /l/, "/l/", ["he","","o"] ); -AddLimitedSplitCases( "hello", /l/, "/l/", 0, [] ); -AddLimitedSplitCases( "hello", /l/, "/l/", 1, ["he"] ); -AddLimitedSplitCases( "hello", /l/, "/l/", 2, ["he",""] ); -AddLimitedSplitCases( "hello", /l/, "/l/", 3, ["he","","o"] ); -AddLimitedSplitCases( "hello", /l/, "/l/", 4, ["he","","o"] ); -AddLimitedSplitCases( "hello", /l/, "/l/", void 0, ["he","","o"] ); -AddLimitedSplitCases( "hello", /l/, "/l/", "hi", [] ); -AddLimitedSplitCases( "hello", /l/, "/l/", undefined, ["he","","o"] ); - -AddSplitCases( "hello", new RegExp, "new RegExp", ["h","e","l","l","o"] ); -AddLimitedSplitCases( "hello", new RegExp, "new RegExp", 0, [] ); -AddLimitedSplitCases( "hello", new RegExp, "new RegExp", 1, ["h"] ); -AddLimitedSplitCases( "hello", new RegExp, "new RegExp", 2, ["h","e"] ); -AddLimitedSplitCases( "hello", new RegExp, "new RegExp", 3, ["h","e","l"] ); -AddLimitedSplitCases( "hello", new RegExp, "new RegExp", 4, ["h","e","l","l"] ); -AddLimitedSplitCases( "hello", new RegExp, "new RegExp", void 0, ["h","e","l","l","o"] ); -AddLimitedSplitCases( "hello", new RegExp, "new RegExp", "hi", [] ); -AddLimitedSplitCases( "hello", new RegExp, "new RegExp", undefined, ["h","e","l","l","o"] ); - -test(); - -function AddSplitCases( string, separator, str_sep, split_array ) { - // verify that the result of split is an object of type Array - AddTestCase( - "( " + string + " ).split(" + str_sep +").constructor == Array", - true, - string.split(separator).constructor == Array ); - - // check the number of items in the array - AddTestCase( - "( " + string + " ).split(" + str_sep +").length", - split_array.length, - string.split(separator).length ); - - // check the value of each array item - var limit = (split_array.length > string.split(separator).length ) - ? split_array.length : string.split(separator).length; - - for ( var matches = 0; matches < split_array.length; matches++ ) { - AddTestCase( - "( " + string + " ).split(" + str_sep +")[" + matches +"]", - split_array[matches], - string.split( separator )[matches] ); - } -} - -function AddLimitedSplitCases( - string, separator, str_sep, limit, split_array ) { - - // verify that the result of split is an object of type Array - - AddTestCase( - "( " + string + " ).split(" + str_sep +", " + limit + - " ).constructor == Array", - true, - string.split(separator, limit).constructor == Array ); - - // check the length of the array - - AddTestCase( - "( " + string + " ).split(" + str_sep +", " + limit + " ).length", - split_array.length, - string.split(separator, limit).length ); - - // check the value of each array item - - var slimit = (split_array.length > string.split(separator).length ) - ? split_array.length : string.split(separator, limit).length; - - for ( var matches = 0; matches < slimit; matches++ ) { - AddTestCase( - "( " + string + " ).split(" + str_sep +", " + limit + " )[" + matches +"]", - split_array[matches], - string.split( separator, limit )[matches] ); - } -} diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/browser.js b/tests/auto/declarative/parserstress/tests/ecma_2/browser.js deleted file mode 100644 index 4cde9b0629..0000000000 --- a/tests/auto/declarative/parserstress/tests/ecma_2/browser.js +++ /dev/null @@ -1,37 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is mozilla.org code. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/extensions/browser.js b/tests/auto/declarative/parserstress/tests/ecma_2/extensions/browser.js deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/extensions/constructor-001.js b/tests/auto/declarative/parserstress/tests/ecma_2/extensions/constructor-001.js deleted file mode 100755 index cc7907d006..0000000000 --- a/tests/auto/declarative/parserstress/tests/ecma_2/extensions/constructor-001.js +++ /dev/null @@ -1,74 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is JavaScript Engine testing utilities. - * - * The Initial Developer of the Original Code is - * Netscape Communication Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -gTestfile = 'constructor-001.js'; - -/** - * File Name: RegExp/constructor-001.js - * ECMA Section: 15.7.3.3 - * Description: Based on ECMA 2 Draft 7 February 1999 - * - * Author: christine@netscape.com - * Date: 19 February 1999 - */ -var SECTION = "RegExp/constructor-001"; -var VERSION = "ECMA_2"; -var TITLE = "new RegExp()"; - -startTest(); - -/* - * for each test case, verify: - * - verify that [[Class]] property is RegExp - * - prototype property should be set to RegExp.prototype - * - source is set to the empty string - * - global property is set to false - * - ignoreCase property is set to false - * - multiline property is set to false - * - lastIndex property is set to 0 - */ - -RegExp.prototype.getClassProperty = Object.prototype.toString; -var re = new RegExp(); - -AddTestCase( - "new RegExp().__proto__", - RegExp.prototype, - re.__proto__ - ); - -test() diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/extensions/function-001.js b/tests/auto/declarative/parserstress/tests/ecma_2/extensions/function-001.js deleted file mode 100755 index 5153d25f9d..0000000000 --- a/tests/auto/declarative/parserstress/tests/ecma_2/extensions/function-001.js +++ /dev/null @@ -1,74 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is JavaScript Engine testing utilities. - * - * The Initial Developer of the Original Code is - * Netscape Communication Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -gTestfile = 'function-001.js'; - -/** - * File Name: RegExp/function-001.js - * ECMA Section: 15.7.2.1 - * Description: Based on ECMA 2 Draft 7 February 1999 - * - * Author: christine@netscape.com - * Date: 19 February 1999 - */ -var SECTION = "RegExp/function-001"; -var VERSION = "ECMA_2"; -var TITLE = "RegExp( pattern, flags )"; - -startTest(); - -/* - * for each test case, verify: - * - verify that [[Class]] property is RegExp - * - prototype property should be set to RegExp.prototype - * - source is set to the empty string - * - global property is set to false - * - ignoreCase property is set to false - * - multiline property is set to false - * - lastIndex property is set to 0 - */ - -RegExp.prototype.getClassProperty = Object.prototype.toString; -var re = new RegExp(); - -AddTestCase( - "new RegExp().__proto__", - RegExp.prototype, - re.__proto__ - ); - -test() diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/extensions/instanceof-001.js b/tests/auto/declarative/parserstress/tests/ecma_2/extensions/instanceof-001.js deleted file mode 100755 index 8ea446a248..0000000000 --- a/tests/auto/declarative/parserstress/tests/ecma_2/extensions/instanceof-001.js +++ /dev/null @@ -1,144 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is JavaScript Engine testing utilities. - * - * The Initial Developer of the Original Code is - * Netscape Communication Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -gTestfile = 'instanceof-001.js'; - -/** - * File Name: instanceof-001.js - * ECMA Section: 11.8.6 - * Description: - * - * RelationalExpression instanceof Identifier - * - * Author: christine@netscape.com - * Date: 2 September 1998 - */ -var SECTION = "instanceof-001"; -var VERSION = "ECMA_2"; -var TITLE = "instanceof" - - startTest(); -writeHeaderToLog( SECTION + " "+ TITLE); - -function InstanceOf( object_1, object_2, expect ) { - result = object_1 instanceof object_2; - - new TestCase( - SECTION, - "(" + object_1 + ") instanceof " + object_2, - expect, - result ); -} - -function Gen3(value) { - this.value = value; - this.generation = 3; - this.toString = new Function ( "return \"(Gen\"+this.generation+\" instance)\"" ); -} -Gen3.name = 3; -Gen3.__proto__.toString = new Function( "return \"(\"+this.name+\" object)\""); - -function Gen2(value) { - this.value = value; - this.generation = 2; -} -Gen2.name = 2; -Gen2.prototype = new Gen3(); - -function Gen1(value) { - this.value = value; - this.generation = 1; -} -Gen1.name = 1; -Gen1.prototype = new Gen2(); - -function Gen0(value) { - this.value = value; - this.generation = 0; -} -Gen0.name = 0; -Gen0.prototype = new Gen1(); - - -function GenA(value) { - this.value = value; - this.generation = "A"; - this.toString = new Function ( "return \"(instance of Gen\"+this.generation+\")\"" ); - -} -GenA.prototype = new Gen0(); -GenA.name = "A"; - -function GenB(value) { - this.value = value; - this.generation = "B"; - this.toString = new Function ( "return \"(instance of Gen\"+this.generation+\")\"" ); -} -GenB.name = "B" - GenB.prototype = void 0; - -// RelationalExpression is not an object. - -InstanceOf( true, Boolean, false ); -InstanceOf( new Boolean(false), Boolean, true ); - -// __proto__ of RelationalExpression is null. should return false -genA = new GenA(); -genA.__proto__ = null; - -InstanceOf( genA, GenA, false ); - -// RelationalExpression.__proto__ == (but not ===) Identifier.prototype - -InstanceOf( new Gen2(), Gen0, false ); -InstanceOf( new Gen2(), Gen1, false ); -InstanceOf( new Gen2(), Gen2, true ); -InstanceOf( new Gen2(), Gen3, true ); - -// RelationalExpression.__proto__.__proto__ === Identifier.prototype -InstanceOf( new Gen0(), Gen0, true ); -InstanceOf( new Gen0(), Gen1, true ); -InstanceOf( new Gen0(), Gen2, true ); -InstanceOf( new Gen0(), Gen3, true ); - -InstanceOf( new Gen0(), Object, true ); -InstanceOf( new Gen0(), Function, false ); - -InstanceOf( Gen0, Function, true ); -InstanceOf( Gen0, Object, true ); - -test(); diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/extensions/instanceof-002.js b/tests/auto/declarative/parserstress/tests/ecma_2/extensions/instanceof-002.js deleted file mode 100755 index 9cc837d8ef..0000000000 --- a/tests/auto/declarative/parserstress/tests/ecma_2/extensions/instanceof-002.js +++ /dev/null @@ -1,160 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is JavaScript Engine testing utilities. - * - * The Initial Developer of the Original Code is - * Netscape Communication Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -gTestfile = 'instanceof-002.js'; - -/** - File Name: instanceof-002.js - Section: - Description: Determining Instance Relationships - - This test is the same as js1_3/inherit/proto-002, except that it uses - the builtin instanceof operator rather than a user-defined function - called InstanceOf. - - This tests Object Hierarchy and Inheritance, as described in the document - Object Hierarchy and Inheritance in JavaScript, last modified on 12/18/97 - 15:19:34 on http://devedge.netscape.com/. Current URL: - http://devedge.netscape.com/docs/manuals/communicator/jsobj/contents.htm - - This tests the syntax ObjectName.prototype = new PrototypeObject using the - Employee example in the document referenced above. - - Author: christine@netscape.com - Date: 12 november 1997 -*/ -// onerror = err; - -var SECTION = "instanceof-002"; -var VERSION = "ECMA_2"; -var TITLE = "Determining Instance Relationships"; - -startTest(); -writeHeaderToLog( SECTION + " "+ TITLE); - -function InstanceOf( object, constructor ) { - while ( object != null ) { - if ( object == constructor.prototype ) { - return true; - } - object = object.__proto__; - } - return false; -} - -function Employee ( name, dept ) { - this.name = name || ""; - this.dept = dept || "general"; -} - -function Manager () { - this.reports = []; -} -Manager.prototype = new Employee(); - -function WorkerBee ( name, dept, projs ) { - this.base = Employee; - this.base( name, dept) - this.projects = projs || new Array(); -} -WorkerBee.prototype = new Employee(); - -function SalesPerson () { - this.dept = "sales"; - this.quota = 100; -} -SalesPerson.prototype = new WorkerBee(); - -function Engineer ( name, projs, machine ) { - this.base = WorkerBee; - this.base( name, "engineering", projs ) - this.machine = machine || ""; -} -Engineer.prototype = new WorkerBee(); - -var pat = new Engineer(); - -new TestCase( SECTION, - "pat.__proto__ == Engineer.prototype", - true, - pat.__proto__ == Engineer.prototype ); - -new TestCase( SECTION, - "pat.__proto__.__proto__ == WorkerBee.prototype", - true, - pat.__proto__.__proto__ == WorkerBee.prototype ); - -new TestCase( SECTION, - "pat.__proto__.__proto__.__proto__ == Employee.prototype", - true, - pat.__proto__.__proto__.__proto__ == Employee.prototype ); - -new TestCase( SECTION, - "pat.__proto__.__proto__.__proto__.__proto__ == Object.prototype", - true, - pat.__proto__.__proto__.__proto__.__proto__ == Object.prototype ); - -new TestCase( SECTION, - "pat.__proto__.__proto__.__proto__.__proto__.__proto__ == null", - true, - pat.__proto__.__proto__.__proto__.__proto__.__proto__ == null ); - -new TestCase( SECTION, - "pat instanceof Engineer", - true, - pat instanceof Engineer ); - -new TestCase( SECTION, - "pat instanceof WorkerBee )", - true, - pat instanceof WorkerBee ); - -new TestCase( SECTION, - "pat instanceof Employee )", - true, - pat instanceof Employee ); - -new TestCase( SECTION, - "pat instanceof Object )", - true, - pat instanceof Object ); - -new TestCase( SECTION, - "pat instanceof SalesPerson )", - false, - pat instanceof SalesPerson ); -test(); diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/extensions/instanceof-003-n.js b/tests/auto/declarative/parserstress/tests/ecma_2/extensions/instanceof-003-n.js deleted file mode 100755 index 7a763a895c..0000000000 --- a/tests/auto/declarative/parserstress/tests/ecma_2/extensions/instanceof-003-n.js +++ /dev/null @@ -1,121 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is JavaScript Engine testing utilities. - * - * The Initial Developer of the Original Code is - * Netscape Communication Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -gTestfile = 'instanceof-003-n.js'; - -/** - * File Name: instanceof-001.js - * ECMA Section: 11.8.6 - * Description: - * - * RelationalExpression instanceof Identifier - * - * Author: christine@netscape.com - * Date: 2 September 1998 - */ -var SECTION = "instanceof-003-n"; -var VERSION = "ECMA_2"; -var TITLE = "instanceof" - - startTest(); -writeHeaderToLog( SECTION + " "+ TITLE); - -function InstanceOf( object_1, object_2, expect ) { - - result = object_1 instanceof object_2; - - new TestCase( - SECTION, - "(" + object_1 + ") instanceof " + object_2, - expect, - result ); -} - -function Gen3(value) { - this.value = value; - this.generation = 3; - this.toString = new Function ( "return \"(Gen\"+this.generation+\" instance)\"" ); -} -Gen3.name = 3; -Gen3.__proto__.toString = new Function( "return \"(\"+this.name+\" object)\""); - -function Gen2(value) { - this.value = value; - this.generation = 2; -} -Gen2.name = 2; -Gen2.prototype = new Gen3(); - -function Gen1(value) { - this.value = value; - this.generation = 1; -} -Gen1.name = 1; -Gen1.prototype = new Gen2(); - -function Gen0(value) { - this.value = value; - this.generation = 0; -} -Gen0.name = 0; -Gen0.prototype = new Gen1(); - - -function GenA(value) { - this.value = value; - this.generation = "A"; - this.toString = new Function ( "return \"(instance of Gen\"+this.generation+\")\"" ); - -} -GenA.prototype = new Gen0(); -GenA.name = "A"; - -function GenB(value) { - this.value = value; - this.generation = "B"; - this.toString = new Function ( "return \"(instance of Gen\"+this.generation+\")\"" ); -} -GenB.name = "B" - GenB.prototype = void 0; - -// Identifier is not a function -DESCRIPTION = "Identifier is not a function"; -EXPECTED = "error"; - -InstanceOf( true, true, "error" ); - -test(); diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/extensions/instanceof-004-n.js b/tests/auto/declarative/parserstress/tests/ecma_2/extensions/instanceof-004-n.js deleted file mode 100755 index 1662ae566b..0000000000 --- a/tests/auto/declarative/parserstress/tests/ecma_2/extensions/instanceof-004-n.js +++ /dev/null @@ -1,121 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is JavaScript Engine testing utilities. - * - * The Initial Developer of the Original Code is - * Netscape Communication Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -gTestfile = 'instanceof-004-n.js'; - -/** - * File Name: instanceof-001.js - * ECMA Section: 11.8.6 - * Description: - * - * RelationalExpression instanceof Identifier - * - * Author: christine@netscape.com - * Date: 2 September 1998 - */ -var SECTION = "instanceof-004-n"; -var VERSION = "ECMA_2"; -var TITLE = "instanceof" - - startTest(); -writeHeaderToLog( SECTION + " "+ TITLE); - -function InstanceOf( object_1, object_2, expect ) { - result = object_1 instanceof object_2; - - new TestCase( - SECTION, - "(" + object_1 + ") instanceof " + object_2, - expect, - result ); -} - -function Gen3(value) { - this.value = value; - this.generation = 3; - this.toString = new Function ( "return \"(Gen\"+this.generation+\" instance)\"" ); -} -Gen3.name = 3; -Gen3.__proto__.toString = new Function( "return \"(\"+this.name+\" object)\""); - -function Gen2(value) { - this.value = value; - this.generation = 2; -} -Gen2.name = 2; -Gen2.prototype = new Gen3(); - -function Gen1(value) { - this.value = value; - this.generation = 1; -} -Gen1.name = 1; -Gen1.prototype = new Gen2(); - -function Gen0(value) { - this.value = value; - this.generation = 0; -} -Gen0.name = 0; -Gen0.prototype = new Gen1(); - - -function GenA(value) { - this.value = value; - this.generation = "A"; - this.toString = new Function ( "return \"(instance of Gen\"+this.generation+\")\"" ); - -} -GenA.prototype = new Gen0(); -GenA.name = "A"; - -function GenB(value) { - this.value = value; - this.generation = "B"; - this.toString = new Function ( "return \"(instance of Gen\"+this.generation+\")\"" ); -} -GenB.name = "B" - GenB.prototype = void 0; - -// Identifier is not a function - -DESCRIPTION = "Identifier is not a function"; -EXPECTED = "error"; - -InstanceOf( new Boolean(true), false, "error" ); - -test(); diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/extensions/instanceof-005-n.js b/tests/auto/declarative/parserstress/tests/ecma_2/extensions/instanceof-005-n.js deleted file mode 100755 index 1a9b1b3437..0000000000 --- a/tests/auto/declarative/parserstress/tests/ecma_2/extensions/instanceof-005-n.js +++ /dev/null @@ -1,122 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is JavaScript Engine testing utilities. - * - * The Initial Developer of the Original Code is - * Netscape Communication Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -gTestfile = 'instanceof-005-n.js'; - -/** - * File Name: instanceof-001.js - * ECMA Section: 11.8.6 - * Description: - * - * RelationalExpression instanceof Identifier - * - * Author: christine@netscape.com - * Date: 2 September 1998 - */ -var SECTION = "instanceof-005-n"; -var VERSION = "ECMA_2"; -var TITLE = "instanceof" - - startTest(); -writeHeaderToLog( SECTION + " "+ TITLE); - -function InstanceOf( object_1, object_2, expect ) { - result = object_1 instanceof object_2; - - new TestCase( - SECTION, - "(" + object_1 + ") instanceof " + object_2, - expect, - result ); -} - -function Gen3(value) { - this.value = value; - this.generation = 3; - this.toString = new Function ( "return \"(Gen\"+this.generation+\" instance)\"" ); -} -Gen3.name = 3; -Gen3.__proto__.toString = new Function( "return \"(\"+this.name+\" object)\""); - -function Gen2(value) { - this.value = value; - this.generation = 2; -} -Gen2.name = 2; -Gen2.prototype = new Gen3(); - -function Gen1(value) { - this.value = value; - this.generation = 1; -} -Gen1.name = 1; -Gen1.prototype = new Gen2(); - -function Gen0(value) { - this.value = value; - this.generation = 0; -} -Gen0.name = 0; -Gen0.prototype = new Gen1(); - - -function GenA(value) { - this.value = value; - this.generation = "A"; - this.toString = new Function ( "return \"(instance of Gen\"+this.generation+\")\"" ); - -} -GenA.prototype = new Gen0(); -GenA.name = "A"; - -function GenB(value) { - this.value = value; - this.generation = "B"; - this.toString = new Function ( "return \"(instance of Gen\"+this.generation+\")\"" ); -} -GenB.name = "B" - GenB.prototype = void 0; - - -// Identifier is a function, prototype of Identifier is not an object - -DESCRIPTION = "Identifier is a function, prototype of Identifier is not an object"; -EXPECTED = "error"; - -InstanceOf( new GenB(), GenB, "error" ); - -test(); diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/extensions/instanceof-006.js b/tests/auto/declarative/parserstress/tests/ecma_2/extensions/instanceof-006.js deleted file mode 100755 index 03c0f16fb9..0000000000 --- a/tests/auto/declarative/parserstress/tests/ecma_2/extensions/instanceof-006.js +++ /dev/null @@ -1,119 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is JavaScript Engine testing utilities. - * - * The Initial Developer of the Original Code is - * Netscape Communication Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -gTestfile = 'instanceof-006.js'; - -/** - * File Name: instanceof-001.js - * ECMA Section: 11.8.6 - * Description: - * - * RelationalExpression instanceof Identifier - * - * Author: christine@netscape.com - * Date: 2 September 1998 - */ -var SECTION = "instanceof-001"; -var VERSION = "ECMA_2"; -var TITLE = "instanceof" - - startTest(); -writeHeaderToLog( SECTION + " "+ TITLE); - -function InstanceOf( object_1, object_2, expect ) { - result = object_1 instanceof object_2; - - new TestCase( - SECTION, - "(" + object_1 + ") instanceof " + object_2, - expect, - result ); -} - -function Gen3(value) { - this.value = value; - this.generation = 3; - this.toString = new Function ( "return \"(Gen\"+this.generation+\" instance)\"" ); -} -Gen3.name = 3; -Gen3.__proto__.toString = new Function( "return \"(\"+this.name+\" object)\""); - -function Gen2(value) { - this.value = value; - this.generation = 2; -} -Gen2.name = 2; -Gen2.prototype = new Gen3(); - -function Gen1(value) { - this.value = value; - this.generation = 1; -} -Gen1.name = 1; -Gen1.prototype = new Gen2(); - -function Gen0(value) { - this.value = value; - this.generation = 0; -} -Gen0.name = 0; -Gen0.prototype = new Gen1(); - - -function GenA(value) { - this.value = value; - this.generation = "A"; - this.toString = new Function ( "return \"(instance of Gen\"+this.generation+\")\"" ); - -} -GenA.prototype = new Gen0(); -GenA.name = "A"; - -function GenB(value) { - this.value = value; - this.generation = "B"; - this.toString = new Function ( "return \"(instance of Gen\"+this.generation+\")\"" ); -} -GenB.name = "B" - GenB.prototype = void 0; - -// RelationalExpression is not an object. - -// InstanceOf( true, Boolean, false ); -InstanceOf( new Boolean(false), Boolean, true ); - -test(); diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/extensions/shell.js b/tests/auto/declarative/parserstress/tests/ecma_2/extensions/shell.js deleted file mode 100644 index 3f52cffbc0..0000000000 --- a/tests/auto/declarative/parserstress/tests/ecma_2/extensions/shell.js +++ /dev/null @@ -1 +0,0 @@ -gTestsubsuite = 'extensions'; diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/instanceof/browser.js b/tests/auto/declarative/parserstress/tests/ecma_2/instanceof/browser.js deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/instanceof/instanceof-001.js b/tests/auto/declarative/parserstress/tests/ecma_2/instanceof/instanceof-001.js deleted file mode 100644 index 39ae96fa5b..0000000000 --- a/tests/auto/declarative/parserstress/tests/ecma_2/instanceof/instanceof-001.js +++ /dev/null @@ -1,67 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is JavaScript Engine testing utilities. - * - * The Initial Developer of the Original Code is - * Netscape Communication Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -gTestfile = 'instanceof-001.js'; - -/** - File Name: instanceof-1.js - ECMA Section: - Description: instanceof operator - - Author: christine@netscape.com - Date: 12 november 1997 -*/ -var SECTION = ""; -var VERSION = "ECMA_2"; -var TITLE = "instanceof operator"; - -startTest(); -writeHeaderToLog( SECTION + " "+ TITLE); - -var b = new Boolean(); - -new TestCase( SECTION, - "var b = new Boolean(); b instanceof Boolean", - true, - b instanceof Boolean ); - -new TestCase( SECTION, - "b instanceof Object", - true, - b instanceof Object ); - -test(); diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/instanceof/instanceof-002.js b/tests/auto/declarative/parserstress/tests/ecma_2/instanceof/instanceof-002.js deleted file mode 100644 index c35fcb0486..0000000000 --- a/tests/auto/declarative/parserstress/tests/ecma_2/instanceof/instanceof-002.js +++ /dev/null @@ -1,84 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is JavaScript Engine testing utilities. - * - * The Initial Developer of the Original Code is - * Netscape Communication Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -gTestfile = 'instanceof-002.js'; - -/** - File Name: - ECMA Section: - Description: Call Objects - - - - Author: christine@netscape.com - Date: 12 november 1997 -*/ -var SECTION = ""; -var VERSION = "ECMA_2"; -var TITLE = "The Call Constructor"; - -startTest(); -writeHeaderToLog( SECTION + " "+ TITLE); - -var b = new Boolean(); - -new TestCase( SECTION, - "var b = new Boolean(); b instanceof Boolean", - true, - b instanceof Boolean ); - -new TestCase( SECTION, - "b instanceof Object", - true, - b instanceof Object ); - -new TestCase( SECTION, - "b instanceof Array", - false, - b instanceof Array ); - -new TestCase( SECTION, - "true instanceof Boolean", - false, - true instanceof Boolean ); - -new TestCase( SECTION, - "Boolean instanceof Object", - true, - Boolean instanceof Object ); -test(); - diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/instanceof/instanceof-003.js b/tests/auto/declarative/parserstress/tests/ecma_2/instanceof/instanceof-003.js deleted file mode 100644 index 6c1279f865..0000000000 --- a/tests/auto/declarative/parserstress/tests/ecma_2/instanceof/instanceof-003.js +++ /dev/null @@ -1,98 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is JavaScript Engine testing utilities. - * - * The Initial Developer of the Original Code is - * Netscape Communication Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -gTestfile = 'instanceof-003.js'; - -/** - File Name: instanceof-003.js - ECMA Section: - Description: http://bugzilla.mozilla.org/show_bug.cgi?id=7635 - - js> function Foo() {} - js> theproto = {}; - [object Object] - js> Foo.prototype = theproto - [object Object] - js> theproto instanceof Foo - true - - I think this should be 'false' - - - Author: christine@netscape.com - Date: 12 november 1997 - - Modified to conform to ECMA3 - https://bugzilla.mozilla.org/show_bug.cgi?id=281606 -*/ -var SECTION = "instanceof-003"; -var VERSION = "ECMA_2"; -var TITLE = "instanceof operator"; -var BUGNUMBER ="7635"; - -startTest(); - -function Foo() {}; -theproto = {}; -Foo.prototype = theproto; - -AddTestCase( - "function Foo() = {}; theproto = {}; Foo.prototype = theproto; " + - "theproto instanceof Foo", - false, - theproto instanceof Foo ); - - -var o = {}; - -// https://bugzilla.mozilla.org/show_bug.cgi?id=281606 -try -{ - AddTestCase( - "o = {}; o instanceof o", - "error", - o instanceof o ); -} -catch(e) -{ - AddTestCase( - "o = {}; o instanceof o", - "error", - "error" ); -} - -test(); diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/instanceof/regress-7635.js b/tests/auto/declarative/parserstress/tests/ecma_2/instanceof/regress-7635.js deleted file mode 100644 index c643920b04..0000000000 --- a/tests/auto/declarative/parserstress/tests/ecma_2/instanceof/regress-7635.js +++ /dev/null @@ -1,88 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is mozilla.org code. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -gTestfile = 'regress-7635.js'; - -/** - * File Name: regress-7635.js - * Reference: http://bugzilla.mozilla.org/show_bug.cgi?id=7635 - * Description: instanceof tweaks - * Author: - */ - -var SECTION = "instanceof"; // provide a document reference (ie, ECMA section) -var VERSION = "ECMA_2"; // Version of JavaScript or ECMA -var TITLE = "Regression test for Bugzilla #7635"; // Provide ECMA section title or a description -var BUGNUMBER = "7635"; // Provide URL to bugsplat or bugzilla report - -startTest(); // leave this alone - -/* - * Calls to AddTestCase here. AddTestCase is a function that is defined - * in shell.js and takes three arguments: - * - a string representation of what is being tested - * - the expected result - * - the actual result - * - * For example, a test might look like this: - * - * var zip = /[\d]{5}$/; - * - * AddTestCase( - * "zip = /[\d]{5}$/; \"PO Box 12345 Boston, MA 02134\".match(zip)", // description of the test - * "02134", // expected result - * "PO Box 12345 Boston, MA 02134".match(zip) ); // actual result - * - */ - -function Foo() {} -theproto = {}; -Foo.prototype = theproto - theproto instanceof Foo - - - AddTestCase( "function Foo() {}; theproto = {}; Foo.prototype = theproto; theproto instanceof Foo", - false, - theproto instanceof Foo ); - -var f = new Function(); - -AddTestCase( "var f = new Function(); f instanceof f", false, f instanceof f ); - - -test(); // leave this alone. this executes the test cases and -// displays results. diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/instanceof/shell.js b/tests/auto/declarative/parserstress/tests/ecma_2/instanceof/shell.js deleted file mode 100644 index b390356c38..0000000000 --- a/tests/auto/declarative/parserstress/tests/ecma_2/instanceof/shell.js +++ /dev/null @@ -1 +0,0 @@ -gTestsubsuite = 'instanceof'; diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/jsref.js b/tests/auto/declarative/parserstress/tests/ecma_2/jsref.js deleted file mode 100644 index e5a3ddfeed..0000000000 --- a/tests/auto/declarative/parserstress/tests/ecma_2/jsref.js +++ /dev/null @@ -1,591 +0,0 @@ -var completed = false; -var testcases; -var tc = 0; - -SECTION = ""; -VERSION = ""; -BUGNUMBER = ""; -EXCLUDE = ""; -BUGNUMBER = ""; - - -TZ_DIFF = -8; - -var TT = ""; -var TT_ = ""; -var BR = ""; -var NBSP = " "; -var CR = "\n"; -var FONT = ""; -var FONT_ = ""; -var FONT_RED = ""; -var FONT_GREEN = ""; -var B = ""; -var B_ = "" -var H2 = ""; -var H2_ = ""; -var HR = ""; -var DEBUG = false; - - -var PASSED = " PASSED!" -var FAILED = " FAILED! expected: "; -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); -} - -function TestCase( n, d, e, a ) { - this.name = n; - this.description = d; - this.expect = e; - this.actual = a; - this.passed = true; - this.reason = ""; - this.bugnumber = BUGNUMBER; - - this.passed = getTestCaseResult( this.expect, this.actual ); - if ( DEBUG ) { - print( "added " + this.description ); - } -} -function startTest() { - // JavaScript 1.3 is supposed to be compliant ecma version 1.0 - if ( VERSION == "ECMA_1" ) { - version ( "130" ); - } - if ( VERSION == "JS_13" ) { - version ( "130" ); - } - if ( VERSION == "JS_12" ) { - version ( "120" ); - } - if ( VERSION == "JS_11" ) { - version ( "110" ); - } - // for ecma version 2.0, we will leave the javascript version to - // the default ( for now ). - writeHeaderToLog( SECTION + " "+ TITLE); - testcases = new Array(); - tc = 0; - -} -function getTestCaseResult( expect, actual ) { - // because ( NaN == NaN ) always returns false, need to do - // a special compare to see if we got the right result. - if ( actual != actual ) { - if ( typeof actual == "object" ) { - actual = "NaN object"; - } else { - actual = "NaN number"; - } - } - if ( expect != expect ) { - if ( typeof expect == "object" ) { - expect = "NaN object"; - } else { - expect = "NaN number"; - } - } - - var passed = ( expect == actual ) ? true : false; - - // if both objects are numbers - // need to replace w/ IEEE standard for rounding - if ( !passed - && typeof(actual) == "number" - && typeof(expect) == "number" - ) { - if ( Math.abs(actual-expect) < 0.0000001 ) { - passed = true; - } - } - - // verify type is the same - if ( typeof(expect) != typeof(actual) ) { - passed = false; - } - - return passed; -} -function writeTestCaseResult( expect, actual, string ) { - var passed = getTestCaseResult( expect, actual ); - writeFormattedResult( expect, actual, string, passed ); - return passed; -} -function writeFormattedResult( expect, actual, string, passed ) { - var s = TT + string ; - - for ( k = 0; - k < (60 - string.length >= 0 ? 60 - string.length : 5) ; - k++ ) { - } - - s += B ; - s += ( passed ) ? FONT_GREEN + NBSP + PASSED : FONT_RED + NBSP + FAILED + expect + TT_ ; - - print( s + FONT_ + B_ + TT_ ); - - return passed; -} - -function writeHeaderToLog( string ) { - print( H2 + string + H2_ ); -} -function stopTest() -{ - var sizeTag = "<#TEST CASES SIZE>"; - var doneTag = "<#TEST CASES DONE>"; - var beginTag = "<#TEST CASE "; - var endTag = ">"; - - print(sizeTag); - print(testcases.length); - for (tc = 0; tc < testcases.length; tc++) - { - print(beginTag + 'PASSED' + endTag); - print(testcases[tc].passed); - print(beginTag + 'NAME' + endTag); - print(testcases[tc].name); - print(beginTag + 'EXPECTED' + endTag); - print(testcases[tc].expect); - print(beginTag + 'ACTUAL' + endTag); - print(testcases[tc].actual); - print(beginTag + 'DESCRIPTION' + endTag); - print(testcases[tc].description); - print(beginTag + 'REASON' + endTag); - print(( testcases[tc].passed ) ? "" : "wrong value "); - print(beginTag + 'BUGNUMBER' + endTag); - print( BUGNUMBER ); - } - print(doneTag); - print( HR ); - gc(); -} -function getFailedCases() { - for ( var i = 0; i < testcases.length; i++ ) { - if ( ! testcases[i].passed ) { - print( testcases[i].description +" = " +testcases[i].actual +" expected: "+ testcases[i].expect ); - } - } -} -function err( msg, page, line ) { - testcases[tc].actual = "error"; - testcases[tc].reason = msg; - writeTestCaseResult( testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ testcases[tc].actual + - ": " + testcases[tc].reason ); - stopTest(); - return true; -} - -/** - * Type Conversion functions used by Type Conversion - * - */ - - - - /* - * Date functions used by tests in Date suite - * - */ -var msPerDay = 86400000; -var HoursPerDay = 24; -var MinutesPerHour = 60; -var SecondsPerMinute = 60; -var msPerSecond = 1000; -var msPerMinute = 60000; // msPerSecond * SecondsPerMinute -var msPerHour = 3600000; // msPerMinute * MinutesPerHour - -var TIME_1970 = 0; -var TIME_2000 = 946684800000; -var TIME_1900 = -2208988800000; - -function Day( t ) { - return ( Math.floor(t/msPerDay ) ); -} -function DaysInYear( y ) { - if ( y % 4 != 0 ) { - return 365; - } - if ( (y % 4 == 0) && (y % 100 != 0) ) { - return 366; - } - if ( (y % 100 == 0) && (y % 400 != 0) ) { - return 365; - } - if ( (y % 400 == 0) ){ - return 366; - } else { - return "ERROR: DaysInYear(" + y + ") case not covered"; - } -} -function TimeInYear( y ) { - return ( DaysInYear(y) * msPerDay ); -} -function DayNumber( t ) { - return ( Math.floor( t / msPerDay ) ); -} -function TimeWithinDay( t ) { - if ( t < 0 ) { - return ( (t % msPerDay) + msPerDay ); - } else { - return ( t % msPerDay ); - } -} -function YearNumber( t ) { -} -function TimeFromYear( y ) { - return ( msPerDay * DayFromYear(y) ); -} -function DayFromYear( y ) { - return ( 365*(y-1970) + - Math.floor((y-1969)/4) - - Math.floor((y-1901)/100) + - Math.floor((y-1601)/400) ); -} -function InLeapYear( t ) { - if ( DaysInYear(YearFromTime(t)) == 365 ) { - return 0; - } - if ( DaysInYear(YearFromTime(t)) == 366 ) { - return 1; - } else { - return "ERROR: InLeapYear("+t+") case not covered"; - } -} -function YearFromTime( t ) { - t = Number( t ); - var sign = ( t < 0 ) ? -1 : 1; - var year = ( sign < 0 ) ? 1969 : 1970; - for ( var timeToTimeZero = t; ; ) { - // subtract the current year's time from the time that's left. - timeToTimeZero -= sign * TimeInYear(year) - - // if there's less than the current year's worth of time left, then break. - if ( sign < 0 ) { - if ( sign * timeToTimeZero <= 0 ) { - break; - } else { - year += sign; - } - } else { - if ( sign * timeToTimeZero < 0 ) { - break; - } else { - year += sign; - } - } - } - return ( year ); -} -function MonthFromTime( t ) { - // i know i could use switch but i'd rather not until it's part of ECMA - var day = DayWithinYear( t ); - var leap = InLeapYear(t); - - if ( (0 <= day) && (day < 31) ) { - return 0; - } - if ( (31 <= day) && (day < (59+leap)) ) { - return 1; - } - if ( ((59+leap) <= day) && (day < (90+leap)) ) { - return 2; - } - if ( ((90+leap) <= day) && (day < (120+leap)) ) { - return 3; - } - if ( ((120+leap) <= day) && (day < (151+leap)) ) { - return 4; - } - if ( ((151+leap) <= day) && (day < (181+leap)) ) { - return 5; - } - if ( ((181+leap) <= day) && (day < (212+leap)) ) { - return 6; - } - if ( ((212+leap) <= day) && (day < (243+leap)) ) { - return 7; - } - if ( ((243+leap) <= day) && (day < (273+leap)) ) { - return 8; - } - if ( ((273+leap) <= day) && (day < (304+leap)) ) { - return 9; - } - if ( ((304+leap) <= day) && (day < (334+leap)) ) { - return 10; - } - if ( ((334+leap) <= day) && (day < (365+leap)) ) { - return 11; - } else { - return "ERROR: MonthFromTime("+t+") not known"; - } -} -function DayWithinYear( t ) { - return( Day(t) - DayFromYear(YearFromTime(t))); -} -function DateFromTime( t ) { - var day = DayWithinYear(t); - var month = MonthFromTime(t); - - if ( month == 0 ) { - return ( day + 1 ); - } - if ( month == 1 ) { - return ( day - 30 ); - } - if ( month == 2 ) { - return ( day - 58 - InLeapYear(t) ); - } - if ( month == 3 ) { - return ( day - 89 - InLeapYear(t)); - } - if ( month == 4 ) { - return ( day - 119 - InLeapYear(t)); - } - if ( month == 5 ) { - return ( day - 150- InLeapYear(t)); - } - if ( month == 6 ) { - return ( day - 180- InLeapYear(t)); - } - if ( month == 7 ) { - return ( day - 211- InLeapYear(t)); - } - if ( month == 8 ) { - return ( day - 242- InLeapYear(t)); - } - if ( month == 9 ) { - return ( day - 272- InLeapYear(t)); - } - if ( month == 10 ) { - return ( day - 303- InLeapYear(t)); - } - if ( month == 11 ) { - return ( day - 333- InLeapYear(t)); - } - - return ("ERROR: DateFromTime("+t+") not known" ); -} -function WeekDay( t ) { - var weekday = (Day(t)+4) % 7; - return( weekday < 0 ? 7 + weekday : weekday ); -} - -// missing daylight savins time adjustment - -function HourFromTime( t ) { - var h = Math.floor( t / msPerHour ) % HoursPerDay; - return ( (h<0) ? HoursPerDay + h : h ); -} -function MinFromTime( t ) { - var min = Math.floor( t / msPerMinute ) % MinutesPerHour; - return( ( min < 0 ) ? MinutesPerHour + min : min ); -} -function SecFromTime( t ) { - var sec = Math.floor( t / msPerSecond ) % SecondsPerMinute; - return ( (sec < 0 ) ? SecondsPerMinute + sec : sec ); -} -function msFromTime( t ) { - var ms = t % msPerSecond; - return ( (ms < 0 ) ? msPerSecond + ms : ms ); -} -function LocalTZA() { - return ( TZ_DIFF * msPerHour ); -} -function UTC( t ) { - return ( t - LocalTZA() - DaylightSavingTA(t - LocalTZA()) ); -} -function DaylightSavingTA( t ) { - t = t - LocalTZA(); - - var dst_start = GetFirstSundayInApril(t) + 2*msPerHour; - var dst_end = GetLastSundayInOctober(t)+ 2*msPerHour; - - if ( t >= dst_start && t < dst_end ) { - return msPerHour; - } else { - return 0; - } - - // Daylight Savings Time starts on the first Sunday in April at 2:00AM in - // PST. Other time zones will need to override this function. - - print( new Date( UTC(dst_start + LocalTZA())) ); - - return UTC(dst_start + LocalTZA()); -} -function GetFirstSundayInApril( t ) { - var year = YearFromTime(t); - var leap = InLeapYear(t); - - var april = TimeFromYear(year) + TimeInMonth(0, leap) + TimeInMonth(1,leap) + - TimeInMonth(2,leap); - - for ( var first_sunday = april; WeekDay(first_sunday) > 0; - first_sunday += msPerDay ) - { - ; - } - - return first_sunday; -} -function GetLastSundayInOctober( t ) { - var year = YearFromTime(t); - var leap = InLeapYear(t); - - for ( var oct = TimeFromYear(year), m = 0; m < 9; m++ ) { - oct += TimeInMonth(m, leap); - } - for ( var last_sunday = oct + 30*msPerDay; WeekDay(last_sunday) > 0; - last_sunday -= msPerDay ) - { - ; - } - return last_sunday; -} -function LocalTime( t ) { - return ( t + LocalTZA() + DaylightSavingTA(t) ); -} -function MakeTime( hour, min, sec, ms ) { - if ( isNaN( hour ) || isNaN( min ) || isNaN( sec ) || isNaN( ms ) ) { - return Number.NaN; - } - - hour = ToInteger(hour); - min = ToInteger( min); - sec = ToInteger( sec); - ms = ToInteger( ms ); - - return( (hour*msPerHour) + (min*msPerMinute) + - (sec*msPerSecond) + ms ); -} -function MakeDay( year, month, date ) { - if ( isNaN(year) || isNaN(month) || isNaN(date) ) { - return Number.NaN; - } - year = ToInteger(year); - month = ToInteger(month); - date = ToInteger(date ); - - var sign = ( year < 1970 ) ? -1 : 1; - var t = ( year < 1970 ) ? 1 : 0; - var y = ( year < 1970 ) ? 1969 : 1970; - - var result5 = year + Math.floor( month/12 ); - var result6 = month % 12; - - if ( year < 1970 ) { - for ( y = 1969; y >= year; y += sign ) { - t += sign * TimeInYear(y); - } - } else { - for ( y = 1970 ; y < year; y += sign ) { - t += sign * TimeInYear(y); - } - } - - var leap = InLeapYear( t ); - - for ( var m = 0; m < month; m++ ) { - t += TimeInMonth( m, leap ); - } - - if ( YearFromTime(t) != result5 ) { - return Number.NaN; - } - if ( MonthFromTime(t) != result6 ) { - return Number.NaN; - } - if ( DateFromTime(t) != 1 ) { - return Number.NaN; - } - - return ( (Day(t)) + date - 1 ); -} -function TimeInMonth( month, leap ) { - // september april june november - // jan 0 feb 1 mar 2 apr 3 may 4 june 5 jul 6 - // aug 7 sep 8 oct 9 nov 10 dec 11 - - if ( month == 3 || month == 5 || month == 8 || month == 10 ) { - return ( 30*msPerDay ); - } - - // all the rest - if ( month == 0 || month == 2 || month == 4 || month == 6 || - month == 7 || month == 9 || month == 11 ) { - return ( 31*msPerDay ); - } - - // save february - return ( (leap == 0) ? 28*msPerDay : 29*msPerDay ); -} -function MakeDate( day, time ) { - if ( day == Number.POSITIVE_INFINITY || - day == Number.NEGATIVE_INFINITY || - day == Number.NaN ) { - return Number.NaN; - } - if ( time == Number.POSITIVE_INFINITY || - time == Number.POSITIVE_INFINITY || - day == Number.NaN) { - return Number.NaN; - } - return ( day * msPerDay ) + time; -} -function TimeClip( t ) { - if ( isNaN( t ) ) { - return ( Number.NaN ); - } - if ( Math.abs( t ) > 8.64e15 ) { - return ( Number.NaN ); - } - - return ( ToInteger( t ) ); -} -function ToInteger( t ) { - t = Number( t ); - - if ( isNaN( t ) ){ - return ( Number.NaN ); - } - if ( t == 0 || t == -0 || - t == Number.POSITIVE_INFINITY || t == Number.NEGATIVE_INFINITY ) { - return 0; - } - - var sign = ( t < 0 ) ? -1 : 1; - - return ( sign * Math.floor( Math.abs( t ) ) ); -} -function Enumerate ( o ) { - var properties = new Array(); - for ( p in o ) { - properties[ properties.length ] = new Array( p, o[p] ); - } - return properties; -} -function AddTestCase( description, expect, actual ) { - testcases[tc++] = new TestCase( SECTION, description, expect, actual ); -} -function getFailedCases() { - for ( var i = 0; i < testcases.length; i++ ) { - if ( ! testcases[i].passed ) { - print( testcases[i].description +" = " +testcases[i].actual +" expected: "+ testcases[i].expect ); - } - } -} diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/shell.js b/tests/auto/declarative/parserstress/tests/ecma_2/shell.js deleted file mode 100644 index a83dd68ec2..0000000000 --- a/tests/auto/declarative/parserstress/tests/ecma_2/shell.js +++ /dev/null @@ -1,51 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is mozilla.org code. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -gTestsuite = 'ecma_2'; - -var TZ_DIFF = getTimeZoneDiff(); - -/* - * Originally, the test suite used a hard-coded value TZ_DIFF = -8. - * But that was only valid for testers in the Pacific Standard Time Zone! - * We calculate the proper number dynamically for any tester. We just - * have to be careful to use a date not subject to Daylight Savings Time... - */ -function getTimeZoneDiff() -{ - return -((new Date(2000, 1, 1)).getTimezoneOffset())/60; -} diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/template.js b/tests/auto/declarative/parserstress/tests/ecma_2/template.js deleted file mode 100644 index 83397ba7b3..0000000000 --- a/tests/auto/declarative/parserstress/tests/ecma_2/template.js +++ /dev/null @@ -1,57 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is JavaScript Engine testing utilities. - * - * The Initial Developer of the Original Code is - * Mozilla Foundation. - * Portions created by the Initial Developer are Copyright (C) 2008 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -gTestfile = 'template.js'; - -/** - * File Name: template.js - * Reference: ** replace with bugzilla URL or document reference ** - * Description: ** replace with description of test ** - * Author: ** replace with your e-mail address ** - */ - -var SECTION = ""; // if ECMA test, provide section number -var VERSION = "ECMA_2"; // Version of JavaScript or ECMA -var TITLE = ""; // Provide ECMA section title or description -var BUGNUMBER = ""; // Provide URL to bugsplat or bugzilla report - -startTest(); // leave this alone - - -/* Calls to AddTestCase here */ - -test(); // leave this alone diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/Array/15.4.4.11-01.js b/tests/auto/declarative/parserstress/tests/ecma_3/Array/15.4.4.11-01.js deleted file mode 100755 index 0436b8c1e0..0000000000 --- a/tests/auto/declarative/parserstress/tests/ecma_3/Array/15.4.4.11-01.js +++ /dev/null @@ -1,61 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is JavaScript Engine testing utilities. - * - * The Initial Developer of the Original Code is - * Mozilla Foundation. - * Portions created by the Initial Developer are Copyright (C) 2005 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): Igor Bukanov - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -var gTestfile = '15.4.4.11-01.js'; -//----------------------------------------------------------------------------- -var BUGNUMBER = 312138; -var summary = 'Array.sort should not eat exceptions'; -var actual = ''; -var expect = ''; - -printBugNumber(BUGNUMBER); -printStatus (summary); - -expect = "e=1 N=1"; - -var N = 0; -var array = [4,3,2,1]; - -try { - array.sort(function() { - throw ++N; - }); -} catch (e) { - actual = ("e="+e+" N="+N); -} - -reportCompare(expect, actual, summary); diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/Array/15.4.4.3-1.js b/tests/auto/declarative/parserstress/tests/ecma_3/Array/15.4.4.3-1.js deleted file mode 100644 index e3de6fb116..0000000000 --- a/tests/auto/declarative/parserstress/tests/ecma_3/Array/15.4.4.3-1.js +++ /dev/null @@ -1,88 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is mozilla.org code. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * pschwartau@netscape.com - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -/* - * Date: 12 Mar 2001 - * - * - * SUMMARY: Testing Array.prototype.toLocaleString() - * See http://bugzilla.mozilla.org/show_bug.cgi?id=56883 - * See http://bugzilla.mozilla.org/show_bug.cgi?id=58031 - * - * By ECMA3 15.4.4.3, myArray.toLocaleString() means that toLocaleString() - * should be applied to each element of the array, and the results should be - * concatenated with an implementation-specific delimiter. For example: - * - * myArray[0].toLocaleString() + ',' + myArray[1].toLocaleString() + etc. - * - * In this testcase toLocaleString is a user-defined property of each - * array element; therefore it is the function that should be - * invoked. This function increments a global variable. Therefore the - * end value of this variable should be myArray.length. - */ -//----------------------------------------------------------------------------- -var gTestfile = '15.4.4.3-1.js'; -var BUGNUMBER = 56883; -var summary = 'Testing Array.prototype.toLocaleString() -'; -var actual = ''; -var expect = ''; -var n = 0; -var obj = {toLocaleString: function() {n++}}; -var myArray = [obj, obj, obj]; - - -myArray.toLocaleString(); -actual = n; -expect = 3; // (see explanation above) - - -//----------------------------------------------------------------------------- -test(); -//----------------------------------------------------------------------------- - - -function test() -{ - enterFunc ('test'); - printBugNumber(BUGNUMBER); - printStatus (summary); - - reportCompare(expect, actual, summary); - - exitFunc ('test'); -} diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/Array/15.4.4.4-001.js b/tests/auto/declarative/parserstress/tests/ecma_3/Array/15.4.4.4-001.js deleted file mode 100644 index b87233ea97..0000000000 --- a/tests/auto/declarative/parserstress/tests/ecma_3/Array/15.4.4.4-001.js +++ /dev/null @@ -1,153 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is JavaScript Engine testing utilities. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corp. - * Portions created by the Initial Developer are Copyright (C) 2002 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * george@vanous.com, igor@icesoft.no, pschwartau@netscape.com - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -/* - * - * Date: 19 September 2002 - * SUMMARY: Testing Array.prototype.concat() - * See http://bugzilla.mozilla.org/show_bug.cgi?id=169795 - * - */ -//----------------------------------------------------------------------------- -var gTestfile = '15.4.4.4-001.js'; -var UBound = 0; -var BUGNUMBER = 169795; -var summary = 'Testing Array.prototype.concat()'; -var status = ''; -var statusitems = []; -var actual = ''; -var actualvalues = []; -var expect= ''; -var expectedvalues = []; -var x; - - -status = inSection(1); -x = "Hello"; -actual = [].concat(x).toString(); -expect = x.toString(); -addThis(); - -status = inSection(2); -x = 999; -actual = [].concat(x).toString(); -expect = x.toString(); -addThis(); - -status = inSection(3); -x = /Hello/g; -actual = [].concat(x).toString(); -expect = x.toString(); -addThis(); - -status = inSection(4); -x = new Error("Hello"); -actual = [].concat(x).toString(); -expect = x.toString(); -addThis(); - -status = inSection(5); -x = function() {return "Hello";}; -actual = [].concat(x).toString(); -expect = x.toString(); -addThis(); - -status = inSection(6); -x = [function() {return "Hello";}]; -actual = [].concat(x).toString(); -expect = x.toString(); -addThis(); - -status = inSection(7); -x = [1,2,3].concat([4,5,6]); -actual = [].concat(x).toString(); -expect = x.toString(); -addThis(); - -status = inSection(8); -x = eval('this'); -actual = [].concat(x).toString(); -expect = x.toString(); -addThis(); - -/* - * The next two sections are by igor@icesoft.no; see - * http://bugzilla.mozilla.org/show_bug.cgi?id=169795#c3 - */ -status = inSection(9); -x={length:0}; -actual = [].concat(x).toString(); -expect = x.toString(); -addThis(); - -status = inSection(10); -x={length:2, 0:0, 1:1}; -actual = [].concat(x).toString(); -expect = x.toString(); -addThis(); - - - -//----------------------------------------------------------------------------- -test(); -//----------------------------------------------------------------------------- - - - -function addThis() -{ - statusitems[UBound] = status; - actualvalues[UBound] = actual; - expectedvalues[UBound] = expect; - UBound++; -} - - -function test() -{ - enterFunc('test'); - printBugNumber(BUGNUMBER); - printStatus(summary); - - for (var i=0; i - * See http://bugzilla.mozilla.org/show_bug.cgi?id=101488 - * - * Without the "new" keyword, assigning arr.length = Number(n) worked. - * But with it, Rhino was giving an error "Inappropriate array length" - * and SpiderMonkey was exiting without giving any error or return value - - * - * Comments on the Rhino code by igor@icesoft.no: - * - * jsSet_length requires that the new length value should be an instance - * of Number. But according to Ecma 15.4.5.1, item 12-13, an error should - * be thrown only if ToUint32(length_value) != ToNumber(length_value) - */ -//----------------------------------------------------------------------------- -var gTestfile = 'regress-101488.js'; -var UBound = 0; -var BUGNUMBER = 101488; -var summary = 'Try assigning arr.length = new Number(n)'; -var status = ''; -var statusitems = []; -var actual = ''; -var actualvalues = []; -var expect= ''; -var expectedvalues = []; -var arr = []; - - -status = inSection(1); -arr = Array(); -tryThis('arr.length = new Number(1);'); -actual = arr.length; -expect = 1; -addThis(); - -status = inSection(2); -arr = Array(5); -tryThis('arr.length = new Number(1);'); -actual = arr.length; -expect = 1; -addThis(); - -status = inSection(3); -arr = Array(); -tryThis('arr.length = new Number(17);'); -actual = arr.length; -expect = 17; -addThis(); - -status = inSection(4); -arr = Array(5); -tryThis('arr.length = new Number(17);'); -actual = arr.length; -expect = 17; -addThis(); - - -/* - * Also try the above with the "new" keyword before Array(). - * Array() and new Array() should be equivalent, by ECMA 15.4.1.1 - */ -status = inSection(5); -arr = new Array(); -tryThis('arr.length = new Number(1);'); -actual = arr.length; -expect = 1; -addThis(); - -status = inSection(6); -arr = new Array(5); -tryThis('arr.length = new Number(1);'); -actual = arr.length; -expect = 1; -addThis(); - -arr = new Array(); -tryThis('arr.length = new Number(17);'); -actual = arr.length; -expect = 17; -addThis(); - -status = inSection(7); -arr = new Array(5); -tryThis('arr.length = new Number(17);'); -actual = arr.length; -expect = 17; -addThis(); - - - -//----------------------------------------------------------------------------- -test(); -//----------------------------------------------------------------------------- - - - -function tryThis(s) -{ - try - { - eval(s); - } - catch(e) - { - // keep going - } -} - - -function addThis() -{ - statusitems[UBound] = status; - actualvalues[UBound] = actual; - expectedvalues[UBound] = expect; - UBound++; -} - - -function test() -{ - enterFunc ('test'); - printBugNumber(BUGNUMBER); - printStatus (summary); - - for (var i=0; i= dst_start && t < dst_end ) - return msPerHour; - - return 0; -} - -function GetFirstSundayInMonth( t, m ) { - var year = YearFromTime(t); - var leap = InLeapYear(t); - -// month m 0..11 -// april == 3 -// march == 2 - - // set time to first day of month m - var time = TimeFromYear(year); - for (var i = 0; i < m; ++i) - { - time += TimeInMonth(i, leap); - } - - for ( var first_sunday = time; WeekDay(first_sunday) > 0; - first_sunday += msPerDay ) - { - ; - } - - return first_sunday; -} - -function GetLastSundayInMonth( t, m ) { - var year = YearFromTime(t); - var leap = InLeapYear(t); - -// month m 0..11 -// april == 3 -// march == 2 - - // first day of following month - var time = TimeFromYear(year); - for (var i = 0; i <= m; ++i) - { - time += TimeInMonth(i, leap); - } - // prev day == last day of month - time -= msPerDay; - - for ( var last_sunday = time; WeekDay(last_sunday) > 0; - last_sunday -= msPerDay ) - { - ; - } - return last_sunday; -} - -/* - 15.9.1.9 Daylight Saving Time Adjustment - - The implementation of ECMAScript should not try to determine whether - the exact time was subject to daylight saving time, but just whether - daylight saving time would have been in effect if the current - daylight saving time algorithm had been used at the time. This avoids - complications such as taking into account the years that the locale - observed daylight saving time year round. -*/ - -/* - US DST algorithm - - Before 2007, DST starts first Sunday in April at 2 AM and ends last - Sunday in October at 2 AM - - Starting in 2007, DST starts second Sunday in March at 2 AM and ends - first Sunday in November at 2 AM - - Note that different operating systems behave differently. - - Fully patched Windows XP uses the 2007 algorithm for all dates while - fully patched Fedora Core 6 and RHEL 4 Linux use the algorithm in - effect at the time. - - Since pre-2007 DST is a subset of 2007 DST rules, this only affects - tests that occur in the period Mar-Apr and Oct-Nov where the two - algorithms do not agree. - -*/ - -function GetDSTStart( t ) -{ - return (GetFirstSundayInMonth(t, 2) + 7*msPerDay + 2*msPerHour - LocalTZA()); -} - -function GetDSTEnd( t ) -{ - return (GetFirstSundayInMonth(t, 10) + 2*msPerHour - LocalTZA()); -} - -function GetOldDSTStart( t ) -{ - return (GetFirstSundayInMonth(t, 3) + 2*msPerHour - LocalTZA()); -} - -function GetOldDSTEnd( t ) -{ - return (GetLastSundayInMonth(t, 9) + 2*msPerHour - LocalTZA()); -} - -function LocalTime( t ) { - return ( t + LocalTZA() + DaylightSavingTA(t) ); -} -function MakeTime( hour, min, sec, ms ) { - if ( isNaN( hour ) || isNaN( min ) || isNaN( sec ) || isNaN( ms ) ) { - return Number.NaN; - } - - hour = ToInteger(hour); - min = ToInteger( min); - sec = ToInteger( sec); - ms = ToInteger( ms ); - - return( (hour*msPerHour) + (min*msPerMinute) + - (sec*msPerSecond) + ms ); -} -function MakeDay( year, month, date ) { - if ( isNaN(year) || isNaN(month) || isNaN(date) ) { - return Number.NaN; - } - year = ToInteger(year); - month = ToInteger(month); - date = ToInteger(date ); - - var sign = ( year < 1970 ) ? -1 : 1; - var t = ( year < 1970 ) ? 1 : 0; - var y = ( year < 1970 ) ? 1969 : 1970; - - var result5 = year + Math.floor( month/12 ); - var result6 = month % 12; - - if ( year < 1970 ) { - for ( y = 1969; y >= year; y += sign ) { - t += sign * TimeInYear(y); - } - } else { - for ( y = 1970 ; y < year; y += sign ) { - t += sign * TimeInYear(y); - } - } - - var leap = InLeapYear( t ); - - for ( var m = 0; m < month; m++ ) { - t += TimeInMonth( m, leap ); - } - - if ( YearFromTime(t) != result5 ) { - return Number.NaN; - } - if ( MonthFromTime(t) != result6 ) { - return Number.NaN; - } - if ( DateFromTime(t) != 1 ) { - return Number.NaN; - } - - return ( (Day(t)) + date - 1 ); -} -function TimeInMonth( month, leap ) { - // september april june november - // jan 0 feb 1 mar 2 apr 3 may 4 june 5 jul 6 - // aug 7 sep 8 oct 9 nov 10 dec 11 - - if ( month == 3 || month == 5 || month == 8 || month == 10 ) { - return ( 30*msPerDay ); - } - - // all the rest - if ( month == 0 || month == 2 || month == 4 || month == 6 || - month == 7 || month == 9 || month == 11 ) { - return ( 31*msPerDay ); - } - - // save february - return ( (leap == 0) ? 28*msPerDay : 29*msPerDay ); -} -function MakeDate( day, time ) { - if ( day == Number.POSITIVE_INFINITY || - day == Number.NEGATIVE_INFINITY ) { - return Number.NaN; - } - if ( time == Number.POSITIVE_INFINITY || - time == Number.NEGATIVE_INFINITY ) { - return Number.NaN; - } - return ( day * msPerDay ) + time; -} -function TimeClip( t ) { - if ( isNaN( t ) ) { - return ( Number.NaN ); - } - if ( Math.abs( t ) > 8.64e15 ) { - return ( Number.NaN ); - } - - return ( ToInteger( t ) ); -} -function ToInteger( t ) { - t = Number( t ); - - if ( isNaN( t ) ){ - return ( Number.NaN ); - } - if ( t == 0 || t == -0 || - t == Number.POSITIVE_INFINITY || t == Number.NEGATIVE_INFINITY ) { - return 0; - } - - var sign = ( t < 0 ) ? -1 : 1; - - return ( sign * Math.floor( Math.abs( t ) ) ); -} -function Enumerate ( o ) { - var p; - for ( p in o ) { - print( p +": " + o[p] ); - } -} - diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/Exceptions/15.11.1.1.js b/tests/auto/declarative/parserstress/tests/ecma_3/Exceptions/15.11.1.1.js deleted file mode 100644 index 6910d76f15..0000000000 --- a/tests/auto/declarative/parserstress/tests/ecma_3/Exceptions/15.11.1.1.js +++ /dev/null @@ -1,137 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is JavaScript Engine testing utilities. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corp. - * Portions created by the Initial Developer are Copyright (C) 2002 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * joerg.schaible@gmx.de - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -/* - * - * Date: 27 Nov 2002 - * SUMMARY: Ensuring normal function call of Error (ECMA-262 Ed.3 15.11.1.1). - */ -//----------------------------------------------------------------------------- -var gTestfile = '15.11.1.1.js'; -var UBound = 0; -var BUGNUMBER = ''; -var summary = 'Ensuring normal function call of Error (ECMA-262 Ed.3 15.11.1.1)'; -var status = ''; -var statusitems = []; -var actual = ''; -var actualvalues = []; -var expect= ''; -var expectedvalues = []; -var EMPTY_STRING = ''; -var EXPECTED_FORMAT = 0; - - -function otherScope(msg) -{ - return Error(msg); -} - - -status = inSection(1); -var err1 = Error('msg1'); -actual = examineThis(err1, 'msg1'); -expect = EXPECTED_FORMAT; -addThis(); - -status = inSection(2); -var err2 = otherScope('msg2'); -actual = examineThis(err2, 'msg2'); -expect = EXPECTED_FORMAT; -addThis(); - -status = inSection(3); -var err3 = otherScope(); -actual = examineThis(err3, EMPTY_STRING); -expect = EXPECTED_FORMAT; -addThis(); - -status = inSection(4); -var err4 = eval("Error('msg4')"); -actual = examineThis(err4, 'msg4'); -expect = EXPECTED_FORMAT; -addThis(); - - - -//----------------------------------------------------------------------------- -test(); -//----------------------------------------------------------------------------- - - - -/* - * Searches err.toString() for err.name + ':' + err.message, - * with possible whitespace on each side of the colon sign. - * - * We allow for no colon in case err.message was not provided by the user. - * In such a case, SpiderMonkey and Rhino currently set err.message = '', - * as allowed for by ECMA 15.11.4.3. This makes |pattern| work in this case. - * - * If this is ever changed to a non-empty string, e.g. 'undefined', - * you may have to modify |pattern| to take that into account - - * - */ -function examineThis(err, msg) -{ - var pattern = err.name + '\\s*:?\\s*' + msg; - return err.toString().search(RegExp(pattern)); -} - - -function addThis() -{ - statusitems[UBound] = status; - actualvalues[UBound] = actual; - expectedvalues[UBound] = expect; - UBound++; -} - - -function test() -{ - enterFunc ('test'); - printBugNumber(BUGNUMBER); - printStatus (summary); - - for (var i = 0; i < UBound; i++) - { - reportCompare(expectedvalues[i], actualvalues[i], statusitems[i]); - } - - exitFunc ('test'); -} diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/Exceptions/15.11.4.4-1.js b/tests/auto/declarative/parserstress/tests/ecma_3/Exceptions/15.11.4.4-1.js deleted file mode 100644 index 00f9503041..0000000000 --- a/tests/auto/declarative/parserstress/tests/ecma_3/Exceptions/15.11.4.4-1.js +++ /dev/null @@ -1,174 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is JavaScript Engine testing utilities. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corp. - * Portions created by the Initial Developer are Copyright (C) 2001 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * d-russo@ti.com, pschwartau@netscape.com, joerg.schaible@gmx.de - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -/* - * - * Date: 22 Jan 2002 - * SUMMARY: Testing Error.prototype.toString() - * - * Revised: 25 Nov 2002 - * See http://bugzilla.mozilla.org/show_bug.cgi?id=181909 - * - * Note that ECMA-262 3rd Edition Final, Section 15.11.4.4 states that - * Error.prototype.toString() returns an implementation-dependent string. - * Therefore any testcase on this property is somewhat arbitrary. - * - * However, d-russo@ti.com pointed out that Rhino was returning this: - * - * js> err = new Error() - * undefined: undefined - * - * js> err = new Error("msg") - * undefined: msg - * - * - * We expect Rhino to return what SpiderMonkey currently does: - * - * js> err = new Error() - * Error - * - * js> err = new Error("msg") - * Error: msg - * - * - * i.e. we expect err.toString() === err.name if err.message is not defined; - * otherwise, we expect err.toString() === err.name + ': ' + err.message. - * - * See also ECMA 15.11.4.2, 15.11.4.3 - */ -//----------------------------------------------------------------------------- -var gTestfile = '15.11.4.4-1.js'; -var UBound = 0; -var BUGNUMBER = '(none)'; -var summary = 'Testing Error.prototype.toString()'; -var status = ''; -var statusitems = []; -var actual = ''; -var actualvalues = []; -var expect= ''; -var expectedvalues = []; -var EMPTY_STRING = ''; -var EXPECTED_FORMAT = 0; - - -status = inSection(1); -var err1 = new Error('msg1'); -actual = examineThis(err1, 'msg1'); -expect = EXPECTED_FORMAT; -addThis(); - -status = inSection(2); -var err2 = new Error(err1); -actual = examineThis(err2, err1); -expect = EXPECTED_FORMAT; -addThis(); - -status = inSection(3); -var err3 = new Error(); -actual = examineThis(err3, EMPTY_STRING); -expect = EXPECTED_FORMAT; -addThis(); - -status = inSection(4); -var err4 = new Error(EMPTY_STRING); -actual = examineThis(err4, EMPTY_STRING); -expect = EXPECTED_FORMAT; -addThis(); - -// now generate a run-time error - -status = inSection(5); -try -{ - eval('1=2'); -} -catch(err5) -{ - actual = examineThis(err5, '.*'); -} -expect = EXPECTED_FORMAT; -addThis(); - - - -//----------------------------------------------------------------------------- -test(); -//----------------------------------------------------------------------------- - - - -/* - * Searches err.toString() for err.name + ':' + err.message, - * with possible whitespace on each side of the colon sign. - * - * We allow for no colon in case err.message was not provided by the user. - * In such a case, SpiderMonkey and Rhino currently set err.message = '', - * as allowed for by ECMA 15.11.4.3. This makes |pattern| work in this case. - * - * If this is ever changed to a non-empty string, e.g. 'undefined', - * you may have to modify |pattern| to take that into account - - * - */ -function examineThis(err, msg) -{ - var pattern = err.name + '\\s*:?\\s*' + msg; - return err.toString().search(RegExp(pattern)); -} - - -function addThis() -{ - statusitems[UBound] = status; - actualvalues[UBound] = actual; - expectedvalues[UBound] = expect; - UBound++; -} - - -function test() -{ - enterFunc ('test'); - printBugNumber(BUGNUMBER); - printStatus (summary); - - for (var i = 0; i < UBound; i++) - { - reportCompare(expectedvalues[i], actualvalues[i], statusitems[i]); - } - - exitFunc ('test'); -} diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/Exceptions/15.11.7.6-001.js b/tests/auto/declarative/parserstress/tests/ecma_3/Exceptions/15.11.7.6-001.js deleted file mode 100644 index c6248cc7c1..0000000000 --- a/tests/auto/declarative/parserstress/tests/ecma_3/Exceptions/15.11.7.6-001.js +++ /dev/null @@ -1,130 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is JavaScript Engine testing utilities. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corp. - * Portions created by the Initial Developer are Copyright (C) 2003 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * igor@fastmail.fm, pschwartau@netscape.com - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -/* - * - * Date: 14 April 2003 - * SUMMARY: Prototype of predefined error objects should be DontEnum - * See http://bugzilla.mozilla.org/show_bug.cgi?id=201989 - * - */ -//----------------------------------------------------------------------------- -var gTestfile = '15.11.7.6-001.js'; -var UBound = 0; -var BUGNUMBER = 201989; -var summary = 'Prototype of predefined error objects should be DontEnum'; -var status = ''; -var statusitems = []; -var actual = ''; -var actualvalues = []; -var expect= ''; -var expectedvalues = []; - - -/* - * Tests that |F.prototype| is not enumerable in |F| - */ -function testDontEnum(F) -{ - var proto = F.prototype; - - for (var prop in F) - { - if (F[prop] === proto) - return false; - } - return true; -} - - -var list = [ - "Error", - "ConversionError", - "EvalError", - "RangeError", - "ReferenceError", - "SyntaxError", - "TypeError", - "URIError" - ]; - - -for (i in list) -{ - var F = this[list[i]]; - - // Test for |F|; e.g. Rhino defines |ConversionError| while SM does not. - if (F) - { - status = 'Testing DontEnum attribute of |' + list[i] + '.prototype|'; - actual = testDontEnum(F); - expect = true; - addThis(); - } -} - - - -//----------------------------------------------------------------------------- -test(); -//----------------------------------------------------------------------------- - - - -function addThis() -{ - statusitems[UBound] = status; - actualvalues[UBound] = actual; - expectedvalues[UBound] = expect; - UBound++; -} - - -function test() -{ - enterFunc('test'); - printBugNumber(BUGNUMBER); - printStatus(summary); - - for (var i=0; i -1); - expect = true; - addThis(); -} - - - -//----------------------------------------------------------------------------- -test(); -//----------------------------------------------------------------------------- - - -function addThis() -{ - statusitems[UBound] = status; - actualvalues[UBound] = isReferenceError(actual); - expectedvalues[UBound] = isReferenceError(expect); - UBound++; -} - - -function test() -{ - enterFunc ('test'); - printBugNumber(BUGNUMBER); - printStatus (summary); - - for (var i = 0; i < UBound; i++) - { - reportCompare(expectedvalues[i], actualvalues[i], statusitems[i]); - } - - exitFunc ('test'); -} - - -// converts a Boolean result into a textual result - -function isReferenceError(bResult) -{ - return bResult? ERR_REF_YES : ERR_REF_NO; -} diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/Exceptions/browser.js b/tests/auto/declarative/parserstress/tests/ecma_3/Exceptions/browser.js deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/Exceptions/regress-181654.js b/tests/auto/declarative/parserstress/tests/ecma_3/Exceptions/regress-181654.js deleted file mode 100644 index 3fe80f15ac..0000000000 --- a/tests/auto/declarative/parserstress/tests/ecma_3/Exceptions/regress-181654.js +++ /dev/null @@ -1,155 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is JavaScript Engine testing utilities. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corp. - * Portions created by the Initial Developer are Copyright (C) 2002 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * joerg.schaible@gmx.de - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -/* - * - * Date: 23 Nov 2002 - * SUMMARY: Calling toString for an object derived from the Error class - * results in an TypeError (Rhino only) - * See http://bugzilla.mozilla.org/show_bug.cgi?id=181654 - */ -//----------------------------------------------------------------------------- -var gTestfile = 'regress-181654.js'; -var UBound = 0; -var BUGNUMBER = '181654'; -var summary = 'Calling toString for an object derived from the Error class should be possible.'; -var status = ''; -var statusitems = []; -var actual = ''; -var actualvalues = []; -var expect= ''; -var expectedvalues = []; -var EMPTY_STRING = ''; -var EXPECTED_FORMAT = 0; - - -// derive MyError from Error -function MyError( msg ) -{ - this.message = msg; -} -MyError.prototype = new Error(); -MyError.prototype.name = "MyError"; - - -status = inSection(1); -var err1 = new MyError('msg1'); -actual = examineThis(err1, 'msg1'); -expect = EXPECTED_FORMAT; -addThis(); - -status = inSection(2); -var err2 = new MyError(String(err1)); -actual = examineThis(err2, err1); -expect = EXPECTED_FORMAT; -addThis(); - -status = inSection(3); -var err3 = new MyError(); -actual = examineThis(err3, EMPTY_STRING); -expect = EXPECTED_FORMAT; -addThis(); - -status = inSection(4); -var err4 = new MyError(EMPTY_STRING); -actual = examineThis(err4, EMPTY_STRING); -expect = EXPECTED_FORMAT; -addThis(); - -// now generate an error - -status = inSection(5); -try -{ - throw new MyError("thrown"); -} -catch(err5) -{ - actual = examineThis(err5, "thrown"); -} -expect = EXPECTED_FORMAT; -addThis(); - - - -//----------------------------------------------------------------------------- -test(); -//----------------------------------------------------------------------------- - - - -/* - * Searches err.toString() for err.name + ':' + err.message, - * with possible whitespace on each side of the colon sign. - * - * We allow for no colon in case err.message was not provided by the user. - * In such a case, SpiderMonkey and Rhino currently set err.message = '', - * as allowed for by ECMA 15.11.4.3. This makes |pattern| work in this case. - * - * If this is ever changed to a non-empty string, e.g. 'undefined', - * you may have to modify |pattern| to take that into account - - * - */ -function examineThis(err, msg) -{ - var pattern = err.name + '\\s*:?\\s*' + msg; - return err.toString().search(RegExp(pattern)); -} - - -function addThis() -{ - statusitems[UBound] = status; - actualvalues[UBound] = actual; - expectedvalues[UBound] = expect; - UBound++; -} - - -function test() -{ - enterFunc ('test'); - printBugNumber(BUGNUMBER); - printStatus (summary); - - for (var i = 0; i < UBound; i++) - { - reportCompare(expectedvalues[i], actualvalues[i], statusitems[i]); - } - - exitFunc ('test'); -} diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/Exceptions/regress-181914.js b/tests/auto/declarative/parserstress/tests/ecma_3/Exceptions/regress-181914.js deleted file mode 100644 index f4d1f224c8..0000000000 --- a/tests/auto/declarative/parserstress/tests/ecma_3/Exceptions/regress-181914.js +++ /dev/null @@ -1,194 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is JavaScript Engine testing utilities. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corp. - * Portions created by the Initial Developer are Copyright (C) 2002 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * joerg.schaible@gmx.de, pschwartau@netscape.com - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -/* - * - * Date: 25 Nov 2002 - * SUMMARY: Calling a user-defined superconstructor - * See http://bugzilla.mozilla.org/show_bug.cgi?id=181914, esp. Comment 10. - * - */ -//----------------------------------------------------------------------------- -var gTestfile = 'regress-181914.js'; -var UBound = 0; -var BUGNUMBER = '181914'; -var summary = 'Calling a user-defined superconstructor'; -var status = ''; -var statusitems = []; -var actual = ''; -var actualvalues = []; -var expect= ''; -var expectedvalues = []; -var EMPTY_STRING = ''; -var EXPECTED_FORMAT = 0; - - -// make a user-defined version of the Error constructor -function _Error(msg) -{ - this.message = msg; -} -_Error.prototype = new Error(); -_Error.prototype.name = '_Error'; - - -// derive MyApplyError from _Error -function MyApplyError(msg) -{ - if(this instanceof MyApplyError) - _Error.apply(this, arguments); - else - return new MyApplyError(msg); -} -MyApplyError.prototype = new _Error(); -MyApplyError.prototype.name = "MyApplyError"; - - -// derive MyCallError from _Error -function MyCallError(msg) -{ - if(this instanceof MyCallError) - _Error.call(this, msg); - else - return new MyCallError(msg); -} -MyCallError.prototype = new _Error(); -MyCallError.prototype.name = "MyCallError"; - - -function otherScope(msg) -{ - return MyApplyError(msg); -} - - -status = inSection(1); -var err1 = new MyApplyError('msg1'); -actual = examineThis(err1, 'msg1'); -expect = EXPECTED_FORMAT; -addThis(); - -status = inSection(2); -var err2 = new MyCallError('msg2'); -actual = examineThis(err2, 'msg2'); -expect = EXPECTED_FORMAT; -addThis(); - -status = inSection(3); -var err3 = MyApplyError('msg3'); -actual = examineThis(err3, 'msg3'); -expect = EXPECTED_FORMAT; -addThis(); - -status = inSection(4); -var err4 = MyCallError('msg4'); -actual = examineThis(err4, 'msg4'); -expect = EXPECTED_FORMAT; -addThis(); - -status = inSection(5); -var err5 = otherScope('msg5'); -actual = examineThis(err5, 'msg5'); -expect = EXPECTED_FORMAT; -addThis(); - -status = inSection(6); -var err6 = otherScope(); -actual = examineThis(err6, EMPTY_STRING); -expect = EXPECTED_FORMAT; -addThis(); - -status = inSection(7); -var err7 = eval("MyApplyError('msg7')"); -actual = examineThis(err7, 'msg7'); -expect = EXPECTED_FORMAT; -addThis(); - -status = inSection(8); -var err8; -try -{ - throw MyApplyError('msg8'); -} -catch(e) -{ - if(e instanceof Error) - err8 = e; -} -actual = examineThis(err8, 'msg8'); -expect = EXPECTED_FORMAT; -addThis(); - - - -//----------------------------------------------------------------------------- -test(); -//----------------------------------------------------------------------------- - - - -// Searches |err.toString()| for |err.name + ':' + err.message| -function examineThis(err, msg) -{ - var pattern = err.name + '\\s*:?\\s*' + msg; - return err.toString().search(RegExp(pattern)); -} - - -function addThis() -{ - statusitems[UBound] = status; - actualvalues[UBound] = actual; - expectedvalues[UBound] = expect; - UBound++; -} - - -function test() -{ - enterFunc ('test'); - printBugNumber(BUGNUMBER); - printStatus (summary); - - for (var i = 0; i < UBound; i++) - { - reportCompare(expectedvalues[i], actualvalues[i], statusitems[i]); - } - - exitFunc ('test'); -} diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/Exceptions/regress-58946.js b/tests/auto/declarative/parserstress/tests/ecma_3/Exceptions/regress-58946.js deleted file mode 100644 index 97212c88a0..0000000000 --- a/tests/auto/declarative/parserstress/tests/ecma_3/Exceptions/regress-58946.js +++ /dev/null @@ -1,71 +0,0 @@ -/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- - * - * ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is mozilla.org code. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * pschwartau@netscape.com - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -var gTestfile = 'regress-58946.js'; -//------------------------------------------------------------------------------------------------- -var BUGNUMBER = '58946'; -var stat = 'Testing a return statement inside a catch statement inside a function'; - -test(); - -function test() { - enterFunc ("test"); - printBugNumber(BUGNUMBER); - printStatus (stat); - - expect = 'PASS'; - - function f() - { - try - { - throw 'PASS'; - } - catch(e) - { - return e; - } - } - - actual = f(); - - reportCompare(expect, actual, stat); - - exitFunc ("test"); -} diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/Exceptions/regress-95101.js b/tests/auto/declarative/parserstress/tests/ecma_3/Exceptions/regress-95101.js deleted file mode 100644 index b7ef074350..0000000000 --- a/tests/auto/declarative/parserstress/tests/ecma_3/Exceptions/regress-95101.js +++ /dev/null @@ -1,118 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is mozilla.org code. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * pschwartau@netscape.com - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -/* - * Date: 13 August 2001 - * - * SUMMARY: Invoking an undefined function should produce a ReferenceError - * See http://bugzilla.mozilla.org/show_bug.cgi?id=95101 - */ -//----------------------------------------------------------------------------- -var gTestfile = 'regress-95101.js'; -var UBound = 0; -var BUGNUMBER = 95101; -var summary = 'Invoking an undefined function should produce a ReferenceError'; -var msgERR_REF_YES = 'ReferenceError'; -var msgERR_REF_NO = 'did NOT generate a ReferenceError'; -var status = ''; -var statusitems = []; -var actual = ''; -var actualvalues = []; -var expect= ''; -var expectedvalues = []; - - -try -{ - xxxyyyzzz(); -} -catch (e) -{ - status = 'Section 1 of test'; - actual = e instanceof ReferenceError; - expect = true; - addThis(); - - - /* - * This test is more literal, and may one day be invalid. - * Searching for literal string "ReferenceError" in e.toString() - */ - status = 'Section 2 of test'; - var match = e.toString().search(/ReferenceError/); - actual = (match > -1); - expect = true; - addThis(); -} - - - -//----------------------------------------------------------------------------- -test(); -//----------------------------------------------------------------------------- - - -function addThis() -{ - statusitems[UBound] = status; - actualvalues[UBound] = isReferenceError(actual); - expectedvalues[UBound] = isReferenceError(expect); - UBound++; -} - - -function test() -{ - enterFunc ('test'); - printBugNumber(BUGNUMBER); - printStatus (summary); - - for (var i = 0; i < UBound; i++) - { - reportCompare(expectedvalues[i], actualvalues[i], statusitems[i]); - } - - exitFunc ('test'); -} - - -// converts a Boolean result into a textual result - -function isReferenceError(bResult) -{ - return bResult? msgERR_REF_YES : msgERR_REF_NO; -} diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/Exceptions/shell.js b/tests/auto/declarative/parserstress/tests/ecma_3/Exceptions/shell.js deleted file mode 100644 index 6c671f1eea..0000000000 --- a/tests/auto/declarative/parserstress/tests/ecma_3/Exceptions/shell.js +++ /dev/null @@ -1 +0,0 @@ -gTestsubsuite = 'Exceptions'; diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/ExecutionContexts/10.1.3-1.js b/tests/auto/declarative/parserstress/tests/ecma_3/ExecutionContexts/10.1.3-1.js deleted file mode 100644 index 1e7e0254bf..0000000000 --- a/tests/auto/declarative/parserstress/tests/ecma_3/ExecutionContexts/10.1.3-1.js +++ /dev/null @@ -1,201 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is JavaScript Engine testing utilities. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corp. - * Portions created by the Initial Developer are Copyright (C) 2002 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * pschwartau@netscape.com - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -/* - * - * Date: 11 Feb 2002 - * SUMMARY: Testing functions having duplicate formal parameter names - * - * Note: given function f(x,x,x,x) {return x;}; f(1,2,3,4) should return 4. - * See ECMA-262 3rd Edition Final Section 10.1.3: Variable Instantiation - * - * Also see http://bugzilla.mozilla.org/show_bug.cgi?id=124900 - */ -//----------------------------------------------------------------------------- -var gTestfile = '10.1.3-1.js'; -var UBound = 0; -var BUGNUMBER = 124900; -var summary = 'Testing functions having duplicate formal parameter names'; -var status = ''; -var statusitems = []; -var actual = ''; -var actualvalues = []; -var expect= ''; -var expectedvalues = []; - - -function f1(x,x) -{ - return x; -} -status = inSection(1); -actual = f1(1,2); -expect = 2; -addThis(); - - -function f2(x,x,x) -{ - return x*x*x; -} -status = inSection(2); -actual = f2(1,2,3); -expect = 27; -addThis(); - - -function f3(x,x,x,x) -{ - return 'a' + x + 'b' + x + 'c' + x ; -} -status = inSection(3); -actual = f3(1,2,3,4); -expect = 'a4b4c4'; -addThis(); - - -/* - * If the value of the last duplicate parameter is not provided by - * the function caller, the value of this parameter is undefined - */ -function f4(x,a,b,x,z) -{ - return x; -} -status = inSection(4); -actual = f4(1,2); -expect = undefined; -addThis(); - - -/* - * f.toString() should preserve any duplicate formal parameter names that exist - */ -function f5(x,x,x,x) -{ -} -status = inSection(5); -actual = f5.toString().match(/\((.*)\)/)[1]; -actual = actual.replace(/\s/g, ''); // for definiteness, remove any white space -expect = 'x,x,x,x'; -addThis(); - - -function f6(x,x,x,x) -{ - var ret = []; - - for (var i=0; i> p); - - reportCompare(expectval, actualval, summary + ': value'); - reportCompare(expect, actual, summary + ': order'); - - exitFunc ('test'); -} diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/Expressions/11.7.3-01.js b/tests/auto/declarative/parserstress/tests/ecma_3/Expressions/11.7.3-01.js deleted file mode 100755 index d5af3b86d4..0000000000 --- a/tests/auto/declarative/parserstress/tests/ecma_3/Expressions/11.7.3-01.js +++ /dev/null @@ -1,76 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is JavaScript Engine testing utilities. - * - * The Initial Developer of the Original Code is - * Mozilla Foundation. - * Portions created by the Initial Developer are Copyright (C) 2007 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): Brendan Eich - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -var gTestfile = '11.7.3-01.js'; -//----------------------------------------------------------------------------- -var BUGNUMBER = 396969; -var summary = '11.7.3 - >>> should evaluate operands in order'; -var actual = ''; -var expect = ''; - - -//----------------------------------------------------------------------------- -test(); -//----------------------------------------------------------------------------- - -function test() -{ - enterFunc ('test'); - printBugNumber(BUGNUMBER); - printStatus (summary); - - expect = 'o.valueOf, p.valueOf'; - var actualval; - var expectval = 10; - - var o = { - valueOf: (function (){ actual += 'o.valueOf'; return this.value}), - value:42 - }; - - var p = { - valueOf: (function (){ actual += ', p.valueOf'; return this.value}), - value:2 - }; - - actualval = (o >>> p); - - reportCompare(expectval, actualval, summary + ': value'); - reportCompare(expect, actual, summary + ': order'); - - exitFunc ('test'); -} diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/Expressions/11.9.6-1.js b/tests/auto/declarative/parserstress/tests/ecma_3/Expressions/11.9.6-1.js deleted file mode 100644 index 1e8f59e400..0000000000 --- a/tests/auto/declarative/parserstress/tests/ecma_3/Expressions/11.9.6-1.js +++ /dev/null @@ -1,213 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is JavaScript Engine testing utilities. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corp. - * Portions created by the Initial Developer are Copyright (C) 2002 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * pschwartau@netscape.com - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -/* - * - * Date: 20 Feb 2002 - * SUMMARY: Testing the comparison |undefined === null| - * See http://bugzilla.mozilla.org/show_bug.cgi?id=126722 - * - */ -//----------------------------------------------------------------------------- -var gTestfile = '11.9.6-1.js'; -var UBound = 0; -var BUGNUMBER = 126722; -var summary = 'Testing the comparison |undefined === null|'; -var status = ''; -var statusitems = []; -var actual = ''; -var actualvalues = []; -var expect= ''; -var expectedvalues = []; - - -status = inSection(1); -if (undefined === null) - actual = true; -else - actual = false; -expect = false; -addThis(); - - - -status = inSection(2); -switch(true) -{ -case (undefined === null) : - actual = true; - break; - -default: - actual = false; -} -expect = false; -addThis(); - - - -status = inSection(3); -function f3(x) -{ - var res = false; - - switch(true) - { - case (x === null) : - res = true; - break; - - default: - // do nothing - } - - return res; -} - -actual = f3(undefined); -expect = false; -addThis(); - - - -status = inSection(4); -function f4(arr) -{ - var elt = ''; - var res = false; - - for (i=0; i function f\u02B1 () {} - * - * js> f\u02B1.toSource(); - * function f¦() {} - * - * js> f\u02B1.toSource().toSource(); - * (new String("function f\xB1() {}")) - * - * - * See how the high-byte information (the 02) has been lost? - * The same thing was happening with the toString() method: - * - * js> f\u02B1.toString(); - * - * function f¦() { - * } - * - * js> f\u02B1.toString().toSource(); - * (new String("\nfunction f\xB1() {\n}\n")) - * - */ -//----------------------------------------------------------------------------- -var gTestfile = 'regress-58274.js'; -var UBound = 0; -var BUGNUMBER = 58274; -var summary = 'Testing functions with double-byte names'; -var ERR = 'UNEXPECTED ERROR! \n'; -var ERR_MALFORMED_NAME = ERR + 'Could not find function name in: \n\n'; -var status = ''; -var statusitems = []; -var actual = ''; -var actualvalues = []; -var expect= ''; -var expectedvalues = []; -var sEval; -var sName; - - -sEval = "function f\u02B2() {return 42;}"; -eval(sEval); -sName = getFunctionName(f\u02B2); - -// Test function call - -status = inSection(1); -actual = f\u02B2(); -expect = 42; -addThis(); - -// Test both characters of function name - -status = inSection(2); -actual = sName[0]; -expect = sEval[9]; -addThis(); - -status = inSection(3); -actual = sName[1]; -expect = sEval[10]; -addThis(); - - - -sEval = "function f\u02B2\u0AAA () {return 84;}"; -eval(sEval); -sName = getFunctionName(f\u02B2\u0AAA); - -// Test function call - -status = inSection(4); -actual = f\u02B2\u0AAA(); -expect = 84; -addThis(); - -// Test all three characters of function name - -status = inSection(5); -actual = sName[0]; -expect = sEval[9]; -addThis(); - -status = inSection(6); -actual = sName[1]; -expect = sEval[10]; -addThis(); - -status = inSection(7); -actual = sName[2]; -expect = sEval[11]; -addThis(); - - - - -//----------------------------------------------------------------------------- -test(); -//----------------------------------------------------------------------------- - - - -/* - * Goal: test that f.toString() contains the proper function name. - * - * Note, however, f.toString() is implementation-independent. For example, - * it may begin with '\nfunction' instead of 'function'. Therefore we use - * a regexp to make sure we extract the name properly. - * - * Here we assume that f has been defined by means of a function statement, - * and not a function expression (where it wouldn't have to have a name). - * - * Rhino uses a Unicode representation for f.toString(); whereas - * SpiderMonkey uses an ASCII representation, putting escape sequences - * for non-ASCII characters. For example, if a function is called f\u02B1, - * then in Rhino the toString() method will present a 2-character Unicode - * string for its name, whereas SpiderMonkey will present a 7-character - * ASCII string for its name: the string literal 'f\u02B1'. - * - * So we force the lexer to condense the string before using it. - * This will give uniform results in Rhino and SpiderMonkey. - */ -function getFunctionName(f) -{ - var s = condenseStr(f.toString()); - var re = /\s*function\s+(\S+)\s*\(/; - var arr = s.match(re); - - if (!(arr && arr[1])) - return ERR_MALFORMED_NAME + s; - return arr[1]; -} - - -/* - * This function is the opposite of functions like escape(), which take - * Unicode characters and return escape sequences for them. Here, we force - * the lexer to turn escape sequences back into single characters. - * - * Note we can't simply do |eval(str)|, since in practice |str| will be an - * identifier somewhere in the program (e.g. a function name); thus |eval(str)| - * would return the object that the identifier represents: not what we want. - * - * So we surround |str| lexicographically with quotes to force the lexer to - * evaluate it as a string. Have to strip out any linefeeds first, however - - */ -function condenseStr(str) -{ - /* - * You won't be able to do the next step if |str| has - * any carriage returns or linefeeds in it. For example: - * - * js> eval("'" + '\nHello' + "'"); - * 1: SyntaxError: unterminated string literal: - * 1: ' - * 1: ^ - * - * So replace them with the empty string - - */ - str = str.replace(/[\r\n]/g, '') - return eval("'" + str + "'"); -} - - -function addThis() -{ - statusitems[UBound] = status; - actualvalues[UBound] = actual; - expectedvalues[UBound] = expect; - UBound++; -} - - -function test() -{ - enterFunc('test'); - printBugNumber(BUGNUMBER); - printStatus(summary); - - for (var i=0; i - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -var gTestfile = '8.6.1-01.js'; -//----------------------------------------------------------------------------- - -var BUGNUMBER = 315436; -var summary = 'In strict mode, setting a read-only property should generate a warning'; - -printBugNumber(BUGNUMBER); -printStatus (summary); - -enterFunc (String (BUGNUMBER)); - -// should throw an error in strict mode -var actual = ''; -var expect = 's.length is read-only'; -var status = summary + ': Throw if STRICT and WERROR is enabled'; - -if (!options().match(/strict/)) -{ - options('strict'); -} -if (!options().match(/werror/)) -{ - options('werror'); -} - -try -{ - var s = new String ('abc'); - s.length = 0; -} -catch (e) -{ - actual = e.message; -} - -reportCompare(expect, actual, status); - -// should not throw an error if in strict mode and WERROR is false - -actual = 'did not throw'; -expect = 'did not throw'; -var status = summary + ': Do not throw if STRICT is enabled and WERROR is disabled'; - -// toggle werror off -options('werror'); - -try -{ - s.length = 0; -} -catch (e) -{ - actual = e.message; -} - -reportCompare(expect, actual, status); - -// should not throw an error if not in strict mode - -actual = 'did not throw'; -expect = 'did not throw'; -var status = summary + ': Do not throw if not in strict mode'; - -// toggle strict off -options('strict'); - -try -{ - s.length = 0; -} -catch (e) -{ - actual = e.message; -} - -reportCompare(expect, actual, status); diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/Object/8.6.2.6-001.js b/tests/auto/declarative/parserstress/tests/ecma_3/Object/8.6.2.6-001.js deleted file mode 100644 index 8fe2b23f4a..0000000000 --- a/tests/auto/declarative/parserstress/tests/ecma_3/Object/8.6.2.6-001.js +++ /dev/null @@ -1,113 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is JavaScript Engine testing utilities. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corp. - * Portions created by the Initial Developer are Copyright (C) 2002 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * pschwartau@netscape.com - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -/* - * - * Date: 09 September 2002 - * SUMMARY: Test for TypeError on invalid default string value of object - * See ECMA reference at http://bugzilla.mozilla.org/show_bug.cgi?id=167325 - * - */ -//----------------------------------------------------------------------------- -var gTestfile = '8.6.2.6-001.js'; -var UBound = 0; -var BUGNUMBER = 167325; -var summary = "Test for TypeError on invalid default string value of object"; -var TEST_PASSED = 'TypeError'; -var TEST_FAILED = 'Generated an error, but NOT a TypeError!'; -var TEST_FAILED_BADLY = 'Did not generate ANY error!!!'; -var status = ''; -var statusitems = []; -var actual = ''; -var actualvalues = []; -var expect= ''; -var expectedvalues = []; - - -status = inSection(1); -expect = TEST_PASSED; -actual = TEST_FAILED_BADLY; -/* - * This should generate a TypeError. See ECMA reference - * at http://bugzilla.mozilla.org/show_bug.cgi?id=167325 - */ -try -{ - var obj = {toString: function() {return new Object();}} - obj == 'abc'; -} -catch(e) -{ - if (e instanceof TypeError) - actual = TEST_PASSED; - else - actual = TEST_FAILED; -} -addThis(); - - - - -//----------------------------------------------------------------------------- -test(); -//----------------------------------------------------------------------------- - - - -function addThis() -{ - statusitems[UBound] = status; - actualvalues[UBound] = actual; - expectedvalues[UBound] = expect; - UBound++; -} - - -function test() -{ - enterFunc('test'); - printBugNumber(BUGNUMBER); - printStatus(summary); - - for (var i=0; i>'}, - {section: '11.7.3', operator: '>>>'}, - {section: '11.8.1', operator: '<'}, - {section: '11.8.2', operator: '>'}, - {section: '11.8.3', operator: '<='}, - {section: '11.8.4', operator: '>='}, - {section: '11.10', operator: '&'}, - {section: '11.10', operator: '^'}, - {section: '11.10', operator: '|'}, - {section: '11.13.2', operator: '*='}, - {section: '11.13.2', operator: '/='}, - {section: '11.13.2', operator: '%='}, - {section: '11.13.2', operator: '+='}, - {section: '11.13.2', operator: '<<='}, - {section: '11.13.2', operator: '>>='}, - {section: '11.13.2', operator: '>>>='}, - {section: '11.13.2', operator: '&='}, - {section: '11.13.2', operator: '^='}, - {section: '11.13.2', operator: '|='}, - ]; - -//----------------------------------------------------------------------------- -test(); -//----------------------------------------------------------------------------- - -function test() -{ - enterFunc ('test'); - printBugNumber(BUGNUMBER); - printStatus (summary); - - for (var i = 0; i < operators.length; i++) - { - expect = 'left valueOf, left toString, right valueOf, right toString, '; - actual = ''; - - var left = makeObject('left'); - var right = makeObject('right'); - - eval('left ' + operators[i].operator + ' right'); - - reportCompare(expect, actual, summary + ': ' + operators[i].section + ' ' + operators[i].operator); - } - - exitFunc ('test'); -} diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/Operators/shell.js b/tests/auto/declarative/parserstress/tests/ecma_3/Operators/shell.js deleted file mode 100644 index 910515cfe4..0000000000 --- a/tests/auto/declarative/parserstress/tests/ecma_3/Operators/shell.js +++ /dev/null @@ -1 +0,0 @@ -gTestsubsuite = 'Operators'; diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/README b/tests/auto/declarative/parserstress/tests/ecma_3/README deleted file mode 100755 index eebd421c2e..0000000000 --- a/tests/auto/declarative/parserstress/tests/ecma_3/README +++ /dev/null @@ -1 +0,0 @@ -ECMA 262 Edition 3 diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/15.10.2-1.js b/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/15.10.2-1.js deleted file mode 100644 index 9439a2ccd6..0000000000 --- a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/15.10.2-1.js +++ /dev/null @@ -1,181 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is JavaScript Engine testing utilities. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corp. - * Portions created by the Initial Developer are Copyright (C) 2002 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * rogerl@netscape.com, pschwartau@netscape.com - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -/* - * - * Date: 09 July 2002 - * SUMMARY: RegExp conformance test - * - * These gTestcases are derived from the examples in the ECMA-262 Ed.3 spec - * scattered through section 15.10.2. - * - */ -//----------------------------------------------------------------------------- -var gTestfile = '15.10.2-1.js'; -var i = 0; -var BUGNUMBER = '(none)'; -var summary = 'RegExp conformance test'; -var status = ''; -var statusmessages = new Array(); -var pattern = ''; -var patterns = new Array(); -var string = ''; -var strings = new Array(); -var actualmatch = ''; -var actualmatches = new Array(); -var expectedmatch = ''; -var expectedmatches = new Array(); - - -status = inSection(1); -pattern = /a|ab/; -string = 'abc'; -actualmatch = string.match(pattern); -expectedmatch = Array('a'); -addThis(); - -status = inSection(2); -pattern = /((a)|(ab))((c)|(bc))/; -string = 'abc'; -actualmatch = string.match(pattern); -expectedmatch = Array('abc', 'a', 'a', undefined, 'bc', undefined, 'bc'); -addThis(); - -status = inSection(3); -pattern = /a[a-z]{2,4}/; -string = 'abcdefghi'; -actualmatch = string.match(pattern); -expectedmatch = Array('abcde'); -addThis(); - -status = inSection(4); -pattern = /a[a-z]{2,4}?/; -string = 'abcdefghi'; -actualmatch = string.match(pattern); -expectedmatch = Array('abc'); -addThis(); - -status = inSection(5); -pattern = /(aa|aabaac|ba|b|c)*/; -string = 'aabaac'; -actualmatch = string.match(pattern); -expectedmatch = Array('aaba', 'ba'); -addThis(); - -status = inSection(6); -pattern = /^(a+)\1*,\1+$/; -string = 'aaaaaaaaaa,aaaaaaaaaaaaaaa'; -actualmatch = string.match(pattern); -expectedmatch = Array('aaaaaaaaaa,aaaaaaaaaaaaaaa', 'aaaaa'); -addThis(); - -status = inSection(7); -pattern = /(z)((a+)?(b+)?(c))*/; -string = 'zaacbbbcac'; -actualmatch = string.match(pattern); -expectedmatch = Array('zaacbbbcac', 'z', 'ac', 'a', undefined, 'c'); -addThis(); - -status = inSection(8); -pattern = /(a*)*/; -string = 'b'; -actualmatch = string.match(pattern); -expectedmatch = Array('', undefined); -addThis(); - -status = inSection(9); -pattern = /(a*)b\1+/; -string = 'baaaac'; -actualmatch = string.match(pattern); -expectedmatch = Array('b', ''); -addThis(); - -status = inSection(10); -pattern = /(?=(a+))/; -string = 'baaabac'; -actualmatch = string.match(pattern); -expectedmatch = Array('', 'aaa'); -addThis(); - -status = inSection(11); -pattern = /(?=(a+))a*b\1/; -string = 'baaabac'; -actualmatch = string.match(pattern); -expectedmatch = Array('aba', 'a'); -addThis(); - -status = inSection(12); -pattern = /(.*?)a(?!(a+)b\2c)\2(.*)/; -string = 'baaabaac'; -actualmatch = string.match(pattern); -expectedmatch = Array('baaabaac', 'ba', undefined, 'abaac'); -addThis(); - -status = inSection(13); -pattern = /(?=(a+))/; -string = 'baaabac'; -actualmatch = string.match(pattern); -expectedmatch = Array('', 'aaa'); -addThis(); - - - -//------------------------------------------------------------------------------------------------- -test(); -//------------------------------------------------------------------------------------------------- - - -function addThis() -{ - statusmessages[i] = status; - patterns[i] = pattern; - strings[i] = string; - actualmatches[i] = actualmatch; - expectedmatches[i] = expectedmatch; - i++; -} - - -function test() -{ - enterFunc ('test'); - printBugNumber(BUGNUMBER); - printStatus (summary); - testRegExp(statusmessages, patterns, strings, actualmatches, expectedmatches); - exitFunc ('test'); -} diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/15.10.2.12.js b/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/15.10.2.12.js deleted file mode 100755 index d68b86c2ed..0000000000 --- a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/15.10.2.12.js +++ /dev/null @@ -1,63 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is JavaScript Engine testing utilities. - * - * The Initial Developer of the Original Code is - * Mozilla Foundation. - * Portions created by the Initial Developer are Copyright (C) 2007 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): Igor Tandetnik - * Martin Honnen - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -var gTestfile = '15.10.2.12.js'; -//----------------------------------------------------------------------------- -var BUGNUMBER = 378738; -var summary = '15.10.2.12 - CharacterClassEscape \d'; -var actual = ''; -var expect = ''; - - -//----------------------------------------------------------------------------- -test(); -//----------------------------------------------------------------------------- - -function test() -{ - enterFunc ('test'); - printBugNumber(BUGNUMBER); - printStatus (summary); - - expect = false; - actual = /\d/.test("\uFF11"); - - reportCompare(expect, actual, summary); - - exitFunc ('test'); -} diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/15.10.3.1-1.js b/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/15.10.3.1-1.js deleted file mode 100644 index 7286cea297..0000000000 --- a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/15.10.3.1-1.js +++ /dev/null @@ -1,136 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is mozilla.org code. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * pschwartau@netscape.com - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -/* - * Date: 26 November 2000 - * - * - * SUMMARY: Passing (RegExp object, flag) to RegExp() function. - * This test arose from Bugzilla bug 61266. The ECMA3 section is: - * - * 15.10.3 The RegExp Constructor Called as a Function - * - * 15.10.3.1 RegExp(pattern, flags) - * - * If pattern is an object R whose [[Class]] property is "RegExp" - * and flags is undefined, then return R unchanged. Otherwise - * call the RegExp constructor (section 15.10.4.1), passing it the - * pattern and flags arguments and return the object constructed - * by that constructor. - * - * - * The current test will check the first scenario outlined above: - * - * "pattern" is itself a RegExp object R - * "flags" is undefined - * - * The flags parameter will be undefined in the sense of not being - * provided. We check that RegExp(R) returns R - - */ -//----------------------------------------------------------------------------- -var gTestfile = '15.10.3.1-1.js'; -var BUGNUMBER = '61266'; -var summary = 'Passing (RegExp object,flag) to RegExp() function'; -var statprefix = 'RegExp(new RegExp('; -var comma = ', '; var singlequote = "'"; var closeparens = '))'; -var cnSUCCESS = 'RegExp() returned the supplied RegExp object'; -var cnFAILURE = 'RegExp() did NOT return the supplied RegExp object'; -var i = -1; var j = -1; var s = ''; var f = ''; -var obj = {}; -var status = ''; var actual = ''; var expect = ''; -var patterns = new Array(); -var flags = new Array(); - - -// various regular expressions to try - -patterns[0] = ''; -patterns[1] = 'abc'; -patterns[2] = '(.*)(3-1)\s\w'; -patterns[3] = '(.*)(...)\\s\\w'; -patterns[4] = '[^A-Za-z0-9_]'; -patterns[5] = '[^\f\n\r\t\v](123.5)([4 - 8]$)'; - -// various flags to try - -flags[0] = 'i'; -flags[1] = 'g'; -flags[2] = 'm'; -flags[3] = undefined; - - - -//------------------------------------------------------------------------------------------------- -test(); -//------------------------------------------------------------------------------------------------- - - -function test() -{ - enterFunc ('test'); - printBugNumber(BUGNUMBER); - printStatus (summary); - - for (i in patterns) - { - s = patterns[i]; - - for (j in flags) - { - f = flags[j]; - status = getStatus(s, f); - obj = new RegExp(s, f); - - actual = (obj == RegExp(obj))? cnSUCCESS : cnFAILURE; - expect = cnSUCCESS; - reportCompare (expect, actual, status); - } - } - - exitFunc ('test'); -} - - -function getStatus(regexp, flag) -{ - return (statprefix + quote(regexp) + comma + flag + closeparens); -} - - -function quote(text) -{ - return (singlequote + text + singlequote); -} diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/15.10.3.1-2.js b/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/15.10.3.1-2.js deleted file mode 100644 index d78be13c25..0000000000 --- a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/15.10.3.1-2.js +++ /dev/null @@ -1,144 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is mozilla.org code. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * pschwartau@netscape.com - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -/* - * Date: 26 November 2000 - * - * - * SUMMARY: Passing (RegExp object, flag) to RegExp() function. - * This test arose from Bugzilla bug 61266. The ECMA3 section is: - * - * 15.10.3 The RegExp Constructor Called as a Function - * - * 15.10.3.1 RegExp(pattern, flags) - * - * If pattern is an object R whose [[Class]] property is "RegExp" - * and flags is undefined, then return R unchanged. Otherwise - * call the RegExp constructor (section 15.10.4.1), passing it the - * pattern and flags arguments and return the object constructed - * by that constructor. - * - * - * The current test will check the first scenario outlined above: - * - * "pattern" is itself a RegExp object R - * "flags" is undefined - * - * This test is identical to test 15.10.3.1-1.js, except here we do: - * - * RegExp(R, undefined); - * - * instead of: - * - * RegExp(R); - * - * - * We check that RegExp(R, undefined) returns R - - */ -//----------------------------------------------------------------------------- -var gTestfile = '15.10.3.1-2.js'; -var BUGNUMBER = '61266'; -var summary = 'Passing (RegExp object,flag) to RegExp() function'; -var statprefix = 'RegExp(new RegExp('; -var comma = ', '; var singlequote = "'"; var closeparens = '))'; -var cnSUCCESS = 'RegExp() returned the supplied RegExp object'; -var cnFAILURE = 'RegExp() did NOT return the supplied RegExp object'; -var i = -1; var j = -1; var s = ''; var f = ''; -var obj = {}; -var status = ''; var actual = ''; var expect = ''; -var patterns = new Array(); -var flags = new Array(); - - -// various regular expressions to try - -patterns[0] = ''; -patterns[1] = 'abc'; -patterns[2] = '(.*)(3-1)\s\w'; -patterns[3] = '(.*)(...)\\s\\w'; -patterns[4] = '[^A-Za-z0-9_]'; -patterns[5] = '[^\f\n\r\t\v](123.5)([4 - 8]$)'; - -// various flags to try - -flags[0] = 'i'; -flags[1] = 'g'; -flags[2] = 'm'; -flags[3] = undefined; - - - -//------------------------------------------------------------------------------------------------- -test(); -//------------------------------------------------------------------------------------------------- - - -function test() -{ - enterFunc ('test'); - printBugNumber(BUGNUMBER); - printStatus (summary); - - for (i in patterns) - { - s = patterns[i]; - - for (j in flags) - { - f = flags[j]; - status = getStatus(s, f); - obj = new RegExp(s, f); - - actual = (obj == RegExp(obj, undefined))? cnSUCCESS : cnFAILURE ; - expect = cnSUCCESS; - reportCompare (expect, actual, status); - } - } - - exitFunc ('test'); -} - - -function getStatus(regexp, flag) -{ - return (statprefix + quote(regexp) + comma + flag + closeparens); -} - - -function quote(text) -{ - return (singlequote + text + singlequote); -} diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/15.10.4.1-1.js b/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/15.10.4.1-1.js deleted file mode 100644 index 47faf0051b..0000000000 --- a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/15.10.4.1-1.js +++ /dev/null @@ -1,127 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is mozilla.org code. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * pschwartau@netscape.com - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -/* - * Date: 26 November 2000 - * - * - *SUMMARY: Passing a RegExp object to a RegExp() constructor. - *This test arose from Bugzilla bug 61266. The ECMA3 section is: - * - * 15.10.4.1 new RegExp(pattern, flags) - * - * If pattern is an object R whose [[Class]] property is "RegExp" and - * flags is undefined, then let P be the pattern used to construct R - * and let F be the flags used to construct R. If pattern is an object R - * whose [[Class]] property is "RegExp" and flags is not undefined, - * then throw a TypeError exception. Otherwise, let P be the empty string - * if pattern is undefined and ToString(pattern) otherwise, and let F be - * the empty string if flags is undefined and ToString(flags) otherwise. - * - * - *The current test will check the first scenario outlined above: - * - * "pattern" is itself a RegExp object R - * "flags" is undefined - * - * We check that a new RegExp object obj2 defined from these parameters - * is morally the same as the original RegExp object obj1. Of course, they - * can't be equal as objects - so we check their enumerable properties... - * - * In this test, the initial RegExp object obj1 will not include a - * flag. The flags parameter for obj2 will be undefined in the sense - * of not being provided. - */ -//----------------------------------------------------------------------------- -var gTestfile = '15.10.4.1-1.js'; -var BUGNUMBER = '61266'; -var summary = 'Passing a RegExp object to a RegExp() constructor'; -var statprefix = 'Applying RegExp() twice to pattern '; -var statsuffix = '; testing property '; -var singlequote = "'"; -var i = -1; var s = ''; -var obj1 = {}; var obj2 = {}; -var status = ''; var actual = ''; var expect = ''; var msg = ''; -var patterns = new Array(); - - -// various regular expressions to try - -patterns[0] = ''; -patterns[1] = 'abc'; -patterns[2] = '(.*)(3-1)\s\w'; -patterns[3] = '(.*)(...)\\s\\w'; -patterns[4] = '[^A-Za-z0-9_]'; -patterns[5] = '[^\f\n\r\t\v](123.5)([4 - 8]$)'; - - - -//----------------------------------------------------------------------------- -test(); -//----------------------------------------------------------------------------- - - -function test() -{ - enterFunc ('test'); - printBugNumber(BUGNUMBER); - printStatus (summary); - - for (i in patterns) - { - s = patterns[i]; - status =getStatus(s); - obj1 = new RegExp(s); - obj2 = new RegExp(obj1); - - reportCompare (obj1 + '', obj2 + '', status); - } - - exitFunc ('test'); -} - - -function getStatus(regexp) -{ - return (statprefix + quote(regexp) + statsuffix); -} - - -function quote(text) -{ - return (singlequote + text + singlequote); -} diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/15.10.4.1-2.js b/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/15.10.4.1-2.js deleted file mode 100644 index 1d67b8afe6..0000000000 --- a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/15.10.4.1-2.js +++ /dev/null @@ -1,133 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is mozilla.org code. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * pschwartau@netscape.com - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -/* - * Date: 26 November 2000 - * - * - *SUMMARY: Passing a RegExp object to a RegExp() constructor. - *This test arose from Bugzilla bug 61266. The ECMA3 section is: - * - * 15.10.4.1 new RegExp(pattern, flags) - * - * If pattern is an object R whose [[Class]] property is "RegExp" and - * flags is undefined, then let P be the pattern used to construct R - * and let F be the flags used to construct R. If pattern is an object R - * whose [[Class]] property is "RegExp" and flags is not undefined, - * then throw a TypeError exception. Otherwise, let P be the empty string - * if pattern is undefined and ToString(pattern) otherwise, and let F be - * the empty string if flags is undefined and ToString(flags) otherwise. - * - * - *The current test will check the first scenario outlined above: - * - * "pattern" is itself a RegExp object R - * "flags" is undefined - * - * We check that a new RegExp object obj2 defined from these parameters - * is morally the same as the original RegExp object obj1. Of course, they - * can't be equal as objects - so we check their enumerable properties... - * - * In this test, the initial RegExp object obj1 will not include a - * flag. This test is identical to test 15.10.4.1-1.js, except that - * here we use this syntax: - * - * obj2 = new RegExp(obj1, undefined); - * - * instead of: - * - * obj2 = new RegExp(obj1); - */ -//----------------------------------------------------------------------------- -var gTestfile = '15.10.4.1-2.js'; -var BUGNUMBER = '61266'; -var summary = 'Passing a RegExp object to a RegExp() constructor'; -var statprefix = 'Applying RegExp() twice to pattern '; -var statsuffix = '; testing property '; -var singlequote = "'"; -var i = -1; var s = ''; -var obj1 = {}; var obj2 = {}; -var status = ''; var actual = ''; var expect = ''; var msg = ''; -var patterns = new Array(); - - -// various regular expressions to try - -patterns[0] = ''; -patterns[1] = 'abc'; -patterns[2] = '(.*)(3-1)\s\w'; -patterns[3] = '(.*)(...)\\s\\w'; -patterns[4] = '[^A-Za-z0-9_]'; -patterns[5] = '[^\f\n\r\t\v](123.5)([4 - 8]$)'; - - - -//------------------------------------------------------------------------------------------------- -test(); -//------------------------------------------------------------------------------------------------- - - -function test() -{ - enterFunc ('test'); - printBugNumber(BUGNUMBER); - printStatus (summary); - - for (i in patterns) - { - s = patterns[i]; - status =getStatus(s); - obj1 = new RegExp(s); - obj2 = new RegExp(obj1, undefined); // see introduction to bug - - reportCompare (obj1 + '', obj2 + '', status); - } - - exitFunc ('test'); -} - - -function getStatus(regexp) -{ - return (statprefix + quote(regexp) + statsuffix); -} - - -function quote(text) -{ - return (singlequote + text + singlequote); -} diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/15.10.4.1-3.js b/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/15.10.4.1-3.js deleted file mode 100644 index 12ef46bde8..0000000000 --- a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/15.10.4.1-3.js +++ /dev/null @@ -1,139 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is mozilla.org code. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * pschwartau@netscape.com - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -/* - * Date: 26 November 2000 - * - * - *SUMMARY: Passing a RegExp object to a RegExp() constructor. - *This test arose from Bugzilla bug 61266. The ECMA3 section is: - * - * 15.10.4.1 new RegExp(pattern, flags) - * - * If pattern is an object R whose [[Class]] property is "RegExp" and - * flags is undefined, then let P be the pattern used to construct R - * and let F be the flags used to construct R. If pattern is an object R - * whose [[Class]] property is "RegExp" and flags is not undefined, - * then throw a TypeError exception. Otherwise, let P be the empty string - * if pattern is undefined and ToString(pattern) otherwise, and let F be - * the empty string if flags is undefined and ToString(flags) otherwise. - * - * - *The current test will check the first scenario outlined above: - * - * "pattern" is itself a RegExp object R - * "flags" is undefined - * - * We check that a new RegExp object obj2 defined from these parameters - * is morally the same as the original RegExp object obj1. Of course, they - * can't be equal as objects - so we check their enumerable properties... - * - * In this test, the initial RegExp obj1 will include a flag. The flags - * parameter for obj2 will be undefined in the sense of not being provided. - */ -//----------------------------------------------------------------------------- -var gTestfile = '15.10.4.1-3.js'; -var BUGNUMBER = '61266'; -var summary = 'Passing a RegExp object to a RegExp() constructor'; -var statprefix = 'Applying RegExp() twice to pattern '; -var statmiddle = ' and flag '; -var statsuffix = '; testing property '; -var singlequote = "'"; -var i = -1; var j = -1; var s = ''; -var obj1 = {}; var obj2 = {}; -var status = ''; var actual = ''; var expect = ''; var msg = ''; -var patterns = new Array(); -var flags = new Array(); - - -// various regular expressions to try - -patterns[0] = ''; -patterns[1] = 'abc'; -patterns[2] = '(.*)(3-1)\s\w'; -patterns[3] = '(.*)(...)\\s\\w'; -patterns[4] = '[^A-Za-z0-9_]'; -patterns[5] = '[^\f\n\r\t\v](123.5)([4 - 8]$)'; - -// various flags to try - -flags[0] = 'i'; -flags[1] = 'g'; -flags[2] = 'm'; -flags[3] = undefined; - - - -//------------------------------------------------------------------------------------------------- -test(); -//------------------------------------------------------------------------------------------------- - - -function test() -{ - enterFunc ('test'); - printBugNumber(BUGNUMBER); - printStatus (summary); - - for (i in patterns) - { - s = patterns[i]; - - for (j in flags) - { - f = flags[j]; - status = getStatus(s, f); - obj1 = new RegExp(s, f); - obj2 = new RegExp(obj1); - - reportCompare (obj1 + '', obj2 + '', status); - } - } - - exitFunc ('test'); -} - - -function getStatus(regexp, flag) -{ - return (statprefix + quote(regexp) + statmiddle + flag + statsuffix); -} - - -function quote(text) -{ - return (singlequote + text + singlequote); -} diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/15.10.4.1-4.js b/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/15.10.4.1-4.js deleted file mode 100644 index 3b4245851e..0000000000 --- a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/15.10.4.1-4.js +++ /dev/null @@ -1,146 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is mozilla.org code. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * pschwartau@netscape.com - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -/* - * Date: 26 November 2000 - * - * - *SUMMARY: Passing a RegExp object to a RegExp() constructor. - *This test arose from Bugzilla bug 61266. The ECMA3 section is: - * - * 15.10.4.1 new RegExp(pattern, flags) - * - * If pattern is an object R whose [[Class]] property is "RegExp" and - * flags is undefined, then let P be the pattern used to construct R - * and let F be the flags used to construct R. If pattern is an object R - * whose [[Class]] property is "RegExp" and flags is not undefined, - * then throw a TypeError exception. Otherwise, let P be the empty string - * if pattern is undefined and ToString(pattern) otherwise, and let F be - * the empty string if flags is undefined and ToString(flags) otherwise. - * - * - *The current test will check the first scenario outlined above: - * - * "pattern" is itself a RegExp object R - * "flags" is undefined - * - * We check that a new RegExp object obj2 defined from these parameters - * is morally the same as the original RegExp object obj1. Of course, they - * can't be equal as objects - so we check their enumerable properties... - * - * In this test, the initial RegExp object obj1 will include a - * flag. This test is identical to test 15.10.4.1-3.js, except that - * here we use this syntax: - * - * obj2 = new RegExp(obj1, undefined); - * - * instead of: - * - * obj2 = new RegExp(obj1); - */ -//----------------------------------------------------------------------------- -var gTestfile = '15.10.4.1-4.js'; -var BUGNUMBER = '61266'; -var summary = 'Passing a RegExp object to a RegExp() constructor'; -var statprefix = 'Applying RegExp() twice to pattern '; -var statmiddle = ' and flag '; -var statsuffix = '; testing property '; -var singlequote = "'"; -var i = -1; var j = -1; var s = ''; -var obj1 = {}; var obj2 = {}; -var status = ''; var actual = ''; var expect = ''; var msg = ''; -var patterns = new Array(); -var flags = new Array(); - - -// various regular expressions to try - -patterns[0] = ''; -patterns[1] = 'abc'; -patterns[2] = '(.*)(3-1)\s\w'; -patterns[3] = '(.*)(...)\\s\\w'; -patterns[4] = '[^A-Za-z0-9_]'; -patterns[5] = '[^\f\n\r\t\v](123.5)([4 - 8]$)'; - -// various flags to try - -flags[0] = 'i'; -flags[1] = 'g'; -flags[2] = 'm'; -flags[3] = undefined; - - - -//------------------------------------------------------------------------------------------------- -test(); -//------------------------------------------------------------------------------------------------- - - -function test() -{ - enterFunc ('test'); - printBugNumber(BUGNUMBER); - printStatus (summary); - - for (i in patterns) - { - s = patterns[i]; - - for (j in flags) - { - f = flags[j]; - status = getStatus(s, f); - obj1 = new RegExp(s, f); - obj2 = new RegExp(obj1, undefined); // see introduction to bug - - reportCompare (obj1 + '', obj2 + '', status); - } - } - - exitFunc ('test'); -} - - -function getStatus(regexp, flag) -{ - return (statprefix + quote(regexp) + statmiddle + flag + statsuffix); -} - - -function quote(text) -{ - return (singlequote + text + singlequote); -} diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/15.10.4.1-5-n.js b/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/15.10.4.1-5-n.js deleted file mode 100644 index 592fb03ac7..0000000000 --- a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/15.10.4.1-5-n.js +++ /dev/null @@ -1,139 +0,0 @@ -/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is mozilla.org code. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * pschwartau@netscape.com - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -var gTestfile = '15.10.4.1-5-n.js'; -/* - * - * Date: 26 November 2000 - * - * - *SUMMARY: Passing a RegExp object to a RegExp() constructor. - *This test arose from Bugzilla bug 61266. The ECMA3 section is: - * - * 15.10.4.1 new RegExp(pattern, flags) - * - * If pattern is an object R whose [[Class]] property is "RegExp" and - * flags is undefined, then let P be the pattern used to construct R - * and let F be the flags used to construct R. If pattern is an object R - * whose [[Class]] property is "RegExp" and flags is not undefined, - * then throw a TypeError exception. Otherwise, let P be the empty string - * if pattern is undefined and ToString(pattern) otherwise, and let F be - * the empty string if flags is undefined and ToString(flags) otherwise. - * - * - *The current test will check the second scenario outlined above: - * - * "pattern" is itself a RegExp object R - * "flags" is NOT undefined - * - * This should throw an exception ... we test for this. - * - */ - -//------------------------------------------------------------------------------------------------- -var BUGNUMBER = '61266'; -var summary = 'Negative test: Passing (RegExp object, flag) to RegExp() constructor'; -var statprefix = 'Passing RegExp object on pattern '; -var statsuffix = '; passing flag '; -var cnFAILURE = 'Expected an exception to be thrown, but none was -'; -var singlequote = "'"; -var i = -1; var j = -1; var s = ''; var f = ''; -var obj1 = {}; var obj2 = {}; -var patterns = new Array(); -var flags = new Array(); - - -// various regular expressions to try - -patterns[0] = ''; -patterns[1] = 'abc'; -patterns[2] = '(.*)(3-1)\s\w'; -patterns[3] = '(.*)(...)\\s\\w'; -patterns[4] = '[^A-Za-z0-9_]'; -patterns[5] = '[^\f\n\r\t\v](123.5)([4 - 8]$)'; - -// various flags to try - -flags[0] = 'i'; -flags[1] = 'g'; -flags[2] = 'm'; - - -DESCRIPTION = "Negative test: Passing (RegExp object, flag) to RegExp() constructor" - EXPECTED = "error"; - - -//------------------------------------------------------------------------------------------------- -test(); -//------------------------------------------------------------------------------------------------- - - -function test() -{ - enterFunc ('test'); - printBugNumber(BUGNUMBER); - printStatus (summary); - - for (i in patterns) - { - s = patterns[i]; - - for (j in flags) - { - f = flags[j]; - printStatus(getStatus(s, f)); - obj1 = new RegExp(s, f); - obj2 = new RegExp(obj1, f); // this should cause an exception - - // WE SHOULD NEVER REACH THIS POINT - - reportCompare('PASS', 'FAIL', cnFAILURE); - } - } - - exitFunc ('test'); -} - - -function getStatus(regexp, flag) -{ - return (statprefix + quote(regexp) + statsuffix + flag); -} - - -function quote(text) -{ - return (singlequote + text + singlequote); -} diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/15.10.6.2-1.js b/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/15.10.6.2-1.js deleted file mode 100644 index 8203da4967..0000000000 --- a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/15.10.6.2-1.js +++ /dev/null @@ -1,140 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is mozilla.org code. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * pschwartau@netscape.com - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -/* - * Date: 23 October 2001 - * - * SUMMARY: Testing regexps with the global flag set. - * NOT every substring fitting the given pattern will be matched. - * The parent string is CONSUMED as successive matches are found. - * - * From the ECMA-262 Final spec: - * - * 15.10.6.2 RegExp.prototype.exec(string) - * Performs a regular expression match of string against the regular - * expression and returns an Array object containing the results of - * the match, or null if the string did not match. - * - * The string ToString(string) is searched for an occurrence of the - * regular expression pattern as follows: - * - * 1. Let S be the value of ToString(string). - * 2. Let length be the length of S. - * 3. Let lastIndex be the value of the lastIndex property. - * 4. Let i be the value of ToInteger(lastIndex). - * 5. If the global property is false, let i = 0. - * 6. If i < 0 or i > length then set lastIndex to 0 and return null. - * 7. Call [[Match]], giving it the arguments S and i. - * If [[Match]] returned failure, go to step 8; - * otherwise let r be its State result and go to step 10. - * 8. Let i = i+1. - * 9. Go to step 6. - * 10. Let e be r's endIndex value. - * 11. If the global property is true, set lastIndex to e. - * - * etc. - * - * - * So when the global flag is set, |lastIndex| is incremented every time - * there is a match; not from i to i+1, but from i to "endIndex" e: - * - * e = (index of last input character matched so far by the pattern) + 1 - * - * Thus in the example below, the first endIndex e occurs after the - * first match 'a b'. The next match will begin AFTER this, and so - * will NOT be 'b c', but rather 'c d'. Similarly, 'd e' won't be matched. - */ -//----------------------------------------------------------------------------- -var gTestfile = '15.10.6.2-1.js'; -var i = 0; -var BUGNUMBER = '(none)'; -var summary = 'Testing regexps with the global flag set'; -var status = ''; -var statusmessages = new Array(); -var pattern = ''; -var patterns = new Array(); -var string = ''; -var strings = new Array(); -var actualmatch = ''; -var actualmatches = new Array(); -var expectedmatch = ''; -var expectedmatches = new Array(); - - -status = inSection(1); -string = 'a b c d e'; -pattern = /\w\s\w/g; -actualmatch = string.match(pattern); -expectedmatch = ['a b','c d']; // see above explanation - -addThis(); - - -status = inSection(2); -string = '12345678'; -pattern = /\d\d\d/g; -actualmatch = string.match(pattern); -expectedmatch = ['123','456']; -addThis(); - - - -//----------------------------------------------------------------------------- -test(); -//----------------------------------------------------------------------------- - - - -function addThis() -{ - statusmessages[i] = status; - patterns[i] = pattern; - strings[i] = string; - actualmatches[i] = actualmatch; - expectedmatches[i] = expectedmatch; - i++; -} - - -function test() -{ - enterFunc ('test'); - printBugNumber(BUGNUMBER); - printStatus (summary); - testRegExp(statusmessages, patterns, strings, actualmatches, expectedmatches); - exitFunc ('test'); -} diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/15.10.6.2-2.js b/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/15.10.6.2-2.js deleted file mode 100644 index e6fd6c6311..0000000000 --- a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/15.10.6.2-2.js +++ /dev/null @@ -1,367 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is JavaScript Engine testing utilities. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corp. - * Portions created by the Initial Developer are Copyright (C) 2002 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * pschwartau@netscape.com - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -/* - * - * Date: 18 Feb 2002 - * SUMMARY: Testing re.exec(str) when re.lastIndex is < 0 or > str.length - * - * Case 1: If re has the global flag set, then re(str) should be null - * Case 2: If re doesn't have this set, then re(str) should be unaffected - * - * See http://bugzilla.mozilla.org/show_bug.cgi?id=76717 - * - * - * From the ECMA-262 Final spec: - * - * 15.10.6.2 RegExp.prototype.exec(string) - * Performs a regular expression match of string against the regular - * expression and returns an Array object containing the results of - * the match, or null if the string did not match. - * - * The string ToString(string) is searched for an occurrence of the - * regular expression pattern as follows: - * - * 1. Let S be the value of ToString(string). - * 2. Let length be the length of S. - * 3. Let lastIndex be the value of the lastIndex property. - * 4. Let i be the value of ToInteger(lastIndex). - * 5. If the global property is false, let i = 0. - * 6. If i < 0 or i > length then set lastIndex to 0 and return null. - * 7. Call [[Match]], giving it the arguments S and i. - * If [[Match]] returned failure, go to step 8; - * otherwise let r be its State result and go to step 10. - * 8. Let i = i+1. - * 9. Go to step 6. - * 10. Let e be r's endIndex value. - * 11. If the global property is true, set lastIndex to e. - * - * etc. - * - * - * So: - * - * A. If the global flag is not set, |lastIndex| is set to 0 - * before the match is attempted; thus the match is unaffected. - * - * B. If the global flag IS set and re.lastIndex is >= 0 and <= str.length, - * |lastIndex| is incremented every time there is a match; not from - * i to i+1, but from i to "endIndex" e: - * - * e = (index of last input character matched so far by the pattern) + 1 - * - * The match is then attempted from this position in the string (Step 7). - * - * C. When the global flag IS set and re.lastIndex is < 0 or > str.length, - * |lastIndex| is set to 0 and the match returns null. - * - * - * Note the |lastIndex| property is writeable, and may be set arbitrarily - * by the programmer - and we will do that below. - * - */ -//----------------------------------------------------------------------------- -var gTestfile = '15.10.6.2-2.js'; -var i = 0; -var BUGNUMBER = 76717; -var summary = 'Testing re.exec(str) when re.lastIndex is < 0 or > str.length'; -var status = ''; -var statusmessages = new Array(); -var pattern = ''; -var patterns = new Array(); -var string = ''; -var strings = new Array(); -var actualmatch = ''; -var actualmatches = new Array(); -var expectedmatch = ''; -var expectedmatches = new Array(); - - -/****************************************************************************** - * - * Case 1 : when the global flag is set - - * - *****************************************************************************/ -pattern = /abc/gi; -string = 'AbcaBcabC'; - -status = inSection(1); -actualmatch = pattern.exec(string); -expectedmatch = Array('Abc'); -addThis(); - -status = inSection(2); -actualmatch = pattern.exec(string); -expectedmatch = Array('aBc'); -addThis(); - -status = inSection(3); -actualmatch = pattern.exec(string); -expectedmatch = Array('abC'); -addThis(); - -/* - * At this point |lastIndex| is > string.length, so the match should be null - - */ -status = inSection(4); -actualmatch = pattern.exec(string); -expectedmatch = null; -addThis(); - -/* - * Now let's set |lastIndex| to -1, so the match should again be null - - */ -status = inSection(5); -pattern.lastIndex = -1; -actualmatch = pattern.exec(string); -expectedmatch = null; -addThis(); - -/* - * Now try some edge-case values. Thanks to the work done in - * http://bugzilla.mozilla.org/show_bug.cgi?id=124339, |lastIndex| - * is now stored as a double instead of a uint32 (unsigned integer). - * - * Note 2^32 -1 is the upper bound for uint32's, but doubles can go - * all the way up to Number.MAX_VALUE. So that's why we need cases - * between those two numbers. - */ -status = inSection(6); -pattern.lastIndex = Math.pow(2,32); -actualmatch = pattern.exec(string); -expectedmatch = null; -addThis(); - -status = inSection(7); -pattern.lastIndex = -Math.pow(2,32); -actualmatch = pattern.exec(string); -expectedmatch = null; -addThis(); - -status = inSection(8); -pattern.lastIndex = Math.pow(2,32) + 1; -actualmatch = pattern.exec(string); -expectedmatch = null; -addThis(); - -status = inSection(9); -pattern.lastIndex = -(Math.pow(2,32) + 1); -actualmatch = pattern.exec(string); -expectedmatch = null; -addThis(); - -status = inSection(10); -pattern.lastIndex = Math.pow(2,32) * 2; -actualmatch = pattern.exec(string); -expectedmatch = null; -addThis(); - -status = inSection(11); -pattern.lastIndex = -Math.pow(2,32) * 2; -actualmatch = pattern.exec(string); -expectedmatch = null; -addThis(); - -status = inSection(12); -pattern.lastIndex = Math.pow(2,40); -actualmatch = pattern.exec(string); -expectedmatch = null; -addThis(); - -status = inSection(13); -pattern.lastIndex = -Math.pow(2,40); -actualmatch = pattern.exec(string); -expectedmatch = null; -addThis(); - -status = inSection(14); -pattern.lastIndex = Number.MAX_VALUE; -actualmatch = pattern.exec(string); -expectedmatch = null; -addThis(); - -status = inSection(15); -pattern.lastIndex = -Number.MAX_VALUE; -actualmatch = pattern.exec(string); -expectedmatch = null; -addThis(); - - - -/****************************************************************************** - * - * Case 2: repeat all the above cases WITHOUT the global flag set. - * According to EMCA. |lastIndex| should get set to 0 before the match. - * - * Therefore re.exec(str) should be unaffected; thus our expected values - * below are now DIFFERENT when |lastIndex| is < 0 or > str.length - * - *****************************************************************************/ - -pattern = /abc/i; -string = 'AbcaBcabC'; - -status = inSection(16); -actualmatch = pattern.exec(string); -expectedmatch = Array('Abc'); -addThis(); - -status = inSection(17); -actualmatch = pattern.exec(string); -expectedmatch = Array('Abc'); // NOT Array('aBc') as before - -addThis(); - -status = inSection(18); -actualmatch = pattern.exec(string); -expectedmatch = Array('Abc'); // NOT Array('abC') as before - -addThis(); - -/* - * At this point above, |lastIndex| WAS > string.length, but not here - - */ -status = inSection(19); -actualmatch = pattern.exec(string); -expectedmatch = Array('Abc') // NOT null as before - - addThis(); - -/* - * Now let's set |lastIndex| to -1 - */ -status = inSection(20); -pattern.lastIndex = -1; -actualmatch = pattern.exec(string); -expectedmatch = Array('Abc') // NOT null as before - - addThis(); - -/* - * Now try some edge-case values. Thanks to the work done in - * http://bugzilla.mozilla.org/show_bug.cgi?id=124339, |lastIndex| - * is now stored as a double instead of a uint32 (unsigned integer). - * - * Note 2^32 -1 is the upper bound for uint32's, but doubles can go - * all the way up to Number.MAX_VALUE. So that's why we need cases - * between those two numbers. - */ -status = inSection(21); -pattern.lastIndex = Math.pow(2,32); -actualmatch = pattern.exec(string); -expectedmatch = Array('Abc') // NOT null as before - - addThis(); - -status = inSection(22); -pattern.lastIndex = -Math.pow(2,32); -actualmatch = pattern.exec(string); -expectedmatch = Array('Abc') // NOT null as before - - addThis(); - -status = inSection(23); -pattern.lastIndex = Math.pow(2,32) + 1; -actualmatch = pattern.exec(string); -expectedmatch = Array('Abc') // NOT null as before - - addThis(); - -status = inSection(24); -pattern.lastIndex = -(Math.pow(2,32) + 1); -actualmatch = pattern.exec(string); -expectedmatch = Array('Abc') // NOT null as before - - addThis(); - -status = inSection(25); -pattern.lastIndex = Math.pow(2,32) * 2; -actualmatch = pattern.exec(string); -expectedmatch = Array('Abc') // NOT null as before - - addThis(); - -status = inSection(26); -pattern.lastIndex = -Math.pow(2,32) * 2; -actualmatch = pattern.exec(string); -expectedmatch = Array('Abc') // NOT null as before - - addThis(); - -status = inSection(27); -pattern.lastIndex = Math.pow(2,40); -actualmatch = pattern.exec(string); -expectedmatch = Array('Abc') // NOT null as before -; - addThis(); - -status = inSection(28); -pattern.lastIndex = -Math.pow(2,40); -actualmatch = pattern.exec(string); -expectedmatch = Array('Abc') // NOT null as before - - addThis(); - -status = inSection(29); -pattern.lastIndex = Number.MAX_VALUE; -actualmatch = pattern.exec(string); -expectedmatch = Array('Abc') // NOT null as before - - addThis(); - -status = inSection(30); -pattern.lastIndex = -Number.MAX_VALUE; -actualmatch = pattern.exec(string); -expectedmatch = Array('Abc') // NOT null as before - - addThis(); - - - - -//------------------------------------------------------------------------------------------------- -test(); -//------------------------------------------------------------------------------------------------- - - - -function addThis() -{ - statusmessages[i] = status; - patterns[i] = pattern; - strings[i] = string; - actualmatches[i] = actualmatch; - expectedmatches[i] = expectedmatch; - i++; -} - - -function test() -{ - enterFunc ('test'); - printBugNumber(BUGNUMBER); - printStatus (summary); - testRegExp(statusmessages, patterns, strings, actualmatches, expectedmatches); - exitFunc ('test'); -} diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/browser.js b/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/browser.js deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/octal-001.js b/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/octal-001.js deleted file mode 100644 index f35724e47b..0000000000 --- a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/octal-001.js +++ /dev/null @@ -1,136 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is JavaScript Engine testing utilities. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corp. - * Portions created by the Initial Developer are Copyright (C) 2002 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * pschwartau@netscape.com - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -/* - * - * Date: 18 July 2002 - * SUMMARY: Testing octal sequences in regexps - * See http://bugzilla.mozilla.org/show_bug.cgi?id=141078 - * - */ -//----------------------------------------------------------------------------- -var gTestfile = 'octal-001.js'; -var i = 0; -var BUGNUMBER = 141078; -var summary = 'Testing octal sequences in regexps'; -var status = ''; -var statusmessages = new Array(); -var pattern = ''; -var patterns = new Array(); -var string = ''; -var strings = new Array(); -var actualmatch = ''; -var actualmatches = new Array(); -var expectedmatch = ''; -var expectedmatches = new Array(); - - -status = inSection(1); -pattern = /\240/; -string = 'abc'; -actualmatch = string.match(pattern); -expectedmatch = null; -addThis(); - -/* - * In the following sections, we test the octal escape sequence '\052'. - * This is character code 42, representing the asterisk character '*'. - * The Unicode escape for it would be '\u002A', the hex escape '\x2A'. - */ -status = inSection(2); -pattern = /ab\052c/; -string = 'ab*c'; -actualmatch = string.match(pattern); -expectedmatch = Array('ab*c'); -addThis(); - -status = inSection(3); -pattern = /ab\052*c/; -string = 'abc'; -actualmatch = string.match(pattern); -expectedmatch = Array('abc'); -addThis(); - -status = inSection(4); -pattern = /ab(\052)+c/; -string = 'ab****c'; -actualmatch = string.match(pattern); -expectedmatch = Array('ab****c', '*'); -addThis(); - -status = inSection(5); -pattern = /ab((\052)+)c/; -string = 'ab****c'; -actualmatch = string.match(pattern); -expectedmatch = Array('ab****c', '****', '*'); -addThis(); - -status = inSection(6); -pattern = /(?:\052)c/; -string = 'ab****c'; -actualmatch = string.match(pattern); -expectedmatch = Array('*c'); -addThis(); - - - -//----------------------------------------------------------------------------- -test(); -//----------------------------------------------------------------------------- - - - -function addThis() -{ - statusmessages[i] = status; - patterns[i] = pattern; - strings[i] = string; - actualmatches[i] = actualmatch; - expectedmatches[i] = expectedmatch; - i++; -} - - -function test() -{ - enterFunc('test'); - printBugNumber(BUGNUMBER); - printStatus(summary); - testRegExp(statusmessages, patterns, strings, actualmatches, expectedmatches); - exitFunc ('test'); -} diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/octal-002.js b/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/octal-002.js deleted file mode 100644 index 401ad43c11..0000000000 --- a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/octal-002.js +++ /dev/null @@ -1,218 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is JavaScript Engine testing utilities. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corp. - * Portions created by the Initial Developer are Copyright (C) 2002 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * pschwartau@netscape.com - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -/* - * - * Date: 31 July 2002 - * SUMMARY: Testing regexps containing octal escape sequences - * This is an elaboration of mozilla/js/tests/ecma_2/RegExp/octal-003.js - * - * See http://bugzilla.mozilla.org/show_bug.cgi?id=141078 - * for a reference on octal escape sequences in regexps. - * - * NOTE: - * We will use the identities '\011' === '\u0009' === '\x09' === '\t' - * - * The first is an octal escape sequence (\(0-3)OO; O an octal digit). - * See ECMA-262 Edition 2, Section 7.7.4 "String Literals". These were - * dropped in Edition 3 but we support them for backward compatibility. - * - * The second is a Unicode escape sequence (\uHHHH; H a hex digit). - * Since octal 11 = hex 9, the two escapes define the same character. - * - * The third is a hex escape sequence (\xHH; H a hex digit). - * Since hex 09 = hex 0009, this defines the same character. - * - * The fourth is the familiar escape sequence for a horizontal tab, - * defined in the ECMA spec as having Unicode value \u0009. - */ -//----------------------------------------------------------------------------- -var gTestfile = 'octal-002.js'; -var i = 0; -var BUGNUMBER = 141078; -var summary = 'Testing regexps containing octal escape sequences'; -var status = ''; -var statusmessages = new Array(); -var pattern = ''; -var patterns = new Array(); -var string = ''; -var strings = new Array(); -var actualmatch = ''; -var actualmatches = new Array(); -var expectedmatch = ''; -var expectedmatches = new Array(); - - -/* - * Test a string containing the null character '\0' followed by the string '11' - * - * 'a' + String.fromCharCode(0) + '11'; - * - * Note we can't simply write 'a\011', because '\011' would be interpreted - * as the octal escape sequence for the tab character (see above). - * - * We should get no match from the regexp /.\011/, because it should be - * looking for the octal escape sequence \011, i.e. the tab character - - * - */ -status = inSection(1); -pattern = /.\011/; -string = 'a' + String.fromCharCode(0) + '11'; -actualmatch = string.match(pattern); -expectedmatch = null; -addThis(); - - -/* - * Try same thing with 'xx' in place of '11'. - * - * Should get a match now, because the octal escape sequence in the regexp - * has been reduced from \011 to \0, and '\0' is present in the string - - */ -status = inSection(2); -pattern = /.\0xx/; -string = 'a' + String.fromCharCode(0) + 'xx'; -actualmatch = string.match(pattern); -expectedmatch = Array(string); -addThis(); - - -/* - * Same thing; don't use |String.fromCharCode(0)| this time. - * There is no ambiguity in '\0xx': it is the null character - * followed by two x's, no other interpretation is possible. - */ -status = inSection(3); -pattern = /.\0xx/; -string = 'a\0xx'; -actualmatch = string.match(pattern); -expectedmatch = Array(string); -addThis(); - - -/* - * This one should produce a match. The two-character string - * 'a' + '\011' is duplicated in the pattern and test string: - */ -status = inSection(4); -pattern = /.\011/; -string = 'a\011'; -actualmatch = string.match(pattern); -expectedmatch = Array(string); -addThis(); - - -/* - * Same as above, only now, for the second character of the string, - * use the Unicode escape '\u0009' instead of the octal escape '\011' - */ -status = inSection(5); -pattern = /.\011/; -string = 'a\u0009'; -actualmatch = string.match(pattern); -expectedmatch = Array(string); -addThis(); - - -/* - * Same as above, only now for the second character of the string, - * use the hex escape '\x09' instead of the octal escape '\011' - */ -status = inSection(6); -pattern = /.\011/; -string = 'a\x09'; -actualmatch = string.match(pattern); -expectedmatch = Array(string); -addThis(); - - -/* - * Same as above, only now for the second character of the string, - * use the escape '\t' instead of the octal escape '\011' - */ -status = inSection(7); -pattern = /.\011/; -string = 'a\t'; -actualmatch = string.match(pattern); -expectedmatch = Array(string); -addThis(); - - -/* - * Return to the string from Section 1. - * - * Unlike Section 1, use the RegExp() function to create the - * regexp pattern: null character followed by the string '11'. - * - * Since this is exactly what the string is, we should get a match - - */ -status = inSection(8); -string = 'a' + String.fromCharCode(0) + '11'; -pattern = RegExp(string); -actualmatch = string.match(pattern); -expectedmatch = Array(string); -addThis(); - - - - -//------------------------------------------------------------------------------------------------- -test(); -//------------------------------------------------------------------------------------------------- - - - -function addThis() -{ - statusmessages[i] = status; - patterns[i] = pattern; - strings[i] = string; - actualmatches[i] = actualmatch; - expectedmatches[i] = expectedmatch; - i++; -} - - -function test() -{ - enterFunc ('test'); - printBugNumber(BUGNUMBER); - printStatus (summary); - testRegExp(statusmessages, patterns, strings, actualmatches, expectedmatches); - exitFunc ('test'); -} diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/perlstress-001.js b/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/perlstress-001.js deleted file mode 100644 index 0b27529a32..0000000000 --- a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/perlstress-001.js +++ /dev/null @@ -1,3230 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is JavaScript Engine testing utilities. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corp. - * Portions created by the Initial Developer are Copyright (C) 2002 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * pschwartau@netscape.com, rogerl@netscape.com - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -/* - * - * Date: 2002-07-07 - * SUMMARY: Testing JS RegExp engine against Perl 5 RegExp engine. - * Adjust cnLBOUND, cnUBOUND below to restrict which sections are tested. - * - * This test was created by running various patterns and strings through the - * Perl 5 RegExp engine. We saved the results below to test the JS engine. - * - * NOTE: ECMA/JS and Perl do differ on certain points. We have either commented - * out such sections altogether, or modified them to fit what we expect from JS. - * - * EXAMPLES: - * - * - In JS, regexp captures (/(a) etc./) must hold |undefined| if not used. - * See http://bugzilla.mozilla.org/show_bug.cgi?id=123437. - * By contrast, in Perl, unmatched captures hold the empty string. - * We have modified such sections accordingly. Example: - - pattern = /^([^a-z])|(\^)$/; - string = '.'; - actualmatch = string.match(pattern); - //expectedmatch = Array('.', '.', ''); <<<--- Perl - expectedmatch = Array('.', '.', undefined); <<<--- JS - addThis(); - - - * - In JS, you can't refer to a capture before it's encountered & completed - * - * - Perl supports ] & ^] inside a [], ECMA does not - * - * - ECMA does support (?: (?= and (?! operators, but doesn't support (?< etc. - * - * - ECMA doesn't support (?imsx or (?-imsx - * - * - ECMA doesn't support (?(condition) - * - * - Perl has \Z has end-of-line, ECMA doesn't - * - * - In ECMA, ^ matches only the empty string before the first character - * - * - In ECMA, $ matches only the empty string at end of input (unless multiline) - * - * - ECMA spec says that each atom in a range must be a single character - * - * - ECMA doesn't support \A - * - * - ECMA doesn't have rules for [: - * - */ -//----------------------------------------------------------------------------- -var gTestfile = 'perlstress-001.js'; -var i = 0; -var BUGNUMBER = 85721; -var summary = 'Testing regular expression edge cases'; -var cnSingleSpace = ' '; -var status = ''; -var statusmessages = new Array(); -var pattern = ''; -var patterns = new Array(); -var string = ''; -var strings = new Array(); -var actualmatch = ''; -var actualmatches = new Array(); -var expectedmatch = ''; -var expectedmatches = new Array(); -var cnLBOUND = 1; -var cnUBOUND = 1000; - - -status = inSection(1); -pattern = /abc/; -string = 'abc'; -actualmatch = string.match(pattern); -expectedmatch = Array('abc'); -addThis(); - -status = inSection(2); -pattern = /abc/; -string = 'xabcy'; -actualmatch = string.match(pattern); -expectedmatch = Array('abc'); -addThis(); - -status = inSection(3); -pattern = /abc/; -string = 'ababc'; -actualmatch = string.match(pattern); -expectedmatch = Array('abc'); -addThis(); - -status = inSection(4); -pattern = /ab*c/; -string = 'abc'; -actualmatch = string.match(pattern); -expectedmatch = Array('abc'); -addThis(); - -status = inSection(5); -pattern = /ab*bc/; -string = 'abc'; -actualmatch = string.match(pattern); -expectedmatch = Array('abc'); -addThis(); - -status = inSection(6); -pattern = /ab*bc/; -string = 'abbc'; -actualmatch = string.match(pattern); -expectedmatch = Array('abbc'); -addThis(); - -status = inSection(7); -pattern = /ab*bc/; -string = 'abbbbc'; -actualmatch = string.match(pattern); -expectedmatch = Array('abbbbc'); -addThis(); - -status = inSection(8); -pattern = /.{1}/; -string = 'abbbbc'; -actualmatch = string.match(pattern); -expectedmatch = Array('a'); -addThis(); - -status = inSection(9); -pattern = /.{3,4}/; -string = 'abbbbc'; -actualmatch = string.match(pattern); -expectedmatch = Array('abbb'); -addThis(); - -status = inSection(10); -pattern = /ab{0,}bc/; -string = 'abbbbc'; -actualmatch = string.match(pattern); -expectedmatch = Array('abbbbc'); -addThis(); - -status = inSection(11); -pattern = /ab+bc/; -string = 'abbc'; -actualmatch = string.match(pattern); -expectedmatch = Array('abbc'); -addThis(); - -status = inSection(12); -pattern = /ab+bc/; -string = 'abbbbc'; -actualmatch = string.match(pattern); -expectedmatch = Array('abbbbc'); -addThis(); - -status = inSection(13); -pattern = /ab{1,}bc/; -string = 'abbbbc'; -actualmatch = string.match(pattern); -expectedmatch = Array('abbbbc'); -addThis(); - -status = inSection(14); -pattern = /ab{1,3}bc/; -string = 'abbbbc'; -actualmatch = string.match(pattern); -expectedmatch = Array('abbbbc'); -addThis(); - -status = inSection(15); -pattern = /ab{3,4}bc/; -string = 'abbbbc'; -actualmatch = string.match(pattern); -expectedmatch = Array('abbbbc'); -addThis(); - -status = inSection(16); -pattern = /ab?bc/; -string = 'abbc'; -actualmatch = string.match(pattern); -expectedmatch = Array('abbc'); -addThis(); - -status = inSection(17); -pattern = /ab?bc/; -string = 'abc'; -actualmatch = string.match(pattern); -expectedmatch = Array('abc'); -addThis(); - -status = inSection(18); -pattern = /ab{0,1}bc/; -string = 'abc'; -actualmatch = string.match(pattern); -expectedmatch = Array('abc'); -addThis(); - -status = inSection(19); -pattern = /ab?c/; -string = 'abc'; -actualmatch = string.match(pattern); -expectedmatch = Array('abc'); -addThis(); - -status = inSection(20); -pattern = /ab{0,1}c/; -string = 'abc'; -actualmatch = string.match(pattern); -expectedmatch = Array('abc'); -addThis(); - -status = inSection(21); -pattern = /^abc$/; -string = 'abc'; -actualmatch = string.match(pattern); -expectedmatch = Array('abc'); -addThis(); - -status = inSection(22); -pattern = /^abc/; -string = 'abcc'; -actualmatch = string.match(pattern); -expectedmatch = Array('abc'); -addThis(); - -status = inSection(23); -pattern = /abc$/; -string = 'aabc'; -actualmatch = string.match(pattern); -expectedmatch = Array('abc'); -addThis(); - -status = inSection(24); -pattern = /^/; -string = 'abc'; -actualmatch = string.match(pattern); -expectedmatch = Array(''); -addThis(); - -status = inSection(25); -pattern = /$/; -string = 'abc'; -actualmatch = string.match(pattern); -expectedmatch = Array(''); -addThis(); - -status = inSection(26); -pattern = /a.c/; -string = 'abc'; -actualmatch = string.match(pattern); -expectedmatch = Array('abc'); -addThis(); - -status = inSection(27); -pattern = /a.c/; -string = 'axc'; -actualmatch = string.match(pattern); -expectedmatch = Array('axc'); -addThis(); - -status = inSection(28); -pattern = /a.*c/; -string = 'axyzc'; -actualmatch = string.match(pattern); -expectedmatch = Array('axyzc'); -addThis(); - -status = inSection(29); -pattern = /a[bc]d/; -string = 'abd'; -actualmatch = string.match(pattern); -expectedmatch = Array('abd'); -addThis(); - -status = inSection(30); -pattern = /a[b-d]e/; -string = 'ace'; -actualmatch = string.match(pattern); -expectedmatch = Array('ace'); -addThis(); - -status = inSection(31); -pattern = /a[b-d]/; -string = 'aac'; -actualmatch = string.match(pattern); -expectedmatch = Array('ac'); -addThis(); - -status = inSection(32); -pattern = /a[-b]/; -string = 'a-'; -actualmatch = string.match(pattern); -expectedmatch = Array('a-'); -addThis(); - -status = inSection(33); -pattern = /a[b-]/; -string = 'a-'; -actualmatch = string.match(pattern); -expectedmatch = Array('a-'); -addThis(); - -status = inSection(34); -pattern = /a]/; -string = 'a]'; -actualmatch = string.match(pattern); -expectedmatch = Array('a]'); -addThis(); - -/* Perl supports ] & ^] inside a [], ECMA does not - pattern = /a[]]b/; - status = inSection(35); - string = 'a]b'; - actualmatch = string.match(pattern); - expectedmatch = Array('a]b'); - addThis(); -*/ - -status = inSection(36); -pattern = /a[^bc]d/; -string = 'aed'; -actualmatch = string.match(pattern); -expectedmatch = Array('aed'); -addThis(); - -status = inSection(37); -pattern = /a[^-b]c/; -string = 'adc'; -actualmatch = string.match(pattern); -expectedmatch = Array('adc'); -addThis(); - -/* Perl supports ] & ^] inside a [], ECMA does not - status = inSection(38); - pattern = /a[^]b]c/; - string = 'adc'; - actualmatch = string.match(pattern); - expectedmatch = Array('adc'); - addThis(); -*/ - -status = inSection(39); -pattern = /\ba\b/; -string = 'a-'; -actualmatch = string.match(pattern); -expectedmatch = Array('a'); -addThis(); - -status = inSection(40); -pattern = /\ba\b/; -string = '-a'; -actualmatch = string.match(pattern); -expectedmatch = Array('a'); -addThis(); - -status = inSection(41); -pattern = /\ba\b/; -string = '-a-'; -actualmatch = string.match(pattern); -expectedmatch = Array('a'); -addThis(); - -status = inSection(42); -pattern = /\By\b/; -string = 'xy'; -actualmatch = string.match(pattern); -expectedmatch = Array('y'); -addThis(); - -status = inSection(43); -pattern = /\by\B/; -string = 'yz'; -actualmatch = string.match(pattern); -expectedmatch = Array('y'); -addThis(); - -status = inSection(44); -pattern = /\By\B/; -string = 'xyz'; -actualmatch = string.match(pattern); -expectedmatch = Array('y'); -addThis(); - -status = inSection(45); -pattern = /\w/; -string = 'a'; -actualmatch = string.match(pattern); -expectedmatch = Array('a'); -addThis(); - -status = inSection(46); -pattern = /\W/; -string = '-'; -actualmatch = string.match(pattern); -expectedmatch = Array('-'); -addThis(); - -status = inSection(47); -pattern = /a\Sb/; -string = 'a-b'; -actualmatch = string.match(pattern); -expectedmatch = Array('a-b'); -addThis(); - -status = inSection(48); -pattern = /\d/; -string = '1'; -actualmatch = string.match(pattern); -expectedmatch = Array('1'); -addThis(); - -status = inSection(49); -pattern = /\D/; -string = '-'; -actualmatch = string.match(pattern); -expectedmatch = Array('-'); -addThis(); - -status = inSection(50); -pattern = /[\w]/; -string = 'a'; -actualmatch = string.match(pattern); -expectedmatch = Array('a'); -addThis(); - -status = inSection(51); -pattern = /[\W]/; -string = '-'; -actualmatch = string.match(pattern); -expectedmatch = Array('-'); -addThis(); - -status = inSection(52); -pattern = /a[\S]b/; -string = 'a-b'; -actualmatch = string.match(pattern); -expectedmatch = Array('a-b'); -addThis(); - -status = inSection(53); -pattern = /[\d]/; -string = '1'; -actualmatch = string.match(pattern); -expectedmatch = Array('1'); -addThis(); - -status = inSection(54); -pattern = /[\D]/; -string = '-'; -actualmatch = string.match(pattern); -expectedmatch = Array('-'); -addThis(); - -status = inSection(55); -pattern = /ab|cd/; -string = 'abc'; -actualmatch = string.match(pattern); -expectedmatch = Array('ab'); -addThis(); - -status = inSection(56); -pattern = /ab|cd/; -string = 'abcd'; -actualmatch = string.match(pattern); -expectedmatch = Array('ab'); -addThis(); - -status = inSection(57); -pattern = /()ef/; -string = 'def'; -actualmatch = string.match(pattern); -expectedmatch = Array('ef', ''); -addThis(); - -status = inSection(58); -pattern = /a\(b/; -string = 'a(b'; -actualmatch = string.match(pattern); -expectedmatch = Array('a(b'); -addThis(); - -status = inSection(59); -pattern = /a\(*b/; -string = 'ab'; -actualmatch = string.match(pattern); -expectedmatch = Array('ab'); -addThis(); - -status = inSection(60); -pattern = /a\(*b/; -string = 'a((b'; -actualmatch = string.match(pattern); -expectedmatch = Array('a((b'); -addThis(); - -status = inSection(61); -pattern = /a\\b/; -string = 'a\\b'; -actualmatch = string.match(pattern); -expectedmatch = Array('a\\b'); -addThis(); - -status = inSection(62); -pattern = /((a))/; -string = 'abc'; -actualmatch = string.match(pattern); -expectedmatch = Array('a', 'a', 'a'); -addThis(); - -status = inSection(63); -pattern = /(a)b(c)/; -string = 'abc'; -actualmatch = string.match(pattern); -expectedmatch = Array('abc', 'a', 'c'); -addThis(); - -status = inSection(64); -pattern = /a+b+c/; -string = 'aabbabc'; -actualmatch = string.match(pattern); -expectedmatch = Array('abc'); -addThis(); - -status = inSection(65); -pattern = /a{1,}b{1,}c/; -string = 'aabbabc'; -actualmatch = string.match(pattern); -expectedmatch = Array('abc'); -addThis(); - -status = inSection(66); -pattern = /a.+?c/; -string = 'abcabc'; -actualmatch = string.match(pattern); -expectedmatch = Array('abc'); -addThis(); - -status = inSection(67); -pattern = /(a+|b)*/; -string = 'ab'; -actualmatch = string.match(pattern); -expectedmatch = Array('ab', 'b'); -addThis(); - -status = inSection(68); -pattern = /(a+|b){0,}/; -string = 'ab'; -actualmatch = string.match(pattern); -expectedmatch = Array('ab', 'b'); -addThis(); - -status = inSection(69); -pattern = /(a+|b)+/; -string = 'ab'; -actualmatch = string.match(pattern); -expectedmatch = Array('ab', 'b'); -addThis(); - -status = inSection(70); -pattern = /(a+|b){1,}/; -string = 'ab'; -actualmatch = string.match(pattern); -expectedmatch = Array('ab', 'b'); -addThis(); - -status = inSection(71); -pattern = /(a+|b)?/; -string = 'ab'; -actualmatch = string.match(pattern); -expectedmatch = Array('a', 'a'); -addThis(); - -status = inSection(72); -pattern = /(a+|b){0,1}/; -string = 'ab'; -actualmatch = string.match(pattern); -expectedmatch = Array('a', 'a'); -addThis(); - -status = inSection(73); -pattern = /[^ab]*/; -string = 'cde'; -actualmatch = string.match(pattern); -expectedmatch = Array('cde'); -addThis(); - -status = inSection(74); -pattern = /([abc])*d/; -string = 'abbbcd'; -actualmatch = string.match(pattern); -expectedmatch = Array('abbbcd', 'c'); -addThis(); - -status = inSection(75); -pattern = /([abc])*bcd/; -string = 'abcd'; -actualmatch = string.match(pattern); -expectedmatch = Array('abcd', 'a'); -addThis(); - -status = inSection(76); -pattern = /a|b|c|d|e/; -string = 'e'; -actualmatch = string.match(pattern); -expectedmatch = Array('e'); -addThis(); - -status = inSection(77); -pattern = /(a|b|c|d|e)f/; -string = 'ef'; -actualmatch = string.match(pattern); -expectedmatch = Array('ef', 'e'); -addThis(); - -status = inSection(78); -pattern = /abcd*efg/; -string = 'abcdefg'; -actualmatch = string.match(pattern); -expectedmatch = Array('abcdefg'); -addThis(); - -status = inSection(79); -pattern = /ab*/; -string = 'xabyabbbz'; -actualmatch = string.match(pattern); -expectedmatch = Array('ab'); -addThis(); - -status = inSection(80); -pattern = /ab*/; -string = 'xayabbbz'; -actualmatch = string.match(pattern); -expectedmatch = Array('a'); -addThis(); - -status = inSection(81); -pattern = /(ab|cd)e/; -string = 'abcde'; -actualmatch = string.match(pattern); -expectedmatch = Array('cde', 'cd'); -addThis(); - -status = inSection(82); -pattern = /[abhgefdc]ij/; -string = 'hij'; -actualmatch = string.match(pattern); -expectedmatch = Array('hij'); -addThis(); - -status = inSection(83); -pattern = /(abc|)ef/; -string = 'abcdef'; -actualmatch = string.match(pattern); -expectedmatch = Array('ef', ''); -addThis(); - -status = inSection(84); -pattern = /(a|b)c*d/; -string = 'abcd'; -actualmatch = string.match(pattern); -expectedmatch = Array('bcd', 'b'); -addThis(); - -status = inSection(85); -pattern = /(ab|ab*)bc/; -string = 'abc'; -actualmatch = string.match(pattern); -expectedmatch = Array('abc', 'a'); -addThis(); - -status = inSection(86); -pattern = /a([bc]*)c*/; -string = 'abc'; -actualmatch = string.match(pattern); -expectedmatch = Array('abc', 'bc'); -addThis(); - -status = inSection(87); -pattern = /a([bc]*)(c*d)/; -string = 'abcd'; -actualmatch = string.match(pattern); -expectedmatch = Array('abcd', 'bc', 'd'); -addThis(); - -status = inSection(88); -pattern = /a([bc]+)(c*d)/; -string = 'abcd'; -actualmatch = string.match(pattern); -expectedmatch = Array('abcd', 'bc', 'd'); -addThis(); - -status = inSection(89); -pattern = /a([bc]*)(c+d)/; -string = 'abcd'; -actualmatch = string.match(pattern); -expectedmatch = Array('abcd', 'b', 'cd'); -addThis(); - -status = inSection(90); -pattern = /a[bcd]*dcdcde/; -string = 'adcdcde'; -actualmatch = string.match(pattern); -expectedmatch = Array('adcdcde'); -addThis(); - -status = inSection(91); -pattern = /(ab|a)b*c/; -string = 'abc'; -actualmatch = string.match(pattern); -expectedmatch = Array('abc', 'ab'); -addThis(); - -status = inSection(92); -pattern = /((a)(b)c)(d)/; -string = 'abcd'; -actualmatch = string.match(pattern); -expectedmatch = Array('abcd', 'abc', 'a', 'b', 'd'); -addThis(); - -status = inSection(93); -pattern = /[a-zA-Z_][a-zA-Z0-9_]*/; -string = 'alpha'; -actualmatch = string.match(pattern); -expectedmatch = Array('alpha'); -addThis(); - -status = inSection(94); -pattern = /^a(bc+|b[eh])g|.h$/; -string = 'abh'; -actualmatch = string.match(pattern); -expectedmatch = Array('bh', undefined); -addThis(); - -status = inSection(95); -pattern = /(bc+d$|ef*g.|h?i(j|k))/; -string = 'effgz'; -actualmatch = string.match(pattern); -expectedmatch = Array('effgz', 'effgz', undefined); -addThis(); - -status = inSection(96); -pattern = /(bc+d$|ef*g.|h?i(j|k))/; -string = 'ij'; -actualmatch = string.match(pattern); -expectedmatch = Array('ij', 'ij', 'j'); -addThis(); - -status = inSection(97); -pattern = /(bc+d$|ef*g.|h?i(j|k))/; -string = 'reffgz'; -actualmatch = string.match(pattern); -expectedmatch = Array('effgz', 'effgz', undefined); -addThis(); - -status = inSection(98); -pattern = /((((((((((a))))))))))/; -string = 'a'; -actualmatch = string.match(pattern); -expectedmatch = Array('a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a'); -addThis(); - -status = inSection(99); -pattern = /((((((((((a))))))))))\10/; -string = 'aa'; -actualmatch = string.match(pattern); -expectedmatch = Array('aa', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a'); -addThis(); - -status = inSection(100); -pattern = /((((((((((a))))))))))/; -string = 'a!'; -actualmatch = string.match(pattern); -expectedmatch = Array('a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a'); -addThis(); - -status = inSection(101); -pattern = /(((((((((a)))))))))/; -string = 'a'; -actualmatch = string.match(pattern); -expectedmatch = Array('a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a'); -addThis(); - -status = inSection(102); -pattern = /(.*)c(.*)/; -string = 'abcde'; -actualmatch = string.match(pattern); -expectedmatch = Array('abcde', 'ab', 'de'); -addThis(); - -status = inSection(103); -pattern = /abcd/; -string = 'abcd'; -actualmatch = string.match(pattern); -expectedmatch = Array('abcd'); -addThis(); - -status = inSection(104); -pattern = /a(bc)d/; -string = 'abcd'; -actualmatch = string.match(pattern); -expectedmatch = Array('abcd', 'bc'); -addThis(); - -status = inSection(105); -pattern = /a[-]?c/; -string = 'ac'; -actualmatch = string.match(pattern); -expectedmatch = Array('ac'); -addThis(); - -status = inSection(106); -pattern = /(abc)\1/; -string = 'abcabc'; -actualmatch = string.match(pattern); -expectedmatch = Array('abcabc', 'abc'); -addThis(); - -status = inSection(107); -pattern = /([a-c]*)\1/; -string = 'abcabc'; -actualmatch = string.match(pattern); -expectedmatch = Array('abcabc', 'abc'); -addThis(); - -status = inSection(108); -pattern = /(a)|\1/; -string = 'a'; -actualmatch = string.match(pattern); -expectedmatch = Array('a', 'a'); -addThis(); - -status = inSection(109); -pattern = /(([a-c])b*?\2)*/; -string = 'ababbbcbc'; -actualmatch = string.match(pattern); -expectedmatch = Array('ababb', 'bb', 'b'); -addThis(); - -status = inSection(110); -pattern = /(([a-c])b*?\2){3}/; -string = 'ababbbcbc'; -actualmatch = string.match(pattern); -expectedmatch = Array('ababbbcbc', 'cbc', 'c'); -addThis(); - -/* Can't refer to a capture before it's encountered & completed - status = inSection(111); - pattern = /((\3|b)\2(a)x)+/; - string = 'aaaxabaxbaaxbbax'; - actualmatch = string.match(pattern); - expectedmatch = Array('bbax', 'bbax', 'b', 'a'); - addThis(); - - status = inSection(112); - pattern = /((\3|b)\2(a)){2,}/; - string = 'bbaababbabaaaaabbaaaabba'; - actualmatch = string.match(pattern); - expectedmatch = Array('bbaaaabba', 'bba', 'b', 'a'); - addThis(); -*/ - -status = inSection(113); -pattern = /abc/i; -string = 'ABC'; -actualmatch = string.match(pattern); -expectedmatch = Array('ABC'); -addThis(); - -status = inSection(114); -pattern = /abc/i; -string = 'XABCY'; -actualmatch = string.match(pattern); -expectedmatch = Array('ABC'); -addThis(); - -status = inSection(115); -pattern = /abc/i; -string = 'ABABC'; -actualmatch = string.match(pattern); -expectedmatch = Array('ABC'); -addThis(); - -status = inSection(116); -pattern = /ab*c/i; -string = 'ABC'; -actualmatch = string.match(pattern); -expectedmatch = Array('ABC'); -addThis(); - -status = inSection(117); -pattern = /ab*bc/i; -string = 'ABC'; -actualmatch = string.match(pattern); -expectedmatch = Array('ABC'); -addThis(); - -status = inSection(118); -pattern = /ab*bc/i; -string = 'ABBC'; -actualmatch = string.match(pattern); -expectedmatch = Array('ABBC'); -addThis(); - -status = inSection(119); -pattern = /ab*?bc/i; -string = 'ABBBBC'; -actualmatch = string.match(pattern); -expectedmatch = Array('ABBBBC'); -addThis(); - -status = inSection(120); -pattern = /ab{0,}?bc/i; -string = 'ABBBBC'; -actualmatch = string.match(pattern); -expectedmatch = Array('ABBBBC'); -addThis(); - -status = inSection(121); -pattern = /ab+?bc/i; -string = 'ABBC'; -actualmatch = string.match(pattern); -expectedmatch = Array('ABBC'); -addThis(); - -status = inSection(122); -pattern = /ab+bc/i; -string = 'ABBBBC'; -actualmatch = string.match(pattern); -expectedmatch = Array('ABBBBC'); -addThis(); - -status = inSection(123); -pattern = /ab{1,}?bc/i; -string = 'ABBBBC'; -actualmatch = string.match(pattern); -expectedmatch = Array('ABBBBC'); -addThis(); - -status = inSection(124); -pattern = /ab{1,3}?bc/i; -string = 'ABBBBC'; -actualmatch = string.match(pattern); -expectedmatch = Array('ABBBBC'); -addThis(); - -status = inSection(125); -pattern = /ab{3,4}?bc/i; -string = 'ABBBBC'; -actualmatch = string.match(pattern); -expectedmatch = Array('ABBBBC'); -addThis(); - -status = inSection(126); -pattern = /ab??bc/i; -string = 'ABBC'; -actualmatch = string.match(pattern); -expectedmatch = Array('ABBC'); -addThis(); - -status = inSection(127); -pattern = /ab??bc/i; -string = 'ABC'; -actualmatch = string.match(pattern); -expectedmatch = Array('ABC'); -addThis(); - -status = inSection(128); -pattern = /ab{0,1}?bc/i; -string = 'ABC'; -actualmatch = string.match(pattern); -expectedmatch = Array('ABC'); -addThis(); - -status = inSection(129); -pattern = /ab??c/i; -string = 'ABC'; -actualmatch = string.match(pattern); -expectedmatch = Array('ABC'); -addThis(); - -status = inSection(130); -pattern = /ab{0,1}?c/i; -string = 'ABC'; -actualmatch = string.match(pattern); -expectedmatch = Array('ABC'); -addThis(); - -status = inSection(131); -pattern = /^abc$/i; -string = 'ABC'; -actualmatch = string.match(pattern); -expectedmatch = Array('ABC'); -addThis(); - -status = inSection(132); -pattern = /^abc/i; -string = 'ABCC'; -actualmatch = string.match(pattern); -expectedmatch = Array('ABC'); -addThis(); - -status = inSection(133); -pattern = /abc$/i; -string = 'AABC'; -actualmatch = string.match(pattern); -expectedmatch = Array('ABC'); -addThis(); - -status = inSection(134); -pattern = /^/i; -string = 'ABC'; -actualmatch = string.match(pattern); -expectedmatch = Array(''); -addThis(); - -status = inSection(135); -pattern = /$/i; -string = 'ABC'; -actualmatch = string.match(pattern); -expectedmatch = Array(''); -addThis(); - -status = inSection(136); -pattern = /a.c/i; -string = 'ABC'; -actualmatch = string.match(pattern); -expectedmatch = Array('ABC'); -addThis(); - -status = inSection(137); -pattern = /a.c/i; -string = 'AXC'; -actualmatch = string.match(pattern); -expectedmatch = Array('AXC'); -addThis(); - -status = inSection(138); -pattern = /a.*?c/i; -string = 'AXYZC'; -actualmatch = string.match(pattern); -expectedmatch = Array('AXYZC'); -addThis(); - -status = inSection(139); -pattern = /a[bc]d/i; -string = 'ABD'; -actualmatch = string.match(pattern); -expectedmatch = Array('ABD'); -addThis(); - -status = inSection(140); -pattern = /a[b-d]e/i; -string = 'ACE'; -actualmatch = string.match(pattern); -expectedmatch = Array('ACE'); -addThis(); - -status = inSection(141); -pattern = /a[b-d]/i; -string = 'AAC'; -actualmatch = string.match(pattern); -expectedmatch = Array('AC'); -addThis(); - -status = inSection(142); -pattern = /a[-b]/i; -string = 'A-'; -actualmatch = string.match(pattern); -expectedmatch = Array('A-'); -addThis(); - -status = inSection(143); -pattern = /a[b-]/i; -string = 'A-'; -actualmatch = string.match(pattern); -expectedmatch = Array('A-'); -addThis(); - -status = inSection(144); -pattern = /a]/i; -string = 'A]'; -actualmatch = string.match(pattern); -expectedmatch = Array('A]'); -addThis(); - -/* Perl supports ] & ^] inside a [], ECMA does not - status = inSection(145); - pattern = /a[]]b/i; - string = 'A]B'; - actualmatch = string.match(pattern); - expectedmatch = Array('A]B'); - addThis(); -*/ - -status = inSection(146); -pattern = /a[^bc]d/i; -string = 'AED'; -actualmatch = string.match(pattern); -expectedmatch = Array('AED'); -addThis(); - -status = inSection(147); -pattern = /a[^-b]c/i; -string = 'ADC'; -actualmatch = string.match(pattern); -expectedmatch = Array('ADC'); -addThis(); - -/* Perl supports ] & ^] inside a [], ECMA does not - status = inSection(148); - pattern = /a[^]b]c/i; - string = 'ADC'; - actualmatch = string.match(pattern); - expectedmatch = Array('ADC'); - addThis(); -*/ - -status = inSection(149); -pattern = /ab|cd/i; -string = 'ABC'; -actualmatch = string.match(pattern); -expectedmatch = Array('AB'); -addThis(); - -status = inSection(150); -pattern = /ab|cd/i; -string = 'ABCD'; -actualmatch = string.match(pattern); -expectedmatch = Array('AB'); -addThis(); - -status = inSection(151); -pattern = /()ef/i; -string = 'DEF'; -actualmatch = string.match(pattern); -expectedmatch = Array('EF', ''); -addThis(); - -status = inSection(152); -pattern = /a\(b/i; -string = 'A(B'; -actualmatch = string.match(pattern); -expectedmatch = Array('A(B'); -addThis(); - -status = inSection(153); -pattern = /a\(*b/i; -string = 'AB'; -actualmatch = string.match(pattern); -expectedmatch = Array('AB'); -addThis(); - -status = inSection(154); -pattern = /a\(*b/i; -string = 'A((B'; -actualmatch = string.match(pattern); -expectedmatch = Array('A((B'); -addThis(); - -status = inSection(155); -pattern = /a\\b/i; -string = 'A\\B'; -actualmatch = string.match(pattern); -expectedmatch = Array('A\\B'); -addThis(); - -status = inSection(156); -pattern = /((a))/i; -string = 'ABC'; -actualmatch = string.match(pattern); -expectedmatch = Array('A', 'A', 'A'); -addThis(); - -status = inSection(157); -pattern = /(a)b(c)/i; -string = 'ABC'; -actualmatch = string.match(pattern); -expectedmatch = Array('ABC', 'A', 'C'); -addThis(); - -status = inSection(158); -pattern = /a+b+c/i; -string = 'AABBABC'; -actualmatch = string.match(pattern); -expectedmatch = Array('ABC'); -addThis(); - -status = inSection(159); -pattern = /a{1,}b{1,}c/i; -string = 'AABBABC'; -actualmatch = string.match(pattern); -expectedmatch = Array('ABC'); -addThis(); - -status = inSection(160); -pattern = /a.+?c/i; -string = 'ABCABC'; -actualmatch = string.match(pattern); -expectedmatch = Array('ABC'); -addThis(); - -status = inSection(161); -pattern = /a.*?c/i; -string = 'ABCABC'; -actualmatch = string.match(pattern); -expectedmatch = Array('ABC'); -addThis(); - -status = inSection(162); -pattern = /a.{0,5}?c/i; -string = 'ABCABC'; -actualmatch = string.match(pattern); -expectedmatch = Array('ABC'); -addThis(); - -status = inSection(163); -pattern = /(a+|b)*/i; -string = 'AB'; -actualmatch = string.match(pattern); -expectedmatch = Array('AB', 'B'); -addThis(); - -status = inSection(164); -pattern = /(a+|b){0,}/i; -string = 'AB'; -actualmatch = string.match(pattern); -expectedmatch = Array('AB', 'B'); -addThis(); - -status = inSection(165); -pattern = /(a+|b)+/i; -string = 'AB'; -actualmatch = string.match(pattern); -expectedmatch = Array('AB', 'B'); -addThis(); - -status = inSection(166); -pattern = /(a+|b){1,}/i; -string = 'AB'; -actualmatch = string.match(pattern); -expectedmatch = Array('AB', 'B'); -addThis(); - -status = inSection(167); -pattern = /(a+|b)?/i; -string = 'AB'; -actualmatch = string.match(pattern); -expectedmatch = Array('A', 'A'); -addThis(); - -status = inSection(168); -pattern = /(a+|b){0,1}/i; -string = 'AB'; -actualmatch = string.match(pattern); -expectedmatch = Array('A', 'A'); -addThis(); - -status = inSection(169); -pattern = /(a+|b){0,1}?/i; -string = 'AB'; -actualmatch = string.match(pattern); -expectedmatch = Array('', undefined); -addThis(); - -status = inSection(170); -pattern = /[^ab]*/i; -string = 'CDE'; -actualmatch = string.match(pattern); -expectedmatch = Array('CDE'); -addThis(); - -status = inSection(171); -pattern = /([abc])*d/i; -string = 'ABBBCD'; -actualmatch = string.match(pattern); -expectedmatch = Array('ABBBCD', 'C'); -addThis(); - -status = inSection(172); -pattern = /([abc])*bcd/i; -string = 'ABCD'; -actualmatch = string.match(pattern); -expectedmatch = Array('ABCD', 'A'); -addThis(); - -status = inSection(173); -pattern = /a|b|c|d|e/i; -string = 'E'; -actualmatch = string.match(pattern); -expectedmatch = Array('E'); -addThis(); - -status = inSection(174); -pattern = /(a|b|c|d|e)f/i; -string = 'EF'; -actualmatch = string.match(pattern); -expectedmatch = Array('EF', 'E'); -addThis(); - -status = inSection(175); -pattern = /abcd*efg/i; -string = 'ABCDEFG'; -actualmatch = string.match(pattern); -expectedmatch = Array('ABCDEFG'); -addThis(); - -status = inSection(176); -pattern = /ab*/i; -string = 'XABYABBBZ'; -actualmatch = string.match(pattern); -expectedmatch = Array('AB'); -addThis(); - -status = inSection(177); -pattern = /ab*/i; -string = 'XAYABBBZ'; -actualmatch = string.match(pattern); -expectedmatch = Array('A'); -addThis(); - -status = inSection(178); -pattern = /(ab|cd)e/i; -string = 'ABCDE'; -actualmatch = string.match(pattern); -expectedmatch = Array('CDE', 'CD'); -addThis(); - -status = inSection(179); -pattern = /[abhgefdc]ij/i; -string = 'HIJ'; -actualmatch = string.match(pattern); -expectedmatch = Array('HIJ'); -addThis(); - -status = inSection(180); -pattern = /(abc|)ef/i; -string = 'ABCDEF'; -actualmatch = string.match(pattern); -expectedmatch = Array('EF', ''); -addThis(); - -status = inSection(181); -pattern = /(a|b)c*d/i; -string = 'ABCD'; -actualmatch = string.match(pattern); -expectedmatch = Array('BCD', 'B'); -addThis(); - -status = inSection(182); -pattern = /(ab|ab*)bc/i; -string = 'ABC'; -actualmatch = string.match(pattern); -expectedmatch = Array('ABC', 'A'); -addThis(); - -status = inSection(183); -pattern = /a([bc]*)c*/i; -string = 'ABC'; -actualmatch = string.match(pattern); -expectedmatch = Array('ABC', 'BC'); -addThis(); - -status = inSection(184); -pattern = /a([bc]*)(c*d)/i; -string = 'ABCD'; -actualmatch = string.match(pattern); -expectedmatch = Array('ABCD', 'BC', 'D'); -addThis(); - -status = inSection(185); -pattern = /a([bc]+)(c*d)/i; -string = 'ABCD'; -actualmatch = string.match(pattern); -expectedmatch = Array('ABCD', 'BC', 'D'); -addThis(); - -status = inSection(186); -pattern = /a([bc]*)(c+d)/i; -string = 'ABCD'; -actualmatch = string.match(pattern); -expectedmatch = Array('ABCD', 'B', 'CD'); -addThis(); - -status = inSection(187); -pattern = /a[bcd]*dcdcde/i; -string = 'ADCDCDE'; -actualmatch = string.match(pattern); -expectedmatch = Array('ADCDCDE'); -addThis(); - -status = inSection(188); -pattern = /(ab|a)b*c/i; -string = 'ABC'; -actualmatch = string.match(pattern); -expectedmatch = Array('ABC', 'AB'); -addThis(); - -status = inSection(189); -pattern = /((a)(b)c)(d)/i; -string = 'ABCD'; -actualmatch = string.match(pattern); -expectedmatch = Array('ABCD', 'ABC', 'A', 'B', 'D'); -addThis(); - -status = inSection(190); -pattern = /[a-zA-Z_][a-zA-Z0-9_]*/i; -string = 'ALPHA'; -actualmatch = string.match(pattern); -expectedmatch = Array('ALPHA'); -addThis(); - -status = inSection(191); -pattern = /^a(bc+|b[eh])g|.h$/i; -string = 'ABH'; -actualmatch = string.match(pattern); -expectedmatch = Array('BH', undefined); -addThis(); - -status = inSection(192); -pattern = /(bc+d$|ef*g.|h?i(j|k))/i; -string = 'EFFGZ'; -actualmatch = string.match(pattern); -expectedmatch = Array('EFFGZ', 'EFFGZ', undefined); -addThis(); - -status = inSection(193); -pattern = /(bc+d$|ef*g.|h?i(j|k))/i; -string = 'IJ'; -actualmatch = string.match(pattern); -expectedmatch = Array('IJ', 'IJ', 'J'); -addThis(); - -status = inSection(194); -pattern = /(bc+d$|ef*g.|h?i(j|k))/i; -string = 'REFFGZ'; -actualmatch = string.match(pattern); -expectedmatch = Array('EFFGZ', 'EFFGZ', undefined); -addThis(); - -status = inSection(195); -pattern = /((((((((((a))))))))))/i; -string = 'A'; -actualmatch = string.match(pattern); -expectedmatch = Array('A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A'); -addThis(); - -status = inSection(196); -pattern = /((((((((((a))))))))))\10/i; -string = 'AA'; -actualmatch = string.match(pattern); -expectedmatch = Array('AA', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A'); -addThis(); - -status = inSection(197); -pattern = /((((((((((a))))))))))/i; -string = 'A!'; -actualmatch = string.match(pattern); -expectedmatch = Array('A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A'); -addThis(); - -status = inSection(198); -pattern = /(((((((((a)))))))))/i; -string = 'A'; -actualmatch = string.match(pattern); -expectedmatch = Array('A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A'); -addThis(); - -status = inSection(199); -pattern = /(?:(?:(?:(?:(?:(?:(?:(?:(?:(a))))))))))/i; -string = 'A'; -actualmatch = string.match(pattern); -expectedmatch = Array('A', 'A'); -addThis(); - -status = inSection(200); -pattern = /(?:(?:(?:(?:(?:(?:(?:(?:(?:(a|b|c))))))))))/i; -string = 'C'; -actualmatch = string.match(pattern); -expectedmatch = Array('C', 'C'); -addThis(); - -status = inSection(201); -pattern = /(.*)c(.*)/i; -string = 'ABCDE'; -actualmatch = string.match(pattern); -expectedmatch = Array('ABCDE', 'AB', 'DE'); -addThis(); - -status = inSection(202); -pattern = /abcd/i; -string = 'ABCD'; -actualmatch = string.match(pattern); -expectedmatch = Array('ABCD'); -addThis(); - -status = inSection(203); -pattern = /a(bc)d/i; -string = 'ABCD'; -actualmatch = string.match(pattern); -expectedmatch = Array('ABCD', 'BC'); -addThis(); - -status = inSection(204); -pattern = /a[-]?c/i; -string = 'AC'; -actualmatch = string.match(pattern); -expectedmatch = Array('AC'); -addThis(); - -status = inSection(205); -pattern = /(abc)\1/i; -string = 'ABCABC'; -actualmatch = string.match(pattern); -expectedmatch = Array('ABCABC', 'ABC'); -addThis(); - -status = inSection(206); -pattern = /([a-c]*)\1/i; -string = 'ABCABC'; -actualmatch = string.match(pattern); -expectedmatch = Array('ABCABC', 'ABC'); -addThis(); - -status = inSection(207); -pattern = /a(?!b)./; -string = 'abad'; -actualmatch = string.match(pattern); -expectedmatch = Array('ad'); -addThis(); - -status = inSection(208); -pattern = /a(?=d)./; -string = 'abad'; -actualmatch = string.match(pattern); -expectedmatch = Array('ad'); -addThis(); - -status = inSection(209); -pattern = /a(?=c|d)./; -string = 'abad'; -actualmatch = string.match(pattern); -expectedmatch = Array('ad'); -addThis(); - -status = inSection(210); -pattern = /a(?:b|c|d)(.)/; -string = 'ace'; -actualmatch = string.match(pattern); -expectedmatch = Array('ace', 'e'); -addThis(); - -status = inSection(211); -pattern = /a(?:b|c|d)*(.)/; -string = 'ace'; -actualmatch = string.match(pattern); -expectedmatch = Array('ace', 'e'); -addThis(); - -status = inSection(212); -pattern = /a(?:b|c|d)+?(.)/; -string = 'ace'; -actualmatch = string.match(pattern); -expectedmatch = Array('ace', 'e'); -addThis(); - -status = inSection(213); -pattern = /a(?:b|c|d)+?(.)/; -string = 'acdbcdbe'; -actualmatch = string.match(pattern); -expectedmatch = Array('acd', 'd'); -addThis(); - -status = inSection(214); -pattern = /a(?:b|c|d)+(.)/; -string = 'acdbcdbe'; -actualmatch = string.match(pattern); -expectedmatch = Array('acdbcdbe', 'e'); -addThis(); - -status = inSection(215); -pattern = /a(?:b|c|d){2}(.)/; -string = 'acdbcdbe'; -actualmatch = string.match(pattern); -expectedmatch = Array('acdb', 'b'); -addThis(); - -status = inSection(216); -pattern = /a(?:b|c|d){4,5}(.)/; -string = 'acdbcdbe'; -actualmatch = string.match(pattern); -expectedmatch = Array('acdbcdb', 'b'); -addThis(); - -status = inSection(217); -pattern = /a(?:b|c|d){4,5}?(.)/; -string = 'acdbcdbe'; -actualmatch = string.match(pattern); -expectedmatch = Array('acdbcd', 'd'); -addThis(); - -// MODIFIED - ECMA has different rules for paren contents -status = inSection(218); -pattern = /((foo)|(bar))*/; -string = 'foobar'; -actualmatch = string.match(pattern); -//expectedmatch = Array('foobar', 'bar', 'foo', 'bar'); -expectedmatch = Array('foobar', 'bar', undefined, 'bar'); -addThis(); - -status = inSection(219); -pattern = /a(?:b|c|d){6,7}(.)/; -string = 'acdbcdbe'; -actualmatch = string.match(pattern); -expectedmatch = Array('acdbcdbe', 'e'); -addThis(); - -status = inSection(220); -pattern = /a(?:b|c|d){6,7}?(.)/; -string = 'acdbcdbe'; -actualmatch = string.match(pattern); -expectedmatch = Array('acdbcdbe', 'e'); -addThis(); - -status = inSection(221); -pattern = /a(?:b|c|d){5,6}(.)/; -string = 'acdbcdbe'; -actualmatch = string.match(pattern); -expectedmatch = Array('acdbcdbe', 'e'); -addThis(); - -status = inSection(222); -pattern = /a(?:b|c|d){5,6}?(.)/; -string = 'acdbcdbe'; -actualmatch = string.match(pattern); -expectedmatch = Array('acdbcdb', 'b'); -addThis(); - -status = inSection(223); -pattern = /a(?:b|c|d){5,7}(.)/; -string = 'acdbcdbe'; -actualmatch = string.match(pattern); -expectedmatch = Array('acdbcdbe', 'e'); -addThis(); - -status = inSection(224); -pattern = /a(?:b|c|d){5,7}?(.)/; -string = 'acdbcdbe'; -actualmatch = string.match(pattern); -expectedmatch = Array('acdbcdb', 'b'); -addThis(); - -status = inSection(225); -pattern = /a(?:b|(c|e){1,2}?|d)+?(.)/; -string = 'ace'; -actualmatch = string.match(pattern); -expectedmatch = Array('ace', 'c', 'e'); -addThis(); - -status = inSection(226); -pattern = /^(.+)?B/; -string = 'AB'; -actualmatch = string.match(pattern); -expectedmatch = Array('AB', 'A'); -addThis(); - -/* MODIFIED - ECMA has different rules for paren contents */ -status = inSection(227); -pattern = /^([^a-z])|(\^)$/; -string = '.'; -actualmatch = string.match(pattern); -//expectedmatch = Array('.', '.', ''); -expectedmatch = Array('.', '.', undefined); -addThis(); - -status = inSection(228); -pattern = /^[<>]&/; -string = '<&OUT'; -actualmatch = string.match(pattern); -expectedmatch = Array('<&'); -addThis(); - -/* Can't refer to a capture before it's encountered & completed - status = inSection(229); - pattern = /^(a\1?){4}$/; - string = 'aaaaaaaaaa'; - actualmatch = string.match(pattern); - expectedmatch = Array('aaaaaaaaaa', 'aaaa'); - addThis(); - - status = inSection(230); - pattern = /^(a(?(1)\1)){4}$/; - string = 'aaaaaaaaaa'; - actualmatch = string.match(pattern); - expectedmatch = Array('aaaaaaaaaa', 'aaaa'); - addThis(); -*/ - -status = inSection(231); -pattern = /((a{4})+)/; -string = 'aaaaaaaaa'; -actualmatch = string.match(pattern); -expectedmatch = Array('aaaaaaaa', 'aaaaaaaa', 'aaaa'); -addThis(); - -status = inSection(232); -pattern = /(((aa){2})+)/; -string = 'aaaaaaaaaa'; -actualmatch = string.match(pattern); -expectedmatch = Array('aaaaaaaa', 'aaaaaaaa', 'aaaa', 'aa'); -addThis(); - -status = inSection(233); -pattern = /(((a{2}){2})+)/; -string = 'aaaaaaaaaa'; -actualmatch = string.match(pattern); -expectedmatch = Array('aaaaaaaa', 'aaaaaaaa', 'aaaa', 'aa'); -addThis(); - -status = inSection(234); -pattern = /(?:(f)(o)(o)|(b)(a)(r))*/; -string = 'foobar'; -actualmatch = string.match(pattern); -//expectedmatch = Array('foobar', 'f', 'o', 'o', 'b', 'a', 'r'); -expectedmatch = Array('foobar', undefined, undefined, undefined, 'b', 'a', 'r'); -addThis(); - -/* ECMA supports (?: (?= and (?! but doesn't support (?< etc. - status = inSection(235); - pattern = /(?<=a)b/; - string = 'ab'; - actualmatch = string.match(pattern); - expectedmatch = Array('b'); - addThis(); - - status = inSection(236); - pattern = /(? - status = inSection(311); - pattern = /(?>a+)b/; - string = 'aaab'; - actualmatch = string.match(pattern); - expectedmatch = Array('aaab'); - addThis(); -*/ - -status = inSection(312); -pattern = /([[:]+)/; - string = 'a:[b]:'; - actualmatch = string.match(pattern); - expectedmatch = Array(':[', ':['); - addThis(); - - status = inSection(313); - pattern = /([[=]+)/; - string = 'a=[b]='; - actualmatch = string.match(pattern); - expectedmatch = Array('=[', '=['); - addThis(); - - status = inSection(314); - pattern = /([[.]+)/; - string = 'a.[b].'; - actualmatch = string.match(pattern); - expectedmatch = Array('.[', '.['); - addThis(); - -/* ECMA doesn't have rules for [: - status = inSection(315); - pattern = /[a[:]b[:c]/; - string = 'abc'; - actualmatch = string.match(pattern); - expectedmatch = Array('abc'); - addThis(); -*/ - -/* ECMA doesn't support (?> - status = inSection(316); - pattern = /((?>a+)b)/; - string = 'aaab'; - actualmatch = string.match(pattern); - expectedmatch = Array('aaab', 'aaab'); - addThis(); - - status = inSection(317); - pattern = /(?>(a+))b/; - string = 'aaab'; - actualmatch = string.match(pattern); - expectedmatch = Array('aaab', 'aaa'); - addThis(); - - status = inSection(318); - pattern = /((?>[^()]+)|\([^()]*\))+/; - string = '((abc(ade)ufh()()x'; - actualmatch = string.match(pattern); - expectedmatch = Array('abc(ade)ufh()()x', 'x'); - addThis(); -*/ - -/* Perl has \Z has end-of-line, ECMA doesn't - status = inSection(319); - pattern = /\Z/; - string = 'a\nb\n'; - actualmatch = string.match(pattern); - expectedmatch = Array(''); - addThis(); - - status = inSection(320); - pattern = /\z/; - string = 'a\nb\n'; - actualmatch = string.match(pattern); - expectedmatch = Array(''); - addThis(); -*/ - - status = inSection(321); - pattern = /$/; - string = 'a\nb\n'; - actualmatch = string.match(pattern); - expectedmatch = Array(''); - addThis(); - -/* Perl has \Z has end-of-line, ECMA doesn't - status = inSection(322); - pattern = /\Z/; - string = 'b\na\n'; - actualmatch = string.match(pattern); - expectedmatch = Array(''); - addThis(); - - status = inSection(323); - pattern = /\z/; - string = 'b\na\n'; - actualmatch = string.match(pattern); - expectedmatch = Array(''); - addThis(); -*/ - - status = inSection(324); - pattern = /$/; - string = 'b\na\n'; - actualmatch = string.match(pattern); - expectedmatch = Array(''); - addThis(); - -/* Perl has \Z has end-of-line, ECMA doesn't - status = inSection(325); - pattern = /\Z/; - string = 'b\na'; - actualmatch = string.match(pattern); - expectedmatch = Array(''); - addThis(); - - status = inSection(326); - pattern = /\z/; - string = 'b\na'; - actualmatch = string.match(pattern); - expectedmatch = Array(''); - addThis(); -*/ - - status = inSection(327); - pattern = /$/; - string = 'b\na'; - actualmatch = string.match(pattern); - expectedmatch = Array(''); - addThis(); - -/* Perl has \Z has end-of-line, ECMA doesn't - status = inSection(328); - pattern = /\Z/m; - string = 'a\nb\n'; - actualmatch = string.match(pattern); - expectedmatch = Array(''); - addThis(); - - status = inSection(329); - pattern = /\z/m; - string = 'a\nb\n'; - actualmatch = string.match(pattern); - expectedmatch = Array(''); - addThis(); -*/ - - status = inSection(330); - pattern = /$/m; - string = 'a\nb\n'; - actualmatch = string.match(pattern); - expectedmatch = Array(''); - addThis(); - -/* Perl has \Z has end-of-line, ECMA doesn't - status = inSection(331); - pattern = /\Z/m; - string = 'b\na\n'; - actualmatch = string.match(pattern); - expectedmatch = Array(''); - addThis(); - - status = inSection(332); - pattern = /\z/m; - string = 'b\na\n'; - actualmatch = string.match(pattern); - expectedmatch = Array(''); - addThis(); -*/ - - status = inSection(333); - pattern = /$/m; - string = 'b\na\n'; - actualmatch = string.match(pattern); - expectedmatch = Array(''); - addThis(); - -/* Perl has \Z has end-of-line, ECMA doesn't - status = inSection(334); - pattern = /\Z/m; - string = 'b\na'; - actualmatch = string.match(pattern); - expectedmatch = Array(''); - addThis(); - - status = inSection(335); - pattern = /\z/m; - string = 'b\na'; - actualmatch = string.match(pattern); - expectedmatch = Array(''); - addThis(); -*/ - - status = inSection(336); - pattern = /$/m; - string = 'b\na'; - actualmatch = string.match(pattern); - expectedmatch = Array(''); - addThis(); - -/* Perl has \Z has end-of-line, ECMA doesn't - status = inSection(337); - pattern = /a\Z/; - string = 'b\na\n'; - actualmatch = string.match(pattern); - expectedmatch = Array('a'); - addThis(); -*/ - -/* $ only matches end of input unless multiline - status = inSection(338); - pattern = /a$/; - string = 'b\na\n'; - actualmatch = string.match(pattern); - expectedmatch = Array('a'); - addThis(); -*/ - -/* Perl has \Z has end-of-line, ECMA doesn't - status = inSection(339); - pattern = /a\Z/; - string = 'b\na'; - actualmatch = string.match(pattern); - expectedmatch = Array('a'); - addThis(); - - status = inSection(340); - pattern = /a\z/; - string = 'b\na'; - actualmatch = string.match(pattern); - expectedmatch = Array('a'); - addThis(); -*/ - - status = inSection(341); - pattern = /a$/; - string = 'b\na'; - actualmatch = string.match(pattern); - expectedmatch = Array('a'); - addThis(); - - status = inSection(342); - pattern = /a$/m; - string = 'a\nb\n'; - actualmatch = string.match(pattern); - expectedmatch = Array('a'); - addThis(); - -/* Perl has \Z has end-of-line, ECMA doesn't - status = inSection(343); - pattern = /a\Z/m; - string = 'b\na\n'; - actualmatch = string.match(pattern); - expectedmatch = Array('a'); - addThis(); -*/ - - status = inSection(344); - pattern = /a$/m; - string = 'b\na\n'; - actualmatch = string.match(pattern); - expectedmatch = Array('a'); - addThis(); - -/* Perl has \Z has end-of-line, ECMA doesn't - status = inSection(345); - pattern = /a\Z/m; - string = 'b\na'; - actualmatch = string.match(pattern); - expectedmatch = Array('a'); - addThis(); - - status = inSection(346); - pattern = /a\z/m; - string = 'b\na'; - actualmatch = string.match(pattern); - expectedmatch = Array('a'); - addThis(); -*/ - - status = inSection(347); - pattern = /a$/m; - string = 'b\na'; - actualmatch = string.match(pattern); - expectedmatch = Array('a'); - addThis(); - -/* Perl has \Z has end-of-line, ECMA doesn't - status = inSection(348); - pattern = /aa\Z/; - string = 'b\naa\n'; - actualmatch = string.match(pattern); - expectedmatch = Array('aa'); - addThis(); -*/ - -/* $ only matches end of input unless multiline - status = inSection(349); - pattern = /aa$/; - string = 'b\naa\n'; - actualmatch = string.match(pattern); - expectedmatch = Array('aa'); - addThis(); -*/ - -/* Perl has \Z has end-of-line, ECMA doesn't - status = inSection(350); - pattern = /aa\Z/; - string = 'b\naa'; - actualmatch = string.match(pattern); - expectedmatch = Array('aa'); - addThis(); - - status = inSection(351); - pattern = /aa\z/; - string = 'b\naa'; - actualmatch = string.match(pattern); - expectedmatch = Array('aa'); - addThis(); -*/ - - status = inSection(352); - pattern = /aa$/; - string = 'b\naa'; - actualmatch = string.match(pattern); - expectedmatch = Array('aa'); - addThis(); - - status = inSection(353); - pattern = /aa$/m; - string = 'aa\nb\n'; - actualmatch = string.match(pattern); - expectedmatch = Array('aa'); - addThis(); - -/* Perl has \Z has end-of-line, ECMA doesn't - status = inSection(354); - pattern = /aa\Z/m; - string = 'b\naa\n'; - actualmatch = string.match(pattern); - expectedmatch = Array('aa'); - addThis(); -*/ - - status = inSection(355); - pattern = /aa$/m; - string = 'b\naa\n'; - actualmatch = string.match(pattern); - expectedmatch = Array('aa'); - addThis(); - -/* Perl has \Z has end-of-line, ECMA doesn't - status = inSection(356); - pattern = /aa\Z/m; - string = 'b\naa'; - actualmatch = string.match(pattern); - expectedmatch = Array('aa'); - addThis(); - - status = inSection(357); - pattern = /aa\z/m; - string = 'b\naa'; - actualmatch = string.match(pattern); - expectedmatch = Array('aa'); - addThis(); -*/ - - status = inSection(358); - pattern = /aa$/m; - string = 'b\naa'; - actualmatch = string.match(pattern); - expectedmatch = Array('aa'); - addThis(); - -/* Perl has \Z has end-of-line, ECMA doesn't - status = inSection(359); - pattern = /ab\Z/; - string = 'b\nab\n'; - actualmatch = string.match(pattern); - expectedmatch = Array('ab'); - addThis(); -*/ - -/* $ only matches end of input unless multiline - status = inSection(360); - pattern = /ab$/; - string = 'b\nab\n'; - actualmatch = string.match(pattern); - expectedmatch = Array('ab'); - addThis(); -*/ - -/* Perl has \Z has end-of-line, ECMA doesn't - status = inSection(361); - pattern = /ab\Z/; - string = 'b\nab'; - actualmatch = string.match(pattern); - expectedmatch = Array('ab'); - addThis(); - - status = inSection(362); - pattern = /ab\z/; - string = 'b\nab'; - actualmatch = string.match(pattern); - expectedmatch = Array('ab'); - addThis(); -*/ - - status = inSection(363); - pattern = /ab$/; - string = 'b\nab'; - actualmatch = string.match(pattern); - expectedmatch = Array('ab'); - addThis(); - - status = inSection(364); - pattern = /ab$/m; - string = 'ab\nb\n'; - actualmatch = string.match(pattern); - expectedmatch = Array('ab'); - addThis(); - -/* Perl has \Z has end-of-line, ECMA doesn't - status = inSection(365); - pattern = /ab\Z/m; - string = 'b\nab\n'; - actualmatch = string.match(pattern); - expectedmatch = Array('ab'); - addThis(); -*/ - - status = inSection(366); - pattern = /ab$/m; - string = 'b\nab\n'; - actualmatch = string.match(pattern); - expectedmatch = Array('ab'); - addThis(); - -/* Perl has \Z has end-of-line, ECMA doesn't - status = inSection(367); - pattern = /ab\Z/m; - string = 'b\nab'; - actualmatch = string.match(pattern); - expectedmatch = Array('ab'); - addThis(); - - status = inSection(368); - pattern = /ab\z/m; - string = 'b\nab'; - actualmatch = string.match(pattern); - expectedmatch = Array('ab'); - addThis(); -*/ - - status = inSection(369); - pattern = /ab$/m; - string = 'b\nab'; - actualmatch = string.match(pattern); - expectedmatch = Array('ab'); - addThis(); - -/* Perl has \Z has end-of-line, ECMA doesn't - status = inSection(370); - pattern = /abb\Z/; - string = 'b\nabb\n'; - actualmatch = string.match(pattern); - expectedmatch = Array('abb'); - addThis(); -*/ - -/* $ only matches end of input unless multiline - status = inSection(371); - pattern = /abb$/; - string = 'b\nabb\n'; - actualmatch = string.match(pattern); - expectedmatch = Array('abb'); - addThis(); -*/ - -/* Perl has \Z has end-of-line, ECMA doesn't - status = inSection(372); - pattern = /abb\Z/; - string = 'b\nabb'; - actualmatch = string.match(pattern); - expectedmatch = Array('abb'); - addThis(); - - status = inSection(373); - pattern = /abb\z/; - string = 'b\nabb'; - actualmatch = string.match(pattern); - expectedmatch = Array('abb'); - addThis(); -*/ - - status = inSection(374); - pattern = /abb$/; - string = 'b\nabb'; - actualmatch = string.match(pattern); - expectedmatch = Array('abb'); - addThis(); - - status = inSection(375); - pattern = /abb$/m; - string = 'abb\nb\n'; - actualmatch = string.match(pattern); - expectedmatch = Array('abb'); - addThis(); - -/* Perl has \Z has end-of-line, ECMA doesn't - status = inSection(376); - pattern = /abb\Z/m; - string = 'b\nabb\n'; - actualmatch = string.match(pattern); - expectedmatch = Array('abb'); - addThis(); -*/ - - status = inSection(377); - pattern = /abb$/m; - string = 'b\nabb\n'; - actualmatch = string.match(pattern); - expectedmatch = Array('abb'); - addThis(); - -/* Perl has \Z has end-of-line, ECMA doesn't - status = inSection(378); - pattern = /abb\Z/m; - string = 'b\nabb'; - actualmatch = string.match(pattern); - expectedmatch = Array('abb'); - addThis(); - - status = inSection(379); - pattern = /abb\z/m; - string = 'b\nabb'; - actualmatch = string.match(pattern); - expectedmatch = Array('abb'); - addThis(); -*/ - - status = inSection(380); - pattern = /abb$/m; - string = 'b\nabb'; - actualmatch = string.match(pattern); - expectedmatch = Array('abb'); - addThis(); - - status = inSection(381); - pattern = /(^|x)(c)/; - string = 'ca'; - actualmatch = string.match(pattern); - expectedmatch = Array('c', '', 'c'); - addThis(); - - status = inSection(382); - pattern = /foo.bart/; - string = 'foo.bart'; - actualmatch = string.match(pattern); - expectedmatch = Array('foo.bart'); - addThis(); - - status = inSection(383); - pattern = /^d[x][x][x]/m; - string = 'abcd\ndxxx'; - actualmatch = string.match(pattern); - expectedmatch = Array('dxxx'); - addThis(); - - status = inSection(384); - pattern = /tt+$/; - string = 'xxxtt'; - actualmatch = string.match(pattern); - expectedmatch = Array('tt'); - addThis(); - -/* ECMA spec says that each atom in a range must be a single character - status = inSection(385); - pattern = /([a-\d]+)/; - string = 'za-9z'; - actualmatch = string.match(pattern); - expectedmatch = Array('9', '9'); - addThis(); - - status = inSection(386); - pattern = /([\d-z]+)/; - string = 'a0-za'; - actualmatch = string.match(pattern); - expectedmatch = Array('0-z', '0-z'); - addThis(); -*/ - -/* ECMA doesn't support [: - status = inSection(387); - pattern = /([a-[:digit:]]+)/; - string = 'za-9z'; - actualmatch = string.match(pattern); - expectedmatch = Array('a-9', 'a-9'); - addThis(); - - status = inSection(388); - pattern = /([[:digit:]-z]+)/; - string = '=0-z='; - actualmatch = string.match(pattern); - expectedmatch = Array('0-z', '0-z'); - addThis(); - - status = inSection(389); - pattern = /([[:digit:]-[:alpha:]]+)/; - string = '=0-z='; - actualmatch = string.match(pattern); - expectedmatch = Array('0-z', '0-z'); - addThis(); -*/ - - status = inSection(390); - pattern = /(\d+\.\d+)/; - string = '3.1415926'; - actualmatch = string.match(pattern); - expectedmatch = Array('3.1415926', '3.1415926'); - addThis(); - - status = inSection(391); - pattern = /\.c(pp|xx|c)?$/i; - string = 'IO.c'; - actualmatch = string.match(pattern); - expectedmatch = Array('.c', undefined); - addThis(); - - status = inSection(392); - pattern = /(\.c(pp|xx|c)?$)/i; - string = 'IO.c'; - actualmatch = string.match(pattern); - expectedmatch = Array('.c', '.c', undefined); - addThis(); - - status = inSection(393); - pattern = /(^|a)b/; - string = 'ab'; - actualmatch = string.match(pattern); - expectedmatch = Array('ab', 'a'); - addThis(); - - status = inSection(394); - pattern = /^([ab]*?)(b)?(c)$/; - string = 'abac'; - actualmatch = string.match(pattern); - expectedmatch = Array('abac', 'aba', undefined, 'c'); - addThis(); - - status = inSection(395); - pattern = /^(?:.,){2}c/i; - string = 'a,b,c'; - actualmatch = string.match(pattern); - expectedmatch = Array('a,b,c'); - addThis(); - - status = inSection(396); - pattern = /^(.,){2}c/i; - string = 'a,b,c'; - actualmatch = string.match(pattern); - expectedmatch = Array('a,b,c', 'b,'); - addThis(); - - status = inSection(397); - pattern = /^(?:[^,]*,){2}c/; - string = 'a,b,c'; - actualmatch = string.match(pattern); - expectedmatch = Array('a,b,c'); - addThis(); - - status = inSection(398); - pattern = /^([^,]*,){2}c/; - string = 'a,b,c'; - actualmatch = string.match(pattern); - expectedmatch = Array('a,b,c', 'b,'); - addThis(); - - status = inSection(399); - pattern = /^([^,]*,){3}d/; - string = 'aaa,b,c,d'; - actualmatch = string.match(pattern); - expectedmatch = Array('aaa,b,c,d', 'c,'); - addThis(); - - status = inSection(400); - pattern = /^([^,]*,){3,}d/; - string = 'aaa,b,c,d'; - actualmatch = string.match(pattern); - expectedmatch = Array('aaa,b,c,d', 'c,'); - addThis(); - - status = inSection(401); - pattern = /^([^,]*,){0,3}d/; - string = 'aaa,b,c,d'; - actualmatch = string.match(pattern); - expectedmatch = Array('aaa,b,c,d', 'c,'); - addThis(); - - status = inSection(402); - pattern = /^([^,]{1,3},){3}d/i; - string = 'aaa,b,c,d'; - actualmatch = string.match(pattern); - expectedmatch = Array('aaa,b,c,d', 'c,'); - addThis(); - - status = inSection(403); - pattern = /^([^,]{1,3},){3,}d/; - string = 'aaa,b,c,d'; - actualmatch = string.match(pattern); - expectedmatch = Array('aaa,b,c,d', 'c,'); - addThis(); - - status = inSection(404); - pattern = /^([^,]{1,3},){0,3}d/; - string = 'aaa,b,c,d'; - actualmatch = string.match(pattern); - expectedmatch = Array('aaa,b,c,d', 'c,'); - addThis(); - - status = inSection(405); - pattern = /^([^,]{1,},){3}d/; - string = 'aaa,b,c,d'; - actualmatch = string.match(pattern); - expectedmatch = Array('aaa,b,c,d', 'c,'); - addThis(); - - status = inSection(406); - pattern = /^([^,]{1,},){3,}d/; - string = 'aaa,b,c,d'; - actualmatch = string.match(pattern); - expectedmatch = Array('aaa,b,c,d', 'c,'); - addThis(); - - status = inSection(407); - pattern = /^([^,]{1,},){0,3}d/; - string = 'aaa,b,c,d'; - actualmatch = string.match(pattern); - expectedmatch = Array('aaa,b,c,d', 'c,'); - addThis(); - - status = inSection(408); - pattern = /^([^,]{0,3},){3}d/i; - string = 'aaa,b,c,d'; - actualmatch = string.match(pattern); - expectedmatch = Array('aaa,b,c,d', 'c,'); - addThis(); - - status = inSection(409); - pattern = /^([^,]{0,3},){3,}d/; - string = 'aaa,b,c,d'; - actualmatch = string.match(pattern); - expectedmatch = Array('aaa,b,c,d', 'c,'); - addThis(); - - status = inSection(410); - pattern = /^([^,]{0,3},){0,3}d/; - string = 'aaa,b,c,d'; - actualmatch = string.match(pattern); - expectedmatch = Array('aaa,b,c,d', 'c,'); - addThis(); - -/* ECMA doesn't support \A - status = inSection(411); - pattern = /(?!\A)x/m; - string = 'a\nxb\n'; - actualmatch = string.match(pattern); - expectedmatch = Array('\n'); - addThis(); -*/ - - status = inSection(412); - pattern = /^(a(b)?)+$/; - string = 'aba'; - actualmatch = string.match(pattern); - expectedmatch = Array('aba', 'a', undefined); - addThis(); - - status = inSection(413); - pattern = /^(aa(bb)?)+$/; - string = 'aabbaa'; - actualmatch = string.match(pattern); - expectedmatch = Array('aabbaa', 'aa', undefined); - addThis(); - - status = inSection(414); - pattern = /^.{9}abc.*\n/m; - string = '123\nabcabcabcabc\n'; - actualmatch = string.match(pattern); - expectedmatch = Array('abcabcabcabc\n'); - addThis(); - - status = inSection(415); - pattern = /^(a)?a$/; - string = 'a'; - actualmatch = string.match(pattern); - expectedmatch = Array('a', undefined); - addThis(); - - status = inSection(416); - pattern = /^(a\1?)(a\1?)(a\2?)(a\3?)$/; - string = 'aaaaaa'; - actualmatch = string.match(pattern); - expectedmatch = Array('aaaaaa', 'a', 'aa', 'a', 'aa'); - addThis(); - -/* Can't refer to a capture before it's encountered & completed - status = inSection(417); - pattern = /^(a\1?){4}$/; - string = 'aaaaaa'; - actualmatch = string.match(pattern); - expectedmatch = Array('aaaaaa', 'aaa'); - addThis(); -*/ - - status = inSection(418); - pattern = /^(0+)?(?:x(1))?/; - string = 'x1'; - actualmatch = string.match(pattern); - expectedmatch = Array('x1', undefined, '1'); - addThis(); - - status = inSection(419); - pattern = /^([0-9a-fA-F]+)(?:x([0-9a-fA-F]+)?)(?:x([0-9a-fA-F]+))?/; - string = '012cxx0190'; - actualmatch = string.match(pattern); - expectedmatch = Array('012cxx0190', '012c', undefined, '0190'); - addThis(); - - status = inSection(420); - pattern = /^(b+?|a){1,2}c/; - string = 'bbbac'; - actualmatch = string.match(pattern); - expectedmatch = Array('bbbac', 'a'); - addThis(); - - status = inSection(421); - pattern = /^(b+?|a){1,2}c/; - string = 'bbbbac'; - actualmatch = string.match(pattern); - expectedmatch = Array('bbbbac', 'a'); - addThis(); - - status = inSection(422); - pattern = /((?:aaaa|bbbb)cccc)?/; - string = 'aaaacccc'; - actualmatch = string.match(pattern); - expectedmatch = Array('aaaacccc', 'aaaacccc'); - addThis(); - - status = inSection(423); - pattern = /((?:aaaa|bbbb)cccc)?/; - string = 'bbbbcccc'; - actualmatch = string.match(pattern); - expectedmatch = Array('bbbbcccc', 'bbbbcccc'); - addThis(); - - - - -//----------------------------------------------------------------------------- - test(); -//----------------------------------------------------------------------------- - - - - function addThis() - { - if(omitCurrentSection()) - return; - - statusmessages[i] = status; - patterns[i] = pattern; - strings[i] = string; - actualmatches[i] = actualmatch; - expectedmatches[i] = expectedmatch; - i++; - } - - - function omitCurrentSection() - { - try - { - // current section number is in global status variable - var n = status.match(/(\d+)/)[1]; - return ((n < cnLBOUND) || (n > cnUBOUND)); - } - catch(e) - { - return false; - } - } - - - function test() - { - enterFunc ('test'); - printBugNumber(BUGNUMBER); - printStatus (summary); - testRegExp(statusmessages, patterns, strings, actualmatches, expectedmatches); - exitFunc ('test'); - } diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/perlstress-002.js b/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/perlstress-002.js deleted file mode 100644 index a9b147b977..0000000000 --- a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/perlstress-002.js +++ /dev/null @@ -1,1842 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is JavaScript Engine testing utilities. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corp. - * Portions created by the Initial Developer are Copyright (C) 2002 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * pschwartau@netscape.com, rogerl@netscape.com - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -/* - * - * Date: 2002-07-07 - * SUMMARY: Testing JS RegExp engine against Perl 5 RegExp engine. - * Adjust cnLBOUND, cnUBOUND below to restrict which sections are tested. - * - * This test was created by running various patterns and strings through the - * Perl 5 RegExp engine. We saved the results below to test the JS engine. - * - * Each of the examples below is a negative test; that is, each produces a - * null match in Perl. Thus we set |expectedmatch| = |null| in each section. - * - * NOTE: ECMA/JS and Perl do differ on certain points. We have either commented - * out such sections altogether, or modified them to fit what we expect from JS. - * - * EXAMPLES: - * - * - ECMA does support (?: (?= and (?! operators, but doesn't support (?< etc. - * - * - ECMA doesn't support (?(condition) - * - */ -//----------------------------------------------------------------------------- -var gTestfile = 'perlstress-002.js'; -var i = 0; -var BUGNUMBER = 85721; -var summary = 'Testing regular expression edge cases'; -var cnSingleSpace = ' '; -var status = ''; -var statusmessages = new Array(); -var pattern = ''; -var patterns = new Array(); -var string = ''; -var strings = new Array(); -var actualmatch = ''; -var actualmatches = new Array(); -var expectedmatch = ''; -var expectedmatches = new Array(); -var cnLBOUND = 0; -var cnUBOUND = 1000; - - -status = inSection(1); -pattern = /abc/; -string = 'xbc'; -actualmatch = string.match(pattern); -expectedmatch = null; -addThis(); - -status = inSection(2); -pattern = /abc/; -string = 'axc'; -actualmatch = string.match(pattern); -expectedmatch = null; -addThis(); - -status = inSection(3); -pattern = /abc/; -string = 'abx'; -actualmatch = string.match(pattern); -expectedmatch = null; -addThis(); - -status = inSection(4); -pattern = /ab+bc/; -string = 'abc'; -actualmatch = string.match(pattern); -expectedmatch = null; -addThis(); - -status = inSection(5); -pattern = /ab+bc/; -string = 'abq'; -actualmatch = string.match(pattern); -expectedmatch = null; -addThis(); - -status = inSection(6); -pattern = /ab{1,}bc/; -string = 'abq'; -actualmatch = string.match(pattern); -expectedmatch = null; -addThis(); - -status = inSection(7); -pattern = /ab{4,5}bc/; -string = 'abbbbc'; -actualmatch = string.match(pattern); -expectedmatch = null; -addThis(); - -status = inSection(8); -pattern = /ab?bc/; -string = 'abbbbc'; -actualmatch = string.match(pattern); -expectedmatch = null; -addThis(); - -status = inSection(9); -pattern = /^abc$/; -string = 'abcc'; -actualmatch = string.match(pattern); -expectedmatch = null; -addThis(); - -status = inSection(10); -pattern = /^abc$/; -string = 'aabc'; -actualmatch = string.match(pattern); -expectedmatch = null; -addThis(); - -status = inSection(11); -pattern = /abc$/; -string = 'aabcd'; -actualmatch = string.match(pattern); -expectedmatch = null; -addThis(); - -status = inSection(12); -pattern = /a.*c/; -string = 'axyzd'; -actualmatch = string.match(pattern); -expectedmatch = null; -addThis(); - -status = inSection(13); -pattern = /a[bc]d/; -string = 'abc'; -actualmatch = string.match(pattern); -expectedmatch = null; -addThis(); - -status = inSection(14); -pattern = /a[b-d]e/; -string = 'abd'; -actualmatch = string.match(pattern); -expectedmatch = null; -addThis(); - -status = inSection(15); -pattern = /a[^bc]d/; -string = 'abd'; -actualmatch = string.match(pattern); -expectedmatch = null; -addThis(); - -status = inSection(16); -pattern = /a[^-b]c/; -string = 'a-c'; -actualmatch = string.match(pattern); -expectedmatch = null; -addThis(); - -status = inSection(17); -pattern = /a[^]b]c/; -string = 'a]c'; -actualmatch = string.match(pattern); -expectedmatch = null; -addThis(); - -status = inSection(18); -pattern = /\by\b/; -string = 'xy'; -actualmatch = string.match(pattern); -expectedmatch = null; -addThis(); - -status = inSection(19); -pattern = /\by\b/; -string = 'yz'; -actualmatch = string.match(pattern); -expectedmatch = null; -addThis(); - -status = inSection(20); -pattern = /\by\b/; -string = 'xyz'; -actualmatch = string.match(pattern); -expectedmatch = null; -addThis(); - -status = inSection(21); -pattern = /\Ba\B/; -string = 'a-'; -actualmatch = string.match(pattern); -expectedmatch = null; -addThis(); - -status = inSection(22); -pattern = /\Ba\B/; -string = '-a'; -actualmatch = string.match(pattern); -expectedmatch = null; -addThis(); - -status = inSection(23); -pattern = /\Ba\B/; -string = '-a-'; -actualmatch = string.match(pattern); -expectedmatch = null; -addThis(); - -status = inSection(24); -pattern = /\w/; -string = '-'; -actualmatch = string.match(pattern); -expectedmatch = null; -addThis(); - -status = inSection(25); -pattern = /\W/; -string = 'a'; -actualmatch = string.match(pattern); -expectedmatch = null; -addThis(); - -status = inSection(26); -pattern = /a\sb/; -string = 'a-b'; -actualmatch = string.match(pattern); -expectedmatch = null; -addThis(); - -status = inSection(27); -pattern = /\d/; -string = '-'; -actualmatch = string.match(pattern); -expectedmatch = null; -addThis(); - -status = inSection(28); -pattern = /\D/; -string = '1'; -actualmatch = string.match(pattern); -expectedmatch = null; -addThis(); - -status = inSection(29); -pattern = /[\w]/; -string = '-'; -actualmatch = string.match(pattern); -expectedmatch = null; -addThis(); - -status = inSection(30); -pattern = /[\W]/; -string = 'a'; -actualmatch = string.match(pattern); -expectedmatch = null; -addThis(); - -status = inSection(31); -pattern = /a[\s]b/; -string = 'a-b'; -actualmatch = string.match(pattern); -expectedmatch = null; -addThis(); - -status = inSection(32); -pattern = /[\d]/; -string = '-'; -actualmatch = string.match(pattern); -expectedmatch = null; -addThis(); - -status = inSection(33); -pattern = /[\D]/; -string = '1'; -actualmatch = string.match(pattern); -expectedmatch = null; -addThis(); - -status = inSection(34); -pattern = /$b/; -string = 'b'; -actualmatch = string.match(pattern); -expectedmatch = null; -addThis(); - -status = inSection(35); -pattern = /^(ab|cd)e/; -string = 'abcde'; -actualmatch = string.match(pattern); -expectedmatch = null; -addThis(); - -status = inSection(36); -pattern = /a[bcd]+dcdcde/; -string = 'adcdcde'; -actualmatch = string.match(pattern); -expectedmatch = null; -addThis(); - -status = inSection(37); -pattern = /(bc+d$|ef*g.|h?i(j|k))/; -string = 'effg'; -actualmatch = string.match(pattern); -expectedmatch = null; -addThis(); - -status = inSection(38); -pattern = /(bc+d$|ef*g.|h?i(j|k))/; -string = 'bcdd'; -actualmatch = string.match(pattern); -expectedmatch = null; -addThis(); - -status = inSection(39); -pattern = /[k]/; -string = 'ab'; -actualmatch = string.match(pattern); -expectedmatch = null; -addThis(); - -// MODIFIED - ECMA has different rules for paren contents. -status = inSection(40); -pattern = /(a)|\1/; -string = 'x'; -actualmatch = string.match(pattern); -//expectedmatch = null; -expectedmatch = Array("", undefined); -addThis(); - -// MODIFIED - ECMA has different rules for paren contents. -status = inSection(41); -pattern = /((\3|b)\2(a)x)+/; -string = 'aaxabxbaxbbx'; -actualmatch = string.match(pattern); -//expectedmatch = null; -expectedmatch = Array("ax", "ax", "", "a"); -addThis(); - -status = inSection(42); -pattern = /abc/i; -string = 'XBC'; -actualmatch = string.match(pattern); -expectedmatch = null; -addThis(); - -status = inSection(43); -pattern = /abc/i; -string = 'AXC'; -actualmatch = string.match(pattern); -expectedmatch = null; -addThis(); - -status = inSection(44); -pattern = /abc/i; -string = 'ABX'; -actualmatch = string.match(pattern); -expectedmatch = null; -addThis(); - -status = inSection(45); -pattern = /ab+bc/i; -string = 'ABC'; -actualmatch = string.match(pattern); -expectedmatch = null; -addThis(); - -status = inSection(46); -pattern = /ab+bc/i; -string = 'ABQ'; -actualmatch = string.match(pattern); -expectedmatch = null; -addThis(); - -status = inSection(47); -pattern = /ab{1,}bc/i; -string = 'ABQ'; -actualmatch = string.match(pattern); -expectedmatch = null; -addThis(); - -status = inSection(48); -pattern = /ab{4,5}?bc/i; -string = 'ABBBBC'; -actualmatch = string.match(pattern); -expectedmatch = null; -addThis(); - -status = inSection(49); -pattern = /ab??bc/i; -string = 'ABBBBC'; -actualmatch = string.match(pattern); -expectedmatch = null; -addThis(); - -status = inSection(50); -pattern = /^abc$/i; -string = 'ABCC'; -actualmatch = string.match(pattern); -expectedmatch = null; -addThis(); - -status = inSection(51); -pattern = /^abc$/i; -string = 'AABC'; -actualmatch = string.match(pattern); -expectedmatch = null; -addThis(); - -status = inSection(52); -pattern = /a.*c/i; -string = 'AXYZD'; -actualmatch = string.match(pattern); -expectedmatch = null; -addThis(); - -status = inSection(53); -pattern = /a[bc]d/i; -string = 'ABC'; -actualmatch = string.match(pattern); -expectedmatch = null; -addThis(); - -status = inSection(54); -pattern = /a[b-d]e/i; -string = 'ABD'; -actualmatch = string.match(pattern); -expectedmatch = null; -addThis(); - -status = inSection(55); -pattern = /a[^bc]d/i; -string = 'ABD'; -actualmatch = string.match(pattern); -expectedmatch = null; -addThis(); - -status = inSection(56); -pattern = /a[^-b]c/i; -string = 'A-C'; -actualmatch = string.match(pattern); -expectedmatch = null; -addThis(); - -status = inSection(57); -pattern = /a[^]b]c/i; -string = 'A]C'; -actualmatch = string.match(pattern); -expectedmatch = null; -addThis(); - -status = inSection(58); -pattern = /$b/i; -string = 'B'; -actualmatch = string.match(pattern); -expectedmatch = null; -addThis(); - -status = inSection(59); -pattern = /^(ab|cd)e/i; -string = 'ABCDE'; -actualmatch = string.match(pattern); -expectedmatch = null; -addThis(); - -status = inSection(60); -pattern = /a[bcd]+dcdcde/i; -string = 'ADCDCDE'; -actualmatch = string.match(pattern); -expectedmatch = null; -addThis(); - -status = inSection(61); -pattern = /(bc+d$|ef*g.|h?i(j|k))/i; -string = 'EFFG'; -actualmatch = string.match(pattern); -expectedmatch = null; -addThis(); - -status = inSection(62); -pattern = /(bc+d$|ef*g.|h?i(j|k))/i; -string = 'BCDD'; -actualmatch = string.match(pattern); -expectedmatch = null; -addThis(); - -status = inSection(63); -pattern = /[k]/i; -string = 'AB'; -actualmatch = string.match(pattern); -expectedmatch = null; -addThis(); - -status = inSection(64); -pattern = /^(a\1?){4}$/; -string = 'aaaaaaaaa'; -actualmatch = string.match(pattern); -expectedmatch = null; -addThis(); - -status = inSection(65); -pattern = /^(a\1?){4}$/; -string = 'aaaaaaaaaaa'; -actualmatch = string.match(pattern); -expectedmatch = null; -addThis(); - -/* ECMA doesn't support (?( - status = inSection(66); - pattern = /^(a(?(1)\1)){4}$/; - string = 'aaaaaaaaa'; - actualmatch = string.match(pattern); - expectedmatch = null; - addThis(); - - status = inSection(67); - pattern = /^(a(?(1)\1)){4}$/; - string = 'aaaaaaaaaaa'; - actualmatch = string.match(pattern); - expectedmatch = null; - addThis(); -*/ - -/* ECMA doesn't support (?< - status = inSection(68); - pattern = /(?<=a)b/; - string = 'cb'; - actualmatch = string.match(pattern); - expectedmatch = null; - addThis(); - - status = inSection(69); - pattern = /(?<=a)b/; - string = 'b'; - actualmatch = string.match(pattern); - expectedmatch = null; - addThis(); - - status = inSection(70); - pattern = /(?a+)ab/; -string = 'aaab'; -actualmatch = string.match(pattern); -expectedmatch = null; -addThis(); - -status = inSection(106); -pattern = /a\Z/; -string = 'a\nb\n'; -actualmatch = string.match(pattern); -expectedmatch = null; -addThis(); - -status = inSection(107); -pattern = /a\z/; -string = 'a\nb\n'; -actualmatch = string.match(pattern); -expectedmatch = null; -addThis(); - -status = inSection(108); -pattern = /a$/; -string = 'a\nb\n'; -actualmatch = string.match(pattern); -expectedmatch = null; -addThis(); - -status = inSection(109); -pattern = /a\z/; -string = 'b\na\n'; -actualmatch = string.match(pattern); -expectedmatch = null; -addThis(); - -status = inSection(110); -pattern = /a\z/m; -string = 'a\nb\n'; -actualmatch = string.match(pattern); -expectedmatch = null; -addThis(); - -status = inSection(111); -pattern = /a\z/m; -string = 'b\na\n'; -actualmatch = string.match(pattern); -expectedmatch = null; -addThis(); - -status = inSection(112); -pattern = /aa\Z/; -string = 'aa\nb\n'; -actualmatch = string.match(pattern); -expectedmatch = null; -addThis(); - -status = inSection(113); -pattern = /aa\z/; -string = 'aa\nb\n'; -actualmatch = string.match(pattern); -expectedmatch = null; -addThis(); - -status = inSection(114); -pattern = /aa$/; -string = 'aa\nb\n'; -actualmatch = string.match(pattern); -expectedmatch = null; -addThis(); - -status = inSection(115); -pattern = /aa\z/; -string = 'b\naa\n'; -actualmatch = string.match(pattern); -expectedmatch = null; -addThis(); - -status = inSection(116); -pattern = /aa\z/m; -string = 'aa\nb\n'; -actualmatch = string.match(pattern); -expectedmatch = null; -addThis(); - -status = inSection(117); -pattern = /aa\z/m; -string = 'b\naa\n'; -actualmatch = string.match(pattern); -expectedmatch = null; -addThis(); - -status = inSection(118); -pattern = /aa\Z/; -string = 'ac\nb\n'; -actualmatch = string.match(pattern); -expectedmatch = null; -addThis(); - -status = inSection(119); -pattern = /aa\z/; -string = 'ac\nb\n'; -actualmatch = string.match(pattern); -expectedmatch = null; -addThis(); - -status = inSection(120); -pattern = /aa$/; -string = 'ac\nb\n'; -actualmatch = string.match(pattern); -expectedmatch = null; -addThis(); - -status = inSection(121); -pattern = /aa\Z/; -string = 'b\nac\n'; -actualmatch = string.match(pattern); -expectedmatch = null; -addThis(); - -status = inSection(122); -pattern = /aa\z/; -string = 'b\nac\n'; -actualmatch = string.match(pattern); -expectedmatch = null; -addThis(); - -status = inSection(123); -pattern = /aa$/; -string = 'b\nac\n'; -actualmatch = string.match(pattern); -expectedmatch = null; -addThis(); - -status = inSection(124); -pattern = /aa\Z/; -string = 'b\nac'; -actualmatch = string.match(pattern); -expectedmatch = null; -addThis(); - -status = inSection(125); -pattern = /aa\z/; -string = 'b\nac'; -actualmatch = string.match(pattern); -expectedmatch = null; -addThis(); - -status = inSection(126); -pattern = /aa$/; -string = 'b\nac'; -actualmatch = string.match(pattern); -expectedmatch = null; -addThis(); - -status = inSection(127); -pattern = /aa\Z/m; -string = 'ac\nb\n'; -actualmatch = string.match(pattern); -expectedmatch = null; -addThis(); - -status = inSection(128); -pattern = /aa\z/m; -string = 'ac\nb\n'; -actualmatch = string.match(pattern); -expectedmatch = null; -addThis(); - -status = inSection(129); -pattern = /aa$/m; -string = 'ac\nb\n'; -actualmatch = string.match(pattern); -expectedmatch = null; -addThis(); - -status = inSection(130); -pattern = /aa\Z/m; -string = 'b\nac\n'; -actualmatch = string.match(pattern); -expectedmatch = null; -addThis(); - -status = inSection(131); -pattern = /aa\z/m; -string = 'b\nac\n'; -actualmatch = string.match(pattern); -expectedmatch = null; -addThis(); - -status = inSection(132); -pattern = /aa$/m; -string = 'b\nac\n'; -actualmatch = string.match(pattern); -expectedmatch = null; -addThis(); - -status = inSection(133); -pattern = /aa\Z/m; -string = 'b\nac'; -actualmatch = string.match(pattern); -expectedmatch = null; -addThis(); - -status = inSection(134); -pattern = /aa\z/m; -string = 'b\nac'; -actualmatch = string.match(pattern); -expectedmatch = null; -addThis(); - -status = inSection(135); -pattern = /aa$/m; -string = 'b\nac'; -actualmatch = string.match(pattern); -expectedmatch = null; -addThis(); - -status = inSection(136); -pattern = /aa\Z/; -string = 'ca\nb\n'; -actualmatch = string.match(pattern); -expectedmatch = null; -addThis(); - -status = inSection(137); -pattern = /aa\z/; -string = 'ca\nb\n'; -actualmatch = string.match(pattern); -expectedmatch = null; -addThis(); - -status = inSection(138); -pattern = /aa$/; -string = 'ca\nb\n'; -actualmatch = string.match(pattern); -expectedmatch = null; -addThis(); - -status = inSection(139); -pattern = /aa\Z/; -string = 'b\nca\n'; -actualmatch = string.match(pattern); -expectedmatch = null; -addThis(); - -status = inSection(140); -pattern = /aa\z/; -string = 'b\nca\n'; -actualmatch = string.match(pattern); -expectedmatch = null; -addThis(); - -status = inSection(141); -pattern = /aa$/; -string = 'b\nca\n'; -actualmatch = string.match(pattern); -expectedmatch = null; -addThis(); - -status = inSection(142); -pattern = /aa\Z/; -string = 'b\nca'; -actualmatch = string.match(pattern); -expectedmatch = null; -addThis(); - -status = inSection(143); -pattern = /aa\z/; -string = 'b\nca'; -actualmatch = string.match(pattern); -expectedmatch = null; -addThis(); - -status = inSection(144); -pattern = /aa$/; -string = 'b\nca'; -actualmatch = string.match(pattern); -expectedmatch = null; -addThis(); - -status = inSection(145); -pattern = /aa\Z/m; -string = 'ca\nb\n'; -actualmatch = string.match(pattern); -expectedmatch = null; -addThis(); - -status = inSection(146); -pattern = /aa\z/m; -string = 'ca\nb\n'; -actualmatch = string.match(pattern); -expectedmatch = null; -addThis(); - -status = inSection(147); -pattern = /aa$/m; -string = 'ca\nb\n'; -actualmatch = string.match(pattern); -expectedmatch = null; -addThis(); - -status = inSection(148); -pattern = /aa\Z/m; -string = 'b\nca\n'; -actualmatch = string.match(pattern); -expectedmatch = null; -addThis(); - -status = inSection(149); -pattern = /aa\z/m; -string = 'b\nca\n'; -actualmatch = string.match(pattern); -expectedmatch = null; -addThis(); - -status = inSection(150); -pattern = /aa$/m; -string = 'b\nca\n'; -actualmatch = string.match(pattern); -expectedmatch = null; -addThis(); - -status = inSection(151); -pattern = /aa\Z/m; -string = 'b\nca'; -actualmatch = string.match(pattern); -expectedmatch = null; -addThis(); - -status = inSection(152); -pattern = /aa\z/m; -string = 'b\nca'; -actualmatch = string.match(pattern); -expectedmatch = null; -addThis(); - -status = inSection(153); -pattern = /aa$/m; -string = 'b\nca'; -actualmatch = string.match(pattern); -expectedmatch = null; -addThis(); - -status = inSection(154); -pattern = /ab\Z/; -string = 'ab\nb\n'; -actualmatch = string.match(pattern); -expectedmatch = null; -addThis(); - -status = inSection(155); -pattern = /ab\z/; -string = 'ab\nb\n'; -actualmatch = string.match(pattern); -expectedmatch = null; -addThis(); - -status = inSection(156); -pattern = /ab$/; -string = 'ab\nb\n'; -actualmatch = string.match(pattern); -expectedmatch = null; -addThis(); - -status = inSection(157); -pattern = /ab\z/; -string = 'b\nab\n'; -actualmatch = string.match(pattern); -expectedmatch = null; -addThis(); - -status = inSection(158); -pattern = /ab\z/m; -string = 'ab\nb\n'; -actualmatch = string.match(pattern); -expectedmatch = null; -addThis(); - -status = inSection(159); -pattern = /ab\z/m; -string = 'b\nab\n'; -actualmatch = string.match(pattern); -expectedmatch = null; -addThis(); - -status = inSection(160); -pattern = /ab\Z/; -string = 'ac\nb\n'; -actualmatch = string.match(pattern); -expectedmatch = null; -addThis(); - -status = inSection(161); -pattern = /ab\z/; -string = 'ac\nb\n'; -actualmatch = string.match(pattern); -expectedmatch = null; -addThis(); - -status = inSection(162); -pattern = /ab$/; -string = 'ac\nb\n'; -actualmatch = string.match(pattern); -expectedmatch = null; -addThis(); - -status = inSection(163); -pattern = /ab\Z/; -string = 'b\nac\n'; -actualmatch = string.match(pattern); -expectedmatch = null; -addThis(); - -status = inSection(164); -pattern = /ab\z/; -string = 'b\nac\n'; -actualmatch = string.match(pattern); -expectedmatch = null; -addThis(); - -status = inSection(165); -pattern = /ab$/; -string = 'b\nac\n'; -actualmatch = string.match(pattern); -expectedmatch = null; -addThis(); - -status = inSection(166); -pattern = /ab\Z/; -string = 'b\nac'; -actualmatch = string.match(pattern); -expectedmatch = null; -addThis(); - -status = inSection(167); -pattern = /ab\z/; -string = 'b\nac'; -actualmatch = string.match(pattern); -expectedmatch = null; -addThis(); - -status = inSection(168); -pattern = /ab$/; -string = 'b\nac'; -actualmatch = string.match(pattern); -expectedmatch = null; -addThis(); - -status = inSection(169); -pattern = /ab\Z/m; -string = 'ac\nb\n'; -actualmatch = string.match(pattern); -expectedmatch = null; -addThis(); - -status = inSection(170); -pattern = /ab\z/m; -string = 'ac\nb\n'; -actualmatch = string.match(pattern); -expectedmatch = null; -addThis(); - -status = inSection(171); -pattern = /ab$/m; -string = 'ac\nb\n'; -actualmatch = string.match(pattern); -expectedmatch = null; -addThis(); - -status = inSection(172); -pattern = /ab\Z/m; -string = 'b\nac\n'; -actualmatch = string.match(pattern); -expectedmatch = null; -addThis(); - -status = inSection(173); -pattern = /ab\z/m; -string = 'b\nac\n'; -actualmatch = string.match(pattern); -expectedmatch = null; -addThis(); - -status = inSection(174); -pattern = /ab$/m; -string = 'b\nac\n'; -actualmatch = string.match(pattern); -expectedmatch = null; -addThis(); - -status = inSection(175); -pattern = /ab\Z/m; -string = 'b\nac'; -actualmatch = string.match(pattern); -expectedmatch = null; -addThis(); - -status = inSection(176); -pattern = /ab\z/m; -string = 'b\nac'; -actualmatch = string.match(pattern); -expectedmatch = null; -addThis(); - -status = inSection(177); -pattern = /ab$/m; -string = 'b\nac'; -actualmatch = string.match(pattern); -expectedmatch = null; -addThis(); - -status = inSection(178); -pattern = /ab\Z/; -string = 'ca\nb\n'; -actualmatch = string.match(pattern); -expectedmatch = null; -addThis(); - -status = inSection(179); -pattern = /ab\z/; -string = 'ca\nb\n'; -actualmatch = string.match(pattern); -expectedmatch = null; -addThis(); - -status = inSection(180); -pattern = /ab$/; -string = 'ca\nb\n'; -actualmatch = string.match(pattern); -expectedmatch = null; -addThis(); - -status = inSection(181); -pattern = /ab\Z/; -string = 'b\nca\n'; -actualmatch = string.match(pattern); -expectedmatch = null; -addThis(); - -status = inSection(182); -pattern = /ab\z/; -string = 'b\nca\n'; -actualmatch = string.match(pattern); -expectedmatch = null; -addThis(); - -status = inSection(183); -pattern = /ab$/; -string = 'b\nca\n'; -actualmatch = string.match(pattern); -expectedmatch = null; -addThis(); - -status = inSection(184); -pattern = /ab\Z/; -string = 'b\nca'; -actualmatch = string.match(pattern); -expectedmatch = null; -addThis(); - -status = inSection(185); -pattern = /ab\z/; -string = 'b\nca'; -actualmatch = string.match(pattern); -expectedmatch = null; -addThis(); - -status = inSection(186); -pattern = /ab$/; -string = 'b\nca'; -actualmatch = string.match(pattern); -expectedmatch = null; -addThis(); - -status = inSection(187); -pattern = /ab\Z/m; -string = 'ca\nb\n'; -actualmatch = string.match(pattern); -expectedmatch = null; -addThis(); - -status = inSection(188); -pattern = /ab\z/m; -string = 'ca\nb\n'; -actualmatch = string.match(pattern); -expectedmatch = null; -addThis(); - -status = inSection(189); -pattern = /ab$/m; -string = 'ca\nb\n'; -actualmatch = string.match(pattern); -expectedmatch = null; -addThis(); - -status = inSection(190); -pattern = /ab\Z/m; -string = 'b\nca\n'; -actualmatch = string.match(pattern); -expectedmatch = null; -addThis(); - -status = inSection(191); -pattern = /ab\z/m; -string = 'b\nca\n'; -actualmatch = string.match(pattern); -expectedmatch = null; -addThis(); - -status = inSection(192); -pattern = /ab$/m; -string = 'b\nca\n'; -actualmatch = string.match(pattern); -expectedmatch = null; -addThis(); - -status = inSection(193); -pattern = /ab\Z/m; -string = 'b\nca'; -actualmatch = string.match(pattern); -expectedmatch = null; -addThis(); - -status = inSection(194); -pattern = /ab\z/m; -string = 'b\nca'; -actualmatch = string.match(pattern); -expectedmatch = null; -addThis(); - -status = inSection(195); -pattern = /ab$/m; -string = 'b\nca'; -actualmatch = string.match(pattern); -expectedmatch = null; -addThis(); - -status = inSection(196); -pattern = /abb\Z/; -string = 'abb\nb\n'; -actualmatch = string.match(pattern); -expectedmatch = null; -addThis(); - -status = inSection(197); -pattern = /abb\z/; -string = 'abb\nb\n'; -actualmatch = string.match(pattern); -expectedmatch = null; -addThis(); - -status = inSection(198); -pattern = /abb$/; -string = 'abb\nb\n'; -actualmatch = string.match(pattern); -expectedmatch = null; -addThis(); - -status = inSection(199); -pattern = /abb\z/; -string = 'b\nabb\n'; -actualmatch = string.match(pattern); -expectedmatch = null; -addThis(); - -status = inSection(200); -pattern = /abb\z/m; -string = 'abb\nb\n'; -actualmatch = string.match(pattern); -expectedmatch = null; -addThis(); - -status = inSection(201); -pattern = /abb\z/m; -string = 'b\nabb\n'; -actualmatch = string.match(pattern); -expectedmatch = null; -addThis(); - -status = inSection(202); -pattern = /abb\Z/; -string = 'ac\nb\n'; -actualmatch = string.match(pattern); -expectedmatch = null; -addThis(); - -status = inSection(203); -pattern = /abb\z/; -string = 'ac\nb\n'; -actualmatch = string.match(pattern); -expectedmatch = null; -addThis(); - -status = inSection(204); -pattern = /abb$/; -string = 'ac\nb\n'; -actualmatch = string.match(pattern); -expectedmatch = null; -addThis(); - -status = inSection(205); -pattern = /abb\Z/; -string = 'b\nac\n'; -actualmatch = string.match(pattern); -expectedmatch = null; -addThis(); - -status = inSection(206); -pattern = /abb\z/; -string = 'b\nac\n'; -actualmatch = string.match(pattern); -expectedmatch = null; -addThis(); - -status = inSection(207); -pattern = /abb$/; -string = 'b\nac\n'; -actualmatch = string.match(pattern); -expectedmatch = null; -addThis(); - -status = inSection(208); -pattern = /abb\Z/; -string = 'b\nac'; -actualmatch = string.match(pattern); -expectedmatch = null; -addThis(); - -status = inSection(209); -pattern = /abb\z/; -string = 'b\nac'; -actualmatch = string.match(pattern); -expectedmatch = null; -addThis(); - -status = inSection(210); -pattern = /abb$/; -string = 'b\nac'; -actualmatch = string.match(pattern); -expectedmatch = null; -addThis(); - -status = inSection(211); -pattern = /abb\Z/m; -string = 'ac\nb\n'; -actualmatch = string.match(pattern); -expectedmatch = null; -addThis(); - -status = inSection(212); -pattern = /abb\z/m; -string = 'ac\nb\n'; -actualmatch = string.match(pattern); -expectedmatch = null; -addThis(); - -status = inSection(213); -pattern = /abb$/m; -string = 'ac\nb\n'; -actualmatch = string.match(pattern); -expectedmatch = null; -addThis(); - -status = inSection(214); -pattern = /abb\Z/m; -string = 'b\nac\n'; -actualmatch = string.match(pattern); -expectedmatch = null; -addThis(); - -status = inSection(215); -pattern = /abb\z/m; -string = 'b\nac\n'; -actualmatch = string.match(pattern); -expectedmatch = null; -addThis(); - -status = inSection(216); -pattern = /abb$/m; -string = 'b\nac\n'; -actualmatch = string.match(pattern); -expectedmatch = null; -addThis(); - -status = inSection(217); -pattern = /abb\Z/m; -string = 'b\nac'; -actualmatch = string.match(pattern); -expectedmatch = null; -addThis(); - -status = inSection(218); -pattern = /abb\z/m; -string = 'b\nac'; -actualmatch = string.match(pattern); -expectedmatch = null; -addThis(); - -status = inSection(219); -pattern = /abb$/m; -string = 'b\nac'; -actualmatch = string.match(pattern); -expectedmatch = null; -addThis(); - -status = inSection(220); -pattern = /abb\Z/; -string = 'ca\nb\n'; -actualmatch = string.match(pattern); -expectedmatch = null; -addThis(); - -status = inSection(221); -pattern = /abb\z/; -string = 'ca\nb\n'; -actualmatch = string.match(pattern); -expectedmatch = null; -addThis(); - -status = inSection(222); -pattern = /abb$/; -string = 'ca\nb\n'; -actualmatch = string.match(pattern); -expectedmatch = null; -addThis(); - -status = inSection(223); -pattern = /abb\Z/; -string = 'b\nca\n'; -actualmatch = string.match(pattern); -expectedmatch = null; -addThis(); - -status = inSection(224); -pattern = /abb\z/; -string = 'b\nca\n'; -actualmatch = string.match(pattern); -expectedmatch = null; -addThis(); - -status = inSection(225); -pattern = /abb$/; -string = 'b\nca\n'; -actualmatch = string.match(pattern); -expectedmatch = null; -addThis(); - -status = inSection(226); -pattern = /abb\Z/; -string = 'b\nca'; -actualmatch = string.match(pattern); -expectedmatch = null; -addThis(); - -status = inSection(227); -pattern = /abb\z/; -string = 'b\nca'; -actualmatch = string.match(pattern); -expectedmatch = null; -addThis(); - -status = inSection(228); -pattern = /abb$/; -string = 'b\nca'; -actualmatch = string.match(pattern); -expectedmatch = null; -addThis(); - -status = inSection(229); -pattern = /abb\Z/m; -string = 'ca\nb\n'; -actualmatch = string.match(pattern); -expectedmatch = null; -addThis(); - -status = inSection(230); -pattern = /abb\z/m; -string = 'ca\nb\n'; -actualmatch = string.match(pattern); -expectedmatch = null; -addThis(); - -status = inSection(231); -pattern = /abb$/m; -string = 'ca\nb\n'; -actualmatch = string.match(pattern); -expectedmatch = null; -addThis(); - -status = inSection(232); -pattern = /abb\Z/m; -string = 'b\nca\n'; -actualmatch = string.match(pattern); -expectedmatch = null; -addThis(); - -status = inSection(233); -pattern = /abb\z/m; -string = 'b\nca\n'; -actualmatch = string.match(pattern); -expectedmatch = null; -addThis(); - -status = inSection(234); -pattern = /abb$/m; -string = 'b\nca\n'; -actualmatch = string.match(pattern); -expectedmatch = null; -addThis(); - -status = inSection(235); -pattern = /abb\Z/m; -string = 'b\nca'; -actualmatch = string.match(pattern); -expectedmatch = null; -addThis(); - -status = inSection(236); -pattern = /abb\z/m; -string = 'b\nca'; -actualmatch = string.match(pattern); -expectedmatch = null; -addThis(); - -status = inSection(237); -pattern = /abb$/m; -string = 'b\nca'; -actualmatch = string.match(pattern); -expectedmatch = null; -addThis(); - -status = inSection(238); -pattern = /a*abc?xyz+pqr{3}ab{2,}xy{4,5}pq{0,6}AB{0,}zz/; -string = 'x'; -actualmatch = string.match(pattern); -expectedmatch = null; -addThis(); - -status = inSection(239); -pattern = /\GX.*X/; -string = 'aaaXbX'; -actualmatch = string.match(pattern); -expectedmatch = null; -addThis(); - -status = inSection(240); -pattern = /\.c(pp|xx|c)?$/i; -string = 'Changes'; -actualmatch = string.match(pattern); -expectedmatch = null; -addThis(); - -status = inSection(241); -pattern = /^([a-z]:)/; -string = 'C:/'; -actualmatch = string.match(pattern); -expectedmatch = null; -addThis(); - -status = inSection(242); -pattern = /(\w)?(abc)\1b/; -string = 'abcab'; -actualmatch = string.match(pattern); -expectedmatch = null; -addThis(); - -/* ECMA doesn't support (?( - status = inSection(243); - pattern = /^(a)?(?(1)a|b)+$/; - string = 'a'; - actualmatch = string.match(pattern); - expectedmatch = null; - addThis(); -*/ - - - -//----------------------------------------------------------------------------- -test(); -//----------------------------------------------------------------------------- - - - -function addThis() -{ - if(omitCurrentSection()) - return; - - statusmessages[i] = status; - patterns[i] = pattern; - strings[i] = string; - actualmatches[i] = actualmatch; - expectedmatches[i] = expectedmatch; - i++; -} - - -function omitCurrentSection() -{ - try - { - // current section number is in global status variable - var n = status.match(/(\d+)/)[1]; - return ((n < cnLBOUND) || (n > cnUBOUND)); - } - catch(e) - { - return false; - } -} - - -function test() -{ - enterFunc ('test'); - printBugNumber(BUGNUMBER); - printStatus (summary); - testRegExp(statusmessages, patterns, strings, actualmatches, expectedmatches); - exitFunc ('test'); -} diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-100199.js b/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-100199.js deleted file mode 100644 index 8c88aa7f52..0000000000 --- a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-100199.js +++ /dev/null @@ -1,307 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is mozilla.org code. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * pschwartau@netscape.com - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -/* - * Date: 17 September 2001 - * - * SUMMARY: Regression test for Bugzilla bug 100199 - * See http://bugzilla.mozilla.org/show_bug.cgi?id=100199 - * - * The empty character class [] is a valid RegExp construct: the condition - * that a given character belong to a set containing no characters. As such, - * it can never be met and is always FALSE. Similarly, [^] is a condition - * that matches any given character and is always TRUE. - * - * Neither one of these conditions should cause syntax errors in a RegExp. - */ -//----------------------------------------------------------------------------- -var gTestfile = 'regress-100199.js'; -var i = 0; -var BUGNUMBER = 100199; -var summary = '[], [^] are valid RegExp conditions. Should not cause errors -'; -var status = ''; -var statusmessages = new Array(); -var pattern = ''; -var patterns = new Array(); -var string = ''; -var strings = new Array(); -var actualmatch = ''; -var actualmatches = new Array(); -var expectedmatch = ''; -var expectedmatches = new Array(); - - -pattern = /[]/; -string = 'abc'; -status = inSection(1); -actualmatch = string.match(pattern); -expectedmatch = null; -addThis(); - -string = ''; -status = inSection(2); -actualmatch = string.match(pattern); -expectedmatch = null; -addThis(); - -string = '['; -status = inSection(3); -actualmatch = string.match(pattern); -expectedmatch = null; -addThis(); - -string = '/'; -status = inSection(4); -actualmatch = string.match(pattern); -expectedmatch = null; -addThis(); - -string = '['; -status = inSection(5); -actualmatch = string.match(pattern); -expectedmatch = null; -addThis(); - -string = ']'; -status = inSection(6); -actualmatch = string.match(pattern); -expectedmatch = null; -addThis(); - -string = '[]'; -status = inSection(7); -actualmatch = string.match(pattern); -expectedmatch = null; -addThis(); - -string = '[ ]'; -status = inSection(8); -actualmatch = string.match(pattern); -expectedmatch = null; -addThis(); - -string = ']['; -status = inSection(9); -actualmatch = string.match(pattern); -expectedmatch = null; -addThis(); - - -pattern = /a[]/; -string = 'abc'; -status = inSection(10); -actualmatch = string.match(pattern); -expectedmatch = null; -addThis(); - -string = ''; -status = inSection(11); -actualmatch = string.match(pattern); -expectedmatch = null; -addThis(); - -string = 'a['; -status = inSection(12); -actualmatch = string.match(pattern); -expectedmatch = null; -addThis(); - -string = 'a[]'; -status = inSection(13); -actualmatch = string.match(pattern); -expectedmatch = null; -addThis(); - -string = '['; -status = inSection(14); -actualmatch = string.match(pattern); -expectedmatch = null; -addThis(); - -string = ']'; -status = inSection(15); -actualmatch = string.match(pattern); -expectedmatch = null; -addThis(); - -string = '[]'; -status = inSection(16); -actualmatch = string.match(pattern); -expectedmatch = null; -addThis(); - -string = '[ ]'; -status = inSection(17); -actualmatch = string.match(pattern); -expectedmatch = null; -addThis(); - -string = ']['; -status = inSection(18); -actualmatch = string.match(pattern); -expectedmatch = null; -addThis(); - - -pattern = /[^]/; -string = 'abc'; -status = inSection(19); -actualmatch = string.match(pattern); -expectedmatch = Array('a'); -addThis(); - -string = ''; -status = inSection(20); -actualmatch = string.match(pattern); -expectedmatch = null; //there are no characters to test against the condition -addThis(); - -string = '\/'; -status = inSection(21); -actualmatch = string.match(pattern); -expectedmatch = Array('/'); -addThis(); - -string = '\['; -status = inSection(22); -actualmatch = string.match(pattern); -expectedmatch = Array('['); -addThis(); - -string = '['; -status = inSection(23); -actualmatch = string.match(pattern); -expectedmatch = Array('['); -addThis(); - -string = ']'; -status = inSection(24); -actualmatch = string.match(pattern); -expectedmatch = Array(']'); -addThis(); - -string = '[]'; -status = inSection(25); -actualmatch = string.match(pattern); -expectedmatch = Array('['); -addThis(); - -string = '[ ]'; -status = inSection(26); -actualmatch = string.match(pattern); -expectedmatch = Array('['); -addThis(); - -string = ']['; -status = inSection(27); -actualmatch = string.match(pattern); -expectedmatch = Array(']'); -addThis(); - - -pattern = /a[^]/; -string = 'abc'; -status = inSection(28); -actualmatch = string.match(pattern); -expectedmatch = Array('ab'); -addThis(); - -string = ''; -status = inSection(29); -actualmatch = string.match(pattern); -expectedmatch = null; //there are no characters to test against the condition -addThis(); - -string = 'a['; -status = inSection(30); -actualmatch = string.match(pattern); -expectedmatch = Array('a['); -addThis(); - -string = 'a]'; -status = inSection(31); -actualmatch = string.match(pattern); -expectedmatch = Array('a]'); -addThis(); - -string = 'a[]'; -status = inSection(32); -actualmatch = string.match(pattern); -expectedmatch = Array('a['); -addThis(); - -string = 'a[ ]'; -status = inSection(33); -actualmatch = string.match(pattern); -expectedmatch = Array('a['); -addThis(); - -string = 'a]['; -status = inSection(34); -actualmatch = string.match(pattern); -expectedmatch = Array('a]'); -addThis(); - - - - -//----------------------------------------------------------------------------- -test(); -//----------------------------------------------------------------------------- - - - -function addThis() -{ - statusmessages[i] = status; - patterns[i] = pattern; - strings[i] = string; - actualmatches[i] = actualmatch; - expectedmatches[i] = expectedmatch; - i++; -} - - -function test() -{ - enterFunc ('test'); - printBugNumber(BUGNUMBER); - printStatus (summary); - testRegExp(statusmessages, patterns, strings, actualmatches, expectedmatches); - exitFunc ('test'); -} diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-105972.js b/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-105972.js deleted file mode 100644 index e691c518b4..0000000000 --- a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-105972.js +++ /dev/null @@ -1,157 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is mozilla.org code. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * mozilla@pdavis.cx, pschwartau@netscape.com - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -/* - * Date: 22 October 2001 - * - * SUMMARY: Regression test for Bugzilla bug 105972: - * "/^.*?$/ will not match anything" - * - * See http://bugzilla.mozilla.org/show_bug.cgi?id=105972 - */ -//----------------------------------------------------------------------------- -var gTestfile = 'regress-105972.js'; -var i = 0; -var BUGNUMBER = 105972; -var summary = 'Regression test for Bugzilla bug 105972'; -var cnEmptyString = ''; -var status = ''; -var statusmessages = new Array(); -var pattern = ''; -var patterns = new Array(); -var string = ''; -var strings = new Array(); -var actualmatch = ''; -var actualmatches = new Array(); -var expectedmatch = ''; -var expectedmatches = new Array(); - - -/* - * The bug: this match was coming up null in Rhino and SpiderMonkey. - * It should match the whole string. The reason: - * - * The * operator is greedy, but *? is non-greedy: it will stop - * at the simplest match it can find. But the pattern here asks us - * to match till the end of the string. So the simplest match must - * go all the way out to the end, and *? has no choice but to do it. - */ -status = inSection(1); -pattern = /^.*?$/; -string = 'Hello World'; -actualmatch = string.match(pattern); -expectedmatch = Array(string); -addThis(); - - -/* - * Leave off the '$' condition - here we expect the empty string. - * Unlike the above pattern, we don't have to match till the end of - * the string, so the non-greedy operator *? doesn't try to... - */ -status = inSection(2); -pattern = /^.*?/; -string = 'Hello World'; -actualmatch = string.match(pattern); -expectedmatch = Array(cnEmptyString); -addThis(); - - -/* - * Try '$' combined with an 'or' operator. - * - * The operator *? will consume the string from left to right, - * attempting to satisfy the condition (:|$). When it hits ':', - * the match will stop because the operator *? is non-greedy. - * - * The submatch $1 = (:|$) will contain the ':' - */ -status = inSection(3); -pattern = /^.*?(:|$)/; -string = 'Hello: World'; -actualmatch = string.match(pattern); -expectedmatch = Array('Hello:', ':'); -addThis(); - - -/* - * Again, '$' combined with an 'or' operator. - * - * The operator * will consume the string from left to right, - * attempting to satisfy the condition (:|$). When it hits ':', - * the match will not stop since * is greedy. The match will - * continue until it hits $, the end-of-string boundary. - * - * The submatch $1 = (:|$) will contain the empty string - * conceived to exist at the end-of-string boundary. - */ -status = inSection(4); -pattern = /^.*(:|$)/; -string = 'Hello: World'; -actualmatch = string.match(pattern); -expectedmatch = Array(string, cnEmptyString); -addThis(); - - - - -//----------------------------------------------------------------------------- -test(); -//----------------------------------------------------------------------------- - - - -function addThis() -{ - statusmessages[i] = status; - patterns[i] = pattern; - strings[i] = string; - actualmatches[i] = actualmatch; - expectedmatches[i] = expectedmatch; - i++; -} - - -function test() -{ - enterFunc ('test'); - printBugNumber(BUGNUMBER); - printStatus (summary); - testRegExp(statusmessages, patterns, strings, actualmatches, expectedmatches); - exitFunc ('test'); -} diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-119909.js b/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-119909.js deleted file mode 100644 index 97f6414bc7..0000000000 --- a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-119909.js +++ /dev/null @@ -1,92 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is JavaScript Engine testing utilities. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corp. - * Portions created by the Initial Developer are Copyright (C) 2001 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * 1010mozilla@Ostermiller.com, pschwartau@netscape.com - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -/* - * - * Date: 14 Jan 2002 - * SUMMARY: Shouldn't crash on regexps with many nested parentheses - * See http://bugzilla.mozilla.org/show_bug.cgi?id=119909 - * - */ -//----------------------------------------------------------------------------- -var gTestfile = 'regress-119909.js'; -var BUGNUMBER = 119909; -var summary = "Shouldn't crash on regexps with many nested parentheses"; -var NO_BACKREFS = false; -var DO_BACKREFS = true; - - -//-------------------------------------------------- -test(); -//-------------------------------------------------- - - -function test() -{ - enterFunc('test'); - printBugNumber(BUGNUMBER); - printStatus(summary); - - testThis(500, NO_BACKREFS, 'hello', 'goodbye'); - testThis(500, DO_BACKREFS, 'hello', 'goodbye'); - - reportCompare('No Crash', 'No Crash', ''); - - exitFunc('test'); -} - - -/* - * Creates a regexp pattern like (((((((((hello))))))))) - * and tests str.search(), str.match(), str.replace() - */ -function testThis(numParens, doBackRefs, strOriginal, strReplace) -{ - var openParen = doBackRefs? '(' : '(?:'; - var closeParen = ')'; - var pattern = ''; - - for (var i=0; i((.*\n?)*?)<\/body>/i; -actualmatch = string.match(pattern); -expectedmatch = Array(sBody, '\n

Kibology for all

\n

All for Kibology

\n', '

All for Kibology

\n'); -addThis(); - - - -//------------------------------------------------------------------------------------------------- -test(); -//------------------------------------------------------------------------------------------------- - - -function addThis() -{ - statusmessages[i] = status; - patterns[i] = pattern; - strings[i] = string; - actualmatches[i] = actualmatch; - expectedmatches[i] = expectedmatch; - i++; -} - - -function test() -{ - enterFunc ('test'); - printBugNumber(BUGNUMBER); - printStatus (summary); - testRegExp(statusmessages, patterns, strings, actualmatches, expectedmatches); - exitFunc ('test'); -} diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-169534.js b/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-169534.js deleted file mode 100644 index c736631bd7..0000000000 --- a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-169534.js +++ /dev/null @@ -1,95 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is JavaScript Engine testing utilities. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corp. - * Portions created by the Initial Developer are Copyright (C) 2002 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * pschwartau@netscape.com - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -/* - * - * Date: 20 Sep 2002 - * SUMMARY: RegExp conformance test - * See http://bugzilla.mozilla.org/show_bug.cgi?id=169534 - * - */ -//----------------------------------------------------------------------------- -var gTestfile = 'regress-169534.js'; -var UBound = 0; -var BUGNUMBER = 169534; -var summary = 'RegExp conformance test'; -var status = ''; -var statusitems = []; -var actual = ''; -var actualvalues = []; -var expect= ''; -var expectedvalues = []; - - -status = inSection(1); -var re = /(\|)([\w\x81-\xff ]*)(\|)([\/a-z][\w:\/\.]*\.[a-z]{3,4})(\|)/ig; -var str = "To sign up click |here|https://www.xxxx.org/subscribe.htm|"; -actual = str.replace(re, '$2'); -expect = 'To sign up click here'; -addThis(); - - - -//----------------------------------------------------------------------------- -test(); -//----------------------------------------------------------------------------- - - - -function addThis() -{ - statusitems[UBound] = status; - actualvalues[UBound] = actual; - expectedvalues[UBound] = expect; - UBound++; -} - - -function test() -{ - enterFunc('test'); - printBugNumber(BUGNUMBER); - printStatus(summary); - - for (var i=0; i/g,'>'); - } - - h+='\n'; - h=h.replace(/&([^\s]+;)/g,'<&$1>'); - h=h.replace(new RegExp('','g'), S); - h=h.replace(/"[^"]*"/g,S); - h=h.replace(/'[^']*'/g,S); - - - h=h.replace(/<([^>]*)>/g, - function(s,p) - { - if(s.match(/!doctype/i)) - return'<' + p + '>'; - - p=p.replace(/\\'/g,'\\'').replace(/\\"/g,'\\"').replace(/^\s/,''); -p=p.replace(/(\s)([^<]+)$/g, - function(s,p1,p2) - { - p2=p2.replace(/(=)(\s*[^"'][^\s]*)(\s|$)/g,'$1$2$3'); - p2=p2.replace(/("[^"]*")/g,'$1'); - p2=p2.replace(/('[^']*')/g,'$1'); - return p1 + ''+p2+''; - } - ) - - return'<' + p + '>'; - } - ) - - - h=h.replace(/<(&[^\s]+;)>/g,'$1'); - h=h.replace(/(<!--[\s\S]*-->)/g,'$1'); - - - numer=1; - h=h.replace(/(.*\n)/g, - function(s,p) - { - return (numer++) +'. ' + p; - } - ) - - - return'' + h + ''; -} - - - -/* - * sanity check - */ -status = inSection(1); -actual = formatHTML('abc'); -expect = '1. abc\n'; -addThis(); - - -/* - * The real test: can we run this without crashing? - * We are not validating the result, just running it. - */ -status = inSection(2); -var HUGE_TEST_STRING = hugeString(); -formatHTML(HUGE_TEST_STRING); - - - - -//----------------------------------------------------------------------------- -test(); -//----------------------------------------------------------------------------- - - - -function addThis() -{ - statusitems[UBound] = status; - actualvalues[UBound] = actual; - expectedvalues[UBound] = expect; - UBound++; -} - - -function test() -{ - enterFunc('test'); - printBugNumber(BUGNUMBER); - printStatus(summary); - - for (var i=0; i','g'),""); - stra=stra.replace(new RegExp('','g'),"
"); -} - -function runTest() { - for (var j = 1000; j <= 10000; j += 1000) - { - neurodna(j); - } -} - -function neurodna(limit) { - var prepare=""; - for(var i=0;i])*-->', 'g'), ''); -printStatus(data); - -reportCompare(expect, actual, summary); diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-309840.js b/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-309840.js deleted file mode 100755 index 8680b7bcfd..0000000000 --- a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-309840.js +++ /dev/null @@ -1,58 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is JavaScript Engine testing utilities. - * - * The Initial Developer of the Original Code is - * Mozilla Foundation. - * Portions created by the Initial Developer are Copyright (C) 2005 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): Phil Schwartau - * Bob Clary - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -var gTestfile = 'regress-309840.js'; -//----------------------------------------------------------------------------- -var BUGNUMBER = 309840; -var summary = 'Treat / in a literal regexp class as valid'; -var actual = 'No error'; -var expect = 'No error'; - -printBugNumber(BUGNUMBER); -printStatus (summary); - -try -{ - var re = eval('/[/]/'); -} -catch(e) -{ - actual = e.toString(); -} - -reportCompare(expect, actual, summary); diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-311414.js b/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-311414.js deleted file mode 100755 index a24a07bb2b..0000000000 --- a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-311414.js +++ /dev/null @@ -1,101 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is JavaScript Engine testing utilities. - * - * The Initial Developer of the Original Code is - * Mozilla Foundation. - * Portions created by the Initial Developer are Copyright (C) 2005 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): timeless - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -var gTestfile = 'regress-311414.js'; -//----------------------------------------------------------------------------- -var BUGNUMBER = 311414; -var summary = 'RegExp captured tail match should be O(N)'; -var actual = ''; -var expect = ''; - -printBugNumber(BUGNUMBER); -printStatus (summary); - -function q1(n) { - var c = []; - c[n] = 1; - c = c.join(" "); - var d = Date.now(); - var e = c.match(/(.*)foo$/); - var f = Date.now(); - return (f - d); -} - -function q2(n) { - var c = []; - c[n] = 1; - c = c.join(" "); - var d = Date.now(); - var e = /foo$/.test(c) && c.match(/(.*)foo$/); - var f = Date.now(); - return (f - d); -} - -var data1 = {X:[], Y:[]}; -var data2 = {X:[], Y:[]}; - -for (var x = 500; x < 5000; x += 500) -{ - var y1 = q1(x); - var y2 = q2(x); - data1.X.push(x); - data1.Y.push(y1); - data2.X.push(x); - data2.Y.push(y2); - gc(); -} - -var order1 = BigO(data1); -var order2 = BigO(data2); - -var msg = ''; -for (var p = 0; p < data1.X.length; p++) -{ - msg += '(' + data1.X[p] + ', ' + data1.Y[p] + '); '; -} -printStatus(msg); -printStatus('Order: ' + order1); -reportCompare(true, order1 < 2 , summary + ' BigO ' + order1 + ' < 2'); - -msg = ''; -for (var p = 0; p < data2.X.length; p++) -{ - msg += '(' + data2.X[p] + ', ' + data2.Y[p] + '); '; -} -printStatus(msg); -printStatus('Order: ' + order2); -reportCompare(true, order2 < 2 , summary + ' BigO ' + order2 + ' < 2'); diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-312351.js b/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-312351.js deleted file mode 100755 index a9b00d317c..0000000000 --- a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-312351.js +++ /dev/null @@ -1,50 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is JavaScript Engine testing utilities. - * - * The Initial Developer of the Original Code is - * Mozilla Foundation. - * Portions created by the Initial Developer are Copyright (C) 2005 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): drimbk@yahoo.com - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -var gTestfile = 'regress-312351.js'; -//----------------------------------------------------------------------------- -var BUGNUMBER = 312351; -var summary = 'Do not crash on RegExp(null)'; -var actual = 'No Crash'; -var expect = 'No Crash'; - -printBugNumber(BUGNUMBER); -printStatus (summary); - -var x = RegExp(null); - -reportCompare(expect, actual, summary); diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-31316.js b/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-31316.js deleted file mode 100644 index 594913f07c..0000000000 --- a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-31316.js +++ /dev/null @@ -1,96 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is mozilla.org code. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * pschwartau@netscape.com - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -/* - * Date: 01 May 2001 - * - * SUMMARY: Regression test for Bugzilla bug 31316: - * "Rhino: Regexp matches return garbage" - * - * See http://bugzilla.mozilla.org/show_bug.cgi?id=31316 - */ -//----------------------------------------------------------------------------- -var gTestfile = 'regress-31316.js'; -var i = 0; -var BUGNUMBER = 31316; -var summary = 'Regression test for Bugzilla bug 31316'; -var cnEmptyString = ''; -var status = ''; -var statusmessages = new Array(); -var pattern = ''; -var patterns = new Array(); -var string = ''; -var strings = new Array(); -var actualmatch = ''; -var actualmatches = new Array(); -var expectedmatch = ''; -var expectedmatches = new Array(); - - -status = inSection(1); -pattern = /<([^\/<>][^<>]*[^\/])>|<([^\/<>])>/; -string = '

Some
test

'; -actualmatch = string.match(pattern); -expectedmatch = Array('

', undefined, 'p'); -addThis(); - - -//------------------------------------------------------------------------------------------------- -test(); -//------------------------------------------------------------------------------------------------- - - -function addThis() -{ - statusmessages[i] = status; - patterns[i] = pattern; - strings[i] = string; - actualmatches[i] = actualmatch; - expectedmatches[i] = expectedmatch; - i++; -} - - -function test() -{ - enterFunc ('test'); - printBugNumber(BUGNUMBER); - printStatus (summary); - testRegExp(statusmessages, patterns, strings, actualmatches, expectedmatches); - exitFunc ('test'); -} diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-330684.js b/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-330684.js deleted file mode 100755 index b097fbc3d7..0000000000 --- a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-330684.js +++ /dev/null @@ -1,53 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is JavaScript Engine testing utilities. - * - * The Initial Developer of the Original Code is - * Mozilla Foundation. - * Portions created by the Initial Developer are Copyright (C) 2006 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): Shaohua Wen - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -var gTestfile = 'regress-330684.js'; -//----------------------------------------------------------------------------- -var BUGNUMBER = 330684; -var summary = 'Do not hang on RegExp'; -var actual = 'Do not hang on RegExp'; -var expect = ''; - -printBugNumber(BUGNUMBER); -printStatus (summary); - -var re = /^(?:(?:%[0-9A-Fa-f]{2})*[!\$&'\*-;=\?-Z_a-z]*)+$/; -var url = "http://tw.yimg.com/a/tw/wenchuan/cam_240x400_381615_030806_2.swf?clickTAG=javascript:VRECopenWindow(1)"; - -printStatus(re.test(url)); - -reportCompare(expect, actual, summary); diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-334158.js b/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-334158.js deleted file mode 100755 index 41ebf0a731..0000000000 --- a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-334158.js +++ /dev/null @@ -1,58 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is JavaScript Engine testing utilities. - * - * The Initial Developer of the Original Code is - * Mozilla Foundation. - * Portions created by the Initial Developer are Copyright (C) 2006 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): Andreas - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -var gTestfile = 'regress-334158.js'; -//----------------------------------------------------------------------------- -var BUGNUMBER = 334158; -var summary = 'Parse error in control letter escapes (RegExp)'; -var actual = ''; -var expect = ''; - -printBugNumber(BUGNUMBER); -printStatus (summary); - -expect = true; -actual = /\ca/.test( "\x01" ); -reportCompare(expect, actual, summary + ':/\ca/.test( "\x01" )'); - -expect = false - actual = /\ca/.test( "\\ca" ); -reportCompare(expect, actual, summary + ': /\ca/.test( "\\ca" )'); - -expect = false - actual = /\c[a/]/.test( "\x1ba/]" ); -reportCompare(expect, actual, summary + ': /\c[a/]/.test( "\x1ba/]" )'); diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-346090.js b/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-346090.js deleted file mode 100755 index dfd53a9922..0000000000 --- a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-346090.js +++ /dev/null @@ -1,63 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is JavaScript Engine testing utilities. - * - * The Initial Developer of the Original Code is - * Mozilla Foundation. - * Portions created by the Initial Developer are Copyright (C) 2006 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): Priit Laes - * Brian Crowder - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -var gTestfile = 'regress-346090.js'; -//----------------------------------------------------------------------------- -var BUGNUMBER = 346090; -var summary = 'Do not crash with this regexp'; -var actual = 'No Crash'; -var expect = 'No Crash'; - - -//----------------------------------------------------------------------------- -test(); -//----------------------------------------------------------------------------- - -function test() -{ - enterFunc ('test'); - printBugNumber(BUGNUMBER); - printStatus (summary); - - var r = /%((h[^l]+)|(l[^h]+)){0,2}?a/g; - r.exec('%lld %d'); - - reportCompare(expect, actual, summary); - - exitFunc ('test'); -} diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-367888.js b/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-367888.js deleted file mode 100755 index 923c1e5ab3..0000000000 --- a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-367888.js +++ /dev/null @@ -1,62 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is JavaScript Engine testing utilities. - * - * The Initial Developer of the Original Code is - * Mozilla Foundation. - * Portions created by the Initial Developer are Copyright (C) 2007 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): Jesse Ruderman - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -var gTestfile = 'regress-367888.js'; -//----------------------------------------------------------------------------- -var BUGNUMBER = 367888; -var summary = 'RegExp /(|)??x/g.exec("y") barfs'; -var actual = ''; -var expect = ''; - - -//----------------------------------------------------------------------------- -test(); -//----------------------------------------------------------------------------- - -function test() -{ - enterFunc ('test'); - printBugNumber(BUGNUMBER); - printStatus (summary); - - expect = null; - actual = /(|)??x/g.exec("y"); - - reportCompare(expect, actual, summary); - - exitFunc ('test'); -} diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-375642.js b/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-375642.js deleted file mode 100755 index 236eb00d28..0000000000 --- a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-375642.js +++ /dev/null @@ -1,61 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is JavaScript Engine testing utilities. - * - * The Initial Developer of the Original Code is - * Mozilla Foundation. - * Portions created by the Initial Developer are Copyright (C) 2007 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): Jesse Ruderman - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -var gTestfile = 'regress-375642.js'; -//----------------------------------------------------------------------------- -var BUGNUMBER = 375642; -var summary = 'RegExp /(?:a??)+?/.exec("")'; -var actual = ''; -var expect = ''; - - -//----------------------------------------------------------------------------- -test(); -//----------------------------------------------------------------------------- - -function test() -{ - enterFunc ('test'); - printBugNumber(BUGNUMBER); - printStatus (summary); - - /(?:a??)+?/.exec("") - - reportCompare(expect, actual, summary); - - exitFunc ('test'); -} diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-375711.js b/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-375711.js deleted file mode 100755 index 6e7339f9e9..0000000000 --- a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-375711.js +++ /dev/null @@ -1,118 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is JavaScript Engine testing utilities. - * - * The Initial Developer of the Original Code is - * Mozilla Foundation. - * Portions created by the Initial Developer are Copyright (C) 2007 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): Jesse Ruderman - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -var gTestfile = 'regress-375711.js'; -//----------------------------------------------------------------------------- -var BUGNUMBER = 375711; -var summary = 'Do not assert with /[Q-b]/i.exec("")'; -var actual = ''; -var expect = ''; - - -//----------------------------------------------------------------------------- -test(); -//----------------------------------------------------------------------------- - -function test() -{ - enterFunc ('test'); - printBugNumber(BUGNUMBER); - printStatus (summary); - - var s; - - // see bug 416933 - print('see bug 416933 for changed behavior on Gecko 1.9'); - - try - { - s = '/[Q-b]/.exec("")'; - expect = 'No Error'; - print(s + ' expect ' + expect); - eval(s); - actual = 'No Error'; - } - catch(ex) - { - actual = ex + ''; - } - reportCompare(expect, actual, summary + ': ' + s); - - try - { - s ='/[Q-b]/i.exec("")'; - expect = 'No Error'; - print(s + ' expect ' + expect); - eval(s); - actual = 'No Error'; - } - catch(ex) - { - actual = ex + ''; - } - reportCompare(expect, actual, summary + ': ' + s); - - try - { - s = '/[q-b]/.exec("")'; - expect = 'SyntaxError: invalid range in character class'; - print(s + ' expect ' + expect); - eval(s); - actual = 'No Error'; - } - catch(ex) - { - actual = ex + ''; - } - reportCompare(expect, actual, summary + ': ' + s); - - try - { - s ='/[q-b]/i.exec("")'; - expect = 'SyntaxError: invalid range in character class'; - print(s + ' expect ' + expect); - eval(s); - actual = 'No Error'; - } - catch(ex) - { - actual = ex + ''; - } - reportCompare(expect, actual, summary + ': ' + s); - - exitFunc ('test'); -} diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-375715-01-n.js b/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-375715-01-n.js deleted file mode 100755 index 437dcbd5c5..0000000000 --- a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-375715-01-n.js +++ /dev/null @@ -1,63 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is JavaScript Engine testing utilities. - * - * The Initial Developer of the Original Code is - * Mozilla Foundation. - * Portions created by the Initial Developer are Copyright (C) 2007 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): Jesse Ruderman - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -var gTestfile = 'regress-375715-01-n.js'; -//----------------------------------------------------------------------------- -var BUGNUMBER = 375715; -var summary = 'Do not assert: (c2 <= cs->length) && (c1 <= c2)'; -var actual = ''; -var expect = ''; - -//----------------------------------------------------------------------------- -test(); -//----------------------------------------------------------------------------- - -function test() -{ - enterFunc ('test'); - printBugNumber(BUGNUMBER); - printStatus (summary); - - // note that the assertion does not fire if the regexp is - // evald or used in new RegExp, so this test must be an -n - // with uncaught SyntaxError. - - /[\Wb-G]/.exec(""); - reportCompare(expect, actual, summary + ' /[\Wb-G]/.exec("")'); - - exitFunc ('test'); -} diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-375715-02.js b/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-375715-02.js deleted file mode 100755 index 3cd858e845..0000000000 --- a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-375715-02.js +++ /dev/null @@ -1,60 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is JavaScript Engine testing utilities. - * - * The Initial Developer of the Original Code is - * Mozilla Foundation. - * Portions created by the Initial Developer are Copyright (C) 2007 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): Jesse Ruderman - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -var gTestfile = 'regress-375715-02.js'; -//----------------------------------------------------------------------------- -var BUGNUMBER = 375715; -var summary = 'Do not assert: (c2 <= cs->length) && (c1 <= c2)'; -var actual = ''; -var expect = ''; - - -//----------------------------------------------------------------------------- -test(); -//----------------------------------------------------------------------------- - -function test() -{ - enterFunc ('test'); - printBugNumber(BUGNUMBER); - printStatus (summary); - - /[\s-:]/; - reportCompare(expect, actual, summary + '/[\s-:]/'); - - exitFunc ('test'); -} diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-375715-03.js b/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-375715-03.js deleted file mode 100755 index ffc5c5a4cc..0000000000 --- a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-375715-03.js +++ /dev/null @@ -1,60 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is JavaScript Engine testing utilities. - * - * The Initial Developer of the Original Code is - * Mozilla Foundation. - * Portions created by the Initial Developer are Copyright (C) 2007 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): Jesse Ruderman - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -var gTestfile = 'regress-375715-03.js'; -//----------------------------------------------------------------------------- -var BUGNUMBER = 375715; -var summary = 'Do not assert: (c2 <= cs->length) && (c1 <= c2)'; -var actual = ''; -var expect = ''; - - -//----------------------------------------------------------------------------- -test(); -//----------------------------------------------------------------------------- - -function test() -{ - enterFunc ('test'); - printBugNumber(BUGNUMBER); - printStatus (summary); - - /[_-t]/i.exec(""); - reportCompare(expect, actual, summary + '/[_-t]/i.exec("")'); - - exitFunc ('test'); -} diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-375715-04.js b/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-375715-04.js deleted file mode 100755 index 0c78a372ee..0000000000 --- a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-375715-04.js +++ /dev/null @@ -1,68 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is JavaScript Engine testing utilities. - * - * The Initial Developer of the Original Code is - * Mozilla Foundation. - * Portions created by the Initial Developer are Copyright (C) 2007 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): Jesse Ruderman - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -var gTestfile = 'regress-375715-04.js'; -//----------------------------------------------------------------------------- -var BUGNUMBER = 375715; -var summary = 'Do not assert: (c2 <= cs->length) && (c1 <= c2)'; -var actual = ''; -var expect = ''; - - -//----------------------------------------------------------------------------- -test(); -//----------------------------------------------------------------------------- - -function test() -{ - enterFunc ('test'); - printBugNumber(BUGNUMBER); - printStatus (summary); - - try - { - expect = 'SyntaxError: invalid range in character class'; - (new RegExp("[\xDF-\xC7]]", "i")).exec(""); - } - catch(ex) - { - actual = ex + ''; - } - reportCompare(expect, actual, summary + '(new RegExp("[\xDF-\xC7]]", "i")).exec("")'); - - exitFunc ('test'); -} diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-57572.js b/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-57572.js deleted file mode 100644 index c7abd410bf..0000000000 --- a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-57572.js +++ /dev/null @@ -1,150 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is mozilla.org code. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * pschwartau@netscape.com - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -/* - * Date: 28 December 2000 - * - * SUMMARY: Testing regular expressions containing the ? character. - * Arose from Bugzilla bug 57572: "RegExp with ? matches incorrectly" - * - * See http://bugzilla.mozilla.org/show_bug.cgi?id=57572 - * - */ -//----------------------------------------------------------------------------- -var gTestfile = 'regress-57572.js'; -var i = 0; -var BUGNUMBER = 57572; -var summary = 'Testing regular expressions containing "?"'; -var cnEmptyString = ''; var cnSingleSpace = ' '; -var status = ''; -var statusmessages = new Array(); -var pattern = ''; -var patterns = new Array(); -var string = ''; -var strings = new Array(); -var actualmatch = ''; -var actualmatches = new Array(); -var expectedmatch = ''; -var expectedmatches = new Array(); - - -status = inSection(1); -pattern = /(\S+)?(.*)/; -string = 'Test this'; -actualmatch = string.match(pattern); -expectedmatch = Array(string, 'Test', ' this'); //single space in front of 'this' -addThis(); - -status = inSection(2); -pattern = /(\S+)? ?(.*)/; //single space between the ? characters -string= 'Test this'; -actualmatch = string.match(pattern); -expectedmatch = Array(string, 'Test', 'this'); //NO space in front of 'this' -addThis(); - -status = inSection(3); -pattern = /(\S+)?(.*)/; -string = 'Stupid phrase, with six - (short) words'; -actualmatch = string.match(pattern); -expectedmatch = Array(string, 'Stupid', ' phrase, with six - (short) words'); //single space in front of 'phrase' -addThis(); - -status = inSection(4); -pattern = /(\S+)? ?(.*)/; //single space between the ? characters -string = 'Stupid phrase, with six - (short) words'; -actualmatch = string.match(pattern); -expectedmatch = Array(string, 'Stupid', 'phrase, with six - (short) words'); //NO space in front of 'phrase' -addThis(); - - -// let's add an extra back-reference this time - three instead of two - -status = inSection(5); -pattern = /(\S+)?( ?)(.*)/; //single space before second ? character -string = 'Stupid phrase, with six - (short) words'; -actualmatch = string.match(pattern); -expectedmatch = Array(string, 'Stupid', cnSingleSpace, 'phrase, with six - (short) words'); -addThis(); - -status = inSection(6); -pattern = /^(\S+)?( ?)(B+)$/; //single space before second ? character -string = 'AAABBB'; -actualmatch = string.match(pattern); -expectedmatch = Array(string, 'AAABB', cnEmptyString, 'B'); -addThis(); - -status = inSection(7); -pattern = /(\S+)?(!?)(.*)/; -string = 'WOW !!! !!!'; -actualmatch = string.match(pattern); -expectedmatch = Array(string, 'WOW', cnEmptyString, ' !!! !!!'); -addThis(); - -status = inSection(8); -pattern = /(.+)?(!?)(!+)/; -string = 'WOW !!! !!!'; -actualmatch = string.match(pattern); -expectedmatch = Array(string, 'WOW !!! !!', cnEmptyString, '!'); -addThis(); - - - -//----------------------------------------------------------------------------- -test(); -//----------------------------------------------------------------------------- - - - -function addThis() -{ - statusmessages[i] = status; - patterns[i] = pattern; - strings[i] = string; - actualmatches[i] = actualmatch; - expectedmatches[i] = expectedmatch; - i++; -} - - -function test() -{ - enterFunc ('test'); - printBugNumber(BUGNUMBER); - printStatus (summary); - testRegExp(statusmessages, patterns, strings, actualmatches, expectedmatches); - exitFunc ('test'); -} diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-57631.js b/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-57631.js deleted file mode 100644 index dc222bfc0f..0000000000 --- a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-57631.js +++ /dev/null @@ -1,152 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is mozilla.org code. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * pschwartau@netscape.com, zack-weg@gmx.de - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -/* - * Date: 26 November 2000 - * - * - * SUMMARY: This test arose from Bugzilla bug 57631: - * "RegExp with invalid pattern or invalid flag causes segfault" - * - * Either error should throw an exception of type SyntaxError, - * and we check to see that it does... - */ -//----------------------------------------------------------------------------- -var gTestfile = 'regress-57631.js'; -var BUGNUMBER = '57631'; -var summary = 'Testing new RegExp(pattern,flag) with illegal pattern or flag'; -var statprefix = 'Testing for error creating illegal RegExp object on pattern '; -var statsuffix = 'and flag '; -var cnSUCCESS = 'SyntaxError'; -var cnFAILURE = 'not a SyntaxError'; -var singlequote = "'"; -var i = -1; var j = -1; var s = ''; var f = ''; -var obj = {}; -var status = ''; var actual = ''; var expect = ''; var msg = ''; -var legalpatterns = new Array(); var illegalpatterns = new Array(); -var legalflags = new Array(); var illegalflags = new Array(); - - -// valid regular expressions to try - -legalpatterns[0] = ''; -legalpatterns[1] = 'abc'; -legalpatterns[2] = '(.*)(3-1)\s\w'; -legalpatterns[3] = '(.*)(...)\\s\\w'; -legalpatterns[4] = '[^A-Za-z0-9_]'; -legalpatterns[5] = '[^\f\n\r\t\v](123.5)([4 - 8]$)'; - -// invalid regular expressions to try - -illegalpatterns[0] = '(?)'; -illegalpatterns[1] = '(a'; -illegalpatterns[2] = '( ]'; -//illegalpatterns[3] = '\d{1,s}'; - -// valid flags to try - -legalflags[0] = 'i'; -legalflags[1] = 'g'; -legalflags[2] = 'm'; -legalflags[3] = undefined; - -// invalid flags to try - -illegalflags[0] = 'a'; -illegalflags[1] = 123; -illegalflags[2] = new RegExp(); - - - -//------------------------------------------------------------------------------------------------- -test(); -//------------------------------------------------------------------------------------------------- - - -function test() -{ - enterFunc ('test'); - printBugNumber(BUGNUMBER); - printStatus (summary); - - testIllegalRegExps(legalpatterns, illegalflags); - testIllegalRegExps(illegalpatterns, legalflags); - testIllegalRegExps(illegalpatterns, illegalflags); - - exitFunc ('test'); -} - - -// This function will only be called where all the patterns are illegal, or all the flags -function testIllegalRegExps(patterns, flags) -{ - for (i in patterns) - { - s = patterns[i]; - - for (j in flags) - { - f = flags[j]; - status = getStatus(s, f); - actual = cnFAILURE; - expect = cnSUCCESS; - - try - { - // This should cause an exception if either s or f is illegal - - eval('obj = new RegExp(s, f);'); - } - catch(e) - { - // We expect to get a SyntaxError - test for this: - if (e instanceof SyntaxError) - actual = cnSUCCESS; - } - - reportCompare(expect, actual, status); - } - } -} - - -function getStatus(regexp, flag) -{ - return (statprefix + quote(regexp) + statsuffix + quote(flag)); -} - - -function quote(text) -{ - return (singlequote + text + singlequote); -} diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-67773.js b/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-67773.js deleted file mode 100644 index 4ee0d52854..0000000000 --- a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-67773.js +++ /dev/null @@ -1,211 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is mozilla.org code. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * pschwartau@netscape.com - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -/* - * Date: 06 February 2001 - * - * SUMMARY: Arose from Bugzilla bug 67773: - * "Regular subexpressions followed by + failing to run to completion" - * - * See http://bugzilla.mozilla.org/show_bug.cgi?id=67773 - * See http://bugzilla.mozilla.org/show_bug.cgi?id=69989 - */ -//----------------------------------------------------------------------------- -var gTestfile = 'regress-67773.js'; -var i = 0; -var BUGNUMBER = 67773; -var summary = 'Testing regular subexpressions followed by ? or +\n'; -var cnSingleSpace = ' '; -var status = ''; -var statusmessages = new Array(); -var pattern = ''; -var patterns = new Array(); -var string = ''; -var strings = new Array(); -var actualmatch = ''; -var actualmatches = new Array(); -var expectedmatch = ''; -var expectedmatches = new Array(); - - -pattern = /^(\S+)?( ?)(B+)$/; //single space before second ? character -status = inSection(1); -string = 'AAABBB AAABBB '; //single space at middle and at end - -actualmatch = string.match(pattern); -expectedmatch = null; -addThis(); - -status = inSection(2); -string = 'AAABBB BBB'; //single space in the middle -actualmatch = string.match(pattern); -expectedmatch = Array(string, 'AAABBB', cnSingleSpace, 'BBB'); -addThis(); - -status = inSection(3); -string = 'AAABBB AAABBB'; //single space in the middle -actualmatch = string.match(pattern); -expectedmatch = null; -addThis(); - - -pattern = /^(A+B)+$/; -status = inSection(4); -string = 'AABAAB'; -actualmatch = string.match(pattern); -expectedmatch = Array(string, 'AAB'); -addThis(); - -status = inSection(5); -string = 'ABAABAAAAAAB'; -actualmatch = string.match(pattern); -expectedmatch = Array(string, 'AAAAAAB'); -addThis(); - -status = inSection(6); -string = 'ABAABAABAB'; -actualmatch = string.match(pattern); -expectedmatch = Array(string, 'AB'); -addThis(); - -status = inSection(7); -string = 'ABAABAABABB'; -actualmatch = string.match(pattern); -expectedmatch = null; // because string doesn't match at end -addThis(); - - -pattern = /^(A+1)+$/; -status = inSection(8); -string = 'AA1AA1'; -actualmatch = string.match(pattern); -expectedmatch = Array(string, 'AA1'); -addThis(); - - -pattern = /^(\w+\-)+$/; -status = inSection(9); -string = ''; -actualmatch = string.match(pattern); -expectedmatch = null; -addThis(); - -status = inSection(10); -string = 'bla-'; -actualmatch = string.match(pattern); -expectedmatch = Array(string, string); -addThis(); - -status = inSection(11); -string = 'bla-bla'; // hyphen missing at end - -actualmatch = string.match(pattern); -expectedmatch = null; //because string doesn't match at end -addThis(); - -status = inSection(12); -string = 'bla-bla-'; -actualmatch = string.match(pattern); -expectedmatch = Array(string, 'bla-'); -addThis(); - - -pattern = /^(\S+)+(A+)$/; -status = inSection(13); -string = 'asdldflkjAAA'; -actualmatch = string.match(pattern); -expectedmatch = Array(string, 'asdldflkjAA', 'A'); -addThis(); - -status = inSection(14); -string = 'asdldflkj AAA'; // space in middle -actualmatch = string.match(pattern); -expectedmatch = null; //because of the space -addThis(); - - -pattern = /^(\S+)+(\d+)$/; -status = inSection(15); -string = 'asdldflkj122211'; -actualmatch = string.match(pattern); -expectedmatch = Array(string, 'asdldflkj12221', '1'); -addThis(); - -status = inSection(16); -string = 'asdldflkj1111111aaa1'; -actualmatch = string.match(pattern); -expectedmatch = Array(string, 'asdldflkj1111111aaa', '1'); -addThis(); - - -/* - * This one comes from Stephen Ostermiller. - * See http://bugzilla.mozilla.org/show_bug.cgi?id=69989 - */ -pattern = /^[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)+$/; -status = inSection(17); -string = 'some.host.tld'; -actualmatch = string.match(pattern); -expectedmatch = Array(string, '.tld', '.'); -addThis(); - - - -//------------------------------------------------------------------------------------------------- -test(); -//------------------------------------------------------------------------------------------------- - - - -function addThis() -{ - statusmessages[i] = status; - patterns[i] = pattern; - strings[i] = string; - actualmatches[i] = actualmatch; - expectedmatches[i] = expectedmatch; - i++; -} - - -function test() -{ - enterFunc ('test'); - printBugNumber(BUGNUMBER); - printStatus (summary); - testRegExp(statusmessages, patterns, strings, actualmatches, expectedmatches); - exitFunc ('test'); -} diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-72964.js b/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-72964.js deleted file mode 100644 index 67a41e505c..0000000000 --- a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-72964.js +++ /dev/null @@ -1,121 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is mozilla.org code. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * pschwartau@netscape.com - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -/* - * Date: 2001-07-17 - * - * SUMMARY: Regression test for Bugzilla bug 72964: - * "String method for pattern matching failed for Chinese Simplified (GB2312)" - * - * See http://bugzilla.mozilla.org/show_bug.cgi?id=72964 - */ -//----------------------------------------------------------------------------- -var gTestfile = 'regress-72964.js'; -var i = 0; -var BUGNUMBER = 72964; -var summary = 'Testing regular expressions containing non-Latin1 characters'; -var cnSingleSpace = ' '; -var status = ''; -var statusmessages = new Array(); -var pattern = ''; -var patterns = new Array(); -var string = ''; -var strings = new Array(); -var actualmatch = ''; -var actualmatches = new Array(); -var expectedmatch = ''; -var expectedmatches = new Array(); - - -pattern = /[\S]+/; -// 4 low Unicode chars = Latin1; whole string should match -status = inSection(1); -string = '\u00BF\u00CD\u00BB\u00A7'; -actualmatch = string.match(pattern); -expectedmatch = Array(string); -addThis(); - -// Now put a space in the middle; first half of string should match -status = inSection(2); -string = '\u00BF\u00CD \u00BB\u00A7'; -actualmatch = string.match(pattern); -expectedmatch = Array('\u00BF\u00CD'); -addThis(); - - -// 4 high Unicode chars = non-Latin1; whole string should match -status = inSection(3); -string = '\u4e00\uac00\u4e03\u4e00'; -actualmatch = string.match(pattern); -expectedmatch = Array(string); -addThis(); - -// Now put a space in the middle; first half of string should match -status = inSection(4); -string = '\u4e00\uac00 \u4e03\u4e00'; -actualmatch = string.match(pattern); -expectedmatch = Array('\u4e00\uac00'); -addThis(); - - - -//----------------------------------------------------------------------------- -test(); -//----------------------------------------------------------------------------- - - - -function addThis() -{ - statusmessages[i] = status; - patterns[i] = pattern; - strings[i] = string; - actualmatches[i] = actualmatch; - expectedmatches[i] = expectedmatch; - i++; -} - - -function test() -{ - enterFunc ('test'); - printBugNumber(BUGNUMBER); - printStatus (summary); - testRegExp(statusmessages, patterns, strings, actualmatches, expectedmatches); - exitFunc ('test'); -} diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-76683.js b/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-76683.js deleted file mode 100644 index 8792e379ca..0000000000 --- a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-76683.js +++ /dev/null @@ -1,114 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is mozilla.org code. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * pschwartau@netscape.com - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -/* - * Date: 01 May 2001 - * - * SUMMARY: Regression test for Bugzilla bug 76683 on Rhino: - * "RegExp regression (NullPointerException)" - * - * See http://bugzilla.mozilla.org/show_bug.cgi?id=76683 - */ -//----------------------------------------------------------------------------- -var gTestfile = 'regress-76683.js'; -var i = 0; -var BUGNUMBER = 76683; -var summary = 'Regression test for Bugzilla bug 76683'; -var status = ''; -var statusmessages = new Array(); -var pattern = ''; -var patterns = new Array(); -var string = ''; -var strings = new Array(); -var actualmatch = ''; -var actualmatches = new Array(); -var expectedmatch = ''; -var expectedmatches = new Array(); - - -/* - * Rhino (2001-04-19) crashed on the 3rd regular expression below. - * It didn't matter what the string was. No problem in SpiderMonkey - - */ -string = 'abc'; -status = inSection(1); -pattern = /()|(<([\$\w:\.\-]+)((([ ][^\/>]*)?\/>)|(([ ][^>]*)?>)))/; -actualmatch = string.match(pattern); -expectedmatch = null; -addThis(); - -status = inSection(2); -pattern = /()|(<(tagPattern)((([ ][^\/>]*)?\/>)|(([ ][^>]*)?>)))/; -actualmatch = string.match(pattern); -expectedmatch = null; -addThis(); - -// This was the one causing a Rhino crash - -status = inSection(3); -pattern = /()|(<(tagPattern)((([ ][^\/>]*)?\/>)|(([ ][^>]*)?>)))|(<\/tagPattern[^>]*>)/; -actualmatch = string.match(pattern); -expectedmatch = null; -addThis(); - - - -//------------------------------------------------------------------------------------------------- -test(); -//------------------------------------------------------------------------------------------------- - - - -function addThis() -{ - statusmessages[i] = status; - patterns[i] = pattern; - strings[i] = string; - actualmatches[i] = actualmatch; - expectedmatches[i] = expectedmatch; - i++; -} - - -function test() -{ - enterFunc ('test'); - printBugNumber(BUGNUMBER); - printStatus (summary); - testRegExp(statusmessages, patterns, strings, actualmatches, expectedmatches); - exitFunc ('test'); -} diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-78156.js b/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-78156.js deleted file mode 100644 index dd42ce060b..0000000000 --- a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-78156.js +++ /dev/null @@ -1,123 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is mozilla.org code. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * pschwartau@netscape.com - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -/* - * Date: 06 February 2001 - * - * SUMMARY: Arose from Bugzilla bug 78156: - * "m flag of regular expression does not work with $" - * - * See http://bugzilla.mozilla.org/show_bug.cgi?id=78156 - * - * The m flag means a regular expression should search strings - * across multiple lines, i.e. across '\n', '\r'. - */ -//----------------------------------------------------------------------------- -var gTestfile = 'regress-78156.js'; -var i = 0; -var BUGNUMBER = 78156; -var summary = 'Testing regular expressions with ^, $, and the m flag -'; -var status = ''; -var statusmessages = new Array(); -var pattern = ''; -var patterns = new Array(); -var string = ''; -var strings = new Array(); -var actualmatch = ''; -var actualmatches = new Array(); -var expectedmatch = ''; -var expectedmatches = new Array(); - -/* - * All patterns have an m flag; all strings are multiline. - * Looking for digit characters at beginning/end of lines. - */ - -string = 'aaa\n789\r\nccc\r\n345'; -status = inSection(1); -pattern = /^\d/gm; -actualmatch = string.match(pattern); -expectedmatch = ['7','3']; -addThis(); - -status = inSection(2); -pattern = /\d$/gm; -actualmatch = string.match(pattern); -expectedmatch = ['9','5']; -addThis(); - -string = 'aaa\n789\r\nccc\r\nddd'; -status = inSection(3); -pattern = /^\d/gm; -actualmatch = string.match(pattern); -expectedmatch = ['7']; -addThis(); - -status = inSection(4); -pattern = /\d$/gm; -actualmatch = string.match(pattern); -expectedmatch = ['9']; -addThis(); - - - -//------------------------------------------------------------------------------------------------- -test(); -//------------------------------------------------------------------------------------------------- - - - -function addThis() -{ - statusmessages[i] = status; - patterns[i] = pattern; - strings[i] = string; - actualmatches[i] = actualmatch; - expectedmatches[i] = expectedmatch; - i++; -} - - -function test() -{ - enterFunc ('test'); - printBugNumber(BUGNUMBER); - printStatus (summary); - testRegExp(statusmessages, patterns, strings, actualmatches, expectedmatches); - exitFunc ('test'); -} diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-85721.js b/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-85721.js deleted file mode 100644 index bca1a15e19..0000000000 --- a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-85721.js +++ /dev/null @@ -1,276 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is JavaScript Engine testing utilities. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corp. - * Portions created by the Initial Developer are Copyright (C) 2002 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * rogerl@netscape.com, pschwartau@netscape.com - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -/* - * - * Date: 14 Feb 2002 - * SUMMARY: Performance: Regexp performance degraded from 4.7 - * See http://bugzilla.mozilla.org/show_bug.cgi?id=85721 - * - * Adjust this testcase if necessary. The FAST constant defines - * an upper bound in milliseconds for any execution to take. - * - */ -//----------------------------------------------------------------------------- -var gTestfile = 'regress-85721.js'; -var BUGNUMBER = 85721; -var summary = 'Performance: execution of regular expression'; -var FAST = 100; // execution should be 100 ms or less to pass the test -var MSG_FAST = 'Execution took less than ' + FAST + ' ms'; -var MSG_SLOW = 'Execution took '; -var MSG_MS = ' ms'; -var str = ''; -var re = ''; -var status = ''; -var actual = ''; -var expect= ''; - -printBugNumber(BUGNUMBER); -printStatus (summary); - - -function elapsedTime(startTime) -{ - return new Date() - startTime; -} - - -function isThisFast(ms) -{ - if (ms <= FAST) - return MSG_FAST; - return MSG_SLOW + ms + MSG_MS; -} - - - -/* - * The first regexp. We'll test for performance (Section 1) and accuracy (Section 2). - */ -str=' www.m.com drive.class\nfoo goo '; -re = /\s*\s*([^\r\n]*?)\s*<\/sql:url>\s*\s*([^\r\n]*?)\s*<\/sql:driver>\s*(\s*\s*([^\r\n]*?)\s*<\/sql:userId>\s*)?\s*(\s*\s*([^\r\n]*?)\s*<\/sql:password>\s*)?\s*<\/sql:connection>/; -expect = Array(" www.m.com drive.class\nfoo goo ","conn1","www.m.com","drive.class","foo ","foo","goo ","goo"); - -/* - * Check performance - - */ -status = inSection(1); -var start = new Date(); -var result = re.exec(str); -actual = elapsedTime(start); -reportCompare(isThisFast(FAST), isThisFast(actual), status); - -/* - * Check accuracy - - */ -status = inSection(2); -testRegExp([status], [re], [str], [result], [expect]); - - - -/* - * The second regexp (HUGE!). We'll test for performance (Section 3) and accuracy (Section 4). - * It comes from the O'Reilly book "Mastering Regular Expressions" by Jeffrey Friedl, Appendix B - */ - -//# Some things for avoiding backslashitis later on. -$esc = '\\\\'; -$Period = '\.'; -$space = '\040'; $tab = '\t'; -$OpenBR = '\\['; $CloseBR = '\\]'; -$OpenParen = '\\('; $CloseParen = '\\)'; -$NonASCII = '\x80-\xff'; $ctrl = '\000-\037'; -$CRlist = '\n\015'; //# note: this should really be only \015. -// Items 19, 20, 21 -$qtext = '[^' + $esc + $NonASCII + $CRlist + '\"]'; // # for within "..." -$dtext = '[^' + $esc + $NonASCII + $CRlist + $OpenBR + $CloseBR + ']'; // # for within [...] -$quoted_pair = $esc + '[^' + $NonASCII + ']'; // # an escaped character - -//############################################################################## -//# Items 22 and 23, comment. -//# Impossible to do properly with a regex, I make do by allowing at most one level of nesting. -$ctext = '[^' + $esc + $NonASCII + $CRlist + '()]'; - -//# $Cnested matches one non-nested comment. -//# It is unrolled, with normal of $ctext, special of $quoted_pair. -$Cnested = - $OpenParen + // # ( - $ctext + '*' + // # normal* - '(?:' + $quoted_pair + $ctext + '*)*' + // # (special normal*)* - $CloseParen; // # ) - - -//# $comment allows one level of nested parentheses -//# It is unrolled, with normal of $ctext, special of ($quoted_pair|$Cnested) -$comment = - $OpenParen + // # ( - $ctext + '*' + // # normal* - '(?:' + // # ( - '(?:' + $quoted_pair + '|' + $Cnested + ')' + // # special - $ctext + '*' + // # normal* - ')*' + // # )* - $CloseParen; // # ) - - -//############################################################################## -//# $X is optional whitespace/comments. -$X = - '[' + $space + $tab + ']*' + // # Nab whitespace. - '(?:' + $comment + '[' + $space + $tab + ']*)*'; // # If comment found, allow more spaces. - - -//# Item 10: atom -$atom_char = '[^(' + $space + '<>\@,;:\".' + $esc + $OpenBR + $CloseBR + $ctrl + $NonASCII + ']'; -$atom = - $atom_char + '+' + // # some number of atom characters... - '(?!' + $atom_char + ')'; // # ..not followed by something that could be part of an atom - -// # Item 11: doublequoted string, unrolled. -$quoted_str = - '\"' + // # " - $qtext + '*' + // # normal - '(?:' + $quoted_pair + $qtext + '*)*' + // # ( special normal* )* - '\"'; // # " - -//# Item 7: word is an atom or quoted string -$word = - '(?:' + - $atom + // # Atom - '|' + // # or - $quoted_str + // # Quoted string - ')' - -//# Item 12: domain-ref is just an atom - $domain_ref = $atom; - -//# Item 13: domain-literal is like a quoted string, but [...] instead of "..." -$domain_lit = - $OpenBR + // # [ - '(?:' + $dtext + '|' + $quoted_pair + ')*' + // # stuff - $CloseBR; // # ] - -// # Item 9: sub-domain is a domain-ref or domain-literal -$sub_domain = - '(?:' + - $domain_ref + - '|' + - $domain_lit + - ')' + - $X; // # optional trailing comments - -// # Item 6: domain is a list of subdomains separated by dots. -$domain = - $sub_domain + - '(?:' + - $Period + $X + $sub_domain + - ')*'; - -//# Item 8: a route. A bunch of "@ $domain" separated by commas, followed by a colon. -$route = - '\@' + $X + $domain + - '(?:,' + $X + '\@' + $X + $domain + ')*' + // # additional domains - ':' + - $X; // # optional trailing comments - -//# Item 6: local-part is a bunch of $word separated by periods -$local_part = - $word + $X - '(?:' + - $Period + $X + $word + $X + // # additional words - ')*'; - -// # Item 2: addr-spec is local@domain -$addr_spec = - $local_part + '\@' + $X + $domain; - -//# Item 4: route-addr is -$route_addr = - '<' + $X + // # < - '(?:' + $route + ')?' + // # optional route - $addr_spec + // # address spec - '>'; // # > - -//# Item 3: phrase........ -$phrase_ctrl = '\000-\010\012-\037'; // # like ctrl, but without tab - -//# Like atom-char, but without listing space, and uses phrase_ctrl. -//# Since the class is negated, this matches the same as atom-char plus space and tab -$phrase_char = - '[^()<>\@,;:\".' + $esc + $OpenBR + $CloseBR + $NonASCII + $phrase_ctrl + ']'; - -// # We've worked it so that $word, $comment, and $quoted_str to not consume trailing $X -// # because we take care of it manually. -$phrase = - $word + // # leading word - $phrase_char + '*' + // # "normal" atoms and/or spaces - '(?:' + - '(?:' + $comment + '|' + $quoted_str + ')' + // # "special" comment or quoted string - $phrase_char + '*' + // # more "normal" - ')*'; - -// ## Item #1: mailbox is an addr_spec or a phrase/route_addr -$mailbox = - $X + // # optional leading comment - '(?:' + - $phrase + $route_addr + // # name and address - '|' + // # or - $addr_spec + // # address - ')'; - - -//########################################################################### - - -re = new RegExp($mailbox, "g"); -str = 'Jeffy<"That Tall Guy"@ora.com (this address is no longer active)>'; -expect = Array('Jeffy<"That Tall Guy"@ora.com (this address is no longer active)>'); - -/* - * Check performance - - */ -status = inSection(3); -var start = new Date(); -var result = re.exec(str); -actual = elapsedTime(start); -reportCompare(isThisFast(FAST), isThisFast(actual), status); - -/* - * Check accuracy - - */ -status = inSection(4); -testRegExp([status], [re], [str], [result], [expect]); diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-87231.js b/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-87231.js deleted file mode 100644 index b5467322eb..0000000000 --- a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-87231.js +++ /dev/null @@ -1,145 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is mozilla.org code. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * pschwartau@netscape.com - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -/* - * Date: 22 June 2001 - * - * SUMMARY: Regression test for Bugzilla bug 87231: - * "Regular expression /(A)?(A.*)/ picks 'A' twice" - * - * See http://bugzilla.mozilla.org/show_bug.cgi?id=87231 - * Key case: - * - * pattern = /^(A)?(A.*)$/; - * string = 'A'; - * expectedmatch = Array('A', '', 'A'); - * - * - * We expect the 1st subexpression (A)? NOT to consume the single 'A'. - * Recall that "?" means "match 0 or 1 times". Here, it should NOT do - * greedy matching: it should match 0 times instead of 1. This allows - * the 2nd subexpression to make the only match it can: the single 'A'. - * Such "altruism" is the only way there can be a successful global match... - */ -//----------------------------------------------------------------------------- -var gTestfile = 'regress-87231.js'; -var i = 0; -var BUGNUMBER = 87231; -var cnEmptyString = ''; -var summary = 'Testing regular expression /(A)?(A.*)/'; -var status = ''; -var statusmessages = new Array(); -var pattern = ''; -var patterns = new Array(); -var string = ''; -var strings = new Array(); -var actualmatch = ''; -var actualmatches = new Array(); -var expectedmatch = ''; -var expectedmatches = new Array(); - - -pattern = /^(A)?(A.*)$/; -status = inSection(1); -string = 'AAA'; -actualmatch = string.match(pattern); -expectedmatch = Array('AAA', 'A', 'AA'); -addThis(); - -status = inSection(2); -string = 'AA'; -actualmatch = string.match(pattern); -expectedmatch = Array('AA', 'A', 'A'); -addThis(); - -status = inSection(3); -string = 'A'; -actualmatch = string.match(pattern); -expectedmatch = Array('A', undefined, 'A'); // 'altruistic' case: see above -addThis(); - - -pattern = /(A)?(A.*)/; -var strL = 'zxcasd;fl\\\ ^'; -var strR = 'aaAAaaaf;lrlrzs'; - -status = inSection(4); -string = strL + 'AAA' + strR; -actualmatch = string.match(pattern); -expectedmatch = Array('AAA' + strR, 'A', 'AA' + strR); -addThis(); - -status = inSection(5); -string = strL + 'AA' + strR; -actualmatch = string.match(pattern); -expectedmatch = Array('AA' + strR, 'A', 'A' + strR); -addThis(); - -status = inSection(6); -string = strL + 'A' + strR; -actualmatch = string.match(pattern); -expectedmatch = Array('A' + strR, undefined, 'A' + strR); // 'altruistic' case: see above -addThis(); - - - -//------------------------------------------------------------------------------------------------- -test(); -//------------------------------------------------------------------------------------------------- - - - -function addThis() -{ - statusmessages[i] = status; - patterns[i] = pattern; - strings[i] = string; - actualmatches[i] = actualmatch; - expectedmatches[i] = expectedmatch; - i++; -} - - -function test() -{ - enterFunc ('test'); - printBugNumber(BUGNUMBER); - printStatus (summary); - testRegExp(statusmessages, patterns, strings, actualmatches, expectedmatches); - exitFunc ('test'); -} diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-98306.js b/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-98306.js deleted file mode 100644 index a2bfc2bf93..0000000000 --- a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-98306.js +++ /dev/null @@ -1,99 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is mozilla.org code. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * jrgm@netscape.com, pschwartau@netscape.com - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -/* - * Date: 04 September 2001 - * - * SUMMARY: Regression test for Bugzilla bug 98306 - * "JS parser crashes in ParseAtom for script using Regexp()" - * - * See http://bugzilla.mozilla.org/show_bug.cgi?id=98306 - */ -//----------------------------------------------------------------------------- -var gTestfile = 'regress-98306.js'; -var BUGNUMBER = 98306; -var summary = "Testing that we don't crash on this code -"; -var cnUBOUND = 10; -var re; -var s; - - -//----------------------------------------------------------------------------- -test(); -//----------------------------------------------------------------------------- - - -function test() -{ - enterFunc ('test'); - printBugNumber(BUGNUMBER); - printStatus (summary); - - s = '"Hello".match(/[/]/)'; - tryThis(s); - - s = 're = /[/'; - tryThis(s); - - s = 're = /[/]/'; - tryThis(s); - - s = 're = /[//]/'; - tryThis(s); - - reportCompare('No Crash', 'No Crash', ''); - exitFunc ('test'); -} - - -// Try to provoke a crash - -function tryThis(sCode) -{ - // sometimes more than one attempt is necessary - - for (var i=0; i 5) - throw "bad"; - i++; - continue; - } - } - catch(ex) - { - actual = ex + ''; - } - reportCompare(expect, actual, summary); - - exitFunc ('test'); -} diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/Regress/shell.js b/tests/auto/declarative/parserstress/tests/ecma_3/Regress/shell.js deleted file mode 100644 index 8c83369020..0000000000 --- a/tests/auto/declarative/parserstress/tests/ecma_3/Regress/shell.js +++ /dev/null @@ -1 +0,0 @@ -gTestsubsuite = 'Regress'; diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/Statements/12.6.3.js b/tests/auto/declarative/parserstress/tests/ecma_3/Statements/12.6.3.js deleted file mode 100755 index 97c3ca3136..0000000000 --- a/tests/auto/declarative/parserstress/tests/ecma_3/Statements/12.6.3.js +++ /dev/null @@ -1,80 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is JavaScript Engine testing utilities. - * - * The Initial Developer of the Original Code is - * Mozilla Foundation. - * Portions created by the Initial Developer are Copyright (C) 2005 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): Bryant Chen - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -var gTestfile = '12.6.3.js'; -//----------------------------------------------------------------------------- -var BUGNUMBER = 292731; -var summary = 'for-in should not call valueOf method'; -var actual = ''; -var expect = ''; -var i; - -printBugNumber(BUGNUMBER); -printStatus (summary); - -function MyObject() -{ -} - -MyObject.prototype.valueOf = function() -{ - actual += 'MyObject.prototype.valueOf called. '; -} - - var myobject = new MyObject(); - -var myfunction = new function() -{ - this.valueOf = function() - { - actual += 'this.valueOf called. '; - } -} - - actual = ''; -for (i in myobject) -{ - //calls valueOf -} -reportCompare(expect, actual, 'for-in custom object'); - -actual = ''; -for (i in myfunction) -{ - //calls valueOf -} -reportCompare(expect, actual, 'for-in function expression'); diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/Statements/browser.js b/tests/auto/declarative/parserstress/tests/ecma_3/Statements/browser.js deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/Statements/regress-121744.js b/tests/auto/declarative/parserstress/tests/ecma_3/Statements/regress-121744.js deleted file mode 100644 index 828cc5d8d5..0000000000 --- a/tests/auto/declarative/parserstress/tests/ecma_3/Statements/regress-121744.js +++ /dev/null @@ -1,217 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is JavaScript Engine testing utilities. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corp. - * Portions created by the Initial Developer are Copyright (C) 2002 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * pschwartau@netscape.com - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -/* - * - * Date: 30 Jan 2002 - * Revised: 10 Apr 2002 - * Revised: 14 July 2002 - * - * SUMMARY: JS should error on |for(i in undefined)|, |for(i in null)| - * See http://bugzilla.mozilla.org/show_bug.cgi?id=121744 - * - * ECMA-262 3rd Edition Final spec says such statements should error. See: - * - * Section 12.6.4 The for-in Statement - * Section 9.9 ToObject - * - * - * BUT: SpiderMonkey has decided NOT to follow this; it's a bug in the spec. - * See http://bugzilla.mozilla.org/show_bug.cgi?id=131348 - * - * UPDATE: Rhino has also decided not to follow the spec on this. - * See http://bugzilla.mozilla.org/show_bug.cgi?id=136893 - * - - |--------------------------------------------------------------------| - | | - | So for now, adding an early return for this test so it won't run. | - | | - |--------------------------------------------------------------------| - - * - */ -//----------------------------------------------------------------------------- -var gTestfile = 'regress-121744.js'; -var UBound = 0; -var BUGNUMBER = 121744; -var summary = 'JS should error on |for(i in undefined)|, |for(i in null)|'; -var TEST_PASSED = 'TypeError'; -var TEST_FAILED = 'Generated an error, but NOT a TypeError!'; -var TEST_FAILED_BADLY = 'Did not generate ANY error!!!'; -var status = ''; -var statusitems = []; -var actual = ''; -var actualvalues = []; -var expect= ''; -var expectedvalues = []; - -/* - * AS OF 14 JULY 2002, DON'T RUN THIS TEST IN EITHER RHINO OR SPIDERMONKEY - - */ -quit(); - - -status = inSection(1); -expect = TEST_PASSED; -actual = TEST_FAILED_BADLY; -/* - * OK, this should generate a TypeError - */ -try -{ - for (var i in undefined) - { - print(i); - } -} -catch(e) -{ - if (e instanceof TypeError) - actual = TEST_PASSED; - else - actual = TEST_FAILED; -} -addThis(); - - - -status = inSection(2); -expect = TEST_PASSED; -actual = TEST_FAILED_BADLY; -/* - * OK, this should generate a TypeError - */ -try -{ - for (var i in null) - { - print(i); - } -} -catch(e) -{ - if (e instanceof TypeError) - actual = TEST_PASSED; - else - actual = TEST_FAILED; -} -addThis(); - - - -status = inSection(3); -expect = TEST_PASSED; -actual = TEST_FAILED_BADLY; -/* - * Variable names that cannot be looked up generate ReferenceErrors; however, - * property names like obj.ZZZ that cannot be looked up are set to |undefined| - * - * Therefore, this should indirectly test | for (var i in undefined) | - */ -try -{ - for (var i in this.ZZZ) - { - print(i); - } -} -catch(e) -{ - if(e instanceof TypeError) - actual = TEST_PASSED; - else - actual = TEST_FAILED; -} -addThis(); - - - -status = inSection(4); -expect = TEST_PASSED; -actual = TEST_FAILED_BADLY; -/* - * The result of an unsuccessful regexp match is the null value - * Therefore, this should indirectly test | for (var i in null) | - */ -try -{ - for (var i in 'bbb'.match(/aaa/)) - { - print(i); - } -} -catch(e) -{ - if(e instanceof TypeError) - actual = TEST_PASSED; - else - actual = TEST_FAILED; -} -addThis(); - - - -//----------------------------------------------------------------------------- -test(); -//----------------------------------------------------------------------------- - - - -function addThis() -{ - statusitems[UBound] = status; - actualvalues[UBound] = actual; - expectedvalues[UBound] = expect; - UBound++; -} - - -function test() -{ - enterFunc('test'); - printBugNumber(BUGNUMBER); - printStatus(summary); - - for (var i=0; i - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -var gTestfile = '15.5.4.11.js'; -var BUGNUMBER = 392378; -var summary = '15.5.4.11 - String.prototype.replace'; -var rex, f, a, i; - -reportCompare( - 2, - String.prototype.replace.length, - "Section 1" -); - -reportCompare( - "321", - String.prototype.replace.call(123, "123", "321"), - "Section 2" -); - -reportCompare( - "ok", - "ok".replace(), - "Section 3" -); - -reportCompare( - "undefined**", - "***".replace("*"), - "Section 4" -); - -reportCompare( - "xnullz", - "xyz".replace("y", null), - "Section 5" -); - -reportCompare( - "x123", - "xyz".replace("yz", 123), - "Section 6" -); - -reportCompare( - "/x/g/x/g/x/g", - "xxx".replace(/x/g, /x/g), - "Section 7" -); - -reportCompare( - "ok", - "undefined".replace(undefined, "ok"), - "Section 8" -); - -reportCompare( - "ok", - "null".replace(null, "ok"), - "Section 9" -); - -reportCompare( - "ok", - "123".replace(123, "ok"), - "Section 10" -); - -reportCompare( - "xzyxyz", - "xyzxyz".replace("yz", "zy"), - "Section 11" -); - -reportCompare( - "ok", - "(xyz)".replace("(xyz)", "ok"), - "Section 12" -); - -reportCompare( - "*$&yzxyz", - "xyzxyz".replace("x", "*$$&"), - "Section 13" -); - -reportCompare( - "xy*z*", - "xyz".replace("z", "*$&*"), - "Section 14" -); - -reportCompare( - "xyxyzxyz", - "xyzxyzxyz".replace("zxy", "$`"), - "Section 15" -); - -reportCompare( - "zxyzxyzzxyz", - "xyzxyz".replace("xy", "$'xyz"), - "Section 16" -); - -reportCompare( - "$", - "xyzxyz".replace("xyzxyz", "$"), - "Section 17" -); - -reportCompare( - "x$0$00xyz", - "xyzxyz".replace("yz", "$0$00"), - "Section 18" -); - -// Result for $1/$01 .. $99 is implementation-defined if searchValue is no -// regular expression. $+ is a non-standard Mozilla extension. - -reportCompare( - "$!$\"$-1$*$#$.$xyz$$", - "xyzxyz$$".replace("xyz", "$!$\"$-1$*$#$.$"), - "Section 19" -); - -reportCompare( - "$$$&$$$&$&", - "$$$&".replace("$$", "$$$$$$&$&$$&"), - "Section 20" -); - -reportCompare( - "yxx", - "xxx".replace(/x/, "y"), - "Section 21" -); - -reportCompare( - "yyy", - "xxx".replace(/x/g, "y"), - "Section 22" -); - -rex = /x/, rex.lastIndex = 1; -reportCompare( - "yxx1", - "xxx".replace(rex, "y") + rex.lastIndex, - "Section 23" -); - -rex = /x/g, rex.lastIndex = 1; -reportCompare( - "yyy0", - "xxx".replace(rex, "y") + rex.lastIndex, - "Section 24" -); - -rex = /y/, rex.lastIndex = 1; -reportCompare( - "xxx1", - "xxx".replace(rex, "y") + rex.lastIndex, - "Section 25" -); - -rex = /y/g, rex.lastIndex = 1; -reportCompare( - "xxx0", - "xxx".replace(rex, "y") + rex.lastIndex, - "Section 26" -); - -rex = /x?/, rex.lastIndex = 1; -reportCompare( - "(x)xx1", - "xxx".replace(rex, "($&)") + rex.lastIndex, - "Section 27" -); - -rex = /x?/g, rex.lastIndex = 1; -reportCompare( - "(x)(x)(x)()0", - "xxx".replace(rex, "($&)") + rex.lastIndex, - "Section 28" -); - -rex = /y?/, rex.lastIndex = 1; -reportCompare( - "()xxx1", - "xxx".replace(rex, "($&)") + rex.lastIndex, - "Section 29" -); - -rex = /y?/g, rex.lastIndex = 1; -reportCompare( - "()x()x()x()0", - "xxx".replace(rex, "($&)") + rex.lastIndex, - "Section 30" -); - -reportCompare( - "xy$0xy$zxy$zxyz$zxyz", - "xyzxyzxyz".replace(/zxy/, "$0$`$$$&$$$'$"), - "Section 31" -); - -reportCompare( - "xy$0xy$zxy$zxyz$$0xyzxy$zxy$z$z", - "xyzxyzxyz".replace(/zxy/g, "$0$`$$$&$$$'$"), - "Section 32" -); - -reportCompare( - "xyxyxyzxyxyxyz", - "xyzxyz".replace(/(((x)(y)()()))()()()(z)/g, "$01$2$3$04$5$6$7$8$09$10"), - "Section 33" -); - -rex = RegExp( - "()()()()()()()()()()" + - "()()()()()()()()()()" + - "()()()()()()()()()()" + - "()()()()()()()()()()" + - "()()()()()()()()()()" + - "()()()()()()()()()()" + - "()()()()()()()()()()" + - "()()()()()()()()()()" + - "()()()()()()()()()()" + - "()()()()()()()()(y)"); -reportCompare( - "x(y)z", - "xyz".replace(rex, "($99)"), - "Section 34" -); - -rex = RegExp( - "()()()()()()()()()(x)" + - "()()()()()()()()()()" + - "()()()()()()()()()()" + - "()()()()()()()()()()" + - "()()()()()()()()()()" + - "()()()()()()()()()()" + - "()()()()()()()()()()" + - "()()()()()()()()()()" + - "()()()()()()()()()()" + - "()()()()()()()()()(y)"); -reportCompare( - "(x0)z", - "xyz".replace(rex, "($100)"), - "Section 35" -); - -reportCompare( - "xyz(XYZ)", - "xyzXYZ".replace(/XYZ/g, "($&)"), - "Section 36" -); - -reportCompare( - "(xyz)(XYZ)", - "xyzXYZ".replace(/xYz/gi, "($&)"), - "Section 37" -); - -reportCompare( - "xyz\rxyz\n", - "xyz\rxyz\n".replace(/xyz$/g, "($&)"), - "Section 38" -); - -reportCompare( - "(xyz)\r(xyz)\n", - "xyz\rxyz\n".replace(/xyz$/gm, "($&)"), - "Section 39" -); - -f = function () { return "failure" }; - -reportCompare( - "ok", - "ok".replace("x", f), - "Section 40" -); - -reportCompare( - "ok", - "ok".replace(/(?=k)ok/, f), - "Section 41" -); - -reportCompare( - "ok", - "ok".replace(/(?!)ok/, f), - "Section 42" -); - -reportCompare( - "ok", - "ok".replace(/ok(?!$)/, f), - "Section 43" -); - -f = function (sub, offs, str) { - return ["", sub, typeof sub, offs, typeof offs, str, typeof str, ""] - .join("|"); -}; - -reportCompare( - "x|y|string|1|number|xyz|string|z", - "xyz".replace("y", f), - "Section 44" -); - -reportCompare( - "x|(y)|string|1|number|x(y)z|string|z", - "x(y)z".replace("(y)", f), - "Section 45" -); - -reportCompare( - "x|y*|string|1|number|xy*z|string|z", - "xy*z".replace("y*", f), - "Section 46" -); - -reportCompare( - "12|3|string|2|number|12345|string|45", - String.prototype.replace.call(1.2345e4, 3, f), - "Section 47" -); - -reportCompare( - "|x|string|0|number|xxx|string|xx", - "xxx".replace(/^x/g, f), - "Section 48" -); - -reportCompare( - "xx|x|string|2|number|xxx|string|", - "xxx".replace(/x$/g, f), - "Section 49" -); - -f = function (sub, paren, offs, str) { - return ["", sub, typeof sub, paren, typeof paren, offs, typeof offs, - str, typeof str, ""].join("|"); -}; - -reportCompare( - "xy|z|string|z|string|2|number|xyz|string|", - "xyz".replace(/(z)/g, f), - "Section 50" -); - -reportCompare( - "xyz||string||string|3|number|xyz|string|", - "xyz".replace(/($)/g, f), - "Section 51" -); - -reportCompare( - "|xy|string|y|string|0|number|xyz|string|z", - "xyz".replace(/(?:x)(y)/g, f), - "Section 52" -); - -reportCompare( - "|x|string|x|string|0|number|xyz|string|yz", - "xyz".replace(/((?=xy)x)/g, f), - "Section 53" -); - -reportCompare( - "|x|string|x|string|0|number|xyz|string|yz", - "xyz".replace(/(x(?=y))/g, f), - "Section 54" -); - -reportCompare( - "x|y|string|y|string|1|number|xyz|string|z", - "xyz".replace(/((?!x)y)/g, f), - "Section 55" -); - -reportCompare( - "|x|string|x|string|0|number|xyz|string|" + - "|y|string||undefined|1|number|xyz|string|z", - "xyz".replace(/y|(x)/g, f), - "Section 56" -); - -reportCompare( - "xy|z|string||string|2|number|xyz|string|", - "xyz".replace(/(z?)z/, f), - "Section 57" -); - -reportCompare( - "xy|z|string||undefined|2|number|xyz|string|", - "xyz".replace(/(z)?z/, f), - "Section 58" -); - -reportCompare( - "xy|z|string||undefined|2|number|xyz|string|", - "xyz".replace(/(z)?\1z/, f), - "Section 59" -); - -reportCompare( - "xy|z|string||undefined|2|number|xyz|string|", - "xyz".replace(/\1(z)?z/, f), - "Section 60" -); - -reportCompare( - "xy|z|string||string|2|number|xyz|string|", - "xyz".replace(/(z?\1)z/, f), - "Section 61" -); - -f = function (sub, paren1, paren2, offs, str) { - return ["", sub, typeof sub, paren1, typeof paren1, paren2, typeof paren2, - offs, typeof offs, str, typeof str, ""].join("|"); -}; - -reportCompare( - "x|y|string|y|string||undefined|1|number|xyz|string|z", - "xyz".replace(/(y)(\1)?/, f), - "Section 62" -); - -reportCompare( - "x|yy|string|y|string|y|string|1|number|xyyz|string|z", - "xyyz".replace(/(y)(\1)?/g, f), - "Section 63" -); - -reportCompare( - "x|y|string|y|string||undefined|1|number|xyyz|string|" + - "|y|string|y|string||undefined|2|number|xyyz|string|z", - "xyyz".replace(/(y)(\1)??/g, f), - "Section 64" -); - -reportCompare( - "x|y|string|y|string|y|string|1|number|xyz|string|z", - "xyz".replace(/(?=(y))(\1)?/, f), - "Section 65" -); - -reportCompare( - "xyy|z|string||undefined||string|3|number|xyyz|string|", - "xyyz".replace(/(?!(y)y)(\1)z/, f), - "Section 66" -); - -rex = RegExp( - "()()()()()()()()()()" + - "()()()()()()()()()()" + - "()()()()()()()()()()" + - "()()()()()()()()()()" + - "()()()()()()()()()()" + - "()()()()()()()()()()" + - "()()()()()()()()()()" + - "()()()()()()()()()()" + - "()()()()()()()()()()" + - "()()()()()()()()()()(z)?(y)"); -a = ["sub"]; -for (i = 1; i <= 102; ++i) - a[i] = "p" + i; -a[103] = "offs"; -a[104] = "str"; -a[105] = "return ['', sub, typeof sub, offs, typeof offs, str, typeof str, " + - "p100, typeof p100, p101, typeof p101, p102, typeof p102, ''].join('|');"; -f = Function.apply(null, a); -reportCompare( - "x|y|string|1|number|xyz|string||string||undefined|y|string|z", - "xyz".replace(rex, f), - "Section 67" -); - -reportCompare( - "undefined", - "".replace(/.*/g, function () {}), - "Section 68" -); - -reportCompare( - "nullxnullynullznull", - "xyz".replace(/.??/g, function () { return null; }), - "Section 69" -); - -reportCompare( - "111", - "xyz".replace(/./g, function () { return 1; }), - "Section 70" -); diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/String/15.5.4.14.js b/tests/auto/declarative/parserstress/tests/ecma_3/String/15.5.4.14.js deleted file mode 100644 index aa6c7354c2..0000000000 --- a/tests/auto/declarative/parserstress/tests/ecma_3/String/15.5.4.14.js +++ /dev/null @@ -1,50 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is JavaScript Engine testing utilities. - * - * The Initial Developer of the Original Code is - * Mozilla Foundation. - * Portions created by the Initial Developer are Copyright (C) 2005 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): Karsten Sperling - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -var gTestfile = '15.5.4.14.js'; -//----------------------------------------------------------------------------- -var BUGNUMBER = 287630; -var summary = '15.5.4.14 - String.prototype.split(/()/)'; -var actual = ''; -var expect = ['a'].toString(); - -printBugNumber(BUGNUMBER); -printStatus (summary); - -actual = 'a'.split(/()/).toString(); - -reportCompare(expect, actual, summary); diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/String/browser.js b/tests/auto/declarative/parserstress/tests/ecma_3/String/browser.js deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/String/regress-104375.js b/tests/auto/declarative/parserstress/tests/ecma_3/String/regress-104375.js deleted file mode 100644 index c5593948d7..0000000000 --- a/tests/auto/declarative/parserstress/tests/ecma_3/String/regress-104375.js +++ /dev/null @@ -1,116 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is mozilla.org code. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * k.mike@gmx.net, pschwartau@netscape.com - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -/* - * Date: 12 October 2001 - * - * SUMMARY: Regression test for string.replace bug 104375 - * See http://bugzilla.mozilla.org/show_bug.cgi?id=104375 - */ -//----------------------------------------------------------------------------- -var gTestfile = 'regress-104375.js'; -var UBound = 0; -var BUGNUMBER = 104375; -var summary = 'Testing string.replace() with backreferences'; -var status = ''; -var statusitems = []; -var actual = ''; -var actualvalues = []; -var expect= ''; -var expectedvalues = []; - - -/* - * Use the regexp to replace 'uid=31' with 'uid=15' - * - * In the second parameter of string.replace() method, - * "$1" refers to the first backreference: 'uid=' - */ -var str = 'uid=31'; -var re = /(uid=)(\d+)/; - -// try the numeric literal 15 -status = inSection(1); -actual = str.replace (re, "$1" + 15); -expect = 'uid=15'; -addThis(); - -// try the string literal '15' -status = inSection(2); -actual = str.replace (re, "$1" + '15'); -expect = 'uid=15'; -addThis(); - -// try a letter before the '15' -status = inSection(3); -actual = str.replace (re, "$1" + 'A15'); -expect = 'uid=A15'; -addThis(); - - - -//----------------------------------------------------------------------------- -test(); -//----------------------------------------------------------------------------- - - - -function addThis() -{ - statusitems[UBound] = status; - actualvalues[UBound] = actual; - expectedvalues[UBound] = expect; - UBound++; -} - - -function test() -{ - enterFunc ('test'); - printBugNumber(BUGNUMBER); - printStatus (summary); - - for (var i=0; i 'aaZaa' - expect = strJim.replace(new RegExp(strA), strB); // expect 'aa$aaZ' - reportCompare(expect, actual, status); - - - * - * Note: 'Zabc' is the result we expect for 'abc'.replace('', 'Z'). - * - * The string '' is supposed to be equivalent to new RegExp('') = //. - * The regexp // means we should match the "empty string" conceived of - * at the beginning boundary of the word, before the first character. - * - status = 'Section F of test'; - strA = cnEmptyString; - actual = str.replace(strA, strB); - expect = 'Zabc'; - reportCompare(expect, actual, status); - - status = 'Section G of test'; - strA = cnEmptyString; - actual = str.replace(strA, strB); - expect = str.replace(new RegExp(strA), strB); - reportCompare(expect, actual, status); - - ************************* END OF INCORRECT CASES ****************************/ - - -////////////////////////// OK, LET'S START OVER ////////////////////////////// - - status = 'Section 1 of test'; - actual = 'abc'.replace('a', 'Z'); - expect = 'Zbc'; - reportCompare(expect, actual, status); - - status = 'Section 2 of test'; - actual = 'abc'.replace('b', 'Z'); - expect = 'aZc'; - reportCompare(expect, actual, status); - - status = 'Section 3 of test'; - actual = 'abc'.replace(undefined, 'Z'); - expect = 'abc'; // String(undefined) == 'undefined'; no replacement possible - reportCompare(expect, actual, status); - - status = 'Section 4 of test'; - actual = 'abc'.replace(null, 'Z'); - expect = 'abc'; // String(null) == 'null'; no replacement possible - reportCompare(expect, actual, status); - - status = 'Section 5 of test'; - actual = 'abc'.replace(true, 'Z'); - expect = 'abc'; // String(true) == 'true'; no replacement possible - reportCompare(expect, actual, status); - - status = 'Section 6 of test'; - actual = 'abc'.replace(false, 'Z'); - expect = 'abc'; // String(false) == 'false'; no replacement possible - reportCompare(expect, actual, status); - - status = 'Section 7 of test'; - actual = 'aa$aa'.replace('$', 'Z'); - expect = 'aaZaa'; // NOT 'aa$aaZ' as in ECMA Final Draft; see above - reportCompare(expect, actual, status); - - status = 'Section 8 of test'; - actual = 'abc'.replace('.*', 'Z'); - expect = 'abc'; // not 'Z' as in EMCA Final Draft - reportCompare(expect, actual, status); - - status = 'Section 9 of test'; - actual = 'abc'.replace('', 'Z'); - expect = 'Zabc'; // Still expect 'Zabc' for this - reportCompare(expect, actual, status); - - exitFunc ('test'); -} diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/String/shell.js b/tests/auto/declarative/parserstress/tests/ecma_3/String/shell.js deleted file mode 100644 index 7d850446cc..0000000000 --- a/tests/auto/declarative/parserstress/tests/ecma_3/String/shell.js +++ /dev/null @@ -1 +0,0 @@ -gTestsubsuite = 'String'; diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/Unicode/browser.js b/tests/auto/declarative/parserstress/tests/ecma_3/Unicode/browser.js deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/Unicode/regress-352044-01.js b/tests/auto/declarative/parserstress/tests/ecma_3/Unicode/regress-352044-01.js deleted file mode 100755 index bb10ac6f7a..0000000000 --- a/tests/auto/declarative/parserstress/tests/ecma_3/Unicode/regress-352044-01.js +++ /dev/null @@ -1,72 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is JavaScript Engine testing utilities. - * - * The Initial Developer of the Original Code is - * Mozilla Foundation. - * Portions created by the Initial Developer are Copyright (C) 2007 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): Martin Honnen - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -var gTestfile = 'regress-352044-01.js'; -//----------------------------------------------------------------------------- -var BUGNUMBER = 352044; -var summary = 'issues with Unicode escape sequences in JavaScript source code'; -var actual = ''; -var expect = ''; - - -//----------------------------------------------------------------------------- -test(); -//----------------------------------------------------------------------------- - -function test() -{ - enterFunc ('test'); - printBugNumber(BUGNUMBER); - printStatus (summary); - - expect = 'SyntaxError: illegal character'; - - try - { - var i = 1; - eval('i \\u002b= 1'); - print(i); - } - catch(ex) - { - actual = ex + ''; - } - - reportCompare(expect, actual, summary); - - exitFunc ('test'); -} diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/Unicode/regress-352044-02-n.js b/tests/auto/declarative/parserstress/tests/ecma_3/Unicode/regress-352044-02-n.js deleted file mode 100755 index 0e3c4b0189..0000000000 --- a/tests/auto/declarative/parserstress/tests/ecma_3/Unicode/regress-352044-02-n.js +++ /dev/null @@ -1,72 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is JavaScript Engine testing utilities. - * - * The Initial Developer of the Original Code is - * Mozilla Foundation. - * Portions created by the Initial Developer are Copyright (C) 2007 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): Martin Honnen - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -var gTestfile = 'regress-352044-02-n.js'; -//----------------------------------------------------------------------------- -var BUGNUMBER = 352044; -var summary = 'issues with Unicode escape sequences in JavaScript source code'; -var actual = 'No Error'; -var expect = 'SyntaxError'; - - -//----------------------------------------------------------------------------- -test(); -//----------------------------------------------------------------------------- - -function test() -{ - enterFunc ('test'); - printBugNumber(BUGNUMBER); - printStatus (summary); - - print('This test case is expected to throw an uncaught SyntaxError'); - - try - { - var i = 1; - i \u002b= 1; - print(i); - } - catch(ex) - { - actual = ex + ''; - } - - reportCompare(expect, actual, summary); - - exitFunc ('test'); -} diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/Unicode/shell.js b/tests/auto/declarative/parserstress/tests/ecma_3/Unicode/shell.js deleted file mode 100644 index 97a64fe83d..0000000000 --- a/tests/auto/declarative/parserstress/tests/ecma_3/Unicode/shell.js +++ /dev/null @@ -1 +0,0 @@ -gTestsubsuite = 'Unicode'; diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/Unicode/uc-001-n.js b/tests/auto/declarative/parserstress/tests/ecma_3/Unicode/uc-001-n.js deleted file mode 100644 index 31a13f70e2..0000000000 --- a/tests/auto/declarative/parserstress/tests/ecma_3/Unicode/uc-001-n.js +++ /dev/null @@ -1,62 +0,0 @@ -/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- - * - * ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is Mozilla Communicator client code, released - * March 31, 1998. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * Rob Ginda rginda@netscape.com - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -var gTestfile = 'uc-001-n.js'; - -test(); - -function test() -{ - enterFunc ("test"); - - printStatus ("Unicode Characters 1C-1F negative test."); - printBugNumber (23612); - - reportCompare ("error", eval ("'no'\u001C+' error'"), - "Unicode whitespace test (1C.)"); - reportCompare ("error", eval ("'no'\u001D+' error'"), - "Unicode whitespace test (1D.)"); - reportCompare ("error", eval ("'no'\u001E+' error'"), - "Unicode whitespace test (1E.)"); - reportCompare ("error", eval ("'no'\u001F+' error'"), - "Unicode whitespace test (1F.)"); - - exitFunc ("test"); -} diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/Unicode/uc-001.js b/tests/auto/declarative/parserstress/tests/ecma_3/Unicode/uc-001.js deleted file mode 100644 index 3fc0c8d927..0000000000 --- a/tests/auto/declarative/parserstress/tests/ecma_3/Unicode/uc-001.js +++ /dev/null @@ -1,56 +0,0 @@ -/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- - * - * ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is Mozilla Communicator client code, released - * March 31, 1998. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * Rob Ginda rginda@netscape.com - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -var gTestfile = 'uc-001.js'; - -test(); - -function test() -{ - enterFunc ("test"); - - printStatus ("Unicode format-control character (Category Cf) test."); - printBugNumber (23610); - - reportCompare ("no error", eval('"no\u200E error"'), - "Unicode format-control character test (Category Cf.)"); - - exitFunc ("test"); -} diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/Unicode/uc-002-n.js b/tests/auto/declarative/parserstress/tests/ecma_3/Unicode/uc-002-n.js deleted file mode 100644 index f1ae9a749d..0000000000 --- a/tests/auto/declarative/parserstress/tests/ecma_3/Unicode/uc-002-n.js +++ /dev/null @@ -1,55 +0,0 @@ -/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- - * - * ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is Mozilla Communicator client code, released - * March 31, 1998. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * Rob Ginda rginda@netscape.com - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -var gTestfile = 'uc-002-n.js'; - -DESCRIPTION = "Non-character escapes in identifiers negative test."; -EXPECTED = "error"; - -enterFunc ("test"); - -printStatus ("Non-character escapes in identifiers negative test."); -printBugNumber (23607); - -eval("\u0020 = 5"); -reportCompare('PASS', 'FAIL', "Previous statement should have thrown an error."); - -exitFunc ("test"); - diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/Unicode/uc-002.js b/tests/auto/declarative/parserstress/tests/ecma_3/Unicode/uc-002.js deleted file mode 100644 index d19b2c4786..0000000000 --- a/tests/auto/declarative/parserstress/tests/ecma_3/Unicode/uc-002.js +++ /dev/null @@ -1,60 +0,0 @@ -/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- - * - * ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is Mozilla Communicator client code, released - * March 31, 1998. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * Rob Ginda rginda@netscape.com - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -var gTestfile = 'uc-002.js'; - -test(); - -function test() -{ - enterFunc ("test"); - - printStatus ("Unicode non-breaking space character test."); - printBugNumber (23613); - - reportCompare ("no error", eval("'no'\u00A0+ ' error'"), - "Unicode non-breaking space character test."); - - var str = "\u00A0foo"; - reportCompare (0, str.search(/^\sfoo$/), - "Unicode non-breaking space character regexp test."); - - exitFunc ("test"); -} diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/Unicode/uc-003.js b/tests/auto/declarative/parserstress/tests/ecma_3/Unicode/uc-003.js deleted file mode 100644 index 66c3f09860..0000000000 --- a/tests/auto/declarative/parserstress/tests/ecma_3/Unicode/uc-003.js +++ /dev/null @@ -1,71 +0,0 @@ -/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- - * - * ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is Mozilla Communicator client code, released - * March 31, 1998. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * Rob Ginda rginda@netscape.com - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -var gTestfile = 'uc-003.js'; - -test(); - -function test() -{ - enterFunc ("test"); - - var \u0041 = 5; - var A\u03B2 = 15; - var c\u0061se = 25; - - printStatus ("Escapes in identifiers test."); - printBugNumber (23608); - printBugNumber (23607); - - reportCompare (5, eval("\u0041"), - "Escaped ASCII Identifier test."); - reportCompare (6, eval("++\u0041"), - "Escaped ASCII Identifier test"); - reportCompare (15, eval("A\u03B2"), - "Escaped non-ASCII Identifier test"); - reportCompare (16, eval("++A\u03B2"), - "Escaped non-ASCII Identifier test"); - reportCompare (25, eval("c\\u00" + "61se"), - "Escaped keyword Identifier test"); - reportCompare (26, eval("++c\\u00" + "61se"), - "Escaped keyword Identifier test"); - - exitFunc ("test"); -} diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/Unicode/uc-004.js b/tests/auto/declarative/parserstress/tests/ecma_3/Unicode/uc-004.js deleted file mode 100644 index a54923c525..0000000000 --- a/tests/auto/declarative/parserstress/tests/ecma_3/Unicode/uc-004.js +++ /dev/null @@ -1,65 +0,0 @@ -/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- - * - * ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is Mozilla Communicator client code, released - * March 31, 1998. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * Rob Ginda rginda@netscape.com - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -var gTestfile = 'uc-004.js'; - -test(); - -function test() -{ - enterFunc ("test"); - - printStatus ("Unicode Characters 1C-1F with regexps test."); - printBugNumber (23612); - - var ary = ["\u001Cfoo", "\u001Dfoo", "\u001Efoo", "\u001Ffoo"]; - - for (var i in ary) - { - reportCompare (0, ary[Number(i)].search(/^\Sfoo$/), - "Unicode characters 1C-1F in regexps, ary[" + - i + "] did not match \\S test (it should not.)"); - reportCompare (-1, ary[Number(i)].search(/^\sfoo$/), - "Unicode characters 1C-1F in regexps, ary[" + - i + "] matched \\s test (it should not.)"); - } - - exitFunc ("test"); -} diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/Unicode/uc-005.js b/tests/auto/declarative/parserstress/tests/ecma_3/Unicode/uc-005.js deleted file mode 100644 index 3727042046..0000000000 --- a/tests/auto/declarative/parserstress/tests/ecma_3/Unicode/uc-005.js +++ /dev/null @@ -1,276 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is JavaScript Engine testing utilities. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corp. - * Portions created by the Initial Developer are Copyright (C) 2002 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * rogerl@netscape.com, pschwartau@netscape.com - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -/* - * - * Date: 15 July 2002 - * SUMMARY: Testing identifiers with double-byte names - * See http://bugzilla.mozilla.org/show_bug.cgi?id=58274 - * - * Here is a sample of the problem: - * - * js> function f\u02B1 () {} - * - * js> f\u02B1.toSource(); - * function f¦() {} - * - * js> f\u02B1.toSource().toSource(); - * (new String("function f\xB1() {}")) - * - * - * See how the high-byte information (the 02) has been lost? - * The same thing was happening with the toString() method: - * - * js> f\u02B1.toString(); - * - * function f¦() { - * } - * - * js> f\u02B1.toString().toSource(); - * (new String("\nfunction f\xB1() {\n}\n")) - * - */ -//----------------------------------------------------------------------------- -var gTestfile = 'uc-005.js'; -var UBound = 0; -var BUGNUMBER = 58274; -var summary = 'Testing identifiers with double-byte names'; -var status = ''; -var statusitems = []; -var actual = ''; -var actualvalues = []; -var expect= ''; -var expectedvalues = []; - - -/* - * Define a function that uses double-byte identifiers in - * "every possible way" - * - * Then recover each double-byte identifier via f.toString(). - * To make this easier, put a 'Z' token before every one. - * - * Our eval string will be: - * - * sEval = "function Z\u02b1(Z\u02b2, b) { - * try { Z\u02b3 : var Z\u02b4 = Z\u02b1; } - * catch (Z\u02b5) { for (var Z\u02b6 in Z\u02b5) - * {for (1; 1<0; Z\u02b7++) {new Array()[Z\u02b6] = 1;} };} }"; - * - * It will be helpful to build this string in stages: - */ -var s0 = 'function Z'; -var s1 = '\u02b1(Z'; -var s2 = '\u02b2, b) {try { Z'; -var s3 = '\u02b3 : var Z'; -var s4 = '\u02b4 = Z'; -var s5 = '\u02b1; } catch (Z' - var s6 = '\u02b5) { for (var Z'; -var s7 = '\u02b6 in Z'; -var s8 = '\u02b5){for (1; 1<0; Z'; -var s9 = '\u02b7++) {new Array()[Z'; -var s10 = '\u02b6] = 1;} };} }'; - - -/* - * Concatenate these and eval() to create the function Z\u02b1 - */ -var sEval = s0 + s1 + s2 + s3 + s4 + s5 + s6 + s7 + s8 + s9 + s10; -eval(sEval); - - -/* - * Recover all the double-byte identifiers via Z\u02b1.toString(). - * We'll recover the 1st one as arrID[1], the 2nd one as arrID[2], - * and so on ... - */ -var arrID = getIdentifiers(Z\u02b1); - - -/* - * Now check that we got back what we put in - - */ -status = inSection(1); -actual = arrID[1]; -expect = s1.charAt(0); -addThis(); - -status = inSection(2); -actual = arrID[2]; -expect = s2.charAt(0); -addThis(); - -status = inSection(3); -actual = arrID[3]; -expect = s3.charAt(0); -addThis(); - -status = inSection(4); -actual = arrID[4]; -expect = s4.charAt(0); -addThis(); - -status = inSection(5); -actual = arrID[5]; -expect = s5.charAt(0); -addThis(); - -status = inSection(6); -actual = arrID[6]; -expect = s6.charAt(0); -addThis(); - -status = inSection(7); -actual = arrID[7]; -expect = s7.charAt(0); -addThis(); - -status = inSection(8); -actual = arrID[8]; -expect = s8.charAt(0); -addThis(); - -status = inSection(9); -actual = arrID[9]; -expect = s9.charAt(0); -addThis(); - -status = inSection(10); -actual = arrID[10]; -expect = s10.charAt(0); -addThis(); - - - - -//----------------------------------------------------------------------------- -test(); -//----------------------------------------------------------------------------- - - - -/* - * Goal: recover the double-byte identifiers from f.toString() - * by getting the very next character after each 'Z' token. - * - * The return value will be an array |arr| indexed such that - * |arr[1]| is the 1st identifier, |arr[2]| the 2nd, and so on. - * - * Note, however, f.toString() is implementation-independent. - * For example, it may begin with '\nfunction' instead of 'function'. - * - * Rhino uses a Unicode representation for f.toString(); whereas - * SpiderMonkey uses an ASCII representation, putting escape sequences - * for non-ASCII characters. For example, if a function is called f\u02B1, - * then in Rhino the toString() method will present a 2-character Unicode - * string for its name, whereas SpiderMonkey will present a 7-character - * ASCII string for its name: the string literal 'f\u02B1'. - * - * So we force the lexer to condense the string before we use it. - * This will give uniform results in Rhino and SpiderMonkey. - */ -function getIdentifiers(f) -{ - var str = condenseStr(f.toString()); - var arr = str.split('Z'); - - /* - * The identifiers are the 1st char of each split substring - * EXCEPT the first one, which is just ('\n' +) 'function '. - * - * Thus note the 1st identifier will be stored in |arr[1]|, - * the 2nd one in |arr[2]|, etc., making the indexing easy - - */ - for (i in arr) - arr[i] = arr[i].charAt(0); - return arr; -} - - -/* - * This function is the opposite of a functions like escape(), which take - * Unicode characters and return escape sequences for them. Here, we force - * the lexer to turn escape sequences back into single characters. - * - * Note we can't simply do |eval(str)|, since in practice |str| will be an - * identifier somewhere in the program (e.g. a function name); thus |eval(str)| - * would return the object that the identifier represents: not what we want. - * - * So we surround |str| lexicographically with quotes to force the lexer to - * evaluate it as a string. Have to strip out any linefeeds first, however - - */ -function condenseStr(str) -{ - /* - * You won't be able to do the next step if |str| has - * any carriage returns or linefeeds in it. For example: - * - * js> eval("'" + '\nHello' + "'"); - * 1: SyntaxError: unterminated string literal: - * 1: ' - * 1: ^ - * - * So replace them with the empty string - - */ - str = str.replace(/[\r\n]/g, '') - return eval("'" + str + "'") - } - - -function addThis() -{ - statusitems[UBound] = status; - actualvalues[UBound] = actual; - expectedvalues[UBound] = expect; - UBound++; -} - - -function test() -{ - enterFunc('test'); - printBugNumber(BUGNUMBER); - printStatus(summary); - - for (var i=0; i?"; -var UntilRSBs = "[^]]*]([^]]+])*]+"; -var CDATA_CE = UntilRSBs + "([^]>]" + UntilRSBs + ")*>"; -var S = "[ \\n\\t\\r]+"; -var QuoteSE = '"[^"]' + "*" + '"' + "|'[^']*'"; -var DT_IdentSE = S + Name + "(" + S + "(" + Name + "|" + QuoteSE + "))*"; -var MarkupDeclCE = "([^]\"'><]+|" + QuoteSE + ")*>"; -var S1 = "[\\n\\r\\t ]"; -var UntilQMs = "[^?]*\\?+"; -var PI_Tail = "\\?>|" + S1 + UntilQMs + "([^>?]" + UntilQMs + ")*>"; -var DT_ItemSE = "<(!(--" + Until2Hyphens + ">|[^-]" + MarkupDeclCE + ")|\\?" + Name + "(" + PI_Tail + "))|%" + Name + ";|" + S; -var DocTypeCE = DT_IdentSE + "(" + S + ")?(\\[(" + DT_ItemSE + ")*](" + S + ")?)?>?"; -var DeclCE = "--(" + CommentCE + ")?|\\[CDATA\\[(" + CDATA_CE + ")?|DOCTYPE(" + DocTypeCE + ")?"; -var PI_CE = Name + "(" + PI_Tail + ")?"; -var EndTagCE = Name + "(" + S + ")?>?"; -var AttValSE = '"[^<"]' + "*" + '"' + "|'[^<']*'"; -var ElemTagCE = Name + "(" + S + Name + "(" + S + ")?=(" + S + ")?(" + AttValSE + "))*(" + S + ")?/?>?"; -var MarkupSPE = "<(!(" + DeclCE + ")?|\\?(" + PI_CE + ")?|/(" + EndTagCE + ")?|(" + ElemTagCE + ")?)"; -var XML_SPE = TextSE + "|" + MarkupSPE; -var CommentRE = " casting fails - { - Bar *pbar = qscriptvalue_cast(baz2Value); - QVERIFY(pbar == 0); - } - - { - QScriptValue ret = toBaz.callWithInstance(scriptZoo, QScriptValueList() << baz2Value); - QVERIFY(ret.isError()); - QCOMPARE(ret.toString(), QLatin1String("TypeError: incompatible type of argument(s) in call to toBaz(); candidates were\n toBaz(Bar*)")); - } - - // establish chain -- now casting should work - // Why? because qscriptvalue_cast() does magic again. - // It the instance itself is not of type T, qscriptvalue_cast() - // searches the prototype chain for T, and if it finds one, it infers - // that the instance can also be casted to that type. This cast is - // _not_ safe and thus relies on the developer doing the right thing. - // This is an undocumented feature to enable qscriptvalue_cast() to - // be used by prototype functions to cast the JS this-object to C++. - bazProto.setPrototype(barProto); - - { - Bar *pbar = qscriptvalue_cast(baz2Value); - QVERIFY(pbar != 0); - QCOMPARE(pbar->a, baz2.a); - } - - { - QScriptValue ret = toBaz.callWithInstance(scriptZoo, QScriptValueList() << baz2Value); - QEXPECT_FAIL("", "Cannot convert Baz* to Bar*", Continue); - QVERIFY(!ret.isError()); - QEXPECT_FAIL("", "Cannot convert Baz* to Bar*", Continue); - QCOMPARE(qscriptvalue_cast(ret), pbaz); - } - } - - bazProto.setPrototype(barProto.prototype()); // kill chain - { - Baz *pbaz = qscriptvalue_cast(baz2Value); - QVERIFY(pbaz != 0); - // should not work anymore - Bar *pbar = qscriptvalue_cast(baz2Value); - QVERIFY(pbar == 0); - } - - bazProto.setPrototype(eng.newQObject(this)); - { - Baz *pbaz = qscriptvalue_cast(baz2Value); - QVERIFY(pbaz != 0); - // should not work now either - Bar *pbar = qscriptvalue_cast(baz2Value); - QVERIFY(pbar == 0); - } - - { - QScriptValue b = eng.toScriptValue(QBrush()); - b.setPrototype(barProto); - // this shows that a "wrong" cast is possible, if you - // don't play by the rules (the pointer is actually a QBrush*)... - Bar *pbar = qscriptvalue_cast(b); - QVERIFY(pbar != 0); - } - - { - QScriptValue gradientProto = eng.toScriptValue(QGradient()); - QScriptValue linearGradientProto = eng.toScriptValue(QLinearGradient()); - linearGradientProto.setPrototype(gradientProto); - QLinearGradient lg(10, 20, 30, 40); - QScriptValue linearGradient = eng.toScriptValue(lg); - { - QGradient *pgrad = qscriptvalue_cast(linearGradient); - QVERIFY(pgrad == 0); - } - linearGradient.setPrototype(linearGradientProto); - { - QGradient *pgrad = qscriptvalue_cast(linearGradient); - QVERIFY(pgrad != 0); - QCOMPARE(pgrad->type(), QGradient::LinearGradient); - QLinearGradient *plingrad = static_cast(pgrad); - QCOMPARE(plingrad->start(), lg.start()); - QCOMPARE(plingrad->finalStop(), lg.finalStop()); - } - } -} -#endif - -class Klazz : public QWidget, - public QStandardItem, - public QGraphicsItem -{ - Q_INTERFACES(QGraphicsItem) - Q_OBJECT -public: - Klazz(QWidget *parent = 0) : QWidget(parent) { } - virtual QRectF boundingRect() const { return QRectF(); } - virtual void paint(QPainter*, const QStyleOptionGraphicsItem*, QWidget*) { } -}; - -Q_DECLARE_METATYPE(Klazz*) -Q_DECLARE_METATYPE(QStandardItem*) - -void tst_QJSEngine::castWithMultipleInheritance() -{ - QJSEngine eng; - Klazz klz; - QJSValue v = eng.newQObject(&klz); - - QCOMPARE(qjsvalue_cast(v), &klz); - QCOMPARE(qjsvalue_cast(v), (QWidget *)&klz); - QCOMPARE(qjsvalue_cast(v), (QObject *)&klz); - QCOMPARE(qjsvalue_cast(v), (QStandardItem *)&klz); - QCOMPARE(qjsvalue_cast(v), (QGraphicsItem *)&klz); -} - -void tst_QJSEngine::collectGarbage() -{ - QJSEngine eng; - eng.evaluate("a = new Object(); a = new Object(); a = new Object()"); - QJSValue a = eng.newObject(); - a = eng.newObject(); - a = eng.newObject(); - QPointer ptr = new QObject(); - QVERIFY(ptr != 0); - (void)eng.newQObject(ptr); - collectGarbage_helper(eng); - if (ptr) - QGuiApplication::sendPostedEvents(ptr, QEvent::DeferredDelete); - QVERIFY(ptr == 0); -} - -#if 0 // ###FIXME: no reportAdditionalMemoryCost API -void tst_QJSEngine::reportAdditionalMemoryCost() -{ - QScriptEngine eng; - // There isn't any reliable way to test whether calling - // this function affects garbage collection responsiveness; - // the best we can do is call it with a few different values. - for (int x = 0; x < 100; ++x) { - eng.reportAdditionalMemoryCost(0); - eng.reportAdditionalMemoryCost(10); - eng.reportAdditionalMemoryCost(1000); - eng.reportAdditionalMemoryCost(10000); - eng.reportAdditionalMemoryCost(100000); - eng.reportAdditionalMemoryCost(1000000); - eng.reportAdditionalMemoryCost(10000000); - eng.reportAdditionalMemoryCost(-1); - eng.reportAdditionalMemoryCost(-1000); - QScriptValue obj = eng.newObject(); - eng.collectGarbage(); - } -} -#endif - -void tst_QJSEngine::gcWithNestedDataStructure() -{ - // The GC must be able to traverse deeply nested objects, otherwise this - // test would crash. - QJSEngine eng; - eng.evaluate( - "function makeList(size)" - "{" - " var head = { };" - " var l = head;" - " for (var i = 0; i < size; ++i) {" - " l.data = i + \"\";" - " l.next = { }; l = l.next;" - " }" - " l.next = null;" - " return head;" - "}"); - QCOMPARE(eng.hasUncaughtException(), false); - const int size = 200; - QJSValue head = eng.evaluate(QString::fromLatin1("makeList(%0)").arg(size)); - QCOMPARE(eng.hasUncaughtException(), false); - for (int x = 0; x < 2; ++x) { - if (x == 1) - eng.evaluate("gc()"); - QJSValue l = head; - // Make sure all the nodes are still alive. - for (int i = 0; i < 200; ++i) { - QCOMPARE(l.property("data").toString(), QString::number(i)); - l = l.property("next"); - } - } -} - -#if 0 // ###FIXME: No processEvents handling -class EventReceiver : public QObject -{ -public: - EventReceiver() { - received = false; - } - - bool event(QEvent *e) { - received |= (e->type() == QEvent::User + 1); - return QObject::event(e); - } - - bool received; -}; - -void tst_QJSEngine::processEventsWhileRunning() -{ - for (int x = 0; x < 2; ++x) { - QScriptEngine eng; - if (x == 0) - eng.pushContext(); - - // This is running for a silly amount of time just to make sure - // the script doesn't finish before event processing is triggered. - QString script = QString::fromLatin1( - "var end = Number(new Date()) + 2000;" - "var x = 0;" - "while (Number(new Date()) < end) {" - " ++x;" - "}"); - - EventReceiver receiver; - QCoreApplication::postEvent(&receiver, new QEvent(QEvent::Type(QEvent::User+1))); - - eng.evaluate(script); - QVERIFY(!eng.hasUncaughtException()); - QVERIFY(!receiver.received); - - QCOMPARE(eng.processEventsInterval(), -1); - eng.setProcessEventsInterval(100); - eng.evaluate(script); - QVERIFY(!eng.hasUncaughtException()); - QVERIFY(receiver.received); - - if (x == 0) - eng.popContext(); - } -} - -void tst_QJSEngine::processEventsWhileRunning_function() -{ - QScriptEngine eng; - QScriptValue script = eng.evaluate(QString::fromLatin1( - "(function() { var end = Number(new Date()) + 2000;" - "var x = 0;" - "while (Number(new Date()) < end) {" - " ++x;" - "} })")); - - eng.setProcessEventsInterval(100); - - for (int x = 0; x < 2; ++x) { - EventReceiver receiver; - QCoreApplication::postEvent(&receiver, new QEvent(QEvent::Type(QEvent::User+1))); - QVERIFY(!eng.hasUncaughtException()); - QVERIFY(!receiver.received); - QCOMPARE(eng.processEventsInterval(), 100); - - if (x) script.call(); - else script.callAsConstructor(); - - QVERIFY(!eng.hasUncaughtException()); - QVERIFY(receiver.received); - } -} - - -class EventReceiver2 : public QObject -{ -public: - EventReceiver2(QScriptEngine *eng) { - engine = eng; - } - - bool event(QEvent *e) { - if (e->type() == QEvent::User + 1) { - engine->currentContext()->throwError("Killed"); - } - return QObject::event(e); - } - - QScriptEngine *engine; -}; - -void tst_QJSEngine::throwErrorFromProcessEvents_data() -{ - QTest::addColumn("script"); - QTest::addColumn("error"); - - QTest::newRow("while (1)") - << QString::fromLatin1("while (1) { }") - << QString::fromLatin1("Error: Killed"); - QTest::newRow("while (1) i++") - << QString::fromLatin1("i = 0; while (1) { i++; }") - << QString::fromLatin1("Error: Killed"); - // Unlike abortEvaluation(), scripts should be able to catch the - // exception. - QTest::newRow("try catch") - << QString::fromLatin1("try {" - " while (1) { }" - "} catch(e) {" - " throw new Error('Caught');" - "}") - << QString::fromLatin1("Error: Caught"); -} - -void tst_QJSEngine::throwErrorFromProcessEvents() -{ - QFETCH(QString, script); - QFETCH(QString, error); - - QScriptEngine eng; - - EventReceiver2 receiver(&eng); - QCoreApplication::postEvent(&receiver, new QEvent(QEvent::Type(QEvent::User+1))); - - eng.setProcessEventsInterval(100); - QScriptValue ret = eng.evaluate(script); - QVERIFY(ret.isError()); - QCOMPARE(ret.toString(), error); -} - -void tst_QJSEngine::disableProcessEventsInterval() -{ - QScriptEngine eng; - eng.setProcessEventsInterval(100); - QCOMPARE(eng.processEventsInterval(), 100); - eng.setProcessEventsInterval(0); - QCOMPARE(eng.processEventsInterval(), 0); - eng.setProcessEventsInterval(-1); - QCOMPARE(eng.processEventsInterval(), -1); - eng.setProcessEventsInterval(-100); - QCOMPARE(eng.processEventsInterval(), -100); -} -#endif - - -void tst_QJSEngine::stacktrace() -{ - QString script = QString::fromLatin1( - "function foo(counter) {\n" - " switch (counter) {\n" - " case 0: foo(counter+1); break;\n" - " case 1: foo(counter+1); break;\n" - " case 2: foo(counter+1); break;\n" - " case 3: foo(counter+1); break;\n" - " case 4: foo(counter+1); break;\n" - " default:\n" - " throw new Error('blah');\n" - " }\n" - "}\n" - "foo(0);"); - - const QString fileName("testfile"); - - QStringList backtrace; - backtrace << "foo(5)@testfile:9" - << "foo(4)@testfile:7" - << "foo(3)@testfile:6" - << "foo(2)@testfile:5" - << "foo(1)@testfile:4" - << "foo(0)@testfile:3" - << "()@testfile:12"; - - QJSEngine eng; - QJSValue result = eng.evaluate(script, fileName); - QVERIFY(eng.hasUncaughtException()); - QVERIFY(result.isError()); - - // QEXPECT_FAIL("", "QTBUG-6139: uncaughtExceptionBacktrace() doesn't give the full backtrace", Abort); - // ###FIXME: no uncahgutExceptionBacktrace: QCOMPARE(eng.uncaughtExceptionBacktrace(), backtrace); - QVERIFY(eng.hasUncaughtException()); - QVERIFY(result.strictlyEquals(eng.uncaughtException())); - - // FIXME? it is not standard. - //QCOMPARE(result.property("fileName").toString(), fileName); - //QCOMPARE(result.property("lineNumber").toInt(), 9); - - QJSValue stack = result.property("stack"); - - // FIXME? it is not standard. - // QVERIFY(stack.isArray()); - //QCOMPARE(stack.property("length").toInt(), 7); - - QJSValueIterator it(stack); - int counter = 5; - while (it.hasNext()) { - it.next(); - QJSValue obj = it.value(); - QJSValue frame = obj.property("frame"); - - QCOMPARE(obj.property("fileName").toString(), fileName); - if (counter >= 0) { - QJSValue callee = frame.property("arguments").property("callee"); - QVERIFY(callee.strictlyEquals(eng.globalObject().property("foo"))); - QCOMPARE(obj.property("functionName").toString(), QString("foo")); - int line = obj.property("lineNumber").toInt(); - if (counter == 5) - QCOMPARE(line, 9); - else - QCOMPARE(line, 3 + counter); - } else { - QVERIFY(frame.strictlyEquals(eng.globalObject())); - QVERIFY(obj.property("functionName").toString().isEmpty()); - } - - --counter; - } - -// FIXME? it is not standard. -// { -// QJSValue bt = result.property("backtrace").call(result); -// QCOMPARE(qjsvalue_cast(bt), backtrace); -// } - - // throw something that isn't an Error object - eng.clearExceptions(); - // ###FIXME: No uncaughtExceptionBacktrace: QVERIFY(eng.uncaughtExceptionBacktrace().isEmpty()); - QString script2 = QString::fromLatin1( - "function foo(counter) {\n" - " switch (counter) {\n" - " case 0: foo(counter+1); break;\n" - " case 1: foo(counter+1); break;\n" - " case 2: foo(counter+1); break;\n" - " case 3: foo(counter+1); break;\n" - " case 4: foo(counter+1); break;\n" - " default:\n" - " throw 'just a string';\n" - " }\n" - "}\n" - "foo(0);"); - - QJSValue result2 = eng.evaluate(script2, fileName); - QVERIFY(eng.hasUncaughtException()); - QVERIFY(!result2.isError()); - QVERIFY(result2.isString()); - - // ###FIXME: No uncaughtExceptionBacktrace: QCOMPARE(eng.uncaughtExceptionBacktrace(), backtrace); - QVERIFY(eng.hasUncaughtException()); - - eng.clearExceptions(); - QVERIFY(!eng.hasUncaughtException()); - // ###FIXME: No uncaughtExceptionBacktrace: QVERIFY(eng.uncaughtExceptionBacktrace().isEmpty()); -} - -void tst_QJSEngine::numberParsing_data() -{ - QTest::addColumn("string"); - QTest::addColumn("expect"); - - QTest::newRow("decimal 0") << QString("0") << qreal(0); - QTest::newRow("octal 0") << QString("00") << qreal(00); - QTest::newRow("hex 0") << QString("0x0") << qreal(0x0); - QTest::newRow("decimal 100") << QString("100") << qreal(100); - QTest::newRow("hex 100") << QString("0x100") << qreal(0x100); - QTest::newRow("octal 100") << QString("0100") << qreal(0100); - QTest::newRow("decimal 4G") << QString("4294967296") << qreal(Q_UINT64_C(4294967296)); - QTest::newRow("hex 4G") << QString("0x100000000") << qreal(Q_UINT64_C(0x100000000)); - QTest::newRow("octal 4G") << QString("040000000000") << qreal(Q_UINT64_C(040000000000)); - QTest::newRow("0.5") << QString("0.5") << qreal(0.5); - QTest::newRow("1.5") << QString("1.5") << qreal(1.5); - QTest::newRow("1e2") << QString("1e2") << qreal(100); -} - -void tst_QJSEngine::numberParsing() -{ - QFETCH(QString, string); - QFETCH(qreal, expect); - - QJSEngine eng; - QJSValue ret = eng.evaluate(string); - QVERIFY(ret.isNumber()); - qreal actual = ret.toNumber(); - QCOMPARE(actual, expect); -} - -// see ECMA-262, section 7.9 -// This is testing ECMA compliance, not our C++ API, but it's important that -// the back-end is conformant in this regard. -void tst_QJSEngine::automaticSemicolonInsertion() -{ - QJSEngine eng; - { - QJSValue ret = eng.evaluate("{ 1 2 } 3"); - QVERIFY(ret.isError()); - QVERIFY(ret.toString().contains("SyntaxError")); - } - { - QJSValue ret = eng.evaluate("{ 1\n2 } 3"); - QVERIFY(ret.isNumber()); - QCOMPARE(ret.toInt(), 3); - } - { - QJSValue ret = eng.evaluate("for (a; b\n)"); - QVERIFY(ret.isError()); - QVERIFY(ret.toString().contains("SyntaxError")); - } - { - QJSValue ret = eng.evaluate("(function() { return\n1 + 2 })()"); - QVERIFY(ret.isUndefined()); - } - { - eng.evaluate("c = 2; b = 1"); - QJSValue ret = eng.evaluate("a = b\n++c"); - QVERIFY(ret.isNumber()); - QCOMPARE(ret.toInt(), 3); - } - { - QJSValue ret = eng.evaluate("if (a > b)\nelse c = d"); - QVERIFY(ret.isError()); - QVERIFY(ret.toString().contains("SyntaxError")); - } - { - eng.evaluate("function c() { return { foo: function() { return 5; } } }"); - eng.evaluate("b = 1; d = 2; e = 3"); - QJSValue ret = eng.evaluate("a = b + c\n(d + e).foo()"); - QVERIFY(ret.isNumber()); - QCOMPARE(ret.toInt(), 6); - } - { - QJSValue ret = eng.evaluate("throw\n1"); - QVERIFY(ret.isError()); - QVERIFY(ret.toString().contains("SyntaxError")); - } - { - QJSValue ret = eng.evaluate("a = Number(1)\n++a"); - QVERIFY(ret.isNumber()); - QCOMPARE(ret.toInt(), 2); - } - - // "a semicolon is never inserted automatically if the semicolon - // would then be parsed as an empty statement" - { - eng.evaluate("a = 123"); - QJSValue ret = eng.evaluate("if (0)\n ++a; a"); - QVERIFY(ret.isNumber()); - QCOMPARE(ret.toInt(), 123); - } - { - eng.evaluate("a = 123"); - QJSValue ret = eng.evaluate("if (0)\n --a; a"); - QVERIFY(ret.isNumber()); - QCOMPARE(ret.toInt(), 123); - } - { - eng.evaluate("a = 123"); - QJSValue ret = eng.evaluate("if ((0))\n ++a; a"); - QVERIFY(ret.isNumber()); - QCOMPARE(ret.toInt(), 123); - } - { - eng.evaluate("a = 123"); - QJSValue ret = eng.evaluate("if ((0))\n --a; a"); - QVERIFY(ret.isNumber()); - QCOMPARE(ret.toInt(), 123); - } - { - eng.evaluate("a = 123"); - QJSValue ret = eng.evaluate("if (0\n)\n ++a; a"); - QVERIFY(ret.isNumber()); - QCOMPARE(ret.toInt(), 123); - } - { - eng.evaluate("a = 123"); - QJSValue ret = eng.evaluate("if (0\n ++a; a"); - QVERIFY(ret.isError()); - } - { - eng.evaluate("a = 123"); - QJSValue ret = eng.evaluate("if (0))\n ++a; a"); - QVERIFY(ret.isError()); - } - { - QJSValue ret = eng.evaluate("n = 0; for (i = 0; i < 10; ++i)\n ++n; n"); - QVERIFY(ret.isNumber()); - QCOMPARE(ret.toInt(), 10); - } - { - QJSValue ret = eng.evaluate("n = 30; for (i = 0; i < 10; ++i)\n --n; n"); - QVERIFY(ret.isNumber()); - QCOMPARE(ret.toInt(), 20); - } - { - QJSValue ret = eng.evaluate("n = 0; for (var i = 0; i < 10; ++i)\n ++n; n"); - QVERIFY(ret.isNumber()); - QCOMPARE(ret.toInt(), 10); - } - { - QJSValue ret = eng.evaluate("n = 30; for (var i = 0; i < 10; ++i)\n --n; n"); - QVERIFY(ret.isNumber()); - QCOMPARE(ret.toInt(), 20); - } - { - QJSValue ret = eng.evaluate("n = 0; i = 0; while (i++ < 10)\n ++n; n"); - QVERIFY(ret.isNumber()); - QCOMPARE(ret.toInt(), 10); - } - { - QJSValue ret = eng.evaluate("n = 30; i = 0; while (i++ < 10)\n --n; n"); - QVERIFY(ret.isNumber()); - QCOMPARE(ret.toInt(), 20); - } - { - QJSValue ret = eng.evaluate("o = { a: 0, b: 1, c: 2 }; n = 0; for (i in o)\n ++n; n"); - QVERIFY(ret.isNumber()); - QCOMPARE(ret.toInt(), 3); - } - { - QJSValue ret = eng.evaluate("o = { a: 0, b: 1, c: 2 }; n = 9; for (i in o)\n --n; n"); - QVERIFY(ret.isNumber()); - QCOMPARE(ret.toInt(), 6); - } - { - QJSValue ret = eng.evaluate("o = { a: 0, b: 1, c: 2 }; n = 0; for (var i in o)\n ++n; n"); - QVERIFY(ret.isNumber()); - QCOMPARE(ret.toInt(), 3); - } - { - QJSValue ret = eng.evaluate("o = { a: 0, b: 1, c: 2 }; n = 9; for (var i in o)\n --n; n"); - QVERIFY(ret.isNumber()); - QCOMPARE(ret.toInt(), 6); - } - { - QJSValue ret = eng.evaluate("o = { n: 3 }; n = 5; with (o)\n ++n; n"); - QVERIFY(ret.isNumber()); - QCOMPARE(ret.toInt(), 5); - } - { - QJSValue ret = eng.evaluate("o = { n: 3 }; n = 10; with (o)\n --n; n"); - QVERIFY(ret.isNumber()); - QCOMPARE(ret.toInt(), 10); - } - { - QJSValue ret = eng.evaluate("n = 5; i = 0; do\n ++n; while (++i < 10); n"); - QVERIFY(ret.isNumber()); - QCOMPARE(ret.toInt(), 15); - } - { - QJSValue ret = eng.evaluate("n = 20; i = 0; do\n --n; while (++i < 10); n"); - QVERIFY(ret.isNumber()); - QCOMPARE(ret.toInt(), 10); - } - - { - QJSValue ret = eng.evaluate("n = 1; i = 0; if (n) i\n++n; n"); - QVERIFY(ret.isNumber()); - QCOMPARE(ret.toInt(), 2); - } - { - QJSValue ret = eng.evaluate("n = 1; i = 0; if (n) i\n--n; n"); - QVERIFY(ret.isNumber()); - QCOMPARE(ret.toInt(), 0); - } - - { - QJSValue ret = eng.evaluate("if (0)"); - QVERIFY(ret.isError()); - } - { - QJSValue ret = eng.evaluate("while (0)"); - QVERIFY(ret.isError()); - } - { - QJSValue ret = eng.evaluate("for (;;)"); - QVERIFY(ret.isError()); - } - { - QJSValue ret = eng.evaluate("for (p in this)"); - QVERIFY(ret.isError()); - } - { - QJSValue ret = eng.evaluate("with (this)"); - QVERIFY(ret.isError()); - } - { - QJSValue ret = eng.evaluate("do"); - QVERIFY(ret.isError()); - } -} - -#if 0 // ###FIXME: no abortEvaluation API -class EventReceiver3 : public QObject -{ -public: - enum AbortionResult { - None = 0, - String = 1, - Error = 2, - Number = 3 - }; - - EventReceiver3(QScriptEngine *eng) { - engine = eng; - resultType = None; - } - - bool event(QEvent *e) { - if (e->type() == QEvent::User + 1) { - switch (resultType) { - case None: - engine->abortEvaluation(); - break; - case String: - engine->abortEvaluation(QScriptValue(engine, QString::fromLatin1("Aborted"))); - break; - case Error: - engine->abortEvaluation(engine->currentContext()->throwError("AbortedWithError")); - break; - case Number: - engine->abortEvaluation(QScriptValue(1234)); - } - } - return QObject::event(e); - } - - AbortionResult resultType; - QScriptEngine *engine; -}; - -static QScriptValue myFunctionAbortingEvaluation(QScriptContext *, QScriptEngine *eng) -{ - eng->abortEvaluation(); - return eng->nullValue(); // should be ignored -} - -void tst_QJSEngine::abortEvaluation_notEvaluating() -{ - QScriptEngine eng; - - eng.abortEvaluation(); - QVERIFY(!eng.hasUncaughtException()); - - eng.abortEvaluation(123); - { - QScriptValue ret = eng.evaluate("'ciao'"); - QVERIFY(ret.isString()); - QCOMPARE(ret.toString(), QString::fromLatin1("ciao")); - } -} - -void tst_QJSEngine::abortEvaluation_data() -{ - QTest::addColumn("script"); - - QTest::newRow("while (1)") - << QString::fromLatin1("while (1) { }"); - QTest::newRow("while (1) i++") - << QString::fromLatin1("i = 0; while (1) { i++; }"); - QTest::newRow("try catch") - << QString::fromLatin1("try {" - " while (1) { }" - "} catch(e) {" - " throw new Error('Caught');" - "}"); -} - -void tst_QJSEngine::abortEvaluation() -{ - QFETCH(QString, script); - - QScriptEngine eng; - EventReceiver3 receiver(&eng); - - eng.setProcessEventsInterval(100); - for (int x = 0; x < 4; ++x) { - QCoreApplication::postEvent(&receiver, new QEvent(QEvent::Type(QEvent::User+1))); - receiver.resultType = EventReceiver3::AbortionResult(x); - QScriptValue ret = eng.evaluate(script); - switch (receiver.resultType) { - case EventReceiver3::None: - QVERIFY(!eng.hasUncaughtException()); - QVERIFY(ret.isUndefined()); - break; - case EventReceiver3::Number: - QVERIFY(!eng.hasUncaughtException()); - QVERIFY(ret.isNumber()); - QCOMPARE(ret.toInt(), 1234); - break; - case EventReceiver3::String: - QVERIFY(!eng.hasUncaughtException()); - QVERIFY(ret.isString()); - QCOMPARE(ret.toString(), QString::fromLatin1("Aborted")); - break; - case EventReceiver3::Error: - QVERIFY(eng.hasUncaughtException()); - QVERIFY(ret.isError()); - QCOMPARE(ret.toString(), QString::fromLatin1("Error: AbortedWithError")); - break; - } - } - -} - -void tst_QJSEngine::abortEvaluation_tryCatch() -{ - QSKIP("It crashes"); - QScriptEngine eng; - EventReceiver3 receiver(&eng); - eng.setProcessEventsInterval(100); - // scripts cannot intercept the abortion with try/catch - for (int y = 0; y < 4; ++y) { - QCoreApplication::postEvent(&receiver, new QEvent(QEvent::Type(QEvent::User+1))); - receiver.resultType = EventReceiver3::AbortionResult(y); - QScriptValue ret = eng.evaluate(QString::fromLatin1( - "while (1) {\n" - " try {\n" - " (function() { while (1) { } })();\n" - " } catch (e) {\n" - " ;\n" - " }\n" - "}")); - switch (receiver.resultType) { - case EventReceiver3::None: - QVERIFY(!eng.hasUncaughtException()); - QVERIFY(ret.isUndefined()); - break; - case EventReceiver3::Number: - QVERIFY(!eng.hasUncaughtException()); - QVERIFY(ret.isNumber()); - QCOMPARE(ret.toInt(), 1234); - break; - case EventReceiver3::String: - QVERIFY(!eng.hasUncaughtException()); - QVERIFY(ret.isString()); - QCOMPARE(ret.toString(), QString::fromLatin1("Aborted")); - break; - case EventReceiver3::Error: - QVERIFY(eng.hasUncaughtException()); - QVERIFY(ret.isError()); - break; - } - } -} - -void tst_QJSEngine::abortEvaluation_fromNative() -{ - QScriptEngine eng; - QScriptValue fun = eng.newFunction(myFunctionAbortingEvaluation); - eng.globalObject().setProperty("myFunctionAbortingEvaluation", fun); - QScriptValue ret = eng.evaluate("myFunctionAbortingEvaluation()"); - QVERIFY(ret.isUndefined()); -} - -class ThreadedEngine : public QThread { - Q_OBJECT; - -private: - QScriptEngine* m_engine; -protected: - void run() { - m_engine = new QScriptEngine(); - m_engine->setGlobalObject(m_engine->newQObject(this)); - m_engine->evaluate("while (1) { sleep(); }"); - delete m_engine; - } - -public slots: - void sleep() - { - QTest::qSleep(25); - m_engine->abortEvaluation(); - } -}; - -void tst_QJSEngine::abortEvaluation_QTBUG9433() -{ - ThreadedEngine engine; - engine.start(); - QVERIFY(engine.isRunning()); - QTest::qSleep(50); - for (uint i = 0; i < 50; ++i) { // up to ~2500 ms - if (engine.isFinished()) - return; - QTest::qSleep(50); - } - if (!engine.isFinished()) { - engine.terminate(); - engine.wait(7000); - QFAIL("abortEvaluation doesn't work"); - } - -} -#endif - -#if 0 // ###FIXME: no QScriptEngine::isEvaluating -static QScriptValue myFunctionReturningIsEvaluating(QScriptContext *, QScriptEngine *eng) -{ - return QScriptValue(eng, eng->isEvaluating()); -} - -class EventReceiver4 : public QObject -{ -public: - EventReceiver4(QScriptEngine *eng) { - engine = eng; - wasEvaluating = false; - } - - bool event(QEvent *e) { - if (e->type() == QEvent::User + 1) { - wasEvaluating = engine->isEvaluating(); - } - return QObject::event(e); - } - - QScriptEngine *engine; - bool wasEvaluating; -}; - -void tst_QJSEngine::isEvaluating_notEvaluating() -{ - QScriptEngine eng; - - QVERIFY(!eng.isEvaluating()); - - eng.evaluate(""); - QVERIFY(!eng.isEvaluating()); - eng.evaluate("123"); - QVERIFY(!eng.isEvaluating()); - eng.evaluate("0 = 0"); - QVERIFY(!eng.isEvaluating()); -} - -void tst_QJSEngine::isEvaluating_fromNative() -{ - QScriptEngine eng; - QScriptValue fun = eng.newFunction(myFunctionReturningIsEvaluating); - eng.globalObject().setProperty("myFunctionReturningIsEvaluating", fun); - QScriptValue ret = eng.evaluate("myFunctionReturningIsEvaluating()"); - QVERIFY(ret.isBool()); - QVERIFY(ret.toBool()); - ret = fun.call(); - QVERIFY(ret.isBool()); - QVERIFY(ret.toBool()); - ret = myFunctionReturningIsEvaluating(eng.currentContext(), &eng); - QVERIFY(ret.isBool()); - QVERIFY(!ret.toBool()); -} - -void tst_QJSEngine::isEvaluating_fromEvent() -{ - QScriptEngine eng; - EventReceiver4 receiver(&eng); - QCoreApplication::postEvent(&receiver, new QEvent(QEvent::Type(QEvent::User+1))); - - QString script = QString::fromLatin1( - "var end = Number(new Date()) + 1000;" - "var x = 0;" - "while (Number(new Date()) < end) {" - " ++x;" - "}"); - - eng.setProcessEventsInterval(100); - eng.evaluate(script); - QVERIFY(receiver.wasEvaluating); -} -#endif - -static QtMsgType theMessageType; -static QString theMessage; - -static void myMsgHandler(QtMsgType type, const char *msg) -{ - theMessageType = type; - theMessage = QString::fromLatin1(msg); -} - -#if 0 -void tst_QJSEngine::printFunctionWithCustomHandler() -{ - // The built-in print() function passes the output to Qt's message - // handler. By installing a custom message handler, the output can be - // redirected without changing the print() function itself. - // This behavior is not documented. - QJSEngine eng; - QtMsgHandler oldHandler = qInstallMsgHandler(myMsgHandler); - QVERIFY(eng.globalObject().property("print").isCallable()); - - theMessageType = QtSystemMsg; - QVERIFY(theMessage.isEmpty()); - QVERIFY(eng.evaluate("print('test')").isUndefined()); - QCOMPARE(theMessageType, QtDebugMsg); - QCOMPARE(theMessage, QString::fromLatin1("test")); - - theMessageType = QtSystemMsg; - theMessage.clear(); - QVERIFY(eng.evaluate("print(3, true, 'little pigs')").isUndefined()); - QCOMPARE(theMessageType, QtDebugMsg); - QCOMPARE(theMessage, QString::fromLatin1("3 true little pigs")); - - qInstallMsgHandler(oldHandler); -} - -void tst_QJSEngine::printThrowsException() -{ - // If an argument to print() causes an exception to be thrown when - // it's converted to a string, print() should propagate the exception. - QJSEngine eng; - QJSValue ret = eng.evaluate("print({ toString: function() { throw 'foo'; } });"); - QVERIFY(eng.hasUncaughtException()); - QVERIFY(ret.strictlyEquals(eng.toScriptValue(QLatin1String("foo")))); -} -#endif - -void tst_QJSEngine::errorConstructors() -{ - QJSEngine eng; - QStringList prefixes; - prefixes << "" << "Eval" << "Range" << "Reference" << "Syntax" << "Type" << "URI"; - for (int x = 0; x < 3; ++x) { - for (int i = 0; i < prefixes.size(); ++i) { - QString name = prefixes.at(i) + QLatin1String("Error"); - QString code = QString(i+1, QLatin1Char('\n')); - if (x == 0) - code += QLatin1String("throw "); - else if (x == 1) - code += QLatin1String("new "); - code += name + QLatin1String("()"); - QJSValue ret = eng.evaluate(code); - QVERIFY(ret.isError()); - QCOMPARE(eng.hasUncaughtException(), x == 0); - eng.clearExceptions(); - QVERIFY(ret.toString().startsWith(name)); - //QTBUG-6138: JSC doesn't assign lineNumber when errors are not thrown - QEXPECT_FAIL("", "we have no more lineNumber property ", Continue); - QCOMPARE(ret.property("lineNumber").toInt(), i+2); - } - } -} - -void tst_QJSEngine::argumentsProperty_globalContext() -{ - QJSEngine eng; - { - // Unlike function calls, the global context doesn't have an - // arguments property. - QJSValue ret = eng.evaluate("arguments"); - QVERIFY(ret.isError()); - QVERIFY(ret.toString().contains(QString::fromLatin1("ReferenceError"))); - } - eng.evaluate("arguments = 10"); - { - QJSValue ret = eng.evaluate("arguments"); - QVERIFY(ret.isNumber()); - QCOMPARE(ret.toInt(), 10); - } - QVERIFY(eng.evaluate("delete arguments").toBool()); - QVERIFY(eng.globalObject().property("arguments").isUndefined()); -} - -void tst_QJSEngine::argumentsProperty_JS() -{ - { - QJSEngine eng; - eng.evaluate("o = { arguments: 123 }"); - QJSValue ret = eng.evaluate("with (o) { arguments; }"); - QVERIFY(ret.isNumber()); - QCOMPARE(ret.toInt(), 123); - } - { - QJSEngine eng; - QVERIFY(eng.globalObject().property("arguments").isUndefined()); - // This is testing ECMA-262 compliance. In function calls, "arguments" - // appears like a local variable, and it can be replaced. - QJSValue ret = eng.evaluate("(function() { arguments = 456; return arguments; })()"); - QVERIFY(ret.isNumber()); - QCOMPARE(ret.toInt(), 456); - QVERIFY(eng.globalObject().property("arguments").isUndefined()); - } -} - -#if 0 // ###FIXME: no QScriptContext API -static QScriptValue argumentsProperty_fun(QScriptContext *, QScriptEngine *eng) -{ - // Since evaluate() is done in the current context, "arguments" should - // refer to currentContext()->argumentsObject(). - // This is for consistency with the built-in JS eval() function. - eng->evaluate("var a = arguments[0];"); - eng->evaluate("arguments[0] = 200;"); - return eng->evaluate("a + arguments[0]"); -} - -void tst_QJSEngine::argumentsProperty_evaluateInNativeFunction() -{ - QScriptEngine eng; - QScriptValue fun = eng.newFunction(argumentsProperty_fun); - eng.globalObject().setProperty("fun", eng.newFunction(argumentsProperty_fun)); - QScriptValue result = eng.evaluate("fun(18)"); - QVERIFY(result.isNumber()); - QCOMPARE(result.toInt(), 200+18); -} -#endif - -void tst_QJSEngine::jsNumberClass() -{ - // See ECMA-262 Section 15.7, "Number Objects". - - QJSEngine eng; - - QJSValue ctor = eng.globalObject().property("Number"); - QVERIFY(ctor.property("length").isNumber()); - QCOMPARE(ctor.property("length").toNumber(), qreal(1)); - QJSValue proto = ctor.property("prototype"); - QVERIFY(proto.isObject()); - { - QVERIFY(ctor.property("MAX_VALUE").isNumber()); - QVERIFY(ctor.property("MIN_VALUE").isNumber()); - QVERIFY(ctor.property("NaN").isNumber()); - QVERIFY(ctor.property("NEGATIVE_INFINITY").isNumber()); - QVERIFY(ctor.property("POSITIVE_INFINITY").isNumber()); - } - QCOMPARE(proto.toNumber(), qreal(0)); - QVERIFY(proto.property("constructor").strictlyEquals(ctor)); - - { - QJSValue ret = eng.evaluate("Number()"); - QVERIFY(ret.isNumber()); - QCOMPARE(ret.toNumber(), qreal(0)); - } - { - QJSValue ret = eng.evaluate("Number(123)"); - QVERIFY(ret.isNumber()); - QCOMPARE(ret.toNumber(), qreal(123)); - } - { - QJSValue ret = eng.evaluate("Number('456')"); - QVERIFY(ret.isNumber()); - QCOMPARE(ret.toNumber(), qreal(456)); - } - { - QJSValue ret = eng.evaluate("new Number()"); - QVERIFY(!ret.isNumber()); - QVERIFY(ret.isObject()); - QCOMPARE(ret.toNumber(), qreal(0)); - } - { - QJSValue ret = eng.evaluate("new Number(123)"); - QVERIFY(!ret.isNumber()); - QVERIFY(ret.isObject()); - QCOMPARE(ret.toNumber(), qreal(123)); - } - { - QJSValue ret = eng.evaluate("new Number('456')"); - QVERIFY(!ret.isNumber()); - QVERIFY(ret.isObject()); - QCOMPARE(ret.toNumber(), qreal(456)); - } - - QVERIFY(proto.property("toString").isCallable()); - { - QJSValue ret = eng.evaluate("new Number(123).toString()"); - QVERIFY(ret.isString()); - QCOMPARE(ret.toString(), QString::fromLatin1("123")); - } - { - QJSValue ret = eng.evaluate("new Number(123).toString(8)"); - QVERIFY(ret.isString()); - QCOMPARE(ret.toString(), QString::fromLatin1("173")); - } - { - QJSValue ret = eng.evaluate("new Number(123).toString(16)"); - QVERIFY(ret.isString()); - QCOMPARE(ret.toString(), QString::fromLatin1("7b")); - } - QVERIFY(proto.property("toLocaleString").isCallable()); - { - QJSValue ret = eng.evaluate("new Number(123).toLocaleString()"); - QVERIFY(ret.isString()); - QCOMPARE(ret.toString(), QString::fromLatin1("123")); - } - QVERIFY(proto.property("valueOf").isCallable()); - { - QJSValue ret = eng.evaluate("new Number(123).valueOf()"); - QVERIFY(ret.isNumber()); - QCOMPARE(ret.toNumber(), qreal(123)); - } - QVERIFY(proto.property("toExponential").isCallable()); - { - QJSValue ret = eng.evaluate("new Number(123).toExponential()"); - QVERIFY(ret.isString()); - QCOMPARE(ret.toString(), QString::fromLatin1("1.23e+2")); - } - QVERIFY(proto.property("toFixed").isCallable()); - { - QJSValue ret = eng.evaluate("new Number(123).toFixed()"); - QVERIFY(ret.isString()); - QCOMPARE(ret.toString(), QString::fromLatin1("123")); - } - QVERIFY(proto.property("toPrecision").isCallable()); - { - QJSValue ret = eng.evaluate("new Number(123).toPrecision()"); - QVERIFY(ret.isString()); - QCOMPARE(ret.toString(), QString::fromLatin1("123")); - } -} - -void tst_QJSEngine::jsForInStatement_simple() -{ - QJSEngine eng; - { - QJSValue ret = eng.evaluate("o = { }; r = []; for (var p in o) r[r.length] = p; r"); - QStringList lst = qjsvalue_cast(ret); - QVERIFY(lst.isEmpty()); - } - { - QJSValue ret = eng.evaluate("o = { p: 123 }; r = [];" - "for (var p in o) r[r.length] = p; r"); - QStringList lst = qjsvalue_cast(ret); - QCOMPARE(lst.size(), 1); - QCOMPARE(lst.at(0), QString::fromLatin1("p")); - } - { - QJSValue ret = eng.evaluate("o = { p: 123, q: 456 }; r = [];" - "for (var p in o) r[r.length] = p; r"); - QStringList lst = qjsvalue_cast(ret); - QCOMPARE(lst.size(), 2); - QCOMPARE(lst.at(0), QString::fromLatin1("p")); - QCOMPARE(lst.at(1), QString::fromLatin1("q")); - } -} - -void tst_QJSEngine::jsForInStatement_prototypeProperties() -{ - QJSEngine eng; - { - QJSValue ret = eng.evaluate("o = { }; o.__proto__ = { p: 123 }; r = [];" - "for (var p in o) r[r.length] = p; r"); - QStringList lst = qjsvalue_cast(ret); - QCOMPARE(lst.size(), 1); - QCOMPARE(lst.at(0), QString::fromLatin1("p")); - } - { - QJSValue ret = eng.evaluate("o = { p: 123 }; o.__proto__ = { q: 456 }; r = [];" - "for (var p in o) r[r.length] = p; r"); - QStringList lst = qjsvalue_cast(ret); - QCOMPARE(lst.size(), 2); - QCOMPARE(lst.at(0), QString::fromLatin1("p")); - QCOMPARE(lst.at(1), QString::fromLatin1("q")); - } - { - // shadowed property - QJSValue ret = eng.evaluate("o = { p: 123 }; o.__proto__ = { p: 456 }; r = [];" - "for (var p in o) r[r.length] = p; r"); - QStringList lst = qjsvalue_cast(ret); - QCOMPARE(lst.size(), 1); - QCOMPARE(lst.at(0), QString::fromLatin1("p")); - } - -} - -void tst_QJSEngine::jsForInStatement_mutateWhileIterating() -{ - QJSEngine eng; - // deleting property during enumeration - { - QJSValue ret = eng.evaluate("o = { p: 123 }; r = [];" - "for (var p in o) { r[r.length] = p; delete r[p]; } r"); - QStringList lst = qjsvalue_cast(ret); - QCOMPARE(lst.size(), 1); - QCOMPARE(lst.at(0), QString::fromLatin1("p")); - } - { - QJSValue ret = eng.evaluate("o = { p: 123, q: 456 }; r = [];" - "for (var p in o) { r[r.length] = p; delete o.q; } r"); - QStringList lst = qjsvalue_cast(ret); - QCOMPARE(lst.size(), 1); - QCOMPARE(lst.at(0), QString::fromLatin1("p")); - } - - // adding property during enumeration - { - QJSValue ret = eng.evaluate("o = { p: 123 }; r = [];" - "for (var p in o) { r[r.length] = p; o.q = 456; } r"); - QStringList lst = qjsvalue_cast(ret); - QCOMPARE(lst.size(), 1); - QCOMPARE(lst.at(0), QString::fromLatin1("p")); - } - -} - -void tst_QJSEngine::jsForInStatement_arrays() -{ - QJSEngine eng; - { - QJSValue ret = eng.evaluate("a = [123, 456]; r = [];" - "for (var p in a) r[r.length] = p; r"); - QStringList lst = qjsvalue_cast(ret); - QCOMPARE(lst.size(), 2); - QCOMPARE(lst.at(0), QString::fromLatin1("0")); - QCOMPARE(lst.at(1), QString::fromLatin1("1")); - } - { - QJSValue ret = eng.evaluate("a = [123, 456]; a.foo = 'bar'; r = [];" - "for (var p in a) r[r.length] = p; r"); - QStringList lst = qjsvalue_cast(ret); - QCOMPARE(lst.size(), 3); - QCOMPARE(lst.at(0), QString::fromLatin1("0")); - QCOMPARE(lst.at(1), QString::fromLatin1("1")); - QCOMPARE(lst.at(2), QString::fromLatin1("foo")); - } - { - QJSValue ret = eng.evaluate("a = [123, 456]; a.foo = 'bar';" - "b = [111, 222, 333]; b.bar = 'baz';" - "a.__proto__ = b; r = [];" - "for (var p in a) r[r.length] = p; r"); - QStringList lst = qjsvalue_cast(ret); - QCOMPARE(lst.size(), 5); - QCOMPARE(lst.at(0), QString::fromLatin1("0")); - QCOMPARE(lst.at(1), QString::fromLatin1("1")); - QCOMPARE(lst.at(2), QString::fromLatin1("foo")); - QCOMPARE(lst.at(3), QString::fromLatin1("2")); - QCOMPARE(lst.at(4), QString::fromLatin1("bar")); - } -} - -void tst_QJSEngine::jsForInStatement_nullAndUndefined() -{ - QJSEngine eng; - { - QJSValue ret = eng.evaluate("r = true; for (var p in undefined) r = false; r"); - QVERIFY(ret.isBool()); - QVERIFY(ret.toBool()); - } - { - QJSValue ret = eng.evaluate("r = true; for (var p in null) r = false; r"); - QVERIFY(ret.isBool()); - QVERIFY(ret.toBool()); - } -} - -void tst_QJSEngine::jsFunctionDeclarationAsStatement() -{ - // ECMA-262 does not allow function declarations to be used as statements, - // but several popular implementations (including JSC) do. See the NOTE - // at the beginning of chapter 12 in ECMA-262 5th edition, where it's - // recommended that implementations either disallow this usage or issue - // a warning. - // Since we had a bug report long ago about QtScript not supporting this - // "feature" (and thus deviating from other implementations), we still - // check this behavior. - - QJSEngine eng; - QVERIFY(eng.globalObject().property("bar").isUndefined()); - eng.evaluate("function foo(arg) {\n" - " if (arg == 'bar')\n" - " function bar() { return 'bar'; }\n" - " else\n" - " function baz() { return 'baz'; }\n" - " return (arg == 'bar') ? bar : baz;\n" - "}"); - QVERIFY(eng.globalObject().property("bar").isUndefined()); - QVERIFY(eng.globalObject().property("baz").isUndefined()); - QVERIFY(eng.evaluate("foo").isCallable()); - { - QJSValue ret = eng.evaluate("foo('bar')"); - QVERIFY(ret.isCallable()); - QJSValue ret2 = ret.call(); - QCOMPARE(ret2.toString(), QString::fromLatin1("bar")); - QVERIFY(eng.globalObject().property("bar").isUndefined()); - QVERIFY(eng.globalObject().property("baz").isUndefined()); - } - { - QJSValue ret = eng.evaluate("foo('baz')"); - QVERIFY(ret.isCallable()); - QJSValue ret2 = ret.call(); - QCOMPARE(ret2.toString(), QString::fromLatin1("baz")); - QVERIFY(eng.globalObject().property("bar").isUndefined()); - QVERIFY(eng.globalObject().property("baz").isUndefined()); - } -} - -void tst_QJSEngine::stringObjects() -{ - // See ECMA-262 Section 15.5, "String Objects". - - QJSEngine eng; - QString str("ciao"); - // in C++ - { - QJSValue obj = eng.evaluate(QString::fromLatin1("new String('%0')").arg(str)); - QCOMPARE(obj.property("length").toInt(), str.length()); - for (int i = 0; i < str.length(); ++i) { - QString pname = QString::number(i); - QVERIFY(obj.property(pname).isString()); - QCOMPARE(obj.property(pname).toString(), QString(str.at(i))); - QEXPECT_FAIL("", "FIXME: This is V8 issue 862. ECMA script standard 15.5.5.2 compliance.", Continue); - QVERIFY(!obj.deleteProperty(pname)); - obj.setProperty(pname, 123); - QVERIFY(obj.property(pname).isString()); - QCOMPARE(obj.property(pname).toString(), QString(str.at(i))); - } - QVERIFY(obj.property("-1").isUndefined()); - QVERIFY(obj.property(QString::number(str.length())).isUndefined()); - - QJSValue val = eng.toScriptValue(123); - obj.setProperty("-1", val); - QVERIFY(obj.property("-1").strictlyEquals(val)); - obj.setProperty("100", val); - QVERIFY(obj.property("100").strictlyEquals(val)); - } - - { - QJSValue ret = eng.evaluate("s = new String('ciao'); r = []; for (var p in s) r.push(p); r"); - QVERIFY(ret.isArray()); - QStringList lst = qjsvalue_cast(ret); - QCOMPARE(lst.size(), str.length()); - for (int i = 0; i < str.length(); ++i) - QCOMPARE(lst.at(i), QString::number(i)); - - QJSValue ret2 = eng.evaluate("s[0] = 123; s[0]"); - QVERIFY(ret2.isString()); - QCOMPARE(ret2.toString().length(), 1); - QCOMPARE(ret2.toString().at(0), str.at(0)); - - QJSValue ret3 = eng.evaluate("s[-1] = 123; s[-1]"); - QVERIFY(ret3.isNumber()); - QCOMPARE(ret3.toInt(), 123); - - QJSValue ret4 = eng.evaluate("s[s.length] = 456; s[s.length]"); - QVERIFY(ret4.isNumber()); - QCOMPARE(ret4.toInt(), 456); - - QJSValue ret5 = eng.evaluate("delete s[0]"); - QVERIFY(ret5.isBool()); - QEXPECT_FAIL("", "FIXME: This is V8 bug, please report it! ECMA script standard 15.5.5.2", Abort); - QVERIFY(!ret5.toBool()); - - QJSValue ret6 = eng.evaluate("delete s[-1]"); - QVERIFY(ret6.isBool()); - QVERIFY(ret6.toBool()); - - QJSValue ret7 = eng.evaluate("delete s[s.length]"); - QVERIFY(ret7.isBool()); - QVERIFY(ret7.toBool()); - } -} - -void tst_QJSEngine::jsStringPrototypeReplaceBugs() -{ - QJSEngine eng; - // task 212440 - { - QJSValue ret = eng.evaluate("replace_args = []; \"a a a\".replace(/(a)/g, function() { replace_args.push(arguments); }); replace_args"); - QVERIFY(ret.isArray()); - int len = ret.property("length").toInt(); - QCOMPARE(len, 3); - for (int i = 0; i < len; ++i) { - QJSValue args = ret.property(i); - QCOMPARE(args.property("length").toInt(), 4); - QCOMPARE(args.property(0).toString(), QString::fromLatin1("a")); // matched string - QCOMPARE(args.property(1).toString(), QString::fromLatin1("a")); // capture - QVERIFY(args.property(2).isNumber()); - QCOMPARE(args.property(2).toInt(), i*2); // index of match - QCOMPARE(args.property(3).toString(), QString::fromLatin1("a a a")); - } - } - // task 212501 - { - QJSValue ret = eng.evaluate("\"foo\".replace(/a/g, function() {})"); - QVERIFY(ret.isString()); - QCOMPARE(ret.toString(), QString::fromLatin1("foo")); - } -} - -void tst_QJSEngine::getterSetterThisObject_global() -{ - { - QJSEngine eng; - // read - eng.evaluate("__defineGetter__('x', function() { return this; });"); - { - QJSValue ret = eng.evaluate("x"); - QVERIFY(ret.equals(eng.globalObject())); - } - { - QJSValue ret = eng.evaluate("(function() { return x; })()"); - QVERIFY(ret.equals(eng.globalObject())); - } - { - QJSValue ret = eng.evaluate("with (this) x"); - QVERIFY(ret.equals(eng.globalObject())); - } - { - QJSValue ret = eng.evaluate("with ({}) x"); - QVERIFY(ret.equals(eng.globalObject())); - } - { - QJSValue ret = eng.evaluate("(function() { with ({}) return x; })()"); - QVERIFY(ret.equals(eng.globalObject())); - } - // write - eng.evaluate("__defineSetter__('x', function() { return this; });"); - { - QJSValue ret = eng.evaluate("x = 'foo'"); - // SpiderMonkey says setter return value, JSC says RHS. - QVERIFY(ret.isString()); - QCOMPARE(ret.toString(), QString::fromLatin1("foo")); - } - { - QJSValue ret = eng.evaluate("(function() { return x = 'foo'; })()"); - // SpiderMonkey says setter return value, JSC says RHS. - QVERIFY(ret.isString()); - QCOMPARE(ret.toString(), QString::fromLatin1("foo")); - } - { - QJSValue ret = eng.evaluate("with (this) x = 'foo'"); - // SpiderMonkey says setter return value, JSC says RHS. - QVERIFY(ret.isString()); - QCOMPARE(ret.toString(), QString::fromLatin1("foo")); - } - { - QJSValue ret = eng.evaluate("with ({}) x = 'foo'"); - // SpiderMonkey says setter return value, JSC says RHS. - QVERIFY(ret.isString()); - QCOMPARE(ret.toString(), QString::fromLatin1("foo")); - } - { - QJSValue ret = eng.evaluate("(function() { with ({}) return x = 'foo'; })()"); - // SpiderMonkey says setter return value, JSC says RHS. - QVERIFY(ret.isString()); - QCOMPARE(ret.toString(), QString::fromLatin1("foo")); - } - } -} - -void tst_QJSEngine::getterSetterThisObject_plain() -{ - { - QJSEngine eng; - eng.evaluate("o = {}"); - // read - eng.evaluate("o.__defineGetter__('x', function() { return this; })"); - QVERIFY(eng.evaluate("o.x === o").toBool()); - QVERIFY(eng.evaluate("with (o) x").equals(eng.evaluate("o"))); - QVERIFY(eng.evaluate("(function() { with (o) return x; })() === o").toBool()); - eng.evaluate("q = {}; with (o) with (q) x").equals(eng.evaluate("o")); - // write - eng.evaluate("o.__defineSetter__('x', function() { return this; });"); - // SpiderMonkey says setter return value, JSC says RHS. - QVERIFY(eng.evaluate("(o.x = 'foo') === 'foo'").toBool()); - QVERIFY(eng.evaluate("with (o) x = 'foo'").equals("foo")); - QVERIFY(eng.evaluate("with (o) with (q) x = 'foo'").equals("foo")); - } -} - -void tst_QJSEngine::getterSetterThisObject_prototypeChain() -{ - { - QJSEngine eng; - eng.evaluate("o = {}; p = {}; o.__proto__ = p"); - // read - eng.evaluate("p.__defineGetter__('x', function() { return this; })"); - QVERIFY(eng.evaluate("o.x === o").toBool()); - QVERIFY(eng.evaluate("with (o) x").equals(eng.evaluate("o"))); - QVERIFY(eng.evaluate("(function() { with (o) return x; })() === o").toBool()); - eng.evaluate("q = {}; with (o) with (q) x").equals(eng.evaluate("o")); - eng.evaluate("with (q) with (o) x").equals(eng.evaluate("o")); - // write - eng.evaluate("o.__defineSetter__('x', function() { return this; });"); - // SpiderMonkey says setter return value, JSC says RHS. - QVERIFY(eng.evaluate("(o.x = 'foo') === 'foo'").toBool()); - QVERIFY(eng.evaluate("with (o) x = 'foo'").equals("foo")); - QVERIFY(eng.evaluate("with (o) with (q) x = 'foo'").equals("foo")); - } -} - -#if 0 // ###FIXME: no QScriptContext API -void tst_QJSEngine::getterSetterThisObject_activation() -{ - { - QScriptEngine eng; - QScriptContext *ctx = eng.pushContext(); - QVERIFY(ctx != 0); - QScriptValue act = ctx->activationObject(); - act.setProperty("act", act); - // read - eng.evaluate("act.__defineGetter__('x', function() { return this; })"); - QVERIFY(eng.evaluate("x === act").toBool()); - QEXPECT_FAIL("", "QTBUG-17605: Not possible to implement local variables as getter/setter properties", Abort); - QVERIFY(!eng.hasUncaughtException()); - QVERIFY(eng.evaluate("with (act) x").equals("foo")); - QVERIFY(eng.evaluate("(function() { with (act) return x; })() === act").toBool()); - eng.evaluate("q = {}; with (act) with (q) x").equals(eng.evaluate("act")); - eng.evaluate("with (q) with (act) x").equals(eng.evaluate("act")); - // write - eng.evaluate("act.__defineSetter__('x', function() { return this; });"); - QVERIFY(eng.evaluate("(x = 'foo') === 'foo'").toBool()); - QVERIFY(eng.evaluate("with (act) x = 'foo'").equals("foo")); - QVERIFY(eng.evaluate("with (act) with (q) x = 'foo'").equals("foo")); - eng.popContext(); - } -} -#endif - -void tst_QJSEngine::jsContinueInSwitch() -{ - // This is testing ECMA-262 compliance, not C++ API. - - QJSEngine eng; - // switch - continue - { - QJSValue ret = eng.evaluate("switch (1) { default: continue; }"); - QVERIFY(ret.isError()); - } - // for - switch - case - continue - { - QJSValue ret = eng.evaluate("j = 0; for (i = 0; i < 100000; ++i) {\n" - " switch (i) {\n" - " case 1: ++j; continue;\n" - " case 100: ++j; continue;\n" - " case 1000: ++j; continue;\n" - " }\n" - "}; j"); - QVERIFY(ret.isNumber()); - QCOMPARE(ret.toInt(), 3); - } - // for - switch - case - default - continue - { - QJSValue ret = eng.evaluate("j = 0; for (i = 0; i < 100000; ++i) {\n" - " switch (i) {\n" - " case 1: ++j; continue;\n" - " case 100: ++j; continue;\n" - " case 1000: ++j; continue;\n" - " default: if (i < 50000) break; else continue;\n" - " }\n" - "}; j"); - QVERIFY(ret.isNumber()); - QCOMPARE(ret.toInt(), 3); - } - // switch - for - continue - { - QJSValue ret = eng.evaluate("j = 123; switch (j) {\n" - " case 123:\n" - " for (i = 0; i < 100000; ++i) {\n" - " continue;\n" - " }\n" - "}; i\n"); - QVERIFY(ret.isNumber()); - QCOMPARE(ret.toInt(), 100000); - } - // switch - switch - continue - { - QJSValue ret = eng.evaluate("i = 1; switch (i) { default: switch (i) { case 1: continue; } }"); - QVERIFY(ret.isError()); - } - // for - switch - switch - continue - { - QJSValue ret = eng.evaluate("j = 0; for (i = 0; i < 100000; ++i) {\n" - " switch (i) {\n" - " case 1:\n" - " switch (i) {\n" - " case 1: ++j; continue;\n" - " }\n" - " }\n" - "}; j"); - QVERIFY(ret.isNumber()); - QCOMPARE(ret.toInt(), 1); - } - // switch - for - switch - continue - { - QJSValue ret = eng.evaluate("j = 123; switch (j) {\n" - " case 123:\n" - " for (i = 0; i < 100000; ++i) {\n" - " switch (i) {\n" - " case 1:\n" - " ++j; continue;\n" - " }\n" - " }\n" - "}; i\n"); - QVERIFY(ret.isNumber()); - QCOMPARE(ret.toInt(), 100000); - } -} - -void tst_QJSEngine::jsShadowReadOnlyPrototypeProperty() -{ - // SpiderMonkey has different behavior than JSC and V8; it disallows - // creating a property on the instance if there's a property with the - // same name in the prototype, and that property is read-only. We - // adopted that behavior in the old (4.5) QtScript back-end, but it - // just seems weird -- and non-compliant. Adopt the JSC behavior instead. - QJSEngine eng; - QVERIFY(eng.evaluate("o = {}; o.__proto__ = parseInt; o.length").isNumber()); - QCOMPARE(eng.evaluate("o.length = 123; o.length").toInt(), 123); - QVERIFY(eng.evaluate("o.hasOwnProperty('length')").toBool()); -} - -void tst_QJSEngine::jsReservedWords_data() -{ - QTest::addColumn("word"); - QTest::newRow("break") << QString("break"); - QTest::newRow("case") << QString("case"); - QTest::newRow("catch") << QString("catch"); - QTest::newRow("continue") << QString("continue"); - QTest::newRow("default") << QString("default"); - QTest::newRow("delete") << QString("delete"); - QTest::newRow("do") << QString("do"); - QTest::newRow("else") << QString("else"); - QTest::newRow("false") << QString("false"); - QTest::newRow("finally") << QString("finally"); - QTest::newRow("for") << QString("for"); - QTest::newRow("function") << QString("function"); - QTest::newRow("if") << QString("if"); - QTest::newRow("in") << QString("in"); - QTest::newRow("instanceof") << QString("instanceof"); - QTest::newRow("new") << QString("new"); - QTest::newRow("null") << QString("null"); - QTest::newRow("return") << QString("return"); - QTest::newRow("switch") << QString("switch"); - QTest::newRow("this") << QString("this"); - QTest::newRow("throw") << QString("throw"); - QTest::newRow("true") << QString("true"); - QTest::newRow("try") << QString("try"); - QTest::newRow("typeof") << QString("typeof"); - QTest::newRow("var") << QString("var"); - QTest::newRow("void") << QString("void"); - QTest::newRow("while") << QString("while"); - QTest::newRow("with") << QString("with"); -} - -void tst_QJSEngine::jsReservedWords() -{ - // See ECMA-262 Section 7.6.1, "Reserved Words". - // We prefer that the implementation is less strict than the spec; e.g. - // it's good to allow reserved words as identifiers in object literals, - // and when accessing properties using dot notation. - - QFETCH(QString, word); - { - QJSEngine eng; - QJSValue ret = eng.evaluate(word + " = 123"); - QVERIFY(ret.isError()); - QString str = ret.toString(); - QVERIFY(str.startsWith("SyntaxError") || str.startsWith("ReferenceError")); - } - { - QJSEngine eng; - QJSValue ret = eng.evaluate("var " + word + " = 123"); - QVERIFY(ret.isError()); - QVERIFY(ret.toString().startsWith("SyntaxError")); - } - { - QJSEngine eng; - QJSValue ret = eng.evaluate("o = {}; o." + word + " = 123"); - // in the old back-end, in SpiderMonkey and in v8, this is allowed, but not in JSC - QVERIFY(!ret.isError()); - QVERIFY(ret.strictlyEquals(eng.evaluate("o." + word))); - } - { - QJSEngine eng; - QJSValue ret = eng.evaluate("o = { " + word + ": 123 }"); - // in the old back-end, in SpiderMonkey and in v8, this is allowed, but not in JSC - QVERIFY(!ret.isError()); - QVERIFY(ret.property(word).isNumber()); - } - { - // SpiderMonkey allows this, but we don't - QJSEngine eng; - QJSValue ret = eng.evaluate("function " + word + "() {}"); - QVERIFY(ret.isError()); - QVERIFY(ret.toString().startsWith("SyntaxError")); - } -} - -void tst_QJSEngine::jsFutureReservedWords_data() -{ - QTest::addColumn("word"); - QTest::addColumn("allowed"); - QTest::newRow("abstract") << QString("abstract") << true; - QTest::newRow("boolean") << QString("boolean") << true; - QTest::newRow("byte") << QString("byte") << true; - QTest::newRow("char") << QString("char") << true; - QTest::newRow("class") << QString("class") << false; - QTest::newRow("const") << QString("const") << false; - QTest::newRow("debugger") << QString("debugger") << false; - QTest::newRow("double") << QString("double") << true; - QTest::newRow("enum") << QString("enum") << false; - QTest::newRow("export") << QString("export") << false; - QTest::newRow("extends") << QString("extends") << false; - QTest::newRow("final") << QString("final") << true; - QTest::newRow("float") << QString("float") << true; - QTest::newRow("goto") << QString("goto") << true; - QTest::newRow("implements") << QString("implements") << true; - QTest::newRow("import") << QString("import") << false; - QTest::newRow("int") << QString("int") << true; - QTest::newRow("interface") << QString("interface") << true; - QTest::newRow("long") << QString("long") << true; - QTest::newRow("native") << QString("native") << true; - QTest::newRow("package") << QString("package") << true; - QTest::newRow("private") << QString("private") << true; - QTest::newRow("protected") << QString("protected") << true; - QTest::newRow("public") << QString("public") << true; - QTest::newRow("short") << QString("short") << true; - QTest::newRow("static") << QString("static") << true; - QTest::newRow("super") << QString("super") << false; - QTest::newRow("synchronized") << QString("synchronized") << true; - QTest::newRow("throws") << QString("throws") << true; - QTest::newRow("transient") << QString("transient") << true; - QTest::newRow("volatile") << QString("volatile") << true; -} - -void tst_QJSEngine::jsFutureReservedWords() -{ - QSKIP("Fails"); - // See ECMA-262 Section 7.6.1.2, "Future Reserved Words". - // In real-world implementations, most of these words are - // actually allowed as normal identifiers. - - QFETCH(QString, word); - QFETCH(bool, allowed); - { - QJSEngine eng; - QJSValue ret = eng.evaluate(word + " = 123"); - QCOMPARE(!ret.isError(), allowed); - } - { - QJSEngine eng; - QJSValue ret = eng.evaluate("var " + word + " = 123"); - QCOMPARE(!ret.isError(), allowed); - } - { - // this should probably be allowed (see task 162567) - QJSEngine eng; - QJSValue ret = eng.evaluate("o = {}; o." + word + " = 123"); - QCOMPARE(ret.isNumber(), allowed); - QCOMPARE(!ret.isError(), allowed); - } - { - // this should probably be allowed (see task 162567) - QJSEngine eng; - QJSValue ret = eng.evaluate("o = { " + word + ": 123 }"); - QCOMPARE(!ret.isError(), allowed); - } -} - -void tst_QJSEngine::jsThrowInsideWithStatement() -{ - // This is testing ECMA-262 compliance, not C++ API. - - // task 209988 - QJSEngine eng; - { - QJSValue ret = eng.evaluate( - "try {" - " o = { bad : \"bug\" };" - " with (o) {" - " throw 123;" - " }" - "} catch (e) {" - " bad;" - "}"); - QVERIFY(ret.isError()); - QVERIFY(ret.toString().contains(QString::fromLatin1("ReferenceError"))); - } - { - QJSValue ret = eng.evaluate( - "try {" - " o = { bad : \"bug\" };" - " with (o) {" - " throw 123;" - " }" - "} finally {" - " bad;" - "}"); - QVERIFY(ret.isError()); - QVERIFY(ret.toString().contains(QString::fromLatin1("ReferenceError"))); - } - { - eng.clearExceptions(); - QJSValue ret = eng.evaluate( - "o = { bug : \"no bug\" };" - "with (o) {" - " try {" - " throw 123;" - " } finally {" - " bug;" - " }" - "}"); - QVERIFY(ret.isNumber()); - QCOMPARE(ret.toInt(), 123); - QVERIFY(eng.hasUncaughtException()); - } - { - eng.clearExceptions(); - QJSValue ret = eng.evaluate( - "o = { bug : \"no bug\" };" - "with (o) {" - " throw 123;" - "}"); - QVERIFY(ret.isNumber()); - QJSValue ret2 = eng.evaluate("bug"); - QVERIFY(ret2.isError()); - QVERIFY(ret2.toString().contains(QString::fromLatin1("ReferenceError"))); - } -} - -#if 0 // ###FIXME: No QScriptEngineAgent API -class TestAgent : public QScriptEngineAgent -{ -public: - TestAgent(QScriptEngine *engine) : QScriptEngineAgent(engine) {} -}; - -void tst_QJSEngine::getSetAgent_ownership() -{ - // engine deleted before agent --> agent deleted too - QScriptEngine *eng = new QScriptEngine; - QCOMPARE(eng->agent(), (QScriptEngineAgent*)0); - TestAgent *agent = new TestAgent(eng); - eng->setAgent(agent); - QCOMPARE(eng->agent(), (QScriptEngineAgent*)agent); - eng->setAgent(0); // the engine maintains ownership of the old agent - QCOMPARE(eng->agent(), (QScriptEngineAgent*)0); - delete eng; -} - -void tst_QJSEngine::getSetAgent_deleteAgent() -{ - // agent deleted before engine --> engine's agent should become 0 - QScriptEngine *eng = new QScriptEngine; - TestAgent *agent = new TestAgent(eng); - eng->setAgent(agent); - QCOMPARE(eng->agent(), (QScriptEngineAgent*)agent); - delete agent; - QCOMPARE(eng->agent(), (QScriptEngineAgent*)0); - eng->evaluate("(function(){ return 123; })()"); - delete eng; -} - -void tst_QJSEngine::getSetAgent_differentEngine() -{ - QScriptEngine eng; - QScriptEngine eng2; - TestAgent *agent = new TestAgent(&eng); - QTest::ignoreMessage(QtWarningMsg, "QScriptEngine::setAgent(): cannot set agent belonging to different engine"); - eng2.setAgent(agent); - QCOMPARE(eng2.agent(), (QScriptEngineAgent*)0); -} -#endif - -#if 0 // ###FIXME: No QScriptString API -void tst_QJSEngine::reentrancy_stringHandles() -{ - QScriptEngine eng1; - QScriptEngine eng2; - QScriptString s1 = eng1.toStringHandle("foo"); - QScriptString s2 = eng2.toStringHandle("foo"); - QVERIFY(s1 != s2); -} -#endif - -#if 0 // ###FIXME: No processEventsInterval API -void tst_QJSEngine::reentrancy_processEventsInterval() -{ - QScriptEngine eng1; - QScriptEngine eng2; - eng1.setProcessEventsInterval(123); - QCOMPARE(eng2.processEventsInterval(), -1); - eng2.setProcessEventsInterval(456); - QCOMPARE(eng1.processEventsInterval(), 123); -} -#endif - -#if 0 // FIXME: No support for custom types -void tst_QJSEngine::reentrancy_typeConversion() -{ - QScriptEngine eng1; - QScriptEngine eng2; - qScriptRegisterMetaType(&eng1, fooToScriptValue, fooFromScriptValue); - Foo foo; - foo.x = 12; - foo.y = 34; - { - QScriptValue fooVal = qScriptValueFromValue(&eng1, foo); - QVERIFY(fooVal.isObject()); - QVERIFY(!fooVal.isVariant()); - QCOMPARE(fooVal.property("x").toInt(), 12); - QCOMPARE(fooVal.property("y").toInt(), 34); - fooVal.setProperty("x", 56); - fooVal.setProperty("y", 78); - - Foo foo2 = eng.fromScriptValue(fooVal); - QCOMPARE(foo2.x, 56); - QCOMPARE(foo2.y, 78); - } - { - QScriptValue fooVal = qScriptValueFromValue(&eng2, foo); - QVERIFY(fooVal.isVariant()); - - Foo foo2 = eng.fromScriptValue(fooVal); - QCOMPARE(foo2.x, 12); - QCOMPARE(foo2.y, 34); - } - QVERIFY(eng1.defaultPrototype(qMetaTypeId()).isUndefined()); - QVERIFY(eng2.defaultPrototype(qMetaTypeId()).isUndefined()); - QScriptValue proto1 = eng1.newObject(); - eng1.setDefaultPrototype(qMetaTypeId(), proto1); - QVERIFY(eng2.defaultPrototype(qMetaTypeId()).isUndefined()); - QScriptValue proto2 = eng2.newObject(); - eng2.setDefaultPrototype(qMetaTypeId(), proto2); - QVERIFY(!eng2.defaultPrototype(qMetaTypeId()).isUndefined()); - QVERIFY(eng1.defaultPrototype(qMetaTypeId()).strictlyEquals(proto1)); -} -#endif - -void tst_QJSEngine::reentrancy_globalObjectProperties() -{ - QJSEngine eng1; - QJSEngine eng2; - QVERIFY(eng2.globalObject().property("a").isUndefined()); - eng1.evaluate("a = 10"); - QVERIFY(eng1.globalObject().property("a").isNumber()); - QVERIFY(eng2.globalObject().property("a").isUndefined()); - eng2.evaluate("a = 20"); - QVERIFY(eng2.globalObject().property("a").isNumber()); - QCOMPARE(eng1.globalObject().property("a").toInt(), 10); -} - -void tst_QJSEngine::reentrancy_Array() -{ - // weird bug with JSC backend - { - QJSEngine eng; - QCOMPARE(eng.evaluate("Array()").toString(), QString()); - eng.evaluate("Array.prototype.toString"); - QCOMPARE(eng.evaluate("Array()").toString(), QString()); - } - { - QJSEngine eng; - QCOMPARE(eng.evaluate("Array()").toString(), QString()); - } -} - -void tst_QJSEngine::reentrancy_objectCreation() -{ - QJSEngine eng1; - QJSEngine eng2; - { - QDateTime dt = QDateTime::currentDateTime(); - QJSValue d1 = eng1.toScriptValue(dt); - QJSValue d2 = eng2.toScriptValue(dt); - QCOMPARE(d1.toDateTime(), d2.toDateTime()); - QCOMPARE(d2.toDateTime(), d1.toDateTime()); - } - { - QJSValue r1 = eng1.evaluate("new RegExp('foo', 'gim')"); - QJSValue r2 = eng2.evaluate("new RegExp('foo', 'gim')"); - QCOMPARE(qjsvalue_cast(r1), qjsvalue_cast(r2)); - QCOMPARE(qjsvalue_cast(r2), qjsvalue_cast(r1)); - } - { - QJSValue o1 = eng1.newQObject(this); - QJSValue o2 = eng2.newQObject(this); - QCOMPARE(o1.toQObject(), o2.toQObject()); - QCOMPARE(o2.toQObject(), o1.toQObject()); - } -#if 0 // ###FIXME: No QScriptEngine::newQMetaObject API - { - QScriptValue mo1 = eng1.newQMetaObject(&staticMetaObject); - QScriptValue mo2 = eng2.newQMetaObject(&staticMetaObject); - QCOMPARE(mo1.toQMetaObject(), mo2.toQMetaObject()); - QCOMPARE(mo2.toQMetaObject(), mo1.toQMetaObject()); - } -#endif -} - -void tst_QJSEngine::jsIncDecNonObjectProperty() -{ - // This is testing ECMA-262 compliance, not C++ API. - - QJSEngine eng; - { - QJSValue ret = eng.evaluate("var a; a.n++"); - QVERIFY(ret.isError()); - QVERIFY(ret.toString().contains(QString::fromLatin1("TypeError"))); - } - { - QJSValue ret = eng.evaluate("var a; a.n--"); - QVERIFY(ret.isError()); - QVERIFY(ret.toString().contains(QString::fromLatin1("TypeError"))); - } - { - QJSValue ret = eng.evaluate("var a = null; a.n++"); - QVERIFY(ret.isError()); - QVERIFY(ret.toString().contains(QString::fromLatin1("TypeError"))); - } - { - QJSValue ret = eng.evaluate("var a = null; a.n--"); - QVERIFY(ret.isError()); - QVERIFY(ret.toString().contains(QString::fromLatin1("TypeError"))); - } - { - QJSValue ret = eng.evaluate("var a; ++a.n"); - QVERIFY(ret.isError()); - QVERIFY(ret.toString().contains(QString::fromLatin1("TypeError"))); - } - { - QJSValue ret = eng.evaluate("var a; --a.n"); - QVERIFY(ret.isError()); - QVERIFY(ret.toString().contains(QString::fromLatin1("TypeError"))); - } - { - QJSValue ret = eng.evaluate("var a; a.n += 1"); - QVERIFY(ret.isError()); - QVERIFY(ret.toString().contains(QString::fromLatin1("TypeError"))); - } - { - QJSValue ret = eng.evaluate("var a; a.n -= 1"); - QVERIFY(ret.isError()); - QVERIFY(ret.toString().contains(QString::fromLatin1("TypeError"))); - } - { - QJSValue ret = eng.evaluate("var a = 'ciao'; a.length++"); - QVERIFY(ret.isNumber()); - QCOMPARE(ret.toInt(), 4); - } - { - QJSValue ret = eng.evaluate("var a = 'ciao'; a.length--"); - QVERIFY(ret.isNumber()); - QCOMPARE(ret.toInt(), 4); - } - { - QJSValue ret = eng.evaluate("var a = 'ciao'; ++a.length"); - QVERIFY(ret.isNumber()); - QCOMPARE(ret.toInt(), 5); - } - { - QJSValue ret = eng.evaluate("var a = 'ciao'; --a.length"); - QVERIFY(ret.isNumber()); - QCOMPARE(ret.toInt(), 3); - } -} - -#if 0 // ###FIXME: no installTranslatorFunctions API -void tst_QJSEngine::installTranslatorFunctions() -{ - QScriptEngine eng; - QScriptValue global = eng.globalObject(); - QVERIFY(global.property("qsTranslate").isUndefined()); - QVERIFY(global.property("QT_TRANSLATE_NOOP").isUndefined()); - QVERIFY(global.property("qsTr").isUndefined()); - QVERIFY(global.property("QT_TR_NOOP").isUndefined()); - QVERIFY(global.property("qsTrId").isUndefined()); - QVERIFY(global.property("QT_TRID_NOOP").isUndefined()); - QVERIFY(global.property("String").property("prototype").property("arg").isUndefined()); - - eng.installTranslatorFunctions(); - QVERIFY(global.property("qsTranslate").isCallable()); - QVERIFY(global.property("QT_TRANSLATE_NOOP").isCallable()); - QVERIFY(global.property("qsTr").isCallable()); - QVERIFY(global.property("QT_TR_NOOP").isCallable()); - QVERIFY(global.property("qsTrId").isCallable()); - QVERIFY(global.property("QT_TRID_NOOP").isCallable()); - QVERIFY(global.property("String").property("prototype").property("arg").isCallable()); - - { - QScriptValue ret = eng.evaluate("qsTr('foo')"); - QVERIFY(ret.isString()); - QCOMPARE(ret.toString(), QString::fromLatin1("foo")); - } - { - QScriptValue ret = eng.evaluate("qsTranslate('foo', 'bar')"); - QVERIFY(ret.isString()); - QCOMPARE(ret.toString(), QString::fromLatin1("bar")); - } - { - QScriptValue ret = eng.evaluate("QT_TR_NOOP('foo')"); - QVERIFY(ret.isString()); - QCOMPARE(ret.toString(), QString::fromLatin1("foo")); - } - { - QScriptValue ret = eng.evaluate("QT_TRANSLATE_NOOP('foo', 'bar')"); - QVERIFY(ret.isString()); - QCOMPARE(ret.toString(), QString::fromLatin1("bar")); - } - { - QScriptValue ret = eng.evaluate("'foo%0'.arg('bar')"); - QEXPECT_FAIL("Custom global object", "FIXME: why we expect that String prototype exists?", Abort); - QVERIFY(ret.isString()); - QCOMPARE(ret.toString(), QString::fromLatin1("foobar")); - } - { - QScriptValue ret = eng.evaluate("'foo%0'.arg(123)"); - QVERIFY(ret.isString()); - QCOMPARE(ret.toString(), QString::fromLatin1("foo123")); - } - { - // Maybe this should throw an error? - QScriptValue ret = eng.evaluate("'foo%0'.arg()"); - QVERIFY(ret.isString()); - QCOMPARE(ret.toString(), QString()); - } - - { - QScriptValue ret = eng.evaluate("qsTrId('foo')"); - QVERIFY(ret.isString()); - QCOMPARE(ret.toString(), QString::fromLatin1("foo")); - } - { - QScriptValue ret = eng.evaluate("QT_TRID_NOOP('foo')"); - QVERIFY(ret.isString()); - QCOMPARE(ret.toString(), QString::fromLatin1("foo")); - } - QVERIFY(eng.evaluate("QT_TRID_NOOP()").isUndefined()); -} - -class TranslationScope -{ -public: - TranslationScope(const QString &fileName) - { - translator.load(fileName); - QCoreApplication::instance()->installTranslator(&translator); - } - ~TranslationScope() - { - QCoreApplication::instance()->removeTranslator(&translator); - } - -private: - QTranslator translator; -}; - -void tst_QJSEngine::translateScript_data() -{ - QTest::addColumn("expression"); - QTest::addColumn("fileName"); - QTest::addColumn("expectedTranslation"); - - QString fileName = QString::fromLatin1("translatable.js"); - // Top-level - QTest::newRow("qsTr('One')@translatable.js") - << QString::fromLatin1("qsTr('One')") << fileName << QString::fromLatin1("En"); - QTest::newRow("qsTr('Hello')@translatable.js") - << QString::fromLatin1("qsTr('Hello')") << fileName << QString::fromLatin1("Hallo"); - // From function - QTest::newRow("(function() { return qsTr('One'); })()@translatable.js") - << QString::fromLatin1("(function() { return qsTr('One'); })()") << fileName << QString::fromLatin1("En"); - QTest::newRow("(function() { return qsTr('Hello'); })()@translatable.js") - << QString::fromLatin1("(function() { return qsTr('Hello'); })()") << fileName << QString::fromLatin1("Hallo"); - // From eval - QTest::newRow("eval('qsTr(\\'One\\')')@translatable.js") - << QString::fromLatin1("eval('qsTr(\\'One\\')')") << fileName << QString::fromLatin1("En"); - QTest::newRow("eval('qsTr(\\'Hello\\')')@translatable.js") - << QString::fromLatin1("eval('qsTr(\\'Hello\\')')") << fileName << QString::fromLatin1("Hallo"); - // Plural - QTest::newRow("qsTr('%n message(s) saved', '', 1)@translatable.js") - << QString::fromLatin1("qsTr('%n message(s) saved', '', 1)") << fileName << QString::fromLatin1("1 melding lagret"); - QTest::newRow("qsTr('%n message(s) saved', '', 3).arg@translatable.js") - << QString::fromLatin1("qsTr('%n message(s) saved', '', 3)") << fileName << QString::fromLatin1("3 meldinger lagret"); - - // Top-level - QTest::newRow("qsTranslate('FooContext', 'Two')@translatable.js") - << QString::fromLatin1("qsTranslate('FooContext', 'Two')") << fileName << QString::fromLatin1("To"); - QTest::newRow("qsTranslate('FooContext', 'Goodbye')@translatable.js") - << QString::fromLatin1("qsTranslate('FooContext', 'Goodbye')") << fileName << QString::fromLatin1("Farvel"); - // From eval - QTest::newRow("eval('qsTranslate(\\'FooContext\\', \\'Two\\')')@translatable.js") - << QString::fromLatin1("eval('qsTranslate(\\'FooContext\\', \\'Two\\')')") << fileName << QString::fromLatin1("To"); - QTest::newRow("eval('qsTranslate(\\'FooContext\\', \\'Goodbye\\')')@translatable.js") - << QString::fromLatin1("eval('qsTranslate(\\'FooContext\\', \\'Goodbye\\')')") << fileName << QString::fromLatin1("Farvel"); - - QTest::newRow("qsTranslate('FooContext', 'Goodbye', '', 'UnicodeUTF8')@translatable.js") - << QString::fromLatin1("qsTranslate('FooContext', 'Goodbye', '', 'UnicodeUTF8')") << fileName << QString::fromLatin1("Farvel"); - QTest::newRow("qsTranslate('FooContext', 'Goodbye', '', 'CodecForTr')@translatable.js") - << QString::fromLatin1("qsTranslate('FooContext', 'Goodbye', '', 'CodecForTr')") << fileName << QString::fromLatin1("Farvel"); - - QTest::newRow("qsTranslate('FooContext', 'Goodbye', '', 'UnicodeUTF8', 42)@translatable.js") - << QString::fromLatin1("qsTranslate('FooContext', 'Goodbye', '', 'UnicodeUTF8', 42)") << fileName << QString::fromLatin1("Goodbye"); - - QTest::newRow("qsTr('One', 'not the same one')@translatable.js") - << QString::fromLatin1("qsTr('One', 'not the same one')") << fileName << QString::fromLatin1("Enda en"); - - QTest::newRow("qsTr('One', 'not the same one', 42)@translatable.js") - << QString::fromLatin1("qsTr('One', 'not the same one', 42)") << fileName << QString::fromLatin1("One"); - - // Plural - QTest::newRow("qsTranslate('FooContext', '%n fooish bar(s) found', '', 'UnicodeUTF8', 1)@translatable.js") - << QString::fromLatin1("qsTranslate('FooContext', '%n fooish bar(s) found', '', 'UnicodeUTF8', 1)") << fileName << QString::fromLatin1("1 fooaktig bar funnet"); - QTest::newRow("qsTranslate('FooContext', '%n fooish bar(s) found', '', 'UnicodeUTF8', 2)@translatable.js") - << QString::fromLatin1("qsTranslate('FooContext', '%n fooish bar(s) found', '', 'UnicodeUTF8', 2)") << fileName << QString::fromLatin1("2 fooaktige barer funnet"); - - // Don't exist in translation - QTest::newRow("qsTr('Three')@translatable.js") - << QString::fromLatin1("qsTr('Three')") << fileName << QString::fromLatin1("Three"); - QTest::newRow("qsTranslate('FooContext', 'So long')@translatable.js") - << QString::fromLatin1("qsTranslate('FooContext', 'So long')") << fileName << QString::fromLatin1("So long"); - QTest::newRow("qsTranslate('BarContext', 'Goodbye')@translatable.js") - << QString::fromLatin1("qsTranslate('BarContext', 'Goodbye')") << fileName << QString::fromLatin1("Goodbye"); - - // Translate strings from the second script (translatable2.js) - - QString fileName2 = QString::fromLatin1("translatable2.js"); - QTest::newRow("qsTr('Three')@translatable2.js") - << QString::fromLatin1("qsTr('Three')") << fileName2 << QString::fromLatin1("Tre"); - QTest::newRow("qsTr('Happy birthday!')@translatable2.js") - << QString::fromLatin1("qsTr('Happy birthday!')") << fileName2 << QString::fromLatin1("Gratulerer med dagen!"); - - // Not translated because translation is only in translatable.js - QTest::newRow("qsTr('One')@translatable2.js") - << QString::fromLatin1("qsTr('One')") << fileName2 << QString::fromLatin1("One"); - QTest::newRow("(function() { return qsTr('One'); })()@translatable2.js") - << QString::fromLatin1("(function() { return qsTr('One'); })()") << fileName2 << QString::fromLatin1("One"); - - // For qsTranslate() the filename shouldn't matter - QTest::newRow("qsTranslate('FooContext', 'Two')@translatable2.js") - << QString::fromLatin1("qsTranslate('FooContext', 'Two')") << fileName2 << QString::fromLatin1("To"); - QTest::newRow("qsTranslate('BarContext', 'Congratulations!')@translatable.js") - << QString::fromLatin1("qsTranslate('BarContext', 'Congratulations!')") << fileName << QString::fromLatin1("Gratulerer!"); -} - -void tst_QJSEngine::translateScript() -{ - QFETCH(QString, expression); - QFETCH(QString, fileName); - QFETCH(QString, expectedTranslation); - - QScriptEngine engine; - - TranslationScope tranScope(":/translations/translatable_la"); - engine.installTranslatorFunctions(); - - QCOMPARE(engine.evaluate(expression, fileName).toString(), expectedTranslation); - QVERIFY(!engine.hasUncaughtException()); -} - -void tst_QJSEngine::translateScript_crossScript() -{ - QScriptEngine engine; - TranslationScope tranScope(":/translations/translatable_la"); - engine.installTranslatorFunctions(); - - QString fileName = QString::fromLatin1("translatable.js"); - QString fileName2 = QString::fromLatin1("translatable2.js"); - // qsTr() should use the innermost filename as context - engine.evaluate("function foo(s) { return bar(s); }", fileName); - engine.evaluate("function bar(s) { return qsTr(s); }", fileName2); - QCOMPARE(engine.evaluate("bar('Three')", fileName2).toString(), QString::fromLatin1("Tre")); - QCOMPARE(engine.evaluate("bar('Three')", fileName).toString(), QString::fromLatin1("Tre")); - QCOMPARE(engine.evaluate("bar('One')", fileName2).toString(), QString::fromLatin1("One")); - - engine.evaluate("function foo(s) { return bar(s); }", fileName2); - engine.evaluate("function bar(s) { return qsTr(s); }", fileName); - QCOMPARE(engine.evaluate("bar('Three')", fileName2).toString(), QString::fromLatin1("Three")); - QCOMPARE(engine.evaluate("bar('One')", fileName).toString(), QString::fromLatin1("En")); - QCOMPARE(engine.evaluate("bar('One')", fileName2).toString(), QString::fromLatin1("En")); -} - -static QScriptValue callQsTr(QScriptContext *ctx, QScriptEngine *eng) -{ - return eng->globalObject().property("qsTr").callWithInstance(ctx->thisObject(), ctx->argumentsObject()); -} - -void tst_QJSEngine::translateScript_callQsTrFromNative() -{ - QScriptEngine engine; - TranslationScope tranScope(":/translations/translatable_la"); - engine.installTranslatorFunctions(); - - QString fileName = QString::fromLatin1("translatable.js"); - QString fileName2 = QString::fromLatin1("translatable2.js"); - // Calling qsTr() from a native function - engine.globalObject().setProperty("qsTrProxy", engine.newFunction(callQsTr)); - QCOMPARE(engine.evaluate("qsTrProxy('One')", fileName).toString(), QString::fromLatin1("En")); - QCOMPARE(engine.evaluate("qsTrProxy('One')", fileName2).toString(), QString::fromLatin1("One")); - QCOMPARE(engine.evaluate("qsTrProxy('Three')", fileName).toString(), QString::fromLatin1("Three")); - QCOMPARE(engine.evaluate("qsTrProxy('Three')", fileName2).toString(), QString::fromLatin1("Tre")); -} - -void tst_QJSEngine::translateScript_trNoOp() -{ - QScriptEngine engine; - TranslationScope tranScope(":/translations/translatable_la"); - engine.installTranslatorFunctions(); - - QVERIFY(engine.evaluate("QT_TR_NOOP()").isUndefined()); - QCOMPARE(engine.evaluate("QT_TR_NOOP('One')").toString(), QString::fromLatin1("One")); - - QVERIFY(engine.evaluate("QT_TRANSLATE_NOOP()").isUndefined()); - QVERIFY(engine.evaluate("QT_TRANSLATE_NOOP('FooContext')").isUndefined()); - QCOMPARE(engine.evaluate("QT_TRANSLATE_NOOP('FooContext', 'Two')").toString(), QString::fromLatin1("Two")); -} - -void tst_QJSEngine::translateScript_callQsTrFromCpp() -{ - QScriptEngine engine; - TranslationScope tranScope(":/translations/translatable_la"); - engine.installTranslatorFunctions(); - - // There is no context, but it shouldn't crash - QCOMPARE(engine.globalObject().property("qsTr").call( - QScriptValueList() << "One").toString(), QString::fromLatin1("One")); -} - -void tst_QJSEngine::translateWithInvalidArgs_data() -{ - QTest::addColumn("expression"); - QTest::addColumn("expectedError"); - - QTest::newRow("qsTr()") << "qsTr()" << "Error: qsTr() requires at least one argument"; - QTest::newRow("qsTr(123)") << "qsTr(123)" << "Error: qsTr(): first argument (text) must be a string"; - QTest::newRow("qsTr('foo', 123)") << "qsTr('foo', 123)" << "Error: qsTr(): second argument (comment) must be a string"; - QTest::newRow("qsTr('foo', 'bar', 'baz')") << "qsTr('foo', 'bar', 'baz')" << "Error: qsTr(): third argument (n) must be a number"; - QTest::newRow("qsTr('foo', 'bar', true)") << "qsTr('foo', 'bar', true)" << "Error: qsTr(): third argument (n) must be a number"; - - QTest::newRow("qsTranslate()") << "qsTranslate()" << "Error: qsTranslate() requires at least two arguments"; - QTest::newRow("qsTranslate('foo')") << "qsTranslate('foo')" << "Error: qsTranslate() requires at least two arguments"; - QTest::newRow("qsTranslate(123, 'foo')") << "qsTranslate(123, 'foo')" << "Error: qsTranslate(): first argument (context) must be a string"; - QTest::newRow("qsTranslate('foo', 123)") << "qsTranslate('foo', 123)" << "Error: qsTranslate(): second argument (text) must be a string"; - QTest::newRow("qsTranslate('foo', 'bar', 123)") << "qsTranslate('foo', 'bar', 123)" << "Error: qsTranslate(): third argument (comment) must be a string"; - QTest::newRow("qsTranslate('foo', 'bar', 'baz', 123)") << "qsTranslate('foo', 'bar', 'baz', 123)" << "Error: qsTranslate(): fourth argument (encoding) must be a string"; - QTest::newRow("qsTranslate('foo', 'bar', 'baz', 'zab', 'rab')") << "qsTranslate('foo', 'bar', 'baz', 'zab', 'rab')" << "Error: qsTranslate(): fifth argument (n) must be a number"; - QTest::newRow("qsTranslate('foo', 'bar', 'baz', 'zab', 123)") << "qsTranslate('foo', 'bar', 'baz', 'zab', 123)" << "Error: qsTranslate(): invalid encoding 'zab'"; - - QTest::newRow("qsTrId()") << "qsTrId()" << "Error: qsTrId() requires at least one argument"; - QTest::newRow("qsTrId(123)") << "qsTrId(123)" << "TypeError: qsTrId(): first argument (id) must be a string"; - QTest::newRow("qsTrId('foo', 'bar')") << "qsTrId('foo', 'bar')" << "TypeError: qsTrId(): second argument (n) must be a number"; -} - -void tst_QJSEngine::translateWithInvalidArgs() -{ - QFETCH(QString, expression); - QFETCH(QString, expectedError); - QScriptEngine engine; - engine.installTranslatorFunctions(); - QScriptValue result = engine.evaluate(expression); - QVERIFY(result.isError()); - QCOMPARE(result.toString(), expectedError); -} - -void tst_QJSEngine::translationContext_data() -{ - QTest::addColumn("path"); - QTest::addColumn("text"); - QTest::addColumn("expectedTranslation"); - - QTest::newRow("translatable.js") << "translatable.js" << "One" << "En"; - QTest::newRow("/translatable.js") << "/translatable.js" << "One" << "En"; - QTest::newRow("/foo/translatable.js") << "/foo/translatable.js" << "One" << "En"; - QTest::newRow("/foo/bar/translatable.js") << "/foo/bar/translatable.js" << "One" << "En"; - QTest::newRow("./translatable.js") << "./translatable.js" << "One" << "En"; - QTest::newRow("../translatable.js") << "../translatable.js" << "One" << "En"; - QTest::newRow("foo/translatable.js") << "foo/translatable.js" << "One" << "En"; - QTest::newRow("file:///home/qt/translatable.js") << "file:///home/qt/translatable.js" << "One" << "En"; - QTest::newRow(":/resources/translatable.js") << ":/resources/translatable.js" << "One" << "En"; - QTest::newRow("/translatable.js.foo") << "/translatable.js.foo" << "One" << "En"; - QTest::newRow("/translatable.txt") << "/translatable.txt" << "One" << "En"; - QTest::newRow("translatable") << "translatable" << "One" << "En"; - QTest::newRow("foo/translatable") << "foo/translatable" << "One" << "En"; - - QTest::newRow("native separators") - << (QDir::toNativeSeparators(QDir::currentPath()) + QDir::separator() + "translatable.js") - << "One" << "En"; - - QTest::newRow("translatable.js/") << "translatable.js/" << "One" << "One"; - QTest::newRow("nosuchscript.js") << "" << "One" << "One"; - QTest::newRow("(empty)") << "" << "One" << "One"; -} - -void tst_QJSEngine::translationContext() -{ - TranslationScope tranScope(":/translations/translatable_la"); - - QScriptEngine engine; - engine.installTranslatorFunctions(); - - QFETCH(QString, path); - QFETCH(QString, text); - QFETCH(QString, expectedTranslation); - QScriptValue ret = engine.evaluate(QString::fromLatin1("qsTr('%0')").arg(text), path); - QVERIFY(ret.isString()); - QCOMPARE(ret.toString(), expectedTranslation); -} - -void tst_QJSEngine::translateScriptIdBased() -{ - QScriptEngine engine; - - TranslationScope tranScope(":/translations/idtranslatable_la"); - engine.installTranslatorFunctions(); - - QString fileName = QString::fromLatin1("idtranslatable.js"); - - QHash expectedTranslations; - expectedTranslations["qtn_foo_bar"] = "First string"; - expectedTranslations["qtn_needle"] = "Second string"; - expectedTranslations["qtn_haystack"] = "Third string"; - expectedTranslations["qtn_bar_baz"] = "Fourth string"; - - QHash::const_iterator it; - for (it = expectedTranslations.constBegin(); it != expectedTranslations.constEnd(); ++it) { - for (int x = 0; x < 2; ++x) { - QString fn; - if (x) - fn = fileName; - // Top-level - QCOMPARE(engine.evaluate(QString::fromLatin1("qsTrId('%0')") - .arg(it.key()), fn).toString(), - it.value()); - QCOMPARE(engine.evaluate(QString::fromLatin1("QT_TRID_NOOP('%0')") - .arg(it.key()), fn).toString(), - it.key()); - // From function - QCOMPARE(engine.evaluate(QString::fromLatin1("(function() { return qsTrId('%0'); })()") - .arg(it.key()), fn).toString(), - it.value()); - QCOMPARE(engine.evaluate(QString::fromLatin1("(function() { return QT_TRID_NOOP('%0'); })()") - .arg(it.key()), fn).toString(), - it.key()); - } - } - - // Plural form - QCOMPARE(engine.evaluate("qsTrId('qtn_bar_baz', 10)").toString(), - QString::fromLatin1("10 fooish bar(s) found")); - QCOMPARE(engine.evaluate("qsTrId('qtn_foo_bar', 10)").toString(), - QString::fromLatin1("qtn_foo_bar")); // Doesn't have plural -} - -// How to add a new test row: -// - Find a nice list of Unicode characters to choose from -// - Write source string/context/comment in .js using Unicode escape sequences (\uABCD) -// - Update corresponding .ts file (e.g. lupdate foo.js -ts foo.ts -codecfortr UTF-8) -// - Enter translation in Linguist -// - Update corresponding .qm file (e.g. lrelease foo.ts) -// - Evaluate script that performs translation; make sure the correct result is returned -// (e.g. by setting the resulting string as the text of a QLabel and visually verifying -// that it looks the same as what you entered in Linguist :-) ) -// - Generate the expectedTranslation column data using toUtf8().toHex() -void tst_QJSEngine::translateScriptUnicode_data() -{ - QTest::addColumn("expression"); - QTest::addColumn("fileName"); - QTest::addColumn("expectedTranslation"); - - QString fileName = QString::fromLatin1("translatable-unicode.js"); - QTest::newRow("qsTr('H\\u2082O')@translatable-unicode.js") - << QString::fromLatin1("qsTr('H\\u2082O')") << fileName << QString::fromUtf8("\xcd\xbb\xcd\xbc\xcd\xbd"); - QTest::newRow("qsTranslate('\\u010C\\u0101\\u011F\\u0115', 'CO\\u2082')@translatable-unicode.js") - << QString::fromLatin1("qsTranslate('\\u010C\\u0101\\u011F\\u0115', 'CO\\u2082')") << fileName << QString::fromUtf8("\xd7\x91\xd7\x9a\xd7\xa2"); - QTest::newRow("qsTr('\\u0391\\u0392\\u0393')@translatable-unicode.js") - << QString::fromLatin1("qsTr('\\u0391\\u0392\\u0393')") << fileName << QString::fromUtf8("\xd3\x9c\xd2\xb4\xd1\xbc"); - QTest::newRow("qsTranslate('\\u010C\\u0101\\u011F\\u0115', '\\u0414\\u0415\\u0416')@translatable-unicode.js") - << QString::fromLatin1("qsTranslate('\\u010C\\u0101\\u011F\\u0115', '\\u0414\\u0415\\u0416')") << fileName << QString::fromUtf8("\xd8\xae\xd8\xb3\xd8\xb3"); - QTest::newRow("qsTr('H\\u2082O', 'not the same H\\u2082O')@translatable-unicode.js") - << QString::fromLatin1("qsTr('H\\u2082O', 'not the same H\\u2082O')") << fileName << QString::fromUtf8("\xd4\xb6\xd5\x8a\xd5\x92"); - QTest::newRow("qsTr('H\\u2082O')") - << QString::fromLatin1("qsTr('H\\u2082O')") << QString() << QString::fromUtf8("\x48\xe2\x82\x82\x4f"); - QTest::newRow("qsTranslate('\\u010C\\u0101\\u011F\\u0115', 'CO\\u2082')") - << QString::fromLatin1("qsTranslate('\\u010C\\u0101\\u011F\\u0115', 'CO\\u2082')") << QString() << QString::fromUtf8("\xd7\x91\xd7\x9a\xd7\xa2"); -} - -void tst_QJSEngine::translateScriptUnicode() -{ - QFETCH(QString, expression); - QFETCH(QString, fileName); - QFETCH(QString, expectedTranslation); - - QScriptEngine engine; - - TranslationScope tranScope(":/translations/translatable-unicode"); - engine.installTranslatorFunctions(); - - QCOMPARE(engine.evaluate(expression, fileName).toString(), expectedTranslation); - QVERIFY(!engine.hasUncaughtException()); -} - -void tst_QJSEngine::translateScriptUnicodeIdBased_data() -{ - QTest::addColumn("expression"); - QTest::addColumn("expectedTranslation"); - - QTest::newRow("qsTrId('\\u01F8\\u01D2\\u0199\\u01D0\\u01E1'')") - << QString::fromLatin1("qsTrId('\\u01F8\\u01D2\\u0199\\u01D0\\u01E1')") << QString::fromUtf8("\xc6\xa7\xc6\xb0\xc6\x88\xc8\xbc\xc8\x9d\xc8\xbf\xc8\x99"); - QTest::newRow("qsTrId('\\u0191\\u01CE\\u0211\\u0229\\u019C\\u018E\\u019A\\u01D0')") - << QString::fromLatin1("qsTrId('\\u0191\\u01CE\\u0211\\u0229\\u019C\\u018E\\u019A\\u01D0')") << QString::fromUtf8("\xc7\xa0\xc8\xa1\xc8\x8b\xc8\x85\xc8\x95"); - QTest::newRow("qsTrId('\\u0181\\u01A1\\u0213\\u018F\\u018C', 10)") - << QString::fromLatin1("qsTrId('\\u0181\\u01A1\\u0213\\u018F\\u018C', 10)") << QString::fromUtf8("\x31\x30\x20\xc6\x92\xc6\xa1\xc7\x92\x28\xc8\x99\x29"); - QTest::newRow("qsTrId('\\u0181\\u01A1\\u0213\\u018F\\u018C')") - << QString::fromLatin1("qsTrId('\\u0181\\u01A1\\u0213\\u018F\\u018C')") << QString::fromUtf8("\xc6\x91\xc6\xb0\xc7\xb9"); - QTest::newRow("qsTrId('\\u01CD\\u0180\\u01A8\\u0190\\u019E\\u01AB')") - << QString::fromLatin1("qsTrId('\\u01CD\\u0180\\u01A8\\u0190\\u019E\\u01AB')") << QString::fromUtf8("\xc7\x8d\xc6\x80\xc6\xa8\xc6\x90\xc6\x9e\xc6\xab"); -} - -void tst_QJSEngine::translateScriptUnicodeIdBased() -{ - QFETCH(QString, expression); - QFETCH(QString, expectedTranslation); - - QScriptEngine engine; - - TranslationScope tranScope(":/translations/idtranslatable-unicode"); - engine.installTranslatorFunctions(); - - QCOMPARE(engine.evaluate(expression).toString(), expectedTranslation); - QVERIFY(!engine.hasUncaughtException()); -} - -void tst_QJSEngine::translateFromBuiltinCallback() -{ - QScriptEngine eng; - eng.installTranslatorFunctions(); - - // Callback has no translation context. - eng.evaluate("function foo() { qsTr('foo'); }"); - - // Stack at translation time will be: - // qsTr, foo, forEach, global - // qsTr() needs to walk to the outer-most (global) frame before it finds - // a translation context, and this should not crash. - eng.evaluate("[10,20].forEach(foo)", "script.js"); -} -#endif - -#if 0 // ###FIXME: No QScriptValue::scope API -void tst_QJSEngine::functionScopes() -{ - QScriptEngine eng; - { - // top-level functions have only the global object in their scope - QScriptValue fun = eng.evaluate("(function() {})"); - QVERIFY(fun.isCallable()); - QEXPECT_FAIL("", "QScriptValue::scope() is internal, not implemented", Abort); - QVERIFY(fun.scope().isObject()); - QVERIFY(fun.scope().strictlyEquals(eng.globalObject())); - QVERIFY(eng.globalObject().scope().isUndefined()); - } - { - QScriptValue fun = eng.globalObject().property("Object"); - QVERIFY(fun.isCallable()); - // native built-in functions don't have scope - QVERIFY(fun.scope().isUndefined()); - } - { - // closure - QScriptValue fun = eng.evaluate("(function(arg) { var foo = arg; return function() { return foo; }; })(123)"); - QVERIFY(fun.isCallable()); - { - QScriptValue ret = fun.call(); - QVERIFY(ret.isNumber()); - QCOMPARE(ret.toInt(), 123); - } - QScriptValue scope = fun.scope(); - QVERIFY(scope.isObject()); - { - QScriptValue ret = scope.property("foo"); - QVERIFY(ret.isNumber()); - QCOMPARE(ret.toInt(), 123); - } - { - QScriptValue ret = scope.property("arg"); - QVERIFY(ret.isNumber()); - QCOMPARE(ret.toInt(), 123); - } - - scope.setProperty("foo", 456); - { - QScriptValue ret = fun.call(); - QVERIFY(ret.isNumber()); - QCOMPARE(ret.toInt(), 456); - } - - scope = scope.scope(); - QVERIFY(scope.isObject()); - QVERIFY(scope.strictlyEquals(eng.globalObject())); - } -} -#endif - -#if 0 // ###FIXME: No QScriptContext API -static QScriptValue counter_inner(QScriptContext *ctx, QScriptEngine *) -{ - QScriptValue outerAct = ctx->callee().scope(); - double count = outerAct.property("count").toNumber(); - outerAct.setProperty("count", count+1); - return count; -} - -static QScriptValue counter(QScriptContext *ctx, QScriptEngine *eng) -{ - QScriptValue act = ctx->activationObject(); - act.setProperty("count", ctx->argument(0).toInt()); - QScriptValue result = eng->newFunction(counter_inner); - result.setScope(act); - return result; -} - -static QScriptValue counter_hybrid(QScriptContext *ctx, QScriptEngine *eng) -{ - QScriptValue act = ctx->activationObject(); - act.setProperty("count", ctx->argument(0).toInt()); - return eng->evaluate("(function() { return count++; })"); -} - -void tst_QJSEngine::nativeFunctionScopes() -{ - QScriptEngine eng; - { - QScriptValue fun = eng.newFunction(counter); - QScriptValue cnt = fun.call(QScriptValueList() << 123); - QVERIFY(cnt.isCallable()); - { - QScriptValue ret = cnt.call(); - QVERIFY(ret.isNumber()); - QEXPECT_FAIL("", "QScriptValue::setScope not implemented", Continue); - QCOMPARE(ret.toInt(), 123); - } - } - { - QScriptValue fun = eng.newFunction(counter_hybrid); - QScriptValue cnt = fun.call(QScriptValueList() << 123); - QVERIFY(cnt.isCallable()); - { - QScriptValue ret = cnt.call(); - QVERIFY(ret.isNumber()); - QCOMPARE(ret.toInt(), 123); - } - } - - //from http://doc.trolltech.com/latest/qtscript.html#nested-functions-and-the-scope-chain - { - QScriptEngine eng; - eng.evaluate("function counter() { var count = 0; return function() { return count++; } }\n" - "var c1 = counter(); var c2 = counter(); "); - QCOMPARE(eng.evaluate("c1()").toString(), QString::fromLatin1("0")); - QCOMPARE(eng.evaluate("c1()").toString(), QString::fromLatin1("1")); - QCOMPARE(eng.evaluate("c2()").toString(), QString::fromLatin1("0")); - QCOMPARE(eng.evaluate("c2()").toString(), QString::fromLatin1("1")); - QVERIFY(!eng.hasUncaughtException()); - } - { - QScriptEngine eng; - eng.globalObject().setProperty("counter", eng.newFunction(counter)); - eng.evaluate("var c1 = counter(); var c2 = counter(); "); - QCOMPARE(eng.evaluate("c1()").toString(), QString::fromLatin1("0")); - QEXPECT_FAIL("", "QScriptValue::setScope not implemented", Continue); - QCOMPARE(eng.evaluate("c1()").toString(), QString::fromLatin1("1")); - QCOMPARE(eng.evaluate("c2()").toString(), QString::fromLatin1("0")); - QEXPECT_FAIL("", "QScriptValue::setScope not implemented", Continue); - QCOMPARE(eng.evaluate("c2()").toString(), QString::fromLatin1("1")); - QVERIFY(!eng.hasUncaughtException()); - } - { - QScriptEngine eng; - eng.globalObject().setProperty("counter", eng.newFunction(counter_hybrid)); - eng.evaluate("var c1 = counter(); var c2 = counter(); "); - QCOMPARE(eng.evaluate("c1()").toString(), QString::fromLatin1("0")); - QCOMPARE(eng.evaluate("c1()").toString(), QString::fromLatin1("1")); - QCOMPARE(eng.evaluate("c2()").toString(), QString::fromLatin1("0")); - QCOMPARE(eng.evaluate("c2()").toString(), QString::fromLatin1("1")); - QVERIFY(!eng.hasUncaughtException()); - } -} -#endif - -#if 0 // ###FIXME: No QScriptProgram API -static QScriptValue createProgram(QScriptContext *ctx, QScriptEngine *eng) -{ - QString code = ctx->argument(0).toString(); - QScriptProgram result(code); - return qScriptValueFromValue(eng, result); -} - -void tst_QJSEngine::evaluateProgram() -{ - QScriptEngine eng; - - { - QString code("1 + 2"); - QString fileName("hello.js"); - int lineNumber(123); - QScriptProgram program(code, fileName, lineNumber); - QVERIFY(!program.isNull()); - QCOMPARE(program.sourceCode(), code); - QCOMPARE(program.fileName(), fileName); - QCOMPARE(program.firstLineNumber(), lineNumber); - - QScriptValue expected = eng.evaluate(code); - for (int x = 0; x < 10; ++x) { - QScriptValue ret = eng.evaluate(program); - QVERIFY(ret.equals(expected)); - } - - // operator= - QScriptProgram sameProgram = program; - QVERIFY(sameProgram == program); - QVERIFY(eng.evaluate(sameProgram).equals(expected)); - - // copy constructor - QScriptProgram sameProgram2(program); - QVERIFY(sameProgram2 == program); - QVERIFY(eng.evaluate(sameProgram2).equals(expected)); - - QScriptProgram differentProgram("2 + 3"); - QVERIFY(differentProgram != program); - QVERIFY(!eng.evaluate(differentProgram).equals(expected)); - } -} - -void tst_QJSEngine::evaluateProgram_customScope() -{ - QScriptEngine eng; - { - QScriptProgram program("a"); - QVERIFY(!program.isNull()); - { - QScriptValue ret = eng.evaluate(program); - QVERIFY(ret.isError()); - QCOMPARE(ret.toString(), QString::fromLatin1("ReferenceError: a is not defined")); - } - - QScriptValue obj = eng.newObject(); - obj.setProperty("a", 123); - QScriptContext *ctx = eng.currentContext(); - ctx->pushScope(obj); - { - QScriptValue ret = eng.evaluate(program); - QVERIFY(!ret.isError()); - QVERIFY(ret.equals(obj.property("a"))); - } - - obj.setProperty("a", QScriptValue()); - { - QScriptValue ret = eng.evaluate(program); - QVERIFY(ret.isError()); - } - - QScriptValue obj2 = eng.newObject(); - obj2.setProperty("a", 456); - ctx->pushScope(obj2); - { - QScriptValue ret = eng.evaluate(program); - QVERIFY(!ret.isError()); - QVERIFY(ret.equals(obj2.property("a"))); - } - - ctx->popScope(); - } -} - -void tst_QJSEngine::evaluateProgram_closure() -{ - QScriptEngine eng; - { - QScriptProgram program("(function() { var count = 0; return function() { return count++; }; })"); - QVERIFY(!program.isNull()); - QScriptValue createCounter = eng.evaluate(program); - QVERIFY(createCounter.isCallable()); - QScriptValue counter = createCounter.call(); - QVERIFY(counter.isCallable()); - { - QScriptValue ret = counter.call(); - QVERIFY(ret.isNumber()); - } - QScriptValue counter2 = createCounter.call(); - QVERIFY(counter2.isCallable()); - QVERIFY(!counter2.equals(counter)); - { - QScriptValue ret = counter2.call(); - QVERIFY(ret.isNumber()); - } - } -} - -void tst_QJSEngine::evaluateProgram_executeLater() -{ - QScriptEngine eng; - // Program created in a function call, then executed later - { - QScriptValue fun = eng.newFunction(createProgram); - QScriptProgram program = qscriptvalue_cast( - fun.call(QScriptValueList() << "a + 1")); - QVERIFY(!program.isNull()); - eng.globalObject().setProperty("a", QScriptValue()); - { - QScriptValue ret = eng.evaluate(program); - QVERIFY(ret.isError()); - QCOMPARE(ret.toString(), QString::fromLatin1("ReferenceError: a is not defined")); - } - eng.globalObject().setProperty("a", 122); - { - QScriptValue ret = eng.evaluate(program); - QVERIFY(!ret.isError()); - QVERIFY(ret.isNumber()); - QCOMPARE(ret.toInt(), 123); - } - } -} - -void tst_QJSEngine::evaluateProgram_multipleEngines() -{ - QScriptEngine eng; - { - QString code("1 + 2"); - QScriptProgram program(code); - QVERIFY(!program.isNull()); - double expected = eng.evaluate(program).toNumber(); - for (int x = 0; x < 2; ++x) { - QScriptEngine eng2; - for (int y = 0; y < 2; ++y) { - double ret = eng2.evaluate(program).toNumber(); - QCOMPARE(ret, expected); - } - } - } -} - -void tst_QJSEngine::evaluateProgram_empty() -{ - QScriptEngine eng; - { - QScriptProgram program; - QVERIFY(program.isNull()); - QScriptValue ret = eng.evaluate(program); - QVERIFY(ret.isUndefined()); - } -} -#endif - -#if 0 // ###FIXME: No ScriptOwnership API -void tst_QJSEngine::collectGarbageAfterConnect() -{ - // QTBUG-6366 - QScriptEngine engine; - QPointer widget = new QWidget; - engine.globalObject().setProperty( - "widget", engine.newQObject(widget, QScriptEngine::ScriptOwnership)); - QVERIFY(engine.evaluate("widget.customContextMenuRequested.connect(\n" - " function() { print('hello'); }\n" - ");") - .isUndefined()); - QVERIFY(widget != 0); - engine.evaluate("widget = null;"); - // The connection should not keep the widget alive. - collectGarbage_helper(engine); - QVERIFY(widget == 0); -} -#endif - -#if 0 // ###FIXME: No QScriptContext API -void tst_QJSEngine::collectGarbageAfterNativeArguments() -{ - // QTBUG-17788 - QScriptEngine eng; - QScriptContext *ctx = eng.pushContext(); - QScriptValue arguments = ctx->argumentsObject(); - // Shouldn't crash when marking the arguments object. - collectGarbage_helper(eng); -} - -static QScriptValue constructQObjectFromThisObject(QScriptContext *ctx, QScriptEngine *eng) -{ - if (!ctx->isCalledAsConstructor()) { - qWarning("%s: ctx->isCalledAsConstructor() returned false", Q_FUNC_INFO); - return QScriptValue(); - } - return eng->newQObject(ctx->thisObject(), new QObject, QScriptEngine::ScriptOwnership); -} - -void tst_QJSEngine::promoteThisObjectToQObjectInConstructor() -{ - QScriptEngine engine; - QScriptValue ctor = engine.newFunction(constructQObjectFromThisObject); - engine.globalObject().setProperty("Ctor", ctor); - QScriptValue object = engine.evaluate("new Ctor"); - QVERIFY(!object.isError()); - QVERIFY(object.isQObject()); - QVERIFY(object.toQObject() != 0); - QVERIFY(object.property("objectName").isString()); - QVERIFY(object.property("deleteLater").isCallable()); -} -#endif - -static QRegExp minimal(QRegExp r) { r.setMinimal(true); return r; } - -void tst_QJSEngine::qRegExpInport_data() -{ - QTest::addColumn("rx"); - QTest::addColumn("string"); - QTest::addColumn("matched"); - - QTest::newRow("normal") << QRegExp("(test|foo)") << "test _ foo _ test _ Foo"; - QTest::newRow("normal2") << QRegExp("(Test|Foo)") << "test _ foo _ test _ Foo"; - QTest::newRow("case insensitive)") << QRegExp("(test|foo)", Qt::CaseInsensitive) << "test _ foo _ test _ Foo"; - QTest::newRow("case insensitive2)") << QRegExp("(Test|Foo)", Qt::CaseInsensitive) << "test _ foo _ test _ Foo"; - QTest::newRow("b(a*)(b*)") << QRegExp("b(a*)(b*)", Qt::CaseInsensitive) << "aaabbBbaAabaAaababaaabbaaab"; - QTest::newRow("greedy") << QRegExp("a*(a*)", Qt::CaseInsensitive, QRegExp::RegExp2) << "aaaabaaba"; - // this one will fail because we do not support the QRegExp::RegExp in JSC - //QTest::newRow("not_greedy") << QRegExp("a*(a*)", Qt::CaseInsensitive, QRegExp::RegExp) << "aaaabaaba"; - QTest::newRow("willcard") << QRegExp("*.txt", Qt::CaseSensitive, QRegExp::Wildcard) << "file.txt"; - QTest::newRow("willcard 2") << QRegExp("a?b.txt", Qt::CaseSensitive, QRegExp::Wildcard) << "ab.txt abb.rtc acb.txt"; - QTest::newRow("slash") << QRegExp("g/.*/s", Qt::CaseInsensitive, QRegExp::RegExp2) << "string/string/string"; - QTest::newRow("slash2") << QRegExp("g / .* / s", Qt::CaseInsensitive, QRegExp::RegExp2) << "string / string / string"; - QTest::newRow("fixed") << QRegExp("a*aa.a(ba)*a\\ba", Qt::CaseInsensitive, QRegExp::FixedString) << "aa*aa.a(ba)*a\\ba"; - QTest::newRow("fixed insensitive") << QRegExp("A*A", Qt::CaseInsensitive, QRegExp::FixedString) << "a*A A*a A*A a*a"; - QTest::newRow("fixed sensitive") << QRegExp("A*A", Qt::CaseSensitive, QRegExp::FixedString) << "a*A A*a A*A a*a"; - QTest::newRow("html") << QRegExp("(.*)", Qt::CaseSensitive, QRegExp::RegExp2) << "bolditalicbold"; - QTest::newRow("html minimal") << minimal(QRegExp("(.*)", Qt::CaseSensitive, QRegExp::RegExp2)) << "bolditalicbold"; - QTest::newRow("aaa") << QRegExp("a{2,5}") << "aAaAaaaaaAa"; - QTest::newRow("aaa minimal") << minimal(QRegExp("a{2,5}")) << "aAaAaaaaaAa"; - QTest::newRow("minimal") << minimal(QRegExp(".*\\} [*8]")) << "}?} ?} *"; - QTest::newRow(".? minimal") << minimal(QRegExp(".?")) << ".?"; - QTest::newRow(".+ minimal") << minimal(QRegExp(".+")) << ".+"; - QTest::newRow("[.?] minimal") << minimal(QRegExp("[.?]")) << ".?"; - QTest::newRow("[.+] minimal") << minimal(QRegExp("[.+]")) << ".+"; -} - -void tst_QJSEngine::qRegExpInport() -{ - QSKIP("Test failing - QTBUG-22238"); - QFETCH(QRegExp, rx); - QFETCH(QString, string); - - QJSEngine eng; - QJSValue rexp; - rexp = eng.toScriptValue(rx); - - QCOMPARE(rexp.isRegExp(), true); - QVERIFY(rexp.isCallable()); - - QJSValue func = eng.evaluate("(function(string, regexp) { return string.match(regexp); })"); - QJSValue result = func.call(QJSValueList() << string << rexp); - - rx.indexIn(string); - for (int i = 0; i <= rx.captureCount(); i++) { - QCOMPARE(result.property(i).toString(), rx.cap(i)); - } -} - -// QScriptValue::toDateTime() returns a local time, whereas JS dates -// are always stored as UTC. QtScript must respect the current time -// zone, and correctly adjust for daylight saving time that may be in -// effect at a given date (QTBUG-9770). -void tst_QJSEngine::dateRoundtripJSQtJS() -{ - uint secs = QDateTime(QDate(2009, 1, 1)).toUTC().toTime_t(); - QJSEngine eng; - for (int i = 0; i < 8000; ++i) { - QJSValue jsDate = eng.evaluate(QString::fromLatin1("new Date(%0)").arg(secs * 1000.0)); - QDateTime qtDate = jsDate.toDateTime(); - QJSValue jsDate2 = eng.toScriptValue(qtDate); - if (jsDate2.toNumber() != jsDate.toNumber()) - QFAIL(qPrintable(jsDate.toString())); - secs += 2*60*60; - } -} - -void tst_QJSEngine::dateRoundtripQtJSQt() -{ - QDateTime qtDate = QDateTime(QDate(2009, 1, 1)); - QJSEngine eng; - for (int i = 0; i < 8000; ++i) { - QJSValue jsDate = eng.toScriptValue(qtDate); - QDateTime qtDate2 = jsDate.toDateTime(); - if (qtDate2 != qtDate) - QFAIL(qPrintable(qtDate.toString())); - qtDate = qtDate.addSecs(2*60*60); - } -} - -void tst_QJSEngine::dateConversionJSQt() -{ - uint secs = QDateTime(QDate(2009, 1, 1)).toUTC().toTime_t(); - QJSEngine eng; - for (int i = 0; i < 8000; ++i) { - QJSValue jsDate = eng.evaluate(QString::fromLatin1("new Date(%0)").arg(secs * 1000.0)); - QDateTime qtDate = jsDate.toDateTime(); - QString qtUTCDateStr = qtDate.toUTC().toString(Qt::ISODate); - QString jsUTCDateStr = jsDate.property("toISOString").callWithInstance(jsDate).toString(); - jsUTCDateStr.remove(jsUTCDateStr.length() - 5, 4); // get rid of milliseconds (".000") - if (qtUTCDateStr != jsUTCDateStr) - QFAIL(qPrintable(jsDate.toString())); - secs += 2*60*60; - } -} - -void tst_QJSEngine::dateConversionQtJS() -{ - QDateTime qtDate = QDateTime(QDate(2009, 1, 1)); - QJSEngine eng; - for (int i = 0; i < 8000; ++i) { - QJSValue jsDate = eng.toScriptValue(qtDate); - QString jsUTCDateStr = jsDate.property("toISOString").callWithInstance(jsDate).toString(); - jsUTCDateStr.remove(jsUTCDateStr.length() - 5, 4); // get rid of milliseconds (".000") - QString qtUTCDateStr = qtDate.toUTC().toString(Qt::ISODate); - if (jsUTCDateStr != qtUTCDateStr) - QFAIL(qPrintable(qtDate.toString())); - qtDate = qtDate.addSecs(2*60*60); - } -} - -#if 0 // ###FIXME: No QScriptContext API -static QScriptValue createAnotherEngine(QScriptContext *, QScriptEngine *) -{ - QScriptEngine eng; - eng.evaluate("function foo(x, y) { return x + y; }" ); - eng.evaluate("hello = 5; world = 6" ); - return eng.evaluate("foo(hello,world)").toInt(); -} - - -void tst_QJSEngine::reentrency() -{ - QScriptEngine eng; - eng.globalObject().setProperty("foo", eng.newFunction(createAnotherEngine)); - eng.evaluate("function bar() { return foo(); } hello = 9; function getHello() { return hello; }"); - QCOMPARE(eng.evaluate("foo() + getHello() + foo()").toInt(), 5+6 + 9 + 5+6); - QCOMPARE(eng.evaluate("foo").call().toInt(), 5+6); - QCOMPARE(eng.evaluate("hello").toInt(), 9); - QCOMPARE(eng.evaluate("foo() + hello").toInt(), 5+6+9); -} -#endif - -#if 0 // ###FIXME: No QSCriptDeclarativeClass API -void tst_QJSEngine::newFixedStaticScopeObject() -{ - // "Static scope objects" is an optimization we do for QML. - // It enables the creation of JS objects that can guarantee to the - // compiler that no properties will be added or removed. This enables - // the compiler to generate a very simple (fast) property access, as - // opposed to a full virtual lookup. Due to the inherent use of scope - // chains in QML, this can make a huge difference (10x improvement for - // benchmark in QTBUG-8576). - // Ideally we would not need a special object type for this, and the - // VM would dynamically optimize it to be fast... - // See also QScriptEngine benchmark. - - QScriptEngine eng; - static const int propertyCount = 4; - QString names[] = { "foo", "bar", "baz", "Math" }; - QScriptValue values[] = { 123, "ciao", true, false }; - QScriptValue::PropertyFlags flags[] = { QScriptValue::Undeletable, - QScriptValue::ReadOnly | QScriptValue::Undeletable, - QScriptValue::SkipInEnumeration | QScriptValue::Undeletable, - QScriptValue::Undeletable }; - QScriptValue scope = QScriptDeclarativeClass::newStaticScopeObject(&eng, propertyCount, names, values, flags); - - // Query property. - for (int i = 0; i < propertyCount; ++i) { - for (int x = 0; x < 2; ++x) { - if (x) { - // Properties can't be deleted. - scope.setProperty(names[i], QScriptValue()); - } - QVERIFY(scope.property(names[i]).equals(values[i])); - } - } - - // Property that doesn't exist. - QVERIFY(scope.property("noSuchProperty").isUndefined()); - - // Write to writable property. - { - QScriptValue oldValue = scope.property("foo"); - QVERIFY(oldValue.isNumber()); - QScriptValue newValue = oldValue.toNumber() * 2; - scope.setProperty("foo", newValue); - QVERIFY(scope.property("foo").equals(newValue)); - scope.setProperty("foo", oldValue); - QVERIFY(scope.property("foo").equals(oldValue)); - } - - // Write to read-only property. - scope.setProperty("bar", 456); - QVERIFY(scope.property("bar").equals("ciao")); - - // Iterate. - { - QScriptValueIterator it(scope); - QSet iteratedNames; - while (it.hasNext()) { - it.next(); - iteratedNames.insert(it.name()); - } - for (int i = 0; i < propertyCount; ++i) - QVERIFY(iteratedNames.contains(names[i])); - } - - // Push it on the scope chain of a new context. - QScriptContext *ctx = eng.pushContext(); - ctx->pushScope(scope); - QCOMPARE(ctx->scopeChain().size(), 3); // Global Object, native activation, custom scope - QEXPECT_FAIL("", "activationObject has not been implemented yet", Continue); - QVERIFY(ctx->activationObject().equals(scope)); - - // Read property from JS. - for (int i = 0; i < propertyCount; ++i) { - for (int x = 0; x < 2; ++x) { - if (x) { - // Property can't be deleted from JS. - QScriptValue ret = eng.evaluate(QString::fromLatin1("delete %0").arg(names[i])); - QVERIFY(ret.equals(false)); - } - QVERIFY(eng.evaluate(names[i]).equals(values[i])); - } - } - - // Property that doesn't exist. - QVERIFY(eng.evaluate("noSuchProperty").equals("ReferenceError: noSuchProperty is not defined")); - - // Write property from JS. - { - QScriptValue oldValue = eng.evaluate("foo"); - QVERIFY(oldValue.isNumber()); - QScriptValue newValue = oldValue.toNumber() * 2; - QVERIFY(eng.evaluate("foo = foo * 2; foo").equals(newValue)); - scope.setProperty("foo", oldValue); - QVERIFY(eng.evaluate("foo").equals(oldValue)); - } - - // Write to read-only property. - QVERIFY(eng.evaluate("bar = 456; bar").equals("ciao")); - - // Create a closure and return properties from there. - { - QScriptValue props = eng.evaluate("(function() { var baz = 'shadow'; return [foo, bar, baz, Math, Array]; })()"); - QVERIFY(props.isArray()); - // "foo" and "bar" come from scope object. - QVERIFY(props.property(0).equals(scope.property("foo"))); - QVERIFY(props.property(1).equals(scope.property("bar"))); - // "baz" shadows property in scope object. - QVERIFY(props.property(2).equals("shadow")); - // "Math" comes from scope object, and shadows Global Object's "Math". - QVERIFY(props.property(3).equals(scope.property("Math"))); - QVERIFY(!props.property(3).equals(eng.globalObject().property("Math"))); - // "Array" comes from Global Object. - QVERIFY(props.property(4).equals(eng.globalObject().property("Array"))); - } - - // As with normal JS, assigning to an undefined variable will create - // the property on the Global Object, not the inner scope. - QVERIFY(eng.globalObject().property("newProperty").isUndefined()); - QVERIFY(eng.evaluate("(function() { newProperty = 789; })()").isUndefined()); - QVERIFY(!scope.property("newProperty").isUndefined()); - QVERIFY(eng.globalObject().property("newProperty").isNumber()); - - // Nested static scope. - { - static const int propertyCount2 = 2; - QString names2[] = { "foo", "hum" }; - QScriptValue values2[] = { 321, "hello" }; - QScriptValue::PropertyFlags flags2[] = { QScriptValue::Undeletable, - QScriptValue::ReadOnly | QScriptValue::Undeletable }; - QScriptValue scope2 = QScriptDeclarativeClass::newStaticScopeObject(&eng, propertyCount2, names2, values2, flags2); - ctx->pushScope(scope2); - - // "foo" shadows scope.foo. - QVERIFY(eng.evaluate("foo").equals(scope2.property("foo"))); - QVERIFY(!eng.evaluate("foo").equals(scope.property("foo"))); - // "hum" comes from scope2. - QVERIFY(eng.evaluate("hum").equals(scope2.property("hum"))); - // "Array" comes from Global Object. - QVERIFY(eng.evaluate("Array").equals(eng.globalObject().property("Array"))); - - ctx->popScope(); - } - - QScriptValue fun = eng.evaluate("(function() { return foo; })"); - QVERIFY(fun.isCallable()); - eng.popContext(); - // Function's scope chain persists after popContext(). - QVERIFY(fun.call().equals(scope.property("foo"))); -} - -void tst_QJSEngine::newGrowingStaticScopeObject() -{ - // The main use case for a growing static scope object is to set it as - // the activation object of a QScriptContext, so that all JS variable - // declarations end up in that object. It needs to be "growable" since - // we don't know in advance how many variables a script will declare. - - QScriptEngine eng; - QScriptValue scope = QScriptDeclarativeClass::newStaticScopeObject(&eng); - - // Initially empty. - QVERIFY(!QScriptValueIterator(scope).hasNext()); - QVERIFY(scope.property("foo").isUndefined()); - - // Add a static property. - scope.setProperty("foo", 123); - QVERIFY(scope.property("foo").equals(123)); - QEXPECT_FAIL("", "FIXME: newStaticScopeObject not properly implemented", Abort); - - // Modify existing property. - scope.setProperty("foo", 456); - QVERIFY(scope.property("foo").equals(456)); - - // Add a read-only property. - scope.setProperty("bar", "ciao", QScriptValue::ReadOnly); - QVERIFY(scope.property("bar").equals("ciao")); - - // Attempt to modify read-only property. - scope.setProperty("bar", "hello"); - QVERIFY(scope.property("bar").equals("ciao")); - - // Properties can't be deleted. - scope.setProperty("foo", QScriptValue()); - QVERIFY(scope.property("foo").equals(456)); - scope.setProperty("bar", QScriptValue()); - QVERIFY(scope.property("bar").equals("ciao")); - - // Iterate. - { - QScriptValueIterator it(scope); - QSet iteratedNames; - while (it.hasNext()) { - it.next(); - iteratedNames.insert(it.name()); - } - QCOMPARE(iteratedNames.size(), 2); - QVERIFY(iteratedNames.contains("foo")); - QVERIFY(iteratedNames.contains("bar")); - } - - // Push it on the scope chain of a new context. - QScriptContext *ctx = eng.pushContext(); - ctx->pushScope(scope); - QCOMPARE(ctx->scopeChain().size(), 3); // Global Object, native activation, custom scope - QVERIFY(ctx->activationObject().equals(scope)); - - // Read property from JS. - QVERIFY(eng.evaluate("foo").equals(scope.property("foo"))); - QVERIFY(eng.evaluate("bar").equals(scope.property("bar"))); - - // Write property from JS. - { - QScriptValue oldValue = eng.evaluate("foo"); - QVERIFY(oldValue.isNumber()); - QScriptValue newValue = oldValue.toNumber() * 2; - QVERIFY(eng.evaluate("foo = foo * 2; foo").equals(newValue)); - scope.setProperty("foo", oldValue); - QVERIFY(eng.evaluate("foo").equals(oldValue)); - } - - // Write to read-only property. - QVERIFY(eng.evaluate("bar = 456; bar").equals("ciao")); - - // Shadow property. - QVERIFY(eng.evaluate("Math").equals(eng.globalObject().property("Math"))); - scope.setProperty("Math", "fake Math"); - QVERIFY(eng.evaluate("Math").equals(scope.property("Math"))); - - // Variable declarations will create properties on the scope. - eng.evaluate("var baz = 456"); - QVERIFY(scope.property("baz").equals(456)); - - // Function declarations will create properties on the scope. - eng.evaluate("function fun() { return baz; }"); - QVERIFY(scope.property("fun").isCallable()); - QVERIFY(scope.property("fun").call().equals(scope.property("baz"))); - - // Demonstrate the limitation of a growable static scope: Once a function that - // uses the scope has been compiled, it won't pick up properties that are added - // to the scope later. - { - QScriptValue fun = eng.evaluate("(function() { return futureProperty; })"); - QVERIFY(fun.isCallable()); - QVERIFY(fun.call().toString().contains(QString::fromLatin1("ReferenceError"))); - scope.setProperty("futureProperty", "added after the function was compiled"); - // If scope were dynamic, this would return the new property. - QVERIFY(fun.call().toString().contains(QString::fromLatin1("ReferenceError"))); - } - - eng.popContext(); -} -#endif - -#if 0 // ###FIXME: No QScript MetaObject API -QT_BEGIN_NAMESPACE -Q_SCRIPT_DECLARE_QMETAOBJECT(QStandardItemModel, QObject*) -QT_END_NAMESPACE - -void tst_QJSEngine::scriptValueFromQMetaObject() -{ - QScriptEngine eng; - { - QScriptValue meta = eng.scriptValueFromQMetaObject(); - QVERIFY(meta.isQMetaObject()); - QCOMPARE(meta.toQMetaObject(), &QScriptEngine::staticMetaObject); - // Because of missing Q_SCRIPT_DECLARE_QMETAOBJECT() for QScriptEngine. - QEXPECT_FAIL("", "FIXME: because construct never returns invalid values", Continue); - QVERIFY(meta.callAsConstructor().isUndefined()); - } - { - QScriptValue meta = eng.scriptValueFromQMetaObject(); - QVERIFY(meta.isQMetaObject()); - QCOMPARE(meta.toQMetaObject(), &QStandardItemModel::staticMetaObject); - QScriptValue obj = meta.callAsConstructor(QScriptValueList() << eng.newQObject(&eng)); - QVERIFY(obj.isQObject()); - QStandardItemModel *model = qobject_cast(obj.toQObject()); - QVERIFY(model != 0); - QCOMPARE(model->parent(), (QObject*)&eng); - } -} -#endif - -void tst_QJSEngine::functionPrototypeExtensions() -{ - // QJS adds connect and disconnect properties to Function.prototype. - QJSEngine eng; - QJSValue funProto = eng.globalObject().property("Function").property("prototype"); - QVERIFY(funProto.isCallable()); - QVERIFY(funProto.property("connect").isCallable()); - QVERIFY(funProto.property("disconnect").isCallable()); - - // No properties should appear in for-in statements. - QJSValue props = eng.evaluate("props = []; for (var p in Function.prototype) props.push(p); props"); - QVERIFY(!eng.hasUncaughtException()); - QVERIFY(props.isArray()); - QCOMPARE(props.property("length").toInt(), 0); -} - -class ThreadedTestEngine : public QThread { - Q_OBJECT; - -public: - int result; - - ThreadedTestEngine() - : result(0) {} - - void run() { - QJSEngine firstEngine; - QJSEngine secondEngine; - QJSValue value = firstEngine.evaluate("1"); - result = secondEngine.evaluate("1 + " + QString::number(value.toInt())).toInt(); - } -}; - -void tst_QJSEngine::threadedEngine() -{ - ThreadedTestEngine thread1; - ThreadedTestEngine thread2; - thread1.start(); - thread2.start(); - thread1.wait(); - thread2.wait(); - QCOMPARE(thread1.result, 2); - QCOMPARE(thread2.result, 2); -} - -QTEST_MAIN(tst_QJSEngine) - -#include "tst_qjsengine.moc" - diff --git a/tests/auto/declarative/qjsvalue/qjsvalue.pro b/tests/auto/declarative/qjsvalue/qjsvalue.pro deleted file mode 100644 index 3b40e92e67..0000000000 --- a/tests/auto/declarative/qjsvalue/qjsvalue.pro +++ /dev/null @@ -1,6 +0,0 @@ -CONFIG += testcase -TARGET = tst_qjsvalue -macx:CONFIG -= app_bundle -QT += declarative widgets testlib -SOURCES += tst_qjsvalue.cpp -HEADERS += tst_qjsvalue.h diff --git a/tests/auto/declarative/qjsvalue/tst_qjsvalue.cpp b/tests/auto/declarative/qjsvalue/tst_qjsvalue.cpp deleted file mode 100644 index cec10ccf38..0000000000 --- a/tests/auto/declarative/qjsvalue/tst_qjsvalue.cpp +++ /dev/null @@ -1,3655 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "tst_qjsvalue.h" -#include - -QT_BEGIN_NAMESPACE -extern bool qt_script_isJITEnabled(); -QT_END_NAMESPACE - -tst_QJSValue::tst_QJSValue() - : engine(0) -{ -} - -tst_QJSValue::~tst_QJSValue() -{ - if (engine) - delete engine; -} - -void tst_QJSValue::ctor_invalid() -{ - QJSEngine eng; - { - QJSValue v; - QVERIFY(v.isUndefined()); - QCOMPARE(v.engine(), (QJSEngine *)0); - } -} - -void tst_QJSValue::ctor_undefinedWithEngine() -{ - QJSEngine eng; - { - QJSValue v = eng.toScriptValue(QVariant()); - QVERIFY(v.isUndefined()); - QCOMPARE(v.isObject(), false); - QCOMPARE(v.engine(), &eng); - } -} - -void tst_QJSValue::ctor_nullWithEngine() -{ - QJSEngine eng; - { - QJSValue v = eng.evaluate("null"); - QVERIFY(!v.isUndefined()); - QCOMPARE(v.isNull(), true); - QCOMPARE(v.isObject(), false); - QCOMPARE(v.engine(), &eng); - } -} - -void tst_QJSValue::ctor_boolWithEngine() -{ - QJSEngine eng; - { - QJSValue v = eng.toScriptValue(false); - QVERIFY(!v.isUndefined()); - QCOMPARE(v.isBool(), true); - QCOMPARE(v.isObject(), false); - QCOMPARE(v.toBool(), false); - QCOMPARE(v.engine(), &eng); - } -} - -void tst_QJSValue::ctor_intWithEngine() -{ - QJSEngine eng; - { - QJSValue v = eng.toScriptValue(int(1)); - QVERIFY(!v.isUndefined()); - QCOMPARE(v.isNumber(), true); - QCOMPARE(v.isObject(), false); - QCOMPARE(v.toNumber(), 1.0); - QCOMPARE(v.engine(), &eng); - } -} - -void tst_QJSValue::ctor_int() -{ - { - QJSValue v(int(0x43211234)); - QVERIFY(v.isNumber()); - QCOMPARE(v.toInt(), 0x43211234); - } - { - QJSValue v(int(1)); - QVERIFY(!v.isUndefined()); - QCOMPARE(v.isNumber(), true); - QCOMPARE(v.isObject(), false); - QCOMPARE(v.toNumber(), 1.0); - QCOMPARE(v.engine(), (QJSEngine *)0); - } -} - -void tst_QJSValue::ctor_uintWithEngine() -{ - QJSEngine eng; - { - QJSValue v = eng.toScriptValue(uint(1)); - QVERIFY(!v.isUndefined()); - QCOMPARE(v.isNumber(), true); - QCOMPARE(v.isObject(), false); - QCOMPARE(v.toNumber(), 1.0); - QCOMPARE(v.engine(), &eng); - } -} - -void tst_QJSValue::ctor_uint() -{ - { - QJSValue v(uint(0x43211234)); - QVERIFY(v.isNumber()); - QCOMPARE(v.toUInt(), uint(0x43211234)); - } - { - QJSValue v(uint(1)); - QVERIFY(!v.isUndefined()); - QCOMPARE(v.isNumber(), true); - QCOMPARE(v.isObject(), false); - QCOMPARE(v.toNumber(), 1.0); - QCOMPARE(v.engine(), (QJSEngine *)0); - } -} - -void tst_QJSValue::ctor_floatWithEngine() -{ - QJSEngine eng; - { - QJSValue v = eng.toScriptValue(float(1.0)); - QVERIFY(!v.isUndefined()); - QCOMPARE(v.isNumber(), true); - QCOMPARE(v.isObject(), false); - QCOMPARE(v.toNumber(), 1.0); - QCOMPARE(v.engine(), &eng); - } -} - -void tst_QJSValue::ctor_float() -{ - { - QJSValue v(12345678910.5); - QVERIFY(v.isNumber()); - QCOMPARE(v.toNumber(), 12345678910.5); - } - { - QJSValue v(1.0); - QVERIFY(!v.isUndefined()); - QCOMPARE(v.isNumber(), true); - QCOMPARE(v.isObject(), false); - QCOMPARE(v.toNumber(), 1.0); - QCOMPARE(v.engine(), (QJSEngine *)0); - } -} - -void tst_QJSValue::ctor_stringWithEngine() -{ - QJSEngine eng; - { - QJSValue v = eng.toScriptValue(QString::fromLatin1("ciao")); - QVERIFY(!v.isUndefined()); - QCOMPARE(v.isString(), true); - QCOMPARE(v.isObject(), false); - QCOMPARE(v.toString(), QLatin1String("ciao")); - QCOMPARE(v.engine(), &eng); - } -} - -void tst_QJSValue::ctor_string() -{ - { - QJSValue v(QString("ciao")); - QVERIFY(!v.isUndefined()); - QCOMPARE(v.isString(), true); - QCOMPARE(v.isObject(), false); - QCOMPARE(v.toString(), QLatin1String("ciao")); - QCOMPARE(v.engine(), (QJSEngine *)0); - } - { - QJSValue v("ciao"); - QVERIFY(!v.isUndefined()); - QCOMPARE(v.isString(), true); - QCOMPARE(v.isObject(), false); - QCOMPARE(v.toString(), QLatin1String("ciao")); - QCOMPARE(v.engine(), (QJSEngine *)0); - } -} - -void tst_QJSValue::ctor_copyAndAssignWithEngine() -{ - QJSEngine eng; - // copy constructor, operator= - { - QJSValue v = eng.toScriptValue(1.0); - QJSValue v2(v); - QCOMPARE(v2.strictlyEquals(v), true); - QCOMPARE(v2.engine(), &eng); - - QJSValue v3(v); - QCOMPARE(v3.strictlyEquals(v), true); - QCOMPARE(v3.strictlyEquals(v2), true); - QCOMPARE(v3.engine(), &eng); - - QJSValue v4 = eng.toScriptValue(2.0); - QCOMPARE(v4.strictlyEquals(v), false); - v3 = v4; - QCOMPARE(v3.strictlyEquals(v), false); - QCOMPARE(v3.strictlyEquals(v4), true); - - v2 = QJSValue(); - QCOMPARE(v2.strictlyEquals(v), false); - QCOMPARE(v.toNumber(), 1.0); - - QJSValue v5(v); - QCOMPARE(v5.strictlyEquals(v), true); - v = QJSValue(); - QCOMPARE(v5.strictlyEquals(v), false); - QCOMPARE(v5.toNumber(), 1.0); - } -} - -void tst_QJSValue::ctor_undefined() -{ - QJSValue v(QJSValue::UndefinedValue); - QVERIFY(v.isUndefined()); - QCOMPARE(v.isObject(), false); - QCOMPARE(v.engine(), (QJSEngine *)0); -} - -void tst_QJSValue::ctor_null() -{ - QJSValue v(QJSValue::NullValue); - QVERIFY(!v.isUndefined()); - QCOMPARE(v.isNull(), true); - QCOMPARE(v.isObject(), false); - QCOMPARE(v.engine(), (QJSEngine *)0); -} - -void tst_QJSValue::ctor_bool() -{ - QJSValue v(false); - QVERIFY(!v.isUndefined()); - QCOMPARE(v.isBool(), true); - QCOMPARE(v.isBool(), true); - QCOMPARE(v.isObject(), false); - QCOMPARE(v.toBool(), false); - QCOMPARE(v.engine(), (QJSEngine *)0); -} - -void tst_QJSValue::ctor_copyAndAssign() -{ - QJSValue v(1.0); - QJSValue v2(v); - QCOMPARE(v2.strictlyEquals(v), true); - QCOMPARE(v2.engine(), (QJSEngine *)0); - - QJSValue v3(v); - QCOMPARE(v3.strictlyEquals(v), true); - QCOMPARE(v3.strictlyEquals(v2), true); - QCOMPARE(v3.engine(), (QJSEngine *)0); - - QJSValue v4(2.0); - QCOMPARE(v4.strictlyEquals(v), false); - v3 = v4; - QCOMPARE(v3.strictlyEquals(v), false); - QCOMPARE(v3.strictlyEquals(v4), true); - - v2 = QJSValue(); - QCOMPARE(v2.strictlyEquals(v), false); - QCOMPARE(v.toNumber(), 1.0); - - QJSValue v5(v); - QCOMPARE(v5.strictlyEquals(v), true); - v = QJSValue(); - QCOMPARE(v5.strictlyEquals(v), false); - QCOMPARE(v5.toNumber(), 1.0); -} - -#if 0 // FIXME: No c-style callbacks currently -static QJSValue myFunction(QScriptContext *, QScriptEngine *eng) -{ - return eng->undefinedValue(); -} -#endif - -void tst_QJSValue::toString() -{ - QJSEngine eng; - - QJSValue undefined = eng.toScriptValue(QVariant()); - QCOMPARE(undefined.toString(), QString("undefined")); - QCOMPARE(qjsvalue_cast(undefined), QString()); - - QJSValue null = eng.evaluate("null"); - QCOMPARE(null.toString(), QString("null")); - QCOMPARE(qjsvalue_cast(null), QString()); - - { - QJSValue falskt = eng.toScriptValue(false); - QCOMPARE(falskt.toString(), QString("false")); - QCOMPARE(qjsvalue_cast(falskt), QString("false")); - - QJSValue sant = eng.toScriptValue(true); - QCOMPARE(sant.toString(), QString("true")); - QCOMPARE(qjsvalue_cast(sant), QString("true")); - } - { - QJSValue number = eng.toScriptValue(123); - QCOMPARE(number.toString(), QString("123")); - QCOMPARE(qjsvalue_cast(number), QString("123")); - } - { - QJSValue number = eng.toScriptValue(6.37e-8); - QCOMPARE(number.toString(), QString("6.37e-8")); - } - { - QJSValue number = eng.toScriptValue(-6.37e-8); - QCOMPARE(number.toString(), QString("-6.37e-8")); - - QJSValue str = eng.toScriptValue(QString("ciao")); - QCOMPARE(str.toString(), QString("ciao")); - QCOMPARE(qjsvalue_cast(str), QString("ciao")); - } - - QJSValue object = eng.newObject(); - QCOMPARE(object.toString(), QString("[object Object]")); - QCOMPARE(qjsvalue_cast(object), QString("[object Object]")); - - // FIXME: No c-style callbacks currently -#if 0 - QJSValue fun = eng.newFunction(myFunction); - QCOMPARE(fun.toString().simplified(), QString("function () { [native code] }")); - QCOMPARE(qscriptvalue_cast(fun).simplified(), QString("function () { [native code] }")); -#endif - - // toString() that throws exception - { - QJSValue objectObject = eng.evaluate( - "(function(){" - " o = { };" - " o.toString = function() { throw new Error('toString'); };" - " return o;" - "})()"); - QCOMPARE(objectObject.toString(), QLatin1String("Error: toString")); - QVERIFY(eng.hasUncaughtException()); - QCOMPARE(eng.uncaughtException().toString(), QLatin1String("Error: toString")); - } - { - eng.clearExceptions(); - QJSValue objectObject = eng.evaluate( - "(function(){" - " var f = function() {};" - " f.prototype = Date;" - " return new f;" - "})()"); - QVERIFY(!eng.hasUncaughtException()); - QVERIFY(objectObject.isObject()); - QCOMPARE(objectObject.toString(), QString::fromLatin1("TypeError: Function.prototype.toString is not generic")); - QVERIFY(eng.hasUncaughtException()); - eng.clearExceptions(); - } - - QJSValue inv = QJSValue(); - QCOMPARE(inv.toString(), QString::fromLatin1("undefined")); - - // V2 constructors - { - QJSValue falskt = QJSValue(false); - QCOMPARE(falskt.toString(), QString("false")); - QCOMPARE(qjsvalue_cast(falskt), QString("false")); - - QJSValue sant = QJSValue(true); - QCOMPARE(sant.toString(), QString("true")); - QCOMPARE(qjsvalue_cast(sant), QString("true")); - - QJSValue number = QJSValue(123); - QCOMPARE(number.toString(), QString("123")); - QCOMPARE(qjsvalue_cast(number), QString("123")); - - QJSValue number2(int(0x43211234)); - QCOMPARE(number2.toString(), QString("1126240820")); - - QJSValue str = QJSValue(QString("ciao")); - QCOMPARE(str.toString(), QString("ciao")); - QCOMPARE(qjsvalue_cast(str), QString("ciao")); - } - - // variant should use internal valueOf(), then fall back to QVariant::toString(), - // then fall back to "QVariant(typename)" - QJSValue variant = eng.toScriptValue(QPoint(10, 20)); - QVERIFY(variant.isVariant()); - QCOMPARE(variant.toString(), QString::fromLatin1("QVariant(QPoint)")); - variant = eng.toScriptValue(QUrl()); - QVERIFY(variant.isVariant()); - QVERIFY(variant.toString().isEmpty()); -} - -void tst_QJSValue::toNumber() -{ - QJSEngine eng; - - QJSValue undefined = eng.toScriptValue(QVariant()); - QCOMPARE(qIsNaN(undefined.toNumber()), true); - QCOMPARE(qIsNaN(qjsvalue_cast(undefined)), true); - - QJSValue null = eng.evaluate("null"); - QCOMPARE(null.toNumber(), 0.0); - QCOMPARE(qjsvalue_cast(null), 0.0); - - { - QJSValue falskt = eng.toScriptValue(false); - QCOMPARE(falskt.toNumber(), 0.0); - QCOMPARE(qjsvalue_cast(falskt), 0.0); - - QJSValue sant = eng.toScriptValue(true); - QCOMPARE(sant.toNumber(), 1.0); - QCOMPARE(qjsvalue_cast(sant), 1.0); - - QJSValue number = eng.toScriptValue(123.0); - QCOMPARE(number.toNumber(), 123.0); - QCOMPARE(qjsvalue_cast(number), 123.0); - - QJSValue str = eng.toScriptValue(QString("ciao")); - QCOMPARE(qIsNaN(str.toNumber()), true); - QCOMPARE(qIsNaN(qjsvalue_cast(str)), true); - - QJSValue str2 = eng.toScriptValue(QString("123")); - QCOMPARE(str2.toNumber(), 123.0); - QCOMPARE(qjsvalue_cast(str2), 123.0); - } - - QJSValue object = eng.newObject(); - QCOMPARE(qIsNaN(object.toNumber()), true); - QCOMPARE(qIsNaN(qjsvalue_cast(object)), true); - - // FIXME: No c-style callbacks currently -#if 0 - QJSValue fun = eng.newFunction(myFunction); - QCOMPARE(qIsNaN(fun.toNumber()), true); - QCOMPARE(qIsNaN(qscriptvalue_cast(fun)), true); -#endif - - QJSValue inv = QJSValue(); - QVERIFY(qIsNaN(inv.toNumber())); - QVERIFY(qIsNaN(qjsvalue_cast(inv))); - - // V2 constructors - { - QJSValue falskt = QJSValue(false); - QCOMPARE(falskt.toNumber(), 0.0); - QCOMPARE(qjsvalue_cast(falskt), 0.0); - - QJSValue sant = QJSValue(true); - QCOMPARE(sant.toNumber(), 1.0); - QCOMPARE(qjsvalue_cast(sant), 1.0); - - QJSValue number = QJSValue(123.0); - QCOMPARE(number.toNumber(), 123.0); - QCOMPARE(qjsvalue_cast(number), 123.0); - - QJSValue number2(int(0x43211234)); - QCOMPARE(number2.toNumber(), 1126240820.0); - - QJSValue str = QJSValue(QString("ciao")); - QCOMPARE(qIsNaN(str.toNumber()), true); - QCOMPARE(qIsNaN(qjsvalue_cast(str)), true); - - QJSValue str2 = QJSValue(QString("123")); - QCOMPARE(str2.toNumber(), 123.0); - QCOMPARE(qjsvalue_cast(str2), 123.0); - } -} - -void tst_QJSValue::toBoolean() // deprecated -{ - QJSEngine eng; - - QJSValue undefined = eng.toScriptValue(QVariant()); - QCOMPARE(undefined.toBool(), false); - QCOMPARE(qjsvalue_cast(undefined), false); - - QJSValue null = eng.evaluate("null"); - QCOMPARE(null.toBool(), false); - QCOMPARE(qjsvalue_cast(null), false); - - { - QJSValue falskt = eng.toScriptValue(false); - QCOMPARE(falskt.toBool(), false); - QCOMPARE(qjsvalue_cast(falskt), false); - - QJSValue sant = eng.toScriptValue(true); - QCOMPARE(sant.toBool(), true); - QCOMPARE(qjsvalue_cast(sant), true); - - QJSValue number = eng.toScriptValue(0.0); - QCOMPARE(number.toBool(), false); - QCOMPARE(qjsvalue_cast(number), false); - - QJSValue number2 = eng.toScriptValue(qSNaN()); - QCOMPARE(number2.toBool(), false); - QCOMPARE(qjsvalue_cast(number2), false); - - QJSValue number3 = eng.toScriptValue(123.0); - QCOMPARE(number3.toBool(), true); - QCOMPARE(qjsvalue_cast(number3), true); - - QJSValue number4 = eng.toScriptValue(-456.0); - QCOMPARE(number4.toBool(), true); - QCOMPARE(qjsvalue_cast(number4), true); - - QJSValue str = eng.toScriptValue(QString("")); - QCOMPARE(str.toBool(), false); - QCOMPARE(qjsvalue_cast(str), false); - - QJSValue str2 = eng.toScriptValue(QString("123")); - QCOMPARE(str2.toBool(), true); - QCOMPARE(qjsvalue_cast(str2), true); - } - - QJSValue object = eng.newObject(); - QCOMPARE(object.toBool(), true); - QCOMPARE(qjsvalue_cast(object), true); - - // FIXME: No c-style callbacks currently -#if 0 - QJSValue fun = eng.newFunction(myFunction); - QCOMPARE(fun.toBoolean(), true); - QCOMPARE(qscriptvalue_cast(fun), true); -#endif - - QJSValue inv = QJSValue(); - QCOMPARE(inv.toBool(), false); - QCOMPARE(qjsvalue_cast(inv), false); - - // V2 constructors - { - QJSValue falskt = QJSValue(false); - QCOMPARE(falskt.toBool(), false); - QCOMPARE(qjsvalue_cast(falskt), false); - - QJSValue sant = QJSValue(true); - QCOMPARE(sant.toBool(), true); - QCOMPARE(qjsvalue_cast(sant), true); - - QJSValue number = QJSValue(0.0); - QCOMPARE(number.toBool(), false); - QCOMPARE(qjsvalue_cast(number), false); - - QJSValue number2 = QJSValue(qSNaN()); - QCOMPARE(number2.toBool(), false); - QCOMPARE(qjsvalue_cast(number2), false); - - QJSValue number3 = QJSValue(123.0); - QCOMPARE(number3.toBool(), true); - QCOMPARE(qjsvalue_cast(number3), true); - - QJSValue number4 = QJSValue(-456.0); - QCOMPARE(number4.toBool(), true); - QCOMPARE(qjsvalue_cast(number4), true); - - QJSValue number5 = QJSValue(0x43211234); - QCOMPARE(number5.toBool(), true); - - QJSValue str = QJSValue(QString("")); - QCOMPARE(str.toBool(), false); - QCOMPARE(qjsvalue_cast(str), false); - - QJSValue str2 = QJSValue(QString("123")); - QCOMPARE(str2.toBool(), true); - QCOMPARE(qjsvalue_cast(str2), true); - } -} - -void tst_QJSValue::toBool() -{ - QJSEngine eng; - - QJSValue undefined = eng.toScriptValue(QVariant()); - QCOMPARE(undefined.toBool(), false); - QCOMPARE(qjsvalue_cast(undefined), false); - - QJSValue null = eng.evaluate("null"); - QCOMPARE(null.toBool(), false); - QCOMPARE(qjsvalue_cast(null), false); - - { - QJSValue falskt = eng.toScriptValue(false); - QCOMPARE(falskt.toBool(), false); - QCOMPARE(qjsvalue_cast(falskt), false); - - QJSValue sant = eng.toScriptValue(true); - QCOMPARE(sant.toBool(), true); - QCOMPARE(qjsvalue_cast(sant), true); - - QJSValue number = eng.toScriptValue(0.0); - QCOMPARE(number.toBool(), false); - QCOMPARE(qjsvalue_cast(number), false); - - QJSValue number2 = eng.toScriptValue(qSNaN()); - QCOMPARE(number2.toBool(), false); - QCOMPARE(qjsvalue_cast(number2), false); - - QJSValue number3 = eng.toScriptValue(123.0); - QCOMPARE(number3.toBool(), true); - QCOMPARE(qjsvalue_cast(number3), true); - - QJSValue number4 = eng.toScriptValue(-456.0); - QCOMPARE(number4.toBool(), true); - QCOMPARE(qjsvalue_cast(number4), true); - - QJSValue str = eng.toScriptValue(QString("")); - QCOMPARE(str.toBool(), false); - QCOMPARE(qjsvalue_cast(str), false); - - QJSValue str2 = eng.toScriptValue(QString("123")); - QCOMPARE(str2.toBool(), true); - QCOMPARE(qjsvalue_cast(str2), true); - } - - QJSValue object = eng.newObject(); - QCOMPARE(object.toBool(), true); - QCOMPARE(qjsvalue_cast(object), true); - - // FIXME: No c-style callbacks currently -#if 0 - QJSValue fun = eng.newFunction(myFunction); - QCOMPARE(fun.toBool(), true); - QCOMPARE(qscriptvalue_cast(fun), true); -#endif - - QJSValue inv = QJSValue(); - QCOMPARE(inv.toBool(), false); - QCOMPARE(qjsvalue_cast(inv), false); - - // V2 constructors - { - QJSValue falskt = QJSValue(false); - QCOMPARE(falskt.toBool(), false); - QCOMPARE(qjsvalue_cast(falskt), false); - - QJSValue sant = QJSValue(true); - QCOMPARE(sant.toBool(), true); - QCOMPARE(qjsvalue_cast(sant), true); - - QJSValue number = QJSValue(0.0); - QCOMPARE(number.toBool(), false); - QCOMPARE(qjsvalue_cast(number), false); - - QJSValue number2 = QJSValue(qSNaN()); - QCOMPARE(number2.toBool(), false); - QCOMPARE(qjsvalue_cast(number2), false); - - QJSValue number3 = QJSValue(123.0); - QCOMPARE(number3.toBool(), true); - QCOMPARE(qjsvalue_cast(number3), true); - - QJSValue number4 = QJSValue(-456.0); - QCOMPARE(number4.toBool(), true); - QCOMPARE(qjsvalue_cast(number4), true); - - QJSValue number5 = QJSValue(0x43211234); - QCOMPARE(number5.toBool(), true); - - QJSValue str = QJSValue(QString("")); - QCOMPARE(str.toBool(), false); - QCOMPARE(qjsvalue_cast(str), false); - - QJSValue str2 = QJSValue(QString("123")); - QCOMPARE(str2.toBool(), true); - QCOMPARE(qjsvalue_cast(str2), true); - } -} - -void tst_QJSValue::toInt() -{ - QJSEngine eng; - - { - QJSValue zer0 = eng.toScriptValue(0.0); - QCOMPARE(zer0.toInt(), 0); - QCOMPARE(qjsvalue_cast(zer0), 0); - - QJSValue number = eng.toScriptValue(123.0); - QCOMPARE(number.toInt(), 123); - QCOMPARE(qjsvalue_cast(number), 123); - - QJSValue number2 = eng.toScriptValue(qSNaN()); - QCOMPARE(number2.toInt(), 0); - QCOMPARE(qjsvalue_cast(number2), 0); - - QJSValue number3 = eng.toScriptValue(+qInf()); - QCOMPARE(number3.toInt(), 0); - QCOMPARE(qjsvalue_cast(number3), 0); - - QJSValue number3_2 = eng.toScriptValue(-qInf()); - QCOMPARE(number3_2.toInt(), 0); - QCOMPARE(qjsvalue_cast(number3_2), 0); - - QJSValue number4 = eng.toScriptValue(0.5); - QCOMPARE(number4.toInt(), 0); - QCOMPARE(qjsvalue_cast(number4), 0); - - QJSValue number5 = eng.toScriptValue(123.5); - QCOMPARE(number5.toInt(), 123); - QCOMPARE(qjsvalue_cast(number5), 123); - - QJSValue number6 = eng.toScriptValue(-456.5); - QCOMPARE(number6.toInt(), -456); - QCOMPARE(qjsvalue_cast(number6), -456); - - QJSValue str = eng.toScriptValue(QString::fromLatin1("123.0")); - QCOMPARE(str.toInt(), 123); - QCOMPARE(qjsvalue_cast(str), 123); - - QJSValue str2 = eng.toScriptValue(QString::fromLatin1("NaN")); - QCOMPARE(str2.toInt(), 0); - QCOMPARE(qjsvalue_cast(str2), 0); - - QJSValue str3 = eng.toScriptValue(QString::fromLatin1("Infinity")); - QCOMPARE(str3.toInt(), 0); - QCOMPARE(qjsvalue_cast(str3), 0); - - QJSValue str3_2 = eng.toScriptValue(QString::fromLatin1("-Infinity")); - QCOMPARE(str3_2.toInt(), 0); - QCOMPARE(qjsvalue_cast(str3_2), 0); - - QJSValue str4 = eng.toScriptValue(QString::fromLatin1("0.5")); - QCOMPARE(str4.toInt(), 0); - QCOMPARE(qjsvalue_cast(str4), 0); - - QJSValue str5 = eng.toScriptValue(QString::fromLatin1("123.5")); - QCOMPARE(str5.toInt(), 123); - QCOMPARE(qjsvalue_cast(str5), 123); - - QJSValue str6 = eng.toScriptValue(QString::fromLatin1("-456.5")); - QCOMPARE(str6.toInt(), -456); - QCOMPARE(qjsvalue_cast(str6), -456); - } - // V2 constructors - { - QJSValue zer0 = QJSValue(0.0); - QCOMPARE(zer0.toInt(), 0); - QCOMPARE(qjsvalue_cast(zer0), 0); - - QJSValue number = QJSValue(123.0); - QCOMPARE(number.toInt(), 123); - QCOMPARE(qjsvalue_cast(number), 123); - - QJSValue number2 = QJSValue(qSNaN()); - QCOMPARE(number2.toInt(), 0); - QCOMPARE(qjsvalue_cast(number2), 0); - - QJSValue number3 = QJSValue(+qInf()); - QCOMPARE(number3.toInt(), 0); - QCOMPARE(qjsvalue_cast(number3), 0); - - QJSValue number3_2 = QJSValue(-qInf()); - QCOMPARE(number3_2.toInt(), 0); - QCOMPARE(qjsvalue_cast(number3_2), 0); - - QJSValue number4 = QJSValue(0.5); - QCOMPARE(number4.toInt(), 0); - QCOMPARE(qjsvalue_cast(number4), 0); - - QJSValue number5 = QJSValue(123.5); - QCOMPARE(number5.toInt(), 123); - QCOMPARE(qjsvalue_cast(number5), 123); - - QJSValue number6 = QJSValue(-456.5); - QCOMPARE(number6.toInt(), -456); - QCOMPARE(qjsvalue_cast(number6), -456); - - QJSValue number7 = QJSValue(0x43211234); - QCOMPARE(number7.toInt(), 0x43211234); - - QJSValue str = QJSValue("123.0"); - QCOMPARE(str.toInt(), 123); - QCOMPARE(qjsvalue_cast(str), 123); - - QJSValue str2 = QJSValue("NaN"); - QCOMPARE(str2.toInt(), 0); - QCOMPARE(qjsvalue_cast(str2), 0); - - QJSValue str3 = QJSValue("Infinity"); - QCOMPARE(str3.toInt(), 0); - QCOMPARE(qjsvalue_cast(str3), 0); - - QJSValue str3_2 = QJSValue("-Infinity"); - QCOMPARE(str3_2.toInt(), 0); - QCOMPARE(qjsvalue_cast(str3_2), 0); - - QJSValue str4 = QJSValue("0.5"); - QCOMPARE(str4.toInt(), 0); - QCOMPARE(qjsvalue_cast(str4), 0); - - QJSValue str5 = QJSValue("123.5"); - QCOMPARE(str5.toInt(), 123); - QCOMPARE(qjsvalue_cast(str5), 123); - - QJSValue str6 = QJSValue("-456.5"); - QCOMPARE(str6.toInt(), -456); - QCOMPARE(qjsvalue_cast(str6), -456); - } - - QJSValue inv; - QCOMPARE(inv.toInt(), 0); - QCOMPARE(qjsvalue_cast(inv), 0); -} - -void tst_QJSValue::toUInt() -{ - QJSEngine eng; - - { - QJSValue zer0 = eng.toScriptValue(0.0); - QCOMPARE(zer0.toUInt(), quint32(0)); - QCOMPARE(qjsvalue_cast(zer0), quint32(0)); - - QJSValue number = eng.toScriptValue(123.0); - QCOMPARE(number.toUInt(), quint32(123)); - QCOMPARE(qjsvalue_cast(number), quint32(123)); - - QJSValue number2 = eng.toScriptValue(qSNaN()); - QCOMPARE(number2.toUInt(), quint32(0)); - QCOMPARE(qjsvalue_cast(number2), quint32(0)); - - QJSValue number3 = eng.toScriptValue(+qInf()); - QCOMPARE(number3.toUInt(), quint32(0)); - QCOMPARE(qjsvalue_cast(number3), quint32(0)); - - QJSValue number3_2 = eng.toScriptValue(-qInf()); - QCOMPARE(number3_2.toUInt(), quint32(0)); - QCOMPARE(qjsvalue_cast(number3_2), quint32(0)); - - QJSValue number4 = eng.toScriptValue(0.5); - QCOMPARE(number4.toUInt(), quint32(0)); - - QJSValue number5 = eng.toScriptValue(123.5); - QCOMPARE(number5.toUInt(), quint32(123)); - - QJSValue number6 = eng.toScriptValue(-456.5); - QCOMPARE(number6.toUInt(), quint32(-456)); - QCOMPARE(qjsvalue_cast(number6), quint32(-456)); - - QJSValue str = eng.toScriptValue(QString::fromLatin1("123.0")); - QCOMPARE(str.toUInt(), quint32(123)); - QCOMPARE(qjsvalue_cast(str), quint32(123)); - - QJSValue str2 = eng.toScriptValue(QString::fromLatin1("NaN")); - QCOMPARE(str2.toUInt(), quint32(0)); - QCOMPARE(qjsvalue_cast(str2), quint32(0)); - - QJSValue str3 = eng.toScriptValue(QString::fromLatin1("Infinity")); - QCOMPARE(str3.toUInt(), quint32(0)); - QCOMPARE(qjsvalue_cast(str3), quint32(0)); - - QJSValue str3_2 = eng.toScriptValue(QString::fromLatin1("-Infinity")); - QCOMPARE(str3_2.toUInt(), quint32(0)); - QCOMPARE(qjsvalue_cast(str3_2), quint32(0)); - - QJSValue str4 = eng.toScriptValue(QString::fromLatin1("0.5")); - QCOMPARE(str4.toUInt(), quint32(0)); - QCOMPARE(qjsvalue_cast(str4), quint32(0)); - - QJSValue str5 = eng.toScriptValue(QString::fromLatin1("123.5")); - QCOMPARE(str5.toUInt(), quint32(123)); - QCOMPARE(qjsvalue_cast(str5), quint32(123)); - - QJSValue str6 = eng.toScriptValue(QString::fromLatin1("-456.5")); - QCOMPARE(str6.toUInt(), quint32(-456)); - QCOMPARE(qjsvalue_cast(str6), quint32(-456)); - } - // V2 constructors - { - QJSValue zer0 = QJSValue(0.0); - QCOMPARE(zer0.toUInt(), quint32(0)); - QCOMPARE(qjsvalue_cast(zer0), quint32(0)); - - QJSValue number = QJSValue(123.0); - QCOMPARE(number.toUInt(), quint32(123)); - QCOMPARE(qjsvalue_cast(number), quint32(123)); - - QJSValue number2 = QJSValue(qSNaN()); - QCOMPARE(number2.toUInt(), quint32(0)); - QCOMPARE(qjsvalue_cast(number2), quint32(0)); - - QJSValue number3 = QJSValue(+qInf()); - QCOMPARE(number3.toUInt(), quint32(0)); - QCOMPARE(qjsvalue_cast(number3), quint32(0)); - - QJSValue number3_2 = QJSValue(-qInf()); - QCOMPARE(number3_2.toUInt(), quint32(0)); - QCOMPARE(qjsvalue_cast(number3_2), quint32(0)); - - QJSValue number4 = QJSValue(0.5); - QCOMPARE(number4.toUInt(), quint32(0)); - - QJSValue number5 = QJSValue(123.5); - QCOMPARE(number5.toUInt(), quint32(123)); - - QJSValue number6 = QJSValue(-456.5); - QCOMPARE(number6.toUInt(), quint32(-456)); - QCOMPARE(qjsvalue_cast(number6), quint32(-456)); - - QJSValue number7 = QJSValue(0x43211234); - QCOMPARE(number7.toUInt(), quint32(0x43211234)); - - QJSValue str = QJSValue(QLatin1String("123.0")); - QCOMPARE(str.toUInt(), quint32(123)); - QCOMPARE(qjsvalue_cast(str), quint32(123)); - - QJSValue str2 = QJSValue(QLatin1String("NaN")); - QCOMPARE(str2.toUInt(), quint32(0)); - QCOMPARE(qjsvalue_cast(str2), quint32(0)); - - QJSValue str3 = QJSValue(QLatin1String("Infinity")); - QCOMPARE(str3.toUInt(), quint32(0)); - QCOMPARE(qjsvalue_cast(str3), quint32(0)); - - QJSValue str3_2 = QJSValue(QLatin1String("-Infinity")); - QCOMPARE(str3_2.toUInt(), quint32(0)); - QCOMPARE(qjsvalue_cast(str3_2), quint32(0)); - - QJSValue str4 = QJSValue(QLatin1String("0.5")); - QCOMPARE(str4.toUInt(), quint32(0)); - QCOMPARE(qjsvalue_cast(str4), quint32(0)); - - QJSValue str5 = QJSValue(QLatin1String("123.5")); - QCOMPARE(str5.toUInt(), quint32(123)); - QCOMPARE(qjsvalue_cast(str5), quint32(123)); - - QJSValue str6 = QJSValue(QLatin1String("-456.5")); - QCOMPARE(str6.toUInt(), quint32(-456)); - QCOMPARE(qjsvalue_cast(str6), quint32(-456)); - } - - QJSValue inv; - QCOMPARE(inv.toUInt(), quint32(0)); - QCOMPARE(qjsvalue_cast(inv), quint32(0)); -} - -#if defined Q_CC_MSVC && _MSC_VER < 1300 -Q_DECLARE_METATYPE(QVariant) -#endif - -void tst_QJSValue::toVariant() -{ - QJSEngine eng; - - QJSValue undefined = eng.toScriptValue(QVariant()); - QCOMPARE(undefined.toVariant(), QVariant()); - QCOMPARE(qjsvalue_cast(undefined), QVariant()); - - QJSValue null = eng.evaluate("null"); - QCOMPARE(null.toVariant(), QVariant()); - QCOMPARE(qjsvalue_cast(null), QVariant()); - - { - QJSValue number = eng.toScriptValue(123.0); - QCOMPARE(number.toVariant(), QVariant(123.0)); - QCOMPARE(qjsvalue_cast(number), QVariant(123.0)); - - QJSValue intNumber = eng.toScriptValue((qint32)123); - QCOMPARE(intNumber.toVariant().type(), QVariant((qint32)123).type()); - QCOMPARE((qjsvalue_cast(number)).type(), QVariant((qint32)123).type()); - - QJSValue falskt = eng.toScriptValue(false); - QCOMPARE(falskt.toVariant(), QVariant(false)); - QCOMPARE(qjsvalue_cast(falskt), QVariant(false)); - - QJSValue sant = eng.toScriptValue(true); - QCOMPARE(sant.toVariant(), QVariant(true)); - QCOMPARE(qjsvalue_cast(sant), QVariant(true)); - - QJSValue str = eng.toScriptValue(QString("ciao")); - QCOMPARE(str.toVariant(), QVariant(QString("ciao"))); - QCOMPARE(qjsvalue_cast(str), QVariant(QString("ciao"))); - } - - QJSValue object = eng.newObject(); - QCOMPARE(object.toVariant(), QVariant(QVariantMap())); - - QJSValue qobject = eng.newQObject(this); - { - QVariant var = qobject.toVariant(); - QCOMPARE(var.userType(), int(QMetaType::QObjectStar)); - QCOMPARE(qVariantValue(var), (QObject *)this); - } - - { - QDateTime dateTime = QDateTime(QDate(1980, 10, 4)); - QJSValue dateObject = eng.toScriptValue(dateTime); - QVariant var = dateObject.toVariant(); - QCOMPARE(var, QVariant(dateTime)); - } - - { - QRegExp rx = QRegExp("[0-9a-z]+", Qt::CaseSensitive, QRegExp::RegExp2); - QJSValue rxObject = eng.toScriptValue(rx); - QVERIFY(rxObject.isRegExp()); - QVariant var = rxObject.toVariant(); - QCOMPARE(var, QVariant(rx)); - } - - QJSValue inv; - QCOMPARE(inv.toVariant(), QVariant()); - QCOMPARE(qjsvalue_cast(inv), QVariant()); - - // V2 constructors - { - QJSValue number = QJSValue(123.0); - QCOMPARE(number.toVariant(), QVariant(123.0)); - QCOMPARE(qjsvalue_cast(number), QVariant(123.0)); - - QJSValue falskt = QJSValue(false); - QCOMPARE(falskt.toVariant(), QVariant(false)); - QCOMPARE(qjsvalue_cast(falskt), QVariant(false)); - - QJSValue sant = QJSValue(true); - QCOMPARE(sant.toVariant(), QVariant(true)); - QCOMPARE(qjsvalue_cast(sant), QVariant(true)); - - QJSValue str = QJSValue(QString("ciao")); - QCOMPARE(str.toVariant(), QVariant(QString("ciao"))); - QCOMPARE(qjsvalue_cast(str), QVariant(QString("ciao"))); - } - -#if 0 // FIXME: No automatic sequence conversion - // array - { - QVariantList listIn; - listIn << 123 << "hello"; - QJSValue array = qScriptValueFromValue(&eng, listIn); - QVERIFY(array.isArray()); - QCOMPARE(array.property("length").toInt(), 2); - QVariant ret = array.toVariant(); - QCOMPARE(ret.type(), QVariant::List); - QVariantList listOut = ret.toList(); - QCOMPARE(listOut.size(), listIn.size()); - for (int i = 0; i < listIn.size(); ++i) - QVERIFY(listOut.at(i) == listIn.at(i)); - // round-trip conversion - QJSValue array2 = qScriptValueFromValue(&eng, ret); - QVERIFY(array2.isArray()); - QCOMPARE(array2.property("length").toInt(), array.property("length").toInt()); - for (int i = 0; i < array.property("length").toInt(); ++i) - QVERIFY(array2.property(i).strictlyEquals(array.property(i))); - } -#endif -} - -void tst_QJSValue::toQObject_nonQObject_data() -{ - newEngine(); - QTest::addColumn("value"); - - QTest::newRow("invalid") << QJSValue(); - QTest::newRow("bool(false)") << QJSValue(false); - QTest::newRow("bool(true)") << QJSValue(true); - QTest::newRow("int") << QJSValue(123); - QTest::newRow("string") << QJSValue(QString::fromLatin1("ciao")); - QTest::newRow("undefined") << QJSValue(QJSValue::UndefinedValue); - QTest::newRow("null") << QJSValue(QJSValue::NullValue); - - QTest::newRow("bool bound(false)") << engine->toScriptValue(false); - QTest::newRow("bool bound(true)") << engine->toScriptValue(true); - QTest::newRow("int bound") << engine->toScriptValue(123); - QTest::newRow("string bound") << engine->toScriptValue(QString::fromLatin1("ciao")); - QTest::newRow("undefined bound") << engine->toScriptValue(QVariant()); - QTest::newRow("null bound") << engine->evaluate("null"); - QTest::newRow("object") << engine->newObject(); - QTest::newRow("array") << engine->newArray(); - QTest::newRow("date") << engine->evaluate("new Date(124)"); - QTest::newRow("variant(12345)") << engine->toScriptValue(QVariant(12345)); - QTest::newRow("variant((QObject*)0)") << engine->toScriptValue(qVariantFromValue((QObject*)0)); - QTest::newRow("newQObject(0)") << engine->newQObject(0); -} - - -void tst_QJSValue::toQObject_nonQObject() -{ - QFETCH(QJSValue, value); - QCOMPARE(value.toQObject(), (QObject *)0); - QCOMPARE(qjsvalue_cast(value), (QObject *)0); -} - -// unfortunately, this is necessary in order to do qscriptvalue_cast(...) -Q_DECLARE_METATYPE(QPushButton*); - -void tst_QJSValue::toQObject() -{ - QJSEngine eng; - - QJSValue qobject = eng.newQObject(this); - QCOMPARE(qobject.toQObject(), (QObject *)this); - QCOMPARE(qjsvalue_cast(qobject), (QObject *)this); - QCOMPARE(qjsvalue_cast(qobject), (QWidget *)0); - - QWidget widget; - QJSValue qwidget = eng.newQObject(&widget); - QCOMPARE(qwidget.toQObject(), (QObject *)&widget); - QCOMPARE(qjsvalue_cast(qwidget), (QObject *)&widget); - QCOMPARE(qjsvalue_cast(qwidget), &widget); - - QPushButton button; - QJSValue qbutton = eng.newQObject(&button); - QCOMPARE(qbutton.toQObject(), (QObject *)&button); - QCOMPARE(qjsvalue_cast(qbutton), (QObject *)&button); - QCOMPARE(qjsvalue_cast(qbutton), (QWidget *)&button); - QCOMPARE(qjsvalue_cast(qbutton), &button); -} - -void tst_QJSValue::toDateTime() -{ - QJSEngine eng; - QDateTime dt = eng.evaluate("new Date(0)").toDateTime(); - QVERIFY(dt.isValid()); - QCOMPARE(dt.timeSpec(), Qt::LocalTime); - QCOMPARE(dt.toUTC(), QDateTime(QDate(1970, 1, 1), QTime(0, 0, 0), Qt::UTC)); - - QVERIFY(!eng.evaluate("[]").toDateTime().isValid()); - QVERIFY(!eng.evaluate("{}").toDateTime().isValid()); - QVERIFY(!eng.globalObject().toDateTime().isValid()); - QVERIFY(!QJSValue().toDateTime().isValid()); - QVERIFY(!QJSValue(123).toDateTime().isValid()); - QVERIFY(!QJSValue(false).toDateTime().isValid()); - QVERIFY(!eng.evaluate("null").toDateTime().isValid()); - QVERIFY(!eng.toScriptValue(QVariant()).toDateTime().isValid()); -} - -void tst_QJSValue::toRegExp() -{ - QJSEngine eng; - { - QRegExp rx = qjsvalue_cast(eng.evaluate("/foo/")); - QVERIFY(rx.isValid()); - QCOMPARE(rx.patternSyntax(), QRegExp::RegExp2); - QCOMPARE(rx.pattern(), QString::fromLatin1("foo")); - QCOMPARE(rx.caseSensitivity(), Qt::CaseSensitive); - QVERIFY(!rx.isMinimal()); - } - { - QRegExp rx = qjsvalue_cast(eng.evaluate("/bar/gi")); - QVERIFY(rx.isValid()); - QCOMPARE(rx.patternSyntax(), QRegExp::RegExp2); - QCOMPARE(rx.pattern(), QString::fromLatin1("bar")); - QCOMPARE(rx.caseSensitivity(), Qt::CaseInsensitive); - QVERIFY(!rx.isMinimal()); - } - - QVERIFY(qjsvalue_cast(eng.evaluate("[]")).isEmpty()); - QVERIFY(qjsvalue_cast(eng.evaluate("{}")).isEmpty()); - QVERIFY(qjsvalue_cast(eng.globalObject()).isEmpty()); - QVERIFY(qjsvalue_cast(QJSValue()).isEmpty()); - QVERIFY(qjsvalue_cast(QJSValue(123)).isEmpty()); - QVERIFY(qjsvalue_cast(QJSValue(false)).isEmpty()); - QVERIFY(qjsvalue_cast(eng.evaluate("null")).isEmpty()); - QVERIFY(qjsvalue_cast(eng.toScriptValue(QVariant())).isEmpty()); -} - -void tst_QJSValue::isArray_data() -{ - newEngine(); - - QTest::addColumn("value"); - QTest::addColumn("array"); - - QTest::newRow("[]") << engine->evaluate("[]") << true; - QTest::newRow("{}") << engine->evaluate("{}") << false; - QTest::newRow("globalObject") << engine->globalObject() << false; - QTest::newRow("invalid") << QJSValue() << false; - QTest::newRow("number") << QJSValue(123) << false; - QTest::newRow("bool") << QJSValue(false) << false; - QTest::newRow("null") << engine->evaluate("null") << false; - QTest::newRow("undefined") << engine->toScriptValue(QVariant()) << false; -} - -void tst_QJSValue::isArray() -{ - QFETCH(QJSValue, value); - QFETCH(bool, array); - - QCOMPARE(value.isArray(), array); -} - -void tst_QJSValue::isDate_data() -{ - newEngine(); - - QTest::addColumn("value"); - QTest::addColumn("date"); - - QTest::newRow("date") << engine->evaluate("new Date()") << true; - QTest::newRow("[]") << engine->evaluate("[]") << false; - QTest::newRow("{}") << engine->evaluate("{}") << false; - QTest::newRow("globalObject") << engine->globalObject() << false; - QTest::newRow("invalid") << QJSValue() << false; - QTest::newRow("number") << QJSValue(123) << false; - QTest::newRow("bool") << QJSValue(false) << false; - QTest::newRow("null") << engine->evaluate("null") << false; - QTest::newRow("undefined") << engine->toScriptValue(QVariant()) << false; -} - -void tst_QJSValue::isDate() -{ - QFETCH(QJSValue, value); - QFETCH(bool, date); - - QCOMPARE(value.isDate(), date); -} - -void tst_QJSValue::isError_propertiesOfGlobalObject() -{ - QStringList errors; - errors << "Error" - << "EvalError" - << "RangeError" - << "ReferenceError" - << "SyntaxError" - << "TypeError" - << "URIError"; - QJSEngine eng; - for (int i = 0; i < errors.size(); ++i) { - QJSValue ctor = eng.globalObject().property(errors.at(i)); - QVERIFY(ctor.isCallable()); - QVERIFY(ctor.property("prototype").isError()); - } -} - -void tst_QJSValue::isError_data() -{ - newEngine(); - - QTest::addColumn("value"); - QTest::addColumn("error"); - - QTest::newRow("syntax error") << engine->evaluate("%fsdg's") << true; - QTest::newRow("[]") << engine->evaluate("[]") << false; - QTest::newRow("{}") << engine->evaluate("{}") << false; - QTest::newRow("globalObject") << engine->globalObject() << false; - QTest::newRow("invalid") << QJSValue() << false; - QTest::newRow("number") << QJSValue(123) << false; - QTest::newRow("bool") << QJSValue(false) << false; - QTest::newRow("null") << engine->evaluate("null") << false; - QTest::newRow("undefined") << engine->toScriptValue(QVariant()) << false; - QTest::newRow("newObject") << engine->newObject() << false; - QTest::newRow("new Object") << engine->evaluate("new Object()") << false; -} - -void tst_QJSValue::isError() -{ - QFETCH(QJSValue, value); - QFETCH(bool, error); - - QCOMPARE(value.isError(), error); -} - -void tst_QJSValue::isRegExp_data() -{ - newEngine(); - - QTest::addColumn("value"); - QTest::addColumn("regexp"); - - QTest::newRow("/foo/") << engine->evaluate("/foo/") << true; - QTest::newRow("[]") << engine->evaluate("[]") << false; - QTest::newRow("{}") << engine->evaluate("{}") << false; - QTest::newRow("globalObject") << engine->globalObject() << false; - QTest::newRow("invalid") << QJSValue() << false; - QTest::newRow("number") << QJSValue(123) << false; - QTest::newRow("bool") << QJSValue(false) << false; - QTest::newRow("null") << engine->evaluate("null") << false; - QTest::newRow("undefined") << engine->toScriptValue(QVariant()) << false; -} - -void tst_QJSValue::isRegExp() -{ - QFETCH(QJSValue, value); - QFETCH(bool, regexp); - - QCOMPARE(value.isRegExp(), regexp); -} - -#if 0 // FIXME: No c-style callbacks currently -static QJSValue getter(QScriptContext *ctx, QScriptEngine *) -{ - return ctx->thisObject().property("x"); -} - -static QJSValue setter(QScriptContext *ctx, QScriptEngine *) -{ - ctx->thisObject().setProperty("x", ctx->argument(0)); - return ctx->argument(0); -} - -static QJSValue getterSetter(QScriptContext *ctx, QScriptEngine *) -{ - if (ctx->argumentCount() > 0) - ctx->thisObject().setProperty("x", ctx->argument(0)); - return ctx->thisObject().property("x"); -} - -static QJSValue getterSetterThrowingError(QScriptContext *ctx, QScriptEngine *) -{ - if (ctx->argumentCount() > 0) - return ctx->throwError("set foo"); - else - return ctx->throwError("get foo"); -} - -static QJSValue getSet__proto__(QScriptContext *ctx, QScriptEngine *) -{ - if (ctx->argumentCount() > 0) - ctx->callee().setProperty("value", ctx->argument(0)); - return ctx->callee().property("value"); -} -#endif - -void tst_QJSValue::hasProperty_basic() -{ - QJSEngine eng; - QJSValue obj = eng.newObject(); - QVERIFY(obj.hasProperty("hasOwnProperty")); // inherited from Object.prototype - QVERIFY(!obj.hasOwnProperty("hasOwnProperty")); - - QVERIFY(!obj.hasProperty("foo")); - QVERIFY(!obj.hasOwnProperty("foo")); - obj.setProperty("foo", 123); - QVERIFY(obj.hasProperty("foo")); - QVERIFY(obj.hasOwnProperty("foo")); - - QVERIFY(!obj.hasProperty("bar")); - QVERIFY(!obj.hasOwnProperty("bar")); -} - -void tst_QJSValue::hasProperty_globalObject() -{ - QJSEngine eng; - QJSValue global = eng.globalObject(); - QVERIFY(global.hasProperty("Math")); - QVERIFY(global.hasOwnProperty("Math")); - QVERIFY(!global.hasProperty("NoSuchStandardProperty")); - QVERIFY(!global.hasOwnProperty("NoSuchStandardProperty")); - - QVERIFY(!global.hasProperty("foo")); - QVERIFY(!global.hasOwnProperty("foo")); - global.setProperty("foo", 123); - QVERIFY(global.hasProperty("foo")); - QVERIFY(global.hasOwnProperty("foo")); -} - -void tst_QJSValue::hasProperty_changePrototype() -{ - QJSEngine eng; - QJSValue obj = eng.newObject(); - QJSValue proto = eng.newObject(); - obj.setPrototype(proto); - - QVERIFY(!obj.hasProperty("foo")); - QVERIFY(!obj.hasOwnProperty("foo")); - proto.setProperty("foo", 123); - QVERIFY(obj.hasProperty("foo")); - QVERIFY(!obj.hasOwnProperty("foo")); - - obj.setProperty("foo", 456); // override prototype property - QVERIFY(obj.hasProperty("foo")); - QVERIFY(obj.hasOwnProperty("foo")); -} - -void tst_QJSValue::deleteProperty_basic() -{ - QJSEngine eng; - QJSValue obj = eng.newObject(); - // deleteProperty() behavior matches JS delete operator - QVERIFY(obj.deleteProperty("foo")); - - obj.setProperty("foo", 123); - QVERIFY(obj.deleteProperty("foo")); - QVERIFY(!obj.hasOwnProperty("foo")); -} - -void tst_QJSValue::deleteProperty_globalObject() -{ - QJSEngine eng; - QJSValue global = eng.globalObject(); - // deleteProperty() behavior matches JS delete operator - QVERIFY(global.deleteProperty("foo")); - - global.setProperty("foo", 123); - QVERIFY(global.deleteProperty("foo")); - QVERIFY(!global.hasProperty("foo")); - - QVERIFY(global.deleteProperty("Math")); - QVERIFY(!global.hasProperty("Math")); - - QVERIFY(!global.deleteProperty("NaN")); // read-only - QVERIFY(global.hasProperty("NaN")); -} - -void tst_QJSValue::deleteProperty_inPrototype() -{ - QJSEngine eng; - QJSValue obj = eng.newObject(); - QJSValue proto = eng.newObject(); - obj.setPrototype(proto); - - proto.setProperty("foo", 123); - QVERIFY(obj.hasProperty("foo")); - // deleteProperty() behavior matches JS delete operator - QVERIFY(obj.deleteProperty("foo")); - QVERIFY(obj.hasProperty("foo")); -} - -void tst_QJSValue::getSetProperty_HooliganTask162051() -{ - QJSEngine eng; - // task 162051 -- detecting whether the property is an array index or not - QVERIFY(eng.evaluate("a = []; a['00'] = 123; a['00']").strictlyEquals(eng.toScriptValue(123))); - QVERIFY(eng.evaluate("a.length").strictlyEquals(eng.toScriptValue(0))); - QVERIFY(eng.evaluate("a.hasOwnProperty('00')").strictlyEquals(eng.toScriptValue(true))); - QVERIFY(eng.evaluate("a.hasOwnProperty('0')").strictlyEquals(eng.toScriptValue(false))); - QVERIFY(eng.evaluate("a[0]").isUndefined()); - QVERIFY(eng.evaluate("a[0.5] = 456; a[0.5]").strictlyEquals(eng.toScriptValue(456))); - QVERIFY(eng.evaluate("a.length").strictlyEquals(eng.toScriptValue(0))); - QVERIFY(eng.evaluate("a.hasOwnProperty('0.5')").strictlyEquals(eng.toScriptValue(true))); - QVERIFY(eng.evaluate("a[0]").isUndefined()); - QVERIFY(eng.evaluate("a[0] = 789; a[0]").strictlyEquals(eng.toScriptValue(789))); - QVERIFY(eng.evaluate("a.length").strictlyEquals(eng.toScriptValue(1))); -} - -void tst_QJSValue::getSetProperty_HooliganTask183072() -{ - QJSEngine eng; - // task 183072 -- 0x800000000 is not an array index - eng.evaluate("a = []; a[0x800000000] = 123"); - QVERIFY(eng.evaluate("a.length").strictlyEquals(eng.toScriptValue(0))); - QVERIFY(eng.evaluate("a[0]").isUndefined()); - QVERIFY(eng.evaluate("a[0x800000000]").strictlyEquals(eng.toScriptValue(123))); -} - -void tst_QJSValue::getSetProperty_propertyRemoval() -{ - QJSEngine eng; - QJSValue object = eng.newObject(); - QJSValue str = eng.toScriptValue(QString::fromLatin1("bar")); - QJSValue num = eng.toScriptValue(123.0); - - object.setProperty("foo", num); - QCOMPARE(object.property("foo").strictlyEquals(num), true); - object.setProperty("bar", str); - QCOMPARE(object.property("bar").strictlyEquals(str), true); - QVERIFY(object.deleteProperty("foo")); - QVERIFY(!object.hasOwnProperty("foo")); - QCOMPARE(object.property("bar").strictlyEquals(str), true); - object.setProperty("foo", num); - QCOMPARE(object.property("foo").strictlyEquals(num), true); - QCOMPARE(object.property("bar").strictlyEquals(str), true); - QVERIFY(object.deleteProperty("bar")); - QVERIFY(!object.hasOwnProperty("bar")); - QCOMPARE(object.property("foo").strictlyEquals(num), true); - QVERIFY(object.deleteProperty("foo")); - QVERIFY(!object.hasOwnProperty("foo")); - - eng.globalObject().setProperty("object3", object); - QCOMPARE(eng.evaluate("object3.hasOwnProperty('foo')") - .strictlyEquals(eng.toScriptValue(false)), true); - object.setProperty("foo", num); - QCOMPARE(eng.evaluate("object3.hasOwnProperty('foo')") - .strictlyEquals(eng.toScriptValue(true)), true); - QVERIFY(eng.globalObject().deleteProperty("object3")); - QCOMPARE(eng.evaluate("this.hasOwnProperty('object3')") - .strictlyEquals(eng.toScriptValue(false)), true); -} - -void tst_QJSValue::getSetProperty_resolveMode() -{ - // test ResolveMode - QJSEngine eng; - QJSValue object = eng.newObject(); - QJSValue prototype = eng.newObject(); - object.setPrototype(prototype); - QJSValue num2 = eng.toScriptValue(456.0); - prototype.setProperty("propertyInPrototype", num2); - // default is ResolvePrototype - QCOMPARE(object.property("propertyInPrototype") - .strictlyEquals(num2), true); -#if 0 // FIXME: ResolveFlags removed from API - QCOMPARE(object.property("propertyInPrototype", QJSValue::ResolvePrototype) - .strictlyEquals(num2), true); - QCOMPARE(object.property("propertyInPrototype", QJSValue::ResolveLocal) - .isValid(), false); - QCOMPARE(object.property("propertyInPrototype", QJSValue::ResolveScope) - .strictlyEquals(num2), false); - QCOMPARE(object.property("propertyInPrototype", QJSValue::ResolveFull) - .strictlyEquals(num2), true); -#endif -} - -void tst_QJSValue::getSetProperty_twoEngines() -{ - QJSEngine engine; - QJSValue object = engine.newObject(); - - QJSEngine otherEngine; - QJSValue otherNum = otherEngine.toScriptValue(123); - QTest::ignoreMessage(QtWarningMsg, "QJSValue::setProperty(oof) failed: cannot set value created in a different engine"); - object.setProperty("oof", otherNum); - QVERIFY(!object.hasOwnProperty("oof")); - QVERIFY(object.property("oof").isUndefined()); -} - - -void tst_QJSValue::getSetProperty_gettersAndSetters() -{ -#if 0 // FIXME: No setters/getters right now - QScriptEngine eng; - QJSValue str = eng.toScriptValue(QString::fromLatin1("bar")); - QJSValue num = eng.toScriptValue(123.0); - QJSValue object = eng.newObject(); - for (int x = 0; x < 2; ++x) { - object.deleteProperty("foo"); - // getter() returns this.x - object.setProperty("foo", eng.newFunction(getter), - QJSValue::PropertyGetter | QJSValue::UserRange); - QCOMPARE(object.propertyFlags("foo") & ~QJSValue::UserRange, - QJSValue::PropertyGetter ); - - QEXPECT_FAIL("", "QTBUG-17615: User-range flags are not retained for getter/setter properties", Continue); - QCOMPARE(object.propertyFlags("foo"), - QJSValue::PropertyGetter | QJSValue::UserRange); - object.setProperty("x", num); - QCOMPARE(object.property("foo").strictlyEquals(num), true); - - // setter() sets this.x - object.setProperty("foo", eng.newFunction(setter), - QJSValue::PropertySetter); - QCOMPARE(object.propertyFlags("foo") & ~QJSValue::UserRange, - QJSValue::PropertySetter | QJSValue::PropertyGetter); - - QCOMPARE(object.propertyFlags("foo"), - QJSValue::PropertySetter | QJSValue::PropertyGetter); - object.setProperty("foo", str); - QCOMPARE(object.property("x").strictlyEquals(str), true); - QCOMPARE(object.property("foo").strictlyEquals(str), true); - - // kill the getter - object.setProperty("foo", QJSValue(), QJSValue::PropertyGetter); - QVERIFY(!(object.propertyFlags("foo") & QJSValue::PropertyGetter)); - QVERIFY(object.propertyFlags("foo") & QJSValue::PropertySetter); - QCOMPARE(object.property("foo").isUndefined(), true); - - // setter should still work - object.setProperty("foo", num); - QCOMPARE(object.property("x").strictlyEquals(num), true); - - // kill the setter too - object.setProperty("foo", QJSValue(), QJSValue::PropertySetter); - QVERIFY(!(object.propertyFlags("foo") & QJSValue::PropertySetter)); - // now foo is just a regular property - object.setProperty("foo", str); - QCOMPARE(object.property("x").strictlyEquals(num), true); - QCOMPARE(object.property("foo").strictlyEquals(str), true); - } - - for (int x = 0; x < 2; ++x) { - object.deleteProperty("foo"); - // setter() sets this.x - object.setProperty("foo", eng.newFunction(setter), QJSValue::PropertySetter); - object.setProperty("foo", str); - QCOMPARE(object.property("x").strictlyEquals(str), true); - QCOMPARE(object.property("foo").isUndefined(), true); - - // getter() returns this.x - object.setProperty("foo", eng.newFunction(getter), QJSValue::PropertyGetter); - object.setProperty("x", num); - QCOMPARE(object.property("foo").strictlyEquals(num), true); - - // kill the setter - object.setProperty("foo", QJSValue(), QJSValue::PropertySetter); - object.setProperty("foo", str); - - // getter should still work - QCOMPARE(object.property("foo").strictlyEquals(num), true); - - // kill the getter too - object.setProperty("foo", QJSValue(), QJSValue::PropertyGetter); - // now foo is just a regular property - object.setProperty("foo", str); - QCOMPARE(object.property("x").strictlyEquals(num), true); - QCOMPARE(object.property("foo").strictlyEquals(str), true); - } - - // use a single function as both getter and setter - object.deleteProperty("foo"); - object.setProperty("foo", eng.newFunction(getterSetter), - QJSValue::PropertyGetter | QJSValue::PropertySetter); - QCOMPARE(object.propertyFlags("foo"), - QJSValue::PropertyGetter | QJSValue::PropertySetter); - object.setProperty("x", num); - QCOMPARE(object.property("foo").strictlyEquals(num), true); - - // killing the getter will preserve the setter, even though they are the same function - object.setProperty("foo", QJSValue(), QJSValue::PropertyGetter); - QVERIFY(object.propertyFlags("foo") & QJSValue::PropertySetter); - QCOMPARE(object.property("foo").isUndefined(), true); -#endif -} - -void tst_QJSValue::getSetProperty_gettersAndSettersThrowErrorNative() -{ -#if 0 // FIXME: No setters/getters right now - // getter/setter that throws an error - QScriptEngine eng; - QJSValue str = eng.toScriptValue("bar"); - QJSValue object = eng.newObject(); - - object.setProperty("foo", eng.newFunction(getterSetterThrowingError), - QJSValue::PropertyGetter | QJSValue::PropertySetter); - QVERIFY(!eng.hasUncaughtException()); - QJSValue ret = object.property("foo"); - QVERIFY(ret.isError()); - QVERIFY(eng.hasUncaughtException()); - QVERIFY(ret.strictlyEquals(eng.uncaughtException())); - QCOMPARE(ret.toString(), QLatin1String("Error: get foo")); - eng.evaluate("Object"); // clear exception state... - QVERIFY(!eng.hasUncaughtException()); - object.setProperty("foo", str); - QVERIFY(eng.hasUncaughtException()); - QCOMPARE(eng.uncaughtException().toString(), QLatin1String("Error: set foo")); -#endif -} - -void tst_QJSValue::getSetProperty_gettersAndSettersThrowErrorJS() -{ - // getter/setter that throws an error (from js function) - QJSEngine eng; - QJSValue str = eng.toScriptValue(QString::fromLatin1("bar")); - - eng.evaluate("o = new Object; " - "o.__defineGetter__('foo', function() { throw new Error('get foo') }); " - "o.__defineSetter__('foo', function() { throw new Error('set foo') }); "); - QJSValue object = eng.evaluate("o"); - QVERIFY(!eng.hasUncaughtException()); - QJSValue ret = object.property("foo"); - QVERIFY(ret.isError()); - QVERIFY(eng.hasUncaughtException()); - QVERIFY(ret.strictlyEquals(eng.uncaughtException())); - QCOMPARE(ret.toString(), QLatin1String("Error: get foo")); - eng.evaluate("Object"); // clear exception state... - QVERIFY(!eng.hasUncaughtException()); - object.setProperty("foo", str); - QVERIFY(eng.hasUncaughtException()); - QCOMPARE(eng.uncaughtException().toString(), QLatin1String("Error: set foo")); -} - -void tst_QJSValue::getSetProperty_gettersAndSettersOnNative() -{ -#if 0 // FIXME: No c-style functions right now - // attempt to install getter+setter on built-in (native) property - QScriptEngine eng; - QJSValue object = eng.newObject(); - QVERIFY(object.property("__proto__").strictlyEquals(object.prototype())); - - QJSValue fun = eng.newFunction(getSet__proto__); - fun.setProperty("value", eng.toScriptValue("boo")); -/* QTest::ignoreMessage(QtWarningMsg, "QJSValue::setProperty() failed: " - "cannot set getter or setter of native property " - "`__proto__'");*/ - object.setProperty("__proto__", fun, - QJSValue::PropertyGetter | QJSValue::PropertySetter - | QJSValue::UserRange); - QVERIFY(object.property("__proto__").strictlyEquals(object.prototype())); - - object.setProperty("__proto__", QJSValue(), - QJSValue::PropertyGetter | QJSValue::PropertySetter); - QVERIFY(object.property("__proto__").strictlyEquals(object.prototype())); -#endif -} - -void tst_QJSValue::getSetProperty_gettersAndSettersOnGlobalObject() -{ -#if 0 // FIXME: No c-style functions right now - // global property that's a getter+setter - QScriptEngine eng; - eng.globalObject().setProperty("globalGetterSetterProperty", eng.newFunction(getterSetter), - QJSValue::PropertyGetter | QJSValue::PropertySetter); - eng.evaluate("globalGetterSetterProperty = 123"); - { - QJSValue ret = eng.evaluate("globalGetterSetterProperty"); - QVERIFY(ret.isNumber()); - QVERIFY(ret.strictlyEquals(eng.toScriptValue(123))); - } - QCOMPARE(eng.evaluate("typeof globalGetterSetterProperty").toString(), - QString::fromLatin1("number")); - { - QJSValue ret = eng.evaluate("this.globalGetterSetterProperty()"); - QVERIFY(ret.isError()); - QCOMPARE(ret.toString(), QString::fromLatin1("TypeError: Property 'globalGetterSetterProperty' of object # is not a function")); - } - { - QJSValue ret = eng.evaluate("new this.globalGetterSetterProperty()"); - QVERIFY(ret.isError()); - QCOMPARE(ret.toString(), QString::fromLatin1("TypeError: number is not a function")); - } -#endif -} - -void tst_QJSValue::getSetProperty_gettersAndSettersChange() -{ -#if 0 // FIXME: No setters/getters API right now - // "upgrading" an existing property to become a getter+setter - QScriptEngine eng; - QJSValue object = eng.newObject(); - QJSValue num(&eng, 123); - object.setProperty("foo", num); - object.setProperty("foo", eng.newFunction(getterSetter), - QJSValue::PropertyGetter | QJSValue::PropertySetter); - QVERIFY(!object.property("x").isValid()); - object.setProperty("foo", num); - QVERIFY(object.property("x").equals(num)); - - eng.globalObject().setProperty("object", object); - QJSValue res = eng.evaluate("object.x = 89; var a = object.foo; object.foo = 65; a"); - QCOMPARE(res.toInt(), 89); - QCOMPARE(object.property("x").toInt(), 65); - QCOMPARE(object.property("foo").toInt(), 65); -#endif -} - -void tst_QJSValue::getSetProperty_array() -{ - QJSEngine eng; - QJSValue str = eng.toScriptValue(QString::fromLatin1("bar")); - QJSValue num = eng.toScriptValue(123.0); - QJSValue array = eng.newArray(); - - QVERIFY(array.isArray()); - array.setProperty(0, num); - QCOMPARE(array.property(0).toNumber(), num.toNumber()); - QCOMPARE(array.property("0").toNumber(), num.toNumber()); - QCOMPARE(array.property("length").toUInt(), quint32(1)); - array.setProperty(1, str); - QCOMPARE(array.property(1).toString(), str.toString()); - QCOMPARE(array.property("1").toString(), str.toString()); - QCOMPARE(array.property("length").toUInt(), quint32(2)); - array.setProperty("length", eng.toScriptValue(1)); - QCOMPARE(array.property("length").toUInt(), quint32(1)); - QVERIFY(array.property(1).isUndefined()); -} - -void tst_QJSValue::getSetProperty_gettersAndSettersStupid() -{ -#if 0 // FIXME: No setters/getters API right now - //removing unexisting Setter or Getter should not crash. - QScriptEngine eng; - QJSValue num = eng.toScriptValue(123.0); - - { - QJSValue object = eng.newObject(); - object.setProperty("foo", QJSValue(), QJSValue::PropertyGetter); - QVERIFY(!object.property("foo").isValid()); - object.setProperty("foo", num); - QCOMPARE(object.property("foo").strictlyEquals(num), true); - } - - { - QJSValue object = eng.newObject(); - object.setProperty("foo", QJSValue(), QJSValue::PropertySetter); - QVERIFY(!object.property("foo").isValid()); - object.setProperty("foo", num); - QCOMPARE(object.property("foo").strictlyEquals(num), true); - } - - { - QJSValue object = eng.globalObject(); - object.setProperty("foo", QJSValue(), QJSValue::PropertySetter); - object.setProperty("foo", QJSValue(), QJSValue::PropertyGetter); - QVERIFY(!object.property("foo").isValid()); - object.setProperty("foo", num); - QCOMPARE(object.property("foo").strictlyEquals(num), true); - } -#endif -} - -void tst_QJSValue::getSetProperty() -{ - QJSEngine eng; - - QJSValue object = eng.newObject(); - - QJSValue str = eng.toScriptValue(QString::fromLatin1("bar")); - object.setProperty("foo", str); - QCOMPARE(object.property("foo").toString(), str.toString()); - - QJSValue num = eng.toScriptValue(123.0); - object.setProperty("baz", num); - QCOMPARE(object.property("baz").toNumber(), num.toNumber()); - - QJSValue strstr = QJSValue("bar"); - QCOMPARE(strstr.engine(), (QJSEngine *)0); - object.setProperty("foo", strstr); - QCOMPARE(object.property("foo").toString(), strstr.toString()); - QCOMPARE(strstr.engine(), &eng); // the value has been bound to the engine - - QJSValue numnum = QJSValue(123.0); - object.setProperty("baz", numnum); - QCOMPARE(object.property("baz").toNumber(), numnum.toNumber()); - - QJSValue inv; - inv.setProperty("foo", num); - QCOMPARE(inv.property("foo").isUndefined(), true); - - eng.globalObject().setProperty("object", object); - -#if 0 // FIXME: no setProperty API with flags - // ReadOnly - object.setProperty("readOnlyProperty", num, QJSValue::ReadOnly); - QCOMPARE(object.propertyFlags("readOnlyProperty"), QJSValue::ReadOnly); - QCOMPARE(object.property("readOnlyProperty").strictlyEquals(num), true); - eng.evaluate("object.readOnlyProperty = !object.readOnlyProperty"); - QCOMPARE(object.property("readOnlyProperty").strictlyEquals(num), true); - // should still be part of enumeration - { - QJSValue ret = eng.evaluate( - "found = false;" - "for (var p in object) {" - " if (p == 'readOnlyProperty') {" - " found = true; break;" - " }" - "} found"); - QCOMPARE(ret.strictlyEquals(eng.toScriptValue(true)), true); - } - // should still be deletable - { - QJSValue ret = eng.evaluate("delete object.readOnlyProperty"); - QCOMPARE(ret.strictlyEquals(eng.toScriptValue(true)), true); - QCOMPARE(object.property("readOnlyProperty").isValid(), false); - } - - // Undeletable - object.setProperty("undeletableProperty", num, QJSValue::Undeletable); - QCOMPARE(object.propertyFlags("undeletableProperty"), QJSValue::Undeletable); - QCOMPARE(object.property("undeletableProperty").strictlyEquals(num), true); - { - QJSValue ret = eng.evaluate("delete object.undeletableProperty"); - QCOMPARE(ret.strictlyEquals(eng.toScriptValue(true)), false); - QCOMPARE(object.property("undeletableProperty").strictlyEquals(num), true); - } - // should still be writable - eng.evaluate("object.undeletableProperty = object.undeletableProperty + 1"); - QCOMPARE(object.property("undeletableProperty").toNumber(), num.toNumber() + 1); - // should still be part of enumeration - { - QJSValue ret = eng.evaluate( - "found = false;" - "for (var p in object) {" - " if (p == 'undeletableProperty') {" - " found = true; break;" - " }" - "} found"); - QCOMPARE(ret.strictlyEquals(eng.toScriptValue(true)), true); - } - // should still be deletable from C++ - object.deleteProperty("undeletableProperty"); - QEXPECT_FAIL("", "QTBUG-17617: With JSC-based back-end, undeletable properties can't be deleted from C++", Continue); - QVERIFY(!object.property("undeletableProperty").isValid()); - QEXPECT_FAIL("", "QTBUG-17617: With JSC-based back-end, undeletable properties can't be deleted from C++", Continue); - QCOMPARE(object.propertyFlags("undeletableProperty"), 0); - - // SkipInEnumeration - object.setProperty("dontEnumProperty", num, QJSValue::SkipInEnumeration); - QCOMPARE(object.propertyFlags("dontEnumProperty"), QJSValue::SkipInEnumeration); - QCOMPARE(object.property("dontEnumProperty").strictlyEquals(num), true); - // should not be part of enumeration - { - QJSValue ret = eng.evaluate( - "found = false;" - "for (var p in object) {" - " if (p == 'dontEnumProperty') {" - " found = true; break;" - " }" - "} found"); - QCOMPARE(ret.strictlyEquals(eng.toScriptValue(false)), true); - } - // should still be writable - eng.evaluate("object.dontEnumProperty = object.dontEnumProperty + 1"); - QCOMPARE(object.property("dontEnumProperty").toNumber(), num.toNumber() + 1); - // should still be deletable - { - QJSValue ret = eng.evaluate("delete object.dontEnumProperty"); - QCOMPARE(ret.strictlyEquals(eng.toScriptValue(true)), true); - QCOMPARE(object.property("dontEnumProperty").isValid(), false); - } - - // change flags - object.setProperty("flagProperty", str); - QCOMPARE(object.propertyFlags("flagProperty"), static_cast(0)); - - QEXPECT_FAIL("", "FIXME: v8 does not support changing flags of existing properties", Continue); - //v8::i::JSObject::SetProperty(LookupResult* result, ... ) does not take in account the attributes - // if the result->isFound() - object.setProperty("flagProperty", str, QJSValue::ReadOnly); - QCOMPARE(object.propertyFlags("flagProperty"), QJSValue::ReadOnly); - - QEXPECT_FAIL("", "FIXME: v8 does not support changing flags of existing properties", Continue); - object.setProperty("flagProperty", str, object.propertyFlags("flagProperty") | QJSValue::SkipInEnumeration); - QCOMPARE(object.propertyFlags("flagProperty"), QJSValue::ReadOnly | QJSValue::SkipInEnumeration); - - QEXPECT_FAIL("", "FIXME: v8 does not support changing flags of existing properties", Continue); - object.setProperty("flagProperty", str, QJSValue::KeepExistingFlags); - QCOMPARE(object.propertyFlags("flagProperty"), QJSValue::ReadOnly | QJSValue::SkipInEnumeration); - - QEXPECT_FAIL("", "FIXME: v8 does not support UserRange", Continue); - object.setProperty("flagProperty", str, QJSValue::UserRange); - QCOMPARE(object.propertyFlags("flagProperty"), QJSValue::UserRange); - - // flags of property in the prototype - { - QJSValue object2 = eng.newObject(); - object2.setPrototype(object); - QCOMPARE(object2.propertyFlags("flagProperty", QJSValue::ResolveLocal), 0); - QEXPECT_FAIL("", "FIXME: v8 does not support UserRange", Continue); - QCOMPARE(object2.propertyFlags("flagProperty"), QJSValue::UserRange); - } - - // using interned strings - QScriptString foo = eng.toStringHandle("foo"); - - QVERIFY(object.deleteProperty(foo)); - QVERIFY(!object.property(foo).isValid()); - - object.setProperty(foo, num); - QVERIFY(object.property(foo).strictlyEquals(num)); - QVERIFY(object.property("foo").strictlyEquals(num)); - QVERIFY(object.propertyFlags(foo) == 0); -#endif - - // Setting index property on non-Array - object.setProperty(13, num); - QVERIFY(object.property(13).equals(num)); -} - -void tst_QJSValue::arrayElementGetterSetter() -{ -#if 0 // FIXME: No c-style functions - QScriptEngine eng; - QJSValue obj = eng.newObject(); - obj.setProperty(1, eng.newFunction(getterSetter), QJSValue::PropertyGetter|QJSValue::PropertySetter); - { - QJSValue num(123); - obj.setProperty("x", num); - QJSValue ret = obj.property(1); - QVERIFY(ret.isValid()); - QVERIFY(ret.equals(num)); - } - { - QJSValue num(456); - obj.setProperty(1, num); - QJSValue ret = obj.property(1); - QVERIFY(ret.isValid()); - QVERIFY(ret.equals(num)); - QVERIFY(ret.equals(obj.property("1"))); - } - QCOMPARE(obj.propertyFlags("1"), QJSValue::PropertyGetter|QJSValue::PropertySetter); - - obj.setProperty(1, QJSValue(), QJSValue::PropertyGetter|QJSValue::PropertySetter); - QVERIFY(obj.propertyFlags("1") == 0); -#endif -} - -void tst_QJSValue::getSetPrototype_cyclicPrototype() -{ - QJSEngine eng; - QJSValue prototype = eng.newObject(); - QJSValue object = eng.newObject(); - object.setPrototype(prototype); - - QJSValue previousPrototype = prototype.prototype(); - QTest::ignoreMessage(QtWarningMsg, "QJSValue::setPrototype() failed: cyclic prototype value"); - prototype.setPrototype(prototype); - QCOMPARE(prototype.prototype().strictlyEquals(previousPrototype), true); - - object.setPrototype(prototype); - QTest::ignoreMessage(QtWarningMsg, "QJSValue::setPrototype() failed: cyclic prototype value"); - prototype.setPrototype(object); - QCOMPARE(prototype.prototype().strictlyEquals(previousPrototype), true); - -} - -void tst_QJSValue::getSetPrototype_evalCyclicPrototype() -{ - QJSEngine eng; - QJSValue ret = eng.evaluate("o = { }; p = { }; o.__proto__ = p; p.__proto__ = o"); - QCOMPARE(eng.hasUncaughtException(), true); - QVERIFY(ret.strictlyEquals(eng.uncaughtException())); - QCOMPARE(ret.isError(), true); - QCOMPARE(ret.toString(), QLatin1String("Error: Cyclic __proto__ value")); -} - -void tst_QJSValue::getSetPrototype_eval() -{ - QJSEngine eng; - QJSValue ret = eng.evaluate("p = { }; p.__proto__ = { }"); - QCOMPARE(eng.hasUncaughtException(), false); - QCOMPARE(ret.isError(), false); -} - -void tst_QJSValue::getSetPrototype_invalidPrototype() -{ - QJSEngine eng; - QJSValue inv; - QJSValue object = eng.newObject(); - QJSValue proto = object.prototype(); - QVERIFY(object.prototype().strictlyEquals(proto)); - inv.setPrototype(object); - QVERIFY(inv.prototype().isUndefined()); - object.setPrototype(inv); - QVERIFY(object.prototype().strictlyEquals(proto)); -} - -void tst_QJSValue::getSetPrototype_twoEngines() -{ - QJSEngine eng; - QJSValue prototype = eng.newObject(); - QJSValue object = eng.newObject(); - object.setPrototype(prototype); - QJSEngine otherEngine; - QJSValue newPrototype = otherEngine.newObject(); - QTest::ignoreMessage(QtWarningMsg, "QJSValue::setPrototype() failed: cannot set a prototype created in a different engine"); - object.setPrototype(newPrototype); - QCOMPARE(object.prototype().strictlyEquals(prototype), true); - -} - -void tst_QJSValue::getSetPrototype_null() -{ - QJSEngine eng; - QJSValue object = eng.newObject(); - object.setPrototype(QJSValue(QJSValue::NullValue)); - QVERIFY(object.prototype().isNull()); - - QJSValue newProto = eng.newObject(); - object.setPrototype(newProto); - QVERIFY(object.prototype().equals(newProto)); - - object.setPrototype(eng.evaluate("null")); - QVERIFY(object.prototype().isNull()); -} - -void tst_QJSValue::getSetPrototype_notObjectOrNull() -{ - QJSEngine eng; - QJSValue object = eng.newObject(); - QJSValue originalProto = object.prototype(); - - // bool - object.setPrototype(true); - QVERIFY(object.prototype().equals(originalProto)); - object.setPrototype(eng.toScriptValue(true)); - QVERIFY(object.prototype().equals(originalProto)); - - // number - object.setPrototype(123); - QVERIFY(object.prototype().equals(originalProto)); - object.setPrototype(eng.toScriptValue(123)); - QVERIFY(object.prototype().equals(originalProto)); - - // string - object.setPrototype("foo"); - QVERIFY(object.prototype().equals(originalProto)); - object.setPrototype(eng.toScriptValue(QString::fromLatin1("foo"))); - QVERIFY(object.prototype().equals(originalProto)); - - // undefined - object.setPrototype(QJSValue(QJSValue::UndefinedValue)); - QVERIFY(object.prototype().equals(originalProto)); - object.setPrototype(eng.toScriptValue(QVariant())); - QVERIFY(object.prototype().equals(originalProto)); -} - -void tst_QJSValue::getSetPrototype() -{ - QJSEngine eng; - QJSValue prototype = eng.newObject(); - QJSValue object = eng.newObject(); - object.setPrototype(prototype); - QCOMPARE(object.prototype().strictlyEquals(prototype), true); -} - -void tst_QJSValue::getSetScope() -{ -#if 0 // FIXME: No QJSValue::scope - QScriptEngine eng; - - QJSValue object = eng.newObject(); - QCOMPARE(object.scope().isValid(), false); - - QJSValue object2 = eng.newObject(); - object2.setScope(object); - - QEXPECT_FAIL("", "FIXME: scope not implemented yet", Abort); - QCOMPARE(object2.scope().strictlyEquals(object), true); - - object.setProperty("foo", 123); - QVERIFY(!object2.property("foo").isValid()); - { - QJSValue ret = object2.property("foo", QJSValue::ResolveScope); - QVERIFY(ret.isNumber()); - QCOMPARE(ret.toInt(), 123); - } - - QJSValue inv; - inv.setScope(object); - QCOMPARE(inv.scope().isValid(), false); - - QScriptEngine otherEngine; - QJSValue object3 = otherEngine.newObject(); - QTest::ignoreMessage(QtWarningMsg, "QJSValue::setScope() failed: cannot set a scope object created in a different engine"); - object2.setScope(object3); - QCOMPARE(object2.scope().strictlyEquals(object), true); - - object2.setScope(QJSValue()); - QVERIFY(!object2.scope().isValid()); -#endif -} - -void tst_QJSValue::getSetData_objects_data() -{ -#if 0 // FIXME: no setData/data API - newEngine(); - - QTest::addColumn("object"); - - QTest::newRow("object from evaluate") << engine->evaluate("new Object()"); - QTest::newRow("object from engine") << engine->newObject(); - QTest::newRow("Array") << engine->newArray(); - QTest::newRow("Date") << engine->evaluate("new Date(12324)"); - QTest::newRow("QObject") << engine->newQObject(this); - QTest::newRow("RegExp") << engine->newRegExp(QRegExp()); -#endif -} - -void tst_QJSValue::getSetData_objects() -{ -#if 0 // FIXME: no setData/data API - QFETCH(QJSValue, object); - - QVERIFY(!object.data().isValid()); - QJSValue v1(true); - object.setData(v1); - QVERIFY(object.data().strictlyEquals(v1)); - QJSValue v2(123); - object.setData(v2); - QVERIFY(object.data().strictlyEquals(v2)); - QJSValue v3 = engine->newObject(); - object.setData(v3); - QVERIFY(object.data().strictlyEquals(v3)); - object.setData(QJSValue()); - QVERIFY(!object.data().isValid()); -#endif -} - -void tst_QJSValue::getSetData_nonObjects_data() -{ -#if 0 // FIXME: no setData/data API - newEngine(); - - QTest::addColumn("value"); - - QTest::newRow("undefined (bound)") << engine->toScriptValue(QVariant()); - QTest::newRow("null (bound)") << engine->evaluate("null"); - QTest::newRow("string (bound)") << engine->toScriptValue("Pong"); - QTest::newRow("bool (bound)") << engine->toScriptValue(false); - - QTest::newRow("undefined") << QJSValue(QJSValue::UndefinedValue); - QTest::newRow("null") << QJSValue(QJSValue::NullValue); - QTest::newRow("string") << QJSValue("Pong"); - QTest::newRow("bool") << QJSValue(true); -#endif -} - -void tst_QJSValue::getSetData_nonObjects() -{ -#if 0 // FIXME: no setData/data API - QFETCH(QJSValue, value); - - QVERIFY(!value.data().isValid()); - QJSValue v1(true); - value.setData(v1); - QVERIFY(!value.data().isValid()); - QJSValue v2(123); - value.setData(v2); - QVERIFY(!value.data().isValid()); - QJSValue v3 = engine->newObject(); - value.setData(v3); - QVERIFY(!value.data().isValid()); - value.setData(QJSValue()); - QVERIFY(!value.data().isValid()); -#endif -} - -void tst_QJSValue::setData_QTBUG15144() -{ -#if 0 // FIXME: no setData/data API - QScriptEngine eng; - QJSValue obj = eng.newObject(); - for (int i = 0; i < 10000; ++i) { - // Create an object with property 'fooN' on it, and immediately kill - // the reference to the object so it and the property name become garbage. - eng.evaluate(QString::fromLatin1("o = {}; o.foo%0 = 10; o = null;").arg(i)); - // Setting the data will cause a JS string to be allocated, which could - // trigger a GC. This should not cause a crash. - obj.setData("foodfight"); - } -#endif -} - -#if 0 // FIXME: no QScriptClass -class TestScriptClass : public QScriptClass -{ -public: - TestScriptClass(QScriptEngine *engine) : QScriptClass(engine) {} -}; - -void tst_QJSValue::getSetScriptClass_emptyClass_data() -{ - newEngine(); - QTest::addColumn("value"); - - QTest::newRow("invalid") << QJSValue(); - QTest::newRow("number") << QJSValue(123); - QTest::newRow("string") << QJSValue("pong"); - QTest::newRow("bool") << QJSValue(false); - QTest::newRow("null") << QJSValue(QJSValue::NullValue); - QTest::newRow("undefined") << QJSValue(QJSValue::UndefinedValue); - - QTest::newRow("number") << engine->toScriptValue(123); - QTest::newRow("string") << engine->toScriptValue("pong"); - QTest::newRow("bool") << engine->toScriptValue(true); - QTest::newRow("null") << QJSValue(engine->evaluate("null")); - QTest::newRow("undefined") << QJSValue(engine->toScriptValue(QVariant())); - QTest::newRow("object") << QJSValue(engine->newObject()); - QTest::newRow("date") << QJSValue(engine->evaluate("new Date()")); - QTest::newRow("qobject") << QJSValue(engine->newQObject(this)); -} - -void tst_QJSValue::getSetScriptClass_emptyClass() -{ - QFETCH(QJSValue, value); - QCOMPARE(value.scriptClass(), (QScriptClass*)0); -} - -void tst_QJSValue::getSetScriptClass_JSObjectFromCpp() -{ - QScriptEngine eng; - TestScriptClass testClass(&eng); - // object created in C++ (newObject()) - { - QJSValue obj = eng.newObject(); - obj.setScriptClass(&testClass); - QCOMPARE(obj.scriptClass(), (QScriptClass*)&testClass); - obj.setScriptClass(0); - QCOMPARE(obj.scriptClass(), (QScriptClass*)0); - } -} - -void tst_QJSValue::getSetScriptClass_JSObjectFromJS() -{ - QScriptEngine eng; - TestScriptClass testClass(&eng); - // object created in JS - { - QJSValue obj = eng.evaluate("new Object"); - QVERIFY(!eng.hasUncaughtException()); - QVERIFY(obj.isObject()); - QCOMPARE(obj.scriptClass(), (QScriptClass*)0); - obj.setScriptClass(&testClass); - QCOMPARE(obj.scriptClass(), (QScriptClass*)&testClass); - obj.setScriptClass(0); - QCOMPARE(obj.scriptClass(), (QScriptClass*)0); - } -} - -void tst_QJSValue::getSetScriptClass_QVariant() -{ - QScriptEngine eng; - TestScriptClass testClass(&eng); - // object that already has a(n internal) class - { - QJSValue obj = eng.toScriptValue(QUrl("http://example.com")); - QVERIFY(obj.isVariant()); - QCOMPARE(obj.scriptClass(), (QScriptClass*)0); - obj.setScriptClass(&testClass); - QCOMPARE(obj.scriptClass(), (QScriptClass*)&testClass); - QVERIFY(obj.isObject()); - QVERIFY(!obj.isVariant()); - QCOMPARE(obj.toVariant(), QVariant(QVariantMap())); - } -} - -void tst_QJSValue::getSetScriptClass_QObject() -{ - QScriptEngine eng; - TestScriptClass testClass(&eng); - { - QJSValue obj = eng.newQObject(this); - QVERIFY(obj.isQObject()); - obj.setScriptClass(&testClass); - QCOMPARE(obj.scriptClass(), (QScriptClass*)&testClass); - QVERIFY(obj.isObject()); - QVERIFY(!obj.isQObject()); - QVERIFY(obj.toQObject() == 0); - } -} -#endif - -#if 0 // FIXME: No c-style callbacks -static QJSValue getArg(QScriptContext *ctx, QScriptEngine *) -{ - return ctx->argument(0); -} - -static QJSValue evaluateArg(QScriptContext *, QScriptEngine *eng) -{ - return eng->evaluate("arguments[0]"); -} - -static QJSValue addArgs(QScriptContext *, QScriptEngine *eng) -{ - return eng->evaluate("arguments[0] + arguments[1]"); -} - -static QJSValue returnInvalidValue(QScriptContext *, QScriptEngine *) -{ - return QJSValue(); -} -#endif - -void tst_QJSValue::call_function() -{ - QJSEngine eng; - QJSValue fun = eng.evaluate("(function() { return 1; })"); - QVERIFY(fun.isCallable()); - QJSValue result = fun.call(); - QVERIFY(result.isNumber()); - QCOMPARE(result.toInt(), 1); -} - -void tst_QJSValue::call_object() -{ - QJSEngine eng; - QJSValue Object = eng.evaluate("Object"); - QCOMPARE(Object.isCallable(), true); - QJSValue result = Object.callWithInstance(Object); - QCOMPARE(result.isObject(), true); -} - -void tst_QJSValue::call_newObjects() -{ - QJSEngine eng; - // test that call() doesn't construct new objects - QJSValue Number = eng.evaluate("Number"); - QJSValue Object = eng.evaluate("Object"); - QCOMPARE(Object.isCallable(), true); - QJSValueList args; - args << eng.toScriptValue(123); - QJSValue result = Number.callWithInstance(Object, args); - QCOMPARE(result.strictlyEquals(args.at(0)), true); -} - -void tst_QJSValue::call_this() -{ - QJSEngine eng; - // test that correct "this" object is used - QJSValue fun = eng.evaluate("(function() { return this; })"); - QCOMPARE(fun.isCallable(), true); - - QJSValue numberObject = eng.evaluate("new Number(123)"); - QJSValue result = fun.callWithInstance(numberObject); - QCOMPARE(result.isObject(), true); - QCOMPARE(result.toNumber(), 123.0); -} - -void tst_QJSValue::call_arguments() -{ - QJSEngine eng; - // test that correct arguments are passed - - QJSValue fun = eng.evaluate("(function() { return arguments[0]; })"); - QCOMPARE(fun.isCallable(), true); - { - QJSValue result = fun.callWithInstance(eng.toScriptValue(QVariant())); - QCOMPARE(result.isUndefined(), true); - } - { - QJSValueList args; - args << eng.toScriptValue(123.0); - QJSValue result = fun.callWithInstance(eng.toScriptValue(QVariant()), args); - QCOMPARE(result.isNumber(), true); - QCOMPARE(result.toNumber(), 123.0); - } - // V2 constructors - { - QJSValueList args; - args << QJSValue(123.0); - QJSValue result = fun.callWithInstance(eng.toScriptValue(QVariant()), args); - QCOMPARE(result.isNumber(), true); - QCOMPARE(result.toNumber(), 123.0); - } -#if 0 // FIXME: The feature of interpreting a passed array as argument list has been removed from the API - { - QJSValue args = eng.newArray(); - args.setProperty(0, 123); - QJSValue result = fun.callWithInstance(eng.toScriptValue(QVariant()), args); - QVERIFY(result.isNumber()); - QCOMPARE(result.toNumber(), 123.0); - } -#endif -} - -void tst_QJSValue::call() -{ - QJSEngine eng; - { - QJSValue fun = eng.evaluate("(function() { return arguments[1]; })"); - QCOMPARE(fun.isCallable(), true); - - { - QJSValueList args; - args << eng.toScriptValue(123.0) << eng.toScriptValue(456.0); - QJSValue result = fun.callWithInstance(eng.toScriptValue(QVariant()), args); - QCOMPARE(result.isNumber(), true); - QCOMPARE(result.toNumber(), 456.0); - } -#if 0 // FIXME: The feature of interpreting a passed array as argument list has been removed from the API - { - QJSValue args = eng.newArray(); - args.setProperty(0, 123); - args.setProperty(1, 456); - QJSValue result = fun.callWithInstance(eng.toScriptValue(QVariant()), args); - QVERIFY(result.isNumber()); - QCOMPARE(result.toNumber(), 456.0); - } -#endif - } - { - QJSValue fun = eng.evaluate("(function() { throw new Error('foo'); })"); - QCOMPARE(fun.isCallable(), true); - QVERIFY(!eng.hasUncaughtException()); - - { - QJSValue result = fun.call(); - QCOMPARE(result.isError(), true); - QCOMPARE(eng.hasUncaughtException(), true); - QVERIFY(result.strictlyEquals(eng.uncaughtException())); - } - } -#if 0 // FIXME: No c-style callbacks - { - eng.clearExceptions(); - QJSValue fun = eng.newFunction(getArg); - { - QJSValueList args; - args << eng.toScriptValue(123.0); - QJSValue result = fun.callWithInstance(eng.toScriptValue(QVariant()), args); - QVERIFY(!eng.hasUncaughtException()); - QCOMPARE(result.isNumber(), true); - QCOMPARE(result.toNumber(), 123.0); - } - // V2 constructors - { - QJSValueList args; - args << QJSValue(123.0); - QJSValue result = fun.callWithInstance(eng.toScriptValue(QVariant()), args); - QCOMPARE(result.isNumber(), true); - QCOMPARE(result.toNumber(), 123.0); - } -#if 0 // FIXME: The feature of interpreting a passed array as argument list has been removed from the API - { - QJSValue args = eng.newArray(); - args.setProperty(0, 123); - QJSValue result = fun.callWithInstance(eng.toScriptValue(QVariant()), args); - QVERIFY(result.isNumber()); - QCOMPARE(result.toNumber(), 123.0); - } -#endif - } - { - QJSValue fun = eng.newFunction(evaluateArg); - { - QJSValueList args; - args << eng.toScriptValue(123.0); - QJSValue result = fun.callWithInstance(eng.toScriptValue(QVariant()), args); - QVERIFY(!eng.hasUncaughtException()); - QCOMPARE(result.isNumber(), true); - QCOMPARE(result.toNumber(), 123.0); - } - } -#endif -} - -void tst_QJSValue::call_invalidArguments() -{ -#if 0 // FIXME: No c-style callbacks - // test that invalid arguments are handled gracefully - QScriptEngine eng; - { - QJSValue fun = eng.newFunction(getArg); - { - QJSValueList args; - args << QJSValue(); - QJSValue ret = fun.callWithInstance(args); - QVERIFY(!eng.hasUncaughtException()); - QVERIFY(ret.isUndefined()); - } - } - { - QJSValue fun = eng.newFunction(evaluateArg); - { - QJSValueList args; - args << QJSValue(); - QJSValue ret = fun.call(args); - QVERIFY(ret.isUndefined()); - } - } - { - QJSValue fun = eng.newFunction(addArgs); - { - QJSValueList args; - args << QJSValue() << QJSValue(); - QJSValue ret = fun.call(args); - QVERIFY(!ret.isUndefined()); - QCOMPARE(ret.isNumber(), true); - QCOMPARE(qIsNaN(ret.toNumber()), true); - } - } -#endif -} - -void tst_QJSValue::call_invalidReturn() -{ -#if 0 // FIXME: No c-style callbacks - // test that invalid return value is handled gracefully - QScriptEngine eng; - QJSValue fun = eng.newFunction(returnInvalidValue); - eng.globalObject().setProperty("returnInvalidValue", fun); - QJSValue ret = eng.evaluate("returnInvalidValue() + returnInvalidValue()"); - QVERIFY(!ret.isUndefined()); - QCOMPARE(ret.isNumber(), true); - QCOMPARE(qIsNaN(ret.toNumber()), true); -#endif -} - -void tst_QJSValue::call_twoEngines() -{ - QJSEngine eng; - QJSValue object = eng.evaluate("Object"); - QJSEngine otherEngine; - QJSValue fun = otherEngine.evaluate("(function() { return 1; })"); - QVERIFY(fun.isCallable()); - QTest::ignoreMessage(QtWarningMsg, "JSValue can't be rassigned to an another engine."); - QTest::ignoreMessage(QtWarningMsg, "QJSValue::call() failed: " - "cannot call function with thisObject created in " - "a different engine"); - QVERIFY(fun.callWithInstance(object).isUndefined()); - QTest::ignoreMessage(QtWarningMsg, "QJSValue::call() failed: " - "cannot call function with argument created in " - "a different engine"); - QVERIFY(fun.call(QJSValueList() << eng.toScriptValue(123)).isUndefined()); - { - QJSValue fun = eng.evaluate("Object"); - QVERIFY(fun.isCallable()); - QJSEngine eng2; - QJSValue objectInDifferentEngine = eng2.newObject(); - QJSValueList args; - args << objectInDifferentEngine; - QTest::ignoreMessage(QtWarningMsg, "QJSValue::call() failed: cannot call function with argument created in a different engine"); - fun.call(args); - } -} - -void tst_QJSValue::call_array() -{ -#if 0 // FIXME: The feature of interpreting an array as argument list has been removed from the API - QScriptEngine eng; - QJSValue fun = eng.evaluate("(function() { return arguments; })"); - QVERIFY(fun.isCallable()); - QJSValue array = eng.newArray(3); - array.setProperty(0, eng.toScriptValue(123.0)); - array.setProperty(1, eng.toScriptValue(456.0)); - array.setProperty(2, eng.toScriptValue(789.0)); - // call with single array object as arguments - QJSValue ret = fun.call(QJSValue(), array); - QVERIFY(!eng.hasUncaughtException()); - QCOMPARE(ret.isError(), false); - QCOMPARE(ret.property(0).strictlyEquals(array.property(0)), true); - QCOMPARE(ret.property(1).strictlyEquals(array.property(1)), true); - QCOMPARE(ret.property(2).strictlyEquals(array.property(2)), true); - // call with arguments object as arguments - QJSValue ret2 = fun.call(QJSValue(), ret); - QCOMPARE(ret2.isError(), false); - QCOMPARE(ret2.property(0).strictlyEquals(ret.property(0)), true); - QCOMPARE(ret2.property(1).strictlyEquals(ret.property(1)), true); - QCOMPARE(ret2.property(2).strictlyEquals(ret.property(2)), true); - // call with null as arguments - QJSValue ret3 = fun.call(QJSValue(), eng.evaluate("null")); - QCOMPARE(ret3.isError(), false); - QCOMPARE(ret3.property("length").isNumber(), true); - QCOMPARE(ret3.property("length").toNumber(), 0.0); - // call with undefined as arguments - QJSValue ret4 = fun.call(QJSValue(), eng.toScriptValue(QVariant())); - QCOMPARE(ret4.isError(), false); - QCOMPARE(ret4.property("length").isNumber(), true); - QCOMPARE(ret4.property("length").toNumber(), 0.0); - // call with something else as arguments - QJSValue ret5 = fun.call(QJSValue(), eng.toScriptValue(123.0)); - QCOMPARE(ret5.isError(), true); - // call with a non-array object as arguments - QJSValue ret6 = fun.call(QJSValue(), eng.globalObject()); - QVERIFY(ret6.isError()); - QCOMPARE(ret6.toString(), QString::fromLatin1("TypeError: Arguments must be an array")); -#endif -} - - -void tst_QJSValue::call_nonFunction_data() -{ - newEngine(); - QTest::addColumn("value"); - - QTest::newRow("invalid") << QJSValue(); - QTest::newRow("bool") << QJSValue(false); - QTest::newRow("int") << QJSValue(123); - QTest::newRow("string") << QJSValue(QString::fromLatin1("ciao")); - QTest::newRow("undefined") << QJSValue(QJSValue::UndefinedValue); - QTest::newRow("null") << QJSValue(QJSValue::NullValue); - - QTest::newRow("bool bound") << engine->toScriptValue(false); - QTest::newRow("int bound") << engine->toScriptValue(123); - QTest::newRow("string bound") << engine->toScriptValue(QString::fromLatin1("ciao")); - QTest::newRow("undefined bound") << engine->toScriptValue(QVariant()); - QTest::newRow("null bound") << engine->evaluate("null"); -} - -void tst_QJSValue::call_nonFunction() -{ - // calling things that are not functions - QFETCH(QJSValue, value); - QVERIFY(value.call().isUndefined()); -} - -#if 0 // FIXME: no c-style callbacks -static QJSValue ctorReturningUndefined(QScriptContext *ctx, QScriptEngine *) -{ - ctx->thisObject().setProperty("foo", 123); - return QJSValue(QJSValue::UndefinedValue); -} - -static QJSValue ctorReturningNewObject(QScriptContext *, QScriptEngine *eng) -{ - QJSValue result = eng->newObject(); - result.setProperty("bar", 456); - return result; -} -#endif - -void tst_QJSValue::construct_nonFunction_data() -{ - newEngine(); - QTest::addColumn("value"); - - QTest::newRow("invalid") << QJSValue(); - QTest::newRow("bool") << QJSValue(false); - QTest::newRow("int") << QJSValue(123); - QTest::newRow("string") << QJSValue(QString::fromLatin1("ciao")); - QTest::newRow("undefined") << QJSValue(QJSValue::UndefinedValue); - QTest::newRow("null") << QJSValue(QJSValue::NullValue); - - QTest::newRow("bool bound") << engine->toScriptValue(false); - QTest::newRow("int bound") << engine->toScriptValue(123); - QTest::newRow("string bound") << engine->toScriptValue(QString::fromLatin1("ciao")); - QTest::newRow("undefined bound") << engine->toScriptValue(QVariant()); - QTest::newRow("null bound") << engine->evaluate("null"); -} - -void tst_QJSValue::construct_nonFunction() -{ - QFETCH(QJSValue, value); - QVERIFY(value.callAsConstructor().isUndefined()); -} - -void tst_QJSValue::construct_simple() -{ - QJSEngine eng; - QJSValue fun = eng.evaluate("(function () { this.foo = 123; })"); - QVERIFY(fun.isCallable()); - QJSValue ret = fun.callAsConstructor(); - QVERIFY(!ret.isUndefined()); - QVERIFY(ret.isObject()); - QVERIFY(ret.prototype().strictlyEquals(fun.property("prototype"))); - QCOMPARE(ret.property("foo").toInt(), 123); -} - -void tst_QJSValue::construct_newObjectJS() -{ - QJSEngine eng; - // returning a different object overrides the default-constructed one - QJSValue fun = eng.evaluate("(function () { return { bar: 456 }; })"); - QVERIFY(fun.isCallable()); - QJSValue ret = fun.callAsConstructor(); - QVERIFY(ret.isObject()); - QVERIFY(!ret.prototype().strictlyEquals(fun.property("prototype"))); - QCOMPARE(ret.property("bar").toInt(), 456); -} - -#if 0 // FIXME: no c-style callbacks -void tst_QJSValue::construct_undefined() -{ - QScriptEngine eng; - QJSValue fun = eng.newFunction(ctorReturningUndefined); - QJSValue ret = fun.callAsConstructor(); - QVERIFY(ret.isObject()); - QVERIFY(ret.instanceOf(fun)); - QCOMPARE(ret.property("foo").toInt(), 123); -} - -void tst_QJSValue::construct_newObjectCpp() -{ - QScriptEngine eng; - QJSValue fun = eng.newFunction(ctorReturningNewObject); - QJSValue ret = fun.callAsConstructor(); - QVERIFY(ret.isObject()); - QVERIFY(!ret.instanceOf(fun)); - QCOMPARE(ret.property("bar").toInt(), 456); -} -#endif - -void tst_QJSValue::construct_arg() -{ - QJSEngine eng; - QJSValue Number = eng.evaluate("Number"); - QCOMPARE(Number.isCallable(), true); - QJSValueList args; - args << eng.toScriptValue(123); - QJSValue ret = Number.callAsConstructor(args); - QCOMPARE(ret.isObject(), true); - QCOMPARE(ret.toNumber(), args.at(0).toNumber()); -} - -void tst_QJSValue::construct_proto() -{ - QJSEngine eng; - // test that internal prototype is set correctly - QJSValue fun = eng.evaluate("(function() { return this.__proto__; })"); - QCOMPARE(fun.isCallable(), true); - QCOMPARE(fun.property("prototype").isObject(), true); - QJSValue ret = fun.callAsConstructor(); - QCOMPARE(fun.property("prototype").strictlyEquals(ret), true); -} - -void tst_QJSValue::construct_returnInt() -{ - QJSEngine eng; - // test that we return the new object even if a non-object value is returned from the function - QJSValue fun = eng.evaluate("(function() { return 123; })"); - QCOMPARE(fun.isCallable(), true); - QJSValue ret = fun.callAsConstructor(); - QCOMPARE(ret.isObject(), true); -} - -void tst_QJSValue::construct_throw() -{ - QJSEngine eng; - QJSValue fun = eng.evaluate("(function() { throw new Error('foo'); })"); - QCOMPARE(fun.isCallable(), true); - QJSValue ret = fun.callAsConstructor(); - QCOMPARE(ret.isError(), true); - QCOMPARE(eng.hasUncaughtException(), true); - QVERIFY(ret.strictlyEquals(eng.uncaughtException())); -} - -#if 0 // FIXME: The feature of interpreting an array as argument list has been removed from the API -void tst_QJSValue::construct() -{ - QScriptEngine eng; - QJSValue fun = eng.evaluate("(function() { return arguments; })"); - QVERIFY(fun.isCallable()); - QJSValue array = eng.newArray(3); - array.setProperty(0, eng.toScriptValue(123.0)); - array.setProperty(1, eng.toScriptValue(456.0)); - array.setProperty(2, eng.toScriptValue(789.0)); - // construct with single array object as arguments - QJSValue ret = fun.callAsConstructor(array); - QVERIFY(!eng.hasUncaughtException()); - QVERIFY(ret.isObject()); - QCOMPARE(ret.property(0).strictlyEquals(array.property(0)), true); - QCOMPARE(ret.property(1).strictlyEquals(array.property(1)), true); - QCOMPARE(ret.property(2).strictlyEquals(array.property(2)), true); - // construct with arguments object as arguments - QJSValue ret2 = fun.callAsConstructor(ret); - QCOMPARE(ret2.property(0).strictlyEquals(ret.property(0)), true); - QCOMPARE(ret2.property(1).strictlyEquals(ret.property(1)), true); - QCOMPARE(ret2.property(2).strictlyEquals(ret.property(2)), true); - // construct with null as arguments - QJSValue ret3 = fun.callAsConstructor(eng.evaluate("null"); - QCOMPARE(ret3.isError(), false); - QCOMPARE(ret3.property("length").isNumber(), true); - QCOMPARE(ret3.property("length").toNumber(), 0.0); - // construct with undefined as arguments - QJSValue ret4 = fun.callAsConstructor(eng.toScriptValue(QVariant())); - QCOMPARE(ret4.isError(), false); - QCOMPARE(ret4.property("length").isNumber(), true); - QCOMPARE(ret4.property("length").toNumber(), 0.0); - // construct with something else as arguments - QJSValue ret5 = fun.callAsConstructor(eng.toScriptValue(123.0)); - QCOMPARE(ret5.isError(), true); - // construct with a non-array object as arguments - QJSValue ret6 = fun.callAsConstructor(eng.globalObject()); - QVERIFY(ret6.isError()); - QCOMPARE(ret6.toString(), QString::fromLatin1("TypeError: Arguments must be an array")); -} -#endif - -void tst_QJSValue::construct_twoEngines() -{ - QJSEngine engine; - QJSEngine otherEngine; - QJSValue ctor = engine.evaluate("(function (a, b) { this.foo = 123; })"); - QJSValue arg = otherEngine.toScriptValue(124567); - QTest::ignoreMessage(QtWarningMsg, "QJSValue::callAsConstructor() failed: cannot construct function with argument created in a different engine"); - QVERIFY(ctor.callAsConstructor(QJSValueList() << arg).isUndefined()); - QTest::ignoreMessage(QtWarningMsg, "QJSValue::callAsConstructor() failed: cannot construct function with argument created in a different engine"); - QVERIFY(ctor.callAsConstructor(QJSValueList() << arg << otherEngine.newObject()).isUndefined()); -} - -void tst_QJSValue::construct_constructorThrowsPrimitive() -{ - QJSEngine eng; - QJSValue fun = eng.evaluate("(function() { throw 123; })"); - QVERIFY(fun.isCallable()); - // construct(QJSValueList) - { - QJSValue ret = fun.callAsConstructor(); - QVERIFY(ret.isNumber()); - QCOMPARE(ret.toNumber(), 123.0); - QVERIFY(eng.hasUncaughtException()); - QVERIFY(ret.strictlyEquals(eng.uncaughtException())); - eng.clearExceptions(); - } -#if 0 // FIXME: The feature of interpreting an array as argument list has been removed from the API - // construct(QJSValue) - { - QJSValue ret = fun.callAsConstructor(eng.newArray()); - QVERIFY(ret.isNumber()); - QCOMPARE(ret.toNumber(), 123.0); - QVERIFY(eng.hasUncaughtException()); - QVERIFY(ret.strictlyEquals(eng.uncaughtException())); - eng.clearExceptions(); - } -#endif -} - -#if 0 // FIXME: No QJSValue::lessThan -void tst_QJSValue::lessThan() -{ - QScriptEngine eng; - - QVERIFY(!QJSValue().lessThan(QJSValue())); - - QJSValue num = eng.toScriptValue(123); - QCOMPARE(num.lessThan(eng.toScriptValue(124)), true); - QCOMPARE(num.lessThan(eng.toScriptValue(122)), false); - QCOMPARE(num.lessThan(eng.toScriptValue(123)), false); - QCOMPARE(num.lessThan(eng.toScriptValue("124")), true); - QCOMPARE(num.lessThan(eng.toScriptValue("122")), false); - QCOMPARE(num.lessThan(eng.toScriptValue("123")), false); - QCOMPARE(num.lessThan(eng.toScriptValue(qSNaN())), false); - QCOMPARE(num.lessThan(eng.toScriptValue(+qInf())), true); - QCOMPARE(num.lessThan(eng.toScriptValue(-qInf())), false); - QCOMPARE(num.lessThan(num), false); - QCOMPARE(num.lessThan(eng.toScriptValue(124).toObject()), true); - QCOMPARE(num.lessThan(eng.toScriptValue(122).toObject()), false); - QCOMPARE(num.lessThan(eng.toScriptValue(123).toObject()), false); - QCOMPARE(num.lessThan(eng.toScriptValue("124").toObject()), true); - QCOMPARE(num.lessThan(eng.toScriptValue("122").toObject()), false); - QCOMPARE(num.lessThan(eng.toScriptValue("123").toObject()), false); - QCOMPARE(num.lessThan(eng.toScriptValue(qSNaN()).toObject()), false); - QCOMPARE(num.lessThan(eng.toScriptValue(+qInf()).toObject()), true); - QCOMPARE(num.lessThan(eng.toScriptValue(-qInf()).toObject()), false); - QCOMPARE(num.lessThan(num.toObject()), false); - QCOMPARE(num.lessThan(QJSValue()), false); - - QJSValue str = eng.toScriptValue("123"); - QCOMPARE(str.lessThan(eng.toScriptValue("124")), true); - QCOMPARE(str.lessThan(eng.toScriptValue("122")), false); - QCOMPARE(str.lessThan(eng.toScriptValue("123")), false); - QCOMPARE(str.lessThan(eng.toScriptValue(124)), true); - QCOMPARE(str.lessThan(eng.toScriptValue(122)), false); - QCOMPARE(str.lessThan(eng.toScriptValue(123)), false); - QCOMPARE(str.lessThan(str), false); - QCOMPARE(str.lessThan(eng.toScriptValue("124").toObject()), true); - QCOMPARE(str.lessThan(eng.toScriptValue("122").toObject()), false); - QCOMPARE(str.lessThan(eng.toScriptValue("123").toObject()), false); - QCOMPARE(str.lessThan(eng.toScriptValue(124).toObject()), true); - QCOMPARE(str.lessThan(eng.toScriptValue(122).toObject()), false); - QCOMPARE(str.lessThan(eng.toScriptValue(123).toObject()), false); - QCOMPARE(str.lessThan(str.toObject()), false); - QCOMPARE(str.lessThan(QJSValue()), false); - - // V2 constructors - QJSValue num2 = QJSValue(123); - QCOMPARE(num2.lessThan(QJSValue(124)), true); - QCOMPARE(num2.lessThan(QJSValue(122)), false); - QCOMPARE(num2.lessThan(QJSValue(123)), false); - QCOMPARE(num2.lessThan(QJSValue("124")), true); - QCOMPARE(num2.lessThan(QJSValue("122")), false); - QCOMPARE(num2.lessThan(QJSValue("123")), false); - QCOMPARE(num2.lessThan(QJSValue(qSNaN())), false); - QCOMPARE(num2.lessThan(QJSValue(+qInf())), true); - QCOMPARE(num2.lessThan(QJSValue(-qInf())), false); - QCOMPARE(num2.lessThan(num), false); - QCOMPARE(num2.lessThan(QJSValue()), false); - - QJSValue str2 = QJSValue("123"); - QCOMPARE(str2.lessThan(QJSValue("124")), true); - QCOMPARE(str2.lessThan(QJSValue("122")), false); - QCOMPARE(str2.lessThan(QJSValue("123")), false); - QCOMPARE(str2.lessThan(QJSValue(124)), true); - QCOMPARE(str2.lessThan(QJSValue(122)), false); - QCOMPARE(str2.lessThan(QJSValue(123)), false); - QCOMPARE(str2.lessThan(str), false); - QCOMPARE(str2.lessThan(QJSValue()), false); - - QJSValue obj1 = eng.newObject(); - QJSValue obj2 = eng.newObject(); - QCOMPARE(obj1.lessThan(obj2), false); - QCOMPARE(obj2.lessThan(obj1), false); - QCOMPARE(obj1.lessThan(obj1), false); - QCOMPARE(obj2.lessThan(obj2), false); - - QJSValue date1 = eng.toScriptValue(QDateTime(QDate(2000, 1, 1))); - QJSValue date2 = eng.toScriptValue(QDateTime(QDate(1999, 1, 1))); - QCOMPARE(date1.lessThan(date2), false); - QCOMPARE(date2.lessThan(date1), true); - QCOMPARE(date1.lessThan(date1), false); - QCOMPARE(date2.lessThan(date2), false); - QCOMPARE(date1.lessThan(QJSValue()), false); - - QCOMPARE(QJSValue().lessThan(date2), false); - - QScriptEngine otherEngine; - QTest::ignoreMessage(QtWarningMsg, "QJSValue::lessThan: " - "cannot compare to a value created in " - "a different engine"); - QCOMPARE(date1.lessThan(otherEngine.toScriptValue(123)), false); -} -#endif - -void tst_QJSValue::equals() -{ - QJSEngine eng; - - QVERIFY(QJSValue().equals(QJSValue())); - - QJSValue num = eng.toScriptValue(123); - QCOMPARE(num.equals(eng.toScriptValue(123)), true); - QCOMPARE(num.equals(eng.toScriptValue(321)), false); - QCOMPARE(num.equals(eng.toScriptValue(QString::fromLatin1("123"))), true); - QCOMPARE(num.equals(eng.toScriptValue(QString::fromLatin1("321"))), false); - QCOMPARE(num.equals(eng.evaluate("new Number(123)")), true); - QCOMPARE(num.equals(eng.evaluate("new Number(321)")), false); - QCOMPARE(num.equals(eng.evaluate("new String('123')")), true); - QCOMPARE(num.equals(eng.evaluate("new String('321')")), false); - QVERIFY(eng.evaluate("new Number(123)").equals(num)); - QCOMPARE(num.equals(QJSValue()), false); - - QJSValue str = eng.toScriptValue(QString::fromLatin1("123")); - QCOMPARE(str.equals(eng.toScriptValue(QString::fromLatin1("123"))), true); - QCOMPARE(str.equals(eng.toScriptValue(QString::fromLatin1("321"))), false); - QCOMPARE(str.equals(eng.toScriptValue(123)), true); - QCOMPARE(str.equals(eng.toScriptValue(321)), false); - QCOMPARE(str.equals(eng.evaluate("new String('123')")), true); - QCOMPARE(str.equals(eng.evaluate("new String('321')")), false); - QCOMPARE(str.equals(eng.evaluate("new Number(123)")), true); - QCOMPARE(str.equals(eng.evaluate("new Number(321)")), false); - QVERIFY(eng.evaluate("new String('123')").equals(str)); - QCOMPARE(str.equals(QJSValue()), false); - - QJSValue num2 = QJSValue(123); - QCOMPARE(num2.equals(QJSValue(123)), true); - QCOMPARE(num2.equals(QJSValue(321)), false); - QCOMPARE(num2.equals(QJSValue("123")), true); - QCOMPARE(num2.equals(QJSValue("321")), false); - QCOMPARE(num2.equals(QJSValue()), false); - - QJSValue str2 = QJSValue("123"); - QCOMPARE(str2.equals(QJSValue("123")), true); - QCOMPARE(str2.equals(QJSValue("321")), false); - QCOMPARE(str2.equals(QJSValue(123)), true); - QCOMPARE(str2.equals(QJSValue(321)), false); - QCOMPARE(str2.equals(QJSValue()), false); - - QJSValue date1 = eng.toScriptValue(QDateTime(QDate(2000, 1, 1))); - QJSValue date2 = eng.toScriptValue(QDateTime(QDate(1999, 1, 1))); - QCOMPARE(date1.equals(date2), false); - QCOMPARE(date1.equals(date1), true); - QCOMPARE(date2.equals(date2), true); - - QJSValue undefined = eng.toScriptValue(QVariant()); - QJSValue null = eng.evaluate("null"); - QCOMPARE(undefined.equals(undefined), true); - QCOMPARE(null.equals(null), true); - QCOMPARE(undefined.equals(null), true); - QCOMPARE(null.equals(undefined), true); - QVERIFY(undefined.equals(QJSValue())); - QVERIFY(null.equals(QJSValue())); - QVERIFY(!null.equals(num)); - QVERIFY(!undefined.equals(num)); - - QJSValue sant = eng.toScriptValue(true); - QVERIFY(sant.equals(eng.toScriptValue(1))); - QVERIFY(sant.equals(eng.toScriptValue(QString::fromLatin1("1")))); - QVERIFY(sant.equals(sant)); - QVERIFY(sant.equals(eng.evaluate("new Number(1)"))); - QVERIFY(sant.equals(eng.evaluate("new String('1')"))); - QVERIFY(sant.equals(eng.evaluate("new Boolean(true)"))); - QVERIFY(eng.evaluate("new Boolean(true)").equals(sant)); - QVERIFY(!sant.equals(eng.toScriptValue(0))); - QVERIFY(!sant.equals(undefined)); - QVERIFY(!sant.equals(null)); - - QJSValue falskt = eng.toScriptValue(false); - QVERIFY(falskt.equals(eng.toScriptValue(0))); - QVERIFY(falskt.equals(eng.toScriptValue(QString::fromLatin1("0")))); - QVERIFY(falskt.equals(falskt)); - QVERIFY(falskt.equals(eng.evaluate("new Number(0)"))); - QVERIFY(falskt.equals(eng.evaluate("new String('0')"))); - QVERIFY(falskt.equals(eng.evaluate("new Boolean(false)"))); - QVERIFY(eng.evaluate("new Boolean(false)").equals(falskt)); - QVERIFY(!falskt.equals(sant)); - QVERIFY(!falskt.equals(undefined)); - QVERIFY(!falskt.equals(null)); - - QJSValue obj1 = eng.newObject(); - QJSValue obj2 = eng.newObject(); - QCOMPARE(obj1.equals(obj2), false); - QCOMPARE(obj2.equals(obj1), false); - QCOMPARE(obj1.equals(obj1), true); - QCOMPARE(obj2.equals(obj2), true); - - QJSValue qobj1 = eng.newQObject(this); - QJSValue qobj2 = eng.newQObject(this); - QJSValue qobj3 = eng.newQObject(0); - - // FIXME: No ScriptOwnership: QJSValue qobj4 = eng.newQObject(new QObject(), QScriptEngine::ScriptOwnership); - QJSValue qobj4 = eng.newQObject(new QObject()); - - QVERIFY(qobj1.equals(qobj2)); // compares the QObject pointers - QVERIFY(!qobj2.equals(qobj4)); // compares the QObject pointers - QVERIFY(!qobj2.equals(obj2)); // compares the QObject pointers - - QJSValue compareFun = eng.evaluate("(function(a, b) { return a == b; })"); - QVERIFY(compareFun.isCallable()); - { - QJSValue ret = compareFun.call(QJSValueList() << qobj1 << qobj2); - QVERIFY(ret.isBool()); - ret = compareFun.call(QJSValueList() << qobj1 << qobj3); - QVERIFY(ret.isBool()); - QVERIFY(!ret.toBool()); - ret = compareFun.call(QJSValueList() << qobj1 << qobj4); - QVERIFY(ret.isBool()); - QVERIFY(!ret.toBool()); - ret = compareFun.call(QJSValueList() << qobj1 << obj1); - QVERIFY(ret.isBool()); - QVERIFY(!ret.toBool()); - } - - { - QJSValue var1 = eng.toScriptValue(QVariant(QPoint(1, 2))); - QJSValue var2 = eng.toScriptValue(QVariant(QPoint(1, 2))); - QEXPECT_FAIL("", "FIXME: QVariant comparison does not work with v8", Continue); - QVERIFY(var1.equals(var2)); - } - { - QJSValue var1 = eng.toScriptValue(QVariant(QPoint(1, 2))); - QJSValue var2 = eng.toScriptValue(QVariant(QPoint(3, 4))); - QVERIFY(!var1.equals(var2)); - } - - QJSEngine otherEngine; - QTest::ignoreMessage(QtWarningMsg, "QJSValue::equals: " - "cannot compare to a value created in " - "a different engine"); - QCOMPARE(date1.equals(otherEngine.toScriptValue(123)), false); -} - -void tst_QJSValue::strictlyEquals() -{ - QJSEngine eng; - - QVERIFY(QJSValue().strictlyEquals(QJSValue())); - - QJSValue num = eng.toScriptValue(123); - QCOMPARE(num.strictlyEquals(eng.toScriptValue(123)), true); - QCOMPARE(num.strictlyEquals(eng.toScriptValue(321)), false); - QCOMPARE(num.strictlyEquals(eng.toScriptValue(QString::fromLatin1("123"))), false); - QCOMPARE(num.strictlyEquals(eng.toScriptValue(QString::fromLatin1("321"))), false); - QCOMPARE(num.strictlyEquals(eng.evaluate("new Number(123)")), false); - QCOMPARE(num.strictlyEquals(eng.evaluate("new Number(321)")), false); - QCOMPARE(num.strictlyEquals(eng.evaluate("new String('123')")), false); - QCOMPARE(num.strictlyEquals(eng.evaluate("new String('321')")), false); - QVERIFY(!eng.evaluate("new Number(123)").strictlyEquals(num)); - QVERIFY(!num.strictlyEquals(QJSValue())); - QVERIFY(!QJSValue().strictlyEquals(num)); - - QJSValue str = eng.toScriptValue(QString::fromLatin1("123")); - QCOMPARE(str.strictlyEquals(eng.toScriptValue(QString::fromLatin1("123"))), true); - QCOMPARE(str.strictlyEquals(eng.toScriptValue(QString::fromLatin1("321"))), false); - QCOMPARE(str.strictlyEquals(eng.toScriptValue(123)), false); - QCOMPARE(str.strictlyEquals(eng.toScriptValue(321)), false); - QCOMPARE(str.strictlyEquals(eng.evaluate("new String('123')")), false); - QCOMPARE(str.strictlyEquals(eng.evaluate("new String('321')")), false); - QCOMPARE(str.strictlyEquals(eng.evaluate("new Number(123)")), false); - QCOMPARE(str.strictlyEquals(eng.evaluate("new Number(321)")), false); - QVERIFY(!eng.evaluate("new String('123')").strictlyEquals(str)); - QVERIFY(!str.strictlyEquals(QJSValue())); - - QJSValue num2 = QJSValue(123); - QCOMPARE(num2.strictlyEquals(QJSValue(123)), true); - QCOMPARE(num2.strictlyEquals(QJSValue(321)), false); - QCOMPARE(num2.strictlyEquals(QJSValue("123")), false); - QCOMPARE(num2.strictlyEquals(QJSValue("321")), false); - QVERIFY(!num2.strictlyEquals(QJSValue())); - - QJSValue str2 = QJSValue("123"); - QCOMPARE(str2.strictlyEquals(QJSValue("123")), true); - QCOMPARE(str2.strictlyEquals(QJSValue("321")), false); - QCOMPARE(str2.strictlyEquals(QJSValue(123)), false); - QCOMPARE(str2.strictlyEquals(QJSValue(321)), false); - QVERIFY(!str2.strictlyEquals(QJSValue())); - - QJSValue date1 = eng.toScriptValue(QDateTime(QDate(2000, 1, 1))); - QJSValue date2 = eng.toScriptValue(QDateTime(QDate(1999, 1, 1))); - QCOMPARE(date1.strictlyEquals(date2), false); - QCOMPARE(date1.strictlyEquals(date1), true); - QCOMPARE(date2.strictlyEquals(date2), true); - QVERIFY(!date1.strictlyEquals(QJSValue())); - - QJSValue undefined = eng.toScriptValue(QVariant()); - QJSValue null = eng.evaluate("null"); - QCOMPARE(undefined.strictlyEquals(undefined), true); - QCOMPARE(null.strictlyEquals(null), true); - QCOMPARE(undefined.strictlyEquals(null), false); - QCOMPARE(null.strictlyEquals(undefined), false); - QVERIFY(!null.strictlyEquals(QJSValue())); - - QJSValue sant = eng.toScriptValue(true); - QVERIFY(!sant.strictlyEquals(eng.toScriptValue(1))); - QVERIFY(!sant.strictlyEquals(eng.toScriptValue(QString::fromLatin1("1")))); - QVERIFY(sant.strictlyEquals(sant)); - QVERIFY(!sant.strictlyEquals(eng.evaluate("new Number(1)"))); - QVERIFY(!sant.strictlyEquals(eng.evaluate("new String('1')"))); - QVERIFY(!sant.strictlyEquals(eng.evaluate("new Boolean(true)"))); - QVERIFY(!eng.evaluate("new Boolean(true)").strictlyEquals(sant)); - QVERIFY(!sant.strictlyEquals(eng.toScriptValue(0))); - QVERIFY(!sant.strictlyEquals(undefined)); - QVERIFY(!sant.strictlyEquals(null)); - QVERIFY(!sant.strictlyEquals(QJSValue())); - - QJSValue falskt = eng.toScriptValue(false); - QVERIFY(!falskt.strictlyEquals(eng.toScriptValue(0))); - QVERIFY(!falskt.strictlyEquals(eng.toScriptValue(QString::fromLatin1("0")))); - QVERIFY(falskt.strictlyEquals(falskt)); - QVERIFY(!falskt.strictlyEquals(eng.evaluate("new Number(0)"))); - QVERIFY(!falskt.strictlyEquals(eng.evaluate("new String('0')"))); - QVERIFY(!falskt.strictlyEquals(eng.evaluate("new Boolean(false)"))); - QVERIFY(!eng.evaluate("new Boolean(false)").strictlyEquals(falskt)); - QVERIFY(!falskt.strictlyEquals(sant)); - QVERIFY(!falskt.strictlyEquals(undefined)); - QVERIFY(!falskt.strictlyEquals(null)); - QVERIFY(!falskt.strictlyEquals(QJSValue())); - - QVERIFY(!QJSValue(false).strictlyEquals(123)); - QVERIFY(!QJSValue(QJSValue::UndefinedValue).strictlyEquals(123)); - QVERIFY(!QJSValue(QJSValue::NullValue).strictlyEquals(123)); - QVERIFY(!QJSValue(false).strictlyEquals("ciao")); - QVERIFY(!QJSValue(QJSValue::UndefinedValue).strictlyEquals("ciao")); - QVERIFY(!QJSValue(QJSValue::NullValue).strictlyEquals("ciao")); - QVERIFY(eng.toScriptValue(QString::fromLatin1("ciao")).strictlyEquals("ciao")); - QVERIFY(QJSValue("ciao").strictlyEquals(eng.toScriptValue(QString::fromLatin1("ciao")))); - QVERIFY(!QJSValue("ciao").strictlyEquals(123)); - QVERIFY(!QJSValue("ciao").strictlyEquals(eng.toScriptValue(123))); - QVERIFY(!QJSValue(123).strictlyEquals("ciao")); - QVERIFY(!QJSValue(123).strictlyEquals(eng.toScriptValue(QString::fromLatin1("ciao")))); - QVERIFY(!eng.toScriptValue(123).strictlyEquals("ciao")); - - QJSValue obj1 = eng.newObject(); - QJSValue obj2 = eng.newObject(); - QCOMPARE(obj1.strictlyEquals(obj2), false); - QCOMPARE(obj2.strictlyEquals(obj1), false); - QCOMPARE(obj1.strictlyEquals(obj1), true); - QCOMPARE(obj2.strictlyEquals(obj2), true); - QVERIFY(!obj1.strictlyEquals(QJSValue())); - - QJSValue qobj1 = eng.newQObject(this); - QJSValue qobj2 = eng.newQObject(this); - QVERIFY(qobj1.strictlyEquals(qobj2)); - - { - QJSValue var1 = eng.toScriptValue(QVariant(QStringList() << "a")); - QJSValue var2 = eng.toScriptValue(QVariant(QStringList() << "a")); - QVERIFY(var1.isArray()); - QVERIFY(var2.isArray()); - QVERIFY(!var1.strictlyEquals(var2)); - } - { - QJSValue var1 = eng.toScriptValue(QVariant(QStringList() << "a")); - QJSValue var2 = eng.toScriptValue(QVariant(QStringList() << "b")); - QVERIFY(!var1.strictlyEquals(var2)); - } - { - QJSValue var1 = eng.toScriptValue(QVariant(QPoint(1, 2))); - QJSValue var2 = eng.toScriptValue(QVariant(QPoint(1, 2))); - QVERIFY(!var1.strictlyEquals(var2)); - } - { - QJSValue var1 = eng.toScriptValue(QVariant(QPoint(1, 2))); - QJSValue var2 = eng.toScriptValue(QVariant(QPoint(3, 4))); - QVERIFY(!var1.strictlyEquals(var2)); - } - - QJSEngine otherEngine; - QTest::ignoreMessage(QtWarningMsg, "QJSValue::strictlyEquals: " - "cannot compare to a value created in " - "a different engine"); - QCOMPARE(date1.strictlyEquals(otherEngine.toScriptValue(123)), false); -} - -Q_DECLARE_METATYPE(int*) -Q_DECLARE_METATYPE(double*) -Q_DECLARE_METATYPE(QColor*) -Q_DECLARE_METATYPE(QBrush*) - -void tst_QJSValue::castToPointer() -{ - QJSEngine eng; - { - QColor c(123, 210, 231); - QJSValue v = eng.toScriptValue(c); - QColor *cp = qjsvalue_cast(v); - QVERIFY(cp != 0); - QCOMPARE(*cp, c); - - QBrush *bp = qjsvalue_cast(v); - QVERIFY(bp == 0); - - QJSValue v2 = eng.toScriptValue(qVariantFromValue(cp)); - QCOMPARE(qjsvalue_cast(v2), cp); - } -} - -void tst_QJSValue::prettyPrinter_data() -{ - QTest::addColumn("function"); - QTest::addColumn("expected"); - QTest::newRow("function() { }") << QString("function() { }") << QString("function () { }"); - QTest::newRow("function foo() { }") << QString("(function foo() { })") << QString("function foo() { }"); - QTest::newRow("function foo(bar) { }") << QString("(function foo(bar) { })") << QString("function foo(bar) { }"); - QTest::newRow("function foo(bar, baz) { }") << QString("(function foo(bar, baz) { })") << QString("function foo(bar, baz) { }"); - QTest::newRow("this") << QString("function() { this; }") << QString("function () { this; }"); - QTest::newRow("identifier") << QString("function(a) { a; }") << QString("function (a) { a; }"); - QTest::newRow("null") << QString("function() { null; }") << QString("function () { null; }"); - QTest::newRow("true") << QString("function() { true; }") << QString("function () { true; }"); - QTest::newRow("false") << QString("function() { false; }") << QString("function () { false; }"); - QTest::newRow("string") << QString("function() { 'test'; }") << QString("function () { \'test\'; }"); - QTest::newRow("string") << QString("function() { \"test\"; }") << QString("function () { \"test\"; }"); - QTest::newRow("number") << QString("function() { 123; }") << QString("function () { 123; }"); - QTest::newRow("number") << QString("function() { 123.456; }") << QString("function () { 123.456; }"); - QTest::newRow("regexp") << QString("function() { /hello/; }") << QString("function () { /hello/; }"); - QTest::newRow("regexp") << QString("function() { /hello/gim; }") << QString("function () { /hello/gim; }"); - QTest::newRow("array") << QString("function() { []; }") << QString("function () { []; }"); - QTest::newRow("array") << QString("function() { [10]; }") << QString("function () { [10]; }"); - QTest::newRow("array") << QString("function() { [10, 20, 30]; }") << QString("function () { [10, 20, 30]; }"); - QTest::newRow("array") << QString("function() { [10, 20, , 40]; }") << QString("function () { [10, 20, , 40]; }"); - QTest::newRow("array") << QString("function() { [,]; }") << QString("function () { [,]; }"); - QTest::newRow("array") << QString("function() { [, 10]; }") << QString("function () { [, 10]; }"); - QTest::newRow("array") << QString("function() { [, 10, ]; }") << QString("function () { [, 10, ]; }"); - QTest::newRow("array") << QString("function() { [, 10, ,]; }") << QString("function () { [, 10, ,]; }"); - QTest::newRow("array") << QString("function() { [[10], [20]]; }") << QString("function () { [[10], [20]]; }"); - QTest::newRow("member") << QString("function() { a.b; }") << QString("function () { a.b; }"); - QTest::newRow("member") << QString("function() { a.b.c; }") << QString("function () { a.b.c; }"); - QTest::newRow("call") << QString("function() { f(); }") << QString("function () { f(); }"); - QTest::newRow("call") << QString("function() { f(a); }") << QString("function () { f(a); }"); - QTest::newRow("call") << QString("function() { f(a, b); }") << QString("function () { f(a, b); }"); - QTest::newRow("new") << QString("function() { new C(); }") << QString("function () { new C(); }"); - QTest::newRow("new") << QString("function() { new C(a); }") << QString("function () { new C(a); }"); - QTest::newRow("new") << QString("function() { new C(a, b); }") << QString("function () { new C(a, b); }"); - QTest::newRow("++") << QString("function() { a++; }") << QString("function () { a++; }"); - QTest::newRow("++") << QString("function() { ++a; }") << QString("function () { ++a; }"); - QTest::newRow("--") << QString("function() { a--; }") << QString("function () { a--; }"); - QTest::newRow("--") << QString("function() { --a; }") << QString("function () { --a; }"); - QTest::newRow("delete") << QString("function() { delete a; }") << QString("function () { delete a; }"); - QTest::newRow("void") << QString("function() { void a; }") << QString("function () { void a; }"); - QTest::newRow("typeof") << QString("function() { typeof a; }") << QString("function () { typeof a; }"); - QTest::newRow("+") << QString("function() { +a; }") << QString("function () { +a; }"); - QTest::newRow("-") << QString("function() { -a; }") << QString("function () { -a; }"); - QTest::newRow("~") << QString("function() { ~a; }") << QString("function () { ~a; }"); - QTest::newRow("!") << QString("function() { !a; }") << QString("function () { !a; }"); - QTest::newRow("+") << QString("function() { a + b; }") << QString("function () { a + b; }"); - QTest::newRow("&&") << QString("function() { a && b; }") << QString("function () { a && b; }"); - QTest::newRow("&=") << QString("function() { a &= b; }") << QString("function () { a &= b; }"); - QTest::newRow("=") << QString("function() { a = b; }") << QString("function () { a = b; }"); - QTest::newRow("&") << QString("function() { a & b; }") << QString("function () { a & b; }"); - QTest::newRow("|") << QString("function() { a | b; }") << QString("function () { a | b; }"); - QTest::newRow("^") << QString("function() { a ^ b; }") << QString("function () { a ^ b; }"); - QTest::newRow("-=") << QString("function() { a -= b; }") << QString("function () { a -= b; }"); - QTest::newRow("/") << QString("function() { a / b; }") << QString("function () { a / b; }"); - QTest::newRow("/=") << QString("function() { a /= b; }") << QString("function () { a /= b; }"); - QTest::newRow("==") << QString("function() { a == b; }") << QString("function () { a == b; }"); - QTest::newRow(">=") << QString("function() { a >= b; }") << QString("function () { a >= b; }"); - QTest::newRow(">") << QString("function() { a > b; }") << QString("function () { a > b; }"); - QTest::newRow("in") << QString("function() { a in b; }") << QString("function () { a in b; }"); - QTest::newRow("+=") << QString("function() { a += b; }") << QString("function () { a += b; }"); - QTest::newRow("instanceof") << QString("function() { a instanceof b; }") << QString("function () { a instanceof b; }"); - QTest::newRow("<=") << QString("function() { a <= b; }") << QString("function () { a <= b; }"); - QTest::newRow("<<") << QString("function() { a << b; }") << QString("function () { a << b; }"); - QTest::newRow("<<=") << QString("function() { a <<= b; }") << QString("function () { a <<= b; }"); - QTest::newRow("<") << QString("function() { a < b; }") << QString("function () { a < b; }"); - QTest::newRow("%") << QString("function() { a % b; }") << QString("function () { a % b; }"); - QTest::newRow("%=") << QString("function() { a %= b; }") << QString("function () { a %= b; }"); - QTest::newRow("*") << QString("function() { a * b; }") << QString("function () { a * b; }"); - QTest::newRow("*=") << QString("function() { a *= b; }") << QString("function () { a *= b; }"); - QTest::newRow("!=") << QString("function() { a != b; }") << QString("function () { a != b; }"); - QTest::newRow("||") << QString("function() { a || b; }") << QString("function () { a || b; }"); - QTest::newRow("|=") << QString("function() { a |= b; }") << QString("function () { a |= b; }"); - QTest::newRow(">>") << QString("function() { a >> b; }") << QString("function () { a >> b; }"); - QTest::newRow(">>=") << QString("function() { a >>= b; }") << QString("function () { a >>= b; }"); - QTest::newRow("===") << QString("function() { a === b; }") << QString("function () { a === b; }"); - QTest::newRow("!==") << QString("function() { a !== b; }") << QString("function () { a !== b; }"); - QTest::newRow("-") << QString("function() { a - b; }") << QString("function () { a - b; }"); - QTest::newRow(">>>") << QString("function() { a >>> b; }") << QString("function () { a >>> b; }"); - QTest::newRow(">>>=") << QString("function() { a >>>= b; }") << QString("function () { a >>>= b; }"); - QTest::newRow("^=") << QString("function() { a ^= b; }") << QString("function () { a ^= b; }"); - QTest::newRow("? :") << QString("function() { a ? b : c; }") << QString("function () { a ? b : c; }"); - QTest::newRow("a; b; c") << QString("function() { a; b; c; }") << QString("function () { a; b; c; }"); - QTest::newRow("var a;") << QString("function() { var a; }") << QString("function () { var a; }"); - QTest::newRow("var a, b;") << QString("function() { var a, b; }") << QString("function () { var a, b; }"); - QTest::newRow("var a = 10;") << QString("function() { var a = 10; }") << QString("function () { var a = 10; }"); - QTest::newRow("var a, b = 20;") << QString("function() { var a, b = 20; }") << QString("function () { var a, b = 20; }"); - QTest::newRow("var a = 10, b = 20;") << QString("function() { var a = 10, b = 20; }") << QString("function () { var a = 10, b = 20; }"); - QTest::newRow("if") << QString("function() { if (a) b; }") << QString("function () { if (a) b; }"); - QTest::newRow("if") << QString("function() { if (a) { b; c; } }") << QString("function () { if (a) { b; c; } }"); - QTest::newRow("if-else") << QString("function() { if (a) b; else c; }") << QString("function () { if (a) b; else c; }"); - QTest::newRow("if-else") << QString("function() { if (a) { b; c; } else { d; e; } }") << QString("function () { if (a) { b; c; } else { d; e; } }"); - QTest::newRow("do-while") << QString("function() { do { a; } while (b); }") << QString("function () { do { a; } while (b); }"); - QTest::newRow("do-while") << QString("function() { do { a; b; c; } while (d); }") << QString("function () { do { a; b; c; } while (d); }"); - QTest::newRow("while") << QString("function() { while (a) { b; } }") << QString("function () { while (a) { b; } }"); - QTest::newRow("while") << QString("function() { while (a) { b; c; } }") << QString("function () { while (a) { b; c; } }"); - QTest::newRow("for") << QString("function() { for (a; b; c) { } }") << QString("function () { for (a; b; c) { } }"); - QTest::newRow("for") << QString("function() { for (; a; b) { } }") << QString("function () { for (; a; b) { } }"); - QTest::newRow("for") << QString("function() { for (; ; a) { } }") << QString("function () { for (; ; a) { } }"); - QTest::newRow("for") << QString("function() { for (; ; ) { } }") << QString("function () { for (; ; ) { } }"); - QTest::newRow("for") << QString("function() { for (var a; b; c) { } }") << QString("function () { for (var a; b; c) { } }"); - QTest::newRow("for") << QString("function() { for (var a, b, c; d; e) { } }") << QString("function () { for (var a, b, c; d; e) { } }"); - QTest::newRow("continue") << QString("function() { for (; ; ) { continue; } }") << QString("function () { for (; ; ) { continue; } }"); - QTest::newRow("break") << QString("function() { for (; ; ) { break; } }") << QString("function () { for (; ; ) { break; } }"); - QTest::newRow("return") << QString("function() { return; }") << QString("function () { return; }"); - QTest::newRow("return") << QString("function() { return 10; }") << QString("function () { return 10; }"); - QTest::newRow("with") << QString("function() { with (a) { b; } }") << QString("function () { with (a) { b; } }"); - QTest::newRow("with") << QString("function() { with (a) { b; c; } }") << QString("function () { with (a) { b; c; } }"); - QTest::newRow("switch") << QString("function() { switch (a) { } }") << QString("function () { switch (a) { } }"); - QTest::newRow("switch") << QString("function() { switch (a) { case 1: ; } }") << QString("function () { switch (a) { case 1: ; } }"); - QTest::newRow("switch") << QString("function() { switch (a) { case 1: b; break; } }") << QString("function () { switch (a) { case 1: b; break; } }"); - QTest::newRow("switch") << QString("function() { switch (a) { case 1: b; break; case 2: break; } }") << QString("function () { switch (a) { case 1: b; break; case 2: break; } }"); - QTest::newRow("switch") << QString("function() { switch (a) { case 1: case 2: ; } }") << QString("function () { switch (a) { case 1: case 2: ; } }"); - QTest::newRow("switch") << QString("function() { switch (a) { case 1: default: ; } }") << QString("function () { switch (a) { case 1: default: ; } }"); - QTest::newRow("switch") << QString("function() { switch (a) { case 1: default: ; case 3: ; } }") << QString("function () { switch (a) { case 1: default: ; case 3: ; } }"); - QTest::newRow("label") << QString("function() { a: b; }") << QString("function () { a: b; }"); - QTest::newRow("throw") << QString("function() { throw a; }") << QString("function () { throw a; }"); - QTest::newRow("try-catch") << QString("function() { try { a; } catch (e) { b; } }") << QString("function () { try { a; } catch (e) { b; } }"); - QTest::newRow("try-finally") << QString("function() { try { a; } finally { b; } }") << QString("function () { try { a; } finally { b; } }"); - QTest::newRow("try-catch-finally") << QString("function() { try { a; } catch (e) { b; } finally { c; } }") << QString("function () { try { a; } catch (e) { b; } finally { c; } }"); - QTest::newRow("a + b + c + d") << QString("function() { a + b + c + d; }") << QString("function () { a + b + c + d; }"); - QTest::newRow("a + b - c") << QString("function() { a + b - c; }") << QString("function () { a + b - c; }"); - QTest::newRow("a + -b") << QString("function() { a + -b; }") << QString("function () { a + -b; }"); - QTest::newRow("a + ~b") << QString("function() { a + ~b; }") << QString("function () { a + ~b; }"); - QTest::newRow("a + !b") << QString("function() { a + !b; }") << QString("function () { a + !b; }"); - QTest::newRow("a + +b") << QString("function() { a + +b; }") << QString("function () { a + +b; }"); - QTest::newRow("(a + b) - c") << QString("function() { (a + b) - c; }") << QString("function () { (a + b) - c; }"); - QTest::newRow("(a - b + c") << QString("function() { a - b + c; }") << QString("function () { a - b + c; }"); - QTest::newRow("(a - (b + c)") << QString("function() { a - (b + c); }") << QString("function () { a - (b + c); }"); - QTest::newRow("a + -(b + c)") << QString("function() { a + -(b + c); }") << QString("function () { a + -(b + c); }"); - QTest::newRow("a + ~(b + c)") << QString("function() { a + ~(b + c); }") << QString("function () { a + ~(b + c); }"); - QTest::newRow("a + !(b + c)") << QString("function() { a + !(b + c); }") << QString("function () { a + !(b + c); }"); - QTest::newRow("a + +(b + c)") << QString("function() { a + +(b + c); }") << QString("function () { a + +(b + c); }"); - QTest::newRow("a + b * c") << QString("function() { a + b * c; }") << QString("function () { a + b * c; }"); - QTest::newRow("(a + b) * c") << QString("function() { (a + b) * c; }") << QString("function () { (a + b) * c; }"); - QTest::newRow("(a + b) * (c + d)") << QString("function() { (a + b) * (c + d); }") << QString("function () { (a + b) * (c + d); }"); - QTest::newRow("a + (b * c)") << QString("function() { a + (b * c); }") << QString("function () { a + (b * c); }"); - QTest::newRow("a + (b / c)") << QString("function() { a + (b / c); }") << QString("function () { a + (b / c); }"); - QTest::newRow("(a / b) * c") << QString("function() { (a / b) * c; }") << QString("function () { (a / b) * c; }"); - QTest::newRow("a / (b * c)") << QString("function() { a / (b * c); }") << QString("function () { a / (b * c); }"); - QTest::newRow("a / (b % c)") << QString("function() { a / (b % c); }") << QString("function () { a / (b % c); }"); - QTest::newRow("a && b || c") << QString("function() { a && b || c; }") << QString("function () { a && b || c; }"); - QTest::newRow("a && (b || c)") << QString("function() { a && (b || c); }") << QString("function () { a && (b || c); }"); - QTest::newRow("a & b | c") << QString("function() { a & b | c; }") << QString("function () { a & b | c; }"); - QTest::newRow("a & (b | c)") << QString("function() { a & (b | c); }") << QString("function () { a & (b | c); }"); - QTest::newRow("a & b | c ^ d") << QString("function() { a & b | c ^ d; }") << QString("function () { a & b | c ^ d; }"); - QTest::newRow("a & (b | c ^ d)") << QString("function() { a & (b | c ^ d); }") << QString("function () { a & (b | c ^ d); }"); - QTest::newRow("(a & b | c) ^ d") << QString("function() { (a & b | c) ^ d; }") << QString("function () { (a & b | c) ^ d; }"); - QTest::newRow("a << b + c") << QString("function() { a << b + c; }") << QString("function () { a << b + c; }"); - QTest::newRow("(a << b) + c") << QString("function() { (a << b) + c; }") << QString("function () { (a << b) + c; }"); - QTest::newRow("a >> b + c") << QString("function() { a >> b + c; }") << QString("function () { a >> b + c; }"); - QTest::newRow("(a >> b) + c") << QString("function() { (a >> b) + c; }") << QString("function () { (a >> b) + c; }"); - QTest::newRow("a >>> b + c") << QString("function() { a >>> b + c; }") << QString("function () { a >>> b + c; }"); - QTest::newRow("(a >>> b) + c") << QString("function() { (a >>> b) + c; }") << QString("function () { (a >>> b) + c; }"); - QTest::newRow("a == b || c != d") << QString("function() { a == b || c != d; }") << QString("function () { a == b || c != d; }"); - QTest::newRow("a == (b || c != d)") << QString("function() { a == (b || c != d); }") << QString("function () { a == (b || c != d); }"); - QTest::newRow("a === b || c !== d") << QString("function() { a === b || c !== d; }") << QString("function () { a === b || c !== d; }"); - QTest::newRow("a === (b || c !== d)") << QString("function() { a === (b || c !== d); }") << QString("function () { a === (b || c !== d); }"); - QTest::newRow("a &= b + c") << QString("function() { a &= b + c; }") << QString("function () { a &= b + c; }"); - QTest::newRow("debugger") << QString("function() { debugger; }") << QString("function () { debugger; }"); -} - -void tst_QJSValue::prettyPrinter() -{ - QFETCH(QString, function); - QFETCH(QString, expected); - QJSEngine eng; - QJSValue val = eng.evaluate("(" + function + ")"); - QVERIFY(val.isCallable()); - QString actual = val.toString(); - int count = qMin(actual.size(), expected.size()); -// qDebug() << actual << expected; - for (int i = 0; i < count; ++i) { -// qDebug() << i << actual.at(i) << expected.at(i); - QCOMPARE(actual.at(i), expected.at(i)); - } - QCOMPARE(actual.size(), expected.size()); -} - -void tst_QJSValue::engineDeleted() -{ - QJSEngine *eng = new QJSEngine; - QJSValue v1 = eng->toScriptValue(123); - QVERIFY(v1.isNumber()); - QJSValue v2 = eng->toScriptValue(QString("ciao")); - QVERIFY(v2.isString()); - QJSValue v3 = eng->newObject(); - QVERIFY(v3.isObject()); - QJSValue v4 = eng->newQObject(this); - QVERIFY(v4.isQObject()); - QJSValue v5 = "Hello"; - QVERIFY(v2.isString()); - - delete eng; - - QVERIFY(v1.isUndefined()); - QVERIFY(v1.engine() == 0); - QVERIFY(v2.isUndefined()); - QVERIFY(v2.engine() == 0); - QVERIFY(v3.isUndefined()); - QVERIFY(v3.engine() == 0); - QVERIFY(v4.isUndefined()); - QVERIFY(v4.engine() == 0); - QVERIFY(v5.isString()); // was not bound to engine - QVERIFY(v5.engine() == 0); - - QVERIFY(v3.property("foo").isUndefined()); -} - -void tst_QJSValue::valueOfWithClosure() -{ - QJSEngine eng; - // valueOf() - { - QJSValue obj = eng.evaluate("o = {}; (function(foo) { o.valueOf = function() { return foo; } })(123); o"); - QVERIFY(obj.isObject()); - QCOMPARE(obj.toInt(), 123); - } - // toString() - { - QJSValue obj = eng.evaluate("o = {}; (function(foo) { o.toString = function() { return foo; } })('ciao'); o"); - QVERIFY(obj.isObject()); - QCOMPARE(obj.toString(), QString::fromLatin1("ciao")); - } -} - -#if 0 // FIXME: no objectId() -void tst_QJSValue::objectId() -{ - QCOMPARE(QJSValue().objectId(), (qint64)-1); - QCOMPARE(QJSValue(QJSValue::UndefinedValue).objectId(), (qint64)-1); - QCOMPARE(QJSValue(QJSValue::NullValue).objectId(), (qint64)-1); - QCOMPARE(QJSValue(false).objectId(), (qint64)-1); - QCOMPARE(QJSValue(123).objectId(), (qint64)-1); - QCOMPARE(QJSValue(uint(123)).objectId(), (qint64)-1); - QCOMPARE(QJSValue(123.5).objectId(), (qint64)-1); - QCOMPARE(QJSValue("ciao").objectId(), (qint64)-1); - - QScriptEngine eng; - QJSValue o1 = eng.newObject(); - QVERIFY(o1.objectId() != -1); - QJSValue o2 = eng.newObject(); - QVERIFY(o2.objectId() != -1); - QVERIFY(o1.objectId() != o2.objectId()); - - QVERIFY(eng.objectById(o1.objectId()).strictlyEquals(o1)); - QVERIFY(eng.objectById(o2.objectId()).strictlyEquals(o2)); - - qint64 globalObjectId = -1; - { - QJSValue global = eng.globalObject(); - globalObjectId = global.objectId(); - QVERIFY(globalObjectId != -1); - QVERIFY(eng.objectById(globalObjectId).strictlyEquals(global)); - } - QJSValue obj = eng.objectById(globalObjectId); - QVERIFY(obj.isObject()); - QVERIFY(obj.strictlyEquals(eng.globalObject())); -} -#endif - -void tst_QJSValue::nestedObjectToVariant_data() -{ - QTest::addColumn("program"); - QTest::addColumn("expected"); - - // Array literals - QTest::newRow("[[]]") - << QString::fromLatin1("[[]]") - << QVariant(QVariantList() << (QVariant(QVariantList()))); - QTest::newRow("[[123]]") - << QString::fromLatin1("[[123]]") - << QVariant(QVariantList() << (QVariant(QVariantList() << 123))); - QTest::newRow("[[], 123]") - << QString::fromLatin1("[[], 123]") - << QVariant(QVariantList() << QVariant(QVariantList()) << 123); - - // Cyclic arrays - QTest::newRow("var a=[]; a.push(a)") - << QString::fromLatin1("var a=[]; a.push(a); a") - << QVariant(QVariantList() << QVariant(QVariantList())); - QTest::newRow("var a=[]; a.push(123, a)") - << QString::fromLatin1("var a=[]; a.push(123, a); a") - << QVariant(QVariantList() << 123 << QVariant(QVariantList())); - QTest::newRow("var a=[]; var b=[]; a.push(b); b.push(a)") - << QString::fromLatin1("var a=[]; var b=[]; a.push(b); b.push(a); a") - << QVariant(QVariantList() << QVariant(QVariantList() << QVariant(QVariantList()))); - QTest::newRow("var a=[]; var b=[]; a.push(123, b); b.push(456, a)") - << QString::fromLatin1("var a=[]; var b=[]; a.push(123, b); b.push(456, a); a") - << QVariant(QVariantList() << 123 << QVariant(QVariantList() << 456 << QVariant(QVariantList()))); - - // Object literals - { - QVariantMap m; - QTest::newRow("{}") - << QString::fromLatin1("({})") - << QVariant(m); - } - { - QVariantMap m; - m["a"] = QVariantMap(); - QTest::newRow("{ a:{} }") - << QString::fromLatin1("({ a:{} })") - << QVariant(m); - } - { - QVariantMap m, m2; - m2["b"] = 10; - m2["c"] = 20; - m["a"] = m2; - QTest::newRow("{ a:{b:10, c:20} }") - << QString::fromLatin1("({ a:{b:10, c:20} })") - << QVariant(m); - } - { - QVariantMap m; - m["a"] = 10; - m["b"] = QVariantList() << 20 << 30; - QTest::newRow("{ a:10, b:[20, 30]}") - << QString::fromLatin1("({ a:10, b:[20,30]})") - << QVariant(m); - } - - // Cyclic objects - { - QVariantMap m; - m["p"] = QVariantMap(); - QTest::newRow("var o={}; o.p=o") - << QString::fromLatin1("var o={}; o.p=o; o") - << QVariant(m); - } - { - QVariantMap m; - m["p"] = 123; - m["q"] = QVariantMap(); - QTest::newRow("var o={}; o.p=123; o.q=o") - << QString::fromLatin1("var o={}; o.p=123; o.q=o; o") - << QVariant(m); - } -} - -void tst_QJSValue::nestedObjectToVariant() -{ - QJSEngine eng; - QFETCH(QString, program); - QFETCH(QVariant, expected); - QJSValue o = eng.evaluate(program); - QVERIFY(!o.isError()); - QVERIFY(o.isObject()); - QCOMPARE(o.toVariant(), expected); -} - -QTEST_MAIN(tst_QJSValue) diff --git a/tests/auto/declarative/qjsvalue/tst_qjsvalue.h b/tests/auto/declarative/qjsvalue/tst_qjsvalue.h deleted file mode 100644 index 0e7f7405a6..0000000000 --- a/tests/auto/declarative/qjsvalue/tst_qjsvalue.h +++ /dev/null @@ -1,204 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef TST_QJSVALUE_H -#define TST_QJSVALUE_H - -#include -#include -#include -#include -#include - -Q_DECLARE_METATYPE(QVariant) -Q_DECLARE_METATYPE(QJSValue) - -class tst_QJSValue : public QObject -{ - Q_OBJECT - -public: - tst_QJSValue(); - virtual ~tst_QJSValue(); - -private slots: - void ctor_invalid(); - void ctor_undefinedWithEngine(); - void ctor_undefined(); - void ctor_nullWithEngine(); - void ctor_null(); - void ctor_boolWithEngine(); - void ctor_bool(); - void ctor_intWithEngine(); - void ctor_int(); - void ctor_uintWithEngine(); - void ctor_uint(); - void ctor_floatWithEngine(); - void ctor_float(); - void ctor_stringWithEngine(); - void ctor_string(); - void ctor_copyAndAssignWithEngine(); - void ctor_copyAndAssign(); - - void toString(); - void toNumber(); - void toBoolean(); - void toBool(); - void toInt(); - void toUInt(); - void toVariant(); - void toQObject_nonQObject_data(); - void toQObject_nonQObject(); - void toQObject(); - void toDateTime(); - void toRegExp(); - void isArray_data(); - void isArray(); - void isDate(); - void isDate_data(); - void isError_propertiesOfGlobalObject(); - void isError_data(); - void isError(); - void isRegExp_data(); - void isRegExp(); - -#if 0 // FIXME: No QScriptValue::lessThan - void lessThan(); -#endif - void equals(); - void strictlyEquals(); - - void hasProperty_basic(); - void hasProperty_globalObject(); - void hasProperty_changePrototype(); - - void deleteProperty_basic(); - void deleteProperty_globalObject(); - void deleteProperty_inPrototype(); - - void getSetPrototype_cyclicPrototype(); - void getSetPrototype_evalCyclicPrototype(); - void getSetPrototype_eval(); - void getSetPrototype_invalidPrototype(); - void getSetPrototype_twoEngines(); - void getSetPrototype_null(); - void getSetPrototype_notObjectOrNull(); - void getSetPrototype(); - void getSetScope(); - void getSetProperty_HooliganTask162051(); - void getSetProperty_HooliganTask183072(); - void getSetProperty_propertyRemoval(); - void getSetProperty_resolveMode(); - void getSetProperty_twoEngines(); - void getSetProperty_gettersAndSetters(); - void getSetProperty_gettersAndSettersThrowErrorNative(); - void getSetProperty_gettersAndSettersThrowErrorJS(); - void getSetProperty_gettersAndSettersOnNative(); - void getSetProperty_gettersAndSettersOnGlobalObject(); - void getSetProperty_gettersAndSettersChange(); - void getSetProperty_gettersAndSettersStupid(); - void getSetProperty_array(); - void getSetProperty(); - void arrayElementGetterSetter(); - void getSetData_objects_data(); - void getSetData_objects(); - void getSetData_nonObjects_data(); - void getSetData_nonObjects(); - void setData_QTBUG15144(); -#if 0 // FIXME: no QScriptClass - void getSetScriptClass_emptyClass_data(); - void getSetScriptClass_emptyClass(); - void getSetScriptClass_JSObjectFromCpp(); - void getSetScriptClass_JSObjectFromJS(); - void getSetScriptClass_QVariant(); - void getSetScriptClass_QObject(); -#endif - void call_function(); - void call_object(); - void call_newObjects(); - void call_this(); - void call_arguments(); - void call(); - void call_invalidArguments(); - void call_invalidReturn(); - void call_twoEngines(); - void call_array(); - void call_nonFunction_data(); - void call_nonFunction(); - void construct_nonFunction_data(); - void construct_nonFunction(); - void construct_simple(); - void construct_newObjectJS(); -#if 0 // FIXME: no c-style callbacks - void construct_undefined(); - void construct_newObjectCpp(); -#endif - void construct_arg(); - void construct_proto(); - void construct_returnInt(); - void construct_throw(); -#if 0 // FIXME: The feature of interpreting an array as argument list has been removed from the API - void construct(); -#endif - void construct_twoEngines(); - void construct_constructorThrowsPrimitive(); - void castToPointer(); - void prettyPrinter_data(); - void prettyPrinter(); - void engineDeleted(); - void valueOfWithClosure(); -#if 0 // FIXME: no objectId() - void objectId(); -#endif - void nestedObjectToVariant_data(); - void nestedObjectToVariant(); - -private: - void newEngine() - { - if (engine) - delete engine; - engine = new QJSEngine(); - } - QJSEngine *engine; -}; - -#endif diff --git a/tests/auto/declarative/qjsvalueiterator/qjsvalueiterator.pro b/tests/auto/declarative/qjsvalueiterator/qjsvalueiterator.pro deleted file mode 100644 index 9f991c0ab6..0000000000 --- a/tests/auto/declarative/qjsvalueiterator/qjsvalueiterator.pro +++ /dev/null @@ -1,7 +0,0 @@ -CONFIG += testcase -TARGET = tst_qjsvalueiterator -macx:CONFIG -= app_bundle -QT = core declarative testlib -SOURCES += tst_qjsvalueiterator.cpp - - diff --git a/tests/auto/declarative/qjsvalueiterator/tst_qjsvalueiterator.cpp b/tests/auto/declarative/qjsvalueiterator/tst_qjsvalueiterator.cpp deleted file mode 100644 index eade3de1a7..0000000000 --- a/tests/auto/declarative/qjsvalueiterator/tst_qjsvalueiterator.cpp +++ /dev/null @@ -1,522 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - - -#include - -#include -#include -#include - -Q_DECLARE_METATYPE(QJSValue); - -class tst_QJSValueIterator : public QObject -{ - Q_OBJECT - -public: - tst_QJSValueIterator(); - virtual ~tst_QJSValueIterator(); - -private slots: - void iterateForward_data(); - void iterateForward(); - void iterateArray_data(); - void iterateArray(); - void iterateString(); -#if 0 - void iterateGetterSetter(); -#endif - void assignObjectToIterator(); - void iterateNonObject(); - void iterateOverObjectFromDeletedEngine(); -}; - -tst_QJSValueIterator::tst_QJSValueIterator() -{ -} - -tst_QJSValueIterator::~tst_QJSValueIterator() -{ -} - -void tst_QJSValueIterator::iterateForward_data() -{ - QTest::addColumn("propertyNames"); - QTest::addColumn("propertyValues"); - - QTest::newRow("no properties") - << QStringList() << QStringList(); - QTest::newRow("foo=bar") - << (QStringList() << "foo") - << (QStringList() << "bar"); - QTest::newRow("foo=bar, baz=123") - << (QStringList() << "foo" << "baz") - << (QStringList() << "bar" << "123"); - QTest::newRow("foo=bar, baz=123, rab=oof") - << (QStringList() << "foo" << "baz" << "rab") - << (QStringList() << "bar" << "123" << "oof"); -} - -void tst_QJSValueIterator::iterateForward() -{ - QFETCH(QStringList, propertyNames); - QFETCH(QStringList, propertyValues); - QMap pmap; - QVERIFY(propertyNames.size() == propertyValues.size()); - - QJSEngine engine; - QJSValue object = engine.newObject(); - for (int i = 0; i < propertyNames.size(); ++i) { - QString name = propertyNames.at(i); - QString value = propertyValues.at(i); - pmap.insert(name, value); - object.setProperty(name, engine.toScriptValue(value)); - } - QJSValue otherObject = engine.newObject(); - otherObject.setProperty("foo", engine.toScriptValue(123456)); - otherObject.setProperty("protoProperty", engine.toScriptValue(654321)); - object.setPrototype(otherObject); // should not affect iterator - - QStringList lst; - QJSValueIterator it(object); - while (!pmap.isEmpty()) { - QCOMPARE(it.hasNext(), true); - QCOMPARE(it.hasNext(), true); - it.next(); - QString name = it.name(); - QCOMPARE(pmap.contains(name), true); - QCOMPARE(it.name(), name); - QCOMPARE(it.value().strictlyEquals(engine.toScriptValue(pmap.value(name))), true); - pmap.remove(name); - lst.append(name); - } - - QCOMPARE(it.hasNext(), false); - QCOMPARE(it.hasNext(), false); - - it = object; - for (int i = 0; i < lst.count(); ++i) { - QCOMPARE(it.hasNext(), true); - it.next(); - QCOMPARE(it.name(), lst.at(i)); - } -} - -void tst_QJSValueIterator::iterateArray_data() -{ - QTest::addColumn("propertyNames"); - QTest::addColumn("propertyValues"); - - QTest::newRow("no elements") << QStringList() << QStringList(); - - QTest::newRow("0=foo, 1=barr") - << (QStringList() << "0" << "1") - << (QStringList() << "foo" << "bar"); - - - QTest::newRow("0=foo, 3=barr") - << (QStringList() << "0" << "1" << "2" << "3") - << (QStringList() << "foo" << "" << "" << "bar"); -} - -void tst_QJSValueIterator::iterateArray() -{ - QFETCH(QStringList, propertyNames); - QFETCH(QStringList, propertyValues); - - QJSEngine engine; - QJSValue array = engine.newArray(); - - // Fill the array - for (int i = 0; i < propertyNames.size(); ++i) { - array.setProperty(propertyNames.at(i), propertyValues.at(i)); - } - - // Iterate thru array properties. Note that the QJSValueIterator doesn't guarantee - // any order on the iteration! - int length = array.property("length").toInt(); - QCOMPARE(length, propertyNames.size()); - - bool iteratedThruLength = false; - QHash arrayProperties; - QJSValueIterator it(array); - - // Iterate forward - while (it.hasNext()) { - it.next(); - - const QString name = it.name(); - if (name == QString::fromLatin1("length")) { - QVERIFY(it.value().isNumber()); - QCOMPARE(it.value().toInt(), length); - QVERIFY2(!iteratedThruLength, "'length' appeared more than once during iteration."); - iteratedThruLength = true; - continue; - } - - // Storing the properties we iterate in a hash to compare with test data. - QVERIFY2(!arrayProperties.contains(name), "property appeared more than once during iteration."); - arrayProperties.insert(name, it.value()); - QVERIFY(it.value().strictlyEquals(array.property(name))); - } - - // Verify properties - QVERIFY(iteratedThruLength); - QCOMPARE(arrayProperties.size(), propertyNames.size()); - for (int i = 0; i < propertyNames.size(); ++i) { - QVERIFY(arrayProperties.contains(propertyNames.at(i))); - QCOMPARE(arrayProperties.value(propertyNames.at(i)).toString(), propertyValues.at(i)); - } - -#if 0 - - // Iterate backwards - arrayProperties.clear(); - iteratedThruLength = false; - it.toBack(); - - while (it.hasPrevious()) { - it.previous(); - - const QString name = it.name(); - if (name == QString::fromLatin1("length")) { - QVERIFY(it.value().isNumber()); - QCOMPARE(it.value().toInt(), length); - QCOMPARE(it.flags(), QScriptValue::SkipInEnumeration | QScriptValue::Undeletable); - QVERIFY2(!iteratedThruLength, "'length' appeared more than once during iteration."); - iteratedThruLength = true; - continue; - } - - // Storing the properties we iterate in a hash to compare with test data. - QVERIFY2(!arrayProperties.contains(name), "property appeared more than once during iteration."); - arrayProperties.insert(name, it.value()); - QCOMPARE(it.flags(), array.propertyFlags(name)); - QVERIFY(it.value().strictlyEquals(array.property(name))); - } - - // Verify properties - QVERIFY(iteratedThruLength); - QCOMPARE(arrayProperties.size(), propertyNames.size()); - for (int i = 0; i < propertyNames.size(); ++i) { - QVERIFY(arrayProperties.contains(propertyNames.at(i))); - QCOMPARE(arrayProperties.value(propertyNames.at(i)).toString(), propertyValues.at(i)); - } - - // ### Do we still need this test? - // Forward test again but as object - arrayProperties.clear(); - iteratedThruLength = false; - QJSValue arrayObject = engine.toObject(array); - QJSValueIterator it2(arrayObject); - - while (it2.hasNext()) { - it2.next(); - - const QString name = it2.name(); - if (name == QString::fromLatin1("length")) { - QVERIFY(it2.value().isNumber()); - QCOMPARE(it2.value().toInt(), length); - QCOMPARE(it2.flags(), QScriptValue::SkipInEnumeration | QScriptValue::Undeletable); - QVERIFY2(!iteratedThruLength, "'length' appeared more than once during iteration."); - iteratedThruLength = true; - continue; - } - - // Storing the properties we iterate in a hash to compare with test data. - QVERIFY2(!arrayProperties.contains(name), "property appeared more than once during iteration."); - arrayProperties.insert(name, it2.value()); - QCOMPARE(it2.flags(), arrayObject.propertyFlags(name)); - QVERIFY(it2.value().strictlyEquals(arrayObject.property(name))); - } - - // Verify properties - QVERIFY(iteratedThruLength); - QCOMPARE(arrayProperties.size(), propertyNames.size()); - for (int i = 0; i < propertyNames.size(); ++i) { - QVERIFY(arrayProperties.contains(propertyNames.at(i))); - QCOMPARE(arrayProperties.value(propertyNames.at(i)).toString(), propertyValues.at(i)); - } -#endif -} - -void tst_QJSValueIterator::iterateString() -{ - QJSEngine engine; - QJSValue obj = engine.evaluate("new String('ciao')"); - QVERIFY(obj.property("length").isNumber()); - int length = obj.property("length").toInt(); - QCOMPARE(length, 4); - - QJSValueIterator it(obj); - QHash stringProperties; - bool iteratedThruLength = false; - - while (it.hasNext()) { - it.next(); - const QString name = it.name(); - - if (name == QString::fromLatin1("length")) { - QVERIFY(it.value().isNumber()); - QCOMPARE(it.value().toInt(), length); - QVERIFY2(!iteratedThruLength, "'length' appeared more than once during iteration."); - iteratedThruLength = true; - continue; - } - - QVERIFY2(!stringProperties.contains(name), "property appeared more than once during iteration."); - stringProperties.insert(name, it.value()); - QVERIFY(it.value().strictlyEquals(obj.property(name))); - } - - QVERIFY(iteratedThruLength); - QCOMPARE(stringProperties.size(), length); -#if 0 - // And going backwards - iteratedThruLength = false; - stringProperties.clear(); - it.toBack(); - - while (it.hasPrevious()) { - it.previous(); - const QString name = it.name(); - - if (name == QString::fromLatin1("length")) { - QVERIFY(it.value().isNumber()); - QCOMPARE(it.value().toInt(), length); - QVERIFY2(!iteratedThruLength, "'length' appeared more than once during iteration."); - iteratedThruLength = true; - continue; - } - - QVERIFY2(!stringProperties.contains(name), "property appeared more than once during iteration."); - stringProperties.insert(name, it.value()); - QVERIFY(it.value().strictlyEquals(obj.property(name))); - } -#endif -} - -#if 0 // FIXME what we should to keep from here? -static QJSValue myGetterSetter(QScriptContext *ctx, QJSEngine *) -{ - if (ctx->argumentCount() == 1) - ctx->thisObject().setProperty("bar", ctx->argument(0)); - return ctx->thisObject().property("bar"); -} - -static QJSValue myGetter(QScriptContext *ctx, QJSEngine *) -{ - return ctx->thisObject().property("bar"); -} - -static QJSValue mySetter(QScriptContext *ctx, QJSEngine *) -{ - ctx->thisObject().setProperty("bar", ctx->argument(0)); - return ctx->argument(0); -} - -void tst_QJSValueIterator::iterateGetterSetter() -{ - // unified getter/setter function - { - QJSEngine eng; - QJSValue obj = eng.newObject(); - obj.setProperty("foo", eng.newFunction(myGetterSetter), - QScriptValue::PropertyGetter | QScriptValue::PropertySetter); - QJSValue val(&eng, 123); - obj.setProperty("foo", val); - QVERIFY(obj.property("bar").strictlyEquals(val)); - QVERIFY(obj.property("foo").strictlyEquals(val)); - - QJSValueIterator it(obj); - QVERIFY(it.hasNext()); - it.next(); - QCOMPARE(it.name(), QString::fromLatin1("foo")); - QCOMPARE(it.flags(), QScriptValue::PropertyFlags(QScriptValue::PropertyGetter | QScriptValue::PropertySetter)); - QVERIFY(it.value().strictlyEquals(val)); - QJSValue val2(&eng, 456); - it.setValue(val2); - QVERIFY(obj.property("bar").strictlyEquals(val2)); - QVERIFY(obj.property("foo").strictlyEquals(val2)); - - QVERIFY(it.hasNext()); - it.next(); - QCOMPARE(it.name(), QString::fromLatin1("bar")); - QVERIFY(!it.hasNext()); - - QVERIFY(it.hasPrevious()); - it.previous(); - QCOMPARE(it.name(), QString::fromLatin1("bar")); - QVERIFY(it.hasPrevious()); - it.previous(); - QCOMPARE(it.name(), QString::fromLatin1("foo")); - QCOMPARE(it.flags(), QScriptValue::PropertyFlags(QScriptValue::PropertyGetter | QScriptValue::PropertySetter)); - QVERIFY(it.value().strictlyEquals(val2)); - it.setValue(val); - QVERIFY(obj.property("bar").strictlyEquals(val)); - QVERIFY(obj.property("foo").strictlyEquals(val)); - } - // separate getter/setter function - for (int x = 0; x < 2; ++x) { - QJSEngine eng; - QJSValue obj = eng.newObject(); - if (x == 0) { - obj.setProperty("foo", eng.newFunction(myGetter), QScriptValue::PropertyGetter); - obj.setProperty("foo", eng.newFunction(mySetter), QScriptValue::PropertySetter); - } else { - obj.setProperty("foo", eng.newFunction(mySetter), QScriptValue::PropertySetter); - obj.setProperty("foo", eng.newFunction(myGetter), QScriptValue::PropertyGetter); - } - QJSValue val(&eng, 123); - obj.setProperty("foo", val); - QVERIFY(obj.property("bar").strictlyEquals(val)); - QVERIFY(obj.property("foo").strictlyEquals(val)); - - QJSValueIterator it(obj); - QVERIFY(it.hasNext()); - it.next(); - QCOMPARE(it.name(), QString::fromLatin1("foo")); - QVERIFY(it.value().strictlyEquals(val)); - QJSValue val2(&eng, 456); - it.setValue(val2); - QVERIFY(obj.property("bar").strictlyEquals(val2)); - QVERIFY(obj.property("foo").strictlyEquals(val2)); - - QVERIFY(it.hasNext()); - it.next(); - QCOMPARE(it.name(), QString::fromLatin1("bar")); - QVERIFY(!it.hasNext()); - - QVERIFY(it.hasPrevious()); - it.previous(); - QCOMPARE(it.name(), QString::fromLatin1("bar")); - QVERIFY(it.hasPrevious()); - it.previous(); - QCOMPARE(it.name(), QString::fromLatin1("foo")); - QVERIFY(it.value().strictlyEquals(val2)); - it.setValue(val); - QVERIFY(obj.property("bar").strictlyEquals(val)); - QVERIFY(obj.property("foo").strictlyEquals(val)); - } -} -#endif - -void tst_QJSValueIterator::assignObjectToIterator() -{ - QJSEngine eng; - QJSValue obj1 = eng.newObject(); - obj1.setProperty("foo", 123); - QJSValue obj2 = eng.newObject(); - obj2.setProperty("bar", 456); - - QJSValueIterator it(obj1); - QVERIFY(it.hasNext()); - it.next(); - it = obj2; - QVERIFY(it.hasNext()); - it.next(); - QCOMPARE(it.name(), QString::fromLatin1("bar")); - - it = obj1; - QVERIFY(it.hasNext()); - it.next(); - QCOMPARE(it.name(), QString::fromLatin1("foo")); - - it = obj2; - QVERIFY(it.hasNext()); - it.next(); - QCOMPARE(it.name(), QString::fromLatin1("bar")); - - it = obj2; - QVERIFY(it.hasNext()); - it.next(); - QCOMPARE(it.name(), QString::fromLatin1("bar")); -} - -void tst_QJSValueIterator::iterateNonObject() -{ - QJSValueIterator it(123); - QVERIFY(!it.hasNext()); - it.next(); - it.name(); - it.value(); - QJSValue num(5); - it = num; - QVERIFY(!it.hasNext()); -} - -void tst_QJSValueIterator::iterateOverObjectFromDeletedEngine() -{ - QJSEngine *engine = new QJSEngine; - QJSValue objet = engine->newObject(); - - // populate object with properties - QHash properties; - properties.insert("foo",1235); - properties.insert("oof",5321); - properties.insert("ofo",3521); - QHash::const_iterator i = properties.constBegin(); - for (; i != properties.constEnd(); ++i) { - objet.setProperty(i.key(), i.value()); - } - - // start iterating - QJSValueIterator it(objet); - it.next(); - QVERIFY(properties.contains(it.name())); - - delete engine; - - QVERIFY(objet.isUndefined()); - QVERIFY(it.name().isEmpty()); - QVERIFY(it.value().isUndefined()); - - QVERIFY(!it.hasNext()); - it.next(); - - QVERIFY(it.name().isEmpty()); - QVERIFY(it.value().isUndefined()); - -} - -QTEST_MAIN(tst_QJSValueIterator) -#include "tst_qjsvalueiterator.moc" diff --git a/tests/auto/declarative/qmlmin/qmlmin.pro b/tests/auto/declarative/qmlmin/qmlmin.pro deleted file mode 100644 index 61d2330b06..0000000000 --- a/tests/auto/declarative/qmlmin/qmlmin.pro +++ /dev/null @@ -1,9 +0,0 @@ -CONFIG += testcase -TARGET = tst_qmlmin -QT += declarative testlib -macx:CONFIG -= app_bundle - -SOURCES += tst_qmlmin.cpp -DEFINES += SRCDIR=\\\"$$PWD\\\" - -CONFIG += parallel_test diff --git a/tests/auto/declarative/qmlmin/tst_qmlmin.cpp b/tests/auto/declarative/qmlmin/tst_qmlmin.cpp deleted file mode 100644 index c6b019071e..0000000000 --- a/tests/auto/declarative/qmlmin/tst_qmlmin.cpp +++ /dev/null @@ -1,192 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include -#include -#include -#include -#include -#include -#include - -class tst_qmlmin : public QObject -{ - Q_OBJECT -public: - tst_qmlmin(); - -private slots: - void initTestCase(); - void qmlMinify_data(); - void qmlMinify(); - -private: - QString qmlminPath; - QStringList excludedDirs; - QStringList invalidFiles; - - QStringList findFiles(const QDir &); - bool isInvalidFile(const QFileInfo &fileName) const; -}; - -tst_qmlmin::tst_qmlmin() -{ -} - -void tst_qmlmin::initTestCase() -{ - qmlminPath = QLibraryInfo::location(QLibraryInfo::BinariesPath) + QLatin1String("/qmlmin"); -#ifdef Q_OS_WIN - qmlminPath += QLatin1String(".exe"); -#endif - if (!QFileInfo(qmlminPath).exists()) { - QString message = QString::fromLatin1("qmlmin executable not found (looked for %0)") - .arg(qmlminPath); - QFAIL(qPrintable(message)); - } - - // Add directories you want excluded here - - // These snippets are not expected to run on their own. - excludedDirs << "doc/src/snippets/declarative/visualdatamodel_rootindex"; - excludedDirs << "doc/src/snippets/declarative/qtbinding"; - excludedDirs << "doc/src/snippets/declarative/imports"; - excludedDirs << "doc/src/snippets/qtquick1/visualdatamodel_rootindex"; - excludedDirs << "doc/src/snippets/qtquick1/qtbinding"; - excludedDirs << "doc/src/snippets/qtquick1/imports"; - - // Add invalid files (i.e. files with syntax errors) - invalidFiles << "tests/auto/qtquick2/qquickloader/data/InvalidSourceComponent.qml"; - invalidFiles << "tests/auto/declarative/qdeclarativelanguage/data/dynamicObjectProperties.2.qml"; - invalidFiles << "tests/auto/declarative/qdeclarativelanguage/data/signal.3.qml"; - invalidFiles << "tests/auto/declarative/qdeclarativelanguage/data/property.4.qml"; - invalidFiles << "tests/auto/declarative/qdeclarativelanguage/data/empty.qml"; - invalidFiles << "tests/auto/declarative/qdeclarativelanguage/data/signal.2.qml"; - invalidFiles << "tests/auto/declarative/qdeclarativelanguage/data/missingObject.qml"; - invalidFiles << "tests/auto/declarative/qdeclarativelanguage/data/insertedSemicolon.1.qml"; - invalidFiles << "tests/auto/declarative/qdeclarativelanguage/data/nonexistantProperty.5.qml"; - invalidFiles << "tests/auto/declarative/qdeclarativelanguage/data/invalidRoot.1.qml"; - invalidFiles << "tests/auto/declarative/qdeclarativefolderlistmodel/data/dummy.qml"; - invalidFiles << "tests/auto/declarative/qdeclarativeecmascript/data/qtbug_22843.js"; - invalidFiles << "tests/auto/declarative/qdeclarativeecmascript/data/qtbug_22843.library.js"; - invalidFiles << "tests/auto/declarative/qdeclarativeworkerscript/data/script_error_onLoad.js"; - invalidFiles << "tests/auto/declarative/parserstress/tests/ecma_3/Unicode/regress-352044-02-n.js"; -} - -QStringList tst_qmlmin::findFiles(const QDir &d) -{ - for (int ii = 0; ii < excludedDirs.count(); ++ii) { - QString s = excludedDirs.at(ii); - if (d.absolutePath().endsWith(s)) - return QStringList(); - } - - QStringList rv; - - QStringList files = d.entryList(QStringList() << QLatin1String("*.qml") << QLatin1String("*.js"), - QDir::Files); - foreach (const QString &file, files) { - rv << d.absoluteFilePath(file); - } - - QStringList dirs = d.entryList(QDir::Dirs | QDir::NoDotAndDotDot | - QDir::NoSymLinks); - foreach (const QString &dir, dirs) { - QDir sub = d; - sub.cd(dir); - rv << findFiles(sub); - } - - return rv; -} - -bool tst_qmlmin::isInvalidFile(const QFileInfo &fileName) const -{ - foreach (const QString &invalidFile, invalidFiles) { - if (fileName.absoluteFilePath().endsWith(invalidFile)) - return true; - } - return false; -} - -/* -This test runs all the examples in the declarative UI source tree and ensures -that they start and exit cleanly. - -Examples are any .qml files under the examples/ directory that start -with a lower case letter. -*/ - -void tst_qmlmin::qmlMinify_data() -{ - QTest::addColumn("file"); - - QString examples = QLatin1String(SRCDIR) + "/../../../../examples/"; - QString tests = QLatin1String(SRCDIR) + "/../../../../tests/"; - - QStringList files; - files << findFiles(QDir(examples)); - files << findFiles(QDir(tests)); - - foreach (const QString &file, files) - QTest::newRow(qPrintable(file)) << file; -} - -void tst_qmlmin::qmlMinify() -{ - QFETCH(QString, file); - - QProcess qmlminify; - qmlminify.start(qmlminPath, QStringList() << QLatin1String("--verify-only") << file); - qmlminify.waitForFinished(); - - QCOMPARE(qmlminify.error(), QProcess::UnknownError); - QCOMPARE(qmlminify.exitStatus(), QProcess::NormalExit); - - if (isInvalidFile(file)) - QCOMPARE(qmlminify.exitCode(), EXIT_FAILURE); // cannot minify files with syntax errors - else - QCOMPARE(qmlminify.exitCode(), 0); -} - -QTEST_MAIN(tst_qmlmin) - -#include "tst_qmlmin.moc" diff --git a/tests/auto/declarative/qmlplugindump/qmlplugindump.pro b/tests/auto/declarative/qmlplugindump/qmlplugindump.pro deleted file mode 100644 index 498a520873..0000000000 --- a/tests/auto/declarative/qmlplugindump/qmlplugindump.pro +++ /dev/null @@ -1,7 +0,0 @@ -CONFIG += testcase -TARGET = tst_qmlplugindump -QT += testlib -macx:CONFIG -= app_bundle -CONFIG += parallel_test - -SOURCES += tst_qmlplugindump.cpp diff --git a/tests/auto/declarative/qmlplugindump/tst_qmlplugindump.cpp b/tests/auto/declarative/qmlplugindump/tst_qmlplugindump.cpp deleted file mode 100644 index 5512cfdfe8..0000000000 --- a/tests/auto/declarative/qmlplugindump/tst_qmlplugindump.cpp +++ /dev/null @@ -1,117 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include -#include -#include -#include -#include -#include - -class tst_qmlplugindump : public QObject -{ - Q_OBJECT -public: - tst_qmlplugindump(); - -private slots: - void initTestCase(); - void builtins(); - -private: - QString qmlplugindumpPath; -}; - -tst_qmlplugindump::tst_qmlplugindump() -{ -} - -void tst_qmlplugindump::initTestCase() -{ - qmlplugindumpPath = QLibraryInfo::location(QLibraryInfo::BinariesPath); - -#if defined(Q_OS_MAC) - qmlplugindumpPath += QLatin1String("/qmlplugindump.app/Contents/MacOS/qmlplugindump"); -#elif defined(Q_OS_WIN) - qmlplugindumpPath += QLatin1String("/qmlplugindump.exe"); -#else - qmlplugindumpPath += QLatin1String("/qmlplugindump"); -#endif - - if (!QFileInfo(qmlplugindumpPath).exists()) { - QString message = QString::fromLatin1("qmlplugindump executable not found (looked for %0)") - .arg(qmlplugindumpPath); - QFAIL(qPrintable(message)); - } -} - -void tst_qmlplugindump::builtins() -{ - QProcess dumper; - QStringList args; - args += QLatin1String("-builtins"); - dumper.start(qmlplugindumpPath, args); - dumper.waitForFinished(); - - if (dumper.error() != QProcess::UnknownError - || dumper.exitStatus() != QProcess::NormalExit) { - qWarning() << QString("Error while running '%1 %2'").arg( - qmlplugindumpPath, args.join(QLatin1String(" "))); - } - - if (dumper.error() == QProcess::FailedToStart) { - QFAIL("failed to start"); - } - if (dumper.error() == QProcess::Crashed) { - qWarning() << "stderr:\n" << dumper.readAllStandardError(); - QFAIL("crashed"); - } - - QCOMPARE(dumper.error(), QProcess::UnknownError); - QCOMPARE(dumper.exitStatus(), QProcess::NormalExit); - - const QString &result = dumper.readAllStandardOutput(); - QVERIFY(result.contains(QLatin1String("Module {"))); -} - -QTEST_MAIN(tst_qmlplugindump) - -#include "tst_qmlplugindump.moc" diff --git a/tests/auto/declarative/runall.sh b/tests/auto/declarative/runall.sh deleted file mode 100755 index 621791b6ab..0000000000 --- a/tests/auto/declarative/runall.sh +++ /dev/null @@ -1,100 +0,0 @@ -#!/bin/bash -# -############################################################################# -## -## Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -## Contact: http://www.qt-project.org/ -## -## This file is part of the test suite of the Qt Toolkit. -## -## $QT_BEGIN_LICENSE:LGPL$ -## GNU Lesser General Public License Usage -## This file may be used under the terms of the GNU Lesser General Public -## License version 2.1 as published by the Free Software Foundation and -## appearing in the file LICENSE.LGPL included in the packaging of this -## file. Please review the following information to ensure the GNU Lesser -## General Public License version 2.1 requirements will be met: -## http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -## -## In addition, as a special exception, Nokia gives you certain additional -## rights. These rights are described in the Nokia Qt LGPL Exception -## version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -## -## GNU General Public License Usage -## Alternatively, this file may be used under the terms of the GNU General -## Public License version 3.0 as published by the Free Software Foundation -## and appearing in the file LICENSE.GPL included in the packaging of this -## file. Please review the following information to ensure the GNU General -## Public License version 3.0 requirements will be met: -## http://www.gnu.org/copyleft/gpl.html. -## -## Other Usage -## Alternatively, this file may be used in accordance with the terms and -## conditions contained in a signed written agreement between you and Nokia. -## -## -## -## -## -## -## $QT_END_LICENSE$ -## -############################################################################/ - -if [ "$(uname)" = Linux ] -then - Xnest :7 2>/dev/null & - sleep 1 - trap "kill $!" EXIT - export DISPLAY=:7 - export LANG=en_US - kwin 2>/dev/null & - sleep 1 -fi - -function filter -{ - exe=$1 - skip=0 - while read line - do - if [ $skip != 0 ] - then - let skip=skip-1 - else - case "$line" in - make*Error) echo "$line";; - make*Stop) echo "$line";; - /*/bin/make*) ;; - make*) ;; - install*) ;; - QDeclarativeDebugServer:*Waiting*) ;; - QDeclarativeDebugServer:*Connection*) ;; - */qmake*) ;; - */bin/moc*) ;; - *targ.debug*) ;; - g++*) ;; - cd*) ;; - XFAIL*) skip=1;; - SKIP*) skip=1;; - PASS*) ;; - QDEBUG*) ;; - Makefile*) ;; - Config*) ;; - Totals*) ;; - \**) ;; - ./*) ;; - *tst_*) echo "$line" ;; - *) echo "$exe: $line" - esac - fi - done -} - -make -k -j1 install 2>&1 | filter build -for exe in $(make install | sed -n 's/^install .* "\([^"]*qt4\/tst_[^"]*\)".*/\1/p') -do - echo $exe - $exe 2>&1 | filter $exe -done - diff --git a/tests/auto/declarative/v4/data/conditionalExpr.qml b/tests/auto/declarative/v4/data/conditionalExpr.qml deleted file mode 100644 index b74a95a94b..0000000000 --- a/tests/auto/declarative/v4/data/conditionalExpr.qml +++ /dev/null @@ -1,6 +0,0 @@ -import Qt.v4 1.0 - -Result { - property int n: 2 - result: !n ? 100 : 0 -} diff --git a/tests/auto/declarative/v4/data/doubleBoolJump.qml b/tests/auto/declarative/v4/data/doubleBoolJump.qml deleted file mode 100644 index 2eea73b573..0000000000 --- a/tests/auto/declarative/v4/data/doubleBoolJump.qml +++ /dev/null @@ -1,18 +0,0 @@ -import QtQuick 2.0 - -Rectangle { - QtObject { - property real output: i1.p1 || i2.p2 == "text" ? 0.7 : 0 - } - - QtObject { - id: i2 - property string p2 - } - - QtObject { - id: i1 - property bool p1: false - } -} - diff --git a/tests/auto/declarative/v4/data/fetchException.qml b/tests/auto/declarative/v4/data/fetchException.qml deleted file mode 100644 index 6431fcfae8..0000000000 --- a/tests/auto/declarative/v4/data/fetchException.qml +++ /dev/null @@ -1,6 +0,0 @@ -import QtQuick 2.0 - -Item { - property Item data - property int a: data.x, 1 -} diff --git a/tests/auto/declarative/v4/data/logicalOr.2.qml b/tests/auto/declarative/v4/data/logicalOr.2.qml deleted file mode 100644 index 54fb78b127..0000000000 --- a/tests/auto/declarative/v4/data/logicalOr.2.qml +++ /dev/null @@ -1,6 +0,0 @@ -import Qt.v4 1.0 - -Result { - property string s: "foo" || "bar" - result: s == "foo" -} diff --git a/tests/auto/declarative/v4/data/logicalOr.qml b/tests/auto/declarative/v4/data/logicalOr.qml deleted file mode 100644 index 406a7d83eb..0000000000 --- a/tests/auto/declarative/v4/data/logicalOr.qml +++ /dev/null @@ -1,6 +0,0 @@ -import Qt.v4 1.0 - -Result { - property int a: 10 - result: a == 1 || a == 2 -} diff --git a/tests/auto/declarative/v4/data/nestedLogicalOr.qml b/tests/auto/declarative/v4/data/nestedLogicalOr.qml deleted file mode 100644 index c4478a3e7b..0000000000 --- a/tests/auto/declarative/v4/data/nestedLogicalOr.qml +++ /dev/null @@ -1,14 +0,0 @@ -import Qt.v4 1.0 - -Result { - property bool val1: false - property bool val2: true - property bool val3: false - - property bool b1: (false || false || true) - property bool b2: (false || (false || true)) - property bool b3: ((false || false) || true) - property bool b4: (val1 || (val2 || val3)) ? true : false - - result: b1 && b2 && b3 && b4 -} diff --git a/tests/auto/declarative/v4/data/nestedObjectAccess.qml b/tests/auto/declarative/v4/data/nestedObjectAccess.qml deleted file mode 100644 index 56cd17e41e..0000000000 --- a/tests/auto/declarative/v4/data/nestedObjectAccess.qml +++ /dev/null @@ -1,5 +0,0 @@ -import Qt.v4 1.0 - -Result { - result: nested.result -} diff --git a/tests/auto/declarative/v4/data/nullQObject.qml b/tests/auto/declarative/v4/data/nullQObject.qml deleted file mode 100644 index 00185b3988..0000000000 --- a/tests/auto/declarative/v4/data/nullQObject.qml +++ /dev/null @@ -1,7 +0,0 @@ -import QtQuick 2.0 - -Item { - property QtObject obj - property QtObject test - test: obj -} diff --git a/tests/auto/declarative/v4/data/qrealToIntRounding.qml b/tests/auto/declarative/v4/data/qrealToIntRounding.qml deleted file mode 100644 index ee3d405073..0000000000 --- a/tests/auto/declarative/v4/data/qrealToIntRounding.qml +++ /dev/null @@ -1,10 +0,0 @@ -import QtQuick 2.0 - -QtObject { - property int data: 1 - - property int test1: 6.6 + data - property int test2: 6.2 + data - property int test3: 6 + data -} - diff --git a/tests/auto/declarative/v4/data/qtbug_21883.qml b/tests/auto/declarative/v4/data/qtbug_21883.qml deleted file mode 100644 index a51f97c944..0000000000 --- a/tests/auto/declarative/v4/data/qtbug_21883.qml +++ /dev/null @@ -1,5 +0,0 @@ -import Qt.v4 1.0 - -Result { - property Result dummy: Result -} diff --git a/tests/auto/declarative/v4/data/qtbug_22816.qml b/tests/auto/declarative/v4/data/qtbug_22816.qml deleted file mode 100644 index bfa8d4948c..0000000000 --- a/tests/auto/declarative/v4/data/qtbug_22816.qml +++ /dev/null @@ -1,18 +0,0 @@ -import QtQuick 2.0 - -Item { - QtObject { - id: object - property bool prop1: true - function myfunction() { return true; } - property bool prop2: object.prop1 && myfunction(); - } - - property bool test1: object.prop1 && object.prop2 - property bool test2: object.prop1 - - Component.onCompleted: { - object.prop1 = false; - } -} - diff --git a/tests/auto/declarative/v4/data/stringComparison.qml b/tests/auto/declarative/v4/data/stringComparison.qml deleted file mode 100644 index 64b6798c69..0000000000 --- a/tests/auto/declarative/v4/data/stringComparison.qml +++ /dev/null @@ -1,34 +0,0 @@ -import QtQuick 2.0 - -QtObject { - property string string1: "aaba" - property string string2: "aa" - property string string3: "aaab" - property string string4: "c" - - property bool test1: string1 > string2 - property bool test2: string2 < string1 - property bool test3: string1 > string3 - property bool test4: string3 < string1 - property bool test5: string1 < string4 - property bool test6: string4 > string1 - - property bool test7: string1 == "aaba" - property bool test8: string1 != "baa" - property bool test9: string1 === "aaba" - property bool test10: string1 !== "baa" - property bool test11: string4 == "c" - property bool test12: string4 != "d" - property bool test13: string4 === "c" - property bool test14: string4 !== "d" - - property bool test15: string1 >= string2 - property bool test16: string2 <= string1 - property bool test17: string1 >= string3 - property bool test18: string3 <= string1 - property bool test19: string1 <= string4 - property bool test20: string4 >= string1 - property bool test21: string4 <= "c" - property bool test22: string4 >= "c" -} - diff --git a/tests/auto/declarative/v4/data/subscriptionsInConditionalExpressions.qml b/tests/auto/declarative/v4/data/subscriptionsInConditionalExpressions.qml deleted file mode 100644 index a8e05eeda1..0000000000 --- a/tests/auto/declarative/v4/data/subscriptionsInConditionalExpressions.qml +++ /dev/null @@ -1,11 +0,0 @@ -import QtQuick 2.0 - -Item { - id: thisTest - - property bool cond: true - property real a: 1 - property real result: cond ? a : a - - PropertyAction { running: true; target: thisTest; property: "a"; value: 2; } -} diff --git a/tests/auto/declarative/v4/data/unaryMinus.qml b/tests/auto/declarative/v4/data/unaryMinus.qml deleted file mode 100644 index 410654fc3c..0000000000 --- a/tests/auto/declarative/v4/data/unaryMinus.qml +++ /dev/null @@ -1,24 +0,0 @@ -import QtQuick 2.0 - -Item { - property real test1: -i1.p2 - property int test2: -i1.p2 - property real test3: -i1.p1 - property int test4: -i1.p1 - property real test5: -i1.p3 - property int test6: -i1.p3 - property real test7: -i1.p4 - property int test8: -i1.p4 - property real test9: -i1.p5 - property int test10: -i1.p5 - - QtObject { - id: i1 - property real p1: -3.7 - property int p2: 18 - property real p3: -3.3 - property int p4: -7 - property real p5: 4.4 - } - } - diff --git a/tests/auto/declarative/v4/data/unaryPlus.qml b/tests/auto/declarative/v4/data/unaryPlus.qml deleted file mode 100644 index cd5315a7cc..0000000000 --- a/tests/auto/declarative/v4/data/unaryPlus.qml +++ /dev/null @@ -1,24 +0,0 @@ -import QtQuick 2.0 - -Item { - property real test1: +i1.p2 - property int test2: +i1.p2 - property real test3: +i1.p1 - property int test4: +i1.p1 - property real test5: +i1.p3 - property int test6: +i1.p3 - property real test7: +i1.p4 - property int test8: +i1.p4 - property real test9: +i1.p5 - property int test10: +i1.p5 - - QtObject { - id: i1 - property real p1: -3.7 - property int p2: 18 - property real p3: -3.3 - property int p4: -7 - property real p5: 4.4 - } -} - diff --git a/tests/auto/declarative/v4/data/unnecessaryReeval.qml b/tests/auto/declarative/v4/data/unnecessaryReeval.qml deleted file mode 100644 index 48662d7a2d..0000000000 --- a/tests/auto/declarative/v4/data/unnecessaryReeval.qml +++ /dev/null @@ -1,7 +0,0 @@ -import Qt.v4 1.0 - -Result { - property int a: 8 - property int b: 19 - result: (a == 8)?b:7 -} diff --git a/tests/auto/declarative/v4/testtypes.cpp b/tests/auto/declarative/v4/testtypes.cpp deleted file mode 100644 index 6bfd5dc43e..0000000000 --- a/tests/auto/declarative/v4/testtypes.cpp +++ /dev/null @@ -1,49 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include "testtypes.h" - -#include - -void registerTypes() -{ - qmlRegisterType("Qt.v4", 1,0, "Result"); - qmlRegisterType(); -} diff --git a/tests/auto/declarative/v4/testtypes.h b/tests/auto/declarative/v4/testtypes.h deleted file mode 100644 index 02ba721839..0000000000 --- a/tests/auto/declarative/v4/testtypes.h +++ /dev/null @@ -1,83 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#ifndef TESTTYPES_H -#define TESTTYPES_H - -#include - -class NestedObject : public QObject -{ - Q_OBJECT - Q_PROPERTY(int dummy READ dummy); - Q_PROPERTY(int result READ result FINAL CONSTANT); - -public: - int dummy() const { return 7; } - int result() const { return 37; } -}; - -class ResultObject : public QObject -{ - Q_OBJECT - Q_PROPERTY(int result READ result WRITE setResult FINAL) - Q_PROPERTY(NestedObject *nested READ nested CONSTANT) -public: - ResultObject() : m_result(0), m_resultCounter(0) {} - - int resultCounter() const { return m_resultCounter; } - void resetResultCounter() { m_resultCounter = 0; } - - int result() const { return m_result; } - void setResult(int result) { m_result = result; m_resultCounter++; } - - NestedObject *nested() { return &m_nested; } - -private: - int m_result; - int m_resultCounter; - - NestedObject m_nested; -}; - -void registerTypes(); - -#endif // TESTTYPES_H - diff --git a/tests/auto/declarative/v4/tst_v4.cpp b/tests/auto/declarative/v4/tst_v4.cpp deleted file mode 100644 index 927dc0f082..0000000000 --- a/tests/auto/declarative/v4/tst_v4.cpp +++ /dev/null @@ -1,353 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include -#include -#include -#include -#include -#include -#include - -#include - -#include "../../shared/util.h" -#include "testtypes.h" - -class tst_v4 : public QDeclarativeDataTest -{ - Q_OBJECT -public: - tst_v4() {} - -private slots: - void initTestCase(); - - void unnecessaryReeval(); - void logicalOr(); - void nestedLogicalOr(); - void conditionalExpr(); - void qtscript(); - void qtscript_data(); - void nestedObjectAccess(); - void subscriptionsInConditionalExpressions(); - void qtbug_21883(); - void qtbug_22816(); - void stringComparison(); - void unaryMinus(); - void unaryPlus(); - -private: - QDeclarativeEngine engine; -}; - -void tst_v4::initTestCase() -{ - QDeclarativeDataTest::initTestCase(); - registerTypes(); -} - -static int v4ErrorsMsgCount = 0; -static void v4ErrorsMsgHandler(QtMsgType, const char *message) -{ - QByteArray m(message); - if (m.contains("QV4")) - v4ErrorsMsgCount++; -} - -void tst_v4::qtscript() -{ - QFETCH(QString, file); - QV4Compiler::enableBindingsTest(true); - - QDeclarativeComponent component(&engine, testFileUrl(file)); - - v4ErrorsMsgCount = 0; - QtMsgHandler old = qInstallMsgHandler(v4ErrorsMsgHandler); - - QObject *o = component.create(); - delete o; - - qInstallMsgHandler(old); - - QCOMPARE(v4ErrorsMsgCount, 0); - - QV4Compiler::enableBindingsTest(false); -} - -void tst_v4::qtscript_data() -{ - QTest::addColumn("file"); - - QTest::newRow("qreal -> int rounding") << "qrealToIntRounding.qml"; - QTest::newRow("exception on fetch") << "fetchException.qml"; - QTest::newRow("logical or") << "logicalOr.qml"; - QTest::newRow("conditional expressions") << "conditionalExpr.qml"; - QTest::newRow("double bool jump") << "doubleBoolJump.qml"; - QTest::newRow("unary minus") << "unaryMinus.qml"; - QTest::newRow("null qobject") << "nullQObject.qml"; -} - -void tst_v4::unnecessaryReeval() -{ - QDeclarativeComponent component(&engine, testFileUrl("unnecessaryReeval.qml")); - - QObject *o = component.create(); - QVERIFY(o != 0); - - ResultObject *ro = qobject_cast(o); - QVERIFY(ro != 0); - - QCOMPARE(ro->resultCounter(), 1); - QCOMPARE(ro->result(), 19); - ro->resetResultCounter(); - - ro->setProperty("b", 6); - - QCOMPARE(ro->resultCounter(), 1); - QCOMPARE(ro->result(), 6); - ro->resetResultCounter(); - - ro->setProperty("a", 14); - - QCOMPARE(ro->resultCounter(), 1); - QCOMPARE(ro->result(), 7); - ro->resetResultCounter(); - - ro->setProperty("b", 14); - QCOMPARE(ro->resultCounter(), 0); - QCOMPARE(ro->result(), 7); - - delete o; -} - -void tst_v4::logicalOr() -{ - { - QDeclarativeComponent component(&engine, testFileUrl("logicalOr.qml")); - - QObject *o = component.create(); - QVERIFY(o != 0); - - ResultObject *ro = qobject_cast(o); - QVERIFY(ro != 0); - - QCOMPARE(ro->result(), 0); - delete o; - } - - { - QDeclarativeComponent component(&engine, testFileUrl("logicalOr.2.qml")); - - QObject *o = component.create(); - QVERIFY(o != 0); - - ResultObject *ro = qobject_cast(o); - QVERIFY(ro != 0); - - QCOMPARE(ro->result(), 1); - delete o; - } -} - -void tst_v4::nestedLogicalOr() -{ - //we are primarily testing that v4 does not get caught in a loop (QTBUG-24038) - QDeclarativeComponent component(&engine, testFileUrl("nestedLogicalOr.qml")); - - QObject *o = component.create(); - QVERIFY(o != 0); - - ResultObject *ro = qobject_cast(o); - QVERIFY(ro != 0); - - QCOMPARE(ro->result(), 1); - delete o; -} - -void tst_v4::conditionalExpr() -{ - { - QDeclarativeComponent component(&engine, testFileUrl("conditionalExpr.qml")); - - QObject *o = component.create(); - QVERIFY(o != 0); - - ResultObject *ro = qobject_cast(o); - QVERIFY(ro != 0); - - QCOMPARE(ro->result(), 0); - delete o; - } -} - -// This would previously use the metaObject of the root element to result the nested access. -// That is, the index for accessing "result" would have been RootObject::result, instead of -// NestedObject::result. -void tst_v4::nestedObjectAccess() -{ - QDeclarativeComponent component(&engine, testFileUrl("nestedObjectAccess.qml")); - - QObject *o = component.create(); - QVERIFY(o != 0); - - ResultObject *ro = qobject_cast(o); - QVERIFY(ro != 0); - - QCOMPARE(ro->result(), 37); - - delete o; -} - -void tst_v4::subscriptionsInConditionalExpressions() -{ - QDeclarativeComponent component(&engine, testFileUrl("subscriptionsInConditionalExpressions.qml")); - - QObject *o = component.create(); - QVERIFY(o != 0); - - QObject *ro = qobject_cast(o); - QVERIFY(ro != 0); - - QCOMPARE(ro->property("result").toReal(), qreal(2)); - - delete o; -} - -// Crash test -void tst_v4::qtbug_21883() -{ - QDeclarativeComponent component(&engine, testFileUrl("qtbug_21883.qml")); - - QString warning = component.url().toString() + ":4: Unable to assign null to ResultObject*"; - QTest::ignoreMessage(QtWarningMsg, warning.toLatin1().constData()); - - QObject *o = component.create(); - QVERIFY(o != 0); - delete o; -} - -void tst_v4::qtbug_22816() -{ - QDeclarativeComponent component(&engine, testFileUrl("qtbug_22816.qml")); - - QObject *o = component.create(); - QVERIFY(o != 0); - QCOMPARE(o->property("test1").toBool(), false); - QCOMPARE(o->property("test2").toBool(), false); - delete o; -} - -void tst_v4::stringComparison() -{ - QDeclarativeComponent component(&engine, testFileUrl("stringComparison.qml")); - - QObject *o = component.create(); - QVERIFY(o != 0); - QCOMPARE(o->property("test1").toBool(), true); - QCOMPARE(o->property("test2").toBool(), true); - QCOMPARE(o->property("test3").toBool(), true); - QCOMPARE(o->property("test4").toBool(), true); - QCOMPARE(o->property("test5").toBool(), true); - QCOMPARE(o->property("test6").toBool(), true); - QCOMPARE(o->property("test7").toBool(), true); - QCOMPARE(o->property("test8").toBool(), true); - QCOMPARE(o->property("test9").toBool(), true); - QCOMPARE(o->property("test10").toBool(), true); - QCOMPARE(o->property("test11").toBool(), true); - QCOMPARE(o->property("test12").toBool(), true); - QCOMPARE(o->property("test13").toBool(), true); - QCOMPARE(o->property("test14").toBool(), true); - QCOMPARE(o->property("test15").toBool(), true); - QCOMPARE(o->property("test16").toBool(), true); - QCOMPARE(o->property("test17").toBool(), true); - QCOMPARE(o->property("test18").toBool(), true); - QCOMPARE(o->property("test19").toBool(), true); - QCOMPARE(o->property("test20").toBool(), true); - QCOMPARE(o->property("test21").toBool(), true); - QCOMPARE(o->property("test22").toBool(), true); - delete o; -} - -void tst_v4::unaryMinus() -{ - QDeclarativeComponent component(&engine, testFileUrl("unaryMinus.qml")); - - QObject *o = component.create(); - QVERIFY(o != 0); - - QCOMPARE(o->property("test1").toReal(), qreal(-18)); - QCOMPARE(o->property("test2").toInt(), -18); - QCOMPARE(o->property("test3").toReal(), qreal(3.7)); - QCOMPARE(o->property("test4").toInt(), 4); - QCOMPARE(o->property("test5").toReal(), qreal(3.3)); - QCOMPARE(o->property("test6").toInt(), 3); - QCOMPARE(o->property("test7").toReal(), qreal(7)); - QCOMPARE(o->property("test8").toInt(), 7); - QCOMPARE(o->property("test9").toReal(), qreal(-4.4)); - QCOMPARE(o->property("test10").toInt(), -4); - - delete o; -} - -void tst_v4::unaryPlus() -{ - QDeclarativeComponent component(&engine, testFileUrl("unaryPlus.qml")); - - QObject *o = component.create(); - QVERIFY(o != 0); - - QCOMPARE(o->property("test1").toReal(), qreal(18)); - QCOMPARE(o->property("test2").toInt(), 18); - QCOMPARE(o->property("test3").toReal(), qreal(-3.7)); - QCOMPARE(o->property("test4").toInt(), -4); - QCOMPARE(o->property("test5").toReal(), qreal(-3.3)); - QCOMPARE(o->property("test6").toInt(), -3); - QCOMPARE(o->property("test7").toReal(), qreal(-7)); - QCOMPARE(o->property("test8").toInt(), -7); - QCOMPARE(o->property("test9").toReal(), qreal(4.4)); - QCOMPARE(o->property("test10").toInt(), 4); - - delete o; -} - -QTEST_MAIN(tst_v4) - -#include "tst_v4.moc" diff --git a/tests/auto/declarative/v4/v4.pro b/tests/auto/declarative/v4/v4.pro deleted file mode 100644 index 81d12f89be..0000000000 --- a/tests/auto/declarative/v4/v4.pro +++ /dev/null @@ -1,17 +0,0 @@ -CONFIG += testcase -TARGET = tst_qdeclarativev4 -macx:CONFIG -= app_bundle - -SOURCES += tst_v4.cpp \ - testtypes.cpp -HEADERS += testtypes.h - -include (../../shared/util.pri) - -testDataFiles.files = data -testDataFiles.path = . -DEPLOYMENT += testDataFiles - -CONFIG += parallel_test - -QT += core-private gui-private v8-private declarative-private network testlib diff --git a/tests/auto/headersclean/headersclean.pro b/tests/auto/headersclean/headersclean.pro index 16802b7e06..4ce05fe512 100644 --- a/tests/auto/headersclean/headersclean.pro +++ b/tests/auto/headersclean/headersclean.pro @@ -3,4 +3,4 @@ TARGET = tst_headersclean SOURCES += tst_headersclean.cpp QT = core testlib -contains(QT_CONFIG,declarative): QT += declarative declarative-private +contains(QT_CONFIG,qml): QT += qml qml-private diff --git a/tests/auto/headersclean/tst_headersclean.cpp b/tests/auto/headersclean/tst_headersclean.cpp index 132eb90231..d5131f96cd 100644 --- a/tests/auto/headersclean/tst_headersclean.cpp +++ b/tests/auto/headersclean/tst_headersclean.cpp @@ -49,7 +49,7 @@ #include #include -#include +#include class tst_HeadersClean: public QObject { diff --git a/tests/auto/particles/qquickage/qquickage.pro b/tests/auto/particles/qquickage/qquickage.pro index 99c52dfdae..6616ec45ee 100644 --- a/tests/auto/particles/qquickage/qquickage.pro +++ b/tests/auto/particles/qquickage/qquickage.pro @@ -7,5 +7,5 @@ testDataFiles.files = data testDataFiles.path = . DEPLOYMENT += testDataFiles -QT += core-private gui-private v8-private declarative-private quick-private opengl-private testlib +QT += core-private gui-private v8-private qml-private quick-private opengl-private testlib diff --git a/tests/auto/particles/qquickangleddirection/qquickangleddirection.pro b/tests/auto/particles/qquickangleddirection/qquickangleddirection.pro index 235f0d81b0..ac37973695 100644 --- a/tests/auto/particles/qquickangleddirection/qquickangleddirection.pro +++ b/tests/auto/particles/qquickangleddirection/qquickangleddirection.pro @@ -7,5 +7,5 @@ testDataFiles.files = data testDataFiles.path = . DEPLOYMENT += testDataFiles -QT += core-private gui-private v8-private declarative-private quick-private opengl-private testlib +QT += core-private gui-private v8-private qml-private quick-private opengl-private testlib diff --git a/tests/auto/particles/qquickcumulativedirection/qquickcumulativedirection.pro b/tests/auto/particles/qquickcumulativedirection/qquickcumulativedirection.pro index 09fe1aa06a..42029ce721 100644 --- a/tests/auto/particles/qquickcumulativedirection/qquickcumulativedirection.pro +++ b/tests/auto/particles/qquickcumulativedirection/qquickcumulativedirection.pro @@ -7,5 +7,5 @@ testDataFiles.files = data testDataFiles.path = . DEPLOYMENT += testDataFiles -QT += core-private gui-private v8-private declarative-private quick-private opengl-private testlib +QT += core-private gui-private v8-private qml-private quick-private opengl-private testlib diff --git a/tests/auto/particles/qquickcustomaffector/qquickcustomaffector.pro b/tests/auto/particles/qquickcustomaffector/qquickcustomaffector.pro index 6d3ecaa6f4..fdc2445bd1 100644 --- a/tests/auto/particles/qquickcustomaffector/qquickcustomaffector.pro +++ b/tests/auto/particles/qquickcustomaffector/qquickcustomaffector.pro @@ -7,5 +7,5 @@ testDataFiles.files = data testDataFiles.path = . DEPLOYMENT += testDataFiles -QT += core-private gui-private v8-private declarative-private quick-private opengl-private testlib +QT += core-private gui-private v8-private qml-private quick-private opengl-private testlib diff --git a/tests/auto/particles/qquickcustomparticle/qquickcustomparticle.pro b/tests/auto/particles/qquickcustomparticle/qquickcustomparticle.pro index e9bcc1e373..a12c1af62c 100644 --- a/tests/auto/particles/qquickcustomparticle/qquickcustomparticle.pro +++ b/tests/auto/particles/qquickcustomparticle/qquickcustomparticle.pro @@ -7,5 +7,5 @@ testDataFiles.files = data testDataFiles.path = . DEPLOYMENT += testDataFiles -QT += core-private gui-private v8-private declarative-private quick-private opengl-private testlib +QT += core-private gui-private v8-private qml-private quick-private opengl-private testlib diff --git a/tests/auto/particles/qquickellipseextruder/qquickellipseextruder.pro b/tests/auto/particles/qquickellipseextruder/qquickellipseextruder.pro index 803a366429..48d01201ce 100644 --- a/tests/auto/particles/qquickellipseextruder/qquickellipseextruder.pro +++ b/tests/auto/particles/qquickellipseextruder/qquickellipseextruder.pro @@ -7,5 +7,5 @@ testDataFiles.files = data testDataFiles.path = . DEPLOYMENT += testDataFiles -QT += core-private gui-private v8-private declarative-private quick-private opengl-private testlib +QT += core-private gui-private v8-private qml-private quick-private opengl-private testlib diff --git a/tests/auto/particles/qquickfriction/qquickfriction.pro b/tests/auto/particles/qquickfriction/qquickfriction.pro index 889b2d9505..85b5263d36 100644 --- a/tests/auto/particles/qquickfriction/qquickfriction.pro +++ b/tests/auto/particles/qquickfriction/qquickfriction.pro @@ -7,5 +7,5 @@ testDataFiles.files = data testDataFiles.path = . DEPLOYMENT += testDataFiles -QT += core-private gui-private v8-private declarative-private quick-private opengl-private testlib +QT += core-private gui-private v8-private qml-private quick-private opengl-private testlib diff --git a/tests/auto/particles/qquickgravity/qquickgravity.pro b/tests/auto/particles/qquickgravity/qquickgravity.pro index 3bdd8c1efa..5340b32cab 100644 --- a/tests/auto/particles/qquickgravity/qquickgravity.pro +++ b/tests/auto/particles/qquickgravity/qquickgravity.pro @@ -7,5 +7,5 @@ testDataFiles.files = data testDataFiles.path = . DEPLOYMENT += testDataFiles -QT += core-private gui-private v8-private declarative-private quick-private opengl-private testlib +QT += core-private gui-private v8-private qml-private quick-private opengl-private testlib diff --git a/tests/auto/particles/qquickgroupgoal/qquickgroupgoal.pro b/tests/auto/particles/qquickgroupgoal/qquickgroupgoal.pro index 8e7d5ae021..623993c2de 100644 --- a/tests/auto/particles/qquickgroupgoal/qquickgroupgoal.pro +++ b/tests/auto/particles/qquickgroupgoal/qquickgroupgoal.pro @@ -7,5 +7,5 @@ testDataFiles.files = data testDataFiles.path = . DEPLOYMENT += testDataFiles -QT += core-private gui-private v8-private declarative-private opengl-private testlib +QT += core-private gui-private v8-private qml-private opengl-private testlib diff --git a/tests/auto/particles/qquickimageparticle/qquickimageparticle.pro b/tests/auto/particles/qquickimageparticle/qquickimageparticle.pro index fa43b28407..1241467ba1 100644 --- a/tests/auto/particles/qquickimageparticle/qquickimageparticle.pro +++ b/tests/auto/particles/qquickimageparticle/qquickimageparticle.pro @@ -7,4 +7,4 @@ testDataFiles.files = data testDataFiles.path = . DEPLOYMENT += testDataFiles -QT += core-private gui-private v8-private declarative-private quick-private opengl-private testlib +QT += core-private gui-private v8-private qml-private quick-private opengl-private testlib diff --git a/tests/auto/particles/qquickitemparticle/qquickitemparticle.pro b/tests/auto/particles/qquickitemparticle/qquickitemparticle.pro index c36dabbc14..262ebdd5b2 100644 --- a/tests/auto/particles/qquickitemparticle/qquickitemparticle.pro +++ b/tests/auto/particles/qquickitemparticle/qquickitemparticle.pro @@ -7,5 +7,5 @@ testDataFiles.files = data testDataFiles.path = . DEPLOYMENT += testDataFiles -QT += core-private gui-private v8-private declarative-private quick-private opengl-private testlib +QT += core-private gui-private v8-private qml-private quick-private opengl-private testlib diff --git a/tests/auto/particles/qquicklineextruder/qquicklineextruder.pro b/tests/auto/particles/qquicklineextruder/qquicklineextruder.pro index fae5203961..3b87f00320 100644 --- a/tests/auto/particles/qquicklineextruder/qquicklineextruder.pro +++ b/tests/auto/particles/qquicklineextruder/qquicklineextruder.pro @@ -7,5 +7,5 @@ testDataFiles.files = data testDataFiles.path = . DEPLOYMENT += testDataFiles -QT += core-private gui-private v8-private declarative-private quick-private opengl-private testlib +QT += core-private gui-private v8-private qml-private quick-private opengl-private testlib diff --git a/tests/auto/particles/qquickmaskextruder/qquickmaskextruder.pro b/tests/auto/particles/qquickmaskextruder/qquickmaskextruder.pro index d82adf8b4a..33d6f2e41e 100644 --- a/tests/auto/particles/qquickmaskextruder/qquickmaskextruder.pro +++ b/tests/auto/particles/qquickmaskextruder/qquickmaskextruder.pro @@ -7,5 +7,5 @@ testDataFiles.files = data testDataFiles.path = . DEPLOYMENT += testDataFiles -QT += core-private gui-private v8-private declarative-private quick-private opengl-private testlib +QT += core-private gui-private v8-private qml-private quick-private opengl-private testlib diff --git a/tests/auto/particles/qquickparticlegroup/qquickparticlegroup.pro b/tests/auto/particles/qquickparticlegroup/qquickparticlegroup.pro index 27547c16b1..594b704bd5 100644 --- a/tests/auto/particles/qquickparticlegroup/qquickparticlegroup.pro +++ b/tests/auto/particles/qquickparticlegroup/qquickparticlegroup.pro @@ -7,5 +7,5 @@ testDataFiles.files = data testDataFiles.path = . DEPLOYMENT += testDataFiles -QT += core-private gui-private v8-private declarative-private quick-private opengl-private testlib +QT += core-private gui-private v8-private qml-private quick-private opengl-private testlib diff --git a/tests/auto/particles/qquickparticlesystem/qquickparticlesystem.pro b/tests/auto/particles/qquickparticlesystem/qquickparticlesystem.pro index 6fd13ec01e..ea5642aaa9 100644 --- a/tests/auto/particles/qquickparticlesystem/qquickparticlesystem.pro +++ b/tests/auto/particles/qquickparticlesystem/qquickparticlesystem.pro @@ -7,5 +7,5 @@ testDataFiles.files = data testDataFiles.path = . DEPLOYMENT += testDataFiles -QT += core-private gui-private v8-private declarative-private quick-private opengl-private testlib +QT += core-private gui-private v8-private qml-private quick-private opengl-private testlib diff --git a/tests/auto/particles/qquickpointattractor/qquickpointattractor.pro b/tests/auto/particles/qquickpointattractor/qquickpointattractor.pro index a9d390aab8..4a93555f5c 100644 --- a/tests/auto/particles/qquickpointattractor/qquickpointattractor.pro +++ b/tests/auto/particles/qquickpointattractor/qquickpointattractor.pro @@ -7,5 +7,5 @@ testDataFiles.files = data testDataFiles.path = . DEPLOYMENT += testDataFiles -QT += core-private gui-private v8-private declarative-private quick-private opengl-private testlib +QT += core-private gui-private v8-private qml-private quick-private opengl-private testlib diff --git a/tests/auto/particles/qquickpointdirection/qquickpointdirection.pro b/tests/auto/particles/qquickpointdirection/qquickpointdirection.pro index 04fe1617de..093e7a743f 100644 --- a/tests/auto/particles/qquickpointdirection/qquickpointdirection.pro +++ b/tests/auto/particles/qquickpointdirection/qquickpointdirection.pro @@ -7,5 +7,5 @@ testDataFiles.files = data testDataFiles.path = . DEPLOYMENT += testDataFiles -QT += core-private gui-private v8-private declarative-private quick-private opengl-private testlib +QT += core-private gui-private v8-private qml-private quick-private opengl-private testlib diff --git a/tests/auto/particles/qquickrectangleextruder/qquickrectangleextruder.pro b/tests/auto/particles/qquickrectangleextruder/qquickrectangleextruder.pro index e45c43a587..1b5da6165c 100644 --- a/tests/auto/particles/qquickrectangleextruder/qquickrectangleextruder.pro +++ b/tests/auto/particles/qquickrectangleextruder/qquickrectangleextruder.pro @@ -7,5 +7,5 @@ testDataFiles.files = data testDataFiles.path = . DEPLOYMENT += testDataFiles -QT += core-private gui-private v8-private declarative-private quick-private opengl-private testlib +QT += core-private gui-private v8-private qml-private quick-private opengl-private testlib diff --git a/tests/auto/particles/qquickspritegoal/qquickspritegoal.pro b/tests/auto/particles/qquickspritegoal/qquickspritegoal.pro index d335a91537..9908f220d2 100644 --- a/tests/auto/particles/qquickspritegoal/qquickspritegoal.pro +++ b/tests/auto/particles/qquickspritegoal/qquickspritegoal.pro @@ -7,5 +7,5 @@ testDataFiles.files = data testDataFiles.path = . DEPLOYMENT += testDataFiles -QT += core-private gui-private v8-private declarative-private opengl-private testlib +QT += core-private gui-private v8-private qml-private opengl-private testlib diff --git a/tests/auto/particles/qquicktargetdirection/qquicktargetdirection.pro b/tests/auto/particles/qquicktargetdirection/qquicktargetdirection.pro index 0a887d1fb3..226cd9d139 100644 --- a/tests/auto/particles/qquicktargetdirection/qquicktargetdirection.pro +++ b/tests/auto/particles/qquicktargetdirection/qquicktargetdirection.pro @@ -7,5 +7,5 @@ testDataFiles.files = data testDataFiles.path = . DEPLOYMENT += testDataFiles -QT += core-private gui-private v8-private declarative-private quick-private opengl-private testlib +QT += core-private gui-private v8-private qml-private quick-private opengl-private testlib diff --git a/tests/auto/particles/qquicktrailemitter/qquicktrailemitter.pro b/tests/auto/particles/qquicktrailemitter/qquicktrailemitter.pro index 9139dd39fb..67b14c86c3 100644 --- a/tests/auto/particles/qquicktrailemitter/qquicktrailemitter.pro +++ b/tests/auto/particles/qquicktrailemitter/qquicktrailemitter.pro @@ -7,5 +7,5 @@ testDataFiles.files = data testDataFiles.path = . DEPLOYMENT += testDataFiles -QT += core-private gui-private v8-private declarative-private quick-private opengl-private testlib +QT += core-private gui-private v8-private qml-private quick-private opengl-private testlib diff --git a/tests/auto/particles/qquickturbulence/qquickturbulence.pro b/tests/auto/particles/qquickturbulence/qquickturbulence.pro index 16d85445f5..d8de625b9c 100644 --- a/tests/auto/particles/qquickturbulence/qquickturbulence.pro +++ b/tests/auto/particles/qquickturbulence/qquickturbulence.pro @@ -7,5 +7,5 @@ testDataFiles.files = data testDataFiles.path = . DEPLOYMENT += testDataFiles -QT += core-private gui-private v8-private declarative-private quick-private opengl-private testlib +QT += core-private gui-private v8-private qml-private quick-private opengl-private testlib diff --git a/tests/auto/particles/qquickwander/qquickwander.pro b/tests/auto/particles/qquickwander/qquickwander.pro index a9c48ece78..ceb1d9f2c2 100644 --- a/tests/auto/particles/qquickwander/qquickwander.pro +++ b/tests/auto/particles/qquickwander/qquickwander.pro @@ -7,5 +7,5 @@ testDataFiles.files = data testDataFiles.path = . DEPLOYMENT += testDataFiles -QT += core-private gui-private v8-private declarative-private quick-private opengl-private testlib +QT += core-private gui-private v8-private qml-private quick-private opengl-private testlib diff --git a/tests/auto/qml/animation/animation.pro b/tests/auto/qml/animation/animation.pro new file mode 100644 index 0000000000..a9c0cee309 --- /dev/null +++ b/tests/auto/qml/animation/animation.pro @@ -0,0 +1,7 @@ +TEMPLATE=subdirs +SUBDIRS=\ + qabstractanimationjob \ + qanimationgroupjob \ + qparallelanimationgroupjob \ + qpauseanimationjob \ + qsequentialanimationgroupjob diff --git a/tests/auto/qml/animation/qabstractanimationjob/qabstractanimationjob.pro b/tests/auto/qml/animation/qabstractanimationjob/qabstractanimationjob.pro new file mode 100644 index 0000000000..6d3a05e923 --- /dev/null +++ b/tests/auto/qml/animation/qabstractanimationjob/qabstractanimationjob.pro @@ -0,0 +1,5 @@ +CONFIG += testcase parallel_test +macx:CONFIG -= app_bundle +TARGET = tst_qabstractanimationjob +QT = core-private qml-private testlib +SOURCES = tst_qabstractanimationjob.cpp diff --git a/tests/auto/qml/animation/qabstractanimationjob/tst_qabstractanimationjob.cpp b/tests/auto/qml/animation/qabstractanimationjob/tst_qabstractanimationjob.cpp new file mode 100644 index 0000000000..ea347ab2bd --- /dev/null +++ b/tests/auto/qml/animation/qabstractanimationjob/tst_qabstractanimationjob.cpp @@ -0,0 +1,229 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + + +#include +#include +#include + +class tst_QAbstractAnimationJob : public QObject +{ + Q_OBJECT +private slots: + void construction(); + void destruction(); + void currentLoop(); + void currentLoopTime(); + void currentTime(); + void direction(); + void group(); + void loopCount(); + void state(); + void totalDuration(); + void avoidJumpAtStart(); + void avoidJumpAtStartWithStop(); + void avoidJumpAtStartWithRunning(); +}; + +class TestableQAbstractAnimation : public QAbstractAnimationJob +{ +public: + TestableQAbstractAnimation() : m_duration(10) {} + virtual ~TestableQAbstractAnimation() {}; + + int duration() const { return m_duration; } + virtual void updateCurrentTime(int) {} + + void setDuration(int duration) { m_duration = duration; } +private: + int m_duration; +}; + +class DummyQAnimationGroup : public QAnimationGroupJob +{ +public: + int duration() const { return 10; } + virtual void updateCurrentTime(int) {} +}; + +void tst_QAbstractAnimationJob::construction() +{ + TestableQAbstractAnimation anim; +} + +void tst_QAbstractAnimationJob::destruction() +{ + TestableQAbstractAnimation *anim = new TestableQAbstractAnimation; + delete anim; +} + +void tst_QAbstractAnimationJob::currentLoop() +{ + TestableQAbstractAnimation anim; + QCOMPARE(anim.currentLoop(), 0); +} + +void tst_QAbstractAnimationJob::currentLoopTime() +{ + TestableQAbstractAnimation anim; + QCOMPARE(anim.currentLoopTime(), 0); +} + +void tst_QAbstractAnimationJob::currentTime() +{ + TestableQAbstractAnimation anim; + QCOMPARE(anim.currentTime(), 0); + anim.setCurrentTime(10); + QCOMPARE(anim.currentTime(), 10); +} + +void tst_QAbstractAnimationJob::direction() +{ + TestableQAbstractAnimation anim; + QCOMPARE(anim.direction(), QAbstractAnimationJob::Forward); + anim.setDirection(QAbstractAnimationJob::Backward); + QCOMPARE(anim.direction(), QAbstractAnimationJob::Backward); + anim.setDirection(QAbstractAnimationJob::Forward); + QCOMPARE(anim.direction(), QAbstractAnimationJob::Forward); +} + +void tst_QAbstractAnimationJob::group() +{ + TestableQAbstractAnimation *anim = new TestableQAbstractAnimation; + DummyQAnimationGroup group; + group.appendAnimation(anim); + QCOMPARE(anim->group(), &group); +} + +void tst_QAbstractAnimationJob::loopCount() +{ + TestableQAbstractAnimation anim; + QCOMPARE(anim.loopCount(), 1); + anim.setLoopCount(10); + QCOMPARE(anim.loopCount(), 10); +} + +void tst_QAbstractAnimationJob::state() +{ + TestableQAbstractAnimation anim; + QCOMPARE(anim.state(), QAbstractAnimationJob::Stopped); +} + +void tst_QAbstractAnimationJob::totalDuration() +{ + TestableQAbstractAnimation anim; + QCOMPARE(anim.duration(), 10); + anim.setLoopCount(5); + QCOMPARE(anim.totalDuration(), 50); +} + +void tst_QAbstractAnimationJob::avoidJumpAtStart() +{ + TestableQAbstractAnimation anim; + anim.setDuration(1000); + + /* + the timer shouldn't actually start until we hit the event loop, + so the sleep should have no effect + */ + anim.start(); + QTest::qSleep(300); + QCoreApplication::processEvents(); + QVERIFY(anim.currentTime() < 50); +} + +void tst_QAbstractAnimationJob::avoidJumpAtStartWithStop() +{ + TestableQAbstractAnimation anim; + anim.setDuration(1000); + + TestableQAbstractAnimation anim2; + anim2.setDuration(1000); + + TestableQAbstractAnimation anim3; + anim3.setDuration(1000); + + anim.start(); + QTest::qWait(300); + anim.stop(); + + /* + same test as avoidJumpAtStart, but after there is a + running animation that is stopped + */ + anim2.start(); + QTest::qSleep(300); + anim3.start(); + QCoreApplication::processEvents(); + QVERIFY(anim2.currentTime() < 50); + QVERIFY(anim3.currentTime() < 50); +} + +void tst_QAbstractAnimationJob::avoidJumpAtStartWithRunning() +{ + TestableQAbstractAnimation anim; + anim.setDuration(2000); + + TestableQAbstractAnimation anim2; + anim2.setDuration(1000); + + TestableQAbstractAnimation anim3; + anim3.setDuration(1000); + + anim.start(); + QTest::qWait(300); //make sure timer has started + + /* + same test as avoidJumpAtStart, but with an + existing running animation + */ + anim2.start(); + QTest::qSleep(300); //force large delta for next tick + anim3.start(); + QCoreApplication::processEvents(); + QVERIFY(anim2.currentTime() < 50); + QVERIFY(anim3.currentTime() < 50); +} + + +QTEST_MAIN(tst_QAbstractAnimationJob) + +#include "tst_qabstractanimationjob.moc" diff --git a/tests/auto/qml/animation/qanimationgroupjob/qanimationgroupjob.pro b/tests/auto/qml/animation/qanimationgroupjob/qanimationgroupjob.pro new file mode 100644 index 0000000000..96081d0116 --- /dev/null +++ b/tests/auto/qml/animation/qanimationgroupjob/qanimationgroupjob.pro @@ -0,0 +1,5 @@ +CONFIG += testcase parallel_test +macx:CONFIG -= app_bundle +TARGET = tst_qanimationgroupjob +QT = core-private qml-private testlib +SOURCES = tst_qanimationgroupjob.cpp diff --git a/tests/auto/qml/animation/qanimationgroupjob/tst_qanimationgroupjob.cpp b/tests/auto/qml/animation/qanimationgroupjob/tst_qanimationgroupjob.cpp new file mode 100644 index 0000000000..f3fd3b4cfb --- /dev/null +++ b/tests/auto/qml/animation/qanimationgroupjob/tst_qanimationgroupjob.cpp @@ -0,0 +1,310 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include + +#include +#include +#include + +Q_DECLARE_METATYPE(QAbstractAnimationJob::State) + +class tst_QAnimationGroupJob : public QObject +{ + Q_OBJECT +public Q_SLOTS: + void initTestCase(); + +private slots: + void construction(); + void emptyGroup(); + void setCurrentTime(); + void addChildTwice(); +}; + +void tst_QAnimationGroupJob::initTestCase() +{ + qRegisterMetaType("QAbstractAnimationJob::State"); +} + +void tst_QAnimationGroupJob::construction() +{ + QSequentialAnimationGroupJob animationgroup; +} + +class TestableGenericAnimation : public QAbstractAnimationJob +{ +public: + TestableGenericAnimation(int duration = 250) : m_duration(duration) {} + int duration() const { return m_duration; } + +private: + int m_duration; +}; + +class UncontrolledAnimation : public QObject, public QAbstractAnimationJob +{ + Q_OBJECT +public: + UncontrolledAnimation() + : id(0) + { + } + + int duration() const { return -1; /* not time driven */ } + +protected: + void timerEvent(QTimerEvent *event) + { + if (event->timerId() == id) + stop(); + } + + void updateRunning(bool running) + { + if (running) { + id = startTimer(500); + } else { + killTimer(id); + id = 0; + } + } + +private: + int id; +}; + +class StateChangeListener: public QAnimationJobChangeListener +{ +public: + virtual void animationStateChanged(QAbstractAnimationJob *, QAbstractAnimationJob::State newState, QAbstractAnimationJob::State) + { + states << newState; + } + + int count() + { + return states.count(); + } + + QList states; +}; + +void tst_QAnimationGroupJob::emptyGroup() +{ + QSequentialAnimationGroupJob group; + StateChangeListener groupStateChangedSpy; + group.addAnimationChangeListener(&groupStateChangedSpy, QAbstractAnimationJob::StateChange); + + QCOMPARE(group.state(), QAnimationGroupJob::Stopped); + group.start(); + + QCOMPARE(groupStateChangedSpy.count(), 2); + + QCOMPARE(groupStateChangedSpy.states.at(0), QAnimationGroupJob::Running); + QCOMPARE(groupStateChangedSpy.states.at(1), QAnimationGroupJob::Stopped); + + QCOMPARE(group.state(), QAnimationGroupJob::Stopped); + + QTest::ignoreMessage(QtWarningMsg, "QAbstractAnimationJob::pause: Cannot pause a stopped animation"); + group.pause(); + + QCOMPARE(groupStateChangedSpy.count(), 2); + QCOMPARE(group.state(), QAnimationGroupJob::Stopped); + + group.start(); + + QCOMPARE(groupStateChangedSpy.states.at(2), + QAnimationGroupJob::Running); + QCOMPARE(groupStateChangedSpy.states.at(3), + QAnimationGroupJob::Stopped); + + QCOMPARE(group.state(), QAnimationGroupJob::Stopped); + + group.stop(); + + QCOMPARE(groupStateChangedSpy.count(), 4); + QCOMPARE(group.state(), QAnimationGroupJob::Stopped); +} + +void tst_QAnimationGroupJob::setCurrentTime() +{ + // was originally sequence operating on same object/property + QSequentialAnimationGroupJob *sequence = new QSequentialAnimationGroupJob(); + QAbstractAnimationJob *a1_s_o1 = new TestableGenericAnimation; + QAbstractAnimationJob *a2_s_o1 = new TestableGenericAnimation; + QAbstractAnimationJob *a3_s_o1 = new TestableGenericAnimation; + a2_s_o1->setLoopCount(3); + sequence->appendAnimation(a1_s_o1); + sequence->appendAnimation(a2_s_o1); + sequence->appendAnimation(a3_s_o1); + + // was originally sequence operating on different object/properties + QAnimationGroupJob *sequence2 = new QSequentialAnimationGroupJob(); + QAbstractAnimationJob *a1_s_o2 = new TestableGenericAnimation; + QAbstractAnimationJob *a1_s_o3 = new TestableGenericAnimation; + sequence2->appendAnimation(a1_s_o2); + sequence2->appendAnimation(a1_s_o3); + + // was originally parallel operating on different object/properties + QAnimationGroupJob *parallel = new QParallelAnimationGroupJob(); + QAbstractAnimationJob *a1_p_o1 = new TestableGenericAnimation; + QAbstractAnimationJob *a1_p_o2 = new TestableGenericAnimation; + QAbstractAnimationJob *a1_p_o3 = new TestableGenericAnimation; + a1_p_o2->setLoopCount(3); + parallel->appendAnimation(a1_p_o1); + parallel->appendAnimation(a1_p_o2); + parallel->appendAnimation(a1_p_o3); + + QAbstractAnimationJob *notTimeDriven = new UncontrolledAnimation; + QCOMPARE(notTimeDriven->totalDuration(), -1); + + QAbstractAnimationJob *loopsForever = new TestableGenericAnimation; + loopsForever->setLoopCount(-1); + QCOMPARE(loopsForever->totalDuration(), -1); + + QParallelAnimationGroupJob group; + group.appendAnimation(sequence); + group.appendAnimation(sequence2); + group.appendAnimation(parallel); + group.appendAnimation(notTimeDriven); + group.appendAnimation(loopsForever); + + // Current time = 1 + group.setCurrentTime(1); + QCOMPARE(group.state(), QAnimationGroupJob::Stopped); + QCOMPARE(sequence->state(), QAnimationGroupJob::Stopped); + QCOMPARE(a1_s_o1->state(), QAnimationGroupJob::Stopped); + QCOMPARE(sequence2->state(), QAnimationGroupJob::Stopped); + QCOMPARE(a1_s_o2->state(), QAnimationGroupJob::Stopped); + QCOMPARE(parallel->state(), QAnimationGroupJob::Stopped); + QCOMPARE(a1_p_o1->state(), QAnimationGroupJob::Stopped); + QCOMPARE(a1_p_o2->state(), QAnimationGroupJob::Stopped); + QCOMPARE(a1_p_o3->state(), QAnimationGroupJob::Stopped); + QCOMPARE(notTimeDriven->state(), QAnimationGroupJob::Stopped); + QCOMPARE(loopsForever->state(), QAnimationGroupJob::Stopped); + + QCOMPARE(group.currentLoopTime(), 1); + QCOMPARE(sequence->currentLoopTime(), 1); + QCOMPARE(a1_s_o1->currentLoopTime(), 1); + QCOMPARE(a2_s_o1->currentLoopTime(), 0); + QCOMPARE(a3_s_o1->currentLoopTime(), 0); + QCOMPARE(a1_s_o2->currentLoopTime(), 1); + QCOMPARE(a1_s_o3->currentLoopTime(), 0); + QCOMPARE(a1_p_o1->currentLoopTime(), 1); + QCOMPARE(a1_p_o2->currentLoopTime(), 1); + QCOMPARE(a1_p_o3->currentLoopTime(), 1); + QCOMPARE(notTimeDriven->currentLoopTime(), 1); + QCOMPARE(loopsForever->currentLoopTime(), 1); + + // Current time = 250 + group.setCurrentTime(250); + QCOMPARE(group.currentLoopTime(), 250); + QCOMPARE(sequence->currentLoopTime(), 250); + QCOMPARE(a1_s_o1->currentLoopTime(), 250); + QCOMPARE(a2_s_o1->currentLoopTime(), 0); + QCOMPARE(a3_s_o1->currentLoopTime(), 0); + QCOMPARE(a1_s_o2->currentLoopTime(), 250); + QCOMPARE(a1_s_o3->currentLoopTime(), 0); + QCOMPARE(a1_p_o1->currentLoopTime(), 250); + QCOMPARE(a1_p_o2->currentLoopTime(), 0); + QCOMPARE(a1_p_o2->currentLoop(), 1); + QCOMPARE(a1_p_o3->currentLoopTime(), 250); + QCOMPARE(notTimeDriven->currentLoopTime(), 250); + QCOMPARE(loopsForever->currentLoopTime(), 0); + QCOMPARE(loopsForever->currentLoop(), 1); + QCOMPARE(sequence->currentAnimation(), a2_s_o1); + + // Current time = 251 + group.setCurrentTime(251); + QCOMPARE(group.currentLoopTime(), 251); + QCOMPARE(sequence->currentLoopTime(), 251); + QCOMPARE(a1_s_o1->currentLoopTime(), 250); + QCOMPARE(a2_s_o1->currentLoopTime(), 1); + QCOMPARE(a2_s_o1->currentLoop(), 0); + QCOMPARE(a3_s_o1->currentLoopTime(), 0); + QCOMPARE(sequence2->currentLoopTime(), 251); + QCOMPARE(a1_s_o2->currentLoopTime(), 250); + QCOMPARE(a1_s_o3->currentLoopTime(), 1); + QCOMPARE(a1_p_o1->currentLoopTime(), 250); + QCOMPARE(a1_p_o2->currentLoopTime(), 1); + QCOMPARE(a1_p_o2->currentLoop(), 1); + QCOMPARE(a1_p_o3->currentLoopTime(), 250); + QCOMPARE(notTimeDriven->currentLoopTime(), 251); + QCOMPARE(loopsForever->currentLoopTime(), 1); + QCOMPARE(sequence->currentAnimation(), a2_s_o1); +} + +void tst_QAnimationGroupJob::addChildTwice() +{ + QAbstractAnimationJob *subGroup; + QAbstractAnimationJob *subGroup2; + QAnimationGroupJob *parent = new QSequentialAnimationGroupJob(); + + subGroup = new QAbstractAnimationJob; + parent->appendAnimation(subGroup); + parent->appendAnimation(subGroup); + QVERIFY(parent->firstChild() && !parent->firstChild()->nextSibling()); + + parent->clear(); + + QVERIFY(!parent->firstChild()); + + // adding the same item twice to a group will remove the item from its current position + // and append it to the end + subGroup = new QAbstractAnimationJob; + parent->appendAnimation(subGroup); + subGroup2 = new QAbstractAnimationJob; + parent->appendAnimation(subGroup2); + + QCOMPARE(parent->firstChild(), subGroup); + QCOMPARE(parent->lastChild(), subGroup2); + + parent->appendAnimation(subGroup); + + QCOMPARE(parent->firstChild(), subGroup2); + QCOMPARE(parent->lastChild(), subGroup); + + delete parent; +} + +QTEST_MAIN(tst_QAnimationGroupJob) +#include "tst_qanimationgroupjob.moc" diff --git a/tests/auto/qml/animation/qparallelanimationgroupjob/qparallelanimationgroupjob.pro b/tests/auto/qml/animation/qparallelanimationgroupjob/qparallelanimationgroupjob.pro new file mode 100644 index 0000000000..f76548183e --- /dev/null +++ b/tests/auto/qml/animation/qparallelanimationgroupjob/qparallelanimationgroupjob.pro @@ -0,0 +1,5 @@ +CONFIG += testcase +macx:CONFIG -= app_bundle +TARGET = tst_qparallelanimationgroupjob +QT = core-private gui qml-private testlib +SOURCES = tst_qparallelanimationgroupjob.cpp diff --git a/tests/auto/qml/animation/qparallelanimationgroupjob/tst_qparallelanimationgroupjob.cpp b/tests/auto/qml/animation/qparallelanimationgroupjob/tst_qparallelanimationgroupjob.cpp new file mode 100644 index 0000000000..b6b3fac039 --- /dev/null +++ b/tests/auto/qml/animation/qparallelanimationgroupjob/tst_qparallelanimationgroupjob.cpp @@ -0,0 +1,931 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include + +#include + +Q_DECLARE_METATYPE(QAbstractAnimationJob::State) + +class tst_QParallelAnimationGroupJob : public QObject +{ + Q_OBJECT +public Q_SLOTS: + void initTestCase(); + +private slots: + void construction(); + void setCurrentTime(); + void stateChanged(); + void clearGroup(); + void propagateGroupUpdateToChildren(); + void updateChildrenWithRunningGroup(); + void deleteChildrenWithRunningGroup(); + void startChildrenWithStoppedGroup(); + void stopGroupWithRunningChild(); + void startGroupWithRunningChild(); + void zeroDurationAnimation(); + void stopUncontrolledAnimations(); + void loopCount_data(); + void loopCount(); + void addAndRemoveDuration(); + void pauseResume(); + + void crashWhenRemovingUncontrolledAnimation(); +}; + +void tst_QParallelAnimationGroupJob::initTestCase() +{ + qRegisterMetaType("QAbstractAnimationJob::State"); +#if defined(Q_OS_MAC) || defined(Q_OS_WINCE) + // give the mac/wince app start event queue time to clear + QTest::qWait(1000); +#endif +} + +void tst_QParallelAnimationGroupJob::construction() +{ + QParallelAnimationGroupJob animationgroup; +} + +class TestAnimation : public QAbstractAnimationJob +{ +public: + TestAnimation(int duration = 250) : m_duration(duration) {} + int duration() const { return m_duration; } + +private: + int m_duration; +}; + +class UncontrolledAnimation : public QObject, public QAbstractAnimationJob +{ + Q_OBJECT +public: + UncontrolledAnimation() + : id(0) + { + } + + int duration() const { return -1; /* not time driven */ } + +protected: + void timerEvent(QTimerEvent *event) + { + if (event->timerId() == id) + stop(); + } + + void updateRunning(bool running) + { + if (running) { + id = startTimer(500); + } else { + killTimer(id); + id = 0; + } + } + +private: + int id; +}; + +class StateChangeListener: public QAnimationJobChangeListener +{ +public: + virtual void animationStateChanged(QAbstractAnimationJob *, QAbstractAnimationJob::State newState, QAbstractAnimationJob::State) + { + states << newState; + } + + void clear() { states.clear(); } + int count() { return states.count(); } + + QList states; +}; + +class FinishedListener: public QAnimationJobChangeListener +{ +public: + FinishedListener() : m_count(0) {} + + virtual void animationFinished(QAbstractAnimationJob *) { ++m_count; } + void clear() { m_count = 0; } + int count() { return m_count; } + +private: + int m_count; +}; + +void tst_QParallelAnimationGroupJob::setCurrentTime() +{ + // originally was parallel operating on different object/properties + QAnimationGroupJob *parallel = new QParallelAnimationGroupJob(); + TestAnimation *a1_p_o1 = new TestAnimation; + TestAnimation *a1_p_o2 = new TestAnimation; + TestAnimation *a1_p_o3 = new TestAnimation; + a1_p_o2->setLoopCount(3); + parallel->appendAnimation(a1_p_o1); + parallel->appendAnimation(a1_p_o2); + parallel->appendAnimation(a1_p_o3); + + UncontrolledAnimation *notTimeDriven = new UncontrolledAnimation; + QCOMPARE(notTimeDriven->totalDuration(), -1); + + TestAnimation *loopsForever = new TestAnimation; + loopsForever->setLoopCount(-1); + QCOMPARE(loopsForever->totalDuration(), -1); + + QParallelAnimationGroupJob group; + group.appendAnimation(parallel); + group.appendAnimation(notTimeDriven); + group.appendAnimation(loopsForever); + + // Current time = 1 + group.setCurrentTime(1); + QCOMPARE(group.state(), QAnimationGroupJob::Stopped); + QCOMPARE(parallel->state(), QAnimationGroupJob::Stopped); + QCOMPARE(a1_p_o1->state(), QAnimationGroupJob::Stopped); + QCOMPARE(a1_p_o2->state(), QAnimationGroupJob::Stopped); + QCOMPARE(a1_p_o3->state(), QAnimationGroupJob::Stopped); + QCOMPARE(notTimeDriven->state(), QAnimationGroupJob::Stopped); + QCOMPARE(loopsForever->state(), QAnimationGroupJob::Stopped); + + QCOMPARE(group.currentLoopTime(), 1); + QCOMPARE(a1_p_o1->currentLoopTime(), 1); + QCOMPARE(a1_p_o2->currentLoopTime(), 1); + QCOMPARE(a1_p_o3->currentLoopTime(), 1); + QCOMPARE(notTimeDriven->currentLoopTime(), 1); + QCOMPARE(loopsForever->currentLoopTime(), 1); + + // Current time = 250 + group.setCurrentTime(250); + QCOMPARE(group.currentLoopTime(), 250); + QCOMPARE(a1_p_o1->currentLoopTime(), 250); + QCOMPARE(a1_p_o2->currentLoopTime(), 0); + QCOMPARE(a1_p_o2->currentLoop(), 1); + QCOMPARE(a1_p_o3->currentLoopTime(), 250); + QCOMPARE(notTimeDriven->currentLoopTime(), 250); + QCOMPARE(loopsForever->currentLoopTime(), 0); + QCOMPARE(loopsForever->currentLoop(), 1); + + // Current time = 251 + group.setCurrentTime(251); + QCOMPARE(group.currentLoopTime(), 251); + QCOMPARE(a1_p_o1->currentLoopTime(), 250); + QCOMPARE(a1_p_o2->currentLoopTime(), 1); + QCOMPARE(a1_p_o2->currentLoop(), 1); + QCOMPARE(a1_p_o3->currentLoopTime(), 250); + QCOMPARE(notTimeDriven->currentLoopTime(), 251); + QCOMPARE(loopsForever->currentLoopTime(), 1); +} + +void tst_QParallelAnimationGroupJob::stateChanged() +{ + //this ensures that the correct animations are started when starting the group + TestAnimation *anim1 = new TestAnimation(1000); + TestAnimation *anim2 = new TestAnimation(2000); + TestAnimation *anim3 = new TestAnimation(3000); + TestAnimation *anim4 = new TestAnimation(3000); + + QParallelAnimationGroupJob group; + group.appendAnimation(anim1); + group.appendAnimation(anim2); + group.appendAnimation(anim3); + group.appendAnimation(anim4); + + StateChangeListener spy1; + anim1->addAnimationChangeListener(&spy1, QAbstractAnimationJob::StateChange); + StateChangeListener spy2; + anim2->addAnimationChangeListener(&spy2, QAbstractAnimationJob::StateChange); + StateChangeListener spy3; + anim3->addAnimationChangeListener(&spy3, QAbstractAnimationJob::StateChange); + StateChangeListener spy4; + anim4->addAnimationChangeListener(&spy4, QAbstractAnimationJob::StateChange); + + //first; let's start forward + group.start(); + //all the animations should be started + QCOMPARE(spy1.count(), 1); + QCOMPARE(spy1.states.last(), TestAnimation::Running); + QCOMPARE(spy2.count(), 1); + QCOMPARE(spy2.states.last(), TestAnimation::Running); + QCOMPARE(spy3.count(), 1); + QCOMPARE(spy3.states.last(), TestAnimation::Running); + QCOMPARE(spy4.count(), 1); + QCOMPARE(spy4.states.last(), TestAnimation::Running); + + group.setCurrentTime(1500); //anim1 should be finished + QCOMPARE(group.state(), QAnimationGroupJob::Running); + QCOMPARE(spy1.count(), 2); + QCOMPARE(spy1.states.last(), TestAnimation::Stopped); + QCOMPARE(spy2.count(), 1); //no change + QCOMPARE(spy3.count(), 1); //no change + QCOMPARE(spy4.count(), 1); //no change + + group.setCurrentTime(2500); //anim2 should be finished + QCOMPARE(group.state(), QAnimationGroupJob::Running); + QCOMPARE(spy1.count(), 2); //no change + QCOMPARE(spy2.count(), 2); + QCOMPARE(spy2.states.last(), TestAnimation::Stopped); + QCOMPARE(spy3.count(), 1); //no change + QCOMPARE(spy4.count(), 1); //no change + + group.setCurrentTime(3500); //everything should be finished + QCOMPARE(group.state(), QAnimationGroupJob::Stopped); + QCOMPARE(spy1.count(), 2); //no change + QCOMPARE(spy2.count(), 2); //no change + QCOMPARE(spy3.count(), 2); + QCOMPARE(spy3.states.last(), TestAnimation::Stopped); + QCOMPARE(spy4.count(), 2); + QCOMPARE(spy4.states.last(), TestAnimation::Stopped); + + //cleanup + spy1.clear(); + spy2.clear(); + spy3.clear(); + spy4.clear(); + + //now let's try to reverse that + group.setDirection(QAbstractAnimationJob::Backward); + group.start(); + + //only anim3 and anim4 should be started + QCOMPARE(group.state(), QAnimationGroupJob::Running); + QCOMPARE(spy1.count(), 0); + QCOMPARE(spy2.count(), 0); + QCOMPARE(spy3.count(), 1); + QCOMPARE(spy3.states.last(), TestAnimation::Running); + QCOMPARE(spy4.count(), 1); + QCOMPARE(spy4.states.last(), TestAnimation::Running); + + group.setCurrentTime(1500); //anim2 should be started + QCOMPARE(group.state(), QAnimationGroupJob::Running); + QCOMPARE(spy1.count(), 0); //no change + QCOMPARE(spy2.count(), 1); + QCOMPARE(spy2.states.last(), TestAnimation::Running); + QCOMPARE(spy3.count(), 1); //no change + QCOMPARE(spy4.count(), 1); //no change + + group.setCurrentTime(500); //anim1 is finally also started + QCOMPARE(group.state(), QAnimationGroupJob::Running); + QCOMPARE(spy1.count(), 1); + QCOMPARE(spy1.states.last(), TestAnimation::Running); + QCOMPARE(spy2.count(), 1); //no change + QCOMPARE(spy3.count(), 1); //no change + QCOMPARE(spy4.count(), 1); //no change + + group.setCurrentTime(0); //everything should be stopped + QCOMPARE(group.state(), QAnimationGroupJob::Stopped); + QCOMPARE(spy1.count(), 2); + QCOMPARE(spy1.states.last(), TestAnimation::Stopped); + QCOMPARE(spy2.count(), 2); + QCOMPARE(spy2.states.last(), TestAnimation::Stopped); + QCOMPARE(spy3.count(), 2); + QCOMPARE(spy3.states.last(), TestAnimation::Stopped); + QCOMPARE(spy4.count(), 2); + QCOMPARE(spy4.states.last(), TestAnimation::Stopped); +} + +void tst_QParallelAnimationGroupJob::clearGroup() +{ + QParallelAnimationGroupJob group; + static const int animationCount = 10; + + for (int i = 0; i < animationCount; ++i) { + group.appendAnimation(new QParallelAnimationGroupJob); + } + + int count = 0; + for (QAbstractAnimationJob *anim = group.firstChild(); anim; anim = anim->nextSibling()) + ++count; + QCOMPARE(count, animationCount); + + group.clear(); + + QVERIFY(!group.firstChild() && !group.lastChild()); + QCOMPARE(group.currentLoopTime(), 0); +} + +void tst_QParallelAnimationGroupJob::propagateGroupUpdateToChildren() +{ + // this test verifies if group state changes are updating its children correctly + QParallelAnimationGroupJob group; + + TestAnimation anim1(100); + TestAnimation anim2(200); + + QCOMPARE(group.state(), QAnimationGroupJob::Stopped); + QCOMPARE(anim1.state(), QAnimationGroupJob::Stopped); + QCOMPARE(anim2.state(), QAnimationGroupJob::Stopped); + + group.appendAnimation(&anim1); + group.appendAnimation(&anim2); + + group.start(); + + QCOMPARE(group.state(), QAnimationGroupJob::Running); + QCOMPARE(anim1.state(), QAnimationGroupJob::Running); + QCOMPARE(anim2.state(), QAnimationGroupJob::Running); + + group.pause(); + + QCOMPARE(group.state(), QAnimationGroupJob::Paused); + QCOMPARE(anim1.state(), QAnimationGroupJob::Paused); + QCOMPARE(anim2.state(), QAnimationGroupJob::Paused); + + group.stop(); + + QCOMPARE(group.state(), QAnimationGroupJob::Stopped); + QCOMPARE(anim1.state(), QAnimationGroupJob::Stopped); + QCOMPARE(anim2.state(), QAnimationGroupJob::Stopped); +} + +void tst_QParallelAnimationGroupJob::updateChildrenWithRunningGroup() +{ + // assert that its possible to modify a child's state directly while their group is running + QParallelAnimationGroupJob group; + + TestAnimation anim(200); + + StateChangeListener groupStateChangedSpy; + group.addAnimationChangeListener(&groupStateChangedSpy, QAbstractAnimationJob::StateChange); + StateChangeListener childStateChangedSpy; + anim.addAnimationChangeListener(&childStateChangedSpy, QAbstractAnimationJob::StateChange); + + QCOMPARE(groupStateChangedSpy.count(), 0); + QCOMPARE(childStateChangedSpy.count(), 0); + QCOMPARE(group.state(), QAnimationGroupJob::Stopped); + QCOMPARE(anim.state(), QAnimationGroupJob::Stopped); + + group.appendAnimation(&anim); + + group.start(); + + QCOMPARE(group.state(), QAnimationGroupJob::Running); + QCOMPARE(anim.state(), QAnimationGroupJob::Running); + + QCOMPARE(groupStateChangedSpy.count(), 1); + QCOMPARE(childStateChangedSpy.count(), 1); + + QCOMPARE(groupStateChangedSpy.states.at(0), QAnimationGroupJob::Running); + QCOMPARE(childStateChangedSpy.states.at(0), QAnimationGroupJob::Running); + + // starting directly a running child will not have any effect + anim.start(); + + QCOMPARE(groupStateChangedSpy.count(), 1); + QCOMPARE(childStateChangedSpy.count(), 1); + + anim.pause(); + + QCOMPARE(group.state(), QAnimationGroupJob::Running); + QCOMPARE(anim.state(), QAnimationGroupJob::Paused); + + // in the animation stops directly, the group will still be running + anim.stop(); + + QCOMPARE(group.state(), QAnimationGroupJob::Running); + QCOMPARE(anim.state(), QAnimationGroupJob::Stopped); + + //cleanup + group.removeAnimationChangeListener(&groupStateChangedSpy, QAbstractAnimationJob::StateChange); + anim.removeAnimationChangeListener(&childStateChangedSpy, QAbstractAnimationJob::StateChange); +} + +void tst_QParallelAnimationGroupJob::deleteChildrenWithRunningGroup() +{ + // test if children can be activated when their group is stopped + QParallelAnimationGroupJob group; + + TestAnimation *anim1 = new TestAnimation(200); + group.appendAnimation(anim1); + + QCOMPARE(group.duration(), anim1->duration()); + + group.start(); + QCOMPARE(group.state(), QAnimationGroupJob::Running); + QCOMPARE(anim1->state(), QAnimationGroupJob::Running); + + QTest::qWait(80); + QVERIFY(group.currentLoopTime() > 0); + + delete anim1; + QVERIFY(!group.firstChild()); + QCOMPARE(group.duration(), 0); + QCOMPARE(group.state(), QAnimationGroupJob::Stopped); + QCOMPARE(group.currentLoopTime(), 0); //that's the invariant +} + +void tst_QParallelAnimationGroupJob::startChildrenWithStoppedGroup() +{ + // test if children can be activated when their group is stopped + QParallelAnimationGroupJob group; + + TestAnimation anim1(200); + TestAnimation anim2(200); + + QCOMPARE(group.state(), QAnimationGroupJob::Stopped); + QCOMPARE(anim1.state(), QAnimationGroupJob::Stopped); + QCOMPARE(anim2.state(), QAnimationGroupJob::Stopped); + + group.appendAnimation(&anim1); + group.appendAnimation(&anim2); + + group.stop(); + + QCOMPARE(group.state(), QAnimationGroupJob::Stopped); + QCOMPARE(anim1.state(), QAnimationGroupJob::Stopped); + QCOMPARE(anim2.state(), QAnimationGroupJob::Stopped); + + anim1.start(); + anim2.start(); + anim2.pause(); + + QCOMPARE(group.state(), QAnimationGroupJob::Stopped); + QCOMPARE(anim1.state(), QAnimationGroupJob::Running); + QCOMPARE(anim2.state(), QAnimationGroupJob::Paused); +} + +void tst_QParallelAnimationGroupJob::stopGroupWithRunningChild() +{ + // children that started independently will not be affected by a group stop + QParallelAnimationGroupJob group; + + TestAnimation anim1(200); + TestAnimation anim2(200); + + QCOMPARE(group.state(), QAnimationGroupJob::Stopped); + QCOMPARE(anim1.state(), QAnimationGroupJob::Stopped); + QCOMPARE(anim2.state(), QAnimationGroupJob::Stopped); + + group.appendAnimation(&anim1); + group.appendAnimation(&anim2); + + anim1.start(); + anim2.start(); + anim2.pause(); + + QCOMPARE(group.state(), QAnimationGroupJob::Stopped); + QCOMPARE(anim1.state(), QAnimationGroupJob::Running); + QCOMPARE(anim2.state(), QAnimationGroupJob::Paused); + + group.stop(); + + QCOMPARE(group.state(), QAnimationGroupJob::Stopped); + QCOMPARE(anim1.state(), QAnimationGroupJob::Running); + QCOMPARE(anim2.state(), QAnimationGroupJob::Paused); + + anim1.stop(); + anim2.stop(); + + QCOMPARE(group.state(), QAnimationGroupJob::Stopped); + QCOMPARE(anim1.state(), QAnimationGroupJob::Stopped); + QCOMPARE(anim2.state(), QAnimationGroupJob::Stopped); +} + +void tst_QParallelAnimationGroupJob::startGroupWithRunningChild() +{ + // as the group has precedence over its children, starting a group will restart all the children + QParallelAnimationGroupJob group; + + TestAnimation anim1(200); + TestAnimation anim2(200); + + StateChangeListener stateChangedSpy1; + anim1.addAnimationChangeListener(&stateChangedSpy1, QAbstractAnimationJob::StateChange); + StateChangeListener stateChangedSpy2; + anim2.addAnimationChangeListener(&stateChangedSpy2, QAbstractAnimationJob::StateChange); + + QCOMPARE(stateChangedSpy1.count(), 0); + QCOMPARE(stateChangedSpy2.count(), 0); + QCOMPARE(group.state(), QAnimationGroupJob::Stopped); + QCOMPARE(anim1.state(), QAnimationGroupJob::Stopped); + QCOMPARE(anim2.state(), QAnimationGroupJob::Stopped); + + group.appendAnimation(&anim1); + group.appendAnimation(&anim2); + + anim1.start(); + anim2.start(); + anim2.pause(); + + QCOMPARE(stateChangedSpy1.states.at(0), QAnimationGroupJob::Running); + QCOMPARE(stateChangedSpy2.states.at(0), QAnimationGroupJob::Running); + QCOMPARE(stateChangedSpy2.states.at(1), QAnimationGroupJob::Paused); + + QCOMPARE(group.state(), QAnimationGroupJob::Stopped); + QCOMPARE(anim1.state(), QAnimationGroupJob::Running); + QCOMPARE(anim2.state(), QAnimationGroupJob::Paused); + + group.start(); + + QCOMPARE(stateChangedSpy1.count(), 3); + QCOMPARE(stateChangedSpy1.states.at(1), QAnimationGroupJob::Stopped); + QCOMPARE(stateChangedSpy1.states.at(2), QAnimationGroupJob::Running); + + QCOMPARE(stateChangedSpy2.count(), 4); + QCOMPARE(stateChangedSpy2.states.at(2), QAnimationGroupJob::Stopped); + QCOMPARE(stateChangedSpy2.states.at(3), QAnimationGroupJob::Running); + + QCOMPARE(group.state(), QAnimationGroupJob::Running); + QCOMPARE(anim1.state(), QAnimationGroupJob::Running); + QCOMPARE(anim2.state(), QAnimationGroupJob::Running); + + //cleanup + anim1.removeAnimationChangeListener(&stateChangedSpy1, QAbstractAnimationJob::StateChange); + anim2.removeAnimationChangeListener(&stateChangedSpy2, QAbstractAnimationJob::StateChange); +} + +void tst_QParallelAnimationGroupJob::zeroDurationAnimation() +{ + QParallelAnimationGroupJob group; + + TestAnimation anim1(0); + TestAnimation anim2(100); + TestAnimation anim3(10); + + StateChangeListener stateChangedSpy1; + anim1.addAnimationChangeListener(&stateChangedSpy1, QAbstractAnimationJob::StateChange); + FinishedListener finishedSpy1; + anim1.addAnimationChangeListener(&finishedSpy1, QAbstractAnimationJob::Completion); + + StateChangeListener stateChangedSpy2; + anim2.addAnimationChangeListener(&stateChangedSpy2, QAbstractAnimationJob::StateChange); + FinishedListener finishedSpy2; + anim2.addAnimationChangeListener(&finishedSpy2, QAbstractAnimationJob::Completion); + + StateChangeListener stateChangedSpy3; + anim3.addAnimationChangeListener(&stateChangedSpy3, QAbstractAnimationJob::StateChange); + FinishedListener finishedSpy3; + anim3.addAnimationChangeListener(&finishedSpy3, QAbstractAnimationJob::Completion); + + group.appendAnimation(&anim1); + group.appendAnimation(&anim2); + group.appendAnimation(&anim3); + QCOMPARE(stateChangedSpy1.count(), 0); + group.start(); + QCOMPARE(stateChangedSpy1.count(), 2); + QCOMPARE(finishedSpy1.count(), 1); + QCOMPARE(stateChangedSpy1.states.at(0), QAnimationGroupJob::Running); + QCOMPARE(stateChangedSpy1.states.at(1), QAnimationGroupJob::Stopped); + + QCOMPARE(stateChangedSpy2.count(), 1); + QCOMPARE(finishedSpy2.count(), 0); + QCOMPARE(stateChangedSpy1.states.at(0), QAnimationGroupJob::Running); + + QCOMPARE(stateChangedSpy3.count(), 1); + QCOMPARE(finishedSpy3.count(), 0); + QCOMPARE(stateChangedSpy3.states.at(0), QAnimationGroupJob::Running); + + QCOMPARE(anim1.state(), QAnimationGroupJob::Stopped); + QCOMPARE(anim2.state(), QAnimationGroupJob::Running); + QCOMPARE(anim3.state(), QAnimationGroupJob::Running); + QCOMPARE(group.state(), QAnimationGroupJob::Running); + + group.stop(); + group.setLoopCount(4); + stateChangedSpy1.clear(); + stateChangedSpy2.clear(); + stateChangedSpy3.clear(); + + group.start(); + QCOMPARE(stateChangedSpy1.count(), 2); + QCOMPARE(stateChangedSpy2.count(), 1); + QCOMPARE(stateChangedSpy3.count(), 1); + group.setCurrentTime(50); + QCOMPARE(stateChangedSpy1.count(), 2); + QCOMPARE(stateChangedSpy2.count(), 1); + QCOMPARE(stateChangedSpy3.count(), 2); + group.setCurrentTime(150); + QCOMPARE(stateChangedSpy1.count(), 4); + QCOMPARE(stateChangedSpy2.count(), 3); + QCOMPARE(stateChangedSpy3.count(), 4); + group.setCurrentTime(50); + QCOMPARE(stateChangedSpy1.count(), 6); + QCOMPARE(stateChangedSpy2.count(), 5); + QCOMPARE(stateChangedSpy3.count(), 6); + + //cleanup + anim1.removeAnimationChangeListener(&stateChangedSpy1, QAbstractAnimationJob::StateChange); + anim1.removeAnimationChangeListener(&finishedSpy1, QAbstractAnimationJob::Completion); + anim2.removeAnimationChangeListener(&stateChangedSpy2, QAbstractAnimationJob::StateChange); + anim2.removeAnimationChangeListener(&finishedSpy2, QAbstractAnimationJob::Completion); + anim3.removeAnimationChangeListener(&stateChangedSpy3, QAbstractAnimationJob::StateChange); + anim3.removeAnimationChangeListener(&finishedSpy3, QAbstractAnimationJob::Completion); +} + +void tst_QParallelAnimationGroupJob::stopUncontrolledAnimations() +{ + QParallelAnimationGroupJob group; + + TestAnimation anim1(0); + + UncontrolledAnimation notTimeDriven; + QCOMPARE(notTimeDriven.totalDuration(), -1); + + TestAnimation loopsForever(100); + loopsForever.setLoopCount(-1); + + StateChangeListener stateChangedSpy; + anim1.addAnimationChangeListener(&stateChangedSpy, QAbstractAnimationJob::StateChange); + + group.appendAnimation(&anim1); + group.appendAnimation(¬TimeDriven); + group.appendAnimation(&loopsForever); + + group.start(); + + QCOMPARE(stateChangedSpy.count(), 2); + QCOMPARE(stateChangedSpy.states.at(0), QAnimationGroupJob::Running); + QCOMPARE(stateChangedSpy.states.at(1), QAnimationGroupJob::Stopped); + + QCOMPARE(group.state(), QAnimationGroupJob::Running); + QCOMPARE(notTimeDriven.state(), QAnimationGroupJob::Running); + QCOMPARE(loopsForever.state(), QAnimationGroupJob::Running); + QCOMPARE(anim1.state(), QAnimationGroupJob::Stopped); + + notTimeDriven.stop(); + + QCOMPARE(group.state(), QAnimationGroupJob::Running); + QCOMPARE(notTimeDriven.state(), QAnimationGroupJob::Stopped); + QCOMPARE(loopsForever.state(), QAnimationGroupJob::Running); + + loopsForever.stop(); + + QCOMPARE(group.state(), QAnimationGroupJob::Stopped); + QCOMPARE(notTimeDriven.state(), QAnimationGroupJob::Stopped); + QCOMPARE(loopsForever.state(), QAnimationGroupJob::Stopped); +} + +struct AnimState { + AnimState(int time = -1) : time(time), state(-1) {} + AnimState(int time, int state) : time(time), state(state) {} + int time; + int state; +}; + +#define Running QAbstractAnimationJob::Running +#define Stopped QAbstractAnimationJob::Stopped + +Q_DECLARE_METATYPE(AnimState) +void tst_QParallelAnimationGroupJob::loopCount_data() +{ + QTest::addColumn("directionBackward"); + QTest::addColumn("setLoopCount"); + QTest::addColumn("initialGroupTime"); + QTest::addColumn("currentGroupTime"); + QTest::addColumn("expected1"); + QTest::addColumn("expected2"); + QTest::addColumn("expected3"); + + // D U R A T I O N + // 100 60*2 0 + // direction = Forward + QTest::newRow("50") << false << 3 << 0 << 50 << AnimState( 50, Running) << AnimState( 50, Running) << AnimState( 0, Stopped); + QTest::newRow("100") << false << 3 << 0 << 100 << AnimState(100 ) << AnimState( 40, Running) << AnimState( 0, Stopped); + QTest::newRow("110") << false << 3 << 0 << 110 << AnimState(100, Stopped) << AnimState( 50, Running) << AnimState( 0, Stopped); + QTest::newRow("120") << false << 3 << 0 << 120 << AnimState( 0, Running) << AnimState( 0, Running) << AnimState( 0, Stopped); + + QTest::newRow("170") << false << 3 << 0 << 170 << AnimState( 50, Running) << AnimState( 50, Running) << AnimState( 0, Stopped); + QTest::newRow("220") << false << 3 << 0 << 220 << AnimState(100 ) << AnimState( 40, Running) << AnimState( 0, Stopped); + QTest::newRow("230") << false << 3 << 0 << 230 << AnimState(100, Stopped) << AnimState( 50, Running) << AnimState( 0, Stopped); + QTest::newRow("240") << false << 3 << 0 << 240 << AnimState( 0, Running) << AnimState( 0, Running) << AnimState( 0, Stopped); + + QTest::newRow("290") << false << 3 << 0 << 290 << AnimState( 50, Running) << AnimState( 50, Running) << AnimState( 0, Stopped); + QTest::newRow("340") << false << 3 << 0 << 340 << AnimState(100 ) << AnimState( 40, Running) << AnimState( 0, Stopped); + QTest::newRow("350") << false << 3 << 0 << 350 << AnimState(100, Stopped) << AnimState( 50, Running) << AnimState( 0, Stopped); + QTest::newRow("360") << false << 3 << 0 << 360 << AnimState(100, Stopped) << AnimState( 60 ) << AnimState( 0, Stopped); + + QTest::newRow("410") << false << 3 << 0 << 410 << AnimState(100, Stopped) << AnimState( 60, Stopped) << AnimState( 0, Stopped); + QTest::newRow("460") << false << 3 << 0 << 460 << AnimState(100, Stopped) << AnimState( 60, Stopped) << AnimState( 0, Stopped); + QTest::newRow("470") << false << 3 << 0 << 470 << AnimState(100, Stopped) << AnimState( 60, Stopped) << AnimState( 0, Stopped); + QTest::newRow("480") << false << 3 << 0 << 480 << AnimState(100, Stopped) << AnimState( 60, Stopped) << AnimState( 0, Stopped); + + // direction = Forward, rewind + QTest::newRow("120-110") << false << 3 << 120 << 110 << AnimState( 0, Stopped) << AnimState( 50, Running) << AnimState( 0, Stopped); + QTest::newRow("120-50") << false << 3 << 120 << 50 << AnimState( 50, Running) << AnimState( 50, Running) << AnimState( 0, Stopped); + QTest::newRow("120-0") << false << 3 << 120 << 0 << AnimState( 0, Running) << AnimState( 0, Running) << AnimState( 0, Stopped); + QTest::newRow("300-110") << false << 3 << 300 << 110 << AnimState( 0, Stopped) << AnimState( 50, Running) << AnimState( 0, Stopped); + QTest::newRow("300-50") << false << 3 << 300 << 50 << AnimState( 50, Running) << AnimState( 50, Running) << AnimState( 0, Stopped); + QTest::newRow("300-0") << false << 3 << 300 << 0 << AnimState( 0, Running) << AnimState( 0, Running) << AnimState( 0, Stopped); + QTest::newRow("115-105") << false << 3 << 115 << 105 << AnimState( 42, Stopped) << AnimState( 45, Running) << AnimState( 0, Stopped); + + // direction = Backward + QTest::newRow("b120-120") << true << 3 << 120 << 120 << AnimState( 42, Stopped) << AnimState( 60, Running) << AnimState( 0, Stopped); + QTest::newRow("b120-110") << true << 3 << 120 << 110 << AnimState( 42, Stopped) << AnimState( 50, Running) << AnimState( 0, Stopped); + QTest::newRow("b120-100") << true << 3 << 120 << 100 << AnimState(100, Running) << AnimState( 40, Running) << AnimState( 0, Stopped); + QTest::newRow("b120-50") << true << 3 << 120 << 50 << AnimState( 50, Running) << AnimState( 50, Running) << AnimState( 0, Stopped); + QTest::newRow("b120-0") << true << 3 << 120 << 0 << AnimState( 0, Stopped) << AnimState( 0, Stopped) << AnimState( 0, Stopped); + QTest::newRow("b360-170") << true << 3 << 360 << 170 << AnimState( 50, Running) << AnimState( 50, Running) << AnimState( 0, Stopped); + QTest::newRow("b360-220") << true << 3 << 360 << 220 << AnimState(100, Running) << AnimState( 40, Running) << AnimState( 0, Stopped); + QTest::newRow("b360-210") << true << 3 << 360 << 210 << AnimState( 90, Running) << AnimState( 30, Running) << AnimState( 0, Stopped); + QTest::newRow("b360-120") << true << 3 << 360 << 120 << AnimState( 0, Stopped) << AnimState( 60, Running) << AnimState( 0, Stopped); + + // rewind, direction = Backward + QTest::newRow("b50-110") << true << 3 << 50 << 110 << AnimState(100, Stopped) << AnimState( 50, Running) << AnimState( 0, Stopped); + QTest::newRow("b50-120") << true << 3 << 50 << 120 << AnimState(100, Stopped) << AnimState( 60, Running) << AnimState( 0, Stopped); + QTest::newRow("b50-140") << true << 3 << 50 << 140 << AnimState( 20, Running) << AnimState( 20, Running) << AnimState( 0, Stopped); + QTest::newRow("b50-240") << true << 3 << 50 << 240 << AnimState(100, Stopped) << AnimState( 60, Running) << AnimState( 0, Stopped); + QTest::newRow("b50-260") << true << 3 << 50 << 260 << AnimState( 20, Running) << AnimState( 20, Running) << AnimState( 0, Stopped); + QTest::newRow("b50-350") << true << 3 << 50 << 350 << AnimState(100, Stopped) << AnimState( 50, Running) << AnimState( 0, Stopped); + + // infinite looping + QTest::newRow("inf1220") << false << -1 << 0 << 1220 << AnimState( 20, Running) << AnimState( 20, Running) << AnimState( 0, Stopped); + QTest::newRow("inf1310") << false << -1 << 0 << 1310 << AnimState( 100, Stopped) << AnimState( 50, Running) << AnimState( 0, Stopped); + // infinite looping, direction = Backward (will only loop once) + QTest::newRow("b.inf120-120") << true << -1 << 120 << 120 << AnimState( 42, Stopped) << AnimState( 60, Running) << AnimState( 0, Stopped); + QTest::newRow("b.inf120-20") << true << -1 << 120 << 20 << AnimState( 20, Running) << AnimState( 20, Running) << AnimState( 0, Stopped); + QTest::newRow("b.inf120-110") << true << -1 << 120 << 110 << AnimState( 42, Stopped) << AnimState( 50, Running) << AnimState( 0, Stopped); + + +} + +void tst_QParallelAnimationGroupJob::loopCount() +{ + QFETCH(bool, directionBackward); + QFETCH(int, setLoopCount); + QFETCH(int, initialGroupTime); + QFETCH(int, currentGroupTime); + QFETCH(AnimState, expected1); + QFETCH(AnimState, expected2); + QFETCH(AnimState, expected3); + + QParallelAnimationGroupJob group; + + TestAnimation anim1(100); + TestAnimation anim2(60); //total 120 + anim2.setLoopCount(2); + TestAnimation anim3(0); + + group.appendAnimation(&anim1); + group.appendAnimation(&anim2); + group.appendAnimation(&anim3); + + group.setLoopCount(setLoopCount); + if (initialGroupTime >= 0) + group.setCurrentTime(initialGroupTime); + if (directionBackward) + group.setDirection(QAbstractAnimationJob::Backward); + + group.start(); + if (initialGroupTime >= 0) + group.setCurrentTime(initialGroupTime); + + anim1.setCurrentTime(42); // 42 is "untouched" + anim2.setCurrentTime(42); + + group.setCurrentTime(currentGroupTime); + + QCOMPARE(anim1.currentLoopTime(), expected1.time); + QCOMPARE(anim2.currentLoopTime(), expected2.time); + QCOMPARE(anim3.currentLoopTime(), expected3.time); + + if (expected1.state >=0) + QCOMPARE(int(anim1.state()), expected1.state); + if (expected2.state >=0) + QCOMPARE(int(anim2.state()), expected2.state); + if (expected3.state >=0) + QCOMPARE(int(anim3.state()), expected3.state); + +} + +void tst_QParallelAnimationGroupJob::addAndRemoveDuration() +{ + QParallelAnimationGroupJob group; + QCOMPARE(group.duration(), 0); + TestAnimation *test = new TestAnimation(250); // 0, duration = 250; + group.appendAnimation(test); + QCOMPARE(test->group(), static_cast(&group)); + QCOMPARE(test->duration(), 250); + QCOMPARE(group.duration(), 250); + + TestAnimation *test2 = new TestAnimation(750); // 1 + group.appendAnimation(test2); + QCOMPARE(test2->group(), static_cast(&group)); + QCOMPARE(group.duration(), 750); + + TestAnimation *test3 = new TestAnimation(500); // 2 + group.appendAnimation(test3); + QCOMPARE(test3->group(), static_cast(&group)); + QCOMPARE(group.duration(), 750); + + group.removeAnimation(test2); // remove the one with duration = 750 + delete test2; + QCOMPARE(group.duration(), 500); + + group.removeAnimation(test3); // remove the one with duration = 500 + delete test3; + QCOMPARE(group.duration(), 250); + + group.removeAnimation(test); // remove the last one (with duration = 250) + QCOMPARE(test->group(), static_cast(0)); + QCOMPARE(group.duration(), 0); + delete test; +} + +void tst_QParallelAnimationGroupJob::pauseResume() +{ + QParallelAnimationGroupJob group; + TestAnimation *anim = new TestAnimation(250); // 0, duration = 250; + group.appendAnimation(anim); + StateChangeListener spy; + anim->addAnimationChangeListener(&spy, QAbstractAnimationJob::StateChange); + QCOMPARE(group.duration(), 250); + group.start(); + QTest::qWait(100); + QCOMPARE(group.state(), QAnimationGroupJob::Running); + QCOMPARE(anim->state(), QAnimationGroupJob::Running); + QCOMPARE(spy.count(), 1); + spy.clear(); + const int currentTime = group.currentLoopTime(); + QCOMPARE(anim->currentLoopTime(), currentTime); + + group.pause(); + QCOMPARE(group.state(), QAnimationGroupJob::Paused); + QCOMPARE(group.currentLoopTime(), currentTime); + QCOMPARE(anim->state(), QAnimationGroupJob::Paused); + QCOMPARE(anim->currentLoopTime(), currentTime); + QCOMPARE(spy.count(), 1); + spy.clear(); + + group.resume(); + QCOMPARE(group.state(), QAnimationGroupJob::Running); + QCOMPARE(group.currentLoopTime(), currentTime); + QCOMPARE(anim->state(), QAnimationGroupJob::Running); + QCOMPARE(anim->currentLoopTime(), currentTime); + QCOMPARE(spy.count(), 1); + + group.stop(); + spy.clear(); + group.appendAnimation(new TestAnimation(500)); + group.start(); + QCOMPARE(spy.count(), 1); //the animation should have been started + QCOMPARE(spy.states.at(0), TestAnimation::Running); + group.setCurrentTime(250); //end of first animation + QCOMPARE(spy.count(), 2); //the animation should have been stopped + QCOMPARE(spy.states.at(1), TestAnimation::Stopped); + group.pause(); + QCOMPARE(spy.count(), 2); //this shouldn't have changed + group.resume(); + QCOMPARE(spy.count(), 2); //this shouldn't have changed +} + +// This is a regression test for QTBUG-8910, where a crash occurred when the +// last animation was removed from a group. +void tst_QParallelAnimationGroupJob::crashWhenRemovingUncontrolledAnimation() +{ + QParallelAnimationGroupJob group; + TestAnimation *anim = new TestAnimation; + anim->setLoopCount(-1); + TestAnimation *anim2 = new TestAnimation; + anim2->setLoopCount(-1); + group.appendAnimation(anim); + group.appendAnimation(anim2); + group.start(); + delete anim; + // it would crash here because the internals of the group would still have a reference to anim + delete anim2; +} + + +QTEST_MAIN(tst_QParallelAnimationGroupJob) +#include "tst_qparallelanimationgroupjob.moc" diff --git a/tests/auto/qml/animation/qpauseanimationjob/qpauseanimationjob.pro b/tests/auto/qml/animation/qpauseanimationjob/qpauseanimationjob.pro new file mode 100644 index 0000000000..b80bb0c55c --- /dev/null +++ b/tests/auto/qml/animation/qpauseanimationjob/qpauseanimationjob.pro @@ -0,0 +1,5 @@ +CONFIG += testcase +macx:CONFIG -= app_bundle +TARGET = tst_qpauseanimationjob +QT = core-private gui-private qml-private testlib +SOURCES = tst_qpauseanimationjob.cpp diff --git a/tests/auto/qml/animation/qpauseanimationjob/tst_qpauseanimationjob.cpp b/tests/auto/qml/animation/qpauseanimationjob/tst_qpauseanimationjob.cpp new file mode 100644 index 0000000000..247d7791bf --- /dev/null +++ b/tests/auto/qml/animation/qpauseanimationjob/tst_qpauseanimationjob.cpp @@ -0,0 +1,470 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include + +#include +#include +#include + +#ifdef Q_OS_WIN +static const char winTimerError[] = "On windows, consistent timing is not working properly due to bad timer resolution"; +#endif + +class TestablePauseAnimation : public QPauseAnimationJob +{ +public: + TestablePauseAnimation() + : m_updateCurrentTimeCount(0) + { + } + + TestablePauseAnimation(int duration) + : QPauseAnimationJob(duration), m_updateCurrentTimeCount(0) + { + } + + int m_updateCurrentTimeCount; +protected: + void updateCurrentTime(int currentTime) + { + QPauseAnimationJob::updateCurrentTime(currentTime); + ++m_updateCurrentTimeCount; + } +}; + +class TestableGenericAnimation : public QAbstractAnimationJob +{ +public: + TestableGenericAnimation(int duration = 250) : m_duration(duration) {} + int duration() const { return m_duration; } + +private: + int m_duration; +}; + +class EnableConsistentTiming +{ +public: + EnableConsistentTiming() + { + QUnifiedTimer *timer = QUnifiedTimer::instance(); + timer->setConsistentTiming(true); + } + ~EnableConsistentTiming() + { + QUnifiedTimer *timer = QUnifiedTimer::instance(); + timer->setConsistentTiming(false); + } +}; + +class tst_QPauseAnimationJob : public QObject +{ + Q_OBJECT +public Q_SLOTS: + void initTestCase(); + +private slots: + void changeDirectionWhileRunning(); + void noTimerUpdates_data(); + void noTimerUpdates(); + void multiplePauseAnimations(); + void pauseAndPropertyAnimations(); + void pauseResume(); + void sequentialPauseGroup(); + void sequentialGroupWithPause(); + void multipleSequentialGroups(); + void zeroDuration(); +}; + +void tst_QPauseAnimationJob::initTestCase() +{ +// qRegisterMetaType("QAbstractAnimationJob::State"); +} + +void tst_QPauseAnimationJob::changeDirectionWhileRunning() +{ + EnableConsistentTiming enabled; + + TestablePauseAnimation animation; + animation.setDuration(400); + animation.start(); + QTest::qWait(100); + QVERIFY(animation.state() == QAbstractAnimationJob::Running); + animation.setDirection(QAbstractAnimationJob::Backward); + QTest::qWait(animation.totalDuration() + 50); + QVERIFY(animation.state() == QAbstractAnimationJob::Stopped); +} + +void tst_QPauseAnimationJob::noTimerUpdates_data() +{ + QTest::addColumn("duration"); + QTest::addColumn("loopCount"); + + QTest::newRow("0") << 200 << 1; + QTest::newRow("1") << 160 << 1; + QTest::newRow("2") << 160 << 2; + QTest::newRow("3") << 200 << 3; +} + +void tst_QPauseAnimationJob::noTimerUpdates() +{ + EnableConsistentTiming enabled; + + QFETCH(int, duration); + QFETCH(int, loopCount); + + TestablePauseAnimation animation; + animation.setDuration(duration); + animation.setLoopCount(loopCount); + animation.start(); + QTest::qWait(animation.totalDuration() + 100); + +#ifdef Q_OS_WIN + if (animation.state() != QAbstractAnimationJob::Stopped) + QEXPECT_FAIL("", winTimerError, Abort); +#endif + + QVERIFY(animation.state() == QAbstractAnimationJob::Stopped); + const int expectedLoopCount = 1 + loopCount; + +#ifdef Q_OS_WIN + if (animation.m_updateCurrentTimeCount != expectedLoopCount) + QEXPECT_FAIL("", winTimerError, Abort); +#endif + QCOMPARE(animation.m_updateCurrentTimeCount, expectedLoopCount); +} + +void tst_QPauseAnimationJob::multiplePauseAnimations() +{ + EnableConsistentTiming enabled; + + TestablePauseAnimation animation; + animation.setDuration(200); + + TestablePauseAnimation animation2; + animation2.setDuration(800); + + animation.start(); + animation2.start(); + QTest::qWait(animation.totalDuration() + 100); + +#ifdef Q_OS_WIN + if (animation.state() != QAbstractAnimationJob::Stopped) + QEXPECT_FAIL("", winTimerError, Abort); +#endif + QVERIFY(animation.state() == QAbstractAnimationJob::Stopped); + +#ifdef Q_OS_WIN + if (animation2.state() != QAbstractAnimationJob::Running) + QEXPECT_FAIL("", winTimerError, Abort); +#endif + QVERIFY(animation2.state() == QAbstractAnimationJob::Running); + +#ifdef Q_OS_WIN + if (animation.m_updateCurrentTimeCount != 2) + QEXPECT_FAIL("", winTimerError, Abort); +#endif + QCOMPARE(animation.m_updateCurrentTimeCount, 2); + +#ifdef Q_OS_WIN + if (animation2.m_updateCurrentTimeCount != 2) + QEXPECT_FAIL("", winTimerError, Abort); +#endif + QCOMPARE(animation2.m_updateCurrentTimeCount, 2); + + QTest::qWait(550); + +#ifdef Q_OS_WIN + if (animation2.state() != QAbstractAnimationJob::Stopped) + QEXPECT_FAIL("", winTimerError, Abort); +#endif + QVERIFY(animation2.state() == QAbstractAnimationJob::Stopped); + +#ifdef Q_OS_WIN + if (animation2.m_updateCurrentTimeCount != 3) + QEXPECT_FAIL("", winTimerError, Abort); +#endif + QCOMPARE(animation2.m_updateCurrentTimeCount, 3); +} + +void tst_QPauseAnimationJob::pauseAndPropertyAnimations() +{ + EnableConsistentTiming enabled; + + TestablePauseAnimation pause; + pause.setDuration(200); + + TestableGenericAnimation animation; + + pause.start(); + + QTest::qWait(100); + animation.start(); + + QVERIFY(animation.state() == QAbstractAnimationJob::Running); + QVERIFY(pause.state() == QAbstractAnimationJob::Running); + QCOMPARE(pause.m_updateCurrentTimeCount, 2); + + QTest::qWait(animation.totalDuration() + 100); + +#ifdef Q_OS_WIN + if (animation.state() != QAbstractAnimationJob::Stopped) + QEXPECT_FAIL("", winTimerError, Abort); +#endif + QVERIFY(animation.state() == QAbstractAnimationJob::Stopped); + QVERIFY(pause.state() == QAbstractAnimationJob::Stopped); + QVERIFY(pause.m_updateCurrentTimeCount > 3); +} + +void tst_QPauseAnimationJob::pauseResume() +{ + TestablePauseAnimation animation; + animation.setDuration(400); + animation.start(); + QVERIFY(animation.state() == QAbstractAnimationJob::Running); + QTest::qWait(200); + animation.pause(); + QVERIFY(animation.state() == QAbstractAnimationJob::Paused); + animation.start(); + QTest::qWait(300); + QVERIFY(animation.state() == QAbstractAnimationJob::Stopped); + +#ifdef Q_OS_WIN + if (animation.m_updateCurrentTimeCount != 3) + QEXPECT_FAIL("", winTimerError, Abort); +#endif + QCOMPARE(animation.m_updateCurrentTimeCount, 3); +} + +void tst_QPauseAnimationJob::sequentialPauseGroup() +{ + QSequentialAnimationGroupJob group; + + TestablePauseAnimation animation1(200); + group.appendAnimation(&animation1); + TestablePauseAnimation animation2(200); + group.appendAnimation(&animation2); + TestablePauseAnimation animation3(200); + group.appendAnimation(&animation3); + + group.start(); + QCOMPARE(animation1.m_updateCurrentTimeCount, 1); + QCOMPARE(animation2.m_updateCurrentTimeCount, 0); + QCOMPARE(animation3.m_updateCurrentTimeCount, 0); + + QVERIFY(group.state() == QAbstractAnimationJob::Running); + QVERIFY(animation1.state() == QAbstractAnimationJob::Running); + QVERIFY(animation2.state() == QAbstractAnimationJob::Stopped); + QVERIFY(animation3.state() == QAbstractAnimationJob::Stopped); + + group.setCurrentTime(250); + QCOMPARE(animation1.m_updateCurrentTimeCount, 2); + QCOMPARE(animation2.m_updateCurrentTimeCount, 1); + QCOMPARE(animation3.m_updateCurrentTimeCount, 0); + + QVERIFY(group.state() == QAbstractAnimationJob::Running); + QVERIFY(animation1.state() == QAbstractAnimationJob::Stopped); + QCOMPARE((QAbstractAnimationJob*)&animation2, group.currentAnimation()); + QVERIFY(animation2.state() == QAbstractAnimationJob::Running); + QVERIFY(animation3.state() == QAbstractAnimationJob::Stopped); + + group.setCurrentTime(500); + QCOMPARE(animation1.m_updateCurrentTimeCount, 2); + QCOMPARE(animation2.m_updateCurrentTimeCount, 2); + QCOMPARE(animation3.m_updateCurrentTimeCount, 1); + + QVERIFY(group.state() == QAbstractAnimationJob::Running); + QVERIFY(animation1.state() == QAbstractAnimationJob::Stopped); + QVERIFY(animation2.state() == QAbstractAnimationJob::Stopped); + QCOMPARE((QAbstractAnimationJob*)&animation3, group.currentAnimation()); + QVERIFY(animation3.state() == QAbstractAnimationJob::Running); + + group.setCurrentTime(750); + + QVERIFY(group.state() == QAbstractAnimationJob::Stopped); + QVERIFY(animation1.state() == QAbstractAnimationJob::Stopped); + QVERIFY(animation2.state() == QAbstractAnimationJob::Stopped); + QVERIFY(animation3.state() == QAbstractAnimationJob::Stopped); + + QCOMPARE(animation1.m_updateCurrentTimeCount, 2); + QCOMPARE(animation2.m_updateCurrentTimeCount, 2); + QCOMPARE(animation3.m_updateCurrentTimeCount, 2); +} + +void tst_QPauseAnimationJob::sequentialGroupWithPause() +{ + QSequentialAnimationGroupJob group; + + TestableGenericAnimation animation; + group.appendAnimation(&animation); + + TestablePauseAnimation pause; + pause.setDuration(250); + group.appendAnimation(&pause); + + group.start(); + + QVERIFY(group.state() == QAbstractAnimationJob::Running); + QVERIFY(animation.state() == QAbstractAnimationJob::Running); + QVERIFY(pause.state() == QAbstractAnimationJob::Stopped); + + group.setCurrentTime(300); + + QVERIFY(group.state() == QAbstractAnimationJob::Running); + QVERIFY(animation.state() == QAbstractAnimationJob::Stopped); + QCOMPARE((QAbstractAnimationJob*)&pause, group.currentAnimation()); + QVERIFY(pause.state() == QAbstractAnimationJob::Running); + + group.setCurrentTime(600); + + QVERIFY(group.state() == QAbstractAnimationJob::Stopped); + QVERIFY(animation.state() == QAbstractAnimationJob::Stopped); + QVERIFY(pause.state() == QAbstractAnimationJob::Stopped); + + QCOMPARE(pause.m_updateCurrentTimeCount, 2); +} + +void tst_QPauseAnimationJob::multipleSequentialGroups() +{ + EnableConsistentTiming enabled; + + QParallelAnimationGroupJob group; + group.setLoopCount(2); + + QSequentialAnimationGroupJob subgroup1; + group.appendAnimation(&subgroup1); + + TestableGenericAnimation animation(300); + subgroup1.appendAnimation(&animation); + + TestablePauseAnimation pause(200); + subgroup1.appendAnimation(&pause); + + QSequentialAnimationGroupJob subgroup2; + group.appendAnimation(&subgroup2); + + TestableGenericAnimation animation2(200); + subgroup2.appendAnimation(&animation2); + + TestablePauseAnimation pause2(250); + subgroup2.appendAnimation(&pause2); + + QSequentialAnimationGroupJob subgroup3; + group.appendAnimation(&subgroup3); + + TestablePauseAnimation pause3(400); + subgroup3.appendAnimation(&pause3); + + TestableGenericAnimation animation3(200); + subgroup3.appendAnimation(&animation3); + + QSequentialAnimationGroupJob subgroup4; + group.appendAnimation(&subgroup4); + + TestablePauseAnimation pause4(310); + subgroup4.appendAnimation(&pause4); + + TestablePauseAnimation pause5(60); + subgroup4.appendAnimation(&pause5); + + group.start(); + + QVERIFY(group.state() == QAbstractAnimationJob::Running); + QVERIFY(subgroup1.state() == QAbstractAnimationJob::Running); + QVERIFY(subgroup2.state() == QAbstractAnimationJob::Running); + QVERIFY(subgroup3.state() == QAbstractAnimationJob::Running); + QVERIFY(subgroup4.state() == QAbstractAnimationJob::Running); + + // This is a pretty long animation so it tends to get rather out of sync + // when using the consistent timer, so run for an extra half second for good + // measure... + QTest::qWait(group.totalDuration() + 500); + +#ifdef Q_OS_WIN + if (group.state() != QAbstractAnimationJob::Stopped) + QEXPECT_FAIL("", winTimerError, Abort); +#endif + QVERIFY(group.state() == QAbstractAnimationJob::Stopped); + +#ifdef Q_OS_WIN + if (subgroup1.state() != QAbstractAnimationJob::Stopped) + QEXPECT_FAIL("", winTimerError, Abort); +#endif + QVERIFY(subgroup1.state() == QAbstractAnimationJob::Stopped); + +#ifdef Q_OS_WIN + if (subgroup2.state() != QAbstractAnimationJob::Stopped) + QEXPECT_FAIL("", winTimerError, Abort); +#endif + QVERIFY(subgroup2.state() == QAbstractAnimationJob::Stopped); + +#ifdef Q_OS_WIN + if (subgroup3.state() != QAbstractAnimationJob::Stopped) + QEXPECT_FAIL("", winTimerError, Abort); +#endif + QVERIFY(subgroup3.state() == QAbstractAnimationJob::Stopped); + +#ifdef Q_OS_WIN + if (subgroup4.state() != QAbstractAnimationJob::Stopped) + QEXPECT_FAIL("", winTimerError, Abort); +#endif + QVERIFY(subgroup4.state() == QAbstractAnimationJob::Stopped); + +#ifdef Q_OS_WIN + if (pause5.m_updateCurrentTimeCount != 4) + QEXPECT_FAIL("", winTimerError, Abort); +#endif + QCOMPARE(pause5.m_updateCurrentTimeCount, 4); +} + +void tst_QPauseAnimationJob::zeroDuration() +{ + TestablePauseAnimation animation; + animation.setDuration(0); + animation.start(); + QTest::qWait(animation.totalDuration() + 100); + QVERIFY(animation.state() == QAbstractAnimationJob::Stopped); + QCOMPARE(animation.m_updateCurrentTimeCount, 1); +} + +QTEST_MAIN(tst_QPauseAnimationJob) +#include "tst_qpauseanimationjob.moc" diff --git a/tests/auto/qml/animation/qsequentialanimationgroupjob/qsequentialanimationgroupjob.pro b/tests/auto/qml/animation/qsequentialanimationgroupjob/qsequentialanimationgroupjob.pro new file mode 100644 index 0000000000..fe4dc9ce82 --- /dev/null +++ b/tests/auto/qml/animation/qsequentialanimationgroupjob/qsequentialanimationgroupjob.pro @@ -0,0 +1,5 @@ +CONFIG += testcase parallel_test +macx:CONFIG -= app_bundle +TARGET = tst_qsequentialanimationgroupjob +QT = core-private qml-private testlib +SOURCES = tst_qsequentialanimationgroupjob.cpp diff --git a/tests/auto/qml/animation/qsequentialanimationgroupjob/tst_qsequentialanimationgroupjob.cpp b/tests/auto/qml/animation/qsequentialanimationgroupjob/tst_qsequentialanimationgroupjob.cpp new file mode 100644 index 0000000000..caa43cf9cb --- /dev/null +++ b/tests/auto/qml/animation/qsequentialanimationgroupjob/tst_qsequentialanimationgroupjob.cpp @@ -0,0 +1,1617 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include +#include +#include + +Q_DECLARE_METATYPE(QAbstractAnimationJob::State) +Q_DECLARE_METATYPE(QAbstractAnimationJob*) + +class tst_QSequentialAnimationGroupJob : public QObject +{ + Q_OBJECT +public Q_SLOTS: + void initTestCase(); + +private slots: + void construction(); + void setCurrentTime(); + void setCurrentTimeWithUncontrolledAnimation(); + void seekingForwards(); + void seekingBackwards(); + void pauseAndResume(); + void restart(); + void looping(); + void startDelay(); + void clearGroup(); + void groupWithZeroDurationAnimations(); + void propagateGroupUpdateToChildren(); + void updateChildrenWithRunningGroup(); + void deleteChildrenWithRunningGroup(); + void startChildrenWithStoppedGroup(); + void stopGroupWithRunningChild(); + void startGroupWithRunningChild(); + void zeroDurationAnimation(); + void stopUncontrolledAnimations(); + void finishWithUncontrolledAnimation(); + void addRemoveAnimation(); + void currentAnimation(); + void currentAnimationWithZeroDuration(); + void insertAnimation(); + void clear(); + void pauseResume(); +}; + +void tst_QSequentialAnimationGroupJob::initTestCase() +{ + qRegisterMetaType("QAbstractAnimationJob::State"); + qRegisterMetaType("QAbstractAnimationJob*"); +} + +void tst_QSequentialAnimationGroupJob::construction() +{ + QSequentialAnimationGroupJob animationgroup; +} + +class TestAnimation : public QAbstractAnimationJob +{ +public: + TestAnimation(int duration = 250) : m_duration(duration) {} + int duration() const { return m_duration; } + +private: + int m_duration; +}; + +class TestValueAnimation : public TestAnimation +{ +public: + TestValueAnimation(int duration = 250) + : TestAnimation(duration), start(0), end(0), value(0) {} + + void updateCurrentTime(int msecs) + { + if (msecs >= duration()) + value = end; + else + value = start + (end - start) * (qreal(msecs) / duration()); + } + + qreal start, end; + qreal value; +}; + +class UncontrolledAnimation : public QObject, public QAbstractAnimationJob +{ + Q_OBJECT +public: + int duration() const { return -1; /* not time driven */ } + +protected: + void updateCurrentTime(int currentTime) + { + if (currentTime >= 250) + stop(); + } +}; + +class StateChangeListener: public QAnimationJobChangeListener +{ +public: + virtual void animationStateChanged(QAbstractAnimationJob *, QAbstractAnimationJob::State newState, QAbstractAnimationJob::State) + { + states << newState; + } + + void clear() { states.clear(); } + int count() const { return states.count(); } + + QList states; +}; + +class FinishedListener: public QAnimationJobChangeListener +{ +public: + FinishedListener() : m_count(0) {} + + virtual void animationFinished(QAbstractAnimationJob *) { ++m_count; } + void clear() { m_count = 0; } + int count() { return m_count; } + +private: + int m_count; +}; + +void tst_QSequentialAnimationGroupJob::setCurrentTime() +{ + // sequence operating on same object/property + QAnimationGroupJob *sequence = new QSequentialAnimationGroupJob(); + TestAnimation *a1_s_o1 = new TestAnimation; + TestAnimation *a2_s_o1 = new TestAnimation; + TestAnimation *a3_s_o1 = new TestAnimation; + a2_s_o1->setLoopCount(3); + sequence->appendAnimation(a1_s_o1); + sequence->appendAnimation(a2_s_o1); + sequence->appendAnimation(a3_s_o1); + + // sequence operating on different object/properties + QAnimationGroupJob *sequence2 = new QSequentialAnimationGroupJob(); + TestAnimation *a1_s_o2 = new TestAnimation; + TestAnimation *a1_s_o3 = new TestAnimation; + sequence2->appendAnimation(a1_s_o2); + sequence2->appendAnimation(a1_s_o3); + + QSequentialAnimationGroupJob group; + group.appendAnimation(sequence); + group.appendAnimation(sequence2); + + // Current time = 1 + group.setCurrentTime(1); + QCOMPARE(group.state(), QAnimationGroupJob::Stopped); + QCOMPARE(sequence->state(), QAnimationGroupJob::Stopped); + QCOMPARE(a1_s_o1->state(), QAnimationGroupJob::Stopped); + QCOMPARE(sequence2->state(), QAnimationGroupJob::Stopped); + QCOMPARE(a1_s_o2->state(), QAnimationGroupJob::Stopped); + + QCOMPARE(group.currentLoopTime(), 1); + QCOMPARE(sequence->currentLoopTime(), 1); + QCOMPARE(a1_s_o1->currentLoopTime(), 1); + QCOMPARE(a2_s_o1->currentLoopTime(), 0); + QCOMPARE(a3_s_o1->currentLoopTime(), 0); + QCOMPARE(a1_s_o2->currentLoopTime(), 0); + QCOMPARE(a1_s_o3->currentLoopTime(), 0); + + // Current time = 250 + group.setCurrentTime(250); + QCOMPARE(group.currentLoopTime(), 250); + QCOMPARE(sequence->currentLoopTime(), 250); + QCOMPARE(a1_s_o1->currentLoopTime(), 250); + QCOMPARE(a2_s_o1->currentLoopTime(), 0); + QCOMPARE(a3_s_o1->currentLoopTime(), 0); + QCOMPARE(a1_s_o2->currentLoopTime(), 0); + QCOMPARE(a1_s_o3->currentLoopTime(), 0); + + // Current time = 251 + group.setCurrentTime(251); + QCOMPARE(group.currentLoopTime(), 251); + QCOMPARE(sequence->currentLoopTime(), 251); + QCOMPARE(a1_s_o1->currentLoopTime(), 250); + QCOMPARE(a2_s_o1->currentLoopTime(), 1); + QCOMPARE(a2_s_o1->currentLoop(), 0); + QCOMPARE(a3_s_o1->currentLoopTime(), 0); + QCOMPARE(sequence2->currentLoopTime(), 0); + QCOMPARE(a1_s_o2->currentLoopTime(), 0); + QCOMPARE(a1_s_o3->currentLoopTime(), 0); + + // Current time = 750 + group.setCurrentTime(750); + QCOMPARE(group.currentLoopTime(), 750); + QCOMPARE(sequence->currentLoopTime(), 750); + QCOMPARE(a1_s_o1->currentLoopTime(), 250); + QCOMPARE(a2_s_o1->currentLoopTime(), 0); + QCOMPARE(a2_s_o1->currentLoop(), 2); + QCOMPARE(a3_s_o1->currentLoopTime(), 0); + QCOMPARE(sequence2->currentLoopTime(), 0); + QCOMPARE(a1_s_o2->currentLoopTime(), 0); + QCOMPARE(a1_s_o3->currentLoopTime(), 0); + + // Current time = 1000 + group.setCurrentTime(1000); + QCOMPARE(group.currentLoopTime(), 1000); + QCOMPARE(sequence->currentLoopTime(), 1000); + QCOMPARE(a1_s_o1->currentLoopTime(), 250); + QCOMPARE(a2_s_o1->currentLoopTime(), 250); + QCOMPARE(a2_s_o1->currentLoop(), 2); + QCOMPARE(a3_s_o1->currentLoopTime(), 0); + QCOMPARE(sequence2->currentLoopTime(), 0); + QCOMPARE(a1_s_o2->currentLoopTime(), 0); + QCOMPARE(a1_s_o3->currentLoopTime(), 0); + + // Current time = 1010 + group.setCurrentTime(1010); + QCOMPARE(group.currentLoopTime(), 1010); + QCOMPARE(sequence->currentLoopTime(), 1010); + QCOMPARE(a1_s_o1->currentLoopTime(), 250); + QCOMPARE(a2_s_o1->currentLoopTime(), 250); + QCOMPARE(a2_s_o1->currentLoop(), 2); + QCOMPARE(a3_s_o1->currentLoopTime(), 10); + QCOMPARE(sequence2->currentLoopTime(), 0); + QCOMPARE(a1_s_o2->currentLoopTime(), 0); + QCOMPARE(a1_s_o3->currentLoopTime(), 0); + + // Current time = 1250 + group.setCurrentTime(1250); + QCOMPARE(group.currentLoopTime(), 1250); + QCOMPARE(sequence->currentLoopTime(), 1250); + QCOMPARE(a1_s_o1->currentLoopTime(), 250); + QCOMPARE(a2_s_o1->currentLoopTime(), 250); + QCOMPARE(a2_s_o1->currentLoop(), 2); + QCOMPARE(a3_s_o1->currentLoopTime(), 250); + QCOMPARE(sequence2->currentLoopTime(), 0); + QCOMPARE(a1_s_o2->currentLoopTime(), 0); + QCOMPARE(a1_s_o3->currentLoopTime(), 0); + + // Current time = 1500 + group.setCurrentTime(1500); + QCOMPARE(group.currentLoopTime(), 1500); + QCOMPARE(sequence->currentLoopTime(), 1250); + QCOMPARE(a1_s_o1->currentLoopTime(), 250); + QCOMPARE(a2_s_o1->currentLoopTime(), 250); + QCOMPARE(a2_s_o1->currentLoop(), 2); + QCOMPARE(a3_s_o1->currentLoopTime(), 250); + QCOMPARE(sequence2->currentLoopTime(), 250); + QCOMPARE(a1_s_o2->currentLoopTime(), 250); + QCOMPARE(a1_s_o3->currentLoopTime(), 0); + + // Current time = 1750 + group.setCurrentTime(1750); + QCOMPARE(group.currentLoopTime(), 1750); + QCOMPARE(sequence->currentLoopTime(), 1250); + QCOMPARE(a1_s_o1->currentLoopTime(), 250); + QCOMPARE(a2_s_o1->currentLoopTime(), 250); + QCOMPARE(a2_s_o1->currentLoop(), 2); + QCOMPARE(a3_s_o1->currentLoopTime(), 250); + QCOMPARE(sequence2->currentLoopTime(), 500); + QCOMPARE(a1_s_o2->currentLoopTime(), 250); + QCOMPARE(a1_s_o3->currentLoopTime(), 250); + + // Current time = 2000 + group.setCurrentTime(2000); + QCOMPARE(group.currentLoopTime(), 1750); + QCOMPARE(sequence->currentLoopTime(), 1250); + QCOMPARE(a1_s_o1->currentLoopTime(), 250); + QCOMPARE(a2_s_o1->currentLoopTime(), 250); + QCOMPARE(a2_s_o1->currentLoop(), 2); + QCOMPARE(a3_s_o1->currentLoopTime(), 250); + QCOMPARE(sequence2->currentLoopTime(), 500); + QCOMPARE(a1_s_o2->currentLoopTime(), 250); + QCOMPARE(a1_s_o3->currentLoopTime(), 250); +} + +void tst_QSequentialAnimationGroupJob::setCurrentTimeWithUncontrolledAnimation() +{ + // sequence operating on different object/properties + QAnimationGroupJob *sequence = new QSequentialAnimationGroupJob(); + TestAnimation *a1_s_o1 = new TestAnimation; + TestAnimation *a1_s_o2 = new TestAnimation; + sequence->appendAnimation(a1_s_o1); + sequence->appendAnimation(a1_s_o2); + + UncontrolledAnimation *notTimeDriven = new UncontrolledAnimation; + QCOMPARE(notTimeDriven->totalDuration(), -1); + + TestAnimation *loopsForever = new TestAnimation; + loopsForever->setLoopCount(-1); + QCOMPARE(loopsForever->totalDuration(), -1); + + QSequentialAnimationGroupJob group; + group.appendAnimation(sequence); + group.appendAnimation(notTimeDriven); + group.appendAnimation(loopsForever); + group.start(); + group.pause(); // this allows the group to listen for the finish signal of its children + + // Current time = 1 + group.setCurrentTime(1); + QCOMPARE(group.state(), QAnimationGroupJob::Paused); + QCOMPARE(sequence->state(), QAnimationGroupJob::Paused); + QCOMPARE(a1_s_o1->state(), QAnimationGroupJob::Paused); + QCOMPARE(a1_s_o2->state(), QAnimationGroupJob::Stopped); + QCOMPARE(notTimeDriven->state(), QAnimationGroupJob::Stopped); + QCOMPARE(loopsForever->state(), QAnimationGroupJob::Stopped); + + QCOMPARE(group.currentLoopTime(), 1); + QCOMPARE(sequence->currentLoopTime(), 1); + QCOMPARE(a1_s_o1->currentLoopTime(), 1); + QCOMPARE(a1_s_o2->currentLoopTime(), 0); + QCOMPARE(notTimeDriven->currentLoopTime(), 0); + QCOMPARE(loopsForever->currentLoopTime(), 0); + + // Current time = 250 + group.setCurrentTime(250); + QCOMPARE(group.currentLoopTime(), 250); + QCOMPARE(sequence->currentLoopTime(), 250); + QCOMPARE(a1_s_o1->currentLoopTime(), 250); + QCOMPARE(a1_s_o2->currentLoopTime(), 0); + QCOMPARE(notTimeDriven->currentLoopTime(), 0); + QCOMPARE(loopsForever->currentLoopTime(), 0); + + // Current time = 500 + group.setCurrentTime(500); + QCOMPARE(group.currentLoopTime(), 500); + QCOMPARE(sequence->currentLoopTime(), 500); + QCOMPARE(a1_s_o1->currentLoopTime(), 250); + QCOMPARE(a1_s_o2->currentLoopTime(), 250); + QCOMPARE(notTimeDriven->currentLoopTime(), 0); + QCOMPARE(loopsForever->currentLoopTime(), 0); + QCOMPARE(group.currentAnimation(), static_cast(notTimeDriven)); + + // Current time = 505 + group.setCurrentTime(505); + QCOMPARE(group.currentLoopTime(), 505); + QCOMPARE(sequence->currentLoopTime(), 500); + QCOMPARE(a1_s_o1->currentLoopTime(), 250); + QCOMPARE(a1_s_o2->currentLoopTime(), 250); + QCOMPARE(notTimeDriven->currentLoopTime(), 5); + QCOMPARE(loopsForever->currentLoopTime(), 0); + QCOMPARE(group.currentAnimation(), static_cast(notTimeDriven)); + QCOMPARE(sequence->state(), QAnimationGroupJob::Stopped); + QCOMPARE(a1_s_o1->state(), QAnimationGroupJob::Stopped); + QCOMPARE(a1_s_o2->state(), QAnimationGroupJob::Stopped); + QCOMPARE(notTimeDriven->state(), QAnimationGroupJob::Paused); + QCOMPARE(loopsForever->state(), QAnimationGroupJob::Stopped); + + // Current time = 750 (end of notTimeDriven animation) + group.setCurrentTime(750); + QCOMPARE(group.currentLoopTime(), 750); + QCOMPARE(sequence->currentLoopTime(), 500); + QCOMPARE(a1_s_o1->currentLoopTime(), 250); + QCOMPARE(a1_s_o2->currentLoopTime(), 250); + QCOMPARE(notTimeDriven->currentLoopTime(), 250); + QCOMPARE(loopsForever->currentLoopTime(), 0); + QCOMPARE(group.currentAnimation(), loopsForever); + QCOMPARE(sequence->state(), QAnimationGroupJob::Stopped); + QCOMPARE(a1_s_o1->state(), QAnimationGroupJob::Stopped); + QCOMPARE(a1_s_o2->state(), QAnimationGroupJob::Stopped); + QCOMPARE(notTimeDriven->state(), QAnimationGroupJob::Stopped); + QCOMPARE(loopsForever->state(), QAnimationGroupJob::Paused); + + // Current time = 800 (as notTimeDriven was finished at 750, loopsforever should still run) + group.setCurrentTime(800); + QCOMPARE(group.currentLoopTime(), 800); + QCOMPARE(group.currentAnimation(), loopsForever); + QCOMPARE(sequence->currentLoopTime(), 500); + QCOMPARE(a1_s_o1->currentLoopTime(), 250); + QCOMPARE(a1_s_o2->currentLoopTime(), 250); + QCOMPARE(notTimeDriven->currentLoopTime(), 250); + QCOMPARE(loopsForever->currentLoopTime(), 50); + + loopsForever->stop(); // this should stop the group + + QCOMPARE(group.state(), QAnimationGroupJob::Stopped); + QCOMPARE(sequence->state(), QAnimationGroupJob::Stopped); + QCOMPARE(a1_s_o1->state(), QAnimationGroupJob::Stopped); + QCOMPARE(a1_s_o2->state(), QAnimationGroupJob::Stopped); + QCOMPARE(notTimeDriven->state(), QAnimationGroupJob::Stopped); + QCOMPARE(loopsForever->state(), QAnimationGroupJob::Stopped); +} + +void tst_QSequentialAnimationGroupJob::seekingForwards() +{ + + // sequence operating on same object/property + QAnimationGroupJob *sequence = new QSequentialAnimationGroupJob; + TestAnimation *a1_s_o1 = new TestAnimation; + TestAnimation *a2_s_o1 = new TestAnimation; + TestAnimation *a3_s_o1 = new TestAnimation; + a2_s_o1->setLoopCount(3); + sequence->appendAnimation(a1_s_o1); + sequence->appendAnimation(a2_s_o1); + sequence->appendAnimation(a3_s_o1); + + // sequence operating on different object/properties + QAnimationGroupJob *sequence2 = new QSequentialAnimationGroupJob; + TestAnimation *a1_s_o2 = new TestAnimation; + TestAnimation *a1_s_o3 = new TestAnimation; + sequence2->appendAnimation(a1_s_o2); + sequence2->appendAnimation(a1_s_o3); + + QSequentialAnimationGroupJob group; + group.appendAnimation(sequence); + group.appendAnimation(sequence2); + + // Current time = 1 + group.setCurrentTime(1); + QCOMPARE(group.state(), QAnimationGroupJob::Stopped); + QCOMPARE(sequence->state(), QAnimationGroupJob::Stopped); + QCOMPARE(a1_s_o1->state(), QAnimationGroupJob::Stopped); + QCOMPARE(sequence2->state(), QAnimationGroupJob::Stopped); + QCOMPARE(a1_s_o2->state(), QAnimationGroupJob::Stopped); + QCOMPARE(a1_s_o3->state(), QAnimationGroupJob::Stopped); + + QCOMPARE(group.currentLoopTime(), 1); + QCOMPARE(sequence->currentLoopTime(), 1); + QCOMPARE(a1_s_o1->currentLoopTime(), 1); + QCOMPARE(a2_s_o1->currentLoopTime(), 0); + QCOMPARE(a3_s_o1->currentLoopTime(), 0); + QCOMPARE(sequence2->currentLoopTime(), 0); + QCOMPARE(a1_s_o2->currentLoopTime(), 0); + QCOMPARE(a1_s_o3->currentLoopTime(), 0); + + // Current time = 1500 + group.setCurrentTime(1500); + QCOMPARE(group.currentLoopTime(), 1500); + QCOMPARE(sequence->currentLoopTime(), 1250); + QCOMPARE(a1_s_o1->currentLoopTime(), 250); + QCOMPARE(a2_s_o1->currentLoopTime(), 250); + QCOMPARE(a2_s_o1->currentLoop(), 2); + QCOMPARE(a3_s_o1->currentLoopTime(), 250); + QCOMPARE(sequence2->currentLoopTime(), 250); + QCOMPARE(a1_s_o2->currentLoopTime(), 250); + QCOMPARE(a1_s_o3->currentLoopTime(), 0); + + // this will restart the group + group.start(); + group.pause(); + QCOMPARE(group.state(), QAnimationGroupJob::Paused); + QCOMPARE(sequence->state(), QAnimationGroupJob::Paused); + QCOMPARE(a1_s_o1->state(), QAnimationGroupJob::Paused); + QCOMPARE(sequence2->state(), QAnimationGroupJob::Stopped); + QCOMPARE(a1_s_o2->state(), QAnimationGroupJob::Stopped); + QCOMPARE(a1_s_o3->state(), QAnimationGroupJob::Stopped); + + // Current time = 1750 + group.setCurrentTime(1750); + QCOMPARE(group.currentLoopTime(), 1750); + QCOMPARE(sequence->currentLoopTime(), 1250); + QCOMPARE(a1_s_o1->currentLoopTime(), 250); + QCOMPARE(a2_s_o1->currentLoopTime(), 250); + QCOMPARE(a2_s_o1->currentLoop(), 2); + QCOMPARE(a3_s_o1->currentLoopTime(), 250); + QCOMPARE(sequence2->currentLoopTime(), 500); + QCOMPARE(a1_s_o2->currentLoopTime(), 250); + QCOMPARE(a1_s_o3->currentLoopTime(), 250); +} + +void tst_QSequentialAnimationGroupJob::seekingBackwards() +{ + // sequence operating on same object/property + QAnimationGroupJob *sequence = new QSequentialAnimationGroupJob(); + TestAnimation *a1_s_o1 = new TestAnimation; + TestAnimation *a2_s_o1 = new TestAnimation; + TestAnimation *a3_s_o1 = new TestAnimation; + a2_s_o1->setLoopCount(3); + sequence->appendAnimation(a1_s_o1); + sequence->appendAnimation(a2_s_o1); + sequence->appendAnimation(a3_s_o1); + + // sequence operating on different object/properties + QAnimationGroupJob *sequence2 = new QSequentialAnimationGroupJob(); + TestAnimation *a1_s_o2 = new TestAnimation; + TestAnimation *a1_s_o3 = new TestAnimation; + sequence2->appendAnimation(a1_s_o2); + sequence2->appendAnimation(a1_s_o3); + + QSequentialAnimationGroupJob group; + group.appendAnimation(sequence); + group.appendAnimation(sequence2); + + group.start(); + + // Current time = 1600 + group.setCurrentTime(1600); + QCOMPARE(group.currentLoopTime(), 1600); + QCOMPARE(sequence->currentLoopTime(), 1250); + QCOMPARE(a1_s_o1->currentLoopTime(), 250); + QCOMPARE(a2_s_o1->currentLoopTime(), 250); + QCOMPARE(a2_s_o1->currentLoop(), 2); + QCOMPARE(a3_s_o1->currentLoopTime(), 250); + QCOMPARE(sequence2->currentLoopTime(), 350); + QCOMPARE(a1_s_o2->currentLoopTime(), 250); + QCOMPARE(a1_s_o3->currentLoopTime(), 100); + + QCOMPARE(group.state(), QAnimationGroupJob::Running); + QCOMPARE(sequence->state(), QAnimationGroupJob::Stopped); + QCOMPARE(a1_s_o1->state(), QAnimationGroupJob::Stopped); + QCOMPARE(sequence2->state(), QAnimationGroupJob::Running); + QCOMPARE(a1_s_o2->state(), QAnimationGroupJob::Stopped); + QCOMPARE(a1_s_o3->state(), QAnimationGroupJob::Running); + + // Seeking backwards, current time = 1 + group.setCurrentTime(1); + QCOMPARE(group.currentLoopTime(), 1); + QCOMPARE(sequence->currentLoopTime(), 1); + QCOMPARE(a1_s_o1->currentLoopTime(), 1); + + QEXPECT_FAIL("", "rewinding in nested groups is considered as a restart from the children," + "hence they don't reset from their current animation", Continue); + QCOMPARE(a2_s_o1->currentLoopTime(), 0); + QEXPECT_FAIL("", "rewinding in nested groups is considered as a restart from the children," + "hence they don't reset from their current animation", Continue); + QCOMPARE(a2_s_o1->currentLoop(), 0); + QEXPECT_FAIL("", "rewinding in nested groups is considered as a restart from the children," + "hence they don't reset from their current animation", Continue); + QCOMPARE(a3_s_o1->currentLoopTime(), 0); + QCOMPARE(sequence2->currentLoopTime(), 0); + QCOMPARE(a1_s_o2->currentLoopTime(), 0); + QCOMPARE(a1_s_o3->currentLoopTime(), 0); + + QCOMPARE(group.state(), QAnimationGroupJob::Running); + QCOMPARE(sequence->state(), QAnimationGroupJob::Running); + QCOMPARE(a1_s_o1->state(), QAnimationGroupJob::Running); + QCOMPARE(sequence2->state(), QAnimationGroupJob::Stopped); + QCOMPARE(a1_s_o2->state(), QAnimationGroupJob::Stopped); + QCOMPARE(a1_s_o3->state(), QAnimationGroupJob::Stopped); + + // Current time = 2000 + group.setCurrentTime(2000); + QCOMPARE(group.currentLoopTime(), 1750); + QCOMPARE(sequence->currentLoopTime(), 1250); + QCOMPARE(a1_s_o1->currentLoopTime(), 250); + QCOMPARE(a2_s_o1->currentLoopTime(), 250); + QCOMPARE(a2_s_o1->currentLoop(), 2); + QCOMPARE(a3_s_o1->currentLoopTime(), 250); + QCOMPARE(sequence2->currentLoopTime(), 500); + QCOMPARE(a1_s_o2->currentLoopTime(), 250); + QCOMPARE(a1_s_o3->currentLoopTime(), 250); + + QCOMPARE(group.state(), QAnimationGroupJob::Stopped); + QCOMPARE(sequence->state(), QAnimationGroupJob::Stopped); + QCOMPARE(a1_s_o1->state(), QAnimationGroupJob::Stopped); + QCOMPARE(sequence2->state(), QAnimationGroupJob::Stopped); + QCOMPARE(a1_s_o2->state(), QAnimationGroupJob::Stopped); + QCOMPARE(a1_s_o3->state(), QAnimationGroupJob::Stopped); +} + +typedef QList StateList; + +static bool compareStates(const StateChangeListener& spy, const StateList &expectedStates) +{ + bool equals = true; + for (int i = 0; i < qMax(expectedStates.count(), spy.count()); ++i) { + if (i >= spy.count() || i >= expectedStates.count()) { + equals = false; + break; + } + QAbstractAnimationJob::State st = expectedStates.at(i); + QAbstractAnimationJob::State actual = spy.states.at(i); + if (equals && actual != st) { + equals = false; + break; + } + } + if (!equals) { + const char *stateStrings[] = {"Stopped", "Paused", "Running"}; + QString e,a; + for (int i = 0; i < qMax(expectedStates.count(), spy.count()); ++i) { + if (i < expectedStates.count()) { + int exp = int(expectedStates.at(i)); + if (!e.isEmpty()) + e += QLatin1String(", "); + e += QLatin1String(stateStrings[exp]); + } + if (i < spy.count()) { + QAbstractAnimationJob::State actual = spy.states.at(i); + if (!a.isEmpty()) + a += QLatin1String(", "); + if (int(actual) >= 0 && int(actual) <= 2) { + a += QLatin1String(stateStrings[int(actual)]); + } else { + a += QLatin1String("NaN"); + } + } + + } + qDebug("\n" + "expected (count == %d): %s\n" + "actual (count == %d): %s\n", expectedStates.count(), qPrintable(e), spy.count(), qPrintable(a)); + } + return equals; +} + +void tst_QSequentialAnimationGroupJob::pauseAndResume() +{ + // sequence operating on same object/property + QAnimationGroupJob *sequence = new QSequentialAnimationGroupJob(); + TestAnimation *a1_s_o1 = new TestAnimation; + TestAnimation *a2_s_o1 = new TestAnimation; + TestAnimation *a3_s_o1 = new TestAnimation; + a2_s_o1->setLoopCount(2); + sequence->appendAnimation(a1_s_o1); + sequence->appendAnimation(a2_s_o1); + sequence->appendAnimation(a3_s_o1); + sequence->setLoopCount(2); + + StateChangeListener a1StateChangedSpy; + a1_s_o1->addAnimationChangeListener(&a1StateChangedSpy, QAbstractAnimationJob::StateChange); + StateChangeListener seqStateChangedSpy; + sequence->addAnimationChangeListener(&seqStateChangedSpy, QAbstractAnimationJob::StateChange); + + QSequentialAnimationGroupJob group; + group.appendAnimation(sequence); + + group.start(); + group.pause(); + + // Current time = 1751 + group.setCurrentTime(1751); + QCOMPARE(group.currentLoopTime(), 1751); + QCOMPARE(sequence->currentLoopTime(), 751); + QCOMPARE(sequence->currentLoop(), 1); + QCOMPARE(a1_s_o1->currentLoopTime(), 250); + QCOMPARE(a2_s_o1->currentLoopTime(), 250); + QCOMPARE(a2_s_o1->currentLoop(), 1); + QCOMPARE(a3_s_o1->currentLoop(), 0); + QCOMPARE(a3_s_o1->currentLoopTime(), 1); + + QCOMPARE(group.state(), QAnimationGroupJob::Paused); + QCOMPARE(sequence->state(), QAnimationGroupJob::Paused); + QCOMPARE(a1_s_o1->state(), QAnimationGroupJob::Stopped); + QCOMPARE(a2_s_o1->state(), QAnimationGroupJob::Stopped); + QCOMPARE(a3_s_o1->state(), QAnimationGroupJob::Paused); + + QCOMPARE(a1StateChangedSpy.count(), 5); // Running,Paused,Stopped,Running,Stopped + QCOMPARE(seqStateChangedSpy.count(), 2); // Running,Paused + + QVERIFY(compareStates(a1StateChangedSpy, (StateList() << QAbstractAnimationJob::Running + << QAbstractAnimationJob::Paused + << QAbstractAnimationJob::Stopped + << QAbstractAnimationJob::Running + << QAbstractAnimationJob::Stopped))); + + //### is this the same test as compareStates test above? + QCOMPARE(a1StateChangedSpy.states.at(0), QAnimationGroupJob::Running); + QCOMPARE(a1StateChangedSpy.states.at(1), QAnimationGroupJob::Paused); + QCOMPARE(a1StateChangedSpy.states.at(2), QAnimationGroupJob::Stopped); + QCOMPARE(a1StateChangedSpy.states.at(3), QAnimationGroupJob::Running); + QCOMPARE(a1StateChangedSpy.states.at(4), QAnimationGroupJob::Stopped); + + QCOMPARE(seqStateChangedSpy.states.at(0), QAnimationGroupJob::Running); + QCOMPARE(seqStateChangedSpy.states.at(1), QAnimationGroupJob::Paused); + + group.resume(); + + QCOMPARE(group.state(), QAnimationGroupJob::Running); + QCOMPARE(sequence->state(), QAnimationGroupJob::Running); + QCOMPARE(a1_s_o1->state(), QAnimationGroupJob::Stopped); + QCOMPARE(a2_s_o1->state(), QAnimationGroupJob::Stopped); + QCOMPARE(a3_s_o1->state(), QAnimationGroupJob::Running); + + QVERIFY(group.currentLoopTime() >= 1751); + QVERIFY(sequence->currentLoopTime() >= 751); + QCOMPARE(sequence->currentLoop(), 1); + QCOMPARE(a1_s_o1->currentLoopTime(), 250); + QCOMPARE(a2_s_o1->currentLoopTime(), 250); + QCOMPARE(a2_s_o1->currentLoop(), 1); + QCOMPARE(a3_s_o1->currentLoop(), 0); + QVERIFY(a3_s_o1->currentLoopTime() >= 1); + + QCOMPARE(seqStateChangedSpy.count(), 3); // Running,Paused,Running + QCOMPARE(seqStateChangedSpy.states.at(2), QAnimationGroupJob::Running); + + group.pause(); + + QCOMPARE(group.state(), QAnimationGroupJob::Paused); + QCOMPARE(sequence->state(), QAnimationGroupJob::Paused); + QCOMPARE(a1_s_o1->state(), QAnimationGroupJob::Stopped); + QCOMPARE(a2_s_o1->state(), QAnimationGroupJob::Stopped); + QCOMPARE(a3_s_o1->state(), QAnimationGroupJob::Paused); + + QVERIFY(group.currentLoopTime() >= 1751); + QVERIFY(sequence->currentLoopTime() >= 751); + QCOMPARE(sequence->currentLoop(), 1); + QCOMPARE(a1_s_o1->currentLoopTime(), 250); + QCOMPARE(a2_s_o1->currentLoopTime(), 250); + QCOMPARE(a2_s_o1->currentLoop(), 1); + QCOMPARE(a3_s_o1->currentLoop(), 0); + QVERIFY(a3_s_o1->currentLoopTime() >= 1); + + QCOMPARE(seqStateChangedSpy.count(), 4); // Running,Paused,Running,Paused + QCOMPARE(seqStateChangedSpy.states.at(3), QAnimationGroupJob::Paused); + + group.stop(); + + QCOMPARE(seqStateChangedSpy.count(), 5); // Running,Paused,Running,Paused,Stopped + QCOMPARE(seqStateChangedSpy.states.at(4), QAnimationGroupJob::Stopped); +} + +void tst_QSequentialAnimationGroupJob::restart() +{ + // originally was sequence operating on same object/property + QAnimationGroupJob *sequence = new QSequentialAnimationGroupJob(); + //### no equivilant signal + //QSignalSpy seqCurrentAnimChangedSpy(sequence, SIGNAL(currentAnimationChanged(QAbstractAnimationJob*))); + + StateChangeListener seqStateChangedSpy; + sequence->addAnimationChangeListener(&seqStateChangedSpy, QAbstractAnimationJob::StateChange); + + TestAnimation *anims[3]; + StateChangeListener *animsStateChanged[3]; + + for (int i = 0; i < 3; i++) { + anims[i] = new TestAnimation(100); + animsStateChanged[i] = new StateChangeListener; + anims[i]->addAnimationChangeListener(animsStateChanged[i], QAbstractAnimationJob::StateChange); + } + + anims[1]->setLoopCount(2); + sequence->appendAnimation(anims[0]); + sequence->appendAnimation(anims[1]); + sequence->appendAnimation(anims[2]); + sequence->setLoopCount(2); + + QSequentialAnimationGroupJob group; + group.appendAnimation(sequence); + + group.start(); + + QTest::qWait(500); + + QCOMPARE(group.state(), QAnimationGroupJob::Running); + + QTest::qWait(300); + QTRY_COMPARE(group.state(), QAnimationGroupJob::Stopped); + + for (int i = 0; i < 3; i++) { + QCOMPARE(animsStateChanged[i]->count(), 4); + QCOMPARE(animsStateChanged[i]->states.at(0), QAnimationGroupJob::Running); + QCOMPARE(animsStateChanged[i]->states.at(1), QAnimationGroupJob::Stopped); + QCOMPARE(animsStateChanged[i]->states.at(2), QAnimationGroupJob::Running); + QCOMPARE(animsStateChanged[i]->states.at(3), QAnimationGroupJob::Stopped); + } + + QCOMPARE(seqStateChangedSpy.count(), 2); + QCOMPARE(seqStateChangedSpy.states.at(0), QAnimationGroupJob::Running); + QCOMPARE(seqStateChangedSpy.states.at(1), QAnimationGroupJob::Stopped); + + //QCOMPARE(seqCurrentAnimChangedSpy.count(), 6); + //for(int i=0; i(anims[i%3]), qVariantValue(seqCurrentAnimChangedSpy.at(i).at(0))); + + group.start(); + + QCOMPARE(animsStateChanged[0]->count(), 5); + QCOMPARE(animsStateChanged[1]->count(), 4); + QCOMPARE(animsStateChanged[2]->count(), 4); + QCOMPARE(seqStateChangedSpy.count(), 3); +} + +void tst_QSequentialAnimationGroupJob::looping() +{ + // originally was sequence operating on same object/property + QSequentialAnimationGroupJob *sequence = new QSequentialAnimationGroupJob(); + QAbstractAnimationJob *a1_s_o1 = new TestAnimation; + QAbstractAnimationJob *a2_s_o1 = new TestAnimation; + QAbstractAnimationJob *a3_s_o1 = new TestAnimation; + + StateChangeListener a1Spy; + a1_s_o1->addAnimationChangeListener(&a1Spy, QAbstractAnimationJob::StateChange); + StateChangeListener a2Spy; + a2_s_o1->addAnimationChangeListener(&a2Spy, QAbstractAnimationJob::StateChange); + StateChangeListener a3Spy; + a3_s_o1->addAnimationChangeListener(&a3Spy, QAbstractAnimationJob::StateChange); + StateChangeListener seqSpy; + sequence->addAnimationChangeListener(&seqSpy, QAbstractAnimationJob::StateChange); + + a2_s_o1->setLoopCount(2); + sequence->appendAnimation(a1_s_o1); + sequence->appendAnimation(a2_s_o1); + sequence->appendAnimation(a3_s_o1); + sequence->setLoopCount(2); + + QSequentialAnimationGroupJob group; + StateChangeListener groupSpy; + group.addAnimationChangeListener(&groupSpy, QAbstractAnimationJob::StateChange); + + group.appendAnimation(sequence); + group.setLoopCount(2); + + group.start(); + group.pause(); + + // Current time = 1750 + group.setCurrentTime(1750); + QCOMPARE(group.currentLoopTime(), 1750); + QCOMPARE(sequence->currentLoopTime(), 750); + QCOMPARE(sequence->currentLoop(), 1); + QCOMPARE(a1_s_o1->currentLoopTime(), 250); + QCOMPARE(a2_s_o1->currentLoopTime(), 250); + QCOMPARE(a2_s_o1->currentLoop(), 1); + // this animation is at the beginning because it is the current one inside sequence + QCOMPARE(a3_s_o1->currentLoop(), 0); + QCOMPARE(a3_s_o1->currentLoopTime(), 0); + QCOMPARE(sequence->currentAnimation(), a3_s_o1); + + QCOMPARE(group.state(), QAnimationGroupJob::Paused); + QCOMPARE(sequence->state(), QAnimationGroupJob::Paused); + QCOMPARE(a1_s_o1->state(), QAnimationGroupJob::Stopped); + QCOMPARE(a2_s_o1->state(), QAnimationGroupJob::Stopped); + QCOMPARE(a3_s_o1->state(), QAnimationGroupJob::Paused); + + QCOMPARE(a1Spy.count(), 5); // Running,Paused,Stopped,Running,Stopped + QVERIFY(compareStates(a1Spy, (StateList() << QAbstractAnimationJob::Running + << QAbstractAnimationJob::Paused + << QAbstractAnimationJob::Stopped + << QAbstractAnimationJob::Running + << QAbstractAnimationJob::Stopped))); + + QCOMPARE(a2Spy.count(), 4); // Running,Stopped,Running,Stopped + QVERIFY(compareStates(a3Spy, (StateList() << QAbstractAnimationJob::Running + << QAbstractAnimationJob::Stopped + << QAbstractAnimationJob::Running + << QAbstractAnimationJob::Paused))); + + QCOMPARE(seqSpy.count(), 2); // Running,Paused + QCOMPARE(groupSpy.count(), 2); // Running,Paused + + // Looping, current time = duration + 1 + group.setCurrentTime(group.duration() + 1); + QCOMPARE(group.currentLoopTime(), 1); + QCOMPARE(group.currentLoop(), 1); + QCOMPARE(sequence->currentLoopTime(), 1); + QCOMPARE(sequence->currentLoop(), 0); + QCOMPARE(a1_s_o1->currentLoopTime(), 1); + QCOMPARE(a2_s_o1->currentLoopTime(), 250); + QCOMPARE(a2_s_o1->currentLoop(), 1); + // this animation is at the end because it was run on the previous loop + QCOMPARE(a3_s_o1->currentLoop(), 0); + QCOMPARE(a3_s_o1->currentLoopTime(), 250); + + QCOMPARE(group.state(), QAnimationGroupJob::Paused); + QCOMPARE(sequence->state(), QAnimationGroupJob::Paused); + QCOMPARE(a1_s_o1->state(), QAnimationGroupJob::Paused); + QCOMPARE(a2_s_o1->state(), QAnimationGroupJob::Stopped); + QCOMPARE(a3_s_o1->state(), QAnimationGroupJob::Stopped); + + QCOMPARE(a1Spy.count(), 7); // Running,Paused,Stopped,Running,Stopped,Running,Stopped + QCOMPARE(a2Spy.count(), 4); // Running, Stopped, Running, Stopped + QVERIFY(compareStates(a3Spy, (StateList() << QAbstractAnimationJob::Running + << QAbstractAnimationJob::Stopped + << QAbstractAnimationJob::Running + << QAbstractAnimationJob::Paused + << QAbstractAnimationJob::Stopped))); + QVERIFY(compareStates(seqSpy, (StateList() << QAbstractAnimationJob::Running + << QAbstractAnimationJob::Paused + << QAbstractAnimationJob::Stopped + << QAbstractAnimationJob::Running + << QAbstractAnimationJob::Paused))); + QCOMPARE(groupSpy.count(), 2); + + //cleanup + a1_s_o1->removeAnimationChangeListener(&a1Spy, QAbstractAnimationJob::StateChange); + a2_s_o1->removeAnimationChangeListener(&a2Spy, QAbstractAnimationJob::StateChange); + a3_s_o1->removeAnimationChangeListener(&a3Spy, QAbstractAnimationJob::StateChange); + sequence->removeAnimationChangeListener(&seqSpy, QAbstractAnimationJob::StateChange); + group.removeAnimationChangeListener(&groupSpy, QAbstractAnimationJob::StateChange); +} + +void tst_QSequentialAnimationGroupJob::startDelay() +{ + QSequentialAnimationGroupJob group; + group.appendAnimation(new QPauseAnimationJob(250)); + group.appendAnimation(new QPauseAnimationJob(125)); + QCOMPARE(group.totalDuration(), 375); + + group.start(); + QCOMPARE(group.state(), QAnimationGroupJob::Running); + + QTest::qWait(500); + + QTRY_COMPARE(group.state(), QAnimationGroupJob::Stopped); + QVERIFY(group.currentLoopTime() == 375); +} + +void tst_QSequentialAnimationGroupJob::clearGroup() +{ + QSequentialAnimationGroupJob group; + + static const int animationCount = 20; + + for (int i = 0; i < animationCount/2; ++i) { + QSequentialAnimationGroupJob *subGroup = new QSequentialAnimationGroupJob; + group.appendAnimation(subGroup); + group.appendAnimation(new QPauseAnimationJob(100)); + subGroup->appendAnimation(new QPauseAnimationJob(10)); + } + + int count = 0; + for (QAbstractAnimationJob *anim = group.firstChild(); anim; anim = anim->nextSibling()) + ++count; + QCOMPARE(count, animationCount); + + group.clear(); + + QVERIFY(!group.firstChild() && !group.lastChild()); + QCOMPARE(group.currentLoopTime(), 0); +} + +void tst_QSequentialAnimationGroupJob::groupWithZeroDurationAnimations() +{ + QSequentialAnimationGroupJob group; + + TestValueAnimation *a1 = new TestValueAnimation(0); + a1->start = 42; + a1->end = 43; + group.appendAnimation(a1); + + //this should just run fine and change nothing + group.setCurrentTime(0); + QCOMPARE(group.currentAnimation(), static_cast(a1)); + + TestValueAnimation *a2 = new TestValueAnimation(500); + a2->start = 13; + a2->end = 31; + group.appendAnimation(a2); + + TestValueAnimation *a3 = new TestValueAnimation(0); + a3->start = 43; + a3->end = 44; + group.appendAnimation(a3); + + TestValueAnimation *a4 = new TestValueAnimation(250); + a4->start = 13; + a4->end = 75; + group.appendAnimation(a4); + + TestValueAnimation *a5 = new TestValueAnimation(0); + a5->start = 42; + a5->end = 12; + group.appendAnimation(a5); + + QCOMPARE((int)a1->value, 43); //### is this actually the behavior we want? + QCOMPARE((int)a2->value, 0); + QCOMPARE((int)a3->value, 0); + QCOMPARE((int)a4->value, 0); + QCOMPARE((int)a5->value, 0); + + group.start(); + + QCOMPARE((int)a1->value, 43); //### is this actually the behavior we want? + QCOMPARE((int)a2->value, 13); + QCOMPARE((int)a3->value, 0); + QCOMPARE((int)a4->value, 0); + QCOMPARE((int)a5->value, 0); + + QTest::qWait(100); + + QCOMPARE((int)a1->value, 43); + QVERIFY(a2->value > 13 && a2->value < 31); + QCOMPARE((int)a3->value, 0); + QCOMPARE((int)a4->value, 0); + QCOMPARE((int)a5->value, 0); + + QTest::qWait(500); + + QTRY_COMPARE((int)a3->value, 44); + QCOMPARE((int)a1->value, 43); + QCOMPARE((int)a2->value, 31); + //QCOMPARE((int)a4->value, 36); + QCOMPARE((int)a5->value, 0); + QCOMPARE(a1->state(), QAnimationGroupJob::Stopped); + QCOMPARE(a2->state(), QAnimationGroupJob::Stopped); + QCOMPARE(a3->state(), QAnimationGroupJob::Stopped); + QCOMPARE(a4->state(), QAnimationGroupJob::Running); + QCOMPARE(a5->state(), QAnimationGroupJob::Stopped); + QCOMPARE(group.state(), QAnimationGroupJob::Running); + QTest::qWait(500); + + QTRY_COMPARE(group.state(), QAnimationGroupJob::Stopped); + QCOMPARE((int)a1->value, 43); + QCOMPARE((int)a2->value, 31); + QCOMPARE((int)a3->value, 44); + QCOMPARE((int)a4->value, 75); + QCOMPARE((int)a5->value, 12); + QCOMPARE(a1->state(), QAnimationGroupJob::Stopped); + QCOMPARE(a2->state(), QAnimationGroupJob::Stopped); + QCOMPARE(a3->state(), QAnimationGroupJob::Stopped); + QCOMPARE(a4->state(), QAnimationGroupJob::Stopped); + QCOMPARE(a5->state(), QAnimationGroupJob::Stopped); +} + +void tst_QSequentialAnimationGroupJob::propagateGroupUpdateToChildren() +{ + // this test verifies if group state changes are updating its children correctly + QSequentialAnimationGroupJob group; + + TestAnimation anim1(100); + TestAnimation anim2(200); + + QCOMPARE(group.state(), QAnimationGroupJob::Stopped); + QCOMPARE(anim1.state(), QAnimationGroupJob::Stopped); + QCOMPARE(anim2.state(), QAnimationGroupJob::Stopped); + + group.appendAnimation(&anim1); + group.appendAnimation(&anim2); + + group.start(); + + QCOMPARE(group.state(), QAnimationGroupJob::Running); + QCOMPARE(anim1.state(), QAnimationGroupJob::Running); + QCOMPARE(anim2.state(), QAnimationGroupJob::Stopped); + + group.pause(); + + QCOMPARE(group.state(), QAnimationGroupJob::Paused); + QCOMPARE(anim1.state(), QAnimationGroupJob::Paused); + QCOMPARE(anim2.state(), QAnimationGroupJob::Stopped); + + group.stop(); + + QCOMPARE(group.state(), QAnimationGroupJob::Stopped); + QCOMPARE(anim1.state(), QAnimationGroupJob::Stopped); + QCOMPARE(anim2.state(), QAnimationGroupJob::Stopped); +} + +void tst_QSequentialAnimationGroupJob::updateChildrenWithRunningGroup() +{ + // assert that its possible to modify a child's state directly while their group is running + QSequentialAnimationGroupJob group; + + TestAnimation anim(200); + + StateChangeListener groupStateChangedSpy; + group.addAnimationChangeListener(&groupStateChangedSpy, QAbstractAnimationJob::StateChange); + StateChangeListener childStateChangedSpy; + anim.addAnimationChangeListener(&childStateChangedSpy, QAbstractAnimationJob::StateChange); + + QCOMPARE(groupStateChangedSpy.count(), 0); + QCOMPARE(childStateChangedSpy.count(), 0); + QCOMPARE(group.state(), QAnimationGroupJob::Stopped); + QCOMPARE(anim.state(), QAnimationGroupJob::Stopped); + + group.appendAnimation(&anim); + + group.start(); + + QCOMPARE(group.state(), QAnimationGroupJob::Running); + QCOMPARE(anim.state(), QAnimationGroupJob::Running); + + QCOMPARE(groupStateChangedSpy.count(), 1); + QCOMPARE(childStateChangedSpy.count(), 1); + + QCOMPARE(groupStateChangedSpy.states.at(0), QAnimationGroupJob::Running); + QCOMPARE(childStateChangedSpy.states.at(0), QAnimationGroupJob::Running); + + // starting directly a running child will not have any effect + anim.start(); + + QCOMPARE(groupStateChangedSpy.count(), 1); + QCOMPARE(childStateChangedSpy.count(), 1); + + anim.pause(); + + QCOMPARE(group.state(), QAnimationGroupJob::Running); + QCOMPARE(anim.state(), QAnimationGroupJob::Paused); + + // in the animation stops directly, the group will still be running + anim.stop(); + + QCOMPARE(group.state(), QAnimationGroupJob::Running); + QCOMPARE(anim.state(), QAnimationGroupJob::Stopped); + + //cleanup + group.removeAnimationChangeListener(&groupStateChangedSpy, QAbstractAnimationJob::StateChange); + anim.removeAnimationChangeListener(&childStateChangedSpy, QAbstractAnimationJob::StateChange); +} + +void tst_QSequentialAnimationGroupJob::deleteChildrenWithRunningGroup() +{ + // test if children can be activated when their group is stopped + QSequentialAnimationGroupJob group; + + TestAnimation *anim1 = new TestAnimation(200); + group.appendAnimation(anim1); + + QCOMPARE(group.duration(), anim1->duration()); + + group.start(); + QCOMPARE(group.state(), QAnimationGroupJob::Running); + QCOMPARE(anim1->state(), QAnimationGroupJob::Running); + + QTest::qWait(100); + QTRY_VERIFY(group.currentLoopTime() > 0); + + delete anim1; + QVERIFY(!group.firstChild()); + QCOMPARE(group.duration(), 0); + QCOMPARE(group.state(), QAnimationGroupJob::Stopped); + QCOMPARE(group.currentLoopTime(), 0); //that's the invariant +} + +void tst_QSequentialAnimationGroupJob::startChildrenWithStoppedGroup() +{ + // test if children can be activated when their group is stopped + QSequentialAnimationGroupJob group; + + TestAnimation anim1(200); + TestAnimation anim2(200); + + QCOMPARE(group.state(), QAnimationGroupJob::Stopped); + QCOMPARE(anim1.state(), QAnimationGroupJob::Stopped); + QCOMPARE(anim2.state(), QAnimationGroupJob::Stopped); + + group.appendAnimation(&anim1); + group.appendAnimation(&anim2); + + group.stop(); + + QCOMPARE(group.state(), QAnimationGroupJob::Stopped); + QCOMPARE(anim1.state(), QAnimationGroupJob::Stopped); + QCOMPARE(anim2.state(), QAnimationGroupJob::Stopped); + + anim1.start(); + anim2.start(); + anim2.pause(); + + QCOMPARE(group.state(), QAnimationGroupJob::Stopped); + QCOMPARE(anim1.state(), QAnimationGroupJob::Running); + QCOMPARE(anim2.state(), QAnimationGroupJob::Paused); +} + +void tst_QSequentialAnimationGroupJob::stopGroupWithRunningChild() +{ + // children that started independently will not be affected by a group stop + QSequentialAnimationGroupJob group; + + TestAnimation anim1(200); + TestAnimation anim2(200); + + QCOMPARE(group.state(), QAnimationGroupJob::Stopped); + QCOMPARE(anim1.state(), QAnimationGroupJob::Stopped); + QCOMPARE(anim2.state(), QAnimationGroupJob::Stopped); + + group.appendAnimation(&anim1); + group.appendAnimation(&anim2); + + anim1.start(); + anim2.start(); + anim2.pause(); + + QCOMPARE(group.state(), QAnimationGroupJob::Stopped); + QCOMPARE(anim1.state(), QAnimationGroupJob::Running); + QCOMPARE(anim2.state(), QAnimationGroupJob::Paused); + + group.stop(); + + QCOMPARE(group.state(), QAnimationGroupJob::Stopped); + QCOMPARE(anim1.state(), QAnimationGroupJob::Running); + QCOMPARE(anim2.state(), QAnimationGroupJob::Paused); + + anim1.stop(); + anim2.stop(); + + QCOMPARE(group.state(), QAnimationGroupJob::Stopped); + QCOMPARE(anim1.state(), QAnimationGroupJob::Stopped); + QCOMPARE(anim2.state(), QAnimationGroupJob::Stopped); +} + +void tst_QSequentialAnimationGroupJob::startGroupWithRunningChild() +{ + // as the group has precedence over its children, starting a group will restart all the children + QSequentialAnimationGroupJob group; + + TestAnimation *anim1 = new TestAnimation(200); + TestAnimation *anim2 = new TestAnimation(200); + + StateChangeListener stateChangedSpy1; + anim1->addAnimationChangeListener(&stateChangedSpy1, QAbstractAnimationJob::StateChange); + StateChangeListener stateChangedSpy2; + anim2->addAnimationChangeListener(&stateChangedSpy2, QAbstractAnimationJob::StateChange); + + QCOMPARE(stateChangedSpy1.count(), 0); + QCOMPARE(stateChangedSpy2.count(), 0); + QCOMPARE(group.state(), QAnimationGroupJob::Stopped); + QCOMPARE(anim1->state(), QAnimationGroupJob::Stopped); + QCOMPARE(anim2->state(), QAnimationGroupJob::Stopped); + + group.appendAnimation(anim1); + group.appendAnimation(anim2); + + anim1->start(); + anim2->start(); + anim2->pause(); + + QVERIFY(compareStates(stateChangedSpy1, (StateList() << QAbstractAnimationJob::Running))); + + QVERIFY(compareStates(stateChangedSpy2, (StateList() << QAbstractAnimationJob::Running + << QAbstractAnimationJob::Paused))); + + QCOMPARE(group.state(), QAnimationGroupJob::Stopped); + QCOMPARE(anim1->state(), QAnimationGroupJob::Running); + QCOMPARE(anim2->state(), QAnimationGroupJob::Paused); + + group.start(); + + QVERIFY(compareStates(stateChangedSpy1, (StateList() << QAbstractAnimationJob::Running + << QAbstractAnimationJob::Stopped + << QAbstractAnimationJob::Running))); + QVERIFY(compareStates(stateChangedSpy2, (StateList() << QAbstractAnimationJob::Running + << QAbstractAnimationJob::Paused))); + + QCOMPARE(group.state(), QAnimationGroupJob::Running); + QCOMPARE(anim1->state(), QAnimationGroupJob::Running); + QCOMPARE(anim2->state(), QAnimationGroupJob::Paused); + + QTest::qWait(300); + + QCOMPARE(group.state(), QAnimationGroupJob::Running); + QCOMPARE(anim1->state(), QAnimationGroupJob::Stopped); + QCOMPARE(anim2->state(), QAnimationGroupJob::Running); + + QCOMPARE(stateChangedSpy2.count(), 4); + QCOMPARE(stateChangedSpy2.states.at(2), QAnimationGroupJob::Stopped); + QCOMPARE(stateChangedSpy2.states.at(3), QAnimationGroupJob::Running); + + group.stop(); + + QCOMPARE(group.state(), QAnimationGroupJob::Stopped); + QCOMPARE(anim1->state(), QAnimationGroupJob::Stopped); + QCOMPARE(anim2->state(), QAnimationGroupJob::Stopped); + + anim1->removeAnimationChangeListener(&stateChangedSpy1, QAbstractAnimationJob::StateChange); + anim2->removeAnimationChangeListener(&stateChangedSpy2, QAbstractAnimationJob::StateChange); +} + +void tst_QSequentialAnimationGroupJob::zeroDurationAnimation() +{ + QSequentialAnimationGroupJob group; + + TestAnimation *anim1 = new TestAnimation(0); + TestAnimation *anim2 = new TestAnimation(100); + TestValueAnimation *anim3 = new TestValueAnimation(0); + anim3->end = 100; + + StateChangeListener stateChangedSpy; + anim1->addAnimationChangeListener(&stateChangedSpy, QAbstractAnimationJob::StateChange); + + group.appendAnimation(anim1); + group.appendAnimation(anim2); + group.appendAnimation(anim3); + group.setLoopCount(2); + group.start(); + + QCOMPARE(stateChangedSpy.count(), 2); + QCOMPARE(stateChangedSpy.states.at(0), QAnimationGroupJob::Running); + QCOMPARE(stateChangedSpy.states.at(1), QAnimationGroupJob::Stopped); + + QCOMPARE(anim1->state(), QAnimationGroupJob::Stopped); + QCOMPARE(anim2->state(), QAnimationGroupJob::Running); + QCOMPARE(group.state(), QAnimationGroupJob::Running); + + //now let's try to seek to the next loop + group.setCurrentTime(group.duration() + 1); + QCOMPARE(anim1->state(), QAnimationGroupJob::Stopped); + QCOMPARE(anim2->state(), QAnimationGroupJob::Running); + QCOMPARE(anim3->state(), QAnimationGroupJob::Stopped); + QCOMPARE(group.state(), QAnimationGroupJob::Running); + //TODO: test that anim3 was run + QCOMPARE(anim3->value, qreal(100)); //anim3 should have been run + + anim1->removeAnimationChangeListener(&stateChangedSpy, QAbstractAnimationJob::StateChange); +} + +void tst_QSequentialAnimationGroupJob::stopUncontrolledAnimations() +{ + QSequentialAnimationGroupJob group; + + UncontrolledAnimation notTimeDriven; + QCOMPARE(notTimeDriven.totalDuration(), -1); + + TestAnimation loopsForever(100); + loopsForever.setLoopCount(-1); + + group.appendAnimation(¬TimeDriven); + group.appendAnimation(&loopsForever); + + group.start(); + + QCOMPARE(group.state(), QAnimationGroupJob::Running); + QCOMPARE(notTimeDriven.state(), QAnimationGroupJob::Running); + QCOMPARE(loopsForever.state(), QAnimationGroupJob::Stopped); + + notTimeDriven.stop(); + + QCOMPARE(group.state(), QAnimationGroupJob::Running); + QCOMPARE(notTimeDriven.state(), QAnimationGroupJob::Stopped); + QCOMPARE(loopsForever.state(), QAnimationGroupJob::Running); + + loopsForever.stop(); + + QCOMPARE(group.state(), QAnimationGroupJob::Stopped); + QCOMPARE(notTimeDriven.state(), QAnimationGroupJob::Stopped); + QCOMPARE(loopsForever.state(), QAnimationGroupJob::Stopped); +} + +void tst_QSequentialAnimationGroupJob::finishWithUncontrolledAnimation() +{ + //1st case: + //first we test a group with one uncontrolled animation + QSequentialAnimationGroupJob group; + UncontrolledAnimation notTimeDriven; + group.appendAnimation(¬TimeDriven); + FinishedListener spy; + group.addAnimationChangeListener(&spy, QAbstractAnimationJob::Completion); + + group.start(); + QCOMPARE(group.state(), QAnimationGroupJob::Running); + QCOMPARE(notTimeDriven.state(), QAnimationGroupJob::Running); + QCOMPARE(group.currentLoopTime(), 0); + QCOMPARE(notTimeDriven.currentLoopTime(), 0); + + QTest::qWait(300); //wait for the end of notTimeDriven + QTRY_COMPARE(notTimeDriven.state(), QAnimationGroupJob::Stopped); + const int actualDuration = notTimeDriven.currentLoopTime(); + QCOMPARE(group.state(), QAnimationGroupJob::Stopped); + QCOMPARE(group.currentLoopTime(), actualDuration); + QCOMPARE(spy.count(), 1); + + //2nd case: + // lets make sure the seeking will work again + spy.clear(); + TestAnimation anim; + group.appendAnimation(&anim); + StateChangeListener animStateChangedSpy; + anim.addAnimationChangeListener(&animStateChangedSpy, QAbstractAnimationJob::StateChange); + + group.setCurrentTime(300); + QCOMPARE(group.state(), QAnimationGroupJob::Stopped); + QCOMPARE(notTimeDriven.currentLoopTime(), actualDuration); + QCOMPARE(group.currentAnimation(), static_cast(&anim)); + + //3rd case: + //now let's add a perfectly defined animation at the end + QCOMPARE(animStateChangedSpy.count(), 0); + group.start(); + QCOMPARE(group.state(), QAnimationGroupJob::Running); + QCOMPARE(notTimeDriven.state(), QAnimationGroupJob::Running); + QCOMPARE(group.currentLoopTime(), 0); + QCOMPARE(notTimeDriven.currentLoopTime(), 0); + + QCOMPARE(animStateChangedSpy.count(), 0); + + QTest::qWait(300); //wait for the end of notTimeDriven + QTRY_COMPARE(notTimeDriven.state(), QAnimationGroupJob::Stopped); + QCOMPARE(group.state(), QAnimationGroupJob::Running); + QCOMPARE(anim.state(), QAnimationGroupJob::Running); + QCOMPARE(group.currentAnimation(), static_cast(&anim)); + QCOMPARE(animStateChangedSpy.count(), 1); + QTest::qWait(300); //wait for the end of anim + + QTRY_COMPARE(anim.state(), QAnimationGroupJob::Stopped); + QCOMPARE(anim.currentLoopTime(), anim.duration()); + + //we should simply be at the end + QCOMPARE(spy.count(), 1); + QCOMPARE(animStateChangedSpy.count(), 2); + QCOMPARE(group.currentLoopTime(), notTimeDriven.currentLoopTime() + anim.currentLoopTime()); + + //cleanup + group.removeAnimationChangeListener(&spy, QAbstractAnimationJob::Completion); + anim.removeAnimationChangeListener(&animStateChangedSpy, QAbstractAnimationJob::StateChange); +} + +void tst_QSequentialAnimationGroupJob::addRemoveAnimation() +{ + //this test is specific to the sequential animation group + QSequentialAnimationGroupJob group; + + QCOMPARE(group.duration(), 0); + QCOMPARE(group.currentLoopTime(), 0); + QAbstractAnimationJob *anim1 = new TestAnimation; + group.appendAnimation(anim1); + QCOMPARE(group.duration(), 250); + QCOMPARE(group.currentLoopTime(), 0); + QCOMPARE(group.currentAnimation(), anim1); + + //let's append an animation + QAbstractAnimationJob *anim2 = new TestAnimation; + group.appendAnimation(anim2); + QCOMPARE(group.duration(), 500); + QCOMPARE(group.currentLoopTime(), 0); + QCOMPARE(group.currentAnimation(), anim1); + + //let's prepend an animation + QAbstractAnimationJob *anim0 = new TestAnimation; + group.prependAnimation(anim0); + QCOMPARE(group.duration(), 750); + QCOMPARE(group.currentLoopTime(), 0); + QCOMPARE(group.currentAnimation(), anim0); //anim0 has become the new currentAnimation + + group.setCurrentTime(300); //anim0 | anim1 | anim2 + QCOMPARE(group.currentLoopTime(), 300); + QCOMPARE(group.currentAnimation(), anim1); + QCOMPARE(anim1->currentLoopTime(), 50); + + group.removeAnimation(anim0); //anim1 | anim2 + QCOMPARE(group.currentLoopTime(), 50); + QCOMPARE(group.currentAnimation(), anim1); + QCOMPARE(anim1->currentLoopTime(), 50); + + group.setCurrentTime(0); + group.prependAnimation(anim0); //anim0 | anim1 | anim2 + group.setCurrentTime(300); + QCOMPARE(group.currentLoopTime(), 300); + QCOMPARE(group.currentAnimation(), anim1); + QCOMPARE(anim1->currentLoopTime(), 50); + + group.removeAnimation(anim1); //anim0 | anim2 + QCOMPARE(group.currentLoopTime(), 250); + QCOMPARE(group.currentAnimation(), anim2); + QCOMPARE(anim0->currentLoopTime(), 250); +} + +void tst_QSequentialAnimationGroupJob::currentAnimation() +{ + QSequentialAnimationGroupJob group; + QVERIFY(group.currentAnimation() == 0); + + TestAnimation anim(0); + group.appendAnimation(&anim); + QCOMPARE(group.currentAnimation(), static_cast(&anim)); +} + +void tst_QSequentialAnimationGroupJob::currentAnimationWithZeroDuration() +{ + QSequentialAnimationGroupJob group; + QVERIFY(group.currentAnimation() == 0); + + TestAnimation zero1(0); + TestAnimation zero2(0); + + TestAnimation anim; + + TestAnimation zero3(0); + TestAnimation zero4(0); + + group.appendAnimation(&zero1); + group.appendAnimation(&zero2); + group.appendAnimation(&anim); + group.appendAnimation(&zero3); + group.appendAnimation(&zero4); + + QCOMPARE(group.currentAnimation(), static_cast(&zero1)); + + group.setCurrentTime(0); + QCOMPARE(group.currentAnimation(), static_cast(&anim)); + + group.setCurrentTime(group.duration()); + QCOMPARE(group.currentAnimation(), static_cast(&zero4)); + + group.setDirection(QAbstractAnimationJob::Backward); + + group.setCurrentTime(0); + QCOMPARE(group.currentAnimation(), static_cast(&zero1)); + + group.setCurrentTime(group.duration()); + QCOMPARE(group.currentAnimation(), static_cast(&anim)); +} + +void tst_QSequentialAnimationGroupJob::insertAnimation() +{ + QSequentialAnimationGroupJob group; + group.setLoopCount(2); + TestAnimation *anim = new TestAnimation; + group.appendAnimation(anim); + QCOMPARE(group.duration(), anim->duration()); + group.setCurrentTime(300); + QCOMPARE(group.currentLoop(), 1); + + //this will crash if the sequential group calls duration on the created animation + group.appendAnimation(new TestAnimation); +} + +class ClearFinishedListener: public QAnimationJobChangeListener +{ +public: + ClearFinishedListener(QSequentialAnimationGroupJob *g) : group(g) {} + + virtual void animationFinished(QAbstractAnimationJob *) + { + group->clear(); + } + + QSequentialAnimationGroupJob *group; +}; + +class RefillFinishedListener: public QAnimationJobChangeListener +{ +public: + RefillFinishedListener(QSequentialAnimationGroupJob *g) : group(g) {} + + virtual void animationFinished(QAbstractAnimationJob *) + { + group->stop(); + group->clear(); + group->appendAnimation(new TestAnimation); + group->start(); + } + + QSequentialAnimationGroupJob *group; +}; + +void tst_QSequentialAnimationGroupJob::clear() +{ + QSKIP("deleting an animation when finished is not currently supported"); + QSequentialAnimationGroupJob group; + TestAnimation *anim1 = new TestAnimation; + group.appendAnimation(anim1); + ClearFinishedListener clearListener(&group); + anim1->addAnimationChangeListener(&clearListener, QAbstractAnimationJob::Completion); + + TestAnimation *anim2 = new TestAnimation; + group.appendAnimation(anim2); + QCOMPARE(group.firstChild(), anim1); + QCOMPARE(group.lastChild(), anim2); + + group.start(); + QTest::qWait(anim1->duration() + 100); + QTRY_VERIFY(!group.firstChild()); + QCOMPARE(group.state(), QAbstractAnimationJob::Stopped); + QCOMPARE(group.currentLoopTime(), 0); + + anim1 = new TestAnimation; + group.appendAnimation(anim1); + RefillFinishedListener refillListener(&group); + anim1->addAnimationChangeListener(&refillListener, QAbstractAnimationJob::Completion); + group.start(); + QTest::qWait(anim1->duration() + 100); + QTRY_COMPARE(group.state(), QAbstractAnimationJob::Running); +} + +void tst_QSequentialAnimationGroupJob::pauseResume() +{ + QParallelAnimationGroupJob group; + TestAnimation *anim = new TestAnimation; + group.appendAnimation(anim); + StateChangeListener spy; + anim->addAnimationChangeListener(&spy, QAbstractAnimationJob::StateChange); + QCOMPARE(group.duration(), 250); + group.start(); + QTest::qWait(100); + QTRY_COMPARE(group.state(), QAnimationGroupJob::Running); + QCOMPARE(anim->state(), QAnimationGroupJob::Running); + QCOMPARE(spy.count(), 1); + spy.clear(); + const int currentTime = group.currentLoopTime(); + QCOMPARE(anim->currentLoopTime(), currentTime); + + group.pause(); + QCOMPARE(group.state(), QAnimationGroupJob::Paused); + QCOMPARE(group.currentLoopTime(), currentTime); + QCOMPARE(anim->state(), QAnimationGroupJob::Paused); + QCOMPARE(anim->currentLoopTime(), currentTime); + QCOMPARE(spy.count(), 1); + spy.clear(); + + group.resume(); + QCOMPARE(group.state(), QAnimationGroupJob::Running); + QCOMPARE(group.currentLoopTime(), currentTime); + QCOMPARE(anim->state(), QAnimationGroupJob::Running); + QCOMPARE(anim->currentLoopTime(), currentTime); + QCOMPARE(spy.count(), 1); + + anim->removeAnimationChangeListener(&spy, QAbstractAnimationJob::StateChange); +} + +QTEST_MAIN(tst_QSequentialAnimationGroupJob) +#include "tst_qsequentialanimationgroupjob.moc" diff --git a/tests/auto/qml/debugger/debugger.pro b/tests/auto/qml/debugger/debugger.pro new file mode 100644 index 0000000000..4f9ebbc350 --- /dev/null +++ b/tests/auto/qml/debugger/debugger.pro @@ -0,0 +1,16 @@ +TEMPLATE = subdirs + +PRIVATETESTS += \ + qqmlenginedebug \ + qqmldebugclient \ + qqmldebugservice \ + qqmldebugjs \ + qqmlinspector \ + qqmlprofilerservice \ + qpacketprotocol \ + qv8profilerservice \ + qdebugmessageservice + +contains(QT_CONFIG, private_tests) { + SUBDIRS += $$PRIVATETESTS +} diff --git a/tests/auto/qml/debugger/qdebugmessageservice/data/test.qml b/tests/auto/qml/debugger/qdebugmessageservice/data/test.qml new file mode 100644 index 0000000000..ab86c7d468 --- /dev/null +++ b/tests/auto/qml/debugger/qdebugmessageservice/data/test.qml @@ -0,0 +1,51 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Item { + width: 360 + height: 360 + Component.onCompleted: { + console.log("console.log") + console.count("console.count"); + } +} diff --git a/tests/auto/qml/debugger/qdebugmessageservice/qdebugmessageservice.pro b/tests/auto/qml/debugger/qdebugmessageservice/qdebugmessageservice.pro new file mode 100644 index 0000000000..afda4b23bd --- /dev/null +++ b/tests/auto/qml/debugger/qdebugmessageservice/qdebugmessageservice.pro @@ -0,0 +1,21 @@ +CONFIG += testcase +TARGET = tst_qdebugmessageservice +QT += network qml-private testlib +macx:CONFIG -= app_bundle + +HEADERS += ../shared/debugutil_p.h + +SOURCES += tst_qdebugmessageservice.cpp \ + ../shared/debugutil.cpp + +INCLUDEPATH += ../shared + +include(../../../shared/util.pri) + +testDataFiles.files = data +testDataFiles.path = . +DEPLOYMENT += testDataFiles + +CONFIG += parallel_test + +OTHER_FILES += data/test.qml diff --git a/tests/auto/qml/debugger/qdebugmessageservice/tst_qdebugmessageservice.cpp b/tests/auto/qml/debugger/qdebugmessageservice/tst_qdebugmessageservice.cpp new file mode 100644 index 0000000000..a19fd4b766 --- /dev/null +++ b/tests/auto/qml/debugger/qdebugmessageservice/tst_qdebugmessageservice.cpp @@ -0,0 +1,242 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include + +//QQmlDebugTest +#include "../shared/debugutil_p.h" +#include "../../../shared/util.h" + +#include +#include + +const char *NORMALMODE = "-qmljsdebugger=port:3777,block"; +const char *QMLFILE = "test.qml"; + +class QQmlDebugMsgClient; +class tst_QDebugMessageService : public QQmlDataTest +{ + Q_OBJECT + +public: + tst_QDebugMessageService(); + + void init(); + +private slots: + void initTestCase(); + void cleanupTestCase(); + + void cleanup(); + + void retrieveDebugOutput(); + +private: + QQmlDebugProcess *m_process; + QQmlDebugMsgClient *m_client; + QQmlDebugConnection *m_connection; +}; + +struct LogEntry { + LogEntry(QtMsgType _type, QString _message) + : type(_type), message(_message) {} + + QtMsgType type; + QString message; + int line; + QString file; + QString function; + + QString toString() const { return QString::number(type) + ": " + message; } +}; + +bool operator==(const LogEntry &t1, const LogEntry &t2) +{ + return t1.type == t2.type && t1.message == t2.message + && t1.line == t2.line && t1.file == t2.file + && t1.function == t2.function; +} + +class QQmlDebugMsgClient : public QQmlDebugClient +{ + Q_OBJECT +public: + QQmlDebugMsgClient(QQmlDebugConnection *connection) + : QQmlDebugClient(QLatin1String("DebugMessages"), connection) + { + } + + QList logBuffer; + +protected: + //inherited from QQmlDebugClient + void stateChanged(State state); + void messageReceived(const QByteArray &data); + +signals: + void enabled(); + void debugOutput(); +}; + +void QQmlDebugMsgClient::stateChanged(State state) +{ + if (state == Enabled) { + emit enabled(); + } +} + +void QQmlDebugMsgClient::messageReceived(const QByteArray &data) +{ + QDataStream ds(data); + QByteArray command; + ds >> command; + + if (command == "MESSAGE") { + int type; + QByteArray message; + QByteArray file; + QByteArray function; + int line; + ds >> type >> message >> file >> line >> function; + QVERIFY(ds.atEnd()); + + QVERIFY(type >= QtDebugMsg); + QVERIFY(type <= QtFatalMsg); + + LogEntry entry((QtMsgType)type, QString::fromUtf8(message)); + entry.line = line; + entry.file = QString::fromUtf8(file); + entry.function = QString::fromUtf8(function); + logBuffer << entry; + emit debugOutput(); + } else { + QFAIL("Unknown message"); + } +} + +tst_QDebugMessageService::tst_QDebugMessageService() +{ +} + +void tst_QDebugMessageService::initTestCase() +{ + QQmlDataTest::initTestCase(); + m_process = 0; + m_client = 0; + m_connection = 0; +} + +void tst_QDebugMessageService::cleanupTestCase() +{ + if (m_process) + delete m_process; + + if (m_client) + delete m_client; + + if (m_connection) + delete m_connection; +} + +void tst_QDebugMessageService::init() +{ + m_connection = new QQmlDebugConnection(); + m_process = new QQmlDebugProcess(QLibraryInfo::location(QLibraryInfo::BinariesPath) + "/qmlscene"); + m_client = new QQmlDebugMsgClient(m_connection); + + m_process->start(QStringList() << QLatin1String(NORMALMODE) << QQmlDataTest::instance()->testFile(QMLFILE)); + if (!m_process->waitForSessionStart()) { + QFAIL(QString("Could not launch app. Application output: \n%1").arg(m_process->output()).toAscii()); + } + + m_connection->connectToHost("127.0.0.1", 3777); + QVERIFY(m_connection->waitForConnected()); + + QVERIFY(QQmlDebugTest::waitForSignal(m_client, SIGNAL(enabled()))); +} + +void tst_QDebugMessageService::cleanup() +{ + if (QTest::currentTestFailed()) + qDebug() << m_process->output(); + if (m_process) + delete m_process; + + if (m_client) + delete m_client; + + if (m_connection) + delete m_connection; + + m_process = 0; + m_client = 0; + m_connection = 0; +} + +void tst_QDebugMessageService::retrieveDebugOutput() +{ + init(); + + int maxTries = 2; + while ((m_client->logBuffer.size() < 2) + || (maxTries-- > 0)) + QQmlDebugTest::waitForSignal(m_client, SIGNAL(debugOutput()), 1000); + + QVERIFY(m_client->logBuffer.size() >= 2); + + const QString path = + QUrl::fromLocalFile(QQmlDataTest::instance()->testFile(QMLFILE)).toString(); + LogEntry entry1(QtDebugMsg, QLatin1String("console.log")); + entry1.line = 48; + entry1.file = path; + entry1.function = QLatin1String("onCompleted"); + LogEntry entry2(QtDebugMsg, QLatin1String("console.count: 1")); + entry2.line = 49; + entry2.file = path; + entry2.function = QLatin1String("onCompleted"); + + QVERIFY(m_client->logBuffer.contains(entry1)); + QVERIFY(m_client->logBuffer.contains(entry2)); +} + +QTEST_MAIN(tst_QDebugMessageService) + +#include "tst_qdebugmessageservice.moc" diff --git a/tests/auto/qml/debugger/qpacketprotocol/qpacketprotocol.pro b/tests/auto/qml/debugger/qpacketprotocol/qpacketprotocol.pro new file mode 100644 index 0000000000..88439196a7 --- /dev/null +++ b/tests/auto/qml/debugger/qpacketprotocol/qpacketprotocol.pro @@ -0,0 +1,10 @@ +CONFIG += testcase +TARGET = tst_qpacketprotocol +macx:CONFIG -= app_bundle + +HEADERS += ../shared/debugutil_p.h +SOURCES += tst_qpacketprotocol.cpp \ + ../shared/debugutil.cpp + +CONFIG += parallel_test +QT += qml-private network testlib diff --git a/tests/auto/qml/debugger/qpacketprotocol/tst_qpacketprotocol.cpp b/tests/auto/qml/debugger/qpacketprotocol/tst_qpacketprotocol.cpp new file mode 100644 index 0000000000..c02dd2d8fa --- /dev/null +++ b/tests/auto/qml/debugger/qpacketprotocol/tst_qpacketprotocol.cpp @@ -0,0 +1,263 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include "../shared/debugutil_p.h" + +class tst_QPacketProtocol : public QObject +{ + Q_OBJECT + +private: + QTcpServer *m_server; + QTcpSocket *m_client; + QTcpSocket *m_serverConn; + +private slots: + void init(); + void cleanup(); + + void maximumPacketSize(); + void setMaximumPacketSize(); + void setMaximumPacketSize_data(); + void send(); + void send_data(); + void packetsAvailable(); + void packetsAvailable_data(); + void clear(); + void read(); + void device(); + + void tst_QPacket_clear(); +}; + +void tst_QPacketProtocol::init() +{ + m_server = new QTcpServer(this); + m_serverConn = 0; + QVERIFY(m_server->listen(QHostAddress("127.0.0.1"))); + + m_client = new QTcpSocket(this); + m_client->connectToHost(m_server->serverAddress(), m_server->serverPort()); + + QVERIFY(m_client->waitForConnected()); + QVERIFY(m_server->waitForNewConnection(5000)); + m_serverConn = m_server->nextPendingConnection(); +} + +void tst_QPacketProtocol::cleanup() +{ + delete m_client; + delete m_serverConn; + delete m_server; +} + +void tst_QPacketProtocol::maximumPacketSize() +{ + QPacketProtocol p(m_client); + QCOMPARE(p.maximumPacketSize(), 0x7FFFFFFF); +} + +void tst_QPacketProtocol::setMaximumPacketSize() +{ + QFETCH(qint32, size); + QFETCH(qint32, expected); + + QPacketProtocol out(m_serverConn); + QCOMPARE(out.setMaximumPacketSize(size), expected); +} + +void tst_QPacketProtocol::setMaximumPacketSize_data() +{ + QTest::addColumn("size"); + QTest::addColumn("expected"); + + QTest::newRow("invalid") << qint32(sizeof(qint32) - 1) << qint32(0x7FFFFFFF); + QTest::newRow("still invalid") << qint32(sizeof(qint32)) << qint32(0x7FFFFFFF); + QTest::newRow("valid") << qint32(sizeof(qint32) + 1) << qint32(sizeof(qint32) + 1); +} + +void tst_QPacketProtocol::send() +{ + QFETCH(bool, useAutoSend); + + QPacketProtocol in(m_client); + QPacketProtocol out(m_serverConn); + + QByteArray ba; + int num; + + if (useAutoSend) { + out.send() << "Hello world" << 123; + } else { + QPacket packet; + packet << "Hello world" << 123; + out.send(packet); + } + + QVERIFY(QQmlDebugTest::waitForSignal(&in, SIGNAL(readyRead()))); + + QPacket p = in.read(); + p >> ba >> num; + QCOMPARE(ba, QByteArray("Hello world") + '\0'); + QCOMPARE(num, 123); +} + +void tst_QPacketProtocol::send_data() +{ + QTest::addColumn("useAutoSend"); + + QTest::newRow("auto send") << true; + QTest::newRow("no auto send") << false; +} + +void tst_QPacketProtocol::packetsAvailable() +{ + QFETCH(int, packetCount); + + QPacketProtocol out(m_client); + QPacketProtocol in(m_serverConn); + + QCOMPARE(out.packetsAvailable(), qint64(0)); + QCOMPARE(in.packetsAvailable(), qint64(0)); + + for (int i=0; i("packetCount"); + + QTest::newRow("1") << 1; + QTest::newRow("2") << 2; + QTest::newRow("10") << 10; +} + +void tst_QPacketProtocol::clear() +{ + QPacketProtocol in(m_client); + QPacketProtocol out(m_serverConn); + + out.send() << 123; + out.send() << 456; + QVERIFY(QQmlDebugTest::waitForSignal(&in, SIGNAL(readyRead()))); + + in.clear(); + QVERIFY(in.read().isEmpty()); +} + +void tst_QPacketProtocol::read() +{ + QPacketProtocol in(m_client); + QPacketProtocol out(m_serverConn); + + QVERIFY(in.read().isEmpty()); + + out.send() << 123; + out.send() << 456; + QVERIFY(QQmlDebugTest::waitForSignal(&in, SIGNAL(readyRead()))); + + int num; + + QPacket p1 = in.read(); + QVERIFY(!p1.isEmpty()); + p1 >> num; + QCOMPARE(num, 123); + + QPacket p2 = in.read(); + QVERIFY(!p2.isEmpty()); + p2 >> num; + QCOMPARE(num, 456); + + QVERIFY(in.read().isEmpty()); +} + +void tst_QPacketProtocol::device() +{ + QPacketProtocol p(m_client); + QVERIFY(p.device() == m_client); +} + +void tst_QPacketProtocol::tst_QPacket_clear() +{ + QPacketProtocol protocol(m_client); + + QPacket packet; + + packet << "Hello world!" << 123; + protocol.send(packet); + + packet.clear(); + QVERIFY(packet.isEmpty()); + packet << "Goodbyte world!" << 789; + protocol.send(packet); + + QByteArray ba; + int num; + QPacketProtocol in(m_serverConn); + QVERIFY(QQmlDebugTest::waitForSignal(&in, SIGNAL(readyRead()))); + + QPacket p1 = in.read(); + p1 >> ba >> num; + QCOMPARE(ba, QByteArray("Hello world!") + '\0'); + QCOMPARE(num, 123); + + QPacket p2 = in.read(); + p2 >> ba >> num; + QCOMPARE(ba, QByteArray("Goodbyte world!") + '\0'); + QCOMPARE(num, 789); +} + +QTEST_MAIN(tst_QPacketProtocol) + +#include "tst_qpacketprotocol.moc" diff --git a/tests/auto/qml/debugger/qqmldebugclient/qqmldebugclient.pro b/tests/auto/qml/debugger/qqmldebugclient/qqmldebugclient.pro new file mode 100644 index 0000000000..d298b5c087 --- /dev/null +++ b/tests/auto/qml/debugger/qqmldebugclient/qqmldebugclient.pro @@ -0,0 +1,11 @@ +CONFIG += testcase +TARGET = tst_qqmldebugclient +macx:CONFIG -= app_bundle + +HEADERS += ../shared/debugutil_p.h +SOURCES += tst_qqmldebugclient.cpp \ + ../shared/debugutil.cpp + +CONFIG += declarative_debug + +QT += qml-private testlib diff --git a/tests/auto/qml/debugger/qqmldebugclient/tst_qqmldebugclient.cpp b/tests/auto/qml/debugger/qqmldebugclient/tst_qqmldebugclient.cpp new file mode 100644 index 0000000000..2891076af6 --- /dev/null +++ b/tests/auto/qml/debugger/qqmldebugclient/tst_qqmldebugclient.cpp @@ -0,0 +1,197 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include +#include +#include +#include +#include +#include + +#include + +#include "../shared/debugutil_p.h" + +#define PORT 13770 +#define STR_PORT "13770" + +class tst_QQmlDebugClient : public QObject +{ + Q_OBJECT + +private: + QQmlDebugConnection *m_conn; + +private slots: + void initTestCase(); + + void name(); + void state(); + void sendMessage(); + void parallelConnect(); + void sequentialConnect(); +}; + +void tst_QQmlDebugClient::initTestCase() +{ + const QString waitingMsg = QString("QQmlDebugServer: Waiting for connection on port %1...").arg(PORT); + QTest::ignoreMessage(QtWarningMsg, waitingMsg.toAscii().constData()); + new QQmlEngine(this); + + m_conn = new QQmlDebugConnection(this); + + QQmlDebugTestClient client("tst_QQmlDebugClient::handshake()", m_conn); + QQmlDebugTestService service("tst_QQmlDebugClient::handshake()"); + + QTest::ignoreMessage(QtWarningMsg, "QQmlDebugServer: Connection established"); + for (int i = 0; i < 50; ++i) { + // try for 5 seconds ... + m_conn->connectToHost("127.0.0.1", PORT); + if (m_conn->waitForConnected()) + break; + QTest::qSleep(100); + } + + QVERIFY(m_conn->isConnected()); + + QTRY_VERIFY(QQmlDebugService::hasDebuggingClient()); + QTRY_COMPARE(client.state(), QQmlDebugClient::Enabled); +} + +void tst_QQmlDebugClient::name() +{ + QString name = "tst_QQmlDebugClient::name()"; + + QQmlDebugClient client(name, m_conn); + QCOMPARE(client.name(), name); +} + +void tst_QQmlDebugClient::state() +{ + { + QQmlDebugConnection dummyConn; + QQmlDebugClient client("tst_QQmlDebugClient::state()", &dummyConn); + QCOMPARE(client.state(), QQmlDebugClient::NotConnected); + QCOMPARE(client.serviceVersion(), -1.0f); + } + + QQmlDebugTestClient client("tst_QQmlDebugClient::state()", m_conn); + QCOMPARE(client.state(), QQmlDebugClient::Unavailable); + + { + QQmlDebugTestService service("tst_QQmlDebugClient::state()", 2); + QTRY_COMPARE(client.state(), QQmlDebugClient::Enabled); + QCOMPARE(client.serviceVersion(), 2.0f); + } + + QTRY_COMPARE(client.state(), QQmlDebugClient::Unavailable); + + // duplicate plugin name + QTest::ignoreMessage(QtWarningMsg, "QQmlDebugClient: Conflicting plugin name \"tst_QQmlDebugClient::state()\" "); + QQmlDebugClient client2("tst_QQmlDebugClient::state()", m_conn); + QCOMPARE(client2.state(), QQmlDebugClient::NotConnected); + + QQmlDebugClient client3("tst_QQmlDebugClient::state3()", 0); + QCOMPARE(client3.state(), QQmlDebugClient::NotConnected); +} + +void tst_QQmlDebugClient::sendMessage() +{ + QQmlDebugTestService service("tst_QQmlDebugClient::sendMessage()"); + QQmlDebugTestClient client("tst_QQmlDebugClient::sendMessage()", m_conn); + + QByteArray msg = "hello!"; + + QTRY_COMPARE(client.state(), QQmlDebugClient::Enabled); + + client.sendMessage(msg); + QByteArray resp = client.waitForResponse(); + QCOMPARE(resp, msg); +} + +void tst_QQmlDebugClient::parallelConnect() +{ + QQmlDebugConnection connection2; + + QTest::ignoreMessage(QtWarningMsg, "QQmlDebugServer: Another client is already connected"); + // will connect & immediately disconnect + connection2.connectToHost("127.0.0.1", PORT); + QVERIFY(connection2.waitForConnected()); + QTRY_COMPARE(connection2.state(), QAbstractSocket::UnconnectedState); + QVERIFY(m_conn->isConnected()); +} + +void tst_QQmlDebugClient::sequentialConnect() +{ + QQmlDebugConnection connection2; + QQmlDebugTestClient client2("tst_QQmlDebugClient::handshake()", &connection2); + QQmlDebugTestService service("tst_QQmlDebugClient::handshake()"); + + m_conn->close(); + QVERIFY(!m_conn->isConnected()); + QCOMPARE(m_conn->state(), QAbstractSocket::UnconnectedState); + + // Make sure that the disconnect is actually delivered to the server + QTest::qWait(100); + + connection2.connectToHost("127.0.0.1", PORT); + QTest::ignoreMessage(QtWarningMsg, "QQmlDebugServer: Connection established"); + QVERIFY(connection2.waitForConnected()); + QVERIFY(connection2.isConnected()); + QTRY_VERIFY(client2.state() == QQmlDebugClient::Enabled); +} + +int main(int argc, char *argv[]) +{ + int _argc = argc + 1; + char **_argv = new char*[_argc]; + for (int i = 0; i < argc; ++i) + _argv[i] = argv[i]; + char arg[] = "-qmljsdebugger=port:" STR_PORT; + _argv[_argc - 1] = arg; + + QGuiApplication app(_argc, _argv); + tst_QQmlDebugClient tc; + return QTest::qExec(&tc, _argc, _argv); + delete _argv; +} + +#include "tst_qqmldebugclient.moc" + diff --git a/tests/auto/qml/debugger/qqmldebugjs/data/breakpointRelocation.qml b/tests/auto/qml/debugger/qqmldebugjs/data/breakpointRelocation.qml new file mode 100644 index 0000000000..1f0f9e22c9 --- /dev/null +++ b/tests/auto/qml/debugger/qqmldebugjs/data/breakpointRelocation.qml @@ -0,0 +1,53 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +//DO NOT CHANGE + +Item { + Component.onCompleted: { + //Comment + + var b = 6; + } +} + diff --git a/tests/auto/qml/debugger/qqmldebugjs/data/changeBreakpoint.qml b/tests/auto/qml/debugger/qqmldebugjs/data/changeBreakpoint.qml new file mode 100644 index 0000000000..fd81b3f805 --- /dev/null +++ b/tests/auto/qml/debugger/qqmldebugjs/data/changeBreakpoint.qml @@ -0,0 +1,60 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +//DO NOT CHANGE + +Item { + id: item + property int d: 0 + + function doSomething() { + var a = 5; + var b = 6; + } + + Timer { + id: timer; interval: 1; running: true; repeat: true + onTriggered: doSomething(); + } + +} diff --git a/tests/auto/qml/debugger/qqmldebugjs/data/condition.qml b/tests/auto/qml/debugger/qqmldebugjs/data/condition.qml new file mode 100644 index 0000000000..ad4144be11 --- /dev/null +++ b/tests/auto/qml/debugger/qqmldebugjs/data/condition.qml @@ -0,0 +1,54 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +//DO NOT CHANGE + +Item { + id: item + property int a: 0 + Timer { + id: timer; interval: 1; repeat: true; running: true + onTriggered: a++ + } +} + diff --git a/tests/auto/qml/debugger/qqmldebugjs/data/createComponent.qml b/tests/auto/qml/debugger/qqmldebugjs/data/createComponent.qml new file mode 100644 index 0000000000..993f33a661 --- /dev/null +++ b/tests/auto/qml/debugger/qqmldebugjs/data/createComponent.qml @@ -0,0 +1,54 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +//DO NOT CHANGE +Item { + Component.onCompleted: { + var component = Qt.createComponent("oncompleted.qml") + if (component.status === Component.Ready) { + component.createObject(); + } + } +} + + diff --git a/tests/auto/qml/debugger/qqmldebugjs/data/exception.qml b/tests/auto/qml/debugger/qqmldebugjs/data/exception.qml new file mode 100644 index 0000000000..b491087a02 --- /dev/null +++ b/tests/auto/qml/debugger/qqmldebugjs/data/exception.qml @@ -0,0 +1,51 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +//DO NOT CHANGE + +Item { + id: root + + Component.onCompleted: dummy() +} + diff --git a/tests/auto/qml/debugger/qqmldebugjs/data/loadjsfile.qml b/tests/auto/qml/debugger/qqmldebugjs/data/loadjsfile.qml new file mode 100644 index 0000000000..4fff66a325 --- /dev/null +++ b/tests/auto/qml/debugger/qqmldebugjs/data/loadjsfile.qml @@ -0,0 +1,48 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import "test.js" as Script + +//DO NOT CHANGE +Item { + Component.onCompleted: Script.printMessage("onCompleted"); +} diff --git a/tests/auto/qml/debugger/qqmldebugjs/data/oncompleted.qml b/tests/auto/qml/debugger/qqmldebugjs/data/oncompleted.qml new file mode 100644 index 0000000000..e03ba2ca79 --- /dev/null +++ b/tests/auto/qml/debugger/qqmldebugjs/data/oncompleted.qml @@ -0,0 +1,53 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +//DO NOT CHANGE + +Item { + Component.onCompleted: { + console.log("Hello world") + } + id: root + property int a: 10 +} + diff --git a/tests/auto/qml/debugger/qqmldebugjs/data/stepAction.qml b/tests/auto/qml/debugger/qqmldebugjs/data/stepAction.qml new file mode 100644 index 0000000000..690f9fd446 --- /dev/null +++ b/tests/auto/qml/debugger/qqmldebugjs/data/stepAction.qml @@ -0,0 +1,57 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +//DO NOT CHANGE + +Item { + id: item + property int d: 0 + + function doSomething() { + var a = 5; + var b = 6; + } + + Component.onCompleted: doSomething() + +} diff --git a/tests/auto/qml/debugger/qqmldebugjs/data/test.js b/tests/auto/qml/debugger/qqmldebugjs/data/test.js new file mode 100644 index 0000000000..7de138bdf6 --- /dev/null +++ b/tests/auto/qml/debugger/qqmldebugjs/data/test.js @@ -0,0 +1,53 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +function printMessage(msg) +{ + print(msg); +} + +function add(a,b) +{ + //This is a comment and below is an empty line + + var out = a + b; + return out; +} diff --git a/tests/auto/qml/debugger/qqmldebugjs/data/test.qml b/tests/auto/qml/debugger/qqmldebugjs/data/test.qml new file mode 100644 index 0000000000..200f26b1c3 --- /dev/null +++ b/tests/auto/qml/debugger/qqmldebugjs/data/test.qml @@ -0,0 +1,54 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +//DO NOT CHANGE + +Item { + Component.onCompleted: { + var a = [1, 2] + var b = {a: "hello", d: 1 } + var c + var d = 12 + } +} + diff --git a/tests/auto/qml/debugger/qqmldebugjs/data/timer.qml b/tests/auto/qml/debugger/qqmldebugjs/data/timer.qml new file mode 100644 index 0000000000..d9440415d2 --- /dev/null +++ b/tests/auto/qml/debugger/qqmldebugjs/data/timer.qml @@ -0,0 +1,52 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +//DO NOT CHANGE +Item { + Timer { + id: timer; interval: 1; running: true; repeat: true; triggeredOnStart: true + onTriggered: { + console.log("timer"); + } + } +} diff --git a/tests/auto/qml/debugger/qqmldebugjs/qqmldebugjs.pro b/tests/auto/qml/debugger/qqmldebugjs/qqmldebugjs.pro new file mode 100644 index 0000000000..72b0e77f71 --- /dev/null +++ b/tests/auto/qml/debugger/qqmldebugjs/qqmldebugjs.pro @@ -0,0 +1,29 @@ +CONFIG += testcase +TARGET = tst_qqmldebugjs +QT += qml-private testlib +macx:CONFIG -= app_bundle + +HEADERS += ../shared/debugutil_p.h +SOURCES += tst_qqmldebugjs.cpp \ + ../shared/debugutil.cpp + +INCLUDEPATH += ../shared + +include (../../../shared/util.pri) + +testDataFiles.files = data +testDataFiles.path = . +DEPLOYMENT += testDataFiles + +CONFIG += parallel_test + +OTHER_FILES += data/test.qml data/test.js \ + data/timer.qml \ + data/exception.qml \ + data/oncompleted.qml \ + data/loadjsfile.qml \ + data/condition.qml \ + data/changeBreakpoint.qml \ + data/stepAction.qml \ + data/breakpointRelocation.qml \ + data/createComponent.qml diff --git a/tests/auto/qml/debugger/qqmldebugjs/tst_qqmldebugjs.cpp b/tests/auto/qml/debugger/qqmldebugjs/tst_qqmldebugjs.cpp new file mode 100644 index 0000000000..9a8b00bb6c --- /dev/null +++ b/tests/auto/qml/debugger/qqmldebugjs/tst_qqmldebugjs.cpp @@ -0,0 +1,1790 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +//QQmlDebugTest +#include "../shared/debugutil_p.h" +#include "../../../shared/util.h" + +const char *V8REQUEST = "v8request"; +const char *V8MESSAGE = "v8message"; +const char *SEQ = "seq"; +const char *TYPE = "type"; +const char *COMMAND = "command"; +const char *ARGUMENTS = "arguments"; +const char *STEPACTION = "stepaction"; +const char *STEPCOUNT = "stepcount"; +const char *EXPRESSION = "expression"; +const char *FRAME = "frame"; +const char *GLOBAL = "global"; +const char *DISABLEBREAK = "disable_break"; +const char *HANDLES = "handles"; +const char *INCLUDESOURCE = "includeSource"; +const char *FROMFRAME = "fromFrame"; +const char *TOFRAME = "toFrame"; +const char *BOTTOM = "bottom"; +const char *NUMBER = "number"; +const char *FRAMENUMBER = "frameNumber"; +const char *TYPES = "types"; +const char *IDS = "ids"; +const char *FILTER = "filter"; +const char *FROMLINE = "fromLine"; +const char *TOLINE = "toLine"; +const char *TARGET = "target"; +const char *LINE = "line"; +const char *COLUMN = "column"; +const char *ENABLED = "enabled"; +const char *CONDITION = "condition"; +const char *IGNORECOUNT = "ignoreCount"; +const char *BREAKPOINT = "breakpoint"; +const char *FLAGS = "flags"; + +const char *CONTINEDEBUGGING = "continue"; +const char *EVALUATE = "evaluate"; +const char *LOOKUP = "lookup"; +const char *BACKTRACE = "backtrace"; +const char *SCOPE = "scope"; +const char *SCOPES = "scopes"; +const char *SCRIPTS = "scripts"; +const char *SOURCE = "source"; +const char *SETBREAKPOINT = "setbreakpoint"; +const char *CHANGEBREAKPOINT = "changebreakpoint"; +const char *CLEARBREAKPOINT = "clearbreakpoint"; +const char *SETEXCEPTIONBREAK = "setexceptionbreak"; +const char *V8FLAGS = "v8flags"; +const char *VERSION = "version"; +const char *DISCONNECT = "disconnect"; +const char *LISTBREAKPOINTS = "listbreakpoints"; +const char *GARBAGECOLLECTOR = "gc"; +//const char *PROFILE = "profile"; + +const char *CONNECT = "connect"; +const char *INTERRUPT = "interrupt"; +const char *BREAKAFTERCOMPILE = "breakaftercompile"; + +const char *REQUEST = "request"; +const char *IN = "in"; +const char *NEXT = "next"; +const char *OUT = "out"; + +const char *FUNCTION = "function"; +const char *SCRIPT = "script"; +const char *SCRIPTREGEXP = "scriptRegExp"; +const char *EVENT = "event"; + +const char *ALL = "all"; +const char *UNCAUGHT = "uncaught"; + +//const char *PAUSE = "pause"; +//const char *RESUME = "resume"; + +const char *BLOCKMODE = "-qmljsdebugger=port:3771,block"; +const char *NORMALMODE = "-qmljsdebugger=port:3771"; +const char *TEST_QMLFILE = "test.qml"; +const char *TEST_JSFILE = "test.js"; +const char *TIMER_QMLFILE = "timer.qml"; +const char *LOADJSFILE_QMLFILE = "loadjsfile.qml"; +const char *EXCEPTION_QMLFILE = "exception.qml"; +const char *ONCOMPLETED_QMLFILE = "oncompleted.qml"; +const char *CREATECOMPONENT_QMLFILE = "createComponent.qml"; +const char *CONDITION_QMLFILE = "condition.qml"; +const char *CHANGEBREAKPOINT_QMLFILE = "changeBreakpoint.qml"; +const char *STEPACTION_QMLFILE = "stepAction.qml"; +const char *BREAKPOINTRELOCATION_QMLFILE = "breakpointRelocation.qml"; + +#define VARIANTMAPINIT \ + QString obj("{}"); \ + QJSValue jsonVal = parser.call(QJSValueList() << obj); \ + jsonVal.setProperty(SEQ,QJSValue(seq++)); \ + jsonVal.setProperty(TYPE,REQUEST); + + +#undef QVERIFY +#define QVERIFY(statement) \ +do {\ + if (!QTest::qVerify((statement), #statement, "", __FILE__, __LINE__)) {\ + if (QTest::currentTestFailed()) \ + qDebug().nospace() << "\nDEBUGGEE OUTPUT:\n" << process->output();\ + return;\ + }\ +} while (0) + + +class QJSDebugClient; + +class tst_QQmlDebugJS : public QQmlDataTest +{ + Q_OBJECT + + bool init(const QString &qmlFile = QString(TEST_QMLFILE), bool blockMode = true); + +private slots: + void initTestCase(); + void cleanupTestCase(); + + void cleanup(); + + void connect(); + void interrupt(); + void breakAfterCompile(); + void getVersion(); + void getVersionWhenAttaching(); + + void applyV8Flags(); + + void disconnect(); + + void gc(); + + void listBreakpoints(); + + void setBreakpointInScriptOnCompleted(); + void setBreakpointInScriptOnComponentCreated(); + void setBreakpointInScriptOnTimerCallback(); + void setBreakpointInScriptInDifferentFile(); + void setBreakpointInScriptOnComment(); + void setBreakpointInScriptOnEmptyLine(); + void setBreakpointInScriptWithCondition(); + //void setBreakpointInFunction(); //NOT SUPPORTED + void setBreakpointOnEvent(); + void setBreakpointWhenAttaching(); + + void changeBreakpoint(); + void changeBreakpointOnCondition(); + + void clearBreakpoint(); + + void setExceptionBreak(); + + void stepNext(); + void stepNextWithCount(); + void stepIn(); + void stepOut(); + void continueDebugging(); + + void backtrace(); + + void getFrameDetails(); + + void getScopeDetails(); + + void evaluateInGlobalScope(); + void evaluateInLocalScope(); + + void getScopes(); + + void getScripts(); + + void getSource(); + + // void profile(); //NOT SUPPORTED + + // void verifyQMLOptimizerDisabled(); + +private: + QQmlDebugProcess *process; + QJSDebugClient *client; + QQmlDebugConnection *connection; + QTime t; +}; + +class QJSDebugClient : public QQmlDebugClient +{ + Q_OBJECT +public: + enum StepAction + { + Continue, + In, + Out, + Next + }; + + enum Exception + { + All, + Uncaught + }; + +// enum ProfileCommand +// { +// Pause, +// Resume +// }; + + QJSDebugClient(QQmlDebugConnection *connection) + : QQmlDebugClient(QLatin1String("V8Debugger"), connection), + seq(0) + { + parser = jsEngine.evaluate(QLatin1String("JSON.parse")); + stringify = jsEngine.evaluate(QLatin1String("JSON.stringify")); + } + + void connect(); + void interrupt(); + void breakAfterCompile(bool enabled); + + void continueDebugging(StepAction stepAction, int stepCount = 1); + void evaluate(QString expr, bool global = false, bool disableBreak = false, int frame = -1, const QVariantMap &addContext = QVariantMap()); + void lookup(QList handles, bool includeSource = false); + void backtrace(int fromFrame = -1, int toFrame = -1, bool bottom = false); + void frame(int number = -1); + void scope(int number = -1, int frameNumber = -1); + void scopes(int frameNumber = -1); + void scripts(int types = 4, QList ids = QList(), bool includeSource = false, QVariant filter = QVariant()); + void source(int frame = -1, int fromLine = -1, int toLine = -1); + void setBreakpoint(QString type, QString target, int line = -1, int column = -1, bool enabled = true, QString condition = QString(), int ignoreCount = -1); + void changeBreakpoint(int breakpoint, bool enabled = true, QString condition = QString(), int ignoreCount = -1); + void clearBreakpoint(int breakpoint); + void setExceptionBreak(Exception type, bool enabled = false); + void v8flags(QString flags); + void version(); + //void profile(ProfileCommand command); //NOT SUPPORTED + void disconnect(); + void gc(); + void listBreakpoints(); + +protected: + //inherited from QQmlDebugClient + void stateChanged(State state); + void messageReceived(const QByteArray &data); + +signals: + void enabled(); + void connected(); + void interruptRequested(); + void breakAfterCompileRequested(); + void result(); + void stopped(); + +private: + void sendMessage(const QByteArray &); + void flushSendBuffer(); + QByteArray packMessage(const QByteArray &type, const QByteArray &message = QByteArray()); + +private: + QJSEngine jsEngine; + int seq; + + QList sendBuffer; +public: + QJSValue parser; + QJSValue stringify; + QByteArray response; + +}; + +void QJSDebugClient::connect() +{ + sendMessage(packMessage(CONNECT)); +} + +void QJSDebugClient::interrupt() +{ + sendMessage(packMessage(INTERRUPT)); +} + +void QJSDebugClient::breakAfterCompile(bool enabled) +{ + QByteArray request; + QDataStream rs(&request, QIODevice::WriteOnly); + rs << enabled; + sendMessage(packMessage(BREAKAFTERCOMPILE, request)); +} + +void QJSDebugClient::continueDebugging(StepAction action, int count) +{ + // { "seq" : , + // "type" : "request", + // "command" : "continue", + // "arguments" : { "stepaction" : <"in", "next" or "out">, + // "stepcount" : + // } + // } + VARIANTMAPINIT; + jsonVal.setProperty(QLatin1String(COMMAND),QJSValue(QLatin1String(CONTINEDEBUGGING))); + + if (action != Continue) { + QJSValue args = parser.call(QJSValueList() << obj); + switch (action) { + case In: args.setProperty(QLatin1String(STEPACTION),QJSValue(QLatin1String(IN))); + break; + case Out: args.setProperty(QLatin1String(STEPACTION),QJSValue(QLatin1String(OUT))); + break; + case Next: args.setProperty(QLatin1String(STEPACTION),QJSValue(QLatin1String(NEXT))); + break; + default:break; + } + if (!args.isUndefined()) { + if (count != 1) + args.setProperty(QLatin1String(STEPCOUNT),QJSValue(count)); + jsonVal.setProperty(QLatin1String(ARGUMENTS),args); + } + } + QJSValue json = stringify.call(QJSValueList() << jsonVal); + sendMessage(packMessage(V8REQUEST, json.toString().toUtf8())); +} + +void QJSDebugClient::evaluate(QString expr, bool global, bool disableBreak, int frame, const QVariantMap &/*addContext*/) +{ + // { "seq" : , + // "type" : "request", + // "command" : "evaluate", + // "arguments" : { "expression" : , + // "frame" : , + // "global" : , + // "disable_break" : , + // "additional_context" : [ + // { "name" : , "handle" : }, + // { "name" : , "handle" : }, + // ... + // ] + // } + // } + VARIANTMAPINIT; + jsonVal.setProperty(QLatin1String(COMMAND),QJSValue(QLatin1String(EVALUATE))); + + QJSValue args = parser.call(QJSValueList() << obj); + args.setProperty(QLatin1String(EXPRESSION),QJSValue(expr)); + + if (frame != -1) + args.setProperty(QLatin1String(FRAME),QJSValue(frame)); + + if (global) + args.setProperty(QLatin1String(GLOBAL),QJSValue(global)); + + if (disableBreak) + args.setProperty(QLatin1String(DISABLEBREAK),QJSValue(disableBreak)); + + if (!args.isUndefined()) { + jsonVal.setProperty(QLatin1String(ARGUMENTS),args); + } + + QJSValue json = stringify.call(QJSValueList() << jsonVal); + sendMessage(packMessage(V8REQUEST, json.toString().toUtf8())); +} + +void QJSDebugClient::lookup(QList handles, bool includeSource) +{ + // { "seq" : , + // "type" : "request", + // "command" : "lookup", + // "arguments" : { "handles" : , + // "includeSource" : , + // } + // } + VARIANTMAPINIT; + jsonVal.setProperty(QLatin1String(COMMAND),QJSValue(QLatin1String(LOOKUP))); + + QJSValue args = parser.call(QJSValueList() << obj); + + QString arr("[]"); + QJSValue array = parser.call(QJSValueList() << arr); + int index = 0; + foreach (int handle, handles) { + array.setProperty(index++,QJSValue(handle)); + } + args.setProperty(QLatin1String(HANDLES),array); + + if (includeSource) + args.setProperty(QLatin1String(INCLUDESOURCE),QJSValue(includeSource)); + + if (!args.isUndefined()) { + jsonVal.setProperty(QLatin1String(ARGUMENTS),args); + } + + QJSValue json = stringify.call(QJSValueList() << jsonVal); + sendMessage(packMessage(V8REQUEST, json.toString().toUtf8())); +} + +void QJSDebugClient::backtrace(int fromFrame, int toFrame, bool bottom) +{ + // { "seq" : , + // "type" : "request", + // "command" : "backtrace", + // "arguments" : { "fromFrame" : + // "toFrame" : + // "bottom" : + // } + // } + VARIANTMAPINIT; + jsonVal.setProperty(QLatin1String(COMMAND),QJSValue(QLatin1String(BACKTRACE))); + + QJSValue args = parser.call(QJSValueList() << obj); + + if (fromFrame != -1) + args.setProperty(QLatin1String(FROMFRAME),QJSValue(fromFrame)); + + if (toFrame != -1) + args.setProperty(QLatin1String(TOFRAME),QJSValue(toFrame)); + + if (bottom) + args.setProperty(QLatin1String(BOTTOM),QJSValue(bottom)); + + if (!args.isUndefined()) { + jsonVal.setProperty(QLatin1String(ARGUMENTS),args); + } + + QJSValue json = stringify.call(QJSValueList() << jsonVal); + sendMessage(packMessage(V8REQUEST, json.toString().toUtf8())); +} + +void QJSDebugClient::frame(int number) +{ + // { "seq" : , + // "type" : "request", + // "command" : "frame", + // "arguments" : { "number" : + // } + // } + VARIANTMAPINIT; + jsonVal.setProperty(QLatin1String(COMMAND),QJSValue(QLatin1String(FRAME))); + + if (number != -1) { + QJSValue args = parser.call(QJSValueList() << obj); + args.setProperty(QLatin1String(NUMBER),QJSValue(number)); + + if (!args.isUndefined()) { + jsonVal.setProperty(QLatin1String(ARGUMENTS),args); + } + } + + QJSValue json = stringify.call(QJSValueList() << jsonVal); + sendMessage(packMessage(V8REQUEST, json.toString().toUtf8())); +} + +void QJSDebugClient::scope(int number, int frameNumber) +{ + // { "seq" : , + // "type" : "request", + // "command" : "scope", + // "arguments" : { "number" : + // "frameNumber" : + // } + // } + VARIANTMAPINIT; + jsonVal.setProperty(QLatin1String(COMMAND),QJSValue(QLatin1String(SCOPE))); + + if (number != -1) { + QJSValue args = parser.call(QJSValueList() << obj); + args.setProperty(QLatin1String(NUMBER),QJSValue(number)); + + if (frameNumber != -1) + args.setProperty(QLatin1String(FRAMENUMBER),QJSValue(frameNumber)); + + if (!args.isUndefined()) { + jsonVal.setProperty(QLatin1String(ARGUMENTS),args); + } + } + + QJSValue json = stringify.call(QJSValueList() << jsonVal); + sendMessage(packMessage(V8REQUEST, json.toString().toUtf8())); +} + +void QJSDebugClient::scopes(int frameNumber) +{ + // { "seq" : , + // "type" : "request", + // "command" : "scopes", + // "arguments" : { "frameNumber" : + // } + // } + VARIANTMAPINIT; + jsonVal.setProperty(QLatin1String(COMMAND),QJSValue(QLatin1String(SCOPES))); + + if (frameNumber != -1) { + QJSValue args = parser.call(QJSValueList() << obj); + args.setProperty(QLatin1String(FRAMENUMBER),QJSValue(frameNumber)); + + if (!args.isUndefined()) { + jsonVal.setProperty(QLatin1String(ARGUMENTS),args); + } + } + + QJSValue json = stringify.call(QJSValueList() << jsonVal); + sendMessage(packMessage(V8REQUEST, json.toString().toUtf8())); +} + +void QJSDebugClient::scripts(int types, QList ids, bool includeSource, QVariant /*filter*/) +{ + // { "seq" : , + // "type" : "request", + // "command" : "scripts", + // "arguments" : { "types" : + // "ids" : + // "includeSource" : + // "filter" : + // } + // } + VARIANTMAPINIT; + jsonVal.setProperty(QLatin1String(COMMAND),QJSValue(QLatin1String(SCRIPTS))); + + QJSValue args = parser.call(QJSValueList() << obj); + args.setProperty(QLatin1String(TYPES),QJSValue(types)); + + if (ids.count()) { + QString arr("[]"); + QJSValue array = parser.call(QJSValueList() << arr); + int index = 0; + foreach (int id, ids) { + array.setProperty(index++,QJSValue(id)); + } + args.setProperty(QLatin1String(IDS),array); + } + + if (includeSource) + args.setProperty(QLatin1String(INCLUDESOURCE),QJSValue(includeSource)); + + if (!args.isUndefined()) { + jsonVal.setProperty(QLatin1String(ARGUMENTS),args); + } + + QJSValue json = stringify.call(QJSValueList() << jsonVal); + sendMessage(packMessage(V8REQUEST, json.toString().toUtf8())); +} + +void QJSDebugClient::source(int frame, int fromLine, int toLine) +{ + // { "seq" : , + // "type" : "request", + // "command" : "source", + // "arguments" : { "frame" : + // "fromLine" : + // "toLine" : + // } + // } + VARIANTMAPINIT; + jsonVal.setProperty(QLatin1String(COMMAND),QJSValue(QLatin1String(SOURCE))); + + QJSValue args = parser.call(QJSValueList() << obj); + + if (frame != -1) + args.setProperty(QLatin1String(FRAME),QJSValue(frame)); + + if (fromLine != -1) + args.setProperty(QLatin1String(FROMLINE),QJSValue(fromLine)); + + if (toLine != -1) + args.setProperty(QLatin1String(TOLINE),QJSValue(toLine)); + + if (!args.isUndefined()) { + jsonVal.setProperty(QLatin1String(ARGUMENTS),args); + } + + QJSValue json = stringify.call(QJSValueList() << jsonVal); + sendMessage(packMessage(V8REQUEST, json.toString().toUtf8())); +} + +void QJSDebugClient::setBreakpoint(QString type, QString target, int line, int column, bool enabled, QString condition, int ignoreCount) +{ + // { "seq" : , + // "type" : "request", + // "command" : "setbreakpoint", + // "arguments" : { "type" : <"function" or "script" or "scriptId" or "scriptRegExp"> + // "target" : + // "line" : + // "column" : + // "enabled" : + // "condition" : + // "ignoreCount" : + // } + // } + + if (type == QLatin1String(EVENT)) { + QByteArray reply; + QDataStream rs(&reply, QIODevice::WriteOnly); + rs << target.toUtf8() << enabled; + sendMessage(packMessage(QByteArray("breakonsignal"), reply)); + + } else { + VARIANTMAPINIT; + jsonVal.setProperty(QLatin1String(COMMAND),QJSValue(QLatin1String(SETBREAKPOINT))); + + QJSValue args = parser.call(QJSValueList() << obj); + + args.setProperty(QLatin1String(TYPE),QJSValue(type)); + args.setProperty(QLatin1String(TARGET),QJSValue(target)); + + if (line != -1) + args.setProperty(QLatin1String(LINE),QJSValue(line)); + + if (column != -1) + args.setProperty(QLatin1String(COLUMN),QJSValue(column)); + + args.setProperty(QLatin1String(ENABLED),QJSValue(enabled)); + + if (!condition.isEmpty()) + args.setProperty(QLatin1String(CONDITION),QJSValue(condition)); + + if (ignoreCount != -1) + args.setProperty(QLatin1String(IGNORECOUNT),QJSValue(ignoreCount)); + + if (!args.isUndefined()) { + jsonVal.setProperty(QLatin1String(ARGUMENTS),args); + } + + QJSValue json = stringify.call(QJSValueList() << jsonVal); + sendMessage(packMessage(V8REQUEST, json.toString().toUtf8())); + } +} + +void QJSDebugClient::changeBreakpoint(int breakpoint, bool enabled, QString condition, int ignoreCount) +{ + // { "seq" : , + // "type" : "request", + // "command" : "changebreakpoint", + // "arguments" : { "breakpoint" : + // "enabled" : + // "condition" : + // "ignoreCount" : , + // "type" : "request", + // "command" : "clearbreakpoint", + // "arguments" : { "breakpoint" : + // } + // } + VARIANTMAPINIT; + jsonVal.setProperty(QLatin1String(COMMAND),QJSValue(QLatin1String(CLEARBREAKPOINT))); + + QJSValue args = parser.call(QJSValueList() << obj); + + args.setProperty(QLatin1String(BREAKPOINT),QJSValue(breakpoint)); + + if (!args.isUndefined()) { + jsonVal.setProperty(QLatin1String(ARGUMENTS),args); + } + + QJSValue json = stringify.call(QJSValueList() << jsonVal); + sendMessage(packMessage(V8REQUEST, json.toString().toUtf8())); +} + +void QJSDebugClient::setExceptionBreak(Exception type, bool enabled) +{ + // { "seq" : , + // "type" : "request", + // "command" : "setexceptionbreak", + // "arguments" : { "type" : , + // "enabled" : + // } + // } + VARIANTMAPINIT; + jsonVal.setProperty(QLatin1String(COMMAND),QJSValue(QLatin1String(SETEXCEPTIONBREAK))); + + QJSValue args = parser.call(QJSValueList() << obj); + + if (type == All) + args.setProperty(QLatin1String(TYPE),QJSValue(QLatin1String(ALL))); + else if (type == Uncaught) + args.setProperty(QLatin1String(TYPE),QJSValue(QLatin1String(UNCAUGHT))); + + if (enabled) + args.setProperty(QLatin1String(ENABLED),QJSValue(enabled)); + + if (!args.isUndefined()) { + jsonVal.setProperty(QLatin1String(ARGUMENTS),args); + } + + QJSValue json = stringify.call(QJSValueList() << jsonVal); + sendMessage(packMessage(V8REQUEST, json.toString().toUtf8())); +} + +void QJSDebugClient::v8flags(QString flags) +{ + // { "seq" : , + // "type" : "request", + // "command" : "v8flags", + // "arguments" : { "flags" : + // } + // } + VARIANTMAPINIT; + jsonVal.setProperty(QLatin1String(COMMAND),QJSValue(QLatin1String(V8FLAGS))); + + QJSValue args = parser.call(QJSValueList() << obj); + + args.setProperty(QLatin1String(FLAGS),QJSValue(flags)); + + if (!args.isUndefined()) { + jsonVal.setProperty(QLatin1String(ARGUMENTS),args); + } + + QJSValue json = stringify.call(QJSValueList() << jsonVal); + sendMessage(packMessage(V8REQUEST, json.toString().toUtf8())); +} + +void QJSDebugClient::version() +{ + // { "seq" : , + // "type" : "request", + // "command" : "version", + // } + VARIANTMAPINIT; + jsonVal.setProperty(QLatin1String(COMMAND),QJSValue(QLatin1String(VERSION))); + + QJSValue json = stringify.call(QJSValueList() << jsonVal); + sendMessage(packMessage(V8REQUEST, json.toString().toUtf8())); +} + +//void QJSDebugClient::profile(ProfileCommand command) +//{ +//// { "seq" : , +//// "type" : "request", +//// "command" : "profile", +//// "arguments" : { "command" : "resume" or "pause" } +//// } +// VARIANTMAPINIT; +// jsonVal.setProperty(QLatin1String(COMMAND),QJSValue(QLatin1String(PROFILE))); + +// QJSValue args = parser.call(QJSValueList() << obj); + +// if (command == Resume) +// args.setProperty(QLatin1String(COMMAND),QJSValue(QLatin1String(RESUME))); +// else +// args.setProperty(QLatin1String(COMMAND),QJSValue(QLatin1String(PAUSE))); + +// args.setProperty(QLatin1String("modules"),QJSValue(1)); +// if (!args.isUndefined()) { +// jsonVal.setProperty(QLatin1String(ARGUMENTS),args); +// } + +// QJSValue json = stringify.call(QJSValueList() << jsonVal); +// sendMessage(packMessage(V8REQUEST, json.toString().toUtf8())); +//} + +void QJSDebugClient::disconnect() +{ + // { "seq" : , + // "type" : "request", + // "command" : "disconnect", + // } + VARIANTMAPINIT; + jsonVal.setProperty(QLatin1String(COMMAND),QJSValue(QLatin1String(DISCONNECT))); + + QJSValue json = stringify.call(QJSValueList() << jsonVal); + sendMessage(packMessage(DISCONNECT, json.toString().toUtf8())); +} + +void QJSDebugClient::gc() +{ + // { "seq" : , + // "type" : "request", + // "command" : "gc", + // "arguments" : { "type" : , + // } + // } + VARIANTMAPINIT; + jsonVal.setProperty(QLatin1String(COMMAND),QJSValue(QLatin1String(GARBAGECOLLECTOR))); + + QJSValue args = parser.call(QJSValueList() << obj); + + args.setProperty(QLatin1String(TYPE),QJSValue(QLatin1String(ALL))); + + if (!args.isUndefined()) { + jsonVal.setProperty(QLatin1String(ARGUMENTS),args); + } + + QJSValue json = stringify.call(QJSValueList() << jsonVal); + sendMessage(packMessage(V8REQUEST, json.toString().toUtf8())); +} + +void QJSDebugClient::listBreakpoints() +{ + // { "seq" : , + // "type" : "request", + // "command" : "listbreakpoints", + // } + VARIANTMAPINIT; + jsonVal.setProperty(QLatin1String(COMMAND),QJSValue(QLatin1String(LISTBREAKPOINTS))); + + QJSValue json = stringify.call(QJSValueList() << jsonVal); + sendMessage(packMessage(V8REQUEST, json.toString().toUtf8())); +} + +void QJSDebugClient::stateChanged(State state) +{ + if (state == Enabled) { + flushSendBuffer(); + emit enabled(); + } +} + +void QJSDebugClient::messageReceived(const QByteArray &data) +{ + QDataStream ds(data); + QByteArray command; + ds >> command; + + if (command == "V8DEBUG") { + QByteArray type; + ds >> type >> response; + + if (type == CONNECT) { + emit connected(); + + } else if (type == INTERRUPT) { + emit interruptRequested(); + + } else if (type == V8MESSAGE) { + QString jsonString(response); + QVariantMap value = parser.call(QJSValueList() << QJSValue(jsonString)).toVariant().toMap(); + QString type = value.value("type").toString(); + + if (type == "response") { + + if (!value.value("success").toBool()) { +// qDebug() << "Error: The test case will fail since no signal is emitted"; + return; + } + + QString debugCommand(value.value("command").toString()); + if (debugCommand == "backtrace" || + debugCommand == "lookup" || + debugCommand == "setbreakpoint" || + debugCommand == "evaluate" || + debugCommand == "listbreakpoints" || + debugCommand == "version" || + debugCommand == "v8flags" || + debugCommand == "disconnect" || + debugCommand == "gc" || + debugCommand == "changebreakpoint" || + debugCommand == "clearbreakpoint" || + debugCommand == "frame" || + debugCommand == "scope" || + debugCommand == "scopes" || + debugCommand == "scripts" || + debugCommand == "source" || + debugCommand == "setexceptionbreak" /*|| + debugCommand == "profile"*/) { + emit result(); + + } else { + // DO NOTHING + } + + } else if (type == QLatin1String(EVENT)) { + QString event(value.value(QLatin1String(EVENT)).toString()); + + if (event == "break" || + event == "exception") + emit stopped(); + } + + } else if (type == BREAKAFTERCOMPILE) { + emit breakAfterCompileRequested(); + + } + } +} + +void QJSDebugClient::sendMessage(const QByteArray &msg) +{ + if (state() == Enabled) { + QQmlDebugClient::sendMessage(msg); + } else { + sendBuffer.append(msg); + } +} + +void QJSDebugClient::flushSendBuffer() +{ + foreach (const QByteArray &msg, sendBuffer) + QQmlDebugClient::sendMessage(msg); + sendBuffer.clear(); +} + +QByteArray QJSDebugClient::packMessage(const QByteArray &type, const QByteArray &message) +{ + QByteArray reply; + QDataStream rs(&reply, QIODevice::WriteOnly); + QByteArray cmd = "V8DEBUG"; + rs << cmd << type << message; + return reply; +} + +void tst_QQmlDebugJS::initTestCase() +{ + QQmlDataTest::initTestCase(); + t.start(); + process = 0; + client = 0; + connection = 0; +} + +void tst_QQmlDebugJS::cleanupTestCase() +{ + if (process) { + process->stop(); + delete process; + } + + if (client) + delete client; + + if (connection) + delete connection; + +// qDebug() << "Time Elapsed:" << t.elapsed(); +} + +bool tst_QQmlDebugJS::init(const QString &qmlFile, bool blockMode) +{ + connection = new QQmlDebugConnection(); + process = new QQmlDebugProcess(QLibraryInfo::location(QLibraryInfo::BinariesPath) + "/qmlscene"); + client = new QJSDebugClient(connection); + + QStringList systemEnvironment = QProcess::systemEnvironment(); + systemEnvironment << "QML_DISABLE_OPTIMIZER=1"; + process->setEnvironment(systemEnvironment); + if (blockMode) + process->start(QStringList() << QLatin1String(BLOCKMODE) << testFile(qmlFile)); + else + process->start(QStringList() << QLatin1String(NORMALMODE) << testFile(qmlFile)); + + if (!process->waitForSessionStart()) { + return false; + } + + connection->connectToHost("127.0.0.1", 3771); + if (!connection->waitForConnected()) + return false; + + return QQmlDebugTest::waitForSignal(client, SIGNAL(enabled())); +} + +void tst_QQmlDebugJS::cleanup() +{ + if (process) { + process->stop(); + delete process; + } + + if (client) + delete client; + + if (connection) + delete connection; + + process = 0; + client = 0; + connection = 0; +} + +void tst_QQmlDebugJS::connect() +{ + //void connect() + + QVERIFY(init()); + client->connect(); + QVERIFY(QQmlDebugTest::waitForSignal(client, SIGNAL(connected()))); +} + +void tst_QQmlDebugJS::interrupt() +{ + //void connect() + + QVERIFY(init()); + client->connect(); + + client->interrupt(); + QVERIFY(QQmlDebugTest::waitForSignal(client, SIGNAL(interruptRequested()))); +} + +void tst_QQmlDebugJS::breakAfterCompile() +{ + //void breakAfterCompile(bool enabled) + + QVERIFY(init()); + client->breakAfterCompile(true); + client->connect(); + + QVERIFY(QQmlDebugTest::waitForSignal(client, SIGNAL(breakAfterCompileRequested()))); + QVERIFY(QQmlDebugTest::waitForSignal(client, SIGNAL(stopped()))); +} + +void tst_QQmlDebugJS::getVersion() +{ + //void version() + + QVERIFY(init()); + client->connect(); + QVERIFY(QQmlDebugTest::waitForSignal(client, SIGNAL(connected()))); + + client->version(); + QVERIFY(QQmlDebugTest::waitForSignal(client, SIGNAL(result()))); +} + +void tst_QQmlDebugJS::getVersionWhenAttaching() +{ + //void version() + + QVERIFY(init(QLatin1String(TIMER_QMLFILE), false)); + client->connect(); + + client->version(); + QVERIFY(QQmlDebugTest::waitForSignal(client, SIGNAL(result()))); +} + +void tst_QQmlDebugJS::applyV8Flags() +{ + //void v8flags(QString flags) + + QVERIFY(init()); + client->connect(); + + client->v8flags(QString()); + QVERIFY(QQmlDebugTest::waitForSignal(client, SIGNAL(result()))); +} + +void tst_QQmlDebugJS::disconnect() +{ + //void disconnect() + + QVERIFY(init()); + client->connect(); + + client->disconnect(); + QVERIFY(QQmlDebugTest::waitForSignal(client, SIGNAL(result()))); +} + +void tst_QQmlDebugJS::gc() +{ + //void gc() + + QVERIFY(init()); + client->connect(); + + client->gc(); + QVERIFY(QQmlDebugTest::waitForSignal(client, SIGNAL(result()))); +} + +void tst_QQmlDebugJS::listBreakpoints() +{ + //void listBreakpoints() + + int sourceLine1 = 47; + int sourceLine2 = 48; + int sourceLine3 = 49; + + QVERIFY(init()); + client->connect(); + + client->setBreakpoint(QLatin1String(SCRIPTREGEXP), QLatin1String(TEST_QMLFILE), sourceLine1, -1, true); + QVERIFY(QQmlDebugTest::waitForSignal(client, SIGNAL(result()))); + client->setBreakpoint(QLatin1String(SCRIPTREGEXP), QLatin1String(TEST_QMLFILE), sourceLine2, -1, true); + QVERIFY(QQmlDebugTest::waitForSignal(client, SIGNAL(result()))); + client->setBreakpoint(QLatin1String(SCRIPTREGEXP), QLatin1String(TEST_QMLFILE), sourceLine3, -1, true); + QVERIFY(QQmlDebugTest::waitForSignal(client, SIGNAL(result()))); + client->listBreakpoints(); + QVERIFY(QQmlDebugTest::waitForSignal(client, SIGNAL(result()))); + + QString jsonString(client->response); + QVariantMap value = client->parser.call(QJSValueList() << QJSValue(jsonString)).toVariant().toMap(); + + QList breakpoints = value.value("body").toMap().value("breakpoints").toList(); + + QCOMPARE(breakpoints.count(), 3); +} + +void tst_QQmlDebugJS::setBreakpointInScriptOnCompleted() +{ + //void setBreakpoint(QString type, QString target, int line = -1, int column = -1, bool enabled = false, QString condition = QString(), int ignoreCount = -1) + + int sourceLine = 47; + QVERIFY(init(ONCOMPLETED_QMLFILE)); + + client->setBreakpoint(QLatin1String(SCRIPTREGEXP), QLatin1String(ONCOMPLETED_QMLFILE), sourceLine, -1, true); + client->connect(); + QVERIFY(QQmlDebugTest::waitForSignal(client, SIGNAL(stopped()))); + + QString jsonString(client->response); + QVariantMap value = client->parser.call(QJSValueList() << QJSValue(jsonString)).toVariant().toMap(); + + QVariantMap body = value.value("body").toMap(); + + QCOMPARE(body.value("sourceLine").toInt(), sourceLine); + QCOMPARE(QFileInfo(body.value("script").toMap().value("name").toString()).fileName(), QLatin1String(ONCOMPLETED_QMLFILE)); +} + +void tst_QQmlDebugJS::setBreakpointInScriptOnComponentCreated() +{ + //void setBreakpoint(QString type, QString target, int line = -1, int column = -1, bool enabled = false, QString condition = QString(), int ignoreCount = -1) + + int sourceLine = 47; + QVERIFY(init(CREATECOMPONENT_QMLFILE)); + + client->setBreakpoint(QLatin1String(SCRIPTREGEXP), QLatin1String(ONCOMPLETED_QMLFILE), sourceLine, -1, true); + client->connect(); + QVERIFY(QQmlDebugTest::waitForSignal(client, SIGNAL(stopped()))); + + QString jsonString(client->response); + QVariantMap value = client->parser.call(QJSValueList() << QJSValue(jsonString)).toVariant().toMap(); + + QVariantMap body = value.value("body").toMap(); + + QCOMPARE(body.value("sourceLine").toInt(), sourceLine); + QCOMPARE(QFileInfo(body.value("script").toMap().value("name").toString()).fileName(), QLatin1String(ONCOMPLETED_QMLFILE)); +} + +void tst_QQmlDebugJS::setBreakpointInScriptOnTimerCallback() +{ + int sourceLine = 48; + QVERIFY(init(TIMER_QMLFILE)); + + client->connect(); + + client->setBreakpoint(QLatin1String(SCRIPTREGEXP), QLatin1String(TIMER_QMLFILE), sourceLine, -1, true); + QVERIFY(QQmlDebugTest::waitForSignal(client, SIGNAL(stopped()))); + + QString jsonString(client->response); + QVariantMap value = client->parser.call(QJSValueList() << QJSValue(jsonString)).toVariant().toMap(); + + QVariantMap body = value.value("body").toMap(); + + QCOMPARE(body.value("sourceLine").toInt(), sourceLine); + QCOMPARE(QFileInfo(body.value("script").toMap().value("name").toString()).fileName(), QLatin1String(TIMER_QMLFILE)); +} + +void tst_QQmlDebugJS::setBreakpointInScriptInDifferentFile() +{ + //void setBreakpoint(QString type, QString target, int line = -1, int column = -1, bool enabled = false, QString condition = QString(), int ignoreCount = -1) + + int sourceLine = 43; + QVERIFY(init(LOADJSFILE_QMLFILE)); + + client->connect(); + client->setBreakpoint(QLatin1String(SCRIPTREGEXP), QLatin1String(TEST_JSFILE), sourceLine, -1, true); + QVERIFY(QQmlDebugTest::waitForSignal(client, SIGNAL(stopped()))); + + QString jsonString(client->response); + QVariantMap value = client->parser.call(QJSValueList() << QJSValue(jsonString)).toVariant().toMap(); + + QVariantMap body = value.value("body").toMap(); + + QCOMPARE(body.value("sourceLine").toInt(), sourceLine); + QCOMPARE(QFileInfo(body.value("script").toMap().value("name").toString()).fileName(), QLatin1String(TEST_JSFILE)); +} + +void tst_QQmlDebugJS::setBreakpointInScriptOnComment() +{ + //void setBreakpoint(QString type, QString target, int line = -1, int column = -1, bool enabled = false, QString condition = QString(), int ignoreCount = -1) + + int sourceLine = 47; + int actualLine = 49; + QVERIFY(init(BREAKPOINTRELOCATION_QMLFILE)); + + client->connect(); + client->setBreakpoint(QLatin1String(SCRIPTREGEXP), QLatin1String(BREAKPOINTRELOCATION_QMLFILE), sourceLine, -1, true); + QEXPECT_FAIL("", "Relocation of breakpoints is disabled right now", Abort); + QVERIFY(QQmlDebugTest::waitForSignal(client, SIGNAL(stopped()), 1)); + + QString jsonString(client->response); + QVariantMap value = client->parser.call(QJSValueList() << QJSValue(jsonString)).toVariant().toMap(); + + QVariantMap body = value.value("body").toMap(); + + QCOMPARE(body.value("sourceLine").toInt(), actualLine); + QCOMPARE(QFileInfo(body.value("script").toMap().value("name").toString()).fileName(), QLatin1String(BREAKPOINTRELOCATION_QMLFILE)); +} + +void tst_QQmlDebugJS::setBreakpointInScriptOnEmptyLine() +{ + //void setBreakpoint(QString type, QString target, int line = -1, int column = -1, bool enabled = false, QString condition = QString(), int ignoreCount = -1) + + int sourceLine = 48; + int actualLine = 49; + QVERIFY(init(BREAKPOINTRELOCATION_QMLFILE)); + + client->connect(); + client->setBreakpoint(QLatin1String(SCRIPTREGEXP), QLatin1String(BREAKPOINTRELOCATION_QMLFILE), sourceLine, -1, true); + QEXPECT_FAIL("", "Relocation of breakpoints is disabled right now", Abort); + QVERIFY(QQmlDebugTest::waitForSignal(client, SIGNAL(stopped()), 1)); + + QString jsonString(client->response); + QVariantMap value = client->parser.call(QJSValueList() << QJSValue(jsonString)).toVariant().toMap(); + + QVariantMap body = value.value("body").toMap(); + + QCOMPARE(body.value("sourceLine").toInt(), actualLine); + QCOMPARE(QFileInfo(body.value("script").toMap().value("name").toString()).fileName(), QLatin1String(BREAKPOINTRELOCATION_QMLFILE)); +} + +void tst_QQmlDebugJS::setBreakpointInScriptWithCondition() +{ + //void setBreakpoint(QString type, QString target, int line = -1, int column = -1, bool enabled = false, QString condition = QString(), int ignoreCount = -1) + + int out = 10; + int sourceLine = 50; + QVERIFY(init(CONDITION_QMLFILE)); + + client->connect(); + client->setBreakpoint(QLatin1String(SCRIPTREGEXP), QLatin1String(CONDITION_QMLFILE), sourceLine, 1, true, QLatin1String("a > 10")); + QVERIFY(QQmlDebugTest::waitForSignal(client, SIGNAL(stopped()))); + + //Get the frame index + QString jsonString = client->response; + QVariantMap value = client->parser.call(QJSValueList() << QJSValue(jsonString)).toVariant().toMap(); + + QVariantMap body = value.value("body").toMap(); + + int frameIndex = body.value("index").toInt(); + + //Verify the value of 'result' + client->evaluate(QLatin1String("a"),frameIndex); + + QVERIFY(QQmlDebugTest::waitForSignal(client, SIGNAL(result()))); + + jsonString = client->response; + value = client->parser.call(QJSValueList() << QJSValue(jsonString)).toVariant().toMap(); + + body = value.value("body").toMap(); + + QVERIFY(body.value("value").toInt() > out); +} + +void tst_QQmlDebugJS::setBreakpointWhenAttaching() +{ + int sourceLine = 49; + QVERIFY(init(QLatin1String(TIMER_QMLFILE), false)); + + client->connect(); + client->setBreakpoint(QLatin1String(SCRIPTREGEXP), QLatin1String(TIMER_QMLFILE), sourceLine); + QVERIFY(QQmlDebugTest::waitForSignal(client, SIGNAL(stopped()))); +} + +//void tst_QQmlDebugJS::setBreakpointInFunction() +//{ +// //void setBreakpoint(QString type, QString target, int line = -1, int column = -1, bool enabled = false, QString condition = QString(), int ignoreCount = -1) + +// int actualLine = 31; + +// client->connect(); +// client->setBreakpoint(QLatin1String(FUNCTION), QLatin1String("doSomethingElse"), -1, -1, true); + +// QVERIFY(QQmlDebugTest::waitForSignal(client, SIGNAL(stopped()))); + +// QString jsonString(client->response); +// QVariantMap value = client->parser.call(QJSValueList() << QJSValue(jsonString)).toVariant().toMap(); + +// QVariantMap body = value.value("body").toMap(); + +// QCOMPARE(body.value("sourceLine").toInt(), actualLine); +// QCOMPARE(QFileInfo(body.value("script").toMap().value("name").toString()).fileName(), QLatin1String(QMLFILE)); +//} + +void tst_QQmlDebugJS::setBreakpointOnEvent() +{ + //void setBreakpoint(QString type, QString target, int line = -1, int column = -1, bool enabled = false, QString condition = QString(), int ignoreCount = -1) + + QVERIFY(init(TIMER_QMLFILE)); + + client->connect(); + + client->setBreakpoint(QLatin1String(EVENT), QLatin1String("triggered"), -1, -1, true); + QVERIFY(QQmlDebugTest::waitForSignal(client, SIGNAL(stopped()))); + + QString jsonString(client->response); + QVariantMap value = client->parser.call(QJSValueList() << QJSValue(jsonString)).toVariant().toMap(); + + QVariantMap body = value.value("body").toMap(); + + QCOMPARE(QFileInfo(body.value("script").toMap().value("name").toString()).fileName(), QLatin1String(TIMER_QMLFILE)); +} + + +void tst_QQmlDebugJS::changeBreakpoint() +{ + //void changeBreakpoint(int breakpoint, bool enabled = false, QString condition = QString(), int ignoreCount = -1) + + int sourceLine1 = 50; + int sourceLine2 = 51; + QVERIFY(init(CHANGEBREAKPOINT_QMLFILE)); + + client->connect(); + client->setBreakpoint(QLatin1String(SCRIPTREGEXP), QLatin1String(CHANGEBREAKPOINT_QMLFILE), sourceLine2, -1, true); + client->setBreakpoint(QLatin1String(SCRIPTREGEXP), QLatin1String(CHANGEBREAKPOINT_QMLFILE), sourceLine1, -1, true); + + QVERIFY(QQmlDebugTest::waitForSignal(client, SIGNAL(stopped()))); + + //Will hit 1st brakpoint, change this breakpoint enable = false + QString jsonString(client->response); + QVariantMap value = client->parser.call(QJSValueList() << QJSValue(jsonString)).toVariant().toMap(); + + QVariantMap body = value.value("body").toMap(); + QList breakpointsHit = body.value("breakpoints").toList(); + + int breakpoint = breakpointsHit.at(0).toInt(); + client->changeBreakpoint(breakpoint,false); + + QVERIFY(QQmlDebugTest::waitForSignal(client, SIGNAL(result()))); + + //Continue with debugging + client->continueDebugging(QJSDebugClient::Continue); + //Hit 2nd breakpoint + QVERIFY(QQmlDebugTest::waitForSignal(client, SIGNAL(stopped()))); + + //Continue with debugging + client->continueDebugging(QJSDebugClient::Continue); + //Should stop at 2nd breakpoint + QVERIFY(QQmlDebugTest::waitForSignal(client, SIGNAL(stopped()))); + + jsonString = client->response; + value = client->parser.call(QJSValueList() << QJSValue(jsonString)).toVariant().toMap(); + + body = value.value("body").toMap(); + + QCOMPARE(body.value("sourceLine").toInt(), sourceLine2); +} + +void tst_QQmlDebugJS::changeBreakpointOnCondition() +{ + //void changeBreakpoint(int breakpoint, bool enabled = false, QString condition = QString(), int ignoreCount = -1) + + int sourceLine1 = 50; + int sourceLine2 = 51; + + QVERIFY(init(CHANGEBREAKPOINT_QMLFILE)); + + client->connect(); + client->setBreakpoint(QLatin1String(SCRIPTREGEXP), QLatin1String(CHANGEBREAKPOINT_QMLFILE), sourceLine1, -1, true); + client->setBreakpoint(QLatin1String(SCRIPTREGEXP), QLatin1String(CHANGEBREAKPOINT_QMLFILE), sourceLine2, -1, true); + + QVERIFY(QQmlDebugTest::waitForSignal(client, SIGNAL(stopped()))); + + //Will hit 1st brakpoint, change this breakpoint enable = false + QString jsonString(client->response); + QVariantMap value = client->parser.call(QJSValueList() << QJSValue(jsonString)).toVariant().toMap(); + + QVariantMap body = value.value("body").toMap(); + QList breakpointsHit = body.value("breakpoints").toList(); + + int breakpoint = breakpointsHit.at(0).toInt(); + client->changeBreakpoint(breakpoint, false, QLatin1String("d == 0")); + + QVERIFY(QQmlDebugTest::waitForSignal(client, SIGNAL(result()))); + + //Continue with debugging + client->continueDebugging(QJSDebugClient::Continue); + //Hit 2nd breakpoint + QVERIFY(QQmlDebugTest::waitForSignal(client, SIGNAL(stopped()))); + + //Continue with debugging + client->continueDebugging(QJSDebugClient::Continue); + //Should stop at 2nd breakpoint + QVERIFY(QQmlDebugTest::waitForSignal(client, SIGNAL(stopped()))); + + jsonString = client->response; + value = client->parser.call(QJSValueList() << QJSValue(jsonString)).toVariant().toMap(); + + body = value.value("body").toMap(); + + QCOMPARE(body.value("sourceLine").toInt(), sourceLine2); + +} + +void tst_QQmlDebugJS::clearBreakpoint() +{ + //void clearBreakpoint(int breakpoint); + + int sourceLine1 = 50; + int sourceLine2 = 51; + QVERIFY(init(CHANGEBREAKPOINT_QMLFILE)); + + client->connect(); + client->setBreakpoint(QLatin1String(SCRIPTREGEXP), QLatin1String(CHANGEBREAKPOINT_QMLFILE), sourceLine1, -1, true); + client->setBreakpoint(QLatin1String(SCRIPTREGEXP), QLatin1String(CHANGEBREAKPOINT_QMLFILE), sourceLine2, -1, true); + + QVERIFY(QQmlDebugTest::waitForSignal(client, SIGNAL(stopped()))); + + //Will hit 1st brakpoint, change this breakpoint enable = false + QString jsonString(client->response); + QVariantMap value = client->parser.call(QJSValueList() << QJSValue(jsonString)).toVariant().toMap(); + + QVariantMap body = value.value("body").toMap(); + QList breakpointsHit = body.value("breakpoints").toList(); + + int breakpoint = breakpointsHit.at(0).toInt(); + client->clearBreakpoint(breakpoint); + + QVERIFY(QQmlDebugTest::waitForSignal(client, SIGNAL(result()))); + + //Continue with debugging + client->continueDebugging(QJSDebugClient::Continue); + //Hit 2nd breakpoint + QVERIFY(QQmlDebugTest::waitForSignal(client, SIGNAL(stopped()))); + + //Continue with debugging + client->continueDebugging(QJSDebugClient::Continue); + //Should stop at 2nd breakpoint + QVERIFY(QQmlDebugTest::waitForSignal(client, SIGNAL(stopped()))); + + jsonString = client->response; + value = client->parser.call(QJSValueList() << QJSValue(jsonString)).toVariant().toMap(); + + body = value.value("body").toMap(); + + QCOMPARE(body.value("sourceLine").toInt(), sourceLine2); +} + +void tst_QQmlDebugJS::setExceptionBreak() +{ + //void setExceptionBreak(QString type, bool enabled = false); + + QVERIFY(init(EXCEPTION_QMLFILE)); + client->setExceptionBreak(QJSDebugClient::All,true); + client->connect(); + QVERIFY(QQmlDebugTest::waitForSignal(client, SIGNAL(stopped()))); +} + +void tst_QQmlDebugJS::stepNext() +{ + //void continueDebugging(StepAction stepAction, int stepCount = 1); + + int sourceLine = 50; + QVERIFY(init(STEPACTION_QMLFILE)); + + client->setBreakpoint(QLatin1String(SCRIPTREGEXP), QLatin1String(STEPACTION_QMLFILE), sourceLine, -1, true); + client->connect(); + QVERIFY(QQmlDebugTest::waitForSignal(client, SIGNAL(stopped()))); + + client->continueDebugging(QJSDebugClient::Next); + QVERIFY(QQmlDebugTest::waitForSignal(client, SIGNAL(stopped()))); + + QString jsonString(client->response); + QVariantMap value = client->parser.call(QJSValueList() << QJSValue(jsonString)).toVariant().toMap(); + + QVariantMap body = value.value("body").toMap(); + + QCOMPARE(body.value("sourceLine").toInt(), sourceLine + 1); + QCOMPARE(QFileInfo(body.value("script").toMap().value("name").toString()).fileName(), QLatin1String(STEPACTION_QMLFILE)); +} + +void tst_QQmlDebugJS::stepNextWithCount() +{ + //void continueDebugging(StepAction stepAction, int stepCount = 1); + + int sourceLine = 50; + QVERIFY(init(STEPACTION_QMLFILE)); + + client->connect(); + client->setBreakpoint(QLatin1String(SCRIPTREGEXP), QLatin1String(STEPACTION_QMLFILE), sourceLine, -1, true); + QVERIFY(QQmlDebugTest::waitForSignal(client, SIGNAL(stopped()))); + + client->continueDebugging(QJSDebugClient::Next, 2); + QVERIFY(QQmlDebugTest::waitForSignal(client, SIGNAL(stopped()))); + + QString jsonString(client->response); + QVariantMap value = client->parser.call(QJSValueList() << QJSValue(jsonString)).toVariant().toMap(); + + QVariantMap body = value.value("body").toMap(); + + QCOMPARE(body.value("sourceLine").toInt(), sourceLine + 2); + QCOMPARE(QFileInfo(body.value("script").toMap().value("name").toString()).fileName(), QLatin1String(STEPACTION_QMLFILE)); +} + +void tst_QQmlDebugJS::stepIn() +{ + //void continueDebugging(StepAction stepAction, int stepCount = 1); + + int sourceLine = 54; + int actualLine = 50; + QVERIFY(init(STEPACTION_QMLFILE)); + + client->connect(); + client->setBreakpoint(QLatin1String(SCRIPTREGEXP), QLatin1String(STEPACTION_QMLFILE), sourceLine, 1, true); + QVERIFY(QQmlDebugTest::waitForSignal(client, SIGNAL(stopped()))); + + client->continueDebugging(QJSDebugClient::In); + QVERIFY(QQmlDebugTest::waitForSignal(client, SIGNAL(stopped()))); + + QString jsonString(client->response); + QVariantMap value = client->parser.call(QJSValueList() << QJSValue(jsonString)).toVariant().toMap(); + + QVariantMap body = value.value("body").toMap(); + + QCOMPARE(body.value("sourceLine").toInt(), actualLine); + QCOMPARE(QFileInfo(body.value("script").toMap().value("name").toString()).fileName(), QLatin1String(STEPACTION_QMLFILE)); +} + +void tst_QQmlDebugJS::stepOut() +{ + //void continueDebugging(StepAction stepAction, int stepCount = 1); + + int sourceLine = 50; + int actualLine = 54; + QVERIFY(init(STEPACTION_QMLFILE)); + + client->connect(); + client->setBreakpoint(QLatin1String(SCRIPTREGEXP), QLatin1String(STEPACTION_QMLFILE), sourceLine, -1, true); + QVERIFY(QQmlDebugTest::waitForSignal(client, SIGNAL(stopped()))); + + client->continueDebugging(QJSDebugClient::Out); + QVERIFY(QQmlDebugTest::waitForSignal(client, SIGNAL(stopped()))); + + QString jsonString(client->response); + QVariantMap value = client->parser.call(QJSValueList() << QJSValue(jsonString)).toVariant().toMap(); + + QVariantMap body = value.value("body").toMap(); + + QCOMPARE(body.value("sourceLine").toInt(), actualLine); + QCOMPARE(QFileInfo(body.value("script").toMap().value("name").toString()).fileName(), QLatin1String(STEPACTION_QMLFILE)); +} + +void tst_QQmlDebugJS::continueDebugging() +{ + //void continueDebugging(StepAction stepAction, int stepCount = 1); + + int sourceLine1 = 54; + int sourceLine2 = 51; + QVERIFY(init(STEPACTION_QMLFILE)); + + client->connect(); + client->setBreakpoint(QLatin1String(SCRIPTREGEXP), QLatin1String(STEPACTION_QMLFILE), sourceLine1, -1, true); + client->setBreakpoint(QLatin1String(SCRIPTREGEXP), QLatin1String(STEPACTION_QMLFILE), sourceLine2, -1, true); + QVERIFY(QQmlDebugTest::waitForSignal(client, SIGNAL(stopped()))); + + client->continueDebugging(QJSDebugClient::Continue); + QVERIFY(QQmlDebugTest::waitForSignal(client, SIGNAL(stopped()))); + + QString jsonString(client->response); + QVariantMap value = client->parser.call(QJSValueList() << QJSValue(jsonString)).toVariant().toMap(); + + QVariantMap body = value.value("body").toMap(); + + QCOMPARE(body.value("sourceLine").toInt(), sourceLine2); + QCOMPARE(QFileInfo(body.value("script").toMap().value("name").toString()).fileName(), QLatin1String(STEPACTION_QMLFILE)); +} + +void tst_QQmlDebugJS::backtrace() +{ + //void backtrace(int fromFrame = -1, int toFrame = -1, bool bottom = false); + + int sourceLine = 47; + QVERIFY(init(ONCOMPLETED_QMLFILE)); + + client->setBreakpoint(QLatin1String(SCRIPTREGEXP), QLatin1String(ONCOMPLETED_QMLFILE), sourceLine, -1, true); + client->connect(); + QVERIFY(QQmlDebugTest::waitForSignal(client, SIGNAL(stopped()))); + + client->backtrace(); + QVERIFY(QQmlDebugTest::waitForSignal(client, SIGNAL(result()))); +} + +void tst_QQmlDebugJS::getFrameDetails() +{ + //void frame(int number = -1); + + int sourceLine = 47; + QVERIFY(init(ONCOMPLETED_QMLFILE)); + + client->setBreakpoint(QLatin1String(SCRIPTREGEXP), QLatin1String(ONCOMPLETED_QMLFILE), sourceLine, -1, true); + client->connect(); + QVERIFY(QQmlDebugTest::waitForSignal(client, SIGNAL(stopped()))); + + client->frame(); + QVERIFY(QQmlDebugTest::waitForSignal(client, SIGNAL(result()))); +} + +void tst_QQmlDebugJS::getScopeDetails() +{ + //void scope(int number = -1, int frameNumber = -1); + + int sourceLine = 47; + QVERIFY(init(ONCOMPLETED_QMLFILE)); + + client->setBreakpoint(QLatin1String(SCRIPTREGEXP), QLatin1String(ONCOMPLETED_QMLFILE), sourceLine, -1, true); + client->connect(); + QVERIFY(QQmlDebugTest::waitForSignal(client, SIGNAL(stopped()))); + + client->scope(); + QVERIFY(QQmlDebugTest::waitForSignal(client, SIGNAL(result()))); +} + +void tst_QQmlDebugJS::evaluateInGlobalScope() +{ + //void evaluate(QString expr, bool global = false, bool disableBreak = false, int frame = -1, const QVariantMap &addContext = QVariantMap()); + + QVERIFY(init()); + + client->connect(); + client->evaluate(QLatin1String("print('Hello World')"), true); + QVERIFY(QQmlDebugTest::waitForSignal(client, SIGNAL(result()))); + + //Verify the value of 'print' + QString jsonString(client->response); + QVariantMap value = client->parser.call(QJSValueList() << QJSValue(jsonString)).toVariant().toMap(); + + QVariantMap body = value.value("body").toMap(); + + QCOMPARE(body.value("text").toString(),QLatin1String("undefined")); +} + +void tst_QQmlDebugJS::evaluateInLocalScope() +{ + //void evaluate(QString expr, bool global = false, bool disableBreak = false, int frame = -1, const QVariantMap &addContext = QVariantMap()); + + int sourceLine = 47; + QVERIFY(init(ONCOMPLETED_QMLFILE)); + + client->setBreakpoint(QLatin1String(SCRIPTREGEXP), QLatin1String(ONCOMPLETED_QMLFILE), sourceLine, -1, true); + client->connect(); + QVERIFY(QQmlDebugTest::waitForSignal(client, SIGNAL(stopped()))); + + client->frame(); + QVERIFY(QQmlDebugTest::waitForSignal(client, SIGNAL(result()))); + + //Get the frame index + QString jsonString(client->response); + QVariantMap value = client->parser.call(QJSValueList() << QJSValue(jsonString)).toVariant().toMap(); + + QVariantMap body = value.value("body").toMap(); + + int frameIndex = body.value("index").toInt(); + + client->evaluate(QLatin1String("root.a"), frameIndex); + QVERIFY(QQmlDebugTest::waitForSignal(client, SIGNAL(result()))); + + //Verify the value of 'timer.interval' + jsonString = client->response; + value = client->parser.call(QJSValueList() << QJSValue(jsonString)).toVariant().toMap(); + + body = value.value("body").toMap(); + + QCOMPARE(body.value("value").toInt(),10); +} + +void tst_QQmlDebugJS::getScopes() +{ + //void scopes(int frameNumber = -1); + + int sourceLine = 47; + QVERIFY(init(ONCOMPLETED_QMLFILE)); + + client->setBreakpoint(QLatin1String(SCRIPTREGEXP), QLatin1String(ONCOMPLETED_QMLFILE), sourceLine, -1, true); + client->connect(); + QVERIFY(QQmlDebugTest::waitForSignal(client, SIGNAL(stopped()))); + + client->scopes(); + QVERIFY(QQmlDebugTest::waitForSignal(client, SIGNAL(result()))); +} + +void tst_QQmlDebugJS::getScripts() +{ + //void scripts(int types = -1, QList ids = QList(), bool includeSource = false, QVariant filter = QVariant()); + +#ifdef Q_OS_MAC + QSKIP("QTBUG-23475 - Unreliable test on Mac OS X"); +#endif + + QVERIFY(init()); + + client->connect(); + + client->scripts(); + QVERIFY(QQmlDebugTest::waitForSignal(client, SIGNAL(result()))); + QString jsonString(client->response); + QVariantMap value = client->parser.call(QJSValueList() + << QJSValue(jsonString)).toVariant().toMap(); + + QList scripts = value.value("body").toList(); + + QCOMPARE(scripts.count(), 2); +} + +void tst_QQmlDebugJS::getSource() +{ + //void source(int frame = -1, int fromLine = -1, int toLine = -1); + + int sourceLine = 47; + QVERIFY(init(ONCOMPLETED_QMLFILE)); + + client->setBreakpoint(QLatin1String(SCRIPTREGEXP), QLatin1String(ONCOMPLETED_QMLFILE), sourceLine, -1, true); + client->connect(); + QVERIFY(QQmlDebugTest::waitForSignal(client, SIGNAL(stopped()))); + + client->source(); + QVERIFY(QQmlDebugTest::waitForSignal(client, SIGNAL(result()))); +} + +QTEST_MAIN(tst_QQmlDebugJS) + +#include "tst_qqmldebugjs.moc" + diff --git a/tests/auto/qml/debugger/qqmldebugservice/qqmldebugservice.pro b/tests/auto/qml/debugger/qqmldebugservice/qqmldebugservice.pro new file mode 100644 index 0000000000..ecb3b2ca2c --- /dev/null +++ b/tests/auto/qml/debugger/qqmldebugservice/qqmldebugservice.pro @@ -0,0 +1,11 @@ +CONFIG += testcase +TARGET = tst_qqmldebugservice +macx:CONFIG -= app_bundle + +HEADERS += ../shared/debugutil_p.h +SOURCES += tst_qqmldebugservice.cpp \ + ../shared/debugutil.cpp + +CONFIG += parallel_test declarative_debug + +QT += qml-private testlib diff --git a/tests/auto/qml/debugger/qqmldebugservice/tst_qqmldebugservice.cpp b/tests/auto/qml/debugger/qqmldebugservice/tst_qqmldebugservice.cpp new file mode 100644 index 0000000000..5af38c2af0 --- /dev/null +++ b/tests/auto/qml/debugger/qqmldebugservice/tst_qqmldebugservice.cpp @@ -0,0 +1,216 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include +#include +#include +#include +#include +#include + +#include + +#include +#include + +#include "../../../shared/util.h" +#include "../shared/debugutil_p.h" + +#define PORT 13769 +#define STR_PORT "13769" + +class tst_QQmlDebugService : public QObject +{ + Q_OBJECT +private: + QQmlDebugConnection *m_conn; + +private slots: + void initTestCase(); + + void name(); + void version(); + void state(); + void sendMessage(); + void idForObject(); + void objectForId(); + void objectToString(); +}; + +void tst_QQmlDebugService::initTestCase() +{ + const QString waitingMsg = QString("QQmlDebugServer: Waiting for connection on port %1...").arg(PORT); + QTest::ignoreMessage(QtWarningMsg, waitingMsg.toAscii().constData()); + new QQmlEngine(this); + + m_conn = new QQmlDebugConnection(this); + + + QTest::ignoreMessage(QtWarningMsg, "QQmlDebugServer: Connection established"); + for (int i = 0; i < 50; ++i) { + // try for 5 seconds ... + m_conn->connectToHost("127.0.0.1", PORT); + if (m_conn->waitForConnected()) + break; + QTest::qSleep(100); + } + QVERIFY(m_conn->isConnected()); + + QTRY_VERIFY(QQmlDebugService::hasDebuggingClient()); +} + +void tst_QQmlDebugService::name() +{ + QString name = "tst_QQmlDebugService::name()"; + + QQmlDebugService service(name, 1); + QCOMPARE(service.name(), name); +} + +void tst_QQmlDebugService::version() +{ + QString name = "tst_QQmlDebugService::name()"; + + QQmlDebugService service(name, 2); + QCOMPARE(service.version(), 2.0f); +} + +void tst_QQmlDebugService::state() +{ + QQmlDebugTestService service("tst_QQmlDebugService::state()"); + QCOMPARE(service.state(), QQmlDebugService::Unavailable); + + { + QQmlDebugTestClient client("tst_QQmlDebugService::state()", m_conn); + QTRY_COMPARE(client.state(), QQmlDebugClient::Enabled); + QTRY_COMPARE(service.state(), QQmlDebugService::Enabled); + } + + + QTRY_COMPARE(service.state(), QQmlDebugService::Unavailable); + + QTest::ignoreMessage(QtWarningMsg, "QQmlDebugService: Conflicting plugin name \"tst_QQmlDebugService::state()\" "); + QQmlDebugTestService duplicate("tst_QQmlDebugService::state()"); + QCOMPARE(duplicate.state(), QQmlDebugService::NotConnected); +} + +void tst_QQmlDebugService::sendMessage() +{ + QQmlDebugTestService service("tst_QQmlDebugService::sendMessage()"); + QQmlDebugTestClient client("tst_QQmlDebugService::sendMessage()", m_conn); + + QByteArray msg = "hello!"; + + QTRY_COMPARE(client.state(), QQmlDebugClient::Enabled); + QTRY_COMPARE(service.state(), QQmlDebugService::Enabled); + + client.sendMessage(msg); + QByteArray resp = client.waitForResponse(); + QCOMPARE(resp, msg); + + QTest::ignoreMessage(QtWarningMsg, "QQmlDebugService: Conflicting plugin name \"tst_QQmlDebugService::sendMessage()\" "); + QQmlDebugTestService duplicate("tst_QQmlDebugService::sendMessage()"); + duplicate.sendMessage("msg"); +} + +void tst_QQmlDebugService::idForObject() +{ + QCOMPARE(QQmlDebugService::idForObject(0), -1); + + QObject *objA = new QObject; + + int idA = QQmlDebugService::idForObject(objA); + QVERIFY(idA >= 0); + QCOMPARE(QQmlDebugService::objectForId(idA), objA); + + int idAA = QQmlDebugService::idForObject(objA); + QCOMPARE(idAA, idA); + + QObject *objB = new QObject; + int idB = QQmlDebugService::idForObject(objB); + QVERIFY(idB != idA); + QCOMPARE(QQmlDebugService::objectForId(idB), objB); + + delete objA; + delete objB; +} + +void tst_QQmlDebugService::objectForId() +{ + QCOMPARE(QQmlDebugService::objectForId(-1), static_cast(0)); + QCOMPARE(QQmlDebugService::objectForId(1), static_cast(0)); + + QObject *obj = new QObject; + int id = QQmlDebugService::idForObject(obj); + QCOMPARE(QQmlDebugService::objectForId(id), obj); + + delete obj; + QCOMPARE(QQmlDebugService::objectForId(id), static_cast(0)); +} + +void tst_QQmlDebugService::objectToString() +{ + QCOMPARE(QQmlDebugService::objectToString(0), QString("NULL")); + + QObject *obj = new QObject; + QCOMPARE(QQmlDebugService::objectToString(obj), QString("QObject: ")); + + obj->setObjectName("Hello"); + QCOMPARE(QQmlDebugService::objectToString(obj), QString("QObject: Hello")); + delete obj; +} + + +int main(int argc, char *argv[]) +{ + int _argc = argc + 1; + char **_argv = new char*[_argc]; + for (int i = 0; i < argc; ++i) + _argv[i] = argv[i]; + char arg[] = "-qmljsdebugger=port:" STR_PORT; + _argv[_argc - 1] = arg; + + QGuiApplication app(_argc, _argv); + tst_QQmlDebugService tc; + return QTest::qExec(&tc, _argc, _argv); + delete _argv; +} + +#include "tst_qqmldebugservice.moc" diff --git a/tests/auto/qml/debugger/qqmlenginedebug/qqmlenginedebug.pro b/tests/auto/qml/debugger/qqmlenginedebug/qqmlenginedebug.pro new file mode 100644 index 0000000000..529c4667cf --- /dev/null +++ b/tests/auto/qml/debugger/qqmlenginedebug/qqmlenginedebug.pro @@ -0,0 +1,11 @@ +CONFIG += testcase +TARGET = tst_qqmlenginedebug +macx:CONFIG -= app_bundle + +HEADERS += ../shared/debugutil_p.h +SOURCES += tst_qqmlenginedebug.cpp \ + ../shared/debugutil.cpp + +CONFIG += parallel_test declarative_debug + +QT += core-private qml-private quick-private v8-private testlib diff --git a/tests/auto/qml/debugger/qqmlenginedebug/tst_qqmlenginedebug.cpp b/tests/auto/qml/debugger/qqmlenginedebug/tst_qqmlenginedebug.cpp new file mode 100644 index 0000000000..21ed2f40ff --- /dev/null +++ b/tests/auto/qml/debugger/qqmlenginedebug/tst_qqmlenginedebug.cpp @@ -0,0 +1,1235 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include + +#include "../shared/debugutil_p.h" + +Q_DECLARE_METATYPE(QQmlDebugWatch::State) + +class tst_QQmlEngineDebug : public QObject +{ + Q_OBJECT + +private: + QQmlDebugObjectReference findRootObject(int context = 0, bool recursive = false); + QQmlDebugPropertyReference findProperty(const QList &props, const QString &name) const; + void waitForQuery(QQmlDebugQuery *query); + + void recursiveObjectTest(QObject *o, const QQmlDebugObjectReference &oref, bool recursive) const; + + void recursiveCompareObjects(const QQmlDebugObjectReference &a, const QQmlDebugObjectReference &b) const; + void recursiveCompareContexts(const QQmlDebugContextReference &a, const QQmlDebugContextReference &b) const; + void compareProperties(const QQmlDebugPropertyReference &a, const QQmlDebugPropertyReference &b) const; + + QQmlDebugConnection *m_conn; + QQmlEngineDebug *m_dbg; + QQmlEngine *m_engine; + QQuickItem *m_rootItem; + + QObjectList m_components; + +private slots: + void initTestCase(); + void cleanupTestCase(); + + void watch_property(); + void watch_object(); + void watch_expression(); + void watch_expression_data(); + void watch_context(); + void watch_file(); + + void queryAvailableEngines(); + void queryRootContexts(); + void queryObject(); + void queryObject_data(); + void queryExpressionResult(); + void queryExpressionResult_data(); + + void tst_QQmlDebugFileReference(); + void tst_QQmlDebugEngineReference(); + void tst_QQmlDebugObjectReference(); + void tst_QQmlDebugContextReference(); + void tst_QQmlDebugPropertyReference(); + + void setBindingForObject(); + void setMethodBody(); + void queryObjectTree(); + void setBindingInStates(); +}; + +class NonScriptProperty : public QObject { + Q_OBJECT + Q_PROPERTY(int nonScriptProp READ nonScriptProp WRITE setNonScriptProp NOTIFY nonScriptPropChanged SCRIPTABLE false) +public: + int nonScriptProp() const { return 0; } + void setNonScriptProp(int) {} +signals: + void nonScriptPropChanged(); +}; +QML_DECLARE_TYPE(NonScriptProperty) + + +QQmlDebugObjectReference tst_QQmlEngineDebug::findRootObject(int context, bool recursive) +{ + QQmlDebugEnginesQuery *q_engines = m_dbg->queryAvailableEngines(this); + waitForQuery(q_engines); + + if (q_engines->engines().count() == 0) + return QQmlDebugObjectReference(); + QQmlDebugRootContextQuery *q_context = m_dbg->queryRootContexts(q_engines->engines()[0].debugId(), this); + waitForQuery(q_context); + + if (q_context->rootContext().objects().count() == 0) + return QQmlDebugObjectReference(); + QQmlDebugObjectQuery *q_obj = recursive ? + m_dbg->queryObjectRecursive(q_context->rootContext().objects()[context], this) : + m_dbg->queryObject(q_context->rootContext().objects()[context], this); + waitForQuery(q_obj); + + QQmlDebugObjectReference result = q_obj->object(); + + delete q_engines; + delete q_context; + delete q_obj; + + return result; +} + +QQmlDebugPropertyReference tst_QQmlEngineDebug::findProperty(const QList &props, const QString &name) const +{ + foreach(const QQmlDebugPropertyReference &p, props) { + if (p.name() == name) + return p; + } + return QQmlDebugPropertyReference(); +} + +void tst_QQmlEngineDebug::waitForQuery(QQmlDebugQuery *query) +{ + QVERIFY(query); + QCOMPARE(query->parent(), qobject_cast(this)); + QVERIFY(query->state() == QQmlDebugQuery::Waiting); + if (!QQmlDebugTest::waitForSignal(query, SIGNAL(stateChanged(QQmlDebugQuery::State)))) + QFAIL("query timed out"); +} + +void tst_QQmlEngineDebug::recursiveObjectTest(QObject *o, const QQmlDebugObjectReference &oref, bool recursive) const +{ + const QMetaObject *meta = o->metaObject(); + + QQmlType *type = QQmlMetaType::qmlType(meta); + QString className = type ? QString(type->qmlTypeName()) : QString(meta->className()); + className = className.mid(className.lastIndexOf(QLatin1Char('/'))+1); + + QCOMPARE(oref.debugId(), QQmlDebugService::idForObject(o)); + QCOMPARE(oref.name(), o->objectName()); + QCOMPARE(oref.className(), className); + QCOMPARE(oref.contextDebugId(), QQmlDebugService::idForObject(qmlContext(o))); + + const QObjectList &children = o->children(); + for (int i=0; i= 0); + + QQmlDebugObjectReference cref; + foreach (const QQmlDebugObjectReference &ref, oref.children()) { + if (ref.debugId() == debugId) { + cref = ref; + break; + } + } + QVERIFY(cref.debugId() >= 0); + + if (recursive) + recursiveObjectTest(child, cref, true); + } + + foreach (const QQmlDebugPropertyReference &p, oref.properties()) { + QCOMPARE(p.objectDebugId(), QQmlDebugService::idForObject(o)); + + // signal properties are fake - they are generated from QQmlBoundSignal children + if (p.name().startsWith("on") && p.name().length() > 2 && p.name()[2].isUpper()) { + QList signalHandlers = o->findChildren(); + QString signal = p.value().toString(); + bool found = false; + for (int i = 0; i < signalHandlers.count(); ++i) + if (signalHandlers.at(i)->expression()->expression() == signal) { + found = true; + break; + } + QVERIFY(found); + QVERIFY(p.valueTypeName().isEmpty()); + QVERIFY(p.binding().isEmpty()); + QVERIFY(!p.hasNotifySignal()); + continue; + } + + QMetaProperty pmeta = meta->property(meta->indexOfProperty(p.name().toUtf8().constData())); + + QCOMPARE(p.name(), QString::fromUtf8(pmeta.name())); + + if (pmeta.type() < QVariant::UserType && pmeta.userType() != QMetaType::QVariant) // TODO test complex types + QCOMPARE(p.value(), pmeta.read(o)); + + if (p.name() == "parent") + QVERIFY(p.valueTypeName() == "QGraphicsObject*" || p.valueTypeName() == "QQuickItem*"); + else + QCOMPARE(p.valueTypeName(), QString::fromUtf8(pmeta.typeName())); + + QQmlAbstractBinding *binding = + QQmlPropertyPrivate::binding(QQmlProperty(o, p.name())); + if (binding) + QCOMPARE(binding->expression(), p.binding()); + + QCOMPARE(p.hasNotifySignal(), pmeta.hasNotifySignal()); + + QVERIFY(pmeta.isValid()); + } +} + +void tst_QQmlEngineDebug::recursiveCompareObjects(const QQmlDebugObjectReference &a, const QQmlDebugObjectReference &b) const +{ + QCOMPARE(a.debugId(), b.debugId()); + QCOMPARE(a.className(), b.className()); + QCOMPARE(a.name(), b.name()); + QCOMPARE(a.contextDebugId(), b.contextDebugId()); + + QCOMPARE(a.source().url(), b.source().url()); + QCOMPARE(a.source().lineNumber(), b.source().lineNumber()); + QCOMPARE(a.source().columnNumber(), b.source().columnNumber()); + + QCOMPARE(a.properties().count(), b.properties().count()); + QCOMPARE(a.children().count(), b.children().count()); + + QList aprops = a.properties(); + QList bprops = b.properties(); + + for (int i=0; i(); + qmlRegisterType("Test", 1, 0, "NonScriptPropertyElement"); + + QTest::ignoreMessage(QtWarningMsg, "QQmlDebugServer: Waiting for connection on port 3768..."); + m_engine = new QQmlEngine(this); + + QList qml; + qml << "import QtQuick 2.0\n" + "import Test 1.0\n" + "Item {" + "id: root\n" + "width: 10; height: 20; scale: blueRect.scale;" + "Rectangle { id: blueRect; width: 500; height: 600; color: \"blue\"; }" + "Text { color: blueRect.color; }" + "MouseArea {" + "onEntered: { console.log('hello') }" + "}" + "property variant varObj\n" + "property variant varObjList: []\n" + "property variant varObjMap\n" + "Component.onCompleted: {\n" + "varObj = blueRect;\n" + "var list = varObjList;\n" + "list[0] = blueRect;\n" + "varObjList = list;\n" + "var map = new Object;\n" + "map.rect = blueRect;\n" + "varObjMap = map;\n" + "}\n" + "NonScriptPropertyElement {\n" + "}\n" + "}"; + + // add second component to test multiple root contexts + qml << "import QtQuick 2.0\n" + "Item {}"; + + // and a third to test methods + qml << "import QtQuick 2.0\n" + "Item {" + "function myMethodNoArgs() { return 3; }\n" + "function myMethod(a) { return a + 9; }\n" + "function myMethodIndirect() { myMethod(3); }\n" + "}"; + + // and a fourth to test states + qml << "import QtQuick 2.0\n" + "Rectangle {\n" + "id:rootRect\n" + "width:100\n" + "states: [\n" + "State {\n" + "name:\"state1\"\n" + "PropertyChanges {\n" + "target:rootRect\n" + "width:200\n" + "}\n" + "}\n" + "]\n" + "transitions: [\n" + "Transition {\n" + "from:\"*\"\n" + "to:\"state1\"\n" + "PropertyAnimation {\n" + "target:rootRect\n" + "property:\"width\"\n" + "duration:100\n" + "}\n" + "}\n" + "]\n" + "}\n" + ; + + for (int i=0; i(component.create()); + } + m_rootItem = qobject_cast(m_components.first()); + + // add an extra context to test for multiple contexts + QQmlContext *context = new QQmlContext(m_engine->rootContext(), this); + context->setObjectName("tst_QQmlDebug_childContext"); + + m_conn = new QQmlDebugConnection(this); + m_conn->connectToHost("127.0.0.1", 3768); + + QTest::ignoreMessage(QtWarningMsg, "QQmlDebugServer: Connection established"); + bool ok = m_conn->waitForConnected(); + QVERIFY(ok); + QTRY_VERIFY(QQmlDebugService::hasDebuggingClient()); + m_dbg = new QQmlEngineDebug(m_conn, this); + QTRY_VERIFY(m_dbg->state() == QQmlEngineDebug::Enabled); +} + +void tst_QQmlEngineDebug::cleanupTestCase() +{ + delete m_dbg; + delete m_conn; + qDeleteAll(m_components); + delete m_engine; +} + +void tst_QQmlEngineDebug::setMethodBody() +{ + QQmlDebugObjectReference obj = findRootObject(2); + + QObject *root = m_components.at(2); + // Without args + { + QVariant rv; + QVERIFY(QMetaObject::invokeMethod(root, "myMethodNoArgs", Qt::DirectConnection, + Q_RETURN_ARG(QVariant, rv))); + QVERIFY(rv == QVariant(qreal(3))); + + + QVERIFY(m_dbg->setMethodBody(obj.debugId(), "myMethodNoArgs", "return 7")); + QTest::qWait(100); + + QVERIFY(QMetaObject::invokeMethod(root, "myMethodNoArgs", Qt::DirectConnection, + Q_RETURN_ARG(QVariant, rv))); + QVERIFY(rv == QVariant(qreal(7))); + } + + // With args + { + QVariant rv; + QVERIFY(QMetaObject::invokeMethod(root, "myMethod", Qt::DirectConnection, + Q_RETURN_ARG(QVariant, rv), Q_ARG(QVariant, QVariant(19)))); + QVERIFY(rv == QVariant(qreal(28))); + + QVERIFY(m_dbg->setMethodBody(obj.debugId(), "myMethod", "return a + 7")); + QTest::qWait(100); + + QVERIFY(QMetaObject::invokeMethod(root, "myMethod", Qt::DirectConnection, + Q_RETURN_ARG(QVariant, rv), Q_ARG(QVariant, QVariant(19)))); + QVERIFY(rv == QVariant(qreal(26))); + } +} + +void tst_QQmlEngineDebug::watch_property() +{ + QQmlDebugObjectReference obj = findRootObject(); + QQmlDebugPropertyReference prop = findProperty(obj.properties(), "width"); + + QQmlDebugPropertyWatch *watch; + + QQmlEngineDebug *unconnected = new QQmlEngineDebug(0); + watch = unconnected->addWatch(prop, this); + QCOMPARE(watch->state(), QQmlDebugWatch::Dead); + delete watch; + delete unconnected; + + watch = m_dbg->addWatch(QQmlDebugPropertyReference(), this); + QVERIFY(QQmlDebugTest::waitForSignal(watch, SIGNAL(stateChanged(QQmlDebugWatch::State)))); + QCOMPARE(watch->state(), QQmlDebugWatch::Inactive); + delete watch; + + watch = m_dbg->addWatch(prop, this); + QCOMPARE(watch->state(), QQmlDebugWatch::Waiting); + QCOMPARE(watch->objectDebugId(), obj.debugId()); + QCOMPARE(watch->name(), prop.name()); + + QSignalSpy spy(watch, SIGNAL(valueChanged(QByteArray,QVariant))); + + int origWidth = m_rootItem->property("width").toInt(); + m_rootItem->setProperty("width", origWidth*2); + + // stateChanged() is received before valueChanged() + QVERIFY(QQmlDebugTest::waitForSignal(watch, SIGNAL(stateChanged(QQmlDebugWatch::State)))); + QCOMPARE(watch->state(), QQmlDebugWatch::Active); + QCOMPARE(spy.count(), 1); + + m_dbg->removeWatch(watch); + delete watch; + + // restore original value and verify spy doesn't get additional signal since watch has been removed + m_rootItem->setProperty("width", origWidth); + QTest::qWait(100); + QCOMPARE(spy.count(), 1); + + QCOMPARE(spy.at(0).at(0).value(), prop.name().toUtf8()); + QCOMPARE(spy.at(0).at(1).value(), qVariantFromValue(origWidth*2)); +} + +void tst_QQmlEngineDebug::watch_object() +{ + QQmlDebugEnginesQuery *q_engines = m_dbg->queryAvailableEngines(this); + waitForQuery(q_engines); + + QVERIFY(q_engines->engines().count() > 0); + QQmlDebugRootContextQuery *q_context = m_dbg->queryRootContexts(q_engines->engines()[0].debugId(), this); + waitForQuery(q_context); + + QVERIFY(q_context->rootContext().objects().count() > 0); + QQmlDebugObjectQuery *q_obj = m_dbg->queryObject(q_context->rootContext().objects()[0], this); + waitForQuery(q_obj); + + QQmlDebugObjectReference obj = q_obj->object(); + + delete q_engines; + delete q_context; + delete q_obj; + + QQmlDebugWatch *watch; + + QQmlEngineDebug *unconnected = new QQmlEngineDebug(0); + watch = unconnected->addWatch(obj, this); + QCOMPARE(watch->state(), QQmlDebugWatch::Dead); + delete watch; + delete unconnected; + + watch = m_dbg->addWatch(QQmlDebugObjectReference(), this); + QVERIFY(QQmlDebugTest::waitForSignal(watch, SIGNAL(stateChanged(QQmlDebugWatch::State)))); + QCOMPARE(watch->state(), QQmlDebugWatch::Inactive); + delete watch; + + watch = m_dbg->addWatch(obj, this); + QCOMPARE(watch->state(), QQmlDebugWatch::Waiting); + QCOMPARE(watch->objectDebugId(), obj.debugId()); + + QSignalSpy spy(watch, SIGNAL(valueChanged(QByteArray,QVariant))); + + int origWidth = m_rootItem->property("width").toInt(); + int origHeight = m_rootItem->property("height").toInt(); + m_rootItem->setProperty("width", origWidth*2); + m_rootItem->setProperty("height", origHeight*2); + + // stateChanged() is received before any valueChanged() signals + QVERIFY(QQmlDebugTest::waitForSignal(watch, SIGNAL(stateChanged(QQmlDebugWatch::State)))); + QCOMPARE(watch->state(), QQmlDebugWatch::Active); + QVERIFY(spy.count() > 0); + + int newWidth = -1; + int newHeight = -1; + for (int i=0; i() == "width") + newWidth = values[1].value().toInt(); + else if (values[0].value() == "height") + newHeight = values[1].value().toInt(); + + } + + m_dbg->removeWatch(watch); + delete watch; + + // since watch has been removed, restoring the original values should not trigger a valueChanged() + spy.clear(); + m_rootItem->setProperty("width", origWidth); + m_rootItem->setProperty("height", origHeight); + QTest::qWait(100); + QCOMPARE(spy.count(), 0); + + QCOMPARE(newWidth, origWidth * 2); + QCOMPARE(newHeight, origHeight * 2); +} + +void tst_QQmlEngineDebug::watch_expression() +{ + QFETCH(QString, expr); + QFETCH(int, increment); + QFETCH(int, incrementCount); + + int origWidth = m_rootItem->property("width").toInt(); + + QQmlDebugObjectReference obj = findRootObject(); + + QQmlDebugObjectExpressionWatch *watch; + + QQmlEngineDebug *unconnected = new QQmlEngineDebug(0); + watch = unconnected->addWatch(obj, expr, this); + QCOMPARE(watch->state(), QQmlDebugWatch::Dead); + delete watch; + delete unconnected; + + watch = m_dbg->addWatch(QQmlDebugObjectReference(), expr, this); + QVERIFY(QQmlDebugTest::waitForSignal(watch, SIGNAL(stateChanged(QQmlDebugWatch::State)))); + QCOMPARE(watch->state(), QQmlDebugWatch::Inactive); + delete watch; + + watch = m_dbg->addWatch(obj, expr, this); + QCOMPARE(watch->state(), QQmlDebugWatch::Waiting); + QCOMPARE(watch->objectDebugId(), obj.debugId()); + QCOMPARE(watch->expression(), expr); + + QSignalSpy spyState(watch, SIGNAL(stateChanged(QQmlDebugWatch::State))); + + QSignalSpy spy(watch, SIGNAL(valueChanged(QByteArray,QVariant))); + int expectedSpyCount = incrementCount + 1; // should also get signal with expression's initial value + + int width = origWidth; + for (int i=0; i 0) { + width += increment; + m_rootItem->setProperty("width", width); + } + if (!QQmlDebugTest::waitForSignal(watch, SIGNAL(valueChanged(QByteArray,QVariant)))) + QFAIL("Did not receive valueChanged() for expression"); + } + + if (spyState.count() == 0) + QVERIFY(QQmlDebugTest::waitForSignal(watch, SIGNAL(stateChanged(QQmlDebugWatch::State)))); + QCOMPARE(spyState.count(), 1); + QCOMPARE(watch->state(), QQmlDebugWatch::Active); + + m_dbg->removeWatch(watch); + delete watch; + + // restore original value and verify spy doesn't get a signal since watch has been removed + m_rootItem->setProperty("width", origWidth); + QTest::qWait(100); + QCOMPARE(spy.count(), expectedSpyCount); + + width = origWidth + increment; + for (int i=0; i().toInt(), width); + width += increment; + } +} + +void tst_QQmlEngineDebug::watch_expression_data() +{ + QTest::addColumn("expr"); + QTest::addColumn("increment"); + QTest::addColumn("incrementCount"); + + QTest::newRow("width") << "width" << 0 << 0; + QTest::newRow("width+10") << "width + 10" << 10 << 5; +} + +void tst_QQmlEngineDebug::watch_context() +{ + QQmlDebugContextReference c; + QTest::ignoreMessage(QtWarningMsg, "QQmlEngineDebug::addWatch(): Not implemented"); + QVERIFY(!m_dbg->addWatch(c, QString(), this)); +} + +void tst_QQmlEngineDebug::watch_file() +{ + QQmlDebugFileReference f; + QTest::ignoreMessage(QtWarningMsg, "QQmlEngineDebug::addWatch(): Not implemented"); + QVERIFY(!m_dbg->addWatch(f, this)); +} + +void tst_QQmlEngineDebug::queryAvailableEngines() +{ + QQmlDebugEnginesQuery *q_engines; + + QQmlEngineDebug *unconnected = new QQmlEngineDebug(0); + q_engines = unconnected->queryAvailableEngines(0); + QCOMPARE(q_engines->state(), QQmlDebugQuery::Error); + delete q_engines; + delete unconnected; + + q_engines = m_dbg->queryAvailableEngines(this); + delete q_engines; + + q_engines = m_dbg->queryAvailableEngines(this); + QVERIFY(q_engines->engines().isEmpty()); + waitForQuery(q_engines); + + // TODO test multiple engines + QList engines = q_engines->engines(); + QCOMPARE(engines.count(), 1); + + foreach(const QQmlDebugEngineReference &e, engines) { + QCOMPARE(e.debugId(), QQmlDebugService::idForObject(m_engine)); + QCOMPARE(e.name(), m_engine->objectName()); + } + + // Make query invalid by deleting client + q_engines = m_dbg->queryAvailableEngines(this); + QCOMPARE(q_engines->state(), QQmlDebugQuery::Waiting); + delete m_dbg; + QCOMPARE(q_engines->state(), QQmlDebugQuery::Error); + delete q_engines; + m_dbg = new QQmlEngineDebug(m_conn, this); +} + +void tst_QQmlEngineDebug::queryRootContexts() +{ + QQmlDebugEnginesQuery *q_engines = m_dbg->queryAvailableEngines(this); + waitForQuery(q_engines); + int engineId = q_engines->engines()[0].debugId(); + delete q_engines; + + QQmlDebugRootContextQuery *q_context; + + QQmlEngineDebug *unconnected = new QQmlEngineDebug(0); + q_context = unconnected->queryRootContexts(engineId, this); + QCOMPARE(q_context->state(), QQmlDebugQuery::Error); + delete q_context; + delete unconnected; + + q_context = m_dbg->queryRootContexts(engineId, this); + delete q_context; + + q_context = m_dbg->queryRootContexts(engineId, this); + waitForQuery(q_context); + + QQmlContext *actualContext = m_engine->rootContext(); + QQmlDebugContextReference context = q_context->rootContext(); + QCOMPARE(context.debugId(), QQmlDebugService::idForObject(actualContext)); + QCOMPARE(context.name(), actualContext->objectName()); + + QCOMPARE(context.objects().count(), 4); // 4 qml component objects created for context in main() + + // root context query sends only root object data - it doesn't fill in + // the children or property info + QCOMPARE(context.objects()[0].properties().count(), 0); + QCOMPARE(context.objects()[0].children().count(), 0); + + QCOMPARE(context.contexts().count(), 5); + QVERIFY(context.contexts()[0].debugId() >= 0); + QCOMPARE(context.contexts()[0].name(), QString("tst_QQmlDebug_childContext")); + + // Make query invalid by deleting client + q_context = m_dbg->queryRootContexts(engineId, this); + QCOMPARE(q_context->state(), QQmlDebugQuery::Waiting); + delete m_dbg; + QCOMPARE(q_context->state(), QQmlDebugQuery::Error); + delete q_context; + m_dbg = new QQmlEngineDebug(m_conn, this); +} + +void tst_QQmlEngineDebug::queryObject() +{ + QFETCH(bool, recursive); + + QQmlDebugEnginesQuery *q_engines = m_dbg->queryAvailableEngines(this); + waitForQuery(q_engines); + + QQmlDebugRootContextQuery *q_context = m_dbg->queryRootContexts(q_engines->engines()[0].debugId(), this); + waitForQuery(q_context); + QQmlDebugObjectReference rootObject = q_context->rootContext().objects()[0]; + + QQmlDebugObjectQuery *q_obj = 0; + + QQmlEngineDebug *unconnected = new QQmlEngineDebug(0); + q_obj = recursive ? unconnected->queryObjectRecursive(rootObject, this) : unconnected->queryObject(rootObject, this); + QCOMPARE(q_obj->state(), QQmlDebugQuery::Error); + delete q_obj; + delete unconnected; + + q_obj = recursive ? m_dbg->queryObjectRecursive(rootObject, this) : m_dbg->queryObject(rootObject, this); + delete q_obj; + + q_obj = recursive ? m_dbg->queryObjectRecursive(rootObject, this) : m_dbg->queryObject(rootObject, this); + waitForQuery(q_obj); + + QQmlDebugObjectReference obj = q_obj->object(); + + delete q_engines; + delete q_context; + + // Make query invalid by deleting client + q_obj = recursive ? m_dbg->queryObjectRecursive(rootObject, this) : m_dbg->queryObject(rootObject, this); + QCOMPARE(q_obj->state(), QQmlDebugQuery::Waiting); + delete m_dbg; + QCOMPARE(q_obj->state(), QQmlDebugQuery::Error); + delete q_obj; + m_dbg = new QQmlEngineDebug(m_conn, this); + + // check source as defined in main() + QQmlDebugFileReference source = obj.source(); + QCOMPARE(source.url(), QUrl::fromLocalFile("")); + QCOMPARE(source.lineNumber(), 3); + QCOMPARE(source.columnNumber(), 1); + + // generically test all properties, children and childrens' properties + recursiveObjectTest(m_rootItem, obj, recursive); + + if (recursive) { + foreach(const QQmlDebugObjectReference &child, obj.children()) + QVERIFY(child.properties().count() > 0); + + QQmlDebugObjectReference rect; + QQmlDebugObjectReference text; + foreach (const QQmlDebugObjectReference &child, obj.children()) { + if (child.className() == "Rectangle") + rect = child; + else if (child.className() == "Text") + text = child; + } + + // test specific property values + QCOMPARE(findProperty(rect.properties(), "width").value(), qVariantFromValue(500)); + QCOMPARE(findProperty(rect.properties(), "height").value(), qVariantFromValue(600)); + QCOMPARE(findProperty(rect.properties(), "color").value(), qVariantFromValue(QColor("blue"))); + + QCOMPARE(findProperty(text.properties(), "color").value(), qVariantFromValue(QColor("blue"))); + } else { + foreach(const QQmlDebugObjectReference &child, obj.children()) + QCOMPARE(child.properties().count(), 0); + } +} + +void tst_QQmlEngineDebug::queryObject_data() +{ + QTest::addColumn("recursive"); + + QTest::newRow("non-recursive") << false; + QTest::newRow("recursive") << true; +} + +void tst_QQmlEngineDebug::queryExpressionResult() +{ + QFETCH(QString, expr); + QFETCH(QVariant, result); + + QQmlDebugEnginesQuery *q_engines = m_dbg->queryAvailableEngines(this); + waitForQuery(q_engines); // check immediate deletion is ok + + QQmlDebugRootContextQuery *q_context = m_dbg->queryRootContexts(q_engines->engines()[0].debugId(), this); + waitForQuery(q_context); + int objectId = q_context->rootContext().objects()[0].debugId(); + + QQmlDebugExpressionQuery *q_expr; + + QQmlEngineDebug *unconnected = new QQmlEngineDebug(0); + q_expr = unconnected->queryExpressionResult(objectId, expr, this); + QCOMPARE(q_expr->state(), QQmlDebugQuery::Error); + delete q_expr; + delete unconnected; + + q_expr = m_dbg->queryExpressionResult(objectId, expr, this); + delete q_expr; + + q_expr = m_dbg->queryExpressionResult(objectId, expr, this); + QCOMPARE(q_expr->expression().toString(), expr); + waitForQuery(q_expr); + + QCOMPARE(q_expr->result(), result); + + delete q_engines; + delete q_context; + + // Make query invalid by deleting client + q_expr = m_dbg->queryExpressionResult(objectId, expr, this); + QCOMPARE(q_expr->state(), QQmlDebugQuery::Waiting); + delete m_dbg; + QCOMPARE(q_expr->state(), QQmlDebugQuery::Error); + delete q_expr; + m_dbg = new QQmlEngineDebug(m_conn, this); +} + +void tst_QQmlEngineDebug::queryExpressionResult_data() +{ + QTest::addColumn("expr"); + QTest::addColumn("result"); + + QTest::newRow("width + 50") << "width + 50" << qVariantFromValue(60); + QTest::newRow("blueRect.width") << "blueRect.width" << qVariantFromValue(500); + QTest::newRow("bad expr") << "aeaef" << qVariantFromValue(QString("")); + QTest::newRow("QObject*") << "varObj" << qVariantFromValue(QString("")); + QTest::newRow("list of QObject*") << "varObjList" << qVariantFromValue(QString("")); + QVariantMap map; + map.insert(QLatin1String("rect"), QVariant(QLatin1String(""))); + QTest::newRow("varObjMap") << "varObjMap" << qVariantFromValue(map); +} + +void tst_QQmlEngineDebug::tst_QQmlDebugFileReference() +{ + QQmlDebugFileReference ref; + QVERIFY(ref.url().isEmpty()); + QCOMPARE(ref.lineNumber(), -1); + QCOMPARE(ref.columnNumber(), -1); + + ref.setUrl(QUrl("http://test")); + QCOMPARE(ref.url(), QUrl("http://test")); + ref.setLineNumber(1); + QCOMPARE(ref.lineNumber(), 1); + ref.setColumnNumber(1); + QCOMPARE(ref.columnNumber(), 1); + + QQmlDebugFileReference copy(ref); + QQmlDebugFileReference copyAssign; + copyAssign = ref; + foreach (const QQmlDebugFileReference &r, (QList() << copy << copyAssign)) { + QCOMPARE(r.url(), ref.url()); + QCOMPARE(r.lineNumber(), ref.lineNumber()); + QCOMPARE(r.columnNumber(), ref.columnNumber()); + } +} + +void tst_QQmlEngineDebug::tst_QQmlDebugEngineReference() +{ + QQmlDebugEngineReference ref; + QCOMPARE(ref.debugId(), -1); + QVERIFY(ref.name().isEmpty()); + + ref = QQmlDebugEngineReference(1); + QCOMPARE(ref.debugId(), 1); + QVERIFY(ref.name().isEmpty()); + + QQmlDebugEnginesQuery *q_engines = m_dbg->queryAvailableEngines(this); + waitForQuery(q_engines); + ref = q_engines->engines()[0]; + delete q_engines; + + QQmlDebugEngineReference copy(ref); + QQmlDebugEngineReference copyAssign; + copyAssign = ref; + foreach (const QQmlDebugEngineReference &r, (QList() << copy << copyAssign)) { + QCOMPARE(r.debugId(), ref.debugId()); + QCOMPARE(r.name(), ref.name()); + } +} + +void tst_QQmlEngineDebug::tst_QQmlDebugObjectReference() +{ + QQmlDebugObjectReference ref; + QCOMPARE(ref.debugId(), -1); + QCOMPARE(ref.className(), QString()); + QCOMPARE(ref.name(), QString()); + QCOMPARE(ref.contextDebugId(), -1); + QVERIFY(ref.properties().isEmpty()); + QVERIFY(ref.children().isEmpty()); + + QQmlDebugFileReference source = ref.source(); + QVERIFY(source.url().isEmpty()); + QVERIFY(source.lineNumber() < 0); + QVERIFY(source.columnNumber() < 0); + + ref = QQmlDebugObjectReference(1); + QCOMPARE(ref.debugId(), 1); + + QQmlDebugObjectReference rootObject = findRootObject(); + QQmlDebugObjectQuery *query = m_dbg->queryObjectRecursive(rootObject, this); + waitForQuery(query); + ref = query->object(); + delete query; + + QVERIFY(ref.debugId() >= 0); + + QQmlDebugObjectReference copy(ref); + QQmlDebugObjectReference copyAssign; + copyAssign = ref; + foreach (const QQmlDebugObjectReference &r, (QList() << copy << copyAssign)) + recursiveCompareObjects(r, ref); +} + +void tst_QQmlEngineDebug::tst_QQmlDebugContextReference() +{ + QQmlDebugContextReference ref; + QCOMPARE(ref.debugId(), -1); + QVERIFY(ref.name().isEmpty()); + QVERIFY(ref.objects().isEmpty()); + QVERIFY(ref.contexts().isEmpty()); + + QQmlDebugEnginesQuery *q_engines = m_dbg->queryAvailableEngines(this); + waitForQuery(q_engines); + QQmlDebugRootContextQuery *q_context = m_dbg->queryRootContexts(q_engines->engines()[0].debugId(), this); + waitForQuery(q_context); + + ref = q_context->rootContext(); + delete q_engines; + delete q_context; + QVERIFY(ref.debugId() >= 0); + + QQmlDebugContextReference copy(ref); + QQmlDebugContextReference copyAssign; + copyAssign = ref; + foreach (const QQmlDebugContextReference &r, (QList() << copy << copyAssign)) + recursiveCompareContexts(r, ref); +} + +void tst_QQmlEngineDebug::tst_QQmlDebugPropertyReference() +{ + QQmlDebugObjectReference rootObject = findRootObject(); + QQmlDebugObjectQuery *query = m_dbg->queryObject(rootObject, this); + waitForQuery(query); + QQmlDebugObjectReference obj = query->object(); + delete query; + + QQmlDebugPropertyReference ref = findProperty(obj.properties(), "scale"); + QVERIFY(ref.objectDebugId() > 0); + QVERIFY(!ref.name().isEmpty()); + QVERIFY(!ref.value().isNull()); + QVERIFY(!ref.valueTypeName().isEmpty()); + QVERIFY(!ref.binding().isEmpty()); + QVERIFY(ref.hasNotifySignal()); + + QQmlDebugPropertyReference copy(ref); + QQmlDebugPropertyReference copyAssign; + copyAssign = ref; + foreach (const QQmlDebugPropertyReference &r, (QList() << copy << copyAssign)) + compareProperties(r, ref); +} + +void tst_QQmlEngineDebug::setBindingForObject() +{ + QQmlDebugObjectReference rootObject = findRootObject(); + QVERIFY(rootObject.debugId() != -1); + QQmlDebugPropertyReference widthPropertyRef = findProperty(rootObject.properties(), "width"); + + QCOMPARE(widthPropertyRef.value(), QVariant(10)); + QCOMPARE(widthPropertyRef.binding(), QString()); + + // + // set literal + // + m_dbg->setBindingForObject(rootObject.debugId(), "width", "15", true); + + rootObject = findRootObject(); + widthPropertyRef = findProperty(rootObject.properties(), "width"); + + QCOMPARE(widthPropertyRef.value(), QVariant(15)); + QCOMPARE(widthPropertyRef.binding(), QString()); + + // + // set expression + // + m_dbg->setBindingForObject(rootObject.debugId(), "width", "height", false); + + rootObject = findRootObject(); + widthPropertyRef = findProperty(rootObject.properties(), "width"); + + QCOMPARE(widthPropertyRef.value(), QVariant(20)); + QCOMPARE(widthPropertyRef.binding(), QString("height")); + + // + // reset + // + m_dbg->resetBindingForObject(rootObject.debugId(), "width"); + + rootObject = findRootObject(); + widthPropertyRef = findProperty(rootObject.properties(), "width"); + + // QCOMPARE(widthPropertyRef.value(), QVariant(0)); // TODO: Shouldn't this work? + QCOMPARE(widthPropertyRef.binding(), QString()); + + // + // set handler + // + rootObject = findRootObject(); + QCOMPARE(rootObject.children().size(), 5); // Rectangle, Text, MouseArea, Component.onCompleted, NonScriptPropertyElement + QQmlDebugObjectReference mouseAreaObject = rootObject.children().at(2); + QQmlDebugObjectQuery *q_obj = m_dbg->queryObjectRecursive(mouseAreaObject, this); + waitForQuery(q_obj); + mouseAreaObject = q_obj->object(); + + QCOMPARE(mouseAreaObject.className(), QString("MouseArea")); + + QQmlDebugPropertyReference onEnteredRef = findProperty(mouseAreaObject.properties(), "onEntered"); + + QCOMPARE(onEnteredRef.name(), QString("onEntered")); + QCOMPARE(onEnteredRef.value(), QVariant("(function onEntered() { { console.log('hello') } })")); + + m_dbg->setBindingForObject(mouseAreaObject.debugId(), "onEntered", "{console.log('hello, world') }", false) ; + + rootObject = findRootObject(); + mouseAreaObject = rootObject.children().at(2); + q_obj = m_dbg->queryObjectRecursive(mouseAreaObject, this); + waitForQuery(q_obj); + mouseAreaObject = q_obj->object(); + onEnteredRef = findProperty(mouseAreaObject.properties(), "onEntered"); + QCOMPARE(onEnteredRef.name(), QString("onEntered")); + QCOMPARE(onEnteredRef.value(), QVariant("{console.log('hello, world') }")); +} + +void tst_QQmlEngineDebug::setBindingInStates() +{ + // Check if changing bindings of propertychanges works + + const int sourceIndex = 3; + + QQmlDebugObjectReference obj = findRootObject(sourceIndex); + + QVERIFY(obj.debugId() != -1); + QVERIFY(obj.children().count() >= 2); + + // We are going to switch state a couple of times, we need to get rid of the transition before + QQmlDebugExpressionQuery *q_deleteTransition = m_dbg->queryExpressionResult(obj.debugId(),QString("transitions = []"),this); + waitForQuery(q_deleteTransition); + delete q_deleteTransition; + + + // check initial value of the property that is changing + QQmlDebugExpressionQuery *q_setState; + q_setState = m_dbg->queryExpressionResult(obj.debugId(),QString("state=\"state1\""),this); + waitForQuery(q_setState); + delete q_setState; + + obj = findRootObject(sourceIndex); + QCOMPARE(findProperty(obj.properties(),"width").value().toInt(),200); + + + q_setState = m_dbg->queryExpressionResult(obj.debugId(),QString("state=\"\""),this); + waitForQuery(q_setState); + delete q_setState; + + + obj = findRootObject(sourceIndex, true); + QCOMPARE(findProperty(obj.properties(),"width").value().toInt(),100); + + + // change the binding + QQmlDebugObjectReference state = obj.children()[1]; + QCOMPARE(state.className(), QString("State")); + QVERIFY(state.children().count() > 0); + + QQmlDebugObjectReference propertyChange = state.children()[0]; + QVERIFY(propertyChange.debugId() != -1); + + QVERIFY( m_dbg->setBindingForObject(propertyChange.debugId(), "width",QVariant(300),true) ); + + // check properties changed in state + obj = findRootObject(sourceIndex); + QCOMPARE(findProperty(obj.properties(),"width").value().toInt(),100); + + + q_setState = m_dbg->queryExpressionResult(obj.debugId(),QString("state=\"state1\""),this); + waitForQuery(q_setState); + delete q_setState; + + obj = findRootObject(sourceIndex); + QCOMPARE(findProperty(obj.properties(),"width").value().toInt(),300); + + // check changing properties of base state from within a state + QVERIFY(m_dbg->setBindingForObject(obj.debugId(),"width","height*2",false)); + QVERIFY(m_dbg->setBindingForObject(obj.debugId(),"height","200",true)); + + obj = findRootObject(sourceIndex); + QCOMPARE(findProperty(obj.properties(),"width").value().toInt(),300); + + q_setState = m_dbg->queryExpressionResult(obj.debugId(),QString("state=\"\""),this); + waitForQuery(q_setState); + delete q_setState; + + obj = findRootObject(sourceIndex); + QCOMPARE(findProperty(obj.properties(),"width").value().toInt(), 400); + + // reset binding while in a state + q_setState = m_dbg->queryExpressionResult(obj.debugId(),QString("state=\"state1\""),this); + waitForQuery(q_setState); + delete q_setState; + + obj = findRootObject(sourceIndex); + QCOMPARE(findProperty(obj.properties(),"width").value().toInt(), 300); + + m_dbg->resetBindingForObject(propertyChange.debugId(), "width"); + + obj = findRootObject(sourceIndex); + QCOMPARE(findProperty(obj.properties(),"width").value().toInt(), 400); + + // re-add binding + m_dbg->setBindingForObject(propertyChange.debugId(), "width", "300", true); + + obj = findRootObject(sourceIndex); + QCOMPARE(findProperty(obj.properties(),"width").value().toInt(), 300); +} + +void tst_QQmlEngineDebug::queryObjectTree() +{ + const int sourceIndex = 3; + + // Check if states/transitions are initialized when fetching root item + QQmlDebugEnginesQuery *q_engines = m_dbg->queryAvailableEngines(this); + waitForQuery(q_engines); + + QQmlDebugRootContextQuery *q_context = m_dbg->queryRootContexts(q_engines->engines()[0].debugId(), this); + waitForQuery(q_context); + + QVERIFY(q_context->rootContext().objects().count() > sourceIndex); + QQmlDebugObjectReference rootObject = q_context->rootContext().objects()[sourceIndex]; + + QQmlDebugObjectQuery *q_obj = m_dbg->queryObjectRecursive(rootObject, this); + waitForQuery(q_obj); + + QQmlDebugObjectReference obj = q_obj->object(); + + delete q_engines; + delete q_context; + delete q_obj; + + QVERIFY(obj.debugId() != -1); + QVERIFY(obj.children().count() >= 2); + + + + // check state + QQmlDebugObjectReference state = obj.children()[1]; + QCOMPARE(state.className(), QString("State")); + QVERIFY(state.children().count() > 0); + + QQmlDebugObjectReference propertyChange = state.children()[0]; + QVERIFY(propertyChange.debugId() != -1); + + QQmlDebugPropertyReference propertyChangeTarget = findProperty(propertyChange.properties(),"target"); + QCOMPARE(propertyChangeTarget.objectDebugId(), propertyChange.debugId()); + + QQmlDebugObjectReference targetReference = qvariant_cast(propertyChangeTarget.value()); + QVERIFY(targetReference.debugId() != -1); + + + + // check transition + QQmlDebugObjectReference transition = obj.children()[0]; + QCOMPARE(transition.className(), QString("Transition")); + QCOMPARE(findProperty(transition.properties(),"from").value().toString(), QString("*")); + QCOMPARE(findProperty(transition.properties(),"to").value(), findProperty(state.properties(),"name").value()); + QVERIFY(transition.children().count() > 0); + + QQmlDebugObjectReference animation = transition.children()[0]; + QVERIFY(animation.debugId() != -1); + + QQmlDebugPropertyReference animationTarget = findProperty(animation.properties(),"target"); + QCOMPARE(animationTarget.objectDebugId(), animation.debugId()); + + targetReference = qvariant_cast(animationTarget.value()); + QVERIFY(targetReference.debugId() != -1); + + QCOMPARE(findProperty(animation.properties(),"property").value().toString(), QString("width")); + QCOMPARE(findProperty(animation.properties(),"duration").value().toInt(), 100); +} + +int main(int argc, char *argv[]) +{ + int _argc = argc + 1; + char **_argv = new char*[_argc]; + for (int i = 0; i < argc; ++i) + _argv[i] = argv[i]; + char arg[] = "-qmljsdebugger=port:3768"; + _argv[_argc - 1] = arg; + + QGuiApplication app(_argc, _argv); + tst_QQmlEngineDebug tc; + return QTest::qExec(&tc, _argc, _argv); + delete _argv; +} + +#include "tst_qqmlenginedebug.moc" diff --git a/tests/auto/qml/debugger/qqmlinspector/app/app.pro b/tests/auto/qml/debugger/qqmlinspector/app/app.pro new file mode 100644 index 0000000000..f6ef983735 --- /dev/null +++ b/tests/auto/qml/debugger/qqmlinspector/app/app.pro @@ -0,0 +1,9 @@ +TARGET = app +QT += qml quick widgets + +CONFIG += declarative_debug +macx:CONFIG -= app_bundle + +SOURCES += main.cpp + +OTHER_FILES += qtquick1.qml qtquick2.qml diff --git a/tests/auto/qml/debugger/qqmlinspector/app/main.cpp b/tests/auto/qml/debugger/qqmlinspector/app/main.cpp new file mode 100644 index 0000000000..a7ef09c283 --- /dev/null +++ b/tests/auto/qml/debugger/qqmlinspector/app/main.cpp @@ -0,0 +1,71 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include +#include +#include + +int main(int argc, char *argv[]) +{ + QGuiApplication app(argc, argv); + + bool qtquick2 = true; + for (int i = 1; i < app.arguments().size(); ++i) { + const QString arg = app.arguments().at(i); + if (arg == "-qtquick1") { + qtquick2 = false; + } else if (arg == "-qtquick2") { + qtquick2 = true; + } else { + qWarning() << "Usage: " << app.arguments().at(0) << "[-qtquick1|-qtquick2]"; + return -1; + } + } + + if (qtquick2) { + QQuickView *view = new QQuickView(); + view->setSource(QUrl::fromLocalFile("app/qtquick2.qml")); + } else { + qWarning("No suitable QtQuick1 implementation is available!"); + } + return app.exec(); +} diff --git a/tests/auto/qml/debugger/qqmlinspector/app/qtquick2.qml b/tests/auto/qml/debugger/qqmlinspector/app/qtquick2.qml new file mode 100644 index 0000000000..9c36e13c5b --- /dev/null +++ b/tests/auto/qml/debugger/qqmlinspector/app/qtquick2.qml @@ -0,0 +1,5 @@ +import QtQuick 2.0 + +Item { + +} diff --git a/tests/auto/qml/debugger/qqmlinspector/qqmlinspector.pro b/tests/auto/qml/debugger/qqmlinspector/qqmlinspector.pro new file mode 100644 index 0000000000..5544f76581 --- /dev/null +++ b/tests/auto/qml/debugger/qqmlinspector/qqmlinspector.pro @@ -0,0 +1,3 @@ +TEMPLATE = subdirs + +SUBDIRS += tst_qqmlinspector.pro app diff --git a/tests/auto/qml/debugger/qqmlinspector/tst_qqmlinspector.cpp b/tests/auto/qml/debugger/qqmlinspector/tst_qqmlinspector.cpp new file mode 100644 index 0000000000..4f74a036d6 --- /dev/null +++ b/tests/auto/qml/debugger/qqmlinspector/tst_qqmlinspector.cpp @@ -0,0 +1,186 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include +#include +#include +#include +#include +#include + +#include "../../../../../src/plugins/qmltooling/shared/qqmlinspectorprotocol.h" +#include "../shared/debugutil_p.h" + +using namespace QmlJSDebugger; + +#define PORT 13772 +#define STR_PORT "13772" + +class QQmlInspectorClient : public QQmlDebugClient +{ + Q_OBJECT + +public: + QQmlInspectorClient(QQmlDebugConnection *connection) + : QQmlDebugClient(QLatin1String("QQmlObserverMode"), connection) + , m_showAppOnTop(false) + { + } + + bool showAppOnTop() const { return m_showAppOnTop; } + void setShowAppOnTop(bool showOnTop); + +signals: + void showAppOnTopChanged(); + +protected: + void messageReceived(const QByteArray &message); + +private: + bool m_showAppOnTop; +}; + +class tst_QQmlInspector : public QObject +{ + Q_OBJECT + +public: + tst_QQmlInspector() + : m_process(0) + , m_connection(0) + , m_client(0) + { + } + + +private: + QQmlDebugProcess *m_process; + QQmlDebugConnection *m_connection; + QQmlInspectorClient *m_client; + +private slots: + void initTestCase(); + void cleanupTestCase(); + void init(); + void cleanup(); + + void connect(); + void showAppOnTop(); +}; + + +void QQmlInspectorClient::setShowAppOnTop(bool showOnTop) +{ + QByteArray message; + QDataStream ds(&message, QIODevice::WriteOnly); + ds << InspectorProtocol::ShowAppOnTop << showOnTop; + + sendMessage(message); +} + +void QQmlInspectorClient::messageReceived(const QByteArray &message) +{ + QDataStream ds(message); + InspectorProtocol::Message type; + ds >> type; + + switch (type) { + case InspectorProtocol::ShowAppOnTop: + ds >> m_showAppOnTop; + emit showAppOnTopChanged(); + break; + default: + qDebug() << "Unhandled message " << (int)type; + } +} + +void tst_QQmlInspector::initTestCase() +{ +} + +void tst_QQmlInspector::cleanupTestCase() +{ +} + +void tst_QQmlInspector::init() +{ + const QString executable = SRCDIR"/app/app"; + const QString argument = "-qmljsdebugger=port:"STR_PORT",block"; + + m_process = new QQmlDebugProcess(executable); + m_process->start(QStringList() << argument); + if (!m_process->waitForSessionStart()) { + QFAIL(QString("Could not launch app '%1'.\nApplication output:\n%2").arg(executable, m_process->output()).toAscii()); + } + + QQmlDebugConnection *m_connection = new QQmlDebugConnection(); + m_client = new QQmlInspectorClient(m_connection); + + m_connection->connectToHost(QLatin1String("127.0.0.1"), PORT); +} + +void tst_QQmlInspector::cleanup() +{ + delete m_process; + delete m_connection; + delete m_client; +} + +void tst_QQmlInspector::connect() +{ + QTRY_COMPARE(m_client->state(), QQmlDebugClient::Enabled); +} + +void tst_QQmlInspector::showAppOnTop() +{ + QTRY_COMPARE(m_client->state(), QQmlDebugClient::Enabled); + + m_client->setShowAppOnTop(true); + QVERIFY(QQmlDebugTest::waitForSignal(m_client, SIGNAL(showAppOnTopChanged()))); + QCOMPARE(m_client->showAppOnTop(), true); + + m_client->setShowAppOnTop(false); + QVERIFY(QQmlDebugTest::waitForSignal(m_client, SIGNAL(showAppOnTopChanged()))); + QCOMPARE(m_client->showAppOnTop(), false); +} + +QTEST_MAIN(tst_QQmlInspector) + +#include "tst_qqmlinspector.moc" diff --git a/tests/auto/qml/debugger/qqmlinspector/tst_qqmlinspector.pro b/tests/auto/qml/debugger/qqmlinspector/tst_qqmlinspector.pro new file mode 100644 index 0000000000..010e97cef7 --- /dev/null +++ b/tests/auto/qml/debugger/qqmlinspector/tst_qqmlinspector.pro @@ -0,0 +1,12 @@ +CONFIG += testcase +TARGET = tst_qqmlinspector +macx:CONFIG -= app_bundle + +HEADERS += ../shared/debugutil_p.h +SOURCES += tst_qqmlinspector.cpp \ + ../shared/debugutil.cpp + +DEFINES += SRCDIR=\\\"$$PWD\\\" +CONFIG += parallel_test declarative_debug + +QT += qml-private testlib diff --git a/tests/auto/qml/debugger/qqmlprofilerservice/data/exit.qml b/tests/auto/qml/debugger/qqmlprofilerservice/data/exit.qml new file mode 100644 index 0000000000..b250524caa --- /dev/null +++ b/tests/auto/qml/debugger/qqmlprofilerservice/data/exit.qml @@ -0,0 +1,9 @@ +import QtQuick 2.0 + +Item { + Timer { + running: true + interval: 1 + onTriggered: Qt.quit(); + } +} diff --git a/tests/auto/qml/debugger/qqmlprofilerservice/data/test.qml b/tests/auto/qml/debugger/qqmlprofilerservice/data/test.qml new file mode 100644 index 0000000000..9c36e13c5b --- /dev/null +++ b/tests/auto/qml/debugger/qqmlprofilerservice/data/test.qml @@ -0,0 +1,5 @@ +import QtQuick 2.0 + +Item { + +} diff --git a/tests/auto/qml/debugger/qqmlprofilerservice/qqmlprofilerservice.pro b/tests/auto/qml/debugger/qqmlprofilerservice/qqmlprofilerservice.pro new file mode 100644 index 0000000000..0d11213cb4 --- /dev/null +++ b/tests/auto/qml/debugger/qqmlprofilerservice/qqmlprofilerservice.pro @@ -0,0 +1,15 @@ +CONFIG += testcase +TARGET = tst_qqmlprofilerservice +macx:CONFIG -= app_bundle + +HEADERS += ../shared/debugutil_p.h + +SOURCES += tst_qqmlprofilerservice.cpp \ + ../shared/debugutil.cpp +OTHER_FILES += data/test.qml + +include (../../../shared/util.pri) + +CONFIG += parallel_test declarative_debug + +QT += qml-private testlib diff --git a/tests/auto/qml/debugger/qqmlprofilerservice/tst_qqmlprofilerservice.cpp b/tests/auto/qml/debugger/qqmlprofilerservice/tst_qqmlprofilerservice.cpp new file mode 100644 index 0000000000..edc120ba85 --- /dev/null +++ b/tests/auto/qml/debugger/qqmlprofilerservice/tst_qqmlprofilerservice.cpp @@ -0,0 +1,310 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include + +#include "QtQml/private/qqmlprofilerservice_p.h" +#include "../shared/debugutil_p.h" +#include "../../../shared/util.h" + +#define PORT 13773 +#define STR_PORT "13773" + +class QQmlProfilerClient : public QQmlDebugClient +{ + Q_OBJECT + +public: + QQmlProfilerClient(QQmlDebugConnection *connection) + : QQmlDebugClient(QLatin1String("CanvasFrameRate"), connection) + { + } + + QList traceMessages; + + void setTraceState(bool enabled) { + QByteArray message; + QDataStream stream(&message, QIODevice::WriteOnly); + stream << enabled; + sendMessage(message); + } + +signals: + void complete(); + +protected: + void messageReceived(const QByteArray &message); +}; + +class tst_QQmlProfilerService : public QQmlDataTest +{ + Q_OBJECT + +public: + tst_QQmlProfilerService() + : m_process(0) + , m_connection(0) + , m_client(0) + { + } + +private: + QQmlDebugProcess *m_process; + QQmlDebugConnection *m_connection; + QQmlProfilerClient *m_client; + + void connect(bool block, const QString &testFile); + +private slots: + void cleanup(); + + void blockingConnectWithTraceEnabled(); + void blockingConnectWithTraceDisabled(); + void nonBlockingConnect(); + void profileOnExit(); +}; + +void QQmlProfilerClient::messageReceived(const QByteArray &message) +{ + QByteArray msg = message; + QDataStream stream(&msg, QIODevice::ReadOnly); + + + QQmlProfilerData data; + data.time = -2; + data.messageType = -1; + data.detailType = -1; + data.line = -1; + data.framerate = -1; + data.animationcount = -1; + + stream >> data.time >> data.messageType; + + QVERIFY(data.time >= -1); + + switch (data.messageType) { + case (QQmlProfilerService::Event): { + stream >> data.detailType; + + switch (data.detailType) { + case QQmlProfilerService::AnimationFrame: { + stream >> data.framerate >> data.animationcount; + QVERIFY(data.framerate != -1); + QVERIFY(data.animationcount != -1); + break; + } + case QQmlProfilerService::FramePaint: + case QQmlProfilerService::Mouse: + case QQmlProfilerService::Key: + case QQmlProfilerService::StartTrace: + case QQmlProfilerService::EndTrace: + break; + default: { + QString failMsg = QString("Unknown event type:") + data.detailType; + QFAIL(qPrintable(failMsg)); + break; + } + } + break; + } + case QQmlProfilerService::Complete: { + emit complete(); + return; + } + case QQmlProfilerService::RangeStart: { + stream >> data.detailType; + QVERIFY(data.detailType >= 0 && data.detailType < QQmlProfilerService::MaximumRangeType); + break; + } + case QQmlProfilerService::RangeEnd: { + stream >> data.detailType; + QVERIFY(data.detailType >= 0 && data.detailType < QQmlProfilerService::MaximumRangeType); + break; + } + case QQmlProfilerService::RangeData: { + stream >> data.detailType >> data.detailData; + QVERIFY(data.detailType >= 0 && data.detailType < QQmlProfilerService::MaximumRangeType); + break; + } + case QQmlProfilerService::RangeLocation: { + stream >> data.detailType >> data.detailData >> data.line >> data.column; + QVERIFY(data.detailType >= 0 && data.detailType < QQmlProfilerService::MaximumRangeType); + QVERIFY(data.line >= -2); + break; + } + default: + QString failMsg = QString("Unknown message type:") + data.messageType; + QFAIL(qPrintable(failMsg)); + break; + } + QVERIFY(stream.atEnd()); + traceMessages.append(data); +} + +void tst_QQmlProfilerService::connect(bool block, const QString &testFile) +{ + const QString executable = QLibraryInfo::location(QLibraryInfo::BinariesPath) + "/qmlscene"; + QStringList arguments; + + if (block) + arguments << QString("-qmljsdebugger=port:"STR_PORT",block"); + else + arguments << QString("-qmljsdebugger=port:"STR_PORT); + + arguments << QQmlDataTest::instance()->testFile(testFile); + + m_process = new QQmlDebugProcess(executable); + m_process->start(QStringList() << arguments); + if (!m_process->waitForSessionStart()) { + QString failMsg = QString("Could not launch app '%1'.\nApplication output:\n%2").arg( + executable, m_process->output()); + QFAIL(qPrintable(failMsg)); + } + + QQmlDebugConnection *m_connection = new QQmlDebugConnection(); + m_client = new QQmlProfilerClient(m_connection); + + m_connection->connectToHost(QLatin1String("127.0.0.1"), PORT); +} + +void tst_QQmlProfilerService::cleanup() +{ + delete m_process; + delete m_connection; + delete m_client; +} + +void tst_QQmlProfilerService::blockingConnectWithTraceEnabled() +{ + connect(true, "test.qml"); + QTRY_COMPARE(m_client->state(), QQmlDebugClient::Enabled); + + m_client->setTraceState(true); + m_client->setTraceState(false); + if (!QQmlDebugTest::waitForSignal(m_client, SIGNAL(complete()))) { + QString failMsg + = QString("No trace received in time. App output: \n%1\n").arg(m_process->output()); + QFAIL(qPrintable(failMsg)); + } + + QVERIFY(m_client->traceMessages.count()); + // must start with "StartTrace" + QCOMPARE(m_client->traceMessages.first().messageType, (int)QQmlProfilerService::Event); + QCOMPARE(m_client->traceMessages.first().detailType, (int)QQmlProfilerService::StartTrace); + + // must end with "EndTrace" + QCOMPARE(m_client->traceMessages.last().messageType, (int)QQmlProfilerService::Event); + QCOMPARE(m_client->traceMessages.last().detailType, (int)QQmlProfilerService::EndTrace); +} + +void tst_QQmlProfilerService::blockingConnectWithTraceDisabled() +{ + connect(true, "test.qml"); + QTRY_COMPARE(m_client->state(), QQmlDebugClient::Enabled); + + m_client->setTraceState(false); + m_client->setTraceState(true); + m_client->setTraceState(false); + if (!QQmlDebugTest::waitForSignal(m_client, SIGNAL(complete()))) { + QString failMsg + = QString("No trace received in time. App output: \n%1\n").arg(m_process->output()); + QFAIL(qPrintable(failMsg)); + } + + QVERIFY(m_client->traceMessages.count()); + + // must start with "StartTrace" + QCOMPARE(m_client->traceMessages.first().messageType, (int)QQmlProfilerService::Event); + QCOMPARE(m_client->traceMessages.first().detailType, (int)QQmlProfilerService::StartTrace); + + // must end with "EndTrace" + QCOMPARE(m_client->traceMessages.last().messageType, (int)QQmlProfilerService::Event); + QCOMPARE(m_client->traceMessages.last().detailType, (int)QQmlProfilerService::EndTrace); +} + +void tst_QQmlProfilerService::nonBlockingConnect() +{ + connect(false, "test.qml"); + QTRY_COMPARE(m_client->state(), QQmlDebugClient::Enabled); + + m_client->setTraceState(true); + m_client->setTraceState(false); + if (!QQmlDebugTest::waitForSignal(m_client, SIGNAL(complete()))) { + QString failMsg + = QString("No trace received in time. App output: \n%1\n").arg(m_process->output()); + QFAIL(qPrintable(failMsg)); + } + + // must start with "StartTrace" + QCOMPARE(m_client->traceMessages.first().messageType, (int)QQmlProfilerService::Event); + QCOMPARE(m_client->traceMessages.first().detailType, (int)QQmlProfilerService::StartTrace); + + // must end with "EndTrace" + QCOMPARE(m_client->traceMessages.last().messageType, (int)QQmlProfilerService::Event); + QCOMPARE(m_client->traceMessages.last().detailType, (int)QQmlProfilerService::EndTrace); +} + +void tst_QQmlProfilerService::profileOnExit() +{ + connect(true, "exit.qml"); + QTRY_COMPARE(m_client->state(), QQmlDebugClient::Enabled); + + m_client->setTraceState(true); + + if (!QQmlDebugTest::waitForSignal(m_client, SIGNAL(complete()))) { + QString failMsg + = QString("No trace received in time. App output: \n%1\n").arg(m_process->output()); + QFAIL(qPrintable(failMsg)); + } + + // must start with "StartTrace" + QCOMPARE(m_client->traceMessages.first().messageType, (int)QQmlProfilerService::Event); + QCOMPARE(m_client->traceMessages.first().detailType, (int)QQmlProfilerService::StartTrace); + + // must end with "EndTrace" + QCOMPARE(m_client->traceMessages.last().messageType, (int)QQmlProfilerService::Event); + QCOMPARE(m_client->traceMessages.last().detailType, (int)QQmlProfilerService::EndTrace); +} + +QTEST_MAIN(tst_QQmlProfilerService) + +#include "tst_qqmlprofilerservice.moc" diff --git a/tests/auto/qml/debugger/qv8profilerservice/data/console.qml b/tests/auto/qml/debugger/qv8profilerservice/data/console.qml new file mode 100644 index 0000000000..c23c820216 --- /dev/null +++ b/tests/auto/qml/debugger/qv8profilerservice/data/console.qml @@ -0,0 +1,14 @@ +import QtQuick 2.0 + + +Item { + function f() + { + } + + Component.onCompleted: { + console.profile(); + f(); + console.profileEnd(); + } +} diff --git a/tests/auto/qml/debugger/qv8profilerservice/data/exit.qml b/tests/auto/qml/debugger/qv8profilerservice/data/exit.qml new file mode 100644 index 0000000000..604265354c --- /dev/null +++ b/tests/auto/qml/debugger/qv8profilerservice/data/exit.qml @@ -0,0 +1,11 @@ +import QtQuick 2.0 + +Item { + Timer { + running: true + interval: 1 + onTriggered: { + Qt.quit(); + } + } +} diff --git a/tests/auto/qml/debugger/qv8profilerservice/data/test.qml b/tests/auto/qml/debugger/qv8profilerservice/data/test.qml new file mode 100644 index 0000000000..9c36e13c5b --- /dev/null +++ b/tests/auto/qml/debugger/qv8profilerservice/data/test.qml @@ -0,0 +1,5 @@ +import QtQuick 2.0 + +Item { + +} diff --git a/tests/auto/qml/debugger/qv8profilerservice/qv8profilerservice.pro b/tests/auto/qml/debugger/qv8profilerservice/qv8profilerservice.pro new file mode 100644 index 0000000000..e980d6594d --- /dev/null +++ b/tests/auto/qml/debugger/qv8profilerservice/qv8profilerservice.pro @@ -0,0 +1,16 @@ +CONFIG += testcase +TARGET = tst_qv8profilerservice +macx:CONFIG -= app_bundle + +HEADERS += ../shared/debugutil_p.h + +SOURCES += tst_qv8profilerservice.cpp \ + ../shared/debugutil.cpp + +include (../../../shared/util.pri) + +OTHER_FILES += data/test.qml + +CONFIG += parallel_test declarative_debug + +QT += qml-private testlib diff --git a/tests/auto/qml/debugger/qv8profilerservice/tst_qv8profilerservice.cpp b/tests/auto/qml/debugger/qv8profilerservice/tst_qv8profilerservice.cpp new file mode 100644 index 0000000000..a2cac08a21 --- /dev/null +++ b/tests/auto/qml/debugger/qv8profilerservice/tst_qv8profilerservice.cpp @@ -0,0 +1,280 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include + +#include "QtQml/private/qv8profilerservice_p.h" +#include "../shared/debugutil_p.h" +#include "../../../shared/util.h" + +#define PORT 13774 +#define STR_PORT "13774" + +class QV8ProfilerClient : public QQmlDebugClient +{ + Q_OBJECT + +public: + QV8ProfilerClient(QQmlDebugConnection *connection) + : QQmlDebugClient(QLatin1String("V8Profiler"), connection) + { + } + + void startProfiling(const QString &name) { + QByteArray message; + QDataStream stream(&message, QIODevice::WriteOnly); + stream << QByteArray("V8PROFILER") << QByteArray("start") << name; + sendMessage(message); + } + + void stopProfiling(const QString &name) { + QByteArray message; + QDataStream stream(&message, QIODevice::WriteOnly); + stream << QByteArray("V8PROFILER") << QByteArray("stop") << name; + sendMessage(message); + } + + void takeSnapshot() { + QByteArray message; + QDataStream stream(&message, QIODevice::WriteOnly); + stream << QByteArray("V8SNAPSHOT") << QByteArray("full"); + sendMessage(message); + } + + void deleteSnapshots() { + QByteArray message; + QDataStream stream(&message, QIODevice::WriteOnly); + stream << QByteArray("V8SNAPSHOT") << QByteArray("delete"); + sendMessage(message); + } + + QList traceMessages; + QList snapshotMessages; + +signals: + void complete(); + void snapshot(); + +protected: + void messageReceived(const QByteArray &message); +}; + +class tst_QV8ProfilerService : public QQmlDataTest +{ + Q_OBJECT + +public: + tst_QV8ProfilerService() + : m_process(0) + , m_connection(0) + , m_client(0) + { + } + +private: + QQmlDebugProcess *m_process; + QQmlDebugConnection *m_connection; + QV8ProfilerClient *m_client; + + void connect(bool block, const QString &testFile); + +private slots: + void cleanup(); + + void blockingConnectWithTraceEnabled(); + void blockingConnectWithTraceDisabled(); + void nonBlockingConnect(); + void snapshot(); + void profileOnExit(); + void console(); +}; + +void QV8ProfilerClient::messageReceived(const QByteArray &message) +{ + QByteArray msg = message; + QDataStream stream(&msg, QIODevice::ReadOnly); + + int messageType; + stream >> messageType; + + QVERIFY(messageType >= 0); + QVERIFY(messageType < QV8ProfilerService::V8MaximumMessage); + + switch (messageType) { + case QV8ProfilerService::V8Entry: { + QV8ProfilerData entry; + stream >> entry.filename >> entry.functionname >> entry.lineNumber >> entry.totalTime >> entry.selfTime >> entry.treeLevel; + traceMessages.append(entry); + break; + } + case QV8ProfilerService::V8Complete: + emit complete(); + break; + case QV8ProfilerService::V8SnapshotChunk: { + QByteArray json; + stream >> json; + snapshotMessages.append(json); + break; + } + case QV8ProfilerService::V8SnapshotComplete: + emit snapshot(); + break; + default: + QString failMessage = QString("Unknown message type: %1").arg(messageType); + QFAIL(qPrintable(failMessage)); + } + + QVERIFY(stream.atEnd()); +} + +void tst_QV8ProfilerService::connect(bool block, const QString &testFile) +{ + const QString executable = QLibraryInfo::location(QLibraryInfo::BinariesPath) + "/qmlscene"; + QStringList arguments; + + if (block) + arguments << QString("-qmljsdebugger=port:"STR_PORT",block"); + else + arguments << QString("-qmljsdebugger=port:"STR_PORT); + + arguments << QQmlDataTest::instance()->testFile(testFile); + + m_process = new QQmlDebugProcess(executable); + m_process->start(QStringList() << arguments); + if (!m_process->waitForSessionStart()) { + QString failMsg = QString("Could not launch app '%1'.\nApplication output:\n%2").arg( + executable, m_process->output()); + QFAIL(qPrintable(failMsg)); + } + + QQmlDebugConnection *m_connection = new QQmlDebugConnection(); + m_client = new QV8ProfilerClient(m_connection); + + m_connection->connectToHost(QLatin1String("127.0.0.1"), PORT); +} + +void tst_QV8ProfilerService::cleanup() +{ + if (QTest::currentTestFailed()) + qDebug() << "Application Output:" << m_process->output(); + + delete m_process; + delete m_connection; + delete m_client; +} + +void tst_QV8ProfilerService::blockingConnectWithTraceEnabled() +{ + connect(true, "test.qml"); + QTRY_COMPARE(m_client->state(), QQmlDebugClient::Enabled); + + m_client->startProfiling(""); + m_client->stopProfiling(""); + QVERIFY2(QQmlDebugTest::waitForSignal(m_client, SIGNAL(complete())), + "No trace received in time."); +} + +void tst_QV8ProfilerService::blockingConnectWithTraceDisabled() +{ + connect(true, "test.qml"); + QTRY_COMPARE(m_client->state(), QQmlDebugClient::Enabled); + + m_client->stopProfiling(""); + if (QQmlDebugTest::waitForSignal(m_client, SIGNAL(complete()), 1000)) { + QString failMsg + = QString("Unexpected trace received! App output: %1\n\n").arg(m_process->output()); + QFAIL(qPrintable(failMsg)); + } + m_client->startProfiling(""); + m_client->stopProfiling(""); + QVERIFY2(QQmlDebugTest::waitForSignal(m_client, SIGNAL(complete())), + "No trace received in time."); +} + +void tst_QV8ProfilerService::nonBlockingConnect() +{ + connect(false, "test.qml"); + QTRY_COMPARE(m_client->state(), QQmlDebugClient::Enabled); + + m_client->startProfiling(""); + m_client->stopProfiling(""); + QVERIFY2(QQmlDebugTest::waitForSignal(m_client, SIGNAL(complete())), + "No trace received in time."); +} + +void tst_QV8ProfilerService::snapshot() +{ + connect(false, "test.qml"); + QTRY_COMPARE(m_client->state(), QQmlDebugClient::Enabled); + + m_client->takeSnapshot(); + QVERIFY2(QQmlDebugTest::waitForSignal(m_client, SIGNAL(snapshot())), + "No trace received in time."); +} + +void tst_QV8ProfilerService::profileOnExit() +{ + connect(true, "exit.qml"); + QTRY_COMPARE(m_client->state(), QQmlDebugClient::Enabled); + + m_client->startProfiling(""); + + QVERIFY2(QQmlDebugTest::waitForSignal(m_client, SIGNAL(complete())), + "No trace received in time."); + //QVERIFY(!m_client->traceMessages.isEmpty()); +} + +void tst_QV8ProfilerService::console() +{ + connect(true, "console.qml"); + QTRY_COMPARE(m_client->state(), QQmlDebugClient::Enabled); + + m_client->stopProfiling(""); + + QVERIFY2(QQmlDebugTest::waitForSignal(m_client, SIGNAL(complete())), + "No trace received in time."); + QVERIFY(!m_client->traceMessages.isEmpty()); +} + +QTEST_MAIN(tst_QV8ProfilerService) + +#include "tst_qv8profilerservice.moc" diff --git a/tests/auto/qml/debugger/shared/debugutil.cpp b/tests/auto/qml/debugger/shared/debugutil.cpp new file mode 100644 index 0000000000..8ed64d3a5d --- /dev/null +++ b/tests/auto/qml/debugger/shared/debugutil.cpp @@ -0,0 +1,190 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "debugutil_p.h" + +#include +#include + +#include +#include + +bool QQmlDebugTest::waitForSignal(QObject *receiver, const char *member, int timeout) { + QEventLoop loop; + QTimer timer; + timer.setSingleShot(true); + QObject::connect(&timer, SIGNAL(timeout()), &loop, SLOT(quit())); + QObject::connect(receiver, member, &loop, SLOT(quit())); + timer.start(timeout); + loop.exec(); + return timer.isActive(); +} + +QQmlDebugTestService::QQmlDebugTestService(const QString &s, float version, QObject *parent) + : QQmlDebugService(s, version, parent) +{ + registerService(); +} + +void QQmlDebugTestService::messageReceived(const QByteArray &ba) +{ + sendMessage(ba); +} + +void QQmlDebugTestService::stateChanged(State) +{ + emit stateHasChanged(); +} + + +QQmlDebugTestClient::QQmlDebugTestClient(const QString &s, QQmlDebugConnection *c) + : QQmlDebugClient(s, c) +{ +} + +QByteArray QQmlDebugTestClient::waitForResponse() +{ + lastMsg.clear(); + QQmlDebugTest::waitForSignal(this, SIGNAL(serverMessage(QByteArray))); + if (lastMsg.isEmpty()) { + qWarning() << "tst_QQmlDebugTestClient: no response from server!"; + return QByteArray(); + } + return lastMsg; +} + +void QQmlDebugTestClient::stateChanged(State stat) +{ + QCOMPARE(stat, state()); + emit stateHasChanged(); +} + +void QQmlDebugTestClient::messageReceived(const QByteArray &ba) +{ + lastMsg = ba; + emit serverMessage(ba); +} + +QQmlDebugProcess::QQmlDebugProcess(const QString &executable) + : m_executable(executable) + , m_started(false) +{ + m_process.setProcessChannelMode(QProcess::MergedChannels); + m_timer.setSingleShot(true); + m_timer.setInterval(5000); + connect(&m_process, SIGNAL(readyReadStandardOutput()), this, SLOT(processAppOutput())); + connect(&m_timer, SIGNAL(timeout()), &m_eventLoop, SLOT(quit())); +} + +QQmlDebugProcess::~QQmlDebugProcess() +{ + stop(); +} + +void QQmlDebugProcess::start(const QStringList &arguments) +{ + m_mutex.lock(); + m_process.setEnvironment(m_environment); + m_process.start(m_executable, arguments); + m_process.waitForStarted(); + m_timer.start(); + m_mutex.unlock(); +} + +void QQmlDebugProcess::stop() +{ + if (m_process.state() != QProcess::NotRunning) { + m_process.kill(); + m_process.waitForFinished(5000); + } +} + +bool QQmlDebugProcess::waitForSessionStart() +{ + if (m_process.state() != QProcess::Running) { + qWarning() << "Could not start up " << m_executable; + return false; + } + m_eventLoop.exec(QEventLoop::ExcludeUserInputEvents); + + return m_started; +} + +void QQmlDebugProcess::setEnvironment(const QStringList &environment) +{ + m_environment = environment; +} + +QString QQmlDebugProcess::output() const +{ + return m_output; +} + +void QQmlDebugProcess::processAppOutput() +{ + m_mutex.lock(); + + QString newOutput = m_process.readAll(); + m_output.append(newOutput); + m_outputBuffer.append(newOutput); + + while (true) { + const int nlIndex = m_outputBuffer.indexOf(QLatin1Char('\n')); + if (nlIndex < 0) // no further complete lines + break; + const QString line = m_outputBuffer.left(nlIndex); + m_outputBuffer = m_outputBuffer.right(m_outputBuffer.size() - nlIndex - 1); + + if (line.startsWith("Qml debugging is enabled")) // ignore + continue; + if (line.startsWith("QQmlDebugServer:")) { + if (line.contains("Waiting for connection ")) { + m_started = true; + m_eventLoop.quit(); + continue; + } + if (line.contains("Connection established")) { + continue; + } + } + } + m_mutex.unlock(); +} diff --git a/tests/auto/qml/debugger/shared/debugutil_p.h b/tests/auto/qml/debugger/shared/debugutil_p.h new file mode 100644 index 0000000000..194f8fa14c --- /dev/null +++ b/tests/auto/qml/debugger/shared/debugutil_p.h @@ -0,0 +1,127 @@ + +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef DEBUGUTIL_H +#define DEBUGUTIL_H + +#include +#include +#include +#include +#include + +#include + +#include +#include + +class QQmlDebugTest +{ +public: + static bool waitForSignal(QObject *receiver, const char *member, int timeout = 5000); +}; + +class QQmlDebugTestService : public QQmlDebugService +{ + Q_OBJECT +public: + QQmlDebugTestService(const QString &s, float version = 1, QObject *parent = 0); + +signals: + void stateHasChanged(); + +protected: + virtual void messageReceived(const QByteArray &ba); + virtual void stateChanged(State state); +}; + +class QQmlDebugTestClient : public QQmlDebugClient +{ + Q_OBJECT +public: + QQmlDebugTestClient(const QString &s, QQmlDebugConnection *c); + + QByteArray waitForResponse(); + +signals: + void stateHasChanged(); + void serverMessage(const QByteArray &); + +protected: + virtual void stateChanged(State state); + virtual void messageReceived(const QByteArray &ba); + +private: + QByteArray lastMsg; +}; + +class QQmlDebugProcess : public QObject +{ + Q_OBJECT +public: + QQmlDebugProcess(const QString &executable); + ~QQmlDebugProcess(); + + void setEnvironment(const QStringList &environment); + + void start(const QStringList &arguments); + bool waitForSessionStart(); + + QString output() const; + void stop(); + +private slots: + void processAppOutput(); + +private: + QString m_executable; + QProcess m_process; + QString m_outputBuffer; + QString m_output; + QTimer m_timer; + QEventLoop m_eventLoop; + QMutex m_mutex; + bool m_started; + QStringList m_environment; +}; + +#endif // DEBUGUTIL_H diff --git a/tests/auto/qml/parserstress/parserstress.pro b/tests/auto/qml/parserstress/parserstress.pro new file mode 100644 index 0000000000..3cf3e02e4e --- /dev/null +++ b/tests/auto/qml/parserstress/parserstress.pro @@ -0,0 +1,12 @@ +CONFIG += testcase +TARGET = tst_parserstress +macx:CONFIG -= app_bundle + +SOURCES += tst_parserstress.cpp + +DEFINES += SRCDIR=\\\"$$PWD\\\" +DEFINES += TESTDATADIR=\\\"$$PWD/tests\\\" + +CONFIG += parallel_test + +QT += core-private gui-private qml-private testlib diff --git a/tests/auto/qml/parserstress/tests/ecma/Array/15.4-1.js b/tests/auto/qml/parserstress/tests/ecma/Array/15.4-1.js new file mode 100644 index 0000000000..b73ca2df71 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Array/15.4-1.js @@ -0,0 +1,135 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.4-1.js'; + +/** + File Name: 15.4-1.js + ECMA Section: 15.4 Array Objects + + Description: Every Array object has a length property whose value + is always an integer with positive sign and less than + Math.pow(2,32). + + Author: christine@netscape.com + Date: 28 october 1997 + +*/ +var SECTION = "15.4-1"; +var VERSION = "ECMA_1"; +startTest(); + +var TITLE = "Array Objects"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +new TestCase(SECTION, + "var myarr = new Array(); myarr[Math.pow(2,32)-2]='hi'; myarr[Math.pow(2,32)-2]", + "hi", + eval("var myarr = new Array(); myarr[Math.pow(2,32)-2]='hi'; myarr[Math.pow(2,32)-2]") + ); + +new TestCase(SECTION, + "var myarr = new Array(); myarr[Math.pow(2,32)-2]='hi'; myarr.length", + (Math.pow(2,32)-1), + eval("var myarr = new Array(); myarr[Math.pow(2,32)-2]='hi'; myarr.length") + ); + +new TestCase(SECTION, + "var myarr = new Array(); myarr[Math.pow(2,32)-3]='hi'; myarr[Math.pow(2,32)-3]", + "hi", + eval("var myarr = new Array(); myarr[Math.pow(2,32)-3]='hi'; myarr[Math.pow(2,32)-3]") + ); + +new TestCase(SECTION, + "var myarr = new Array(); myarr[Math.pow(2,32)-3]='hi'; myarr.length", + (Math.pow(2,32)-2), + eval("var myarr = new Array(); myarr[Math.pow(2,32)-3]='hi'; myarr.length") + ); + +new TestCase(SECTION, + "var myarr = new Array(); myarr[Math.pow(2,31)-2]='hi'; myarr[Math.pow(2,31)-2]", + "hi", + eval("var myarr = new Array(); myarr[Math.pow(2,31)-2]='hi'; myarr[Math.pow(2,31)-2]") + ); + +new TestCase(SECTION, + "var myarr = new Array(); myarr[Math.pow(2,31)-2]='hi'; myarr.length", + (Math.pow(2,31)-1), + eval("var myarr = new Array(); myarr[Math.pow(2,31)-2]='hi'; myarr.length") + ); + +new TestCase(SECTION, + "var myarr = new Array(); myarr[Math.pow(2,31)-1]='hi'; myarr[Math.pow(2,31)-1]", + "hi", + eval("var myarr = new Array(); myarr[Math.pow(2,31)-1]='hi'; myarr[Math.pow(2,31)-1]") + ); + +new TestCase(SECTION, + "var myarr = new Array(); myarr[Math.pow(2,31)-1]='hi'; myarr.length", + (Math.pow(2,31)), + eval("var myarr = new Array(); myarr[Math.pow(2,31)-1]='hi'; myarr.length") + ); + +new TestCase(SECTION, + "var myarr = new Array(); myarr[Math.pow(2,31)]='hi'; myarr[Math.pow(2,31)]", + "hi", + eval("var myarr = new Array(); myarr[Math.pow(2,31)]='hi'; myarr[Math.pow(2,31)]") + ); + +new TestCase(SECTION, + "var myarr = new Array(); myarr[Math.pow(2,31)]='hi'; myarr.length", + (Math.pow(2,31)+1), + eval("var myarr = new Array(); myarr[Math.pow(2,31)]='hi'; myarr.length") + ); + +new TestCase(SECTION, + "var myarr = new Array(); myarr[Math.pow(2,30)-2]='hi'; myarr[Math.pow(2,30)-2]", + "hi", + eval("var myarr = new Array(); myarr[Math.pow(2,30)-2]='hi'; myarr[Math.pow(2,30)-2]") + ); + +new TestCase(SECTION, + "var myarr = new Array(); myarr[Math.pow(2,30)-2]='hi'; myarr.length", + (Math.pow(2,30)-1), + eval("var myarr = new Array(); myarr[Math.pow(2,30)-2]='hi'; myarr.length") + ); + +print(typeof testcases, testcases instanceof Array, testcases.length); +test(); + diff --git a/tests/auto/qml/parserstress/tests/ecma/Array/15.4-2.js b/tests/auto/qml/parserstress/tests/ecma/Array/15.4-2.js new file mode 100644 index 0000000000..7d00703d30 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Array/15.4-2.js @@ -0,0 +1,114 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.4-2.js'; + +/** + File Name: 15.4-2.js + ECMA Section: 15.4 Array Objects + + Description: Whenever a property is added whose name is an array + index, the length property is changed, if necessary, + to be one more than the numeric value of that array + index; and whenever the length property is changed, + every property whose name is an array index whose value + is not smaller than the new length is automatically + deleted. This constraint applies only to the Array + object itself, and is unaffected by length or array + index properties that may be inherited from its + prototype. + + Author: christine@netscape.com + Date: 28 october 1997 + +*/ +var SECTION = "15.4-2"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Array Objects"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +new TestCase( SECTION, + "var arr=new Array(); arr[Math.pow(2,16)] = 'hi'; arr.length", + Math.pow(2,16)+1, + eval("var arr=new Array(); arr[Math.pow(2,16)] = 'hi'; arr.length") ); + +new TestCase( SECTION, + "var arr=new Array(); arr[Math.pow(2,30)-2] = 'hi'; arr.length", + Math.pow(2,30)-1, + eval("var arr=new Array(); arr[Math.pow(2,30)-2] = 'hi'; arr.length") ); + +new TestCase( SECTION, + "var arr=new Array(); arr[Math.pow(2,30)-1] = 'hi'; arr.length", + Math.pow(2,30), + eval("var arr=new Array(); arr[Math.pow(2,30)-1] = 'hi'; arr.length") ); + +new TestCase( SECTION, + "var arr=new Array(); arr[Math.pow(2,30)] = 'hi'; arr.length", + Math.pow(2,30)+1, + eval("var arr=new Array(); arr[Math.pow(2,30)] = 'hi'; arr.length") ); + + +new TestCase( SECTION, + "var arr=new Array(); arr[Math.pow(2,31)-2] = 'hi'; arr.length", + Math.pow(2,31)-1, + eval("var arr=new Array(); arr[Math.pow(2,31)-2] = 'hi'; arr.length") ); + +new TestCase( SECTION, + "var arr=new Array(); arr[Math.pow(2,31)-1] = 'hi'; arr.length", + Math.pow(2,31), + eval("var arr=new Array(); arr[Math.pow(2,31)-1] = 'hi'; arr.length") ); + +new TestCase( SECTION, + "var arr=new Array(); arr[Math.pow(2,31)] = 'hi'; arr.length", + Math.pow(2,31)+1, + eval("var arr=new Array(); arr[Math.pow(2,31)] = 'hi'; arr.length") ); + +new TestCase( SECTION, + "var arr = new Array(0,1,2,3,4,5); arr.length = 2; String(arr)", + "0,1", + eval("var arr = new Array(0,1,2,3,4,5); arr.length = 2; String(arr)") ); + +new TestCase( SECTION, + "var arr = new Array(0,1); arr.length = 3; String(arr)", + "0,1,", + eval("var arr = new Array(0,1); arr.length = 3; String(arr)") ); + +test(); + diff --git a/tests/auto/qml/parserstress/tests/ecma/Array/15.4.1.1.js b/tests/auto/qml/parserstress/tests/ecma/Array/15.4.1.1.js new file mode 100644 index 0000000000..b894433d01 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Array/15.4.1.1.js @@ -0,0 +1,111 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.4.1.1.js'; + +/** + File Name: 15.4.1.1.js + ECMA Section: 15.4.1 Array( item0, item1,... ) + + Description: When Array is called as a function rather than as a + constructor, it creates and initializes a new array + object. Thus, the function call Array(...) is + equivalent to the object creation new Array(...) with + the same arguments. + + An array is created and returned as if by the expression + new Array( item0, item1, ... ). + + Author: christine@netscape.com + Date: 7 october 1997 +*/ +var SECTION = "15.4.1.1"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Array Constructor Called as a Function"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +new TestCase( SECTION, + "typeof Array(1,2)", + "object", + typeof Array(1,2) ); + +new TestCase( SECTION, + "(Array(1,2)).toString", + Array.prototype.toString, + (Array(1,2)).toString ); + +new TestCase( SECTION, + "var arr = Array(1,2,3); arr.toString = Object.prototype.toString; arr.toString()", + "[object Array]", + eval("var arr = Array(1,2,3); arr.toString = Object.prototype.toString; arr.toString()") ); + +new TestCase( SECTION, + "(Array(1,2)).length", + 2, + (Array(1,2)).length ); + +new TestCase( SECTION, + "var arr = (Array(1,2)); arr[0]", + 1, + eval("var arr = (Array(1,2)); arr[0]") ); + +new TestCase( SECTION, + "var arr = (Array(1,2)); arr[1]", + 2, + eval("var arr = (Array(1,2)); arr[1]") ); + +new TestCase( SECTION, + "var arr = (Array(1,2)); String(arr)", + "1,2", + eval("var arr = (Array(1,2)); String(arr)") ); + +test(); + +function ToUint32( n ) { + n = Number( n ); + if( isNaN(n) || n == 0 || n == Number.POSITIVE_INFINITY || + n == Number.NEGATIVE_INFINITY ) { + return 0; + } + var sign = n < 0 ? -1 : 1; + + return ( sign * ( n * Math.floor( Math.abs(n) ) ) ) % Math.pow(2, 32); +} + diff --git a/tests/auto/qml/parserstress/tests/ecma/Array/15.4.1.2.js b/tests/auto/qml/parserstress/tests/ecma/Array/15.4.1.2.js new file mode 100644 index 0000000000..7e2e7ef436 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Array/15.4.1.2.js @@ -0,0 +1,162 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.4.1.2.js'; + +/** + File Name: 15.4.1.2.js + ECMA Section: 15.4.1.2 Array(len) + + Description: When Array is called as a function rather than as a + constructor, it creates and initializes a new array + object. Thus, the function call Array(...) is + equivalent to the object creationi new Array(...) with + the same arguments. + + An array is created and returned as if by the + expression new Array(len). + + Author: christine@netscape.com + Date: 7 october 1997 +*/ +var SECTION = "15.4.1.2"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Array Constructor Called as a Function: Array(len)"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +new TestCase( SECTION, + "(Array()).length", + 0, + (Array()).length ); + +new TestCase( SECTION, + "(Array(0)).length", + 0, + (Array(0)).length ); + +new TestCase( SECTION, + "(Array(1)).length", + 1, + (Array(1)).length ); + +new TestCase( SECTION, + "(Array(10)).length", + 10, + (Array(10)).length ); + +new TestCase( SECTION, + "(Array('1')).length", + 1, + (Array('1')).length ); + +new TestCase( SECTION, + "(Array(1000)).length", + 1000, + (Array(1000)).length ); + +new TestCase( SECTION, + "(Array('1000')).length", + 1, + (Array('1000')).length ); + +new TestCase( SECTION, + "(Array(4294967295)).length", + ToUint32(4294967295), + (Array(4294967295)).length ); + +new TestCase( SECTION, + "(Array(Math.pow(2,31)-1)).length", + ToUint32(Math.pow(2,31)-1), + (Array(Math.pow(2,31)-1)).length ); + +new TestCase( SECTION, + "(Array(Math.pow(2,31))).length", + ToUint32(Math.pow(2,31)), + (Array(Math.pow(2,31))).length ); + +new TestCase( SECTION, + "(Array(Math.pow(2,31)+1)).length", + ToUint32(Math.pow(2,31)+1), + (Array(Math.pow(2,31)+1)).length ); + +new TestCase( SECTION, + "(Array('8589934592')).length", + 1, + (Array("8589934592")).length ); + +new TestCase( SECTION, + "(Array('4294967296')).length", + 1, + (Array("4294967296")).length ); + +new TestCase( SECTION, + "(Array(1073741823)).length", + ToUint32(1073741823), + (Array(1073741823)).length ); + +new TestCase( SECTION, + "(Array(1073741824)).length", + ToUint32(1073741824), + (Array(1073741824)).length ); + +new TestCase( SECTION, + "(Array('a string')).length", + 1, + (Array("a string")).length ); + +test(); + +function ToUint32( n ) { + n = Number( n ); + var sign = ( n < 0 ) ? -1 : 1; + + if ( Math.abs( n ) == 0 || Math.abs( n ) == Number.POSITIVE_INFINITY) { + return 0; + } + n = sign * Math.floor( Math.abs(n) ) + + n = n % Math.pow(2,32); + + if ( n < 0 ){ + n += Math.pow(2,32); + } + + return ( n ); +} diff --git a/tests/auto/qml/parserstress/tests/ecma/Array/15.4.1.3.js b/tests/auto/qml/parserstress/tests/ecma/Array/15.4.1.3.js new file mode 100644 index 0000000000..b36f339966 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Array/15.4.1.3.js @@ -0,0 +1,84 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.4.1.3.js'; + +/** + File Name: 15.4.1.3.js + ECMA Section: 15.4.1.3 Array() + + Description: When Array is called as a function rather than as a + constructor, it creates and initializes a new array + object. Thus, the function call Array(...) is + equivalent to the object creationi new Array(...) with + the same arguments. + + An array is created and returned as if by the + expression new Array(len). + + Author: christine@netscape.com + Date: 7 october 1997 +*/ +var SECTION = "15.4.1.3"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Array Constructor Called as a Function: Array()"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +new TestCase( SECTION, + "typeof Array()", + "object", + typeof Array() ); + +new TestCase( SECTION, + "MYARR = new Array();MYARR.getClass = Object.prototype.toString;MYARR.getClass()", + "[object Array]", + eval("MYARR = Array();MYARR.getClass = Object.prototype.toString;MYARR.getClass()") ); + +new TestCase( SECTION, + "(Array()).length", + 0, + (Array()).length ); + +new TestCase( SECTION, + "Array().toString()", + "", + Array().toString() ); + +test(); diff --git a/tests/auto/qml/parserstress/tests/ecma/Array/15.4.1.js b/tests/auto/qml/parserstress/tests/ecma/Array/15.4.1.js new file mode 100644 index 0000000000..414c901926 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Array/15.4.1.js @@ -0,0 +1,132 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.4.1.js'; + +/** + File Name: 15.4.1.js + ECMA Section: 15.4.1 The Array Constructor Called as a Function + + Description: When Array is called as a function rather than as a + constructor, it creates and initializes a new array + object. Thus, the function call Array(...) is + equivalent to the object creationi new Array(...) with + the same arguments. + + Author: christine@netscape.com + Date: 7 october 1997 +*/ + +var SECTION = "15.4.1"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "The Array Constructor Called as a Function"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +new TestCase( SECTION, + "Array() +''", + "", + Array() +"" ); + +new TestCase( SECTION, + "typeof Array()", + "object", + typeof Array() ); + +new TestCase( SECTION, + "var arr = Array(); arr.getClass = Object.prototype.toString; arr.getClass()", + "[object Array]", + eval("var arr = Array(); arr.getClass = Object.prototype.toString; arr.getClass()") ); + +new TestCase( SECTION, + "var arr = Array(); arr.toString == Array.prototype.toString", + true, + eval("var arr = Array(); arr.toString == Array.prototype.toString") ); + +new TestCase( SECTION, + "Array().length", + 0, + Array().length ); + +new TestCase( SECTION, + "Array(1,2,3) +''", + "1,2,3", + Array(1,2,3) +"" ); + +new TestCase( SECTION, + "typeof Array(1,2,3)", + "object", + typeof Array(1,2,3) ); + +new TestCase( SECTION, + "var arr = Array(1,2,3); arr.getClass = Object.prototype.toString; arr.getClass()", + "[object Array]", + eval("var arr = Array(1,2,3); arr.getClass = Object.prototype.toString; arr.getClass()") ); + +new TestCase( SECTION, + "var arr = Array(1,2,3); arr.toString == Array.prototype.toString", + true, + eval("var arr = Array(1,2,3); arr.toString == Array.prototype.toString") ); + +new TestCase( SECTION, + "Array(1,2,3).length", + 3, + Array(1,2,3).length ); + +new TestCase( SECTION, + "typeof Array(12345)", + "object", + typeof Array(12345) ); + +new TestCase( SECTION, + "var arr = Array(12345); arr.getClass = Object.prototype.toString; arr.getClass()", + "[object Array]", + eval("var arr = Array(12345); arr.getClass = Object.prototype.toString; arr.getClass()") ); + +new TestCase( SECTION, + "var arr = Array(1,2,3,4,5); arr.toString == Array.prototype.toString", + true, + eval("var arr = Array(1,2,3,4,5); arr.toString == Array.prototype.toString") ); + +new TestCase( SECTION, + "Array(12345).length", + 12345, + Array(12345).length ); + +test(); diff --git a/tests/auto/qml/parserstress/tests/ecma/Array/15.4.2.1-1.js b/tests/auto/qml/parserstress/tests/ecma/Array/15.4.2.1-1.js new file mode 100644 index 0000000000..986684e338 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Array/15.4.2.1-1.js @@ -0,0 +1,112 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.4.2.1-1.js'; + +/** + File Name: 15.4.2.1-1.js + ECMA Section: 15.4.2.1 new Array( item0, item1, ... ) + Description: This description only applies of the constructor is + given two or more arguments. + + The [[Prototype]] property of the newly constructed + object is set to the original Array prototype object, + the one that is the initial value of Array.prototype + (15.4.3.1). + + The [[Class]] property of the newly constructed object + is set to "Array". + + The length property of the newly constructed object is + set to the number of arguments. + + The 0 property of the newly constructed object is set + to item0... in general, for as many arguments as there + are, the k property of the newly constructed object is + set to argument k, where the first argument is + considered to be argument number 0. + + This file tests the typeof the newly constructed object. + + Author: christine@netscape.com + Date: 7 october 1997 +*/ + +var SECTION = "15.4.2.1-1"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "The Array Constructor: new Array( item0, item1, ...)"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +new TestCase( SECTION, + "typeof new Array(1,2)", + "object", + typeof new Array(1,2) ); + +new TestCase( SECTION, + "(new Array(1,2)).toString", + Array.prototype.toString, + (new Array(1,2)).toString ); + +new TestCase( SECTION, + "var arr = new Array(1,2,3); arr.getClass = Object.prototype.toString; arr.getClass()", + "[object Array]", + eval("var arr = new Array(1,2,3); arr.getClass = Object.prototype.toString; arr.getClass()") ); + +new TestCase( SECTION, + "(new Array(1,2)).length", + 2, + (new Array(1,2)).length ); + +new TestCase( SECTION, + "var arr = (new Array(1,2)); arr[0]", + 1, + eval("var arr = (new Array(1,2)); arr[0]") ); + +new TestCase( SECTION, + "var arr = (new Array(1,2)); arr[1]", + 2, + eval("var arr = (new Array(1,2)); arr[1]") ); + +new TestCase( SECTION, + "var arr = (new Array(1,2)); String(arr)", + "1,2", + eval("var arr = (new Array(1,2)); String(arr)") ); + +test(); diff --git a/tests/auto/qml/parserstress/tests/ecma/Array/15.4.2.1-2.js b/tests/auto/qml/parserstress/tests/ecma/Array/15.4.2.1-2.js new file mode 100644 index 0000000000..9e957cbb21 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Array/15.4.2.1-2.js @@ -0,0 +1,101 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.4.2.1-2.js'; + +/** + File Name: 15.4.2.1-2.js + ECMA Section: 15.4.2.1 new Array( item0, item1, ... ) + Description: This description only applies of the constructor is + given two or more arguments. + + The [[Prototype]] property of the newly constructed + object is set to the original Array prototype object, + the one that is the initial value of Array.prototype + (15.4.3.1). + + The [[Class]] property of the newly constructed object + is set to "Array". + + The length property of the newly constructed object is + set to the number of arguments. + + The 0 property of the newly constructed object is set + to item0... in general, for as many arguments as there + are, the k property of the newly constructed object is + set to argument k, where the first argument is + considered to be argument number 0. + + + Author: christine@netscape.com + Date: 7 october 1997 +*/ +var SECTION = "15.4.2.1-2"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "The Array Constructor: new Array( item0, item1, ...)"; + +writeHeaderToLog( SECTION + " "+ TITLE); + + +var TEST_STRING = "new Array("; +var ARGUMENTS = "" + var TEST_LENGTH = Math.pow(2,10); //Math.pow(2,32); + +for ( var index = 0; index < TEST_LENGTH; index++ ) { + ARGUMENTS += index; + ARGUMENTS += (index == (TEST_LENGTH-1) ) ? "" : ","; +} + +TEST_STRING += ARGUMENTS + ")"; + +TEST_ARRAY = eval( TEST_STRING ); + +for ( var item = 0; item < TEST_LENGTH; item++ ) { + new TestCase( SECTION, + "["+item+"]", + item, + TEST_ARRAY[item] ); +} + +new TestCase( SECTION, + "new Array( ["+TEST_LENGTH+" arguments] ) +''", + ARGUMENTS, + TEST_ARRAY +"" ); + +test(); diff --git a/tests/auto/qml/parserstress/tests/ecma/Array/15.4.2.1-3.js b/tests/auto/qml/parserstress/tests/ecma/Array/15.4.2.1-3.js new file mode 100644 index 0000000000..4d1806d9b8 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Array/15.4.2.1-3.js @@ -0,0 +1,137 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.4.2.1-3.js'; + +/** + File Name: 15.4.2.1-3.js + ECMA Section: 15.4.2.1 new Array( item0, item1, ... ) + Description: This description only applies of the constructor is + given two or more arguments. + + The [[Prototype]] property of the newly constructed + object is set to the original Array prototype object, + the one that is the initial value of Array.prototype + (15.4.3.1). + + The [[Class]] property of the newly constructed object + is set to "Array". + + The length property of the newly constructed object is + set to the number of arguments. + + The 0 property of the newly constructed object is set + to item0... in general, for as many arguments as there + are, the k property of the newly constructed object is + set to argument k, where the first argument is + considered to be argument number 0. + + This test stresses the number of arguments presented to + the Array constructor. Should support up to Math.pow + (2,32) arguments, since that is the maximum length of an + ECMAScript array. + + ***Change TEST_LENGTH to Math.pow(2,32) when larger array + lengths are supported. + + Author: christine@netscape.com + Date: 7 october 1997 +*/ +var SECTION = "15.4.2.1-3"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "The Array Constructor: new Array( item0, item1, ...)"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +var TEST_STRING = "new Array("; +var ARGUMENTS = "" + var TEST_LENGTH = Math.pow(2,10); //Math.pow(2,32); + +for ( var index = 0; index < TEST_LENGTH; index++ ) { + ARGUMENTS += index; + ARGUMENTS += (index == (TEST_LENGTH-1) ) ? "" : ","; +} + +TEST_STRING += ARGUMENTS + ")"; + +TEST_ARRAY = eval( TEST_STRING ); + +for ( var item = 0; item < TEST_LENGTH; item++ ) { + new TestCase( SECTION, + "TEST_ARRAY["+item+"]", + item, + TEST_ARRAY[item] ); +} + +new TestCase( SECTION, + "new Array( ["+TEST_LENGTH+" arguments] ) +''", + ARGUMENTS, + TEST_ARRAY +"" ); + +new TestCase( SECTION, + "TEST_ARRAY.toString", + Array.prototype.toString, + TEST_ARRAY.toString ); + +new TestCase( SECTION, + "TEST_ARRAY.join", + Array.prototype.join, + TEST_ARRAY.join ); + +new TestCase( SECTION, + "TEST_ARRAY.sort", + Array.prototype.sort, + TEST_ARRAY.sort ); + +new TestCase( SECTION, + "TEST_ARRAY.reverse", + Array.prototype.reverse, + TEST_ARRAY.reverse ); + +new TestCase( SECTION, + "TEST_ARRAY.length", + TEST_LENGTH, + TEST_ARRAY.length ); + +new TestCase( SECTION, + "TEST_ARRAY.toString = Object.prototype.toString; TEST_ARRAY.toString()", + "[object Array]", + eval("TEST_ARRAY.toString = Object.prototype.toString; TEST_ARRAY.toString()") ); + +test(); diff --git a/tests/auto/qml/parserstress/tests/ecma/Array/15.4.2.2-1.js b/tests/auto/qml/parserstress/tests/ecma/Array/15.4.2.2-1.js new file mode 100644 index 0000000000..255d0b5fb4 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Array/15.4.2.2-1.js @@ -0,0 +1,183 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.4.2.2-1.js'; + +/** + File Name: 15.4.2.2-1.js + ECMA Section: 15.4.2.2 new Array(len) + + Description: This description only applies of the constructor is + given two or more arguments. + + The [[Prototype]] property of the newly constructed + object is set to the original Array prototype object, + the one that is the initial value of Array.prototype(0) + (15.4.3.1). + + The [[Class]] property of the newly constructed object + is set to "Array". + + If the argument len is a number, then the length + property of the newly constructed object is set to + ToUint32(len). + + If the argument len is not a number, then the length + property of the newly constructed object is set to 1 + and the 0 property of the newly constructed object is + set to len. + + This file tests cases where len is a number. + + The cases in this test need to be updated since the + ToUint32 description has changed. + + Author: christine@netscape.com + Date: 7 october 1997 +*/ +var SECTION = "15.4.2.2-1"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "The Array Constructor: new Array( len )"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +new TestCase( SECTION, + "new Array(0)", + "", + (new Array(0)).toString() ); + +new TestCase( SECTION, + "typeof new Array(0)", + "object", + (typeof new Array(0)) ); + +new TestCase( SECTION, + "(new Array(0)).length", + 0, + (new Array(0)).length ); + +new TestCase( SECTION, + "(new Array(0)).toString", + Array.prototype.toString, + (new Array(0)).toString ); + +new TestCase( SECTION, + "new Array(1)", + "", + (new Array(1)).toString() ); + +new TestCase( SECTION, + "new Array(1).length", + 1, + (new Array(1)).length ); + +new TestCase( SECTION, + "(new Array(1)).toString", + Array.prototype.toString, + (new Array(1)).toString ); + +new TestCase( SECTION, + "(new Array(-0)).length", + 0, + (new Array(-0)).length ); + +new TestCase( SECTION, + "(new Array(0)).length", + 0, + (new Array(0)).length ); + +new TestCase( SECTION, + "(new Array(10)).length", + 10, + (new Array(10)).length ); + +new TestCase( SECTION, + "(new Array('1')).length", + 1, + (new Array('1')).length ); + +new TestCase( SECTION, + "(new Array(1000)).length", + 1000, + (new Array(1000)).length ); + +new TestCase( SECTION, + "(new Array('1000')).length", + 1, + (new Array('1000')).length ); + +new TestCase( SECTION, + "(new Array(4294967295)).length", + ToUint32(4294967295), + (new Array(4294967295)).length ); + +new TestCase( SECTION, + "(new Array('8589934592')).length", + 1, + (new Array("8589934592")).length ); + +new TestCase( SECTION, + "(new Array('4294967296')).length", + 1, + (new Array("4294967296")).length ); + +new TestCase( SECTION, + "(new Array(1073741824)).length", + ToUint32(1073741824), + (new Array(1073741824)).length ); + +test(); + +function ToUint32( n ) { + n = Number( n ); + var sign = ( n < 0 ) ? -1 : 1; + + if ( Math.abs( n ) == 0 || Math.abs( n ) == Number.POSITIVE_INFINITY) { + return 0; + } + n = sign * Math.floor( Math.abs(n) ) + + n = n % Math.pow(2,32); + + if ( n < 0 ){ + n += Math.pow(2,32); + } + + return ( n ); +} diff --git a/tests/auto/qml/parserstress/tests/ecma/Array/15.4.2.2-2.js b/tests/auto/qml/parserstress/tests/ecma/Array/15.4.2.2-2.js new file mode 100644 index 0000000000..e77ba8d876 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Array/15.4.2.2-2.js @@ -0,0 +1,118 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.4.2.2-2.js'; + +/** + File Name: 15.4.2.2-2.js + ECMA Section: 15.4.2.2 new Array(len) + + Description: This description only applies of the constructor is + given two or more arguments. + + The [[Prototype]] property of the newly constructed + object is set to the original Array prototype object, + the one that is the initial value of Array.prototype(0) + (15.4.3.1). + + The [[Class]] property of the newly constructed object + is set to "Array". + + If the argument len is a number, then the length + property of the newly constructed object is set to + ToUint32(len). + + If the argument len is not a number, then the length + property of the newly constructed object is set to 1 + and the 0 property of the newly constructed object is + set to len. + + This file tests length of the newly constructed array + when len is not a number. + + Author: christine@netscape.com + Date: 7 october 1997 +*/ +var SECTION = "15.4.2.2-2"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "The Array Constructor: new Array( len )"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +new TestCase( SECTION, + "(new Array(new Number(1073741823))).length", + 1, + (new Array(new Number(1073741823))).length ); + +new TestCase( SECTION, + "(new Array(new Number(0))).length", + 1, + (new Array(new Number(0))).length ); + +new TestCase( SECTION, + "(new Array(new Number(1000))).length", + 1, + (new Array(new Number(1000))).length ); + +new TestCase( SECTION, + "(new Array('mozilla, larryzilla, curlyzilla')).length", + 1, + (new Array('mozilla, larryzilla, curlyzilla')).length ); + +new TestCase( SECTION, + "(new Array(true)).length", + 1, + (new Array(true)).length ); + +new TestCase( SECTION, + "(new Array(false)).length", + 1, + (new Array(false)).length); + +new TestCase( SECTION, + "(new Array(new Boolean(true)).length", + 1, + (new Array(new Boolean(true))).length ); + +new TestCase( SECTION, + "(new Array(new Boolean(false)).length", + 1, + (new Array(new Boolean(false))).length ); + +test(); diff --git a/tests/auto/qml/parserstress/tests/ecma/Array/15.4.2.3.js b/tests/auto/qml/parserstress/tests/ecma/Array/15.4.2.3.js new file mode 100644 index 0000000000..27d9bd257b --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Array/15.4.2.3.js @@ -0,0 +1,101 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.4.2.3.js'; + +/** + File Name: 15.4.2.3.js + ECMA Section: 15.4.2.3 new Array() + Description: The [[Prototype]] property of the newly constructed + object is set to the origianl Array prototype object, + the one that is the initial value of Array.prototype. + The [[Class]] property of the new object is set to + "Array". The length of the object is set to 0. + + Author: christine@netscape.com + Date: 7 october 1997 +*/ + +var SECTION = "15.4.2.3"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "The Array Constructor: new Array()"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +new TestCase( SECTION, + "new Array() +''", + "", + (new Array()) +"" ); + +new TestCase( SECTION, + "typeof new Array()", + "object", + (typeof new Array()) ); + +new TestCase( SECTION, + "var arr = new Array(); arr.getClass = Object.prototype.toString; arr.getClass()", + "[object Array]", + eval("var arr = new Array(); arr.getClass = Object.prototype.toString; arr.getClass()") ); + +new TestCase( SECTION, + "(new Array()).length", + 0, + (new Array()).length ); + +new TestCase( SECTION, + "(new Array()).toString == Array.prototype.toString", + true, + (new Array()).toString == Array.prototype.toString ); + +new TestCase( SECTION, + "(new Array()).join == Array.prototype.join", + true, + (new Array()).join == Array.prototype.join ); + +new TestCase( SECTION, + "(new Array()).reverse == Array.prototype.reverse", + true, + (new Array()).reverse == Array.prototype.reverse ); + +new TestCase( SECTION, + "(new Array()).sort == Array.prototype.sort", + true, + (new Array()).sort == Array.prototype.sort ); + +test(); diff --git a/tests/auto/qml/parserstress/tests/ecma/Array/15.4.3.1-2.js b/tests/auto/qml/parserstress/tests/ecma/Array/15.4.3.1-2.js new file mode 100644 index 0000000000..36c1967f16 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Array/15.4.3.1-2.js @@ -0,0 +1,81 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.4.3.1-2.js'; + +/** + File Name: 15.4.3.1-1.js + ECMA Section: 15.4.3.1 Array.prototype + Description: The initial value of Array.prototype is the built-in + Array prototype object (15.4.4). + + Author: christine@netscape.com + Date: 7 october 1997 +*/ + +var SECTION = "15.4.3.1-1"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Array.prototype"; + +writeHeaderToLog( SECTION + " "+ TITLE); + + +var ARRAY_PROTO = Array.prototype; + +new TestCase( SECTION, + "var props = ''; for ( p in Array ) { props += p } props", + "", + eval("var props = ''; for ( p in Array ) { props += p } props") ); + +new TestCase( SECTION, + "Array.prototype = null; Array.prototype", + ARRAY_PROTO, + eval("Array.prototype = null; Array.prototype") ); + +new TestCase( SECTION, + "delete Array.prototype", + false, + delete Array.prototype ); + +new TestCase( SECTION, + "delete Array.prototype; Array.prototype", + ARRAY_PROTO, + eval("delete Array.prototype; Array.prototype") ); + +test(); diff --git a/tests/auto/qml/parserstress/tests/ecma/Array/15.4.3.2.js b/tests/auto/qml/parserstress/tests/ecma/Array/15.4.3.2.js new file mode 100644 index 0000000000..dfb47ca284 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Array/15.4.3.2.js @@ -0,0 +1,62 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.4.3.2.js'; + +/** + File Name: 15.4.3.2.js + ECMA Section: 15.4.3.2 Array.length + Description: The length property is 1. + + Author: christine@netscape.com + Date: 7 october 1997 +*/ + +var SECTION = "15.4.3.2"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Array.length"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +new TestCase( SECTION, + "Array.length", + 1, + Array.length ); + +test(); diff --git a/tests/auto/qml/parserstress/tests/ecma/Array/15.4.4.1.js b/tests/auto/qml/parserstress/tests/ecma/Array/15.4.4.1.js new file mode 100644 index 0000000000..bd886b0cb0 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Array/15.4.4.1.js @@ -0,0 +1,63 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.4.4.1.js'; + +/** + File Name: 15.4.4.1.js + ECMA Section: 15.4.4.1 Array.prototype.constructor + Description: The initial value of Array.prototype.constructor + is the built-in Array constructor. + Author: christine@netscape.com + Date: 7 october 1997 +*/ + +var SECTION = "15.4.4.1"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Array.prototype.constructor"; + +writeHeaderToLog( SECTION + " "+ TITLE); + + +new TestCase( SECTION, + "Array.prototype.constructor == Array", + true, + Array.prototype.constructor == Array); + +test(); diff --git a/tests/auto/qml/parserstress/tests/ecma/Array/15.4.4.2.js b/tests/auto/qml/parserstress/tests/ecma/Array/15.4.4.2.js new file mode 100644 index 0000000000..d0be6bd471 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Array/15.4.4.2.js @@ -0,0 +1,120 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.4.4.2.js'; + +/** + File Name: 15.4.4.2.js + ECMA Section: 15.4.4.2 Array.prototype.toString() + Description: The elements of this object are converted to strings + and these strings are then concatenated, separated by + comma characters. The result is the same as if the + built-in join method were invoiked for this object + with no argument. + Author: christine@netscape.com + Date: 7 october 1997 +*/ + +var SECTION = "15.4.4.2"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Array.prototype.toString"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +print(1); +new TestCase( SECTION, + "Array.prototype.toString.length", + 0, + Array.prototype.toString.length ); + +print(2); +new TestCase( SECTION, + "(new Array()).toString()", + "", + (new Array()).toString() ); + +print(3); +new TestCase( SECTION, + "(new Array(2)).toString()", + ",", + (new Array(2)).toString() ); + +print(4); +new TestCase( SECTION, + "(new Array(0,1)).toString()", + "0,1", + (new Array(0,1)).toString() ); + +print(5); +new TestCase( SECTION, + "(new Array( Number.NaN, Number.POSITIVE_INFINITY, Number.NEGATIVE_INFINITY)).toString()", + "NaN,Infinity,-Infinity", + (new Array( Number.NaN, Number.POSITIVE_INFINITY, Number.NEGATIVE_INFINITY)).toString() ); + +print(6); +new TestCase( SECTION, + "(new Array( Boolean(1), Boolean(0))).toString()", + "true,false", + (new Array(Boolean(1),Boolean(0))).toString() ); + +print(7); +new TestCase( SECTION, + "(new Array(void 0,null)).toString()", + ",", + (new Array(void 0,null)).toString() ); + +print(8); +var EXPECT_STRING = ""; +var MYARR = new Array(); + +for ( var i = -50; i < 50; i+= 0.25 ) { + print(i); + MYARR[MYARR.length] = i; + EXPECT_STRING += i +","; +} + +EXPECT_STRING = EXPECT_STRING.substring( 0, EXPECT_STRING.length -1 ); + +print(9); +new TestCase( SECTION, + "MYARR.toString()", + EXPECT_STRING, + MYARR.toString() ); + +test(); diff --git a/tests/auto/qml/parserstress/tests/ecma/Array/15.4.4.3-1.js b/tests/auto/qml/parserstress/tests/ecma/Array/15.4.4.3-1.js new file mode 100644 index 0000000000..ff97512a44 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Array/15.4.4.3-1.js @@ -0,0 +1,163 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.4.4.3-1.js'; + +/** + File Name: 15.4.4.3-1.js + ECMA Section: 15.4.4.3-1 Array.prototype.join() + Description: The elements of this object are converted to strings and + these strings are then concatenated, separated by comma + characters. The result is the same as if the built-in join + method were invoiked for this object with no argument. + Author: christine@netscape.com, pschwartau@netscape.com + Date: 07 October 1997 + Modified: 14 July 2002 + Reason: See http://bugzilla.mozilla.org/show_bug.cgi?id=155285 + ECMA-262 Ed.3 Section 15.4.4.5 Array.prototype.join() + Step 3: If |separator| is |undefined|, let |separator| + be the single-character string "," + * + */ + +var SECTION = "15.4.4.3-1"; +var VERSION = "ECMA_1"; +startTest(); + +writeHeaderToLog( SECTION + " Array.prototype.join()"); + +var ARR_PROTOTYPE = Array.prototype; + +new TestCase( SECTION, "Array.prototype.join.length", 1, Array.prototype.join.length ); +new TestCase( SECTION, "delete Array.prototype.join.length", false, delete Array.prototype.join.length ); +new TestCase( SECTION, "delete Array.prototype.join.length; Array.prototype.join.length", 1, eval("delete Array.prototype.join.length; Array.prototype.join.length") ); + +// case where array length is 0 + +new TestCase( SECTION, + "var TEST_ARRAY = new Array(); TEST_ARRAY.join()", + "", + eval("var TEST_ARRAY = new Array(); TEST_ARRAY.join()") ); + +// array length is 0, but spearator is specified + +new TestCase( SECTION, + "var TEST_ARRAY = new Array(); TEST_ARRAY.join(' ')", + "", + eval("var TEST_ARRAY = new Array(); TEST_ARRAY.join(' ')") ); + +// length is greater than 0, separator is supplied +new TestCase( SECTION, + "var TEST_ARRAY = new Array(null, void 0, true, false, 123, new Object(), new Boolean(true) ); TEST_ARRAY.join('&')", + "&&true&false&123&[object Object]&true", + eval("var TEST_ARRAY = new Array(null, void 0, true, false, 123, new Object(), new Boolean(true) ); TEST_ARRAY.join('&')") ); + +// length is greater than 0, separator is empty string +new TestCase( SECTION, + "var TEST_ARRAY = new Array(null, void 0, true, false, 123, new Object(), new Boolean(true) ); TEST_ARRAY.join('')", + "truefalse123[object Object]true", + eval("var TEST_ARRAY = new Array(null, void 0, true, false, 123, new Object(), new Boolean(true) ); TEST_ARRAY.join('')") ); + +// length is greater than 0, separator is undefined +new TestCase( SECTION, + "var TEST_ARRAY = new Array(null, void 0, true, false, 123, new Object(), new Boolean(true) ); TEST_ARRAY.join(void 0)", + ",,true,false,123,[object Object],true", + eval("var TEST_ARRAY = new Array(null, void 0, true, false, 123, new Object(), new Boolean(true) ); TEST_ARRAY.join(void 0)") ); + +// length is greater than 0, separator is not supplied +new TestCase( SECTION, + "var TEST_ARRAY = new Array(null, void 0, true, false, 123, new Object(), new Boolean(true) ); TEST_ARRAY.join()", + ",,true,false,123,[object Object],true", + eval("var TEST_ARRAY = new Array(null, void 0, true, false, 123, new Object(), new Boolean(true) ); TEST_ARRAY.join()") ); + +// separator is a control character +new TestCase( SECTION, + "var TEST_ARRAY = new Array(null, void 0, true, false, 123, new Object(), new Boolean(true) ); TEST_ARRAY.join('\v')", + decodeURIComponent("%0B%0Btrue%0Bfalse%0B123%0B[object Object]%0Btrue"), + eval("var TEST_ARRAY = new Array(null, void 0, true, false, 123, new Object(), new Boolean(true) ); TEST_ARRAY.join('\v')") ); + +// length of array is 1 +new TestCase( SECTION, + "var TEST_ARRAY = new Array(true) ); TEST_ARRAY.join('\v')", + "true", + eval("var TEST_ARRAY = new Array(true); TEST_ARRAY.join('\v')") ); + + +SEPARATOR = "\t" + TEST_LENGTH = 100; +TEST_STRING = ""; +ARGUMENTS = ""; +TEST_RESULT = ""; + +for ( var index = 0; index < TEST_LENGTH; index++ ) { + ARGUMENTS += index; + ARGUMENTS += ( index == TEST_LENGTH -1 ) ? "" : ","; + + TEST_RESULT += index; + TEST_RESULT += ( index == TEST_LENGTH -1 ) ? "" : SEPARATOR; +} + +TEST_ARRAY = eval( "new Array( "+ARGUMENTS +")" ); + +new TestCase( SECTION, + "TEST_ARRAY.join("+SEPARATOR+")", + TEST_RESULT, + TEST_ARRAY.join( SEPARATOR ) ); + +new TestCase( SECTION, + "(new Array( Boolean(true), Boolean(false), null, void 0, Number(1e+21), Number(1e-7))).join()", + "true,false,,,1e+21,1e-7", + (new Array( Boolean(true), Boolean(false), null, void 0, Number(1e+21), Number(1e-7))).join() ); + +// this is not an Array object +new TestCase( SECTION, + "var OB = new Object_1('true,false,111,0.5,1.23e6,NaN,void 0,null'); OB.join(':')", + "true:false:111:0.5:1230000:NaN::", + eval("var OB = new Object_1('true,false,111,0.5,1.23e6,NaN,void 0,null'); OB.join(':')") ); + +test(); + +function Object_1( value ) { + this.array = value.split(","); + this.length = this.array.length; + for ( var i = 0; i < this.length; i++ ) { + this[i] = eval(this.array[i]); + } + this.join = Array.prototype.join; + this.getClass = Object.prototype.toString; +} diff --git a/tests/auto/qml/parserstress/tests/ecma/Array/15.4.4.4-1.js b/tests/auto/qml/parserstress/tests/ecma/Array/15.4.4.4-1.js new file mode 100644 index 0000000000..503d7e635e --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Array/15.4.4.4-1.js @@ -0,0 +1,294 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.4.4.4-1.js'; + +/** + File Name: 15.4.4.3-1.js + ECMA Section: 15.4.4.3-1 Array.prototype.reverse() + Description: + + The elements of the array are rearranged so as to reverse their order. + This object is returned as the result of the call. + + 1. Call the [[Get]] method of this object with argument "length". + 2. Call ToUint32(Result(1)). + 3. Compute floor(Result(2)/2). + 4. Let k be 0. + 5. If k equals Result(3), return this object. + 6. Compute Result(2)k1. + 7. Call ToString(k). + 8. ToString(Result(6)). + 9. Call the [[Get]] method of this object with argument Result(7). + 10. Call the [[Get]] method of this object with argument Result(8). + 11. If this object has a property named by Result(8), go to step 12; but + if this object has no property named by Result(8), then go to either + step 12 or step 14, depending on the implementation. + 12. Call the [[Put]] method of this object with arguments Result(7) and + Result(10). + 13. Go to step 15. + 14. Call the [[Delete]] method on this object, providing Result(7) as the + name of the property to delete. + 15. If this object has a property named by Result(7), go to step 16; but if + this object has no property named by Result(7), then go to either step 16 + or step 18, depending on the implementation. + 16. Call the [[Put]] method of this object with arguments Result(8) and + Result(9). + 17. Go to step 19. + 18. Call the [[Delete]] method on this object, providing Result(8) as the + name of the property to delete. + 19. Increase k by 1. + 20. Go to step 5. + + Note that the reverse function is intentionally generic; it does not require + that its this value be an Array object. Therefore it can be transferred to other + kinds of objects for use as a method. Whether the reverse function can be applied + successfully to a host object is implementation dependent. + + Note: Array.prototype.reverse allows some flexibility in implementation + regarding array indices that have not been populated. This test covers the + cases in which unpopulated indices are not deleted, since the JavaScript + implementation does not delete uninitialzed indices. + + Author: christine@netscape.com + Date: 7 october 1997 +*/ +var SECTION = "15.4.4.4-1"; +var VERSION = "ECMA_1"; +var BUGNUMBER="123724"; +startTest(); + +writeHeaderToLog( SECTION + " Array.prototype.reverse()"); + +var ARR_PROTOTYPE = Array.prototype; + +new TestCase( SECTION, + "Array.prototype.reverse.length", + 0, + Array.prototype.reverse.length ); + +new TestCase( SECTION, + "delete Array.prototype.reverse.length", + false, + delete Array.prototype.reverse.length ); + +new TestCase( SECTION, + "delete Array.prototype.reverse.length; Array.prototype.reverse.length", + 0, + eval("delete Array.prototype.reverse.length; Array.prototype.reverse.length") ); + +// length of array is 0 +new TestCase( SECTION, + "var A = new Array(); A.reverse(); A.length", + 0, + eval("var A = new Array(); A.reverse(); A.length") ); + +// length of array is 1 +var A = new Array(true); +var R = Reverse(A); + +new TestCase( SECTION, + "var A = new Array(true); A.reverse(); A.length", + R.length, + eval("var A = new Array(true); A.reverse(); A.length") ); + +CheckItems( R, A ); + +// length of array is 2 +var S = "var A = new Array( true,false )"; +eval(S); +var R = Reverse(A); + +new TestCase( SECTION, + S +"; A.reverse(); A.length", + R.length, + eval( S + "; A.reverse(); A.length") ); + +CheckItems( R, A ); + +// length of array is 3 +var S = "var A = new Array( true,false,null )"; +eval(S); +var R = Reverse(A); + +new TestCase( SECTION, + S +"; A.reverse(); A.length", + R.length, + eval( S + "; A.reverse(); A.length") ); + +CheckItems( R, A ); + +// length of array is 4 +var S = "var A = new Array( true,false,null,void 0 )"; +eval(S); +var R = Reverse(A); + +new TestCase( SECTION, + S +"; A.reverse(); A.length", + R.length, + eval( S + "; A.reverse(); A.length") ); +CheckItems( R, A ); + + +// some array indexes have not been set +var S = "var A = new Array(); A[8] = 'hi', A[3] = 'yo'"; +eval(S); +var R = Reverse(A); + +new TestCase( SECTION, + S +"; A.reverse(); A.length", + R.length, + eval( S + "; A.reverse(); A.length") ); + +CheckItems( R, A ); + + +var OBJECT_OBJECT = new Object(); +var FUNCTION_OBJECT = new Function( 'return this' ); +var BOOLEAN_OBJECT = new Boolean; +var DATE_OBJECT = new Date(0); +var STRING_OBJECT = new String('howdy'); +var NUMBER_OBJECT = new Number(Math.PI); +var ARRAY_OBJECT= new Array(1000); + +var args = "null, void 0, Math.pow(2,32), 1.234e-32, OBJECT_OBJECT, BOOLEAN_OBJECT, FUNCTION_OBJECT, DATE_OBJECT, STRING_OBJECT,"+ + "ARRAY_OBJECT, NUMBER_OBJECT, Math, true, false, 123, '90210'"; + +var S = "var A = new Array("+args+")"; +eval(S); +var R = Reverse(A); + +new TestCase( SECTION, + S +"; A.reverse(); A.length", + R.length, + eval( S + "; A.reverse(); A.length") ); + +CheckItems( R, A ); + +var limit = 1000; +var args = ""; +for (var i = 0; i < limit; i++ ) { + args += i +""; + if ( i + 1 < limit ) { + args += ","; + } +} + +var S = "var A = new Array("+args+")"; +eval(S); +var R = Reverse(A); + +new TestCase( SECTION, + S +"; A.reverse(); A.length", + R.length, + eval( S + "; A.reverse(); A.length") ); + +CheckItems( R, A ); + +var S = "var MYOBJECT = new Object_1( \"void 0, 1, null, 2, \'\'\" )"; +eval(S); +var R = Reverse( A ); + +new TestCase( SECTION, + S +"; A.reverse(); A.length", + R.length, + eval( S + "; A.reverse(); A.length") ); + +CheckItems( R, A ); + +test(); + +function CheckItems( R, A ) { + for ( var i = 0; i < R.length; i++ ) { + new TestCase( + SECTION, + "A["+i+ "]", + R[i], + A[i] ); + } +} + +function Object_1( value ) { + this.array = value.split(","); + this.length = this.array.length; + for ( var i = 0; i < this.length; i++ ) { + this[i] = eval(this.array[i]); + } + this.join = Array.prototype.reverse; + this.getClass = Object.prototype.toString; +} + +function Reverse( array ) { + var r2 = array.length; + var k = 0; + var r3 = Math.floor( r2/2 ); + if ( r3 == k ) { + return array; + } + + for ( k = 0; k < r3; k++ ) { + var r6 = r2 - k - 1; +// var r7 = String( k ); + var r7 = k; + var r8 = String( r6 ); + + var r9 = array[r7]; + var r10 = array[r8]; + + array[r7] = r10; + array[r8] = r9; + } + + return array; +} + +function Iterate( array ) { + for ( var i = 0; i < array.length; i++ ) { +// print( i+": "+ array[String(i)] ); + } +} + +function Object_1( value ) { + this.array = value.split(","); + this.length = this.array.length; + for ( var i = 0; i < this.length; i++ ) { + this[i] = this.array[i]; + } + this.reverse = Array.prototype.reverse; + this.getClass = Object.prototype.toString; +} diff --git a/tests/auto/qml/parserstress/tests/ecma/Array/15.4.4.4-2.js b/tests/auto/qml/parserstress/tests/ecma/Array/15.4.4.4-2.js new file mode 100644 index 0000000000..a9b7b0ec14 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Array/15.4.4.4-2.js @@ -0,0 +1,169 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.4.4.4-2.js'; + +/** + File Name: 15.4.4.3-1.js + ECMA Section: 15.4.4.3-1 Array.prototype.reverse() + Description: + + The elements of the array are rearranged so as to reverse their order. + This object is returned as the result of the call. + + 1. Call the [[Get]] method of this object with argument "length". + 2. Call ToUint32(Result(1)). + 3. Compute floor(Result(2)/2). + 4. Let k be 0. + 5. If k equals Result(3), return this object. + 6. Compute Result(2)k1. + 7. Call ToString(k). + 8. ToString(Result(6)). + 9. Call the [[Get]] method of this object with argument Result(7). + 10. Call the [[Get]] method of this object with argument Result(8). + 11. If this object has a property named by Result(8), go to step 12; but + if this object has no property named by Result(8), then go to either + step 12 or step 14, depending on the implementation. + 12. Call the [[Put]] method of this object with arguments Result(7) and + Result(10). + 13. Go to step 15. + 14. Call the [[Delete]] method on this object, providing Result(7) as the + name of the property to delete. + 15. If this object has a property named by Result(7), go to step 16; but if + this object has no property named by Result(7), then go to either step 16 + or step 18, depending on the implementation. + 16. Call the [[Put]] method of this object with arguments Result(8) and + Result(9). + 17. Go to step 19. + 18. Call the [[Delete]] method on this object, providing Result(8) as the + name of the property to delete. + 19. Increase k by 1. + 20. Go to step 5. + + Note that the reverse function is intentionally generic; it does not require + that its this value be an Array object. Therefore it can be transferred to other + kinds of objects for use as a method. Whether the reverse function can be applied + successfully to a host object is implementation dependent. + + Note: Array.prototype.reverse allows some flexibility in implementation + regarding array indices that have not been populated. This test covers the + cases in which unpopulated indices are not deleted, since the JavaScript + implementation does not delete uninitialzed indices. + + Author: christine@netscape.com + Date: 7 october 1997 +*/ + +var SECTION = "15.4.4.4-1"; +var VERSION = "ECMA_1"; +startTest(); + +writeHeaderToLog( SECTION + " Array.prototype.reverse()"); + +var ARR_PROTOTYPE = Array.prototype; + +new TestCase( SECTION, "Array.prototype.reverse.length", 0, Array.prototype.reverse.length ); +new TestCase( SECTION, "delete Array.prototype.reverse.length", false, delete Array.prototype.reverse.length ); +new TestCase( SECTION, "delete Array.prototype.reverse.length; Array.prototype.reverse.length", 0, eval("delete Array.prototype.reverse.length; Array.prototype.reverse.length") ); + +// length of array is 0 +new TestCase( SECTION, + "var A = new Array(); A.reverse(); A.length", + 0, + eval("var A = new Array(); A.reverse(); A.length") ); + +test(); + +function CheckItems( R, A ) { + for ( var i = 0; i < R.length; i++ ) { + new TestCase( + SECTION, + "A["+i+ "]", + R[i], + A[i] ); + } +} +test(); + +function Object_1( value ) { + this.array = value.split(","); + this.length = this.array.length; + for ( var i = 0; i < this.length; i++ ) { + this[i] = eval(this.array[i]); + } + this.join = Array.prototype.reverse; + this.getClass = Object.prototype.toString; +} +function Reverse( array ) { + var r2 = array.length; + var k = 0; + var r3 = Math.floor( r2/2 ); + if ( r3 == k ) { + return array; + } + + for ( k = 0; k < r3; k++ ) { + var r6 = r2 - k - 1; +// var r7 = String( k ); + var r7 = k; + var r8 = String( r6 ); + + var r9 = array[r7]; + var r10 = array[r8]; + + array[r7] = r10; + array[r8] = r9; + } + + return array; +} +function Iterate( array ) { + for ( var i = 0; i < array.length; i++ ) { +// print( i+": "+ array[String(i)] ); + } +} + +function Object_1( value ) { + this.array = value.split(","); + this.length = this.array.length; + for ( var i = 0; i < this.length; i++ ) { + this[i] = this.array[i]; + } + this.reverse = Array.prototype.reverse; + this.getClass = Object.prototype.toString; +} diff --git a/tests/auto/qml/parserstress/tests/ecma/Array/15.4.4.5-1.js b/tests/auto/qml/parserstress/tests/ecma/Array/15.4.4.5-1.js new file mode 100644 index 0000000000..a3a521da09 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Array/15.4.4.5-1.js @@ -0,0 +1,225 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.4.4.5-1.js'; + +/** + File Name: 15.4.4.5.js + ECMA Section: Array.prototype.sort(comparefn) + Description: + + This test file tests cases in which the compare function is not supplied. + + The elements of this array are sorted. The sort is not necessarily stable. + If comparefn is provided, it should be a function that accepts two arguments + x and y and returns a negative value if x < y, zero if x = y, or a positive + value if x > y. + + 1. Call the [[Get]] method of this object with argument "length". + 2. Call ToUint32(Result(1)). + 1. Perform an implementation-dependent sequence of calls to the + [[Get]] , [[Put]], and [[Delete]] methods of this object and + toSortCompare (described below), where the first argument for each call + to [[Get]], [[Put]] , or [[Delete]] is a nonnegative integer less + than Result(2) and where the arguments for calls to SortCompare are + results of previous calls to the [[Get]] method. After this sequence + is complete, this object must have the following two properties. + (1) There must be some mathematical permutation of the nonnegative + integers less than Result(2), such that for every nonnegative integer + j less than Result(2), if property old[j] existed, then new[(j)] is + exactly the same value as old[j],. but if property old[j] did not exist, + then new[(j)] either does not exist or exists with value undefined. + (2) If comparefn is not supplied or is a consistent comparison + function for the elements of this array, then for all nonnegative + integers j and k, each less than Result(2), if old[j] compares less + than old[k] (see SortCompare below), then (j) < (k). Here we use the + notation old[j] to refer to the hypothetical result of calling the [ + [Get]] method of this object with argument j before this step is + executed, and the notation new[j] to refer to the hypothetical result + of calling the [[Get]] method of this object with argument j after this + step has been completely executed. A function is a consistent + comparison function for a set of values if (a) for any two of those + values (possibly the same value) considered as an ordered pair, it + always returns the same value when given that pair of values as its + two arguments, and the result of applying ToNumber to this value is + not NaN; (b) when considered as a relation, where the pair (x, y) is + considered to be in the relation if and only if applying the function + to x and y and then applying ToNumber to the result produces a + negative value, this relation is a partial order; and (c) when + considered as a different relation, where the pair (x, y) is considered + to be in the relation if and only if applying the function to x and y + and then applying ToNumber to the result produces a zero value (of either + sign), this relation is an equivalence relation. In this context, the + phrase "x compares less than y" means applying Result(2) to x and y and + then applying ToNumber to the result produces a negative value. + 3.Return this object. + + When the SortCompare operator is called with two arguments x and y, the following steps are taken: + 1.If x and y are both undefined, return +0. + 2.If x is undefined, return 1. + 3.If y is undefined, return 1. + 4.If the argument comparefn was not provided in the call to sort, go to step 7. + 5.Call comparefn with arguments x and y. + 6.Return Result(5). + 7.Call ToString(x). + 8.Call ToString(y). + 9.If Result(7) < Result(8), return 1. + 10.If Result(7) > Result(8), return 1. + 11.Return +0. + + Note that, because undefined always compared greater than any other value, undefined and nonexistent + property values always sort to the end of the result. It is implementation-dependent whether or not such + properties will exist or not at the end of the array when the sort is concluded. + + Note that the sort function is intentionally generic; it does not require that its this value be an Array object. + Therefore it can be transferred to other kinds of objects for use as a method. Whether the sort function can be + applied successfully to a host object is implementation dependent . + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + + +var SECTION = "15.4.4.5-1"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Array.prototype.sort(comparefn)"; + +writeHeaderToLog( SECTION + " "+ TITLE); +var S = new Array(); +var item = 0; + +// array is empty. +S[item++] = "var A = new Array()"; + +// array contains one item +S[item++] = "var A = new Array( true )"; + +// length of array is 2 +S[item++] = "var A = new Array( true, false, new Boolean(true), new Boolean(false), 'true', 'false' )"; + +S[item++] = "var A = new Array(); A[3] = 'undefined'; A[6] = null; A[8] = 'null'; A[0] = void 0"; + +S[item] = "var A = new Array( "; + +var limit = 0x0061; +for ( var i = 0x007A; i >= limit; i-- ) { + S[item] += "\'"+ String.fromCharCode(i) +"\'" ; + if ( i > limit ) { + S[item] += ","; + } +} + +S[item] += ")"; + +item++; + +for ( var i = 0; i < S.length; i++ ) { + CheckItems( S[i] ); +} + +test(); + +function CheckItems( S ) { + eval( S ); + var E = Sort( A ); + + new TestCase( SECTION, + S +"; A.sort(); A.length", + E.length, + eval( S + "; A.sort(); A.length") ); + + for ( var i = 0; i < E.length; i++ ) { + new TestCase( + SECTION, + "A["+i+ "].toString()", + E[i] +"", + A[i] +""); + + if ( A[i] == void 0 && typeof A[i] == "undefined" ) { + new TestCase( + SECTION, + "typeof A["+i+ "]", + typeof E[i], + typeof A[i] ); + } + } +} +function Object_1( value ) { + this.array = value.split(","); + this.length = this.array.length; + for ( var i = 0; i < this.length; i++ ) { + this[i] = eval(this.array[i]); + } + this.sort = Array.prototype.sort; + this.getClass = Object.prototype.toString; +} +function Sort( a ) { + for ( i = 0; i < a.length; i++ ) { + for ( j = i+1; j < a.length; j++ ) { + var lo = a[i]; + var hi = a[j]; + var c = Compare( lo, hi ); + if ( c == 1 ) { + a[i] = hi; + a[j] = lo; + } + } + } + return a; +} +function Compare( x, y ) { + if ( x == void 0 && y == void 0 && typeof x == "undefined" && typeof y == "undefined" ) { + return +0; + } + if ( x == void 0 && typeof x == "undefined" ) { + return 1; + } + if ( y == void 0 && typeof y == "undefined" ) { + return -1; + } + x = String(x); + y = String(y); + if ( x < y ) { + return -1; + } + if ( x > y ) { + return 1; + } + return 0; +} diff --git a/tests/auto/qml/parserstress/tests/ecma/Array/15.4.4.5-2.js b/tests/auto/qml/parserstress/tests/ecma/Array/15.4.4.5-2.js new file mode 100644 index 0000000000..301c435d15 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Array/15.4.4.5-2.js @@ -0,0 +1,227 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.4.4.5-2.js'; + +/** + File Name: 15.4.4.5-2.js + ECMA Section: Array.prototype.sort(comparefn) + Description: + + This test file tests cases in which the compare function is supplied. + In this cases, the sort creates a reverse sort. + + The elements of this array are sorted. The sort is not necessarily stable. + If comparefn is provided, it should be a function that accepts two arguments + x and y and returns a negative value if x < y, zero if x = y, or a positive + value if x > y. + + 1. Call the [[Get]] method of this object with argument "length". + 2. Call ToUint32(Result(1)). + 1. Perform an implementation-dependent sequence of calls to the + [[Get]] , [[Put]], and [[Delete]] methods of this object and + toSortCompare (described below), where the first argument for each call + to [[Get]], [[Put]] , or [[Delete]] is a nonnegative integer less + than Result(2) and where the arguments for calls to SortCompare are + results of previous calls to the [[Get]] method. After this sequence + is complete, this object must have the following two properties. + (1) There must be some mathematical permutation of the nonnegative + integers less than Result(2), such that for every nonnegative integer + j less than Result(2), if property old[j] existed, then new[(j)] is + exactly the same value as old[j],. but if property old[j] did not exist, + then new[(j)] either does not exist or exists with value undefined. + (2) If comparefn is not supplied or is a consistent comparison + function for the elements of this array, then for all nonnegative + integers j and k, each less than Result(2), if old[j] compares less + than old[k] (see SortCompare below), then (j) < (k). Here we use the + notation old[j] to refer to the hypothetical result of calling the [ + [Get]] method of this object with argument j before this step is + executed, and the notation new[j] to refer to the hypothetical result + of calling the [[Get]] method of this object with argument j after this + step has been completely executed. A function is a consistent + comparison function for a set of values if (a) for any two of those + values (possibly the same value) considered as an ordered pair, it + always returns the same value when given that pair of values as its + two arguments, and the result of applying ToNumber to this value is + not NaN; (b) when considered as a relation, where the pair (x, y) is + considered to be in the relation if and only if applying the function + to x and y and then applying ToNumber to the result produces a + negative value, this relation is a partial order; and (c) when + considered as a different relation, where the pair (x, y) is considered + to be in the relation if and only if applying the function to x and y + and then applying ToNumber to the result produces a zero value (of either + sign), this relation is an equivalence relation. In this context, the + phrase "x compares less than y" means applying Result(2) to x and y and + then applying ToNumber to the result produces a negative value. + 3.Return this object. + + When the SortCompare operator is called with two arguments x and y, the following steps are taken: + 1.If x and y are both undefined, return +0. + 2.If x is undefined, return 1. + 3.If y is undefined, return 1. + 4.If the argument comparefn was not provided in the call to sort, go to step 7. + 5.Call comparefn with arguments x and y. + 6.Return Result(5). + 7.Call ToString(x). + 8.Call ToString(y). + 9.If Result(7) < Result(8), return 1. + 10.If Result(7) > Result(8), return 1. + 11.Return +0. + + Note that, because undefined always compared greater than any other value, undefined and nonexistent + property values always sort to the end of the result. It is implementation-dependent whether or not such + properties will exist or not at the end of the array when the sort is concluded. + + Note that the sort function is intentionally generic; it does not require that its this value be an Array object. + Therefore it can be transferred to other kinds of objects for use as a method. Whether the sort function can be + applied successfully to a host object is implementation dependent . + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + + +var SECTION = "15.4.4.5-2"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Array.prototype.sort(comparefn)"; + +writeHeaderToLog( SECTION + " "+ TITLE); + + +var S = new Array(); +var item = 0; + +// array is empty. +S[item++] = "var A = new Array()"; + +// array contains one item +S[item++] = "var A = new Array( true )"; + +// length of array is 2 +S[item++] = "var A = new Array( true, false, new Boolean(true), new Boolean(false), 'true', 'false' )"; + +S[item++] = "var A = new Array(); A[3] = 'undefined'; A[6] = null; A[8] = 'null'; A[0] = void 0"; + +S[item] = "var A = new Array( "; + +var limit = 0x0061; +for ( var i = 0x007A; i >= limit; i-- ) { + S[item] += "\'"+ String.fromCharCode(i) +"\'" ; + if ( i > limit ) { + S[item] += ","; + } +} + +S[item] += ")"; + +for ( var i = 0; i < S.length; i++ ) { + CheckItems( S[i] ); +} + +test(); + +function CheckItems( S ) { + eval( S ); + var E = Sort( A ); + + new TestCase( SECTION, + S +"; A.sort(Compare); A.length", + E.length, + eval( S + "; A.sort(Compare); A.length") ); + + for ( var i = 0; i < E.length; i++ ) { + new TestCase( + SECTION, + "A["+i+ "].toString()", + E[i] +"", + A[i] +""); + + if ( A[i] == void 0 && typeof A[i] == "undefined" ) { + new TestCase( + SECTION, + "typeof A["+i+ "]", + typeof E[i], + typeof A[i] ); + } + } +} +function Object_1( value ) { + this.array = value.split(","); + this.length = this.array.length; + for ( var i = 0; i < this.length; i++ ) { + this[i] = eval(this.array[i]); + } + this.sort = Array.prototype.sort; + this.getClass = Object.prototype.toString; +} +function Sort( a ) { + var r1 = a.length; + for ( i = 0; i < a.length; i++ ) { + for ( j = i+1; j < a.length; j++ ) { + var lo = a[i]; + var hi = a[j]; + var c = Compare( lo, hi ); + if ( c == 1 ) { + a[i] = hi; + a[j] = lo; + } + } + } + return a; +} +function Compare( x, y ) { + if ( x == void 0 && y == void 0 && typeof x == "undefined" && typeof y == "undefined" ) { + return +0; + } + if ( x == void 0 && typeof x == "undefined" ) { + return 1; + } + if ( y == void 0 && typeof y == "undefined" ) { + return -1; + } + x = String(x); + y = String(y); + if ( x < y ) { + return 1; + } + if ( x > y ) { + return -1; + } + return 0; +} diff --git a/tests/auto/qml/parserstress/tests/ecma/Array/15.4.4.5-3.js b/tests/auto/qml/parserstress/tests/ecma/Array/15.4.4.5-3.js new file mode 100644 index 0000000000..984d2fe80a --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Array/15.4.4.5-3.js @@ -0,0 +1,182 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.4.4.5-3.js'; + +/** + File Name: 15.4.4.5-3.js + ECMA Section: Array.prototype.sort(comparefn) + Description: + + This is a regression test for + http://scopus/bugsplat/show_bug.cgi?id=117144 + + Verify that sort is successfull, even if the sort compare function returns + a very large negative or positive value. + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + + +var SECTION = "15.4.4.5-3"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Array.prototype.sort(comparefn)"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +var array = new Array(); + +array[array.length] = new Date( TIME_2000 * Math.PI ); +array[array.length] = new Date( TIME_2000 * 10 ); +array[array.length] = new Date( TIME_1900 + TIME_1900 ); +array[array.length] = new Date(0); +array[array.length] = new Date( TIME_2000 ); +array[array.length] = new Date( TIME_1900 + TIME_1900 +TIME_1900 ); +array[array.length] = new Date( TIME_1900 * Math.PI ); +array[array.length] = new Date( TIME_1900 * 10 ); +array[array.length] = new Date( TIME_1900 ); +array[array.length] = new Date( TIME_2000 + TIME_2000 ); +array[array.length] = new Date( 1899, 0, 1 ); +array[array.length] = new Date( 2000, 1, 29 ); +array[array.length] = new Date( 2000, 0, 1 ); +array[array.length] = new Date( 1999, 11, 31 ); + +var testarr1 = new Array(); +clone( array, testarr1 ); +testarr1.sort( comparefn1 ); + +var testarr2 = new Array(); +clone( array, testarr2 ); +testarr2.sort( comparefn2 ); + +testarr3 = new Array(); +clone( array, testarr3 ); +testarr3.sort( comparefn3 ); + +// when there's no sort function, sort sorts by the toString value of Date. + +var testarr4 = new Array(); +clone( array, testarr4 ); +testarr4.sort(); + +var realarr = new Array(); +clone( array, realarr ); +realarr.sort( realsort ); + +var stringarr = new Array(); +clone( array, stringarr ); +stringarr.sort( stringsort ); + +for ( var i = 0; i < array.length; i++) { + new TestCase( + SECTION, + "testarr1["+i+"]", + realarr[i], + testarr1[i] ); +} + +for ( var i=0; i < array.length; i++) { + new TestCase( + SECTION, + "testarr2["+i+"]", + realarr[i], + testarr2[i] ); +} + +for ( var i=0; i < array.length; i++) { + new TestCase( + SECTION, + "testarr3["+i+"]", + realarr[i], + testarr3[i] ); +} + +for ( var i=0; i < array.length; i++) { + new TestCase( + SECTION, + "testarr4["+i+"]", + stringarr[i].toString(), + testarr4[i].toString() ); +} + +test(); + +function comparefn1( x, y ) { + return x - y; +} +function comparefn2( x, y ) { + return x.valueOf() - y.valueOf(); +} +function realsort( x, y ) { + return ( x.valueOf() == y.valueOf() ? 0 : ( x.valueOf() > y.valueOf() ? 1 : -1 ) ); +} +function comparefn3( x, y ) { + return ( x == y ? 0 : ( x > y ? 1: -1 ) ); +} +function clone( source, target ) { + for (i = 0; i < source.length; i++ ) { + target[i] = source[i]; + } +} +function stringsort( x, y ) { + for ( var i = 0; i < x.toString().length; i++ ) { + var d = (x.toString()).charCodeAt(i) - (y.toString()).charCodeAt(i); + if ( d > 0 ) { + return 1; + } else { + if ( d < 0 ) { + return -1; + } else { + continue; + } + } + + var d = x.length - y.length; + + if ( d > 0 ) { + return 1; + } else { + if ( d < 0 ) { + return -1; + } + } + } + return 0; +} diff --git a/tests/auto/qml/parserstress/tests/ecma/Array/15.4.4.js b/tests/auto/qml/parserstress/tests/ecma/Array/15.4.4.js new file mode 100644 index 0000000000..2ab2072098 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Array/15.4.4.js @@ -0,0 +1,74 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.4.4.js'; + +/** + File Name: 15.4.4.js + ECMA Section: 15.4.4 Properties of the Array Prototype Object + Description: The value of the internal [[Prototype]] property of + the Array prototype object is the Object prototype + object. + + Note that the Array prototype object is itself an + array; it has a length property (whose initial value + is (0) and the special [[Put]] method. + + Author: christine@netscape.com + Date: 7 october 1997 +*/ + +var SECTION = "15.4.4"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Properties of the Array Prototype Object"; + +writeHeaderToLog( SECTION + " "+ TITLE); + + +new TestCase( SECTION, "Array.prototype.length", 0, Array.prototype.length ); + +// verify that prototype object is an Array object. +new TestCase( SECTION, "typeof Array.prototype", "object", typeof Array.prototype ); + +new TestCase( SECTION, + "Array.prototype.toString = Object.prototype.toString; Array.prototype.toString()", + "[object Array]", + eval("Array.prototype.toString = Object.prototype.toString; Array.prototype.toString()") ); + +test(); diff --git a/tests/auto/qml/parserstress/tests/ecma/Array/15.4.5.1-1.js b/tests/auto/qml/parserstress/tests/ecma/Array/15.4.5.1-1.js new file mode 100644 index 0000000000..090300d59b --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Array/15.4.5.1-1.js @@ -0,0 +1,170 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.4.5.1-1.js'; + +/** + File Name: 15.4.5.1-1.js + ECMA Section: [[ Put]] (P, V) + Description: + Array objects use a variation of the [[Put]] method used for other native + ECMAScript objects (section 8.6.2.2). + + Assume A is an Array object and P is a string. + + When the [[Put]] method of A is called with property P and value V, the + following steps are taken: + + 1. Call the [[CanPut]] method of A with name P. + 2. If Result(1) is false, return. + 3. If A doesn't have a property with name P, go to step 7. + 4. If P is "length", go to step 12. + 5. Set the value of property P of A to V. + 6. Go to step 8. + 7. Create a property with name P, set its value to V and give it empty + attributes. + 8. If P is not an array index, return. + 9. If A itself has a property (not an inherited property) named "length", + andToUint32(P) is less than the value of the length property of A, then + return. + 10. Change (or set) the value of the length property of A to ToUint32(P)+1. + 11. Return. + 12. Compute ToUint32(V). + 13. For every integer k that is less than the value of the length property + of A but not less than Result(12), if A itself has a property (not an + inherited property) named ToString(k), then delete that property. + 14. Set the value of property P of A to Result(12). + 15. Return. + Author: christine@netscape.com + Date: 12 november 1997 +*/ + +var SECTION = "15.4.5.1-1"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Array [[Put]] (P, V)"; + +writeHeaderToLog( SECTION + " "+ TITLE); + + +// P is "length" + +new TestCase( SECTION, + "var A = new Array(); A.length = 1000; A.length", + 1000, + eval("var A = new Array(); A.length = 1000; A.length") ); + +// A has Property P, and P is not length or an array index +new TestCase( SECTION, + "var A = new Array(1000); A.name = 'name of this array'; A.name", + 'name of this array', + eval("var A = new Array(1000); A.name = 'name of this array'; A.name") ); + +new TestCase( SECTION, + "var A = new Array(1000); A.name = 'name of this array'; A.length", + 1000, + eval("var A = new Array(1000); A.name = 'name of this array'; A.length") ); + + +// A has Property P, P is not length, P is an array index, and ToUint32(p) is less than the +// value of length + +new TestCase( SECTION, + "var A = new Array(1000); A[123] = 'hola'; A[123]", + 'hola', + eval("var A = new Array(1000); A[123] = 'hola'; A[123]") ); + +new TestCase( SECTION, + "var A = new Array(1000); A[123] = 'hola'; A.length", + 1000, + eval("var A = new Array(1000); A[123] = 'hola'; A.length") ); + + +for ( var i = 0X0020, TEST_STRING = "var A = new Array( " ; i < 0x00ff; i++ ) { + TEST_STRING += "\'\\"+ String.fromCharCode( i ) +"\'"; + if ( i < 0x00FF - 1 ) { + TEST_STRING += ","; + } else { + TEST_STRING += ");" + } +} + +var LENGTH = 0x00ff - 0x0020; + +new TestCase( SECTION, + TEST_STRING +" A[150] = 'hello'; A[150]", + 'hello', + eval( TEST_STRING + " A[150] = 'hello'; A[150]" ) ); + +new TestCase( SECTION, + TEST_STRING +" A[150] = 'hello'; A[150]", + LENGTH, + eval( TEST_STRING + " A[150] = 'hello'; A.length" ) ); + +// A has Property P, P is not length, P is an array index, and ToUint32(p) is not less than the +// value of length + +new TestCase( SECTION, + "var A = new Array(); A[123] = true; A.length", + 124, + eval("var A = new Array(); A[123] = true; A.length") ); + +new TestCase( SECTION, + "var A = new Array(0,1,2,3,4,5,6,7,8,9,10); A[15] ='15'; A.length", + 16, + eval("var A = new Array(0,1,2,3,4,5,6,7,8,9,10); A[15] ='15'; A.length") ); + +for ( var i = 0; i < A.length; i++ ) { + new TestCase( SECTION, + "var A = new Array(0,1,2,3,4,5,6,7,8,9,10); A[15] ='15'; A[" +i +"]", + (i <= 10) ? i : ( i == 15 ? '15' : void 0 ), + A[i] ); +} +// P is not an array index, and P is not "length" + +new TestCase( SECTION, + "var A = new Array(); A.join.length = 4; A.join.length", + 1, + eval("var A = new Array(); A.join.length = 4; A.join.length") ); + +new TestCase( SECTION, + "var A = new Array(); A.join.length = 4; A.length", + 0, + eval("var A = new Array(); A.join.length = 4; A.length") ); + +test(); diff --git a/tests/auto/qml/parserstress/tests/ecma/Array/15.4.5.1-2.js b/tests/auto/qml/parserstress/tests/ecma/Array/15.4.5.1-2.js new file mode 100644 index 0000000000..2966a00456 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Array/15.4.5.1-2.js @@ -0,0 +1,152 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.4.5.1-2.js'; + +/** + File Name: 15.4.5.1-2.js + ECMA Section: [[ Put]] (P, V) + Description: + Array objects use a variation of the [[Put]] method used for other native + ECMAScript objects (section 8.6.2.2). + + Assume A is an Array object and P is a string. + + When the [[Put]] method of A is called with property P and value V, the + following steps are taken: + + 1. Call the [[CanPut]] method of A with name P. + 2. If Result(1) is false, return. + 3. If A doesn't have a property with name P, go to step 7. + 4. If P is "length", go to step 12. + 5. Set the value of property P of A to V. + 6. Go to step 8. + 7. Create a property with name P, set its value to V and give it empty + attributes. + 8. If P is not an array index, return. + 9. If A itself has a property (not an inherited property) named "length", + andToUint32(P) is less than the value of the length property of A, then + return. + 10. Change (or set) the value of the length property of A to ToUint32(P)+1. + 11. Return. + 12. Compute ToUint32(V). + 13. For every integer k that is less than the value of the length property + of A but not less than Result(12), if A itself has a property (not an + inherited property) named ToString(k), then delete that property. + 14. Set the value of property P of A to Result(12). + 15. Return. + + + These are gTestcases from Waldemar, detailed in + http://scopus.mcom.com/bugsplat/show_bug.cgi?id=123552 + + Author: christine@netscape.com + Date: 15 June 1998 +*/ + +var SECTION = "15.4.5.1-2"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Array [[Put]] (P,V)"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +var a = new Array(); + +AddCase( "3.00", "three" ); +AddCase( "00010", "eight" ); +AddCase( "37xyz", "thirty-five" ); +AddCase("5000000000", 5) + AddCase( "-2", -3 ); + +new TestCase( SECTION, + "a[10]", + void 0, + a[10] ); + +new TestCase( SECTION, + "a[3]", + void 0, + a[3] ); + +a[4] = "four"; + +new TestCase( SECTION, + "a[4] = \"four\"; a[4]", + "four", + a[4] ); + +new TestCase( SECTION, + "a[\"4\"]", + "four", + a["4"] ); + +new TestCase( SECTION, + "a[\"4.00\"]", + void 0, + a["4.00"] ); + +new TestCase( SECTION, + "a.length", + 5, + a.length ); + + +a["5000000000"] = 5; + +new TestCase( SECTION, + "a[\"5000000000\"] = 5; a.length", + 5, + a.length ); + +new TestCase( SECTION, + "a[\"-2\"] = -3; a.length", + 5, + a.length ); + +test(); + +function AddCase ( arg, value ) { + + a[arg] = value; + + new TestCase( SECTION, + "a[\"" + arg + "\"] = "+ value +"; a.length", + 0, + a.length ); +} diff --git a/tests/auto/qml/parserstress/tests/ecma/Array/15.4.5.2-1.js b/tests/auto/qml/parserstress/tests/ecma/Array/15.4.5.2-1.js new file mode 100644 index 0000000000..ff15f9d4e8 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Array/15.4.5.2-1.js @@ -0,0 +1,86 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.4.5.2-1.js'; + +/** + File Name: 15.4.5.2-1.js + ECMA Section: Array.length + Description: + 15.4.5.2 length + The length property of this Array object is always numerically greater + than the name of every property whose name is an array index. + + The length property has the attributes { DontEnum, DontDelete }. + Author: christine@netscape.com + Date: 12 november 1997 +*/ + +var SECTION = "15.4.5.2-1"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Array.length"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +new TestCase( SECTION, + "var A = new Array(); A.length", + 0, + eval("var A = new Array(); A.length") ); +new TestCase( SECTION, + "var A = new Array(); A[Math.pow(2,32)-2] = 'hi'; A.length", + Math.pow(2,32)-1, + eval("var A = new Array(); A[Math.pow(2,32)-2] = 'hi'; A.length") ); +new TestCase( SECTION, + "var A = new Array(); A.length = 123; A.length", + 123, + eval("var A = new Array(); A.length = 123; A.length") ); +new TestCase( SECTION, + "var A = new Array(); A.length = 123; var PROPS = ''; for ( var p in A ) { PROPS += ( p == 'length' ? p : ''); } PROPS", + "", + eval("var A = new Array(); A.length = 123; var PROPS = ''; for ( var p in A ) { PROPS += ( p == 'length' ? p : ''); } PROPS") ); +new TestCase( SECTION, + "var A = new Array(); A.length = 123; delete A.length", + false , + eval("var A = new Array(); A.length = 123; delete A.length") ); +new TestCase( SECTION, + "var A = new Array(); A.length = 123; delete A.length; A.length", + 123, + eval("var A = new Array(); A.length = 123; delete A.length; A.length") ); +test(); + diff --git a/tests/auto/qml/parserstress/tests/ecma/Array/15.4.5.2-2.js b/tests/auto/qml/parserstress/tests/ecma/Array/15.4.5.2-2.js new file mode 100644 index 0000000000..56a400ab49 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Array/15.4.5.2-2.js @@ -0,0 +1,127 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.4.5.2-2.js'; + +/** + File Name: 15.4.5.2-2.js + ECMA Section: Array.length + Description: + 15.4.5.2 length + The length property of this Array object is always numerically greater + than the name of every property whose name is an array index. + + The length property has the attributes { DontEnum, DontDelete }. + + This test verifies that the Array.length property is not Read Only. + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + +var SECTION = "15.4.5.2-2"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Array.length"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +addCase( new Array(), 0, Math.pow(2,14), Math.pow(2,14) ); + +addCase( new Array(), 0, 1, 1 ); + +addCase( new Array(Math.pow(2,12)), Math.pow(2,12), 0, 0 ); +addCase( new Array(Math.pow(2,13)), Math.pow(2,13), Math.pow(2,12), Math.pow(2,12) ); +addCase( new Array(Math.pow(2,12)), Math.pow(2,12), Math.pow(2,12), Math.pow(2,12) ); +addCase( new Array(Math.pow(2,14)), Math.pow(2,14), Math.pow(2,12), Math.pow(2,12) ) + +// some tests where array is not empty +// array is populated with strings + for ( var arg = "", i = 0; i < Math.pow(2,12); i++ ) { + arg += String(i) + ( i != Math.pow(2,12)-1 ? "," : "" ); + + } +// print(i +":"+arg); + +var a = eval( "new Array("+arg+")" ); + +addCase( a, i, i, i ); +addCase( a, i, Math.pow(2,12)+i+1, Math.pow(2,12)+i+1, true ); +addCase( a, Math.pow(2,12)+5, 0, 0, true ); + +test(); + +function addCase( object, old_len, set_len, new_len, checkitems ) { + object.length = set_len; + + new TestCase( SECTION, + "array = new Array("+ old_len+"); array.length = " + set_len + + "; array.length", + new_len, + object.length ); + + if ( checkitems ) { + // verify that items between old and newlen are all undefined + if ( new_len < old_len ) { + var passed = true; + for ( var i = new_len; i < old_len; i++ ) { + if ( object[i] != void 0 ) { + passed = false; + } + } + new TestCase( SECTION, + "verify that array items have been deleted", + true, + passed ); + } + if ( new_len > old_len ) { + var passed = true; + for ( var i = old_len; i < new_len; i++ ) { + if ( object[i] != void 0 ) { + passed = false; + } + } + new TestCase( SECTION, + "verify that new items are undefined", + true, + passed ); + } + } + +} + diff --git a/tests/auto/qml/parserstress/tests/ecma/Array/browser.js b/tests/auto/qml/parserstress/tests/ecma/Array/browser.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/auto/qml/parserstress/tests/ecma/Array/shell.js b/tests/auto/qml/parserstress/tests/ecma/Array/shell.js new file mode 100644 index 0000000000..9480d9e77d --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Array/shell.js @@ -0,0 +1 @@ +gTestsubsuite = 'Array'; diff --git a/tests/auto/qml/parserstress/tests/ecma/Boolean/15.6.1.js b/tests/auto/qml/parserstress/tests/ecma/Boolean/15.6.1.js new file mode 100644 index 0000000000..b698cbe407 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Boolean/15.6.1.js @@ -0,0 +1,96 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.6.1.js'; + +/** + File Name: 15.6.1.js + ECMA Section: 15.6.1 The Boolean Function + 15.6.1.1 Boolean( value ) + 15.6.1.2 Boolean () + Description: Boolean( value ) should return a Boolean value + not a Boolean object) computed by + Boolean.toBooleanValue( value) + + 15.6.1.2 Boolean() returns false + + Author: christine@netscape.com + Date: 27 jun 1997 + + + Data File Fields: + VALUE Argument passed to the Boolean function + TYPE typeof VALUE (not used, but helpful in understanding + the data file) + E_RETURN Expected return value of Boolean( VALUE ) +*/ +var SECTION = "15.6.1"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "The Boolean constructor called as a function: Boolean( value ) and Boolean()"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +var array = new Array(); +var item = 0; + +new TestCase( SECTION, "Boolean(1)", true, Boolean(1) ); +new TestCase( SECTION, "Boolean(0)", false, Boolean(0) ); +new TestCase( SECTION, "Boolean(-1)", true, Boolean(-1) ); +new TestCase( SECTION, "Boolean('1')", true, Boolean("1") ); +new TestCase( SECTION, "Boolean('0')", true, Boolean("0") ); +new TestCase( SECTION, "Boolean('-1')", true, Boolean("-1") ); +new TestCase( SECTION, "Boolean(true)", true, Boolean(true) ); +new TestCase( SECTION, "Boolean(false)", false, Boolean(false) ); + +new TestCase( SECTION, "Boolean('true')", true, Boolean("true") ); +new TestCase( SECTION, "Boolean('false')", true, Boolean("false") ); +new TestCase( SECTION, "Boolean(null)", false, Boolean(null) ); + +new TestCase( SECTION, "Boolean(-Infinity)", true, Boolean(Number.NEGATIVE_INFINITY) ); +new TestCase( SECTION, "Boolean(NaN)", false, Boolean(Number.NaN) ); +new TestCase( SECTION, "Boolean(void(0))", false, Boolean( void(0) ) ); +new TestCase( SECTION, "Boolean(x=0)", false, Boolean( x=0 ) ); +new TestCase( SECTION, "Boolean(x=1)", true, Boolean( x=1 ) ); +new TestCase( SECTION, "Boolean(x=false)", false, Boolean( x=false ) ); +new TestCase( SECTION, "Boolean(x=true)", true, Boolean( x=true ) ); +new TestCase( SECTION, "Boolean(x=null)", false, Boolean( x=null ) ); +new TestCase( SECTION, "Boolean()", false, Boolean() ); +// array[item++] = new TestCase( SECTION, "Boolean(var someVar)", false, Boolean( someVar ) ); + +test(); diff --git a/tests/auto/qml/parserstress/tests/ecma/Boolean/15.6.2.js b/tests/auto/qml/parserstress/tests/ecma/Boolean/15.6.2.js new file mode 100644 index 0000000000..f9fccb3e57 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Boolean/15.6.2.js @@ -0,0 +1,161 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.6.2.js'; + +/** + File Name: 15.6.2.js + ECMA Section: 15.6.2 The Boolean Constructor + 15.6.2.1 new Boolean( value ) + 15.6.2.2 new Boolean() + + This test verifies that the Boolean constructor + initializes a new object (typeof should return + "object"). The prototype of the new object should + be Boolean.prototype. The value of the object + should be ToBoolean( value ) (a boolean value). + + Description: + Author: christine@netscape.com + Date: june 27, 1997 + +*/ +var SECTION = "15.6.2"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "15.6.2 The Boolean Constructor; 15.6.2.1 new Boolean( value ); 15.6.2.2 new Boolean()"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +var array = new Array(); +var item = 0; + +new TestCase( SECTION, "typeof (new Boolean(1))", "object", typeof (new Boolean(1)) ); +new TestCase( SECTION, "(new Boolean(1)).constructor", Boolean.prototype.constructor, (new Boolean(1)).constructor ); +new TestCase( SECTION, + "TESTBOOL=new Boolean(1);TESTBOOL.toString=Object.prototype.toString;TESTBOOL.toString()", + "[object Boolean]", + eval("TESTBOOL=new Boolean(1);TESTBOOL.toString=Object.prototype.toString;TESTBOOL.toString()") ); +new TestCase( SECTION, "(new Boolean(1)).valueOf()", true, (new Boolean(1)).valueOf() ); +new TestCase( SECTION, "typeof new Boolean(1)", "object", typeof new Boolean(1) ); +new TestCase( SECTION, "(new Boolean(0)).constructor", Boolean.prototype.constructor, (new Boolean(0)).constructor ); +new TestCase( SECTION, + "TESTBOOL=new Boolean(0);TESTBOOL.toString=Object.prototype.toString;TESTBOOL.toString()", + "[object Boolean]", + eval("TESTBOOL=new Boolean(0);TESTBOOL.toString=Object.prototype.toString;TESTBOOL.toString()") ); +new TestCase( SECTION, "(new Boolean(0)).valueOf()", false, (new Boolean(0)).valueOf() ); +new TestCase( SECTION, "typeof new Boolean(0)", "object", typeof new Boolean(0) ); +new TestCase( SECTION, "(new Boolean(-1)).constructor", Boolean.prototype.constructor, (new Boolean(-1)).constructor ); +new TestCase( SECTION, + "TESTBOOL=new Boolean(-1);TESTBOOL.toString=Object.prototype.toString;TESTBOOL.toString()", + "[object Boolean]", + eval("TESTBOOL=new Boolean(-1);TESTBOOL.toString=Object.prototype.toString;TESTBOOL.toString()") ); +new TestCase( SECTION, "(new Boolean(-1)).valueOf()", true, (new Boolean(-1)).valueOf() ); +new TestCase( SECTION, "typeof new Boolean(-1)", "object", typeof new Boolean(-1) ); +new TestCase( SECTION, "(new Boolean('1')).constructor", Boolean.prototype.constructor, (new Boolean('1')).constructor ); +new TestCase( SECTION, + "TESTBOOL=new Boolean('1');TESTBOOL.toString=Object.prototype.toString;TESTBOOL.toString()", + "[object Boolean]", + eval("TESTBOOL=new Boolean('1');TESTBOOL.toString=Object.prototype.toString;TESTBOOL.toString()") ); +new TestCase( SECTION, "(new Boolean('1')).valueOf()", true, (new Boolean('1')).valueOf() ); +new TestCase( SECTION, "typeof new Boolean('1')", "object", typeof new Boolean('1') ); +new TestCase( SECTION, "(new Boolean('0')).constructor", Boolean.prototype.constructor, (new Boolean('0')).constructor ); +new TestCase( SECTION, + "TESTBOOL=new Boolean('0');TESTBOOL.toString=Object.prototype.toString;TESTBOOL.toString()", + "[object Boolean]", + eval("TESTBOOL=new Boolean('0');TESTBOOL.toString=Object.prototype.toString;TESTBOOL.toString()") ); +new TestCase( SECTION, "(new Boolean('0')).valueOf()", true, (new Boolean('0')).valueOf() ); +new TestCase( SECTION, "typeof new Boolean('0')", "object", typeof new Boolean('0') ); +new TestCase( SECTION, "(new Boolean('-1')).constructor", Boolean.prototype.constructor, (new Boolean('-1')).constructor ); +new TestCase( SECTION, + "TESTBOOL=new Boolean('-1');TESTBOOL.toString=Object.prototype.toString;TESTBOOL.toString()", + "[object Boolean]", + eval("TESTBOOL=new Boolean('-1');TESTBOOL.toString=Object.prototype.toString;TESTBOOL.toString()") ); +new TestCase( SECTION, "(new Boolean('-1')).valueOf()", true, (new Boolean('-1')).valueOf() ); +new TestCase( SECTION, "typeof new Boolean('-1')", "object", typeof new Boolean('-1') ); +new TestCase( SECTION, "(new Boolean(new Boolean(true))).constructor", Boolean.prototype.constructor, (new Boolean(new Boolean(true))).constructor ); +new TestCase( SECTION, + "TESTBOOL=new Boolean(new Boolean(true));TESTBOOL.toString=Object.prototype.toString;TESTBOOL.toString()", + "[object Boolean]", + eval("TESTBOOL=new Boolean(new Boolean(true));TESTBOOL.toString=Object.prototype.toString;TESTBOOL.toString()") ); +new TestCase( SECTION, "(new Boolean(new Boolean(true))).valueOf()", true, (new Boolean(new Boolean(true))).valueOf() ); +new TestCase( SECTION, "typeof new Boolean(new Boolean(true))", "object", typeof new Boolean(new Boolean(true)) ); +new TestCase( SECTION, "(new Boolean(Number.NaN)).constructor", Boolean.prototype.constructor, (new Boolean(Number.NaN)).constructor ); +new TestCase( SECTION, + "TESTBOOL=new Boolean(Number.NaN);TESTBOOL.toString=Object.prototype.toString;TESTBOOL.toString()", + "[object Boolean]", + eval("TESTBOOL=new Boolean(Number.NaN);TESTBOOL.toString=Object.prototype.toString;TESTBOOL.toString()") ); +new TestCase( SECTION, "(new Boolean(Number.NaN)).valueOf()", false, (new Boolean(Number.NaN)).valueOf() ); +new TestCase( SECTION, "typeof new Boolean(Number.NaN)", "object", typeof new Boolean(Number.NaN) ); +new TestCase( SECTION, "(new Boolean(null)).constructor", Boolean.prototype.constructor, (new Boolean(null)).constructor ); +new TestCase( SECTION, + "TESTBOOL=new Boolean(null);TESTBOOL.toString=Object.prototype.toString;TESTBOOL.toString()", + "[object Boolean]", + eval("TESTBOOL=new Boolean(null);TESTBOOL.toString=Object.prototype.toString;TESTBOOL.toString()") ); +new TestCase( SECTION, "(new Boolean(null)).valueOf()", false, (new Boolean(null)).valueOf() ); +new TestCase( SECTION, "typeof new Boolean(null)", "object", typeof new Boolean(null) ); +new TestCase( SECTION, "(new Boolean(void 0)).constructor", Boolean.prototype.constructor, (new Boolean(void 0)).constructor ); +new TestCase( SECTION, + "TESTBOOL=new Boolean(void 0);TESTBOOL.toString=Object.prototype.toString;TESTBOOL.toString()", + "[object Boolean]", + eval("TESTBOOL=new Boolean(void 0);TESTBOOL.toString=Object.prototype.toString;TESTBOOL.toString()") ); +new TestCase( SECTION, "(new Boolean(void 0)).valueOf()", false, (new Boolean(void 0)).valueOf() ); +new TestCase( SECTION, "typeof new Boolean(void 0)", "object", typeof new Boolean(void 0) ); +new TestCase( SECTION, "(new Boolean(Number.POSITIVE_INFINITY)).constructor", Boolean.prototype.constructor, (new Boolean(Number.POSITIVE_INFINITY)).constructor ); +new TestCase( SECTION, + "TESTBOOL=new Boolean(Number.POSITIVE_INFINITY);TESTBOOL.toString=Object.prototype.toString;TESTBOOL.toString()", + "[object Boolean]", + eval("TESTBOOL=new Boolean(Number.POSITIVE_INFINITY);TESTBOOL.toString=Object.prototype.toString;TESTBOOL.toString()") ); +new TestCase( SECTION, "(new Boolean(Number.POSITIVE_INFINITY)).valueOf()", true, (new Boolean(Number.POSITIVE_INFINITY)).valueOf() ); +new TestCase( SECTION, "typeof new Boolean(Number.POSITIVE_INFINITY)", "object", typeof new Boolean(Number.POSITIVE_INFINITY) ); +new TestCase( SECTION, "(new Boolean(Number.NEGATIVE_INFINITY)).constructor", Boolean.prototype.constructor, (new Boolean(Number.NEGATIVE_INFINITY)).constructor ); +new TestCase( SECTION, + "TESTBOOL=new Boolean(Number.NEGATIVE_INFINITY);TESTBOOL.toString=Object.prototype.toString;TESTBOOL.toString()", + "[object Boolean]", + eval("TESTBOOL=new Boolean(Number.NEGATIVE_INFINITY);TESTBOOL.toString=Object.prototype.toString;TESTBOOL.toString()") ); +new TestCase( SECTION, "(new Boolean(Number.NEGATIVE_INFINITY)).valueOf()", true, (new Boolean(Number.NEGATIVE_INFINITY)).valueOf() ); +new TestCase( SECTION, "typeof new Boolean(Number.NEGATIVE_INFINITY)", "object", typeof new Boolean(Number.NEGATIVE_INFINITY) ); +new TestCase( SECTION, "(new Boolean(Number.NEGATIVE_INFINITY)).constructor", Boolean.prototype.constructor, (new Boolean(Number.NEGATIVE_INFINITY)).constructor ); +new TestCase( "15.6.2.2", + "TESTBOOL=new Boolean();TESTBOOL.toString=Object.prototype.toString;TESTBOOL.toString()", + "[object Boolean]", + eval("TESTBOOL=new Boolean();TESTBOOL.toString=Object.prototype.toString;TESTBOOL.toString()") ); +new TestCase( "15.6.2.2", "(new Boolean()).valueOf()", false, (new Boolean()).valueOf() ); +new TestCase( "15.6.2.2", "typeof new Boolean()", "object", typeof new Boolean() ); + +test(); diff --git a/tests/auto/qml/parserstress/tests/ecma/Boolean/15.6.3.1-1.js b/tests/auto/qml/parserstress/tests/ecma/Boolean/15.6.3.1-1.js new file mode 100644 index 0000000000..0be8097487 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Boolean/15.6.3.1-1.js @@ -0,0 +1,72 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.6.3.1-1.js'; + +/** + File Name: 15.6.3.1-1.js + ECMA Section: 15.6.3 Boolean.prototype + + Description: The initial value of Boolean.prototype is the built-in + Boolean prototype object (15.6.4). + + The property shall have the attributes [DontEnum, + DontDelete, ReadOnly ]. + + This tests the DontEnum property of Boolean.prototype + + Author: christine@netscape.com + Date: june 27, 1997 + +*/ +var SECTION = "15.6.3.1-1"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Boolean.prototype"; + +writeHeaderToLog( SECTION + " "+ TITLE); + + +var array = new Array(); +var item = 0; + +new TestCase( SECTION, + "var str='';for ( p in Boolean ) { str += p } str;", + "", + eval("var str='';for ( p in Boolean ) { str += p } str;") ); +test(); diff --git a/tests/auto/qml/parserstress/tests/ecma/Boolean/15.6.3.1-2.js b/tests/auto/qml/parserstress/tests/ecma/Boolean/15.6.3.1-2.js new file mode 100644 index 0000000000..5d435982d4 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Boolean/15.6.3.1-2.js @@ -0,0 +1,71 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.6.3.1-2.js'; + +/** + File Name: 15.6.3.1-2.js + ECMA Section: 15.6.3.1 Boolean.prototype + + Description: The initial valu eof Boolean.prototype is the built-in + Boolean prototype object (15.6.4). + + The property shall have the attributes [DontEnum, + DontDelete, ReadOnly ]. + + This tests the DontDelete property of Boolean.prototype + + Author: christine@netscape.com + Date: june 27, 1997 + +*/ +var SECTION = "15.6.3.1-2"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Boolean.prototype" + writeHeaderToLog( SECTION + TITLE ); + +var array = new Array(); +var item = 0; + +new TestCase( SECTION, + "delete( Boolean.prototype)", + false, + delete( Boolean.prototype) ); + +test(); diff --git a/tests/auto/qml/parserstress/tests/ecma/Boolean/15.6.3.1-3.js b/tests/auto/qml/parserstress/tests/ecma/Boolean/15.6.3.1-3.js new file mode 100644 index 0000000000..0f1b125267 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Boolean/15.6.3.1-3.js @@ -0,0 +1,71 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.6.3.1-3.js'; + +/** + File Name: 15.6.3.1-3.js + ECMA Section: 15.6.3.1 Boolean.prototype + + Description: The initial valu eof Boolean.prototype is the built-in + Boolean prototype object (15.6.4). + + The property shall have the attributes [DontEnum, + DontDelete, ReadOnly ]. + + This tests the DontDelete property of Boolean.prototype + + Author: christine@netscape.com + Date: june 27, 1997 + +*/ +var SECTION = "15.6.3.1-3"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Boolean.prototype" + writeHeaderToLog( SECTION + TITLE ); + +var array = new Array(); +var item = 0; + +new TestCase( SECTION, + "delete( Boolean.prototype); Boolean.prototype", + Boolean.prototype, + eval("delete( Boolean.prototype); Boolean.prototype") ); + +test(); diff --git a/tests/auto/qml/parserstress/tests/ecma/Boolean/15.6.3.1-4.js b/tests/auto/qml/parserstress/tests/ecma/Boolean/15.6.3.1-4.js new file mode 100644 index 0000000000..822750308a --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Boolean/15.6.3.1-4.js @@ -0,0 +1,75 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.6.3.1-4.js'; + +/** + File Name: 15.6.3.1-4.js + ECMA Section: 15.6.3.1 Properties of the Boolean Prototype Object + + Description: The initial value of Boolean.prototype is the built-in + Boolean prototype object (15.6.4). + + The property shall have the attributes [DontEnum, + DontDelete, ReadOnly ]. + + This tests the ReadOnly property of Boolean.prototype + + Author: christine@netscape.com + Date: 30 september 1997 + +*/ +var SECTION = "15.6.3.1-4"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Boolean.prototype" + writeHeaderToLog( SECTION + TITLE ); + +var BOOL_PROTO = Boolean.prototype; + +new TestCase( SECTION, + "var BOOL_PROTO = Boolean.prototype; Boolean.prototype=null; Boolean.prototype == BOOL_PROTO", + true, + eval("var BOOL_PROTO = Boolean.prototype; Boolean.prototype=null; Boolean.prototype == BOOL_PROTO") ); + +new TestCase( SECTION, + "var BOOL_PROTO = Boolean.prototype; Boolean.prototype=null; Boolean.prototype == null", + false, + eval("var BOOL_PROTO = Boolean.prototype; Boolean.prototype=null; Boolean.prototype == null") ); + +test(); diff --git a/tests/auto/qml/parserstress/tests/ecma/Boolean/15.6.3.1.js b/tests/auto/qml/parserstress/tests/ecma/Boolean/15.6.3.1.js new file mode 100644 index 0000000000..ca808c63a5 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Boolean/15.6.3.1.js @@ -0,0 +1,69 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.6.3.1.js'; + +/** + File Name: 15.6.3.1.js + ECMA Section: 15.6.3.1 Boolean.prototype + + Description: The initial valu eof Boolean.prototype is the built-in + Boolean prototype object (15.6.4). + + The property shall have the attributes [DontEnum, + DontDelete, ReadOnly ]. + + It has the internal [[Call]] and [[Construct]] + properties (not tested), and the length property. + + Author: christine@netscape.com + Date: june 27, 1997 + +*/ + +var SECTION = "15.6.3.1"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Boolean.prototype"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +new TestCase( SECTION, "Boolean.prototype.valueOf()", false, Boolean.prototype.valueOf() ); +new TestCase( SECTION, "Boolean.length", 1, Boolean.length ); + +test(); diff --git a/tests/auto/qml/parserstress/tests/ecma/Boolean/15.6.4-1.js b/tests/auto/qml/parserstress/tests/ecma/Boolean/15.6.4-1.js new file mode 100644 index 0000000000..584562b2a8 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Boolean/15.6.4-1.js @@ -0,0 +1,72 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.6.4-1.js'; + +/** + File Name: 15.6.4-1.js + ECMA Section: 15.6.4 Properties of the Boolean Prototype Object + + Description: + The Boolean prototype object is itself a Boolean object (its [[Class]] is + "Boolean") whose value is false. + + The value of the internal [[Prototype]] property of the Boolean prototype object + is the Object prototype object (15.2.3.1). + + Author: christine@netscape.com + Date: 30 september 1997 + +*/ + + +var VERSION = "ECMA_1" + startTest(); +var SECTION = "15.6.4-1"; + +writeHeaderToLog( SECTION + " Properties of the Boolean Prototype Object"); + +new TestCase( SECTION, "typeof Boolean.prototype == typeof( new Boolean )", true, typeof Boolean.prototype == typeof( new Boolean ) ); +new TestCase( SECTION, "typeof( Boolean.prototype )", "object", typeof(Boolean.prototype) ); +new TestCase( SECTION, + "Boolean.prototype.toString = Object.prototype.toString; Boolean.prototype.toString()", + "[object Boolean]", + eval("Boolean.prototype.toString = Object.prototype.toString; Boolean.prototype.toString()") ); +new TestCase( SECTION, "Boolean.prototype.valueOf()", false, Boolean.prototype.valueOf() ); + +test(); diff --git a/tests/auto/qml/parserstress/tests/ecma/Boolean/15.6.4.1.js b/tests/auto/qml/parserstress/tests/ecma/Boolean/15.6.4.1.js new file mode 100644 index 0000000000..3b75fb49ec --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Boolean/15.6.4.1.js @@ -0,0 +1,62 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.6.4.1.js'; + +/** + File Name: 15.6.4.1.js + ECMA Section: 15.6.4.1 Boolean.prototype.constructor + + Description: The initial value of Boolean.prototype.constructor + is the built-in Boolean constructor. + + Author: christine@netscape.com + Date: 30 september 1997 + +*/ +var SECTION = "15.6.4.1"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Boolean.prototype.constructor" + writeHeaderToLog( SECTION + TITLE ); + +new TestCase( SECTION, + "( Boolean.prototype.constructor == Boolean )", + true , + (Boolean.prototype.constructor == Boolean) ); +test(); diff --git a/tests/auto/qml/parserstress/tests/ecma/Boolean/15.6.4.2-1.js b/tests/auto/qml/parserstress/tests/ecma/Boolean/15.6.4.2-1.js new file mode 100644 index 0000000000..54bd2e19d3 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Boolean/15.6.4.2-1.js @@ -0,0 +1,97 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.6.4.2-1.js'; + +/** + File Name: 15.6.4.2.js + ECMA Section: 15.6.4.2-1 Boolean.prototype.toString() + Description: If this boolean value is true, then the string "true" + is returned; otherwise this boolean value must be false, + and the string "false" is returned. + + The toString function is not generic; it generates + a runtime error if its this value is not a Boolean + object. Therefore it cannot be transferred to other + kinds of objects for use as a method. + + Author: christine@netscape.com + Date: june 27, 1997 +*/ + +var SECTION = "15.6.4.2-1"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Boolean.prototype.toString()" + writeHeaderToLog( SECTION + TITLE ); + + +new TestCase( SECTION, "new Boolean(1)", "true", (new Boolean(1)).toString() ); +new TestCase( SECTION, "new Boolean(0)", "false", (new Boolean(0)).toString() ); +new TestCase( SECTION, "new Boolean(-1)", "true", (new Boolean(-1)).toString() ); +new TestCase( SECTION, "new Boolean('1')", "true", (new Boolean("1")).toString() ); +new TestCase( SECTION, "new Boolean('0')", "true", (new Boolean("0")).toString() ); +new TestCase( SECTION, "new Boolean(true)", "true", (new Boolean(true)).toString() ); +new TestCase( SECTION, "new Boolean(false)", "false", (new Boolean(false)).toString() ); +new TestCase( SECTION, "new Boolean('true')", "true", (new Boolean('true')).toString() ); +new TestCase( SECTION, "new Boolean('false')", "true", (new Boolean('false')).toString() ); + +new TestCase( SECTION, "new Boolean('')", "false", (new Boolean('')).toString() ); +new TestCase( SECTION, "new Boolean(null)", "false", (new Boolean(null)).toString() ); +new TestCase( SECTION, "new Boolean(void(0))", "false", (new Boolean(void(0))).toString() ); +new TestCase( SECTION, "new Boolean(-Infinity)", "true", (new Boolean(Number.NEGATIVE_INFINITY)).toString() ); +new TestCase( SECTION, "new Boolean(NaN)", "false", (new Boolean(Number.NaN)).toString() ); +new TestCase( SECTION, "new Boolean()", "false", (new Boolean()).toString() ); +new TestCase( SECTION, "new Boolean(x=1)", "true", (new Boolean(x=1)).toString() ); +new TestCase( SECTION, "new Boolean(x=0)", "false", (new Boolean(x=0)).toString() ); +new TestCase( SECTION, "new Boolean(x=false)", "false", (new Boolean(x=false)).toString() ); +new TestCase( SECTION, "new Boolean(x=true)", "true", (new Boolean(x=true)).toString() ); +new TestCase( SECTION, "new Boolean(x=null)", "false", (new Boolean(x=null)).toString() ); +new TestCase( SECTION, "new Boolean(x='')", "false", (new Boolean(x="")).toString() ); +new TestCase( SECTION, "new Boolean(x=' ')", "true", (new Boolean(x=" ")).toString() ); + +new TestCase( SECTION, "new Boolean(new MyObject(true))", "true", (new Boolean(new MyObject(true))).toString() ); +new TestCase( SECTION, "new Boolean(new MyObject(false))", "true", (new Boolean(new MyObject(false))).toString() ); + +test(); + +function MyObject( value ) { + this.value = value; + this.valueOf = new Function( "return this.value" ); + return this; +} diff --git a/tests/auto/qml/parserstress/tests/ecma/Boolean/15.6.4.2-2.js b/tests/auto/qml/parserstress/tests/ecma/Boolean/15.6.4.2-2.js new file mode 100644 index 0000000000..2039004472 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Boolean/15.6.4.2-2.js @@ -0,0 +1,73 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.6.4.2-2.js'; + +/** + File Name: 15.6.4.2-2.js + ECMA Section: 15.6.4.2 Boolean.prototype.toString() + Description: Returns this boolean value. + + The toString function is not generic; it generates + a runtime error if its this value is not a Boolean + object. Therefore it cannot be transferred to other + kinds of objects for use as a method. + + Author: christine@netscape.com + Date: june 27, 1997 +*/ + +var SECTION = "15.6.4.2-2"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Boolean.prototype.toString()" + writeHeaderToLog( SECTION + TITLE ); + +new TestCase( SECTION, + "tostr=Boolean.prototype.toString; x=new Boolean(); x.toString=tostr;x.toString()", + "false", + eval("tostr=Boolean.prototype.toString; x=new Boolean(); x.toString=tostr;x.toString()") ); +new TestCase( SECTION, + "tostr=Boolean.prototype.toString; x=new Boolean(true); x.toString=tostr; x.toString()", + "true", + eval("tostr=Boolean.prototype.toString; x=new Boolean(true); x.toString=tostr; x.toString()") ); +new TestCase( SECTION, + "tostr=Boolean.prototype.toString; x=new Boolean(false); x.toString=tostr;x.toString()", + "false", + eval("tostr=Boolean.prototype.toString; x=new Boolean(); x.toString=tostr;x.toString()") ); +test(); diff --git a/tests/auto/qml/parserstress/tests/ecma/Boolean/15.6.4.2-3.js b/tests/auto/qml/parserstress/tests/ecma/Boolean/15.6.4.2-3.js new file mode 100644 index 0000000000..4dcc65f21f --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Boolean/15.6.4.2-3.js @@ -0,0 +1,65 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.6.4.2-3.js'; + +/** + File Name: 15.6.4.2-3.js + ECMA Section: 15.6.4.2 Boolean.prototype.toString() + Description: Returns this boolean value. + + The toString function is not generic; it generates + a runtime error if its this value is not a Boolean + object. Therefore it cannot be transferred to other + kinds of objects for use as a method. + + Author: christine@netscape.com + Date: june 27, 1997 +*/ + + +var SECTION = "15.6.4.2-3"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Boolean.prototype.toString()" + writeHeaderToLog( SECTION + TITLE ); + +new TestCase( SECTION, "tostr=Boolean.prototype.toString; x=true; x.toString=tostr;x.toString()", "true", eval("tostr=Boolean.prototype.toString; x=true; x.toString=tostr;x.toString()") ); +new TestCase( SECTION, "tostr=Boolean.prototype.toString; x=false; x.toString=tostr;x.toString()", "false", eval("tostr=Boolean.prototype.toString; x=false; x.toString=tostr;x.toString()") ); + +test(); diff --git a/tests/auto/qml/parserstress/tests/ecma/Boolean/15.6.4.2-4-n.js b/tests/auto/qml/parserstress/tests/ecma/Boolean/15.6.4.2-4-n.js new file mode 100644 index 0000000000..0dd3e5f349 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Boolean/15.6.4.2-4-n.js @@ -0,0 +1,69 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.6.4.2-4-n.js'; + +/** + File Name: 15.6.4.2-4.js + ECMA Section: 15.6.4.2 Boolean.prototype.toString() + Description: Returns this boolean value. + + The toString function is not generic; it generates + a runtime error if its this value is not a Boolean + object. Therefore it cannot be transferred to other + kinds of objects for use as a method. + + Author: christine@netscape.com + Date: june 27, 1997 +*/ + +var SECTION = "15.6.4.2-4-n"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Boolean.prototype.toString()"; +writeHeaderToLog( SECTION +" "+ TITLE ); + +DESCRIPTION = "tostr=Boolean.prototype.toString; x=new String( 'hello' ); x.toString=tostr; x.toString()"; +EXPECTED = "error"; + +new TestCase( SECTION, + "tostr=Boolean.prototype.toString; x=new String( 'hello' ); x.toString=tostr; x.toString()", + "error", + eval("tostr=Boolean.prototype.toString; x=new String( 'hello' ); x.toString=tostr; x.toString()") ); + +test(); diff --git a/tests/auto/qml/parserstress/tests/ecma/Boolean/15.6.4.3-1.js b/tests/auto/qml/parserstress/tests/ecma/Boolean/15.6.4.3-1.js new file mode 100644 index 0000000000..8b913e011e --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Boolean/15.6.4.3-1.js @@ -0,0 +1,88 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.6.4.3-1.js'; + +/** + File Name: 15.6.4.3.js + ECMA Section: 15.6.4.3 Boolean.prototype.valueOf() + Description: Returns this boolean value. + + The valueOf function is not generic; it generates + a runtime error if its this value is not a Boolean + object. Therefore it cannot be transferred to other + kinds of objects for use as a method. + + Author: christine@netscape.com + Date: june 27, 1997 +*/ + +var SECTION = "15.6.4.3-1"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Boolean.prototype.valueOf()"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +new TestCase( SECTION, "new Boolean(1)", true, (new Boolean(1)).valueOf() ); + +new TestCase( SECTION, "new Boolean(0)", false, (new Boolean(0)).valueOf() ); +new TestCase( SECTION, "new Boolean(-1)", true, (new Boolean(-1)).valueOf() ); +new TestCase( SECTION, "new Boolean('1')", true, (new Boolean("1")).valueOf() ); +new TestCase( SECTION, "new Boolean('0')", true, (new Boolean("0")).valueOf() ); +new TestCase( SECTION, "new Boolean(true)", true, (new Boolean(true)).valueOf() ); +new TestCase( SECTION, "new Boolean(false)", false, (new Boolean(false)).valueOf() ); +new TestCase( SECTION, "new Boolean('true')", true, (new Boolean("true")).valueOf() ); +new TestCase( SECTION, "new Boolean('false')", true, (new Boolean('false')).valueOf() ); + +new TestCase( SECTION, "new Boolean('')", false, (new Boolean('')).valueOf() ); +new TestCase( SECTION, "new Boolean(null)", false, (new Boolean(null)).valueOf() ); +new TestCase( SECTION, "new Boolean(void(0))", false, (new Boolean(void(0))).valueOf() ); +new TestCase( SECTION, "new Boolean(-Infinity)", true, (new Boolean(Number.NEGATIVE_INFINITY)).valueOf() ); +new TestCase( SECTION, "new Boolean(NaN)", false, (new Boolean(Number.NaN)).valueOf() ); +new TestCase( SECTION, "new Boolean()", false, (new Boolean()).valueOf() ); + +new TestCase( SECTION, "new Boolean(x=1)", true, (new Boolean(x=1)).valueOf() ); +new TestCase( SECTION, "new Boolean(x=0)", false, (new Boolean(x=0)).valueOf() ); +new TestCase( SECTION, "new Boolean(x=false)", false, (new Boolean(x=false)).valueOf() ); +new TestCase( SECTION, "new Boolean(x=true)", true, (new Boolean(x=true)).valueOf() ); +new TestCase( SECTION, "new Boolean(x=null)", false, (new Boolean(x=null)).valueOf() ); +new TestCase( SECTION, "new Boolean(x='')", false, (new Boolean(x="")).valueOf() ); +new TestCase( SECTION, "new Boolean(x=' ')", true, (new Boolean(x=" ")).valueOf() ); + +test(); diff --git a/tests/auto/qml/parserstress/tests/ecma/Boolean/15.6.4.3-2.js b/tests/auto/qml/parserstress/tests/ecma/Boolean/15.6.4.3-2.js new file mode 100644 index 0000000000..5548a7874f --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Boolean/15.6.4.3-2.js @@ -0,0 +1,67 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.6.4.3-2.js'; + +/** + File Name: 15.6.4.3-2.js + ECMA Section: 15.6.4.3 Boolean.prototype.valueOf() + Description: Returns this boolean value. + + The valueOf function is not generic; it generates + a runtime error if its this value is not a Boolean + object. Therefore it cannot be transferred to other + kinds of objects for use as a method. + + Author: christine@netscape.com + Date: june 27, 1997 +*/ + +var SECTION = "15.6.4.3-2"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Boolean.prototype.valueOf()"; + +writeHeaderToLog( SECTION + " "+ TITLE); + + +new TestCase( SECTION, "valof=Boolean.prototype.valueOf; x=new Boolean(); x.valueOf=valof;x.valueOf()", false, eval("valof=Boolean.prototype.valueOf; x=new Boolean(); x.valueOf=valof;x.valueOf()") ); + +new TestCase( SECTION, "valof=Boolean.prototype.valueOf; x=new Boolean(true); x.valueOf=valof;x.valueOf()", true, eval("valof=Boolean.prototype.valueOf; x=new Boolean(true); x.valueOf=valof;x.valueOf()") ); + +test(); diff --git a/tests/auto/qml/parserstress/tests/ecma/Boolean/15.6.4.3-3.js b/tests/auto/qml/parserstress/tests/ecma/Boolean/15.6.4.3-3.js new file mode 100644 index 0000000000..f05dfc0c60 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Boolean/15.6.4.3-3.js @@ -0,0 +1,66 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.6.4.3-3.js'; + +/** + File Name: 15.6.4.3-3.js + ECMA Section: 15.6.4.3 Boolean.prototype.valueOf() + Description: Returns this boolean value. + + The valueOf function is not generic; it generates + a runtime error if its this value is not a Boolean + object. Therefore it cannot be transferred to other + kinds of objects for use as a method. + + Author: christine@netscape.com + Date: june 27, 1997 +*/ + +var SECTION = "15.6.4.3-3"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Boolean.prototype.valueOf()"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +new TestCase( SECTION, + "x=true; x.valueOf=Boolean.prototype.valueOf;x.valueOf()", + true, + eval("x=true; x.valueOf=Boolean.prototype.valueOf;x.valueOf()") ); +test(); diff --git a/tests/auto/qml/parserstress/tests/ecma/Boolean/15.6.4.3-4-n.js b/tests/auto/qml/parserstress/tests/ecma/Boolean/15.6.4.3-4-n.js new file mode 100644 index 0000000000..4ebabfa84c --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Boolean/15.6.4.3-4-n.js @@ -0,0 +1,69 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.6.4.3-4-n.js'; + +/** + File Name: 15.6.4.3-4.js + ECMA Section: 15.6.4.3 Boolean.prototype.valueOf() + Description: Returns this boolean value. + + The valueOf function is not generic; it generates + a runtime error if its this value is not a Boolean + object. Therefore it cannot be transferred to other + kinds of objects for use as a method. + + Author: christine@netscape.com + Date: june 27, 1997 +*/ +var SECTION = "15.6.4.3-4-n"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Boolean.prototype.valueOf()"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +DESCRIPTION = "valof=Boolean.prototype.valueOf; x=new String( 'hello' ); x.valueOf=valof;x.valueOf()" + EXPECTED = "error"; + +new TestCase( SECTION, + "valof=Boolean.prototype.valueOf; x=new String( 'hello' ); x.valueOf=valof;x.valueOf()", + "error", + eval("valof=Boolean.prototype.valueOf; x=new String( 'hello' ); x.valueOf=valof;x.valueOf()") ); + +test(); diff --git a/tests/auto/qml/parserstress/tests/ecma/Boolean/15.6.4.3.js b/tests/auto/qml/parserstress/tests/ecma/Boolean/15.6.4.3.js new file mode 100644 index 0000000000..570652ee39 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Boolean/15.6.4.3.js @@ -0,0 +1,83 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.6.4.3.js'; + +/** + File Name: 15.6.4.3.js + ECMA Section: 15.6.4.3 Boolean.prototype.valueOf() + Description: Returns this boolean value. + + The valueOf function is not generic; it generates + a runtime error if its this value is not a Boolean + object. Therefore it cannot be transferred to other + kinds of objects for use as a method. + + Author: christine@netscape.com + Date: june 27, 1997 +*/ + +startTest(); + +new TestCase( "15.8.6.4", "new Boolean(1)", true, (new Boolean(1)).valueOf() ); + +new TestCase( "15.8.6.4", "new Boolean(0)", false, (new Boolean(0)).valueOf() ); +new TestCase( "15.8.6.4", "new Boolean(-1)", true, (new Boolean(-1)).valueOf() ); +new TestCase( "15.8.6.4", "new Boolean('1')", true, (new Boolean("1")).valueOf() ); +new TestCase( "15.8.6.4", "new Boolean('0')", true, (new Boolean("0")).valueOf() ); +new TestCase( "15.8.6.4", "new Boolean(true)", true, (new Boolean(true)).valueOf() ); +new TestCase( "15.8.6.4", "new Boolean(false)", false, (new Boolean(false)).valueOf() ); +new TestCase( "15.8.6.4", "new Boolean('true')", true, (new Boolean("true")).valueOf() ); +new TestCase( "15.8.6.4", "new Boolean('false')", true, (new Boolean('false')).valueOf() ); + +new TestCase( "15.8.6.4", "new Boolean('')", false, (new Boolean('')).valueOf() ); +new TestCase( "15.8.6.4", "new Boolean(null)", false, (new Boolean(null)).valueOf() ); +new TestCase( "15.8.6.4", "new Boolean(void(0))", false, (new Boolean(void(0))).valueOf() ); +new TestCase( "15.8.6.4", "new Boolean(-Infinity)", true, (new Boolean(Number.NEGATIVE_INFINITY)).valueOf() ); +new TestCase( "15.8.6.4", "new Boolean(NaN)", false, (new Boolean(Number.NaN)).valueOf() ); +new TestCase( "15.8.6.4", "new Boolean()", false, (new Boolean()).valueOf() ); + +new TestCase( "15.8.6.4", "new Boolean(x=1)", true, (new Boolean(x=1)).valueOf() ); +new TestCase( "15.8.6.4", "new Boolean(x=0)", false, (new Boolean(x=0)).valueOf() ); +new TestCase( "15.8.6.4", "new Boolean(x=false)", false, (new Boolean(x=false)).valueOf() ); +new TestCase( "15.8.6.4", "new Boolean(x=true)", true, (new Boolean(x=true)).valueOf() ); +new TestCase( "15.8.6.4", "new Boolean(x=null)", false, (new Boolean(x=null)).valueOf() ); +new TestCase( "15.8.6.4", "new Boolean(x='')", false, (new Boolean(x="")).valueOf() ); +new TestCase( "15.8.6.4", "new Boolean(x=' ')", true, (new Boolean(x=" ")).valueOf() ); + +test(); diff --git a/tests/auto/qml/parserstress/tests/ecma/Boolean/15.6.4.js b/tests/auto/qml/parserstress/tests/ecma/Boolean/15.6.4.js new file mode 100644 index 0000000000..0c95d255fe --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Boolean/15.6.4.js @@ -0,0 +1,80 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.6.4.js'; + +/** + File Name: 15.6.4.js + ECMA Section: Properties of the Boolean Prototype Object + Description: + The Boolean prototype object is itself a Boolean object (its [[Class]] is " + Boolean") whose value is false. + + The value of the internal [[Prototype]] property of the Boolean prototype + object is the Object prototype object (15.2.3.1). + + In following descriptions of functions that are properties of the Boolean + prototype object, the phrase "this Boolean object" refers to the object that + is the this value for the invocation of the function; it is an error if + this does not refer to an object for which the value of the internal + [[Class]] property is "Boolean". Also, the phrase "this boolean value" + refers to the boolean value represented by this Boolean object, that is, + the value of the internal [[Value]] property of this Boolean object. + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + +var SECTION = "15.6.4"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Properties of the Boolean Prototype Object"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +new TestCase( SECTION, + "Boolean.prototype == false", + true, + Boolean.prototype == false ); + +new TestCase( SECTION, + "Boolean.prototype.toString = Object.prototype.toString; Boolean.prototype.toString()", + "[object Boolean]", + eval("Boolean.prototype.toString = Object.prototype.toString; Boolean.prototype.toString()") ); + +test(); diff --git a/tests/auto/qml/parserstress/tests/ecma/Boolean/browser.js b/tests/auto/qml/parserstress/tests/ecma/Boolean/browser.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/auto/qml/parserstress/tests/ecma/Boolean/shell.js b/tests/auto/qml/parserstress/tests/ecma/Boolean/shell.js new file mode 100644 index 0000000000..2ff7258ce8 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Boolean/shell.js @@ -0,0 +1 @@ +gTestsubsuite = 'Boolean'; diff --git a/tests/auto/qml/parserstress/tests/ecma/Date/15.9.1.1-1.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.1.1-1.js new file mode 100644 index 0000000000..8e82d205f3 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.1.1-1.js @@ -0,0 +1,96 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.9.1.1-1.js'; + +/** + File Name: 15.9.1.1-1.js + ECMA Section: 15.9.1.1 Time Range + Description: + - leap seconds are ignored + - assume 86400000 ms / day + - numbers range fom +/- 9,007,199,254,740,991 + - ms precision for any instant that is within + approximately +/-285,616 years from 1 jan 1970 + UTC + - range of times supported is -100,000,000 days + to 100,000,000 days from 1 jan 1970 12:00 am + - time supported is 8.64e5*10e8 milliseconds from + 1 jan 1970 UTC (+/-273972.6027397 years) + + - this test generates its own data -- it does not + read data from a file. + Author: christine@netscape.com + Date: 7 july 1997 + + Static variables: + FOUR_HUNDRED_YEARS + +*/ + +// every one hundred years contains: +// 24 years with 366 days +// +// every four hundred years contains: +// 97 years with 366 days +// 303 years with 365 days +// +// 86400000*365*97 = 3067372800000 +// +86400000*366*303 = + 9555408000000 +// = 1.26227808e+13 +var FOUR_HUNDRED_YEARS = 1.26227808e+13; +var SECTION = "15.9.1.1-1"; +startTest(); + +writeHeaderToLog("15.8.1.1 Time Range"); + +var M_SECS; +var CURRENT_YEAR; + +for ( M_SECS = 0, CURRENT_YEAR = 1970; + M_SECS < 8640000000000000; + M_SECS += FOUR_HUNDRED_YEARS, CURRENT_YEAR += 400 ) { + + new TestCase( SECTION, + "new Date("+M_SECS+")", + CURRENT_YEAR, + (new Date( M_SECS)).getUTCFullYear() ); +} + +test(); + diff --git a/tests/auto/qml/parserstress/tests/ecma/Date/15.9.1.1-2.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.1.1-2.js new file mode 100644 index 0000000000..7b8c2644e3 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.1.1-2.js @@ -0,0 +1,91 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.9.1.1-2.js'; + +/** + File Name: 15.9.1.1-2.js + ECMA Section: 15.9.1.1 Time Range + Description: + - leap seconds are ignored + - assume 86400000 ms / day + - numbers range fom +/- 9,007,199,254,740,991 + - ms precision for any instant that is within + approximately +/-285,616 years from 1 jan 1970 + UTC + - range of times supported is -100,000,000 days + to 100,000,000 days from 1 jan 1970 12:00 am + - time supported is 8.64e5*10e8 milliseconds from + 1 jan 1970 UTC (+/-273972.6027397 years) + Author: christine@netscape.com + Date: 9 july 1997 +*/ + +// every one hundred years contains: +// 24 years with 366 days +// +// every four hundred years contains: +// 97 years with 366 days +// 303 years with 365 days +// +// 86400000*366*97 = 3067372800000 +// +86400000*365*303 = + 9555408000000 +// = 1.26227808e+13 + +var FOUR_HUNDRED_YEARS = 1.26227808e+13; +var SECTION = "15.9.1.1-2"; +startTest(); + +writeHeaderToLog("15.8.1.1 Time Range"); + +var M_SECS; +var CURRENT_YEAR; + +for ( M_SECS = 0, CURRENT_YEAR = 1970; + M_SECS > -8640000000000000; + M_SECS -= FOUR_HUNDRED_YEARS, CURRENT_YEAR -= 400 ) { + + new TestCase( SECTION, + "new Date("+M_SECS+")", + CURRENT_YEAR, + (new Date( M_SECS )).getUTCFullYear() ); + +} + +test(); + diff --git a/tests/auto/qml/parserstress/tests/ecma/Date/15.9.1.13-1.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.1.13-1.js new file mode 100755 index 0000000000..720b39dd54 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.1.13-1.js @@ -0,0 +1,79 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.9.1.13-1.js'; + +/** + File Name: 15.9.1.13-1.js + ECMA Section: 15.9.1.1 MakeDate(day, time) + Description: + + The operator MakeDate calculates a number of milliseconds from its + two arguments, which must be ECMAScript number values. This + operator functions as follows: + + 1. If day is not finite or time is not finite, return NaN. + + 2. Compute day * msPerDay + time. + + 3. Return Result(2). +*/ +startTest(); + +new TestCase( SECTION, + "MakeDate(Number.POSITIVE_INFINITY, 0)", + Number.NaN, + MakeDate(Number.POSITIVE_INFINITY, 0)); + +new TestCase( SECTION, + "MakeDate(Number.NEGATIVE_INFINITY, 0)", + Number.NaN, + MakeDate(Number.NEGATIVE_INFINITY, 0)); + +new TestCase( SECTION, + "MakeDate(0, Number.POSITIVE_INFINITY)", + Number.NaN, + MakeDate(0, Number.POSITIVE_INFINITY)); + +new TestCase( SECTION, + "MakeDate(0, Number.NEGATIVE_INFINITY)", + Number.NaN, + MakeDate(0, Number.NEGATIVE_INFINITY)); + +test(); + diff --git a/tests/auto/qml/parserstress/tests/ecma/Date/15.9.2.1.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.2.1.js new file mode 100644 index 0000000000..6cd76efb6b --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.2.1.js @@ -0,0 +1,104 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.9.2.1.js'; + +/** + File Name: 15.9.2.1.js + ECMA Section: 15.9.2.1 Date constructor used as a function + Date( year, month, date, hours, minutes, seconds, ms ) + Description: The arguments are accepted, but are completely ignored. + A string is created and returned as if by the + expression (new Date()).toString(). + + Author: christine@netscape.com + Date: 28 october 1997 + +*/ +var VERSION = "ECMA_1"; +startTest(); +var SECTION = "15.9.2.1"; +var TITLE = "Date Constructor used as a function"; +var TYPEOF = "string"; +var TOLERANCE = 1000; + +writeHeaderToLog("15.9.2.1 The Date Constructor Called as a Function: " + + "Date( year, month, date, hours, minutes, seconds, ms )" ); + +var TODAY = new Date(); + +// Dates around 1970 + +new TestCase( SECTION, "Date(1970,0,1,0,0,0,0)", (new Date()).toString(), Date(1970,0,1,0,0,0,0) ); +new TestCase( SECTION, "Date(1969,11,31,15,59,59,999)", (new Date()).toString(), Date(1969,11,31,15,59,59,999)); +new TestCase( SECTION, "Date(1969,11,31,16,0,0,0)", (new Date()).toString(), Date(1969,11,31,16,0,0,0)); +new TestCase( SECTION, "Date(1969,11,31,16,0,0,1)", (new Date()).toString(), Date(1969,11,31,16,0,0,1)); + +// Dates around 2000 +new TestCase( SECTION, "Date(1999,11,15,59,59,999)", (new Date()).toString(), Date(1999,11,15,59,59,999)); +new TestCase( SECTION, "Date(1999,11,16,0,0,0,0)", (new Date()).toString(), Date(1999,11,16,0,0,0,0)); +new TestCase( SECTION, "Date(1999,11,31,23,59,59,999)", (new Date()).toString(), Date(1999,11,31,23,59,59,999) ); +new TestCase( SECTION, "Date(2000,0,1,0,0,0,0)", (new Date()).toString(), Date(2000,0,0,0,0,0,0) ); +new TestCase( SECTION, "Date(2000,0,1,0,0,0,1)", (new Date()).toString(), Date(2000,0,0,0,0,0,1) ); + +// Dates around 1900 + +new TestCase( SECTION, "Date(1899,11,31,23,59,59,999)", (new Date()).toString(), Date(1899,11,31,23,59,59,999)); +new TestCase( SECTION, "Date(1900,0,1,0,0,0,0)", (new Date()).toString(), Date(1900,0,1,0,0,0,0) ); +new TestCase( SECTION, "Date(1900,0,1,0,0,0,1)", (new Date()).toString(), Date(1900,0,1,0,0,0,1) ); +new TestCase( SECTION, "Date(1899,11,31,16,0,0,0,0)", (new Date()).toString(), Date(1899,11,31,16,0,0,0,0)); + +// Dates around feb 29, 2000 + +new TestCase( SECTION, "Date( 2000,1,29,0,0,0,0)", (new Date()).toString(), Date(2000,1,29,0,0,0,0)); +new TestCase( SECTION, "Date( 2000,1,28,23,59,59,999)", (new Date()).toString(), Date( 2000,1,28,23,59,59,999)); +new TestCase( SECTION, "Date( 2000,1,27,16,0,0,0)", (new Date()).toString(), Date(2000,1,27,16,0,0,0)); + +// Dates around jan 1, 2005 +new TestCase( SECTION, "Date(2004,11,31,23,59,59,999)", (new Date()).toString(), Date(2004,11,31,23,59,59,999)); +new TestCase( SECTION, "Date(2005,0,1,0,0,0,0)", (new Date()).toString(), Date(2005,0,1,0,0,0,0) ); +new TestCase( SECTION, "Date(2005,0,1,0,0,0,1)", (new Date()).toString(), Date(2005,0,1,0,0,0,1) ); +new TestCase( SECTION, "Date(2004,11,31,16,0,0,0,0)", (new Date()).toString(), Date(2004,11,31,16,0,0,0,0)); + +// Dates around jan 1, 2032 +new TestCase( SECTION, "Date(2031,11,31,23,59,59,999)", (new Date()).toString(), Date(2031,11,31,23,59,59,999)); +new TestCase( SECTION, "Date(2032,0,1,0,0,0,0)", (new Date()).toString(), Date(2032,0,1,0,0,0,0) ); +new TestCase( SECTION, "Date(2032,0,1,0,0,0,1)", (new Date()).toString(), Date(2032,0,1,0,0,0,1) ); +new TestCase( SECTION, "Date(2031,11,31,16,0,0,0,0)", (new Date()).toString(), Date(2031,11,31,16,0,0,0,0)); + +test(); diff --git a/tests/auto/qml/parserstress/tests/ecma/Date/15.9.2.2-1.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.2.2-1.js new file mode 100644 index 0000000000..0c643cfd3a --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.2.2-1.js @@ -0,0 +1,69 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.9.2.2-1.js'; + +/** + File Name: 15.9.2.2.js + ECMA Section: 15.9.2.2 Date constructor used as a function + Date( year, month, date, hours, minutes, seconds ) + Description: The arguments are accepted, but are completely ignored. + A string is created and returned as if by the + expression (new Date()).toString(). + + Author: christine@netscape.com + Date: 28 october 1997 + Version: 9706 + +*/ +var VERSION = 9706; +startTest(); +var SECTION = "15.9.2.2"; +var TOLERANCE = 100; +var TITLE = "The Date Constructor Called as a Function"; + +writeHeaderToLog(SECTION+" "+TITLE ); + +// Dates around 1970 + +new TestCase( SECTION, "Date(1970,0,1,0,0,0)", (new Date()).toString(), Date(1970,0,1,0,0,0) ); +new TestCase( SECTION, "Date(1969,11,31,15,59,59)", (new Date()).toString(), Date(1969,11,31,15,59,59)); +new TestCase( SECTION, "Date(1969,11,31,16,0,0)", (new Date()).toString(), Date(1969,11,31,16,0,0)); +new TestCase( SECTION, "Date(1969,11,31,16,0,1)", (new Date()).toString(), Date(1969,11,31,16,0,1)); + +test(); diff --git a/tests/auto/qml/parserstress/tests/ecma/Date/15.9.2.2-2.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.2.2-2.js new file mode 100644 index 0000000000..af95bb3ae6 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.2.2-2.js @@ -0,0 +1,69 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.9.2.2-2.js'; + +/** + File Name: 15.9.2.2.js + ECMA Section: 15.9.2.2 Date constructor used as a function + Date( year, month, date, hours, minutes, seconds ) + Description: The arguments are accepted, but are completely ignored. + A string is created and returned as if by the + expression (new Date()).toString(). + + Author: christine@netscape.com + Date: 28 october 1997 + Version: 9706 + +*/ +var VERSION = 9706; +startTest(); +var SECTION = "15.9.2.2"; +var TOLERANCE = 100; +var TITLE = "The Date Constructor Called as a Function"; + +writeHeaderToLog(SECTION+" "+TITLE ); + +// Dates around 2000 +new TestCase( SECTION, "Date(1999,11,15,59,59)", (new Date()).toString(), Date(1999,11,15,59,59)); +new TestCase( SECTION, "Date(1999,11,16,0,0,0)", (new Date()).toString(), Date(1999,11,16,0,0,0)); +new TestCase( SECTION, "Date(1999,11,31,23,59,59)", (new Date()).toString(), Date(1999,11,31,23,59,59) ); +new TestCase( SECTION, "Date(2000,0,1,0,0,0)", (new Date()).toString(), Date(2000,0,0,0,0,0) ); +new TestCase( SECTION, "Date(2000,0,1,0,0,1)", (new Date()).toString(), Date(2000,0,0,0,0,1) ); + +test(); diff --git a/tests/auto/qml/parserstress/tests/ecma/Date/15.9.2.2-3.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.2.2-3.js new file mode 100644 index 0000000000..f7de60b5b1 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.2.2-3.js @@ -0,0 +1,69 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.9.2.2-3.js'; + +/** + File Name: 15.9.2.2.js + ECMA Section: 15.9.2.2 Date constructor used as a function + Date( year, month, date, hours, minutes, seconds ) + Description: The arguments are accepted, but are completely ignored. + A string is created and returned as if by the + expression (new Date()).toString(). + + Author: christine@netscape.com + Date: 28 october 1997 + Version: 9706 + +*/ +var VERSION = 9706; +startTest(); +var SECTION = "15.9.2.2"; +var TOLERANCE = 100; +var TITLE = "The Date Constructor Called as a Function"; + +writeHeaderToLog(SECTION+" "+TITLE ); + +// Dates around 1900 + +new TestCase( SECTION, "Date(1899,11,31,23,59,59)", (new Date()).toString(), Date(1899,11,31,23,59,59)); +new TestCase( SECTION, "Date(1900,0,1,0,0,0)", (new Date()).toString(), Date(1900,0,1,0,0,0) ); +new TestCase( SECTION, "Date(1900,0,1,0,0,1)", (new Date()).toString(), Date(1900,0,1,0,0,1) ); +new TestCase( SECTION, "Date(1899,11,31,16,0,0,0)", (new Date()).toString(), Date(1899,11,31,16,0,0,0)); + +test(); diff --git a/tests/auto/qml/parserstress/tests/ecma/Date/15.9.2.2-4.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.2.2-4.js new file mode 100644 index 0000000000..119b4f2559 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.2.2-4.js @@ -0,0 +1,68 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.9.2.2-4.js'; + +/** + File Name: 15.9.2.2.js + ECMA Section: 15.9.2.2 Date constructor used as a function + Date( year, month, date, hours, minutes, seconds ) + Description: The arguments are accepted, but are completely ignored. + A string is created and returned as if by the + expression (new Date()).toString(). + + Author: christine@netscape.com + Date: 28 october 1997 + Version: 9706 + +*/ +var VERSION = 9706; +startTest(); +var SECTION = "15.9.2.2"; +var TOLERANCE = 100; +var TITLE = "The Date Constructor Called as a Function"; + +writeHeaderToLog(SECTION+" "+TITLE ); + +// Dates around feb 29, 2000 + +new TestCase( SECTION, "Date( 2000,1,29,0,0,0)", (new Date()).toString(), Date(2000,1,29,0,0,0)); +new TestCase( SECTION, "Date( 2000,1,28,23,59,59)", (new Date()).toString(), Date( 2000,1,28,23,59,59)); +new TestCase( SECTION, "Date( 2000,1,27,16,0,0)", (new Date()).toString(), Date(2000,1,27,16,0,0)); + +test(); diff --git a/tests/auto/qml/parserstress/tests/ecma/Date/15.9.2.2-5.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.2.2-5.js new file mode 100644 index 0000000000..d9369ca4c5 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.2.2-5.js @@ -0,0 +1,68 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.9.2.2-5.js'; + +/** + File Name: 15.9.2.2.js + ECMA Section: 15.9.2.2 Date constructor used as a function + Date( year, month, date, hours, minutes, seconds ) + Description: The arguments are accepted, but are completely ignored. + A string is created and returned as if by the + expression (new Date()).toString(). + + Author: christine@netscape.com + Date: 28 october 1997 + Version: 9706 + +*/ +var VERSION = 9706; +startTest(); +var SECTION = "15.9.2.2"; +var TOLERANCE = 100; +var TITLE = "The Date Constructor Called as a Function"; + +writeHeaderToLog(SECTION+" "+TITLE ); + +// Dates around jan 1, 2005 +new TestCase( SECTION, "Date(2004,11,31,23,59,59)", (new Date()).toString(), Date(2004,11,31,23,59,59)); +new TestCase( SECTION, "Date(2005,0,1,0,0,0)", (new Date()).toString(), Date(2005,0,1,0,0,0) ); +new TestCase( SECTION, "Date(2005,0,1,0,0,1)", (new Date()).toString(), Date(2005,0,1,0,0,1) ); +new TestCase( SECTION, "Date(2004,11,31,16,0,0,0)", (new Date()).toString(), Date(2004,11,31,16,0,0,0)); + +test(); diff --git a/tests/auto/qml/parserstress/tests/ecma/Date/15.9.2.2-6.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.2.2-6.js new file mode 100644 index 0000000000..8e549936e3 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.2.2-6.js @@ -0,0 +1,67 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.9.2.2-6.js'; + +/** + File Name: 15.9.2.2.js + ECMA Section: 15.9.2.2 Date constructor used as a function + Date( year, month, date, hours, minutes, seconds ) + Description: The arguments are accepted, but are completely ignored. + A string is created and returned as if by the + expression (new Date()).toString(). + + Author: christine@netscape.com + Date: 28 october 1997 + Version: 9706 + +*/ +var VERSION = 9706; +startTest(); +var SECTION = "15.9.2.2"; +var TOLERANCE = 100; +var TITLE = "The Date Constructor Called as a Function"; + +writeHeaderToLog(SECTION+" "+TITLE ); + +// Dates around jan 1, 2032 +new TestCase( SECTION, "Date(2031,11,31,23,59,59)", (new Date()).toString(), Date(2031,11,31,23,59,59)); +new TestCase( SECTION, "Date(2032,0,1,0,0,0)", (new Date()).toString(), Date(2032,0,1,0,0,0) ); +new TestCase( SECTION, "Date(2032,0,1,0,0,1)", (new Date()).toString(), Date(2032,0,1,0,0,1) ); +new TestCase( SECTION, "Date(2031,11,31,16,0,0,0)", (new Date()).toString(), Date(2031,11,31,16,0,0,0)); +test(); diff --git a/tests/auto/qml/parserstress/tests/ecma/Date/15.9.3.1-1.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.3.1-1.js new file mode 100644 index 0000000000..642169a60c --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.3.1-1.js @@ -0,0 +1,239 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.9.3.1-1.js'; + +/** + File Name: 15.9.3.1.js + ECMA Section: 15.9.3.1 new Date (year, month, date, hours, minutes, seconds, ms) + Description: The [[Prototype]] property of the newly constructed + object is set to the original Date prototype object, + the one that is the initial value of Date.prototype. + + The [[Class]] property of the newly constructed object + is set as follows: + 1. Call ToNumber(year) + 2. Call ToNumber(month) + 3. Call ToNumber(date) + 4. Call ToNumber(hours) + 5. Call ToNumber(minutes) + 6. Call ToNumber(seconds) + 7. Call ToNumber(ms) + 8. If Result(1) is NaN and 0 <= ToInteger(Result(1)) <= + 99, Result(8) is 1900+ToInteger(Result(1)); otherwise, + Result(8) is Result(1) + 9. Compute MakeDay(Result(8), Result(2), Result(3) + 10. Compute MakeTime(Result(4), Result(5), Result(6), + Result(7) + 11. Compute MakeDate(Result(9), Result(10)) + 12. Set the [[Value]] property of the newly constructed + object to TimeClip(UTC(Result(11))). + + + This tests the returned value of a newly constructed + Date object. + + Author: christine@netscape.com + Date: 7 july 1997 +*/ + +var SECTION = "15.9.3.1"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "new Date( year, month, date, hours, minutes, seconds, ms )"; + +var TIME = 0; +var UTC_YEAR = 1; +var UTC_MONTH = 2; +var UTC_DATE = 3; +var UTC_DAY = 4; +var UTC_HOURS = 5; +var UTC_MINUTES = 6; +var UTC_SECONDS = 7; +var UTC_MS = 8; + +var YEAR = 9; +var MONTH = 10; +var DATE = 11; +var DAY = 12; +var HOURS = 13; +var MINUTES = 14; +var SECONDS = 15; +var MS = 16; + +writeHeaderToLog( SECTION + " "+ TITLE); + +// Dates around 1970 + +addNewTestCase( new Date( 1969,11,31,15,59,59,999), + "new Date( 1969,11,31,15,59,59,999)", + [TIME_1970-1,1969,11,31,3,23,59,59,999,1969,11,31,3,15,59,59,999] ); + +addNewTestCase( new Date( 1969,11,31,23,59,59,999), + "new Date( 1969,11,31,23,59,59,999)", + [TIME_1970-PST_ADJUST-1,1970,0,1,4,7,59,59,999,1969,11,31,3,23,59,59,999] ); + +addNewTestCase( new Date( 1970,0,1,0,0,0,0), + "new Date( 1970,0,1,0,0,0,0)", + [TIME_1970-PST_ADJUST,1970,0,1,4,8,0,0,0,1970,0,1,4,0,0,0,0] ); + +addNewTestCase( new Date( 1969,11,31,16,0,0,0), + "new Date( 1969,11,31,16,0,0,0)", + [TIME_1970,1970,0,1,4,0,0,0,0,1969,11,31,3,16,0,0,0] ); + +addNewTestCase( new Date(1969,12,1,0,0,0,0), + "new Date(1969,12,1,0,0,0,0)", + [TIME_1970-PST_ADJUST,1970,0,1,4,8,0,0,0,1970,0,1,4,0,0,0,0] ); + +addNewTestCase( new Date(1969,11,32,0,0,0,0), + "new Date(1969,11,32,0,0,0,0)", + [TIME_1970-PST_ADJUST,1970,0,1,4,8,0,0,0,1970,0,1,4,0,0,0,0] ); + +addNewTestCase( new Date(1969,11,31,24,0,0,0), + "new Date(1969,11,31,24,0,0,0)", + [TIME_1970-PST_ADJUST,1970,0,1,4,8,0,0,0,1970,0,1,4,0,0,0,0] ); + +addNewTestCase( new Date(1969,11,31,23,60,0,0), + "new Date(1969,11,31,23,60,0,0)", + [TIME_1970-PST_ADJUST,1970,0,1,4,8,0,0,0,1970,0,1,4,0,0,0,0] ); + +addNewTestCase( new Date(1969,11,31,23,59,60,0), + "new Date(1969,11,31,23,59,60,0)", + [TIME_1970-PST_ADJUST,1970,0,1,4,8,0,0,0,1970,0,1,4,0,0,0,0] ); + +addNewTestCase( new Date(1969,11,31,23,59,59,1000), + "new Date(1969,11,31,23,59,59,1000)", + [TIME_1970-PST_ADJUST,1970,0,1,4,8,0,0,0,1970,0,1,4,0,0,0,0] ); + +// Dates around 2000 + +addNewTestCase( new Date( 1999,11,31,15,59,59,999), + "new Date( 1999,11,31,15,59,59,999)", + [TIME_2000-1,1999,11,31,5,23,59,59,999,1999,11,31,5,15,59,59,999] ); + +addNewTestCase( new Date( 1999,11,31,16,0,0,0), + "new Date( 1999,11,31,16,0,0,0)", + [TIME_2000,2000,0,1,6,0,0,0,0,1999,11,31,5, 16,0,0,0] ); + +addNewTestCase( new Date( 1999,11,31,23,59,59,999), + "new Date( 1999,11,31,23,59,59,999)", + [TIME_2000-PST_ADJUST-1,2000,0,1,6,7,59,59,999,1999,11,31,5,23,59,59,999] ); + +addNewTestCase( new Date( 2000,0,1,0,0,0,0), + "new Date( 2000,0,1,0,0,0,0)", + [TIME_2000-PST_ADJUST,2000,0,1,6,8,0,0,0,2000,0,1,6,0,0,0,0] ); + +addNewTestCase( new Date( 2000,0,1,0,0,0,1), + "new Date( 2000,0,1,0,0,0,1)", + [TIME_2000-PST_ADJUST+1,2000,0,1,6,8,0,0,1,2000,0,1,6,0,0,0,1] ); + +// Dates around 29 Feb 2000 + +addNewTestCase( new Date(2000,1,28,16,0,0,0), + "new Date(2000,1,28,16,0,0,0)", + [UTC_FEB_29_2000,2000,1,29,2,0,0,0,0,2000,1,28,1,16,0,0,0] ); + +addNewTestCase( new Date(2000,1,29,0,0,0,0), + "new Date(2000,1,29,0,0,0,0)", + [UTC_FEB_29_2000-PST_ADJUST,2000,1,29,2,8,0,0,0,2000,1,29,2,0,0,0,0] ); + +addNewTestCase( new Date(2000,1,28,24,0,0,0), + "new Date(2000,1,28,24,0,0,0)", + [UTC_FEB_29_2000-PST_ADJUST,2000,1,29,2,8,0,0,0,2000,1,29,2,0,0,0,0] ); + +// Dates around 1900 + +addNewTestCase( new Date(1899,11,31,16,0,0,0), + "new Date(1899,11,31,16,0,0,0)", + [TIME_1900,1900,0,1,1,0,0,0,0,1899,11,31,0,16,0,0,0] ); + +addNewTestCase( new Date(1899,11,31,15,59,59,999), + "new Date(1899,11,31,15,59,59,999)", + [TIME_1900-1,1899,11,31,0,23,59,59,999,1899,11,31,0,15,59,59,999] ); + +addNewTestCase( new Date(1899,11,31,23,59,59,999), + "new Date(1899,11,31,23,59,59,999)", + [TIME_1900-PST_ADJUST-1,1900,0,1,1,7,59,59,999,1899,11,31,0,23,59,59,999] ); + +addNewTestCase( new Date(1900,0,1,0,0,0,0), + "new Date(1900,0,1,0,0,0,0)", + [TIME_1900-PST_ADJUST,1900,0,1,1,8,0,0,0,1900,0,1,1,0,0,0,0] ); + +addNewTestCase( new Date(1900,0,1,0,0,0,1), + "new Date(1900,0,1,0,0,0,1)", + [TIME_1900-PST_ADJUST+1,1900,0,1,1,8,0,0,1,1900,0,1,1,0,0,0,1] ); + +// Dates around 2005 + +addNewTestCase( new Date(2005,0,1,0,0,0,0), + "new Date(2005,0,1,0,0,0,0)", + [UTC_JAN_1_2005-PST_ADJUST,2005,0,1,6,8,0,0,0,2005,0,1,6,0,0,0,0] ); + +addNewTestCase( new Date(2004,11,31,16,0,0,0), + "new Date(2004,11,31,16,0,0,0)", + [UTC_JAN_1_2005,2005,0,1,6,0,0,0,0,2004,11,31,5,16,0,0,0] ); + +test(); + + +function addNewTestCase( DateCase, DateString, ResultArray ) { + //adjust hard-coded ResultArray for tester's timezone instead of PST + adjustResultArray(ResultArray); + + new TestCase( SECTION, DateString+".getTime()", ResultArray[TIME], DateCase.getTime() ); + new TestCase( SECTION, DateString+".valueOf()", ResultArray[TIME], DateCase.valueOf() ); + + new TestCase( SECTION, DateString+".getUTCFullYear()", ResultArray[UTC_YEAR], DateCase.getUTCFullYear() ); + new TestCase( SECTION, DateString+".getUTCMonth()", ResultArray[UTC_MONTH], DateCase.getUTCMonth() ); + new TestCase( SECTION, DateString+".getUTCDate()", ResultArray[UTC_DATE], DateCase.getUTCDate() ); + new TestCase( SECTION, DateString+".getUTCDay()", ResultArray[UTC_DAY], DateCase.getUTCDay() ); + new TestCase( SECTION, DateString+".getUTCHours()", ResultArray[UTC_HOURS], DateCase.getUTCHours() ); + new TestCase( SECTION, DateString+".getUTCMinutes()", ResultArray[UTC_MINUTES],DateCase.getUTCMinutes() ); + new TestCase( SECTION, DateString+".getUTCSeconds()", ResultArray[UTC_SECONDS],DateCase.getUTCSeconds() ); + new TestCase( SECTION, DateString+".getUTCMilliseconds()", ResultArray[UTC_MS], DateCase.getUTCMilliseconds() ); + + new TestCase( SECTION, DateString+".getFullYear()", ResultArray[YEAR], DateCase.getFullYear() ); + new TestCase( SECTION, DateString+".getMonth()", ResultArray[MONTH], DateCase.getMonth() ); + new TestCase( SECTION, DateString+".getDate()", ResultArray[DATE], DateCase.getDate() ); + new TestCase( SECTION, DateString+".getDay()", ResultArray[DAY], DateCase.getDay() ); + new TestCase( SECTION, DateString+".getHours()", ResultArray[HOURS], DateCase.getHours() ); + new TestCase( SECTION, DateString+".getMinutes()", ResultArray[MINUTES], DateCase.getMinutes() ); + new TestCase( SECTION, DateString+".getSeconds()", ResultArray[SECONDS], DateCase.getSeconds() ); + new TestCase( SECTION, DateString+".getMilliseconds()", ResultArray[MS], DateCase.getMilliseconds() ); +} + diff --git a/tests/auto/qml/parserstress/tests/ecma/Date/15.9.3.1-2.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.3.1-2.js new file mode 100644 index 0000000000..fb9dff486c --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.3.1-2.js @@ -0,0 +1,152 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.9.3.1-2.js'; + +/** + File Name: 15.9.3.1.js + ECMA Section: 15.9.3.1 new Date (year, month, date, hours, minutes, seconds, ms) + Description: The [[Prototype]] property of the newly constructed + object is set to the original Date prototype object, + the one that is the initial value of Date.prototype. + + The [[Class]] property of the newly constructed object + is set as follows: + 1. Call ToNumber(year) + 2. Call ToNumber(month) + 3. Call ToNumber(date) + 4. Call ToNumber(hours) + 5. Call ToNumber(minutes) + 6. Call ToNumber(seconds) + 7. Call ToNumber(ms) + 8. If Result(1) is NaN and 0 <= ToInteger(Result(1)) <= + 99, Result(8) is 1900+ToInteger(Result(1)); otherwise, + Result(8) is Result(1) + 9. Compute MakeDay(Result(8), Result(2), Result(3) + 10. Compute MakeTime(Result(4), Result(5), Result(6), + Result(7) + 11. Compute MakeDate(Result(9), Result(10)) + 12. Set the [[Value]] property of the newly constructed + object to TimeClip(UTC(Result(11))). + + + This tests the returned value of a newly constructed + Date object. + + Author: christine@netscape.com + Date: 7 july 1997 +*/ + +var SECTION = "15.9.3.1"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "new Date( year, month, date, hours, minutes, seconds, ms )"; + +var TIME = 0; +var UTC_YEAR = 1; +var UTC_MONTH = 2; +var UTC_DATE = 3; +var UTC_DAY = 4; +var UTC_HOURS = 5; +var UTC_MINUTES = 6; +var UTC_SECONDS = 7; +var UTC_MS = 8; + +var YEAR = 9; +var MONTH = 10; +var DATE = 11; +var DAY = 12; +var HOURS = 13; +var MINUTES = 14; +var SECONDS = 15; +var MS = 16; + +writeHeaderToLog( SECTION + " "+ TITLE); + + +// all the "ResultArrays" below are hard-coded to Pacific Standard Time values - + +// Dates around 2000 + +addNewTestCase( new Date( 1999,11,31,15,59,59,999), + "new Date( 1999,11,31,15,59,59,999)", + [TIME_2000-1,1999,11,31,5,23,59,59,999,1999,11,31,5,15,59,59,999] ); + +addNewTestCase( new Date( 1999,11,31,16,0,0,0), + "new Date( 1999,11,31,16,0,0,0)", + [TIME_2000,2000,0,1,6,0,0,0,0,1999,11,31,5, 16,0,0,0] ); + +addNewTestCase( new Date( 1999,11,31,23,59,59,999), + "new Date( 1999,11,31,23,59,59,999)", + [TIME_2000-PST_ADJUST-1,2000,0,1,6,7,59,59,999,1999,11,31,5,23,59,59,999] ); + +addNewTestCase( new Date( 2000,0,1,0,0,0,0), + "new Date( 2000,0,1,0,0,0,0)", + [TIME_2000-PST_ADJUST,2000,0,1,6,8,0,0,0,2000,0,1,6,0,0,0,0] ); + +addNewTestCase( new Date( 2000,0,1,0,0,0,1), + "new Date( 2000,0,1,0,0,0,1)", + [TIME_2000-PST_ADJUST+1,2000,0,1,6,8,0,0,1,2000,0,1,6,0,0,0,1] ); + +test(); + +function addNewTestCase( DateCase, DateString, ResultArray ) { + //adjust hard-coded ResultArray for tester's timezone instead of PST + adjustResultArray(ResultArray); + + new TestCase( SECTION, DateString+".getTime()", ResultArray[TIME], DateCase.getTime() ); + new TestCase( SECTION, DateString+".valueOf()", ResultArray[TIME], DateCase.valueOf() ); + + new TestCase( SECTION, DateString+".getUTCFullYear()", ResultArray[UTC_YEAR], DateCase.getUTCFullYear() ); + new TestCase( SECTION, DateString+".getUTCMonth()", ResultArray[UTC_MONTH], DateCase.getUTCMonth() ); + new TestCase( SECTION, DateString+".getUTCDate()", ResultArray[UTC_DATE], DateCase.getUTCDate() ); + new TestCase( SECTION, DateString+".getUTCDay()", ResultArray[UTC_DAY], DateCase.getUTCDay() ); + new TestCase( SECTION, DateString+".getUTCHours()", ResultArray[UTC_HOURS], DateCase.getUTCHours() ); + new TestCase( SECTION, DateString+".getUTCMinutes()", ResultArray[UTC_MINUTES],DateCase.getUTCMinutes() ); + new TestCase( SECTION, DateString+".getUTCSeconds()", ResultArray[UTC_SECONDS],DateCase.getUTCSeconds() ); + new TestCase( SECTION, DateString+".getUTCMilliseconds()", ResultArray[UTC_MS], DateCase.getUTCMilliseconds() ); + + new TestCase( SECTION, DateString+".getFullYear()", ResultArray[YEAR], DateCase.getFullYear() ); + new TestCase( SECTION, DateString+".getMonth()", ResultArray[MONTH], DateCase.getMonth() ); + new TestCase( SECTION, DateString+".getDate()", ResultArray[DATE], DateCase.getDate() ); + new TestCase( SECTION, DateString+".getDay()", ResultArray[DAY], DateCase.getDay() ); + new TestCase( SECTION, DateString+".getHours()", ResultArray[HOURS], DateCase.getHours() ); + new TestCase( SECTION, DateString+".getMinutes()", ResultArray[MINUTES], DateCase.getMinutes() ); + new TestCase( SECTION, DateString+".getSeconds()", ResultArray[SECONDS], DateCase.getSeconds() ); + new TestCase( SECTION, DateString+".getMilliseconds()", ResultArray[MS], DateCase.getMilliseconds() ); +} diff --git a/tests/auto/qml/parserstress/tests/ecma/Date/15.9.3.1-3.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.3.1-3.js new file mode 100644 index 0000000000..0d888b089c --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.3.1-3.js @@ -0,0 +1,141 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.9.3.1-3.js'; + +/** + File Name: 15.9.3.1.js + ECMA Section: 15.9.3.1 new Date (year, month, date, hours, minutes, seconds, ms) + Description: The [[Prototype]] property of the newly constructed + object is set to the original Date prototype object, + the one that is the initial value of Date.prototype. + + The [[Class]] property of the newly constructed object + is set as follows: + 1. Call ToNumber(year) + 2. Call ToNumber(month) + 3. Call ToNumber(date) + 4. Call ToNumber(hours) + 5. Call ToNumber(minutes) + 6. Call ToNumber(seconds) + 7. Call ToNumber(ms) + 8. If Result(1) is NaN and 0 <= ToInteger(Result(1)) <= + 99, Result(8) is 1900+ToInteger(Result(1)); otherwise, + Result(8) is Result(1) + 9. Compute MakeDay(Result(8), Result(2), Result(3) + 10. Compute MakeTime(Result(4), Result(5), Result(6), + Result(7) + 11. Compute MakeDate(Result(9), Result(10)) + 12. Set the [[Value]] property of the newly constructed + object to TimeClip(UTC(Result(11))). + + + This tests the returned value of a newly constructed + Date object. + + Author: christine@netscape.com + Date: 7 july 1997 +*/ + +var SECTION = "15.9.3.1"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "new Date( year, month, date, hours, minutes, seconds, ms )"; + +var TIME = 0; +var UTC_YEAR = 1; +var UTC_MONTH = 2; +var UTC_DATE = 3; +var UTC_DAY = 4; +var UTC_HOURS = 5; +var UTC_MINUTES = 6; +var UTC_SECONDS = 7; +var UTC_MS = 8; + +var YEAR = 9; +var MONTH = 10; +var DATE = 11; +var DAY = 12; +var HOURS = 13; +var MINUTES = 14; +var SECONDS = 15; +var MS = 16; + +writeHeaderToLog( SECTION + " "+ TITLE); + +// all the "ResultArrays" below are hard-coded to Pacific Standard Time values - +addNewTestCase( new Date(2000,1,28,16,0,0,0), + "new Date(2000,1,28,16,0,0,0)", + [UTC_FEB_29_2000,2000,1,29,2,0,0,0,0,2000,1,28,1,16,0,0,0] ); + +addNewTestCase( new Date(2000,1,29,0,0,0,0), + "new Date(2000,1,29,0,0,0,0)", + [UTC_FEB_29_2000 - PST_ADJUST,2000,1,29,2,8,0,0,0,2000,1,29,2,0,0,0,0] ); + +addNewTestCase( new Date(2000,1,28,24,0,0,0), + "new Date(2000,1,28,24,0,0,0)", + [UTC_FEB_29_2000 - PST_ADJUST,2000,1,29,2,8,0,0,0,2000,1,29,2,0,0,0,0] ); + +test(); + +function addNewTestCase( DateCase, DateString, ResultArray ) { + //adjust hard-coded ResultArray for tester's timezone instead of PST + adjustResultArray(ResultArray); + + + new TestCase( SECTION, DateString+".getTime()", ResultArray[TIME], DateCase.getTime() ); + new TestCase( SECTION, DateString+".valueOf()", ResultArray[TIME], DateCase.valueOf() ); + + new TestCase( SECTION, DateString+".getUTCFullYear()", ResultArray[UTC_YEAR], DateCase.getUTCFullYear() ); + new TestCase( SECTION, DateString+".getUTCMonth()", ResultArray[UTC_MONTH], DateCase.getUTCMonth() ); + new TestCase( SECTION, DateString+".getUTCDate()", ResultArray[UTC_DATE], DateCase.getUTCDate() ); + new TestCase( SECTION, DateString+".getUTCDay()", ResultArray[UTC_DAY], DateCase.getUTCDay() ); + new TestCase( SECTION, DateString+".getUTCHours()", ResultArray[UTC_HOURS], DateCase.getUTCHours() ); + new TestCase( SECTION, DateString+".getUTCMinutes()", ResultArray[UTC_MINUTES],DateCase.getUTCMinutes() ); + new TestCase( SECTION, DateString+".getUTCSeconds()", ResultArray[UTC_SECONDS],DateCase.getUTCSeconds() ); + new TestCase( SECTION, DateString+".getUTCMilliseconds()", ResultArray[UTC_MS], DateCase.getUTCMilliseconds() ); + + new TestCase( SECTION, DateString+".getFullYear()", ResultArray[YEAR], DateCase.getFullYear() ); + new TestCase( SECTION, DateString+".getMonth()", ResultArray[MONTH], DateCase.getMonth() ); + new TestCase( SECTION, DateString+".getDate()", ResultArray[DATE], DateCase.getDate() ); + new TestCase( SECTION, DateString+".getDay()", ResultArray[DAY], DateCase.getDay() ); + new TestCase( SECTION, DateString+".getHours()", ResultArray[HOURS], DateCase.getHours() ); + new TestCase( SECTION, DateString+".getMinutes()", ResultArray[MINUTES], DateCase.getMinutes() ); + new TestCase( SECTION, DateString+".getSeconds()", ResultArray[SECONDS], DateCase.getSeconds() ); + new TestCase( SECTION, DateString+".getMilliseconds()", ResultArray[MS], DateCase.getMilliseconds() ); +} diff --git a/tests/auto/qml/parserstress/tests/ecma/Date/15.9.3.1-4.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.3.1-4.js new file mode 100644 index 0000000000..5f95a5b797 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.3.1-4.js @@ -0,0 +1,151 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.9.3.1-4.js'; + +/** + File Name: 15.9.3.1.js + ECMA Section: 15.9.3.1 new Date (year, month, date, hours, minutes, seconds, ms) + Description: The [[Prototype]] property of the newly constructed + object is set to the original Date prototype object, + the one that is the initial value of Date.prototype. + + The [[Class]] property of the newly constructed object + is set as follows: + 1. Call ToNumber(year) + 2. Call ToNumber(month) + 3. Call ToNumber(date) + 4. Call ToNumber(hours) + 5. Call ToNumber(minutes) + 6. Call ToNumber(seconds) + 7. Call ToNumber(ms) + 8. If Result(1) is NaN and 0 <= ToInteger(Result(1)) <= + 99, Result(8) is 1900+ToInteger(Result(1)); otherwise, + Result(8) is Result(1) + 9. Compute MakeDay(Result(8), Result(2), Result(3) + 10. Compute MakeTime(Result(4), Result(5), Result(6), + Result(7) + 11. Compute MakeDate(Result(9), Result(10)) + 12. Set the [[Value]] property of the newly constructed + object to TimeClip(UTC(Result(11))). + + + This tests the returned value of a newly constructed + Date object. + + Author: christine@netscape.com + Date: 7 july 1997 +*/ + +var SECTION = "15.9.3.1"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "new Date( year, month, date, hours, minutes, seconds, ms )"; + +var TIME = 0; +var UTC_YEAR = 1; +var UTC_MONTH = 2; +var UTC_DATE = 3; +var UTC_DAY = 4; +var UTC_HOURS = 5; +var UTC_MINUTES = 6; +var UTC_SECONDS = 7; +var UTC_MS = 8; + +var YEAR = 9; +var MONTH = 10; +var DATE = 11; +var DAY = 12; +var HOURS = 13; +var MINUTES = 14; +var SECONDS = 15; +var MS = 16; + +writeHeaderToLog( SECTION + " "+ TITLE); + +// all the "ResultArrays" below are hard-coded to Pacific Standard Time values - + +// Dates around 1900 + +addNewTestCase( new Date(1899,11,31,16,0,0,0), + "new Date(1899,11,31,16,0,0,0)", + [TIME_1900,1900,0,1,1,0,0,0,0,1899,11,31,0,16,0,0,0] ); + +addNewTestCase( new Date(1899,11,31,15,59,59,999), + "new Date(1899,11,31,15,59,59,999)", + [TIME_1900-1,1899,11,31,0,23,59,59,999,1899,11,31,0,15,59,59,999] ); + +addNewTestCase( new Date(1899,11,31,23,59,59,999), + "new Date(1899,11,31,23,59,59,999)", + [TIME_1900-PST_ADJUST-1,1900,0,1,1,7,59,59,999,1899,11,31,0,23,59,59,999] ); + +addNewTestCase( new Date(1900,0,1,0,0,0,0), + "new Date(1900,0,1,0,0,0,0)", + [TIME_1900-PST_ADJUST,1900,0,1,1,8,0,0,0,1900,0,1,1,0,0,0,0] ); + +addNewTestCase( new Date(1900,0,1,0,0,0,1), + "new Date(1900,0,1,0,0,0,1)", + [TIME_1900-PST_ADJUST+1,1900,0,1,1,8,0,0,1,1900,0,1,1,0,0,0,1] ); + +test(); + +function addNewTestCase( DateCase, DateString, ResultArray ) { + //adjust hard-coded ResultArray for tester's timezone instead of PST + adjustResultArray(ResultArray); + + new TestCase( SECTION, DateString+".getTime()", ResultArray[TIME], DateCase.getTime() ); + new TestCase( SECTION, DateString+".valueOf()", ResultArray[TIME], DateCase.valueOf() ); + + new TestCase( SECTION, DateString+".getUTCFullYear()", ResultArray[UTC_YEAR], DateCase.getUTCFullYear() ); + new TestCase( SECTION, DateString+".getUTCMonth()", ResultArray[UTC_MONTH], DateCase.getUTCMonth() ); + new TestCase( SECTION, DateString+".getUTCDate()", ResultArray[UTC_DATE], DateCase.getUTCDate() ); + new TestCase( SECTION, DateString+".getUTCDay()", ResultArray[UTC_DAY], DateCase.getUTCDay() ); + new TestCase( SECTION, DateString+".getUTCHours()", ResultArray[UTC_HOURS], DateCase.getUTCHours() ); + new TestCase( SECTION, DateString+".getUTCMinutes()", ResultArray[UTC_MINUTES],DateCase.getUTCMinutes() ); + new TestCase( SECTION, DateString+".getUTCSeconds()", ResultArray[UTC_SECONDS],DateCase.getUTCSeconds() ); + new TestCase( SECTION, DateString+".getUTCMilliseconds()", ResultArray[UTC_MS], DateCase.getUTCMilliseconds() ); + + new TestCase( SECTION, DateString+".getFullYear()", ResultArray[YEAR], DateCase.getFullYear() ); + new TestCase( SECTION, DateString+".getMonth()", ResultArray[MONTH], DateCase.getMonth() ); + new TestCase( SECTION, DateString+".getDate()", ResultArray[DATE], DateCase.getDate() ); + new TestCase( SECTION, DateString+".getDay()", ResultArray[DAY], DateCase.getDay() ); + new TestCase( SECTION, DateString+".getHours()", ResultArray[HOURS], DateCase.getHours() ); + new TestCase( SECTION, DateString+".getMinutes()", ResultArray[MINUTES], DateCase.getMinutes() ); + new TestCase( SECTION, DateString+".getSeconds()", ResultArray[SECONDS], DateCase.getSeconds() ); + new TestCase( SECTION, DateString+".getMilliseconds()", ResultArray[MS], DateCase.getMilliseconds() ); +} diff --git a/tests/auto/qml/parserstress/tests/ecma/Date/15.9.3.1-5.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.3.1-5.js new file mode 100644 index 0000000000..f37c1c8da2 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.3.1-5.js @@ -0,0 +1,140 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.9.3.1-5.js'; + +/** + File Name: 15.9.3.1.js + ECMA Section: 15.9.3.1 new Date (year, month, date, hours, minutes, seconds, ms) + Description: The [[Prototype]] property of the newly constructed + object is set to the original Date prototype object, + the one that is the initial value of Date.prototype. + + The [[Class]] property of the newly constructed object + is set as follows: + 1. Call ToNumber(year) + 2. Call ToNumber(month) + 3. Call ToNumber(date) + 4. Call ToNumber(hours) + 5. Call ToNumber(minutes) + 6. Call ToNumber(seconds) + 7. Call ToNumber(ms) + 8. If Result(1) is NaN and 0 <= ToInteger(Result(1)) <= + 99, Result(8) is 1900+ToInteger(Result(1)); otherwise, + Result(8) is Result(1) + 9. Compute MakeDay(Result(8), Result(2), Result(3) + 10. Compute MakeTime(Result(4), Result(5), Result(6), + Result(7) + 11. Compute MakeDate(Result(9), Result(10)) + 12. Set the [[Value]] property of the newly constructed + object to TimeClip(UTC(Result(11))). + + + This tests the returned value of a newly constructed + Date object. + + Author: christine@netscape.com + Date: 7 july 1997 +*/ + +var SECTION = "15.9.3.1"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "new Date( year, month, date, hours, minutes, seconds, ms )"; + +var TIME = 0; +var UTC_YEAR = 1; +var UTC_MONTH = 2; +var UTC_DATE = 3; +var UTC_DAY = 4; +var UTC_HOURS = 5; +var UTC_MINUTES = 6; +var UTC_SECONDS = 7; +var UTC_MS = 8; + +var YEAR = 9; +var MONTH = 10; +var DATE = 11; +var DAY = 12; +var HOURS = 13; +var MINUTES = 14; +var SECONDS = 15; +var MS = 16; + +writeHeaderToLog( SECTION + " "+ TITLE); + +// all the "ResultArrays" below are hard-coded to Pacific Standard Time values - + +// Dates around 2005 + +addNewTestCase( new Date(2005,0,1,0,0,0,0), + "new Date(2005,0,1,0,0,0,0)", + [UTC_JAN_1_2005-PST_ADJUST,2005,0,1,6,8,0,0,0,2005,0,1,6,0,0,0,0] ); + +addNewTestCase( new Date(2004,11,31,16,0,0,0), + "new Date(2004,11,31,16,0,0,0)", + [UTC_JAN_1_2005,2005,0,1,6,0,0,0,0,2004,11,31,5,16,0,0,0] ); + +test(); + +function addNewTestCase( DateCase, DateString, ResultArray ) { + //adjust hard-coded ResultArray for tester's timezone instead of PST + adjustResultArray(ResultArray); + + new TestCase( SECTION, DateString+".getTime()", ResultArray[TIME], DateCase.getTime() ); + new TestCase( SECTION, DateString+".valueOf()", ResultArray[TIME], DateCase.valueOf() ); + + new TestCase( SECTION, DateString+".getUTCFullYear()", ResultArray[UTC_YEAR], DateCase.getUTCFullYear() ); + new TestCase( SECTION, DateString+".getUTCMonth()", ResultArray[UTC_MONTH], DateCase.getUTCMonth() ); + new TestCase( SECTION, DateString+".getUTCDate()", ResultArray[UTC_DATE], DateCase.getUTCDate() ); + new TestCase( SECTION, DateString+".getUTCDay()", ResultArray[UTC_DAY], DateCase.getUTCDay() ); + new TestCase( SECTION, DateString+".getUTCHours()", ResultArray[UTC_HOURS], DateCase.getUTCHours() ); + new TestCase( SECTION, DateString+".getUTCMinutes()", ResultArray[UTC_MINUTES],DateCase.getUTCMinutes() ); + new TestCase( SECTION, DateString+".getUTCSeconds()", ResultArray[UTC_SECONDS],DateCase.getUTCSeconds() ); + new TestCase( SECTION, DateString+".getUTCMilliseconds()", ResultArray[UTC_MS], DateCase.getUTCMilliseconds() ); + + new TestCase( SECTION, DateString+".getFullYear()", ResultArray[YEAR], DateCase.getFullYear() ); + new TestCase( SECTION, DateString+".getMonth()", ResultArray[MONTH], DateCase.getMonth() ); + new TestCase( SECTION, DateString+".getDate()", ResultArray[DATE], DateCase.getDate() ); + new TestCase( SECTION, DateString+".getDay()", ResultArray[DAY], DateCase.getDay() ); + new TestCase( SECTION, DateString+".getHours()", ResultArray[HOURS], DateCase.getHours() ); + new TestCase( SECTION, DateString+".getMinutes()", ResultArray[MINUTES], DateCase.getMinutes() ); + new TestCase( SECTION, DateString+".getSeconds()", ResultArray[SECONDS], DateCase.getSeconds() ); + new TestCase( SECTION, DateString+".getMilliseconds()", ResultArray[MS], DateCase.getMilliseconds() ); +} + diff --git a/tests/auto/qml/parserstress/tests/ecma/Date/15.9.3.2-1.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.3.2-1.js new file mode 100644 index 0000000000..ae0502be64 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.3.2-1.js @@ -0,0 +1,151 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.9.3.2-1.js'; + +/** + File Name: 15.9.3.1.js + ECMA Section: 15.9.3.1 new Date (year, month, date, hours, minutes, seconds, ms) + Description: The [[Prototype]] property of the newly constructed + object is set to the original Date prototype object, + the one that is the initial value of Date.prototype. + + The [[Class]] property of the newly constructed object + is set as follows: + 1. Call ToNumber(year) + 2. Call ToNumber(month) + 3. Call ToNumber(date) + 4. Call ToNumber(hours) + 5. Call ToNumber(minutes) + 6. Call ToNumber(seconds) + 7. Call ToNumber(ms) + 8. If Result(1)is NaN and 0 <= ToInteger(Result(1)) <= + 99, Result(8) is 1900+ToInteger(Result(1)); otherwise, + Result(8) is Result(1) + 9. Compute MakeDay(Result(8), Result(2), Result(3) + 10. Compute MakeTime(Result(4), Result(5), Result(6), + Result(7) + 11. Compute MakeDate(Result(9), Result(10)) + 12. Set the [[Value]] property of the newly constructed + object to TimeClip(UTC(Result(11))). + + + This tests the returned value of a newly constructed + Date object. + + Author: christine@netscape.com + Date: 7 july 1997 +*/ + +var TIME = 0; +var UTC_YEAR = 1; +var UTC_MONTH = 2; +var UTC_DATE = 3; +var UTC_DAY = 4; +var UTC_HOURS = 5; +var UTC_MINUTES = 6; +var UTC_SECONDS = 7; +var UTC_MS = 8; + +var YEAR = 9; +var MONTH = 10; +var DATE = 11; +var DAY = 12; +var HOURS = 13; +var MINUTES = 14; +var SECONDS = 15; +var MS = 16; + +// for TCMS, the gTestcases array must be global. +var SECTION = "15.9.3.1"; +var TITLE = "Date( year, month, date, hours, minutes, seconds )"; +startTest(); + +writeHeaderToLog( SECTION+" " +TITLE ); + +// Dates around 1970 + +addNewTestCase( new Date( 1969,11,31,15,59,59), + "new Date( 1969,11,31,15,59,59)", + [-1000,1969,11,31,3,23,59,59,0,1969,11,31,3,15,59,59,0] ); + +addNewTestCase( new Date( 1969,11,31,16,0,0), + "new Date( 1969,11,31,16,0,0)", + [0,1970,0,1,4,0,0,0,0,1969,11,31,3,16,0,0,0] ); + +addNewTestCase( new Date( 1969,11,31,23,59,59), + "new Date( 1969,11,31,23,59,59)", + [28799000,1970,0,1,4,7,59,59,0,1969,11,31,3,23,59,59,0] ); + +addNewTestCase( new Date( 1970, 0, 1, 0, 0, 0), + "new Date( 1970, 0, 1, 0, 0, 0)", + [28800000,1970,0,1,4,8,0,0,0,1970,0,1,4,0,0,0,0] ); + +addNewTestCase( new Date( 1969,11,31,16,0,0), + "new Date( 1969,11,31,16,0,0)", + [0,1970,0,1,4,0,0,0,0,1969,11,31,3,16,0,0,0] ); + +test(); + +function addNewTestCase( DateCase, DateString, ResultArray ) { + //adjust hard-coded ResultArray for tester's timezone instead of PST + adjustResultArray(ResultArray); + + + new TestCase( SECTION, DateString+".getTime()", ResultArray[TIME], DateCase.getTime() ); + new TestCase( SECTION, DateString+".valueOf()", ResultArray[TIME], DateCase.valueOf() ); + + new TestCase( SECTION, DateString+".getUTCFullYear()", ResultArray[UTC_YEAR], DateCase.getUTCFullYear() ); + new TestCase( SECTION, DateString+".getUTCMonth()", ResultArray[UTC_MONTH], DateCase.getUTCMonth() ); + new TestCase( SECTION, DateString+".getUTCDate()", ResultArray[UTC_DATE], DateCase.getUTCDate() ); + new TestCase( SECTION, DateString+".getUTCDay()", ResultArray[UTC_DAY], DateCase.getUTCDay() ); + new TestCase( SECTION, DateString+".getUTCHours()", ResultArray[UTC_HOURS], DateCase.getUTCHours() ); + new TestCase( SECTION, DateString+".getUTCMinutes()", ResultArray[UTC_MINUTES],DateCase.getUTCMinutes() ); + new TestCase( SECTION, DateString+".getUTCSeconds()", ResultArray[UTC_SECONDS],DateCase.getUTCSeconds() ); + new TestCase( SECTION, DateString+".getUTCMilliseconds()", ResultArray[UTC_MS], DateCase.getUTCMilliseconds() ); + + new TestCase( SECTION, DateString+".getFullYear()", ResultArray[YEAR], DateCase.getFullYear() ); + new TestCase( SECTION, DateString+".getMonth()", ResultArray[MONTH], DateCase.getMonth() ); + new TestCase( SECTION, DateString+".getDate()", ResultArray[DATE], DateCase.getDate() ); + new TestCase( SECTION, DateString+".getDay()", ResultArray[DAY], DateCase.getDay() ); + new TestCase( SECTION, DateString+".getHours()", ResultArray[HOURS], DateCase.getHours() ); + new TestCase( SECTION, DateString+".getMinutes()", ResultArray[MINUTES], DateCase.getMinutes() ); + new TestCase( SECTION, DateString+".getSeconds()", ResultArray[SECONDS], DateCase.getSeconds() ); + new TestCase( SECTION, DateString+".getMilliseconds()", ResultArray[MS], DateCase.getMilliseconds() ); + +} diff --git a/tests/auto/qml/parserstress/tests/ecma/Date/15.9.3.2-2.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.3.2-2.js new file mode 100644 index 0000000000..acc2ac7f0b --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.3.2-2.js @@ -0,0 +1,142 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.9.3.2-2.js'; + +/** + File Name: 15.9.3.1.js + ECMA Section: 15.9.3.1 new Date (year, month, date, hours, minutes, seconds, ms) + Description: The [[Prototype]] property of the newly constructed + object is set to the original Date prototype object, + the one that is the initial value of Date.prototype. + + The [[Class]] property of the newly constructed object + is set as follows: + 1. Call ToNumber(year) + 2. Call ToNumber(month) + 3. Call ToNumber(date) + 4. Call ToNumber(hours) + 5. Call ToNumber(minutes) + 6. Call ToNumber(seconds) + 7. Call ToNumber(ms) + 8. If Result(1)is NaN and 0 <= ToInteger(Result(1)) <= + 99, Result(8) is 1900+ToInteger(Result(1)); otherwise, + Result(8) is Result(1) + 9. Compute MakeDay(Result(8), Result(2), Result(3) + 10. Compute MakeTime(Result(4), Result(5), Result(6), + Result(7) + 11. Compute MakeDate(Result(9), Result(10)) + 12. Set the [[Value]] property of the newly constructed + object to TimeClip(UTC(Result(11))). + + + This tests the returned value of a newly constructed + Date object. + + Author: christine@netscape.com + Date: 7 july 1997 +*/ + +var TIME = 0; +var UTC_YEAR = 1; +var UTC_MONTH = 2; +var UTC_DATE = 3; +var UTC_DAY = 4; +var UTC_HOURS = 5; +var UTC_MINUTES = 6; +var UTC_SECONDS = 7; +var UTC_MS = 8; + +var YEAR = 9; +var MONTH = 10; +var DATE = 11; +var DAY = 12; +var HOURS = 13; +var MINUTES = 14; +var SECONDS = 15; +var MS = 16; + +// for TCMS, the gTestcases array must be global. +var SECTION = "15.9.3.1"; +var TITLE = "Date( year, month, date, hours, minutes, seconds )"; +startTest(); + +writeHeaderToLog( SECTION+" " +TITLE ); + +// Dates around 2000 + +addNewTestCase( new Date( 1999,11,31,15,59,59), + "new Date( 1999,11,31,15,59,59)", + [946684799000,1999,11,31,5,23,59,59,0,1999,11,31,5,15,59,59,0] ); + +addNewTestCase( new Date( 1999,11,31,16,0,0), + "new Date( 1999,11,31,16,0,0)", + [946684800000,2000,0,1,6,0,0,0,0,1999,11,31,5, 16,0,0,0] ); + +addNewTestCase( new Date( 2000,0,1,0,0,0), + "new Date( 2000,0,1,0,0,0)", + [946713600000,2000,0,1,6,8,0,0,0,2000,0,1,6,0,0,0,0] ); + +test(); + +function addNewTestCase( DateCase, DateString, ResultArray ) { + //adjust hard-coded ResultArray for tester's timezone instead of PST + adjustResultArray(ResultArray); + + new TestCase( SECTION, DateString+".getTime()", ResultArray[TIME], DateCase.getTime() ); + new TestCase( SECTION, DateString+".valueOf()", ResultArray[TIME], DateCase.valueOf() ); + + new TestCase( SECTION, DateString+".getUTCFullYear()", ResultArray[UTC_YEAR], DateCase.getUTCFullYear() ); + new TestCase( SECTION, DateString+".getUTCMonth()", ResultArray[UTC_MONTH], DateCase.getUTCMonth() ); + new TestCase( SECTION, DateString+".getUTCDate()", ResultArray[UTC_DATE], DateCase.getUTCDate() ); + new TestCase( SECTION, DateString+".getUTCDay()", ResultArray[UTC_DAY], DateCase.getUTCDay() ); + new TestCase( SECTION, DateString+".getUTCHours()", ResultArray[UTC_HOURS], DateCase.getUTCHours() ); + new TestCase( SECTION, DateString+".getUTCMinutes()", ResultArray[UTC_MINUTES],DateCase.getUTCMinutes() ); + new TestCase( SECTION, DateString+".getUTCSeconds()", ResultArray[UTC_SECONDS],DateCase.getUTCSeconds() ); + new TestCase( SECTION, DateString+".getUTCMilliseconds()", ResultArray[UTC_MS], DateCase.getUTCMilliseconds() ); + + new TestCase( SECTION, DateString+".getFullYear()", ResultArray[YEAR], DateCase.getFullYear() ); + new TestCase( SECTION, DateString+".getMonth()", ResultArray[MONTH], DateCase.getMonth() ); + new TestCase( SECTION, DateString+".getDate()", ResultArray[DATE], DateCase.getDate() ); + new TestCase( SECTION, DateString+".getDay()", ResultArray[DAY], DateCase.getDay() ); + new TestCase( SECTION, DateString+".getHours()", ResultArray[HOURS], DateCase.getHours() ); + new TestCase( SECTION, DateString+".getMinutes()", ResultArray[MINUTES], DateCase.getMinutes() ); + new TestCase( SECTION, DateString+".getSeconds()", ResultArray[SECONDS], DateCase.getSeconds() ); + new TestCase( SECTION, DateString+".getMilliseconds()", ResultArray[MS], DateCase.getMilliseconds() ); + +} diff --git a/tests/auto/qml/parserstress/tests/ecma/Date/15.9.3.2-3.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.3.2-3.js new file mode 100644 index 0000000000..d4b48fed35 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.3.2-3.js @@ -0,0 +1,146 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.9.3.2-3.js'; + +/** + File Name: 15.9.3.1.js + ECMA Section: 15.9.3.1 new Date (year, month, date, hours, minutes, seconds, ms) + Description: The [[Prototype]] property of the newly constructed + object is set to the original Date prototype object, + the one that is the initial value of Date.prototype. + + The [[Class]] property of the newly constructed object + is set as follows: + 1. Call ToNumber(year) + 2. Call ToNumber(month) + 3. Call ToNumber(date) + 4. Call ToNumber(hours) + 5. Call ToNumber(minutes) + 6. Call ToNumber(seconds) + 7. Call ToNumber(ms) + 8. If Result(1)is NaN and 0 <= ToInteger(Result(1)) <= + 99, Result(8) is 1900+ToInteger(Result(1)); otherwise, + Result(8) is Result(1) + 9. Compute MakeDay(Result(8), Result(2), Result(3) + 10. Compute MakeTime(Result(4), Result(5), Result(6), + Result(7) + 11. Compute MakeDate(Result(9), Result(10)) + 12. Set the [[Value]] property of the newly constructed + object to TimeClip(UTC(Result(11))). + + + This tests the returned value of a newly constructed + Date object. + + Author: christine@netscape.com + Date: 7 july 1997 +*/ + +var TIME = 0; +var UTC_YEAR = 1; +var UTC_MONTH = 2; +var UTC_DATE = 3; +var UTC_DAY = 4; +var UTC_HOURS = 5; +var UTC_MINUTES = 6; +var UTC_SECONDS = 7; +var UTC_MS = 8; + +var YEAR = 9; +var MONTH = 10; +var DATE = 11; +var DAY = 12; +var HOURS = 13; +var MINUTES = 14; +var SECONDS = 15; +var MS = 16; + +// for TCMS, the gTestcases array must be global. +var SECTION = "15.9.3.1"; +var TITLE = "Date( year, month, date, hours, minutes, seconds )"; +startTest(); + +writeHeaderToLog( SECTION+" " +TITLE ); + +// Dates around 1900 + +addNewTestCase( new Date(1899,11,31,16,0,0), + "new Date(1899,11,31,16,0,0)", + [-2208988800000,1900,0,1,1,0,0,0,0,1899,11,31,0,16,0,0,0] ); + +addNewTestCase( new Date(1899,11,31,15,59,59), + "new Date(1899,11,31,15,59,59)", + [-2208988801000,1899,11,31,0,23,59,59,0,1899,11,31,0,15,59,59,0] ); + +addNewTestCase( new Date(1900,0,1,0,0,0), + "new Date(1900,0,1,0,0,0)", + [-2208960000000,1900,0,1,1,8,0,0,0,1900,0,1,1,0,0,0,0] ); + +addNewTestCase( new Date(1900,0,1,0,0,1), + "new Date(1900,0,1,0,0,1)", + [-2208959999000,1900,0,1,1,8,0,1,0,1900,0,1,1,0,0,1,0] ); + +test(); + +function addNewTestCase( DateCase, DateString, ResultArray ) { + //adjust hard-coded ResultArray for tester's timezone instead of PST + adjustResultArray(ResultArray); + + new TestCase( SECTION, DateString+".getTime()", ResultArray[TIME], DateCase.getTime() ); + new TestCase( SECTION, DateString+".valueOf()", ResultArray[TIME], DateCase.valueOf() ); + + new TestCase( SECTION, DateString+".getUTCFullYear()", ResultArray[UTC_YEAR], DateCase.getUTCFullYear() ); + new TestCase( SECTION, DateString+".getUTCMonth()", ResultArray[UTC_MONTH], DateCase.getUTCMonth() ); + new TestCase( SECTION, DateString+".getUTCDate()", ResultArray[UTC_DATE], DateCase.getUTCDate() ); + new TestCase( SECTION, DateString+".getUTCDay()", ResultArray[UTC_DAY], DateCase.getUTCDay() ); + new TestCase( SECTION, DateString+".getUTCHours()", ResultArray[UTC_HOURS], DateCase.getUTCHours() ); + new TestCase( SECTION, DateString+".getUTCMinutes()", ResultArray[UTC_MINUTES],DateCase.getUTCMinutes() ); + new TestCase( SECTION, DateString+".getUTCSeconds()", ResultArray[UTC_SECONDS],DateCase.getUTCSeconds() ); + new TestCase( SECTION, DateString+".getUTCMilliseconds()", ResultArray[UTC_MS], DateCase.getUTCMilliseconds() ); + + new TestCase( SECTION, DateString+".getFullYear()", ResultArray[YEAR], DateCase.getFullYear() ); + new TestCase( SECTION, DateString+".getMonth()", ResultArray[MONTH], DateCase.getMonth() ); + new TestCase( SECTION, DateString+".getDate()", ResultArray[DATE], DateCase.getDate() ); + new TestCase( SECTION, DateString+".getDay()", ResultArray[DAY], DateCase.getDay() ); + new TestCase( SECTION, DateString+".getHours()", ResultArray[HOURS], DateCase.getHours() ); + new TestCase( SECTION, DateString+".getMinutes()", ResultArray[MINUTES], DateCase.getMinutes() ); + new TestCase( SECTION, DateString+".getSeconds()", ResultArray[SECONDS], DateCase.getSeconds() ); + new TestCase( SECTION, DateString+".getMilliseconds()", ResultArray[MS], DateCase.getMilliseconds() ); + +} diff --git a/tests/auto/qml/parserstress/tests/ecma/Date/15.9.3.2-4.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.3.2-4.js new file mode 100644 index 0000000000..1b2757cd9a --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.3.2-4.js @@ -0,0 +1,143 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.9.3.2-4.js'; + +/** + File Name: 15.9.3.1.js + ECMA Section: 15.9.3.1 new Date (year, month, date, hours, minutes, seconds, ms) + Description: The [[Prototype]] property of the newly constructed + object is set to the original Date prototype object, + the one that is the initial value of Date.prototype. + + The [[Class]] property of the newly constructed object + is set as follows: + 1. Call ToNumber(year) + 2. Call ToNumber(month) + 3. Call ToNumber(date) + 4. Call ToNumber(hours) + 5. Call ToNumber(minutes) + 6. Call ToNumber(seconds) + 7. Call ToNumber(ms) + 8. If Result(1)is NaN and 0 <= ToInteger(Result(1)) <= + 99, Result(8) is 1900+ToInteger(Result(1)); otherwise, + Result(8) is Result(1) + 9. Compute MakeDay(Result(8), Result(2), Result(3) + 10. Compute MakeTime(Result(4), Result(5), Result(6), + Result(7) + 11. Compute MakeDate(Result(9), Result(10)) + 12. Set the [[Value]] property of the newly constructed + object to TimeClip(UTC(Result(11))). + + + This tests the returned value of a newly constructed + Date object. + + Author: christine@netscape.com + Date: 7 july 1997 +*/ + +var TIME = 0; +var UTC_YEAR = 1; +var UTC_MONTH = 2; +var UTC_DATE = 3; +var UTC_DAY = 4; +var UTC_HOURS = 5; +var UTC_MINUTES = 6; +var UTC_SECONDS = 7; +var UTC_MS = 8; + +var YEAR = 9; +var MONTH = 10; +var DATE = 11; +var DAY = 12; +var HOURS = 13; +var MINUTES = 14; +var SECONDS = 15; +var MS = 16; + +// for TCMS, the gTestcases array must be global. +var SECTION = "15.9.3.1"; +var TITLE = "Date( year, month, date, hours, minutes, seconds )"; +startTest(); + +writeHeaderToLog( SECTION+" " +TITLE ); + +var PST_FEB_29_2000 = UTC_FEB_29_2000 + 8*msPerHour; + +// Dates around Feb 29, 2000 +addNewTestCase( new Date(2000,1,28,16,0,0,0), + "new Date(2000,1,28,16,0,0,0)", + [UTC_FEB_29_2000,2000,1,29,2,0,0,0,0,2000,1,28,1,16,0,0,0,0] ); + +addNewTestCase( new Date(2000,1,29,0,0,0,0), + "new Date(2000,1,29,0,0,0,0)", + [PST_FEB_29_2000,2000,1,29,2,8,0,0,0,2000,1,29,2,0,0,0,0] ); + +addNewTestCase( new Date(2000,1,29,24,0,0,0), + "new Date(2000,1,29,24,0,0,0)", + [PST_FEB_29_2000+msPerDay,2000,2,1,3,8,0,0,0,2000,2,1,3,0,0,0,0] ); + +test(); + +function addNewTestCase( DateCase, DateString, ResultArray ) { + //adjust hard-coded ResultArray for tester's timezone instead of PST + adjustResultArray(ResultArray); + + new TestCase( SECTION, DateString+".getTime()", ResultArray[TIME], DateCase.getTime() ); + new TestCase( SECTION, DateString+".valueOf()", ResultArray[TIME], DateCase.valueOf() ); + + new TestCase( SECTION, DateString+".getUTCFullYear()", ResultArray[UTC_YEAR], DateCase.getUTCFullYear() ); + new TestCase( SECTION, DateString+".getUTCMonth()", ResultArray[UTC_MONTH], DateCase.getUTCMonth() ); + new TestCase( SECTION, DateString+".getUTCDate()", ResultArray[UTC_DATE], DateCase.getUTCDate() ); + new TestCase( SECTION, DateString+".getUTCDay()", ResultArray[UTC_DAY], DateCase.getUTCDay() ); + new TestCase( SECTION, DateString+".getUTCHours()", ResultArray[UTC_HOURS], DateCase.getUTCHours() ); + new TestCase( SECTION, DateString+".getUTCMinutes()", ResultArray[UTC_MINUTES],DateCase.getUTCMinutes() ); + new TestCase( SECTION, DateString+".getUTCSeconds()", ResultArray[UTC_SECONDS],DateCase.getUTCSeconds() ); + new TestCase( SECTION, DateString+".getUTCMilliseconds()", ResultArray[UTC_MS], DateCase.getUTCMilliseconds() ); + + new TestCase( SECTION, DateString+".getFullYear()", ResultArray[YEAR], DateCase.getFullYear() ); + new TestCase( SECTION, DateString+".getMonth()", ResultArray[MONTH], DateCase.getMonth() ); + new TestCase( SECTION, DateString+".getDate()", ResultArray[DATE], DateCase.getDate() ); + new TestCase( SECTION, DateString+".getDay()", ResultArray[DAY], DateCase.getDay() ); + new TestCase( SECTION, DateString+".getHours()", ResultArray[HOURS], DateCase.getHours() ); + new TestCase( SECTION, DateString+".getMinutes()", ResultArray[MINUTES], DateCase.getMinutes() ); + new TestCase( SECTION, DateString+".getSeconds()", ResultArray[SECONDS], DateCase.getSeconds() ); + new TestCase( SECTION, DateString+".getMilliseconds()", ResultArray[MS], DateCase.getMilliseconds() ); + +} diff --git a/tests/auto/qml/parserstress/tests/ecma/Date/15.9.3.2-5.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.3.2-5.js new file mode 100644 index 0000000000..09d6272c6f --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.3.2-5.js @@ -0,0 +1,140 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.9.3.2-5.js'; + +/** + File Name: 15.9.3.1.js + ECMA Section: 15.9.3.1 new Date (year, month, date, hours, minutes, seconds, ms) + Description: The [[Prototype]] property of the newly constructed + object is set to the original Date prototype object, + the one that is the initial value of Date.prototype. + + The [[Class]] property of the newly constructed object + is set as follows: + 1. Call ToNumber(year) + 2. Call ToNumber(month) + 3. Call ToNumber(date) + 4. Call ToNumber(hours) + 5. Call ToNumber(minutes) + 6. Call ToNumber(seconds) + 7. Call ToNumber(ms) + 8. If Result(1)is NaN and 0 <= ToInteger(Result(1)) <= + 99, Result(8) is 1900+ToInteger(Result(1)); otherwise, + Result(8) is Result(1) + 9. Compute MakeDay(Result(8), Result(2), Result(3) + 10. Compute MakeTime(Result(4), Result(5), Result(6), + Result(7) + 11. Compute MakeDate(Result(9), Result(10)) + 12. Set the [[Value]] property of the newly constructed + object to TimeClip(UTC(Result(11))). + + + This tests the returned value of a newly constructed + Date object. + + Author: christine@netscape.com + Date: 7 july 1997 +*/ + +var TIME = 0; +var UTC_YEAR = 1; +var UTC_MONTH = 2; +var UTC_DATE = 3; +var UTC_DAY = 4; +var UTC_HOURS = 5; +var UTC_MINUTES = 6; +var UTC_SECONDS = 7; +var UTC_MS = 8; + +var YEAR = 9; +var MONTH = 10; +var DATE = 11; +var DAY = 12; +var HOURS = 13; +var MINUTES = 14; +var SECONDS = 15; +var MS = 16; + +// for TCMS, the gTestcases array must be global. +var SECTION = "15.9.3.1"; +var TITLE = "Date( year, month, date, hours, minutes, seconds )"; +startTest(); + +writeHeaderToLog( SECTION+" " +TITLE ); + +// Dates around Jan 1, 2005 + +var PST_JAN_1_2005 = UTC_JAN_1_2005 + 8*msPerHour; + +addNewTestCase( new Date(2005,0,1,0,0,0,0), + "new Date(2005,0,1,0,0,0,0)", + [PST_JAN_1_2005,2005,0,1,6,8,0,0,0,2005,0,1,6,0,0,0,0] ); + +addNewTestCase( new Date(2004,11,31,16,0,0,0), + "new Date(2004,11,31,16,0,0,0)", + [UTC_JAN_1_2005,2005,0,1,6,0,0,0,0,2004,11,31,5,16,0,0,0] ); + +test(); + +function addNewTestCase( DateCase, DateString, ResultArray ) { +//adjust hard-coded ResultArray for tester's timezone instead of PST + adjustResultArray(ResultArray); + + new TestCase( SECTION, DateString+".getTime()", ResultArray[TIME], DateCase.getTime() ); + new TestCase( SECTION, DateString+".valueOf()", ResultArray[TIME], DateCase.valueOf() ); + + new TestCase( SECTION, DateString+".getUTCFullYear()", ResultArray[UTC_YEAR], DateCase.getUTCFullYear() ); + new TestCase( SECTION, DateString+".getUTCMonth()", ResultArray[UTC_MONTH], DateCase.getUTCMonth() ); + new TestCase( SECTION, DateString+".getUTCDate()", ResultArray[UTC_DATE], DateCase.getUTCDate() ); + new TestCase( SECTION, DateString+".getUTCDay()", ResultArray[UTC_DAY], DateCase.getUTCDay() ); + new TestCase( SECTION, DateString+".getUTCHours()", ResultArray[UTC_HOURS], DateCase.getUTCHours() ); + new TestCase( SECTION, DateString+".getUTCMinutes()", ResultArray[UTC_MINUTES],DateCase.getUTCMinutes() ); + new TestCase( SECTION, DateString+".getUTCSeconds()", ResultArray[UTC_SECONDS],DateCase.getUTCSeconds() ); + new TestCase( SECTION, DateString+".getUTCMilliseconds()", ResultArray[UTC_MS], DateCase.getUTCMilliseconds() ); + + new TestCase( SECTION, DateString+".getFullYear()", ResultArray[YEAR], DateCase.getFullYear() ); + new TestCase( SECTION, DateString+".getMonth()", ResultArray[MONTH], DateCase.getMonth() ); + new TestCase( SECTION, DateString+".getDate()", ResultArray[DATE], DateCase.getDate() ); + new TestCase( SECTION, DateString+".getDay()", ResultArray[DAY], DateCase.getDay() ); + new TestCase( SECTION, DateString+".getHours()", ResultArray[HOURS], DateCase.getHours() ); + new TestCase( SECTION, DateString+".getMinutes()", ResultArray[MINUTES], DateCase.getMinutes() ); + new TestCase( SECTION, DateString+".getSeconds()", ResultArray[SECONDS], DateCase.getSeconds() ); + new TestCase( SECTION, DateString+".getMilliseconds()", ResultArray[MS], DateCase.getMilliseconds() ); + +} diff --git a/tests/auto/qml/parserstress/tests/ecma/Date/15.9.3.8-1.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.3.8-1.js new file mode 100644 index 0000000000..d48199ccba --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.3.8-1.js @@ -0,0 +1,155 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.9.3.8-1.js'; + +/** + File Name: 15.9.3.8.js + ECMA Section: 15.9.3.8 The Date Constructor + new Date( value ) + Description: The [[Prototype]] property of the newly constructed + object is set to the original Date prototype object, + the one that is the initial valiue of Date.prototype. + + The [[Class]] property of the newly constructed object is + set to "Date". + + The [[Value]] property of the newly constructed object is + set as follows: + + 1. Call ToPrimitive(value) + 2. If Type( Result(1) ) is String, then go to step 5. + 3. Let V be ToNumber( Result(1) ). + 4. Set the [[Value]] property of the newly constructed + object to TimeClip(V) and return. + 5. Parse Result(1) as a date, in exactly the same manner + as for the parse method. Let V be the time value for + this date. + 6. Go to step 4. + + Author: christine@netscape.com + Date: 28 october 1997 + Version: 9706 + +*/ + +var VERSION = "ECMA_1"; +startTest(); +var SECTION = "15.9.3.8"; +var TYPEOF = "object"; + +var TIME = 0; +var UTC_YEAR = 1; +var UTC_MONTH = 2; +var UTC_DATE = 3; +var UTC_DAY = 4; +var UTC_HOURS = 5; +var UTC_MINUTES = 6; +var UTC_SECONDS = 7; +var UTC_MS = 8; + +var YEAR = 9; +var MONTH = 10; +var DATE = 11; +var DAY = 12; +var HOURS = 13; +var MINUTES = 14; +var SECONDS = 15; +var MS = 16; + + +// for TCMS, the gTestcases array must be global. +var gTc= 0; +var TITLE = "Date constructor: new Date( value )"; +var SECTION = "15.9.3.8"; +var VERSION = "ECMA_1"; +startTest(); + +writeHeaderToLog( SECTION +" " + TITLE ); + +// all the "ResultArrays" below are hard-coded to Pacific Standard Time values - +var TZ_ADJUST = -TZ_PST * msPerHour; + + +// Dates around 1970 +addNewTestCase( new Date(0), + "new Date(0)", + [0,1970,0,1,4,0,0,0,0,1969,11,31,3,16,0,0,0] ); + +addNewTestCase( new Date(1), + "new Date(1)", + [1,1970,0,1,4,0,0,0,1,1969,11,31,3,16,0,0,1] ); + +addNewTestCase( new Date(true), + "new Date(true)", + [1,1970,0,1,4,0,0,0,1,1969,11,31,3,16,0,0,1] ); + +addNewTestCase( new Date(false), + "new Date(false)", + [0,1970,0,1,4,0,0,0,0,1969,11,31,3,16,0,0,0] ); + +addNewTestCase( new Date( (new Date(0)).toString() ), + "new Date(\""+ (new Date(0)).toString()+"\" )", + [0,1970,0,1,4,0,0,0,0,1969,11,31,3,16,0,0,0] ); + +test(); + +function addNewTestCase( DateCase, DateString, ResultArray ) { + //adjust hard-coded ResultArray for tester's timezone instead of PST + adjustResultArray(ResultArray, 'msMode'); + + + new TestCase( SECTION, DateString+".getTime()", ResultArray[TIME], DateCase.getTime() ); + new TestCase( SECTION, DateString+".valueOf()", ResultArray[TIME], DateCase.valueOf() ); + new TestCase( SECTION, DateString+".getUTCFullYear()", ResultArray[UTC_YEAR], DateCase.getUTCFullYear() ); + new TestCase( SECTION, DateString+".getUTCMonth()", ResultArray[UTC_MONTH], DateCase.getUTCMonth() ); + new TestCase( SECTION, DateString+".getUTCDate()", ResultArray[UTC_DATE], DateCase.getUTCDate() ); + new TestCase( SECTION, DateString+".getUTCDay()", ResultArray[UTC_DAY], DateCase.getUTCDay() ); + new TestCase( SECTION, DateString+".getUTCHours()", ResultArray[UTC_HOURS], DateCase.getUTCHours() ); + new TestCase( SECTION, DateString+".getUTCMinutes()", ResultArray[UTC_MINUTES],DateCase.getUTCMinutes() ); + new TestCase( SECTION, DateString+".getUTCSeconds()", ResultArray[UTC_SECONDS],DateCase.getUTCSeconds() ); + new TestCase( SECTION, DateString+".getUTCMilliseconds()", ResultArray[UTC_MS], DateCase.getUTCMilliseconds() ); + new TestCase( SECTION, DateString+".getFullYear()", ResultArray[YEAR], DateCase.getFullYear() ); + new TestCase( SECTION, DateString+".getMonth()", ResultArray[MONTH], DateCase.getMonth() ); + new TestCase( SECTION, DateString+".getDate()", ResultArray[DATE], DateCase.getDate() ); + new TestCase( SECTION, DateString+".getDay()", ResultArray[DAY], DateCase.getDay() ); + new TestCase( SECTION, DateString+".getHours()", ResultArray[HOURS], DateCase.getHours() ); + new TestCase( SECTION, DateString+".getMinutes()", ResultArray[MINUTES], DateCase.getMinutes() ); + new TestCase( SECTION, DateString+".getSeconds()", ResultArray[SECONDS], DateCase.getSeconds() ); + new TestCase( SECTION, DateString+".getMilliseconds()", ResultArray[MS], DateCase.getMilliseconds() ); +} diff --git a/tests/auto/qml/parserstress/tests/ecma/Date/15.9.3.8-2.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.3.8-2.js new file mode 100644 index 0000000000..f9d8d36d04 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.3.8-2.js @@ -0,0 +1,153 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.9.3.8-2.js'; + +/** + File Name: 15.9.3.8.js + ECMA Section: 15.9.3.8 The Date Constructor + new Date( value ) + Description: The [[Prototype]] property of the newly constructed + object is set to the original Date prototype object, + the one that is the initial valiue of Date.prototype. + + The [[Class]] property of the newly constructed object is + set to "Date". + + The [[Value]] property of the newly constructed object is + set as follows: + + 1. Call ToPrimitive(value) + 2. If Type( Result(1) ) is String, then go to step 5. + 3. Let V be ToNumber( Result(1) ). + 4. Set the [[Value]] property of the newly constructed + object to TimeClip(V) and return. + 5. Parse Result(1) as a date, in exactly the same manner + as for the parse method. Let V be the time value for + this date. + 6. Go to step 4. + + Author: christine@netscape.com + Date: 28 october 1997 + Version: 9706 + +*/ + +var VERSION = "ECMA_1"; +startTest(); +var SECTION = "15.9.3.8"; +var TYPEOF = "object"; + +var TIME = 0; +var UTC_YEAR = 1; +var UTC_MONTH = 2; +var UTC_DATE = 3; +var UTC_DAY = 4; +var UTC_HOURS = 5; +var UTC_MINUTES = 6; +var UTC_SECONDS = 7; +var UTC_MS = 8; + +var YEAR = 9; +var MONTH = 10; +var DATE = 11; +var DAY = 12; +var HOURS = 13; +var MINUTES = 14; +var SECONDS = 15; +var MS = 16; + + +// for TCMS, the gTestcases array must be global. +var gTc= 0; +var TITLE = "Date constructor: new Date( value )"; +var SECTION = "15.9.3.8"; +var VERSION = "ECMA_1"; +startTest(); + +writeHeaderToLog( SECTION +" " + TITLE ); + +// all the "ResultArrays" below are hard-coded to Pacific Standard Time values - +var TZ_ADJUST = -TZ_PST * msPerHour; + +addNewTestCase( new Date((new Date(0)).toUTCString()), + "new Date(\""+ (new Date(0)).toUTCString()+"\" )", + [0,1970,0,1,4,0,0,0,0,1969,11,31,3,16,0,0,0] ); + +addNewTestCase( new Date((new Date(1)).toString()), + "new Date(\""+ (new Date(1)).toString()+"\" )", + [0,1970,0,1,4,0,0,0,0,1969,11,31,3,16,0,0,0] ); + +addNewTestCase( new Date( TZ_ADJUST ), + "new Date(" + TZ_ADJUST+")", + [TZ_ADJUST,1970,0,1,4,8,0,0,0,1970,0,1,4,0,0,0,0] ); + +addNewTestCase( new Date((new Date(TZ_ADJUST)).toString()), + "new Date(\""+ (new Date(TZ_ADJUST)).toString()+"\")", + [TZ_ADJUST,1970,0,1,4,8,0,0,0,1970,0,1,4,0,0,0,0] ); + + +addNewTestCase( new Date( (new Date(TZ_ADJUST)).toUTCString() ), + "new Date(\""+ (new Date(TZ_ADJUST)).toUTCString()+"\")", + [TZ_ADJUST,1970,0,1,4,8,0,0,0,1970,0,1,4,0,0,0,0] ); + +test(); + +function addNewTestCase( DateCase, DateString, ResultArray ) { + //adjust hard-coded ResultArray for tester's timezone instead of PST + adjustResultArray(ResultArray, 'msMode'); + + new TestCase( SECTION, DateString+".getTime()", ResultArray[TIME], DateCase.getTime() ); + new TestCase( SECTION, DateString+".valueOf()", ResultArray[TIME], DateCase.valueOf() ); + new TestCase( SECTION, DateString+".getUTCFullYear()", ResultArray[UTC_YEAR], DateCase.getUTCFullYear() ); + new TestCase( SECTION, DateString+".getUTCMonth()", ResultArray[UTC_MONTH], DateCase.getUTCMonth() ); + new TestCase( SECTION, DateString+".getUTCDate()", ResultArray[UTC_DATE], DateCase.getUTCDate() ); + new TestCase( SECTION, DateString+".getUTCDay()", ResultArray[UTC_DAY], DateCase.getUTCDay() ); + new TestCase( SECTION, DateString+".getUTCHours()", ResultArray[UTC_HOURS], DateCase.getUTCHours() ); + new TestCase( SECTION, DateString+".getUTCMinutes()", ResultArray[UTC_MINUTES],DateCase.getUTCMinutes() ); + new TestCase( SECTION, DateString+".getUTCSeconds()", ResultArray[UTC_SECONDS],DateCase.getUTCSeconds() ); + new TestCase( SECTION, DateString+".getUTCMilliseconds()", ResultArray[UTC_MS], DateCase.getUTCMilliseconds() ); + new TestCase( SECTION, DateString+".getFullYear()", ResultArray[YEAR], DateCase.getFullYear() ); + new TestCase( SECTION, DateString+".getMonth()", ResultArray[MONTH], DateCase.getMonth() ); + new TestCase( SECTION, DateString+".getDate()", ResultArray[DATE], DateCase.getDate() ); + new TestCase( SECTION, DateString+".getDay()", ResultArray[DAY], DateCase.getDay() ); + new TestCase( SECTION, DateString+".getHours()", ResultArray[HOURS], DateCase.getHours() ); + new TestCase( SECTION, DateString+".getMinutes()", ResultArray[MINUTES], DateCase.getMinutes() ); + new TestCase( SECTION, DateString+".getSeconds()", ResultArray[SECONDS], DateCase.getSeconds() ); + new TestCase( SECTION, DateString+".getMilliseconds()", ResultArray[MS], DateCase.getMilliseconds() ); +} diff --git a/tests/auto/qml/parserstress/tests/ecma/Date/15.9.3.8-3.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.3.8-3.js new file mode 100644 index 0000000000..c3042a8216 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.3.8-3.js @@ -0,0 +1,160 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.9.3.8-3.js'; + +/** + File Name: 15.9.3.8.js + ECMA Section: 15.9.3.8 The Date Constructor + new Date( value ) + Description: The [[Prototype]] property of the newly constructed + object is set to the original Date prototype object, + the one that is the initial valiue of Date.prototype. + + The [[Class]] property of the newly constructed object is + set to "Date". + + The [[Value]] property of the newly constructed object is + set as follows: + + 1. Call ToPrimitive(value) + 2. If Type( Result(1) ) is String, then go to step 5. + 3. Let V be ToNumber( Result(1) ). + 4. Set the [[Value]] property of the newly constructed + object to TimeClip(V) and return. + 5. Parse Result(1) as a date, in exactly the same manner + as for the parse method. Let V be the time value for + this date. + 6. Go to step 4. + + Author: christine@netscape.com + Date: 28 october 1997 + Version: 9706 + +*/ + +var VERSION = "ECMA_1"; +startTest(); +var SECTION = "15.9.3.8"; +var TYPEOF = "object"; + +var TIME = 0; +var UTC_YEAR = 1; +var UTC_MONTH = 2; +var UTC_DATE = 3; +var UTC_DAY = 4; +var UTC_HOURS = 5; +var UTC_MINUTES = 6; +var UTC_SECONDS = 7; +var UTC_MS = 8; + +var YEAR = 9; +var MONTH = 10; +var DATE = 11; +var DAY = 12; +var HOURS = 13; +var MINUTES = 14; +var SECONDS = 15; +var MS = 16; + + +// for TCMS, the gTestcases array must be global. +var gTc= 0; +var TITLE = "Date constructor: new Date( value )"; +var SECTION = "15.9.3.8"; +var VERSION = "ECMA_1"; +startTest(); + +writeHeaderToLog( SECTION +" " + TITLE ); + +// all the "ResultArrays" below are hard-coded to Pacific Standard Time values - +var TZ_ADJUST = -TZ_PST * msPerHour; + + +// Dates around 2000 + +addNewTestCase( new Date(TIME_2000+TZ_ADJUST), + "new Date(" +(TIME_2000+TZ_ADJUST)+")", + [TIME_2000+TZ_ADJUST,2000,0,1,6,8,0,0,0,2000,0,1,6,0,0,0,0] ); + +addNewTestCase( new Date(TIME_2000), + "new Date(" +TIME_2000+")", + [TIME_2000,2000,0,1,6,0,0,0,0,1999,11,31,5,16,0,0,0] ); + +addNewTestCase( new Date( (new Date(TIME_2000+TZ_ADJUST)).toString()), + "new Date(\"" +(new Date(TIME_2000+TZ_ADJUST)).toString()+"\")", + [TIME_2000+TZ_ADJUST,2000,0,1,6,8,0,0,0,2000,0,1,6,0,0,0,0] ); + +addNewTestCase( new Date((new Date(TIME_2000)).toString()), + "new Date(\"" +(new Date(TIME_2000)).toString()+"\")", + [TIME_2000,2000,0,1,6,0,0,0,0,1999,11,31,5,16,0,0,0] ); + + +addNewTestCase( new Date( (new Date(TIME_2000+TZ_ADJUST)).toUTCString()), + "new Date(\"" +(new Date(TIME_2000+TZ_ADJUST)).toUTCString()+"\")", + [TIME_2000+TZ_ADJUST,2000,0,1,6,8,0,0,0,2000,0,1,6,0,0,0,0] ); + +addNewTestCase( new Date( (new Date(TIME_2000)).toUTCString()), + "new Date(\"" +(new Date(TIME_2000)).toUTCString()+"\")", + [TIME_2000,2000,0,1,6,0,0,0,0,1999,11,31,5,16,0,0,0] ); + +test(); + +function addNewTestCase( DateCase, DateString, ResultArray ) { + //adjust hard-coded ResultArray for tester's timezone instead of PST + adjustResultArray(ResultArray, 'msMode'); + + new TestCase( SECTION, DateString+".getTime()", ResultArray[TIME], DateCase.getTime() ); + new TestCase( SECTION, DateString+".valueOf()", ResultArray[TIME], DateCase.valueOf() ); + new TestCase( SECTION, DateString+".getUTCFullYear()", ResultArray[UTC_YEAR], DateCase.getUTCFullYear() ); + new TestCase( SECTION, DateString+".getUTCMonth()", ResultArray[UTC_MONTH], DateCase.getUTCMonth() ); + new TestCase( SECTION, DateString+".getUTCDate()", ResultArray[UTC_DATE], DateCase.getUTCDate() ); + new TestCase( SECTION, DateString+".getUTCDay()", ResultArray[UTC_DAY], DateCase.getUTCDay() ); + new TestCase( SECTION, DateString+".getUTCHours()", ResultArray[UTC_HOURS], DateCase.getUTCHours() ); + new TestCase( SECTION, DateString+".getUTCMinutes()", ResultArray[UTC_MINUTES],DateCase.getUTCMinutes() ); + new TestCase( SECTION, DateString+".getUTCSeconds()", ResultArray[UTC_SECONDS],DateCase.getUTCSeconds() ); + new TestCase( SECTION, DateString+".getUTCMilliseconds()", ResultArray[UTC_MS], DateCase.getUTCMilliseconds() ); + new TestCase( SECTION, DateString+".getFullYear()", ResultArray[YEAR], DateCase.getFullYear() ); + new TestCase( SECTION, DateString+".getMonth()", ResultArray[MONTH], DateCase.getMonth() ); + new TestCase( SECTION, DateString+".getDate()", ResultArray[DATE], DateCase.getDate() ); + new TestCase( SECTION, DateString+".getDay()", ResultArray[DAY], DateCase.getDay() ); + new TestCase( SECTION, DateString+".getHours()", ResultArray[HOURS], DateCase.getHours() ); + new TestCase( SECTION, DateString+".getMinutes()", ResultArray[MINUTES], DateCase.getMinutes() ); + new TestCase( SECTION, DateString+".getSeconds()", ResultArray[SECONDS], DateCase.getSeconds() ); + new TestCase( SECTION, DateString+".getMilliseconds()", ResultArray[MS], DateCase.getMilliseconds() ); +} diff --git a/tests/auto/qml/parserstress/tests/ecma/Date/15.9.3.8-4.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.3.8-4.js new file mode 100644 index 0000000000..c3a1eae7dc --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.3.8-4.js @@ -0,0 +1,161 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.9.3.8-4.js'; + +/** + File Name: 15.9.3.8.js + ECMA Section: 15.9.3.8 The Date Constructor + new Date( value ) + Description: The [[Prototype]] property of the newly constructed + object is set to the original Date prototype object, + the one that is the initial valiue of Date.prototype. + + The [[Class]] property of the newly constructed object is + set to "Date". + + The [[Value]] property of the newly constructed object is + set as follows: + + 1. Call ToPrimitive(value) + 2. If Type( Result(1) ) is String, then go to step 5. + 3. Let V be ToNumber( Result(1) ). + 4. Set the [[Value]] property of the newly constructed + object to TimeClip(V) and return. + 5. Parse Result(1) as a date, in exactly the same manner + as for the parse method. Let V be the time value for + this date. + 6. Go to step 4. + + Author: christine@netscape.com + Date: 28 october 1997 + Version: 9706 + +*/ + +var VERSION = "ECMA_1"; +startTest(); +var SECTION = "15.9.3.8"; +var TYPEOF = "object"; + +var TIME = 0; +var UTC_YEAR = 1; +var UTC_MONTH = 2; +var UTC_DATE = 3; +var UTC_DAY = 4; +var UTC_HOURS = 5; +var UTC_MINUTES = 6; +var UTC_SECONDS = 7; +var UTC_MS = 8; + +var YEAR = 9; +var MONTH = 10; +var DATE = 11; +var DAY = 12; +var HOURS = 13; +var MINUTES = 14; +var SECONDS = 15; +var MS = 16; + + +// for TCMS, the gTestcases array must be global. +var gTc= 0; +var TITLE = "Date constructor: new Date( value )"; +var SECTION = "15.9.3.8"; +var VERSION = "ECMA_1"; +startTest(); + +writeHeaderToLog( SECTION +" " + TITLE ); + +// all the "ResultArrays" below are hard-coded to Pacific Standard Time values - +var TZ_ADJUST = -TZ_PST * msPerHour; + +// Dates around Feb 29, 2000 + +var PST_FEB_29_2000 = UTC_FEB_29_2000 + TZ_ADJUST; + +addNewTestCase( new Date(UTC_FEB_29_2000), + "new Date("+UTC_FEB_29_2000+")", + [UTC_FEB_29_2000,2000,1,29,2,0,0,0,0,2000,1,28,1,16,0,0,0] ); + +addNewTestCase( new Date(PST_FEB_29_2000), + "new Date("+PST_FEB_29_2000+")", + [PST_FEB_29_2000,2000,1,29,2,8,0,0,0,2000,1,29,2,0,0,0,0] ); + +addNewTestCase( new Date( (new Date(UTC_FEB_29_2000)).toString() ), + "new Date(\""+(new Date(UTC_FEB_29_2000)).toString()+"\")", + [UTC_FEB_29_2000,2000,1,29,2,0,0,0,0,2000,1,28,1,16,0,0,0] ); + +addNewTestCase( new Date( (new Date(PST_FEB_29_2000)).toString() ), + "new Date(\""+(new Date(PST_FEB_29_2000)).toString()+"\")", + [PST_FEB_29_2000,2000,1,29,2,8,0,0,0,2000,1,29,2,0,0,0,0] ); + + +addNewTestCase( new Date( (new Date(UTC_FEB_29_2000)).toGMTString() ), + "new Date(\""+(new Date(UTC_FEB_29_2000)).toGMTString()+"\")", + [UTC_FEB_29_2000,2000,1,29,2,0,0,0,0,2000,1,28,1,16,0,0,0] ); + +addNewTestCase( new Date( (new Date(PST_FEB_29_2000)).toGMTString() ), + "new Date(\""+(new Date(PST_FEB_29_2000)).toGMTString()+"\")", + [PST_FEB_29_2000,2000,1,29,2,8,0,0,0,2000,1,29,2,0,0,0,0] ); + +test(); + +function addNewTestCase( DateCase, DateString, ResultArray ) { + //adjust hard-coded ResultArray for tester's timezone instead of PST + adjustResultArray(ResultArray, 'msMode'); + + new TestCase( SECTION, DateString+".getTime()", ResultArray[TIME], DateCase.getTime() ); + new TestCase( SECTION, DateString+".valueOf()", ResultArray[TIME], DateCase.valueOf() ); + new TestCase( SECTION, DateString+".getUTCFullYear()", ResultArray[UTC_YEAR], DateCase.getUTCFullYear() ); + new TestCase( SECTION, DateString+".getUTCMonth()", ResultArray[UTC_MONTH], DateCase.getUTCMonth() ); + new TestCase( SECTION, DateString+".getUTCDate()", ResultArray[UTC_DATE], DateCase.getUTCDate() ); + new TestCase( SECTION, DateString+".getUTCDay()", ResultArray[UTC_DAY], DateCase.getUTCDay() ); + new TestCase( SECTION, DateString+".getUTCHours()", ResultArray[UTC_HOURS], DateCase.getUTCHours() ); + new TestCase( SECTION, DateString+".getUTCMinutes()", ResultArray[UTC_MINUTES],DateCase.getUTCMinutes() ); + new TestCase( SECTION, DateString+".getUTCSeconds()", ResultArray[UTC_SECONDS],DateCase.getUTCSeconds() ); + new TestCase( SECTION, DateString+".getUTCMilliseconds()", ResultArray[UTC_MS], DateCase.getUTCMilliseconds() ); + new TestCase( SECTION, DateString+".getFullYear()", ResultArray[YEAR], DateCase.getFullYear() ); + new TestCase( SECTION, DateString+".getMonth()", ResultArray[MONTH], DateCase.getMonth() ); + new TestCase( SECTION, DateString+".getDate()", ResultArray[DATE], DateCase.getDate() ); + new TestCase( SECTION, DateString+".getDay()", ResultArray[DAY], DateCase.getDay() ); + new TestCase( SECTION, DateString+".getHours()", ResultArray[HOURS], DateCase.getHours() ); + new TestCase( SECTION, DateString+".getMinutes()", ResultArray[MINUTES], DateCase.getMinutes() ); + new TestCase( SECTION, DateString+".getSeconds()", ResultArray[SECONDS], DateCase.getSeconds() ); + new TestCase( SECTION, DateString+".getMilliseconds()", ResultArray[MS], DateCase.getMilliseconds() ); +} diff --git a/tests/auto/qml/parserstress/tests/ecma/Date/15.9.3.8-5.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.3.8-5.js new file mode 100644 index 0000000000..405842c79f --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.3.8-5.js @@ -0,0 +1,161 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.9.3.8-5.js'; + +/** + File Name: 15.9.3.8.js + ECMA Section: 15.9.3.8 The Date Constructor + new Date( value ) + Description: The [[Prototype]] property of the newly constructed + object is set to the original Date prototype object, + the one that is the initial valiue of Date.prototype. + + The [[Class]] property of the newly constructed object is + set to "Date". + + The [[Value]] property of the newly constructed object is + set as follows: + + 1. Call ToPrimitive(value) + 2. If Type( Result(1) ) is String, then go to step 5. + 3. Let V be ToNumber( Result(1) ). + 4. Set the [[Value]] property of the newly constructed + object to TimeClip(V) and return. + 5. Parse Result(1) as a date, in exactly the same manner + as for the parse method. Let V be the time value for + this date. + 6. Go to step 4. + + Author: christine@netscape.com + Date: 28 october 1997 + Version: 9706 + +*/ + +var VERSION = "ECMA_1"; +startTest(); +var SECTION = "15.9.3.8"; +var TYPEOF = "object"; + +var TIME = 0; +var UTC_YEAR = 1; +var UTC_MONTH = 2; +var UTC_DATE = 3; +var UTC_DAY = 4; +var UTC_HOURS = 5; +var UTC_MINUTES = 6; +var UTC_SECONDS = 7; +var UTC_MS = 8; + +var YEAR = 9; +var MONTH = 10; +var DATE = 11; +var DAY = 12; +var HOURS = 13; +var MINUTES = 14; +var SECONDS = 15; +var MS = 16; + + +// for TCMS, the gTestcases array must be global. +var gTc= 0; +var TITLE = "Date constructor: new Date( value )"; +var SECTION = "15.9.3.8"; +var VERSION = "ECMA_1"; +startTest(); + +writeHeaderToLog( SECTION +" " + TITLE ); + +// all the "ResultArrays" below are hard-coded to Pacific Standard Time values - +var TZ_ADJUST = -TZ_PST * msPerHour; + + +// Dates around 1900 + +var PST_1900 = TIME_1900 + 8*msPerHour; + +addNewTestCase( new Date( TIME_1900 ), + "new Date("+TIME_1900+")", + [TIME_1900,1900,0,1,1,0,0,0,0,1899,11,31,0,16,0,0,0] ); + +addNewTestCase( new Date(PST_1900), + "new Date("+PST_1900+")", + [ PST_1900,1900,0,1,1,8,0,0,0,1900,0,1,1,0,0,0,0] ); + +addNewTestCase( new Date( (new Date(TIME_1900)).toString() ), + "new Date(\""+(new Date(TIME_1900)).toString()+"\")", + [TIME_1900,1900,0,1,1,0,0,0,0,1899,11,31,0,16,0,0,0] ); + +addNewTestCase( new Date( (new Date(PST_1900)).toString() ), + "new Date(\""+(new Date(PST_1900 )).toString()+"\")", + [ PST_1900,1900,0,1,1,8,0,0,0,1900,0,1,1,0,0,0,0] ); + +addNewTestCase( new Date( (new Date(TIME_1900)).toUTCString() ), + "new Date(\""+(new Date(TIME_1900)).toUTCString()+"\")", + [TIME_1900,1900,0,1,1,0,0,0,0,1899,11,31,0,16,0,0,0] ); + +addNewTestCase( new Date( (new Date(PST_1900)).toUTCString() ), + "new Date(\""+(new Date(PST_1900 )).toUTCString()+"\")", + [ PST_1900,1900,0,1,1,8,0,0,0,1900,0,1,1,0,0,0,0] ); + +test(); + +function addNewTestCase( DateCase, DateString, ResultArray ) { + //adjust hard-coded ResultArray for tester's timezone instead of PST + adjustResultArray(ResultArray, 'msMode'); + + new TestCase( SECTION, DateString+".getTime()", ResultArray[TIME], DateCase.getTime() ); + new TestCase( SECTION, DateString+".valueOf()", ResultArray[TIME], DateCase.valueOf() ); + new TestCase( SECTION, DateString+".getUTCFullYear()", ResultArray[UTC_YEAR], DateCase.getUTCFullYear() ); + new TestCase( SECTION, DateString+".getUTCMonth()", ResultArray[UTC_MONTH], DateCase.getUTCMonth() ); + new TestCase( SECTION, DateString+".getUTCDate()", ResultArray[UTC_DATE], DateCase.getUTCDate() ); + new TestCase( SECTION, DateString+".getUTCDay()", ResultArray[UTC_DAY], DateCase.getUTCDay() ); + new TestCase( SECTION, DateString+".getUTCHours()", ResultArray[UTC_HOURS], DateCase.getUTCHours() ); + new TestCase( SECTION, DateString+".getUTCMinutes()", ResultArray[UTC_MINUTES],DateCase.getUTCMinutes() ); + new TestCase( SECTION, DateString+".getUTCSeconds()", ResultArray[UTC_SECONDS],DateCase.getUTCSeconds() ); + new TestCase( SECTION, DateString+".getUTCMilliseconds()", ResultArray[UTC_MS], DateCase.getUTCMilliseconds() ); + new TestCase( SECTION, DateString+".getFullYear()", ResultArray[YEAR], DateCase.getFullYear() ); + new TestCase( SECTION, DateString+".getMonth()", ResultArray[MONTH], DateCase.getMonth() ); + new TestCase( SECTION, DateString+".getDate()", ResultArray[DATE], DateCase.getDate() ); + new TestCase( SECTION, DateString+".getDay()", ResultArray[DAY], DateCase.getDay() ); + new TestCase( SECTION, DateString+".getHours()", ResultArray[HOURS], DateCase.getHours() ); + new TestCase( SECTION, DateString+".getMinutes()", ResultArray[MINUTES], DateCase.getMinutes() ); + new TestCase( SECTION, DateString+".getSeconds()", ResultArray[SECONDS], DateCase.getSeconds() ); + new TestCase( SECTION, DateString+".getMilliseconds()", ResultArray[MS], DateCase.getMilliseconds() ); +} diff --git a/tests/auto/qml/parserstress/tests/ecma/Date/15.9.4.2-1.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.4.2-1.js new file mode 100644 index 0000000000..4b269f264f --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.4.2-1.js @@ -0,0 +1,81 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is mozilla.org code. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.9.4.2-1.js'; + +/** + * File Name: + * Reference: http://bugzilla.mozilla.org/show_bug.cgi?id=4088 + * Description: Date parsing gets 12:30 AM wrong. + * New behavior: + * js> d = new Date('1/1/1999 13:30 AM') + * Invalid Date + * js> d = new Date('1/1/1999 13:30 PM') + * Invalid Date + * js> d = new Date('1/1/1999 12:30 AM') + * Fri Jan 01 00:30:00 GMT-0800 (PST) 1999 + * js> d = new Date('1/1/1999 12:30 PM') + * Fri Jan 01 12:30:00 GMT-0800 (PST) 1999 + * Author: christine@netscape.com + */ + +var SECTION = "15.9.4.2-1"; // provide a document reference (ie, ECMA section) +var VERSION = "ECMA"; // Version of JavaScript or ECMA +var TITLE = "Regression Test for Date.parse"; // Provide ECMA section title or a description +var BUGNUMBER = "http://bugzilla.mozilla.org/show_bug.cgi?id=4088"; // Provide URL to bugsplat or bugzilla report + +startTest(); // leave this alone + +AddTestCase( "new Date('1/1/1999 12:30 AM').toString()", + new Date(1999,0,1,0,30).toString(), + new Date('1/1/1999 12:30 AM').toString() ); + +AddTestCase( "new Date('1/1/1999 12:30 PM').toString()", + new Date( 1999,0,1,12,30 ).toString(), + new Date('1/1/1999 12:30 PM').toString() ); + +AddTestCase( "new Date('1/1/1999 13:30 AM')", + "Invalid Date", + new Date('1/1/1999 13:30 AM').toString() ); + + +AddTestCase( "new Date('1/1/1999 13:30 PM')", + "Invalid Date", + new Date('1/1/1999 13:30 PM').toString() ); + +test(); // leave this alone. this executes the test cases and +// displays results. diff --git a/tests/auto/qml/parserstress/tests/ecma/Date/15.9.4.2.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.4.2.js new file mode 100644 index 0000000000..5a518e6442 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.4.2.js @@ -0,0 +1,191 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.9.4.2.js'; + +/** + File Name: 15.9.4.2.js + ECMA Section: 15.9.4.2 Date.parse() + Description: The parse() function applies the to ToString() operator + to its argument and interprets the resulting string as + a date. It returns a number, the UTC time value + corresponding to the date. + + The string may be interpreted as a local time, a UTC + time, or a time in some other time zone, depending on + the contents of the string. + + (need to test strings containing stuff with the time + zone specified, and verify that parse() returns the + correct GMT time) + + so for any Date object x, all of these things should + be equal: + + value tested in function: + x.valueOf() test_value() + Date.parse(x.toString()) test_tostring() + Date.parse(x.toGMTString()) test_togmt() + + Date.parse(x.toLocaleString()) is not required to + produce the same number value as the preceeding three + expressions. in general the value produced by + Date.parse is implementation dependent when given any + string value that could not be produced in that + implementation by the toString or toGMTString method. + + value tested in function: + Date.parse( x.toLocaleString()) test_tolocale() + + Author: christine@netscape.com + Date: 10 july 1997 + +*/ + +var VERSION = "ECMA_1"; +startTest(); +var SECTION = "15.9.4.2"; +var TITLE = "Date.parse()"; + +var TIME = 0; +var UTC_YEAR = 1; +var UTC_MONTH = 2; +var UTC_DATE = 3; +var UTC_DAY = 4; +var UTC_HOURS = 5; +var UTC_MINUTES = 6; +var UTC_SECONDS = 7; +var UTC_MS = 8; + +var YEAR = 9; +var MONTH = 10; +var DATE = 11; +var DAY = 12; +var HOURS = 13; +var MINUTES = 14; +var SECONDS = 15; +var MS = 16; +var TYPEOF = "object"; + +// for TCMS, the gTestcases array must be global. +writeHeaderToLog("15.9.4.2 Date.parse()" ); + +// Dates around 1970 + +addNewTestCase( new Date(0), + "new Date(0)", + [0,1970,0,1,4,0,0,0,0,1969,11,31,3,16,0,0,0] ); + +addNewTestCase( new Date(-1), + "new Date(-1)", + [-1,1969,11,31,3,23,59,59,999,1969,11,31,3,15,59,59,999] ); +addNewTestCase( new Date(28799999), + "new Date(28799999)", + [28799999,1970,0,1,4,7,59,59,999,1969,11,31,3,23,59,59,999] ); +addNewTestCase( new Date(28800000), + "new Date(28800000)", + [28800000,1970,0,1,4,8,0,0,0,1970,0,1,4,0,0,0,0] ); + +// Dates around 2000 + +addNewTestCase( new Date(946684799999), + "new Date(946684799999)", + [946684799999,1999,11,31,5,23,59,59,999,1999,11,31,5,15,59,59,999] ); +addNewTestCase( new Date(946713599999), + "new Date(946713599999)", + [946713599999,2000,0,1,6,7,59,59,999,1999,11,31,5,23,59,59,999] ); +addNewTestCase( new Date(946684800000), + "new Date(946684800000)", + [946684800000,2000,0,1,6,0,0,0,0,1999,11,31,5, 16,0,0,0] ); +addNewTestCase( new Date(946713600000), + "new Date(946713600000)", + [946713600000,2000,0,1,6,8,0,0,0,2000,0,1,6,0,0,0,0] ); + +// Dates around 1900 + +addNewTestCase( new Date(-2208988800000), + "new Date(-2208988800000)", + [-2208988800000,1900,0,1,1,0,0,0,0,1899,11,31,0,16,0,0,0] ); + +addNewTestCase( new Date(-2208988800001), + "new Date(-2208988800001)", + [-2208988800001,1899,11,31,0,23,59,59,999,1899,11,31,0,15,59,59,999] ); + +addNewTestCase( new Date(-2208960000001), + "new Date(-2208960000001)", + [-2208960000001,1900,0,1,1,7,59,59,0,1899,11,31,0,23,59,59,999] ); +addNewTestCase( new Date(-2208960000000), + "new Date(-2208960000000)", + [-2208960000000,1900,0,1,1,8,0,0,0,1900,0,1,1,0,0,0,0] ); +addNewTestCase( new Date(-2208959999999), + "new Date(-2208959999999)", + [-2208959999999,1900,0,1,1,8,0,0,1,1900,0,1,1,0,0,0,1] ); + +// Dates around Feb 29, 2000 + +var PST_FEB_29_2000 = UTC_FEB_29_2000 + 8*msPerHour; + +addNewTestCase( new Date(UTC_FEB_29_2000), + "new Date(" + UTC_FEB_29_2000 +")", + [UTC_FEB_29_2000,2000,0,1,6,0,0,0,0,1999,11,31,5,16,0,0,0] ); +addNewTestCase( new Date(PST_FEB_29_2000), + "new Date(" + PST_FEB_29_2000 +")", + [PST_FEB_29_2000,2000,0,1,6,8.0,0,0,2000,0,1,6,0,0,0,0]); + +// Dates around Jan 1 2005 + +var PST_JAN_1_2005 = UTC_JAN_1_2005 + 8*msPerHour; + +addNewTestCase( new Date(UTC_JAN_1_2005), + "new Date("+ UTC_JAN_1_2005 +")", + [UTC_JAN_1_2005,2005,0,1,6,0,0,0,0,2004,11,31,5,16,0,0,0] ); +addNewTestCase( new Date(PST_JAN_1_2005), + "new Date("+ PST_JAN_1_2005 +")", + [PST_JAN_1_2005,2005,0,1,6,8,0,0,0,2005,0,1,6,0,0,0,0] ); + + +test(); + +function addNewTestCase( DateCase, DateString, ResultArray ) { + DateCase = DateCase; + + new TestCase( SECTION, DateString+".getTime()", ResultArray[TIME], DateCase.getTime() ); + new TestCase( SECTION, DateString+".valueOf()", ResultArray[TIME], DateCase.valueOf() ); + new TestCase( SECTION, "Date.parse(" + DateCase.toString() +")", Math.floor(ResultArray[TIME]/1000)*1000, Date.parse(DateCase.toString()) ); + new TestCase( SECTION, "Date.parse(" + DateCase.toGMTString() +")", Math.floor(ResultArray[TIME]/1000)*1000, Date.parse(DateCase.toGMTString()) ); +} diff --git a/tests/auto/qml/parserstress/tests/ecma/Date/15.9.4.3.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.4.3.js new file mode 100644 index 0000000000..b0549588aa --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.4.3.js @@ -0,0 +1,186 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.9.4.3.js'; + +var SECTION = "15.9.4.3"; +var TITLE = "Date.UTC( year, month, date, hours, minutes, seconds, ms )"; +startTest(); + +// Dates around 1970 + +addNewTestCase( Date.UTC( 1970,0,1,0,0,0,0), + "Date.UTC( 1970,0,1,0,0,0,0)", + utc(1970,0,1,0,0,0,0) ); + +addNewTestCase( Date.UTC( 1969,11,31,23,59,59,999), + "Date.UTC( 1969,11,31,23,59,59,999)", + utc(1969,11,31,23,59,59,999) ); +addNewTestCase( Date.UTC( 1972,1,29,23,59,59,999), + "Date.UTC( 1972,1,29,23,59,59,999)", + utc(1972,1,29,23,59,59,999) ); +addNewTestCase( Date.UTC( 1972,2,1,23,59,59,999), + "Date.UTC( 1972,2,1,23,59,59,999)", + utc(1972,2,1,23,59,59,999) ); +addNewTestCase( Date.UTC( 1968,1,29,23,59,59,999), + "Date.UTC( 1968,1,29,23,59,59,999)", + utc(1968,1,29,23,59,59,999) ); +addNewTestCase( Date.UTC( 1968,2,1,23,59,59,999), + "Date.UTC( 1968,2,1,23,59,59,999)", + utc(1968,2,1,23,59,59,999) ); +addNewTestCase( Date.UTC( 1969,0,1,0,0,0,0), + "Date.UTC( 1969,0,1,0,0,0,0)", + utc(1969,0,1,0,0,0,0) ); +addNewTestCase( Date.UTC( 1969,11,31,23,59,59,1000), + "Date.UTC( 1969,11,31,23,59,59,1000)", + utc(1970,0,1,0,0,0,0) ); +addNewTestCase( Date.UTC( 1969,Number.NaN,31,23,59,59,999), + "Date.UTC( 1969,Number.NaN,31,23,59,59,999)", + utc(1969,Number.NaN,31,23,59,59,999) ); + +// Dates around 2000 + +addNewTestCase( Date.UTC( 1999,11,31,23,59,59,999), + "Date.UTC( 1999,11,31,23,59,59,999)", + utc(1999,11,31,23,59,59,999) ); +addNewTestCase( Date.UTC( 2000,0,1,0,0,0,0), + "Date.UTC( 2000,0,1,0,0,0,0)", + utc(2000,0,1,0,0,0,0) ); + +// Dates around 1900 +addNewTestCase( Date.UTC( 1899,11,31,23,59,59,999), + "Date.UTC( 1899,11,31,23,59,59,999)", + utc(1899,11,31,23,59,59,999) ); +addNewTestCase( Date.UTC( 1900,0,1,0,0,0,0), + "Date.UTC( 1900,0,1,0,0,0,0)", + utc(1900,0,1,0,0,0,0) ); +addNewTestCase( Date.UTC( 1973,0,1,0,0,0,0), + "Date.UTC( 1973,0,1,0,0,0,0)", + utc(1973,0,1,0,0,0,0) ); +addNewTestCase( Date.UTC( 1776,6,4,12,36,13,111), + "Date.UTC( 1776,6,4,12,36,13,111)", + utc(1776,6,4,12,36,13,111) ); +addNewTestCase( Date.UTC( 2525,9,18,15,30,1,123), + "Date.UTC( 2525,9,18,15,30,1,123)", + utc(2525,9,18,15,30,1,123) ); + +// Dates around 29 Feb 2000 + +addNewTestCase( Date.UTC( 2000,1,29,0,0,0,0 ), + "Date.UTC( 2000,1,29,0,0,0,0 )", + utc(2000,1,29,0,0,0,0) ); +addNewTestCase( Date.UTC( 2000,1,29,8,0,0,0 ), + "Date.UTC( 2000,1,29,8,0,0,0 )", + utc(2000,1,29,8,0,0,0) ); + +// Dates around 1 Jan 2005 + +addNewTestCase( Date.UTC( 2005,0,1,0,0,0,0 ), + "Date.UTC( 2005,0,1,0,0,0,0 )", + utc(2005,0,1,0,0,0,0) ); +addNewTestCase( Date.UTC( 2004,11,31,16,0,0,0 ), + "Date.UTC( 2004,11,31,16,0,0,0 )", + utc(2004,11,31,16,0,0,0) ); + +test(); + +function addNewTestCase( DateCase, DateString, ExpectDate) { + DateCase = DateCase; + + new TestCase( SECTION, DateString, ExpectDate.value, DateCase ); + new TestCase( SECTION, DateString, ExpectDate.value, DateCase ); +} + +function MyDate() { + this.year = 0; + this.month = 0; + this.date = 0; + this.hours = 0; + this.minutes = 0; + this.seconds = 0; + this.ms = 0; +} + +function utc( year, month, date, hours, minutes, seconds, ms ) { + d = new MyDate(); + d.year = Number(year); + + if (month) + d.month = Number(month); + if (date) + d.date = Number(date); + if (hours) + d.hours = Number(hours); + if (minutes) + d.minutes = Number(minutes); + if (seconds) + d.seconds = Number(seconds); + if (ms) + d.ms = Number(ms); + + if ( isNaN(d.year) && 0 <= ToInteger(d.year) && d.year <= 99 ) { + d.year = 1900 + ToInteger(d.year); + } + + if (isNaN(month) || isNaN(year) || isNaN(date) || isNaN(hours) || + isNaN(minutes) || isNaN(seconds) || isNaN(ms) ) { + d.year = Number.NaN; + d.month = Number.NaN; + d.date = Number.NaN; + d.hours = Number.NaN; + d.minutes = Number.NaN; + d.seconds = Number.NaN; + d.ms = Number.NaN; + d.value = Number.NaN; + d.time = Number.NaN; + d.day =Number.NaN; + return d; + } + + d.day = MakeDay( d.year, d.month, d.date ); + d.time = MakeTime( d.hours, d.minutes, d.seconds, d.ms ); + d.value = (TimeClip( MakeDate(d.day,d.time))); + + return d; +} + +function UTCTime( t ) { + sign = ( t < 0 ) ? -1 : 1; + return ( (t +(TZ_DIFF*msPerHour)) ); +} + diff --git a/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.1.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.1.js new file mode 100644 index 0000000000..3185a7c4e5 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.1.js @@ -0,0 +1,63 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.9.5.1.js'; + +/** + File Name: 15.9.5.1.js + ECMA Section: 15.9.5.1 Date.prototype.constructor + Description: + The initial value of Date.prototype.constructor is the built-in Date + constructor. + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + +var SECTION = "15.9.5.1"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Date.prototype.constructor"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +new TestCase( SECTION, + "Date.prototype.constructor == Date", + true, + Date.prototype.constructor == Date ); +test(); diff --git a/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.10-1.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.10-1.js new file mode 100644 index 0000000000..cd73d288c9 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.10-1.js @@ -0,0 +1,85 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.9.5.10-1.js'; + +/** + File Name: 15.9.5.10.js + ECMA Section: 15.9.5.10 + Description: Date.prototype.getDate + + 1.Let t be this time value. + 2.If t is NaN, return NaN. + 3.Return DateFromTime(LocalTime(t)). + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + +var SECTION = "15.9.5.10"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Date.prototype.getDate()"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +addTestCase( TIME_NOW ); + +new TestCase( SECTION, + "(new Date(NaN)).getDate()", + NaN, + (new Date(NaN)).getDate() ); + +new TestCase( SECTION, + "Date.prototype.getDate.length", + 0, + Date.prototype.getDate.length ); +test(); + +function addTestCase( t ) { + var start = TimeFromYear(YearFromTime(t)); + var stop = TimeFromYear(YearFromTime(t) + 1); + + for (var d = start; d < stop; d += msPerDay) + { + new TestCase( SECTION, + "(new Date("+d+")).getDate()", + DateFromTime(LocalTime(d)), + (new Date(d)).getDate() ); + } +} diff --git a/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.10-10.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.10-10.js new file mode 100644 index 0000000000..4142635486 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.10-10.js @@ -0,0 +1,89 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.9.5.10-10.js'; + +/** + File Name: 15.9.5.10.js + ECMA Section: 15.9.5.10 + Description: Date.prototype.getDate + + 1.Let t be this time value. + 2.If t is NaN, return NaN. + 3.Return DateFromTime(LocalTime(t)). + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + +var SECTION = "15.9.5.10"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Date.prototype.getDate()"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +// some daylight savings time cases + +var DST_START_1998 = GetDSTStart(TimeFromYear(1998)); + +addTestCase( DST_START_1998+1 ); + +new TestCase( SECTION, + "(new Date(NaN)).getDate()", + NaN, + (new Date(NaN)).getDate() ); + +new TestCase( SECTION, + "Date.prototype.getDate.length", + 0, + Date.prototype.getDate.length ); +test(); + +function addTestCase( t ) { + var start = TimeFromYear(YearFromTime(t)); + var stop = TimeFromYear(YearFromTime(t) + 1); + + for (var d = start; d < stop; d += msPerDay) + { + new TestCase( SECTION, + "(new Date("+d+")).getDate()", + DateFromTime(LocalTime(d)), + (new Date(d)).getDate() ); + } +} diff --git a/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.10-11.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.10-11.js new file mode 100644 index 0000000000..dfadc18838 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.10-11.js @@ -0,0 +1,89 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.9.5.10-11.js'; + +/** + File Name: 15.9.5.10.js + ECMA Section: 15.9.5.10 + Description: Date.prototype.getDate + + 1.Let t be this time value. + 2.If t is NaN, return NaN. + 3.Return DateFromTime(LocalTime(t)). + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + +var SECTION = "15.9.5.10"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Date.prototype.getDate()"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +// some daylight savings time cases + +var DST_END_1998 = GetDSTEnd(TimeFromYear(1998)); + +addTestCase( DST_END_1998 ); + +new TestCase( SECTION, + "(new Date(NaN)).getDate()", + NaN, + (new Date(NaN)).getDate() ); + +new TestCase( SECTION, + "Date.prototype.getDate.length", + 0, + Date.prototype.getDate.length ); +test(); + +function addTestCase( t ) { + var start = TimeFromYear(YearFromTime(t)); + var stop = TimeFromYear(YearFromTime(t) + 1); + + for (var d = start; d < stop; d += msPerDay) + { + new TestCase( SECTION, + "(new Date("+d+")).getDate()", + DateFromTime(LocalTime(d)), + (new Date(d)).getDate() ); + } +} diff --git a/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.10-12.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.10-12.js new file mode 100644 index 0000000000..2557108faf --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.10-12.js @@ -0,0 +1,89 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.9.5.10-12.js'; + +/** + File Name: 15.9.5.10.js + ECMA Section: 15.9.5.10 + Description: Date.prototype.getDate + + 1.Let t be this time value. + 2.If t is NaN, return NaN. + 3.Return DateFromTime(LocalTime(t)). + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + +var SECTION = "15.9.5.10"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Date.prototype.getDate()"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +// some daylight savings time cases + +var DST_END_1998 = GetDSTEnd(TimeFromYear(1998)); + +addTestCase( DST_END_1998-1 ); + +new TestCase( SECTION, + "(new Date(NaN)).getDate()", + NaN, + (new Date(NaN)).getDate() ); + +new TestCase( SECTION, + "Date.prototype.getDate.length", + 0, + Date.prototype.getDate.length ); +test(); + +function addTestCase( t ) { + var start = TimeFromYear(YearFromTime(t)); + var stop = TimeFromYear(YearFromTime(t) + 1); + + for (var d = start; d < stop; d += msPerDay) + { + new TestCase( SECTION, + "(new Date("+d+")).getDate()", + DateFromTime(LocalTime(d)), + (new Date(d)).getDate() ); + } +} diff --git a/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.10-13.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.10-13.js new file mode 100644 index 0000000000..e0e2402ebd --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.10-13.js @@ -0,0 +1,89 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.9.5.10-13.js'; + +/** + File Name: 15.9.5.10.js + ECMA Section: 15.9.5.10 + Description: Date.prototype.getDate + + 1.Let t be this time value. + 2.If t is NaN, return NaN. + 3.Return DateFromTime(LocalTime(t)). + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + +var SECTION = "15.9.5.10"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Date.prototype.getDate()"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +// some daylight savings time cases + +var DST_END_1998 = GetDSTEnd(TimeFromYear(1998)); + +addTestCase( DST_END_1998+1 ); + +new TestCase( SECTION, + "(new Date(NaN)).getDate()", + NaN, + (new Date(NaN)).getDate() ); + +new TestCase( SECTION, + "Date.prototype.getDate.length", + 0, + Date.prototype.getDate.length ); +test(); + +function addTestCase( t ) { + var start = TimeFromYear(YearFromTime(t)); + var stop = TimeFromYear(YearFromTime(t) + 1); + + for (var d = start; d < stop; d += msPerDay) + { + new TestCase( SECTION, + "(new Date("+d+")).getDate()", + DateFromTime(LocalTime(d)), + (new Date(d)).getDate() ); + } +} diff --git a/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.10-2.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.10-2.js new file mode 100644 index 0000000000..e44cfcc5d7 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.10-2.js @@ -0,0 +1,87 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.9.5.10-2.js'; + +/** + File Name: 15.9.5.10.js + ECMA Section: 15.9.5.10 + Description: Date.prototype.getDate + + 1.Let t be this time value. + 2.If t is NaN, return NaN. + 3.Return DateFromTime(LocalTime(t)). + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + +var SECTION = "15.9.5.10"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Date.prototype.getDate()"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +// addTestCase( TIME_0000 ); + +new TestCase( SECTION, + "(new Date(NaN)).getDate()", + NaN, + (new Date(NaN)).getDate() ); + +new TestCase( SECTION, + "Date.prototype.getDate.length", + 0, + Date.prototype.getDate.length ); +test(); + +function addTestCase( t ) { + print(t); + var start = TimeFromYear(YearFromTime(t)); + var stop = TimeFromYear(YearFromTime(t) + 1); + + for (var d = start; d < stop; d += msPerDay) + { + print(start, stop, d); + new TestCase( SECTION, + "(new Date("+d+")).getDate()", + DateFromTime(LocalTime(d)), + (new Date(d)).getDate() ); + } +} diff --git a/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.10-3.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.10-3.js new file mode 100644 index 0000000000..325c9bfaf2 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.10-3.js @@ -0,0 +1,85 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.9.5.10-3.js'; + +/** + File Name: 15.9.5.10.js + ECMA Section: 15.9.5.10 + Description: Date.prototype.getDate + + 1.Let t be this time value. + 2.If t is NaN, return NaN. + 3.Return DateFromTime(LocalTime(t)). + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + +var SECTION = "15.9.5.10"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Date.prototype.getDate()"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +addTestCase( TIME_1970 ); + +new TestCase( SECTION, + "(new Date(NaN)).getDate()", + NaN, + (new Date(NaN)).getDate() ); + +new TestCase( SECTION, + "Date.prototype.getDate.length", + 0, + Date.prototype.getDate.length ); +test(); + +function addTestCase( t ) { + var start = TimeFromYear(YearFromTime(t)); + var stop = TimeFromYear(YearFromTime(t) + 1); + + for (var d = start; d < stop; d += msPerDay) + { + new TestCase( SECTION, + "(new Date("+d+")).getDate()", + DateFromTime(LocalTime(d)), + (new Date(d)).getDate() ); + } +} diff --git a/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.10-4.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.10-4.js new file mode 100644 index 0000000000..41676c2658 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.10-4.js @@ -0,0 +1,85 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.9.5.10-4.js'; + +/** + File Name: 15.9.5.10.js + ECMA Section: 15.9.5.10 + Description: Date.prototype.getDate + + 1.Let t be this time value. + 2.If t is NaN, return NaN. + 3.Return DateFromTime(LocalTime(t)). + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + +var SECTION = "15.9.5.10"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Date.prototype.getDate()"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +addTestCase( TIME_1900 ); + +new TestCase( SECTION, + "(new Date(NaN)).getDate()", + NaN, + (new Date(NaN)).getDate() ); + +new TestCase( SECTION, + "Date.prototype.getDate.length", + 0, + Date.prototype.getDate.length ); +test(); + +function addTestCase( t ) { + var start = TimeFromYear(YearFromTime(t)); + var stop = TimeFromYear(YearFromTime(t) + 1); + + for (var d = start; d < stop; d += msPerDay) + { + new TestCase( SECTION, + "(new Date("+d+")).getDate()", + DateFromTime(LocalTime(d)), + (new Date(d)).getDate() ); + } +} diff --git a/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.10-5.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.10-5.js new file mode 100644 index 0000000000..f17b0a0b29 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.10-5.js @@ -0,0 +1,85 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.9.5.10-5.js'; + +/** + File Name: 15.9.5.10.js + ECMA Section: 15.9.5.10 + Description: Date.prototype.getDate + + 1.Let t be this time value. + 2.If t is NaN, return NaN. + 3.Return DateFromTime(LocalTime(t)). + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + +var SECTION = "15.9.5.10"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Date.prototype.getDate()"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +addTestCase( TIME_2000 ); + +new TestCase( SECTION, + "(new Date(NaN)).getDate()", + NaN, + (new Date(NaN)).getDate() ); + +new TestCase( SECTION, + "Date.prototype.getDate.length", + 0, + Date.prototype.getDate.length ); +test(); + +function addTestCase( t ) { + var start = TimeFromYear(YearFromTime(t)); + var stop = TimeFromYear(YearFromTime(t) + 1); + + for (var d = start; d < stop; d += msPerDay) + { + new TestCase( SECTION, + "(new Date("+d+")).getDate()", + DateFromTime(LocalTime(d)), + (new Date(d)).getDate() ); + } +} diff --git a/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.10-6.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.10-6.js new file mode 100644 index 0000000000..84f57b8805 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.10-6.js @@ -0,0 +1,85 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.9.5.10-6.js'; + +/** + File Name: 15.9.5.10.js + ECMA Section: 15.9.5.10 + Description: Date.prototype.getDate + + 1.Let t be this time value. + 2.If t is NaN, return NaN. + 3.Return DateFromTime(LocalTime(t)). + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + +var SECTION = "15.9.5.10"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Date.prototype.getDate()"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +addTestCase( UTC_FEB_29_2000 ); + +new TestCase( SECTION, + "(new Date(NaN)).getDate()", + NaN, + (new Date(NaN)).getDate() ); + +new TestCase( SECTION, + "Date.prototype.getDate.length", + 0, + Date.prototype.getDate.length ); +test(); + +function addTestCase( t ) { + var start = TimeFromYear(YearFromTime(t)); + var stop = TimeFromYear(YearFromTime(t) + 1); + + for (var d = start; d < stop; d += msPerDay) + { + new TestCase( SECTION, + "(new Date("+d+")).getDate()", + DateFromTime(LocalTime(d)), + (new Date(d)).getDate() ); + } +} diff --git a/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.10-7.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.10-7.js new file mode 100644 index 0000000000..96ba89078a --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.10-7.js @@ -0,0 +1,85 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.9.5.10-7.js'; + +/** + File Name: 15.9.5.10.js + ECMA Section: 15.9.5.10 + Description: Date.prototype.getDate + + 1.Let t be this time value. + 2.If t is NaN, return NaN. + 3.Return DateFromTime(LocalTime(t)). + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + +var SECTION = "15.9.5.10"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Date.prototype.getDate()"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +addTestCase( UTC_JAN_1_2005 ); + +new TestCase( SECTION, + "(new Date(NaN)).getDate()", + NaN, + (new Date(NaN)).getDate() ); + +new TestCase( SECTION, + "Date.prototype.getDate.length", + 0, + Date.prototype.getDate.length ); +test(); + +function addTestCase( t ) { + var start = TimeFromYear(YearFromTime(t)); + var stop = TimeFromYear(YearFromTime(t) + 1); + + for (var d = start; d < stop; d += msPerDay) + { + new TestCase( SECTION, + "(new Date("+d+")).getDate()", + DateFromTime(LocalTime(d)), + (new Date(d)).getDate() ); + } +} diff --git a/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.10-8.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.10-8.js new file mode 100644 index 0000000000..bae220a94e --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.10-8.js @@ -0,0 +1,89 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.9.5.10-8.js'; + +/** + File Name: 15.9.5.10.js + ECMA Section: 15.9.5.10 + Description: Date.prototype.getDate + + 1.Let t be this time value. + 2.If t is NaN, return NaN. + 3.Return DateFromTime(LocalTime(t)). + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + +var SECTION = "15.9.5.10"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Date.prototype.getDate()"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +// some daylight savings time cases + +var DST_START_1998 = GetDSTStart(TimeFromYear(1998)); + +addTestCase( DST_START_1998 ); + +new TestCase( SECTION, + "(new Date(NaN)).getDate()", + NaN, + (new Date(NaN)).getDate() ); + +new TestCase( SECTION, + "Date.prototype.getDate.length", + 0, + Date.prototype.getDate.length ); +test(); + +function addTestCase( t ) { + var start = TimeFromYear(YearFromTime(t)); + var stop = TimeFromYear(YearFromTime(t) + 1); + + for (var d = start; d < stop; d += msPerDay) + { + new TestCase( SECTION, + "(new Date("+d+")).getDate()", + DateFromTime(LocalTime(d)), + (new Date(d)).getDate() ); + } +} diff --git a/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.10-9.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.10-9.js new file mode 100644 index 0000000000..a1cee0e682 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.10-9.js @@ -0,0 +1,89 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.9.5.10-9.js'; + +/** + File Name: 15.9.5.10.js + ECMA Section: 15.9.5.10 + Description: Date.prototype.getDate + + 1.Let t be this time value. + 2.If t is NaN, return NaN. + 3.Return DateFromTime(LocalTime(t)). + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + +var SECTION = "15.9.5.10"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Date.prototype.getDate()"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +// some daylight savings time cases + +var DST_START_1998 = GetDSTStart(TimeFromYear(1998)); + +addTestCase( DST_START_1998-1 ); + +new TestCase( SECTION, + "(new Date(NaN)).getDate()", + NaN, + (new Date(NaN)).getDate() ); + +new TestCase( SECTION, + "Date.prototype.getDate.length", + 0, + Date.prototype.getDate.length ); +test(); + +function addTestCase( t ) { + var start = TimeFromYear(YearFromTime(t)); + var stop = TimeFromYear(YearFromTime(t) + 1); + + for (var d = start; d < stop; d += msPerDay) + { + new TestCase( SECTION, + "(new Date("+d+")).getDate()", + DateFromTime(LocalTime(d)), + (new Date(d)).getDate() ); + } +} diff --git a/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.11-1.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.11-1.js new file mode 100644 index 0000000000..5c2439ba09 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.11-1.js @@ -0,0 +1,76 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.9.5.11-1.js'; + +/** + File Name: 15.9.5.11.js + ECMA Section: 15.9.5.11 + Description: Date.prototype.getUTCDate + + 1.Let t be this time value. + 2.If t is NaN, return NaN. + 1.Return DateFromTime(t). + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + +var SECTION = "15.9.5.11"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Date.prototype.getUTCDate()"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +addTestCase( TIME_NOW ); + +test(); + +function addTestCase( t ) { + var start = TimeFromYear(YearFromTime(t)); + var stop = TimeFromYear(YearFromTime(t) + 1); + + for (var d = start; d < stop; d += msPerDay) + { + new TestCase( SECTION, + "(new Date("+d+")).getUTCDate()", + DateFromTime(d), + (new Date(d)).getUTCDate() ); + } +} diff --git a/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.11-2.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.11-2.js new file mode 100644 index 0000000000..d9eda4cfc1 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.11-2.js @@ -0,0 +1,76 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.9.5.11-2.js'; + +/** + File Name: 15.9.5.11 + ECMA Section: 15.9.5.11 + Description: Date.prototype.getUTCDate + + 1.Let t be this time value. + 2.If t is NaN, return NaN. + 1.Return DateFromTime(t). + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + +var SECTION = "15.9.5.11"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Date.prototype.getUTCDate()"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +// addTestCase( TIME_0000 ); + +test(); + +function addTestCase( t ) { + var start = TimeFromYear(YearFromTime(t)); + var stop = TimeFromYear(YearFromTime(t) + 1); + + for (var d = start; d < stop; d += msPerDay) + { + new TestCase( SECTION, + "(new Date("+d+")).getUTCDate()", + DateFromTime(d), + (new Date(d)).getUTCDate() ); + } +} diff --git a/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.11-3.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.11-3.js new file mode 100644 index 0000000000..d35f8d5967 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.11-3.js @@ -0,0 +1,76 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.9.5.11-3.js'; + +/** + File Name: 15.9.5.11.js + ECMA Section: 15.9.5.11 + Description: Date.prototype.getUTCDate + + 1.Let t be this time value. + 2.If t is NaN, return NaN. + 1.Return DateFromTime(t). + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + +var SECTION = "15.9.5.11"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Date.prototype.getUTCDate()"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +addTestCase( TIME_1970 ); + +test(); + +function addTestCase( t ) { + var start = TimeFromYear(YearFromTime(t)); + var stop = TimeFromYear(YearFromTime(t) + 1); + + for (var d = start; d < stop; d += msPerDay) + { + new TestCase( SECTION, + "(new Date("+d+")).getUTCDate()", + DateFromTime(d), + (new Date(d)).getUTCDate() ); + } +} diff --git a/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.11-4.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.11-4.js new file mode 100644 index 0000000000..4fc9f2ee65 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.11-4.js @@ -0,0 +1,76 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.9.5.11-4.js'; + +/** + File Name: 15.9.5.11.js + ECMA Section: 15.9.5.11 + Description: Date.prototype.getUTCDate + + 1.Let t be this time value. + 2.If t is NaN, return NaN. + 1.Return DateFromTime(t). + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + +var SECTION = "15.9.5.11"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Date.prototype.getUTCDate()"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +addTestCase( TIME_1900 ); + +test(); + +function addTestCase( t ) { + var start = TimeFromYear(YearFromTime(t)); + var stop = TimeFromYear(YearFromTime(t) + 1); + + for (var d = start; d < stop; d += msPerDay) + { + new TestCase( SECTION, + "(new Date("+d+")).getUTCDate()", + DateFromTime(d), + (new Date(d)).getUTCDate() ); + } +} diff --git a/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.11-5.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.11-5.js new file mode 100644 index 0000000000..cee93a770b --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.11-5.js @@ -0,0 +1,76 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.9.5.11-5.js'; + +/** + File Name: 15.9.5.11.js + ECMA Section: 15.9.5.11 + Description: Date.prototype.getUTCDate + + 1.Let t be this time value. + 2.If t is NaN, return NaN. + 1.Return DateFromTime(t). + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + +var SECTION = "15.9.5.11"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Date.prototype.getUTCDate()"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +addTestCase( TIME_2000 ); + +test(); + +function addTestCase( t ) { + var start = TimeFromYear(YearFromTime(t)); + var stop = TimeFromYear(YearFromTime(t) + 1); + + for (var d = start; d < stop; d += msPerDay) + { + new TestCase( SECTION, + "(new Date("+d+")).getUTCDate()", + DateFromTime(d), + (new Date(d)).getUTCDate() ); + } +} diff --git a/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.11-6.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.11-6.js new file mode 100644 index 0000000000..b756e43a7e --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.11-6.js @@ -0,0 +1,76 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.9.5.11-6.js'; + +/** + File Name: 15.9.5.11.js + ECMA Section: 15.9.5.11 + Description: Date.prototype.getUTCDate + + 1.Let t be this time value. + 2.If t is NaN, return NaN. + 1.Return DateFromTime(t). + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + +var SECTION = "15.9.5.11"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Date.prototype.getUTCDate()"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +addTestCase( UTC_FEB_29_2000 ); + +test(); + +function addTestCase( t ) { + var start = TimeFromYear(YearFromTime(t)); + var stop = TimeFromYear(YearFromTime(t) + 1); + + for (var d = start; d < stop; d += msPerDay) + { + new TestCase( SECTION, + "(new Date("+d+")).getUTCDate()", + DateFromTime(d), + (new Date(d)).getUTCDate() ); + } +} diff --git a/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.11-7.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.11-7.js new file mode 100644 index 0000000000..65c5c1c765 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.11-7.js @@ -0,0 +1,76 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.9.5.11-7.js'; + +/** + File Name: 15.9.5.11.js + ECMA Section: 15.9.5.11 + Description: Date.prototype.getUTCDate + + 1.Let t be this time value. + 2.If t is NaN, return NaN. + 1.Return DateFromTime(t). + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + +var SECTION = "15.9.5.11"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Date.prototype.getUTCDate()"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +addTestCase( UTC_JAN_1_2005 ); + +test(); + +function addTestCase( t ) { + var start = TimeFromYear(YearFromTime(t)); + var stop = TimeFromYear(YearFromTime(t) + 1); + + for (var d = start; d < stop; d += msPerDay) + { + new TestCase( SECTION, + "(new Date("+d+")).getUTCDate()", + DateFromTime(d), + (new Date(d)).getUTCDate() ); + } +} diff --git a/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.12-1.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.12-1.js new file mode 100644 index 0000000000..c173ffb193 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.12-1.js @@ -0,0 +1,77 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.9.5.12-1.js'; + +/** + File Name: 15.9.5.12.js + ECMA Section: 15.9.5.12 + Description: Date.prototype.getDay + + + 1. Let t be this time value. + 2. If t is NaN, return NaN. + 3. Return WeekDay(LocalTime(t)). + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + +var SECTION = "15.9.5.12"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Date.prototype.getDay()"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +addTestCase( TIME_NOW ); + +test(); + +function addTestCase( t ) { + var start = TimeFromYear(YearFromTime(t)); + var stop = TimeFromYear(YearFromTime(t) + 1); + + for (var d = start; d < stop; d += msPerDay) + { + new TestCase( SECTION, + "(new Date("+d+")).getDay()", + WeekDay((LocalTime(d))), + (new Date(d)).getDay() ); + } +} diff --git a/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.12-2.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.12-2.js new file mode 100644 index 0000000000..5967da6ef6 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.12-2.js @@ -0,0 +1,77 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.9.5.12-2.js'; + +/** + File Name: 15.9.5.12.js + ECMA Section: 15.9.5.12 + Description: Date.prototype.getDay + + + 1. Let t be this time value. + 2. If t is NaN, return NaN. + 3. Return WeekDay(LocalTime(t)). + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + +var SECTION = "15.9.5.12"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Date.prototype.getDay()"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +// addTestCase( TIME_0000 ); + +test(); + +function addTestCase( t ) { + var start = TimeFromYear(YearFromTime(t)); + var stop = TimeFromYear(YearFromTime(t) + 1); + + for (var d = start; d < stop; d += msPerDay) + { + new TestCase( SECTION, + "(new Date("+d+")).getDay()", + WeekDay((LocalTime(d))), + (new Date(d)).getDay() ); + } +} diff --git a/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.12-3.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.12-3.js new file mode 100644 index 0000000000..9ce226665c --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.12-3.js @@ -0,0 +1,77 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.9.5.12-3.js'; + +/** + File Name: 15.9.5.12.js + ECMA Section: 15.9.5.12 + Description: Date.prototype.getDay + + + 1. Let t be this time value. + 2. If t is NaN, return NaN. + 3. Return WeekDay(LocalTime(t)). + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + +var SECTION = "15.9.5.12"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Date.prototype.getDay()"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +addTestCase( TIME_1970 ); + +test(); + +function addTestCase( t ) { + var start = TimeFromYear(YearFromTime(t)); + var stop = TimeFromYear(YearFromTime(t) + 1); + + for (var d = start; d < stop; d += msPerDay) + { + new TestCase( SECTION, + "(new Date("+d+")).getDay()", + WeekDay((LocalTime(d))), + (new Date(d)).getDay() ); + } +} diff --git a/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.12-4.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.12-4.js new file mode 100644 index 0000000000..3b752a1767 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.12-4.js @@ -0,0 +1,77 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.9.5.12-4.js'; + +/** + File Name: 15.9.5.12.js + ECMA Section: 15.9.5.12 + Description: Date.prototype.getDay + + + 1. Let t be this time value. + 2. If t is NaN, return NaN. + 3. Return WeekDay(LocalTime(t)). + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + +var SECTION = "15.9.5.12"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Date.prototype.getDay()"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +addTestCase( TIME_1900 ); + +test(); + +function addTestCase( t ) { + var start = TimeFromYear(YearFromTime(t)); + var stop = TimeFromYear(YearFromTime(t) + 1); + + for (var d = start; d < stop; d += msPerDay) + { + new TestCase( SECTION, + "(new Date("+d+")).getDay()", + WeekDay((LocalTime(d))), + (new Date(d)).getDay() ); + } +} diff --git a/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.12-5.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.12-5.js new file mode 100644 index 0000000000..7fe153a5ea --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.12-5.js @@ -0,0 +1,77 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.9.5.12-5.js'; + +/** + File Name: 15.9.5.12.js + ECMA Section: 15.9.5.12 + Description: Date.prototype.getDay + + + 1. Let t be this time value. + 2. If t is NaN, return NaN. + 3. Return WeekDay(LocalTime(t)). + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + +var SECTION = "15.9.5.12"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Date.prototype.getDay()"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +addTestCase( TIME_2000 ); + +test(); + +function addTestCase( t ) { + var start = TimeFromYear(YearFromTime(t)); + var stop = TimeFromYear(YearFromTime(t) + 1); + + for (var d = start; d < stop; d += msPerDay) + { + new TestCase( SECTION, + "(new Date("+d+")).getDay()", + WeekDay((LocalTime(d))), + (new Date(d)).getDay() ); + } +} diff --git a/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.12-6.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.12-6.js new file mode 100644 index 0000000000..663ab81b2d --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.12-6.js @@ -0,0 +1,77 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.9.5.12-6.js'; + +/** + File Name: 15.9.5.12.js + ECMA Section: 15.9.5.12 + Description: Date.prototype.getDay + + + 1. Let t be this time value. + 2. If t is NaN, return NaN. + 3. Return WeekDay(LocalTime(t)). + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + +var SECTION = "15.9.5.12"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Date.prototype.getDay()"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +addTestCase( UTC_FEB_29_2000 ); + +test(); + +function addTestCase( t ) { + var start = TimeFromYear(YearFromTime(t)); + var stop = TimeFromYear(YearFromTime(t) + 1); + + for (var d = start; d < stop; d += msPerDay) + { + new TestCase( SECTION, + "(new Date("+d+")).getDay()", + WeekDay((LocalTime(d))), + (new Date(d)).getDay() ); + } +} diff --git a/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.12-7.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.12-7.js new file mode 100644 index 0000000000..23a0218058 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.12-7.js @@ -0,0 +1,77 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.9.5.12-7.js'; + +/** + File Name: 15.9.5.12.js + ECMA Section: 15.9.5.12 + Description: Date.prototype.getDay + + + 1. Let t be this time value. + 2. If t is NaN, return NaN. + 3. Return WeekDay(LocalTime(t)). + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + +var SECTION = "15.9.5.12"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Date.prototype.getDay()"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +addTestCase( UTC_JAN_1_2005 ); + +test(); + +function addTestCase( t ) { + var start = TimeFromYear(YearFromTime(t)); + var stop = TimeFromYear(YearFromTime(t) + 1); + + for (var d = start; d < stop; d += msPerDay) + { + new TestCase( SECTION, + "(new Date("+d+")).getDay()", + WeekDay((LocalTime(d))), + (new Date(d)).getDay() ); + } +} diff --git a/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.12-8.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.12-8.js new file mode 100644 index 0000000000..4f3f66e0ce --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.12-8.js @@ -0,0 +1,71 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.9.5.12-8.js'; + +/** + File Name: 15.9.5.12 + ECMA Section: 15.9.5.12 + Description: Date.prototype.getDay + + + 1. Let t be this time value. + 2. If t is NaN, return NaN. + 3. Return WeekDay(LocalTime(t)). + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + +var SECTION = "15.9.5.12"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Date.prototype.getDay()"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +new TestCase( SECTION, + "(new Date(NaN)).getDay()", + NaN, + (new Date(NaN)).getDay() ); + +new TestCase( SECTION, + "Date.prototype.getDay.length", + 0, + Date.prototype.getDay.length ); +test(); diff --git a/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.13-1.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.13-1.js new file mode 100644 index 0000000000..d82f39a7e0 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.13-1.js @@ -0,0 +1,79 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.9.5.13-1.js'; + +/** + File Name: 15.9.5.13.js + ECMA Section: 15.9.5.13 + Description: Date.prototype.getUTCDay + + 1.Let t be this time value. + 2.If t is NaN, return NaN. + 3.Return WeekDay(t). + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + +var SECTION = "15.9.5.13"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Date.prototype.getUTCDay()"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +// get the current time +var now = (new Date()).valueOf(); + +addTestCase( now ); + +test(); + +function addTestCase( t ) { + var start = TimeFromYear(YearFromTime(t)); + var stop = TimeFromYear(YearFromTime(t) + 1); + + for (var d = start; d < stop; d += msPerDay) + { + new TestCase( SECTION, + "(new Date("+d+")).getUTCDay()", + WeekDay((d)), + (new Date(d)).getUTCDay() ); + } +} diff --git a/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.13-2.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.13-2.js new file mode 100644 index 0000000000..13f0d080e3 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.13-2.js @@ -0,0 +1,76 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.9.5.13-2.js'; + +/** + File Name: 15.9.5.13 + ECMA Section: 15.9.5.13 + Description: Date.prototype.getUTCDay + + 1.Let t be this time value. + 2.If t is NaN, return NaN. + 3.Return WeekDay(t). + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + +var SECTION = "15.9.5.13"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Date.prototype.getUTCDay()"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +addTestCase( TIME_0000 ); + +test(); + +function addTestCase( t ) { + var start = TimeFromYear(YearFromTime(t)); + var stop = TimeFromYear(YearFromTime(t) + 1); + + for (var d = start; d < stop; d += msPerDay) + { + new TestCase( SECTION, + "(new Date("+d+")).getUTCDay()", + WeekDay((d)), + (new Date(d)).getUTCDay() ); + } +} diff --git a/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.13-3.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.13-3.js new file mode 100644 index 0000000000..7c78072ee5 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.13-3.js @@ -0,0 +1,77 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.9.5.13-3.js'; + +/** + File Name: 15.9.5.13.js + ECMA Section: 15.9.5.13 + Description: Date.prototype.getUTCDay + + 1.Let t be this time value. + 2.If t is NaN, return NaN. + 3.Return WeekDay(t). + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + +var SECTION = "15.9.5.13"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Date.prototype.getUTCDay()"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +addTestCase( TIME_1970 ); + +test(); + +function addTestCase( t ) { + var start = TimeFromYear(YearFromTime(t)); + var stop = TimeFromYear(YearFromTime(t) + 1); + + for (var d = start; d < stop; d += msPerDay) + { + new TestCase( SECTION, + "(new Date("+d+")).getUTCDay()", + WeekDay((d)), + (new Date(d)).getUTCDay() ); + } +} + diff --git a/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.13-4.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.13-4.js new file mode 100644 index 0000000000..bcfcfb8c00 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.13-4.js @@ -0,0 +1,77 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.9.5.13-4.js'; + +/** + File Name: 15.9.5.13.js + ECMA Section: 15.9.5.13 + Description: Date.prototype.getUTCDay + + 1.Let t be this time value. + 2.If t is NaN, return NaN. + 3.Return WeekDay(t). + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + +var SECTION = "15.9.5.13"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Date.prototype.getUTCDay()"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +addTestCase( TIME_1900 ); + +test(); + +function addTestCase( t ) { + var start = TimeFromYear(YearFromTime(t)); + var stop = TimeFromYear(YearFromTime(t) + 1); + + for (var d = start; d < stop; d += msPerDay) + { + new TestCase( SECTION, + "(new Date("+d+")).getUTCDay()", + WeekDay((d)), + (new Date(d)).getUTCDay() ); + } +} + diff --git a/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.13-5.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.13-5.js new file mode 100644 index 0000000000..96b1acb170 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.13-5.js @@ -0,0 +1,77 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.9.5.13-5.js'; + +/** + File Name: 15.9.5.13.js + ECMA Section: 15.9.5.13 + Description: Date.prototype.getUTCDay + + 1.Let t be this time value. + 2.If t is NaN, return NaN. + 3.Return WeekDay(t). + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + +var SECTION = "15.9.5.13"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Date.prototype.getUTCDay()"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +addTestCase( TIME_2000 ); + +test(); + +function addTestCase( t ) { + var start = TimeFromYear(YearFromTime(t)); + var stop = TimeFromYear(YearFromTime(t) + 1); + + for (var d = start; d < stop; d += msPerDay) + { + new TestCase( SECTION, + "(new Date("+d+")).getUTCDay()", + WeekDay((d)), + (new Date(d)).getUTCDay() ); + } +} + diff --git a/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.13-6.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.13-6.js new file mode 100644 index 0000000000..e749ad6b7f --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.13-6.js @@ -0,0 +1,77 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.9.5.13-6.js'; + +/** + File Name: 15.9.5.13.js + ECMA Section: 15.9.5.13 + Description: Date.prototype.getUTCDay + + 1.Let t be this time value. + 2.If t is NaN, return NaN. + 3.Return WeekDay(t). + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + +var SECTION = "15.9.5.13"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Date.prototype.getUTCDay()"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +addTestCase( UTC_FEB_29_2000 ); + +test(); + +function addTestCase( t ) { + var start = TimeFromYear(YearFromTime(t)); + var stop = TimeFromYear(YearFromTime(t) + 1); + + for (var d = start; d < stop; d += msPerDay) + { + new TestCase( SECTION, + "(new Date("+d+")).getUTCDay()", + WeekDay((d)), + (new Date(d)).getUTCDay() ); + } +} + diff --git a/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.13-7.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.13-7.js new file mode 100644 index 0000000000..63607f8d2d --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.13-7.js @@ -0,0 +1,76 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.9.5.13-7.js'; + +/** + File Name: 15.9.5.13.js + ECMA Section: 15.9.5.13 + Description: Date.prototype.getUTCDay + + 1.Let t be this time value. + 2.If t is NaN, return NaN. + 3.Return WeekDay(t). + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + +var SECTION = "15.9.5.13"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Date.prototype.getUTCDay()"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +addTestCase( UTC_JAN_1_2005 ); + +test(); + +function addTestCase( t ) { + var start = TimeFromYear(YearFromTime(t)); + var stop = TimeFromYear(YearFromTime(t) + 1); + + for (var d = start; d < stop; d += msPerDay) + { + new TestCase( SECTION, + "(new Date("+d+")).getUTCDay()", + WeekDay((d)), + (new Date(d)).getUTCDay() ); + } +} diff --git a/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.13-8.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.13-8.js new file mode 100644 index 0000000000..75d42b200b --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.13-8.js @@ -0,0 +1,71 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.9.5.13-8.js'; + +/** + File Name: 15.9.5.13.js + ECMA Section: 15.9.5.13 + Description: Date.prototype.getUTCDay + + 1.Let t be this time value. + 2.If t is NaN, return NaN. + 3.Return WeekDay(t). + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + +var SECTION = "15.9.5.13"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Date.prototype.getUTCDay()"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +new TestCase( SECTION, + "(new Date(NaN)).getUTCDay()", + NaN, + (new Date(NaN)).getUTCDay() ); + +new TestCase( SECTION, + "Date.prototype.getUTCDay.length", + 0, + Date.prototype.getUTCDay.length ); + +test(); diff --git a/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.14.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.14.js new file mode 100644 index 0000000000..5a3f8216da --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.14.js @@ -0,0 +1,87 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.9.5.14.js'; + +/** + File Name: 15.9.5.14.js + ECMA Section: 15.9.5.14 + Description: Date.prototype.getHours + 1. Let t be this time value. + 2. If t is NaN, return NaN. + 3. Return HourFromTime(LocalTime(t)). + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + +var SECTION = "15.9.5.14"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Date.prototype.getHours()"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +addTestCase( TIME_NOW ); +addTestCase( TIME_0000 ); +addTestCase( TIME_1970 ); +addTestCase( TIME_1900 ); +addTestCase( TIME_2000 ); +addTestCase( UTC_FEB_29_2000 ); +addTestCase( UTC_JAN_1_2005 ); + +new TestCase( SECTION, + "(new Date(NaN)).getHours()", + NaN, + (new Date(NaN)).getHours() ); + +new TestCase( SECTION, + "Date.prototype.getHours.length", + 0, + Date.prototype.getHours.length ); +test(); + +function addTestCase( t ) { + for ( h = 0; h < 24; h+=4 ) { + t += msPerHour; + new TestCase( SECTION, + "(new Date("+t+")).getHours()", + HourFromTime((LocalTime(t))), + (new Date(t)).getHours() ); + } +} diff --git a/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.15.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.15.js new file mode 100644 index 0000000000..ca2babd7ef --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.15.js @@ -0,0 +1,88 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.9.5.15.js'; + +/** + File Name: 15.9.5.15.js + ECMA Section: 15.9.5.15 + Description: Date.prototype.getUTCHours + + 1. Let t be this time value. + 2. If t is NaN, return NaN. + 3. Return HourFromTime(t). + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + +var SECTION = "15.9.5.15"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Date.prototype.getUTCHours()"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +addTestCase( TIME_NOW ); +addTestCase( TIME_0000 ); +addTestCase( TIME_1970 ); +addTestCase( TIME_1900 ); +addTestCase( TIME_2000 ); +addTestCase( UTC_FEB_29_2000 ); +addTestCase( UTC_JAN_1_2005 ); + +new TestCase( SECTION, + "(new Date(NaN)).getUTCHours()", + NaN, + (new Date(NaN)).getUTCHours() ); + +new TestCase( SECTION, + "Date.prototype.getUTCHours.length", + 0, + Date.prototype.getUTCHours.length ); +test(); + +function addTestCase( t ) { + for ( h = 0; h < 24; h+=3 ) { + t += msPerHour; + new TestCase( SECTION, + "(new Date("+t+")).getUTCHours()", + HourFromTime((t)), + (new Date(t)).getUTCHours() ); + } +} diff --git a/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.16.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.16.js new file mode 100644 index 0000000000..e791b74eae --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.16.js @@ -0,0 +1,87 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.9.5.16.js'; + +/** + File Name: 15.9.5.16.js + ECMA Section: 15.9.5.16 + Description: Date.prototype.getMinutes + 1.Let t be this time value. + 2.If t is NaN, return NaN. + 3.Return MinFromTime(LocalTime(t)). + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + +var SECTION = "15.9.5.16"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Date.prototype.getMinutes()"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +addTestCase( TIME_NOW ); +addTestCase( TIME_0000 ); +addTestCase( TIME_1970 ); +addTestCase( TIME_1900 ); +addTestCase( TIME_2000 ); +addTestCase( UTC_FEB_29_2000 ); +addTestCase( UTC_JAN_1_2005 ); + +new TestCase( SECTION, + "(new Date(NaN)).getMinutes()", + NaN, + (new Date(NaN)).getMinutes() ); + +new TestCase( SECTION, + "Date.prototype.getMinutes.length", + 0, + Date.prototype.getMinutes.length ); +test(); + +function addTestCase( t ) { + for ( m = 0; m <= 60; m+=10 ) { + t += msPerMinute; + new TestCase( SECTION, + "(new Date("+t+")).getMinutes()", + MinFromTime((LocalTime(t))), + (new Date(t)).getMinutes() ); + } +} diff --git a/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.17.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.17.js new file mode 100644 index 0000000000..e9b30c3eed --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.17.js @@ -0,0 +1,88 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.9.5.17.js'; + +/** + File Name: 15.9.5.17.js + ECMA Section: 15.9.5.17 + Description: Date.prototype.getUTCMinutes + + 1. Let t be this time value. + 2. If t is NaN, return NaN. + 3. Return MinFromTime(t). + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + +var SECTION = "15.9.5.17"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Date.prototype.getUTCMinutes()"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +addTestCase( TIME_NOW ); +addTestCase( TIME_0000 ); +addTestCase( TIME_1970 ); +addTestCase( TIME_1900 ); +addTestCase( TIME_2000 ); +addTestCase( UTC_FEB_29_2000 ); +addTestCase( UTC_JAN_1_2005 ); + +new TestCase( SECTION, + "(new Date(NaN)).getUTCMinutes()", + NaN, + (new Date(NaN)).getUTCMinutes() ); + +new TestCase( SECTION, + "Date.prototype.getUTCMinutes.length", + 0, + Date.prototype.getUTCMinutes.length ); +test(); + +function addTestCase( t ) { + for ( m = 0; m <= 60; m+=10 ) { + t += msPerMinute; + new TestCase( SECTION, + "(new Date("+t+")).getUTCMinutes()", + MinFromTime(t), + (new Date(t)).getUTCMinutes() ); + } +} diff --git a/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.18.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.18.js new file mode 100644 index 0000000000..f735168efe --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.18.js @@ -0,0 +1,88 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.9.5.18.js'; + +/** + File Name: 15.9.5.18.js + ECMA Section: 15.9.5.18 + Description: Date.prototype.getSeconds + + 1. Let t be this time value. + 2. If t is NaN, return NaN. + 3. Return SecFromTime(LocalTime(t)). + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + +var SECTION = "15.9.5.18"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Date.prototype.getSeconds()"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +addTestCase( TIME_NOW ); +addTestCase( TIME_0000 ); +addTestCase( TIME_1970 ); +addTestCase( TIME_1900 ); +addTestCase( TIME_2000 ); +addTestCase( UTC_FEB_29_2000 ); +addTestCase( UTC_JAN_1_2005 ); + +new TestCase( SECTION, + "(new Date(NaN)).getSeconds()", + NaN, + (new Date(NaN)).getSeconds() ); + +new TestCase( SECTION, + "Date.prototype.getSeconds.length", + 0, + Date.prototype.getSeconds.length ); +test(); + +function addTestCase( t ) { + for ( m = 0; m <= 60; m+=10 ) { + t += 1000; + new TestCase( SECTION, + "(new Date("+t+")).getSeconds()", + SecFromTime(LocalTime(t)), + (new Date(t)).getSeconds() ); + } +} diff --git a/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.19.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.19.js new file mode 100644 index 0000000000..2a0d7430ef --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.19.js @@ -0,0 +1,88 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.9.5.19.js'; + +/** + File Name: 15.9.5.19.js + ECMA Section: 15.9.5.19 + Description: Date.prototype.getUTCSeconds + + 1. Let t be this time value. + 2. If t is NaN, return NaN. + 3. Return SecFromTime(t). + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + +var SECTION = "15.9.5.19"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Date.prototype.getUTCSeconds()"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +addTestCase( TIME_NOW ); +addTestCase( TIME_0000 ); +addTestCase( TIME_1970 ); +addTestCase( TIME_1900 ); +addTestCase( TIME_2000 ); +addTestCase( UTC_FEB_29_2000 ); +addTestCase( UTC_JAN_1_2005 ); + +new TestCase( SECTION, + "(new Date(NaN)).getUTCSeconds()", + NaN, + (new Date(NaN)).getUTCSeconds() ); + +new TestCase( SECTION, + "Date.prototype.getUTCSeconds.length", + 0, + Date.prototype.getUTCSeconds.length ); +test(); + +function addTestCase( t ) { + for ( m = 0; m <= 60; m+=10 ) { + t += 1000; + new TestCase( SECTION, + "(new Date("+t+")).getUTCSeconds()", + SecFromTime(t), + (new Date(t)).getUTCSeconds() ); + } +} diff --git a/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.2-1.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.2-1.js new file mode 100644 index 0000000000..7ec3c691c8 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.2-1.js @@ -0,0 +1,151 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.9.5.2-1.js'; + +/** + File Name: 15.9.5.2.js + ECMA Section: 15.9.5.2 Date.prototype.toString + Description: + This function returns a string value. The contents of the string are + implementation dependent, but are intended to represent the Date in a + convenient, human-readable form in the current time zone. + + The toString function is not generic; it generates a runtime error if its + this value is not a Date object. Therefore it cannot be transferred to + other kinds of objects for use as a method. + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + +var SECTION = "15.9.5.2"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Date.prototype.toString"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +new TestCase( SECTION, + "Date.prototype.toString.length", + 0, + Date.prototype.toString.length ); + +var now = new Date(); + +// can't test the content of the string, but can verify that the string is +// parsable by Date.parse + +new TestCase( SECTION, + "Math.abs(Date.parse(now.toString()) - now.valueOf()) < 1000", + true, + Math.abs(Date.parse(now.toString()) - now.valueOf()) < 1000 ); + +new TestCase( SECTION, + "typeof now.toString()", + "string", + typeof now.toString() ); +// 1970 + +new TestCase( SECTION, + "Date.parse( (new Date(0)).toString() )", + 0, + Date.parse( (new Date(0)).toString() ) ); + +new TestCase( SECTION, + "Date.parse( (new Date("+TZ_ADJUST+")).toString() )", + TZ_ADJUST, + Date.parse( (new Date(TZ_ADJUST)).toString() ) ); + +// 1900 +new TestCase( SECTION, + "Date.parse( (new Date("+TIME_1900+")).toString() )", + TIME_1900, + Date.parse( (new Date(TIME_1900)).toString() ) ); + +new TestCase( SECTION, + "Date.parse( (new Date("+TIME_1900 -TZ_ADJUST+")).toString() )", + TIME_1900 -TZ_ADJUST, + Date.parse( (new Date(TIME_1900 -TZ_ADJUST)).toString() ) ); + +// 2000 +new TestCase( SECTION, + "Date.parse( (new Date("+TIME_2000+")).toString() )", + TIME_2000, + Date.parse( (new Date(TIME_2000)).toString() ) ); + +new TestCase( SECTION, + "Date.parse( (new Date("+TIME_2000 -TZ_ADJUST+")).toString() )", + TIME_2000 -TZ_ADJUST, + Date.parse( (new Date(TIME_2000 -TZ_ADJUST)).toString() ) ); + +// 29 Feb 2000 + +new TestCase( SECTION, + "Date.parse( (new Date("+UTC_FEB_29_2000+")).toString() )", + UTC_FEB_29_2000, + Date.parse( (new Date(UTC_FEB_29_2000)).toString() ) ); + +new TestCase( SECTION, + "Date.parse( (new Date("+(UTC_FEB_29_2000-1000)+")).toString() )", + UTC_FEB_29_2000-1000, + Date.parse( (new Date(UTC_FEB_29_2000-1000)).toString() ) ); + + +new TestCase( SECTION, + "Date.parse( (new Date("+(UTC_FEB_29_2000-TZ_ADJUST)+")).toString() )", + UTC_FEB_29_2000-TZ_ADJUST, + Date.parse( (new Date(UTC_FEB_29_2000-TZ_ADJUST)).toString() ) ); +// 2O05 + +new TestCase( SECTION, + "Date.parse( (new Date("+UTC_JAN_1_2005+")).toString() )", + UTC_JAN_1_2005, + Date.parse( (new Date(UTC_JAN_1_2005)).toString() ) ); + +new TestCase( SECTION, + "Date.parse( (new Date("+(UTC_JAN_1_2005-1000)+")).toString() )", + UTC_JAN_1_2005-1000, + Date.parse( (new Date(UTC_JAN_1_2005-1000)).toString() ) ); + +new TestCase( SECTION, + "Date.parse( (new Date("+(UTC_JAN_1_2005-TZ_ADJUST)+")).toString() )", + UTC_JAN_1_2005-TZ_ADJUST, + Date.parse( (new Date(UTC_JAN_1_2005-TZ_ADJUST)).toString() ) ); + +test(); diff --git a/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.2-2-n.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.2-2-n.js new file mode 100644 index 0000000000..c5513b8168 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.2-2-n.js @@ -0,0 +1,84 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.9.5.2-2-n.js'; + +/** + File Name: 15.9.5.2-2.js + ECMA Section: 15.9.5.2 Date.prototype.toString + Description: + This function returns a string value. The contents of the string are + implementation dependent, but are intended to represent the Date in a + convenient, human-readable form in the current time zone. + + The toString function is not generic; it generates a runtime error if its + this value is not a Date object. Therefore it cannot be transferred to + other kinds of objects for use as a method. + + + This verifies that calling toString on an object that is not a string + generates a runtime error. + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + +var SECTION = "15.9.5.2-2"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Date.prototype.toString"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +var OBJ = new MyObject( new Date(0) ); + +DESCRIPTION = "var OBJ = new MyObject( new Date(0) ); OBJ.toString()"; +EXPECTED = "error"; + +new TestCase( SECTION, + "var OBJ = new MyObject( new Date(0) ); OBJ.toString()", + "error", + eval("OBJ.toString()") ); +test(); + +function MyObject( value ) { + this.value = value; + this.valueOf = new Function( "return this.value" ); + this.toString = Date.prototype.toString; + return this; +} diff --git a/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.2.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.2.js new file mode 100644 index 0000000000..ef2df0510b --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.2.js @@ -0,0 +1,151 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.9.5.2.js'; + +/** + File Name: 15.9.5.2.js + ECMA Section: 15.9.5.2 Date.prototype.toString + Description: + This function returns a string value. The contents of the string are + implementation dependent, but are intended to represent the Date in a + convenient, human-readable form in the current time zone. + + The toString function is not generic; it generates a runtime error if its + this value is not a Date object. Therefore it cannot be transferred to + other kinds of objects for use as a method. + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + +var SECTION = "15.9.5.2"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Date.prototype.toString"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +new TestCase( SECTION, + "Date.prototype.toString.length", + 0, + Date.prototype.toString.length ); + +var now = new Date(); + +// can't test the content of the string, but can verify that the string is +// parsable by Date.parse + +new TestCase( SECTION, + "Math.abs(Date.parse(now.toString()) - now.valueOf()) < 1000", + true, + Math.abs(Date.parse(now.toString()) - now.valueOf()) < 1000 ); + +new TestCase( SECTION, + "typeof now.toString()", + "string", + typeof now.toString() ); +// 1970 + +new TestCase( SECTION, + "Date.parse( (new Date(0)).toString() )", + 0, + Date.parse( (new Date(0)).toString() ) ); + +new TestCase( SECTION, + "Date.parse( (new Date("+TZ_ADJUST+")).toString() )", + TZ_ADJUST, + Date.parse( (new Date(TZ_ADJUST)).toString() ) ); + +// 1900 +new TestCase( SECTION, + "Date.parse( (new Date("+TIME_1900+")).toString() )", + TIME_1900, + Date.parse( (new Date(TIME_1900)).toString() ) ); + +new TestCase( SECTION, + "Date.parse( (new Date("+TIME_1900 -TZ_ADJUST+")).toString() )", + TIME_1900 -TZ_ADJUST, + Date.parse( (new Date(TIME_1900 -TZ_ADJUST)).toString() ) ); + +// 2000 +new TestCase( SECTION, + "Date.parse( (new Date("+TIME_2000+")).toString() )", + TIME_2000, + Date.parse( (new Date(TIME_2000)).toString() ) ); + +new TestCase( SECTION, + "Date.parse( (new Date("+TIME_2000 -TZ_ADJUST+")).toString() )", + TIME_2000 -TZ_ADJUST, + Date.parse( (new Date(TIME_2000 -TZ_ADJUST)).toString() ) ); + +// 29 Feb 2000 + +new TestCase( SECTION, + "Date.parse( (new Date("+UTC_FEB_29_2000+")).toString() )", + UTC_FEB_29_2000, + Date.parse( (new Date(UTC_FEB_29_2000)).toString() ) ); + +new TestCase( SECTION, + "Date.parse( (new Date("+(UTC_FEB_29_2000-1000)+")).toString() )", + UTC_FEB_29_2000-1000, + Date.parse( (new Date(UTC_FEB_29_2000-1000)).toString() ) ); + + +new TestCase( SECTION, + "Date.parse( (new Date("+(UTC_FEB_29_2000-TZ_ADJUST)+")).toString() )", + UTC_FEB_29_2000-TZ_ADJUST, + Date.parse( (new Date(UTC_FEB_29_2000-TZ_ADJUST)).toString() ) ); +// 2O05 + +new TestCase( SECTION, + "Date.parse( (new Date("+UTC_JAN_1_2005+")).toString() )", + UTC_JAN_1_2005, + Date.parse( (new Date(UTC_JAN_1_2005)).toString() ) ); + +new TestCase( SECTION, + "Date.parse( (new Date("+(UTC_JAN_1_2005-1000)+")).toString() )", + UTC_JAN_1_2005-1000, + Date.parse( (new Date(UTC_JAN_1_2005-1000)).toString() ) ); + +new TestCase( SECTION, + "Date.parse( (new Date("+(UTC_JAN_1_2005-TZ_ADJUST)+")).toString() )", + UTC_JAN_1_2005-TZ_ADJUST, + Date.parse( (new Date(UTC_JAN_1_2005-TZ_ADJUST)).toString() ) ); + +test(); diff --git a/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.20.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.20.js new file mode 100644 index 0000000000..fb3dafde2c --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.20.js @@ -0,0 +1,88 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.9.5.20.js'; + +/** + File Name: 15.9.5.20.js + ECMA Section: 15.9.5.20 + Description: Date.prototype.getMilliseconds + + 1. Let t be this time value. + 2. If t is NaN, return NaN. + 3. Return msFromTime(LocalTime(t)). + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + +var SECTION = "15.9.5.20"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Date.prototype.getMilliseconds()"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +addTestCase( TIME_NOW ); +addTestCase( TIME_0000 ); +addTestCase( TIME_1970 ); +addTestCase( TIME_1900 ); +addTestCase( TIME_2000 ); +addTestCase( UTC_FEB_29_2000 ); +addTestCase( UTC_JAN_1_2005 ); + +new TestCase( SECTION, + "(new Date(NaN)).getMilliseconds()", + NaN, + (new Date(NaN)).getMilliseconds() ); + +new TestCase( SECTION, + "Date.prototype.getMilliseconds.length", + 0, + Date.prototype.getMilliseconds.length ); +test(); + +function addTestCase( t ) { + for ( m = 0; m <= 1000; m+=100 ) { + t++; + new TestCase( SECTION, + "(new Date("+t+")).getMilliseconds()", + msFromTime(LocalTime(t)), + (new Date(t)).getMilliseconds() ); + } +} diff --git a/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.21-1.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.21-1.js new file mode 100644 index 0000000000..4eea164305 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.21-1.js @@ -0,0 +1,70 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.9.5.21-1.js'; + +/** + File Name: 15.9.5.21.js + ECMA Section: 15.9.5.21 + Description: Date.prototype.getUTCMilliseconds + + 1. Let t be this time value. + 2. If t is NaN, return NaN. + 3. Return msFromTime(t). + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + +var SECTION = "15.9.5.21"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Date.prototype.getUTCMilliseconds()"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +addTestCase( TIME_NOW ); + +test(); + +function addTestCase( t ) { + new TestCase( SECTION, + "(new Date("+t+")).getUTCMilliseconds()", + msFromTime(t), + (new Date(t)).getUTCMilliseconds() ); +} diff --git a/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.21-2.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.21-2.js new file mode 100644 index 0000000000..37b443117a --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.21-2.js @@ -0,0 +1,70 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.9.5.21-2.js'; + +/** + File Name: 15.9.5.21.js + ECMA Section: 15.9.5.21 + Description: Date.prototype.getUTCMilliseconds + + 1. Let t be this time value. + 2. If t is NaN, return NaN. + 3. Return msFromTime(t). + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + +var SECTION = "15.9.5.21"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Date.prototype.getUTCMilliseconds()"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +addTestCase( TIME_0000 ); + +test(); + +function addTestCase( t ) { + new TestCase( SECTION, + "(new Date("+t+")).getUTCMilliseconds()", + msFromTime(t), + (new Date(t)).getUTCMilliseconds() ); +} diff --git a/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.21-3.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.21-3.js new file mode 100644 index 0000000000..d1d96cb7a3 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.21-3.js @@ -0,0 +1,70 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.9.5.21-3.js'; + +/** + File Name: 15.9.5.21.js + ECMA Section: 15.9.5.21 + Description: Date.prototype.getUTCMilliseconds + + 1. Let t be this time value. + 2. If t is NaN, return NaN. + 3. Return msFromTime(t). + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + +var SECTION = "15.9.5.21"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Date.prototype.getUTCMilliseconds()"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +addTestCase( TIME_1970 ); + +test(); + +function addTestCase( t ) { + new TestCase( SECTION, + "(new Date("+t+")).getUTCMilliseconds()", + msFromTime(t), + (new Date(t)).getUTCMilliseconds() ); +} diff --git a/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.21-4.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.21-4.js new file mode 100644 index 0000000000..b7dfa656ff --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.21-4.js @@ -0,0 +1,70 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.9.5.21-4.js'; + +/** + File Name: 15.9.5.21.js + ECMA Section: 15.9.5.21 + Description: Date.prototype.getUTCMilliseconds + + 1. Let t be this time value. + 2. If t is NaN, return NaN. + 3. Return msFromTime(t). + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + +var SECTION = "15.9.5.21"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Date.prototype.getUTCMilliseconds()"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +addTestCase( TIME_1900 ); + +test(); + +function addTestCase( t ) { + new TestCase( SECTION, + "(new Date("+t+")).getUTCMilliseconds()", + msFromTime(t), + (new Date(t)).getUTCMilliseconds() ); +} diff --git a/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.21-5.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.21-5.js new file mode 100644 index 0000000000..ca90b1784a --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.21-5.js @@ -0,0 +1,70 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.9.5.21-5.js'; + +/** + File Name: 15.9.5.21.js + ECMA Section: 15.9.5.21 + Description: Date.prototype.getUTCMilliseconds + + 1. Let t be this time value. + 2. If t is NaN, return NaN. + 3. Return msFromTime(t). + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + +var SECTION = "15.9.5.21"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Date.prototype.getUTCMilliseconds()"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +addTestCase( TIME_2000 ); + +test(); + +function addTestCase( t ) { + new TestCase( SECTION, + "(new Date("+t+")).getUTCMilliseconds()", + msFromTime(t), + (new Date(t)).getUTCMilliseconds() ); +} diff --git a/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.21-6.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.21-6.js new file mode 100644 index 0000000000..9178ae76cf --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.21-6.js @@ -0,0 +1,70 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.9.5.21-6.js'; + +/** + File Name: 15.9.5.21.js + ECMA Section: 15.9.5.21 + Description: Date.prototype.getUTCMilliseconds + + 1. Let t be this time value. + 2. If t is NaN, return NaN. + 3. Return msFromTime(t). + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + +var SECTION = "15.9.5.21"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Date.prototype.getUTCMilliseconds()"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +addTestCase( UTC_FEB_29_2000 ); + +test(); + +function addTestCase( t ) { + new TestCase( SECTION, + "(new Date("+t+")).getUTCMilliseconds()", + msFromTime(t), + (new Date(t)).getUTCMilliseconds() ); +} diff --git a/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.21-7.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.21-7.js new file mode 100644 index 0000000000..c4d0a4b615 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.21-7.js @@ -0,0 +1,70 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.9.5.21-7.js'; + +/** + File Name: 15.9.5.21.js + ECMA Section: 15.9.5.21 + Description: Date.prototype.getUTCMilliseconds + + 1. Let t be this time value. + 2. If t is NaN, return NaN. + 3. Return msFromTime(t). + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + +var SECTION = "15.9.5.21"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Date.prototype.getUTCMilliseconds()"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +addTestCase( UTC_JAN_1_2005 ); + +test(); + +function addTestCase( t ) { + new TestCase( SECTION, + "(new Date("+t+")).getUTCMilliseconds()", + msFromTime(t), + (new Date(t)).getUTCMilliseconds() ); +} diff --git a/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.21-8.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.21-8.js new file mode 100644 index 0000000000..624d6c6bcb --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.21-8.js @@ -0,0 +1,71 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.9.5.21-8.js'; + +/** + File Name: 15.9.5.21.js + ECMA Section: 15.9.5.21 + Description: Date.prototype.getUTCMilliseconds + + 1. Let t be this time value. + 2. If t is NaN, return NaN. + 3. Return msFromTime(t). + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + +var SECTION = "15.9.5.21"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Date.prototype.getUTCMilliseconds()"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +new TestCase( SECTION, + "(new Date(NaN)).getUTCMilliseconds()", + NaN, + (new Date(NaN)).getUTCMilliseconds() ); + +new TestCase( SECTION, + "Date.prototype.getUTCMilliseconds.length", + 0, + Date.prototype.getUTCMilliseconds.length ); +test(); + diff --git a/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.22-1.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.22-1.js new file mode 100644 index 0000000000..5d2a6934ab --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.22-1.js @@ -0,0 +1,89 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.9.5.22-1.js'; + +/** + File Name: 15.9.5.22.js + ECMA Section: 15.9.5.22 + Description: Date.prototype.getTimezoneOffset + + Returns the difference between local time and UTC time in minutes. + 1. Let t be this time value. + 2. If t is NaN, return NaN. + 3. Return (t - LocalTime(t)) / msPerMinute. + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + +var SECTION = "15.9.5.22"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Date.prototype.getTimezoneOffset()"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +addTestCase( TIME_0000 ); +addTestCase( TIME_1970 ); +addTestCase( TIME_1900 ); +addTestCase( TIME_2000 ); +addTestCase( UTC_FEB_29_2000 ); +addTestCase( UTC_JAN_1_2005 ); + +new TestCase( SECTION, + "(new Date(NaN)).getTimezoneOffset()", + NaN, + (new Date(NaN)).getTimezoneOffset() ); + +new TestCase( SECTION, + "Date.prototype.getTimezoneOffset.length", + 0, + Date.prototype.getTimezoneOffset.length ); + +test(); + +function addTestCase( t ) { + for ( m = 0; m <= 1000; m+=100 ) { + t++; + new TestCase( SECTION, + "(new Date("+t+")).getTimezoneOffset()", + (t - LocalTime(t)) / msPerMinute, + (new Date(t)).getTimezoneOffset() ); + } +} diff --git a/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.22-2.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.22-2.js new file mode 100644 index 0000000000..b828b468d1 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.22-2.js @@ -0,0 +1,74 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.9.5.22-2.js'; + +/** + File Name: 15.9.5.22.js + ECMA Section: 15.9.5.22 + Description: Date.prototype.getTimezoneOffset + + Returns the difference between local time and UTC time in minutes. + 1. Let t be this time value. + 2. If t is NaN, return NaN. + 3. Return (t - LocalTime(t)) / msPerMinute. + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + +var SECTION = "15.9.5.22"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Date.prototype.getTimezoneOffset()"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +addTestCase( TIME_0000 ); + +test(); + +function addTestCase( t ) { + for ( m = 0; m <= 1000; m+=100 ) { + t++; + new TestCase( SECTION, + "(new Date("+t+")).getTimezoneOffset()", + (t - LocalTime(t)) / msPerMinute, + (new Date(t)).getTimezoneOffset() ); + } +} diff --git a/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.22-3.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.22-3.js new file mode 100644 index 0000000000..26c059368d --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.22-3.js @@ -0,0 +1,74 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.9.5.22-3.js'; + +/** + File Name: 15.9.5.22.js + ECMA Section: 15.9.5.22 + Description: Date.prototype.getTimezoneOffset + + Returns the difference between local time and UTC time in minutes. + 1. Let t be this time value. + 2. If t is NaN, return NaN. + 3. Return (t - LocalTime(t)) / msPerMinute. + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + +var SECTION = "15.9.5.22"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Date.prototype.getTimezoneOffset()"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +addTestCase( TIME_1970 ); + +test(); + +function addTestCase( t ) { + for ( m = 0; m <= 1000; m+=100 ) { + t++; + new TestCase( SECTION, + "(new Date("+t+")).getTimezoneOffset()", + (t - LocalTime(t)) / msPerMinute, + (new Date(t)).getTimezoneOffset() ); + } +} diff --git a/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.22-4.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.22-4.js new file mode 100644 index 0000000000..96b9771d59 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.22-4.js @@ -0,0 +1,74 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.9.5.22-4.js'; + +/** + File Name: 15.9.5.22.js + ECMA Section: 15.9.5.22 + Description: Date.prototype.getTimezoneOffset + + Returns the difference between local time and UTC time in minutes. + 1. Let t be this time value. + 2. If t is NaN, return NaN. + 3. Return (t - LocalTime(t)) / msPerMinute. + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + +var SECTION = "15.9.5.22"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Date.prototype.getTimezoneOffset()"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +addTestCase( TIME_1900 ); + +test(); + +function addTestCase( t ) { + for ( m = 0; m <= 1000; m+=100 ) { + t++; + new TestCase( SECTION, + "(new Date("+t+")).getTimezoneOffset()", + (t - LocalTime(t)) / msPerMinute, + (new Date(t)).getTimezoneOffset() ); + } +} diff --git a/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.22-5.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.22-5.js new file mode 100644 index 0000000000..a943aa5699 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.22-5.js @@ -0,0 +1,74 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.9.5.22-5.js'; + +/** + File Name: 15.9.5.22.js + ECMA Section: 15.9.5.22 + Description: Date.prototype.getTimezoneOffset + + Returns the difference between local time and UTC time in minutes. + 1. Let t be this time value. + 2. If t is NaN, return NaN. + 3. Return (t - LocalTime(t)) / msPerMinute. + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + +var SECTION = "15.9.5.22"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Date.prototype.getTimezoneOffset()"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +addTestCase( TIME_2000 ); + +test(); + +function addTestCase( t ) { + for ( m = 0; m <= 1000; m+=100 ) { + t++; + new TestCase( SECTION, + "(new Date("+t+")).getTimezoneOffset()", + (t - LocalTime(t)) / msPerMinute, + (new Date(t)).getTimezoneOffset() ); + } +} diff --git a/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.22-6.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.22-6.js new file mode 100644 index 0000000000..96b39d2c43 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.22-6.js @@ -0,0 +1,74 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.9.5.22-6.js'; + +/** + File Name: 15.9.5.22.js + ECMA Section: 15.9.5.22 + Description: Date.prototype.getTimezoneOffset + + Returns the difference between local time and UTC time in minutes. + 1. Let t be this time value. + 2. If t is NaN, return NaN. + 3. Return (t - LocalTime(t)) / msPerMinute. + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + +var SECTION = "15.9.5.22"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Date.prototype.getTimezoneOffset()"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +addTestCase( UTC_FEB_29_2000 ); + +test(); + +function addTestCase( t ) { + for ( m = 0; m <= 1000; m+=100 ) { + t++; + new TestCase( SECTION, + "(new Date("+t+")).getTimezoneOffset()", + (t - LocalTime(t)) / msPerMinute, + (new Date(t)).getTimezoneOffset() ); + } +} diff --git a/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.22-7.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.22-7.js new file mode 100644 index 0000000000..7fa0ecaf14 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.22-7.js @@ -0,0 +1,74 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.9.5.22-7.js'; + +/** + File Name: 15.9.5.22.js + ECMA Section: 15.9.5.22 + Description: Date.prototype.getTimezoneOffset + + Returns the difference between local time and UTC time in minutes. + 1. Let t be this time value. + 2. If t is NaN, return NaN. + 3. Return (t - LocalTime(t)) / msPerMinute. + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + +var SECTION = "15.9.5.22"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Date.prototype.getTimezoneOffset()"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +addTestCase( UTC_JAN_1_2005 ); + +test(); + +function addTestCase( t ) { + for ( m = 0; m <= 1000; m+=100 ) { + t++; + new TestCase( SECTION, + "(new Date("+t+")).getTimezoneOffset()", + (t - LocalTime(t)) / msPerMinute, + (new Date(t)).getTimezoneOffset() ); + } +} diff --git a/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.22-8.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.22-8.js new file mode 100644 index 0000000000..3eca9d8ec9 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.22-8.js @@ -0,0 +1,72 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.9.5.22-8.js'; + +/** + File Name: 15.9.5.22.js + ECMA Section: 15.9.5.22 + Description: Date.prototype.getTimezoneOffset + + Returns the difference between local time and UTC time in minutes. + 1. Let t be this time value. + 2. If t is NaN, return NaN. + 3. Return (t - LocalTime(t)) / msPerMinute. + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + +var SECTION = "15.9.5.22"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Date.prototype.getTimezoneOffset()"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +new TestCase( SECTION, + "(new Date(NaN)).getTimezoneOffset()", + NaN, + (new Date(NaN)).getTimezoneOffset() ); + +new TestCase( SECTION, + "Date.prototype.getTimezoneOffset.length", + 0, + Date.prototype.getTimezoneOffset.length ); +test(); + diff --git a/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.23-1.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.23-1.js new file mode 100644 index 0000000000..e4a228e2cd --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.23-1.js @@ -0,0 +1,139 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.9.5.23-1.js'; + +/** + File Name: 15.9.5.23-1.js + ECMA Section: 15.9.5.23 Date.prototype.setTime(time) + Description: + + 1. If the this value is not a Date object, generate a runtime error. + 2. Call ToNumber(time). + 3. Call TimeClip(Result(1)). + 4. Set the [[Value]] property of the this value to Result(2). + 5. Return the value of the [[Value]] property of the this value. + + Author: christine@netscape.com + Date: 12 november 1997 + +*/ +var SECTION = "15.9.5.23-1"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Date.prototype.setTime()"; + +writeHeaderToLog( SECTION + " Date.prototype.setTime(time)"); + +var now = "now"; +addTestCase( 0, 0 ); + +test(); + +function addTestCase( startTime, setTime ) { + if ( startTime == "now" ) { + DateCase = new Date(); + } else { + DateCase = new Date( startTime ); + } + + DateCase.setTime( setTime ); + var DateString = "var d = new Date("+startTime+"); d.setTime("+setTime+"); d" ; + var UTCDate = UTCDateFromTime ( Number(setTime) ); + var LocalDate = LocalDateFromTime( Number(setTime) ); + + new TestCase( SECTION, DateString+".getTime()", UTCDate.value, DateCase.getTime() ); + new TestCase( SECTION, DateString+".valueOf()", UTCDate.value, DateCase.valueOf() ); + + new TestCase( SECTION, DateString+".getUTCFullYear()", UTCDate.year, DateCase.getUTCFullYear() ); + new TestCase( SECTION, DateString+".getUTCMonth()", UTCDate.month, DateCase.getUTCMonth() ); + new TestCase( SECTION, DateString+".getUTCDate()", UTCDate.date, DateCase.getUTCDate() ); + new TestCase( SECTION, DateString+".getUTCDay()", UTCDate.day, DateCase.getUTCDay() ); + new TestCase( SECTION, DateString+".getUTCHours()", UTCDate.hours, DateCase.getUTCHours() ); + new TestCase( SECTION, DateString+".getUTCMinutes()", UTCDate.minutes, DateCase.getUTCMinutes() ); + new TestCase( SECTION, DateString+".getUTCSeconds()", UTCDate.seconds, DateCase.getUTCSeconds() ); + new TestCase( SECTION, DateString+".getUTCMilliseconds()", UTCDate.ms, DateCase.getUTCMilliseconds() ); + + new TestCase( SECTION, DateString+".getFullYear()", LocalDate.year, DateCase.getFullYear() ); + new TestCase( SECTION, DateString+".getMonth()", LocalDate.month, DateCase.getMonth() ); + new TestCase( SECTION, DateString+".getDate()", LocalDate.date, DateCase.getDate() ); + new TestCase( SECTION, DateString+".getDay()", LocalDate.day, DateCase.getDay() ); + new TestCase( SECTION, DateString+".getHours()", LocalDate.hours, DateCase.getHours() ); + new TestCase( SECTION, DateString+".getMinutes()", LocalDate.minutes, DateCase.getMinutes() ); + new TestCase( SECTION, DateString+".getSeconds()", LocalDate.seconds, DateCase.getSeconds() ); + new TestCase( SECTION, DateString+".getMilliseconds()", LocalDate.ms, DateCase.getMilliseconds() ); + + DateCase.toString = Object.prototype.toString; + + new TestCase( SECTION, + DateString+".toString=Object.prototype.toString;"+DateString+".toString()", + "[object Date]", + DateCase.toString() ); +} + +function MyDate() { + this.year = 0; + this.month = 0; + this.date = 0; + this.hours = 0; + this.minutes = 0; + this.seconds = 0; + this.ms = 0; +} +function LocalDateFromTime(t) { + t = LocalTime(t); + return ( MyDateFromTime(t) ); +} +function UTCDateFromTime(t) { + return ( MyDateFromTime(t) ); +} +function MyDateFromTime( t ) { + var d = new MyDate(); + d.year = YearFromTime(t); + d.month = MonthFromTime(t); + d.date = DateFromTime(t); + d.hours = HourFromTime(t); + d.minutes = MinFromTime(t); + d.seconds = SecFromTime(t); + d.ms = msFromTime(t); + d.time = MakeTime( d.hours, d.minutes, d.seconds, d.ms ); + d.value = TimeClip( MakeDate( MakeDay( d.year, d.month, d.date ), d.time ) ); + d.day = WeekDay( d.value ); + return (d); +} + diff --git a/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.23-10.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.23-10.js new file mode 100644 index 0000000000..d4cb298d19 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.23-10.js @@ -0,0 +1,139 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.9.5.23-10.js'; + +/** + File Name: 15.9.5.23-1.js + ECMA Section: 15.9.5.23 Date.prototype.setTime(time) + Description: + + 1. If the this value is not a Date object, generate a runtime error. + 2. Call ToNumber(time). + 3. Call TimeClip(Result(1)). + 4. Set the [[Value]] property of the this value to Result(2). + 5. Return the value of the [[Value]] property of the this value. + + Author: christine@netscape.com + Date: 12 november 1997 + +*/ +var SECTION = "15.9.5.23-1"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Date.prototype.setTime()"; + +writeHeaderToLog( SECTION + " Date.prototype.setTime(time)"); + +var now = "now"; +addTestCase( now, -2208988800000 ); + +test(); + +function addTestCase( startTime, setTime ) { + if ( startTime == "now" ) { + DateCase = new Date(); + } else { + DateCase = new Date( startTime ); + } + + DateCase.setTime( setTime ); + var DateString = "var d = new Date("+startTime+"); d.setTime("+setTime+"); d" ; + var UTCDate = UTCDateFromTime ( Number(setTime) ); + var LocalDate = LocalDateFromTime( Number(setTime) ); + + new TestCase( SECTION, DateString+".getTime()", UTCDate.value, DateCase.getTime() ); + new TestCase( SECTION, DateString+".valueOf()", UTCDate.value, DateCase.valueOf() ); + + new TestCase( SECTION, DateString+".getUTCFullYear()", UTCDate.year, DateCase.getUTCFullYear() ); + new TestCase( SECTION, DateString+".getUTCMonth()", UTCDate.month, DateCase.getUTCMonth() ); + new TestCase( SECTION, DateString+".getUTCDate()", UTCDate.date, DateCase.getUTCDate() ); + new TestCase( SECTION, DateString+".getUTCDay()", UTCDate.day, DateCase.getUTCDay() ); + new TestCase( SECTION, DateString+".getUTCHours()", UTCDate.hours, DateCase.getUTCHours() ); + new TestCase( SECTION, DateString+".getUTCMinutes()", UTCDate.minutes, DateCase.getUTCMinutes() ); + new TestCase( SECTION, DateString+".getUTCSeconds()", UTCDate.seconds, DateCase.getUTCSeconds() ); + new TestCase( SECTION, DateString+".getUTCMilliseconds()", UTCDate.ms, DateCase.getUTCMilliseconds() ); + + new TestCase( SECTION, DateString+".getFullYear()", LocalDate.year, DateCase.getFullYear() ); + new TestCase( SECTION, DateString+".getMonth()", LocalDate.month, DateCase.getMonth() ); + new TestCase( SECTION, DateString+".getDate()", LocalDate.date, DateCase.getDate() ); + new TestCase( SECTION, DateString+".getDay()", LocalDate.day, DateCase.getDay() ); + new TestCase( SECTION, DateString+".getHours()", LocalDate.hours, DateCase.getHours() ); + new TestCase( SECTION, DateString+".getMinutes()", LocalDate.minutes, DateCase.getMinutes() ); + new TestCase( SECTION, DateString+".getSeconds()", LocalDate.seconds, DateCase.getSeconds() ); + new TestCase( SECTION, DateString+".getMilliseconds()", LocalDate.ms, DateCase.getMilliseconds() ); + + DateCase.toString = Object.prototype.toString; + + new TestCase( SECTION, + DateString+".toString=Object.prototype.toString;"+DateString+".toString()", + "[object Date]", + DateCase.toString() ); +} + +function MyDate() { + this.year = 0; + this.month = 0; + this.date = 0; + this.hours = 0; + this.minutes = 0; + this.seconds = 0; + this.ms = 0; +} +function LocalDateFromTime(t) { + t = LocalTime(t); + return ( MyDateFromTime(t) ); +} +function UTCDateFromTime(t) { + return ( MyDateFromTime(t) ); +} +function MyDateFromTime( t ) { + var d = new MyDate(); + d.year = YearFromTime(t); + d.month = MonthFromTime(t); + d.date = DateFromTime(t); + d.hours = HourFromTime(t); + d.minutes = MinFromTime(t); + d.seconds = SecFromTime(t); + d.ms = msFromTime(t); + d.time = MakeTime( d.hours, d.minutes, d.seconds, d.ms ); + d.value = TimeClip( MakeDate( MakeDay( d.year, d.month, d.date ), d.time ) ); + d.day = WeekDay( d.value ); + return (d); +} + diff --git a/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.23-11.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.23-11.js new file mode 100644 index 0000000000..ca28015766 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.23-11.js @@ -0,0 +1,140 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.9.5.23-11.js'; + +/** + File Name: 15.9.5.23-1.js + ECMA Section: 15.9.5.23 Date.prototype.setTime(time) + Description: + + 1. If the this value is not a Date object, generate a runtime error. + 2. Call ToNumber(time). + 3. Call TimeClip(Result(1)). + 4. Set the [[Value]] property of the this value to Result(2). + 5. Return the value of the [[Value]] property of the this value. + + Author: christine@netscape.com + Date: 12 november 1997 + +*/ +var SECTION = "15.9.5.23-1"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Date.prototype.setTime()"; + +writeHeaderToLog( SECTION + " Date.prototype.setTime(time)"); + +var now = "now"; +addTestCase( now, -86400000 ); + +test(); + + +function addTestCase( startTime, setTime ) { + if ( startTime == "now" ) { + DateCase = new Date(); + } else { + DateCase = new Date( startTime ); + } + + DateCase.setTime( setTime ); + var DateString = "var d = new Date("+startTime+"); d.setTime("+setTime+"); d" ; + var UTCDate = UTCDateFromTime ( Number(setTime) ); + var LocalDate = LocalDateFromTime( Number(setTime) ); + + new TestCase( SECTION, DateString+".getTime()", UTCDate.value, DateCase.getTime() ); + new TestCase( SECTION, DateString+".valueOf()", UTCDate.value, DateCase.valueOf() ); + + new TestCase( SECTION, DateString+".getUTCFullYear()", UTCDate.year, DateCase.getUTCFullYear() ); + new TestCase( SECTION, DateString+".getUTCMonth()", UTCDate.month, DateCase.getUTCMonth() ); + new TestCase( SECTION, DateString+".getUTCDate()", UTCDate.date, DateCase.getUTCDate() ); + new TestCase( SECTION, DateString+".getUTCDay()", UTCDate.day, DateCase.getUTCDay() ); + new TestCase( SECTION, DateString+".getUTCHours()", UTCDate.hours, DateCase.getUTCHours() ); + new TestCase( SECTION, DateString+".getUTCMinutes()", UTCDate.minutes, DateCase.getUTCMinutes() ); + new TestCase( SECTION, DateString+".getUTCSeconds()", UTCDate.seconds, DateCase.getUTCSeconds() ); + new TestCase( SECTION, DateString+".getUTCMilliseconds()", UTCDate.ms, DateCase.getUTCMilliseconds() ); + + new TestCase( SECTION, DateString+".getFullYear()", LocalDate.year, DateCase.getFullYear() ); + new TestCase( SECTION, DateString+".getMonth()", LocalDate.month, DateCase.getMonth() ); + new TestCase( SECTION, DateString+".getDate()", LocalDate.date, DateCase.getDate() ); + new TestCase( SECTION, DateString+".getDay()", LocalDate.day, DateCase.getDay() ); + new TestCase( SECTION, DateString+".getHours()", LocalDate.hours, DateCase.getHours() ); + new TestCase( SECTION, DateString+".getMinutes()", LocalDate.minutes, DateCase.getMinutes() ); + new TestCase( SECTION, DateString+".getSeconds()", LocalDate.seconds, DateCase.getSeconds() ); + new TestCase( SECTION, DateString+".getMilliseconds()", LocalDate.ms, DateCase.getMilliseconds() ); + + DateCase.toString = Object.prototype.toString; + + new TestCase( SECTION, + DateString+".toString=Object.prototype.toString;"+DateString+".toString()", + "[object Date]", + DateCase.toString() ); +} +function MyDate() { + this.year = 0; + this.month = 0; + this.date = 0; + this.hours = 0; + this.minutes = 0; + this.seconds = 0; + this.ms = 0; +} +function LocalDateFromTime(t) { + t = LocalTime(t); + return ( MyDateFromTime(t) ); +} +function UTCDateFromTime(t) { + return ( MyDateFromTime(t) ); +} +function MyDateFromTime( t ) { + var d = new MyDate(); + d.year = YearFromTime(t); + d.month = MonthFromTime(t); + d.date = DateFromTime(t); + d.hours = HourFromTime(t); + d.minutes = MinFromTime(t); + d.seconds = SecFromTime(t); + d.ms = msFromTime(t); + d.time = MakeTime( d.hours, d.minutes, d.seconds, d.ms ); + d.value = TimeClip( MakeDate( MakeDay( d.year, d.month, d.date ), d.time ) ); + d.day = WeekDay( d.value ); + return (d); +} + + diff --git a/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.23-12.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.23-12.js new file mode 100644 index 0000000000..a03f599567 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.23-12.js @@ -0,0 +1,137 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.9.5.23-12.js'; + +/** + File Name: 15.9.5.23-1.js + ECMA Section: 15.9.5.23 Date.prototype.setTime(time) + Description: + + 1. If the this value is not a Date object, generate a runtime error. + 2. Call ToNumber(time). + 3. Call TimeClip(Result(1)). + 4. Set the [[Value]] property of the this value to Result(2). + 5. Return the value of the [[Value]] property of the this value. + + Author: christine@netscape.com + Date: 12 november 1997 + +*/ +var SECTION = "15.9.5.23-1"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Date.prototype.setTime()"; + +writeHeaderToLog( SECTION + " Date.prototype.setTime(time)"); + +var now = "now"; +addTestCase( now, 946684800000 ); + +test(); + +function addTestCase( startTime, setTime ) { + if ( startTime == "now" ) { + DateCase = new Date(); + } else { + DateCase = new Date( startTime ); + } + + DateCase.setTime( setTime ); + var DateString = "var d = new Date("+startTime+"); d.setTime("+setTime+"); d" ; + var UTCDate = UTCDateFromTime ( Number(setTime) ); + var LocalDate = LocalDateFromTime( Number(setTime) ); + + new TestCase( SECTION, DateString+".getTime()", UTCDate.value, DateCase.getTime() ); + new TestCase( SECTION, DateString+".valueOf()", UTCDate.value, DateCase.valueOf() ); + + new TestCase( SECTION, DateString+".getUTCFullYear()", UTCDate.year, DateCase.getUTCFullYear() ); + new TestCase( SECTION, DateString+".getUTCMonth()", UTCDate.month, DateCase.getUTCMonth() ); + new TestCase( SECTION, DateString+".getUTCDate()", UTCDate.date, DateCase.getUTCDate() ); + new TestCase( SECTION, DateString+".getUTCDay()", UTCDate.day, DateCase.getUTCDay() ); + new TestCase( SECTION, DateString+".getUTCHours()", UTCDate.hours, DateCase.getUTCHours() ); + new TestCase( SECTION, DateString+".getUTCMinutes()", UTCDate.minutes, DateCase.getUTCMinutes() ); + new TestCase( SECTION, DateString+".getUTCSeconds()", UTCDate.seconds, DateCase.getUTCSeconds() ); + new TestCase( SECTION, DateString+".getUTCMilliseconds()", UTCDate.ms, DateCase.getUTCMilliseconds() ); + + new TestCase( SECTION, DateString+".getFullYear()", LocalDate.year, DateCase.getFullYear() ); + new TestCase( SECTION, DateString+".getMonth()", LocalDate.month, DateCase.getMonth() ); + new TestCase( SECTION, DateString+".getDate()", LocalDate.date, DateCase.getDate() ); + new TestCase( SECTION, DateString+".getDay()", LocalDate.day, DateCase.getDay() ); + new TestCase( SECTION, DateString+".getHours()", LocalDate.hours, DateCase.getHours() ); + new TestCase( SECTION, DateString+".getMinutes()", LocalDate.minutes, DateCase.getMinutes() ); + new TestCase( SECTION, DateString+".getSeconds()", LocalDate.seconds, DateCase.getSeconds() ); + new TestCase( SECTION, DateString+".getMilliseconds()", LocalDate.ms, DateCase.getMilliseconds() ); + + DateCase.toString = Object.prototype.toString; + + new TestCase( SECTION, + DateString+".toString=Object.prototype.toString;"+DateString+".toString()", + "[object Date]", + DateCase.toString() ); +} +function MyDate() { + this.year = 0; + this.month = 0; + this.date = 0; + this.hours = 0; + this.minutes = 0; + this.seconds = 0; + this.ms = 0; +} +function LocalDateFromTime(t) { + t = LocalTime(t); + return ( MyDateFromTime(t) ); +} +function UTCDateFromTime(t) { + return ( MyDateFromTime(t) ); +} +function MyDateFromTime( t ) { + var d = new MyDate(); + d.year = YearFromTime(t); + d.month = MonthFromTime(t); + d.date = DateFromTime(t); + d.hours = HourFromTime(t); + d.minutes = MinFromTime(t); + d.seconds = SecFromTime(t); + d.ms = msFromTime(t); + d.time = MakeTime( d.hours, d.minutes, d.seconds, d.ms ); + d.value = TimeClip( MakeDate( MakeDay( d.year, d.month, d.date ), d.time ) ); + d.day = WeekDay( d.value ); + return (d); +} diff --git a/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.23-13.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.23-13.js new file mode 100644 index 0000000000..a68128770c --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.23-13.js @@ -0,0 +1,137 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.9.5.23-13.js'; + +/** + File Name: 15.9.5.23-1.js + ECMA Section: 15.9.5.23 Date.prototype.setTime(time) + Description: + + 1. If the this value is not a Date object, generate a runtime error. + 2. Call ToNumber(time). + 3. Call TimeClip(Result(1)). + 4. Set the [[Value]] property of the this value to Result(2). + 5. Return the value of the [[Value]] property of the this value. + + Author: christine@netscape.com + Date: 12 november 1997 + +*/ +var SECTION = "15.9.5.23-13"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Date.prototype.setTime()"; + +writeHeaderToLog( SECTION + " Date.prototype.setTime(time)"); + +var now = "now"; +addTestCase( now, -2208988800000 ); + +test(); + +function addTestCase( startTime, setTime ) { + if ( startTime == "now" ) { + DateCase = new Date(); + } else { + DateCase = new Date( startTime ); + } + + DateCase.setTime( setTime ); + var DateString = "var d = new Date("+startTime+"); d.setTime("+setTime+"); d" ; + var UTCDate = UTCDateFromTime ( Number(setTime) ); + var LocalDate = LocalDateFromTime( Number(setTime) ); + + new TestCase( SECTION, DateString+".getTime()", UTCDate.value, DateCase.getTime() ); + new TestCase( SECTION, DateString+".valueOf()", UTCDate.value, DateCase.valueOf() ); + + new TestCase( SECTION, DateString+".getUTCFullYear()", UTCDate.year, DateCase.getUTCFullYear() ); + new TestCase( SECTION, DateString+".getUTCMonth()", UTCDate.month, DateCase.getUTCMonth() ); + new TestCase( SECTION, DateString+".getUTCDate()", UTCDate.date, DateCase.getUTCDate() ); + new TestCase( SECTION, DateString+".getUTCDay()", UTCDate.day, DateCase.getUTCDay() ); + new TestCase( SECTION, DateString+".getUTCHours()", UTCDate.hours, DateCase.getUTCHours() ); + new TestCase( SECTION, DateString+".getUTCMinutes()", UTCDate.minutes, DateCase.getUTCMinutes() ); + new TestCase( SECTION, DateString+".getUTCSeconds()", UTCDate.seconds, DateCase.getUTCSeconds() ); + new TestCase( SECTION, DateString+".getUTCMilliseconds()", UTCDate.ms, DateCase.getUTCMilliseconds() ); + + new TestCase( SECTION, DateString+".getFullYear()", LocalDate.year, DateCase.getFullYear() ); + new TestCase( SECTION, DateString+".getMonth()", LocalDate.month, DateCase.getMonth() ); + new TestCase( SECTION, DateString+".getDate()", LocalDate.date, DateCase.getDate() ); + new TestCase( SECTION, DateString+".getDay()", LocalDate.day, DateCase.getDay() ); + new TestCase( SECTION, DateString+".getHours()", LocalDate.hours, DateCase.getHours() ); + new TestCase( SECTION, DateString+".getMinutes()", LocalDate.minutes, DateCase.getMinutes() ); + new TestCase( SECTION, DateString+".getSeconds()", LocalDate.seconds, DateCase.getSeconds() ); + new TestCase( SECTION, DateString+".getMilliseconds()", LocalDate.ms, DateCase.getMilliseconds() ); + + DateCase.toString = Object.prototype.toString; + + new TestCase( SECTION, + DateString+".toString=Object.prototype.toString;"+DateString+".toString()", + "[object Date]", + DateCase.toString() ); +} +function MyDate() { + this.year = 0; + this.month = 0; + this.date = 0; + this.hours = 0; + this.minutes = 0; + this.seconds = 0; + this.ms = 0; +} +function LocalDateFromTime(t) { + t = LocalTime(t); + return ( MyDateFromTime(t) ); +} +function UTCDateFromTime(t) { + return ( MyDateFromTime(t) ); +} +function MyDateFromTime( t ) { + var d = new MyDate(); + d.year = YearFromTime(t); + d.month = MonthFromTime(t); + d.date = DateFromTime(t); + d.hours = HourFromTime(t); + d.minutes = MinFromTime(t); + d.seconds = SecFromTime(t); + d.ms = msFromTime(t); + d.time = MakeTime( d.hours, d.minutes, d.seconds, d.ms ); + d.value = TimeClip( MakeDate( MakeDay( d.year, d.month, d.date ), d.time ) ); + d.day = WeekDay( d.value ); + return (d); +} diff --git a/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.23-14.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.23-14.js new file mode 100644 index 0000000000..1923d715e3 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.23-14.js @@ -0,0 +1,137 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.9.5.23-14.js'; + +/** + File Name: 15.9.5.23-1.js + ECMA Section: 15.9.5.23 Date.prototype.setTime(time) + Description: + + 1. If the this value is not a Date object, generate a runtime error. + 2. Call ToNumber(time). + 3. Call TimeClip(Result(1)). + 4. Set the [[Value]] property of the this value to Result(2). + 5. Return the value of the [[Value]] property of the this value. + + Author: christine@netscape.com + Date: 12 november 1997 + +*/ +var SECTION = "15.9.5.23-14"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Date.prototype.setTime()"; + +writeHeaderToLog( SECTION + " Date.prototype.setTime(time)"); + +var now = "now"; +addTestCase( now, 946684800000 ); + +test(); + +function addTestCase( startTime, setTime ) { + if ( startTime == "now" ) { + DateCase = new Date(); + } else { + DateCase = new Date( startTime ); + } + + DateCase.setTime( setTime ); + var DateString = "var d = new Date("+startTime+"); d.setTime("+setTime+"); d" ; + var UTCDate = UTCDateFromTime ( Number(setTime) ); + var LocalDate = LocalDateFromTime( Number(setTime) ); + + new TestCase( SECTION, DateString+".getTime()", UTCDate.value, DateCase.getTime() ); + new TestCase( SECTION, DateString+".valueOf()", UTCDate.value, DateCase.valueOf() ); + + new TestCase( SECTION, DateString+".getUTCFullYear()", UTCDate.year, DateCase.getUTCFullYear() ); + new TestCase( SECTION, DateString+".getUTCMonth()", UTCDate.month, DateCase.getUTCMonth() ); + new TestCase( SECTION, DateString+".getUTCDate()", UTCDate.date, DateCase.getUTCDate() ); + new TestCase( SECTION, DateString+".getUTCDay()", UTCDate.day, DateCase.getUTCDay() ); + new TestCase( SECTION, DateString+".getUTCHours()", UTCDate.hours, DateCase.getUTCHours() ); + new TestCase( SECTION, DateString+".getUTCMinutes()", UTCDate.minutes, DateCase.getUTCMinutes() ); + new TestCase( SECTION, DateString+".getUTCSeconds()", UTCDate.seconds, DateCase.getUTCSeconds() ); + new TestCase( SECTION, DateString+".getUTCMilliseconds()", UTCDate.ms, DateCase.getUTCMilliseconds() ); + + new TestCase( SECTION, DateString+".getFullYear()", LocalDate.year, DateCase.getFullYear() ); + new TestCase( SECTION, DateString+".getMonth()", LocalDate.month, DateCase.getMonth() ); + new TestCase( SECTION, DateString+".getDate()", LocalDate.date, DateCase.getDate() ); + new TestCase( SECTION, DateString+".getDay()", LocalDate.day, DateCase.getDay() ); + new TestCase( SECTION, DateString+".getHours()", LocalDate.hours, DateCase.getHours() ); + new TestCase( SECTION, DateString+".getMinutes()", LocalDate.minutes, DateCase.getMinutes() ); + new TestCase( SECTION, DateString+".getSeconds()", LocalDate.seconds, DateCase.getSeconds() ); + new TestCase( SECTION, DateString+".getMilliseconds()", LocalDate.ms, DateCase.getMilliseconds() ); + + DateCase.toString = Object.prototype.toString; + + new TestCase( SECTION, + DateString+".toString=Object.prototype.toString;"+DateString+".toString()", + "[object Date]", + DateCase.toString() ); +} +function MyDate() { + this.year = 0; + this.month = 0; + this.date = 0; + this.hours = 0; + this.minutes = 0; + this.seconds = 0; + this.ms = 0; +} +function LocalDateFromTime(t) { + t = LocalTime(t); + return ( MyDateFromTime(t) ); +} +function UTCDateFromTime(t) { + return ( MyDateFromTime(t) ); +} +function MyDateFromTime( t ) { + var d = new MyDate(); + d.year = YearFromTime(t); + d.month = MonthFromTime(t); + d.date = DateFromTime(t); + d.hours = HourFromTime(t); + d.minutes = MinFromTime(t); + d.seconds = SecFromTime(t); + d.ms = msFromTime(t); + d.time = MakeTime( d.hours, d.minutes, d.seconds, d.ms ); + d.value = TimeClip( MakeDate( MakeDay( d.year, d.month, d.date ), d.time ) ); + d.day = WeekDay( d.value ); + return (d); +} diff --git a/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.23-15.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.23-15.js new file mode 100644 index 0000000000..31680eb386 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.23-15.js @@ -0,0 +1,137 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.9.5.23-15.js'; + +/** + File Name: 15.9.5.23-1.js + ECMA Section: 15.9.5.23 Date.prototype.setTime(time) + Description: + + 1. If the this value is not a Date object, generate a runtime error. + 2. Call ToNumber(time). + 3. Call TimeClip(Result(1)). + 4. Set the [[Value]] property of the this value to Result(2). + 5. Return the value of the [[Value]] property of the this value. + + Author: christine@netscape.com + Date: 12 november 1997 + +*/ +var SECTION = "15.9.5.23-1"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Date.prototype.setTime()"; + +writeHeaderToLog( SECTION + " Date.prototype.setTime(time)"); + +var now = "now"; +addTestCase( now, 0 ); + +test(); + +function addTestCase( startTime, setTime ) { + if ( startTime == "now" ) { + DateCase = new Date(); + } else { + DateCase = new Date( startTime ); + } + + DateCase.setTime( setTime ); + var DateString = "var d = new Date("+startTime+"); d.setTime("+setTime+"); d" ; + var UTCDate = UTCDateFromTime ( Number(setTime) ); + var LocalDate = LocalDateFromTime( Number(setTime) ); + + new TestCase( SECTION, DateString+".getTime()", UTCDate.value, DateCase.getTime() ); + new TestCase( SECTION, DateString+".valueOf()", UTCDate.value, DateCase.valueOf() ); + + new TestCase( SECTION, DateString+".getUTCFullYear()", UTCDate.year, DateCase.getUTCFullYear() ); + new TestCase( SECTION, DateString+".getUTCMonth()", UTCDate.month, DateCase.getUTCMonth() ); + new TestCase( SECTION, DateString+".getUTCDate()", UTCDate.date, DateCase.getUTCDate() ); + new TestCase( SECTION, DateString+".getUTCDay()", UTCDate.day, DateCase.getUTCDay() ); + new TestCase( SECTION, DateString+".getUTCHours()", UTCDate.hours, DateCase.getUTCHours() ); + new TestCase( SECTION, DateString+".getUTCMinutes()", UTCDate.minutes, DateCase.getUTCMinutes() ); + new TestCase( SECTION, DateString+".getUTCSeconds()", UTCDate.seconds, DateCase.getUTCSeconds() ); + new TestCase( SECTION, DateString+".getUTCMilliseconds()", UTCDate.ms, DateCase.getUTCMilliseconds() ); + + new TestCase( SECTION, DateString+".getFullYear()", LocalDate.year, DateCase.getFullYear() ); + new TestCase( SECTION, DateString+".getMonth()", LocalDate.month, DateCase.getMonth() ); + new TestCase( SECTION, DateString+".getDate()", LocalDate.date, DateCase.getDate() ); + new TestCase( SECTION, DateString+".getDay()", LocalDate.day, DateCase.getDay() ); + new TestCase( SECTION, DateString+".getHours()", LocalDate.hours, DateCase.getHours() ); + new TestCase( SECTION, DateString+".getMinutes()", LocalDate.minutes, DateCase.getMinutes() ); + new TestCase( SECTION, DateString+".getSeconds()", LocalDate.seconds, DateCase.getSeconds() ); + new TestCase( SECTION, DateString+".getMilliseconds()", LocalDate.ms, DateCase.getMilliseconds() ); + + DateCase.toString = Object.prototype.toString; + + new TestCase( SECTION, + DateString+".toString=Object.prototype.toString;"+DateString+".toString()", + "[object Date]", + DateCase.toString() ); +} +function MyDate() { + this.year = 0; + this.month = 0; + this.date = 0; + this.hours = 0; + this.minutes = 0; + this.seconds = 0; + this.ms = 0; +} +function LocalDateFromTime(t) { + t = LocalTime(t); + return ( MyDateFromTime(t) ); +} +function UTCDateFromTime(t) { + return ( MyDateFromTime(t) ); +} +function MyDateFromTime( t ) { + var d = new MyDate(); + d.year = YearFromTime(t); + d.month = MonthFromTime(t); + d.date = DateFromTime(t); + d.hours = HourFromTime(t); + d.minutes = MinFromTime(t); + d.seconds = SecFromTime(t); + d.ms = msFromTime(t); + d.time = MakeTime( d.hours, d.minutes, d.seconds, d.ms ); + d.value = TimeClip( MakeDate( MakeDay( d.year, d.month, d.date ), d.time ) ); + d.day = WeekDay( d.value ); + return (d); +} diff --git a/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.23-16.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.23-16.js new file mode 100644 index 0000000000..3dc0726ca8 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.23-16.js @@ -0,0 +1,137 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.9.5.23-16.js'; + +/** + File Name: 15.9.5.23-1.js + ECMA Section: 15.9.5.23 Date.prototype.setTime(time) + Description: + + 1. If the this value is not a Date object, generate a runtime error. + 2. Call ToNumber(time). + 3. Call TimeClip(Result(1)). + 4. Set the [[Value]] property of the this value to Result(2). + 5. Return the value of the [[Value]] property of the this value. + + Author: christine@netscape.com + Date: 12 november 1997 + +*/ +var SECTION = "15.9.5.23-1"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Date.prototype.setTime()"; + +writeHeaderToLog( SECTION + " Date.prototype.setTime(time)"); + +var now = "now"; +addTestCase( now, String( TIME_1900 ) ); + +test(); + +function addTestCase( startTime, setTime ) { + if ( startTime == "now" ) { + DateCase = new Date(); + } else { + DateCase = new Date( startTime ); + } + + DateCase.setTime( setTime ); + var DateString = "var d = new Date("+startTime+"); d.setTime("+setTime+"); d" ; + var UTCDate = UTCDateFromTime ( Number(setTime) ); + var LocalDate = LocalDateFromTime( Number(setTime) ); + + new TestCase( SECTION, DateString+".getTime()", UTCDate.value, DateCase.getTime() ); + new TestCase( SECTION, DateString+".valueOf()", UTCDate.value, DateCase.valueOf() ); + + new TestCase( SECTION, DateString+".getUTCFullYear()", UTCDate.year, DateCase.getUTCFullYear() ); + new TestCase( SECTION, DateString+".getUTCMonth()", UTCDate.month, DateCase.getUTCMonth() ); + new TestCase( SECTION, DateString+".getUTCDate()", UTCDate.date, DateCase.getUTCDate() ); + new TestCase( SECTION, DateString+".getUTCDay()", UTCDate.day, DateCase.getUTCDay() ); + new TestCase( SECTION, DateString+".getUTCHours()", UTCDate.hours, DateCase.getUTCHours() ); + new TestCase( SECTION, DateString+".getUTCMinutes()", UTCDate.minutes, DateCase.getUTCMinutes() ); + new TestCase( SECTION, DateString+".getUTCSeconds()", UTCDate.seconds, DateCase.getUTCSeconds() ); + new TestCase( SECTION, DateString+".getUTCMilliseconds()", UTCDate.ms, DateCase.getUTCMilliseconds() ); + + new TestCase( SECTION, DateString+".getFullYear()", LocalDate.year, DateCase.getFullYear() ); + new TestCase( SECTION, DateString+".getMonth()", LocalDate.month, DateCase.getMonth() ); + new TestCase( SECTION, DateString+".getDate()", LocalDate.date, DateCase.getDate() ); + new TestCase( SECTION, DateString+".getDay()", LocalDate.day, DateCase.getDay() ); + new TestCase( SECTION, DateString+".getHours()", LocalDate.hours, DateCase.getHours() ); + new TestCase( SECTION, DateString+".getMinutes()", LocalDate.minutes, DateCase.getMinutes() ); + new TestCase( SECTION, DateString+".getSeconds()", LocalDate.seconds, DateCase.getSeconds() ); + new TestCase( SECTION, DateString+".getMilliseconds()", LocalDate.ms, DateCase.getMilliseconds() ); + + DateCase.toString = Object.prototype.toString; + + new TestCase( SECTION, + DateString+".toString=Object.prototype.toString;"+DateString+".toString()", + "[object Date]", + DateCase.toString() ); +} +function MyDate() { + this.year = 0; + this.month = 0; + this.date = 0; + this.hours = 0; + this.minutes = 0; + this.seconds = 0; + this.ms = 0; +} +function LocalDateFromTime(t) { + t = LocalTime(t); + return ( MyDateFromTime(t) ); +} +function UTCDateFromTime(t) { + return ( MyDateFromTime(t) ); +} +function MyDateFromTime( t ) { + var d = new MyDate(); + d.year = YearFromTime(t); + d.month = MonthFromTime(t); + d.date = DateFromTime(t); + d.hours = HourFromTime(t); + d.minutes = MinFromTime(t); + d.seconds = SecFromTime(t); + d.ms = msFromTime(t); + d.time = MakeTime( d.hours, d.minutes, d.seconds, d.ms ); + d.value = TimeClip( MakeDate( MakeDay( d.year, d.month, d.date ), d.time ) ); + d.day = WeekDay( d.value ); + return (d); +} diff --git a/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.23-17.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.23-17.js new file mode 100644 index 0000000000..605f4cf00b --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.23-17.js @@ -0,0 +1,137 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.9.5.23-17.js'; + +/** + File Name: 15.9.5.23-1.js + ECMA Section: 15.9.5.23 Date.prototype.setTime(time) + Description: + + 1. If the this value is not a Date object, generate a runtime error. + 2. Call ToNumber(time). + 3. Call TimeClip(Result(1)). + 4. Set the [[Value]] property of the this value to Result(2). + 5. Return the value of the [[Value]] property of the this value. + + Author: christine@netscape.com + Date: 12 november 1997 + +*/ +var SECTION = "15.9.5.23-1"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Date.prototype.setTime()"; + +writeHeaderToLog( SECTION + " Date.prototype.setTime(time)"); + +var now = "now"; +addTestCase( now, String( TZ_DIFF* msPerHour ) ); + +test(); + +function addTestCase( startTime, setTime ) { + if ( startTime == "now" ) { + DateCase = new Date(); + } else { + DateCase = new Date( startTime ); + } + + DateCase.setTime( setTime ); + var DateString = "var d = new Date("+startTime+"); d.setTime("+setTime+"); d" ; + var UTCDate = UTCDateFromTime ( Number(setTime) ); + var LocalDate = LocalDateFromTime( Number(setTime) ); + + new TestCase( SECTION, DateString+".getTime()", UTCDate.value, DateCase.getTime() ); + new TestCase( SECTION, DateString+".valueOf()", UTCDate.value, DateCase.valueOf() ); + + new TestCase( SECTION, DateString+".getUTCFullYear()", UTCDate.year, DateCase.getUTCFullYear() ); + new TestCase( SECTION, DateString+".getUTCMonth()", UTCDate.month, DateCase.getUTCMonth() ); + new TestCase( SECTION, DateString+".getUTCDate()", UTCDate.date, DateCase.getUTCDate() ); + new TestCase( SECTION, DateString+".getUTCDay()", UTCDate.day, DateCase.getUTCDay() ); + new TestCase( SECTION, DateString+".getUTCHours()", UTCDate.hours, DateCase.getUTCHours() ); + new TestCase( SECTION, DateString+".getUTCMinutes()", UTCDate.minutes, DateCase.getUTCMinutes() ); + new TestCase( SECTION, DateString+".getUTCSeconds()", UTCDate.seconds, DateCase.getUTCSeconds() ); + new TestCase( SECTION, DateString+".getUTCMilliseconds()", UTCDate.ms, DateCase.getUTCMilliseconds() ); + + new TestCase( SECTION, DateString+".getFullYear()", LocalDate.year, DateCase.getFullYear() ); + new TestCase( SECTION, DateString+".getMonth()", LocalDate.month, DateCase.getMonth() ); + new TestCase( SECTION, DateString+".getDate()", LocalDate.date, DateCase.getDate() ); + new TestCase( SECTION, DateString+".getDay()", LocalDate.day, DateCase.getDay() ); + new TestCase( SECTION, DateString+".getHours()", LocalDate.hours, DateCase.getHours() ); + new TestCase( SECTION, DateString+".getMinutes()", LocalDate.minutes, DateCase.getMinutes() ); + new TestCase( SECTION, DateString+".getSeconds()", LocalDate.seconds, DateCase.getSeconds() ); + new TestCase( SECTION, DateString+".getMilliseconds()", LocalDate.ms, DateCase.getMilliseconds() ); + + DateCase.toString = Object.prototype.toString; + + new TestCase( SECTION, + DateString+".toString=Object.prototype.toString;"+DateString+".toString()", + "[object Date]", + DateCase.toString() ); +} +function MyDate() { + this.year = 0; + this.month = 0; + this.date = 0; + this.hours = 0; + this.minutes = 0; + this.seconds = 0; + this.ms = 0; +} +function LocalDateFromTime(t) { + t = LocalTime(t); + return ( MyDateFromTime(t) ); +} +function UTCDateFromTime(t) { + return ( MyDateFromTime(t) ); +} +function MyDateFromTime( t ) { + var d = new MyDate(); + d.year = YearFromTime(t); + d.month = MonthFromTime(t); + d.date = DateFromTime(t); + d.hours = HourFromTime(t); + d.minutes = MinFromTime(t); + d.seconds = SecFromTime(t); + d.ms = msFromTime(t); + d.time = MakeTime( d.hours, d.minutes, d.seconds, d.ms ); + d.value = TimeClip( MakeDate( MakeDay( d.year, d.month, d.date ), d.time ) ); + d.day = WeekDay( d.value ); + return (d); +} diff --git a/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.23-18.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.23-18.js new file mode 100644 index 0000000000..e30d0f05c8 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.23-18.js @@ -0,0 +1,137 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.9.5.23-18.js'; + +/** + File Name: 15.9.5.23-1.js + ECMA Section: 15.9.5.23 Date.prototype.setTime(time) + Description: + + 1. If the this value is not a Date object, generate a runtime error. + 2. Call ToNumber(time). + 3. Call TimeClip(Result(1)). + 4. Set the [[Value]] property of the this value to Result(2). + 5. Return the value of the [[Value]] property of the this value. + + Author: christine@netscape.com + Date: 12 november 1997 + +*/ +var SECTION = "15.9.5.23-1"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Date.prototype.setTime()"; + +writeHeaderToLog( SECTION + " Date.prototype.setTime(time)"); + +var now = "now"; +addTestCase( now, String( TIME_2000 ) ); + +test(); + +function addTestCase( startTime, setTime ) { + if ( startTime == "now" ) { + DateCase = new Date(); + } else { + DateCase = new Date( startTime ); + } + + DateCase.setTime( setTime ); + var DateString = "var d = new Date("+startTime+"); d.setTime("+setTime+"); d" ; + var UTCDate = UTCDateFromTime ( Number(setTime) ); + var LocalDate = LocalDateFromTime( Number(setTime) ); + + new TestCase( SECTION, DateString+".getTime()", UTCDate.value, DateCase.getTime() ); + new TestCase( SECTION, DateString+".valueOf()", UTCDate.value, DateCase.valueOf() ); + + new TestCase( SECTION, DateString+".getUTCFullYear()", UTCDate.year, DateCase.getUTCFullYear() ); + new TestCase( SECTION, DateString+".getUTCMonth()", UTCDate.month, DateCase.getUTCMonth() ); + new TestCase( SECTION, DateString+".getUTCDate()", UTCDate.date, DateCase.getUTCDate() ); + new TestCase( SECTION, DateString+".getUTCDay()", UTCDate.day, DateCase.getUTCDay() ); + new TestCase( SECTION, DateString+".getUTCHours()", UTCDate.hours, DateCase.getUTCHours() ); + new TestCase( SECTION, DateString+".getUTCMinutes()", UTCDate.minutes, DateCase.getUTCMinutes() ); + new TestCase( SECTION, DateString+".getUTCSeconds()", UTCDate.seconds, DateCase.getUTCSeconds() ); + new TestCase( SECTION, DateString+".getUTCMilliseconds()", UTCDate.ms, DateCase.getUTCMilliseconds() ); + + new TestCase( SECTION, DateString+".getFullYear()", LocalDate.year, DateCase.getFullYear() ); + new TestCase( SECTION, DateString+".getMonth()", LocalDate.month, DateCase.getMonth() ); + new TestCase( SECTION, DateString+".getDate()", LocalDate.date, DateCase.getDate() ); + new TestCase( SECTION, DateString+".getDay()", LocalDate.day, DateCase.getDay() ); + new TestCase( SECTION, DateString+".getHours()", LocalDate.hours, DateCase.getHours() ); + new TestCase( SECTION, DateString+".getMinutes()", LocalDate.minutes, DateCase.getMinutes() ); + new TestCase( SECTION, DateString+".getSeconds()", LocalDate.seconds, DateCase.getSeconds() ); + new TestCase( SECTION, DateString+".getMilliseconds()", LocalDate.ms, DateCase.getMilliseconds() ); + + DateCase.toString = Object.prototype.toString; + + new TestCase( SECTION, + DateString+".toString=Object.prototype.toString;"+DateString+".toString()", + "[object Date]", + DateCase.toString() ); +} +function MyDate() { + this.year = 0; + this.month = 0; + this.date = 0; + this.hours = 0; + this.minutes = 0; + this.seconds = 0; + this.ms = 0; +} +function LocalDateFromTime(t) { + t = LocalTime(t); + return ( MyDateFromTime(t) ); +} +function UTCDateFromTime(t) { + return ( MyDateFromTime(t) ); +} +function MyDateFromTime( t ) { + var d = new MyDate(); + d.year = YearFromTime(t); + d.month = MonthFromTime(t); + d.date = DateFromTime(t); + d.hours = HourFromTime(t); + d.minutes = MinFromTime(t); + d.seconds = SecFromTime(t); + d.ms = msFromTime(t); + d.time = MakeTime( d.hours, d.minutes, d.seconds, d.ms ); + d.value = TimeClip( MakeDate( MakeDay( d.year, d.month, d.date ), d.time ) ); + d.day = WeekDay( d.value ); + return (d); +} diff --git a/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.23-2.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.23-2.js new file mode 100644 index 0000000000..8086af88d9 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.23-2.js @@ -0,0 +1,109 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.9.5.23-2.js'; + +/** + File Name: 15.9.5.23-2.js + ECMA Section: 15.9.5.23 + Description: Date.prototype.setTime + + 1. If the this value is not a Date object, generate a runtime error. + 2. Call ToNumber(time). + 3. Call TimeClip(Result(1)). + 4. Set the [[Value]] property of the this value to Result(2). + 5. Return the value of the [[Value]] property of the this value. + + Author: christine@netscape.com + Date: 12 november 1997 +*/ +var SECTION = "15.9.5.23-2"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Date.prototype.setTime()"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +test_times = new Array( TIME_NOW, TIME_1970, TIME_1900, TIME_2000 ); + +for ( var j = 0; j < test_times.length; j++ ) { + addTestCase( new Date(TIME_NOW), test_times[j] ); +} + +new TestCase( SECTION, + "(new Date(NaN)).setTime()", + NaN, + (new Date(NaN)).setTime() ); + +new TestCase( SECTION, + "Date.prototype.setTime.length", + 1, + Date.prototype.setTime.length ); +test(); + +function addTestCase( d, t ) { + new TestCase( SECTION, + "( "+d+" ).setTime("+t+")", + t, + d.setTime(t) ); + + new TestCase( SECTION, + "( "+d+" ).setTime("+(t+1.1)+")", + TimeClip(t+1.1), + d.setTime(t+1.1) ); + + new TestCase( SECTION, + "( "+d+" ).setTime("+(t+1)+")", + t+1, + d.setTime(t+1) ); + + new TestCase( SECTION, + "( "+d+" ).setTime("+(t-1)+")", + t-1, + d.setTime(t-1) ); + + new TestCase( SECTION, + "( "+d+" ).setTime("+(t-TZ_ADJUST)+")", + t-TZ_ADJUST, + d.setTime(t-TZ_ADJUST) ); + + new TestCase( SECTION, + "( "+d+" ).setTime("+(t+TZ_ADJUST)+")", + t+TZ_ADJUST, + d.setTime(t+TZ_ADJUST) ); +} diff --git a/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.23-3-n.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.23-3-n.js new file mode 100644 index 0000000000..040604bd0e --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.23-3-n.js @@ -0,0 +1,79 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.9.5.23-3-n.js'; + +/** + File Name: 15.9.5.23-3-n.js + ECMA Section: 15.9.5.23 + Description: Date.prototype.setTime + + 1. If the this value is not a Date object, generate a runtime error. + 2. Call ToNumber(time). + 3. Call TimeClip(Result(1)). + 4. Set the [[Value]] property of the this value to Result(2). + 5. Return the value of the [[Value]] property of the this value. + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + +var SECTION = "15.9.5.23-3-n"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Date.prototype.setTime()"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +var MYDATE = new MyDate(TIME_1970); + +DESCRIPTION = "MYDATE.setTime(TIME_2000)"; +EXPECTED = "error"; + +new TestCase( SECTION, + "MYDATE.setTime(TIME_2000)", + "error", + eval("MYDATE.setTime(TIME_2000)") ); + +test(); + +function MyDate(value) { + this.value = value; + this.setTime = Date.prototype.setTime; + return this; +} diff --git a/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.23-4.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.23-4.js new file mode 100644 index 0000000000..39e3dec8d4 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.23-4.js @@ -0,0 +1,112 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.9.5.23-4.js'; + +/** + File Name: 15.9.5.23-2.js + ECMA Section: 15.9.5.23 + Description: Date.prototype.setTime + + 1. If the this value is not a Date object, generate a runtime error. + 2. Call ToNumber(time). + 3. Call TimeClip(Result(1)). + 4. Set the [[Value]] property of the this value to Result(2). + 5. Return the value of the [[Value]] property of the this value. + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + +var SECTION = "15.9.5.23-2"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Date.prototype.setTime()"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +test_times = new Array( TIME_NOW, TIME_0000, TIME_1970, TIME_1900, TIME_2000, + UTC_FEB_29_2000, UTC_JAN_1_2005 ); + + +for ( var j = 0; j < test_times.length; j++ ) { + addTestCase( new Date(TIME_0000), test_times[j] ); +} + +new TestCase( SECTION, + "(new Date(NaN)).setTime()", + NaN, + (new Date(NaN)).setTime() ); + +new TestCase( SECTION, + "Date.prototype.setTime.length", + 1, + Date.prototype.setTime.length ); +test(); + +function addTestCase( d, t ) { + new TestCase( SECTION, + "( "+d+" ).setTime("+t+")", + t, + d.setTime(t) ); + + new TestCase( SECTION, + "( "+d+" ).setTime("+(t+1.1)+")", + TimeClip(t+1.1), + d.setTime(t+1.1) ); + + new TestCase( SECTION, + "( "+d+" ).setTime("+(t+1)+")", + t+1, + d.setTime(t+1) ); + + new TestCase( SECTION, + "( "+d+" ).setTime("+(t-1)+")", + t-1, + d.setTime(t-1) ); + + new TestCase( SECTION, + "( "+d+" ).setTime("+(t-TZ_ADJUST)+")", + t-TZ_ADJUST, + d.setTime(t-TZ_ADJUST) ); + + new TestCase( SECTION, + "( "+d+" ).setTime("+(t+TZ_ADJUST)+")", + t+TZ_ADJUST, + d.setTime(t+TZ_ADJUST) ); +} diff --git a/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.23-5.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.23-5.js new file mode 100644 index 0000000000..b4317e6a55 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.23-5.js @@ -0,0 +1,113 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.9.5.23-5.js'; + +/** + File Name: 15.9.5.23-2.js + ECMA Section: 15.9.5.23 + Description: Date.prototype.setTime + + 1. If the this value is not a Date object, generate a runtime error. + 2. Call ToNumber(time). + 3. Call TimeClip(Result(1)). + 4. Set the [[Value]] property of the this value to Result(2). + 5. Return the value of the [[Value]] property of the this value. + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + +var SECTION = "15.9.5.23-2"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Date.prototype.setTime()"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +test_times = new Array( TIME_NOW, TIME_0000, TIME_1970, TIME_1900, TIME_2000, + UTC_FEB_29_2000, UTC_JAN_1_2005 ); + + +for ( var j = 0; j < test_times.length; j++ ) { + addTestCase( new Date(TIME_1970), test_times[j] ); +} + + +new TestCase( SECTION, + "(new Date(NaN)).setTime()", + NaN, + (new Date(NaN)).setTime() ); + +new TestCase( SECTION, + "Date.prototype.setTime.length", + 1, + Date.prototype.setTime.length ); +test(); + +function addTestCase( d, t ) { + new TestCase( SECTION, + "( "+d+" ).setTime("+t+")", + t, + d.setTime(t) ); + + new TestCase( SECTION, + "( "+d+" ).setTime("+(t+1.1)+")", + TimeClip(t+1.1), + d.setTime(t+1.1) ); + + new TestCase( SECTION, + "( "+d+" ).setTime("+(t+1)+")", + t+1, + d.setTime(t+1) ); + + new TestCase( SECTION, + "( "+d+" ).setTime("+(t-1)+")", + t-1, + d.setTime(t-1) ); + + new TestCase( SECTION, + "( "+d+" ).setTime("+(t-TZ_ADJUST)+")", + t-TZ_ADJUST, + d.setTime(t-TZ_ADJUST) ); + + new TestCase( SECTION, + "( "+d+" ).setTime("+(t+TZ_ADJUST)+")", + t+TZ_ADJUST, + d.setTime(t+TZ_ADJUST) ); +} diff --git a/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.23-6.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.23-6.js new file mode 100644 index 0000000000..cc9e07b9fd --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.23-6.js @@ -0,0 +1,112 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.9.5.23-6.js'; + +/** + File Name: 15.9.5.23-2.js + ECMA Section: 15.9.5.23 + Description: Date.prototype.setTime + + 1. If the this value is not a Date object, generate a runtime error. + 2. Call ToNumber(time). + 3. Call TimeClip(Result(1)). + 4. Set the [[Value]] property of the this value to Result(2). + 5. Return the value of the [[Value]] property of the this value. + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + +var SECTION = "15.9.5.23-2"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Date.prototype.setTime()"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +test_times = new Array( TIME_NOW, TIME_0000, TIME_1970, TIME_1900, TIME_2000, + UTC_FEB_29_2000, UTC_JAN_1_2005 ); + + +for ( var j = 0; j < test_times.length; j++ ) { + addTestCase( new Date(TIME_1900), test_times[j] ); +} + + +new TestCase( SECTION, + "(new Date(NaN)).setTime()", + NaN, + (new Date(NaN)).setTime() ); + +new TestCase( SECTION, + "Date.prototype.setTime.length", + 1, + Date.prototype.setTime.length ); +test(); +function addTestCase( d, t ) { + new TestCase( SECTION, + "( "+d+" ).setTime("+t+")", + t, + d.setTime(t) ); + + new TestCase( SECTION, + "( "+d+" ).setTime("+(t+1.1)+")", + TimeClip(t+1.1), + d.setTime(t+1.1) ); + + new TestCase( SECTION, + "( "+d+" ).setTime("+(t+1)+")", + t+1, + d.setTime(t+1) ); + + new TestCase( SECTION, + "( "+d+" ).setTime("+(t-1)+")", + t-1, + d.setTime(t-1) ); + + new TestCase( SECTION, + "( "+d+" ).setTime("+(t-TZ_ADJUST)+")", + t-TZ_ADJUST, + d.setTime(t-TZ_ADJUST) ); + + new TestCase( SECTION, + "( "+d+" ).setTime("+(t+TZ_ADJUST)+")", + t+TZ_ADJUST, + d.setTime(t+TZ_ADJUST) ); +} diff --git a/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.23-7.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.23-7.js new file mode 100644 index 0000000000..46bb900b18 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.23-7.js @@ -0,0 +1,113 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.9.5.23-7.js'; + +/** + File Name: 15.9.5.23-2.js + ECMA Section: 15.9.5.23 + Description: Date.prototype.setTime + + 1. If the this value is not a Date object, generate a runtime error. + 2. Call ToNumber(time). + 3. Call TimeClip(Result(1)). + 4. Set the [[Value]] property of the this value to Result(2). + 5. Return the value of the [[Value]] property of the this value. + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + +var SECTION = "15.9.5.23-2"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Date.prototype.setTime()"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +test_times = new Array( TIME_NOW, TIME_0000, TIME_1970, TIME_1900, TIME_2000, + UTC_FEB_29_2000, UTC_JAN_1_2005 ); + + +for ( var j = 0; j < test_times.length; j++ ) { + addTestCase( new Date(TIME_2000), test_times[j] ); +} + + +new TestCase( SECTION, + "(new Date(NaN)).setTime()", + NaN, + (new Date(NaN)).setTime() ); + +new TestCase( SECTION, + "Date.prototype.setTime.length", + 1, + Date.prototype.setTime.length ); +test(); + +function addTestCase( d, t ) { + new TestCase( SECTION, + "( "+d+" ).setTime("+t+")", + t, + d.setTime(t) ); + + new TestCase( SECTION, + "( "+d+" ).setTime("+(t+1.1)+")", + TimeClip(t+1.1), + d.setTime(t+1.1) ); + + new TestCase( SECTION, + "( "+d+" ).setTime("+(t+1)+")", + t+1, + d.setTime(t+1) ); + + new TestCase( SECTION, + "( "+d+" ).setTime("+(t-1)+")", + t-1, + d.setTime(t-1) ); + + new TestCase( SECTION, + "( "+d+" ).setTime("+(t-TZ_ADJUST)+")", + t-TZ_ADJUST, + d.setTime(t-TZ_ADJUST) ); + + new TestCase( SECTION, + "( "+d+" ).setTime("+(t+TZ_ADJUST)+")", + t+TZ_ADJUST, + d.setTime(t+TZ_ADJUST) ); +} diff --git a/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.23-8.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.23-8.js new file mode 100644 index 0000000000..8072a9cc1f --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.23-8.js @@ -0,0 +1,103 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.9.5.23-8.js'; + +/** + File Name: 15.9.5.23-2.js + ECMA Section: 15.9.5.23 + Description: Date.prototype.setTime + + 1. If the this value is not a Date object, generate a runtime error. + 2. Call ToNumber(time). + 3. Call TimeClip(Result(1)). + 4. Set the [[Value]] property of the this value to Result(2). + 5. Return the value of the [[Value]] property of the this value. + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + +var SECTION = "15.9.5.23-2"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Date.prototype.setTime()"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +test_times = new Array( TIME_NOW, TIME_0000, TIME_1970, TIME_1900, TIME_2000, + UTC_FEB_29_2000, UTC_JAN_1_2005 ); + + +for ( var j = 0; j < test_times.length; j++ ) { + addTestCase( new Date(UTC_FEB_29_2000), test_times[j] ); +} + +test(); + +function addTestCase( d, t ) { + new TestCase( SECTION, + "( "+d+" ).setTime("+t+")", + t, + d.setTime(t) ); + + new TestCase( SECTION, + "( "+d+" ).setTime("+(t+1.1)+")", + TimeClip(t+1.1), + d.setTime(t+1.1) ); + + new TestCase( SECTION, + "( "+d+" ).setTime("+(t+1)+")", + t+1, + d.setTime(t+1) ); + + new TestCase( SECTION, + "( "+d+" ).setTime("+(t-1)+")", + t-1, + d.setTime(t-1) ); + + new TestCase( SECTION, + "( "+d+" ).setTime("+(t-TZ_ADJUST)+")", + t-TZ_ADJUST, + d.setTime(t-TZ_ADJUST) ); + + new TestCase( SECTION, + "( "+d+" ).setTime("+(t+TZ_ADJUST)+")", + t+TZ_ADJUST, + d.setTime(t+TZ_ADJUST) ); +} diff --git a/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.23-9.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.23-9.js new file mode 100644 index 0000000000..b480791e3d --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.23-9.js @@ -0,0 +1,103 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.9.5.23-9.js'; + +/** + File Name: 15.9.5.23-2.js + ECMA Section: 15.9.5.23 + Description: Date.prototype.setTime + + 1. If the this value is not a Date object, generate a runtime error. + 2. Call ToNumber(time). + 3. Call TimeClip(Result(1)). + 4. Set the [[Value]] property of the this value to Result(2). + 5. Return the value of the [[Value]] property of the this value. + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + +var SECTION = "15.9.5.23-2"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Date.prototype.setTime()"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +test_times = new Array( TIME_NOW, TIME_0000, TIME_1970, TIME_1900, TIME_2000, + UTC_FEB_29_2000, UTC_JAN_1_2005 ); + + +for ( var j = 0; j < test_times.length; j++ ) { + addTestCase( new Date(UTC_JAN_1_2005), test_times[j] ); +} + +test(); + +function addTestCase( d, t ) { + new TestCase( SECTION, + "( "+d+" ).setTime("+t+")", + t, + d.setTime(t) ); + + new TestCase( SECTION, + "( "+d+" ).setTime("+(t+1.1)+")", + TimeClip(t+1.1), + d.setTime(t+1.1) ); + + new TestCase( SECTION, + "( "+d+" ).setTime("+(t+1)+")", + t+1, + d.setTime(t+1) ); + + new TestCase( SECTION, + "( "+d+" ).setTime("+(t-1)+")", + t-1, + d.setTime(t-1) ); + + new TestCase( SECTION, + "( "+d+" ).setTime("+(t-TZ_ADJUST)+")", + t-TZ_ADJUST, + d.setTime(t-TZ_ADJUST) ); + + new TestCase( SECTION, + "( "+d+" ).setTime("+(t+TZ_ADJUST)+")", + t+TZ_ADJUST, + d.setTime(t+TZ_ADJUST) ); +} diff --git a/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.24-1.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.24-1.js new file mode 100644 index 0000000000..e02aa6150a --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.24-1.js @@ -0,0 +1,134 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.9.5.24-1.js'; + +/** + File Name: 15.9.5.24-1.js + ECMA Section: 15.9.5.24 Date.prototype.setTime(time) + Description: + 1. If the this value is not a Date object, generate a runtime error. + 2. Call ToNumber(time). + 3. Call TimeClip(Result(1)). + 4. Set the [[Value]] property of the this value to Result(2). + 5. Return the value of the [[Value]] property of the this value. + Author: christine@netscape.com + Date: 12 november 1997 + +*/ +var TITLE = "Date.prototype.setTime" + var SECTION = "15.9.5.24-1"; +var VERSION = "ECMA_1"; +startTest(); + +writeHeaderToLog( SECTION + " Date.prototype.setMilliseconds(ms)"); + + +addTestCase( 0, 0 ); + +test(); + +function addTestCase( startms, newms ) { + + var DateCase = new Date( startms ); + DateCase.setMilliseconds( newms ); + var DateString = "var date = new Date("+ startms +"); date.setMilliseconds("+ newms +"); date"; + var UTCDate = UTCDateFromTime( Number(newms) ); + var LocalDate = LocalDateFromTime( Number(newms) ); + + new TestCase( SECTION, DateString+".getTime()", UTCDate.value, DateCase.getTime() ); + new TestCase( SECTION, DateString+".valueOf()", UTCDate.value, DateCase.valueOf() ); + + new TestCase( SECTION, DateString+".getUTCFullYear()", UTCDate.year, DateCase.getUTCFullYear() ); + new TestCase( SECTION, DateString+".getUTCMonth()", UTCDate.month, DateCase.getUTCMonth() ); + new TestCase( SECTION, DateString+".getUTCDate()", UTCDate.date, DateCase.getUTCDate() ); + + new TestCase( SECTION, DateString+".getUTCHours()", UTCDate.hours, DateCase.getUTCHours() ); + new TestCase( SECTION, DateString+".getUTCMinutes()", UTCDate.minutes,DateCase.getUTCMinutes() ); + new TestCase( SECTION, DateString+".getUTCSeconds()", UTCDate.seconds,DateCase.getUTCSeconds() ); + new TestCase( SECTION, DateString+".getUTCMilliseconds()", UTCDate.ms, DateCase.getUTCMilliseconds() ); + + new TestCase( SECTION, DateString+".getFullYear()", LocalDate.year, DateCase.getFullYear() ); + new TestCase( SECTION, DateString+".getMonth()", LocalDate.month, DateCase.getMonth() ); + new TestCase( SECTION, DateString+".getDate()", LocalDate.date, DateCase.getDate() ); + + new TestCase( SECTION, DateString+".getHours()", LocalDate.hours, DateCase.getHours() ); + new TestCase( SECTION, DateString+".getMinutes()", LocalDate.minutes, DateCase.getMinutes() ); + new TestCase( SECTION, DateString+".getSeconds()", LocalDate.seconds, DateCase.getSeconds() ); + new TestCase( SECTION, DateString+".getMilliseconds()", LocalDate.ms, DateCase.getMilliseconds() ); + + DateCase.toString = Object.prototype.toString; + + new TestCase( SECTION, + DateString+".toString=Object.prototype.toString;"+DateString+".toString()", + "[object Date]", + DateCase.toString() ); +} + +function MyDate() { + this.year = 0; + this.month = 0; + this.date = 0; + this.hours = 0; + this.minutes = 0; + this.seconds = 0; + this.ms = 0; +} +function LocalDateFromTime(t) { + t = LocalTime(t); + return ( MyDateFromTime(t) ); +} +function UTCDateFromTime(t) { + return ( MyDateFromTime(t) ); +} +function MyDateFromTime( t ) { + var d = new MyDate(); + d.year = YearFromTime(t); + d.month = MonthFromTime(t); + d.date = DateFromTime(t); + d.hours = HourFromTime(t); + d.minutes = MinFromTime(t); + d.seconds = SecFromTime(t); + d.ms = msFromTime(t); + + d.time = MakeTime( d.hours, d.minutes, d.seconds, d.ms ); + d.value = TimeClip( MakeDate( MakeDay( d.year, d.month, d.date ), d.time ) ); + d.day = WeekDay( d.value ); + + return (d); +} diff --git a/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.24-2.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.24-2.js new file mode 100644 index 0000000000..da6261670b --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.24-2.js @@ -0,0 +1,134 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.9.5.24-2.js'; + +/** + File Name: 15.9.5.24-1.js + ECMA Section: 15.9.5.24 Date.prototype.setTime(time) + Description: + 1. If the this value is not a Date object, generate a runtime error. + 2. Call ToNumber(time). + 3. Call TimeClip(Result(1)). + 4. Set the [[Value]] property of the this value to Result(2). + 5. Return the value of the [[Value]] property of the this value. + Author: christine@netscape.com + Date: 12 november 1997 + +*/ +var TITLE = "Date.prototype.setTime" + var SECTION = "15.9.5.24-1"; +var VERSION = "ECMA_1"; +startTest(); + +writeHeaderToLog( SECTION + " Date.prototype.setMilliseconds(ms)"); + + +addTestCase( 0, -86400000 ); + +test(); + +function addTestCase( startms, newms ) { + + var DateCase = new Date( startms ); + DateCase.setMilliseconds( newms ); + var DateString = "var date = new Date("+ startms +"); date.setMilliseconds("+ newms +"); date"; + var UTCDate = UTCDateFromTime( Number(newms) ); + var LocalDate = LocalDateFromTime( Number(newms) ); + + new TestCase( SECTION, DateString+".getTime()", UTCDate.value, DateCase.getTime() ); + new TestCase( SECTION, DateString+".valueOf()", UTCDate.value, DateCase.valueOf() ); + + new TestCase( SECTION, DateString+".getUTCFullYear()", UTCDate.year, DateCase.getUTCFullYear() ); + new TestCase( SECTION, DateString+".getUTCMonth()", UTCDate.month, DateCase.getUTCMonth() ); + new TestCase( SECTION, DateString+".getUTCDate()", UTCDate.date, DateCase.getUTCDate() ); + + new TestCase( SECTION, DateString+".getUTCHours()", UTCDate.hours, DateCase.getUTCHours() ); + new TestCase( SECTION, DateString+".getUTCMinutes()", UTCDate.minutes,DateCase.getUTCMinutes() ); + new TestCase( SECTION, DateString+".getUTCSeconds()", UTCDate.seconds,DateCase.getUTCSeconds() ); + new TestCase( SECTION, DateString+".getUTCMilliseconds()", UTCDate.ms, DateCase.getUTCMilliseconds() ); + + new TestCase( SECTION, DateString+".getFullYear()", LocalDate.year, DateCase.getFullYear() ); + new TestCase( SECTION, DateString+".getMonth()", LocalDate.month, DateCase.getMonth() ); + new TestCase( SECTION, DateString+".getDate()", LocalDate.date, DateCase.getDate() ); + + new TestCase( SECTION, DateString+".getHours()", LocalDate.hours, DateCase.getHours() ); + new TestCase( SECTION, DateString+".getMinutes()", LocalDate.minutes, DateCase.getMinutes() ); + new TestCase( SECTION, DateString+".getSeconds()", LocalDate.seconds, DateCase.getSeconds() ); + new TestCase( SECTION, DateString+".getMilliseconds()", LocalDate.ms, DateCase.getMilliseconds() ); + + DateCase.toString = Object.prototype.toString; + + new TestCase( SECTION, + DateString+".toString=Object.prototype.toString;"+DateString+".toString()", + "[object Date]", + DateCase.toString() ); +} + +function MyDate() { + this.year = 0; + this.month = 0; + this.date = 0; + this.hours = 0; + this.minutes = 0; + this.seconds = 0; + this.ms = 0; +} +function LocalDateFromTime(t) { + t = LocalTime(t); + return ( MyDateFromTime(t) ); +} +function UTCDateFromTime(t) { + return ( MyDateFromTime(t) ); +} +function MyDateFromTime( t ) { + var d = new MyDate(); + d.year = YearFromTime(t); + d.month = MonthFromTime(t); + d.date = DateFromTime(t); + d.hours = HourFromTime(t); + d.minutes = MinFromTime(t); + d.seconds = SecFromTime(t); + d.ms = msFromTime(t); + + d.time = MakeTime( d.hours, d.minutes, d.seconds, d.ms ); + d.value = TimeClip( MakeDate( MakeDay( d.year, d.month, d.date ), d.time ) ); + d.day = WeekDay( d.value ); + + return (d); +} diff --git a/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.24-3.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.24-3.js new file mode 100644 index 0000000000..8199010953 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.24-3.js @@ -0,0 +1,134 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.9.5.24-3.js'; + +/** + File Name: 15.9.5.24-1.js + ECMA Section: 15.9.5.24 Date.prototype.setTime(time) + Description: + 1. If the this value is not a Date object, generate a runtime error. + 2. Call ToNumber(time). + 3. Call TimeClip(Result(1)). + 4. Set the [[Value]] property of the this value to Result(2). + 5. Return the value of the [[Value]] property of the this value. + Author: christine@netscape.com + Date: 12 november 1997 + +*/ +var TITLE = "Date.prototype.setTime" + var SECTION = "15.9.5.24-1"; +var VERSION = "ECMA_1"; +startTest(); + +writeHeaderToLog( SECTION + " Date.prototype.setMilliseconds(ms)"); + + +addTestCase( 0, -2208988800000 ); + +test(); + +function addTestCase( startms, newms ) { + + var DateCase = new Date( startms ); + DateCase.setMilliseconds( newms ); + var DateString = "var date = new Date("+ startms +"); date.setMilliseconds("+ newms +"); date"; + var UTCDate = UTCDateFromTime( Number(newms) ); + var LocalDate = LocalDateFromTime( Number(newms) ); + + new TestCase( SECTION, DateString+".getTime()", UTCDate.value, DateCase.getTime() ); + new TestCase( SECTION, DateString+".valueOf()", UTCDate.value, DateCase.valueOf() ); + + new TestCase( SECTION, DateString+".getUTCFullYear()", UTCDate.year, DateCase.getUTCFullYear() ); + new TestCase( SECTION, DateString+".getUTCMonth()", UTCDate.month, DateCase.getUTCMonth() ); + new TestCase( SECTION, DateString+".getUTCDate()", UTCDate.date, DateCase.getUTCDate() ); + + new TestCase( SECTION, DateString+".getUTCHours()", UTCDate.hours, DateCase.getUTCHours() ); + new TestCase( SECTION, DateString+".getUTCMinutes()", UTCDate.minutes,DateCase.getUTCMinutes() ); + new TestCase( SECTION, DateString+".getUTCSeconds()", UTCDate.seconds,DateCase.getUTCSeconds() ); + new TestCase( SECTION, DateString+".getUTCMilliseconds()", UTCDate.ms, DateCase.getUTCMilliseconds() ); + + new TestCase( SECTION, DateString+".getFullYear()", LocalDate.year, DateCase.getFullYear() ); + new TestCase( SECTION, DateString+".getMonth()", LocalDate.month, DateCase.getMonth() ); + new TestCase( SECTION, DateString+".getDate()", LocalDate.date, DateCase.getDate() ); + + new TestCase( SECTION, DateString+".getHours()", LocalDate.hours, DateCase.getHours() ); + new TestCase( SECTION, DateString+".getMinutes()", LocalDate.minutes, DateCase.getMinutes() ); + new TestCase( SECTION, DateString+".getSeconds()", LocalDate.seconds, DateCase.getSeconds() ); + new TestCase( SECTION, DateString+".getMilliseconds()", LocalDate.ms, DateCase.getMilliseconds() ); + + DateCase.toString = Object.prototype.toString; + + new TestCase( SECTION, + DateString+".toString=Object.prototype.toString;"+DateString+".toString()", + "[object Date]", + DateCase.toString() ); +} + +function MyDate() { + this.year = 0; + this.month = 0; + this.date = 0; + this.hours = 0; + this.minutes = 0; + this.seconds = 0; + this.ms = 0; +} +function LocalDateFromTime(t) { + t = LocalTime(t); + return ( MyDateFromTime(t) ); +} +function UTCDateFromTime(t) { + return ( MyDateFromTime(t) ); +} +function MyDateFromTime( t ) { + var d = new MyDate(); + d.year = YearFromTime(t); + d.month = MonthFromTime(t); + d.date = DateFromTime(t); + d.hours = HourFromTime(t); + d.minutes = MinFromTime(t); + d.seconds = SecFromTime(t); + d.ms = msFromTime(t); + + d.time = MakeTime( d.hours, d.minutes, d.seconds, d.ms ); + d.value = TimeClip( MakeDate( MakeDay( d.year, d.month, d.date ), d.time ) ); + d.day = WeekDay( d.value ); + + return (d); +} diff --git a/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.24-4.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.24-4.js new file mode 100644 index 0000000000..f6b1dae966 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.24-4.js @@ -0,0 +1,134 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.9.5.24-4.js'; + +/** + File Name: 15.9.5.24-1.js + ECMA Section: 15.9.5.24 Date.prototype.setTime(time) + Description: + 1. If the this value is not a Date object, generate a runtime error. + 2. Call ToNumber(time). + 3. Call TimeClip(Result(1)). + 4. Set the [[Value]] property of the this value to Result(2). + 5. Return the value of the [[Value]] property of the this value. + Author: christine@netscape.com + Date: 12 november 1997 + +*/ +var TITLE = "Date.prototype.setTime" + var SECTION = "15.9.5.24-1"; +var VERSION = "ECMA_1"; +startTest(); + +writeHeaderToLog( SECTION + " Date.prototype.setMilliseconds(ms)"); + + +addTestCase( 0, 946684800000 ); + +test(); + +function addTestCase( startms, newms ) { + + var DateCase = new Date( startms ); + DateCase.setMilliseconds( newms ); + var DateString = "var date = new Date("+ startms +"); date.setMilliseconds("+ newms +"); date"; + var UTCDate = UTCDateFromTime( Number(newms) ); + var LocalDate = LocalDateFromTime( Number(newms) ); + + new TestCase( SECTION, DateString+".getTime()", UTCDate.value, DateCase.getTime() ); + new TestCase( SECTION, DateString+".valueOf()", UTCDate.value, DateCase.valueOf() ); + + new TestCase( SECTION, DateString+".getUTCFullYear()", UTCDate.year, DateCase.getUTCFullYear() ); + new TestCase( SECTION, DateString+".getUTCMonth()", UTCDate.month, DateCase.getUTCMonth() ); + new TestCase( SECTION, DateString+".getUTCDate()", UTCDate.date, DateCase.getUTCDate() ); + + new TestCase( SECTION, DateString+".getUTCHours()", UTCDate.hours, DateCase.getUTCHours() ); + new TestCase( SECTION, DateString+".getUTCMinutes()", UTCDate.minutes,DateCase.getUTCMinutes() ); + new TestCase( SECTION, DateString+".getUTCSeconds()", UTCDate.seconds,DateCase.getUTCSeconds() ); + new TestCase( SECTION, DateString+".getUTCMilliseconds()", UTCDate.ms, DateCase.getUTCMilliseconds() ); + + new TestCase( SECTION, DateString+".getFullYear()", LocalDate.year, DateCase.getFullYear() ); + new TestCase( SECTION, DateString+".getMonth()", LocalDate.month, DateCase.getMonth() ); + new TestCase( SECTION, DateString+".getDate()", LocalDate.date, DateCase.getDate() ); + + new TestCase( SECTION, DateString+".getHours()", LocalDate.hours, DateCase.getHours() ); + new TestCase( SECTION, DateString+".getMinutes()", LocalDate.minutes, DateCase.getMinutes() ); + new TestCase( SECTION, DateString+".getSeconds()", LocalDate.seconds, DateCase.getSeconds() ); + new TestCase( SECTION, DateString+".getMilliseconds()", LocalDate.ms, DateCase.getMilliseconds() ); + + DateCase.toString = Object.prototype.toString; + + new TestCase( SECTION, + DateString+".toString=Object.prototype.toString;"+DateString+".toString()", + "[object Date]", + DateCase.toString() ); +} + +function MyDate() { + this.year = 0; + this.month = 0; + this.date = 0; + this.hours = 0; + this.minutes = 0; + this.seconds = 0; + this.ms = 0; +} +function LocalDateFromTime(t) { + t = LocalTime(t); + return ( MyDateFromTime(t) ); +} +function UTCDateFromTime(t) { + return ( MyDateFromTime(t) ); +} +function MyDateFromTime( t ) { + var d = new MyDate(); + d.year = YearFromTime(t); + d.month = MonthFromTime(t); + d.date = DateFromTime(t); + d.hours = HourFromTime(t); + d.minutes = MinFromTime(t); + d.seconds = SecFromTime(t); + d.ms = msFromTime(t); + + d.time = MakeTime( d.hours, d.minutes, d.seconds, d.ms ); + d.value = TimeClip( MakeDate( MakeDay( d.year, d.month, d.date ), d.time ) ); + d.day = WeekDay( d.value ); + + return (d); +} diff --git a/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.24-5.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.24-5.js new file mode 100644 index 0000000000..53458028be --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.24-5.js @@ -0,0 +1,134 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.9.5.24-5.js'; + +/** + File Name: 15.9.5.24-1.js + ECMA Section: 15.9.5.24 Date.prototype.setTime(time) + Description: + 1. If the this value is not a Date object, generate a runtime error. + 2. Call ToNumber(time). + 3. Call TimeClip(Result(1)). + 4. Set the [[Value]] property of the this value to Result(2). + 5. Return the value of the [[Value]] property of the this value. + Author: christine@netscape.com + Date: 12 november 1997 + +*/ +var TITLE = "Date.prototype.setTime" + var SECTION = "15.9.5.24-1"; +var VERSION = "ECMA_1"; +startTest(); + +writeHeaderToLog( SECTION + " Date.prototype.setMilliseconds(ms)"); + + +addTestCase( 0, "0" ); + +test(); + +function addTestCase( startms, newms ) { + + var DateCase = new Date( startms ); + DateCase.setMilliseconds( newms ); + var DateString = "var date = new Date("+ startms +"); date.setMilliseconds("+ newms +"); date"; + var UTCDate = UTCDateFromTime( Number(newms) ); + var LocalDate = LocalDateFromTime( Number(newms) ); + + new TestCase( SECTION, DateString+".getTime()", UTCDate.value, DateCase.getTime() ); + new TestCase( SECTION, DateString+".valueOf()", UTCDate.value, DateCase.valueOf() ); + + new TestCase( SECTION, DateString+".getUTCFullYear()", UTCDate.year, DateCase.getUTCFullYear() ); + new TestCase( SECTION, DateString+".getUTCMonth()", UTCDate.month, DateCase.getUTCMonth() ); + new TestCase( SECTION, DateString+".getUTCDate()", UTCDate.date, DateCase.getUTCDate() ); + + new TestCase( SECTION, DateString+".getUTCHours()", UTCDate.hours, DateCase.getUTCHours() ); + new TestCase( SECTION, DateString+".getUTCMinutes()", UTCDate.minutes,DateCase.getUTCMinutes() ); + new TestCase( SECTION, DateString+".getUTCSeconds()", UTCDate.seconds,DateCase.getUTCSeconds() ); + new TestCase( SECTION, DateString+".getUTCMilliseconds()", UTCDate.ms, DateCase.getUTCMilliseconds() ); + + new TestCase( SECTION, DateString+".getFullYear()", LocalDate.year, DateCase.getFullYear() ); + new TestCase( SECTION, DateString+".getMonth()", LocalDate.month, DateCase.getMonth() ); + new TestCase( SECTION, DateString+".getDate()", LocalDate.date, DateCase.getDate() ); + + new TestCase( SECTION, DateString+".getHours()", LocalDate.hours, DateCase.getHours() ); + new TestCase( SECTION, DateString+".getMinutes()", LocalDate.minutes, DateCase.getMinutes() ); + new TestCase( SECTION, DateString+".getSeconds()", LocalDate.seconds, DateCase.getSeconds() ); + new TestCase( SECTION, DateString+".getMilliseconds()", LocalDate.ms, DateCase.getMilliseconds() ); + + DateCase.toString = Object.prototype.toString; + + new TestCase( SECTION, + DateString+".toString=Object.prototype.toString;"+DateString+".toString()", + "[object Date]", + DateCase.toString() ); +} + +function MyDate() { + this.year = 0; + this.month = 0; + this.date = 0; + this.hours = 0; + this.minutes = 0; + this.seconds = 0; + this.ms = 0; +} +function LocalDateFromTime(t) { + t = LocalTime(t); + return ( MyDateFromTime(t) ); +} +function UTCDateFromTime(t) { + return ( MyDateFromTime(t) ); +} +function MyDateFromTime( t ) { + var d = new MyDate(); + d.year = YearFromTime(t); + d.month = MonthFromTime(t); + d.date = DateFromTime(t); + d.hours = HourFromTime(t); + d.minutes = MinFromTime(t); + d.seconds = SecFromTime(t); + d.ms = msFromTime(t); + + d.time = MakeTime( d.hours, d.minutes, d.seconds, d.ms ); + d.value = TimeClip( MakeDate( MakeDay( d.year, d.month, d.date ), d.time ) ); + d.day = WeekDay( d.value ); + + return (d); +} diff --git a/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.24-6.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.24-6.js new file mode 100644 index 0000000000..188dbacff9 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.24-6.js @@ -0,0 +1,134 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.9.5.24-6.js'; + +/** + File Name: 15.9.5.24-1.js + ECMA Section: 15.9.5.24 Date.prototype.setTime(time) + Description: + 1. If the this value is not a Date object, generate a runtime error. + 2. Call ToNumber(time). + 3. Call TimeClip(Result(1)). + 4. Set the [[Value]] property of the this value to Result(2). + 5. Return the value of the [[Value]] property of the this value. + Author: christine@netscape.com + Date: 12 november 1997 + +*/ +var TITLE = "Date.prototype.setTime" + var SECTION = "15.9.5.24-1"; +var VERSION = "ECMA_1"; +startTest(); + +writeHeaderToLog( SECTION + " Date.prototype.setMilliseconds(ms)"); + + +addTestCase( 0, "-2208988800000" ); + +test(); + +function addTestCase( startms, newms ) { + + var DateCase = new Date( startms ); + DateCase.setMilliseconds( newms ); + var DateString = "var date = new Date("+ startms +"); date.setMilliseconds("+ newms +"); date"; + var UTCDate = UTCDateFromTime( Number(newms) ); + var LocalDate = LocalDateFromTime( Number(newms) ); + + new TestCase( SECTION, DateString+".getTime()", UTCDate.value, DateCase.getTime() ); + new TestCase( SECTION, DateString+".valueOf()", UTCDate.value, DateCase.valueOf() ); + + new TestCase( SECTION, DateString+".getUTCFullYear()", UTCDate.year, DateCase.getUTCFullYear() ); + new TestCase( SECTION, DateString+".getUTCMonth()", UTCDate.month, DateCase.getUTCMonth() ); + new TestCase( SECTION, DateString+".getUTCDate()", UTCDate.date, DateCase.getUTCDate() ); + + new TestCase( SECTION, DateString+".getUTCHours()", UTCDate.hours, DateCase.getUTCHours() ); + new TestCase( SECTION, DateString+".getUTCMinutes()", UTCDate.minutes,DateCase.getUTCMinutes() ); + new TestCase( SECTION, DateString+".getUTCSeconds()", UTCDate.seconds,DateCase.getUTCSeconds() ); + new TestCase( SECTION, DateString+".getUTCMilliseconds()", UTCDate.ms, DateCase.getUTCMilliseconds() ); + + new TestCase( SECTION, DateString+".getFullYear()", LocalDate.year, DateCase.getFullYear() ); + new TestCase( SECTION, DateString+".getMonth()", LocalDate.month, DateCase.getMonth() ); + new TestCase( SECTION, DateString+".getDate()", LocalDate.date, DateCase.getDate() ); + + new TestCase( SECTION, DateString+".getHours()", LocalDate.hours, DateCase.getHours() ); + new TestCase( SECTION, DateString+".getMinutes()", LocalDate.minutes, DateCase.getMinutes() ); + new TestCase( SECTION, DateString+".getSeconds()", LocalDate.seconds, DateCase.getSeconds() ); + new TestCase( SECTION, DateString+".getMilliseconds()", LocalDate.ms, DateCase.getMilliseconds() ); + + DateCase.toString = Object.prototype.toString; + + new TestCase( SECTION, + DateString+".toString=Object.prototype.toString;"+DateString+".toString()", + "[object Date]", + DateCase.toString() ); +} + +function MyDate() { + this.year = 0; + this.month = 0; + this.date = 0; + this.hours = 0; + this.minutes = 0; + this.seconds = 0; + this.ms = 0; +} +function LocalDateFromTime(t) { + t = LocalTime(t); + return ( MyDateFromTime(t) ); +} +function UTCDateFromTime(t) { + return ( MyDateFromTime(t) ); +} +function MyDateFromTime( t ) { + var d = new MyDate(); + d.year = YearFromTime(t); + d.month = MonthFromTime(t); + d.date = DateFromTime(t); + d.hours = HourFromTime(t); + d.minutes = MinFromTime(t); + d.seconds = SecFromTime(t); + d.ms = msFromTime(t); + + d.time = MakeTime( d.hours, d.minutes, d.seconds, d.ms ); + d.value = TimeClip( MakeDate( MakeDay( d.year, d.month, d.date ), d.time ) ); + d.day = WeekDay( d.value ); + + return (d); +} diff --git a/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.24-7.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.24-7.js new file mode 100644 index 0000000000..b2fe8fcff9 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.24-7.js @@ -0,0 +1,134 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.9.5.24-7.js'; + +/** + File Name: 15.9.5.24-1.js + ECMA Section: 15.9.5.24 Date.prototype.setTime(time) + Description: + 1. If the this value is not a Date object, generate a runtime error. + 2. Call ToNumber(time). + 3. Call TimeClip(Result(1)). + 4. Set the [[Value]] property of the this value to Result(2). + 5. Return the value of the [[Value]] property of the this value. + Author: christine@netscape.com + Date: 12 november 1997 + +*/ +var TITLE = "Date.prototype.setTime" + var SECTION = "15.9.5.24-1"; +var VERSION = "ECMA_1"; +startTest(); + +writeHeaderToLog( SECTION + " Date.prototype.setMilliseconds(ms)"); + + +addTestCase( 0, "-86400000" ); + +test(); + +function addTestCase( startms, newms ) { + + var DateCase = new Date( startms ); + DateCase.setMilliseconds( newms ); + var DateString = "var date = new Date("+ startms +"); date.setMilliseconds("+ newms +"); date"; + var UTCDate = UTCDateFromTime( Number(newms) ); + var LocalDate = LocalDateFromTime( Number(newms) ); + + new TestCase( SECTION, DateString+".getTime()", UTCDate.value, DateCase.getTime() ); + new TestCase( SECTION, DateString+".valueOf()", UTCDate.value, DateCase.valueOf() ); + + new TestCase( SECTION, DateString+".getUTCFullYear()", UTCDate.year, DateCase.getUTCFullYear() ); + new TestCase( SECTION, DateString+".getUTCMonth()", UTCDate.month, DateCase.getUTCMonth() ); + new TestCase( SECTION, DateString+".getUTCDate()", UTCDate.date, DateCase.getUTCDate() ); + + new TestCase( SECTION, DateString+".getUTCHours()", UTCDate.hours, DateCase.getUTCHours() ); + new TestCase( SECTION, DateString+".getUTCMinutes()", UTCDate.minutes,DateCase.getUTCMinutes() ); + new TestCase( SECTION, DateString+".getUTCSeconds()", UTCDate.seconds,DateCase.getUTCSeconds() ); + new TestCase( SECTION, DateString+".getUTCMilliseconds()", UTCDate.ms, DateCase.getUTCMilliseconds() ); + + new TestCase( SECTION, DateString+".getFullYear()", LocalDate.year, DateCase.getFullYear() ); + new TestCase( SECTION, DateString+".getMonth()", LocalDate.month, DateCase.getMonth() ); + new TestCase( SECTION, DateString+".getDate()", LocalDate.date, DateCase.getDate() ); + + new TestCase( SECTION, DateString+".getHours()", LocalDate.hours, DateCase.getHours() ); + new TestCase( SECTION, DateString+".getMinutes()", LocalDate.minutes, DateCase.getMinutes() ); + new TestCase( SECTION, DateString+".getSeconds()", LocalDate.seconds, DateCase.getSeconds() ); + new TestCase( SECTION, DateString+".getMilliseconds()", LocalDate.ms, DateCase.getMilliseconds() ); + + DateCase.toString = Object.prototype.toString; + + new TestCase( SECTION, + DateString+".toString=Object.prototype.toString;"+DateString+".toString()", + "[object Date]", + DateCase.toString() ); +} + +function MyDate() { + this.year = 0; + this.month = 0; + this.date = 0; + this.hours = 0; + this.minutes = 0; + this.seconds = 0; + this.ms = 0; +} +function LocalDateFromTime(t) { + t = LocalTime(t); + return ( MyDateFromTime(t) ); +} +function UTCDateFromTime(t) { + return ( MyDateFromTime(t) ); +} +function MyDateFromTime( t ) { + var d = new MyDate(); + d.year = YearFromTime(t); + d.month = MonthFromTime(t); + d.date = DateFromTime(t); + d.hours = HourFromTime(t); + d.minutes = MinFromTime(t); + d.seconds = SecFromTime(t); + d.ms = msFromTime(t); + + d.time = MakeTime( d.hours, d.minutes, d.seconds, d.ms ); + d.value = TimeClip( MakeDate( MakeDay( d.year, d.month, d.date ), d.time ) ); + d.day = WeekDay( d.value ); + + return (d); +} diff --git a/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.24-8.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.24-8.js new file mode 100644 index 0000000000..d6ea2d8d3e --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.24-8.js @@ -0,0 +1,133 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.9.5.24-8.js'; + +/** + File Name: 15.9.5.24-1.js + ECMA Section: 15.9.5.24 Date.prototype.setTime(time) + Description: + 1. If the this value is not a Date object, generate a runtime error. + 2. Call ToNumber(time). + 3. Call TimeClip(Result(1)). + 4. Set the [[Value]] property of the this value to Result(2). + 5. Return the value of the [[Value]] property of the this value. + Author: christine@netscape.com + Date: 12 november 1997 + +*/ +var TITLE = "Date.prototype.setTime" + var SECTION = "15.9.5.24-1"; +var VERSION = "ECMA_1"; +startTest(); + +writeHeaderToLog( SECTION + " Date.prototype.setMilliseconds(ms)"); + +addTestCase( 0, "946684800000" ); + +test(); + +function addTestCase( startms, newms ) { + + var DateCase = new Date( startms ); + DateCase.setMilliseconds( newms ); + var DateString = "var date = new Date("+ startms +"); date.setMilliseconds("+ newms +"); date"; + var UTCDate = UTCDateFromTime( Number(newms) ); + var LocalDate = LocalDateFromTime( Number(newms) ); + + new TestCase( SECTION, DateString+".getTime()", UTCDate.value, DateCase.getTime() ); + new TestCase( SECTION, DateString+".valueOf()", UTCDate.value, DateCase.valueOf() ); + + new TestCase( SECTION, DateString+".getUTCFullYear()", UTCDate.year, DateCase.getUTCFullYear() ); + new TestCase( SECTION, DateString+".getUTCMonth()", UTCDate.month, DateCase.getUTCMonth() ); + new TestCase( SECTION, DateString+".getUTCDate()", UTCDate.date, DateCase.getUTCDate() ); + + new TestCase( SECTION, DateString+".getUTCHours()", UTCDate.hours, DateCase.getUTCHours() ); + new TestCase( SECTION, DateString+".getUTCMinutes()", UTCDate.minutes,DateCase.getUTCMinutes() ); + new TestCase( SECTION, DateString+".getUTCSeconds()", UTCDate.seconds,DateCase.getUTCSeconds() ); + new TestCase( SECTION, DateString+".getUTCMilliseconds()", UTCDate.ms, DateCase.getUTCMilliseconds() ); + + new TestCase( SECTION, DateString+".getFullYear()", LocalDate.year, DateCase.getFullYear() ); + new TestCase( SECTION, DateString+".getMonth()", LocalDate.month, DateCase.getMonth() ); + new TestCase( SECTION, DateString+".getDate()", LocalDate.date, DateCase.getDate() ); + + new TestCase( SECTION, DateString+".getHours()", LocalDate.hours, DateCase.getHours() ); + new TestCase( SECTION, DateString+".getMinutes()", LocalDate.minutes, DateCase.getMinutes() ); + new TestCase( SECTION, DateString+".getSeconds()", LocalDate.seconds, DateCase.getSeconds() ); + new TestCase( SECTION, DateString+".getMilliseconds()", LocalDate.ms, DateCase.getMilliseconds() ); + + DateCase.toString = Object.prototype.toString; + + new TestCase( SECTION, + DateString+".toString=Object.prototype.toString;"+DateString+".toString()", + "[object Date]", + DateCase.toString() ); +} + +function MyDate() { + this.year = 0; + this.month = 0; + this.date = 0; + this.hours = 0; + this.minutes = 0; + this.seconds = 0; + this.ms = 0; +} +function LocalDateFromTime(t) { + t = LocalTime(t); + return ( MyDateFromTime(t) ); +} +function UTCDateFromTime(t) { + return ( MyDateFromTime(t) ); +} +function MyDateFromTime( t ) { + var d = new MyDate(); + d.year = YearFromTime(t); + d.month = MonthFromTime(t); + d.date = DateFromTime(t); + d.hours = HourFromTime(t); + d.minutes = MinFromTime(t); + d.seconds = SecFromTime(t); + d.ms = msFromTime(t); + + d.time = MakeTime( d.hours, d.minutes, d.seconds, d.ms ); + d.value = TimeClip( MakeDate( MakeDay( d.year, d.month, d.date ), d.time ) ); + d.day = WeekDay( d.value ); + + return (d); +} diff --git a/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.25-1.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.25-1.js new file mode 100644 index 0000000000..0eb7783ec8 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.25-1.js @@ -0,0 +1,174 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.9.5.25-1.js'; + +/** + File Name: 15.9.5.25-1.js + ECMA Section: 15.9.5.25 Date.prototype.setUTCMilliseconds(ms) + Description: + 1. Let t be this time value. + 2. Call ToNumber(ms). + 3. Compute MakeTime(HourFromTime(t), MinFromTime(t), SecFromTime(t), Result(2)). + 4. Compute MakeDate(Day(t), Result(3)). + 5. Set the [[Value]] property of the this value to TimeClip(Result(4)). + 6. Return the value of the [[Value]] property of the this value. + Author: christine@netscape.com + Date: 12 november 1997 +*/ +var SECTION = "15.9.5.25-1"; +var VERSION = "ECMA_1"; +startTest(); + +writeHeaderToLog( SECTION + " Date.prototype.setUTCMilliseconds(ms)"); + +addNewTestCase( 0, 0, "TDATE = new Date(0);(TDATE).setUTCMilliseconds(0);TDATE", + UTCDateFromTime(SetUTCMilliseconds(0,0)), + LocalDateFromTime(SetUTCMilliseconds(0,0)) ); +addNewTestCase( 28800000,999, + "TDATE = new Date(28800000);(TDATE).setUTCMilliseconds(999);TDATE", + UTCDateFromTime(SetUTCMilliseconds(28800000,999)), + LocalDateFromTime(SetUTCMilliseconds(28800000,999)) ); +addNewTestCase( 28800000,-28800000, + "TDATE = new Date(28800000);(TDATE).setUTCMilliseconds(-28800000);TDATE", + UTCDateFromTime(SetUTCMilliseconds(28800000,-28800000)), + LocalDateFromTime(SetUTCMilliseconds(28800000,-28800000)) ); +addNewTestCase( 946684800000,1234567, + "TDATE = new Date(946684800000);(TDATE).setUTCMilliseconds(1234567);TDATE", + UTCDateFromTime(SetUTCMilliseconds(946684800000,1234567)), + LocalDateFromTime(SetUTCMilliseconds(946684800000,1234567)) ); +addNewTestCase( 946684800000, 123456789, + "TDATE = new Date(946684800000);(TDATE).setUTCMilliseconds(123456789);TDATE", + UTCDateFromTime(SetUTCMilliseconds(946684800000,123456789)), + LocalDateFromTime(SetUTCMilliseconds(946684800000,123456789)) ); + +addNewTestCase( -2208988800000,123456789, + "TDATE = new Date(-2208988800000);(TDATE).setUTCMilliseconds(123456789);TDATE", + UTCDateFromTime(SetUTCMilliseconds(-2208988800000,123456789)), + LocalDateFromTime(SetUTCMilliseconds(-2208988800000,123456789)) ); + +addNewTestCase( -2208988800000,123456, + "TDATE = new Date(-2208988800000);(TDATE).setUTCMilliseconds(123456);TDATE", + UTCDateFromTime(SetUTCMilliseconds(-2208988800000,123456)), + LocalDateFromTime(SetUTCMilliseconds(-2208988800000,123456)) ); + +addNewTestCase( -2208988800000,-123456, + "TDATE = new Date(-2208988800000);(TDATE).setUTCMilliseconds(-123456);TDATE", + UTCDateFromTime(SetUTCMilliseconds(-2208988800000,-123456)), + LocalDateFromTime(SetUTCMilliseconds(-2208988800000,-123456)) ); + +addNewTestCase( 0,-999, + "TDATE = new Date(0);(TDATE).setUTCMilliseconds(-999);TDATE", + UTCDateFromTime(SetUTCMilliseconds(0,-999)), + LocalDateFromTime(SetUTCMilliseconds(0,-999)) ); + +test(); + +function addNewTestCase( initialTime, ms, DateString, UTCDate, LocalDate) { + DateCase = new Date(initialTime); + DateCase.setUTCMilliseconds(ms); + + new TestCase( SECTION, DateString+".getTime()", UTCDate.value, DateCase.getTime() ); + new TestCase( SECTION, DateString+".valueOf()", UTCDate.value, DateCase.valueOf() ); + + new TestCase( SECTION, DateString+".getUTCFullYear()", UTCDate.year, DateCase.getUTCFullYear() ); + new TestCase( SECTION, DateString+".getUTCMonth()", UTCDate.month, DateCase.getUTCMonth() ); + new TestCase( SECTION, DateString+".getUTCDate()", UTCDate.date, DateCase.getUTCDate() ); + + new TestCase( SECTION, DateString+".getUTCHours()", UTCDate.hours, DateCase.getUTCHours() ); + new TestCase( SECTION, DateString+".getUTCMinutes()", UTCDate.minutes,DateCase.getUTCMinutes() ); + new TestCase( SECTION, DateString+".getUTCSeconds()", UTCDate.seconds,DateCase.getUTCSeconds() ); + new TestCase( SECTION, DateString+".getUTCMilliseconds()", UTCDate.ms, DateCase.getUTCMilliseconds() ); + + new TestCase( SECTION, DateString+".getFullYear()", LocalDate.year, DateCase.getFullYear() ); + new TestCase( SECTION, DateString+".getMonth()", LocalDate.month, DateCase.getMonth() ); + new TestCase( SECTION, DateString+".getDate()", LocalDate.date, DateCase.getDate() ); + + new TestCase( SECTION, DateString+".getHours()", LocalDate.hours, DateCase.getHours() ); + new TestCase( SECTION, DateString+".getMinutes()", LocalDate.minutes, DateCase.getMinutes() ); + new TestCase( SECTION, DateString+".getSeconds()", LocalDate.seconds, DateCase.getSeconds() ); + new TestCase( SECTION, DateString+".getMilliseconds()", LocalDate.ms, DateCase.getMilliseconds() ); + + DateCase.toString = Object.prototype.toString; + + new TestCase( SECTION, + DateString+".toString=Object.prototype.toString;"+DateString+".toString()", + "[object Date]", + DateCase.toString() ); +} +function MyDate() { + this.year = 0; + this.month = 0; + this.date = 0; + this.hours = 0; + this.minutes = 0; + this.seconds = 0; + this.ms = 0; +} +function LocalDateFromTime(t) { + t = LocalTime(t); + return ( MyDateFromTime(t) ); +} +function UTCDateFromTime(t) { + return ( MyDateFromTime(t) ); +} +function MyDateFromTime( t ) { + var d = new MyDate(); + d.year = YearFromTime(t); + d.month = MonthFromTime(t); + d.date = DateFromTime(t); + d.hours = HourFromTime(t); + d.minutes = MinFromTime(t); + d.seconds = SecFromTime(t); + d.ms = msFromTime(t); + + d.time = MakeTime( d.hours, d.minutes, d.seconds, d.ms ); + d.value = TimeClip( MakeDate( MakeDay( d.year, d.month, d.date ), d.time ) ); + d.day = WeekDay( d.value ); + + return (d); +} + +function SetUTCMilliseconds( T, MS ) { + T = Number( T ); + TIME = MakeTime( HourFromTime(T), + MinFromTime(T), + SecFromTime(T), + MS ); + return( MakeDate( Day(T), TIME )); +} diff --git a/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.26-1.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.26-1.js new file mode 100644 index 0000000000..509ec73d33 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.26-1.js @@ -0,0 +1,183 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.9.5.26-1.js'; + +/** File Name: 15.9.5.26-1.js + ECMA Section: 15.9.5.26 Date.prototype.setSeconds(sec [,ms]) + Description: + + If ms is not specified, this behaves as if ms were specified with the + value getMilliseconds( ). + + 1. Let t be the result of LocalTime(this time value). + 2. Call ToNumber(sec). + 3. If ms is not specified, compute msFromTime(t); otherwise, call + ToNumber(ms). + 4. Compute MakeTime(HourFromTime(t), MinFromTime(t), Result(2), + Result(3)). + 5. Compute UTC(MakeDate(Day(t), Result(4))). + 6. Set the [[Value]] property of the this value to TimeClip(Result(5)). + 7. Return the value of the [[Value]] property of the this value. + + Author: christine@netscape.com + Date: 12 november 1997 +*/ +var SECTION = "15.9.5.26-1"; +var VERSION = "ECMA_1"; +startTest(); + +writeHeaderToLog( SECTION + " Date.prototype.setSeconds(sec [,ms] )"); + +addNewTestCase( 0, 0, 0, + "TDATE = new Date(0);(TDATE).setSeconds(0,0);TDATE", + UTCDateFromTime(SetSeconds(0,0,0)), + LocalDateFromTime(SetSeconds(0,0,0)) ); + +addNewTestCase( 28800000,59,999, + "TDATE = new Date(28800000);(TDATE).setSeconds(59,999);TDATE", + UTCDateFromTime(SetSeconds(28800000,59,999)), + LocalDateFromTime(SetSeconds(28800000,59,999)) ); + +addNewTestCase( 28800000,999,999, + "TDATE = new Date(28800000);(TDATE).setSeconds(999,999);TDATE", + UTCDateFromTime(SetSeconds(28800000,999,999)), + LocalDateFromTime(SetSeconds(28800000,999,999)) ); + +addNewTestCase( 28800000,999, void 0, + "TDATE = new Date(28800000);(TDATE).setSeconds(999);TDATE", + UTCDateFromTime(SetSeconds(28800000,999,0)), + LocalDateFromTime(SetSeconds(28800000,999,0)) ); + +addNewTestCase( 28800000,-28800, void 0, + "TDATE = new Date(28800000);(TDATE).setSeconds(-28800);TDATE", + UTCDateFromTime(SetSeconds(28800000,-28800)), + LocalDateFromTime(SetSeconds(28800000,-28800)) ); + +addNewTestCase( 946684800000,1234567,void 0, + "TDATE = new Date(946684800000);(TDATE).setSeconds(1234567);TDATE", + UTCDateFromTime(SetSeconds(946684800000,1234567)), + LocalDateFromTime(SetSeconds(946684800000,1234567)) ); + +addNewTestCase( -2208988800000,59,999, + "TDATE = new Date(-2208988800000);(TDATE).setSeconds(59,999);TDATE", + UTCDateFromTime(SetSeconds(-2208988800000,59,999)), + LocalDateFromTime(SetSeconds(-2208988800000,59,999)) ); + +test(); + +function addNewTestCase( startTime, sec, ms, DateString,UTCDate, LocalDate) { + DateCase = new Date( startTime ); + if ( ms != void 0 ) { + DateCase.setSeconds( sec, ms ); + } else { + DateCase.setSeconds( sec ); + } + + new TestCase( SECTION, DateString+".getTime()", UTCDate.value, DateCase.getTime() ); + new TestCase( SECTION, DateString+".valueOf()", UTCDate.value, DateCase.valueOf() ); + + new TestCase( SECTION, DateString+".getUTCFullYear()", UTCDate.year, DateCase.getUTCFullYear() ); + new TestCase( SECTION, DateString+".getUTCMonth()", UTCDate.month, DateCase.getUTCMonth() ); + new TestCase( SECTION, DateString+".getUTCDate()", UTCDate.date, DateCase.getUTCDate() ); + + new TestCase( SECTION, DateString+".getUTCHours()", UTCDate.hours, DateCase.getUTCHours() ); + new TestCase( SECTION, DateString+".getUTCMinutes()", UTCDate.minutes,DateCase.getUTCMinutes() ); + new TestCase( SECTION, DateString+".getUTCSeconds()", UTCDate.seconds,DateCase.getUTCSeconds() ); + new TestCase( SECTION, DateString+".getUTCMilliseconds()", UTCDate.ms, DateCase.getUTCMilliseconds() ); + + new TestCase( SECTION, DateString+".getFullYear()", LocalDate.year, DateCase.getFullYear() ); + new TestCase( SECTION, DateString+".getMonth()", LocalDate.month, DateCase.getMonth() ); + new TestCase( SECTION, DateString+".getDate()", LocalDate.date, DateCase.getDate() ); + + new TestCase( SECTION, DateString+".getHours()", LocalDate.hours, DateCase.getHours() ); + new TestCase( SECTION, DateString+".getMinutes()", LocalDate.minutes, DateCase.getMinutes() ); + new TestCase( SECTION, DateString+".getSeconds()", LocalDate.seconds, DateCase.getSeconds() ); + new TestCase( SECTION, DateString+".getMilliseconds()", LocalDate.ms, DateCase.getMilliseconds() ); + + DateCase.toString = Object.prototype.toString; + + new TestCase( SECTION, + DateString+".toString=Object.prototype.toString;"+DateString+".toString()", + "[object Date]", + DateCase.toString() ); +} + +function MyDate() { + this.year = 0; + this.month = 0; + this.date = 0; + this.hours = 0; + this.minutes = 0; + this.seconds = 0; + this.ms = 0; +} +function LocalDateFromTime(t) { + t = LocalTime(t); + return ( MyDateFromTime(t) ); +} +function UTCDateFromTime(t) { + return ( MyDateFromTime(t) ); +} +function MyDateFromTime( t ) { + var d = new MyDate(); + d.year = YearFromTime(t); + d.month = MonthFromTime(t); + d.date = DateFromTime(t); + d.hours = HourFromTime(t); + d.minutes = MinFromTime(t); + d.seconds = SecFromTime(t); + d.ms = msFromTime(t); + + d.time = MakeTime( d.hours, d.minutes, d.seconds, d.ms ); + d.value = TimeClip( MakeDate( MakeDay( d.year, d.month, d.date ), d.time ) ); + d.day = WeekDay( d.value ); + + return (d); +} +function SetSeconds( t, s, m ) { + var MS = ( m == void 0 ) ? msFromTime(t) : Number( m ); + var TIME = LocalTime( t ); + var SEC = Number(s); + var RESULT4 = MakeTime( HourFromTime( TIME ), + MinFromTime( TIME ), + SEC, + MS ); + var UTC_TIME = UTC(MakeDate(Day(TIME), RESULT4)); + return ( TimeClip(UTC_TIME) ); +} diff --git a/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.27-1.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.27-1.js new file mode 100644 index 0000000000..1b06777332 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.27-1.js @@ -0,0 +1,183 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.9.5.27-1.js'; + +/** + File Name: 15.9.5.27-1.js + ECMA Section: 15.9.5.27 Date.prototype.setUTCSeconds(sec [,ms]) + Description: + + If ms is not specified, this behaves as if ms were specified with the + value getUTCMilliseconds( ). + + 1. Let t be this time value. + 2. Call ToNumber(sec). + 3. If ms is not specified, compute msFromTime(t); otherwise, call + ToNumber(ms) + 4. Compute MakeTime(HourFromTime(t), MinFromTime(t), Result(2), Result(3)) + 5. Compute MakeDate(Day(t), Result(4)). + 6. Set the [[Value]] property of the this value to TimeClip(Result(5)). + 7. Return the value of the [[Value]] property of the this value. + + Author: christine@netscape.com + Date: 12 november 1997 +*/ +var SECTION = "15.9.5.27-1"; +var VERSION = "ECMA_1"; +startTest(); + +writeHeaderToLog( SECTION + " Date.prototype.setUTCSeconds(sec [,ms] )"); + +addNewTestCase( 0, 0, 0, "TDATE = new Date(0);(TDATE).setUTCSeconds(0,0);TDATE", + UTCDateFromTime(SetUTCSeconds(0,0,0)), + LocalDateFromTime(SetUTCSeconds(0,0,0)) ); + +addNewTestCase( 28800000,59,999, + "TDATE = new Date(28800000);(TDATE).setUTCSeconds(59,999);TDATE", + UTCDateFromTime(SetUTCSeconds(28800000,59,999)), + LocalDateFromTime(SetUTCSeconds(28800000,59,999)) ); + +addNewTestCase( 28800000,999,999, + "TDATE = new Date(28800000);(TDATE).setUTCSeconds(999,999);TDATE", + UTCDateFromTime(SetUTCSeconds(28800000,999,999)), + LocalDateFromTime(SetUTCSeconds(28800000,999,999)) ); + +addNewTestCase( 28800000, 999, void 0, + "TDATE = new Date(28800000);(TDATE).setUTCSeconds(999);TDATE", + UTCDateFromTime(SetUTCSeconds(28800000,999,0)), + LocalDateFromTime(SetUTCSeconds(28800000,999,0)) ); + +addNewTestCase( 28800000, -28800, void 0, + "TDATE = new Date(28800000);(TDATE).setUTCSeconds(-28800);TDATE", + UTCDateFromTime(SetUTCSeconds(28800000,-28800)), + LocalDateFromTime(SetUTCSeconds(28800000,-28800)) ); + +addNewTestCase( 946684800000, 1234567, void 0, + "TDATE = new Date(946684800000);(TDATE).setUTCSeconds(1234567);TDATE", + UTCDateFromTime(SetUTCSeconds(946684800000,1234567)), + LocalDateFromTime(SetUTCSeconds(946684800000,1234567)) ); + +addNewTestCase( -2208988800000,59,999, + "TDATE = new Date(-2208988800000);(TDATE).setUTCSeconds(59,999);TDATE", + UTCDateFromTime(SetUTCSeconds(-2208988800000,59,999)), + LocalDateFromTime(SetUTCSeconds(-2208988800000,59,999)) ); + +test(); + +function addNewTestCase( startTime, sec, ms, DateString, UTCDate, LocalDate) { + DateCase = new Date( startTime ); + if ( ms == void 0) { + DateCase.setSeconds( sec ); + } else { + DateCase.setSeconds( sec, ms ); + } + + new TestCase( SECTION, DateString+".getTime()", UTCDate.value, DateCase.getTime() ); + new TestCase( SECTION, DateString+".valueOf()", UTCDate.value, DateCase.valueOf() ); + + new TestCase( SECTION, DateString+".getUTCFullYear()", UTCDate.year, DateCase.getUTCFullYear() ); + new TestCase( SECTION, DateString+".getUTCMonth()", UTCDate.month, DateCase.getUTCMonth() ); + new TestCase( SECTION, DateString+".getUTCDate()", UTCDate.date, DateCase.getUTCDate() ); + + new TestCase( SECTION, DateString+".getUTCHours()", UTCDate.hours, DateCase.getUTCHours() ); + new TestCase( SECTION, DateString+".getUTCMinutes()", UTCDate.minutes,DateCase.getUTCMinutes() ); + new TestCase( SECTION, DateString+".getUTCSeconds()", UTCDate.seconds,DateCase.getUTCSeconds() ); + new TestCase( SECTION, DateString+".getUTCMilliseconds()", UTCDate.ms, DateCase.getUTCMilliseconds() ); + + new TestCase( SECTION, DateString+".getFullYear()", LocalDate.year, DateCase.getFullYear() ); + new TestCase( SECTION, DateString+".getMonth()", LocalDate.month, DateCase.getMonth() ); + new TestCase( SECTION, DateString+".getDate()", LocalDate.date, DateCase.getDate() ); + + new TestCase( SECTION, DateString+".getHours()", LocalDate.hours, DateCase.getHours() ); + new TestCase( SECTION, DateString+".getMinutes()", LocalDate.minutes, DateCase.getMinutes() ); + new TestCase( SECTION, DateString+".getSeconds()", LocalDate.seconds, DateCase.getSeconds() ); + new TestCase( SECTION, DateString+".getMilliseconds()", LocalDate.ms, DateCase.getMilliseconds() ); + + DateCase.toString = Object.prototype.toString; + + new TestCase( SECTION, + DateString+".toString=Object.prototype.toString;"+DateString+".toString()", + "[object Date]", + DateCase.toString() ); +} + +function MyDate() { + this.year = 0; + this.month = 0; + this.date = 0; + this.hours = 0; + this.minutes = 0; + this.seconds = 0; + this.ms = 0; +} +function LocalDateFromTime(t) { + t = LocalTime(t); + return ( MyDateFromTime(t) ); +} +function UTCDateFromTime(t) { + return ( MyDateFromTime(t) ); +} +function MyDateFromTime( t ) { + var d = new MyDate(); + d.year = YearFromTime(t); + d.month = MonthFromTime(t); + d.date = DateFromTime(t); + d.hours = HourFromTime(t); + d.minutes = MinFromTime(t); + d.seconds = SecFromTime(t); + d.ms = msFromTime(t); + + d.time = MakeTime( d.hours, d.minutes, d.seconds, d.ms ); + d.value = TimeClip( MakeDate( MakeDay( d.year, d.month, d.date ), d.time ) ); + d.day = WeekDay( d.value ); + + return (d); +} + +function SetUTCSeconds( t, s, m ) { + var TIME = t; + var SEC = Number(s); + var MS = ( m == void 0 ) ? msFromTime(TIME) : Number( m ); + var RESULT4 = MakeTime( HourFromTime( TIME ), + MinFromTime( TIME ), + SEC, + MS ); + return ( TimeClip(MakeDate(Day(TIME), RESULT4)) ); +} + diff --git a/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.28-1.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.28-1.js new file mode 100644 index 0000000000..902d70a873 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.28-1.js @@ -0,0 +1,196 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.9.5.28-1.js'; + +/** + File Name: 15.9.5.28-1.js + ECMA Section: 15.9.5.28 Date.prototype.setMinutes(min [, sec [, ms ]] ) + Description: + If sec is not specified, this behaves as if sec were specified with the + value getSeconds ( ). + + If ms is not specified, this behaves as if ms were specified with the + value getMilliseconds( ). + + 1. Let t be the result of LocalTime(this time value). + 2. Call ToNumber(min). + 3. If sec is not specified, compute SecFromTime(t); otherwise, call ToNumber(sec). + 4. If ms is not specified, compute msFromTime(t); otherwise, call ToNumber(ms). + 5. Compute MakeTime(HourFromTime(t), Result(2), Result(3), Result(4)). + 6. Compute UTC(MakeDate(Day(t), Result(5))). + 7. Set the [[Value]] property of the this value to TimeClip(Result(6)). + 8. Return the value of the [[Value]] property of the this value. + + Author: christine@netscape.com + Date: 12 november 1997 +*/ +var SECTION = "15.9.5.28-1"; +var VERSION = "ECMA_1"; +startTest(); + +writeHeaderToLog( SECTION + " Date.prototype.setMinutes(sec [,ms] )"); + +addNewTestCase( 0, 0, void 0, void 0, + "TDATE = new Date(0);(TDATE).setMinutes(0);TDATE", + UTCDateFromTime(SetMinutes(0,0,0,0)), + LocalDateFromTime(SetMinutes(0,0,0,0)) ); + +addNewTestCase( 28800000, 59, 59, void 0, + "TDATE = new Date(28800000);(TDATE).setMinutes(59,59);TDATE", + UTCDateFromTime(SetMinutes(28800000,59,59)), + LocalDateFromTime(SetMinutes(28800000,59,59)) ); + +addNewTestCase( 28800000, 59, 59, 999, + "TDATE = new Date(28800000);(TDATE).setMinutes(59,59,999);TDATE", + UTCDateFromTime(SetMinutes(28800000,59,59,999)), + LocalDateFromTime(SetMinutes(28800000,59,59,999)) ); + +addNewTestCase( 28800000, 59, void 0, void 0, + "TDATE = new Date(28800000);(TDATE).setMinutes(59);TDATE", + UTCDateFromTime(SetMinutes(28800000,59,0)), + LocalDateFromTime(SetMinutes(28800000,59,0)) ); + +addNewTestCase( 28800000, -480, void 0, void 0, + "TDATE = new Date(28800000);(TDATE).setMinutes(-480);TDATE", + UTCDateFromTime(SetMinutes(28800000,-480)), + LocalDateFromTime(SetMinutes(28800000,-480)) ); + +addNewTestCase( 946684800000, 1234567, void 0, void 0, + "TDATE = new Date(946684800000);(TDATE).setMinutes(1234567);TDATE", + UTCDateFromTime(SetMinutes(946684800000,1234567)), + LocalDateFromTime(SetMinutes(946684800000,1234567)) ); + +addNewTestCase( -2208988800000,59, 59, void 0, + "TDATE = new Date(-2208988800000);(TDATE).setMinutes(59,59);TDATE", + UTCDateFromTime(SetMinutes(-2208988800000,59,59)), + LocalDateFromTime(SetMinutes(-2208988800000,59,59)) ); + +addNewTestCase( -2208988800000, 59, 59, 999, + "TDATE = new Date(-2208988800000);(TDATE).setMinutes(59,59,999);TDATE", + UTCDateFromTime(SetMinutes(-2208988800000,59,59,999)), + LocalDateFromTime(SetMinutes(-2208988800000,59,59,999)) ); + +test(); + +function addNewTestCase( time, min, sec, ms, DateString, UTCDate, LocalDate) { + DateCase = new Date( time ); + + if ( sec == void 0 ) { + DateCase.setMinutes( min ); + } else { + if ( ms == void 0 ) { + DateCase.setMinutes( min, sec ); + } else { + DateCase.setMinutes( min, sec, ms ); + } + } + + new TestCase( SECTION, DateString+".getTime()", UTCDate.value, DateCase.getTime() ); + new TestCase( SECTION, DateString+".valueOf()", UTCDate.value, DateCase.valueOf() ); + + new TestCase( SECTION, DateString+".getUTCFullYear()", UTCDate.year, DateCase.getUTCFullYear() ); + new TestCase( SECTION, DateString+".getUTCMonth()", UTCDate.month, DateCase.getUTCMonth() ); + new TestCase( SECTION, DateString+".getUTCDate()", UTCDate.date, DateCase.getUTCDate() ); + + new TestCase( SECTION, DateString+".getUTCHours()", UTCDate.hours, DateCase.getUTCHours() ); + new TestCase( SECTION, DateString+".getUTCMinutes()", UTCDate.minutes,DateCase.getUTCMinutes() ); + new TestCase( SECTION, DateString+".getUTCSeconds()", UTCDate.seconds,DateCase.getUTCSeconds() ); + new TestCase( SECTION, DateString+".getUTCMilliseconds()", UTCDate.ms, DateCase.getUTCMilliseconds() ); + + new TestCase( SECTION, DateString+".getFullYear()", LocalDate.year, DateCase.getFullYear() ); + new TestCase( SECTION, DateString+".getMonth()", LocalDate.month, DateCase.getMonth() ); + new TestCase( SECTION, DateString+".getDate()", LocalDate.date, DateCase.getDate() ); + + new TestCase( SECTION, DateString+".getHours()", LocalDate.hours, DateCase.getHours() ); + new TestCase( SECTION, DateString+".getMinutes()", LocalDate.minutes, DateCase.getMinutes() ); + new TestCase( SECTION, DateString+".getSeconds()", LocalDate.seconds, DateCase.getSeconds() ); + new TestCase( SECTION, DateString+".getMilliseconds()", LocalDate.ms, DateCase.getMilliseconds() ); + + DateCase.toString = Object.prototype.toString; + + new TestCase( SECTION, + DateString+".toString=Object.prototype.toString;"+DateString+".toString()", + "[object Date]", + DateCase.toString() ); +} + +function MyDate() { + this.year = 0; + this.month = 0; + this.date = 0; + this.hours = 0; + this.minutes = 0; + this.seconds = 0; + this.ms = 0; +} +function LocalDateFromTime(t) { + t = LocalTime(t); + return ( MyDateFromTime(t) ); +} +function UTCDateFromTime(t) { + return ( MyDateFromTime(t) ); +} +function MyDateFromTime( t ) { + var d = new MyDate(); + d.year = YearFromTime(t); + d.month = MonthFromTime(t); + d.date = DateFromTime(t); + d.hours = HourFromTime(t); + d.minutes = MinFromTime(t); + d.seconds = SecFromTime(t); + d.ms = msFromTime(t); + + d.time = MakeTime( d.hours, d.minutes, d.seconds, d.ms ); + d.value = TimeClip( MakeDate( MakeDay( d.year, d.month, d.date ), d.time ) ); + d.day = WeekDay( d.value ); + + return (d); +} + +function SetMinutes( t, min, sec, ms ) { + var TIME = LocalTime(t); + var MIN = Number(min); + var SEC = ( sec == void 0) ? SecFromTime(TIME) : Number(sec); + var MS = ( ms == void 0 ) ? msFromTime(TIME) : Number(ms); + var RESULT5 = MakeTime( HourFromTime( TIME ), + MIN, + SEC, + MS ); + return ( TimeClip(UTC( MakeDate(Day(TIME),RESULT5))) ); +} diff --git a/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.29-1.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.29-1.js new file mode 100644 index 0000000000..42fa36e9b5 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.29-1.js @@ -0,0 +1,191 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.9.5.29-1.js'; + +/** + File Name: 15.9.5.29-1.js + ECMA Section: 15.9.5.29 Date.prototype.setUTCMinutes(min [, sec [, ms ]] ) + Description: + If sec is not specified, this behaves as if sec were specified with the + value getUTCSeconds ( ). + + If ms is not specified, this behaves as if ms were specified with the value + getUTCMilliseconds( ). + + 1. Let t be this time value. + 2. Call ToNumber(min). + 3. If sec is not specified, compute SecFromTime(t); otherwise, call + ToNumber(sec). + 4. If ms is not specified, compute msFromTime(t); otherwise, call + ToNumber(ms). + 5. Compute MakeTime(HourFromTime(t), Result(2), Result(3), Result(4)). + 6. Compute MakeDate(Day(t), Result(5)). + 7. Set the [[Value]] property of the this value to TimeClip(Result(6)). + 8. Return the value of the [[Value]] property of the this value. + + Author: christine@netscape.com + Date: 12 november 1997 +*/ +var SECTION = "15.9.5.29-1"; +var VERSION = "ECMA_1"; +startTest(); + +writeHeaderToLog( SECTION + " Date.prototype.setUTCMinutes( min [, sec, ms] )"); + +addNewTestCase( 0, 0, void 0, void 0, + "TDATE = new Date(0);(TDATE).setUTCMinutes(0);TDATE", + UTCDateFromTime(SetUTCMinutes(0,0,0,0)), + LocalDateFromTime(SetUTCMinutes(0,0,0,0)) ); + +addNewTestCase( 28800000, 59, 59, void 0, + "TDATE = new Date(28800000);(TDATE).setUTCMinutes(59,59);TDATE", + UTCDateFromTime(SetUTCMinutes(28800000,59,59)), + LocalDateFromTime(SetUTCMinutes(28800000,59,59)) ); + +addNewTestCase( 28800000, 59, 59, 999, + "TDATE = new Date(28800000);(TDATE).setUTCMinutes(59,59,999);TDATE", + UTCDateFromTime(SetUTCMinutes(28800000,59,59,999)), + LocalDateFromTime(SetUTCMinutes(28800000,59,59,999)) ); + +addNewTestCase( 28800000, 59, void 0, void 0, + "TDATE = new Date(28800000);(TDATE).setUTCMinutes(59);TDATE", + UTCDateFromTime(SetUTCMinutes(28800000,59)), + LocalDateFromTime(SetUTCMinutes(28800000,59)) ); + +addNewTestCase( 28800000, -480, 0, 0, + "TDATE = new Date(28800000);(TDATE).setUTCMinutes(-480);TDATE", + UTCDateFromTime(SetUTCMinutes(28800000,-480)), + LocalDateFromTime(SetUTCMinutes(28800000,-480)) ); + +addNewTestCase( 946684800000, 1234567, void 0, void 0, + "TDATE = new Date(946684800000);(TDATE).setUTCMinutes(1234567);TDATE", + UTCDateFromTime(SetUTCMinutes(946684800000,1234567)), + LocalDateFromTime(SetUTCMinutes(946684800000,1234567)) ); + +addNewTestCase( -2208988800000, 59, 999, void 0, + "TDATE = new Date(-2208988800000);(TDATE).setUTCMinutes(59,999);TDATE", + UTCDateFromTime(SetUTCMinutes(-2208988800000,59,999)), + LocalDateFromTime(SetUTCMinutes(-2208988800000,59,999)) ); + +test(); + +function addNewTestCase( time, min, sec, ms, DateString, UTCDate, LocalDate) { + var DateCase = new Date( time ); + + if ( sec == void 0 ) { + DateCase.setUTCMinutes( min ); + } else { + if ( ms == void 0 ) { + DateCase.setUTCMinutes( min, sec ); + } else { + DateCase.setUTCMinutes( min, sec, ms ); + } + } + + new TestCase( SECTION, DateString+".getTime()", UTCDate.value, DateCase.getTime() ); + new TestCase( SECTION, DateString+".valueOf()", UTCDate.value, DateCase.valueOf() ); + + new TestCase( SECTION, DateString+".getUTCFullYear()", UTCDate.year, DateCase.getUTCFullYear() ); + new TestCase( SECTION, DateString+".getUTCMonth()", UTCDate.month, DateCase.getUTCMonth() ); + new TestCase( SECTION, DateString+".getUTCDate()", UTCDate.date, DateCase.getUTCDate() ); + + new TestCase( SECTION, DateString+".getUTCHours()", UTCDate.hours, DateCase.getUTCHours() ); + new TestCase( SECTION, DateString+".getUTCMinutes()", UTCDate.minutes,DateCase.getUTCMinutes() ); + new TestCase( SECTION, DateString+".getUTCSeconds()", UTCDate.seconds,DateCase.getUTCSeconds() ); + new TestCase( SECTION, DateString+".getUTCMilliseconds()", UTCDate.ms, DateCase.getUTCMilliseconds() ); + + new TestCase( SECTION, DateString+".getFullYear()", LocalDate.year, DateCase.getFullYear() ); + new TestCase( SECTION, DateString+".getMonth()", LocalDate.month, DateCase.getMonth() ); + new TestCase( SECTION, DateString+".getDate()", LocalDate.date, DateCase.getDate() ); + + new TestCase( SECTION, DateString+".getHours()", LocalDate.hours, DateCase.getHours() ); + new TestCase( SECTION, DateString+".getMinutes()", LocalDate.minutes, DateCase.getMinutes() ); + new TestCase( SECTION, DateString+".getSeconds()", LocalDate.seconds, DateCase.getSeconds() ); + new TestCase( SECTION, DateString+".getMilliseconds()", LocalDate.ms, DateCase.getMilliseconds() ); + + DateCase.toString = Object.prototype.toString; + + new TestCase( SECTION, + DateString+".toString=Object.prototype.toString;"+DateString+".toString()", + "[object Date]", + DateCase.toString() ); +} +function MyDate() { + this.year = 0; + this.month = 0; + this.date = 0; + this.hours = 0; + this.minutes = 0; + this.seconds = 0; + this.ms = 0; +} +function LocalDateFromTime(t) { + t = LocalTime(t); + return ( MyDateFromTime(t) ); +} +function UTCDateFromTime(t) { + return ( MyDateFromTime(t) ); +} +function MyDateFromTime( t ) { + var d = new MyDate(); + d.year = YearFromTime(t); + d.month = MonthFromTime(t); + d.date = DateFromTime(t); + d.hours = HourFromTime(t); + d.minutes = MinFromTime(t); + d.seconds = SecFromTime(t); + d.ms = msFromTime(t); + + d.time = MakeTime( d.hours, d.minutes, d.seconds, d.ms ); + d.value = TimeClip( MakeDate( MakeDay( d.year, d.month, d.date ), d.time ) ); + d.day = WeekDay( d.value ); + + return (d); +} +function SetUTCMinutes( t, min, sec, ms ) { + var TIME = t; + var MIN = Number(min); + var SEC = ( sec == void 0) ? SecFromTime(TIME) : Number(sec); + var MS = ( ms == void 0 ) ? msFromTime(TIME) : Number(ms); + var RESULT5 = MakeTime( HourFromTime( TIME ), + MIN, + SEC, + MS ); + return ( TimeClip(MakeDate(Day(TIME),RESULT5)) ); +} diff --git a/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.3-1-n.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.3-1-n.js new file mode 100644 index 0000000000..e1f227f785 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.3-1-n.js @@ -0,0 +1,80 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.9.5.3-1-n.js'; + +/** + File Name: 15.9.5.3-1.js + ECMA Section: 15.9.5.3-1 Date.prototype.valueOf + Description: + + The valueOf function returns a number, which is this time value. + + The valueOf function is not generic; it generates a runtime error if + its this value is not a Date object. Therefore it cannot be transferred + to other kinds of objects for use as a method. + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + +var SECTION = "15.9.5.3-1-n"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Date.prototype.valueOf"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +var OBJ = new MyObject( new Date(0) ); + +DESCRIPTION = "var OBJ = new MyObject( new Date(0) ); OBJ.valueOf()"; +EXPECTED = "error"; + +new TestCase( SECTION, + "var OBJ = new MyObject( new Date(0) ); OBJ.valueOf()", + "error", + eval("OBJ.valueOf()") ); +test(); + +function MyObject( value ) { + this.value = value; + this.valueOf = Date.prototype.valueOf; +// The following line causes an infinte loop +// this.toString = new Function( "return this+\"\";"); + return this; +} diff --git a/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.3-2.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.3-2.js new file mode 100644 index 0000000000..9f425c3450 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.3-2.js @@ -0,0 +1,104 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.9.5.3-2.js'; + +/** + File Name: 15.9.5.3-2.js + ECMA Section: 15.9.5.3-2 Date.prototype.valueOf + Description: + + The valueOf function returns a number, which is this time value. + + The valueOf function is not generic; it generates a runtime error if + its this value is not a Date object. Therefore it cannot be transferred + to other kinds of objects for use as a method. + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + +var SECTION = "15.9.5.3-2"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Date.prototype.valueOf"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +addTestCase( TIME_NOW ); +addTestCase( TIME_1970 ); +addTestCase( TIME_1900 ); +addTestCase( TIME_2000 ); +addTestCase( UTC_FEB_29_2000 ); +addTestCase( UTC_JAN_1_2005 ); + +test(); + +function addTestCase( t ) { + new TestCase( SECTION, + "(new Date("+t+").valueOf()", + t, + (new Date(t)).valueOf() ); + + new TestCase( SECTION, + "(new Date("+(t+1)+").valueOf()", + t+1, + (new Date(t+1)).valueOf() ); + + new TestCase( SECTION, + "(new Date("+(t-1)+").valueOf()", + t-1, + (new Date(t-1)).valueOf() ); + + new TestCase( SECTION, + "(new Date("+(t-TZ_ADJUST)+").valueOf()", + t-TZ_ADJUST, + (new Date(t-TZ_ADJUST)).valueOf() ); + + new TestCase( SECTION, + "(new Date("+(t+TZ_ADJUST)+").valueOf()", + t+TZ_ADJUST, + (new Date(t+TZ_ADJUST)).valueOf() ); +} + +function MyObject( value ) { + this.value = value; + this.valueOf = Date.prototype.valueOf; + this.toString = new Function( "return this+\"\";"); + return this; +} diff --git a/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.30-1.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.30-1.js new file mode 100644 index 0000000000..7abb3927d7 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.30-1.js @@ -0,0 +1,192 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.9.5.30-1.js'; + +/** + File Name: 15.9.5.30-1.js + ECMA Section: 15.9.5.30 Date.prototype.setHours(hour [, min [, sec [, ms ]]] ) + Description: + If min is not specified, this behaves as if min were specified with the + value getMinutes( ). If sec is not specified, this behaves as if sec were + specified with the value getSeconds ( ). If ms is not specified, this + behaves as if ms were specified with the value getMilliseconds( ). + + 1. Let t be the result of LocalTime(this time value). + 2. Call ToNumber(hour). + 3. If min is not specified, compute MinFromTime(t); otherwise, call + ToNumber(min). + 4. If sec is not specified, compute SecFromTime(t); otherwise, call + ToNumber(sec). + 5. If ms is not specified, compute msFromTime(t); otherwise, call + ToNumber(ms). + 6. Compute MakeTime(Result(2), Result(3), Result(4), Result(5)). + 7. Compute UTC(MakeDate(Day(t), Result(6))). + 8. Set the [[Value]] property of the this value to TimeClip(Result(7)). + 9. Return the value of the [[Value]] property of the this value. + + Author: christine@netscape.com + Date: 12 november 1997 +*/ +var SECTION = "15.9.5.30-1"; +var VERSION = "ECMA_1"; +startTest(); + +writeHeaderToLog( SECTION + " Date.prototype.setHours( hour [, min, sec, ms] )"); + +addNewTestCase( 0,0,0,0,void 0, + "TDATE = new Date(0);(TDATE).setHours(0);TDATE" ); + +addNewTestCase( 28800000, 23, 59, 999,void 0, + "TDATE = new Date(28800000);(TDATE).setHours(23,59,999);TDATE" ); + +addNewTestCase( 28800000, 999, 999, void 0, void 0, + "TDATE = new Date(28800000);(TDATE).setHours(999,999);TDATE" ); + +addNewTestCase( 28800000,999,0, void 0, void 0, + "TDATE = new Date(28800000);(TDATE).setHours(999);TDATE" ); + +addNewTestCase( 28800000,-8, void 0, void 0, void 0, + "TDATE = new Date(28800000);(TDATE).setHours(-8);TDATE" ); + +addNewTestCase( 946684800000,8760, void 0, void 0, void 0, + "TDATE = new Date(946684800000);(TDATE).setHours(8760);TDATE" ); + +addNewTestCase( TIME_2000 - msPerDay, 23, 59, 59, 999, + "d = new Date( " + (TIME_2000-msPerDay) +"); d.setHours(23,59,59,999)" ); + +addNewTestCase( TIME_2000 - msPerDay, 23, 59, 59, 1000, + "d = new Date( " + (TIME_2000-msPerDay) +"); d.setHours(23,59,59,1000)" ); + +test(); + +function addNewTestCase( time, hours, min, sec, ms, DateString) { + var UTCDate = UTCDateFromTime( SetHours( time, hours, min, sec, ms )); + var LocalDate = LocalDateFromTime( SetHours( time, hours, min, sec, ms )); + + var DateCase = new Date( time ); + + if ( min == void 0 ) { + DateCase.setHours( hours ); + } else { + if ( sec == void 0 ) { + DateCase.setHours( hours, min ); + } else { + if ( ms == void 0 ) { + DateCase.setHours( hours, min, sec ); + } else { + DateCase.setHours( hours, min, sec, ms ); + } + } + } + + + new TestCase( SECTION, DateString+".getTime()", UTCDate.value, DateCase.getTime() ); + new TestCase( SECTION, DateString+".valueOf()", UTCDate.value, DateCase.valueOf() ); + + new TestCase( SECTION, DateString+".getUTCFullYear()", UTCDate.year, DateCase.getUTCFullYear() ); + new TestCase( SECTION, DateString+".getUTCMonth()", UTCDate.month, DateCase.getUTCMonth() ); + new TestCase( SECTION, DateString+".getUTCDate()", UTCDate.date, DateCase.getUTCDate() ); + new TestCase( SECTION, DateString+".getUTCDay()", UTCDate.day, DateCase.getUTCDay() ); + new TestCase( SECTION, DateString+".getUTCHours()", UTCDate.hours, DateCase.getUTCHours() ); + new TestCase( SECTION, DateString+".getUTCMinutes()", UTCDate.minutes,DateCase.getUTCMinutes() ); + new TestCase( SECTION, DateString+".getUTCSeconds()", UTCDate.seconds,DateCase.getUTCSeconds() ); + new TestCase( SECTION, DateString+".getUTCMilliseconds()", UTCDate.ms, DateCase.getUTCMilliseconds() ); + + new TestCase( SECTION, DateString+".getFullYear()", LocalDate.year, DateCase.getFullYear() ); + new TestCase( SECTION, DateString+".getMonth()", LocalDate.month, DateCase.getMonth() ); + new TestCase( SECTION, DateString+".getDate()", LocalDate.date, DateCase.getDate() ); + new TestCase( SECTION, DateString+".getDay()", LocalDate.day, DateCase.getDay() ); + new TestCase( SECTION, DateString+".getHours()", LocalDate.hours, DateCase.getHours() ); + new TestCase( SECTION, DateString+".getMinutes()", LocalDate.minutes, DateCase.getMinutes() ); + new TestCase( SECTION, DateString+".getSeconds()", LocalDate.seconds, DateCase.getSeconds() ); + new TestCase( SECTION, DateString+".getMilliseconds()", LocalDate.ms, DateCase.getMilliseconds() ); + + DateCase.toString = Object.prototype.toString; + + new TestCase( SECTION, + DateString+".toString=Object.prototype.toString;"+DateString+".toString()", + "[object Date]", + DateCase.toString() ); +} + +function MyDate() { + this.year = 0; + this.month = 0; + this.date = 0; + this.hours = 0; + this.minutes = 0; + this.seconds = 0; + this.ms = 0; +} +function LocalDateFromTime(t) { + t = LocalTime(t); + return ( MyDateFromTime(t) ); +} +function UTCDateFromTime(t) { + return ( MyDateFromTime(t) ); +} +function MyDateFromTime( t ) { + var d = new MyDate(); + d.year = YearFromTime(t); + d.month = MonthFromTime(t); + d.date = DateFromTime(t); + d.hours = HourFromTime(t); + d.minutes = MinFromTime(t); + d.seconds = SecFromTime(t); + d.ms = msFromTime(t); + + d.day = WeekDay( t ); + d.time = MakeTime( d.hours, d.minutes, d.seconds, d.ms ); + d.value = TimeClip( MakeDate( MakeDay( d.year, d.month, d.date ), d.time ) ); + + return (d); +} +function SetHours( t, hour, min, sec, ms ) { + var TIME = LocalTime(t); + var HOUR = Number(hour); + var MIN = ( min == void 0) ? MinFromTime(TIME) : Number(min); + var SEC = ( sec == void 0) ? SecFromTime(TIME) : Number(sec); + var MS = ( ms == void 0 ) ? msFromTime(TIME) : Number(ms); + var RESULT6 = MakeTime( HOUR, + MIN, + SEC, + MS ); + var UTC_TIME = UTC( MakeDate(Day(TIME), RESULT6) ); + return ( TimeClip(UTC_TIME) ); +} diff --git a/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.31-1.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.31-1.js new file mode 100644 index 0000000000..10f0f93e17 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.31-1.js @@ -0,0 +1,221 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.9.5.31-1.js'; + +/** + File Name: 15.9.5.31-1.js + + ECMA Section: + 15.9.5.31 Date.prototype.setUTCHours(hour [, min [, sec [, ms ]]] ) + + Description: + + If min is not specified, this behaves as if min were specified with + the value getUTCMinutes( ). If sec is not specified, this behaves + as if sec were specified with the value getUTCSeconds ( ). If ms + is not specified, this behaves as if ms were specified with the + value getUTCMilliseconds( ). + + 1.Let t be this time value. + 2.Call ToNumber(hour). + 3.If min is not specified, compute MinFromTime(t); + otherwise, call ToNumber(min). + 4.If sec is not specified, compute SecFromTime(t); + otherwise, call ToNumber(sec). + 5.If ms is not specified, compute msFromTime(t); + otherwise, call ToNumber(ms). + 6.Compute MakeTime(Result(2), Result(3), Result(4), Result(5)). + 7.Compute MakeDate(Day(t), Result(6)). + 8.Set the [[Value]] property of the this value to TimeClip(Result(7)). + + 1.Return the value of the [[Value]] property of the this value. + Author: christine@netscape.com + Date: 12 november 1997 +*/ +var SECTION = "15.9.5.31-1"; +var VERSION = "ECMA_1"; +startTest(); + +writeHeaderToLog(SECTION + + " Date.prototype.setUTCHours(hour [, min [, sec [, ms ]]] )"); + +addNewTestCase( 0, 0, void 0, void 0, void 0, + "TDATE = new Date(0);(TDATE).setUTCHours(0);TDATE", + UTCDateFromTime(SetUTCHours(0,0,0,0)), + LocalDateFromTime(SetUTCHours(0,0,0,0)) ); + +addNewTestCase( 28800000, 23, 59, 999, void 0, + "TDATE = new Date(28800000);(TDATE).setUTCHours(23,59,999);TDATE", + UTCDateFromTime(SetUTCHours(28800000,23,59,999)), + LocalDateFromTime(SetUTCHours(28800000,23,59,999)) ); + +addNewTestCase( 28800000,999,999, void 0, void 0, + "TDATE = new Date(28800000);(TDATE).setUTCHours(999,999);TDATE", + UTCDateFromTime(SetUTCHours(28800000,999,999)), + LocalDateFromTime(SetUTCHours(28800000,999,999)) ); + +addNewTestCase( 28800000, 999, void 0, void 0, void 0, + "TDATE = new Date(28800000);(TDATE).setUTCHours(999);TDATE", + UTCDateFromTime(SetUTCHours(28800000,999,0)), + LocalDateFromTime(SetUTCHours(28800000,999,0)) ); + +addNewTestCase( 28800000, -8670, void 0, void 0, void 0, + "TDATE = new Date(28800000);(TDATE).setUTCHours(-8670);TDATE", + UTCDateFromTime(SetUTCHours(28800000,-8670)), + LocalDateFromTime(SetUTCHours(28800000,-8670)) ); + +addNewTestCase( 946684800000, 1234567, void 0, void 0, void 0, + "TDATE = new Date(946684800000);(TDATE).setUTCHours(1234567);TDATE", + UTCDateFromTime(SetUTCHours(946684800000,1234567)), + LocalDateFromTime(SetUTCHours(946684800000,1234567)) ); + +addNewTestCase( -2208988800000, 59, 999, void 0, void 0, + "TDATE = new Date(-2208988800000);(TDATE).setUTCHours(59,999);TDATE", + UTCDateFromTime(SetUTCHours(-2208988800000,59,999)), + LocalDateFromTime(SetUTCHours(-2208988800000,59,999)) ); + +test(); + +function addNewTestCase( time, hours, min, sec, ms, DateString, UTCDate, LocalDate) { + + DateCase = new Date(time); + if ( min == void 0 ) { + DateCase.setUTCHours( hours ); + } else { + if ( sec == void 0 ) { + DateCase.setUTCHours( hours, min ); + } else { + if ( ms == void 0 ) { + DateCase.setUTCHours( hours, min, sec ); + } else { + DateCase.setUTCHours( hours, min, sec, ms ); + } + } + } + + new TestCase( SECTION, DateString+".getTime()", UTCDate.value, + DateCase.getTime() ); + new TestCase( SECTION, DateString+".valueOf()", UTCDate.value, + DateCase.valueOf() ); + new TestCase( SECTION, DateString+".getUTCFullYear()", UTCDate.year, + DateCase.getUTCFullYear() ); + new TestCase( SECTION, DateString+".getUTCMonth()", UTCDate.month, + DateCase.getUTCMonth() ); + new TestCase( SECTION, DateString+".getUTCDate()", UTCDate.date, + DateCase.getUTCDate() ); + new TestCase( SECTION, DateString+".getUTCDay()", UTCDate.day, + DateCase.getUTCDay() ); + new TestCase( SECTION, DateString+".getUTCHours()", UTCDate.hours, + DateCase.getUTCHours() ); + new TestCase( SECTION, DateString+".getUTCMinutes()", UTCDate.minutes, + DateCase.getUTCMinutes() ); + new TestCase( SECTION, DateString+".getUTCSeconds()", UTCDate.seconds, + DateCase.getUTCSeconds() ); + new TestCase( SECTION, DateString+".getUTCMilliseconds()", UTCDate.ms, + DateCase.getUTCMilliseconds() ); + + new TestCase( SECTION, DateString+".getFullYear()", LocalDate.year, + DateCase.getFullYear() ); + new TestCase( SECTION, DateString+".getMonth()", LocalDate.month, + DateCase.getMonth() ); + new TestCase( SECTION, DateString+".getDate()", LocalDate.date, + DateCase.getDate() ); + new TestCase( SECTION, DateString+".getDay()", LocalDate.day, + DateCase.getDay() ); + new TestCase( SECTION, DateString+".getHours()", LocalDate.hours, + DateCase.getHours() ); + new TestCase( SECTION, DateString+".getMinutes()", LocalDate.minutes, + DateCase.getMinutes() ); + new TestCase( SECTION, DateString+".getSeconds()", LocalDate.seconds, + DateCase.getSeconds() ); + new TestCase( SECTION, DateString+".getMilliseconds()", LocalDate.ms, + DateCase.getMilliseconds() ); + + DateCase.toString = Object.prototype.toString; + + new TestCase( SECTION, + DateString+".toString=Object.prototype.toString;" + + DateString+".toString()", + "[object Date]", + DateCase.toString() ); +} +function MyDate() { + this.year = 0; + this.month = 0; + this.date = 0; + this.hours = 0; + this.minutes = 0; + this.seconds = 0; + this.ms = 0; +} +function LocalDateFromTime(t) { + t = LocalTime(t); + return ( MyDateFromTime(t) ); +} +function UTCDateFromTime(t) { + return ( MyDateFromTime(t) ); +} +function MyDateFromTime( t ) { + var d = new MyDate(); + d.year = YearFromTime(t); + d.month = MonthFromTime(t); + d.date = DateFromTime(t); + d.hours = HourFromTime(t); + d.minutes = MinFromTime(t); + d.seconds = SecFromTime(t); + d.ms = msFromTime(t); + + d.time = MakeTime( d.hours, d.minutes, d.seconds, d.ms ); + d.value = TimeClip( MakeDate( MakeDay( d.year, d.month, d.date ), d.time ) ); + d.day = WeekDay( d.value ); + + return (d); +} +function SetUTCHours( t, hour, min, sec, ms ) { + var TIME = t; + var HOUR = Number(hour); + var MIN = ( min == void 0) ? MinFromTime(TIME) : Number(min); + var SEC = ( sec == void 0) ? SecFromTime(TIME) : Number(sec); + var MS = ( ms == void 0 ) ? msFromTime(TIME) : Number(ms); + var RESULT6 = MakeTime( HOUR, + MIN, + SEC, + MS ); + return ( TimeClip(MakeDate(Day(TIME), RESULT6)) ); +} diff --git a/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.32-1.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.32-1.js new file mode 100644 index 0000000000..d277fd9af1 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.32-1.js @@ -0,0 +1,141 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.9.5.32-1.js'; + +/** + File Name: 15.9.5.32-1.js + ECMA Section: 15.9.5.32 Date.prototype.setDate(date) + Description: + 1. Let t be the result of LocalTime(this time value). + 2. Call ToNumber(date). + 3. Compute MakeDay(YearFromTime(t), MonthFromTime(t), Result(2)). + 4. Compute UTC(MakeDate(Result(3), TimeWithinDay(t))). + 5. Set the [[Value]] property of the this value to TimeClip(Result(4)). + 6. Return the value of the [[Value]] property of the this value. + + Author: christine@netscape.com + Date: 12 november 1997 +*/ +var SECTION = "15.9.5.32-1"; +var VERSION = "ECMA_1"; +startTest(); + +writeHeaderToLog( SECTION + " Date.prototype.setDate(date) "); + +addNewTestCase( 0, 1, + "TDATE = new Date(0);(TDATE).setDate(1);TDATE" ); + +test(); + +function addNewTestCase( t, d, DateString ) { + var DateCase = new Date( t ); + DateCase.setDate( d ); + + var UTCDate = UTCDateFromTime(SetDate(t, d)); + var LocalDate=LocalDateFromTime(SetDate(t,d)); + + + new TestCase( SECTION, DateString+".getTime()", UTCDate.value, DateCase.getTime() ); + new TestCase( SECTION, DateString+".valueOf()", UTCDate.value, DateCase.valueOf() ); + + new TestCase( SECTION, DateString+".getUTCFullYear()", UTCDate.year, DateCase.getUTCFullYear() ); + new TestCase( SECTION, DateString+".getUTCMonth()", UTCDate.month, DateCase.getUTCMonth() ); + new TestCase( SECTION, DateString+".getUTCDate()", UTCDate.date, DateCase.getUTCDate() ); + new TestCase( SECTION, DateString+".getUTCDay()", UTCDate.day, DateCase.getUTCDay() ); + new TestCase( SECTION, DateString+".getUTCHours()", UTCDate.hours, DateCase.getUTCHours() ); + new TestCase( SECTION, DateString+".getUTCMinutes()", UTCDate.minutes,DateCase.getUTCMinutes() ); + new TestCase( SECTION, DateString+".getUTCSeconds()", UTCDate.seconds,DateCase.getUTCSeconds() ); + new TestCase( SECTION, DateString+".getUTCMilliseconds()", UTCDate.ms, DateCase.getUTCMilliseconds() ); + + new TestCase( SECTION, DateString+".getFullYear()", LocalDate.year, DateCase.getFullYear() ); + new TestCase( SECTION, DateString+".getMonth()", LocalDate.month, DateCase.getMonth() ); + new TestCase( SECTION, DateString+".getDate()", LocalDate.date, DateCase.getDate() ); + new TestCase( SECTION, DateString+".getDay()", LocalDate.day, DateCase.getDay() ); + new TestCase( SECTION, DateString+".getHours()", LocalDate.hours, DateCase.getHours() ); + new TestCase( SECTION, DateString+".getMinutes()", LocalDate.minutes, DateCase.getMinutes() ); + new TestCase( SECTION, DateString+".getSeconds()", LocalDate.seconds, DateCase.getSeconds() ); + new TestCase( SECTION, DateString+".getMilliseconds()", LocalDate.ms, DateCase.getMilliseconds() ); + + DateCase.toString = Object.prototype.toString; + + new TestCase( SECTION, + DateString+".toString=Object.prototype.toString;"+DateString+".toString()", + "[object Date]", + DateCase.toString() ); +} +function MyDate() { + this.year = 0; + this.month = 0; + this.date = 0; + this.hours = 0; + this.minutes = 0; + this.seconds = 0; + this.ms = 0; +} +function LocalDateFromTime(t) { + t = LocalTime(t); + return ( MyDateFromTime(t) ); +} +function UTCDateFromTime(t) { + return ( MyDateFromTime(t) ); +} +function MyDateFromTime( t ) { + var d = new MyDate(); + d.year = YearFromTime(t); + d.month = MonthFromTime(t); + d.date = DateFromTime(t); + d.hours = HourFromTime(t); + d.minutes = MinFromTime(t); + d.seconds = SecFromTime(t); + d.ms = msFromTime(t); + + d.time = MakeTime( d.hours, d.minutes, d.seconds, d.ms ); + d.value = TimeClip( MakeDate( MakeDay( d.year, d.month, d.date ), d.time ) ); + d.day = WeekDay( d.value ); + + return (d); +} + +function SetDate( t, date ) { + var T = LocalTime( t ); + var DATE = Number( date ); + var RESULT3 = MakeDay(YearFromTime(T), MonthFromTime(T), DATE ); + var UTC_DATE = UTC( MakeDate(RESULT3, TimeWithinDay(T)) ); + return ( TimeClip(UTC_DATE) ); +} diff --git a/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.33-1.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.33-1.js new file mode 100644 index 0000000000..01e1ff2f94 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.33-1.js @@ -0,0 +1,145 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.9.5.33-1.js'; + +/** + File Name: 15.9.5.33-1.js + ECMA Section: 15.9.5.33 Date.prototype.setUTCDate(date) + Description: + 1. Let t be this time value. + 2. Call ToNumber(date). + 3. Compute MakeDay(YearFromTime(t), MonthFromTime(t), Result(2)). + 4. Compute MakeDate(Result(3), TimeWithinDay(t)). + 5. Set the [[Value]] property of the this value to TimeClip(Result(4)). + 6. Return the value of the [[Value]] property of the this value. + + Author: christine@netscape.com + Date: 12 november 1997 +*/ +var SECTION = "15.9.5.33-1"; +var VERSION = "ECMA_1"; +startTest(); + +writeHeaderToLog( SECTION + " Date.prototype.setUTCDate(date) "); + +addNewTestCase( "TDATE = new Date(0);(TDATE).setUTCDate(31);TDATE", + UTCDateFromTime(SetUTCDate(0,31)), + LocalDateFromTime(SetUTCDate(0,31)) ); + +addNewTestCase( "TDATE = new Date(0);(TDATE).setUTCDate(1);TDATE", + UTCDateFromTime(SetUTCDate(0,1)), + LocalDateFromTime(SetUTCDate(0,1)) ); + +addNewTestCase( "TDATE = new Date(86400000);(TDATE).setUTCDate(1);TDATE", + UTCDateFromTime(SetUTCDate(86400000,1)), + LocalDateFromTime(SetUTCDate(86400000,1)) ); + +test(); + +function addNewTestCase( DateString, UTCDate, LocalDate) { + DateCase = eval( DateString ); + + + new TestCase( SECTION, DateString+".getTime()", UTCDate.value, DateCase.getTime() ); + new TestCase( SECTION, DateString+".valueOf()", UTCDate.value, DateCase.valueOf() ); + + new TestCase( SECTION, DateString+".getUTCFullYear()", UTCDate.year, DateCase.getUTCFullYear() ); + new TestCase( SECTION, DateString+".getUTCMonth()", UTCDate.month, DateCase.getUTCMonth() ); + new TestCase( SECTION, DateString+".getUTCDate()", UTCDate.date, DateCase.getUTCDate() ); + new TestCase( SECTION, DateString+".getUTCDay()", UTCDate.day, DateCase.getUTCDay() ); + new TestCase( SECTION, DateString+".getUTCHours()", UTCDate.hours, DateCase.getUTCHours() ); + new TestCase( SECTION, DateString+".getUTCMinutes()", UTCDate.minutes,DateCase.getUTCMinutes() ); + new TestCase( SECTION, DateString+".getUTCSeconds()", UTCDate.seconds,DateCase.getUTCSeconds() ); + new TestCase( SECTION, DateString+".getUTCMilliseconds()", UTCDate.ms, DateCase.getUTCMilliseconds() ); + + new TestCase( SECTION, DateString+".getFullYear()", LocalDate.year, DateCase.getFullYear() ); + new TestCase( SECTION, DateString+".getMonth()", LocalDate.month, DateCase.getMonth() ); + new TestCase( SECTION, DateString+".getDate()", LocalDate.date, DateCase.getDate() ); + new TestCase( SECTION, DateString+".getDay()", LocalDate.day, DateCase.getDay() ); + new TestCase( SECTION, DateString+".getHours()", LocalDate.hours, DateCase.getHours() ); + new TestCase( SECTION, DateString+".getMinutes()", LocalDate.minutes, DateCase.getMinutes() ); + new TestCase( SECTION, DateString+".getSeconds()", LocalDate.seconds, DateCase.getSeconds() ); + new TestCase( SECTION, DateString+".getMilliseconds()", LocalDate.ms, DateCase.getMilliseconds() ); + + DateCase.toString = Object.prototype.toString; + + new TestCase( SECTION, + DateString+".toString=Object.prototype.toString;"+DateString+".toString()", + "[object Date]", + DateCase.toString() ); +} +function MyDate() { + this.year = 0; + this.month = 0; + this.date = 0; + this.hours = 0; + this.minutes = 0; + this.seconds = 0; + this.ms = 0; +} +function LocalDateFromTime(t) { + t = LocalTime(t); + return ( MyDateFromTime(t) ); +} +function UTCDateFromTime(t) { + return ( MyDateFromTime(t) ); +} +function MyDateFromTime( t ) { + var d = new MyDate(); + d.year = YearFromTime(t); + d.month = MonthFromTime(t); + d.date = DateFromTime(t); + d.hours = HourFromTime(t); + d.minutes = MinFromTime(t); + d.seconds = SecFromTime(t); + d.ms = msFromTime(t); + + d.time = MakeTime( d.hours, d.minutes, d.seconds, d.ms ); + d.value = TimeClip( MakeDate( MakeDay( d.year, d.month, d.date ), d.time ) ); + d.day = WeekDay( d.value ); + + return (d); +} +function SetUTCDate( t, date ) { + var T = t; + var DATE = Number( date ); + var RESULT3 = MakeDay(YearFromTime(T), MonthFromTime(T), DATE ); + return ( TimeClip(MakeDate(RESULT3, TimeWithinDay(t))) ); +} + diff --git a/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.34-1.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.34-1.js new file mode 100644 index 0000000000..de4d8c817b --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.34-1.js @@ -0,0 +1,182 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.9.5.34-1.js'; + +/** + File Name: 15.9.5.34-1.js + ECMA Section: 15.9.5.34 Date.prototype.setMonth(mon [, date ] ) + Description: + If date is not specified, this behaves as if date were specified with the + value getDate( ). + + 1. Let t be the result of LocalTime(this time value). + 2. Call ToNumber(date). + 3. If date is not specified, compute DateFromTime(t); otherwise, call ToNumber(date). + 4. Compute MakeDay(YearFromTime(t), Result(2), Result(3)). + 5. Compute UTC(MakeDate(Result(4), TimeWithinDay(t))). + 6. Set the [[Value]] property of the this value to TimeClip(Result(5)). + 7. Return the value of the [[Value]] property of the this value. + + Author: christine@netscape.com + Date: 12 november 1997 +*/ +var SECTION = "15.9.5.34-1"; +var VERSION = "ECMA_1"; +startTest(); + +writeHeaderToLog( SECTION + " Date.prototype.setMonth(mon [, date ] )"); + +getFunctionCases(); + +// regression test for http://scopus.mcom.com/bugsplat/show_bug.cgi?id=112404 +d = new Date(0); +d.setMonth(1,1,1,1,1,1); + +addNewTestCase( + "TDATE = new Date(0); TDATE.setMonth(1,1,1,1,1,1); TDATE", + UTCDateFromTime(SetMonth(0,1,1)), + LocalDateFromTime(SetMonth(0,1,1)) ); + + +// whatever today is + +addNewTestCase( "TDATE = new Date(TIME_NOW); (TDATE).setMonth(11,31); TDATE", + UTCDateFromTime(SetMonth(TIME_NOW,11,31)), + LocalDateFromTime(SetMonth(TIME_NOW,11,31)) ); + +// 1970 + +addNewTestCase( "TDATE = new Date(0);(TDATE).setMonth(0,1);TDATE", + UTCDateFromTime(SetMonth(0,0,1)), + LocalDateFromTime(SetMonth(0,0,1)) ); + +addNewTestCase( "TDATE = new Date("+TIME_1900+"); "+ + "(TDATE).setMonth(11,31); TDATE", + UTCDateFromTime( SetMonth(TIME_1900,11,31) ), + LocalDateFromTime( SetMonth(TIME_1900,11,31) ) ); + +test(); + +function addNewTestCase( DateString, UTCDate, LocalDate) { + DateCase = eval( DateString ); + + new TestCase( SECTION, DateString+".getTime()", UTCDate.value, DateCase.getTime() ); + new TestCase( SECTION, DateString+".valueOf()", UTCDate.value, DateCase.valueOf() ); + + new TestCase( SECTION, DateString+".getUTCFullYear()", UTCDate.year, DateCase.getUTCFullYear() ); + new TestCase( SECTION, DateString+".getUTCMonth()", UTCDate.month, DateCase.getUTCMonth() ); + new TestCase( SECTION, DateString+".getUTCDate()", UTCDate.date, DateCase.getUTCDate() ); + new TestCase( SECTION, DateString+".getUTCDay()", UTCDate.day, DateCase.getUTCDay() ); + new TestCase( SECTION, DateString+".getUTCHours()", UTCDate.hours, DateCase.getUTCHours() ); + new TestCase( SECTION, DateString+".getUTCMinutes()", UTCDate.minutes,DateCase.getUTCMinutes() ); + new TestCase( SECTION, DateString+".getUTCSeconds()", UTCDate.seconds,DateCase.getUTCSeconds() ); + new TestCase( SECTION, DateString+".getUTCMilliseconds()", UTCDate.ms, DateCase.getUTCMilliseconds() ); + + new TestCase( SECTION, DateString+".getFullYear()", LocalDate.year, DateCase.getFullYear() ); + new TestCase( SECTION, DateString+".getMonth()", LocalDate.month, DateCase.getMonth() ); + new TestCase( SECTION, DateString+".getDate()", LocalDate.date, DateCase.getDate() ); + new TestCase( SECTION, DateString+".getDay()", LocalDate.day, DateCase.getDay() ); + new TestCase( SECTION, DateString+".getHours()", LocalDate.hours, DateCase.getHours() ); + new TestCase( SECTION, DateString+".getMinutes()", LocalDate.minutes, DateCase.getMinutes() ); + new TestCase( SECTION, DateString+".getSeconds()", LocalDate.seconds, DateCase.getSeconds() ); + new TestCase( SECTION, DateString+".getMilliseconds()", LocalDate.ms, DateCase.getMilliseconds() ); + + DateCase.toString = Object.prototype.toString; + + new TestCase( SECTION, + DateString+".toString=Object.prototype.toString;"+DateString+".toString()", + "[object Date]", + DateCase.toString() ); +} + +function getFunctionCases() { + // some tests for all functions + new TestCase( + SECTION, + "Date.prototype.setMonth.length", + 2, + Date.prototype.setMonth.length ); + + new TestCase( + SECTION, + "typeof Date.prototype.setMonth", + "function", + typeof Date.prototype.setMonth ); + +} + +function MyDate() { + this.year = 0; + this.month = 0; + this.date = 0; + this.hours = 0; + this.minutes = 0; + this.seconds = 0; + this.ms = 0; +} +function LocalDateFromTime(t) { + t = LocalTime(t); + return ( MyDateFromTime(t) ); +} +function UTCDateFromTime(t) { + return ( MyDateFromTime(t) ); +} +function MyDateFromTime( t ) { + var d = new MyDate(); + d.year = YearFromTime(t); + d.month = MonthFromTime(t); + d.date = DateFromTime(t); + d.hours = HourFromTime(t); + d.minutes = MinFromTime(t); + d.seconds = SecFromTime(t); + d.ms = msFromTime(t); + + d.time = MakeTime( d.hours, d.minutes, d.seconds, d.ms ); + d.value = TimeClip( MakeDate( MakeDay( d.year, d.month, d.date ), d.time ) ); + d.day = WeekDay( d.value ); + + return (d); +} +function SetMonth( t, mon, date ) { + var TIME = LocalTime(t); + var MONTH = Number( mon ); + var DATE = ( date == void 0 ) ? DateFromTime(TIME) : Number( date ); + var DAY = MakeDay( YearFromTime(TIME), MONTH, DATE ); + return ( TimeClip (UTC(MakeDate( DAY, TimeWithinDay(TIME) ))) ); +} diff --git a/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.35-1.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.35-1.js new file mode 100644 index 0000000000..427657cb47 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.35-1.js @@ -0,0 +1,139 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.9.5.35-1.js'; + +/** + File Name: 15.9.5.35-1.js + ECMA Section: 15.9.5.35 Date.prototype.setUTCMonth(mon [,date]) + Description: + Author: christine@netscape.com + Date: 12 november 1997 +*/ +var SECTION = "15.9.5.35-1"; +var VERSION = "ECMA_1"; +startTest(); + +writeHeaderToLog( SECTION + " Date.prototype.setUTCMonth(mon [,date] ) "); +addNewTestCase( "TDATE = new Date(0);(TDATE).setUTCMonth(0);TDATE", + UTCDateFromTime(SetUTCMonth(0,0)), + LocalDateFromTime(SetUTCMonth(0,0)) ); + +addNewTestCase( "TDATE = new Date(0);(TDATE).setUTCMonth(11);TDATE", + UTCDateFromTime(SetUTCMonth(0,11)), + LocalDateFromTime(SetUTCMonth(0,11)) ); + +addNewTestCase( "TDATE = new Date(0);(TDATE).setUTCMonth(3,4);TDATE", + UTCDateFromTime(SetUTCMonth(0,3,4)), + LocalDateFromTime(SetUTCMonth(0,3,4)) ); + +test(); + +function addNewTestCase( DateString, UTCDate, LocalDate) { + DateCase = eval( DateString ); + + new TestCase( SECTION, DateString+".getTime()", UTCDate.value, DateCase.getTime() ); + new TestCase( SECTION, DateString+".valueOf()", UTCDate.value, DateCase.valueOf() ); + + new TestCase( SECTION, DateString+".getUTCFullYear()", UTCDate.year, DateCase.getUTCFullYear() ); + new TestCase( SECTION, DateString+".getUTCMonth()", UTCDate.month, DateCase.getUTCMonth() ); + new TestCase( SECTION, DateString+".getUTCDate()", UTCDate.date, DateCase.getUTCDate() ); + new TestCase( SECTION, DateString+".getUTCDay()", UTCDate.day, DateCase.getUTCDay() ); + new TestCase( SECTION, DateString+".getUTCHours()", UTCDate.hours, DateCase.getUTCHours() ); + new TestCase( SECTION, DateString+".getUTCMinutes()", UTCDate.minutes, DateCase.getUTCMinutes() ); + new TestCase( SECTION, DateString+".getUTCSeconds()", UTCDate.seconds, DateCase.getUTCSeconds() ); + new TestCase( SECTION, DateString+".getUTCMilliseconds()", UTCDate.ms, DateCase.getUTCMilliseconds() ); + + new TestCase( SECTION, DateString+".getFullYear()", LocalDate.year, DateCase.getFullYear() ); + new TestCase( SECTION, DateString+".getMonth()", LocalDate.month, DateCase.getMonth() ); + new TestCase( SECTION, DateString+".getDate()", LocalDate.date, DateCase.getDate() ); + new TestCase( SECTION, DateString+".getDay()", LocalDate.day, DateCase.getDay() ); + new TestCase( SECTION, DateString+".getHours()", LocalDate.hours, DateCase.getHours() ); + new TestCase( SECTION, DateString+".getMinutes()", LocalDate.minutes, DateCase.getMinutes() ); + new TestCase( SECTION, DateString+".getSeconds()", LocalDate.seconds, DateCase.getSeconds() ); + new TestCase( SECTION, DateString+".getMilliseconds()", LocalDate.ms, DateCase.getMilliseconds() ); + + DateCase.toString = Object.prototype.toString; + + new TestCase( SECTION, + DateString+".toString=Object.prototype.toString;"+DateString+".toString()", + "[object Date]", + DateCase.toString() ); +} +function MyDate() { + this.year = 0; + this.month = 0; + this.date = 0; + this.hours = 0; + this.minutes = 0; + this.seconds = 0; + this.ms = 0; +} +function LocalDateFromTime(t) { + t = LocalTime(t); + return ( MyDateFromTime(t) ); +} +function UTCDateFromTime(t) { + return ( MyDateFromTime(t) ); +} +function MyDateFromTime( t ) { + var d = new MyDate(); + d.year = YearFromTime(t); + d.month = MonthFromTime(t); + d.date = DateFromTime(t); + d.hours = HourFromTime(t); + d.minutes = MinFromTime(t); + d.seconds = SecFromTime(t); + d.ms = msFromTime(t); + + d.time = MakeTime( d.hours, d.minutes, d.seconds, d.ms ); + d.value = TimeClip( MakeDate( MakeDay( d.year, d.month, d.date ), d.time ) ); + d.day = WeekDay( d.value ); + + return (d); +} +function SetUTCMonth( t, month, date ) { + var T = t; + var MONTH = Number( month ); + var DATE = ( date == void 0) ? DateFromTime(T) : Number( date ); + + var RESULT4 = MakeDay(YearFromTime(T), MONTH, DATE ); + var RESULT5 = MakeDate( RESULT4, TimeWithinDay(T)); + + return ( TimeClip(RESULT5) ); +} diff --git a/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.36-1.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.36-1.js new file mode 100644 index 0000000000..f4cd44c2c2 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.36-1.js @@ -0,0 +1,165 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.9.5.36-1.js'; + +/** + File Name: 15.9.5.36-1.js + ECMA Section: 15.9.5.36 Date.prototype.setFullYear(year [, mon [, date ]] ) + Description: + + If mon is not specified, this behaves as if mon were specified with the + value getMonth( ). If date is not specified, this behaves as if date were + specified with the value getDate( ). + + 1. Let t be the result of LocalTime(this time value); but if this time + value is NaN, let t be +0. + 2. Call ToNumber(year). + 3. If mon is not specified, compute MonthFromTime(t); otherwise, call + ToNumber(mon). + 4. If date is not specified, compute DateFromTime(t); otherwise, call + ToNumber(date). + 5. Compute MakeDay(Result(2), Result(3), Result(4)). + 6. Compute UTC(MakeDate(Result(5), TimeWithinDay(t))). + 7. Set the [[Value]] property of the this value to TimeClip(Result(6)). + 8. Return the value of the [[Value]] property of the this value. + + Author: christine@netscape.com + Date: 12 november 1997 + + Added test cases for Year 2000 Compatilibity Testing. + +*/ +var SECTION = "15.9.5.36-1"; +var VERSION = "ECMA_1"; +startTest(); + +writeHeaderToLog( SECTION + " Date.prototype.setFullYear(year [, mon [, date ]] )"); + + +// 1969 + +addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(1969);TDATE", + UTCDateFromTime(SetFullYear(0,1969)), + LocalDateFromTime(SetFullYear(0,1969)) ); + +addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(1969,11);TDATE", + UTCDateFromTime(SetFullYear(0,1969,11)), + LocalDateFromTime(SetFullYear(0,1969,11)) ); + +addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(1969,11,31);TDATE", + UTCDateFromTime(SetFullYear(0,1969,11,31)), + LocalDateFromTime(SetFullYear(0,1969,11,31)) ); + +test(); + +function addNewTestCase( DateString, UTCDate, LocalDate) { + DateCase = eval( DateString ); + + new TestCase( SECTION, DateString+".getTime()", UTCDate.value, DateCase.getTime() ); + new TestCase( SECTION, DateString+".valueOf()", UTCDate.value, DateCase.valueOf() ); + + new TestCase( SECTION, DateString+".getUTCFullYear()", UTCDate.year, DateCase.getUTCFullYear() ); + new TestCase( SECTION, DateString+".getUTCMonth()", UTCDate.month, DateCase.getUTCMonth() ); + new TestCase( SECTION, DateString+".getUTCDate()", UTCDate.date, DateCase.getUTCDate() ); + new TestCase( SECTION, DateString+".getUTCDay()", UTCDate.day, DateCase.getUTCDay() ); + new TestCase( SECTION, DateString+".getUTCHours()", UTCDate.hours, DateCase.getUTCHours() ); + new TestCase( SECTION, DateString+".getUTCMinutes()", UTCDate.minutes,DateCase.getUTCMinutes() ); + new TestCase( SECTION, DateString+".getUTCSeconds()", UTCDate.seconds,DateCase.getUTCSeconds() ); + new TestCase( SECTION, DateString+".getUTCMilliseconds()", UTCDate.ms, DateCase.getUTCMilliseconds() ); + + new TestCase( SECTION, DateString+".getFullYear()", LocalDate.year, DateCase.getFullYear() ); + new TestCase( SECTION, DateString+".getMonth()", LocalDate.month, DateCase.getMonth() ); + new TestCase( SECTION, DateString+".getDate()", LocalDate.date, DateCase.getDate() ); + new TestCase( SECTION, DateString+".getDay()", LocalDate.day, DateCase.getDay() ); + new TestCase( SECTION, DateString+".getHours()", LocalDate.hours, DateCase.getHours() ); + new TestCase( SECTION, DateString+".getMinutes()", LocalDate.minutes, DateCase.getMinutes() ); + new TestCase( SECTION, DateString+".getSeconds()", LocalDate.seconds, DateCase.getSeconds() ); + new TestCase( SECTION, DateString+".getMilliseconds()", LocalDate.ms, DateCase.getMilliseconds() ); + + DateCase.toString = Object.prototype.toString; + + new TestCase( SECTION, + DateString+".toString=Object.prototype.toString;"+DateString+".toString()", + "[object Date]", + DateCase.toString() ); +} + +function MyDate() { + this.year = 0; + this.month = 0; + this.date = 0; + this.hours = 0; + this.minutes = 0; + this.seconds = 0; + this.ms = 0; +} +function LocalDateFromTime(t) { + t = LocalTime(t); + return ( MyDateFromTime(t) ); +} +function UTCDateFromTime(t) { + return ( MyDateFromTime(t) ); +} +function MyDateFromTime( t ) { + var d = new MyDate(); + d.year = YearFromTime(t); + d.month = MonthFromTime(t); + d.date = DateFromTime(t); + d.hours = HourFromTime(t); + d.minutes = MinFromTime(t); + d.seconds = SecFromTime(t); + d.ms = msFromTime(t); + + d.time = MakeTime( d.hours, d.minutes, d.seconds, d.ms ); + d.value = TimeClip( MakeDate( MakeDay( d.year, d.month, d.date ), d.time ) ); + d.day = WeekDay( d.value ); + + return (d); +} +function SetFullYear( t, year, mon, date ) { + var T = ( isNaN(t) ) ? 0 : LocalTime(t) ; + var YEAR = Number( year ); + var MONTH = ( mon == void 0 ) ? MonthFromTime(T) : Number( mon ); + var DATE = ( date == void 0 ) ? DateFromTime(T) : Number( date ); + + var DAY = MakeDay( YEAR, MONTH, DATE ); + var UTC_DATE = UTC(MakeDate( DAY, TimeWithinDay(T))); + + return ( TimeClip(UTC_DATE) ); +} diff --git a/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.36-2.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.36-2.js new file mode 100644 index 0000000000..a0ce018d0f --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.36-2.js @@ -0,0 +1,164 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.9.5.36-2.js'; + +/** + File Name: 15.9.5.36-1.js + ECMA Section: 15.9.5.36 Date.prototype.setFullYear(year [, mon [, date ]] ) + Description: + + If mon is not specified, this behaves as if mon were specified with the + value getMonth( ). If date is not specified, this behaves as if date were + specified with the value getDate( ). + + 1. Let t be the result of LocalTime(this time value); but if this time + value is NaN, let t be +0. + 2. Call ToNumber(year). + 3. If mon is not specified, compute MonthFromTime(t); otherwise, call + ToNumber(mon). + 4. If date is not specified, compute DateFromTime(t); otherwise, call + ToNumber(date). + 5. Compute MakeDay(Result(2), Result(3), Result(4)). + 6. Compute UTC(MakeDate(Result(5), TimeWithinDay(t))). + 7. Set the [[Value]] property of the this value to TimeClip(Result(6)). + 8. Return the value of the [[Value]] property of the this value. + + Author: christine@netscape.com + Date: 12 november 1997 + + Added test cases for Year 2000 Compatilibity Testing. + +*/ +var SECTION = "15.9.5.36-2"; +var VERSION = "ECMA_1"; +startTest(); + +writeHeaderToLog( SECTION + " Date.prototype.setFullYear(year [, mon [, date ]] )"); + +// 1970 + +addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(1970);TDATE", + UTCDateFromTime(SetFullYear(0,1970)), + LocalDateFromTime(SetFullYear(0,1970)) ); + +addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(1970,0);TDATE", + UTCDateFromTime(SetFullYear(0,1970,0)), + LocalDateFromTime(SetFullYear(0,1970,0)) ); + +addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(1970,0,1);TDATE", + UTCDateFromTime(SetFullYear(0,1970,0,1)), + LocalDateFromTime(SetFullYear(0,1970,0,1)) ); + +test(); + +function addNewTestCase( DateString, UTCDate, LocalDate) { + DateCase = eval( DateString ); + + new TestCase( SECTION, DateString+".getTime()", UTCDate.value, DateCase.getTime() ); + new TestCase( SECTION, DateString+".valueOf()", UTCDate.value, DateCase.valueOf() ); + + new TestCase( SECTION, DateString+".getUTCFullYear()", UTCDate.year, DateCase.getUTCFullYear() ); + new TestCase( SECTION, DateString+".getUTCMonth()", UTCDate.month, DateCase.getUTCMonth() ); + new TestCase( SECTION, DateString+".getUTCDate()", UTCDate.date, DateCase.getUTCDate() ); + new TestCase( SECTION, DateString+".getUTCDay()", UTCDate.day, DateCase.getUTCDay() ); + new TestCase( SECTION, DateString+".getUTCHours()", UTCDate.hours, DateCase.getUTCHours() ); + new TestCase( SECTION, DateString+".getUTCMinutes()", UTCDate.minutes,DateCase.getUTCMinutes() ); + new TestCase( SECTION, DateString+".getUTCSeconds()", UTCDate.seconds,DateCase.getUTCSeconds() ); + new TestCase( SECTION, DateString+".getUTCMilliseconds()", UTCDate.ms, DateCase.getUTCMilliseconds() ); + + new TestCase( SECTION, DateString+".getFullYear()", LocalDate.year, DateCase.getFullYear() ); + new TestCase( SECTION, DateString+".getMonth()", LocalDate.month, DateCase.getMonth() ); + new TestCase( SECTION, DateString+".getDate()", LocalDate.date, DateCase.getDate() ); + new TestCase( SECTION, DateString+".getDay()", LocalDate.day, DateCase.getDay() ); + new TestCase( SECTION, DateString+".getHours()", LocalDate.hours, DateCase.getHours() ); + new TestCase( SECTION, DateString+".getMinutes()", LocalDate.minutes, DateCase.getMinutes() ); + new TestCase( SECTION, DateString+".getSeconds()", LocalDate.seconds, DateCase.getSeconds() ); + new TestCase( SECTION, DateString+".getMilliseconds()", LocalDate.ms, DateCase.getMilliseconds() ); + + DateCase.toString = Object.prototype.toString; + + new TestCase( SECTION, + DateString+".toString=Object.prototype.toString;"+DateString+".toString()", + "[object Date]", + DateCase.toString() ); +} + +function MyDate() { + this.year = 0; + this.month = 0; + this.date = 0; + this.hours = 0; + this.minutes = 0; + this.seconds = 0; + this.ms = 0; +} +function LocalDateFromTime(t) { + t = LocalTime(t); + return ( MyDateFromTime(t) ); +} +function UTCDateFromTime(t) { + return ( MyDateFromTime(t) ); +} +function MyDateFromTime( t ) { + var d = new MyDate(); + d.year = YearFromTime(t); + d.month = MonthFromTime(t); + d.date = DateFromTime(t); + d.hours = HourFromTime(t); + d.minutes = MinFromTime(t); + d.seconds = SecFromTime(t); + d.ms = msFromTime(t); + + d.time = MakeTime( d.hours, d.minutes, d.seconds, d.ms ); + d.value = TimeClip( MakeDate( MakeDay( d.year, d.month, d.date ), d.time ) ); + d.day = WeekDay( d.value ); + + return (d); +} +function SetFullYear( t, year, mon, date ) { + var T = ( isNaN(t) ) ? 0 : LocalTime(t) ; + var YEAR = Number( year ); + var MONTH = ( mon == void 0 ) ? MonthFromTime(T) : Number( mon ); + var DATE = ( date == void 0 ) ? DateFromTime(T) : Number( date ); + + var DAY = MakeDay( YEAR, MONTH, DATE ); + var UTC_DATE = UTC(MakeDate( DAY, TimeWithinDay(T))); + + return ( TimeClip(UTC_DATE) ); +} diff --git a/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.36-3.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.36-3.js new file mode 100644 index 0000000000..f0849f28e7 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.36-3.js @@ -0,0 +1,163 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.9.5.36-3.js'; + +/** + File Name: 15.9.5.36-1.js + ECMA Section: 15.9.5.36 Date.prototype.setFullYear(year [, mon [, date ]] ) + Description: + + If mon is not specified, this behaves as if mon were specified with the + value getMonth( ). If date is not specified, this behaves as if date were + specified with the value getDate( ). + + 1. Let t be the result of LocalTime(this time value); but if this time + value is NaN, let t be +0. + 2. Call ToNumber(year). + 3. If mon is not specified, compute MonthFromTime(t); otherwise, call + ToNumber(mon). + 4. If date is not specified, compute DateFromTime(t); otherwise, call + ToNumber(date). + 5. Compute MakeDay(Result(2), Result(3), Result(4)). + 6. Compute UTC(MakeDate(Result(5), TimeWithinDay(t))). + 7. Set the [[Value]] property of the this value to TimeClip(Result(6)). + 8. Return the value of the [[Value]] property of the this value. + + Author: christine@netscape.com + Date: 12 november 1997 + + Added test cases for Year 2000 Compatilibity Testing. + +*/ +var SECTION = "15.9.5.36-1"; +var VERSION = "ECMA_1"; +startTest(); + +writeHeaderToLog( SECTION + " Date.prototype.setFullYear(year [, mon [, date ]] )"); + +// 1971 +addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(1971);TDATE", + UTCDateFromTime(SetFullYear(0,1971)), + LocalDateFromTime(SetFullYear(0,1971)) ); + +addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(1971,0);TDATE", + UTCDateFromTime(SetFullYear(0,1971,0)), + LocalDateFromTime(SetFullYear(0,1971,0)) ); + +addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(1971,0,1);TDATE", + UTCDateFromTime(SetFullYear(0,1971,0,1)), + LocalDateFromTime(SetFullYear(0,1971,0,1)) ); + +test(); + +function addNewTestCase( DateString, UTCDate, LocalDate) { + DateCase = eval( DateString ); + + new TestCase( SECTION, DateString+".getTime()", UTCDate.value, DateCase.getTime() ); + new TestCase( SECTION, DateString+".valueOf()", UTCDate.value, DateCase.valueOf() ); + + new TestCase( SECTION, DateString+".getUTCFullYear()", UTCDate.year, DateCase.getUTCFullYear() ); + new TestCase( SECTION, DateString+".getUTCMonth()", UTCDate.month, DateCase.getUTCMonth() ); + new TestCase( SECTION, DateString+".getUTCDate()", UTCDate.date, DateCase.getUTCDate() ); + new TestCase( SECTION, DateString+".getUTCDay()", UTCDate.day, DateCase.getUTCDay() ); + new TestCase( SECTION, DateString+".getUTCHours()", UTCDate.hours, DateCase.getUTCHours() ); + new TestCase( SECTION, DateString+".getUTCMinutes()", UTCDate.minutes,DateCase.getUTCMinutes() ); + new TestCase( SECTION, DateString+".getUTCSeconds()", UTCDate.seconds,DateCase.getUTCSeconds() ); + new TestCase( SECTION, DateString+".getUTCMilliseconds()", UTCDate.ms, DateCase.getUTCMilliseconds() ); + + new TestCase( SECTION, DateString+".getFullYear()", LocalDate.year, DateCase.getFullYear() ); + new TestCase( SECTION, DateString+".getMonth()", LocalDate.month, DateCase.getMonth() ); + new TestCase( SECTION, DateString+".getDate()", LocalDate.date, DateCase.getDate() ); + new TestCase( SECTION, DateString+".getDay()", LocalDate.day, DateCase.getDay() ); + new TestCase( SECTION, DateString+".getHours()", LocalDate.hours, DateCase.getHours() ); + new TestCase( SECTION, DateString+".getMinutes()", LocalDate.minutes, DateCase.getMinutes() ); + new TestCase( SECTION, DateString+".getSeconds()", LocalDate.seconds, DateCase.getSeconds() ); + new TestCase( SECTION, DateString+".getMilliseconds()", LocalDate.ms, DateCase.getMilliseconds() ); + + DateCase.toString = Object.prototype.toString; + + new TestCase( SECTION, + DateString+".toString=Object.prototype.toString;"+DateString+".toString()", + "[object Date]", + DateCase.toString() ); +} + +function MyDate() { + this.year = 0; + this.month = 0; + this.date = 0; + this.hours = 0; + this.minutes = 0; + this.seconds = 0; + this.ms = 0; +} +function LocalDateFromTime(t) { + t = LocalTime(t); + return ( MyDateFromTime(t) ); +} +function UTCDateFromTime(t) { + return ( MyDateFromTime(t) ); +} +function MyDateFromTime( t ) { + var d = new MyDate(); + d.year = YearFromTime(t); + d.month = MonthFromTime(t); + d.date = DateFromTime(t); + d.hours = HourFromTime(t); + d.minutes = MinFromTime(t); + d.seconds = SecFromTime(t); + d.ms = msFromTime(t); + + d.time = MakeTime( d.hours, d.minutes, d.seconds, d.ms ); + d.value = TimeClip( MakeDate( MakeDay( d.year, d.month, d.date ), d.time ) ); + d.day = WeekDay( d.value ); + + return (d); +} +function SetFullYear( t, year, mon, date ) { + var T = ( isNaN(t) ) ? 0 : LocalTime(t) ; + var YEAR = Number( year ); + var MONTH = ( mon == void 0 ) ? MonthFromTime(T) : Number( mon ); + var DATE = ( date == void 0 ) ? DateFromTime(T) : Number( date ); + + var DAY = MakeDay( YEAR, MONTH, DATE ); + var UTC_DATE = UTC(MakeDate( DAY, TimeWithinDay(T))); + + return ( TimeClip(UTC_DATE) ); +} diff --git a/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.36-4.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.36-4.js new file mode 100644 index 0000000000..0ca872f8db --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.36-4.js @@ -0,0 +1,163 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.9.5.36-4.js'; + +/** + File Name: 15.9.5.36-1.js + ECMA Section: 15.9.5.36 Date.prototype.setFullYear(year [, mon [, date ]] ) + Description: + + If mon is not specified, this behaves as if mon were specified with the + value getMonth( ). If date is not specified, this behaves as if date were + specified with the value getDate( ). + + 1. Let t be the result of LocalTime(this time value); but if this time + value is NaN, let t be +0. + 2. Call ToNumber(year). + 3. If mon is not specified, compute MonthFromTime(t); otherwise, call + ToNumber(mon). + 4. If date is not specified, compute DateFromTime(t); otherwise, call + ToNumber(date). + 5. Compute MakeDay(Result(2), Result(3), Result(4)). + 6. Compute UTC(MakeDate(Result(5), TimeWithinDay(t))). + 7. Set the [[Value]] property of the this value to TimeClip(Result(6)). + 8. Return the value of the [[Value]] property of the this value. + + Author: christine@netscape.com + Date: 12 november 1997 + + Added test cases for Year 2000 Compatilibity Testing. + +*/ +var SECTION = "15.9.5.36-1"; +var VERSION = "ECMA_1"; +startTest(); + +writeHeaderToLog( SECTION + " Date.prototype.setFullYear(year [, mon [, date ]] )"); + +// 1999 +addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(1999);TDATE", + UTCDateFromTime(SetFullYear(0,1999)), + LocalDateFromTime(SetFullYear(0,1999)) ); + +addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(1999,11);TDATE", + UTCDateFromTime(SetFullYear(0,1999,11)), + LocalDateFromTime(SetFullYear(0,1999,11)) ); + +addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(1999,11,31);TDATE", + UTCDateFromTime(SetFullYear(0,1999,11,31)), + LocalDateFromTime(SetFullYear(0,1999,11,31)) ); + +test(); + +function addNewTestCase( DateString, UTCDate, LocalDate) { + DateCase = eval( DateString ); + + new TestCase( SECTION, DateString+".getTime()", UTCDate.value, DateCase.getTime() ); + new TestCase( SECTION, DateString+".valueOf()", UTCDate.value, DateCase.valueOf() ); + + new TestCase( SECTION, DateString+".getUTCFullYear()", UTCDate.year, DateCase.getUTCFullYear() ); + new TestCase( SECTION, DateString+".getUTCMonth()", UTCDate.month, DateCase.getUTCMonth() ); + new TestCase( SECTION, DateString+".getUTCDate()", UTCDate.date, DateCase.getUTCDate() ); + new TestCase( SECTION, DateString+".getUTCDay()", UTCDate.day, DateCase.getUTCDay() ); + new TestCase( SECTION, DateString+".getUTCHours()", UTCDate.hours, DateCase.getUTCHours() ); + new TestCase( SECTION, DateString+".getUTCMinutes()", UTCDate.minutes,DateCase.getUTCMinutes() ); + new TestCase( SECTION, DateString+".getUTCSeconds()", UTCDate.seconds,DateCase.getUTCSeconds() ); + new TestCase( SECTION, DateString+".getUTCMilliseconds()", UTCDate.ms, DateCase.getUTCMilliseconds() ); + + new TestCase( SECTION, DateString+".getFullYear()", LocalDate.year, DateCase.getFullYear() ); + new TestCase( SECTION, DateString+".getMonth()", LocalDate.month, DateCase.getMonth() ); + new TestCase( SECTION, DateString+".getDate()", LocalDate.date, DateCase.getDate() ); + new TestCase( SECTION, DateString+".getDay()", LocalDate.day, DateCase.getDay() ); + new TestCase( SECTION, DateString+".getHours()", LocalDate.hours, DateCase.getHours() ); + new TestCase( SECTION, DateString+".getMinutes()", LocalDate.minutes, DateCase.getMinutes() ); + new TestCase( SECTION, DateString+".getSeconds()", LocalDate.seconds, DateCase.getSeconds() ); + new TestCase( SECTION, DateString+".getMilliseconds()", LocalDate.ms, DateCase.getMilliseconds() ); + + DateCase.toString = Object.prototype.toString; + + new TestCase( SECTION, + DateString+".toString=Object.prototype.toString;"+DateString+".toString()", + "[object Date]", + DateCase.toString() ); +} + +function MyDate() { + this.year = 0; + this.month = 0; + this.date = 0; + this.hours = 0; + this.minutes = 0; + this.seconds = 0; + this.ms = 0; +} +function LocalDateFromTime(t) { + t = LocalTime(t); + return ( MyDateFromTime(t) ); +} +function UTCDateFromTime(t) { + return ( MyDateFromTime(t) ); +} +function MyDateFromTime( t ) { + var d = new MyDate(); + d.year = YearFromTime(t); + d.month = MonthFromTime(t); + d.date = DateFromTime(t); + d.hours = HourFromTime(t); + d.minutes = MinFromTime(t); + d.seconds = SecFromTime(t); + d.ms = msFromTime(t); + + d.time = MakeTime( d.hours, d.minutes, d.seconds, d.ms ); + d.value = TimeClip( MakeDate( MakeDay( d.year, d.month, d.date ), d.time ) ); + d.day = WeekDay( d.value ); + + return (d); +} +function SetFullYear( t, year, mon, date ) { + var T = ( isNaN(t) ) ? 0 : LocalTime(t) ; + var YEAR = Number( year ); + var MONTH = ( mon == void 0 ) ? MonthFromTime(T) : Number( mon ); + var DATE = ( date == void 0 ) ? DateFromTime(T) : Number( date ); + + var DAY = MakeDay( YEAR, MONTH, DATE ); + var UTC_DATE = UTC(MakeDate( DAY, TimeWithinDay(T))); + + return ( TimeClip(UTC_DATE) ); +} diff --git a/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.36-5.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.36-5.js new file mode 100644 index 0000000000..2496548b1d --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.36-5.js @@ -0,0 +1,163 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.9.5.36-5.js'; + +/** + File Name: 15.9.5.36-1.js + ECMA Section: 15.9.5.36 Date.prototype.setFullYear(year [, mon [, date ]] ) + Description: + + If mon is not specified, this behaves as if mon were specified with the + value getMonth( ). If date is not specified, this behaves as if date were + specified with the value getDate( ). + + 1. Let t be the result of LocalTime(this time value); but if this time + value is NaN, let t be +0. + 2. Call ToNumber(year). + 3. If mon is not specified, compute MonthFromTime(t); otherwise, call + ToNumber(mon). + 4. If date is not specified, compute DateFromTime(t); otherwise, call + ToNumber(date). + 5. Compute MakeDay(Result(2), Result(3), Result(4)). + 6. Compute UTC(MakeDate(Result(5), TimeWithinDay(t))). + 7. Set the [[Value]] property of the this value to TimeClip(Result(6)). + 8. Return the value of the [[Value]] property of the this value. + + Author: christine@netscape.com + Date: 12 november 1997 + + Added test cases for Year 2000 Compatilibity Testing. + +*/ +var SECTION = "15.9.5.36-1"; +var VERSION = "ECMA_1"; +startTest(); + +writeHeaderToLog( SECTION + " Date.prototype.setFullYear(year [, mon [, date ]] )"); + +// 2000 +addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(2000);TDATE", + UTCDateFromTime(SetFullYear(0,2000)), + LocalDateFromTime(SetFullYear(0,2000)) ); + +addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(2000,0);TDATE", + UTCDateFromTime(SetFullYear(0,2000,0)), + LocalDateFromTime(SetFullYear(0,2000,0)) ); + +addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(2000,0,1);TDATE", + UTCDateFromTime(SetFullYear(0,2000,0,1)), + LocalDateFromTime(SetFullYear(0,2000,0,1)) ); + +test(); + +function addNewTestCase( DateString, UTCDate, LocalDate) { + DateCase = eval( DateString ); + + new TestCase( SECTION, DateString+".getTime()", UTCDate.value, DateCase.getTime() ); + new TestCase( SECTION, DateString+".valueOf()", UTCDate.value, DateCase.valueOf() ); + + new TestCase( SECTION, DateString+".getUTCFullYear()", UTCDate.year, DateCase.getUTCFullYear() ); + new TestCase( SECTION, DateString+".getUTCMonth()", UTCDate.month, DateCase.getUTCMonth() ); + new TestCase( SECTION, DateString+".getUTCDate()", UTCDate.date, DateCase.getUTCDate() ); + new TestCase( SECTION, DateString+".getUTCDay()", UTCDate.day, DateCase.getUTCDay() ); + new TestCase( SECTION, DateString+".getUTCHours()", UTCDate.hours, DateCase.getUTCHours() ); + new TestCase( SECTION, DateString+".getUTCMinutes()", UTCDate.minutes,DateCase.getUTCMinutes() ); + new TestCase( SECTION, DateString+".getUTCSeconds()", UTCDate.seconds,DateCase.getUTCSeconds() ); + new TestCase( SECTION, DateString+".getUTCMilliseconds()", UTCDate.ms, DateCase.getUTCMilliseconds() ); + + new TestCase( SECTION, DateString+".getFullYear()", LocalDate.year, DateCase.getFullYear() ); + new TestCase( SECTION, DateString+".getMonth()", LocalDate.month, DateCase.getMonth() ); + new TestCase( SECTION, DateString+".getDate()", LocalDate.date, DateCase.getDate() ); + new TestCase( SECTION, DateString+".getDay()", LocalDate.day, DateCase.getDay() ); + new TestCase( SECTION, DateString+".getHours()", LocalDate.hours, DateCase.getHours() ); + new TestCase( SECTION, DateString+".getMinutes()", LocalDate.minutes, DateCase.getMinutes() ); + new TestCase( SECTION, DateString+".getSeconds()", LocalDate.seconds, DateCase.getSeconds() ); + new TestCase( SECTION, DateString+".getMilliseconds()", LocalDate.ms, DateCase.getMilliseconds() ); + + DateCase.toString = Object.prototype.toString; + + new TestCase( SECTION, + DateString+".toString=Object.prototype.toString;"+DateString+".toString()", + "[object Date]", + DateCase.toString() ); +} + +function MyDate() { + this.year = 0; + this.month = 0; + this.date = 0; + this.hours = 0; + this.minutes = 0; + this.seconds = 0; + this.ms = 0; +} +function LocalDateFromTime(t) { + t = LocalTime(t); + return ( MyDateFromTime(t) ); +} +function UTCDateFromTime(t) { + return ( MyDateFromTime(t) ); +} +function MyDateFromTime( t ) { + var d = new MyDate(); + d.year = YearFromTime(t); + d.month = MonthFromTime(t); + d.date = DateFromTime(t); + d.hours = HourFromTime(t); + d.minutes = MinFromTime(t); + d.seconds = SecFromTime(t); + d.ms = msFromTime(t); + + d.time = MakeTime( d.hours, d.minutes, d.seconds, d.ms ); + d.value = TimeClip( MakeDate( MakeDay( d.year, d.month, d.date ), d.time ) ); + d.day = WeekDay( d.value ); + + return (d); +} +function SetFullYear( t, year, mon, date ) { + var T = ( isNaN(t) ) ? 0 : LocalTime(t) ; + var YEAR = Number( year ); + var MONTH = ( mon == void 0 ) ? MonthFromTime(T) : Number( mon ); + var DATE = ( date == void 0 ) ? DateFromTime(T) : Number( date ); + + var DAY = MakeDay( YEAR, MONTH, DATE ); + var UTC_DATE = UTC(MakeDate( DAY, TimeWithinDay(T))); + + return ( TimeClip(UTC_DATE) ); +} diff --git a/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.36-6.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.36-6.js new file mode 100644 index 0000000000..9a05c3130e --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.36-6.js @@ -0,0 +1,163 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.9.5.36-6.js'; + +/** + File Name: 15.9.5.36-1.js + ECMA Section: 15.9.5.36 Date.prototype.setFullYear(year [, mon [, date ]] ) + Description: + + If mon is not specified, this behaves as if mon were specified with the + value getMonth( ). If date is not specified, this behaves as if date were + specified with the value getDate( ). + + 1. Let t be the result of LocalTime(this time value); but if this time + value is NaN, let t be +0. + 2. Call ToNumber(year). + 3. If mon is not specified, compute MonthFromTime(t); otherwise, call + ToNumber(mon). + 4. If date is not specified, compute DateFromTime(t); otherwise, call + ToNumber(date). + 5. Compute MakeDay(Result(2), Result(3), Result(4)). + 6. Compute UTC(MakeDate(Result(5), TimeWithinDay(t))). + 7. Set the [[Value]] property of the this value to TimeClip(Result(6)). + 8. Return the value of the [[Value]] property of the this value. + + Author: christine@netscape.com + Date: 12 november 1997 + + Added test cases for Year 2000 Compatilibity Testing. + +*/ +var SECTION = "15.9.5.36-1"; +var VERSION = "ECMA_1"; +startTest(); + +writeHeaderToLog( SECTION + " Date.prototype.setFullYear(year [, mon [, date ]] )"); + +// feb 29, 2000 +addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(2000);TDATE", + UTCDateFromTime(SetFullYear(0,2000)), + LocalDateFromTime(SetFullYear(0,2000)) ); + +addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(2000,1);TDATE", + UTCDateFromTime(SetFullYear(0,2000,1)), + LocalDateFromTime(SetFullYear(0,2000,1)) ); + +addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(2000,1,29);TDATE", + UTCDateFromTime(SetFullYear(0,2000,1,29)), + LocalDateFromTime(SetFullYear(0,2000,1,29)) ); + +test(); + +function addNewTestCase( DateString, UTCDate, LocalDate) { + DateCase = eval( DateString ); + + new TestCase( SECTION, DateString+".getTime()", UTCDate.value, DateCase.getTime() ); + new TestCase( SECTION, DateString+".valueOf()", UTCDate.value, DateCase.valueOf() ); + + new TestCase( SECTION, DateString+".getUTCFullYear()", UTCDate.year, DateCase.getUTCFullYear() ); + new TestCase( SECTION, DateString+".getUTCMonth()", UTCDate.month, DateCase.getUTCMonth() ); + new TestCase( SECTION, DateString+".getUTCDate()", UTCDate.date, DateCase.getUTCDate() ); + new TestCase( SECTION, DateString+".getUTCDay()", UTCDate.day, DateCase.getUTCDay() ); + new TestCase( SECTION, DateString+".getUTCHours()", UTCDate.hours, DateCase.getUTCHours() ); + new TestCase( SECTION, DateString+".getUTCMinutes()", UTCDate.minutes,DateCase.getUTCMinutes() ); + new TestCase( SECTION, DateString+".getUTCSeconds()", UTCDate.seconds,DateCase.getUTCSeconds() ); + new TestCase( SECTION, DateString+".getUTCMilliseconds()", UTCDate.ms, DateCase.getUTCMilliseconds() ); + + new TestCase( SECTION, DateString+".getFullYear()", LocalDate.year, DateCase.getFullYear() ); + new TestCase( SECTION, DateString+".getMonth()", LocalDate.month, DateCase.getMonth() ); + new TestCase( SECTION, DateString+".getDate()", LocalDate.date, DateCase.getDate() ); + new TestCase( SECTION, DateString+".getDay()", LocalDate.day, DateCase.getDay() ); + new TestCase( SECTION, DateString+".getHours()", LocalDate.hours, DateCase.getHours() ); + new TestCase( SECTION, DateString+".getMinutes()", LocalDate.minutes, DateCase.getMinutes() ); + new TestCase( SECTION, DateString+".getSeconds()", LocalDate.seconds, DateCase.getSeconds() ); + new TestCase( SECTION, DateString+".getMilliseconds()", LocalDate.ms, DateCase.getMilliseconds() ); + + DateCase.toString = Object.prototype.toString; + + new TestCase( SECTION, + DateString+".toString=Object.prototype.toString;"+DateString+".toString()", + "[object Date]", + DateCase.toString() ); +} + +function MyDate() { + this.year = 0; + this.month = 0; + this.date = 0; + this.hours = 0; + this.minutes = 0; + this.seconds = 0; + this.ms = 0; +} +function LocalDateFromTime(t) { + t = LocalTime(t); + return ( MyDateFromTime(t) ); +} +function UTCDateFromTime(t) { + return ( MyDateFromTime(t) ); +} +function MyDateFromTime( t ) { + var d = new MyDate(); + d.year = YearFromTime(t); + d.month = MonthFromTime(t); + d.date = DateFromTime(t); + d.hours = HourFromTime(t); + d.minutes = MinFromTime(t); + d.seconds = SecFromTime(t); + d.ms = msFromTime(t); + + d.time = MakeTime( d.hours, d.minutes, d.seconds, d.ms ); + d.value = TimeClip( MakeDate( MakeDay( d.year, d.month, d.date ), d.time ) ); + d.day = WeekDay( d.value ); + + return (d); +} +function SetFullYear( t, year, mon, date ) { + var T = ( isNaN(t) ) ? 0 : LocalTime(t) ; + var YEAR = Number( year ); + var MONTH = ( mon == void 0 ) ? MonthFromTime(T) : Number( mon ); + var DATE = ( date == void 0 ) ? DateFromTime(T) : Number( date ); + + var DAY = MakeDay( YEAR, MONTH, DATE ); + var UTC_DATE = UTC(MakeDate( DAY, TimeWithinDay(T))); + + return ( TimeClip(UTC_DATE) ); +} diff --git a/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.36-7.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.36-7.js new file mode 100644 index 0000000000..5bc330bbea --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.36-7.js @@ -0,0 +1,163 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.9.5.36-7.js'; + +/** + File Name: 15.9.5.36-1.js + ECMA Section: 15.9.5.36 Date.prototype.setFullYear(year [, mon [, date ]] ) + Description: + + If mon is not specified, this behaves as if mon were specified with the + value getMonth( ). If date is not specified, this behaves as if date were + specified with the value getDate( ). + + 1. Let t be the result of LocalTime(this time value); but if this time + value is NaN, let t be +0. + 2. Call ToNumber(year). + 3. If mon is not specified, compute MonthFromTime(t); otherwise, call + ToNumber(mon). + 4. If date is not specified, compute DateFromTime(t); otherwise, call + ToNumber(date). + 5. Compute MakeDay(Result(2), Result(3), Result(4)). + 6. Compute UTC(MakeDate(Result(5), TimeWithinDay(t))). + 7. Set the [[Value]] property of the this value to TimeClip(Result(6)). + 8. Return the value of the [[Value]] property of the this value. + + Author: christine@netscape.com + Date: 12 november 1997 + + Added test cases for Year 2000 Compatilibity Testing. + +*/ +var SECTION = "15.9.5.36-1"; +var VERSION = "ECMA_1"; +startTest(); + +writeHeaderToLog( SECTION + " Date.prototype.setFullYear(year [, mon [, date ]] )"); + +// Jan 1, 2005 +addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(2005);TDATE", + UTCDateFromTime(SetFullYear(0,2005)), + LocalDateFromTime(SetFullYear(0,2005)) ); + +addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(2005,0);TDATE", + UTCDateFromTime(SetFullYear(0,2005,0)), + LocalDateFromTime(SetFullYear(0,2005,0)) ); + +addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(2005,0,1);TDATE", + UTCDateFromTime(SetFullYear(0,2005,0,1)), + LocalDateFromTime(SetFullYear(0,2005,0,1)) ); + +test(); + +function addNewTestCase( DateString, UTCDate, LocalDate) { + DateCase = eval( DateString ); + + new TestCase( SECTION, DateString+".getTime()", UTCDate.value, DateCase.getTime() ); + new TestCase( SECTION, DateString+".valueOf()", UTCDate.value, DateCase.valueOf() ); + + new TestCase( SECTION, DateString+".getUTCFullYear()", UTCDate.year, DateCase.getUTCFullYear() ); + new TestCase( SECTION, DateString+".getUTCMonth()", UTCDate.month, DateCase.getUTCMonth() ); + new TestCase( SECTION, DateString+".getUTCDate()", UTCDate.date, DateCase.getUTCDate() ); + new TestCase( SECTION, DateString+".getUTCDay()", UTCDate.day, DateCase.getUTCDay() ); + new TestCase( SECTION, DateString+".getUTCHours()", UTCDate.hours, DateCase.getUTCHours() ); + new TestCase( SECTION, DateString+".getUTCMinutes()", UTCDate.minutes,DateCase.getUTCMinutes() ); + new TestCase( SECTION, DateString+".getUTCSeconds()", UTCDate.seconds,DateCase.getUTCSeconds() ); + new TestCase( SECTION, DateString+".getUTCMilliseconds()", UTCDate.ms, DateCase.getUTCMilliseconds() ); + + new TestCase( SECTION, DateString+".getFullYear()", LocalDate.year, DateCase.getFullYear() ); + new TestCase( SECTION, DateString+".getMonth()", LocalDate.month, DateCase.getMonth() ); + new TestCase( SECTION, DateString+".getDate()", LocalDate.date, DateCase.getDate() ); + new TestCase( SECTION, DateString+".getDay()", LocalDate.day, DateCase.getDay() ); + new TestCase( SECTION, DateString+".getHours()", LocalDate.hours, DateCase.getHours() ); + new TestCase( SECTION, DateString+".getMinutes()", LocalDate.minutes, DateCase.getMinutes() ); + new TestCase( SECTION, DateString+".getSeconds()", LocalDate.seconds, DateCase.getSeconds() ); + new TestCase( SECTION, DateString+".getMilliseconds()", LocalDate.ms, DateCase.getMilliseconds() ); + + DateCase.toString = Object.prototype.toString; + + new TestCase( SECTION, + DateString+".toString=Object.prototype.toString;"+DateString+".toString()", + "[object Date]", + DateCase.toString() ); +} + +function MyDate() { + this.year = 0; + this.month = 0; + this.date = 0; + this.hours = 0; + this.minutes = 0; + this.seconds = 0; + this.ms = 0; +} +function LocalDateFromTime(t) { + t = LocalTime(t); + return ( MyDateFromTime(t) ); +} +function UTCDateFromTime(t) { + return ( MyDateFromTime(t) ); +} +function MyDateFromTime( t ) { + var d = new MyDate(); + d.year = YearFromTime(t); + d.month = MonthFromTime(t); + d.date = DateFromTime(t); + d.hours = HourFromTime(t); + d.minutes = MinFromTime(t); + d.seconds = SecFromTime(t); + d.ms = msFromTime(t); + + d.time = MakeTime( d.hours, d.minutes, d.seconds, d.ms ); + d.value = TimeClip( MakeDate( MakeDay( d.year, d.month, d.date ), d.time ) ); + d.day = WeekDay( d.value ); + + return (d); +} +function SetFullYear( t, year, mon, date ) { + var T = ( isNaN(t) ) ? 0 : LocalTime(t) ; + var YEAR = Number( year ); + var MONTH = ( mon == void 0 ) ? MonthFromTime(T) : Number( mon ); + var DATE = ( date == void 0 ) ? DateFromTime(T) : Number( date ); + + var DAY = MakeDay( YEAR, MONTH, DATE ); + var UTC_DATE = UTC(MakeDate( DAY, TimeWithinDay(T))); + + return ( TimeClip(UTC_DATE) ); +} diff --git a/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.37-1.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.37-1.js new file mode 100644 index 0000000000..a6acd3d10a --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.37-1.js @@ -0,0 +1,173 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.9.5.37-1.js'; + +/** + File Name: 15.9.5.37-1.js + ECMA Section: 15.9.5.37 Date.prototype.setUTCFullYear(year [, mon [, date ]] ) + Description: + + If mon is not specified, this behaves as if mon were specified with the + value getUTCMonth( ). If date is not specified, this behaves as if date + were specified with the value getUTCDate( ). + + 1. Let t be this time value; but if this time value is NaN, let t be +0. + 2. Call ToNumber(year). + 3. If mon is not specified, compute MonthFromTime(t); otherwise, call + ToNumber(mon). + 4. If date is not specified, compute DateFromTime(t); otherwise, call + ToNumber(date). + 5. Compute MakeDay(Result(2), Result(3), Result(4)). + 6. Compute MakeDate(Result(5), TimeWithinDay(t)). + 7. Set the [[Value]] property of the this value to TimeClip(Result(6)). + 8. Return the value of the [[Value]] property of the this value. + + Author: christine@netscape.com + Date: 12 november 1997 + + Added some Year 2000 test cases. +*/ +var SECTION = "15.9.5.37-1"; +var VERSION = "ECMA_1"; +startTest(); + +writeHeaderToLog( SECTION + " Date.prototype.setUTCFullYear(year [, mon [, date ]] )"); + + +// Dates around 1970 + +addNewTestCase( "TDATE = new Date(0);(TDATE).setUTCFullYear(1970);TDATE", + UTCDateFromTime(SetUTCFullYear(0,1970)), + LocalDateFromTime(SetUTCFullYear(0,1970)) ); + +addNewTestCase( "TDATE = new Date(0);(TDATE).setUTCFullYear(1971);TDATE", + UTCDateFromTime(SetUTCFullYear(0,1971)), + LocalDateFromTime(SetUTCFullYear(0,1971)) ); + +addNewTestCase( "TDATE = new Date(0);(TDATE).setUTCFullYear(1972);TDATE", + UTCDateFromTime(SetUTCFullYear(0,1972)), + LocalDateFromTime(SetUTCFullYear(0,1972)) ); + +addNewTestCase( "TDATE = new Date(0);(TDATE).setUTCFullYear(1968);TDATE", + UTCDateFromTime(SetUTCFullYear(0,1968)), + LocalDateFromTime(SetUTCFullYear(0,1968)) ); + +addNewTestCase( "TDATE = new Date(0);(TDATE).setUTCFullYear(1969);TDATE", + UTCDateFromTime(SetUTCFullYear(0,1969)), + LocalDateFromTime(SetUTCFullYear(0,1969)) ); + +addNewTestCase( "TDATE = new Date(0);(TDATE).setUTCFullYear(1969);TDATE", + UTCDateFromTime(SetUTCFullYear(0,1969)), + LocalDateFromTime(SetUTCFullYear(0,1969)) ); + +test(); + +function addNewTestCase( DateString, UTCDate, LocalDate) { + DateCase = eval( DateString ); + + new TestCase( SECTION, DateString+".getTime()", UTCDate.value, DateCase.getTime() ); + new TestCase( SECTION, DateString+".valueOf()", UTCDate.value, DateCase.valueOf() ); + + new TestCase( SECTION, DateString+".getUTCFullYear()", UTCDate.year, DateCase.getUTCFullYear() ); + new TestCase( SECTION, DateString+".getUTCMonth()", UTCDate.month, DateCase.getUTCMonth() ); + new TestCase( SECTION, DateString+".getUTCDate()", UTCDate.date, DateCase.getUTCDate() ); + new TestCase( SECTION, DateString+".getUTCDay()", UTCDate.day, DateCase.getUTCDay() ); + new TestCase( SECTION, DateString+".getUTCHours()", UTCDate.hours, DateCase.getUTCHours() ); + new TestCase( SECTION, DateString+".getUTCMinutes()", UTCDate.minutes,DateCase.getUTCMinutes() ); + new TestCase( SECTION, DateString+".getUTCSeconds()", UTCDate.seconds,DateCase.getUTCSeconds() ); + new TestCase( SECTION, DateString+".getUTCMilliseconds()", UTCDate.ms, DateCase.getUTCMilliseconds() ); + + new TestCase( SECTION, DateString+".getFullYear()", LocalDate.year, DateCase.getFullYear() ); + new TestCase( SECTION, DateString+".getMonth()", LocalDate.month, DateCase.getMonth() ); + new TestCase( SECTION, DateString+".getDate()", LocalDate.date, DateCase.getDate() ); + new TestCase( SECTION, DateString+".getDay()", LocalDate.day, DateCase.getDay() ); + new TestCase( SECTION, DateString+".getHours()", LocalDate.hours, DateCase.getHours() ); + new TestCase( SECTION, DateString+".getMinutes()", LocalDate.minutes, DateCase.getMinutes() ); + new TestCase( SECTION, DateString+".getSeconds()", LocalDate.seconds, DateCase.getSeconds() ); + new TestCase( SECTION, DateString+".getMilliseconds()", LocalDate.ms, DateCase.getMilliseconds() ); + + DateCase.toString = Object.prototype.toString; + + new TestCase( SECTION, + DateString+".toString=Object.prototype.toString;"+DateString+".toString()", + "[object Date]", + DateCase.toString() ); +} + +function MyDate() { + this.year = 0; + this.month = 0; + this.date = 0; + this.hours = 0; + this.minutes = 0; + this.seconds = 0; + this.ms = 0; +} +function LocalDateFromTime(t) { + t = LocalTime(t); + return ( MyDateFromTime(t) ); +} +function UTCDateFromTime(t) { + return ( MyDateFromTime(t) ); +} +function MyDateFromTime( t ) { + var d = new MyDate(); + d.year = YearFromTime(t); + d.month = MonthFromTime(t); + d.date = DateFromTime(t); + d.hours = HourFromTime(t); + d.minutes = MinFromTime(t); + d.seconds = SecFromTime(t); + d.ms = msFromTime(t); + + d.time = MakeTime( d.hours, d.minutes, d.seconds, d.ms ); + d.value = TimeClip( MakeDate( MakeDay( d.year, d.month, d.date ), d.time ) ); + d.day = WeekDay( d.value ); + + return (d); +} +function SetUTCFullYear( t, year, mon, date ) { + var T = ( t != t ) ? 0 : t; + var YEAR = Number(year); + var MONTH = ( mon == void 0 ) ? MonthFromTime(T) : Number( mon ); + var DATE = ( date == void 0 ) ? DateFromTime(T) : Number( date ); + var DAY = MakeDay( YEAR, MONTH, DATE ); + + return ( TimeClip(MakeDate(DAY, TimeWithinDay(T))) ); +} diff --git a/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.37-2.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.37-2.js new file mode 100644 index 0000000000..e5ec78ea72 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.37-2.js @@ -0,0 +1,161 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.9.5.37-2.js'; + +/** + File Name: 15.9.5.37-1.js + ECMA Section: 15.9.5.37 Date.prototype.setUTCFullYear(year [, mon [, date ]] ) + Description: + + If mon is not specified, this behaves as if mon were specified with the + value getUTCMonth( ). If date is not specified, this behaves as if date + were specified with the value getUTCDate( ). + + 1. Let t be this time value; but if this time value is NaN, let t be +0. + 2. Call ToNumber(year). + 3. If mon is not specified, compute MonthFromTime(t); otherwise, call + ToNumber(mon). + 4. If date is not specified, compute DateFromTime(t); otherwise, call + ToNumber(date). + 5. Compute MakeDay(Result(2), Result(3), Result(4)). + 6. Compute MakeDate(Result(5), TimeWithinDay(t)). + 7. Set the [[Value]] property of the this value to TimeClip(Result(6)). + 8. Return the value of the [[Value]] property of the this value. + + Author: christine@netscape.com + Date: 12 november 1997 + + Added some Year 2000 test cases. +*/ +var SECTION = "15.9.5.37-1"; +var VERSION = "ECMA_1"; +startTest(); + +writeHeaderToLog( SECTION + " Date.prototype.setUTCFullYear(year [, mon [, date ]] )"); + + +// Dates around 2000 + +addNewTestCase( "TDATE = new Date(0); TDATE.setUTCFullYear(2000);TDATE", + UTCDateFromTime(SetUTCFullYear(0,2000)), + LocalDateFromTime(SetUTCFullYear(0,2000)) ); + +addNewTestCase( "TDATE = new Date(0); TDATE.setUTCFullYear(2001);TDATE", + UTCDateFromTime(SetUTCFullYear(0,2001)), + LocalDateFromTime(SetUTCFullYear(0,2001)) ); + +addNewTestCase( "TDATE = new Date(0); TDATE.setUTCFullYear(1999);TDATE", + UTCDateFromTime(SetUTCFullYear(0,1999)), + LocalDateFromTime(SetUTCFullYear(0,1999)) ); + +test(); + +function addNewTestCase( DateString, UTCDate, LocalDate) { + DateCase = eval( DateString ); + + new TestCase( SECTION, DateString+".getTime()", UTCDate.value, DateCase.getTime() ); + new TestCase( SECTION, DateString+".valueOf()", UTCDate.value, DateCase.valueOf() ); + + new TestCase( SECTION, DateString+".getUTCFullYear()", UTCDate.year, DateCase.getUTCFullYear() ); + new TestCase( SECTION, DateString+".getUTCMonth()", UTCDate.month, DateCase.getUTCMonth() ); + new TestCase( SECTION, DateString+".getUTCDate()", UTCDate.date, DateCase.getUTCDate() ); + new TestCase( SECTION, DateString+".getUTCDay()", UTCDate.day, DateCase.getUTCDay() ); + new TestCase( SECTION, DateString+".getUTCHours()", UTCDate.hours, DateCase.getUTCHours() ); + new TestCase( SECTION, DateString+".getUTCMinutes()", UTCDate.minutes,DateCase.getUTCMinutes() ); + new TestCase( SECTION, DateString+".getUTCSeconds()", UTCDate.seconds,DateCase.getUTCSeconds() ); + new TestCase( SECTION, DateString+".getUTCMilliseconds()", UTCDate.ms, DateCase.getUTCMilliseconds() ); + + new TestCase( SECTION, DateString+".getFullYear()", LocalDate.year, DateCase.getFullYear() ); + new TestCase( SECTION, DateString+".getMonth()", LocalDate.month, DateCase.getMonth() ); + new TestCase( SECTION, DateString+".getDate()", LocalDate.date, DateCase.getDate() ); + new TestCase( SECTION, DateString+".getDay()", LocalDate.day, DateCase.getDay() ); + new TestCase( SECTION, DateString+".getHours()", LocalDate.hours, DateCase.getHours() ); + new TestCase( SECTION, DateString+".getMinutes()", LocalDate.minutes, DateCase.getMinutes() ); + new TestCase( SECTION, DateString+".getSeconds()", LocalDate.seconds, DateCase.getSeconds() ); + new TestCase( SECTION, DateString+".getMilliseconds()", LocalDate.ms, DateCase.getMilliseconds() ); + + DateCase.toString = Object.prototype.toString; + + new TestCase( SECTION, + DateString+".toString=Object.prototype.toString;"+DateString+".toString()", + "[object Date]", + DateCase.toString() ); +} + +function MyDate() { + this.year = 0; + this.month = 0; + this.date = 0; + this.hours = 0; + this.minutes = 0; + this.seconds = 0; + this.ms = 0; +} +function LocalDateFromTime(t) { + t = LocalTime(t); + return ( MyDateFromTime(t) ); +} +function UTCDateFromTime(t) { + return ( MyDateFromTime(t) ); +} +function MyDateFromTime( t ) { + var d = new MyDate(); + d.year = YearFromTime(t); + d.month = MonthFromTime(t); + d.date = DateFromTime(t); + d.hours = HourFromTime(t); + d.minutes = MinFromTime(t); + d.seconds = SecFromTime(t); + d.ms = msFromTime(t); + + d.time = MakeTime( d.hours, d.minutes, d.seconds, d.ms ); + d.value = TimeClip( MakeDate( MakeDay( d.year, d.month, d.date ), d.time ) ); + d.day = WeekDay( d.value ); + + return (d); +} +function SetUTCFullYear( t, year, mon, date ) { + var T = ( t != t ) ? 0 : t; + var YEAR = Number(year); + var MONTH = ( mon == void 0 ) ? MonthFromTime(T) : Number( mon ); + var DATE = ( date == void 0 ) ? DateFromTime(T) : Number( date ); + var DAY = MakeDay( YEAR, MONTH, DATE ); + + return ( TimeClip(MakeDate(DAY, TimeWithinDay(T))) ); +} diff --git a/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.37-3.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.37-3.js new file mode 100644 index 0000000000..d256511459 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.37-3.js @@ -0,0 +1,164 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.9.5.37-3.js'; + +/** + File Name: 15.9.5.37-1.js + ECMA Section: 15.9.5.37 Date.prototype.setUTCFullYear(year [, mon [, date ]] ) + Description: + + If mon is not specified, this behaves as if mon were specified with the + value getUTCMonth( ). If date is not specified, this behaves as if date + were specified with the value getUTCDate( ). + + 1. Let t be this time value; but if this time value is NaN, let t be +0. + 2. Call ToNumber(year). + 3. If mon is not specified, compute MonthFromTime(t); otherwise, call + ToNumber(mon). + 4. If date is not specified, compute DateFromTime(t); otherwise, call + ToNumber(date). + 5. Compute MakeDay(Result(2), Result(3), Result(4)). + 6. Compute MakeDate(Result(5), TimeWithinDay(t)). + 7. Set the [[Value]] property of the this value to TimeClip(Result(6)). + 8. Return the value of the [[Value]] property of the this value. + + Author: christine@netscape.com + Date: 12 november 1997 + + Added some Year 2000 test cases. +*/ +var SECTION = "15.9.5.37-1"; +var VERSION = "ECMA_1"; +startTest(); + +writeHeaderToLog( SECTION + " Date.prototype.setUTCFullYear(year [, mon [, date ]] )"); + + +// Dates around 29 February 2000 + +var UTC_FEB_29_1972 = TIME_1970 + TimeInYear(1970) + TimeInYear(1971) + + 31*msPerDay + 28*msPerDay; + +var PST_FEB_29_1972 = UTC_FEB_29_1972 - TZ_DIFF * msPerHour; + +addNewTestCase( "TDATE = new Date("+UTC_FEB_29_1972+"); "+ + "TDATE.setUTCFullYear(2000);TDATE", + UTCDateFromTime(SetUTCFullYear(UTC_FEB_29_1972,2000)), + LocalDateFromTime(SetUTCFullYear(UTC_FEB_29_1972,2000)) ); + +addNewTestCase( "TDATE = new Date("+PST_FEB_29_1972+"); "+ + "TDATE.setUTCFullYear(2000);TDATE", + UTCDateFromTime(SetUTCFullYear(PST_FEB_29_1972,2000)), + LocalDateFromTime(SetUTCFullYear(PST_FEB_29_1972,2000)) ); + +test(); + +function addNewTestCase( DateString, UTCDate, LocalDate) { + DateCase = eval( DateString ); + + new TestCase( SECTION, DateString+".getTime()", UTCDate.value, DateCase.getTime() ); + new TestCase( SECTION, DateString+".valueOf()", UTCDate.value, DateCase.valueOf() ); + + new TestCase( SECTION, DateString+".getUTCFullYear()", UTCDate.year, DateCase.getUTCFullYear() ); + new TestCase( SECTION, DateString+".getUTCMonth()", UTCDate.month, DateCase.getUTCMonth() ); + new TestCase( SECTION, DateString+".getUTCDate()", UTCDate.date, DateCase.getUTCDate() ); + new TestCase( SECTION, DateString+".getUTCDay()", UTCDate.day, DateCase.getUTCDay() ); + new TestCase( SECTION, DateString+".getUTCHours()", UTCDate.hours, DateCase.getUTCHours() ); + new TestCase( SECTION, DateString+".getUTCMinutes()", UTCDate.minutes,DateCase.getUTCMinutes() ); + new TestCase( SECTION, DateString+".getUTCSeconds()", UTCDate.seconds,DateCase.getUTCSeconds() ); + new TestCase( SECTION, DateString+".getUTCMilliseconds()", UTCDate.ms, DateCase.getUTCMilliseconds() ); + + new TestCase( SECTION, DateString+".getFullYear()", LocalDate.year, DateCase.getFullYear() ); + new TestCase( SECTION, DateString+".getMonth()", LocalDate.month, DateCase.getMonth() ); + new TestCase( SECTION, DateString+".getDate()", LocalDate.date, DateCase.getDate() ); + new TestCase( SECTION, DateString+".getDay()", LocalDate.day, DateCase.getDay() ); + new TestCase( SECTION, DateString+".getHours()", LocalDate.hours, DateCase.getHours() ); + new TestCase( SECTION, DateString+".getMinutes()", LocalDate.minutes, DateCase.getMinutes() ); + new TestCase( SECTION, DateString+".getSeconds()", LocalDate.seconds, DateCase.getSeconds() ); + new TestCase( SECTION, DateString+".getMilliseconds()", LocalDate.ms, DateCase.getMilliseconds() ); + + DateCase.toString = Object.prototype.toString; + + new TestCase( SECTION, + DateString+".toString=Object.prototype.toString;"+DateString+".toString()", + "[object Date]", + DateCase.toString() ); +} + +function MyDate() { + this.year = 0; + this.month = 0; + this.date = 0; + this.hours = 0; + this.minutes = 0; + this.seconds = 0; + this.ms = 0; +} +function LocalDateFromTime(t) { + t = LocalTime(t); + return ( MyDateFromTime(t) ); +} +function UTCDateFromTime(t) { + return ( MyDateFromTime(t) ); +} +function MyDateFromTime( t ) { + var d = new MyDate(); + d.year = YearFromTime(t); + d.month = MonthFromTime(t); + d.date = DateFromTime(t); + d.hours = HourFromTime(t); + d.minutes = MinFromTime(t); + d.seconds = SecFromTime(t); + d.ms = msFromTime(t); + + d.time = MakeTime( d.hours, d.minutes, d.seconds, d.ms ); + d.value = TimeClip( MakeDate( MakeDay( d.year, d.month, d.date ), d.time ) ); + d.day = WeekDay( d.value ); + + return (d); +} +function SetUTCFullYear( t, year, mon, date ) { + var T = ( t != t ) ? 0 : t; + var YEAR = Number(year); + var MONTH = ( mon == void 0 ) ? MonthFromTime(T) : Number( mon ); + var DATE = ( date == void 0 ) ? DateFromTime(T) : Number( date ); + var DAY = MakeDay( YEAR, MONTH, DATE ); + + return ( TimeClip(MakeDate(DAY, TimeWithinDay(T))) ); +} diff --git a/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.37-4.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.37-4.js new file mode 100644 index 0000000000..017afd6389 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.37-4.js @@ -0,0 +1,163 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.9.5.37-4.js'; + +/** + File Name: 15.9.5.37-1.js + ECMA Section: 15.9.5.37 Date.prototype.setUTCFullYear(year [, mon [, date ]] ) + Description: + + If mon is not specified, this behaves as if mon were specified with the + value getUTCMonth( ). If date is not specified, this behaves as if date + were specified with the value getUTCDate( ). + + 1. Let t be this time value; but if this time value is NaN, let t be +0. + 2. Call ToNumber(year). + 3. If mon is not specified, compute MonthFromTime(t); otherwise, call + ToNumber(mon). + 4. If date is not specified, compute DateFromTime(t); otherwise, call + ToNumber(date). + 5. Compute MakeDay(Result(2), Result(3), Result(4)). + 6. Compute MakeDate(Result(5), TimeWithinDay(t)). + 7. Set the [[Value]] property of the this value to TimeClip(Result(6)). + 8. Return the value of the [[Value]] property of the this value. + + Author: christine@netscape.com + Date: 12 november 1997 + + Added some Year 2000 test cases. +*/ +var SECTION = "15.9.5.37-1"; +var VERSION = "ECMA_1"; +startTest(); + +writeHeaderToLog( SECTION + " Date.prototype.setUTCFullYear(year [, mon [, date ]] )"); + +// Dates around 2005 + +addNewTestCase( "TDATE = new Date(0); TDATE.setUTCFullYear(2005);TDATE", + UTCDateFromTime(SetUTCFullYear(0,2005)), + LocalDateFromTime(SetUTCFullYear(0,2005)) ); + +addNewTestCase( "TDATE = new Date(0); TDATE.setUTCFullYear(2004);TDATE", + UTCDateFromTime(SetUTCFullYear(0,2004)), + LocalDateFromTime(SetUTCFullYear(0,2004)) ); + +addNewTestCase( "TDATE = new Date(0); TDATE.setUTCFullYear(2006);TDATE", + UTCDateFromTime(SetUTCFullYear(0,2006)), + LocalDateFromTime(SetUTCFullYear(0,2006)) ); + +test(); + +function addNewTestCase( DateString, UTCDate, LocalDate) { + DateCase = eval( DateString ); + + +// fixed_year = ( ExpectDate.year >=1900 || ExpectDate.year < 2000 ) ? ExpectDate.year - 1900 : ExpectDate.year; + + new TestCase( SECTION, DateString+".getTime()", UTCDate.value, DateCase.getTime() ); + new TestCase( SECTION, DateString+".valueOf()", UTCDate.value, DateCase.valueOf() ); + + new TestCase( SECTION, DateString+".getUTCFullYear()", UTCDate.year, DateCase.getUTCFullYear() ); + new TestCase( SECTION, DateString+".getUTCMonth()", UTCDate.month, DateCase.getUTCMonth() ); + new TestCase( SECTION, DateString+".getUTCDate()", UTCDate.date, DateCase.getUTCDate() ); + new TestCase( SECTION, DateString+".getUTCDay()", UTCDate.day, DateCase.getUTCDay() ); + new TestCase( SECTION, DateString+".getUTCHours()", UTCDate.hours, DateCase.getUTCHours() ); + new TestCase( SECTION, DateString+".getUTCMinutes()", UTCDate.minutes,DateCase.getUTCMinutes() ); + new TestCase( SECTION, DateString+".getUTCSeconds()", UTCDate.seconds,DateCase.getUTCSeconds() ); + new TestCase( SECTION, DateString+".getUTCMilliseconds()", UTCDate.ms, DateCase.getUTCMilliseconds() ); + + new TestCase( SECTION, DateString+".getFullYear()", LocalDate.year, DateCase.getFullYear() ); + new TestCase( SECTION, DateString+".getMonth()", LocalDate.month, DateCase.getMonth() ); + new TestCase( SECTION, DateString+".getDate()", LocalDate.date, DateCase.getDate() ); + new TestCase( SECTION, DateString+".getDay()", LocalDate.day, DateCase.getDay() ); + new TestCase( SECTION, DateString+".getHours()", LocalDate.hours, DateCase.getHours() ); + new TestCase( SECTION, DateString+".getMinutes()", LocalDate.minutes, DateCase.getMinutes() ); + new TestCase( SECTION, DateString+".getSeconds()", LocalDate.seconds, DateCase.getSeconds() ); + new TestCase( SECTION, DateString+".getMilliseconds()", LocalDate.ms, DateCase.getMilliseconds() ); + + DateCase.toString = Object.prototype.toString; + + new TestCase( SECTION, + DateString+".toString=Object.prototype.toString;"+DateString+".toString()", + "[object Date]", + DateCase.toString() ); +} + +function MyDate() { + this.year = 0; + this.month = 0; + this.date = 0; + this.hours = 0; + this.minutes = 0; + this.seconds = 0; + this.ms = 0; +} +function LocalDateFromTime(t) { + t = LocalTime(t); + return ( MyDateFromTime(t) ); +} +function UTCDateFromTime(t) { + return ( MyDateFromTime(t) ); +} +function MyDateFromTime( t ) { + var d = new MyDate(); + d.year = YearFromTime(t); + d.month = MonthFromTime(t); + d.date = DateFromTime(t); + d.hours = HourFromTime(t); + d.minutes = MinFromTime(t); + d.seconds = SecFromTime(t); + d.ms = msFromTime(t); + + d.time = MakeTime( d.hours, d.minutes, d.seconds, d.ms ); + d.value = TimeClip( MakeDate( MakeDay( d.year, d.month, d.date ), d.time ) ); + d.day = WeekDay( d.value ); + + return (d); +} +function SetUTCFullYear( t, year, mon, date ) { + var T = ( t != t ) ? 0 : t; + var YEAR = Number(year); + var MONTH = ( mon == void 0 ) ? MonthFromTime(T) : Number( mon ); + var DATE = ( date == void 0 ) ? DateFromTime(T) : Number( date ); + var DAY = MakeDay( YEAR, MONTH, DATE ); + + return ( TimeClip(MakeDate(DAY, TimeWithinDay(T))) ); +} diff --git a/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.37-5.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.37-5.js new file mode 100644 index 0000000000..046f3095df --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.37-5.js @@ -0,0 +1,159 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.9.5.37-5.js'; + +/** + File Name: 15.9.5.37-1.js + ECMA Section: 15.9.5.37 Date.prototype.setUTCFullYear(year [, mon [, date ]] ) + Description: + + If mon is not specified, this behaves as if mon were specified with the + value getUTCMonth( ). If date is not specified, this behaves as if date + were specified with the value getUTCDate( ). + + 1. Let t be this time value; but if this time value is NaN, let t be +0. + 2. Call ToNumber(year). + 3. If mon is not specified, compute MonthFromTime(t); otherwise, call + ToNumber(mon). + 4. If date is not specified, compute DateFromTime(t); otherwise, call + ToNumber(date). + 5. Compute MakeDay(Result(2), Result(3), Result(4)). + 6. Compute MakeDate(Result(5), TimeWithinDay(t)). + 7. Set the [[Value]] property of the this value to TimeClip(Result(6)). + 8. Return the value of the [[Value]] property of the this value. + + Author: christine@netscape.com + Date: 12 november 1997 + + Added some Year 2000 test cases. +*/ +var SECTION = "15.9.5.37-1"; +var VERSION = "ECMA_1"; +startTest(); + +writeHeaderToLog( SECTION + " Date.prototype.setUTCFullYear(year [, mon [, date ]] )"); + +// Dates around 1900 +addNewTestCase( "TDATE = new Date(0); TDATE.setUTCFullYear(1900);TDATE", + UTCDateFromTime(SetUTCFullYear(0,1900)), + LocalDateFromTime(SetUTCFullYear(0,1900)) ); + +addNewTestCase( "TDATE = new Date(0); TDATE.setUTCFullYear(1899);TDATE", + UTCDateFromTime(SetUTCFullYear(0,1899)), + LocalDateFromTime(SetUTCFullYear(0,1899)) ); + +addNewTestCase( "TDATE = new Date(0); TDATE.setUTCFullYear(1901);TDATE", + UTCDateFromTime(SetUTCFullYear(0,1901)), + LocalDateFromTime(SetUTCFullYear(0,1901)) ); + +test(); + +function addNewTestCase( DateString, UTCDate, LocalDate) { + DateCase = eval( DateString ); + + new TestCase( SECTION, DateString+".getTime()", UTCDate.value, DateCase.getTime() ); + new TestCase( SECTION, DateString+".valueOf()", UTCDate.value, DateCase.valueOf() ); + + new TestCase( SECTION, DateString+".getUTCFullYear()", UTCDate.year, DateCase.getUTCFullYear() ); + new TestCase( SECTION, DateString+".getUTCMonth()", UTCDate.month, DateCase.getUTCMonth() ); + new TestCase( SECTION, DateString+".getUTCDate()", UTCDate.date, DateCase.getUTCDate() ); + new TestCase( SECTION, DateString+".getUTCDay()", UTCDate.day, DateCase.getUTCDay() ); + new TestCase( SECTION, DateString+".getUTCHours()", UTCDate.hours, DateCase.getUTCHours() ); + new TestCase( SECTION, DateString+".getUTCMinutes()", UTCDate.minutes,DateCase.getUTCMinutes() ); + new TestCase( SECTION, DateString+".getUTCSeconds()", UTCDate.seconds,DateCase.getUTCSeconds() ); + new TestCase( SECTION, DateString+".getUTCMilliseconds()", UTCDate.ms, DateCase.getUTCMilliseconds() ); + + new TestCase( SECTION, DateString+".getFullYear()", LocalDate.year, DateCase.getFullYear() ); + new TestCase( SECTION, DateString+".getMonth()", LocalDate.month, DateCase.getMonth() ); + new TestCase( SECTION, DateString+".getDate()", LocalDate.date, DateCase.getDate() ); + new TestCase( SECTION, DateString+".getDay()", LocalDate.day, DateCase.getDay() ); + new TestCase( SECTION, DateString+".getHours()", LocalDate.hours, DateCase.getHours() ); + new TestCase( SECTION, DateString+".getMinutes()", LocalDate.minutes, DateCase.getMinutes() ); + new TestCase( SECTION, DateString+".getSeconds()", LocalDate.seconds, DateCase.getSeconds() ); + new TestCase( SECTION, DateString+".getMilliseconds()", LocalDate.ms, DateCase.getMilliseconds() ); + + DateCase.toString = Object.prototype.toString; + + new TestCase( SECTION, + DateString+".toString=Object.prototype.toString;"+DateString+".toString()", + "[object Date]", + DateCase.toString() ); +} + +function MyDate() { + this.year = 0; + this.month = 0; + this.date = 0; + this.hours = 0; + this.minutes = 0; + this.seconds = 0; + this.ms = 0; +} +function LocalDateFromTime(t) { + t = LocalTime(t); + return ( MyDateFromTime(t) ); +} +function UTCDateFromTime(t) { + return ( MyDateFromTime(t) ); +} +function MyDateFromTime( t ) { + var d = new MyDate(); + d.year = YearFromTime(t); + d.month = MonthFromTime(t); + d.date = DateFromTime(t); + d.hours = HourFromTime(t); + d.minutes = MinFromTime(t); + d.seconds = SecFromTime(t); + d.ms = msFromTime(t); + + d.time = MakeTime( d.hours, d.minutes, d.seconds, d.ms ); + d.value = TimeClip( MakeDate( MakeDay( d.year, d.month, d.date ), d.time ) ); + d.day = WeekDay( d.value ); + + return (d); +} +function SetUTCFullYear( t, year, mon, date ) { + var T = ( t != t ) ? 0 : t; + var YEAR = Number(year); + var MONTH = ( mon == void 0 ) ? MonthFromTime(T) : Number( mon ); + var DATE = ( date == void 0 ) ? DateFromTime(T) : Number( date ); + var DAY = MakeDay( YEAR, MONTH, DATE ); + + return ( TimeClip(MakeDate(DAY, TimeWithinDay(T))) ); +} diff --git a/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.4-1.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.4-1.js new file mode 100644 index 0000000000..6ad06931f8 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.4-1.js @@ -0,0 +1,93 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.9.5.4-1.js'; + +/** + File Name: 15.9.5.4-1.js + ECMA Section: 15.9.5.4-1 Date.prototype.getTime + Description: + + 1. If the this value is not an object whose [[Class]] property is "Date", + generate a runtime error. + 2. Return this time value. + Author: christine@netscape.com + Date: 12 november 1997 +*/ +var SECTION = "15.9.5.4-1"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Date.prototype.getTime"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +addTestCase( TIME_NOW ); +addTestCase( TIME_1970 ); +addTestCase( TIME_1900 ); +addTestCase( TIME_2000 ); +addTestCase( UTC_FEB_29_2000 ); +addTestCase( UTC_JAN_1_2005 ); + +test(); + +function addTestCase( t ) { + new TestCase( SECTION, + "(new Date("+t+").getTime()", + t, + (new Date(t)).getTime() ); + + new TestCase( SECTION, + "(new Date("+(t+1)+").getTime()", + t+1, + (new Date(t+1)).getTime() ); + + new TestCase( SECTION, + "(new Date("+(t-1)+").getTime()", + t-1, + (new Date(t-1)).getTime() ); + + new TestCase( SECTION, + "(new Date("+(t-TZ_ADJUST)+").getTime()", + t-TZ_ADJUST, + (new Date(t-TZ_ADJUST)).getTime() ); + + new TestCase( SECTION, + "(new Date("+(t+TZ_ADJUST)+").getTime()", + t+TZ_ADJUST, + (new Date(t+TZ_ADJUST)).getTime() ); +} diff --git a/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.4-2-n.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.4-2-n.js new file mode 100644 index 0000000000..1cd98dd801 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.4-2-n.js @@ -0,0 +1,76 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.9.5.4-2-n.js'; + +/** + File Name: 15.9.5.4-2-n.js + ECMA Section: 15.9.5.4-1 Date.prototype.getTime + Description: + + 1. If the this value is not an object whose [[Class]] property is "Date", + generate a runtime error. + 2. Return this time value. + Author: christine@netscape.com + Date: 12 november 1997 +*/ + + +var SECTION = "15.9.5.4-2-n"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Date.prototype.getTime"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +var MYDATE = new MyDate( TIME_2000 ); + +DESCRIPTION = "MYDATE.getTime()"; +EXPECTED = "error"; + +new TestCase( SECTION, + "MYDATE.getTime()", + "error", + eval("MYDATE.getTime()") ); + +test(); + +function MyDate( value ) { + this.value = value; + this.getTime = Date.prototype.getTime; +} diff --git a/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.5.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.5.js new file mode 100644 index 0000000000..f0136b00ad --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.5.js @@ -0,0 +1,112 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.9.5.5.js'; + +/** + File Name: 15.9.5.5.js + ECMA Section: 15.9.5.5 + Description: Date.prototype.getYear + + This function is specified here for backwards compatibility only. The + function getFullYear is much to be preferred for nearly all purposes, + because it avoids the "year 2000 problem." + + 1. Let t be this time value. + 2. If t is NaN, return NaN. + 3. Return YearFromTime(LocalTime(t)) 1900. + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + +var SECTION = "15.9.5.5"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Date.prototype.getYear()"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +addTestCase( TIME_NOW ); +addTestCase( TIME_0000 ); +addTestCase( TIME_1970 ); +addTestCase( TIME_1900 ); +addTestCase( TIME_2000 ); +addTestCase( UTC_FEB_29_2000 ); + +new TestCase( SECTION, + "(new Date(NaN)).getYear()", + NaN, + (new Date(NaN)).getYear() ); + +new TestCase( SECTION, + "Date.prototype.getYear.length", + 0, + Date.prototype.getYear.length ); + +test(); + +function addTestCase( t ) { + new TestCase( SECTION, + "(new Date("+t+")).getYear()", + GetYear(YearFromTime(LocalTime(t))), + (new Date(t)).getYear() ); + + new TestCase( SECTION, + "(new Date("+(t+1)+")).getYear()", + GetYear(YearFromTime(LocalTime(t+1))), + (new Date(t+1)).getYear() ); + + new TestCase( SECTION, + "(new Date("+(t-1)+")).getYear()", + GetYear(YearFromTime(LocalTime(t-1))), + (new Date(t-1)).getYear() ); + + new TestCase( SECTION, + "(new Date("+(t-TZ_ADJUST)+")).getYear()", + GetYear(YearFromTime(LocalTime(t-TZ_ADJUST))), + (new Date(t-TZ_ADJUST)).getYear() ); + + new TestCase( SECTION, + "(new Date("+(t+TZ_ADJUST)+")).getYear()", + GetYear(YearFromTime(LocalTime(t+TZ_ADJUST))), + (new Date(t+TZ_ADJUST)).getYear() ); +} +function GetYear( year ) { + return year - 1900; +} diff --git a/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.6.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.6.js new file mode 100644 index 0000000000..9ae804ebb9 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.6.js @@ -0,0 +1,104 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.9.5.6.js'; + +/** + File Name: 15.9.5.6.js + ECMA Section: 15.9.5.6 + Description: Date.prototype.getFullYear + + 1. Let t be this time value. + 2. If t is NaN, return NaN. + 3. Return YearFromTime(LocalTime(t)). + Author: christine@netscape.com + Date: 12 november 1997 +*/ + +var SECTION = "15.9.5.6"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Date.prototype.getFullYear()"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +addTestCase( TIME_NOW ); +addTestCase( TIME_0000 ); +addTestCase( TIME_1970 ); +addTestCase( TIME_1900 ); +addTestCase( TIME_2000 ); +addTestCase( UTC_FEB_29_2000 ); +addTestCase( UTC_JAN_1_2005 ); + +new TestCase( SECTION, + "(new Date(NaN)).getFullYear()", + NaN, + (new Date(NaN)).getFullYear() ); + +new TestCase( SECTION, + "Date.prototype.getFullYear.length", + 0, + Date.prototype.getFullYear.length ); + +test(); +function addTestCase( t ) { + new TestCase( SECTION, + "(new Date("+t+")).getFullYear()", + YearFromTime(LocalTime(t)), + (new Date(t)).getFullYear() ); + + new TestCase( SECTION, + "(new Date("+(t+1)+")).getFullYear()", + YearFromTime(LocalTime(t+1)), + (new Date(t+1)).getFullYear() ); + + new TestCase( SECTION, + "(new Date("+(t-1)+")).getFullYear()", + YearFromTime(LocalTime(t-1)), + (new Date(t-1)).getFullYear() ); + + new TestCase( SECTION, + "(new Date("+(t-TZ_ADJUST)+")).getFullYear()", + YearFromTime(LocalTime(t-TZ_ADJUST)), + (new Date(t-TZ_ADJUST)).getFullYear() ); + + new TestCase( SECTION, + "(new Date("+(t+TZ_ADJUST)+")).getFullYear()", + YearFromTime(LocalTime(t+TZ_ADJUST)), + (new Date(t+TZ_ADJUST)).getFullYear() ); +} diff --git a/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.7.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.7.js new file mode 100644 index 0000000000..c4c83a2c38 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.7.js @@ -0,0 +1,105 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.9.5.7.js'; + +/** + File Name: 15.9.5.7.js + ECMA Section: 15.9.5.7 + Description: Date.prototype.getUTCFullYear + + 1.Let t be this time value. + 2.If t is NaN, return NaN. + 3.Return YearFromTime(t). + Author: christine@netscape.com + Date: 12 november 1997 +*/ + +var SECTION = "15.9.5.7"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Date.prototype.getUTCFullYear()"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +addTestCase( TIME_NOW ); +addTestCase( TIME_0000 ); +addTestCase( TIME_1970 ); +addTestCase( TIME_1900 ); +addTestCase( TIME_2000 ); +addTestCase( UTC_FEB_29_2000 ); +addTestCase( UTC_JAN_1_2005 ); + +new TestCase( SECTION, + "(new Date(NaN)).getUTCFullYear()", + NaN, + (new Date(NaN)).getUTCFullYear() ); + +new TestCase( SECTION, + "Date.prototype.getUTCFullYear.length", + 0, + Date.prototype.getUTCFullYear.length ); + +test(); + +function addTestCase( t ) { + new TestCase( SECTION, + "(new Date("+t+")).getUTCFullYear()", + YearFromTime(t), + (new Date(t)).getUTCFullYear() ); + + new TestCase( SECTION, + "(new Date("+(t+1)+")).getUTCFullYear()", + YearFromTime(t+1), + (new Date(t+1)).getUTCFullYear() ); + + new TestCase( SECTION, + "(new Date("+(t-1)+")).getUTCFullYear()", + YearFromTime(t-1), + (new Date(t-1)).getUTCFullYear() ); + + new TestCase( SECTION, + "(new Date("+(t-TZ_ADJUST)+")).getUTCFullYear()", + YearFromTime(t-TZ_ADJUST), + (new Date(t-TZ_ADJUST)).getUTCFullYear() ); + + new TestCase( SECTION, + "(new Date("+(t+TZ_ADJUST)+")).getUTCFullYear()", + YearFromTime(t+TZ_ADJUST), + (new Date(t+TZ_ADJUST)).getUTCFullYear() ); +} diff --git a/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.8.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.8.js new file mode 100644 index 0000000000..572e293960 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.8.js @@ -0,0 +1,113 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.9.5.8.js'; + +/** + File Name: 15.9.5.8.js + ECMA Section: 15.9.5.8 + Description: Date.prototype.getMonth + + 1. Let t be this time value. + 2. If t is NaN, return NaN. + 3. Return MonthFromTime(LocalTime(t)). + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + +var SECTION = "15.9.5.8"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Date.prototype.getMonth()"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +addTestCase( TIME_NOW ); +addTestCase( TIME_0000 ); +addTestCase( TIME_1970 ); +addTestCase( TIME_1900 ); +addTestCase( TIME_2000 ); +addTestCase( UTC_FEB_29_2000 ); +addTestCase( UTC_JAN_1_2005 ); + +new TestCase( SECTION, + "(new Date(NaN)).getMonth()", + NaN, + (new Date(NaN)).getMonth() ); + +new TestCase( SECTION, + "Date.prototype.getMonth.length", + 0, + Date.prototype.getMonth.length ); +test(); + +function addTestCase( t ) { + var leap = InLeapYear(t); + + for ( var m = 0; m < 12; m++ ) { + + t += TimeInMonth(m, leap); + + new TestCase( SECTION, + "(new Date("+t+")).getMonth()", + MonthFromTime(LocalTime(t)), + (new Date(t)).getMonth() ); + + new TestCase( SECTION, + "(new Date("+(t+1)+")).getMonth()", + MonthFromTime(LocalTime(t+1)), + (new Date(t+1)).getMonth() ); + + new TestCase( SECTION, + "(new Date("+(t-1)+")).getMonth()", + MonthFromTime(LocalTime(t-1)), + (new Date(t-1)).getMonth() ); + + new TestCase( SECTION, + "(new Date("+(t-TZ_ADJUST)+")).getMonth()", + MonthFromTime(LocalTime(t-TZ_ADJUST)), + (new Date(t-TZ_ADJUST)).getMonth() ); + + new TestCase( SECTION, + "(new Date("+(t+TZ_ADJUST)+")).getMonth()", + MonthFromTime(LocalTime(t+TZ_ADJUST)), + (new Date(t+TZ_ADJUST)).getMonth() ); + + } +} diff --git a/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.9.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.9.js new file mode 100644 index 0000000000..9f0fc124af --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.9.js @@ -0,0 +1,113 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.9.5.9.js'; + +/** + File Name: 15.9.5.9.js + ECMA Section: 15.9.5.9 + Description: Date.prototype.getUTCMonth + + 1. Let t be this time value. + 2. If t is NaN, return NaN. + 3. Return MonthFromTime(t). + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + +var SECTION = "15.9.5.9"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Date.prototype.getUTCMonth()"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +addTestCase( TIME_NOW ); +addTestCase( TIME_0000 ); +addTestCase( TIME_1970 ); +addTestCase( TIME_1900 ); +addTestCase( TIME_2000 ); +addTestCase( UTC_FEB_29_2000 ); +addTestCase( UTC_JAN_1_2005 ); + +new TestCase( SECTION, + "(new Date(NaN)).getUTCMonth()", + NaN, + (new Date(NaN)).getUTCMonth() ); + +new TestCase( SECTION, + "Date.prototype.getUTCMonth.length", + 0, + Date.prototype.getUTCMonth.length ); +test(); + +function addTestCase( t ) { + var leap = InLeapYear(t); + + for ( var m = 0; m < 12; m++ ) { + + t += TimeInMonth(m, leap); + + new TestCase( SECTION, + "(new Date("+t+")).getUTCMonth()", + MonthFromTime(t), + (new Date(t)).getUTCMonth() ); + + new TestCase( SECTION, + "(new Date("+(t+1)+")).getUTCMonth()", + MonthFromTime(t+1), + (new Date(t+1)).getUTCMonth() ); + + new TestCase( SECTION, + "(new Date("+(t-1)+")).getUTCMonth()", + MonthFromTime(t-1), + (new Date(t-1)).getUTCMonth() ); + + new TestCase( SECTION, + "(new Date("+(t-TZ_ADJUST)+")).getUTCMonth()", + MonthFromTime(t-TZ_ADJUST), + (new Date(t-TZ_ADJUST)).getUTCMonth() ); + + new TestCase( SECTION, + "(new Date("+(t+TZ_ADJUST)+")).getUTCMonth()", + MonthFromTime(t+TZ_ADJUST), + (new Date(t+TZ_ADJUST)).getUTCMonth() ); + + } +} diff --git a/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.js new file mode 100644 index 0000000000..9e3bd94080 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.js @@ -0,0 +1,83 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.9.5.js'; + +/** + File Name: 15.9.5.js + ECMA Section: 15.9.5 Properties of the Date prototype object + Description: + + The Date prototype object is itself a Date object (its [[Class]] is + "Date") whose value is NaN. + + The value of the internal [[Prototype]] property of the Date prototype + object is the Object prototype object (15.2.3.1). + + In following descriptions of functions that are properties of the Date + prototype object, the phrase "this Date object" refers to the object that + is the this value for the invocation of the function; it is an error if + this does not refer to an object for which the value of the internal + [[Class]] property is "Date". Also, the phrase "this time value" refers + to the number value for the time represented by this Date object, that is, + the value of the internal [[Value]] property of this Date object. + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + +var SECTION = "15.9.5"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Properties of the Date Prototype Object"; + +writeHeaderToLog( SECTION + " "+ TITLE); + + +Date.prototype.getClass = Object.prototype.toString; + +new TestCase( SECTION, + "Date.prototype.getClass", + "[object Date]", + Date.prototype.getClass() ); +new TestCase( SECTION, + "Date.prototype.valueOf()", + NaN, + Date.prototype.valueOf() ); +test(); + diff --git a/tests/auto/qml/parserstress/tests/ecma/Date/browser.js b/tests/auto/qml/parserstress/tests/ecma/Date/browser.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/auto/qml/parserstress/tests/ecma/Date/shell.js b/tests/auto/qml/parserstress/tests/ecma/Date/shell.js new file mode 100644 index 0000000000..0beb78e064 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Date/shell.js @@ -0,0 +1 @@ +gTestsubsuite = 'Date'; diff --git a/tests/auto/qml/parserstress/tests/ecma/ExecutionContexts/10.1.3-1.js b/tests/auto/qml/parserstress/tests/ecma/ExecutionContexts/10.1.3-1.js new file mode 100644 index 0000000000..699296d6b1 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/ExecutionContexts/10.1.3-1.js @@ -0,0 +1,107 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '10.1.3-1.js'; + +/** + File Name: 10.1.3-1.js + ECMA Section: 10.1.3 + Description: + + For each formal parameter, as defined in the FormalParameterList, create + a property of the variable object whose name is the Identifier and whose + attributes are determined by the type of code. The values of the + parameters are supplied by the caller. If the caller supplies fewer + parameter values than there are formal parameters, the extra formal + parameters have value undefined. If two or more formal parameters share + the same name, hence the same property, the corresponding property is + given the value that was supplied for the last parameter with this name. + If the value of this last parameter was not supplied by the caller, + the value of the corresponding property is undefined. + + + http://scopus.mcom.com/bugsplat/show_bug.cgi?id=104191 + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + +var SECTION = "10.1.3-1"; +var VERSION = "ECMA_1"; +var TITLE = "Variable Instantiation: Formal Parameters"; +var BUGNUMBER="104191"; +startTest(); + +writeHeaderToLog( SECTION + " "+ TITLE); + +var myfun1 = new Function( "a", "a", "return a" ); +var myfun2 = new Function( "a", "b", "a", "return a" ); + +function myfun3(a, b, a) { + return a; +} + +// myfun1, myfun2, myfun3 tostring + + +new TestCase( + SECTION, + String(myfun2) +"; myfun2(2,4,8)", + 8, + myfun2(2,4,8) ); + +new TestCase( + SECTION, + "myfun2(2,4)", + void 0, + myfun2(2,4)); + +new TestCase( + SECTION, + String(myfun3) +"; myfun3(2,4,8)", + 8, + myfun3(2,4,8) ); + +new TestCase( + SECTION, + "myfun3(2,4)", + void 0, + myfun3(2,4) ); + +test(); + diff --git a/tests/auto/qml/parserstress/tests/ecma/ExecutionContexts/10.1.3-2.js b/tests/auto/qml/parserstress/tests/ecma/ExecutionContexts/10.1.3-2.js new file mode 100755 index 0000000000..3762842461 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/ExecutionContexts/10.1.3-2.js @@ -0,0 +1,73 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): mozilla@florian.loitsch.com + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '10.1.3-2.js'; + +/** + File Name: 10.1.3-1.js + ECMA Section: 10.1.3 + Description: + + Author: mozilla@florian.loitsch.com + Date: 27 July 2005 +*/ + +var SECTION = "10.1.3-2"; +var VERSION = "ECMA_1"; +var TITLE = "Variable Instantiation: Function Declarations"; +var BUGNUMBER="299639"; +startTest(); + +writeHeaderToLog( SECTION + " "+ TITLE); + +function f(g) +{ + function g() { + return "g"; + }; + return g; +} + +new TestCase( + SECTION, + "typeof f(\"parameter\")", + "function", + typeof f("parameter") ); + +test(); + diff --git a/tests/auto/qml/parserstress/tests/ecma/ExecutionContexts/10.1.3.js b/tests/auto/qml/parserstress/tests/ecma/ExecutionContexts/10.1.3.js new file mode 100644 index 0000000000..fd466de210 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/ExecutionContexts/10.1.3.js @@ -0,0 +1,170 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '10.1.3.js'; + +/** + File Name: 10.1.3.js + ECMA Section: 10.1.3.js Variable Instantiation + Description: + Author: christine@netscape.com + Date: 11 september 1997 +*/ + +var SECTION = "10.1.3"; +var VERSION = "ECMA_1"; +var TITLE = "Variable instantiation"; +var BUGNUMBER = "20256"; +startTest(); + +writeHeaderToLog( SECTION + " "+ TITLE); + + +// overriding a variable or function name with a function should succeed + +new TestCase(SECTION, + "function t() { return \"first\" };" + + "function t() { return \"second\" };t() ", + "second", + eval("function t() { return \"first\" };" + + "function t() { return \"second\" };t()")); + + +new TestCase(SECTION, + "var t; function t(){}; typeof(t)", + "function", + eval("var t; function t(){}; typeof(t)")); + + +// formal parameter tests + +new TestCase(SECTION, + "function t1(a,b) { return b; }; t1( 4 );", + void 0, + eval("function t1(a,b) { return b; }; t1( 4 );") ); + +new TestCase(SECTION, + "function t1(a,b) { return a; }; t1(4);", + 4, + eval("function t1(a,b) { return a; }; t1(4)")); + +new TestCase(SECTION, + "function t1(a,b) { return a; }; t1();", + void 0, + eval("function t1(a,b) { return a; }; t1()")); + +new TestCase(SECTION, + "function t1(a,b) { return a; }; t1(1,2,4);", + 1, + eval("function t1(a,b) { return a; }; t1(1,2,4)")); +/* + +new TestCase(SECTION, "function t1(a,a) { return a; }; t1( 4 );", +void 0, +eval("function t1(a,a) { return a; }; t1( 4 )")); + +new TestCase(SECTION, +"function t1(a,a) { return a; }; t1( 1,2 );", +2, +eval("function t1(a,a) { return a; }; t1( 1,2 )")); +*/ +// variable declarations + +new TestCase(SECTION, + "function t1(a,b) { return a; }; t1( false, true );", + false, + eval("function t1(a,b) { return a; }; t1( false, true );")); + +new TestCase(SECTION, + "function t1(a,b) { return b; }; t1( false, true );", + true, + eval("function t1(a,b) { return b; }; t1( false, true );")); + +new TestCase(SECTION, + "function t1(a,b) { return a+b; }; t1( 4, 2 );", + 6, + eval("function t1(a,b) { return a+b; }; t1( 4, 2 );")); + +new TestCase(SECTION, + "function t1(a,b) { return a+b; }; t1( 4 );", + Number.NaN, + eval("function t1(a,b) { return a+b; }; t1( 4 );")); + +// overriding a function name with a variable should fail + +new TestCase(SECTION, + "function t() { return 'function' };" + + "var t = 'variable'; typeof(t)", + "string", + eval("function t() { return 'function' };" + + "var t = 'variable'; typeof(t)")); + +// function as a constructor + +new TestCase(SECTION, + "function t1(a,b) { var a = b; return a; } t1(1,3);", + 3, + eval("function t1(a, b){ var a = b; return a;}; t1(1,3)")); + +new TestCase(SECTION, + "function t2(a,b) { this.a = b; } x = new t2(1,3); x.a", + 3, + eval("function t2(a,b) { this.a = b; };" + + "x = new t2(1,3); x.a")); + +new TestCase(SECTION, + "function t2(a,b) { this.a = a; } x = new t2(1,3); x.a", + 1, + eval("function t2(a,b) { this.a = a; };" + + "x = new t2(1,3); x.a")); + +new TestCase(SECTION, + "function t2(a,b) { this.a = b; this.b = a; } " + + "x = new t2(1,3);x.a;", + 3, + eval("function t2(a,b) { this.a = b; this.b = a; };" + + "x = new t2(1,3);x.a;")); + +new TestCase(SECTION, + "function t2(a,b) { this.a = b; this.b = a; }" + + "x = new t2(1,3);x.b;", + 1, + eval("function t2(a,b) { this.a = b; this.b = a; };" + + "x = new t2(1,3);x.b;") ); + +test(); diff --git a/tests/auto/qml/parserstress/tests/ecma/ExecutionContexts/10.1.4-1.js b/tests/auto/qml/parserstress/tests/ecma/ExecutionContexts/10.1.4-1.js new file mode 100644 index 0000000000..ec49f20596 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/ExecutionContexts/10.1.4-1.js @@ -0,0 +1,111 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '10.1.4-1.js'; + +/** + File Name: 10.1.4-1.js + ECMA Section: 10.1.4 Scope Chain and Identifier Resolution + Description: + Every execution context has associated with it a scope chain. This is + logically a list of objects that are searched when binding an Identifier. + When control enters an execution context, the scope chain is created and + is populated with an initial set of objects, depending on the type of + code. When control leaves the execution context, the scope chain is + destroyed. + + During execution, the scope chain of the execution context is affected + only by WithStatement. When execution enters a with block, the object + specified in the with statement is added to the front of the scope chain. + When execution leaves a with block, whether normally or via a break or + continue statement, the object is removed from the scope chain. The object + being removed will always be the first object in the scope chain. + + During execution, the syntactic production PrimaryExpression : Identifier + is evaluated using the following algorithm: + + 1. Get the next object in the scope chain. If there isn't one, go to step 5. + 2. Call the [[HasProperty]] method of Result(l), passing the Identifier as + the property. + 3. If Result(2) is true, return a value of type Reference whose base object + is Result(l) and whose property name is the Identifier. + 4. Go to step 1. + 5. Return a value of type Reference whose base object is null and whose + property name is the Identifier. + The result of binding an identifier is always a value of type Reference with + its member name component equal to the identifier string. + Author: christine@netscape.com + Date: 12 november 1997 +*/ +var SECTION = "10.1.4-1"; +var VERSION = "ECMA_1"; +startTest(); + +writeHeaderToLog( SECTION + " Scope Chain and Identifier Resolution"); + +new TestCase( "SECTION", "with MyObject, eval should return square of " ); + +test(); + +function test() { + for ( gTc=0; gTc < gTestcases.length; gTc++ ) { + + var MYOBJECT = new MyObject(); + var INPUT = 2; + gTestcases[gTc].description += "( " + INPUT +" )" ; + + with ( MYOBJECT ) { + gTestcases[gTc].actual = eval( INPUT ); + gTestcases[gTc].expect = Math.pow(INPUT,2); + } + + gTestcases[gTc].passed = writeTestCaseResult( + gTestcases[gTc].expect, + gTestcases[gTc].actual, + gTestcases[gTc].description +" = "+ + gTestcases[gTc].actual ); + + gTestcases[gTc].reason += ( gTestcases[gTc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( gTestcases ); +} + +function MyObject() { + this.eval = new Function( "x", "return(Math.pow(Number(x),2))" ); +} diff --git a/tests/auto/qml/parserstress/tests/ecma/ExecutionContexts/10.1.4-10.js b/tests/auto/qml/parserstress/tests/ecma/ExecutionContexts/10.1.4-10.js new file mode 100644 index 0000000000..218031c83f --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/ExecutionContexts/10.1.4-10.js @@ -0,0 +1,105 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '10.1.4-10.js'; + +/** + File Name: 10.1.4-10.js + ECMA Section: 10.1.4 Scope Chain and Identifier Resolution + Description: + Every execution context has associated with it a scope chain. This is + logically a list of objects that are searched when binding an Identifier. + When control enters an execution context, the scope chain is created and + is populated with an initial set of objects, depending on the type of + code. When control leaves the execution context, the scope chain is + destroyed. + + During execution, the scope chain of the execution context is affected + only by WithStatement. When execution enters a with block, the object + specified in the with statement is added to the front of the scope chain. + When execution leaves a with block, whether normally or via a break or + continue statement, the object is removed from the scope chain. The object + being removed will always be the first object in the scope chain. + + During execution, the syntactic production PrimaryExpression : Identifier + is evaluated using the following algorithm: + + 1. Get the next object in the scope chain. If there isn't one, go to step 5. + 2. Call the [[HasProperty]] method of Result(l), passing the Identifier as + the property. + 3. If Result(2) is true, return a value of type Reference whose base object + is Result(l) and whose property name is the Identifier. + 4. Go to step 1. + 5. Return a value of type Reference whose base object is null and whose + property name is the Identifier. + The result of binding an identifier is always a value of type Reference with + its member name component equal to the identifier string. + Author: christine@netscape.com + Date: 12 november 1997 +*/ +var SECTION = "10.1.4-10"; +var VERSION = "ECMA_1"; +startTest(); + +writeHeaderToLog( SECTION + " Scope Chain and Identifier Resolution"); + +new TestCase( "SECTION", "MYOBJECT.toString()" ); + +test(); + +function test() { + for ( gTc=0; gTc < gTestcases.length; gTc++ ) { + var VALUE = 12345; + var MYOBJECT = new Number( VALUE ); + + with ( MYOBJECT ) { + gTestcases[gTc].actual = toString(); + gTestcases[gTc].expect = String(VALUE); + } + + gTestcases[gTc].passed = writeTestCaseResult( + gTestcases[gTc].expect, + gTestcases[gTc].actual, + gTestcases[gTc].description +" = "+ + gTestcases[gTc].actual ); + + gTestcases[gTc].reason += ( gTestcases[gTc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( gTestcases ); +} diff --git a/tests/auto/qml/parserstress/tests/ecma/ExecutionContexts/10.1.4-2.js b/tests/auto/qml/parserstress/tests/ecma/ExecutionContexts/10.1.4-2.js new file mode 100644 index 0000000000..2aee831b45 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/ExecutionContexts/10.1.4-2.js @@ -0,0 +1,113 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '10.1.4-2.js'; + +/** + File Name: 10.1.4-1.js + ECMA Section: 10.1.4 Scope Chain and Identifier Resolution + Description: + Every execution context has associated with it a scope chain. This is + logically a list of objects that are searched when binding an Identifier. + When control enters an execution context, the scope chain is created and + is populated with an initial set of objects, depending on the type of + code. When control leaves the execution context, the scope chain is + destroyed. + + During execution, the scope chain of the execution context is affected + only by WithStatement. When execution enters a with block, the object + specified in the with statement is added to the front of the scope chain. + When execution leaves a with block, whether normally or via a break or + continue statement, the object is removed from the scope chain. The object + being removed will always be the first object in the scope chain. + + During execution, the syntactic production PrimaryExpression : Identifier + is evaluated using the following algorithm: + + 1. Get the next object in the scope chain. If there isn't one, go to step 5. + 2. Call the [[HasProperty]] method of Result(l), passing the Identifier as + the property. + 3. If Result(2) is true, return a value of type Reference whose base object + is Result(l) and whose property name is the Identifier. + 4. Go to step 1. + 5. Return a value of type Reference whose base object is null and whose + property name is the Identifier. + The result of binding an identifier is always a value of type Reference with + its member name component equal to the identifier string. + Author: christine@netscape.com + Date: 12 november 1997 +*/ +var SECTION = "10.1.4-2"; +var VERSION = "ECMA_1"; +startTest(); + +writeHeaderToLog( SECTION + " Scope Chain and Identifier Resolution"); + +new TestCase( "SECTION", "with MyObject, eval should return square of " ); + +test(); + +function test() { + for ( gTc=0; gTc < gTestcases.length; gTc++ ) { + + var MYOBJECT = new MyObject(); + var INPUT = 2; + gTestcases[gTc].description += "( "+INPUT +" )" ; + + with ( this ) { + with ( MYOBJECT ) { + gTestcases[gTc].actual = eval( INPUT ); + gTestcases[gTc].expect = Math.pow(INPUT,2); + } + } + + gTestcases[gTc].passed = writeTestCaseResult( + gTestcases[gTc].expect, + gTestcases[gTc].actual, + gTestcases[gTc].description +" = "+ + gTestcases[gTc].actual ); + + gTestcases[gTc].reason += ( gTestcases[gTc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( gTestcases ); +} + +function MyObject() { + this.eval = new Function( "x", "return(Math.pow(Number(x),2))" ); +} diff --git a/tests/auto/qml/parserstress/tests/ecma/ExecutionContexts/10.1.4-3.js b/tests/auto/qml/parserstress/tests/ecma/ExecutionContexts/10.1.4-3.js new file mode 100644 index 0000000000..a3ae0ffdec --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/ExecutionContexts/10.1.4-3.js @@ -0,0 +1,111 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '10.1.4-3.js'; + +/** + File Name: 10.1.4-1.js + ECMA Section: 10.1.4 Scope Chain and Identifier Resolution + Description: + Every execution context has associated with it a scope chain. This is + logically a list of objects that are searched when binding an Identifier. + When control enters an execution context, the scope chain is created and + is populated with an initial set of objects, depending on the type of + code. When control leaves the execution context, the scope chain is + destroyed. + + During execution, the scope chain of the execution context is affected + only by WithStatement. When execution enters a with block, the object + specified in the with statement is added to the front of the scope chain. + When execution leaves a with block, whether normally or via a break or + continue statement, the object is removed from the scope chain. The object + being removed will always be the first object in the scope chain. + + During execution, the syntactic production PrimaryExpression : Identifier + is evaluated using the following algorithm: + + 1. Get the next object in the scope chain. If there isn't one, go to step 5. + 2. Call the [[HasProperty]] method of Result(l), passing the Identifier as + the property. + 3. If Result(2) is true, return a value of type Reference whose base object + is Result(l) and whose property name is the Identifier. + 4. Go to step 1. + 5. Return a value of type Reference whose base object is null and whose + property name is the Identifier. + The result of binding an identifier is always a value of type Reference with + its member name component equal to the identifier string. + Author: christine@netscape.com + Date: 12 november 1997 +*/ +var SECTION = "10.1.4-3"; +var VERSION = "ECMA_1"; +startTest(); + +writeHeaderToLog( SECTION + " Scope Chain and Identifier Resolution"); + +new TestCase( "SECTION", + "with MyObject, eval should be [object Global].eval " ); + +test(); + +function test() { + for ( gTc=0; gTc < gTestcases.length; gTc++ ) { + + var MYOBJECT = new MyObject(); + var INPUT = 2; + gTestcases[gTc].description += ( INPUT +"" ); + + with ( MYOBJECT ) { + eval( INPUT ); + } + + gTestcases[gTc].passed = writeTestCaseResult( + gTestcases[gTc].expect, + gTestcases[gTc].actual, + gTestcases[gTc].description +" = "+ + gTestcases[gTc].actual ); + + gTestcases[gTc].reason += ( gTestcases[gTc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( gTestcases ); +} + +function MyObject() { + this.eval = new Function( "x", "return(Math.pow(Number(x),2))" ); +} diff --git a/tests/auto/qml/parserstress/tests/ecma/ExecutionContexts/10.1.4-4.js b/tests/auto/qml/parserstress/tests/ecma/ExecutionContexts/10.1.4-4.js new file mode 100644 index 0000000000..31274a0209 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/ExecutionContexts/10.1.4-4.js @@ -0,0 +1,113 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '10.1.4-4.js'; + +/** + File Name: 10.1.4-1.js + ECMA Section: 10.1.4 Scope Chain and Identifier Resolution + Description: + Every execution context has associated with it a scope chain. This is + logically a list of objects that are searched when binding an Identifier. + When control enters an execution context, the scope chain is created and + is populated with an initial set of objects, depending on the type of + code. When control leaves the execution context, the scope chain is + destroyed. + + During execution, the scope chain of the execution context is affected + only by WithStatement. When execution enters a with block, the object + specified in the with statement is added to the front of the scope chain. + When execution leaves a with block, whether normally or via a break or + continue statement, the object is removed from the scope chain. The object + being removed will always be the first object in the scope chain. + + During execution, the syntactic production PrimaryExpression : Identifier + is evaluated using the following algorithm: + + 1. Get the next object in the scope chain. If there isn't one, go to step 5. + 2. Call the [[HasProperty]] method of Result(l), passing the Identifier as + the property. + 3. If Result(2) is true, return a value of type Reference whose base object + is Result(l) and whose property name is the Identifier. + 4. Go to step 1. + 5. Return a value of type Reference whose base object is null and whose + property name is the Identifier. + The result of binding an identifier is always a value of type Reference with + its member name component equal to the identifier string. + Author: christine@netscape.com + Date: 12 november 1997 +*/ +var SECTION = "10.1.4-1"; +var VERSION = "ECMA_1"; +startTest(); + +writeHeaderToLog( SECTION + " Scope Chain and Identifier Resolution"); + +new TestCase( "SECTION", + "with MyObject, eval should be [object Global].eval " ); +test(); + +function test() { + for ( gTc=0; gTc < gTestcases.length; gTc++ ) { + + var MYOBJECT = new MyObject(); + var INPUT = 2; + gTestcases[gTc].description += ( INPUT +"" ); + + with ( MYOBJECT ) { + eval( INPUT ); + } + + gTestcases[gTc].actual = eval( INPUT ); + gTestcases[gTc].expect = INPUT; + + gTestcases[gTc].passed = writeTestCaseResult( + gTestcases[gTc].expect, + gTestcases[gTc].actual, + gTestcases[gTc].description +" = "+ + gTestcases[gTc].actual ); + + gTestcases[gTc].reason += ( gTestcases[gTc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( gTestcases ); +} + +function MyObject() { + this.eval = new Function( "x", "return(Math.pow(Number(x),2))" ); +} diff --git a/tests/auto/qml/parserstress/tests/ecma/ExecutionContexts/10.1.4-5.js b/tests/auto/qml/parserstress/tests/ecma/ExecutionContexts/10.1.4-5.js new file mode 100644 index 0000000000..c36d2db8cc --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/ExecutionContexts/10.1.4-5.js @@ -0,0 +1,112 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '10.1.4-5.js'; + +/** + File Name: 10.1.4-1.js + ECMA Section: 10.1.4 Scope Chain and Identifier Resolution + Description: + Every execution context has associated with it a scope chain. This is + logically a list of objects that are searched when binding an Identifier. + When control enters an execution context, the scope chain is created and + is populated with an initial set of objects, depending on the type of + code. When control leaves the execution context, the scope chain is + destroyed. + + During execution, the scope chain of the execution context is affected + only by WithStatement. When execution enters a with block, the object + specified in the with statement is added to the front of the scope chain. + When execution leaves a with block, whether normally or via a break or + continue statement, the object is removed from the scope chain. The object + being removed will always be the first object in the scope chain. + + During execution, the syntactic production PrimaryExpression : Identifier + is evaluated using the following algorithm: + + 1. Get the next object in the scope chain. If there isn't one, go to step 5. + 2. Call the [[HasProperty]] method of Result(l), passing the Identifier as + the property. + 3. If Result(2) is true, return a value of type Reference whose base object + is Result(l) and whose property name is the Identifier. + 4. Go to step 1. + 5. Return a value of type Reference whose base object is null and whose + property name is the Identifier. + The result of binding an identifier is always a value of type Reference with + its member name component equal to the identifier string. + Author: christine@netscape.com + Date: 12 november 1997 +*/ +var SECTION = "10.1.4-1"; +var VERSION = "ECMA_1"; +startTest(); + +writeHeaderToLog( SECTION + " Scope Chain and Identifier Resolution"); + +new TestCase( "SECTION", + "with MyObject, eval should be [object Global].eval " ); +test(); + +function test() { + for ( gTc=0; gTc < gTestcases.length; gTc++ ) { + + var MYOBJECT = new MyObject(); + var INPUT = 2; + gTestcases[gTc].description += ( INPUT +"" ); + + with ( MYOBJECT ) { + eval = null; + } + + gTestcases[gTc].actual = eval( INPUT ); + gTestcases[gTc].expect = INPUT; + + gTestcases[gTc].passed = writeTestCaseResult( + gTestcases[gTc].expect, + gTestcases[gTc].actual, + gTestcases[gTc].description +" = "+ + gTestcases[gTc].actual ); + + gTestcases[gTc].reason += ( gTestcases[gTc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( gTestcases ); +} +function MyObject() { + this.eval = new Function( "x", "return(Math.pow(Number(x),2))" ); +} diff --git a/tests/auto/qml/parserstress/tests/ecma/ExecutionContexts/10.1.4-6.js b/tests/auto/qml/parserstress/tests/ecma/ExecutionContexts/10.1.4-6.js new file mode 100644 index 0000000000..da11110cc5 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/ExecutionContexts/10.1.4-6.js @@ -0,0 +1,100 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '10.1.4-6.js'; + +/** + File Name: 10.1.4-1.js + ECMA Section: 10.1.4 Scope Chain and Identifier Resolution + Description: + Every execution context has associated with it a scope chain. This is + logically a list of objects that are searched when binding an Identifier. + When control enters an execution context, the scope chain is created and + is populated with an initial set of objects, depending on the type of + code. When control leaves the execution context, the scope chain is + destroyed. + + During execution, the scope chain of the execution context is affected + only by WithStatement. When execution enters a with block, the object + specified in the with statement is added to the front of the scope chain. + When execution leaves a with block, whether normally or via a break or + continue statement, the object is removed from the scope chain. The object + being removed will always be the first object in the scope chain. + + During execution, the syntactic production PrimaryExpression : Identifier + is evaluated using the following algorithm: + + 1. Get the next object in the scope chain. If there isn't one, go to step 5. + 2. Call the [[HasProperty]] method of Result(l), passing the Identifier as + the property. + 3. If Result(2) is true, return a value of type Reference whose base object + is Result(l) and whose property name is the Identifier. + 4. Go to step 1. + 5. Return a value of type Reference whose base object is null and whose + property name is the Identifier. + The result of binding an identifier is always a value of type Reference with + its member name component equal to the identifier string. + Author: christine@netscape.com + Date: 12 november 1997 +*/ +var SECTION = "10.1.4-6"; +var VERSION = "ECMA_1"; +startTest(); + +writeHeaderToLog( SECTION + " Scope Chain and Identifier Resolution"); + + +var testcase = new TestCase( "SECTION", + "with MyObject, eval should be [object Global].eval " ); + +var MYOBJECT = new MyObject(); +var INPUT = 2; +testcase.description += ( INPUT +"" ); + +with ( MYOBJECT ) { + ; +} +testcase.actual = eval( INPUT ); +testcase.expect = INPUT; + +test(); + + +function MyObject() { + this.eval = new Function( "x", "return(Math.pow(Number(x),2))" ); +} diff --git a/tests/auto/qml/parserstress/tests/ecma/ExecutionContexts/10.1.4-7.js b/tests/auto/qml/parserstress/tests/ecma/ExecutionContexts/10.1.4-7.js new file mode 100644 index 0000000000..f1a0db4569 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/ExecutionContexts/10.1.4-7.js @@ -0,0 +1,112 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '10.1.4-7.js'; + +/** + File Name: 10.1.4-7.js + ECMA Section: 10.1.4 Scope Chain and Identifier Resolution + Description: + Every execution context has associated with it a scope chain. This is + logically a list of objects that are searched when binding an Identifier. + When control enters an execution context, the scope chain is created and + is populated with an initial set of objects, depending on the type of + code. When control leaves the execution context, the scope chain is + destroyed. + + During execution, the scope chain of the execution context is affected + only by WithStatement. When execution enters a with block, the object + specified in the with statement is added to the front of the scope chain. + When execution leaves a with block, whether normally or via a break or + continue statement, the object is removed from the scope chain. The object + being removed will always be the first object in the scope chain. + + During execution, the syntactic production PrimaryExpression : Identifier + is evaluated using the following algorithm: + + 1. Get the next object in the scope chain. If there isn't one, go to step 5. + 2. Call the [[HasProperty]] method of Result(l), passing the Identifier as + the property. + 3. If Result(2) is true, return a value of type Reference whose base object + is Result(l) and whose property name is the Identifier. + 4. Go to step 1. + 5. Return a value of type Reference whose base object is null and whose + property name is the Identifier. + The result of binding an identifier is always a value of type Reference with + its member name component equal to the identifier string. + Author: christine@netscape.com + Date: 12 november 1997 +*/ +var SECTION = "10.1.4-7"; +var VERSION = "ECMA_1"; +startTest(); + +writeHeaderToLog( SECTION + " Scope Chain and Identifier Resolution"); + +new TestCase( "SECTION", + "with MyObject, eval should be [object Global].eval " ); +test(); + +function test() { + for ( gTc=0; gTc < gTestcases.length; gTc++ ) { + + var MYOBJECT = new MyObject(); + var INPUT = 2; + gTestcases[gTc].description += ( INPUT +"" ); + + with ( MYOBJECT ) { + delete( eval ); + gTestcases[gTc].actual = eval( INPUT ); + gTestcases[gTc].expect = INPUT; + } + + gTestcases[gTc].passed = writeTestCaseResult( + gTestcases[gTc].expect, + gTestcases[gTc].actual, + gTestcases[gTc].description +" = "+ + gTestcases[gTc].actual ); + + gTestcases[gTc].reason += ( gTestcases[gTc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( gTestcases ); +} + +function MyObject() { + this.eval = new Function( "x", "return(Math.pow(Number(x),2))" ); +} diff --git a/tests/auto/qml/parserstress/tests/ecma/ExecutionContexts/10.1.4-8.js b/tests/auto/qml/parserstress/tests/ecma/ExecutionContexts/10.1.4-8.js new file mode 100644 index 0000000000..1eee8da4fb --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/ExecutionContexts/10.1.4-8.js @@ -0,0 +1,113 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '10.1.4-8.js'; + +/** + File Name: 10.1.4-1.js + ECMA Section: 10.1.4 Scope Chain and Identifier Resolution + Description: + Every execution context has associated with it a scope chain. This is + logically a list of objects that are searched when binding an Identifier. + When control enters an execution context, the scope chain is created and + is populated with an initial set of objects, depending on the type of + code. When control leaves the execution context, the scope chain is + destroyed. + + During execution, the scope chain of the execution context is affected + only by WithStatement. When execution enters a with block, the object + specified in the with statement is added to the front of the scope chain. + When execution leaves a with block, whether normally or via a break or + continue statement, the object is removed from the scope chain. The object + being removed will always be the first object in the scope chain. + + During execution, the syntactic production PrimaryExpression : Identifier + is evaluated using the following algorithm: + + 1. Get the next object in the scope chain. If there isn't one, go to step 5. + 2. Call the [[HasProperty]] method of Result(l), passing the Identifier as + the property. + 3. If Result(2) is true, return a value of type Reference whose base object + is Result(l) and whose property name is the Identifier. + 4. Go to step 1. + 5. Return a value of type Reference whose base object is null and whose + property name is the Identifier. + The result of binding an identifier is always a value of type Reference with + its member name component equal to the identifier string. + Author: christine@netscape.com + Date: 12 november 1997 +*/ +var SECTION = "10.1.4-1"; +var VERSION = "ECMA_1"; +startTest(); + +writeHeaderToLog( SECTION + " Scope Chain and Identifier Resolution"); + +new TestCase( "SECTION", + "with MyObject, eval should cube INPUT: " ); +test(); + +function test() { + for ( gTc=0; gTc < gTestcases.length; gTc++ ) { + + var MYOBJECT = new MyObject(); + var INPUT = 2; + gTestcases[gTc].description += ( INPUT +"" ); + + with ( MYOBJECT ) { + eval = new Function ( "x", "return(Math.pow(Number(x),3))" ); + + gTestcases[gTc].actual = eval( INPUT ); + gTestcases[gTc].expect = Math.pow(INPUT,3); + } + + gTestcases[gTc].passed = writeTestCaseResult( + gTestcases[gTc].expect, + gTestcases[gTc].actual, + gTestcases[gTc].description +" = "+ + gTestcases[gTc].actual ); + + gTestcases[gTc].reason += ( gTestcases[gTc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( gTestcases ); +} + +function MyObject() { + this.eval = new Function( "x", "return(Math.pow(Number(x),2))" ); +} diff --git a/tests/auto/qml/parserstress/tests/ecma/ExecutionContexts/10.1.5-1.js b/tests/auto/qml/parserstress/tests/ecma/ExecutionContexts/10.1.5-1.js new file mode 100644 index 0000000000..363581eff6 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/ExecutionContexts/10.1.5-1.js @@ -0,0 +1,118 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '10.1.5-1.js'; + +/** + File Name: 10.1.5-1.js + ECMA Section: 10.1.5 Global Object + Description: + There is a unique global object which is created before control enters + any execution context. Initially the global object has the following + properties: + + Built-in objects such as Math, String, Date, parseInt, etc. These have + attributes { DontEnum }. + + Additional host defined properties. This may include a property whose + value is the global object itself, for example window in HTML. + + As control enters execution contexts, and as ECMAScript code is executed, + additional properties may be added to the global object and the initial + properties may be changed. + + Author: christine@netscape.com + Date: 12 november 1997 +*/ +var SECTION = "10.5.1-1"; +var VERSION = "ECMA_1"; +startTest(); + +writeHeaderToLog( SECTION + " Global Object"); + + +new TestCase( "SECTION", "Global Code check" ); + +if ( Object == null ) { + gTestcases[0].reason += " Object == null" ; +} +if ( Function == null ) { + gTestcases[0].reason += " Function == null"; +} +if ( String == null ) { + gTestcases[0].reason += " String == null"; +} +if ( Array == null ) { + gTestcases[0].reason += " Array == null"; +} +if ( Number == null ) { + gTestcases[0].reason += " Function == null"; +} +if ( Math == null ) { + gTestcases[0].reason += " Math == null"; +} +if ( Boolean == null ) { + gTestcases[0].reason += " Boolean == null"; +} +if ( Date == null ) { + gTestcases[0].reason += " Date == null"; +} +/* + if ( NaN == null ) { + gTestcases[0].reason += " NaN == null"; + } + if ( Infinity == null ) { + gTestcases[0].reason += " Infinity == null"; + } +*/ +if ( eval == null ) { + gTestcases[0].reason += " eval == null"; +} +if ( parseInt == null ) { + gTestcases[0].reason += " parseInt == null"; +} + +if ( gTestcases[0].reason != "" ) { + gTestcases[0].actual = "fail"; +} else { + gTestcases[0].actual = "pass"; +} +gTestcases[0].expect = "pass"; + +test(); + diff --git a/tests/auto/qml/parserstress/tests/ecma/ExecutionContexts/10.1.5-2.js b/tests/auto/qml/parserstress/tests/ecma/ExecutionContexts/10.1.5-2.js new file mode 100644 index 0000000000..cfba3b5c73 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/ExecutionContexts/10.1.5-2.js @@ -0,0 +1,100 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '10.1.5-2.js'; + +/** + File Name: 10.1.5-2.js + ECMA Section: 10.1.5 Global Object + Description: + There is a unique global object which is created before control enters + any execution context. Initially the global object has the following + properties: + + Built-in objects such as Math, String, Date, parseInt, etc. These have + attributes { DontEnum }. + + Additional host defined properties. This may include a property whose + value is the global object itself, for example window in HTML. + + As control enters execution contexts, and as ECMAScript code is executed, + additional properties may be added to the global object and the initial + properties may be changed. + + Author: christine@netscape.com + Date: 12 november 1997 +*/ +var SECTION = "10.5.1-2"; +var VERSION = "ECMA_1"; +startTest(); + +writeHeaderToLog( SECTION + " Global Object"); + +new TestCase( "SECTION", "Eval Code check" ); + +var EVAL_STRING = 'if ( Object == null ) { gTestcases[0].reason += " Object == null" ; }' + + 'if ( Function == null ) { gTestcases[0].reason += " Function == null"; }' + + 'if ( String == null ) { gTestcases[0].reason += " String == null"; }' + + 'if ( Array == null ) { gTestcases[0].reason += " Array == null"; }' + + 'if ( Number == null ) { gTestcases[0].reason += " Function == null";}' + + 'if ( Math == null ) { gTestcases[0].reason += " Math == null"; }' + + 'if ( Boolean == null ) { gTestcases[0].reason += " Boolean == null"; }' + + 'if ( Date == null ) { gTestcases[0].reason += " Date == null"; }' + + 'if ( eval == null ) { gTestcases[0].reason += " eval == null"; }' + + 'if ( parseInt == null ) { gTestcases[0].reason += " parseInt == null"; }' ; + +eval( EVAL_STRING ); + +/* + if ( NaN == null ) { + gTestcases[0].reason += " NaN == null"; + } + if ( Infinity == null ) { + gTestcases[0].reason += " Infinity == null"; + } +*/ + +if ( gTestcases[0].reason != "" ) { + gTestcases[0].actual = "fail"; +} else { + gTestcases[0].actual = "pass"; +} +gTestcases[0].expect = "pass"; + +test(); + diff --git a/tests/auto/qml/parserstress/tests/ecma/ExecutionContexts/10.1.5-3.js b/tests/auto/qml/parserstress/tests/ecma/ExecutionContexts/10.1.5-3.js new file mode 100644 index 0000000000..f5234cb13b --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/ExecutionContexts/10.1.5-3.js @@ -0,0 +1,130 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '10.1.5-3.js'; + +/** + File Name: 10.1.5-3.js + ECMA Section: 10.1.5 Global Object + Description: + There is a unique global object which is created before control enters + any execution context. Initially the global object has the following + properties: + + Built-in objects such as Math, String, Date, parseInt, etc. These have + attributes { DontEnum }. + + Additional host defined properties. This may include a property whose + value is the global object itself, for example window in HTML. + + As control enters execution contexts, and as ECMAScript code is executed, + additional properties may be added to the global object and the initial + properties may be changed. + + Author: christine@netscape.com + Date: 12 november 1997 +*/ +var SECTION = "10.5.1-3"; +var VERSION = "ECMA_1"; +startTest(); +writeHeaderToLog( SECTION + " Global Object"); + +new TestCase( "SECTION", "Function Code check" ); + +test(); + +function test() { + if ( Object == null ) { + gTestcases[0].reason += " Object == null" ; + } + if ( Function == null ) { + gTestcases[0].reason += " Function == null"; + } + if ( String == null ) { + gTestcases[0].reason += " String == null"; + } + if ( Array == null ) { + gTestcases[0].reason += " Array == null"; + } + if ( Number == null ) { + gTestcases[0].reason += " Function == null"; + } + if ( Math == null ) { + gTestcases[0].reason += " Math == null"; + } + if ( Boolean == null ) { + gTestcases[0].reason += " Boolean == null"; + } + if ( Date == null ) { + gTestcases[0].reason += " Date == null"; + } +/* + if ( NaN == null ) { + gTestcases[0].reason += " NaN == null"; + } + if ( Infinity == null ) { + gTestcases[0].reason += " Infinity == null"; + } +*/ + if ( eval == null ) { + gTestcases[0].reason += " eval == null"; + } + if ( parseInt == null ) { + gTestcases[0].reason += " parseInt == null"; + } + + if ( gTestcases[0].reason != "" ) { + gTestcases[0].actual = "fail"; + } else { + gTestcases[0].actual = "pass"; + } + gTestcases[0].expect = "pass"; + + for ( gTc=0; gTc < gTestcases.length; gTc++ ) { + + gTestcases[gTc].passed = writeTestCaseResult( + gTestcases[gTc].expect, + gTestcases[gTc].actual, + gTestcases[gTc].description +" = "+ + gTestcases[gTc].actual ); + + gTestcases[gTc].reason += ( gTestcases[gTc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( gTestcases ); +} diff --git a/tests/auto/qml/parserstress/tests/ecma/ExecutionContexts/10.1.5-4.js b/tests/auto/qml/parserstress/tests/ecma/ExecutionContexts/10.1.5-4.js new file mode 100644 index 0000000000..953e6a8feb --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/ExecutionContexts/10.1.5-4.js @@ -0,0 +1,91 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '10.1.5-4.js'; + +/** + File Name: 10.1.5-4.js + ECMA Section: 10.1.5 Global Object + Description: + There is a unique global object which is created before control enters + any execution context. Initially the global object has the following + properties: + + Built-in objects such as Math, String, Date, parseInt, etc. These have + attributes { DontEnum }. + + Additional host defined properties. This may include a property whose + value is the global object itself, for example window in HTML. + + As control enters execution contexts, and as ECMAScript code is executed, + additional properties may be added to the global object and the initial + properties may be changed. + + Author: christine@netscape.com + Date: 12 november 1997 +*/ +var SECTION = "10.5.1-4"; +var VERSION = "ECMA_1"; +startTest(); + +writeHeaderToLog( SECTION + " Global Object"); + +new TestCase( "SECTION", "Anonymous Code check" ); + + +var EVAL_STRING = 'if ( Object == null ) { gTestcases[0].reason += " Object == null" ; }' + + 'if ( Function == null ) { gTestcases[0].reason += " Function == null"; }' + + 'if ( String == null ) { gTestcases[0].reason += " String == null"; }' + + 'if ( Array == null ) { gTestcases[0].reason += " Array == null"; }' + + 'if ( Number == null ) { gTestcases[0].reason += " Function == null";}' + + 'if ( Math == null ) { gTestcases[0].reason += " Math == null"; }' + + 'if ( Boolean == null ) { gTestcases[0].reason += " Boolean == null"; }' + + 'if ( Date == null ) { gTestcases[0].reason += " Date == null"; }' + + 'if ( eval == null ) { gTestcases[0].reason += " eval == null"; }' + + 'if ( parseInt == null ) { gTestcases[0].reason += " parseInt == null"; }' ; + +var NEW_FUNCTION = new Function( EVAL_STRING ); + +if ( gTestcases[0].reason != "" ) { + gTestcases[0].actual = "fail"; +} else { + gTestcases[0].actual = "pass"; +} +gTestcases[0].expect = "pass"; + +test(); diff --git a/tests/auto/qml/parserstress/tests/ecma/ExecutionContexts/10.1.8-2.js b/tests/auto/qml/parserstress/tests/ecma/ExecutionContexts/10.1.8-2.js new file mode 100644 index 0000000000..40e6f0ee8f --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/ExecutionContexts/10.1.8-2.js @@ -0,0 +1,120 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '10.1.8-2.js'; + +/** + File Name: 10.1.8-2 + ECMA Section: Arguments Object + Description: + + When control enters an execution context for declared function code, + anonymous code, or implementation-supplied code, an arguments object is + created and initialized as follows: + + The [[Prototype]] of the arguments object is to the original Object + prototype object, the one that is the initial value of Object.prototype + (section 15.2.3.1). + + A property is created with name callee and property attributes {DontEnum}. + The initial value of this property is the function object being executed. + This allows anonymous functions to be recursive. + + A property is created with name length and property attributes {DontEnum}. + The initial value of this property is the number of actual parameter values + supplied by the caller. + + For each non-negative integer, iarg, less than the value of the length + property, a property is created with name ToString(iarg) and property + attributes { DontEnum }. The initial value of this property is the value + of the corresponding actual parameter supplied by the caller. The first + actual parameter value corresponds to iarg = 0, the second to iarg = 1 and + so on. In the case when iarg is less than the number of formal parameters + for the function object, this property shares its value with the + corresponding property of the activation object. This means that changing + this property changes the corresponding property of the activation object + and vice versa. The value sharing mechanism depends on the implementation. + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + +var SECTION = "10.1.8-2"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Arguments Object"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +// Tests for anonymous functions + +var GetCallee = new Function( "var c = arguments.callee; return c" ); +var GetArguments = new Function( "var a = arguments; return a" ); +var GetLength = new Function( "var l = arguments.length; return l" ); + +var ARG_STRING = "value of the argument property"; + +new TestCase( SECTION, + "GetCallee()", + GetCallee, + GetCallee() ); + +var LIMIT = 100; + +for ( var i = 0, args = "" ; i < LIMIT; i++ ) { + args += String(i) + ( i+1 < LIMIT ? "," : "" ); + +} + +var LENGTH = eval( "GetLength("+ args +")" ); + +new TestCase( SECTION, + "GetLength("+args+")", + 100, + LENGTH ); + +var ARGUMENTS = eval( "GetArguments( " +args+")" ); + +for ( var i = 0; i < 100; i++ ) { + new TestCase( SECTION, + "GetArguments("+args+")["+i+"]", + i, + ARGUMENTS[i] ); +} + +test(); diff --git a/tests/auto/qml/parserstress/tests/ecma/ExecutionContexts/10.1.8-3.js b/tests/auto/qml/parserstress/tests/ecma/ExecutionContexts/10.1.8-3.js new file mode 100644 index 0000000000..71aa876f02 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/ExecutionContexts/10.1.8-3.js @@ -0,0 +1,66 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * Norris Boyd + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '10.1.8-3.js'; + +/** + File Name: 10.1.8-3 + ECMA Section: Arguments Object + Description: + + The [[Prototype]] of the arguments object is to the original Object + prototype object, the one that is the initial value of Object.prototype + (section 15.2.3.1). + + ... + + Test that "typeof arguments" is thus "object". + +*/ + +var SECTION = "10.1.8-2"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Arguments Object"; +writeHeaderToLog( SECTION + " "+ TITLE); + +var expected = "object"; +var actual = (function () { return typeof arguments; })(); +reportCompare(expected, actual, "typeof arguments == object"); + diff --git a/tests/auto/qml/parserstress/tests/ecma/ExecutionContexts/10.2.1.js b/tests/auto/qml/parserstress/tests/ecma/ExecutionContexts/10.2.1.js new file mode 100644 index 0000000000..5384da4f83 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/ExecutionContexts/10.2.1.js @@ -0,0 +1,85 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '10.2.1.js'; + +/** + File Name: 10.2.1.js + ECMA Section: 10.2.1 Global Code + Description: + + The scope chain is created and initialized to contain the global object and + no others. + + Variable instantiation is performed using the global object as the variable + object and using empty property attributes. + + The this value is the global object. + Author: christine@netscape.com + Date: 12 november 1997 +*/ + +var SECTION = "10.2.1"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Global Code"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +var THIS = this; + +new TestCase( SECTION, + "this +''", + GLOBAL, + THIS + "" ); + +var GLOBAL_PROPERTIES = new Array(); +var i = 0; + +for ( p in this ) { + GLOBAL_PROPERTIES[i++] = p; +} + +for ( i = 0; i < GLOBAL_PROPERTIES.length; i++ ) { + new TestCase( SECTION, + GLOBAL_PROPERTIES[i] +" == void 0", + false, + eval("GLOBAL_PROPERTIES["+i+"] == void 0")); +} + +test(); diff --git a/tests/auto/qml/parserstress/tests/ecma/ExecutionContexts/10.2.2-1.js b/tests/auto/qml/parserstress/tests/ecma/ExecutionContexts/10.2.2-1.js new file mode 100644 index 0000000000..787ef9e5b3 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/ExecutionContexts/10.2.2-1.js @@ -0,0 +1,122 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '10.2.2-1.js'; + +/** + File Name: 10.2.2-1.js + ECMA Section: 10.2.2 Eval Code + Description: + + When control enters an execution context for eval code, the previous + active execution context, referred to as the calling context, is used to + determine the scope chain, the variable object, and the this value. If + there is no calling context, then initializing the scope chain, variable + instantiation, and determination of the this value are performed just as + for global code. + + The scope chain is initialized to contain the same objects, in the same + order, as the calling context's scope chain. This includes objects added + to the calling context's scope chain by WithStatement. + + Variable instantiation is performed using the calling context's variable + object and using empty property attributes. + + The this value is the same as the this value of the calling context. + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + +var SECTION = "10.2.2-1"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Eval Code"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +var THIS = eval("this"); + +new TestCase( SECTION, + "this +''", + GLOBAL, + THIS + "" ); + +var GLOBAL_PROPERTIES = new Array(); +var i = 0; + +for ( p in THIS ) { + GLOBAL_PROPERTIES[i++] = p; +} + +for ( i = 0; i < GLOBAL_PROPERTIES.length; i++ ) { + new TestCase( SECTION, + GLOBAL_PROPERTIES[i] +" == THIS["+GLOBAL_PROPERTIES[i]+"]", + true, + eval(GLOBAL_PROPERTIES[i]) == eval( "THIS[GLOBAL_PROPERTIES[i]]") ); +} + +// this in eval statements is the same as this value of the calling context + +var RESULT = THIS == this; + +new TestCase( SECTION, + "eval( 'this == THIS' )", + true, + RESULT ); + +var RESULT = THIS +''; + +new TestCase( SECTION, + "eval( 'this + \"\"' )", + GLOBAL, + RESULT ); + + +new TestCase( SECTION, + "eval( 'this == THIS' )", + true, + eval( "this == THIS" ) ); + +new TestCase( SECTION, + "eval( 'this + \"\"' )", + GLOBAL, + eval( "this +''") ); + + +test(); diff --git a/tests/auto/qml/parserstress/tests/ecma/ExecutionContexts/10.2.2-2.js b/tests/auto/qml/parserstress/tests/ecma/ExecutionContexts/10.2.2-2.js new file mode 100644 index 0000000000..8048c45575 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/ExecutionContexts/10.2.2-2.js @@ -0,0 +1,133 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '10.2.2-2.js'; + +/** + File Name: 10.2.2-2.js + ECMA Section: 10.2.2 Eval Code + Description: + + When control enters an execution context for eval code, the previous + active execution context, referred to as the calling context, is used to + determine the scope chain, the variable object, and the this value. If + there is no calling context, then initializing the scope chain, variable + instantiation, and determination of the this value are performed just as + for global code. + + The scope chain is initialized to contain the same objects, in the same + order, as the calling context's scope chain. This includes objects added + to the calling context's scope chain by WithStatement. + + Variable instantiation is performed using the calling context's variable + object and using empty property attributes. + + The this value is the same as the this value of the calling context. + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + +var SECTION = "10.2.2-2"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Eval Code"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +// Test Objects + +var OBJECT = new MyObject( "hello" ); +var GLOBAL_PROPERTIES = new Array(); +var i = 0; + +for ( p in this ) { + GLOBAL_PROPERTIES[i++] = p; +} + +with ( OBJECT ) { + var THIS = this; + new TestCase( SECTION, + "eval( 'this == THIS' )", + true, + eval("this == THIS") ); + new TestCase( SECTION, + "this in a with() block", + GLOBAL, + this+"" ); + new TestCase( SECTION, + "new MyObject('hello').value", + "hello", + value ); + new TestCase( SECTION, + "eval(new MyObject('hello').value)", + "hello", + eval("value") ); + new TestCase( SECTION, + "new MyObject('hello').getClass()", + "[object Object]", + getClass() ); + new TestCase( SECTION, + "eval(new MyObject('hello').getClass())", + "[object Object]", + eval("getClass()") ); + new TestCase( SECTION, + "eval(new MyObject('hello').toString())", + "hello", + eval("toString()") ); + new TestCase( SECTION, + "eval('getClass') == Object.prototype.toString", + true, + eval("getClass") == Object.prototype.toString ); + + for ( i = 0; i < GLOBAL_PROPERTIES.length; i++ ) { + new TestCase( SECTION, GLOBAL_PROPERTIES[i] + + " == THIS["+GLOBAL_PROPERTIES[i]+"]", true, + eval(GLOBAL_PROPERTIES[i]) == eval( "THIS[GLOBAL_PROPERTIES[i]]") ); + } + +} + +test(); + +function MyObject( value ) { + this.value = value; + this.getClass = Object.prototype.toString; + this.toString = new Function( "return this.value+''" ); + return this; +} diff --git a/tests/auto/qml/parserstress/tests/ecma/ExecutionContexts/10.2.3-1.js b/tests/auto/qml/parserstress/tests/ecma/ExecutionContexts/10.2.3-1.js new file mode 100644 index 0000000000..a1977c66d6 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/ExecutionContexts/10.2.3-1.js @@ -0,0 +1,86 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '10.2.3-1.js'; + +/** + File Name: 10.2.3-1.js + ECMA Section: 10.2.3 Function and Anonymous Code + Description: + + The scope chain is initialized to contain the activation object followed + by the global object. Variable instantiation is performed using the + activation by the global object. Variable instantiation is performed using + the activation object as the variable object and using property attributes + { DontDelete }. The caller provides the this value. If the this value + provided by the caller is not an object (including the case where it is + null), then the this value is the global object. + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + +var SECTION = "10.2.3-1"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Eval Code"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +var o = new MyObject("hello") + + new TestCase( SECTION, + "var o = new MyObject('hello'); o.THIS == x", + true, + o.THIS == o ); + +var o = MyFunction(); + +new TestCase( SECTION, + "var o = MyFunction(); o == this", + true, + o == this ); + +test(); + +function MyFunction( value ) { + return this; +} +function MyObject( value ) { + this.THIS = this; +} diff --git a/tests/auto/qml/parserstress/tests/ecma/ExecutionContexts/10.2.3-2.js b/tests/auto/qml/parserstress/tests/ecma/ExecutionContexts/10.2.3-2.js new file mode 100644 index 0000000000..e1aa78c5da --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/ExecutionContexts/10.2.3-2.js @@ -0,0 +1,92 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '10.2.3-2.js'; + +/** + File Name: 10.2.3-2.js + ECMA Section: 10.2.3 Function and Anonymous Code + Description: + + The scope chain is initialized to contain the activation object followed + by the global object. Variable instantiation is performed using the + activation by the global object. Variable instantiation is performed using + the activation object as the variable object and using property attributes + { DontDelete }. The caller provides the this value. If the this value + provided by the caller is not an object (including the case where it is + null), then the this value is the global object. + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + +var SECTION = "10.2.3-2"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Function and Anonymous Code"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +var o = new MyObject("hello"); + +new TestCase( SECTION, + "MyFunction(\"PASSED!\")", + "PASSED!", + MyFunction("PASSED!") ); + +var o = MyFunction(); + +new TestCase( SECTION, + "MyOtherFunction(true);", + false, + MyOtherFunction(true) ); + +test(); + +function MyFunction( value ) { + var x = value; + delete x; + return x; +} +function MyOtherFunction(value) { + var x = value; + return delete x; +} +function MyObject( value ) { + this.THIS = this; +} diff --git a/tests/auto/qml/parserstress/tests/ecma/ExecutionContexts/browser.js b/tests/auto/qml/parserstress/tests/ecma/ExecutionContexts/browser.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/auto/qml/parserstress/tests/ecma/ExecutionContexts/shell.js b/tests/auto/qml/parserstress/tests/ecma/ExecutionContexts/shell.js new file mode 100644 index 0000000000..1d353cff74 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/ExecutionContexts/shell.js @@ -0,0 +1 @@ +gTestsubsuite = 'ExecutionContexts'; diff --git a/tests/auto/qml/parserstress/tests/ecma/Expressions/11.1.1.js b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.1.1.js new file mode 100644 index 0000000000..18f0ec7f13 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.1.1.js @@ -0,0 +1,137 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '11.1.1.js'; + +/** + File Name: 11.1.1.js + ECMA Section: 11.1.1 The this keyword + Description: + + The this keyword evaluates to the this value of the execution context. + + Author: christine@netscape.com + Date: 12 november 1997 +*/ +var SECTION = "11.1.1"; +var VERSION = "ECMA_1"; +startTest(); + +writeHeaderToLog( SECTION + " The this keyword"); + +var GLOBAL_OBJECT = this.toString(); + +// this in global code and eval(this) in global code should return the global object. + +new TestCase( SECTION, + "Global Code: this.toString()", + GLOBAL_OBJECT, + this.toString() ); + +new TestCase( SECTION, + "Global Code: eval('this.toString()')", + GLOBAL_OBJECT, + eval('this.toString()') ); + +// this in anonymous code called as a function should return the global object. + +new TestCase( SECTION, + "Anonymous Code: var MYFUNC = new Function('return this.toString()'); MYFUNC()", + GLOBAL_OBJECT, + eval("var MYFUNC = new Function('return this.toString()'); MYFUNC()") ); + +// eval( this ) in anonymous code called as a function should return that function's activation object + +new TestCase( SECTION, + "Anonymous Code: var MYFUNC = new Function('return (eval(\"this.toString()\")'); (MYFUNC()).toString()", + GLOBAL_OBJECT, + eval("var MYFUNC = new Function('return eval(\"this.toString()\")'); (MYFUNC()).toString()") ); + +// this and eval( this ) in anonymous code called as a constructor should return the object + +new TestCase( SECTION, + "Anonymous Code: var MYFUNC = new Function('this.THIS = this'); ((new MYFUNC()).THIS).toString()", + "[object Object]", + eval("var MYFUNC = new Function('this.THIS = this'); ((new MYFUNC()).THIS).toString()") ); + +new TestCase( SECTION, + "Anonymous Code: var MYFUNC = new Function('this.THIS = this'); var FUN1 = new MYFUNC(); FUN1.THIS == FUN1", + true, + eval("var MYFUNC = new Function('this.THIS = this'); var FUN1 = new MYFUNC(); FUN1.THIS == FUN1") ); + +new TestCase( SECTION, + "Anonymous Code: var MYFUNC = new Function('this.THIS = eval(\"this\")'); ((new MYFUNC().THIS).toString()", + "[object Object]", + eval("var MYFUNC = new Function('this.THIS = eval(\"this\")'); ((new MYFUNC()).THIS).toString()") ); + +new TestCase( SECTION, + "Anonymous Code: var MYFUNC = new Function('this.THIS = eval(\"this\")'); var FUN1 = new MYFUNC(); FUN1.THIS == FUN1", + true, + eval("var MYFUNC = new Function('this.THIS = eval(\"this\")'); var FUN1 = new MYFUNC(); FUN1.THIS == FUN1") ); + +// this and eval(this) in function code called as a function should return the global object. +new TestCase( SECTION, + "Function Code: ReturnThis()", + GLOBAL_OBJECT, + ReturnThis() ); + +new TestCase( SECTION, + "Function Code: ReturnEvalThis()", + GLOBAL_OBJECT, + ReturnEvalThis() ); + +// this and eval(this) in function code called as a contructor should return the object. +new TestCase( SECTION, + "var MYOBJECT = new ReturnThis(); MYOBJECT.toString()", + "[object Object]", + eval("var MYOBJECT = new ReturnThis(); MYOBJECT.toString()") ); + +new TestCase( SECTION, + "var MYOBJECT = new ReturnEvalThis(); MYOBJECT.toString()", + "[object Object]", + eval("var MYOBJECT = new ReturnEvalThis(); MYOBJECT.toString()") ); + +test(); + +function ReturnThis() { + return this.toString(); +} + +function ReturnEvalThis() { + return( eval("this.toString()") ); +} diff --git a/tests/auto/qml/parserstress/tests/ecma/Expressions/11.10-1.js b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.10-1.js new file mode 100644 index 0000000000..5b70334ff5 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.10-1.js @@ -0,0 +1,270 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '11.10-1.js'; + +/** + File Name: 11.10-1.js + ECMA Section: 11.10-1 Binary Bitwise Operators: & + Description: + Semantics + + The production A : A @ B, where @ is one of the bitwise operators in the + productions &, ^, | , is evaluated as follows: + + 1. Evaluate A. + 2. Call GetValue(Result(1)). + 3. Evaluate B. + 4. Call GetValue(Result(3)). + 5. Call ToInt32(Result(2)). + 6. Call ToInt32(Result(4)). + 7. Apply the bitwise operator @ to Result(5) and Result(6). The result is + a signed 32 bit integer. + 8. Return Result(7). + + Author: christine@netscape.com + Date: 12 november 1997 +*/ +var SECTION = "11.10-1"; +var VERSION = "ECMA_1"; +startTest(); + +writeHeaderToLog( SECTION + " Binary Bitwise Operators: &"); + +var shiftexp = 0; +var addexp = 0; + +// for ( shiftpow = 0; shiftpow < 33; shiftpow++ ) { +for ( shiftpow = 0; shiftpow < 1; shiftpow++ ) { + shiftexp += Math.pow( 2, shiftpow ); + + for ( addpow = 0; addpow < 33; addpow++ ) { + addexp += Math.pow(2, addpow); + + new TestCase( SECTION, + shiftexp + " & " + addexp, + And( shiftexp, addexp ), + shiftexp & addexp ); + } +} + +test(); + +function ToInteger( n ) { + n = Number( n ); + var sign = ( n < 0 ) ? -1 : 1; + + if ( n != n ) { + return 0; + } + if ( Math.abs( n ) == 0 || Math.abs( n ) == Number.POSITIVE_INFINITY ) { + return n; + } + return ( sign * Math.floor(Math.abs(n)) ); +} +function ToInt32( n ) { + n = Number( n ); + var sign = ( n < 0 ) ? -1 : 1; + + if ( Math.abs( n ) == 0 || Math.abs( n ) == Number.POSITIVE_INFINITY) { + return 0; + } + + n = (sign * Math.floor( Math.abs(n) )) % Math.pow(2,32); + n = ( n >= Math.pow(2,31) ) ? n - Math.pow(2,32) : n; + + return ( n ); +} +function ToUint32( n ) { + n = Number( n ); + var sign = ( n < 0 ) ? -1 : 1; + + if ( Math.abs( n ) == 0 || Math.abs( n ) == Number.POSITIVE_INFINITY) { + return 0; + } + n = sign * Math.floor( Math.abs(n) ) + + n = n % Math.pow(2,32); + + if ( n < 0 ){ + n += Math.pow(2,32); + } + + return ( n ); +} +function ToUint16( n ) { + var sign = ( n < 0 ) ? -1 : 1; + + if ( Math.abs( n ) == 0 || Math.abs( n ) == Number.POSITIVE_INFINITY) { + return 0; + } + + n = ( sign * Math.floor( Math.abs(n) ) ) % Math.pow(2,16); + + if (n <0) { + n += Math.pow(2,16); + } + + return ( n ); +} +function Mask( b, n ) { + b = ToUint32BitString( b ); + b = b.substring( b.length - n ); + b = ToUint32Decimal( b ); + return ( b ); +} +function ToUint32BitString( n ) { + var b = ""; + for ( p = 31; p >=0; p-- ) { + if ( n >= Math.pow(2,p) ) { + b += "1"; + n -= Math.pow(2,p); + } else { + b += "0"; + } + } + return b; +} +function ToInt32BitString( n ) { + var b = ""; + var sign = ( n < 0 ) ? -1 : 1; + + b += ( sign == 1 ) ? "0" : "1"; + + for ( p = 30; p >=0; p-- ) { + if ( (sign == 1 ) ? sign * n >= Math.pow(2,p) : sign * n > Math.pow(2,p) ) { + b += ( sign == 1 ) ? "1" : "0"; + n -= sign * Math.pow( 2, p ); + } else { + b += ( sign == 1 ) ? "0" : "1"; + } + } + + return b; +} +function ToInt32Decimal( bin ) { + var r = 0; + var sign; + + if ( Number(bin.charAt(0)) == 0 ) { + sign = 1; + r = 0; + } else { + sign = -1; + r = -(Math.pow(2,31)); + } + + for ( var j = 0; j < 31; j++ ) { + r += Math.pow( 2, j ) * Number(bin.charAt(31-j)); + } + + return r; +} +function ToUint32Decimal( bin ) { + var r = 0; + + + for ( l = bin.length; l < 32; l++ ) { + bin = "0" + bin; + } + + for ( j = 0; j < 31; j++ ) { + r += Math.pow( 2, j ) * Number(bin.charAt(31-j)); + + } + + return r; +} +function And( s, a ) { + s = ToInt32( s ); + a = ToInt32( a ); + + var bs = ToInt32BitString( s ); + var ba = ToInt32BitString( a ); + + var result = ""; + + for ( var bit = 0; bit < bs.length; bit++ ) { + if ( bs.charAt(bit) == "1" && ba.charAt(bit) == "1" ) { + result += "1"; + } else { + result += "0"; + } + } + return ToInt32Decimal(result); +} +function Xor( s, a ) { + s = ToInt32( s ); + a = ToInt32( a ); + + var bs = ToInt32BitString( s ); + var ba = ToInt32BitString( a ); + + var result = ""; + + for ( var bit = 0; bit < bs.length; bit++ ) { + if ( (bs.charAt(bit) == "1" && ba.charAt(bit) == "0") || + (bs.charAt(bit) == "0" && ba.charAt(bit) == "1") + ) { + result += "1"; + } else { + result += "0"; + } + } + + return ToInt32Decimal(result); +} +function Or( s, a ) { + s = ToInt32( s ); + a = ToInt32( a ); + + var bs = ToInt32BitString( s ); + var ba = ToInt32BitString( a ); + + var result = ""; + + for ( var bit = 0; bit < bs.length; bit++ ) { + if ( bs.charAt(bit) == "1" || ba.charAt(bit) == "1" ) { + result += "1"; + } else { + result += "0"; + } + } + + return ToInt32Decimal(result); +} diff --git a/tests/auto/qml/parserstress/tests/ecma/Expressions/11.10-2.js b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.10-2.js new file mode 100644 index 0000000000..27bde196e0 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.10-2.js @@ -0,0 +1,269 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '11.10-2.js'; + +/** + File Name: 11.10-2.js + ECMA Section: 11.10-2 Binary Bitwise Operators: | + Description: + Semantics + + The production A : A @ B, where @ is one of the bitwise operators in the + productions &, ^, | , is evaluated as follows: + + 1. Evaluate A. + 2. Call GetValue(Result(1)). + 3. Evaluate B. + 4. Call GetValue(Result(3)). + 5. Call ToInt32(Result(2)). + 6. Call ToInt32(Result(4)). + 7. Apply the bitwise operator @ to Result(5) and Result(6). The result is + a signed 32 bit integer. + 8. Return Result(7). + + Author: christine@netscape.com + Date: 12 november 1997 +*/ +var SECTION = "11.10-2"; +var VERSION = "ECMA_1"; +startTest(); + +writeHeaderToLog( SECTION + " Binary Bitwise Operators: |"); + +var shiftexp = 0; +var addexp = 0; + +for ( shiftpow = 0; shiftpow < 33; shiftpow++ ) { + shiftexp += Math.pow( 2, shiftpow ); + + for ( addpow = 0; addpow < 33; addpow++ ) { + addexp += Math.pow(2, addpow); + + new TestCase( SECTION, + shiftexp + " | " + addexp, + Or( shiftexp, addexp ), + shiftexp | addexp ); + } +} + +test(); + +function ToInteger( n ) { + n = Number( n ); + var sign = ( n < 0 ) ? -1 : 1; + + if ( n != n ) { + return 0; + } + if ( Math.abs( n ) == 0 || Math.abs( n ) == Number.POSITIVE_INFINITY ) { + return n; + } + return ( sign * Math.floor(Math.abs(n)) ); +} +function ToInt32( n ) { + n = Number( n ); + var sign = ( n < 0 ) ? -1 : 1; + + if ( Math.abs( n ) == 0 || Math.abs( n ) == Number.POSITIVE_INFINITY) { + return 0; + } + + n = (sign * Math.floor( Math.abs(n) )) % Math.pow(2,32); + n = ( n >= Math.pow(2,31) ) ? n - Math.pow(2,32) : n; + + return ( n ); +} +function ToUint32( n ) { + n = Number( n ); + var sign = ( n < 0 ) ? -1 : 1; + + if ( Math.abs( n ) == 0 || Math.abs( n ) == Number.POSITIVE_INFINITY) { + return 0; + } + n = sign * Math.floor( Math.abs(n) ) + + n = n % Math.pow(2,32); + + if ( n < 0 ){ + n += Math.pow(2,32); + } + + return ( n ); +} +function ToUint16( n ) { + var sign = ( n < 0 ) ? -1 : 1; + + if ( Math.abs( n ) == 0 || Math.abs( n ) == Number.POSITIVE_INFINITY) { + return 0; + } + + n = ( sign * Math.floor( Math.abs(n) ) ) % Math.pow(2,16); + + if (n <0) { + n += Math.pow(2,16); + } + + return ( n ); +} +function Mask( b, n ) { + b = ToUint32BitString( b ); + b = b.substring( b.length - n ); + b = ToUint32Decimal( b ); + return ( b ); +} +function ToUint32BitString( n ) { + var b = ""; + for ( p = 31; p >=0; p-- ) { + if ( n >= Math.pow(2,p) ) { + b += "1"; + n -= Math.pow(2,p); + } else { + b += "0"; + } + } + return b; +} +function ToInt32BitString( n ) { + var b = ""; + var sign = ( n < 0 ) ? -1 : 1; + + b += ( sign == 1 ) ? "0" : "1"; + + for ( p = 30; p >=0; p-- ) { + if ( (sign == 1 ) ? sign * n >= Math.pow(2,p) : sign * n > Math.pow(2,p) ) { + b += ( sign == 1 ) ? "1" : "0"; + n -= sign * Math.pow( 2, p ); + } else { + b += ( sign == 1 ) ? "0" : "1"; + } + } + + return b; +} +function ToInt32Decimal( bin ) { + var r = 0; + var sign; + + if ( Number(bin.charAt(0)) == 0 ) { + sign = 1; + r = 0; + } else { + sign = -1; + r = -(Math.pow(2,31)); + } + + for ( var j = 0; j < 31; j++ ) { + r += Math.pow( 2, j ) * Number(bin.charAt(31-j)); + } + + return r; +} +function ToUint32Decimal( bin ) { + var r = 0; + + + for ( l = bin.length; l < 32; l++ ) { + bin = "0" + bin; + } + + for ( j = 0; j < 31; j++ ) { + r += Math.pow( 2, j ) * Number(bin.charAt(31-j)); + + } + + return r; +} +function And( s, a ) { + s = ToInt32( s ); + a = ToInt32( a ); + + var bs = ToInt32BitString( s ); + var ba = ToInt32BitString( a ); + + var result = ""; + + for ( var bit = 0; bit < bs.length; bit++ ) { + if ( bs.charAt(bit) == "1" && ba.charAt(bit) == "1" ) { + result += "1"; + } else { + result += "0"; + } + } + return ToInt32Decimal(result); +} +function Xor( s, a ) { + s = ToInt32( s ); + a = ToInt32( a ); + + var bs = ToInt32BitString( s ); + var ba = ToInt32BitString( a ); + + var result = ""; + + for ( var bit = 0; bit < bs.length; bit++ ) { + if ( (bs.charAt(bit) == "1" && ba.charAt(bit) == "0") || + (bs.charAt(bit) == "0" && ba.charAt(bit) == "1") + ) { + result += "1"; + } else { + result += "0"; + } + } + + return ToInt32Decimal(result); +} +function Or( s, a ) { + s = ToInt32( s ); + a = ToInt32( a ); + + var bs = ToInt32BitString( s ); + var ba = ToInt32BitString( a ); + + var result = ""; + + for ( var bit = 0; bit < bs.length; bit++ ) { + if ( bs.charAt(bit) == "1" || ba.charAt(bit) == "1" ) { + result += "1"; + } else { + result += "0"; + } + } + + return ToInt32Decimal(result); +} diff --git a/tests/auto/qml/parserstress/tests/ecma/Expressions/11.10-3.js b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.10-3.js new file mode 100644 index 0000000000..3da6963255 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.10-3.js @@ -0,0 +1,268 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '11.10-3.js'; + +/** + File Name: 11.10-3.js + ECMA Section: 11.10-3 Binary Bitwise Operators: ^ + Description: + Semantics + + The production A : A @ B, where @ is one of the bitwise operators in the + productions &, ^, | , is evaluated as follows: + + 1. Evaluate A. + 2. Call GetValue(Result(1)). + 3. Evaluate B. + 4. Call GetValue(Result(3)). + 5. Call ToInt32(Result(2)). + 6. Call ToInt32(Result(4)). + 7. Apply the bitwise operator @ to Result(5) and Result(6). The result is + a signed 32 bit integer. + 8. Return Result(7). + + Author: christine@netscape.com + Date: 12 november 1997 +*/ +var SECTION = "11.10-3"; +var VERSION = "ECMA_1"; +startTest(); + +writeHeaderToLog( SECTION + " Binary Bitwise Operators: ^"); + +var shiftexp = 0; +var addexp = 0; + +for ( shiftpow = 0; shiftpow < 33; shiftpow++ ) { + shiftexp += Math.pow( 2, shiftpow ); + + for ( addpow = 0; addpow < 33; addpow++ ) { + addexp += Math.pow(2, addpow); + + new TestCase( SECTION, + shiftexp + " ^ " + addexp, + Xor( shiftexp, addexp ), + shiftexp ^ addexp ); + } +} + +test(); + +function ToInteger( n ) { + n = Number( n ); + var sign = ( n < 0 ) ? -1 : 1; + + if ( n != n ) { + return 0; + } + if ( Math.abs( n ) == 0 || Math.abs( n ) == Number.POSITIVE_INFINITY ) { + return n; + } + return ( sign * Math.floor(Math.abs(n)) ); +} +function ToInt32( n ) { + n = Number( n ); + var sign = ( n < 0 ) ? -1 : 1; + + if ( Math.abs( n ) == 0 || Math.abs( n ) == Number.POSITIVE_INFINITY) { + return 0; + } + + n = (sign * Math.floor( Math.abs(n) )) % Math.pow(2,32); + n = ( n >= Math.pow(2,31) ) ? n - Math.pow(2,32) : n; + + return ( n ); +} +function ToUint32( n ) { + n = Number( n ); + var sign = ( n < 0 ) ? -1 : 1; + + if ( Math.abs( n ) == 0 || Math.abs( n ) == Number.POSITIVE_INFINITY) { + return 0; + } + n = sign * Math.floor( Math.abs(n) ) + + n = n % Math.pow(2,32); + + if ( n < 0 ){ + n += Math.pow(2,32); + } + + return ( n ); +} +function ToUint16( n ) { + var sign = ( n < 0 ) ? -1 : 1; + + if ( Math.abs( n ) == 0 || Math.abs( n ) == Number.POSITIVE_INFINITY) { + return 0; + } + + n = ( sign * Math.floor( Math.abs(n) ) ) % Math.pow(2,16); + + if (n <0) { + n += Math.pow(2,16); + } + + return ( n ); +} +function Mask( b, n ) { + b = ToUint32BitString( b ); + b = b.substring( b.length - n ); + b = ToUint32Decimal( b ); + return ( b ); +} +function ToUint32BitString( n ) { + var b = ""; + for ( p = 31; p >=0; p-- ) { + if ( n >= Math.pow(2,p) ) { + b += "1"; + n -= Math.pow(2,p); + } else { + b += "0"; + } + } + return b; +} +function ToInt32BitString( n ) { + var b = ""; + var sign = ( n < 0 ) ? -1 : 1; + + b += ( sign == 1 ) ? "0" : "1"; + + for ( p = 30; p >=0; p-- ) { + if ( (sign == 1 ) ? sign * n >= Math.pow(2,p) : sign * n > Math.pow(2,p) ) { + b += ( sign == 1 ) ? "1" : "0"; + n -= sign * Math.pow( 2, p ); + } else { + b += ( sign == 1 ) ? "0" : "1"; + } + } + + return b; +} +function ToInt32Decimal( bin ) { + var r = 0; + var sign; + + if ( Number(bin.charAt(0)) == 0 ) { + sign = 1; + r = 0; + } else { + sign = -1; + r = -(Math.pow(2,31)); + } + + for ( var j = 0; j < 31; j++ ) { + r += Math.pow( 2, j ) * Number(bin.charAt(31-j)); + } + + return r; +} +function ToUint32Decimal( bin ) { + var r = 0; + + for ( l = bin.length; l < 32; l++ ) { + bin = "0" + bin; + } + + for ( j = 0; j < 31; j++ ) { + r += Math.pow( 2, j ) * Number(bin.charAt(31-j)); + + } + + return r; +} +function And( s, a ) { + s = ToInt32( s ); + a = ToInt32( a ); + + var bs = ToInt32BitString( s ); + var ba = ToInt32BitString( a ); + + var result = ""; + + for ( var bit = 0; bit < bs.length; bit++ ) { + if ( bs.charAt(bit) == "1" && ba.charAt(bit) == "1" ) { + result += "1"; + } else { + result += "0"; + } + } + return ToInt32Decimal(result); +} +function Xor( s, a ) { + s = ToInt32( s ); + a = ToInt32( a ); + + var bs = ToInt32BitString( s ); + var ba = ToInt32BitString( a ); + + var result = ""; + + for ( var bit = 0; bit < bs.length; bit++ ) { + if ( (bs.charAt(bit) == "1" && ba.charAt(bit) == "0") || + (bs.charAt(bit) == "0" && ba.charAt(bit) == "1") + ) { + result += "1"; + } else { + result += "0"; + } + } + + return ToInt32Decimal(result); +} +function Or( s, a ) { + s = ToInt32( s ); + a = ToInt32( a ); + + var bs = ToInt32BitString( s ); + var ba = ToInt32BitString( a ); + + var result = ""; + + for ( var bit = 0; bit < bs.length; bit++ ) { + if ( bs.charAt(bit) == "1" || ba.charAt(bit) == "1" ) { + result += "1"; + } else { + result += "0"; + } + } + + return ToInt32Decimal(result); +} diff --git a/tests/auto/qml/parserstress/tests/ecma/Expressions/11.12-1.js b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.12-1.js new file mode 100644 index 0000000000..ff131b672e --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.12-1.js @@ -0,0 +1,110 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '11.12-1.js'; + +/** + File Name: 11.12.js + ECMA Section: 11.12 Conditional Operator + Description: + Logi + + calORExpression ? AssignmentExpression : AssignmentExpression + + Semantics + + The production ConditionalExpression : + LogicalORExpression ? AssignmentExpression : AssignmentExpression + is evaluated as follows: + + 1. Evaluate LogicalORExpression. + 2. Call GetValue(Result(1)). + 3. Call ToBoolean(Result(2)). + 4. If Result(3) is false, go to step 8. + 5. Evaluate the first AssignmentExpression. + 6. Call GetValue(Result(5)). + 7. Return Result(6). + 8. Evaluate the second AssignmentExpression. + 9. Call GetValue(Result(8)). + 10. Return Result(9). + + Author: christine@netscape.com + Date: 12 november 1997 +*/ +var SECTION = "11.12"; +var VERSION = "ECMA_1"; +startTest(); + +writeHeaderToLog( SECTION + " Conditional operator( ? : )"); + +new TestCase( SECTION, + "true ? 'PASSED' : 'FAILED'", + "PASSED", + (true?"PASSED":"FAILED")); + +new TestCase( SECTION, + "false ? 'FAILED' : 'PASSED'", + "PASSED", + (false?"FAILED":"PASSED")); + +new TestCase( SECTION, + "1 ? 'PASSED' : 'FAILED'", + "PASSED", + (true?"PASSED":"FAILED")); + +new TestCase( SECTION, + "0 ? 'FAILED' : 'PASSED'", + "PASSED", + (false?"FAILED":"PASSED")); + +new TestCase( SECTION, + "-1 ? 'PASSED' : 'FAILED'", + "PASSED", + (true?"PASSED":"FAILED")); + +new TestCase( SECTION, + "NaN ? 'FAILED' : 'PASSED'", + "PASSED", + (Number.NaN?"FAILED":"PASSED")); + +new TestCase( SECTION, + "var VAR = true ? , : 'FAILED'", + "PASSED", + (VAR = true ? "PASSED" : "FAILED") ); + +test(); diff --git a/tests/auto/qml/parserstress/tests/ecma/Expressions/11.12-2-n.js b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.12-2-n.js new file mode 100644 index 0000000000..c2a1e894e0 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.12-2-n.js @@ -0,0 +1,74 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '11.12-2-n.js'; + +/** + File Name: 11.12-2-n.js + ECMA Section: 11.12 + Description: + + The grammar for a ConditionalExpression in ECMAScript is a little bit + different from that in C and Java, which each allow the second + subexpression to be an Expression but restrict the third expression to + be a ConditionalExpression. The motivation for this difference in + ECMAScript is to allow an assignment expression to be governed by either + arm of a conditional and to eliminate the confusing and fairly useless + case of a comma expression as the center expression. + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + +var SECTION = "11.12-2-n"; +var VERSION = "ECMA_1"; +startTest(); +writeHeaderToLog( SECTION + " Conditional operator ( ? : )"); + +// the following expression should be an error in JS. + +DESCRIPTION = "var MYVAR = true ? 'EXPR1', 'EXPR2' : 'EXPR3'; MYVAR"; +EXPECTED = "error"; + +new TestCase( SECTION, + "var MYVAR = true ? 'EXPR1', 'EXPR2' : 'EXPR3'; MYVAR", + "error", + eval("var MYVAR = true ? 'EXPR1', 'EXPR2' : 'EXPR3'; MYVAR") ); + +test(); + diff --git a/tests/auto/qml/parserstress/tests/ecma/Expressions/11.12-3.js b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.12-3.js new file mode 100644 index 0000000000..11dde79fb3 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.12-3.js @@ -0,0 +1,71 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '11.12-3.js'; + +/** + File Name: 11.12-3.js + ECMA Section: 11.12 + Description: + + The grammar for a ConditionalExpression in ECMAScript is a little bit + different from that in C and Java, which each allow the second + subexpression to be an Expression but restrict the third expression to + be a ConditionalExpression. The motivation for this difference in + ECMAScript is to allow an assignment expression to be governed by either + arm of a conditional and to eliminate the confusing and fairly useless + case of a comma expression as the center expression. + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + +var SECTION = "11.12-3"; +var VERSION = "ECMA_1"; +startTest(); +writeHeaderToLog( SECTION + " Conditional operator ( ? : )"); + +// the following expression should NOT be an error in JS. + +new TestCase( SECTION, + "var MYVAR = true ? ('FAIL1', 'PASSED') : 'FAIL2'; MYVAR", + "PASSED", + eval("var MYVAR = true ? ('FAIL1', 'PASSED') : 'FAIL2'; MYVAR")); + +test(); + diff --git a/tests/auto/qml/parserstress/tests/ecma/Expressions/11.12-4.js b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.12-4.js new file mode 100644 index 0000000000..861692c4e8 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.12-4.js @@ -0,0 +1,71 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '11.12-4.js'; + +/** + File Name: 11.12-4.js + ECMA Section: 11.12 + Description: + + The grammar for a ConditionalExpression in ECMAScript is a little bit + different from that in C and Java, which each allow the second + subexpression to be an Expression but restrict the third expression to + be a ConditionalExpression. The motivation for this difference in + ECMAScript is to allow an assignment expression to be governed by either + arm of a conditional and to eliminate the confusing and fairly useless + case of a comma expression as the center expression. + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + +var SECTION = "11.12-4"; +var VERSION = "ECMA_1"; +startTest(); +writeHeaderToLog( SECTION + " Conditional operator ( ? : )"); + +// the following expression should NOT be an error in JS. + +new TestCase( SECTION, + "true ? MYVAR1 = 'PASSED' : MYVAR1 = 'FAILED'; MYVAR1", + "PASSED", + eval("true ? MYVAR1 = 'PASSED' : MYVAR1 = 'FAILED'; MYVAR1") ); + +test(); + diff --git a/tests/auto/qml/parserstress/tests/ecma/Expressions/11.13.1.js b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.13.1.js new file mode 100644 index 0000000000..5e548a3e76 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.13.1.js @@ -0,0 +1,72 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '11.13.1.js'; + +/** + File Name: 11.13.1.js + ECMA Section: 11.13.1 Simple assignment + Description: + + 11.13.1 Simple Assignment ( = ) + + The production AssignmentExpression : + LeftHandSideExpression = AssignmentExpression is evaluated as follows: + + 1. Evaluate LeftHandSideExpression. + 2. Evaluate AssignmentExpression. + 3. Call GetValue(Result(2)). + 4. Call PutValue(Result(1), Result(3)). + 5. Return Result(3). + + Author: christine@netscape.com + Date: 12 november 1997 +*/ +var SECTION = "11.13.1"; +var VERSION = "ECMA_1"; +startTest(); + +writeHeaderToLog( SECTION + " Simple Assignment ( = )"); + +new TestCase( SECTION, + "SOMEVAR = true", + true, + SOMEVAR = true ); + +test(); + diff --git a/tests/auto/qml/parserstress/tests/ecma/Expressions/11.13.2-1.js b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.13.2-1.js new file mode 100644 index 0000000000..41402b77ce --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.13.2-1.js @@ -0,0 +1,231 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '11.13.2-1.js'; + +/** + File Name: 11.13.2-1.js + ECMA Section: 11.13.2 Compound Assignment: *= + Description: + + *= /= %= += -= <<= >>= >>>= &= ^= |= + + 11.13.2 Compound assignment ( op= ) + + The production AssignmentExpression : + LeftHandSideExpression @ = AssignmentExpression, where @ represents one of + the operators indicated above, is evaluated as follows: + + 1. Evaluate LeftHandSideExpression. + 2. Call GetValue(Result(1)). + 3. Evaluate AssignmentExpression. + 4. Call GetValue(Result(3)). + 5. Apply operator @ to Result(2) and Result(4). + 6. Call PutValue(Result(1), Result(5)). + 7. Return Result(5). + + Author: christine@netscape.com + Date: 12 november 1997 +*/ +var SECTION = "11.13.2-1"; +var VERSION = "ECMA_1"; +startTest(); + +writeHeaderToLog( SECTION + " Compound Assignment: *="); + + +// NaN cases + +new TestCase( SECTION, + "VAR1 = NaN; VAR2=1; VAR1 *= VAR2", + Number.NaN, + eval("VAR1 = Number.NaN; VAR2=1; VAR1 *= VAR2") ); + +new TestCase( SECTION, + "VAR1 = NaN; VAR2=1; VAR1 *= VAR2; VAR1", + Number.NaN, + eval("VAR1 = Number.NaN; VAR2=1; VAR1 *= VAR2; VAR1") ); + +// number cases +new TestCase( SECTION, + "VAR1 = 0; VAR2=1; VAR1 *= VAR2", + 0, + eval("VAR1 = 0; VAR2=1; VAR1 *= VAR2") ); + +new TestCase( SECTION, + "VAR1 = 0; VAR2=1; VAR1 *= VAR2;VAR1", + 0, + eval("VAR1 = 0; VAR2=1; VAR1 *= VAR2;VAR1") ); + +new TestCase( SECTION, + "VAR1 = 0xFF; VAR2 = 0xA, VAR1 *= VAR2", + 2550, + eval("VAR1 = 0XFF; VAR2 = 0XA, VAR1 *= VAR2") ); + +// special multiplication cases + +new TestCase( SECTION, + "VAR1 = 0; VAR2= Infinity; VAR1 *= VAR2", + Number.NaN, + eval("VAR1 = 0; VAR2 = Number.POSITIVE_INFINITY; VAR1 *= VAR2; VAR1") ); + +new TestCase( SECTION, + "VAR1 = -0; VAR2= Infinity; VAR1 *= VAR2", + Number.NaN, + eval("VAR1 = -0; VAR2 = Number.POSITIVE_INFINITY; VAR1 *= VAR2; VAR1") ); + +new TestCase( SECTION, + "VAR1 = -0; VAR2= -Infinity; VAR1 *= VAR2", + Number.NaN, + eval("VAR1 = -0; VAR2 = Number.NEGATIVE_INFINITY; VAR1 *= VAR2; VAR1") ); + +new TestCase( SECTION, + "VAR1 = 0; VAR2= -Infinity; VAR1 *= VAR2", + Number.NaN, + eval("VAR1 = 0; VAR2 = Number.NEGATIVE_INFINITY; VAR1 *= VAR2; VAR1") ); + +new TestCase( SECTION, + "VAR1 = 0; VAR2= Infinity; VAR2 *= VAR1", + Number.NaN, + eval("VAR1 = 0; VAR2 = Number.POSITIVE_INFINITY; VAR2 *= VAR1; VAR2") ); + +new TestCase( SECTION, + "VAR1 = -0; VAR2= Infinity; VAR2 *= VAR1", + Number.NaN, + eval("VAR1 = -0; VAR2 = Number.POSITIVE_INFINITY; VAR2 *= VAR1; VAR2") ); + +new TestCase( SECTION, + "VAR1 = -0; VAR2= -Infinity; VAR2 *= VAR1", + Number.NaN, + eval("VAR1 = -0; VAR2 = Number.NEGATIVE_INFINITY; VAR2 *= VAR1; VAR2") ); + +new TestCase( SECTION, + "VAR1 = 0; VAR2= -Infinity; VAR2 *= VAR1", + Number.NaN, + eval("VAR1 = 0; VAR2 = Number.NEGATIVE_INFINITY; VAR2 *= VAR1; VAR2") ); + +new TestCase( SECTION, + "VAR1 = Infinity; VAR2= Infinity; VAR1 *= VAR2", + Number.POSITIVE_INFINITY, + eval("VAR1 = Number.POSITIVE_INFINITY; VAR2 = Number.POSITIVE_INFINITY; VAR1 *= VAR2; VAR1") ); + +new TestCase( SECTION, + "VAR1 = Infinity; VAR2= -Infinity; VAR1 *= VAR2", + Number.NEGATIVE_INFINITY, + eval("VAR1 = Number.POSITIVE_INFINITY; VAR2 = Number.NEGATIVE_INFINITY; VAR1 *= VAR2; VAR1") ); + +new TestCase( SECTION, + "VAR1 =-Infinity; VAR2= Infinity; VAR1 *= VAR2", + Number.NEGATIVE_INFINITY, + eval("VAR1 = Number.NEGATIVE_INFINITY; VAR2 = Number.POSITIVE_INFINITY; VAR1 *= VAR2; VAR1") ); + +new TestCase( SECTION, + "VAR1 =-Infinity; VAR2=-Infinity; VAR1 *= VAR2", + Number.POSITIVE_INFINITY, + eval("VAR1 = Number.NEGATIVE_INFINITY; VAR2 = Number.NEGATIVE_INFINITY; VAR1 *= VAR2; VAR1") ); + +// string cases +new TestCase( SECTION, + "VAR1 = 10; VAR2 = '255', VAR1 *= VAR2", + 2550, + eval("VAR1 = 10; VAR2 = '255', VAR1 *= VAR2") ); + +new TestCase( SECTION, + "VAR1 = '255'; VAR2 = 10, VAR1 *= VAR2", + 2550, + eval("VAR1 = '255'; VAR2 = 10, VAR1 *= VAR2") ); + +new TestCase( SECTION, + "VAR1 = 10; VAR2 = '0XFF', VAR1 *= VAR2", + 2550, + eval("VAR1 = 10; VAR2 = '0XFF', VAR1 *= VAR2") ); + +new TestCase( SECTION, + "VAR1 = '0xFF'; VAR2 = 0xA, VAR1 *= VAR2", + 2550, + eval("VAR1 = '0XFF'; VAR2 = 0XA, VAR1 *= VAR2") ); + +new TestCase( SECTION, + "VAR1 = '10'; VAR2 = '255', VAR1 *= VAR2", + 2550, + eval("VAR1 = '10'; VAR2 = '255', VAR1 *= VAR2") ); + +new TestCase( SECTION, + "VAR1 = '10'; VAR2 = '0XFF', VAR1 *= VAR2", + 2550, + eval("VAR1 = '10'; VAR2 = '0XFF', VAR1 *= VAR2") ); + +new TestCase( SECTION, + "VAR1 = '0xFF'; VAR2 = 0xA, VAR1 *= VAR2", + 2550, + eval("VAR1 = '0XFF'; VAR2 = 0XA, VAR1 *= VAR2") ); + +// boolean cases +new TestCase( SECTION, + "VAR1 = true; VAR2 = false; VAR1 *= VAR2", + 0, + eval("VAR1 = true; VAR2 = false; VAR1 *= VAR2") ); + +new TestCase( SECTION, + "VAR1 = true; VAR2 = true; VAR1 *= VAR2", + 1, + eval("VAR1 = true; VAR2 = true; VAR1 *= VAR2") ); + +// object cases +new TestCase( SECTION, + "VAR1 = new Boolean(true); VAR2 = 10; VAR1 *= VAR2;VAR1", + 10, + eval("VAR1 = new Boolean(true); VAR2 = 10; VAR1 *= VAR2; VAR1") ); + +new TestCase( SECTION, + "VAR1 = new Number(11); VAR2 = 10; VAR1 *= VAR2; VAR1", + 110, + eval("VAR1 = new Number(11); VAR2 = 10; VAR1 *= VAR2; VAR1") ); + +new TestCase( SECTION, + "VAR1 = new Number(11); VAR2 = new Number(10); VAR1 *= VAR2", + 110, + eval("VAR1 = new Number(11); VAR2 = new Number(10); VAR1 *= VAR2") ); + +new TestCase( SECTION, + "VAR1 = new String('15'); VAR2 = new String('0xF'); VAR1 *= VAR2", + 225, + eval("VAR1 = String('15'); VAR2 = new String('0xF'); VAR1 *= VAR2") ); + +test(); + diff --git a/tests/auto/qml/parserstress/tests/ecma/Expressions/11.13.2-2.js b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.13.2-2.js new file mode 100644 index 0000000000..2d3b53630b --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.13.2-2.js @@ -0,0 +1,253 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '11.13.2-2.js'; + +/** + File Name: 11.13.2-2js + ECMA Section: 11.13.2 Compound Assignment: /= + Description: + + *= /= %= += -= <<= >>= >>>= &= ^= |= + + 11.13.2 Compound assignment ( op= ) + + The production AssignmentExpression : + LeftHandSideExpression @ = AssignmentExpression, where @ represents one of + the operators indicated above, is evaluated as follows: + + 1. Evaluate LeftHandSideExpression. + 2. Call GetValue(Result(1)). + 3. Evaluate AssignmentExpression. + 4. Call GetValue(Result(3)). + 5. Apply operator @ to Result(2) and Result(4). + 6. Call PutValue(Result(1), Result(5)). + 7. Return Result(5). + + Author: christine@netscape.com + Date: 12 november 1997 +*/ +var SECTION = "11.13.2-2"; +var VERSION = "ECMA_1"; +startTest(); + +writeHeaderToLog( SECTION + " Compound Assignment: /="); + + +// NaN cases + +new TestCase( SECTION, + "VAR1 = NaN; VAR2=1; VAR1 /= VAR2", + Number.NaN, + eval("VAR1 = Number.NaN; VAR2=1; VAR1 /= VAR2") ); + +new TestCase( SECTION, + "VAR1 = NaN; VAR2=1; VAR1 /= VAR2; VAR1", + Number.NaN, + eval("VAR1 = Number.NaN; VAR2=1; VAR1 /= VAR2; VAR1") ); + +new TestCase( SECTION, + "VAR1 = NaN; VAR2=0; VAR1 /= VAR2", + Number.NaN, + eval("VAR1 = Number.NaN; VAR2=0; VAR1 /= VAR2") ); + +new TestCase( SECTION, + "VAR1 = NaN; VAR2=0; VAR1 /= VAR2; VAR1", + Number.NaN, + eval("VAR1 = Number.NaN; VAR2=0; VAR1 /= VAR2; VAR1") ); + +new TestCase( SECTION, + "VAR1 = 0; VAR2=NaN; VAR1 /= VAR2", + Number.NaN, + eval("VAR1 = 0; VAR2=Number.NaN; VAR1 /= VAR2") ); + +new TestCase( SECTION, + "VAR1 = 0; VAR2=NaN; VAR1 /= VAR2; VAR1", + Number.NaN, + eval("VAR1 = 0; VAR2=Number.NaN; VAR1 /= VAR2; VAR1") ); + +// number cases +new TestCase( SECTION, + "VAR1 = 0; VAR2=1; VAR1 /= VAR2", + 0, + eval("VAR1 = 0; VAR2=1; VAR1 /= VAR2") ); + +new TestCase( SECTION, + "VAR1 = 0; VAR2=1; VAR1 /= VAR2;VAR1", + 0, + eval("VAR1 = 0; VAR2=1; VAR1 /= VAR2;VAR1") ); + +new TestCase( SECTION, + "VAR1 = 0xFF; VAR2 = 0xA, VAR1 /= VAR2", + 25.5, + eval("VAR1 = 0XFF; VAR2 = 0XA, VAR1 /= VAR2") ); + +// special division cases + +new TestCase( SECTION, + "VAR1 = 0; VAR2= Infinity; VAR1 /= VAR2", + 0, + eval("VAR1 = 0; VAR2 = Number.POSITIVE_INFINITY; VAR1 /= VAR2; VAR1") ); + +new TestCase( SECTION, + "VAR1 = -0; VAR2= Infinity; VAR1 /= VAR2", + 0, + eval("VAR1 = -0; VAR2 = Number.POSITIVE_INFINITY; VAR1 /= VAR2; VAR1") ); + +new TestCase( SECTION, + "VAR1 = -0; VAR2= -Infinity; VAR1 /= VAR2", + 0, + eval("VAR1 = -0; VAR2 = Number.NEGATIVE_INFINITY; VAR1 /= VAR2; VAR1") ); + +new TestCase( SECTION, + "VAR1 = 0; VAR2= -Infinity; VAR1 /= VAR2", + 0, + eval("VAR1 = 0; VAR2 = Number.NEGATIVE_INFINITY; VAR1 /= VAR2; VAR1") ); + +new TestCase( SECTION, + "VAR1 = 0; VAR2= Infinity; VAR2 /= VAR1", + Number.POSITIVE_INFINITY, + eval("VAR1 = 0; VAR2 = Number.POSITIVE_INFINITY; VAR2 /= VAR1; VAR2") ); + +new TestCase( SECTION, + "VAR1 = -0; VAR2= Infinity; VAR2 /= VAR1", + Number.NEGATIVE_INFINITY, + eval("VAR1 = -0; VAR2 = Number.POSITIVE_INFINITY; VAR2 /= VAR1; VAR2") ); + +new TestCase( SECTION, + "VAR1 = -0; VAR2= -Infinity; VAR2 /= VAR1", + Number.POSITIVE_INFINITY, + eval("VAR1 = -0; VAR2 = Number.NEGATIVE_INFINITY; VAR2 /= VAR1; VAR2") ); + +new TestCase( SECTION, + "VAR1 = 0; VAR2= -Infinity; VAR2 /= VAR1", + Number.NEGATIVE_INFINITY, + eval("VAR1 = 0; VAR2 = Number.NEGATIVE_INFINITY; VAR2 /= VAR1; VAR2") ); + +new TestCase( SECTION, + "VAR1 = Infinity; VAR2= Infinity; VAR1 /= VAR2", + Number.NaN, + eval("VAR1 = Number.POSITIVE_INFINITY; VAR2 = Number.POSITIVE_INFINITY; VAR1 /= VAR2; VAR1") ); + +new TestCase( SECTION, + "VAR1 = Infinity; VAR2= -Infinity; VAR1 /= VAR2", + Number.NaN, + eval("VAR1 = Number.POSITIVE_INFINITY; VAR2 = Number.NEGATIVE_INFINITY; VAR1 /= VAR2; VAR1") ); + +new TestCase( SECTION, + "VAR1 =-Infinity; VAR2= Infinity; VAR1 /= VAR2", + Number.NaN, + eval("VAR1 = Number.NEGATIVE_INFINITY; VAR2 = Number.POSITIVE_INFINITY; VAR1 /= VAR2; VAR1") ); + +new TestCase( SECTION, + "VAR1 =-Infinity; VAR2=-Infinity; VAR1 /= VAR2", + Number.NaN, + eval("VAR1 = Number.NEGATIVE_INFINITY; VAR2 = Number.NEGATIVE_INFINITY; VAR1 /= VAR2; VAR1") ); + +new TestCase( SECTION, + "VAR1 = 0; VAR2= 0; VAR1 /= VAR2", + Number.NaN, + eval("VAR1 = 0; VAR2 = 0; VAR1 /= VAR2; VAR1") ); + +new TestCase( SECTION, + "VAR1 = 0; VAR2= -0; VAR1 /= VAR2", + Number.NaN, + eval("VAR1 = 0; VAR2 = -0; VAR1 /= VAR2; VAR1") ); + +new TestCase( SECTION, + "VAR1 = -0; VAR2= 0; VAR1 /= VAR2", + Number.NaN, + eval("VAR1 = -0; VAR2 = 0; VAR1 /= VAR2; VAR1") ); + +new TestCase( SECTION, + "VAR1 = -0; VAR2= -0; VAR1 /= VAR2", + Number.NaN, + eval("VAR1 = -0; VAR2 = -0; VAR1 /= VAR2; VAR1") ); + +new TestCase( SECTION, + "VAR1 = 1; VAR2= 0; VAR1 /= VAR2", + Number.POSITIVE_INFINITY, + eval("VAR1 = 1; VAR2 = 0; VAR1 /= VAR2; VAR1") ); + +new TestCase( SECTION, + "VAR1 = 1; VAR2= -0; VAR1 /= VAR2", + Number.NEGATIVE_INFINITY, + eval("VAR1 = 1; VAR2 = -0; VAR1 /= VAR2; VAR1") ); + +new TestCase( SECTION, + "VAR1 = -1; VAR2= 0; VAR1 /= VAR2", + Number.NEGATIVE_INFINITY, + eval("VAR1 = -1; VAR2 = 0; VAR1 /= VAR2; VAR1") ); + +new TestCase( SECTION, + "VAR1 = -1; VAR2= -0; VAR1 /= VAR2", + Number.POSITIVE_INFINITY, + eval("VAR1 = -1; VAR2 = -0; VAR1 /= VAR2; VAR1") ); + +// string cases +new TestCase( SECTION, + "VAR1 = 1000; VAR2 = '10', VAR1 /= VAR2; VAR1", + 100, + eval("VAR1 = 1000; VAR2 = '10', VAR1 /= VAR2; VAR1") ); + +new TestCase( SECTION, + "VAR1 = '1000'; VAR2 = 10, VAR1 /= VAR2; VAR1", + 100, + eval("VAR1 = '1000'; VAR2 = 10, VAR1 /= VAR2; VAR1") ); +/* + new TestCase( SECTION, "VAR1 = 10; VAR2 = '0XFF', VAR1 /= VAR2", 2550, eval("VAR1 = 10; VAR2 = '0XFF', VAR1 /= VAR2") ); + new TestCase( SECTION, "VAR1 = '0xFF'; VAR2 = 0xA, VAR1 /= VAR2", 2550, eval("VAR1 = '0XFF'; VAR2 = 0XA, VAR1 /= VAR2") ); + + new TestCase( SECTION, "VAR1 = '10'; VAR2 = '255', VAR1 /= VAR2", 2550, eval("VAR1 = '10'; VAR2 = '255', VAR1 /= VAR2") ); + new TestCase( SECTION, "VAR1 = '10'; VAR2 = '0XFF', VAR1 /= VAR2", 2550, eval("VAR1 = '10'; VAR2 = '0XFF', VAR1 /= VAR2") ); + new TestCase( SECTION, "VAR1 = '0xFF'; VAR2 = 0xA, VAR1 /= VAR2", 2550, eval("VAR1 = '0XFF'; VAR2 = 0XA, VAR1 /= VAR2") ); + + // boolean cases + new TestCase( SECTION, "VAR1 = true; VAR2 = false; VAR1 /= VAR2", 0, eval("VAR1 = true; VAR2 = false; VAR1 /= VAR2") ); + new TestCase( SECTION, "VAR1 = true; VAR2 = true; VAR1 /= VAR2", 1, eval("VAR1 = true; VAR2 = true; VAR1 /= VAR2") ); + + // object cases + new TestCase( SECTION, "VAR1 = new Boolean(true); VAR2 = 10; VAR1 /= VAR2;VAR1", 10, eval("VAR1 = new Boolean(true); VAR2 = 10; VAR1 /= VAR2; VAR1") ); + new TestCase( SECTION, "VAR1 = new Number(11); VAR2 = 10; VAR1 /= VAR2; VAR1", 110, eval("VAR1 = new Number(11); VAR2 = 10; VAR1 /= VAR2; VAR1") ); + new TestCase( SECTION, "VAR1 = new Number(11); VAR2 = new Number(10); VAR1 /= VAR2", 110, eval("VAR1 = new Number(11); VAR2 = new Number(10); VAR1 /= VAR2") ); + new TestCase( SECTION, "VAR1 = new String('15'); VAR2 = new String('0xF'); VAR1 /= VAR2", 255, eval("VAR1 = String('15'); VAR2 = new String('0xF'); VAR1 /= VAR2") ); + +*/ + +test(); + diff --git a/tests/auto/qml/parserstress/tests/ecma/Expressions/11.13.2-3.js b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.13.2-3.js new file mode 100644 index 0000000000..c432934a30 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.13.2-3.js @@ -0,0 +1,300 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '11.13.2-3.js'; + +/** + File Name: 11.13.2-4.js + ECMA Section: 11.13.2 Compound Assignment: %= + Description: + + *= /= %= += -= <<= >>= >>>= &= ^= |= + + 11.13.2 Compound assignment ( op= ) + + The production AssignmentExpression : + LeftHandSideExpression @ = AssignmentExpression, where @ represents one of + the operators indicated above, is evaluated as follows: + + 1. Evaluate LeftHandSideExpression. + 2. Call GetValue(Result(1)). + 3. Evaluate AssignmentExpression. + 4. Call GetValue(Result(3)). + 5. Apply operator @ to Result(2) and Result(4). + 6. Call PutValue(Result(1), Result(5)). + 7. Return Result(5). + + Author: christine@netscape.com + Date: 12 november 1997 +*/ +var SECTION = "11.13.2-3"; +var VERSION = "ECMA_1"; +startTest(); + +writeHeaderToLog( SECTION + " Compound Assignment: +="); + +// If either operand is NaN, result is NaN + +new TestCase( SECTION, + "VAR1 = NaN; VAR2=1; VAR1 %= VAR2", + Number.NaN, + eval("VAR1 = Number.NaN; VAR2=1; VAR1 %= VAR2") ); + +new TestCase( SECTION, + "VAR1 = NaN; VAR2=1; VAR1 %= VAR2; VAR1", + Number.NaN, + eval("VAR1 = Number.NaN; VAR2=1; VAR1 %= VAR2; VAR1") ); + +new TestCase( SECTION, + "VAR1 = NaN; VAR2=0; VAR1 %= VAR2", + Number.NaN, + eval("VAR1 = Number.NaN; VAR2=0; VAR1 %= VAR2") ); + +new TestCase( SECTION, + "VAR1 = NaN; VAR2=0; VAR1 %= VAR2; VAR1", + Number.NaN, + eval("VAR1 = Number.NaN; VAR2=0; VAR1 %= VAR2; VAR1") ); + +new TestCase( SECTION, + "VAR1 = 0; VAR2=NaN; VAR1 %= VAR2", + Number.NaN, + eval("VAR1 = 0; VAR2=Number.NaN; VAR1 %= VAR2") ); + +new TestCase( SECTION, + "VAR1 = 0; VAR2=NaN; VAR1 %= VAR2; VAR1", + Number.NaN, + eval("VAR1 = 0; VAR2=Number.NaN; VAR1 %= VAR2; VAR1") ); + +// if the dividend is infinity or the divisor is zero or both, the result is NaN + +new TestCase( SECTION, + "VAR1 = Infinity; VAR2= Infinity; VAR1 %= VAR2; VAR1", + Number.NaN, + eval("VAR1 = Number.POSITIVE_INFINITY; VAR2 = Number.POSITIVE_INFINITY; VAR1 %= VAR2; VAR1") ); + +new TestCase( SECTION, + "VAR1 = Infinity; VAR2= -Infinity; VAR1 %= VAR2; VAR1", + Number.NaN, + eval("VAR1 = Number.POSITIVE_INFINITY; VAR2 = Number.NEGATIVE_INFINITY; VAR1 %= VAR2; VAR1") ); + +new TestCase( SECTION, + "VAR1 =-Infinity; VAR2= Infinity; VAR1 %= VAR2; VAR1", + Number.NaN, + eval("VAR1 = Number.NEGATIVE_INFINITY; VAR2 = Number.POSITIVE_INFINITY; VAR1 %= VAR2; VAR1") ); + +new TestCase( SECTION, + "VAR1 =-Infinity; VAR2=-Infinity; VAR1 %= VAR2; VAR1", + Number.NaN, + eval("VAR1 = Number.NEGATIVE_INFINITY; VAR2 = Number.NEGATIVE_INFINITY; VAR1 %= VAR2; VAR1") ); + +new TestCase( SECTION, + "VAR1 = 0; VAR2= Infinity; VAR2 %= VAR1", + Number.NaN, + eval("VAR1 = 0; VAR2 = Number.POSITIVE_INFINITY; VAR2 %= VAR1; VAR2") ); + +new TestCase( SECTION, + "VAR1 = -0; VAR2= Infinity; VAR2 %= VAR1", + Number.NaN, + eval("VAR1 = -0; VAR2 = Number.POSITIVE_INFINITY; VAR2 %= VAR1; VAR2") ); + +new TestCase( SECTION, + "VAR1 = -0; VAR2= -Infinity; VAR2 %= VAR1", + Number.NaN, + eval("VAR1 = -0; VAR2 = Number.NEGATIVE_INFINITY; VAR2 %= VAR1; VAR2") ); + +new TestCase( SECTION, + "VAR1 = 0; VAR2= -Infinity; VAR2 %= VAR1", + Number.NaN, + eval("VAR1 = 0; VAR2 = Number.NEGATIVE_INFINITY; VAR2 %= VAR1; VAR2") ); + +new TestCase( SECTION, + "VAR1 = 1; VAR2= Infinity; VAR2 %= VAR1", + Number.NaN, + eval("VAR1 = 1; VAR2 = Number.POSITIVE_INFINITY; VAR2 %= VAR1; VAR2") ); + +new TestCase( SECTION, + "VAR1 = -1; VAR2= Infinity; VAR2 %= VAR1", + Number.NaN, + eval("VAR1 = -1; VAR2 = Number.POSITIVE_INFINITY; VAR2 %= VAR1; VAR2") ); + +new TestCase( SECTION, + "VAR1 = -1; VAR2= -Infinity; VAR2 %= VAR1", + Number.NaN, + eval("VAR1 = -1; VAR2 = Number.NEGATIVE_INFINITY; VAR2 %= VAR1; VAR2") ); + +new TestCase( SECTION, + "VAR1 = 1; VAR2= -Infinity; VAR2 %= VAR1", + Number.NaN, + eval("VAR1 = 1; VAR2 = Number.NEGATIVE_INFINITY; VAR2 %= VAR1; VAR2") ); + +new TestCase( SECTION, + "VAR1 = 0; VAR2= 0; VAR1 %= VAR2", + Number.NaN, + eval("VAR1 = 0; VAR2 = 0; VAR1 %= VAR2; VAR1") ); + +new TestCase( SECTION, + "VAR1 = 0; VAR2= -0; VAR1 %= VAR2", + Number.NaN, + eval("VAR1 = 0; VAR2 = -0; VAR1 %= VAR2; VAR1") ); + +new TestCase( SECTION, + "VAR1 = -0; VAR2= 0; VAR1 %= VAR2", + Number.NaN, + eval("VAR1 = -0; VAR2 = 0; VAR1 %= VAR2; VAR1") ); + +new TestCase( SECTION, + "VAR1 = -0; VAR2= -0; VAR1 %= VAR2", + Number.NaN, + eval("VAR1 = -0; VAR2 = -0; VAR1 %= VAR2; VAR1") ); + +new TestCase( SECTION, + "VAR1 = 1; VAR2= 0; VAR1 %= VAR2", + Number.NaN, + eval("VAR1 = 1; VAR2 = 0; VAR1 %= VAR2; VAR1") ); + +new TestCase( SECTION, + "VAR1 = 1; VAR2= -0; VAR1 %= VAR2", + Number.NaN, + eval("VAR1 = 1; VAR2 = -0; VAR1 %= VAR2; VAR1") ); + +new TestCase( SECTION, + "VAR1 = -1; VAR2= 0; VAR1 %= VAR2", + Number.NaN, + eval("VAR1 = -1; VAR2 = 0; VAR1 %= VAR2; VAR1") ); + +new TestCase( SECTION, + "VAR1 = -1; VAR2= -0; VAR1 %= VAR2", + Number.NaN, + eval("VAR1 = -1; VAR2 = -0; VAR1 %= VAR2; VAR1") ); + +// if the dividend is finite and the divisor is an infinity, the result equals the dividend. + +new TestCase( SECTION, + "VAR1 = 0; VAR2= Infinity; VAR1 %= VAR2;VAR1", + 0, + eval("VAR1 = 0; VAR2 = Number.POSITIVE_INFINITY; VAR1 %= VAR2; VAR1") ); + +new TestCase( SECTION, + "VAR1 = -0; VAR2= Infinity; VAR1 %= VAR2;VAR1", + -0, + eval("VAR1 = -0; VAR2 = Number.POSITIVE_INFINITY; VAR1 %= VAR2; VAR1") ); + +new TestCase( SECTION, + "VAR1 = -0; VAR2= -Infinity; VAR1 %= VAR2;VAR1", + -0, + eval("VAR1 = -0; VAR2 = Number.NEGATIVE_INFINITY; VAR1 %= VAR2; VAR1") ); + +new TestCase( SECTION, + "VAR1 = 0; VAR2= -Infinity; VAR1 %= VAR2;VAR1", + 0, + eval("VAR1 = 0; VAR2 = Number.NEGATIVE_INFINITY; VAR1 %= VAR2; VAR1") ); + +new TestCase( SECTION, + "VAR1 = 1; VAR2= Infinity; VAR1 %= VAR2;VAR1", + 1, + eval("VAR1 = 1; VAR2 = Number.POSITIVE_INFINITY; VAR1 %= VAR2; VAR1") ); + +new TestCase( SECTION, + "VAR1 = -1; VAR2= Infinity; VAR1 %= VAR2;VAR1", + -1, + eval("VAR1 = -1; VAR2 = Number.POSITIVE_INFINITY; VAR1 %= VAR2; VAR1") ); + +new TestCase( SECTION, + "VAR1 = -1; VAR2= -Infinity; VAR1 %= VAR2;VAR1", + -1, + eval("VAR1 = -1; VAR2 = Number.NEGATIVE_INFINITY; VAR1 %= VAR2; VAR1") ); + +new TestCase( SECTION, + "VAR1 = 1; VAR2= -Infinity; VAR1 %= VAR2;VAR1", + 1, + eval("VAR1 = 1; VAR2 = Number.NEGATIVE_INFINITY; VAR1 %= VAR2; VAR1") ); + +// if the dividend is a zero and the divisor is finite, the result is the same as the dividend + +new TestCase( SECTION, + "VAR1 = 0; VAR2= 1; VAR1 %= VAR2; VAR1", + 0, + eval("VAR1 = 0; VAR2 = 1; VAR1 %= VAR2; VAR1") ); + +new TestCase( SECTION, + "VAR1 = -0; VAR2= 1; VAR1 %= VAR2; VAR1", + -0, + eval("VAR1 = -0; VAR2 = 1; VAR1 %= VAR2; VAR1") ); + +new TestCase( SECTION, + "VAR1 = -0; VAR2= -1; VAR1 %= VAR2; VAR1", + -0, + eval("VAR1 = -0; VAR2 = -1; VAR1 %= VAR2; VAR1") ); + +new TestCase( SECTION, + "VAR1 = 0; VAR2= -1; VAR1 %= VAR2; VAR1", + 0, + eval("VAR1 = 0; VAR2 = -1; VAR1 %= VAR2; VAR1") ); + +// string cases +new TestCase( SECTION, + "VAR1 = 1000; VAR2 = '10', VAR1 %= VAR2; VAR1", + 0, + eval("VAR1 = 1000; VAR2 = '10', VAR1 %= VAR2; VAR1") ); + +new TestCase( SECTION, + "VAR1 = '1000'; VAR2 = 10, VAR1 %= VAR2; VAR1", + 0, + eval("VAR1 = '1000'; VAR2 = 10, VAR1 %= VAR2; VAR1") ); +/* + new TestCase( SECTION, "VAR1 = 10; VAR2 = '0XFF', VAR1 %= VAR2", 2550, eval("VAR1 = 10; VAR2 = '0XFF', VAR1 %= VAR2") ); + new TestCase( SECTION, "VAR1 = '0xFF'; VAR2 = 0xA, VAR1 %= VAR2", 2550, eval("VAR1 = '0XFF'; VAR2 = 0XA, VAR1 %= VAR2") ); + + new TestCase( SECTION, "VAR1 = '10'; VAR2 = '255', VAR1 %= VAR2", 2550, eval("VAR1 = '10'; VAR2 = '255', VAR1 %= VAR2") ); + new TestCase( SECTION, "VAR1 = '10'; VAR2 = '0XFF', VAR1 %= VAR2", 2550, eval("VAR1 = '10'; VAR2 = '0XFF', VAR1 %= VAR2") ); + new TestCase( SECTION, "VAR1 = '0xFF'; VAR2 = 0xA, VAR1 %= VAR2", 2550, eval("VAR1 = '0XFF'; VAR2 = 0XA, VAR1 %= VAR2") ); + + // boolean cases + new TestCase( SECTION, "VAR1 = true; VAR2 = false; VAR1 %= VAR2", 0, eval("VAR1 = true; VAR2 = false; VAR1 %= VAR2") ); + new TestCase( SECTION, "VAR1 = true; VAR2 = true; VAR1 %= VAR2", 1, eval("VAR1 = true; VAR2 = true; VAR1 %= VAR2") ); + + // object cases + new TestCase( SECTION, "VAR1 = new Boolean(true); VAR2 = 10; VAR1 %= VAR2;VAR1", 10, eval("VAR1 = new Boolean(true); VAR2 = 10; VAR1 %= VAR2; VAR1") ); + new TestCase( SECTION, "VAR1 = new Number(11); VAR2 = 10; VAR1 %= VAR2; VAR1", 110, eval("VAR1 = new Number(11); VAR2 = 10; VAR1 %= VAR2; VAR1") ); + new TestCase( SECTION, "VAR1 = new Number(11); VAR2 = new Number(10); VAR1 %= VAR2", 110, eval("VAR1 = new Number(11); VAR2 = new Number(10); VAR1 %= VAR2") ); + new TestCase( SECTION, "VAR1 = new String('15'); VAR2 = new String('0xF'); VAR1 %= VAR2", 255, eval("VAR1 = String('15'); VAR2 = new String('0xF'); VAR1 %= VAR2") ); + +*/ + +test(); + diff --git a/tests/auto/qml/parserstress/tests/ecma/Expressions/11.13.2-4.js b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.13.2-4.js new file mode 100644 index 0000000000..8514dd8c9c --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.13.2-4.js @@ -0,0 +1,137 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '11.13.2-4.js'; + +/** + File Name: 11.13.2-4.js + ECMA Section: 11.13.2 Compound Assignment:+= + Description: + + *= /= %= += -= <<= >>= >>>= &= ^= |= + + 11.13.2 Compound assignment ( op= ) + + The production AssignmentExpression : + LeftHandSideExpression @ = AssignmentExpression, where @ represents one of + the operators indicated above, is evaluated as follows: + + 1. Evaluate LeftHandSideExpression. + 2. Call GetValue(Result(1)). + 3. Evaluate AssignmentExpression. + 4. Call GetValue(Result(3)). + 5. Apply operator @ to Result(2) and Result(4). + 6. Call PutValue(Result(1), Result(5)). + 7. Return Result(5). + + Author: christine@netscape.com + Date: 12 november 1997 +*/ +var SECTION = "11.13.2-4"; +var VERSION = "ECMA_1"; +startTest(); + +writeHeaderToLog( SECTION + " Compound Assignment: +="); + +// If either operand is NaN, result is NaN + +new TestCase( SECTION, "VAR1 = NaN; VAR2=1; VAR1 += VAR2", Number.NaN, eval("VAR1 = Number.NaN; VAR2=1; VAR1 += VAR2") ); +new TestCase( SECTION, "VAR1 = NaN; VAR2=1; VAR1 += VAR2; VAR1", Number.NaN, eval("VAR1 = Number.NaN; VAR2=1; VAR1 += VAR2; VAR1") ); +new TestCase( SECTION, "VAR1 = NaN; VAR2=0; VAR1 += VAR2", Number.NaN, eval("VAR1 = Number.NaN; VAR2=0; VAR1 += VAR2") ); +new TestCase( SECTION, "VAR1 = NaN; VAR2=0; VAR1 += VAR2; VAR1", Number.NaN, eval("VAR1 = Number.NaN; VAR2=0; VAR1 += VAR2; VAR1") ); +new TestCase( SECTION, "VAR1 = 0; VAR2=NaN; VAR1 += VAR2", Number.NaN, eval("VAR1 = 0; VAR2=Number.NaN; VAR1 += VAR2") ); +new TestCase( SECTION, "VAR1 = 0; VAR2=NaN; VAR1 += VAR2; VAR1", Number.NaN, eval("VAR1 = 0; VAR2=Number.NaN; VAR1 += VAR2; VAR1") ); + +// the sum of two Infinities the same sign is the infinity of that sign +// the sum of two Infinities of opposite sign is NaN + +new TestCase( SECTION, "VAR1 = Infinity; VAR2= Infinity; VAR1 += VAR2; VAR1", Number.POSITIVE_INFINITY, eval("VAR1 = Number.POSITIVE_INFINITY; VAR2 = Number.POSITIVE_INFINITY; VAR1 += VAR2; VAR1") ); +new TestCase( SECTION, "VAR1 = Infinity; VAR2= -Infinity; VAR1 += VAR2; VAR1", Number.NaN, eval("VAR1 = Number.POSITIVE_INFINITY; VAR2 = Number.NEGATIVE_INFINITY; VAR1 += VAR2; VAR1") ); +new TestCase( SECTION, "VAR1 =-Infinity; VAR2= Infinity; VAR1 += VAR2; VAR1", Number.NaN, eval("VAR1 = Number.NEGATIVE_INFINITY; VAR2 = Number.POSITIVE_INFINITY; VAR1 += VAR2; VAR1") ); +new TestCase( SECTION, "VAR1 =-Infinity; VAR2=-Infinity; VAR1 += VAR2; VAR1", Number.NEGATIVE_INFINITY, eval("VAR1 = Number.NEGATIVE_INFINITY; VAR2 = Number.NEGATIVE_INFINITY; VAR1 += VAR2; VAR1") ); + +// the sum of an infinity and a finite value is equal to the infinite operand + +new TestCase( SECTION, "VAR1 = 0; VAR2= Infinity; VAR1 += VAR2;VAR1", Number.POSITIVE_INFINITY, eval("VAR1 = 0; VAR2 = Number.POSITIVE_INFINITY; VAR1 += VAR2; VAR1") ); +new TestCase( SECTION, "VAR1 = -0; VAR2= Infinity; VAR1 += VAR2;VAR1", Number.POSITIVE_INFINITY, eval("VAR1 = -0; VAR2 = Number.POSITIVE_INFINITY; VAR1 += VAR2; VAR1") ); +new TestCase( SECTION, "VAR1 = -0; VAR2= -Infinity; VAR1 += VAR2;VAR1", Number.NEGATIVE_INFINITY, eval("VAR1 = -0; VAR2 = Number.NEGATIVE_INFINITY; VAR1 += VAR2; VAR1") ); +new TestCase( SECTION, "VAR1 = 0; VAR2= -Infinity; VAR1 += VAR2;VAR1", Number.NEGATIVE_INFINITY, eval("VAR1 = 0; VAR2 = Number.NEGATIVE_INFINITY; VAR1 += VAR2; VAR1") ); + +// the sum of two negative zeros is -0. the sum of two positive zeros, or of two zeros of opposite sign, is +0 + +new TestCase( SECTION, "VAR1 = 0; VAR2= 0; VAR1 += VAR2", 0, eval("VAR1 = 0; VAR2 = 0; VAR1 += VAR2; VAR1") ); +new TestCase( SECTION, "VAR1 = 0; VAR2= -0; VAR1 += VAR2", 0, eval("VAR1 = 0; VAR2 = -0; VAR1 += VAR2; VAR1") ); +new TestCase( SECTION, "VAR1 = -0; VAR2= 0; VAR1 += VAR2", 0, eval("VAR1 = -0; VAR2 = 0; VAR1 += VAR2; VAR1") ); +new TestCase( SECTION, "VAR1 = -0; VAR2= -0; VAR1 += VAR2", -0, eval("VAR1 = -0; VAR2 = -0; VAR1 += VAR2; VAR1") ); + +// the sum of a zero and a nonzero finite value is eqal to the nonzero operand + +new TestCase( SECTION, "VAR1 = 0; VAR2= 1; VAR2 += VAR1; VAR2", 1, eval("VAR1 = 0; VAR2 = 1; VAR2 += VAR1; VAR2") ); +new TestCase( SECTION, "VAR1 = -0; VAR2= 1; VAR2 += VAR1; VAR2", 1, eval("VAR1 = -0; VAR2 = 1; VAR2 += VAR1; VAR2") ); +new TestCase( SECTION, "VAR1 = -0; VAR2= -1; VAR2 += VAR1; VAR2", -1, eval("VAR1 = -0; VAR2 = -1; VAR2 += VAR1; VAR2") ); +new TestCase( SECTION, "VAR1 = 0; VAR2= -1; VAR2 += VAR1; VAR2", -1, eval("VAR1 = 0; VAR2 = -1; VAR2 += VAR1; VAR2") ); + +// the sum of a zero and a nozero finite value is equal to the nonzero operand. +new TestCase( SECTION, "VAR1 = 0; VAR2=1; VAR1 += VAR2", 1, eval("VAR1 = 0; VAR2=1; VAR1 += VAR2") ); +new TestCase( SECTION, "VAR1 = 0; VAR2=1; VAR1 += VAR2;VAR1", 1, eval("VAR1 = 0; VAR2=1; VAR1 += VAR2;VAR1") ); + +// the sum of two nonzero finite values of the same magnitude and opposite sign is +0 +new TestCase( SECTION, "VAR1 = Number.MAX_VALUE; VAR2= -Number.MAX_VALUE; VAR1 += VAR2; VAR1", 0, eval("VAR1 = Number.MAX_VALUE; VAR2= -Number.MAX_VALUE; VAR1 += VAR2; VAR1") ); +new TestCase( SECTION, "VAR1 = Number.MIN_VALUE; VAR2= -Number.MIN_VALUE; VAR1 += VAR2; VAR1", 0, eval("VAR1 = Number.MIN_VALUE; VAR2= -Number.MIN_VALUE; VAR1 += VAR2; VAR1") ); + +/* + new TestCase( SECTION, "VAR1 = 10; VAR2 = '0XFF', VAR1 += VAR2", 2550, eval("VAR1 = 10; VAR2 = '0XFF', VAR1 += VAR2") ); + new TestCase( SECTION, "VAR1 = '0xFF'; VAR2 = 0xA, VAR1 += VAR2", 2550, eval("VAR1 = '0XFF'; VAR2 = 0XA, VAR1 += VAR2") ); + + new TestCase( SECTION, "VAR1 = '10'; VAR2 = '255', VAR1 += VAR2", 2550, eval("VAR1 = '10'; VAR2 = '255', VAR1 += VAR2") ); + new TestCase( SECTION, "VAR1 = '10'; VAR2 = '0XFF', VAR1 += VAR2", 2550, eval("VAR1 = '10'; VAR2 = '0XFF', VAR1 += VAR2") ); + new TestCase( SECTION, "VAR1 = '0xFF'; VAR2 = 0xA, VAR1 += VAR2", 2550, eval("VAR1 = '0XFF'; VAR2 = 0XA, VAR1 += VAR2") ); + + // boolean cases + new TestCase( SECTION, "VAR1 = true; VAR2 = false; VAR1 += VAR2", 0, eval("VAR1 = true; VAR2 = false; VAR1 += VAR2") ); + new TestCase( SECTION, "VAR1 = true; VAR2 = true; VAR1 += VAR2", 1, eval("VAR1 = true; VAR2 = true; VAR1 += VAR2") ); + + // object cases + new TestCase( SECTION, "VAR1 = new Boolean(true); VAR2 = 10; VAR1 += VAR2;VAR1", 10, eval("VAR1 = new Boolean(true); VAR2 = 10; VAR1 += VAR2; VAR1") ); + new TestCase( SECTION, "VAR1 = new Number(11); VAR2 = 10; VAR1 += VAR2; VAR1", 110, eval("VAR1 = new Number(11); VAR2 = 10; VAR1 += VAR2; VAR1") ); + new TestCase( SECTION, "VAR1 = new Number(11); VAR2 = new Number(10); VAR1 += VAR2", 110, eval("VAR1 = new Number(11); VAR2 = new Number(10); VAR1 += VAR2") ); + new TestCase( SECTION, "VAR1 = new String('15'); VAR2 = new String('0xF'); VAR1 += VAR2", 255, eval("VAR1 = String('15'); VAR2 = new String('0xF'); VAR1 += VAR2") ); + +*/ + +test(); diff --git a/tests/auto/qml/parserstress/tests/ecma/Expressions/11.13.2-5.js b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.13.2-5.js new file mode 100644 index 0000000000..99d227b80f --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.13.2-5.js @@ -0,0 +1,137 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '11.13.2-5.js'; + +/** + File Name: 11.13.2-5.js + ECMA Section: 11.13.2 Compound Assignment: -= + Description: + + *= /= %= -= -= <<= >>= >>>= &= ^= |= + + 11.13.2 Compound assignment ( op= ) + + The production AssignmentExpression : + LeftHandSideExpression @ = AssignmentExpression, where @ represents one of + the operators indicated above, is evaluated as follows: + + 1. Evaluate LeftHandSideExpression. + 2. Call GetValue(Result(1)). + 3. Evaluate AssignmentExpression. + 4. Call GetValue(Result(3)). + 5. Apply operator @ to Result(2) and Result(4). + 6. Call PutValue(Result(1), Result(5)). + 7. Return Result(5). + + Author: christine@netscape.com + Date: 12 november 1997 +*/ +var SECTION = "11.13.2-5"; +var VERSION = "ECMA_1"; +startTest(); + +writeHeaderToLog( SECTION + " Compound Assignment: -="); + +// If either operand is NaN, result is NaN + +new TestCase( SECTION, "VAR1 = NaN; VAR2=1; VAR1 -= VAR2", Number.NaN, eval("VAR1 = Number.NaN; VAR2=1; VAR1 -= VAR2") ); +new TestCase( SECTION, "VAR1 = NaN; VAR2=1; VAR1 -= VAR2; VAR1", Number.NaN, eval("VAR1 = Number.NaN; VAR2=1; VAR1 -= VAR2; VAR1") ); +new TestCase( SECTION, "VAR1 = NaN; VAR2=0; VAR1 -= VAR2", Number.NaN, eval("VAR1 = Number.NaN; VAR2=0; VAR1 -= VAR2") ); +new TestCase( SECTION, "VAR1 = NaN; VAR2=0; VAR1 -= VAR2; VAR1", Number.NaN, eval("VAR1 = Number.NaN; VAR2=0; VAR1 -= VAR2; VAR1") ); +new TestCase( SECTION, "VAR1 = 0; VAR2=NaN; VAR1 -= VAR2", Number.NaN, eval("VAR1 = 0; VAR2=Number.NaN; VAR1 -= VAR2") ); +new TestCase( SECTION, "VAR1 = 0; VAR2=NaN; VAR1 -= VAR2; VAR1", Number.NaN, eval("VAR1 = 0; VAR2=Number.NaN; VAR1 -= VAR2; VAR1") ); + +// the sum of two Infinities the same sign is the infinity of that sign +// the sum of two Infinities of opposite sign is NaN + +new TestCase( SECTION, "VAR1 = Infinity; VAR2= Infinity; VAR1 -= VAR2; VAR1", Number.NaN, eval("VAR1 = Number.POSITIVE_INFINITY; VAR2 = Number.POSITIVE_INFINITY; VAR1 -= VAR2; VAR1") ); +new TestCase( SECTION, "VAR1 = Infinity; VAR2= -Infinity; VAR1 -= VAR2; VAR1", Number.POSITIVE_INFINITY, eval("VAR1 = Number.POSITIVE_INFINITY; VAR2 = Number.NEGATIVE_INFINITY; VAR1 -= VAR2; VAR1") ); +new TestCase( SECTION, "VAR1 =-Infinity; VAR2= Infinity; VAR1 -= VAR2; VAR1", Number.NEGATIVE_INFINITY, eval("VAR1 = Number.NEGATIVE_INFINITY; VAR2 = Number.POSITIVE_INFINITY; VAR1 -= VAR2; VAR1") ); +new TestCase( SECTION, "VAR1 =-Infinity; VAR2=-Infinity; VAR1 -= VAR2; VAR1", Number.NaN, eval("VAR1 = Number.NEGATIVE_INFINITY; VAR2 = Number.NEGATIVE_INFINITY; VAR1 -= VAR2; VAR1") ); + +// the sum of an infinity and a finite value is equal to the infinite operand + +new TestCase( SECTION, "VAR1 = 0; VAR2= Infinity; VAR1 -= VAR2;VAR1", Number.NEGATIVE_INFINITY, eval("VAR1 = 0; VAR2 = Number.POSITIVE_INFINITY; VAR1 -= VAR2; VAR1") ); +new TestCase( SECTION, "VAR1 = -0; VAR2= Infinity; VAR1 -= VAR2;VAR1", Number.NEGATIVE_INFINITY, eval("VAR1 = -0; VAR2 = Number.POSITIVE_INFINITY; VAR1 -= VAR2; VAR1") ); +new TestCase( SECTION, "VAR1 = 0; VAR2= -Infinity; VAR1 -= VAR2;VAR1", Number.POSITIVE_INFINITY, eval("VAR1 = 0; VAR2 = Number.NEGATIVE_INFINITY; VAR1 -= VAR2; VAR1") ); +new TestCase( SECTION, "VAR1 = -0; VAR2= -Infinity; VAR1 -= VAR2;VAR1", Number.POSITIVE_INFINITY, eval("VAR1 = -0; VAR2 = Number.NEGATIVE_INFINITY; VAR1 -= VAR2; VAR1") ); + +// the sum of two negative zeros is -0. the sum of two positive zeros, or of two zeros of opposite sign, is +0 + +new TestCase( SECTION, "VAR1 = 0; VAR2= -0; VAR1 -= VAR2", 0, eval("VAR1 = 0; VAR2 = 0; VAR1 -= VAR2; VAR1") ); +new TestCase( SECTION, "VAR1 = 0; VAR2= 0; VAR1 -= VAR2", 0, eval("VAR1 = 0; VAR2 = -0; VAR1 -= VAR2; VAR1") ); +new TestCase( SECTION, "VAR1 = -0; VAR2= -0; VAR1 -= VAR2", 0, eval("VAR1 = -0; VAR2 = 0; VAR1 -= VAR2; VAR1") ); +new TestCase( SECTION, "VAR1 = -0; VAR2= 0; VAR1 -= VAR2", -0, eval("VAR1 = -0; VAR2 = -0; VAR1 -= VAR2; VAR1") ); + +// the sum of a zero and a nonzero finite value is eqal to the nonzero operand + +new TestCase( SECTION, "VAR1 = 0; VAR2= -1; VAR1 -= VAR2; VAR1", 1, eval("VAR1 = 0; VAR2 = -1; VAR1 -= VAR2; VAR1") ); +new TestCase( SECTION, "VAR1 = -0; VAR2= -1; VAR1 -= VAR2; VAR1", 1, eval("VAR1 = -0; VAR2 = -1; VAR1 -= VAR2; VAR1") ); +new TestCase( SECTION, "VAR1 = -0; VAR2= 1; VAR1 -= VAR2; VAR1", -1, eval("VAR1 = -0; VAR2 = 1; VAR1 -= VAR2; VAR1") ); +new TestCase( SECTION, "VAR1 = 0; VAR2= 1; VAR1 -= VAR2; VAR1", -1, eval("VAR1 = 0; VAR2 = 1; VAR1 -= VAR2; VAR1") ); + +// the sum of a zero and a nozero finite value is equal to the nonzero operand. +new TestCase( SECTION, "VAR1 = 0; VAR2=-1; VAR1 -= VAR2", 1, eval("VAR1 = 0; VAR2=-1; VAR1 -= VAR2;VAR1") ); +new TestCase( SECTION, "VAR1 = 0; VAR2=-1; VAR1 -= VAR2;VAR1", 1, eval("VAR1 = 0; VAR2=-1; VAR1 -= VAR2;VAR1") ); + +// the sum of two nonzero finite values of the same magnitude and opposite sign is +0 +new TestCase( SECTION, "VAR1 = Number.MAX_VALUE; VAR2= Number.MAX_VALUE; VAR1 -= VAR2; VAR1", 0, eval("VAR1 = Number.MAX_VALUE; VAR2= Number.MAX_VALUE; VAR1 -= VAR2; VAR1") ); +new TestCase( SECTION, "VAR1 = Number.MIN_VALUE; VAR2= Number.MIN_VALUE; VAR1 -= VAR2; VAR1", 0, eval("VAR1 = Number.MIN_VALUE; VAR2= Number.MIN_VALUE; VAR1 -= VAR2; VAR1") ); + +/* + new TestCase( SECTION, "VAR1 = 10; VAR2 = '0XFF', VAR1 -= VAR2", 2550, eval("VAR1 = 10; VAR2 = '0XFF', VAR1 -= VAR2") ); + new TestCase( SECTION, "VAR1 = '0xFF'; VAR2 = 0xA, VAR1 -= VAR2", 2550, eval("VAR1 = '0XFF'; VAR2 = 0XA, VAR1 -= VAR2") ); + + new TestCase( SECTION, "VAR1 = '10'; VAR2 = '255', VAR1 -= VAR2", 2550, eval("VAR1 = '10'; VAR2 = '255', VAR1 -= VAR2") ); + new TestCase( SECTION, "VAR1 = '10'; VAR2 = '0XFF', VAR1 -= VAR2", 2550, eval("VAR1 = '10'; VAR2 = '0XFF', VAR1 -= VAR2") ); + new TestCase( SECTION, "VAR1 = '0xFF'; VAR2 = 0xA, VAR1 -= VAR2", 2550, eval("VAR1 = '0XFF'; VAR2 = 0XA, VAR1 -= VAR2") ); + + // boolean cases + new TestCase( SECTION, "VAR1 = true; VAR2 = false; VAR1 -= VAR2", 0, eval("VAR1 = true; VAR2 = false; VAR1 -= VAR2") ); + new TestCase( SECTION, "VAR1 = true; VAR2 = true; VAR1 -= VAR2", 1, eval("VAR1 = true; VAR2 = true; VAR1 -= VAR2") ); + + // object cases + new TestCase( SECTION, "VAR1 = new Boolean(true); VAR2 = 10; VAR1 -= VAR2;VAR1", 10, eval("VAR1 = new Boolean(true); VAR2 = 10; VAR1 -= VAR2; VAR1") ); + new TestCase( SECTION, "VAR1 = new Number(11); VAR2 = 10; VAR1 -= VAR2; VAR1", 110, eval("VAR1 = new Number(11); VAR2 = 10; VAR1 -= VAR2; VAR1") ); + new TestCase( SECTION, "VAR1 = new Number(11); VAR2 = new Number(10); VAR1 -= VAR2", 110, eval("VAR1 = new Number(11); VAR2 = new Number(10); VAR1 -= VAR2") ); + new TestCase( SECTION, "VAR1 = new String('15'); VAR2 = new String('0xF'); VAR1 -= VAR2", 255, eval("VAR1 = String('15'); VAR2 = new String('0xF'); VAR1 -= VAR2") ); + +*/ + +test(); diff --git a/tests/auto/qml/parserstress/tests/ecma/Expressions/11.13.js b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.13.js new file mode 100644 index 0000000000..bf5f172d36 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.13.js @@ -0,0 +1,86 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '11.13.js'; + +/** + File Name: 11.12.js + ECMA Section: 11.12 Conditional Operator + Description: + Logi + + calORExpression ? AssignmentExpression : AssignmentExpression + + Semantics + + The production ConditionalExpression : + LogicalORExpression ? AssignmentExpression : AssignmentExpression + is evaluated as follows: + + 1. Evaluate LogicalORExpression. + 2. Call GetValue(Result(1)). + 3. Call ToBoolean(Result(2)). + 4. If Result(3) is false, go to step 8. + 5. Evaluate the first AssignmentExpression. + 6. Call GetValue(Result(5)). + 7. Return Result(6). + 8. Evaluate the second AssignmentExpression. + 9. Call GetValue(Result(8)). + 10. Return Result(9). + + Author: christine@netscape.com + Date: 12 november 1997 +*/ +var SECTION = "11.12"; +var VERSION = "ECMA_1"; +startTest(); + +writeHeaderToLog( SECTION + " Conditional operator( ? : )"); + +new TestCase( SECTION, "true ? 'PASSED' : 'FAILED'", "PASSED", (true?"PASSED":"FAILED")); +new TestCase( SECTION, "false ? 'FAILED' : 'PASSED'", "PASSED", (false?"FAILED":"PASSED")); + +new TestCase( SECTION, "1 ? 'PASSED' : 'FAILED'", "PASSED", (true?"PASSED":"FAILED")); +new TestCase( SECTION, "0 ? 'FAILED' : 'PASSED'", "PASSED", (false?"FAILED":"PASSED")); +new TestCase( SECTION, "-1 ? 'PASSED' : 'FAILED'", "PASSED", (true?"PASSED":"FAILED")); + +new TestCase( SECTION, "NaN ? 'FAILED' : 'PASSED'", "PASSED", (Number.NaN?"FAILED":"PASSED")); + +new TestCase( SECTION, "var VAR = true ? , : 'FAILED'", "PASSED", (VAR = true ? "PASSED" : "FAILED") ); + +test(); diff --git a/tests/auto/qml/parserstress/tests/ecma/Expressions/11.14-1.js b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.14-1.js new file mode 100644 index 0000000000..c2f30afb6a --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.14-1.js @@ -0,0 +1,73 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '11.14-1.js'; + +/** + File Name: 11.14-1.js + ECMA Section: 11.14 Comma operator (,) + Description: + Expression : + + AssignmentExpression + Expression , AssignmentExpression + + Semantics + + The production Expression : Expression , AssignmentExpression is evaluated as follows: + + 1. Evaluate Expression. + 2. Call GetValue(Result(1)). + 3. Evaluate AssignmentExpression. + 4. Call GetValue(Result(3)). + 5. Return Result(4). + + Author: christine@netscape.com + Date: 12 november 1997 +*/ +var SECTION = "11.14-1"; +var VERSION = "ECMA_1"; +startTest(); + +writeHeaderToLog( SECTION + " Comma operator (,)"); + +new TestCase( SECTION, "true, false", false, eval("true, false") ); +new TestCase( SECTION, "VAR1=true, VAR2=false", false, eval("VAR1=true, VAR2=false") ); +new TestCase( SECTION, "VAR1=true, VAR2=false;VAR1", true, eval("VAR1=true, VAR2=false; VAR1") ); + +test(); diff --git a/tests/auto/qml/parserstress/tests/ecma/Expressions/11.2.1-1.js b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.2.1-1.js new file mode 100644 index 0000000000..91e25b01f1 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.2.1-1.js @@ -0,0 +1,272 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '11.2.1-1.js'; + +/** + File Name: 11.2.1-1.js + ECMA Section: 11.2.1 Property Accessors + Description: + + Properties are accessed by name, using either the dot notation: + MemberExpression . Identifier + CallExpression . Identifier + + or the bracket notation: MemberExpression [ Expression ] + CallExpression [ Expression ] + + The dot notation is explained by the following syntactic conversion: + MemberExpression . Identifier + is identical in its behavior to + MemberExpression [ ] + and similarly + CallExpression . Identifier + is identical in its behavior to + CallExpression [ ] + where is a string literal containing the same sequence + of characters as the Identifier. + + The production MemberExpression : MemberExpression [ Expression ] is + evaluated as follows: + + 1. Evaluate MemberExpression. + 2. Call GetValue(Result(1)). + 3. Evaluate Expression. + 4. Call GetValue(Result(3)). + 5. Call ToObject(Result(2)). + 6. Call ToString(Result(4)). + 7. Return a value of type Reference whose base object is Result(5) and + whose property name is Result(6). + + The production CallExpression : CallExpression [ Expression ] is evaluated + in exactly the same manner, except that the contained CallExpression is + evaluated in step 1. + + Author: christine@netscape.com + Date: 12 november 1997 +*/ +var SECTION = "11.2.1-1"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Property Accessors"; +writeHeaderToLog( SECTION + " "+TITLE ); + +// go through all Native Function objects, methods, and properties and get their typeof. + +var PROPERTY = new Array(); +var p = 0; + +// properties and functions of the global object + +PROPERTY[p++] = new Property( "this", "NaN", "number" ); +PROPERTY[p++] = new Property( "this", "Infinity", "number" ); +PROPERTY[p++] = new Property( "this", "eval", "function" ); +PROPERTY[p++] = new Property( "this", "parseInt", "function" ); +PROPERTY[p++] = new Property( "this", "parseFloat", "function" ); +PROPERTY[p++] = new Property( "this", "escape", "function" ); +PROPERTY[p++] = new Property( "this", "unescape", "function" ); +PROPERTY[p++] = new Property( "this", "isNaN", "function" ); +PROPERTY[p++] = new Property( "this", "isFinite", "function" ); +PROPERTY[p++] = new Property( "this", "Object", "function" ); +PROPERTY[p++] = new Property( "this", "Number", "function" ); +PROPERTY[p++] = new Property( "this", "Function", "function" ); +PROPERTY[p++] = new Property( "this", "Array", "function" ); +PROPERTY[p++] = new Property( "this", "String", "function" ); +PROPERTY[p++] = new Property( "this", "Boolean", "function" ); +PROPERTY[p++] = new Property( "this", "Date", "function" ); +PROPERTY[p++] = new Property( "this", "Math", "object" ); + +// properties and methods of Object objects + +PROPERTY[p++] = new Property( "Object", "prototype", "object" ); +PROPERTY[p++] = new Property( "Object", "toString", "function" ); +PROPERTY[p++] = new Property( "Object", "valueOf", "function" ); +PROPERTY[p++] = new Property( "Object", "constructor", "function" ); + +// properties of the Function object + +PROPERTY[p++] = new Property( "Function", "prototype", "function" ); +PROPERTY[p++] = new Property( "Function.prototype", "toString", "function" ); +PROPERTY[p++] = new Property( "Function.prototype", "length", "number" ); +PROPERTY[p++] = new Property( "Function.prototype", "valueOf", "function" ); + +Function.prototype.myProperty = "hi"; + +PROPERTY[p++] = new Property( "Function.prototype", "myProperty", "string" ); + +// properties of the Array object +PROPERTY[p++] = new Property( "Array", "prototype", "object" ); +PROPERTY[p++] = new Property( "Array", "length", "number" ); +PROPERTY[p++] = new Property( "Array.prototype", "constructor", "function" ); +PROPERTY[p++] = new Property( "Array.prototype", "toString", "function" ); +PROPERTY[p++] = new Property( "Array.prototype", "join", "function" ); +PROPERTY[p++] = new Property( "Array.prototype", "reverse", "function" ); +PROPERTY[p++] = new Property( "Array.prototype", "sort", "function" ); + +// properties of the String object +PROPERTY[p++] = new Property( "String", "prototype", "object" ); +PROPERTY[p++] = new Property( "String", "fromCharCode", "function" ); +PROPERTY[p++] = new Property( "String.prototype", "toString", "function" ); +PROPERTY[p++] = new Property( "String.prototype", "constructor", "function" ); +PROPERTY[p++] = new Property( "String.prototype", "valueOf", "function" ); +PROPERTY[p++] = new Property( "String.prototype", "charAt", "function" ); +PROPERTY[p++] = new Property( "String.prototype", "charCodeAt", "function" ); +PROPERTY[p++] = new Property( "String.prototype", "indexOf", "function" ); +PROPERTY[p++] = new Property( "String.prototype", "lastIndexOf", "function" ); +PROPERTY[p++] = new Property( "String.prototype", "split", "function" ); +PROPERTY[p++] = new Property( "String.prototype", "substring", "function" ); +PROPERTY[p++] = new Property( "String.prototype", "toLowerCase", "function" ); +PROPERTY[p++] = new Property( "String.prototype", "toUpperCase", "function" ); +PROPERTY[p++] = new Property( "String.prototype", "length", "number" ); + +// properties of the Boolean object +PROPERTY[p++] = new Property( "Boolean", "prototype", "object" ); +PROPERTY[p++] = new Property( "Boolean", "constructor", "function" ); +PROPERTY[p++] = new Property( "Boolean.prototype", "valueOf", "function" ); +PROPERTY[p++] = new Property( "Boolean.prototype", "toString", "function" ); + +// properties of the Number object + +PROPERTY[p++] = new Property( "Number", "MAX_VALUE", "number" ); +PROPERTY[p++] = new Property( "Number", "MIN_VALUE", "number" ); +PROPERTY[p++] = new Property( "Number", "NaN", "number" ); +PROPERTY[p++] = new Property( "Number", "NEGATIVE_INFINITY", "number" ); +PROPERTY[p++] = new Property( "Number", "POSITIVE_INFINITY", "number" ); +PROPERTY[p++] = new Property( "Number.prototype", "toString", "function" ); +PROPERTY[p++] = new Property( "Number.prototype", "constructor", "function" ); +PROPERTY[p++] = new Property( "Number.prototype", "valueOf", "function" ); + +// properties of the Math Object. +PROPERTY[p++] = new Property( "Math", "E", "number" ); +PROPERTY[p++] = new Property( "Math", "LN10", "number" ); +PROPERTY[p++] = new Property( "Math", "LN2", "number" ); +PROPERTY[p++] = new Property( "Math", "LOG2E", "number" ); +PROPERTY[p++] = new Property( "Math", "LOG10E", "number" ); +PROPERTY[p++] = new Property( "Math", "PI", "number" ); +PROPERTY[p++] = new Property( "Math", "SQRT1_2", "number" ); +PROPERTY[p++] = new Property( "Math", "SQRT2", "number" ); +PROPERTY[p++] = new Property( "Math", "abs", "function" ); +PROPERTY[p++] = new Property( "Math", "acos", "function" ); +PROPERTY[p++] = new Property( "Math", "asin", "function" ); +PROPERTY[p++] = new Property( "Math", "atan", "function" ); +PROPERTY[p++] = new Property( "Math", "atan2", "function" ); +PROPERTY[p++] = new Property( "Math", "ceil", "function" ); +PROPERTY[p++] = new Property( "Math", "cos", "function" ); +PROPERTY[p++] = new Property( "Math", "exp", "function" ); +PROPERTY[p++] = new Property( "Math", "floor", "function" ); +PROPERTY[p++] = new Property( "Math", "log", "function" ); +PROPERTY[p++] = new Property( "Math", "max", "function" ); +PROPERTY[p++] = new Property( "Math", "min", "function" ); +PROPERTY[p++] = new Property( "Math", "pow", "function" ); +PROPERTY[p++] = new Property( "Math", "random", "function" ); +PROPERTY[p++] = new Property( "Math", "round", "function" ); +PROPERTY[p++] = new Property( "Math", "sin", "function" ); +PROPERTY[p++] = new Property( "Math", "sqrt", "function" ); +PROPERTY[p++] = new Property( "Math", "tan", "function" ); + +// properties of the Date object +PROPERTY[p++] = new Property( "Date", "parse", "function" ); +PROPERTY[p++] = new Property( "Date", "prototype", "object" ); +PROPERTY[p++] = new Property( "Date", "UTC", "function" ); +PROPERTY[p++] = new Property( "Date.prototype", "constructor", "function" ); +PROPERTY[p++] = new Property( "Date.prototype", "toString", "function" ); +PROPERTY[p++] = new Property( "Date.prototype", "valueOf", "function" ); +PROPERTY[p++] = new Property( "Date.prototype", "getTime", "function" ); +PROPERTY[p++] = new Property( "Date.prototype", "getYear", "function" ); +PROPERTY[p++] = new Property( "Date.prototype", "getFullYear", "function" ); +PROPERTY[p++] = new Property( "Date.prototype", "getUTCFullYear", "function" ); +PROPERTY[p++] = new Property( "Date.prototype", "getMonth", "function" ); +PROPERTY[p++] = new Property( "Date.prototype", "getUTCMonth", "function" ); +PROPERTY[p++] = new Property( "Date.prototype", "getDate", "function" ); +PROPERTY[p++] = new Property( "Date.prototype", "getUTCDate", "function" ); +PROPERTY[p++] = new Property( "Date.prototype", "getDay", "function" ); +PROPERTY[p++] = new Property( "Date.prototype", "getUTCDay", "function" ); +PROPERTY[p++] = new Property( "Date.prototype", "getHours", "function" ); +PROPERTY[p++] = new Property( "Date.prototype", "getUTCHours", "function" ); +PROPERTY[p++] = new Property( "Date.prototype", "getMinutes", "function" ); +PROPERTY[p++] = new Property( "Date.prototype", "getUTCMinutes", "function" ); +PROPERTY[p++] = new Property( "Date.prototype", "getSeconds", "function" ); +PROPERTY[p++] = new Property( "Date.prototype", "getUTCSeconds", "function" ); +PROPERTY[p++] = new Property( "Date.prototype", "getMilliseconds","function" ); +PROPERTY[p++] = new Property( "Date.prototype", "getUTCMilliseconds", "function" ); +PROPERTY[p++] = new Property( "Date.prototype", "setTime", "function" ); +PROPERTY[p++] = new Property( "Date.prototype", "setMilliseconds","function" ); +PROPERTY[p++] = new Property( "Date.prototype", "setUTCMilliseconds", "function" ); +PROPERTY[p++] = new Property( "Date.prototype", "setSeconds", "function" ); +PROPERTY[p++] = new Property( "Date.prototype", "setUTCSeconds", "function" ); +PROPERTY[p++] = new Property( "Date.prototype", "setMinutes", "function" ); +PROPERTY[p++] = new Property( "Date.prototype", "setUTCMinutes", "function" ); +PROPERTY[p++] = new Property( "Date.prototype", "setHours", "function" ); +PROPERTY[p++] = new Property( "Date.prototype", "setUTCHours", "function" ); +PROPERTY[p++] = new Property( "Date.prototype", "setDate", "function" ); +PROPERTY[p++] = new Property( "Date.prototype", "setUTCDate", "function" ); +PROPERTY[p++] = new Property( "Date.prototype", "setMonth", "function" ); +PROPERTY[p++] = new Property( "Date.prototype", "setUTCMonth", "function" ); +PROPERTY[p++] = new Property( "Date.prototype", "setFullYear", "function" ); +PROPERTY[p++] = new Property( "Date.prototype", "setUTCFullYear", "function" ); +PROPERTY[p++] = new Property( "Date.prototype", "setYear", "function" ); +PROPERTY[p++] = new Property( "Date.prototype", "toLocaleString", "function" ); +PROPERTY[p++] = new Property( "Date.prototype", "toUTCString", "function" ); +PROPERTY[p++] = new Property( "Date.prototype", "toGMTString", "function" ); + +for ( var i = 0, RESULT; i < PROPERTY.length; i++ ) { + RESULT = eval("typeof " + PROPERTY[i].object + "." + PROPERTY[i].name ); + + new TestCase( SECTION, + "typeof " + PROPERTY[i].object + "." + PROPERTY[i].name, + PROPERTY[i].type, + RESULT ); + + RESULT = eval("typeof " + PROPERTY[i].object + "['" + PROPERTY[i].name +"']"); + + new TestCase( SECTION, + "typeof " + PROPERTY[i].object + "['" + PROPERTY[i].name +"']", + PROPERTY[i].type, + RESULT ); +} + +test(); + +function MyObject( arg0, arg1, arg2, arg3, arg4 ) { + this.name = arg0; +} +function Property( object, name, type ) { + this.object = object; + this.name = name; + this.type = type; +} diff --git a/tests/auto/qml/parserstress/tests/ecma/Expressions/11.2.1-2.js b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.2.1-2.js new file mode 100644 index 0000000000..eda8168c0f --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.2.1-2.js @@ -0,0 +1,128 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '11.2.1-2.js'; + +/** + File Name: 11.2.1-2.js + ECMA Section: 11.2.1 Property Accessors + Description: + + Properties are accessed by name, using either the dot notation: + MemberExpression . Identifier + CallExpression . Identifier + + or the bracket notation: MemberExpression [ Expression ] + CallExpression [ Expression ] + + The dot notation is explained by the following syntactic conversion: + MemberExpression . Identifier + is identical in its behavior to + MemberExpression [ ] + and similarly + CallExpression . Identifier + is identical in its behavior to + CallExpression [ ] + where is a string literal containing the same sequence + of characters as the Identifier. + + The production MemberExpression : MemberExpression [ Expression ] is + evaluated as follows: + + 1. Evaluate MemberExpression. + 2. Call GetValue(Result(1)). + 3. Evaluate Expression. + 4. Call GetValue(Result(3)). + 5. Call ToObject(Result(2)). + 6. Call ToString(Result(4)). + 7. Return a value of type Reference whose base object is Result(5) and + whose property name is Result(6). + + The production CallExpression : CallExpression [ Expression ] is evaluated + in exactly the same manner, except that the contained CallExpression is + evaluated in step 1. + + Author: christine@netscape.com + Date: 12 november 1997 +*/ +var SECTION = "11.2.1-2"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Property Accessors"; +writeHeaderToLog( SECTION + " "+TITLE ); + +// go through all Native Function objects, methods, and properties and get their typeof. + +var PROPERTY = new Array(); +var p = 0; + +// try to access properties of primitive types + +PROPERTY[p++] = new Property( "\"hi\"", "hi", "hi", NaN ); +PROPERTY[p++] = new Property( NaN, NaN, "NaN", NaN ); +// PROPERTY[p++] = new Property( 3, 3, "3", 3 ); +PROPERTY[p++] = new Property( true, true, "true", 1 ); +PROPERTY[p++] = new Property( false, false, "false", 0 ); + +for ( var i = 0, RESULT; i < PROPERTY.length; i++ ) { + new TestCase( SECTION, + PROPERTY[i].object + ".valueOf()", + PROPERTY[i].value, + eval( PROPERTY[i].object+ ".valueOf()" ) ); + + new TestCase( SECTION, + PROPERTY[i].object + ".toString()", + PROPERTY[i].string, + eval( PROPERTY[i].object+ ".toString()" ) ); + +} + +test(); + +function MyObject( value ) { + this.value = value; + this.stringValue = value +""; + this.numberValue = Number(value); + return this; +} +function Property( object, value, string, number ) { + this.object = object; + this.string = String(value); + this.number = Number(value); + this.value = value; +} diff --git a/tests/auto/qml/parserstress/tests/ecma/Expressions/11.2.1-3-n.js b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.2.1-3-n.js new file mode 100644 index 0000000000..0732aa0378 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.2.1-3-n.js @@ -0,0 +1,128 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '11.2.1-3-n.js'; + +/** + File Name: 11.2.1-2.js + ECMA Section: 11.2.1 Property Accessors + Description: + + Properties are accessed by name, using either the dot notation: + MemberExpression . Identifier + CallExpression . Identifier + + or the bracket notation: MemberExpression [ Expression ] + CallExpression [ Expression ] + + The dot notation is explained by the following syntactic conversion: + MemberExpression . Identifier + is identical in its behavior to + MemberExpression [ ] + and similarly + CallExpression . Identifier + is identical in its behavior to + CallExpression [ ] + where is a string literal containing the same sequence + of characters as the Identifier. + + The production MemberExpression : MemberExpression [ Expression ] is + evaluated as follows: + + 1. Evaluate MemberExpression. + 2. Call GetValue(Result(1)). + 3. Evaluate Expression. + 4. Call GetValue(Result(3)). + 5. Call ToObject(Result(2)). + 6. Call ToString(Result(4)). + 7. Return a value of type Reference whose base object is Result(5) and + whose property name is Result(6). + + The production CallExpression : CallExpression [ Expression ] is evaluated + in exactly the same manner, except that the contained CallExpression is + evaluated in step 1. + + Author: christine@netscape.com + Date: 12 november 1997 +*/ +var SECTION = "11.2.1-2"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Property Accessors"; +writeHeaderToLog( SECTION + " "+TITLE ); + +// go through all Native Function objects, methods, and properties and get their typeof. + +var PROPERTY = new Array(); +var p = 0; + +// try to access properties of primitive types + +PROPERTY[p++] = new Property( "undefined", void 0, "undefined", NaN ); + +for ( var i = 0, RESULT; i < PROPERTY.length; i++ ) { + + DESCRIPTION = PROPERTY[i].object + ".valueOf()"; + EXPECTED = "error"; + + new TestCase( SECTION, + PROPERTY[i].object + ".valueOf()", + PROPERTY[i].value, + eval( PROPERTY[i].object+ ".valueOf()" ) ); + + new TestCase( SECTION, + PROPERTY[i].object + ".toString()", + PROPERTY[i].string, + eval(PROPERTY[i].object+ ".toString()") ); +} +test(); + + +function MyObject( value ) { + this.value = value; + this.stringValue = value +""; + this.numberValue = Number(value); + return this; +} + +function Property( object, value, string, number ) { + this.object = object; + this.string = String(value); + this.number = Number(value); + this.value = value; +} diff --git a/tests/auto/qml/parserstress/tests/ecma/Expressions/11.2.1-4-n.js b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.2.1-4-n.js new file mode 100644 index 0000000000..110684c9c6 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.2.1-4-n.js @@ -0,0 +1,128 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '11.2.1-4-n.js'; + +/** + File Name: 11.2.1-4-n.js + ECMA Section: 11.2.1 Property Accessors + Description: + + Properties are accessed by name, using either the dot notation: + MemberExpression . Identifier + CallExpression . Identifier + + or the bracket notation: MemberExpression [ Expression ] + CallExpression [ Expression ] + + The dot notation is explained by the following syntactic conversion: + MemberExpression . Identifier + is identical in its behavior to + MemberExpression [ ] + and similarly + CallExpression . Identifier + is identical in its behavior to + CallExpression [ ] + where is a string literal containing the same sequence + of characters as the Identifier. + + The production MemberExpression : MemberExpression [ Expression ] is + evaluated as follows: + + 1. Evaluate MemberExpression. + 2. Call GetValue(Result(1)). + 3. Evaluate Expression. + 4. Call GetValue(Result(3)). + 5. Call ToObject(Result(2)). + 6. Call ToString(Result(4)). + 7. Return a value of type Reference whose base object is Result(5) and + whose property name is Result(6). + + The production CallExpression : CallExpression [ Expression ] is evaluated + in exactly the same manner, except that the contained CallExpression is + evaluated in step 1. + + Author: christine@netscape.com + Date: 12 november 1997 +*/ +var SECTION = "11.2.1-4-n"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Property Accessors"; +writeHeaderToLog( SECTION + " "+TITLE ); + +// go through all Native Function objects, methods, and properties and get their typeof. + +var PROPERTY = new Array(); +var p = 0; + +// try to access properties of primitive types + +PROPERTY[p++] = new Property( "null", null, "null", 0 ); + +for ( var i = 0, RESULT; i < PROPERTY.length; i++ ) { + + DESCRIPTION = PROPERTY[i].object + ".valueOf()"; + EXPECTED = "error"; + + new TestCase( SECTION, + PROPERTY[i].object + ".valueOf()", + PROPERTY[i].value, + eval( PROPERTY[i].object+ ".valueOf()" ) ); + + new TestCase( SECTION, + PROPERTY[i].object + ".toString()", + PROPERTY[i].string, + eval(PROPERTY[i].object+ ".toString()") ); + +} + +test(); + +function MyObject( value ) { + this.value = value; + this.stringValue = value +""; + this.numberValue = Number(value); + return this; +} +function Property( object, value, string, number ) { + this.object = object; + this.string = String(value); + this.number = Number(value); + this.value = value; +} diff --git a/tests/auto/qml/parserstress/tests/ecma/Expressions/11.2.1-5.js b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.2.1-5.js new file mode 100644 index 0000000000..2d9f0f1632 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.2.1-5.js @@ -0,0 +1,128 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '11.2.1-5.js'; + +/** + File Name: 11.2.1-5.js + ECMA Section: 11.2.1 Property Accessors + Description: + + Properties are accessed by name, using either the dot notation: + MemberExpression . Identifier + CallExpression . Identifier + + or the bracket notation: MemberExpression [ Expression ] + CallExpression [ Expression ] + + The dot notation is explained by the following syntactic conversion: + MemberExpression . Identifier + is identical in its behavior to + MemberExpression [ ] + and similarly + CallExpression . Identifier + is identical in its behavior to + CallExpression [ ] + where is a string literal containing the same sequence + of characters as the Identifier. + + The production MemberExpression : MemberExpression [ Expression ] is + evaluated as follows: + + 1. Evaluate MemberExpression. + 2. Call GetValue(Result(1)). + 3. Evaluate Expression. + 4. Call GetValue(Result(3)). + 5. Call ToObject(Result(2)). + 6. Call ToString(Result(4)). + 7. Return a value of type Reference whose base object is Result(5) and + whose property name is Result(6). + + The production CallExpression : CallExpression [ Expression ] is evaluated + in exactly the same manner, except that the contained CallExpression is + evaluated in step 1. + + Author: christine@netscape.com + Date: 12 november 1997 +*/ +var SECTION = "11.2.1-5"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Property Accessors"; +writeHeaderToLog( SECTION + " "+TITLE ); + +// go through all Native Function objects, methods, and properties and get their typeof. + +var PROPERTY = new Array(); +var p = 0; + +// try to access properties of primitive types + +PROPERTY[p++] = new Property( new String("hi"), "hi", "hi", NaN ); +PROPERTY[p++] = new Property( new Number(NaN), NaN, "NaN", NaN ); +PROPERTY[p++] = new Property( new Number(3), 3, "3", 3 ); +PROPERTY[p++] = new Property( new Boolean(true), true, "true", 1 ); +PROPERTY[p++] = new Property( new Boolean(false), false, "false", 0 ); + +for ( var i = 0, RESULT; i < PROPERTY.length; i++ ) { + new TestCase( SECTION, + PROPERTY[i].object + ".valueOf()", + PROPERTY[i].value, + eval( "PROPERTY[i].object.valueOf()" ) ); + + new TestCase( SECTION, + PROPERTY[i].object + ".toString()", + PROPERTY[i].string, + eval( "PROPERTY[i].object.toString()" ) ); + +} + +test(); + +function MyObject( value ) { + this.value = value; + this.stringValue = value +""; + this.numberValue = Number(value); + return this; +} +function Property( object, value, string, number ) { + this.object = object; + this.string = String(value); + this.number = Number(value); + this.value = value; +} diff --git a/tests/auto/qml/parserstress/tests/ecma/Expressions/11.2.2-1-n.js b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.2.2-1-n.js new file mode 100644 index 0000000000..3603892114 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.2.2-1-n.js @@ -0,0 +1,104 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '11.2.2-1-n.js'; + +/** + File Name: 11.2.2-1.js + ECMA Section: 11.2.2. The new operator + Description: + + MemberExpression: + PrimaryExpression + MemberExpression[Expression] + MemberExpression.Identifier + new MemberExpression Arguments + + new NewExpression + + The production NewExpression : new NewExpression is evaluated as follows: + + 1. Evaluate NewExpression. + 2. Call GetValue(Result(1)). + 3. If Type(Result(2)) is not Object, generate a runtime error. + 4. If Result(2) does not implement the internal [[Construct]] method, + generate a runtime error. + 5. Call the [[Construct]] method on Result(2), providing no arguments + (that is, an empty list of arguments). + 6. If Type(Result(5)) is not Object, generate a runtime error. + 7. Return Result(5). + + The production MemberExpression : new MemberExpression Arguments is evaluated as follows: + + 1. Evaluate MemberExpression. + 2. Call GetValue(Result(1)). + 3. Evaluate Arguments, producing an internal list of argument values + (section 0). + 4. If Type(Result(2)) is not Object, generate a runtime error. + 5. If Result(2) does not implement the internal [[Construct]] method, + generate a runtime error. + 6. Call the [[Construct]] method on Result(2), providing the list + Result(3) as the argument values. + 7. If Type(Result(6)) is not Object, generate a runtime error. + 8 .Return Result(6). + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + +var SECTION = "11.2.2-1-n.js"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "The new operator"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +var OBJECT = new Object(); + +DESCRIPTION = "OBJECT = new Object; var o = new OBJECT()"; +EXPECTED = "error"; + +new TestCase( SECTION, + "OBJECT = new Object; var o = new OBJECT()", + "error", + eval("o = new OBJECT()") ); +test(); + +function TestFunction() { + return arguments; +} diff --git a/tests/auto/qml/parserstress/tests/ecma/Expressions/11.2.2-1.js b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.2.2-1.js new file mode 100644 index 0000000000..7105f17071 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.2.2-1.js @@ -0,0 +1,100 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '11.2.2-1.js'; + +/** + File Name: 11.2.2-1.js + ECMA Section: 11.2.2. The new operator + Description: + + MemberExpression: + PrimaryExpression + MemberExpression[Expression] + MemberExpression.Identifier + new MemberExpression Arguments + + new NewExpression + + The production NewExpression : new NewExpression is evaluated as follows: + + 1. Evaluate NewExpression. + 2. Call GetValue(Result(1)). + 3. If Type(Result(2)) is not Object, generate a runtime error. + 4. If Result(2) does not implement the internal [[Construct]] method, + generate a runtime error. + 5. Call the [[Construct]] method on Result(2), providing no arguments + (that is, an empty list of arguments). + 6. If Type(Result(5)) is not Object, generate a runtime error. + 7. Return Result(5). + + The production MemberExpression : new MemberExpression Arguments is evaluated as follows: + + 1. Evaluate MemberExpression. + 2. Call GetValue(Result(1)). + 3. Evaluate Arguments, producing an internal list of argument values + (section 0). + 4. If Type(Result(2)) is not Object, generate a runtime error. + 5. If Result(2) does not implement the internal [[Construct]] method, + generate a runtime error. + 6. Call the [[Construct]] method on Result(2), providing the list + Result(3) as the argument values. + 7. If Type(Result(6)) is not Object, generate a runtime error. + 8 .Return Result(6). + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + +var SECTION = "11.2.2-1"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "The new operator"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +new TestCase( SECTION, + "(new TestFunction(0,1,2,3,4,5)).length", + 6, + (new TestFunction(0,1,2,3,4,5)).length ); + +test(); + +function TestFunction() { + return arguments; +} diff --git a/tests/auto/qml/parserstress/tests/ecma/Expressions/11.2.2-10-n.js b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.2.2-10-n.js new file mode 100644 index 0000000000..36781503d9 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.2.2-10-n.js @@ -0,0 +1,102 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '11.2.2-10-n.js'; + +/** + File Name: 11.2.2-9-n.js + ECMA Section: 11.2.2. The new operator + Description: + + MemberExpression: + PrimaryExpression + MemberExpression[Expression] + MemberExpression.Identifier + new MemberExpression Arguments + + new NewExpression + + The production NewExpression : new NewExpression is evaluated as follows: + + 1. Evaluate NewExpression. + 2. Call GetValue(Result(1)). + 3. If Type(Result(2)) is not Object, generate a runtime error. + 4. If Result(2) does not implement the internal [[Construct]] method, + generate a runtime error. + 5. Call the [[Construct]] method on Result(2), providing no arguments + (that is, an empty list of arguments). + 6. If Type(Result(5)) is not Object, generate a runtime error. + 7. Return Result(5). + + The production MemberExpression : new MemberExpression Arguments is evaluated as follows: + + 1. Evaluate MemberExpression. + 2. Call GetValue(Result(1)). + 3. Evaluate Arguments, producing an internal list of argument values + (section 0). + 4. If Type(Result(2)) is not Object, generate a runtime error. + 5. If Result(2) does not implement the internal [[Construct]] method, + generate a runtime error. + 6. Call the [[Construct]] method on Result(2), providing the list + Result(3) as the argument values. + 7. If Type(Result(6)) is not Object, generate a runtime error. + 8 .Return Result(6). + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + +var SECTION = "11.2.2-9-n.js"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "The new operator"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +DESCRIPTION = "var m = new Math()"; +EXPECTED = "error"; + +new TestCase( SECTION, + "var m = new Math()", + "error", + eval("m = new Math()") ); +test(); + +function TestFunction() { + return arguments; +} diff --git a/tests/auto/qml/parserstress/tests/ecma/Expressions/11.2.2-11.js b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.2.2-11.js new file mode 100644 index 0000000000..03a0f8c436 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.2.2-11.js @@ -0,0 +1,104 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '11.2.2-11.js'; + +/** + File Name: 11.2.2-9-n.js + ECMA Section: 11.2.2. The new operator + Description: + + MemberExpression: + PrimaryExpression + MemberExpression[Expression] + MemberExpression.Identifier + new MemberExpression Arguments + + new NewExpression + + The production NewExpression : new NewExpression is evaluated as follows: + + 1. Evaluate NewExpression. + 2. Call GetValue(Result(1)). + 3. If Type(Result(2)) is not Object, generate a runtime error. + 4. If Result(2) does not implement the internal [[Construct]] method, + generate a runtime error. + 5. Call the [[Construct]] method on Result(2), providing no arguments + (that is, an empty list of arguments). + 6. If Type(Result(5)) is not Object, generate a runtime error. + 7. Return Result(5). + + The production MemberExpression : new MemberExpression Arguments is evaluated as follows: + + 1. Evaluate MemberExpression. + 2. Call GetValue(Result(1)). + 3. Evaluate Arguments, producing an internal list of argument values + (section 0). + 4. If Type(Result(2)) is not Object, generate a runtime error. + 5. If Result(2) does not implement the internal [[Construct]] method, + generate a runtime error. + 6. Call the [[Construct]] method on Result(2), providing the list + Result(3) as the argument values. + 7. If Type(Result(6)) is not Object, generate a runtime error. + 8 Return Result(6). + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + +var SECTION = "11.2.2-9-n.js"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "The new operator"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +var FUNCTION = new Function(); + +new TestCase( SECTION, + "var FUNCTION = new Function(); f = new FUNCTION(); typeof f", + "object", + eval("var FUNCTION = new Function(); f = new FUNCTION(); typeof f") ); + +new TestCase( SECTION, + "var FUNCTION = new Function('return this'); f = new FUNCTION(); typeof f", + "object", + eval("var FUNCTION = new Function('return this'); f = new FUNCTION(); typeof f") ); + +test(); + diff --git a/tests/auto/qml/parserstress/tests/ecma/Expressions/11.2.2-2-n.js b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.2.2-2-n.js new file mode 100644 index 0000000000..7fbea97ca1 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.2.2-2-n.js @@ -0,0 +1,104 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '11.2.2-2-n.js'; + +/** + File Name: 11.2.2-2.js + ECMA Section: 11.2.2. The new operator + Description: + + MemberExpression: + PrimaryExpression + MemberExpression[Expression] + MemberExpression.Identifier + new MemberExpression Arguments + + new NewExpression + + The production NewExpression : new NewExpression is evaluated as follows: + + 1. Evaluate NewExpression. + 2. Call GetValue(Result(1)). + 3. If Type(Result(2)) is not Object, generate a runtime error. + 4. If Result(2) does not implement the internal [[Construct]] method, + generate a runtime error. + 5. Call the [[Construct]] method on Result(2), providing no arguments + (that is, an empty list of arguments). + 6. If Type(Result(5)) is not Object, generate a runtime error. + 7. Return Result(5). + + The production MemberExpression : new MemberExpression Arguments is evaluated as follows: + + 1. Evaluate MemberExpression. + 2. Call GetValue(Result(1)). + 3. Evaluate Arguments, producing an internal list of argument values + (section 0). + 4. If Type(Result(2)) is not Object, generate a runtime error. + 5. If Result(2) does not implement the internal [[Construct]] method, + generate a runtime error. + 6. Call the [[Construct]] method on Result(2), providing the list + Result(3) as the argument values. + 7. If Type(Result(6)) is not Object, generate a runtime error. + 8 .Return Result(6). + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + +var SECTION = "11.2.2-2-n.js"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "The new operator"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +var UNDEFINED = void 0; + +DESCRIPTION = "UNDEFINED = void 0; var o = new UNDEFINED()"; +EXPECTED = "error"; + +new TestCase( SECTION, + "UNDEFINED = void 0; var o = new UNDEFINED()", + "error", + eval("o = new UNDEFINED()") ); +test(); + +function TestFunction() { + return arguments; +} diff --git a/tests/auto/qml/parserstress/tests/ecma/Expressions/11.2.2-3-n.js b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.2.2-3-n.js new file mode 100644 index 0000000000..8b344a3dda --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.2.2-3-n.js @@ -0,0 +1,100 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '11.2.2-3-n.js'; + +/** + File Name: 11.2.2-3-n.js + ECMA Section: 11.2.2. The new operator + Description: + + MemberExpression: + PrimaryExpression + MemberExpression[Expression] + MemberExpression.Identifier + new MemberExpression Arguments + + new NewExpression + + The production NewExpression : new NewExpression is evaluated as follows: + + 1. Evaluate NewExpression. + 2. Call GetValue(Result(1)). + 3. If Type(Result(2)) is not Object, generate a runtime error. + 4. If Result(2) does not implement the internal [[Construct]] method, + generate a runtime error. + 5. Call the [[Construct]] method on Result(2), providing no arguments + (that is, an empty list of arguments). + 6. If Type(Result(5)) is not Object, generate a runtime error. + 7. Return Result(5). + + The production MemberExpression : new MemberExpression Arguments is evaluated as follows: + + 1. Evaluate MemberExpression. + 2. Call GetValue(Result(1)). + 3. Evaluate Arguments, producing an internal list of argument values + (section 0). + 4. If Type(Result(2)) is not Object, generate a runtime error. + 5. If Result(2) does not implement the internal [[Construct]] method, + generate a runtime error. + 6. Call the [[Construct]] method on Result(2), providing the list + Result(3) as the argument values. + 7. If Type(Result(6)) is not Object, generate a runtime error. + 8 .Return Result(6). + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + +var SECTION = "11.2.2-3-n.js"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "The new operator"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +var DESCRIPTION = "NULL = null; var o = new NULL()"; +var EXPECTED = "error"; +var NULL = null; + +new TestCase( SECTION, + "NULL = null; var o = new NULL()", + "error", + eval("o = new NULL()") ); +test(); + diff --git a/tests/auto/qml/parserstress/tests/ecma/Expressions/11.2.2-4-n.js b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.2.2-4-n.js new file mode 100644 index 0000000000..c2ff538b9f --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.2.2-4-n.js @@ -0,0 +1,104 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '11.2.2-4-n.js'; + +/** + File Name: 11.2.2-4-n.js + ECMA Section: 11.2.2. The new operator + Description: + + MemberExpression: + PrimaryExpression + MemberExpression[Expression] + MemberExpression.Identifier + new MemberExpression Arguments + + new NewExpression + + The production NewExpression : new NewExpression is evaluated as follows: + + 1. Evaluate NewExpression. + 2. Call GetValue(Result(1)). + 3. If Type(Result(2)) is not Object, generate a runtime error. + 4. If Result(2) does not implement the internal [[Construct]] method, + generate a runtime error. + 5. Call the [[Construct]] method on Result(2), providing no arguments + (that is, an empty list of arguments). + 6. If Type(Result(5)) is not Object, generate a runtime error. + 7. Return Result(5). + + The production MemberExpression : new MemberExpression Arguments is evaluated as follows: + + 1. Evaluate MemberExpression. + 2. Call GetValue(Result(1)). + 3. Evaluate Arguments, producing an internal list of argument values + (section 0). + 4. If Type(Result(2)) is not Object, generate a runtime error. + 5. If Result(2) does not implement the internal [[Construct]] method, + generate a runtime error. + 6. Call the [[Construct]] method on Result(2), providing the list + Result(3) as the argument values. + 7. If Type(Result(6)) is not Object, generate a runtime error. + 8 .Return Result(6). + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + +var SECTION = "11.2.2-4-n.js"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "The new operator"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +var STRING = ""; + +DESCRIPTION = "STRING = '', var s = new STRING()"; +EXPECTED = "error"; + +new TestCase( SECTION, + "STRING = '', var s = new STRING()", + "error", + eval("s = new STRING()") ); +test(); + +function TestFunction() { + return arguments; +} diff --git a/tests/auto/qml/parserstress/tests/ecma/Expressions/11.2.2-5-n.js b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.2.2-5-n.js new file mode 100644 index 0000000000..ba8d0756fb --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.2.2-5-n.js @@ -0,0 +1,104 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '11.2.2-5-n.js'; + +/** + File Name: 11.2.2-5-n.js + ECMA Section: 11.2.2. The new operator + Description: + + MemberExpression: + PrimaryExpression + MemberExpression[Expression] + MemberExpression.Identifier + new MemberExpression Arguments + + new NewExpression + + The production NewExpression : new NewExpression is evaluated as follows: + + 1. Evaluate NewExpression. + 2. Call GetValue(Result(1)). + 3. If Type(Result(2)) is not Object, generate a runtime error. + 4. If Result(2) does not implement the internal [[Construct]] method, + generate a runtime error. + 5. Call the [[Construct]] method on Result(2), providing no arguments + (that is, an empty list of arguments). + 6. If Type(Result(5)) is not Object, generate a runtime error. + 7. Return Result(5). + + The production MemberExpression : new MemberExpression Arguments is evaluated as follows: + + 1. Evaluate MemberExpression. + 2. Call GetValue(Result(1)). + 3. Evaluate Arguments, producing an internal list of argument values + (section 0). + 4. If Type(Result(2)) is not Object, generate a runtime error. + 5. If Result(2) does not implement the internal [[Construct]] method, + generate a runtime error. + 6. Call the [[Construct]] method on Result(2), providing the list + Result(3) as the argument values. + 7. If Type(Result(6)) is not Object, generate a runtime error. + 8 .Return Result(6). + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + +var SECTION = "11.2.2-5-n.js"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "The new operator"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +var NUMBER = 0; + +DESCRIPTION = "NUMBER=0, var n = new NUMBER()"; +EXPECTED = "error"; + +new TestCase( SECTION, + "NUMBER=0, var n = new NUMBER()", + "error", + eval("n = new NUMBER()") ); +test(); + +function TestFunction() { + return arguments; +} diff --git a/tests/auto/qml/parserstress/tests/ecma/Expressions/11.2.2-6-n.js b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.2.2-6-n.js new file mode 100644 index 0000000000..f89b4009e3 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.2.2-6-n.js @@ -0,0 +1,103 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '11.2.2-6-n.js'; + +/** + File Name: 11.2.2-6-n.js + ECMA Section: 11.2.2. The new operator + Description: + + MemberExpression: + PrimaryExpression + MemberExpression[Expression] + MemberExpression.Identifier + new MemberExpression Arguments + + new NewExpression + + The production NewExpression : new NewExpression is evaluated as follows: + + 1. Evaluate NewExpression. + 2. Call GetValue(Result(1)). + 3. If Type(Result(2)) is not Object, generate a runtime error. + 4. If Result(2) does not implement the internal [[Construct]] method, + generate a runtime error. + 5. Call the [[Construct]] method on Result(2), providing no arguments + (that is, an empty list of arguments). + 6. If Type(Result(5)) is not Object, generate a runtime error. + 7. Return Result(5). + + The production MemberExpression : new MemberExpression Arguments is evaluated as follows: + + 1. Evaluate MemberExpression. + 2. Call GetValue(Result(1)). + 3. Evaluate Arguments, producing an internal list of argument values + (section 0). + 4. If Type(Result(2)) is not Object, generate a runtime error. + 5. If Result(2) does not implement the internal [[Construct]] method, + generate a runtime error. + 6. Call the [[Construct]] method on Result(2), providing the list + Result(3) as the argument values. + 7. If Type(Result(6)) is not Object, generate a runtime error. + 8 .Return Result(6). + + Author: christine@netscape.com + Date: 12 november 1997 +*/ +var SECTION = "11.2.2-6-n.js"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "The new operator"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +var BOOLEAN = true; +DESCRIPTION = "BOOLEAN = true; var b = new BOOLEAN()"; +EXPECTED = "error"; + +new TestCase( SECTION, + "BOOLEAN = true; var b = new BOOLEAN()", + "error", + eval("b = new BOOLEAN()") ); +test(); + +function TestFunction() { + return arguments; +} + diff --git a/tests/auto/qml/parserstress/tests/ecma/Expressions/11.2.2-7-n.js b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.2.2-7-n.js new file mode 100644 index 0000000000..97ae43e810 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.2.2-7-n.js @@ -0,0 +1,104 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '11.2.2-7-n.js'; + +/** + File Name: 11.2.2-6-n.js + ECMA Section: 11.2.2. The new operator + Description: + + MemberExpression: + PrimaryExpression + MemberExpression[Expression] + MemberExpression.Identifier + new MemberExpression Arguments + + new NewExpression + + The production NewExpression : new NewExpression is evaluated as follows: + + 1. Evaluate NewExpression. + 2. Call GetValue(Result(1)). + 3. If Type(Result(2)) is not Object, generate a runtime error. + 4. If Result(2) does not implement the internal [[Construct]] method, + generate a runtime error. + 5. Call the [[Construct]] method on Result(2), providing no arguments + (that is, an empty list of arguments). + 6. If Type(Result(5)) is not Object, generate a runtime error. + 7. Return Result(5). + + The production MemberExpression : new MemberExpression Arguments is evaluated as follows: + + 1. Evaluate MemberExpression. + 2. Call GetValue(Result(1)). + 3. Evaluate Arguments, producing an internal list of argument values + (section 0). + 4. If Type(Result(2)) is not Object, generate a runtime error. + 5. If Result(2) does not implement the internal [[Construct]] method, + generate a runtime error. + 6. Call the [[Construct]] method on Result(2), providing the list + Result(3) as the argument values. + 7. If Type(Result(6)) is not Object, generate a runtime error. + 8 .Return Result(6). + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + +var SECTION = "11.2.2-6-n.js"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "The new operator"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +var STRING = new String("hi"); + +DESCRIPTION = "var STRING = new String('hi'); var s = new STRING()"; +EXPECTED = "error"; + +new TestCase( SECTION, + "var STRING = new String('hi'); var s = new STRING()", + "error", + eval("s = new STRING()") ); +test(); + +function TestFunction() { + return arguments; +} diff --git a/tests/auto/qml/parserstress/tests/ecma/Expressions/11.2.2-8-n.js b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.2.2-8-n.js new file mode 100644 index 0000000000..10117c726e --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.2.2-8-n.js @@ -0,0 +1,104 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '11.2.2-8-n.js'; + +/** + File Name: 11.2.2-8-n.js + ECMA Section: 11.2.2. The new operator + Description: + + MemberExpression: + PrimaryExpression + MemberExpression[Expression] + MemberExpression.Identifier + new MemberExpression Arguments + + new NewExpression + + The production NewExpression : new NewExpression is evaluated as follows: + + 1. Evaluate NewExpression. + 2. Call GetValue(Result(1)). + 3. If Type(Result(2)) is not Object, generate a runtime error. + 4. If Result(2) does not implement the internal [[Construct]] method, + generate a runtime error. + 5. Call the [[Construct]] method on Result(2), providing no arguments + (that is, an empty list of arguments). + 6. If Type(Result(5)) is not Object, generate a runtime error. + 7. Return Result(5). + + The production MemberExpression : new MemberExpression Arguments is evaluated as follows: + + 1. Evaluate MemberExpression. + 2. Call GetValue(Result(1)). + 3. Evaluate Arguments, producing an internal list of argument values + (section 0). + 4. If Type(Result(2)) is not Object, generate a runtime error. + 5. If Result(2) does not implement the internal [[Construct]] method, + generate a runtime error. + 6. Call the [[Construct]] method on Result(2), providing the list + Result(3) as the argument values. + 7. If Type(Result(6)) is not Object, generate a runtime error. + 8 .Return Result(6). + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + +var SECTION = "11.2.2-8-n.js"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "The new operator"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +var NUMBER = new Number(1); + +DESCRIPTION = "var NUMBER = new Number(1); var n = new NUMBER()"; +EXPECTED = "error"; + +new TestCase( SECTION, + "var NUMBER = new Number(1); var n = new NUMBER()", + "error", + eval("n = new NUMBER()") ); +test(); + +function TestFunction() { + return arguments; +} diff --git a/tests/auto/qml/parserstress/tests/ecma/Expressions/11.2.2-9-n.js b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.2.2-9-n.js new file mode 100644 index 0000000000..6099754ca3 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.2.2-9-n.js @@ -0,0 +1,104 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '11.2.2-9-n.js'; + +/** + File Name: 11.2.2-9-n.js + ECMA Section: 11.2.2. The new operator + Description: + + MemberExpression: + PrimaryExpression + MemberExpression[Expression] + MemberExpression.Identifier + new MemberExpression Arguments + + new NewExpression + + The production NewExpression : new NewExpression is evaluated as follows: + + 1. Evaluate NewExpression. + 2. Call GetValue(Result(1)). + 3. If Type(Result(2)) is not Object, generate a runtime error. + 4. If Result(2) does not implement the internal [[Construct]] method, + generate a runtime error. + 5. Call the [[Construct]] method on Result(2), providing no arguments + (that is, an empty list of arguments). + 6. If Type(Result(5)) is not Object, generate a runtime error. + 7. Return Result(5). + + The production MemberExpression : new MemberExpression Arguments is evaluated as follows: + + 1. Evaluate MemberExpression. + 2. Call GetValue(Result(1)). + 3. Evaluate Arguments, producing an internal list of argument values + (section 0). + 4. If Type(Result(2)) is not Object, generate a runtime error. + 5. If Result(2) does not implement the internal [[Construct]] method, + generate a runtime error. + 6. Call the [[Construct]] method on Result(2), providing the list + Result(3) as the argument values. + 7. If Type(Result(6)) is not Object, generate a runtime error. + 8 .Return Result(6). + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + +var SECTION = "11.2.2-9-n.js"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "The new operator"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +var BOOLEAN = new Boolean(); + +DESCRIPTION = "var BOOLEAN = new Boolean(); var b = new BOOLEAN()"; +EXPECTED = "error"; + +new TestCase( SECTION, + "var BOOLEAN = new Boolean(); var b = new BOOLEAN()", + "error", + eval("b = new BOOLEAN()") ); +test(); + +function TestFunction() { + return arguments; +} diff --git a/tests/auto/qml/parserstress/tests/ecma/Expressions/11.2.3-1.js b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.2.3-1.js new file mode 100644 index 0000000000..6e36ba8d3f --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.2.3-1.js @@ -0,0 +1,125 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '11.2.3-1.js'; + +/** + File Name: 11.2.3-1.js + ECMA Section: 11.2.3. Function Calls + Description: + + The production CallExpression : MemberExpression Arguments is evaluated as + follows: + + 1.Evaluate MemberExpression. + 2.Evaluate Arguments, producing an internal list of argument values + (section 0). + 3.Call GetValue(Result(1)). + 4.If Type(Result(3)) is not Object, generate a runtime error. + 5.If Result(3) does not implement the internal [[Call]] method, generate a + runtime error. + 6.If Type(Result(1)) is Reference, Result(6) is GetBase(Result(1)). Otherwise, + Result(6) is null. + 7.If Result(6) is an activation object, Result(7) is null. Otherwise, Result(7) is + the same as Result(6). + 8.Call the [[Call]] method on Result(3), providing Result(7) as the this value + and providing the list Result(2) as the argument values. + 9.Return Result(8). + + The production CallExpression : CallExpression Arguments is evaluated in + exactly the same manner, except that the contained CallExpression is + evaluated in step 1. + + Note: Result(8) will never be of type Reference if Result(3) is a native + ECMAScript object. Whether calling a host object can return a value of + type Reference is implementation-dependent. + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + +var SECTION = "11.2.3-1"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Function Calls"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +/* this.eval() is no longer legal syntax. +// MemberExpression : this + +new TestCase( SECTION, +"this.eval()", +void 0, +this.eval() ); + +new TestCase( SECTION, +"this.eval('NaN')", +NaN, +this.eval("NaN") ); +*/ +// MemberExpression: Identifier + +var OBJECT = true; + +new TestCase( SECTION, + "OBJECT.toString()", + "true", + OBJECT.toString() ); + +// MemberExpression[ Expression] + +new TestCase( SECTION, + "(new Array())['length'].valueOf()", + 0, + (new Array())["length"].valueOf() ); + +// MemberExpression . Identifier +new TestCase( SECTION, + "(new Array()).length.valueOf()", + 0, + (new Array()).length.valueOf() ); +// new MemberExpression Arguments + +new TestCase( SECTION, + "(new Array(20))['length'].valueOf()", + 20, + (new Array(20))["length"].valueOf() ); + +test(); + diff --git a/tests/auto/qml/parserstress/tests/ecma/Expressions/11.2.3-2-n.js b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.2.3-2-n.js new file mode 100644 index 0000000000..c3539e817a --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.2.3-2-n.js @@ -0,0 +1,94 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '11.2.3-2-n.js'; + +/** + File Name: 11.2.3-2-n.js + ECMA Section: 11.2.3. Function Calls + Description: + + The production CallExpression : MemberExpression Arguments is evaluated as + follows: + + 1.Evaluate MemberExpression. + 2.Evaluate Arguments, producing an internal list of argument values + (section 0). + 3.Call GetValue(Result(1)). + 4.If Type(Result(3)) is not Object, generate a runtime error. + 5.If Result(3) does not implement the internal [[Call]] method, generate a + runtime error. + 6.If Type(Result(1)) is Reference, Result(6) is GetBase(Result(1)). Otherwise, + Result(6) is null. + 7.If Result(6) is an activation object, Result(7) is null. Otherwise, Result(7) is + the same as Result(6). + 8.Call the [[Call]] method on Result(3), providing Result(7) as the this value + and providing the list Result(2) as the argument values. + 9.Return Result(8). + + The production CallExpression : CallExpression Arguments is evaluated in + exactly the same manner, except that the contained CallExpression is + evaluated in step 1. + + Note: Result(8) will never be of type Reference if Result(3) is a native + ECMAScript object. Whether calling a host object can return a value of + type Reference is implementation-dependent. + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + +var SECTION = "11.2.3-2-n.js"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Function Calls"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +new TestCase( SECTION, + "3.valueOf()", + 3, + eval("3.valueOf()") ); + +new TestCase( SECTION, + "(3).valueOf()", + 3, + eval("(3).valueOf()") ); + +test(); + diff --git a/tests/auto/qml/parserstress/tests/ecma/Expressions/11.2.3-3-n.js b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.2.3-3-n.js new file mode 100644 index 0000000000..3023fee16b --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.2.3-3-n.js @@ -0,0 +1,91 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '11.2.3-3-n.js'; + +/** + File Name: 11.2.3-3-n.js + ECMA Section: 11.2.3. Function Calls + Description: + + The production CallExpression : MemberExpression Arguments is evaluated as + follows: + + 1.Evaluate MemberExpression. + 2.Evaluate Arguments, producing an internal list of argument values + (section 0). + 3.Call GetValue(Result(1)). + 4.If Type(Result(3)) is not Object, generate a runtime error. + 5.If Result(3) does not implement the internal [[Call]] method, generate a + runtime error. + 6.If Type(Result(1)) is Reference, Result(6) is GetBase(Result(1)). Otherwise, + Result(6) is null. + 7.If Result(6) is an activation object, Result(7) is null. Otherwise, Result(7) is + the same as Result(6). + 8.Call the [[Call]] method on Result(3), providing Result(7) as the this value + and providing the list Result(2) as the argument values. + 9.Return Result(8). + + The production CallExpression : CallExpression Arguments is evaluated in + exactly the same manner, except that the contained CallExpression is + evaluated in step 1. + + Note: Result(8) will never be of type Reference if Result(3) is a native + ECMAScript object. Whether calling a host object can return a value of + type Reference is implementation-dependent. + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + +var SECTION = "11.2.3-3-n.js"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Function Calls"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +DESCRIPTION = "(void 0).valueOf()"; +EXPECTED = "error"; + +new TestCase( SECTION, + "(void 0).valueOf()", + "error", + eval("(void 0).valueOf()") ); +test(); + diff --git a/tests/auto/qml/parserstress/tests/ecma/Expressions/11.2.3-4-n.js b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.2.3-4-n.js new file mode 100644 index 0000000000..3c0ac1a4b3 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.2.3-4-n.js @@ -0,0 +1,91 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '11.2.3-4-n.js'; + +/** + File Name: 11.2.3-4-n.js + ECMA Section: 11.2.3. Function Calls + Description: + + The production CallExpression : MemberExpression Arguments is evaluated as + follows: + + 1.Evaluate MemberExpression. + 2.Evaluate Arguments, producing an internal list of argument values + (section 0). + 3.Call GetValue(Result(1)). + 4.If Type(Result(3)) is not Object, generate a runtime error. + 5.If Result(3) does not implement the internal [[Call]] method, generate a + runtime error. + 6.If Type(Result(1)) is Reference, Result(6) is GetBase(Result(1)). Otherwise, + Result(6) is null. + 7.If Result(6) is an activation object, Result(7) is null. Otherwise, Result(7) is + the same as Result(6). + 8.Call the [[Call]] method on Result(3), providing Result(7) as the this value + and providing the list Result(2) as the argument values. + 9.Return Result(8). + + The production CallExpression : CallExpression Arguments is evaluated in + exactly the same manner, except that the contained CallExpression is + evaluated in step 1. + + Note: Result(8) will never be of type Reference if Result(3) is a native + ECMAScript object. Whether calling a host object can return a value of + type Reference is implementation-dependent. + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + +var SECTION = "11.2.3-4-n.js"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Function Calls"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +DESCRIPTION = "null.valueOf()"; +EXPECTED = "error"; + +new TestCase( SECTION, + "null.valueOf()", + "error", + eval("null.valueOf()") ); +test(); + diff --git a/tests/auto/qml/parserstress/tests/ecma/Expressions/11.2.3-5.js b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.2.3-5.js new file mode 100644 index 0000000000..92b356c1dd --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.2.3-5.js @@ -0,0 +1,85 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '11.2.3-5.js'; + +/** + File Name: 11.2.3-5-n.js + ECMA Section: 11.2.3. Function Calls + Description: + + The production CallExpression : MemberExpression Arguments is evaluated as + follows: + + 1. Evaluate MemberExpression. + 2. Evaluate Arguments, producing an internal list of argument values + (section 0). + 3. Call GetValue(Result(1)). + 4. If Type(Result(3)) is not Object, generate a runtime error. + 5. If Result(3) does not implement the internal [[Call]] method, generate a + runtime error. + 6. If Type(Result(1)) is Reference, Result(6) is GetBase(Result(1)). Otherwise, + Result(6) is null. + 7. If Result(6) is an activation object, Result(7) is null. Otherwise, Result(7) is + the same as Result(6). + 8. Call the [[Call]] method on Result(3), providing Result(7) as the this value + and providing the list Result(2) as the argument values. + 9. Return Result(8). + + The production CallExpression : CallExpression Arguments is evaluated in + exactly the same manner, except that the contained CallExpression is + evaluated in step 1. + + Note: Result(8) will never be of type Reference if Result(3) is a native + ECMAScript object. Whether calling a host object can return a value of + type Reference is implementation-dependent. + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + +var SECTION = "11.2.3-5"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Function Calls"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +new TestCase( SECTION, "true.valueOf()", true, true.valueOf() ); +test(); + diff --git a/tests/auto/qml/parserstress/tests/ecma/Expressions/11.3.1.js b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.3.1.js new file mode 100644 index 0000000000..29235f1107 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.3.1.js @@ -0,0 +1,153 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '11.3.1.js'; + +/** + File Name: 11.3.1.js + ECMA Section: 11.3.1 Postfix increment operator + Description: + The production MemberExpression : MemberExpression ++ is evaluated as + follows: + + 1. Evaluate MemberExpression. + 2. Call GetValue(Result(1)). + 3. Call ToNumber(Result(2)). + 4. Add the value 1 to Result(3), using the same rules as for the + + operator (section 0). + 5. Call PutValue(Result(1), Result(4)). + 6. Return Result(3). + + Author: christine@netscape.com + Date: 12 november 1997 +*/ +var SECTION = "11.3.1"; +var VERSION = "ECMA_1"; +startTest(); + +writeHeaderToLog( SECTION + " Postfix increment operator"); + +// special numbers +new TestCase( SECTION, "var MYVAR; MYVAR++", NaN, eval("var MYVAR; MYVAR++") ); +new TestCase( SECTION, "var MYVAR= void 0; MYVAR++", NaN, eval("var MYVAR=void 0; MYVAR++") ); +new TestCase( SECTION, "var MYVAR=null; MYVAR++", 0, eval("var MYVAR=null; MYVAR++") ); +new TestCase( SECTION, "var MYVAR=true; MYVAR++", 1, eval("var MYVAR=true; MYVAR++") ); +new TestCase( SECTION, "var MYVAR=false; MYVAR++", 0, eval("var MYVAR=false; MYVAR++") ); + +// verify return value + +new TestCase( SECTION, "var MYVAR=Number.POSITIVE_INFINITY;MYVAR++", Number.POSITIVE_INFINITY, eval("var MYVAR=Number.POSITIVE_INFINITY;MYVAR++") ); +new TestCase( SECTION, "var MYVAR=Number.NEGATIVE_INFINITY;MYVAR++", Number.NEGATIVE_INFINITY, eval("var MYVAR=Number.NEGATIVE_INFINITY;MYVAR++") ); +new TestCase( SECTION, "var MYVAR=Number.NaN;MYVAR++", Number.NaN, eval("var MYVAR=Number.NaN;MYVAR++") ); + +// verify value of variable + +new TestCase( SECTION, "var MYVAR=Number.POSITIVE_INFINITY;MYVAR++;MYVAR", Number.POSITIVE_INFINITY, eval("var MYVAR=Number.POSITIVE_INFINITY;MYVAR++;MYVAR") ); +new TestCase( SECTION, "var MYVAR=Number.NEGATIVE_INFINITY;MYVAR++;MYVAR", Number.NEGATIVE_INFINITY, eval("var MYVAR=Number.NEGATIVE_INFINITY;MYVAR++;MYVAR") ); +new TestCase( SECTION, "var MYVAR=Number.NaN;MYVAR++;MYVAR", Number.NaN, eval("var MYVAR=Number.NaN;MYVAR++;MYVAR") ); + +// number primitives +new TestCase( SECTION, "var MYVAR=0;MYVAR++", 0, eval("var MYVAR=0;MYVAR++") ); +new TestCase( SECTION, "var MYVAR=0.2345;MYVAR++", 0.2345, eval("var MYVAR=0.2345;MYVAR++") ); +new TestCase( SECTION, "var MYVAR=-0.2345;MYVAR++", -0.2345, eval("var MYVAR=-0.2345;MYVAR++") ); + +// verify value of variable + +new TestCase( SECTION, "var MYVAR=0;MYVAR++;MYVAR", 1, eval("var MYVAR=0;MYVAR++;MYVAR") ); +new TestCase( SECTION, "var MYVAR=0.2345;MYVAR++;MYVAR", 1.2345, eval("var MYVAR=0.2345;MYVAR++;MYVAR") ); +new TestCase( SECTION, "var MYVAR=-0.2345;MYVAR++;MYVAR", 0.7655, eval("var MYVAR=-0.2345;MYVAR++;MYVAR") ); +new TestCase( SECTION, "var MYVAR=0;MYVAR++;MYVAR", 1, eval("var MYVAR=0;MYVAR++;MYVAR") ); +new TestCase( SECTION, "var MYVAR=0;MYVAR++;MYVAR", 1, eval("var MYVAR=0;MYVAR++;MYVAR") ); +new TestCase( SECTION, "var MYVAR=0;MYVAR++;MYVAR", 1, eval("var MYVAR=0;MYVAR++;MYVAR") ); + +// boolean values +// verify return value + +new TestCase( SECTION, "var MYVAR=true;MYVAR++", 1, eval("var MYVAR=true;MYVAR++") ); +new TestCase( SECTION, "var MYVAR=false;MYVAR++", 0, eval("var MYVAR=false;MYVAR++") ); +// verify value of variable + +new TestCase( SECTION, "var MYVAR=true;MYVAR++;MYVAR", 2, eval("var MYVAR=true;MYVAR++;MYVAR") ); +new TestCase( SECTION, "var MYVAR=false;MYVAR++;MYVAR", 1, eval("var MYVAR=false;MYVAR++;MYVAR") ); + +// boolean objects +// verify return value + +new TestCase( SECTION, "var MYVAR=new Boolean(true);MYVAR++", 1, eval("var MYVAR=true;MYVAR++") ); +new TestCase( SECTION, "var MYVAR=new Boolean(false);MYVAR++", 0, eval("var MYVAR=false;MYVAR++") ); +// verify value of variable + +new TestCase( SECTION, "var MYVAR=new Boolean(true);MYVAR++;MYVAR", 2, eval("var MYVAR=new Boolean(true);MYVAR++;MYVAR") ); +new TestCase( SECTION, "var MYVAR=new Boolean(false);MYVAR++;MYVAR", 1, eval("var MYVAR=new Boolean(false);MYVAR++;MYVAR") ); + +// string primitives +new TestCase( SECTION, "var MYVAR='string';MYVAR++", Number.NaN, eval("var MYVAR='string';MYVAR++") ); +new TestCase( SECTION, "var MYVAR='12345';MYVAR++", 12345, eval("var MYVAR='12345';MYVAR++") ); +new TestCase( SECTION, "var MYVAR='-12345';MYVAR++", -12345, eval("var MYVAR='-12345';MYVAR++") ); +new TestCase( SECTION, "var MYVAR='0Xf';MYVAR++", 15, eval("var MYVAR='0Xf';MYVAR++") ); +new TestCase( SECTION, "var MYVAR='077';MYVAR++", 77, eval("var MYVAR='077';MYVAR++") ); +new TestCase( SECTION, "var MYVAR=''; MYVAR++", 0, eval("var MYVAR='';MYVAR++") ); + +// verify value of variable + +new TestCase( SECTION, "var MYVAR='string';MYVAR++;MYVAR", Number.NaN, eval("var MYVAR='string';MYVAR++;MYVAR") ); +new TestCase( SECTION, "var MYVAR='12345';MYVAR++;MYVAR", 12346, eval("var MYVAR='12345';MYVAR++;MYVAR") ); +new TestCase( SECTION, "var MYVAR='-12345';MYVAR++;MYVAR", -12344, eval("var MYVAR='-12345';MYVAR++;MYVAR") ); +new TestCase( SECTION, "var MYVAR='0xf';MYVAR++;MYVAR", 16, eval("var MYVAR='0xf';MYVAR++;MYVAR") ); +new TestCase( SECTION, "var MYVAR='077';MYVAR++;MYVAR", 78, eval("var MYVAR='077';MYVAR++;MYVAR") ); +new TestCase( SECTION, "var MYVAR='';MYVAR++;MYVAR", 1, eval("var MYVAR='';MYVAR++;MYVAR") ); + +// string objects +new TestCase( SECTION, "var MYVAR=new String('string');MYVAR++", Number.NaN, eval("var MYVAR=new String('string');MYVAR++") ); +new TestCase( SECTION, "var MYVAR=new String('12345');MYVAR++", 12345, eval("var MYVAR=new String('12345');MYVAR++") ); +new TestCase( SECTION, "var MYVAR=new String('-12345');MYVAR++", -12345, eval("var MYVAR=new String('-12345');MYVAR++") ); +new TestCase( SECTION, "var MYVAR=new String('0Xf');MYVAR++", 15, eval("var MYVAR=new String('0Xf');MYVAR++") ); +new TestCase( SECTION, "var MYVAR=new String('077');MYVAR++", 77, eval("var MYVAR=new String('077');MYVAR++") ); +new TestCase( SECTION, "var MYVAR=new String(''); MYVAR++", 0, eval("var MYVAR=new String('');MYVAR++") ); + +// verify value of variable + +new TestCase( SECTION, "var MYVAR=new String('string');MYVAR++;MYVAR", Number.NaN, eval("var MYVAR=new String('string');MYVAR++;MYVAR") ); +new TestCase( SECTION, "var MYVAR=new String('12345');MYVAR++;MYVAR", 12346, eval("var MYVAR=new String('12345');MYVAR++;MYVAR") ); +new TestCase( SECTION, "var MYVAR=new String('-12345');MYVAR++;MYVAR", -12344, eval("var MYVAR=new String('-12345');MYVAR++;MYVAR") ); +new TestCase( SECTION, "var MYVAR=new String('0xf');MYVAR++;MYVAR", 16, eval("var MYVAR=new String('0xf');MYVAR++;MYVAR") ); +new TestCase( SECTION, "var MYVAR=new String('077');MYVAR++;MYVAR", 78, eval("var MYVAR=new String('077');MYVAR++;MYVAR") ); +new TestCase( SECTION, "var MYVAR=new String('');MYVAR++;MYVAR", 1, eval("var MYVAR=new String('');MYVAR++;MYVAR") ); + +test(); + diff --git a/tests/auto/qml/parserstress/tests/ecma/Expressions/11.3.2.js b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.3.2.js new file mode 100644 index 0000000000..2d6f6c6770 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.3.2.js @@ -0,0 +1,153 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '11.3.2.js'; + +/** + File Name: 11.3.2.js + ECMA Section: 11.3.2 Postfix decrement operator + Description: + + 11.3.2 Postfix decrement operator + + The production MemberExpression : MemberExpression -- is evaluated as follows: + 1. Evaluate MemberExpression. + 2. Call GetValue(Result(1)). + 3. Call ToNumber(Result(2)). + 4. Subtract the value 1 from Result(3), using the same rules as for the - + operator (section 0). + 5. Call PutValue(Result(1), Result(4)). + 6. Return Result(3). + + Author: christine@netscape.com + Date: 12 november 1997 +*/ +var SECTION = "11.3.2"; +var VERSION = "ECMA_1"; +startTest(); + +writeHeaderToLog( SECTION + " Postfix decrement operator"); + +// special numbers +new TestCase( SECTION, "var MYVAR; MYVAR--", NaN, eval("var MYVAR; MYVAR--") ); +new TestCase( SECTION, "var MYVAR= void 0; MYVAR--", NaN, eval("var MYVAR=void 0; MYVAR--") ); +new TestCase( SECTION, "var MYVAR=null; MYVAR--", 0, eval("var MYVAR=null; MYVAR--") ); +new TestCase( SECTION, "var MYVAR=true; MYVAR--", 1, eval("var MYVAR=true; MYVAR--") ); +new TestCase( SECTION, "var MYVAR=false; MYVAR--", 0, eval("var MYVAR=false; MYVAR--") ); + +// verify return value + +new TestCase( SECTION, "var MYVAR=Number.POSITIVE_INFINITY;MYVAR--", Number.POSITIVE_INFINITY, eval("var MYVAR=Number.POSITIVE_INFINITY;MYVAR--") ); +new TestCase( SECTION, "var MYVAR=Number.NEGATIVE_INFINITY;MYVAR--", Number.NEGATIVE_INFINITY, eval("var MYVAR=Number.NEGATIVE_INFINITY;MYVAR--") ); +new TestCase( SECTION, "var MYVAR=Number.NaN;MYVAR--", Number.NaN, eval("var MYVAR=Number.NaN;MYVAR--") ); + +// verify value of variable + +new TestCase( SECTION, "var MYVAR=Number.POSITIVE_INFINITY;MYVAR--;MYVAR", Number.POSITIVE_INFINITY, eval("var MYVAR=Number.POSITIVE_INFINITY;MYVAR--;MYVAR") ); +new TestCase( SECTION, "var MYVAR=Number.NEGATIVE_INFINITY;MYVAR--;MYVAR", Number.NEGATIVE_INFINITY, eval("var MYVAR=Number.NEGATIVE_INFINITY;MYVAR--;MYVAR") ); +new TestCase( SECTION, "var MYVAR=Number.NaN;MYVAR--;MYVAR", Number.NaN, eval("var MYVAR=Number.NaN;MYVAR--;MYVAR") ); + +// number primitives +new TestCase( SECTION, "var MYVAR=0;MYVAR--", 0, eval("var MYVAR=0;MYVAR--") ); +new TestCase( SECTION, "var MYVAR=0.2345;MYVAR--", 0.2345, eval("var MYVAR=0.2345;MYVAR--") ); +new TestCase( SECTION, "var MYVAR=-0.2345;MYVAR--", -0.2345, eval("var MYVAR=-0.2345;MYVAR--") ); + +// verify value of variable + +new TestCase( SECTION, "var MYVAR=0;MYVAR--;MYVAR", -1, eval("var MYVAR=0;MYVAR--;MYVAR") ); +new TestCase( SECTION, "var MYVAR=0.2345;MYVAR--;MYVAR", -0.7655, eval("var MYVAR=0.2345;MYVAR--;MYVAR") ); +new TestCase( SECTION, "var MYVAR=-0.2345;MYVAR--;MYVAR", -1.2345, eval("var MYVAR=-0.2345;MYVAR--;MYVAR") ); +new TestCase( SECTION, "var MYVAR=0;MYVAR--;MYVAR", -1, eval("var MYVAR=0;MYVAR--;MYVAR") ); +new TestCase( SECTION, "var MYVAR=0;MYVAR--;MYVAR", -1, eval("var MYVAR=0;MYVAR--;MYVAR") ); +new TestCase( SECTION, "var MYVAR=0;MYVAR--;MYVAR", -1, eval("var MYVAR=0;MYVAR--;MYVAR") ); + +// boolean values +// verify return value + +new TestCase( SECTION, "var MYVAR=true;MYVAR--", 1, eval("var MYVAR=true;MYVAR--") ); +new TestCase( SECTION, "var MYVAR=false;MYVAR--", 0, eval("var MYVAR=false;MYVAR--") ); +// verify value of variable + +new TestCase( SECTION, "var MYVAR=true;MYVAR--;MYVAR", 0, eval("var MYVAR=true;MYVAR--;MYVAR") ); +new TestCase( SECTION, "var MYVAR=false;MYVAR--;MYVAR", -1, eval("var MYVAR=false;MYVAR--;MYVAR") ); + +// boolean objects +// verify return value + +new TestCase( SECTION, "var MYVAR=new Boolean(true);MYVAR--", 1, eval("var MYVAR=true;MYVAR--") ); +new TestCase( SECTION, "var MYVAR=new Boolean(false);MYVAR--", 0, eval("var MYVAR=false;MYVAR--") ); +// verify value of variable + +new TestCase( SECTION, "var MYVAR=new Boolean(true);MYVAR--;MYVAR", 0, eval("var MYVAR=new Boolean(true);MYVAR--;MYVAR") ); +new TestCase( SECTION, "var MYVAR=new Boolean(false);MYVAR--;MYVAR", -1, eval("var MYVAR=new Boolean(false);MYVAR--;MYVAR") ); + +// string primitives +new TestCase( SECTION, "var MYVAR='string';MYVAR--", Number.NaN, eval("var MYVAR='string';MYVAR--") ); +new TestCase( SECTION, "var MYVAR='12345';MYVAR--", 12345, eval("var MYVAR='12345';MYVAR--") ); +new TestCase( SECTION, "var MYVAR='-12345';MYVAR--", -12345, eval("var MYVAR='-12345';MYVAR--") ); +new TestCase( SECTION, "var MYVAR='0Xf';MYVAR--", 15, eval("var MYVAR='0Xf';MYVAR--") ); +new TestCase( SECTION, "var MYVAR='077';MYVAR--", 77, eval("var MYVAR='077';MYVAR--") ); +new TestCase( SECTION, "var MYVAR=''; MYVAR--", 0, eval("var MYVAR='';MYVAR--") ); + +// verify value of variable + +new TestCase( SECTION, "var MYVAR='string';MYVAR--;MYVAR", Number.NaN, eval("var MYVAR='string';MYVAR--;MYVAR") ); +new TestCase( SECTION, "var MYVAR='12345';MYVAR--;MYVAR", 12344, eval("var MYVAR='12345';MYVAR--;MYVAR") ); +new TestCase( SECTION, "var MYVAR='-12345';MYVAR--;MYVAR", -12346, eval("var MYVAR='-12345';MYVAR--;MYVAR") ); +new TestCase( SECTION, "var MYVAR='0xf';MYVAR--;MYVAR", 14, eval("var MYVAR='0xf';MYVAR--;MYVAR") ); +new TestCase( SECTION, "var MYVAR='077';MYVAR--;MYVAR", 76, eval("var MYVAR='077';MYVAR--;MYVAR") ); +new TestCase( SECTION, "var MYVAR='';MYVAR--;MYVAR", -1, eval("var MYVAR='';MYVAR--;MYVAR") ); + +// string objects +new TestCase( SECTION, "var MYVAR=new String('string');MYVAR--", Number.NaN, eval("var MYVAR=new String('string');MYVAR--") ); +new TestCase( SECTION, "var MYVAR=new String('12345');MYVAR--", 12345, eval("var MYVAR=new String('12345');MYVAR--") ); +new TestCase( SECTION, "var MYVAR=new String('-12345');MYVAR--", -12345, eval("var MYVAR=new String('-12345');MYVAR--") ); +new TestCase( SECTION, "var MYVAR=new String('0Xf');MYVAR--", 15, eval("var MYVAR=new String('0Xf');MYVAR--") ); +new TestCase( SECTION, "var MYVAR=new String('077');MYVAR--", 77, eval("var MYVAR=new String('077');MYVAR--") ); +new TestCase( SECTION, "var MYVAR=new String(''); MYVAR--", 0, eval("var MYVAR=new String('');MYVAR--") ); + +// verify value of variable + +new TestCase( SECTION, "var MYVAR=new String('string');MYVAR--;MYVAR", Number.NaN, eval("var MYVAR=new String('string');MYVAR--;MYVAR") ); +new TestCase( SECTION, "var MYVAR=new String('12345');MYVAR--;MYVAR", 12344, eval("var MYVAR=new String('12345');MYVAR--;MYVAR") ); +new TestCase( SECTION, "var MYVAR=new String('-12345');MYVAR--;MYVAR", -12346, eval("var MYVAR=new String('-12345');MYVAR--;MYVAR") ); +new TestCase( SECTION, "var MYVAR=new String('0xf');MYVAR--;MYVAR", 14, eval("var MYVAR=new String('0xf');MYVAR--;MYVAR") ); +new TestCase( SECTION, "var MYVAR=new String('077');MYVAR--;MYVAR", 76, eval("var MYVAR=new String('077');MYVAR--;MYVAR") ); +new TestCase( SECTION, "var MYVAR=new String('');MYVAR--;MYVAR", -1, eval("var MYVAR=new String('');MYVAR--;MYVAR") ); + +test(); diff --git a/tests/auto/qml/parserstress/tests/ecma/Expressions/11.4.1.js b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.4.1.js new file mode 100644 index 0000000000..62354e17bc --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.4.1.js @@ -0,0 +1,92 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '11.4.1.js'; + +/** + File Name: 11.4.1.js + ECMA Section: 11.4.1 the Delete Operator + Description: returns true if the property could be deleted + returns false if it could not be deleted + Author: christine@netscape.com + Date: 7 july 1997 + +*/ + + +var SECTION = "11.4.1"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "The delete operator"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +// new TestCase( SECTION, "x=[9,8,7];delete(x[2]);x.length", 2, eval("x=[9,8,7];delete(x[2]);x.length") ); +// new TestCase( SECTION, "x=[9,8,7];delete(x[2]);x.toString()", "9,8", eval("x=[9,8,7];delete(x[2]);x.toString()") ); +new TestCase( SECTION, "x=new Date();delete x;typeof(x)", "undefined", eval("x=new Date();delete x;typeof(x)") ); + +// array[item++] = new TestCase( SECTION, "delete(x=new Date())", true, delete(x=new Date()) ); +// array[item++] = new TestCase( SECTION, "delete('string primitive')", true, delete("string primitive") ); +// array[item++] = new TestCase( SECTION, "delete(new String( 'string object' ) )", true, delete(new String("string object")) ); +// array[item++] = new TestCase( SECTION, "delete(new Number(12345) )", true, delete(new Number(12345)) ); +new TestCase( SECTION, "delete(Math.PI)", false, delete(Math.PI) ); +// array[item++] = new TestCase( SECTION, "delete(null)", true, delete(null) ); +// array[item++] = new TestCase( SECTION, "delete(void(0))", true, delete(void(0)) ); + +// variables declared with the var statement are not deletable. + +var abc; +new TestCase( SECTION, "var abc; delete(abc)", false, delete abc ); + +new TestCase( SECTION, + "var OB = new MyObject(); for ( p in OB ) { delete p }", + true, + eval("var OB = new MyObject(); for ( p in OB ) { delete p }") ); + +test(); + +function MyObject() { + this.prop1 = true; + this.prop2 = false; + this.prop3 = null; + this.prop4 = void 0; + this.prop5 = "hi"; + this.prop6 = 42; + this.prop7 = new Date(); + this.prop8 = Math.PI; +} diff --git a/tests/auto/qml/parserstress/tests/ecma/Expressions/11.4.2.js b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.4.2.js new file mode 100644 index 0000000000..b89d9145c9 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.4.2.js @@ -0,0 +1,83 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '11.4.2.js'; + +/** + File Name: 11.4.2.js + ECMA Section: 11.4.2 the Void Operator + Description: always returns undefined (?) + Author: christine@netscape.com + Date: 7 july 1997 + +*/ +var SECTION = "11.4.2"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "The void operator"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +new TestCase( SECTION, "void(new String('string object'))", void 0, void(new String( 'string object' )) ); +new TestCase( SECTION, "void('string primitive')", void 0, void("string primitive") ); +new TestCase( SECTION, "void(Number.NaN)", void 0, void(Number.NaN) ); +new TestCase( SECTION, "void(Number.POSITIVE_INFINITY)", void 0, void(Number.POSITIVE_INFINITY) ); +new TestCase( SECTION, "void(1)", void 0, void(1) ); +new TestCase( SECTION, "void(0)", void 0, void(0) ); +new TestCase( SECTION, "void(-1)", void 0, void(-1) ); +new TestCase( SECTION, "void(Number.NEGATIVE_INFINITY)", void 0, void(Number.NEGATIVE_INFINITY) ); +new TestCase( SECTION, "void(Math.PI)", void 0, void(Math.PI) ); +new TestCase( SECTION, "void(true)", void 0, void(true) ); +new TestCase( SECTION, "void(false)", void 0, void(false) ); +new TestCase( SECTION, "void(null)", void 0, void(null) ); +new TestCase( SECTION, "void new String('string object')", void 0, void new String( 'string object' ) ); +new TestCase( SECTION, "void 'string primitive'", void 0, void "string primitive" ); +new TestCase( SECTION, "void Number.NaN", void 0, void Number.NaN ); +new TestCase( SECTION, "void Number.POSITIVE_INFINITY", void 0, void Number.POSITIVE_INFINITY ); +new TestCase( SECTION, "void 1", void 0, void 1 ); +new TestCase( SECTION, "void 0", void 0, void 0 ); +new TestCase( SECTION, "void -1", void 0, void -1 ); +new TestCase( SECTION, "void Number.NEGATIVE_INFINITY", void 0, void Number.NEGATIVE_INFINITY ); +new TestCase( SECTION, "void Math.PI", void 0, void Math.PI ); +new TestCase( SECTION, "void true", void 0, void true ); +new TestCase( SECTION, "void false", void 0, void false ); +new TestCase( SECTION, "void null", void 0, void null ); + +// array[item++] = new TestCase( SECTION, "void()", void 0, void() ); + +test(); diff --git a/tests/auto/qml/parserstress/tests/ecma/Expressions/11.4.3.js b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.4.3.js new file mode 100644 index 0000000000..b746fbe8b5 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.4.3.js @@ -0,0 +1,111 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '11.4.3.js'; + +/** + File Name: typeof_1.js + ECMA Section: 11.4.3 typeof operator + Description: typeof evaluates unary expressions: + undefined "undefined" + null "object" + Boolean "boolean" + Number "number" + String "string" + Object "object" [native, doesn't implement Call] + Object "function" [native, implements [Call]] + Object implementation dependent + [not sure how to test this] + Author: christine@netscape.com + Date: june 30, 1997 + +*/ + +var SECTION = "11.4.3"; + +var VERSION = "ECMA_1"; +startTest(); +var TITLE = " The typeof operator"; +writeHeaderToLog( SECTION + " "+ TITLE); + +new TestCase( SECTION, "typeof(void(0))", "undefined", typeof(void(0)) ); +new TestCase( SECTION, "typeof(null)", "object", typeof(null) ); +new TestCase( SECTION, "typeof(true)", "boolean", typeof(true) ); +new TestCase( SECTION, "typeof(false)", "boolean", typeof(false) ); +new TestCase( SECTION, "typeof(new Boolean())", "object", typeof(new Boolean()) ); +new TestCase( SECTION, "typeof(new Boolean(true))", "object", typeof(new Boolean(true)) ); +new TestCase( SECTION, "typeof(Boolean())", "boolean", typeof(Boolean()) ); +new TestCase( SECTION, "typeof(Boolean(false))", "boolean", typeof(Boolean(false)) ); +new TestCase( SECTION, "typeof(Boolean(true))", "boolean", typeof(Boolean(true)) ); +new TestCase( SECTION, "typeof(NaN)", "number", typeof(Number.NaN) ); +new TestCase( SECTION, "typeof(Infinity)", "number", typeof(Number.POSITIVE_INFINITY) ); +new TestCase( SECTION, "typeof(-Infinity)", "number", typeof(Number.NEGATIVE_INFINITY) ); +new TestCase( SECTION, "typeof(Math.PI)", "number", typeof(Math.PI) ); +new TestCase( SECTION, "typeof(0)", "number", typeof(0) ); +new TestCase( SECTION, "typeof(1)", "number", typeof(1) ); +new TestCase( SECTION, "typeof(-1)", "number", typeof(-1) ); +new TestCase( SECTION, "typeof('0')", "string", typeof("0") ); +new TestCase( SECTION, "typeof(Number())", "number", typeof(Number()) ); +new TestCase( SECTION, "typeof(Number(0))", "number", typeof(Number(0)) ); +new TestCase( SECTION, "typeof(Number(1))", "number", typeof(Number(1)) ); +new TestCase( SECTION, "typeof(Nubmer(-1))", "number", typeof(Number(-1)) ); +new TestCase( SECTION, "typeof(new Number())", "object", typeof(new Number()) ); +new TestCase( SECTION, "typeof(new Number(0))", "object", typeof(new Number(0)) ); +new TestCase( SECTION, "typeof(new Number(1))", "object", typeof(new Number(1)) ); + +// Math does not implement [[Construct]] or [[Call]] so its type is object. + +new TestCase( SECTION, "typeof(Math)", "object", typeof(Math) ); + +new TestCase( SECTION, "typeof(Number.prototype.toString)", "function", typeof(Number.prototype.toString) ); + +new TestCase( SECTION, "typeof('a string')", "string", typeof("a string") ); +new TestCase( SECTION, "typeof('')", "string", typeof("") ); +new TestCase( SECTION, "typeof(new Date())", "object", typeof(new Date()) ); +new TestCase( SECTION, "typeof(new Array(1,2,3))", "object", typeof(new Array(1,2,3)) ); +new TestCase( SECTION, "typeof(new String('string object'))", "object", typeof(new String("string object")) ); +new TestCase( SECTION, "typeof(String('string primitive'))", "string", typeof(String("string primitive")) ); +new TestCase( SECTION, "typeof(['array', 'of', 'strings'])", "object", typeof(["array", "of", "strings"]) ); +new TestCase( SECTION, "typeof(new Function())", "function", typeof( new Function() ) ); +new TestCase( SECTION, "typeof(parseInt)", "function", typeof( parseInt ) ); +new TestCase( SECTION, "typeof(test)", "function", typeof( test ) ); +new TestCase( SECTION, "typeof(String.fromCharCode)", "function", typeof( String.fromCharCode ) ); + + +test(); + diff --git a/tests/auto/qml/parserstress/tests/ecma/Expressions/11.4.4.js b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.4.4.js new file mode 100644 index 0000000000..cbacf869e4 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.4.4.js @@ -0,0 +1,156 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '11.4.4.js'; + +/** + File Name: 11.4.4.js + ECMA Section: 11.4.4 Prefix increment operator + Description: + The production UnaryExpression : ++ UnaryExpression is evaluated as + follows: + + 1. Evaluate UnaryExpression. + 2. Call GetValue(Result(1)). + 3. Call ToNumber(Result(2)). + 4. Add the value 1 to Result(3), using the same rules as for the + + operator (section 11.6.3). + 5. Call PutValue(Result(1), Result(4)). + 6. Return Result(4). + + Author: christine@netscape.com + Date: 12 november 1997 +*/ +var SECTION = "11.4.4"; +var VERSION = "ECMA_1"; +startTest(); + +writeHeaderToLog( SECTION + " Prefix increment operator"); + +// special case: var is not defined + +new TestCase( SECTION, "var MYVAR; ++MYVAR", NaN, eval("var MYVAR; ++MYVAR") ); +new TestCase( SECTION, "var MYVAR= void 0; ++MYVAR", NaN, eval("var MYVAR=void 0; ++MYVAR") ); +new TestCase( SECTION, "var MYVAR=null; ++MYVAR", 1, eval("var MYVAR=null; ++MYVAR") ); +new TestCase( SECTION, "var MYVAR=true; ++MYVAR", 2, eval("var MYVAR=true; ++MYVAR") ); +new TestCase( SECTION, "var MYVAR=false; ++MYVAR", 1, eval("var MYVAR=false; ++MYVAR") ); + +// special numbers +// verify return value + +new TestCase( SECTION, "var MYVAR=Number.POSITIVE_INFINITY;++MYVAR", Number.POSITIVE_INFINITY, eval("var MYVAR=Number.POSITIVE_INFINITY;++MYVAR") ); +new TestCase( SECTION, "var MYVAR=Number.NEGATIVE_INFINITY;++MYVAR", Number.NEGATIVE_INFINITY, eval("var MYVAR=Number.NEGATIVE_INFINITY;++MYVAR") ); +new TestCase( SECTION, "var MYVAR=Number.NaN;++MYVAR", Number.NaN, eval("var MYVAR=Number.NaN;++MYVAR") ); + +// verify value of variable + +new TestCase( SECTION, "var MYVAR=Number.POSITIVE_INFINITY;++MYVAR;MYVAR", Number.POSITIVE_INFINITY, eval("var MYVAR=Number.POSITIVE_INFINITY;++MYVAR;MYVAR") ); +new TestCase( SECTION, "var MYVAR=Number.NEGATIVE_INFINITY;++MYVAR;MYVAR", Number.NEGATIVE_INFINITY, eval("var MYVAR=Number.NEGATIVE_INFINITY;++MYVAR;MYVAR") ); +new TestCase( SECTION, "var MYVAR=Number.NaN;++MYVAR;MYVAR", Number.NaN, eval("var MYVAR=Number.NaN;++MYVAR;MYVAR") ); + + +// number primitives +new TestCase( SECTION, "var MYVAR=0;++MYVAR", 1, eval("var MYVAR=0;++MYVAR") ); +new TestCase( SECTION, "var MYVAR=0.2345;++MYVAR", 1.2345, eval("var MYVAR=0.2345;++MYVAR") ); +new TestCase( SECTION, "var MYVAR=-0.2345;++MYVAR", 0.7655, eval("var MYVAR=-0.2345;++MYVAR") ); + +// verify value of variable + +new TestCase( SECTION, "var MYVAR=0;++MYVAR;MYVAR", 1, eval("var MYVAR=0;++MYVAR;MYVAR") ); +new TestCase( SECTION, "var MYVAR=0.2345;++MYVAR;MYVAR", 1.2345, eval("var MYVAR=0.2345;++MYVAR;MYVAR") ); +new TestCase( SECTION, "var MYVAR=-0.2345;++MYVAR;MYVAR", 0.7655, eval("var MYVAR=-0.2345;++MYVAR;MYVAR") ); +new TestCase( SECTION, "var MYVAR=0;++MYVAR;MYVAR", 1, eval("var MYVAR=0;++MYVAR;MYVAR") ); +new TestCase( SECTION, "var MYVAR=0;++MYVAR;MYVAR", 1, eval("var MYVAR=0;++MYVAR;MYVAR") ); +new TestCase( SECTION, "var MYVAR=0;++MYVAR;MYVAR", 1, eval("var MYVAR=0;++MYVAR;MYVAR") ); + +// boolean values +// verify return value + +new TestCase( SECTION, "var MYVAR=true;++MYVAR", 2, eval("var MYVAR=true;++MYVAR") ); +new TestCase( SECTION, "var MYVAR=false;++MYVAR", 1, eval("var MYVAR=false;++MYVAR") ); +// verify value of variable + +new TestCase( SECTION, "var MYVAR=true;++MYVAR;MYVAR", 2, eval("var MYVAR=true;++MYVAR;MYVAR") ); +new TestCase( SECTION, "var MYVAR=false;++MYVAR;MYVAR", 1, eval("var MYVAR=false;++MYVAR;MYVAR") ); + +// boolean objects +// verify return value + +new TestCase( SECTION, "var MYVAR=new Boolean(true);++MYVAR", 2, eval("var MYVAR=true;++MYVAR") ); +new TestCase( SECTION, "var MYVAR=new Boolean(false);++MYVAR", 1, eval("var MYVAR=false;++MYVAR") ); +// verify value of variable + +new TestCase( SECTION, "var MYVAR=new Boolean(true);++MYVAR;MYVAR", 2, eval("var MYVAR=new Boolean(true);++MYVAR;MYVAR") ); +new TestCase( SECTION, "var MYVAR=new Boolean(false);++MYVAR;MYVAR", 1, eval("var MYVAR=new Boolean(false);++MYVAR;MYVAR") ); + +// string primitives +new TestCase( SECTION, "var MYVAR='string';++MYVAR", Number.NaN, eval("var MYVAR='string';++MYVAR") ); +new TestCase( SECTION, "var MYVAR='12345';++MYVAR", 12346, eval("var MYVAR='12345';++MYVAR") ); +new TestCase( SECTION, "var MYVAR='-12345';++MYVAR", -12344, eval("var MYVAR='-12345';++MYVAR") ); +new TestCase( SECTION, "var MYVAR='0Xf';++MYVAR", 16, eval("var MYVAR='0Xf';++MYVAR") ); +new TestCase( SECTION, "var MYVAR='077';++MYVAR", 78, eval("var MYVAR='077';++MYVAR") ); +new TestCase( SECTION, "var MYVAR=''; ++MYVAR", 1, eval("var MYVAR='';++MYVAR") ); + +// verify value of variable + +new TestCase( SECTION, "var MYVAR='string';++MYVAR;MYVAR", Number.NaN, eval("var MYVAR='string';++MYVAR;MYVAR") ); +new TestCase( SECTION, "var MYVAR='12345';++MYVAR;MYVAR", 12346, eval("var MYVAR='12345';++MYVAR;MYVAR") ); +new TestCase( SECTION, "var MYVAR='-12345';++MYVAR;MYVAR", -12344, eval("var MYVAR='-12345';++MYVAR;MYVAR") ); +new TestCase( SECTION, "var MYVAR='0xf';++MYVAR;MYVAR", 16, eval("var MYVAR='0xf';++MYVAR;MYVAR") ); +new TestCase( SECTION, "var MYVAR='077';++MYVAR;MYVAR", 78, eval("var MYVAR='077';++MYVAR;MYVAR") ); +new TestCase( SECTION, "var MYVAR='';++MYVAR;MYVAR", 1, eval("var MYVAR='';++MYVAR;MYVAR") ); + +// string objects +new TestCase( SECTION, "var MYVAR=new String('string');++MYVAR", Number.NaN, eval("var MYVAR=new String('string');++MYVAR") ); +new TestCase( SECTION, "var MYVAR=new String('12345');++MYVAR", 12346, eval("var MYVAR=new String('12345');++MYVAR") ); +new TestCase( SECTION, "var MYVAR=new String('-12345');++MYVAR", -12344, eval("var MYVAR=new String('-12345');++MYVAR") ); +new TestCase( SECTION, "var MYVAR=new String('0Xf');++MYVAR", 16, eval("var MYVAR=new String('0Xf');++MYVAR") ); +new TestCase( SECTION, "var MYVAR=new String('077');++MYVAR", 78, eval("var MYVAR=new String('077');++MYVAR") ); +new TestCase( SECTION, "var MYVAR=new String(''); ++MYVAR", 1, eval("var MYVAR=new String('');++MYVAR") ); + +// verify value of variable + +new TestCase( SECTION, "var MYVAR=new String('string');++MYVAR;MYVAR", Number.NaN, eval("var MYVAR=new String('string');++MYVAR;MYVAR") ); +new TestCase( SECTION, "var MYVAR=new String('12345');++MYVAR;MYVAR", 12346, eval("var MYVAR=new String('12345');++MYVAR;MYVAR") ); +new TestCase( SECTION, "var MYVAR=new String('-12345');++MYVAR;MYVAR", -12344, eval("var MYVAR=new String('-12345');++MYVAR;MYVAR") ); +new TestCase( SECTION, "var MYVAR=new String('0xf');++MYVAR;MYVAR", 16, eval("var MYVAR=new String('0xf');++MYVAR;MYVAR") ); +new TestCase( SECTION, "var MYVAR=new String('077');++MYVAR;MYVAR", 78, eval("var MYVAR=new String('077');++MYVAR;MYVAR") ); +new TestCase( SECTION, "var MYVAR=new String('');++MYVAR;MYVAR", 1, eval("var MYVAR=new String('');++MYVAR;MYVAR") ); + +test(); + diff --git a/tests/auto/qml/parserstress/tests/ecma/Expressions/11.4.5.js b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.4.5.js new file mode 100644 index 0000000000..ee761c5d96 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.4.5.js @@ -0,0 +1,154 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '11.4.5.js'; + +/** + File Name: 11.4.5.js + ECMA Section: 11.4.5 Prefix decrement operator + Description: + + The production UnaryExpression : -- UnaryExpression is evaluated as follows: + + 1.Evaluate UnaryExpression. + 2.Call GetValue(Result(1)). + 3.Call ToNumber(Result(2)). + 4.Subtract the value 1 from Result(3), using the same rules as for the - operator (section 11.6.3). + 5.Call PutValue(Result(1), Result(4)). + + 1.Return Result(4). + Author: christine@netscape.com + Date: \ 12 november 1997 +*/ +var SECTION = "11.4.5"; +var VERSION = "ECMA_1"; +startTest(); + +writeHeaderToLog( SECTION + " Prefix decrement operator"); + +// +new TestCase( SECTION, "var MYVAR; --MYVAR", NaN, eval("var MYVAR; --MYVAR") ); +new TestCase( SECTION, "var MYVAR= void 0; --MYVAR", NaN, eval("var MYVAR=void 0; --MYVAR") ); +new TestCase( SECTION, "var MYVAR=null; --MYVAR", -1, eval("var MYVAR=null; --MYVAR") ); +new TestCase( SECTION, "var MYVAR=true; --MYVAR", 0, eval("var MYVAR=true; --MYVAR") ); +new TestCase( SECTION, "var MYVAR=false; --MYVAR", -1, eval("var MYVAR=false; --MYVAR") ); + +// special numbers +// verify return value + +new TestCase( SECTION, "var MYVAR=Number.POSITIVE_INFINITY;--MYVAR", Number.POSITIVE_INFINITY, eval("var MYVAR=Number.POSITIVE_INFINITY;--MYVAR") ); +new TestCase( SECTION, "var MYVAR=Number.NEGATIVE_INFINITY;--MYVAR", Number.NEGATIVE_INFINITY, eval("var MYVAR=Number.NEGATIVE_INFINITY;--MYVAR") ); +new TestCase( SECTION, "var MYVAR=Number.NaN;--MYVAR", Number.NaN, eval("var MYVAR=Number.NaN;--MYVAR") ); + +// verify value of variable + +new TestCase( SECTION, "var MYVAR=Number.POSITIVE_INFINITY;--MYVAR;MYVAR", Number.POSITIVE_INFINITY, eval("var MYVAR=Number.POSITIVE_INFINITY;--MYVAR;MYVAR") ); +new TestCase( SECTION, "var MYVAR=Number.NEGATIVE_INFINITY;--MYVAR;MYVAR", Number.NEGATIVE_INFINITY, eval("var MYVAR=Number.NEGATIVE_INFINITY;--MYVAR;MYVAR") ); +new TestCase( SECTION, "var MYVAR=Number.NaN;--MYVAR;MYVAR", Number.NaN, eval("var MYVAR=Number.NaN;--MYVAR;MYVAR") ); + + +// number primitives +new TestCase( SECTION, "var MYVAR=0;--MYVAR", -1, eval("var MYVAR=0;--MYVAR") ); +new TestCase( SECTION, "var MYVAR=0.2345;--MYVAR", -0.7655, eval("var MYVAR=0.2345;--MYVAR") ); +new TestCase( SECTION, "var MYVAR=-0.2345;--MYVAR", -1.2345, eval("var MYVAR=-0.2345;--MYVAR") ); + +// verify value of variable + +new TestCase( SECTION, "var MYVAR=0;--MYVAR;MYVAR", -1, eval("var MYVAR=0;--MYVAR;MYVAR") ); +new TestCase( SECTION, "var MYVAR=0.2345;--MYVAR;MYVAR", -0.7655, eval("var MYVAR=0.2345;--MYVAR;MYVAR") ); +new TestCase( SECTION, "var MYVAR=-0.2345;--MYVAR;MYVAR", -1.2345, eval("var MYVAR=-0.2345;--MYVAR;MYVAR") ); +new TestCase( SECTION, "var MYVAR=0;--MYVAR;MYVAR", -1, eval("var MYVAR=0;--MYVAR;MYVAR") ); +new TestCase( SECTION, "var MYVAR=0;--MYVAR;MYVAR", -1, eval("var MYVAR=0;--MYVAR;MYVAR") ); +new TestCase( SECTION, "var MYVAR=0;--MYVAR;MYVAR", -1, eval("var MYVAR=0;--MYVAR;MYVAR") ); + +// boolean values +// verify return value + +new TestCase( SECTION, "var MYVAR=true;--MYVAR", 0, eval("var MYVAR=true;--MYVAR") ); +new TestCase( SECTION, "var MYVAR=false;--MYVAR", -1, eval("var MYVAR=false;--MYVAR") ); +// verify value of variable + +new TestCase( SECTION, "var MYVAR=true;--MYVAR;MYVAR", 0, eval("var MYVAR=true;--MYVAR;MYVAR") ); +new TestCase( SECTION, "var MYVAR=false;--MYVAR;MYVAR", -1, eval("var MYVAR=false;--MYVAR;MYVAR") ); + +// boolean objects +// verify return value + +new TestCase( SECTION, "var MYVAR=new Boolean(true);--MYVAR", 0, eval("var MYVAR=true;--MYVAR") ); +new TestCase( SECTION, "var MYVAR=new Boolean(false);--MYVAR", -1, eval("var MYVAR=false;--MYVAR") ); +// verify value of variable + +new TestCase( SECTION, "var MYVAR=new Boolean(true);--MYVAR;MYVAR", 0, eval("var MYVAR=new Boolean(true);--MYVAR;MYVAR") ); +new TestCase( SECTION, "var MYVAR=new Boolean(false);--MYVAR;MYVAR", -1, eval("var MYVAR=new Boolean(false);--MYVAR;MYVAR") ); + +// string primitives +new TestCase( SECTION, "var MYVAR='string';--MYVAR", Number.NaN, eval("var MYVAR='string';--MYVAR") ); +new TestCase( SECTION, "var MYVAR='12345';--MYVAR", 12344, eval("var MYVAR='12345';--MYVAR") ); +new TestCase( SECTION, "var MYVAR='-12345';--MYVAR", -12346, eval("var MYVAR='-12345';--MYVAR") ); +new TestCase( SECTION, "var MYVAR='0Xf';--MYVAR", 14, eval("var MYVAR='0Xf';--MYVAR") ); +new TestCase( SECTION, "var MYVAR='077';--MYVAR", 76, eval("var MYVAR='077';--MYVAR") ); +new TestCase( SECTION, "var MYVAR=''; --MYVAR", -1, eval("var MYVAR='';--MYVAR") ); + +// verify value of variable + +new TestCase( SECTION, "var MYVAR='string';--MYVAR;MYVAR", Number.NaN, eval("var MYVAR='string';--MYVAR;MYVAR") ); +new TestCase( SECTION, "var MYVAR='12345';--MYVAR;MYVAR", 12344, eval("var MYVAR='12345';--MYVAR;MYVAR") ); +new TestCase( SECTION, "var MYVAR='-12345';--MYVAR;MYVAR", -12346, eval("var MYVAR='-12345';--MYVAR;MYVAR") ); +new TestCase( SECTION, "var MYVAR='0xf';--MYVAR;MYVAR", 14, eval("var MYVAR='0xf';--MYVAR;MYVAR") ); +new TestCase( SECTION, "var MYVAR='077';--MYVAR;MYVAR", 76, eval("var MYVAR='077';--MYVAR;MYVAR") ); +new TestCase( SECTION, "var MYVAR='';--MYVAR;MYVAR", -1, eval("var MYVAR='';--MYVAR;MYVAR") ); + +// string objects +new TestCase( SECTION, "var MYVAR=new String('string');--MYVAR", Number.NaN, eval("var MYVAR=new String('string');--MYVAR") ); +new TestCase( SECTION, "var MYVAR=new String('12345');--MYVAR", 12344, eval("var MYVAR=new String('12345');--MYVAR") ); +new TestCase( SECTION, "var MYVAR=new String('-12345');--MYVAR", -12346, eval("var MYVAR=new String('-12345');--MYVAR") ); +new TestCase( SECTION, "var MYVAR=new String('0Xf');--MYVAR", 14, eval("var MYVAR=new String('0Xf');--MYVAR") ); +new TestCase( SECTION, "var MYVAR=new String('077');--MYVAR", 76, eval("var MYVAR=new String('077');--MYVAR") ); +new TestCase( SECTION, "var MYVAR=new String(''); --MYVAR", -1, eval("var MYVAR=new String('');--MYVAR") ); + +// verify value of variable + +new TestCase( SECTION, "var MYVAR=new String('string');--MYVAR;MYVAR", Number.NaN, eval("var MYVAR=new String('string');--MYVAR;MYVAR") ); +new TestCase( SECTION, "var MYVAR=new String('12345');--MYVAR;MYVAR", 12344, eval("var MYVAR=new String('12345');--MYVAR;MYVAR") ); +new TestCase( SECTION, "var MYVAR=new String('-12345');--MYVAR;MYVAR", -12346, eval("var MYVAR=new String('-12345');--MYVAR;MYVAR") ); +new TestCase( SECTION, "var MYVAR=new String('0xf');--MYVAR;MYVAR", 14, eval("var MYVAR=new String('0xf');--MYVAR;MYVAR") ); +new TestCase( SECTION, "var MYVAR=new String('077');--MYVAR;MYVAR", 76, eval("var MYVAR=new String('077');--MYVAR;MYVAR") ); +new TestCase( SECTION, "var MYVAR=new String('');--MYVAR;MYVAR", -1, eval("var MYVAR=new String('');--MYVAR;MYVAR") ); + +test(); + diff --git a/tests/auto/qml/parserstress/tests/ecma/Expressions/11.4.6.js b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.4.6.js new file mode 100644 index 0000000000..9b100d9d50 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.4.6.js @@ -0,0 +1,299 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '11.4.6.js'; + +/** + File Name: 11.4.6.js + ECMA Section: 11.4.6 Unary + Operator + Description: convert operand to Number type + Author: christine@netscape.com + Date: 7 july 1997 +*/ + +var SECTION = "11.4.6"; +var VERSION = "ECMA_1"; +var BUGNUMBER="77391"; + +startTest(); + +writeHeaderToLog( SECTION + " Unary + operator"); + +new TestCase( SECTION, "+('')", 0, +("") ); +new TestCase( SECTION, "+(' ')", 0, +(" ") ); +new TestCase( SECTION, "+(\\t)", 0, +("\t") ); +new TestCase( SECTION, "+(\\n)", 0, +("\n") ); +new TestCase( SECTION, "+(\\r)", 0, +("\r") ); +new TestCase( SECTION, "+(\\f)", 0, +("\f") ); + +new TestCase( SECTION, "+(String.fromCharCode(0x0009)", 0, +(String.fromCharCode(0x0009)) ); +new TestCase( SECTION, "+(String.fromCharCode(0x0020)", 0, +(String.fromCharCode(0x0020)) ); +new TestCase( SECTION, "+(String.fromCharCode(0x000C)", 0, +(String.fromCharCode(0x000C)) ); +new TestCase( SECTION, "+(String.fromCharCode(0x000B)", 0, +(String.fromCharCode(0x000B)) ); +new TestCase( SECTION, "+(String.fromCharCode(0x000D)", 0, +(String.fromCharCode(0x000D)) ); +new TestCase( SECTION, "+(String.fromCharCode(0x000A)", 0, +(String.fromCharCode(0x000A)) ); + +// a StringNumericLiteral may be preceeded or followed by whitespace and/or +// line terminators + +new TestCase( SECTION, "+( ' ' + 999 )", 999, +( ' '+999) ); +new TestCase( SECTION, "+( '\\n' + 999 )", 999, +( '\n' +999) ); +new TestCase( SECTION, "+( '\\r' + 999 )", 999, +( '\r' +999) ); +new TestCase( SECTION, "+( '\\t' + 999 )", 999, +( '\t' +999) ); +new TestCase( SECTION, "+( '\\f' + 999 )", 999, +( '\f' +999) ); + +new TestCase( SECTION, "+( 999 + ' ' )", 999, +( 999+' ') ); +new TestCase( SECTION, "+( 999 + '\\n' )", 999, +( 999+'\n' ) ); +new TestCase( SECTION, "+( 999 + '\\r' )", 999, +( 999+'\r' ) ); +new TestCase( SECTION, "+( 999 + '\\t' )", 999, +( 999+'\t' ) ); +new TestCase( SECTION, "+( 999 + '\\f' )", 999, +( 999+'\f' ) ); + +new TestCase( SECTION, "+( '\\n' + 999 + '\\n' )", 999, +( '\n' +999+'\n' ) ); +new TestCase( SECTION, "+( '\\r' + 999 + '\\r' )", 999, +( '\r' +999+'\r' ) ); +new TestCase( SECTION, "+( '\\t' + 999 + '\\t' )", 999, +( '\t' +999+'\t' ) ); +new TestCase( SECTION, "+( '\\f' + 999 + '\\f' )", 999, +( '\f' +999+'\f' ) ); + +new TestCase( SECTION, "+( ' ' + '999' )", 999, +( ' '+'999') ); +new TestCase( SECTION, "+( '\\n' + '999' )", 999, +( '\n' +'999') ); +new TestCase( SECTION, "+( '\\r' + '999' )", 999, +( '\r' +'999') ); +new TestCase( SECTION, "+( '\\t' + '999' )", 999, +( '\t' +'999') ); +new TestCase( SECTION, "+( '\\f' + '999' )", 999, +( '\f' +'999') ); + +new TestCase( SECTION, "+( '999' + ' ' )", 999, +( '999'+' ') ); +new TestCase( SECTION, "+( '999' + '\\n' )", 999, +( '999'+'\n' ) ); +new TestCase( SECTION, "+( '999' + '\\r' )", 999, +( '999'+'\r' ) ); +new TestCase( SECTION, "+( '999' + '\\t' )", 999, +( '999'+'\t' ) ); +new TestCase( SECTION, "+( '999' + '\\f' )", 999, +( '999'+'\f' ) ); + +new TestCase( SECTION, "+( '\\n' + '999' + '\\n' )", 999, +( '\n' +'999'+'\n' ) ); +new TestCase( SECTION, "+( '\\r' + '999' + '\\r' )", 999, +( '\r' +'999'+'\r' ) ); +new TestCase( SECTION, "+( '\\t' + '999' + '\\t' )", 999, +( '\t' +'999'+'\t' ) ); +new TestCase( SECTION, "+( '\\f' + '999' + '\\f' )", 999, +( '\f' +'999'+'\f' ) ); + +new TestCase( SECTION, "+( String.fromCharCode(0x0009) + '99' )", 99, +( String.fromCharCode(0x0009) + '99' ) ); +new TestCase( SECTION, "+( String.fromCharCode(0x0020) + '99' )", 99, +( String.fromCharCode(0x0020) + '99' ) ); +new TestCase( SECTION, "+( String.fromCharCode(0x000C) + '99' )", 99, +( String.fromCharCode(0x000C) + '99' ) ); +new TestCase( SECTION, "+( String.fromCharCode(0x000B) + '99' )", 99, +( String.fromCharCode(0x000B) + '99' ) ); +new TestCase( SECTION, "+( String.fromCharCode(0x000D) + '99' )", 99, +( String.fromCharCode(0x000D) + '99' ) ); +new TestCase( SECTION, "+( String.fromCharCode(0x000A) + '99' )", 99, +( String.fromCharCode(0x000A) + '99' ) ); + +new TestCase( SECTION, "+( String.fromCharCode(0x0009) + '99' + String.fromCharCode(0x0009)", 99, +( String.fromCharCode(0x0009) + '99' + String.fromCharCode(0x0009)) ); +new TestCase( SECTION, "+( String.fromCharCode(0x0020) + '99' + String.fromCharCode(0x0020)", 99, +( String.fromCharCode(0x0009) + '99' + String.fromCharCode(0x0020)) ); +new TestCase( SECTION, "+( String.fromCharCode(0x000C) + '99' + String.fromCharCode(0x000C)", 99, +( String.fromCharCode(0x0009) + '99' + String.fromCharCode(0x000C)) ); +new TestCase( SECTION, "+( String.fromCharCode(0x000D) + '99' + String.fromCharCode(0x000D)", 99, +( String.fromCharCode(0x0009) + '99' + String.fromCharCode(0x000D)) ); +new TestCase( SECTION, "+( String.fromCharCode(0x000B) + '99' + String.fromCharCode(0x000B)", 99, +( String.fromCharCode(0x0009) + '99' + String.fromCharCode(0x000B)) ); +new TestCase( SECTION, "+( String.fromCharCode(0x000A) + '99' + String.fromCharCode(0x000A)", 99, +( String.fromCharCode(0x0009) + '99' + String.fromCharCode(0x000A)) ); + +new TestCase( SECTION, "+( '99' + String.fromCharCode(0x0009)", 99, +( '99' + String.fromCharCode(0x0009)) ); +new TestCase( SECTION, "+( '99' + String.fromCharCode(0x0020)", 99, +( '99' + String.fromCharCode(0x0020)) ); +new TestCase( SECTION, "+( '99' + String.fromCharCode(0x000C)", 99, +( '99' + String.fromCharCode(0x000C)) ); +new TestCase( SECTION, "+( '99' + String.fromCharCode(0x000D)", 99, +( '99' + String.fromCharCode(0x000D)) ); +new TestCase( SECTION, "+( '99' + String.fromCharCode(0x000B)", 99, +( '99' + String.fromCharCode(0x000B)) ); +new TestCase( SECTION, "+( '99' + String.fromCharCode(0x000A)", 99, +( '99' + String.fromCharCode(0x000A)) ); + +new TestCase( SECTION, "+( String.fromCharCode(0x0009) + 99 )", 99, +( String.fromCharCode(0x0009) + 99 ) ); +new TestCase( SECTION, "+( String.fromCharCode(0x0020) + 99 )", 99, +( String.fromCharCode(0x0020) + 99 ) ); +new TestCase( SECTION, "+( String.fromCharCode(0x000C) + 99 )", 99, +( String.fromCharCode(0x000C) + 99 ) ); +new TestCase( SECTION, "+( String.fromCharCode(0x000B) + 99 )", 99, +( String.fromCharCode(0x000B) + 99 ) ); +new TestCase( SECTION, "+( String.fromCharCode(0x000D) + 99 )", 99, +( String.fromCharCode(0x000D) + 99 ) ); +new TestCase( SECTION, "+( String.fromCharCode(0x000A) + 99 )", 99, +( String.fromCharCode(0x000A) + 99 ) ); + +new TestCase( SECTION, "+( String.fromCharCode(0x0009) + 99 + String.fromCharCode(0x0009)", 99, +( String.fromCharCode(0x0009) + 99 + String.fromCharCode(0x0009)) ); +new TestCase( SECTION, "+( String.fromCharCode(0x0020) + 99 + String.fromCharCode(0x0020)", 99, +( String.fromCharCode(0x0009) + 99 + String.fromCharCode(0x0020)) ); +new TestCase( SECTION, "+( String.fromCharCode(0x000C) + 99 + String.fromCharCode(0x000C)", 99, +( String.fromCharCode(0x0009) + 99 + String.fromCharCode(0x000C)) ); +new TestCase( SECTION, "+( String.fromCharCode(0x000D) + 99 + String.fromCharCode(0x000D)", 99, +( String.fromCharCode(0x0009) + 99 + String.fromCharCode(0x000D)) ); +new TestCase( SECTION, "+( String.fromCharCode(0x000B) + 99 + String.fromCharCode(0x000B)", 99, +( String.fromCharCode(0x0009) + 99 + String.fromCharCode(0x000B)) ); +new TestCase( SECTION, "+( String.fromCharCode(0x000A) + 99 + String.fromCharCode(0x000A)", 99, +( String.fromCharCode(0x0009) + 99 + String.fromCharCode(0x000A)) ); + +new TestCase( SECTION, "+( 99 + String.fromCharCode(0x0009)", 99, +( 99 + String.fromCharCode(0x0009)) ); +new TestCase( SECTION, "+( 99 + String.fromCharCode(0x0020)", 99, +( 99 + String.fromCharCode(0x0020)) ); +new TestCase( SECTION, "+( 99 + String.fromCharCode(0x000C)", 99, +( 99 + String.fromCharCode(0x000C)) ); +new TestCase( SECTION, "+( 99 + String.fromCharCode(0x000D)", 99, +( 99 + String.fromCharCode(0x000D)) ); +new TestCase( SECTION, "+( 99 + String.fromCharCode(0x000B)", 99, +( 99 + String.fromCharCode(0x000B)) ); +new TestCase( SECTION, "+( 99 + String.fromCharCode(0x000A)", 99, +( 99 + String.fromCharCode(0x000A)) ); + + +// StrNumericLiteral:::StrDecimalLiteral:::Infinity + +new TestCase( SECTION, "+('Infinity')", Math.pow(10,10000), +("Infinity") ); +new TestCase( SECTION, "+('-Infinity')", -Math.pow(10,10000), +("-Infinity") ); +new TestCase( SECTION, "+('+Infinity')", Math.pow(10,10000), +("+Infinity") ); + +// StrNumericLiteral::: StrDecimalLiteral ::: DecimalDigits . DecimalDigits opt ExponentPart opt + +new TestCase( SECTION, "+('0')", 0, +("0") ); +new TestCase( SECTION, "+('-0')", -0, +("-0") ); +new TestCase( SECTION, "+('+0')", 0, +("+0") ); + +new TestCase( SECTION, "+('1')", 1, +("1") ); +new TestCase( SECTION, "+('-1')", -1, +("-1") ); +new TestCase( SECTION, "+('+1')", 1, +("+1") ); + +new TestCase( SECTION, "+('2')", 2, +("2") ); +new TestCase( SECTION, "+('-2')", -2, +("-2") ); +new TestCase( SECTION, "+('+2')", 2, +("+2") ); + +new TestCase( SECTION, "+('3')", 3, +("3") ); +new TestCase( SECTION, "+('-3')", -3, +("-3") ); +new TestCase( SECTION, "+('+3')", 3, +("+3") ); + +new TestCase( SECTION, "+('4')", 4, +("4") ); +new TestCase( SECTION, "+('-4')", -4, +("-4") ); +new TestCase( SECTION, "+('+4')", 4, +("+4") ); + +new TestCase( SECTION, "+('5')", 5, +("5") ); +new TestCase( SECTION, "+('-5')", -5, +("-5") ); +new TestCase( SECTION, "+('+5')", 5, +("+5") ); + +new TestCase( SECTION, "+('6')", 6, +("6") ); +new TestCase( SECTION, "+('-6')", -6, +("-6") ); +new TestCase( SECTION, "+('+6')", 6, +("+6") ); + +new TestCase( SECTION, "+('7')", 7, +("7") ); +new TestCase( SECTION, "+('-7')", -7, +("-7") ); +new TestCase( SECTION, "+('+7')", 7, +("+7") ); + +new TestCase( SECTION, "+('8')", 8, +("8") ); +new TestCase( SECTION, "+('-8')", -8, +("-8") ); +new TestCase( SECTION, "+('+8')", 8, +("+8") ); + +new TestCase( SECTION, "+('9')", 9, +("9") ); +new TestCase( SECTION, "+('-9')", -9, +("-9") ); +new TestCase( SECTION, "+('+9')", 9, +("+9") ); + +new TestCase( SECTION, "+('3.14159')", 3.14159, +("3.14159") ); +new TestCase( SECTION, "+('-3.14159')", -3.14159, +("-3.14159") ); +new TestCase( SECTION, "+('+3.14159')", 3.14159, +("+3.14159") ); + +new TestCase( SECTION, "+('3.')", 3, +("3.") ); +new TestCase( SECTION, "+('-3.')", -3, +("-3.") ); +new TestCase( SECTION, "+('+3.')", 3, +("+3.") ); + +new TestCase( SECTION, "+('3.e1')", 30, +("3.e1") ); +new TestCase( SECTION, "+('-3.e1')", -30, +("-3.e1") ); +new TestCase( SECTION, "+('+3.e1')", 30, +("+3.e1") ); + +new TestCase( SECTION, "+('3.e+1')", 30, +("3.e+1") ); +new TestCase( SECTION, "+('-3.e+1')", -30, +("-3.e+1") ); +new TestCase( SECTION, "+('+3.e+1')", 30, +("+3.e+1") ); + +new TestCase( SECTION, "+('3.e-1')", .30, +("3.e-1") ); +new TestCase( SECTION, "+('-3.e-1')", -.30, +("-3.e-1") ); +new TestCase( SECTION, "+('+3.e-1')", .30, +("+3.e-1") ); + +// StrDecimalLiteral::: .DecimalDigits ExponentPart opt + +new TestCase( SECTION, "+('.00001')", 0.00001, +(".00001") ); +new TestCase( SECTION, "+('+.00001')", 0.00001, +("+.00001") ); +new TestCase( SECTION, "+('-0.0001')", -0.00001, +("-.00001") ); + +new TestCase( SECTION, "+('.01e2')", 1, +(".01e2") ); +new TestCase( SECTION, "+('+.01e2')", 1, +("+.01e2") ); +new TestCase( SECTION, "+('-.01e2')", -1, +("-.01e2") ); + +new TestCase( SECTION, "+('.01e+2')", 1, +(".01e+2") ); +new TestCase( SECTION, "+('+.01e+2')", 1, +("+.01e+2") ); +new TestCase( SECTION, "+('-.01e+2')", -1, +("-.01e+2") ); + +new TestCase( SECTION, "+('.01e-2')", 0.0001, +(".01e-2") ); +new TestCase( SECTION, "+('+.01e-2')", 0.0001, +("+.01e-2") ); +new TestCase( SECTION, "+('-.01e-2')", -0.0001, +("-.01e-2") ); + +// StrDecimalLiteral::: DecimalDigits ExponentPart opt + +new TestCase( SECTION, "+('1234e5')", 123400000, +("1234e5") ); +new TestCase( SECTION, "+('+1234e5')", 123400000, +("+1234e5") ); +new TestCase( SECTION, "+('-1234e5')", -123400000, +("-1234e5") ); + +new TestCase( SECTION, "+('1234e+5')", 123400000, +("1234e+5") ); +new TestCase( SECTION, "+('+1234e+5')", 123400000, +("+1234e+5") ); +new TestCase( SECTION, "+('-1234e+5')", -123400000, +("-1234e+5") ); + +new TestCase( SECTION, "+('1234e-5')", 0.01234, +("1234e-5") ); +new TestCase( SECTION, "+('+1234e-5')", 0.01234, +("+1234e-5") ); +new TestCase( SECTION, "+('-1234e-5')", -0.01234, +("-1234e-5") ); + +// StrNumericLiteral::: HexIntegerLiteral + +new TestCase( SECTION, "+('0x0')", 0, +("0x0")); +new TestCase( SECTION, "+('0x1')", 1, +("0x1")); +new TestCase( SECTION, "+('0x2')", 2, +("0x2")); +new TestCase( SECTION, "+('0x3')", 3, +("0x3")); +new TestCase( SECTION, "+('0x4')", 4, +("0x4")); +new TestCase( SECTION, "+('0x5')", 5, +("0x5")); +new TestCase( SECTION, "+('0x6')", 6, +("0x6")); +new TestCase( SECTION, "+('0x7')", 7, +("0x7")); +new TestCase( SECTION, "+('0x8')", 8, +("0x8")); +new TestCase( SECTION, "+('0x9')", 9, +("0x9")); +new TestCase( SECTION, "+('0xa')", 10, +("0xa")); +new TestCase( SECTION, "+('0xb')", 11, +("0xb")); +new TestCase( SECTION, "+('0xc')", 12, +("0xc")); +new TestCase( SECTION, "+('0xd')", 13, +("0xd")); +new TestCase( SECTION, "+('0xe')", 14, +("0xe")); +new TestCase( SECTION, "+('0xf')", 15, +("0xf")); +new TestCase( SECTION, "+('0xA')", 10, +("0xA")); +new TestCase( SECTION, "+('0xB')", 11, +("0xB")); +new TestCase( SECTION, "+('0xC')", 12, +("0xC")); +new TestCase( SECTION, "+('0xD')", 13, +("0xD")); +new TestCase( SECTION, "+('0xE')", 14, +("0xE")); +new TestCase( SECTION, "+('0xF')", 15, +("0xF")); + +new TestCase( SECTION, "+('0X0')", 0, +("0X0")); +new TestCase( SECTION, "+('0X1')", 1, +("0X1")); +new TestCase( SECTION, "+('0X2')", 2, +("0X2")); +new TestCase( SECTION, "+('0X3')", 3, +("0X3")); +new TestCase( SECTION, "+('0X4')", 4, +("0X4")); +new TestCase( SECTION, "+('0X5')", 5, +("0X5")); +new TestCase( SECTION, "+('0X6')", 6, +("0X6")); +new TestCase( SECTION, "+('0X7')", 7, +("0X7")); +new TestCase( SECTION, "+('0X8')", 8, +("0X8")); +new TestCase( SECTION, "+('0X9')", 9, +("0X9")); +new TestCase( SECTION, "+('0Xa')", 10, +("0Xa")); +new TestCase( SECTION, "+('0Xb')", 11, +("0Xb")); +new TestCase( SECTION, "+('0Xc')", 12, +("0Xc")); +new TestCase( SECTION, "+('0Xd')", 13, +("0Xd")); +new TestCase( SECTION, "+('0Xe')", 14, +("0Xe")); +new TestCase( SECTION, "+('0Xf')", 15, +("0Xf")); +new TestCase( SECTION, "+('0XA')", 10, +("0XA")); +new TestCase( SECTION, "+('0XB')", 11, +("0XB")); +new TestCase( SECTION, "+('0XC')", 12, +("0XC")); +new TestCase( SECTION, "+('0XD')", 13, +("0XD")); +new TestCase( SECTION, "+('0XE')", 14, +("0XE")); +new TestCase( SECTION, "+('0XF')", 15, +("0XF")); + +test(); diff --git a/tests/auto/qml/parserstress/tests/ecma/Expressions/11.4.7-01.js b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.4.7-01.js new file mode 100644 index 0000000000..827b80189d --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.4.7-01.js @@ -0,0 +1,299 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '11.4.7-01.js'; + +/** + File Name: 11.4.7-01.js + ECMA Section: 11.4.7 Unary - Operator + Description: convert operand to Number type and change sign + Author: christine@netscape.com + Date: 7 july 1997 +*/ + +var SECTION = "11.4.7"; +var VERSION = "ECMA_1"; +var BUGNUMBER="77391"; + +startTest(); + +writeHeaderToLog( SECTION + " Unary + operator"); + +new TestCase( SECTION, "-('')", -0, -("") ); +new TestCase( SECTION, "-(' ')", -0, -(" ") ); +new TestCase( SECTION, "-(\\t)", -0, -("\t") ); +new TestCase( SECTION, "-(\\n)", -0, -("\n") ); +new TestCase( SECTION, "-(\\r)", -0, -("\r") ); +new TestCase( SECTION, "-(\\f)", -0, -("\f") ); + +new TestCase( SECTION, "-(String.fromCharCode(0x0009)", -0, -(String.fromCharCode(0x0009)) ); +new TestCase( SECTION, "-(String.fromCharCode(0x0020)", -0, -(String.fromCharCode(0x0020)) ); +new TestCase( SECTION, "-(String.fromCharCode(0x000C)", -0, -(String.fromCharCode(0x000C)) ); +new TestCase( SECTION, "-(String.fromCharCode(0x000B)", -0, -(String.fromCharCode(0x000B)) ); +new TestCase( SECTION, "-(String.fromCharCode(0x000D)", -0, -(String.fromCharCode(0x000D)) ); +new TestCase( SECTION, "-(String.fromCharCode(0x000A)", -0, -(String.fromCharCode(0x000A)) ); + +// a StringNumericLiteral may be preceeded or followed by whitespace and/or +// line terminators + +new TestCase( SECTION, "-( ' ' + 999 )", -999, -( ' '+999) ); +new TestCase( SECTION, "-( '\\n' + 999 )", -999, -( '\n' +999) ); +new TestCase( SECTION, "-( '\\r' + 999 )", -999, -( '\r' +999) ); +new TestCase( SECTION, "-( '\\t' + 999 )", -999, -( '\t' +999) ); +new TestCase( SECTION, "-( '\\f' + 999 )", -999, -( '\f' +999) ); + +new TestCase( SECTION, "-( 999 + ' ' )", -999, -( 999+' ') ); +new TestCase( SECTION, "-( 999 + '\\n' )", -999, -( 999+'\n' ) ); +new TestCase( SECTION, "-( 999 + '\\r' )", -999, -( 999+'\r' ) ); +new TestCase( SECTION, "-( 999 + '\\t' )", -999, -( 999+'\t' ) ); +new TestCase( SECTION, "-( 999 + '\\f' )", -999, -( 999+'\f' ) ); + +new TestCase( SECTION, "-( '\\n' + 999 + '\\n' )", -999, -( '\n' +999+'\n' ) ); +new TestCase( SECTION, "-( '\\r' + 999 + '\\r' )", -999, -( '\r' +999+'\r' ) ); +new TestCase( SECTION, "-( '\\t' + 999 + '\\t' )", -999, -( '\t' +999+'\t' ) ); +new TestCase( SECTION, "-( '\\f' + 999 + '\\f' )", -999, -( '\f' +999+'\f' ) ); + +new TestCase( SECTION, "-( ' ' + '999' )", -999, -( ' '+'999') ); +new TestCase( SECTION, "-( '\\n' + '999' )", -999, -( '\n' +'999') ); +new TestCase( SECTION, "-( '\\r' + '999' )", -999, -( '\r' +'999') ); +new TestCase( SECTION, "-( '\\t' + '999' )", -999, -( '\t' +'999') ); +new TestCase( SECTION, "-( '\\f' + '999' )", -999, -( '\f' +'999') ); + +new TestCase( SECTION, "-( '999' + ' ' )", -999, -( '999'+' ') ); +new TestCase( SECTION, "-( '999' + '\\n' )", -999, -( '999'+'\n' ) ); +new TestCase( SECTION, "-( '999' + '\\r' )", -999, -( '999'+'\r' ) ); +new TestCase( SECTION, "-( '999' + '\\t' )", -999, -( '999'+'\t' ) ); +new TestCase( SECTION, "-( '999' + '\\f' )", -999, -( '999'+'\f' ) ); + +new TestCase( SECTION, "-( '\\n' + '999' + '\\n' )", -999, -( '\n' +'999'+'\n' ) ); +new TestCase( SECTION, "-( '\\r' + '999' + '\\r' )", -999, -( '\r' +'999'+'\r' ) ); +new TestCase( SECTION, "-( '\\t' + '999' + '\\t' )", -999, -( '\t' +'999'+'\t' ) ); +new TestCase( SECTION, "-( '\\f' + '999' + '\\f' )", -999, -( '\f' +'999'+'\f' ) ); + +new TestCase( SECTION, "-( String.fromCharCode(0x0009) + '99' )", -99, -( String.fromCharCode(0x0009) + '99' ) ); +new TestCase( SECTION, "-( String.fromCharCode(0x0020) + '99' )", -99, -( String.fromCharCode(0x0020) + '99' ) ); +new TestCase( SECTION, "-( String.fromCharCode(0x000C) + '99' )", -99, -( String.fromCharCode(0x000C) + '99' ) ); +new TestCase( SECTION, "-( String.fromCharCode(0x000B) + '99' )", -99, -( String.fromCharCode(0x000B) + '99' ) ); +new TestCase( SECTION, "-( String.fromCharCode(0x000D) + '99' )", -99, -( String.fromCharCode(0x000D) + '99' ) ); +new TestCase( SECTION, "-( String.fromCharCode(0x000A) + '99' )", -99, -( String.fromCharCode(0x000A) + '99' ) ); + +new TestCase( SECTION, "-( String.fromCharCode(0x0009) + '99' + String.fromCharCode(0x0009)", -99, -( String.fromCharCode(0x0009) + '99' + String.fromCharCode(0x0009)) ); +new TestCase( SECTION, "-( String.fromCharCode(0x0020) + '99' + String.fromCharCode(0x0020)", -99, -( String.fromCharCode(0x0009) + '99' + String.fromCharCode(0x0020)) ); +new TestCase( SECTION, "-( String.fromCharCode(0x000C) + '99' + String.fromCharCode(0x000C)", -99, -( String.fromCharCode(0x0009) + '99' + String.fromCharCode(0x000C)) ); +new TestCase( SECTION, "-( String.fromCharCode(0x000D) + '99' + String.fromCharCode(0x000D)", -99, -( String.fromCharCode(0x0009) + '99' + String.fromCharCode(0x000D)) ); +new TestCase( SECTION, "-( String.fromCharCode(0x000B) + '99' + String.fromCharCode(0x000B)", -99, -( String.fromCharCode(0x0009) + '99' + String.fromCharCode(0x000B)) ); +new TestCase( SECTION, "-( String.fromCharCode(0x000A) + '99' + String.fromCharCode(0x000A)", -99, -( String.fromCharCode(0x0009) + '99' + String.fromCharCode(0x000A)) ); + +new TestCase( SECTION, "-( '99' + String.fromCharCode(0x0009)", -99, -( '99' + String.fromCharCode(0x0009)) ); +new TestCase( SECTION, "-( '99' + String.fromCharCode(0x0020)", -99, -( '99' + String.fromCharCode(0x0020)) ); +new TestCase( SECTION, "-( '99' + String.fromCharCode(0x000C)", -99, -( '99' + String.fromCharCode(0x000C)) ); +new TestCase( SECTION, "-( '99' + String.fromCharCode(0x000D)", -99, -( '99' + String.fromCharCode(0x000D)) ); +new TestCase( SECTION, "-( '99' + String.fromCharCode(0x000B)", -99, -( '99' + String.fromCharCode(0x000B)) ); +new TestCase( SECTION, "-( '99' + String.fromCharCode(0x000A)", -99, -( '99' + String.fromCharCode(0x000A)) ); + +new TestCase( SECTION, "-( String.fromCharCode(0x0009) + 99 )", -99, -( String.fromCharCode(0x0009) + 99 ) ); +new TestCase( SECTION, "-( String.fromCharCode(0x0020) + 99 )", -99, -( String.fromCharCode(0x0020) + 99 ) ); +new TestCase( SECTION, "-( String.fromCharCode(0x000C) + 99 )", -99, -( String.fromCharCode(0x000C) + 99 ) ); +new TestCase( SECTION, "-( String.fromCharCode(0x000B) + 99 )", -99, -( String.fromCharCode(0x000B) + 99 ) ); +new TestCase( SECTION, "-( String.fromCharCode(0x000D) + 99 )", -99, -( String.fromCharCode(0x000D) + 99 ) ); +new TestCase( SECTION, "-( String.fromCharCode(0x000A) + 99 )", -99, -( String.fromCharCode(0x000A) + 99 ) ); + +new TestCase( SECTION, "-( String.fromCharCode(0x0009) + 99 + String.fromCharCode(0x0009)", -99, -( String.fromCharCode(0x0009) + 99 + String.fromCharCode(0x0009)) ); +new TestCase( SECTION, "-( String.fromCharCode(0x0020) + 99 + String.fromCharCode(0x0020)", -99, -( String.fromCharCode(0x0009) + 99 + String.fromCharCode(0x0020)) ); +new TestCase( SECTION, "-( String.fromCharCode(0x000C) + 99 + String.fromCharCode(0x000C)", -99, -( String.fromCharCode(0x0009) + 99 + String.fromCharCode(0x000C)) ); +new TestCase( SECTION, "-( String.fromCharCode(0x000D) + 99 + String.fromCharCode(0x000D)", -99, -( String.fromCharCode(0x0009) + 99 + String.fromCharCode(0x000D)) ); +new TestCase( SECTION, "-( String.fromCharCode(0x000B) + 99 + String.fromCharCode(0x000B)", -99, -( String.fromCharCode(0x0009) + 99 + String.fromCharCode(0x000B)) ); +new TestCase( SECTION, "-( String.fromCharCode(0x000A) + 99 + String.fromCharCode(0x000A)", -99, -( String.fromCharCode(0x0009) + 99 + String.fromCharCode(0x000A)) ); + +new TestCase( SECTION, "-( 99 + String.fromCharCode(0x0009)", -99, -( 99 + String.fromCharCode(0x0009)) ); +new TestCase( SECTION, "-( 99 + String.fromCharCode(0x0020)", -99, -( 99 + String.fromCharCode(0x0020)) ); +new TestCase( SECTION, "-( 99 + String.fromCharCode(0x000C)", -99, -( 99 + String.fromCharCode(0x000C)) ); +new TestCase( SECTION, "-( 99 + String.fromCharCode(0x000D)", -99, -( 99 + String.fromCharCode(0x000D)) ); +new TestCase( SECTION, "-( 99 + String.fromCharCode(0x000B)", -99, -( 99 + String.fromCharCode(0x000B)) ); +new TestCase( SECTION, "-( 99 + String.fromCharCode(0x000A)", -99, -( 99 + String.fromCharCode(0x000A)) ); + + +// StrNumericLiteral:::StrDecimalLiteral:::Infinity + +new TestCase( SECTION, "-('Infinity')", -Math.pow(10,10000), -("Infinity") ); +new TestCase( SECTION, "-('-Infinity')", +Math.pow(10,10000), -("-Infinity") ); +new TestCase( SECTION, "-('+Infinity')", -Math.pow(10,10000), -("+Infinity") ); + +// StrNumericLiteral::: StrDecimalLiteral ::: DecimalDigits . DecimalDigits opt ExponentPart opt + +new TestCase( SECTION, "-('0')", -0, -("0") ); +new TestCase( SECTION, "-('-0')", +0, -("-0") ); +new TestCase( SECTION, "-('+0')", -0, -("+0") ); + +new TestCase( SECTION, "-('1')", -1, -("1") ); +new TestCase( SECTION, "-('-1')", +1, -("-1") ); +new TestCase( SECTION, "-('+1')", -1, -("+1") ); + +new TestCase( SECTION, "-('2')", -2, -("2") ); +new TestCase( SECTION, "-('-2')", +2, -("-2") ); +new TestCase( SECTION, "-('+2')", -2, -("+2") ); + +new TestCase( SECTION, "-('3')", -3, -("3") ); +new TestCase( SECTION, "-('-3')", +3, -("-3") ); +new TestCase( SECTION, "-('+3')", -3, -("+3") ); + +new TestCase( SECTION, "-('4')", -4, -("4") ); +new TestCase( SECTION, "-('-4')", +4, -("-4") ); +new TestCase( SECTION, "-('+4')", -4, -("+4") ); + +new TestCase( SECTION, "-('5')", -5, -("5") ); +new TestCase( SECTION, "-('-5')", +5, -("-5") ); +new TestCase( SECTION, "-('+5')", -5, -("+5") ); + +new TestCase( SECTION, "-('6')", -6, -("6") ); +new TestCase( SECTION, "-('-6')", +6, -("-6") ); +new TestCase( SECTION, "-('+6')", -6, -("+6") ); + +new TestCase( SECTION, "-('7')", -7, -("7") ); +new TestCase( SECTION, "-('-7')", +7, -("-7") ); +new TestCase( SECTION, "-('+7')", -7, -("+7") ); + +new TestCase( SECTION, "-('8')", -8, -("8") ); +new TestCase( SECTION, "-('-8')", +8, -("-8") ); +new TestCase( SECTION, "-('+8')", -8, -("+8") ); + +new TestCase( SECTION, "-('9')", -9, -("9") ); +new TestCase( SECTION, "-('-9')", +9, -("-9") ); +new TestCase( SECTION, "-('+9')", -9, -("+9") ); + +new TestCase( SECTION, "-('3.14159')", -3.14159, -("3.14159") ); +new TestCase( SECTION, "-('-3.14159')", +3.14159, -("-3.14159") ); +new TestCase( SECTION, "-('+3.14159')", -3.14159, -("+3.14159") ); + +new TestCase( SECTION, "-('3.')", -3, -("3.") ); +new TestCase( SECTION, "-('-3.')", +3, -("-3.") ); +new TestCase( SECTION, "-('+3.')", -3, -("+3.") ); + +new TestCase( SECTION, "-('3.e1')", -30, -("3.e1") ); +new TestCase( SECTION, "-('-3.e1')", +30, -("-3.e1") ); +new TestCase( SECTION, "-('+3.e1')", -30, -("+3.e1") ); + +new TestCase( SECTION, "-('3.e+1')", -30, -("3.e+1") ); +new TestCase( SECTION, "-('-3.e+1')", +30, -("-3.e+1") ); +new TestCase( SECTION, "-('+3.e+1')", -30, -("+3.e+1") ); + +new TestCase( SECTION, "-('3.e-1')", -.30, -("3.e-1") ); +new TestCase( SECTION, "-('-3.e-1')", +.30, -("-3.e-1") ); +new TestCase( SECTION, "-('+3.e-1')", -.30, -("+3.e-1") ); + +// StrDecimalLiteral::: .DecimalDigits ExponentPart opt + +new TestCase( SECTION, "-('.00001')", -0.00001, -(".00001") ); +new TestCase( SECTION, "-('+.00001')", -0.00001, -("+.00001") ); +new TestCase( SECTION, "-('-0.0001')", +0.00001, -("-.00001") ); + +new TestCase( SECTION, "-('.01e2')", -1, -(".01e2") ); +new TestCase( SECTION, "-('+.01e2')", -1, -("+.01e2") ); +new TestCase( SECTION, "-('-.01e2')", +1, -("-.01e2") ); + +new TestCase( SECTION, "-('.01e+2')", -1, -(".01e+2") ); +new TestCase( SECTION, "-('+.01e+2')", -1, -("+.01e+2") ); +new TestCase( SECTION, "-('-.01e+2')", +1, -("-.01e+2") ); + +new TestCase( SECTION, "-('.01e-2')", -0.0001, -(".01e-2") ); +new TestCase( SECTION, "-('+.01e-2')", -0.0001, -("+.01e-2") ); +new TestCase( SECTION, "-('-.01e-2')", +0.0001, -("-.01e-2") ); + +// StrDecimalLiteral::: DecimalDigits ExponentPart opt + +new TestCase( SECTION, "-('1234e5')", -123400000, -("1234e5") ); +new TestCase( SECTION, "-('+1234e5')", -123400000, -("+1234e5") ); +new TestCase( SECTION, "-('-1234e5')", +123400000, -("-1234e5") ); + +new TestCase( SECTION, "-('1234e+5')", -123400000, -("1234e+5") ); +new TestCase( SECTION, "-('+1234e+5')", -123400000, -("+1234e+5") ); +new TestCase( SECTION, "-('-1234e+5')", +123400000, -("-1234e+5") ); + +new TestCase( SECTION, "-('1234e-5')", -0.01234, -("1234e-5") ); +new TestCase( SECTION, "-('+1234e-5')", -0.01234, -("+1234e-5") ); +new TestCase( SECTION, "-('-1234e-5')", +0.01234, -("-1234e-5") ); + +// StrNumericLiteral::: HexIntegerLiteral + +new TestCase( SECTION, "-('0x0')", -0, -("0x0")); +new TestCase( SECTION, "-('0x1')", -1, -("0x1")); +new TestCase( SECTION, "-('0x2')", -2, -("0x2")); +new TestCase( SECTION, "-('0x3')", -3, -("0x3")); +new TestCase( SECTION, "-('0x4')", -4, -("0x4")); +new TestCase( SECTION, "-('0x5')", -5, -("0x5")); +new TestCase( SECTION, "-('0x6')", -6, -("0x6")); +new TestCase( SECTION, "-('0x7')", -7, -("0x7")); +new TestCase( SECTION, "-('0x8')", -8, -("0x8")); +new TestCase( SECTION, "-('0x9')", -9, -("0x9")); +new TestCase( SECTION, "-('0xa')", -10, -("0xa")); +new TestCase( SECTION, "-('0xb')", -11, -("0xb")); +new TestCase( SECTION, "-('0xc')", -12, -("0xc")); +new TestCase( SECTION, "-('0xd')", -13, -("0xd")); +new TestCase( SECTION, "-('0xe')", -14, -("0xe")); +new TestCase( SECTION, "-('0xf')", -15, -("0xf")); +new TestCase( SECTION, "-('0xA')", -10, -("0xA")); +new TestCase( SECTION, "-('0xB')", -11, -("0xB")); +new TestCase( SECTION, "-('0xC')", -12, -("0xC")); +new TestCase( SECTION, "-('0xD')", -13, -("0xD")); +new TestCase( SECTION, "-('0xE')", -14, -("0xE")); +new TestCase( SECTION, "-('0xF')", -15, -("0xF")); + +new TestCase( SECTION, "-('0X0')", -0, -("0X0")); +new TestCase( SECTION, "-('0X1')", -1, -("0X1")); +new TestCase( SECTION, "-('0X2')", -2, -("0X2")); +new TestCase( SECTION, "-('0X3')", -3, -("0X3")); +new TestCase( SECTION, "-('0X4')", -4, -("0X4")); +new TestCase( SECTION, "-('0X5')", -5, -("0X5")); +new TestCase( SECTION, "-('0X6')", -6, -("0X6")); +new TestCase( SECTION, "-('0X7')", -7, -("0X7")); +new TestCase( SECTION, "-('0X8')", -8, -("0X8")); +new TestCase( SECTION, "-('0X9')", -9, -("0X9")); +new TestCase( SECTION, "-('0Xa')", -10, -("0Xa")); +new TestCase( SECTION, "-('0Xb')", -11, -("0Xb")); +new TestCase( SECTION, "-('0Xc')", -12, -("0Xc")); +new TestCase( SECTION, "-('0Xd')", -13, -("0Xd")); +new TestCase( SECTION, "-('0Xe')", -14, -("0Xe")); +new TestCase( SECTION, "-('0Xf')", -15, -("0Xf")); +new TestCase( SECTION, "-('0XA')", -10, -("0XA")); +new TestCase( SECTION, "-('0XB')", -11, -("0XB")); +new TestCase( SECTION, "-('0XC')", -12, -("0XC")); +new TestCase( SECTION, "-('0XD')", -13, -("0XD")); +new TestCase( SECTION, "-('0XE')", -14, -("0XE")); +new TestCase( SECTION, "-('0XF')", -15, -("0XF")); + +test(); diff --git a/tests/auto/qml/parserstress/tests/ecma/Expressions/11.4.7-02.js b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.4.7-02.js new file mode 100644 index 0000000000..43bd923e23 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.4.7-02.js @@ -0,0 +1,87 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is JavaScript Engine testing utilities. + * + * The Initial Developer of the Original Code is + * Mozilla Foundation. + * Portions created by the Initial Developer are Copyright (C) 2007 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '11.4.7-02.js'; + +/** + * File Name: 11.4.7-02.js + * Reference: https://bugzilla.mozilla.org/show_bug.cgi?id=432881 + * Description: ecma 11.4.7 + */ + +var SECTION = "11.4.7"; +var VERSION = "ECMA"; +var TITLE = "Unary - Operator"; +var BUGNUMBER = "432881"; + +startTest(); + +test_negation(0, -0.0); +test_negation(-0.0, 0); +test_negation(1, -1); +test_negation(1.0/0.0, -1.0/0.0); +test_negation(-1.0/0.0, 1.0/0.0); + +//1073741824 == (1 << 30) +test_negation(1073741824, -1073741824); +test_negation(-1073741824, 1073741824); + +//1073741824 == (1 << 30) - 1 +test_negation(1073741823, -1073741823); +test_negation(-1073741823, 1073741823); + +//1073741824 == (1 << 30) +test_negation(1073741824, -1073741824); +test_negation(-1073741824, 1073741824); + +//1073741824 == (1 << 30) - 1 +test_negation(1073741823, -1073741823); +test_negation(-1073741823, 1073741823); + +//2147483648 == (1 << 31) +test_negation(2147483648, -2147483648); +test_negation(-2147483648, 2147483648); + +//2147483648 == (1 << 31) - 1 +test_negation(2147483647, -2147483647); +test_negation(-2147483647, 2147483647); + +function test_negation(value, expected) +{ + var actual = -value; + reportCompare(expected, actual, '-(' + value + ') == ' + expected); +} diff --git a/tests/auto/qml/parserstress/tests/ecma/Expressions/11.4.8.js b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.4.8.js new file mode 100644 index 0000000000..f617e10689 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.4.8.js @@ -0,0 +1,215 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '11.4.8.js'; + +/** + File Name: 11.4.8.js + ECMA Section: 11.4.8 Bitwise NOT Operator + Description: flip bits up to 32 bits + no special cases + Author: christine@netscape.com + Date: 7 july 1997 + + Data File Fields: + VALUE value passed as an argument to the ~ operator + E_RESULT expected return value of ~ VALUE; + + Static variables: + none + +*/ + +var SECTION = "11.4.8"; +var VERSION = "ECMA_1"; +startTest(); + +writeHeaderToLog( SECTION + " Bitwise Not operator"); + +for ( var i = 0; i < 35; i++ ) { + var p = Math.pow(2,i); + + new TestCase( SECTION, "~"+p, Not(p), ~p ); + +} +for ( i = 0; i < 35; i++ ) { + var p = -Math.pow(2,i); + + new TestCase( SECTION, "~"+p, Not(p), ~p ); + +} + +test(); + +function ToInteger( n ) { + n = Number( n ); + var sign = ( n < 0 ) ? -1 : 1; + + if ( n != n ) { + return 0; + } + if ( Math.abs( n ) == 0 || Math.abs( n ) == Number.POSITIVE_INFINITY ) { + return n; + } + return ( sign * Math.floor(Math.abs(n)) ); +} +function ToInt32( n ) { + n = Number( n ); + var sign = ( n < 0 ) ? -1 : 1; + + if ( Math.abs( n ) == 0 || Math.abs( n ) == Number.POSITIVE_INFINITY) { + return 0; + } + + n = (sign * Math.floor( Math.abs(n) )) % Math.pow(2,32); + n = ( n >= Math.pow(2,31) ) ? n - Math.pow(2,32) : n; + + return ( n ); +} +function ToUint32( n ) { + n = Number( n ); + var sign = ( n < 0 ) ? -1 : 1; + + if ( Math.abs( n ) == 0 || Math.abs( n ) == Number.POSITIVE_INFINITY) { + return 0; + } + n = sign * Math.floor( Math.abs(n) ) + + n = n % Math.pow(2,32); + + if ( n < 0 ){ + n += Math.pow(2,32); + } + + return ( n ); +} +function ToUint16( n ) { + var sign = ( n < 0 ) ? -1 : 1; + + if ( Math.abs( n ) == 0 || Math.abs( n ) == Number.POSITIVE_INFINITY) { + return 0; + } + + n = ( sign * Math.floor( Math.abs(n) ) ) % Math.pow(2,16); + + if (n <0) { + n += Math.pow(2,16); + } + + return ( n ); +} +function Mask( b, n ) { + b = ToUint32BitString( b ); + b = b.substring( b.length - n ); + b = ToUint32Decimal( b ); + return ( b ); +} +function ToUint32BitString( n ) { + var b = ""; + for ( var p = 31; p >=0; p-- ) { + if ( n >= Math.pow(2,p) ) { + b += "1"; + n -= Math.pow(2,p); + } else { + b += "0"; + } + } + return b; +} +function ToInt32BitString( n ) { + var b = ""; + var sign = ( n < 0 ) ? -1 : 1; + + b += ( sign == 1 ) ? "0" : "1"; + + for ( var p = 30; p >=0; p-- ) { + if ( (sign == 1 ) ? sign * n >= Math.pow(2,p) : sign * n > Math.pow(2,p) ) { + b += ( sign == 1 ) ? "1" : "0"; + n -= sign * Math.pow( 2, p ); + } else { + b += ( sign == 1 ) ? "0" : "1"; + } + } + + return b; +} +function ToInt32Decimal( bin ) { + var r = 0; + var sign; + + if ( Number(bin.charAt(0)) == 0 ) { + sign = 1; + r = 0; + } else { + sign = -1; + r = -(Math.pow(2,31)); + } + + for ( var j = 0; j < 31; j++ ) { + r += Math.pow( 2, j ) * Number(bin.charAt(31-j)); + } + + return r; +} +function ToUint32Decimal( bin ) { + var r = 0; + + for ( var l = bin.length; l < 32; l++ ) { + bin = "0" + bin; + } + + for ( var j = 0; j < 31; j++ ) { + r += Math.pow( 2, j ) * Number(bin.charAt(31-j)); + } + + return r; +} +function Not( n ) { + n = ToInt32(n); + n = ToInt32BitString(n); + + var r = ""; + + for( var l = 0; l < n.length; l++ ) { + r += ( n.charAt(l) == "0" ) ? "1" : "0"; + } + + n = ToInt32Decimal(r); + + return n; +} diff --git a/tests/auto/qml/parserstress/tests/ecma/Expressions/11.4.9.js b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.4.9.js new file mode 100644 index 0000000000..2c57e88211 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.4.9.js @@ -0,0 +1,94 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '11.4.9.js'; + +/** + File Name: 11.4.9.js + ECMA Section: 11.4.9 Logical NOT Operator (!) + Description: if the ToBoolean( VALUE ) result is true, return + true. else return false. + Author: christine@netscape.com + Date: 7 july 1997 + + Static variables: + none +*/ +var SECTION = "11.4.9"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Logical NOT operator (!)"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +// version("130") + + +new TestCase( SECTION, "!(null)", true, !(null) ); +new TestCase( SECTION, "!(var x)", true, !(eval("var x")) ); +new TestCase( SECTION, "!(void 0)", true, !(void 0) ); + +new TestCase( SECTION, "!(false)", true, !(false) ); +new TestCase( SECTION, "!(true)", false, !(true) ); +new TestCase( SECTION, "!()", true, !(eval()) ); +new TestCase( SECTION, "!(0)", true, !(0) ); +new TestCase( SECTION, "!(-0)", true, !(-0) ); +new TestCase( SECTION, "!(NaN)", true, !(Number.NaN) ); +new TestCase( SECTION, "!(Infinity)", false, !(Number.POSITIVE_INFINITY) ); +new TestCase( SECTION, "!(-Infinity)", false, !(Number.NEGATIVE_INFINITY) ); +new TestCase( SECTION, "!(Math.PI)", false, !(Math.PI) ); +new TestCase( SECTION, "!(1)", false, !(1) ); +new TestCase( SECTION, "!(-1)", false, !(-1) ); +new TestCase( SECTION, "!('')", true, !("") ); +new TestCase( SECTION, "!('\t')", false, !("\t") ); +new TestCase( SECTION, "!('0')", false, !("0") ); +new TestCase( SECTION, "!('string')", false, !("string") ); +new TestCase( SECTION, "!(new String(''))", false, !(new String("")) ); +new TestCase( SECTION, "!(new String('string'))", false, !(new String("string")) ); +new TestCase( SECTION, "!(new String())", false, !(new String()) ); +new TestCase( SECTION, "!(new Boolean(true))", false, !(new Boolean(true)) ); +new TestCase( SECTION, "!(new Boolean(false))", false, !(new Boolean(false)) ); +new TestCase( SECTION, "!(new Array())", false, !(new Array()) ); +new TestCase( SECTION, "!(new Array(1,2,3)", false, !(new Array(1,2,3)) ); +new TestCase( SECTION, "!(new Number())", false, !(new Number()) ); +new TestCase( SECTION, "!(new Number(0))", false, !(new Number(0)) ); +new TestCase( SECTION, "!(new Number(NaN))", false, !(new Number(Number.NaN)) ); +new TestCase( SECTION, "!(new Number(Infinity))", false, !(new Number(Number.POSITIVE_INFINITY)) ); + +test(); + diff --git a/tests/auto/qml/parserstress/tests/ecma/Expressions/11.5.1.js b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.5.1.js new file mode 100644 index 0000000000..94edcefea5 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.5.1.js @@ -0,0 +1,115 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '11.5.1.js'; + +/** + File Name: 11.5.1.js + ECMA Section: 11.5.1 Applying the * operator + Description: + + 11.5.1 Applying the * operator + + The * operator performs multiplication, producing the product of its + operands. Multiplication is commutative. Multiplication is not always + associative in ECMAScript, because of finite precision. + + The result of a floating-point multiplication is governed by the rules + of IEEE 754 double-precision arithmetic: + + If either operand is NaN, the result is NaN. + The sign of the result is positive if both operands have the same sign, + negative if the operands have different signs. + Multiplication of an infinity by a zero results in NaN. + Multiplication of an infinity by an infinity results in an infinity. + The sign is determined by the rule already stated above. + Multiplication of an infinity by a finite non-zero value results in a + signed infinity. The sign is determined by the rule already stated above. + In the remaining cases, where neither an infinity or NaN is involved, the + product is computed and rounded to the nearest representable value using IEEE + 754 round-to-nearest mode. If the magnitude is too large to represent, + the result is then an infinity of appropriate sign. If the magnitude is + oo small to represent, the result is then a zero + of appropriate sign. The ECMAScript language requires support of gradual + underflow as defined by IEEE 754. + + Author: christine@netscape.com + Date: 12 november 1997 +*/ +var SECTION = "11.5.1"; +var VERSION = "ECMA_1"; +startTest(); + +writeHeaderToLog( SECTION + " Applying the * operator"); + +new TestCase( SECTION, "Number.NaN * Number.NaN", Number.NaN, Number.NaN * Number.NaN ); +new TestCase( SECTION, "Number.NaN * 1", Number.NaN, Number.NaN * 1 ); +new TestCase( SECTION, "1 * Number.NaN", Number.NaN, 1 * Number.NaN ); + +new TestCase( SECTION, "Number.POSITIVE_INFINITY * 0", Number.NaN, Number.POSITIVE_INFINITY * 0 ); +new TestCase( SECTION, "Number.NEGATIVE_INFINITY * 0", Number.NaN, Number.NEGATIVE_INFINITY * 0 ); +new TestCase( SECTION, "0 * Number.POSITIVE_INFINITY", Number.NaN, 0 * Number.POSITIVE_INFINITY ); +new TestCase( SECTION, "0 * Number.NEGATIVE_INFINITY", Number.NaN, 0 * Number.NEGATIVE_INFINITY ); + +new TestCase( SECTION, "-0 * Number.POSITIVE_INFINITY", Number.NaN, -0 * Number.POSITIVE_INFINITY ); +new TestCase( SECTION, "-0 * Number.NEGATIVE_INFINITY", Number.NaN, -0 * Number.NEGATIVE_INFINITY ); +new TestCase( SECTION, "Number.POSITIVE_INFINITY * -0", Number.NaN, Number.POSITIVE_INFINITY * -0 ); +new TestCase( SECTION, "Number.NEGATIVE_INFINITY * -0", Number.NaN, Number.NEGATIVE_INFINITY * -0 ); + +new TestCase( SECTION, "0 * -0", -0, 0 * -0 ); +new TestCase( SECTION, "-0 * 0", -0, -0 * 0 ); +new TestCase( SECTION, "-0 * -0", 0, -0 * -0 ); +new TestCase( SECTION, "0 * 0", 0, 0 * 0 ); + +new TestCase( SECTION, "Number.NEGATIVE_INFINITY * Number.NEGATIVE_INFINITY", Number.POSITIVE_INFINITY, Number.NEGATIVE_INFINITY * Number.NEGATIVE_INFINITY ); +new TestCase( SECTION, "Number.POSITIVE_INFINITY * Number.NEGATIVE_INFINITY", Number.NEGATIVE_INFINITY, Number.POSITIVE_INFINITY * Number.NEGATIVE_INFINITY ); +new TestCase( SECTION, "Number.NEGATIVE_INFINITY * Number.POSITIVE_INFINITY", Number.NEGATIVE_INFINITY, Number.NEGATIVE_INFINITY * Number.POSITIVE_INFINITY ); +new TestCase( SECTION, "Number.POSITIVE_INFINITY * Number.POSITIVE_INFINITY", Number.POSITIVE_INFINITY, Number.POSITIVE_INFINITY * Number.POSITIVE_INFINITY ); + +new TestCase( SECTION, "Number.NEGATIVE_INFINITY * 1 ", Number.NEGATIVE_INFINITY, Number.NEGATIVE_INFINITY * 1 ); +new TestCase( SECTION, "Number.NEGATIVE_INFINITY * -1 ", Number.POSITIVE_INFINITY, Number.NEGATIVE_INFINITY * -1 ); +new TestCase( SECTION, "1 * Number.NEGATIVE_INFINITY", Number.NEGATIVE_INFINITY, 1 * Number.NEGATIVE_INFINITY ); +new TestCase( SECTION, "-1 * Number.NEGATIVE_INFINITY", Number.POSITIVE_INFINITY, -1 * Number.NEGATIVE_INFINITY ); + +new TestCase( SECTION, "Number.POSITIVE_INFINITY * 1 ", Number.POSITIVE_INFINITY, Number.POSITIVE_INFINITY * 1 ); +new TestCase( SECTION, "Number.POSITIVE_INFINITY * -1 ", Number.NEGATIVE_INFINITY, Number.POSITIVE_INFINITY * -1 ); +new TestCase( SECTION, "1 * Number.POSITIVE_INFINITY", Number.POSITIVE_INFINITY, 1 * Number.POSITIVE_INFINITY ); +new TestCase( SECTION, "-1 * Number.POSITIVE_INFINITY", Number.NEGATIVE_INFINITY, -1 * Number.POSITIVE_INFINITY ); + +test(); + diff --git a/tests/auto/qml/parserstress/tests/ecma/Expressions/11.5.2.js b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.5.2.js new file mode 100644 index 0000000000..e459e7613f --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.5.2.js @@ -0,0 +1,154 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '11.5.2.js'; + +/** + File Name: 11.5.2.js + ECMA Section: 11.5.2 Applying the / operator + Description: + + The / operator performs division, producing the quotient of its operands. + The left operand is the dividend and the right operand is the divisor. + ECMAScript does not perform integer division. The operands and result of all + division operations are double-precision floating-point numbers. + The result of division is determined by the specification of IEEE 754 arithmetic: + + If either operand is NaN, the result is NaN. + The sign of the result is positive if both operands have the same sign, negative if the operands have different + signs. + Division of an infinity by an infinity results in NaN. + Division of an infinity by a zero results in an infinity. The sign is determined by the rule already stated above. + Division of an infinity by a non-zero finite value results in a signed infinity. The sign is determined by the rule + already stated above. + Division of a finite value by an infinity results in zero. The sign is determined by the rule already stated above. + Division of a zero by a zero results in NaN; division of zero by any other finite value results in zero, with the sign + determined by the rule already stated above. + Division of a non-zero finite value by a zero results in a signed infinity. The sign is determined by the rule + already stated above. + In the remaining cases, where neither an infinity, nor a zero, nor NaN is involved, the quotient is computed and + rounded to the nearest representable value using IEEE 754 round-to-nearest mode. If the magnitude is too + large to represent, we say the operation overflows; the result is then an infinity of appropriate sign. If the + magnitude is too small to represent, we say the operation underflows and the result is a zero of the appropriate + sign. The ECMAScript language requires support of gradual underflow as defined by IEEE 754. + + Author: christine@netscape.com + Date: 12 november 1997 +*/ +var SECTION = "11.5.2"; +var VERSION = "ECMA_1"; +var BUGNUMBER="111202"; +startTest(); + +writeHeaderToLog( SECTION + " Applying the / operator"); + +// if either operand is NaN, the result is NaN. + +new TestCase( SECTION, "Number.NaN / Number.NaN", Number.NaN, Number.NaN / Number.NaN ); +new TestCase( SECTION, "Number.NaN / 1", Number.NaN, Number.NaN / 1 ); +new TestCase( SECTION, "1 / Number.NaN", Number.NaN, 1 / Number.NaN ); + +new TestCase( SECTION, "Number.POSITIVE_INFINITY / Number.NaN", Number.NaN, Number.POSITIVE_INFINITY / Number.NaN ); +new TestCase( SECTION, "Number.NEGATIVE_INFINITY / Number.NaN", Number.NaN, Number.NEGATIVE_INFINITY / Number.NaN ); + +// Division of an infinity by an infinity results in NaN. + +new TestCase( SECTION, "Number.NEGATIVE_INFINITY / Number.NEGATIVE_INFINITY", Number.NaN, Number.NEGATIVE_INFINITY / Number.NEGATIVE_INFINITY ); +new TestCase( SECTION, "Number.POSITIVE_INFINITY / Number.NEGATIVE_INFINITY", Number.NaN, Number.POSITIVE_INFINITY / Number.NEGATIVE_INFINITY ); +new TestCase( SECTION, "Number.NEGATIVE_INFINITY / Number.POSITIVE_INFINITY", Number.NaN, Number.NEGATIVE_INFINITY / Number.POSITIVE_INFINITY ); +new TestCase( SECTION, "Number.POSITIVE_INFINITY / Number.POSITIVE_INFINITY", Number.NaN, Number.POSITIVE_INFINITY / Number.POSITIVE_INFINITY ); + +// Division of an infinity by a zero results in an infinity. + +new TestCase( SECTION, "Number.POSITIVE_INFINITY / 0", Number.POSITIVE_INFINITY, Number.POSITIVE_INFINITY / 0 ); +new TestCase( SECTION, "Number.NEGATIVE_INFINITY / 0", Number.NEGATIVE_INFINITY, Number.NEGATIVE_INFINITY / 0 ); +new TestCase( SECTION, "Number.POSITIVE_INFINITY / -0", Number.NEGATIVE_INFINITY, Number.POSITIVE_INFINITY / -0 ); +new TestCase( SECTION, "Number.NEGATIVE_INFINITY / -0", Number.POSITIVE_INFINITY, Number.NEGATIVE_INFINITY / -0 ); + +// Division of an infinity by a non-zero finite value results in a signed infinity. + +new TestCase( SECTION, "Number.NEGATIVE_INFINITY / 1 ", Number.NEGATIVE_INFINITY, Number.NEGATIVE_INFINITY / 1 ); +new TestCase( SECTION, "Number.NEGATIVE_INFINITY / -1 ", Number.POSITIVE_INFINITY, Number.NEGATIVE_INFINITY / -1 ); +new TestCase( SECTION, "Number.POSITIVE_INFINITY / 1 ", Number.POSITIVE_INFINITY, Number.POSITIVE_INFINITY / 1 ); +new TestCase( SECTION, "Number.POSITIVE_INFINITY / -1 ", Number.NEGATIVE_INFINITY, Number.POSITIVE_INFINITY / -1 ); + +new TestCase( SECTION, "Number.NEGATIVE_INFINITY / Number.MAX_VALUE ", Number.NEGATIVE_INFINITY, Number.NEGATIVE_INFINITY / Number.MAX_VALUE ); +new TestCase( SECTION, "Number.NEGATIVE_INFINITY / -Number.MAX_VALUE ", Number.POSITIVE_INFINITY, Number.NEGATIVE_INFINITY / -Number.MAX_VALUE ); +new TestCase( SECTION, "Number.POSITIVE_INFINITY / Number.MAX_VALUE ", Number.POSITIVE_INFINITY, Number.POSITIVE_INFINITY / Number.MAX_VALUE ); +new TestCase( SECTION, "Number.POSITIVE_INFINITY / -Number.MAX_VALUE ", Number.NEGATIVE_INFINITY, Number.POSITIVE_INFINITY / -Number.MAX_VALUE ); + +// Division of a finite value by an infinity results in zero. + +new TestCase( SECTION, "1 / Number.NEGATIVE_INFINITY", -0, 1 / Number.NEGATIVE_INFINITY ); +new TestCase( SECTION, "1 / Number.POSITIVE_INFINITY", 0, 1 / Number.POSITIVE_INFINITY ); +new TestCase( SECTION, "-1 / Number.POSITIVE_INFINITY", -0, -1 / Number.POSITIVE_INFINITY ); +new TestCase( SECTION, "-1 / Number.NEGATIVE_INFINITY", 0, -1 / Number.NEGATIVE_INFINITY ); + +new TestCase( SECTION, "Number.MAX_VALUE / Number.NEGATIVE_INFINITY", -0, Number.MAX_VALUE / Number.NEGATIVE_INFINITY ); +new TestCase( SECTION, "Number.MAX_VALUE / Number.POSITIVE_INFINITY", 0, Number.MAX_VALUE / Number.POSITIVE_INFINITY ); +new TestCase( SECTION, "-Number.MAX_VALUE / Number.POSITIVE_INFINITY", -0, -Number.MAX_VALUE / Number.POSITIVE_INFINITY ); +new TestCase( SECTION, "-Number.MAX_VALUE / Number.NEGATIVE_INFINITY", 0, -Number.MAX_VALUE / Number.NEGATIVE_INFINITY ); + +// Division of a zero by a zero results in NaN + +new TestCase( SECTION, "0 / -0", Number.NaN, 0 / -0 ); +new TestCase( SECTION, "-0 / 0", Number.NaN, -0 / 0 ); +new TestCase( SECTION, "-0 / -0", Number.NaN, -0 / -0 ); +new TestCase( SECTION, "0 / 0", Number.NaN, 0 / 0 ); + +// division of zero by any other finite value results in zero + +new TestCase( SECTION, "0 / 1", 0, 0 / 1 ); +new TestCase( SECTION, "0 / -1", -0, 0 / -1 ); +new TestCase( SECTION, "-0 / 1", -0, -0 / 1 ); +new TestCase( SECTION, "-0 / -1", 0, -0 / -1 ); + +// Division of a non-zero finite value by a zero results in a signed infinity. + +new TestCase( SECTION, "1 / 0", Number.POSITIVE_INFINITY, 1/0 ); +new TestCase( SECTION, "1 / -0", Number.NEGATIVE_INFINITY, 1/-0 ); +new TestCase( SECTION, "-1 / 0", Number.NEGATIVE_INFINITY, -1/0 ); +new TestCase( SECTION, "-1 / -0", Number.POSITIVE_INFINITY, -1/-0 ); + +new TestCase( SECTION, "0 / Number.POSITIVE_INFINITY", 0, 0 / Number.POSITIVE_INFINITY ); +new TestCase( SECTION, "0 / Number.NEGATIVE_INFINITY", -0, 0 / Number.NEGATIVE_INFINITY ); +new TestCase( SECTION, "-0 / Number.POSITIVE_INFINITY", -0, -0 / Number.POSITIVE_INFINITY ); +new TestCase( SECTION, "-0 / Number.NEGATIVE_INFINITY", 0, -0 / Number.NEGATIVE_INFINITY ); + +test(); + diff --git a/tests/auto/qml/parserstress/tests/ecma/Expressions/11.5.3.js b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.5.3.js new file mode 100644 index 0000000000..9558b63a96 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.5.3.js @@ -0,0 +1,161 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '11.5.3.js'; + +/** + File Name: 11.5.3.js + ECMA Section: 11.5.3 Applying the % operator + Description: + + The binary % operator is said to yield the remainder of its operands from + an implied division; the left operand is the dividend and the right operand + is the divisor. In C and C++, the remainder operator accepts only integral + operands, but in ECMAScript, it also accepts floating-point operands. + + The result of a floating-point remainder operation as computed by the % + operator is not the same as the "remainder" operation defined by IEEE 754. + The IEEE 754 "remainder" operation computes the remainder from a rounding + division, not a truncating division, and so its behavior is not analogous + to that of the usual integer remainder operator. Instead the ECMAScript + language defines % on floating-point operations to behave in a manner + analogous to that of the Java integer remainder operator; this may be + compared with the C library function fmod. + + The result of a ECMAScript floating-point remainder operation is determined by the rules of IEEE arithmetic: + + If either operand is NaN, the result is NaN. + The sign of the result equals the sign of the dividend. + If the dividend is an infinity, or the divisor is a zero, or both, the result is NaN. + If the dividend is finite and the divisor is an infinity, the result equals the dividend. + If the dividend is a zero and the divisor is finite, the result is the same as the dividend. + In the remaining cases, where neither an infinity, nor a zero, nor NaN is involved, the floating-point remainder r + from a dividend n and a divisor d is defined by the mathematical relation r = n (d * q) where q is an integer that + is negative only if n/d is negative and positive only if n/d is positive, and whose magnitude is as large as + possible without exceeding the magnitude of the true mathematical quotient of n and d. + + Author: christine@netscape.com + Date: 12 november 1997 +*/ +var SECTION = "11.5.3"; +var VERSION = "ECMA_1"; +var BUGNUMBER="111202"; +startTest(); + + +writeHeaderToLog( SECTION + " Applying the % operator"); + +// if either operand is NaN, the result is NaN. + +new TestCase( SECTION, "Number.NaN % Number.NaN", Number.NaN, Number.NaN % Number.NaN ); +new TestCase( SECTION, "Number.NaN % 1", Number.NaN, Number.NaN % 1 ); +new TestCase( SECTION, "1 % Number.NaN", Number.NaN, 1 % Number.NaN ); + +new TestCase( SECTION, "Number.POSITIVE_INFINITY % Number.NaN", Number.NaN, Number.POSITIVE_INFINITY % Number.NaN ); +new TestCase( SECTION, "Number.NEGATIVE_INFINITY % Number.NaN", Number.NaN, Number.NEGATIVE_INFINITY % Number.NaN ); + +// If the dividend is an infinity, or the divisor is a zero, or both, the result is NaN. +// dividend is an infinity + +new TestCase( SECTION, "Number.NEGATIVE_INFINITY % Number.NEGATIVE_INFINITY", Number.NaN, Number.NEGATIVE_INFINITY % Number.NEGATIVE_INFINITY ); +new TestCase( SECTION, "Number.POSITIVE_INFINITY % Number.NEGATIVE_INFINITY", Number.NaN, Number.POSITIVE_INFINITY % Number.NEGATIVE_INFINITY ); +new TestCase( SECTION, "Number.NEGATIVE_INFINITY % Number.POSITIVE_INFINITY", Number.NaN, Number.NEGATIVE_INFINITY % Number.POSITIVE_INFINITY ); +new TestCase( SECTION, "Number.POSITIVE_INFINITY % Number.POSITIVE_INFINITY", Number.NaN, Number.POSITIVE_INFINITY % Number.POSITIVE_INFINITY ); + +new TestCase( SECTION, "Number.POSITIVE_INFINITY % 0", Number.NaN, Number.POSITIVE_INFINITY % 0 ); +new TestCase( SECTION, "Number.NEGATIVE_INFINITY % 0", Number.NaN, Number.NEGATIVE_INFINITY % 0 ); +new TestCase( SECTION, "Number.POSITIVE_INFINITY % -0", Number.NaN, Number.POSITIVE_INFINITY % -0 ); +new TestCase( SECTION, "Number.NEGATIVE_INFINITY % -0", Number.NaN, Number.NEGATIVE_INFINITY % -0 ); + +new TestCase( SECTION, "Number.NEGATIVE_INFINITY % 1 ", Number.NaN, Number.NEGATIVE_INFINITY % 1 ); +new TestCase( SECTION, "Number.NEGATIVE_INFINITY % -1 ", Number.NaN, Number.NEGATIVE_INFINITY % -1 ); +new TestCase( SECTION, "Number.POSITIVE_INFINITY % 1 ", Number.NaN, Number.POSITIVE_INFINITY % 1 ); +new TestCase( SECTION, "Number.POSITIVE_INFINITY % -1 ", Number.NaN, Number.POSITIVE_INFINITY % -1 ); + +new TestCase( SECTION, "Number.NEGATIVE_INFINITY % Number.MAX_VALUE ", Number.NaN, Number.NEGATIVE_INFINITY % Number.MAX_VALUE ); +new TestCase( SECTION, "Number.NEGATIVE_INFINITY % -Number.MAX_VALUE ", Number.NaN, Number.NEGATIVE_INFINITY % -Number.MAX_VALUE ); +new TestCase( SECTION, "Number.POSITIVE_INFINITY % Number.MAX_VALUE ", Number.NaN, Number.POSITIVE_INFINITY % Number.MAX_VALUE ); +new TestCase( SECTION, "Number.POSITIVE_INFINITY % -Number.MAX_VALUE ", Number.NaN, Number.POSITIVE_INFINITY % -Number.MAX_VALUE ); + +// divisor is 0 +new TestCase( SECTION, "0 % -0", Number.NaN, 0 % -0 ); +new TestCase( SECTION, "-0 % 0", Number.NaN, -0 % 0 ); +new TestCase( SECTION, "-0 % -0", Number.NaN, -0 % -0 ); +new TestCase( SECTION, "0 % 0", Number.NaN, 0 % 0 ); + +new TestCase( SECTION, "1 % 0", Number.NaN, 1%0 ); +new TestCase( SECTION, "1 % -0", Number.NaN, 1%-0 ); +new TestCase( SECTION, "-1 % 0", Number.NaN, -1%0 ); +new TestCase( SECTION, "-1 % -0", Number.NaN, -1%-0 ); + +new TestCase( SECTION, "Number.MAX_VALUE % 0", Number.NaN, Number.MAX_VALUE%0 ); +new TestCase( SECTION, "Number.MAX_VALUE % -0", Number.NaN, Number.MAX_VALUE%-0 ); +new TestCase( SECTION, "-Number.MAX_VALUE % 0", Number.NaN, -Number.MAX_VALUE%0 ); +new TestCase( SECTION, "-Number.MAX_VALUE % -0", Number.NaN, -Number.MAX_VALUE%-0 ); + +// If the dividend is finite and the divisor is an infinity, the result equals the dividend. + +new TestCase( SECTION, "1 % Number.NEGATIVE_INFINITY", 1, 1 % Number.NEGATIVE_INFINITY ); +new TestCase( SECTION, "1 % Number.POSITIVE_INFINITY", 1, 1 % Number.POSITIVE_INFINITY ); +new TestCase( SECTION, "-1 % Number.POSITIVE_INFINITY", -1, -1 % Number.POSITIVE_INFINITY ); +new TestCase( SECTION, "-1 % Number.NEGATIVE_INFINITY", -1, -1 % Number.NEGATIVE_INFINITY ); + +new TestCase( SECTION, "Number.MAX_VALUE % Number.NEGATIVE_INFINITY", Number.MAX_VALUE, Number.MAX_VALUE % Number.NEGATIVE_INFINITY ); +new TestCase( SECTION, "Number.MAX_VALUE % Number.POSITIVE_INFINITY", Number.MAX_VALUE, Number.MAX_VALUE % Number.POSITIVE_INFINITY ); +new TestCase( SECTION, "-Number.MAX_VALUE % Number.POSITIVE_INFINITY", -Number.MAX_VALUE, -Number.MAX_VALUE % Number.POSITIVE_INFINITY ); +new TestCase( SECTION, "-Number.MAX_VALUE % Number.NEGATIVE_INFINITY", -Number.MAX_VALUE, -Number.MAX_VALUE % Number.NEGATIVE_INFINITY ); + +new TestCase( SECTION, "0 % Number.POSITIVE_INFINITY", 0, 0 % Number.POSITIVE_INFINITY ); +new TestCase( SECTION, "0 % Number.NEGATIVE_INFINITY", 0, 0 % Number.NEGATIVE_INFINITY ); +new TestCase( SECTION, "-0 % Number.POSITIVE_INFINITY", -0, -0 % Number.POSITIVE_INFINITY ); +new TestCase( SECTION, "-0 % Number.NEGATIVE_INFINITY", -0, -0 % Number.NEGATIVE_INFINITY ); + +// If the dividend is a zero and the divisor is finite, the result is the same as the dividend. + +new TestCase( SECTION, "0 % 1", 0, 0 % 1 ); +new TestCase( SECTION, "0 % -1", -0, 0 % -1 ); +new TestCase( SECTION, "-0 % 1", -0, -0 % 1 ); +new TestCase( SECTION, "-0 % -1", 0, -0 % -1 ); + +// In the remaining cases, where neither an infinity, nor a zero, nor NaN is involved, the floating-point remainder r +// from a dividend n and a divisor d is defined by the mathematical relation r = n (d * q) where q is an integer that +// is negative only if n/d is negative and positive only if n/d is positive, and whose magnitude is as large as +// possible without exceeding the magnitude of the true mathematical quotient of n and d. + +test(); + diff --git a/tests/auto/qml/parserstress/tests/ecma/Expressions/11.6.1-1.js b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.6.1-1.js new file mode 100644 index 0000000000..87666161b6 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.6.1-1.js @@ -0,0 +1,160 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '11.6.1-1.js'; + +/** + File Name: 11.6.1-1.js + ECMA Section: 11.6.1 The addition operator ( + ) + Description: + + The addition operator either performs string concatenation or numeric + addition. + + The production AdditiveExpression : AdditiveExpression + MultiplicativeExpression + is evaluated as follows: + + 1. Evaluate AdditiveExpression. + 2. Call GetValue(Result(1)). + 3. Evaluate MultiplicativeExpression. + 4. Call GetValue(Result(3)). + 5. Call ToPrimitive(Result(2)). + 6. Call ToPrimitive(Result(4)). + 7. If Type(Result(5)) is String or Type(Result(6)) is String, go to step 12. + (Note that this step differs from step 3 in the algorithm for comparison + for the relational operators in using or instead of and.) + 8. Call ToNumber(Result(5)). + 9. Call ToNumber(Result(6)). + 10. Apply the addition operation to Result(8) and Result(9). See the discussion below (11.6.3). + 11. Return Result(10). + 12. Call ToString(Result(5)). + 13. Call ToString(Result(6)). + 14. Concatenate Result(12) followed by Result(13). + 15. Return Result(14). + + Note that no hint is provided in the calls to ToPrimitive in steps 5 and 6. + All native ECMAScript objects except Date objects handle the absence of a + hint as if the hint Number were given; Date objects handle the absence of a + hint as if the hint String were given. Host objects may handle the absence + of a hint in some other manner. + + This test does not cover cases where the Additive or Mulplicative expression + ToPrimitive is string. + + Author: christine@netscape.com + Date: 12 november 1997 +*/ +var SECTION = "11.6.1-1"; +var VERSION = "ECMA_1"; +startTest(); + +writeHeaderToLog( SECTION + " The Addition operator ( + )"); + +// tests for boolean primitive, boolean object, Object object, a "MyObject" whose value is +// a boolean primitive and a boolean object. + +new TestCase( SECTION, + "var EXP_1 = true; var EXP_2 = false; EXP_1 + EXP_2", + 1, + eval("var EXP_1 = true; var EXP_2 = false; EXP_1 + EXP_2") ); + +new TestCase( SECTION, + "var EXP_1 = new Boolean(true); var EXP_2 = new Boolean(false); EXP_1 + EXP_2", + 1, + eval("var EXP_1 = new Boolean(true); var EXP_2 = new Boolean(false); EXP_1 + EXP_2") ); + +new TestCase( SECTION, + "var EXP_1 = new Object(true); var EXP_2 = new Object(false); EXP_1 + EXP_2", + 1, + eval("var EXP_1 = new Object(true); var EXP_2 = new Object(false); EXP_1 + EXP_2") ); + +new TestCase( SECTION, + "var EXP_1 = new Object(new Boolean(true)); var EXP_2 = new Object(new Boolean(false)); EXP_1 + EXP_2", + 1, + eval("var EXP_1 = new Object(new Boolean(true)); var EXP_2 = new Object(new Boolean(false)); EXP_1 + EXP_2") ); + +new TestCase( SECTION, + "var EXP_1 = new MyObject(true); var EXP_2 = new MyObject(false); EXP_1 + EXP_2", + 1, + eval("var EXP_1 = new MyObject(true); var EXP_2 = new MyObject(false); EXP_1 + EXP_2") ); + +new TestCase( SECTION, + "var EXP_1 = new MyObject(new Boolean(true)); var EXP_2 = new MyObject(new Boolean(false)); EXP_1 + EXP_2", + "[object Object][object Object]", + eval("var EXP_1 = new MyObject(new Boolean(true)); var EXP_2 = new MyObject(new Boolean(false)); EXP_1 + EXP_2") ); + +// tests for number primitive, number object, Object object, a "MyObject" whose value is +// a number primitive and a number object. + +new TestCase( SECTION, + "var EXP_1 = 100; var EXP_2 = -1; EXP_1 + EXP_2", + 99, + eval("var EXP_1 = 100; var EXP_2 = -1; EXP_1 + EXP_2") ); + +new TestCase( SECTION, + "var EXP_1 = new Number(100); var EXP_2 = new Number(-1); EXP_1 + EXP_2", + 99, + eval("var EXP_1 = new Number(100); var EXP_2 = new Number(-1); EXP_1 + EXP_2") ); + +new TestCase( SECTION, + "var EXP_1 = new Object(100); var EXP_2 = new Object(-1); EXP_1 + EXP_2", + 99, + eval("var EXP_1 = new Object(100); var EXP_2 = new Object(-1); EXP_1 + EXP_2") ); + +new TestCase( SECTION, + "var EXP_1 = new Object(new Number(100)); var EXP_2 = new Object(new Number(-1)); EXP_1 + EXP_2", + 99, + eval("var EXP_1 = new Object(new Number(100)); var EXP_2 = new Object(new Number(-1)); EXP_1 + EXP_2") ); + +new TestCase( SECTION, + "var EXP_1 = new MyObject(100); var EXP_2 = new MyObject(-1); EXP_1 + EXP_2", + 99, + eval("var EXP_1 = new MyObject(100); var EXP_2 = new MyObject(-1); EXP_1 + EXP_2") ); + +new TestCase( SECTION, + "var EXP_1 = new MyObject(new Number(100)); var EXP_2 = new MyObject(new Number(-1)); EXP_1 + EXP_2", + "[object Object][object Object]", + eval("var EXP_1 = new MyObject(new Number(100)); var EXP_2 = new MyObject(new Number(-1)); EXP_1 + EXP_2") ); + + +test(); + +function MyObject( value ) { + this.valueOf = new Function( "return this.value" ); + this.value = value; +} diff --git a/tests/auto/qml/parserstress/tests/ecma/Expressions/11.6.1-2.js b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.6.1-2.js new file mode 100644 index 0000000000..1d96d14e92 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.6.1-2.js @@ -0,0 +1,164 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '11.6.1-2.js'; + +/** + File Name: 11.6.1-2.js + ECMA Section: 11.6.1 The addition operator ( + ) + Description: + + The addition operator either performs string concatenation or numeric + addition. + + The production AdditiveExpression : AdditiveExpression + MultiplicativeExpression + is evaluated as follows: + + 1. Evaluate AdditiveExpression. + 2. Call GetValue(Result(1)). + 3. Evaluate MultiplicativeExpression. + 4. Call GetValue(Result(3)). + 5. Call ToPrimitive(Result(2)). + 6. Call ToPrimitive(Result(4)). + 7. If Type(Result(5)) is String or Type(Result(6)) is String, go to step 12. + (Note that this step differs from step 3 in the algorithm for comparison + for the relational operators in using or instead of and.) + 8. Call ToNumber(Result(5)). + 9. Call ToNumber(Result(6)). + 10. Apply the addition operation to Result(8) and Result(9). See the discussion below (11.6.3). + 11. Return Result(10). + 12. Call ToString(Result(5)). + 13. Call ToString(Result(6)). + 14. Concatenate Result(12) followed by Result(13). + 15. Return Result(14). + + Note that no hint is provided in the calls to ToPrimitive in steps 5 and 6. + All native ECMAScript objects except Date objects handle the absence of a + hint as if the hint Number were given; Date objects handle the absence of a + hint as if the hint String were given. Host objects may handle the absence + of a hint in some other manner. + + This test does only covers cases where the Additive or Mulplicative expression + ToPrimitive is a string. + + Author: christine@netscape.com + Date: 12 november 1997 +*/ +var SECTION = "11.6.1-2"; +var VERSION = "ECMA_1"; +startTest(); + +writeHeaderToLog( SECTION + " The Addition operator ( + )"); + +// tests for boolean primitive, boolean object, Object object, a "MyObject" whose value is +// a boolean primitive and a boolean object. + +new TestCase( SECTION, + "var EXP_1 = 'string'; var EXP_2 = false; EXP_1 + EXP_2", + "stringfalse", + eval("var EXP_1 = 'string'; var EXP_2 = false; EXP_1 + EXP_2") ); + +new TestCase( SECTION, + "var EXP_1 = true; var EXP_2 = 'string'; EXP_1 + EXP_2", + "truestring", + eval("var EXP_1 = true; var EXP_2 = 'string'; EXP_1 + EXP_2") ); + +new TestCase( SECTION, + "var EXP_1 = new Boolean(true); var EXP_2 = new String('string'); EXP_1 + EXP_2", + "truestring", + eval("var EXP_1 = new Boolean(true); var EXP_2 = new String('string'); EXP_1 + EXP_2") ); + +new TestCase( SECTION, + "var EXP_1 = new Object(true); var EXP_2 = new Object('string'); EXP_1 + EXP_2", + "truestring", + eval("var EXP_1 = new Object(true); var EXP_2 = new Object('string'); EXP_1 + EXP_2") ); + +new TestCase( SECTION, + "var EXP_1 = new Object(new String('string')); var EXP_2 = new Object(new Boolean(false)); EXP_1 + EXP_2", + "stringfalse", + eval("var EXP_1 = new Object(new String('string')); var EXP_2 = new Object(new Boolean(false)); EXP_1 + EXP_2") ); + +new TestCase( SECTION, + "var EXP_1 = new MyObject(true); var EXP_2 = new MyObject('string'); EXP_1 + EXP_2", + "truestring", + eval("var EXP_1 = new MyObject(true); var EXP_2 = new MyObject('string'); EXP_1 + EXP_2") ); + +new TestCase( SECTION, + "var EXP_1 = new MyObject(new String('string')); var EXP_2 = new MyObject(new Boolean(false)); EXP_1 + EXP_2", + "[object Object][object Object]", + eval("var EXP_1 = new MyObject(new String('string')); var EXP_2 = new MyObject(new Boolean(false)); EXP_1 + EXP_2") ); + +// tests for number primitive, number object, Object object, a "MyObject" whose value is +// a number primitive and a number object. + +new TestCase( SECTION, + "var EXP_1 = 100; var EXP_2 = 'string'; EXP_1 + EXP_2", + "100string", + eval("var EXP_1 = 100; var EXP_2 = 'string'; EXP_1 + EXP_2") ); + +new TestCase( SECTION, + "var EXP_1 = new String('string'); var EXP_2 = new Number(-1); EXP_1 + EXP_2", + "string-1", + eval("var EXP_1 = new String('string'); var EXP_2 = new Number(-1); EXP_1 + EXP_2") ); + +new TestCase( SECTION, + "var EXP_1 = new Object(100); var EXP_2 = new Object('string'); EXP_1 + EXP_2", + "100string", + eval("var EXP_1 = new Object(100); var EXP_2 = new Object('string'); EXP_1 + EXP_2") ); + +new TestCase( SECTION, + "var EXP_1 = new Object(new String('string')); var EXP_2 = new Object(new Number(-1)); EXP_1 + EXP_2", + "string-1", + eval("var EXP_1 = new Object(new String('string')); var EXP_2 = new Object(new Number(-1)); EXP_1 + EXP_2") ); + +new TestCase( SECTION, + "var EXP_1 = new MyObject(100); var EXP_2 = new MyObject('string'); EXP_1 + EXP_2", + "100string", + eval("var EXP_1 = new MyObject(100); var EXP_2 = new MyObject('string'); EXP_1 + EXP_2") ); + +new TestCase( SECTION, + "var EXP_1 = new MyObject(new String('string')); var EXP_2 = new MyObject(new Number(-1)); EXP_1 + EXP_2", + "[object Object][object Object]", + eval("var EXP_1 = new MyObject(new String('string')); var EXP_2 = new MyObject(new Number(-1)); EXP_1 + EXP_2") ); + +test(); + +function MyObject( value ) { + this.valueOf = new Function( "return this.value" ); + this.value = value; +} diff --git a/tests/auto/qml/parserstress/tests/ecma/Expressions/11.6.1-3.js b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.6.1-3.js new file mode 100644 index 0000000000..9a162787d5 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.6.1-3.js @@ -0,0 +1,150 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '11.6.1-3.js'; + +/** + File Name: 11.6.1-3.js + ECMA Section: 11.6.1 The addition operator ( + ) + Description: + + The addition operator either performs string concatenation or numeric + addition. + + The production AdditiveExpression : AdditiveExpression + MultiplicativeExpression + is evaluated as follows: + + 1. Evaluate AdditiveExpression. + 2. Call GetValue(Result(1)). + 3. Evaluate MultiplicativeExpression. + 4. Call GetValue(Result(3)). + 5. Call ToPrimitive(Result(2)). + 6. Call ToPrimitive(Result(4)). + 7. If Type(Result(5)) is String or Type(Result(6)) is String, go to step 12. + (Note that this step differs from step 3 in the algorithm for comparison + for the relational operators in using or instead of and.) + 8. Call ToNumber(Result(5)). + 9. Call ToNumber(Result(6)). + 10. Apply the addition operation to Result(8) and Result(9). See the discussion below (11.6.3). + 11. Return Result(10). + 12. Call ToString(Result(5)). + 13. Call ToString(Result(6)). + 14. Concatenate Result(12) followed by Result(13). + 15. Return Result(14). + + Note that no hint is provided in the calls to ToPrimitive in steps 5 and 6. + All native ECMAScript objects except Date objects handle the absence of a + hint as if the hint Number were given; Date objects handle the absence of a + hint as if the hint String were given. Host objects may handle the absence + of a hint in some other manner. + + This test does only covers cases where the Additive or Mulplicative expression + is a Date. + + Author: christine@netscape.com + Date: 12 november 1997 +*/ +var SECTION = "11.6.1-3"; +var VERSION = "ECMA_1"; +startTest(); + +writeHeaderToLog( SECTION + " The Addition operator ( + )"); + +// tests for boolean primitive, boolean object, Object object, a "MyObject" whose value is +// a boolean primitive and a boolean object. + +var DATE1 = new Date(); + +new TestCase( SECTION, + "var DATE1 = new Date(); DATE1 + DATE1", + DATE1.toString() + DATE1.toString(), + DATE1 + DATE1 ); + +new TestCase( SECTION, + "var DATE1 = new Date(); DATE1 + 0", + DATE1.toString() + 0, + DATE1 + 0 ); + +new TestCase( SECTION, + "var DATE1 = new Date(); DATE1 + new Number(0)", + DATE1.toString() + 0, + DATE1 + new Number(0) ); + +new TestCase( SECTION, + "var DATE1 = new Date(); DATE1 + true", + DATE1.toString() + "true", + DATE1 + true ); + +new TestCase( SECTION, + "var DATE1 = new Date(); DATE1 + new Boolean(true)", + DATE1.toString() + "true", + DATE1 + new Boolean(true) ); + +new TestCase( SECTION, + "var DATE1 = new Date(); DATE1 + new Boolean(true)", + DATE1.toString() + "true", + DATE1 + new Boolean(true) ); + +var MYOB1 = new MyObject( DATE1 ); + +new TestCase( SECTION, + "MYOB1 = new MyObject(DATE1); MYOB1 + new Number(1)", + "[object Object]1", + MYOB1 + new Number(1) ); + +new TestCase( SECTION, + "MYOB1 = new MyObject(DATE1); MYOB1 + 1", + "[object Object]1", + MYOB1 + 1 ); + +new TestCase( SECTION, + "MYOB1 = new MyObject(DATE1); MYOB1 + true", + "[object Object]true", + MYOB1 + true ); + +test(); + +function MyPrototypeObject(value) { + this.valueOf = new Function( "return this.value;" ); + this.toString = new Function( "return (this.value + '');" ); + this.value = value; +} +function MyObject( value ) { + this.valueOf = new Function( "return this.value" ); + this.value = value; +} diff --git a/tests/auto/qml/parserstress/tests/ecma/Expressions/11.6.2-1.js b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.6.2-1.js new file mode 100644 index 0000000000..b3ab9b17fb --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.6.2-1.js @@ -0,0 +1,165 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '11.6.2-1.js'; + +/** + File Name: 11.6.2-1.js + ECMA Section: 11.6.2 The Subtraction operator ( - ) + Description: + + The production AdditiveExpression : AdditiveExpression - + MultiplicativeExpression is evaluated as follows: + + 1. Evaluate AdditiveExpression. + 2. Call GetValue(Result(1)). + 3. Evaluate MultiplicativeExpression. + 4. Call GetValue(Result(3)). + 5. Call ToNumber(Result(2)). + 6. Call ToNumber(Result(4)). + 7. Apply the subtraction operation to Result(5) and Result(6). See the + discussion below (11.6.3). + 8. Return Result(7). + + Author: christine@netscape.com + Date: 12 november 1997 +*/ +var SECTION = "11.6.2-1"; +var VERSION = "ECMA_1"; +startTest(); + +writeHeaderToLog( SECTION + " The subtraction operator ( - )"); + +// tests for boolean primitive, boolean object, Object object, a "MyObject" whose value is +// a boolean primitive and a boolean object. + +new TestCase( SECTION, + "var EXP_1 = true; var EXP_2 = false; EXP_1 - EXP_2", + 1, + eval("var EXP_1 = true; var EXP_2 = false; EXP_1 - EXP_2") ); + +new TestCase( SECTION, + "var EXP_1 = new Boolean(true); var EXP_2 = new Boolean(false); EXP_1 - EXP_2", + 1, + eval("var EXP_1 = new Boolean(true); var EXP_2 = new Boolean(false); EXP_1 - EXP_2") ); + +new TestCase( SECTION, + "var EXP_1 = new Object(true); var EXP_2 = new Object(false); EXP_1 - EXP_2", + 1, + eval("var EXP_1 = new Object(true); var EXP_2 = new Object(false); EXP_1 - EXP_2") ); + +new TestCase( SECTION, + "var EXP_1 = new Object(new Boolean(true)); var EXP_2 = new Object(new Boolean(false)); EXP_1 - EXP_2", + 1, + eval("var EXP_1 = new Object(new Boolean(true)); var EXP_2 = new Object(new Boolean(false)); EXP_1 - EXP_2") ); + +new TestCase( SECTION, + "var EXP_1 = new MyObject(true); var EXP_2 = new MyObject(false); EXP_1 - EXP_2", + 1, + eval("var EXP_1 = new MyObject(true); var EXP_2 = new MyObject(false); EXP_1 - EXP_2") ); + +new TestCase( SECTION, + "var EXP_1 = new MyObject(new Boolean(true)); var EXP_2 = new MyObject(new Boolean(false)); EXP_1 - EXP_2", + Number.NaN, + eval("var EXP_1 = new MyObject(new Boolean(true)); var EXP_2 = new MyObject(new Boolean(false)); EXP_1 - EXP_2") ); + +new TestCase( SECTION, + "var EXP_1 = new MyOtherObject(new Boolean(true)); var EXP_2 = new MyOtherObject(new Boolean(false)); EXP_1 - EXP_2", + Number.NaN, + eval("var EXP_1 = new MyOtherObject(new Boolean(true)); var EXP_2 = new MyOtherObject(new Boolean(false)); EXP_1 - EXP_2") ); + +// tests for number primitive, number object, Object object, a "MyObject" whose value is +// a number primitive and a number object. + +new TestCase( SECTION, + "var EXP_1 = 100; var EXP_2 = 1; EXP_1 - EXP_2", + 99, + eval("var EXP_1 = 100; var EXP_2 = 1; EXP_1 - EXP_2") ); + +new TestCase( SECTION, + "var EXP_1 = new Number(100); var EXP_2 = new Number(1); EXP_1 - EXP_2", + 99, + eval("var EXP_1 = new Number(100); var EXP_2 = new Number(1); EXP_1 - EXP_2") ); + +new TestCase( SECTION, + "var EXP_1 = new Object(100); var EXP_2 = new Object(1); EXP_1 - EXP_2", + 99, + eval("var EXP_1 = new Object(100); var EXP_2 = new Object(1); EXP_1 - EXP_2") ); + +new TestCase( SECTION, + "var EXP_1 = new Object(new Number(100)); var EXP_2 = new Object(new Number(1)); EXP_1 - EXP_2", + 99, + eval("var EXP_1 = new Object(new Number(100)); var EXP_2 = new Object(new Number(1)); EXP_1 - EXP_2") ); + +new TestCase( SECTION, + "var EXP_1 = new MyObject(100); var EXP_2 = new MyObject(1); EXP_1 - EXP_2", + 99, + eval("var EXP_1 = new MyObject(100); var EXP_2 = new MyObject(1); EXP_1 - EXP_2") ); + +new TestCase( SECTION, + "var EXP_1 = new MyObject(new Number(100)); var EXP_2 = new MyObject(new Number(1)); EXP_1 - EXP_2", + Number.NaN, + eval("var EXP_1 = new MyObject(new Number(100)); var EXP_2 = new MyObject(new Number(1)); EXP_1 - EXP_2") ); + +new TestCase( SECTION, + "var EXP_1 = new MyOtherObject(new Number(100)); var EXP_2 = new MyOtherObject(new Number(1)); EXP_1 - EXP_2", + 99, + eval("var EXP_1 = new MyOtherObject(new Number(100)); var EXP_2 = new MyOtherObject(new Number(1)); EXP_1 - EXP_2") ); + +// same thing with string! +new TestCase( SECTION, + "var EXP_1 = new MyOtherObject(new String('0xff')); var EXP_2 = new MyOtherObject(new String('1'); EXP_1 - EXP_2", + 254, + eval("var EXP_1 = new MyOtherObject(new String('0xff')); var EXP_2 = new MyOtherObject(new String('1')); EXP_1 - EXP_2") ); + +test(); + +function MyPrototypeObject(value) { + this.valueOf = new Function( "return this.value;" ); + this.toString = new Function( "return (this.value + '');" ); + this.value = value; +} +function MyObject( value ) { + this.valueOf = new Function( "return this.value" ); + this.value = value; +} +function MyOtherObject( value ) { + this.valueOf = new Function( "return this.value" ); + this.toString = new Function ( "return this.value + ''" ); + this.value = value; +} diff --git a/tests/auto/qml/parserstress/tests/ecma/Expressions/11.6.3.js b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.6.3.js new file mode 100644 index 0000000000..cf44738528 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.6.3.js @@ -0,0 +1,115 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '11.6.3.js'; + +/** + File Name: 11.6.3.js + ECMA Section: 11.6.3 Applying the additive operators + (+, -) to numbers + Description: + The + operator performs addition when applied to two operands of numeric + type, producing the sum of the operands. The - operator performs + subtraction, producing the difference of two numeric operands. + + Addition is a commutative operation, but not always associative. + + The result of an addition is determined using the rules of IEEE 754 + double-precision arithmetic: + + If either operand is NaN, the result is NaN. + The sum of two infinities of opposite sign is NaN. + The sum of two infinities of the same sign is the infinity of that sign. + The sum of an infinity and a finite value is equal to the infinite operand. + The sum of two negative zeros is 0. The sum of two positive zeros, or of + two zeros of opposite sign, is +0. + The sum of a zero and a nonzero finite value is equal to the nonzero + operand. + The sum of two nonzero finite values of the same magnitude and opposite + sign is +0. + In the remaining cases, where neither an infinity, nor a zero, nor NaN is + involved, and the operands have the same sign or have different + magnitudes, the sum is computed and rounded to the nearest + representable value using IEEE 754 round-to-nearest mode. If the + magnitude is too large to represent, the operation overflows and + the result is then an infinity of appropriate sign. The ECMAScript + language requires support of gradual underflow as defined by IEEE 754. + + Author: christine@netscape.com + Date: 12 november 1997 +*/ +var SECTION = "11.6.3"; +var VERSION = "ECMA_1"; +startTest(); + +writeHeaderToLog( SECTION + " Applying the additive operators (+,-) to numbers"); + +new TestCase( SECTION, "Number.NaN + 1", Number.NaN, Number.NaN + 1 ); +new TestCase( SECTION, "1 + Number.NaN", Number.NaN, 1 + Number.NaN ); + +new TestCase( SECTION, "Number.NaN - 1", Number.NaN, Number.NaN - 1 ); +new TestCase( SECTION, "1 - Number.NaN", Number.NaN, 1 - Number.NaN ); + +new TestCase( SECTION, "Number.POSITIVE_INFINITY + Number.POSITIVE_INFINITY", Number.POSITIVE_INFINITY, Number.POSITIVE_INFINITY + Number.POSITIVE_INFINITY); +new TestCase( SECTION, "Number.NEGATIVE_INFINITY + Number.NEGATIVE_INFINITY", Number.NEGATIVE_INFINITY, Number.NEGATIVE_INFINITY + Number.NEGATIVE_INFINITY); + +new TestCase( SECTION, "Number.POSITIVE_INFINITY + Number.NEGATIVE_INFINITY", Number.NaN, Number.POSITIVE_INFINITY + Number.NEGATIVE_INFINITY); +new TestCase( SECTION, "Number.NEGATIVE_INFINITY + Number.POSITIVE_INFINITY", Number.NaN, Number.NEGATIVE_INFINITY + Number.POSITIVE_INFINITY); + +new TestCase( SECTION, "Number.POSITIVE_INFINITY - Number.POSITIVE_INFINITY", Number.NaN, Number.POSITIVE_INFINITY - Number.POSITIVE_INFINITY); +new TestCase( SECTION, "Number.NEGATIVE_INFINITY - Number.NEGATIVE_INFINITY", Number.NaN, Number.NEGATIVE_INFINITY - Number.NEGATIVE_INFINITY); + +new TestCase( SECTION, "Number.POSITIVE_INFINITY - Number.NEGATIVE_INFINITY", Number.POSITIVE_INFINITY, Number.POSITIVE_INFINITY - Number.NEGATIVE_INFINITY); +new TestCase( SECTION, "Number.NEGATIVE_INFINITY - Number.POSITIVE_INFINITY", Number.NEGATIVE_INFINITY, Number.NEGATIVE_INFINITY - Number.POSITIVE_INFINITY); + +new TestCase( SECTION, "-0 + -0", -0, -0 + -0 ); +new TestCase( SECTION, "-0 - 0", -0, -0 - 0 ); + +new TestCase( SECTION, "0 + 0", 0, 0 + 0 ); +new TestCase( SECTION, "0 + -0", 0, 0 + -0 ); +new TestCase( SECTION, "0 - -0", 0, 0 - -0 ); +new TestCase( SECTION, "0 - 0", 0, 0 - 0 ); +new TestCase( SECTION, "-0 - -0", 0, -0 - -0 ); +new TestCase( SECTION, "-0 + 0", 0, -0 + 0 ); + +new TestCase( SECTION, "Number.MAX_VALUE - Number.MAX_VALUE", 0, Number.MAX_VALUE - Number.MAX_VALUE ); +new TestCase( SECTION, "1/Number.MAX_VALUE - 1/Number.MAX_VALUE", 0, 1/Number.MAX_VALUE - 1/Number.MAX_VALUE ); + +new TestCase( SECTION, "Number.MIN_VALUE - Number.MIN_VALUE", 0, Number.MIN_VALUE - Number.MIN_VALUE ); + +test(); diff --git a/tests/auto/qml/parserstress/tests/ecma/Expressions/11.7.1.js b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.7.1.js new file mode 100644 index 0000000000..44099f6c94 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.7.1.js @@ -0,0 +1,228 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '11.7.1.js'; + +/** + File Name: 11.7.1.js + ECMA Section: 11.7.1 The Left Shift Operator ( << ) + Description: + Performs a bitwise left shift operation on the left argument by the amount + specified by the right argument. + + The production ShiftExpression : ShiftExpression << AdditiveExpression is + evaluated as follows: + + 1. Evaluate ShiftExpression. + 2. Call GetValue(Result(1)). + 3. Evaluate AdditiveExpression. + 4. Call GetValue(Result(3)). + 5. Call ToInt32(Result(2)). + 6. Call ToUint32(Result(4)). + 7. Mask out all but the least significant 5 bits of Result(6), that is, + compute Result(6) & 0x1F. + 8. Left shift Result(5) by Result(7) bits. The result is a signed 32 bit + integer. + 9. Return Result(8). + + Author: christine@netscape.com + Date: 12 november 1997 +*/ +var SECTION = "11.7.1"; +var VERSION = "ECMA_1"; +startTest(); + +writeHeaderToLog( SECTION + " The left shift operator ( << )"); + +for ( power = 0; power < 33; power++ ) { + shiftexp = Math.pow( 2, power ); + + for ( addexp = 0; addexp < 33; addexp++ ) { + new TestCase( SECTION, + shiftexp + " << " + addexp, + LeftShift( shiftexp, addexp ), + shiftexp << addexp ); + } +} + +test(); + +function ToInteger( n ) { + n = Number( n ); + var sign = ( n < 0 ) ? -1 : 1; + + if ( n != n ) { + return 0; + } + if ( Math.abs( n ) == 0 || Math.abs( n ) == Number.POSITIVE_INFINITY ) { + return n; + } + return ( sign * Math.floor(Math.abs(n)) ); +} +function ToInt32( n ) { + n = Number( n ); + var sign = ( n < 0 ) ? -1 : 1; + + if ( Math.abs( n ) == 0 || Math.abs( n ) == Number.POSITIVE_INFINITY) { + return 0; + } + + n = (sign * Math.floor( Math.abs(n) )) % Math.pow(2,32); + n = ( n >= Math.pow(2,31) ) ? n - Math.pow(2,32) : n; + + return ( n ); +} +function ToUint32( n ) { + n = Number( n ); + var sign = ( n < 0 ) ? -1 : 1; + + if ( Math.abs( n ) == 0 || Math.abs( n ) == Number.POSITIVE_INFINITY) { + return 0; + } + n = sign * Math.floor( Math.abs(n) ) + + n = n % Math.pow(2,32); + + if ( n < 0 ){ + n += Math.pow(2,32); + } + + return ( n ); +} +function ToUint16( n ) { + var sign = ( n < 0 ) ? -1 : 1; + + if ( Math.abs( n ) == 0 || Math.abs( n ) == Number.POSITIVE_INFINITY) { + return 0; + } + + n = ( sign * Math.floor( Math.abs(n) ) ) % Math.pow(2,16); + + if (n <0) { + n += Math.pow(2,16); + } + + return ( n ); +} +function Mask( b, n ) { + b = ToUint32BitString( b ); + b = b.substring( b.length - n ); + b = ToUint32Decimal( b ); + return ( b ); +} +function ToUint32BitString( n ) { + var b = ""; + for ( p = 31; p >=0; p-- ) { + if ( n >= Math.pow(2,p) ) { + b += "1"; + n -= Math.pow(2,p); + } else { + b += "0"; + } + } + return b; +} +function ToInt32BitString( n ) { + var b = ""; + var sign = ( n < 0 ) ? -1 : 1; + + b += ( sign == 1 ) ? "0" : "1"; + + for ( p = 30; p >=0; p-- ) { + if ( (sign == 1 ) ? sign * n >= Math.pow(2,p) : sign * n > Math.pow(2,p) ) { + b += ( sign == 1 ) ? "1" : "0"; + n -= sign * Math.pow( 2, p ); + } else { + b += ( sign == 1 ) ? "0" : "1"; + } + } + + return b; +} +function ToInt32Decimal( bin ) { + var r = 0; + var sign; + + if ( Number(bin.charAt(0)) == 0 ) { + sign = 1; + r = 0; + } else { + sign = -1; + r = -(Math.pow(2,31)); + } + + for ( var j = 0; j < 31; j++ ) { + r += Math.pow( 2, j ) * Number(bin.charAt(31-j)); + } + + return r; +} +function ToUint32Decimal( bin ) { + var r = 0; + + + for ( l = bin.length; l < 32; l++ ) { + bin = "0" + bin; + } + + for ( j = 0; j < 31; j++ ) { + r += Math.pow( 2, j ) * Number(bin.charAt(31-j)); + + } + + return r; +} +function LeftShift( s, a ) { + var shift = ToInt32( s ); + var add = ToUint32( a ); + add = Mask( add, 5 ); + var exp = LShift( shift, add ); + + return ( exp ); +} +function LShift( s, a ) { + s = ToInt32BitString( s ); + + for ( var z = 0; z < a; z++ ) { + s += "0"; + } + + s = s.substring( a, s.length); + + return ToInt32(ToInt32Decimal(s)); +} diff --git a/tests/auto/qml/parserstress/tests/ecma/Expressions/11.7.2.js b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.7.2.js new file mode 100644 index 0000000000..843388767f --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.7.2.js @@ -0,0 +1,246 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '11.7.2.js'; + +/** + File Name: 11.7.2.js + ECMA Section: 11.7.2 The signed right shift operator ( >> ) + Description: + Performs a sign-filling bitwise right shift operation on the left argument + by the amount specified by the right argument. + + The production ShiftExpression : ShiftExpression >> AdditiveExpression is + evaluated as follows: + + 1. Evaluate ShiftExpression. + 2. Call GetValue(Result(1)). + 3. Evaluate AdditiveExpression. + 4. Call GetValue(Result(3)). + 5. Call ToInt32(Result(2)). + 6. Call ToUint32(Result(4)). + 7. Mask out all but the least significant 5 bits of Result(6), that is, + compute Result(6) & 0x1F. + 8. Perform sign-extending right shift of Result(5) by Result(7) bits. The + most significant bit is propagated. The result is a signed 32 bit + integer. + 9. Return Result(8). + + Author: christine@netscape.com + Date: 12 november 1997 +*/ +var SECTION = "11.7.2"; +var VERSION = "ECMA_1"; +startTest(); + +writeHeaderToLog( SECTION + " The signed right shift operator ( >> )"); + +var power = 0; +var addexp = 0; + +for ( power = 0; power <= 32; power++ ) { + shiftexp = Math.pow( 2, power ); + + for ( addexp = 0; addexp <= 32; addexp++ ) { + new TestCase( SECTION, + shiftexp + " >> " + addexp, + SignedRightShift( shiftexp, addexp ), + shiftexp >> addexp ); + } +} + +for ( power = 0; power <= 32; power++ ) { + shiftexp = -Math.pow( 2, power ); + + for ( addexp = 0; addexp <= 32; addexp++ ) { + new TestCase( SECTION, + shiftexp + " >> " + addexp, + SignedRightShift( shiftexp, addexp ), + shiftexp >> addexp ); + } +} + +test(); + +function ToInteger( n ) { + n = Number( n ); + var sign = ( n < 0 ) ? -1 : 1; + + if ( n != n ) { + return 0; + } + if ( Math.abs( n ) == 0 || Math.abs( n ) == Number.POSITIVE_INFINITY ) { + return n; + } + return ( sign * Math.floor(Math.abs(n)) ); +} +function ToInt32( n ) { + n = Number( n ); + var sign = ( n < 0 ) ? -1 : 1; + + if ( Math.abs( n ) == 0 || Math.abs( n ) == Number.POSITIVE_INFINITY) { + return 0; + } + + n = (sign * Math.floor( Math.abs(n) )) % Math.pow(2,32); + n = ( n >= Math.pow(2,31) ) ? n - Math.pow(2,32) : n; + + return ( n ); +} +function ToUint32( n ) { + n = Number( n ); + var sign = ( n < 0 ) ? -1 : 1; + + if ( Math.abs( n ) == 0 || Math.abs( n ) == Number.POSITIVE_INFINITY) { + return 0; + } + n = sign * Math.floor( Math.abs(n) ) + + n = n % Math.pow(2,32); + + if ( n < 0 ){ + n += Math.pow(2,32); + } + + return ( n ); +} +function ToUint16( n ) { + var sign = ( n < 0 ) ? -1 : 1; + + if ( Math.abs( n ) == 0 || Math.abs( n ) == Number.POSITIVE_INFINITY) { + return 0; + } + + n = ( sign * Math.floor( Math.abs(n) ) ) % Math.pow(2,16); + + if (n <0) { + n += Math.pow(2,16); + } + + return ( n ); +} +function Mask( b, n ) { + b = ToUint32BitString( b ); + b = b.substring( b.length - n ); + b = ToUint32Decimal( b ); + return ( b ); +} +function ToUint32BitString( n ) { + var b = ""; + for ( p = 31; p >=0; p-- ) { + if ( n >= Math.pow(2,p) ) { + b += "1"; + n -= Math.pow(2,p); + } else { + b += "0"; + } + } + return b; +} +function ToInt32BitString( n ) { + var b = ""; + var sign = ( n < 0 ) ? -1 : 1; + + b += ( sign == 1 ) ? "0" : "1"; + + for ( p = 30; p >=0; p-- ) { + if ( (sign == 1 ) ? sign * n >= Math.pow(2,p) : sign * n > Math.pow(2,p) ) { + b += ( sign == 1 ) ? "1" : "0"; + n -= sign * Math.pow( 2, p ); + } else { + b += ( sign == 1 ) ? "0" : "1"; + } + } + + return b; +} +function ToInt32Decimal( bin ) { + var r = 0; + var sign; + + if ( Number(bin.charAt(0)) == 0 ) { + sign = 1; + r = 0; + } else { + sign = -1; + r = -(Math.pow(2,31)); + } + + for ( var j = 0; j < 31; j++ ) { + r += Math.pow( 2, j ) * Number(bin.charAt(31-j)); + } + + return r; +} +function ToUint32Decimal( bin ) { + var r = 0; + + for ( l = bin.length; l < 32; l++ ) { + bin = "0" + bin; + } + + for ( j = 0; j < 31; j++ ) { + r += Math.pow( 2, j ) * Number(bin.charAt(31-j)); + } + + return r; +} +function SignedRightShift( s, a ) { + s = ToInt32( s ); + a = ToUint32( a ); + a = Mask( a, 5 ); + return ( SignedRShift( s, a ) ); +} +function SignedRShift( s, a ) { + s = ToInt32BitString( s ); + + var firstbit = s.substring(0,1); + + s = s.substring( 1, s.length ); + + for ( var z = 0; z < a; z++ ) { + s = firstbit + s; + } + + s = s.substring( 0, s.length - a); + + s = firstbit +s; + + + return ToInt32(ToInt32Decimal(s)); +} diff --git a/tests/auto/qml/parserstress/tests/ecma/Expressions/11.7.3.js b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.7.3.js new file mode 100644 index 0000000000..27d24e121a --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.7.3.js @@ -0,0 +1,230 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '11.7.3.js'; + +/** + File Name: 11.7.3.js + ECMA Section: 11.7.3 The unsigned right shift operator ( >>> ) + Description: + 11.7.3 The unsigned right shift operator ( >>> ) + Performs a zero-filling bitwise right shift operation on the left argument + by the amount specified by the right argument. + + The production ShiftExpression : ShiftExpression >>> AdditiveExpression is + evaluated as follows: + + 1. Evaluate ShiftExpression. + 2. Call GetValue(Result(1)). + 3. Evaluate AdditiveExpression. + 4. Call GetValue(Result(3)). + 5. Call ToUint32(Result(2)). + 6. Call ToUint32(Result(4)). + 7. Mask out all but the least significant 5 bits of Result(6), that is, + compute Result(6) & 0x1F. + 8. Perform zero-filling right shift of Result(5) by Result(7) bits. + Vacated bits are filled with zero. The result is an unsigned 32 bit + integer. + 9. Return Result(8). + + Author: christine@netscape.com + Date: 12 november 1997 +*/ +var SECTION = "11.7.3"; +var VERSION = "ECMA_1"; +startTest(); + +writeHeaderToLog( SECTION + " The unsigned right shift operator ( >>> )"); + +var addexp = 0; +var power = 0; + +for ( power = 0; power <= 32; power++ ) { + shiftexp = Math.pow( 2, power ); + + for ( addexp = 0; addexp <= 32; addexp++ ) { + new TestCase( SECTION, + shiftexp + " >>> " + addexp, + UnsignedRightShift( shiftexp, addexp ), + shiftexp >>> addexp ); + } +} + +test(); + + +function ToInteger( n ) { + n = Number( n ); + var sign = ( n < 0 ) ? -1 : 1; + + if ( n != n ) { + return 0; + } + if ( Math.abs( n ) == 0 || Math.abs( n ) == Number.POSITIVE_INFINITY ) { + return n; + } + return ( sign * Math.floor(Math.abs(n)) ); +} +function ToInt32( n ) { + n = Number( n ); + var sign = ( n < 0 ) ? -1 : 1; + + if ( Math.abs( n ) == 0 || Math.abs( n ) == Number.POSITIVE_INFINITY) { + return 0; + } + + n = (sign * Math.floor( Math.abs(n) )) % Math.pow(2,32); + n = ( n >= Math.pow(2,31) ) ? n - Math.pow(2,32) : n; + + return ( n ); +} +function ToUint32( n ) { + n = Number( n ); + var sign = ( n < 0 ) ? -1 : 1; + + if ( Math.abs( n ) == 0 || Math.abs( n ) == Number.POSITIVE_INFINITY) { + return 0; + } + n = sign * Math.floor( Math.abs(n) ) + + n = n % Math.pow(2,32); + + if ( n < 0 ){ + n += Math.pow(2,32); + } + + return ( n ); +} +function ToUint16( n ) { + var sign = ( n < 0 ) ? -1 : 1; + + if ( Math.abs( n ) == 0 || Math.abs( n ) == Number.POSITIVE_INFINITY) { + return 0; + } + + n = ( sign * Math.floor( Math.abs(n) ) ) % Math.pow(2,16); + + if (n <0) { + n += Math.pow(2,16); + } + + return ( n ); +} +function Mask( b, n ) { + b = ToUint32BitString( b ); + b = b.substring( b.length - n ); + b = ToUint32Decimal( b ); + return ( b ); +} +function ToUint32BitString( n ) { + var b = ""; + for ( p = 31; p >=0; p-- ) { + if ( n >= Math.pow(2,p) ) { + b += "1"; + n -= Math.pow(2,p); + } else { + b += "0"; + } + } + return b; +} +function ToInt32BitString( n ) { + var b = ""; + var sign = ( n < 0 ) ? -1 : 1; + + b += ( sign == 1 ) ? "0" : "1"; + + for ( p = 30; p >=0; p-- ) { + if ( (sign == 1 ) ? sign * n >= Math.pow(2,p) : sign * n > Math.pow(2,p) ) { + b += ( sign == 1 ) ? "1" : "0"; + n -= sign * Math.pow( 2, p ); + } else { + b += ( sign == 1 ) ? "0" : "1"; + } + } + + return b; +} +function ToInt32Decimal( bin ) { + var r = 0; + var sign; + + if ( Number(bin.charAt(0)) == 0 ) { + sign = 1; + r = 0; + } else { + sign = -1; + r = -(Math.pow(2,31)); + } + + for ( var j = 0; j < 31; j++ ) { + r += Math.pow( 2, j ) * Number(bin.charAt(31-j)); + } + + return r; +} +function ToUint32Decimal( bin ) { + var r = 0; + + + for ( l = bin.length; l < 32; l++ ) { + bin = "0" + bin; + } + + for ( j = 0; j < 32; j++ ) { + r += Math.pow( 2, j ) * Number(bin.charAt(31-j)); + + } + + return r; +} +function RShift( s, a ) { + s = ToUint32BitString( s ); + for ( z = 0; z < a; z++ ) { + s = "0" + s; + } + s = s.substring( 0, s.length - a ); + + return ToUint32Decimal(s); +} +function UnsignedRightShift( s, a ) { + s = ToUint32( s ); + a = ToUint32( a ); + a = Mask( a, 5 ); + return ( RShift( s, a ) ); +} diff --git a/tests/auto/qml/parserstress/tests/ecma/Expressions/11.8.1.js b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.8.1.js new file mode 100644 index 0000000000..4b35c11b16 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.8.1.js @@ -0,0 +1,121 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '11.8.1.js'; + +/** + File Name: 11.8.1.js + ECMA Section: 11.8.1 The less-than operator ( < ) + Description: + + + Author: christine@netscape.com + Date: 12 november 1997 +*/ +var SECTION = "11.8.1"; +var VERSION = "ECMA_1"; +startTest(); + +writeHeaderToLog( SECTION + " The less-than operator ( < )"); + +new TestCase( SECTION, "true < false", false, true < false ); +new TestCase( SECTION, "false < true", true, false < true ); +new TestCase( SECTION, "false < false", false, false < false ); +new TestCase( SECTION, "true < true", false, true < true ); + +new TestCase( SECTION, "new Boolean(true) < new Boolean(true)", false, new Boolean(true) < new Boolean(true) ); +new TestCase( SECTION, "new Boolean(true) < new Boolean(false)", false, new Boolean(true) < new Boolean(false) ); +new TestCase( SECTION, "new Boolean(false) < new Boolean(true)", true, new Boolean(false) < new Boolean(true) ); +new TestCase( SECTION, "new Boolean(false) < new Boolean(false)", false, new Boolean(false) < new Boolean(false) ); + +new TestCase( SECTION, "new MyObject(Infinity) < new MyObject(Infinity)", false, new MyObject( Number.POSITIVE_INFINITY ) < new MyObject( Number.POSITIVE_INFINITY) ); +new TestCase( SECTION, "new MyObject(-Infinity) < new MyObject(Infinity)", true, new MyObject( Number.NEGATIVE_INFINITY ) < new MyObject( Number.POSITIVE_INFINITY) ); +new TestCase( SECTION, "new MyObject(-Infinity) < new MyObject(-Infinity)", false, new MyObject( Number.NEGATIVE_INFINITY ) < new MyObject( Number.NEGATIVE_INFINITY) ); + +new TestCase( SECTION, "new MyValueObject(false) < new MyValueObject(true)", true, new MyValueObject(false) < new MyValueObject(true) ); +new TestCase( SECTION, "new MyValueObject(true) < new MyValueObject(true)", false, new MyValueObject(true) < new MyValueObject(true) ); +new TestCase( SECTION, "new MyValueObject(false) < new MyValueObject(false)", false, new MyValueObject(false) < new MyValueObject(false) ); + +new TestCase( SECTION, "new MyStringObject(false) < new MyStringObject(true)", true, new MyStringObject(false) < new MyStringObject(true) ); +new TestCase( SECTION, "new MyStringObject(true) < new MyStringObject(true)", false, new MyStringObject(true) < new MyStringObject(true) ); +new TestCase( SECTION, "new MyStringObject(false) < new MyStringObject(false)", false, new MyStringObject(false) < new MyStringObject(false) ); + +new TestCase( SECTION, "Number.NaN < Number.NaN", false, Number.NaN < Number.NaN ); +new TestCase( SECTION, "0 < Number.NaN", false, 0 < Number.NaN ); +new TestCase( SECTION, "Number.NaN < 0", false, Number.NaN < 0 ); + +new TestCase( SECTION, "0 < -0", false, 0 < -0 ); +new TestCase( SECTION, "-0 < 0", false, -0 < 0 ); + +new TestCase( SECTION, "Infinity < 0", false, Number.POSITIVE_INFINITY < 0 ); +new TestCase( SECTION, "Infinity < Number.MAX_VALUE", false, Number.POSITIVE_INFINITY < Number.MAX_VALUE ); +new TestCase( SECTION, "Infinity < Infinity", false, Number.POSITIVE_INFINITY < Number.POSITIVE_INFINITY ); + +new TestCase( SECTION, "0 < Infinity", true, 0 < Number.POSITIVE_INFINITY ); +new TestCase( SECTION, "Number.MAX_VALUE < Infinity", true, Number.MAX_VALUE < Number.POSITIVE_INFINITY ); + +new TestCase( SECTION, "0 < -Infinity", false, 0 < Number.NEGATIVE_INFINITY ); +new TestCase( SECTION, "Number.MAX_VALUE < -Infinity", false, Number.MAX_VALUE < Number.NEGATIVE_INFINITY ); +new TestCase( SECTION, "-Infinity < -Infinity", false, Number.NEGATIVE_INFINITY < Number.NEGATIVE_INFINITY ); + +new TestCase( SECTION, "-Infinity < 0", true, Number.NEGATIVE_INFINITY < 0 ); +new TestCase( SECTION, "-Infinity < -Number.MAX_VALUE", true, Number.NEGATIVE_INFINITY < -Number.MAX_VALUE ); +new TestCase( SECTION, "-Infinity < Number.MIN_VALUE", true, Number.NEGATIVE_INFINITY < Number.MIN_VALUE ); + +new TestCase( SECTION, "'string' < 'string'", false, 'string' < 'string' ); +new TestCase( SECTION, "'astring' < 'string'", true, 'astring' < 'string' ); +new TestCase( SECTION, "'strings' < 'stringy'", true, 'strings' < 'stringy' ); +new TestCase( SECTION, "'strings' < 'stringier'", false, 'strings' < 'stringier' ); +new TestCase( SECTION, "'string' < 'astring'", false, 'string' < 'astring' ); +new TestCase( SECTION, "'string' < 'strings'", true, 'string' < 'strings' ); + +test(); + +function MyObject(value) { + this.value = value; + this.valueOf = new Function( "return this.value" ); + this.toString = new Function( "return this.value +''" ); +} +function MyValueObject(value) { + this.value = value; + this.valueOf = new Function( "return this.value" ); +} +function MyStringObject(value) { + this.value = value; + this.toString = new Function( "return this.value +''" ); +} diff --git a/tests/auto/qml/parserstress/tests/ecma/Expressions/11.8.2.js b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.8.2.js new file mode 100644 index 0000000000..c4e6f4cfbd --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.8.2.js @@ -0,0 +1,121 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '11.8.2.js'; + +/** + File Name: 11.8.2.js + ECMA Section: 11.8.2 The greater-than operator ( > ) + Description: + + + Author: christine@netscape.com + Date: 12 november 1997 +*/ +var SECTION = "11.8.2"; +var VERSION = "ECMA_1"; +startTest(); + +writeHeaderToLog( SECTION + " The greater-than operator ( > )"); + +new TestCase( SECTION, "true > false", true, true > false ); +new TestCase( SECTION, "false > true", false, false > true ); +new TestCase( SECTION, "false > false", false, false > false ); +new TestCase( SECTION, "true > true", false, true > true ); + +new TestCase( SECTION, "new Boolean(true) > new Boolean(true)", false, new Boolean(true) > new Boolean(true) ); +new TestCase( SECTION, "new Boolean(true) > new Boolean(false)", true, new Boolean(true) > new Boolean(false) ); +new TestCase( SECTION, "new Boolean(false) > new Boolean(true)", false, new Boolean(false) > new Boolean(true) ); +new TestCase( SECTION, "new Boolean(false) > new Boolean(false)", false, new Boolean(false) > new Boolean(false) ); + +new TestCase( SECTION, "new MyObject(Infinity) > new MyObject(Infinity)", false, new MyObject( Number.POSITIVE_INFINITY ) > new MyObject( Number.POSITIVE_INFINITY) ); +new TestCase( SECTION, "new MyObject(-Infinity) > new MyObject(Infinity)", false, new MyObject( Number.NEGATIVE_INFINITY ) > new MyObject( Number.POSITIVE_INFINITY) ); +new TestCase( SECTION, "new MyObject(-Infinity) > new MyObject(-Infinity)", false, new MyObject( Number.NEGATIVE_INFINITY ) > new MyObject( Number.NEGATIVE_INFINITY) ); + +new TestCase( SECTION, "new MyValueObject(false) > new MyValueObject(true)", false, new MyValueObject(false) > new MyValueObject(true) ); +new TestCase( SECTION, "new MyValueObject(true) > new MyValueObject(true)", false, new MyValueObject(true) > new MyValueObject(true) ); +new TestCase( SECTION, "new MyValueObject(false) > new MyValueObject(false)", false, new MyValueObject(false) > new MyValueObject(false) ); + +new TestCase( SECTION, "new MyStringObject(false) > new MyStringObject(true)", false, new MyStringObject(false) > new MyStringObject(true) ); +new TestCase( SECTION, "new MyStringObject(true) > new MyStringObject(true)", false, new MyStringObject(true) > new MyStringObject(true) ); +new TestCase( SECTION, "new MyStringObject(false) > new MyStringObject(false)", false, new MyStringObject(false) > new MyStringObject(false) ); + +new TestCase( SECTION, "Number.NaN > Number.NaN", false, Number.NaN > Number.NaN ); +new TestCase( SECTION, "0 > Number.NaN", false, 0 > Number.NaN ); +new TestCase( SECTION, "Number.NaN > 0", false, Number.NaN > 0 ); + +new TestCase( SECTION, "0 > -0", false, 0 > -0 ); +new TestCase( SECTION, "-0 > 0", false, -0 > 0 ); + +new TestCase( SECTION, "Infinity > 0", true, Number.POSITIVE_INFINITY > 0 ); +new TestCase( SECTION, "Infinity > Number.MAX_VALUE", true, Number.POSITIVE_INFINITY > Number.MAX_VALUE ); +new TestCase( SECTION, "Infinity > Infinity", false, Number.POSITIVE_INFINITY > Number.POSITIVE_INFINITY ); + +new TestCase( SECTION, "0 > Infinity", false, 0 > Number.POSITIVE_INFINITY ); +new TestCase( SECTION, "Number.MAX_VALUE > Infinity", false, Number.MAX_VALUE > Number.POSITIVE_INFINITY ); + +new TestCase( SECTION, "0 > -Infinity", true, 0 > Number.NEGATIVE_INFINITY ); +new TestCase( SECTION, "Number.MAX_VALUE > -Infinity", true, Number.MAX_VALUE > Number.NEGATIVE_INFINITY ); +new TestCase( SECTION, "-Infinity > -Infinity", false, Number.NEGATIVE_INFINITY > Number.NEGATIVE_INFINITY ); + +new TestCase( SECTION, "-Infinity > 0", false, Number.NEGATIVE_INFINITY > 0 ); +new TestCase( SECTION, "-Infinity > -Number.MAX_VALUE", false, Number.NEGATIVE_INFINITY > -Number.MAX_VALUE ); +new TestCase( SECTION, "-Infinity > Number.MIN_VALUE", false, Number.NEGATIVE_INFINITY > Number.MIN_VALUE ); + +new TestCase( SECTION, "'string' > 'string'", false, 'string' > 'string' ); +new TestCase( SECTION, "'astring' > 'string'", false, 'astring' > 'string' ); +new TestCase( SECTION, "'strings' > 'stringy'", false, 'strings' > 'stringy' ); +new TestCase( SECTION, "'strings' > 'stringier'", true, 'strings' > 'stringier' ); +new TestCase( SECTION, "'string' > 'astring'", true, 'string' > 'astring' ); +new TestCase( SECTION, "'string' > 'strings'", false, 'string' > 'strings' ); + +test(); + +function MyObject(value) { + this.value = value; + this.valueOf = new Function( "return this.value" ); + this.toString = new Function( "return this.value +''" ); +} +function MyValueObject(value) { + this.value = value; + this.valueOf = new Function( "return this.value" ); +} +function MyStringObject(value) { + this.value = value; + this.toString = new Function( "return this.value +''" ); +} diff --git a/tests/auto/qml/parserstress/tests/ecma/Expressions/11.8.3.js b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.8.3.js new file mode 100644 index 0000000000..2180fc5655 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.8.3.js @@ -0,0 +1,120 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '11.8.3.js'; + +/** + File Name: 11.8.3.js + ECMA Section: 11.8.3 The less-than-or-equal operator ( <= ) + Description: + + Author: christine@netscape.com + Date: 12 november 1997 +*/ +var SECTION = "11.8.1"; +var VERSION = "ECMA_1"; +startTest(); + +writeHeaderToLog( SECTION + " The less-than-or-equal operator ( <= )"); + +new TestCase( SECTION, "true <= false", false, true <= false ); +new TestCase( SECTION, "false <= true", true, false <= true ); +new TestCase( SECTION, "false <= false", true, false <= false ); +new TestCase( SECTION, "true <= true", true, true <= true ); + +new TestCase( SECTION, "new Boolean(true) <= new Boolean(true)", true, new Boolean(true) <= new Boolean(true) ); +new TestCase( SECTION, "new Boolean(true) <= new Boolean(false)", false, new Boolean(true) <= new Boolean(false) ); +new TestCase( SECTION, "new Boolean(false) <= new Boolean(true)", true, new Boolean(false) <= new Boolean(true) ); +new TestCase( SECTION, "new Boolean(false) <= new Boolean(false)", true, new Boolean(false) <= new Boolean(false) ); + +new TestCase( SECTION, "new MyObject(Infinity) <= new MyObject(Infinity)", true, new MyObject( Number.POSITIVE_INFINITY ) <= new MyObject( Number.POSITIVE_INFINITY) ); +new TestCase( SECTION, "new MyObject(-Infinity) <= new MyObject(Infinity)", true, new MyObject( Number.NEGATIVE_INFINITY ) <= new MyObject( Number.POSITIVE_INFINITY) ); +new TestCase( SECTION, "new MyObject(-Infinity) <= new MyObject(-Infinity)", true, new MyObject( Number.NEGATIVE_INFINITY ) <= new MyObject( Number.NEGATIVE_INFINITY) ); + +new TestCase( SECTION, "new MyValueObject(false) <= new MyValueObject(true)", true, new MyValueObject(false) <= new MyValueObject(true) ); +new TestCase( SECTION, "new MyValueObject(true) <= new MyValueObject(true)", true, new MyValueObject(true) <= new MyValueObject(true) ); +new TestCase( SECTION, "new MyValueObject(false) <= new MyValueObject(false)", true, new MyValueObject(false) <= new MyValueObject(false) ); + +new TestCase( SECTION, "new MyStringObject(false) <= new MyStringObject(true)", true, new MyStringObject(false) <= new MyStringObject(true) ); +new TestCase( SECTION, "new MyStringObject(true) <= new MyStringObject(true)", true, new MyStringObject(true) <= new MyStringObject(true) ); +new TestCase( SECTION, "new MyStringObject(false) <= new MyStringObject(false)", true, new MyStringObject(false) <= new MyStringObject(false) ); + +new TestCase( SECTION, "Number.NaN <= Number.NaN", false, Number.NaN <= Number.NaN ); +new TestCase( SECTION, "0 <= Number.NaN", false, 0 <= Number.NaN ); +new TestCase( SECTION, "Number.NaN <= 0", false, Number.NaN <= 0 ); + +new TestCase( SECTION, "0 <= -0", true, 0 <= -0 ); +new TestCase( SECTION, "-0 <= 0", true, -0 <= 0 ); + +new TestCase( SECTION, "Infinity <= 0", false, Number.POSITIVE_INFINITY <= 0 ); +new TestCase( SECTION, "Infinity <= Number.MAX_VALUE", false, Number.POSITIVE_INFINITY <= Number.MAX_VALUE ); +new TestCase( SECTION, "Infinity <= Infinity", true, Number.POSITIVE_INFINITY <= Number.POSITIVE_INFINITY ); + +new TestCase( SECTION, "0 <= Infinity", true, 0 <= Number.POSITIVE_INFINITY ); +new TestCase( SECTION, "Number.MAX_VALUE <= Infinity", true, Number.MAX_VALUE <= Number.POSITIVE_INFINITY ); + +new TestCase( SECTION, "0 <= -Infinity", false, 0 <= Number.NEGATIVE_INFINITY ); +new TestCase( SECTION, "Number.MAX_VALUE <= -Infinity", false, Number.MAX_VALUE <= Number.NEGATIVE_INFINITY ); +new TestCase( SECTION, "-Infinity <= -Infinity", true, Number.NEGATIVE_INFINITY <= Number.NEGATIVE_INFINITY ); + +new TestCase( SECTION, "-Infinity <= 0", true, Number.NEGATIVE_INFINITY <= 0 ); +new TestCase( SECTION, "-Infinity <= -Number.MAX_VALUE", true, Number.NEGATIVE_INFINITY <= -Number.MAX_VALUE ); +new TestCase( SECTION, "-Infinity <= Number.MIN_VALUE", true, Number.NEGATIVE_INFINITY <= Number.MIN_VALUE ); + +new TestCase( SECTION, "'string' <= 'string'", true, 'string' <= 'string' ); +new TestCase( SECTION, "'astring' <= 'string'", true, 'astring' <= 'string' ); +new TestCase( SECTION, "'strings' <= 'stringy'", true, 'strings' <= 'stringy' ); +new TestCase( SECTION, "'strings' <= 'stringier'", false, 'strings' <= 'stringier' ); +new TestCase( SECTION, "'string' <= 'astring'", false, 'string' <= 'astring' ); +new TestCase( SECTION, "'string' <= 'strings'", true, 'string' <= 'strings' ); + +test(); + +function MyObject(value) { + this.value = value; + this.valueOf = new Function( "return this.value" ); + this.toString = new Function( "return this.value +''" ); +} +function MyValueObject(value) { + this.value = value; + this.valueOf = new Function( "return this.value" ); +} +function MyStringObject(value) { + this.value = value; + this.toString = new Function( "return this.value +''" ); +} diff --git a/tests/auto/qml/parserstress/tests/ecma/Expressions/11.8.4.js b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.8.4.js new file mode 100644 index 0000000000..d43aaa260d --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.8.4.js @@ -0,0 +1,121 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '11.8.4.js'; + +/** + File Name: 11.8.4.js + ECMA Section: 11.8.4 The greater-than-or-equal operator ( >= ) + Description: + + + Author: christine@netscape.com + Date: 12 november 1997 +*/ +var SECTION = "11.8.4"; +var VERSION = "ECMA_1"; +startTest(); + +writeHeaderToLog( SECTION + " The greater-than-or-equal operator ( >= )"); + +new TestCase( SECTION, "true >= false", true, true >= false ); +new TestCase( SECTION, "false >= true", false, false >= true ); +new TestCase( SECTION, "false >= false", true, false >= false ); +new TestCase( SECTION, "true >= true", true, true >= true ); + +new TestCase( SECTION, "new Boolean(true) >= new Boolean(true)", true, new Boolean(true) >= new Boolean(true) ); +new TestCase( SECTION, "new Boolean(true) >= new Boolean(false)", true, new Boolean(true) >= new Boolean(false) ); +new TestCase( SECTION, "new Boolean(false) >= new Boolean(true)", false, new Boolean(false) >= new Boolean(true) ); +new TestCase( SECTION, "new Boolean(false) >= new Boolean(false)", true, new Boolean(false) >= new Boolean(false) ); + +new TestCase( SECTION, "new MyObject(Infinity) >= new MyObject(Infinity)", true, new MyObject( Number.POSITIVE_INFINITY ) >= new MyObject( Number.POSITIVE_INFINITY) ); +new TestCase( SECTION, "new MyObject(-Infinity) >= new MyObject(Infinity)", false, new MyObject( Number.NEGATIVE_INFINITY ) >= new MyObject( Number.POSITIVE_INFINITY) ); +new TestCase( SECTION, "new MyObject(-Infinity) >= new MyObject(-Infinity)", true, new MyObject( Number.NEGATIVE_INFINITY ) >= new MyObject( Number.NEGATIVE_INFINITY) ); + +new TestCase( SECTION, "new MyValueObject(false) >= new MyValueObject(true)", false, new MyValueObject(false) >= new MyValueObject(true) ); +new TestCase( SECTION, "new MyValueObject(true) >= new MyValueObject(true)", true, new MyValueObject(true) >= new MyValueObject(true) ); +new TestCase( SECTION, "new MyValueObject(false) >= new MyValueObject(false)", true, new MyValueObject(false) >= new MyValueObject(false) ); + +new TestCase( SECTION, "new MyStringObject(false) >= new MyStringObject(true)", false, new MyStringObject(false) >= new MyStringObject(true) ); +new TestCase( SECTION, "new MyStringObject(true) >= new MyStringObject(true)", true, new MyStringObject(true) >= new MyStringObject(true) ); +new TestCase( SECTION, "new MyStringObject(false) >= new MyStringObject(false)", true, new MyStringObject(false) >= new MyStringObject(false) ); + +new TestCase( SECTION, "Number.NaN >= Number.NaN", false, Number.NaN >= Number.NaN ); +new TestCase( SECTION, "0 >= Number.NaN", false, 0 >= Number.NaN ); +new TestCase( SECTION, "Number.NaN >= 0", false, Number.NaN >= 0 ); + +new TestCase( SECTION, "0 >= -0", true, 0 >= -0 ); +new TestCase( SECTION, "-0 >= 0", true, -0 >= 0 ); + +new TestCase( SECTION, "Infinity >= 0", true, Number.POSITIVE_INFINITY >= 0 ); +new TestCase( SECTION, "Infinity >= Number.MAX_VALUE", true, Number.POSITIVE_INFINITY >= Number.MAX_VALUE ); +new TestCase( SECTION, "Infinity >= Infinity", true, Number.POSITIVE_INFINITY >= Number.POSITIVE_INFINITY ); + +new TestCase( SECTION, "0 >= Infinity", false, 0 >= Number.POSITIVE_INFINITY ); +new TestCase( SECTION, "Number.MAX_VALUE >= Infinity", false, Number.MAX_VALUE >= Number.POSITIVE_INFINITY ); + +new TestCase( SECTION, "0 >= -Infinity", true, 0 >= Number.NEGATIVE_INFINITY ); +new TestCase( SECTION, "Number.MAX_VALUE >= -Infinity", true, Number.MAX_VALUE >= Number.NEGATIVE_INFINITY ); +new TestCase( SECTION, "-Infinity >= -Infinity", true, Number.NEGATIVE_INFINITY >= Number.NEGATIVE_INFINITY ); + +new TestCase( SECTION, "-Infinity >= 0", false, Number.NEGATIVE_INFINITY >= 0 ); +new TestCase( SECTION, "-Infinity >= -Number.MAX_VALUE", false, Number.NEGATIVE_INFINITY >= -Number.MAX_VALUE ); +new TestCase( SECTION, "-Infinity >= Number.MIN_VALUE", false, Number.NEGATIVE_INFINITY >= Number.MIN_VALUE ); + +new TestCase( SECTION, "'string' > 'string'", false, 'string' > 'string' ); +new TestCase( SECTION, "'astring' > 'string'", false, 'astring' > 'string' ); +new TestCase( SECTION, "'strings' > 'stringy'", false, 'strings' > 'stringy' ); +new TestCase( SECTION, "'strings' > 'stringier'", true, 'strings' > 'stringier' ); +new TestCase( SECTION, "'string' > 'astring'", true, 'string' > 'astring' ); +new TestCase( SECTION, "'string' > 'strings'", false, 'string' > 'strings' ); + +test(); + +function MyObject(value) { + this.value = value; + this.valueOf = new Function( "return this.value" ); + this.toString = new Function( "return this.value +''" ); +} +function MyValueObject(value) { + this.value = value; + this.valueOf = new Function( "return this.value" ); +} +function MyStringObject(value) { + this.value = value; + this.toString = new Function( "return this.value +''" ); +} diff --git a/tests/auto/qml/parserstress/tests/ecma/Expressions/11.9.1.js b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.9.1.js new file mode 100644 index 0000000000..6bf3fc0517 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.9.1.js @@ -0,0 +1,159 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '11.9.1.js'; + +/** + File Name: 11.9.1.js + ECMA Section: 11.9.1 The equals operator ( == ) + Description: + + The production EqualityExpression: + EqualityExpression == RelationalExpression is evaluated as follows: + + 1. Evaluate EqualityExpression. + 2. Call GetValue(Result(1)). + 3. Evaluate RelationalExpression. + 4. Call GetValue(Result(3)). + 5. Perform the comparison Result(4) == Result(2). (See section 11.9.3) + 6. Return Result(5). + Author: christine@netscape.com + Date: 12 november 1997 +*/ +var SECTION = "11.9.1"; +var VERSION = "ECMA_1"; +var BUGNUMBER="77391"; +startTest(); + +writeHeaderToLog( SECTION + " The equals operator ( == )"); + +// type x and type y are the same. if type x is undefined or null, return true + +new TestCase( SECTION, "void 0 = void 0", true, void 0 == void 0 ); +new TestCase( SECTION, "null == null", true, null == null ); + +// if x is NaN, return false. if y is NaN, return false. + +new TestCase( SECTION, "NaN == NaN", false, Number.NaN == Number.NaN ); +new TestCase( SECTION, "NaN == 0", false, Number.NaN == 0 ); +new TestCase( SECTION, "0 == NaN", false, 0 == Number.NaN ); +new TestCase( SECTION, "NaN == Infinity", false, Number.NaN == Number.POSITIVE_INFINITY ); +new TestCase( SECTION, "Infinity == NaN", false, Number.POSITIVE_INFINITY == Number.NaN ); + +// if x is the same number value as y, return true. + +new TestCase( SECTION, "Number.MAX_VALUE == Number.MAX_VALUE", true, Number.MAX_VALUE == Number.MAX_VALUE ); +new TestCase( SECTION, "Number.MIN_VALUE == Number.MIN_VALUE", true, Number.MIN_VALUE == Number.MIN_VALUE ); +new TestCase( SECTION, "Number.POSITIVE_INFINITY == Number.POSITIVE_INFINITY", true, Number.POSITIVE_INFINITY == Number.POSITIVE_INFINITY ); +new TestCase( SECTION, "Number.NEGATIVE_INFINITY == Number.NEGATIVE_INFINITY", true, Number.NEGATIVE_INFINITY == Number.NEGATIVE_INFINITY ); + +// if xis 0 and y is -0, return true. if x is -0 and y is 0, return true. + +new TestCase( SECTION, "0 == 0", true, 0 == 0 ); +new TestCase( SECTION, "0 == -0", true, 0 == -0 ); +new TestCase( SECTION, "-0 == 0", true, -0 == 0 ); +new TestCase( SECTION, "-0 == -0", true, -0 == -0 ); + +// return false. + +new TestCase( SECTION, "0.9 == 1", false, 0.9 == 1 ); +new TestCase( SECTION, "0.999999 == 1", false, 0.999999 == 1 ); +new TestCase( SECTION, "0.9999999999 == 1", false, 0.9999999999 == 1 ); +new TestCase( SECTION, "0.9999999999999 == 1", false, 0.9999999999999 == 1 ); + +// type x and type y are the same type, but not numbers. + + +// x and y are strings. return true if x and y are exactly the same sequence of characters. +// otherwise, return false. + +new TestCase( SECTION, "'hello' == 'hello'", true, "hello" == "hello" ); + +// x and y are booleans. return true if both are true or both are false. + +new TestCase( SECTION, "true == true", true, true == true ); +new TestCase( SECTION, "false == false", true, false == false ); +new TestCase( SECTION, "true == false", false, true == false ); +new TestCase( SECTION, "false == true", false, false == true ); + +// return true if x and y refer to the same object. otherwise return false. + +new TestCase( SECTION, "new MyObject(true) == new MyObject(true)", false, new MyObject(true) == new MyObject(true) ); +new TestCase( SECTION, "new Boolean(true) == new Boolean(true)", false, new Boolean(true) == new Boolean(true) ); +new TestCase( SECTION, "new Boolean(false) == new Boolean(false)", false, new Boolean(false) == new Boolean(false) ); + + +new TestCase( SECTION, "x = new MyObject(true); y = x; z = x; z == y", true, eval("x = new MyObject(true); y = x; z = x; z == y") ); +new TestCase( SECTION, "x = new MyObject(false); y = x; z = x; z == y", true, eval("x = new MyObject(false); y = x; z = x; z == y") ); +new TestCase( SECTION, "x = new Boolean(true); y = x; z = x; z == y", true, eval("x = new Boolean(true); y = x; z = x; z == y") ); +new TestCase( SECTION, "x = new Boolean(false); y = x; z = x; z == y", true, eval("x = new Boolean(false); y = x; z = x; z == y") ); + +new TestCase( SECTION, "new Boolean(true) == new Boolean(true)", false, new Boolean(true) == new Boolean(true) ); +new TestCase( SECTION, "new Boolean(false) == new Boolean(false)", false, new Boolean(false) == new Boolean(false) ); + +// if x is null and y is undefined, return true. if x is undefined and y is null return true. + +new TestCase( SECTION, "null == void 0", true, null == void 0 ); +new TestCase( SECTION, "void 0 == null", true, void 0 == null ); + +// if type(x) is Number and type(y) is string, return the result of the comparison x == ToNumber(y). + +new TestCase( SECTION, "1 == '1'", true, 1 == '1' ); +new TestCase( SECTION, "255 == '0xff'", true, 255 == '0xff' ); +new TestCase( SECTION, "0 == '\r'", true, 0 == "\r" ); +new TestCase( SECTION, "1e19 == '1e19'", true, 1e19 == "1e19" ); + + +new TestCase( SECTION, "new Boolean(true) == true", true, true == new Boolean(true) ); +new TestCase( SECTION, "new MyObject(true) == true", true, true == new MyObject(true) ); + +new TestCase( SECTION, "new Boolean(false) == false", true, new Boolean(false) == false ); +new TestCase( SECTION, "new MyObject(false) == false", true, new MyObject(false) == false ); + +new TestCase( SECTION, "true == new Boolean(true)", true, true == new Boolean(true) ); +new TestCase( SECTION, "true == new MyObject(true)", true, true == new MyObject(true) ); + +new TestCase( SECTION, "false == new Boolean(false)", true, false == new Boolean(false) ); +new TestCase( SECTION, "false == new MyObject(false)", true, false == new MyObject(false) ); + +test(); + +function MyObject( value ) { + this.value = value; + this.valueOf = new Function( "return this.value" ); +} diff --git a/tests/auto/qml/parserstress/tests/ecma/Expressions/11.9.2.js b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.9.2.js new file mode 100644 index 0000000000..b6983e6af1 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.9.2.js @@ -0,0 +1,159 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '11.9.2.js'; + +/** + File Name: 11.9.2.js + ECMA Section: 11.9.2 The equals operator ( == ) + Description: + + The production EqualityExpression: + EqualityExpression == RelationalExpression is evaluated as follows: + + 1. Evaluate EqualityExpression. + 2. Call GetValue(Result(1)). + 3. Evaluate RelationalExpression. + 4. Call GetValue(Result(3)). + 5. Perform the comparison Result(4) == Result(2). (See section 11.9.3) + 6. Return Result(5). + Author: christine@netscape.com + Date: 12 november 1997 +*/ +var SECTION = "11.9.2"; +var VERSION = "ECMA_1"; +var BUGNUMBER="77391"; +startTest(); + +writeHeaderToLog( SECTION + " The equals operator ( == )"); + +// type x and type y are the same. if type x is undefined or null, return true + +new TestCase( SECTION, "void 0 == void 0", false, void 0 != void 0 ); +new TestCase( SECTION, "null == null", false, null != null ); + +// if x is NaN, return false. if y is NaN, return false. + +new TestCase( SECTION, "NaN != NaN", true, Number.NaN != Number.NaN ); +new TestCase( SECTION, "NaN != 0", true, Number.NaN != 0 ); +new TestCase( SECTION, "0 != NaN", true, 0 != Number.NaN ); +new TestCase( SECTION, "NaN != Infinity", true, Number.NaN != Number.POSITIVE_INFINITY ); +new TestCase( SECTION, "Infinity != NaN", true, Number.POSITIVE_INFINITY != Number.NaN ); + +// if x is the same number value as y, return true. + +new TestCase( SECTION, "Number.MAX_VALUE != Number.MAX_VALUE", false, Number.MAX_VALUE != Number.MAX_VALUE ); +new TestCase( SECTION, "Number.MIN_VALUE != Number.MIN_VALUE", false, Number.MIN_VALUE != Number.MIN_VALUE ); +new TestCase( SECTION, "Number.POSITIVE_INFINITY != Number.POSITIVE_INFINITY", false, Number.POSITIVE_INFINITY != Number.POSITIVE_INFINITY ); +new TestCase( SECTION, "Number.NEGATIVE_INFINITY != Number.NEGATIVE_INFINITY", false, Number.NEGATIVE_INFINITY != Number.NEGATIVE_INFINITY ); + +// if xis 0 and y is -0, return true. if x is -0 and y is 0, return true. + +new TestCase( SECTION, "0 != 0", false, 0 != 0 ); +new TestCase( SECTION, "0 != -0", false, 0 != -0 ); +new TestCase( SECTION, "-0 != 0", false, -0 != 0 ); +new TestCase( SECTION, "-0 != -0", false, -0 != -0 ); + +// return false. + +new TestCase( SECTION, "0.9 != 1", true, 0.9 != 1 ); +new TestCase( SECTION, "0.999999 != 1", true, 0.999999 != 1 ); +new TestCase( SECTION, "0.9999999999 != 1", true, 0.9999999999 != 1 ); +new TestCase( SECTION, "0.9999999999999 != 1", true, 0.9999999999999 != 1 ); + +// type x and type y are the same type, but not numbers. + + +// x and y are strings. return true if x and y are exactly the same sequence of characters. +// otherwise, return false. + +new TestCase( SECTION, "'hello' != 'hello'", false, "hello" != "hello" ); + +// x and y are booleans. return true if both are true or both are false. + +new TestCase( SECTION, "true != true", false, true != true ); +new TestCase( SECTION, "false != false", false, false != false ); +new TestCase( SECTION, "true != false", true, true != false ); +new TestCase( SECTION, "false != true", true, false != true ); + +// return true if x and y refer to the same object. otherwise return false. + +new TestCase( SECTION, "new MyObject(true) != new MyObject(true)", true, new MyObject(true) != new MyObject(true) ); +new TestCase( SECTION, "new Boolean(true) != new Boolean(true)", true, new Boolean(true) != new Boolean(true) ); +new TestCase( SECTION, "new Boolean(false) != new Boolean(false)", true, new Boolean(false) != new Boolean(false) ); + + +new TestCase( SECTION, "x = new MyObject(true); y = x; z = x; z != y", false, eval("x = new MyObject(true); y = x; z = x; z != y") ); +new TestCase( SECTION, "x = new MyObject(false); y = x; z = x; z != y", false, eval("x = new MyObject(false); y = x; z = x; z != y") ); +new TestCase( SECTION, "x = new Boolean(true); y = x; z = x; z != y", false, eval("x = new Boolean(true); y = x; z = x; z != y") ); +new TestCase( SECTION, "x = new Boolean(false); y = x; z = x; z != y", false, eval("x = new Boolean(false); y = x; z = x; z != y") ); + +new TestCase( SECTION, "new Boolean(true) != new Boolean(true)", true, new Boolean(true) != new Boolean(true) ); +new TestCase( SECTION, "new Boolean(false) != new Boolean(false)", true, new Boolean(false) != new Boolean(false) ); + +// if x is null and y is undefined, return true. if x is undefined and y is null return true. + +new TestCase( SECTION, "null != void 0", false, null != void 0 ); +new TestCase( SECTION, "void 0 != null", false, void 0 != null ); + +// if type(x) is Number and type(y) is string, return the result of the comparison x != ToNumber(y). + +new TestCase( SECTION, "1 != '1'", false, 1 != '1' ); +new TestCase( SECTION, "255 != '0xff'", false, 255 != '0xff' ); +new TestCase( SECTION, "0 != '\r'", false, 0 != "\r" ); +new TestCase( SECTION, "1e19 != '1e19'", false, 1e19 != "1e19" ); + + +new TestCase( SECTION, "new Boolean(true) != true", false, true != new Boolean(true) ); +new TestCase( SECTION, "new MyObject(true) != true", false, true != new MyObject(true) ); + +new TestCase( SECTION, "new Boolean(false) != false", false, new Boolean(false) != false ); +new TestCase( SECTION, "new MyObject(false) != false", false, new MyObject(false) != false ); + +new TestCase( SECTION, "true != new Boolean(true)", false, true != new Boolean(true) ); +new TestCase( SECTION, "true != new MyObject(true)", false, true != new MyObject(true) ); + +new TestCase( SECTION, "false != new Boolean(false)", false, false != new Boolean(false) ); +new TestCase( SECTION, "false != new MyObject(false)", false, false != new MyObject(false) ); + +test(); + +function MyObject( value ) { + this.value = value; + this.valueOf = new Function( "return this.value" ); +} diff --git a/tests/auto/qml/parserstress/tests/ecma/Expressions/11.9.3.js b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.9.3.js new file mode 100644 index 0000000000..cce1c63c16 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.9.3.js @@ -0,0 +1,159 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '11.9.3.js'; + +/** + File Name: 11.9.3.js + ECMA Section: 11.9.3 The equals operator ( == ) + Description: + + The production EqualityExpression: + EqualityExpression == RelationalExpression is evaluated as follows: + + 1. Evaluate EqualityExpression. + 2. Call GetValue(Result(1)). + 3. Evaluate RelationalExpression. + 4. Call GetValue(Result(3)). + 5. Perform the comparison Result(4) == Result(2). (See section 11.9.3) + 6. Return Result(5). + Author: christine@netscape.com + Date: 12 november 1997 +*/ +var SECTION = "11.9.3"; +var VERSION = "ECMA_1"; +var BUGNUMBER="77391"; +startTest(); + +writeHeaderToLog( SECTION + " The equals operator ( == )"); + +// type x and type y are the same. if type x is undefined or null, return true + +new TestCase( SECTION, "void 0 = void 0", true, void 0 == void 0 ); +new TestCase( SECTION, "null == null", true, null == null ); + +// if x is NaN, return false. if y is NaN, return false. + +new TestCase( SECTION, "NaN == NaN", false, Number.NaN == Number.NaN ); +new TestCase( SECTION, "NaN == 0", false, Number.NaN == 0 ); +new TestCase( SECTION, "0 == NaN", false, 0 == Number.NaN ); +new TestCase( SECTION, "NaN == Infinity", false, Number.NaN == Number.POSITIVE_INFINITY ); +new TestCase( SECTION, "Infinity == NaN", false, Number.POSITIVE_INFINITY == Number.NaN ); + +// if x is the same number value as y, return true. + +new TestCase( SECTION, "Number.MAX_VALUE == Number.MAX_VALUE", true, Number.MAX_VALUE == Number.MAX_VALUE ); +new TestCase( SECTION, "Number.MIN_VALUE == Number.MIN_VALUE", true, Number.MIN_VALUE == Number.MIN_VALUE ); +new TestCase( SECTION, "Number.POSITIVE_INFINITY == Number.POSITIVE_INFINITY", true, Number.POSITIVE_INFINITY == Number.POSITIVE_INFINITY ); +new TestCase( SECTION, "Number.NEGATIVE_INFINITY == Number.NEGATIVE_INFINITY", true, Number.NEGATIVE_INFINITY == Number.NEGATIVE_INFINITY ); + +// if xis 0 and y is -0, return true. if x is -0 and y is 0, return true. + +new TestCase( SECTION, "0 == 0", true, 0 == 0 ); +new TestCase( SECTION, "0 == -0", true, 0 == -0 ); +new TestCase( SECTION, "-0 == 0", true, -0 == 0 ); +new TestCase( SECTION, "-0 == -0", true, -0 == -0 ); + +// return false. + +new TestCase( SECTION, "0.9 == 1", false, 0.9 == 1 ); +new TestCase( SECTION, "0.999999 == 1", false, 0.999999 == 1 ); +new TestCase( SECTION, "0.9999999999 == 1", false, 0.9999999999 == 1 ); +new TestCase( SECTION, "0.9999999999999 == 1", false, 0.9999999999999 == 1 ); + +// type x and type y are the same type, but not numbers. + + +// x and y are strings. return true if x and y are exactly the same sequence of characters. +// otherwise, return false. + +new TestCase( SECTION, "'hello' == 'hello'", true, "hello" == "hello" ); + +// x and y are booleans. return true if both are true or both are false. + +new TestCase( SECTION, "true == true", true, true == true ); +new TestCase( SECTION, "false == false", true, false == false ); +new TestCase( SECTION, "true == false", false, true == false ); +new TestCase( SECTION, "false == true", false, false == true ); + +// return true if x and y refer to the same object. otherwise return false. + +new TestCase( SECTION, "new MyObject(true) == new MyObject(true)", false, new MyObject(true) == new MyObject(true) ); +new TestCase( SECTION, "new Boolean(true) == new Boolean(true)", false, new Boolean(true) == new Boolean(true) ); +new TestCase( SECTION, "new Boolean(false) == new Boolean(false)", false, new Boolean(false) == new Boolean(false) ); + + +new TestCase( SECTION, "x = new MyObject(true); y = x; z = x; z == y", true, eval("x = new MyObject(true); y = x; z = x; z == y") ); +new TestCase( SECTION, "x = new MyObject(false); y = x; z = x; z == y", true, eval("x = new MyObject(false); y = x; z = x; z == y") ); +new TestCase( SECTION, "x = new Boolean(true); y = x; z = x; z == y", true, eval("x = new Boolean(true); y = x; z = x; z == y") ); +new TestCase( SECTION, "x = new Boolean(false); y = x; z = x; z == y", true, eval("x = new Boolean(false); y = x; z = x; z == y") ); + +new TestCase( SECTION, "new Boolean(true) == new Boolean(true)", false, new Boolean(true) == new Boolean(true) ); +new TestCase( SECTION, "new Boolean(false) == new Boolean(false)", false, new Boolean(false) == new Boolean(false) ); + +// if x is null and y is undefined, return true. if x is undefined and y is null return true. + +new TestCase( SECTION, "null == void 0", true, null == void 0 ); +new TestCase( SECTION, "void 0 == null", true, void 0 == null ); + +// if type(x) is Number and type(y) is string, return the result of the comparison x == ToNumber(y). + +new TestCase( SECTION, "1 == '1'", true, 1 == '1' ); +new TestCase( SECTION, "255 == '0xff'", true, 255 == '0xff' ); +new TestCase( SECTION, "0 == '\r'", true, 0 == "\r" ); +new TestCase( SECTION, "1e19 == '1e19'", true, 1e19 == "1e19" ); + + +new TestCase( SECTION, "new Boolean(true) == true", true, true == new Boolean(true) ); +new TestCase( SECTION, "new MyObject(true) == true", true, true == new MyObject(true) ); + +new TestCase( SECTION, "new Boolean(false) == false", true, new Boolean(false) == false ); +new TestCase( SECTION, "new MyObject(false) == false", true, new MyObject(false) == false ); + +new TestCase( SECTION, "true == new Boolean(true)", true, true == new Boolean(true) ); +new TestCase( SECTION, "true == new MyObject(true)", true, true == new MyObject(true) ); + +new TestCase( SECTION, "false == new Boolean(false)", true, false == new Boolean(false) ); +new TestCase( SECTION, "false == new MyObject(false)", true, false == new MyObject(false) ); + +test(); + +function MyObject( value ) { + this.value = value; + this.valueOf = new Function( "return this.value" ); +} diff --git a/tests/auto/qml/parserstress/tests/ecma/Expressions/browser.js b/tests/auto/qml/parserstress/tests/ecma/Expressions/browser.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/auto/qml/parserstress/tests/ecma/Expressions/shell.js b/tests/auto/qml/parserstress/tests/ecma/Expressions/shell.js new file mode 100644 index 0000000000..8f5d1129d5 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Expressions/shell.js @@ -0,0 +1 @@ +gTestsubsuite = 'Expressions'; diff --git a/tests/auto/qml/parserstress/tests/ecma/FunctionObjects/15.3.1.1-1.js b/tests/auto/qml/parserstress/tests/ecma/FunctionObjects/15.3.1.1-1.js new file mode 100644 index 0000000000..90f080acc9 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/FunctionObjects/15.3.1.1-1.js @@ -0,0 +1,136 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.3.1.1-1.js'; + +/** + File Name: 15.3.1.1.js + ECMA Section: 15.3.1.1 The Function Constructor Called as a Function + + Description: + When the Function function is called with some arguments p1, p2, . . . , pn, body + (where n might be 0, that is, there are no "p" arguments, and where body might + also not be provided), the following steps are taken: + + 1. Create and return a new Function object exactly if the function constructor had + been called with the same arguments (15.3.2.1). + + Author: christine@netscape.com + Date: 28 october 1997 + +*/ +var SECTION = "15.3.1.1-1"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "The Function Constructor Called as a Function"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +var MyObject = Function( "value", "this.value = value; this.valueOf = Function( 'return this.value' ); this.toString = Function( 'return String(this.value);' )" ); + + +var myfunc = Function(); +myfunc.toString = Object.prototype.toString; + +// not going to test toString here since it is implementation dependent. +// new TestCase( SECTION, "myfunc.toString()", "function anonymous() { }", myfunc.toString() ); + +myfunc.toString = Object.prototype.toString; +new TestCase( SECTION, + "myfunc = Function(); myfunc.toString = Object.prototype.toString; myfunc.toString()", + "[object Function]", + myfunc.toString() ); + +new TestCase( SECTION, + "myfunc.length", + 0, + myfunc.length ); + +new TestCase( SECTION, + "myfunc.prototype.toString()", + "[object Object]", + myfunc.prototype.toString() ); + +new TestCase( SECTION, + "myfunc.prototype.constructor", + myfunc, + myfunc.prototype.constructor ); + +new TestCase( SECTION, + "myfunc.arguments", + null, + myfunc.arguments ); + +new TestCase( SECTION, + "var OBJ = new MyObject(true); OBJ.valueOf()", + true, + eval("var OBJ = new MyObject(true); OBJ.valueOf()") ); + +new TestCase( SECTION, + "OBJ.toString()", + "true", + OBJ.toString() ); + +new TestCase( SECTION, + "OBJ.toString = Object.prototype.toString; OBJ.toString()", + "[object Object]", + eval("OBJ.toString = Object.prototype.toString; OBJ.toString()") ); + +new TestCase( SECTION, + "MyObject.toString = Object.prototype.toString; MyObject.toString()", + "[object Function]", + eval("MyObject.toString = Object.prototype.toString; MyObject.toString()") ); + +new TestCase( SECTION, + "MyObject.length", + 1, + MyObject.length ); + +new TestCase( SECTION, + "MyObject.prototype.constructor", + MyObject, + MyObject.prototype.constructor ); + +new TestCase( SECTION, + "MyObject.arguments", + null, + MyObject.arguments ); + +test(); + + diff --git a/tests/auto/qml/parserstress/tests/ecma/FunctionObjects/15.3.1.1-2.js b/tests/auto/qml/parserstress/tests/ecma/FunctionObjects/15.3.1.1-2.js new file mode 100644 index 0000000000..57fe78c8f1 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/FunctionObjects/15.3.1.1-2.js @@ -0,0 +1,183 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.3.1.1-2.js'; + +/** + File Name: 15.3.1.1-2.js + ECMA Section: 15.3.1.1 The Function Constructor Called as a Function + Function(p1, p2, ..., pn, body ) + + Description: + When the Function function is called with some arguments p1, p2, . . . , pn, + body (where n might be 0, that is, there are no "p" arguments, and where body + might also not be provided), the following steps are taken: + + 1. Create and return a new Function object exactly if the function constructor + had been called with the same arguments (15.3.2.1). + + Author: christine@netscape.com + Date: 28 october 1997 + +*/ +var SECTION = "15.3.1.1-2"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "The Function Constructor Called as a Function"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +var myfunc1 = Function("a","b","c", "return a+b+c" ); +var myfunc2 = Function("a, b, c", "return a+b+c" ); +var myfunc3 = Function("a,b", "c", "return a+b+c" ); + +myfunc1.toString = Object.prototype.toString; +myfunc2.toString = Object.prototype.toString; +myfunc3.toString = Object.prototype.toString; + +new TestCase( SECTION, + "myfunc1 = Function('a','b','c'); myfunc.toString = Object.prototype.toString; myfunc.toString()", + "[object Function]", + myfunc1.toString() ); + +new TestCase( SECTION, + "myfunc1.length", + 3, + myfunc1.length ); + +new TestCase( SECTION, + "myfunc1.prototype.toString()", + "[object Object]", + myfunc1.prototype.toString() ); + +new TestCase( SECTION, + "myfunc1.prototype.constructor", + myfunc1, + myfunc1.prototype.constructor ); + +new TestCase( SECTION, + "myfunc1.arguments", + null, + myfunc1.arguments ); + +new TestCase( SECTION, + "myfunc1(1,2,3)", + 6, + myfunc1(1,2,3) ); + +new TestCase( SECTION, + "var MYPROPS = ''; for ( var p in myfunc1.prototype ) { MYPROPS += p; }; MYPROPS", + "", + eval("var MYPROPS = ''; for ( var p in myfunc1.prototype ) { MYPROPS += p; }; MYPROPS") ); + +new TestCase( SECTION, + "myfunc2 = Function('a','b','c'); myfunc.toString = Object.prototype.toString; myfunc.toString()", + "[object Function]", + myfunc2.toString() ); + +new TestCase( SECTION, + "myfunc2.length", + 3, + myfunc2.length ); + +new TestCase( SECTION, + "myfunc2.prototype.toString()", + "[object Object]", + myfunc2.prototype.toString() ); + +new TestCase( SECTION, + "myfunc2.prototype.constructor", + myfunc2, + myfunc2.prototype.constructor ); + +new TestCase( SECTION, + "myfunc2.arguments", + null, + myfunc2.arguments ); + +new TestCase( SECTION, + "myfunc2( 1000, 200, 30 )", + 1230, + myfunc2(1000,200,30) ); + +new TestCase( SECTION, + "var MYPROPS = ''; for ( var p in myfunc2.prototype ) { MYPROPS += p; }; MYPROPS", + "", + eval("var MYPROPS = ''; for ( var p in myfunc2.prototype ) { MYPROPS += p; }; MYPROPS") ); + +new TestCase( SECTION, + "myfunc3 = Function('a','b','c'); myfunc.toString = Object.prototype.toString; myfunc.toString()", + "[object Function]", + myfunc3.toString() ); + +new TestCase( SECTION, + "myfunc3.length", + 3, + myfunc3.length ); + +new TestCase( SECTION, + "myfunc3.prototype.toString()", + "[object Object]", + myfunc3.prototype.toString() ); + +new TestCase( SECTION, + "myfunc3.prototype.valueOf() +''", + "[object Object]", + myfunc3.prototype.valueOf() +'' ); + +new TestCase( SECTION, + "myfunc3.prototype.constructor", + myfunc3, + myfunc3.prototype.constructor ); + +new TestCase( SECTION, + "myfunc3.arguments", + null, + myfunc3.arguments ); + +new TestCase( SECTION, + "myfunc3(-100,100,NaN)", + Number.NaN, + myfunc3(-100,100,NaN) ); + +new TestCase( SECTION, + "var MYPROPS = ''; for ( var p in myfunc3.prototype ) { MYPROPS += p; }; MYPROPS", + "", + eval("var MYPROPS = ''; for ( var p in myfunc3.prototype ) { MYPROPS += p; }; MYPROPS") ); + +test(); diff --git a/tests/auto/qml/parserstress/tests/ecma/FunctionObjects/15.3.1.1-3.js b/tests/auto/qml/parserstress/tests/ecma/FunctionObjects/15.3.1.1-3.js new file mode 100644 index 0000000000..51f7bb763b --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/FunctionObjects/15.3.1.1-3.js @@ -0,0 +1,99 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.3.1.1-3.js'; + +/** + File Name: 15.3.1.1-3.js + ECMA Section: 15.3.1.1 The Function Constructor Called as a Function + + new Function(p1, p2, ..., pn, body ) + + Description: The last argument specifies the body (executable code) + of a function; any preceeding arguments sepcify formal + parameters. + + See the text for description of this section. + + This test examples from the specification. + + Author: christine@netscape.com + Date: 28 october 1997 + +*/ +var SECTION = "15.3.1.1-3"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "The Function Constructor Called as a Function"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +var args = ""; + +for ( var i = 0; i < 2000; i++ ) { + args += "arg"+i; + if ( i != 1999 ) { + args += ","; + } +} + +var s = ""; + +for ( var i = 0; i < 2000; i++ ) { + s += ".0005"; + if ( i != 1999 ) { + s += ","; + } +} + +MyFunc = Function( args, "var r=0; for (var i = 0; i < MyFunc.length; i++ ) { if ( eval('arg'+i) == void 0) break; else r += eval('arg'+i); }; return r"); +MyObject = Function( args, "for (var i = 0; i < MyFunc.length; i++ ) { if ( eval('arg'+i) == void 0) break; eval('this.arg'+i +'=arg'+i); };"); + +var MY_OB = eval( "MyFunc("+ s +")" ); + +new TestCase( SECTION, "MyFunc.length", 2000, MyFunc.length ); +new TestCase( SECTION, "var MY_OB = eval('MyFunc(s)')", 1, MY_OB ); +new TestCase( SECTION, "var MY_OB = eval('MyFunc(s)')", 1, eval("var MY_OB = MyFunc("+s+"); MY_OB") ); + +new TestCase( SECTION, "MyObject.length", 2000, MyObject.length ); + +new TestCase( SECTION, "FUN1 = Function( 'a','b','c', 'return FUN1.length' ); FUN1.length", 3, eval("FUN1 = Function( 'a','b','c', 'return FUN1.length' ); FUN1.length") ); +new TestCase( SECTION, "FUN1 = Function( 'a','b','c', 'return FUN1.length' ); FUN1()", 3, eval("FUN1 = Function( 'a','b','c', 'return FUN1.length' ); FUN1()") ); +new TestCase( SECTION, "FUN1 = Function( 'a','b','c', 'return FUN1.length' ); FUN1(1,2,3,4,5)", 3, eval("FUN1 = Function( 'a','b','c', 'return FUN1.length' ); FUN1(1,2,3,4,5)") ); + +test(); diff --git a/tests/auto/qml/parserstress/tests/ecma/FunctionObjects/15.3.2.1-1.js b/tests/auto/qml/parserstress/tests/ecma/FunctionObjects/15.3.2.1-1.js new file mode 100644 index 0000000000..d76e57b828 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/FunctionObjects/15.3.2.1-1.js @@ -0,0 +1,132 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.3.2.1-1.js'; + +/** + File Name: 15.3.2.1.js + ECMA Section: 15.3.2.1 The Function Constructor + new Function(p1, p2, ..., pn, body ) + + Description: The last argument specifies the body (executable code) + of a function; any preceeding arguments sepcify formal + parameters. + + See the text for description of this section. + + This test examples from the specification. + + Author: christine@netscape.com + Date: 28 october 1997 + +*/ +var SECTION = "15.3.2.1"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "The Function Constructor"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +var MyObject = new Function( "value", "this.value = value; this.valueOf = new Function( 'return this.value' ); this.toString = new Function( 'return String(this.value);' )" ); + +var myfunc = new Function(); + +// not going to test toString here since it is implementation dependent. +// new TestCase( SECTION, "myfunc.toString()", "function anonymous() { }", myfunc.toString() ); + +myfunc.toString = Object.prototype.toString; + +new TestCase( SECTION, "myfunc = new Function(); myfunc.toString = Object.prototype.toString; myfunc.toString()", + "[object Function]", + myfunc.toString() ); + +new TestCase( SECTION, + "myfunc.length", + 0, + myfunc.length ); + +new TestCase( SECTION, + "myfunc.prototype.toString()", + "[object Object]", + myfunc.prototype.toString() ); + +new TestCase( SECTION, + "myfunc.prototype.constructor", + myfunc, + myfunc.prototype.constructor ); + +new TestCase( SECTION, + "myfunc.arguments", + null, + myfunc.arguments ); + +new TestCase( SECTION, + "var OBJ = new MyObject(true); OBJ.valueOf()", + true, + eval("var OBJ = new MyObject(true); OBJ.valueOf()") ); + +new TestCase( SECTION, + "OBJ.toString()", + "true", + OBJ.toString() ); + +new TestCase( SECTION, + "OBJ.toString = Object.prototype.toString; OBJ.toString()", "[object Object]", + eval("OBJ.toString = Object.prototype.toString; OBJ.toString()") ); + +new TestCase( SECTION, + "MyObject.toString = Object.prototype.toString; MyObject.toString()", + "[object Function]", + eval("MyObject.toString = Object.prototype.toString; MyObject.toString()") ); + +new TestCase( SECTION, + "MyObject.length", + 1, + MyObject.length ); + +new TestCase( SECTION, + "MyObject.prototype.constructor", + MyObject, + MyObject.prototype.constructor ); + +new TestCase( SECTION, + "MyObject.arguments", + null, + MyObject.arguments ); + +test(); diff --git a/tests/auto/qml/parserstress/tests/ecma/FunctionObjects/15.3.2.1-2.js b/tests/auto/qml/parserstress/tests/ecma/FunctionObjects/15.3.2.1-2.js new file mode 100644 index 0000000000..7729c9587a --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/FunctionObjects/15.3.2.1-2.js @@ -0,0 +1,107 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.3.2.1-2.js'; + +/** + File Name: 15.3.2.1.js + ECMA Section: 15.3.2.1 The Function Constructor + new Function(p1, p2, ..., pn, body ) + + Description: + Author: christine@netscape.com + Date: 28 october 1997 + +*/ +var SECTION = "15.3.2.1-2"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "The Function Constructor"; + +writeHeaderToLog( SECTION + " "+ TITLE); + + +var myfunc1 = new Function("a","b","c", "return a+b+c" ); +var myfunc2 = new Function("a, b, c", "return a+b+c" ); +var myfunc3 = new Function("a,b", "c", "return a+b+c" ); + +myfunc1.toString = Object.prototype.toString; +myfunc2.toString = Object.prototype.toString; +myfunc3.toString = Object.prototype.toString; + +new TestCase( SECTION, "myfunc1 = new Function('a','b','c'); myfunc.toString = Object.prototype.toString; myfunc.toString()", + "[object Function]", + myfunc1.toString() ); + +new TestCase( SECTION, "myfunc1.length", 3, myfunc1.length ); +new TestCase( SECTION, "myfunc1.prototype.toString()", "[object Object]", myfunc1.prototype.toString() ); + +new TestCase( SECTION, "myfunc1.prototype.constructor", myfunc1, myfunc1.prototype.constructor ); +new TestCase( SECTION, "myfunc1.arguments", null, myfunc1.arguments ); +new TestCase( SECTION, "myfunc1(1,2,3)", 6, myfunc1(1,2,3) ); +new TestCase( SECTION, "var MYPROPS = ''; for ( var p in myfunc1.prototype ) { MYPROPS += p; }; MYPROPS", + "", + eval("var MYPROPS = ''; for ( var p in myfunc1.prototype ) { MYPROPS += p; }; MYPROPS") ); + +new TestCase( SECTION, "myfunc2 = new Function('a','b','c'); myfunc.toString = Object.prototype.toString; myfunc.toString()", + "[object Function]", + myfunc2.toString() ); +new TestCase( SECTION, "myfunc2.length", 3, myfunc2.length ); +new TestCase( SECTION, "myfunc2.prototype.toString()", "[object Object]", myfunc2.prototype.toString() ); + +new TestCase( SECTION, "myfunc2.prototype.constructor", myfunc2, myfunc2.prototype.constructor ); +new TestCase( SECTION, "myfunc2.arguments", null, myfunc2.arguments ); +new TestCase( SECTION, "myfunc2( 1000, 200, 30 )", 1230, myfunc2(1000,200,30) ); +new TestCase( SECTION, "var MYPROPS = ''; for ( var p in myfunc2.prototype ) { MYPROPS += p; }; MYPROPS", + "", + eval("var MYPROPS = ''; for ( var p in myfunc2.prototype ) { MYPROPS += p; }; MYPROPS") ); + +new TestCase( SECTION, "myfunc3 = new Function('a','b','c'); myfunc.toString = Object.prototype.toString; myfunc.toString()", + "[object Function]", + myfunc3.toString() ); +new TestCase( SECTION, "myfunc3.length", 3, myfunc3.length ); +new TestCase( SECTION, "myfunc3.prototype.toString()", "[object Object]", myfunc3.prototype.toString() ); +new TestCase( SECTION, "myfunc3.prototype.valueOf() +''", "[object Object]", myfunc3.prototype.valueOf() +'' ); +new TestCase( SECTION, "myfunc3.prototype.constructor", myfunc3, myfunc3.prototype.constructor ); +new TestCase( SECTION, "myfunc3.arguments", null, myfunc3.arguments ); +new TestCase( SECTION, "myfunc3(-100,100,NaN)", Number.NaN, myfunc3(-100,100,NaN) ); + +new TestCase( SECTION, "var MYPROPS = ''; for ( var p in myfunc3.prototype ) { MYPROPS += p; }; MYPROPS", + "", + eval("var MYPROPS = ''; for ( var p in myfunc3.prototype ) { MYPROPS += p; }; MYPROPS") ); +test(); diff --git a/tests/auto/qml/parserstress/tests/ecma/FunctionObjects/15.3.2.1-3.js b/tests/auto/qml/parserstress/tests/ecma/FunctionObjects/15.3.2.1-3.js new file mode 100644 index 0000000000..80b1c41e00 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/FunctionObjects/15.3.2.1-3.js @@ -0,0 +1,95 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.3.2.1-3.js'; + +/** + File Name: 15.3.2.1-3.js + ECMA Section: 15.3.2.1 The Function Constructor + new Function(p1, p2, ..., pn, body ) + + Description: The last argument specifies the body (executable code) + of a function; any preceeding arguments sepcify formal + parameters. + + See the text for description of this section. + + This test examples from the specification. + + Author: christine@netscape.com + Date: 28 october 1997 + +*/ +var SECTION = "15.3.2.1-3"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "The Function Constructor"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +var args = ""; + +for ( var i = 0; i < 2000; i++ ) { + args += "arg"+i; + if ( i != 1999 ) { + args += ","; + } +} + +var s = ""; + +for ( var i = 0; i < 2000; i++ ) { + s += ".0005"; + if ( i != 1999 ) { + s += ","; + } +} + +MyFunc = new Function( args, "var r=0; for (var i = 0; i < MyFunc.length; i++ ) { if ( eval('arg'+i) == void 0) break; else r += eval('arg'+i); }; return r"); +MyObject = new Function( args, "for (var i = 0; i < MyFunc.length; i++ ) { if ( eval('arg'+i) == void 0) break; eval('this.arg'+i +'=arg'+i); };"); + +new TestCase( SECTION, "MyFunc.length", 2000, MyFunc.length ); +new TestCase( SECTION, "var MY_OB = eval('MyFunc(s)')", 1, eval("var MY_OB = MyFunc("+s+"); MY_OB") ); + +new TestCase( SECTION, "MyObject.length", 2000, MyObject.length ); + +new TestCase( SECTION, "FUN1 = new Function( 'a','b','c', 'return FUN1.length' ); FUN1.length", 3, eval("FUN1 = new Function( 'a','b','c', 'return FUN1.length' ); FUN1.length") ); +new TestCase( SECTION, "FUN1 = new Function( 'a','b','c', 'return FUN1.length' ); FUN1()", 3, eval("FUN1 = new Function( 'a','b','c', 'return FUN1.length' ); FUN1()") ); +new TestCase( SECTION, "FUN1 = new Function( 'a','b','c', 'return FUN1.length' ); FUN1(1,2,3,4,5)", 3, eval("FUN1 = new Function( 'a','b','c', 'return FUN1.length' ); FUN1(1,2,3,4,5)") ); + +test(); diff --git a/tests/auto/qml/parserstress/tests/ecma/FunctionObjects/15.3.3.1-2.js b/tests/auto/qml/parserstress/tests/ecma/FunctionObjects/15.3.3.1-2.js new file mode 100644 index 0000000000..b760afd149 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/FunctionObjects/15.3.3.1-2.js @@ -0,0 +1,70 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.3.3.1-2.js'; + +/** + File Name: 15.3.3.1-2.js + ECMA Section: 15.3.3.1 Properties of the Function Constructor + Function.prototype + + Description: The initial value of Function.prototype is the built-in + Function prototype object. + + This property shall have the attributes [DontEnum | + DontDelete | ReadOnly] + + This test the DontEnum property of Function.prototype. + + Author: christine@netscape.com + Date: 28 october 1997 + +*/ +var SECTION = "15.3.3.1-2"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Function.prototype"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +new TestCase( SECTION, + "var str='';for (prop in Function ) str += prop; str;", + "", + eval("var str='';for (prop in Function) str += prop; str;") + ); +test(); diff --git a/tests/auto/qml/parserstress/tests/ecma/FunctionObjects/15.3.3.1-3.js b/tests/auto/qml/parserstress/tests/ecma/FunctionObjects/15.3.3.1-3.js new file mode 100644 index 0000000000..62e6d42342 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/FunctionObjects/15.3.3.1-3.js @@ -0,0 +1,79 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.3.3.1-3.js'; + +/** + File Name: 15.3.3.1-3.js + ECMA Section: 15.3.3.1 Properties of the Function Constructor + Function.prototype + + Description: The initial value of Function.prototype is the built-in + Function prototype object. + + This property shall have the attributes [DontEnum | + DontDelete | ReadOnly] + + This test the DontDelete property of Function.prototype. + + Author: christine@netscape.com + Date: 28 october 1997 + +*/ +var SECTION = "15.3.3.1-3"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Function.prototype"; + +writeHeaderToLog( SECTION + " "+ TITLE); + + +var FUN_PROTO = Function.prototype; + +new TestCase( SECTION, + "delete Function.prototype", + false, + delete Function.prototype + ); + +new TestCase( SECTION, + "delete Function.prototype; Function.prototype", + FUN_PROTO, + eval("delete Function.prototype; Function.prototype") + ); +test(); diff --git a/tests/auto/qml/parserstress/tests/ecma/FunctionObjects/15.3.3.1-4.js b/tests/auto/qml/parserstress/tests/ecma/FunctionObjects/15.3.3.1-4.js new file mode 100644 index 0000000000..6e1aa8426d --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/FunctionObjects/15.3.3.1-4.js @@ -0,0 +1,70 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.3.3.1-4.js'; + +/** + File Name: 15.3.3.1-4.js + ECMA Section: 15.3.3.1 Properties of the Function Constructor + Function.prototype + + Description: The initial value of Function.prototype is the built-in + Function prototype object. + + This property shall have the attributes [DontEnum | + DontDelete | ReadOnly] + + This test the ReadOnly property of Function.prototype. + + Author: christine@netscape.com + Date: 28 october 1997 + +*/ +var SECTION = "15.3.3.1-4"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Function.prototype"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +new TestCase( SECTION, + "Function.prototype = null; Function.prototype", + Function.prototype, + eval("Function.prototype = null; Function.prototype") + ); +test(); diff --git a/tests/auto/qml/parserstress/tests/ecma/FunctionObjects/15.3.3.2.js b/tests/auto/qml/parserstress/tests/ecma/FunctionObjects/15.3.3.2.js new file mode 100644 index 0000000000..b1d04f3957 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/FunctionObjects/15.3.3.2.js @@ -0,0 +1,62 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.3.3.2.js'; + +/** + File Name: 15.3.3.2.js + ECMA Section: 15.3.3.2 Properties of the Function Constructor + Function.length + + Description: The length property is 1. + + Author: christine@netscape.com + Date: 28 october 1997 + +*/ + +var SECTION = "15.3.3.2"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Function.length"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +new TestCase( SECTION, "Function.length", 1, Function.length ); + +test(); diff --git a/tests/auto/qml/parserstress/tests/ecma/FunctionObjects/15.3.4-1.js b/tests/auto/qml/parserstress/tests/ecma/FunctionObjects/15.3.4-1.js new file mode 100644 index 0000000000..c90c26a9e5 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/FunctionObjects/15.3.4-1.js @@ -0,0 +1,94 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.3.4-1.js'; + +/** + File Name: 15.3.4-1.js + ECMA Section: 15.3.4 Properties of the Function Prototype Object + + Description: The Function prototype object is itself a Function + object ( its [[Class]] is "Function") that, when + invoked, accepts any arguments and returns undefined. + + The value of the internal [[Prototype]] property + object is the Object prototype object. + + It is a function with an "empty body"; if it is + invoked, it merely returns undefined. + + The Function prototype object does not have a valueOf + property of its own; however it inherits the valueOf + property from the Object prototype Object. + + Author: christine@netscape.com + Date: 28 october 1997 + +*/ + +var SECTION = "15.3.4-1"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Properties of the Function Prototype Object"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +new TestCase( SECTION, + "var myfunc = Function.prototype; myfunc.toString = Object.prototype.toString; myfunc.toString()", + "[object Function]", + eval("var myfunc = Function.prototype; myfunc.toString = Object.prototype.toString; myfunc.toString()")); + + +// new TestCase( SECTION, "Function.prototype.__proto__", Object.prototype, Function.prototype.__proto__ ); + +new TestCase( SECTION, + "Function.prototype.valueOf", + Object.prototype.valueOf, + Function.prototype.valueOf ); + +new TestCase( SECTION, + "Function.prototype()", + (void 0), + Function.prototype() ); + +new TestCase( SECTION, + "Function.prototype(1,true,false,'string', new Date(),null)", + (void 0), + Function.prototype(1,true,false,'string', new Date(),null) ); + +test(); diff --git a/tests/auto/qml/parserstress/tests/ecma/FunctionObjects/15.3.4.1.js b/tests/auto/qml/parserstress/tests/ecma/FunctionObjects/15.3.4.1.js new file mode 100644 index 0000000000..a6bc775902 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/FunctionObjects/15.3.4.1.js @@ -0,0 +1,61 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.3.4.1.js'; + +/** + File Name: 15.3.4.1.js + ECMA Section: 15.3.4.1 Function.prototype.constructor + + Description: The initial value of Function.prototype.constructor + is the built-in Function constructor. + Author: christine@netscape.com + Date: 28 october 1997 + +*/ + +var SECTION = "15.3.4.1"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Function.prototype.constructor"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +new TestCase( SECTION, "Function.prototype.constructor", Function, Function.prototype.constructor ); + +test(); diff --git a/tests/auto/qml/parserstress/tests/ecma/FunctionObjects/15.3.4.js b/tests/auto/qml/parserstress/tests/ecma/FunctionObjects/15.3.4.js new file mode 100644 index 0000000000..59e3ff81a5 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/FunctionObjects/15.3.4.js @@ -0,0 +1,81 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.3.4.js'; + +/** + File Name: 15.3.4.js + ECMA Section: 15.3.4 Properties of the Function Prototype Object + + Description: The Function prototype object is itself a Function + object ( its [[Class]] is "Function") that, when + invoked, accepts any arguments and returns undefined. + + The value of the internal [[Prototype]] property + object is the Object prototype object. + + It is a function with an "empty body"; if it is + invoked, it merely returns undefined. + + The Function prototype object does not have a valueOf + property of its own; however it inherits the valueOf + property from the Object prototype Object. + + Author: christine@netscape.com + Date: 28 october 1997 + +*/ +var SECTION = "15.3.4"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Properties of the Function Prototype Object"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +new TestCase( SECTION, + "var myfunc = Function.prototype; myfunc.toString = Object.prototype.toString; myfunc.toString()", + "[object Function]", + eval("var myfunc = Function.prototype; myfunc.toString = Object.prototype.toString; myfunc.toString()")); + + +// new TestCase( SECTION, "Function.prototype.__proto__", Object.prototype, Function.prototype.__proto__ ); +new TestCase( SECTION, "Function.prototype.valueOf", Object.prototype.valueOf, Function.prototype.valueOf ); +new TestCase( SECTION, "Function.prototype()", (void 0), Function.prototype() ); +new TestCase( SECTION, "Function.prototype(1,true,false,'string', new Date(),null)", (void 0), Function.prototype(1,true,false,'string', new Date(),null) ); + +test(); diff --git a/tests/auto/qml/parserstress/tests/ecma/FunctionObjects/15.3.5-1.js b/tests/auto/qml/parserstress/tests/ecma/FunctionObjects/15.3.5-1.js new file mode 100644 index 0000000000..c3fbfc774e --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/FunctionObjects/15.3.5-1.js @@ -0,0 +1,117 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.3.5-1.js'; + +/** + File Name: 15.3.5-1.js + ECMA Section: 15.3.5 Properties of Function Instances + new Function(p1, p2, ..., pn, body ) + + Description: + + 15.3.5.1 length + + The value of the length property is usually an integer that indicates + the "typical" number of arguments expected by the function. However, + the language permits the function to be invoked with some other number + of arguments. The behavior of a function when invoked on a number of + arguments other than the number specified by its length property depends + on the function. + + 15.3.5.2 prototype + The value of the prototype property is used to initialize the internal [[ + Prototype]] property of a newly created object before the Function object + is invoked as a constructor for that newly created object. + + 15.3.5.3 arguments + + The value of the arguments property is normally null if there is no + outstanding invocation of the function in progress (that is, the function has been called + but has not yet returned). When a non-internal Function object (15.3.2.1) is invoked, its + arguments property is "dynamically bound" to a newly created object that contains the + arguments on which it was invoked (see 10.1.6 and 10.1.8). Note that the use of this + property is discouraged; it is provided principally for compatibility with existing old code. + + Author: christine@netscape.com + Date: 28 october 1997 + +*/ + +var SECTION = "15.3.5-1"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Properties of Function Instances"; + +writeHeaderToLog( SECTION + " "+TITLE); + +var args = ""; + +for ( var i = 0; i < 2000; i++ ) { + args += "arg"+i; + if ( i != 1999 ) { + args += ","; + } +} + +var s = ""; + +for ( var i = 0; i < 2000; i++ ) { + s += ".0005"; + if ( i != 1999 ) { + s += ","; + } +} + +MyFunc = new Function( args, "var r=0; for (var i = 0; i < MyFunc.length; i++ ) { if ( eval('arg'+i) == void 0) break; else r += eval('arg'+i); }; return r"); +MyObject = new Function( args, "for (var i = 0; i < MyFunc.length; i++ ) { if ( eval('arg'+i) == void 0) break; eval('this.arg'+i +'=arg'+i); };"); + + +new TestCase( SECTION, "MyFunc.length", 2000, MyFunc.length ); +new TestCase( SECTION, "var MY_OB = eval('MyFunc(s)')", 1, eval("var MY_OB = MyFunc("+s+"); MY_OB") ); +new TestCase( SECTION, "MyFunc.prototype.toString()", "[object Object]", MyFunc.prototype.toString() ); +new TestCase( SECTION, "typeof MyFunc.prototype", "object", typeof MyFunc.prototype ); + + +new TestCase( SECTION, "MyObject.length", 2000, MyObject.length ); + +new TestCase( SECTION, "FUN1 = new Function( 'a','b','c', 'return FUN1.length' ); FUN1.length", 3, eval("FUN1 = new Function( 'a','b','c', 'return FUN1.length' ); FUN1.length") ); +new TestCase( SECTION, "FUN1 = new Function( 'a','b','c', 'return FUN1.length' ); FUN1()", 3, eval("FUN1 = new Function( 'a','b','c', 'return FUN1.length' ); FUN1()") ); +new TestCase( SECTION, "FUN1 = new Function( 'a','b','c', 'return FUN1.length' ); FUN1(1,2,3,4,5)", 3, eval("FUN1 = new Function( 'a','b','c', 'return FUN1.length' ); FUN1(1,2,3,4,5)") ); + +test(); diff --git a/tests/auto/qml/parserstress/tests/ecma/FunctionObjects/15.3.5-2.js b/tests/auto/qml/parserstress/tests/ecma/FunctionObjects/15.3.5-2.js new file mode 100644 index 0000000000..dcb351985d --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/FunctionObjects/15.3.5-2.js @@ -0,0 +1,90 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.3.5-2.js'; + +/** + File Name: 15.3.5-1.js + ECMA Section: 15.3.5 Properties of Function Instances + new Function(p1, p2, ..., pn, body ) + + Description: + + 15.3.5.1 length + + The value of the length property is usually an integer that indicates + the "typical" number of arguments expected by the function. However, + the language permits the function to be invoked with some other number + of arguments. The behavior of a function when invoked on a number of + arguments other than the number specified by its length property depends + on the function. + + 15.3.5.2 prototype + The value of the prototype property is used to initialize the internal [[ + Prototype]] property of a newly created object before the Function object + is invoked as a constructor for that newly created object. + + 15.3.5.3 arguments + + The value of the arguments property is normally null if there is no + outstanding invocation of the function in progress (that is, the function has been called + but has not yet returned). When a non-internal Function object (15.3.2.1) is invoked, its + arguments property is "dynamically bound" to a newly created object that contains the + arguments on which it was invoked (see 10.1.6 and 10.1.8). Note that the use of this + property is discouraged; it is provided principally for compatibility with existing old code. + + Author: christine@netscape.com + Date: 28 october 1997 + +*/ + +var SECTION = "15.3.5-2"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Properties of Function Instances"; + +writeHeaderToLog( SECTION + " "+TITLE); + +var MyObject = new Function( 'a', 'b', 'c', 'this.a = a; this.b = b; this.c = c; this.value = a+b+c; this.valueOf = new Function( "return this.value" )' ); + +new TestCase( SECTION, "MyObject.length", 3, MyObject.length ); +new TestCase( SECTION, "typeof MyObject.prototype", "object", typeof MyObject.prototype ); +new TestCase( SECTION, "typeof MyObject.prototype.constructor", "function", typeof MyObject.prototype.constructor ); +new TestCase( SECTION, "MyObject.arguments", null, MyObject.arguments ); + +test(); diff --git a/tests/auto/qml/parserstress/tests/ecma/FunctionObjects/15.3.5.1.js b/tests/auto/qml/parserstress/tests/ecma/FunctionObjects/15.3.5.1.js new file mode 100644 index 0000000000..406d569dba --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/FunctionObjects/15.3.5.1.js @@ -0,0 +1,83 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.3.5.1.js'; + +/** + File Name: 15.3.5.1.js + ECMA Section: Function.length + Description: + + The value of the length property is usually an integer that indicates the + "typical" number of arguments expected by the function. However, the + language permits the function to be invoked with some other number of + arguments. The behavior of a function when invoked on a number of arguments + other than the number specified by its length property depends on the function. + + this test needs a 1.2 version check. + + http://scopus.mcom.com/bugsplat/show_bug.cgi?id=104204 + + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + +var SECTION = "15.3.5.1"; +var VERSION = "ECMA_1"; +var TITLE = "Function.length"; +var BUGNUMBER="104204"; +startTest(); + +writeHeaderToLog( SECTION + " "+ TITLE); + +var f = new Function( "a","b", "c", "return f.length"); + +new TestCase( SECTION, + 'var f = new Function( "a","b", "c", "return f.length"); f()', + 3, + f() ); + + +new TestCase( SECTION, + 'var f = new Function( "a","b", "c", "return f.length"); f(1,2,3,4,5)', + 3, + f(1,2,3,4,5) ); + +test(); + diff --git a/tests/auto/qml/parserstress/tests/ecma/FunctionObjects/15.3.5.3.js b/tests/auto/qml/parserstress/tests/ecma/FunctionObjects/15.3.5.3.js new file mode 100644 index 0000000000..4a127fbc68 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/FunctionObjects/15.3.5.3.js @@ -0,0 +1,72 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.3.5.3.js'; + +/** + File Name: 15.3.5.3.js + ECMA Section: Function.arguments + Description: + + The value of the arguments property is normally null if there is no + outstanding invocation of the function in progress (that is, the + function has been called but has not yet returned). When a non-internal + Function object (15.3.2.1) is invoked, its arguments property is + "dynamically bound" to a newly created object that contains the arguments + on which it was invoked (see 10.1.6 and 10.1.8). Note that the use of this + property is discouraged; it is provided principally for compatibility + with existing old code. + + See sections 10.1.6 and 10.1.8 for more extensive tests. + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + +var SECTION = "15.3.5.3"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Function.arguments"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +var MYFUNCTION = new Function( "return this.arguments" ); + +new TestCase( SECTION, "var MYFUNCTION = new Function( 'return this.arguments' ); MYFUNCTION.arguments", null, MYFUNCTION.arguments ); + +test(); diff --git a/tests/auto/qml/parserstress/tests/ecma/FunctionObjects/browser.js b/tests/auto/qml/parserstress/tests/ecma/FunctionObjects/browser.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/auto/qml/parserstress/tests/ecma/FunctionObjects/shell.js b/tests/auto/qml/parserstress/tests/ecma/FunctionObjects/shell.js new file mode 100644 index 0000000000..27aa7b1318 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/FunctionObjects/shell.js @@ -0,0 +1 @@ +gTestsubsuite = 'FunctionObjects'; diff --git a/tests/auto/qml/parserstress/tests/ecma/GlobalObject/15.1-1-n.js b/tests/auto/qml/parserstress/tests/ecma/GlobalObject/15.1-1-n.js new file mode 100644 index 0000000000..9946a7f2da --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/GlobalObject/15.1-1-n.js @@ -0,0 +1,70 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.1-1-n.js'; + +/** + File Name: 15.1-1-n.js + ECMA Section: The global object + Description: + + The global object does not have a [[Construct]] property; it is not + possible to use the global object as a constructor with the new operator. + + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + +var SECTION = "15.1-1-n"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "The Global Object"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +DESCRIPTION = "var MY_GLOBAL = new this()"; +EXPECTED = "error"; + +new TestCase( SECTION, + "var MY_GLOBAL = new this()", + "error", + eval("var MY_GLOBAL = new this()") ); + +test(); + diff --git a/tests/auto/qml/parserstress/tests/ecma/GlobalObject/15.1-2-n.js b/tests/auto/qml/parserstress/tests/ecma/GlobalObject/15.1-2-n.js new file mode 100644 index 0000000000..545caeeae0 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/GlobalObject/15.1-2-n.js @@ -0,0 +1,67 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.1-2-n.js'; + +/** + File Name: 15.1-2-n.js + ECMA Section: The global object + Description: + + The global object does not have a [[Call]] property; it is not possible + to invoke the global object as a function. + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + +var SECTION = "15.1-2-n"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "The Global Object"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +DESCRIPTION = "var MY_GLOBAL = this()"; +EXPECTED = "error"; + +new TestCase( SECTION, + "var MY_GLOBAL = this()", + "error", + eval("var MY_GLOBAL = this()") ); +test(); diff --git a/tests/auto/qml/parserstress/tests/ecma/GlobalObject/15.1.1.1.js b/tests/auto/qml/parserstress/tests/ecma/GlobalObject/15.1.1.1.js new file mode 100644 index 0000000000..a8d4e7fecf --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/GlobalObject/15.1.1.1.js @@ -0,0 +1,63 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.1.1.1.js'; + +/** + File Name: 15.1.1.1.js + ECMA Section: 15.1.1.1 NaN + + Description: The initial value of NaN is NaN. + + Author: christine@netscape.com + Date: 28 october 1997 + +*/ +var SECTION = "15.1.1.1"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "NaN"; + +writeHeaderToLog( SECTION + " "+ TITLE); + + +new TestCase( SECTION, "NaN", Number.NaN, NaN ); +new TestCase( SECTION, "this.NaN", Number.NaN, this.NaN ); +new TestCase( SECTION, "typeof NaN", "number", typeof NaN ); + +test(); diff --git a/tests/auto/qml/parserstress/tests/ecma/GlobalObject/15.1.1.2.js b/tests/auto/qml/parserstress/tests/ecma/GlobalObject/15.1.1.2.js new file mode 100644 index 0000000000..8671ff642a --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/GlobalObject/15.1.1.2.js @@ -0,0 +1,62 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.1.1.2.js'; + +/** + File Name: 15.1.1.2.js + ECMA Section: 15.1.1.2 Infinity + + Description: The initial value of Infinity is +Infinity. + + Author: christine@netscape.com + Date: 28 october 1997 + +*/ +var SECTION = "15.1.1.2"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Infinity"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +new TestCase( SECTION, "Infinity", Number.POSITIVE_INFINITY, Infinity ); +new TestCase( SECTION, "this.Infinity", Number.POSITIVE_INFINITY, this.Infinity ); +new TestCase( SECTION, "typeof Infinity", "number", typeof Infinity ); + +test(); diff --git a/tests/auto/qml/parserstress/tests/ecma/GlobalObject/15.1.2.1-2.js b/tests/auto/qml/parserstress/tests/ecma/GlobalObject/15.1.2.1-2.js new file mode 100644 index 0000000000..8572371f8e --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/GlobalObject/15.1.2.1-2.js @@ -0,0 +1,66 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.1.2.1-2.js'; + +/** + File Name: 15.1.2.1-2.js + ECMA Section: 15.1.2.1 eval(x) + + Parse x as an ECMAScript Program. If the parse fails, + generate a runtime error. Evaluate the program. If + result is "Normal completion after value V", return + the value V. Else, return undefined. + Description: + Author: christine@netscape.com + Date: 16 september 1997 +*/ +var SECTION = "15.1.2.1-2"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "eval(x)"; +var BUGNUMBER = "none"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +new TestCase( SECTION, + "d = new Date(0); with (d) { x = getUTCMonth() +'/'+ getUTCDate() +'/'+ getUTCFullYear(); } x", + "0/1/1970", + eval( "d = new Date(0); with (d) { x = getUTCMonth() +'/'+ getUTCDate() +'/'+ getUTCFullYear(); } x" )); + +test(); diff --git a/tests/auto/qml/parserstress/tests/ecma/GlobalObject/15.1.2.2-1.js b/tests/auto/qml/parserstress/tests/ecma/GlobalObject/15.1.2.2-1.js new file mode 100644 index 0000000000..a4bf1c7de6 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/GlobalObject/15.1.2.2-1.js @@ -0,0 +1,410 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.1.2.2-1.js'; + +/** + File Name: 15.1.2.2-1.js + ECMA Section: 15.1.2.2 Function properties of the global object + parseInt( string, radix ) + + Description: + + The parseInt function produces an integer value dictated by intepretation + of the contents of the string argument according to the specified radix. + + When the parseInt function is called, the following steps are taken: + + 1. Call ToString(string). + 2. Compute a substring of Result(1) consisting of the leftmost character + that is not a StrWhiteSpaceChar and all characters to the right of + that character. (In other words, remove leading whitespace.) + 3. Let sign be 1. + 4. If Result(2) is not empty and the first character of Result(2) is a + minus sign -, let sign be -1. + 5. If Result(2) is not empty and the first character of Result(2) is a + plus sign + or a minus sign -, then Result(5) is the substring of + Result(2) produced by removing the first character; otherwise, Result(5) + is Result(2). + 6. If the radix argument is not supplied, go to step 12. + 7. Call ToInt32(radix). + 8. If Result(7) is zero, go to step 12; otherwise, if Result(7) < 2 or + Result(7) > 36, return NaN. + 9. Let R be Result(7). + 10. If R = 16 and the length of Result(5) is at least 2 and the first two + characters of Result(5) are either "0x" or "0X", let S be the substring + of Result(5) consisting of all but the first two characters; otherwise, + let S be Result(5). + 11. Go to step 22. + 12. If Result(5) is empty or the first character of Result(5) is not 0, + go to step 20. + 13. If the length of Result(5) is at least 2 and the second character of + Result(5) is x or X, go to step 17. + 14. Let R be 8. + 15. Let S be Result(5). + 16. Go to step 22. + 17. Let R be 16. + 18. Let S be the substring of Result(5) consisting of all but the first + two characters. + 19. Go to step 22. + 20. Let R be 10. + 21. Let S be Result(5). + 22. If S contains any character that is not a radix-R digit, then let Z be + the substring of S consisting of all characters to the left of the + leftmost such character; otherwise, let Z be S. + 23. If Z is empty, return NaN. + 24. Compute the mathematical integer value that is represented by Z in + radix-R notation. (But if R is 10 and Z contains more than 20 + significant digits, every digit after the 20th may be replaced by a 0 + digit, at the option of the implementation; and if R is not 2, 4, 8, + 10, 16, or 32, then Result(24) may be an implementation-dependent + approximation to the mathematical integer value that is represented + by Z in radix-R notation.) + 25. Compute the number value for Result(24). + 26. Return sign Result(25). + + Note that parseInt may interpret only a leading portion of the string as + an integer value; it ignores any characters that cannot be interpreted as + part of the notation of an integer, and no indication is given that any + such characters were ignored. + + Author: christine@netscape.com + Date: 28 october 1997 + +*/ +var SECTION = "15.1.2.2-1"; +var VERSION = "ECMA_1"; +var TITLE = "parseInt(string, radix)"; +var BUGNUMBER = "none"; + +startTest(); + +writeHeaderToLog( SECTION + " "+ TITLE); + +var HEX_STRING = "0x0"; +var HEX_VALUE = 0; + +new TestCase( SECTION, + "parseInt.length", + 2, + parseInt.length ); + +new TestCase( SECTION, + "parseInt.length = 0; parseInt.length", + 2, + eval("parseInt.length = 0; parseInt.length") ); + +new TestCase( SECTION, + "var PROPS=''; for ( var p in parseInt ) { PROPS += p; }; PROPS", "prototype", + eval("var PROPS=''; for ( var p in parseInt ) { PROPS += p; }; PROPS") ); + +new TestCase( SECTION, + "delete parseInt.length", + false, + delete parseInt.length ); + +new TestCase( SECTION, + "delete parseInt.length; parseInt.length", + 2, + eval("delete parseInt.length; parseInt.length") ); + +new TestCase( SECTION, + "parseInt.length = null; parseInt.length", + 2, + eval("parseInt.length = null; parseInt.length") ); + +new TestCase( SECTION, + "parseInt()", + NaN, + parseInt() ); + +new TestCase( SECTION, + "parseInt('')", + NaN, + parseInt("") ); + +new TestCase( SECTION, + "parseInt('','')", + NaN, + parseInt("","") ); + +new TestCase( SECTION, + "parseInt(\" 0xabcdef ", + 11259375, + parseInt( " 0xabcdef " )); + +new TestCase( SECTION, + "parseInt(\" 0XABCDEF ", + 11259375, + parseInt( " 0XABCDEF " ) ); + +new TestCase( SECTION, + "parseInt( 0xabcdef )", + 11259375, + parseInt( "0xabcdef") ); + +new TestCase( SECTION, + "parseInt( 0XABCDEF )", + 11259375, + parseInt( "0XABCDEF") ); + +for ( HEX_STRING = "0x0", HEX_VALUE = 0, POWER = 0; POWER < 15; POWER++, HEX_STRING = HEX_STRING +"f" ) { + new TestCase( SECTION, "parseInt("+HEX_STRING+")", HEX_VALUE, parseInt(HEX_STRING) ); + HEX_VALUE += Math.pow(16,POWER)*15; +} +for ( HEX_STRING = "0X0", HEX_VALUE = 0, POWER = 0; POWER < 15; POWER++, HEX_STRING = HEX_STRING +"f" ) { + new TestCase( SECTION, "parseInt("+HEX_STRING+")", HEX_VALUE, parseInt(HEX_STRING) ); + HEX_VALUE += Math.pow(16,POWER)*15; +} +for ( HEX_STRING = "0x0", HEX_VALUE = 0, POWER = 0; POWER < 15; POWER++, HEX_STRING = HEX_STRING +"f" ) { + new TestCase( SECTION, "parseInt("+HEX_STRING+",16)", HEX_VALUE, parseInt(HEX_STRING,16) ); + HEX_VALUE += Math.pow(16,POWER)*15; +} +for ( HEX_STRING = "0x0", HEX_VALUE = 0, POWER = 0; POWER < 15; POWER++, HEX_STRING = HEX_STRING +"f" ) { + new TestCase( SECTION, "parseInt("+HEX_STRING+",16)", HEX_VALUE, parseInt(HEX_STRING,16) ); + HEX_VALUE += Math.pow(16,POWER)*15; +} +for ( HEX_STRING = "0x0", HEX_VALUE = 0, POWER = 0; POWER < 15; POWER++, HEX_STRING = HEX_STRING +"f" ) { + new TestCase( SECTION, "parseInt("+HEX_STRING+",null)", HEX_VALUE, parseInt(HEX_STRING,null) ); + HEX_VALUE += Math.pow(16,POWER)*15; +} +for ( HEX_STRING = "0x0", HEX_VALUE = 0, POWER = 0; POWER < 15; POWER++, HEX_STRING = HEX_STRING +"f" ) { + new TestCase( SECTION, "parseInt("+HEX_STRING+", void 0)", HEX_VALUE, parseInt(HEX_STRING, void 0) ); + HEX_VALUE += Math.pow(16,POWER)*15; +} + +// a few tests with spaces + +for ( var space = " ", HEX_STRING = "0x0", HEX_VALUE = 0, POWER = 0; + POWER < 15; + POWER++, HEX_STRING = HEX_STRING +"f", space += " ") +{ + new TestCase( SECTION, "parseInt("+space+HEX_STRING+space+", void 0)", HEX_VALUE, parseInt(space+HEX_STRING+space, void 0) ); + HEX_VALUE += Math.pow(16,POWER)*15; +} + +// a few tests with negative numbers +for ( HEX_STRING = "-0x0", HEX_VALUE = 0, POWER = 0; POWER < 15; POWER++, HEX_STRING = HEX_STRING +"f" ) { + new TestCase( SECTION, "parseInt("+HEX_STRING+")", HEX_VALUE, parseInt(HEX_STRING) ); + HEX_VALUE -= Math.pow(16,POWER)*15; +} + +// we should stop parsing when we get to a value that is not a numeric literal for the type we expect + +for ( HEX_STRING = "0x0", HEX_VALUE = 0, POWER = 0; POWER < 15; POWER++, HEX_STRING = HEX_STRING +"f" ) { + new TestCase( SECTION, "parseInt("+HEX_STRING+"g,16)", HEX_VALUE, parseInt(HEX_STRING+"g",16) ); + HEX_VALUE += Math.pow(16,POWER)*15; +} +for ( HEX_STRING = "0x0", HEX_VALUE = 0, POWER = 0; POWER < 15; POWER++, HEX_STRING = HEX_STRING +"f" ) { + new TestCase( SECTION, "parseInt("+HEX_STRING+"g,16)", HEX_VALUE, parseInt(HEX_STRING+"G",16) ); + HEX_VALUE += Math.pow(16,POWER)*15; +} + +for ( HEX_STRING = "-0x0", HEX_VALUE = 0, POWER = 0; POWER < 15; POWER++, HEX_STRING = HEX_STRING +"f" ) { + new TestCase( SECTION, "parseInt("+HEX_STRING+")", HEX_VALUE, parseInt(HEX_STRING) ); + HEX_VALUE -= Math.pow(16,POWER)*15; +} +for ( HEX_STRING = "-0X0", HEX_VALUE = 0, POWER = 0; POWER < 15; POWER++, HEX_STRING = HEX_STRING +"f" ) { + new TestCase( SECTION, "parseInt("+HEX_STRING+")", HEX_VALUE, parseInt(HEX_STRING) ); + HEX_VALUE -= Math.pow(16,POWER)*15; +} +for ( HEX_STRING = "-0x0", HEX_VALUE = 0, POWER = 0; POWER < 15; POWER++, HEX_STRING = HEX_STRING +"f" ) { + new TestCase( SECTION, "parseInt("+HEX_STRING+",16)", HEX_VALUE, parseInt(HEX_STRING,16) ); + HEX_VALUE -= Math.pow(16,POWER)*15; +} +for ( HEX_STRING = "-0x0", HEX_VALUE = 0, POWER = 0; POWER < 15; POWER++, HEX_STRING = HEX_STRING +"f" ) { + new TestCase( SECTION, "parseInt("+HEX_STRING+",16)", HEX_VALUE, parseInt(HEX_STRING,16) ); + HEX_VALUE -= Math.pow(16,POWER)*15; +} + +// let us do some octal tests. numbers that start with 0 and do not provid a radix should +// default to using "0" as a radix. + +var OCT_STRING = "0"; +var OCT_VALUE = 0; + +for ( OCT_STRING = "0", OCT_VALUE = 0, POWER = 0; POWER < 15; POWER++, OCT_STRING = OCT_STRING +"7" ) { + new TestCase( SECTION, "parseInt("+OCT_STRING+")", OCT_VALUE, parseInt(OCT_STRING) ); + OCT_VALUE += Math.pow(8,POWER)*7; +} + +for ( OCT_STRING = "-0", OCT_VALUE = 0, POWER = 0; POWER < 15; POWER++, OCT_STRING = OCT_STRING +"7" ) { + new TestCase( SECTION, "parseInt("+OCT_STRING+")", OCT_VALUE, parseInt(OCT_STRING) ); + OCT_VALUE -= Math.pow(8,POWER)*7; +} + +// should get the same results as above if we provid the radix of 8 (or 010) + +for ( OCT_STRING = "0", OCT_VALUE = 0, POWER = 0; POWER < 15; POWER++, OCT_STRING = OCT_STRING +"7" ) { + new TestCase( SECTION, "parseInt("+OCT_STRING+",8)", OCT_VALUE, parseInt(OCT_STRING,8) ); + OCT_VALUE += Math.pow(8,POWER)*7; +} +for ( OCT_STRING = "-0", OCT_VALUE = 0, POWER = 0; POWER < 15; POWER++, OCT_STRING = OCT_STRING +"7" ) { + new TestCase( SECTION, "parseInt("+OCT_STRING+",010)", OCT_VALUE, parseInt(OCT_STRING,010) ); + OCT_VALUE -= Math.pow(8,POWER)*7; +} + +// we shall stop parsing digits when we get one that isn't a numeric literal of the type we think +// it should be. +for ( OCT_STRING = "0", OCT_VALUE = 0, POWER = 0; POWER < 15; POWER++, OCT_STRING = OCT_STRING +"7" ) { + new TestCase( SECTION, "parseInt("+OCT_STRING+"8,8)", OCT_VALUE, parseInt(OCT_STRING+"8",8) ); + OCT_VALUE += Math.pow(8,POWER)*7; +} +for ( OCT_STRING = "-0", OCT_VALUE = 0, POWER = 0; POWER < 15; POWER++, OCT_STRING = OCT_STRING +"7" ) { + new TestCase( SECTION, "parseInt("+OCT_STRING+"8,010)", OCT_VALUE, parseInt(OCT_STRING+"8",010) ); + OCT_VALUE -= Math.pow(8,POWER)*7; +} + +new TestCase( SECTION, + "parseInt( '0x' )", + NaN, + parseInt("0x") ); + +new TestCase( SECTION, + "parseInt( '0X' )", + NaN, + parseInt("0X") ); + +new TestCase( SECTION, + "parseInt( '11111111112222222222' )", + 11111111112222222222, + parseInt("11111111112222222222") ); + +new TestCase( SECTION, + "parseInt( '111111111122222222223' )", + 111111111122222222220, + parseInt("111111111122222222223") ); + +new TestCase( SECTION, + "parseInt( '11111111112222222222',10 )", + 11111111112222222222, + parseInt("11111111112222222222",10) ); + +new TestCase( SECTION, + "parseInt( '111111111122222222223',10 )", + 111111111122222222220, + parseInt("111111111122222222223",10) ); + +new TestCase( SECTION, + "parseInt( '01234567890', -1 )", + Number.NaN, + parseInt("01234567890",-1) ); + +new TestCase( SECTION, + "parseInt( '01234567890', 0 )", + Number.NaN, + parseInt("01234567890",1) ); + +new TestCase( SECTION, + "parseInt( '01234567890', 1 )", + Number.NaN, + parseInt("01234567890",1) ); + +new TestCase( SECTION, + "parseInt( '01234567890', 2 )", + 1, + parseInt("01234567890",2) ); + +new TestCase( SECTION, + "parseInt( '01234567890', 3 )", + 5, + parseInt("01234567890",3) ); + +new TestCase( SECTION, + "parseInt( '01234567890', 4 )", + 27, + parseInt("01234567890",4) ); + +new TestCase( SECTION, + "parseInt( '01234567890', 5 )", + 194, + parseInt("01234567890",5) ); + +new TestCase( SECTION, + "parseInt( '01234567890', 6 )", + 1865, + parseInt("01234567890",6) ); + +new TestCase( SECTION, + "parseInt( '01234567890', 7 )", + 22875, + parseInt("01234567890",7) ); + +new TestCase( SECTION, + "parseInt( '01234567890', 8 )", + 342391, + parseInt("01234567890",8) ); + +new TestCase( SECTION, + "parseInt( '01234567890', 9 )", + 6053444, + parseInt("01234567890",9) ); + +new TestCase( SECTION, + "parseInt( '01234567890', 10 )", + 1234567890, + parseInt("01234567890",10) ); + +// need more test cases with hex radix + +new TestCase( SECTION, + "parseInt( '1234567890', '0xa')", + 1234567890, + parseInt("1234567890","0xa") ); + +new TestCase( SECTION, + "parseInt( '012345', 11 )", + 17715, + parseInt("012345",11) ); + +new TestCase( SECTION, + "parseInt( '012345', 35 )", + 1590195, + parseInt("012345",35) ); + +new TestCase( SECTION, + "parseInt( '012345', 36 )", + 1776965, + parseInt("012345",36) ); + +new TestCase( SECTION, + "parseInt( '012345', 37 )", + Number.NaN, + parseInt("012345",37) ); + +test(); diff --git a/tests/auto/qml/parserstress/tests/ecma/GlobalObject/15.1.2.2-2.js b/tests/auto/qml/parserstress/tests/ecma/GlobalObject/15.1.2.2-2.js new file mode 100644 index 0000000000..ff8806dfb2 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/GlobalObject/15.1.2.2-2.js @@ -0,0 +1,238 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.1.2.2-2.js'; + +/** + File Name: 15.1.2.2-1.js + ECMA Section: 15.1.2.2 Function properties of the global object + parseInt( string, radix ) + + Description: parseInt test cases written by waldemar, and documented in + http://scopus.mcom.com/bugsplat/show_bug.cgi?id=123874. + + Author: christine@netscape.com + Date: 28 october 1997 + +*/ +var SECTION = "15.1.2.2-2"; +var VERSION = "ECMA_1"; +var TITLE = "parseInt(string, radix)"; +var BUGNUMBER = "none"; + +startTest(); + +writeHeaderToLog( SECTION + " "+ TITLE); + +new TestCase( SECTION, + 'parseInt("000000100000000100100011010001010110011110001001101010111100",2)', + 9027215253084860, + parseInt("000000100000000100100011010001010110011110001001101010111100",2) ); + +new TestCase( SECTION, + 'parseInt("000000100000000100100011010001010110011110001001101010111101",2)', + 9027215253084860, + parseInt("000000100000000100100011010001010110011110001001101010111101",2)); + +new TestCase( SECTION, + 'parseInt("000000100000000100100011010001010110011110001001101010111111",2)', + 9027215253084864, + parseInt("000000100000000100100011010001010110011110001001101010111111",2) ); + +new TestCase( SECTION, + 'parseInt("0000001000000001001000110100010101100111100010011010101111010",2)', + 18054430506169720, + parseInt("0000001000000001001000110100010101100111100010011010101111010",2) ); + +new TestCase( SECTION, + 'parseInt("0000001000000001001000110100010101100111100010011010101111011",2)', + 18054430506169724, + parseInt("0000001000000001001000110100010101100111100010011010101111011",2)); + +new TestCase( SECTION, + 'parseInt("0000001000000001001000110100010101100111100010011010101111100",2)', + 18054430506169724, + parseInt("0000001000000001001000110100010101100111100010011010101111100",2) ); + +new TestCase( SECTION, + 'parseInt("0000001000000001001000110100010101100111100010011010101111110",2)', + 18054430506169728, + parseInt("0000001000000001001000110100010101100111100010011010101111110",2) ); + +new TestCase( SECTION, + 'parseInt("yz",35)', + 34, + parseInt("yz",35) ); + +new TestCase( SECTION, + 'parseInt("yz",36)', + 1259, + parseInt("yz",36) ); + +new TestCase( SECTION, + 'parseInt("yz",37)', + NaN, + parseInt("yz",37) ); + +new TestCase( SECTION, + 'parseInt("+77")', + 77, + parseInt("+77") ); + +new TestCase( SECTION, + 'parseInt("-77",9)', + -70, + parseInt("-77",9) ); + +new TestCase( SECTION, + 'parseInt("\u20001234\u2000")', + 1234, + parseInt("\u20001234\u2000") ); + +new TestCase( SECTION, + 'parseInt("123456789012345678")', + 123456789012345680, + parseInt("123456789012345678") ); + +new TestCase( SECTION, + 'parseInt("9",8)', + NaN, + parseInt("9",8) ); + +new TestCase( SECTION, + 'parseInt("1e2")', + 1, + parseInt("1e2") ); + +new TestCase( SECTION, + 'parseInt("1.9999999999999999999")', + 1, + parseInt("1.9999999999999999999") ); + +new TestCase( SECTION, + 'parseInt("0x10")', + 16, + parseInt("0x10") ); + +new TestCase( SECTION, + 'parseInt("0x10",10)', + 0, + parseInt("0x10",10)); + +new TestCase( SECTION, + 'parseInt("0022")', + 18, + parseInt("0022")); + +new TestCase( SECTION, + 'parseInt("0022",10)', + 22, + parseInt("0022",10) ); + +new TestCase( SECTION, + 'parseInt("0x1000000000000080")', + 1152921504606847000, + parseInt("0x1000000000000080") ); + +new TestCase( SECTION, + 'parseInt("0x1000000000000081")', + 1152921504606847200, + parseInt("0x1000000000000081") ); + +s = + "0xFFFFFFFFFFFFF80000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000" + + s += "0000000000000000000000000000000000000"; + +new TestCase( SECTION, + "s = " + s +"; -s", + -1.7976931348623157e+308, + -s ); + +s = + "0xFFFFFFFFFFFFF80000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"; +s += "0000000000000000000000000000000000001"; + +new TestCase( SECTION, + "s = " + s +"; -s", + -1.7976931348623157e+308, + -s ); + + +s = "0xFFFFFFFFFFFFFC0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"; + +s += "0000000000000000000000000000000000000" + + +new TestCase( SECTION, + "s = " + s + "; -s", + -Infinity, + -s ); + +s = "0xFFFFFFFFFFFFFB0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"; +s += "0000000000000000000000000000000000001"; + +new TestCase( SECTION, + "s = " + s + "; -s", + -1.7976931348623157e+308, + -s ); + +s += "0" + +new TestCase( SECTION, + "s = " + s + "; -s", + -Infinity, + -s ); + +new TestCase( SECTION, + 'parseInt(s)', + Infinity, + parseInt(s) ); + +new TestCase( SECTION, + 'parseInt(s,32)', + 0, + parseInt(s,32) ); + +new TestCase( SECTION, + 'parseInt(s,36)', + Infinity, + parseInt(s,36)); + +test(); + diff --git a/tests/auto/qml/parserstress/tests/ecma/GlobalObject/15.1.2.3-1.js b/tests/auto/qml/parserstress/tests/ecma/GlobalObject/15.1.2.3-1.js new file mode 100644 index 0000000000..56bf83adcc --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/GlobalObject/15.1.2.3-1.js @@ -0,0 +1,441 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.1.2.3-1.js'; + +/** + File Name: 15.1.2.3.js + ECMA Section: 15.1.2.3 Function properties of the global object: + parseFloat( string ) + + Description: The parseFloat function produces a number value dictated + by the interpretation of the contents of the string + argument defined as a decimal literal. + + When the parseFloat function is called, the following + steps are taken: + + 1. Call ToString( string ). + 2. Remove leading whitespace Result(1). + 3. If neither Result(2) nor any prefix of Result(2) + satisfies the syntax of a StrDecimalLiteral, + return NaN. + 4. Compute the longest prefix of Result(2) which might + be Resusult(2) itself, that satisfies the syntax of + a StrDecimalLiteral + 5. Return the number value for the MV of Result(4). + + Note that parseFloate may interpret only a leading + portion of the string as a number value; it ignores any + characters that cannot be interpreted as part of the + notation of a decimal literal, and no indication is given + that such characters were ignored. + + StrDecimalLiteral:: + Infinity + DecimalDigits.DecimalDigits opt ExponentPart opt + .DecimalDigits ExponentPart opt + DecimalDigits ExponentPart opt + + Author: christine@netscape.com + Date: 28 october 1997 + +*/ + +var SECTION = "15.1.2.3-1"; +var VERSION = "ECMA_1"; +var TITLE = "parseFloat(string)"; +var BUGNUMBER="none"; + +startTest(); +writeHeaderToLog( SECTION + " "+ TITLE); + +new TestCase( SECTION, "parseFloat.length", 1, parseFloat.length ); + +new TestCase( SECTION, "parseFloat.length = null; parseFloat.length", 1, eval("parseFloat.length = null; parseFloat.length") ); +new TestCase( SECTION, "delete parseFloat.length", false, delete parseFloat.length ); +new TestCase( SECTION, "delete parseFloat.length; parseFloat.length", 1, eval("delete parseFloat.length; parseFloat.length") ); +new TestCase( SECTION, "var MYPROPS=''; for ( var p in parseFloat ) { MYPROPS += p }; MYPROPS", "prototype", eval("var MYPROPS=''; for ( var p in parseFloat ) { MYPROPS += p }; MYPROPS") ); + +new TestCase( SECTION, "parseFloat()", Number.NaN, parseFloat() ); +new TestCase( SECTION, "parseFloat('')", Number.NaN, parseFloat('') ); + +new TestCase( SECTION, "parseFloat(' ')", Number.NaN, parseFloat(' ') ); +new TestCase( SECTION, "parseFloat(true)", Number.NaN, parseFloat(true) ); +new TestCase( SECTION, "parseFloat(false)", Number.NaN, parseFloat(false) ); +new TestCase( SECTION, "parseFloat('string')", Number.NaN, parseFloat("string") ); + +new TestCase( SECTION, "parseFloat(' Infinity')", Infinity, parseFloat("Infinity") ); +new TestCase( SECTION, "parseFloat(' Infinity ')", Infinity, parseFloat(' Infinity ') ); + +new TestCase( SECTION, "parseFloat('Infinity')", Infinity, parseFloat("Infinity") ); +new TestCase( SECTION, "parseFloat(Infinity)", Infinity, parseFloat(Infinity) ); + + +new TestCase( SECTION, "parseFloat(' +Infinity')", +Infinity, parseFloat("+Infinity") ); +new TestCase( SECTION, "parseFloat(' -Infinity ')", -Infinity, parseFloat(' -Infinity ') ); + +new TestCase( SECTION, "parseFloat('+Infinity')", +Infinity, parseFloat("+Infinity") ); +new TestCase( SECTION, "parseFloat(-Infinity)", -Infinity, parseFloat(-Infinity) ); + +new TestCase( SECTION, "parseFloat('0')", 0, parseFloat("0") ); +new TestCase( SECTION, "parseFloat('-0')", -0, parseFloat("-0") ); +new TestCase( SECTION, "parseFloat('+0')", 0, parseFloat("+0") ); + +new TestCase( SECTION, "parseFloat('1')", 1, parseFloat("1") ); +new TestCase( SECTION, "parseFloat('-1')", -1, parseFloat("-1") ); +new TestCase( SECTION, "parseFloat('+1')", 1, parseFloat("+1") ); + +new TestCase( SECTION, "parseFloat('2')", 2, parseFloat("2") ); +new TestCase( SECTION, "parseFloat('-2')", -2, parseFloat("-2") ); +new TestCase( SECTION, "parseFloat('+2')", 2, parseFloat("+2") ); + +new TestCase( SECTION, "parseFloat('3')", 3, parseFloat("3") ); +new TestCase( SECTION, "parseFloat('-3')", -3, parseFloat("-3") ); +new TestCase( SECTION, "parseFloat('+3')", 3, parseFloat("+3") ); + +new TestCase( SECTION, "parseFloat('4')", 4, parseFloat("4") ); +new TestCase( SECTION, "parseFloat('-4')", -4, parseFloat("-4") ); +new TestCase( SECTION, "parseFloat('+4')", 4, parseFloat("+4") ); + +new TestCase( SECTION, "parseFloat('5')", 5, parseFloat("5") ); +new TestCase( SECTION, "parseFloat('-5')", -5, parseFloat("-5") ); +new TestCase( SECTION, "parseFloat('+5')", 5, parseFloat("+5") ); + +new TestCase( SECTION, "parseFloat('6')", 6, parseFloat("6") ); +new TestCase( SECTION, "parseFloat('-6')", -6, parseFloat("-6") ); +new TestCase( SECTION, "parseFloat('+6')", 6, parseFloat("+6") ); + +new TestCase( SECTION, "parseFloat('7')", 7, parseFloat("7") ); +new TestCase( SECTION, "parseFloat('-7')", -7, parseFloat("-7") ); +new TestCase( SECTION, "parseFloat('+7')", 7, parseFloat("+7") ); + +new TestCase( SECTION, "parseFloat('8')", 8, parseFloat("8") ); +new TestCase( SECTION, "parseFloat('-8')", -8, parseFloat("-8") ); +new TestCase( SECTION, "parseFloat('+8')", 8, parseFloat("+8") ); + +new TestCase( SECTION, "parseFloat('9')", 9, parseFloat("9") ); +new TestCase( SECTION, "parseFloat('-9')", -9, parseFloat("-9") ); +new TestCase( SECTION, "parseFloat('+9')", 9, parseFloat("+9") ); + +new TestCase( SECTION, "parseFloat('3.14159')", 3.14159, parseFloat("3.14159") ); +new TestCase( SECTION, "parseFloat('-3.14159')", -3.14159, parseFloat("-3.14159") ); +new TestCase( SECTION, "parseFloat('+3.14159')", 3.14159, parseFloat("+3.14159") ); + +new TestCase( SECTION, "parseFloat('3.')", 3, parseFloat("3.") ); +new TestCase( SECTION, "parseFloat('-3.')", -3, parseFloat("-3.") ); +new TestCase( SECTION, "parseFloat('+3.')", 3, parseFloat("+3.") ); + +new TestCase( SECTION, "parseFloat('3.e1')", 30, parseFloat("3.e1") ); +new TestCase( SECTION, "parseFloat('-3.e1')", -30, parseFloat("-3.e1") ); +new TestCase( SECTION, "parseFloat('+3.e1')", 30, parseFloat("+3.e1") ); + +new TestCase( SECTION, "parseFloat('3.e+1')", 30, parseFloat("3.e+1") ); +new TestCase( SECTION, "parseFloat('-3.e+1')", -30, parseFloat("-3.e+1") ); +new TestCase( SECTION, "parseFloat('+3.e+1')", 30, parseFloat("+3.e+1") ); + +new TestCase( SECTION, "parseFloat('3.e-1')", .30, parseFloat("3.e-1") ); +new TestCase( SECTION, "parseFloat('-3.e-1')", -.30, parseFloat("-3.e-1") ); +new TestCase( SECTION, "parseFloat('+3.e-1')", .30, parseFloat("+3.e-1") ); + +// StrDecimalLiteral::: .DecimalDigits ExponentPart opt + +new TestCase( SECTION, "parseFloat('.00001')", 0.00001, parseFloat(".00001") ); +new TestCase( SECTION, "parseFloat('+.00001')", 0.00001, parseFloat("+.00001") ); +new TestCase( SECTION, "parseFloat('-0.0001')", -0.00001, parseFloat("-.00001") ); + +new TestCase( SECTION, "parseFloat('.01e2')", 1, parseFloat(".01e2") ); +new TestCase( SECTION, "parseFloat('+.01e2')", 1, parseFloat("+.01e2") ); +new TestCase( SECTION, "parseFloat('-.01e2')", -1, parseFloat("-.01e2") ); + +new TestCase( SECTION, "parseFloat('.01e+2')", 1, parseFloat(".01e+2") ); +new TestCase( SECTION, "parseFloat('+.01e+2')", 1, parseFloat("+.01e+2") ); +new TestCase( SECTION, "parseFloat('-.01e+2')", -1, parseFloat("-.01e+2") ); + +new TestCase( SECTION, "parseFloat('.01e-2')", 0.0001, parseFloat(".01e-2") ); +new TestCase( SECTION, "parseFloat('+.01e-2')", 0.0001, parseFloat("+.01e-2") ); +new TestCase( SECTION, "parseFloat('-.01e-2')", -0.0001, parseFloat("-.01e-2") ); + +// StrDecimalLiteral::: DecimalDigits ExponentPart opt + +new TestCase( SECTION, "parseFloat('1234e5')", 123400000, parseFloat("1234e5") ); +new TestCase( SECTION, "parseFloat('+1234e5')", 123400000, parseFloat("+1234e5") ); +new TestCase( SECTION, "parseFloat('-1234e5')", -123400000, parseFloat("-1234e5") ); + +new TestCase( SECTION, "parseFloat('1234e+5')", 123400000, parseFloat("1234e+5") ); +new TestCase( SECTION, "parseFloat('+1234e+5')", 123400000, parseFloat("+1234e+5") ); +new TestCase( SECTION, "parseFloat('-1234e+5')", -123400000, parseFloat("-1234e+5") ); + +new TestCase( SECTION, "parseFloat('1234e-5')", 0.01234, parseFloat("1234e-5") ); +new TestCase( SECTION, "parseFloat('+1234e-5')", 0.01234, parseFloat("+1234e-5") ); +new TestCase( SECTION, "parseFloat('-1234e-5')", -0.01234, parseFloat("-1234e-5") ); + + +new TestCase( SECTION, "parseFloat(0)", 0, parseFloat(0) ); +new TestCase( SECTION, "parseFloat(-0)", -0, parseFloat(-0) ); + +new TestCase( SECTION, "parseFloat(1)", 1, parseFloat(1) ); +new TestCase( SECTION, "parseFloat(-1)", -1, parseFloat(-1) ); + +new TestCase( SECTION, "parseFloat(2)", 2, parseFloat(2) ); +new TestCase( SECTION, "parseFloat(-2)", -2, parseFloat(-2) ); + +new TestCase( SECTION, "parseFloat(3)", 3, parseFloat(3) ); +new TestCase( SECTION, "parseFloat(-3)", -3, parseFloat(-3) ); + +new TestCase( SECTION, "parseFloat(4)", 4, parseFloat(4) ); +new TestCase( SECTION, "parseFloat(-4)", -4, parseFloat(-4) ); + +new TestCase( SECTION, "parseFloat(5)", 5, parseFloat(5) ); +new TestCase( SECTION, "parseFloat(-5)", -5, parseFloat(-5) ); + +new TestCase( SECTION, "parseFloat(6)", 6, parseFloat(6) ); +new TestCase( SECTION, "parseFloat(-6)", -6, parseFloat(-6) ); + +new TestCase( SECTION, "parseFloat(7)", 7, parseFloat(7) ); +new TestCase( SECTION, "parseFloat(-7)", -7, parseFloat(-7) ); + +new TestCase( SECTION, "parseFloat(8)", 8, parseFloat(8) ); +new TestCase( SECTION, "parseFloat(-8)", -8, parseFloat(-8) ); + +new TestCase( SECTION, "parseFloat(9)", 9, parseFloat(9) ); +new TestCase( SECTION, "parseFloat(-9)", -9, parseFloat(-9) ); + +new TestCase( SECTION, "parseFloat(3.14159)", 3.14159, parseFloat(3.14159) ); +new TestCase( SECTION, "parseFloat(-3.14159)", -3.14159, parseFloat(-3.14159) ); + +new TestCase( SECTION, "parseFloat(3.)", 3, parseFloat(3.) ); +new TestCase( SECTION, "parseFloat(-3.)", -3, parseFloat(-3.) ); + +new TestCase( SECTION, "parseFloat(3.e1)", 30, parseFloat(3.e1) ); +new TestCase( SECTION, "parseFloat(-3.e1)", -30, parseFloat(-3.e1) ); + +new TestCase( SECTION, "parseFloat(3.e+1)", 30, parseFloat(3.e+1) ); +new TestCase( SECTION, "parseFloat(-3.e+1)", -30, parseFloat(-3.e+1) ); + +new TestCase( SECTION, "parseFloat(3.e-1)", .30, parseFloat(3.e-1) ); +new TestCase( SECTION, "parseFloat(-3.e-1)", -.30, parseFloat(-3.e-1) ); + + +new TestCase( SECTION, "parseFloat(3.E1)", 30, parseFloat(3.E1) ); +new TestCase( SECTION, "parseFloat(-3.E1)", -30, parseFloat(-3.E1) ); + +new TestCase( SECTION, "parseFloat(3.E+1)", 30, parseFloat(3.E+1) ); +new TestCase( SECTION, "parseFloat(-3.E+1)", -30, parseFloat(-3.E+1) ); + +new TestCase( SECTION, "parseFloat(3.E-1)", .30, parseFloat(3.E-1) ); +new TestCase( SECTION, "parseFloat(-3.E-1)", -.30, parseFloat(-3.E-1) ); + +// StrDecimalLiteral::: .DecimalDigits ExponentPart opt + +new TestCase( SECTION, "parseFloat(.00001)", 0.00001, parseFloat(.00001) ); +new TestCase( SECTION, "parseFloat(-0.0001)", -0.00001, parseFloat(-.00001) ); + +new TestCase( SECTION, "parseFloat(.01e2)", 1, parseFloat(.01e2) ); +new TestCase( SECTION, "parseFloat(-.01e2)", -1, parseFloat(-.01e2) ); + +new TestCase( SECTION, "parseFloat(.01e+2)", 1, parseFloat(.01e+2) ); +new TestCase( SECTION, "parseFloat(-.01e+2)", -1, parseFloat(-.01e+2) ); + +new TestCase( SECTION, "parseFloat(.01e-2)", 0.0001, parseFloat(.01e-2) ); +new TestCase( SECTION, "parseFloat(-.01e-2)", -0.0001, parseFloat(-.01e-2) ); + +// StrDecimalLiteral::: DecimalDigits ExponentPart opt + +new TestCase( SECTION, "parseFloat(1234e5)", 123400000, parseFloat(1234e5) ); +new TestCase( SECTION, "parseFloat(-1234e5)", -123400000, parseFloat(-1234e5) ); + +new TestCase( SECTION, "parseFloat(1234e+5)", 123400000, parseFloat(1234e+5) ); +new TestCase( SECTION, "parseFloat(-1234e+5)", -123400000, parseFloat(-1234e+5) ); + +new TestCase( SECTION, "parseFloat(1234e-5)", 0.01234, parseFloat(1234e-5) ); +new TestCase( SECTION, "parseFloat(-1234e-5)", -0.01234, parseFloat(-1234e-5) ); + +// hex cases should all return 0 (0 is the longest string that satisfies a StringDecimalLiteral) + +new TestCase( SECTION, "parseFloat('0x0')", 0, parseFloat("0x0")); +new TestCase( SECTION, "parseFloat('0x1')", 0, parseFloat("0x1")); +new TestCase( SECTION, "parseFloat('0x2')", 0, parseFloat("0x2")); +new TestCase( SECTION, "parseFloat('0x3')", 0, parseFloat("0x3")); +new TestCase( SECTION, "parseFloat('0x4')", 0, parseFloat("0x4")); +new TestCase( SECTION, "parseFloat('0x5')", 0, parseFloat("0x5")); +new TestCase( SECTION, "parseFloat('0x6')", 0, parseFloat("0x6")); +new TestCase( SECTION, "parseFloat('0x7')", 0, parseFloat("0x7")); +new TestCase( SECTION, "parseFloat('0x8')", 0, parseFloat("0x8")); +new TestCase( SECTION, "parseFloat('0x9')", 0, parseFloat("0x9")); +new TestCase( SECTION, "parseFloat('0xa')", 0, parseFloat("0xa")); +new TestCase( SECTION, "parseFloat('0xb')", 0, parseFloat("0xb")); +new TestCase( SECTION, "parseFloat('0xc')", 0, parseFloat("0xc")); +new TestCase( SECTION, "parseFloat('0xd')", 0, parseFloat("0xd")); +new TestCase( SECTION, "parseFloat('0xe')", 0, parseFloat("0xe")); +new TestCase( SECTION, "parseFloat('0xf')", 0, parseFloat("0xf")); +new TestCase( SECTION, "parseFloat('0xA')", 0, parseFloat("0xA")); +new TestCase( SECTION, "parseFloat('0xB')", 0, parseFloat("0xB")); +new TestCase( SECTION, "parseFloat('0xC')", 0, parseFloat("0xC")); +new TestCase( SECTION, "parseFloat('0xD')", 0, parseFloat("0xD")); +new TestCase( SECTION, "parseFloat('0xE')", 0, parseFloat("0xE")); +new TestCase( SECTION, "parseFloat('0xF')", 0, parseFloat("0xF")); + +new TestCase( SECTION, "parseFloat('0X0')", 0, parseFloat("0X0")); +new TestCase( SECTION, "parseFloat('0X1')", 0, parseFloat("0X1")); +new TestCase( SECTION, "parseFloat('0X2')", 0, parseFloat("0X2")); +new TestCase( SECTION, "parseFloat('0X3')", 0, parseFloat("0X3")); +new TestCase( SECTION, "parseFloat('0X4')", 0, parseFloat("0X4")); +new TestCase( SECTION, "parseFloat('0X5')", 0, parseFloat("0X5")); +new TestCase( SECTION, "parseFloat('0X6')", 0, parseFloat("0X6")); +new TestCase( SECTION, "parseFloat('0X7')", 0, parseFloat("0X7")); +new TestCase( SECTION, "parseFloat('0X8')", 0, parseFloat("0X8")); +new TestCase( SECTION, "parseFloat('0X9')", 0, parseFloat("0X9")); +new TestCase( SECTION, "parseFloat('0Xa')", 0, parseFloat("0Xa")); +new TestCase( SECTION, "parseFloat('0Xb')", 0, parseFloat("0Xb")); +new TestCase( SECTION, "parseFloat('0Xc')", 0, parseFloat("0Xc")); +new TestCase( SECTION, "parseFloat('0Xd')", 0, parseFloat("0Xd")); +new TestCase( SECTION, "parseFloat('0Xe')", 0, parseFloat("0Xe")); +new TestCase( SECTION, "parseFloat('0Xf')", 0, parseFloat("0Xf")); +new TestCase( SECTION, "parseFloat('0XA')", 0, parseFloat("0XA")); +new TestCase( SECTION, "parseFloat('0XB')", 0, parseFloat("0XB")); +new TestCase( SECTION, "parseFloat('0XC')", 0, parseFloat("0XC")); +new TestCase( SECTION, "parseFloat('0XD')", 0, parseFloat("0XD")); +new TestCase( SECTION, "parseFloat('0XE')", 0, parseFloat("0XE")); +new TestCase( SECTION, "parseFloat('0XF')", 0, parseFloat("0XF")); +new TestCase( SECTION, "parseFloat(' 0XF ')", 0, parseFloat(" 0XF ")); + +// hex literals should still succeed + +new TestCase( SECTION, "parseFloat(0x0)", 0, parseFloat(0x0)); +new TestCase( SECTION, "parseFloat(0x1)", 1, parseFloat(0x1)); +new TestCase( SECTION, "parseFloat(0x2)", 2, parseFloat(0x2)); +new TestCase( SECTION, "parseFloat(0x3)", 3, parseFloat(0x3)); +new TestCase( SECTION, "parseFloat(0x4)", 4, parseFloat(0x4)); +new TestCase( SECTION, "parseFloat(0x5)", 5, parseFloat(0x5)); +new TestCase( SECTION, "parseFloat(0x6)", 6, parseFloat(0x6)); +new TestCase( SECTION, "parseFloat(0x7)", 7, parseFloat(0x7)); +new TestCase( SECTION, "parseFloat(0x8)", 8, parseFloat(0x8)); +new TestCase( SECTION, "parseFloat(0x9)", 9, parseFloat(0x9)); +new TestCase( SECTION, "parseFloat(0xa)", 10, parseFloat(0xa)); +new TestCase( SECTION, "parseFloat(0xb)", 11, parseFloat(0xb)); +new TestCase( SECTION, "parseFloat(0xc)", 12, parseFloat(0xc)); +new TestCase( SECTION, "parseFloat(0xd)", 13, parseFloat(0xd)); +new TestCase( SECTION, "parseFloat(0xe)", 14, parseFloat(0xe)); +new TestCase( SECTION, "parseFloat(0xf)", 15, parseFloat(0xf)); +new TestCase( SECTION, "parseFloat(0xA)", 10, parseFloat(0xA)); +new TestCase( SECTION, "parseFloat(0xB)", 11, parseFloat(0xB)); +new TestCase( SECTION, "parseFloat(0xC)", 12, parseFloat(0xC)); +new TestCase( SECTION, "parseFloat(0xD)", 13, parseFloat(0xD)); +new TestCase( SECTION, "parseFloat(0xE)", 14, parseFloat(0xE)); +new TestCase( SECTION, "parseFloat(0xF)", 15, parseFloat(0xF)); + +new TestCase( SECTION, "parseFloat(0X0)", 0, parseFloat(0X0)); +new TestCase( SECTION, "parseFloat(0X1)", 1, parseFloat(0X1)); +new TestCase( SECTION, "parseFloat(0X2)", 2, parseFloat(0X2)); +new TestCase( SECTION, "parseFloat(0X3)", 3, parseFloat(0X3)); +new TestCase( SECTION, "parseFloat(0X4)", 4, parseFloat(0X4)); +new TestCase( SECTION, "parseFloat(0X5)", 5, parseFloat(0X5)); +new TestCase( SECTION, "parseFloat(0X6)", 6, parseFloat(0X6)); +new TestCase( SECTION, "parseFloat(0X7)", 7, parseFloat(0X7)); +new TestCase( SECTION, "parseFloat(0X8)", 8, parseFloat(0X8)); +new TestCase( SECTION, "parseFloat(0X9)", 9, parseFloat(0X9)); +new TestCase( SECTION, "parseFloat(0Xa)", 10, parseFloat(0Xa)); +new TestCase( SECTION, "parseFloat(0Xb)", 11, parseFloat(0Xb)); +new TestCase( SECTION, "parseFloat(0Xc)", 12, parseFloat(0Xc)); +new TestCase( SECTION, "parseFloat(0Xd)", 13, parseFloat(0Xd)); +new TestCase( SECTION, "parseFloat(0Xe)", 14, parseFloat(0Xe)); +new TestCase( SECTION, "parseFloat(0Xf)", 15, parseFloat(0Xf)); +new TestCase( SECTION, "parseFloat(0XA)", 10, parseFloat(0XA)); +new TestCase( SECTION, "parseFloat(0XB)", 11, parseFloat(0XB)); +new TestCase( SECTION, "parseFloat(0XC)", 12, parseFloat(0XC)); +new TestCase( SECTION, "parseFloat(0XD)", 13, parseFloat(0XD)); +new TestCase( SECTION, "parseFloat(0XE)", 14, parseFloat(0XE)); +new TestCase( SECTION, "parseFloat(0XF)", 15, parseFloat(0XF)); + + +// A StringNumericLiteral may not use octal notation + +new TestCase( SECTION, "parseFloat('00')", 0, parseFloat("00")); +new TestCase( SECTION, "parseFloat('01')", 1, parseFloat("01")); +new TestCase( SECTION, "parseFloat('02')", 2, parseFloat("02")); +new TestCase( SECTION, "parseFloat('03')", 3, parseFloat("03")); +new TestCase( SECTION, "parseFloat('04')", 4, parseFloat("04")); +new TestCase( SECTION, "parseFloat('05')", 5, parseFloat("05")); +new TestCase( SECTION, "parseFloat('06')", 6, parseFloat("06")); +new TestCase( SECTION, "parseFloat('07')", 7, parseFloat("07")); +new TestCase( SECTION, "parseFloat('010')", 10, parseFloat("010")); +new TestCase( SECTION, "parseFloat('011')", 11, parseFloat("011")); + +// A StringNumericLIteral may have any number of leading 0 digits + +new TestCase( SECTION, "parseFloat('001')", 1, parseFloat("001")); +new TestCase( SECTION, "parseFloat('0001')", 1, parseFloat("0001")); +new TestCase( SECTION, "parseFloat(' 0001 ')", 1, parseFloat(" 0001 ")); + +// an octal numeric literal should be treated as an octal + +new TestCase( SECTION, "parseFloat(00)", 0, parseFloat(00)); +new TestCase( SECTION, "parseFloat(01)", 1, parseFloat(01)); +new TestCase( SECTION, "parseFloat(02)", 2, parseFloat(02)); +new TestCase( SECTION, "parseFloat(03)", 3, parseFloat(03)); +new TestCase( SECTION, "parseFloat(04)", 4, parseFloat(04)); +new TestCase( SECTION, "parseFloat(05)", 5, parseFloat(05)); +new TestCase( SECTION, "parseFloat(06)", 6, parseFloat(06)); +new TestCase( SECTION, "parseFloat(07)", 7, parseFloat(07)); +new TestCase( SECTION, "parseFloat(010)", 8, parseFloat(010)); +new TestCase( SECTION, "parseFloat(011)", 9, parseFloat(011)); + +// A StringNumericLIteral may have any number of leading 0 digits + +new TestCase( SECTION, "parseFloat(001)", 1, parseFloat(001)); +new TestCase( SECTION, "parseFloat(0001)", 1, parseFloat(0001)); + +// make sure it's reflexive +new TestCase( SECTION, "parseFloat(Math.PI)", Math.PI, parseFloat(Math.PI)); +new TestCase( SECTION, "parseFloat(Math.LN2)", Math.LN2, parseFloat(Math.LN2)); +new TestCase( SECTION, "parseFloat(Math.LN10)", Math.LN10, parseFloat(Math.LN10)); +new TestCase( SECTION, "parseFloat(Math.LOG2E)", Math.LOG2E, parseFloat(Math.LOG2E)); +new TestCase( SECTION, "parseFloat(Math.LOG10E)", Math.LOG10E, parseFloat(Math.LOG10E)); +new TestCase( SECTION, "parseFloat(Math.SQRT2)", Math.SQRT2, parseFloat(Math.SQRT2)); +new TestCase( SECTION, "parseFloat(Math.SQRT1_2)", Math.SQRT1_2, parseFloat(Math.SQRT1_2)); + +new TestCase( SECTION, "parseFloat(Math.PI+'')", Math.PI, parseFloat(Math.PI+'')); +new TestCase( SECTION, "parseFloat(Math.LN2+'')", Math.LN2, parseFloat(Math.LN2+'')); +new TestCase( SECTION, "parseFloat(Math.LN10+'')", Math.LN10, parseFloat(Math.LN10+'')); +new TestCase( SECTION, "parseFloat(Math.LOG2E+'')", Math.LOG2E, parseFloat(Math.LOG2E+'')); +new TestCase( SECTION, "parseFloat(Math.LOG10E+'')", Math.LOG10E, parseFloat(Math.LOG10E+'')); +new TestCase( SECTION, "parseFloat(Math.SQRT2+'')", Math.SQRT2, parseFloat(Math.SQRT2+'')); +new TestCase( SECTION, "parseFloat(Math.SQRT1_2+'')", Math.SQRT1_2, parseFloat(Math.SQRT1_2+'')); + +test(); diff --git a/tests/auto/qml/parserstress/tests/ecma/GlobalObject/15.1.2.3-2.js b/tests/auto/qml/parserstress/tests/ecma/GlobalObject/15.1.2.3-2.js new file mode 100644 index 0000000000..557b93f637 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/GlobalObject/15.1.2.3-2.js @@ -0,0 +1,291 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.1.2.3-2.js'; + +/** + File Name: 15.1.2.3-2.js + ECMA Section: 15.1.2.3 Function properties of the global object: + parseFloat( string ) + + Description: The parseFloat function produces a number value dictated + by the interpretation of the contents of the string + argument defined as a decimal literal. + + When the parseFloat function is called, the following + steps are taken: + + 1. Call ToString( string ). + 2. Remove leading whitespace Result(1). + 3. If neither Result(2) nor any prefix of Result(2) + satisfies the syntax of a StrDecimalLiteral, + return NaN. + 4. Compute the longest prefix of Result(2) which might + be Resusult(2) itself, that satisfies the syntax of + a StrDecimalLiteral + 5. Return the number value for the MV of Result(4). + + Note that parseFloate may interpret only a leading + portion of the string as a number value; it ignores any + characters that cannot be interpreted as part of the + notation of a decimal literal, and no indication is given + that such characters were ignored. + + StrDecimalLiteral:: + Infinity + DecimalDigits.DecimalDigits opt ExponentPart opt + .DecimalDigits ExponentPart opt + DecimalDigits ExponentPart opt + + Author: christine@netscape.com + Date: 28 october 1997 + +*/ +var SECTION = "15.1.2.3-2"; +var VERSION = "ECMA_1"; +startTest(); + +var BUGNUMBER="none"; + +new TestCase( SECTION, "parseFloat(true)", Number.NaN, parseFloat(true) ); +new TestCase( SECTION, "parseFloat(false)", Number.NaN, parseFloat(false) ); +new TestCase( SECTION, "parseFloat('string')", Number.NaN, parseFloat("string") ); + +new TestCase( SECTION, "parseFloat(' Infinity')", Number.POSITIVE_INFINITY, parseFloat("Infinity") ); +// new TestCase( SECTION, "parseFloat(Infinity)", Number.POSITIVE_INFINITY, parseFloat(Infinity) ); + +new TestCase( SECTION, "parseFloat(' 0')", 0, parseFloat(" 0") ); +new TestCase( SECTION, "parseFloat(' -0')", -0, parseFloat(" -0") ); +new TestCase( SECTION, "parseFloat(' +0')", 0, parseFloat(" +0") ); + +new TestCase( SECTION, "parseFloat(' 1')", 1, parseFloat(" 1") ); +new TestCase( SECTION, "parseFloat(' -1')", -1, parseFloat(" -1") ); +new TestCase( SECTION, "parseFloat(' +1')", 1, parseFloat(" +1") ); + +new TestCase( SECTION, "parseFloat(' 2')", 2, parseFloat(" 2") ); +new TestCase( SECTION, "parseFloat(' -2')", -2, parseFloat(" -2") ); +new TestCase( SECTION, "parseFloat(' +2')", 2, parseFloat(" +2") ); + +new TestCase( SECTION, "parseFloat(' 3')", 3, parseFloat(" 3") ); +new TestCase( SECTION, "parseFloat(' -3')", -3, parseFloat(" -3") ); +new TestCase( SECTION, "parseFloat(' +3')", 3, parseFloat(" +3") ); + +new TestCase( SECTION, "parseFloat(' 4')", 4, parseFloat(" 4") ); +new TestCase( SECTION, "parseFloat(' -4')", -4, parseFloat(" -4") ); +new TestCase( SECTION, "parseFloat(' +4')", 4, parseFloat(" +4") ); + +new TestCase( SECTION, "parseFloat(' 5')", 5, parseFloat(" 5") ); +new TestCase( SECTION, "parseFloat(' -5')", -5, parseFloat(" -5") ); +new TestCase( SECTION, "parseFloat(' +5')", 5, parseFloat(" +5") ); + +new TestCase( SECTION, "parseFloat(' 6')", 6, parseFloat(" 6") ); +new TestCase( SECTION, "parseFloat(' -6')", -6, parseFloat(" -6") ); +new TestCase( SECTION, "parseFloat(' +6')", 6, parseFloat(" +6") ); + +new TestCase( SECTION, "parseFloat(' 7')", 7, parseFloat(" 7") ); +new TestCase( SECTION, "parseFloat(' -7')", -7, parseFloat(" -7") ); +new TestCase( SECTION, "parseFloat(' +7')", 7, parseFloat(" +7") ); + +new TestCase( SECTION, "parseFloat(' 8')", 8, parseFloat(" 8") ); +new TestCase( SECTION, "parseFloat(' -8')", -8, parseFloat(" -8") ); +new TestCase( SECTION, "parseFloat(' +8')", 8, parseFloat(" +8") ); + +new TestCase( SECTION, "parseFloat(' 9')", 9, parseFloat(" 9") ); +new TestCase( SECTION, "parseFloat(' -9')", -9, parseFloat(" -9") ); +new TestCase( SECTION, "parseFloat(' +9')", 9, parseFloat(" +9") ); + +new TestCase( SECTION, "parseFloat(' 3.14159')", 3.14159, parseFloat(" 3.14159") ); +new TestCase( SECTION, "parseFloat(' -3.14159')", -3.14159, parseFloat(" -3.14159") ); +new TestCase( SECTION, "parseFloat(' +3.14159')", 3.14159, parseFloat(" +3.14159") ); + +new TestCase( SECTION, "parseFloat(' 3.')", 3, parseFloat(" 3.") ); +new TestCase( SECTION, "parseFloat(' -3.')", -3, parseFloat(" -3.") ); +new TestCase( SECTION, "parseFloat(' +3.')", 3, parseFloat(" +3.") ); + +new TestCase( SECTION, "parseFloat(' 3.e1')", 30, parseFloat(" 3.e1") ); +new TestCase( SECTION, "parseFloat(' -3.e1')", -30, parseFloat(" -3.e1") ); +new TestCase( SECTION, "parseFloat(' +3.e1')", 30, parseFloat(" +3.e1") ); + +new TestCase( SECTION, "parseFloat(' 3.e+1')", 30, parseFloat(" 3.e+1") ); +new TestCase( SECTION, "parseFloat(' -3.e+1')", -30, parseFloat(" -3.e+1") ); +new TestCase( SECTION, "parseFloat(' +3.e+1')", 30, parseFloat(" +3.e+1") ); + +new TestCase( SECTION, "parseFloat(' 3.e-1')", .30, parseFloat(" 3.e-1") ); +new TestCase( SECTION, "parseFloat(' -3.e-1')", -.30, parseFloat(" -3.e-1") ); +new TestCase( SECTION, "parseFloat(' +3.e-1')", .30, parseFloat(" +3.e-1") ); + +// StrDecimalLiteral::: .DecimalDigits ExponentPart opt + +new TestCase( SECTION, "parseFloat(' .00001')", 0.00001, parseFloat(" .00001") ); +new TestCase( SECTION, "parseFloat(' +.00001')", 0.00001, parseFloat(" +.00001") ); +new TestCase( SECTION, "parseFloat(' -0.0001')", -0.00001, parseFloat(" -.00001") ); + +new TestCase( SECTION, "parseFloat(' .01e2')", 1, parseFloat(" .01e2") ); +new TestCase( SECTION, "parseFloat(' +.01e2')", 1, parseFloat(" +.01e2") ); +new TestCase( SECTION, "parseFloat(' -.01e2')", -1, parseFloat(" -.01e2") ); + +new TestCase( SECTION, "parseFloat(' .01e+2')", 1, parseFloat(" .01e+2") ); +new TestCase( SECTION, "parseFloat(' +.01e+2')", 1, parseFloat(" +.01e+2") ); +new TestCase( SECTION, "parseFloat(' -.01e+2')", -1, parseFloat(" -.01e+2") ); + +new TestCase( SECTION, "parseFloat(' .01e-2')", 0.0001, parseFloat(" .01e-2") ); +new TestCase( SECTION, "parseFloat(' +.01e-2')", 0.0001, parseFloat(" +.01e-2") ); +new TestCase( SECTION, "parseFloat(' -.01e-2')", -0.0001, parseFloat(" -.01e-2") ); + +// StrDecimalLiteral::: DecimalDigits ExponentPart opt + +new TestCase( SECTION, "parseFloat(' 1234e5')", 123400000, parseFloat(" 1234e5") ); +new TestCase( SECTION, "parseFloat(' +1234e5')", 123400000, parseFloat(" +1234e5") ); +new TestCase( SECTION, "parseFloat(' -1234e5')", -123400000, parseFloat(" -1234e5") ); + +new TestCase( SECTION, "parseFloat(' 1234e+5')", 123400000, parseFloat(" 1234e+5") ); +new TestCase( SECTION, "parseFloat(' +1234e+5')", 123400000, parseFloat(" +1234e+5") ); +new TestCase( SECTION, "parseFloat(' -1234e+5')", -123400000, parseFloat(" -1234e+5") ); + +new TestCase( SECTION, "parseFloat(' 1234e-5')", 0.01234, parseFloat(" 1234e-5") ); +new TestCase( SECTION, "parseFloat(' +1234e-5')", 0.01234, parseFloat(" +1234e-5") ); +new TestCase( SECTION, "parseFloat(' -1234e-5')", -0.01234, parseFloat(" -1234e-5") ); + + +new TestCase( SECTION, "parseFloat(' .01E2')", 1, parseFloat(" .01E2") ); +new TestCase( SECTION, "parseFloat(' +.01E2')", 1, parseFloat(" +.01E2") ); +new TestCase( SECTION, "parseFloat(' -.01E2')", -1, parseFloat(" -.01E2") ); + +new TestCase( SECTION, "parseFloat(' .01E+2')", 1, parseFloat(" .01E+2") ); +new TestCase( SECTION, "parseFloat(' +.01E+2')", 1, parseFloat(" +.01E+2") ); +new TestCase( SECTION, "parseFloat(' -.01E+2')", -1, parseFloat(" -.01E+2") ); + +new TestCase( SECTION, "parseFloat(' .01E-2')", 0.0001, parseFloat(" .01E-2") ); +new TestCase( SECTION, "parseFloat(' +.01E-2')", 0.0001, parseFloat(" +.01E-2") ); +new TestCase( SECTION, "parseFloat(' -.01E-2')", -0.0001, parseFloat(" -.01E-2") ); + +// StrDecimalLiteral::: DecimalDigits ExponentPart opt +new TestCase( SECTION, "parseFloat(' 1234E5')", 123400000, parseFloat(" 1234E5") ); +new TestCase( SECTION, "parseFloat(' +1234E5')", 123400000, parseFloat(" +1234E5") ); +new TestCase( SECTION, "parseFloat(' -1234E5')", -123400000, parseFloat(" -1234E5") ); + +new TestCase( SECTION, "parseFloat(' 1234E+5')", 123400000, parseFloat(" 1234E+5") ); +new TestCase( SECTION, "parseFloat(' +1234E+5')", 123400000, parseFloat(" +1234E+5") ); +new TestCase( SECTION, "parseFloat(' -1234E+5')", -123400000, parseFloat(" -1234E+5") ); + +new TestCase( SECTION, "parseFloat(' 1234E-5')", 0.01234, parseFloat(" 1234E-5") ); +new TestCase( SECTION, "parseFloat(' +1234E-5')", 0.01234, parseFloat(" +1234E-5") ); +new TestCase( SECTION, "parseFloat(' -1234E-5')", -0.01234, parseFloat(" -1234E-5") ); + + +// hex cases should all return NaN + +new TestCase( SECTION, "parseFloat(' 0x0')", 0, parseFloat(" 0x0")); +new TestCase( SECTION, "parseFloat(' 0x1')", 0, parseFloat(" 0x1")); +new TestCase( SECTION, "parseFloat(' 0x2')", 0, parseFloat(" 0x2")); +new TestCase( SECTION, "parseFloat(' 0x3')", 0, parseFloat(" 0x3")); +new TestCase( SECTION, "parseFloat(' 0x4')", 0, parseFloat(" 0x4")); +new TestCase( SECTION, "parseFloat(' 0x5')", 0, parseFloat(" 0x5")); +new TestCase( SECTION, "parseFloat(' 0x6')", 0, parseFloat(" 0x6")); +new TestCase( SECTION, "parseFloat(' 0x7')", 0, parseFloat(" 0x7")); +new TestCase( SECTION, "parseFloat(' 0x8')", 0, parseFloat(" 0x8")); +new TestCase( SECTION, "parseFloat(' 0x9')", 0, parseFloat(" 0x9")); +new TestCase( SECTION, "parseFloat(' 0xa')", 0, parseFloat(" 0xa")); +new TestCase( SECTION, "parseFloat(' 0xb')", 0, parseFloat(" 0xb")); +new TestCase( SECTION, "parseFloat(' 0xc')", 0, parseFloat(" 0xc")); +new TestCase( SECTION, "parseFloat(' 0xd')", 0, parseFloat(" 0xd")); +new TestCase( SECTION, "parseFloat(' 0xe')", 0, parseFloat(" 0xe")); +new TestCase( SECTION, "parseFloat(' 0xf')", 0, parseFloat(" 0xf")); +new TestCase( SECTION, "parseFloat(' 0xA')", 0, parseFloat(" 0xA")); +new TestCase( SECTION, "parseFloat(' 0xB')", 0, parseFloat(" 0xB")); +new TestCase( SECTION, "parseFloat(' 0xC')", 0, parseFloat(" 0xC")); +new TestCase( SECTION, "parseFloat(' 0xD')", 0, parseFloat(" 0xD")); +new TestCase( SECTION, "parseFloat(' 0xE')", 0, parseFloat(" 0xE")); +new TestCase( SECTION, "parseFloat(' 0xF')", 0, parseFloat(" 0xF")); + +new TestCase( SECTION, "parseFloat(' 0X0')", 0, parseFloat(" 0X0")); +new TestCase( SECTION, "parseFloat(' 0X1')", 0, parseFloat(" 0X1")); +new TestCase( SECTION, "parseFloat(' 0X2')", 0, parseFloat(" 0X2")); +new TestCase( SECTION, "parseFloat(' 0X3')", 0, parseFloat(" 0X3")); +new TestCase( SECTION, "parseFloat(' 0X4')", 0, parseFloat(" 0X4")); +new TestCase( SECTION, "parseFloat(' 0X5')", 0, parseFloat(" 0X5")); +new TestCase( SECTION, "parseFloat(' 0X6')", 0, parseFloat(" 0X6")); +new TestCase( SECTION, "parseFloat(' 0X7')", 0, parseFloat(" 0X7")); +new TestCase( SECTION, "parseFloat(' 0X8')", 0, parseFloat(" 0X8")); +new TestCase( SECTION, "parseFloat(' 0X9')", 0, parseFloat(" 0X9")); +new TestCase( SECTION, "parseFloat(' 0Xa')", 0, parseFloat(" 0Xa")); +new TestCase( SECTION, "parseFloat(' 0Xb')", 0, parseFloat(" 0Xb")); +new TestCase( SECTION, "parseFloat(' 0Xc')", 0, parseFloat(" 0Xc")); +new TestCase( SECTION, "parseFloat(' 0Xd')", 0, parseFloat(" 0Xd")); +new TestCase( SECTION, "parseFloat(' 0Xe')", 0, parseFloat(" 0Xe")); +new TestCase( SECTION, "parseFloat(' 0Xf')", 0, parseFloat(" 0Xf")); +new TestCase( SECTION, "parseFloat(' 0XA')", 0, parseFloat(" 0XA")); +new TestCase( SECTION, "parseFloat(' 0XB')", 0, parseFloat(" 0XB")); +new TestCase( SECTION, "parseFloat(' 0XC')", 0, parseFloat(" 0XC")); +new TestCase( SECTION, "parseFloat(' 0XD')", 0, parseFloat(" 0XD")); +new TestCase( SECTION, "parseFloat(' 0XE')", 0, parseFloat(" 0XE")); +new TestCase( SECTION, "parseFloat(' 0XF')", 0, parseFloat(" 0XF")); + +// A StringNumericLiteral may not use octal notation + +new TestCase( SECTION, "parseFloat(' 00')", 0, parseFloat(" 00")); +new TestCase( SECTION, "parseFloat(' 01')", 1, parseFloat(" 01")); +new TestCase( SECTION, "parseFloat(' 02')", 2, parseFloat(" 02")); +new TestCase( SECTION, "parseFloat(' 03')", 3, parseFloat(" 03")); +new TestCase( SECTION, "parseFloat(' 04')", 4, parseFloat(" 04")); +new TestCase( SECTION, "parseFloat(' 05')", 5, parseFloat(" 05")); +new TestCase( SECTION, "parseFloat(' 06')", 6, parseFloat(" 06")); +new TestCase( SECTION, "parseFloat(' 07')", 7, parseFloat(" 07")); +new TestCase( SECTION, "parseFloat(' 010')", 10, parseFloat(" 010")); +new TestCase( SECTION, "parseFloat(' 011')", 11, parseFloat(" 011")); + +// A StringNumericLIteral may have any number of leading 0 digits + +new TestCase( SECTION, "parseFloat(' 001')", 1, parseFloat(" 001")); +new TestCase( SECTION, "parseFloat(' 0001')", 1, parseFloat(" 0001")); + +// A StringNumericLIteral may have any number of leading 0 digits + +new TestCase( SECTION, "parseFloat(001)", 1, parseFloat(001)); +new TestCase( SECTION, "parseFloat(0001)", 1, parseFloat(0001)); + +// make sure it' s reflexive +new TestCase( SECTION, "parseFloat( ' ' +Math.PI+' ')", Math.PI, parseFloat( ' ' +Math.PI+' ')); +new TestCase( SECTION, "parseFloat( ' ' +Math.LN2+' ')", Math.LN2, parseFloat( ' ' +Math.LN2+' ')); +new TestCase( SECTION, "parseFloat( ' ' +Math.LN10+' ')", Math.LN10, parseFloat( ' ' +Math.LN10+' ')); +new TestCase( SECTION, "parseFloat( ' ' +Math.LOG2E+' ')", Math.LOG2E, parseFloat( ' ' +Math.LOG2E+' ')); +new TestCase( SECTION, "parseFloat( ' ' +Math.LOG10E+' ')", Math.LOG10E, parseFloat( ' ' +Math.LOG10E+' ')); +new TestCase( SECTION, "parseFloat( ' ' +Math.SQRT2+' ')", Math.SQRT2, parseFloat( ' ' +Math.SQRT2+' ')); +new TestCase( SECTION, "parseFloat( ' ' +Math.SQRT1_2+' ')", Math.SQRT1_2, parseFloat( ' ' +Math.SQRT1_2+' ')); + +test(); diff --git a/tests/auto/qml/parserstress/tests/ecma/GlobalObject/15.1.2.4.js b/tests/auto/qml/parserstress/tests/ecma/GlobalObject/15.1.2.4.js new file mode 100644 index 0000000000..bd2114a1a9 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/GlobalObject/15.1.2.4.js @@ -0,0 +1,205 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.1.2.4.js'; + +/** + File Name: 15.1.2.4.js + ECMA Section: 15.1.2.4 Function properties of the global object + escape( string ) + + Description: + The escape function computes a new version of a string value in which + certain characters have been replaced by a hexadecimal escape sequence. + The result thus contains no special characters that might have special + meaning within a URL. + + For characters whose Unicode encoding is 0xFF or less, a two-digit + escape sequence of the form %xx is used in accordance with RFC1738. + For characters whose Unicode encoding is greater than 0xFF, a four- + digit escape sequence of the form %uxxxx is used. + + When the escape function is called with one argument string, the + following steps are taken: + + 1. Call ToString(string). + 2. Compute the number of characters in Result(1). + 3. Let R be the empty string. + 4. Let k be 0. + 5. If k equals Result(2), return R. + 6. Get the character at position k within Result(1). + 7. If Result(6) is one of the 69 nonblank ASCII characters + ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz + 0123456789 @*_+-./, go to step 14. + 8. Compute the 16-bit unsigned integer that is the Unicode character + encoding of Result(6). + 9. If Result(8), is less than 256, go to step 12. + 10. Let S be a string containing six characters "%uwxyz" where wxyz are + four hexadecimal digits encoding the value of Result(8). + 11. Go to step 15. + 12. Let S be a string containing three characters "%xy" where xy are two + hexadecimal digits encoding the value of Result(8). + 13. Go to step 15. + 14. Let S be a string containing the single character Result(6). + 15. Let R be a new string value computed by concatenating the previous value + of R and S. + 16. Increase k by 1. + 17. Go to step 5. + + Author: christine@netscape.com + Date: 28 october 1997 + +*/ +var SECTION = "15.1.2.4"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "escape(string)"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +new TestCase( SECTION, "escape.length", 1, escape.length ); +new TestCase( SECTION, "escape.length = null; escape.length", 1, eval("escape.length = null; escape.length") ); +new TestCase( SECTION, "delete escape.length", false, delete escape.length ); +new TestCase( SECTION, "delete escape.length; escape.length", 1, eval("delete escape.length; escape.length") ); +new TestCase( SECTION, "var MYPROPS=''; for ( var p in escape ) { MYPROPS+= p}; MYPROPS", "prototype", eval("var MYPROPS=''; for ( var p in escape ) { MYPROPS+= p}; MYPROPS") ); + +new TestCase( SECTION, "escape()", "undefined", escape() ); +new TestCase( SECTION, "escape('')", "", escape('') ); +new TestCase( SECTION, "escape( null )", "null", escape(null) ); +new TestCase( SECTION, "escape( void 0 )", "undefined", escape(void 0) ); +new TestCase( SECTION, "escape( true )", "true", escape( true ) ); +new TestCase( SECTION, "escape( false )", "false", escape( false ) ); + +new TestCase( SECTION, "escape( new Boolean(true) )", "true", escape(new Boolean(true)) ); +new TestCase( SECTION, "escape( new Boolean(false) )", "false", escape(new Boolean(false)) ); + +new TestCase( SECTION, "escape( Number.NaN )", "NaN", escape(Number.NaN) ); +new TestCase( SECTION, "escape( -0 )", "0", escape( -0 ) ); +new TestCase( SECTION, "escape( 'Infinity' )", "Infinity", escape( "Infinity" ) ); +new TestCase( SECTION, "escape( Number.POSITIVE_INFINITY )", "Infinity", escape( Number.POSITIVE_INFINITY ) ); +new TestCase( SECTION, "escape( Number.NEGATIVE_INFINITY )", "-Infinity", escape( Number.NEGATIVE_INFINITY ) ); + +var ASCII_TEST_STRING = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789@*_+-./"; + +new TestCase( SECTION, "escape( " +ASCII_TEST_STRING+" )", ASCII_TEST_STRING, escape( ASCII_TEST_STRING ) ); + +// ASCII value less than + +for ( var CHARCODE = 0; CHARCODE < 32; CHARCODE++ ) { + new TestCase( SECTION, + "escape(String.fromCharCode("+CHARCODE+"))", + "%"+ToHexString(CHARCODE), + escape(String.fromCharCode(CHARCODE)) ); +} +for ( var CHARCODE = 128; CHARCODE < 256; CHARCODE++ ) { + new TestCase( SECTION, + "escape(String.fromCharCode("+CHARCODE+"))", + "%"+ToHexString(CHARCODE), + escape(String.fromCharCode(CHARCODE)) ); +} + +for ( var CHARCODE = 256; CHARCODE < 1024; CHARCODE++ ) { + new TestCase( SECTION, + "escape(String.fromCharCode("+CHARCODE+"))", + "%u"+ ToUnicodeString(CHARCODE), + escape(String.fromCharCode(CHARCODE)) ); +} +for ( var CHARCODE = 65500; CHARCODE < 65536; CHARCODE++ ) { + new TestCase( SECTION, + "escape(String.fromCharCode("+CHARCODE+"))", + "%u"+ ToUnicodeString(CHARCODE), + escape(String.fromCharCode(CHARCODE)) ); +} + +test(); + +function ToUnicodeString( n ) { + var string = ToHexString(n); + + for ( var PAD = (4 - string.length ); PAD > 0; PAD-- ) { + string = "0" + string; + } + + return string; +} +function ToHexString( n ) { + var hex = new Array(); + + for ( var mag = 1; Math.pow(16,mag) <= n ; mag++ ) { + ; + } + + for ( index = 0, mag -= 1; mag > 0; index++, mag-- ) { + hex[index] = Math.floor( n / Math.pow(16,mag) ); + n -= Math.pow(16,mag) * Math.floor( n/Math.pow(16,mag) ); + } + + hex[hex.length] = n % 16; + + var string =""; + + for ( var index = 0 ; index < hex.length ; index++ ) { + switch ( hex[index] ) { + case 10: + string += "A"; + break; + case 11: + string += "B"; + break; + case 12: + string += "C"; + break; + case 13: + string += "D"; + break; + case 14: + string += "E"; + break; + case 15: + string += "F"; + break; + default: + string += hex[index]; + } + } + + if ( string.length == 1 ) { + string = "0" + string; + } + return string; +} diff --git a/tests/auto/qml/parserstress/tests/ecma/GlobalObject/15.1.2.5-1.js b/tests/auto/qml/parserstress/tests/ecma/GlobalObject/15.1.2.5-1.js new file mode 100644 index 0000000000..b7b072a627 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/GlobalObject/15.1.2.5-1.js @@ -0,0 +1,206 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.1.2.5-1.js'; + +/** + File Name: 15.1.2.5-1.js + ECMA Section: 15.1.2.5 Function properties of the global object + unescape( string ) + + Description: + The unescape function computes a new version of a string value in which + each escape sequences of the sort that might be introduced by the escape + function is replaced with the character that it represents. + + When the unescape function is called with one argument string, the + following steps are taken: + + 1. Call ToString(string). + 2. Compute the number of characters in Result(1). + 3. Let R be the empty string. + 4. Let k be 0. + 5. If k equals Result(2), return R. + 6. Let c be the character at position k within Result(1). + 7. If c is not %, go to step 18. + 8. If k is greater than Result(2)-6, go to step 14. + 9. If the character at position k+1 within result(1) is not u, go to step + 14. + 10. If the four characters at positions k+2, k+3, k+4, and k+5 within + Result(1) are not all hexadecimal digits, go to step 14. + 11. Let c be the character whose Unicode encoding is the integer represented + by the four hexadecimal digits at positions k+2, k+3, k+4, and k+5 + within Result(1). + 12. Increase k by 5. + 13. Go to step 18. + 14. If k is greater than Result(2)-3, go to step 18. + 15. If the two characters at positions k+1 and k+2 within Result(1) are not + both hexadecimal digits, go to step 18. + 16. Let c be the character whose Unicode encoding is the integer represented + by two zeroes plus the two hexadecimal digits at positions k+1 and k+2 + within Result(1). + 17. Increase k by 2. + 18. Let R be a new string value computed by concatenating the previous value + of R and c. + 19. Increase k by 1. + 20. Go to step 5. + Author: christine@netscape.com + Date: 28 october 1997 +*/ + +var SECTION = "15.1.2.5-1"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "unescape(string)"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +new TestCase( SECTION, "unescape.length", 1, unescape.length ); +new TestCase( SECTION, "unescape.length = null; unescape.length", 1, eval("unescape.length=null; unescape.length") ); +new TestCase( SECTION, "delete unescape.length", false, delete unescape.length ); +new TestCase( SECTION, "delete unescape.length; unescape.length", 1, eval("delete unescape.length; unescape.length") ); +new TestCase( SECTION, "var MYPROPS=''; for ( var p in unescape ) { MYPROPS+= p }; MYPROPS", "prototype", eval("var MYPROPS=''; for ( var p in unescape ) { MYPROPS+= p }; MYPROPS") ); + +new TestCase( SECTION, "unescape()", "undefined", unescape() ); +new TestCase( SECTION, "unescape('')", "", unescape('') ); +new TestCase( SECTION, "unescape( null )", "null", unescape(null) ); +new TestCase( SECTION, "unescape( void 0 )", "undefined", unescape(void 0) ); +new TestCase( SECTION, "unescape( true )", "true", unescape( true ) ); +new TestCase( SECTION, "unescape( false )", "false", unescape( false ) ); + +new TestCase( SECTION, "unescape( new Boolean(true) )", "true", unescape(new Boolean(true)) ); +new TestCase( SECTION, "unescape( new Boolean(false) )", "false", unescape(new Boolean(false)) ); + +new TestCase( SECTION, "unescape( Number.NaN )", "NaN", unescape(Number.NaN) ); +new TestCase( SECTION, "unescape( -0 )", "0", unescape( -0 ) ); +new TestCase( SECTION, "unescape( 'Infinity' )", "Infinity", unescape( "Infinity" ) ); +new TestCase( SECTION, "unescape( Number.POSITIVE_INFINITY )", "Infinity", unescape( Number.POSITIVE_INFINITY ) ); +new TestCase( SECTION, "unescape( Number.NEGATIVE_INFINITY )", "-Infinity", unescape( Number.NEGATIVE_INFINITY ) ); + +var ASCII_TEST_STRING = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789@*_+-./"; + +new TestCase( SECTION, "unescape( " +ASCII_TEST_STRING+" )", ASCII_TEST_STRING, unescape( ASCII_TEST_STRING ) ); + +// escaped chars with ascii values less than 256 + +for ( var CHARCODE = 0; CHARCODE < 256; CHARCODE++ ) { + new TestCase( SECTION, + "unescape( %"+ ToHexString(CHARCODE)+" )", + String.fromCharCode(CHARCODE), + unescape( "%" + ToHexString(CHARCODE) ) ); +} + +// unicode chars represented by two hex digits +for ( var CHARCODE = 0; CHARCODE < 256; CHARCODE++ ) { + new TestCase( SECTION, + "unescape( %u"+ ToHexString(CHARCODE)+" )", + "%u"+ToHexString(CHARCODE), + unescape( "%u" + ToHexString(CHARCODE) ) ); +} +/* + for ( var CHARCODE = 0; CHARCODE < 256; CHARCODE++ ) { + new TestCase( SECTION, + "unescape( %u"+ ToUnicodeString(CHARCODE)+" )", + String.fromCharCode(CHARCODE), + unescape( "%u" + ToUnicodeString(CHARCODE) ) ); + } + for ( var CHARCODE = 256; CHARCODE < 65536; CHARCODE+= 333 ) { + new TestCase( SECTION, + "unescape( %u"+ ToUnicodeString(CHARCODE)+" )", + String.fromCharCode(CHARCODE), + unescape( "%u" + ToUnicodeString(CHARCODE) ) ); + } +*/ + +test(); + +function ToUnicodeString( n ) { + var string = ToHexString(n); + + for ( var PAD = (4 - string.length ); PAD > 0; PAD-- ) { + string = "0" + string; + } + + return string; +} +function ToHexString( n ) { + var hex = new Array(); + + for ( var mag = 1; Math.pow(16,mag) <= n ; mag++ ) { + ; + } + + for ( index = 0, mag -= 1; mag > 0; index++, mag-- ) { + hex[index] = Math.floor( n / Math.pow(16,mag) ); + n -= Math.pow(16,mag) * Math.floor( n/Math.pow(16,mag) ); + } + + hex[hex.length] = n % 16; + + var string =""; + + for ( var index = 0 ; index < hex.length ; index++ ) { + switch ( hex[index] ) { + case 10: + string += "A"; + break; + case 11: + string += "B"; + break; + case 12: + string += "C"; + break; + case 13: + string += "D"; + break; + case 14: + string += "E"; + break; + case 15: + string += "F"; + break; + default: + string += hex[index]; + } + } + + if ( string.length == 1 ) { + string = "0" + string; + } + return string; +} diff --git a/tests/auto/qml/parserstress/tests/ecma/GlobalObject/15.1.2.5-2.js b/tests/auto/qml/parserstress/tests/ecma/GlobalObject/15.1.2.5-2.js new file mode 100644 index 0000000000..99b58752b2 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/GlobalObject/15.1.2.5-2.js @@ -0,0 +1,183 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.1.2.5-2.js'; + +/** + File Name: 15.1.2.5-2.js + ECMA Section: 15.1.2.5 Function properties of the global object + unescape( string ) + Description: + + This tests the cases where there are fewer than 4 characters following "%u", + or fewer than 2 characters following "%" or "%u". + + The unescape function computes a new version of a string value in which + each escape sequences of the sort that might be introduced by the escape + function is replaced with the character that it represents. + + When the unescape function is called with one argument string, the + following steps are taken: + + 1. Call ToString(string). + 2. Compute the number of characters in Result(1). + 3. Let R be the empty string. + 4. Let k be 0. + 5. If k equals Result(2), return R. + 6. Let c be the character at position k within Result(1). + 7. If c is not %, go to step 18. + 8. If k is greater than Result(2)-6, go to step 14. + 9. If the character at position k+1 within result(1) is not u, go to step + 14. + 10. If the four characters at positions k+2, k+3, k+4, and k+5 within + Result(1) are not all hexadecimal digits, go to step 14. + 11. Let c be the character whose Unicode encoding is the integer represented + by the four hexadecimal digits at positions k+2, k+3, k+4, and k+5 + within Result(1). + 12. Increase k by 5. + 13. Go to step 18. + 14. If k is greater than Result(2)-3, go to step 18. + 15. If the two characters at positions k+1 and k+2 within Result(1) are not + both hexadecimal digits, go to step 18. + 16. Let c be the character whose Unicode encoding is the integer represented + by two zeroes plus the two hexadecimal digits at positions k+1 and k+2 + within Result(1). + 17. Increase k by 2. + 18. Let R be a new string value computed by concatenating the previous value + of R and c. + 19. Increase k by 1. + 20. Go to step 5. + Author: christine@netscape.com + Date: 28 october 1997 +*/ + +var SECTION = "15.1.2.5-2"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "unescape(string)"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +// since there is only one character following "%", no conversion should occur. + +for ( var CHARCODE = 0; CHARCODE < 256; CHARCODE += 16 ) { + new TestCase( SECTION, + "unescape( %"+ (ToHexString(CHARCODE)).substring(0,1) +" )", + "%"+(ToHexString(CHARCODE)).substring(0,1), + unescape( "%" + (ToHexString(CHARCODE)).substring(0,1) ) ); +} + +// since there is only one character following "%u", no conversion should occur. + +for ( var CHARCODE = 0; CHARCODE < 256; CHARCODE +=16 ) { + new TestCase( SECTION, + "unescape( %u"+ (ToHexString(CHARCODE)).substring(0,1) +" )", + "%u"+(ToHexString(CHARCODE)).substring(0,1), + unescape( "%u" + (ToHexString(CHARCODE)).substring(0,1) ) ); +} + + +// three char unicode string. no conversion should occur + +for ( var CHARCODE = 1024; CHARCODE < 65536; CHARCODE+= 1234 ) { + new TestCase + ( SECTION, + "unescape( %u"+ (ToUnicodeString(CHARCODE)).substring(0,3)+ " )", + + "%u"+(ToUnicodeString(CHARCODE)).substring(0,3), + unescape( "%u"+(ToUnicodeString(CHARCODE)).substring(0,3) ) + ); +} + +test(); + +function ToUnicodeString( n ) { + var string = ToHexString(n); + + for ( var PAD = (4 - string.length ); PAD > 0; PAD-- ) { + string = "0" + string; + } + + return string; +} +function ToHexString( n ) { + var hex = new Array(); + + for ( var mag = 1; Math.pow(16,mag) <= n ; mag++ ) { + ; + } + + for ( index = 0, mag -= 1; mag > 0; index++, mag-- ) { + hex[index] = Math.floor( n / Math.pow(16,mag) ); + n -= Math.pow(16,mag) * Math.floor( n/Math.pow(16,mag) ); + } + + hex[hex.length] = n % 16; + + var string =""; + + for ( var index = 0 ; index < hex.length ; index++ ) { + switch ( hex[index] ) { + case 10: + string += "A"; + break; + case 11: + string += "B"; + break; + case 12: + string += "C"; + break; + case 13: + string += "D"; + break; + case 14: + string += "E"; + break; + case 15: + string += "F"; + break; + default: + string += hex[index]; + } + } + + if ( string.length == 1 ) { + string = "0" + string; + } + return string; +} diff --git a/tests/auto/qml/parserstress/tests/ecma/GlobalObject/15.1.2.5-3.js b/tests/auto/qml/parserstress/tests/ecma/GlobalObject/15.1.2.5-3.js new file mode 100644 index 0000000000..2615d62531 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/GlobalObject/15.1.2.5-3.js @@ -0,0 +1,207 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.1.2.5-3.js'; + +/** + File Name: 15.1.2.5-3.js + ECMA Section: 15.1.2.5 Function properties of the global object + unescape( string ) + + Description: + This tests the cases where one of the four characters following "%u" is + not a hexidecimal character, or one of the two characters following "%" + or "%u" is not a hexidecimal character. + + The unescape function computes a new version of a string value in which + each escape sequences of the sort that might be introduced by the escape + function is replaced with the character that it represents. + + When the unescape function is called with one argument string, the + following steps are taken: + + 1. Call ToString(string). + 2. Compute the number of characters in Result(1). + 3. Let R be the empty string. + 4. Let k be 0. + 5. If k equals Result(2), return R. + 6. Let c be the character at position k within Result(1). + 7. If c is not %, go to step 18. + 8. If k is greater than Result(2)-6, go to step 14. + 9. If the character at position k+1 within result(1) is not u, go to step + 14. + 10. If the four characters at positions k+2, k+3, k+4, and k+5 within + Result(1) are not all hexadecimal digits, go to step 14. + 11. Let c be the character whose Unicode encoding is the integer represented + by the four hexadecimal digits at positions k+2, k+3, k+4, and k+5 + within Result(1). + 12. Increase k by 5. + 13. Go to step 18. + 14. If k is greater than Result(2)-3, go to step 18. + 15. If the two characters at positions k+1 and k+2 within Result(1) are not + both hexadecimal digits, go to step 18. + 16. Let c be the character whose Unicode encoding is the integer represented + by two zeroes plus the two hexadecimal digits at positions k+1 and k+2 + within Result(1). + 17. Increase k by 2. + 18. Let R be a new string value computed by concatenating the previous value + of R and c. + 19. Increase k by 1. + 20. Go to step 5. + Author: christine@netscape.com + Date: 28 october 1997 +*/ + + +var SECTION = "15.1.2.5-3"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "unescape(string)"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +for ( var CHARCODE = 0, NONHEXCHARCODE = 0; CHARCODE < 256; CHARCODE++, NONHEXCHARCODE++ ) { + NONHEXCHARCODE = getNextNonHexCharCode( NONHEXCHARCODE ); + + new TestCase( SECTION, + "unescape( %"+ (ToHexString(CHARCODE)).substring(0,1) + + String.fromCharCode( NONHEXCHARCODE ) +" )" + + "[where last character is String.fromCharCode("+NONHEXCHARCODE+")]", + "%"+(ToHexString(CHARCODE)).substring(0,1)+ + String.fromCharCode( NONHEXCHARCODE ), + unescape( "%" + (ToHexString(CHARCODE)).substring(0,1)+ + String.fromCharCode( NONHEXCHARCODE ) ) ); +} +for ( var CHARCODE = 0, NONHEXCHARCODE = 0; CHARCODE < 256; CHARCODE++, NONHEXCHARCODE++ ) { + NONHEXCHARCODE = getNextNonHexCharCode( NONHEXCHARCODE ); + + new TestCase( SECTION, + "unescape( %u"+ (ToHexString(CHARCODE)).substring(0,1) + + String.fromCharCode( NONHEXCHARCODE ) +" )" + + "[where last character is String.fromCharCode("+NONHEXCHARCODE+")]", + "%u"+(ToHexString(CHARCODE)).substring(0,1)+ + String.fromCharCode( NONHEXCHARCODE ), + unescape( "%u" + (ToHexString(CHARCODE)).substring(0,1)+ + String.fromCharCode( NONHEXCHARCODE ) ) ); +} + +for ( var CHARCODE = 0, NONHEXCHARCODE = 0 ; CHARCODE < 65536; CHARCODE+= 54321, NONHEXCHARCODE++ ) { + NONHEXCHARCODE = getNextNonHexCharCode( NONHEXCHARCODE ); + + new TestCase( SECTION, + "unescape( %u"+ (ToUnicodeString(CHARCODE)).substring(0,3) + + String.fromCharCode( NONHEXCHARCODE ) +" )" + + "[where last character is String.fromCharCode("+NONHEXCHARCODE+")]", + + String.fromCharCode(eval("0x"+ (ToUnicodeString(CHARCODE)).substring(0,2))) + + (ToUnicodeString(CHARCODE)).substring(2,3) + + String.fromCharCode( NONHEXCHARCODE ), + + unescape( "%" + (ToUnicodeString(CHARCODE)).substring(0,3)+ + String.fromCharCode( NONHEXCHARCODE ) ) ); +} + +test(); + +function getNextNonHexCharCode( n ) { + for ( ; n < Math.pow(2,16); n++ ) { + if ( ( n == 43 || n == 45 || n == 46 || n == 47 || + (n >= 71 && n <= 90) || (n >= 103 && n <= 122) || + n == 64 || n == 95 ) ) { + break; + } else { + n = ( n > 122 ) ? 0 : n; + } + } + return n; +} +function ToUnicodeString( n ) { + var string = ToHexString(n); + + for ( var PAD = (4 - string.length ); PAD > 0; PAD-- ) { + string = "0" + string; + } + + return string; +} +function ToHexString( n ) { + var hex = new Array(); + + for ( var mag = 1; Math.pow(16,mag) <= n ; mag++ ) { + ; + } + + for ( index = 0, mag -= 1; mag > 0; index++, mag-- ) { + hex[index] = Math.floor( n / Math.pow(16,mag) ); + n -= Math.pow(16,mag) * Math.floor( n/Math.pow(16,mag) ); + } + + hex[hex.length] = n % 16; + + var string =""; + + for ( var index = 0 ; index < hex.length ; index++ ) { + switch ( hex[index] ) { + case 10: + string += "A"; + break; + case 11: + string += "B"; + break; + case 12: + string += "C"; + break; + case 13: + string += "D"; + break; + case 14: + string += "E"; + break; + case 15: + string += "F"; + break; + default: + string += hex[index]; + } + } + + if ( string.length == 1 ) { + string = "0" + string; + } + return string; +} diff --git a/tests/auto/qml/parserstress/tests/ecma/GlobalObject/15.1.2.6.js b/tests/auto/qml/parserstress/tests/ecma/GlobalObject/15.1.2.6.js new file mode 100644 index 0000000000..faeeb9e0b0 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/GlobalObject/15.1.2.6.js @@ -0,0 +1,125 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.1.2.6.js'; + +/** + File Name: 15.1.2.6.js + ECMA Section: 15.1.2.6 isNaN( x ) + + Description: Applies ToNumber to its argument, then returns true if + the result isNaN and otherwise returns false. + + Author: christine@netscape.com + Date: 28 october 1997 + +*/ +var SECTION = "15.1.2.6"; +var VERSION = "ECMA_1"; +var TITLE = "isNaN( x )"; +var BUGNUMBER = "none"; + +startTest(); + +writeHeaderToLog( SECTION + " "+ TITLE); + +new TestCase( SECTION, "isNaN.length", 1, isNaN.length ); +new TestCase( SECTION, "var MYPROPS=''; for ( var p in isNaN ) { MYPROPS+= p }; MYPROPS", "prototype", eval("var MYPROPS=''; for ( var p in isNaN ) { MYPROPS+= p }; MYPROPS") ); +new TestCase( SECTION, "isNaN.length = null; isNaN.length", 1, eval("isNaN.length=null; isNaN.length") ); +new TestCase( SECTION, "delete isNaN.length", false, delete isNaN.length ); +new TestCase( SECTION, "delete isNaN.length; isNaN.length", 1, eval("delete isNaN.length; isNaN.length") ); + +// new TestCase( SECTION, "isNaN.__proto__", Function.prototype, isNaN.__proto__ ); + +new TestCase( SECTION, "isNaN()", true, isNaN() ); +new TestCase( SECTION, "isNaN( null )", false, isNaN(null) ); +new TestCase( SECTION, "isNaN( void 0 )", true, isNaN(void 0) ); +new TestCase( SECTION, "isNaN( true )", false, isNaN(true) ); +new TestCase( SECTION, "isNaN( false)", false, isNaN(false) ); +new TestCase( SECTION, "isNaN( ' ' )", false, isNaN( " " ) ); + +new TestCase( SECTION, "isNaN( 0 )", false, isNaN(0) ); +new TestCase( SECTION, "isNaN( 1 )", false, isNaN(1) ); +new TestCase( SECTION, "isNaN( 2 )", false, isNaN(2) ); +new TestCase( SECTION, "isNaN( 3 )", false, isNaN(3) ); +new TestCase( SECTION, "isNaN( 4 )", false, isNaN(4) ); +new TestCase( SECTION, "isNaN( 5 )", false, isNaN(5) ); +new TestCase( SECTION, "isNaN( 6 )", false, isNaN(6) ); +new TestCase( SECTION, "isNaN( 7 )", false, isNaN(7) ); +new TestCase( SECTION, "isNaN( 8 )", false, isNaN(8) ); +new TestCase( SECTION, "isNaN( 9 )", false, isNaN(9) ); + +new TestCase( SECTION, "isNaN( '0' )", false, isNaN('0') ); +new TestCase( SECTION, "isNaN( '1' )", false, isNaN('1') ); +new TestCase( SECTION, "isNaN( '2' )", false, isNaN('2') ); +new TestCase( SECTION, "isNaN( '3' )", false, isNaN('3') ); +new TestCase( SECTION, "isNaN( '4' )", false, isNaN('4') ); +new TestCase( SECTION, "isNaN( '5' )", false, isNaN('5') ); +new TestCase( SECTION, "isNaN( '6' )", false, isNaN('6') ); +new TestCase( SECTION, "isNaN( '7' )", false, isNaN('7') ); +new TestCase( SECTION, "isNaN( '8' )", false, isNaN('8') ); +new TestCase( SECTION, "isNaN( '9' )", false, isNaN('9') ); + + +new TestCase( SECTION, "isNaN( 0x0a )", false, isNaN( 0x0a ) ); +new TestCase( SECTION, "isNaN( 0xaa )", false, isNaN( 0xaa ) ); +new TestCase( SECTION, "isNaN( 0x0A )", false, isNaN( 0x0A ) ); +new TestCase( SECTION, "isNaN( 0xAA )", false, isNaN( 0xAA ) ); + +new TestCase( SECTION, "isNaN( '0x0a' )", false, isNaN( "0x0a" ) ); +new TestCase( SECTION, "isNaN( '0xaa' )", false, isNaN( "0xaa" ) ); +new TestCase( SECTION, "isNaN( '0x0A' )", false, isNaN( "0x0A" ) ); +new TestCase( SECTION, "isNaN( '0xAA' )", false, isNaN( "0xAA" ) ); + +new TestCase( SECTION, "isNaN( 077 )", false, isNaN( 077 ) ); +new TestCase( SECTION, "isNaN( '077' )", false, isNaN( "077" ) ); + + +new TestCase( SECTION, "isNaN( Number.NaN )", true, isNaN(Number.NaN) ); +new TestCase( SECTION, "isNaN( Number.POSITIVE_INFINITY )", false, isNaN(Number.POSITIVE_INFINITY) ); +new TestCase( SECTION, "isNaN( Number.NEGATIVE_INFINITY )", false, isNaN(Number.NEGATIVE_INFINITY) ); +new TestCase( SECTION, "isNaN( Number.MAX_VALUE )", false, isNaN(Number.MAX_VALUE) ); +new TestCase( SECTION, "isNaN( Number.MIN_VALUE )", false, isNaN(Number.MIN_VALUE) ); + +new TestCase( SECTION, "isNaN( NaN )", true, isNaN(NaN) ); +new TestCase( SECTION, "isNaN( Infinity )", false, isNaN(Infinity) ); + +new TestCase( SECTION, "isNaN( 'Infinity' )", false, isNaN("Infinity") ); +new TestCase( SECTION, "isNaN( '-Infinity' )", false, isNaN("-Infinity") ); + +test(); diff --git a/tests/auto/qml/parserstress/tests/ecma/GlobalObject/15.1.2.7.js b/tests/auto/qml/parserstress/tests/ecma/GlobalObject/15.1.2.7.js new file mode 100644 index 0000000000..e3db5e7931 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/GlobalObject/15.1.2.7.js @@ -0,0 +1,130 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.1.2.7.js'; + +/** + File Name: 15.1.2.7.js + ECMA Section: 15.1.2.7 isFinite(number) + + Description: Applies ToNumber to its argument, then returns false if + the result is NaN, Infinity, or -Infinity, and otherwise + returns true. + + Author: christine@netscape.com + Date: 28 october 1997 + +*/ +var SECTION = "15.1.2.7"; +var VERSION = "ECMA_1"; +var TITLE = "isFinite( x )"; +var BUGNUMBER= "none"; + +startTest(); + +writeHeaderToLog( SECTION + " "+ TITLE); + +new TestCase( SECTION, "isFinite.length", 1, isFinite.length ); +new TestCase( SECTION, "isFinite.length = null; isFinite.length", 1, eval("isFinite.length=null; isFinite.length") ); +new TestCase( SECTION, "delete isFinite.length", false, delete isFinite.length ); +new TestCase( SECTION, "delete isFinite.length; isFinite.length", 1, eval("delete isFinite.length; isFinite.length") ); +new TestCase( SECTION, "var MYPROPS=''; for ( p in isFinite ) { MYPROPS+= p }; MYPROPS", "prototype", eval("var MYPROPS=''; for ( p in isFinite ) { MYPROPS += p }; MYPROPS") ); + +new TestCase( SECTION, "isFinite()", false, isFinite() ); +new TestCase( SECTION, "isFinite( null )", true, isFinite(null) ); +new TestCase( SECTION, "isFinite( void 0 )", false, isFinite(void 0) ); +new TestCase( SECTION, "isFinite( false )", true, isFinite(false) ); +new TestCase( SECTION, "isFinite( true)", true, isFinite(true) ); +new TestCase( SECTION, "isFinite( ' ' )", true, isFinite( " " ) ); + +new TestCase( SECTION, "isFinite( new Boolean(true) )", true, isFinite(new Boolean(true)) ); +new TestCase( SECTION, "isFinite( new Boolean(false) )", true, isFinite(new Boolean(false)) ); + +new TestCase( SECTION, "isFinite( 0 )", true, isFinite(0) ); +new TestCase( SECTION, "isFinite( 1 )", true, isFinite(1) ); +new TestCase( SECTION, "isFinite( 2 )", true, isFinite(2) ); +new TestCase( SECTION, "isFinite( 3 )", true, isFinite(3) ); +new TestCase( SECTION, "isFinite( 4 )", true, isFinite(4) ); +new TestCase( SECTION, "isFinite( 5 )", true, isFinite(5) ); +new TestCase( SECTION, "isFinite( 6 )", true, isFinite(6) ); +new TestCase( SECTION, "isFinite( 7 )", true, isFinite(7) ); +new TestCase( SECTION, "isFinite( 8 )", true, isFinite(8) ); +new TestCase( SECTION, "isFinite( 9 )", true, isFinite(9) ); + +new TestCase( SECTION, "isFinite( '0' )", true, isFinite('0') ); +new TestCase( SECTION, "isFinite( '1' )", true, isFinite('1') ); +new TestCase( SECTION, "isFinite( '2' )", true, isFinite('2') ); +new TestCase( SECTION, "isFinite( '3' )", true, isFinite('3') ); +new TestCase( SECTION, "isFinite( '4' )", true, isFinite('4') ); +new TestCase( SECTION, "isFinite( '5' )", true, isFinite('5') ); +new TestCase( SECTION, "isFinite( '6' )", true, isFinite('6') ); +new TestCase( SECTION, "isFinite( '7' )", true, isFinite('7') ); +new TestCase( SECTION, "isFinite( '8' )", true, isFinite('8') ); +new TestCase( SECTION, "isFinite( '9' )", true, isFinite('9') ); + +new TestCase( SECTION, "isFinite( 0x0a )", true, isFinite( 0x0a ) ); +new TestCase( SECTION, "isFinite( 0xaa )", true, isFinite( 0xaa ) ); +new TestCase( SECTION, "isFinite( 0x0A )", true, isFinite( 0x0A ) ); +new TestCase( SECTION, "isFinite( 0xAA )", true, isFinite( 0xAA ) ); + +new TestCase( SECTION, "isFinite( '0x0a' )", true, isFinite( "0x0a" ) ); +new TestCase( SECTION, "isFinite( '0xaa' )", true, isFinite( "0xaa" ) ); +new TestCase( SECTION, "isFinite( '0x0A' )", true, isFinite( "0x0A" ) ); +new TestCase( SECTION, "isFinite( '0xAA' )", true, isFinite( "0xAA" ) ); + +new TestCase( SECTION, "isFinite( 077 )", true, isFinite( 077 ) ); +new TestCase( SECTION, "isFinite( '077' )", true, isFinite( "077" ) ); + +new TestCase( SECTION, "isFinite( new String('Infinity') )", false, isFinite(new String("Infinity")) ); +new TestCase( SECTION, "isFinite( new String('-Infinity') )", false, isFinite(new String("-Infinity")) ); + +new TestCase( SECTION, "isFinite( 'Infinity' )", false, isFinite("Infinity") ); +new TestCase( SECTION, "isFinite( '-Infinity' )", false, isFinite("-Infinity") ); +new TestCase( SECTION, "isFinite( Number.POSITIVE_INFINITY )", false, isFinite(Number.POSITIVE_INFINITY) ); +new TestCase( SECTION, "isFinite( Number.NEGATIVE_INFINITY )", false, isFinite(Number.NEGATIVE_INFINITY) ); +new TestCase( SECTION, "isFinite( Number.NaN )", false, isFinite(Number.NaN) ); + +new TestCase( SECTION, "isFinite( Infinity )", false, isFinite(Infinity) ); +new TestCase( SECTION, "isFinite( -Infinity )", false, isFinite(-Infinity) ); +new TestCase( SECTION, "isFinite( NaN )", false, isFinite(NaN) ); + + +new TestCase( SECTION, "isFinite( Number.MAX_VALUE )", true, isFinite(Number.MAX_VALUE) ); +new TestCase( SECTION, "isFinite( Number.MIN_VALUE )", true, isFinite(Number.MIN_VALUE) ); + +test(); diff --git a/tests/auto/qml/parserstress/tests/ecma/GlobalObject/browser.js b/tests/auto/qml/parserstress/tests/ecma/GlobalObject/browser.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/auto/qml/parserstress/tests/ecma/GlobalObject/shell.js b/tests/auto/qml/parserstress/tests/ecma/GlobalObject/shell.js new file mode 100644 index 0000000000..d922707218 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/GlobalObject/shell.js @@ -0,0 +1 @@ +gTestsubsuite = 'GlobalObject'; diff --git a/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.1-1.js b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.1-1.js new file mode 100644 index 0000000000..7fa415c20d --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.1-1.js @@ -0,0 +1,82 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '7.1-1.js'; + +/** + File Name: 7.1-1.js + ECMA Section: 7.1 White Space + Description: - readability + - separate tokens + - otherwise should be insignificant + - in strings, white space characters are significant + - cannot appear within any other kind of token + + white space characters are: + unicode name formal name string representation + \u0009 tab \t + \u000B veritical tab \v + \U000C form feed \f + \u0020 space " " + + Author: christine@netscape.com + Date: 11 september 1997 +*/ + +var SECTION = "7.1-1"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "White Space"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +// whitespace between var keyword and identifier + +new TestCase( SECTION, 'var'+'\t'+'MYVAR1=10;MYVAR1', 10, eval('var'+'\t'+'MYVAR1=10;MYVAR1') ); +new TestCase( SECTION, 'var'+'\f'+'MYVAR2=10;MYVAR2', 10, eval('var'+'\f'+'MYVAR2=10;MYVAR2') ); +new TestCase( SECTION, 'var'+'\v'+'MYVAR2=10;MYVAR2', 10, eval('var'+'\v'+'MYVAR2=10;MYVAR2') ); +new TestCase( SECTION, 'var'+'\ '+'MYVAR2=10;MYVAR2', 10, eval('var'+'\ '+'MYVAR2=10;MYVAR2') ); + +// use whitespace between tokens object name, dot operator, and object property + +new TestCase( SECTION, + "var a = new Array(12345); a\t\v\f .\\u0009\\000B\\u000C\\u0020length", + 12345, + eval("var a = new Array(12345); a\t\v\f .\u0009\u0020\u000C\u000Blength") ); + +test(); diff --git a/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.1-2.js b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.1-2.js new file mode 100644 index 0000000000..aa0c3fb373 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.1-2.js @@ -0,0 +1,73 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '7.1-2.js'; + +/** + File Name: 7.1-2.js + ECMA Section: 7.1 White Space + Description: - readability + - separate tokens + - otherwise should be insignificant + - in strings, white space characters are significant + - cannot appear within any other kind of token + + white space characters are: + unicode name formal name string representation + \u0009 tab \t + \u000B veritical tab ?? + \U000C form feed \f + \u0020 space " " + + Author: christine@netscape.com + Date: 11 september 1997 +*/ + +var SECTION = "7.1-2"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "White Space"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +new TestCase( SECTION, "'var'+'\u000B'+'MYVAR1=10;MYVAR1'", 10, eval('var'+'\u000B'+'MYVAR1=10;MYVAR1') ); +new TestCase( SECTION, "'var'+'\u0009'+'MYVAR2=10;MYVAR2'", 10, eval('var'+'\u0009'+'MYVAR2=10;MYVAR2') ); +new TestCase( SECTION, "'var'+'\u000C'+'MYVAR3=10;MYVAR3'", 10, eval('var'+'\u000C'+'MYVAR3=10;MYVAR3') ); +new TestCase( SECTION, "'var'+'\u0020'+'MYVAR4=10;MYVAR4'", 10, eval('var'+'\u0020'+'MYVAR4=10;MYVAR4') ); + +test(); diff --git a/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.1-3.js b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.1-3.js new file mode 100644 index 0000000000..c405106ade --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.1-3.js @@ -0,0 +1,89 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '7.1-3.js'; + +/** + File Name: 7.1-3.js + ECMA Section: 7.1 White Space + Description: - readability + - separate tokens + - otherwise should be insignificant + - in strings, white space characters are significant + - cannot appear within any other kind of token + + white space characters are: + unicode name formal name string representation + \u0009 tab \t + \u000B veritical tab ?? + \U000C form feed \f + \u0020 space " " + + Author: christine@netscape.com + Date: 11 september 1997 +*/ + +var SECTION = "7.1-3"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "White Space"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +new TestCase( SECTION, "'var'+'\u000B'+'MYVAR1=10;MYVAR1'", 10, eval('var'+'\u000B'+'MYVAR1=10;MYVAR1') ); +new TestCase( SECTION, "'var'+'\u0009'+'MYVAR2=10;MYVAR2'", 10, eval('var'+'\u0009'+'MYVAR2=10;MYVAR2') ); +new TestCase( SECTION, "'var'+'\u000C'+'MYVAR3=10;MYVAR3'", 10, eval('var'+'\u000C'+'MYVAR3=10;MYVAR3') ); +new TestCase( SECTION, "'var'+'\u0020'+'MYVAR4=10;MYVAR4'", 10, eval('var'+'\u0020'+'MYVAR4=10;MYVAR4') ); + +// ++ should be interpreted as the unary + operator twice, not as a post or prefix increment operator + +new TestCase( SECTION, + "var VAR = 12345; + + VAR", + 12345, + eval("var VAR = 12345; + + VAR") ); + +new TestCase( SECTION, + "var VAR = 12345;VAR+ + VAR", + 24690, + eval("var VAR = 12345;VAR+ +VAR") ); +new TestCase( SECTION, + "var VAR = 12345;VAR - - VAR", + 24690, + eval("var VAR = 12345;VAR- -VAR") ); + +test(); diff --git a/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.2-1.js b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.2-1.js new file mode 100644 index 0000000000..dd4f2fcbed --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.2-1.js @@ -0,0 +1,73 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '7.2-1.js'; + +/** + File Name: 7.2-1.js + ECMA Section: 7.2 Line Terminators + Description: - readability + - separate tokens + - may occur between any two tokens + - cannot occur within any token, not even a string + - affect the process of automatic semicolon insertion. + + white space characters are: + unicode name formal name string representation + \u000A line feed \n + \u000D carriage return \r + + Author: christine@netscape.com + Date: 11 september 1997 +*/ +var SECTION = "7.2-1"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Line Terminators"; + +writeHeaderToLog( SECTION + " "+ TITLE); + + +new TestCase( SECTION, "var a\nb = 5; ab=10;ab;", 10, eval("var a\nb = 5; ab=10;ab") ); +new TestCase( SECTION, "var a\nb = 5; ab=10;b;", 5, eval("var a\nb = 5; ab=10;b") ); +new TestCase( SECTION, "var a\rb = 5; ab=10;ab;", 10, eval("var a\rb = 5; ab=10;ab") ); +new TestCase( SECTION, "var a\rb = 5; ab=10;b;", 5, eval("var a\rb = 5; ab=10;b") ); +new TestCase( SECTION, "var a\r\nb = 5; ab=10;ab;", 10, eval("var a\r\nb = 5; ab=10;ab") ); +new TestCase( SECTION, "var a\r\nb = 5; ab=10;b;", 5, eval("var a\r\nb = 5; ab=10;b") ); + +test(); diff --git a/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.2-2-n.js b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.2-2-n.js new file mode 100644 index 0000000000..d945115832 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.2-2-n.js @@ -0,0 +1,74 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '7.2-2-n.js'; + +/** + File Name: 7.2.js + ECMA Section: 7.2 Line Terminators + Description: - readability + - separate tokens + - may occur between any two tokens + - cannot occur within any token, not even a string + - affect the process of automatic semicolon insertion. + + white space characters are: + unicode name formal name string representation + \u000A line feed \n + \u000D carriage return \r + + this test uses onerror to capture line numbers. because + we use on error, we can only have one test case per file. + + Author: christine@netscape.com + Date: 11 september 1997 +*/ +var SECTION = "7.2-2"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Line Terminators"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +DESCRIPTION = "\r\r\r\nb"; +EXPECTED = "error" + + new TestCase( SECTION, DESCRIPTION, "error", eval("\r\r\r\nb")); + +test(); + diff --git a/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.2-3-n.js b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.2-3-n.js new file mode 100644 index 0000000000..c62410d202 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.2-3-n.js @@ -0,0 +1,74 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '7.2-3-n.js'; + +/** + File Name: 7.2-3.js + ECMA Section: 7.2 Line Terminators + Description: - readability + - separate tokens + - may occur between any two tokens + - cannot occur within any token, not even a string + - affect the process of automatic semicolon insertion. + + white space characters are: + unicode name formal name string representation + \u000A line feed \n + \u000D carriage return \r + + this test uses onerror to capture line numbers. because + we use on error, we can only have one test case per file. + + Author: christine@netscape.com + Date: 11 september 1997 +*/ +var SECTION = "7.2-3"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Line Terminators"; + +writeHeaderToLog( SECTION + " "+ TITLE); + + +DESCRIPTION = "\r\nb"; +EXPECTED = "error" + + new TestCase( SECTION, "a", "error", eval("\r\nb")); + +test(); diff --git a/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.2-4-n.js b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.2-4-n.js new file mode 100644 index 0000000000..b29f999739 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.2-4-n.js @@ -0,0 +1,73 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '7.2-4-n.js'; + +/** + File Name: 7.2.js + ECMA Section: 7.2 Line Terminators + Description: - readability + - separate tokens + - may occur between any two tokens + - cannot occur within any token, not even a string + - affect the process of automatic semicolon insertion. + + white space characters are: + unicode name formal name string representation + \u000A line feed \n + \u000D carriage return \r + + this test uses onerror to capture line numbers. because + we use on error, we can only have one test case per file. + + Author: christine@netscape.com + Date: 11 september 1997 +*/ +var SECTION = "7.2-6"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Line Terminators"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +DESCRIPTION = "\nb"; +EXPECTED = "error"; + +new TestCase( SECTION, "\nb", "error", eval("\nb")); + +test(); diff --git a/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.2-5-n.js b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.2-5-n.js new file mode 100644 index 0000000000..b563d86437 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.2-5-n.js @@ -0,0 +1,72 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '7.2-5-n.js'; + +/** + File Name: 7.2.js + ECMA Section: 7.2 Line Terminators + Description: - readability + - separate tokens + - may occur between any two tokens + - cannot occur within any token, not even a string + - affect the process of automatic semicolon insertion. + + white space characters are: + unicode name formal name string representation + \u000A line feed \n + \u000D carriage return \r + + this test uses onerror to capture line numbers. because + we use on error, we can only have one test case per file. + + Author: christine@netscape.com + Date: 11 september 1997 +*/ +var SECTION = "7.2-5"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Line Terminators"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +DESCRIPTION = + EXPECTED = "error"; + +new TestCase( SECTION, "\rb", "error", eval("\rb")); +test(); diff --git a/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.2-6.js b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.2-6.js new file mode 100644 index 0000000000..220548e78e --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.2-6.js @@ -0,0 +1,68 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '7.2-6.js'; + +/** + File Name: 7.2-6.js + ECMA Section: 7.2 Line Terminators + Description: - readability + - separate tokens + - may occur between any two tokens + - cannot occur within any token, not even a string + - affect the process of automatic semicolon insertion. + + white space characters are: + unicode name formal name string representation + \u000A line feed \n + \u000D carriage return \r + + Author: christine@netscape.com + Date: 11 september 1997 +*/ +var SECTION = "7.2-6"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Line Terminators"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +new TestCase( SECTION, "var a\u000Ab = 5; ab=10;ab;", 10, eval("var a\nb = 5; ab=10;ab") ); +new TestCase( SECTION, "var a\u000Db = 5; ab=10;b;", 5, eval("var a\nb = 5; ab=10;b") ); + +test(); diff --git a/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.3-1.js b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.3-1.js new file mode 100644 index 0000000000..9701660576 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.3-1.js @@ -0,0 +1,92 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '7.3-1.js'; + +/** + File Name: 7.3-1.js + ECMA Section: 7.3 Comments + Description: + + + Author: christine@netscape.com + Date: 12 november 1997 + +*/ +var SECTION = "7.3-1"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Comments"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +var testcase; + +testcase = new TestCase( SECTION, + "a comment with a line terminator string, and text following", + "pass", + "pass"); + +// "\u000A" testcase.actual = "fail"; + + +testcase = new TestCase( SECTION, + "// test \\n testcase.actual = \"pass\"", + "pass", + "" ); + +var x = "// test \n testcase.actual = 'pass'"; + +testcase.actual = eval(x); + +test(); + +// XXX bc replace test() +function test() { + for ( gTc=0; gTc < gTestcases.length; gTc++ ) { + gTestcases[gTc].passed = writeTestCaseResult( + gTestcases[gTc].expect, + gTestcases[gTc].actual, + gTestcases[gTc].description +": "+ + gTestcases[gTc].actual ); + + gTestcases[gTc].reason += ( gTestcases[gTc].passed ) ? "" : " ignored chars after line terminator of single-line comment"; + } + stopTest(); + return ( gTestcases ); +} diff --git a/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.3-10.js b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.3-10.js new file mode 100644 index 0000000000..1cd0f18a90 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.3-10.js @@ -0,0 +1,65 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '7.3-10.js'; + +/** + File Name: 7.3-10.js + ECMA Section: 7.3 Comments + Description: + + + Author: christine@netscape.com + Date: 12 november 1997 + +*/ +var SECTION = "7.3-10"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Comments"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +var testcase = new TestCase( SECTION, + "code following multiline comment", + "pass", + "fail"); + +/*//*/testcase.actual="pass"; + +test(); diff --git a/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.3-11.js b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.3-11.js new file mode 100644 index 0000000000..f9033cd05a --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.3-11.js @@ -0,0 +1,66 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '7.3-11.js'; + +/** + File Name: 7.3-11.js + ECMA Section: 7.3 Comments + Description: + + + Author: christine@netscape.com + Date: 12 november 1997 + +*/ +var SECTION = "7.3-11"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Comments"; + +writeHeaderToLog( SECTION + " "+ TITLE); + + +var testcase = new TestCase( SECTION, + "code following multiline comment", + "pass", + "pass"); + +////testcase.actual="fail"; + +test(); diff --git a/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.3-12.js b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.3-12.js new file mode 100644 index 0000000000..04ceb81409 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.3-12.js @@ -0,0 +1,64 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '7.3-12.js'; + +/** + File Name: 7.3-12.js + ECMA Section: 7.3 Comments + Description: + + + Author: christine@netscape.com + Date: 12 november 1997 + +*/ +var SECTION = "7.3-12"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Comments"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +var testcase = new TestCase( SECTION, + "code following multiline comment", + "pass", + "pass"); +/*testcase.actual="fail";**/ + +test(); diff --git a/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.3-13-n.js b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.3-13-n.js new file mode 100644 index 0000000000..714de99a9a --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.3-13-n.js @@ -0,0 +1,66 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '7.3-13-n.js'; + +/** + File Name: 7.3-13-n.js + ECMA Section: 7.3 Comments + Description: + + + Author: christine@netscape.com + Date: 12 november 1997 + +*/ +var SECTION = "7.3-13-n"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Comments"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +DESCRIPTION = "nested comment"; +EXPECTED = "error"; + +var testcase = new TestCase( SECTION, + "nested comment", + "error", + eval("/*/*\"fail\";*/*/")); + +test(); diff --git a/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.3-2.js b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.3-2.js new file mode 100644 index 0000000000..7aa029feda --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.3-2.js @@ -0,0 +1,65 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '7.3-2.js'; + +/** + File Name: 7.3-2.js + ECMA Section: 7.3 Comments + Description: + + + Author: christine@netscape.com + Date: 12 november 1997 + +*/ +var SECTION = "7.3-2"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Comments"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +var testcase = new TestCase( SECTION, + "a comment with a carriage return, and text following", + "pass", + "pass"); + +// "\u000D" testcase.actual = "fail"; + +test(); diff --git a/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.3-3.js b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.3-3.js new file mode 100644 index 0000000000..1886639e26 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.3-3.js @@ -0,0 +1,65 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '7.3-3.js'; + +/** + File Name: 7.3-3.js + ECMA Section: 7.3 Comments + Description: + + + Author: christine@netscape.com + Date: 12 november 1997 + +*/ +var SECTION = "7.3-3"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Comments"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +var testcase = new TestCase( SECTION, + "source text directly following a single-line comment", + "pass", + "fail"); +// a comment string +testcase.actual = "pass"; + +test(); diff --git a/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.3-4.js b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.3-4.js new file mode 100644 index 0000000000..4cb53af0fb --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.3-4.js @@ -0,0 +1,65 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '7.3-4.js'; + +/** + File Name: 7.3-4.js + ECMA Section: 7.3 Comments + Description: + + + Author: christine@netscape.com + Date: 12 november 1997 + +*/ +var SECTION = "7.3-4"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Comments"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +var testcase = new TestCase( SECTION, + "multiline comment ", + "pass", + "pass"); + +/*testcase.actual = "fail";*/ + +test(); diff --git a/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.3-5.js b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.3-5.js new file mode 100644 index 0000000000..22d9e08a60 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.3-5.js @@ -0,0 +1,65 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '7.3-5.js'; + +/** + File Name: 7.3-5.js + ECMA Section: 7.3 Comments + Description: + + + Author: christine@netscape.com + Date: 12 november 1997 + +*/ +var SECTION = "7.3-5"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Comments"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +var testcase = new TestCase( SECTION, + "a comment with a carriage return, and text following", + "pass", + "pass"); + +// "\u000A" testcase.actual = "fail"; + +test(); diff --git a/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.3-6.js b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.3-6.js new file mode 100644 index 0000000000..91afd319a4 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.3-6.js @@ -0,0 +1,65 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '7.3-6.js'; + +/** + File Name: 7.3-6.js + ECMA Section: 7.3 Comments + Description: + + + Author: christine@netscape.com + Date: 12 november 1997 + +*/ +var SECTION = "7.3-6"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Comments"; + +writeHeaderToLog( SECTION + " "+ TITLE); +var testcase = new TestCase( SECTION, + "comment with multiple asterisks", + "pass", + "fail"); + +/* +***/testcase.actual="pass"; + +test(); diff --git a/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.3-7.js b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.3-7.js new file mode 100644 index 0000000000..a35cd54289 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.3-7.js @@ -0,0 +1,66 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '7.3-7.js'; + +/** + File Name: 7.3-7.js + ECMA Section: 7.3 Comments + Description: + + + Author: christine@netscape.com + Date: 12 november 1997 + +*/ +var SECTION = "7.3-7"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Comments"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +var testcase = new TestCase( SECTION, + "single line comment following multiline comment", + "pass", + "pass"); + +/* +***///testcase.actual="fail"; + +test(); diff --git a/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.3-8.js b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.3-8.js new file mode 100644 index 0000000000..2d665c4ff0 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.3-8.js @@ -0,0 +1,65 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '7.3-8.js'; + +/** + File Name: 7.3-7.js + ECMA Section: 7.3 Comments + Description: + + + Author: christine@netscape.com + Date: 12 november 1997 + +*/ +var SECTION = "7.3-8"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Comments"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +var testcase = new TestCase( SECTION, + "code following multiline comment", + "pass", + "fail"); + +/**/testcase.actual="pass"; + +test(); diff --git a/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.3-9.js b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.3-9.js new file mode 100644 index 0000000000..caff9f7f09 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.3-9.js @@ -0,0 +1,65 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '7.3-9.js'; + +/** + File Name: 7.3-9.js + ECMA Section: 7.3 Comments + Description: + + + Author: christine@netscape.com + Date: 12 november 1997 + +*/ +var SECTION = "7.3-9"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Comments"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +var testcase = new TestCase( SECTION, + "code following multiline comment", + "pass", + "fail"); + +/*/*/testcase.actual="pass"; + +test(); diff --git a/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.1-1-n.js b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.1-1-n.js new file mode 100644 index 0000000000..2153cc2638 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.1-1-n.js @@ -0,0 +1,71 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '7.4.1-1-n.js'; + +/** + File Name: 7.4.1-1-n.js + ECMA Section: 7.4.1 + + Description: + + Reserved words cannot be used as identifiers. + + ReservedWord :: + Keyword + FutureReservedWord + NullLiteral + BooleanLiteral + + Author: christine@netscape.com + Date: 12 november 1997 + +*/ +var SECTION = "7.4.1-1-n"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Keywords"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +DESCRIPTION = "var null = true"; +EXPECTED = "error"; + +new TestCase( SECTION, "var null = true", "error", eval("var null = true") ); + +test(); diff --git a/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.1-2-n.js b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.1-2-n.js new file mode 100644 index 0000000000..a50bd6020f --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.1-2-n.js @@ -0,0 +1,71 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '7.4.1-2-n.js'; + +/** + File Name: 7.4.1-2.js + ECMA Section: 7.4.1 + + Description: + + Reserved words cannot be used as identifiers. + + ReservedWord :: + Keyword + FutureReservedWord + NullLiteral + BooleanLiteral + + Author: christine@netscape.com + Date: 12 november 1997 + +*/ +var SECTION = "7.4.1-2-n"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Keywords"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +DESCRIPTION = "var true = false"; +EXPECTED = "error"; + +new TestCase( SECTION, "var true = false", "error", eval("var true = false") ); + +test(); diff --git a/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.1-3-n.js b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.1-3-n.js new file mode 100644 index 0000000000..b49fe7937b --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.1-3-n.js @@ -0,0 +1,69 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '7.4.1-3-n.js'; + +/** + File Name: 7.4.1-3-n.js + ECMA Section: 7.4.1 + + Description: + + Reserved words cannot be used as identifiers. + + ReservedWord :: + Keyword + FutureReservedWord + NullLiteral + BooleanLiteral + + Author: christine@netscape.com + Date: 12 november 1997 + +*/ +var SECTION = "7.4.1-3-n"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Keywords"; + +DESCRIPTION = "var false = true"; +EXPECTED = "error"; + +new TestCase( SECTION, "var false = true", "error", eval("var false = true") ); + +test(); diff --git a/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.2-1-n.js b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.2-1-n.js new file mode 100644 index 0000000000..36723173f5 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.2-1-n.js @@ -0,0 +1,77 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '7.4.2-1-n.js'; + +/** + File Name: 7.4.2-1.js + ECMA Section: 7.4.2 + + Description: + The following tokens are ECMAScript keywords and may not be used as + identifiers in ECMAScript programs. + + Syntax + + Keyword :: one of + break for new var + continue function return void + delete if this while + else in typeof with + + This test verifies that the keyword cannot be used as an identifier. + Functioinal tests of the keyword may be found in the section corresponding + to the function of the keyword. + + Author: christine@netscape.com + Date: 12 november 1997 + +*/ +var SECTION = "7.4.2-1-n"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Keywords"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +DESCRIPTION = "var break = true"; +EXPECTED = "error"; + +new TestCase( SECTION, "var break = true", "error", eval("var break = true") ); + +test(); diff --git a/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.2-10-n.js b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.2-10-n.js new file mode 100644 index 0000000000..89003d3601 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.2-10-n.js @@ -0,0 +1,77 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '7.4.2-10-n.js'; + +/** + File Name: 7.4.2-10.js + ECMA Section: 7.4.2 + + Description: + The following tokens are ECMAScript keywords and may not be used as + identifiers in ECMAScript programs. + + Syntax + + Keyword :: one of + break for new var + continue function return void + delete if this while + else in typeof with + + This test verifies that the keyword cannot be used as an identifier. + Functioinal tests of the keyword may be found in the section corresponding + to the function of the keyword. + + Author: christine@netscape.com + Date: 12 november 1997 + +*/ +var SECTION = "7.4.1-10-n"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Keywords"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +DESCRIPTION = "var if = true"; +EXPECTED = "error"; + +new TestCase( SECTION, "var if = true", "error", eval("var if = true") ); + +test(); diff --git a/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.2-11-n.js b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.2-11-n.js new file mode 100644 index 0000000000..3aff749e51 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.2-11-n.js @@ -0,0 +1,77 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '7.4.2-11-n.js'; + +/** + File Name: 7.4.2-11-n.js + ECMA Section: 7.4.2 + + Description: + The following tokens are ECMAScript keywords and may not be used as + identifiers in ECMAScript programs. + + Syntax + + Keyword :: one of + break for new var + continue function return void + delete if this while + else in typeof with + + This test verifies that the keyword cannot be used as an identifier. + Functioinal tests of the keyword may be found in the section corresponding + to the function of the keyword. + + Author: christine@netscape.com + Date: 12 november 1997 + +*/ +var SECTION = "7.4.1-11-n"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Keywords"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +DESCRIPTION = "var this = true"; +EXPECTED = "error"; + +new TestCase( SECTION, "var this = true", "error", eval("var this = true") ); + +test(); diff --git a/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.2-12-n.js b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.2-12-n.js new file mode 100644 index 0000000000..f19ed8c904 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.2-12-n.js @@ -0,0 +1,77 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '7.4.2-12-n.js'; + +/** + File Name: 7.4.2-12-n.js + ECMA Section: 7.4.2 + + Description: + The following tokens are ECMAScript keywords and may not be used as + identifiers in ECMAScript programs. + + Syntax + + Keyword :: one of + break for new var + continue function return void + delete if this while + else in typeof with + + This test verifies that the keyword cannot be used as an identifier. + Functioinal tests of the keyword may be found in the section corresponding + to the function of the keyword. + + Author: christine@netscape.com + Date: 12 november 1997 + +*/ +var SECTION = "7.4.1-12-n"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Keywords"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +DESCRIPTION = "var while = true"; +EXPECTED = "error"; + +new TestCase( SECTION, "var while = true", "error", eval("var while = true") ); + +test(); diff --git a/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.2-13-n.js b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.2-13-n.js new file mode 100644 index 0000000000..22a5284dcc --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.2-13-n.js @@ -0,0 +1,77 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '7.4.2-13-n.js'; + +/** + File Name: 7.4.2-13-n.js + ECMA Section: 7.4.2 + + Description: + The following tokens are ECMAScript keywords and may not be used as + identifiers in ECMAScript programs. + + Syntax + + Keyword :: one of + break for new var + continue function return void + delete if this while + else in typeof with + + This test verifies that the keyword cannot be used as an identifier. + Functioinal tests of the keyword may be found in the section corresponding + to the function of the keyword. + + Author: christine@netscape.com + Date: 12 november 1997 + +*/ +var SECTION = "7.4.1-13-n"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Keywords"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +DESCRIPTION = "var else = true"; +EXPECTED = "error"; + +new TestCase( SECTION, "var else = true", "error", eval("var else = true") ); + +test(); diff --git a/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.2-14-n.js b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.2-14-n.js new file mode 100644 index 0000000000..b9b05f42b7 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.2-14-n.js @@ -0,0 +1,77 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '7.4.2-14-n.js'; + +/** + File Name: 7.4.2-14-n.js + ECMA Section: 7.4.2 + + Description: + The following tokens are ECMAScript keywords and may not be used as + identifiers in ECMAScript programs. + + Syntax + + Keyword :: one of + break for new var + continue function return void + delete if this while + else in typeof with + + This test verifies that the keyword cannot be used as an identifier. + Functioinal tests of the keyword may be found in the section corresponding + to the function of the keyword. + + Author: christine@netscape.com + Date: 12 november 1997 + +*/ +var SECTION = "7.4.1-14-n"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Keywords"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +DESCRIPTION = "var in = true"; +EXPECTED = "error"; + +new TestCase( SECTION, "var in = true", "error", eval("var in = true") ); + +test(); diff --git a/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.2-15-n.js b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.2-15-n.js new file mode 100644 index 0000000000..27e83972c3 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.2-15-n.js @@ -0,0 +1,77 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '7.4.2-15-n.js'; + +/** + File Name: 7.4.2-15-n.js + ECMA Section: 7.4.2 + + Description: + The following tokens are ECMAScript keywords and may not be used as + identifiers in ECMAScript programs. + + Syntax + + Keyword :: one of + break for new var + continue function return void + delete if this while + else in typeof with + + This test verifies that the keyword cannot be used as an identifier. + Functioinal tests of the keyword may be found in the section corresponding + to the function of the keyword. + + Author: christine@netscape.com + Date: 12 november 1997 + +*/ +var SECTION = "7.4.1-15-n"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Keywords"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +DESCRIPTION = "var typeof = true"; +EXPECTED = "error"; + +new TestCase( SECTION, "var typeof = true", "error", eval("var typeof = true") ); + +test(); diff --git a/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.2-16-n.js b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.2-16-n.js new file mode 100644 index 0000000000..988920538c --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.2-16-n.js @@ -0,0 +1,77 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '7.4.2-16-n.js'; + +/** + File Name: 7.4.2-16-n.js + ECMA Section: 7.4.2 + + Description: + The following tokens are ECMAScript keywords and may not be used as + identifiers in ECMAScript programs. + + Syntax + + Keyword :: one of + break for new var + continue function return void + delete if this while + else in typeof with + + This test verifies that the keyword cannot be used as an identifier. + Functioinal tests of the keyword may be found in the section corresponding + to the function of the keyword. + + Author: christine@netscape.com + Date: 12 november 1997 + +*/ +var SECTION = "7.4.1-16-n"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Keywords"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +DESCRIPTION = "var with = true"; +EXPECTED = "error"; + +new TestCase( SECTION, "var with = true", "error", eval("var with = true") ); + +test(); diff --git a/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.2-2-n.js b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.2-2-n.js new file mode 100644 index 0000000000..648610a9e6 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.2-2-n.js @@ -0,0 +1,77 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '7.4.2-2-n.js'; + +/** + File Name: 7.4.2-2-n.js + ECMA Section: 7.4.2 + + Description: + The following tokens are ECMAScript keywords and may not be used as + identifiers in ECMAScript programs. + + Syntax + + Keyword :: one of + break for new var + continue function return void + delete if this while + else in typeof with + + This test verifies that the keyword cannot be used as an identifier. + Functioinal tests of the keyword may be found in the section corresponding + to the function of the keyword. + + Author: christine@netscape.com + Date: 12 november 1997 + +*/ +var SECTION = "7.4.1-2-n"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Keywords"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +DESCRIPTION = "var for = true"; +EXPECTED = "error"; + +new TestCase( SECTION, "var for = true", "error", eval("var for = true") ); + +test(); diff --git a/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.2-3-n.js b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.2-3-n.js new file mode 100644 index 0000000000..d8b74d6b0e --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.2-3-n.js @@ -0,0 +1,77 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '7.4.2-3-n.js'; + +/** + File Name: 7.4.2-3-n.js + ECMA Section: 7.4.2 + + Description: + The following tokens are ECMAScript keywords and may not be used as + identifiers in ECMAScript programs. + + Syntax + + Keyword :: one of + break for new var + continue function return void + delete if this while + else in typeof with + + This test verifies that the keyword cannot be used as an identifier. + Functioinal tests of the keyword may be found in the section corresponding + to the function of the keyword. + + Author: christine@netscape.com + Date: 12 november 1997 + +*/ +var SECTION = "7.4.2-3-n"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Keywords"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +DESCRIPTION = "var new = true"; +EXPECTED = "error"; + +new TestCase( SECTION, "var new = true", "error", eval("var new = true") ); + +test(); diff --git a/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.2-4-n.js b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.2-4-n.js new file mode 100644 index 0000000000..2bb0aa260b --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.2-4-n.js @@ -0,0 +1,77 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '7.4.2-4-n.js'; + +/** + File Name: 7.4.2-4-n.js + ECMA Section: 7.4.2 + + Description: + The following tokens are ECMAScript keywords and may not be used as + identifiers in ECMAScript programs. + + Syntax + + Keyword :: one of + break for new var + continue function return void + delete if this while + else in typeof with + + This test verifies that the keyword cannot be used as an identifier. + Functioinal tests of the keyword may be found in the section corresponding + to the function of the keyword. + + Author: christine@netscape.com + Date: 12 november 1997 + +*/ +var SECTION = "7.4.2-4-n"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Keywords"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +DESCRIPTION = "var var = true"; +EXPECTED = "error"; + +TestCase( SECTION, "var var = true", "error", eval("var var = true") ); + +test(); diff --git a/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.2-5-n.js b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.2-5-n.js new file mode 100644 index 0000000000..3fdf06b2c1 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.2-5-n.js @@ -0,0 +1,77 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '7.4.2-5-n.js'; + +/** + File Name: 7.4.2-5-n.js + ECMA Section: 7.4.2 + + Description: + The following tokens are ECMAScript keywords and may not be used as + identifiers in ECMAScript programs. + + Syntax + + Keyword :: one of + break for new var + continue function return void + delete if this while + else in typeof with + + This test verifies that the keyword cannot be used as an identifier. + Functioinal tests of the keyword may be found in the section corresponding + to the function of the keyword. + + Author: christine@netscape.com + Date: 12 november 1997 + +*/ +var SECTION = "7.4.2-5-n"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Keywords"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +DESCRIPTION = "var continue = true"; +EXPECTED = "error"; + +new TestCase( SECTION, "var continue = true", "error", eval("var continue = true") ); + +test(); diff --git a/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.2-6-n.js b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.2-6-n.js new file mode 100644 index 0000000000..00f3f99a4c --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.2-6-n.js @@ -0,0 +1,77 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '7.4.2-6-n.js'; + +/** + File Name: 7.4.2-6.js + ECMA Section: 7.4.2 + + Description: + The following tokens are ECMAScript keywords and may not be used as + identifiers in ECMAScript programs. + + Syntax + + Keyword :: one of + break for new var + continue function return void + delete if this while + else in typeof with + + This test verifies that the keyword cannot be used as an identifier. + Functioinal tests of the keyword may be found in the section corresponding + to the function of the keyword. + + Author: christine@netscape.com + Date: 12 november 1997 + +*/ +var SECTION = "7.4.2-6-n"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Keywords"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +DESCRIPTION = "var function = true"; +EXPECTED = "error"; + +new TestCase( SECTION, "var function = true", "error", eval("var function = true") ); + +test(); diff --git a/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.2-7-n.js b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.2-7-n.js new file mode 100644 index 0000000000..6a85b261ce --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.2-7-n.js @@ -0,0 +1,75 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '7.4.2-7-n.js'; + +/** + File Name: 7.4.2-7-n.js + ECMA Section: 7.4.2 + + Description: + The following tokens are ECMAScript keywords and may not be used as + identifiers in ECMAScript programs. + + Syntax + + Keyword :: one of + break for new var + continue function return void + delete if this while + else in typeof with + + This test verifies that the keyword cannot be used as an identifier. + Functioinal tests of the keyword may be found in the section corresponding + to the function of the keyword. + + Author: christine@netscape.com + Date: 12 november 1997 + +*/ +var SECTION = "7.4.2-7"; +var VERSION = "ECMA_1"; +startTest(); +writeHeaderToLog( SECTION + " Keywords"); + +DESCRIPTION = "var return = true"; +EXPECTED = "error"; + +new TestCase( SECTION, "var return = true", "error", eval("var return = true") ); + +test(); diff --git a/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.2-8-n.js b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.2-8-n.js new file mode 100644 index 0000000000..5f5122e0f2 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.2-8-n.js @@ -0,0 +1,76 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '7.4.2-8-n.js'; + +/** + File Name: 7.4.2-8-n.js + ECMA Section: 7.4.2 + + Description: + The following tokens are ECMAScript keywords and may not be used as + identifiers in ECMAScript programs. + + Syntax + + Keyword :: one of + break for new var + continue function return void + delete if this while + else in typeof with + + This test verifies that the keyword cannot be used as an identifier. + Functioinal tests of the keyword may be found in the section corresponding + to the function of the keyword. + + Author: christine@netscape.com + Date: 12 november 1997 + +*/ +var SECTION = "7.4.2-8"; +var VERSION = "ECMA_1"; +startTest(); + +writeHeaderToLog( SECTION + " Keywords"); + +DESCRIPTION = "var void = true"; +EXPECTED = "error"; + +new TestCase( SECTION, "var void = true", "error", eval("var void = true") ); + +test(); diff --git a/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.2-9-n.js b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.2-9-n.js new file mode 100644 index 0000000000..c1c4df6d9b --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.2-9-n.js @@ -0,0 +1,77 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '7.4.2-9-n.js'; + +/** + File Name: 7.4.2-9-n.js + ECMA Section: 7.4.2 + + Description: + The following tokens are ECMAScript keywords and may not be used as + identifiers in ECMAScript programs. + + Syntax + + Keyword :: one of + break for new var + continue function return void + delete if this while + else in typeof with + + This test verifies that the keyword cannot be used as an identifier. + Functioinal tests of the keyword may be found in the section corresponding + to the function of the keyword. + + Author: christine@netscape.com + Date: 12 november 1997 + +*/ +var SECTION = "7.4.1-9-n"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Keywords"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +DESCRIPTION = "var delete = true"; +EXPECTED = "error"; + +new TestCase( SECTION, "var delete = true", "error", eval("var delete = true") ); + +test(); diff --git a/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.3-1-n.js b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.3-1-n.js new file mode 100644 index 0000000000..dee163d8e5 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.3-1-n.js @@ -0,0 +1,71 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '7.4.3-1-n.js'; + +/** + File Name: 7.4.3-1-n.js + ECMA Section: 7.4.3 + + Description: + The following words are used as keywords in proposed extensions and are + therefore reserved to allow for the possibility of future adoption of + those extensions. + + FutureReservedWord :: one of + case debugger export super + catch default extends switch + class do finally throw + const enum import try + + Author: christine@netscape.com + Date: 12 november 1997 +*/ +var SECTION = "7.4.3-1-n"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Future Reserved Words"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +DESCRIPTION = "var case = true"; +EXPECTED = "error"; + +new TestCase( SECTION, "var case = true", "error", eval("var case = true") ); + +test(); diff --git a/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.3-10-n.js b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.3-10-n.js new file mode 100644 index 0000000000..8d717f323d --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.3-10-n.js @@ -0,0 +1,71 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '7.4.3-10-n.js'; + +/** + File Name: 7.4.3-10-n.js + ECMA Section: 7.4.3 + + Description: + The following words are used as keywords in proposed extensions and are + therefore reserved to allow for the possibility of future adoption of + those extensions. + + FutureReservedWord :: one of + case debugger export super + catch default extends switch + class do finally throw + const enum import try + + Author: christine@netscape.com + Date: 12 november 1997 +*/ +var SECTION = "7.4.3-10-n"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Future Reserved Words"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +DESCRIPTION = "var do = true"; +EXPECTED = "error"; + +new TestCase( SECTION, "var do = true", "error", eval("var do = true") ); + +test(); diff --git a/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.3-11-n.js b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.3-11-n.js new file mode 100644 index 0000000000..4e29e9c3af --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.3-11-n.js @@ -0,0 +1,71 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '7.4.3-11-n.js'; + +/** + File Name: 7.4.3-11-n.js + ECMA Section: 7.4.3 + + Description: + The following words are used as keywords in proposed extensions and are + therefore reserved to allow for the possibility of future adoption of + those extensions. + + FutureReservedWord :: one of + case debugger export super + catch default extends switch + class do finally throw + const enum import try + + Author: christine@netscape.com + Date: 12 november 1997 +*/ +var SECTION = "7.4.3-11-n"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Future Reserved Words"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +DESCRIPTION = "var finally = true"; +EXPECTED = "error"; + +new TestCase( SECTION, "var finally = true", "error", eval("var finally = true") ); + +test(); diff --git a/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.3-12-n.js b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.3-12-n.js new file mode 100644 index 0000000000..913fae905b --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.3-12-n.js @@ -0,0 +1,71 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '7.4.3-12-n.js'; + +/** + File Name: 7.4.3-12-n.js + ECMA Section: 7.4.3 + + Description: + The following words are used as keywords in proposed extensions and are + therefore reserved to allow for the possibility of future adoption of + those extensions. + + FutureReservedWord :: one of + case debugger export super + catch default extends switch + class do finally throw + const enum import try + + Author: christine@netscape.com + Date: 12 november 1997 +*/ +var SECTION = "7.4.3-12-n"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Future Reserved Words"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +DESCRIPTION = "var throw = true"; +EXPECTED = "error"; + +new TestCase( SECTION, "var throw = true", "error", eval("var throw = true") ); + +test(); diff --git a/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.3-13-n.js b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.3-13-n.js new file mode 100644 index 0000000000..c196ea2418 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.3-13-n.js @@ -0,0 +1,71 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '7.4.3-13-n.js'; + +/** + File Name: 7.4.3-13-n.js + ECMA Section: 7.4.3 + + Description: + The following words are used as keywords in proposed extensions and are + therefore reserved to allow for the possibility of future adoption of + those extensions. + + FutureReservedWord :: one of + case debugger export super + catch default extends switch + class do finally throw + const enum import try + + Author: christine@netscape.com + Date: 12 november 1997 +*/ +var SECTION = "7.4.3-13-n"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Future Reserved Words"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +DESCRIPTION = "var const = true"; +EXPECTED = "error"; + +new TestCase( SECTION, "var const = true", "error", eval("var const = true") ); + +test(); diff --git a/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.3-14-n.js b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.3-14-n.js new file mode 100644 index 0000000000..8d5af29ede --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.3-14-n.js @@ -0,0 +1,97 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '7.4.3-14-n.js'; + +/** + File Name: 7.4.3-14-n.js + ECMA Section: 7.4.3 + + Description: + The following words are used as keywords in proposed extensions and are + therefore reserved to allow for the possibility of future adoption of + those extensions. + + FutureReservedWord :: one of + case debugger export super + catch default extends switch + class do finally throw + const enum import try + + Author: christine@netscape.com + Date: 12 november 1997 +*/ +var SECTION = "7.4.3-14-n"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Future Reserved Words"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +var actual = 'no error'; +var prefValue; + +print("This test requires option javascript.options.strict enabled"); + +options('strict'); +options('werror'); + +try +{ + eval("var enum = true"); +} +catch(e) +{ + actual = 'error'; +} + +DESCRIPTION = "var enum = true"; +EXPECTED = "error"; + +// force exception since this is a negative test +if (actual == 'error') +{ + throw actual; +} + +new TestCase( SECTION, + "var enum = true", + "error", + actual ); + +test(); diff --git a/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.3-15-n.js b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.3-15-n.js new file mode 100644 index 0000000000..f855132d8a --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.3-15-n.js @@ -0,0 +1,97 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '7.4.3-15-n.js'; + +/** + File Name: 7.4.3-15-n.js + ECMA Section: 7.4.3 + + Description: + The following words are used as keywords in proposed extensions and are + therefore reserved to allow for the possibility of future adoption of + those extensions. + + FutureReservedWord :: one of + case debugger export super + catch default extends switch + class do finally throw + const enum import try + + Author: christine@netscape.com + Date: 12 november 1997 +*/ +var SECTION = "7.4.3-15-n"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Future Reserved Words"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +var actual = 'no error'; +var prefValue; + +print("This test requires option javascript.options.strict enabled"); + +options('strict'); +options('werror'); + +try +{ + eval("var import = true"); +} +catch(e) +{ + actual = 'error'; +} + +DESCRIPTION = "var import = true"; +EXPECTED = "error"; + +// force exception since this is a negative test +if (actual == 'error') +{ + throw actual; +} + +new TestCase( SECTION, + "var import = true", + "error", + actual ); + +test(); diff --git a/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.3-16-n.js b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.3-16-n.js new file mode 100644 index 0000000000..6d86d357f2 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.3-16-n.js @@ -0,0 +1,88 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '7.4.3-16-n.js'; + +/** + File Name: lexical-023.js + Corresponds To: 7.4.3-16-n.js + ECMA Section: 7.4.3 + Description: + The following words are used as keywords in proposed extensions and are + therefore reserved to allow for the possibility of future adoption of + those extensions. + + FutureReservedWord :: one of + case debugger export super + catch default extends switch + class do finally throw + const enum import try + + Author: christine@netscape.com + Date: 12 november 1997 +*/ +var SECTION = "lexical-023.js"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Future Reserved Words"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +var result = "Failed"; +var exception = "No exception thrown"; +var expect = "Passed"; +/* + try { + try = true; + } catch ( e ) { + result = expect; + exception = e.toString(); + } +*/ + +DESCRIPTION = "try = true"; +EXPECTED = "error"; + +new TestCase( + SECTION, + "try = true" + + " (threw " + exception +")", + "error", + eval("try = true") ); + +test(); diff --git a/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.3-2-n.js b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.3-2-n.js new file mode 100644 index 0000000000..fe5f6ffac1 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.3-2-n.js @@ -0,0 +1,71 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '7.4.3-2-n.js'; + +/** + File Name: 7.4.3-2-n.js + ECMA Section: 7.4.3 + + Description: + The following words are used as keywords in proposed extensions and are + therefore reserved to allow for the possibility of future adoption of + those extensions. + + FutureReservedWord :: one of + case debugger export super + catch default extends switch + class do finally throw + const enum import try + + Author: christine@netscape.com + Date: 12 november 1997 +*/ +var SECTION = "7.4.3-2-n"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Future Reserved Words"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +DESCRIPTION = "var debugger = true"; +EXPECTED = "error"; + +new TestCase( SECTION, "var debugger = true", "error", eval("var debugger = true") ); + +test(); diff --git a/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.3-3-n.js b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.3-3-n.js new file mode 100644 index 0000000000..b95c8ecbe0 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.3-3-n.js @@ -0,0 +1,71 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '7.4.3-3-n.js'; + +/** + File Name: 7.4.3-3-n.js + ECMA Section: 7.4.3 + + Description: + The following words are used as keywords in proposed extensions and are + therefore reserved to allow for the possibility of future adoption of + those extensions. + + FutureReservedWord :: one of + case debugger export super + catch default extends switch + class do finally throw + const enum import try + + Author: christine@netscape.com + Date: 12 november 1997 +*/ +var SECTION = "7.4.3-3-n"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Future Reserved Words"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +DESCRIPTION = "var export = true"; +EXPECTED = "error"; + +new TestCase( SECTION, "var export = true", "error", eval("var export = true") ); + +test(); diff --git a/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.3-4-n.js b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.3-4-n.js new file mode 100644 index 0000000000..b17b06f2e9 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.3-4-n.js @@ -0,0 +1,96 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '7.4.3-4-n.js'; + +/** + File Name: 7.4.3-4-n.js + ECMA Section: 7.4.3 + + Description: + The following words are used as keywords in proposed extensions and are + therefore reserved to allow for the possibility of future adoption of + those extensions. + + FutureReservedWord :: one of + case debugger export super + catch default extends switch + class do finally throw + const enum import try + + Author: christine@netscape.com + Date: 12 november 1997 +*/ +var SECTION = "7.4.3-4-n"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Future Reserved Words"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +var actual = 'no error'; +var prefValue; + +print("This test requires option javascript.options.strict enabled"); + +options('strict'); +options('werror'); + +try +{ + eval("var super = true"); +} +catch(e) +{ + actual = 'error'; +} + +DESCRIPTION = "var super = true" + EXPECTED = "error"; + +// force exception since this is a negative test +if (actual == 'error') +{ + throw actual; +} + +new TestCase( SECTION, + "var super = true", + "error", + actual ); +test(); diff --git a/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.3-5-n.js b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.3-5-n.js new file mode 100644 index 0000000000..d76025b3cc --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.3-5-n.js @@ -0,0 +1,71 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '7.4.3-5-n.js'; + +/** + File Name: 7.4.3-5-n.js + ECMA Section: 7.4.3 + + Description: + The following words are used as keywords in proposed extensions and are + therefore reserved to allow for the possibility of future adoption of + those extensions. + + FutureReservedWord :: one of + case debugger export super + catch default extends switch + class do finally throw + const enum import try + + Author: christine@netscape.com + Date: 12 november 1997 +*/ +var SECTION = "7.4.3-5-n"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Future Reserved Words"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +DESCRIPTION = "var catch = true"; +EXPECTED = "error"; + +new TestCase( SECTION, "var catch = true", "error", eval("var catch = true") ); + +test(); diff --git a/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.3-6-n.js b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.3-6-n.js new file mode 100644 index 0000000000..36ffe63977 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.3-6-n.js @@ -0,0 +1,71 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '7.4.3-6-n.js'; + +/** + File Name: 7.4.3-6-n.js + ECMA Section: 7.4.3 + + Description: + The following words are used as keywords in proposed extensions and are + therefore reserved to allow for the possibility of future adoption of + those extensions. + + FutureReservedWord :: one of + case debugger export super + catch default extends switch + class do finally throw + const enum import try + + Author: christine@netscape.com + Date: 12 november 1997 +*/ +var SECTION = "7.4.3-6-n"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Future Reserved Words"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +DESCRIPTION = "var default = true"; +EXPECTED = "error"; + +new TestCase( SECTION, "var default = true", "error", eval("var default = true") ); + +test(); diff --git a/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.3-7-n.js b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.3-7-n.js new file mode 100644 index 0000000000..31239d561a --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.3-7-n.js @@ -0,0 +1,97 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '7.4.3-7-n.js'; + +/** + File Name: 7.4.3-7-n.js + ECMA Section: 7.4.3 + + Description: + The following words are used as keywords in proposed extensions and are + therefore reserved to allow for the possibility of future adoption of + those extensions. + + FutureReservedWord :: one of + case debugger export super + catch default extends switch + class do finally throw + const enum import try + + Author: christine@netscape.com + Date: 12 november 1997 +*/ +var SECTION = "7.4.3-7-n"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Future Reserved Words"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +var actual = 'no error'; +var prefValue; + +print("This test requires option javascript.options.strict enabled"); + +options('strict'); +options('werror'); + +try +{ + eval("var extends = true"); +} +catch(e) +{ + actual = 'error'; +} + +DESCRIPTION = "var extends = true"; +EXPECTED = "error"; + +// force exception since this is a negative test +if (actual == 'error') +{ + throw actual; +} + +new TestCase( SECTION, + "var extends = true", + "error", + actual); + +test(); diff --git a/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.3-8-n.js b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.3-8-n.js new file mode 100644 index 0000000000..666abcc0c8 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.3-8-n.js @@ -0,0 +1,71 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '7.4.3-8-n.js'; + +/** + File Name: 7.4.3-8-n.js + ECMA Section: 7.4.3 + + Description: + The following words are used as keywords in proposed extensions and are + therefore reserved to allow for the possibility of future adoption of + those extensions. + + FutureReservedWord :: one of + case debugger export super + catch default extends switch + class do finally throw + const enum import try + + Author: christine@netscape.com + Date: 12 november 1997 +*/ +var SECTION = "7.4.3-9-n"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Future Reserved Words"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +DESCRIPTION = "var switch = true"; +EXPECTED = "error"; + +new TestCase( SECTION, "var switch = true", "error", eval("var switch = true") ); + +test(); diff --git a/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.3-9-n.js b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.3-9-n.js new file mode 100644 index 0000000000..4fee9c8c4a --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.3-9-n.js @@ -0,0 +1,98 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '7.4.3-9-n.js'; + +/** + File Name: 7.4.3-9-n.js + ECMA Section: 7.4.3 + + Description: + The following words are used as keywords in proposed extensions and are + therefore reserved to allow for the possibility of future adoption of + those extensions. + + FutureReservedWord :: one of + case debugger export super + catch default extends switch + class do finally throw + const enum import try + + Author: christine@netscape.com + Date: 12 november 1997 +*/ +var SECTION = "7.4.3-9-n"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Future Reserved Words"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +var actual = 'no error'; +var prefValue; + +DESCRIPTION = "var class = true"; +EXPECTED = "error"; + + +print("This test requires option javascript.options.strict enabled"); + +options('strict'); +options('werror'); + +try +{ + eval("var class = true"); +} +catch(e) +{ + actual = 'error'; +} + +// force exception since this is a negative test +if (actual == 'error') +{ + throw actual; +} + +new TestCase( SECTION, + "var class = true", + "error", + actual ); + +test(); diff --git a/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.5-1.js b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.5-1.js new file mode 100644 index 0000000000..57be9b63ee --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.5-1.js @@ -0,0 +1,62 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '7.5-1.js'; + +/** + File Name: 7.5-1.js + ECMA Section: 7.5 Identifiers + Description: Identifiers are of unlimited length + - can contain letters, a decimal digit, _, or $ + - the first character cannot be a decimal digit + - identifiers are case sensitive + + Author: christine@netscape.com + Date: 11 september 1997 +*/ +var SECTION = "7.5-1"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Identifiers"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +new TestCase( SECTION, "var $123 = 5", 5, eval("var $123 = 5;$123") ); +new TestCase( SECTION, "var _123 = 5", 5, eval("var _123 = 5;_123") ); + +test(); diff --git a/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.5-10-n.js b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.5-10-n.js new file mode 100644 index 0000000000..2561a3deda --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.5-10-n.js @@ -0,0 +1,64 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '7.5-10-n.js'; + +/** + File Name: 7.5-9-n.js + ECMA Section: 7.5 Identifiers + Description: Identifiers are of unlimited length + - can contain letters, a decimal digit, _, or $ + - the first character cannot be a decimal digit + - identifiers are case sensitive + + Author: christine@netscape.com + Date: 11 september 1997 +*/ +var SECTION = "7.5-9-n"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Identifiers"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +DESCRIPTION = "var 123=\"hi\""; +EXPECTED = "error"; + +new TestCase( SECTION, "var 123=\"hi\"", "error", eval("123 = \"hi\"; array[item] = 123;") ); + +test(); diff --git a/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.5-2-n.js b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.5-2-n.js new file mode 100644 index 0000000000..3401fe4891 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.5-2-n.js @@ -0,0 +1,64 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '7.5-2-n.js'; + +/** + File Name: 7.5-2-n.js + ECMA Section: 7.5 Identifiers + Description: Identifiers are of unlimited length + - can contain letters, a decimal digit, _, or $ + - the first character cannot be a decimal digit + - identifiers are case sensitive + + Author: christine@netscape.com + Date: 11 september 1997 +*/ +var SECTION = "7.5-2-n"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Identifiers"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +DESCRIPTION = "var 0abc"; +EXPECTED = "error"; + +new TestCase( SECTION, "var 0abc", "error", eval("var 0abc") ); + +test(); diff --git a/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.5-3-n.js b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.5-3-n.js new file mode 100644 index 0000000000..778c284cfb --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.5-3-n.js @@ -0,0 +1,64 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '7.5-3-n.js'; + +/** + File Name: 7.5-2.js + ECMA Section: 7.5 Identifiers + Description: Identifiers are of unlimited length + - can contain letters, a decimal digit, _, or $ + - the first character cannot be a decimal digit + - identifiers are case sensitive + + Author: christine@netscape.com + Date: 11 september 1997 +*/ +var SECTION = "7.5-3-n"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Identifiers"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +DESCRIPTION = "var 1abc"; +EXPECTED = "error"; + +new TestCase( SECTION, "var 1abc", "error", eval("var 1abc") ); + +test(); diff --git a/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.5-4-n.js b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.5-4-n.js new file mode 100644 index 0000000000..0f4b0fb2f1 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.5-4-n.js @@ -0,0 +1,64 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '7.5-4-n.js'; + +/** + File Name: 7.5-4-n.js + ECMA Section: 7.5 Identifiers + Description: Identifiers are of unlimited length + - can contain letters, a decimal digit, _, or $ + - the first character cannot be a decimal digit + - identifiers are case sensitive + + Author: christine@netscape.com + Date: 11 september 1997 +*/ +var SECTION = "7.5-4-n"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Identifiers"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +DESCRIPTION = "var 2abc"; +EXPECTED = "error"; + +new TestCase( SECTION, "var 2abc", "error", eval("var 2abc") ); + +test(); diff --git a/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.5-5-n.js b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.5-5-n.js new file mode 100644 index 0000000000..97a61e3449 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.5-5-n.js @@ -0,0 +1,64 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '7.5-5-n.js'; + +/** + File Name: 7.5-5-n.js + ECMA Section: 7.5 Identifiers + Description: Identifiers are of unlimited length + - can contain letters, a decimal digit, _, or $ + - the first character cannot be a decimal digit + - identifiers are case sensitive + + Author: christine@netscape.com + Date: 11 september 1997 +*/ +var SECTION = "7.5-5-n"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Identifiers"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +DESCRIPTION = "var 3abc"; +EXPECTED = "error"; + +new TestCase( SECTION, "var 3abc", "error", eval("var 3abc") ); + +test(); diff --git a/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.5-6.js b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.5-6.js new file mode 100644 index 0000000000..a53f4413eb --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.5-6.js @@ -0,0 +1,61 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '7.5-6.js'; + +/** + File Name: 7.5-6.js + ECMA Section: 7.5 Identifiers + Description: Identifiers are of unlimited length + - can contain letters, a decimal digit, _, or $ + - the first character cannot be a decimal digit + - identifiers are case sensitive + + Author: christine@netscape.com + Date: 11 september 1997 +*/ +var SECTION = "7.5-6"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Identifiers"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +new TestCase( SECTION, "var _0abc = 5", 5, eval("var _0abc = 5; _0abc") ); + +test(); diff --git a/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.5-7.js b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.5-7.js new file mode 100644 index 0000000000..c3446c6c0d --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.5-7.js @@ -0,0 +1,61 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '7.5-7.js'; + +/** + File Name: 7.5-7.js + ECMA Section: 7.5 Identifiers + Description: Identifiers are of unlimited length + - can contain letters, a decimal digit, _, or $ + - the first character cannot be a decimal digit + - identifiers are case sensitive + + Author: christine@netscape.com + Date: 11 september 1997 +*/ +var SECTION = "7.5-7"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Identifiers"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +new TestCase( SECTION, "var $0abc = 5", 5, eval("var $0abc = 5; $0abc") ); + +test(); diff --git a/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.5-8-n.js b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.5-8-n.js new file mode 100644 index 0000000000..e363666148 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.5-8-n.js @@ -0,0 +1,64 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '7.5-8-n.js'; + +/** + File Name: 7.5-8-n.js + ECMA Section: 7.5 Identifiers + Description: Identifiers are of unlimited length + - can contain letters, a decimal digit, _, or $ + - the first character cannot be a decimal digit + - identifiers are case sensitive + + Author: christine@netscape.com + Date: 11 september 1997 +*/ +var SECTION = "7.5-8-n"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Identifiers"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +DESCRIPTION = "var @0abc = 5; @0abc"; +EXPECTED = "error"; + +new TestCase( SECTION, "var @0abc = 5; @0abc", "error", eval("var @0abc = 5; @0abc") ); + +test(); diff --git a/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.5-9-n.js b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.5-9-n.js new file mode 100644 index 0000000000..c1ac68512a --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.5-9-n.js @@ -0,0 +1,64 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '7.5-9-n.js'; + +/** + File Name: 7.5-9-n.js + ECMA Section: 7.5 Identifiers + Description: Identifiers are of unlimited length + - can contain letters, a decimal digit, _, or $ + - the first character cannot be a decimal digit + - identifiers are case sensitive + + Author: christine@netscape.com + Date: 11 september 1997 +*/ +var SECTION = "7.5-9-n"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Identifiers"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +DESCRIPTION = "var 123=\"hi\""; +EXPECTED = "error"; + +new TestCase( SECTION, "var 123=\"hi\"", "error", eval("var 123 = \"hi\";array[item] = 123;") ); + +test(); diff --git a/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.6.js b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.6.js new file mode 100644 index 0000000000..091c74d7db --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.6.js @@ -0,0 +1,313 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '7.6.js'; + +/** + File Name: 7.6.js + ECMA Section: Punctuators + Description: + + This tests verifies that all ECMA punctutors are recognized as a + token separator, but does not attempt to verify the functionality + of any punctuator. + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + +var SECTION = "7.6"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Punctuators"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +// == +new TestCase( SECTION, + "var c,d;c==d", + true, + eval("var c,d;c==d") ); + +// = + +new TestCase( SECTION, + "var a=true;a", + true, + eval("var a=true;a") ); + +// > +new TestCase( SECTION, + "var a=true,b=false;a>b", + true, + eval("var a=true,b=false;a>b") ); + +// < +new TestCase( SECTION, + "var a=true,b=false;a= +new TestCase( SECTION, + "var a=0xFFFF,b=0XFFFE;a>=b", + true, + eval("var a=0xFFFF,b=0XFFFE;a>=b") ); + +// != +new TestCase( SECTION, + "var a=true,b=false;a!=b", + true, + eval("var a=true,b=false;a!=b") ); + +new TestCase( SECTION, + "var a=false,b=false;a!=b", + false, + eval("var a=false,b=false;a!=b") ); +// , +new TestCase( SECTION, + "var a=true,b=false;a,b", + false, + eval("var a=true,b=false;a,b") ); +// ! +new TestCase( SECTION, + "var a=true,b=false;!a", + false, + eval("var a=true,b=false;!a") ); + +// ~ +new TestCase( SECTION, + "var a=true;~a", + -2, + eval("var a=true;~a") ); +// ? +new TestCase( SECTION, + "var a=true; (a ? 'PASS' : '')", + "PASS", + eval("var a=true; (a ? 'PASS' : '')") ); + +// : + +new TestCase( SECTION, + "var a=false; (a ? 'FAIL' : 'PASS')", + "PASS", + eval("var a=false; (a ? 'FAIL' : 'PASS')") ); +// . + +new TestCase( SECTION, + "var a=Number;a.NaN", + NaN, + eval("var a=Number;a.NaN") ); + +// && +new TestCase( SECTION, + "var a=true,b=true;if(a&&b)'PASS';else'FAIL'", + "PASS", + eval("var a=true,b=true;if(a&&b)'PASS';else'FAIL'") ); + +// || +new TestCase( SECTION, + "var a=false,b=false;if(a||b)'FAIL';else'PASS'", + "PASS", + eval("var a=false,b=false;if(a||b)'FAIL';else'PASS'") ); +// ++ +new TestCase( SECTION, + "var a=false,b=false;++a", + 1, + eval("var a=false,b=false;++a") ); +// -- +new TestCase( SECTION, + "var a=true,b=false--a", + 0, + eval("var a=true,b=false;--a") ); +// + + +new TestCase( SECTION, + "var a=true,b=true;a+b", + 2, + eval("var a=true,b=true;a+b") ); +// - +new TestCase( SECTION, + "var a=true,b=true;a-b", + 0, + eval("var a=true,b=true;a-b") ); +// * +new TestCase( SECTION, + "var a=true,b=true;a*b", + 1, + eval("var a=true,b=true;a*b") ); +// / +new TestCase( SECTION, + "var a=true,b=true;a/b", + 1, + eval("var a=true,b=true;a/b") ); +// & +new TestCase( SECTION, + "var a=3,b=2;a&b", + 2, + eval("var a=3,b=2;a&b") ); +// | +new TestCase( SECTION, + "var a=4,b=3;a|b", + 7, + eval("var a=4,b=3;a|b") ); + +// | +new TestCase( SECTION, + "var a=4,b=3;a^b", + 7, + eval("var a=4,b=3;a^b") ); + +// % +new TestCase( SECTION, + "var a=4,b=3;a|b", + 1, + eval("var a=4,b=3;a%b") ); + +// << +new TestCase( SECTION, + "var a=4,b=3;a<> +new TestCase( SECTION, + "var a=4,b=1;a>>b", + 2, + eval("var a=4,b=1;a>>b") ); + +// >>> +new TestCase( SECTION, + "var a=1,b=1;a>>>b", + 0, + eval("var a=1,b=1;a>>>b") ); +// += +new TestCase( SECTION, + "var a=4,b=3;a+=b;a", + 7, + eval("var a=4,b=3;a+=b;a") ); + +// -= +new TestCase( SECTION, + "var a=4,b=3;a-=b;a", + 1, + eval("var a=4,b=3;a-=b;a") ); +// *= +new TestCase( SECTION, + "var a=4,b=3;a*=b;a", + 12, + eval("var a=4,b=3;a*=b;a") ); +// += +new TestCase( SECTION, + "var a=4,b=3;a+=b;a", + 7, + eval("var a=4,b=3;a+=b;a") ); +// /= +new TestCase( SECTION, + "var a=12,b=3;a/=b;a", + 4, + eval("var a=12,b=3;a/=b;a") ); + +// &= +new TestCase( SECTION, + "var a=4,b=5;a&=b;a", + 4, + eval("var a=4,b=5;a&=b;a") ); + +// |= +new TestCase( SECTION, + "var a=4,b=5;a&=b;a", + 5, + eval("var a=4,b=5;a|=b;a") ); +// ^= +new TestCase( SECTION, + "var a=4,b=5;a^=b;a", + 1, + eval("var a=4,b=5;a^=b;a") ); +// %= +new TestCase( SECTION, + "var a=12,b=5;a%=b;a", + 2, + eval("var a=12,b=5;a%=b;a") ); +// <<= +new TestCase( SECTION, + "var a=4,b=3;a<<=b;a", + 32, + eval("var a=4,b=3;a<<=b;a") ); + +// >> +new TestCase( SECTION, + "var a=4,b=1;a>>=b;a", + 2, + eval("var a=4,b=1;a>>=b;a") ); + +// >>> +new TestCase( SECTION, + "var a=1,b=1;a>>>=b;a", + 0, + eval("var a=1,b=1;a>>>=b;a") ); + +// () +new TestCase( SECTION, + "var a=4,b=3;(a)", + 4, + eval("var a=4,b=3;(a)") ); +// {} +new TestCase( SECTION, + "var a=4,b=3;{b}", + 3, + eval("var a=4,b=3;{b}") ); + +// [] +new TestCase( SECTION, + "var a=new Array('hi');a[0]", + "hi", + eval("var a=new Array('hi');a[0]") ); +// [] +new TestCase( SECTION, + ";", + void 0, + eval(";") ); +test(); + diff --git a/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.7.1.js b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.7.1.js new file mode 100644 index 0000000000..83325b5f32 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.7.1.js @@ -0,0 +1,64 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '7.7.1.js'; + +/** + File Name: 7.7.1.js + ECMA Section: 7.7.1 Null Literals + + Description: NullLiteral:: + null + + + The value of the null literal null is the sole value + of the Null type, namely null. + + Author: christine@netscape.com + Date: 21 october 1997 +*/ +var SECTION = "7.7.1"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Null Literals"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +new TestCase( SECTION, "null", null, null); + +test(); diff --git a/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.7.2.js b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.7.2.js new file mode 100644 index 0000000000..f021eb9b18 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.7.2.js @@ -0,0 +1,71 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '7.7.2.js'; + +/** + File Name: 7.7.2.js + ECMA Section: 7.7.2 Boolean Literals + + Description: BooleanLiteral:: + true + false + + The value of the Boolean literal true is a value of the + Boolean type, namely true. + + The value of the Boolean literal false is a value of the + Boolean type, namely false. + + Author: christine@netscape.com + Date: 16 september 1997 +*/ + +var SECTION = "7.7.2"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Boolean Literals"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +// StringLiteral:: "" and '' + +new TestCase( SECTION, "true", Boolean(true), true ); +new TestCase( SECTION, "false", Boolean(false), false ); + +test(); diff --git a/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.7.3-1.js b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.7.3-1.js new file mode 100644 index 0000000000..fb13b24e07 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.7.3-1.js @@ -0,0 +1,198 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '7.7.3-1.js'; + +/** + File Name: 7.7.3-1.js + ECMA Section: 7.7.3 Numeric Literals + + Description: A numeric literal stands for a value of the Number type + This value is determined in two steps: first a + mathematical value (MV) is derived from the literal; + second, this mathematical value is rounded, ideally + using IEEE 754 round-to-nearest mode, to a reprentable + value of of the number type. + + These test cases came from Waldemar. + + Author: christine@netscape.com + Date: 12 June 1998 +*/ + +var SECTION = "7.7.3-1"; +var VERSION = "ECMA_1"; +var TITLE = "Numeric Literals"; +var BUGNUMBER="122877"; + +startTest(); + +writeHeaderToLog( SECTION + " "+ TITLE); + +new TestCase( SECTION, + "0x12345678", + 305419896, + 0x12345678 ); + +new TestCase( SECTION, + "0x80000000", + 2147483648, + 0x80000000 ); + +new TestCase( SECTION, + "0xffffffff", + 4294967295, + 0xffffffff ); + +new TestCase( SECTION, + "0x100000000", + 4294967296, + 0x100000000 ); + +new TestCase( SECTION, + "077777777777777777", + 2251799813685247, + 077777777777777777 ); + +new TestCase( SECTION, + "077777777777777776", + 2251799813685246, + 077777777777777776 ); + +new TestCase( SECTION, + "0x1fffffffffffff", + 9007199254740991, + 0x1fffffffffffff ); + +new TestCase( SECTION, + "0x20000000000000", + 9007199254740992, + 0x20000000000000 ); + +new TestCase( SECTION, + "0x20123456789abc", + 9027215253084860, + 0x20123456789abc ); + +new TestCase( SECTION, + "0x20123456789abd", + 9027215253084860, + 0x20123456789abd ); + +new TestCase( SECTION, + "0x20123456789abe", + 9027215253084862, + 0x20123456789abe ); + +new TestCase( SECTION, + "0x20123456789abf", + 9027215253084864, + 0x20123456789abf ); + +new TestCase( SECTION, + "0x1000000000000080", + 1152921504606847000, + 0x1000000000000080 ); + +new TestCase( SECTION, + "0x1000000000000081", + 1152921504606847200, + 0x1000000000000081 ); + +new TestCase( SECTION, + "0x1000000000000100", + 1152921504606847200, + 0x1000000000000100 ); + +new TestCase( SECTION, + "0x100000000000017f", + 1152921504606847200, + 0x100000000000017f ); + +new TestCase( SECTION, + "0x1000000000000180", + 1152921504606847500, + 0x1000000000000180 ); + +new TestCase( SECTION, + "0x1000000000000181", + 1152921504606847500, + 0x1000000000000181 ); + +new TestCase( SECTION, + "0x10000000000001f0", + 1152921504606847500, + 0x10000000000001f0 ); + +new TestCase( SECTION, + "0x1000000000000200", + 1152921504606847500, + 0x1000000000000200 ); + +new TestCase( SECTION, + "0x100000000000027f", + 1152921504606847500, + 0x100000000000027f ); + +new TestCase( SECTION, + "0x1000000000000280", + 1152921504606847500, + 0x1000000000000280 ); + +new TestCase( SECTION, + "0x1000000000000281", + 1152921504606847700, + 0x1000000000000281 ); + +new TestCase( SECTION, + "0x10000000000002ff", + 1152921504606847700, + 0x10000000000002ff ); + +new TestCase( SECTION, + "0x1000000000000300", + 1152921504606847700, + 0x1000000000000300 ); + +new TestCase( SECTION, + "0x10000000000000000", + 18446744073709552000, + 0x10000000000000000 ); + +test(); + diff --git a/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.7.3-2.js b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.7.3-2.js new file mode 100644 index 0000000000..8fbe16cb8f --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.7.3-2.js @@ -0,0 +1,93 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '7.7.3-2.js'; + +/** + File Name: 7.7.3-2.js + ECMA Section: 7.7.3 Numeric Literals + + Description: + + This is a regression test for + http://scopus.mcom.com/bugsplat/show_bug.cgi?id=122884 + + Waldemar's comments: + + A numeric literal that starts with either '08' or '09' is interpreted as a + decimal literal; it should be an error instead. (Strictly speaking, according + to ECMA v1 such literals should be interpreted as two integers -- a zero + followed by a decimal number whose first digit is 8 or 9, but this is a bug in + ECMA that will be fixed in v2. In any case, there is no place in the grammar + where two consecutive numbers would be legal.) + + Author: christine@netscape.com + Date: 15 june 1998 + +*/ +var SECTION = "7.7.3-2"; +var VERSION = "ECMA_1"; +var TITLE = "Numeric Literals"; +var BUGNUMBER="122884"; + +startTest(); + +writeHeaderToLog( SECTION + " "+ TITLE); + +new TestCase( SECTION, + "9", + 9, + 9 ); + +new TestCase( SECTION, + "09", + 9, + 09 ); + +new TestCase( SECTION, + "099", + 99, + 099 ); + + +new TestCase( SECTION, + "077", + 63, + 077 ); + +test(); diff --git a/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.7.3.js b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.7.3.js new file mode 100644 index 0000000000..9ccb912752 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.7.3.js @@ -0,0 +1,331 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '7.7.3.js'; + +/** + File Name: 7.7.3.js + ECMA Section: 7.7.3 Numeric Literals + + Description: A numeric literal stands for a value of the Number type + This value is determined in two steps: first a + mathematical value (MV) is derived from the literal; + second, this mathematical value is rounded, ideally + using IEEE 754 round-to-nearest mode, to a reprentable + value of of the number type. + + Author: christine@netscape.com + Date: 16 september 1997 +*/ +var SECTION = "7.7.3"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Numeric Literals"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +new TestCase( SECTION, "0", 0, 0 ); +new TestCase( SECTION, "1", 1, 1 ); +new TestCase( SECTION, "2", 2, 2 ); +new TestCase( SECTION, "3", 3, 3 ); +new TestCase( SECTION, "4", 4, 4 ); +new TestCase( SECTION, "5", 5, 5 ); +new TestCase( SECTION, "6", 6, 6 ); +new TestCase( SECTION, "7", 7, 7 ); +new TestCase( SECTION, "8", 8, 8 ); +new TestCase( SECTION, "9", 9, 9 ); + +new TestCase( SECTION, "0.", 0, 0. ); +new TestCase( SECTION, "1.", 1, 1. ); +new TestCase( SECTION, "2.", 2, 2. ); +new TestCase( SECTION, "3.", 3, 3. ); +new TestCase( SECTION, "4.", 4, 4. ); + +new TestCase( SECTION, "0.e0", 0, 0.e0 ); +new TestCase( SECTION, "1.e1", 10, 1.e1 ); +new TestCase( SECTION, "2.e2", 200, 2.e2 ); +new TestCase( SECTION, "3.e3", 3000, 3.e3 ); +new TestCase( SECTION, "4.e4", 40000, 4.e4 ); + +new TestCase( SECTION, "0.1e0", .1, 0.1e0 ); +new TestCase( SECTION, "1.1e1", 11, 1.1e1 ); +new TestCase( SECTION, "2.2e2", 220, 2.2e2 ); +new TestCase( SECTION, "3.3e3", 3300, 3.3e3 ); +new TestCase( SECTION, "4.4e4", 44000, 4.4e4 ); + +new TestCase( SECTION, ".1e0", .1, .1e0 ); +new TestCase( SECTION, ".1e1", 1, .1e1 ); +new TestCase( SECTION, ".2e2", 20, .2e2 ); +new TestCase( SECTION, ".3e3", 300, .3e3 ); +new TestCase( SECTION, ".4e4", 4000, .4e4 ); + +new TestCase( SECTION, "0e0", 0, 0e0 ); +new TestCase( SECTION, "1e1", 10, 1e1 ); +new TestCase( SECTION, "2e2", 200, 2e2 ); +new TestCase( SECTION, "3e3", 3000, 3e3 ); +new TestCase( SECTION, "4e4", 40000, 4e4 ); + +new TestCase( SECTION, "0e0", 0, 0e0 ); +new TestCase( SECTION, "1e1", 10, 1e1 ); +new TestCase( SECTION, "2e2", 200, 2e2 ); +new TestCase( SECTION, "3e3", 3000, 3e3 ); +new TestCase( SECTION, "4e4", 40000, 4e4 ); + +new TestCase( SECTION, "0E0", 0, 0E0 ); +new TestCase( SECTION, "1E1", 10, 1E1 ); +new TestCase( SECTION, "2E2", 200, 2E2 ); +new TestCase( SECTION, "3E3", 3000, 3E3 ); +new TestCase( SECTION, "4E4", 40000, 4E4 ); + +new TestCase( SECTION, "1.e-1", 0.1, 1.e-1 ); +new TestCase( SECTION, "2.e-2", 0.02, 2.e-2 ); +new TestCase( SECTION, "3.e-3", 0.003, 3.e-3 ); +new TestCase( SECTION, "4.e-4", 0.0004, 4.e-4 ); + +new TestCase( SECTION, "0.1e-0", .1, 0.1e-0 ); +new TestCase( SECTION, "1.1e-1", 0.11, 1.1e-1 ); +new TestCase( SECTION, "2.2e-2", .022, 2.2e-2 ); +new TestCase( SECTION, "3.3e-3", .0033, 3.3e-3 ); +new TestCase( SECTION, "4.4e-4", .00044, 4.4e-4 ); + +new TestCase( SECTION, ".1e-0", .1, .1e-0 ); +new TestCase( SECTION, ".1e-1", .01, .1e-1 ); +new TestCase( SECTION, ".2e-2", .002, .2e-2 ); +new TestCase( SECTION, ".3e-3", .0003, .3e-3 ); +new TestCase( SECTION, ".4e-4", .00004, .4e-4 ); + +new TestCase( SECTION, "1.e+1", 10, 1.e+1 ); +new TestCase( SECTION, "2.e+2", 200, 2.e+2 ); +new TestCase( SECTION, "3.e+3", 3000, 3.e+3 ); +new TestCase( SECTION, "4.e+4", 40000, 4.e+4 ); + +new TestCase( SECTION, "0.1e+0", .1, 0.1e+0 ); +new TestCase( SECTION, "1.1e+1", 11, 1.1e+1 ); +new TestCase( SECTION, "2.2e+2", 220, 2.2e+2 ); +new TestCase( SECTION, "3.3e+3", 3300, 3.3e+3 ); +new TestCase( SECTION, "4.4e+4", 44000, 4.4e+4 ); + +new TestCase( SECTION, ".1e+0", .1, .1e+0 ); +new TestCase( SECTION, ".1e+1", 1, .1e+1 ); +new TestCase( SECTION, ".2e+2", 20, .2e+2 ); +new TestCase( SECTION, ".3e+3", 300, .3e+3 ); +new TestCase( SECTION, ".4e+4", 4000, .4e+4 ); + +new TestCase( SECTION, "0x0", 0, 0x0 ); +new TestCase( SECTION, "0x1", 1, 0x1 ); +new TestCase( SECTION, "0x2", 2, 0x2 ); +new TestCase( SECTION, "0x3", 3, 0x3 ); +new TestCase( SECTION, "0x4", 4, 0x4 ); +new TestCase( SECTION, "0x5", 5, 0x5 ); +new TestCase( SECTION, "0x6", 6, 0x6 ); +new TestCase( SECTION, "0x7", 7, 0x7 ); +new TestCase( SECTION, "0x8", 8, 0x8 ); +new TestCase( SECTION, "0x9", 9, 0x9 ); +new TestCase( SECTION, "0xa", 10, 0xa ); +new TestCase( SECTION, "0xb", 11, 0xb ); +new TestCase( SECTION, "0xc", 12, 0xc ); +new TestCase( SECTION, "0xd", 13, 0xd ); +new TestCase( SECTION, "0xe", 14, 0xe ); +new TestCase( SECTION, "0xf", 15, 0xf ); + +new TestCase( SECTION, "0X0", 0, 0X0 ); +new TestCase( SECTION, "0X1", 1, 0X1 ); +new TestCase( SECTION, "0X2", 2, 0X2 ); +new TestCase( SECTION, "0X3", 3, 0X3 ); +new TestCase( SECTION, "0X4", 4, 0X4 ); +new TestCase( SECTION, "0X5", 5, 0X5 ); +new TestCase( SECTION, "0X6", 6, 0X6 ); +new TestCase( SECTION, "0X7", 7, 0X7 ); +new TestCase( SECTION, "0X8", 8, 0X8 ); +new TestCase( SECTION, "0X9", 9, 0X9 ); +new TestCase( SECTION, "0Xa", 10, 0Xa ); +new TestCase( SECTION, "0Xb", 11, 0Xb ); +new TestCase( SECTION, "0Xc", 12, 0Xc ); +new TestCase( SECTION, "0Xd", 13, 0Xd ); +new TestCase( SECTION, "0Xe", 14, 0Xe ); +new TestCase( SECTION, "0Xf", 15, 0Xf ); + +new TestCase( SECTION, "0x0", 0, 0x0 ); +new TestCase( SECTION, "0x1", 1, 0x1 ); +new TestCase( SECTION, "0x2", 2, 0x2 ); +new TestCase( SECTION, "0x3", 3, 0x3 ); +new TestCase( SECTION, "0x4", 4, 0x4 ); +new TestCase( SECTION, "0x5", 5, 0x5 ); +new TestCase( SECTION, "0x6", 6, 0x6 ); +new TestCase( SECTION, "0x7", 7, 0x7 ); +new TestCase( SECTION, "0x8", 8, 0x8 ); +new TestCase( SECTION, "0x9", 9, 0x9 ); +new TestCase( SECTION, "0xA", 10, 0xA ); +new TestCase( SECTION, "0xB", 11, 0xB ); +new TestCase( SECTION, "0xC", 12, 0xC ); +new TestCase( SECTION, "0xD", 13, 0xD ); +new TestCase( SECTION, "0xE", 14, 0xE ); +new TestCase( SECTION, "0xF", 15, 0xF ); + +new TestCase( SECTION, "0X0", 0, 0X0 ); +new TestCase( SECTION, "0X1", 1, 0X1 ); +new TestCase( SECTION, "0X2", 2, 0X2 ); +new TestCase( SECTION, "0X3", 3, 0X3 ); +new TestCase( SECTION, "0X4", 4, 0X4 ); +new TestCase( SECTION, "0X5", 5, 0X5 ); +new TestCase( SECTION, "0X6", 6, 0X6 ); +new TestCase( SECTION, "0X7", 7, 0X7 ); +new TestCase( SECTION, "0X8", 8, 0X8 ); +new TestCase( SECTION, "0X9", 9, 0X9 ); +new TestCase( SECTION, "0XA", 10, 0XA ); +new TestCase( SECTION, "0XB", 11, 0XB ); +new TestCase( SECTION, "0XC", 12, 0XC ); +new TestCase( SECTION, "0XD", 13, 0XD ); +new TestCase( SECTION, "0XE", 14, 0XE ); +new TestCase( SECTION, "0XF", 15, 0XF ); + + +new TestCase( SECTION, "00", 0, 00 ); +new TestCase( SECTION, "01", 1, 01 ); +new TestCase( SECTION, "02", 2, 02 ); +new TestCase( SECTION, "03", 3, 03 ); +new TestCase( SECTION, "04", 4, 04 ); +new TestCase( SECTION, "05", 5, 05 ); +new TestCase( SECTION, "06", 6, 06 ); +new TestCase( SECTION, "07", 7, 07 ); + +new TestCase( SECTION, "000", 0, 000 ); +new TestCase( SECTION, "011", 9, 011 ); +new TestCase( SECTION, "022", 18, 022 ); +new TestCase( SECTION, "033", 27, 033 ); +new TestCase( SECTION, "044", 36, 044 ); +new TestCase( SECTION, "055", 45, 055 ); +new TestCase( SECTION, "066", 54, 066 ); +new TestCase( SECTION, "077", 63, 077 ); + +new TestCase( SECTION, "0.00000000001", 0.00000000001, 0.00000000001 ); +new TestCase( SECTION, "0.00000000001e-2", 0.0000000000001, 0.00000000001e-2 ); + + +new TestCase( SECTION, + "123456789012345671.9999", + "123456789012345660", + 123456789012345671.9999 +""); +new TestCase( SECTION, + "123456789012345672", + "123456789012345660", + 123456789012345672 +""); + +new TestCase( SECTION, + "123456789012345672.000000000000000000000000000", + "123456789012345660", + 123456789012345672.000000000000000000000000000 +""); + +new TestCase( SECTION, + "123456789012345672.01", + "123456789012345680", + 123456789012345672.01 +""); + +new TestCase( SECTION, + "123456789012345672.000000000000000000000000001+'' == 123456789012345680 || 123456789012345660", + true, + ( 123456789012345672.00000000000000000000000000 +"" == 1234567890 * 100000000 + 12345680 ) + || + ( 123456789012345672.00000000000000000000000000 +"" == 1234567890 * 100000000 + 12345660) ); + +new TestCase( SECTION, + "123456789012345673", + "123456789012345680", + 123456789012345673 +"" ); + +new TestCase( SECTION, + "-123456789012345671.9999", + "-123456789012345660", + -123456789012345671.9999 +"" ); + +new TestCase( SECTION, + "-123456789012345672", + "-123456789012345660", + -123456789012345672+""); + +new TestCase( SECTION, + "-123456789012345672.000000000000000000000000000", + "-123456789012345660", + -123456789012345672.000000000000000000000000000 +""); + +new TestCase( SECTION, + "-123456789012345672.01", + "-123456789012345680", + -123456789012345672.01 +"" ); + +new TestCase( SECTION, + "-123456789012345672.000000000000000000000000001 == -123456789012345680 or -123456789012345660", + true, + (-123456789012345672.000000000000000000000000001 +"" == -1234567890 * 100000000 -12345680) + || + (-123456789012345672.000000000000000000000000001 +"" == -1234567890 * 100000000 -12345660)); + +new TestCase( SECTION, + -123456789012345673, + "-123456789012345680", + -123456789012345673 +""); + +new TestCase( SECTION, + "12345678901234567890", + "12345678901234567000", + 12345678901234567890 +"" ); + + +/* + new TestCase( SECTION, "12345678901234567", "12345678901234567", 12345678901234567+"" ); + new TestCase( SECTION, "123456789012345678", "123456789012345678", 123456789012345678+"" ); + new TestCase( SECTION, "1234567890123456789", "1234567890123456789", 1234567890123456789+"" ); + new TestCase( SECTION, "12345678901234567890", "12345678901234567890", 12345678901234567890+"" ); + new TestCase( SECTION, "123456789012345678900", "123456789012345678900", 123456789012345678900+"" ); + new TestCase( SECTION, "1234567890123456789000", "1234567890123456789000", 1234567890123456789000+"" ); +*/ +new TestCase( SECTION, "0x1", 1, 0x1 ); +new TestCase( SECTION, "0x10", 16, 0x10 ); +new TestCase( SECTION, "0x100", 256, 0x100 ); +new TestCase( SECTION, "0x1000", 4096, 0x1000 ); +new TestCase( SECTION, "0x10000", 65536, 0x10000 ); +new TestCase( SECTION, "0x100000", 1048576, 0x100000 ); +new TestCase( SECTION, "0x1000000", 16777216, 0x1000000 ); +new TestCase( SECTION, "0x10000000", 268435456, 0x10000000 ); +/* + new TestCase( SECTION, "0x100000000", 4294967296, 0x100000000 ); + new TestCase( SECTION, "0x1000000000", 68719476736, 0x1000000000 ); + new TestCase( SECTION, "0x10000000000", 1099511627776, 0x10000000000 ); +*/ + +test(); diff --git a/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.7.4.js b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.7.4.js new file mode 100644 index 0000000000..015a385220 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.7.4.js @@ -0,0 +1,269 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '7.7.4.js'; + +/** + File Name: 7.7.4.js + ECMA Section: 7.7.4 String Literals + + Description: A string literal is zero or more characters enclosed in + single or double quotes. Each character may be + represented by an escape sequence. + + + Author: christine@netscape.com + Date: 16 september 1997 +*/ + +var SECTION = "7.7.4"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "String Literals"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +// StringLiteral:: "" and '' + +new TestCase( SECTION, "\"\"", "", "" ); +new TestCase( SECTION, "\'\'", "", '' ); + +// DoubleStringCharacters:: DoubleStringCharacter :: EscapeSequence :: CharacterEscapeSequence +new TestCase( SECTION, "\\\"", String.fromCharCode(0x0022), "\"" ); +new TestCase( SECTION, "\\\'", String.fromCharCode(0x0027), "\'" ); +new TestCase( SECTION, "\\", String.fromCharCode(0x005C), "\\" ); +new TestCase( SECTION, "\\b", String.fromCharCode(0x0008), "\b" ); +new TestCase( SECTION, "\\f", String.fromCharCode(0x000C), "\f" ); +new TestCase( SECTION, "\\n", String.fromCharCode(0x000A), "\n" ); +new TestCase( SECTION, "\\r", String.fromCharCode(0x000D), "\r" ); +new TestCase( SECTION, "\\t", String.fromCharCode(0x0009), "\t" ); +new TestCase( SECTION, "\\v", String.fromCharCode(0x000B), "\v" ); + +// DoubleStringCharacters:DoubleStringCharacter::EscapeSequence::OctalEscapeSequence + +new TestCase( SECTION, "\\00", String.fromCharCode(0x0000), "\00" ); +new TestCase( SECTION, "\\01", String.fromCharCode(0x0001), "\01" ); +new TestCase( SECTION, "\\02", String.fromCharCode(0x0002), "\02" ); +new TestCase( SECTION, "\\03", String.fromCharCode(0x0003), "\03" ); +new TestCase( SECTION, "\\04", String.fromCharCode(0x0004), "\04" ); +new TestCase( SECTION, "\\05", String.fromCharCode(0x0005), "\05" ); +new TestCase( SECTION, "\\06", String.fromCharCode(0x0006), "\06" ); +new TestCase( SECTION, "\\07", String.fromCharCode(0x0007), "\07" ); + +new TestCase( SECTION, "\\010", String.fromCharCode(0x0008), "\010" ); +new TestCase( SECTION, "\\011", String.fromCharCode(0x0009), "\011" ); +new TestCase( SECTION, "\\012", String.fromCharCode(0x000A), "\012" ); +new TestCase( SECTION, "\\013", String.fromCharCode(0x000B), "\013" ); +new TestCase( SECTION, "\\014", String.fromCharCode(0x000C), "\014" ); +new TestCase( SECTION, "\\015", String.fromCharCode(0x000D), "\015" ); +new TestCase( SECTION, "\\016", String.fromCharCode(0x000E), "\016" ); +new TestCase( SECTION, "\\017", String.fromCharCode(0x000F), "\017" ); +new TestCase( SECTION, "\\020", String.fromCharCode(0x0010), "\020" ); +new TestCase( SECTION, "\\042", String.fromCharCode(0x0022), "\042" ); + +new TestCase( SECTION, "\\0", String.fromCharCode(0x0000), "\0" ); +new TestCase( SECTION, "\\1", String.fromCharCode(0x0001), "\1" ); +new TestCase( SECTION, "\\2", String.fromCharCode(0x0002), "\2" ); +new TestCase( SECTION, "\\3", String.fromCharCode(0x0003), "\3" ); +new TestCase( SECTION, "\\4", String.fromCharCode(0x0004), "\4" ); +new TestCase( SECTION, "\\5", String.fromCharCode(0x0005), "\5" ); +new TestCase( SECTION, "\\6", String.fromCharCode(0x0006), "\6" ); +new TestCase( SECTION, "\\7", String.fromCharCode(0x0007), "\7" ); + +new TestCase( SECTION, "\\10", String.fromCharCode(0x0008), "\10" ); +new TestCase( SECTION, "\\11", String.fromCharCode(0x0009), "\11" ); +new TestCase( SECTION, "\\12", String.fromCharCode(0x000A), "\12" ); +new TestCase( SECTION, "\\13", String.fromCharCode(0x000B), "\13" ); +new TestCase( SECTION, "\\14", String.fromCharCode(0x000C), "\14" ); +new TestCase( SECTION, "\\15", String.fromCharCode(0x000D), "\15" ); +new TestCase( SECTION, "\\16", String.fromCharCode(0x000E), "\16" ); +new TestCase( SECTION, "\\17", String.fromCharCode(0x000F), "\17" ); +new TestCase( SECTION, "\\20", String.fromCharCode(0x0010), "\20" ); +new TestCase( SECTION, "\\42", String.fromCharCode(0x0022), "\42" ); + +new TestCase( SECTION, "\\000", String.fromCharCode(0), "\000" ); +new TestCase( SECTION, "\\111", String.fromCharCode(73), "\111" ); +new TestCase( SECTION, "\\222", String.fromCharCode(146), "\222" ); +new TestCase( SECTION, "\\333", String.fromCharCode(219), "\333" ); + +// following line commented out as it causes a compile time error +// new TestCase( SECTION, "\\444", "444", "\444" ); + +// DoubleStringCharacters:DoubleStringCharacter::EscapeSequence::HexEscapeSequence +/* + new TestCase( SECTION, "\\x0", String.fromCharCode(0), "\x0" ); + new TestCase( SECTION, "\\x1", String.fromCharCode(1), "\x1" ); + new TestCase( SECTION, "\\x2", String.fromCharCode(2), "\x2" ); + new TestCase( SECTION, "\\x3", String.fromCharCode(3), "\x3" ); + new TestCase( SECTION, "\\x4", String.fromCharCode(4), "\x4" ); + new TestCase( SECTION, "\\x5", String.fromCharCode(5), "\x5" ); + new TestCase( SECTION, "\\x6", String.fromCharCode(6), "\x6" ); + new TestCase( SECTION, "\\x7", String.fromCharCode(7), "\x7" ); + new TestCase( SECTION, "\\x8", String.fromCharCode(8), "\x8" ); + new TestCase( SECTION, "\\x9", String.fromCharCode(9), "\x9" ); + new TestCase( SECTION, "\\xA", String.fromCharCode(10), "\xA" ); + new TestCase( SECTION, "\\xB", String.fromCharCode(11), "\xB" ); + new TestCase( SECTION, "\\xC", String.fromCharCode(12), "\xC" ); + new TestCase( SECTION, "\\xD", String.fromCharCode(13), "\xD" ); + new TestCase( SECTION, "\\xE", String.fromCharCode(14), "\xE" ); + new TestCase( SECTION, "\\xF", String.fromCharCode(15), "\xF" ); + +*/ +new TestCase( SECTION, "\\xF0", String.fromCharCode(240), "\xF0" ); +new TestCase( SECTION, "\\xE1", String.fromCharCode(225), "\xE1" ); +new TestCase( SECTION, "\\xD2", String.fromCharCode(210), "\xD2" ); +new TestCase( SECTION, "\\xC3", String.fromCharCode(195), "\xC3" ); +new TestCase( SECTION, "\\xB4", String.fromCharCode(180), "\xB4" ); +new TestCase( SECTION, "\\xA5", String.fromCharCode(165), "\xA5" ); +new TestCase( SECTION, "\\x96", String.fromCharCode(150), "\x96" ); +new TestCase( SECTION, "\\x87", String.fromCharCode(135), "\x87" ); +new TestCase( SECTION, "\\x78", String.fromCharCode(120), "\x78" ); +new TestCase( SECTION, "\\x69", String.fromCharCode(105), "\x69" ); +new TestCase( SECTION, "\\x5A", String.fromCharCode(90), "\x5A" ); +new TestCase( SECTION, "\\x4B", String.fromCharCode(75), "\x4B" ); +new TestCase( SECTION, "\\x3C", String.fromCharCode(60), "\x3C" ); +new TestCase( SECTION, "\\x2D", String.fromCharCode(45), "\x2D" ); +new TestCase( SECTION, "\\x1E", String.fromCharCode(30), "\x1E" ); +new TestCase( SECTION, "\\x0F", String.fromCharCode(15), "\x0F" ); + +// string literals only take up to two hext digits. therefore, the third character in this string +// should be interpreted as a StringCharacter and not part of the HextEscapeSequence + +new TestCase( SECTION, "\\xF0F", String.fromCharCode(240)+"F", "\xF0F" ); +new TestCase( SECTION, "\\xE1E", String.fromCharCode(225)+"E", "\xE1E" ); +new TestCase( SECTION, "\\xD2D", String.fromCharCode(210)+"D", "\xD2D" ); +new TestCase( SECTION, "\\xC3C", String.fromCharCode(195)+"C", "\xC3C" ); +new TestCase( SECTION, "\\xB4B", String.fromCharCode(180)+"B", "\xB4B" ); +new TestCase( SECTION, "\\xA5A", String.fromCharCode(165)+"A", "\xA5A" ); +new TestCase( SECTION, "\\x969", String.fromCharCode(150)+"9", "\x969" ); +new TestCase( SECTION, "\\x878", String.fromCharCode(135)+"8", "\x878" ); +new TestCase( SECTION, "\\x787", String.fromCharCode(120)+"7", "\x787" ); +new TestCase( SECTION, "\\x696", String.fromCharCode(105)+"6", "\x696" ); +new TestCase( SECTION, "\\x5A5", String.fromCharCode(90)+"5", "\x5A5" ); +new TestCase( SECTION, "\\x4B4", String.fromCharCode(75)+"4", "\x4B4" ); +new TestCase( SECTION, "\\x3C3", String.fromCharCode(60)+"3", "\x3C3" ); +new TestCase( SECTION, "\\x2D2", String.fromCharCode(45)+"2", "\x2D2" ); +new TestCase( SECTION, "\\x1E1", String.fromCharCode(30)+"1", "\x1E1" ); +new TestCase( SECTION, "\\x0F0", String.fromCharCode(15)+"0", "\x0F0" ); + +// G is out of hex range + +new TestCase( SECTION, "\\xG", "xG", "\xG" ); +new TestCase( SECTION, "\\xCG", "xCG", "\xCG" ); + +// DoubleStringCharacter::EscapeSequence::CharacterEscapeSequence::\ NonEscapeCharacter +new TestCase( SECTION, "\\a", "a", "\a" ); +new TestCase( SECTION, "\\c", "c", "\c" ); +new TestCase( SECTION, "\\d", "d", "\d" ); +new TestCase( SECTION, "\\e", "e", "\e" ); +new TestCase( SECTION, "\\g", "g", "\g" ); +new TestCase( SECTION, "\\h", "h", "\h" ); +new TestCase( SECTION, "\\i", "i", "\i" ); +new TestCase( SECTION, "\\j", "j", "\j" ); +new TestCase( SECTION, "\\k", "k", "\k" ); +new TestCase( SECTION, "\\l", "l", "\l" ); +new TestCase( SECTION, "\\m", "m", "\m" ); +new TestCase( SECTION, "\\o", "o", "\o" ); +new TestCase( SECTION, "\\p", "p", "\p" ); +new TestCase( SECTION, "\\q", "q", "\q" ); +new TestCase( SECTION, "\\s", "s", "\s" ); +new TestCase( SECTION, "\\u", "u", "\u" ); + +new TestCase( SECTION, "\\w", "w", "\w" ); +new TestCase( SECTION, "\\x", "x", "\x" ); +new TestCase( SECTION, "\\y", "y", "\y" ); +new TestCase( SECTION, "\\z", "z", "\z" ); +new TestCase( SECTION, "\\9", "9", "\9" ); + +new TestCase( SECTION, "\\A", "A", "\A" ); +new TestCase( SECTION, "\\B", "B", "\B" ); +new TestCase( SECTION, "\\C", "C", "\C" ); +new TestCase( SECTION, "\\D", "D", "\D" ); +new TestCase( SECTION, "\\E", "E", "\E" ); +new TestCase( SECTION, "\\F", "F", "\F" ); +new TestCase( SECTION, "\\G", "G", "\G" ); +new TestCase( SECTION, "\\H", "H", "\H" ); +new TestCase( SECTION, "\\I", "I", "\I" ); +new TestCase( SECTION, "\\J", "J", "\J" ); +new TestCase( SECTION, "\\K", "K", "\K" ); +new TestCase( SECTION, "\\L", "L", "\L" ); +new TestCase( SECTION, "\\M", "M", "\M" ); +new TestCase( SECTION, "\\N", "N", "\N" ); +new TestCase( SECTION, "\\O", "O", "\O" ); +new TestCase( SECTION, "\\P", "P", "\P" ); +new TestCase( SECTION, "\\Q", "Q", "\Q" ); +new TestCase( SECTION, "\\R", "R", "\R" ); +new TestCase( SECTION, "\\S", "S", "\S" ); +new TestCase( SECTION, "\\T", "T", "\T" ); +new TestCase( SECTION, "\\U", "U", "\U" ); +new TestCase( SECTION, "\\V", "V", "\V" ); +new TestCase( SECTION, "\\W", "W", "\W" ); +new TestCase( SECTION, "\\X", "X", "\X" ); +new TestCase( SECTION, "\\Y", "Y", "\Y" ); +new TestCase( SECTION, "\\Z", "Z", "\Z" ); + +// DoubleStringCharacter::EscapeSequence::UnicodeEscapeSequence + +new TestCase( SECTION, "\\u0020", " ", "\u0020" ); +new TestCase( SECTION, "\\u0021", "!", "\u0021" ); +new TestCase( SECTION, "\\u0022", "\"", "\u0022" ); +new TestCase( SECTION, "\\u0023", "#", "\u0023" ); +new TestCase( SECTION, "\\u0024", "$", "\u0024" ); +new TestCase( SECTION, "\\u0025", "%", "\u0025" ); +new TestCase( SECTION, "\\u0026", "&", "\u0026" ); +new TestCase( SECTION, "\\u0027", "'", "\u0027" ); +new TestCase( SECTION, "\\u0028", "(", "\u0028" ); +new TestCase( SECTION, "\\u0029", ")", "\u0029" ); +new TestCase( SECTION, "\\u002A", "*", "\u002A" ); +new TestCase( SECTION, "\\u002B", "+", "\u002B" ); +new TestCase( SECTION, "\\u002C", ",", "\u002C" ); +new TestCase( SECTION, "\\u002D", "-", "\u002D" ); +new TestCase( SECTION, "\\u002E", ".", "\u002E" ); +new TestCase( SECTION, "\\u002F", "/", "\u002F" ); +new TestCase( SECTION, "\\u0030", "0", "\u0030" ); +new TestCase( SECTION, "\\u0031", "1", "\u0031" ); +new TestCase( SECTION, "\\u0032", "2", "\u0032" ); +new TestCase( SECTION, "\\u0033", "3", "\u0033" ); +new TestCase( SECTION, "\\u0034", "4", "\u0034" ); +new TestCase( SECTION, "\\u0035", "5", "\u0035" ); +new TestCase( SECTION, "\\u0036", "6", "\u0036" ); +new TestCase( SECTION, "\\u0037", "7", "\u0037" ); +new TestCase( SECTION, "\\u0038", "8", "\u0038" ); +new TestCase( SECTION, "\\u0039", "9", "\u0039" ); + +test(); diff --git a/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.8.2-n.js b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.8.2-n.js new file mode 100644 index 0000000000..b8d844e41d --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.8.2-n.js @@ -0,0 +1,63 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '7.8.2-n.js'; + +/** + File Name: 7.8.2.js + ECMA Section: 7.8.2 Examples of Automatic Semicolon Insertion + Description: compare some specific examples of the automatic + insertion rules in the EMCA specification. + Author: christine@netscape.com + Date: 15 september 1997 +*/ + +var SECTION="7.8.2"; +var VERSION="ECMA_1" + startTest(); +writeHeaderToLog(SECTION+" "+"Examples of Semicolon Insertion"); + + +// new TestCase( "7.8.2", "{ 1 \n 2 } 3", 3, eval("{ 1 \n 2 } 3") ); + +DESCRIPTION = "{ 1 2 } 3"; +EXPECTED = "error"; + +new TestCase( "7.8.2", "{ 1 2 } 3", "error", eval("{1 2 } 3") ); + +test(); diff --git a/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/browser.js b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/browser.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/shell.js b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/shell.js new file mode 100644 index 0000000000..4e1d61d68a --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/shell.js @@ -0,0 +1 @@ +gTestsubsuite = 'LexicalConventions'; diff --git a/tests/auto/qml/parserstress/tests/ecma/Math/15.8-2-n.js b/tests/auto/qml/parserstress/tests/ecma/Math/15.8-2-n.js new file mode 100644 index 0000000000..40c2ae8d2d --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Math/15.8-2-n.js @@ -0,0 +1,82 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.8-2-n.js'; + +/** + File Name: 15.8-2.js + ECMA Section: 15.8 The Math Object + + Description: + + The Math object is merely a single object that has some named properties, + some of which are functions. + + The value of the internal [[Prototype]] property of the Math object is the + Object prototype object (15.2.3.1). + + The Math object does not have a [[Construct]] property; it is not possible + to use the Math object as a constructor with the new operator. + + The Math object does not have a [[Call]] property; it is not possible to + invoke the Math object as a function. + + Recall that, in this specification, the phrase "the number value for x" has + a technical meaning defined in section 8.5. + + Author: christine@netscape.com + Date: 12 november 1997 + +*/ + +var SECTION = "15.8-2-n"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "The Math Object"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +DESCRIPTION = "MYMATH = new Math()"; +EXPECTED = "error"; + +new TestCase( SECTION, + "MYMATH = new Math()", + "error", + eval("MYMATH = new Math()") ); + +test(); diff --git a/tests/auto/qml/parserstress/tests/ecma/Math/15.8-3-n.js b/tests/auto/qml/parserstress/tests/ecma/Math/15.8-3-n.js new file mode 100644 index 0000000000..f6333d7ec7 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Math/15.8-3-n.js @@ -0,0 +1,81 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.8-3-n.js'; + +/** + File Name: 15.8-3.js + ECMA Section: 15.8 The Math Object + + Description: + + The Math object is merely a single object that has some named properties, + some of which are functions. + + The value of the internal [[Prototype]] property of the Math object is the + Object prototype object (15.2.3.1). + + The Math object does not have a [[Construct]] property; it is not possible + to use the Math object as a constructor with the new operator. + + The Math object does not have a [[Call]] property; it is not possible to + invoke the Math object as a function. + + Recall that, in this specification, the phrase "the number value for x" has + a technical meaning defined in section 8.5. + + Author: christine@netscape.com + Date: 12 november 1997 + +*/ +var SECTION = "15.8-3-n"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "The Math Object"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +DESCRIPTION = "MYMATH = Math()"; +EXPECTED = "error"; + +new TestCase( SECTION, + "MYMATH = Math()", + "error", + eval("MYMATH = Math()") ); + +test(); diff --git a/tests/auto/qml/parserstress/tests/ecma/Math/15.8.1.1-1.js b/tests/auto/qml/parserstress/tests/ecma/Math/15.8.1.1-1.js new file mode 100644 index 0000000000..f90f74b9e8 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Math/15.8.1.1-1.js @@ -0,0 +1,64 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.8.1.1-1.js'; + +/** + File Name: 15.8.1.1-1.js + ECMA Section: 15.8.1.1.js + Description: All value properties of the Math object should have + the attributes [DontEnum, DontDelete, ReadOnly] + + this test checks the ReadOnly attribute of Math.E + + Author: christine@netscape.com + Date: 16 september 1997 +*/ +var SECTION = "15.8.1.1-1"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Math.E"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +new TestCase( SECTION, + "Math.E = 0; Math.E", + 2.7182818284590452354, + eval("Math.E=0;Math.E") ); + +test(); diff --git a/tests/auto/qml/parserstress/tests/ecma/Math/15.8.1.1-2.js b/tests/auto/qml/parserstress/tests/ecma/Math/15.8.1.1-2.js new file mode 100644 index 0000000000..9f136f2fb8 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Math/15.8.1.1-2.js @@ -0,0 +1,69 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.8.1.1-2.js'; + +/** + File Name: 15.8.1.1-2.js + ECMA Section: 15.8.1.1.js + Description: All value properties of the Math object should have + the attributes [DontEnum, DontDelete, ReadOnly] + + this test checks the DontDelete attribute of Math.E + + Author: christine@netscape.com + Date: 16 september 1997 +*/ +var SECTION = "15.8.1.1-2"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Math.E"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +var MATH_E = 2.7182818284590452354 + new TestCase( SECTION, + "delete(Math.E)", + false, + eval("delete Math.E") ); +new TestCase( SECTION, + "delete(Math.E); Math.E", + MATH_E, + eval("delete Math.E; Math.E") ); + +test(); diff --git a/tests/auto/qml/parserstress/tests/ecma/Math/15.8.1.2-1.js b/tests/auto/qml/parserstress/tests/ecma/Math/15.8.1.2-1.js new file mode 100644 index 0000000000..0cbc65a4fb --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Math/15.8.1.2-1.js @@ -0,0 +1,64 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.8.1.2-1.js'; + +/** + File Name: 15.8.1.2-1.js + ECMA Section: 15.8.2.js + Description: All value properties of the Math object should have + the attributes [DontEnum, DontDelete, ReadOnly] + + this test checks the ReadOnly attribute of Math.LN10 + + Author: christine@netscape.com + Date: 16 september 1997 +*/ +var SECTION = "15.8.1.2-1"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Math.LN10"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +new TestCase( SECTION, + "Math.LN10=0; Math.LN10", + 2.302585092994046, + eval("Math.LN10=0; Math.LN10") ); + +test(); diff --git a/tests/auto/qml/parserstress/tests/ecma/Math/15.8.1.2-2.js b/tests/auto/qml/parserstress/tests/ecma/Math/15.8.1.2-2.js new file mode 100644 index 0000000000..6937b3520b --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Math/15.8.1.2-2.js @@ -0,0 +1,70 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.8.1.2-2.js'; + +/** + File Name: 15.8.1.2-1.js + ECMA Section: 15.8.2.js + Description: All value properties of the Math object should have + the attributes [DontEnum, DontDelete, ReadOnly] + + this test checks the DontDelete attribute of Math.LN10 + + Author: christine@netscape.com + Date: 16 september 1997 +*/ + +var SECTION = "15.8.1.2-2"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Math.LN10"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +new TestCase( SECTION, + "delete( Math.LN10 ); Math.LN10", + 2.302585092994046, + eval("delete(Math.LN10); Math.LN10") ); + +new TestCase( SECTION, + "delete( Math.LN10 ); ", + false, + eval("delete(Math.LN10)") ); + +test(); diff --git a/tests/auto/qml/parserstress/tests/ecma/Math/15.8.1.3-1.js b/tests/auto/qml/parserstress/tests/ecma/Math/15.8.1.3-1.js new file mode 100644 index 0000000000..8289cc2a46 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Math/15.8.1.3-1.js @@ -0,0 +1,65 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.8.1.3-1.js'; + +/** + File Name: 15.8.1.3-1.js + ECMA Section: 15.8.1.3.js + Description: All value properties of the Math object should have + the attributes [DontEnum, DontDelete, ReadOnly] + + this test checks the ReadOnly attribute of Math.LN2 + + Author: christine@netscape.com + Date: 16 september 1997 +*/ + +var SECTION = "15.8.1.3-1"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Math.LN2"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +new TestCase( SECTION, + "Math.LN2=0; Math.LN2", + 0.6931471805599453, + eval("Math.LN2=0; Math.LN2") ); + +test(); diff --git a/tests/auto/qml/parserstress/tests/ecma/Math/15.8.1.3-2.js b/tests/auto/qml/parserstress/tests/ecma/Math/15.8.1.3-2.js new file mode 100644 index 0000000000..24a8b18231 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Math/15.8.1.3-2.js @@ -0,0 +1,72 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.8.1.3-2.js'; + +/** + File Name: 15.8.1.3-3.js + ECMA Section: 15.8.1.3.js + Description: All value properties of the Math object should have + the attributes [DontEnum, DontDelete, ReadOnly] + + this test checks the DontDelete attribute of Math.LN2 + + Author: christine@netscape.com + Date: 16 september 1997 +*/ + +var SECTION = "15.8.1.3-2"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Math.LN2"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +var MATH_LN2 = 0.6931471805599453; + +new TestCase( SECTION, + "delete(Math.LN2)", + false, + eval("delete(Math.LN2)") ); + +new TestCase( SECTION, + "delete(Math.LN2); Math.LN2", + MATH_LN2, + eval("delete(Math.LN2); Math.LN2") ); + +test(); diff --git a/tests/auto/qml/parserstress/tests/ecma/Math/15.8.1.4-1.js b/tests/auto/qml/parserstress/tests/ecma/Math/15.8.1.4-1.js new file mode 100644 index 0000000000..227dbb3e2a --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Math/15.8.1.4-1.js @@ -0,0 +1,65 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.8.1.4-1.js'; + +/** + File Name: 15.8.1.4-1.js + ECMA Section: 15.8.1.4.js + Description: All value properties of the Math object should have + the attributes [DontEnum, DontDelete, ReadOnly] + + this test checks the ReadOnly attribute of Math.LOG2E + + Author: christine@netscape.com + Date: 16 september 1997 +*/ + +var SECTION = "15.8.1.4-1"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Math.LOG2E"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +new TestCase( SECTION, + "Math.L0G2E=0; Math.LOG2E", + 1.4426950408889634, + eval("Math.LOG2E=0; Math.LOG2E") ); + +test(); diff --git a/tests/auto/qml/parserstress/tests/ecma/Math/15.8.1.4-2.js b/tests/auto/qml/parserstress/tests/ecma/Math/15.8.1.4-2.js new file mode 100644 index 0000000000..c9aa98e77a --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Math/15.8.1.4-2.js @@ -0,0 +1,69 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.8.1.4-2.js'; + +/** + File Name: 15.8.1.4-2.js + ECMA Section: 15.8.1.4.js + Description: All value properties of the Math object should have + the attributes [DontEnum, DontDelete, ReadOnly] + + this test checks the DontDelete attribute of Math.LOG2E + + Author: christine@netscape.com + Date: 16 september 1997 +*/ + +var SECTION = "15.8.1.4-2"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Math.LOG2E"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +new TestCase( SECTION, + "delete(Math.L0G2E);Math.LOG2E", + 1.4426950408889634, + eval("delete(Math.LOG2E);Math.LOG2E") ); +new TestCase( SECTION, + "delete(Math.L0G2E)", + false, + eval("delete(Math.LOG2E)") ); + +test(); diff --git a/tests/auto/qml/parserstress/tests/ecma/Math/15.8.1.5-1.js b/tests/auto/qml/parserstress/tests/ecma/Math/15.8.1.5-1.js new file mode 100644 index 0000000000..b753025c8a --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Math/15.8.1.5-1.js @@ -0,0 +1,66 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.8.1.5-1.js'; + +/** + File Name: 15.8.1.5-1.js + ECMA Section: 15.8.1.5.js + Description: All value properties of the Math object should have + the attributes [DontEnum, DontDelete, ReadOnly] + + this test checks the ReadOnly attribute of Math.LOG10E + + Author: christine@netscape.com + Date: 16 september 1997 +*/ + + +var SECTION = "15.8.1.5-1"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Math.LOG10E"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +new TestCase( SECTION, + "Math.LOG10E=0; Math.LOG10E", + 0.4342944819032518, + eval("Math.LOG10E=0; Math.LOG10E") ); + +test(); diff --git a/tests/auto/qml/parserstress/tests/ecma/Math/15.8.1.5-2.js b/tests/auto/qml/parserstress/tests/ecma/Math/15.8.1.5-2.js new file mode 100644 index 0000000000..c134e4a577 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Math/15.8.1.5-2.js @@ -0,0 +1,70 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.8.1.5-2.js'; + +/** + File Name: 15.8.1.5-2.js + ECMA Section: 15.8.1.5.js + Description: All value properties of the Math object should have + the attributes [DontEnum, DontDelete, ReadOnly] + + this test checks the DontDelete attribute of Math.LOG10E + + Author: christine@netscape.com + Date: 16 september 1997 +*/ + +var SECTION = "15.8.1.5-2"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Math.LOG10E"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +new TestCase( SECTION, + "delete Math.LOG10E; Math.LOG10E", + 0.4342944819032518, + eval("delete Math.LOG10E; Math.LOG10E") ); + +new TestCase( SECTION, + "delete Math.LOG10E", + false, + eval("delete Math.LOG10E") ); + +test(); diff --git a/tests/auto/qml/parserstress/tests/ecma/Math/15.8.1.6-1.js b/tests/auto/qml/parserstress/tests/ecma/Math/15.8.1.6-1.js new file mode 100644 index 0000000000..f2a395618c --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Math/15.8.1.6-1.js @@ -0,0 +1,65 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.8.1.6-1.js'; + +/** + File Name: 15.8.1.6-1.js + ECMA Section: 15.8.1.6.js + Description: All value properties of the Math object should have + the attributes [DontEnum, DontDelete, ReadOnly] + + this test checks the ReadOnly attribute of Math.PI + + Author: christine@netscape.com + Date: 16 september 1997 +*/ + +var SECTION = "15.8.1.6-1"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Math.PI"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +new TestCase( SECTION, + "Math.PI=0; Math.PI", + 3.1415926535897923846, + eval("Math.PI=0; Math.PI") ); + +test(); diff --git a/tests/auto/qml/parserstress/tests/ecma/Math/15.8.1.6-2.js b/tests/auto/qml/parserstress/tests/ecma/Math/15.8.1.6-2.js new file mode 100644 index 0000000000..ba53e78de5 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Math/15.8.1.6-2.js @@ -0,0 +1,70 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.8.1.6-2.js'; + +/** + File Name: 15.8.1.6-2.js + ECMA Section: 15.8.1.6.js + Description: All value properties of the Math object should have + the attributes [DontEnum, DontDelete, ReadOnly] + + this test checks the DontDelete attribute of Math.PI + + Author: christine@netscape.com + Date: 16 september 1997 +*/ + +var SECTION = "15.8.1.6-2"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Math.PI"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +new TestCase( SECTION, + "delete Math.PI; Math.PI", + 3.1415926535897923846, + eval("delete Math.PI; Math.PI") ); + +new TestCase( SECTION, + "delete Math.PI; Math.PI", + false, + eval("delete Math.PI") ); + +test(); diff --git a/tests/auto/qml/parserstress/tests/ecma/Math/15.8.1.7-1.js b/tests/auto/qml/parserstress/tests/ecma/Math/15.8.1.7-1.js new file mode 100644 index 0000000000..aa60aead5b --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Math/15.8.1.7-1.js @@ -0,0 +1,65 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.8.1.7-1.js'; + +/** + File Name: 15.8.1.7-1.js + ECMA Section: 15.8.1.7.js + Description: All value properties of the Math object should have + the attributes [DontEnum, DontDelete, ReadOnly] + + this test checks the ReadOnly attribute of Math.SQRT1_2 + + Author: christine@netscape.com + Date: 16 september 1997 +*/ + +var SECTION = "15.8.1.7-1"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Math.SQRT1_2"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +new TestCase( SECTION, + "Math.SQRT1_2=0; Math.SQRT1_2", + 0.7071067811865476, + eval("Math.SQRT1_2=0; Math.SQRT1_2") ); + +test(); diff --git a/tests/auto/qml/parserstress/tests/ecma/Math/15.8.1.7-2.js b/tests/auto/qml/parserstress/tests/ecma/Math/15.8.1.7-2.js new file mode 100644 index 0000000000..2f8c45c9f9 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Math/15.8.1.7-2.js @@ -0,0 +1,70 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.8.1.7-2.js'; + +/** + File Name: 15.8.1.7-2.js + ECMA Section: 15.8.1.7.js + Description: All value properties of the Math object should have + the attributes [DontEnum, DontDelete, ReadOnly] + + this test checks the DontDelete attribute of Math.SQRT1_2 + + Author: christine@netscape.com + Date: 16 september 1997 +*/ + +var SECTION = "15.8.1.7-2"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Math.SQRT1_2"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +new TestCase( SECTION, + "delete Math.SQRT1_2; Math.SQRT1_2", + 0.7071067811865476, + eval("delete Math.SQRT1_2; Math.SQRT1_2") ); + +new TestCase( SECTION, + "delete Math.SQRT1_2", + false, + eval("delete Math.SQRT1_2") ); + +test(); diff --git a/tests/auto/qml/parserstress/tests/ecma/Math/15.8.1.8-1.js b/tests/auto/qml/parserstress/tests/ecma/Math/15.8.1.8-1.js new file mode 100644 index 0000000000..3c5764d019 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Math/15.8.1.8-1.js @@ -0,0 +1,65 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.8.1.8-1.js'; + +/** + File Name: 15.8.1.8-1.js + ECMA Section: 15.8.1.8.js + Description: All value properties of the Math object should have + the attributes [DontEnum, DontDelete, ReadOnly] + + this test checks the ReadOnly attribute of Math.SQRT2 + + Author: christine@netscape.com + Date: 16 september 1997 +*/ + +var SECTION = "15.8.1.8-1"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Math.SQRT2"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +new TestCase( SECTION, + "Math.SQRT2=0; Math.SQRT2", + 1.4142135623730951, + eval("Math.SQRT2=0; Math.SQRT2") ); + +test(); diff --git a/tests/auto/qml/parserstress/tests/ecma/Math/15.8.1.8-2.js b/tests/auto/qml/parserstress/tests/ecma/Math/15.8.1.8-2.js new file mode 100644 index 0000000000..f999dac920 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Math/15.8.1.8-2.js @@ -0,0 +1,69 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.8.1.8-2.js'; + +/** + File Name: 15.8.1.8-2.js + ECMA Section: 15.8.1.8.js + Description: All value properties of the Math object should have + the attributes [DontEnum, DontDelete, ReadOnly] + + this test checks the DontDelete attribute of Math.SQRT2 + + Author: christine@netscape.com + Date: 16 september 1997 +*/ +var SECTION = "15.8.1.8-2"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Math.SQRT2"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +new TestCase( SECTION, + "delete Math.SQRT2; Math.SQRT2", + 1.4142135623730951, + eval("delete Math.SQRT2; Math.SQRT2") ); + +new TestCase( SECTION, + "delete Math.SQRT2", + false, + eval("delete Math.SQRT2") ); + +test(); diff --git a/tests/auto/qml/parserstress/tests/ecma/Math/15.8.1.8-3.js b/tests/auto/qml/parserstress/tests/ecma/Math/15.8.1.8-3.js new file mode 100644 index 0000000000..0c823aea57 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Math/15.8.1.8-3.js @@ -0,0 +1,63 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.8.1.8-3.js'; + +/** + File Name: 15.8.1.8-3.js + ECMA Section: 15.8.1.8.js + Description: All value properties of the Math object should have + the attributes [DontEnum, DontDelete, ReadOnly] + + this test checks the DontDelete attribute of Math.SQRT2 + + Author: christine@netscape.com + Date: 16 september 1997 +*/ +var SECTION = "15.8.1.8-3"; +var VERSION = "ECMA_1"; +startTest(); + +writeHeaderToLog( SECTION + " Math.SQRT2: DontDelete"); + +new TestCase( SECTION, + "delete Math.SQRT2", + false, + eval("delete Math.SQRT2") ); + +test(); diff --git a/tests/auto/qml/parserstress/tests/ecma/Math/15.8.1.js b/tests/auto/qml/parserstress/tests/ecma/Math/15.8.1.js new file mode 100644 index 0000000000..009325640b --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Math/15.8.1.js @@ -0,0 +1,149 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.8.1.js'; + +/** + File Name: 15.8.1.js + ECMA Section: 15.8.1.js Value Properties of the Math Object + 15.8.1.1 E + 15.8.1.2 LN10 + 15.8.1.3 LN2 + 15.8.1.4 LOG2E + 15.8.1.5 LOG10E + 15.8.1.6 PI + 15.8.1.7 SQRT1_2 + 15.8.1.8 SQRT2 + Description: verify the values of some math constants + Author: christine@netscape.com + Date: 7 july 1997 + +*/ +var SECTION = "15.8.1" + var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Value Properties of the Math Object"; + +writeHeaderToLog( SECTION + " "+ TITLE); + + +new TestCase( "15.8.1.1", "Math.E", + 2.7182818284590452354, + Math.E ); + +new TestCase( "15.8.1.1", + "typeof Math.E", + "number", + typeof Math.E ); + +new TestCase( "15.8.1.2", + "Math.LN10", + 2.302585092994046, + Math.LN10 ); + +new TestCase( "15.8.1.2", + "typeof Math.LN10", + "number", + typeof Math.LN10 ); + +new TestCase( "15.8.1.3", + "Math.LN2", + 0.6931471805599453, + Math.LN2 ); + +new TestCase( "15.8.1.3", + "typeof Math.LN2", + "number", + typeof Math.LN2 ); + +new TestCase( "15.8.1.4", + "Math.LOG2E", + 1.4426950408889634, + Math.LOG2E ); + +new TestCase( "15.8.1.4", + "typeof Math.LOG2E", + "number", + typeof Math.LOG2E ); + +new TestCase( "15.8.1.5", + "Math.LOG10E", + 0.4342944819032518, + Math.LOG10E); + +new TestCase( "15.8.1.5", + "typeof Math.LOG10E", + "number", + typeof Math.LOG10E); + +new TestCase( "15.8.1.6", + "Math.PI", + 3.14159265358979323846, + Math.PI ); + +new TestCase( "15.8.1.6", + "typeof Math.PI", + "number", + typeof Math.PI ); + +new TestCase( "15.8.1.7", + "Math.SQRT1_2", + 0.7071067811865476, + Math.SQRT1_2); + +new TestCase( "15.8.1.7", + "typeof Math.SQRT1_2", + "number", + typeof Math.SQRT1_2); + +new TestCase( "15.8.1.8", + "Math.SQRT2", + 1.4142135623730951, + Math.SQRT2 ); + +new TestCase( "15.8.1.8", + "typeof Math.SQRT2", + "number", + typeof Math.SQRT2 ); + +new TestCase( SECTION, + "var MATHPROPS='';for( p in Math ){ MATHPROPS +=p; };MATHPROPS", + "", + eval("var MATHPROPS='';for( p in Math ){ MATHPROPS +=p; };MATHPROPS") ); + +test(); diff --git a/tests/auto/qml/parserstress/tests/ecma/Math/15.8.2.1.js b/tests/auto/qml/parserstress/tests/ecma/Math/15.8.2.1.js new file mode 100644 index 0000000000..0412742767 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Math/15.8.2.1.js @@ -0,0 +1,226 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.8.2.1.js'; + +/** + File Name: 15.8.2.1.js + ECMA Section: 15.8.2.1 abs( x ) + Description: return the absolute value of the argument, + which should be the magnitude of the argument + with a positive sign. + - if x is NaN, return NaN + - if x is -0, result is +0 + - if x is -Infinity, result is +Infinity + Author: christine@netscape.com + Date: 7 july 1997 +*/ +var SECTION = "15.8.2.1"; +var VERSION = "ECMA_1"; +var TITLE = "Math.abs()"; +var BUGNUMBER = "77391"; +startTest(); + +writeHeaderToLog( SECTION + " "+ TITLE); + +new TestCase( SECTION, + "Math.abs.length", + 1, + Math.abs.length ); + +new TestCase( SECTION, + "Math.abs()", + Number.NaN, + Math.abs() ); + +new TestCase( SECTION, + "Math.abs( void 0 )", + Number.NaN, + Math.abs(void 0) ); + +new TestCase( SECTION, + "Math.abs( null )", + 0, + Math.abs(null) ); + +new TestCase( SECTION, + "Math.abs( true )", + 1, + Math.abs(true) ); + +new TestCase( SECTION, + "Math.abs( false )", + 0, + Math.abs(false) ); + +new TestCase( SECTION, + "Math.abs( string primitive)", + Number.NaN, + Math.abs("a string primitive") ); + +new TestCase( SECTION, + "Math.abs( string object )", + Number.NaN, + Math.abs(new String( 'a String object' )) ); + +new TestCase( SECTION, + "Math.abs( Number.NaN )", + Number.NaN, + Math.abs(Number.NaN) ); + +new TestCase( SECTION, + "Math.abs(0)", + 0, + Math.abs( 0 ) ); + +new TestCase( SECTION, + "Math.abs( -0 )", + 0, + Math.abs(-0) ); + +new TestCase( SECTION, + "Infinity/Math.abs(-0)", + Infinity, + Infinity/Math.abs(-0) ); + +new TestCase( SECTION, + "Math.abs( -Infinity )", + Number.POSITIVE_INFINITY, + Math.abs( Number.NEGATIVE_INFINITY ) ); + +new TestCase( SECTION, + "Math.abs( Infinity )", + Number.POSITIVE_INFINITY, + Math.abs( Number.POSITIVE_INFINITY ) ); + +new TestCase( SECTION, + "Math.abs( - MAX_VALUE )", + Number.MAX_VALUE, + Math.abs( - Number.MAX_VALUE ) ); + +new TestCase( SECTION, + "Math.abs( - MIN_VALUE )", + Number.MIN_VALUE, + Math.abs( -Number.MIN_VALUE ) ); + +new TestCase( SECTION, + "Math.abs( MAX_VALUE )", + Number.MAX_VALUE, + Math.abs( Number.MAX_VALUE ) ); + +new TestCase( SECTION, + "Math.abs( MIN_VALUE )", + Number.MIN_VALUE, + Math.abs( Number.MIN_VALUE ) ); + +new TestCase( SECTION, + "Math.abs( -1 )", + 1, + Math.abs( -1 ) ); + +new TestCase( SECTION, + "Math.abs( new Number( -1 ) )", + 1, + Math.abs( new Number(-1) ) ); + +new TestCase( SECTION, + "Math.abs( 1 )", + 1, + Math.abs( 1 ) ); + +new TestCase( SECTION, + "Math.abs( Math.PI )", + Math.PI, + Math.abs( Math.PI ) ); + +new TestCase( SECTION, + "Math.abs( -Math.PI )", + Math.PI, + Math.abs( -Math.PI ) ); + +new TestCase( SECTION, + "Math.abs(-1/100000000)", + 1/100000000, + Math.abs(-1/100000000) ); + +new TestCase( SECTION, + "Math.abs(-Math.pow(2,32))", + Math.pow(2,32), + Math.abs(-Math.pow(2,32)) ); + +new TestCase( SECTION, + "Math.abs(Math.pow(2,32))", + Math.pow(2,32), + Math.abs(Math.pow(2,32)) ); + +new TestCase( SECTION, + "Math.abs( -0xfff )", + 4095, + Math.abs( -0xfff ) ); + +new TestCase( SECTION, + "Math.abs( -0777 )", + 511, + Math.abs(-0777 ) ); + +new TestCase( SECTION, + "Math.abs('-1e-1')", + 0.1, + Math.abs('-1e-1') ); + +new TestCase( SECTION, + "Math.abs('0xff')", + 255, + Math.abs('0xff') ); + +new TestCase( SECTION, + "Math.abs('077')", + 77, + Math.abs('077') ); + +new TestCase( SECTION, + "Math.abs( 'Infinity' )", + Infinity, + Math.abs('Infinity') ); + +new TestCase( SECTION, + "Math.abs( '-Infinity' )", + Infinity, + Math.abs('-Infinity') ); + +test(); diff --git a/tests/auto/qml/parserstress/tests/ecma/Math/15.8.2.10.js b/tests/auto/qml/parserstress/tests/ecma/Math/15.8.2.10.js new file mode 100644 index 0000000000..05d4c187c9 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Math/15.8.2.10.js @@ -0,0 +1,153 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.8.2.10.js'; + +/** + File Name: 15.8.2.10.js + ECMA Section: 15.8.2.10 Math.log(x) + Description: return an approximiation to the natural logarithm of + the argument. + special cases: + - if arg is NaN result is NaN + - if arg is <0 result is NaN + - if arg is 0 or -0 result is -Infinity + - if arg is 1 result is 0 + - if arg is Infinity result is Infinity + Author: christine@netscape.com + Date: 7 july 1997 +*/ + +var SECTION = "15.8.2.10"; +var VERSION = "ECMA_1"; +var TITLE = "Math.log(x)"; +var BUGNUMBER = "77391"; + +startTest(); + +writeHeaderToLog( SECTION + " "+ TITLE); + + +new TestCase( SECTION, + "Math.log.length", + 1, + Math.log.length ); + + +new TestCase( SECTION, + "Math.log()", + Number.NaN, + Math.log() ); + +new TestCase( SECTION, + "Math.log(void 0)", + Number.NaN, + Math.log(void 0) ); + +new TestCase( SECTION, + "Math.log(null)", + Number.NEGATIVE_INFINITY, + Math.log(null) ); + +new TestCase( SECTION, + "Math.log(true)", + 0, + Math.log(true) ); + +new TestCase( SECTION, + "Math.log(false)", + -Infinity, + Math.log(false) ); + +new TestCase( SECTION, + "Math.log('0')", + -Infinity, + Math.log('0') ); + +new TestCase( SECTION, + "Math.log('1')", + 0, + Math.log('1') ); + +new TestCase( SECTION, + "Math.log('Infinity')", + Infinity, + Math.log("Infinity") ); + + +new TestCase( SECTION, + "Math.log(NaN)", + Number.NaN, + Math.log(Number.NaN) ); + +new TestCase( SECTION, + "Math.log(-0.0000001)", + Number.NaN, + Math.log(-0.000001) ); + +new TestCase( SECTION, + "Math.log(-1)", + Number.NaN, + Math.log(-1) ); + +new TestCase( SECTION, + "Math.log(0)", + Number.NEGATIVE_INFINITY, + Math.log(0) ); + +new TestCase( SECTION, + "Math.log(-0)", + Number.NEGATIVE_INFINITY, + Math.log(-0)); + +new TestCase( SECTION, + "Math.log(1)", + 0, + Math.log(1) ); + +new TestCase( SECTION, + "Math.log(Infinity)", + Number.POSITIVE_INFINITY, + Math.log(Number.POSITIVE_INFINITY) ); + +new TestCase( SECTION, + "Math.log(-Infinity)", + Number.NaN, + Math.log(Number.NEGATIVE_INFINITY) ); + +test(); diff --git a/tests/auto/qml/parserstress/tests/ecma/Math/15.8.2.11.js b/tests/auto/qml/parserstress/tests/ecma/Math/15.8.2.11.js new file mode 100644 index 0000000000..5a957b3de4 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Math/15.8.2.11.js @@ -0,0 +1,200 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.8.2.11.js'; + +/** + File Name: 15.8.2.11.js + ECMA Section: 15.8.2.11 Math.max(x, y) + Description: return the smaller of the two arguments. + special cases: + - if x is NaN or y is NaN return NaN + - if x < y return x + - if y > x return y + - if x is +0 and y is +0 return +0 + - if x is +0 and y is -0 return -0 + - if x is -0 and y is +0 return -0 + - if x is -0 and y is -0 return -0 + Author: christine@netscape.com + Date: 7 july 1997 +*/ + +var SECTION = "15.8.2.11"; +var VERSION = "ECMA_1"; +var TITLE = "Math.max(x, y)"; +var BUGNUMBER="76439"; + +startTest(); + +writeHeaderToLog( SECTION + " "+ TITLE); + +new TestCase( SECTION, + "Math.max.length", + 2, + Math.max.length ); + +new TestCase( SECTION, + "Math.max()", + -Infinity, + Math.max() ); + +new TestCase( SECTION, + "Math.max(void 0, 1)", + Number.NaN, + Math.max( void 0, 1 ) ); + +new TestCase( SECTION, + "Math.max(void 0, void 0)", + Number.NaN, + Math.max( void 0, void 0 ) ); + +new TestCase( SECTION, + "Math.max(null, 1)", + 1, + Math.max( null, 1 ) ); + +new TestCase( SECTION, + "Math.max(-1, null)", + 0, + Math.max( -1, null ) ); + +new TestCase( SECTION, + "Math.max(true, false)", + 1, + Math.max(true,false) ); + +new TestCase( SECTION, + "Math.max('-99','99')", + 99, + Math.max( "-99","99") ); + +new TestCase( SECTION, + "Math.max(NaN, Infinity)", + Number.NaN, + Math.max(Number.NaN,Number.POSITIVE_INFINITY) ); + +new TestCase( SECTION, + "Math.max(NaN, 0)", + Number.NaN, + Math.max(Number.NaN, 0) ); + +new TestCase( SECTION, + "Math.max('a string', 0)", + Number.NaN, + Math.max("a string", 0) ); + +new TestCase( SECTION, + "Math.max(NaN, 1)", + Number.NaN, + Math.max(Number.NaN,1) ); + +new TestCase( SECTION, + "Math.max('a string',Infinity)", + Number.NaN, + Math.max("a string", Number.POSITIVE_INFINITY) ); + +new TestCase( SECTION, + "Math.max(Infinity, NaN)", + Number.NaN, + Math.max( Number.POSITIVE_INFINITY, Number.NaN) ); + +new TestCase( SECTION, + "Math.max(NaN, NaN)", + Number.NaN, + Math.max(Number.NaN, Number.NaN) ); + +new TestCase( SECTION, + "Math.max(0,NaN)", + Number.NaN, + Math.max(0,Number.NaN) ); + +new TestCase( SECTION, + "Math.max(1, NaN)", + Number.NaN, + Math.max(1, Number.NaN) ); + +new TestCase( SECTION, + "Math.max(0,0)", + 0, + Math.max(0,0) ); + +new TestCase( SECTION, + "Math.max(0,-0)", + 0, + Math.max(0,-0) ); + +new TestCase( SECTION, + "Math.max(-0,0)", + 0, + Math.max(-0,0) ); + +new TestCase( SECTION, + "Math.max(-0,-0)", + -0, + Math.max(-0,-0) ); + +new TestCase( SECTION, + "Infinity/Math.max(-0,-0)", + -Infinity, + Infinity/Math.max(-0,-0) ); + +new TestCase( SECTION, + "Math.max(Infinity, Number.MAX_VALUE)", Number.POSITIVE_INFINITY, + Math.max(Number.POSITIVE_INFINITY, Number.MAX_VALUE) ); + +new TestCase( SECTION, + "Math.max(Infinity, Infinity)", + Number.POSITIVE_INFINITY, + Math.max(Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY) ); + +new TestCase( SECTION, + "Math.max(-Infinity,-Infinity)", + Number.NEGATIVE_INFINITY, + Math.max(Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY) ); + +new TestCase( SECTION, + "Math.max(1,.99999999999999)", + 1, + Math.max(1,.99999999999999) ); + +new TestCase( SECTION, + "Math.max(-1,-.99999999999999)", + -.99999999999999, + Math.max(-1,-.99999999999999) ); + +test(); diff --git a/tests/auto/qml/parserstress/tests/ecma/Math/15.8.2.12.js b/tests/auto/qml/parserstress/tests/ecma/Math/15.8.2.12.js new file mode 100644 index 0000000000..a33a5aca4a --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Math/15.8.2.12.js @@ -0,0 +1,177 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.8.2.12.js'; + +/** + File Name: 15.8.2.12.js + ECMA Section: 15.8.2.12 Math.min(x, y) + Description: return the smaller of the two arguments. + special cases: + - if x is NaN or y is NaN return NaN + - if x < y return x + - if y > x return y + - if x is +0 and y is +0 return +0 + - if x is +0 and y is -0 return -0 + - if x is -0 and y is +0 return -0 + - if x is -0 and y is -0 return -0 + Author: christine@netscape.com + Date: 7 july 1997 +*/ + + +var SECTION = "15.8.2.12"; +var VERSION = "ECMA_1"; +var TITLE = "Math.min(x, y)"; +var BUGNUMBER="76439"; + +startTest(); + +writeHeaderToLog( SECTION + " "+ TITLE); + +new TestCase( SECTION, + "Math.min.length", + 2, + Math.min.length ); + +new TestCase( SECTION, + "Math.min()", + Infinity, + Math.min() ); + +new TestCase( SECTION, + "Math.min(void 0, 1)", + Number.NaN, + Math.min( void 0, 1 ) ); + +new TestCase( SECTION, + "Math.min(void 0, void 0)", + Number.NaN, + Math.min( void 0, void 0 ) ); + +new TestCase( SECTION, + "Math.min(null, 1)", + 0, + Math.min( null, 1 ) ); + +new TestCase( SECTION, + "Math.min(-1, null)", + -1, + Math.min( -1, null ) ); + +new TestCase( SECTION, + "Math.min(true, false)", + 0, + Math.min(true,false) ); + +new TestCase( SECTION, + "Math.min('-99','99')", + -99, + Math.min( "-99","99") ); + +new TestCase( SECTION, + "Math.min(NaN,0)", + Number.NaN, + Math.min(Number.NaN,0) ); + +new TestCase( SECTION, + "Math.min(NaN,1)", + Number.NaN, + Math.min(Number.NaN,1) ); + +new TestCase( SECTION, + "Math.min(NaN,-1)", + Number.NaN, + Math.min(Number.NaN,-1) ); + +new TestCase( SECTION, + "Math.min(0,NaN)", + Number.NaN, + Math.min(0,Number.NaN) ); + +new TestCase( SECTION, + "Math.min(1,NaN)", + Number.NaN, + Math.min(1,Number.NaN) ); + +new TestCase( SECTION, + "Math.min(-1,NaN)", + Number.NaN, + Math.min(-1,Number.NaN) ); + +new TestCase( SECTION, + "Math.min(NaN,NaN)", + Number.NaN, + Math.min(Number.NaN,Number.NaN) ); + +new TestCase( SECTION, + "Math.min(1,1.0000000001)", + 1, + Math.min(1,1.0000000001) ); + +new TestCase( SECTION, + "Math.min(1.0000000001,1)", + 1, + Math.min(1.0000000001,1) ); + +new TestCase( SECTION, + "Math.min(0,0)", + 0, + Math.min(0,0) ); + +new TestCase( SECTION, + "Math.min(0,-0)", + -0, + Math.min(0,-0) ); + +new TestCase( SECTION, + "Math.min(-0,-0)", + -0, + Math.min(-0,-0) ); + +new TestCase( SECTION, + "Infinity/Math.min(0,-0)", + -Infinity, + Infinity/Math.min(0,-0) ); + +new TestCase( SECTION, + "Infinity/Math.min(-0,-0)", + -Infinity, + Infinity/Math.min(-0,-0) ); + +test(); diff --git a/tests/auto/qml/parserstress/tests/ecma/Math/15.8.2.13.js b/tests/auto/qml/parserstress/tests/ecma/Math/15.8.2.13.js new file mode 100644 index 0000000000..341b3e7651 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Math/15.8.2.13.js @@ -0,0 +1,385 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.8.2.13.js'; + +/** + File Name: 15.8.2.13.js + ECMA Section: 15.8.2.13 Math.pow(x, y) + Description: return an approximation to the result of x + to the power of y. there are many special cases; + refer to the spec. + Author: christine@netscape.com + Date: 9 july 1997 +*/ + +var SECTION = "15.8.2.13"; +var VERSION = "ECMA_1"; +var TITLE = "Math.pow(x, y)"; +var BUGNUMBER="77141"; + +startTest(); + +writeHeaderToLog( SECTION + " "+ TITLE); + +new TestCase( SECTION, + "Math.pow.length", + 2, + Math.pow.length ); + +new TestCase( SECTION, + "Math.pow()", + Number.NaN, + Math.pow() ); + +new TestCase( SECTION, + "Math.pow(null, null)", + 1, + Math.pow(null,null) ); + +new TestCase( SECTION, + "Math.pow(void 0, void 0)", + Number.NaN, + Math.pow(void 0, void 0)); + +new TestCase( SECTION, + "Math.pow(true, false)", + 1, + Math.pow(true, false) ); + +new TestCase( SECTION, + "Math.pow(false,true)", + 0, + Math.pow(false,true) ); + +new TestCase( SECTION, + "Math.pow('2','32')", + 4294967296, + Math.pow('2','32') ); + +new TestCase( SECTION, + "Math.pow(1,NaN)", + Number.NaN, + Math.pow(1,Number.NaN) ); + +new TestCase( SECTION, + "Math.pow(0,NaN)", + Number.NaN, + Math.pow(0,Number.NaN) ); + +new TestCase( SECTION, + "Math.pow(NaN,0)", + 1, + Math.pow(Number.NaN,0) ); + +new TestCase( SECTION, + "Math.pow(NaN,-0)", + 1, + Math.pow(Number.NaN,-0) ); + +new TestCase( SECTION, + "Math.pow(NaN,1)", + Number.NaN, + Math.pow(Number.NaN, 1) ); + +new TestCase( SECTION, + "Math.pow(NaN,.5)", + Number.NaN, + Math.pow(Number.NaN, .5) ); + +new TestCase( SECTION, + "Math.pow(1.00000001, Infinity)", + Number.POSITIVE_INFINITY, + Math.pow(1.00000001, Number.POSITIVE_INFINITY) ); + +new TestCase( SECTION, + "Math.pow(1.00000001, -Infinity)", + 0, + Math.pow(1.00000001, Number.NEGATIVE_INFINITY) ); + +new TestCase( SECTION, + "Math.pow(-1.00000001, Infinity)", + Number.POSITIVE_INFINITY, + Math.pow(-1.00000001,Number.POSITIVE_INFINITY) ); + +new TestCase( SECTION, + "Math.pow(-1.00000001, -Infinity)", + 0, + Math.pow(-1.00000001,Number.NEGATIVE_INFINITY) ); + +new TestCase( SECTION, + "Math.pow(1, Infinity)", + Number.NaN, + Math.pow(1, Number.POSITIVE_INFINITY) ); + +new TestCase( SECTION, + "Math.pow(1, -Infinity)", + Number.NaN, + Math.pow(1, Number.NEGATIVE_INFINITY) ); + +new TestCase( SECTION, + "Math.pow(-1, Infinity)", + Number.NaN, + Math.pow(-1, Number.POSITIVE_INFINITY) ); + +new TestCase( SECTION, + "Math.pow(-1, -Infinity)", + Number.NaN, + Math.pow(-1, Number.NEGATIVE_INFINITY) ); + +new TestCase( SECTION, + "Math.pow(.0000000009, Infinity)", + 0, + Math.pow(.0000000009, Number.POSITIVE_INFINITY) ); + +new TestCase( SECTION, + "Math.pow(-.0000000009, Infinity)", + 0, + Math.pow(-.0000000009, Number.POSITIVE_INFINITY) ); + +new TestCase( SECTION, + "Math.pow(.0000000009, -Infinity)", + Number.POSITIVE_INFINITY, + Math.pow(-.0000000009, Number.NEGATIVE_INFINITY) ); + +new TestCase( SECTION, + "Math.pow(Infinity, .00000000001)", + Number.POSITIVE_INFINITY, + Math.pow(Number.POSITIVE_INFINITY,.00000000001) ); + +new TestCase( SECTION, + "Math.pow(Infinity, 1)", + Number.POSITIVE_INFINITY, + Math.pow(Number.POSITIVE_INFINITY, 1) ); + +new TestCase( SECTION, + "Math.pow(Infinity, -.00000000001)", + 0, + Math.pow(Number.POSITIVE_INFINITY, -.00000000001) ); + +new TestCase( SECTION, + "Math.pow(Infinity, -1)", + 0, + Math.pow(Number.POSITIVE_INFINITY, -1) ); + +new TestCase( SECTION, + "Math.pow(-Infinity, 1)", + Number.NEGATIVE_INFINITY, + Math.pow(Number.NEGATIVE_INFINITY, 1) ); + +new TestCase( SECTION, + "Math.pow(-Infinity, 333)", + Number.NEGATIVE_INFINITY, + Math.pow(Number.NEGATIVE_INFINITY, 333) ); + +new TestCase( SECTION, + "Math.pow(Infinity, 2)", + Number.POSITIVE_INFINITY, + Math.pow(Number.POSITIVE_INFINITY, 2) ); + +new TestCase( SECTION, + "Math.pow(-Infinity, 666)", + Number.POSITIVE_INFINITY, + Math.pow(Number.NEGATIVE_INFINITY, 666) ); + +new TestCase( SECTION, + "Math.pow(-Infinity, 0.5)", + Number.POSITIVE_INFINITY, + Math.pow(Number.NEGATIVE_INFINITY, 0.5) ); + +new TestCase( SECTION, + "Math.pow(-Infinity, Infinity)", + Number.POSITIVE_INFINITY, + Math.pow(Number.NEGATIVE_INFINITY, Number.POSITIVE_INFINITY) ); + +new TestCase( SECTION, + "Math.pow(-Infinity, -1)", + -0, + Math.pow(Number.NEGATIVE_INFINITY, -1) ); + +new TestCase( SECTION, + "Infinity/Math.pow(-Infinity, -1)", + -Infinity, + Infinity/Math.pow(Number.NEGATIVE_INFINITY, -1) ); + +new TestCase( SECTION, + "Math.pow(-Infinity, -3)", + -0, + Math.pow(Number.NEGATIVE_INFINITY, -3) ); + +new TestCase( SECTION, + "Math.pow(-Infinity, -2)", + 0, + Math.pow(Number.NEGATIVE_INFINITY, -2) ); + +new TestCase( SECTION, + "Math.pow(-Infinity, -0.5)", + 0, + Math.pow(Number.NEGATIVE_INFINITY,-0.5) ); + +new TestCase( SECTION, + "Math.pow(-Infinity, -Infinity)", + 0, + Math.pow(Number.NEGATIVE_INFINITY, Number.NEGATIVE_INFINITY) ); + +new TestCase( SECTION, + "Math.pow(0, 1)", + 0, + Math.pow(0,1) ); + +new TestCase( SECTION, + "Math.pow(0, 0)", + 1, + Math.pow(0,0) ); + +new TestCase( SECTION, + "Math.pow(1, 0)", + 1, + Math.pow(1,0) ); + +new TestCase( SECTION, + "Math.pow(-1, 0)", + 1, + Math.pow(-1,0) ); + +new TestCase( SECTION, + "Math.pow(0, 0.5)", + 0, + Math.pow(0,0.5) ); + +new TestCase( SECTION, + "Math.pow(0, 1000)", + 0, + Math.pow(0,1000) ); + +new TestCase( SECTION, + "Math.pow(0, Infinity)", + 0, + Math.pow(0, Number.POSITIVE_INFINITY) ); + +new TestCase( SECTION, + "Math.pow(0, -1)", + Number.POSITIVE_INFINITY, + Math.pow(0, -1) ); + +new TestCase( SECTION, + "Math.pow(0, -0.5)", + Number.POSITIVE_INFINITY, + Math.pow(0, -0.5) ); + +new TestCase( SECTION, + "Math.pow(0, -1000)", + Number.POSITIVE_INFINITY, + Math.pow(0, -1000) ); + +new TestCase( SECTION, + "Math.pow(0, -Infinity)", + Number.POSITIVE_INFINITY, + Math.pow(0, Number.NEGATIVE_INFINITY) ); + +new TestCase( SECTION, + "Math.pow(-0, 1)", + -0, + Math.pow(-0, 1) ); + +new TestCase( SECTION, + "Math.pow(-0, 3)", + -0, + Math.pow(-0,3) ); + +new TestCase( SECTION, + "Infinity/Math.pow(-0, 1)", + -Infinity, + Infinity/Math.pow(-0, 1) ); + +new TestCase( SECTION, + "Infinity/Math.pow(-0, 3)", + -Infinity, + Infinity/Math.pow(-0,3) ); + +new TestCase( SECTION, + "Math.pow(-0, 2)", + 0, + Math.pow(-0,2) ); + +new TestCase( SECTION, + "Math.pow(-0, Infinity)", + 0, + Math.pow(-0, Number.POSITIVE_INFINITY) ); + +new TestCase( SECTION, + "Math.pow(-0, -1)", + Number.NEGATIVE_INFINITY, + Math.pow(-0, -1) ); + +new TestCase( SECTION, + "Math.pow(-0, -10001)", + Number.NEGATIVE_INFINITY, + Math.pow(-0, -10001) ); + +new TestCase( SECTION, + "Math.pow(-0, -2)", + Number.POSITIVE_INFINITY, + Math.pow(-0, -2) ); + +new TestCase( SECTION, + "Math.pow(-0, 0.5)", + 0, + Math.pow(-0, 0.5) ); + +new TestCase( SECTION, + "Math.pow(-0, Infinity)", + 0, + Math.pow(-0, Number.POSITIVE_INFINITY) ); + +new TestCase( SECTION, + "Math.pow(-1, 0.5)", + Number.NaN, + Math.pow(-1, 0.5) ); + +new TestCase( SECTION, + "Math.pow(-1, NaN)", + Number.NaN, + Math.pow(-1, Number.NaN) ); + +new TestCase( SECTION, + "Math.pow(-1, -0.5)", + Number.NaN, + Math.pow(-1, -0.5) ); + +test(); diff --git a/tests/auto/qml/parserstress/tests/ecma/Math/15.8.2.14.js b/tests/auto/qml/parserstress/tests/ecma/Math/15.8.2.14.js new file mode 100644 index 0000000000..1972518c81 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Math/15.8.2.14.js @@ -0,0 +1,79 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.8.2.14.js'; + +/** + File Name: 15.8.2.14.js + ECMA Section: 15.8.2.14 Math.random() + returns a number value x with a positive sign + with 1 > x >= 0 with approximately uniform + distribution over that range, using an + implementation-dependent algorithm or strategy. + This function takes no arguments. + + Description: + Author: christine@netscape.com + Date: 16 september 1997 +*/ + +var SECTION = "15.8.2.14"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Math.random()"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +for ( var item = 0; item < 100; item++ ) { + var testcase = new TestCase( SECTION, + "Math.random()", + "pass", + null ); + testcase.reason = Math.random(); + testcase.actual = "pass"; + + if ( ! ( testcase.reason >= 0) ) { + testcase.actual = "fail"; + } + + if ( ! (testcase.reason < 1) ) { + testcase.actual = "fail"; + } +} + +test(); diff --git a/tests/auto/qml/parserstress/tests/ecma/Math/15.8.2.15.js b/tests/auto/qml/parserstress/tests/ecma/Math/15.8.2.15.js new file mode 100644 index 0000000000..a5c36b4e61 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Math/15.8.2.15.js @@ -0,0 +1,202 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.8.2.15.js'; + +/** + File Name: 15.8.2.15.js + ECMA Section: 15.8.2.15 Math.round(x) + Description: return the greatest number value that is closest to the + argument and is an integer. if two integers are equally + close to the argument. then the result is the number value + that is closer to Infinity. if the argument is an integer, + return the argument. + special cases: + - if x is NaN return NaN + - if x = +0 return +0 + - if x = -0 return -0 + - if x = Infinity return Infinity + - if x = -Infinity return -Infinity + - if 0 < x < 0.5 return 0 + - if -0.5 <= x < 0 return -0 + example: + Math.round( 3.5 ) == 4 + Math.round( -3.5 ) == 3 + also: + - Math.round(x) == Math.floor( x + 0.5 ) + except if x = -0. in that case, Math.round(x) = -0 + + and Math.floor( x+0.5 ) = +0 + + + Author: christine@netscape.com + Date: 7 july 1997 +*/ + +var SECTION = "15.8.2.15"; +var VERSION = "ECMA_1"; +var TITLE = "Math.round(x)"; +var BUGNUMBER="331411"; + +var EXCLUDE = "true"; + +startTest(); + +writeHeaderToLog( SECTION + " "+ TITLE); + +new TestCase( SECTION, + "Math.round.length", + 1, + Math.round.length ); + +new TestCase( SECTION, + "Math.round()", + Number.NaN, + Math.round() ); + +new TestCase( SECTION, + "Math.round(null)", + 0, + Math.round(0) ); + +new TestCase( SECTION, + "Math.round(void 0)", + Number.NaN, + Math.round(void 0) ); + +new TestCase( SECTION, + "Math.round(true)", + 1, + Math.round(true) ); + +new TestCase( SECTION, + "Math.round(false)", + 0, + Math.round(false) ); + +new TestCase( SECTION, + "Math.round('.99999')", + 1, + Math.round('.99999') ); + +new TestCase( SECTION, + "Math.round('12345e-2')", + 123, + Math.round('12345e-2') ); + +new TestCase( SECTION, + "Math.round(NaN)", + Number.NaN, + Math.round(Number.NaN) ); + +new TestCase( SECTION, + "Math.round(0)", + 0, + Math.round(0) ); + +new TestCase( SECTION, + "Math.round(-0)", + -0, + Math.round(-0)); + +new TestCase( SECTION, + "Infinity/Math.round(-0)", + -Infinity, + Infinity/Math.round(-0) ); + +new TestCase( SECTION, + "Math.round(Infinity)", + Number.POSITIVE_INFINITY, + Math.round(Number.POSITIVE_INFINITY)); + +new TestCase( SECTION, + "Math.round(-Infinity)", + Number.NEGATIVE_INFINITY, + Math.round(Number.NEGATIVE_INFINITY)); + +new TestCase( SECTION, + "Math.round(0.49)", + 0, + Math.round(0.49)); + +new TestCase( SECTION, + "Math.round(0.5)", + 1, + Math.round(0.5)); + +new TestCase( SECTION, + "Math.round(0.51)", + 1, + Math.round(0.51)); + +new TestCase( SECTION, + "Math.round(-0.49)", + -0, + Math.round(-0.49)); + +new TestCase( SECTION, + "Math.round(-0.5)", + -0, + Math.round(-0.5)); + +new TestCase( SECTION, + "Infinity/Math.round(-0.49)", + -Infinity, + Infinity/Math.round(-0.49)); + +new TestCase( SECTION, + "Infinity/Math.round(-0.5)", + -Infinity, + Infinity/Math.round(-0.5)); + +new TestCase( SECTION, + "Math.round(-0.51)", + -1, + Math.round(-0.51)); + +new TestCase( SECTION, + "Math.round(3.5)", + 4, + Math.round(3.5)); + +new TestCase( SECTION, + "Math.round(-3.5)", + -3, + Math.round(-3)); + +test(); diff --git a/tests/auto/qml/parserstress/tests/ecma/Math/15.8.2.16.js b/tests/auto/qml/parserstress/tests/ecma/Math/15.8.2.16.js new file mode 100644 index 0000000000..deb873cdaa --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Math/15.8.2.16.js @@ -0,0 +1,132 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.8.2.16.js'; + +/** + File Name: 15.8.2.16.js + ECMA Section: 15.8.2.16 sin( x ) + Description: return an approximation to the sine of the + argument. argument is expressed in radians + Author: christine@netscape.com + Date: 7 july 1997 + +*/ +var SECTION = "15.8.2.16"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Math.sin(x)"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +new TestCase( SECTION, + "Math.sin.length", + 1, + Math.sin.length ); + +new TestCase( SECTION, + "Math.sin()", + Number.NaN, + Math.sin() ); + +new TestCase( SECTION, + "Math.sin(null)", + 0, + Math.sin(null) ); + +new TestCase( SECTION, + "Math.sin(void 0)", + Number.NaN, + Math.sin(void 0) ); + +new TestCase( SECTION, + "Math.sin(false)", + 0, + Math.sin(false) ); + +new TestCase( SECTION, + "Math.sin('2.356194490192')", + 0.7071067811865, + Math.sin('2.356194490192') ); + +new TestCase( SECTION, + "Math.sin(NaN)", + Number.NaN, + Math.sin(Number.NaN) ); + +new TestCase( SECTION, + "Math.sin(0)", + 0, + Math.sin(0) ); + +new TestCase( SECTION, + "Math.sin(-0)", + -0, + Math.sin(-0)); + +new TestCase( SECTION, + "Math.sin(Infinity)", + Number.NaN, + Math.sin(Number.POSITIVE_INFINITY)); + +new TestCase( SECTION, + "Math.sin(-Infinity)", + Number.NaN, + Math.sin(Number.NEGATIVE_INFINITY)); + +new TestCase( SECTION, + "Math.sin(0.7853981633974)", + 0.7071067811865, + Math.sin(0.7853981633974)); + +new TestCase( SECTION, + "Math.sin(1.570796326795)", + 1, + Math.sin(1.570796326795)); + +new TestCase( SECTION, + "Math.sin(2.356194490192)", + 0.7071067811865, + Math.sin(2.356194490192)); + +new TestCase( SECTION, + "Math.sin(3.14159265359)", + 0, + Math.sin(3.14159265359)); + +test(); diff --git a/tests/auto/qml/parserstress/tests/ecma/Math/15.8.2.17.js b/tests/auto/qml/parserstress/tests/ecma/Math/15.8.2.17.js new file mode 100644 index 0000000000..2f12f1d93b --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Math/15.8.2.17.js @@ -0,0 +1,217 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.8.2.17.js'; + +/** + File Name: 15.8.2.17.js + ECMA Section: 15.8.2.17 Math.sqrt(x) + Description: return an approximation to the squareroot of the argument. + special cases: + - if x is NaN return NaN + - if x < 0 return NaN + - if x == 0 return 0 + - if x == -0 return -0 + - if x == Infinity return Infinity + Author: christine@netscape.com + Date: 7 july 1997 +*/ + +var SECTION = "15.8.2.17"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Math.sqrt(x)"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +new TestCase( SECTION, + "Math.sqrt.length", + 1, + Math.sqrt.length ); + +new TestCase( SECTION, + "Math.sqrt()", + Number.NaN, + Math.sqrt() ); + +new TestCase( SECTION, + "Math.sqrt(void 0)", + Number.NaN, + Math.sqrt(void 0) ); + +new TestCase( SECTION, + "Math.sqrt(null)", + 0, + Math.sqrt(null) ); + +new TestCase( SECTION, + "Math.sqrt(true)", + 1, + Math.sqrt(1) ); + +new TestCase( SECTION, + "Math.sqrt(false)", + 0, + Math.sqrt(false) ); + +new TestCase( SECTION, + "Math.sqrt('225')", + 15, + Math.sqrt('225') ); + +new TestCase( SECTION, + "Math.sqrt(NaN)", + Number.NaN, + Math.sqrt(Number.NaN) ); + +new TestCase( SECTION, + "Math.sqrt(-Infinity)", + Number.NaN, + Math.sqrt(Number.NEGATIVE_INFINITY)); + +new TestCase( SECTION, + "Math.sqrt(-1)", + Number.NaN, + Math.sqrt(-1)); + +new TestCase( SECTION, + "Math.sqrt(-0.5)", + Number.NaN, + Math.sqrt(-0.5)); + +new TestCase( SECTION, + "Math.sqrt(0)", + 0, + Math.sqrt(0)); + +new TestCase( SECTION, + "Math.sqrt(-0)", + -0, + Math.sqrt(-0)); + +new TestCase( SECTION, + "Infinity/Math.sqrt(-0)", + -Infinity, + Infinity/Math.sqrt(-0) ); + +new TestCase( SECTION, + "Math.sqrt(Infinity)", + Number.POSITIVE_INFINITY, + Math.sqrt(Number.POSITIVE_INFINITY)); + +new TestCase( SECTION, + "Math.sqrt(1)", + 1, + Math.sqrt(1)); + +new TestCase( SECTION, + "Math.sqrt(2)", + Math.SQRT2, + Math.sqrt(2)); + +new TestCase( SECTION, + "Math.sqrt(0.5)", + Math.SQRT1_2, + Math.sqrt(0.5)); + +new TestCase( SECTION, + "Math.sqrt(4)", + 2, + Math.sqrt(4)); + +new TestCase( SECTION, + "Math.sqrt(9)", + 3, + Math.sqrt(9)); + +new TestCase( SECTION, + "Math.sqrt(16)", + 4, + Math.sqrt(16)); + +new TestCase( SECTION, + "Math.sqrt(25)", + 5, + Math.sqrt(25)); + +new TestCase( SECTION, + "Math.sqrt(36)", + 6, + Math.sqrt(36)); + +new TestCase( SECTION, + "Math.sqrt(49)", + 7, + Math.sqrt(49)); + +new TestCase( SECTION, + "Math.sqrt(64)", + 8, + Math.sqrt(64)); + +new TestCase( SECTION, + "Math.sqrt(256)", + 16, + Math.sqrt(256)); + +new TestCase( SECTION, + "Math.sqrt(10000)", + 100, + Math.sqrt(10000)); + +new TestCase( SECTION, + "Math.sqrt(65536)", + 256, + Math.sqrt(65536)); + +new TestCase( SECTION, + "Math.sqrt(0.09)", + 0.3, + Math.sqrt(0.09)); + +new TestCase( SECTION, + "Math.sqrt(0.01)", + 0.1, + Math.sqrt(0.01)); + +new TestCase( SECTION, + "Math.sqrt(0.00000001)", + 0.0001, + Math.sqrt(0.00000001)); + +test(); diff --git a/tests/auto/qml/parserstress/tests/ecma/Math/15.8.2.18.js b/tests/auto/qml/parserstress/tests/ecma/Math/15.8.2.18.js new file mode 100644 index 0000000000..be68ea191f --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Math/15.8.2.18.js @@ -0,0 +1,165 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.8.2.18.js'; + +/** + File Name: 15.8.2.18.js + ECMA Section: 15.8.2.18 tan( x ) + Description: return an approximation to the tan of the + argument. argument is expressed in radians + special cases: + - if x is NaN result is NaN + - if x is 0 result is 0 + - if x is -0 result is -0 + - if x is Infinity or -Infinity result is NaN + Author: christine@netscape.com + Date: 7 july 1997 +*/ + +var SECTION = "15.8.2.18"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Math.tan(x)"; +var EXCLUDE = "true"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +new TestCase( SECTION, + "Math.tan.length", + 1, + Math.tan.length ); + +new TestCase( SECTION, + "Math.tan()", + Number.NaN, + Math.tan() ); + +new TestCase( SECTION, + "Math.tan(void 0)", + Number.NaN, + Math.tan(void 0)); + +new TestCase( SECTION, + "Math.tan(null)", + 0, + Math.tan(null) ); + +new TestCase( SECTION, + "Math.tan(false)", + 0, + Math.tan(false) ); + +new TestCase( SECTION, + "Math.tan(NaN)", + Number.NaN, + Math.tan(Number.NaN) ); + +new TestCase( SECTION, + "Math.tan(0)", + 0, + Math.tan(0)); + +new TestCase( SECTION, + "Math.tan(-0)", + -0, + Math.tan(-0)); + +new TestCase( SECTION, + "Math.tan(Infinity)", + Number.NaN, + Math.tan(Number.POSITIVE_INFINITY)); + +new TestCase( SECTION, + "Math.tan(-Infinity)", + Number.NaN, + Math.tan(Number.NEGATIVE_INFINITY)); + +new TestCase( SECTION, + "Math.tan(Math.PI/4)", + 1, + Math.tan(Math.PI/4)); + +new TestCase( SECTION, + "Math.tan(3*Math.PI/4)", + -1, + Math.tan(3*Math.PI/4)); + +new TestCase( SECTION, + "Math.tan(Math.PI)", + -0, + Math.tan(Math.PI)); + +new TestCase( SECTION, + "Math.tan(5*Math.PI/4)", + 1, + Math.tan(5*Math.PI/4)); + +new TestCase( SECTION, + "Math.tan(7*Math.PI/4)", + -1, + Math.tan(7*Math.PI/4)); + +new TestCase( SECTION, + "Infinity/Math.tan(-0)", + -Infinity, + Infinity/Math.tan(-0) ); + +/* + Arctan (x) ~ PI/2 - 1/x for large x. For x = 1.6x10^16, 1/x is about the last binary digit of double precision PI/2. + That is to say, perturbing PI/2 by this much is about the smallest rounding error possible. + + This suggests that the answer Christine is getting and a real Infinity are "adjacent" results from the tangent function. I + suspect that tan (PI/2 + one ulp) is a negative result about the same size as tan (PI/2) and that this pair are the closest + results to infinity that the algorithm can deliver. + + In any case, my call is that the answer we're seeing is "right". I suggest the test pass on any result this size or larger. + = C = +*/ + +new TestCase( SECTION, + "Math.tan(3*Math.PI/2) >= 5443000000000000", + true, + Math.tan(3*Math.PI/2) >= 5443000000000000 ); + +new TestCase( SECTION, + "Math.tan(Math.PI/2) >= 5443000000000000", + true, + Math.tan(Math.PI/2) >= 5443000000000000 ); + +test(); diff --git a/tests/auto/qml/parserstress/tests/ecma/Math/15.8.2.2.js b/tests/auto/qml/parserstress/tests/ecma/Math/15.8.2.2.js new file mode 100644 index 0000000000..12fb00ef81 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Math/15.8.2.2.js @@ -0,0 +1,151 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.8.2.2.js'; + +/** + File Name: 15.8.2.2.js + ECMA Section: 15.8.2.2 acos( x ) + Description: return an approximation to the arc cosine of the + argument. the result is expressed in radians and + range is from +0 to +PI. special cases: + - if x is NaN, return NaN + - if x > 1, the result is NaN + - if x < -1, the result is NaN + - if x == 1, the result is +0 + Author: christine@netscape.com + Date: 7 july 1997 +*/ +var SECTION = "15.8.2.2"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Math.acos()"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +new TestCase( SECTION, + "Math.acos.length", + 1, + Math.acos.length ); + +new TestCase( SECTION, + "Math.acos(void 0)", + Number.NaN, + Math.acos(void 0) ); + +new TestCase( SECTION, + "Math.acos()", + Number.NaN, + Math.acos() ); + +new TestCase( SECTION, + "Math.acos(null)", + Math.PI/2, + Math.acos(null) ); + +new TestCase( SECTION, + "Math.acos(NaN)", + Number.NaN, + Math.acos(Number.NaN) ); + +new TestCase( SECTION, + "Math.acos(a string)", + Number.NaN, + Math.acos("a string") ); + +new TestCase( SECTION, + "Math.acos('0')", + Math.PI/2, + Math.acos('0') ); + +new TestCase( SECTION, + "Math.acos('1')", + 0, + Math.acos('1') ); + +new TestCase( SECTION, + "Math.acos('-1')", + Math.PI, + Math.acos('-1') ); + +new TestCase( SECTION, + "Math.acos(1.00000001)", + Number.NaN, + Math.acos(1.00000001) ); + +new TestCase( SECTION, + "Math.acos(11.00000001)", + Number.NaN, + Math.acos(-1.00000001) ); + +new TestCase( SECTION, + "Math.acos(1)", + 0, + Math.acos(1) ); + +new TestCase( SECTION, + "Math.acos(-1)", + Math.PI, + Math.acos(-1) ); + +new TestCase( SECTION, + "Math.acos(0)", + Math.PI/2, + Math.acos(0) ); + +new TestCase( SECTION, + "Math.acos(-0)", + Math.PI/2, + Math.acos(-0) ); + +new TestCase( SECTION, + "Math.acos(Math.SQRT1_2)", + Math.PI/4, + Math.acos(Math.SQRT1_2)); + +new TestCase( SECTION, + "Math.acos(-Math.SQRT1_2)", + Math.PI/4*3, + Math.acos(-Math.SQRT1_2)); + +new TestCase( SECTION, + "Math.acos(0.9999619230642)", + Math.PI/360, + Math.acos(0.9999619230642)); + +test(); diff --git a/tests/auto/qml/parserstress/tests/ecma/Math/15.8.2.3.js b/tests/auto/qml/parserstress/tests/ecma/Math/15.8.2.3.js new file mode 100644 index 0000000000..11c6d73657 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Math/15.8.2.3.js @@ -0,0 +1,158 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.8.2.3.js'; + +/** + File Name: 15.8.2.3.js + ECMA Section: 15.8.2.3 asin( x ) + Description: return an approximation to the arc sine of the + argument. the result is expressed in radians and + range is from -PI/2 to +PI/2. special cases: + - if x is NaN, the result is NaN + - if x > 1, the result is NaN + - if x < -1, the result is NaN + - if x == +0, the result is +0 + - if x == -0, the result is -0 + Author: christine@netscape.com + Date: 7 july 1997 + +*/ +var SECTION = "15.8.2.3"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Math.asin()"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +new TestCase( SECTION, + "Math.asin()", + Number.NaN, + Math.asin() ); + +new TestCase( SECTION, + "Math.asin(void 0)", + Number.NaN, + Math.asin(void 0) ); + +new TestCase( SECTION, + "Math.asin(null)", + 0, + Math.asin(null) ); + +new TestCase( SECTION, + "Math.asin(NaN)", + Number.NaN, + Math.asin(Number.NaN) ); + +new TestCase( SECTION, + "Math.asin('string')", + Number.NaN, + Math.asin("string") ); + +new TestCase( SECTION, + "Math.asin('0')", + 0, + Math.asin("0") ); + +new TestCase( SECTION, + "Math.asin('1')", + Math.PI/2, + Math.asin("1") ); + +new TestCase( SECTION, + "Math.asin('-1')", + -Math.PI/2, + Math.asin("-1") ); + +new TestCase( SECTION, + "Math.asin(Math.SQRT1_2+'')", + Math.PI/4, + Math.asin(Math.SQRT1_2+'') ); + +new TestCase( SECTION, + "Math.asin(-Math.SQRT1_2+'')", + -Math.PI/4, + Math.asin(-Math.SQRT1_2+'') ); + +new TestCase( SECTION, + "Math.asin(1.000001)", + Number.NaN, + Math.asin(1.000001) ); + +new TestCase( SECTION, + "Math.asin(-1.000001)", + Number.NaN, + Math.asin(-1.000001) ); + +new TestCase( SECTION, + "Math.asin(0)", + 0, + Math.asin(0) ); + +new TestCase( SECTION, + "Math.asin(-0)", + -0, + Math.asin(-0) ); + +new TestCase( SECTION, + "Infinity/Math.asin(-0)", + -Infinity, + Infinity/Math.asin(-0) ); + +new TestCase( SECTION, + "Math.asin(1)", + Math.PI/2, + Math.asin(1) ); + +new TestCase( SECTION, + "Math.asin(-1)", + -Math.PI/2, + Math.asin(-1) ); + +new TestCase( SECTION, + "Math.asin(Math.SQRT1_2))", + Math.PI/4, + Math.asin(Math.SQRT1_2) ); + +new TestCase( SECTION, + "Math.asin(-Math.SQRT1_2))", + -Math.PI/4, + Math.asin(-Math.SQRT1_2)); + +test(); diff --git a/tests/auto/qml/parserstress/tests/ecma/Math/15.8.2.4.js b/tests/auto/qml/parserstress/tests/ecma/Math/15.8.2.4.js new file mode 100644 index 0000000000..c67ac6d4ea --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Math/15.8.2.4.js @@ -0,0 +1,156 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.8.2.4.js'; + +/** + File Name: 15.8.2.4.js + ECMA Section: 15.8.2.4 atan( x ) + Description: return an approximation to the arc tangent of the + argument. the result is expressed in radians and + range is from -PI/2 to +PI/2. special cases: + - if x is NaN, the result is NaN + - if x == +0, the result is +0 + - if x == -0, the result is -0 + - if x == +Infinity, the result is approximately +PI/2 + - if x == -Infinity, the result is approximately -PI/2 + Author: christine@netscape.com + Date: 7 july 1997 + +*/ + +var SECTION = "15.8.2.4"; +var VERSION = "ECMA_1"; +var TITLE = "Math.atan()"; +var BUGNUMBER="77391"; + +startTest(); + +writeHeaderToLog( SECTION + " "+ TITLE); + +new TestCase( SECTION, + "Math.atan.length", + 1, + Math.atan.length ); + +new TestCase( SECTION, + "Math.atan()", + Number.NaN, + Math.atan() ); + +new TestCase( SECTION, + "Math.atan(void 0)", + Number.NaN, + Math.atan(void 0) ); + +new TestCase( SECTION, + "Math.atan(null)", + 0, + Math.atan(null) ); + +new TestCase( SECTION, + "Math.atan(NaN)", + Number.NaN, + Math.atan(Number.NaN) ); + +new TestCase( SECTION, + "Math.atan('a string')", + Number.NaN, + Math.atan("a string") ); + +new TestCase( SECTION, + "Math.atan('0')", + 0, + Math.atan('0') ); + +new TestCase( SECTION, + "Math.atan('1')", + Math.PI/4, + Math.atan('1') ); + +new TestCase( SECTION, + "Math.atan('-1')", + -Math.PI/4, + Math.atan('-1') ); + +new TestCase( SECTION, + "Math.atan('Infinity)", + Math.PI/2, + Math.atan('Infinity') ); + +new TestCase( SECTION, + "Math.atan('-Infinity)", + -Math.PI/2, + Math.atan('-Infinity') ); + +new TestCase( SECTION, + "Math.atan(0)", + 0, + Math.atan(0) ); + +new TestCase( SECTION, + "Math.atan(-0)", + -0, + Math.atan(-0) ); + +new TestCase( SECTION, + "Infinity/Math.atan(-0)", + -Infinity, + Infinity/Math.atan(-0) ); + +new TestCase( SECTION, + "Math.atan(Infinity)", + Math.PI/2, + Math.atan(Number.POSITIVE_INFINITY) ); + +new TestCase( SECTION, + "Math.atan(-Infinity)", + -Math.PI/2, + Math.atan(Number.NEGATIVE_INFINITY) ); + +new TestCase( SECTION, + "Math.atan(1)", + Math.PI/4, + Math.atan(1) ); + +new TestCase( SECTION, + "Math.atan(-1)", + -Math.PI/4, + Math.atan(-1) ); + +test(); diff --git a/tests/auto/qml/parserstress/tests/ecma/Math/15.8.2.5.js b/tests/auto/qml/parserstress/tests/ecma/Math/15.8.2.5.js new file mode 100644 index 0000000000..0adc690743 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Math/15.8.2.5.js @@ -0,0 +1,244 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.8.2.5.js'; + +/** + File Name: 15.8.2.5.js + ECMA Section: 15.8.2.5 atan2( y, x ) + Description: + + Author: christine@netscape.com + Date: 7 july 1997 + +*/ +var SECTION = "15.8.2.5"; +var VERSION = "ECMA_1"; +var TITLE = "Math.atan2(x,y)"; +var BUGNUMBER="76111"; + +startTest(); + +writeHeaderToLog( SECTION + " "+ TITLE); + +new TestCase( SECTION, + "Math.atan2.length", + 2, + Math.atan2.length ); + +new TestCase( SECTION, + "Math.atan2(NaN, 0)", + Number.NaN, + Math.atan2(Number.NaN,0) ); + +new TestCase( SECTION, + "Math.atan2(null, null)", + 0, + Math.atan2(null, null) ); + +new TestCase( SECTION, + "Math.atan2(void 0, void 0)", + Number.NaN, + Math.atan2(void 0, void 0) ); + +new TestCase( SECTION, + "Math.atan2()", + Number.NaN, + Math.atan2() ); + +new TestCase( SECTION, + "Math.atan2(0, NaN)", + Number.NaN, + Math.atan2(0,Number.NaN) ); + +new TestCase( SECTION, + "Math.atan2(1, 0)", + Math.PI/2, + Math.atan2(1,0) ); + +new TestCase( SECTION, + "Math.atan2(1,-0)", + Math.PI/2, + Math.atan2(1,-0) ); + +new TestCase( SECTION, + "Math.atan2(0,0.001)", + 0, + Math.atan2(0,0.001) ); + +new TestCase( SECTION, + "Math.atan2(0,0)", + 0, + Math.atan2(0,0) ); + +new TestCase( SECTION, + "Math.atan2(0, -0)", + Math.PI, + Math.atan2(0,-0) ); + +new TestCase( SECTION, + "Math.atan2(0, -1)", + Math.PI, + Math.atan2(0, -1) ); + +new TestCase( SECTION, + "Math.atan2(-0, 1)", + -0, + Math.atan2(-0, 1) ); + +new TestCase( SECTION, + "Infinity/Math.atan2(-0, 1)", + -Infinity, + Infinity/Math.atan2(-0,1) ); + +new TestCase( SECTION, + "Math.atan2(-0, 0)", + -0, + Math.atan2(-0,0) ); + +new TestCase( SECTION, + "Math.atan2(-0, -0)", + -Math.PI, + Math.atan2(-0, -0) ); + +new TestCase( SECTION, + "Math.atan2(-0, -1)", + -Math.PI, + Math.atan2(-0, -1) ); + +new TestCase( SECTION, + "Math.atan2(-1, 0)", + -Math.PI/2, + Math.atan2(-1, 0) ); + +new TestCase( SECTION, + "Math.atan2(-1, -0)", + -Math.PI/2, + Math.atan2(-1, -0) ); + +new TestCase( SECTION, + "Math.atan2(1, Infinity)", + 0, + Math.atan2(1, Number.POSITIVE_INFINITY) ); + +new TestCase( SECTION, + "Math.atan2(1,-Infinity)", + Math.PI, + Math.atan2(1, Number.NEGATIVE_INFINITY) ); + +new TestCase( SECTION, + "Math.atan2(-1, Infinity)", + -0, + Math.atan2(-1,Number.POSITIVE_INFINITY) ); + +new TestCase( SECTION, + "Infinity/Math.atan2(-1, Infinity)", + -Infinity, + Infinity/Math.atan2(-1,Infinity) ); + +new TestCase( SECTION, + "Math.atan2(-1,-Infinity)", + -Math.PI, + Math.atan2(-1,Number.NEGATIVE_INFINITY) ); + +new TestCase( SECTION, + "Math.atan2(Infinity, 0)", + Math.PI/2, + Math.atan2(Number.POSITIVE_INFINITY, 0) ); + +new TestCase( SECTION, + "Math.atan2(Infinity, 1)", + Math.PI/2, + Math.atan2(Number.POSITIVE_INFINITY, 1) ); + +new TestCase( SECTION, + "Math.atan2(Infinity,-1)", + Math.PI/2, + Math.atan2(Number.POSITIVE_INFINITY,-1) ); + +new TestCase( SECTION, + "Math.atan2(Infinity,-0)", + Math.PI/2, + Math.atan2(Number.POSITIVE_INFINITY,-0) ); + +new TestCase( SECTION, + "Math.atan2(-Infinity, 0)", + -Math.PI/2, + Math.atan2(Number.NEGATIVE_INFINITY, 0) ); + +new TestCase( SECTION, + "Math.atan2(-Infinity,-0)", + -Math.PI/2, + Math.atan2(Number.NEGATIVE_INFINITY,-0) ); + +new TestCase( SECTION, + "Math.atan2(-Infinity, 1)", + -Math.PI/2, + Math.atan2(Number.NEGATIVE_INFINITY, 1) ); + +new TestCase( SECTION, + "Math.atan2(-Infinity, -1)", + -Math.PI/2, + Math.atan2(Number.NEGATIVE_INFINITY,-1) ); + +new TestCase( SECTION, + "Math.atan2(Infinity, Infinity)", + Math.PI/4, + Math.atan2(Number.POSITIVE_INFINITY, Number.POSITIVE_INFINITY) ); + +new TestCase( SECTION, + "Math.atan2(Infinity, -Infinity)", + 3*Math.PI/4, + Math.atan2(Number.POSITIVE_INFINITY, Number.NEGATIVE_INFINITY) ); + +new TestCase( SECTION, + "Math.atan2(-Infinity, Infinity)", + -Math.PI/4, + Math.atan2(Number.NEGATIVE_INFINITY, Number.POSITIVE_INFINITY) ); + +new TestCase( SECTION, + "Math.atan2(-Infinity, -Infinity)", + -3*Math.PI/4, + Math.atan2(Number.NEGATIVE_INFINITY, Number.NEGATIVE_INFINITY) ); + +new TestCase( SECTION, + "Math.atan2(-1, 1)", + -Math.PI/4, + Math.atan2( -1, 1) ); + +test(); diff --git a/tests/auto/qml/parserstress/tests/ecma/Math/15.8.2.6.js b/tests/auto/qml/parserstress/tests/ecma/Math/15.8.2.6.js new file mode 100644 index 0000000000..1c20a1c93e --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Math/15.8.2.6.js @@ -0,0 +1,232 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.8.2.6.js'; + +/** + File Name: 15.8.2.6.js + ECMA Section: 15.8.2.6 Math.ceil(x) + Description: return the smallest number value that is not less than the + argument and is equal to a mathematical integer. if the + number is already an integer, return the number itself. + special cases: + - if x is NaN return NaN + - if x = +0 return +0 + - if x = 0 return -0 + - if x = Infinity return Infinity + - if x = -Infinity return -Infinity + - if ( -1 < x < 0 ) return -0 + also: + - the value of Math.ceil(x) == -Math.ceil(-x) + Author: christine@netscape.com + Date: 7 july 1997 +*/ +var SECTION = "15.8.2.6"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Math.ceil(x)"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +new TestCase( SECTION, + "Math.ceil.length", + 1, + Math.ceil.length ); + +new TestCase( SECTION, + "Math.ceil(NaN)", + Number.NaN, + Math.ceil(Number.NaN) ); + +new TestCase( SECTION, + "Math.ceil(null)", + 0, + Math.ceil(null) ); + +new TestCase( SECTION, + "Math.ceil()", + Number.NaN, + Math.ceil() ); + +new TestCase( SECTION, + "Math.ceil(void 0)", + Number.NaN, + Math.ceil(void 0) ); + +new TestCase( SECTION, + "Math.ceil('0')", + 0, + Math.ceil('0') ); + +new TestCase( SECTION, + "Math.ceil('-0')", + -0, + Math.ceil('-0') ); + +new TestCase( SECTION, + "Infinity/Math.ceil('0')", + Infinity, + Infinity/Math.ceil('0')); + +new TestCase( SECTION, + "Infinity/Math.ceil('-0')", + -Infinity, + Infinity/Math.ceil('-0')); + +new TestCase( SECTION, + "Math.ceil(0)", + 0, + Math.ceil(0) ); + +new TestCase( SECTION, + "Math.ceil(-0)", + -0, + Math.ceil(-0) ); + +new TestCase( SECTION, + "Infinity/Math.ceil(0)", + Infinity, + Infinity/Math.ceil(0)); + +new TestCase( SECTION, + "Infinity/Math.ceil(-0)", + -Infinity, + Infinity/Math.ceil(-0)); + + +new TestCase( SECTION, + "Math.ceil(Infinity)", + Number.POSITIVE_INFINITY, + Math.ceil(Number.POSITIVE_INFINITY) ); + +new TestCase( SECTION, + "Math.ceil(-Infinity)", + Number.NEGATIVE_INFINITY, + Math.ceil(Number.NEGATIVE_INFINITY) ); + +new TestCase( SECTION, + "Math.ceil(-Number.MIN_VALUE)", + -0, + Math.ceil(-Number.MIN_VALUE) ); + +new TestCase( SECTION, + "Infinity/Math.ceil(-Number.MIN_VALUE)", + -Infinity, + Infinity/Math.ceil(-Number.MIN_VALUE) ); + +new TestCase( SECTION, + "Math.ceil(1)", + 1, + Math.ceil(1) ); + +new TestCase( SECTION, + "Math.ceil(-1)", + -1, + Math.ceil(-1) ); + +new TestCase( SECTION, + "Math.ceil(-0.9)", + -0, + Math.ceil(-0.9) ); + +new TestCase( SECTION, + "Infinity/Math.ceil(-0.9)", + -Infinity, + Infinity/Math.ceil(-0.9) ); + +new TestCase( SECTION, + "Math.ceil(0.9 )", + 1, + Math.ceil( 0.9) ); + +new TestCase( SECTION, + "Math.ceil(-1.1)", + -1, + Math.ceil( -1.1)); + +new TestCase( SECTION, + "Math.ceil( 1.1)", + 2, + Math.ceil( 1.1)); + +new TestCase( SECTION, + "Math.ceil(Infinity)", + -Math.floor(-Infinity), + Math.ceil(Number.POSITIVE_INFINITY) ); + +new TestCase( SECTION, + "Math.ceil(-Infinity)", + -Math.floor(Infinity), + Math.ceil(Number.NEGATIVE_INFINITY) ); + +new TestCase( SECTION, + "Math.ceil(-Number.MIN_VALUE)", + -Math.floor(Number.MIN_VALUE), + Math.ceil(-Number.MIN_VALUE) ); + +new TestCase( SECTION, + "Math.ceil(1)", + -Math.floor(-1), + Math.ceil(1) ); + +new TestCase( SECTION, + "Math.ceil(-1)", + -Math.floor(1), + Math.ceil(-1) ); + +new TestCase( SECTION, + "Math.ceil(-0.9)", + -Math.floor(0.9), + Math.ceil(-0.9) ); + +new TestCase( SECTION, + "Math.ceil(0.9 )", + -Math.floor(-0.9), + Math.ceil( 0.9) ); + +new TestCase( SECTION, + "Math.ceil(-1.1)", + -Math.floor(1.1), + Math.ceil( -1.1)); + +new TestCase( SECTION, + "Math.ceil( 1.1)", + -Math.floor(-1.1), + Math.ceil( 1.1)); + +test(); diff --git a/tests/auto/qml/parserstress/tests/ecma/Math/15.8.2.7.js b/tests/auto/qml/parserstress/tests/ecma/Math/15.8.2.7.js new file mode 100644 index 0000000000..2b19b5986e --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Math/15.8.2.7.js @@ -0,0 +1,283 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.8.2.7.js'; + +/** + File Name: 15.8.2.7.js + ECMA Section: 15.8.2.7 cos( x ) + Description: return an approximation to the cosine of the + argument. argument is expressed in radians + Author: christine@netscape.com + Date: 7 july 1997 + +*/ + +var SECTION = "15.8.2.7"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Math.cos(x)"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +new TestCase( SECTION, + "Math.cos.length", + 1, + Math.cos.length ); + +new TestCase( SECTION, + "Math.cos()", + Number.NaN, + Math.cos() ); + +new TestCase( SECTION, + "Math.cos(void 0)", + Number.NaN, + Math.cos(void 0) ); + +new TestCase( SECTION, + "Math.cos(false)", + 1, + Math.cos(false) ); + +new TestCase( SECTION, + "Math.cos(null)", + 1, + Math.cos(null) ); + +new TestCase( SECTION, + "Math.cos('0')", + 1, + Math.cos('0') ); + +new TestCase( SECTION, + "Math.cos('Infinity')", + Number.NaN, + Math.cos("Infinity") ); + +new TestCase( SECTION, + "Math.cos('3.14159265359')", + -1, + Math.cos('3.14159265359') ); + +new TestCase( SECTION, + "Math.cos(NaN)", + Number.NaN, + Math.cos(Number.NaN) ); + +new TestCase( SECTION, + "Math.cos(0)", + 1, + Math.cos(0) ); + +new TestCase( SECTION, + "Math.cos(-0)", + 1, + Math.cos(-0) ); + +new TestCase( SECTION, + "Math.cos(Infinity)", + Number.NaN, + Math.cos(Number.POSITIVE_INFINITY) ); + +new TestCase( SECTION, + "Math.cos(-Infinity)", + Number.NaN, + Math.cos(Number.NEGATIVE_INFINITY) ); + +new TestCase( SECTION, + "Math.cos(0.7853981633974)", + 0.7071067811865, + Math.cos(0.7853981633974) ); + +new TestCase( SECTION, + "Math.cos(1.570796326795)", + 0, + Math.cos(1.570796326795) ); + +new TestCase( SECTION, + "Math.cos(2.356194490192)", + -0.7071067811865, + Math.cos(2.356194490192) ); + +new TestCase( SECTION, + "Math.cos(3.14159265359)", + -1, + Math.cos(3.14159265359) ); + +new TestCase( SECTION, + "Math.cos(3.926990816987)", + -0.7071067811865, + Math.cos(3.926990816987) ); + +new TestCase( SECTION, + "Math.cos(4.712388980385)", + 0, + Math.cos(4.712388980385) ); + +new TestCase( SECTION, + "Math.cos(5.497787143782)", + 0.7071067811865, + Math.cos(5.497787143782) ); + +new TestCase( SECTION, + "Math.cos(Math.PI*2)", + 1, + Math.cos(Math.PI*2) ); + +new TestCase( SECTION, + "Math.cos(Math.PI/4)", + Math.SQRT2/2, + Math.cos(Math.PI/4) ); + +new TestCase( SECTION, + "Math.cos(Math.PI/2)", + 0, + Math.cos(Math.PI/2) ); + +new TestCase( SECTION, + "Math.cos(3*Math.PI/4)", + -Math.SQRT2/2, + Math.cos(3*Math.PI/4) ); + +new TestCase( SECTION, + "Math.cos(Math.PI)", + -1, + Math.cos(Math.PI) ); + +new TestCase( SECTION, + "Math.cos(5*Math.PI/4)", + -Math.SQRT2/2, + Math.cos(5*Math.PI/4) ); + +new TestCase( SECTION, + "Math.cos(3*Math.PI/2)", + 0, + Math.cos(3*Math.PI/2) ); + +new TestCase( SECTION, + "Math.cos(7*Math.PI/4)", + Math.SQRT2/2, + Math.cos(7*Math.PI/4) ); + +new TestCase( SECTION, + "Math.cos(Math.PI*2)", + 1, + Math.cos(2*Math.PI) ); + +new TestCase( SECTION, + "Math.cos(-0.7853981633974)", + 0.7071067811865, + Math.cos(-0.7853981633974) ); + +new TestCase( SECTION, + "Math.cos(-1.570796326795)", + 0, + Math.cos(-1.570796326795) ); + +new TestCase( SECTION, + "Math.cos(-2.3561944901920)", + -.7071067811865, + Math.cos(2.3561944901920) ); + +new TestCase( SECTION, + "Math.cos(-3.14159265359)", + -1, + Math.cos(3.14159265359) ); + +new TestCase( SECTION, + "Math.cos(-3.926990816987)", + -0.7071067811865, + Math.cos(3.926990816987) ); + +new TestCase( SECTION, + "Math.cos(-4.712388980385)", + 0, + Math.cos(4.712388980385) ); + +new TestCase( SECTION, + "Math.cos(-5.497787143782)", + 0.7071067811865, + Math.cos(5.497787143782) ); + +new TestCase( SECTION, + "Math.cos(-6.28318530718)", + 1, + Math.cos(6.28318530718) ); + +new TestCase( SECTION, + "Math.cos(-Math.PI/4)", + Math.SQRT2/2, + Math.cos(-Math.PI/4) ); + +new TestCase( SECTION, + "Math.cos(-Math.PI/2)", + 0, + Math.cos(-Math.PI/2) ); + +new TestCase( SECTION, + "Math.cos(-3*Math.PI/4)", + -Math.SQRT2/2, + Math.cos(-3*Math.PI/4) ); + +new TestCase( SECTION, + "Math.cos(-Math.PI)", + -1, + Math.cos(-Math.PI) ); + +new TestCase( SECTION, + "Math.cos(-5*Math.PI/4)", + -Math.SQRT2/2, + Math.cos(-5*Math.PI/4) ); + +new TestCase( SECTION, + "Math.cos(-3*Math.PI/2)", + 0, + Math.cos(-3*Math.PI/2) ); + +new TestCase( SECTION, + "Math.cos(-7*Math.PI/4)", + Math.SQRT2/2, + Math.cos(-7*Math.PI/4) ); + +new TestCase( SECTION, + "Math.cos(-Math.PI*2)", + 1, + Math.cos(-Math.PI*2) ); + +test(); diff --git a/tests/auto/qml/parserstress/tests/ecma/Math/15.8.2.8.js b/tests/auto/qml/parserstress/tests/ecma/Math/15.8.2.8.js new file mode 100644 index 0000000000..96b6231da2 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Math/15.8.2.8.js @@ -0,0 +1,134 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.8.2.8.js'; + +/** + File Name: 15.8.2.8.js + ECMA Section: 15.8.2.8 Math.exp(x) + Description: return an approximation to the exponential function of + the argument (e raised to the power of the argument) + special cases: + - if x is NaN return NaN + - if x is 0 return 1 + - if x is -0 return 1 + - if x is Infinity return Infinity + - if x is -Infinity return 0 + Author: christine@netscape.com + Date: 7 july 1997 +*/ + + +var SECTION = "15.8.2.8"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Math.exp(x)"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +new TestCase( SECTION, + "Math.exp.length", + 1, + Math.exp.length ); + +new TestCase( SECTION, + "Math.exp()", + Number.NaN, + Math.exp() ); + +new TestCase( SECTION, + "Math.exp(null)", + 1, + Math.exp(null) ); + +new TestCase( SECTION, + "Math.exp(void 0)", + Number.NaN, + Math.exp(void 0) ); + +new TestCase( SECTION, + "Math.exp(1)", + Math.E, + Math.exp(1) ); + +new TestCase( SECTION, + "Math.exp(true)", + Math.E, + Math.exp(true) ); + +new TestCase( SECTION, + "Math.exp(false)", + 1, + Math.exp(false) ); + +new TestCase( SECTION, + "Math.exp('1')", + Math.E, + Math.exp('1') ); + +new TestCase( SECTION, + "Math.exp('0')", + 1, + Math.exp('0') ); + +new TestCase( SECTION, + "Math.exp(NaN)", + Number.NaN, + Math.exp(Number.NaN) ); + +new TestCase( SECTION, + "Math.exp(0)", + 1, + Math.exp(0) ); + +new TestCase( SECTION, + "Math.exp(-0)", + 1, + Math.exp(-0) ); + +new TestCase( SECTION, + "Math.exp(Infinity)", + Number.POSITIVE_INFINITY, + Math.exp(Number.POSITIVE_INFINITY) ); + +new TestCase( SECTION, + "Math.exp(-Infinity)", + 0, + Math.exp(Number.NEGATIVE_INFINITY) ); + +test(); diff --git a/tests/auto/qml/parserstress/tests/ecma/Math/15.8.2.9.js b/tests/auto/qml/parserstress/tests/ecma/Math/15.8.2.9.js new file mode 100644 index 0000000000..b68a57d5bb --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Math/15.8.2.9.js @@ -0,0 +1,191 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.8.2.9.js'; + +/** + File Name: 15.8.2.9.js + ECMA Section: 15.8.2.9 Math.floor(x) + Description: return the greatest number value that is not greater + than the argument and is equal to a mathematical integer. + if the number is already an integer, return the number + itself. special cases: + - if x is NaN return NaN + - if x = +0 return +0 + - if x = -0 return -0 + - if x = Infinity return Infinity + - if x = -Infinity return -Infinity + - if ( -1 < x < 0 ) return -0 + also: + - the value of Math.floor(x) == -Math.ceil(-x) + Author: christine@netscape.com + Date: 7 july 1997 +*/ + +var SECTION = "15.8.2.9"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Math.floor(x)"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +new TestCase( SECTION, + "Math.floor.length", + 1, + Math.floor.length ); + +new TestCase( SECTION, + "Math.floor()", + Number.NaN, + Math.floor() ); + +new TestCase( SECTION, + "Math.floor(void 0)", + Number.NaN, + Math.floor(void 0) ); + +new TestCase( SECTION, + "Math.floor(null)", + 0, + Math.floor(null) ); + +new TestCase( SECTION, + "Math.floor(true)", + 1, + Math.floor(true) ); + +new TestCase( SECTION, + "Math.floor(false)", + 0, + Math.floor(false) ); + +new TestCase( SECTION, + "Math.floor('1.1')", + 1, + Math.floor("1.1") ); + +new TestCase( SECTION, + "Math.floor('-1.1')", + -2, + Math.floor("-1.1") ); + +new TestCase( SECTION, + "Math.floor('0.1')", + 0, + Math.floor("0.1") ); + +new TestCase( SECTION, + "Math.floor('-0.1')", + -1, + Math.floor("-0.1") ); + +new TestCase( SECTION, + "Math.floor(NaN)", + Number.NaN, + Math.floor(Number.NaN) ); + +new TestCase( SECTION, + "Math.floor(NaN)==-Math.ceil(-NaN)", + false, + Math.floor(Number.NaN) == -Math.ceil(-Number.NaN) ); + +new TestCase( SECTION, + "Math.floor(0)", + 0, + Math.floor(0) ); + +new TestCase( SECTION, + "Math.floor(0)==-Math.ceil(-0)", + true, + Math.floor(0) == -Math.ceil(-0) ); + +new TestCase( SECTION, + "Math.floor(-0)", + -0, + Math.floor(-0) ); + +new TestCase( SECTION, + "Infinity/Math.floor(-0)", + -Infinity, + Infinity/Math.floor(-0) ); + +new TestCase( SECTION, + "Math.floor(-0)==-Math.ceil(0)", + true, + Math.floor(-0)== -Math.ceil(0) ); + +new TestCase( SECTION, + "Math.floor(Infinity)", + Number.POSITIVE_INFINITY, + Math.floor(Number.POSITIVE_INFINITY) ); + +new TestCase( SECTION, + "Math.floor(Infinity)==-Math.ceil(-Infinity)", + true, + Math.floor(Number.POSITIVE_INFINITY) == -Math.ceil(Number.NEGATIVE_INFINITY) ); + +new TestCase( SECTION, + "Math.floor(-Infinity)", + Number.NEGATIVE_INFINITY, + Math.floor(Number.NEGATIVE_INFINITY) ); + +new TestCase( SECTION, + "Math.floor(-Infinity)==-Math.ceil(Infinity)", + true, + Math.floor(Number.NEGATIVE_INFINITY) == -Math.ceil(Number.POSITIVE_INFINITY) ); + +new TestCase( SECTION, + "Math.floor(0.0000001)", + 0, + Math.floor(0.0000001) ); + +new TestCase( SECTION, + "Math.floor(0.0000001)==-Math.ceil(0.0000001)", true, + Math.floor(0.0000001)==-Math.ceil(-0.0000001) ); + +new TestCase( SECTION, + "Math.floor(-0.0000001)", + -1, + Math.floor(-0.0000001) ); + +new TestCase( SECTION, + "Math.floor(0.0000001)==-Math.ceil(0.0000001)", + true, + Math.floor(-0.0000001)==-Math.ceil(0.0000001) ); + +test(); diff --git a/tests/auto/qml/parserstress/tests/ecma/Math/browser.js b/tests/auto/qml/parserstress/tests/ecma/Math/browser.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/auto/qml/parserstress/tests/ecma/Math/shell.js b/tests/auto/qml/parserstress/tests/ecma/Math/shell.js new file mode 100644 index 0000000000..fbcc5c3f92 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Math/shell.js @@ -0,0 +1 @@ +gTestsubsuite = 'Math'; diff --git a/tests/auto/qml/parserstress/tests/ecma/NativeObjects/browser.js b/tests/auto/qml/parserstress/tests/ecma/NativeObjects/browser.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/auto/qml/parserstress/tests/ecma/NativeObjects/shell.js b/tests/auto/qml/parserstress/tests/ecma/NativeObjects/shell.js new file mode 100644 index 0000000000..4ddb940f71 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/NativeObjects/shell.js @@ -0,0 +1 @@ +gTestsubsuite = 'NativeObjects'; diff --git a/tests/auto/qml/parserstress/tests/ecma/Number/15.7.1.js b/tests/auto/qml/parserstress/tests/ecma/Number/15.7.1.js new file mode 100644 index 0000000000..34cec9f378 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Number/15.7.1.js @@ -0,0 +1,88 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.7.1.js'; + +/** + File Name: 15.7.1.js + ECMA Section: 15.7.1 The Number Constructor Called as a Function + 15.7.1.1 + 15.7.1.2 + + Description: When Number is called as a function rather than as a + constructor, it performs a type conversion. + 15.7.1.1 Return a number value (not a Number object) + computed by ToNumber( value ) + 15.7.1.2 Number() returns 0. + + need to add more test cases. see the gTestcases for + TypeConversion ToNumber. + + Author: christine@netscape.com + Date: 29 september 1997 +*/ + +var SECTION = "15.7.1"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "The Number Constructor Called as a Function"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +new TestCase(SECTION, "Number()", 0, Number() ); +new TestCase(SECTION, "Number(void 0)", Number.NaN, Number(void 0) ); +new TestCase(SECTION, "Number(null)", 0, Number(null) ); +new TestCase(SECTION, "Number()", 0, Number() ); +new TestCase(SECTION, "Number(new Number())", 0, Number( new Number() ) ); +new TestCase(SECTION, "Number(0)", 0, Number(0) ); +new TestCase(SECTION, "Number(1)", 1, Number(1) ); +new TestCase(SECTION, "Number(-1)", -1, Number(-1) ); +new TestCase(SECTION, "Number(NaN)", Number.NaN, Number( Number.NaN ) ); +new TestCase(SECTION, "Number('string')", Number.NaN, Number( "string") ); +new TestCase(SECTION, "Number(new String())", 0, Number( new String() ) ); +new TestCase(SECTION, "Number('')", 0, Number( "" ) ); +new TestCase(SECTION, "Number(Infinity)", Number.POSITIVE_INFINITY, Number("Infinity") ); + +new TestCase(SECTION, "Number(new MyObject(100))", 100, Number(new MyObject(100)) ); + +test(); + +function MyObject( value ) { + this.value = value; + this.valueOf = new Function( "return this.value" ); +} diff --git a/tests/auto/qml/parserstress/tests/ecma/Number/15.7.2.js b/tests/auto/qml/parserstress/tests/ecma/Number/15.7.2.js new file mode 100644 index 0000000000..4c2c8a298c --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Number/15.7.2.js @@ -0,0 +1,168 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.7.2.js'; + +/** + File Name: 15.7.2.js + ECMA Section: 15.7.2 The Number Constructor + 15.7.2.1 + 15.7.2.2 + + Description: 15.7.2 When Number is called as part of a new + expression, it is a constructor: it initializes + the newly created object. + + 15.7.2.1 The [[Prototype]] property of the newly + constructed object is set to othe original Number + prototype object, the one that is the initial value + of Number.prototype(0). The [[Class]] property is + set to "Number". The [[Value]] property of the + newly constructed object is set to ToNumber(value) + + 15.7.2.2 new Number(). same as in 15.7.2.1, except + the [[Value]] property is set to +0. + + need to add more test cases. see the gTestcases for + TypeConversion ToNumber. + + Author: christine@netscape.com + Date: 29 september 1997 +*/ + +var SECTION = "15.7.2"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "The Number Constructor"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +// To verify that the object's prototype is the Number.prototype, check to see if the object's +// constructor property is the same as Number.prototype.constructor. + +new TestCase(SECTION, "(new Number()).constructor", Number.prototype.constructor, (new Number()).constructor ); + +new TestCase(SECTION, "typeof (new Number())", "object", typeof (new Number()) ); +new TestCase(SECTION, "(new Number()).valueOf()", 0, (new Number()).valueOf() ); +new TestCase(SECTION, + "NUMB = new Number();NUMB.toString=Object.prototype.toString;NUMB.toString()", + "[object Number]", + eval("NUMB = new Number();NUMB.toString=Object.prototype.toString;NUMB.toString()") ); + +new TestCase(SECTION, "(new Number(0)).constructor", Number.prototype.constructor, (new Number(0)).constructor ); +new TestCase(SECTION, "typeof (new Number(0))", "object", typeof (new Number(0)) ); +new TestCase(SECTION, "(new Number(0)).valueOf()", 0, (new Number(0)).valueOf() ); +new TestCase(SECTION, + "NUMB = new Number(0);NUMB.toString=Object.prototype.toString;NUMB.toString()", + "[object Number]", + eval("NUMB = new Number(0);NUMB.toString=Object.prototype.toString;NUMB.toString()") ); + +new TestCase(SECTION, "(new Number(1)).constructor", Number.prototype.constructor, (new Number(1)).constructor ); +new TestCase(SECTION, "typeof (new Number(1))", "object", typeof (new Number(1)) ); +new TestCase(SECTION, "(new Number(1)).valueOf()", 1, (new Number(1)).valueOf() ); +new TestCase(SECTION, + "NUMB = new Number(1);NUMB.toString=Object.prototype.toString;NUMB.toString()", + "[object Number]", + eval("NUMB = new Number(1);NUMB.toString=Object.prototype.toString;NUMB.toString()") ); + +new TestCase(SECTION, "(new Number(-1)).constructor", Number.prototype.constructor, (new Number(-1)).constructor ); +new TestCase(SECTION, "typeof (new Number(-1))", "object", typeof (new Number(-1)) ); +new TestCase(SECTION, "(new Number(-1)).valueOf()", -1, (new Number(-1)).valueOf() ); +new TestCase(SECTION, + "NUMB = new Number(-1);NUMB.toString=Object.prototype.toString;NUMB.toString()", + "[object Number]", + eval("NUMB = new Number(-1);NUMB.toString=Object.prototype.toString;NUMB.toString()") ); + +new TestCase(SECTION, "(new Number(Number.NaN)).constructor", Number.prototype.constructor, (new Number(Number.NaN)).constructor ); +new TestCase(SECTION, "typeof (new Number(Number.NaN))", "object", typeof (new Number(Number.NaN)) ); +new TestCase(SECTION, "(new Number(Number.NaN)).valueOf()", Number.NaN, (new Number(Number.NaN)).valueOf() ); +new TestCase(SECTION, + "NUMB = new Number(Number.NaN);NUMB.toString=Object.prototype.toString;NUMB.toString()", + "[object Number]", + eval("NUMB = new Number(Number.NaN);NUMB.toString=Object.prototype.toString;NUMB.toString()") ); + +new TestCase(SECTION, "(new Number('string')).constructor", Number.prototype.constructor, (new Number('string')).constructor ); +new TestCase(SECTION, "typeof (new Number('string'))", "object", typeof (new Number('string')) ); +new TestCase(SECTION, "(new Number('string')).valueOf()", Number.NaN, (new Number('string')).valueOf() ); +new TestCase(SECTION, + "NUMB = new Number('string');NUMB.toString=Object.prototype.toString;NUMB.toString()", + "[object Number]", + eval("NUMB = new Number('string');NUMB.toString=Object.prototype.toString;NUMB.toString()") ); + +new TestCase(SECTION, "(new Number(new String())).constructor", Number.prototype.constructor, (new Number(new String())).constructor ); +new TestCase(SECTION, "typeof (new Number(new String()))", "object", typeof (new Number(new String())) ); +new TestCase(SECTION, "(new Number(new String())).valueOf()", 0, (new Number(new String())).valueOf() ); +new TestCase(SECTION, + "NUMB = new Number(new String());NUMB.toString=Object.prototype.toString;NUMB.toString()", + "[object Number]", + eval("NUMB = new Number(new String());NUMB.toString=Object.prototype.toString;NUMB.toString()") ); + +new TestCase(SECTION, "(new Number('')).constructor", Number.prototype.constructor, (new Number('')).constructor ); +new TestCase(SECTION, "typeof (new Number(''))", "object", typeof (new Number('')) ); +new TestCase(SECTION, "(new Number('')).valueOf()", 0, (new Number('')).valueOf() ); +new TestCase(SECTION, + "NUMB = new Number('');NUMB.toString=Object.prototype.toString;NUMB.toString()", + "[object Number]", + eval("NUMB = new Number('');NUMB.toString=Object.prototype.toString;NUMB.toString()") ); + +new TestCase(SECTION, "(new Number(Number.POSITIVE_INFINITY)).constructor", Number.prototype.constructor, (new Number(Number.POSITIVE_INFINITY)).constructor ); +new TestCase(SECTION, "typeof (new Number(Number.POSITIVE_INFINITY))", "object", typeof (new Number(Number.POSITIVE_INFINITY)) ); +new TestCase(SECTION, "(new Number(Number.POSITIVE_INFINITY)).valueOf()", Number.POSITIVE_INFINITY, (new Number(Number.POSITIVE_INFINITY)).valueOf() ); +new TestCase(SECTION, + "NUMB = new Number(Number.POSITIVE_INFINITY);NUMB.toString=Object.prototype.toString;NUMB.toString()", + "[object Number]", + eval("NUMB = new Number(Number.POSITIVE_INFINITY);NUMB.toString=Object.prototype.toString;NUMB.toString()") ); + +new TestCase(SECTION, "(new Number(Number.NEGATIVE_INFINITY)).constructor", Number.prototype.constructor, (new Number(Number.NEGATIVE_INFINITY)).constructor ); +new TestCase(SECTION, "typeof (new Number(Number.NEGATIVE_INFINITY))", "object", typeof (new Number(Number.NEGATIVE_INFINITY)) ); +new TestCase(SECTION, "(new Number(Number.NEGATIVE_INFINITY)).valueOf()", Number.NEGATIVE_INFINITY, (new Number(Number.NEGATIVE_INFINITY)).valueOf() ); +new TestCase(SECTION, + "NUMB = new Number(Number.NEGATIVE_INFINITY);NUMB.toString=Object.prototype.toString;NUMB.toString()", + "[object Number]", + eval("NUMB = new Number(Number.NEGATIVE_INFINITY);NUMB.toString=Object.prototype.toString;NUMB.toString()") ); + + +new TestCase(SECTION, "(new Number()).constructor", Number.prototype.constructor, (new Number()).constructor ); +new TestCase(SECTION, "typeof (new Number())", "object", typeof (new Number()) ); +new TestCase(SECTION, "(new Number()).valueOf()", 0, (new Number()).valueOf() ); +new TestCase(SECTION, + "NUMB = new Number();NUMB.toString=Object.prototype.toString;NUMB.toString()", + "[object Number]", + eval("NUMB = new Number();NUMB.toString=Object.prototype.toString;NUMB.toString()") ); + +test(); diff --git a/tests/auto/qml/parserstress/tests/ecma/Number/15.7.3.1-1.js b/tests/auto/qml/parserstress/tests/ecma/Number/15.7.3.1-1.js new file mode 100644 index 0000000000..d275f50a12 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Number/15.7.3.1-1.js @@ -0,0 +1,71 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.7.3.1-1.js'; + +/** + File Name: 15.7.3.1-2.js + ECMA Section: 15.7.3.1 Number.prototype + Description: All value properties of the Number object should have + the attributes [DontEnum, DontDelete, ReadOnly] + + this test checks the DontDelete attribute of Number.prototype + + Author: christine@netscape.com + Date: 16 september 1997 +*/ + + +var SECTION = "15.7.3.1-1"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Number.prototype"; + +writeHeaderToLog( SECTION +" "+ TITLE); + +new TestCase(SECTION, + "var NUM_PROT = Number.prototype; delete( Number.prototype ); NUM_PROT == Number.prototype", + true, + eval("var NUM_PROT = Number.prototype; delete( Number.prototype ); NUM_PROT == Number.prototype") ); + +new TestCase(SECTION, + "delete( Number.prototype )", + false, + eval("delete( Number.prototype )") ); + +test(); diff --git a/tests/auto/qml/parserstress/tests/ecma/Number/15.7.3.1-2.js b/tests/auto/qml/parserstress/tests/ecma/Number/15.7.3.1-2.js new file mode 100644 index 0000000000..ff26a03e63 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Number/15.7.3.1-2.js @@ -0,0 +1,71 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.7.3.1-2.js'; + +/** + File Name: 15.7.3.1-2.js + ECMA Section: 15.7.3.1 Number.prototype + Description: All value properties of the Number object should have + the attributes [DontEnum, DontDelete, ReadOnly] + + this test checks the ReadOnly attribute of Number.prototype + + Author: christine@netscape.com + Date: 16 september 1997 +*/ + + +var SECTION = "15.7.3.1-2"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Number.prototype"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +new TestCase( SECTION, + "var NUM_PROT = Number.prototype; Number.prototype = null; Number.prototype == NUM_PROT", + true, + eval("var NUM_PROT = Number.prototype; Number.prototype = null; Number.prototype == NUM_PROT") ); + +new TestCase( SECTION, + "Number.prototype=0; Number.prototype", + Number.prototype, + eval("Number.prototype=0; Number.prototype") ); + +test(); diff --git a/tests/auto/qml/parserstress/tests/ecma/Number/15.7.3.1-3.js b/tests/auto/qml/parserstress/tests/ecma/Number/15.7.3.1-3.js new file mode 100644 index 0000000000..4669e969a7 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Number/15.7.3.1-3.js @@ -0,0 +1,67 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.7.3.1-3.js'; + +/** + File Name: 15.7.3.1-4.js + ECMA Section: 15.7.3.1 Number.prototype + Description: All value properties of the Number object should have + the attributes [DontEnum, DontDelete, ReadOnly] + + this test checks the DontEnum attribute of Number.prototype + + Author: christine@netscape.com + Date: 16 september 1997 +*/ + +var VERSION = "ECMA_1"; +startTest(); +var SECTION = "15.7.3.1-3"; +var TITLE = "Number.prototype"; + +writeHeaderToLog( SECTION + " Number.prototype: DontEnum Attribute"); + +new TestCase( + SECTION, + "var string = ''; for ( prop in Number ) { string += ( prop == 'prototype' ) ? prop: '' } string;", + "", + eval("var string = ''; for ( prop in Number ) { string += ( prop == 'prototype' ) ? prop : '' } string;") + ); + +test(); diff --git a/tests/auto/qml/parserstress/tests/ecma/Number/15.7.3.2-1.js b/tests/auto/qml/parserstress/tests/ecma/Number/15.7.3.2-1.js new file mode 100644 index 0000000000..35ff1b25c3 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Number/15.7.3.2-1.js @@ -0,0 +1,65 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.7.3.2-1.js'; + +/** + File Name: 15.7.3.2-1.js + ECMA Section: 15.7.3.2 Number.MAX_VALUE + Description: All value properties of the Number object should have + the attributes [DontEnum, DontDelete, ReadOnly] + + this test checks the value of MAX_VALUE + + Author: christine@netscape.com + Date: 16 september 1997 +*/ + +var SECTION = "15.7.3.2-1"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Number.MAX_VALUE"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +new TestCase( SECTION, + "Number.MAX_VALUE", + 1.7976931348623157e308, + Number.MAX_VALUE ); + +test(); diff --git a/tests/auto/qml/parserstress/tests/ecma/Number/15.7.3.2-2.js b/tests/auto/qml/parserstress/tests/ecma/Number/15.7.3.2-2.js new file mode 100644 index 0000000000..980b688bb6 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Number/15.7.3.2-2.js @@ -0,0 +1,70 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.7.3.2-2.js'; + +/** + File Name: 15.7.3.2-2.js + ECMA Section: 15.7.3.2 Number.MAX_VALUE + Description: All value properties of the Number object should have + the attributes [DontEnum, DontDelete, ReadOnly] + + this test checks the DontDelete attribute of Number.MAX_VALUE + + Author: christine@netscape.com + Date: 16 september 1997 +*/ + +var SECTION = "15.7.3.2-2"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Number.MAX_VALUE: DontDelete Attribute"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +new TestCase( SECTION, + "delete( Number.MAX_VALUE ); Number.MAX_VALUE", + 1.7976931348623157e308, + eval("delete( Number.MAX_VALUE );Number.MAX_VALUE") ); + +new TestCase( SECTION, + "delete( Number.MAX_VALUE )", + false, + eval("delete( Number.MAX_VALUE )") ); + +test(); diff --git a/tests/auto/qml/parserstress/tests/ecma/Number/15.7.3.2-3.js b/tests/auto/qml/parserstress/tests/ecma/Number/15.7.3.2-3.js new file mode 100644 index 0000000000..2f20efe2a8 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Number/15.7.3.2-3.js @@ -0,0 +1,67 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.7.3.2-3.js'; + +/** + File Name: 15.7.3.2-3.js + ECMA Section: 15.7.3.2 Number.MAX_VALUE + Description: All value properties of the Number object should have + the attributes [DontEnum, DontDelete, ReadOnly] + + this test checks the ReadOnly attribute of Number.MAX_VALUE + + Author: christine@netscape.com + Date: 16 september 1997 +*/ + +var SECTION = "15.7.3.2-3"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Number.MAX_VALUE"; + +writeHeaderToLog( SECTION + " "+ TITLE ); + +var MAX_VAL = 1.7976931348623157e308; + +new TestCase( SECTION, + "Number.MAX_VALUE=0; Number.MAX_VALUE", + MAX_VAL, + eval("Number.MAX_VALUE=0; Number.MAX_VALUE") ); + +test(); diff --git a/tests/auto/qml/parserstress/tests/ecma/Number/15.7.3.2-4.js b/tests/auto/qml/parserstress/tests/ecma/Number/15.7.3.2-4.js new file mode 100644 index 0000000000..04d70ce3a9 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Number/15.7.3.2-4.js @@ -0,0 +1,64 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.7.3.2-4.js'; + +/** + File Name: 15.7.3.2-4.js + ECMA Section: 15.7.3.2 Number.MAX_VALUE + Description: All value properties of the Number object should have + the attributes [DontEnum, DontDelete, ReadOnly] + + this test checks the DontEnum attribute of Number.MAX_VALUE + + Author: christine@netscape.com + Date: 16 september 1997 +*/ +var SECTION = "15.7.3.2-4"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Number.MAX_VALUE: DontEnum Attribute"; +writeHeaderToLog( SECTION + " "+ TITLE); + +new TestCase( SECTION, + "var string = ''; for ( prop in Number ) { string += ( prop == 'MAX_VALUE' ) ? prop : '' } string;", + "", + eval("var string = ''; for ( prop in Number ) { string += ( prop == 'MAX_VALUE' ) ? prop : '' } string;") + ); + +test(); diff --git a/tests/auto/qml/parserstress/tests/ecma/Number/15.7.3.3-1.js b/tests/auto/qml/parserstress/tests/ecma/Number/15.7.3.3-1.js new file mode 100644 index 0000000000..ed7f0e88a9 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Number/15.7.3.3-1.js @@ -0,0 +1,68 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.7.3.3-1.js'; + +/** + File Name: 15.7.3.3-1.js + ECMA Section: 15.7.3.3 Number.MIN_VALUE + Description: All value properties of the Number object should have + the attributes [DontEnum, DontDelete, ReadOnly] + + this test checks the value of Number.MIN_VALUE + + Author: christine@netscape.com + Date: 16 september 1997 +*/ + + +var SECTION = "15.7.3.3-1"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Number.MIN_VALUE"; + +writeHeaderToLog( SECTION + " "+ TITLE ); + +var MIN_VAL = 5e-324; + +new TestCase( SECTION, + "Number.MIN_VALUE", + MIN_VAL, + Number.MIN_VALUE ); + +test(); diff --git a/tests/auto/qml/parserstress/tests/ecma/Number/15.7.3.3-2.js b/tests/auto/qml/parserstress/tests/ecma/Number/15.7.3.3-2.js new file mode 100644 index 0000000000..2b73147c2a --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Number/15.7.3.3-2.js @@ -0,0 +1,73 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.7.3.3-2.js'; + +/** + File Name: 15.7.3.3-2.js + ECMA Section: 15.7.3.3 Number.MIN_VALUE + Description: All value properties of the Number object should have + the attributes [DontEnum, DontDelete, ReadOnly] + + this test checks the DontDelete attribute of Number.MIN_VALUE + + Author: christine@netscape.com + Date: 16 september 1997 +*/ + + +var SECTION = "15.7.3.3-2"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Number.MIN_VALUE"; + +writeHeaderToLog( SECTION + " "+ TITLE ); + +var MIN_VAL = 5e-324; + +new TestCase( SECTION, + "delete( Number.MIN_VALUE )", + false, + eval("delete( Number.MIN_VALUE )") ); + +new TestCase( SECTION, + "delete( Number.MIN_VALUE ); Number.MIN_VALUE", + MIN_VAL, + eval("delete( Number.MIN_VALUE );Number.MIN_VALUE") ); + +test(); diff --git a/tests/auto/qml/parserstress/tests/ecma/Number/15.7.3.3-3.js b/tests/auto/qml/parserstress/tests/ecma/Number/15.7.3.3-3.js new file mode 100644 index 0000000000..d0c98282dd --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Number/15.7.3.3-3.js @@ -0,0 +1,64 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.7.3.3-3.js'; + +/** + File Name: 15.7.3.3-3.js + ECMA Section: 15.7.3.3 Number.MIN_VALUE + Description: All value properties of the Number object should have + the attributes [DontEnum, DontDelete, ReadOnly] + + this test checks the ReadOnly attribute of Number.MIN_VALUE + + Author: christine@netscape.com + Date: 16 september 1997 +*/ +var SECTION = "15.7.3.3-3"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Number.MIN_VALUE: ReadOnly Attribute"; + +writeHeaderToLog( SECTION + " "+TITLE ); + +new TestCase( SECTION, + "Number.MIN_VALUE=0; Number.MIN_VALUE", + Number.MIN_VALUE, + eval("Number.MIN_VALUE=0; Number.MIN_VALUE" )); + +test(); diff --git a/tests/auto/qml/parserstress/tests/ecma/Number/15.7.3.3-4.js b/tests/auto/qml/parserstress/tests/ecma/Number/15.7.3.3-4.js new file mode 100644 index 0000000000..e9427c62f2 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Number/15.7.3.3-4.js @@ -0,0 +1,66 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.7.3.3-4.js'; + +/** + File Name: 15.7.3.3-4.js + ECMA Section: 15.7.3.3 Number.MIN_VALUE + Description: All value properties of the Number object should have + the attributes [DontEnum, DontDelete, ReadOnly] + + this test checks the DontEnum attribute of Number.MIN_VALUE + + Author: christine@netscape.com + Date: 16 september 1997 +*/ + + +var SECTION = "15.7.3.3-4"; +var VERSION = "ECMA_1"; +startTest(); + +writeHeaderToLog( SECTION + " Number.MIN_VALUE: DontEnum Attribute"); + +new TestCase( SECTION, + "var string = ''; for ( prop in Number ) { string += ( prop == 'MIN_VALUE' ) ? prop : '' } string;", + "", + eval("var string = ''; for ( prop in Number ) { string += ( prop == 'MIN_VALUE' ) ? prop : '' } string;") + ); + +test(); diff --git a/tests/auto/qml/parserstress/tests/ecma/Number/15.7.3.4-1.js b/tests/auto/qml/parserstress/tests/ecma/Number/15.7.3.4-1.js new file mode 100644 index 0000000000..6a6835f04d --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Number/15.7.3.4-1.js @@ -0,0 +1,66 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.7.3.4-1.js'; + +/** + File Name: 15.7.3.4-1.js + ECMA Section: 15.7.3.4 Number.NaN + Description: All value properties of the Number object should have + the attributes [DontEnum, DontDelete, ReadOnly] + + this test checks the value of Number.NaN + + Author: christine@netscape.com + Date: 16 september 1997 +*/ + + +var SECTION = "15.7.3.4-1"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Number.NaN"; + +writeHeaderToLog( SECTION + " "+ TITLE ); + +new TestCase(SECTION, + "NaN", + NaN, + Number.NaN ); + +test(); diff --git a/tests/auto/qml/parserstress/tests/ecma/Number/15.7.3.4-2.js b/tests/auto/qml/parserstress/tests/ecma/Number/15.7.3.4-2.js new file mode 100644 index 0000000000..fd1e630d54 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Number/15.7.3.4-2.js @@ -0,0 +1,71 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.7.3.4-2.js'; + +/** + File Name: 15.7.3.4-2.js + ECMA Section: 15.7.3.4 Number.NaN + Description: All value properties of the Number object should have + the attributes [DontEnum, DontDelete, ReadOnly] + + this test checks the DontDelete attribute of Number.NaN + + Author: christine@netscape.com + Date: 16 september 1997 +*/ + + +var SECTION = "15.7.3.4-2"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Number.NaN"; + +writeHeaderToLog( SECTION + " "+ TITLE ); + +new TestCase(SECTION, + "delete( Number.NaN ); Number.NaN", + NaN, + eval("delete( Number.NaN );Number.NaN" )); + +new TestCase( SECTION, + "delete( Number.NaN )", + false, + eval("delete( Number.NaN )") ); + +test(); diff --git a/tests/auto/qml/parserstress/tests/ecma/Number/15.7.3.4-3.js b/tests/auto/qml/parserstress/tests/ecma/Number/15.7.3.4-3.js new file mode 100644 index 0000000000..6cf1072e20 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Number/15.7.3.4-3.js @@ -0,0 +1,65 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.7.3.4-3.js'; + +/** + File Name: 15.7.3.4-3.js + ECMA Section: 15.7.3.4 Number.NaN + Description: All value properties of the Number object should have + the attributes [DontEnum, DontDelete, ReadOnly] + + this test checks the ReadOnly attribute of Number.NaN + + Author: christine@netscape.com + Date: 16 september 1997 +*/ + +var SECTION = "15.7.3.4-3"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Number.NaN"; + +writeHeaderToLog( SECTION + " "+ TITLE ); + +new TestCase( SECTION, + "Number.NaN=0; Number.NaN", + Number.NaN, + eval("Number.NaN=0; Number.NaN") ); + +test(); diff --git a/tests/auto/qml/parserstress/tests/ecma/Number/15.7.3.4-4.js b/tests/auto/qml/parserstress/tests/ecma/Number/15.7.3.4-4.js new file mode 100644 index 0000000000..3e1db5b9d2 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Number/15.7.3.4-4.js @@ -0,0 +1,66 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.7.3.4-4.js'; + +/** + File Name: 15.7.3.4-4.js + ECMA Section: 15.7.3.4 Number.NaN + Description: All value properties of the Number object should have + the attributes [DontEnum, DontDelete, ReadOnly] + + this test checks the DontEnum attribute of Number.NaN + + Author: christine@netscape.com + Date: 16 september 1997 +*/ + +var SECTION = "15.7.3.4-4"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Number.NaN"; + +writeHeaderToLog( SECTION + " " + TITLE); + +new TestCase( SECTION, + "var string = ''; for ( prop in Number ) { string += ( prop == 'NaN' ) ? prop : '' } string;", + "", + eval("var string = ''; for ( prop in Number ) { string += ( prop == 'NaN' ) ? prop : '' } string;") + ); + +test(); diff --git a/tests/auto/qml/parserstress/tests/ecma/Number/15.7.3.5-1.js b/tests/auto/qml/parserstress/tests/ecma/Number/15.7.3.5-1.js new file mode 100644 index 0000000000..8bcb3e3782 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Number/15.7.3.5-1.js @@ -0,0 +1,64 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.7.3.5-1.js'; + +/** + File Name: 15.7.3.5-1.js + ECMA Section: 15.7.3.5 Number.NEGATIVE_INFINITY + Description: All value properties of the Number object should have + the attributes [DontEnum, DontDelete, ReadOnly] + + this test checks the value of Number.NEGATIVE_INFINITY + + Author: christine@netscape.com + Date: 16 september 1997 +*/ +var SECTION = "15.7.3.5-1"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Number.NEGATIVE_INFINITY"; + +writeHeaderToLog( SECTION + " "+TITLE); + +new TestCase(SECTION, + "Number.NEGATIVE_INFINITY", + -Infinity, + Number.NEGATIVE_INFINITY ); + +test(); diff --git a/tests/auto/qml/parserstress/tests/ecma/Number/15.7.3.5-2.js b/tests/auto/qml/parserstress/tests/ecma/Number/15.7.3.5-2.js new file mode 100644 index 0000000000..e0c2c440ac --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Number/15.7.3.5-2.js @@ -0,0 +1,70 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.7.3.5-2.js'; + +/** + File Name: 15.7.3.5-2.js + ECMA Section: 15.7.3.5 Number.NEGATIVE_INFINITY + Description: All value properties of the Number object should have + the attributes [DontEnum, DontDelete, ReadOnly] + + this test checks the DontDelete attribute of Number.NEGATIVE_INFINITY + + Author: christine@netscape.com + Date: 16 september 1997 +*/ + +var SECTION = "15.7.3.5-2"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Number.NEGATIVE_INFINITY"; + +writeHeaderToLog( SECTION + " "+TITLE); + +new TestCase( SECTION, + "delete( Number.NEGATIVE_INFINITY )", + false, + eval("delete( Number.NEGATIVE_INFINITY )") ); + +new TestCase( SECTION, + "delete( Number.NEGATIVE_INFINITY ); Number.NEGATIVE_INFINITY", + -Infinity, + eval("delete( Number.NEGATIVE_INFINITY );Number.NEGATIVE_INFINITY") ); + +test(); diff --git a/tests/auto/qml/parserstress/tests/ecma/Number/15.7.3.5-3.js b/tests/auto/qml/parserstress/tests/ecma/Number/15.7.3.5-3.js new file mode 100644 index 0000000000..983cdd3147 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Number/15.7.3.5-3.js @@ -0,0 +1,65 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.7.3.5-3.js'; + +/** + File Name: 15.7.3.5-3.js + ECMA Section: 15.7.3.5 Number.NEGATIVE_INFINITY + Description: All value properties of the Number object should have + the attributes [DontEnum, DontDelete, ReadOnly] + + this test checks the ReadOnly attribute of Number.NEGATIVE_INFINITY + + Author: christine@netscape.com + Date: 16 september 1997 +*/ + +var SECTION = "15.7.3.5-3"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Number.NEGATIVE_INFINITY"; + +writeHeaderToLog( SECTION + " "+TITLE); + +new TestCase( SECTION, + "Number.NEGATIVE_INFINITY=0; Number.NEGATIVE_INFINITY", + -Infinity, + eval("Number.NEGATIVE_INFINITY=0; Number.NEGATIVE_INFINITY") ); + +test(); diff --git a/tests/auto/qml/parserstress/tests/ecma/Number/15.7.3.5-4.js b/tests/auto/qml/parserstress/tests/ecma/Number/15.7.3.5-4.js new file mode 100644 index 0000000000..acf7b0f543 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Number/15.7.3.5-4.js @@ -0,0 +1,66 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.7.3.5-4.js'; + +/** + File Name: 15.7.3.5-4.js + ECMA Section: 15.7.3.5 Number.NEGATIVE_INFINITY + Description: All value properties of the Number object should have + the attributes [DontEnum, DontDelete, ReadOnly] + + this test checks the DontEnum attribute of Number.NEGATIVE_INFINITY + + Author: christine@netscape.com + Date: 16 september 1997 +*/ + +var SECTION = "15.7.3.5-4"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Number.NEGATIVE_INFINITY"; + +writeHeaderToLog( SECTION + " "+TITLE); + +new TestCase( SECTION, + "var string = ''; for ( prop in Number ) { string += ( prop == 'NEGATIVE_INFINITY' ) ? prop : '' } string;", + "", + eval("var string = ''; for ( prop in Number ) { string += ( prop == 'NEGATIVE_INFINITY' ) ? prop : '' } string;") + ); + +test(); diff --git a/tests/auto/qml/parserstress/tests/ecma/Number/15.7.3.6-1.js b/tests/auto/qml/parserstress/tests/ecma/Number/15.7.3.6-1.js new file mode 100644 index 0000000000..466267f7d4 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Number/15.7.3.6-1.js @@ -0,0 +1,65 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.7.3.6-1.js'; + +/** + File Name: 15.7.3.6-1.js + ECMA Section: 15.7.3.6 Number.POSITIVE_INFINITY + Description: All value properties of the Number object should have + the attributes [DontEnum, DontDelete, ReadOnly] + + this test checks the value of Number.POSITIVE_INFINITY + + Author: christine@netscape.com + Date: 16 september 1997 +*/ + +var SECTION = "15.7.3.6-1"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Number.POSITIVE_INFINITY"; + +writeHeaderToLog( SECTION + " "+TITLE); + +new TestCase( SECTION, + "Number.POSITIVE_INFINITY", + Infinity, + Number.POSITIVE_INFINITY ); + +test(); diff --git a/tests/auto/qml/parserstress/tests/ecma/Number/15.7.3.6-2.js b/tests/auto/qml/parserstress/tests/ecma/Number/15.7.3.6-2.js new file mode 100644 index 0000000000..c3e6dbd0fb --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Number/15.7.3.6-2.js @@ -0,0 +1,69 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.7.3.6-2.js'; + +/** + File Name: 15.7.3.6-2.js + ECMA Section: 15.7.3.6 Number.POSITIVE_INFINITY + Description: All value properties of the Number object should have + the attributes [DontEnum, DontDelete, ReadOnly] + + this test checks the DontDelete attribute of Number.POSITIVE_INFINITY + + Author: christine@netscape.com + Date: 16 september 1997 +*/ +var SECTION = "15.7.3.6-2"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Number.POSITIVE_INFINITY"; + +writeHeaderToLog( SECTION + " "+TITLE); + +new TestCase(SECTION, + "delete( Number.POSITIVE_INFINITY )", + false, + eval("delete( Number.POSITIVE_INFINITY )") ); + +new TestCase(SECTION, + "delete( Number.POSITIVE_INFINITY ); Number.POSITIVE_INFINITY", + Infinity, + eval("delete( Number.POSITIVE_INFINITY );Number.POSITIVE_INFINITY") ); + +test(); diff --git a/tests/auto/qml/parserstress/tests/ecma/Number/15.7.3.6-3.js b/tests/auto/qml/parserstress/tests/ecma/Number/15.7.3.6-3.js new file mode 100644 index 0000000000..6055f49374 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Number/15.7.3.6-3.js @@ -0,0 +1,65 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.7.3.6-3.js'; + +/** + File Name: 15.7.3.6-3.js + ECMA Section: 15.7.3.6 Number.POSITIVE_INFINITY + Description: All value properties of the Number object should have + the attributes [DontEnum, DontDelete, ReadOnly] + + this test checks the ReadOnly attribute of Number.POSITIVE_INFINITY + + Author: christine@netscape.com + Date: 16 september 1997 +*/ + +var SECTION = "15.7.3.6-3"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Number.POSITIVE_INFINITY"; + +writeHeaderToLog( SECTION + " "+TITLE); + +new TestCase( SECTION, + "Number.POSITIVE_INFINITY=0; Number.POSITIVE_INFINITY", + Number.POSITIVE_INFINITY, + eval("Number.POSITIVE_INFINITY=0; Number.POSITIVE_INFINITY") ); + +test(); diff --git a/tests/auto/qml/parserstress/tests/ecma/Number/15.7.3.6-4.js b/tests/auto/qml/parserstress/tests/ecma/Number/15.7.3.6-4.js new file mode 100644 index 0000000000..75fa6ee485 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Number/15.7.3.6-4.js @@ -0,0 +1,66 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.7.3.6-4.js'; + +/** + File Name: 15.7.3.6-4.js + ECMA Section: 15.7.3.6 Number.POSITIVE_INFINITY + Description: All value properties of the Number object should have + the attributes [DontEnum, DontDelete, ReadOnly] + + this test checks the DontEnum attribute of Number.POSITIVE_INFINITY + + Author: christine@netscape.com + Date: 16 september 1997 +*/ +var SECTION = "15.7.3.6-4"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Number.POSITIVE_INFINITY"; + +writeHeaderToLog( SECTION + " "+TITLE); + +new TestCase( SECTION, + "var string = ''; for ( prop in Number ) { string += ( prop == 'POSITIVE_INFINITY' ) ? prop : '' } string;", + "", + eval("var string = ''; for ( prop in Number ) { string += ( prop == 'POSITIVE_INFINITY' ) ? prop : '' } string;") + ); + + +test(); diff --git a/tests/auto/qml/parserstress/tests/ecma/Number/15.7.3.js b/tests/auto/qml/parserstress/tests/ecma/Number/15.7.3.js new file mode 100644 index 0000000000..bc5e7a3fa1 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Number/15.7.3.js @@ -0,0 +1,69 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.7.3.js'; + +/** + File Name: 15.7.3.js + 15.7.3 Properties of the Number Constructor + + Description: The value of the internal [[Prototype]] property + of the Number constructor is the Function prototype + object. The Number constructor also has the internal + [[Call]] and [[Construct]] properties, and the length + property. + + Other properties are in subsequent tests. + + Author: christine@netscape.com + Date: 29 september 1997 +*/ + +var SECTION = "15.7.3"; +var VERSION = "ECMA_2"; +startTest(); +var TITLE = "Properties of the Number Constructor"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +new TestCase(SECTION, + "Number.length", + 1, + Number.length ); + +test(); diff --git a/tests/auto/qml/parserstress/tests/ecma/Number/15.7.4-1.js b/tests/auto/qml/parserstress/tests/ecma/Number/15.7.4-1.js new file mode 100644 index 0000000000..175835987a --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Number/15.7.4-1.js @@ -0,0 +1,60 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.7.4-1.js'; + +/** + File Name: 15.7.4-1.js + ECMA Section: 15.7.4.1 Properties of the Number Prototype Object + Description: + Author: christine@netscape.com + Date: 16 september 1997 +*/ + + +var SECTION = "15.7.4-1"; +var VERSION = "ECMA_1"; +startTest(); +writeHeaderToLog( SECTION + "Properties of the Number prototype object"); + +new TestCase(SECTION, "Number.prototype.valueOf()", 0, Number.prototype.valueOf() ); +new TestCase(SECTION, "typeof(Number.prototype)", "object", typeof(Number.prototype) ); +new TestCase(SECTION, "Number.prototype.constructor == Number", true, Number.prototype.constructor == Number ); +// new TestCase(SECTION, "Number.prototype == Number.__proto__", true, Number.prototype == Number.__proto__ ); + +test(); diff --git a/tests/auto/qml/parserstress/tests/ecma/Number/15.7.4.1.js b/tests/auto/qml/parserstress/tests/ecma/Number/15.7.4.1.js new file mode 100644 index 0000000000..27c0a0a9e4 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Number/15.7.4.1.js @@ -0,0 +1,62 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.7.4.1.js'; + +/** + File Name: 15.7.4.1.js + ECMA Section: 15.7.4.1.1 Number.prototype.constructor + + Number.prototype.constructor is the built-in Number constructor. + + Description: + Author: christine@netscape.com + Date: 16 september 1997 +*/ +var SECTION = "15.7.4.1"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Number.prototype.constructor"; + +writeHeaderToLog( SECTION + " "+TITLE); + +new TestCase( SECTION, + "Number.prototype.constructor", + Number, + Number.prototype.constructor ); +test(); diff --git a/tests/auto/qml/parserstress/tests/ecma/Number/15.7.4.2-1.js b/tests/auto/qml/parserstress/tests/ecma/Number/15.7.4.2-1.js new file mode 100644 index 0000000000..531876d980 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Number/15.7.4.2-1.js @@ -0,0 +1,111 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.7.4.2-1.js'; + +/** + File Name: 15.7.4.2.js + ECMA Section: 15.7.4.2.1 Number.prototype.toString() + Description: + If the radix is the number 10 or not supplied, then this number value is + given as an argument to the ToString operator; the resulting string value + is returned. + + If the radix is supplied and is an integer from 2 to 36, but not 10, the + result is a string, the choice of which is implementation dependent. + + The toString function is not generic; it generates a runtime error if its + this value is not a Number object. Therefore it cannot be transferred to + other kinds of objects for use as a method. + + Author: christine@netscape.com + Date: 16 september 1997 +*/ +var SECTION = "15.7.4.2-1"; +var VERSION = "ECMA_1"; +startTest(); + +writeHeaderToLog( SECTION + " Number.prototype.toString()"); + +// the following two lines cause navigator to crash -- cmb 9/16/97 +new TestCase(SECTION, + "Number.prototype.toString()", + "0", + eval("Number.prototype.toString()") ); + +new TestCase(SECTION, + "typeof(Number.prototype.toString())", + "string", + eval("typeof(Number.prototype.toString())") ); + +new TestCase(SECTION, + "s = Number.prototype.toString; o = new Number(); o.toString = s; o.toString()", + "0", + eval("s = Number.prototype.toString; o = new Number(); o.toString = s; o.toString()") ); + +new TestCase(SECTION, + "s = Number.prototype.toString; o = new Number(1); o.toString = s; o.toString()", + "1", + eval("s = Number.prototype.toString; o = new Number(1); o.toString = s; o.toString()") ); + +new TestCase(SECTION, + "s = Number.prototype.toString; o = new Number(-1); o.toString = s; o.toString()", + "-1", + eval("s = Number.prototype.toString; o = new Number(-1); o.toString = s; o.toString()") ); + +new TestCase(SECTION, + "var MYNUM = new Number(255); MYNUM.toString(10)", + "255", + eval("var MYNUM = new Number(255); MYNUM.toString(10)") ); + +new TestCase(SECTION, + "var MYNUM = new Number(Number.NaN); MYNUM.toString(10)", + "NaN", + eval("var MYNUM = new Number(Number.NaN); MYNUM.toString(10)") ); + +new TestCase(SECTION, + "var MYNUM = new Number(Infinity); MYNUM.toString(10)", + "Infinity", + eval("var MYNUM = new Number(Infinity); MYNUM.toString(10)") ); + +new TestCase(SECTION, + "var MYNUM = new Number(-Infinity); MYNUM.toString(10)", + "-Infinity", + eval("var MYNUM = new Number(-Infinity); MYNUM.toString(10)") ); + +test(); diff --git a/tests/auto/qml/parserstress/tests/ecma/Number/15.7.4.2-2-n.js b/tests/auto/qml/parserstress/tests/ecma/Number/15.7.4.2-2-n.js new file mode 100644 index 0000000000..a99b1deb45 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Number/15.7.4.2-2-n.js @@ -0,0 +1,76 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.7.4.2-2-n.js'; + +/** + File Name: 15.7.4.2-2-n.js + ECMA Section: 15.7.4.2.1 Number.prototype.toString() + Description: + If the radix is the number 10 or not supplied, then this number value is + given as an argument to the ToString operator; the resulting string value + is returned. + + If the radix is supplied and is an integer from 2 to 36, but not 10, the + result is a string, the choice of which is implementation dependent. + + The toString function is not generic; it generates a runtime error if its + this value is not a Number object. Therefore it cannot be transferred to + other kinds of objects for use as a method. + + Author: christine@netscape.com + Date: 16 september 1997 +*/ +var SECTION = "15.7.4.2-2-n"; +var VERSION = "ECMA_1"; +startTest(); + +writeHeaderToLog( SECTION + " Number.prototype.toString()"); + +DESCRIPTION = "o = new Object(); o.toString = Number.prototype.toString; o.toString()"; +EXPECTED = "error"; + +new TestCase(SECTION, + "o = new Object(); o.toString = Number.prototype.toString; o.toString()", + "error", + eval("o = new Object(); o.toString = Number.prototype.toString; o.toString()") ); + +// new TestCase(SECTION, "o = new String(); o.toString = Number.prototype.toString; o.toString()", "error", eval("o = new String(); o.toString = Number.prototype.toString; o.toString()") ); +// new TestCase(SECTION, "o = 3; o.toString = Number.prototype.toString; o.toString()", "error", eval("o = 3; o.toString = Number.prototype.toString; o.toString()") ); + +test(); diff --git a/tests/auto/qml/parserstress/tests/ecma/Number/15.7.4.2-3-n.js b/tests/auto/qml/parserstress/tests/ecma/Number/15.7.4.2-3-n.js new file mode 100644 index 0000000000..f6148db1cc --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Number/15.7.4.2-3-n.js @@ -0,0 +1,73 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.7.4.2-3-n.js'; + +/** + File Name: 15.7.4.2-3-n.js + ECMA Section: 15.7.4.2.1 Number.prototype.toString() + Description: + If the radix is the number 10 or not supplied, then this number value is + given as an argument to the ToString operator; the resulting string value + is returned. + + If the radix is supplied and is an integer from 2 to 36, but not 10, the + result is a string, the choice of which is implementation dependent. + + The toString function is not generic; it generates a runtime error if its + this value is not a Number object. Therefore it cannot be transferred to + other kinds of objects for use as a method. + + Author: christine@netscape.com + Date: 16 september 1997 +*/ +var SECTION = "15.7.4.2-3-n"; +var VERSION = "ECMA_1"; +startTest(); + +writeHeaderToLog( SECTION + " Number.prototype.toString()"); + +DESCRIPTION = "o = new String(); o.toString = Number.prototype.toString; o.toString()"; +EXPECTED = "error"; + +new TestCase(SECTION, + "o = new String(); o.toString = Number.prototype.toString; o.toString()", + "error", + eval("o = new String(); o.toString = Number.prototype.toString; o.toString()") ); + +test(); diff --git a/tests/auto/qml/parserstress/tests/ecma/Number/15.7.4.2-4.js b/tests/auto/qml/parserstress/tests/ecma/Number/15.7.4.2-4.js new file mode 100644 index 0000000000..c2fd40dd17 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Number/15.7.4.2-4.js @@ -0,0 +1,70 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.7.4.2-4.js'; + +/** + File Name: 15.7.4.2-4.js + ECMA Section: 15.7.4.2.1 Number.prototype.toString() + Description: + If the radix is the number 10 or not supplied, then this number value is + given as an argument to the ToString operator; the resulting string value + is returned. + + If the radix is supplied and is an integer from 2 to 36, but not 10, the + result is a string, the choice of which is implementation dependent. + + The toString function is not generic; it generates a runtime error if its + this value is not a Number object. Therefore it cannot be transferred to + other kinds of objects for use as a method. + + Author: christine@netscape.com + Date: 16 september 1997 +*/ +var SECTION = "15.7.4.2-4"; +var VERSION = "ECMA_1"; +startTest(); + +writeHeaderToLog( SECTION + " Number.prototype.toString()"); + +new TestCase(SECTION, + "o = 3; o.toString = Number.prototype.toString; o.toString()", + "3", + eval("o = 3; o.toString = Number.prototype.toString; o.toString()") ); + +test(); diff --git a/tests/auto/qml/parserstress/tests/ecma/Number/15.7.4.3-1.js b/tests/auto/qml/parserstress/tests/ecma/Number/15.7.4.3-1.js new file mode 100644 index 0000000000..755e2281b3 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Number/15.7.4.3-1.js @@ -0,0 +1,97 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.7.4.3-1.js'; + +/** + File Name: 15.7.4.3-1.js + ECMA Section: 15.7.4.3.1 Number.prototype.valueOf() + Description: + Returns this number value. + + The valueOf function is not generic; it generates a runtime error if its + this value is not a Number object. Therefore it cannot be transferred to + other kinds of objects for use as a method. + + Author: christine@netscape.com + Date: 16 september 1997 +*/ +var SECTION = "15.7.4.3-1"; +var VERSION = "ECMA_1"; +startTest(); + + +writeHeaderToLog( SECTION + " Number.prototype.valueOf()"); + +// the following two line causes navigator to crash -- cmb 9/16/97 +new TestCase("SECTION", + "Number.prototype.valueOf()", + 0, + eval("Number.prototype.valueOf()") ); + +new TestCase("SECTION", + "(new Number(1)).valueOf()", + 1, + eval("(new Number(1)).valueOf()") ); + +new TestCase("SECTION", + "(new Number(-1)).valueOf()", + -1, + eval("(new Number(-1)).valueOf()") ); + +new TestCase("SECTION", + "(new Number(0)).valueOf()", + 0, + eval("(new Number(0)).valueOf()") ); + +new TestCase("SECTION", + "(new Number(Number.POSITIVE_INFINITY)).valueOf()", + Number.POSITIVE_INFINITY, + eval("(new Number(Number.POSITIVE_INFINITY)).valueOf()") ); + +new TestCase("SECTION", + "(new Number(Number.NaN)).valueOf()", + Number.NaN, + eval("(new Number(Number.NaN)).valueOf()") ); + +new TestCase("SECTION", + "(new Number()).valueOf()", + 0, + eval("(new Number()).valueOf()") ); + +test(); diff --git a/tests/auto/qml/parserstress/tests/ecma/Number/15.7.4.3-2.js b/tests/auto/qml/parserstress/tests/ecma/Number/15.7.4.3-2.js new file mode 100644 index 0000000000..1bfed1d4af --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Number/15.7.4.3-2.js @@ -0,0 +1,65 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.7.4.3-2.js'; + +/** + File Name: 15.7.4.3-2.js + ECMA Section: 15.7.4.3.1 Number.prototype.valueOf() + Description: + Returns this number value. + + The valueOf function is not generic; it generates a runtime error if its + this value is not a Number object. Therefore it cannot be transferred to + other kinds of objects for use as a method. + + Author: christine@netscape.com + Date: 16 september 1997 +*/ +var SECTION = "15.7.4.3-2"; +var VERSION = "ECMA_1"; +startTest(); + +writeHeaderToLog( SECTION + " Number.prototype.valueOf()"); + +new TestCase(SECTION, + "v = Number.prototype.valueOf; num = 3; num.valueOf = v; num.valueOf()", + 3, + eval("v = Number.prototype.valueOf; num = 3; num.valueOf = v; num.valueOf()") ); + +test(); diff --git a/tests/auto/qml/parserstress/tests/ecma/Number/15.7.4.3-3-n.js b/tests/auto/qml/parserstress/tests/ecma/Number/15.7.4.3-3-n.js new file mode 100644 index 0000000000..7df413ae48 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Number/15.7.4.3-3-n.js @@ -0,0 +1,72 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.7.4.3-3-n.js'; + +/** + File Name: 15.7.4.3-3.js + ECMA Section: 15.7.4.3.1 Number.prototype.valueOf() + Description: + Returns this number value. + + The valueOf function is not generic; it generates a runtime error if its + this value is not a Number object. Therefore it cannot be transferred to + other kinds of objects for use as a method. + + Author: christine@netscape.com + Date: 16 september 1997 +*/ +var SECTION = "15.7.4.3-3-n"; +var VERSION = "ECMA_1"; +startTest(); + +writeHeaderToLog( SECTION + " Number.prototype.valueOf()"); + +// new TestCase("15.7.4.1", "v = Number.prototype.valueOf; num = 3; num.valueOf = v; num.valueOf()", "error", eval("v = Number.prototype.valueOf; num = 3; num.valueOf = v; num.valueOf()") ); + +DESCRIPTION = "v = Number.prototype.valueOf; o = new String('Infinity'); o.valueOf = v; o.valueOf()"; +EXPECTED = "error"; + +new TestCase("15.7.4.1", + "v = Number.prototype.valueOf; o = new String('Infinity'); o.valueOf = v; o.valueOf()", + "error", + eval("v = Number.prototype.valueOf; o = new String('Infinity'); o.valueOf = v; o.valueOf()") ); + +// new TestCase("15.7.4.1", "v = Number.prototype.valueOf; o = new Object(); o.valueOf = v; o.valueOf()", "error", eval("v = Number.prototype.valueOf; o = new Object(); o.valueOf = v; o.valueOf()") ); + +test(); diff --git a/tests/auto/qml/parserstress/tests/ecma/Number/browser.js b/tests/auto/qml/parserstress/tests/ecma/Number/browser.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/auto/qml/parserstress/tests/ecma/Number/shell.js b/tests/auto/qml/parserstress/tests/ecma/Number/shell.js new file mode 100644 index 0000000000..03cca1d551 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Number/shell.js @@ -0,0 +1 @@ +gTestsubsuite = 'Number'; diff --git a/tests/auto/qml/parserstress/tests/ecma/ObjectObjects/15.2.1.1.js b/tests/auto/qml/parserstress/tests/ecma/ObjectObjects/15.2.1.1.js new file mode 100644 index 0000000000..73ddd2894c --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/ObjectObjects/15.2.1.1.js @@ -0,0 +1,146 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.2.1.1.js'; + +/** + File Name: 15.2.1.1.js + ECMA Section: 15.2.1.1 The Object Constructor Called as a Function: + Object(value) + Description: When Object is called as a function rather than as a + constructor, the following steps are taken: + + 1. If value is null or undefined, create and return a + new object with no properties other than internal + properties exactly as if the object constructor + had been called on that same value (15.2.2.1). + 2. Return ToObject (value), whose rules are: + + undefined generate a runtime error + null generate a runtime error + boolean create a new Boolean object whose default + value is the value of the boolean. + number Create a new Number object whose default + value is the value of the number. + string Create a new String object whose default + value is the value of the string. + object Return the input argument (no conversion). + + Author: christine@netscape.com + Date: 17 july 1997 +*/ + +var SECTION = "15.2.1.1"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Object( value )"; + +writeHeaderToLog( SECTION + " "+ TITLE); + + +var NULL_OBJECT = Object(null); + +new TestCase( SECTION, "Object(null).valueOf()", NULL_OBJECT, (NULL_OBJECT).valueOf() ); +new TestCase( SECTION, "typeof Object(null)", "object", typeof (Object(null)) ); + +var UNDEFINED_OBJECT = Object( void 0 ); + +new TestCase( SECTION, "Object(void 0).valueOf()", UNDEFINED_OBJECT, (UNDEFINED_OBJECT).valueOf() ); +new TestCase( SECTION, "typeof Object(void 0)", "object", typeof (Object(void 0)) ); + +new TestCase( SECTION, "Object(true).valueOf()", true, (Object(true)).valueOf() ); +new TestCase( SECTION, "typeof Object(true)", "object", typeof Object(true) ); +new TestCase( SECTION, "var MYOB = Object(true); MYOB.toString = Object.prototype.toString; MYOB.toString()", "[object Boolean]", eval("var MYOB = Object(true); MYOB.toString = Object.prototype.toString; MYOB.toString()") ); + +new TestCase( SECTION, "Object(false).valueOf()", false, (Object(false)).valueOf() ); +new TestCase( SECTION, "typeof Object(false)", "object", typeof Object(false) ); +new TestCase( SECTION, "var MYOB = Object(false); MYOB.toString = Object.prototype.toString; MYOB.toString()", "[object Boolean]", eval("var MYOB = Object(false); MYOB.toString = Object.prototype.toString; MYOB.toString()") ); + +new TestCase( SECTION, "Object(0).valueOf()", 0, (Object(0)).valueOf() ); +new TestCase( SECTION, "typeof Object(0)", "object", typeof Object(0) ); +new TestCase( SECTION, "var MYOB = Object(0); MYOB.toString = Object.prototype.toString; MYOB.toString()", "[object Number]", eval("var MYOB = Object(0); MYOB.toString = Object.prototype.toString; MYOB.toString()") ); + +new TestCase( SECTION, "Object(-0).valueOf()", -0, (Object(-0)).valueOf() ); +new TestCase( SECTION, "typeof Object(-0)", "object", typeof Object(-0) ); +new TestCase( SECTION, "var MYOB = Object(-0); MYOB.toString = Object.prototype.toString; MYOB.toString()", "[object Number]", eval("var MYOB = Object(-0); MYOB.toString = Object.prototype.toString; MYOB.toString()") ); + +new TestCase( SECTION, "Object(1).valueOf()", 1, (Object(1)).valueOf() ); +new TestCase( SECTION, "typeof Object(1)", "object", typeof Object(1) ); +new TestCase( SECTION, "var MYOB = Object(1); MYOB.toString = Object.prototype.toString; MYOB.toString()", "[object Number]", eval("var MYOB = Object(1); MYOB.toString = Object.prototype.toString; MYOB.toString()") ); + +new TestCase( SECTION, "Object(-1).valueOf()", -1, (Object(-1)).valueOf() ); +new TestCase( SECTION, "typeof Object(-1)", "object", typeof Object(-1) ); +new TestCase( SECTION, "var MYOB = Object(-1); MYOB.toString = Object.prototype.toString; MYOB.toString()", "[object Number]", eval("var MYOB = Object(-1); MYOB.toString = Object.prototype.toString; MYOB.toString()") ); + +new TestCase( SECTION, "Object(Number.MAX_VALUE).valueOf()", 1.7976931348623157e308, (Object(Number.MAX_VALUE)).valueOf() ); +new TestCase( SECTION, "typeof Object(Number.MAX_VALUE)", "object", typeof Object(Number.MAX_VALUE) ); +new TestCase( SECTION, "var MYOB = Object(Number.MAX_VALUE); MYOB.toString = Object.prototype.toString; MYOB.toString()", "[object Number]", eval("var MYOB = Object(Number.MAX_VALUE); MYOB.toString = Object.prototype.toString; MYOB.toString()") ); + +new TestCase( SECTION, "Object(Number.MIN_VALUE).valueOf()", 5e-324, (Object(Number.MIN_VALUE)).valueOf() ); +new TestCase( SECTION, "typeof Object(Number.MIN_VALUE)", "object", typeof Object(Number.MIN_VALUE) ); +new TestCase( SECTION, "var MYOB = Object(Number.MIN_VALUE); MYOB.toString = Object.prototype.toString; MYOB.toString()", "[object Number]", eval("var MYOB = Object(Number.MIN_VALUE); MYOB.toString = Object.prototype.toString; MYOB.toString()") ); + +new TestCase( SECTION, "Object(Number.POSITIVE_INFINITY).valueOf()", Number.POSITIVE_INFINITY, (Object(Number.POSITIVE_INFINITY)).valueOf() ); +new TestCase( SECTION, "typeof Object(Number.POSITIVE_INFINITY)", "object", typeof Object(Number.POSITIVE_INFINITY) ); +new TestCase( SECTION, "var MYOB = Object(Number.POSITIVE_INFINITY); MYOB.toString = Object.prototype.toString; MYOB.toString()", "[object Number]", eval("var MYOB = Object(Number.POSITIVE_INFINITY); MYOB.toString = Object.prototype.toString; MYOB.toString()") ); + +new TestCase( SECTION, "Object(Number.NEGATIVE_INFINITY).valueOf()", Number.NEGATIVE_INFINITY, (Object(Number.NEGATIVE_INFINITY)).valueOf() ); +new TestCase( SECTION, "typeof Object(Number.NEGATIVE_INFINITY)", "object", typeof Object(Number.NEGATIVE_INFINITY) ); +new TestCase( SECTION, "var MYOB = Object(Number.NEGATIVE_INFINITY); MYOB.toString = Object.prototype.toString; MYOB.toString()", "[object Number]", eval("var MYOB = Object(Number.NEGATIVE_INFINITY); MYOB.toString = Object.prototype.toString; MYOB.toString()") ); + +new TestCase( SECTION, "Object(Number.NaN).valueOf()", Number.NaN, (Object(Number.NaN)).valueOf() ); +new TestCase( SECTION, "typeof Object(Number.NaN)", "object", typeof Object(Number.NaN) ); +new TestCase( SECTION, "var MYOB = Object(Number.NaN); MYOB.toString = Object.prototype.toString; MYOB.toString()", "[object Number]", eval("var MYOB = Object(Number.NaN); MYOB.toString = Object.prototype.toString; MYOB.toString()") ); + +new TestCase( SECTION, "Object('a string').valueOf()", "a string", (Object("a string")).valueOf() ); +new TestCase( SECTION, "typeof Object('a string')", "object", typeof (Object("a string")) ); +new TestCase( SECTION, "var MYOB = Object('a string'); MYOB.toString = Object.prototype.toString; MYOB.toString()", "[object String]", eval("var MYOB = Object('a string'); MYOB.toString = Object.prototype.toString; MYOB.toString()") ); + +new TestCase( SECTION, "Object('').valueOf()", "", (Object("")).valueOf() ); +new TestCase( SECTION, "typeof Object('')", "object", typeof (Object("")) ); +new TestCase( SECTION, "var MYOB = Object(''); MYOB.toString = Object.prototype.toString; MYOB.toString()", "[object String]", eval("var MYOB = Object(''); MYOB.toString = Object.prototype.toString; MYOB.toString()") ); + +new TestCase( SECTION, "Object('\\r\\t\\b\\n\\v\\f').valueOf()", "\r\t\b\n\v\f", (Object("\r\t\b\n\v\f")).valueOf() ); +new TestCase( SECTION, "typeof Object('\\r\\t\\b\\n\\v\\f')", "object", typeof (Object("\\r\\t\\b\\n\\v\\f")) ); +new TestCase( SECTION, "var MYOB = Object('\\r\\t\\b\\n\\v\\f'); MYOB.toString = Object.prototype.toString; MYOB.toString()", "[object String]", eval("var MYOB = Object('\\r\\t\\b\\n\\v\\f'); MYOB.toString = Object.prototype.toString; MYOB.toString()") ); + +new TestCase( SECTION, "Object( '\\\'\\\"\\' ).valueOf()", "\'\"\\", (Object("\'\"\\")).valueOf() ); +new TestCase( SECTION, "typeof Object( '\\\'\\\"\\' )", "object", typeof Object("\'\"\\") ); +// new TestCase( SECTION, "var MYOB = Object( '\\\'\\\"\\' ); MYOB.toString = Object.prototype.toString; MYOB.toString()", "[object String]", eval("var MYOB = Object( '\\\'\\\"\\' ); MYOB.toString = Object.prototype.toString; MYOB.toString()") ); + +test(); diff --git a/tests/auto/qml/parserstress/tests/ecma/ObjectObjects/15.2.1.2.js b/tests/auto/qml/parserstress/tests/ecma/ObjectObjects/15.2.1.2.js new file mode 100644 index 0000000000..9e41594430 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/ObjectObjects/15.2.1.2.js @@ -0,0 +1,81 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.2.1.2.js'; + +/** + File Name: 15.2.1.2.js + ECMA Section: 15.2.1.2 The Object Constructor Called as a Function: + Object(value) + Description: When Object is called as a function rather than as a + constructor, the following steps are taken: + + 1. If value is null or undefined, create and return a + new object with no proerties other than internal + properties exactly as if the object constructor + had been called on that same value (15.2.2.1). + 2. Return ToObject (value), whose rules are: + + undefined generate a runtime error + null generate a runtime error + boolean create a new Boolean object whose default + value is the value of the boolean. + number Create a new Number object whose default + value is the value of the number. + string Create a new String object whose default + value is the value of the string. + object Return the input argument (no conversion). + + Author: christine@netscape.com + Date: 17 july 1997 +*/ + +var SECTION = "15.2.1.2"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Object()"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +var MYOB = Object(); + +new TestCase( SECTION, "var MYOB = Object(); MYOB.valueOf()", MYOB, MYOB.valueOf() ); +new TestCase( SECTION, "typeof Object()", "object", typeof (Object(null)) ); +new TestCase( SECTION, "var MYOB = Object(); MYOB.toString()", "[object Object]", eval("var MYOB = Object(); MYOB.toString()") ); + +test(); diff --git a/tests/auto/qml/parserstress/tests/ecma/ObjectObjects/15.2.2.1.js b/tests/auto/qml/parserstress/tests/ecma/ObjectObjects/15.2.2.1.js new file mode 100644 index 0000000000..dfdfaeb4ab --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/ObjectObjects/15.2.2.1.js @@ -0,0 +1,138 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.2.2.1.js'; + +/** + File Name: 15.2.2.1.js + ECMA Section: 15.2.2.1 The Object Constructor: new Object( value ) + + 1.If the type of the value is not Object, go to step 4. + 2.If the value is a native ECMAScript object, do not create a new object; simply return value. + 3.If the value is a host object, then actions are taken and a result is returned in an + implementation-dependent manner that may depend on the host object. + 4.If the type of the value is String, return ToObject(value). + 5.If the type of the value is Boolean, return ToObject(value). + 6.If the type of the value is Number, return ToObject(value). + 7.(The type of the value must be Null or Undefined.) Create a new native ECMAScript object. + The [[Prototype]] property of the newly constructed object is set to the Object prototype object. + The [[Class]] property of the newly constructed object is set to "Object". + The newly constructed object has no [[Value]] property. + Return the newly created native object. + + Description: This does not test cases where the object is a host object. + Author: christine@netscape.com + Date: 7 october 1997 +*/ + +var SECTION = "15.2.2.1"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "new Object( value )"; + +writeHeaderToLog( SECTION + " "+ TITLE); + + +new TestCase( SECTION, "typeof new Object(null)", "object", typeof new Object(null) ); +new TestCase( SECTION, "MYOB = new Object(null); MYOB.toString = Object.prototype.toString; MYOB.toString()", "[object Object]", eval("MYOB = new Object(null); MYOB.toString = Object.prototype.toString; MYOB.toString()") ); + +new TestCase( SECTION, "typeof new Object(void 0)", "object", typeof new Object(void 0) ); +new TestCase( SECTION, "MYOB = new Object(new Object(void 0)); MYOB.toString = Object.prototype.toString; MYOB.toString()", "[object Object]", eval("MYOB = new Object(new Object(void 0)); MYOB.toString = Object.prototype.toString; MYOB.toString()") ); + +new TestCase( SECTION, "typeof new Object('string')", "object", typeof new Object('string') ); +new TestCase( SECTION, "MYOB = (new Object('string'); MYOB.toString = Object.prototype.toString; MYOB.toString()", "[object String]", eval("MYOB = new Object('string'); MYOB.toString = Object.prototype.toString; MYOB.toString()") ); +new TestCase( SECTION, "(new Object('string').valueOf()", "string", (new Object('string')).valueOf() ); + +new TestCase( SECTION, "typeof new Object('')", "object", typeof new Object('') ); +new TestCase( SECTION, "MYOB = (new Object(''); MYOB.toString = Object.prototype.toString; MYOB.toString()", "[object String]", eval("MYOB = new Object(''); MYOB.toString = Object.prototype.toString; MYOB.toString()") ); +new TestCase( SECTION, "(new Object('').valueOf()", "", (new Object('')).valueOf() ); + +new TestCase( SECTION, "typeof new Object(Number.NaN)", "object", typeof new Object(Number.NaN) ); +new TestCase( SECTION, "MYOB = (new Object(Number.NaN); MYOB.toString = Object.prototype.toString; MYOB.toString()", "[object Number]", eval("MYOB = new Object(Number.NaN); MYOB.toString = Object.prototype.toString; MYOB.toString()") ); +new TestCase( SECTION, "(new Object(Number.NaN).valueOf()", Number.NaN, (new Object(Number.NaN)).valueOf() ); + +new TestCase( SECTION, "typeof new Object(0)", "object", typeof new Object(0) ); +new TestCase( SECTION, "MYOB = (new Object(0); MYOB.toString = Object.prototype.toString; MYOB.toString()", "[object Number]", eval("MYOB = new Object(0); MYOB.toString = Object.prototype.toString; MYOB.toString()") ); +new TestCase( SECTION, "(new Object(0).valueOf()", 0, (new Object(0)).valueOf() ); + +new TestCase( SECTION, "typeof new Object(-0)", "object", typeof new Object(-0) ); +new TestCase( SECTION, "MYOB = (new Object(-0); MYOB.toString = Object.prototype.toString; MYOB.toString()", "[object Number]", eval("MYOB = new Object(-0); MYOB.toString = Object.prototype.toString; MYOB.toString()") ); +new TestCase( SECTION, "(new Object(-0).valueOf()", -0, (new Object(-0)).valueOf() ); + +new TestCase( SECTION, "typeof new Object(1)", "object", typeof new Object(1) ); +new TestCase( SECTION, "MYOB = (new Object(1); MYOB.toString = Object.prototype.toString; MYOB.toString()", "[object Number]", eval("MYOB = new Object(1); MYOB.toString = Object.prototype.toString; MYOB.toString()") ); +new TestCase( SECTION, "(new Object(1).valueOf()", 1, (new Object(1)).valueOf() ); + +new TestCase( SECTION, "typeof new Object(-1)", "object", typeof new Object(-1) ); +new TestCase( SECTION, "MYOB = (new Object(-1); MYOB.toString = Object.prototype.toString; MYOB.toString()", "[object Number]", eval("MYOB = new Object(-1); MYOB.toString = Object.prototype.toString; MYOB.toString()") ); +new TestCase( SECTION, "(new Object(-1).valueOf()", -1, (new Object(-1)).valueOf() ); + +new TestCase( SECTION, "typeof new Object(true)", "object", typeof new Object(true) ); +new TestCase( SECTION, "MYOB = (new Object(true); MYOB.toString = Object.prototype.toString; MYOB.toString()", "[object Boolean]", eval("MYOB = new Object(true); MYOB.toString = Object.prototype.toString; MYOB.toString()") ); +new TestCase( SECTION, "(new Object(true).valueOf()", true, (new Object(true)).valueOf() ); + +new TestCase( SECTION, "typeof new Object(false)", "object", typeof new Object(false) ); +new TestCase( SECTION, "MYOB = (new Object(false); MYOB.toString = Object.prototype.toString; MYOB.toString()", "[object Boolean]", eval("MYOB = new Object(false); MYOB.toString = Object.prototype.toString; MYOB.toString()") ); +new TestCase( SECTION, "(new Object(false).valueOf()", false, (new Object(false)).valueOf() ); + +new TestCase( SECTION, "typeof new Object(Boolean())", "object", typeof new Object(Boolean()) ); +new TestCase( SECTION, "MYOB = (new Object(Boolean()); MYOB.toString = Object.prototype.toString; MYOB.toString()", "[object Boolean]", eval("MYOB = new Object(Boolean()); MYOB.toString = Object.prototype.toString; MYOB.toString()") ); +new TestCase( SECTION, "(new Object(Boolean()).valueOf()", Boolean(), (new Object(Boolean())).valueOf() ); + + +var myglobal = this; +var myobject = new Object( "my new object" ); +var myarray = new Array(); +var myboolean = new Boolean(); +var mynumber = new Number(); +var mystring = new String(); +var myobject = new Object(); +var myfunction = new Function( "x", "return x"); +var mymath = Math; + +new TestCase( SECTION, "myglobal = new Object( this )", myglobal, new Object(this) ); +new TestCase( SECTION, "myobject = new Object('my new object'); new Object(myobject)", myobject, new Object(myobject) ); +new TestCase( SECTION, "myarray = new Array(); new Object(myarray)", myarray, new Object(myarray) ); +new TestCase( SECTION, "myboolean = new Boolean(); new Object(myboolean)", myboolean, new Object(myboolean) ); +new TestCase( SECTION, "mynumber = new Number(); new Object(mynumber)", mynumber, new Object(mynumber) ); +new TestCase( SECTION, "mystring = new String9); new Object(mystring)", mystring, new Object(mystring) ); +new TestCase( SECTION, "myobject = new Object(); new Object(mynobject)", myobject, new Object(myobject) ); +new TestCase( SECTION, "myfunction = new Function(); new Object(myfunction)", myfunction, new Object(myfunction) ); +new TestCase( SECTION, "mymath = Math; new Object(mymath)", mymath, new Object(mymath) ); + +test(); diff --git a/tests/auto/qml/parserstress/tests/ecma/ObjectObjects/15.2.2.2.js b/tests/auto/qml/parserstress/tests/ecma/ObjectObjects/15.2.2.2.js new file mode 100644 index 0000000000..2a5743a826 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/ObjectObjects/15.2.2.2.js @@ -0,0 +1,74 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.2.2.2.js'; + +/** + File Name: 15.2.2.2.js + ECMA Section: 15.2.2.2 new Object() + Description: + + When the Object constructor is called with no argument, the following + step is taken: + + 1. Create a new native ECMAScript object. + The [[Prototype]] property of the newly constructed object is set to + the Object prototype object. + + The [[Class]] property of the newly constructed object is set + to "Object". + + The newly constructed object has no [[Value]] property. + + Return the newly created native object. + + Author: christine@netscape.com + Date: 7 october 1997 +*/ +var SECTION = "15.2.2.2"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "new Object()"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +new TestCase( SECTION, "typeof new Object()", "object", typeof new Object() ); +new TestCase( SECTION, "Object.prototype.toString()", "[object Object]", Object.prototype.toString() ); +new TestCase( SECTION, "(new Object()).toString()", "[object Object]", (new Object()).toString() ); + +test(); diff --git a/tests/auto/qml/parserstress/tests/ecma/ObjectObjects/15.2.3-1.js b/tests/auto/qml/parserstress/tests/ecma/ObjectObjects/15.2.3-1.js new file mode 100644 index 0000000000..5242d7e6a5 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/ObjectObjects/15.2.3-1.js @@ -0,0 +1,64 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.2.3-1.js'; + +/** + File Name: 15.2.3-1.js + ECMA Section: 15.2.3 Properties of the Object Constructor + + Description: The value of the internal [[Prototype]] property of the + Object constructor is the Function prototype object. + + Besides the call and construct propreties and the length + property, the Object constructor has properties described + in 15.2.3.1. + + Author: christine@netscape.com + Date: 28 october 1997 + +*/ +var SECTION = "15.2.3"; +var VERSION = "ECMA_2"; +startTest(); + +writeHeaderToLog( SECTION + " Properties of the Object Constructor"); + +new TestCase( SECTION, "Object.length", 1, Object.length ); + +test(); diff --git a/tests/auto/qml/parserstress/tests/ecma/ObjectObjects/15.2.3.1-1.js b/tests/auto/qml/parserstress/tests/ecma/ObjectObjects/15.2.3.1-1.js new file mode 100644 index 0000000000..39510b6b22 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/ObjectObjects/15.2.3.1-1.js @@ -0,0 +1,69 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.2.3.1-1.js'; + +/** + File Name: 15.2.3.1-1.js + ECMA Section: 15.2.3.1 Object.prototype + + Description: The initial value of Object.prototype is the built-in + Object prototype object. + + This property shall have the attributes [ DontEnum, + DontDelete ReadOnly ] + + This tests the [DontEnum] property of Object.prototype + + Author: christine@netscape.com + Date: 28 october 1997 + +*/ +var SECTION = "15.2.3.1-1"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Object.prototype"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +new TestCase( SECTION, + "var str = '';for ( p in Object ) { str += p; }; str", + "", + eval( "var str = ''; for ( p in Object ) { str += p; }; str" ) ); + +test(); diff --git a/tests/auto/qml/parserstress/tests/ecma/ObjectObjects/15.2.3.1-2.js b/tests/auto/qml/parserstress/tests/ecma/ObjectObjects/15.2.3.1-2.js new file mode 100644 index 0000000000..a92739f2d1 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/ObjectObjects/15.2.3.1-2.js @@ -0,0 +1,70 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.2.3.1-2.js'; + +/** + File Name: 15.2.3.1-2.js + ECMA Section: 15.2.3.1 Object.prototype + + Description: The initial value of Object.prototype is the built-in + Object prototype object. + + This property shall have the attributes [ DontEnum, + DontDelete ReadOnly ] + + This tests the [DontDelete] property of Object.prototype + + Author: christine@netscape.com + Date: 28 october 1997 + +*/ + +var SECTION = "15.2.3.1-2"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Object.prototype"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +new TestCase( SECTION, + "delete( Object.prototype )", + false, + eval("delete( Object.prototype )") ); + +test(); diff --git a/tests/auto/qml/parserstress/tests/ecma/ObjectObjects/15.2.3.1-3.js b/tests/auto/qml/parserstress/tests/ecma/ObjectObjects/15.2.3.1-3.js new file mode 100644 index 0000000000..0a82c6cd02 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/ObjectObjects/15.2.3.1-3.js @@ -0,0 +1,70 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.2.3.1-3.js'; + +/** + File Name: 15.2.3.1-3.js + ECMA Section: 15.2.3.1 Object.prototype + + Description: The initial value of Object.prototype is the built-in + Object prototype object. + + This property shall have the attributes [ DontEnum, + DontDelete ReadOnly ] + + This tests the [ReadOnly] property of Object.prototype + + Author: christine@netscape.com + Date: 28 october 1997 + +*/ + +var SECTION = "15.2.3.1-3"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Object.prototype"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +new TestCase( SECTION, + "Object.prototype = null; Object.prototype", + Object.prototype, + eval("Object.prototype = null; Object.prototype")); + +test(); diff --git a/tests/auto/qml/parserstress/tests/ecma/ObjectObjects/15.2.3.1-4.js b/tests/auto/qml/parserstress/tests/ecma/ObjectObjects/15.2.3.1-4.js new file mode 100644 index 0000000000..86be98e1ad --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/ObjectObjects/15.2.3.1-4.js @@ -0,0 +1,70 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.2.3.1-4.js'; + +/** + File Name: 15.2.3.1-4.js + ECMA Section: 15.2.3.1 Object.prototype + + Description: The initial value of Object.prototype is the built-in + Object prototype object. + + This property shall have the attributes [ DontEnum, + DontDelete ReadOnly ] + + This tests the [DontDelete] property of Object.prototype + + Author: christine@netscape.com + Date: 28 october 1997 + +*/ + +var SECTION = "15.2.3.1-4"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Object.prototype"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +new TestCase( SECTION, + "delete( Object.prototype ); Object.prototype", + Object.prototype, + eval("delete(Object.prototype); Object.prototype") ); + +test(); diff --git a/tests/auto/qml/parserstress/tests/ecma/ObjectObjects/15.2.3.js b/tests/auto/qml/parserstress/tests/ecma/ObjectObjects/15.2.3.js new file mode 100644 index 0000000000..70a9605c2e --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/ObjectObjects/15.2.3.js @@ -0,0 +1,67 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.2.3.js'; + +/** + File Name: 15.2.3.js + ECMA Section: 15.2.3 Properties of the Object Constructor + + Description: The value of the internal [[Prototype]] property of the + Object constructor is the Function prototype object. + + Besides the call and construct propreties and the length + property, the Object constructor has properties described + in 15.2.3.1. + + Author: christine@netscape.com + Date: 28 october 1997 + +*/ + +var SECTION = "15.2.3"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Properties of the Object Constructor"; + +writeHeaderToLog( SECTION + " " + TITLE); + +// new TestCase( SECTION, "Object.__proto__", Function.prototype, Object.__proto__ ); +new TestCase( SECTION, "Object.length", 1, Object.length ); + +test(); diff --git a/tests/auto/qml/parserstress/tests/ecma/ObjectObjects/15.2.4.1.js b/tests/auto/qml/parserstress/tests/ecma/ObjectObjects/15.2.4.1.js new file mode 100644 index 0000000000..bff668f43c --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/ObjectObjects/15.2.4.1.js @@ -0,0 +1,64 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.2.4.1.js'; + +/** + File Name: 15.2.4.1.js + ECMA Section: 15.2.4 Object.prototype.constructor + + Description: The initial value of the Object.prototype.constructor + is the built-in Object constructor. + + Author: christine@netscape.com + Date: 28 october 1997 + +*/ +var SECTION = "15.2.4.1"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Object.prototype.constructor"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +new TestCase( SECTION, + "Object.prototype.constructor", + Object, + Object.prototype.constructor ); + +test(); diff --git a/tests/auto/qml/parserstress/tests/ecma/ObjectObjects/15.2.4.2.js b/tests/auto/qml/parserstress/tests/ecma/ObjectObjects/15.2.4.2.js new file mode 100644 index 0000000000..c52a825bb8 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/ObjectObjects/15.2.4.2.js @@ -0,0 +1,130 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.2.4.2.js'; + +/** + File Name: 15.2.4.2.js + ECMA Section: 15.2.4.2 Object.prototype.toString() + + Description: When the toString method is called, the following + steps are taken: + 1. Get the [[Class]] property of this object + 2. Call ToString( Result(1) ) + 3. Compute a string value by concatenating the three + strings "[object " + Result(2) + "]" + 4. Return Result(3). + + Author: christine@netscape.com + Date: 28 october 1997 + +*/ +var SECTION = "15.2.4.2"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Object.prototype.toString()"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +new TestCase( SECTION, "(new Object()).toString()", "[object Object]", (new Object()).toString() ); + +new TestCase( SECTION, "myvar = this; myvar.toString = Object.prototype.toString; myvar.toString()", + GLOBAL.replace(/ @ 0x[0-9a-fA-F]+ \(native @ 0x[0-9a-fA-F]+\)/, ''), + eval("myvar = this; myvar.toString = Object.prototype.toString; myvar.toString()") + ); + +new TestCase( SECTION, "myvar = MyObject; myvar.toString = Object.prototype.toString; myvar.toString()", + "[object Function]", + eval("myvar = MyObject; myvar.toString = Object.prototype.toString; myvar.toString()") ); + +new TestCase( SECTION, "myvar = new MyObject( true ); myvar.toString = Object.prototype.toString; myvar.toString()", + '[object Object]', + eval("myvar = new MyObject( true ); myvar.toString = Object.prototype.toString; myvar.toString()") ); + +new TestCase( SECTION, "myvar = new Number(0); myvar.toString = Object.prototype.toString; myvar.toString()", + "[object Number]", + eval("myvar = new Number(0); myvar.toString = Object.prototype.toString; myvar.toString()") ); + +new TestCase( SECTION, "myvar = new String(''); myvar.toString = Object.prototype.toString; myvar.toString()", + "[object String]", + eval("myvar = new String(''); myvar.toString = Object.prototype.toString; myvar.toString()") ); + +new TestCase( SECTION, "myvar = Math; myvar.toString = Object.prototype.toString; myvar.toString()", + "[object Math]", + eval("myvar = Math; myvar.toString = Object.prototype.toString; myvar.toString()") ); + +new TestCase( SECTION, "myvar = new Function(); myvar.toString = Object.prototype.toString; myvar.toString()", + "[object Function]", + eval("myvar = new Function(); myvar.toString = Object.prototype.toString; myvar.toString()") ); + +new TestCase( SECTION, "myvar = new Array(); myvar.toString = Object.prototype.toString; myvar.toString()", + "[object Array]", + eval("myvar = new Array(); myvar.toString = Object.prototype.toString; myvar.toString()") ); + +new TestCase( SECTION, "myvar = new Boolean(); myvar.toString = Object.prototype.toString; myvar.toString()", + "[object Boolean]", + eval("myvar = new Boolean(); myvar.toString = Object.prototype.toString; myvar.toString()") ); + +new TestCase( SECTION, "myvar = new Date(); myvar.toString = Object.prototype.toString; myvar.toString()", + "[object Date]", + eval("myvar = new Date(); myvar.toString = Object.prototype.toString; myvar.toString()") ); + +new TestCase( SECTION, "var MYVAR = new Object( this ); MYVAR.toString()", + GLOBAL.replace(/ @ 0x[0-9a-fA-F]+ \(native @ 0x[0-9a-fA-F]+\)/, ''), + eval("var MYVAR = new Object( this ); MYVAR.toString()") + ); + +new TestCase( SECTION, "var MYVAR = new Object(); MYVAR.toString()", + "[object Object]", + eval("var MYVAR = new Object(); MYVAR.toString()") ); + +new TestCase( SECTION, "var MYVAR = new Object(void 0); MYVAR.toString()", + "[object Object]", + eval("var MYVAR = new Object(void 0); MYVAR.toString()") ); + +new TestCase( SECTION, "var MYVAR = new Object(null); MYVAR.toString()", + "[object Object]", + eval("var MYVAR = new Object(null); MYVAR.toString()") ); + + +function MyObject( value ) { + this.value = new Function( "return this.value" ); + this.toString = new Function ( "return this.value+''"); +} + +test(); diff --git a/tests/auto/qml/parserstress/tests/ecma/ObjectObjects/15.2.4.3.js b/tests/auto/qml/parserstress/tests/ecma/ObjectObjects/15.2.4.3.js new file mode 100644 index 0000000000..17c4558679 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/ObjectObjects/15.2.4.3.js @@ -0,0 +1,117 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.2.4.3.js'; + +/** + File Name: 15.2.4.3.js + ECMA Section: 15.2.4.3 Object.prototype.valueOf() + + Description: As a rule, the valueOf method for an object simply + returns the object; but if the object is a "wrapper" + for a host object, as may perhaps be created by the + Object constructor, then the contained host object + should be returned. + + This only covers native objects. + + Author: christine@netscape.com + Date: 28 october 1997 + +*/ +var SECTION = "15.2.4.3"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Object.prototype.valueOf()"; + +writeHeaderToLog( SECTION + " "+ TITLE); + + +var myarray = new Array(); +myarray.valueOf = Object.prototype.valueOf; +var myboolean = new Boolean(); +myboolean.valueOf = Object.prototype.valueOf; +var myfunction = new Function(); +myfunction.valueOf = Object.prototype.valueOf; +var myobject = new Object(); +myobject.valueOf = Object.prototype.valueOf; +var mymath = Math; +mymath.valueOf = Object.prototype.valueOf; +var mydate = new Date(); +mydate.valueOf = Object.prototype.valueOf; +var mynumber = new Number(); +mynumber.valueOf = Object.prototype.valueOf; +var mystring = new String(); +mystring.valueOf = Object.prototype.valueOf; + +new TestCase( SECTION, "Object.prototype.valueOf.length", 0, Object.prototype.valueOf.length ); + +new TestCase( SECTION, + "myarray = new Array(); myarray.valueOf = Object.prototype.valueOf; myarray.valueOf()", + myarray, + myarray.valueOf() ); +new TestCase( SECTION, + "myboolean = new Boolean(); myboolean.valueOf = Object.prototype.valueOf; myboolean.valueOf()", + myboolean, + myboolean.valueOf() ); +new TestCase( SECTION, + "myfunction = new Function(); myfunction.valueOf = Object.prototype.valueOf; myfunction.valueOf()", + myfunction, + myfunction.valueOf() ); +new TestCase( SECTION, + "myobject = new Object(); myobject.valueOf = Object.prototype.valueOf; myobject.valueOf()", + myobject, + myobject.valueOf() ); +new TestCase( SECTION, + "mymath = Math; mymath.valueOf = Object.prototype.valueOf; mymath.valueOf()", + mymath, + mymath.valueOf() ); +new TestCase( SECTION, + "mynumber = new Number(); mynumber.valueOf = Object.prototype.valueOf; mynumber.valueOf()", + mynumber, + mynumber.valueOf() ); +new TestCase( SECTION, + "mystring = new String(); mystring.valueOf = Object.prototype.valueOf; mystring.valueOf()", + mystring, + mystring.valueOf() ); +new TestCase( SECTION, + "mydate = new Date(); mydate.valueOf = Object.prototype.valueOf; mydate.valueOf()", + mydate, + mydate.valueOf() ); + +test(); diff --git a/tests/auto/qml/parserstress/tests/ecma/ObjectObjects/browser.js b/tests/auto/qml/parserstress/tests/ecma/ObjectObjects/browser.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/auto/qml/parserstress/tests/ecma/ObjectObjects/shell.js b/tests/auto/qml/parserstress/tests/ecma/ObjectObjects/shell.js new file mode 100644 index 0000000000..1a71207967 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/ObjectObjects/shell.js @@ -0,0 +1 @@ +gTestsubsuite = 'ObjectObjects'; diff --git a/tests/auto/qml/parserstress/tests/ecma/README b/tests/auto/qml/parserstress/tests/ecma/README new file mode 100755 index 0000000000..91f174ab61 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/README @@ -0,0 +1 @@ +ECMA 262 Edition 1 diff --git a/tests/auto/qml/parserstress/tests/ecma/SourceText/6-1.js b/tests/auto/qml/parserstress/tests/ecma/SourceText/6-1.js new file mode 100644 index 0000000000..487a47e3aa --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/SourceText/6-1.js @@ -0,0 +1,128 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '6-1.js'; + +/** + File Name: 6-1.js + ECMA Section: Source Text + Description: + + ECMAScript source text is represented as a sequence of characters + representable using the Unicode version 2.0 character encoding. + + SourceCharacter :: + any Unicode character + + However, it is possible to represent every ECMAScript program using + only ASCII characters (which are equivalent to the first 128 Unicode + characters). Non-ASCII Unicode characters may appear only within comments + and string literals. In string literals, any Unicode character may also be + expressed as a Unicode escape sequence consisting of six ASCII characters, + namely \u plus four hexadecimal digits. Within a comment, such an escape + sequence is effectively ignored as part of the comment. Within a string + literal, the Unicode escape sequence contributes one character to the string + value of the literal. + + Note that ECMAScript differs from the Java programming language in the + behavior of Unicode escape sequences. In a Java program, if the Unicode escape + sequence \u000A, for example, occurs within a single-line comment, it is + interpreted as a line terminator (Unicode character 000A is line feed) and + therefore the next character is not part of the comment. Similarly, if the + Unicode escape sequence \u000A occurs within a string literal in a Java + program, it is likewise interpreted as a line terminator, which is not + allowed within a string literal-one must write \n instead of \u000A to + cause a line feed to be part of the string value of a string literal. In + an ECMAScript program, a Unicode escape sequence occurring within a comment + is never interpreted and therefore cannot contribute to termination of the + comment. Similarly, a Unicode escape sequence occurring within a string literal + in an ECMAScript program always contributes a character to the string value of + the literal and is never interpreted as a line terminator or as a quote mark + that might terminate the string literal. + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + +var SECTION = "6-1"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Source Text"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +var testcase = new TestCase( SECTION, + "// the following character should not be interpreted as a line terminator in a comment: \u000A", + 'PASSED', + "PASSED" ); + +// \u000A testcase.actual = "FAILED!"; + +testcase = + new TestCase( SECTION, + "// the following character should not be interpreted as a line terminator in a comment: \\n 'FAILED'", + 'PASSED', + 'PASSED' ); + +// the following character should noy be interpreted as a line terminator: \\n testcase.actual = "FAILED" + +testcase = + new TestCase( SECTION, + "// the following character should not be interpreted as a line terminator in a comment: \\u000A 'FAILED'", + 'PASSED', + 'PASSED' ); + +// the following character should not be interpreted as a line terminator: \u000A testcase.actual = "FAILED" + +testcase = + new TestCase( SECTION, + "// the following character should not be interpreted as a line terminator in a comment: \n 'PASSED'", + 'PASSED', + 'PASSED' ); +// the following character should not be interpreted as a line terminator: \n testcase.actual = 'FAILED' + +testcase = + new TestCase( SECTION, + "// the following character should not be interpreted as a line terminator in a comment: u000D", + 'PASSED', + 'PASSED' ); + +// the following character should not be interpreted as a line terminator: \u000D testcase.actual = "FAILED" + +test(); + diff --git a/tests/auto/qml/parserstress/tests/ecma/SourceText/6-2.js b/tests/auto/qml/parserstress/tests/ecma/SourceText/6-2.js new file mode 100644 index 0000000000..4044308053 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/SourceText/6-2.js @@ -0,0 +1,131 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '6-2.js'; + +/** + File Name: 6-1.js + ECMA Section: Source Text + Description: + + ECMAScript source text is represented as a sequence of characters + representable using the Unicode version 2.0 character encoding. + + SourceCharacter :: + any Unicode character + + However, it is possible to represent every ECMAScript program using + only ASCII characters (which are equivalent to the first 128 Unicode + characters). Non-ASCII Unicode characters may appear only within comments + and string literals. In string literals, any Unicode character may also be + expressed as a Unicode escape sequence consisting of six ASCII characters, + namely \u plus four hexadecimal digits. Within a comment, such an escape + sequence is effectively ignored as part of the comment. Within a string + literal, the Unicode escape sequence contributes one character to the string + value of the literal. + + Note that ECMAScript differs from the Java programming language in the + behavior of Unicode escape sequences. In a Java program, if the Unicode escape + sequence \u000A, for example, occurs within a single-line comment, it is + interpreted as a line terminator (Unicode character 000A is line feed) and + therefore the next character is not part of the comment. Similarly, if the + Unicode escape sequence \u000A occurs within a string literal in a Java + program, it is likewise interpreted as a line terminator, which is not + allowed within a string literal-one must write \n instead of \u000A to + cause a line feed to be part of the string value of a string literal. In + an ECMAScript program, a Unicode escape sequence occurring within a comment + is never interpreted and therefore cannot contribute to termination of the + comment. Similarly, a Unicode escape sequence occurring within a string literal + in an ECMAScript program always contributes a character to the string value of + the literal and is never interpreted as a line terminator or as a quote mark + that might terminate the string literal. + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + +var SECTION = "6-1"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Source Text"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +// encoded quotes should not end a quote + +new TestCase( SECTION, + "var s = 'PAS\\u0022SED'; s", + "PAS\"SED", + eval("var s = 'PAS\\u0022SED'; s") ); + +new TestCase( SECTION, + 'var s = "PAS\\u0022SED"; s', + "PAS\"SED", + eval('var s = "PAS\\u0022SED"; s') ); + + +new TestCase( SECTION, + "var s = 'PAS\\u0027SED'; s", + "PAS\'SED", + eval("var s = 'PAS\\u0027SED'; s") ); + + +new TestCase( SECTION, + 'var s = "PAS\\u0027SED"; s', + "PAS\'SED", + eval('var s = "PAS\\u0027SED"; s') ); + +var testcase = new TestCase( SECTION, + 'var s="PAS\\u0027SED"; s', + "PAS\'SED", + "" ); +var s = "PAS\u0027SED"; + +testcase.actual = s; + +testcase = new TestCase( SECTION, + 'var s = "PAS\\u0022SED"; s', + "PAS\"SED", + "" ); +var s = "PAS\u0022SED"; + +testcase.actual = s; + + +test(); + diff --git a/tests/auto/qml/parserstress/tests/ecma/SourceText/browser.js b/tests/auto/qml/parserstress/tests/ecma/SourceText/browser.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/auto/qml/parserstress/tests/ecma/SourceText/shell.js b/tests/auto/qml/parserstress/tests/ecma/SourceText/shell.js new file mode 100644 index 0000000000..c8f9f02671 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/SourceText/shell.js @@ -0,0 +1 @@ +gTestsubsuite = 'SourceText'; diff --git a/tests/auto/qml/parserstress/tests/ecma/Statements/12.10-1.js b/tests/auto/qml/parserstress/tests/ecma/Statements/12.10-1.js new file mode 100644 index 0000000000..7cb13789eb --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Statements/12.10-1.js @@ -0,0 +1,151 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '12.10-1.js'; + +/** + File Name: 12.10-1.js + ECMA Section: 12.10 The with statement + Description: + WithStatement : + with ( Expression ) Statement + + The with statement adds a computed object to the front of the scope chain + of the current execution context, then executes a statement with this + augmented scope chain, then restores the scope chain. + + Semantics + + The production WithStatement : with ( Expression ) Statement is evaluated + as follows: + 1. Evaluate Expression. + 2. Call GetValue(Result(1)). + 3. Call ToObject(Result(2)). + 4. Add Result(3) to the front of the scope chain. + 5. Evaluate Statement using the augmented scope chain from step 4. + 6. Remove Result(3) from the front of the scope chain. + 7. Return Result(5). + + Discussion + Note that no matter how control leaves the embedded Statement, whether + normally or by some form of abrupt completion, the scope chain is always + restored to its former state. + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + +var SECTION = "12.10-1"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "The with statement"; + +writeHeaderToLog( SECTION + " "+ TITLE); + + +// although the scope chain changes, the this value is immutable for a given +// execution context. + +new TestCase( SECTION, + "with( new Number() ) { this +'' }", + GLOBAL, + eval("with( new Number() ) { this +'' }") ); + +// the object's functions and properties should override those of the +// global object. + +new TestCase( + SECTION, + "var MYOB = new WithObject(true); with (MYOB) { parseInt() }", + true, + eval("var MYOB = new WithObject(true); with (MYOB) { parseInt() }") ); + +new TestCase( + SECTION, + "var MYOB = new WithObject(false); with (MYOB) { NaN }", + false, + eval("var MYOB = new WithObject(false); with (MYOB) { NaN }") ); + +new TestCase( + SECTION, + "var MYOB = new WithObject(NaN); with (MYOB) { Infinity }", + Number.NaN, + eval("var MYOB = new WithObject(NaN); with (MYOB) { Infinity }") ); + +new TestCase( + SECTION, + "var MYOB = new WithObject(false); with (MYOB) { }; Infinity", + Number.POSITIVE_INFINITY, + eval("var MYOB = new WithObject(false); with (MYOB) { }; Infinity") ); + + +new TestCase( + SECTION, + "var MYOB = new WithObject(0); with (MYOB) { delete Infinity; Infinity }", + Number.POSITIVE_INFINITY, + eval("var MYOB = new WithObject(0); with (MYOB) { delete Infinity; Infinity }") ); + +// let us leave the with block via a break. + +new TestCase( + SECTION, + "var MYOB = new WithObject(0); while (true) { with (MYOB) { Infinity; break; } } Infinity", + Number.POSITIVE_INFINITY, + eval("var MYOB = new WithObject(0); while (true) { with (MYOB) { Infinity; break; } } Infinity") ); + + +test(); + +function WithObject( value ) { + this.prop1 = 1; + this.prop2 = new Boolean(true); + this.prop3 = "a string"; + this.value = value; + + // now we will override global functions + + this.parseInt = new Function( "return this.value" ); + this.NaN = value; + this.Infinity = value; + this.unescape = new Function( "return this.value" ); + this.escape = new Function( "return this.value" ); + this.eval = new Function( "return this.value" ); + this.parseFloat = new Function( "return this.value" ); + this.isNaN = new Function( "return this.value" ); + this.isFinite = new Function( "return this.value" ); +} diff --git a/tests/auto/qml/parserstress/tests/ecma/Statements/12.10.js b/tests/auto/qml/parserstress/tests/ecma/Statements/12.10.js new file mode 100644 index 0000000000..b8d27c64e9 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Statements/12.10.js @@ -0,0 +1,61 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '12.10.js'; + +/** + File Name: 12.10-1.js + ECMA Section: 12.10 The with statement + Description: + + Author: christine@netscape.com + Date: 11 september 1997 +*/ +var SECTION = "12.10-1"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "The with statement"; + +writeHeaderToLog( SECTION +" "+ TITLE); + +new TestCase( SECTION, + "var x; with (7) x = valueOf(); typeof x;", + "number", + eval("var x; with(7) x = valueOf(); typeof x;") ); + +test(); diff --git a/tests/auto/qml/parserstress/tests/ecma/Statements/12.2-1.js b/tests/auto/qml/parserstress/tests/ecma/Statements/12.2-1.js new file mode 100644 index 0000000000..d6f3b97f6d --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Statements/12.2-1.js @@ -0,0 +1,74 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '12.2-1.js'; + +/** + File Name: 12.2-1.js + ECMA Section: The variable statement + Description: + + If the variable statement occurs inside a FunctionDeclaration, the + variables are defined with function-local scope in that function, as + described in section 10.1.3. Otherwise, they are defined with global + scope, that is, they are created as members of the global object, as + described in section 0. Variables are created when the execution scope + is entered. A Block does not define a new execution scope. Only Program and + FunctionDeclaration produce a new scope. Variables are initialized to the + undefined value when created. A variable with an Initializer is assigned + the value of its AssignmentExpression when the VariableStatement is executed, + not when the variable is created. + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + +var SECTION = "12.2-1"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "The variable statement"; + +writeHeaderToLog( SECTION +" "+ TITLE); + +new TestCase( "SECTION", + "var x = 3; function f() { var a = x; var x = 23; return a; }; f()", + void 0, + eval("var x = 3; function f() { var a = x; var x = 23; return a; }; f()") ); + +test(); + diff --git a/tests/auto/qml/parserstress/tests/ecma/Statements/12.5-1.js b/tests/auto/qml/parserstress/tests/ecma/Statements/12.5-1.js new file mode 100644 index 0000000000..0745428c4a --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Statements/12.5-1.js @@ -0,0 +1,102 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '12.5-1.js'; + +/** + File Name: 12.5-1.js + ECMA Section: The if statement + Description: + + The production IfStatement : if ( Expression ) Statement else Statement + is evaluated as follows: + + 1.Evaluate Expression. + 2.Call GetValue(Result(1)). + 3.Call ToBoolean(Result(2)). + 4.If Result(3) is false, go to step 7. + 5.Evaluate the first Statement. + 6.Return Result(5). + 7.Evaluate the second Statement. + 8.Return Result(7). + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + + +var SECTION = "12.5-1"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "The if statement"; + +writeHeaderToLog( SECTION + " "+ TITLE); + + +new TestCase( SECTION, + "var MYVAR; if ( true ) MYVAR='PASSED'; else MYVAR= 'FAILED';", + "PASSED", + eval("var MYVAR; if ( true ) MYVAR='PASSED'; else MYVAR= 'FAILED';") ); + +new TestCase( SECTION, + "var MYVAR; if ( false ) MYVAR='FAILED'; else MYVAR= 'PASSED';", + "PASSED", + eval("var MYVAR; if ( false ) MYVAR='FAILED'; else MYVAR= 'PASSED';") ); + +new TestCase( SECTION, + "var MYVAR; if ( new Boolean(true) ) MYVAR='PASSED'; else MYVAR= 'FAILED';", + "PASSED", + eval("var MYVAR; if ( new Boolean(true) ) MYVAR='PASSED'; else MYVAR= 'FAILED';") ); + +new TestCase( SECTION, + "var MYVAR; if ( new Boolean(false) ) MYVAR='PASSED'; else MYVAR= 'FAILED';", + "PASSED", + eval("var MYVAR; if ( new Boolean(false) ) MYVAR='PASSED'; else MYVAR= 'FAILED';") ); + +new TestCase( SECTION, + "var MYVAR; if ( 1 ) MYVAR='PASSED'; else MYVAR= 'FAILED';", + "PASSED", + eval("var MYVAR; if ( 1 ) MYVAR='PASSED'; else MYVAR= 'FAILED';") ); + +new TestCase( SECTION, + "var MYVAR; if ( 0 ) MYVAR='FAILED'; else MYVAR= 'PASSED';", + "PASSED", + eval("var MYVAR; if ( 0 ) MYVAR='FAILED'; else MYVAR= 'PASSED';") ); + +test(); + diff --git a/tests/auto/qml/parserstress/tests/ecma/Statements/12.5-2.js b/tests/auto/qml/parserstress/tests/ecma/Statements/12.5-2.js new file mode 100644 index 0000000000..143edb0705 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Statements/12.5-2.js @@ -0,0 +1,99 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '12.5-2.js'; + +/** + File Name: 12.5-2.js + ECMA Section: The if statement + Description: + + The production IfStatement : if ( Expression ) Statement else Statement + is evaluated as follows: + + 1.Evaluate Expression. + 2.Call GetValue(Result(1)). + 3.Call ToBoolean(Result(2)). + 4.If Result(3) is false, go to step 7. + 5.Evaluate the first Statement. + 6.Return Result(5). + 7.Evaluate the second Statement. + 8.Return Result(7). + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + +var SECTION = "12.5-2"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "The if statement" ; + +writeHeaderToLog( SECTION + " "+ TITLE); + +new TestCase( SECTION, + "var MYVAR; if ( true ) MYVAR='PASSED'; MYVAR", + "PASSED", + eval("var MYVAR; if ( true ) MYVAR='PASSED'; MYVAR") ); + +new TestCase( SECTION, + "var MYVAR; if ( false ) MYVAR='FAILED'; MYVAR;", + "PASSED", + eval("var MYVAR=\"PASSED\"; if ( false ) MYVAR='FAILED'; MYVAR;") ); + +new TestCase( SECTION, + "var MYVAR; if ( new Boolean(true) ) MYVAR='PASSED'; MYVAR", + "PASSED", + eval("var MYVAR; if ( new Boolean(true) ) MYVAR='PASSED'; MYVAR") ); + +new TestCase( SECTION, + "var MYVAR; if ( new Boolean(false) ) MYVAR='PASSED'; MYVAR", + "PASSED", + eval("var MYVAR; if ( new Boolean(false) ) MYVAR='PASSED'; MYVAR") ); + +new TestCase( SECTION, + "var MYVAR; if ( 1 ) MYVAR='PASSED'; MYVAR", + "PASSED", + eval("var MYVAR; if ( 1 ) MYVAR='PASSED'; MYVAR") ); + +new TestCase( SECTION, + "var MYVAR; if ( 0 ) MYVAR='FAILED'; MYVAR;", + "PASSED", + eval("var MYVAR=\"PASSED\"; if ( 0 ) MYVAR='FAILED'; MYVAR;") ); + +test(); diff --git a/tests/auto/qml/parserstress/tests/ecma/Statements/12.6.1-1.js b/tests/auto/qml/parserstress/tests/ecma/Statements/12.6.1-1.js new file mode 100644 index 0000000000..97b9afaa82 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Statements/12.6.1-1.js @@ -0,0 +1,74 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '12.6.1-1.js'; + +/** + File Name: 12.6.1-1.js + ECMA Section: The while statement + Description: + + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + +var SECTION = "12.6.1-1"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "The While statement"; +writeHeaderToLog( SECTION + " "+ TITLE); + + +new TestCase( SECTION, + "var MYVAR = 0; while( MYVAR++ < 100) { if ( MYVAR < 100 ) break; } MYVAR ", + 1, + eval("var MYVAR = 0; while( MYVAR++ < 100) { if ( MYVAR < 100 ) break; } MYVAR ")); + +new TestCase( SECTION, + "var MYVAR = 0; while( MYVAR++ < 100) { if ( MYVAR < 100 ) continue; else break; } MYVAR ", + 100, + eval("var MYVAR = 0; while( MYVAR++ < 100) { if ( MYVAR < 100 ) continue; else break; } MYVAR ")); + +new TestCase( SECTION, + "function MYFUN( arg1 ) { while ( arg1++ < 100 ) { if ( arg1 < 100 ) return arg1; } }; MYFUN(1)", + 2, + eval("function MYFUN( arg1 ) { while ( arg1++ < 100 ) { if ( arg1 < 100 ) return arg1; } }; MYFUN(1)")); + +test(); + diff --git a/tests/auto/qml/parserstress/tests/ecma/Statements/12.6.2-1.js b/tests/auto/qml/parserstress/tests/ecma/Statements/12.6.2-1.js new file mode 100644 index 0000000000..2ef9378f5a --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Statements/12.6.2-1.js @@ -0,0 +1,75 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '12.6.2-1.js'; + +/** + File Name: 12.6.2-1.js + ECMA Section: 12.6.2 The for Statement + + 1. first expression is not present. + 2. second expression is not present + 3. third expression is not present + + + Author: christine@netscape.com + Date: 15 september 1997 +*/ + +var SECTION = "12.6.2-1"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "The for statement"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +new TestCase( "12.6.2-1", "for statement", 99, testprogram() ); + +test(); + + +function testprogram() { + myVar = 0; + + for ( ; ; ) { + if ( ++myVar == 99 ) + break; + } + + return myVar; +} diff --git a/tests/auto/qml/parserstress/tests/ecma/Statements/12.6.2-2.js b/tests/auto/qml/parserstress/tests/ecma/Statements/12.6.2-2.js new file mode 100644 index 0000000000..cc8676cd29 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Statements/12.6.2-2.js @@ -0,0 +1,76 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '12.6.2-2.js'; + +/** + File Name: 12.6.2-2.js + ECMA Section: 12.6.2 The for Statement + + 1. first expression is not present. + 2. second expression is not present + 3. third expression is present + + + Author: christine@netscape.com + Date: 15 september 1997 +*/ +var SECTION = "12.6.2-2"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "The for statement"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +new TestCase( SECTION, "for statement", 99, testprogram() ); + +test(); + +function testprogram() { + myVar = 0; + + for ( ; ; myVar++ ) { + if ( myVar < 99 ) { + continue; + } else { + break; + } + } + + return myVar; +} diff --git a/tests/auto/qml/parserstress/tests/ecma/Statements/12.6.2-3.js b/tests/auto/qml/parserstress/tests/ecma/Statements/12.6.2-3.js new file mode 100644 index 0000000000..a16b7aa18e --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Statements/12.6.2-3.js @@ -0,0 +1,72 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '12.6.2-3.js'; + +/** + File Name: 12.6.2-3.js + ECMA Section: 12.6.2 The for Statement + + 1. first expression is not present. + 2. second expression is present + 3. third expression is present + + + Author: christine@netscape.com + Date: 15 september 1997 +*/ +var SECTION = "12.6.2-3"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "The for statement"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +new TestCase( SECTION, "for statement", 100, testprogram() ); + +test(); + +function testprogram() { + myVar = 0; + + for ( ; myVar < 100 ; myVar++ ) { + continue; + } + + return myVar; +} diff --git a/tests/auto/qml/parserstress/tests/ecma/Statements/12.6.2-4.js b/tests/auto/qml/parserstress/tests/ecma/Statements/12.6.2-4.js new file mode 100644 index 0000000000..6b1500d3a4 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Statements/12.6.2-4.js @@ -0,0 +1,72 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '12.6.2-4.js'; + +/** + File Name: 12.6.2-4.js + ECMA Section: 12.6.2 The for Statement + + 1. first expression is not present. + 2. second expression is present + 3. third expression is present + + + Author: christine@netscape.com + Date: 15 september 1997 +*/ + +var SECTION = "12.6.2-4"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "The for statement"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +new TestCase( SECTION, "for statement", 100, testprogram() ); + +test(); + +function testprogram() { + myVar = 0; + + for ( ; myVar < 100 ; myVar++ ) { + } + + return myVar; +} diff --git a/tests/auto/qml/parserstress/tests/ecma/Statements/12.6.2-5.js b/tests/auto/qml/parserstress/tests/ecma/Statements/12.6.2-5.js new file mode 100644 index 0000000000..a6f86ecc88 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Statements/12.6.2-5.js @@ -0,0 +1,73 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '12.6.2-5.js'; + +/** + File Name: 12.6.2-5.js + ECMA Section: 12.6.2 The for Statement + + 1. first expression is not present. + 2. second expression is present + 3. third expression is present + + + Author: christine@netscape.com + Date: 15 september 1997 +*/ +var SECTION = "12.6.2-5"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "The for statement"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +new TestCase( SECTION, "for statement", 99, testprogram() ); + +test(); + +function testprogram() { + myVar = 0; + + for ( ; myVar < 100 ; myVar++ ) { + if (myVar == 99) + break; + } + + return myVar; +} diff --git a/tests/auto/qml/parserstress/tests/ecma/Statements/12.6.2-6.js b/tests/auto/qml/parserstress/tests/ecma/Statements/12.6.2-6.js new file mode 100644 index 0000000000..48a4e2e607 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Statements/12.6.2-6.js @@ -0,0 +1,75 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '12.6.2-6.js'; + +/** + File Name: 12.6.2-6.js + ECMA Section: 12.6.2 The for Statement + + 1. first expression is present. + 2. second expression is not present + 3. third expression is present + + + Author: christine@netscape.com + Date: 15 september 1997 +*/ +var SECTION = "12.6.2-6"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "The for statement"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +new TestCase( "12.6.2-6", "for statement", 256, testprogram() ); + +test(); + +function testprogram() { + var myVar; + + for ( myVar=2; ; myVar *= myVar ) { + + if (myVar > 100) + break; + continue; + } + + return myVar; +} diff --git a/tests/auto/qml/parserstress/tests/ecma/Statements/12.6.2-7.js b/tests/auto/qml/parserstress/tests/ecma/Statements/12.6.2-7.js new file mode 100644 index 0000000000..a14ced0497 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Statements/12.6.2-7.js @@ -0,0 +1,73 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '12.6.2-7.js'; + +/** + File Name: 12.6.2-7.js + ECMA Section: 12.6.2 The for Statement + + 1. first expression is present. + 2. second expression is not present + 3. third expression is present + + + Author: christine@netscape.com + Date: 15 september 1997 +*/ +var SECTION = "12.6.2-7"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "The for statement"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +new TestCase( SECTION, "for statement", 256, testprogram() ); + +test(); + +function testprogram() { + var myVar; + + for ( myVar=2; myVar < 100 ; myVar *= myVar ) { + + continue; + } + + return myVar; +} diff --git a/tests/auto/qml/parserstress/tests/ecma/Statements/12.6.2-8.js b/tests/auto/qml/parserstress/tests/ecma/Statements/12.6.2-8.js new file mode 100644 index 0000000000..73d931d838 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Statements/12.6.2-8.js @@ -0,0 +1,71 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '12.6.2-8.js'; + +/** + File Name: 12.6.2-8.js + ECMA Section: 12.6.2 The for Statement + + 1. first expression is present. + 2. second expression is present + 3. third expression is present + + + Author: christine@netscape.com + Date: 15 september 1997 +*/ +var SECTION = "12.6.2-8"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "The for statement"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +new TestCase( SECTION, "for statement", 256, testprogram() ); + +test(); + +function testprogram() { + var myVar; + + for ( myVar=2; myVar < 256; myVar *= myVar ) { + } + + return myVar; +} diff --git a/tests/auto/qml/parserstress/tests/ecma/Statements/12.6.2-9-n.js b/tests/auto/qml/parserstress/tests/ecma/Statements/12.6.2-9-n.js new file mode 100644 index 0000000000..3e2f942a22 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Statements/12.6.2-9-n.js @@ -0,0 +1,76 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '12.6.2-9-n.js'; + +/** + File Name: 12.6.2-9-n.js + ECMA Section: 12.6.2 The for Statement + + 1. first expression is not present. + 2. second expression is not present + 3. third expression is not present + + + Author: christine@netscape.com + Date: 15 september 1997 +*/ + + +var SECTION = "12.6.2-9-n"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "The for statement"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +DESCRIPTION = "for (i)"; +EXPECTED = "error"; + +new TestCase( SECTION, + "for (i)", + "error", + eval("for (i) { }") ); + +/* + for (i) { + } + +*/ +test(); + diff --git a/tests/auto/qml/parserstress/tests/ecma/Statements/12.6.3-1.js b/tests/auto/qml/parserstress/tests/ecma/Statements/12.6.3-1.js new file mode 100644 index 0000000000..6e23b84a48 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Statements/12.6.3-1.js @@ -0,0 +1,63 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '12.6.3-1.js'; + +/** + File Name: 12.6.3-1.js + ECMA Section: 12.6.3 The for...in Statement + Description: + + Author: christine@netscape.com + Date: 11 september 1997 +*/ + +var SECTION = "12.6.3-1"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "The for..in statement"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +new TestCase( SECTION, + "var x; Number.prototype.foo = 34; for ( j in 7 ) x = j; x", + "foo", + eval("var x; Number.prototype.foo = 34; for ( j in 7 ){x = j;} x") ); + +test(); + diff --git a/tests/auto/qml/parserstress/tests/ecma/Statements/12.6.3-10.js b/tests/auto/qml/parserstress/tests/ecma/Statements/12.6.3-10.js new file mode 100644 index 0000000000..0e74f14ece --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Statements/12.6.3-10.js @@ -0,0 +1,115 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '12.6.3-10.js'; + +/** + File Name: 12.6.3-10.js + ECMA Section: 12.6.3 The for...in Statement + Description: + The production IterationStatement : for ( LeftHandSideExpression in Expression ) + Statement is evaluated as follows: + + 1. Evaluate the Expression. + 2. Call GetValue(Result(1)). + 3. Call ToObject(Result(2)). + 4. Let C be "normal completion". + 5. Get the name of the next property of Result(3) that doesn't have the + DontEnum attribute. If there is no such property, go to step 14. + 6. Evaluate the LeftHandSideExpression (it may be evaluated repeatedly). + 7. Call PutValue(Result(6), Result(5)). PutValue( V, W ): + 1. If Type(V) is not Reference, generate a runtime error. + 2. Call GetBase(V). + 3. If Result(2) is null, go to step 6. + 4. Call the [[Put]] method of Result(2), passing GetPropertyName(V) + for the property name and W for the value. + 5. Return. + 6. Call the [[Put]] method for the global object, passing + GetPropertyName(V) for the property name and W for the value. + 7. Return. + 8. Evaluate Statement. + 9. If Result(8) is a value completion, change C to be "normal completion + after value V" where V is the value carried by Result(8). + 10. If Result(8) is a break completion, go to step 14. + 11. If Result(8) is a continue completion, go to step 5. + 12. If Result(8) is a return completion, return Result(8). + 13. Go to step 5. + 14. Return C. + + Author: christine@netscape.com + Date: 11 september 1997 +*/ +var SECTION = "12.6.3-10"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "The for..in statement"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +// for ( LeftHandSideExpression in Expression ) +// LeftHandSideExpression:NewExpression:MemberExpression + +var count = 0; +function f() { count++; return new Array("h","e","l","l","o"); } + +var result = ""; +for ( p in f() ) { result += f()[p] }; + +new TestCase( SECTION, + "count = 0; result = \"\"; "+ + "function f() { count++; return new Array(\"h\",\"e\",\"l\",\"l\",\"o\"); }"+ + "for ( p in f() ) { result += f()[p] }; count", + 6, + count ); + +new TestCase( SECTION, + "result", + "hello", + result ); + +// LeftHandSideExpression:NewExpression:MemberExpression [ Expression ] +// LeftHandSideExpression:NewExpression:MemberExpression . Identifier +// LeftHandSideExpression:NewExpression:new MemberExpression Arguments +// LeftHandSideExpression:NewExpression:PrimaryExpression:( Expression ) +// LeftHandSideExpression:CallExpression:MemberExpression Arguments +// LeftHandSideExpression:CallExpression Arguments +// LeftHandSideExpression:CallExpression [ Expression ] +// LeftHandSideExpression:CallExpression . Identifier + +test(); + diff --git a/tests/auto/qml/parserstress/tests/ecma/Statements/12.6.3-11.js b/tests/auto/qml/parserstress/tests/ecma/Statements/12.6.3-11.js new file mode 100644 index 0000000000..efc65ee14e --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Statements/12.6.3-11.js @@ -0,0 +1,98 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '12.6.3-11.js'; + +/** + File Name: 12.6.3-11.js + ECMA Section: 12.6.3 The for...in Statement + Description: + The production IterationStatement : for ( LeftHandSideExpression in Expression ) + Statement is evaluated as follows: + + 1. Evaluate the Expression. + 2. Call GetValue(Result(1)). + 3. Call ToObject(Result(2)). + 4. Let C be "normal completion". + 5. Get the name of the next property of Result(3) that doesn't have the + DontEnum attribute. If there is no such property, go to step 14. + 6. Evaluate the LeftHandSideExpression (it may be evaluated repeatedly). + 7. Call PutValue(Result(6), Result(5)). PutValue( V, W ): + 1. If Type(V) is not Reference, generate a runtime error. + 2. Call GetBase(V). + 3. If Result(2) is null, go to step 6. + 4. Call the [[Put]] method of Result(2), passing GetPropertyName(V) + for the property name and W for the value. + 5. Return. + 6. Call the [[Put]] method for the global object, passing + GetPropertyName(V) for the property name and W for the value. + 7. Return. + 8. Evaluate Statement. + 9. If Result(8) is a value completion, change C to be "normal completion + after value V" where V is the value carried by Result(8). + 10. If Result(8) is a break completion, go to step 14. + 11. If Result(8) is a continue completion, go to step 5. + 12. If Result(8) is a return completion, return Result(8). + 13. Go to step 5. + 14. Return C. + + Author: christine@netscape.com + Date: 11 september 1997 +*/ +var SECTION = "12.6.3-11"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "The for..in statement"; + +writeHeaderToLog( SECTION + " "+ TITLE); + + +// 5. Get the name of the next property of Result(3) that doesn't have the +// DontEnum attribute. If there is no such property, go to step 14. + +var result = ""; + +for ( p in Number ) { result += String(p) }; + +new TestCase( SECTION, + "result = \"\"; for ( p in Number ) { result += String(p) };", + "", + result ); + +test(); + diff --git a/tests/auto/qml/parserstress/tests/ecma/Statements/12.6.3-12.js b/tests/auto/qml/parserstress/tests/ecma/Statements/12.6.3-12.js new file mode 100644 index 0000000000..840ca9da65 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Statements/12.6.3-12.js @@ -0,0 +1,103 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '12.6.3-12.js'; + +/** + File Name: 12.6.3-12.js + ECMA Section: 12.6.3 The for...in Statement + Description: + + This is a regression test for http://bugzilla.mozilla.org/show_bug.cgi?id=9802. + + The production IterationStatement : for ( LeftHandSideExpression in Expression ) + Statement is evaluated as follows: + + 1. Evaluate the Expression. + 2. Call GetValue(Result(1)). + 3. Call ToObject(Result(2)). + 4. Let C be "normal completion". + 5. Get the name of the next property of Result(3) that doesn't have the + DontEnum attribute. If there is no such property, go to step 14. + 6. Evaluate the LeftHandSideExpression (it may be evaluated repeatedly). + 7. Call PutValue(Result(6), Result(5)). PutValue( V, W ): + 1. If Type(V) is not Reference, generate a runtime error. + 2. Call GetBase(V). + 3. If Result(2) is null, go to step 6. + 4. Call the [[Put]] method of Result(2), passing GetPropertyName(V) + for the property name and W for the value. + 5. Return. + 6. Call the [[Put]] method for the global object, passing + GetPropertyName(V) for the property name and W for the value. + 7. Return. + 8. Evaluate Statement. + 9. If Result(8) is a value completion, change C to be "normal completion + after value V" where V is the value carried by Result(8). + 10. If Result(8) is a break completion, go to step 14. + 11. If Result(8) is a continue completion, go to step 5. + 12. If Result(8) is a return completion, return Result(8). + 13. Go to step 5. + 14. Return C. + + Author: christine@netscape.com + Date: 11 september 1997 +*/ +var SECTION = "12.6.3-12"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "The for..in statement"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +var result = "PASSED"; + +for ( aVar in this ) { + if (aVar == "aVar") { + result = "FAILED" + } +}; + +new TestCase( + SECTION, + "var result=''; for ( aVar in this ) { " + + "if (aVar == 'aVar') {return a failure}; result", + "PASSED", + result ); + +test(); + diff --git a/tests/auto/qml/parserstress/tests/ecma/Statements/12.6.3-19.js b/tests/auto/qml/parserstress/tests/ecma/Statements/12.6.3-19.js new file mode 100644 index 0000000000..5acbee7127 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Statements/12.6.3-19.js @@ -0,0 +1,117 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '12.6.3-19.js'; + +/** + File Name: 12.6.3-1.js + ECMA Section: 12.6.3 The for...in Statement + Description: + The production IterationStatement : for ( LeftHandSideExpression in Expression ) + Statement is evaluated as follows: + + 1. Evaluate the Expression. + 2. Call GetValue(Result(1)). + 3. Call ToObject(Result(2)). + 4. Let C be "normal completion". + 5. Get the name of the next property of Result(3) that doesn't have the + DontEnum attribute. If there is no such property, go to step 14. + 6. Evaluate the LeftHandSideExpression (it may be evaluated repeatedly). + 7. Call PutValue(Result(6), Result(5)). PutValue( V, W ): + 1. If Type(V) is not Reference, generate a runtime error. + 2. Call GetBase(V). + 3. If Result(2) is null, go to step 6. + 4. Call the [[Put]] method of Result(2), passing GetPropertyName(V) + for the property name and W for the value. + 5. Return. + 6. Call the [[Put]] method for the global object, passing + GetPropertyName(V) for the property name and W for the value. + 7. Return. + 8. Evaluate Statement. + 9. If Result(8) is a value completion, change C to be "normal completion + after value V" where V is the value carried by Result(8). + 10. If Result(8) is a break completion, go to step 14. + 11. If Result(8) is a continue completion, go to step 5. + 12. If Result(8) is a return completion, return Result(8). + 13. Go to step 5. + 14. Return C. + + Author: christine@netscape.com + Date: 11 september 1997 +*/ +var SECTION = "12.6.3-4"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "The for..in statement"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +// for ( LeftHandSideExpression in Expression ) +// LeftHandSideExpression:NewExpression:MemberExpression + +var count = 0; +function f() { count++; return new Array("h","e","l","l","o"); } + +var result = ""; +for ( p in f() ) { result += f()[p] }; + +new TestCase( SECTION, + "count = 0; result = \"\"; "+ + "function f() { count++; return new Array(\"h\",\"e\",\"l\",\"l\",\"o\"); }"+ + "for ( p in f() ) { result += f()[p] }; count", + 6, + count ); + +new TestCase( SECTION, + "result", + "hello", + result ); + + + +// LeftHandSideExpression:NewExpression:MemberExpression [ Expression ] +// LeftHandSideExpression:NewExpression:MemberExpression . Identifier +// LeftHandSideExpression:NewExpression:new MemberExpression Arguments +// LeftHandSideExpression:NewExpression:PrimaryExpression:( Expression ) +// LeftHandSideExpression:CallExpression:MemberExpression Arguments +// LeftHandSideExpression:CallExpression Arguments +// LeftHandSideExpression:CallExpression [ Expression ] +// LeftHandSideExpression:CallExpression . Identifier + +test(); + diff --git a/tests/auto/qml/parserstress/tests/ecma/Statements/12.6.3-2.js b/tests/auto/qml/parserstress/tests/ecma/Statements/12.6.3-2.js new file mode 100644 index 0000000000..3ed93dc9a1 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Statements/12.6.3-2.js @@ -0,0 +1,63 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '12.6.3-2.js'; + +/** + File Name: 12.6.3-2.js + ECMA Section: 12.6.3 The for...in Statement + Description: Check the Boolean Object + + + Author: christine@netscape.com + Date: 11 september 1997 +*/ + +var SECTION = "12.6.3-2"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "The for..in statement"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +new TestCase( SECTION, + "Boolean.prototype.foo = 34; for ( j in Boolean ) Boolean[j]", + 34, + eval("Boolean.prototype.foo = 34; for ( j in Boolean ) Boolean[j] ") ); + +test(); diff --git a/tests/auto/qml/parserstress/tests/ecma/Statements/12.6.3-3.js b/tests/auto/qml/parserstress/tests/ecma/Statements/12.6.3-3.js new file mode 100644 index 0000000000..f52569bba2 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Statements/12.6.3-3.js @@ -0,0 +1,73 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '12.6.3-3.js'; + +/** + File Name: 12.6.3-3.js + ECMA Section: for..in loops + Description: + + This verifies the fix to + http://scopus.mcom.com/bugsplat/show_bug.cgi?id=112156 + for..in should take general lvalue for first argument + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + +var SECTION = "12.6.3-3"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "The for..in statement"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +var o = {}; + +var result = ""; + +for ( o.a in [1,2,3] ) { result += String( [1,2,3][o.a] ); } + +new TestCase( SECTION, + "for ( o.a in [1,2,3] ) { result += String( [1,2,3][o.a] ); } result", + "123", + result ); + +test(); + diff --git a/tests/auto/qml/parserstress/tests/ecma/Statements/12.6.3-4.js b/tests/auto/qml/parserstress/tests/ecma/Statements/12.6.3-4.js new file mode 100644 index 0000000000..c30641f8bb --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Statements/12.6.3-4.js @@ -0,0 +1,202 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '12.6.3-4.js'; + +/** + File Name: 12.6.3-1.js + ECMA Section: 12.6.3 The for...in Statement + Description: + The production IterationStatement : for ( LeftHandSideExpression in Expression ) + Statement is evaluated as follows: + + 1. Evaluate the Expression. + 2. Call GetValue(Result(1)). + 3. Call ToObject(Result(2)). + 4. Let C be "normal completion". + 5. Get the name of the next property of Result(3) that doesn't have the + DontEnum attribute. If there is no such property, go to step 14. + 6. Evaluate the LeftHandSideExpression (it may be evaluated repeatedly). + 7. Call PutValue(Result(6), Result(5)). PutValue( V, W ): + 1. If Type(V) is not Reference, generate a runtime error. + 2. Call GetBase(V). + 3. If Result(2) is null, go to step 6. + 4. Call the [[Put]] method of Result(2), passing GetPropertyName(V) + for the property name and W for the value. + 5. Return. + 6. Call the [[Put]] method for the global object, passing + GetPropertyName(V) for the property name and W for the value. + 7. Return. + 8. Evaluate Statement. + 9. If Result(8) is a value completion, change C to be "normal completion + after value V" where V is the value carried by Result(8). + 10. If Result(8) is a break completion, go to step 14. + 11. If Result(8) is a continue completion, go to step 5. + 12. If Result(8) is a return completion, return Result(8). + 13. Go to step 5. + 14. Return C. + + Author: christine@netscape.com + Date: 11 september 1997 +*/ +var SECTION = "12.6.3-4"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "The for..in statement"; +var BUGNUMBER="http://scopus.mcom.com/bugsplat/show_bug.cgi?id=344855"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +// for ( LeftHandSideExpression in Expression ) +// LeftHandSideExpression:NewExpression:MemberExpression + +var o = new MyObject(); +var result = 0; + +for ( MyObject in o ) { + result += o[MyObject]; +} + +new TestCase( SECTION, + "for ( MyObject in o ) { result += o[MyObject] }", + 6, + result ); + +var result = 0; + +for ( value in o ) { + result += o[value]; +} + +new TestCase( SECTION, + "for ( value in o ) { result += o[value]", + 6, + result ); + +var value = "value"; +var result = 0; +for ( value in o ) { + result += o[value]; +} + +new TestCase( SECTION, + "value = \"value\"; for ( value in o ) { result += o[value]", + 6, + result ); + +var value = 0; +var result = 0; +for ( value in o ) { + result += o[value]; +} + +new TestCase( SECTION, + "value = 0; for ( value in o ) { result += o[value]", + 6, + result ); + +// this causes a segv + +var ob = { 0:"hello" }; +var result = 0; +for ( ob[0] in o ) { + result += o[ob[0]]; +} + +new TestCase( SECTION, + "ob = { 0:\"hello\" }; for ( ob[0] in o ) { result += o[ob[0]]", + 6, + result ); + +var result = 0; +for ( ob["0"] in o ) { + result += o[ob["0"]]; +} + +new TestCase( SECTION, + "value = 0; for ( ob[\"0\"] in o ) { result += o[o[\"0\"]]", + 6, + result ); + +var result = 0; +var ob = { value:"hello" }; +for ( ob[value] in o ) { + result += o[ob[value]]; +} + +new TestCase( SECTION, + "ob = { 0:\"hello\" }; for ( ob[value] in o ) { result += o[ob[value]]", + 6, + result ); + +var result = 0; +for ( ob["value"] in o ) { + result += o[ob["value"]]; +} + +new TestCase( SECTION, + "value = 0; for ( ob[\"value\"] in o ) { result += o[ob[\"value\"]]", + 6, + result ); + +var result = 0; +for ( ob.value in o ) { + result += o[ob.value]; +} + +new TestCase( SECTION, + "value = 0; for ( ob.value in o ) { result += o[ob.value]", + 6, + result ); + +// LeftHandSideExpression:NewExpression:MemberExpression [ Expression ] +// LeftHandSideExpression:NewExpression:MemberExpression . Identifier +// LeftHandSideExpression:NewExpression:new MemberExpression Arguments +// LeftHandSideExpression:NewExpression:PrimaryExpression:( Expression ) +// LeftHandSideExpression:CallExpression:MemberExpression Arguments +// LeftHandSideExpression:CallExpression Arguments +// LeftHandSideExpression:CallExpression [ Expression ] +// LeftHandSideExpression:CallExpression . Identifier + +test(); + +function MyObject() { + this.value = 2; + this[0] = 4; + return this; +} diff --git a/tests/auto/qml/parserstress/tests/ecma/Statements/12.6.3-5-n.js b/tests/auto/qml/parserstress/tests/ecma/Statements/12.6.3-5-n.js new file mode 100644 index 0000000000..295d059c39 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Statements/12.6.3-5-n.js @@ -0,0 +1,110 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '12.6.3-5-n.js'; + +/** + File Name: 12.6.3-1.js + ECMA Section: 12.6.3 The for...in Statement + Description: + The production IterationStatement : for ( LeftHandSideExpression in Expression ) + Statement is evaluated as follows: + + 1. Evaluate the Expression. + 2. Call GetValue(Result(1)). + 3. Call ToObject(Result(2)). + 4. Let C be "normal completion". + 5. Get the name of the next property of Result(3) that doesn't have the + DontEnum attribute. If there is no such property, go to step 14. + 6. Evaluate the LeftHandSideExpression ( it may be evaluated repeatedly). + 7. Call PutValue(Result(6), Result(5)). PutValue( V, W ): + 1. If Type(V) is not Reference, generate a runtime error. + 2. Call GetBase(V). + 3. If Result(2) is null, go to step 6. + 4. Call the [[Put]] method of Result(2), passing GetPropertyName(V) + for the property name and W for the value. + 5. Return. + 6. Call the [[Put]] method for the global object, passing + GetPropertyName(V) for the property name and W for the value. + 7. Return. + 8. Evaluate Statement. + 9. If Result(8) is a value completion, change C to be "normal completion + after value V" where V is the value carried by Result(8). + 10. If Result(8) is a break completion, go to step 14. + 11. If Result(8) is a continue completion, go to step 5. + 12. If Result(8) is a return completion, return Result(8). + 13. Go to step 5. + 14. Return C. + + Author: christine@netscape.com + Date: 11 september 1997 +*/ +var SECTION = "12.6.3-4"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "The for..in statement"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +// for ( LeftHandSideExpression in Expression ) +// LeftHandSideExpression:NewExpression:MemberExpression + +DESCRIPTION = "more than one member expression"; +EXPECTED = "error"; + +new TestCase( SECTION, + "more than one member expression", + "error", + eval("var o = new MyObject(); var result = 0; for ( var i, p in this) { result += this[p]; }") ); + +/* + var o = new MyObject(); + var result = 0; + + for ( var i, p in this) { + result += this[p]; + } +*/ + +test(); + +function MyObject() { + this.value = 2; + this[0] = 4; + return this; +} diff --git a/tests/auto/qml/parserstress/tests/ecma/Statements/12.6.3-6-n.js b/tests/auto/qml/parserstress/tests/ecma/Statements/12.6.3-6-n.js new file mode 100644 index 0000000000..8cb4c7f638 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Statements/12.6.3-6-n.js @@ -0,0 +1,109 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '12.6.3-6-n.js'; + +/** + File Name: 12.6.3-1.js + ECMA Section: 12.6.3 The for...in Statement + Description: + The production IterationStatement : for ( LeftHandSideExpression in Expression ) + Statement is evaluated as follows: + + 1. Evaluate the Expression. + 2. Call GetValue(Result(1)). + 3. Call ToObject(Result(2)). + 4. Let C be "normal completion". + 5. Get the name of the next property of Result(3) that doesn't have the + DontEnum attribute. If there is no such property, go to step 14. + 6. Evaluate the LeftHandSideExpression ( it may be evaluated repeatedly). + 7. Call PutValue(Result(6), Result(5)). PutValue( V, W ): + 1. If Type(V) is not Reference, generate a runtime error. + 2. Call GetBase(V). + 3. If Result(2) is null, go to step 6. + 4. Call the [[Put]] method of Result(2), passing GetPropertyName(V) + for the property name and W for the value. + 5. Return. + 6. Call the [[Put]] method for the global object, passing + GetPropertyName(V) for the property name and W for the value. + 7. Return. + 8. Evaluate Statement. + 9. If Result(8) is a value completion, change C to be "normal completion + after value V" where V is the value carried by Result(8). + 10. If Result(8) is a break completion, go to step 14. + 11. If Result(8) is a continue completion, go to step 5. + 12. If Result(8) is a return completion, return Result(8). + 13. Go to step 5. + 14. Return C. + + Author: christine@netscape.com + Date: 11 september 1997 +*/ +var SECTION = "12.6.3-4"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "The for..in statement"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +// for ( LeftHandSideExpression in Expression ) +// LeftHandSideExpression:NewExpression:MemberExpression + +DESCRIPTION = "bad left-hand side expression"; +EXPECTED = "error"; + +new TestCase( SECTION, + "bad left-hand side expression", + "error", + eval("var o = new MyObject(); var result = 0; for ( this in o) { result += this[p]; }") ); +/* + var o = new MyObject(); + var result = 0; + + for ( this in o) { + result += this[p]; + } +*/ + +test(); + +function MyObject() { + this.value = 2; + this[0] = 4; + return this; +} diff --git a/tests/auto/qml/parserstress/tests/ecma/Statements/12.6.3-7-n.js b/tests/auto/qml/parserstress/tests/ecma/Statements/12.6.3-7-n.js new file mode 100644 index 0000000000..871dd474cb --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Statements/12.6.3-7-n.js @@ -0,0 +1,110 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '12.6.3-7-n.js'; + +/** + File Name: 12.6.3-1.js + ECMA Section: 12.6.3 The for...in Statement + Description: + The production IterationStatement : for ( LeftHandSideExpression in Expression ) + Statement is evaluated as follows: + + 1. Evaluate the Expression. + 2. Call GetValue(Result(1)). + 3. Call ToObject(Result(2)). + 4. Let C be "normal completion". + 5. Get the name of the next property of Result(3) that doesn't have the + DontEnum attribute. If there is no such property, go to step 14. + 6. Evaluate the LeftHandSideExpression ( it may be evaluated repeatedly). + 7. Call PutValue(Result(6), Result(5)). PutValue( V, W ): + 1. If Type(V) is not Reference, generate a runtime error. + 2. Call GetBase(V). + 3. If Result(2) is null, go to step 6. + 4. Call the [[Put]] method of Result(2), passing GetPropertyName(V) + for the property name and W for the value. + 5. Return. + 6. Call the [[Put]] method for the global object, passing + GetPropertyName(V) for the property name and W for the value. + 7. Return. + 8. Evaluate Statement. + 9. If Result(8) is a value completion, change C to be "normal completion + after value V" where V is the value carried by Result(8). + 10. If Result(8) is a break completion, go to step 14. + 11. If Result(8) is a continue completion, go to step 5. + 12. If Result(8) is a return completion, return Result(8). + 13. Go to step 5. + 14. Return C. + + Author: christine@netscape.com + Date: 11 september 1997 +*/ +var SECTION = "12.6.3-4"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "The for..in statement"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +// for ( LeftHandSideExpression in Expression ) +// LeftHandSideExpression:NewExpression:MemberExpression + +DESCRIPTION = "bad left-hand side expression"; +EXPECTED = "error"; + +new TestCase( SECTION, + "bad left-hand side expression", + "error", + eval("var o = new MyObject(); var result = 0; for ( \"a\" in o) { result += this[p]; } ") ); + +/* + var o = new MyObject(); + var result = 0; + + for ( "a" in o) { + result += this[p]; + } +*/ + +test(); + +function MyObject() { + this.value = 2; + this[0] = 4; + return this; +} diff --git a/tests/auto/qml/parserstress/tests/ecma/Statements/12.6.3-8-n.js b/tests/auto/qml/parserstress/tests/ecma/Statements/12.6.3-8-n.js new file mode 100644 index 0000000000..b75a7b5f37 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Statements/12.6.3-8-n.js @@ -0,0 +1,110 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '12.6.3-8-n.js'; + +/** + File Name: 12.6.3-8-n.js + ECMA Section: 12.6.3 The for...in Statement + Description: + The production IterationStatement : for ( LeftHandSideExpression in Expression ) + Statement is evaluated as follows: + + 1. Evaluate the Expression. + 2. Call GetValue(Result(1)). + 3. Call ToObject(Result(2)). + 4. Let C be "normal completion". + 5. Get the name of the next property of Result(3) that doesn't have the + DontEnum attribute. If there is no such property, go to step 14. + 6. Evaluate the LeftHandSideExpression ( it may be evaluated repeatedly). + 7. Call PutValue(Result(6), Result(5)). PutValue( V, W ): + 1. If Type(V) is not Reference, generate a runtime error. + 2. Call GetBase(V). + 3. If Result(2) is null, go to step 6. + 4. Call the [[Put]] method of Result(2), passing GetPropertyName(V) + for the property name and W for the value. + 5. Return. + 6. Call the [[Put]] method for the global object, passing + GetPropertyName(V) for the property name and W for the value. + 7. Return. + 8. Evaluate Statement. + 9. If Result(8) is a value completion, change C to be "normal completion + after value V" where V is the value carried by Result(8). + 10. If Result(8) is a break completion, go to step 14. + 11. If Result(8) is a continue completion, go to step 5. + 12. If Result(8) is a return completion, return Result(8). + 13. Go to step 5. + 14. Return C. + + Author: christine@netscape.com + Date: 11 september 1997 +*/ +var SECTION = "12.6.3-4"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "The for..in statement"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +// for ( LeftHandSideExpression in Expression ) +// LeftHandSideExpression:NewExpression:MemberExpression + +DESCRIPTION = "bad left-hand side expression"; +EXPECTED = "error"; + +new TestCase( SECTION, + "bad left-hand side expression", + "error", + eval("var o = new MyObject(); var result = 0; for ( 1 in o) { result += this[p]; } ") ); + +/* + var o = new MyObject(); + var result = 0; + + for ( 1 in o) { + result += this[p]; + } +*/ + +test(); + +function MyObject() { + this.value = 2; + this[0] = 4; + return this; +} diff --git a/tests/auto/qml/parserstress/tests/ecma/Statements/12.6.3-9-n.js b/tests/auto/qml/parserstress/tests/ecma/Statements/12.6.3-9-n.js new file mode 100644 index 0000000000..f83a8ed65a --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Statements/12.6.3-9-n.js @@ -0,0 +1,109 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '12.6.3-9-n.js'; + +/** + File Name: 12.6.3-9-n.js + ECMA Section: 12.6.3 The for...in Statement + Description: + The production IterationStatement : for ( LeftHandSideExpression in Expression ) + Statement is evaluated as follows: + + 1. Evaluate the Expression. + 2. Call GetValue(Result(1)). + 3. Call ToObject(Result(2)). + 4. Let C be "normal completion". + 5. Get the name of the next property of Result(3) that doesn't have the + DontEnum attribute. If there is no such property, go to step 14. + 6. Evaluate the LeftHandSideExpression ( it may be evaluated repeatedly). + 7. Call PutValue(Result(6), Result(5)). PutValue( V, W ): + 1. If Type(V) is not Reference, generate a runtime error. + 2. Call GetBase(V). + 3. If Result(2) is null, go to step 6. + 4. Call the [[Put]] method of Result(2), passing GetPropertyName(V) + for the property name and W for the value. + 5. Return. + 6. Call the [[Put]] method for the global object, passing + GetPropertyName(V) for the property name and W for the value. + 7. Return. + 8. Evaluate Statement. + 9. If Result(8) is a value completion, change C to be "normal completion + after value V" where V is the value carried by Result(8). + 10. If Result(8) is a break completion, go to step 14. + 11. If Result(8) is a continue completion, go to step 5. + 12. If Result(8) is a return completion, return Result(8). + 13. Go to step 5. + 14. Return C. + + Author: christine@netscape.com + Date: 11 september 1997 +*/ +var SECTION = "12.6.3-9-n"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "The for..in statement"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +// for ( LeftHandSideExpression in Expression ) +// LeftHandSideExpression:NewExpression:MemberExpression + +DESCRIPTION = "object is not defined"; +EXPECTED = "error"; + +new TestCase( SECTION, + "object is not defined", + "error", + eval("var o = new MyObject(); var result = 0; for ( var o in foo) { result += this[o]; } ") ); +/* + var o = new MyObject(); + var result = 0; + + for ( var o in foo) { + result += this[o]; + } +*/ + +test(); + +function MyObject() { + this.value = 2; + this[0] = 4; + return this; +} diff --git a/tests/auto/qml/parserstress/tests/ecma/Statements/12.7-1-n.js b/tests/auto/qml/parserstress/tests/ecma/Statements/12.7-1-n.js new file mode 100644 index 0000000000..7978f3be56 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Statements/12.7-1-n.js @@ -0,0 +1,64 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '12.7-1-n.js'; + +/** + File Name: 12.7-1-n.js + ECMA Section: 12.7 The continue statement + Description: + + Author: christine@netscape.com + Date: 12 november 1997 +*/ +var SECTION = "12.7.1-n"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "The continue statement"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +DESCRIPTION = "continue"; +EXPECTED = "error"; + +new TestCase( SECTION, + "continue", + "error", + eval("continue") ); + +test(); diff --git a/tests/auto/qml/parserstress/tests/ecma/Statements/12.8-1-n.js b/tests/auto/qml/parserstress/tests/ecma/Statements/12.8-1-n.js new file mode 100644 index 0000000000..29f46cf29e --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Statements/12.8-1-n.js @@ -0,0 +1,67 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '12.8-1-n.js'; + +/** + File Name: 12.8-1-n.js + ECMA Section: 12.8 The break statement + Description: + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + +var SECTION = "12.8-1-n"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "The break in statement"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +DESCRIPTION = "break"; +EXPECTED = "error"; + +new TestCase( SECTION, + "break", + "error", + eval("break") ); + + +test(); + diff --git a/tests/auto/qml/parserstress/tests/ecma/Statements/12.9-1-n.js b/tests/auto/qml/parserstress/tests/ecma/Statements/12.9-1-n.js new file mode 100644 index 0000000000..450cb66593 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Statements/12.9-1-n.js @@ -0,0 +1,63 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '12.9-1-n.js'; + +/** + File Name: 12.9-1-n.js + ECMA Section: 12.9 The return statement + Description: + + Author: christine@netscape.com + Date: 12 november 1997 +*/ +var SECTION = "12.9-1-n"; +var VERSION = "ECMA_1"; +startTest(); + +writeHeaderToLog( SECTION + " The return statement"); + +DESCRIPTION = "return"; +EXPECTED = "error"; + +new TestCase( SECTION, + "return", + "error", + eval("return") ); + +test(); diff --git a/tests/auto/qml/parserstress/tests/ecma/Statements/browser.js b/tests/auto/qml/parserstress/tests/ecma/Statements/browser.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/auto/qml/parserstress/tests/ecma/Statements/shell.js b/tests/auto/qml/parserstress/tests/ecma/Statements/shell.js new file mode 100644 index 0000000000..7346f697a5 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Statements/shell.js @@ -0,0 +1 @@ +gTestsubsuite = 'Statements'; diff --git a/tests/auto/qml/parserstress/tests/ecma/String/15.5.1.js b/tests/auto/qml/parserstress/tests/ecma/String/15.5.1.js new file mode 100644 index 0000000000..cf7ab8b420 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/String/15.5.1.js @@ -0,0 +1,134 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.5.1.js'; + +/** + File Name: 15.5.1.js + ECMA Section: 15.5.1 The String Constructor called as a Function + 15.5.1.1 String(value) + 15.5.1.2 String() + + Description: When String is called as a function rather than as + a constructor, it performs a type conversion. + - String(value) returns a string value (not a String + object) computed by ToString(value) + - String() returns the empty string "" + + Author: christine@netscape.com + Date: 1 october 1997 +*/ + +var SECTION = "15.5.1"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "The String Constructor Called as a Function"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +new TestCase( SECTION, "String('string primitive')", "string primitive", String('string primitive') ); +new TestCase( SECTION, "String(void 0)", "undefined", String( void 0) ); +new TestCase( SECTION, "String(null)", "null", String( null ) ); +new TestCase( SECTION, "String(true)", "true", String( true) ); +new TestCase( SECTION, "String(false)", "false", String( false ) ); +new TestCase( SECTION, "String(Boolean(true))", "true", String(Boolean(true)) ); +new TestCase( SECTION, "String(Boolean(false))", "false", String(Boolean(false)) ); +new TestCase( SECTION, "String(Boolean())", "false", String(Boolean(false)) ); +new TestCase( SECTION, "String(new Array())", "", String( new Array()) ); +new TestCase( SECTION, "String(new Array(1,2,3))", "1,2,3", String( new Array(1,2,3)) ); + + +new TestCase( SECTION, "String( Number.NaN )", "NaN", String( Number.NaN ) ); +new TestCase( SECTION, "String( 0 )", "0", String( 0 ) ); +new TestCase( SECTION, "String( -0 )", "0", String( -0 ) ); +new TestCase( SECTION, "String( Number.POSITIVE_INFINITY )", "Infinity", String( Number.POSITIVE_INFINITY ) ); +new TestCase( SECTION, "String( Number.NEGATIVE_INFINITY )", "-Infinity", String( Number.NEGATIVE_INFINITY ) ); +new TestCase( SECTION, "String( -1 )", "-1", String( -1 ) ); + +// cases in step 6: integers 1e21 > x >= 1 or -1 >= x > -1e21 + +new TestCase( SECTION, "String( 1 )", "1", String( 1 ) ); +new TestCase( SECTION, "String( 10 )", "10", String( 10 ) ); +new TestCase( SECTION, "String( 100 )", "100", String( 100 ) ); +new TestCase( SECTION, "String( 1000 )", "1000", String( 1000 ) ); +new TestCase( SECTION, "String( 10000 )", "10000", String( 10000 ) ); +new TestCase( SECTION, "String( 10000000000 )", "10000000000", String( 10000000000 ) ); +new TestCase( SECTION, "String( 10000000000000000000 )", "10000000000000000000", String( 10000000000000000000 ) ); +new TestCase( SECTION, "String( 100000000000000000000 )","100000000000000000000",String( 100000000000000000000 ) ); + +new TestCase( SECTION, "String( 12345 )", "12345", String( 12345 ) ); +new TestCase( SECTION, "String( 1234567890 )", "1234567890", String( 1234567890 ) ); + +new TestCase( SECTION, "String( -1 )", "-1", String( -1 ) ); +new TestCase( SECTION, "String( -10 )", "-10", String( -10 ) ); +new TestCase( SECTION, "String( -100 )", "-100", String( -100 ) ); +new TestCase( SECTION, "String( -1000 )", "-1000", String( -1000 ) ); +new TestCase( SECTION, "String( -1000000000 )", "-1000000000", String( -1000000000 ) ); +new TestCase( SECTION, "String( -1000000000000000 )", "-1000000000000000", String( -1000000000000000 ) ); +new TestCase( SECTION, "String( -100000000000000000000 )", "-100000000000000000000", String( -100000000000000000000 ) ); +new TestCase( SECTION, "String( -1000000000000000000000 )", "-1e+21", String( -1000000000000000000000 ) ); + +new TestCase( SECTION, "String( -12345 )", "-12345", String( -12345 ) ); +new TestCase( SECTION, "String( -1234567890 )", "-1234567890", String( -1234567890 ) ); + +// cases in step 7: numbers with a fractional component, 1e21> x >1 or -1 > x > -1e21, +new TestCase( SECTION, "String( 1.0000001 )", "1.0000001", String( 1.0000001 ) ); + + +// cases in step 8: fractions between 1 > x > -1, exclusive of 0 and -0 + +// cases in step 9: numbers with 1 significant digit >= 1e+21 or <= 1e-6 + +new TestCase( SECTION, "String( 1000000000000000000000 )", "1e+21", String( 1000000000000000000000 ) ); +new TestCase( SECTION, "String( 10000000000000000000000 )", "1e+22", String( 10000000000000000000000 ) ); + +// cases in step 10: numbers with more than 1 significant digit >= 1e+21 or <= 1e-6 +new TestCase( SECTION, "String( 1.2345 )", "1.2345", String( 1.2345)); +new TestCase( SECTION, "String( 1.234567890 )", "1.23456789", String( 1.234567890 )); + +new TestCase( SECTION, "String( .12345 )", "0.12345", String(.12345 ) ); +new TestCase( SECTION, "String( .012345 )", "0.012345", String(.012345) ); +new TestCase( SECTION, "String( .0012345 )", "0.0012345", String(.0012345) ); +new TestCase( SECTION, "String( .00012345 )", "0.00012345", String(.00012345) ); +new TestCase( SECTION, "String( .000012345 )", "0.000012345", String(.000012345) ); +new TestCase( SECTION, "String( .0000012345 )", "0.0000012345", String(.0000012345) ); +new TestCase( SECTION, "String( .00000012345 )", "1.2345e-7", String(.00000012345)); + +new TestCase( "15.5.2", "String()", "", String() ); + +test(); diff --git a/tests/auto/qml/parserstress/tests/ecma/String/15.5.2.js b/tests/auto/qml/parserstress/tests/ecma/String/15.5.2.js new file mode 100644 index 0000000000..062d31cdc2 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/String/15.5.2.js @@ -0,0 +1,110 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.5.2.js'; + +/** + File Name: 15.5.2.js + ECMA Section: 15.5.2 The String Constructor + 15.5.2.1 new String(value) + 15.5.2.2 new String() + + Description: When String is called as part of a new expression, it + is a constructor; it initializes the newly constructed + object. + + - The prototype property of the newly constructed + object is set to the original String prototype object, + the one that is the intial value of String.prototype + - The internal [[Class]] property of the object is "String" + - The value of the object is ToString(value). + - If no value is specified, its value is the empty string. + + Author: christine@netscape.com + Date: 1 october 1997 +*/ + +var SECTION = "15.5.2"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "The String Constructor"; + +writeHeaderToLog( SECTION + " "+ TITLE); + + +new TestCase( SECTION, "typeof new String('string primitive')", "object", typeof new String('string primitive') ); +new TestCase( SECTION, "var TESTSTRING = new String('string primitive'); TESTSTRING.toString=Object.prototype.toString;TESTSTRING.toString()", "[object String]", eval("var TESTSTRING = new String('string primitive'); TESTSTRING.toString=Object.prototype.toString;TESTSTRING.toString()") ); +new TestCase( SECTION, "(new String('string primitive')).valueOf()", 'string primitive', (new String('string primitive')).valueOf() ); +new TestCase( SECTION, "(new String('string primitive')).substring", String.prototype.substring, (new String('string primitive')).substring ); + +new TestCase( SECTION, "typeof new String(void 0)", "object", typeof new String(void 0) ); +new TestCase( SECTION, "var TESTSTRING = new String(void 0); TESTSTRING.toString=Object.prototype.toString;TESTSTRING.toString()", "[object String]", eval("var TESTSTRING = new String(void 0); TESTSTRING.toString=Object.prototype.toString;TESTSTRING.toString()") ); +new TestCase( SECTION, "(new String(void 0)).valueOf()", "undefined", (new String(void 0)).valueOf() ); +new TestCase( SECTION, "(new String(void 0)).toString", String.prototype.toString, (new String(void 0)).toString ); + +new TestCase( SECTION, "typeof new String(null)", "object", typeof new String(null) ); +new TestCase( SECTION, "var TESTSTRING = new String(null); TESTSTRING.toString=Object.prototype.toString;TESTSTRING.toString()", "[object String]", eval("var TESTSTRING = new String(null); TESTSTRING.toString=Object.prototype.toString;TESTSTRING.toString()") ); +new TestCase( SECTION, "(new String(null)).valueOf()", "null", (new String(null)).valueOf() ); +new TestCase( SECTION, "(new String(null)).valueOf", String.prototype.valueOf, (new String(null)).valueOf ); + +new TestCase( SECTION, "typeof new String(true)", "object", typeof new String(true) ); +new TestCase( SECTION, "var TESTSTRING = new String(true); TESTSTRING.toString=Object.prototype.toString;TESTSTRING.toString()", "[object String]", eval("var TESTSTRING = new String(true); TESTSTRING.toString=Object.prototype.toString;TESTSTRING.toString()") ); +new TestCase( SECTION, "(new String(true)).valueOf()", "true", (new String(true)).valueOf() ); +new TestCase( SECTION, "(new String(true)).charAt", String.prototype.charAt, (new String(true)).charAt ); + +new TestCase( SECTION, "typeof new String(false)", "object", typeof new String(false) ); +new TestCase( SECTION, "var TESTSTRING = new String(false); TESTSTRING.toString=Object.prototype.toString;TESTSTRING.toString()", "[object String]", eval("var TESTSTRING = new String(false); TESTSTRING.toString=Object.prototype.toString;TESTSTRING.toString()") ); +new TestCase( SECTION, "(new String(false)).valueOf()", "false", (new String(false)).valueOf() ); +new TestCase( SECTION, "(new String(false)).charCodeAt", String.prototype.charCodeAt, (new String(false)).charCodeAt ); + +new TestCase( SECTION, "typeof new String(new Boolean(true))", "object", typeof new String(new Boolean(true)) ); +new TestCase( SECTION, "var TESTSTRING = new String(new Boolean(true)); TESTSTRING.toString=Object.prototype.toString;TESTSTRING.toString()", "[object String]", eval("var TESTSTRING = new String(new Boolean(true)); TESTSTRING.toString=Object.prototype.toString;TESTSTRING.toString()") ); +new TestCase( SECTION, "(new String(new Boolean(true))).valueOf()", "true", (new String(new Boolean(true))).valueOf() ); +new TestCase( SECTION, "(new String(new Boolean(true))).indexOf", String.prototype.indexOf, (new String(new Boolean(true))).indexOf ); + +new TestCase( SECTION, "typeof new String()", "object", typeof new String() ); +new TestCase( SECTION, "var TESTSTRING = new String(); TESTSTRING.toString=Object.prototype.toString;TESTSTRING.toString()", "[object String]", eval("var TESTSTRING = new String(); TESTSTRING.toString=Object.prototype.toString;TESTSTRING.toString()") ); +new TestCase( SECTION, "(new String()).valueOf()", '', (new String()).valueOf() ); +new TestCase( SECTION, "(new String()).lastIndexOf", String.prototype.lastIndexOf, (new String()).lastIndexOf ); + +new TestCase( SECTION, "typeof new String('')", "object", typeof new String('') ); +new TestCase( SECTION, "var TESTSTRING = new String(''); TESTSTRING.toString=Object.prototype.toString;TESTSTRING.toString()", "[object String]", eval("var TESTSTRING = new String(''); TESTSTRING.toString=Object.prototype.toString;TESTSTRING.toString()") ); +new TestCase( SECTION, "(new String('')).valueOf()", '', (new String('')).valueOf() ); +new TestCase( SECTION, "(new String('')).split", String.prototype.split, (new String('')).split ); + +test(); diff --git a/tests/auto/qml/parserstress/tests/ecma/String/15.5.3.1-1.js b/tests/auto/qml/parserstress/tests/ecma/String/15.5.3.1-1.js new file mode 100644 index 0000000000..cc62c9ed51 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/String/15.5.3.1-1.js @@ -0,0 +1,71 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.5.3.1-1.js'; + +/** + File Name: 15.5.3.1-1.js + ECMA Section: 15.5.3.1 Properties of the String Constructor + + Description: The initial value of String.prototype is the built-in + String prototype object. + + This property shall have the attributes [ DontEnum, + DontDelete, ReadOnly] + + This tests the DontEnum attribute. + + Author: christine@netscape.com + Date: 1 october 1997 +*/ + +var SECTION = "15.5.3.1-1"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Properties of the String Constructor"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +new TestCase( SECTION, "String.prototype.length", 0, String.prototype.length ); + +new TestCase( SECTION, + "var str='';for ( p in String ) { if ( p == 'prototype' ) str += p; } str", + "", + eval("var str='';for ( p in String ) { if ( p == 'prototype' ) str += p; } str") ); + +test(); diff --git a/tests/auto/qml/parserstress/tests/ecma/String/15.5.3.1-2.js b/tests/auto/qml/parserstress/tests/ecma/String/15.5.3.1-2.js new file mode 100644 index 0000000000..b87137a140 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/String/15.5.3.1-2.js @@ -0,0 +1,69 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.5.3.1-2.js'; + +/** + File Name: 15.5.3.1-2.js + ECMA Section: 15.5.3.1 Properties of the String Constructor + + Description: The initial value of String.prototype is the built-in + String prototype object. + + This property shall have the attributes [ DontEnum, + DontDelete, ReadOnly] + + This tests the ReadOnly attribute. + + Author: christine@netscape.com + Date: 1 october 1997 +*/ + +var SECTION = "15.5.3.1-2"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Properties of the String Constructor"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +new TestCase( SECTION, + "String.prototype=null;String.prototype", + String.prototype, + eval("String.prototype=null;String.prototype") ); + +test(); diff --git a/tests/auto/qml/parserstress/tests/ecma/String/15.5.3.1-3.js b/tests/auto/qml/parserstress/tests/ecma/String/15.5.3.1-3.js new file mode 100644 index 0000000000..f94f83db11 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/String/15.5.3.1-3.js @@ -0,0 +1,66 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.5.3.1-3.js'; + +/** + File Name: 15.5.3.1-3.js + ECMA Section: 15.5.3.1 Properties of the String Constructor + + Description: The initial value of String.prototype is the built-in + String prototype object. + + This property shall have the attributes [ DontEnum, + DontDelete, ReadOnly] + + This tests the DontDelete attribute. + + Author: christine@netscape.com + Date: 1 october 1997 +*/ + +var SECTION = "15.5.3.1-3"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Properties of the String Constructor"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +new TestCase( SECTION, "delete( String.prototype )", false, eval("delete ( String.prototype )") ); + +test(); diff --git a/tests/auto/qml/parserstress/tests/ecma/String/15.5.3.1-4.js b/tests/auto/qml/parserstress/tests/ecma/String/15.5.3.1-4.js new file mode 100644 index 0000000000..af8c1b9560 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/String/15.5.3.1-4.js @@ -0,0 +1,66 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.5.3.1-4.js'; + +/** + File Name: 15.5.3.1-4.js + ECMA Section: 15.5.3.1 Properties of the String Constructor + + Description: The initial value of String.prototype is the built-in + String prototype object. + + This property shall have the attributes [ DontEnum, + DontDelete, ReadOnly] + + This tests the DontDelete attribute. + + Author: christine@netscape.com + Date: 1 october 1997 +*/ + +var SECTION = "15.5.3.1-4"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Properties of the String Constructor"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +new TestCase( SECTION, "delete( String.prototype );String.prototype", String.prototype, eval("delete ( String.prototype );String.prototype") ); + +test(); diff --git a/tests/auto/qml/parserstress/tests/ecma/String/15.5.3.2-1.js b/tests/auto/qml/parserstress/tests/ecma/String/15.5.3.2-1.js new file mode 100644 index 0000000000..17e715bca0 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/String/15.5.3.2-1.js @@ -0,0 +1,190 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.5.3.2-1.js'; + +/** + File Name: 15.5.3.2-1.js + ECMA Section: 15.5.3.2 String.fromCharCode( char0, char1, ... ) + Description: Return a string value containing as many characters + as the number of arguments. Each argument specifies + one character of the resulting string, with the first + argument specifying the first character, and so on, + from left to right. An argument is converted to a + character by applying the operation ToUint16 and + regarding the resulting 16bit integeras the Unicode + encoding of a character. If no arguments are supplied, + the result is the empty string. + + This test covers Basic Latin (range U+0020 - U+007F) + + Author: christine@netscape.com + Date: 2 october 1997 +*/ + +var SECTION = "15.5.3.2-1"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "String.fromCharCode()"; + +new TestCase( SECTION, "typeof String.fromCharCode", "function", typeof String.fromCharCode ); +new TestCase( SECTION, "typeof String.prototype.fromCharCode", "undefined", typeof String.prototype.fromCharCode ); +new TestCase( SECTION, "var x = new String(); typeof x.fromCharCode", "undefined", eval("var x = new String(); typeof x.fromCharCode") ); +new TestCase( SECTION, "String.fromCharCode.length", 1, String.fromCharCode.length ); + +new TestCase( SECTION, "String.fromCharCode()", "", String.fromCharCode() ); +new TestCase( SECTION, "String.fromCharCode(0x0020)", " ", String.fromCharCode(0x0020) ); +new TestCase( SECTION, "String.fromCharCode(0x0021)", "!", String.fromCharCode(0x0021) ); +new TestCase( SECTION, "String.fromCharCode(0x0022)", "\"", String.fromCharCode(0x0022) ); +new TestCase( SECTION, "String.fromCharCode(0x0023)", "#", String.fromCharCode(0x0023) ); +new TestCase( SECTION, "String.fromCharCode(0x0024)", "$", String.fromCharCode(0x0024) ); +new TestCase( SECTION, "String.fromCharCode(0x0025)", "%", String.fromCharCode(0x0025) ); +new TestCase( SECTION, "String.fromCharCode(0x0026)", "&", String.fromCharCode(0x0026) ); +new TestCase( SECTION, "String.fromCharCode(0x0027)", "\'", String.fromCharCode(0x0027) ); +new TestCase( SECTION, "String.fromCharCode(0x0028)", "(", String.fromCharCode(0x0028) ); +new TestCase( SECTION, "String.fromCharCode(0x0029)", ")", String.fromCharCode(0x0029) ); +new TestCase( SECTION, "String.fromCharCode(0x002A)", "*", String.fromCharCode(0x002A) ); +new TestCase( SECTION, "String.fromCharCode(0x002B)", "+", String.fromCharCode(0x002B) ); +new TestCase( SECTION, "String.fromCharCode(0x002C)", ",", String.fromCharCode(0x002C) ); +new TestCase( SECTION, "String.fromCharCode(0x002D)", "-", String.fromCharCode(0x002D) ); +new TestCase( SECTION, "String.fromCharCode(0x002E)", ".", String.fromCharCode(0x002E) ); +new TestCase( SECTION, "String.fromCharCode(0x002F)", "/", String.fromCharCode(0x002F) ); + +new TestCase( SECTION, "String.fromCharCode(0x0030)", "0", String.fromCharCode(0x0030) ); +new TestCase( SECTION, "String.fromCharCode(0x0031)", "1", String.fromCharCode(0x0031) ); +new TestCase( SECTION, "String.fromCharCode(0x0032)", "2", String.fromCharCode(0x0032) ); +new TestCase( SECTION, "String.fromCharCode(0x0033)", "3", String.fromCharCode(0x0033) ); +new TestCase( SECTION, "String.fromCharCode(0x0034)", "4", String.fromCharCode(0x0034) ); +new TestCase( SECTION, "String.fromCharCode(0x0035)", "5", String.fromCharCode(0x0035) ); +new TestCase( SECTION, "String.fromCharCode(0x0036)", "6", String.fromCharCode(0x0036) ); +new TestCase( SECTION, "String.fromCharCode(0x0037)", "7", String.fromCharCode(0x0037) ); +new TestCase( SECTION, "String.fromCharCode(0x0038)", "8", String.fromCharCode(0x0038) ); +new TestCase( SECTION, "String.fromCharCode(0x0039)", "9", String.fromCharCode(0x0039) ); +new TestCase( SECTION, "String.fromCharCode(0x003A)", ":", String.fromCharCode(0x003A) ); +new TestCase( SECTION, "String.fromCharCode(0x003B)", ";", String.fromCharCode(0x003B) ); +new TestCase( SECTION, "String.fromCharCode(0x003C)", "<", String.fromCharCode(0x003C) ); +new TestCase( SECTION, "String.fromCharCode(0x003D)", "=", String.fromCharCode(0x003D) ); +new TestCase( SECTION, "String.fromCharCode(0x003E)", ">", String.fromCharCode(0x003E) ); +new TestCase( SECTION, "String.fromCharCode(0x003F)", "?", String.fromCharCode(0x003F) ); + +new TestCase( SECTION, "String.fromCharCode(0x0040)", "@", String.fromCharCode(0x0040) ); +new TestCase( SECTION, "String.fromCharCode(0x0041)", "A", String.fromCharCode(0x0041) ); +new TestCase( SECTION, "String.fromCharCode(0x0042)", "B", String.fromCharCode(0x0042) ); +new TestCase( SECTION, "String.fromCharCode(0x0043)", "C", String.fromCharCode(0x0043) ); +new TestCase( SECTION, "String.fromCharCode(0x0044)", "D", String.fromCharCode(0x0044) ); +new TestCase( SECTION, "String.fromCharCode(0x0045)", "E", String.fromCharCode(0x0045) ); +new TestCase( SECTION, "String.fromCharCode(0x0046)", "F", String.fromCharCode(0x0046) ); +new TestCase( SECTION, "String.fromCharCode(0x0047)", "G", String.fromCharCode(0x0047) ); +new TestCase( SECTION, "String.fromCharCode(0x0048)", "H", String.fromCharCode(0x0048) ); +new TestCase( SECTION, "String.fromCharCode(0x0049)", "I", String.fromCharCode(0x0049) ); +new TestCase( SECTION, "String.fromCharCode(0x004A)", "J", String.fromCharCode(0x004A) ); +new TestCase( SECTION, "String.fromCharCode(0x004B)", "K", String.fromCharCode(0x004B) ); +new TestCase( SECTION, "String.fromCharCode(0x004C)", "L", String.fromCharCode(0x004C) ); +new TestCase( SECTION, "String.fromCharCode(0x004D)", "M", String.fromCharCode(0x004D) ); +new TestCase( SECTION, "String.fromCharCode(0x004E)", "N", String.fromCharCode(0x004E) ); +new TestCase( SECTION, "String.fromCharCode(0x004F)", "O", String.fromCharCode(0x004F) ); + +new TestCase( SECTION, "String.fromCharCode(0x0040)", "@", String.fromCharCode(0x0040) ); +new TestCase( SECTION, "String.fromCharCode(0x0041)", "A", String.fromCharCode(0x0041) ); +new TestCase( SECTION, "String.fromCharCode(0x0042)", "B", String.fromCharCode(0x0042) ); +new TestCase( SECTION, "String.fromCharCode(0x0043)", "C", String.fromCharCode(0x0043) ); +new TestCase( SECTION, "String.fromCharCode(0x0044)", "D", String.fromCharCode(0x0044) ); +new TestCase( SECTION, "String.fromCharCode(0x0045)", "E", String.fromCharCode(0x0045) ); +new TestCase( SECTION, "String.fromCharCode(0x0046)", "F", String.fromCharCode(0x0046) ); +new TestCase( SECTION, "String.fromCharCode(0x0047)", "G", String.fromCharCode(0x0047) ); +new TestCase( SECTION, "String.fromCharCode(0x0048)", "H", String.fromCharCode(0x0048) ); +new TestCase( SECTION, "String.fromCharCode(0x0049)", "I", String.fromCharCode(0x0049) ); +new TestCase( SECTION, "String.fromCharCode(0x004A)", "J", String.fromCharCode(0x004A) ); +new TestCase( SECTION, "String.fromCharCode(0x004B)", "K", String.fromCharCode(0x004B) ); +new TestCase( SECTION, "String.fromCharCode(0x004C)", "L", String.fromCharCode(0x004C) ); +new TestCase( SECTION, "String.fromCharCode(0x004D)", "M", String.fromCharCode(0x004D) ); +new TestCase( SECTION, "String.fromCharCode(0x004E)", "N", String.fromCharCode(0x004E) ); +new TestCase( SECTION, "String.fromCharCode(0x004F)", "O", String.fromCharCode(0x004F) ); + +new TestCase( SECTION, "String.fromCharCode(0x0050)", "P", String.fromCharCode(0x0050) ); +new TestCase( SECTION, "String.fromCharCode(0x0051)", "Q", String.fromCharCode(0x0051) ); +new TestCase( SECTION, "String.fromCharCode(0x0052)", "R", String.fromCharCode(0x0052) ); +new TestCase( SECTION, "String.fromCharCode(0x0053)", "S", String.fromCharCode(0x0053) ); +new TestCase( SECTION, "String.fromCharCode(0x0054)", "T", String.fromCharCode(0x0054) ); +new TestCase( SECTION, "String.fromCharCode(0x0055)", "U", String.fromCharCode(0x0055) ); +new TestCase( SECTION, "String.fromCharCode(0x0056)", "V", String.fromCharCode(0x0056) ); +new TestCase( SECTION, "String.fromCharCode(0x0057)", "W", String.fromCharCode(0x0057) ); +new TestCase( SECTION, "String.fromCharCode(0x0058)", "X", String.fromCharCode(0x0058) ); +new TestCase( SECTION, "String.fromCharCode(0x0059)", "Y", String.fromCharCode(0x0059) ); +new TestCase( SECTION, "String.fromCharCode(0x005A)", "Z", String.fromCharCode(0x005A) ); +new TestCase( SECTION, "String.fromCharCode(0x005B)", "[", String.fromCharCode(0x005B) ); +new TestCase( SECTION, "String.fromCharCode(0x005C)", "\\", String.fromCharCode(0x005C) ); +new TestCase( SECTION, "String.fromCharCode(0x005D)", "]", String.fromCharCode(0x005D) ); +new TestCase( SECTION, "String.fromCharCode(0x005E)", "^", String.fromCharCode(0x005E) ); +new TestCase( SECTION, "String.fromCharCode(0x005F)", "_", String.fromCharCode(0x005F) ); + +new TestCase( SECTION, "String.fromCharCode(0x0060)", "`", String.fromCharCode(0x0060) ); +new TestCase( SECTION, "String.fromCharCode(0x0061)", "a", String.fromCharCode(0x0061) ); +new TestCase( SECTION, "String.fromCharCode(0x0062)", "b", String.fromCharCode(0x0062) ); +new TestCase( SECTION, "String.fromCharCode(0x0063)", "c", String.fromCharCode(0x0063) ); +new TestCase( SECTION, "String.fromCharCode(0x0064)", "d", String.fromCharCode(0x0064) ); +new TestCase( SECTION, "String.fromCharCode(0x0065)", "e", String.fromCharCode(0x0065) ); +new TestCase( SECTION, "String.fromCharCode(0x0066)", "f", String.fromCharCode(0x0066) ); +new TestCase( SECTION, "String.fromCharCode(0x0067)", "g", String.fromCharCode(0x0067) ); +new TestCase( SECTION, "String.fromCharCode(0x0068)", "h", String.fromCharCode(0x0068) ); +new TestCase( SECTION, "String.fromCharCode(0x0069)", "i", String.fromCharCode(0x0069) ); +new TestCase( SECTION, "String.fromCharCode(0x006A)", "j", String.fromCharCode(0x006A) ); +new TestCase( SECTION, "String.fromCharCode(0x006B)", "k", String.fromCharCode(0x006B) ); +new TestCase( SECTION, "String.fromCharCode(0x006C)", "l", String.fromCharCode(0x006C) ); +new TestCase( SECTION, "String.fromCharCode(0x006D)", "m", String.fromCharCode(0x006D) ); +new TestCase( SECTION, "String.fromCharCode(0x006E)", "n", String.fromCharCode(0x006E) ); +new TestCase( SECTION, "String.fromCharCode(0x006F)", "o", String.fromCharCode(0x006F) ); + +new TestCase( SECTION, "String.fromCharCode(0x0070)", "p", String.fromCharCode(0x0070) ); +new TestCase( SECTION, "String.fromCharCode(0x0071)", "q", String.fromCharCode(0x0071) ); +new TestCase( SECTION, "String.fromCharCode(0x0072)", "r", String.fromCharCode(0x0072) ); +new TestCase( SECTION, "String.fromCharCode(0x0073)", "s", String.fromCharCode(0x0073) ); +new TestCase( SECTION, "String.fromCharCode(0x0074)", "t", String.fromCharCode(0x0074) ); +new TestCase( SECTION, "String.fromCharCode(0x0075)", "u", String.fromCharCode(0x0075) ); +new TestCase( SECTION, "String.fromCharCode(0x0076)", "v", String.fromCharCode(0x0076) ); +new TestCase( SECTION, "String.fromCharCode(0x0077)", "w", String.fromCharCode(0x0077) ); +new TestCase( SECTION, "String.fromCharCode(0x0078)", "x", String.fromCharCode(0x0078) ); +new TestCase( SECTION, "String.fromCharCode(0x0079)", "y", String.fromCharCode(0x0079) ); +new TestCase( SECTION, "String.fromCharCode(0x007A)", "z", String.fromCharCode(0x007A) ); +new TestCase( SECTION, "String.fromCharCode(0x007B)", "{", String.fromCharCode(0x007B) ); +new TestCase( SECTION, "String.fromCharCode(0x007C)", "|", String.fromCharCode(0x007C) ); +new TestCase( SECTION, "String.fromCharCode(0x007D)", "}", String.fromCharCode(0x007D) ); +new TestCase( SECTION, "String.fromCharCode(0x007E)", "~", String.fromCharCode(0x007E) ); +// new TestCase( SECTION, "String.fromCharCode(0x0020, 0x007F)", "", String.fromCharCode(0x0040, 0x007F) ); + +test(); diff --git a/tests/auto/qml/parserstress/tests/ecma/String/15.5.3.2-2.js b/tests/auto/qml/parserstress/tests/ecma/String/15.5.3.2-2.js new file mode 100644 index 0000000000..563623e6e3 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/String/15.5.3.2-2.js @@ -0,0 +1,77 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.5.3.2-2.js'; + +/** + File Name: 15.5.3.2-2.js + ECMA Section: 15.5.3.2 String.fromCharCode( char0, char1, ... ) + Description: Return a string value containing as many characters + as the number of arguments. Each argument specifies + one character of the resulting string, with the first + argument specifying the first character, and so on, + from left to right. An argument is converted to a + character by applying the operation ToUint16 and + regarding the resulting 16bit integeras the Unicode + encoding of a character. If no arguments are supplied, + the result is the empty string. + + This tests String.fromCharCode with multiple arguments. + + Author: christine@netscape.com + Date: 2 october 1997 +*/ + +var SECTION = "15.5.3.2-2"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "String.fromCharCode()"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +new TestCase( SECTION, + "var MYSTRING = String.fromCharCode(eval(\"var args=''; for ( i = 0x0020; i < 0x007f; i++ ) { args += ( i == 0x007e ) ? i : i + ', '; } args;\")); MYSTRING", + " !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~", + eval( "var MYSTRING = String.fromCharCode(" + eval("var args=''; for ( i = 0x0020; i < 0x007f; i++ ) { args += ( i == 0x007e ) ? i : i + ', '; } args;") +"); MYSTRING" )); + +new TestCase( SECTION, + "MYSTRING.length", + 0x007f - 0x0020, + MYSTRING.length ); + +test(); diff --git a/tests/auto/qml/parserstress/tests/ecma/String/15.5.3.2-3.js b/tests/auto/qml/parserstress/tests/ecma/String/15.5.3.2-3.js new file mode 100644 index 0000000000..ae41742be2 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/String/15.5.3.2-3.js @@ -0,0 +1,121 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.5.3.2-3.js'; + +/** + File Name: 15.5.3.2-1.js + ECMA Section: 15.5.3.2 String.fromCharCode( char0, char1, ... ) + Description: Return a string value containing as many characters + as the number of arguments. Each argument specifies + one character of the resulting string, with the first + argument specifying the first character, and so on, + from left to right. An argument is converted to a + character by applying the operation ToUint16 and + regarding the resulting 16bit integeras the Unicode + encoding of a character. If no arguments are supplied, + the result is the empty string. + + This test covers Basic Latin (range U+0020 - U+007F) + + Author: christine@netscape.com + Date: 2 october 1997 +*/ + +var SECTION = "15.5.3.2-3"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "String.fromCharCode()"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +for ( CHARCODE = 0; CHARCODE < 256; CHARCODE++ ) { + new TestCase( SECTION, + "(String.fromCharCode(" + CHARCODE +")).charCodeAt(0)", + ToUint16(CHARCODE), + (String.fromCharCode(CHARCODE)).charCodeAt(0) + ); +} +for ( CHARCODE = 256; CHARCODE < 65536; CHARCODE+=333 ) { + new TestCase( SECTION, + "(String.fromCharCode(" + CHARCODE +")).charCodeAt(0)", + ToUint16(CHARCODE), + (String.fromCharCode(CHARCODE)).charCodeAt(0) + ); +} +for ( CHARCODE = 65535; CHARCODE < 65538; CHARCODE++ ) { + new TestCase( SECTION, + "(String.fromCharCode(" + CHARCODE +")).charCodeAt(0)", + ToUint16(CHARCODE), + (String.fromCharCode(CHARCODE)).charCodeAt(0) + ); +} +for ( CHARCODE = Math.pow(2,32)-1; CHARCODE < Math.pow(2,32)+1; CHARCODE++ ) { + new TestCase( SECTION, + "(String.fromCharCode(" + CHARCODE +")).charCodeAt(0)", + ToUint16(CHARCODE), + (String.fromCharCode(CHARCODE)).charCodeAt(0) + ); +} +for ( CHARCODE = 0; CHARCODE > -65536; CHARCODE-=3333 ) { + new TestCase( SECTION, + "(String.fromCharCode(" + CHARCODE +")).charCodeAt(0)", + ToUint16(CHARCODE), + (String.fromCharCode(CHARCODE)).charCodeAt(0) + ); +} +new TestCase( SECTION, "(String.fromCharCode(65535)).charCodeAt(0)", 65535, (String.fromCharCode(65535)).charCodeAt(0) ); +new TestCase( SECTION, "(String.fromCharCode(65536)).charCodeAt(0)", 0, (String.fromCharCode(65536)).charCodeAt(0) ); +new TestCase( SECTION, "(String.fromCharCode(65537)).charCodeAt(0)", 1, (String.fromCharCode(65537)).charCodeAt(0) ); + +test(); + +function ToUint16( num ) { + num = Number( num ); + if ( isNaN( num ) || num == 0 || num == Number.POSITIVE_INFINITY || num == Number.NEGATIVE_INFINITY ) { + return 0; + } + + var sign = ( num < 0 ) ? -1 : 1; + + num = sign * Math.floor( Math.abs( num ) ); + num = num % Math.pow(2,16); + num = ( num > -65536 && num < 0) ? 65536 + num : num; + return num; +} + diff --git a/tests/auto/qml/parserstress/tests/ecma/String/15.5.3.js b/tests/auto/qml/parserstress/tests/ecma/String/15.5.3.js new file mode 100644 index 0000000000..5370484568 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/String/15.5.3.js @@ -0,0 +1,66 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.5.3.js'; + +/** + File Name: 15.5.3.1.js + ECMA Section: 15.5.3 Properties of the String Constructor + + Description: The value of the internal [[Prototype]] property of + the String constructor is the Function prototype + object. + + In addition to the internal [[Call]] and [[Construct]] + properties, the String constructor also has the length + property, as well as properties described in 15.5.3.1 + and 15.5.3.2. + + Author: christine@netscape.com + Date: 1 october 1997 +*/ + +var SECTION = "15.5.3"; +var VERSION = "ECMA_2"; +startTest(); +var passed = true; +writeHeaderToLog( SECTION + " Properties of the String Constructor" ); + +new TestCase( SECTION, "String.length", 1, String.length ); + +test(); diff --git a/tests/auto/qml/parserstress/tests/ecma/String/15.5.4.1.js b/tests/auto/qml/parserstress/tests/ecma/String/15.5.4.1.js new file mode 100644 index 0000000000..ae8e12463d --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/String/15.5.4.1.js @@ -0,0 +1,63 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.5.4.1.js'; + +/** + File Name: 15.5.4.1.js + ECMA Section: 15.5.4.1 String.prototype.constructor + + Description: + Author: christine@netscape.com + Date: 28 october 1997 + +*/ +var SECTION = "15.5.4.1"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "String.prototype.constructor"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +new TestCase( SECTION, "String.prototype.constructor == String", true, String.prototype.constructor == String ); + +new TestCase( SECTION, "var STRING = new String.prototype.constructor('hi'); STRING.getClass = Object.prototype.toString; STRING.getClass()", + "[object String]", + eval("var STRING = new String.prototype.constructor('hi'); STRING.getClass = Object.prototype.toString; STRING.getClass()") ); + +test(); diff --git a/tests/auto/qml/parserstress/tests/ecma/String/15.5.4.10-1.js b/tests/auto/qml/parserstress/tests/ecma/String/15.5.4.10-1.js new file mode 100644 index 0000000000..2647d18cb2 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/String/15.5.4.10-1.js @@ -0,0 +1,217 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.5.4.10-1.js'; + +/** + File Name: 15.5.4.10-1.js + ECMA Section: 15.5.4.10 String.prototype.substring( start, end ) + Description: + + 15.5.4.10 String.prototype.substring(start, end) + + Returns a substring of the result of converting this object to a string, + starting from character position start and running to character position + end of the string. The result is a string value, not a String object. + + If either argument is NaN or negative, it is replaced with zero; if either + argument is larger than the length of the string, it is replaced with the + length of the string. + + If start is larger than end, they are swapped. + + When the substring method is called with two arguments start and end, the + following steps are taken: + + 1. Call ToString, giving it the this value as its argument. + 2. Call ToInteger(start). + 3. Call ToInteger (end). + 4. Compute the number of characters in Result(1). + 5. Compute min(max(Result(2), 0), Result(4)). + 6. Compute min(max(Result(3), 0), Result(4)). + 7. Compute min(Result(5), Result(6)). + 8. Compute max(Result(5), Result(6)). + 9. Return a string whose length is the difference between Result(8) and + Result(7), containing characters from Result(1), namely the characters + with indices Result(7) through Result(8)1, in ascending order. + + Note that the substring function is intentionally generic; it does not require + that its this value be a String object. Therefore it can be transferred to other + kinds of objects for use as a method. + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + +var SECTION = "15.5.4.10-1"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "String.prototype.substring( start, end )"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +new TestCase( SECTION, "String.prototype.substring.length", 2, String.prototype.substring.length ); +new TestCase( SECTION, "delete String.prototype.substring.length", false, delete String.prototype.substring.length ); +new TestCase( SECTION, "delete String.prototype.substring.length; String.prototype.substring.length", 2, eval("delete String.prototype.substring.length; String.prototype.substring.length") ); + +// test cases for when substring is called with no arguments. + +// this is a string object + +new TestCase( SECTION, + "var s = new String('this is a string object'); typeof s.substring()", + "string", + eval("var s = new String('this is a string object'); typeof s.substring()") ); + +new TestCase( SECTION, + "var s = new String(''); s.substring(1,0)", + "", + eval("var s = new String(''); s.substring(1,0)") ); + +new TestCase( SECTION, + "var s = new String('this is a string object'); s.substring(true, false)", + "t", + eval("var s = new String('this is a string object'); s.substring(false, true)") ); + +new TestCase( SECTION, + "var s = new String('this is a string object'); s.substring(NaN, Infinity)", + "this is a string object", + eval("var s = new String('this is a string object'); s.substring(NaN, Infinity)") ); + + +new TestCase( SECTION, + "var s = new String('this is a string object'); s.substring(Infinity, NaN)", + "this is a string object", + eval("var s = new String('this is a string object'); s.substring(Infinity, NaN)") ); + + +new TestCase( SECTION, + "var s = new String('this is a string object'); s.substring(Infinity, Infinity)", + "", + eval("var s = new String('this is a string object'); s.substring(Infinity, Infinity)") ); + +new TestCase( SECTION, + "var s = new String('this is a string object'); s.substring(-0.01, 0)", + "", + eval("var s = new String('this is a string object'); s.substring(-0.01,0)") ); + + +new TestCase( SECTION, + "var s = new String('this is a string object'); s.substring(s.length, s.length)", + "", + eval("var s = new String('this is a string object'); s.substring(s.length, s.length)") ); + +new TestCase( SECTION, + "var s = new String('this is a string object'); s.substring(s.length+1, 0)", + "this is a string object", + eval("var s = new String('this is a string object'); s.substring(s.length+1, 0)") ); + + +new TestCase( SECTION, + "var s = new String('this is a string object'); s.substring(-Infinity, -Infinity)", + "", + eval("var s = new String('this is a string object'); s.substring(-Infinity, -Infinity)") ); + +// this is not a String object, start is not an integer + + +new TestCase( SECTION, + "var s = new Array(1,2,3,4,5); s.substring = String.prototype.substring; s.substring(Infinity,-Infinity)", + "1,2,3,4,5", + eval("var s = new Array(1,2,3,4,5); s.substring = String.prototype.substring; s.substring(Infinity,-Infinity)") ); + +new TestCase( SECTION, + "var s = new Array(1,2,3,4,5); s.substring = String.prototype.substring; s.substring(true, false)", + "1", + eval("var s = new Array(1,2,3,4,5); s.substring = String.prototype.substring; s.substring(true, false)") ); + +new TestCase( SECTION, + "var s = new Array(1,2,3,4,5); s.substring = String.prototype.substring; s.substring('4', '5')", + "3", + eval("var s = new Array(1,2,3,4,5); s.substring = String.prototype.substring; s.substring('4', '5')") ); + + +// this is an object object +new TestCase( SECTION, + "var obj = new Object(); obj.substring = String.prototype.substring; obj.substring(8,0)", + "[object ", + eval("var obj = new Object(); obj.substring = String.prototype.substring; obj.substring(8,0)") ); + +new TestCase( SECTION, + "var obj = new Object(); obj.substring = String.prototype.substring; obj.substring(8,obj.toString().length)", + "Object]", + eval("var obj = new Object(); obj.substring = String.prototype.substring; obj.substring(8, obj.toString().length)") ); + +// this is a function object +new TestCase( SECTION, + "var obj = new Function(); obj.substring = String.prototype.substring; obj.toString = Object.prototype.toString; obj.substring(8, Infinity)", + "Function]", + eval("var obj = new Function(); obj.substring = String.prototype.substring; obj.toString = Object.prototype.toString; obj.substring(8,Infinity)") ); +// this is a number object +new TestCase( SECTION, + "var obj = new Number(NaN); obj.substring = String.prototype.substring; obj.substring(Infinity, NaN)", + "NaN", + eval("var obj = new Number(NaN); obj.substring = String.prototype.substring; obj.substring(Infinity, NaN)") ); + +// this is the Math object +new TestCase( SECTION, + "var obj = Math; obj.substring = String.prototype.substring; obj.substring(Math.PI, -10)", + "[ob", + eval("var obj = Math; obj.substring = String.prototype.substring; obj.substring(Math.PI, -10)") ); + +// this is a Boolean object + +new TestCase( SECTION, + "var obj = new Boolean(); obj.substring = String.prototype.substring; obj.substring(new Array(), new Boolean(1))", + "f", + eval("var obj = new Boolean(); obj.substring = String.prototype.substring; obj.substring(new Array(), new Boolean(1))") ); + +// this is a user defined object + +new TestCase( SECTION, + "var obj = new MyObject( void 0 ); obj.substring(0, 100)", + "undefined", + eval( "var obj = new MyObject( void 0 ); obj.substring(0,100)") ); + +test(); + +function MyObject( value ) { + this.value = value; + this.substring = String.prototype.substring; + this.toString = new Function ( "return this.value+''" ); +} diff --git a/tests/auto/qml/parserstress/tests/ecma/String/15.5.4.11-1.js b/tests/auto/qml/parserstress/tests/ecma/String/15.5.4.11-1.js new file mode 100644 index 0000000000..a705f3bbda --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/String/15.5.4.11-1.js @@ -0,0 +1,518 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.5.4.11-1.js'; + +/** + File Name: 15.5.4.11-1.js + ECMA Section: 15.5.4.11 String.prototype.toLowerCase() + Description: + + Returns a string equal in length to the length of the result of converting + this object to a string. The result is a string value, not a String object. + + Every character of the result is equal to the corresponding character of the + string, unless that character has a Unicode 2.0 uppercase equivalent, in which + case the uppercase equivalent is used instead. (The canonical Unicode 2.0 case + mapping shall be used, which does not depend on implementation or locale.) + + Note that the toLowerCase function is intentionally generic; it does not require + that its this value be a String object. Therefore it can be transferred to other + kinds of objects for use as a method. + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + +var SECTION = "15.5.4.11-1"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "String.prototype.toLowerCase()"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +new TestCase( SECTION, "String.prototype.toLowerCase.length", 0, String.prototype.toLowerCase.length ); +new TestCase( SECTION, "delete String.prototype.toLowerCase.length", false, delete String.prototype.toLowerCase.length ); +new TestCase( SECTION, "delete String.prototype.toLowerCase.length; String.prototype.toLowerCase.length", 0, eval("delete String.prototype.toLowerCase.length; String.prototype.toLowerCase.length") ); + +// Basic Latin, Latin-1 Supplement, Latin Extended A +for ( var i = 0; i <= 0x017f; i++ ) { + var U = new Unicode(i); +/* + new TestCase( SECTION, + "var s = new String( String.fromCharCode("+i+") ); s.toLowerCase()", + String.fromCharCode(U.lower), + eval("var s = new String( String.fromCharCode("+i+") ); s.toLowerCase()") ); +*/ + new TestCase( SECTION, + "var s = new String( String.fromCharCode("+i+") ); s.toLowerCase().charCodeAt(0)", + U.lower, + eval("var s = new String( String.fromCharCode(i) ); s.toLowerCase().charCodeAt(0)") ); + +} + +test(); + +function MyObject( value ) { + this.value = value; + this.substring = String.prototype.substring; + this.toString = new Function ( "return this.value+''" ); +} +function Unicode( c ) { + u = GetUnicodeValues( c ); + this.upper = u[0]; + this.lower = u[1] + return this; +} +function GetUnicodeValues( c ) { + u = new Array(); + + u[0] = c; + u[1] = c; + + // upper case Basic Latin + + if ( c >= 0x0041 && c <= 0x005A) { + u[0] = c; + u[1] = c + 32; + return u; + } + + // lower case Basic Latin + if ( c >= 0x0061 && c <= 0x007a ) { + u[0] = c - 32; + u[1] = c; + return u; + } + + // upper case Latin-1 Supplement + if ( (c >= 0x00C0 && c <= 0x00D6) || (c >= 0x00D8 && c<=0x00DE) ) { + u[0] = c; + u[1] = c + 32; + return u; + } + + // lower case Latin-1 Supplement + if ( (c >= 0x00E0 && c <= 0x00F6) || (c >= 0x00F8 && c <= 0x00FE) ) { + u[0] = c - 32; + u[1] = c; + return u; + } + if ( c == 0x00FF ) { + u[0] = 0x0178; + u[1] = c; + return u; + } + // Latin Extended A + if ( (c >= 0x0100 && c < 0x0138) || (c > 0x0149 && c < 0x0178) ) { + // special case for capital I + if ( c == 0x0130 ) { + u[0] = c; + u[1] = 0x0069; + return u; + } + if ( c == 0x0131 ) { + u[0] = 0x0049; + u[1] = c; + return u; + } + + if ( c % 2 == 0 ) { + // if it's even, it's a capital and the lower case is c +1 + u[0] = c; + u[1] = c+1; + } else { + // if it's odd, it's a lower case and upper case is c-1 + u[0] = c-1; + u[1] = c; + } + return u; + } + if ( c == 0x0178 ) { + u[0] = c; + u[1] = 0x00FF; + return u; + } + + if ( (c >= 0x0139 && c < 0x0149) || (c > 0x0178 && c < 0x017F) ) { + if ( c % 2 == 1 ) { + // if it's odd, it's a capital and the lower case is c +1 + u[0] = c; + u[1] = c+1; + } else { + // if it's even, it's a lower case and upper case is c-1 + u[0] = c-1; + u[1] = c; + } + return u; + } + if ( c == 0x017F ) { + u[0] = 0x0053; + u[1] = c; + } + + // Latin Extended B + // need to improve this set + + if ( c >= 0x0200 && c <= 0x0217 ) { + if ( c % 2 == 0 ) { + u[0] = c; + u[1] = c+1; + } else { + u[0] = c-1; + u[1] = c; + } + return u; + } + + // Latin Extended Additional + // Range: U+1E00 to U+1EFF + // http://www.unicode.org/Unicode.charts/glyphless/U1E00.html + + // Spacing Modifier Leters + // Range: U+02B0 to U+02FF + + // Combining Diacritical Marks + // Range: U+0300 to U+036F + + // skip Greek for now + // Greek + // Range: U+0370 to U+03FF + + // Cyrillic + // Range: U+0400 to U+04FF + + if ( (c >= 0x0401 && c <= 0x040C) || ( c>= 0x040E && c <= 0x040F ) ) { + u[0] = c; + u[1] = c + 80; + return u; + } + + + if ( c >= 0x0410 && c <= 0x042F ) { + u[0] = c; + u[1] = c + 32; + return u; + } + + if ( c >= 0x0430 && c<= 0x044F ) { + u[0] = c - 32; + u[1] = c; + return u; + + } + if ( (c >= 0x0451 && c <= 0x045C) || (c >=0x045E && c<= 0x045F) ) { + u[0] = c -80; + u[1] = c; + return u; + } + + if ( c >= 0x0460 && c <= 0x047F ) { + if ( c % 2 == 0 ) { + u[0] = c; + u[1] = c +1; + } else { + u[0] = c - 1; + u[1] = c; + } + return u; + } + + // Armenian + // Range: U+0530 to U+058F + if ( c >= 0x0531 && c <= 0x0556 ) { + u[0] = c; + u[1] = c + 48; + return u; + } + if ( c >= 0x0561 && c < 0x0587 ) { + u[0] = c - 48; + u[1] = c; + return u; + } + + // Hebrew + // Range: U+0590 to U+05FF + + + // Arabic + // Range: U+0600 to U+06FF + + // Devanagari + // Range: U+0900 to U+097F + + + // Bengali + // Range: U+0980 to U+09FF + + + // Gurmukhi + // Range: U+0A00 to U+0A7F + + + // Gujarati + // Range: U+0A80 to U+0AFF + + + // Oriya + // Range: U+0B00 to U+0B7F + // no capital / lower case + + + // Tamil + // Range: U+0B80 to U+0BFF + // no capital / lower case + + + // Telugu + // Range: U+0C00 to U+0C7F + // no capital / lower case + + + // Kannada + // Range: U+0C80 to U+0CFF + // no capital / lower case + + + // Malayalam + // Range: U+0D00 to U+0D7F + + // Thai + // Range: U+0E00 to U+0E7F + + + // Lao + // Range: U+0E80 to U+0EFF + + + // Tibetan + // Range: U+0F00 to U+0FBF + + // Georgian + // Range: U+10A0 to U+10F0 + if ( c >= 0x10A0 && c <= 0x10C5 ) { + u[0] = c; + u[1] = c + 48; + return u; + } + if ( c >= 0x10D0 && c <= 0x10F5 ) { + u[0] = c; + u[1] = c; + return u; + } + + // Hangul Jamo + // Range: U+1100 to U+11FF + + // Greek Extended + // Range: U+1F00 to U+1FFF + // skip for now + + + // General Punctuation + // Range: U+2000 to U+206F + + // Superscripts and Subscripts + // Range: U+2070 to U+209F + + // Currency Symbols + // Range: U+20A0 to U+20CF + + + // Combining Diacritical Marks for Symbols + // Range: U+20D0 to U+20FF + // skip for now + + + // Number Forms + // Range: U+2150 to U+218F + // skip for now + + + // Arrows + // Range: U+2190 to U+21FF + + // Mathematical Operators + // Range: U+2200 to U+22FF + + // Miscellaneous Technical + // Range: U+2300 to U+23FF + + // Control Pictures + // Range: U+2400 to U+243F + + // Optical Character Recognition + // Range: U+2440 to U+245F + + // Enclosed Alphanumerics + // Range: U+2460 to U+24FF + + // Box Drawing + // Range: U+2500 to U+257F + + // Block Elements + // Range: U+2580 to U+259F + + // Geometric Shapes + // Range: U+25A0 to U+25FF + + // Miscellaneous Symbols + // Range: U+2600 to U+26FF + + // Dingbats + // Range: U+2700 to U+27BF + + // CJK Symbols and Punctuation + // Range: U+3000 to U+303F + + // Hiragana + // Range: U+3040 to U+309F + + // Katakana + // Range: U+30A0 to U+30FF + + // Bopomofo + // Range: U+3100 to U+312F + + // Hangul Compatibility Jamo + // Range: U+3130 to U+318F + + // Kanbun + // Range: U+3190 to U+319F + + + // Enclosed CJK Letters and Months + // Range: U+3200 to U+32FF + + // CJK Compatibility + // Range: U+3300 to U+33FF + + // Hangul Syllables + // Range: U+AC00 to U+D7A3 + + // High Surrogates + // Range: U+D800 to U+DB7F + + // Private Use High Surrogates + // Range: U+DB80 to U+DBFF + + // Low Surrogates + // Range: U+DC00 to U+DFFF + + // Private Use Area + // Range: U+E000 to U+F8FF + + // CJK Compatibility Ideographs + // Range: U+F900 to U+FAFF + + // Alphabetic Presentation Forms + // Range: U+FB00 to U+FB4F + + // Arabic Presentation Forms-A + // Range: U+FB50 to U+FDFF + + // Combining Half Marks + // Range: U+FE20 to U+FE2F + + // CJK Compatibility Forms + // Range: U+FE30 to U+FE4F + + // Small Form Variants + // Range: U+FE50 to U+FE6F + + // Arabic Presentation Forms-B + // Range: U+FE70 to U+FEFF + + // Halfwidth and Fullwidth Forms + // Range: U+FF00 to U+FFEF + + if ( c >= 0xFF21 && c <= 0xFF3A ) { + u[0] = c; + u[1] = c + 32; + return u; + } + + if ( c >= 0xFF41 && c <= 0xFF5A ) { + u[0] = c - 32; + u[1] = c; + return u; + } + + // Specials + // Range: U+FFF0 to U+FFFF + + return u; +} + +function DecimalToHexString( n ) { + n = Number( n ); + var h = "0x"; + + for ( var i = 3; i >= 0; i-- ) { + if ( n >= Math.pow(16, i) ){ + var t = Math.floor( n / Math.pow(16, i)); + n -= t * Math.pow(16, i); + if ( t >= 10 ) { + if ( t == 10 ) { + h += "A"; + } + if ( t == 11 ) { + h += "B"; + } + if ( t == 12 ) { + h += "C"; + } + if ( t == 13 ) { + h += "D"; + } + if ( t == 14 ) { + h += "E"; + } + if ( t == 15 ) { + h += "F"; + } + } else { + h += String( t ); + } + } else { + h += "0"; + } + } + + return h; +} diff --git a/tests/auto/qml/parserstress/tests/ecma/String/15.5.4.11-2.js b/tests/auto/qml/parserstress/tests/ecma/String/15.5.4.11-2.js new file mode 100644 index 0000000000..7377dc8247 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/String/15.5.4.11-2.js @@ -0,0 +1,515 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.5.4.11-2.js'; + +/** + File Name: 15.5.4.11-2.js + ECMA Section: 15.5.4.11 String.prototype.toLowerCase() + Description: + + Returns a string equal in length to the length of the result of converting + this object to a string. The result is a string value, not a String object. + + Every character of the result is equal to the corresponding character of the + string, unless that character has a Unicode 2.0 uppercase equivalent, in which + case the uppercase equivalent is used instead. (The canonical Unicode 2.0 case + mapping shall be used, which does not depend on implementation or locale.) + + Note that the toLowerCase function is intentionally generic; it does not require + that its this value be a String object. Therefore it can be transferred to other + kinds of objects for use as a method. + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + +var SECTION = "15.5.4.11-2"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "String.prototype.toLowerCase()"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +// Georgian +// Range: U+10A0 to U+10FF +for ( var i = 0x10A0; i <= 0x10FF; i++ ) { + var U = new Unicode( i ); + +/* + new TestCase( SECTION, + "var s = new String( String.fromCharCode("+i+") ); s.toLowerCase()", + String.fromCharCode(U.lower), + eval("var s = new String( String.fromCharCode("+i+") ); s.toLowerCase()") ); +*/ + new TestCase( SECTION, + "var s = new String( String.fromCharCode("+i+") ); s.toLowerCase().charCodeAt(0)", + U.lower, + eval("var s = new String( String.fromCharCode(i) ); s.toLowerCase().charCodeAt(0)") ); +} + +test(); + +function MyObject( value ) { + this.value = value; + this.substring = String.prototype.substring; + this.toString = new Function ( "return this.value+''" ); +} +function Unicode( c ) { + u = GetUnicodeValues( c ); + this.upper = u[0]; + this.lower = u[1] + return this; +} +function GetUnicodeValues( c ) { + u = new Array(); + + u[0] = c; + u[1] = c; + + // upper case Basic Latin + + if ( c >= 0x0041 && c <= 0x005A) { + u[0] = c; + u[1] = c + 32; + return u; + } + + // lower case Basic Latin + if ( c >= 0x0061 && c <= 0x007a ) { + u[0] = c - 32; + u[1] = c; + return u; + } + + // upper case Latin-1 Supplement + if ( (c >= 0x00C0 && c <= 0x00D6) || (c >= 0x00D8 && c<=0x00DE) ) { + u[0] = c; + u[1] = c + 32; + return u; + } + + // lower case Latin-1 Supplement + if ( (c >= 0x00E0 && c <= 0x00F6) || (c >= 0x00F8 && c <= 0x00FE) ) { + u[0] = c - 32; + u[1] = c; + return u; + } + if ( c == 0x00FF ) { + u[0] = 0x0178; + u[1] = c; + return u; + } + // Latin Extended A + if ( (c >= 0x0100 && c < 0x0138) || (c > 0x0149 && c < 0x0178) ) { + // special case for capital I + if ( c == 0x0130 ) { + u[0] = c; + u[1] = 0x0069; + return u; + } + if ( c == 0x0131 ) { + u[0] = 0x0049; + u[1] = c; + return u; + } + + if ( c % 2 == 0 ) { + // if it's even, it's a capital and the lower case is c +1 + u[0] = c; + u[1] = c+1; + } else { + // if it's odd, it's a lower case and upper case is c-1 + u[0] = c-1; + u[1] = c; + } + return u; + } + if ( c == 0x0178 ) { + u[0] = c; + u[1] = 0x00FF; + return u; + } + + if ( (c >= 0x0139 && c < 0x0149) || (c > 0x0178 && c < 0x017F) ) { + if ( c % 2 == 1 ) { + // if it's odd, it's a capital and the lower case is c +1 + u[0] = c; + u[1] = c+1; + } else { + // if it's even, it's a lower case and upper case is c-1 + u[0] = c-1; + u[1] = c; + } + return u; + } + if ( c == 0x017F ) { + u[0] = 0x0053; + u[1] = c; + } + + // Latin Extended B + // need to improve this set + + if ( c >= 0x0200 && c <= 0x0217 ) { + if ( c % 2 == 0 ) { + u[0] = c; + u[1] = c+1; + } else { + u[0] = c-1; + u[1] = c; + } + return u; + } + + // Latin Extended Additional + // Range: U+1E00 to U+1EFF + // http://www.unicode.org/Unicode.charts/glyphless/U1E00.html + + // Spacing Modifier Leters + // Range: U+02B0 to U+02FF + + // Combining Diacritical Marks + // Range: U+0300 to U+036F + + // skip Greek for now + // Greek + // Range: U+0370 to U+03FF + + // Cyrillic + // Range: U+0400 to U+04FF + + if ( (c >= 0x0401 && c <= 0x040C) || ( c>= 0x040E && c <= 0x040F ) ) { + u[0] = c; + u[1] = c + 80; + return u; + } + + + if ( c >= 0x0410 && c <= 0x042F ) { + u[0] = c; + u[1] = c + 32; + return u; + } + + if ( c >= 0x0430 && c<= 0x044F ) { + u[0] = c - 32; + u[1] = c; + return u; + + } + if ( (c >= 0x0451 && c <= 0x045C) || (c >=0x045E && c<= 0x045F) ) { + u[0] = c -80; + u[1] = c; + return u; + } + + if ( c >= 0x0460 && c <= 0x047F ) { + if ( c % 2 == 0 ) { + u[0] = c; + u[1] = c +1; + } else { + u[0] = c - 1; + u[1] = c; + } + return u; + } + + // Armenian + // Range: U+0530 to U+058F + if ( c >= 0x0531 && c <= 0x0556 ) { + u[0] = c; + u[1] = c + 48; + return u; + } + if ( c >= 0x0561 && c < 0x0587 ) { + u[0] = c - 48; + u[1] = c; + return u; + } + + // Hebrew + // Range: U+0590 to U+05FF + + + // Arabic + // Range: U+0600 to U+06FF + + // Devanagari + // Range: U+0900 to U+097F + + + // Bengali + // Range: U+0980 to U+09FF + + + // Gurmukhi + // Range: U+0A00 to U+0A7F + + + // Gujarati + // Range: U+0A80 to U+0AFF + + + // Oriya + // Range: U+0B00 to U+0B7F + // no capital / lower case + + + // Tamil + // Range: U+0B80 to U+0BFF + // no capital / lower case + + + // Telugu + // Range: U+0C00 to U+0C7F + // no capital / lower case + + + // Kannada + // Range: U+0C80 to U+0CFF + // no capital / lower case + + + // Malayalam + // Range: U+0D00 to U+0D7F + + // Thai + // Range: U+0E00 to U+0E7F + + + // Lao + // Range: U+0E80 to U+0EFF + + + // Tibetan + // Range: U+0F00 to U+0FBF + + // Georgian + // Range: U+10A0 to U+10F0 + if ( c >= 0x10A0 && c <= 0x10C5 ) { + u[0] = c; + u[1] = c + 48; + return u; + } + if ( c >= 0x10D0 && c <= 0x10F5 ) { + u[0] = c; + u[1] = c; + return u; + } + + // Hangul Jamo + // Range: U+1100 to U+11FF + + // Greek Extended + // Range: U+1F00 to U+1FFF + // skip for now + + + // General Punctuation + // Range: U+2000 to U+206F + + // Superscripts and Subscripts + // Range: U+2070 to U+209F + + // Currency Symbols + // Range: U+20A0 to U+20CF + + + // Combining Diacritical Marks for Symbols + // Range: U+20D0 to U+20FF + // skip for now + + + // Number Forms + // Range: U+2150 to U+218F + // skip for now + + + // Arrows + // Range: U+2190 to U+21FF + + // Mathematical Operators + // Range: U+2200 to U+22FF + + // Miscellaneous Technical + // Range: U+2300 to U+23FF + + // Control Pictures + // Range: U+2400 to U+243F + + // Optical Character Recognition + // Range: U+2440 to U+245F + + // Enclosed Alphanumerics + // Range: U+2460 to U+24FF + + // Box Drawing + // Range: U+2500 to U+257F + + // Block Elements + // Range: U+2580 to U+259F + + // Geometric Shapes + // Range: U+25A0 to U+25FF + + // Miscellaneous Symbols + // Range: U+2600 to U+26FF + + // Dingbats + // Range: U+2700 to U+27BF + + // CJK Symbols and Punctuation + // Range: U+3000 to U+303F + + // Hiragana + // Range: U+3040 to U+309F + + // Katakana + // Range: U+30A0 to U+30FF + + // Bopomofo + // Range: U+3100 to U+312F + + // Hangul Compatibility Jamo + // Range: U+3130 to U+318F + + // Kanbun + // Range: U+3190 to U+319F + + + // Enclosed CJK Letters and Months + // Range: U+3200 to U+32FF + + // CJK Compatibility + // Range: U+3300 to U+33FF + + // Hangul Syllables + // Range: U+AC00 to U+D7A3 + + // High Surrogates + // Range: U+D800 to U+DB7F + + // Private Use High Surrogates + // Range: U+DB80 to U+DBFF + + // Low Surrogates + // Range: U+DC00 to U+DFFF + + // Private Use Area + // Range: U+E000 to U+F8FF + + // CJK Compatibility Ideographs + // Range: U+F900 to U+FAFF + + // Alphabetic Presentation Forms + // Range: U+FB00 to U+FB4F + + // Arabic Presentation Forms-A + // Range: U+FB50 to U+FDFF + + // Combining Half Marks + // Range: U+FE20 to U+FE2F + + // CJK Compatibility Forms + // Range: U+FE30 to U+FE4F + + // Small Form Variants + // Range: U+FE50 to U+FE6F + + // Arabic Presentation Forms-B + // Range: U+FE70 to U+FEFF + + // Halfwidth and Fullwidth Forms + // Range: U+FF00 to U+FFEF + + if ( c >= 0xFF21 && c <= 0xFF3A ) { + u[0] = c; + u[1] = c + 32; + return u; + } + + if ( c >= 0xFF41 && c <= 0xFF5A ) { + u[0] = c - 32; + u[1] = c; + return u; + } + + // Specials + // Range: U+FFF0 to U+FFFF + + return u; +} + +function DecimalToHexString( n ) { + n = Number( n ); + var h = "0x"; + + for ( var i = 3; i >= 0; i-- ) { + if ( n >= Math.pow(16, i) ){ + var t = Math.floor( n / Math.pow(16, i)); + n -= t * Math.pow(16, i); + if ( t >= 10 ) { + if ( t == 10 ) { + h += "A"; + } + if ( t == 11 ) { + h += "B"; + } + if ( t == 12 ) { + h += "C"; + } + if ( t == 13 ) { + h += "D"; + } + if ( t == 14 ) { + h += "E"; + } + if ( t == 15 ) { + h += "F"; + } + } else { + h += String( t ); + } + } else { + h += "0"; + } + } + + return h; +} diff --git a/tests/auto/qml/parserstress/tests/ecma/String/15.5.4.11-3.js b/tests/auto/qml/parserstress/tests/ecma/String/15.5.4.11-3.js new file mode 100644 index 0000000000..0a37dcd28a --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/String/15.5.4.11-3.js @@ -0,0 +1,514 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.5.4.11-3.js'; + +/** + File Name: 15.5.4.11-2.js + ECMA Section: 15.5.4.11 String.prototype.toLowerCase() + Description: + + Returns a string equal in length to the length of the result of converting + this object to a string. The result is a string value, not a String object. + + Every character of the result is equal to the corresponding character of the + string, unless that character has a Unicode 2.0 uppercase equivalent, in which + case the uppercase equivalent is used instead. (The canonical Unicode 2.0 case + mapping shall be used, which does not depend on implementation or locale.) + + Note that the toLowerCase function is intentionally generic; it does not require + that its this value be a String object. Therefore it can be transferred to other + kinds of objects for use as a method. + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + +var SECTION = "15.5.4.11-2"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "String.prototype.toLowerCase()"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +// Halfwidth and Fullwidth Forms +// Range: U+FF00 to U+FFEF +for ( var i = 0xFF00; i <= 0xFFEF; i++ ) { + var U = new Unicode(i); +/* + new TestCase( SECTION, + "var s = new String( String.fromCharCode("+i+") ); s.toLowerCase()", + String.fromCharCode(U.lower), + eval("var s = new String( String.fromCharCode("+i+") ); s.toLowerCase()") ); +*/ + new TestCase( SECTION, + "var s = new String( String.fromCharCode("+i+") ); s.toLowerCase().charCodeAt(0)", + U.lower, + eval("var s = new String( String.fromCharCode(i) ); s.toLowerCase().charCodeAt(0)") ); +} + +test(); + +function MyObject( value ) { + this.value = value; + this.substring = String.prototype.substring; + this.toString = new Function ( "return this.value+''" ); +} +function Unicode( c ) { + u = GetUnicodeValues( c ); + this.upper = u[0]; + this.lower = u[1] + return this; +} +function GetUnicodeValues( c ) { + u = new Array(); + + u[0] = c; + u[1] = c; + + // upper case Basic Latin + + if ( c >= 0x0041 && c <= 0x005A) { + u[0] = c; + u[1] = c + 32; + return u; + } + + // lower case Basic Latin + if ( c >= 0x0061 && c <= 0x007a ) { + u[0] = c - 32; + u[1] = c; + return u; + } + + // upper case Latin-1 Supplement + if ( (c >= 0x00C0 && c <= 0x00D6) || (c >= 0x00D8 && c<=0x00DE) ) { + u[0] = c; + u[1] = c + 32; + return u; + } + + // lower case Latin-1 Supplement + if ( (c >= 0x00E0 && c <= 0x00F6) || (c >= 0x00F8 && c <= 0x00FE) ) { + u[0] = c - 32; + u[1] = c; + return u; + } + if ( c == 0x00FF ) { + u[0] = 0x0178; + u[1] = c; + return u; + } + // Latin Extended A + if ( (c >= 0x0100 && c < 0x0138) || (c > 0x0149 && c < 0x0178) ) { + // special case for capital I + if ( c == 0x0130 ) { + u[0] = c; + u[1] = 0x0069; + return u; + } + if ( c == 0x0131 ) { + u[0] = 0x0049; + u[1] = c; + return u; + } + + if ( c % 2 == 0 ) { + // if it's even, it's a capital and the lower case is c +1 + u[0] = c; + u[1] = c+1; + } else { + // if it's odd, it's a lower case and upper case is c-1 + u[0] = c-1; + u[1] = c; + } + return u; + } + if ( c == 0x0178 ) { + u[0] = c; + u[1] = 0x00FF; + return u; + } + + if ( (c >= 0x0139 && c < 0x0149) || (c > 0x0178 && c < 0x017F) ) { + if ( c % 2 == 1 ) { + // if it's odd, it's a capital and the lower case is c +1 + u[0] = c; + u[1] = c+1; + } else { + // if it's even, it's a lower case and upper case is c-1 + u[0] = c-1; + u[1] = c; + } + return u; + } + if ( c == 0x017F ) { + u[0] = 0x0053; + u[1] = c; + } + + // Latin Extended B + // need to improve this set + + if ( c >= 0x0200 && c <= 0x0217 ) { + if ( c % 2 == 0 ) { + u[0] = c; + u[1] = c+1; + } else { + u[0] = c-1; + u[1] = c; + } + return u; + } + + // Latin Extended Additional + // Range: U+1E00 to U+1EFF + // http://www.unicode.org/Unicode.charts/glyphless/U1E00.html + + // Spacing Modifier Leters + // Range: U+02B0 to U+02FF + + // Combining Diacritical Marks + // Range: U+0300 to U+036F + + // skip Greek for now + // Greek + // Range: U+0370 to U+03FF + + // Cyrillic + // Range: U+0400 to U+04FF + + if ( (c >= 0x0401 && c <= 0x040C) || ( c>= 0x040E && c <= 0x040F ) ) { + u[0] = c; + u[1] = c + 80; + return u; + } + + + if ( c >= 0x0410 && c <= 0x042F ) { + u[0] = c; + u[1] = c + 32; + return u; + } + + if ( c >= 0x0430 && c<= 0x044F ) { + u[0] = c - 32; + u[1] = c; + return u; + + } + if ( (c >= 0x0451 && c <= 0x045C) || (c >=0x045E && c<= 0x045F) ) { + u[0] = c -80; + u[1] = c; + return u; + } + + if ( c >= 0x0460 && c <= 0x047F ) { + if ( c % 2 == 0 ) { + u[0] = c; + u[1] = c +1; + } else { + u[0] = c - 1; + u[1] = c; + } + return u; + } + + // Armenian + // Range: U+0530 to U+058F + if ( c >= 0x0531 && c <= 0x0556 ) { + u[0] = c; + u[1] = c + 48; + return u; + } + if ( c >= 0x0561 && c < 0x0587 ) { + u[0] = c - 48; + u[1] = c; + return u; + } + + // Hebrew + // Range: U+0590 to U+05FF + + + // Arabic + // Range: U+0600 to U+06FF + + // Devanagari + // Range: U+0900 to U+097F + + + // Bengali + // Range: U+0980 to U+09FF + + + // Gurmukhi + // Range: U+0A00 to U+0A7F + + + // Gujarati + // Range: U+0A80 to U+0AFF + + + // Oriya + // Range: U+0B00 to U+0B7F + // no capital / lower case + + + // Tamil + // Range: U+0B80 to U+0BFF + // no capital / lower case + + + // Telugu + // Range: U+0C00 to U+0C7F + // no capital / lower case + + + // Kannada + // Range: U+0C80 to U+0CFF + // no capital / lower case + + + // Malayalam + // Range: U+0D00 to U+0D7F + + // Thai + // Range: U+0E00 to U+0E7F + + + // Lao + // Range: U+0E80 to U+0EFF + + + // Tibetan + // Range: U+0F00 to U+0FBF + + // Georgian + // Range: U+10A0 to U+10F0 + if ( c >= 0x10A0 && c <= 0x10C5 ) { + u[0] = c; + u[1] = c + 48; + return u; + } + if ( c >= 0x10D0 && c <= 0x10F5 ) { + u[0] = c; + u[1] = c; + return u; + } + + // Hangul Jamo + // Range: U+1100 to U+11FF + + // Greek Extended + // Range: U+1F00 to U+1FFF + // skip for now + + + // General Punctuation + // Range: U+2000 to U+206F + + // Superscripts and Subscripts + // Range: U+2070 to U+209F + + // Currency Symbols + // Range: U+20A0 to U+20CF + + + // Combining Diacritical Marks for Symbols + // Range: U+20D0 to U+20FF + // skip for now + + + // Number Forms + // Range: U+2150 to U+218F + // skip for now + + + // Arrows + // Range: U+2190 to U+21FF + + // Mathematical Operators + // Range: U+2200 to U+22FF + + // Miscellaneous Technical + // Range: U+2300 to U+23FF + + // Control Pictures + // Range: U+2400 to U+243F + + // Optical Character Recognition + // Range: U+2440 to U+245F + + // Enclosed Alphanumerics + // Range: U+2460 to U+24FF + + // Box Drawing + // Range: U+2500 to U+257F + + // Block Elements + // Range: U+2580 to U+259F + + // Geometric Shapes + // Range: U+25A0 to U+25FF + + // Miscellaneous Symbols + // Range: U+2600 to U+26FF + + // Dingbats + // Range: U+2700 to U+27BF + + // CJK Symbols and Punctuation + // Range: U+3000 to U+303F + + // Hiragana + // Range: U+3040 to U+309F + + // Katakana + // Range: U+30A0 to U+30FF + + // Bopomofo + // Range: U+3100 to U+312F + + // Hangul Compatibility Jamo + // Range: U+3130 to U+318F + + // Kanbun + // Range: U+3190 to U+319F + + + // Enclosed CJK Letters and Months + // Range: U+3200 to U+32FF + + // CJK Compatibility + // Range: U+3300 to U+33FF + + // Hangul Syllables + // Range: U+AC00 to U+D7A3 + + // High Surrogates + // Range: U+D800 to U+DB7F + + // Private Use High Surrogates + // Range: U+DB80 to U+DBFF + + // Low Surrogates + // Range: U+DC00 to U+DFFF + + // Private Use Area + // Range: U+E000 to U+F8FF + + // CJK Compatibility Ideographs + // Range: U+F900 to U+FAFF + + // Alphabetic Presentation Forms + // Range: U+FB00 to U+FB4F + + // Arabic Presentation Forms-A + // Range: U+FB50 to U+FDFF + + // Combining Half Marks + // Range: U+FE20 to U+FE2F + + // CJK Compatibility Forms + // Range: U+FE30 to U+FE4F + + // Small Form Variants + // Range: U+FE50 to U+FE6F + + // Arabic Presentation Forms-B + // Range: U+FE70 to U+FEFF + + // Halfwidth and Fullwidth Forms + // Range: U+FF00 to U+FFEF + + if ( c >= 0xFF21 && c <= 0xFF3A ) { + u[0] = c; + u[1] = c + 32; + return u; + } + + if ( c >= 0xFF41 && c <= 0xFF5A ) { + u[0] = c - 32; + u[1] = c; + return u; + } + + // Specials + // Range: U+FFF0 to U+FFFF + + return u; +} + +function DecimalToHexString( n ) { + n = Number( n ); + var h = "0x"; + + for ( var i = 3; i >= 0; i-- ) { + if ( n >= Math.pow(16, i) ){ + var t = Math.floor( n / Math.pow(16, i)); + n -= t * Math.pow(16, i); + if ( t >= 10 ) { + if ( t == 10 ) { + h += "A"; + } + if ( t == 11 ) { + h += "B"; + } + if ( t == 12 ) { + h += "C"; + } + if ( t == 13 ) { + h += "D"; + } + if ( t == 14 ) { + h += "E"; + } + if ( t == 15 ) { + h += "F"; + } + } else { + h += String( t ); + } + } else { + h += "0"; + } + } + + return h; +} diff --git a/tests/auto/qml/parserstress/tests/ecma/String/15.5.4.11-4.js b/tests/auto/qml/parserstress/tests/ecma/String/15.5.4.11-4.js new file mode 100644 index 0000000000..1196e61c08 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/String/15.5.4.11-4.js @@ -0,0 +1,507 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.5.4.11-4.js'; + +/** + File Name: 15.5.4.11-2.js + ECMA Section: 15.5.4.11 String.prototype.toLowerCase() + Description: + + Returns a string equal in length to the length of the result of converting + this object to a string. The result is a string value, not a String object. + + Every character of the result is equal to the corresponding character of the + string, unless that character has a Unicode 2.0 uppercase equivalent, in which + case the uppercase equivalent is used instead. (The canonical Unicode 2.0 case + mapping shall be used, which does not depend on implementation or locale.) + + Note that the toLowerCase function is intentionally generic; it does not require + that its this value be a String object. Therefore it can be transferred to other + kinds of objects for use as a method. + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + +var SECTION = "15.5.4.11-2"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "String.prototype.toLowerCase()"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +// Hiragana (no upper / lower case) +// Range: U+3040 to U+309F + +for ( var i = 0x3040; i <= 0x309F; i++ ) { + var U = new Unicode( i ); +/* + new TestCase( SECTION, + "var s = new String( String.fromCharCode("+i+") ); s.toLowerCase()", + String.fromCharCode(U.lower), + eval("var s = new String( String.fromCharCode("+i+") ); s.toLowerCase()") ); +*/ + new TestCase( SECTION, + "var s = new String( String.fromCharCode("+i+") ); s.toLowerCase().charCodeAt(0)", + U.lower, + eval("var s = new String( String.fromCharCode(i) ); s.toLowerCase().charCodeAt(0)") ); +} + +test(); + +function MyObject( value ) { + this.value = value; + this.substring = String.prototype.substring; + this.toString = new Function ( "return this.value+''" ); +} +function Unicode( c ) { + this.upper = c; + this.lower = c; + + // upper case Basic Latin + + if ( c >= 0x0041 && c <= 0x005A) { + this.upper = c; + this.lower = c + 32; + return this; + } + + // lower case Basic Latin + if ( c >= 0x0061 && c <= 0x007a ) { + this.upper = c - 32; + this.lower = c; + return this; + } + + // upper case Latin-1 Supplement + if ( (c >= 0x00C0 && c <= 0x00D6) || (c >= 0x00D8 && c<=0x00DE) ) { + this.upper = c; + this.lower = c + 32; + return this; + } + + // lower case Latin-1 Supplement + if ( (c >= 0x00E0 && c <= 0x00F6) || (c >= 0x00F8 && c <= 0x00FE) ) { + this.upper = c - 32; + this.lower = c; + return this; + } + if ( c == 0x00FF ) { + this.upper = 0x0178; + this.lower = c; + return this; + } + // Latin Extended A + if ( (c >= 0x0100 && c < 0x0138) || (c > 0x0149 && c < 0x0178) ) { + // special case for capital I + if ( c == 0x0130 ) { + this.upper = c; + this.lower = 0x0069; + return this; + } + if ( c == 0x0131 ) { + this.upper = 0x0049; + this.lower = c; + return this; + } + + if ( c % 2 == 0 ) { + // if it's even, it's a capital and the lower case is c +1 + this.upper = c; + this.lower = c+1; + } else { + // if it's odd, it's a lower case and upper case is c-1 + this.upper = c-1; + this.lower = c; + } + return this; + } + if ( c == 0x0178 ) { + this.upper = c; + this.lower = 0x00FF; + return this; + } + + if ( (c >= 0x0139 && c < 0x0149) || (c > 0x0178 && c < 0x017F) ) { + if ( c % 2 == 1 ) { + // if it's odd, it's a capital and the lower case is c +1 + this.upper = c; + this.lower = c+1; + } else { + // if it's even, it's a lower case and upper case is c-1 + this.upper = c-1; + this.lower = c; + } + return this; + } + if ( c == 0x017F ) { + this.upper = 0x0053; + this.lower = c; + } + + // Latin Extended B + // need to improve this set + + if ( c >= 0x0200 && c <= 0x0217 ) { + if ( c % 2 == 0 ) { + this.upper = c; + this.lower = c+1; + } else { + this.upper = c-1; + this.lower = c; + } + return this; + } + + // Latin Extended Additional + // Range: U+1E00 to U+1EFF + // http://www.unicode.org/Unicode.charts/glyphless/U1E00.html + + // Spacing Modifier Leters + // Range: U+02B0 to U+02FF + + // Combining Diacritical Marks + // Range: U+0300 to U+036F + + // skip Greek for now + // Greek + // Range: U+0370 to U+03FF + + // Cyrillic + // Range: U+0400 to U+04FF + + if ( (c >= 0x0401 && c <= 0x040C) || ( c>= 0x040E && c <= 0x040F ) ) { + this.upper = c; + this.lower = c + 80; + return this; + } + + + if ( c >= 0x0410 && c <= 0x042F ) { + this.upper = c; + this.lower = c + 32; + return this; + } + + if ( c >= 0x0430 && c<= 0x044F ) { + this.upper = c - 32; + this.lower = c; + return this; + + } + if ( (c >= 0x0451 && c <= 0x045C) || (c >=0x045E && c<= 0x045F) ) { + this.upper = c -80; + this.lower = c; + return this; + } + + if ( c >= 0x0460 && c <= 0x047F ) { + if ( c % 2 == 0 ) { + this.upper = c; + this.lower = c +1; + } else { + this.upper = c - 1; + this.lower = c; + } + return this; + } + + // Armenian + // Range: U+0530 to U+058F + if ( c >= 0x0531 && c <= 0x0556 ) { + this.upper = c; + this.lower = c + 48; + return this; + } + if ( c >= 0x0561 && c < 0x0587 ) { + this.upper = c - 48; + this.lower = c; + return this; + } + + // Hebrew + // Range: U+0590 to U+05FF + + + // Arabic + // Range: U+0600 to U+06FF + + // Devanagari + // Range: U+0900 to U+097F + + + // Bengali + // Range: U+0980 to U+09FF + + + // Gurmukhi + // Range: U+0A00 to U+0A7F + + + // Gujarati + // Range: U+0A80 to U+0AFF + + + // Oriya + // Range: U+0B00 to U+0B7F + // no capital / lower case + + + // Tamil + // Range: U+0B80 to U+0BFF + // no capital / lower case + + + // Telugu + // Range: U+0C00 to U+0C7F + // no capital / lower case + + + // Kannada + // Range: U+0C80 to U+0CFF + // no capital / lower case + + + // Malayalam + // Range: U+0D00 to U+0D7F + + // Thai + // Range: U+0E00 to U+0E7F + + + // Lao + // Range: U+0E80 to U+0EFF + + + // Tibetan + // Range: U+0F00 to U+0FBF + + // Georgian + // Range: U+10A0 to U+10F0 + if ( c >= 0x10A0 && c <= 0x10C5 ) { + this.upper = c; + this.lower = c + 48; + return this; + } + if ( c >= 0x10D0 && c <= 0x10F5 ) { + this.upper = c; + this.lower = c; + return this; + } + + // Hangul Jamo + // Range: U+1100 to U+11FF + + // Greek Extended + // Range: U+1F00 to U+1FFF + // skip for now + + + // General Punctuation + // Range: U+2000 to U+206F + + // Superscripts and Subscripts + // Range: U+2070 to U+209F + + // Currency Symbols + // Range: U+20A0 to U+20CF + + + // Combining Diacritical Marks for Symbols + // Range: U+20D0 to U+20FF + // skip for now + + + // Number Forms + // Range: U+2150 to U+218F + // skip for now + + + // Arrows + // Range: U+2190 to U+21FF + + // Mathematical Operators + // Range: U+2200 to U+22FF + + // Miscellaneous Technical + // Range: U+2300 to U+23FF + + // Control Pictures + // Range: U+2400 to U+243F + + // Optical Character Recognition + // Range: U+2440 to U+245F + + // Enclosed Alphanumerics + // Range: U+2460 to U+24FF + + // Box Drawing + // Range: U+2500 to U+257F + + // Block Elements + // Range: U+2580 to U+259F + + // Geometric Shapes + // Range: U+25A0 to U+25FF + + // Miscellaneous Symbols + // Range: U+2600 to U+26FF + + // Dingbats + // Range: U+2700 to U+27BF + + // CJK Symbols and Punctuation + // Range: U+3000 to U+303F + + // Hiragana + // Range: U+3040 to U+309F + + // Katakana + // Range: U+30A0 to U+30FF + + // Bopomofo + // Range: U+3100 to U+312F + + // Hangul Compatibility Jamo + // Range: U+3130 to U+318F + + // Kanbun + // Range: U+3190 to U+319F + + + // Enclosed CJK Letters and Months + // Range: U+3200 to U+32FF + + // CJK Compatibility + // Range: U+3300 to U+33FF + + // Hangul Syllables + // Range: U+AC00 to U+D7A3 + + // High Surrogates + // Range: U+D800 to U+DB7F + + // Private Use High Surrogates + // Range: U+DB80 to U+DBFF + + // Low Surrogates + // Range: U+DC00 to U+DFFF + + // Private Use Area + // Range: U+E000 to U+F8FF + + // CJK Compatibility Ideographs + // Range: U+F900 to U+FAFF + + // Alphabetic Presentation Forms + // Range: U+FB00 to U+FB4F + + // Arabic Presentation Forms-A + // Range: U+FB50 to U+FDFF + + // Combining Half Marks + // Range: U+FE20 to U+FE2F + + // CJK Compatibility Forms + // Range: U+FE30 to U+FE4F + + // Small Form Variants + // Range: U+FE50 to U+FE6F + + // Arabic Presentation Forms-B + // Range: U+FE70 to U+FEFF + + // Halfwidth and Fullwidth Forms + // Range: U+FF00 to U+FFEF + + if ( c >= 0xFF21 && c <= 0xFF3A ) { + this.upper = c; + this.lower = c + 32; + return this; + } + + if ( c >= 0xFF41 && c <= 0xFF5A ) { + this.upper = c - 32; + this.lower = c; + return this; + } + + // Specials + // Range: U+FFF0 to U+FFFF + + return this; +} + +function DecimalToHexString( n ) { + n = Number( n ); + var h = "0x"; + + for ( var i = 3; i >= 0; i-- ) { + if ( n >= Math.pow(16, i) ){ + var t = Math.floor( n / Math.pow(16, i)); + n -= t * Math.pow(16, i); + if ( t >= 10 ) { + if ( t == 10 ) { + h += "A"; + } + if ( t == 11 ) { + h += "B"; + } + if ( t == 12 ) { + h += "C"; + } + if ( t == 13 ) { + h += "D"; + } + if ( t == 14 ) { + h += "E"; + } + if ( t == 15 ) { + h += "F"; + } + } else { + h += String( t ); + } + } else { + h += "0"; + } + } + + return h; +} diff --git a/tests/auto/qml/parserstress/tests/ecma/String/15.5.4.11-5.js b/tests/auto/qml/parserstress/tests/ecma/String/15.5.4.11-5.js new file mode 100644 index 0000000000..eec6410200 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/String/15.5.4.11-5.js @@ -0,0 +1,520 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.5.4.11-5.js'; + +/** + File Name: 15.5.4.11-5.js + ECMA Section: 15.5.4.11 String.prototype.toLowerCase() + Description: + + Returns a string equal in length to the length of the result of converting + this object to a string. The result is a string value, not a String object. + + Every character of the result is equal to the corresponding character of the + string, unless that character has a Unicode 2.0 uppercase equivalent, in which + case the uppercase equivalent is used instead. (The canonical Unicode 2.0 case + mapping shall be used, which does not depend on implementation or locale.) + + Note that the toLowerCase function is intentionally generic; it does not require + that its this value be a String object. Therefore it can be transferred to other + kinds of objects for use as a method. + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + +var SECTION = "15.5.4.11-5"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "String.prototype.toLowerCase()"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +new TestCase( SECTION, "String.prototype.toLowerCase.length", 0, String.prototype.toLowerCase.length ); + +new TestCase( SECTION, "delete String.prototype.toLowerCase.length", false, delete String.prototype.toLowerCase.length ); + +new TestCase( SECTION, "delete String.prototype.toLowerCase.length; String.prototype.toLowerCase.length", 0, eval("delete String.prototype.toLowerCase.length; String.prototype.toLowerCase.length") ); + +// Cyrillic (part) +// Range: U+0400 to U+04FF +for ( var i = 0x0400; i <= 0x047F; i++ ) { + var U = new Unicode( i ); +/* + new TestCase( SECTION, + "var s = new String( String.fromCharCode("+i+") ); s.toLowerCase()", + String.fromCharCode(U.lower), + eval("var s = new String( String.fromCharCode("+i+") ); s.toLowerCase()") ); +*/ + new TestCase( SECTION, + "var s = new String( String.fromCharCode("+i+") ); s.toLowerCase().charCodeAt(0)", + U.lower, + eval("var s = new String( String.fromCharCode(i) ); s.toLowerCase().charCodeAt(0)") ); +} + +test(); + +function MyObject( value ) { + this.value = value; + this.substring = String.prototype.substring; + this.toString = new Function ( "return this.value+''" ); +} +function Unicode( c ) { + u = GetUnicodeValues( c ); + this.upper = u[0]; + this.lower = u[1] + return this; +} +function GetUnicodeValues( c ) { + u = new Array(); + + u[0] = c; + u[1] = c; + + // upper case Basic Latin + + if ( c >= 0x0041 && c <= 0x005A) { + u[0] = c; + u[1] = c + 32; + return u; + } + + // lower case Basic Latin + if ( c >= 0x0061 && c <= 0x007a ) { + u[0] = c - 32; + u[1] = c; + return u; + } + + // upper case Latin-1 Supplement + if ( (c >= 0x00C0 && c <= 0x00D6) || (c >= 0x00D8 && c<=0x00DE) ) { + u[0] = c; + u[1] = c + 32; + return u; + } + + // lower case Latin-1 Supplement + if ( (c >= 0x00E0 && c <= 0x00F6) || (c >= 0x00F8 && c <= 0x00FE) ) { + u[0] = c - 32; + u[1] = c; + return u; + } + if ( c == 0x00FF ) { + u[0] = 0x0178; + u[1] = c; + return u; + } + // Latin Extended A + if ( (c >= 0x0100 && c < 0x0138) || (c > 0x0149 && c < 0x0178) ) { + // special case for capital I + if ( c == 0x0130 ) { + u[0] = c; + u[1] = 0x0069; + return u; + } + if ( c == 0x0131 ) { + u[0] = 0x0049; + u[1] = c; + return u; + } + + if ( c % 2 == 0 ) { + // if it's even, it's a capital and the lower case is c +1 + u[0] = c; + u[1] = c+1; + } else { + // if it's odd, it's a lower case and upper case is c-1 + u[0] = c-1; + u[1] = c; + } + return u; + } + if ( c == 0x0178 ) { + u[0] = c; + u[1] = 0x00FF; + return u; + } + + if ( (c >= 0x0139 && c < 0x0149) || (c > 0x0178 && c < 0x017F) ) { + if ( c % 2 == 1 ) { + // if it's odd, it's a capital and the lower case is c +1 + u[0] = c; + u[1] = c+1; + } else { + // if it's even, it's a lower case and upper case is c-1 + u[0] = c-1; + u[1] = c; + } + return u; + } + if ( c == 0x017F ) { + u[0] = 0x0053; + u[1] = c; + } + + // Latin Extended B + // need to improve this set + + if ( c >= 0x0200 && c <= 0x0217 ) { + if ( c % 2 == 0 ) { + u[0] = c; + u[1] = c+1; + } else { + u[0] = c-1; + u[1] = c; + } + return u; + } + + // Latin Extended Additional + // Range: U+1E00 to U+1EFF + // http://www.unicode.org/Unicode.charts/glyphless/U1E00.html + + // Spacing Modifier Leters + // Range: U+02B0 to U+02FF + + // Combining Diacritical Marks + // Range: U+0300 to U+036F + + // skip Greek for now + // Greek + // Range: U+0370 to U+03FF + + // Cyrillic + // Range: U+0400 to U+04FF + + if ( (c >= 0x0401 && c <= 0x040C) || ( c>= 0x040E && c <= 0x040F ) ) { + u[0] = c; + u[1] = c + 80; + return u; + } + + + if ( c >= 0x0410 && c <= 0x042F ) { + u[0] = c; + u[1] = c + 32; + return u; + } + + if ( c >= 0x0430 && c<= 0x044F ) { + u[0] = c - 32; + u[1] = c; + return u; + + } + if ( (c >= 0x0451 && c <= 0x045C) || (c >=0x045E && c<= 0x045F) ) { + u[0] = c -80; + u[1] = c; + return u; + } + + if ( c >= 0x0460 && c <= 0x047F ) { + if ( c % 2 == 0 ) { + u[0] = c; + u[1] = c +1; + } else { + u[0] = c - 1; + u[1] = c; + } + return u; + } + + // Armenian + // Range: U+0530 to U+058F + if ( c >= 0x0531 && c <= 0x0556 ) { + u[0] = c; + u[1] = c + 48; + return u; + } + if ( c >= 0x0561 && c < 0x0587 ) { + u[0] = c - 48; + u[1] = c; + return u; + } + + // Hebrew + // Range: U+0590 to U+05FF + + + // Arabic + // Range: U+0600 to U+06FF + + // Devanagari + // Range: U+0900 to U+097F + + + // Bengali + // Range: U+0980 to U+09FF + + + // Gurmukhi + // Range: U+0A00 to U+0A7F + + + // Gujarati + // Range: U+0A80 to U+0AFF + + + // Oriya + // Range: U+0B00 to U+0B7F + // no capital / lower case + + + // Tamil + // Range: U+0B80 to U+0BFF + // no capital / lower case + + + // Telugu + // Range: U+0C00 to U+0C7F + // no capital / lower case + + + // Kannada + // Range: U+0C80 to U+0CFF + // no capital / lower case + + + // Malayalam + // Range: U+0D00 to U+0D7F + + // Thai + // Range: U+0E00 to U+0E7F + + + // Lao + // Range: U+0E80 to U+0EFF + + + // Tibetan + // Range: U+0F00 to U+0FBF + + // Georgian + // Range: U+10A0 to U+10F0 + if ( c >= 0x10A0 && c <= 0x10C5 ) { + u[0] = c; + u[1] = c + 48; + return u; + } + if ( c >= 0x10D0 && c <= 0x10F5 ) { + u[0] = c; + u[1] = c; + return u; + } + + // Hangul Jamo + // Range: U+1100 to U+11FF + + // Greek Extended + // Range: U+1F00 to U+1FFF + // skip for now + + + // General Punctuation + // Range: U+2000 to U+206F + + // Superscripts and Subscripts + // Range: U+2070 to U+209F + + // Currency Symbols + // Range: U+20A0 to U+20CF + + + // Combining Diacritical Marks for Symbols + // Range: U+20D0 to U+20FF + // skip for now + + + // Number Forms + // Range: U+2150 to U+218F + // skip for now + + + // Arrows + // Range: U+2190 to U+21FF + + // Mathematical Operators + // Range: U+2200 to U+22FF + + // Miscellaneous Technical + // Range: U+2300 to U+23FF + + // Control Pictures + // Range: U+2400 to U+243F + + // Optical Character Recognition + // Range: U+2440 to U+245F + + // Enclosed Alphanumerics + // Range: U+2460 to U+24FF + + // Box Drawing + // Range: U+2500 to U+257F + + // Block Elements + // Range: U+2580 to U+259F + + // Geometric Shapes + // Range: U+25A0 to U+25FF + + // Miscellaneous Symbols + // Range: U+2600 to U+26FF + + // Dingbats + // Range: U+2700 to U+27BF + + // CJK Symbols and Punctuation + // Range: U+3000 to U+303F + + // Hiragana + // Range: U+3040 to U+309F + + // Katakana + // Range: U+30A0 to U+30FF + + // Bopomofo + // Range: U+3100 to U+312F + + // Hangul Compatibility Jamo + // Range: U+3130 to U+318F + + // Kanbun + // Range: U+3190 to U+319F + + + // Enclosed CJK Letters and Months + // Range: U+3200 to U+32FF + + // CJK Compatibility + // Range: U+3300 to U+33FF + + // Hangul Syllables + // Range: U+AC00 to U+D7A3 + + // High Surrogates + // Range: U+D800 to U+DB7F + + // Private Use High Surrogates + // Range: U+DB80 to U+DBFF + + // Low Surrogates + // Range: U+DC00 to U+DFFF + + // Private Use Area + // Range: U+E000 to U+F8FF + + // CJK Compatibility Ideographs + // Range: U+F900 to U+FAFF + + // Alphabetic Presentation Forms + // Range: U+FB00 to U+FB4F + + // Arabic Presentation Forms-A + // Range: U+FB50 to U+FDFF + + // Combining Half Marks + // Range: U+FE20 to U+FE2F + + // CJK Compatibility Forms + // Range: U+FE30 to U+FE4F + + // Small Form Variants + // Range: U+FE50 to U+FE6F + + // Arabic Presentation Forms-B + // Range: U+FE70 to U+FEFF + + // Halfwidth and Fullwidth Forms + // Range: U+FF00 to U+FFEF + + if ( c >= 0xFF21 && c <= 0xFF3A ) { + u[0] = c; + u[1] = c + 32; + return u; + } + + if ( c >= 0xFF41 && c <= 0xFF5A ) { + u[0] = c - 32; + u[1] = c; + return u; + } + + // Specials + // Range: U+FFF0 to U+FFFF + + return u; +} + +function DecimalToHexString( n ) { + n = Number( n ); + var h = "0x"; + + for ( var i = 3; i >= 0; i-- ) { + if ( n >= Math.pow(16, i) ){ + var t = Math.floor( n / Math.pow(16, i)); + n -= t * Math.pow(16, i); + if ( t >= 10 ) { + if ( t == 10 ) { + h += "A"; + } + if ( t == 11 ) { + h += "B"; + } + if ( t == 12 ) { + h += "C"; + } + if ( t == 13 ) { + h += "D"; + } + if ( t == 14 ) { + h += "E"; + } + if ( t == 15 ) { + h += "F"; + } + } else { + h += String( t ); + } + } else { + h += "0"; + } + } + + return h; +} diff --git a/tests/auto/qml/parserstress/tests/ecma/String/15.5.4.11-6.js b/tests/auto/qml/parserstress/tests/ecma/String/15.5.4.11-6.js new file mode 100644 index 0000000000..e3cc6039d4 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/String/15.5.4.11-6.js @@ -0,0 +1,516 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.5.4.11-6.js'; + +/** + File Name: 15.5.4.11-6.js + ECMA Section: 15.5.4.11 String.prototype.toLowerCase() + Description: + + Returns a string equal in length to the length of the result of converting + this object to a string. The result is a string value, not a String object. + + Every character of the result is equal to the corresponding character of the + string, unless that character has a Unicode 2.0 uppercase equivalent, in which + case the uppercase equivalent is used instead. (The canonical Unicode 2.0 case + mapping shall be used, which does not depend on implementation or locale.) + + Note that the toLowerCase function is intentionally generic; it does not require + that its this value be a String object. Therefore it can be transferred to other + kinds of objects for use as a method. + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + +var SECTION = "15.5.4.11-6"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "String.prototype.toLowerCase()"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +// Armenian +// Range: U+0530 to U+058F +for ( var i = 0x0530; i <= 0x058F; i++ ) { + + var U = new Unicode( i ); +/* + new TestCase( SECTION, + "var s = new String( String.fromCharCode("+i+") ); s.toLowerCase()", + String.fromCharCode(U.lower), + eval("var s = new String( String.fromCharCode("+i+") ); s.toLowerCase()") ); +*/ + new TestCase( SECTION, + "var s = new String( String.fromCharCode("+i+") ); s.toLowerCase().charCodeAt(0)", + U.lower, + eval("var s = new String( String.fromCharCode(i) ); s.toLowerCase().charCodeAt(0)") ); + +} + +test(); + +function MyObject( value ) { + this.value = value; + this.substring = String.prototype.substring; + this.toString = new Function ( "return this.value+''" ); +} +function Unicode( c ) { + u = GetUnicodeValues( c ); + this.upper = u[0]; + this.lower = u[1] + return this; +} +function GetUnicodeValues( c ) { + u = new Array(); + + u[0] = c; + u[1] = c; + + // upper case Basic Latin + + if ( c >= 0x0041 && c <= 0x005A) { + u[0] = c; + u[1] = c + 32; + return u; + } + + // lower case Basic Latin + if ( c >= 0x0061 && c <= 0x007a ) { + u[0] = c - 32; + u[1] = c; + return u; + } + + // upper case Latin-1 Supplement + if ( (c >= 0x00C0 && c <= 0x00D6) || (c >= 0x00D8 && c<=0x00DE) ) { + u[0] = c; + u[1] = c + 32; + return u; + } + + // lower case Latin-1 Supplement + if ( (c >= 0x00E0 && c <= 0x00F6) || (c >= 0x00F8 && c <= 0x00FE) ) { + u[0] = c - 32; + u[1] = c; + return u; + } + if ( c == 0x00FF ) { + u[0] = 0x0178; + u[1] = c; + return u; + } + // Latin Extended A + if ( (c >= 0x0100 && c < 0x0138) || (c > 0x0149 && c < 0x0178) ) { + // special case for capital I + if ( c == 0x0130 ) { + u[0] = c; + u[1] = 0x0069; + return u; + } + if ( c == 0x0131 ) { + u[0] = 0x0049; + u[1] = c; + return u; + } + + if ( c % 2 == 0 ) { + // if it's even, it's a capital and the lower case is c +1 + u[0] = c; + u[1] = c+1; + } else { + // if it's odd, it's a lower case and upper case is c-1 + u[0] = c-1; + u[1] = c; + } + return u; + } + if ( c == 0x0178 ) { + u[0] = c; + u[1] = 0x00FF; + return u; + } + + if ( (c >= 0x0139 && c < 0x0149) || (c > 0x0178 && c < 0x017F) ) { + if ( c % 2 == 1 ) { + // if it's odd, it's a capital and the lower case is c +1 + u[0] = c; + u[1] = c+1; + } else { + // if it's even, it's a lower case and upper case is c-1 + u[0] = c-1; + u[1] = c; + } + return u; + } + if ( c == 0x017F ) { + u[0] = 0x0053; + u[1] = c; + } + + // Latin Extended B + // need to improve this set + + if ( c >= 0x0200 && c <= 0x0217 ) { + if ( c % 2 == 0 ) { + u[0] = c; + u[1] = c+1; + } else { + u[0] = c-1; + u[1] = c; + } + return u; + } + + // Latin Extended Additional + // Range: U+1E00 to U+1EFF + // http://www.unicode.org/Unicode.charts/glyphless/U1E00.html + + // Spacing Modifier Leters + // Range: U+02B0 to U+02FF + + // Combining Diacritical Marks + // Range: U+0300 to U+036F + + // skip Greek for now + // Greek + // Range: U+0370 to U+03FF + + // Cyrillic + // Range: U+0400 to U+04FF + + if ( (c >= 0x0401 && c <= 0x040C) || ( c>= 0x040E && c <= 0x040F ) ) { + u[0] = c; + u[1] = c + 80; + return u; + } + + + if ( c >= 0x0410 && c <= 0x042F ) { + u[0] = c; + u[1] = c + 32; + return u; + } + + if ( c >= 0x0430 && c<= 0x044F ) { + u[0] = c - 32; + u[1] = c; + return u; + + } + if ( (c >= 0x0451 && c <= 0x045C) || (c >=0x045E && c<= 0x045F) ) { + u[0] = c -80; + u[1] = c; + return u; + } + + if ( c >= 0x0460 && c <= 0x047F ) { + if ( c % 2 == 0 ) { + u[0] = c; + u[1] = c +1; + } else { + u[0] = c - 1; + u[1] = c; + } + return u; + } + + // Armenian + // Range: U+0530 to U+058F + if ( c >= 0x0531 && c <= 0x0556 ) { + u[0] = c; + u[1] = c + 48; + return u; + } + if ( c >= 0x0561 && c < 0x0587 ) { + u[0] = c - 48; + u[1] = c; + return u; + } + + // Hebrew + // Range: U+0590 to U+05FF + + + // Arabic + // Range: U+0600 to U+06FF + + // Devanagari + // Range: U+0900 to U+097F + + + // Bengali + // Range: U+0980 to U+09FF + + + // Gurmukhi + // Range: U+0A00 to U+0A7F + + + // Gujarati + // Range: U+0A80 to U+0AFF + + + // Oriya + // Range: U+0B00 to U+0B7F + // no capital / lower case + + + // Tamil + // Range: U+0B80 to U+0BFF + // no capital / lower case + + + // Telugu + // Range: U+0C00 to U+0C7F + // no capital / lower case + + + // Kannada + // Range: U+0C80 to U+0CFF + // no capital / lower case + + + // Malayalam + // Range: U+0D00 to U+0D7F + + // Thai + // Range: U+0E00 to U+0E7F + + + // Lao + // Range: U+0E80 to U+0EFF + + + // Tibetan + // Range: U+0F00 to U+0FBF + + // Georgian + // Range: U+10A0 to U+10F0 + if ( c >= 0x10A0 && c <= 0x10C5 ) { + u[0] = c; + u[1] = c + 48; + return u; + } + if ( c >= 0x10D0 && c <= 0x10F5 ) { + u[0] = c; + u[1] = c; + return u; + } + + // Hangul Jamo + // Range: U+1100 to U+11FF + + // Greek Extended + // Range: U+1F00 to U+1FFF + // skip for now + + + // General Punctuation + // Range: U+2000 to U+206F + + // Superscripts and Subscripts + // Range: U+2070 to U+209F + + // Currency Symbols + // Range: U+20A0 to U+20CF + + + // Combining Diacritical Marks for Symbols + // Range: U+20D0 to U+20FF + // skip for now + + + // Number Forms + // Range: U+2150 to U+218F + // skip for now + + + // Arrows + // Range: U+2190 to U+21FF + + // Mathematical Operators + // Range: U+2200 to U+22FF + + // Miscellaneous Technical + // Range: U+2300 to U+23FF + + // Control Pictures + // Range: U+2400 to U+243F + + // Optical Character Recognition + // Range: U+2440 to U+245F + + // Enclosed Alphanumerics + // Range: U+2460 to U+24FF + + // Box Drawing + // Range: U+2500 to U+257F + + // Block Elements + // Range: U+2580 to U+259F + + // Geometric Shapes + // Range: U+25A0 to U+25FF + + // Miscellaneous Symbols + // Range: U+2600 to U+26FF + + // Dingbats + // Range: U+2700 to U+27BF + + // CJK Symbols and Punctuation + // Range: U+3000 to U+303F + + // Hiragana + // Range: U+3040 to U+309F + + // Katakana + // Range: U+30A0 to U+30FF + + // Bopomofo + // Range: U+3100 to U+312F + + // Hangul Compatibility Jamo + // Range: U+3130 to U+318F + + // Kanbun + // Range: U+3190 to U+319F + + + // Enclosed CJK Letters and Months + // Range: U+3200 to U+32FF + + // CJK Compatibility + // Range: U+3300 to U+33FF + + // Hangul Syllables + // Range: U+AC00 to U+D7A3 + + // High Surrogates + // Range: U+D800 to U+DB7F + + // Private Use High Surrogates + // Range: U+DB80 to U+DBFF + + // Low Surrogates + // Range: U+DC00 to U+DFFF + + // Private Use Area + // Range: U+E000 to U+F8FF + + // CJK Compatibility Ideographs + // Range: U+F900 to U+FAFF + + // Alphabetic Presentation Forms + // Range: U+FB00 to U+FB4F + + // Arabic Presentation Forms-A + // Range: U+FB50 to U+FDFF + + // Combining Half Marks + // Range: U+FE20 to U+FE2F + + // CJK Compatibility Forms + // Range: U+FE30 to U+FE4F + + // Small Form Variants + // Range: U+FE50 to U+FE6F + + // Arabic Presentation Forms-B + // Range: U+FE70 to U+FEFF + + // Halfwidth and Fullwidth Forms + // Range: U+FF00 to U+FFEF + + if ( c >= 0xFF21 && c <= 0xFF3A ) { + u[0] = c; + u[1] = c + 32; + return u; + } + + if ( c >= 0xFF41 && c <= 0xFF5A ) { + u[0] = c - 32; + u[1] = c; + return u; + } + + // Specials + // Range: U+FFF0 to U+FFFF + + return u; +} + +function DecimalToHexString( n ) { + n = Number( n ); + var h = "0x"; + + for ( var i = 3; i >= 0; i-- ) { + if ( n >= Math.pow(16, i) ){ + var t = Math.floor( n / Math.pow(16, i)); + n -= t * Math.pow(16, i); + if ( t >= 10 ) { + if ( t == 10 ) { + h += "A"; + } + if ( t == 11 ) { + h += "B"; + } + if ( t == 12 ) { + h += "C"; + } + if ( t == 13 ) { + h += "D"; + } + if ( t == 14 ) { + h += "E"; + } + if ( t == 15 ) { + h += "F"; + } + } else { + h += String( t ); + } + } else { + h += "0"; + } + } + + return h; +} diff --git a/tests/auto/qml/parserstress/tests/ecma/String/15.5.4.12-1.js b/tests/auto/qml/parserstress/tests/ecma/String/15.5.4.12-1.js new file mode 100644 index 0000000000..ecc497db48 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/String/15.5.4.12-1.js @@ -0,0 +1,520 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.5.4.12-1.js'; + +/** + File Name: 15.5.4.12-1.js + ECMA Section: 15.5.4.12 String.prototype.toUpperCase() + Description: + + Returns a string equal in length to the length of the result of converting + this object to a string. The result is a string value, not a String object. + + Every character of the result is equal to the corresponding character of the + string, unless that character has a Unicode 2.0 uppercase equivalent, in which + case the uppercase equivalent is used instead. (The canonical Unicode 2.0 case + mapping shall be used, which does not depend on implementation or locale.) + + Note that the toUpperCase function is intentionally generic; it does not require + that its this value be a String object. Therefore it can be transferred to other + kinds of objects for use as a method. + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + +var SECTION = "15.5.4.12-1"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "String.prototype.toUpperCase()"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +new TestCase( SECTION, "String.prototype.toUpperCase.length", 0, String.prototype.toUpperCase.length ); +new TestCase( SECTION, "delete String.prototype.toUpperCase.length", false, delete String.prototype.toUpperCase.length ); +new TestCase( SECTION, "delete String.prototype.toupperCase.length; String.prototype.toupperCase.length", 0, eval("delete String.prototype.toUpperCase.length; String.prototype.toUpperCase.length") ); + +// Basic Latin, Latin-1 Supplement, Latin Extended A +for ( var i = 0; i <= 0x017f; i++ ) { + var U = new Unicode( i ); + + // XXX DF fails in java + + if ( i == 0x00DF ) { + continue; + } + + + new TestCase( SECTION, + "var s = new String( String.fromCharCode("+i+") ); s.toUpperCase().charCodeAt(0)", + U.upper, + eval("var s = new String( String.fromCharCode(i) ); s.toUpperCase().charCodeAt(0)") ); +} + +test(); + + +function MyObject( value ) { + this.value = value; + this.substring = String.prototype.substring; + this.toString = new Function ( "return this.value+''" ); +} +function Unicode( c ) { + u = GetUnicodeValues( c ); + this.upper = u[0]; + this.lower = u[1] + return this; +} +function GetUnicodeValues( c ) { + u = new Array(); + + u[0] = c; + u[1] = c; + + // upper case Basic Latin + + if ( c >= 0x0041 && c <= 0x005A) { + u[0] = c; + u[1] = c + 32; + return u; + } + + // lower case Basic Latin + if ( c >= 0x0061 && c <= 0x007a ) { + u[0] = c - 32; + u[1] = c; + return u; + } + + // upper case Latin-1 Supplement + if ( (c >= 0x00C0 && c <= 0x00D6) || (c >= 0x00D8 && c<=0x00DE) ) { + u[0] = c; + u[1] = c + 32; + return u; + } + + // lower case Latin-1 Supplement + if ( (c >= 0x00E0 && c <= 0x00F6) || (c >= 0x00F8 && c <= 0x00FE) ) { + u[0] = c - 32; + u[1] = c; + return u; + } + if ( c == 0x00FF ) { + u[0] = 0x0178; + u[1] = c; + return u; + } + // Latin Extended A + if ( (c >= 0x0100 && c < 0x0138) || (c > 0x0149 && c < 0x0178) ) { + // special case for capital I + if ( c == 0x0130 ) { + u[0] = c; + u[1] = 0x0069; + return u; + } + if ( c == 0x0131 ) { + u[0] = 0x0049; + u[1] = c; + return u; + } + + if ( c % 2 == 0 ) { + // if it's even, it's a capital and the lower case is c +1 + u[0] = c; + u[1] = c+1; + } else { + // if it's odd, it's a lower case and upper case is c-1 + u[0] = c-1; + u[1] = c; + } + return u; + } + if ( c == 0x0178 ) { + u[0] = c; + u[1] = 0x00FF; + return u; + } + + if ( (c >= 0x0139 && c < 0x0149) || (c > 0x0178 && c < 0x017F) ) { + if ( c % 2 == 1 ) { + // if it's odd, it's a capital and the lower case is c +1 + u[0] = c; + u[1] = c+1; + } else { + // if it's even, it's a lower case and upper case is c-1 + u[0] = c-1; + u[1] = c; + } + return u; + } + if ( c == 0x017F ) { + u[0] = 0x0053; + u[1] = c; + } + + // Latin Extended B + // need to improve this set + + if ( c >= 0x0200 && c <= 0x0217 ) { + if ( c % 2 == 0 ) { + u[0] = c; + u[1] = c+1; + } else { + u[0] = c-1; + u[1] = c; + } + return u; + } + + // Latin Extended Additional + // Range: U+1E00 to U+1EFF + // http://www.unicode.org/Unicode.charts/glyphless/U1E00.html + + // Spacing Modifier Leters + // Range: U+02B0 to U+02FF + + // Combining Diacritical Marks + // Range: U+0300 to U+036F + + // skip Greek for now + // Greek + // Range: U+0370 to U+03FF + + // Cyrillic + // Range: U+0400 to U+04FF + + if ( (c >= 0x0401 && c <= 0x040C) || ( c>= 0x040E && c <= 0x040F ) ) { + u[0] = c; + u[1] = c + 80; + return u; + } + + + if ( c >= 0x0410 && c <= 0x042F ) { + u[0] = c; + u[1] = c + 32; + return u; + } + + if ( c >= 0x0430 && c<= 0x044F ) { + u[0] = c - 32; + u[1] = c; + return u; + + } + if ( (c >= 0x0451 && c <= 0x045C) || (c >=0x045E && c<= 0x045F) ) { + u[0] = c -80; + u[1] = c; + return u; + } + + if ( c >= 0x0460 && c <= 0x047F ) { + if ( c % 2 == 0 ) { + u[0] = c; + u[1] = c +1; + } else { + u[0] = c - 1; + u[1] = c; + } + return u; + } + + // Armenian + // Range: U+0530 to U+058F + if ( c >= 0x0531 && c <= 0x0556 ) { + u[0] = c; + u[1] = c + 48; + return u; + } + if ( c >= 0x0561 && c < 0x0587 ) { + u[0] = c - 48; + u[1] = c; + return u; + } + + // Hebrew + // Range: U+0590 to U+05FF + + + // Arabic + // Range: U+0600 to U+06FF + + // Devanagari + // Range: U+0900 to U+097F + + + // Bengali + // Range: U+0980 to U+09FF + + + // Gurmukhi + // Range: U+0A00 to U+0A7F + + + // Gujarati + // Range: U+0A80 to U+0AFF + + + // Oriya + // Range: U+0B00 to U+0B7F + // no capital / lower case + + + // Tamil + // Range: U+0B80 to U+0BFF + // no capital / lower case + + + // Telugu + // Range: U+0C00 to U+0C7F + // no capital / lower case + + + // Kannada + // Range: U+0C80 to U+0CFF + // no capital / lower case + + + // Malayalam + // Range: U+0D00 to U+0D7F + + // Thai + // Range: U+0E00 to U+0E7F + + + // Lao + // Range: U+0E80 to U+0EFF + + + // Tibetan + // Range: U+0F00 to U+0FBF + + // Georgian + // Range: U+10A0 to U+10F0 + if ( c >= 0x10A0 && c <= 0x10C5 ) { + u[0] = c; + u[1] = c + 48; + return u; + } + if ( c >= 0x10D0 && c <= 0x10F5 ) { + u[0] = c; + u[1] = c; + return u; + } + + // Hangul Jamo + // Range: U+1100 to U+11FF + + // Greek Extended + // Range: U+1F00 to U+1FFF + // skip for now + + + // General Punctuation + // Range: U+2000 to U+206F + + // Superscripts and Subscripts + // Range: U+2070 to U+209F + + // Currency Symbols + // Range: U+20A0 to U+20CF + + + // Combining Diacritical Marks for Symbols + // Range: U+20D0 to U+20FF + // skip for now + + + // Number Forms + // Range: U+2150 to U+218F + // skip for now + + + // Arrows + // Range: U+2190 to U+21FF + + // Mathematical Operators + // Range: U+2200 to U+22FF + + // Miscellaneous Technical + // Range: U+2300 to U+23FF + + // Control Pictures + // Range: U+2400 to U+243F + + // Optical Character Recognition + // Range: U+2440 to U+245F + + // Enclosed Alphanumerics + // Range: U+2460 to U+24FF + + // Box Drawing + // Range: U+2500 to U+257F + + // Block Elements + // Range: U+2580 to U+259F + + // Geometric Shapes + // Range: U+25A0 to U+25FF + + // Miscellaneous Symbols + // Range: U+2600 to U+26FF + + // Dingbats + // Range: U+2700 to U+27BF + + // CJK Symbols and Punctuation + // Range: U+3000 to U+303F + + // Hiragana + // Range: U+3040 to U+309F + + // Katakana + // Range: U+30A0 to U+30FF + + // Bopomofo + // Range: U+3100 to U+312F + + // Hangul Compatibility Jamo + // Range: U+3130 to U+318F + + // Kanbun + // Range: U+3190 to U+319F + + + // Enclosed CJK Letters and Months + // Range: U+3200 to U+32FF + + // CJK Compatibility + // Range: U+3300 to U+33FF + + // Hangul Syllables + // Range: U+AC00 to U+D7A3 + + // High Surrogates + // Range: U+D800 to U+DB7F + + // Private Use High Surrogates + // Range: U+DB80 to U+DBFF + + // Low Surrogates + // Range: U+DC00 to U+DFFF + + // Private Use Area + // Range: U+E000 to U+F8FF + + // CJK Compatibility Ideographs + // Range: U+F900 to U+FAFF + + // Alphabetic Presentation Forms + // Range: U+FB00 to U+FB4F + + // Arabic Presentation Forms-A + // Range: U+FB50 to U+FDFF + + // Combining Half Marks + // Range: U+FE20 to U+FE2F + + // CJK Compatibility Forms + // Range: U+FE30 to U+FE4F + + // Small Form Variants + // Range: U+FE50 to U+FE6F + + // Arabic Presentation Forms-B + // Range: U+FE70 to U+FEFF + + // Halfwidth and Fullwidth Forms + // Range: U+FF00 to U+FFEF + + if ( c >= 0xFF21 && c <= 0xFF3A ) { + u[0] = c; + u[1] = c + 32; + return u; + } + + if ( c >= 0xFF41 && c <= 0xFF5A ) { + u[0] = c - 32; + u[1] = c; + return u; + } + + // Specials + // Range: U+FFF0 to U+FFFF + + return u; +} + +function DecimalToHexString( n ) { + n = Number( n ); + var h = "0x"; + + for ( var i = 3; i >= 0; i-- ) { + if ( n >= Math.pow(16, i) ){ + var t = Math.floor( n / Math.pow(16, i)); + n -= t * Math.pow(16, i); + if ( t >= 10 ) { + if ( t == 10 ) { + h += "A"; + } + if ( t == 11 ) { + h += "B"; + } + if ( t == 12 ) { + h += "C"; + } + if ( t == 13 ) { + h += "D"; + } + if ( t == 14 ) { + h += "E"; + } + if ( t == 15 ) { + h += "F"; + } + } else { + h += String( t ); + } + } else { + h += "0"; + } + } + + return h; +} diff --git a/tests/auto/qml/parserstress/tests/ecma/String/15.5.4.12-2.js b/tests/auto/qml/parserstress/tests/ecma/String/15.5.4.12-2.js new file mode 100644 index 0000000000..c22b87b4dc --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/String/15.5.4.12-2.js @@ -0,0 +1,518 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.5.4.12-2.js'; + +/** + File Name: 15.5.4.12-2.js + ECMA Section: 15.5.4.12 String.prototype.toUpperCase() + Description: + + Returns a string equal in length to the length of the result of converting + this object to a string. The result is a string value, not a String object. + + Every character of the result is equal to the corresponding character of the + string, unless that character has a Unicode 2.0 uppercase equivalent, in which + case the uppercase equivalent is used instead. (The canonical Unicode 2.0 case + mapping shall be used, which does not depend on implementation or locale.) + + Note that the toUpperCase function is intentionally generic; it does not require + that its this value be a String object. Therefore it can be transferred to other + kinds of objects for use as a method. + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + +var SECTION = "15.5.4.12-2"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "String.prototype.toUpperCase()"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +var TEST_STRING = ""; +var EXPECT_STRING = ""; + +// basic latin test + +for ( var i = 0; i < 0x007A; i++ ) { + var u = new Unicode(i); + TEST_STRING += String.fromCharCode(i); + EXPECT_STRING += String.fromCharCode( u.upper ); +} + +// don't print out the value of the strings since they contain control +// characters that break the driver +var isEqual = EXPECT_STRING == (new String( TEST_STRING )).toUpperCase(); + +new TestCase( SECTION, + "isEqual", + true, + isEqual); +test(); + +function MyObject( value ) { + this.value = value; + this.substring = String.prototype.substring; + this.toString = new Function ( "return this.value+''" ); +} +function Unicode( c ) { + u = GetUnicodeValues( c ); + this.upper = u[0]; + this.lower = u[1] + return this; +} +function GetUnicodeValues( c ) { + u = new Array(); + + u[0] = c; + u[1] = c; + + // upper case Basic Latin + + if ( c >= 0x0041 && c <= 0x005A) { + u[0] = c; + u[1] = c + 32; + return u; + } + + // lower case Basic Latin + if ( c >= 0x0061 && c <= 0x007a ) { + u[0] = c - 32; + u[1] = c; + return u; + } + + // upper case Latin-1 Supplement + if ( (c >= 0x00C0 && c <= 0x00D6) || (c >= 0x00D8 && c<=0x00DE) ) { + u[0] = c; + u[1] = c + 32; + return u; + } + + // lower case Latin-1 Supplement + if ( (c >= 0x00E0 && c <= 0x00F6) || (c >= 0x00F8 && c <= 0x00FE) ) { + u[0] = c - 32; + u[1] = c; + return u; + } + if ( c == 0x00FF ) { + u[0] = 0x0178; + u[1] = c; + return u; + } + // Latin Extended A + if ( (c >= 0x0100 && c < 0x0138) || (c > 0x0149 && c < 0x0178) ) { + // special case for capital I + if ( c == 0x0130 ) { + u[0] = c; + u[1] = 0x0069; + return u; + } + if ( c == 0x0131 ) { + u[0] = 0x0049; + u[1] = c; + return u; + } + + if ( c % 2 == 0 ) { + // if it's even, it's a capital and the lower case is c +1 + u[0] = c; + u[1] = c+1; + } else { + // if it's odd, it's a lower case and upper case is c-1 + u[0] = c-1; + u[1] = c; + } + return u; + } + if ( c == 0x0178 ) { + u[0] = c; + u[1] = 0x00FF; + return u; + } + + if ( (c >= 0x0139 && c < 0x0149) || (c > 0x0178 && c < 0x017F) ) { + if ( c % 2 == 1 ) { + // if it's odd, it's a capital and the lower case is c +1 + u[0] = c; + u[1] = c+1; + } else { + // if it's even, it's a lower case and upper case is c-1 + u[0] = c-1; + u[1] = c; + } + return u; + } + if ( c == 0x017F ) { + u[0] = 0x0053; + u[1] = c; + } + + // Latin Extended B + // need to improve this set + + if ( c >= 0x0200 && c <= 0x0217 ) { + if ( c % 2 == 0 ) { + u[0] = c; + u[1] = c+1; + } else { + u[0] = c-1; + u[1] = c; + } + return u; + } + + // Latin Extended Additional + // Range: U+1E00 to U+1EFF + // http://www.unicode.org/Unicode.charts/glyphless/U1E00.html + + // Spacing Modifier Leters + // Range: U+02B0 to U+02FF + + // Combining Diacritical Marks + // Range: U+0300 to U+036F + + // skip Greek for now + // Greek + // Range: U+0370 to U+03FF + + // Cyrillic + // Range: U+0400 to U+04FF + + if ( (c >= 0x0401 && c <= 0x040C) || ( c>= 0x040E && c <= 0x040F ) ) { + u[0] = c; + u[1] = c + 80; + return u; + } + + + if ( c >= 0x0410 && c <= 0x042F ) { + u[0] = c; + u[1] = c + 32; + return u; + } + + if ( c >= 0x0430 && c<= 0x044F ) { + u[0] = c - 32; + u[1] = c; + return u; + + } + if ( (c >= 0x0451 && c <= 0x045C) || (c >=0x045E && c<= 0x045F) ) { + u[0] = c -80; + u[1] = c; + return u; + } + + if ( c >= 0x0460 && c <= 0x047F ) { + if ( c % 2 == 0 ) { + u[0] = c; + u[1] = c +1; + } else { + u[0] = c - 1; + u[1] = c; + } + return u; + } + + // Armenian + // Range: U+0530 to U+058F + if ( c >= 0x0531 && c <= 0x0556 ) { + u[0] = c; + u[1] = c + 48; + return u; + } + if ( c >= 0x0561 && c < 0x0587 ) { + u[0] = c - 48; + u[1] = c; + return u; + } + + // Hebrew + // Range: U+0590 to U+05FF + + + // Arabic + // Range: U+0600 to U+06FF + + // Devanagari + // Range: U+0900 to U+097F + + + // Bengali + // Range: U+0980 to U+09FF + + + // Gurmukhi + // Range: U+0A00 to U+0A7F + + + // Gujarati + // Range: U+0A80 to U+0AFF + + + // Oriya + // Range: U+0B00 to U+0B7F + // no capital / lower case + + + // Tamil + // Range: U+0B80 to U+0BFF + // no capital / lower case + + + // Telugu + // Range: U+0C00 to U+0C7F + // no capital / lower case + + + // Kannada + // Range: U+0C80 to U+0CFF + // no capital / lower case + + + // Malayalam + // Range: U+0D00 to U+0D7F + + // Thai + // Range: U+0E00 to U+0E7F + + + // Lao + // Range: U+0E80 to U+0EFF + + + // Tibetan + // Range: U+0F00 to U+0FBF + + // Georgian + // Range: U+10A0 to U+10F0 + if ( c >= 0x10A0 && c <= 0x10C5 ) { + u[0] = c; + u[1] = c + 48; + return u; + } + if ( c >= 0x10D0 && c <= 0x10F5 ) { + u[0] = c; + u[1] = c; + return u; + } + + // Hangul Jamo + // Range: U+1100 to U+11FF + + // Greek Extended + // Range: U+1F00 to U+1FFF + // skip for now + + + // General Punctuation + // Range: U+2000 to U+206F + + // Superscripts and Subscripts + // Range: U+2070 to U+209F + + // Currency Symbols + // Range: U+20A0 to U+20CF + + + // Combining Diacritical Marks for Symbols + // Range: U+20D0 to U+20FF + // skip for now + + + // Number Forms + // Range: U+2150 to U+218F + // skip for now + + + // Arrows + // Range: U+2190 to U+21FF + + // Mathematical Operators + // Range: U+2200 to U+22FF + + // Miscellaneous Technical + // Range: U+2300 to U+23FF + + // Control Pictures + // Range: U+2400 to U+243F + + // Optical Character Recognition + // Range: U+2440 to U+245F + + // Enclosed Alphanumerics + // Range: U+2460 to U+24FF + + // Box Drawing + // Range: U+2500 to U+257F + + // Block Elements + // Range: U+2580 to U+259F + + // Geometric Shapes + // Range: U+25A0 to U+25FF + + // Miscellaneous Symbols + // Range: U+2600 to U+26FF + + // Dingbats + // Range: U+2700 to U+27BF + + // CJK Symbols and Punctuation + // Range: U+3000 to U+303F + + // Hiragana + // Range: U+3040 to U+309F + + // Katakana + // Range: U+30A0 to U+30FF + + // Bopomofo + // Range: U+3100 to U+312F + + // Hangul Compatibility Jamo + // Range: U+3130 to U+318F + + // Kanbun + // Range: U+3190 to U+319F + + + // Enclosed CJK Letters and Months + // Range: U+3200 to U+32FF + + // CJK Compatibility + // Range: U+3300 to U+33FF + + // Hangul Syllables + // Range: U+AC00 to U+D7A3 + + // High Surrogates + // Range: U+D800 to U+DB7F + + // Private Use High Surrogates + // Range: U+DB80 to U+DBFF + + // Low Surrogates + // Range: U+DC00 to U+DFFF + + // Private Use Area + // Range: U+E000 to U+F8FF + + // CJK Compatibility Ideographs + // Range: U+F900 to U+FAFF + + // Alphabetic Presentation Forms + // Range: U+FB00 to U+FB4F + + // Arabic Presentation Forms-A + // Range: U+FB50 to U+FDFF + + // Combining Half Marks + // Range: U+FE20 to U+FE2F + + // CJK Compatibility Forms + // Range: U+FE30 to U+FE4F + + // Small Form Variants + // Range: U+FE50 to U+FE6F + + // Arabic Presentation Forms-B + // Range: U+FE70 to U+FEFF + + // Halfwidth and Fullwidth Forms + // Range: U+FF00 to U+FFEF + + if ( c >= 0xFF21 && c <= 0xFF3A ) { + u[0] = c; + u[1] = c + 32; + return u; + } + + if ( c >= 0xFF41 && c <= 0xFF5A ) { + u[0] = c - 32; + u[1] = c; + return u; + } + + // Specials + // Range: U+FFF0 to U+FFFF + + return u; +} + +function DecimalToHexString( n ) { + n = Number( n ); + var h = "0x"; + + for ( var i = 3; i >= 0; i-- ) { + if ( n >= Math.pow(16, i) ){ + var t = Math.floor( n / Math.pow(16, i)); + n -= t * Math.pow(16, i); + if ( t >= 10 ) { + if ( t == 10 ) { + h += "A"; + } + if ( t == 11 ) { + h += "B"; + } + if ( t == 12 ) { + h += "C"; + } + if ( t == 13 ) { + h += "D"; + } + if ( t == 14 ) { + h += "E"; + } + if ( t == 15 ) { + h += "F"; + } + } else { + h += String( t ); + } + } else { + h += "0"; + } + } + + return h; +} + diff --git a/tests/auto/qml/parserstress/tests/ecma/String/15.5.4.12-3.js b/tests/auto/qml/parserstress/tests/ecma/String/15.5.4.12-3.js new file mode 100644 index 0000000000..d9d8bc69ce --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/String/15.5.4.12-3.js @@ -0,0 +1,559 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.5.4.12-3.js'; + +/** + File Name: 15.5.4.12-3.js + ECMA Section: 15.5.4.12 String.prototype.toUpperCase() + Description: + + Returns a string equal in length to the length of the result of converting + this object to a string. The result is a string value, not a String object. + + Every character of the result is equal to the corresponding character of the + string, unless that character has a Unicode 2.0 uppercase equivalent, in which + case the uppercase equivalent is used instead. (The canonical Unicode 2.0 case + mapping shall be used, which does not depend on implementation or locale.) + + Note that the toUpperCase function is intentionally generic; it does not require + that its this value be a String object. Therefore it can be transferred to other + kinds of objects for use as a method. + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + +var SECTION = "15.5.4.12-3"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "String.prototype.toUpperCase()"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +// Georgian +// Range: U+10A0 to U+10FF +for ( var i = 0x10A0; i <= 0x10FF; i++ ) { + var U = new Unicode( i ); +/* + new TestCase( SECTION, + "var s = new String( String.fromCharCode("+i+") ); s.toUpperCase()", + String.fromCharCode(U.upper), + eval("var s = new String( String.fromCharCode("+i+") ); s.toUpperCase()") ); +*/ + new TestCase( SECTION, + "var s = new String( String.fromCharCode("+i+") ); s.toUpperCase().charCodeAt(0)", + U.upper, + eval("var s = new String( String.fromCharCode(i) ); s.toUpperCase().charCodeAt(0)") ); + +} + +// Halfwidth and Fullwidth Forms +// Range: U+FF00 to U+FFEF +for ( var i = 0xFF00; i <= 0xFFEF; i++ ) { + new TestCase( SECTION, + "var s = new String( String.fromCharCode("+i+") ); s.toUpperCase()", + eval( "var u = new Unicode( i ); String.fromCharCode(u.upper)" ), + eval("var s = new String( String.fromCharCode("+i+") ); s.toUpperCase()") ); + + new TestCase( SECTION, + "var s = new String( String.fromCharCode("+i+") ); s.toUpperCase().charCodeAt(0)", + eval( "var u = new Unicode( i ); u.upper" ), + eval("var s = new String( String.fromCharCode("+i+") ); s.toUpperCase().charCodeAt(0)") ); +} + +// Hiragana (no upper / lower case) +// Range: U+3040 to U+309F + +for ( var i = 0x3040; i <= 0x309F; i++ ) { + new TestCase( SECTION, + "var s = new String( String.fromCharCode("+i+") ); s.toUpperCase()", + eval( "var u = new Unicode( i ); String.fromCharCode(u.upper)" ), + eval("var s = new String( String.fromCharCode("+i+") ); s.toUpperCase()") ); + + new TestCase( SECTION, + "var s = new String( String.fromCharCode("+i+") ); s.toUpperCase().charCodeAt(0)", + eval( "var u = new Unicode( i ); u.upper" ), + eval("var s = new String( String.fromCharCode("+i+") ); s.toUpperCase().charCodeAt(0)") ); +} + + +/* + var TEST_STRING = ""; + var EXPECT_STRING = ""; + + // basic latin test + + for ( var i = 0; i < 0x007A; i++ ) { + var u = new Unicode(i); + TEST_STRING += String.fromCharCode(i); + EXPECT_STRING += String.fromCharCode( u.upper ); + } +*/ + + +test(); + +function MyObject( value ) { + this.value = value; + this.substring = String.prototype.substring; + this.toString = new Function ( "return this.value+''" ); +} +function Unicode( c ) { + u = GetUnicodeValues( c ); + this.upper = u[0]; + this.lower = u[1] + return this; +} +function GetUnicodeValues( c ) { + u = new Array(); + + u[0] = c; + u[1] = c; + + // upper case Basic Latin + + if ( c >= 0x0041 && c <= 0x005A) { + u[0] = c; + u[1] = c + 32; + return u; + } + + // lower case Basic Latin + if ( c >= 0x0061 && c <= 0x007a ) { + u[0] = c - 32; + u[1] = c; + return u; + } + + // upper case Latin-1 Supplement + if ( (c >= 0x00C0 && c <= 0x00D6) || (c >= 0x00D8 && c<=0x00DE) ) { + u[0] = c; + u[1] = c + 32; + return u; + } + + // lower case Latin-1 Supplement + if ( (c >= 0x00E0 && c <= 0x00F6) || (c >= 0x00F8 && c <= 0x00FE) ) { + u[0] = c - 32; + u[1] = c; + return u; + } + if ( c == 0x00FF ) { + u[0] = 0x0178; + u[1] = c; + return u; + } + // Latin Extended A + if ( (c >= 0x0100 && c < 0x0138) || (c > 0x0149 && c < 0x0178) ) { + // special case for capital I + if ( c == 0x0130 ) { + u[0] = c; + u[1] = 0x0069; + return u; + } + if ( c == 0x0131 ) { + u[0] = 0x0049; + u[1] = c; + return u; + } + + if ( c % 2 == 0 ) { + // if it's even, it's a capital and the lower case is c +1 + u[0] = c; + u[1] = c+1; + } else { + // if it's odd, it's a lower case and upper case is c-1 + u[0] = c-1; + u[1] = c; + } + return u; + } + if ( c == 0x0178 ) { + u[0] = c; + u[1] = 0x00FF; + return u; + } + + if ( (c >= 0x0139 && c < 0x0149) || (c > 0x0178 && c < 0x017F) ) { + if ( c % 2 == 1 ) { + // if it's odd, it's a capital and the lower case is c +1 + u[0] = c; + u[1] = c+1; + } else { + // if it's even, it's a lower case and upper case is c-1 + u[0] = c-1; + u[1] = c; + } + return u; + } + if ( c == 0x017F ) { + u[0] = 0x0053; + u[1] = c; + } + + // Latin Extended B + // need to improve this set + + if ( c >= 0x0200 && c <= 0x0217 ) { + if ( c % 2 == 0 ) { + u[0] = c; + u[1] = c+1; + } else { + u[0] = c-1; + u[1] = c; + } + return u; + } + + // Latin Extended Additional + // Range: U+1E00 to U+1EFF + // http://www.unicode.org/Unicode.charts/glyphless/U1E00.html + + // Spacing Modifier Leters + // Range: U+02B0 to U+02FF + + // Combining Diacritical Marks + // Range: U+0300 to U+036F + + // skip Greek for now + // Greek + // Range: U+0370 to U+03FF + + // Cyrillic + // Range: U+0400 to U+04FF + + if ( (c >= 0x0401 && c <= 0x040C) || ( c>= 0x040E && c <= 0x040F ) ) { + u[0] = c; + u[1] = c + 80; + return u; + } + + + if ( c >= 0x0410 && c <= 0x042F ) { + u[0] = c; + u[1] = c + 32; + return u; + } + + if ( c >= 0x0430 && c<= 0x044F ) { + u[0] = c - 32; + u[1] = c; + return u; + + } + if ( (c >= 0x0451 && c <= 0x045C) || (c >=0x045E && c<= 0x045F) ) { + u[0] = c -80; + u[1] = c; + return u; + } + + if ( c >= 0x0460 && c <= 0x047F ) { + if ( c % 2 == 0 ) { + u[0] = c; + u[1] = c +1; + } else { + u[0] = c - 1; + u[1] = c; + } + return u; + } + + // Armenian + // Range: U+0530 to U+058F + if ( c >= 0x0531 && c <= 0x0556 ) { + u[0] = c; + u[1] = c + 48; + return u; + } + if ( c >= 0x0561 && c < 0x0587 ) { + u[0] = c - 48; + u[1] = c; + return u; + } + + // Hebrew + // Range: U+0590 to U+05FF + + + // Arabic + // Range: U+0600 to U+06FF + + // Devanagari + // Range: U+0900 to U+097F + + + // Bengali + // Range: U+0980 to U+09FF + + + // Gurmukhi + // Range: U+0A00 to U+0A7F + + + // Gujarati + // Range: U+0A80 to U+0AFF + + + // Oriya + // Range: U+0B00 to U+0B7F + // no capital / lower case + + + // Tamil + // Range: U+0B80 to U+0BFF + // no capital / lower case + + + // Telugu + // Range: U+0C00 to U+0C7F + // no capital / lower case + + + // Kannada + // Range: U+0C80 to U+0CFF + // no capital / lower case + + + // Malayalam + // Range: U+0D00 to U+0D7F + + // Thai + // Range: U+0E00 to U+0E7F + + + // Lao + // Range: U+0E80 to U+0EFF + + + // Tibetan + // Range: U+0F00 to U+0FBF + + // Georgian + // Range: U+10A0 to U+10F0 + if ( c >= 0x10A0 && c <= 0x10C5 ) { + u[0] = c; + u[1] = c + 48; + return u; + } + if ( c >= 0x10D0 && c <= 0x10F5 ) { + u[0] = c; + u[1] = c; + return u; + } + + // Hangul Jamo + // Range: U+1100 to U+11FF + + // Greek Extended + // Range: U+1F00 to U+1FFF + // skip for now + + + // General Punctuation + // Range: U+2000 to U+206F + + // Superscripts and Subscripts + // Range: U+2070 to U+209F + + // Currency Symbols + // Range: U+20A0 to U+20CF + + + // Combining Diacritical Marks for Symbols + // Range: U+20D0 to U+20FF + // skip for now + + + // Number Forms + // Range: U+2150 to U+218F + // skip for now + + + // Arrows + // Range: U+2190 to U+21FF + + // Mathematical Operators + // Range: U+2200 to U+22FF + + // Miscellaneous Technical + // Range: U+2300 to U+23FF + + // Control Pictures + // Range: U+2400 to U+243F + + // Optical Character Recognition + // Range: U+2440 to U+245F + + // Enclosed Alphanumerics + // Range: U+2460 to U+24FF + + // Box Drawing + // Range: U+2500 to U+257F + + // Block Elements + // Range: U+2580 to U+259F + + // Geometric Shapes + // Range: U+25A0 to U+25FF + + // Miscellaneous Symbols + // Range: U+2600 to U+26FF + + // Dingbats + // Range: U+2700 to U+27BF + + // CJK Symbols and Punctuation + // Range: U+3000 to U+303F + + // Hiragana + // Range: U+3040 to U+309F + + // Katakana + // Range: U+30A0 to U+30FF + + // Bopomofo + // Range: U+3100 to U+312F + + // Hangul Compatibility Jamo + // Range: U+3130 to U+318F + + // Kanbun + // Range: U+3190 to U+319F + + + // Enclosed CJK Letters and Months + // Range: U+3200 to U+32FF + + // CJK Compatibility + // Range: U+3300 to U+33FF + + // Hangul Syllables + // Range: U+AC00 to U+D7A3 + + // High Surrogates + // Range: U+D800 to U+DB7F + + // Private Use High Surrogates + // Range: U+DB80 to U+DBFF + + // Low Surrogates + // Range: U+DC00 to U+DFFF + + // Private Use Area + // Range: U+E000 to U+F8FF + + // CJK Compatibility Ideographs + // Range: U+F900 to U+FAFF + + // Alphabetic Presentation Forms + // Range: U+FB00 to U+FB4F + + // Arabic Presentation Forms-A + // Range: U+FB50 to U+FDFF + + // Combining Half Marks + // Range: U+FE20 to U+FE2F + + // CJK Compatibility Forms + // Range: U+FE30 to U+FE4F + + // Small Form Variants + // Range: U+FE50 to U+FE6F + + // Arabic Presentation Forms-B + // Range: U+FE70 to U+FEFF + + // Halfwidth and Fullwidth Forms + // Range: U+FF00 to U+FFEF + + if ( c >= 0xFF21 && c <= 0xFF3A ) { + u[0] = c; + u[1] = c + 32; + return u; + } + + if ( c >= 0xFF41 && c <= 0xFF5A ) { + u[0] = c - 32; + u[1] = c; + return u; + } + + // Specials + // Range: U+FFF0 to U+FFFF + + return u; +} + +function DecimalToHexString( n ) { + n = Number( n ); + var h = "0x"; + + for ( var i = 3; i >= 0; i-- ) { + if ( n >= Math.pow(16, i) ){ + var t = Math.floor( n / Math.pow(16, i)); + n -= t * Math.pow(16, i); + if ( t >= 10 ) { + if ( t == 10 ) { + h += "A"; + } + if ( t == 11 ) { + h += "B"; + } + if ( t == 12 ) { + h += "C"; + } + if ( t == 13 ) { + h += "D"; + } + if ( t == 14 ) { + h += "E"; + } + if ( t == 15 ) { + h += "F"; + } + } else { + h += String( t ); + } + } else { + h += "0"; + } + } + + return h; +} diff --git a/tests/auto/qml/parserstress/tests/ecma/String/15.5.4.12-4.js b/tests/auto/qml/parserstress/tests/ecma/String/15.5.4.12-4.js new file mode 100644 index 0000000000..caf5663f07 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/String/15.5.4.12-4.js @@ -0,0 +1,515 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.5.4.12-4.js'; + +/** + File Name: 15.5.4.12-1.js + ECMA Section: 15.5.4.12 String.prototype.toUpperCase() + Description: + + Returns a string equal in length to the length of the result of converting + this object to a string. The result is a string value, not a String object. + + Every character of the result is equal to the corresponding character of the + string, unless that character has a Unicode 2.0 uppercase equivalent, in which + case the uppercase equivalent is used instead. (The canonical Unicode 2.0 case + mapping shall be used, which does not depend on implementation or locale.) + + Note that the toUpperCase function is intentionally generic; it does not require + that its this value be a String object. Therefore it can be transferred to other + kinds of objects for use as a method. + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + +var SECTION = "15.5.4.12-1"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "String.prototype.toUpperCase()"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +// Cyrillic (part) +// Range: U+0400 to U+04FF +for ( var i = 0x0400; i <= 0x047F; i++ ) { + var U =new Unicode( i ); +/* + new TestCase( SECTION, + "var s = new String( String.fromCharCode("+i+") ); s.toUpperCase()", + U.upper, + eval("var s = new String( String.fromCharCode("+i+") ); s.toUpperCase()") ); +*/ + new TestCase( SECTION, + "var s = new String( String.fromCharCode("+i+") ); s.toUpperCase().charCodeAt(0)", + U.upper, + eval("var s = new String( String.fromCharCode(i) ); s.toUpperCase().charCodeAt(0)") ); + +} + +test(); + +function MyObject( value ) { + this.value = value; + this.substring = String.prototype.substring; + this.toString = new Function ( "return this.value+''" ); +} +function Unicode( c ) { + u = GetUnicodeValues( c ); + this.upper = u[0]; + this.lower = u[1] + return this; +} +function GetUnicodeValues( c ) { + u = new Array(); + + u[0] = c; + u[1] = c; + + // upper case Basic Latin + + if ( c >= 0x0041 && c <= 0x005A) { + u[0] = c; + u[1] = c + 32; + return u; + } + + // lower case Basic Latin + if ( c >= 0x0061 && c <= 0x007a ) { + u[0] = c - 32; + u[1] = c; + return u; + } + + // upper case Latin-1 Supplement + if ( (c >= 0x00C0 && c <= 0x00D6) || (c >= 0x00D8 && c<=0x00DE) ) { + u[0] = c; + u[1] = c + 32; + return u; + } + + // lower case Latin-1 Supplement + if ( (c >= 0x00E0 && c <= 0x00F6) || (c >= 0x00F8 && c <= 0x00FE) ) { + u[0] = c - 32; + u[1] = c; + return u; + } + if ( c == 0x00FF ) { + u[0] = 0x0178; + u[1] = c; + return u; + } + // Latin Extended A + if ( (c >= 0x0100 && c < 0x0138) || (c > 0x0149 && c < 0x0178) ) { + // special case for capital I + if ( c == 0x0130 ) { + u[0] = c; + u[1] = 0x0069; + return u; + } + if ( c == 0x0131 ) { + u[0] = 0x0049; + u[1] = c; + return u; + } + + if ( c % 2 == 0 ) { + // if it's even, it's a capital and the lower case is c +1 + u[0] = c; + u[1] = c+1; + } else { + // if it's odd, it's a lower case and upper case is c-1 + u[0] = c-1; + u[1] = c; + } + return u; + } + if ( c == 0x0178 ) { + u[0] = c; + u[1] = 0x00FF; + return u; + } + + if ( (c >= 0x0139 && c < 0x0149) || (c > 0x0178 && c < 0x017F) ) { + if ( c % 2 == 1 ) { + // if it's odd, it's a capital and the lower case is c +1 + u[0] = c; + u[1] = c+1; + } else { + // if it's even, it's a lower case and upper case is c-1 + u[0] = c-1; + u[1] = c; + } + return u; + } + if ( c == 0x017F ) { + u[0] = 0x0053; + u[1] = c; + } + + // Latin Extended B + // need to improve this set + + if ( c >= 0x0200 && c <= 0x0217 ) { + if ( c % 2 == 0 ) { + u[0] = c; + u[1] = c+1; + } else { + u[0] = c-1; + u[1] = c; + } + return u; + } + + // Latin Extended Additional + // Range: U+1E00 to U+1EFF + // http://www.unicode.org/Unicode.charts/glyphless/U1E00.html + + // Spacing Modifier Leters + // Range: U+02B0 to U+02FF + + // Combining Diacritical Marks + // Range: U+0300 to U+036F + + // skip Greek for now + // Greek + // Range: U+0370 to U+03FF + + // Cyrillic + // Range: U+0400 to U+04FF + + if ( (c >= 0x0401 && c <= 0x040C) || ( c>= 0x040E && c <= 0x040F ) ) { + u[0] = c; + u[1] = c + 80; + return u; + } + + + if ( c >= 0x0410 && c <= 0x042F ) { + u[0] = c; + u[1] = c + 32; + return u; + } + + if ( c >= 0x0430 && c<= 0x044F ) { + u[0] = c - 32; + u[1] = c; + return u; + + } + if ( (c >= 0x0451 && c <= 0x045C) || (c >=0x045E && c<= 0x045F) ) { + u[0] = c -80; + u[1] = c; + return u; + } + + if ( c >= 0x0460 && c <= 0x047F ) { + if ( c % 2 == 0 ) { + u[0] = c; + u[1] = c +1; + } else { + u[0] = c - 1; + u[1] = c; + } + return u; + } + + // Armenian + // Range: U+0530 to U+058F + if ( c >= 0x0531 && c <= 0x0556 ) { + u[0] = c; + u[1] = c + 48; + return u; + } + if ( c >= 0x0561 && c < 0x0587 ) { + u[0] = c - 48; + u[1] = c; + return u; + } + + // Hebrew + // Range: U+0590 to U+05FF + + + // Arabic + // Range: U+0600 to U+06FF + + // Devanagari + // Range: U+0900 to U+097F + + + // Bengali + // Range: U+0980 to U+09FF + + + // Gurmukhi + // Range: U+0A00 to U+0A7F + + + // Gujarati + // Range: U+0A80 to U+0AFF + + + // Oriya + // Range: U+0B00 to U+0B7F + // no capital / lower case + + + // Tamil + // Range: U+0B80 to U+0BFF + // no capital / lower case + + + // Telugu + // Range: U+0C00 to U+0C7F + // no capital / lower case + + + // Kannada + // Range: U+0C80 to U+0CFF + // no capital / lower case + + + // Malayalam + // Range: U+0D00 to U+0D7F + + // Thai + // Range: U+0E00 to U+0E7F + + + // Lao + // Range: U+0E80 to U+0EFF + + + // Tibetan + // Range: U+0F00 to U+0FBF + + // Georgian + // Range: U+10A0 to U+10F0 + if ( c >= 0x10A0 && c <= 0x10C5 ) { + u[0] = c; + u[1] = c + 48; + return u; + } + if ( c >= 0x10D0 && c <= 0x10F5 ) { + u[0] = c; + u[1] = c; + return u; + } + + // Hangul Jamo + // Range: U+1100 to U+11FF + + // Greek Extended + // Range: U+1F00 to U+1FFF + // skip for now + + + // General Punctuation + // Range: U+2000 to U+206F + + // Superscripts and Subscripts + // Range: U+2070 to U+209F + + // Currency Symbols + // Range: U+20A0 to U+20CF + + + // Combining Diacritical Marks for Symbols + // Range: U+20D0 to U+20FF + // skip for now + + + // Number Forms + // Range: U+2150 to U+218F + // skip for now + + + // Arrows + // Range: U+2190 to U+21FF + + // Mathematical Operators + // Range: U+2200 to U+22FF + + // Miscellaneous Technical + // Range: U+2300 to U+23FF + + // Control Pictures + // Range: U+2400 to U+243F + + // Optical Character Recognition + // Range: U+2440 to U+245F + + // Enclosed Alphanumerics + // Range: U+2460 to U+24FF + + // Box Drawing + // Range: U+2500 to U+257F + + // Block Elements + // Range: U+2580 to U+259F + + // Geometric Shapes + // Range: U+25A0 to U+25FF + + // Miscellaneous Symbols + // Range: U+2600 to U+26FF + + // Dingbats + // Range: U+2700 to U+27BF + + // CJK Symbols and Punctuation + // Range: U+3000 to U+303F + + // Hiragana + // Range: U+3040 to U+309F + + // Katakana + // Range: U+30A0 to U+30FF + + // Bopomofo + // Range: U+3100 to U+312F + + // Hangul Compatibility Jamo + // Range: U+3130 to U+318F + + // Kanbun + // Range: U+3190 to U+319F + + + // Enclosed CJK Letters and Months + // Range: U+3200 to U+32FF + + // CJK Compatibility + // Range: U+3300 to U+33FF + + // Hangul Syllables + // Range: U+AC00 to U+D7A3 + + // High Surrogates + // Range: U+D800 to U+DB7F + + // Private Use High Surrogates + // Range: U+DB80 to U+DBFF + + // Low Surrogates + // Range: U+DC00 to U+DFFF + + // Private Use Area + // Range: U+E000 to U+F8FF + + // CJK Compatibility Ideographs + // Range: U+F900 to U+FAFF + + // Alphabetic Presentation Forms + // Range: U+FB00 to U+FB4F + + // Arabic Presentation Forms-A + // Range: U+FB50 to U+FDFF + + // Combining Half Marks + // Range: U+FE20 to U+FE2F + + // CJK Compatibility Forms + // Range: U+FE30 to U+FE4F + + // Small Form Variants + // Range: U+FE50 to U+FE6F + + // Arabic Presentation Forms-B + // Range: U+FE70 to U+FEFF + + // Halfwidth and Fullwidth Forms + // Range: U+FF00 to U+FFEF + + if ( c >= 0xFF21 && c <= 0xFF3A ) { + u[0] = c; + u[1] = c + 32; + return u; + } + + if ( c >= 0xFF41 && c <= 0xFF5A ) { + u[0] = c - 32; + u[1] = c; + return u; + } + + // Specials + // Range: U+FFF0 to U+FFFF + + return u; +} + +function DecimalToHexString( n ) { + n = Number( n ); + var h = "0x"; + + for ( var i = 3; i >= 0; i-- ) { + if ( n >= Math.pow(16, i) ){ + var t = Math.floor( n / Math.pow(16, i)); + n -= t * Math.pow(16, i); + if ( t >= 10 ) { + if ( t == 10 ) { + h += "A"; + } + if ( t == 11 ) { + h += "B"; + } + if ( t == 12 ) { + h += "C"; + } + if ( t == 13 ) { + h += "D"; + } + if ( t == 14 ) { + h += "E"; + } + if ( t == 15 ) { + h += "F"; + } + } else { + h += String( t ); + } + } else { + h += "0"; + } + } + + return h; +} diff --git a/tests/auto/qml/parserstress/tests/ecma/String/15.5.4.12-5.js b/tests/auto/qml/parserstress/tests/ecma/String/15.5.4.12-5.js new file mode 100644 index 0000000000..2fbed42202 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/String/15.5.4.12-5.js @@ -0,0 +1,515 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.5.4.12-5.js'; + +/** + File Name: 15.5.4.12-1.js + ECMA Section: 15.5.4.12 String.prototype.toUpperCase() + Description: + + Returns a string equal in length to the length of the result of converting + this object to a string. The result is a string value, not a String object. + + Every character of the result is equal to the corresponding character of the + string, unless that character has a Unicode 2.0 uppercase equivalent, in which + case the uppercase equivalent is used instead. (The canonical Unicode 2.0 case + mapping shall be used, which does not depend on implementation or locale.) + + Note that the toUpperCase function is intentionally generic; it does not require + that its this value be a String object. Therefore it can be transferred to other + kinds of objects for use as a method. + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + +var SECTION = "15.5.4.12-1"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "String.prototype.toUpperCase()"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +// Armenian +// Range: U+0530 to U+058F +for ( var i = 0x0530; i <= 0x058F; i++ ) { + var U = new Unicode( i ); +/* + new TestCase( SECTION, + "var s = new String( String.fromCharCode("+i+") ); s.toUpperCase()", + String.fromCharCode(U.upper), + eval("var s = new String( String.fromCharCode("+i+") ); s.toUpperCase()") ); +*/ + new TestCase( SECTION, + "var s = new String( String.fromCharCode("+i+") ); s.toUpperCase().charCodeAt(0)", + U.upper, + eval("var s = new String( String.fromCharCode(i) ); s.toUpperCase().charCodeAt(0)") ); + +} + +test(); + +function MyObject( value ) { + this.value = value; + this.substring = String.prototype.substring; + this.toString = new Function ( "return this.value+''" ); +} +function Unicode( c ) { + u = GetUnicodeValues( c ); + this.upper = u[0]; + this.lower = u[1] + return this; +} +function GetUnicodeValues( c ) { + u = new Array(); + + u[0] = c; + u[1] = c; + + // upper case Basic Latin + + if ( c >= 0x0041 && c <= 0x005A) { + u[0] = c; + u[1] = c + 32; + return u; + } + + // lower case Basic Latin + if ( c >= 0x0061 && c <= 0x007a ) { + u[0] = c - 32; + u[1] = c; + return u; + } + + // upper case Latin-1 Supplement + if ( (c >= 0x00C0 && c <= 0x00D6) || (c >= 0x00D8 && c<=0x00DE) ) { + u[0] = c; + u[1] = c + 32; + return u; + } + + // lower case Latin-1 Supplement + if ( (c >= 0x00E0 && c <= 0x00F6) || (c >= 0x00F8 && c <= 0x00FE) ) { + u[0] = c - 32; + u[1] = c; + return u; + } + if ( c == 0x00FF ) { + u[0] = 0x0178; + u[1] = c; + return u; + } + // Latin Extended A + if ( (c >= 0x0100 && c < 0x0138) || (c > 0x0149 && c < 0x0178) ) { + // special case for capital I + if ( c == 0x0130 ) { + u[0] = c; + u[1] = 0x0069; + return u; + } + if ( c == 0x0131 ) { + u[0] = 0x0049; + u[1] = c; + return u; + } + + if ( c % 2 == 0 ) { + // if it's even, it's a capital and the lower case is c +1 + u[0] = c; + u[1] = c+1; + } else { + // if it's odd, it's a lower case and upper case is c-1 + u[0] = c-1; + u[1] = c; + } + return u; + } + if ( c == 0x0178 ) { + u[0] = c; + u[1] = 0x00FF; + return u; + } + + if ( (c >= 0x0139 && c < 0x0149) || (c > 0x0178 && c < 0x017F) ) { + if ( c % 2 == 1 ) { + // if it's odd, it's a capital and the lower case is c +1 + u[0] = c; + u[1] = c+1; + } else { + // if it's even, it's a lower case and upper case is c-1 + u[0] = c-1; + u[1] = c; + } + return u; + } + if ( c == 0x017F ) { + u[0] = 0x0053; + u[1] = c; + } + + // Latin Extended B + // need to improve this set + + if ( c >= 0x0200 && c <= 0x0217 ) { + if ( c % 2 == 0 ) { + u[0] = c; + u[1] = c+1; + } else { + u[0] = c-1; + u[1] = c; + } + return u; + } + + // Latin Extended Additional + // Range: U+1E00 to U+1EFF + // http://www.unicode.org/Unicode.charts/glyphless/U1E00.html + + // Spacing Modifier Leters + // Range: U+02B0 to U+02FF + + // Combining Diacritical Marks + // Range: U+0300 to U+036F + + // skip Greek for now + // Greek + // Range: U+0370 to U+03FF + + // Cyrillic + // Range: U+0400 to U+04FF + + if ( (c >= 0x0401 && c <= 0x040C) || ( c>= 0x040E && c <= 0x040F ) ) { + u[0] = c; + u[1] = c + 80; + return u; + } + + + if ( c >= 0x0410 && c <= 0x042F ) { + u[0] = c; + u[1] = c + 32; + return u; + } + + if ( c >= 0x0430 && c<= 0x044F ) { + u[0] = c - 32; + u[1] = c; + return u; + + } + if ( (c >= 0x0451 && c <= 0x045C) || (c >=0x045E && c<= 0x045F) ) { + u[0] = c -80; + u[1] = c; + return u; + } + + if ( c >= 0x0460 && c <= 0x047F ) { + if ( c % 2 == 0 ) { + u[0] = c; + u[1] = c +1; + } else { + u[0] = c - 1; + u[1] = c; + } + return u; + } + + // Armenian + // Range: U+0530 to U+058F + if ( c >= 0x0531 && c <= 0x0556 ) { + u[0] = c; + u[1] = c + 48; + return u; + } + if ( c >= 0x0561 && c < 0x0587 ) { + u[0] = c - 48; + u[1] = c; + return u; + } + + // Hebrew + // Range: U+0590 to U+05FF + + + // Arabic + // Range: U+0600 to U+06FF + + // Devanagari + // Range: U+0900 to U+097F + + + // Bengali + // Range: U+0980 to U+09FF + + + // Gurmukhi + // Range: U+0A00 to U+0A7F + + + // Gujarati + // Range: U+0A80 to U+0AFF + + + // Oriya + // Range: U+0B00 to U+0B7F + // no capital / lower case + + + // Tamil + // Range: U+0B80 to U+0BFF + // no capital / lower case + + + // Telugu + // Range: U+0C00 to U+0C7F + // no capital / lower case + + + // Kannada + // Range: U+0C80 to U+0CFF + // no capital / lower case + + + // Malayalam + // Range: U+0D00 to U+0D7F + + // Thai + // Range: U+0E00 to U+0E7F + + + // Lao + // Range: U+0E80 to U+0EFF + + + // Tibetan + // Range: U+0F00 to U+0FBF + + // Georgian + // Range: U+10A0 to U+10F0 + if ( c >= 0x10A0 && c <= 0x10C5 ) { + u[0] = c; + u[1] = c + 48; + return u; + } + if ( c >= 0x10D0 && c <= 0x10F5 ) { + u[0] = c; + u[1] = c; + return u; + } + + // Hangul Jamo + // Range: U+1100 to U+11FF + + // Greek Extended + // Range: U+1F00 to U+1FFF + // skip for now + + + // General Punctuation + // Range: U+2000 to U+206F + + // Superscripts and Subscripts + // Range: U+2070 to U+209F + + // Currency Symbols + // Range: U+20A0 to U+20CF + + + // Combining Diacritical Marks for Symbols + // Range: U+20D0 to U+20FF + // skip for now + + + // Number Forms + // Range: U+2150 to U+218F + // skip for now + + + // Arrows + // Range: U+2190 to U+21FF + + // Mathematical Operators + // Range: U+2200 to U+22FF + + // Miscellaneous Technical + // Range: U+2300 to U+23FF + + // Control Pictures + // Range: U+2400 to U+243F + + // Optical Character Recognition + // Range: U+2440 to U+245F + + // Enclosed Alphanumerics + // Range: U+2460 to U+24FF + + // Box Drawing + // Range: U+2500 to U+257F + + // Block Elements + // Range: U+2580 to U+259F + + // Geometric Shapes + // Range: U+25A0 to U+25FF + + // Miscellaneous Symbols + // Range: U+2600 to U+26FF + + // Dingbats + // Range: U+2700 to U+27BF + + // CJK Symbols and Punctuation + // Range: U+3000 to U+303F + + // Hiragana + // Range: U+3040 to U+309F + + // Katakana + // Range: U+30A0 to U+30FF + + // Bopomofo + // Range: U+3100 to U+312F + + // Hangul Compatibility Jamo + // Range: U+3130 to U+318F + + // Kanbun + // Range: U+3190 to U+319F + + + // Enclosed CJK Letters and Months + // Range: U+3200 to U+32FF + + // CJK Compatibility + // Range: U+3300 to U+33FF + + // Hangul Syllables + // Range: U+AC00 to U+D7A3 + + // High Surrogates + // Range: U+D800 to U+DB7F + + // Private Use High Surrogates + // Range: U+DB80 to U+DBFF + + // Low Surrogates + // Range: U+DC00 to U+DFFF + + // Private Use Area + // Range: U+E000 to U+F8FF + + // CJK Compatibility Ideographs + // Range: U+F900 to U+FAFF + + // Alphabetic Presentation Forms + // Range: U+FB00 to U+FB4F + + // Arabic Presentation Forms-A + // Range: U+FB50 to U+FDFF + + // Combining Half Marks + // Range: U+FE20 to U+FE2F + + // CJK Compatibility Forms + // Range: U+FE30 to U+FE4F + + // Small Form Variants + // Range: U+FE50 to U+FE6F + + // Arabic Presentation Forms-B + // Range: U+FE70 to U+FEFF + + // Halfwidth and Fullwidth Forms + // Range: U+FF00 to U+FFEF + + if ( c >= 0xFF21 && c <= 0xFF3A ) { + u[0] = c; + u[1] = c + 32; + return u; + } + + if ( c >= 0xFF41 && c <= 0xFF5A ) { + u[0] = c - 32; + u[1] = c; + return u; + } + + // Specials + // Range: U+FFF0 to U+FFFF + + return u; +} + +function DecimalToHexString( n ) { + n = Number( n ); + var h = "0x"; + + for ( var i = 3; i >= 0; i-- ) { + if ( n >= Math.pow(16, i) ){ + var t = Math.floor( n / Math.pow(16, i)); + n -= t * Math.pow(16, i); + if ( t >= 10 ) { + if ( t == 10 ) { + h += "A"; + } + if ( t == 11 ) { + h += "B"; + } + if ( t == 12 ) { + h += "C"; + } + if ( t == 13 ) { + h += "D"; + } + if ( t == 14 ) { + h += "E"; + } + if ( t == 15 ) { + h += "F"; + } + } else { + h += String( t ); + } + } else { + h += "0"; + } + } + + return h; +} diff --git a/tests/auto/qml/parserstress/tests/ecma/String/15.5.4.2-1.js b/tests/auto/qml/parserstress/tests/ecma/String/15.5.4.2-1.js new file mode 100644 index 0000000000..e607ed51e4 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/String/15.5.4.2-1.js @@ -0,0 +1,72 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.5.4.2-1.js'; + +/** + File Name: 15.5.4.2-1.js + ECMA Section: 15.5.4.2 String.prototype.toString() + + Description: Returns this string value. Note that, for a String + object, the toString() method happens to return the same + thing as the valueOf() method. + + The toString function is not generic; it generates a + runtime error if its this value is not a String object. + Therefore it connot be transferred to the other kinds of + objects for use as a method. + + Author: christine@netscape.com + Date: 1 october 1997 +*/ + +var SECTION = "15.5.4.2-1"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "String.prototype.toString"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +new TestCase( SECTION, "String.prototype.toString()", "", String.prototype.toString() ); +new TestCase( SECTION, "(new String()).toString()", "", (new String()).toString() ); +new TestCase( SECTION, "(new String(\"\")).toString()", "", (new String("")).toString() ); +new TestCase( SECTION, "(new String( String() )).toString()","", (new String(String())).toString() ); +new TestCase( SECTION, "(new String( \"h e l l o\" )).toString()", "h e l l o", (new String("h e l l o")).toString() ); +new TestCase( SECTION, "(new String( 0 )).toString()", "0", (new String(0)).toString() ); + +test(); diff --git a/tests/auto/qml/parserstress/tests/ecma/String/15.5.4.2-2-n.js b/tests/auto/qml/parserstress/tests/ecma/String/15.5.4.2-2-n.js new file mode 100644 index 0000000000..930c1f8136 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/String/15.5.4.2-2-n.js @@ -0,0 +1,73 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.5.4.2-2-n.js'; + +/** + File Name: 15.5.4.2-2-n.js + ECMA Section: 15.5.4.2 String.prototype.toString() + + Description: Returns this string value. Note that, for a String + object, the toString() method happens to return the same + thing as the valueOf() method. + + The toString function is not generic; it generates a + runtime error if its this value is not a String object. + Therefore it connot be transferred to the other kinds of + objects for use as a method. + + Author: christine@netscape.com + Date: 1 october 1997 +*/ + +var SECTION = "15.5.4.2-3-n"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "String.prototype.toString"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +DESCRIPTION = "var tostr=String.prototype.toString; astring=new Number(); astring.toString = tostr; astring.toString()"; +EXPECTED = "error"; + +new TestCase( SECTION, + "var tostr=String.prototype.toString; astring=new Number(); astring.toString = tostr; astring.toString()", + "error", + eval("var tostr=String.prototype.toString; astring=new Number(); astring.toString = tostr; astring.toString()") ); + +test(); diff --git a/tests/auto/qml/parserstress/tests/ecma/String/15.5.4.2-3.js b/tests/auto/qml/parserstress/tests/ecma/String/15.5.4.2-3.js new file mode 100644 index 0000000000..1e306a06f3 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/String/15.5.4.2-3.js @@ -0,0 +1,83 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.5.4.2-3.js'; + +/** + File Name: 15.5.4.2-3.js + ECMA Section: 15.5.4.2 String.prototype.toString() + + Description: Returns this string value. Note that, for a String + object, the toString() method happens to return the same + thing as the valueOf() method. + + The toString function is not generic; it generates a + runtime error if its this value is not a String object. + Therefore it connot be transferred to the other kinds of + objects for use as a method. + + Author: christine@netscape.com + Date: 1 october 1997 +*/ + + +var SECTION = "15.5.4.2-3"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "String.prototype.toString"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +new TestCase( SECTION, + "var tostr=String.prototype.toString; astring=new String(); astring.toString = tostr; astring.toString()", + "", + eval("var tostr=String.prototype.toString; astring=new String(); astring.toString = tostr; astring.toString()") ); +new TestCase( SECTION, + "var tostr=String.prototype.toString; astring=new String(0); astring.toString = tostr; astring.toString()", + "0", + eval("var tostr=String.prototype.toString; astring=new String(0); astring.toString = tostr; astring.toString()") ); +new TestCase( SECTION, + "var tostr=String.prototype.toString; astring=new String('hello'); astring.toString = tostr; astring.toString()", + "hello", + eval("var tostr=String.prototype.toString; astring=new String('hello'); astring.toString = tostr; astring.toString()") ); +new TestCase( SECTION, + "var tostr=String.prototype.toString; astring=new String(''); astring.toString = tostr; astring.toString()", + "", + eval("var tostr=String.prototype.toString; astring=new String(''); astring.toString = tostr; astring.toString()") ); + +test(); diff --git a/tests/auto/qml/parserstress/tests/ecma/String/15.5.4.2.js b/tests/auto/qml/parserstress/tests/ecma/String/15.5.4.2.js new file mode 100644 index 0000000000..0a1100fc63 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/String/15.5.4.2.js @@ -0,0 +1,87 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.5.4.2.js'; + +/** + File Name: 15.5.4.2.js + ECMA Section: 15.5.4.2 String.prototype.toString + + Description: + Author: christine@netscape.com + Date: 28 october 1997 + +*/ +var SECTION = "15.5.4.2"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "String.prototype.tostring"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +new TestCase( SECTION, + "String.prototype.toString() == String.prototype.valueOf()", + true, + String.prototype.toString() == String.prototype.valueOf() ); + +new TestCase( SECTION, "String.prototype.toString()", "", String.prototype.toString() ); +new TestCase( SECTION, "String.prototype.toString.length", 0, String.prototype.toString.length ); + + +new TestCase( SECTION, + "TESTSTRING = new String();TESTSTRING.valueOf() == TESTSTRING.toString()", + true, + eval("TESTSTRING = new String();TESTSTRING.valueOf() == TESTSTRING.toString()") ); +new TestCase( SECTION, + "TESTSTRING = new String(true);TESTSTRING.valueOf() == TESTSTRING.toString()", + true, + eval("TESTSTRING = new String(true);TESTSTRING.valueOf() == TESTSTRING.toString()") ); +new TestCase( SECTION, + "TESTSTRING = new String(false);TESTSTRING.valueOf() == TESTSTRING.toString()", + true, + eval("TESTSTRING = new String(false);TESTSTRING.valueOf() == TESTSTRING.toString()") ); +new TestCase( SECTION, + "TESTSTRING = new String(Math.PI);TESTSTRING.valueOf() == TESTSTRING.toString()", + true, + eval("TESTSTRING = new String(Math.PI);TESTSTRING.valueOf() == TESTSTRING.toString()") ); +new TestCase( SECTION, + "TESTSTRING = new String();TESTSTRING.valueOf() == TESTSTRING.toString()", + true, + eval("TESTSTRING = new String();TESTSTRING.valueOf() == TESTSTRING.toString()") ); + +test(); diff --git a/tests/auto/qml/parserstress/tests/ecma/String/15.5.4.3-1.js b/tests/auto/qml/parserstress/tests/ecma/String/15.5.4.3-1.js new file mode 100644 index 0000000000..b990876fe8 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/String/15.5.4.3-1.js @@ -0,0 +1,72 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.5.4.3-1.js'; + +/** + File Name: 15.5.4.3-1.js + ECMA Section: 15.5.4.3 String.prototype.valueOf() + + Description: Returns this string value. + + The valueOf function is not generic; it generates a + runtime error if its this value is not a String object. + Therefore it connot be transferred to the other kinds of + objects for use as a method. + + Author: christine@netscape.com + Date: 1 october 1997 +*/ + +var SECTION = "15.5.4.3-1"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "String.prototype.valueOf"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +new TestCase( SECTION, "String.prototype.valueOf.length", 0, String.prototype.valueOf.length ); + +new TestCase( SECTION, "String.prototype.valueOf()", "", String.prototype.valueOf() ); +new TestCase( SECTION, "(new String()).valueOf()", "", (new String()).valueOf() ); +new TestCase( SECTION, "(new String(\"\")).valueOf()", "", (new String("")).valueOf() ); +new TestCase( SECTION, "(new String( String() )).valueOf()","", (new String(String())).valueOf() ); +new TestCase( SECTION, "(new String( \"h e l l o\" )).valueOf()", "h e l l o", (new String("h e l l o")).valueOf() ); +new TestCase( SECTION, "(new String( 0 )).valueOf()", "0", (new String(0)).valueOf() ); + +test(); diff --git a/tests/auto/qml/parserstress/tests/ecma/String/15.5.4.3-2.js b/tests/auto/qml/parserstress/tests/ecma/String/15.5.4.3-2.js new file mode 100644 index 0000000000..4747e013e6 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/String/15.5.4.3-2.js @@ -0,0 +1,90 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.5.4.3-2.js'; + +/** + File Name: 15.5.4.3-2.js + ECMA Section: 15.5.4.3 String.prototype.valueOf() + + Description: Returns this string value. + + The valueOf function is not generic; it generates a + runtime error if its this value is not a String object. + Therefore it connot be transferred to the other kinds of + objects for use as a method. + + Author: christine@netscape.com + Date: 1 october 1997 +*/ + + +var SECTION = "15.5.4.3-2"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "String.prototype.valueOf"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +new TestCase( SECTION, + "var valof=String.prototype.valueOf; astring=new String(); astring.valueOf = valof; astring.valof()", + "", + eval("var valof=String.prototype.valueOf; astring=new String(); astring.valueOf = valof; astring.valueOf()") ); + +new TestCase( SECTION, + "var valof=String.prototype.valueOf; astring=new String(0); astring.valueOf = valof; astring.valof()", + "0", + eval("var valof=String.prototype.valueOf; astring=new String(0); astring.valueOf = valof; astring.valueOf()") ); + +new TestCase( SECTION, + "var valof=String.prototype.valueOf; astring=new String('hello'); astring.valueOf = valof; astring.valof()", + "hello", + eval("var valof=String.prototype.valueOf; astring=new String('hello'); astring.valueOf = valof; astring.valueOf()") ); + +new TestCase( SECTION, + "var valof=String.prototype.valueOf; astring=new String(''); astring.valueOf = valof; astring.valof()", + "", + eval("var valof=String.prototype.valueOf; astring=new String(''); astring.valueOf = valof; astring.valueOf()") ); +/* + new TestCase( SECTION, + "var valof=String.prototype.valueOf; astring=new Number(); astring.valueOf = valof; astring.valof()", + "error", + eval("var valof=String.prototype.valueOf; astring=new Number(); astring.valueOf = valof; astring.valueOf()") ); +*/ + +test(); diff --git a/tests/auto/qml/parserstress/tests/ecma/String/15.5.4.3-3-n.js b/tests/auto/qml/parserstress/tests/ecma/String/15.5.4.3-3-n.js new file mode 100644 index 0000000000..bdfa52ece0 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/String/15.5.4.3-3-n.js @@ -0,0 +1,72 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.5.4.3-3-n.js'; + +/** + File Name: 15.5.4.3-3-n.js + ECMA Section: 15.5.4.3 String.prototype.valueOf() + + Description: Returns this string value. + + The valueOf function is not generic; it generates a + runtime error if its this value is not a String object. + Therefore it connot be transferred to the other kinds of + objects for use as a method. + + Author: christine@netscape.com + Date: 1 october 1997 +*/ + + +var SECTION = "15.5.4.3-3-n"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "String.prototype.valueOf"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +DESCRIPTION = "var valof=String.prototype.valueOf; astring=new Number(); astring.valueOf = valof; astring.valof()"; +EXPECTED = "error"; + +new TestCase( SECTION, + "var valof=String.prototype.valueOf; astring=new Number(); astring.valueOf = valof; astring.valof()", + "error", + eval("var valof=String.prototype.valueOf; astring=new Number(); astring.valueOf = valof; astring.valueOf()") ); + +test(); diff --git a/tests/auto/qml/parserstress/tests/ecma/String/15.5.4.4-1.js b/tests/auto/qml/parserstress/tests/ecma/String/15.5.4.4-1.js new file mode 100644 index 0000000000..5dbffb1d14 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/String/15.5.4.4-1.js @@ -0,0 +1,92 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.5.4.4-1.js'; + +/** + File Name: 15.5.4.4-1.js + ECMA Section: 15.5.4.4 String.prototype.charAt(pos) + Description: Returns a string containing the character at position + pos in the string. If there is no character at that + string, the result is the empty string. The result is + a string value, not a String object. + + When the charAt method is called with one argument, + pos, the following steps are taken: + 1. Call ToString, with this value as its argument + 2. Call ToInteger pos + + In this test, this is a String, pos is an integer, and + all pos are in range. + + Author: christine@netscape.com + Date: 2 october 1997 +*/ +var SECTION = "15.5.4.4-1"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "String.prototype.charAt"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +var TEST_STRING = new String( " !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~" ); + +var item = 0; +var i; + +for ( i = 0x0020; i < 0x007e; i++, item++) { + new TestCase( SECTION, + "TEST_STRING.charAt("+item+")", + String.fromCharCode( i ), + TEST_STRING.charAt( item ) ); +} + +for ( i = 0x0020; i < 0x007e; i++, item++) { + new TestCase( SECTION, + "TEST_STRING.charAt("+item+") == TEST_STRING.substring( "+item +", "+ (item+1) + ")", + true, + TEST_STRING.charAt( item ) == TEST_STRING.substring( item, item+1 ) + ); +} + +new TestCase( SECTION, "String.prototype.charAt.length", 1, String.prototype.charAt.length ); + +print( "TEST_STRING = new String(\" !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~\")" ); + +test(); + diff --git a/tests/auto/qml/parserstress/tests/ecma/String/15.5.4.4-2.js b/tests/auto/qml/parserstress/tests/ecma/String/15.5.4.4-2.js new file mode 100644 index 0000000000..c822a1d5f7 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/String/15.5.4.4-2.js @@ -0,0 +1,136 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.5.4.4-2.js'; + +/** + File Name: 15.5.4.4-1.js + ECMA Section: 15.5.4.4 String.prototype.charAt(pos) + Description: Returns a string containing the character at position + pos in the string. If there is no character at that + string, the result is the empty string. The result is + a string value, not a String object. + + When the charAt method is called with one argument, + pos, the following steps are taken: + 1. Call ToString, with this value as its argument + 2. Call ToInteger pos + 3. Compute the number of characters in Result(1) + 4. If Result(2) is less than 0 is or not less than + Result(3), return the empty string + 5. Return a string of length 1 containing one character + from result (1), the character at position Result(2). + + Note that the charAt function is intentionally generic; + it does not require that its this value be a String + object. Therefore it can be transferred to other kinds + of objects for use as a method. + + Author: christine@netscape.com + Date: 2 october 1997 +*/ +var SECTION = "15.5.4.4-2"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "String.prototype.charAt"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +new TestCase( SECTION, "x = new Boolean(true); x.charAt=String.prototype.charAt;x.charAt(0)", "t", eval("x = new Boolean(true); x.charAt=String.prototype.charAt;x.charAt(0)") ); +new TestCase( SECTION, "x = new Boolean(true); x.charAt=String.prototype.charAt;x.charAt(1)", "r", eval("x = new Boolean(true); x.charAt=String.prototype.charAt;x.charAt(1)") ); +new TestCase( SECTION, "x = new Boolean(true); x.charAt=String.prototype.charAt;x.charAt(2)", "u", eval("x = new Boolean(true); x.charAt=String.prototype.charAt;x.charAt(2)") ); +new TestCase( SECTION, "x = new Boolean(true); x.charAt=String.prototype.charAt;x.charAt(3)", "e", eval("x = new Boolean(true); x.charAt=String.prototype.charAt;x.charAt(3)") ); +new TestCase( SECTION, "x = new Boolean(true); x.charAt=String.prototype.charAt;x.charAt(4)", "", eval("x = new Boolean(true); x.charAt=String.prototype.charAt;x.charAt(4)") ); +new TestCase( SECTION, "x = new Boolean(true); x.charAt=String.prototype.charAt;x.charAt(-1)", "", eval("x = new Boolean(true); x.charAt=String.prototype.charAt;x.charAt(-1)") ); + +new TestCase( SECTION, "x = new Boolean(true); x.charAt=String.prototype.charAt;x.charAt(true)", "r", eval("x = new Boolean(true); x.charAt=String.prototype.charAt;x.charAt(true)") ); +new TestCase( SECTION, "x = new Boolean(true); x.charAt=String.prototype.charAt;x.charAt(false)", "t", eval("x = new Boolean(true); x.charAt=String.prototype.charAt;x.charAt(false)") ); + +new TestCase( SECTION, "x = new String(); x.charAt(0)", "", eval("x=new String();x.charAt(0)") ); +new TestCase( SECTION, "x = new String(); x.charAt(1)", "", eval("x=new String();x.charAt(1)") ); +new TestCase( SECTION, "x = new String(); x.charAt(-1)", "", eval("x=new String();x.charAt(-1)") ); + +new TestCase( SECTION, "x = new String(); x.charAt(NaN)", "", eval("x=new String();x.charAt(Number.NaN)") ); +new TestCase( SECTION, "x = new String(); x.charAt(Number.POSITIVE_INFINITY)", "", eval("x=new String();x.charAt(Number.POSITIVE_INFINITY)") ); +new TestCase( SECTION, "x = new String(); x.charAt(Number.NEGATIVE_INFINITY)", "", eval("x=new String();x.charAt(Number.NEGATIVE_INFINITY)") ); + +new TestCase( SECTION, "var MYOB = new MyObject(1234567890); MYOB.charAt(0)", "1", eval("var MYOB = new MyObject(1234567890); MYOB.charAt(0)") ); +new TestCase( SECTION, "var MYOB = new MyObject(1234567890); MYOB.charAt(1)", "2", eval("var MYOB = new MyObject(1234567890); MYOB.charAt(1)") ); +new TestCase( SECTION, "var MYOB = new MyObject(1234567890); MYOB.charAt(2)", "3", eval("var MYOB = new MyObject(1234567890); MYOB.charAt(2)") ); +new TestCase( SECTION, "var MYOB = new MyObject(1234567890); MYOB.charAt(3)", "4", eval("var MYOB = new MyObject(1234567890); MYOB.charAt(3)") ); +new TestCase( SECTION, "var MYOB = new MyObject(1234567890); MYOB.charAt(4)", "5", eval("var MYOB = new MyObject(1234567890); MYOB.charAt(4)") ); +new TestCase( SECTION, "var MYOB = new MyObject(1234567890); MYOB.charAt(5)", "6", eval("var MYOB = new MyObject(1234567890); MYOB.charAt(5)") ); +new TestCase( SECTION, "var MYOB = new MyObject(1234567890); MYOB.charAt(6)", "7", eval("var MYOB = new MyObject(1234567890); MYOB.charAt(6)") ); +new TestCase( SECTION, "var MYOB = new MyObject(1234567890); MYOB.charAt(7)", "8", eval("var MYOB = new MyObject(1234567890); MYOB.charAt(7)") ); +new TestCase( SECTION, "var MYOB = new MyObject(1234567890); MYOB.charAt(8)", "9", eval("var MYOB = new MyObject(1234567890); MYOB.charAt(8)") ); +new TestCase( SECTION, "var MYOB = new MyObject(1234567890); MYOB.charAt(9)", "0", eval("var MYOB = new MyObject(1234567890); MYOB.charAt(9)") ); +new TestCase( SECTION, "var MYOB = new MyObject(1234567890); MYOB.charAt(10)", "", eval("var MYOB = new MyObject(1234567890); MYOB.charAt(10)") ); + +new TestCase( SECTION, "var MYOB = new MyObject(1234567890); MYOB.charAt(Math.PI)", "4", eval("var MYOB = new MyObject(1234567890); MYOB.charAt(Math.PI)") ); + +// MyOtherObject.toString will return "[object Object] + +new TestCase( SECTION, "var MYOB = new MyOtherObject(1234567890); MYOB.charAt(0)", "[", eval("var MYOB = new MyOtherObject(1234567890); MYOB.charAt(0)") ); +new TestCase( SECTION, "var MYOB = new MyOtherObject(1234567890); MYOB.charAt(1)", "o", eval("var MYOB = new MyOtherObject(1234567890); MYOB.charAt(1)") ); +new TestCase( SECTION, "var MYOB = new MyOtherObject(1234567890); MYOB.charAt(2)", "b", eval("var MYOB = new MyOtherObject(1234567890); MYOB.charAt(2)") ); +new TestCase( SECTION, "var MYOB = new MyOtherObject(1234567890); MYOB.charAt(3)", "j", eval("var MYOB = new MyOtherObject(1234567890); MYOB.charAt(3)") ); +new TestCase( SECTION, "var MYOB = new MyOtherObject(1234567890); MYOB.charAt(4)", "e", eval("var MYOB = new MyOtherObject(1234567890); MYOB.charAt(4)") ); +new TestCase( SECTION, "var MYOB = new MyOtherObject(1234567890); MYOB.charAt(5)", "c", eval("var MYOB = new MyOtherObject(1234567890); MYOB.charAt(5)") ); +new TestCase( SECTION, "var MYOB = new MyOtherObject(1234567890); MYOB.charAt(6)", "t", eval("var MYOB = new MyOtherObject(1234567890); MYOB.charAt(6)") ); +new TestCase( SECTION, "var MYOB = new MyOtherObject(1234567890); MYOB.charAt(7)", " ", eval("var MYOB = new MyOtherObject(1234567890); MYOB.charAt(7)") ); +new TestCase( SECTION, "var MYOB = new MyOtherObject(1234567890); MYOB.charAt(8)", "O", eval("var MYOB = new MyOtherObject(1234567890); MYOB.charAt(8)") ); +new TestCase( SECTION, "var MYOB = new MyOtherObject(1234567890); MYOB.charAt(9)", "b", eval("var MYOB = new MyOtherObject(1234567890); MYOB.charAt(9)") ); +new TestCase( SECTION, "var MYOB = new MyOtherObject(1234567890); MYOB.charAt(10)", "j", eval("var MYOB = new MyOtherObject(1234567890); MYOB.charAt(10)") ); +new TestCase( SECTION, "var MYOB = new MyOtherObject(1234567890); MYOB.charAt(11)", "e", eval("var MYOB = new MyOtherObject(1234567890); MYOB.charAt(11)") ); +new TestCase( SECTION, "var MYOB = new MyOtherObject(1234567890); MYOB.charAt(12)", "c", eval("var MYOB = new MyOtherObject(1234567890); MYOB.charAt(12)") ); +new TestCase( SECTION, "var MYOB = new MyOtherObject(1234567890); MYOB.charAt(13)", "t", eval("var MYOB = new MyOtherObject(1234567890); MYOB.charAt(13)") ); +new TestCase( SECTION, "var MYOB = new MyOtherObject(1234567890); MYOB.charAt(14)", "]", eval("var MYOB = new MyOtherObject(1234567890); MYOB.charAt(14)") ); + +test(); + +function MyObject( value ) { + this.value = value; + this.valueOf = new Function( "return this.value;" ); + this.toString = new Function( "return this.value +''" ); + this.charAt = String.prototype.charAt; +} +function MyOtherObject(value) { + this.value = value; + this.valueOf = new Function( "return this.value;" ); + this.charAt = String.prototype.charAt; +} diff --git a/tests/auto/qml/parserstress/tests/ecma/String/15.5.4.4-3.js b/tests/auto/qml/parserstress/tests/ecma/String/15.5.4.4-3.js new file mode 100644 index 0000000000..96b4759c98 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/String/15.5.4.4-3.js @@ -0,0 +1,112 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.5.4.4-3.js'; + +/** + File Name: 15.5.4.4-3.js + ECMA Section: 15.5.4.4 String.prototype.charAt(pos) + Description: Returns a string containing the character at position + pos in the string. If there is no character at that + string, the result is the empty string. The result is + a string value, not a String object. + + When the charAt method is called with one argument, + pos, the following steps are taken: + 1. Call ToString, with this value as its argument + 2. Call ToInteger pos + 3. Compute the number of characters in Result(1) + 4. If Result(2) is less than 0 is or not less than + Result(3), return the empty string + 5. Return a string of length 1 containing one character + from result (1), the character at position Result(2). + + Note that the charAt function is intentionally generic; + it does not require that its this value be a String + object. Therefore it can be transferred to other kinds + of objects for use as a method. + + This tests assiging charAt to a user-defined function. + + Author: christine@netscape.com + Date: 2 october 1997 +*/ +var SECTION = "15.5.4.4-3"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "String.prototype.charAt"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +var foo = new MyObject('hello'); + + +new TestCase( SECTION, "var foo = new MyObject('hello'); ", "h", foo.charAt(0) ); +new TestCase( SECTION, "var foo = new MyObject('hello'); ", "e", foo.charAt(1) ); +new TestCase( SECTION, "var foo = new MyObject('hello'); ", "l", foo.charAt(2) ); +new TestCase( SECTION, "var foo = new MyObject('hello'); ", "l", foo.charAt(3) ); +new TestCase( SECTION, "var foo = new MyObject('hello'); ", "o", foo.charAt(4) ); +new TestCase( SECTION, "var foo = new MyObject('hello'); ", "", foo.charAt(-1) ); +new TestCase( SECTION, "var foo = new MyObject('hello'); ", "", foo.charAt(5) ); + +var boo = new MyObject(true); + +new TestCase( SECTION, "var boo = new MyObject(true); ", "t", boo.charAt(0) ); +new TestCase( SECTION, "var boo = new MyObject(true); ", "r", boo.charAt(1) ); +new TestCase( SECTION, "var boo = new MyObject(true); ", "u", boo.charAt(2) ); +new TestCase( SECTION, "var boo = new MyObject(true); ", "e", boo.charAt(3) ); + +var noo = new MyObject( Math.PI ); + +new TestCase( SECTION, "var noo = new MyObject(Math.PI); ", "3", noo.charAt(0) ); +new TestCase( SECTION, "var noo = new MyObject(Math.PI); ", ".", noo.charAt(1) ); +new TestCase( SECTION, "var noo = new MyObject(Math.PI); ", "1", noo.charAt(2) ); +new TestCase( SECTION, "var noo = new MyObject(Math.PI); ", "4", noo.charAt(3) ); +new TestCase( SECTION, "var noo = new MyObject(Math.PI); ", "1", noo.charAt(4) ); +new TestCase( SECTION, "var noo = new MyObject(Math.PI); ", "5", noo.charAt(5) ); +new TestCase( SECTION, "var noo = new MyObject(Math.PI); ", "9", noo.charAt(6) ); + +test(); + +function MyObject (v) { + this.value = v; + this.toString = new Function( "return this.value +'';" ); + this.valueOf = new Function( "return this.value" ); + this.charAt = String.prototype.charAt; +} + diff --git a/tests/auto/qml/parserstress/tests/ecma/String/15.5.4.4-4.js b/tests/auto/qml/parserstress/tests/ecma/String/15.5.4.4-4.js new file mode 100644 index 0000000000..bf9f7a6898 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/String/15.5.4.4-4.js @@ -0,0 +1,124 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.5.4.4-4.js'; + +/** + File Name: 15.5.4.4-4.js + ECMA Section: 15.5.4.4 String.prototype.charAt(pos) + Description: Returns a string containing the character at position + pos in the string. If there is no character at that + string, the result is the empty string. The result is + a string value, not a String object. + + When the charAt method is called with one argument, + pos, the following steps are taken: + 1. Call ToString, with this value as its argument + 2. Call ToInteger pos + 3. Compute the number of characters in Result(1) + 4. If Result(2) is less than 0 is or not less than + Result(3), return the empty string + 5. Return a string of length 1 containing one character + from result (1), the character at position Result(2). + + Note that the charAt function is intentionally generic; + it does not require that its this value be a String + object. Therefore it can be transferred to other kinds + of objects for use as a method. + + This tests assiging charAt to primitive types.. + + Author: christine@netscape.com + Date: 2 october 1997 +*/ +var SECTION = "15.5.4.4-4"; +var VERSION = "ECMA_2"; +startTest(); +var TITLE = "String.prototype.charAt"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +new TestCase( SECTION, "x = new Array(1,2,3); x.charAt = String.prototype.charAt; x.charAt(0)", "1", eval("x=new Array(1,2,3); x.charAt = String.prototype.charAt; x.charAt(0)") ); +new TestCase( SECTION, "x = new Array(1,2,3); x.charAt = String.prototype.charAt; x.charAt(1)", ",", eval("x=new Array(1,2,3); x.charAt = String.prototype.charAt; x.charAt(1)") ); +new TestCase( SECTION, "x = new Array(1,2,3); x.charAt = String.prototype.charAt; x.charAt(2)", "2", eval("x=new Array(1,2,3); x.charAt = String.prototype.charAt; x.charAt(2)") ); +new TestCase( SECTION, "x = new Array(1,2,3); x.charAt = String.prototype.charAt; x.charAt(3)", ",", eval("x=new Array(1,2,3); x.charAt = String.prototype.charAt; x.charAt(3)") ); +new TestCase( SECTION, "x = new Array(1,2,3); x.charAt = String.prototype.charAt; x.charAt(4)", "3", eval("x=new Array(1,2,3); x.charAt = String.prototype.charAt; x.charAt(4)") ); + +new TestCase( SECTION, "x = new Array(); x.charAt = String.prototype.charAt; x.charAt(0)", "", eval("x = new Array(); x.charAt = String.prototype.charAt; x.charAt(0)") ); + +new TestCase( SECTION, "x = new Number(123); x.charAt = String.prototype.charAt; x.charAt(0)", "1", eval("x=new Number(123); x.charAt = String.prototype.charAt; x.charAt(0)") ); +new TestCase( SECTION, "x = new Number(123); x.charAt = String.prototype.charAt; x.charAt(1)", "2", eval("x=new Number(123); x.charAt = String.prototype.charAt; x.charAt(1)") ); +new TestCase( SECTION, "x = new Number(123); x.charAt = String.prototype.charAt; x.charAt(2)", "3", eval("x=new Number(123); x.charAt = String.prototype.charAt; x.charAt(2)") ); + +new TestCase( SECTION, "x = new Object(); x.charAt = String.prototype.charAt; x.charAt(0)", "[", eval("x=new Object(); x.charAt = String.prototype.charAt; x.charAt(0)") ); +new TestCase( SECTION, "x = new Object(); x.charAt = String.prototype.charAt; x.charAt(1)", "o", eval("x=new Object(); x.charAt = String.prototype.charAt; x.charAt(1)") ); +new TestCase( SECTION, "x = new Object(); x.charAt = String.prototype.charAt; x.charAt(2)", "b", eval("x=new Object(); x.charAt = String.prototype.charAt; x.charAt(2)") ); +new TestCase( SECTION, "x = new Object(); x.charAt = String.prototype.charAt; x.charAt(3)", "j", eval("x=new Object(); x.charAt = String.prototype.charAt; x.charAt(3)") ); +new TestCase( SECTION, "x = new Object(); x.charAt = String.prototype.charAt; x.charAt(4)", "e", eval("x=new Object(); x.charAt = String.prototype.charAt; x.charAt(4)") ); +new TestCase( SECTION, "x = new Object(); x.charAt = String.prototype.charAt; x.charAt(5)", "c", eval("x=new Object(); x.charAt = String.prototype.charAt; x.charAt(5)") ); +new TestCase( SECTION, "x = new Object(); x.charAt = String.prototype.charAt; x.charAt(6)", "t", eval("x=new Object(); x.charAt = String.prototype.charAt; x.charAt(6)") ); +new TestCase( SECTION, "x = new Object(); x.charAt = String.prototype.charAt; x.charAt(7)", " ", eval("x=new Object(); x.charAt = String.prototype.charAt; x.charAt(7)") ); +new TestCase( SECTION, "x = new Object(); x.charAt = String.prototype.charAt; x.charAt(8)", "O", eval("x=new Object(); x.charAt = String.prototype.charAt; x.charAt(8)") ); +new TestCase( SECTION, "x = new Object(); x.charAt = String.prototype.charAt; x.charAt(9)", "b", eval("x=new Object(); x.charAt = String.prototype.charAt; x.charAt(9)") ); +new TestCase( SECTION, "x = new Object(); x.charAt = String.prototype.charAt; x.charAt(10)", "j", eval("x=new Object(); x.charAt = String.prototype.charAt; x.charAt(10)") ); +new TestCase( SECTION, "x = new Object(); x.charAt = String.prototype.charAt; x.charAt(11)", "e", eval("x=new Object(); x.charAt = String.prototype.charAt; x.charAt(11)") ); +new TestCase( SECTION, "x = new Object(); x.charAt = String.prototype.charAt; x.charAt(12)", "c", eval("x=new Object(); x.charAt = String.prototype.charAt; x.charAt(12)") ); +new TestCase( SECTION, "x = new Object(); x.charAt = String.prototype.charAt; x.charAt(13)", "t", eval("x=new Object(); x.charAt = String.prototype.charAt; x.charAt(13)") ); +new TestCase( SECTION, "x = new Object(); x.charAt = String.prototype.charAt; x.charAt(14)", "]", eval("x=new Object(); x.charAt = String.prototype.charAt; x.charAt(14)") ); + +new TestCase( SECTION, "x = new Function(); x.toString = Object.prototype.toString; x.charAt = String.prototype.charAt; x.charAt(0)", "[", eval("x=new Function(); x.toString = Object.prototype.toString; x.charAt = String.prototype.charAt; x.charAt(0)") ); +new TestCase( SECTION, "x = new Function(); x.toString = Object.prototype.toString; x.charAt = String.prototype.charAt; x.charAt(1)", "o", eval("x=new Function(); x.toString = Object.prototype.toString; x.charAt = String.prototype.charAt; x.charAt(1)") ); +new TestCase( SECTION, "x = new Function(); x.toString = Object.prototype.toString; x.charAt = String.prototype.charAt; x.charAt(2)", "b", eval("x=new Function(); x.toString = Object.prototype.toString; x.charAt = String.prototype.charAt; x.charAt(2)") ); +new TestCase( SECTION, "x = new Function(); x.toString = Object.prototype.toString; x.charAt = String.prototype.charAt; x.charAt(3)", "j", eval("x=new Function(); x.toString = Object.prototype.toString; x.charAt = String.prototype.charAt; x.charAt(3)") ); +new TestCase( SECTION, "x = new Function(); x.toString = Object.prototype.toString; x.charAt = String.prototype.charAt; x.charAt(4)", "e", eval("x=new Function(); x.toString = Object.prototype.toString; x.charAt = String.prototype.charAt; x.charAt(4)") ); +new TestCase( SECTION, "x = new Function(); x.toString = Object.prototype.toString; x.charAt = String.prototype.charAt; x.charAt(5)", "c", eval("x=new Function(); x.toString = Object.prototype.toString; x.charAt = String.prototype.charAt; x.charAt(5)") ); +new TestCase( SECTION, "x = new Function(); x.toString = Object.prototype.toString; x.charAt = String.prototype.charAt; x.charAt(6)", "t", eval("x=new Function(); x.toString = Object.prototype.toString; x.charAt = String.prototype.charAt; x.charAt(6)") ); +new TestCase( SECTION, "x = new Function(); x.toString = Object.prototype.toString; x.charAt = String.prototype.charAt; x.charAt(7)", " ", eval("x=new Function(); x.toString = Object.prototype.toString; x.charAt = String.prototype.charAt; x.charAt(7)") ); +new TestCase( SECTION, "x = new Function(); x.toString = Object.prototype.toString; x.charAt = String.prototype.charAt; x.charAt(8)", "F", eval("x=new Function(); x.toString = Object.prototype.toString; x.charAt = String.prototype.charAt; x.charAt(8)") ); +new TestCase( SECTION, "x = new Function(); x.toString = Object.prototype.toString; x.charAt = String.prototype.charAt; x.charAt(9)", "u", eval("x=new Function(); x.toString = Object.prototype.toString; x.charAt = String.prototype.charAt; x.charAt(9)") ); +new TestCase( SECTION, "x = new Function(); x.toString = Object.prototype.toString; x.charAt = String.prototype.charAt; x.charAt(10)", "n", eval("x=new Function(); x.toString = Object.prototype.toString; x.charAt = String.prototype.charAt; x.charAt(10)") ); +new TestCase( SECTION, "x = new Function(); x.toString = Object.prototype.toString; x.charAt = String.prototype.charAt; x.charAt(11)", "c", eval("x=new Function(); x.toString = Object.prototype.toString; x.charAt = String.prototype.charAt; x.charAt(11)") ); +new TestCase( SECTION, "x = new Function(); x.toString = Object.prototype.toString; x.charAt = String.prototype.charAt; x.charAt(12)", "t", eval("x=new Function(); x.toString = Object.prototype.toString; x.charAt = String.prototype.charAt; x.charAt(12)") ); +new TestCase( SECTION, "x = new Function(); x.toString = Object.prototype.toString; x.charAt = String.prototype.charAt; x.charAt(13)", "i", eval("x=new Function(); x.toString = Object.prototype.toString; x.charAt = String.prototype.charAt; x.charAt(13)") ); +new TestCase( SECTION, "x = new Function(); x.toString = Object.prototype.toString; x.charAt = String.prototype.charAt; x.charAt(14)", "o", eval("x=new Function(); x.toString = Object.prototype.toString; x.charAt = String.prototype.charAt; x.charAt(14)") ); +new TestCase( SECTION, "x = new Function(); x.toString = Object.prototype.toString; x.charAt = String.prototype.charAt; x.charAt(15)", "n", eval("x=new Function(); x.toString = Object.prototype.toString; x.charAt = String.prototype.charAt; x.charAt(15)") ); +new TestCase( SECTION, "x = new Function(); x.toString = Object.prototype.toString; x.charAt = String.prototype.charAt; x.charAt(16)", "]", eval("x=new Function(); x.toString = Object.prototype.toString; x.charAt = String.prototype.charAt; x.charAt(16)") ); +new TestCase( SECTION, "x = new Function(); x.toString = Object.prototype.toString; x.charAt = String.prototype.charAt; x.charAt(17)", "", eval("x=new Function(); x.toString = Object.prototype.toString; x.charAt = String.prototype.charAt; x.charAt(17)") ); + + +test(); diff --git a/tests/auto/qml/parserstress/tests/ecma/String/15.5.4.5-1.js b/tests/auto/qml/parserstress/tests/ecma/String/15.5.4.5-1.js new file mode 100644 index 0000000000..a1ba440a60 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/String/15.5.4.5-1.js @@ -0,0 +1,87 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.5.4.5-1.js'; + +/** + File Name: 15.5.4.5.1.js + ECMA Section: 15.5.4.5 String.prototype.charCodeAt(pos) + Description: Returns a number (a nonnegative integer less than 2^16) + representing the Unicode encoding of the character at + position pos in this string. If there is no character + at that position, the number is NaN. + + When the charCodeAt method is called with one argument + pos, the following steps are taken: + 1. Call ToString, giving it the theis value as its + argument + 2. Call ToInteger(pos) + 3. Compute the number of characters in result(1). + 4. If Result(2) is less than 0 or is not less than + Result(3), return NaN. + 5. Return a value of Number type, of positive sign, whose + magnitude is the Unicode encoding of one character + from result 1, namely the characer at position Result + (2), where the first character in Result(1) is + considered to be at position 0. + + Note that the charCodeAt funciton is intentionally + generic; it does not require that its this value be a + String object. Therefore it can be transferred to other + kinds of objects for use as a method. + + Author: christine@netscape.com + Date: 2 october 1997 +*/ +var SECTION = "15.5.4.5-1"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "String.prototype.charCodeAt"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +var TEST_STRING = new String( " !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~" ); + +for ( j = 0, i = 0x0020; i < 0x007e; i++, j++ ) { + new TestCase( SECTION, "TEST_STRING.charCodeAt("+j+")", i, TEST_STRING.charCodeAt( j ) ); +} + +new TestCase( SECTION, 'TEST_STRING.charCodeAt('+i+')', NaN, TEST_STRING.charCodeAt( i ) ); + + +test(); diff --git a/tests/auto/qml/parserstress/tests/ecma/String/15.5.4.5-2.js b/tests/auto/qml/parserstress/tests/ecma/String/15.5.4.5-2.js new file mode 100644 index 0000000000..29cb76152e --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/String/15.5.4.5-2.js @@ -0,0 +1,121 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.5.4.5-2.js'; + +/** + File Name: 15.5.4.5.1.js + ECMA Section: 15.5.4.5 String.prototype.charCodeAt(pos) + Description: Returns a number (a nonnegative integer less than 2^16) + representing the Unicode encoding of the character at + position pos in this string. If there is no character + at that position, the number is NaN. + + When the charCodeAt method is called with one argument + pos, the following steps are taken: + 1. Call ToString, giving it the theis value as its + argument + 2. Call ToInteger(pos) + 3. Compute the number of characters in result(1). + 4. If Result(2) is less than 0 or is not less than + Result(3), return NaN. + 5. Return a value of Number type, of positive sign, whose + magnitude is the Unicode encoding of one character + from result 1, namely the characer at position Result + (2), where the first character in Result(1) is + considered to be at position 0. + + Note that the charCodeAt funciton is intentionally + generic; it does not require that its this value be a + String object. Therefore it can be transferred to other + kinds of objects for use as a method. + + Author: christine@netscape.com + Date: 2 october 1997 +*/ +var SECTION = "15.5.4.5-2"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "String.prototype.charCodeAt"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +var TEST_STRING = new String( " !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~" ); + +var x; + +new TestCase( SECTION, "x = new Boolean(true); x.charCodeAt=String.prototype.charCodeAt;x.charCodeAt(0)", 0x0074, eval("x = new Boolean(true); x.charCodeAt=String.prototype.charCodeAt;x.charCodeAt(0)") ); +new TestCase( SECTION, "x = new Boolean(true); x.charCodeAt=String.prototype.charCodeAt;x.charCodeAt(1)", 0x0072, eval("x = new Boolean(true); x.charCodeAt=String.prototype.charCodeAt;x.charCodeAt(1)") ); +new TestCase( SECTION, "x = new Boolean(true); x.charCodeAt=String.prototype.charCodeAt;x.charCodeAt(2)", 0x0075, eval("x = new Boolean(true); x.charCodeAt=String.prototype.charCodeAt;x.charCodeAt(2)") ); +new TestCase( SECTION, "x = new Boolean(true); x.charCodeAt=String.prototype.charCodeAt;x.charCodeAt(3)", 0x0065, eval("x = new Boolean(true); x.charCodeAt=String.prototype.charCodeAt;x.charCodeAt(3)") ); +new TestCase( SECTION, "x = new Boolean(true); x.charCodeAt=String.prototype.charCodeAt;x.charCodeAt(4)", Number.NaN, eval("x = new Boolean(true); x.charCodeAt=String.prototype.charCodeAt;x.charCodeAt(4)") ); +new TestCase( SECTION, "x = new Boolean(true); x.charCodeAt=String.prototype.charCodeAt;x.charCodeAt(-1)", Number.NaN, eval("x = new Boolean(true); x.charCodeAt=String.prototype.charCodeAt;x.charCodeAt(-1)") ); + +new TestCase( SECTION, "x = new Boolean(true); x.charCodeAt=String.prototype.charCodeAt;x.charCodeAt(true)", 0x0072, eval("x = new Boolean(true); x.charCodeAt=String.prototype.charCodeAt;x.charCodeAt(true)") ); +new TestCase( SECTION, "x = new Boolean(true); x.charCodeAt=String.prototype.charCodeAt;x.charCodeAt(false)", 0x0074, eval("x = new Boolean(true); x.charCodeAt=String.prototype.charCodeAt;x.charCodeAt(false)") ); + +new TestCase( SECTION, "x = new String(); x.charCodeAt(0)", Number.NaN, eval("x=new String();x.charCodeAt(0)") ); +new TestCase( SECTION, "x = new String(); x.charCodeAt(1)", Number.NaN, eval("x=new String();x.charCodeAt(1)") ); +new TestCase( SECTION, "x = new String(); x.charCodeAt(-1)", Number.NaN, eval("x=new String();x.charCodeAt(-1)") ); + +new TestCase( SECTION, "x = new String(); x.charCodeAt(NaN)", Number.NaN, eval("x=new String();x.charCodeAt(Number.NaN)") ); +new TestCase( SECTION, "x = new String(); x.charCodeAt(Number.POSITIVE_INFINITY)", Number.NaN, eval("x=new String();x.charCodeAt(Number.POSITIVE_INFINITY)") ); +new TestCase( SECTION, "x = new String(); x.charCodeAt(Number.NEGATIVE_INFINITY)", Number.NaN, eval("x=new String();x.charCodeAt(Number.NEGATIVE_INFINITY)") ); + +new TestCase( SECTION, "x = new Array(1,2,3); x.charCodeAt = String.prototype.charCodeAt; x.charCodeAt(0)", 0x0031, eval("x = new Array(1,2,3); x.charCodeAt = String.prototype.charCodeAt; x.charCodeAt(0)") ); +new TestCase( SECTION, "x = new Array(1,2,3); x.charCodeAt = String.prototype.charCodeAt; x.charCodeAt(1)", 0x002C, eval("x = new Array(1,2,3); x.charCodeAt = String.prototype.charCodeAt; x.charCodeAt(1)") ); +new TestCase( SECTION, "x = new Array(1,2,3); x.charCodeAt = String.prototype.charCodeAt; x.charCodeAt(2)", 0x0032, eval("x = new Array(1,2,3); x.charCodeAt = String.prototype.charCodeAt; x.charCodeAt(2)") ); +new TestCase( SECTION, "x = new Array(1,2,3); x.charCodeAt = String.prototype.charCodeAt; x.charCodeAt(3)", 0x002C, eval("x = new Array(1,2,3); x.charCodeAt = String.prototype.charCodeAt; x.charCodeAt(3)") ); +new TestCase( SECTION, "x = new Array(1,2,3); x.charCodeAt = String.prototype.charCodeAt; x.charCodeAt(4)", 0x0033, eval("x = new Array(1,2,3); x.charCodeAt = String.prototype.charCodeAt; x.charCodeAt(4)") ); +new TestCase( SECTION, "x = new Array(1,2,3); x.charCodeAt = String.prototype.charCodeAt; x.charCodeAt(5)", NaN, eval("x = new Array(1,2,3); x.charCodeAt = String.prototype.charCodeAt; x.charCodeAt(5)") ); + +new TestCase( SECTION, "x = new Function( 'this.charCodeAt = String.prototype.charCodeAt' ); f = new x(); f.charCodeAt(0)", 0x005B, eval("x = new Function( 'this.charCodeAt = String.prototype.charCodeAt' ); f = new x(); f.charCodeAt(0)") ); +new TestCase( SECTION, "x = new Function( 'this.charCodeAt = String.prototype.charCodeAt' ); f = new x(); f.charCodeAt(1)", 0x006F, eval("x = new Function( 'this.charCodeAt = String.prototype.charCodeAt' ); f = new x(); f.charCodeAt(1)") ); +new TestCase( SECTION, "x = new Function( 'this.charCodeAt = String.prototype.charCodeAt' ); f = new x(); f.charCodeAt(2)", 0x0062, eval("x = new Function( 'this.charCodeAt = String.prototype.charCodeAt' ); f = new x(); f.charCodeAt(2)") ); +new TestCase( SECTION, "x = new Function( 'this.charCodeAt = String.prototype.charCodeAt' ); f = new x(); f.charCodeAt(3)", 0x006A, eval("x = new Function( 'this.charCodeAt = String.prototype.charCodeAt' ); f = new x(); f.charCodeAt(3)") ); +new TestCase( SECTION, "x = new Function( 'this.charCodeAt = String.prototype.charCodeAt' ); f = new x(); f.charCodeAt(4)", 0x0065, eval("x = new Function( 'this.charCodeAt = String.prototype.charCodeAt' ); f = new x(); f.charCodeAt(4)") ); +new TestCase( SECTION, "x = new Function( 'this.charCodeAt = String.prototype.charCodeAt' ); f = new x(); f.charCodeAt(5)", 0x0063, eval("x = new Function( 'this.charCodeAt = String.prototype.charCodeAt' ); f = new x(); f.charCodeAt(5)") ); +new TestCase( SECTION, "x = new Function( 'this.charCodeAt = String.prototype.charCodeAt' ); f = new x(); f.charCodeAt(6)", 0x0074, eval("x = new Function( 'this.charCodeAt = String.prototype.charCodeAt' ); f = new x(); f.charCodeAt(6)") ); + +new TestCase( SECTION, "x = new Function( 'this.charCodeAt = String.prototype.charCodeAt' ); f = new x(); f.charCodeAt(7)", 0x0020, eval("x = new Function( 'this.charCodeAt = String.prototype.charCodeAt' ); f = new x(); f.charCodeAt(7)") ); + +new TestCase( SECTION, "x = new Function( 'this.charCodeAt = String.prototype.charCodeAt' ); f = new x(); f.charCodeAt(8)", 0x004F, eval("x = new Function( 'this.charCodeAt = String.prototype.charCodeAt' ); f = new x(); f.charCodeAt(8)") ); +new TestCase( SECTION, "x = new Function( 'this.charCodeAt = String.prototype.charCodeAt' ); f = new x(); f.charCodeAt(9)", 0x0062, eval("x = new Function( 'this.charCodeAt = String.prototype.charCodeAt' ); f = new x(); f.charCodeAt(9)") ); +new TestCase( SECTION, "x = new Function( 'this.charCodeAt = String.prototype.charCodeAt' ); f = new x(); f.charCodeAt(10)", 0x006A, eval("x = new Function( 'this.charCodeAt = String.prototype.charCodeAt' ); f = new x(); f.charCodeAt(10)") ); + +test(); diff --git a/tests/auto/qml/parserstress/tests/ecma/String/15.5.4.5-3.js b/tests/auto/qml/parserstress/tests/ecma/String/15.5.4.5-3.js new file mode 100644 index 0000000000..46852f4022 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/String/15.5.4.5-3.js @@ -0,0 +1,131 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.5.4.5-3.js'; + +/** + File Name: 15.5.4.5-3.js + ECMA Section: 15.5.4.5 String.prototype.charCodeAt(pos) + Description: Returns a number (a nonnegative integer less than 2^16) + representing the Unicode encoding of the character at + position pos in this string. If there is no character + at that position, the number is NaN. + + When the charCodeAt method is called with one argument + pos, the following steps are taken: + 1. Call ToString, giving it the theis value as its + argument + 2. Call ToInteger(pos) + 3. Compute the number of characters in result(1). + 4. If Result(2) is less than 0 or is not less than + Result(3), return NaN. + 5. Return a value of Number type, of positive sign, whose + magnitude is the Unicode encoding of one character + from result 1, namely the characer at position Result + (2), where the first character in Result(1) is + considered to be at position 0. + + Note that the charCodeAt funciton is intentionally + generic; it does not require that its this value be a + String object. Therefore it can be transferred to other + kinds of objects for use as a method. + + Author: christine@netscape.com + Date: 2 october 1997 +*/ +var SECTION = "15.5.4.5-3"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "String.prototype.charCodeAt"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +var TEST_STRING = new String( " !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~" ); + + +var foo = new MyObject('hello'); + +new TestCase( SECTION, "var foo = new MyObject('hello');foo.charCodeAt(0)", 0x0068, foo.charCodeAt(0) ); +new TestCase( SECTION, "var foo = new MyObject('hello');foo.charCodeAt(1)", 0x0065, foo.charCodeAt(1) ); +new TestCase( SECTION, "var foo = new MyObject('hello');foo.charCodeAt(2)", 0x006c, foo.charCodeAt(2) ); +new TestCase( SECTION, "var foo = new MyObject('hello');foo.charCodeAt(3)", 0x006c, foo.charCodeAt(3) ); +new TestCase( SECTION, "var foo = new MyObject('hello');foo.charCodeAt(4)", 0x006f, foo.charCodeAt(4) ); +new TestCase( SECTION, "var foo = new MyObject('hello');foo.charCodeAt(-1)", Number.NaN, foo.charCodeAt(-1) ); +new TestCase( SECTION, "var foo = new MyObject('hello');foo.charCodeAt(5)", Number.NaN, foo.charCodeAt(5) ); + +var boo = new MyObject(true); + +new TestCase( SECTION, "var boo = new MyObject(true);boo.charCodeAt(0)", 0x0074, boo.charCodeAt(0) ); +new TestCase( SECTION, "var boo = new MyObject(true);boo.charCodeAt(1)", 0x0072, boo.charCodeAt(1) ); +new TestCase( SECTION, "var boo = new MyObject(true);boo.charCodeAt(2)", 0x0075, boo.charCodeAt(2) ); +new TestCase( SECTION, "var boo = new MyObject(true);boo.charCodeAt(3)", 0x0065, boo.charCodeAt(3) ); + +var noo = new MyObject( Math.PI ); + +new TestCase( SECTION, "var noo = new MyObject(Math.PI);noo.charCodeAt(0)", 0x0033, noo.charCodeAt(0) ); +new TestCase( SECTION, "var noo = new MyObject(Math.PI);noo.charCodeAt(1)", 0x002E, noo.charCodeAt(1) ); +new TestCase( SECTION, "var noo = new MyObject(Math.PI);noo.charCodeAt(2)", 0x0031, noo.charCodeAt(2) ); +new TestCase( SECTION, "var noo = new MyObject(Math.PI);noo.charCodeAt(3)", 0x0034, noo.charCodeAt(3) ); +new TestCase( SECTION, "var noo = new MyObject(Math.PI);noo.charCodeAt(4)", 0x0031, noo.charCodeAt(4) ); +new TestCase( SECTION, "var noo = new MyObject(Math.PI);noo.charCodeAt(5)", 0x0035, noo.charCodeAt(5) ); +new TestCase( SECTION, "var noo = new MyObject(Math.PI);noo.charCodeAt(6)", 0x0039, noo.charCodeAt(6) ); + +var noo = new MyObject( null ); + +new TestCase( SECTION, "var noo = new MyObject(null);noo.charCodeAt(0)", 0x006E, noo.charCodeAt(0) ); +new TestCase( SECTION, "var noo = new MyObject(null);noo.charCodeAt(1)", 0x0075, noo.charCodeAt(1) ); +new TestCase( SECTION, "var noo = new MyObject(null);noo.charCodeAt(2)", 0x006C, noo.charCodeAt(2) ); +new TestCase( SECTION, "var noo = new MyObject(null);noo.charCodeAt(3)", 0x006C, noo.charCodeAt(3) ); +new TestCase( SECTION, "var noo = new MyObject(null);noo.charCodeAt(4)", NaN, noo.charCodeAt(4) ); + +var noo = new MyObject( void 0 ); + +new TestCase( SECTION, "var noo = new MyObject(void 0);noo.charCodeAt(0)", 0x0075, noo.charCodeAt(0) ); +new TestCase( SECTION, "var noo = new MyObject(void 0);noo.charCodeAt(1)", 0x006E, noo.charCodeAt(1) ); +new TestCase( SECTION, "var noo = new MyObject(void 0);noo.charCodeAt(2)", 0x0064, noo.charCodeAt(2) ); +new TestCase( SECTION, "var noo = new MyObject(void 0);noo.charCodeAt(3)", 0x0065, noo.charCodeAt(3) ); +new TestCase( SECTION, "var noo = new MyObject(void 0);noo.charCodeAt(4)", 0x0066, noo.charCodeAt(4) ); + +test(); + + +function MyObject (v) { + this.value = v; + this.toString = new Function ( "return this.value +\"\"" ); + this.charCodeAt = String.prototype.charCodeAt; +} diff --git a/tests/auto/qml/parserstress/tests/ecma/String/15.5.4.5-4.js b/tests/auto/qml/parserstress/tests/ecma/String/15.5.4.5-4.js new file mode 100644 index 0000000000..e1d42c820f --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/String/15.5.4.5-4.js @@ -0,0 +1,75 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.5.4.5-4.js'; + +/** + File Name: 15.5.4.5-4.js + ECMA Section: 15.5.4.5 String.prototype.charCodeAt(pos) + + Description: Returns a nonnegative integer less than 2^16. + + Author: christine@netscape.com + Date: 28 october 1997 + +*/ +var VERSION = "0697"; +startTest(); +var SECTION = "15.5.4.5-4"; + +writeHeaderToLog( SECTION + " String.prototype.charCodeAt(pos)" ); + +var MAXCHARCODE = Math.pow(2,16); +var item=0, CHARCODE; + +for ( CHARCODE=0; CHARCODE <256; CHARCODE++ ) { + new TestCase( SECTION, + "(String.fromCharCode("+CHARCODE+")).charCodeAt(0)", + CHARCODE, + (String.fromCharCode(CHARCODE)).charCodeAt(0) ); +} +for ( CHARCODE=256; CHARCODE < 65536; CHARCODE+=999 ) { + new TestCase( SECTION, + "(String.fromCharCode("+CHARCODE+")).charCodeAt(0)", + CHARCODE, + (String.fromCharCode(CHARCODE)).charCodeAt(0) ); +} + +new TestCase( SECTION, "(String.fromCharCode(65535)).charCodeAt(0)", 65535, (String.fromCharCode(65535)).charCodeAt(0) ); + +test(); diff --git a/tests/auto/qml/parserstress/tests/ecma/String/15.5.4.5-5.js b/tests/auto/qml/parserstress/tests/ecma/String/15.5.4.5-5.js new file mode 100644 index 0000000000..cb3ec71e25 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/String/15.5.4.5-5.js @@ -0,0 +1,106 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.5.4.5-5.js'; + +/** + File Name: 15.5.4.5.1.js + ECMA Section: 15.5.4.5 String.prototype.charCodeAt(pos) + Description: Returns a number (a nonnegative integer less than 2^16) + representing the Unicode encoding of the character at + position pos in this string. If there is no character + at that position, the number is NaN. + + When the charCodeAt method is called with one argument + pos, the following steps are taken: + 1. Call ToString, giving it the theis value as its + argument + 2. Call ToInteger(pos) + 3. Compute the number of characters in result(1). + 4. If Result(2) is less than 0 or is not less than + Result(3), return NaN. + 5. Return a value of Number type, of positive sign, whose + magnitude is the Unicode encoding of one character + from result 1, namely the characer at position Result + (2), where the first character in Result(1) is + considered to be at position 0. + + Note that the charCodeAt funciton is intentionally + generic; it does not require that its this value be a + String object. Therefore it can be transferred to other + kinds of objects for use as a method. + + Author: christine@netscape.com + Date: 2 october 1997 +*/ +var SECTION = "15.5.4.5-5"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "String.prototype.charCodeAt"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +var TEST_STRING = ""; + +for ( var i = 0x0000; i < 255; i++ ) { + TEST_STRING += String.fromCharCode( i ); +} + +new TestCase( SECTION, "x = new Boolean(true); x.charCodeAt=String.prototype.charCodeAt;x.charCodeAt(0)", 0x0074, eval("x = new Boolean(true); x.charCodeAt=String.prototype.charCodeAt;x.charCodeAt(0)") ); +new TestCase( SECTION, "x = new Boolean(true); x.charCodeAt=String.prototype.charCodeAt;x.charCodeAt(1)", 0x0072, eval("x = new Boolean(true); x.charCodeAt=String.prototype.charCodeAt;x.charCodeAt(1)") ); +new TestCase( SECTION, "x = new Boolean(true); x.charCodeAt=String.prototype.charCodeAt;x.charCodeAt(2)", 0x0075, eval("x = new Boolean(true); x.charCodeAt=String.prototype.charCodeAt;x.charCodeAt(2)") ); +new TestCase( SECTION, "x = new Boolean(true); x.charCodeAt=String.prototype.charCodeAt;x.charCodeAt(3)", 0x0065, eval("x = new Boolean(true); x.charCodeAt=String.prototype.charCodeAt;x.charCodeAt(3)") ); +new TestCase( SECTION, "x = new Boolean(true); x.charCodeAt=String.prototype.charCodeAt;x.charCodeAt(4)", Number.NaN, eval("x = new Boolean(true); x.charCodeAt=String.prototype.charCodeAt;x.charCodeAt(4)") ); +new TestCase( SECTION, "x = new Boolean(true); x.charCodeAt=String.prototype.charCodeAt;x.charCodeAt(-1)", Number.NaN, eval("x = new Boolean(true); x.charCodeAt=String.prototype.charCodeAt;x.charCodeAt(-1)") ); + +new TestCase( SECTION, "x = new Boolean(true); x.charCodeAt=String.prototype.charCodeAt;x.charCodeAt(true)", 0x0072, eval("x = new Boolean(true); x.charCodeAt=String.prototype.charCodeAt;x.charCodeAt(true)") ); +new TestCase( SECTION, "x = new Boolean(true); x.charCodeAt=String.prototype.charCodeAt;x.charCodeAt(false)", 0x0074, eval("x = new Boolean(true); x.charCodeAt=String.prototype.charCodeAt;x.charCodeAt(false)") ); + +new TestCase( SECTION, "x = new String(); x.charCodeAt(0)", Number.NaN, eval("x=new String();x.charCodeAt(0)") ); +new TestCase( SECTION, "x = new String(); x.charCodeAt(1)", Number.NaN, eval("x=new String();x.charCodeAt(1)") ); +new TestCase( SECTION, "x = new String(); x.charCodeAt(-1)", Number.NaN, eval("x=new String();x.charCodeAt(-1)") ); + +new TestCase( SECTION, "x = new String(); x.charCodeAt(NaN)", Number.NaN, eval("x=new String();x.charCodeAt(Number.NaN)") ); +new TestCase( SECTION, "x = new String(); x.charCodeAt(Number.POSITIVE_INFINITY)", Number.NaN, eval("x=new String();x.charCodeAt(Number.POSITIVE_INFINITY)") ); +new TestCase( SECTION, "x = new String(); x.charCodeAt(Number.NEGATIVE_INFINITY)", Number.NaN, eval("x=new String();x.charCodeAt(Number.NEGATIVE_INFINITY)") ); + +for ( var j = 0; j < 255; j++ ) { + new TestCase( SECTION, "TEST_STRING.charCodeAt("+j+")", j, TEST_STRING.charCodeAt(j) ); +} + +test(); diff --git a/tests/auto/qml/parserstress/tests/ecma/String/15.5.4.6-1.js b/tests/auto/qml/parserstress/tests/ecma/String/15.5.4.6-1.js new file mode 100644 index 0000000000..94e34ad5ed --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/String/15.5.4.6-1.js @@ -0,0 +1,155 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.5.4.6-1.js'; + +/** + File Name: 15.5.4.6-1.js + ECMA Section: 15.5.4.6 String.prototype.indexOf( searchString, pos) + Description: If the given searchString appears as a substring of the + result of converting this object to a string, at one or + more positions that are at or to the right of the + specified position, then the index of the leftmost such + position is returned; otherwise -1 is returned. If + positionis undefined or not supplied, 0 is assumed, so + as to search all of the string. + + When the indexOf method is called with two arguments, + searchString and pos, the following steps are taken: + + 1. Call ToString, giving it the this value as its + argument. + 2. Call ToString(searchString). + 3. Call ToInteger(position). (If position is undefined + or not supplied, this step produces the value 0). + 4. Compute the number of characters in Result(1). + 5. Compute min(max(Result(3), 0), Result(4)). + 6. Compute the number of characters in the string that + is Result(2). + 7. Compute the smallest possible integer k not smaller + than Result(5) such that k+Result(6) is not greater + than Result(4), and for all nonnegative integers j + less than Result(6), the character at position k+j + of Result(1) is the same as the character at position + j of Result(2); but if there is no such integer k, + then compute the value -1. + 8. Return Result(7). + + Note that the indexOf function is intentionally generic; + it does not require that its this value be a String object. + Therefore it can be transferred to other kinds of objects + for use as a method. + + Author: christine@netscape.com + Date: 2 october 1997 +*/ +var SECTION = "15.5.4.6-1"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "String.protoype.indexOf"; + +var TEST_STRING = new String( " !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~" ); + +writeHeaderToLog( SECTION + " "+ TITLE); + +var j = 0; + +for ( k = 0, i = 0x0020; i < 0x007e; i++, j++, k++ ) { + new TestCase( SECTION, + "String.indexOf(" +String.fromCharCode(i)+ ", 0)", + k, + TEST_STRING.indexOf( String.fromCharCode(i), 0 ) ); +} + +for ( k = 0, i = 0x0020; i < 0x007e; i++, j++, k++ ) { + new TestCase( SECTION, + "String.indexOf("+String.fromCharCode(i)+ ", "+ k +")", + k, + TEST_STRING.indexOf( String.fromCharCode(i), k ) ); +} + +for ( k = 0, i = 0x0020; i < 0x007e; i++, j++, k++ ) { + new TestCase( SECTION, + "String.indexOf("+String.fromCharCode(i)+ ", "+k+1+")", + -1, + TEST_STRING.indexOf( String.fromCharCode(i), k+1 ) ); +} + +for ( k = 0, i = 0x0020; i < 0x007d; i++, j++, k++ ) { + new TestCase( SECTION, + "String.indexOf("+(String.fromCharCode(i) + + String.fromCharCode(i+1)+ + String.fromCharCode(i+2)) +", "+0+")", + k, + TEST_STRING.indexOf( (String.fromCharCode(i)+ + String.fromCharCode(i+1)+ + String.fromCharCode(i+2)), + 0 ) ); +} + +for ( k = 0, i = 0x0020; i < 0x007d; i++, j++, k++ ) { + new TestCase( SECTION, + "String.indexOf("+(String.fromCharCode(i) + + String.fromCharCode(i+1)+ + String.fromCharCode(i+2)) +", "+ k +")", + k, + TEST_STRING.indexOf( (String.fromCharCode(i)+ + String.fromCharCode(i+1)+ + String.fromCharCode(i+2)), + k ) ); +} +for ( k = 0, i = 0x0020; i < 0x007d; i++, j++, k++ ) { + new TestCase( SECTION, + "String.indexOf("+(String.fromCharCode(i) + + String.fromCharCode(i+1)+ + String.fromCharCode(i+2)) +", "+ k+1 +")", + -1, + TEST_STRING.indexOf( (String.fromCharCode(i)+ + String.fromCharCode(i+1)+ + String.fromCharCode(i+2)), + k+1 ) ); +} + +new TestCase( SECTION, "String.indexOf(" +TEST_STRING + ", 0 )", 0, TEST_STRING.indexOf( TEST_STRING, 0 ) ); + +new TestCase( SECTION, "String.indexOf(" +TEST_STRING + ", 1 )", -1, TEST_STRING.indexOf( TEST_STRING, 1 )); + +print( "TEST_STRING = new String(\" !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~\")" ); + + +test(); diff --git a/tests/auto/qml/parserstress/tests/ecma/String/15.5.4.6-2.js b/tests/auto/qml/parserstress/tests/ecma/String/15.5.4.6-2.js new file mode 100644 index 0000000000..acaeffb38a --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/String/15.5.4.6-2.js @@ -0,0 +1,259 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.5.4.6-2.js'; + +/** + File Name: 15.5.4.6-1.js + ECMA Section: 15.5.4.6 String.prototype.indexOf( searchString, pos) + Description: If the given searchString appears as a substring of the + result of converting this object to a string, at one or + more positions that are at or to the right of the + specified position, then the index of the leftmost such + position is returned; otherwise -1 is returned. If + positionis undefined or not supplied, 0 is assumed, so + as to search all of the string. + + When the indexOf method is called with two arguments, + searchString and pos, the following steps are taken: + + 1. Call ToString, giving it the this value as its + argument. + 2. Call ToString(searchString). + 3. Call ToInteger(position). (If position is undefined + or not supplied, this step produces the value 0). + 4. Compute the number of characters in Result(1). + 5. Compute min(max(Result(3), 0), Result(4)). + 6. Compute the number of characters in the string that + is Result(2). + 7. Compute the smallest possible integer k not smaller + than Result(5) such that k+Result(6) is not greater + than Result(4), and for all nonnegative integers j + less than Result(6), the character at position k+j + of Result(1) is the same as the character at position + j of Result(2); but if there is no such integer k, + then compute the value -1. + 8. Return Result(7). + + Note that the indexOf function is intentionally generic; + it does not require that its this value be a String object. + Therefore it can be transferred to other kinds of objects + for use as a method. + + Author: christine@netscape.com, pschwartau@netscape.com + Date: 02 October 1997 + Modified: 14 July 2002 + Reason: See http://bugzilla.mozilla.org/show_bug.cgi?id=155289 + ECMA-262 Ed.3 Section 15.5.4.7 + The length property of the indexOf method is 1 + * + */ +var SECTION = "15.5.4.6-2"; +var VERSION = "ECMA_1"; +var TITLE = "String.protoype.indexOf"; +var BUGNUMBER="105721"; + +startTest(); + +writeHeaderToLog( SECTION + " "+ TITLE); + + +// the following test regresses http://scopus/bugsplat/show_bug.cgi?id=105721 + +// regress http://scopus/bugsplat/show_bug.cgi?id=105721 + +new TestCase( SECTION, + "function f() { return this; }; function g() { var h = f; return h(); }; g().toString()", + GLOBAL, + g().toString() + ); + + +new TestCase( SECTION, "String.prototype.indexOf.length", 1, String.prototype.indexOf.length ); +new TestCase( SECTION, "String.prototype.indexOf.length = null; String.prototype.indexOf.length", 1, eval("String.prototype.indexOf.length = null; String.prototype.indexOf.length") ); +new TestCase( SECTION, "delete String.prototype.indexOf.length", false, delete String.prototype.indexOf.length ); +new TestCase( SECTION, "delete String.prototype.indexOf.length; String.prototype.indexOf.length", 1, eval("delete String.prototype.indexOf.length; String.prototype.indexOf.length") ); + +new TestCase( SECTION, + "var s = new String(); s.indexOf()", + -1, + eval("var s = new String(); s.indexOf()") ); + +// some Unicode tests. + +// generate a test string. + +var TEST_STRING = ""; + +for ( var u = 0x00A1; u <= 0x00FF; u++ ) { + TEST_STRING += String.fromCharCode( u ); +} + +for ( var u = 0x00A1, i = 0; u <= 0x00FF; u++, i++ ) { + new TestCase( SECTION, + "TEST_STRING.indexOf( " + String.fromCharCode(u) + " )", + i, + TEST_STRING.indexOf( String.fromCharCode(u) ) ); +} +for ( var u = 0x00A1, i = 0; u <= 0x00FF; u++, i++ ) { + new TestCase( SECTION, + "TEST_STRING.indexOf( " + String.fromCharCode(u) + ", void 0 )", + i, + TEST_STRING.indexOf( String.fromCharCode(u), void 0 ) ); +} + + + +var foo = new MyObject('hello'); + +new TestCase( SECTION, "var foo = new MyObject('hello');foo.indexOf('h')", 0, foo.indexOf("h") ); +new TestCase( SECTION, "var foo = new MyObject('hello');foo.indexOf('e')", 1, foo.indexOf("e") ); +new TestCase( SECTION, "var foo = new MyObject('hello');foo.indexOf('l')", 2, foo.indexOf("l") ); +new TestCase( SECTION, "var foo = new MyObject('hello');foo.indexOf('l')", 2, foo.indexOf("l") ); +new TestCase( SECTION, "var foo = new MyObject('hello');foo.indexOf('o')", 4, foo.indexOf("o") ); +new TestCase( SECTION, "var foo = new MyObject('hello');foo.indexOf('X')", -1, foo.indexOf("X") ); +new TestCase( SECTION, "var foo = new MyObject('hello');foo.indexOf(5) ", -1, foo.indexOf(5) ); + +var boo = new MyObject(true); + +new TestCase( SECTION, "var boo = new MyObject(true);boo.indexOf('t')", 0, boo.indexOf("t") ); +new TestCase( SECTION, "var boo = new MyObject(true);boo.indexOf('r')", 1, boo.indexOf("r") ); +new TestCase( SECTION, "var boo = new MyObject(true);boo.indexOf('u')", 2, boo.indexOf("u") ); +new TestCase( SECTION, "var boo = new MyObject(true);boo.indexOf('e')", 3, boo.indexOf("e") ); +new TestCase( SECTION, "var boo = new MyObject(true);boo.indexOf('true')", 0, boo.indexOf("true") ); +new TestCase( SECTION, "var boo = new MyObject(true);boo.indexOf('rue')", 1, boo.indexOf("rue") ); +new TestCase( SECTION, "var boo = new MyObject(true);boo.indexOf('ue')", 2, boo.indexOf("ue") ); +new TestCase( SECTION, "var boo = new MyObject(true);boo.indexOf('oy')", -1, boo.indexOf("oy") ); + + +var noo = new MyObject( Math.PI ); +new TestCase( SECTION, "var noo = new MyObject(Math.PI); noo.indexOf('3') ", 0, noo.indexOf('3') ); +new TestCase( SECTION, "var noo = new MyObject(Math.PI); noo.indexOf('.') ", 1, noo.indexOf('.') ); +new TestCase( SECTION, "var noo = new MyObject(Math.PI); noo.indexOf('1') ", 2, noo.indexOf('1') ); +new TestCase( SECTION, "var noo = new MyObject(Math.PI); noo.indexOf('4') ", 3, noo.indexOf('4') ); +new TestCase( SECTION, "var noo = new MyObject(Math.PI); noo.indexOf('1') ", 2, noo.indexOf('1') ); +new TestCase( SECTION, "var noo = new MyObject(Math.PI); noo.indexOf('5') ", 5, noo.indexOf('5') ); +new TestCase( SECTION, "var noo = new MyObject(Math.PI); noo.indexOf('9') ", 6, noo.indexOf('9') ); + +new TestCase( SECTION, + "var arr = new Array('new','zoo','revue'); arr.indexOf = String.prototype.indexOf; arr.indexOf('new')", + 0, + eval("var arr = new Array('new','zoo','revue'); arr.indexOf = String.prototype.indexOf; arr.indexOf('new')") ); + +new TestCase( SECTION, + "var arr = new Array('new','zoo','revue'); arr.indexOf = String.prototype.indexOf; arr.indexOf(',zoo,')", + 3, + eval("var arr = new Array('new','zoo','revue'); arr.indexOf = String.prototype.indexOf; arr.indexOf(',zoo,')") ); + +new TestCase( SECTION, + "var obj = new Object(); obj.indexOf = String.prototype.indexOf; obj.indexOf('[object Object]')", + 0, + eval("var obj = new Object(); obj.indexOf = String.prototype.indexOf; obj.indexOf('[object Object]')") ); + +new TestCase( SECTION, + "var obj = new Object(); obj.indexOf = String.prototype.indexOf; obj.indexOf('bject')", + 2, + eval("var obj = new Object(); obj.indexOf = String.prototype.indexOf; obj.indexOf('bject')") ); + +new TestCase( SECTION, + "var f = new Object( String.prototype.indexOf ); f('"+GLOBAL+"')", + 0, + eval("var f = new Object( String.prototype.indexOf ); f('"+GLOBAL+"')") ); + +new TestCase( SECTION, + "var f = new Function(); f.toString = Object.prototype.toString; f.indexOf = String.prototype.indexOf; f.indexOf('[object Function]')", + 0, + eval("var f = new Function(); f.toString = Object.prototype.toString; f.indexOf = String.prototype.indexOf; f.indexOf('[object Function]')") ); + +new TestCase( SECTION, + "var b = new Boolean(); b.indexOf = String.prototype.indexOf; b.indexOf('true')", + -1, + eval("var b = new Boolean(); b.indexOf = String.prototype.indexOf; b.indexOf('true')") ); + +new TestCase( SECTION, + "var b = new Boolean(); b.indexOf = String.prototype.indexOf; b.indexOf('false', 1)", + -1, + eval("var b = new Boolean(); b.indexOf = String.prototype.indexOf; b.indexOf('false', 1)") ); + +new TestCase( SECTION, + "var b = new Boolean(); b.indexOf = String.prototype.indexOf; b.indexOf('false', 0)", + 0, + eval("var b = new Boolean(); b.indexOf = String.prototype.indexOf; b.indexOf('false', 0)") ); + +new TestCase( SECTION, + "var n = new Number(1e21); n.indexOf = String.prototype.indexOf; n.indexOf('e')", + 1, + eval("var n = new Number(1e21); n.indexOf = String.prototype.indexOf; n.indexOf('e')") ); + +new TestCase( SECTION, + "var n = new Number(-Infinity); n.indexOf = String.prototype.indexOf; n.indexOf('-')", + 0, + eval("var n = new Number(-Infinity); n.indexOf = String.prototype.indexOf; n.indexOf('-')") ); + +new TestCase( SECTION, + "var n = new Number(0xFF); n.indexOf = String.prototype.indexOf; n.indexOf('5')", + 1, + eval("var n = new Number(0xFF); n.indexOf = String.prototype.indexOf; n.indexOf('5')") ); + +new TestCase( SECTION, + "var m = Math; m.indexOf = String.prototype.indexOf; m.indexOf( 'Math' )", + 8, + eval("var m = Math; m.indexOf = String.prototype.indexOf; m.indexOf( 'Math' )") ); + +// new Date(0) has '31' or '01' at index 8 depending on whether tester is (GMT-) or (GMT+), respectively +new TestCase( SECTION, + "var d = new Date(0); d.indexOf = String.prototype.indexOf; d.getTimezoneOffset()>0 ? d.indexOf('31') : d.indexOf('01')", + 8, + eval("var d = new Date(0); d.indexOf = String.prototype.indexOf; d.getTimezoneOffset()>0 ? d.indexOf('31') : d.indexOf('01')") ); + +test(); + +function f() { + return this; +} +function g() { + var h = f; + return h(); +} + +function MyObject (v) { + this.value = v; + this.toString = new Function ( "return this.value +\"\""); + this.indexOf = String.prototype.indexOf; +} + diff --git a/tests/auto/qml/parserstress/tests/ecma/String/15.5.4.7-1.js b/tests/auto/qml/parserstress/tests/ecma/String/15.5.4.7-1.js new file mode 100644 index 0000000000..094be2ed62 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/String/15.5.4.7-1.js @@ -0,0 +1,219 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.5.4.7-1.js'; + +/** + File Name: 15.5.4.7-1.js + ECMA Section: 15.5.4.7 String.prototype.lastIndexOf( searchString, pos) + Description: + + If the given searchString appears as a substring of the result of + converting this object to a string, at one or more positions that are + at or to the left of the specified position, then the index of the + rightmost such position is returned; otherwise -1 is returned. If position + is undefined or not supplied, the length of this string value is assumed, + so as to search all of the string. + + When the lastIndexOf method is called with two arguments searchString and + position, the following steps are taken: + + 1.Call ToString, giving it the this value as its argument. + 2.Call ToString(searchString). + 3.Call ToNumber(position). (If position is undefined or not supplied, this step produces the value NaN). + 4.If Result(3) is NaN, use +; otherwise, call ToInteger(Result(3)). + 5.Compute the number of characters in Result(1). + 6.Compute min(max(Result(4), 0), Result(5)). + 7.Compute the number of characters in the string that is Result(2). + 8.Compute the largest possible integer k not larger than Result(6) such that k+Result(7) is not greater + than Result(5), and for all nonnegative integers j less than Result(7), the character at position k+j of + Result(1) is the same as the character at position j of Result(2); but if there is no such integer k, then + compute the value -1. + + 1.Return Result(8). + + Note that the lastIndexOf function is intentionally generic; it does not require that its this value be a + String object. Therefore it can be transferred to other kinds of objects for use as a method. + + Author: christine@netscape.com + Date: 2 october 1997 +*/ +var SECTION = "15.5.4.7-1"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "String.protoype.lastIndexOf"; + +var TEST_STRING = new String( " !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~" ); + +writeHeaderToLog( SECTION + " "+ TITLE); + +var j = 0; + +for ( k = 0, i = 0x0021; i < 0x007e; i++, j++, k++ ) { + new TestCase( SECTION, + "String.lastIndexOf(" +String.fromCharCode(i)+ ", 0)", + -1, + TEST_STRING.lastIndexOf( String.fromCharCode(i), 0 ) ); +} + +for ( k = 0, i = 0x0020; i < 0x007e; i++, j++, k++ ) { + new TestCase( SECTION, + "String.lastIndexOf("+String.fromCharCode(i)+ ", "+ k +")", + k, + TEST_STRING.lastIndexOf( String.fromCharCode(i), k ) ); +} + +for ( k = 0, i = 0x0020; i < 0x007e; i++, j++, k++ ) { + new TestCase( SECTION, + "String.lastIndexOf("+String.fromCharCode(i)+ ", "+k+1+")", + k, + TEST_STRING.lastIndexOf( String.fromCharCode(i), k+1 ) ); +} + +for ( k = 9, i = 0x0021; i < 0x007d; i++, j++, k++ ) { + new TestCase( SECTION, + + "String.lastIndexOf("+(String.fromCharCode(i) + + String.fromCharCode(i+1)+ + String.fromCharCode(i+2)) +", "+ 0 + ")", + LastIndexOf( TEST_STRING, String.fromCharCode(i) + + String.fromCharCode(i+1)+String.fromCharCode(i+2), 0), + TEST_STRING.lastIndexOf( (String.fromCharCode(i)+ + String.fromCharCode(i+1)+ + String.fromCharCode(i+2)), + 0 ) ); +} + +for ( k = 0, i = 0x0020; i < 0x007d; i++, j++, k++ ) { + new TestCase( SECTION, + "String.lastIndexOf("+(String.fromCharCode(i) + + String.fromCharCode(i+1)+ + String.fromCharCode(i+2)) +", "+ k +")", + k, + TEST_STRING.lastIndexOf( (String.fromCharCode(i)+ + String.fromCharCode(i+1)+ + String.fromCharCode(i+2)), + k ) ); +} +for ( k = 0, i = 0x0020; i < 0x007d; i++, j++, k++ ) { + new TestCase( SECTION, + "String.lastIndexOf("+(String.fromCharCode(i) + + String.fromCharCode(i+1)+ + String.fromCharCode(i+2)) +", "+ k+1 +")", + k, + TEST_STRING.lastIndexOf( (String.fromCharCode(i)+ + String.fromCharCode(i+1)+ + String.fromCharCode(i+2)), + k+1 ) ); +} +for ( k = 0, i = 0x0020; i < 0x007d; i++, j++, k++ ) { + new TestCase( SECTION, + "String.lastIndexOf("+ + (String.fromCharCode(i) + + String.fromCharCode(i+1)+ + String.fromCharCode(i+2)) +", "+ (k-1) +")", + LastIndexOf( TEST_STRING, String.fromCharCode(i) + + String.fromCharCode(i+1)+String.fromCharCode(i+2), k-1), + TEST_STRING.lastIndexOf( (String.fromCharCode(i)+ + String.fromCharCode(i+1)+ + String.fromCharCode(i+2)), + k-1 ) ); +} + +new TestCase( SECTION, "String.lastIndexOf(" +TEST_STRING + ", 0 )", 0, TEST_STRING.lastIndexOf( TEST_STRING, 0 ) ); + +// new TestCase( SECTION, "String.lastIndexOf(" +TEST_STRING + ", 1 )", 0, TEST_STRING.lastIndexOf( TEST_STRING, 1 )); + +new TestCase( SECTION, "String.lastIndexOf(" +TEST_STRING + ")", 0, TEST_STRING.lastIndexOf( TEST_STRING )); + +print( "TEST_STRING = new String(\" !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~\")" ); + +test(); + +function LastIndexOf( string, search, position ) { + string = String( string ); + search = String( search ); + + position = Number( position ) + + if ( isNaN( position ) ) { + position = Infinity; + } else { + position = ToInteger( position ); + } + + result5= string.length; + result6 = Math.min(Math.max(position, 0), result5); + result7 = search.length; + + if (result7 == 0) { + return Math.min(position, result5); + } + + result8 = -1; + + for ( k = 0; k <= result6; k++ ) { + if ( k+ result7 > result5 ) { + break; + } + for ( j = 0; j < result7; j++ ) { + if ( string.charAt(k+j) != search.charAt(j) ){ + break; + } else { + if ( j == result7 -1 ) { + result8 = k; + } + } + } + } + + return result8; +} +function ToInteger( n ) { + n = Number( n ); + if ( isNaN(n) ) { + return 0; + } + if ( Math.abs(n) == 0 || Math.abs(n) == Infinity ) { + return n; + } + + var sign = ( n < 0 ) ? -1 : 1; + + return ( sign * Math.floor(Math.abs(n)) ); +} diff --git a/tests/auto/qml/parserstress/tests/ecma/String/15.5.4.7-2.js b/tests/auto/qml/parserstress/tests/ecma/String/15.5.4.7-2.js new file mode 100644 index 0000000000..0252eae00f --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/String/15.5.4.7-2.js @@ -0,0 +1,217 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.5.4.7-2.js'; + +/** + File Name: 15.5.4.7-2.js + ECMA Section: 15.5.4.7 String.prototype.lastIndexOf( searchString, pos) + Description: + + If the given searchString appears as a substring of the result of + converting this object to a string, at one or more positions that are + at or to the left of the specified position, then the index of the + rightmost such position is returned; otherwise -1 is returned. If position + is undefined or not supplied, the length of this string value is assumed, + so as to search all of the string. + + When the lastIndexOf method is called with two arguments searchString and + position, the following steps are taken: + + 1.Call ToString, giving it the this value as its argument. + 2.Call ToString(searchString). + 3.Call ToNumber(position). (If position is undefined or not supplied, this step produces the value NaN). + 4.If Result(3) is NaN, use +; otherwise, call ToInteger(Result(3)). + 5.Compute the number of characters in Result(1). + 6.Compute min(max(Result(4), 0), Result(5)). + 7.Compute the number of characters in the string that is Result(2). + 8.Compute the largest possible integer k not larger than Result(6) such that k+Result(7) is not greater + than Result(5), and for all nonnegative integers j less than Result(7), the character at position k+j of + Result(1) is the same as the character at position j of Result(2); but if there is no such integer k, then + compute the value -1. + + 1.Return Result(8). + + Note that the lastIndexOf function is intentionally generic; it does not require that its this value be a + String object. Therefore it can be transferred to other kinds of objects for use as a method. + + Author: christine@netscape.com, pschwartau@netscape.com + Date: 02 October 1997 + Modified: 14 July 2002 + Reason: See http://bugzilla.mozilla.org/show_bug.cgi?id=155289 + ECMA-262 Ed.3 Section 15.5.4.8 + The length property of the lastIndexOf method is 1 + * + */ +var SECTION = "15.5.4.7-2"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "String.protoype.lastIndexOf"; + +writeHeaderToLog( SECTION + " "+ TITLE); + + +new TestCase( SECTION, "String.prototype.lastIndexOf.length", 1, String.prototype.lastIndexOf.length ); +new TestCase( SECTION, "delete String.prototype.lastIndexOf.length", false, delete String.prototype.lastIndexOf.length ); +new TestCase( SECTION, "delete String.prototype.lastIndexOf.length; String.prototype.lastIndexOf.length", 1, eval("delete String.prototype.lastIndexOf.length; String.prototype.lastIndexOf.length" ) ); + +new TestCase( SECTION, "var s = new String(''); s.lastIndexOf('', 0)", LastIndexOf("","",0), eval("var s = new String(''); s.lastIndexOf('', 0)") ); +new TestCase( SECTION, "var s = new String(''); s.lastIndexOf('')", LastIndexOf("",""), eval("var s = new String(''); s.lastIndexOf('')") ); +new TestCase( SECTION, "var s = new String('hello'); s.lastIndexOf('', 0)", LastIndexOf("hello","",0), eval("var s = new String('hello'); s.lastIndexOf('',0)") ); +new TestCase( SECTION, "var s = new String('hello'); s.lastIndexOf('')", LastIndexOf("hello",""), eval("var s = new String('hello'); s.lastIndexOf('')") ); + +new TestCase( SECTION, "var s = new String('hello'); s.lastIndexOf('ll')", LastIndexOf("hello","ll"), eval("var s = new String('hello'); s.lastIndexOf('ll')") ); +new TestCase( SECTION, "var s = new String('hello'); s.lastIndexOf('ll', 0)", LastIndexOf("hello","ll",0), eval("var s = new String('hello'); s.lastIndexOf('ll', 0)") ); +new TestCase( SECTION, "var s = new String('hello'); s.lastIndexOf('ll', 1)", LastIndexOf("hello","ll",1), eval("var s = new String('hello'); s.lastIndexOf('ll', 1)") ); +new TestCase( SECTION, "var s = new String('hello'); s.lastIndexOf('ll', 2)", LastIndexOf("hello","ll",2), eval("var s = new String('hello'); s.lastIndexOf('ll', 2)") ); +new TestCase( SECTION, "var s = new String('hello'); s.lastIndexOf('ll', 3)", LastIndexOf("hello","ll",3), eval("var s = new String('hello'); s.lastIndexOf('ll', 3)") ); +new TestCase( SECTION, "var s = new String('hello'); s.lastIndexOf('ll', 4)", LastIndexOf("hello","ll",4), eval("var s = new String('hello'); s.lastIndexOf('ll', 4)") ); +new TestCase( SECTION, "var s = new String('hello'); s.lastIndexOf('ll', 5)", LastIndexOf("hello","ll",5), eval("var s = new String('hello'); s.lastIndexOf('ll', 5)") ); +new TestCase( SECTION, "var s = new String('hello'); s.lastIndexOf('ll', 6)", LastIndexOf("hello","ll",6), eval("var s = new String('hello'); s.lastIndexOf('ll', 6)") ); + +new TestCase( SECTION, "var s = new String('hello'); s.lastIndexOf('ll', 1.5)", LastIndexOf('hello','ll', 1.5), eval("var s = new String('hello'); s.lastIndexOf('ll', 1.5)") ); +new TestCase( SECTION, "var s = new String('hello'); s.lastIndexOf('ll', 2.5)", LastIndexOf('hello','ll', 2.5), eval("var s = new String('hello'); s.lastIndexOf('ll', 2.5)") ); +new TestCase( SECTION, "var s = new String('hello'); s.lastIndexOf('ll', -1)", LastIndexOf('hello','ll', -1), eval("var s = new String('hello'); s.lastIndexOf('ll', -1)") ); +new TestCase( SECTION, "var s = new String('hello'); s.lastIndexOf('ll', -1.5)",LastIndexOf('hello','ll', -1.5), eval("var s = new String('hello'); s.lastIndexOf('ll', -1.5)") ); + +new TestCase( SECTION, "var s = new String('hello'); s.lastIndexOf('ll', -Infinity)", LastIndexOf("hello","ll",-Infinity), eval("var s = new String('hello'); s.lastIndexOf('ll', -Infinity)") ); +new TestCase( SECTION, "var s = new String('hello'); s.lastIndexOf('ll', Infinity)", LastIndexOf("hello","ll",Infinity), eval("var s = new String('hello'); s.lastIndexOf('ll', Infinity)") ); +new TestCase( SECTION, "var s = new String('hello'); s.lastIndexOf('ll', NaN)", LastIndexOf("hello","ll",NaN), eval("var s = new String('hello'); s.lastIndexOf('ll', NaN)") ); +new TestCase( SECTION, "var s = new String('hello'); s.lastIndexOf('ll', -0)", LastIndexOf("hello","ll",-0), eval("var s = new String('hello'); s.lastIndexOf('ll', -0)") ); +for ( var i = 0; i < ( "[object Object]" ).length; i++ ) { + new TestCase( SECTION, + "var o = new Object(); o.lastIndexOf = String.prototype.lastIndexOf; o.lastIndexOf('b', "+ i + ")", + ( i < 2 ? -1 : ( i < 9 ? 2 : 9 )) , + eval("var o = new Object(); o.lastIndexOf = String.prototype.lastIndexOf; o.lastIndexOf('b', "+ i + ")") ); +} +for ( var i = 0; i < 5; i ++ ) { + new TestCase( SECTION, + "var b = new Boolean(); b.lastIndexOf = String.prototype.lastIndexOf; b.lastIndexOf('l', "+ i + ")", + ( i < 2 ? -1 : 2 ), + eval("var b = new Boolean(); b.lastIndexOf = String.prototype.lastIndexOf; b.lastIndexOf('l', "+ i + ")") ); +} +for ( var i = 0; i < 5; i ++ ) { + new TestCase( SECTION, + "var b = new Boolean(); b.toString = Object.prototype.toString; b.lastIndexOf = String.prototype.lastIndexOf; b.lastIndexOf('o', "+ i + ")", + ( i < 1 ? -1 : ( i < 9 ? 1 : ( i < 10 ? 9 : 10 ) ) ), + eval("var b = new Boolean(); b.toString = Object.prototype.toString; b.lastIndexOf = String.prototype.lastIndexOf; b.lastIndexOf('o', "+ i + ")") ); +} +for ( var i = 0; i < 9; i++ ) { + new TestCase( SECTION, + "var n = new Number(Infinity); n.lastIndexOf = String.prototype.lastIndexOf; n.lastIndexOf( 'i', " + i + " )", + ( i < 3 ? -1 : ( i < 5 ? 3 : 5 ) ), + eval("var n = new Number(Infinity); n.lastIndexOf = String.prototype.lastIndexOf; n.lastIndexOf( 'i', " + i + " )") ); +} +var a = new Array( "abc","def","ghi","jkl","mno","pqr","stu","vwx","yz" ); + +for ( var i = 0; i < (a.toString()).length; i++ ) { + new TestCase( SECTION, + "var a = new Array( 'abc','def','ghi','jkl','mno','pqr','stu','vwx','yz' ); a.lastIndexOf = String.prototype.lastIndexOf; a.lastIndexOf( ',mno,p', "+i+" )", + ( i < 15 ? -1 : 15 ), + eval("var a = new Array( 'abc','def','ghi','jkl','mno','pqr','stu','vwx','yz' ); a.lastIndexOf = String.prototype.lastIndexOf; a.lastIndexOf( ',mno,p', "+i+" )") ); +} + +for ( var i = 0; i < 15; i ++ ) { + new TestCase( SECTION, + "var m = Math; m.lastIndexOf = String.prototype.lastIndexOf; m.lastIndexOf('t', "+ i + ")", + ( i < 6 ? -1 : ( i < 10 ? 6 : 10 ) ), + eval("var m = Math; m.lastIndexOf = String.prototype.lastIndexOf; m.lastIndexOf('t', "+ i + ")") ); +} +/* + for ( var i = 0; i < 15; i++ ) { + new TestCase( SECTION, + "var d = new Date(); d.lastIndexOf = String.prototype.lastIndexOf; d.lastIndexOf( '0' )", + ) + } + +*/ + +test(); + +function LastIndexOf( string, search, position ) { + string = String( string ); + search = String( search ); + + position = Number( position ) + + if ( isNaN( position ) ) { + position = Infinity; + } else { + position = ToInteger( position ); + } + + result5= string.length; + result6 = Math.min(Math.max(position, 0), result5); + result7 = search.length; + + if (result7 == 0) { + return Math.min(position, result5); + } + + result8 = -1; + + for ( k = 0; k <= result6; k++ ) { + if ( k+ result7 > result5 ) { + break; + } + for ( j = 0; j < result7; j++ ) { + if ( string.charAt(k+j) != search.charAt(j) ){ + break; + } else { + if ( j == result7 -1 ) { + result8 = k; + } + } + } + } + + return result8; +} +function ToInteger( n ) { + n = Number( n ); + if ( isNaN(n) ) { + return 0; + } + if ( Math.abs(n) == 0 || Math.abs(n) == Infinity ) { + return n; + } + + var sign = ( n < 0 ) ? -1 : 1; + + return ( sign * Math.floor(Math.abs(n)) ); +} diff --git a/tests/auto/qml/parserstress/tests/ecma/String/15.5.4.8-1.js b/tests/auto/qml/parserstress/tests/ecma/String/15.5.4.8-1.js new file mode 100644 index 0000000000..4aa16d5ea0 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/String/15.5.4.8-1.js @@ -0,0 +1,232 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.5.4.8-1.js'; + +/** + File Name: 15.5.4.8-1.js + ECMA Section: 15.5.4.8 String.prototype.split( separator ) + Description: + + Returns an Array object into which substrings of the result of converting + this object to a string have been stored. The substrings are determined by + searching from left to right for occurrences of the given separator; these + occurrences are not part of any substring in the returned array, but serve + to divide up this string value. The separator may be a string of any length. + + As a special case, if the separator is the empty string, the string is split + up into individual characters; the length of the result array equals the + length of the string, and each substring contains one character. + + If the separator is not supplied, then the result array contains just one + string, which is the string. + + Author: christine@netscape.com, pschwartau@netscape.com + Date: 12 November 1997 + Modified: 14 July 2002 + Reason: See http://bugzilla.mozilla.org/show_bug.cgi?id=155289 + ECMA-262 Ed.3 Section 15.5.4.14 + The length property of the split method is 2 + * + */ + +var SECTION = "15.5.4.8-1"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "String.prototype.split"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +new TestCase( SECTION, "String.prototype.split.length", 2, String.prototype.split.length ); +new TestCase( SECTION, "delete String.prototype.split.length", false, delete String.prototype.split.length ); +new TestCase( SECTION, "delete String.prototype.split.length; String.prototype.split.length", 2, eval("delete String.prototype.split.length; String.prototype.split.length") ); + +// test cases for when split is called with no arguments. + +// this is a string object + +new TestCase( SECTION, + "var s = new String('this is a string object'); typeof s.split()", + "object", + eval("var s = new String('this is a string object'); typeof s.split()") ); + +new TestCase( SECTION, + "var s = new String('this is a string object'); Array.prototype.getClass = Object.prototype.toString; (s.split()).getClass()", + "[object Array]", + eval("var s = new String('this is a string object'); Array.prototype.getClass = Object.prototype.toString; (s.split()).getClass()") ); + +new TestCase( SECTION, + "var s = new String('this is a string object'); s.split().length", + 1, + eval("var s = new String('this is a string object'); s.split().length") ); + +new TestCase( SECTION, + "var s = new String('this is a string object'); s.split()[0]", + "this is a string object", + eval("var s = new String('this is a string object'); s.split()[0]") ); + +// this is an object object +new TestCase( SECTION, + "var obj = new Object(); obj.split = String.prototype.split; typeof obj.split()", + "object", + eval("var obj = new Object(); obj.split = String.prototype.split; typeof obj.split()") ); + +new TestCase( SECTION, + "var obj = new Object(); obj.split = String.prototype.split; Array.prototype.getClass = Object.prototype.toString; obj.getClass()", + "[object Array]", + eval("var obj = new Object(); obj.split = String.prototype.split; Array.prototype.getClass = Object.prototype.toString; obj.split().getClass()") ); + +new TestCase( SECTION, + "var obj = new Object(); obj.split = String.prototype.split; obj.split().length", + 1, + eval("var obj = new Object(); obj.split = String.prototype.split; obj.split().length") ); + +new TestCase( SECTION, + "var obj = new Object(); obj.split = String.prototype.split; obj.split()[0]", + "[object Object]", + eval("var obj = new Object(); obj.split = String.prototype.split; obj.split()[0]") ); + +// this is a function object +new TestCase( SECTION, + "var obj = new Function(); obj.split = String.prototype.split; typeof obj.split()", + "object", + eval("var obj = new Function(); obj.split = String.prototype.split; typeof obj.split()") ); + +new TestCase( SECTION, + "var obj = new Function(); obj.split = String.prototype.split; Array.prototype.getClass = Object.prototype.toString; obj.getClass()", + "[object Array]", + eval("var obj = new Function(); obj.split = String.prototype.split; Array.prototype.getClass = Object.prototype.toString; obj.split().getClass()") ); + +new TestCase( SECTION, + "var obj = new Function(); obj.split = String.prototype.split; obj.split().length", + 1, + eval("var obj = new Function(); obj.split = String.prototype.split; obj.split().length") ); + +new TestCase( SECTION, + "var obj = new Function(); obj.split = String.prototype.split; obj.toString = Object.prototype.toString; obj.split()[0]", + "[object Function]", + eval("var obj = new Function(); obj.split = String.prototype.split; obj.toString = Object.prototype.toString; obj.split()[0]") ); + +// this is a number object +new TestCase( SECTION, + "var obj = new Number(NaN); obj.split = String.prototype.split; typeof obj.split()", + "object", + eval("var obj = new Number(NaN); obj.split = String.prototype.split; typeof obj.split()") ); + +new TestCase( SECTION, + "var obj = new Number(Infinity); obj.split = String.prototype.split; Array.prototype.getClass = Object.prototype.toString; obj.getClass()", + "[object Array]", + eval("var obj = new Number(Infinity); obj.split = String.prototype.split; Array.prototype.getClass = Object.prototype.toString; obj.split().getClass()") ); + +new TestCase( SECTION, + "var obj = new Number(-1234567890); obj.split = String.prototype.split; obj.split().length", + 1, + eval("var obj = new Number(-1234567890); obj.split = String.prototype.split; obj.split().length") ); + +new TestCase( SECTION, + "var obj = new Number(-1e21); obj.split = String.prototype.split; obj.split()[0]", + "-1e+21", + eval("var obj = new Number(-1e21); obj.split = String.prototype.split; obj.split()[0]") ); + + +// this is the Math object +new TestCase( SECTION, + "var obj = Math; obj.split = String.prototype.split; typeof obj.split()", + "object", + eval("var obj = Math; obj.split = String.prototype.split; typeof obj.split()") ); + +new TestCase( SECTION, + "var obj = Math; obj.split = String.prototype.split; Array.prototype.getClass = Object.prototype.toString; obj.getClass()", + "[object Array]", + eval("var obj = Math; obj.split = String.prototype.split; Array.prototype.getClass = Object.prototype.toString; obj.split().getClass()") ); + +new TestCase( SECTION, + "var obj = Math; obj.split = String.prototype.split; obj.split().length", + 1, + eval("var obj = Math; obj.split = String.prototype.split; obj.split().length") ); + +new TestCase( SECTION, + "var obj = Math; obj.split = String.prototype.split; obj.split()[0]", + "[object Math]", + eval("var obj = Math; obj.split = String.prototype.split; obj.split()[0]") ); + +// this is an array object +new TestCase( SECTION, + "var obj = new Array(1,2,3,4,5); obj.split = String.prototype.split; typeof obj.split()", + "object", + eval("var obj = new Array(1,2,3,4,5); obj.split = String.prototype.split; typeof obj.split()") ); + +new TestCase( SECTION, + "var obj = new Array(1,2,3,4,5); obj.split = String.prototype.split; Array.prototype.getClass = Object.prototype.toString; obj.getClass()", + "[object Array]", + eval("var obj = new Array(1,2,3,4,5); obj.split = String.prototype.split; Array.prototype.getClass = Object.prototype.toString; obj.split().getClass()") ); + +new TestCase( SECTION, + "var obj = new Array(1,2,3,4,5); obj.split = String.prototype.split; obj.split().length", + 1, + eval("var obj = new Array(1,2,3,4,5); obj.split = String.prototype.split; obj.split().length") ); + +new TestCase( SECTION, + "var obj = new Array(1,2,3,4,5); obj.split = String.prototype.split; obj.split()[0]", + "1,2,3,4,5", + eval("var obj = new Array(1,2,3,4,5); obj.split = String.prototype.split; obj.split()[0]") ); + +// this is a Boolean object + +new TestCase( SECTION, + "var obj = new Boolean(); obj.split = String.prototype.split; typeof obj.split()", + "object", + eval("var obj = new Boolean(); obj.split = String.prototype.split; typeof obj.split()") ); + +new TestCase( SECTION, + "var obj = new Boolean(); obj.split = String.prototype.split; Array.prototype.getClass = Object.prototype.toString; obj.getClass()", + "[object Array]", + eval("var obj = new Boolean(); obj.split = String.prototype.split; Array.prototype.getClass = Object.prototype.toString; obj.split().getClass()") ); + +new TestCase( SECTION, + "var obj = new Boolean(); obj.split = String.prototype.split; obj.split().length", + 1, + eval("var obj = new Boolean(); obj.split = String.prototype.split; obj.split().length") ); + +new TestCase( SECTION, + "var obj = new Boolean(); obj.split = String.prototype.split; obj.split()[0]", + "false", + eval("var obj = new Boolean(); obj.split = String.prototype.split; obj.split()[0]") ); + + +test(); diff --git a/tests/auto/qml/parserstress/tests/ecma/String/15.5.4.8-2.js b/tests/auto/qml/parserstress/tests/ecma/String/15.5.4.8-2.js new file mode 100644 index 0000000000..ff33e62ba6 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/String/15.5.4.8-2.js @@ -0,0 +1,247 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.5.4.8-2.js'; + +/** + File Name: 15.5.4.8-2.js + ECMA Section: 15.5.4.8 String.prototype.split( separator ) + Description: + + Returns an Array object into which substrings of the result of converting + this object to a string have been stored. The substrings are determined by + searching from left to right for occurrences of the given separator; these + occurrences are not part of any substring in the returned array, but serve + to divide up this string value. The separator may be a string of any length. + + As a special case, if the separator is the empty string, the string is split + up into individual characters; the length of the result array equals the + length of the string, and each substring contains one character. + + If the separator is not supplied, then the result array contains just one + string, which is the string. + + When the split method is called with one argument separator, the following steps are taken: + + 1. Call ToString, giving it the this value as its argument. + 2. Create a new Array object of length 0 and call it A. + 3. If separator is not supplied, call the [[Put]] method of A with 0 and + Result(1) as arguments, and then return A. + 4. Call ToString(separator). + 5. Compute the number of characters in Result(1). + 6. Compute the number of characters in the string that is Result(4). + 7. Let p be 0. + 8. If Result(6) is zero (the separator string is empty), go to step 17. + 9. Compute the smallest possible integer k not smaller than p such that + k+Result(6) is not greater than Result(5), and for all nonnegative + integers j less than Result(6), the character at position k+j of + Result(1) is the same as the character at position j of Result(2); + but if there is no such integer k, then go to step 14. + 10. Compute a string value equal to the substring of Result(1), consisting + of the characters at positions p through k1, inclusive. + 11. Call the [[Put]] method of A with A.length and Result(10) as arguments. + 12. Let p be k+Result(6). + 13. Go to step 9. + 14. Compute a string value equal to the substring of Result(1), consisting + of the characters from position p to the end of Result(1). + 15. Call the [[Put]] method of A with A.length and Result(14) as arguments. + 16. Return A. + 17. If p equals Result(5), return A. + 18. Compute a string value equal to the substring of Result(1), consisting of + the single character at position p. + 19. Call the [[Put]] method of A with A.length and Result(18) as arguments. + 20. Increase p by 1. + 21. Go to step 17. + + Note that the split function is intentionally generic; it does not require that its this value be a String + object. Therefore it can be transferred to other kinds of objects for use as a method. + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + +var SECTION = "15.5.4.8-2"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "String.prototype.split"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +// case where separator is the empty string. + +var TEST_STRING = "this is a string object"; + +new TestCase( SECTION, + "var s = new String( "+ TEST_STRING +" ); s.split('').length", + TEST_STRING.length, + eval("var s = new String( TEST_STRING ); s.split('').length") ); + +for ( var i = 0; i < TEST_STRING.length; i++ ) { + + new TestCase( SECTION, + "var s = new String( "+TEST_STRING+" ); s.split('')["+i+"]", + TEST_STRING.charAt(i), + eval("var s = new String( TEST_STRING ); s.split('')["+i+"]") ); +} + +// case where the value of the separator is undefined. in this case. the value of the separator +// should be ToString( separator ), or "undefined". + +var TEST_STRING = "thisundefinedisundefinedaundefinedstringundefinedobject"; +var EXPECT_STRING = new Array( "this", "is", "a", "string", "object" ); + +new TestCase( SECTION, + "var s = new String( "+ TEST_STRING +" ); s.split(void 0).length", + EXPECT_STRING.length, + eval("var s = new String( TEST_STRING ); s.split(void 0).length") ); + +for ( var i = 0; i < EXPECT_STRING.length; i++ ) { + new TestCase( SECTION, + "var s = new String( "+TEST_STRING+" ); s.split(void 0)["+i+"]", + EXPECT_STRING[i], + eval("var s = new String( TEST_STRING ); s.split(void 0)["+i+"]") ); +} + +// case where the value of the separator is null. in this case the value of the separator is "null". +TEST_STRING = "thisnullisnullanullstringnullobject"; +var EXPECT_STRING = new Array( "this", "is", "a", "string", "object" ); + +new TestCase( SECTION, + "var s = new String( "+ TEST_STRING +" ); s.split(null).length", + EXPECT_STRING.length, + eval("var s = new String( TEST_STRING ); s.split(null).length") ); + +for ( var i = 0; i < EXPECT_STRING.length; i++ ) { + new TestCase( SECTION, + "var s = new String( "+TEST_STRING+" ); s.split(null)["+i+"]", + EXPECT_STRING[i], + eval("var s = new String( TEST_STRING ); s.split(null)["+i+"]") ); +} + +// case where the value of the separator is a boolean. +TEST_STRING = "thistrueistrueatruestringtrueobject"; +var EXPECT_STRING = new Array( "this", "is", "a", "string", "object" ); + +new TestCase( SECTION, + "var s = new String( "+ TEST_STRING +" ); s.split(true).length", + EXPECT_STRING.length, + eval("var s = new String( TEST_STRING ); s.split(true).length") ); + +for ( var i = 0; i < EXPECT_STRING.length; i++ ) { + new TestCase( SECTION, + "var s = new String( "+TEST_STRING+" ); s.split(true)["+i+"]", + EXPECT_STRING[i], + eval("var s = new String( TEST_STRING ); s.split(true)["+i+"]") ); +} + +// case where the value of the separator is a number +TEST_STRING = "this123is123a123string123object"; +var EXPECT_STRING = new Array( "this", "is", "a", "string", "object" ); + +new TestCase( SECTION, + "var s = new String( "+ TEST_STRING +" ); s.split(123).length", + EXPECT_STRING.length, + eval("var s = new String( TEST_STRING ); s.split(123).length") ); + +for ( var i = 0; i < EXPECT_STRING.length; i++ ) { + new TestCase( SECTION, + "var s = new String( "+TEST_STRING+" ); s.split(123)["+i+"]", + EXPECT_STRING[i], + eval("var s = new String( TEST_STRING ); s.split(123)["+i+"]") ); +} + + +// case where the value of the separator is a number +TEST_STRING = "this123is123a123string123object"; +var EXPECT_STRING = new Array( "this", "is", "a", "string", "object" ); + +new TestCase( SECTION, + "var s = new String( "+ TEST_STRING +" ); s.split(123).length", + EXPECT_STRING.length, + eval("var s = new String( TEST_STRING ); s.split(123).length") ); + +for ( var i = 0; i < EXPECT_STRING.length; i++ ) { + new TestCase( SECTION, + "var s = new String( "+TEST_STRING+" ); s.split(123)["+i+"]", + EXPECT_STRING[i], + eval("var s = new String( TEST_STRING ); s.split(123)["+i+"]") ); +} + +// case where the separator is not in the string +TEST_STRING = "this is a string"; +EXPECT_STRING = new Array( "this is a string" ); + +new TestCase( SECTION, + "var s = new String( " + TEST_STRING + " ); s.split(':').length", + 1, + eval("var s = new String( TEST_STRING ); s.split(':').length") ); + +new TestCase( SECTION, + "var s = new String( " + TEST_STRING + " ); s.split(':')[0]", + TEST_STRING, + eval("var s = new String( TEST_STRING ); s.split(':')[0]") ); + +// case where part but not all of separator is in the string. +TEST_STRING = "this is a string"; +EXPECT_STRING = new Array( "this is a string" ); +new TestCase( SECTION, + "var s = new String( " + TEST_STRING + " ); s.split('strings').length", + 1, + eval("var s = new String( TEST_STRING ); s.split('strings').length") ); + +new TestCase( SECTION, + "var s = new String( " + TEST_STRING + " ); s.split('strings')[0]", + TEST_STRING, + eval("var s = new String( TEST_STRING ); s.split('strings')[0]") ); + +// case where the separator is at the end of the string +TEST_STRING = "this is a string"; +EXPECT_STRING = new Array( "this is a " ); +new TestCase( SECTION, + "var s = new String( " + TEST_STRING + " ); s.split('string').length", + 2, + eval("var s = new String( TEST_STRING ); s.split('string').length") ); + +for ( var i = 0; i < EXPECT_STRING.length; i++ ) { + new TestCase( SECTION, + "var s = new String( "+TEST_STRING+" ); s.split('string')["+i+"]", + EXPECT_STRING[i], + eval("var s = new String( TEST_STRING ); s.split('string')["+i+"]") ); +} + +test(); diff --git a/tests/auto/qml/parserstress/tests/ecma/String/15.5.4.8-3.js b/tests/auto/qml/parserstress/tests/ecma/String/15.5.4.8-3.js new file mode 100644 index 0000000000..fe10284a9c --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/String/15.5.4.8-3.js @@ -0,0 +1,204 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.5.4.8-3.js'; + +/** + File Name: 15.5.4.8-3.js + ECMA Section: 15.5.4.8 String.prototype.split( separator ) + Description: + + Returns an Array object into which substrings of the result of converting + this object to a string have been stored. The substrings are determined by + searching from left to right for occurrences of the given separator; these + occurrences are not part of any substring in the returned array, but serve + to divide up this string value. The separator may be a string of any length. + + As a special case, if the separator is the empty string, the string is split + up into individual characters; the length of the result array equals the + length of the string, and each substring contains one character. + + If the separator is not supplied, then the result array contains just one + string, which is the string. + + When the split method is called with one argument separator, the following steps are taken: + + 1. Call ToString, giving it the this value as its argument. + 2. Create a new Array object of length 0 and call it A. + 3. If separator is not supplied, call the [[Put]] method of A with 0 and + Result(1) as arguments, and then return A. + 4. Call ToString(separator). + 5. Compute the number of characters in Result(1). + 6. Compute the number of characters in the string that is Result(4). + 7. Let p be 0. + 8. If Result(6) is zero (the separator string is empty), go to step 17. + 9. Compute the smallest possible integer k not smaller than p such that + k+Result(6) is not greater than Result(5), and for all nonnegative + integers j less than Result(6), the character at position k+j of + Result(1) is the same as the character at position j of Result(2); + but if there is no such integer k, then go to step 14. + 10. Compute a string value equal to the substring of Result(1), consisting + of the characters at positions p through k1, inclusive. + 11. Call the [[Put]] method of A with A.length and Result(10) as arguments. + 12. Let p be k+Result(6). + 13. Go to step 9. + 14. Compute a string value equal to the substring of Result(1), consisting + of the characters from position p to the end of Result(1). + 15. Call the [[Put]] method of A with A.length and Result(14) as arguments. + 16. Return A. + 17. If p equals Result(5), return A. + 18. Compute a string value equal to the substring of Result(1), consisting of + the single character at position p. + 19. Call the [[Put]] method of A with A.length and Result(18) as arguments. + 20. Increase p by 1. + 21. Go to step 17. + + Note that the split function is intentionally generic; it does not require that its this value be a String + object. Therefore it can be transferred to other kinds of objects for use as a method. + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + +var SECTION = "15.5.4.8-3"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "String.prototype.split"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +var TEST_STRING = ""; +var EXPECT = new Array(); + +// this.toString is the empty string. + +new TestCase( SECTION, + "var s = new String(); s.split().length", + 1, + eval("var s = new String(); s.split().length") ); + +new TestCase( SECTION, + "var s = new String(); s.split()[0]", + "", + eval("var s = new String(); s.split()[0]") ); + +// this.toString() is the empty string, separator is specified. + +new TestCase( SECTION, + "var s = new String(); s.split('').length", + 0, + eval("var s = new String(); s.split('').length") ); + +new TestCase( SECTION, + "var s = new String(); s.split(' ').length", + 1, + eval("var s = new String(); s.split(' ').length") ); + +// this to string is " " +new TestCase( SECTION, + "var s = new String(' '); s.split().length", + 1, + eval("var s = new String(' '); s.split().length") ); + +new TestCase( SECTION, + "var s = new String(' '); s.split()[0]", + " ", + eval("var s = new String(' '); s.split()[0]") ); + +new TestCase( SECTION, + "var s = new String(' '); s.split('').length", + 1, + eval("var s = new String(' '); s.split('').length") ); + +new TestCase( SECTION, + "var s = new String(' '); s.split('')[0]", + " ", + eval("var s = new String(' '); s.split('')[0]") ); + +new TestCase( SECTION, + "var s = new String(' '); s.split(' ').length", + 2, + eval("var s = new String(' '); s.split(' ').length") ); + +new TestCase( SECTION, + "var s = new String(' '); s.split(' ')[0]", + "", + eval("var s = new String(' '); s.split(' ')[0]") ); + +new TestCase( SECTION, + "\"\".split(\"\").length", + 0, + ("".split("")).length ); + +new TestCase( SECTION, + "\"\".split(\"x\").length", + 1, + ("".split("x")).length ); + +new TestCase( SECTION, + "\"\".split(\"x\")[0]", + "", + ("".split("x"))[0] ); + +test(); + +function Split( string, separator ) { + string = String( string ); + + var A = new Array(); + + if ( arguments.length < 2 ) { + A[0] = string; + return A; + } + + separator = String( separator ); + + var str_len = String( string ).length; + var sep_len = String( separator ).length; + + var p = 0; + var k = 0; + + if ( sep_len == 0 ) { + for ( ; p < str_len; p++ ) { + A[A.length] = String( string.charAt(p) ); + } + } + return A; +} diff --git a/tests/auto/qml/parserstress/tests/ecma/String/15.5.4.9-1.js b/tests/auto/qml/parserstress/tests/ecma/String/15.5.4.9-1.js new file mode 100644 index 0000000000..2184c60f45 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/String/15.5.4.9-1.js @@ -0,0 +1,202 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.5.4.9-1.js'; + +/** + File Name: 15.5.4.9-1.js + ECMA Section: 15.5.4.9 String.prototype.substring( start ) + Description: + + 15.5.4.9 String.prototype.substring(start) + + Returns a substring of the result of converting this object to a string, + starting from character position start and running to the end of the + string. The result is a string value, not a String object. + + If the argument is NaN or negative, it is replaced with zero; if the + argument is larger than the length of the string, it is replaced with the + length of the string. + + When the substring method is called with one argument start, the following + steps are taken: + + 1.Call ToString, giving it the this value as its argument. + 2.Call ToInteger(start). + 3.Compute the number of characters in Result(1). + 4.Compute min(max(Result(2), 0), Result(3)). + 5.Return a string whose length is the difference between Result(3) and Result(4), + containing characters from Result(1), namely the characters with indices Result(4) + through Result(3)1, in ascending order. + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + +var SECTION = "15.5.4.9-1"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "String.prototype.substring( start )"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +new TestCase( SECTION, "String.prototype.substring.length", 2, String.prototype.substring.length ); +new TestCase( SECTION, "delete String.prototype.substring.length", false, delete String.prototype.substring.length ); +new TestCase( SECTION, "delete String.prototype.substring.length; String.prototype.substring.length", 2, eval("delete String.prototype.substring.length; String.prototype.substring.length") ); + +// test cases for when substring is called with no arguments. + +// this is a string object + +new TestCase( SECTION, + "var s = new String('this is a string object'); typeof s.substring()", + "string", + eval("var s = new String('this is a string object'); typeof s.substring()") ); + +new TestCase( SECTION, + "var s = new String(''); s.substring()", + "", + eval("var s = new String(''); s.substring()") ); + + +new TestCase( SECTION, + "var s = new String('this is a string object'); s.substring()", + "this is a string object", + eval("var s = new String('this is a string object'); s.substring()") ); + +new TestCase( SECTION, + "var s = new String('this is a string object'); s.substring(NaN)", + "this is a string object", + eval("var s = new String('this is a string object'); s.substring(NaN)") ); + + +new TestCase( SECTION, + "var s = new String('this is a string object'); s.substring(-0.01)", + "this is a string object", + eval("var s = new String('this is a string object'); s.substring(-0.01)") ); + + +new TestCase( SECTION, + "var s = new String('this is a string object'); s.substring(s.length)", + "", + eval("var s = new String('this is a string object'); s.substring(s.length)") ); + +new TestCase( SECTION, + "var s = new String('this is a string object'); s.substring(s.length+1)", + "", + eval("var s = new String('this is a string object'); s.substring(s.length+1)") ); + + +new TestCase( SECTION, + "var s = new String('this is a string object'); s.substring(Infinity)", + "", + eval("var s = new String('this is a string object'); s.substring(Infinity)") ); + +new TestCase( SECTION, + "var s = new String('this is a string object'); s.substring(-Infinity)", + "this is a string object", + eval("var s = new String('this is a string object'); s.substring(-Infinity)") ); + +// this is not a String object, start is not an integer + + +new TestCase( SECTION, + "var s = new Array(1,2,3,4,5); s.substring = String.prototype.substring; s.substring()", + "1,2,3,4,5", + eval("var s = new Array(1,2,3,4,5); s.substring = String.prototype.substring; s.substring()") ); + +new TestCase( SECTION, + "var s = new Array(1,2,3,4,5); s.substring = String.prototype.substring; s.substring(true)", + ",2,3,4,5", + eval("var s = new Array(1,2,3,4,5); s.substring = String.prototype.substring; s.substring(true)") ); + +new TestCase( SECTION, + "var s = new Array(1,2,3,4,5); s.substring = String.prototype.substring; s.substring('4')", + "3,4,5", + eval("var s = new Array(1,2,3,4,5); s.substring = String.prototype.substring; s.substring('4')") ); + +new TestCase( SECTION, + "var s = new Array(); s.substring = String.prototype.substring; s.substring('4')", + "", + eval("var s = new Array(); s.substring = String.prototype.substring; s.substring('4')") ); + +// this is an object object +new TestCase( SECTION, + "var obj = new Object(); obj.substring = String.prototype.substring; obj.substring(8)", + "Object]", + eval("var obj = new Object(); obj.substring = String.prototype.substring; obj.substring(8)") ); + +// this is a function object +new TestCase( SECTION, + "var obj = new Function(); obj.substring = String.prototype.substring; obj.toString = Object.prototype.toString; obj.substring(8)", + "Function]", + eval("var obj = new Function(); obj.substring = String.prototype.substring; obj.toString = Object.prototype.toString; obj.substring(8)") ); +// this is a number object +new TestCase( SECTION, + "var obj = new Number(NaN); obj.substring = String.prototype.substring; obj.substring(false)", + "NaN", + eval("var obj = new Number(NaN); obj.substring = String.prototype.substring; obj.substring(false)") ); + +// this is the Math object +new TestCase( SECTION, + "var obj = Math; obj.substring = String.prototype.substring; obj.substring(Math.PI)", + "ject Math]", + eval("var obj = Math; obj.substring = String.prototype.substring; obj.substring(Math.PI)") ); + +// this is a Boolean object + +new TestCase( SECTION, + "var obj = new Boolean(); obj.substring = String.prototype.substring; obj.substring(new Array())", + "false", + eval("var obj = new Boolean(); obj.substring = String.prototype.substring; obj.substring(new Array())") ); + +// this is a user defined object + +new TestCase( SECTION, + "var obj = new MyObject( null ); obj.substring(0)", + "null", + eval( "var obj = new MyObject( null ); obj.substring(0)") ); + + +test(); + +function MyObject( value ) { + this.value = value; + this.substring = String.prototype.substring; + this.toString = new Function ( "return this.value+''" ); +} diff --git a/tests/auto/qml/parserstress/tests/ecma/String/15.5.4.js b/tests/auto/qml/parserstress/tests/ecma/String/15.5.4.js new file mode 100644 index 0000000000..063e4e68d1 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/String/15.5.4.js @@ -0,0 +1,108 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.5.4.js'; + +/** + File Name: 15.5.4.js + ECMA Section: 15.5.4 Properties of the String prototype object + + Description: + Author: christine@netscape.com + Date: 28 october 1997 + +*/ +var SECTION = "15.5.4"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Properties of the String Prototype objecta"; + +writeHeaderToLog( SECTION + " "+ TITLE); + + +new TestCase( SECTION, + "String.prototype.getClass = Object.prototype.toString; String.prototype.getClass()", + "[object String]", + eval("String.prototype.getClass = Object.prototype.toString; String.prototype.getClass()") ); + +delete String.prototype.getClass; + +new TestCase( SECTION, + "typeof String.prototype", + "object", + typeof String.prototype ); + +new TestCase( SECTION, + "String.prototype.valueOf()", + "", + String.prototype.valueOf() ); + +new TestCase( SECTION, + "String.prototype +''", + "", + String.prototype + '' ); + +new TestCase( SECTION, + "String.prototype.length", + 0, + String.prototype.length ); + +var prop; +var value; + +value = ''; +for (prop in "") +{ + value += prop; +} +new TestCase( SECTION, + 'String "" has no enumerable properties', + '', + value ); + +value = ''; +for (prop in String.prototype) +{ + value += prop; +} +new TestCase( SECTION, + 'String.prototype has no enumerable properties', + '', + value ); + +test(); diff --git a/tests/auto/qml/parserstress/tests/ecma/String/15.5.5.1.js b/tests/auto/qml/parserstress/tests/ecma/String/15.5.5.1.js new file mode 100644 index 0000000000..85d3d24ef2 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/String/15.5.5.1.js @@ -0,0 +1,88 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.5.5.1.js'; + +/** + File Name: 15.5.5.1 + ECMA Section: String.length + Description: + + The number of characters in the String value represented by this String + object. + + Once a String object is created, this property is unchanging. It has the + attributes { DontEnum, DontDelete, ReadOnly }. + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + +var SECTION = "15.5.5.1"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "String.length"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +new TestCase( SECTION, + "var s = new String(); s.length", + 0, + eval("var s = new String(); s.length") ); + +new TestCase( SECTION, + "var s = new String(); s.length = 10; s.length", + 0, + eval("var s = new String(); s.length = 10; s.length") ); + +new TestCase( SECTION, + "var s = new String(); var props = ''; for ( var p in s ) { props += p; }; props", + "", + eval("var s = new String(); var props = ''; for ( var p in s ) { props += p; }; props") ); + +new TestCase( SECTION, + "var s = new String(); delete s.length", + false, + eval("var s = new String(); delete s.length") ); + +new TestCase( SECTION, + "var s = new String('hello'); delete s.length; s.length", + 5, + eval("var s = new String('hello'); delete s.length; s.length") ); + +test(); diff --git a/tests/auto/qml/parserstress/tests/ecma/String/browser.js b/tests/auto/qml/parserstress/tests/ecma/String/browser.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/auto/qml/parserstress/tests/ecma/String/shell.js b/tests/auto/qml/parserstress/tests/ecma/String/shell.js new file mode 100644 index 0000000000..7d850446cc --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/String/shell.js @@ -0,0 +1 @@ +gTestsubsuite = 'String'; diff --git a/tests/auto/qml/parserstress/tests/ecma/TypeConversion/9.2.js b/tests/auto/qml/parserstress/tests/ecma/TypeConversion/9.2.js new file mode 100644 index 0000000000..2d428b9a9e --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/TypeConversion/9.2.js @@ -0,0 +1,138 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): christine@netscape.com + * Jesse Ruderman + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '9.2.js'; + +/** + File Name: 9.2.js + ECMA Section: 9.2 Type Conversion: ToBoolean + Description: rules for converting an argument to a boolean. + undefined false + Null false + Boolean input argument( no conversion ) + Number returns false for 0, -0, and NaN + otherwise return true + String return false if the string is empty + (length is 0) otherwise the result is + true + Object all return true + + Author: christine@netscape.com + Date: 14 july 1997 +*/ +var SECTION = "9.2"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "ToBoolean"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +// special cases here + +new TestCase( SECTION, "Boolean()", false, Boolean() ); +new TestCase( SECTION, "Boolean(var x)", false, Boolean(eval("var x")) ); +new TestCase( SECTION, "Boolean(void 0)", false, Boolean(void 0) ); +new TestCase( SECTION, "Boolean(null)", false, Boolean(null) ); +new TestCase( SECTION, "Boolean(false)", false, Boolean(false) ); +new TestCase( SECTION, "Boolean(true)", true, Boolean(true) ); +new TestCase( SECTION, "Boolean(0)", false, Boolean(0) ); +new TestCase( SECTION, "Boolean(-0)", false, Boolean(-0) ); +new TestCase( SECTION, "Boolean(NaN)", false, Boolean(Number.NaN) ); +new TestCase( SECTION, "Boolean('')", false, Boolean("") ); + +// normal test cases here + +new TestCase( SECTION, "Boolean(Infinity)", true, Boolean(Number.POSITIVE_INFINITY) ); +new TestCase( SECTION, "Boolean(-Infinity)", true, Boolean(Number.NEGATIVE_INFINITY) ); +new TestCase( SECTION, "Boolean(Math.PI)", true, Boolean(Math.PI) ); +new TestCase( SECTION, "Boolean(1)", true, Boolean(1) ); +new TestCase( SECTION, "Boolean(-1)", true, Boolean(-1) ); +new TestCase( SECTION, "Boolean([tab])", true, Boolean("\t") ); +new TestCase( SECTION, "Boolean('0')", true, Boolean("0") ); +new TestCase( SECTION, "Boolean('string')", true, Boolean("string") ); + +// ToBoolean (object) should always return true. +new TestCase( SECTION, "Boolean(new String() )", true, Boolean(new String()) ); +new TestCase( SECTION, "Boolean(new String('') )", true, Boolean(new String("")) ); + +new TestCase( SECTION, "Boolean(new Boolean(true))", true, Boolean(new Boolean(true)) ); +new TestCase( SECTION, "Boolean(new Boolean(false))", true, Boolean(new Boolean(false)) ); +new TestCase( SECTION, "Boolean(new Boolean() )", true, Boolean(new Boolean()) ); + +new TestCase( SECTION, "Boolean(new Array())", true, Boolean(new Array()) ); + +new TestCase( SECTION, "Boolean(new Number())", true, Boolean(new Number()) ); +new TestCase( SECTION, "Boolean(new Number(-0))", true, Boolean(new Number(-0)) ); +new TestCase( SECTION, "Boolean(new Number(0))", true, Boolean(new Number(0)) ); +new TestCase( SECTION, "Boolean(new Number(NaN))", true, Boolean(new Number(Number.NaN)) ); + +new TestCase( SECTION, "Boolean(new Number(-1))", true, Boolean(new Number(-1)) ); +new TestCase( SECTION, "Boolean(new Number(Infinity))", true, Boolean(new Number(Number.POSITIVE_INFINITY)) ); +new TestCase( SECTION, "Boolean(new Number(-Infinity))",true, Boolean(new Number(Number.NEGATIVE_INFINITY)) ); + +new TestCase( SECTION, "Boolean(new Object())", true, Boolean(new Object()) ); +new TestCase( SECTION, "Boolean(new Function())", true, Boolean(new Function()) ); +new TestCase( SECTION, "Boolean(new Date())", true, Boolean(new Date()) ); +new TestCase( SECTION, "Boolean(new Date(0))", true, Boolean(new Date(0)) ); +new TestCase( SECTION, "Boolean(Math)", true, Boolean(Math) ); + +// bug 375793 +new TestCase( SECTION, + "NaN ? true : false", + false, + (NaN ? true : false) ); +new TestCase( SECTION, + "1000 % 0 ? true : false", + false, + (1000 % 0 ? true : false) ); +new TestCase( SECTION, + "(function(a,b){ return a % b ? true : false })(1000, 0)", + false, + ((function(a,b){ return a % b ? true : false })(1000, 0)) ); + +new TestCase( SECTION, + "(function(x) { return !(x) })(0/0)", + true, + ((function(x) { return !(x) })(0/0)) ); +new TestCase( SECTION, + "!(0/0)", + true, + (!(0/0)) ); +test(); + diff --git a/tests/auto/qml/parserstress/tests/ecma/TypeConversion/9.3-1.js b/tests/auto/qml/parserstress/tests/ecma/TypeConversion/9.3-1.js new file mode 100644 index 0000000000..9994d6a7cd --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/TypeConversion/9.3-1.js @@ -0,0 +1,100 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '9.3-1.js'; + +/** + File Name: 9.3-1.js + ECMA Section: 9.3 Type Conversion: ToNumber + Description: rules for converting an argument to a number. + see 9.3.1 for cases for converting strings to numbers. + special cases: + undefined NaN + Null NaN + Boolean 1 if true; +0 if false + Number the argument ( no conversion ) + String see test 9.3.1 + Object see test 9.3-1 + + + This tests ToNumber applied to the object type, except + if object is string. See 9.3-2 for + ToNumber( String object). + + Author: christine@netscape.com + Date: 10 july 1997 + +*/ +var SECTION = "9.3-1"; +var VERSION = "ECMA_1"; +startTest(); + +writeHeaderToLog( SECTION + " ToNumber"); + +// object is Number +new TestCase( SECTION, "Number(new Number())", 0, Number(new Number()) ); +new TestCase( SECTION, "typeof Number(new Number())", "number", typeof Number(new Number()) ); + +new TestCase( SECTION, "Number(new Number(Number.NaN))", Number.NaN, Number(new Number(Number.NaN)) ); +new TestCase( SECTION, "typeof Number(new Number(Number.NaN))","number", typeof Number(new Number(Number.NaN)) ); + +new TestCase( SECTION, "Number(new Number(0))", 0, Number(new Number(0)) ); +new TestCase( SECTION, "typeof Number(new Number(0))", "number", typeof Number(new Number(0)) ); + +new TestCase( SECTION, "Number(new Number(null))", 0, Number(new Number(null)) ); +new TestCase( SECTION, "typeof Number(new Number(null))", "number", typeof Number(new Number(null)) ); + + +// new TestCase( SECTION, "Number(new Number(void 0))", Number.NaN, Number(new Number(void 0)) ); +new TestCase( SECTION, "Number(new Number(true))", 1, Number(new Number(true)) ); +new TestCase( SECTION, "typeof Number(new Number(true))", "number", typeof Number(new Number(true)) ); + +new TestCase( SECTION, "Number(new Number(false))", 0, Number(new Number(false)) ); +new TestCase( SECTION, "typeof Number(new Number(false))", "number", typeof Number(new Number(false)) ); + +// object is boolean +new TestCase( SECTION, "Number(new Boolean(true))", 1, Number(new Boolean(true)) ); +new TestCase( SECTION, "typeof Number(new Boolean(true))", "number", typeof Number(new Boolean(true)) ); + +new TestCase( SECTION, "Number(new Boolean(false))", 0, Number(new Boolean(false)) ); +new TestCase( SECTION, "typeof Number(new Boolean(false))", "number", typeof Number(new Boolean(false)) ); + +// object is array +new TestCase( SECTION, "Number(new Array(2,4,8,16,32))", Number.NaN, Number(new Array(2,4,8,16,32)) ); +new TestCase( SECTION, "typeof Number(new Array(2,4,8,16,32))", "number", typeof Number(new Array(2,4,8,16,32)) ); + diff --git a/tests/auto/qml/parserstress/tests/ecma/TypeConversion/9.3.1-1.js b/tests/auto/qml/parserstress/tests/ecma/TypeConversion/9.3.1-1.js new file mode 100644 index 0000000000..da3e8794c0 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/TypeConversion/9.3.1-1.js @@ -0,0 +1,323 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '9.3.1-1.js'; + +/** + File Name: 9.3.1-1.js + ECMA Section: 9.3 Type Conversion: ToNumber + Description: rules for converting an argument to a number. + see 9.3.1 for cases for converting strings to numbers. + special cases: + undefined NaN + Null NaN + Boolean 1 if true; +0 if false + Number the argument ( no conversion ) + String see test 9.3.1 + Object see test 9.3-1 + + + This tests ToNumber applied to the string type + + Author: christine@netscape.com + Date: 10 july 1997 + +*/ +var SECTION = "9.3.1-1"; +var VERSION = "ECMA_1"; +var TITLE = "ToNumber applied to the String type"; +var BUGNUMBER="77391"; + +startTest(); + +writeHeaderToLog( SECTION + " "+ TITLE); + + +// StringNumericLiteral:::StrWhiteSpace:::StrWhiteSpaceChar StrWhiteSpace::: +// +// Name Unicode Value Escape Sequence +// 0X0009 \t +// 0X0020 +// 0X000C \f +// 0X000B +// 0X000D \r +// 0X000A \n +new TestCase( SECTION, "Number('')", 0, Number("") ); +new TestCase( SECTION, "Number(' ')", 0, Number(" ") ); +new TestCase( SECTION, "Number(\\t)", 0, Number("\t") ); +new TestCase( SECTION, "Number(\\n)", 0, Number("\n") ); +new TestCase( SECTION, "Number(\\r)", 0, Number("\r") ); +new TestCase( SECTION, "Number(\\f)", 0, Number("\f") ); + +new TestCase( SECTION, "Number(String.fromCharCode(0x0009)", 0, Number(String.fromCharCode(0x0009)) ); +new TestCase( SECTION, "Number(String.fromCharCode(0x0020)", 0, Number(String.fromCharCode(0x0020)) ); +new TestCase( SECTION, "Number(String.fromCharCode(0x000C)", 0, Number(String.fromCharCode(0x000C)) ); +new TestCase( SECTION, "Number(String.fromCharCode(0x000B)", 0, Number(String.fromCharCode(0x000B)) ); +new TestCase( SECTION, "Number(String.fromCharCode(0x000D)", 0, Number(String.fromCharCode(0x000D)) ); +new TestCase( SECTION, "Number(String.fromCharCode(0x000A)", 0, Number(String.fromCharCode(0x000A)) ); + +// a StringNumericLiteral may be preceeded or followed by whitespace and/or +// line terminators + +new TestCase( SECTION, "Number( ' ' + 999 )", 999, Number( ' '+999) ); +new TestCase( SECTION, "Number( '\\n' + 999 )", 999, Number( '\n' +999) ); +new TestCase( SECTION, "Number( '\\r' + 999 )", 999, Number( '\r' +999) ); +new TestCase( SECTION, "Number( '\\t' + 999 )", 999, Number( '\t' +999) ); +new TestCase( SECTION, "Number( '\\f' + 999 )", 999, Number( '\f' +999) ); + +new TestCase( SECTION, "Number( 999 + ' ' )", 999, Number( 999+' ') ); +new TestCase( SECTION, "Number( 999 + '\\n' )", 999, Number( 999+'\n' ) ); +new TestCase( SECTION, "Number( 999 + '\\r' )", 999, Number( 999+'\r' ) ); +new TestCase( SECTION, "Number( 999 + '\\t' )", 999, Number( 999+'\t' ) ); +new TestCase( SECTION, "Number( 999 + '\\f' )", 999, Number( 999+'\f' ) ); + +new TestCase( SECTION, "Number( '\\n' + 999 + '\\n' )", 999, Number( '\n' +999+'\n' ) ); +new TestCase( SECTION, "Number( '\\r' + 999 + '\\r' )", 999, Number( '\r' +999+'\r' ) ); +new TestCase( SECTION, "Number( '\\t' + 999 + '\\t' )", 999, Number( '\t' +999+'\t' ) ); +new TestCase( SECTION, "Number( '\\f' + 999 + '\\f' )", 999, Number( '\f' +999+'\f' ) ); + +new TestCase( SECTION, "Number( ' ' + '999' )", 999, Number( ' '+'999') ); +new TestCase( SECTION, "Number( '\\n' + '999' )", 999, Number( '\n' +'999') ); +new TestCase( SECTION, "Number( '\\r' + '999' )", 999, Number( '\r' +'999') ); +new TestCase( SECTION, "Number( '\\t' + '999' )", 999, Number( '\t' +'999') ); +new TestCase( SECTION, "Number( '\\f' + '999' )", 999, Number( '\f' +'999') ); + +new TestCase( SECTION, "Number( '999' + ' ' )", 999, Number( '999'+' ') ); +new TestCase( SECTION, "Number( '999' + '\\n' )", 999, Number( '999'+'\n' ) ); +new TestCase( SECTION, "Number( '999' + '\\r' )", 999, Number( '999'+'\r' ) ); +new TestCase( SECTION, "Number( '999' + '\\t' )", 999, Number( '999'+'\t' ) ); +new TestCase( SECTION, "Number( '999' + '\\f' )", 999, Number( '999'+'\f' ) ); + +new TestCase( SECTION, "Number( '\\n' + '999' + '\\n' )", 999, Number( '\n' +'999'+'\n' ) ); +new TestCase( SECTION, "Number( '\\r' + '999' + '\\r' )", 999, Number( '\r' +'999'+'\r' ) ); +new TestCase( SECTION, "Number( '\\t' + '999' + '\\t' )", 999, Number( '\t' +'999'+'\t' ) ); +new TestCase( SECTION, "Number( '\\f' + '999' + '\\f' )", 999, Number( '\f' +'999'+'\f' ) ); + +new TestCase( SECTION, "Number( String.fromCharCode(0x0009) + '99' )", 99, Number( String.fromCharCode(0x0009) + '99' ) ); +new TestCase( SECTION, "Number( String.fromCharCode(0x0020) + '99' )", 99, Number( String.fromCharCode(0x0020) + '99' ) ); +new TestCase( SECTION, "Number( String.fromCharCode(0x000C) + '99' )", 99, Number( String.fromCharCode(0x000C) + '99' ) ); +new TestCase( SECTION, "Number( String.fromCharCode(0x000B) + '99' )", 99, Number( String.fromCharCode(0x000B) + '99' ) ); +new TestCase( SECTION, "Number( String.fromCharCode(0x000D) + '99' )", 99, Number( String.fromCharCode(0x000D) + '99' ) ); +new TestCase( SECTION, "Number( String.fromCharCode(0x000A) + '99' )", 99, Number( String.fromCharCode(0x000A) + '99' ) ); + +new TestCase( SECTION, "Number( String.fromCharCode(0x0009) + '99' + String.fromCharCode(0x0009)", 99, Number( String.fromCharCode(0x0009) + '99' + String.fromCharCode(0x0009)) ); +new TestCase( SECTION, "Number( String.fromCharCode(0x0020) + '99' + String.fromCharCode(0x0020)", 99, Number( String.fromCharCode(0x0009) + '99' + String.fromCharCode(0x0020)) ); +new TestCase( SECTION, "Number( String.fromCharCode(0x000C) + '99' + String.fromCharCode(0x000C)", 99, Number( String.fromCharCode(0x0009) + '99' + String.fromCharCode(0x000C)) ); +new TestCase( SECTION, "Number( String.fromCharCode(0x000D) + '99' + String.fromCharCode(0x000D)", 99, Number( String.fromCharCode(0x0009) + '99' + String.fromCharCode(0x000D)) ); +new TestCase( SECTION, "Number( String.fromCharCode(0x000B) + '99' + String.fromCharCode(0x000B)", 99, Number( String.fromCharCode(0x0009) + '99' + String.fromCharCode(0x000B)) ); +new TestCase( SECTION, "Number( String.fromCharCode(0x000A) + '99' + String.fromCharCode(0x000A)", 99, Number( String.fromCharCode(0x0009) + '99' + String.fromCharCode(0x000A)) ); + +new TestCase( SECTION, "Number( '99' + String.fromCharCode(0x0009)", 99, Number( '99' + String.fromCharCode(0x0009)) ); +new TestCase( SECTION, "Number( '99' + String.fromCharCode(0x0020)", 99, Number( '99' + String.fromCharCode(0x0020)) ); +new TestCase( SECTION, "Number( '99' + String.fromCharCode(0x000C)", 99, Number( '99' + String.fromCharCode(0x000C)) ); +new TestCase( SECTION, "Number( '99' + String.fromCharCode(0x000D)", 99, Number( '99' + String.fromCharCode(0x000D)) ); +new TestCase( SECTION, "Number( '99' + String.fromCharCode(0x000B)", 99, Number( '99' + String.fromCharCode(0x000B)) ); +new TestCase( SECTION, "Number( '99' + String.fromCharCode(0x000A)", 99, Number( '99' + String.fromCharCode(0x000A)) ); + +new TestCase( SECTION, "Number( String.fromCharCode(0x0009) + 99 )", 99, Number( String.fromCharCode(0x0009) + 99 ) ); +new TestCase( SECTION, "Number( String.fromCharCode(0x0020) + 99 )", 99, Number( String.fromCharCode(0x0020) + 99 ) ); +new TestCase( SECTION, "Number( String.fromCharCode(0x000C) + 99 )", 99, Number( String.fromCharCode(0x000C) + 99 ) ); +new TestCase( SECTION, "Number( String.fromCharCode(0x000B) + 99 )", 99, Number( String.fromCharCode(0x000B) + 99 ) ); +new TestCase( SECTION, "Number( String.fromCharCode(0x000D) + 99 )", 99, Number( String.fromCharCode(0x000D) + 99 ) ); +new TestCase( SECTION, "Number( String.fromCharCode(0x000A) + 99 )", 99, Number( String.fromCharCode(0x000A) + 99 ) ); + +new TestCase( SECTION, "Number( String.fromCharCode(0x0009) + 99 + String.fromCharCode(0x0009)", 99, Number( String.fromCharCode(0x0009) + 99 + String.fromCharCode(0x0009)) ); +new TestCase( SECTION, "Number( String.fromCharCode(0x0020) + 99 + String.fromCharCode(0x0020)", 99, Number( String.fromCharCode(0x0009) + 99 + String.fromCharCode(0x0020)) ); +new TestCase( SECTION, "Number( String.fromCharCode(0x000C) + 99 + String.fromCharCode(0x000C)", 99, Number( String.fromCharCode(0x0009) + 99 + String.fromCharCode(0x000C)) ); +new TestCase( SECTION, "Number( String.fromCharCode(0x000D) + 99 + String.fromCharCode(0x000D)", 99, Number( String.fromCharCode(0x0009) + 99 + String.fromCharCode(0x000D)) ); +new TestCase( SECTION, "Number( String.fromCharCode(0x000B) + 99 + String.fromCharCode(0x000B)", 99, Number( String.fromCharCode(0x0009) + 99 + String.fromCharCode(0x000B)) ); +new TestCase( SECTION, "Number( String.fromCharCode(0x000A) + 99 + String.fromCharCode(0x000A)", 99, Number( String.fromCharCode(0x0009) + 99 + String.fromCharCode(0x000A)) ); + +new TestCase( SECTION, "Number( 99 + String.fromCharCode(0x0009)", 99, Number( 99 + String.fromCharCode(0x0009)) ); +new TestCase( SECTION, "Number( 99 + String.fromCharCode(0x0020)", 99, Number( 99 + String.fromCharCode(0x0020)) ); +new TestCase( SECTION, "Number( 99 + String.fromCharCode(0x000C)", 99, Number( 99 + String.fromCharCode(0x000C)) ); +new TestCase( SECTION, "Number( 99 + String.fromCharCode(0x000D)", 99, Number( 99 + String.fromCharCode(0x000D)) ); +new TestCase( SECTION, "Number( 99 + String.fromCharCode(0x000B)", 99, Number( 99 + String.fromCharCode(0x000B)) ); +new TestCase( SECTION, "Number( 99 + String.fromCharCode(0x000A)", 99, Number( 99 + String.fromCharCode(0x000A)) ); + + +// StrNumericLiteral:::StrDecimalLiteral:::Infinity + +new TestCase( SECTION, "Number('Infinity')", Math.pow(10,10000), Number("Infinity") ); +new TestCase( SECTION, "Number('-Infinity')", -Math.pow(10,10000), Number("-Infinity") ); +new TestCase( SECTION, "Number('+Infinity')", Math.pow(10,10000), Number("+Infinity") ); + +// StrNumericLiteral::: StrDecimalLiteral ::: DecimalDigits . DecimalDigits opt ExponentPart opt + +new TestCase( SECTION, "Number('0')", 0, Number("0") ); +new TestCase( SECTION, "Number('-0')", -0, Number("-0") ); +new TestCase( SECTION, "Number('+0')", 0, Number("+0") ); + +new TestCase( SECTION, "Number('1')", 1, Number("1") ); +new TestCase( SECTION, "Number('-1')", -1, Number("-1") ); +new TestCase( SECTION, "Number('+1')", 1, Number("+1") ); + +new TestCase( SECTION, "Number('2')", 2, Number("2") ); +new TestCase( SECTION, "Number('-2')", -2, Number("-2") ); +new TestCase( SECTION, "Number('+2')", 2, Number("+2") ); + +new TestCase( SECTION, "Number('3')", 3, Number("3") ); +new TestCase( SECTION, "Number('-3')", -3, Number("-3") ); +new TestCase( SECTION, "Number('+3')", 3, Number("+3") ); + +new TestCase( SECTION, "Number('4')", 4, Number("4") ); +new TestCase( SECTION, "Number('-4')", -4, Number("-4") ); +new TestCase( SECTION, "Number('+4')", 4, Number("+4") ); + +new TestCase( SECTION, "Number('5')", 5, Number("5") ); +new TestCase( SECTION, "Number('-5')", -5, Number("-5") ); +new TestCase( SECTION, "Number('+5')", 5, Number("+5") ); + +new TestCase( SECTION, "Number('6')", 6, Number("6") ); +new TestCase( SECTION, "Number('-6')", -6, Number("-6") ); +new TestCase( SECTION, "Number('+6')", 6, Number("+6") ); + +new TestCase( SECTION, "Number('7')", 7, Number("7") ); +new TestCase( SECTION, "Number('-7')", -7, Number("-7") ); +new TestCase( SECTION, "Number('+7')", 7, Number("+7") ); + +new TestCase( SECTION, "Number('8')", 8, Number("8") ); +new TestCase( SECTION, "Number('-8')", -8, Number("-8") ); +new TestCase( SECTION, "Number('+8')", 8, Number("+8") ); + +new TestCase( SECTION, "Number('9')", 9, Number("9") ); +new TestCase( SECTION, "Number('-9')", -9, Number("-9") ); +new TestCase( SECTION, "Number('+9')", 9, Number("+9") ); + +new TestCase( SECTION, "Number('3.14159')", 3.14159, Number("3.14159") ); +new TestCase( SECTION, "Number('-3.14159')", -3.14159, Number("-3.14159") ); +new TestCase( SECTION, "Number('+3.14159')", 3.14159, Number("+3.14159") ); + +new TestCase( SECTION, "Number('3.')", 3, Number("3.") ); +new TestCase( SECTION, "Number('-3.')", -3, Number("-3.") ); +new TestCase( SECTION, "Number('+3.')", 3, Number("+3.") ); + +new TestCase( SECTION, "Number('3.e1')", 30, Number("3.e1") ); +new TestCase( SECTION, "Number('-3.e1')", -30, Number("-3.e1") ); +new TestCase( SECTION, "Number('+3.e1')", 30, Number("+3.e1") ); + +new TestCase( SECTION, "Number('3.e+1')", 30, Number("3.e+1") ); +new TestCase( SECTION, "Number('-3.e+1')", -30, Number("-3.e+1") ); +new TestCase( SECTION, "Number('+3.e+1')", 30, Number("+3.e+1") ); + +new TestCase( SECTION, "Number('3.e-1')", .30, Number("3.e-1") ); +new TestCase( SECTION, "Number('-3.e-1')", -.30, Number("-3.e-1") ); +new TestCase( SECTION, "Number('+3.e-1')", .30, Number("+3.e-1") ); + +// StrDecimalLiteral::: .DecimalDigits ExponentPart opt + +new TestCase( SECTION, "Number('.00001')", 0.00001, Number(".00001") ); +new TestCase( SECTION, "Number('+.00001')", 0.00001, Number("+.00001") ); +new TestCase( SECTION, "Number('-0.0001')", -0.00001, Number("-.00001") ); + +new TestCase( SECTION, "Number('.01e2')", 1, Number(".01e2") ); +new TestCase( SECTION, "Number('+.01e2')", 1, Number("+.01e2") ); +new TestCase( SECTION, "Number('-.01e2')", -1, Number("-.01e2") ); + +new TestCase( SECTION, "Number('.01e+2')", 1, Number(".01e+2") ); +new TestCase( SECTION, "Number('+.01e+2')", 1, Number("+.01e+2") ); +new TestCase( SECTION, "Number('-.01e+2')", -1, Number("-.01e+2") ); + +new TestCase( SECTION, "Number('.01e-2')", 0.0001, Number(".01e-2") ); +new TestCase( SECTION, "Number('+.01e-2')", 0.0001, Number("+.01e-2") ); +new TestCase( SECTION, "Number('-.01e-2')", -0.0001, Number("-.01e-2") ); + +// StrDecimalLiteral::: DecimalDigits ExponentPart opt + +new TestCase( SECTION, "Number('1234e5')", 123400000, Number("1234e5") ); +new TestCase( SECTION, "Number('+1234e5')", 123400000, Number("+1234e5") ); +new TestCase( SECTION, "Number('-1234e5')", -123400000, Number("-1234e5") ); + +new TestCase( SECTION, "Number('1234e+5')", 123400000, Number("1234e+5") ); +new TestCase( SECTION, "Number('+1234e+5')", 123400000, Number("+1234e+5") ); +new TestCase( SECTION, "Number('-1234e+5')", -123400000, Number("-1234e+5") ); + +new TestCase( SECTION, "Number('1234e-5')", 0.01234, Number("1234e-5") ); +new TestCase( SECTION, "Number('+1234e-5')", 0.01234, Number("+1234e-5") ); +new TestCase( SECTION, "Number('-1234e-5')", -0.01234, Number("-1234e-5") ); + +// StrNumericLiteral::: HexIntegerLiteral + +new TestCase( SECTION, "Number('0x0')", 0, Number("0x0")); +new TestCase( SECTION, "Number('0x1')", 1, Number("0x1")); +new TestCase( SECTION, "Number('0x2')", 2, Number("0x2")); +new TestCase( SECTION, "Number('0x3')", 3, Number("0x3")); +new TestCase( SECTION, "Number('0x4')", 4, Number("0x4")); +new TestCase( SECTION, "Number('0x5')", 5, Number("0x5")); +new TestCase( SECTION, "Number('0x6')", 6, Number("0x6")); +new TestCase( SECTION, "Number('0x7')", 7, Number("0x7")); +new TestCase( SECTION, "Number('0x8')", 8, Number("0x8")); +new TestCase( SECTION, "Number('0x9')", 9, Number("0x9")); +new TestCase( SECTION, "Number('0xa')", 10, Number("0xa")); +new TestCase( SECTION, "Number('0xb')", 11, Number("0xb")); +new TestCase( SECTION, "Number('0xc')", 12, Number("0xc")); +new TestCase( SECTION, "Number('0xd')", 13, Number("0xd")); +new TestCase( SECTION, "Number('0xe')", 14, Number("0xe")); +new TestCase( SECTION, "Number('0xf')", 15, Number("0xf")); +new TestCase( SECTION, "Number('0xA')", 10, Number("0xA")); +new TestCase( SECTION, "Number('0xB')", 11, Number("0xB")); +new TestCase( SECTION, "Number('0xC')", 12, Number("0xC")); +new TestCase( SECTION, "Number('0xD')", 13, Number("0xD")); +new TestCase( SECTION, "Number('0xE')", 14, Number("0xE")); +new TestCase( SECTION, "Number('0xF')", 15, Number("0xF")); + +new TestCase( SECTION, "Number('0X0')", 0, Number("0X0")); +new TestCase( SECTION, "Number('0X1')", 1, Number("0X1")); +new TestCase( SECTION, "Number('0X2')", 2, Number("0X2")); +new TestCase( SECTION, "Number('0X3')", 3, Number("0X3")); +new TestCase( SECTION, "Number('0X4')", 4, Number("0X4")); +new TestCase( SECTION, "Number('0X5')", 5, Number("0X5")); +new TestCase( SECTION, "Number('0X6')", 6, Number("0X6")); +new TestCase( SECTION, "Number('0X7')", 7, Number("0X7")); +new TestCase( SECTION, "Number('0X8')", 8, Number("0X8")); +new TestCase( SECTION, "Number('0X9')", 9, Number("0X9")); +new TestCase( SECTION, "Number('0Xa')", 10, Number("0Xa")); +new TestCase( SECTION, "Number('0Xb')", 11, Number("0Xb")); +new TestCase( SECTION, "Number('0Xc')", 12, Number("0Xc")); +new TestCase( SECTION, "Number('0Xd')", 13, Number("0Xd")); +new TestCase( SECTION, "Number('0Xe')", 14, Number("0Xe")); +new TestCase( SECTION, "Number('0Xf')", 15, Number("0Xf")); +new TestCase( SECTION, "Number('0XA')", 10, Number("0XA")); +new TestCase( SECTION, "Number('0XB')", 11, Number("0XB")); +new TestCase( SECTION, "Number('0XC')", 12, Number("0XC")); +new TestCase( SECTION, "Number('0XD')", 13, Number("0XD")); +new TestCase( SECTION, "Number('0XE')", 14, Number("0XE")); +new TestCase( SECTION, "Number('0XF')", 15, Number("0XF")); + +test(); + diff --git a/tests/auto/qml/parserstress/tests/ecma/TypeConversion/9.3.1-2.js b/tests/auto/qml/parserstress/tests/ecma/TypeConversion/9.3.1-2.js new file mode 100644 index 0000000000..911ec84b94 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/TypeConversion/9.3.1-2.js @@ -0,0 +1,87 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '9.3.1-2.js'; + +/** + File Name: 9.3.1-2.js + ECMA Section: 9.3 Type Conversion: ToNumber + Description: rules for converting an argument to a number. + see 9.3.1 for cases for converting strings to numbers. + special cases: + undefined NaN + Null NaN + Boolean 1 if true; +0 if false + Number the argument ( no conversion ) + String see test 9.3.1 + Object see test 9.3-1 + + This tests special cases of ToNumber(string) that are + not covered in 9.3.1-1.js. + + Author: christine@netscape.com + Date: 10 july 1997 + +*/ +var SECTION = "9.3.1-2"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "ToNumber applied to the String type"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +// A StringNumericLiteral may not use octal notation + +new TestCase( SECTION, "Number(00)", 0, Number("00")); +new TestCase( SECTION, "Number(01)", 1, Number("01")); +new TestCase( SECTION, "Number(02)", 2, Number("02")); +new TestCase( SECTION, "Number(03)", 3, Number("03")); +new TestCase( SECTION, "Number(04)", 4, Number("04")); +new TestCase( SECTION, "Number(05)", 5, Number("05")); +new TestCase( SECTION, "Number(06)", 6, Number("06")); +new TestCase( SECTION, "Number(07)", 7, Number("07")); +new TestCase( SECTION, "Number(010)", 10, Number("010")); +new TestCase( SECTION, "Number(011)", 11, Number("011")); + +// A StringNumericLIteral may have any number of leading 0 digits + +new TestCase( SECTION, "Number(001)", 1, Number("001")); +new TestCase( SECTION, "Number(0001)", 1, Number("0001")); + +test(); + diff --git a/tests/auto/qml/parserstress/tests/ecma/TypeConversion/9.3.1-3.js b/tests/auto/qml/parserstress/tests/ecma/TypeConversion/9.3.1-3.js new file mode 100644 index 0000000000..dc56427395 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/TypeConversion/9.3.1-3.js @@ -0,0 +1,743 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '9.3.1-3.js'; + +/** + File Name: 9.3.1-3.js + ECMA Section: 9.3 Type Conversion: ToNumber + Description: rules for converting an argument to a number. + see 9.3.1 for cases for converting strings to numbers. + special cases: + undefined NaN + Null NaN + Boolean 1 if true; +0 if false + Number the argument ( no conversion ) + String see test 9.3.1 + Object see test 9.3-1 + + + Test cases provided by waldemar. + + + Author: christine@netscape.com + Date: 10 june 1998 + +*/ + +var SECTION = "9.3.1-3"; +var VERSION = "ECMA_1"; +var BUGNUMBER="129087"; + +var TITLE = "Number To String, String To Number"; + +startTest(); + +writeHeaderToLog( SECTION + " "+ TITLE); + +// test case from http://scopus.mcom.com/bugsplat/show_bug.cgi?id=312954 +var z = 0; + +new TestCase( + SECTION, + "var z = 0; print(1/-z)", + -Infinity, + 1/-z ); + + + + + +// test cases from bug http://scopus.mcom.com/bugsplat/show_bug.cgi?id=122882 + + + +new TestCase( SECTION, + '- -"0x80000000"', + 2147483648, + - -"0x80000000" ); + +new TestCase( SECTION, + '- -"0x100000000"', + 4294967296, + - -"0x100000000" ); + +new TestCase( SECTION, + '- "-0x123456789abcde8"', + 81985529216486880, + - "-0x123456789abcde8" ); + +// Convert some large numbers to string + + +new TestCase( SECTION, + "1e2000 +''", + "Infinity", + 1e2000 +"" ); + +new TestCase( SECTION, + "1e2000", + Infinity, + 1e2000 ); + +new TestCase( SECTION, + "-1e2000 +''", + "-Infinity", + -1e2000 +"" ); + +new TestCase( SECTION, + "-\"1e2000\"", + -Infinity, + -"1e2000" ); + +new TestCase( SECTION, + "-\"-1e2000\" +''", + "Infinity", + -"-1e2000" +"" ); + +new TestCase( SECTION, + "1e-2000", + 0, + 1e-2000 ); + +new TestCase( SECTION, + "1/1e-2000", + Infinity, + 1/1e-2000 ); + +// convert some strings to large numbers + +new TestCase( SECTION, + "1/-1e-2000", + -Infinity, + 1/-1e-2000 ); + +new TestCase( SECTION, + "1/\"1e-2000\"", + Infinity, + 1/"1e-2000" ); + +new TestCase( SECTION, + "1/\"-1e-2000\"", + -Infinity, + 1/"-1e-2000" ); + +new TestCase( SECTION, + "parseFloat(\"1e2000\")", + Infinity, + parseFloat("1e2000") ); + +new TestCase( SECTION, + "parseFloat(\"1e-2000\")", + 0, + parseFloat("1e-2000") ); + +new TestCase( SECTION, + "1.7976931348623157E+308", + 1.7976931348623157e+308, + 1.7976931348623157E+308 ); + +new TestCase( SECTION, + "1.7976931348623158e+308", + 1.7976931348623157e+308, + 1.7976931348623158e+308 ); + +new TestCase( SECTION, + "1.7976931348623159e+308", + Infinity, + 1.7976931348623159e+308 ); + +s = + "17976931348623158079372897140530341507993413271003782693617377898044496829276475094664901797758720709633028641669288791094655554785194040263065748867150582068"; + +print("s = " + s); +print("-s = " + (-s)); + +new TestCase( SECTION, + "s = " + s +"; s +="+ + "\"190890200070838367627385484581771153176447573027006985557136695962284291481986083493647529271907416844436551070434271155969950809304288017790417449779\""+ + + +"; s", + "17976931348623158079372897140530341507993413271003782693617377898044496829276475094664901797758720709633028641669288791094655554785194040263065748867150582068190890200070838367627385484581771153176447573027006985557136695962284291481986083493647529271907416844436551070434271155969950809304288017790417449779", + s += + "190890200070838367627385484581771153176447573027006985557136695962284291481986083493647529271907416844436551070434271155969950809304288017790417449779" + ); + +s1 = s+1; + +print("s1 = " + s1); +print("-s1 = " + (-s1)); + +new TestCase( SECTION, + "s1 = s+1; s1", + "179769313486231580793728971405303415079934132710037826936173778980444968292764750946649017977587207096330286416692887910946555547851940402630657488671505820681908902000708383676273854845817711531764475730270069855571366959622842914819860834936475292719074168444365510704342711559699508093042880177904174497791", + s1 ); + +/***** This answer is preferred but -Infinity is also acceptable here *****/ + +new TestCase( SECTION, + "-s1 == Infinity || s1 == 1.7976931348623157e+308", + true, + -s1 == Infinity || s1 == 1.7976931348623157e+308 ); + +s2 = s + 2; + +print("s2 = " + s2); +print("-s2 = " + (-s2)); + +new TestCase( SECTION, + "s2 = s+2; s2", + "179769313486231580793728971405303415079934132710037826936173778980444968292764750946649017977587207096330286416692887910946555547851940402630657488671505820681908902000708383676273854845817711531764475730270069855571366959622842914819860834936475292719074168444365510704342711559699508093042880177904174497792", + s2 ); + +// ***** This answer is preferred but -1.7976931348623157e+308 is also acceptable here ***** +new TestCase( SECTION, + "-s2 == -Infinity || -s2 == -1.7976931348623157e+308 ", + true, + -s2 == -Infinity || -s2 == -1.7976931348623157e+308 ); + +s3 = s+3; + +print("s3 = " + s3); +print("-s3 = " + (-s3)); + +new TestCase( SECTION, + "s3 = s+3; s3", + "179769313486231580793728971405303415079934132710037826936173778980444968292764750946649017977587207096330286416692887910946555547851940402630657488671505820681908902000708383676273854845817711531764475730270069855571366959622842914819860834936475292719074168444365510704342711559699508093042880177904174497793", + s3 ); + +//***** This answer is preferred but -1.7976931348623157e+308 is also acceptable here ***** + +new TestCase( SECTION, + "-s3 == -Infinity || -s3 == -1.7976931348623157e+308", + true, + -s3 == -Infinity || -s3 == -1.7976931348623157e+308 ); + + +//***** This answer is preferred but Infinity is also acceptable here ***** + +new TestCase( SECTION, + "parseInt(s1,10) == 1.7976931348623157e+308 || parseInt(s1,10) == Infinity", + true, + parseInt(s1,10) == 1.7976931348623157e+308 || parseInt(s1,10) == Infinity ); + +//***** This answer is preferred but 1.7976931348623157e+308 is also acceptable here ***** +new TestCase( SECTION, + "parseInt(s2,10) == Infinity || parseInt(s2,10) == 1.7976931348623157e+308", + true , + parseInt(s2,10) == Infinity || parseInt(s2,10) == 1.7976931348623157e+308 ); + +//***** This answer is preferred but Infinity is also acceptable here ***** + +new TestCase( SECTION, + "parseInt(s1) == 1.7976931348623157e+308 || parseInt(s1) == Infinity", + true, + parseInt(s1) == 1.7976931348623157e+308 || parseInt(s1) == Infinity); + +//***** This answer is preferred but 1.7976931348623157e+308 is also acceptable here ***** +new TestCase( SECTION, + "parseInt(s2) == Infinity || parseInt(s2) == 1.7976931348623157e+308", + true, + parseInt(s2) == Infinity || parseInt(s2) == 1.7976931348623157e+308 ); + +new TestCase( SECTION, + "0x12345678", + 305419896, + 0x12345678 ); + +new TestCase( SECTION, + "0x80000000", + 2147483648, + 0x80000000 ); + +new TestCase( SECTION, + "0xffffffff", + 4294967295, + 0xffffffff ); + +new TestCase( SECTION, + "0x100000000", + 4294967296, + 0x100000000 ); + +new TestCase( SECTION, + "077777777777777777", + 2251799813685247, + 077777777777777777 ); + +new TestCase( SECTION, + "077777777777777776", + 2251799813685246, + 077777777777777776 ); + +new TestCase( SECTION, + "0x1fffffffffffff", + 9007199254740991, + 0x1fffffffffffff ); + +new TestCase( SECTION, + "0x20000000000000", + 9007199254740992, + 0x20000000000000 ); + +new TestCase( SECTION, + "0x20123456789abc", + 9027215253084860, + 0x20123456789abc ); + +new TestCase( SECTION, + "0x20123456789abd", + 9027215253084860, + 0x20123456789abd ); + +new TestCase( SECTION, + "0x20123456789abe", + 9027215253084862, + 0x20123456789abe ); + +new TestCase( SECTION, + "0x20123456789abf", + 9027215253084864, + 0x20123456789abf ); + +/***** These test the round-to-nearest-or-even-if-equally-close rule *****/ + +new TestCase( SECTION, + "0x1000000000000080", + 1152921504606847000, + 0x1000000000000080 ); + +new TestCase( SECTION, + "0x1000000000000081", + 1152921504606847200, + 0x1000000000000081 ); + +new TestCase( SECTION, + "0x1000000000000100", + 1152921504606847200, + 0x1000000000000100 ); +new TestCase( SECTION, + "0x100000000000017f", + 1152921504606847200, + 0x100000000000017f ); + +new TestCase( SECTION, + "0x1000000000000180", + 1152921504606847500, + 0x1000000000000180 ); + +new TestCase( SECTION, + "0x1000000000000181", + 1152921504606847500, + 0x1000000000000181 ); + +new TestCase( SECTION, + "0x10000000000001f0", + 1152921504606847500, + 0x10000000000001f0 ); + +new TestCase( SECTION, + "0x1000000000000200", + 1152921504606847500, + 0x1000000000000200 ); + +new TestCase( SECTION, + "0x100000000000027f", + 1152921504606847500, + 0x100000000000027f ); + +new TestCase( SECTION, + "0x1000000000000280", + 1152921504606847500, + 0x1000000000000280 ); + +new TestCase( SECTION, + "0x1000000000000281", + 1152921504606847700, + 0x1000000000000281 ); + +new TestCase( SECTION, + "0x10000000000002ff", + 1152921504606847700, + 0x10000000000002ff ); + +new TestCase( SECTION, + "0x1000000000000300", + 1152921504606847700, + 0x1000000000000300 ); + +new TestCase( SECTION, + "0x10000000000000000", + 18446744073709552000, + 0x10000000000000000 ); + +new TestCase( SECTION, + "parseInt(\"000000100000000100100011010001010110011110001001101010111100\",2)", + 9027215253084860, + parseInt("000000100000000100100011010001010110011110001001101010111100",2) ); + +new TestCase( SECTION, + "parseInt(\"000000100000000100100011010001010110011110001001101010111101\",2)", + 9027215253084860, + parseInt("000000100000000100100011010001010110011110001001101010111101",2) ); + +new TestCase( SECTION, + "parseInt(\"000000100000000100100011010001010110011110001001101010111111\",2)", + 9027215253084864, + parseInt("000000100000000100100011010001010110011110001001101010111111",2) ); + +new TestCase( SECTION, + "parseInt(\"0000001000000001001000110100010101100111100010011010101111010\",2)", + 18054430506169720, + parseInt("0000001000000001001000110100010101100111100010011010101111010",2)); + +new TestCase( SECTION, + "parseInt(\"0000001000000001001000110100010101100111100010011010101111011\",2)", + 18054430506169724, + parseInt("0000001000000001001000110100010101100111100010011010101111011",2) ); + +new TestCase( SECTION, + "parseInt(\"0000001000000001001000110100010101100111100010011010101111100\",2)", + 18054430506169724, + parseInt("0000001000000001001000110100010101100111100010011010101111100",2)); + +new TestCase( SECTION, + "parseInt(\"0000001000000001001000110100010101100111100010011010101111110\",2)", + 18054430506169728, + parseInt("0000001000000001001000110100010101100111100010011010101111110",2)); + +new TestCase( SECTION, + "parseInt(\"yz\",35)", + 34, + parseInt("yz",35) ); + +new TestCase( SECTION, + "parseInt(\"yz\",36)", + 1259, + parseInt("yz",36) ); + +new TestCase( SECTION, + "parseInt(\"yz\",37)", + NaN, + parseInt("yz",37) ); + +new TestCase( SECTION, + "parseInt(\"+77\")", + 77, + parseInt("+77") ); + +new TestCase( SECTION, + "parseInt(\"-77\",9)", + -70, + parseInt("-77",9) ); + +new TestCase( SECTION, + "parseInt(\"\\u20001234\\u2000\")", + 1234, + parseInt("\u20001234\u2000") ); + +new TestCase( SECTION, + "parseInt(\"123456789012345678\")", + 123456789012345680, + parseInt("123456789012345678") ); + +new TestCase( SECTION, + "parseInt(\"9\",8)", + NaN, + parseInt("9",8) ); + +new TestCase( SECTION, + "parseInt(\"1e2\")", + 1, + parseInt("1e2") ); + +new TestCase( SECTION, + "parseInt(\"1.9999999999999999999\")", + 1, + parseInt("1.9999999999999999999") ); + +new TestCase( SECTION, + "parseInt(\"0x10\")", + 16, + parseInt("0x10") ); + +new TestCase( SECTION, + "parseInt(\"0x10\",10)", + 0, + parseInt("0x10",10) ); + +new TestCase( SECTION, + "parseInt(\"0022\")", + 18, + parseInt("0022") ); + +new TestCase( SECTION, + "parseInt(\"0022\",10)", + 22, + parseInt("0022",10) ); + +new TestCase( SECTION, + "parseInt(\"0x1000000000000080\")", + 1152921504606847000, + parseInt("0x1000000000000080") ); + +new TestCase( SECTION, + "parseInt(\"0x1000000000000081\")", + 1152921504606847200, + parseInt("0x1000000000000081") ); + +s = + "0xFFFFFFFFFFFFF80000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"; + +new TestCase( SECTION, "s = "+ + "\"0xFFFFFFFFFFFFF80000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\";"+ + "s", + "0xFFFFFFFFFFFFF80000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + s ); + + +new TestCase( SECTION, "s +="+ + "\"0000000000000000000000000000000000000\"; s", + "0xFFFFFFFFFFFFF800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + s += "0000000000000000000000000000000000000" ); + +new TestCase( SECTION, "-s", + -1.7976931348623157e+308, + -s ); + +s = + "0xFFFFFFFFFFFFF80000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"; + +new TestCase( SECTION, "s ="+ + "\"0xFFFFFFFFFFFFF80000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\";"+ + "s", + "0xFFFFFFFFFFFFF80000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + s ); + +new TestCase( SECTION, + "s += \"0000000000000000000000000000000000001\"", + "0xFFFFFFFFFFFFF800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001", + s += "0000000000000000000000000000000000001" ); + +new TestCase( SECTION, + "-s", + -1.7976931348623157e+308, + -s ); + +s = + "0xFFFFFFFFFFFFFC0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"; + +new TestCase( SECTION, + "s ="+ + "\"0xFFFFFFFFFFFFFC0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\";"+ + "s", + "0xFFFFFFFFFFFFFC0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + s ); + + +new TestCase( SECTION, + "s += \"0000000000000000000000000000000000000\"", + "0xFFFFFFFFFFFFFC00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + s += "0000000000000000000000000000000000000"); + + +new TestCase( SECTION, + "-s", + -Infinity, + -s ); + +s = + "0xFFFFFFFFFFFFFB0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"; + +new TestCase( SECTION, + "s = "+ + "\"0xFFFFFFFFFFFFFB0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\";s", + "0xFFFFFFFFFFFFFB0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + s); + +new TestCase( SECTION, + "s += \"0000000000000000000000000000000000001\"", + "0xFFFFFFFFFFFFFB00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001", + s += "0000000000000000000000000000000000001" ); + +new TestCase( SECTION, + "-s", + -1.7976931348623157e+308, + -s ); + +new TestCase( SECTION, + "s += \"0\"", + "0xFFFFFFFFFFFFFB000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010", + s += "0" ); + +new TestCase( SECTION, + "-s", + -Infinity, + -s ); + +new TestCase( SECTION, + "parseInt(s)", + Infinity, + parseInt(s) ); + +new TestCase( SECTION, + "parseInt(s,32)", + 0, + parseInt(s,32) ); + +new TestCase( SECTION, + "parseInt(s,36)", + Infinity, + parseInt(s,36) ); + +new TestCase( SECTION, + "-\"\"", + 0, + -"" ); + +new TestCase( SECTION, + "-\" \"", + 0, + -" " ); + +new TestCase( SECTION, + "-\"999\"", + -999, + -"999" ); + +new TestCase( SECTION, + "-\" 999\"", + -999, + -" 999" ); + +new TestCase( SECTION, + "-\"\\t999\"", + -999, + -"\t999" ); + +new TestCase( SECTION, + "-\"013 \"", + -13, + -"013 " ); + +new TestCase( SECTION, + "-\"999\\t\"", + -999, + -"999\t" ); + +new TestCase( SECTION, + "-\"-Infinity\"", + Infinity, + -"-Infinity" ); + +new TestCase( SECTION, + "-\"-infinity\"", + NaN, + -"-infinity" ); + + +new TestCase( SECTION, + "-\"+Infinity\"", + -Infinity, + -"+Infinity" ); + +new TestCase( SECTION, + "-\"+Infiniti\"", + NaN, + -"+Infiniti" ); + +new TestCase( SECTION, + "- -\"0x80000000\"", + 2147483648, + - -"0x80000000" ); + +new TestCase( SECTION, + "- -\"0x100000000\"", + 4294967296, + - -"0x100000000" ); + +new TestCase( SECTION, + "- \"-0x123456789abcde8\"", + 81985529216486880, + - "-0x123456789abcde8" ); + +// the following two tests are not strictly ECMA 1.0 + +new TestCase( SECTION, + "-\"\\u20001234\\u2001\"", + -1234, + -"\u20001234\u2001" ); + +new TestCase( SECTION, + "-\"\\u20001234\\0\"", + NaN, + -"\u20001234\0" ); + +new TestCase( SECTION, + "-\"0x10\"", + -16, + -"0x10" ); + +new TestCase( SECTION, + "-\"+\"", + NaN, + -"+" ); + +new TestCase( SECTION, + "-\"-\"", + NaN, + -"-" ); + +new TestCase( SECTION, + "-\"-0-\"", + NaN, + -"-0-" ); + +new TestCase( SECTION, + "-\"1e-\"", + NaN, + -"1e-" ); + +new TestCase( SECTION, + "-\"1e-1\"", + -0.1, + -"1e-1" ); + +test(); + + diff --git a/tests/auto/qml/parserstress/tests/ecma/TypeConversion/9.3.js b/tests/auto/qml/parserstress/tests/ecma/TypeConversion/9.3.js new file mode 100644 index 0000000000..c4b866e7f3 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/TypeConversion/9.3.js @@ -0,0 +1,87 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '9.3.js'; + +/** + File Name: 9.3.js + ECMA Section: 9.3 Type Conversion: ToNumber + Description: rules for converting an argument to a number. + see 9.3.1 for cases for converting strings to numbers. + special cases: + undefined NaN + Null NaN + Boolean 1 if true; +0 if false + Number the argument ( no conversion ) + String see test 9.3.1 + Object see test 9.3-1 + + For ToNumber applied to the String type, see test 9.3.1. + For ToNumber applied to the object type, see test 9.3-1. + + Author: christine@netscape.com + Date: 10 july 1997 + +*/ +var SECTION = "9.3"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "ToNumber"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +// special cases here + +new TestCase( SECTION, "Number()", 0, Number() ); +new TestCase( SECTION, "Number(eval('var x'))", Number.NaN, Number(eval("var x")) ); +new TestCase( SECTION, "Number(void 0)", Number.NaN, Number(void 0) ); +new TestCase( SECTION, "Number(null)", 0, Number(null) ); +new TestCase( SECTION, "Number(true)", 1, Number(true) ); +new TestCase( SECTION, "Number(false)", 0, Number(false) ); +new TestCase( SECTION, "Number(0)", 0, Number(0) ); +new TestCase( SECTION, "Number(-0)", -0, Number(-0) ); +new TestCase( SECTION, "Number(1)", 1, Number(1) ); +new TestCase( SECTION, "Number(-1)", -1, Number(-1) ); +new TestCase( SECTION, "Number(Number.MAX_VALUE)", 1.7976931348623157e308, Number(Number.MAX_VALUE) ); +new TestCase( SECTION, "Number(Number.MIN_VALUE)", 5e-324, Number(Number.MIN_VALUE) ); + +new TestCase( SECTION, "Number(Number.NaN)", Number.NaN, Number(Number.NaN) ); +new TestCase( SECTION, "Number(Number.POSITIVE_INFINITY)", Number.POSITIVE_INFINITY, Number(Number.POSITIVE_INFINITY) ); +new TestCase( SECTION, "Number(Number.NEGATIVE_INFINITY)", Number.NEGATIVE_INFINITY, Number(Number.NEGATIVE_INFINITY) ); + +test(); diff --git a/tests/auto/qml/parserstress/tests/ecma/TypeConversion/9.4-1.js b/tests/auto/qml/parserstress/tests/ecma/TypeConversion/9.4-1.js new file mode 100644 index 0000000000..e99875697a --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/TypeConversion/9.4-1.js @@ -0,0 +1,112 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '9.4-1.js'; + +/** + File Name: 9.4-1.js + ECMA Section: 9.4 ToInteger + Description: 1. Call ToNumber on the input argument + 2. If Result(1) is NaN, return +0 + 3. If Result(1) is +0, -0, Infinity, or -Infinity, + return Result(1). + 4. Compute sign(Result(1)) * floor(abs(Result(1))). + 5. Return Result(4). + + To test ToInteger, this test uses new Date(value), + 15.9.3.7. The Date constructor sets the [[Value]] + property of the new object to TimeClip(value), which + uses the rules: + + TimeClip(time) + 1. If time is not finite, return NaN + 2. If abs(Result(1)) > 8.64e15, return NaN + 3. Return an implementation dependent choice of either + ToInteger(Result(2)) or ToInteger(Result(2)) + (+0) + (Adding a positive 0 converts -0 to +0). + + This tests ToInteger for values -8.64e15 > value > 8.64e15, + not including -0 and +0. + + For additional special cases (0, +0, Infinity, -Infinity, + and NaN, see 9.4-2.js). For value is String, see 9.4-3.js. + + Author: christine@netscape.com + Date: 10 july 1997 + +*/ +var SECTION = "9.4-1"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "ToInteger"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +// some special cases + +new TestCase( SECTION, "td = new Date(Number.NaN); td.valueOf()", Number.NaN, eval("td = new Date(Number.NaN); td.valueOf()") ); +new TestCase( SECTION, "td = new Date(Infinity); td.valueOf()", Number.NaN, eval("td = new Date(Number.POSITIVE_INFINITY); td.valueOf()") ); +new TestCase( SECTION, "td = new Date(-Infinity); td.valueOf()", Number.NaN, eval("td = new Date(Number.NEGATIVE_INFINITY); td.valueOf()") ); +new TestCase( SECTION, "td = new Date(-0); td.valueOf()", -0, eval("td = new Date(-0); td.valueOf()" ) ); +new TestCase( SECTION, "td = new Date(0); td.valueOf()", 0, eval("td = new Date(0); td.valueOf()") ); + +// value is not an integer + +new TestCase( SECTION, "td = new Date(3.14159); td.valueOf()", 3, eval("td = new Date(3.14159); td.valueOf()") ); +new TestCase( SECTION, "td = new Date(Math.PI); td.valueOf()", 3, eval("td = new Date(Math.PI); td.valueOf()") ); +new TestCase( SECTION, "td = new Date(-Math.PI);td.valueOf()", -3, eval("td = new Date(-Math.PI);td.valueOf()") ); +new TestCase( SECTION, "td = new Date(3.14159e2); td.valueOf()", 314, eval("td = new Date(3.14159e2); td.valueOf()") ); + +new TestCase( SECTION, "td = new Date(.692147e1); td.valueOf()", 6, eval("td = new Date(.692147e1);td.valueOf()") ); +new TestCase( SECTION, "td = new Date(-.692147e1);td.valueOf()", -6, eval("td = new Date(-.692147e1);td.valueOf()") ); + +// value is not a number + +new TestCase( SECTION, "td = new Date(true); td.valueOf()", 1, eval("td = new Date(true); td.valueOf()" ) ); +new TestCase( SECTION, "td = new Date(false); td.valueOf()", 0, eval("td = new Date(false); td.valueOf()") ); + +new TestCase( SECTION, "td = new Date(new Number(Math.PI)); td.valueOf()", 3, eval("td = new Date(new Number(Math.PI)); td.valueOf()") ); +new TestCase( SECTION, "td = new Date(new Number(Math.PI)); td.valueOf()", 3, eval("td = new Date(new Number(Math.PI)); td.valueOf()") ); + +// edge cases +new TestCase( SECTION, "td = new Date(8.64e15); td.valueOf()", 8.64e15, eval("td = new Date(8.64e15); td.valueOf()") ); +new TestCase( SECTION, "td = new Date(-8.64e15); td.valueOf()", -8.64e15, eval("td = new Date(-8.64e15); td.valueOf()") ); +new TestCase( SECTION, "td = new Date(8.64e-15); td.valueOf()", 0, eval("td = new Date(8.64e-15); td.valueOf()") ); +new TestCase( SECTION, "td = new Date(-8.64e-15); td.valueOf()", 0, eval("td = new Date(-8.64e-15); td.valueOf()") ); + +test(); diff --git a/tests/auto/qml/parserstress/tests/ecma/TypeConversion/9.4-2.js b/tests/auto/qml/parserstress/tests/ecma/TypeConversion/9.4-2.js new file mode 100644 index 0000000000..9b26a67fac --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/TypeConversion/9.4-2.js @@ -0,0 +1,112 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '9.4-2.js'; + +/** + File Name: 9.4-1.js + ECMA Section: 9.4 ToInteger + Description: 1. Call ToNumber on the input argument + 2. If Result(1) is NaN, return +0 + 3. If Result(1) is +0, -0, Infinity, or -Infinity, + return Result(1). + 4. Compute sign(Result(1)) * floor(abs(Result(1))). + 5. Return Result(4). + + To test ToInteger, this test uses new Date(value), + 15.9.3.7. The Date constructor sets the [[Value]] + property of the new object to TimeClip(value), which + uses the rules: + + TimeClip(time) + 1. If time is not finite, return NaN + 2. If abs(Result(1)) > 8.64e15, return NaN + 3. Return an implementation dependent choice of either + ToInteger(Result(2)) or ToInteger(Result(2)) + (+0) + (Adding a positive 0 converts -0 to +0). + + This tests ToInteger for values -8.64e15 > value > 8.64e15, + not including -0 and +0. + + For additional special cases (0, +0, Infinity, -Infinity, + and NaN, see 9.4-2.js). For value is String, see 9.4-3.js. + + Author: christine@netscape.com + Date: 10 july 1997 + +*/ +var SECTION = "9.4-1"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "ToInteger"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +// some special cases + +new TestCase( SECTION, "td = new Date(Number.NaN); td.valueOf()", Number.NaN, eval("td = new Date(Number.NaN); td.valueOf()") ); +new TestCase( SECTION, "td = new Date(Infinity); td.valueOf()", Number.NaN, eval("td = new Date(Number.POSITIVE_INFINITY); td.valueOf()") ); +new TestCase( SECTION, "td = new Date(-Infinity); td.valueOf()", Number.NaN, eval("td = new Date(Number.NEGATIVE_INFINITY); td.valueOf()") ); +new TestCase( SECTION, "td = new Date(-0); td.valueOf()", -0, eval("td = new Date(-0); td.valueOf()" ) ); +new TestCase( SECTION, "td = new Date(0); td.valueOf()", 0, eval("td = new Date(0); td.valueOf()") ); + +// value is not an integer + +new TestCase( SECTION, "td = new Date(3.14159); td.valueOf()", 3, eval("td = new Date(3.14159); td.valueOf()") ); +new TestCase( SECTION, "td = new Date(Math.PI); td.valueOf()", 3, eval("td = new Date(Math.PI); td.valueOf()") ); +new TestCase( SECTION, "td = new Date(-Math.PI);td.valueOf()", -3, eval("td = new Date(-Math.PI);td.valueOf()") ); +new TestCase( SECTION, "td = new Date(3.14159e2); td.valueOf()", 314, eval("td = new Date(3.14159e2); td.valueOf()") ); + +new TestCase( SECTION, "td = new Date(.692147e1); td.valueOf()", 6, eval("td = new Date(.692147e1);td.valueOf()") ); +new TestCase( SECTION, "td = new Date(-.692147e1);td.valueOf()", -6, eval("td = new Date(-.692147e1);td.valueOf()") ); + +// value is not a number + +new TestCase( SECTION, "td = new Date(true); td.valueOf()", 1, eval("td = new Date(true); td.valueOf()" ) ); +new TestCase( SECTION, "td = new Date(false); td.valueOf()", 0, eval("td = new Date(false); td.valueOf()") ); + +new TestCase( SECTION, "td = new Date(new Number(Math.PI)); td.valueOf()", 3, eval("td = new Date(new Number(Math.PI)); td.valueOf()") ); +new TestCase( SECTION, "td = new Date(new Number(Math.PI)); td.valueOf()", 3, eval("td = new Date(new Number(Math.PI)); td.valueOf()") ); + +// edge cases +new TestCase( SECTION, "td = new Date(8.64e15); td.valueOf()", 8.64e15, eval("td = new Date(8.64e15); td.valueOf()") ); +new TestCase( SECTION, "td = new Date(-8.64e15); td.valueOf()", -8.64e15, eval("td = new Date(-8.64e15); td.valueOf()") ); +new TestCase( SECTION, "td = new Date(8.64e-15); td.valueOf()", 0, eval("td = new Date(8.64e-15); td.valueOf()") ); +new TestCase( SECTION, "td = new Date(-8.64e-15); td.valueOf()", 0, eval("td = new Date(-8.64e-15); td.valueOf()") ); + +test(); diff --git a/tests/auto/qml/parserstress/tests/ecma/TypeConversion/9.5-2.js b/tests/auto/qml/parserstress/tests/ecma/TypeConversion/9.5-2.js new file mode 100644 index 0000000000..2773052340 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/TypeConversion/9.5-2.js @@ -0,0 +1,173 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '9.5-2.js'; + +/** + File Name: 9.5-2.js + ECMA Section: 9.5 Type Conversion: ToInt32 + Description: rules for converting an argument to a signed 32 bit integer + + this test uses << 0 to convert the argument to a 32bit + integer. + + The operator ToInt32 converts its argument to one of 2^32 + integer values in the range -2^31 through 2^31 inclusive. + This operator functions as follows: + + 1 call ToNumber on argument + 2 if result is NaN, 0, -0, return 0 + 3 compute (sign (result(1)) * floor(abs(result 1))) + 4 compute result(3) modulo 2^32: + 5 if result(4) is greater than or equal to 2^31, return + result(5)-2^32. otherwise, return result(5) + + special cases: + -0 returns 0 + Infinity returns 0 + -Infinity returns 0 + ToInt32(ToUint32(x)) == ToInt32(x) for all values of x + Numbers greater than 2^31 (see step 5 above) + (note http://bugzilla.mozilla.org/show_bug.cgi?id=120083) + + Author: christine@netscape.com + Date: 17 july 1997 +*/ +var SECTION = "9.5-2"; +var VERSION = "ECMA_1"; +startTest(); + +writeHeaderToLog( SECTION + " ToInt32"); + +new TestCase( SECTION, "0 << 0", 0, 0 << 0 ); +new TestCase( SECTION, "-0 << 0", 0, -0 << 0 ); +new TestCase( SECTION, "Infinity << 0", 0, "Infinity" << 0 ); +new TestCase( SECTION, "-Infinity << 0", 0, "-Infinity" << 0 ); +new TestCase( SECTION, "Number.POSITIVE_INFINITY << 0", 0, Number.POSITIVE_INFINITY << 0 ); +new TestCase( SECTION, "Number.NEGATIVE_INFINITY << 0", 0, Number.NEGATIVE_INFINITY << 0 ); +new TestCase( SECTION, "Number.NaN << 0", 0, Number.NaN << 0 ); + +new TestCase( SECTION, "Number.MIN_VALUE << 0", 0, Number.MIN_VALUE << 0 ); +new TestCase( SECTION, "-Number.MIN_VALUE << 0", 0, -Number.MIN_VALUE << 0 ); +new TestCase( SECTION, "0.1 << 0", 0, 0.1 << 0 ); +new TestCase( SECTION, "-0.1 << 0", 0, -0.1 << 0 ); +new TestCase( SECTION, "1 << 0", 1, 1 << 0 ); +new TestCase( SECTION, "1.1 << 0", 1, 1.1 << 0 ); +new TestCase( SECTION, "-1 << 0", ToInt32(-1), -1 << 0 ); + + +new TestCase( SECTION, "2147483647 << 0", ToInt32(2147483647), 2147483647 << 0 ); +new TestCase( SECTION, "2147483648 << 0", ToInt32(2147483648), 2147483648 << 0 ); +new TestCase( SECTION, "2147483649 << 0", ToInt32(2147483649), 2147483649 << 0 ); + +new TestCase( SECTION, "(Math.pow(2,31)-1) << 0", ToInt32(2147483647), (Math.pow(2,31)-1) << 0 ); +new TestCase( SECTION, "Math.pow(2,31) << 0", ToInt32(2147483648), Math.pow(2,31) << 0 ); +new TestCase( SECTION, "(Math.pow(2,31)+1) << 0", ToInt32(2147483649), (Math.pow(2,31)+1) << 0 ); + +new TestCase( SECTION, "(Math.pow(2,32)-1) << 0", ToInt32(4294967295), (Math.pow(2,32)-1) << 0 ); +new TestCase( SECTION, "(Math.pow(2,32)) << 0", ToInt32(4294967296), (Math.pow(2,32)) << 0 ); +new TestCase( SECTION, "(Math.pow(2,32)+1) << 0", ToInt32(4294967297), (Math.pow(2,32)+1) << 0 ); + +new TestCase( SECTION, "4294967295 << 0", ToInt32(4294967295), 4294967295 << 0 ); +new TestCase( SECTION, "4294967296 << 0", ToInt32(4294967296), 4294967296 << 0 ); +new TestCase( SECTION, "4294967297 << 0", ToInt32(4294967297), 4294967297 << 0 ); + +new TestCase( SECTION, "'2147483647' << 0", ToInt32(2147483647), '2147483647' << 0 ); +new TestCase( SECTION, "'2147483648' << 0", ToInt32(2147483648), '2147483648' << 0 ); +new TestCase( SECTION, "'2147483649' << 0", ToInt32(2147483649), '2147483649' << 0 ); + +new TestCase( SECTION, "'4294967295' << 0", ToInt32(4294967295), '4294967295' << 0 ); +new TestCase( SECTION, "'4294967296' << 0", ToInt32(4294967296), '4294967296' << 0 ); +new TestCase( SECTION, "'4294967297' << 0", ToInt32(4294967297), '4294967297' << 0 ); + +new TestCase( SECTION, "-2147483647 << 0", ToInt32(-2147483647), -2147483647 << 0 ); +new TestCase( SECTION, "-2147483648 << 0", ToInt32(-2147483648), -2147483648 << 0 ); +new TestCase( SECTION, "-2147483649 << 0", ToInt32(-2147483649), -2147483649 << 0 ); + +new TestCase( SECTION, "-4294967295 << 0", ToInt32(-4294967295), -4294967295 << 0 ); +new TestCase( SECTION, "-4294967296 << 0", ToInt32(-4294967296), -4294967296 << 0 ); +new TestCase( SECTION, "-4294967297 << 0", ToInt32(-4294967297), -4294967297 << 0 ); + +/* + * Numbers between 2^31 and 2^32 will have a negative ToInt32 per ECMA (see step 5 of introduction) + * (These are by stevechapel@earthlink.net; cf. http://bugzilla.mozilla.org/show_bug.cgi?id=120083) + */ +new TestCase( SECTION, "2147483648.25 << 0", ToInt32(2147483648.25), 2147483648.25 << 0 ); +new TestCase( SECTION, "2147483648.5 << 0", ToInt32(2147483648.5), 2147483648.5 << 0 ); +new TestCase( SECTION, "2147483648.75 << 0", ToInt32(2147483648.75), 2147483648.75 << 0 ); +new TestCase( SECTION, "4294967295.25 << 0", ToInt32(4294967295.25), 4294967295.25 << 0 ); +new TestCase( SECTION, "4294967295.5 << 0", ToInt32(4294967295.5), 4294967295.5 << 0 ); +new TestCase( SECTION, "4294967295.75 << 0", ToInt32(4294967295.75), 4294967295.75 << 0 ); +new TestCase( SECTION, "3000000000.25 << 0", ToInt32(3000000000.25), 3000000000.25 << 0 ); +new TestCase( SECTION, "3000000000.5 << 0", ToInt32(3000000000.5), 3000000000.5 << 0 ); +new TestCase( SECTION, "3000000000.75 << 0", ToInt32(3000000000.75), 3000000000.75 << 0 ); + +/* + * Numbers between - 2^31 and - 2^32 + */ +new TestCase( SECTION, "-2147483648.25 << 0", ToInt32(-2147483648.25), -2147483648.25 << 0 ); +new TestCase( SECTION, "-2147483648.5 << 0", ToInt32(-2147483648.5), -2147483648.5 << 0 ); +new TestCase( SECTION, "-2147483648.75 << 0", ToInt32(-2147483648.75), -2147483648.75 << 0 ); +new TestCase( SECTION, "-4294967295.25 << 0", ToInt32(-4294967295.25), -4294967295.25 << 0 ); +new TestCase( SECTION, "-4294967295.5 << 0", ToInt32(-4294967295.5), -4294967295.5 << 0 ); +new TestCase( SECTION, "-4294967295.75 << 0", ToInt32(-4294967295.75), -4294967295.75 << 0 ); +new TestCase( SECTION, "-3000000000.25 << 0", ToInt32(-3000000000.25), -3000000000.25 << 0 ); +new TestCase( SECTION, "-3000000000.5 << 0", ToInt32(-3000000000.5), -3000000000.5 << 0 ); +new TestCase( SECTION, "-3000000000.75 << 0", ToInt32(-3000000000.75), -3000000000.75 << 0 ); + + +test(); + +function ToInt32( n ) { + n = Number( n ); + var sign = ( n < 0 ) ? -1 : 1; + + if ( Math.abs( n ) == 0 || Math.abs( n ) == Number.POSITIVE_INFINITY) { + return 0; + } + + n = (sign * Math.floor( Math.abs(n) )) % Math.pow(2,32); + if ( sign == -1 ) { + n = ( n < -Math.pow(2,31) ) ? n + Math.pow(2,32) : n; + } else{ + n = ( n >= Math.pow(2,31) ) ? n - Math.pow(2,32) : n; + } + + return ( n ); +} + diff --git a/tests/auto/qml/parserstress/tests/ecma/TypeConversion/9.6.js b/tests/auto/qml/parserstress/tests/ecma/TypeConversion/9.6.js new file mode 100644 index 0000000000..3d958b3f9d --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/TypeConversion/9.6.js @@ -0,0 +1,140 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '9.6.js'; + +/** + File Name: 9.6.js + ECMA Section: 9.6 Type Conversion: ToUint32 + Description: rules for converting an argument to an unsigned + 32 bit integer + + this test uses >>> 0 to convert the argument to + an unsigned 32bit integer. + + 1 call ToNumber on argument + 2 if result is NaN, 0, -0, Infinity, -Infinity + return 0 + 3 compute (sign (result(1)) * floor(abs(result 1))) + 4 compute result(3) modulo 2^32: + 5 return result(4) + + special cases: + -0 returns 0 + Infinity returns 0 + -Infinity returns 0 + 0 returns 0 + ToInt32(ToUint32(x)) == ToInt32(x) for all values of x + ** NEED TO DO THIS PART IN A SEPARATE TEST FILE ** + + + Author: christine@netscape.com + Date: 17 july 1997 +*/ + +var SECTION = "9.6"; +var VERSION = "ECMA_1"; +startTest(); + +writeHeaderToLog( SECTION + " Type Conversion: ToUint32"); + +new TestCase( SECTION, "0 >>> 0", 0, 0 >>> 0 ); +// new TestCase( SECTION, "+0 >>> 0", 0, +0 >>> 0); +new TestCase( SECTION, "-0 >>> 0", 0, -0 >>> 0 ); +new TestCase( SECTION, "'Infinity' >>> 0", 0, "Infinity" >>> 0 ); +new TestCase( SECTION, "'-Infinity' >>> 0", 0, "-Infinity" >>> 0); +new TestCase( SECTION, "'+Infinity' >>> 0", 0, "+Infinity" >>> 0 ); +new TestCase( SECTION, "Number.POSITIVE_INFINITY >>> 0", 0, Number.POSITIVE_INFINITY >>> 0 ); +new TestCase( SECTION, "Number.NEGATIVE_INFINITY >>> 0", 0, Number.NEGATIVE_INFINITY >>> 0 ); +new TestCase( SECTION, "Number.NaN >>> 0", 0, Number.NaN >>> 0 ); + +new TestCase( SECTION, "Number.MIN_VALUE >>> 0", 0, Number.MIN_VALUE >>> 0 ); +new TestCase( SECTION, "-Number.MIN_VALUE >>> 0", 0, Number.MIN_VALUE >>> 0 ); +new TestCase( SECTION, "0.1 >>> 0", 0, 0.1 >>> 0 ); +new TestCase( SECTION, "-0.1 >>> 0", 0, -0.1 >>> 0 ); +new TestCase( SECTION, "1 >>> 0", 1, 1 >>> 0 ); +new TestCase( SECTION, "1.1 >>> 0", 1, 1.1 >>> 0 ); + +new TestCase( SECTION, "-1.1 >>> 0", ToUint32(-1.1), -1.1 >>> 0 ); +new TestCase( SECTION, "-1 >>> 0", ToUint32(-1), -1 >>> 0 ); + +new TestCase( SECTION, "2147483647 >>> 0", ToUint32(2147483647), 2147483647 >>> 0 ); +new TestCase( SECTION, "2147483648 >>> 0", ToUint32(2147483648), 2147483648 >>> 0 ); +new TestCase( SECTION, "2147483649 >>> 0", ToUint32(2147483649), 2147483649 >>> 0 ); + +new TestCase( SECTION, "4294967295 >>> 0", ToUint32(4294967295), 4294967295 >>> 0 ); +new TestCase( SECTION, "4294967296 >>> 0", ToUint32(4294967296), 4294967296 >>> 0 ); +new TestCase( SECTION, "4294967297 >>> 0", ToUint32(4294967297), 4294967297 >>> 0 ); + +new TestCase( SECTION, "-2147483647 >>> 0", ToUint32(-2147483647), -2147483647 >>> 0 ); +new TestCase( SECTION, "-2147483648 >>> 0", ToUint32(-2147483648), -2147483648 >>> 0 ); +new TestCase( SECTION, "-2147483649 >>> 0", ToUint32(-2147483649), -2147483649 >>> 0 ); + +new TestCase( SECTION, "-4294967295 >>> 0", ToUint32(-4294967295), -4294967295 >>> 0 ); +new TestCase( SECTION, "-4294967296 >>> 0", ToUint32(-4294967296), -4294967296 >>> 0 ); +new TestCase( SECTION, "-4294967297 >>> 0", ToUint32(-4294967297), -4294967297 >>> 0 ); + +new TestCase( SECTION, "'2147483647' >>> 0", ToUint32(2147483647), '2147483647' >>> 0 ); +new TestCase( SECTION, "'2147483648' >>> 0", ToUint32(2147483648), '2147483648' >>> 0 ); +new TestCase( SECTION, "'2147483649' >>> 0", ToUint32(2147483649), '2147483649' >>> 0 ); + +new TestCase( SECTION, "'4294967295' >>> 0", ToUint32(4294967295), '4294967295' >>> 0 ); +new TestCase( SECTION, "'4294967296' >>> 0", ToUint32(4294967296), '4294967296' >>> 0 ); +new TestCase( SECTION, "'4294967297' >>> 0", ToUint32(4294967297), '4294967297' >>> 0 ); + + +test(); + +function ToUint32( n ) { + n = Number( n ); + var sign = ( n < 0 ) ? -1 : 1; + + if ( Math.abs( n ) == 0 || Math.abs( n ) == Number.POSITIVE_INFINITY) { + return 0; + } + n = sign * Math.floor( Math.abs(n) ) + + n = n % Math.pow(2,32); + + if ( n < 0 ){ + n += Math.pow(2,32); + } + + return ( n ); +} + diff --git a/tests/auto/qml/parserstress/tests/ecma/TypeConversion/9.7.js b/tests/auto/qml/parserstress/tests/ecma/TypeConversion/9.7.js new file mode 100644 index 0000000000..34e4857fd7 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/TypeConversion/9.7.js @@ -0,0 +1,160 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '9.7.js'; + +/** + File Name: 9.7.js + ECMA Section: 9.7 Type Conversion: ToInt16 + Description: rules for converting an argument to an unsigned + 16 bit integer in the range 0 to 2^16-1. + + this test uses String.prototype.fromCharCode() and + String.prototype.charCodeAt() to test ToInt16. + + special cases: + -0 returns 0 + Infinity returns 0 + -Infinity returns 0 + 0 returns 0 + + Author: christine@netscape.com + Date: 17 july 1997 +*/ +var SECTION = "9.7"; +var VERSION = "ECMA_1"; +startTest(); + +writeHeaderToLog( SECTION + " Type Conversion: ToInt16"); + +/* + new TestCase( "9.7", "String.fromCharCode(0).charCodeAt(0)", 0, String.fromCharCode(0).charCodeAt(0) ); + new TestCase( "9.7", "String.fromCharCode(-0).charCodeAt(0)", 0, String.fromCharCode(-0).charCodeAt(0) ); + new TestCase( "9.7", "String.fromCharCode(1).charCodeAt(0)", 1, String.fromCharCode(1).charCodeAt(0) ); + new TestCase( "9.7", "String.fromCharCode(64).charCodeAt(0)", 64, String.fromCharCode(64).charCodeAt(0) ); + new TestCase( "9.7", "String.fromCharCode(126).charCodeAt(0)", 126, String.fromCharCode(126).charCodeAt(0) ); + new TestCase( "9.7", "String.fromCharCode(127).charCodeAt(0)", 127, String.fromCharCode(127).charCodeAt(0) ); + new TestCase( "9.7", "String.fromCharCode(128).charCodeAt(0)", 128, String.fromCharCode(128).charCodeAt(0) ); + new TestCase( "9.7", "String.fromCharCode(130).charCodeAt(0)", 130, String.fromCharCode(130).charCodeAt(0) ); + new TestCase( "9.7", "String.fromCharCode(255).charCodeAt(0)", 255, String.fromCharCode(255).charCodeAt(0) ); + new TestCase( "9.7", "String.fromCharCode(256).charCodeAt(0)", 256, String.fromCharCode(256).charCodeAt(0) ); + new TestCase( "9.7", "String.fromCharCode(Math.pow(2,16)-1).charCodeAt(0)", 65535, String.fromCharCode(Math.pow(2,16)-1).charCodeAt(0) ); + new TestCase( "9.7", "String.fromCharCode(Math.pow(2,16)).charCodeAt(0)", 0, String.fromCharCode(Math.pow(2,16)).charCodeAt(0) ); +*/ + + +new TestCase( "9.7", "String.fromCharCode(0).charCodeAt(0)", ToInt16(0), String.fromCharCode(0).charCodeAt(0) ); +new TestCase( "9.7", "String.fromCharCode(-0).charCodeAt(0)", ToInt16(0), String.fromCharCode(-0).charCodeAt(0) ); +new TestCase( "9.7", "String.fromCharCode(1).charCodeAt(0)", ToInt16(1), String.fromCharCode(1).charCodeAt(0) ); +new TestCase( "9.7", "String.fromCharCode(64).charCodeAt(0)", ToInt16(64), String.fromCharCode(64).charCodeAt(0) ); +new TestCase( "9.7", "String.fromCharCode(126).charCodeAt(0)", ToInt16(126), String.fromCharCode(126).charCodeAt(0) ); +new TestCase( "9.7", "String.fromCharCode(127).charCodeAt(0)", ToInt16(127), String.fromCharCode(127).charCodeAt(0) ); +new TestCase( "9.7", "String.fromCharCode(128).charCodeAt(0)", ToInt16(128), String.fromCharCode(128).charCodeAt(0) ); +new TestCase( "9.7", "String.fromCharCode(130).charCodeAt(0)", ToInt16(130), String.fromCharCode(130).charCodeAt(0) ); +new TestCase( "9.7", "String.fromCharCode(255).charCodeAt(0)", ToInt16(255), String.fromCharCode(255).charCodeAt(0) ); +new TestCase( "9.7", "String.fromCharCode(256).charCodeAt(0)", ToInt16(256), String.fromCharCode(256).charCodeAt(0) ); + +new TestCase( "9.7", "String.fromCharCode(Math.pow(2,16)-1).charCodeAt(0)", 65535, String.fromCharCode(Math.pow(2,16)-1).charCodeAt(0) ); +new TestCase( "9.7", "String.fromCharCode(Math.pow(2,16)).charCodeAt(0)", 0, String.fromCharCode(Math.pow(2,16)).charCodeAt(0) ); + +new TestCase( "9.7", "String.fromCharCode(65535).charCodeAt(0)", ToInt16(65535), String.fromCharCode(65535).charCodeAt(0) ); +new TestCase( "9.7", "String.fromCharCode(65536).charCodeAt(0)", ToInt16(65536), String.fromCharCode(65536).charCodeAt(0) ); +new TestCase( "9.7", "String.fromCharCode(65537).charCodeAt(0)", ToInt16(65537), String.fromCharCode(65537).charCodeAt(0) ); + +new TestCase( "9.7", "String.fromCharCode(131071).charCodeAt(0)", ToInt16(131071), String.fromCharCode(131071).charCodeAt(0) ); +new TestCase( "9.7", "String.fromCharCode(131072).charCodeAt(0)", ToInt16(131072), String.fromCharCode(131072).charCodeAt(0) ); +new TestCase( "9.7", "String.fromCharCode(131073).charCodeAt(0)", ToInt16(131073), String.fromCharCode(131073).charCodeAt(0) ); + +new TestCase( "9.7", "String.fromCharCode('65535').charCodeAt(0)", 65535, String.fromCharCode("65535").charCodeAt(0) ); +new TestCase( "9.7", "String.fromCharCode('65536').charCodeAt(0)", 0, String.fromCharCode("65536").charCodeAt(0) ); + +new TestCase( "9.7", "String.fromCharCode(-1).charCodeAt(0)", ToInt16(-1), String.fromCharCode(-1).charCodeAt(0) ); +new TestCase( "9.7", "String.fromCharCode(-64).charCodeAt(0)", ToInt16(-64), String.fromCharCode(-64).charCodeAt(0) ); +new TestCase( "9.7", "String.fromCharCode(-126).charCodeAt(0)", ToInt16(-126), String.fromCharCode(-126).charCodeAt(0) ); +new TestCase( "9.7", "String.fromCharCode(-127).charCodeAt(0)", ToInt16(-127), String.fromCharCode(-127).charCodeAt(0) ); +new TestCase( "9.7", "String.fromCharCode(-128).charCodeAt(0)", ToInt16(-128), String.fromCharCode(-128).charCodeAt(0) ); +new TestCase( "9.7", "String.fromCharCode(-130).charCodeAt(0)", ToInt16(-130), String.fromCharCode(-130).charCodeAt(0) ); +new TestCase( "9.7", "String.fromCharCode(-255).charCodeAt(0)", ToInt16(-255), String.fromCharCode(-255).charCodeAt(0) ); +new TestCase( "9.7", "String.fromCharCode(-256).charCodeAt(0)", ToInt16(-256), String.fromCharCode(-256).charCodeAt(0) ); + +new TestCase( "9.7", "String.fromCharCode(-Math.pow(2,16)-1).charCodeAt(0)", 65535, String.fromCharCode(-Math.pow(2,16)-1).charCodeAt(0) ); +new TestCase( "9.7", "String.fromCharCode(-Math.pow(2,16)).charCodeAt(0)", 0, String.fromCharCode(-Math.pow(2,16)).charCodeAt(0) ); + +new TestCase( "9.7", "String.fromCharCode(-65535).charCodeAt(0)", ToInt16(-65535), String.fromCharCode(-65535).charCodeAt(0) ); +new TestCase( "9.7", "String.fromCharCode(-65536).charCodeAt(0)", ToInt16(-65536), String.fromCharCode(-65536).charCodeAt(0) ); +new TestCase( "9.7", "String.fromCharCode(-65537).charCodeAt(0)", ToInt16(-65537), String.fromCharCode(-65537).charCodeAt(0) ); + +new TestCase( "9.7", "String.fromCharCode(-131071).charCodeAt(0)", ToInt16(-131071), String.fromCharCode(-131071).charCodeAt(0) ); +new TestCase( "9.7", "String.fromCharCode(-131072).charCodeAt(0)", ToInt16(-131072), String.fromCharCode(-131072).charCodeAt(0) ); +new TestCase( "9.7", "String.fromCharCode(-131073).charCodeAt(0)", ToInt16(-131073), String.fromCharCode(-131073).charCodeAt(0) ); + +new TestCase( "9.7", "String.fromCharCode('-65535').charCodeAt(0)", ToInt16(-65535), String.fromCharCode("-65535").charCodeAt(0) ); +new TestCase( "9.7", "String.fromCharCode('-65536').charCodeAt(0)", ToInt16(-65536), String.fromCharCode("-65536").charCodeAt(0) ); + + +// new TestCase( "9.7", "String.fromCharCode(2147483648).charCodeAt(0)", ToInt16(2147483648), String.fromCharCode(2147483648).charCodeAt(0) ); + + + +// the following test cases cause a runtime error. see: http://scopus.mcom.com/bugsplat/show_bug.cgi?id=78878 + +// new TestCase( "9.7", "String.fromCharCode(Infinity).charCodeAt(0)", 0, String.fromCharCode("Infinity").charCodeAt(0) ); +// new TestCase( "9.7", "String.fromCharCode(-Infinity).charCodeAt(0)", 0, String.fromCharCode("-Infinity").charCodeAt(0) ); +// new TestCase( "9.7", "String.fromCharCode(NaN).charCodeAt(0)", 0, String.fromCharCode(Number.NaN).charCodeAt(0) ); +// new TestCase( "9.7", "String.fromCharCode(Number.POSITIVE_INFINITY).charCodeAt(0)", 0, String.fromCharCode(Number.POSITIVE_INFINITY).charCodeAt(0) ); +// new TestCase( "9.7", "String.fromCharCode(Number.NEGATIVE_INFINITY).charCodeAt(0)", 0, String.fromCharCode(Number.NEGATIVE_INFINITY).charCodeAt(0) ); + +test(); + +function ToInt16( num ) { + num = Number( num ); + if ( isNaN( num ) || num == 0 || num == Number.POSITIVE_INFINITY || num == Number.NEGATIVE_INFINITY ) { + return 0; + } + + var sign = ( num < 0 ) ? -1 : 1; + + num = sign * Math.floor( Math.abs( num ) ); + + num = num % Math.pow(2,16); + + num = ( num > -65536 && num < 0) ? 65536 + num : num; + + return num; +} + diff --git a/tests/auto/qml/parserstress/tests/ecma/TypeConversion/9.8.1.js b/tests/auto/qml/parserstress/tests/ecma/TypeConversion/9.8.1.js new file mode 100644 index 0000000000..897dc59f6f --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/TypeConversion/9.8.1.js @@ -0,0 +1,167 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '9.8.1.js'; + +/** + File Name: 9.8.1.js + ECMA Section: 9.8.1 ToString Applied to the Number Type + Description: The operator ToString convers a number m to string + as follows: + + 1. if m is NaN, return the string "NaN" + 2. if m is +0 or -0, return the string "0" + 3. if m is less than zero, return the string + concatenation of the string "-" and ToString(-m). + 4. If m is Infinity, return the string "Infinity". + 5. Otherwise, let n, k, and s be integers such that + k >= 1, 10k1 <= s < 10k, the number value for s10nk + is m, and k is as small as possible. Note that k is + the number of digits in the decimal representation + of s, that s is not divisible by 10, and that the + least significant digit of s is not necessarily + uniquely determined by these criteria. + 6. If k <= n <= 21, return the string consisting of the + k digits of the decimal representation of s (in order, + with no leading zeroes), followed by n-k occurences + of the character '0'. + 7. If 0 < n <= 21, return the string consisting of the + most significant n digits of the decimal + representation of s, followed by a decimal point + '.', followed by the remaining kn digits of the + decimal representation of s. + 8. If 6 < n <= 0, return the string consisting of the + character '0', followed by a decimal point '.', + followed by n occurences of the character '0', + followed by the k digits of the decimal + representation of s. + 9. Otherwise, if k = 1, return the string consisting + of the single digit of s, followed by lowercase + character 'e', followed by a plus sign '+' or minus + sign '' according to whether n1 is positive or + negative, followed by the decimal representation + of the integer abs(n1) (with no leading zeros). + 10. Return the string consisting of the most significant + digit of the decimal representation of s, followed + by a decimal point '.', followed by the remaining k1 + digits of the decimal representation of s, followed + by the lowercase character 'e', followed by a plus + sign '+' or minus sign '' according to whether n1 is + positive or negative, followed by the decimal + representation of the integer abs(n1) (with no + leading zeros). + + Note that if x is any number value other than 0, then + ToNumber(ToString(x)) is exactly the same number value as x. + + As noted, the least significant digit of s is not always + uniquely determined by the requirements listed in step 5. + The following specification for step 5 was considered, but + not adopted: + + Author: christine@netscape.com + Date: 10 july 1997 +*/ + +var SECTION = "9.8.1"; +var VERSION = "ECMA_1"; +startTest(); + +writeHeaderToLog( SECTION + " ToString applied to the Number type"); + +new TestCase( SECTION, "Number.NaN", "NaN", Number.NaN + "" ); +new TestCase( SECTION, "0", "0", 0 + "" ); +new TestCase( SECTION, "-0", "0", -0 + "" ); +new TestCase( SECTION, "Number.POSITIVE_INFINITY", "Infinity", Number.POSITIVE_INFINITY + "" ); +new TestCase( SECTION, "Number.NEGATIVE_INFINITY", "-Infinity", Number.NEGATIVE_INFINITY + "" ); +new TestCase( SECTION, "-1", "-1", -1 + "" ); + +// cases in step 6: integers 1e21 > x >= 1 or -1 >= x > -1e21 + +new TestCase( SECTION, "1", "1", 1 + "" ); +new TestCase( SECTION, "10", "10", 10 + "" ); +new TestCase( SECTION, "100", "100", 100 + "" ); +new TestCase( SECTION, "1000", "1000", 1000 + "" ); +new TestCase( SECTION, "10000", "10000", 10000 + "" ); +new TestCase( SECTION, "10000000000", "10000000000", 10000000000 + "" ); +new TestCase( SECTION, "10000000000000000000", "10000000000000000000", 10000000000000000000 + "" ); +new TestCase( SECTION, "100000000000000000000","100000000000000000000",100000000000000000000 + "" ); + +new TestCase( SECTION, "12345", "12345", 12345 + "" ); +new TestCase( SECTION, "1234567890", "1234567890", 1234567890 + "" ); + +new TestCase( SECTION, "-1", "-1", -1 + "" ); +new TestCase( SECTION, "-10", "-10", -10 + "" ); +new TestCase( SECTION, "-100", "-100", -100 + "" ); +new TestCase( SECTION, "-1000", "-1000", -1000 + "" ); +new TestCase( SECTION, "-1000000000", "-1000000000", -1000000000 + "" ); +new TestCase( SECTION, "-1000000000000000", "-1000000000000000", -1000000000000000 + "" ); +new TestCase( SECTION, "-100000000000000000000", "-100000000000000000000", -100000000000000000000 + "" ); +new TestCase( SECTION, "-1000000000000000000000", "-1e+21", -1000000000000000000000 + "" ); + +new TestCase( SECTION, "-12345", "-12345", -12345 + "" ); +new TestCase( SECTION, "-1234567890", "-1234567890", -1234567890 + "" ); + +// cases in step 7: numbers with a fractional component, 1e21> x >1 or -1 > x > -1e21, +new TestCase( SECTION, "1.0000001", "1.0000001", 1.0000001 + "" ); + +// cases in step 8: fractions between 1 > x > -1, exclusive of 0 and -0 + +// cases in step 9: numbers with 1 significant digit >= 1e+21 or <= 1e-6 + +new TestCase( SECTION, "1000000000000000000000", "1e+21", 1000000000000000000000 + "" ); +new TestCase( SECTION, "10000000000000000000000", "1e+22", 10000000000000000000000 + "" ); + +// cases in step 10: numbers with more than 1 significant digit >= 1e+21 or <= 1e-6 + +new TestCase( SECTION, "1.2345", "1.2345", String( 1.2345)); +new TestCase( SECTION, "1.234567890", "1.23456789", String( 1.234567890 )); + + +new TestCase( SECTION, ".12345", "0.12345", String(.12345 ) ); +new TestCase( SECTION, ".012345", "0.012345", String(.012345) ); +new TestCase( SECTION, ".0012345", "0.0012345", String(.0012345) ); +new TestCase( SECTION, ".00012345", "0.00012345", String(.00012345) ); +new TestCase( SECTION, ".000012345", "0.000012345", String(.000012345) ); +new TestCase( SECTION, ".0000012345", "0.0000012345", String(.0000012345) ); +new TestCase( SECTION, ".00000012345", "1.2345e-7", String(.00000012345)); + +new TestCase( SECTION, "-1e21", "-1e+21", String(-1e21) ); + +test(); + diff --git a/tests/auto/qml/parserstress/tests/ecma/TypeConversion/9.9-1.js b/tests/auto/qml/parserstress/tests/ecma/TypeConversion/9.9-1.js new file mode 100644 index 0000000000..ea22980767 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/TypeConversion/9.9-1.js @@ -0,0 +1,119 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '9.9-1.js'; + +/** + File Name: 9.9-1.js + ECMA Section: 9.9 Type Conversion: ToObject + Description: + + undefined generate a runtime error + null generate a runtime error + boolean create a new Boolean object whose default + value is the value of the boolean. + number Create a new Number object whose default + value is the value of the number. + string Create a new String object whose default + value is the value of the string. + object Return the input argument (no conversion). + Author: christine@netscape.com + Date: 17 july 1997 +*/ + +var VERSION = "ECMA_1"; +startTest(); +var SECTION = "9.9-1"; + +writeHeaderToLog( SECTION + " Type Conversion: ToObject" ); + +new TestCase( SECTION, "Object(true).valueOf()", true, (Object(true)).valueOf() ); +new TestCase( SECTION, "typeof Object(true)", "object", typeof Object(true) ); + +new TestCase( SECTION, "Object(false).valueOf()", false, (Object(false)).valueOf() ); +new TestCase( SECTION, "typeof Object(false)", "object", typeof Object(false) ); + +new TestCase( SECTION, "Object(0).valueOf()", 0, (Object(0)).valueOf() ); +new TestCase( SECTION, "typeof Object(0)", "object", typeof Object(0) ); + +new TestCase( SECTION, "Object(-0).valueOf()", -0, (Object(-0)).valueOf() ); +new TestCase( SECTION, "typeof Object(-0)", "object", typeof Object(-0) ); + +new TestCase( SECTION, "Object(1).valueOf()", 1, (Object(1)).valueOf() ); +new TestCase( SECTION, "typeof Object(1)", "object", typeof Object(1) ); + +new TestCase( SECTION, "Object(-1).valueOf()", -1, (Object(-1)).valueOf() ); +new TestCase( SECTION, "typeof Object(-1)", "object", typeof Object(-1) ); + +new TestCase( SECTION, "Object(Number.MAX_VALUE).valueOf()", 1.7976931348623157e308, (Object(Number.MAX_VALUE)).valueOf() ); +new TestCase( SECTION, "typeof Object(Number.MAX_VALUE)", "object", typeof Object(Number.MAX_VALUE) ); + +new TestCase( SECTION, "Object(Number.MIN_VALUE).valueOf()", 5e-324, (Object(Number.MIN_VALUE)).valueOf() ); +new TestCase( SECTION, "typeof Object(Number.MIN_VALUE)", "object", typeof Object(Number.MIN_VALUE) ); + +new TestCase( SECTION, "Object(Number.POSITIVE_INFINITY).valueOf()", Number.POSITIVE_INFINITY, (Object(Number.POSITIVE_INFINITY)).valueOf() ); +new TestCase( SECTION, "typeof Object(Number.POSITIVE_INFINITY)", "object", typeof Object(Number.POSITIVE_INFINITY) ); + +new TestCase( SECTION, "Object(Number.NEGATIVE_INFINITY).valueOf()", Number.NEGATIVE_INFINITY, (Object(Number.NEGATIVE_INFINITY)).valueOf() ); +new TestCase( SECTION, "typeof Object(Number.NEGATIVE_INFINITY)", "object", typeof Object(Number.NEGATIVE_INFINITY) ); + +new TestCase( SECTION, "Object(Number.NaN).valueOf()", Number.NaN, (Object(Number.NaN)).valueOf() ); +new TestCase( SECTION, "typeof Object(Number.NaN)", "object", typeof Object(Number.NaN) ); + +new TestCase( SECTION, "Object('a string').valueOf()", "a string", (Object("a string")).valueOf() ); +new TestCase( SECTION, "typeof Object('a string')", "object", typeof (Object("a string")) ); + +new TestCase( SECTION, "Object('').valueOf()", "", (Object("")).valueOf() ); +new TestCase( SECTION, "typeof Object('')", "object", typeof (Object("")) ); + +new TestCase( SECTION, "Object('\\r\\t\\b\\n\\v\\f').valueOf()", "\r\t\b\n\v\f", (Object("\r\t\b\n\v\f")).valueOf() ); +new TestCase( SECTION, "typeof Object('\\r\\t\\b\\n\\v\\f')", "object", typeof (Object("\\r\\t\\b\\n\\v\\f")) ); + +new TestCase( SECTION, "Object( '\\\'\\\"\\' ).valueOf()", "\'\"\\", (Object("\'\"\\")).valueOf() ); +new TestCase( SECTION, "typeof Object( '\\\'\\\"\\' )", "object", typeof Object("\'\"\\") ); + +new TestCase( SECTION, "Object( new MyObject(true) ).valueOf()", true, eval("Object( new MyObject(true) ).valueOf()") ); +new TestCase( SECTION, "typeof Object( new MyObject(true) )", "object", eval("typeof Object( new MyObject(true) )") ); +new TestCase( SECTION, "(Object( new MyObject(true) )).toString()", "[object Object]", eval("(Object( new MyObject(true) )).toString()") ); + +test(); + +function MyObject( value ) { + this.value = value; + this.valueOf = new Function ( "return this.value" ); +} diff --git a/tests/auto/qml/parserstress/tests/ecma/TypeConversion/browser.js b/tests/auto/qml/parserstress/tests/ecma/TypeConversion/browser.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/auto/qml/parserstress/tests/ecma/TypeConversion/shell.js b/tests/auto/qml/parserstress/tests/ecma/TypeConversion/shell.js new file mode 100644 index 0000000000..49ce60f627 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/TypeConversion/shell.js @@ -0,0 +1 @@ +gTestsubsuite = 'TypeConversion'; diff --git a/tests/auto/qml/parserstress/tests/ecma/Types/8.1.js b/tests/auto/qml/parserstress/tests/ecma/Types/8.1.js new file mode 100644 index 0000000000..7abcb93c02 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Types/8.1.js @@ -0,0 +1,75 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '8.1.js'; + +/** + File Name: 8.1.js + ECMA Section: The undefined type + Description: + + The Undefined type has exactly one value, called undefined. Any variable + that has not been assigned a value is of type Undefined. + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + +var SECTION = "8.1"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "The undefined type"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +new TestCase( SECTION, + "var x; typeof x", + "undefined", + eval("var x; typeof x") ); + +new TestCase( SECTION, + "var x; typeof x == 'undefined", + true, + eval("var x; typeof x == 'undefined'") ); + +new TestCase( SECTION, + "var x; x == void 0", + true, + eval("var x; x == void 0") ); +test(); + diff --git a/tests/auto/qml/parserstress/tests/ecma/Types/8.4.js b/tests/auto/qml/parserstress/tests/ecma/Types/8.4.js new file mode 100644 index 0000000000..7d3465f8b2 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Types/8.4.js @@ -0,0 +1,130 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '8.4.js'; + +/** + File Name: 8.4.js + ECMA Section: The String type + Description: + + The String type is the set of all finite ordered sequences of zero or more + Unicode characters. Each character is regarded as occupying a position + within the sequence. These positions are identified by nonnegative + integers. The leftmost character (if any) is at position 0, the next + character (if any) at position 1, and so on. The length of a string is the + number of distinct positions within it. The empty string has length zero + and therefore contains no characters. + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + +var SECTION = "8.4"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "The String type"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +new TestCase( SECTION, + "var s = ''; s.length", + 0, + eval("var s = ''; s.length") ); + +new TestCase( SECTION, + "var s = ''; s.charAt(0)", + "", + eval("var s = ''; s.charAt(0)") ); + + +for ( var i = 0x0041, TEST_STRING = "", EXPECT_STRING = ""; i < 0x007B; i++ ) { + TEST_STRING += ("\\u"+ DecimalToHexString( i ) ); + EXPECT_STRING += String.fromCharCode(i); +} + +new TestCase( SECTION, + "var s = '" + TEST_STRING+ "'; s", + EXPECT_STRING, + eval("var s = '" + TEST_STRING+ "'; s") ); + +new TestCase( SECTION, + "var s = '" + TEST_STRING+ "'; s.length", + 0x007B-0x0041, + eval("var s = '" + TEST_STRING+ "'; s.length") ); + +test(); + +function DecimalToHexString( n ) { + n = Number( n ); + var h = ""; + + for ( var i = 3; i >= 0; i-- ) { + if ( n >= Math.pow(16, i) ){ + var t = Math.floor( n / Math.pow(16, i)); + n -= t * Math.pow(16, i); + if ( t >= 10 ) { + if ( t == 10 ) { + h += "A"; + } + if ( t == 11 ) { + h += "B"; + } + if ( t == 12 ) { + h += "C"; + } + if ( t == 13 ) { + h += "D"; + } + if ( t == 14 ) { + h += "E"; + } + if ( t == 15 ) { + h += "F"; + } + } else { + h += String( t ); + } + } else { + h += "0"; + } + } + + return h; +} + diff --git a/tests/auto/qml/parserstress/tests/ecma/Types/8.6.2.1-1.js b/tests/auto/qml/parserstress/tests/ecma/Types/8.6.2.1-1.js new file mode 100644 index 0000000000..c06999c42c --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Types/8.6.2.1-1.js @@ -0,0 +1,78 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '8.6.2.1-1.js'; + +/** + File Name: 8.6.2.1-1.js + ECMA Section: 8.6.2.1 Get (Value) + Description: + + When the [[Get]] method of O is called with property name P, the following + steps are taken: + + 1. If O doesn't have a property with name P, go to step 4. + 2. Get the value of the property. + 3. Return Result(2). + 4. If the [[Prototype]] of O is null, return undefined. + 5. Call the [[Get]] method of [[Prototype]] with property name P. + 6. Return Result(5). + + This tests [[Get]] (Value). + + Author: christine@netscape.com + Date: 12 november 1997 +*/ +var SECTION = "8.6.2.1-1"; +var VERSION = "ECMA_1"; +startTest(); + +writeHeaderToLog( SECTION + " [[Get]] (Value)"); + +new TestCase( SECTION, "var OBJ = new MyObject(true); OBJ.valueOf()", true, eval("var OBJ = new MyObject(true); OBJ.valueOf()") ); + +new TestCase( SECTION, "var OBJ = new MyObject(Number.POSITIVE_INFINITY); OBJ.valueOf()", Number.POSITIVE_INFINITY, eval("var OBJ = new MyObject(Number.POSITIVE_INFINITY); OBJ.valueOf()") ); + +new TestCase( SECTION, "var OBJ = new MyObject('string'); OBJ.valueOf()", 'string', eval("var OBJ = new MyObject('string'); OBJ.valueOf()") ); + +test(); + +function MyObject( value ) { + this.valueOf = new Function( "return this.value" ); + this.value = value; +} diff --git a/tests/auto/qml/parserstress/tests/ecma/Types/browser.js b/tests/auto/qml/parserstress/tests/ecma/Types/browser.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/auto/qml/parserstress/tests/ecma/Types/shell.js b/tests/auto/qml/parserstress/tests/ecma/Types/shell.js new file mode 100644 index 0000000000..a16b996e00 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/Types/shell.js @@ -0,0 +1 @@ +gTestsubsuite = 'Types'; diff --git a/tests/auto/qml/parserstress/tests/ecma/browser.js b/tests/auto/qml/parserstress/tests/ecma/browser.js new file mode 100644 index 0000000000..60e48ceed8 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/browser.js @@ -0,0 +1,62 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is mozilla.org code. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +/* + * JavaScript test library shared functions file for running the tests + * in the browser. Overrides the shell's print function with document.write + * and make everything HTML pretty. + * + * To run the tests in the browser, use the mkhtml.pl script to generate + * html pages that include the shell.js, browser.js (this file), and the + * test js file in script tags. + * + * The source of the page that is generated should look something like this: + * + * + * + */ + +/* + * The earlier versions of the test code used exceptions + * to terminate the test script in "negative" test cases + * before the failure reporting code could run. In order + * to be able to capture errors for the "negative" case + * where the exception is a sign the test actually passed, + * the err online handler will assume that any error is a + * failure unless gExceptionExpected is true. + */ + diff --git a/tests/auto/qml/parserstress/tests/ecma/extensions/10.1.4-9.js b/tests/auto/qml/parserstress/tests/ecma/extensions/10.1.4-9.js new file mode 100644 index 0000000000..91982de20c --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/extensions/10.1.4-9.js @@ -0,0 +1,110 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '10.1.4-9.js'; + +/** + File Name: 10.1.4-9.js + ECMA Section: 10.1.4 Scope Chain and Identifier Resolution + Description: + Every execution context has associated with it a scope chain. This is + logically a list of objects that are searched when binding an Identifier. + When control enters an execution context, the scope chain is created and + is populated with an initial set of objects, depending on the type of + code. When control leaves the execution context, the scope chain is + destroyed. + + During execution, the scope chain of the execution context is affected + only by WithStatement. When execution enters a with block, the object + specified in the with statement is added to the front of the scope chain. + When execution leaves a with block, whether normally or via a break or + continue statement, the object is removed from the scope chain. The object + being removed will always be the first object in the scope chain. + + During execution, the syntactic production PrimaryExpression : Identifier + is evaluated using the following algorithm: + + 1. Get the next object in the scope chain. If there isn't one, go to step 5. + 2. Call the [[HasProperty]] method of Result(l), passing the Identifier as + the property. + 3. If Result(2) is true, return a value of type Reference whose base object + is Result(l) and whose property name is the Identifier. + 4. Go to step 1. + 5. Return a value of type Reference whose base object is null and whose + property name is the Identifier. + The result of binding an identifier is always a value of type Reference with + its member name component equal to the identifier string. + Author: christine@netscape.com + Date: 12 november 1997 +*/ +var SECTION = "10.1.4-9"; +var VERSION = "ECMA_2"; +startTest(); + +writeHeaderToLog( SECTION + " Scope Chain and Identifier Resolution"); + +new TestCase( SECTION, "NEW_PROPERTY = " ); + +test(); + +function test() { + for ( gTc=0; gTc < gTestcases.length; gTc++ ) { + + var MYOBJECT = new MyObject(); + var RESULT = "hello"; + + with ( MYOBJECT ) { + NEW_PROPERTY = RESULT; + } + gTestcases[gTc].actual = NEW_PROPERTY; + gTestcases[gTc].expect = RESULT; + + gTestcases[gTc].passed = writeTestCaseResult( + gTestcases[gTc].expect, + gTestcases[gTc].actual, + gTestcases[gTc].description +" = "+ + gTestcases[gTc].actual ); + + gTestcases[gTc].reason += ( gTestcases[gTc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( gTestcases ); +} +function MyObject( n ) { + this.__proto__ = Number.prototype; +} diff --git a/tests/auto/qml/parserstress/tests/ecma/extensions/10.1.6.js b/tests/auto/qml/parserstress/tests/ecma/extensions/10.1.6.js new file mode 100644 index 0000000000..99fd4a7ff1 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/extensions/10.1.6.js @@ -0,0 +1,127 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '10.1.6.js'; + +/** + File Name: 10.1.6 + ECMA Section: Activation Object + Description: + + If the function object being invoked has an arguments property, let x be + the value of that property; the activation object is also given an internal + property [[OldArguments]] whose initial value is x; otherwise, an arguments + property is created for the function object but the activation object is + not given an [[OldArguments]] property. Next, arguments object described + below (the same one stored in the arguments property of the activation + object) is used as the new value of the arguments property of the function + object. This new value is installed even if the arguments property already + exists and has the ReadOnly attribute (as it will for native Function + objects). (These actions are taken to provide compatibility with a form of + program syntax that is now discouraged: to access the arguments object for + function f within the body of f by using the expression f.arguments. + The recommended way to access the arguments object for function f within + the body of f is simply to refer to the variable arguments.) + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + +var SECTION = "10.1.6"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Activation Object"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +var arguments = "FAILED!"; + +var ARG_STRING = "value of the argument property"; + +new TestCase( SECTION, + "(new TestObject(0,1,2,3,4,5)).length", + 6, + (new TestObject(0,1,2,3,4,5)).length ); + +for ( i = 0; i < 6; i++ ) { + + new TestCase( SECTION, + "(new TestObject(0,1,2,3,4,5))["+i+"]", + i, + (new TestObject(0,1,2,3,4,5))[i]); +} + + +// The current object already has an arguments property. + +new TestCase( SECTION, + "(new AnotherTestObject(1,2,3)).arguments", + ARG_STRING, + (new AnotherTestObject(1,2,3)).arguments ); + +// The function invoked with [[Call]] + +new TestCase( SECTION, + "TestFunction(1,2,3)", + ARG_STRING, + TestFunction() + '' ); + + +test(); + + + +function Prototype() { + this.arguments = ARG_STRING; +} +function TestObject() { + this.__proto__ = new Prototype(); + return arguments; +} +function AnotherTestObject() { + this.__proto__ = new Prototype(); + return this; +} +function TestFunction() { + arguments = ARG_STRING; + return arguments; +} +function AnotherTestFunction() { + this.__proto__ = new Prototype(); + return this; +} diff --git a/tests/auto/qml/parserstress/tests/ecma/extensions/10.1.8-1.js b/tests/auto/qml/parserstress/tests/ecma/extensions/10.1.8-1.js new file mode 100644 index 0000000000..adfc8d5df5 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/extensions/10.1.8-1.js @@ -0,0 +1,135 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '10.1.8-1.js'; + +/** + File Name: 10.1.8 + ECMA Section: Arguments Object + Description: + + When control enters an execution context for declared function code, + anonymous code, or implementation-supplied code, an arguments object is + created and initialized as follows: + + The [[Prototype]] of the arguments object is to the original Object + prototype object, the one that is the initial value of Object.prototype + (section 15.2.3.1). + + A property is created with name callee and property attributes {DontEnum}. + The initial value of this property is the function object being executed. + This allows anonymous functions to be recursive. + + A property is created with name length and property attributes {DontEnum}. + The initial value of this property is the number of actual parameter values + supplied by the caller. + + For each non-negative integer, iarg, less than the value of the length + property, a property is created with name ToString(iarg) and property + attributes { DontEnum }. The initial value of this property is the value + of the corresponding actual parameter supplied by the caller. The first + actual parameter value corresponds to iarg = 0, the second to iarg = 1 and + so on. In the case when iarg is less than the number of formal parameters + for the function object, this property shares its value with the + corresponding property of the activation object. This means that changing + this property changes the corresponding property of the activation object + and vice versa. The value sharing mechanism depends on the implementation. + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + +var SECTION = "10.1.8"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Arguments Object"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +var ARG_STRING = "value of the argument property"; + +new TestCase( SECTION, + "GetCallee()", + GetCallee, + GetCallee() ); + +var LIMIT = 100; + +for ( var i = 0, args = "" ; i < LIMIT; i++ ) { + args += String(i) + ( i+1 < LIMIT ? "," : "" ); + +} + +var LENGTH = eval( "GetLength("+ args +")" ); + +new TestCase( SECTION, + "GetLength("+args+")", + 100, + LENGTH ); + +var ARGUMENTS = eval( "GetArguments( " +args+")" ); + +for ( var i = 0; i < 100; i++ ) { + new TestCase( SECTION, + "GetArguments("+args+")["+i+"]", + i, + ARGUMENTS[i] ); +} + +test(); + +function TestFunction() { + var arg_proto = arguments.__proto__; +} +function GetCallee() { + var c = arguments.callee; + return c; +} +function GetArguments() { + var a = arguments; + return a; +} +function GetLength() { + var l = arguments.length; + return l; +} + +function AnotherTestFunction() { + this.__proto__ = new Prototype(); + return this; +} diff --git a/tests/auto/qml/parserstress/tests/ecma/extensions/11.6.1-1.js b/tests/auto/qml/parserstress/tests/ecma/extensions/11.6.1-1.js new file mode 100644 index 0000000000..e467157441 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/extensions/11.6.1-1.js @@ -0,0 +1,145 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '11.6.1-1.js'; + +/** + File Name: 11.6.1-1.js + ECMA Section: 11.6.1 The addition operator ( + ) + Description: + + The addition operator either performs string concatenation or numeric + addition. + + The production AdditiveExpression : AdditiveExpression + MultiplicativeExpression + is evaluated as follows: + + 1. Evaluate AdditiveExpression. + 2. Call GetValue(Result(1)). + 3. Evaluate MultiplicativeExpression. + 4. Call GetValue(Result(3)). + 5. Call ToPrimitive(Result(2)). + 6. Call ToPrimitive(Result(4)). + 7. If Type(Result(5)) is String or Type(Result(6)) is String, go to step 12. + (Note that this step differs from step 3 in the algorithm for comparison + for the relational operators in using or instead of and.) + 8. Call ToNumber(Result(5)). + 9. Call ToNumber(Result(6)). + 10. Apply the addition operation to Result(8) and Result(9). See the discussion below (11.6.3). + 11. Return Result(10). + 12. Call ToString(Result(5)). + 13. Call ToString(Result(6)). + 14. Concatenate Result(12) followed by Result(13). + 15. Return Result(14). + + Note that no hint is provided in the calls to ToPrimitive in steps 5 and 6. + All native ECMAScript objects except Date objects handle the absence of a + hint as if the hint Number were given; Date objects handle the absence of a + hint as if the hint String were given. Host objects may handle the absence + of a hint in some other manner. + + This test does not cover cases where the Additive or Mulplicative expression + ToPrimitive is string. + + Author: christine@netscape.com + Date: 12 november 1997 +*/ +var SECTION = "11.6.1-1"; +var VERSION = "ECMA_1"; +startTest(); + +writeHeaderToLog( SECTION + " The Addition operator ( + )"); + +// tests for "MyValuelessObject", where the value is +// set in the object's prototype, not the object itself. + +new TestCase( SECTION, + "var EXP_1 = new MyValuelessObject(true); var EXP_2 = new MyValuelessObject(false); EXP_1 + EXP_2", + 1, + eval("var EXP_1 = new MyValuelessObject(true); var EXP_2 = new MyValuelessObject(false); EXP_1 + EXP_2") ); + +new TestCase( SECTION, + "var EXP_1 = new MyValuelessObject(new Boolean(true)); var EXP_2 = new MyValuelessObject(new Boolean(false)); EXP_1 + EXP_2", + "truefalse", + eval("var EXP_1 = new MyValuelessObject(new Boolean(true)); var EXP_2 = new MyValuelessObject(new Boolean(false)); EXP_1 + EXP_2") ); + +// tests for "MyValuelessObject", where the value is +// set in the object's prototype, not the object itself. + + +new TestCase( SECTION, + "var EXP_1 = new MyValuelessObject(100); var EXP_2 = new MyValuelessObject(-1); EXP_1 + EXP_2", + 99, + eval("var EXP_1 = new MyValuelessObject(100); var EXP_2 = new MyValuelessObject(-1); EXP_1 + EXP_2") ); + +new TestCase( SECTION, + "var EXP_1 = new MyValuelessObject(new Number(100)); var EXP_2 = new MyValuelessObject(new Number(-1)); EXP_1 + EXP_2", + "100-1", + eval("var EXP_1 = new MyValuelessObject(new Number(100)); var EXP_2 = new MyValuelessObject(new Number(-1)); EXP_1 + EXP_2") ); + +new TestCase( SECTION, + "var EXP_1 = new MyValuelessObject( new MyValuelessObject( new Boolean(true) ) ); EXP_1 + EXP_1", + "truetrue", + eval("var EXP_1 = new MyValuelessObject( new MyValuelessObject( new Boolean(true) ) ); EXP_1 + EXP_1") ); + +test(); + +function MyProtoValuelessObject() { + this.valueOf = new Function ( "" ); + this.__proto__ = null; +} + +function MyProtolessObject( value ) { + this.valueOf = new Function( "return this.value" ); + this.__proto__ = null; + this.value = value; +} + +function MyValuelessObject(value) { + this.__proto__ = new MyPrototypeObject(value); +} +function MyPrototypeObject(value) { + this.valueOf = new Function( "return this.value;" ); + this.toString = new Function( "return (this.value + '');" ); + this.value = value; +} + +function MyObject( value ) { + this.valueOf = new Function( "return this.value" ); + this.value = value; +} diff --git a/tests/auto/qml/parserstress/tests/ecma/extensions/11.6.1-2.js b/tests/auto/qml/parserstress/tests/ecma/extensions/11.6.1-2.js new file mode 100644 index 0000000000..a486885b7f --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/extensions/11.6.1-2.js @@ -0,0 +1,136 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '11.6.1-2.js'; + +/** + File Name: 11.6.1-2.js + ECMA Section: 11.6.1 The addition operator ( + ) + Description: + + The addition operator either performs string concatenation or numeric + addition. + + The production AdditiveExpression : AdditiveExpression + MultiplicativeExpression + is evaluated as follows: + + 1. Evaluate AdditiveExpression. + 2. Call GetValue(Result(1)). + 3. Evaluate MultiplicativeExpression. + 4. Call GetValue(Result(3)). + 5. Call ToPrimitive(Result(2)). + 6. Call ToPrimitive(Result(4)). + 7. If Type(Result(5)) is String or Type(Result(6)) is String, go to step 12. + (Note that this step differs from step 3 in the algorithm for comparison + for the relational operators in using or instead of and.) + 8. Call ToNumber(Result(5)). + 9. Call ToNumber(Result(6)). + 10. Apply the addition operation to Result(8) and Result(9). See the discussion below (11.6.3). + 11. Return Result(10). + 12. Call ToString(Result(5)). + 13. Call ToString(Result(6)). + 14. Concatenate Result(12) followed by Result(13). + 15. Return Result(14). + + Note that no hint is provided in the calls to ToPrimitive in steps 5 and 6. + All native ECMAScript objects except Date objects handle the absence of a + hint as if the hint Number were given; Date objects handle the absence of a + hint as if the hint String were given. Host objects may handle the absence + of a hint in some other manner. + + This test does only covers cases where the Additive or Mulplicative expression + ToPrimitive is a string. + + Author: christine@netscape.com + Date: 12 november 1997 +*/ +var SECTION = "11.6.1-2"; +var VERSION = "ECMA_1"; +startTest(); + +writeHeaderToLog( SECTION + " The Addition operator ( + )"); + +// tests for "MyValuelessObject", where the value is +// set in the object's prototype, not the object itself. + +new TestCase( SECTION, + "var EXP_1 = new MyValuelessObject('string'); var EXP_2 = new MyValuelessObject(false); EXP_1 + EXP_2", + "stringfalse", + eval("var EXP_1 = new MyValuelessObject('string'); var EXP_2 = new MyValuelessObject(false); EXP_1 + EXP_2") ); + +new TestCase( SECTION, + "var EXP_1 = new MyValuelessObject(new String('string')); var EXP_2 = new MyValuelessObject(new Boolean(false)); EXP_1 + EXP_2", + "stringfalse", + eval("var EXP_1 = new MyValuelessObject(new String('string')); var EXP_2 = new MyValuelessObject(new Boolean(false)); EXP_1 + EXP_2") ); + +// tests for "MyValuelessObject", where the value is +// set in the object's prototype, not the object itself. + +new TestCase( SECTION, + "var EXP_1 = new MyValuelessObject(100); var EXP_2 = new MyValuelessObject('string'); EXP_1 + EXP_2", + "100string", + eval("var EXP_1 = new MyValuelessObject(100); var EXP_2 = new MyValuelessObject('string'); EXP_1 + EXP_2") ); + +new TestCase( SECTION, + "var EXP_1 = new MyValuelessObject(new String('string')); var EXP_2 = new MyValuelessObject(new Number(-1)); EXP_1 + EXP_2", + "string-1", + eval("var EXP_1 = new MyValuelessObject(new String('string')); var EXP_2 = new MyValuelessObject(new Number(-1)); EXP_1 + EXP_2") ); + +test(); + +function MyProtoValuelessObject() { + this.valueOf = new Function ( "" ); + this.__proto__ = null; +} +function MyProtolessObject( value ) { + this.valueOf = new Function( "return this.value" ); + this.__proto__ = null; + this.value = value; +} +function MyValuelessObject(value) { + this.__proto__ = new MyPrototypeObject(value); +} +function MyPrototypeObject(value) { + this.valueOf = new Function( "return this.value;" ); + this.toString = new Function( "return (this.value + '');" ); + this.value = value; +} +function MyObject( value ) { + this.valueOf = new Function( "return this.value" ); + this.value = value; +} diff --git a/tests/auto/qml/parserstress/tests/ecma/extensions/11.6.1-3.js b/tests/auto/qml/parserstress/tests/ecma/extensions/11.6.1-3.js new file mode 100644 index 0000000000..7d66e58530 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/extensions/11.6.1-3.js @@ -0,0 +1,137 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '11.6.1-3.js'; + +/** + File Name: 11.6.1-3.js + ECMA Section: 11.6.1 The addition operator ( + ) + Description: + + The addition operator either performs string concatenation or numeric + addition. + + The production AdditiveExpression : AdditiveExpression + MultiplicativeExpression + is evaluated as follows: + + 1. Evaluate AdditiveExpression. + 2. Call GetValue(Result(1)). + 3. Evaluate MultiplicativeExpression. + 4. Call GetValue(Result(3)). + 5. Call ToPrimitive(Result(2)). + 6. Call ToPrimitive(Result(4)). + 7. If Type(Result(5)) is String or Type(Result(6)) is String, go to step 12. + (Note that this step differs from step 3 in the algorithm for comparison + for the relational operators in using or instead of and.) + 8. Call ToNumber(Result(5)). + 9. Call ToNumber(Result(6)). + 10. Apply the addition operation to Result(8) and Result(9). See the discussion below (11.6.3). + 11. Return Result(10). + 12. Call ToString(Result(5)). + 13. Call ToString(Result(6)). + 14. Concatenate Result(12) followed by Result(13). + 15. Return Result(14). + + Note that no hint is provided in the calls to ToPrimitive in steps 5 and 6. + All native ECMAScript objects except Date objects handle the absence of a + hint as if the hint Number were given; Date objects handle the absence of a + hint as if the hint String were given. Host objects may handle the absence + of a hint in some other manner. + + This test does only covers cases where the Additive or Mulplicative expression + is a Date. + + Author: christine@netscape.com + Date: 12 november 1997 +*/ +var SECTION = "11.6.1-3"; +var VERSION = "ECMA_1"; +startTest(); + +writeHeaderToLog( SECTION + " The Addition operator ( + )"); + +// tests for a boolean primitive and a boolean object, and +// "MyValuelessObject", where the value is set in the object's +// prototype, not the object itself. + +var DATE1 = new Date(); + +var MYOB1 = new MyObject( DATE1 ); +var MYOB2 = new MyValuelessObject( DATE1 ); +var MYOB3 = new MyProtolessObject( DATE1 ); +var MYOB4 = new MyProtoValuelessObject( DATE1 ); + +new TestCase( SECTION, + "MYOB2 = new MyValuelessObject(DATE1); MYOB3 + 'string'", + DATE1.toString() + "string", + MYOB2 + 'string' ); + +new TestCase( SECTION, + "MYOB2 = new MyValuelessObject(DATE1); MYOB3 + new String('string')", + DATE1.toString() + "string", + MYOB2 + new String('string') ); +/* + new TestCase( SECTION, + "MYOB3 = new MyProtolessObject(DATE1); MYOB3 + new Boolean(true)", + DATE1.toString() + "true", + MYOB3 + new Boolean(true) ); +*/ + +test(); + +function MyProtoValuelessObject() { + this.valueOf = new Function ( "" ); + this.__proto__ = null; +} +function MyProtolessObject( value ) { + this.valueOf = new Function( "return this.value" ); + this.__proto__ = null; + this.value = value; +} +function MyValuelessObject(value) { + this.__proto__ = new MyPrototypeObject(value); +} +function MyPrototypeObject(value) { + this.valueOf = new Function( "return this.value;" ); + this.toString = new Function( "return (this.value + '');" ); + this.value = value; +} +function MyObject( value ) { + this.valueOf = new Function( "return this.value" ); + this.value = value; +} diff --git a/tests/auto/qml/parserstress/tests/ecma/extensions/11.6.2-1.js b/tests/auto/qml/parserstress/tests/ecma/extensions/11.6.2-1.js new file mode 100644 index 0000000000..be8a6f6c98 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/extensions/11.6.2-1.js @@ -0,0 +1,124 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '11.6.2-1.js'; + +/** + File Name: 11.6.2-1.js + ECMA Section: 11.6.2 The Subtraction operator ( - ) + Description: + + The production AdditiveExpression : AdditiveExpression - + MultiplicativeExpression is evaluated as follows: + + 1. Evaluate AdditiveExpression. + 2. Call GetValue(Result(1)). + 3. Evaluate MultiplicativeExpression. + 4. Call GetValue(Result(3)). + 5. Call ToNumber(Result(2)). + 6. Call ToNumber(Result(4)). + 7. Apply the subtraction operation to Result(5) and Result(6). See the + discussion below (11.6.3). + 8. Return Result(7). + + Author: christine@netscape.com + Date: 12 november 1997 +*/ +var SECTION = "11.6.2-1"; +var VERSION = "ECMA_1"; +startTest(); + +writeHeaderToLog( SECTION + " The subtraction operator ( - )"); + +// tests "MyValuelessObject", where the value is +// set in the object's prototype, not the object itself. + + +new TestCase( SECTION, + "var EXP_1 = new MyValuelessObject(true); var EXP_2 = new MyValuelessObject(false); EXP_1 - EXP_2", + 1, + eval("var EXP_1 = new MyValuelessObject(true); var EXP_2 = new MyValuelessObject(false); EXP_1 - EXP_2") ); + +new TestCase( SECTION, + "var EXP_1 = new MyValuelessObject(new Boolean(true)); var EXP_2 = new MyValuelessObject(new Boolean(false)); EXP_1 - EXP_2", + Number.NaN, + eval("var EXP_1 = new MyValuelessObject(new Boolean(true)); var EXP_2 = new MyValuelessObject(new Boolean(false)); EXP_1 - EXP_2") ); + +// tests "MyValuelessObject", where the value is +// set in the object's prototype, not the object itself. + +new TestCase( SECTION, + "var EXP_1 = new MyValuelessObject(100); var EXP_2 = new MyValuelessObject(1); EXP_1 - EXP_2", + 99, + eval("var EXP_1 = new MyValuelessObject(100); var EXP_2 = new MyValuelessObject(1); EXP_1 - EXP_2") ); +/* + new TestCase( SECTION, + "var EXP_1 = new MyValuelessObject(new Number(100)); var EXP_2 = new MyValuelessObject(new Number(1)); EXP_1 - EXP_2", + Number.NaN, + eval("var EXP_1 = new MyValuelessObject(new Number(100)); var EXP_2 = new MyValuelessObject(new Number(1)); EXP_1 - EXP_2") ); +*/ +// same thing with string! + +test(); + +function MyProtoValuelessObject() { + this.valueOf = new Function ( "" ); + this.__proto__ = null; +} +function MyProtolessObject( value ) { + this.valueOf = new Function( "return this.value" ); + this.__proto__ = null; + this.value = value; +} +function MyValuelessObject(value) { + this.__proto__ = new MyPrototypeObject(value); +} +function MyPrototypeObject(value) { + this.valueOf = new Function( "return this.value;" ); + this.toString = new Function( "return (this.value + '');" ); + this.value = value; +} +function MyObject( value ) { + this.valueOf = new Function( "return this.value" ); + this.value = value; +} +function MyOtherObject( value ) { + this.valueOf = new Function( "return this.value" ); + this.toString = new Function ( "return this.value + ''" ); + this.value = value; +} diff --git a/tests/auto/qml/parserstress/tests/ecma/extensions/15-1.js b/tests/auto/qml/parserstress/tests/ecma/extensions/15-1.js new file mode 100644 index 0000000000..fc037873a5 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/extensions/15-1.js @@ -0,0 +1,94 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15-1.js'; + +/** + File Name: 15.js + ECMA Section: 15 Native ECMAScript Objects + Description: Every built-in prototype object has the Object prototype + object, which is the value of the expression + Object.prototype (15.2.3.1) as the value of its internal + [[Prototype]] property, except the Object prototype + object itself. + + Every native object associated with a program-created + function also has the Object prototype object as the + value of its internal [[Prototype]] property. + + Author: christine@netscape.com + Date: 28 october 1997 + +*/ +var SECTION = "15-1"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Native ECMAScript Objects"; + +writeHeaderToLog( SECTION + " "+ TITLE); +/* + new TestCase( SECTION, "Function.prototype.__proto__", Object.prototype, Function.prototype.__proto__ ); + new TestCase( SECTION, "Array.prototype.__proto__", Object.prototype, Array.prototype.__proto__ ); + new TestCase( SECTION, "String.prototype.__proto__", Object.prototype, String.prototype.__proto__ ); + new TestCase( SECTION, "Boolean.prototype.__proto__", Object.prototype, Boolean.prototype.__proto__ ); + new TestCase( SECTION, "Number.prototype.__proto__", Object.prototype, Number.prototype.__proto__ ); +// new TestCase( SECTION, "Math.prototype.__proto__", Object.prototype, Math.prototype.__proto__ ); +new TestCase( SECTION, "Date.prototype.__proto__", Object.prototype, Date.prototype.__proto__ ); +new TestCase( SECTION, "TestCase.prototype.__proto__", Object.prototype, TestCase.prototype.__proto__ ); + +new TestCase( SECTION, "MyObject.prototype.__proto__", Object.prototype, MyObject.prototype.__proto__ ); +*/ +new TestCase( SECTION, "Function.prototype.__proto__ == Object.prototype", true, Function.prototype.__proto__ == Object.prototype ); +new TestCase( SECTION, "Array.prototype.__proto__ == Object.prototype", true, Array.prototype.__proto__ == Object.prototype ); +new TestCase( SECTION, "String.prototype.__proto__ == Object.prototype", true, String.prototype.__proto__ == Object.prototype ); +new TestCase( SECTION, "Boolean.prototype.__proto__ == Object.prototype", true, Boolean.prototype.__proto__ == Object.prototype ); +new TestCase( SECTION, "Number.prototype.__proto__ == Object.prototype", true, Number.prototype.__proto__ == Object.prototype ); +// new TestCase( SECTION, "Math.prototype.__proto__ == Object.prototype", true, Math.prototype.__proto__ == Object.prototype ); +new TestCase( SECTION, "Date.prototype.__proto__ == Object.prototype", true, Date.prototype.__proto__ == Object.prototype ); +new TestCase( SECTION, "TestCase.prototype.__proto__ == Object.prototype", true, TestCase.prototype.__proto__ == Object.prototype ); + +new TestCase( SECTION, "MyObject.prototype.__proto__ == Object.prototype", true, MyObject.prototype.__proto__ == Object.prototype ); + + +test(); + + +function MyObject( value ) { + this.value = value; + this.valueOf = new Function( "return this.value" ); +} diff --git a/tests/auto/qml/parserstress/tests/ecma/extensions/15-2.js b/tests/auto/qml/parserstress/tests/ecma/extensions/15-2.js new file mode 100644 index 0000000000..e403e46e8e --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/extensions/15-2.js @@ -0,0 +1,77 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15-2.js'; + +/** + File Name: 15-2.js + ECMA Section: 15 Native ECMAScript Objects + + Description: Every built-in function and every built-in constructor + has the Function prototype object, which is the value of + the expression Function.prototype as the value of its + internal [[Prototype]] property, except the Function + prototype object itself. + + That is, the __proto__ property of builtin functions and + constructors should be the Function.prototype object. + + Author: christine@netscape.com + Date: 28 october 1997 + +*/ +var SECTION = "15-2"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Native ECMAScript Objects"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +new TestCase( SECTION, "Object.__proto__", Function.prototype, Object.__proto__ ); +new TestCase( SECTION, "Array.__proto__", Function.prototype, Array.__proto__ ); +new TestCase( SECTION, "String.__proto__", Function.prototype, String.__proto__ ); +new TestCase( SECTION, "Boolean.__proto__", Function.prototype, Boolean.__proto__ ); +new TestCase( SECTION, "Number.__proto__", Function.prototype, Number.__proto__ ); +new TestCase( SECTION, "Date.__proto__", Function.prototype, Date.__proto__ ); +new TestCase( SECTION, "TestCase.__proto__", Function.prototype, TestCase.__proto__ ); + +new TestCase( SECTION, "eval.__proto__", Function.prototype, eval.__proto__ ); +new TestCase( SECTION, "Math.pow.__proto__", Function.prototype, Math.pow.__proto__ ); +new TestCase( SECTION, "String.prototype.indexOf.__proto__", Function.prototype, String.prototype.indexOf.__proto__ ); + +test(); diff --git a/tests/auto/qml/parserstress/tests/ecma/extensions/15.1.2.1-1.js b/tests/auto/qml/parserstress/tests/ecma/extensions/15.1.2.1-1.js new file mode 100644 index 0000000000..c3fe679e5e --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/extensions/15.1.2.1-1.js @@ -0,0 +1,88 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.1.2.1-1.js'; + +/** + File Name: 15.1.2.1-1.js + ECMA Section: 15.1.2.1 eval(x) + + if x is not a string object, return x. + Description: + Author: christine@netscape.com + Date: 16 september 1997 +*/ +var SECTION = "15.1.2.1-1"; +var VERSION = "ECMA_1"; +var TITLE = "eval(x)"; +var BUGNUMBER = "none"; + +startTest(); + +writeHeaderToLog( SECTION + " "+ TITLE); + +new TestCase( SECTION, "eval.length", 1, eval.length ); +new TestCase( SECTION, "delete eval.length", false, delete eval.length ); +new TestCase( SECTION, "var PROPS = ''; for ( p in eval ) { PROPS += p }; PROPS", "prototype", eval("var PROPS = ''; for ( p in eval ) { PROPS += p }; PROPS") ); +new TestCase( SECTION, "eval.length = null; eval.length", 1, eval( "eval.length = null; eval.length") ); +// new TestCase( SECTION, "eval.__proto__", Function.prototype, eval.__proto__ ); + +// test cases where argument is not a string. should return the argument. + +new TestCase( SECTION, "eval()", void 0, eval() ); +new TestCase( SECTION, "eval(void 0)", void 0, eval( void 0) ); +new TestCase( SECTION, "eval(null)", null, eval( null ) ); +new TestCase( SECTION, "eval(true)", true, eval( true ) ); +new TestCase( SECTION, "eval(false)", false, eval( false ) ); + +new TestCase( SECTION, "typeof eval(new String('Infinity/-0')", "object", typeof eval(new String('Infinity/-0')) ); + +new TestCase( SECTION, "eval([1,2,3,4,5,6])", "1,2,3,4,5,6", ""+eval([1,2,3,4,5,6]) ); +new TestCase( SECTION, "eval(new Array(0,1,2,3)", "1,2,3", ""+ eval(new Array(1,2,3)) ); +new TestCase( SECTION, "eval(1)", 1, eval(1) ); +new TestCase( SECTION, "eval(0)", 0, eval(0) ); +new TestCase( SECTION, "eval(-1)", -1, eval(-1) ); +new TestCase( SECTION, "eval(Number.NaN)", Number.NaN, eval(Number.NaN) ); +new TestCase( SECTION, "eval(Number.MIN_VALUE)", 5e-308, eval(Number.MIN_VALUE) ); +new TestCase( SECTION, "eval(-Number.MIN_VALUE)", -5e-308, eval(-Number.MIN_VALUE) ); +new TestCase( SECTION, "eval(Number.POSITIVE_INFINITY)", Number.POSITIVE_INFINITY, eval(Number.POSITIVE_INFINITY) ); +new TestCase( SECTION, "eval(Number.NEGATIVE_INFINITY)", Number.NEGATIVE_INFINITY, eval(Number.NEGATIVE_INFINITY) ); +new TestCase( SECTION, "eval( 4294967296 )", 4294967296, eval(4294967296) ); +new TestCase( SECTION, "eval( 2147483648 )", 2147483648, eval(2147483648) ); + +test(); diff --git a/tests/auto/qml/parserstress/tests/ecma/extensions/15.2.1.1.js b/tests/auto/qml/parserstress/tests/ecma/extensions/15.2.1.1.js new file mode 100644 index 0000000000..f4f821877d --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/extensions/15.2.1.1.js @@ -0,0 +1,82 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.2.1.1.js'; + +/** + File Name: 15.2.1.1.js + ECMA Section: 15.2.1.1 The Object Constructor Called as a Function: + Object(value) + Description: When Object is called as a function rather than as a + constructor, the following steps are taken: + + 1. If value is null or undefined, create and return a + new object with no properties other than internal + properties exactly as if the object constructor + had been called on that same value (15.2.2.1). + 2. Return ToObject (value), whose rules are: + + undefined generate a runtime error + null generate a runtime error + boolean create a new Boolean object whose default + value is the value of the boolean. + number Create a new Number object whose default + value is the value of the number. + string Create a new String object whose default + value is the value of the string. + object Return the input argument (no conversion). + + Author: christine@netscape.com + Date: 17 july 1997 +*/ + +var SECTION = "15.2.1.1"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Object( value )"; + +writeHeaderToLog( SECTION + " "+ TITLE); + + +var NULL_OBJECT = Object(null); + +new TestCase( SECTION, "Object(null).__proto__", Object.prototype, (Object(null)).__proto__ ); + +new TestCase( SECTION, "Object(void 0).__proto__", Object.prototype, (Object(void 0)).__proto__ ); + +test(); diff --git a/tests/auto/qml/parserstress/tests/ecma/extensions/15.2.3-1.js b/tests/auto/qml/parserstress/tests/ecma/extensions/15.2.3-1.js new file mode 100644 index 0000000000..6d49db2481 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/extensions/15.2.3-1.js @@ -0,0 +1,64 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.2.3-1.js'; + +/** + File Name: 15.2.3-1.js + ECMA Section: 15.2.3 Properties of the Object Constructor + + Description: The value of the internal [[Prototype]] property of the + Object constructor is the Function prototype object. + + Besides the call and construct propreties and the length + property, the Object constructor has properties described + in 15.2.3.1. + + Author: christine@netscape.com + Date: 28 october 1997 + +*/ +var SECTION = "15.2.3"; +var VERSION = "ECMA_2"; +startTest(); + +writeHeaderToLog( SECTION + " Properties of the Object Constructor"); + +new TestCase( SECTION, "Object.__proto__", Function.prototype, Object.__proto__ ); + +test(); diff --git a/tests/auto/qml/parserstress/tests/ecma/extensions/15.2.4.js b/tests/auto/qml/parserstress/tests/ecma/extensions/15.2.4.js new file mode 100644 index 0000000000..df55e0894a --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/extensions/15.2.4.js @@ -0,0 +1,66 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.2.4.js'; + +/** + File Name: 15.2.4.js + ECMA Section: 15.2.4 Properties of the Object prototype object + + Description: The value of the internal [[Prototype]] property of + the Object prototype object is null + + Author: christine@netscape.com + Date: 28 october 1997 + +*/ + +var SECTION = "15.2.4"; +var VERSION = "ECMA_2"; +startTest(); +var TITLE = "Properties of the Object.prototype object"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +new TestCase( SECTION, + "Object.prototype.__proto__", + null, + Object.prototype.__proto__ ); + +test(); + diff --git a/tests/auto/qml/parserstress/tests/ecma/extensions/15.3.1.1-1.js b/tests/auto/qml/parserstress/tests/ecma/extensions/15.3.1.1-1.js new file mode 100644 index 0000000000..169cf50851 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/extensions/15.3.1.1-1.js @@ -0,0 +1,82 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.3.1.1-1.js'; + +/** + File Name: 15.3.1.1.js + ECMA Section: 15.3.1.1 The Function Constructor Called as a Function + + Description: + When the Function function is called with some arguments p1, p2, . . . , pn, body + (where n might be 0, that is, there are no "p" arguments, and where body might + also not be provided), the following steps are taken: + + 1. Create and return a new Function object exactly if the function constructor had + been called with the same arguments (15.3.2.1). + + Author: christine@netscape.com + Date: 28 october 1997 + +*/ +var SECTION = "15.3.1.1-1"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "The Function Constructor Called as a Function"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +var MyObject = Function( "value", "this.value = value; this.valueOf = Function( 'return this.value' ); this.toString = Function( 'return String(this.value);' )" ); + + +var myfunc = Function(); +myfunc.toString = Object.prototype.toString; + +// not going to test toString here since it is implementation dependent. +// new TestCase( SECTION, "myfunc.toString()", "function anonymous() { }", myfunc.toString() ); + +myfunc.toString = Object.prototype.toString; + +new TestCase( SECTION, + "MyObject.__proto__ == Function.prototype", + true, + MyObject.__proto__ == Function.prototype ); + +test(); + + diff --git a/tests/auto/qml/parserstress/tests/ecma/extensions/15.3.1.1-2.js b/tests/auto/qml/parserstress/tests/ecma/extensions/15.3.1.1-2.js new file mode 100644 index 0000000000..42165465bc --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/extensions/15.3.1.1-2.js @@ -0,0 +1,82 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.3.1.1-2.js'; + +/** + File Name: 15.3.1.1-2.js + ECMA Section: 15.3.1.1 The Function Constructor Called as a Function + Function(p1, p2, ..., pn, body ) + + Description: + When the Function function is called with some arguments p1, p2, . . . , pn, + body (where n might be 0, that is, there are no "p" arguments, and where body + might also not be provided), the following steps are taken: + + 1. Create and return a new Function object exactly if the function constructor + had been called with the same arguments (15.3.2.1). + + Author: christine@netscape.com + Date: 28 october 1997 + +*/ +var SECTION = "15.3.1.1-2"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "The Function Constructor Called as a Function"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +var myfunc2 = Function("a, b, c", "return a+b+c" ); +var myfunc3 = Function("a,b", "c", "return a+b+c" ); + +myfunc2.toString = Object.prototype.toString; +myfunc3.toString = Object.prototype.toString; + + +new TestCase( SECTION, + "myfunc2.__proto__", + Function.prototype, + myfunc2.__proto__ ); + +new TestCase( SECTION, + "myfunc3.__proto__", + Function.prototype, + myfunc3.__proto__ ); + +test(); diff --git a/tests/auto/qml/parserstress/tests/ecma/extensions/15.3.2.1-1.js b/tests/auto/qml/parserstress/tests/ecma/extensions/15.3.2.1-1.js new file mode 100644 index 0000000000..fab359211f --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/extensions/15.3.2.1-1.js @@ -0,0 +1,72 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.3.2.1-1.js'; + +/** + File Name: 15.3.2.1.js + ECMA Section: 15.3.2.1 The Function Constructor + new Function(p1, p2, ..., pn, body ) + + Description: The last argument specifies the body (executable code) + of a function; any preceeding arguments sepcify formal + parameters. + + See the text for description of this section. + + This test examples from the specification. + + Author: christine@netscape.com + Date: 28 october 1997 + +*/ +var SECTION = "15.3.2.1"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "The Function Constructor"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +var MyObject = new Function( "value", "this.value = value; this.valueOf = new Function( 'return this.value' ); this.toString = new Function( 'return String(this.value);' )" ); + +new TestCase( SECTION, + "MyObject.__proto__ == Function.prototype", + true, + MyObject.__proto__ == Function.prototype ); + +test(); diff --git a/tests/auto/qml/parserstress/tests/ecma/extensions/15.3.2.1-2.js b/tests/auto/qml/parserstress/tests/ecma/extensions/15.3.2.1-2.js new file mode 100644 index 0000000000..0b37e21028 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/extensions/15.3.2.1-2.js @@ -0,0 +1,72 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.3.2.1-2.js'; + +/** + File Name: 15.3.2.1.js + ECMA Section: 15.3.2.1 The Function Constructor + new Function(p1, p2, ..., pn, body ) + + Description: + Author: christine@netscape.com + Date: 28 october 1997 + +*/ +var SECTION = "15.3.2.1-2"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "The Function Constructor"; + +writeHeaderToLog( SECTION + " "+ TITLE); + + +var myfunc1 = new Function("a","b","c", "return a+b+c" ); +var myfunc2 = new Function("a, b, c", "return a+b+c" ); +var myfunc3 = new Function("a,b", "c", "return a+b+c" ); + +myfunc1.toString = Object.prototype.toString; +myfunc2.toString = Object.prototype.toString; +myfunc3.toString = Object.prototype.toString; + + +new TestCase( SECTION, "myfunc2.__proto__", Function.prototype, myfunc2.__proto__ ); + +new TestCase( SECTION, "myfunc3.__proto__", Function.prototype, myfunc3.__proto__ ); + +test(); diff --git a/tests/auto/qml/parserstress/tests/ecma/extensions/15.3.3.1-1.js b/tests/auto/qml/parserstress/tests/ecma/extensions/15.3.3.1-1.js new file mode 100644 index 0000000000..d4f22ff257 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/extensions/15.3.3.1-1.js @@ -0,0 +1,67 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.3.3.1-1.js'; + +/** + File Name: 15.3.3.1-1.js + ECMA Section: 15.3.3.1 Properties of the Function Constructor + Function.prototype + + Description: The initial value of Function.prototype is the built-in + Function prototype object. + + This property shall have the attributes [DontEnum | + DontDelete | ReadOnly] + + This test the value of Function.prototype. + + Author: christine@netscape.com + Date: 28 october 1997 + +*/ +var SECTION = "15.3.3.1-1"; +var VERSION = "ECMA_2"; +startTest(); +var TITLE = "Function.prototype"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +new TestCase( SECTION, "Function.prototype == Function.__proto__", true, Function.__proto__ == Function.prototype ); + +test(); diff --git a/tests/auto/qml/parserstress/tests/ecma/extensions/15.4.3.js b/tests/auto/qml/parserstress/tests/ecma/extensions/15.4.3.js new file mode 100644 index 0000000000..8cbf949855 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/extensions/15.4.3.js @@ -0,0 +1,63 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.4.3.js'; + +/** + File Name: 15.4.3.js + ECMA Section: 15.4.3 Properties of the Array Constructor + Description: The value of the internal [[Prototype]] property of the + Array constructor is the Function prototype object. + + Author: christine@netscape.com + Date: 7 october 1997 +*/ + +var SECTION = "15.4.3"; +var VERSION = "ECMA_2"; +startTest(); +var TITLE = "Properties of the Array Constructor"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +new TestCase( SECTION, + "Array.__proto__", + Function.prototype, + Array.__proto__ ); + +test(); diff --git a/tests/auto/qml/parserstress/tests/ecma/extensions/15.5.3.js b/tests/auto/qml/parserstress/tests/ecma/extensions/15.5.3.js new file mode 100644 index 0000000000..c25398c4f4 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/extensions/15.5.3.js @@ -0,0 +1,66 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.5.3.js'; + +/** + File Name: 15.5.3.1.js + ECMA Section: 15.5.3 Properties of the String Constructor + + Description: The value of the internal [[Prototype]] property of + the String constructor is the Function prototype + object. + + In addition to the internal [[Call]] and [[Construct]] + properties, the String constructor also has the length + property, as well as properties described in 15.5.3.1 + and 15.5.3.2. + + Author: christine@netscape.com + Date: 1 october 1997 +*/ + +var SECTION = "15.5.3"; +var VERSION = "ECMA_2"; +startTest(); +var passed = true; +writeHeaderToLog( SECTION + " Properties of the String Constructor" ); + +new TestCase( SECTION, "String.prototype", Function.prototype, String.__proto__ ); + +test(); diff --git a/tests/auto/qml/parserstress/tests/ecma/extensions/15.5.4.2.js b/tests/auto/qml/parserstress/tests/ecma/extensions/15.5.4.2.js new file mode 100644 index 0000000000..ebf4d03781 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/extensions/15.5.4.2.js @@ -0,0 +1,59 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.5.4.2.js'; + +/** + File Name: 15.5.4.2.js + ECMA Section: 15.5.4.2 String.prototype.toString + + Description: + Author: christine@netscape.com + Date: 28 october 1997 + +*/ +var SECTION = "15.5.4.2"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "String.prototype.tostring"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +new TestCase( SECTION, "String.prototype.toString.__proto__", Function.prototype, String.prototype.toString.__proto__ ); + +test(); diff --git a/tests/auto/qml/parserstress/tests/ecma/extensions/15.5.4.4-4.js b/tests/auto/qml/parserstress/tests/ecma/extensions/15.5.4.4-4.js new file mode 100644 index 0000000000..c2e115e0c6 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/extensions/15.5.4.4-4.js @@ -0,0 +1,107 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.5.4.4-4.js'; + +/** + File Name: 15.5.4.4-4.js + ECMA Section: 15.5.4.4 String.prototype.charAt(pos) + Description: Returns a string containing the character at position + pos in the string. If there is no character at that + string, the result is the empty string. The result is + a string value, not a String object. + + When the charAt method is called with one argument, + pos, the following steps are taken: + 1. Call ToString, with this value as its argument + 2. Call ToInteger pos + 3. Compute the number of characters in Result(1) + 4. If Result(2) is less than 0 is or not less than + Result(3), return the empty string + 5. Return a string of length 1 containing one character + from result (1), the character at position Result(2). + + Note that the charAt function is intentionally generic; + it does not require that its this value be a String + object. Therefore it can be transferred to other kinds + of objects for use as a method. + + This tests assiging charAt to primitive types.. + + Author: christine@netscape.com + Date: 2 october 1997 +*/ +var SECTION = "15.5.4.4-4"; +var VERSION = "ECMA_2"; +startTest(); +var TITLE = "String.prototype.charAt"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +/* + new TestCase( SECTION, "x = null; x.__proto.charAt = String.prototype.charAt; x.charAt(0)", "n", eval("x=null; x.__proto__.charAt = String.prototype.charAt; x.charAt(0)") ); + new TestCase( SECTION, "x = null; x.__proto.charAt = String.prototype.charAt; x.charAt(1)", "u", eval("x=null; x.__proto__.charAt = String.prototype.charAt; x.charAt(1)") ); + new TestCase( SECTION, "x = null; x.__proto.charAt = String.prototype.charAt; x.charAt(2)", "l", eval("x=null; x.__proto__.charAt = String.prototype.charAt; x.charAt(2)") ); + new TestCase( SECTION, "x = null; x.__proto.charAt = String.prototype.charAt; x.charAt(3)", "l", eval("x=null; x.__proto__.charAt = String.prototype.charAt; x.charAt(3)") ); + + new TestCase( SECTION, "x = undefined; x.__proto.charAt = String.prototype.charAt; x.charAt(0)", "u", eval("x=undefined; x.__proto__.charAt = String.prototype.charAt; x.charAt(0)") ); + new TestCase( SECTION, "x = undefined; x.__proto.charAt = String.prototype.charAt; x.charAt(1)", "n", eval("x=undefined; x.__proto__.charAt = String.prototype.charAt; x.charAt(1)") ); + new TestCase( SECTION, "x = undefined; x.__proto.charAt = String.prototype.charAt; x.charAt(2)", "d", eval("x=undefined; x.__proto__.charAt = String.prototype.charAt; x.charAt(2)") ); + new TestCase( SECTION, "x = undefined; x.__proto.charAt = String.prototype.charAt; x.charAt(3)", "e", eval("x=undefined; x.__proto__.charAt = String.prototype.charAt; x.charAt(3)") ); +*/ +new TestCase( SECTION, "x = false; x.__proto.charAt = String.prototype.charAt; x.charAt(0)", "f", eval("x=false; x.__proto__.charAt = String.prototype.charAt; x.charAt(0)") ); +new TestCase( SECTION, "x = false; x.__proto.charAt = String.prototype.charAt; x.charAt(1)", "a", eval("x=false; x.__proto__.charAt = String.prototype.charAt; x.charAt(1)") ); +new TestCase( SECTION, "x = false; x.__proto.charAt = String.prototype.charAt; x.charAt(2)", "l", eval("x=false; x.__proto__.charAt = String.prototype.charAt; x.charAt(2)") ); +new TestCase( SECTION, "x = false; x.__proto.charAt = String.prototype.charAt; x.charAt(3)", "s", eval("x=false; x.__proto__.charAt = String.prototype.charAt; x.charAt(3)") ); +new TestCase( SECTION, "x = false; x.__proto.charAt = String.prototype.charAt; x.charAt(4)", "e", eval("x=false; x.__proto__.charAt = String.prototype.charAt; x.charAt(4)") ); + +new TestCase( SECTION, "x = true; x.__proto.charAt = String.prototype.charAt; x.charAt(0)", "t", eval("x=true; x.__proto__.charAt = String.prototype.charAt; x.charAt(0)") ); +new TestCase( SECTION, "x = true; x.__proto.charAt = String.prototype.charAt; x.charAt(1)", "r", eval("x=true; x.__proto__.charAt = String.prototype.charAt; x.charAt(1)") ); +new TestCase( SECTION, "x = true; x.__proto.charAt = String.prototype.charAt; x.charAt(2)", "u", eval("x=true; x.__proto__.charAt = String.prototype.charAt; x.charAt(2)") ); +new TestCase( SECTION, "x = true; x.__proto.charAt = String.prototype.charAt; x.charAt(3)", "e", eval("x=true; x.__proto__.charAt = String.prototype.charAt; x.charAt(3)") ); + +new TestCase( SECTION, "x = NaN; x.__proto.charAt = String.prototype.charAt; x.charAt(0)", "N", eval("x=NaN; x.__proto__.charAt = String.prototype.charAt; x.charAt(0)") ); +new TestCase( SECTION, "x = NaN; x.__proto.charAt = String.prototype.charAt; x.charAt(1)", "a", eval("x=NaN; x.__proto__.charAt = String.prototype.charAt; x.charAt(1)") ); +new TestCase( SECTION, "x = NaN; x.__proto.charAt = String.prototype.charAt; x.charAt(2)", "N", eval("x=NaN; x.__proto__.charAt = String.prototype.charAt; x.charAt(2)") ); + +new TestCase( SECTION, "x = 123; x.__proto.charAt = String.prototype.charAt; x.charAt(0)", "1", eval("x=123; x.__proto__.charAt = String.prototype.charAt; x.charAt(0)") ); +new TestCase( SECTION, "x = 123; x.__proto.charAt = String.prototype.charAt; x.charAt(1)", "2", eval("x=123; x.__proto__.charAt = String.prototype.charAt; x.charAt(1)") ); +new TestCase( SECTION, "x = 123; x.__proto.charAt = String.prototype.charAt; x.charAt(2)", "3", eval("x=123; x.__proto__.charAt = String.prototype.charAt; x.charAt(2)") ); + + +test(); diff --git a/tests/auto/qml/parserstress/tests/ecma/extensions/15.5.4.5-6.js b/tests/auto/qml/parserstress/tests/ecma/extensions/15.5.4.5-6.js new file mode 100644 index 0000000000..4eadc66c04 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/extensions/15.5.4.5-6.js @@ -0,0 +1,94 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.5.4.5-6.js'; + +/** + File Name: 15.5.4.5-6.js + ECMA Section: 15.5.4.5 String.prototype.charCodeAt(pos) + Description: Returns a number (a nonnegative integer less than 2^16) + representing the Unicode encoding of the character at + position pos in this string. If there is no character + at that position, the number is NaN. + + When the charCodeAt method is called with one argument + pos, the following steps are taken: + 1. Call ToString, giving it the theis value as its + argument + 2. Call ToInteger(pos) + 3. Compute the number of characters in result(1). + 4. If Result(2) is less than 0 or is not less than + Result(3), return NaN. + 5. Return a value of Number type, of positive sign, whose + magnitude is the Unicode encoding of one character + from result 1, namely the characer at position Result + (2), where the first character in Result(1) is + considered to be at position 0. + + Note that the charCodeAt funciton is intentionally + generic; it does not require that its this value be a + String object. Therefore it can be transferred to other + kinds of objects for use as a method. + + Author: christine@netscape.com + Date: 2 october 1997 +*/ +var SECTION = "15.5.4.5-6"; +var VERSION = "ECMA_2"; +startTest(); +var TITLE = "String.prototype.charCodeAt"; + +writeHeaderToLog( SECTION + " "+ TITLE); + + +new TestCase( SECTION, + "var obj = true; obj.__proto__.charCodeAt = String.prototype.charCodeAt; var s = ''; for ( var i = 0; i < 4; i++ ) s+= String.fromCharCode( obj.charCodeAt(i) ); s", + "true", + eval("var obj = true; obj.__proto__.charCodeAt = String.prototype.charCodeAt; var s = ''; for ( var i = 0; i < 4; i++ ) s+= String.fromCharCode( obj.charCodeAt(i) ); s") ); + +new TestCase( SECTION, + "var obj = 1234; obj.__proto__.charCodeAt = String.prototype.charCodeAt; var s = ''; for ( var i = 0; i < 4; i++ ) s+= String.fromCharCode( obj.charCodeAt(i) ); s", + "1234", + eval("var obj = 1234; obj.__proto__.charCodeAt = String.prototype.charCodeAt; var s = ''; for ( var i = 0; i < 4; i++ ) s+= String.fromCharCode( obj.charCodeAt(i) ); s") ); + +new TestCase( SECTION, + "var obj = 'hello'; obj.__proto__.charCodeAt = String.prototype.charCodeAt; var s = ''; for ( var i = 0; i < 5; i++ ) s+= String.fromCharCode( obj.charCodeAt(i) ); s", + "hello", + eval("var obj = 'hello'; obj.__proto__.charCodeAt = String.prototype.charCodeAt; var s = ''; for ( var i = 0; i < 5; i++ ) s+= String.fromCharCode( obj.charCodeAt(i) ); s") ); + +test(); diff --git a/tests/auto/qml/parserstress/tests/ecma/extensions/15.5.4.7-3.js b/tests/auto/qml/parserstress/tests/ecma/extensions/15.5.4.7-3.js new file mode 100644 index 0000000000..c5832fd477 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/extensions/15.5.4.7-3.js @@ -0,0 +1,161 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.5.4.7-3.js'; + +/** + File Name: 15.5.4.7-3.js + ECMA Section: 15.5.4.7 String.prototype.lastIndexOf( searchString, pos) + Description: + + If the given searchString appears as a substring of the result of + converting this object to a string, at one or more positions that are + at or to the left of the specified position, then the index of the + rightmost such position is returned; otherwise -1 is returned. If position + is undefined or not supplied, the length of this string value is assumed, + so as to search all of the string. + + When the lastIndexOf method is called with two arguments searchString and + position, the following steps are taken: + + 1.Call ToString, giving it the this value as its argument. + 2.Call ToString(searchString). + 3.Call ToNumber(position). (If position is undefined or not supplied, this step produces the value NaN). + 4.If Result(3) is NaN, use +; otherwise, call ToInteger(Result(3)). + 5.Compute the number of characters in Result(1). + 6.Compute min(max(Result(4), 0), Result(5)). + 7.Compute the number of characters in the string that is Result(2). + 8.Compute the largest possible integer k not larger than Result(6) such that k+Result(7) is not greater + than Result(5), and for all nonnegative integers j less than Result(7), the character at position k+j of + Result(1) is the same as the character at position j of Result(2); but if there is no such integer k, then + compute the value -1. + + 1.Return Result(8). + + Note that the lastIndexOf function is intentionally generic; it does not require that its this value be a + String object. Therefore it can be transferred to other kinds of objects for use as a method. + + Author: christine@netscape.com + Date: 2 october 1997 +*/ +var SECTION = "15.5.4.7-3"; +var VERSION = "ECMA_2"; +startTest(); +var TITLE = "String.protoype.lastIndexOf"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +new TestCase( SECTION, + "var b = true; b.__proto__.lastIndexOf = String.prototype.lastIndexOf; b.lastIndexOf('r', 0 )", + -1, + eval("var b = true; b.__proto__.lastIndexOf = String.prototype.lastIndexOf; b.lastIndexOf('r', 0 )") ); + +new TestCase( SECTION, + "var b = true; b.__proto__.lastIndexOf = String.prototype.lastIndexOf; b.lastIndexOf('r', 1 )", + 1, + eval("var b = true; b.__proto__.lastIndexOf = String.prototype.lastIndexOf; b.lastIndexOf('r', 1 )") ); + +new TestCase( SECTION, + "var b = true; b.__proto__.lastIndexOf = String.prototype.lastIndexOf; b.lastIndexOf('r', 2 )", + 1, + eval("var b = true; b.__proto__.lastIndexOf = String.prototype.lastIndexOf; b.lastIndexOf('r', 2 )") ); + +new TestCase( SECTION, + "var b = true; b.__proto__.lastIndexOf = String.prototype.lastIndexOf; b.lastIndexOf('r', 10 )", + 1, + eval("var b = true; b.__proto__.lastIndexOf = String.prototype.lastIndexOf; b.lastIndexOf('r', 10 )") ); + +new TestCase( SECTION, + "var b = true; b.__proto__.lastIndexOf = String.prototype.lastIndexOf; b.lastIndexOf('r' )", + 1, + eval("var b = true; b.__proto__.lastIndexOf = String.prototype.lastIndexOf; b.lastIndexOf('r' )") ); + +test(); + +function LastIndexOf( string, search, position ) { + string = String( string ); + search = String( search ); + + position = Number( position ) + + if ( isNaN( position ) ) { + position = Infinity; + } else { + position = ToInteger( position ); + } + + result5= string.length; + result6 = Math.min(Math.max(position, 0), result5); + result7 = search.length; + + if (result7 == 0) { + return Math.min(position, result5); + } + + result8 = -1; + + for ( k = 0; k <= result6; k++ ) { + if ( k+ result7 > result5 ) { + break; + } + for ( j = 0; j < result7; j++ ) { + if ( string.charAt(k+j) != search.charAt(j) ){ + break; + } else { + if ( j == result7 -1 ) { + result8 = k; + } + } + } + } + + return result8; +} +function ToInteger( n ) { + n = Number( n ); + if ( isNaN(n) ) { + return 0; + } + if ( Math.abs(n) == 0 || Math.abs(n) == Infinity ) { + return n; + } + + var sign = ( n < 0 ) ? -1 : 1; + + return ( sign * Math.floor(Math.abs(n)) ); +} diff --git a/tests/auto/qml/parserstress/tests/ecma/extensions/15.6.3.1-5.js b/tests/auto/qml/parserstress/tests/ecma/extensions/15.6.3.1-5.js new file mode 100644 index 0000000000..b9f35b8225 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/extensions/15.6.3.1-5.js @@ -0,0 +1,58 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.6.3.1-5.js'; + +/** + File Name: 15.6.3.1-5.js + ECMA Section: 15.6.3.1 Boolean.prototype + Description: + Author: christine@netscape.com + Date: 28 october 1997 + +*/ +var VERSION = "ECMA_2"; +startTest(); +var SECTION = "15.6.3.1-5"; +var TITLE = "Boolean.prototype" + + writeHeaderToLog( SECTION + " " + TITLE ); + +new TestCase( SECTION, "Function.prototype == Boolean.__proto__", true, Function.prototype == Boolean.__proto__ ); + +test(); diff --git a/tests/auto/qml/parserstress/tests/ecma/extensions/15.6.3.js b/tests/auto/qml/parserstress/tests/ecma/extensions/15.6.3.js new file mode 100644 index 0000000000..0ae48c59f2 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/extensions/15.6.3.js @@ -0,0 +1,65 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.6.3.js'; + +/** + File Name: 15.6.3.js + ECMA Section: 15.6.3 Properties of the Boolean Constructor + + Description: The value of the internal prototype property is + the Function prototype object. + + It has the internal [[Call]] and [[Construct]] + properties, and the length property. + + Author: christine@netscape.com + Date: june 27, 1997 + +*/ +var SECTION = "15.6.3"; +var VERSION = "ECMA_2"; +startTest(); +var TITLE = "Properties of the Boolean Constructor" + writeHeaderToLog( SECTION + TITLE ); + + +new TestCase( SECTION, "Boolean.__proto__ == Function.prototype", true, Boolean.__proto__ == Function.prototype ); +new TestCase( SECTION, "Boolean.length", 1, Boolean.length ); + +test(); diff --git a/tests/auto/qml/parserstress/tests/ecma/extensions/15.6.4-2.js b/tests/auto/qml/parserstress/tests/ecma/extensions/15.6.4-2.js new file mode 100644 index 0000000000..7ca222235f --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/extensions/15.6.4-2.js @@ -0,0 +1,66 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.6.4-2.js'; + +/** + File Name: 15.6.4-2.js + ECMA Section: 15.6.4 Properties of the Boolean Prototype Object + + Description: + The Boolean prototype object is itself a Boolean object (its [[Class]] is + "Boolean") whose value is false. + + The value of the internal [[Prototype]] property of the Boolean prototype object + is the Object prototype object (15.2.3.1). + + Author: christine@netscape.com + Date: 30 september 1997 + +*/ + + +var VERSION = "ECMA_2" + startTest(); +var SECTION = "15.6.4-2"; + +writeHeaderToLog( SECTION + " Properties of the Boolean Prototype Object"); + +new TestCase( SECTION, "Boolean.prototype.__proto__", Object.prototype, Boolean.prototype.__proto__ ); + +test(); diff --git a/tests/auto/qml/parserstress/tests/ecma/extensions/15.7.3.js b/tests/auto/qml/parserstress/tests/ecma/extensions/15.7.3.js new file mode 100644 index 0000000000..84e362c2db --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/extensions/15.7.3.js @@ -0,0 +1,69 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.7.3.js'; + +/** + File Name: 15.7.3.js + 15.7.3 Properties of the Number Constructor + + Description: The value of the internal [[Prototype]] property + of the Number constructor is the Function prototype + object. The Number constructor also has the internal + [[Call]] and [[Construct]] properties, and the length + property. + + Other properties are in subsequent tests. + + Author: christine@netscape.com + Date: 29 september 1997 +*/ + +var SECTION = "15.7.3"; +var VERSION = "ECMA_2"; +startTest(); +var TITLE = "Properties of the Number Constructor"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +new TestCase(SECTION, + "Number.__proto__", + Function.prototype, + Number.__proto__ ); + +test(); diff --git a/tests/auto/qml/parserstress/tests/ecma/extensions/15.7.4.js b/tests/auto/qml/parserstress/tests/ecma/extensions/15.7.4.js new file mode 100644 index 0000000000..733b937e55 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/extensions/15.7.4.js @@ -0,0 +1,90 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.7.4.js'; + +/** + File Name: 15.7.4.js + ECMA Section: 15.7.4 + + Description: + + The Number prototype object is itself a Number object (its [[Class]] is + "Number") whose value is +0. + + The value of the internal [[Prototype]] property of the Number prototype + object is the Object prototype object (15.2.3.1). + + In following descriptions of functions that are properties of the Number + prototype object, the phrase "this Number object" refers to the object + that is the this value for the invocation of the function; it is an error + if this does not refer to an object for which the value of the internal + [[Class]] property is "Number". Also, the phrase "this number value" refers + to the number value represented by this Number object, that is, the value + of the internal [[Value]] property of this Number object. + + Author: christine@netscape.com + Date: 12 november 1997 +*/ +var SECTION = "15.7.4"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Properties of the Number Prototype Object"; + +writeHeaderToLog( SECTION + " "+TITLE); + +new TestCase( SECTION, + "Number.prototype.toString=Object.prototype.toString;Number.prototype.toString()", + "[object Number]", + eval("Number.prototype.toString=Object.prototype.toString;Number.prototype.toString()") ); + +new TestCase( SECTION, + "typeof Number.prototype", + "object", + typeof Number.prototype ); + +new TestCase( SECTION, + "Number.prototype.valueOf()", + 0, + Number.prototype.valueOf() ); + +// The __proto__ property cannot be used in ECMA_1 tests. +// new TestCase( SECTION, "Number.prototype.__proto__", Object.prototype, Number.prototype.__proto__ ); +// new TestCase( SECTION, "Number.prototype.__proto__ == Object.prototype", true, Number.prototype.__proto__ == Object.prototype ); + +test(); diff --git a/tests/auto/qml/parserstress/tests/ecma/extensions/15.8-1.js b/tests/auto/qml/parserstress/tests/ecma/extensions/15.8-1.js new file mode 100644 index 0000000000..0f51cf5e61 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/extensions/15.8-1.js @@ -0,0 +1,84 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.8-1.js'; + +/** + File Name: 15.8-1.js + ECMA Section: 15.8 The Math Object + + Description: + + The Math object is merely a single object that has some named properties, + some of which are functions. + + The value of the internal [[Prototype]] property of the Math object is the + Object prototype object (15.2.3.1). + + The Math object does not have a [[Construct]] property; it is not possible + to use the Math object as a constructor with the new operator. + + The Math object does not have a [[Call]] property; it is not possible to + invoke the Math object as a function. + + Recall that, in this specification, the phrase "the number value for x" has + a technical meaning defined in section 8.5. + + Author: christine@netscape.com + Date: 12 november 1997 + +*/ + +var SECTION = "15.8-1"; +var VERSION = "ECMA_2"; +startTest(); +var TITLE = "The Math Object"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +new TestCase( SECTION, + "Math.__proto__ == Object.prototype", + true, + Math.__proto__ == Object.prototype ); + +new TestCase( SECTION, + "Math.__proto__", + Object.prototype, + Math.__proto__ ); + +test(); diff --git a/tests/auto/qml/parserstress/tests/ecma/extensions/15.9.5.js b/tests/auto/qml/parserstress/tests/ecma/extensions/15.9.5.js new file mode 100644 index 0000000000..54e6bb6f0f --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/extensions/15.9.5.js @@ -0,0 +1,76 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '15.9.5.js'; + +/** + File Name: 15.9.5.js + ECMA Section: 15.9.5 Properties of the Date prototype object + Description: + + The Date prototype object is itself a Date object (its [[Class]] is + "Date") whose value is NaN. + + The value of the internal [[Prototype]] property of the Date prototype + object is the Object prototype object (15.2.3.1). + + In following descriptions of functions that are properties of the Date + prototype object, the phrase "this Date object" refers to the object that + is the this value for the invocation of the function; it is an error if + this does not refer to an object for which the value of the internal + [[Class]] property is "Date". Also, the phrase "this time value" refers + to the number value for the time represented by this Date object, that is, + the value of the internal [[Value]] property of this Date object. + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + +var SECTION = "15.9.5"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Properties of the Date Prototype Object"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +new TestCase( SECTION, + "Date.prototype.__proto__ == Object.prototype", + true, + Date.prototype.__proto__ == Object.prototype ); +test(); + diff --git a/tests/auto/qml/parserstress/tests/ecma/extensions/8.6.2.1-1.js b/tests/auto/qml/parserstress/tests/ecma/extensions/8.6.2.1-1.js new file mode 100644 index 0000000000..a99bb01ee6 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/extensions/8.6.2.1-1.js @@ -0,0 +1,98 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '8.6.2.1-1.js'; + +/** + File Name: 8.6.2.1-1.js + ECMA Section: 8.6.2.1 Get (Value) + Description: + + When the [[Get]] method of O is called with property name P, the following + steps are taken: + + 1. If O doesn't have a property with name P, go to step 4. + 2. Get the value of the property. + 3. Return Result(2). + 4. If the [[Prototype]] of O is null, return undefined. + 5. Call the [[Get]] method of [[Prototype]] with property name P. + 6. Return Result(5). + + This tests [[Get]] (Value). + + Author: christine@netscape.com + Date: 12 november 1997 +*/ +var SECTION = "8.6.2.1-1"; +var VERSION = "ECMA_1"; +startTest(); + +writeHeaderToLog( SECTION + " [[Get]] (Value)"); + +new TestCase( SECTION, "var OBJ = new MyValuelessObject(true); OBJ.valueOf()", true, eval("var OBJ = new MyValuelessObject(true); OBJ.valueOf()") ); +// new TestCase( SECTION, "var OBJ = new MyProtoValuelessObject(true); OBJ + ''", "undefined", eval("var OBJ = new MyProtoValuelessObject(); OBJ + ''") ); +new TestCase( SECTION, "var OBJ = new MyProtolessObject(true); OBJ.valueOf()", true, eval("var OBJ = new MyProtolessObject(true); OBJ.valueOf()") ); + +new TestCase( SECTION, "var OBJ = new MyValuelessObject(Number.POSITIVE_INFINITY); OBJ.valueOf()", Number.POSITIVE_INFINITY, eval("var OBJ = new MyValuelessObject(Number.POSITIVE_INFINITY); OBJ.valueOf()") ); +// new TestCase( SECTION, "var OBJ = new MyProtoValuelessObject(Number.POSITIVE_INFINITY); OBJ + ''", "undefined", eval("var OBJ = new MyProtoValuelessObject(); OBJ + ''") ); +new TestCase( SECTION, "var OBJ = new MyProtolessObject(Number.POSITIVE_INFINITY); OBJ.valueOf()", Number.POSITIVE_INFINITY, eval("var OBJ = new MyProtolessObject(Number.POSITIVE_INFINITY); OBJ.valueOf()") ); + +new TestCase( SECTION, "var OBJ = new MyValuelessObject('string'); OBJ.valueOf()", 'string', eval("var OBJ = new MyValuelessObject('string'); OBJ.valueOf()") ); +// new TestCase( SECTION, "var OBJ = new MyProtoValuelessObject('string'); OJ + ''", "undefined", eval("var OBJ = new MyProtoValuelessObject(); OBJ + ''") ); +new TestCase( SECTION, "var OBJ = new MyProtolessObject('string'); OBJ.valueOf()", 'string', eval("var OBJ = new MyProtolessObject('string'); OBJ.valueOf()") ); + +test(); + +function MyProtoValuelessObject(value) { + this.valueOf = new Function ( "" ); + this.__proto__ = null; +} + +function MyProtolessObject( value ) { + this.valueOf = new Function( "return this.value" ); + this.__proto__ = null; + this.value = value; +} +function MyValuelessObject(value) { + this.__proto__ = new MyPrototypeObject(value); +} +function MyPrototypeObject(value) { + this.valueOf = new Function( "return this.value;" ); + this.toString = new Function( "return (this.value + '');" ); + this.value = value; +} diff --git a/tests/auto/qml/parserstress/tests/ecma/extensions/9.9-1.js b/tests/auto/qml/parserstress/tests/ecma/extensions/9.9-1.js new file mode 100644 index 0000000000..0df44013cd --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/extensions/9.9-1.js @@ -0,0 +1,102 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = '9.9-1.js'; + +/** + File Name: 9.9-1.js + ECMA Section: 9.9 Type Conversion: ToObject + Description: + + undefined generate a runtime error + null generate a runtime error + boolean create a new Boolean object whose default + value is the value of the boolean. + number Create a new Number object whose default + value is the value of the number. + string Create a new String object whose default + value is the value of the string. + object Return the input argument (no conversion). + Author: christine@netscape.com + Date: 17 july 1997 +*/ + +var VERSION = "ECMA_1"; +startTest(); +var SECTION = "9.9-1"; + +writeHeaderToLog( SECTION + " Type Conversion: ToObject" ); + +new TestCase( SECTION, "(Object(true)).__proto__", Boolean.prototype, (Object(true)).__proto__ ); + +new TestCase( SECTION, "(Object(true)).__proto__", Boolean.prototype, (Object(true)).__proto__ ); + +new TestCase( SECTION, "(Object(0)).__proto__", Number.prototype, (Object(0)).__proto__ ); + +new TestCase( SECTION, "(Object(-0)).__proto__", Number.prototype, (Object(-0)).__proto__ ); + +new TestCase( SECTION, "(Object(1)).__proto__", Number.prototype, (Object(1)).__proto__ ); + +new TestCase( SECTION, "(Object(-1)).__proto__", Number.prototype, (Object(-1)).__proto__ ); + +new TestCase( SECTION, "(Object(Number.MAX_VALUE)).__proto__", Number.prototype, (Object(Number.MAX_VALUE)).__proto__ ); + +new TestCase( SECTION, "(Object(Number.MIN_VALUE)).__proto__", Number.prototype, (Object(Number.MIN_VALUE)).__proto__ ); + +new TestCase( SECTION, "(Object(Number.POSITIVE_INFINITY)).__proto__", Number.prototype, (Object(Number.POSITIVE_INFINITY)).__proto__ ); + +new TestCase( SECTION, "(Object(Number.NEGATIVE_INFINITY)).__proto__", Number.prototype, (Object(Number.NEGATIVE_INFINITY)).__proto__ ); + +new TestCase( SECTION, "(Object(Number.NaN)).__proto__", Number.prototype, (Object(Number.NaN)).__proto__ ); + +new TestCase( SECTION, "(Object('a string')).__proto__", String.prototype, (Object("a string")).__proto__ ); + +new TestCase( SECTION, "(Object('')).__proto__", String.prototype, (Object("")).__proto__ ); + +new TestCase( SECTION, "(Object('\\r\\t\\b\\n\\v\\f')).__proto__", String.prototype, (Object("\\r\\t\\b\\n\\v\\f")).__proto__ ); + +new TestCase( SECTION, "Object( '\\\'\\\"\\' ).__proto__", String.prototype, (Object("\'\"\\")).__proto__ ); + +new TestCase( SECTION, "(Object( new MyObject(true) )).toString()", "[object Object]", eval("(Object( new MyObject(true) )).toString()") ); + +test(); + +function MyObject( value ) { + this.value = value; + this.valueOf = new Function ( "return this.value" ); +} diff --git a/tests/auto/qml/parserstress/tests/ecma/extensions/browser.js b/tests/auto/qml/parserstress/tests/ecma/extensions/browser.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/auto/qml/parserstress/tests/ecma/extensions/shell.js b/tests/auto/qml/parserstress/tests/ecma/extensions/shell.js new file mode 100644 index 0000000000..3f52cffbc0 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/extensions/shell.js @@ -0,0 +1 @@ +gTestsubsuite = 'extensions'; diff --git a/tests/auto/qml/parserstress/tests/ecma/jsref.js b/tests/auto/qml/parserstress/tests/ecma/jsref.js new file mode 100644 index 0000000000..1416643e1e --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/jsref.js @@ -0,0 +1,634 @@ +var completed = false; +var testcases; +var tc = 0; + +SECTION = ""; +VERSION = ""; +BUGNUMBER = ""; +TITLE = ""; + +/* + * constant strings + */ +var GLOBAL = "[object global]"; +var PASSED = " PASSED!" +var FAILED = " FAILED! expected: "; +var DEBUG = false; + +TZ_DIFF = -8; + +var TT = ""; +var TT_ = ""; +var BR = ""; +var NBSP = " "; +var CR = "\n"; +var FONT = ""; +var FONT_ = ""; +var FONT_RED = ""; +var FONT_GREEN = ""; +var B = ""; +var B_ = "" +var H2 = ""; +var H2_ = ""; +var HR = ""; +var DEBUG = false; + +var PASSED = " PASSED!" +var FAILED = " FAILED! expected: "; + +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} +/* wrapper for test cas constructor that doesn't require the SECTION + * argument. + */ + +function AddTestCase( description, expect, actual ) { + testcases[tc++] = new TestCase( SECTION, description, expect, actual ); +} + +function TestCase( n, d, e, a ) { + this.name = n; + this.description = d; + this.expect = e; + this.actual = a; + this.passed = true; + this.reason = ""; + this.bugnumber = BUGNUMBER; + + this.passed = getTestCaseResult( this.expect, this.actual ); + if ( DEBUG ) { + print( "added " + this.description ); + } + + testcases[tc++] = this; +} + +/* + * Set up test environment. + * + */ +function startTest() { + if ( version ) { + // JavaScript 1.3 is supposed to be compliant ecma version 1.0 + if ( VERSION == "ECMA_1" ) { + version ( "130" ); + } + if ( VERSION == "JS_1.3" ) { + version ( "130" ); + } + if ( VERSION == "JS_1.2" ) { + version ( "120" ); + } + if ( VERSION == "JS_1.1" ) { + version ( "110" ); + } + // for ecma version 2.0, we will leave the javascript version to + // the default ( for now ). + } + + // print out bugnumber + + if ( BUGNUMBER ) { + print ("BUGNUMBER: " + BUGNUMBER ); + } + + testcases = new Array(); + tc = 0; +} + + +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ testcases[tc].actual ); + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} + + +function getTestCaseResult( expect, actual ) { + // because ( NaN == NaN ) always returns false, need to do + // a special compare to see if we got the right result. + if ( actual != actual ) { + if ( typeof actual == "object" ) { + actual = "NaN object"; + } else { + actual = "NaN number"; + } + } + if ( expect != expect ) { + if ( typeof expect == "object" ) { + expect = "NaN object"; + } else { + expect = "NaN number"; + } + } + + var passed = ( expect == actual ) ? true : false; + + // if both objects are numbers + // need to replace w/ IEEE standard for rounding + if ( !passed + && typeof(actual) == "number" + && typeof(expect) == "number" + ) { + if ( Math.abs(actual-expect) < 0.0000001 ) { + passed = true; + } + } + + // verify type is the same + if ( typeof(expect) != typeof(actual) ) { + passed = false; + } + + return passed; +} +function writeTestCaseResult( expect, actual, string ) { + var passed = getTestCaseResult( expect, actual ); + writeFormattedResult( expect, actual, string, passed ); + return passed; +} +function writeFormattedResult( expect, actual, string, passed ) { + var s = TT + string ; + + for ( k = 0; + k < (60 - string.length >= 0 ? 60 - string.length : 5) ; + k++ ) { + } + + s += B ; + s += ( passed ) ? FONT_GREEN + NBSP + PASSED : FONT_RED + NBSP + FAILED + expect + TT_ ; + + print( s + FONT_ + B_ + TT_ ); + + return passed; +} + +function writeHeaderToLog( string ) { + print( H2 + string + H2_ ); +} +function stopTest() +{ + var sizeTag = "<#TEST CASES SIZE>"; + var doneTag = "<#TEST CASES DONE>"; + var beginTag = "<#TEST CASE "; + var endTag = ">"; + + print(sizeTag); + print(testcases.length); + for (tc = 0; tc < testcases.length; tc++) + { + print(beginTag + 'PASSED' + endTag); + print(testcases[tc].passed); + print(beginTag + 'NAME' + endTag); + print(testcases[tc].name); + print(beginTag + 'EXPECTED' + endTag); + print(testcases[tc].expect); + print(beginTag + 'ACTUAL' + endTag); + print(testcases[tc].actual); + print(beginTag + 'DESCRIPTION' + endTag); + print(testcases[tc].description); + print(beginTag + 'REASON' + endTag); + print(( testcases[tc].passed ) ? "" : "wrong value "); + print(beginTag + 'BUGNUMBER' + endTag); + print( BUGNUMBER ); + } + print(doneTag); + print( HR ); + gc(); +} +function getFailedCases() { + for ( var i = 0; i < testcases.length; i++ ) { + if ( ! testcases[i].passed ) { + print( testcases[i].description +" = " +testcases[i].actual +" expected: "+ testcases[i].expect ); + } + } +} +function err( msg, page, line ) { + testcases[tc].actual = "error"; + testcases[tc].reason = msg; + writeTestCaseResult( testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ testcases[tc].actual + + ": " + testcases[tc].reason ); + stopTest(); + return true; +} + +/** + * Type Conversion functions used by Type Conversion + * + */ + + + + /* + * Date functions used by tests in Date suite + * + */ +var msPerDay = 86400000; +var HoursPerDay = 24; +var MinutesPerHour = 60; +var SecondsPerMinute = 60; +var msPerSecond = 1000; +var msPerMinute = 60000; // msPerSecond * SecondsPerMinute +var msPerHour = 3600000; // msPerMinute * MinutesPerHour + +var TIME_1970 = 0; +var TIME_2000 = 946684800000; +var TIME_1900 = -2208988800000; + +function Day( t ) { + return ( Math.floor(t/msPerDay ) ); +} +function DaysInYear( y ) { + if ( y % 4 != 0 ) { + return 365; + } + if ( (y % 4 == 0) && (y % 100 != 0) ) { + return 366; + } + if ( (y % 100 == 0) && (y % 400 != 0) ) { + return 365; + } + if ( (y % 400 == 0) ){ + return 366; + } else { + return "ERROR: DaysInYear(" + y + ") case not covered"; + } +} +function TimeInYear( y ) { + return ( DaysInYear(y) * msPerDay ); +} +function DayNumber( t ) { + return ( Math.floor( t / msPerDay ) ); +} +function TimeWithinDay( t ) { + if ( t < 0 ) { + return ( (t % msPerDay) + msPerDay ); + } else { + return ( t % msPerDay ); + } +} +function YearNumber( t ) { +} +function TimeFromYear( y ) { + return ( msPerDay * DayFromYear(y) ); +} +function DayFromYear( y ) { + return ( 365*(y-1970) + + Math.floor((y-1969)/4) - + Math.floor((y-1901)/100) + + Math.floor((y-1601)/400) ); +} +function InLeapYear( t ) { + if ( DaysInYear(YearFromTime(t)) == 365 ) { + return 0; + } + if ( DaysInYear(YearFromTime(t)) == 366 ) { + return 1; + } else { + return "ERROR: InLeapYear("+t+") case not covered"; + } +} +function YearFromTime( t ) { + t = Number( t ); + var sign = ( t < 0 ) ? -1 : 1; + var year = ( sign < 0 ) ? 1969 : 1970; + for ( var timeToTimeZero = t; ; ) { + // subtract the current year's time from the time that's left. + timeToTimeZero -= sign * TimeInYear(year) + + // if there's less than the current year's worth of time left, then break. + if ( sign < 0 ) { + if ( sign * timeToTimeZero <= 0 ) { + break; + } else { + year += sign; + } + } else { + if ( sign * timeToTimeZero < 0 ) { + break; + } else { + year += sign; + } + } + } + return ( year ); +} +function MonthFromTime( t ) { + // i know i could use switch but i'd rather not until it's part of ECMA + var day = DayWithinYear( t ); + var leap = InLeapYear(t); + + if ( (0 <= day) && (day < 31) ) { + return 0; + } + if ( (31 <= day) && (day < (59+leap)) ) { + return 1; + } + if ( ((59+leap) <= day) && (day < (90+leap)) ) { + return 2; + } + if ( ((90+leap) <= day) && (day < (120+leap)) ) { + return 3; + } + if ( ((120+leap) <= day) && (day < (151+leap)) ) { + return 4; + } + if ( ((151+leap) <= day) && (day < (181+leap)) ) { + return 5; + } + if ( ((181+leap) <= day) && (day < (212+leap)) ) { + return 6; + } + if ( ((212+leap) <= day) && (day < (243+leap)) ) { + return 7; + } + if ( ((243+leap) <= day) && (day < (273+leap)) ) { + return 8; + } + if ( ((273+leap) <= day) && (day < (304+leap)) ) { + return 9; + } + if ( ((304+leap) <= day) && (day < (334+leap)) ) { + return 10; + } + if ( ((334+leap) <= day) && (day < (365+leap)) ) { + return 11; + } else { + return "ERROR: MonthFromTime("+t+") not known"; + } +} +function DayWithinYear( t ) { + return( Day(t) - DayFromYear(YearFromTime(t))); +} +function DateFromTime( t ) { + var day = DayWithinYear(t); + var month = MonthFromTime(t); + + if ( month == 0 ) { + return ( day + 1 ); + } + if ( month == 1 ) { + return ( day - 30 ); + } + if ( month == 2 ) { + return ( day - 58 - InLeapYear(t) ); + } + if ( month == 3 ) { + return ( day - 89 - InLeapYear(t)); + } + if ( month == 4 ) { + return ( day - 119 - InLeapYear(t)); + } + if ( month == 5 ) { + return ( day - 150- InLeapYear(t)); + } + if ( month == 6 ) { + return ( day - 180- InLeapYear(t)); + } + if ( month == 7 ) { + return ( day - 211- InLeapYear(t)); + } + if ( month == 8 ) { + return ( day - 242- InLeapYear(t)); + } + if ( month == 9 ) { + return ( day - 272- InLeapYear(t)); + } + if ( month == 10 ) { + return ( day - 303- InLeapYear(t)); + } + if ( month == 11 ) { + return ( day - 333- InLeapYear(t)); + } + + return ("ERROR: DateFromTime("+t+") not known" ); +} +function WeekDay( t ) { + var weekday = (Day(t)+4) % 7; + return( weekday < 0 ? 7 + weekday : weekday ); +} + +// missing daylight savins time adjustment + +function HourFromTime( t ) { + var h = Math.floor( t / msPerHour ) % HoursPerDay; + return ( (h<0) ? HoursPerDay + h : h ); +} +function MinFromTime( t ) { + var min = Math.floor( t / msPerMinute ) % MinutesPerHour; + return( ( min < 0 ) ? MinutesPerHour + min : min ); +} +function SecFromTime( t ) { + var sec = Math.floor( t / msPerSecond ) % SecondsPerMinute; + return ( (sec < 0 ) ? SecondsPerMinute + sec : sec ); +} +function msFromTime( t ) { + var ms = t % msPerSecond; + return ( (ms < 0 ) ? msPerSecond + ms : ms ); +} +function LocalTZA() { + return ( TZ_DIFF * msPerHour ); +} +function UTC( t ) { + return ( t - LocalTZA() - DaylightSavingTA(t - LocalTZA()) ); +} +function DaylightSavingTA( t ) { + t = t - LocalTZA(); + + var dst_start = GetFirstSundayInApril(t) + 2*msPerHour; + var dst_end = GetLastSundayInOctober(t)+ 2*msPerHour; + + if ( t >= dst_start && t < dst_end ) { + return msPerHour; + } else { + return 0; + } + + // Daylight Savings Time starts on the first Sunday in April at 2:00AM in + // PST. Other time zones will need to override this function. + + print( new Date( UTC(dst_start + LocalTZA())) ); + + return UTC(dst_start + LocalTZA()); +} +function GetFirstSundayInApril( t ) { + var year = YearFromTime(t); + var leap = InLeapYear(t); + + var april = TimeFromYear(year) + TimeInMonth(0, leap) + TimeInMonth(1,leap) + + TimeInMonth(2,leap); + + for ( var first_sunday = april; WeekDay(first_sunday) > 0; + first_sunday += msPerDay ) + { + ; + } + + return first_sunday; +} +function GetLastSundayInOctober( t ) { + var year = YearFromTime(t); + var leap = InLeapYear(t); + + for ( var oct = TimeFromYear(year), m = 0; m < 9; m++ ) { + oct += TimeInMonth(m, leap); + } + for ( var last_sunday = oct + 30*msPerDay; WeekDay(last_sunday) > 0; + last_sunday -= msPerDay ) + { + ; + } + return last_sunday; +} +function LocalTime( t ) { + return ( t + LocalTZA() + DaylightSavingTA(t) ); +} +function MakeTime( hour, min, sec, ms ) { + if ( isNaN( hour ) || isNaN( min ) || isNaN( sec ) || isNaN( ms ) ) { + return Number.NaN; + } + + hour = ToInteger(hour); + min = ToInteger( min); + sec = ToInteger( sec); + ms = ToInteger( ms ); + + return( (hour*msPerHour) + (min*msPerMinute) + + (sec*msPerSecond) + ms ); +} +function MakeDay( year, month, date ) { + if ( isNaN(year) || isNaN(month) || isNaN(date) ) { + return Number.NaN; + } + year = ToInteger(year); + month = ToInteger(month); + date = ToInteger(date ); + + var sign = ( year < 1970 ) ? -1 : 1; + var t = ( year < 1970 ) ? 1 : 0; + var y = ( year < 1970 ) ? 1969 : 1970; + + var result5 = year + Math.floor( month/12 ); + var result6 = month % 12; + + if ( year < 1970 ) { + for ( y = 1969; y >= year; y += sign ) { + t += sign * TimeInYear(y); + } + } else { + for ( y = 1970 ; y < year; y += sign ) { + t += sign * TimeInYear(y); + } + } + + var leap = InLeapYear( t ); + + for ( var m = 0; m < month; m++ ) { + t += TimeInMonth( m, leap ); + } + + if ( YearFromTime(t) != result5 ) { + return Number.NaN; + } + if ( MonthFromTime(t) != result6 ) { + return Number.NaN; + } + if ( DateFromTime(t) != 1 ) { + return Number.NaN; + } + + return ( (Day(t)) + date - 1 ); +} +function TimeInMonth( month, leap ) { + // september april june november + // jan 0 feb 1 mar 2 apr 3 may 4 june 5 jul 6 + // aug 7 sep 8 oct 9 nov 10 dec 11 + + if ( month == 3 || month == 5 || month == 8 || month == 10 ) { + return ( 30*msPerDay ); + } + + // all the rest + if ( month == 0 || month == 2 || month == 4 || month == 6 || + month == 7 || month == 9 || month == 11 ) { + return ( 31*msPerDay ); + } + + // save february + return ( (leap == 0) ? 28*msPerDay : 29*msPerDay ); +} +function MakeDate( day, time ) { + if ( day == Number.POSITIVE_INFINITY || + day == Number.NEGATIVE_INFINITY || + day == Number.NaN ) { + return Number.NaN; + } + if ( time == Number.POSITIVE_INFINITY || + time == Number.POSITIVE_INFINITY || + day == Number.NaN) { + return Number.NaN; + } + return ( day * msPerDay ) + time; +} +function TimeClip( t ) { + if ( isNaN( t ) ) { + return ( Number.NaN ); + } + if ( Math.abs( t ) > 8.64e15 ) { + return ( Number.NaN ); + } + + return ( ToInteger( t ) ); +} +function ToInteger( t ) { + t = Number( t ); + + if ( isNaN( t ) ){ + return ( Number.NaN ); + } + if ( t == 0 || t == -0 || + t == Number.POSITIVE_INFINITY || t == Number.NEGATIVE_INFINITY ) { + return 0; + } + + var sign = ( t < 0 ) ? -1 : 1; + + return ( sign * Math.floor( Math.abs( t ) ) ); +} +function Enumerate ( o ) { + var properties = new Array(); + for ( p in o ) { + properties[ properties.length ] = new Array( p, o[p] ); + } + return properties; +} +function AddTestCase( description, expect, actual ) { + testcases[tc++] = new TestCase( SECTION, description, expect, actual ); +} + +function getFailedCases() { + for ( var i = 0; i < testcases.length; i++ ) { + if ( ! testcases[i].passed ) { + print( testcases[i].description +" = " +testcases[i].actual +" expected: "+ testcases[i].expect ); + } + } +} diff --git a/tests/auto/qml/parserstress/tests/ecma/shell.js b/tests/auto/qml/parserstress/tests/ecma/shell.js new file mode 100644 index 0000000000..1c012601e6 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/shell.js @@ -0,0 +1,577 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestsuite = 'ecma'; + +/* + * Date functions used by tests in Date suite + * + */ +var msPerDay = 86400000; +var HoursPerDay = 24; +var MinutesPerHour = 60; +var SecondsPerMinute = 60; +var msPerSecond = 1000; +var msPerMinute = 60000; // msPerSecond * SecondsPerMinute +var msPerHour = 3600000; // msPerMinute * MinutesPerHour +var TZ_DIFF = getTimeZoneDiff(); // offset of tester's timezone from UTC +var TZ_ADJUST = TZ_DIFF * msPerHour; +var TZ_PST = -8; // offset of Pacific Standard Time from UTC +var PST_DIFF = TZ_DIFF - TZ_PST; // offset of tester's timezone from PST +var PST_ADJUST = TZ_PST * msPerHour; +var TIME_0000 = (function () + { // calculate time for year 0 + for ( var time = 0, year = 1969; year >= 0; year-- ) { + time -= TimeInYear(year); + } + return time; + })(); +var TIME_1970 = 0; +var TIME_2000 = 946684800000; +var TIME_1900 = -2208988800000; +var UTC_FEB_29_2000 = TIME_2000 + 31*msPerDay + 28*msPerDay; +var UTC_JAN_1_2005 = TIME_2000 + TimeInYear(2000) + TimeInYear(2001) + + TimeInYear(2002) + TimeInYear(2003) + TimeInYear(2004); +var now = new Date(); +var TIME_NOW = now.valueOf(); //valueOf() is to accurate to the millisecond + //Date.parse() is accurate only to the second + +/* + * Originally, the test suite used a hard-coded value TZ_DIFF = -8. + * But that was only valid for testers in the Pacific Standard Time Zone! + * We calculate the proper number dynamically for any tester. We just + * have to be careful not to use a date subject to Daylight Savings Time... + */ +function getTimeZoneDiff() +{ + return -((new Date(2000, 1, 1)).getTimezoneOffset())/60; +} + +/* + * Date test "ResultArrays" are hard-coded for Pacific Standard Time. + * We must adjust them for the tester's own timezone - + */ +function adjustResultArray(ResultArray, msMode) +{ + // If the tester's system clock is in PST, no need to continue - +// if (!PST_DIFF) {return;} + + /* The date gTestcases instantiate Date objects in two different ways: + * + * millisecond mode: e.g. dt = new Date(10000000); + * year-month-day mode: dt = new Date(2000, 5, 1, ...); + * + * In the first case, the date is measured from Time 0 in Greenwich (i.e. UTC). + * In the second case, it is measured with reference to the tester's local timezone. + * + * In the first case we must correct those values expected for local measurements, + * like dt.getHours() etc. No correction is necessary for dt.getUTCHours() etc. + * + * In the second case, it is exactly the other way around - + */ + if (msMode) + { + // The hard-coded UTC milliseconds from Time 0 derives from a UTC date. + // Shift to the right by the offset between UTC and the tester. + var t = ResultArray[TIME] + TZ_DIFF*msPerHour; + + // Use our date arithmetic functions to determine the local hour, day, etc. + ResultArray[HOURS] = HourFromTime(t); + ResultArray[DAY] = WeekDay(t); + ResultArray[DATE] = DateFromTime(t); + ResultArray[MONTH] = MonthFromTime(t); + ResultArray[YEAR] = YearFromTime(t); + } + else + { + // The hard-coded UTC milliseconds from Time 0 derives from a PST date. + // Shift to the left by the offset between PST and the tester. + var t = ResultArray[TIME] - PST_DIFF*msPerHour; + + // Use our date arithmetic functions to determine the UTC hour, day, etc. + ResultArray[TIME] = t; + ResultArray[UTC_HOURS] = HourFromTime(t); + ResultArray[UTC_DAY] = WeekDay(t); + ResultArray[UTC_DATE] = DateFromTime(t); + ResultArray[UTC_MONTH] = MonthFromTime(t); + ResultArray[UTC_YEAR] = YearFromTime(t); + } +} + +function Day( t ) { + return ( Math.floor(t/msPerDay ) ); +} +function DaysInYear( y ) { + if ( y % 4 != 0 ) { + return 365; + } + if ( (y % 4 == 0) && (y % 100 != 0) ) { + return 366; + } + if ( (y % 100 == 0) && (y % 400 != 0) ) { + return 365; + } + if ( (y % 400 == 0) ){ + return 366; + } else { + return "ERROR: DaysInYear(" + y + ") case not covered"; + } +} +function TimeInYear( y ) { + return ( DaysInYear(y) * msPerDay ); +} +function DayNumber( t ) { + return ( Math.floor( t / msPerDay ) ); +} +function TimeWithinDay( t ) { + if ( t < 0 ) { + return ( (t % msPerDay) + msPerDay ); + } else { + return ( t % msPerDay ); + } +} +function YearNumber( t ) { +} +function TimeFromYear( y ) { + return ( msPerDay * DayFromYear(y) ); +} +function DayFromYear( y ) { + return ( 365*(y-1970) + + Math.floor((y-1969)/4) - + Math.floor((y-1901)/100) + + Math.floor((y-1601)/400) ); +} +function InLeapYear( t ) { + if ( DaysInYear(YearFromTime(t)) == 365 ) { + return 0; + } + if ( DaysInYear(YearFromTime(t)) == 366 ) { + return 1; + } else { + return "ERROR: InLeapYear("+ t + ") case not covered"; + } +} +function YearFromTime( t ) { + t = Number( t ); + var sign = ( t < 0 ) ? -1 : 1; + var year = ( sign < 0 ) ? 1969 : 1970; + for ( var timeToTimeZero = t; ; ) { + // subtract the current year's time from the time that's left. + timeToTimeZero -= sign * TimeInYear(year) + + // if there's less than the current year's worth of time left, then break. + if ( sign < 0 ) { + if ( sign * timeToTimeZero <= 0 ) { + break; + } else { + year += sign; + } + } else { + if ( sign * timeToTimeZero < 0 ) { + break; + } else { + year += sign; + } + } + } + return ( year ); +} +function MonthFromTime( t ) { + // i know i could use switch but i'd rather not until it's part of ECMA + var day = DayWithinYear( t ); + var leap = InLeapYear(t); + + if ( (0 <= day) && (day < 31) ) { + return 0; + } + if ( (31 <= day) && (day < (59+leap)) ) { + return 1; + } + if ( ((59+leap) <= day) && (day < (90+leap)) ) { + return 2; + } + if ( ((90+leap) <= day) && (day < (120+leap)) ) { + return 3; + } + if ( ((120+leap) <= day) && (day < (151+leap)) ) { + return 4; + } + if ( ((151+leap) <= day) && (day < (181+leap)) ) { + return 5; + } + if ( ((181+leap) <= day) && (day < (212+leap)) ) { + return 6; + } + if ( ((212+leap) <= day) && (day < (243+leap)) ) { + return 7; + } + if ( ((243+leap) <= day) && (day < (273+leap)) ) { + return 8; + } + if ( ((273+leap) <= day) && (day < (304+leap)) ) { + return 9; + } + if ( ((304+leap) <= day) && (day < (334+leap)) ) { + return 10; + } + if ( ((334+leap) <= day) && (day < (365+leap)) ) { + return 11; + } else { + return "ERROR: MonthFromTime("+t+") not known"; + } +} +function DayWithinYear( t ) { + return( Day(t) - DayFromYear(YearFromTime(t))); +} +function DateFromTime( t ) { + var day = DayWithinYear(t); + var month = MonthFromTime(t); + + if ( month == 0 ) { + return ( day + 1 ); + } + if ( month == 1 ) { + return ( day - 30 ); + } + if ( month == 2 ) { + return ( day - 58 - InLeapYear(t) ); + } + if ( month == 3 ) { + return ( day - 89 - InLeapYear(t)); + } + if ( month == 4 ) { + return ( day - 119 - InLeapYear(t)); + } + if ( month == 5 ) { + return ( day - 150- InLeapYear(t)); + } + if ( month == 6 ) { + return ( day - 180- InLeapYear(t)); + } + if ( month == 7 ) { + return ( day - 211- InLeapYear(t)); + } + if ( month == 8 ) { + return ( day - 242- InLeapYear(t)); + } + if ( month == 9 ) { + return ( day - 272- InLeapYear(t)); + } + if ( month == 10 ) { + return ( day - 303- InLeapYear(t)); + } + if ( month == 11 ) { + return ( day - 333- InLeapYear(t)); + } + + return ("ERROR: DateFromTime("+t+") not known" ); +} +function WeekDay( t ) { + var weekday = (Day(t)+4) % 7; + return( weekday < 0 ? 7 + weekday : weekday ); +} + +// missing daylight savings time adjustment + +function HourFromTime( t ) { + var h = Math.floor( t / msPerHour ) % HoursPerDay; + return ( (h<0) ? HoursPerDay + h : h ); +} +function MinFromTime( t ) { + var min = Math.floor( t / msPerMinute ) % MinutesPerHour; + return( ( min < 0 ) ? MinutesPerHour + min : min ); +} +function SecFromTime( t ) { + var sec = Math.floor( t / msPerSecond ) % SecondsPerMinute; + return ( (sec < 0 ) ? SecondsPerMinute + sec : sec ); +} +function msFromTime( t ) { + var ms = t % msPerSecond; + return ( (ms < 0 ) ? msPerSecond + ms : ms ); +} +function LocalTZA() { + return ( TZ_DIFF * msPerHour ); +} +function UTC( t ) { + return ( t - LocalTZA() - DaylightSavingTA(t - LocalTZA()) ); +} +function LocalTime( t ) { + return ( t + LocalTZA() + DaylightSavingTA(t) ); +} +function DaylightSavingTA( t ) { + t = t - LocalTZA(); + + var dst_start = GetDSTStart(t); + var dst_end = GetDSTEnd(t); + + if ( t >= dst_start && t < dst_end ) + return msPerHour; + + return 0; +} + +function GetFirstSundayInMonth( t, m ) { + var year = YearFromTime(t); + var leap = InLeapYear(t); + +// month m 0..11 +// april == 3 +// march == 2 + + // set time to first day of month m + var time = TimeFromYear(year); + for (var i = 0; i < m; ++i) + { + time += TimeInMonth(i, leap); + } + + for ( var first_sunday = time; WeekDay(first_sunday) > 0; + first_sunday += msPerDay ) + { + ; + } + + return first_sunday; +} + +function GetLastSundayInMonth( t, m ) { + var year = YearFromTime(t); + var leap = InLeapYear(t); + +// month m 0..11 +// april == 3 +// march == 2 + + // first day of following month + var time = TimeFromYear(year); + for (var i = 0; i <= m; ++i) + { + time += TimeInMonth(i, leap); + } + // prev day == last day of month + time -= msPerDay; + + for ( var last_sunday = time; WeekDay(last_sunday) > 0; + last_sunday -= msPerDay ) + { + ; + } + return last_sunday; +} + +/* + 15.9.1.9 Daylight Saving Time Adjustment + + The implementation of ECMAScript should not try to determine whether + the exact time was subject to daylight saving time, but just whether + daylight saving time would have been in effect if the current + daylight saving time algorithm had been used at the time. This avoids + complications such as taking into account the years that the locale + observed daylight saving time year round. +*/ + +/* + US DST algorithm + + Before 2007, DST starts first Sunday in April at 2 AM and ends last + Sunday in October at 2 AM + + Starting in 2007, DST starts second Sunday in March at 2 AM and ends + first Sunday in November at 2 AM + + Note that different operating systems behave differently. + + Fully patched Windows XP uses the 2007 algorithm for all dates while + fully patched Fedora Core 6 and RHEL 4 Linux use the algorithm in + effect at the time. + + Since pre-2007 DST is a subset of 2007 DST rules, this only affects + tests that occur in the period Mar-Apr and Oct-Nov where the two + algorithms do not agree. + +*/ + +function GetDSTStart( t ) +{ + return (GetFirstSundayInMonth(t, 2) + 7*msPerDay + 2*msPerHour - LocalTZA()); +} + +function GetDSTEnd( t ) +{ + return (GetFirstSundayInMonth(t, 10) + 2*msPerHour - LocalTZA()); +} + +function GetOldDSTStart( t ) +{ + return (GetFirstSundayInMonth(t, 3) + 2*msPerHour - LocalTZA()); +} + +function GetOldDSTEnd( t ) +{ + return (GetLastSundayInMonth(t, 9) + 2*msPerHour - LocalTZA()); +} + +function MakeTime( hour, min, sec, ms ) { + if ( isNaN( hour ) || isNaN( min ) || isNaN( sec ) || isNaN( ms ) ) { + return Number.NaN; + } + + hour = ToInteger(hour); + min = ToInteger( min); + sec = ToInteger( sec); + ms = ToInteger( ms ); + + return( (hour*msPerHour) + (min*msPerMinute) + + (sec*msPerSecond) + ms ); +} +function MakeDay( year, month, date ) { + if ( isNaN(year) || isNaN(month) || isNaN(date) ) { + return Number.NaN; + } + year = ToInteger(year); + month = ToInteger(month); + date = ToInteger(date ); + + var sign = ( year < 1970 ) ? -1 : 1; + var t = ( year < 1970 ) ? 1 : 0; + var y = ( year < 1970 ) ? 1969 : 1970; + + var result5 = year + Math.floor( month/12 ); + var result6 = month % 12; + + if ( year < 1970 ) { + for ( y = 1969; y >= year; y += sign ) { + t += sign * TimeInYear(y); + } + } else { + for ( y = 1970 ; y < year; y += sign ) { + t += sign * TimeInYear(y); + } + } + + var leap = InLeapYear( t ); + + for ( var m = 0; m < month; m++ ) { + t += TimeInMonth( m, leap ); + } + + if ( YearFromTime(t) != result5 ) { + return Number.NaN; + } + if ( MonthFromTime(t) != result6 ) { + return Number.NaN; + } + if ( DateFromTime(t) != 1 ) { + return Number.NaN; + } + + return ( (Day(t)) + date - 1 ); +} +function TimeInMonth( month, leap ) { + // september april june november + // jan 0 feb 1 mar 2 apr 3 may 4 june 5 jul 6 + // aug 7 sep 8 oct 9 nov 10 dec 11 + + if ( month == 3 || month == 5 || month == 8 || month == 10 ) { + return ( 30*msPerDay ); + } + + // all the rest + if ( month == 0 || month == 2 || month == 4 || month == 6 || + month == 7 || month == 9 || month == 11 ) { + return ( 31*msPerDay ); + } + + // save february + return ( (leap == 0) ? 28*msPerDay : 29*msPerDay ); +} +function MakeDate( day, time ) { + if ( day == Number.POSITIVE_INFINITY || + day == Number.NEGATIVE_INFINITY ) { + return Number.NaN; + } + if ( time == Number.POSITIVE_INFINITY || + time == Number.NEGATIVE_INFINITY ) { + return Number.NaN; + } + return ( day * msPerDay ) + time; +} +function TimeClip( t ) { + if ( isNaN( t ) ) { + return ( Number.NaN ); + } + if ( Math.abs( t ) > 8.64e15 ) { + return ( Number.NaN ); + } + + return ( ToInteger( t ) ); +} +function ToInteger( t ) { + t = Number( t ); + + if ( isNaN( t ) ){ + return ( Number.NaN ); + } + if ( t == 0 || t == -0 || + t == Number.POSITIVE_INFINITY || t == Number.NEGATIVE_INFINITY ) { + return 0; + } + + var sign = ( t < 0 ) ? -1 : 1; + + return ( sign * Math.floor( Math.abs( t ) ) ); +} +function Enumerate ( o ) { + var p; + for ( p in o ) { + print( p +": " + o[p] ); + } +} + +/* these functions are useful for running tests manually in Rhino */ + +function GetContext() { + return Packages.com.netscape.javascript.Context.getCurrentContext(); +} +function OptLevel( i ) { + i = Number(i); + var cx = GetContext(); + cx.setOptimizationLevel(i); +} +/* end of Rhino functions */ + diff --git a/tests/auto/qml/parserstress/tests/ecma/template.js b/tests/auto/qml/parserstress/tests/ecma/template.js new file mode 100644 index 0000000000..8f11686890 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma/template.js @@ -0,0 +1,70 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is JavaScript Engine testing utilities. + * + * The Initial Developer of the Original Code is + * Mozilla Foundation. + * Portions created by the Initial Developer are Copyright (C) 2007 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = 'template.js'; + +/** + * File Name: template.js + * Reference: ** replace with bugzilla URL or document reference ** + * Description: ** replace with description of test ** + * Author: ** replace with your e-mail address ** + */ + +var SECTION = ""; // provide a document reference (ie, ECMA section) +var VERSION = "ECMA"; // Version of JavaScript or ECMA +var TITLE = ""; // Provide ECMA section title or a description +var BUGNUMBER = ""; // Provide URL to bugsplat or bugzilla report + +startTest(); // leave this alone + +/* + * Calls to AddTestCase here. AddTestCase is a function that is defined + * in shell.js and takes three arguments: + * - a string representation of what is being tested + * - the expected result + * - the actual result + * + * For example, a test might look like this: + * + * AddTestCase("** description", + * "** expected value", + * "** actual value"); + */ + +// leave this alone. this executes the test cases and +// displays results. +test(); diff --git a/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/boolean-001.js b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/boolean-001.js new file mode 100644 index 0000000000..7462df2f98 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/boolean-001.js @@ -0,0 +1,80 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is JavaScript Engine testing utilities. + * + * The Initial Developer of the Original Code is + * Netscape Communication Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = 'boolean-001.js'; + +/** + File Name: boolean-001.js + Description: Corresponds to ecma/Boolean/15.6.4.2-4-n.js + + The toString function is not generic; it generates + a runtime error if its this value is not a Boolean + object. Therefore it cannot be transferred to other + kinds of objects for use as a method. + + Author: christine@netscape.com + Date: june 27, 1997 +*/ +var SECTION = "boolean-001.js"; +var VERSION = "JS1_4"; +var TITLE = "Boolean.prototype.toString()"; +startTest(); +writeHeaderToLog( SECTION +" "+ TITLE ); + +var exception = "No exception thrown"; +var result = "Failed"; + +var TO_STRING = Boolean.prototype.toString; + +try { + var s = new String("Not a Boolean"); + s.toString = TO_STRING; + s.toString(); +} catch ( e ) { + result = "Passed!"; + exception = e.toString(); +} + +new TestCase( + SECTION, + "Assigning Boolean.prototype.toString to a String object "+ + "(threw " +exception +")", + "Passed!", + result ); + +test(); + diff --git a/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/boolean-002.js b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/boolean-002.js new file mode 100644 index 0000000000..813e11cd39 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/boolean-002.js @@ -0,0 +1,84 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is JavaScript Engine testing utilities. + * + * The Initial Developer of the Original Code is + * Netscape Communication Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = 'boolean-002.js'; + +/** + File Name: boolean-001.js + Description: Corresponds to ecma/Boolean/15.6.4.3-4-n.js + + 15.6.4.3 Boolean.prototype.valueOf() + Returns this boolean value. + + The valueOf function is not generic; it generates + a runtime error if its this value is not a Boolean + object. Therefore it cannot be transferred to other + kinds of objects for use as a method. + + Author: christine@netscape.com + Date: 09 september 1998 +*/ +var SECTION = "boolean-002.js"; +var VERSION = "JS1_4"; +var TITLE = "Boolean.prototype.valueOf()"; +startTest(); +writeHeaderToLog( SECTION +" "+ TITLE ); + + +var exception = "No exception thrown"; +var result = "Failed"; + +var VALUE_OF = Boolean.prototype.valueOf; + +try { + var s = new String("Not a Boolean"); + s.valueOf = VALUE_0F; + s.valueOf(); +} catch ( e ) { + result = "Passed!"; + exception = e.toString(); +} + +new TestCase( + SECTION, + "Assigning Boolean.prototype.valueOf to a String object "+ + "(threw " +exception +")", + "Passed!", + result ); + +test(); + diff --git a/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/browser.js b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/browser.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/date-001.js b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/date-001.js new file mode 100644 index 0000000000..041bbb523c --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/date-001.js @@ -0,0 +1,93 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is JavaScript Engine testing utilities. + * + * The Initial Developer of the Original Code is + * Netscape Communication Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = 'date-001.js'; + +/** + File Name: date-001.js + Corresponds To: 15.9.5.2-2.js + ECMA Section: 15.9.5.2 Date.prototype.toString + Description: + This function returns a string value. The contents of the string are + implementation dependent, but are intended to represent the Date in a + convenient, human-readable form in the current time zone. + + The toString function is not generic; it generates a runtime error if its + this value is not a Date object. Therefore it cannot be transferred to + other kinds of objects for use as a method. + + + This verifies that calling toString on an object that is not a string + generates a runtime error. + + Author: christine@netscape.com + Date: 12 november 1997 +*/ +var SECTION = "date-001"; +var VERSION = "JS1_4"; +var TITLE = "Date.prototype.toString"; + +startTest(); +writeHeaderToLog( SECTION + " "+ TITLE); + +var result = "Failed"; +var exception = "No exception thrown"; +var expect = "Passed"; + +try { + var OBJ = new MyObject( new Date(0) ); + result = OBJ.toString(); +} catch ( e ) { + result = expect; + exception = e.toString(); +} + +new TestCase( + SECTION, + "OBJECT = new MyObject( new Date(0)) ; result = OBJ.toString()" + + " (threw " + exception +")", + expect, + result ); + +test(); + +function MyObject( value ) { + this.value = value; + this.valueOf = new Function( "return this.value" ); + this.toString = Date.prototype.toString; + return this; +} diff --git a/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/date-002.js b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/date-002.js new file mode 100644 index 0000000000..4fb11b38d9 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/date-002.js @@ -0,0 +1,87 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is JavaScript Engine testing utilities. + * + * The Initial Developer of the Original Code is + * Netscape Communication Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = 'date-002.js'; + +/** + File Name: date-002.js + Corresponds To: 15.9.5.23-3-n.js + ECMA Section: 15.9.5.23 + Description: Date.prototype.setTime + + 1. If the this value is not a Date object, generate a runtime error. + 2. Call ToNumber(time). + 3. Call TimeClip(Result(1)). + 4. Set the [[Value]] property of the this value to Result(2). + 5. Return the value of the [[Value]] property of the this value. + + Author: christine@netscape.com + Date: 12 november 1997 +*/ +var SECTION = "date-002"; +var VERSION = "JS1_4"; +var TITLE = "Date.prototype.setTime()"; + +startTest(); +writeHeaderToLog( SECTION + " "+ TITLE); + +var result = "Failed"; +var exception = "No exception thrown"; +var expect = "Passed"; + +try { + var MYDATE = new MyDate(); + result = MYDATE.setTime(0); +} catch ( e ) { + result = expect; + exception = e.toString(); +} + +new TestCase( + SECTION, + "MYDATE = new MyDate(); MYDATE.setTime(0)" + + " (threw " + exception +")", + expect, + result ); + +test(); + +function MyDate(value) { + this.value = value; + this.setTime = Date.prototype.setTime; + return this; +} diff --git a/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/date-003.js b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/date-003.js new file mode 100644 index 0000000000..95129177c7 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/date-003.js @@ -0,0 +1,89 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is JavaScript Engine testing utilities. + * + * The Initial Developer of the Original Code is + * Netscape Communication Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = 'date-003.js'; + +/** + File Name: date-003.js + Corresponds To 15.9.5.3-1.js + ECMA Section: 15.9.5.3-1 Date.prototype.valueOf + Description: + + The valueOf function returns a number, which is this time value. + + The valueOf function is not generic; it generates a runtime error if + its this value is not a Date object. Therefore it cannot be transferred + to other kinds of objects for use as a method. + + Author: christine@netscape.com + Date: 12 november 1997 +*/ +var SECTION = "date-003"; +var VERSION = "JS1_4"; +var TITLE = "Date.prototype.valueOf"; + +startTest(); +writeHeaderToLog( SECTION + " "+ TITLE); + +var result = "Failed"; +var exception = "No exception thrown"; +var expect = "Passed"; + +try { + var OBJ = new MyObject( new Date(0) ); + result = OBJ.valueOf(); +} catch ( e ) { + result = expect; + exception = e.toString(); +} + +new TestCase( + SECTION, + "OBJ = new MyObject( new Date(0)); OBJ.valueOf()" + + " (threw " + exception +")", + expect, + result ); + +test(); + +function MyObject( value ) { + this.value = value; + this.valueOf = Date.prototype.valueOf; +// The following line causes an infinte loop +// this.toString = new Function( "return this+\"\";"); + return this; +} diff --git a/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/date-004.js b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/date-004.js new file mode 100644 index 0000000000..d77bd1c272 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/date-004.js @@ -0,0 +1,83 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is JavaScript Engine testing utilities. + * + * The Initial Developer of the Original Code is + * Netscape Communication Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = 'date-004.js'; + +/** + File Name: date-004.js + Corresponds To: 15.9.5.4-2-n.js + ECMA Section: 15.9.5.4-1 Date.prototype.getTime + Description: + + 1. If the this value is not an object whose [[Class]] property is "Date", + generate a runtime error. + 2. Return this time value. + Author: christine@netscape.com + Date: 12 november 1997 +*/ +var SECTION = "date-004"; +var VERSION = "JS1_4"; +var TITLE = "Date.prototype.getTime"; + +startTest(); +writeHeaderToLog( SECTION + " "+ TITLE); + +var result = "Failed"; +var exception = "No exception thrown"; +var expect = "Passed"; + +try { + var MYDATE = new MyDate(); + result = MYDATE.getTime(); +} catch ( e ) { + result = expect; + exception = e.toString(); +} + +new TestCase( + SECTION, + "MYDATE = new MyDate(); MYDATE.getTime()" + + " (threw " + exception +")", + expect, + result ); + +test(); + +function MyDate( value ) { + this.value = value; + this.getTime = Date.prototype.getTime; +} diff --git a/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/exception-001.js b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/exception-001.js new file mode 100644 index 0000000000..3762c5b3c4 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/exception-001.js @@ -0,0 +1,78 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is JavaScript Engine testing utilities. + * + * The Initial Developer of the Original Code is + * Netscape Communication Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = 'exception-001.js'; + +/** + * File Name: exception-001 + * ECMA Section: + * Description: Tests for JavaScript Standard Exceptions + * + * Call error. + * + * Author: christine@netscape.com + * Date: 31 August 1998 + */ +var SECTION = "exception-001"; +var VERSION = "js1_4"; +var TITLE = "Tests for JavaScript Standard Exceptions: CallError"; + +startTest(); +writeHeaderToLog( SECTION + " "+ TITLE); + +Call_1(); + +test(); + +function Call_1() { + result = "failed: no exception thrown"; + exception = null; + + try { + Math(); + } catch ( e ) { + result = "passed: threw exception", + exception = e.toString(); + } finally { + new TestCase( + SECTION, + "Math() [ exception is " + exception +" ]", + "passed: threw exception", + result ); + } +} + diff --git a/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/exception-002.js b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/exception-002.js new file mode 100644 index 0000000000..e5328b8b81 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/exception-002.js @@ -0,0 +1,78 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is JavaScript Engine testing utilities. + * + * The Initial Developer of the Original Code is + * Netscape Communication Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = 'exception-002.js'; + +/** + * File Name: exception-002 + * ECMA Section: + * Description: Tests for JavaScript Standard Exceptions + * + * Construct error. + * + * Author: christine@netscape.com + * Date: 31 August 1998 + */ +var SECTION = "exception-002"; +var VERSION = "js1_4"; +var TITLE = "Tests for JavaScript Standard Exceptions: ConstructError"; + +startTest(); +writeHeaderToLog( SECTION + " "+ TITLE); + +Construct_1(); + +test(); + +function Construct_1() { + result = "failed: no exception thrown"; + exception = null; + + try { + result = new Math(); + } catch ( e ) { + result = "passed: threw exception", + exception = e.toString(); + } finally { + new TestCase( + SECTION, + "new Math() [ exception is " + exception +" ]", + "passed: threw exception", + result ); + } +} + diff --git a/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/exception-003.js b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/exception-003.js new file mode 100644 index 0000000000..c5956ffc95 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/exception-003.js @@ -0,0 +1,82 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is JavaScript Engine testing utilities. + * + * The Initial Developer of the Original Code is + * Netscape Communication Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = 'exception-003.js'; + +/** + * File Name: exception-003 + * ECMA Section: + * Description: Tests for JavaScript Standard Exceptions + * + * Target error. + * + * Author: christine@netscape.com + * Date: 31 August 1998 + */ +var SECTION = "exception-003"; +var VERSION = "js1_4"; +var TITLE = "Tests for JavaScript Standard Exceptions: TargetError"; + +startTest(); +writeHeaderToLog( SECTION + " "+ TITLE); + +Target_1(); + +test(); + +function Target_1() { + result = "failed: no exception thrown"; + exception = null; + + try { + string = new String("hi"); + string.toString = Boolean.prototype.toString; + string.toString(); + } catch ( e ) { + result = "passed: threw exception", + exception = e.toString(); + } finally { + new TestCase( + SECTION, + "string = new String(\"hi\");"+ + "string.toString = Boolean.prototype.toString" + + "string.toString() [ exception is " + exception +" ]", + "passed: threw exception", + result ); + } +} + diff --git a/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/exception-004.js b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/exception-004.js new file mode 100644 index 0000000000..15a07a806f --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/exception-004.js @@ -0,0 +1,78 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is JavaScript Engine testing utilities. + * + * The Initial Developer of the Original Code is + * Netscape Communication Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = 'exception-004.js'; + +/** + * File Name: exception-004 + * ECMA Section: + * Description: Tests for JavaScript Standard Exceptions + * + * ToObject error. + * + * Author: christine@netscape.com + * Date: 31 August 1998 + */ +var SECTION = "exception-004"; +var VERSION = "js1_4"; +var TITLE = "Tests for JavaScript Standard Exceptions: ToObjectError"; + +startTest(); +writeHeaderToLog( SECTION + " "+ TITLE); + +ToObject_1(); + +test(); + +function ToObject_1() { + result = "failed: no exception thrown"; + exception = null; + + try { + result = foo["bar"]; + } catch ( e ) { + result = "passed: threw exception", + exception = e.toString(); + } finally { + new TestCase( + SECTION, + "foo[\"bar\"] [ exception is " + exception +" ]", + "passed: threw exception", + result ); + } +} + diff --git a/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/exception-005.js b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/exception-005.js new file mode 100644 index 0000000000..e5532ff40c --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/exception-005.js @@ -0,0 +1,78 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is JavaScript Engine testing utilities. + * + * The Initial Developer of the Original Code is + * Netscape Communication Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = 'exception-005.js'; + +/** + * File Name: exception-005 + * ECMA Section: + * Description: Tests for JavaScript Standard Exceptions + * + * ToObject error. + * + * Author: christine@netscape.com + * Date: 31 August 1998 + */ +var SECTION = "exception-005"; +var VERSION = "js1_4"; +var TITLE = "Tests for JavaScript Standard Exceptions: ToObjectError"; + +startTest(); +writeHeaderToLog( SECTION + " "+ TITLE); + +ToObject_1(); + +test(); + +function ToObject_1() { + result = "failed: no exception thrown"; + exception = null; + + try { + result = foo["bar"]; + } catch ( e ) { + result = "passed: threw exception", + exception = e.toString(); + } finally { + new TestCase( + SECTION, + "foo[\"bar\"] [ exception is " + exception +" ]", + "passed: threw exception", + result ); + } +} + diff --git a/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/exception-006.js b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/exception-006.js new file mode 100644 index 0000000000..b37b52becb --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/exception-006.js @@ -0,0 +1,89 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is JavaScript Engine testing utilities. + * + * The Initial Developer of the Original Code is + * Netscape Communication Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = 'exception-006.js'; + +/** + * File Name: exception-006 + * ECMA Section: + * Description: Tests for JavaScript Standard Exceptions + * + * ToPrimitive error. + * + * Author: christine@netscape.com + * Date: 31 August 1998 + */ +var SECTION = "exception-006"; +var VERSION = "js1_4"; +var TITLE = "Tests for JavaScript Standard Exceptions: TypeError"; + +startTest(); +writeHeaderToLog( SECTION + " "+ TITLE); + +ToPrimitive_1(); + +test(); + + +/** + * Getting the [[DefaultValue]] of any instances of MyObject + * should result in a runtime error in ToPrimitive. + */ + +function MyObject() { + this.toString = void 0; + this.valueOf = void 0; +} + +function ToPrimitive_1() { + result = "failed: no exception thrown"; + exception = null; + + try { + result = new MyObject() + new MyObject(); + } catch ( e ) { + result = "passed: threw exception", + exception = e.toString(); + } finally { + new TestCase( + SECTION, + "new MyObject() + new MyObject() [ exception is " + exception +" ]", + "passed: threw exception", + result ); + } +} + diff --git a/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/exception-007.js b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/exception-007.js new file mode 100644 index 0000000000..a63ed0e3f8 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/exception-007.js @@ -0,0 +1,90 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is JavaScript Engine testing utilities. + * + * The Initial Developer of the Original Code is + * Netscape Communication Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = 'exception-007.js'; + +/** + * File Name: exception-007 + * ECMA Section: + * Description: Tests for JavaScript Standard Exceptions + * + * DefaultValue error. + * + * Author: christine@netscape.com + * Date: 31 August 1998 + */ +var SECTION = "exception-007"; +var VERSION = "js1_4"; +var TITLE = "Tests for JavaScript Standard Exceptions: TypeError"; +var BUGNUMBER="318250"; + +startTest(); +writeHeaderToLog( SECTION + " "+ TITLE); + +DefaultValue_1(); + +test(); + + +/** + * Getting the [[DefaultValue]] of any instances of MyObject + * should result in a runtime error in ToPrimitive. + */ + +function MyObject() { + this.toString = void 0; + this.valueOf = new Object(); +} + +function DefaultValue_1() { + result = "failed: no exception thrown"; + exception = null; + + try { + result = new MyObject() + new MyObject(); + } catch ( e ) { + result = "passed: threw exception", + exception = e.toString(); + } finally { + new TestCase( + SECTION, + "new MyObject() + new MyObject() [ exception is " + exception +" ]", + "passed: threw exception", + result ); + } +} + diff --git a/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/exception-008.js b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/exception-008.js new file mode 100644 index 0000000000..39326183a4 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/exception-008.js @@ -0,0 +1,77 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is JavaScript Engine testing utilities. + * + * The Initial Developer of the Original Code is + * Netscape Communication Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = 'exception-008.js'; + +/** + * File Name: exception-008 + * ECMA Section: + * Description: Tests for JavaScript Standard Exceptions + * + * SyntaxError. + * + * Author: christine@netscape.com + * Date: 31 August 1998 + */ +var SECTION = "exception-008"; +var VERSION = "js1_4"; +var TITLE = "Tests for JavaScript Standard Exceptions: SyntaxError"; + +startTest(); +writeHeaderToLog( SECTION + " "+ TITLE); + +Syntax_1(); + +test(); + +function Syntax_1() { + result = "failed: no exception thrown"; + exception = null; + + try { + result = eval("continue;"); + } catch ( e ) { + result = "passed: threw exception", + exception = e.toString(); + } finally { + new TestCase( + SECTION, + "eval(\"continue\") [ exception is " + exception +" ]", + "passed: threw exception", + result ); + } +} diff --git a/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/exception-009.js b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/exception-009.js new file mode 100644 index 0000000000..bd5cbe7f40 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/exception-009.js @@ -0,0 +1,86 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is JavaScript Engine testing utilities. + * + * The Initial Developer of the Original Code is + * Netscape Communication Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = 'exception-009.js'; + +/** + * File Name: exception-009 + * ECMA Section: + * Description: Tests for JavaScript Standard Exceptions + * + * Regression test for nested try blocks. + * + * http://scopus.mcom.com/bugsplat/show_bug.cgi?id=312964 + * + * Author: christine@netscape.com + * Date: 31 August 1998 + */ +var SECTION = "exception-009"; +var VERSION = "JS1_4"; +var TITLE = "Tests for JavaScript Standard Exceptions: SyntaxError"; +var BUGNUMBER= "312964"; + +startTest(); +writeHeaderToLog( SECTION + " "+ TITLE); + +try { + expect = "passed: no exception thrown"; + result = expect; + Nested_1(); +} catch ( e ) { + result = "failed: threw " + e; +} finally { + new TestCase( + SECTION, + "nested try", + expect, + result ); +} + + +test(); + +function Nested_1() { + try { + try { + } catch (a) { + } finally { + } + } catch (b) { + } finally { + } +} diff --git a/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/exception-010-n.js b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/exception-010-n.js new file mode 100644 index 0000000000..cb28d635a6 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/exception-010-n.js @@ -0,0 +1,61 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- + * + * ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * Rob Ginda rginda@netscape.com + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = 'exception-010-n.js'; + +var SECTION = "exception-010"; +var VERSION = "ECMA_2"; +startTest(); +var TITLE = "Don't Crash throwing null"; + +writeHeaderToLog( SECTION + " "+ TITLE); +print("Null throw test."); +print("BUGNUMBER: 21799"); + +DESCRIPTION = "throw null"; +EXPECTED = "error"; + +new TestCase( SECTION, "throw null", "error", eval("throw null" )); + +test(); + +print("FAILED!: Should have exited with uncaught exception."); + + diff --git a/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/exception-011-n.js b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/exception-011-n.js new file mode 100644 index 0000000000..ec5302c247 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/exception-011-n.js @@ -0,0 +1,62 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- + * + * ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * Rob Ginda rginda@netscape.com + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = 'exception-011-n.js'; + +var SECTION = "exception-011"; +var VERSION = "ECMA_2"; +startTest(); +var TITLE = "Don't Crash throwing undefined"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +print("Undefined throw test."); + +DESCRIPTION = "throw undefined"; +EXPECTED = "error"; + +new TestCase( SECTION, "throw undefined", "error", eval("throw (void 0)") ); + +test(); + +print("FAILED!: Should have exited with uncaught exception."); + + + diff --git a/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/expression-001.js b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/expression-001.js new file mode 100644 index 0000000000..c3ae4f21e6 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/expression-001.js @@ -0,0 +1,83 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is JavaScript Engine testing utilities. + * + * The Initial Developer of the Original Code is + * Netscape Communication Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = 'expression-001.js'; + +/** + File Name: expression-001.js + Corresponds to: ecma/Expressions/11.12-2-n.js + ECMA Section: 11.12 + Description: + + The grammar for a ConditionalExpression in ECMAScript is a little bit + different from that in C and Java, which each allow the second + subexpression to be an Expression but restrict the third expression to + be a ConditionalExpression. The motivation for this difference in + ECMAScript is to allow an assignment expression to be governed by either + arm of a conditional and to eliminate the confusing and fairly useless + case of a comma expression as the center expression. + + Author: christine@netscape.com + Date: 09 september 1998 +*/ +var SECTION = "expression-001"; +var VERSION = "JS1_4"; +var TITLE = "Conditional operator ( ? : )" + startTest(); +writeHeaderToLog( SECTION + " " + TITLE ); + +// the following expression should be an error in JS. + +var result = "Failed" + var exception = "No exception was thrown"; + +try { + eval("var MY_VAR = true ? \"EXPR1\", \"EXPR2\" : \"EXPR3\""); +} catch ( e ) { + result = "Passed"; + exception = e.toString(); +} + +new TestCase( + SECTION, + "comma expression in a conditional statement "+ + "(threw "+ exception +")", + "Passed", + result ); + + +test(); diff --git a/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/expression-002.js b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/expression-002.js new file mode 100644 index 0000000000..2f060936ae --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/expression-002.js @@ -0,0 +1,93 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is JavaScript Engine testing utilities. + * + * The Initial Developer of the Original Code is + * Netscape Communication Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = 'expression-002.js'; + +/** + File Name: expressions-002.js + Corresponds to: ecma/Expressions/11.2.1-3-n.js + ECMA Section: 11.2.1 Property Accessors + Description: + + Try to access properties of an object whose value is undefined. + + Author: christine@netscape.com + Date: 09 september 1998 +*/ +var SECTION = "expressions-002.js"; +var VERSION = "JS1_4"; +var TITLE = "Property Accessors"; +writeHeaderToLog( SECTION + " "+TITLE ); + +startTest(); + +// go through all Native Function objects, methods, and properties and get their typeof. + +var PROPERTY = new Array(); +var p = 0; + +// try to access properties of primitive types + +OBJECT = new Property( "undefined", void 0, "undefined", NaN ); + +var result = "Failed"; +var exception = "No exception thrown"; +var expect = "Passed"; + +try { + result = OBJECT.value.valueOf(); +} catch ( e ) { + result = expect; + exception = e.toString(); +} + + +new TestCase( + SECTION, + "Get the value of an object whose value is undefined "+ + "(threw " + exception +")", + expect, + result ); + +test(); + +function Property( object, value, string, number ) { + this.object = object; + this.string = String(value); + this.number = Number(value); + this.valueOf = value; +} diff --git a/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/expression-003.js b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/expression-003.js new file mode 100644 index 0000000000..5007b83adf --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/expression-003.js @@ -0,0 +1,88 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is JavaScript Engine testing utilities. + * + * The Initial Developer of the Original Code is + * Netscape Communication Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = 'expression-003.js'; + +/** + File Name: expressions-003.js + Corresponds to: ecma/Expressions/11.2.1-3-n.js + ECMA Section: 11.2.1 Property Accessors + Description: + + Try to access properties of an object whose value is undefined. + + Author: christine@netscape.com + Date: 09 september 1998 +*/ +var SECTION = "expressions-003.js"; +var VERSION = "JS1_4"; +var TITLE = "Property Accessors"; +writeHeaderToLog( SECTION + " "+TITLE ); + +startTest(); + +// try to access properties of primitive types + +OBJECT = new Property( "undefined", void 0, "undefined", NaN ); + +var result = "Failed"; +var exception = "No exception thrown"; +var expect = "Passed"; + +try { + result = OBJECT.value.toString(); +} catch ( e ) { + result = expect; + exception = e.toString(); +} + + +new TestCase( + SECTION, + "Get the toString value of an object whose value is undefined "+ + "(threw " + exception +")", + expect, + result ); + +test(); + +function Property( object, value, string, number ) { + this.object = object; + this.string = String(value); + this.number = Number(value); + this.value = value; +} diff --git a/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/expression-004.js b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/expression-004.js new file mode 100644 index 0000000000..2befdd10f3 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/expression-004.js @@ -0,0 +1,82 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is JavaScript Engine testing utilities. + * + * The Initial Developer of the Original Code is + * Netscape Communication Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = 'expression-004.js'; + +/** + File Name: expression-004.js + Corresponds To: 11.2.1-4-n.js + ECMA Section: 11.2.1 Property Accessors + Description: + + Author: christine@netscape.com + Date: 09 september 1998 +*/ +var SECTION = "expression-004"; +var VERSION = "JS1_4"; +var TITLE = "Property Accessors"; +writeHeaderToLog( SECTION + " "+TITLE ); +startTest(); + +var OBJECT = new Property( "null", null, "null", 0 ); + +var result = "Failed"; +var exception = "No exception thrown"; +var expect = "Passed"; + +try { + result = OBJECT.value.toString(); +} catch ( e ) { + result = expect; + exception = e.toString(); +} + +new TestCase( + SECTION, + "Get the toString value of an object whose value is null "+ + "(threw " + exception +")", + expect, + result ); + +test(); + +function Property( object, value, string, number ) { + this.object = object; + this.string = String(value); + this.number = Number(value); + this.value = value; +} diff --git a/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/expression-005.js b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/expression-005.js new file mode 100644 index 0000000000..2d76593ea2 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/expression-005.js @@ -0,0 +1,74 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is JavaScript Engine testing utilities. + * + * The Initial Developer of the Original Code is + * Netscape Communication Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = 'expression-005.js'; + +/** + File Name: expression-005.js + Corresponds To: 11.2.2-10-n.js + ECMA Section: 11.2.2. The new operator + Description: + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + +var SECTION = "expression-005"; +var VERSION = "JS1_4"; +var TITLE = "The new operator"; + +startTest(); +writeHeaderToLog( SECTION + " "+ TITLE); + +var result = "Failed"; +var expect = "Passed"; +var exception = "No exception thrown"; + +try { + result = new Math(); +} catch ( e ) { + result = expect; + exception = e.toString(); +} + +new TestCase( + SECTION, + "result= new Math() (threw " + exception + ")", + expect, + result ); + +test(); diff --git a/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/expression-006.js b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/expression-006.js new file mode 100644 index 0000000000..eb21e0308c --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/expression-006.js @@ -0,0 +1,79 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is JavaScript Engine testing utilities. + * + * The Initial Developer of the Original Code is + * Netscape Communication Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = 'expression-006.js'; + +/** + File Name: expression-006.js + Corresponds to: 11.2.2-1-n.js + ECMA Section: 11.2.2. The new operator + Description: + + http://scopus/bugsplat/show_bug.cgi?id=327765 + + Author: christine@netscape.com + Date: 12 november 1997 +*/ +var SECTION = "expression-006.js"; +var VERSION = "JS1_4"; +var TITLE = "The new operator"; +var BUGNUMBER="327765"; + +startTest(); +writeHeaderToLog( SECTION + " "+ TITLE); + +var result = "Failed"; +var exception = "No exception thrown"; +var expect = "Passed"; + +try { + var OBJECT = new Object(); + result = new OBJECT(); +} catch ( e ) { + result = expect; + exception = e.toString(); +} + +new TestCase( + SECTION, + "OBJECT = new Object; result = new OBJECT()" + + " (threw " + exception +")", + expect, + result ); + +test(); + diff --git a/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/expression-007.js b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/expression-007.js new file mode 100644 index 0000000000..a2305be16d --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/expression-007.js @@ -0,0 +1,77 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is JavaScript Engine testing utilities. + * + * The Initial Developer of the Original Code is + * Netscape Communication Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = 'expression-007.js'; + +/** + File Name: expression-007.js + Corresponds To: 11.2.2-2-n.js + ECMA Section: 11.2.2. The new operator + Description: + + + Author: christine@netscape.com + Date: 12 november 1997 +*/ +var SECTION = "expression-007"; +var VERSION = "JS1_4"; +var TITLE = "The new operator"; + +startTest(); +writeHeaderToLog( SECTION + " "+ TITLE); + +var result = "Failed"; +var exception = "No exception thrown"; +var expect = "Passed"; + +try { + UNDEFINED = void 0; + result = new UNDEFINED(); +} catch ( e ) { + result = expect; + exception = e.toString(); +} + +new TestCase( + SECTION, + "UNDEFINED = void 0; result = new UNDEFINED()" + + " (threw " + exception +")", + expect, + result ); + +test(); + diff --git a/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/expression-008.js b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/expression-008.js new file mode 100644 index 0000000000..c85310f957 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/expression-008.js @@ -0,0 +1,74 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is JavaScript Engine testing utilities. + * + * The Initial Developer of the Original Code is + * Netscape Communication Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = 'expression-008.js'; + +/** + File Name: expression-008 + Corresponds To: 11.2.2-3-n.js + ECMA Section: 11.2.2. The new operator + Description: + Author: christine@netscape.com + Date: 12 november 1997 +*/ +var SECTION = "expression-008"; +var VERSION = "JS1_4"; +var TITLE = "The new operator"; + +startTest(); +writeHeaderToLog( SECTION + " "+ TITLE); + +var NULL = null; +var result = "Failed"; +var exception = "No exception thrown"; +var expect = "Passed"; + +try { + result = new NULL(); +} catch ( e ) { + result = expect; + exception = e.toString(); +} + +new TestCase( + SECTION, + "NULL = null; result = new NULL()" + + " (threw " + exception +")", + expect, + result ); + +test(); diff --git a/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/expression-009.js b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/expression-009.js new file mode 100644 index 0000000000..feec2cd052 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/expression-009.js @@ -0,0 +1,75 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is JavaScript Engine testing utilities. + * + * The Initial Developer of the Original Code is + * Netscape Communication Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = 'expression-009.js'; + +/** + File Name: expression-009 + Corresponds to: ecma/Expressions/11.2.2-4-n.js + ECMA Section: 11.2.2. The new operator + Description: + Author: christine@netscape.com + Date: 12 november 1997 +*/ +var SECTION = "expression-009"; +var VERSION = "JS1_4"; +var TITLE = "The new operator"; + +startTest(); +writeHeaderToLog( SECTION + " "+ TITLE); + +var STRING = ""; + +var result = "Failed"; +var exception = "No exception thrown"; +var expect = "Passed"; + +try { + result = new STRING(); +} catch ( e ) { + result = expect; + exception = e.toString(); +} + +new TestCase( + SECTION, + "STRING = ''; result = new STRING()" + + " (threw " + exception +")", + expect, + result ); + +test(); diff --git a/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/expression-010.js b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/expression-010.js new file mode 100644 index 0000000000..e0b38a4838 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/expression-010.js @@ -0,0 +1,76 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is JavaScript Engine testing utilities. + * + * The Initial Developer of the Original Code is + * Netscape Communication Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = 'expression-010.js'; + +/** + File Name: expression-010.js + Corresponds To: 11.2.2-5-n.js + ECMA Section: 11.2.2. The new operator + Description: + Author: christine@netscape.com + Date: 12 november 1997 +*/ +var SECTION = "expression-010"; +var VERSION = "JS1_4"; +var TITLE = "The new operator"; + +startTest(); +writeHeaderToLog( SECTION + " "+ TITLE); + +var NUMBER = 0; + +var result = "Failed"; +var exception = "No exception thrown"; +var expect = "Passed"; + +try { + result = new NUMBER(); +} catch ( e ) { + result = expect; + exception = e.toString(); +} + +new TestCase( + SECTION, + "NUMBER=0, result = new NUMBER()" + + " (threw " + exception +")", + expect, + result ); + +test(); + diff --git a/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/expression-011.js b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/expression-011.js new file mode 100644 index 0000000000..75f872480d --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/expression-011.js @@ -0,0 +1,76 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is JavaScript Engine testing utilities. + * + * The Initial Developer of the Original Code is + * Netscape Communication Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = 'expression-011.js'; + +/** + File Name: expression-011.js + Corresponds To: ecma/Expressions/11.2.2-6-n.js + ECMA Section: 11.2.2. The new operator + Description: + Author: christine@netscape.com + Date: 12 november 1997 +*/ +var SECTION = "expression-011"; +var VERSION = "JS1_4"; +var TITLE = "The new operator"; + +startTest(); +writeHeaderToLog( SECTION + " "+ TITLE); + +var BOOLEAN = true; + +var result = "Failed"; +var exception = "No exception thrown"; +var expect = "Passed"; + +try { + var OBJECT = new BOOLEAN(); +} catch ( e ) { + result = expect; + exception = e.toString(); +} + +new TestCase( + SECTION, + "BOOLEAN = true; result = new BOOLEAN()" + + " (threw " + exception +")", + expect, + result ); + +test(); + diff --git a/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/expression-012.js b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/expression-012.js new file mode 100644 index 0000000000..5223abd480 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/expression-012.js @@ -0,0 +1,77 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is JavaScript Engine testing utilities. + * + * The Initial Developer of the Original Code is + * Netscape Communication Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = 'expression-012.js'; + +/** + File Name: expression-012.js + Corresponds To: ecma/Expressions/11.2.2-6-n.js + ECMA Section: 11.2.2. The new operator + Description: + http://scopus/bugsplat/show_bug.cgi?id=327765 + Author: christine@netscape.com + Date: 12 november 1997 +*/ +var SECTION = "expression-012"; +var VERSION = "JS1_4"; +var TITLE = "The new operator"; +var BUGNUMBER= "327765"; + +startTest(); +writeHeaderToLog( SECTION + " "+ TITLE); + +var STRING = new String("hi"); +var result = "Failed"; +var exception = "No exception thrown"; +var expect = "Passed"; + +try { + result = new STRING(); +} catch ( e ) { + result = expect; + exception = e.toString(); +} + +new TestCase( + SECTION, + "STRING = new String(\"hi\"); result = new STRING()" + + " (threw " + exception +")", + expect, + result ); + +test(); + diff --git a/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/expression-013.js b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/expression-013.js new file mode 100644 index 0000000000..10ad726653 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/expression-013.js @@ -0,0 +1,77 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is JavaScript Engine testing utilities. + * + * The Initial Developer of the Original Code is + * Netscape Communication Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = 'expression-013.js'; + +/** + File Name: expression-013.js + Corresponds To: ecma/Expressions/11.2.2-8-n.js + ECMA Section: 11.2.2. The new operator + Description: + Author: christine@netscape.com + Date: 12 november 1997 +*/ +var SECTION = "expression-013"; +var VERSION = "JS1_4"; +var TITLE = "The new operator"; +var BUGNUMBER= "327765"; + +startTest(); +writeHeaderToLog( SECTION + " "+ TITLE); + +var NUMBER = new Number(1); + +var result = "Failed"; +var exception = "No exception thrown"; +var expect = "Passed"; + +try { + result = new NUMBER(); +} catch ( e ) { + result = expect; + exception = e.toString(); +} + +new TestCase( + SECTION, + "NUMBER = new Number(1); result = new NUMBER()" + + " (threw " + exception +")", + expect, + result ); + +test(); + diff --git a/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/expression-014.js b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/expression-014.js new file mode 100644 index 0000000000..fadca81c7a --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/expression-014.js @@ -0,0 +1,79 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is JavaScript Engine testing utilities. + * + * The Initial Developer of the Original Code is + * Netscape Communication Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = 'expression-014.js'; + +/** + File Name: expression-014.js + Corresponds To: ecma/Expressions/11.2.2-9-n.js + ECMA Section: 11.2.2. The new operator + Description: + + Author: christine@netscape.com + Date: 12 november 1997 +*/ +var SECTION = "expression-014.js"; +var VERSION = "ECMA_1"; +var TITLE = "The new operator"; +var BUGNUMBER= "327765"; + +startTest(); +writeHeaderToLog( SECTION + " "+ TITLE); + +var BOOLEAN = new Boolean(); + + +var result = "Failed"; +var exception = "No exception thrown"; +var expect = "Passed"; + +try { + result = new BOOLEAN(); +} catch ( e ) { + result = expect; + exception = e.toString(); +} + +new TestCase( + SECTION, + "BOOLEAN = new Boolean(); result = new BOOLEAN()" + + " (threw " + exception +")", + expect, + result ); + +test(); + diff --git a/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/expression-015.js b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/expression-015.js new file mode 100644 index 0000000000..2bd2b8d094 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/expression-015.js @@ -0,0 +1,73 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is JavaScript Engine testing utilities. + * + * The Initial Developer of the Original Code is + * Netscape Communication Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = 'expression-015.js'; + +/** + File Name: expression-015.js + Corresponds To: ecma/Expressions/11.2.3-2-n.js + ECMA Section: 11.2.3. Function Calls + Description: + Author: christine@netscape.com + Date: 12 november 1997 +*/ +var SECTION = "expression-015"; +var VERSION = "JS1_4"; +var TITLE = "Function Calls"; + +startTest(); +writeHeaderToLog( SECTION + " "+ TITLE); + +var result = "Failed"; +var exception = "No exception thrown"; +var expect = "Passed"; + +try { + eval("result = 3.valueOf();"); +} catch ( e ) { + result = expect; + exception = e.toString(); +} + +new TestCase( + SECTION, + "3.valueOf()" + + " (threw " + exception +")", + expect, + result ); + +test(); diff --git a/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/expression-016.js b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/expression-016.js new file mode 100644 index 0000000000..3c91495f3c --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/expression-016.js @@ -0,0 +1,73 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is JavaScript Engine testing utilities. + * + * The Initial Developer of the Original Code is + * Netscape Communication Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = 'expression-016.js'; + +/** + File Name: expression-016.js + Corresponds To: ecma/Expressions/11.2.3-3-n.js + ECMA Section: 11.2.3. Function Calls + Description: + Author: christine@netscape.com + Date: 12 november 1997 +*/ +var SECTION = "expression-016"; +var VERSION = "JS1_4"; +var TITLE = "Function Calls"; + +startTest(); +writeHeaderToLog( SECTION + " "+ TITLE); + +var result = "Failed"; +var exception = "No exception thrown"; +var expect = "Passed"; + +try { + result = (void 0).valueOf(); +} catch ( e ) { + result = expect; + exception = e.toString(); +} + +new TestCase( + SECTION, + "(void 0).valueOf()" + + " (threw " + exception +")", + expect, + result ); + +test(); diff --git a/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/expression-017.js b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/expression-017.js new file mode 100644 index 0000000000..4e762a54a9 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/expression-017.js @@ -0,0 +1,73 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is JavaScript Engine testing utilities. + * + * The Initial Developer of the Original Code is + * Netscape Communication Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = 'expression-017.js'; + +/** + File Name: expression-07.js + Corresponds To: ecma/Expressions/11.2.3-4-n.js + ECMA Section: 11.2.3. Function Calls + Description: + Author: christine@netscape.com + Date: 12 november 1997 +*/ +var SECTION = "expression-017"; +var VERSION = "JS1_4"; +var TITLE = "Function Calls"; + +startTest(); +writeHeaderToLog( SECTION + " "+ TITLE); + +var result = "Failed"; +var exception = "No exception thrown"; +var expect = "Passed"; + +try { + result = nullvalueOf(); +} catch ( e ) { + result = expect; + exception = e.toString(); +} + +new TestCase( + SECTION, + "null.valueOf()" + + " (threw " + exception +")", + expect, + result ); + +test(); diff --git a/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/expression-019.js b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/expression-019.js new file mode 100644 index 0000000000..11ee3a0063 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/expression-019.js @@ -0,0 +1,77 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is JavaScript Engine testing utilities. + * + * The Initial Developer of the Original Code is + * Netscape Communication Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = 'expression-019.js'; + +/** + File Name: expression-019.js + Corresponds To: 11.2.2-7-n.js + ECMA Section: 11.2.2. The new operator + Description: + + Author: christine@netscape.com + Date: 12 november 1997 +*/ +var SECTION = "expression-019"; +var VERSION = "JS1_4"; +var TITLE = "The new operator"; +var BUGNUMBER= "327765"; + +startTest(); +writeHeaderToLog( SECTION + " "+ TITLE); + +var result = "Failed"; +var exception = "No exception thrown"; +var expect = "Passed"; + +try { + var STRING = new String("hi"); + result = new STRING(); +} catch ( e ) { + result = expect; + exception = e.toString(); +} + +new TestCase( + SECTION, + "var STRING = new String(\"hi\"); result = new STRING();" + + " (threw " + exception + ")", + expect, + result ); + +test(); + diff --git a/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/function-001.js b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/function-001.js new file mode 100644 index 0000000000..d5f7b452e2 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/function-001.js @@ -0,0 +1,86 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is JavaScript Engine testing utilities. + * + * The Initial Developer of the Original Code is + * Netscape Communication Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = 'function-001.js'; + +/** + * File Name: boolean-001.js + * Description: + * + * http://scopus.mcom.com/bugsplat/show_bug.cgi?id=99232 + * + * eval("function f(){}function g(){}") at top level is an error for JS1.2 + * and above (missing ; between named function expressions), but declares f + * and g as functions below 1.2. + * + * Fails to produce error regardless of version: + * js> version(100) + * 120 + * js> eval("function f(){}function g(){}") + * js> version(120); + * 100 + * js> eval("function f(){}function g(){}") + * js> + * Author: christine@netscape.com + * Date: 11 August 1998 + */ +var SECTION = "function-001.js"; +var VERSION = "JS_12"; +var TITLE = "functions not separated by semicolons are errors in version 120 and higher"; +var BUGNUMBER="10278"; + +startTest(); +writeHeaderToLog( SECTION + " "+ TITLE); + +var result = "pass"; +var exception = "no exception thrown"; + +try { + eval("function f(){}function g(){}"); +} catch ( e ) { + result = "fail"; + exception = e.toString(); +} + +new TestCase( + SECTION, + "eval(\"function f(){}function g(){}\") (threw "+exception, + "pass", + result ); + +test(); + diff --git a/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/global-001.js b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/global-001.js new file mode 100644 index 0000000000..a186a51e64 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/global-001.js @@ -0,0 +1,78 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is JavaScript Engine testing utilities. + * + * The Initial Developer of the Original Code is + * Netscape Communication Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = 'global-001.js'; + +/** + File Name: global-001 + Corresponds To: ecma/GlobalObject/15.1-1-n.js + ECMA Section: The global object + Description: + + The global object does not have a [[Construct]] property; it is not + possible to use the global object as a constructor with the new operator. + + + Author: christine@netscape.com + Date: 12 november 1997 +*/ +var SECTION = "global-001"; +var VERSION = "ECMA_1"; +var TITLE = "The Global Object"; + +startTest(); +writeHeaderToLog( SECTION + " "+ TITLE); + +var result = "Failed"; +var exception = "No exception thrown"; +var expect = "Passed"; + +try { + result = new this(); +} catch ( e ) { + result = expect; + exception = e.toString(); +} + +new TestCase( + SECTION, + "result = new this()" + + " (threw " + exception +")", + expect, + result ); + +test(); diff --git a/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/global-002.js b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/global-002.js new file mode 100644 index 0000000000..c4ef143529 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/global-002.js @@ -0,0 +1,78 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is JavaScript Engine testing utilities. + * + * The Initial Developer of the Original Code is + * Netscape Communication Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = 'global-002.js'; + +/** + File Name: global-002 + Corresponds To: ecma/GlobalObject/15.1-2-n.js + ECMA Section: The global object + Description: + + The global object does not have a [[Construct]] property; it is not + possible to use the global object as a constructor with the new operator. + + + Author: christine@netscape.com + Date: 12 november 1997 +*/ +var SECTION = "global-002"; +var VERSION = "JS1_4"; +var TITLE = "The Global Object"; + +startTest(); +writeHeaderToLog( SECTION + " "+ TITLE); + +var result = "Failed"; +var exception = "No exception thrown"; +var expect = "Passed"; + +try { + result = this(); +} catch ( e ) { + result = expect; + exception = e.toString(); +} + +new TestCase( + SECTION, + "result = this()" + + " (threw " + exception +")", + expect, + result ); + +test(); diff --git a/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-001.js b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-001.js new file mode 100644 index 0000000000..cc2e3a46aa --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-001.js @@ -0,0 +1,85 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is JavaScript Engine testing utilities. + * + * The Initial Developer of the Original Code is + * Netscape Communication Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = 'lexical-001.js'; + +/** + File Name: lexical-001.js + CorrespondsTo: ecma/LexicalConventions/7.2.js + ECMA Section: 7.2 Line Terminators + Description: - readability + - separate tokens + - may occur between any two tokens + - cannot occur within any token, not even a string + - affect the process of automatic semicolon insertion. + + white space characters are: + unicode name formal name string representation + \u000A line feed \n + \u000D carriage return \r + + this test uses onerror to capture line numbers. because + we use on error, we can only have one test case per file. + + Author: christine@netscape.com + Date: 11 september 1997 +*/ +var SECTION = "lexical-001"; +var VERSION = "JS1_4"; +var TITLE = "Line Terminators"; + +startTest(); +writeHeaderToLog( SECTION + " "+ TITLE); + +var result = "Failed"; +var exception = "No exception thrown"; +var expect = "Passed"; + +try { + result = eval("\r\n\expect"); +} catch ( e ) { + exception = e.toString(); +} + +new TestCase( + SECTION, + "OBJECT = new Object; result = new OBJECT()" + + " (threw " + exception +")", + expect, + result ); + +test(); diff --git a/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-002.js b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-002.js new file mode 100644 index 0000000000..f7f691a049 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-002.js @@ -0,0 +1,85 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is JavaScript Engine testing utilities. + * + * The Initial Developer of the Original Code is + * Netscape Communication Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = 'lexical-002.js'; + +/** + File Name: lexical-002.js + Corresponds To: ecma/LexicalConventions/7.2-3-n.js + ECMA Section: 7.2 Line Terminators + Description: - readability + - separate tokens + - may occur between any two tokens + - cannot occur within any token, not even a string + - affect the process of automatic semicolon insertion. + + white space characters are: + unicode name formal name string representation + \u000A line feed \n + \u000D carriage return \r + + this test uses onerror to capture line numbers. because + we use on error, we can only have one test case per file. + + Author: christine@netscape.com + Date: 11 september 1997 +*/ +var SECTION = "lexical-002"; +var VERSION = "JS1_4"; +var TITLE = "Line Terminators"; + +startTest(); +writeHeaderToLog( SECTION + " "+ TITLE); + +var result = "Failed"; +var exception = "No exception thrown"; +var expect = "Passed"; + +try { + result = eval("\r\n\expect"); +} catch ( e ) { + exception = e.toString(); +} + +new TestCase( + SECTION, + "result=eval(\"\r\nexpect\")" + + " (threw " + exception +")", + expect, + result ); + +test(); diff --git a/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-003.js b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-003.js new file mode 100644 index 0000000000..482382eeed --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-003.js @@ -0,0 +1,76 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is JavaScript Engine testing utilities. + * + * The Initial Developer of the Original Code is + * Netscape Communication Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = 'lexical-003.js'; + +/** + File Name: lexical-003.js + Corresponds To: 7.3-13-n.js + ECMA Section: 7.3 Comments + Description: + + Author: christine@netscape.com + Date: 12 november 1997 + +*/ +var SECTION = "lexical-003.js"; +var VERSION = "JS1_4"; +var TITLE = "Comments"; + +startTest(); +writeHeaderToLog( SECTION + " "+ TITLE); + +var result = "Failed"; +var exception = "No exception thrown"; +var expect = "Passed"; + +try { + eval("/*\n/* nested comment */\n*/\n"); +} catch ( e ) { + result = expect; + exception = e.toString(); +} + +new TestCase( + SECTION, + "/*/*nested comment*/ */" + + " (threw " + exception +")", + expect, + result ); + +test(); + diff --git a/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-004.js b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-004.js new file mode 100644 index 0000000000..ccf6124109 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-004.js @@ -0,0 +1,85 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is JavaScript Engine testing utilities. + * + * The Initial Developer of the Original Code is + * Netscape Communication Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = 'lexical-004.js'; + +/** + File Name: lexical-004.js + Corresponds To: ecma/LexicalExpressions/7.4.1-1-n.js + ECMA Section: 7.4.1 + + Description: + + Reserved words cannot be used as identifiers. + + ReservedWord :: + Keyword + FutureReservedWord + NullLiteral + BooleanLiteral + + Author: christine@netscape.com + Date: 12 november 1997 + +*/ +var SECTION = "lexical-004"; +var VERSION = "JS1_4"; +var TITLE = "Keywords"; + +startTest(); +writeHeaderToLog( SECTION + " "+ TITLE); + +var result = "Failed"; +var exception = "No exception thrown"; +var expect = "Passed"; + +try { + eval("var null = true;"); +} catch ( e ) { + result = expect; + exception = e.toString(); +} + +new TestCase( + SECTION, + "var null = true" + + " (threw " + exception +")", + expect, + result ); + +test(); + diff --git a/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-005.js b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-005.js new file mode 100644 index 0000000000..44b2ea9c87 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-005.js @@ -0,0 +1,85 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is JavaScript Engine testing utilities. + * + * The Initial Developer of the Original Code is + * Netscape Communication Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = 'lexical-005.js'; + +/** + File Name: lexical-005.js + Corresponds To: 7.4.1-2.js + ECMA Section: 7.4.1 + + Description: + + Reserved words cannot be used as identifiers. + + ReservedWord :: + Keyword + FutureReservedWord + NullLiteral + BooleanLiteral + + Author: christine@netscape.com + Date: 12 november 1997 + +*/ +var SECTION = "lexical-005"; +var VERSION = "JS1_4"; +var TITLE = "Keywords"; + +startTest(); +writeHeaderToLog( SECTION + " "+ TITLE); + +var result = "Failed"; +var exception = "No exception thrown"; +var expect = "Passed"; + +try { + eval("true = false;"); +} catch ( e ) { + result = expect; + exception = e.toString(); +} + +new TestCase( + SECTION, + "true = false" + + " (threw " + exception +")", + expect, + result ); + +test(); + diff --git a/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-006.js b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-006.js new file mode 100644 index 0000000000..6f693d8ad2 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-006.js @@ -0,0 +1,91 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is JavaScript Engine testing utilities. + * + * The Initial Developer of the Original Code is + * Netscape Communication Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = 'lexical-006.js'; + +/** + File Name: lexical-006.js + Corresponds To: 7.4.2-1.js + ECMA Section: 7.4.2 + + Description: + The following tokens are ECMAScript keywords and may not be used as + identifiers in ECMAScript programs. + + Syntax + + Keyword :: one of + break for new var + continue function return void + delete if this while + else in typeof with + + This test verifies that the keyword cannot be used as an identifier. + Functioinal tests of the keyword may be found in the section corresponding + to the function of the keyword. + + Author: christine@netscape.com + Date: 12 november 1997 + +*/ +var SECTION = "lexical-006"; +var VERSION = "JS1_4"; +var TITLE = "Keywords"; + +startTest(); +writeHeaderToLog( SECTION + " "+ TITLE); + +var result = "Failed"; +var exception = "No exception thrown"; +var expect = "Passed"; + +try { + eval("break = new Object();"); +} catch ( e ) { + result = expect; + exception = e.toString(); +} + +new TestCase( + SECTION, + "break = new Object()" + + " (threw " + exception +")", + expect, + result ); + +test(); + diff --git a/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-007.js b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-007.js new file mode 100644 index 0000000000..b6d5152ea0 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-007.js @@ -0,0 +1,84 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is JavaScript Engine testing utilities. + * + * The Initial Developer of the Original Code is + * Netscape Communication Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = 'lexical-007.js'; + +/** + File Name: lexical-005.js + Corresponds To: 7.4.1-3-n.js + ECMA Section: 7.4.1 + + Description: + + Reserved words cannot be used as identifiers. + + ReservedWord :: + Keyword + FutureReservedWord + NullLiteral + BooleanLiteral + + Author: christine@netscape.com + Date: 12 november 1997 +*/ +var SECTION = "lexical-005"; +var VERSION = "JS1_4"; +var TITLE = "Keywords"; + +startTest(); +writeHeaderToLog( SECTION + " "+ TITLE); + +var result = "Failed"; +var exception = "No exception thrown"; +var expect = "Passed"; + +try { + eval("false = true;"); +} catch ( e ) { + result = expect; + exception = e.toString(); +} + +new TestCase( + SECTION, + "false = true" + + " (threw " + exception +")", + expect, + result ); + +test(); + diff --git a/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-008.js b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-008.js new file mode 100644 index 0000000000..eed455c243 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-008.js @@ -0,0 +1,86 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is JavaScript Engine testing utilities. + * + * The Initial Developer of the Original Code is + * Netscape Communication Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = 'lexical-008.js'; + +/** + File Name: lexical-008.js + Corresponds To: 7.4.3-1-n.js + ECMA Section: 7.4.3 + + Description: + The following words are used as keywords in proposed extensions and are + therefore reserved to allow for the possibility of future adoption of + those extensions. + + FutureReservedWord :: one of + case debugger export super + catch default extends switch + class do finally throw + const enum import try + + Author: christine@netscape.com + Date: 12 november 1997 +*/ +var SECTION = "lexical-008.js"; +var VERSION = "JS1_4"; +var TITLE = "Future Reserved Words"; + +startTest(); +writeHeaderToLog( SECTION + " "+ TITLE); + +var result = "Failed"; +var exception = "No exception thrown"; +var expect = "Passed"; + +try { + eval("case = true;"); +} catch ( e ) { + result = expect; + exception = e.toString(); +} + +new TestCase( + SECTION, + "case = true" + + " (threw " + exception +")", + expect, + result ); + +test(); + + diff --git a/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-009.js b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-009.js new file mode 100644 index 0000000000..d796574809 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-009.js @@ -0,0 +1,86 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is JavaScript Engine testing utilities. + * + * The Initial Developer of the Original Code is + * Netscape Communication Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = 'lexical-009.js'; + +/** + File Name: lexical-009 + Corresponds To: 7.4.3-2-n.js + ECMA Section: 7.4.3 + + Description: + The following words are used as keywords in proposed extensions and are + therefore reserved to allow for the possibility of future adoption of + those extensions. + + FutureReservedWord :: one of + case debugger export super + catch default extends switch + class do finally throw + const enum import try + + Author: christine@netscape.com + Date: 12 november 1997 +*/ +var SECTION = "lexical-009"; +var VERSION = "ECMA_1"; +var TITLE = "Future Reserved Words"; + +startTest(); +writeHeaderToLog( SECTION + " "+ TITLE); + +var result = "Failed"; +var exception = "No exception thrown"; +var expect = "Passed"; + +try { + eval("debugger = true;"); +} catch ( e ) { + result = expect; + exception = e.toString(); +} + +new TestCase( + SECTION, + "debugger = true" + + " (threw " + exception +")", + expect, + result ); + +test(); + + diff --git a/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-010.js b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-010.js new file mode 100644 index 0000000000..059b5a06be --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-010.js @@ -0,0 +1,84 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is JavaScript Engine testing utilities. + * + * The Initial Developer of the Original Code is + * Netscape Communication Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = 'lexical-010.js'; + +/** + File Name: lexical-010.js + Corresponds To: 7.4.3-3-n.js + ECMA Section: 7.4.3 + + Description: + The following words are used as keywords in proposed extensions and are + therefore reserved to allow for the possibility of future adoption of + those extensions. + + FutureReservedWord :: one of + case debugger export super + catch default extends switch + class do finally throw + const enum import try + + Author: christine@netscape.com + Date: 12 november 1997 +*/ +var SECTION = "lexical-010"; +var VERSION = "ECMA_1"; +var TITLE = "Future Reserved Words"; + +startTest(); +writeHeaderToLog( SECTION + " "+ TITLE); + +var result = "Failed"; +var exception = "No exception thrown"; +var expect = "Passed"; + +try { + eval("export = true;"); +} catch ( e ) { + result = expect; + exception = e.toString(); +} + +new TestCase( + SECTION, + "export = true" + + " (threw " + exception +")", + expect, + result ); + +test(); diff --git a/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-011.js b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-011.js new file mode 100644 index 0000000000..7f01041c41 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-011.js @@ -0,0 +1,95 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is JavaScript Engine testing utilities. + * + * The Initial Developer of the Original Code is + * Netscape Communication Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = 'lexical-011.js'; + +/** + File Name: lexical-011.js + Corresponds To: 7.4.3-4-n.js + ECMA Section: 7.4.3 + + Description: + The following words are used as keywords in proposed extensions and are + therefore reserved to allow for the possibility of future adoption of + those extensions. + + FutureReservedWord :: one of + case debugger export super + catch default extends switch + class do finally throw + const enum import try + + Author: christine@netscape.com + Date: 12 november 1997 +*/ +var SECTION = "lexical-011"; +var VERSION = "JS1_4"; +var TITLE = "Future Reserved Words"; + +startTest(); +writeHeaderToLog( SECTION + " "+ TITLE); + +print("This test requires option javascript.options.strict enabled"); + +if (!options().match(/strict/)) +{ + options('strict'); +} +if (!options().match(/werror/)) +{ + options('werror'); +} + +var result = "Failed"; +var exception = "No exception thrown"; +var expect = "Passed"; + +try { + eval("super = true;"); +} catch ( e ) { + result = expect; + exception = e.toString(); +} + +new TestCase( + SECTION, + "super = true" + + " (threw " + exception +")", + expect, + result ); + +test(); diff --git a/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-012.js b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-012.js new file mode 100644 index 0000000000..e55b6eb30f --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-012.js @@ -0,0 +1,86 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is JavaScript Engine testing utilities. + * + * The Initial Developer of the Original Code is + * Netscape Communication Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = 'lexical-012.js'; + +/** + File Name: lexical-012.js + Corresponds To: 7.4.3-5-n.js + ECMA Section: 7.4.3 + + Description: + The following words are used as keywords in proposed extensions and are + therefore reserved to allow for the possibility of future adoption of + those extensions. + + FutureReservedWord :: one of + case debugger export super + catch default extends switch + class do finally throw + const enum import try + + Author: christine@netscape.com + Date: 12 november 1997 +*/ +var SECTION = "lexical-012"; +var VERSION = "JS1_4"; +var TITLE = "Future Reserved Words"; + +startTest(); +writeHeaderToLog( SECTION + " "+ TITLE); + +var result = "Failed"; +var exception = "No exception thrown"; +var expect = "Passed"; + +try { + eval("catch = true;"); +} catch ( e ) { + result = expect; + exception = e.toString(); +} + +new TestCase( + SECTION, + "catch = true" + + " (threw " + exception +")", + expect, + result ); + +test(); + + diff --git a/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-013.js b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-013.js new file mode 100644 index 0000000000..fbbf20b263 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-013.js @@ -0,0 +1,86 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is JavaScript Engine testing utilities. + * + * The Initial Developer of the Original Code is + * Netscape Communication Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = 'lexical-013.js'; + +/** + File Name: lexical-013.js + Corresponds To: 7.4.3-6-n.js + ECMA Section: 7.4.3 + + Description: + The following words are used as keywords in proposed extensions and are + therefore reserved to allow for the possibility of future adoption of + those extensions. + + FutureReservedWord :: one of + case debugger export super + catch default extends switch + class do finally throw + const enum import try + + Author: christine@netscape.com + Date: 12 november 1997 +*/ +var SECTION = "lexical-013"; +var VERSION = "JS1_4"; +var TITLE = "Future Reserved Words"; + +startTest(); +writeHeaderToLog( SECTION + " "+ TITLE); + +var result = "Failed"; +var exception = "No exception thrown"; +var expect = "Passed"; + +try { + eval("default = true;"); +} catch ( e ) { + result = expect; + exception = e.toString(); +} + +new TestCase( + SECTION, + "default = true" + + " (threw " + exception +")", + expect, + result ); + +test(); + + diff --git a/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-014.js b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-014.js new file mode 100644 index 0000000000..880d2800e5 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-014.js @@ -0,0 +1,95 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is JavaScript Engine testing utilities. + * + * The Initial Developer of the Original Code is + * Netscape Communication Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = 'lexical-014.js'; + +/** + File Name: lexical-014.js + Corresponds To: 7.4.3-7-n.js + ECMA Section: 7.4.3 + + Description: + The following words are used as keywords in proposed extensions and are + therefore reserved to allow for the possibility of future adoption of + those extensions. + + FutureReservedWord :: one of + case debugger export super + catch default extends switch + class do finally throw + const enum import try + + Author: christine@netscape.com + Date: 12 november 1997 +*/ +var SECTION = "lexical-014.js"; +var VERSION = "JS1_4"; +var TITLE = "Future Reserved Words"; + +startTest(); +writeHeaderToLog( SECTION + " "+ TITLE); + +print("This test requires option javascript.options.strict enabled"); + +if (!options().match(/strict/)) +{ + options('strict'); +} +if (!options().match(/werror/)) +{ + options('werror'); +} + +var result = "Failed"; +var exception = "No exception thrown"; +var expect = "Passed"; + +try { + eval("extends = true;"); +} catch ( e ) { + result = expect; + exception = e.toString(); +} + +new TestCase( + SECTION, + "extends = true" + + " (threw " + exception +")", + expect, + result ); + +test(); diff --git a/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-015.js b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-015.js new file mode 100644 index 0000000000..a15a2be544 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-015.js @@ -0,0 +1,86 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is JavaScript Engine testing utilities. + * + * The Initial Developer of the Original Code is + * Netscape Communication Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = 'lexical-015.js'; + +/** + File Name: lexical-015.js + Corresponds To: 7.4.3-8-n.js + ECMA Section: 7.4.3 + + Description: + The following words are used as keywords in proposed extensions and are + therefore reserved to allow for the possibility of future adoption of + those extensions. + + FutureReservedWord :: one of + case debugger export super + catch default extends switch + class do finally throw + const enum import try + + Author: christine@netscape.com + Date: 12 november 1997 +*/ +var SECTION = "lexical-015"; +var VERSION = "JS1_4"; +var TITLE = "Future Reserved Words"; + +startTest(); +writeHeaderToLog( SECTION + " "+ TITLE); + +var result = "Failed"; +var exception = "No exception thrown"; +var expect = "Passed"; + +try { + eval("switch = true;"); +} catch ( e ) { + result = expect; + exception = e.toString(); +} + +new TestCase( + SECTION, + "switch = true" + + " (threw " + exception +")", + expect, + result ); + +test(); + + diff --git a/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-016.js b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-016.js new file mode 100644 index 0000000000..021594d052 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-016.js @@ -0,0 +1,95 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is JavaScript Engine testing utilities. + * + * The Initial Developer of the Original Code is + * Netscape Communication Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = 'lexical-016.js'; + +/** + File Name: lexical-016 + Corresponds To: 7.4.3-9-n.js + ECMA Section: 7.4.3 + + Description: + The following words are used as keywords in proposed extensions and are + therefore reserved to allow for the possibility of future adoption of + those extensions. + + FutureReservedWord :: one of + case debugger export super + catch default extends switch + class do finally throw + const enum import try + + Author: christine@netscape.com + Date: 12 november 1997 +*/ +var SECTION = "lexical-016"; +var VERSION = "JS1_4"; +var TITLE = "Future Reserved Words"; + +startTest(); +writeHeaderToLog( SECTION + " "+ TITLE); + +print("This test requires option javascript.options.strict enabled"); + +if (!options().match(/strict/)) +{ + options('strict'); +} +if (!options().match(/werror/)) +{ + options('werror'); +} + +var result = "Failed"; +var exception = "No exception thrown"; +var expect = "Passed"; + +try { + eval("class = true;"); +} catch ( e ) { + result = expect; + exception = e.toString(); +} + +new TestCase( + SECTION, + "class = true" + + " (threw " + exception +")", + expect, + result ); + +test(); diff --git a/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-017.js b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-017.js new file mode 100644 index 0000000000..b89a526229 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-017.js @@ -0,0 +1,87 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is JavaScript Engine testing utilities. + * + * The Initial Developer of the Original Code is + * Netscape Communication Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = 'lexical-017.js'; + +/** + File Name: lexical-017.js + Corresponds To: 7.4.3-10-n.js + ECMA Section: 7.4.3 + + Description: + The following words are used as keywords in proposed extensions and are + therefore reserved to allow for the possibility of future adoption of + those extensions. + + FutureReservedWord :: one of + case debugger export super + catch default extends switch + class do finally throw + const enum import try + + Author: christine@netscape.com + Date: 12 november 1997 +*/ +var SECTION = "lexical-017"; +var VERSION = "JS1_4"; +var TITLE = "Future Reserved Words"; + +startTest(); +writeHeaderToLog( SECTION + " "+ TITLE); + +var result = "Failed"; +var exception = "No exception thrown"; +var expect = "Passed"; + +try { + eval("do = true;"); +} catch ( e ) { + result = expect; + exception = e.toString(); +} + +new TestCase( + SECTION, + "do = true" + + " (threw " + exception +")", + expect, + result ); + +test(); + + + diff --git a/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-018.js b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-018.js new file mode 100644 index 0000000000..18773dafe6 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-018.js @@ -0,0 +1,86 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is JavaScript Engine testing utilities. + * + * The Initial Developer of the Original Code is + * Netscape Communication Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = 'lexical-018.js'; + +/** + File Name: lexical-018 + Corresponds To: 7.4.3-11-n.js + ECMA Section: 7.4.3 + + Description: + The following words are used as keywords in proposed extensions and are + therefore reserved to allow for the possibility of future adoption of + those extensions. + + FutureReservedWord :: one of + case debugger export super + catch default extends switch + class do finally throw + const enum import try + + Author: christine@netscape.com + Date: 12 november 1997 +*/ +var SECTION = "lexical-018"; +var VERSION = "JS1_4"; +var TITLE = "Future Reserved Words"; + +startTest(); +writeHeaderToLog( SECTION + " "+ TITLE); + +var result = "Failed"; +var exception = "No exception thrown"; +var expect = "Passed"; + +try { + eval("finally = true;"); +} catch ( e ) { + result = expect; + exception = e.toString(); +} + +new TestCase( + SECTION, + "finally = true" + + " (threw " + exception +")", + expect, + result ); + +test(); + + diff --git a/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-019.js b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-019.js new file mode 100644 index 0000000000..c1c34a93c1 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-019.js @@ -0,0 +1,86 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is JavaScript Engine testing utilities. + * + * The Initial Developer of the Original Code is + * Netscape Communication Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = 'lexical-019.js'; + +/** + File Name: lexical-019.js + Corresponds To: 7.4.3-12-n.js + ECMA Section: 7.4.3 + + Description: + The following words are used as keywords in proposed extensions and are + therefore reserved to allow for the possibility of future adoption of + those extensions. + + FutureReservedWord :: one of + case debugger export super + catch default extends switch + class do finally throw + const enum import try + + Author: christine@netscape.com + Date: 12 november 1997 +*/ +var SECTION = "lexical-019"; +var VERSION = "JS1_4"; +var TITLE = "Future Reserved Words"; + +startTest(); +writeHeaderToLog( SECTION + " "+ TITLE); + +var result = "Failed"; +var exception = "No exception thrown"; +var expect = "Passed"; + +try { + eval("throw = true;"); +} catch ( e ) { + result = expect; + exception = e.toString(); +} + +new TestCase( + SECTION, + "throw = true" + + " (threw " + exception +")", + expect, + result ); + +test(); + + diff --git a/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-020.js b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-020.js new file mode 100644 index 0000000000..e82e1e50b9 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-020.js @@ -0,0 +1,86 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is JavaScript Engine testing utilities. + * + * The Initial Developer of the Original Code is + * Netscape Communication Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = 'lexical-020.js'; + +/** + File Name: lexical-020.js + Corresponds To 7.4.3-13-n.js + ECMA Section: 7.4.3 + + Description: + The following words are used as keywords in proposed extensions and are + therefore reserved to allow for the possibility of future adoption of + those extensions. + + FutureReservedWord :: one of + case debugger export super + catch default extends switch + class do finally throw + const enum import try + + Author: christine@netscape.com + Date: 12 november 1997 +*/ +var SECTION = "lexical-020"; +var VERSION = "JS1_4"; +var TITLE = "Future Reserved Words"; + +startTest(); +writeHeaderToLog( SECTION + " "+ TITLE); + +var result = "Failed"; +var exception = "No exception thrown"; +var expect = "Passed"; + +try { + eval("const = true;"); +} catch ( e ) { + result = expect; + exception = e.toString(); +} + +new TestCase( + SECTION, + "const = true" + + " (threw " + exception +")", + expect, + result ); + +test(); + + diff --git a/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-021.js b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-021.js new file mode 100644 index 0000000000..47a0725a09 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-021.js @@ -0,0 +1,95 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is JavaScript Engine testing utilities. + * + * The Initial Developer of the Original Code is + * Netscape Communication Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = 'lexical-021.js'; + +/** + File Name: lexical-021.js + Corresponds To: 7.4.3-14-n.js + ECMA Section: 7.4.3 + + Description: + The following words are used as keywords in proposed extensions and are + therefore reserved to allow for the possibility of future adoption of + those extensions. + + FutureReservedWord :: one of + case debugger export super + catch default extends switch + class do finally throw + const enum import try + + Author: christine@netscape.com + Date: 12 november 1997 +*/ +var SECTION = "lexical-021.js"; +var VERSION = "ECMA_1"; +var TITLE = "Future Reserved Words"; + +startTest(); +writeHeaderToLog( SECTION + " "+ TITLE); + +print("This test requires option javascript.options.strict enabled"); + +if (!options().match(/strict/)) +{ + options('strict'); +} +if (!options().match(/werror/)) +{ + options('werror'); +} + +var result = "Failed"; +var exception = "No exception thrown"; +var expect = "Passed"; + +try { + eval("enum = true;"); +} catch ( e ) { + result = expect; + exception = e.toString(); +} + +new TestCase( + SECTION, + "enum = true" + + " (threw " + exception +")", + expect, + result ); + +test(); diff --git a/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-022.js b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-022.js new file mode 100644 index 0000000000..75d72aa5b6 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-022.js @@ -0,0 +1,86 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is JavaScript Engine testing utilities. + * + * The Initial Developer of the Original Code is + * Netscape Communication Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = 'lexical-022.js'; + +/** + File Name: lexical-022 + Corresponds To 7.4.3-15-n.js + ECMA Section: 7.4.3 + + Description: + The following words are used as keywords in proposed extensions and are + therefore reserved to allow for the possibility of future adoption of + those extensions. + + FutureReservedWord :: one of + case debugger export super + catch default extends switch + class do finally throw + const enum import try + + Author: christine@netscape.com + Date: 12 november 1997 +*/ +var SECTION = "lexical-022.js"; +var VERSION = "ECMA_1"; +var TITLE = "Future Reserved Words"; + +startTest(); +writeHeaderToLog( SECTION + " "+ TITLE); + +var result = "Failed"; +var exception = "No exception thrown"; +var expect = "Passed"; + +try { + eval("import = true;"); +} catch ( e ) { + result = expect; + exception = e.toString(); +} + +new TestCase( + SECTION, + "import = true" + + " (threw " + exception +")", + expect, + result ); + +test(); + + diff --git a/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-023.js b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-023.js new file mode 100644 index 0000000000..aa89c04782 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-023.js @@ -0,0 +1,85 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is JavaScript Engine testing utilities. + * + * The Initial Developer of the Original Code is + * Netscape Communication Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = 'lexical-023.js'; + +/** + File Name: lexical-023.js + Corresponds To: 7.4.3-16-n.js + ECMA Section: 7.4.3 + Description: + The following words are used as keywords in proposed extensions and are + therefore reserved to allow for the possibility of future adoption of + those extensions. + + FutureReservedWord :: one of + case debugger export super + catch default extends switch + class do finally throw + const enum import try + + Author: christine@netscape.com + Date: 12 november 1997 +*/ +var SECTION = "lexical-023.js"; +var VERSION = "ECMA_1"; +var TITLE = "Future Reserved Words"; + +startTest(); +writeHeaderToLog( SECTION + " "+ TITLE); + +var result = "Failed"; +var exception = "No exception thrown"; +var expect = "Passed"; + +try { + eval("try = true;"); +} catch ( e ) { + result = expect; + exception = e.toString(); +} + +new TestCase( + SECTION, + "try = true" + + " (threw " + exception +")", + expect, + result ); + +test(); + + diff --git a/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-024.js b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-024.js new file mode 100644 index 0000000000..7c1f22f745 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-024.js @@ -0,0 +1,92 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is JavaScript Engine testing utilities. + * + * The Initial Developer of the Original Code is + * Netscape Communication Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = 'lexical-024.js'; + +/** + File Name: lexical-024 + Corresponds To: 7.4.2-1-n.js + ECMA Section: 7.4.2 + + Description: + The following tokens are ECMAScript keywords and may not be used as + identifiers in ECMAScript programs. + + Syntax + + Keyword :: one of + break for new var + continue function return void + delete if this while + else in typeof with + + This test verifies that the keyword cannot be used as an identifier. + Functioinal tests of the keyword may be found in the section corresponding + to the function of the keyword. + + Author: christine@netscape.com + Date: 12 november 1997 + +*/ +var SECTION = "lexical-024"; +var VERSION = "JS1_4"; +var TITLE = "Keywords"; + +startTest(); +writeHeaderToLog( SECTION + " "+ TITLE); + +var result = "Failed"; +var exception = "No exception thrown"; +var expect = "Passed"; + +try { + eval("var break;"); +} catch ( e ) { + result = expect; + exception = e.toString(); +} + +new TestCase( + SECTION, + "var break" + + " (threw " + exception +")", + expect, + result ); + +test(); + + diff --git a/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-025.js b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-025.js new file mode 100644 index 0000000000..f1c7b93daf --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-025.js @@ -0,0 +1,92 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is JavaScript Engine testing utilities. + * + * The Initial Developer of the Original Code is + * Netscape Communication Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = 'lexical-025.js'; + +/** + File Name: lexical-025.js + Corresponds To 7.4.2-2-n.js + ECMA Section: 7.4.2 + + Description: + The following tokens are ECMAScript keywords and may not be used as + identifiers in ECMAScript programs. + + Syntax + + Keyword :: one of + break for new var + continue function return void + delete if this while + else in typeof with + + This test verifies that the keyword cannot be used as an identifier. + Functioinal tests of the keyword may be found in the section corresponding + to the function of the keyword. + + Author: christine@netscape.com + Date: 12 november 1997 + +*/ +var SECTION = "lexical-025"; +var VERSION = "JS1_4"; +var TITLE = "Keywords"; + +startTest(); +writeHeaderToLog( SECTION + " "+ TITLE); + +var result = "Failed"; +var exception = "No exception thrown"; +var expect = "Passed"; + +try { + eval("var for;"); +} catch ( e ) { + result = expect; + exception = e.toString(); +} + +new TestCase( + SECTION, + "var for" + + " (threw " + exception +")", + expect, + result ); + +test(); + + diff --git a/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-026.js b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-026.js new file mode 100644 index 0000000000..31b5aaaf61 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-026.js @@ -0,0 +1,92 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is JavaScript Engine testing utilities. + * + * The Initial Developer of the Original Code is + * Netscape Communication Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = 'lexical-026.js'; + +/** + File Name: lexical-026.js + Corresponds To: 7.4.2-3-n.js + ECMA Section: 7.4.2 + + Description: + The following tokens are ECMAScript keywords and may not be used as + identifiers in ECMAScript programs. + + Syntax + + Keyword :: one of + break for new var + continue function return void + delete if this while + else in typeof with + + This test verifies that the keyword cannot be used as an identifier. + Functioinal tests of the keyword may be found in the section corresponding + to the function of the keyword. + + Author: christine@netscape.com + Date: 12 november 1997 + +*/ +var SECTION = "lexical-026"; +var VERSION = "JS1_4"; +var TITLE = "Keywords"; + +startTest(); +writeHeaderToLog( SECTION + " "+ TITLE); + +var result = "Failed"; +var exception = "No exception thrown"; +var expect = "Passed"; + +try { + eval("var new;"); +} catch ( e ) { + result = expect; + exception = e.toString(); +} + +new TestCase( + SECTION, + "var new" + + " (threw " + exception +")", + expect, + result ); + +test(); + + diff --git a/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-027.js b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-027.js new file mode 100644 index 0000000000..573025b591 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-027.js @@ -0,0 +1,94 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is JavaScript Engine testing utilities. + * + * The Initial Developer of the Original Code is + * Netscape Communication Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = 'lexical-027.js'; + +/** + File Name: lexical-027.js + Corresponds To: 7.4.2-4-n.js + ECMA Section: 7.4.2 + + Description: + The following tokens are ECMAScript keywords and may not be used as + identifiers in ECMAScript programs. + + Syntax + + var + + Keyword :: one of + break for new var + continue function return void + delete if this while + else in typeof with + + This test verifies that the keyword cannot be used as an identifier. + Functioinal tests of the keyword may be found in the section corresponding + to the function of the keyword. + + Author: christine@netscape.com + Date: 12 november 1997 + +*/ +var SECTION = "lexical-027"; +var VERSION = "JS1_4"; +var TITLE = "Keywords"; + +startTest(); +writeHeaderToLog( SECTION + " "+ TITLE); + +var result = "Failed"; +var exception = "No exception thrown"; +var expect = "Passed"; + +try { + eval("var var;"); +} catch ( e ) { + result = expect; + exception = e.toString(); +} + +new TestCase( + SECTION, + "var var" + + " (threw " + exception +")", + expect, + result ); + +test(); + + diff --git a/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-028.js b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-028.js new file mode 100644 index 0000000000..1b76a22169 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-028.js @@ -0,0 +1,92 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is JavaScript Engine testing utilities. + * + * The Initial Developer of the Original Code is + * Netscape Communication Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = 'lexical-028.js'; + +/** + File Name: lexical-028.js + Corresponds To: 7.4.2-5-n.js + ECMA Section: 7.4.2 + + Description: + The following tokens are ECMAScript keywords and may not be used as + identifiers in ECMAScript programs. + + Syntax + + Keyword :: one of + break for new var + continue function return void + delete if this while + else in typeof with + + This test verifies that the keyword cannot be used as an identifier. + Functioinal tests of the keyword may be found in the section corresponding + to the function of the keyword. + + Author: christine@netscape.com + Date: 12 november 1997 + +*/ +var SECTION = "lexical-028"; +var VERSION = "JS1_4"; +var TITLE = "Keywords"; + +startTest(); +writeHeaderToLog( SECTION + " "+ TITLE); + +var result = "Failed"; +var exception = "No exception thrown"; +var expect = "Passed"; + +try { + eval("var continue=true;"); +} catch ( e ) { + result = expect; + exception = e.toString(); +} + +new TestCase( + SECTION, + "var continue=true" + + " (threw " + exception +")", + expect, + result ); + +test(); + + diff --git a/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-029.js b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-029.js new file mode 100644 index 0000000000..f978b8ef89 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-029.js @@ -0,0 +1,92 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is JavaScript Engine testing utilities. + * + * The Initial Developer of the Original Code is + * Netscape Communication Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = 'lexical-029.js'; + +/** + File Name: lexical-029.js + Corresponds To: 7.4.2-6.js + ECMA Section: 7.4.2 + + Description: + The following tokens are ECMAScript keywords and may not be used as + identifiers in ECMAScript programs. + + Syntax + + Keyword :: one of + break for new var + continue function return void + delete if this while + else in typeof with + + This test verifies that the keyword cannot be used as an identifier. + Functioinal tests of the keyword may be found in the section corresponding + to the function of the keyword. + + Author: christine@netscape.com + Date: 12 november 1997 + +*/ +var SECTION = "lexical-029"; +var VERSION = "JS1_4"; +var TITLE = "Keywords"; + +startTest(); +writeHeaderToLog( SECTION + " "+ TITLE); + +var result = "Failed"; +var exception = "No exception thrown"; +var expect = "Passed"; + +try { + eval("var function = true;"); +} catch ( e ) { + result = expect; + exception = e.toString(); +} + +new TestCase( + SECTION, + "var function = true" + + " (threw " + exception +")", + expect, + result ); + +test(); + + diff --git a/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-030.js b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-030.js new file mode 100644 index 0000000000..3796551698 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-030.js @@ -0,0 +1,92 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is JavaScript Engine testing utilities. + * + * The Initial Developer of the Original Code is + * Netscape Communication Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = 'lexical-030.js'; + +/** + File Name: lexical-030.js + Corresponds To: 7.4.2-7-n.js + ECMA Section: 7.4.2 + + Description: + The following tokens are ECMAScript keywords and may not be used as + identifiers in ECMAScript programs. + + Syntax + + Keyword :: one of + break for new var + continue function return void + delete if this while + else in typeof with + + This test verifies that the keyword cannot be used as an identifier. + Functioinal tests of the keyword may be found in the section corresponding + to the function of the keyword. + + Author: christine@netscape.com + Date: 12 november 1997 + +*/ +var SECTION = "lexical-030"; +var VERSION = "JS1_4"; +var TITLE = "Keywords"; + +startTest(); +writeHeaderToLog( SECTION + " "+ TITLE); + +var result = "Failed"; +var exception = "No exception thrown"; +var expect = "Passed"; + +try { + eval("var return = true;"); +} catch ( e ) { + result = expect; + exception = e.toString(); +} + +new TestCase( + SECTION, + "var return = true" + + " (threw " + exception +")", + expect, + result ); + +test(); + + diff --git a/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-031.js b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-031.js new file mode 100644 index 0000000000..13379fed01 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-031.js @@ -0,0 +1,92 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is JavaScript Engine testing utilities. + * + * The Initial Developer of the Original Code is + * Netscape Communication Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = 'lexical-031.js'; + +/** + File Name: lexical-031.js + Corresponds To: 7.4.2-8-n.js + ECMA Section: 7.4.2 + + Description: + The following tokens are ECMAScript keywords and may not be used as + identifiers in ECMAScript programs. + + Syntax + + Keyword :: one of + break for new var + continue function return void + delete if this while + else in typeof with + + This test verifies that the keyword cannot be used as an identifier. + Functioinal tests of the keyword may be found in the section corresponding + to the function of the keyword. + + Author: christine@netscape.com + Date: 12 november 1997 + +*/ +var SECTION = "lexical-031"; +var VERSION = "JS1_4"; +var TITLE = "Keywords"; + +startTest(); +writeHeaderToLog( SECTION + " "+ TITLE); + +var result = "Failed"; +var exception = "No exception thrown"; +var expect = "Passed"; + +try { + eval("var return;"); +} catch ( e ) { + result = expect; + exception = e.toString(); +} + +new TestCase( + SECTION, + "var return" + + " (threw " + exception +")", + expect, + result ); + +test(); + + diff --git a/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-032.js b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-032.js new file mode 100644 index 0000000000..48e6e9aac5 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-032.js @@ -0,0 +1,92 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is JavaScript Engine testing utilities. + * + * The Initial Developer of the Original Code is + * Netscape Communication Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = 'lexical-032.js'; + +/** + File Name: lexical-032.js + Corresponds To: 7.4.2-9-n.js + ECMA Section: 7.4.2 + + Description: + The following tokens are ECMAScript keywords and may not be used as + identifiers in ECMAScript programs. + + Syntax + + Keyword :: one of + break for new var + continue function return void + delete if this while + else in typeof with + + This test verifies that the keyword cannot be used as an identifier. + Functioinal tests of the keyword may be found in the section corresponding + to the function of the keyword. + + Author: christine@netscape.com + Date: 12 november 1997 + +*/ +var SECTION = "lexical-032"; +var VERSION = "JS1_4"; +var TITLE = "Keywords"; + +startTest(); +writeHeaderToLog( SECTION + " "+ TITLE); + +var result = "Failed"; +var exception = "No exception thrown"; +var expect = "Passed"; + +try { + eval("delete = true;"); +} catch ( e ) { + result = expect; + exception = e.toString(); +} + +new TestCase( + SECTION, + "delete = true" + + " (threw " + exception +")", + expect, + result ); + +test(); + + diff --git a/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-033.js b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-033.js new file mode 100644 index 0000000000..cc223c2282 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-033.js @@ -0,0 +1,92 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is JavaScript Engine testing utilities. + * + * The Initial Developer of the Original Code is + * Netscape Communication Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = 'lexical-033.js'; + +/** + File Name: lexical-033.js + Corresponds To: 7.4.2-10.js + ECMA Section: 7.4.2 + + Description: + The following tokens are ECMAScript keywords and may not be used as + identifiers in ECMAScript programs. + + Syntax + + Keyword :: one of + break for new var + continue function return void + delete if this while + else in typeof with + + This test verifies that the keyword cannot be used as an identifier. + Functioinal tests of the keyword may be found in the section corresponding + to the function of the keyword. + + Author: christine@netscape.com + Date: 12 november 1997 + +*/ +var SECTION = "lexical-033"; +var VERSION = "JS1_4"; +var TITLE = "Keywords"; + +startTest(); +writeHeaderToLog( SECTION + " "+ TITLE); + +var result = "Failed"; +var exception = "No exception thrown"; +var expect = "Passed"; + +try { + eval("if = true;"); +} catch ( e ) { + result = expect; + exception = e.toString(); +} + +new TestCase( + SECTION, + "if = true" + + " (threw " + exception +")", + expect, + result ); + +test(); + + diff --git a/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-034.js b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-034.js new file mode 100644 index 0000000000..4d3c7d5fc0 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-034.js @@ -0,0 +1,91 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is JavaScript Engine testing utilities. + * + * The Initial Developer of the Original Code is + * Netscape Communication Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = 'lexical-034.js'; + +/** + File Name: 7.4.2-11-n.js + ECMA Section: 7.4.2 + + Description: + The following tokens are ECMAScript keywords and may not be used as + identifiers in ECMAScript programs. + + Syntax + + Keyword :: one of + break for new var + continue function return void + delete if this while + else in typeof with + + This test verifies that the keyword cannot be used as an identifier. + Functioinal tests of the keyword may be found in the section corresponding + to the function of the keyword. + + Author: christine@netscape.com + Date: 12 november 1997 + +*/ +var SECTION = "lexical-034"; +var VERSION = "JS1_4"; +var TITLE = "Keywords"; + +startTest(); +writeHeaderToLog( SECTION + " "+ TITLE); + +var result = "Failed"; +var exception = "No exception thrown"; +var expect = "Passed"; + +try { + eval("this = true"); +} catch ( e ) { + result = expect; + exception = e.toString(); +} + +new TestCase( + SECTION, + "this = true" + + " (threw " + exception +")", + expect, + result ); + +test(); + + diff --git a/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-035.js b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-035.js new file mode 100644 index 0000000000..2a61b437ba --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-035.js @@ -0,0 +1,92 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is JavaScript Engine testing utilities. + * + * The Initial Developer of the Original Code is + * Netscape Communication Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = 'lexical-035.js'; + +/** + File Name: lexical-035.js + Correpsonds To: 7.4.2-12-n.js + ECMA Section: 7.4.2 + + Description: + The following tokens are ECMAScript keywords and may not be used as + identifiers in ECMAScript programs. + + Syntax + + Keyword :: one of + break for new var + continue function return void + delete if this while + else in typeof with + + This test verifies that the keyword cannot be used as an identifier. + Functioinal tests of the keyword may be found in the section corresponding + to the function of the keyword. + + Author: christine@netscape.com + Date: 12 november 1997 + +*/ +var SECTION = "lexical-035"; +var VERSION = "JS1_4"; +var TITLE = "Keywords"; + +startTest(); +writeHeaderToLog( SECTION + " "+ TITLE); + +var result = "Failed"; +var exception = "No exception thrown"; +var expect = "Passed"; + +try { + eval("var while"); +} catch ( e ) { + result = expect; + exception = e.toString(); +} + +new TestCase( + SECTION, + "var while" + + " (threw " + exception +")", + expect, + result ); + +test(); + + diff --git a/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-036.js b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-036.js new file mode 100644 index 0000000000..a1923b7303 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-036.js @@ -0,0 +1,92 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is JavaScript Engine testing utilities. + * + * The Initial Developer of the Original Code is + * Netscape Communication Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = 'lexical-036.js'; + +/** + File Name: lexical-036.js + Corresponds To: 7.4.2-13-n.js + ECMA Section: 7.4.2 + + Description: + The following tokens are ECMAScript keywords and may not be used as + identifiers in ECMAScript programs. + + Syntax + + Keyword :: one of + break for new var + continue function return void + delete if this while + else in typeof with + + This test verifies that the keyword cannot be used as an identifier. + Functioinal tests of the keyword may be found in the section corresponding + to the function of the keyword. + + Author: christine@netscape.com + Date: 12 november 1997 + +*/ +var SECTION = "lexical-036"; +var VERSION = "JS1_4"; +var TITLE = "Keywords"; + +startTest(); +writeHeaderToLog( SECTION + " "+ TITLE); + +var result = "Failed"; +var exception = "No exception thrown"; +var expect = "Passed"; + +try { + eval("else = true;"); +} catch ( e ) { + result = expect; + exception = e.toString(); +} + +new TestCase( + SECTION, + "else = true" + + " (threw " + exception +")", + expect, + result ); + +test(); + + diff --git a/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-037.js b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-037.js new file mode 100644 index 0000000000..e3cd75bd60 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-037.js @@ -0,0 +1,92 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is JavaScript Engine testing utilities. + * + * The Initial Developer of the Original Code is + * Netscape Communication Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = 'lexical-037.js'; + +/** + File Name: lexical-037.js + Corresponds To: 7.4.2-14-n.js + ECMA Section: 7.4.2 + + Description: + The following tokens are ECMAScript keywords and may not be used as + identifiers in ECMAScript programs. + + Syntax + + Keyword :: one of + break for new var + continue function return void + delete if this while + else in typeof with + + This test verifies that the keyword cannot be used as an identifier. + Functioinal tests of the keyword may be found in the section corresponding + to the function of the keyword. + + Author: christine@netscape.com + Date: 12 november 1997 + +*/ +var SECTION = "lexical-028"; +var VERSION = "JS1_4"; +var TITLE = "Keywords"; + +startTest(); +writeHeaderToLog( SECTION + " "+ TITLE); + +var result = "Failed"; +var exception = "No exception thrown"; +var expect = "Passed"; + +try { + eval("var in;"); +} catch ( e ) { + result = expect; + exception = e.toString(); +} + +new TestCase( + SECTION, + "var in" + + " (threw " + exception +")", + expect, + result ); + +test(); + + diff --git a/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-038.js b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-038.js new file mode 100644 index 0000000000..1bf8c6c4e4 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-038.js @@ -0,0 +1,92 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is JavaScript Engine testing utilities. + * + * The Initial Developer of the Original Code is + * Netscape Communication Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = 'lexical-038.js'; + +/** + File Name: lexical-038.js + Corresponds To: 7.4.2-15-n.js + ECMA Section: 7.4.2 + + Description: + The following tokens are ECMAScript keywords and may not be used as + identifiers in ECMAScript programs. + + Syntax + + Keyword :: one of + break for new var + continue function return void + delete if this while + else in typeof with + + This test verifies that the keyword cannot be used as an identifier. + Functioinal tests of the keyword may be found in the section corresponding + to the function of the keyword. + + Author: christine@netscape.com + Date: 12 november 1997 + +*/ +var SECTION = "lexical-038"; +var VERSION = "JS1_4"; +var TITLE = "Keywords"; + +startTest(); +writeHeaderToLog( SECTION + " "+ TITLE); + +var result = "Failed"; +var exception = "No exception thrown"; +var expect = "Passed"; + +try { + eval("typeof = true;"); +} catch ( e ) { + result = expect; + exception = e.toString(); +} + +new TestCase( + SECTION, + "typeof = true" + + " (threw " + exception +")", + expect, + result ); + +test(); + + diff --git a/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-039.js b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-039.js new file mode 100644 index 0000000000..2f193af89a --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-039.js @@ -0,0 +1,79 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is JavaScript Engine testing utilities. + * + * The Initial Developer of the Original Code is + * Netscape Communication Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = 'lexical-039.js'; + +/** + File Name: lexical-039 + Corresponds To: 7.5-2-n.js + ECMA Section: 7.5 Identifiers + Description: Identifiers are of unlimited length + - can contain letters, a decimal digit, _, or $ + - the first character cannot be a decimal digit + - identifiers are case sensitive + + Author: christine@netscape.com + Date: 11 september 1997 +*/ +var SECTION = "lexical-039"; +var VERSION = "JS1_4"; +var TITLE = "Identifiers"; + +startTest(); +writeHeaderToLog( SECTION + " "+ TITLE); + +var result = "Failed"; +var exception = "No exception thrown"; +var expect = "Passed"; + +try { + eval("var 0abc;"); +} catch ( e ) { + result = expect; + exception = e.toString(); +} + +new TestCase( + SECTION, + "var 0abc" + + " (threw " + exception +")", + expect, + result ); + +test(); + + diff --git a/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-040.js b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-040.js new file mode 100644 index 0000000000..f5ba3533dd --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-040.js @@ -0,0 +1,79 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is JavaScript Engine testing utilities. + * + * The Initial Developer of the Original Code is + * Netscape Communication Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = 'lexical-040.js'; + +/** + File Name: lexical-040.js + Corresponds To: 7.5-2.js + ECMA Section: 7.5 Identifiers + Description: Identifiers are of unlimited length + - can contain letters, a decimal digit, _, or $ + - the first character cannot be a decimal digit + - identifiers are case sensitive + + Author: christine@netscape.com + Date: 11 september 1997 +*/ +var SECTION = "lexical-040"; +var VERSION = "JS1_4"; +var TITLE = "Identifiers"; + +startTest(); +writeHeaderToLog( SECTION + " "+ TITLE); + +var result = "Failed"; +var exception = "No exception thrown"; +var expect = "Passed"; + +try { + eval("var 1abc;"); +} catch ( e ) { + result = expect; + exception = e.toString(); +} + +new TestCase( + SECTION, + "var 1abc" + + " (threw " + exception +")", + expect, + result ); + +test(); + + diff --git a/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-041.js b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-041.js new file mode 100644 index 0000000000..06d63bddb3 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-041.js @@ -0,0 +1,81 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is JavaScript Engine testing utilities. + * + * The Initial Developer of the Original Code is + * Netscape Communication Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = 'lexical-041.js'; + +/** + File Name: lexical-041.js + Corresponds To: 7.5-8-n.js + ECMA Section: 7.5 Identifiers + Description: Identifiers are of unlimited length + - can contain letters, a decimal digit, _, or $ + - the first character cannot be a decimal digit + - identifiers are case sensitive + + Author: christine@netscape.com + Date: 11 september 1997 +*/ +var SECTION = "lexical-041"; +var VERSION = "ECMA_1"; +var TITLE = "Identifiers"; + +startTest(); +writeHeaderToLog( SECTION + " "+ TITLE); +startTest(); +writeHeaderToLog( SECTION + " "+ TITLE); + +var result = "Failed"; +var exception = "No exception thrown"; +var expect = "Passed"; + +try { + eval("var @abc;"); +} catch ( e ) { + result = expect; + exception = e.toString(); +} + +new TestCase( + SECTION, + "var @abc" + + " (threw " + exception +")", + expect, + result ); + +test(); + + diff --git a/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-042.js b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-042.js new file mode 100644 index 0000000000..c2cedb0b81 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-042.js @@ -0,0 +1,82 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is JavaScript Engine testing utilities. + * + * The Initial Developer of the Original Code is + * Netscape Communication Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = 'lexical-042.js'; + +/** + File Name: lexical-042.js + Corresponds To: 7.5-9-n.js + ECMA Section: 7.5 Identifiers + Description: Identifiers are of unlimited length + - can contain letters, a decimal digit, _, or $ + - the first character cannot be a decimal digit + - identifiers are case sensitive + + Author: christine@netscape.com + Date: 11 september 1997 +*/ +var SECTION = "lexical-042"; +var VERSION = "JS1_4"; +var TITLE = "Identifiers"; + +startTest(); +writeHeaderToLog( SECTION + " "+ TITLE); + +startTest(); +writeHeaderToLog( SECTION + " "+ TITLE); + +var result = "Failed"; +var exception = "No exception thrown"; +var expect = "Passed"; + +try { + eval("var 123;"); +} catch ( e ) { + result = expect; + exception = e.toString(); +} + +new TestCase( + SECTION, + "var 123" + + " (threw " + exception +")", + expect, + result ); + +test(); + + diff --git a/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-047.js b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-047.js new file mode 100644 index 0000000000..e809c24149 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-047.js @@ -0,0 +1,83 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is JavaScript Engine testing utilities. + * + * The Initial Developer of the Original Code is + * Netscape Communication Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = 'lexical-047.js'; + +/** + File Name: lexical-047.js + Corresponds To: 7.8.1-7-n.js + ECMA Section: 7.8.1 + Description: + Author: christine@netscape.com + Date: 15 september 1997 +*/ + +var SECTION = "lexical-047"; +var VERSION = "JS1_4"; +var TITLE = "for loops"; + +startTest(); +writeHeaderToLog( SECTION + " "+ TITLE); + +var result = "Failed"; +var exception = "No exception thrown"; +var expect = "Passed"; + +try { + var counter = 0; + eval("for ( counter = 0\n" + + "counter <= 1\n" + + "counter++ )\n" + + "{\n" + + "result += \": got to inner loop\";\n" + + "}\n"); + +} catch ( e ) { + result = expect; + exception = e.toString(); +} + +new TestCase( + SECTION, + "line breaks within a for expression" + + " (threw " + exception +")", + expect, + result ); + +test(); + + diff --git a/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-048.js b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-048.js new file mode 100644 index 0000000000..18054d4328 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-048.js @@ -0,0 +1,77 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is JavaScript Engine testing utilities. + * + * The Initial Developer of the Original Code is + * Netscape Communication Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = 'lexical-048.js'; + +/** + File Name: lexical-048.js + Corresponds To: 7.8.1-1.js + ECMA Section: 7.8.1 Rules of Automatic Semicolon Insertion + Description: + Author: christine@netscape.com + Date: 15 september 1997 +*/ + +var SECTION = "lexical-048"; +var VERSION = "JS1_4"; +var TITLE = "The Rules of Automatic Semicolon Insertion"; + +startTest(); +writeHeaderToLog( SECTION + " "+ TITLE); + +var result = "Failed"; +var exception = "No exception thrown"; +var expect = "Passed"; + +try { + var counter = 0; + eval( "for ( counter = 0;\ncounter <= 1\ncounter++ ) {\nresult += \": got inside for loop\")"); +} catch ( e ) { + result = expect; + exception = e.toString(); +} + +new TestCase( + SECTION, + "line breaks within a for expression" + + " (threw " + exception +")", + expect, + result ); + +test(); + + diff --git a/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-049.js b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-049.js new file mode 100644 index 0000000000..e4ce840829 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-049.js @@ -0,0 +1,82 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is JavaScript Engine testing utilities. + * + * The Initial Developer of the Original Code is + * Netscape Communication Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = 'lexical-049.js'; + +/** + File Name: lexical-049 + Corresponds To: 7.8.1-1.js + ECMA Section: 7.8.1 Rules of Automatic Semicolon Insertioin + Description: + Author: christine@netscape.com + Date: 15 september 1997 +*/ +var SECTION = "lexical-049"; +var VERSION = "JS1_4"; +var TITLE = "The Rules of Automatic Semicolon Insertion"; + +startTest(); +writeHeaderToLog( SECTION + " "+ TITLE); + +var result = "Failed"; +var exception = "No exception thrown"; +var expect = "Passed"; + +try { + var counter = 0; + eval("for ( counter = 0\n" + + "counter <= 1;\n" + + "counter++ )\n" + + "{\n" + + "result += \": got inside for loop\";\n" + + "}\n"); + +} catch ( e ) { + result = expect; + exception = e.toString(); +} + +new TestCase( + SECTION, + "line breaks within a for expression" + + " (threw " + exception +")", + expect, + result ); + +test(); + + diff --git a/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-050.js b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-050.js new file mode 100644 index 0000000000..d9161c4b8f --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-050.js @@ -0,0 +1,78 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is JavaScript Engine testing utilities. + * + * The Initial Developer of the Original Code is + * Netscape Communication Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = 'lexical-050.js'; + +/** + File Name: lexical-050.js + Corresponds to: 7.8.2-1-n.js + ECMA Section: 7.8.2 Examples of Automatic Semicolon Insertion + Description: compare some specific examples of the automatic + insertion rules in the EMCA specification. + Author: christine@netscape.com + Date: 15 september 1997 +*/ + +var SECTION = "lexical-050"; +var VERSION = "JS1_4"; +var TITLE = "Examples of Automatic Semicolon Insertion"; + +startTest(); +writeHeaderToLog( SECTION + " "+ TITLE); + +var result = "Failed"; +var exception = "No exception thrown"; +var expect = "Passed"; + +try { + eval("{ 1 2 } 3"); +} catch ( e ) { + result = expect; + exception = e.toString(); +} + +new TestCase( + SECTION, + "{ 1 2 } 3" + + " (threw " + exception +")", + expect, + result ); + +test(); + + + diff --git a/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-051.js b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-051.js new file mode 100644 index 0000000000..97ccbc6b43 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-051.js @@ -0,0 +1,78 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is JavaScript Engine testing utilities. + * + * The Initial Developer of the Original Code is + * Netscape Communication Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = 'lexical-051.js'; + +/** + File Name: lexical-051.js + Corresponds to: 7.8.2-3-n.js + ECMA Section: 7.8.2 Examples of Automatic Semicolon Insertion + Description: compare some specific examples of the automatic + insertion rules in the EMCA specification. + Author: christine@netscape.com + Date: 15 september 1997 +*/ + +var SECTION = "lexical-051"; +var VERSION = "JS1_4"; +var TITLE = "Examples of Automatic Semicolon Insertion"; + +startTest(); +writeHeaderToLog( SECTION + " "+ TITLE); + +var result = "Failed"; +var exception = "No exception thrown"; +var expect = "Passed"; + +try { + eval("for (a; b\n) result += \": got to inner loop\";") + } catch ( e ) { + result = expect; + exception = e.toString(); +} + +new TestCase( + SECTION, + "for (a; b\n)" + + " (threw " + exception +")", + expect, + result ); + +test(); + + + diff --git a/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-052.js b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-052.js new file mode 100644 index 0000000000..20d2d3c254 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-052.js @@ -0,0 +1,80 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is JavaScript Engine testing utilities. + * + * The Initial Developer of the Original Code is + * Netscape Communication Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = 'lexical-052.js'; + +/** + File Name: lexical-052.js + Corresponds to: 7.8.2-4-n.js + ECMA Section: 7.8.2 Examples of Automatic Semicolon Insertion + Description: compare some specific examples of the automatic + insertion rules in the EMCA specification. + Author: christine@netscape.com + Date: 15 september 1997 +*/ + +var SECTION = "lexical-052"; +var VERSION = "JS1_4"; +var TITLE = "Examples of Automatic Semicolon Insertion"; + +startTest(); +writeHeaderToLog( SECTION + " "+ TITLE); + +var result = "Failed"; +var exception = "No exception thrown"; +var expect = "Passed"; + +try { + MyFunction(); +} catch ( e ) { + result = expect; + exception = e.toString(); +} + +new TestCase( + SECTION, + "calling return indirectly" + + " (threw " + exception +")", + expect, + result ); + +test(); + +function MyFunction() { + var s = "return"; + eval(s); +} diff --git a/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-053.js b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-053.js new file mode 100644 index 0000000000..4e64fa1322 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-053.js @@ -0,0 +1,78 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is JavaScript Engine testing utilities. + * + * The Initial Developer of the Original Code is + * Netscape Communication Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = 'lexical-053.js'; + +/** + File Name: lexical-053.js + Corresponds to: 7.8.2-7-n.js + ECMA Section: 7.8.2 Examples of Automatic Semicolon Insertion + Description: compare some specific examples of the automatic + insertion rules in the EMCA specification. + Author: christine@netscape.com + Date: 15 september 1997 +*/ + +var SECTION = "lexical-053"; +var VERSION = "JS1_4"; +var TITLE = "Examples of Automatic Semicolon Insertion"; + +startTest(); +writeHeaderToLog( SECTION + " "+ TITLE); + +var result = "Failed"; +var exception = "No exception thrown"; +var expect = "Passed"; + +try { + a = true + b = false + + eval('if (a > b)\nelse result += ": got to else statement"'); +} catch ( e ) { + result = expect; + exception = e.toString(); +} + +new TestCase( + SECTION, + "calling return indirectly" + + " (threw " + exception +")", + expect, + result ); + +test(); diff --git a/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-054.js b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-054.js new file mode 100644 index 0000000000..3e25c36ef8 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-054.js @@ -0,0 +1,79 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is JavaScript Engine testing utilities. + * + * The Initial Developer of the Original Code is + * Netscape Communication Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = 'lexical-054.js'; + +/** + File Name: lexical-054.js + Corresponds to: 7.8.2-7-n.js + ECMA Section: 7.8.2 Examples of Automatic Semicolon Insertion + Description: compare some specific examples of the automatic + insertion rules in the EMCA specification. + Author: christine@netscape.com + Date: 15 september 1997 +*/ + +var SECTION = "lexical-054"; +var VERSION = "JS1_4"; +var TITLE = "Examples of Automatic Semicolon Insertion"; + +startTest(); +writeHeaderToLog( SECTION + " "+ TITLE); + +var result = "Failed"; +var exception = "No exception thrown"; +var expect = "Passed"; + +try { + a=0; + b=1; + c=2; + d=3; + eval("if (a > b)\nelse c = d"); +} catch ( e ) { + result = expect; + exception = e.toString(); +} + +new TestCase( + SECTION, + "if (a > b)\nelse c = d" + + " (threw " + exception +")", + expect, + result ); + +test(); diff --git a/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/number-001.js b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/number-001.js new file mode 100644 index 0000000000..eb49a5b9bd --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/number-001.js @@ -0,0 +1,86 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is JavaScript Engine testing utilities. + * + * The Initial Developer of the Original Code is + * Netscape Communication Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = 'number-001.js'; + +/** + File Name: number-001 + Corresponds To: 15.7.4.2-2-n.js + ECMA Section: 15.7.4.2.2 Number.prototype.toString() + Description: + If the radix is the number 10 or not supplied, then this number value is + given as an argument to the ToString operator; the resulting string value + is returned. + + If the radix is supplied and is an integer from 2 to 36, but not 10, the + result is a string, the choice of which is implementation dependent. + + The toString function is not generic; it generates a runtime error if its + this value is not a Number object. Therefore it cannot be transferred to + other kinds of objects for use as a method. + + Author: christine@netscape.com + Date: 16 september 1997 +*/ +var SECTION = "number-001"; +var VERSION = "JS1_4"; +var TITLE = "Exceptions for Number.toString()"; + +startTest(); +writeHeaderToLog( SECTION + " Number.prototype.toString()"); + +var result = "Failed"; +var exception = "No exception thrown"; +var expect = "Passed"; + +try { + object= new Object(); + object.toString = Number.prototype.toString; + result = object.toString(); +} catch ( e ) { + result = expect; + exception = e.toString(); +} + +new TestCase( + SECTION, + "object = new Object(); object.toString = Number.prototype.toString; object.toString()" + + " (threw " + exception +")", + expect, + result ); + +test(); diff --git a/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/number-002.js b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/number-002.js new file mode 100644 index 0000000000..fef61fd527 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/number-002.js @@ -0,0 +1,81 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is JavaScript Engine testing utilities. + * + * The Initial Developer of the Original Code is + * Netscape Communication Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = 'number-002.js'; + +/** + File Name: number-002.js + Corresponds To: ecma/Number/15.7.4.3-2-n.js + ECMA Section: 15.7.4.3.1 Number.prototype.valueOf() + Description: + Returns this number value. + + The valueOf function is not generic; it generates a runtime error if its + this value is not a Number object. Therefore it cannot be transferred to + other kinds of objects for use as a method. + + Author: christine@netscape.com + Date: 16 september 1997 +*/ +var SECTION = "number-002"; +var VERSION = "JS1_4"; +var TITLE = "Exceptions for Number.valueOf()"; + +startTest(); +writeHeaderToLog( SECTION + " Number.prototype.valueOf()"); + +var result = "Failed"; +var exception = "No exception thrown"; +var expect = "Passed"; + +try { + object= new Object(); + object.toString = Number.prototype.valueOf; + result = object.toString(); +} catch ( e ) { + result = expect; + exception = e.toString(); +} + +new TestCase( + SECTION, + "object = new Object(); object.valueOf = Number.prototype.valueOf; object.valueOf()" + + " (threw " + exception +")", + expect, + result ); + +test(); diff --git a/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/number-003.js b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/number-003.js new file mode 100644 index 0000000000..46920b7072 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/number-003.js @@ -0,0 +1,83 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is JavaScript Engine testing utilities. + * + * The Initial Developer of the Original Code is + * Netscape Communication Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = 'number-003.js'; + +/** + File Name: number-003.js + Corresponds To: 15.7.4.3-3.js + ECMA Section: 15.7.4.3.1 Number.prototype.valueOf() + Description: + Returns this number value. + + The valueOf function is not generic; it generates a runtime error if its + this value is not a Number object. Therefore it cannot be transferred to + other kinds of objects for use as a method. + + Author: christine@netscape.com + Date: 16 september 1997 +*/ +var SECTION = "number-003"; +var VERSION = "JS1_4"; +var TITLE = "Exceptions for Number.valueOf()"; + +startTest(); +writeHeaderToLog( SECTION + " Number.prototype.valueOf()"); + +var result = "Failed"; +var exception = "No exception thrown"; +var expect = "Passed"; + +try { + VALUE_OF = Number.prototype.valueOf; + OBJECT = new String("Infinity"); + OBJECT.valueOf = VALUE_OF; + result = OBJECT.valueOf(); +} catch ( e ) { + result = expect; + exception = e.toString(); +} + +new TestCase( + SECTION, + "Assigning Number.prototype.valueOf as the valueOf of a String object " + + " (threw " + exception +")", + expect, + result ); + +test(); + diff --git a/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/shell.js b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/shell.js new file mode 100644 index 0000000000..6c671f1eea --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/shell.js @@ -0,0 +1 @@ +gTestsubsuite = 'Exceptions'; diff --git a/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/statement-001.js b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/statement-001.js new file mode 100644 index 0000000000..98e3d61a0c --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/statement-001.js @@ -0,0 +1,80 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is JavaScript Engine testing utilities. + * + * The Initial Developer of the Original Code is + * Netscape Communication Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = 'statement-001.js'; + +/** + File Name: statement-001.js + Corresponds To: 12.6.2-9-n.js + ECMA Section: 12.6.2 The for Statement + + 1. first expression is not present. + 2. second expression is not present + 3. third expression is not present + + + Author: christine@netscape.com + Date: 15 september 1997 +*/ + +var SECTION = "statement-001.js"; +// var SECTION = "12.6.2-9-n"; +var VERSION = "ECMA_1"; +var TITLE = "The for statement"; + +startTest(); +writeHeaderToLog( SECTION + " "+ TITLE); + +var result = "Failed"; +var exception = "No exception thrown"; +var expect = "Passed"; + +try { + eval("for (i) {\n}"); +} catch ( e ) { + result = expect; + exception = e.toString(); +} + +new TestCase( + SECTION, + "for(i) {}" + + " (threw " + exception +")", + expect, + result ); + +test(); diff --git a/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/statement-002.js b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/statement-002.js new file mode 100644 index 0000000000..da9931e9ab --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/statement-002.js @@ -0,0 +1,102 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is JavaScript Engine testing utilities. + * + * The Initial Developer of the Original Code is + * Netscape Communication Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = 'statement-002.js'; + +/** + File Name: statement-002.js + Corresponds To: 12.6.3-1.js + ECMA Section: 12.6.3 The for...in Statement + Description: + The production IterationStatement : for ( LeftHandSideExpression in Expression ) + Statement is evaluated as follows: + + 1. Evaluate the Expression. + 2. Call GetValue(Result(1)). + 3. Call ToObject(Result(2)). + 4. Let C be "normal completion". + 5. Get the name of the next property of Result(3) that doesn't have the + DontEnum attribute. If there is no such property, go to step 14. + 6. Evaluate the LeftHandSideExpression ( it may be evaluated repeatedly). + 7. Call PutValue(Result(6), Result(5)). PutValue( V, W ): + 1. If Type(V) is not Reference, generate a runtime error. + 2. Call GetBase(V). + 3. If Result(2) is null, go to step 6. + 4. Call the [[Put]] method of Result(2), passing GetPropertyName(V) + for the property name and W for the value. + 5. Return. + 6. Call the [[Put]] method for the global object, passing + GetPropertyName(V) for the property name and W for the value. + 7. Return. + 8. Evaluate Statement. + 9. If Result(8) is a value completion, change C to be "normal completion + after value V" where V is the value carried by Result(8). + 10. If Result(8) is a break completion, go to step 14. + 11. If Result(8) is a continue completion, go to step 5. + 12. If Result(8) is a return completion, return Result(8). + 13. Go to step 5. + 14. Return C. + + Author: christine@netscape.com + Date: 11 september 1997 +*/ +var SECTION = "statement-002"; +var VERSION = "JS1_4"; +var TITLE = "The for..in statement"; + +startTest(); +writeHeaderToLog( SECTION + " "+ TITLE); + +var result = "Failed"; +var exception = "No exception thrown"; +var expect = "Passed"; + +try { + eval(" for ( var i, p in this) { result += this[p]; }"); +} catch ( e ) { + result = expect; + exception = e.toString(); +} + +new TestCase( + SECTION, + "more than one member expression" + + " (threw " + exception +")", + expect, + result ); + +test(); diff --git a/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/statement-003.js b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/statement-003.js new file mode 100644 index 0000000000..d51083c4cf --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/statement-003.js @@ -0,0 +1,113 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is JavaScript Engine testing utilities. + * + * The Initial Developer of the Original Code is + * Netscape Communication Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = 'statement-003.js'; + +/** + File Name: statement-003 + Corresponds To: 12.6.3-7-n.js + ECMA Section: 12.6.3 The for...in Statement + Description: + The production IterationStatement : for ( LeftHandSideExpression in Expression ) + Statement is evaluated as follows: + + 1. Evaluate the Expression. + 2. Call GetValue(Result(1)). + 3. Call ToObject(Result(2)). + 4. Let C be "normal completion". + 5. Get the name of the next property of Result(3) that doesn't have the + DontEnum attribute. If there is no such property, go to step 14. + 6. Evaluate the LeftHandSideExpression ( it may be evaluated repeatedly). + 7. Call PutValue(Result(6), Result(5)). PutValue( V, W ): + 1. If Type(V) is not Reference, generate a runtime error. + 2. Call GetBase(V). + 3. If Result(2) is null, go to step 6. + 4. Call the [[Put]] method of Result(2), passing GetPropertyName(V) + for the property name and W for the value. + 5. Return. + 6. Call the [[Put]] method for the global object, passing + GetPropertyName(V) for the property name and W for the value. + 7. Return. + 8. Evaluate Statement. + 9. If Result(8) is a value completion, change C to be "normal completion + after value V" where V is the value carried by Result(8). + 10. If Result(8) is a break completion, go to step 14. + 11. If Result(8) is a continue completion, go to step 5. + 12. If Result(8) is a return completion, return Result(8). + 13. Go to step 5. + 14. Return C. + + Author: christine@netscape.com + Date: 11 september 1997 +*/ +var SECTION = "statement-003"; +var VERSION = "JS1_4"; +var TITLE = "The for..in statement"; + +startTest(); +writeHeaderToLog( SECTION + " "+ TITLE); + +var result = "Failed"; +var exception = "No exception thrown"; +var expect = "Passed"; + +try { + var o = new MyObject(); + var result = 0; + + eval("for ( this in o) {\n" + + "result += this[p];\n" + + "}\n"); +} catch ( e ) { + result = expect; + exception = e.toString(); +} + +new TestCase( + SECTION, + "bad left-hand side expression" + + " (threw " + exception +")", + expect, + result ); + +test(); + +function MyObject() { + this.value = 2; + this[0] = 4; + return this; +} diff --git a/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/statement-004.js b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/statement-004.js new file mode 100644 index 0000000000..8b9789a929 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/statement-004.js @@ -0,0 +1,85 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is JavaScript Engine testing utilities. + * + * The Initial Developer of the Original Code is + * Netscape Communication Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = 'statement-004.js'; + +/** + File Name: statement-004.js + Corresponds To: 12.6.3-1.js + ECMA Section: 12.6.3 The for...in Statement + Description: + Author: christine@netscape.com + Date: 11 september 1997 +*/ +var SECTION = "statement-004"; +var VERSION = "JS1_4"; +var TITLE = "The for..in statement"; + +startTest(); +writeHeaderToLog( SECTION + " "+ TITLE); + +var result = "Failed"; +var exception = "No exception thrown"; +var expect = "Passed"; + +try { + var o = new MyObject(); + + eval("for ( \"a\" in o) {\n" + + "result += this[p];\n" + + "}"); + +} catch ( e ) { + result = expect; + exception = e.toString(); +} + +new TestCase( + SECTION, + "bad left-hand side expression" + + " (threw " + exception +")", + expect, + result ); + +test(); + + +function MyObject() { + this.value = 2; + this[0] = 4; + return this; +} diff --git a/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/statement-005.js b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/statement-005.js new file mode 100644 index 0000000000..62a8c45d92 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/statement-005.js @@ -0,0 +1,84 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is JavaScript Engine testing utilities. + * + * The Initial Developer of the Original Code is + * Netscape Communication Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = 'statement-005.js'; + +/** + File Name: statement-005.js + Corresponds To: 12.6.3-8-n.js + ECMA Section: 12.6.3 The for...in Statement + Description: + Author: christine@netscape.com + Date: 11 september 1997 +*/ +var SECTION = "statement-005"; +var VERSION = "JS1_4"; +var TITLE = "The for..in statement"; + +startTest(); +writeHeaderToLog( SECTION + " "+ TITLE); + +var result = "Failed"; +var exception = "No exception thrown"; +var expect = "Passed"; + +try { + var o = new MyObject(); + result = 0; + + eval("for (1 in o) {\n" + + "result += this[p];" + + "}\n"); +} catch ( e ) { + result = expect; + exception = e.toString(); +} + +new TestCase( + SECTION, + "bad left-hand side expression" + + " (threw " + exception +")", + expect, + result ); + +test(); + +function MyObject() { + this.value = 2; + this[0] = 4; + return this; +} diff --git a/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/statement-006.js b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/statement-006.js new file mode 100644 index 0000000000..ec5ba97576 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/statement-006.js @@ -0,0 +1,84 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is JavaScript Engine testing utilities. + * + * The Initial Developer of the Original Code is + * Netscape Communication Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = 'statement-006.js'; + +/** + File Name: statement-006.js + Corresponds To: 12.6.3-9-n.js + ECMA Section: 12.6.3 The for...in Statement + Description: + + Author: christine@netscape.com + Date: 11 september 1997 +*/ +var SECTION = "statement-006"; +var VERSION = "JS1_4"; +var TITLE = "The for..in statement"; + +startTest(); +writeHeaderToLog( SECTION + " "+ TITLE); + +var result = "Failed"; +var exception = "No exception thrown"; +var expect = "Passed"; + +try { + var o = new MyObject(); + var result = 0; + for ( var o in foo) { + result += this[o]; + } +} catch ( e ) { + result = expect; + exception = e.toString(); +} + +new TestCase( + SECTION, + "object is not defined" + + " (threw " + exception +")", + expect, + result ); + +test(); + +function MyObject() { + this.value = 2; + this[0] = 4; + return this; +} diff --git a/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/statement-007.js b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/statement-007.js new file mode 100644 index 0000000000..bb367c9924 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/statement-007.js @@ -0,0 +1,75 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is JavaScript Engine testing utilities. + * + * The Initial Developer of the Original Code is + * Netscape Communication Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = 'statement-007.js'; + +/** + File Name: statement-007.js + Corresponds To: 12.7-1-n.js + ECMA Section: 12.7 The continue statement + Description: + + Author: christine@netscape.com + Date: 12 november 1997 +*/ +var SECTION = "statement-007"; +var VERSION = "JS1_4"; +var TITLE = "The continue statement"; + +startTest(); +writeHeaderToLog( SECTION + " "+ TITLE); + +var result = "Failed"; +var exception = "No exception thrown"; +var expect = "Passed"; + +try { + eval("continue;"); +} catch ( e ) { + result = expect; + exception = e.toString(); +} + +new TestCase( + SECTION, + "continue outside of an iteration statement" + + " (threw " + exception +")", + expect, + result ); + +test(); + diff --git a/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/statement-008.js b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/statement-008.js new file mode 100644 index 0000000000..54ab39a9c9 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/statement-008.js @@ -0,0 +1,75 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is JavaScript Engine testing utilities. + * + * The Initial Developer of the Original Code is + * Netscape Communication Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = 'statement-008.js'; + +/** + File Name: statement-008.js + Corresponds To: 12.8-1-n.js + ECMA Section: 12.8 The break statement + Description: + + Author: christine@netscape.com + Date: 12 november 1997 +*/ +var SECTION = "statement-008"; +var VERSION = "JS1_4"; +var TITLE = "The break in statement"; + +startTest(); +writeHeaderToLog( SECTION + " "+ TITLE); + +var result = "Failed"; +var exception = "No exception thrown"; +var expect = "Passed"; + +try { + eval("break;"); +} catch ( e ) { + result = expect; + exception = e.toString(); +} + +new TestCase( + SECTION, + "break outside of an iteration statement" + + " (threw " + exception +")", + expect, + result ); + +test(); + diff --git a/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/statement-009.js b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/statement-009.js new file mode 100644 index 0000000000..a63bd84e8e --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/statement-009.js @@ -0,0 +1,74 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is JavaScript Engine testing utilities. + * + * The Initial Developer of the Original Code is + * Netscape Communication Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = 'statement-009.js'; + +/** + File Name: 12.9-1-n.js + ECMA Section: 12.9 The return statement + Description: + + Author: christine@netscape.com + Date: 12 november 1997 +*/ +var SECTION = "12.9-1-n"; +var VERSION = "ECMA_1"; +var TITLE = "The return statement"; + +startTest(); +writeHeaderToLog( SECTION + " The return statement"); + +var result = "Failed"; +var exception = "No exception thrown"; +var expect = "Passed"; + +try { + eval("return;"); +} catch ( e ) { + result = expect; + exception = e.toString(); +} + +new TestCase( + SECTION, + "return outside of a function" + + " (threw " + exception +")", + expect, + result ); + +test(); + diff --git a/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/string-001.js b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/string-001.js new file mode 100644 index 0000000000..551030db33 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/string-001.js @@ -0,0 +1,86 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is JavaScript Engine testing utilities. + * + * The Initial Developer of the Original Code is + * Netscape Communication Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = 'string-001.js'; + +/** + File Name: string-001.js + Corresponds To: 15.5.4.2-2-n.js + ECMA Section: 15.5.4.2 String.prototype.toString() + + Description: Returns this string value. Note that, for a String + object, the toString() method happens to return the same + thing as the valueOf() method. + + The toString function is not generic; it generates a + runtime error if its this value is not a String object. + Therefore it connot be transferred to the other kinds of + objects for use as a method. + + Author: christine@netscape.com + Date: 1 october 1997 +*/ +var SECTION = "string-001"; +var VERSION = "JS1_4"; +var TITLE = "String.prototype.toString"; + +startTest(); +writeHeaderToLog( SECTION + " "+ TITLE); + +var result = "Failed"; +var exception = "No exception thrown"; +var expect = "Passed"; + +try { + OBJECT = new Object(); + OBJECT.toString = String.prototype.toString(); + result = OBJECT.toString(); +} catch ( e ) { + result = expect; + exception = e.toString(); +} + +new TestCase( + SECTION, + "OBJECT = new Object; "+ + " OBJECT.toString = String.prototype.toString; OBJECT.toString()" + + " (threw " + exception +")", + expect, + result ); + +test(); + diff --git a/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/string-002.js b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/string-002.js new file mode 100644 index 0000000000..785e339080 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/string-002.js @@ -0,0 +1,85 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is JavaScript Engine testing utilities. + * + * The Initial Developer of the Original Code is + * Netscape Communication Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = 'string-002.js'; + +/** + File Name: string-002.js + Corresponds To: 15.5.4.3-3-n.js + ECMA Section: 15.5.4.3 String.prototype.valueOf() + + Description: Returns this string value. + + The valueOf function is not generic; it generates a + runtime error if its this value is not a String object. + Therefore it connot be transferred to the other kinds of + objects for use as a method. + + Author: christine@netscape.com + Date: 1 october 1997 +*/ +var SECTION = "string-002"; +var VERSION = "JS1_4"; +var TITLE = "String.prototype.valueOf"; + +startTest(); +writeHeaderToLog( SECTION + " "+ TITLE); + +var result = "Failed"; +var exception = "No exception thrown"; +var expect = "Passed"; + +try { + var OBJECT =new Object(); + OBJECT.valueOf = String.prototype.valueOf; + result = OBJECT.valueOf(); +} catch ( e ) { + result = expect; + exception = e.toString(); +} + +new TestCase( + SECTION, + "OBJECT = new Object; OBJECT.valueOf = String.prototype.valueOf;"+ + "result = OBJECT.valueOf();" + + " (threw " + exception +")", + expect, + result ); + +test(); + + diff --git a/tests/auto/qml/parserstress/tests/ecma_2/Expressions/StrictEquality-001.js b/tests/auto/qml/parserstress/tests/ecma_2/Expressions/StrictEquality-001.js new file mode 100644 index 0000000000..db5c403d3d --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma_2/Expressions/StrictEquality-001.js @@ -0,0 +1,106 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is JavaScript Engine testing utilities. + * + * The Initial Developer of the Original Code is + * Netscape Communication Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = 'StrictEquality-001.js'; + +/** + * File Name: StrictEquality-001.js + * ECMA Section: 11.9.6.js + * Description: + * + * Author: christine@netscape.com + * Date: 4 september 1998 + */ +var SECTION = "StrictEquality-001 - 11.9.6"; +var VERSION = "ECMA_2"; +var TITLE = "The strict equality operator ( === )"; + +startTest(); +writeHeaderToLog( SECTION + " "+ TITLE); + + +// 1. If Type(x) is different from Type(y) return false + +StrictEquality( true, new Boolean(true), false ); +StrictEquality( new Boolean(), false, false ); +StrictEquality( "", new String(), false ); +StrictEquality( new String("hi"), "hi", false ); + +// 2. If Type(x) is not Number go to step 9. + +// 3. If x is NaN, return false +StrictEquality( NaN, NaN, false ); +StrictEquality( NaN, 0, false ); + +// 4. If y is NaN, return false. +StrictEquality( 0, NaN, false ); + +// 5. if x is the same number value as y, return true + +// 6. If x is +0 and y is -0, return true + +// 7. If x is -0 and y is +0, return true + +// 8. Return false. + + +// 9. If Type(x) is String, then return true if x and y are exactly +// the same sequence of characters ( same length and same characters +// in corresponding positions.) Otherwise return false. + +// 10. If Type(x) is Boolean, return true if x and y are both true or +// both false. otherwise return false. + + +// Return true if x and y refer to the same object. Otherwise return +// false. + +// Return false. + + +test(); + +function StrictEquality( x, y, expect ) { + result = ( x === y ); + + new TestCase( + SECTION, + x +" === " + y, + expect, + result ); +} + diff --git a/tests/auto/qml/parserstress/tests/ecma_2/Expressions/browser.js b/tests/auto/qml/parserstress/tests/ecma_2/Expressions/browser.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/auto/qml/parserstress/tests/ecma_2/Expressions/shell.js b/tests/auto/qml/parserstress/tests/ecma_2/Expressions/shell.js new file mode 100644 index 0000000000..8f5d1129d5 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma_2/Expressions/shell.js @@ -0,0 +1 @@ +gTestsubsuite = 'Expressions'; diff --git a/tests/auto/qml/parserstress/tests/ecma_2/FunctionObjects/apply-001-n.js b/tests/auto/qml/parserstress/tests/ecma_2/FunctionObjects/apply-001-n.js new file mode 100644 index 0000000000..e58d087121 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma_2/FunctionObjects/apply-001-n.js @@ -0,0 +1,65 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- + * + * ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * Rob Ginda rginda@netscape.com + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = 'apply-001-n.js'; + +print("STATUS: f.apply crash test."); + +print("BUGNUMBER: 21836"); + +function f () +{ +} + +var SECTION = "apply-001-n"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "f.apply(2,2) doesn't crash"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +DESCRIPTION = "f.apply(2,2) doesn't crash"; +EXPECTED = "error"; + +new TestCase( SECTION, "f.apply(2,2) doesn't crash", "error", eval("f.apply(2,2)") ); + +test(); + + diff --git a/tests/auto/qml/parserstress/tests/ecma_2/FunctionObjects/browser.js b/tests/auto/qml/parserstress/tests/ecma_2/FunctionObjects/browser.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/auto/qml/parserstress/tests/ecma_2/FunctionObjects/call-1.js b/tests/auto/qml/parserstress/tests/ecma_2/FunctionObjects/call-1.js new file mode 100644 index 0000000000..283e323797 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma_2/FunctionObjects/call-1.js @@ -0,0 +1,75 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is JavaScript Engine testing utilities. + * + * The Initial Developer of the Original Code is + * Netscape Communication Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = 'call-1.js'; + +/** + File Name: call-1.js + Section: Function.prototype.call + Description: + + + Author: christine@netscape.com + Date: 12 november 1997 +*/ +var SECTION = "call-1"; +var VERSION = "ECMA_2"; +var TITLE = "Function.prototype.call"; + +startTest(); +writeHeaderToLog( SECTION + " "+ TITLE); + +new TestCase( SECTION, + "ToString.call( this, this )", + GLOBAL, + ToString.call( this, this ) ); + +new TestCase( SECTION, + "ToString.call( Boolean, Boolean.prototype )", + "false", + ToString.call( Boolean, Boolean.prototype ) ); + +new TestCase( SECTION, + "ToString.call( Boolean, Boolean.prototype.valueOf() )", + "false", + ToString.call( Boolean, Boolean.prototype.valueOf() ) ); + +test(); + +function ToString( obj ) { + return obj +""; +} diff --git a/tests/auto/qml/parserstress/tests/ecma_2/FunctionObjects/shell.js b/tests/auto/qml/parserstress/tests/ecma_2/FunctionObjects/shell.js new file mode 100644 index 0000000000..27aa7b1318 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma_2/FunctionObjects/shell.js @@ -0,0 +1 @@ +gTestsubsuite = 'FunctionObjects'; diff --git a/tests/auto/qml/parserstress/tests/ecma_2/LexicalConventions/browser.js b/tests/auto/qml/parserstress/tests/ecma_2/LexicalConventions/browser.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/auto/qml/parserstress/tests/ecma_2/LexicalConventions/keywords-001.js b/tests/auto/qml/parserstress/tests/ecma_2/LexicalConventions/keywords-001.js new file mode 100644 index 0000000000..7362613783 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma_2/LexicalConventions/keywords-001.js @@ -0,0 +1,81 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is JavaScript Engine testing utilities. + * + * The Initial Developer of the Original Code is + * Netscape Communication Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = 'keywords-001.js'; + +/** + * File Name: + * ECMA Section: + * Description: + * + * + * Author: christine@netscape.com + * Date: 11 August 1998 + */ +var SECTION = ""; +var VERSION = "ECMA_2"; +var TITLE = "Keywords"; + +startTest(); + +print("This test requires option javascript.options.strict enabled"); + +if (!options().match(/strict/)) +{ + options('strict'); +} +if (!options().match(/werror/)) +{ + options('werror'); +} + +var result = "failed"; + +try { + eval("super;"); +} +catch (x) { + if (x instanceof SyntaxError) + result = x.name; +} + +AddTestCase( + "using the expression \"super\" shouldn't cause js to crash", + "SyntaxError", + result ); + +test(); diff --git a/tests/auto/qml/parserstress/tests/ecma_2/LexicalConventions/regexp-literals-001.js b/tests/auto/qml/parserstress/tests/ecma_2/LexicalConventions/regexp-literals-001.js new file mode 100644 index 0000000000..caa50fe363 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma_2/LexicalConventions/regexp-literals-001.js @@ -0,0 +1,77 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is JavaScript Engine testing utilities. + * + * The Initial Developer of the Original Code is + * Netscape Communication Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = 'regexp-literals-001.js'; + +/** + * File Name: LexicalConventions/regexp-literals-001.js + * ECMA Section: 7.8.5 + * Description: + * + * + * Author: christine@netscape.com + * Date: 11 August 1998 + */ +var SECTION = "LexicalConventions/regexp-literals-001.js"; +var VERSION = "ECMA_2"; +var TITLE = "Regular Expression Literals"; + +startTest(); + +// Regular Expression Literals may not be empty; // should be regarded +// as a comment, not a RegExp literal. + +s = //; + + "passed"; + +AddTestCase( + "// should be a comment, not a regular expression literal", + "passed", + String(s)); + +AddTestCase( + "// typeof object should be type of object declared on following line", + "passed", + (typeof s) == "string" ? "passed" : "failed" ); + +AddTestCase( + "// should not return an object of the type RegExp", + "passed", + (typeof s == "object") ? "failed" : "passed" ); + +test(); diff --git a/tests/auto/qml/parserstress/tests/ecma_2/LexicalConventions/regexp-literals-002.js b/tests/auto/qml/parserstress/tests/ecma_2/LexicalConventions/regexp-literals-002.js new file mode 100644 index 0000000000..911b5d117a --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma_2/LexicalConventions/regexp-literals-002.js @@ -0,0 +1,61 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is JavaScript Engine testing utilities. + * + * The Initial Developer of the Original Code is + * Netscape Communication Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = 'regexp-literals-002.js'; + +/** + * File Name: LexicalConventions/regexp-literals-002.js + * ECMA Section: 7.8.5 + * Description: Based on ECMA 2 Draft 8 October 1999 + * + * Author: christine@netscape.com + * Date: 19 February 1999 + */ +var SECTION = "LexicalConventions/regexp-literals-002.js"; +var VERSION = "ECMA_2"; +var TITLE = "Regular Expression Literals"; + +startTest(); + +// A regular expression literal represents an object of type RegExp. + +AddTestCase( + "// A regular expression literal represents an object of type RegExp.", + "true", + (/x*/ instanceof RegExp).toString() ); + +test(); diff --git a/tests/auto/qml/parserstress/tests/ecma_2/LexicalConventions/shell.js b/tests/auto/qml/parserstress/tests/ecma_2/LexicalConventions/shell.js new file mode 100644 index 0000000000..4e1d61d68a --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma_2/LexicalConventions/shell.js @@ -0,0 +1 @@ +gTestsubsuite = 'LexicalConventions'; diff --git a/tests/auto/qml/parserstress/tests/ecma_2/README b/tests/auto/qml/parserstress/tests/ecma_2/README new file mode 100755 index 0000000000..6da6cdd514 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma_2/README @@ -0,0 +1 @@ +ECMA 262 Edition 2 diff --git a/tests/auto/qml/parserstress/tests/ecma_2/RegExp/browser.js b/tests/auto/qml/parserstress/tests/ecma_2/RegExp/browser.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/auto/qml/parserstress/tests/ecma_2/RegExp/constructor-001.js b/tests/auto/qml/parserstress/tests/ecma_2/RegExp/constructor-001.js new file mode 100644 index 0000000000..f1dba13b06 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma_2/RegExp/constructor-001.js @@ -0,0 +1,99 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is JavaScript Engine testing utilities. + * + * The Initial Developer of the Original Code is + * Netscape Communication Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = 'constructor-001.js'; + +/** + * File Name: RegExp/constructor-001.js + * ECMA Section: 15.7.3.3 + * Description: Based on ECMA 2 Draft 7 February 1999 + * + * Author: christine@netscape.com + * Date: 19 February 1999 + */ +var SECTION = "RegExp/constructor-001"; +var VERSION = "ECMA_2"; +var TITLE = "new RegExp()"; + +startTest(); + +/* + * for each test case, verify: + * - verify that [[Class]] property is RegExp + * - prototype property should be set to RegExp.prototype + * - source is set to the empty string + * - global property is set to false + * - ignoreCase property is set to false + * - multiline property is set to false + * - lastIndex property is set to 0 + */ + +RegExp.prototype.getClassProperty = Object.prototype.toString; +var re = new RegExp(); + +AddTestCase( + "RegExp.prototype.getClassProperty = Object.prototype.toString; " + + "(new RegExp()).getClassProperty()", + "[object RegExp]", + re.getClassProperty() ); + +AddTestCase( + "(new RegExp()).source", + "", + re.source ); + +AddTestCase( + "(new RegExp()).global", + false, + re.global ); + +AddTestCase( + "(new RegExp()).ignoreCase", + false, + re.ignoreCase ); + +AddTestCase( + "(new RegExp()).multiline", + false, + re.multiline ); + +AddTestCase( + "(new RegExp()).lastIndex", + 0, + re.lastIndex ); + +test() diff --git a/tests/auto/qml/parserstress/tests/ecma_2/RegExp/exec-001.js b/tests/auto/qml/parserstress/tests/ecma_2/RegExp/exec-001.js new file mode 100644 index 0000000000..2d1bab472c --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma_2/RegExp/exec-001.js @@ -0,0 +1,73 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is JavaScript Engine testing utilities. + * + * The Initial Developer of the Original Code is + * Netscape Communication Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = 'exec-001.js'; + +/** + * File Name: RegExp/exec-001.js + * ECMA Section: 15.7.5.3 + * Description: Based on ECMA 2 Draft 7 February 1999 + * + * Author: christine@netscape.com + * Date: 19 February 1999 + */ +var SECTION = "RegExp/exec-001"; +var VERSION = "ECMA_2"; +var TITLE = "RegExp.prototype.exec(string)"; + +startTest(); + +/* + * for each test case, verify: + * - type of object returned + * - length of the returned array + * - value of lastIndex + * - value of index + * - value of input + * - value of the array indices + */ + +// test cases without subpatterns +// test cases with subpatterns +// global property is true +// global property is false +// test cases in which the exec returns null + +AddTestCase("NO TESTS EXIST", "PASSED", "Test not implemented"); + +test(); + diff --git a/tests/auto/qml/parserstress/tests/ecma_2/RegExp/exec-002.js b/tests/auto/qml/parserstress/tests/ecma_2/RegExp/exec-002.js new file mode 100644 index 0000000000..026f27d9d4 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma_2/RegExp/exec-002.js @@ -0,0 +1,221 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is JavaScript Engine testing utilities. + * + * The Initial Developer of the Original Code is + * Netscape Communication Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = 'exec-002.js'; + +/** + * File Name: RegExp/exec-002.js + * ECMA Section: 15.7.5.3 + * Description: Based on ECMA 2 Draft 7 February 1999 + * + * Test cases provided by rogerl@netscape.com + * + * Author: christine@netscape.com + * Date: 19 February 1999 + */ +var SECTION = "RegExp/exec-002"; +var VERSION = "ECMA_2"; +var TITLE = "RegExp.prototype.exec(string)"; + +startTest(); + +/* + * for each test case, verify: + * - type of object returned + * - length of the returned array + * - value of lastIndex + * - value of index + * - value of input + * - value of the array indices + */ + +AddRegExpCases( + /(a|d|q|)x/i, + "bcaDxqy", + 3, + ["Dx", "D"] ); + +AddRegExpCases( + /(a|(e|q))(x|y)/, + "bcaddxqy", + 6, + ["qy","q","q","y"] ); + + +AddRegExpCases( + /a+b+d/, + "aabbeeaabbs", + 0, + null ); + +AddRegExpCases( + /a*b/, + "aaadaabaaa", + 4, + ["aab"] ); + +AddRegExpCases( + /a*b/, + "dddb", + 3, + ["b"] ); + +AddRegExpCases( + /a*b/, + "xxx", + 0, + null ); + +AddRegExpCases( + /x\d\dy/, + "abcx45ysss235", + 3, + ["x45y"] ); + +AddRegExpCases( + /[^abc]def[abc]+/, + "abxdefbb", + 2, + ["xdefbb"] ); + +AddRegExpCases( + /(a*)baa/, + "ccdaaabaxaabaa", + 9, + ["aabaa", "aa"] ); + +AddRegExpCases( + /(a*)baa/, + "aabaa", + 0, + ["aabaa", "aa"] ); + +AddRegExpCases( + /q(a|b)*q/, + "xxqababqyy", + 2, + ["qababq", "b"] ); + +AddRegExpCases( + /(a(.|[^d])c)*/, + "adcaxc", + 0, + ["adcaxc", "axc", "x"] ); + +AddRegExpCases( + /(a*)b\1/, + "abaaaxaabaayy", + 0, + ["aba", "a"] ); + +AddRegExpCases( + /(a*)b\1/, + "abaaaxaabaayy", + 0, + ["aba", "a"] ); + +AddRegExpCases( + /(a*)b\1/, + "cccdaaabaxaabaayy", + 6, + ["aba", "a"] ); + +AddRegExpCases( + /(a*)b\1/, + "cccdaaabqxaabaayy", + 7, + ["b", ""] ); + +AddRegExpCases( + /"(.|[^"\\\\])*"/, + 'xx\"makudonarudo\"yy', + 2, + ["\"makudonarudo\"", "o"] ); + + AddRegExpCases( + /"(.|[^"\\\\])*"/, + "xx\"ma\"yy", + 2, + ["\"ma\"", "a"] ); + + test(); + + function AddRegExpCases( + regexp, pattern, index, matches_array ) { + +// prevent a runtime error + + if ( regexp.exec(pattern) == null || matches_array == null ) { + AddTestCase( + regexp + ".exec(" + pattern +")", + matches_array, + regexp.exec(pattern) ); + + return; + } + AddTestCase( + regexp + ".exec(" + pattern +").length", + matches_array.length, + regexp.exec(pattern).length ); + + AddTestCase( + regexp + ".exec(" + pattern +").index", + index, + regexp.exec(pattern).index ); + + AddTestCase( + regexp + ".exec(" + pattern +").input", + pattern, + regexp.exec(pattern).input ); + + AddTestCase( + regexp + ".exec(" + pattern +").toString()", + matches_array.toString(), + regexp.exec(pattern).toString() ); +/* + var limit = matches_array.length > regexp.exec(pattern).length + ? matches_array.length + : regexp.exec(pattern).length; + + for ( var matches = 0; matches < limit; matches++ ) { + AddTestCase( + regexp + ".exec(" + pattern +")[" + matches +"]", + matches_array[matches], + regexp.exec(pattern)[matches] ); + } +*/ + } diff --git a/tests/auto/qml/parserstress/tests/ecma_2/RegExp/function-001.js b/tests/auto/qml/parserstress/tests/ecma_2/RegExp/function-001.js new file mode 100644 index 0000000000..8b219b935b --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma_2/RegExp/function-001.js @@ -0,0 +1,99 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is JavaScript Engine testing utilities. + * + * The Initial Developer of the Original Code is + * Netscape Communication Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = 'function-001.js'; + +/** + * File Name: RegExp/function-001.js + * ECMA Section: 15.7.2.1 + * Description: Based on ECMA 2 Draft 7 February 1999 + * + * Author: christine@netscape.com + * Date: 19 February 1999 + */ +var SECTION = "RegExp/function-001"; +var VERSION = "ECMA_2"; +var TITLE = "RegExp( pattern, flags )"; + +startTest(); + +/* + * for each test case, verify: + * - verify that [[Class]] property is RegExp + * - prototype property should be set to RegExp.prototype + * - source is set to the empty string + * - global property is set to false + * - ignoreCase property is set to false + * - multiline property is set to false + * - lastIndex property is set to 0 + */ + +RegExp.prototype.getClassProperty = Object.prototype.toString; +var re = new RegExp(); + +AddTestCase( + "RegExp.prototype.getClassProperty = Object.prototype.toString; " + + "(new RegExp()).getClassProperty()", + "[object RegExp]", + re.getClassProperty() ); + +AddTestCase( + "(new RegExp()).source", + "", + re.source ); + +AddTestCase( + "(new RegExp()).global", + false, + re.global ); + +AddTestCase( + "(new RegExp()).ignoreCase", + false, + re.ignoreCase ); + +AddTestCase( + "(new RegExp()).multiline", + false, + re.multiline ); + +AddTestCase( + "(new RegExp()).lastIndex", + 0, + re.lastIndex ); + +test() diff --git a/tests/auto/qml/parserstress/tests/ecma_2/RegExp/hex-001.js b/tests/auto/qml/parserstress/tests/ecma_2/RegExp/hex-001.js new file mode 100644 index 0000000000..3e85ac7abf --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma_2/RegExp/hex-001.js @@ -0,0 +1,102 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is JavaScript Engine testing utilities. + * + * The Initial Developer of the Original Code is + * Netscape Communication Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = 'hex-001.js'; + +/** + * File Name: RegExp/hex-001.js + * ECMA Section: 15.7.3.1 + * Description: Based on ECMA 2 Draft 7 February 1999 + * Positive test cases for constructing a RegExp object + * Author: christine@netscape.com + * Date: 19 February 1999 + */ +var SECTION = "RegExp/hex-001"; +var VERSION = "ECMA_2"; +var TITLE = "RegExp patterns that contain HexicdecimalEscapeSequences"; + +startTest(); + +// These examples come from 15.7.1, HexidecimalEscapeSequence + +AddRegExpCases( new RegExp("\x41"), "new RegExp('\\x41')", "A", "A", 1, 0, ["A"] ); +AddRegExpCases( new RegExp("\x412"),"new RegExp('\\x412')", "A2", "A2", 1, 0, ["A2"] ); +AddRegExpCases( new RegExp("\x1g"), "new RegExp('\\x1g')", "x1g","x1g", 1, 0, ["x1g"] ); + +AddRegExpCases( new RegExp("A"), "new RegExp('A')", "\x41", "\\x41", 1, 0, ["A"] ); +AddRegExpCases( new RegExp("A"), "new RegExp('A')", "\x412", "\\x412", 1, 0, ["A"] ); +AddRegExpCases( new RegExp("^x"), "new RegExp('^x')", "x412", "x412", 1, 0, ["x"]); +AddRegExpCases( new RegExp("A"), "new RegExp('A')", "A2", "A2", 1, 0, ["A"] ); + +test(); + +function AddRegExpCases( + regexp, str_regexp, pattern, str_pattern, length, index, matches_array ) { + + // prevent a runtime error + + if ( regexp.exec(pattern) == null || matches_array == null ) { + AddTestCase( + str_regexp + ".exec(" + pattern +")", + matches_array, + regexp.exec(pattern) ); + + return; + } + + AddTestCase( + str_regexp + ".exec(" + str_pattern +").length", + length, + regexp.exec(pattern).length ); + + AddTestCase( + str_regexp + ".exec(" + str_pattern +").index", + index, + regexp.exec(pattern).index ); + + AddTestCase( + str_regexp + ".exec(" + str_pattern +").input", + pattern, + regexp.exec(pattern).input ); + + for ( var matches = 0; matches < matches_array.length; matches++ ) { + AddTestCase( + str_regexp + ".exec(" + str_pattern +")[" + matches +"]", + matches_array[matches], + regexp.exec(pattern)[matches] ); + } +} diff --git a/tests/auto/qml/parserstress/tests/ecma_2/RegExp/multiline-001.js b/tests/auto/qml/parserstress/tests/ecma_2/RegExp/multiline-001.js new file mode 100644 index 0000000000..102f91fcd4 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma_2/RegExp/multiline-001.js @@ -0,0 +1,101 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is JavaScript Engine testing utilities. + * + * The Initial Developer of the Original Code is + * Netscape Communication Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = 'multiline-001.js'; + +/** + * File Name: RegExp/multiline-001.js + * ECMA Section: + * Description: Based on ECMA 2 Draft 7 February 1999 + * + * Date: 19 February 1999 + */ + +var SECTION = "RegExp/multiline-001"; +var VERSION = "ECMA_2"; +var TITLE = "RegExp: multiline flag"; +var BUGNUMBER="343901"; + +startTest(); + +var woodpeckers = "ivory-billed\ndowny\nhairy\nacorn\nyellow-bellied sapsucker\n" + + "northern flicker\npileated\n"; + +AddRegExpCases( /.*[y]$/m, woodpeckers, woodpeckers.indexOf("downy"), ["downy"] ); + +AddRegExpCases( /.*[d]$/m, woodpeckers, woodpeckers.indexOf("ivory-billed"), ["ivory-billed"] ); + +test(); + + +function AddRegExpCases +( regexp, pattern, index, matches_array ) { + + // prevent a runtime error + + if ( regexp.exec(pattern) == null || matches_array == null ) { + AddTestCase( + regexp + ".exec(" + pattern +")", + matches_array, + regexp.exec(pattern) ); + + return; + } + + AddTestCase( + regexp.toString() + ".exec(" + pattern +").length", + matches_array.length, + regexp.exec(pattern).length ); + + AddTestCase( + regexp.toString() + ".exec(" + pattern +").index", + index, + regexp.exec(pattern).index ); + + AddTestCase( + regexp + ".exec(" + pattern +").input", + pattern, + regexp.exec(pattern).input ); + + + for ( var matches = 0; matches < matches_array.length; matches++ ) { + AddTestCase( + regexp + ".exec(" + pattern +")[" + matches +"]", + matches_array[matches], + regexp.exec(pattern)[matches] ); + } +} diff --git a/tests/auto/qml/parserstress/tests/ecma_2/RegExp/octal-001.js b/tests/auto/qml/parserstress/tests/ecma_2/RegExp/octal-001.js new file mode 100644 index 0000000000..1c520750ce --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma_2/RegExp/octal-001.js @@ -0,0 +1,111 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is JavaScript Engine testing utilities. + * + * The Initial Developer of the Original Code is + * Netscape Communication Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = 'octal-001.js'; + +/** + * File Name: RegExp/octal-001.js + * ECMA Section: 15.7.1 + * Description: Based on ECMA 2 Draft 7 February 1999 + * Simple test cases for matching OctalEscapeSequences. + * Author: christine@netscape.com + * Date: 19 February 1999 + */ +var SECTION = "RegExp/octal-001.js"; +var VERSION = "ECMA_2"; +var TITLE = "RegExp patterns that contain OctalEscapeSequences"; +var BUGNUMBER="http://scopus/bugsplat/show_bug.cgi?id=346196"; + +startTest(); + + +// backreference +AddRegExpCases( + /(.)\1/, + "/(.)\\1/", + "HI!!", + "HI!", + 2, + ["!!", "!"] ); + +test(); + +function AddRegExpCases( + regexp, str_regexp, pattern, str_pattern, index, matches_array ) { + + // prevent a runtime error + + if ( regexp.exec(pattern) == null || matches_array == null ) { + AddTestCase( + regexp + ".exec(" + str_pattern +")", + matches_array, + regexp.exec(pattern) ); + + return; + } + AddTestCase( + str_regexp + ".exec(" + str_pattern +").length", + matches_array.length, + regexp.exec(pattern).length ); + + AddTestCase( + str_regexp + ".exec(" + str_pattern +").index", + index, + regexp.exec(pattern).index ); + + AddTestCase( + str_regexp + ".exec(" + str_pattern +").input", + pattern, + regexp.exec(pattern).input ); + + AddTestCase( + str_regexp + ".exec(" + str_pattern +").toString()", + matches_array.toString(), + regexp.exec(pattern).toString() ); +/* + var limit = matches_array.length > regexp.exec(pattern).length + ? matches_array.length + : regexp.exec(pattern).length; + + for ( var matches = 0; matches < limit; matches++ ) { + AddTestCase( + str_regexp + ".exec(" + str_pattern +")[" + matches +"]", + matches_array[matches], + regexp.exec(pattern)[matches] ); + } +*/ +} diff --git a/tests/auto/qml/parserstress/tests/ecma_2/RegExp/octal-002.js b/tests/auto/qml/parserstress/tests/ecma_2/RegExp/octal-002.js new file mode 100644 index 0000000000..b654e5e68a --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma_2/RegExp/octal-002.js @@ -0,0 +1,126 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is JavaScript Engine testing utilities. + * + * The Initial Developer of the Original Code is + * Netscape Communication Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = 'octal-002.js'; + +/** + * File Name: RegExp/octal-002.js + * ECMA Section: 15.7.1 + * Description: Based on ECMA 2 Draft 7 February 1999 + * Simple test cases for matching OctalEscapeSequences. + * Author: christine@netscape.com + * Date: 19 February 1999 + */ +var SECTION = "RegExp/octal-002.js"; +var VERSION = "ECMA_2"; +var TITLE = "RegExp patterns that contain OctalEscapeSequences"; +var BUGNUMBER="http://scopus/bugsplat/show_bug.cgi?id=346189"; + +startTest(); + +// backreference +AddRegExpCases( + /(.)(.)(.)(.)(.)(.)(.)(.)\8/, + "/(.)(.)(.)(.)(.)(.)(.)(.)\\8", + "aabbccaaabbbccc", + "aabbccaaabbbccc", + 0, + ["aabbccaaa", "a", "a", "b", "b", "c", "c", "a", "a"] ); + +AddRegExpCases( + /(.)(.)(.)(.)(.)(.)(.)(.)(.)\9/, + "/(.)(.)(.)(.)(.)(.)(.)(.)\\9", + "aabbccaabbcc", + "aabbccaabbcc", + 0, + ["aabbccaabb", "a", "a", "b", "b", "c", "c", "a", "a", "b"] ); + +AddRegExpCases( + /(.)(.)(.)(.)(.)(.)(.)(.)(.)\8/, + "/(.)(.)(.)(.)(.)(.)(.)(.)(.)\\8", + "aabbccaababcc", + "aabbccaababcc", + 0, + ["aabbccaaba", "a", "a", "b", "b", "c", "c", "a", "a", "b"] ); + +test(); + +function AddRegExpCases( + regexp, str_regexp, pattern, str_pattern, index, matches_array ) { + + // prevent a runtime error + + if ( regexp.exec(pattern) == null || matches_array == null ) { + AddTestCase( + regexp + ".exec(" + str_pattern +")", + matches_array, + regexp.exec(pattern) ); + + return; + } + AddTestCase( + str_regexp + ".exec(" + str_pattern +").length", + matches_array.length, + regexp.exec(pattern).length ); + + AddTestCase( + str_regexp + ".exec(" + str_pattern +").index", + index, + regexp.exec(pattern).index ); + + AddTestCase( + str_regexp + ".exec(" + str_pattern +").input", + pattern, + regexp.exec(pattern).input ); + + AddTestCase( + str_regexp + ".exec(" + str_pattern +").toString()", + matches_array.toString(), + regexp.exec(pattern).toString() ); +/* + var limit = matches_array.length > regexp.exec(pattern).length + ? matches_array.length + : regexp.exec(pattern).length; + + for ( var matches = 0; matches < limit; matches++ ) { + AddTestCase( + str_regexp + ".exec(" + str_pattern +")[" + matches +"]", + matches_array[matches], + regexp.exec(pattern)[matches] ); + } +*/ +} diff --git a/tests/auto/qml/parserstress/tests/ecma_2/RegExp/octal-003.js b/tests/auto/qml/parserstress/tests/ecma_2/RegExp/octal-003.js new file mode 100644 index 0000000000..ee07ca602b --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma_2/RegExp/octal-003.js @@ -0,0 +1,120 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is JavaScript Engine testing utilities. + * + * The Initial Developer of the Original Code is + * Netscape Communication Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = 'octal-003.js'; + +/** + * File Name: RegExp/octal-003.js + * ECMA Section: 15.7.1 + * Description: Based on ECMA 2 Draft 7 February 1999 + * Simple test cases for matching OctalEscapeSequences. + * Author: christine@netscape.com + * Date: 19 February 1999 + * + * Revised: 02 August 2002 + * Author: pschwartau@netscape.com + * + * WHY: the original test expected the regexp /.\011/ + * to match 'a' + String.fromCharCode(0) + '11' + * + * This is incorrect: the string is a 4-character string consisting of + * the characters <'a'>, , <'1'>, <'1'>. By contrast, the \011 in the + * regexp should be parsed as a single token: it is the octal escape sequence + * for the horizontal tab character '\t' === '\u0009' === '\x09' === '\011'. + * + * So the regexp consists of 2 characters: , <'\t'>. + * There is no match between the regexp and the string. + * + * See the testcase ecma_3/RegExp/octal-002.js for an elaboration. + * + */ +var SECTION = "RegExp/octal-003.js"; +var VERSION = "ECMA_2"; +var TITLE = "RegExp patterns that contain OctalEscapeSequences"; +var BUGNUMBER="http://scopus/bugsplat/show_bug.cgi?id=346132"; + +startTest(); + +AddRegExpCases( /.\011/, "/\\011/", "a" + String.fromCharCode(0) + "11", "a\\011", 0, null ); + +test(); + +function AddRegExpCases( + regexp, str_regexp, pattern, str_pattern, index, matches_array ) { + + // prevent a runtime error + + if ( regexp.exec(pattern) == null || matches_array == null ) { + AddTestCase( + regexp + ".exec(" + str_pattern +")", + matches_array, + regexp.exec(pattern) ); + + return; + } + AddTestCase( + str_regexp + ".exec(" + str_pattern +").length", + matches_array.length, + regexp.exec(pattern).length ); + + AddTestCase( + str_regexp + ".exec(" + str_pattern +").index", + index, + regexp.exec(pattern).index ); + + AddTestCase( + str_regexp + ".exec(" + str_pattern +").input", + escape(pattern), + escape(regexp.exec(pattern).input) ); + + AddTestCase( + str_regexp + ".exec(" + str_pattern +").toString()", + matches_array.toString(), + escape(regexp.exec(pattern).toString()) ); + + var limit = matches_array.length > regexp.exec(pattern).length + ? matches_array.length + : regexp.exec(pattern).length; + + for ( var matches = 0; matches < limit; matches++ ) { + AddTestCase( + str_regexp + ".exec(" + str_pattern +")[" + matches +"]", + matches_array[matches], + escape(regexp.exec(pattern)[matches]) ); + } + +} diff --git a/tests/auto/qml/parserstress/tests/ecma_2/RegExp/properties-001.js b/tests/auto/qml/parserstress/tests/ecma_2/RegExp/properties-001.js new file mode 100644 index 0000000000..7d2913cc53 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma_2/RegExp/properties-001.js @@ -0,0 +1,124 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is JavaScript Engine testing utilities. + * + * The Initial Developer of the Original Code is + * Netscape Communication Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = 'properties-001.js'; + +/** + * File Name: RegExp/properties-001.js + * ECMA Section: 15.7.6.js + * Description: Based on ECMA 2 Draft 7 February 1999 + * + * Author: christine@netscape.com + * Date: 19 February 1999 + */ +var SECTION = "RegExp/properties-001.js"; +var VERSION = "ECMA_2"; +var TITLE = "Properties of RegExp Instances"; +var BUGNUMBER =""; + +startTest(); + +AddRegExpCases( new RegExp, "", false, false, false, 0 ); +AddRegExpCases( /.*/, ".*", false, false, false, 0 ); +AddRegExpCases( /[\d]{5}/g, "[\\d]{5}", true, false, false, 0 ); +AddRegExpCases( /[\S]?$/i, "[\\S]?$", false, true, false, 0 ); +AddRegExpCases( /^([a-z]*)[^\w\s\f\n\r]+/m, "^([a-z]*)[^\\w\\s\\f\\n\\r]+", false, false, true, 0 ); +AddRegExpCases( /[\D]{1,5}[\ -][\d]/gi, "[\\D]{1,5}[\\ -][\\d]", true, true, false, 0 ); +AddRegExpCases( /[a-zA-Z0-9]*/gm, "[a-zA-Z0-9]*", true, false, true, 0 ); +AddRegExpCases( /x|y|z/gim, "x|y|z", true, true, true, 0 ); + +AddRegExpCases( /\u0051/im, "\\u0051", false, true, true, 0 ); +AddRegExpCases( /\x45/gm, "\\x45", true, false, true, 0 ); +AddRegExpCases( /\097/gi, "\\097", true, true, false, 0 ); + +test(); + +function AddRegExpCases( re, s, g, i, m, l ) { + + AddTestCase( re + ".test == RegExp.prototype.test", + true, + re.test == RegExp.prototype.test ); + + AddTestCase( re + ".toString == RegExp.prototype.toString", + true, + re.toString == RegExp.prototype.toString ); + + AddTestCase( re + ".contructor == RegExp.prototype.constructor", + true, + re.constructor == RegExp.prototype.constructor ); + + AddTestCase( re + ".compile == RegExp.prototype.compile", + true, + re.compile == RegExp.prototype.compile ); + + AddTestCase( re + ".exec == RegExp.prototype.exec", + true, + re.exec == RegExp.prototype.exec ); + + // properties + + AddTestCase( re + ".source", + s, + re.source ); + +/* + * http://bugzilla.mozilla.org/show_bug.cgi?id=225550 changed + * the behavior of toString() and toSource() on empty regexps. + * So branch if |s| is the empty string - + */ + var S = s? s : '(?:)'; + + AddTestCase( re + ".toString()", + "/" + S +"/" + (g?"g":"") + (i?"i":"") +(m?"m":""), + re.toString() ); + + AddTestCase( re + ".global", + g, + re.global ); + + AddTestCase( re + ".ignoreCase", + i, + re.ignoreCase ); + + AddTestCase( re + ".multiline", + m, + re.multiline); + + AddTestCase( re + ".lastIndex", + l, + re.lastIndex ); +} diff --git a/tests/auto/qml/parserstress/tests/ecma_2/RegExp/properties-002.js b/tests/auto/qml/parserstress/tests/ecma_2/RegExp/properties-002.js new file mode 100644 index 0000000000..1fcfd8d219 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma_2/RegExp/properties-002.js @@ -0,0 +1,162 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is JavaScript Engine testing utilities. + * + * The Initial Developer of the Original Code is + * Netscape Communication Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = 'properties-002.js'; + +/** + * File Name: RegExp/properties-002.js + * ECMA Section: 15.7.6.js + * Description: Based on ECMA 2 Draft 7 February 1999 + * + * Author: christine@netscape.com + * Date: 19 February 1999 + */ +//----------------------------------------------------------------------------- +var SECTION = "RegExp/properties-002.js"; +var VERSION = "ECMA_2"; +var TITLE = "Properties of RegExp Instances"; +var BUGNUMBER ="124339"; + +startTest(); + +re_1 = /\cA?/g; +re_1.lastIndex = Math.pow(2,31); +AddRegExpCases( re_1, "\\cA?", true, false, false, Math.pow(2,31) ); + +re_2 = /\w*/i; +re_2.lastIndex = Math.pow(2,32) -1; +AddRegExpCases( re_2, "\\w*", false, true, false, Math.pow(2,32)-1 ); + +re_3 = /\*{0,80}/m; +re_3.lastIndex = Math.pow(2,31) -1; +AddRegExpCases( re_3, "\\*{0,80}", false, false, true, Math.pow(2,31) -1 ); + +re_4 = /^./gim; +re_4.lastIndex = Math.pow(2,30) -1; +AddRegExpCases( re_4, "^.", true, true, true, Math.pow(2,30) -1 ); + +re_5 = /\B/; +re_5.lastIndex = Math.pow(2,30); +AddRegExpCases( re_5, "\\B", false, false, false, Math.pow(2,30) ); + +/* + * Brendan: "need to test cases Math.pow(2,32) and greater to see + * whether they round-trip." Reason: thanks to the work done in + * http://bugzilla.mozilla.org/show_bug.cgi?id=124339, lastIndex + * is now stored as a double instead of a uint32 (unsigned integer). + * + * Note 2^32 -1 is the upper bound for uint32's, but doubles can go + * all the way up to Number.MAX_VALUE. So that's why we need cases + * between those two numbers. + * + */ +re_6 = /\B/; +re_6.lastIndex = Math.pow(2,32); +AddRegExpCases( re_6, "\\B", false, false, false, Math.pow(2,32) ); + +re_7 = /\B/; +re_7.lastIndex = Math.pow(2,32) + 1; +AddRegExpCases( re_7, "\\B", false, false, false, Math.pow(2,32) + 1 ); + +re_8 = /\B/; +re_8.lastIndex = Math.pow(2,32) * 2; +AddRegExpCases( re_8, "\\B", false, false, false, Math.pow(2,32) * 2 ); + +re_9 = /\B/; +re_9.lastIndex = Math.pow(2,40); +AddRegExpCases( re_9, "\\B", false, false, false, Math.pow(2,40) ); + +re_10 = /\B/; +re_10.lastIndex = Number.MAX_VALUE; +AddRegExpCases( re_10, "\\B", false, false, false, Number.MAX_VALUE ); + + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + + + +function AddRegExpCases( re, s, g, i, m, l ){ + + AddTestCase( re + ".test == RegExp.prototype.test", + true, + re.test == RegExp.prototype.test ); + + AddTestCase( re + ".toString == RegExp.prototype.toString", + true, + re.toString == RegExp.prototype.toString ); + + AddTestCase( re + ".contructor == RegExp.prototype.constructor", + true, + re.constructor == RegExp.prototype.constructor ); + + AddTestCase( re + ".compile == RegExp.prototype.compile", + true, + re.compile == RegExp.prototype.compile ); + + AddTestCase( re + ".exec == RegExp.prototype.exec", + true, + re.exec == RegExp.prototype.exec ); + + // properties + + AddTestCase( re + ".source", + s, + re.source ); + + AddTestCase( re + ".toString()", + "/" + s +"/" + (g?"g":"") + (i?"i":"") +(m?"m":""), + re.toString() ); + + AddTestCase( re + ".global", + g, + re.global ); + + AddTestCase( re + ".ignoreCase", + i, + re.ignoreCase ); + + AddTestCase( re + ".multiline", + m, + re.multiline); + + AddTestCase( re + ".lastIndex", + l, + re.lastIndex ); +} diff --git a/tests/auto/qml/parserstress/tests/ecma_2/RegExp/regexp-enumerate-001.js b/tests/auto/qml/parserstress/tests/ecma_2/RegExp/regexp-enumerate-001.js new file mode 100644 index 0000000000..c26a1216ea --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma_2/RegExp/regexp-enumerate-001.js @@ -0,0 +1,121 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is JavaScript Engine testing utilities. + * + * The Initial Developer of the Original Code is + * Netscape Communication Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = 'regexp-enumerate-001.js'; + +/** + File Name: regexp-enumerate-001.js + ECMA V2 Section: + Description: Regression Test. + + If instance Native Object have properties that are enumerable, + JavaScript enumerated through the properties twice. This only + happened if objects had been instantiated, but their properties + had not been enumerated. ie, the object inherited properties + from its prototype that are enumerated. + + In the core JavaScript, this is only a problem with RegExp + objects, since the inherited properties of most core JavaScript + objects are not enumerated. + + Author: christine@netscape.com, pschwartau@netscape.com + Date: 12 November 1997 + Modified: 14 July 2002 + Reason: See http://bugzilla.mozilla.org/show_bug.cgi?id=155291 + ECMA-262 Ed.3 Sections 15.10.7.1 through 15.10.7.5 + RegExp properties should be DontEnum + * + */ +// onerror = err; + +var SECTION = "regexp-enumerate-001"; +var VERSION = "ECMA_2"; +var TITLE = "Regression Test for Enumerating Properties"; + +var BUGNUMBER="339403"; + +startTest(); +writeHeaderToLog( SECTION + " "+ TITLE); + +/* + * This test expects RegExp instances to have four enumerated properties: + * source, global, ignoreCase, and lastIndex + * + * 99.01.25: now they also have a multiLine instance property. + * + */ + + +var r = new RegExp(); + +var e = new Array(); + +var t = new TestRegExp(); + +for ( p in r ) { e[e.length] = { property:p, value:r[p] }; t.addProperty( p, r[p]) }; + +new TestCase( SECTION, + "r = new RegExp(); e = new Array(); "+ + "for ( p in r ) { e[e.length] = { property:p, value:r[p] }; e.length", + 0, + e.length ); + +test(); + +function TestRegExp() { + this.addProperty = addProperty; +} +function addProperty(name, value) { + var pass = false; + + if ( eval("this."+name) != void 0 ) { + pass = true; + } else { + eval( "this."+ name+" = "+ false ); + } + + new TestCase( SECTION, + "Property: " + name +" already enumerated?", + false, + pass ); + + if ( gTestcases[ gTestcases.length-1].passed == false ) { + gTestcases[gTestcases.length-1].reason = "property already enumerated"; + + } + +} diff --git a/tests/auto/qml/parserstress/tests/ecma_2/RegExp/regress-001.js b/tests/auto/qml/parserstress/tests/ecma_2/RegExp/regress-001.js new file mode 100644 index 0000000000..219ce245ee --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma_2/RegExp/regress-001.js @@ -0,0 +1,78 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is JavaScript Engine testing utilities. + * + * The Initial Developer of the Original Code is + * Netscape Communication Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = 'regress-001.js'; + +/** + * File Name: RegExp/regress-001.js + * ECMA Section: N/A + * Description: Regression test case: + * JS regexp anchoring on empty match bug + * http://bugzilla.mozilla.org/show_bug.cgi?id=2157 + * + * Author: christine@netscape.com + * Date: 19 February 1999 + */ +var SECTION = "RegExp/hex-001.js"; +var VERSION = "ECMA_2"; +var TITLE = "JS regexp anchoring on empty match bug"; +var BUGNUMBER = "2157"; + +startTest(); + +AddRegExpCases( /a||b/(''), + "//a||b/('')", + 1, + [''] ); + +test(); + +function AddRegExpCases( regexp, str_regexp, length, matches_array ) { + + AddTestCase( + "( " + str_regexp + " ).length", + regexp.length, + regexp.length ); + + + for ( var matches = 0; matches < matches_array.length; matches++ ) { + AddTestCase( + "( " + str_regexp + " )[" + matches +"]", + matches_array[matches], + regexp[matches] ); + } +} diff --git a/tests/auto/qml/parserstress/tests/ecma_2/RegExp/shell.js b/tests/auto/qml/parserstress/tests/ecma_2/RegExp/shell.js new file mode 100644 index 0000000000..9b4657d963 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma_2/RegExp/shell.js @@ -0,0 +1 @@ +gTestsubsuite = 'RegExp'; diff --git a/tests/auto/qml/parserstress/tests/ecma_2/RegExp/unicode-001.js b/tests/auto/qml/parserstress/tests/ecma_2/RegExp/unicode-001.js new file mode 100644 index 0000000000..79a3212a2e --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma_2/RegExp/unicode-001.js @@ -0,0 +1,92 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is JavaScript Engine testing utilities. + * + * The Initial Developer of the Original Code is + * Netscape Communication Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = 'unicode-001.js'; + +/** + * File Name: RegExp/unicode-001.js + * ECMA Section: 15.7.3.1 + * Description: Based on ECMA 2 Draft 7 February 1999 + * Positive test cases for constructing a RegExp object + * Author: christine@netscape.com + * Date: 19 February 1999 + */ +var SECTION = "RegExp/unicode-001.js"; +var VERSION = "ECMA_2"; +var TITLE = "new RegExp( pattern, flags )"; + +startTest(); + +// These examples come from 15.7.1, UnicodeEscapeSequence + +AddRegExpCases( /\u0041/, "/\\u0041/", "A", "A", 1, 0, ["A"] ); +AddRegExpCases( /\u00412/, "/\\u00412/", "A2", "A2", 1, 0, ["A2"] ); +AddRegExpCases( /\u00412/, "/\\u00412/", "A2", "A2", 1, 0, ["A2"] ); +AddRegExpCases( /\u001g/, "/\\u001g/", "u001g", "u001g", 1, 0, ["u001g"] ); + +AddRegExpCases( /A/, "/A/", "\u0041", "\\u0041", 1, 0, ["A"] ); +AddRegExpCases( /A/, "/A/", "\u00412", "\\u00412", 1, 0, ["A"] ); +AddRegExpCases( /A2/, "/A2/", "\u00412", "\\u00412", 1, 0, ["A2"]); +AddRegExpCases( /A/, "/A/", "A2", "A2", 1, 0, ["A"] ); + +test(); + +function AddRegExpCases( + regexp, str_regexp, pattern, str_pattern, length, index, matches_array ) { + + AddTestCase( + str_regexp + " .exec(" + str_pattern +").length", + length, + regexp.exec(pattern).length ); + + AddTestCase( + str_regexp + " .exec(" + str_pattern +").index", + index, + regexp.exec(pattern).index ); + + AddTestCase( + str_regexp + " .exec(" + str_pattern +").input", + pattern, + regexp.exec(pattern).input ); + + for ( var matches = 0; matches < matches_array.length; matches++ ) { + AddTestCase( + str_regexp + " .exec(" + str_pattern +")[" + matches +"]", + matches_array[matches], + regexp.exec(pattern)[matches] ); + } +} diff --git a/tests/auto/qml/parserstress/tests/ecma_2/Statements/browser.js b/tests/auto/qml/parserstress/tests/ecma_2/Statements/browser.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/auto/qml/parserstress/tests/ecma_2/Statements/dowhile-001.js b/tests/auto/qml/parserstress/tests/ecma_2/Statements/dowhile-001.js new file mode 100644 index 0000000000..8cfdc25dd6 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma_2/Statements/dowhile-001.js @@ -0,0 +1,77 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is JavaScript Engine testing utilities. + * + * The Initial Developer of the Original Code is + * Netscape Communication Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = 'dowhile-001.js'; + +/** + * File Name: dowhile-001 + * ECMA Section: + * Description: do...while statements + * + * + * + * Author: christine@netscape.com + * Date: 11 August 1998 + */ +var SECTION = "dowhile-002"; +var VERSION = "ECMA_2"; +var TITLE = "do...while with a labeled continue statement"; + +startTest(); +writeHeaderToLog( SECTION + " "+ TITLE); + +LabeledContinue( 0, 1 ); +LabeledContinue( 1, 1 ); +LabeledContinue( -1, 1 ); +LabeledContinue( 5, 5 ); + +test(); + +function LabeledContinue( limit, expect ) { + i = 0; +woohoo: + do { + i++; + continue woohoo; + } while ( i < limit ); + + new TestCase( + SECTION, + "do while ( " + i +" < " + limit +" )", + expect, + i ); +} diff --git a/tests/auto/qml/parserstress/tests/ecma_2/Statements/dowhile-002.js b/tests/auto/qml/parserstress/tests/ecma_2/Statements/dowhile-002.js new file mode 100644 index 0000000000..ca53dff899 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma_2/Statements/dowhile-002.js @@ -0,0 +1,104 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is JavaScript Engine testing utilities. + * + * The Initial Developer of the Original Code is + * Netscape Communication Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = 'dowhile-002.js'; + +/** + * File Name: dowhile-002 + * ECMA Section: + * Description: do...while statements + * + * Verify that code after a labeled break is not executed. Verify that + * a labeled break breaks you out of the whole labeled block, and not + * just the current iteration statement. + * + * Author: christine@netscape.com + * Date: 11 August 1998 + */ +var SECTION = "dowhile-002"; +var VERSION = "ECMA_2"; +var TITLE = "do...while with a labeled continue statement"; + +startTest(); +writeHeaderToLog( SECTION + " "+ TITLE); + +LabeledContinue( 0, 1 ); +LabeledContinue( 1, 1 ); +LabeledContinue( -1, 1 ); +LabeledContinue( 5, 5 ); + +test(); + +// The labeled statement contains statements after the labeled break. +// Verify that the statements after the break are not executed. + +function LabeledContinue( limit, expect ) { + i = 0; + result1 = "pass"; + result2 = "pass"; + +woohoo: { + do { + i++; + if ( ! (i < limit) ) { + break woohoo; + result1 = "fail: evaluated statement after a labeled break"; + } + } while ( true ); + + result2 = "failed: broke out of loop, but not out of labeled block"; + } + + new TestCase( + SECTION, + "do while ( " + i +" < " + limit +" )", + expect, + i ); + + new TestCase( + SECTION, + "breaking out of a do... while loop", + "pass", + result1 ); + + + new TestCase( + SECTION, + "breaking out of a labeled do...while loop", + "pass", + result2 ); +} diff --git a/tests/auto/qml/parserstress/tests/ecma_2/Statements/dowhile-003.js b/tests/auto/qml/parserstress/tests/ecma_2/Statements/dowhile-003.js new file mode 100644 index 0000000000..598f655f8d --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma_2/Statements/dowhile-003.js @@ -0,0 +1,96 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is JavaScript Engine testing utilities. + * + * The Initial Developer of the Original Code is + * Netscape Communication Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = 'dowhile-003.js'; + +/** + * File Name: dowhile-003 + * ECMA Section: + * Description: do...while statements + * + * Test do while, when the while expression is a JavaScript Number object. + * + * + * Author: christine@netscape.com + * Date: 11 August 1998 + */ +var SECTION = "dowhile-003"; +var VERSION = "ECMA_2"; +var TITLE = "do...while with a labeled continue statement"; + +startTest(); +writeHeaderToLog( SECTION + " "+ TITLE); + +DoWhile( new DoWhileObject( 1, 1, 0 )); +DoWhile( new DoWhileObject( 1000, 1000, 0 )); +DoWhile( new DoWhileObject( 1001, 1001, 0 )); +DoWhile( new DoWhileObject( 1002, 1001, 1 )); +DoWhile( new DoWhileObject( -1, 1001, -1002 )); + +test(); + +function DoWhileObject( value, iterations, endvalue ) { + this.value = value; + this.iterations = iterations; + this.endvalue = endvalue; +} + +function DoWhile( object ) { + var i = 0; + + do { + object.value = --object.value; + i++; + if ( i > 1000 ) + break; + } while( object.value ); + + new TestCase( + SECTION, + "loop iterations", + object.iterations, + i + ); + + new TestCase( + SECTION, + "object.value", + object.endvalue, + Number( object.value ) + ); + +} diff --git a/tests/auto/qml/parserstress/tests/ecma_2/Statements/dowhile-004.js b/tests/auto/qml/parserstress/tests/ecma_2/Statements/dowhile-004.js new file mode 100644 index 0000000000..eb8e0c1b72 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma_2/Statements/dowhile-004.js @@ -0,0 +1,100 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is JavaScript Engine testing utilities. + * + * The Initial Developer of the Original Code is + * Netscape Communication Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = 'dowhile-004.js'; + +/** + * File Name: dowhile-004 + * ECMA Section: + * Description: do...while statements + * + * Test a labeled do...while. Break out of the loop with no label + * should break out of the loop, but not out of the label. + * + * Author: christine@netscape.com + * Date: 11 August 1998 + */ +var SECTION = "dowhile-004"; +var VERSION = "ECMA_2"; +var TITLE = "do...while with a labeled continue statement"; + +startTest(); +writeHeaderToLog( SECTION + " "+ TITLE); + +DoWhile( 0, 1 ); +DoWhile( 1, 1 ); +DoWhile( -1, 1 ); +DoWhile( 5, 5 ); + +test(); + +function DoWhile( limit, expect ) { + i = 0; + result1 = "pass"; + result2 = "failed: broke out of labeled statement unexpectedly"; + +foo: { + do { + i++; + if ( ! (i < limit) ) { + break; + result1 = "fail: evaluated statement after a labeled break"; + } + } while ( true ); + + result2 = "pass"; + } + + new TestCase( + SECTION, + "do while ( " + i +" < " + limit +" )", + expect, + i ); + + new TestCase( + SECTION, + "breaking out of a do... while loop", + "pass", + result1 ); + + + new TestCase( + SECTION, + "breaking out of a labeled do...while loop", + "pass", + result2 ); +} diff --git a/tests/auto/qml/parserstress/tests/ecma_2/Statements/dowhile-005.js b/tests/auto/qml/parserstress/tests/ecma_2/Statements/dowhile-005.js new file mode 100644 index 0000000000..e4096f0d25 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma_2/Statements/dowhile-005.js @@ -0,0 +1,106 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is JavaScript Engine testing utilities. + * + * The Initial Developer of the Original Code is + * Netscape Communication Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = 'dowhile-005.js'; + +/** + * File Name: dowhile-005 + * ECMA Section: + * Description: do...while statements + * + * Test a labeled do...while. Break out of the loop with no label + * should break out of the loop, but not out of the label. + * + * Currently causes an infinite loop in the monkey. Uncomment the + * print statement below and it works OK. + * + * Author: christine@netscape.com + * Date: 26 August 1998 + */ +var SECTION = "dowhile-005"; +var VERSION = "ECMA_2"; +var TITLE = "do...while with a labeled continue statement"; +var BUGNUMBER = "316293"; + +startTest(); +writeHeaderToLog( SECTION + " "+ TITLE); + +NestedLabel(); + + +test(); + +function NestedLabel() { + i = 0; + result1 = "pass"; + result2 = "fail: did not hit code after inner loop"; + result3 = "pass"; + +outer: { + do { + inner: { +// print( i ); + break inner; + result1 = "fail: did break out of inner label"; + } + result2 = "pass"; + break outer; + print(i); + } while ( i++ < 100 ); + + } + + result3 = "fail: did not break out of outer label"; + + new TestCase( + SECTION, + "number of loop iterations", + 0, + i ); + + new TestCase( + SECTION, + "break out of inner loop", + "pass", + result1 ); + + new TestCase( + SECTION, + "break out of outer loop", + "pass", + result2 ); +} diff --git a/tests/auto/qml/parserstress/tests/ecma_2/Statements/dowhile-006.js b/tests/auto/qml/parserstress/tests/ecma_2/Statements/dowhile-006.js new file mode 100644 index 0000000000..c8ad46f629 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma_2/Statements/dowhile-006.js @@ -0,0 +1,122 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is JavaScript Engine testing utilities. + * + * The Initial Developer of the Original Code is + * Netscape Communication Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = 'dowhile-006.js'; + +/** + * File Name: dowhile-006 + * ECMA Section: + * Description: do...while statements + * + * A general do...while test. + * + * Author: christine@netscape.com + * Date: 26 August 1998 + */ +var SECTION = "dowhile-006"; +var VERSION = "ECMA_2"; +var TITLE = "do...while"; + +startTest(); +writeHeaderToLog( SECTION + " "+ TITLE); + +DoWhile( new DoWhileObject( false, false, 10 ) ); +DoWhile( new DoWhileObject( true, false, 2 ) ); +DoWhile( new DoWhileObject( false, true, 3 ) ); +DoWhile( new DoWhileObject( true, true, 4 ) ); + +test(); + +function looping( object ) { + object.iterations--; + + if ( object.iterations <= 0 ) { + return false; + } else { + return true; + } +} +function DoWhileObject( breakOut, breakIn, iterations, loops ) { + this.iterations = iterations; + this.loops = loops; + this.breakOut = breakOut; + this.breakIn = breakIn; + this.looping = looping; +} +function DoWhile( object ) { + var result1 = false; + var result2 = false; + +outie: { + innie: { + do { + if ( object.breakOut ) + break outie; + + if ( object.breakIn ) + break innie; + + } while ( looping(object) ); + + // statements should be executed if: + // do...while exits normally + // do...while exits abruptly with no label + + result1 = true; + + } + +// statements should be executed if: +// do...while breaks out with label "innie" +// do...while exits normally +// do...while does not break out with "outie" + + result2 = true; + } + + new TestCase( + SECTION, + "hit code after loop in inner loop", + ( object.breakIn || object.breakOut ) ? false : true , + result1 ); + + new TestCase( + SECTION, + "hit code after loop in outer loop", + ( object.breakOut ) ? false : true, + result2 ); +} diff --git a/tests/auto/qml/parserstress/tests/ecma_2/Statements/dowhile-007.js b/tests/auto/qml/parserstress/tests/ecma_2/Statements/dowhile-007.js new file mode 100644 index 0000000000..5d148095d1 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma_2/Statements/dowhile-007.js @@ -0,0 +1,130 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is JavaScript Engine testing utilities. + * + * The Initial Developer of the Original Code is + * Netscape Communication Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = 'dowhile-007.js'; + +/** + * File Name: dowhile-007 + * ECMA Section: + * Description: do...while statements + * + * A general do...while test. + * + * Author: christine@netscape.com + * Date: 26 August 1998 + */ +var SECTION = "dowhile-007"; +var VERSION = "ECMA_2"; +var TITLE = "do...while"; + +startTest(); +writeHeaderToLog( SECTION + " "+ TITLE); + +DoWhile( new DoWhileObject( false, false, false, false )); +DoWhile( new DoWhileObject( true, false, false, false )); +DoWhile( new DoWhileObject( true, true, false, false )); +DoWhile( new DoWhileObject( true, true, true, false )); +DoWhile( new DoWhileObject( true, true, true, true )); +DoWhile( new DoWhileObject( false, false, false, true )); +DoWhile( new DoWhileObject( false, false, true, true )); +DoWhile( new DoWhileObject( false, true, true, true )); +DoWhile( new DoWhileObject( false, false, true, false )); + +test(); + +function DoWhileObject( out1, out2, out3, in1 ) { + this.breakOutOne = out1; + this.breakOutTwo = out2; + this.breakOutThree = out3; + this.breakIn = in1; +} +function DoWhile( object ) { + result1 = false; + result2 = false; + result3 = false; + result4 = false; + +outie: + do { + if ( object.breakOutOne ) { + break outie; + } + result1 = true; + + innie: + do { + if ( object.breakOutTwo ) { + break outie; + } + result2 = true; + + if ( object.breakIn ) { + break innie; + } + result3 = true; + + } while ( false ); + if ( object.breakOutThree ) { + break outie; + } + result4 = true; + } while ( false ); + + new TestCase( + SECTION, + "break one: ", + (object.breakOutOne) ? false : true, + result1 ); + + new TestCase( + SECTION, + "break two: ", + (object.breakOutOne||object.breakOutTwo) ? false : true, + result2 ); + + new TestCase( + SECTION, + "break three: ", + (object.breakOutOne||object.breakOutTwo||object.breakIn) ? false : true, + result3 ); + + new TestCase( + SECTION, + "break four: ", + (object.breakOutOne||object.breakOutTwo||object.breakOutThree) ? false: true, + result4 ); +} diff --git a/tests/auto/qml/parserstress/tests/ecma_2/Statements/forin-001.js b/tests/auto/qml/parserstress/tests/ecma_2/Statements/forin-001.js new file mode 100644 index 0000000000..0f20f6e953 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma_2/Statements/forin-001.js @@ -0,0 +1,330 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is JavaScript Engine testing utilities. + * + * The Initial Developer of the Original Code is + * Netscape Communication Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = 'forin-001.js'; + +/** + * File Name: forin-001.js + * ECMA Section: + * Description: The forin-001 statement + * + * Verify that the property name is assigned to the property on the left + * hand side of the for...in expression. + * + * Author: christine@netscape.com + * Date: 28 August 1998 + */ +var SECTION = "forin-001"; +var VERSION = "ECMA_2"; +var TITLE = "The for...in statement"; +var BUGNUMBER="330890"; +var BUGNUMBER="http://scopus.mcom.com/bugsplat/show_bug.cgi?id=344855"; + +startTest(); +writeHeaderToLog( SECTION + " "+ TITLE); + +ForIn_1( { length:4, company:"netscape", year:2000, 0:"zero" } ); +ForIn_2( { length:4, company:"netscape", year:2000, 0:"zero" } ); +ForIn_3( { length:4, company:"netscape", year:2000, 0:"zero" } ); + +// ForIn_6({ length:4, company:"netscape", year:2000, 0:"zero" }); +// ForIn_7({ length:4, company:"netscape", year:2000, 0:"zero" }); +ForIn_8({ length:4, company:"netscape", year:2000, 0:"zero" }); + +test(); + +/** + * Verify that the left side argument is evaluated with every iteration. + * Verify that the name of each property of the object is assigned to a + * a property. + * + */ +function ForIn_1( object ) { + PropertyArray = new Array(); + ValueArray = new Array(); + + for ( PropertyArray[PropertyArray.length] in object ) { + ValueArray[ValueArray.length] = + object[PropertyArray[PropertyArray.length-1]]; + } + + for ( var i = 0; i < PropertyArray.length; i++ ) { + new TestCase( + SECTION, + "object[" + PropertyArray[i] +"]", + object[PropertyArray[i]], + ValueArray[i] + ); + } + + new TestCase( + SECTION, + "object.length", + PropertyArray.length, + object.length ); +} + +/** + * Similar to ForIn_1, except it should increment the counter variable + * every time the left hand expression is evaluated. + */ +function ForIn_2( object ) { + PropertyArray = new Array(); + ValueArray = new Array(); + var i = 0; + + for ( PropertyArray[i++] in object ) { + ValueArray[ValueArray.length] = + object[PropertyArray[PropertyArray.length-1]]; + } + + for ( i = 0; i < PropertyArray.length; i++ ) { + new TestCase( + SECTION, + "object[" + PropertyArray[i] +"]", + object[PropertyArray[i]], + ValueArray[i] + ); + } + + new TestCase( + SECTION, + "object.length", + PropertyArray.length, + object.length ); +} + +/** + * Break out of a for...in loop + * + * + */ +function ForIn_3( object ) { + var checkBreak = "pass"; + var properties = new Array(); + var values = new Array(); + + for ( properties[properties.length] in object ) { + values[values.length] = object[properties[properties.length-1]]; + break; + checkBreak = "fail"; + } + + new TestCase( + SECTION, + "check break out of for...in", + "pass", + checkBreak ); + + new TestCase( + SECTION, + "properties.length", + 1, + properties.length ); + + new TestCase( + SECTION, + "object["+properties[0]+"]", + values[0], + object[properties[0]] ); +} + +/** + * Break out of a labeled for...in loop. + */ +function ForIn_4( object ) { + var result1 = 0; + var result2 = 0; + var result3 = 0; + var result4 = 0; + var i = 0; + var property = new Array(); + +butterbean: { + result1++; + + for ( property[i++] in object ) { + result2++; + break; + result4++; + } + result3++; + } + + new TestCase( + SECTION, + "verify labeled statement is only executed once", + true, + result1 == 1 ); + + new TestCase( + SECTION, + "verify statements in for loop are evaluated", + true, + result2 == i ); + + new TestCase( + SECTION, + "verify break out of labeled for...in loop", + true, + result4 == 0 ); + + new TestCase( + SECTION, + "verify break out of labeled block", + true, + result3 == 0 ); +} + +/** + * Labeled break out of a labeled for...in loop. + */ +function ForIn_5 (object) { + var result1 = 0; + var result2 = 0; + var result3 = 0; + var result4 = 0; + var i = 0; + var property = new Array(); + +bigredbird: { + result1++; + for ( property[i++] in object ) { + result2++; + break bigredbird; + result4++; + } + result3++; + } + + new TestCase( + SECTION, + "verify labeled statement is only executed once", + true, + result1 == 1 ); + + new TestCase( + SECTION, + "verify statements in for loop are evaluated", + true, + result2 == i ); + + new TestCase( + SECTION, + "verify break out of labeled for...in loop", + true, + result4 == 0 ); + + new TestCase( + SECTION, + "verify break out of labeled block", + true, + result3 == 0 ); +} + +/** + * Labeled continue from a labeled for...in loop + */ +function ForIn_7( object ) { + var result1 = 0; + var result2 = 0; + var result3 = 0; + var result4 = 0; + var i = 0; + var property = new Array(); + +bigredbird: + for ( property[i++] in object ) { + result2++; + continue bigredbird; + result4++; + } + + new TestCase( + SECTION, + "verify statements in for loop are evaluated", + true, + result2 == i ); + + new TestCase( + SECTION, + "verify break out of labeled for...in loop", + true, + result4 == 0 ); + + new TestCase( + SECTION, + "verify break out of labeled block", + true, + result3 == 1 ); +} + + +/** + * continue in a for...in loop + * + */ +function ForIn_8( object ) { + var checkBreak = "pass"; + var properties = new Array(); + var values = new Array(); + + for ( properties[properties.length] in object ) { + values[values.length] = object[properties[properties.length-1]]; + break; + checkBreak = "fail"; + } + + new TestCase( + SECTION, + "check break out of for...in", + "pass", + checkBreak ); + + new TestCase( + SECTION, + "properties.length", + 1, + properties.length ); + + new TestCase( + SECTION, + "object["+properties[0]+"]", + values[0], + object[properties[0]] ); +} + diff --git a/tests/auto/qml/parserstress/tests/ecma_2/Statements/forin-002.js b/tests/auto/qml/parserstress/tests/ecma_2/Statements/forin-002.js new file mode 100644 index 0000000000..524bf38b9a --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma_2/Statements/forin-002.js @@ -0,0 +1,109 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is JavaScript Engine testing utilities. + * + * The Initial Developer of the Original Code is + * Netscape Communication Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = 'forin-002.js'; + +/** + * File Name: forin-002.js + * ECMA Section: + * Description: The forin-001 statement + * + * Verify that the property name is assigned to the property on the left + * hand side of the for...in expression. + * + * Author: christine@netscape.com + * Date: 28 August 1998 + */ +var SECTION = "forin-002"; +var VERSION = "ECMA_2"; +var TITLE = "The for...in statement"; + +startTest(); +writeHeaderToLog( SECTION + " "+ TITLE); + +function MyObject( value ) { + this.value = value; + this.valueOf = new Function ( "return this.value" ); + this.toString = new Function ( "return this.value + \"\"" ); + this.toNumber = new Function ( "return this.value + 0" ); + this.toBoolean = new Function ( "return Boolean( this.value )" ); +} + +ForIn_1(this); +ForIn_2(this); + +ForIn_1(new MyObject(true)); +ForIn_2(new MyObject(new Boolean(true))); + +ForIn_2(3); + +test(); + +/** + * For ... In in a With Block + * + */ +function ForIn_1( object) { + with ( object ) { + for ( property in object ) { + new TestCase( + SECTION, + "with loop in a for...in loop. ("+object+")["+property +"] == "+ + "eval ( " + property +" )", + true, + object[property] == eval(property) ); + } + } +} + +/** + * With block in a For...In loop + * + */ +function ForIn_2(object) { + for ( property in object ) { + with ( object ) { + new TestCase( + SECTION, + "with loop in a for...in loop. ("+object+")["+property +"] == "+ + "eval ( " + property +" )", + true, + object[property] == eval(property) ); + } + } +} + diff --git a/tests/auto/qml/parserstress/tests/ecma_2/Statements/if-001.js b/tests/auto/qml/parserstress/tests/ecma_2/Statements/if-001.js new file mode 100644 index 0000000000..439410c9a6 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma_2/Statements/if-001.js @@ -0,0 +1,75 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is JavaScript Engine testing utilities. + * + * The Initial Developer of the Original Code is + * Netscape Communication Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = 'if-001.js'; + +/** + * File Name: if-001.js + * ECMA Section: + * Description: The if statement + * + * Verify that assignment in the if expression is evaluated correctly. + * Verifies the fix for bug http://scopus/bugsplat/show_bug.cgi?id=148822. + * + * Author: christine@netscape.com + * Date: 28 August 1998 + */ +var SECTION = "for-001"; +var VERSION = "ECMA_2"; +var TITLE = "The if statement"; +var BUGNUMBER="148822"; + +startTest(); +writeHeaderToLog( SECTION + " "+ TITLE); + +var a = 0; +var b = 0; +var result = "passed"; + +if ( a = b ) { + result = "failed: a = b should return 0"; +} + +new TestCase( + SECTION, + "if ( a = b ), where a and b are both equal to 0", + "passed", + result ); + + +test(); + diff --git a/tests/auto/qml/parserstress/tests/ecma_2/Statements/label-001.js b/tests/auto/qml/parserstress/tests/ecma_2/Statements/label-001.js new file mode 100644 index 0000000000..07bdeb6b81 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma_2/Statements/label-001.js @@ -0,0 +1,75 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is JavaScript Engine testing utilities. + * + * The Initial Developer of the Original Code is + * Netscape Communication Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = 'label-001.js'; + +/** + * File Name: label-001.js + * ECMA Section: + * Description: Labeled statements + * + * Labeled break and continue within a for loop. + * + * + * Author: christine@netscape.com + * Date: 11 August 1998 + */ +var SECTION = "label-003"; +var VERSION = "ECMA_2"; +var TITLE = "Labeled statements"; + +startTest(); +writeHeaderToLog( SECTION + " "+ TITLE); + +LabelTest(0, 0); +LabelTest(1, 1) + LabelTest(-1, 1000); +LabelTest(false, 0); +LabelTest(true, 1); + +test(); + +function LabelTest( limit, expect) { +woo: for ( var result = 0; result < 1000; result++ ) { if (result == limit) { break woo; } else { continue woo; } }; + + new TestCase( + SECTION, + "break out of a labeled for loop: "+ limit, + expect, + result ); +} + diff --git a/tests/auto/qml/parserstress/tests/ecma_2/Statements/label-002.js b/tests/auto/qml/parserstress/tests/ecma_2/Statements/label-002.js new file mode 100644 index 0000000000..83b114d3f2 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma_2/Statements/label-002.js @@ -0,0 +1,89 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is JavaScript Engine testing utilities. + * + * The Initial Developer of the Original Code is + * Netscape Communication Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = 'label-002.js'; + +/** + * File Name: label-002.js + * ECMA Section: + * Description: Labeled statements + * + * Labeled break and continue within a for-in loop. + * + * + * Author: christine@netscape.com + * Date: 11 August 1998 + */ +var SECTION = "label-002"; +var VERSION = "ECMA_2"; +var TITLE = "Labeled statements"; + +startTest(); +writeHeaderToLog( SECTION + " "+ TITLE); + +LabelTest( { p1:"hi,", p2:" norris" }, "hi, norris", " norrishi," ); +LabelTest( { 0:"zero", 1:"one" }, "zeroone", "onezero" ); + +LabelTest2( { p1:"hi,", p2:" norris" }, "hi,", " norris" ); +LabelTest2( { 0:"zero", 1:"one" }, "zero", "one" ); + +test(); + +function LabelTest( object, expect1, expect2 ) { + result = ""; + +yoohoo: { for ( property in object ) { result += object[property]; }; break yoohoo }; + + new TestCase( + SECTION, + "yoohoo: for ( property in object ) { result += object[property]; } break yoohoo }", + true, + result == expect1 || result == expect2 ); +} + +function LabelTest2( object, expect1, expect2 ) { + result = ""; + +yoohoo: { for ( property in object ) { result += object[property]; break yoohoo } }; ; + + new TestCase( + SECTION, + "yoohoo: for ( property in object ) { result += object[property]; break yoohoo }}", + true, + result == expect1 || result == expect2 ); +} + diff --git a/tests/auto/qml/parserstress/tests/ecma_2/Statements/shell.js b/tests/auto/qml/parserstress/tests/ecma_2/Statements/shell.js new file mode 100644 index 0000000000..7346f697a5 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma_2/Statements/shell.js @@ -0,0 +1 @@ +gTestsubsuite = 'Statements'; diff --git a/tests/auto/qml/parserstress/tests/ecma_2/Statements/switch-001.js b/tests/auto/qml/parserstress/tests/ecma_2/Statements/switch-001.js new file mode 100644 index 0000000000..22ab0a7b60 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma_2/Statements/switch-001.js @@ -0,0 +1,98 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is JavaScript Engine testing utilities. + * + * The Initial Developer of the Original Code is + * Netscape Communication Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = 'switch-001.js'; + +/** + * File Name: switch-001.js + * ECMA Section: + * Description: The switch Statement + * + * A simple switch test with no abrupt completions. + * + * Author: christine@netscape.com + * Date: 11 August 1998 + * + */ +var SECTION = "switch-001"; +var VERSION = "ECMA_2"; +var TITLE = "The switch statement"; + +var BUGNUMBER="315767"; + +startTest(); +writeHeaderToLog( SECTION + " "+ TITLE); + +SwitchTest( 0, 126 ); +SwitchTest( 1, 124 ); +SwitchTest( 2, 120 ); +SwitchTest( 3, 112 ); +SwitchTest( 4, 64 ); +SwitchTest( 5, 96 ); +SwitchTest( true, 96 ); +SwitchTest( false, 96 ); +SwitchTest( null, 96 ); +SwitchTest( void 0, 96 ); +SwitchTest( "0", 96 ); + +test(); + +function SwitchTest( input, expect ) { + var result = 0; + + switch ( input ) { + case 0: + result += 2; + case 1: + result += 4; + case 2: + result += 8; + case 3: + result += 16; + default: + result += 32; + case 4: + result +=64; + } + + new TestCase( + SECTION, + "switch with no breaks, case expressions are numbers. input is "+ + input, + expect, + result ); +} diff --git a/tests/auto/qml/parserstress/tests/ecma_2/Statements/switch-002.js b/tests/auto/qml/parserstress/tests/ecma_2/Statements/switch-002.js new file mode 100644 index 0000000000..6cb5491beb --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma_2/Statements/switch-002.js @@ -0,0 +1,96 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is JavaScript Engine testing utilities. + * + * The Initial Developer of the Original Code is + * Netscape Communication Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = 'switch-002.js'; + +/** + * File Name: switch-002.js + * ECMA Section: + * Description: The switch Statement + * + * A simple switch test with no abrupt completions. + * + * Author: christine@netscape.com + * Date: 11 August 1998 + * + */ +var SECTION = "switch-002"; +var VERSION = "ECMA_2"; +var TITLE = "The switch statement"; + +startTest(); +writeHeaderToLog( SECTION + " "+ TITLE); + +SwitchTest( 0, 6 ); +SwitchTest( 1, 4 ); +SwitchTest( 2, 56 ); +SwitchTest( 3, 48 ); +SwitchTest( 4, 64 ); +SwitchTest( true, 32 ); +SwitchTest( false, 32 ); +SwitchTest( null, 32 ); +SwitchTest( void 0, 32 ); +SwitchTest( "0", 32 ); + +test(); + +function SwitchTest( input, expect ) { + var result = 0; + + switch ( input ) { + case 0: + result += 2; + case 1: + result += 4; + break; + case 2: + result += 8; + case 3: + result += 16; + default: + result += 32; + break; + case 4: + result += 64; + } + + new TestCase( + SECTION, + "switch with no breaks: input is " + input, + expect, + result ); +} diff --git a/tests/auto/qml/parserstress/tests/ecma_2/Statements/switch-003.js b/tests/auto/qml/parserstress/tests/ecma_2/Statements/switch-003.js new file mode 100644 index 0000000000..27ed593bfe --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma_2/Statements/switch-003.js @@ -0,0 +1,90 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is JavaScript Engine testing utilities. + * + * The Initial Developer of the Original Code is + * Netscape Communication Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = 'switch-003.js'; + +/** + * File Name: switch-003.js + * ECMA Section: + * Description: The switch Statement + * + * Attempt to verify that case statements are evaluated in source order + * + * Author: christine@netscape.com + * Date: 11 August 1998 + * + */ +var SECTION = "switch-003"; +var VERSION = "ECMA_2"; +var TITLE = "The switch statement"; + +startTest(); +writeHeaderToLog( SECTION + " "+ TITLE); + +SwitchTest( "a", "abc" ); +SwitchTest( "b", "bc" ); +SwitchTest( "c", "c" ); +SwitchTest( "d", "*abc" ); +SwitchTest( "v", "*abc" ); +SwitchTest( "w", "w*abc" ); +SwitchTest( "x", "xw*abc" ); +SwitchTest( "y", "yxw*abc" ); +SwitchTest( "z", "zyxw*abc" ); +// SwitchTest( new java.lang.String("z"), "*abc" ); + +test(); + +function SwitchTest( input, expect ) { + var result = ""; + + switch ( input ) { + case "z": result += "z"; + case "y": result += "y"; + case "x": result += "x"; + case "w": result += "w"; + default: result += "*"; + case "a": result += "a"; + case "b": result += "b"; + case "c": result += "c"; + } + + new TestCase( + SECTION, + "switch with no breaks: input is " + input, + expect, + result ); +} diff --git a/tests/auto/qml/parserstress/tests/ecma_2/Statements/switch-004.js b/tests/auto/qml/parserstress/tests/ecma_2/Statements/switch-004.js new file mode 100644 index 0000000000..e7605222d6 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma_2/Statements/switch-004.js @@ -0,0 +1,127 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is JavaScript Engine testing utilities. + * + * The Initial Developer of the Original Code is + * Netscape Communication Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = 'switch-004.js'; + +/** + * File Name: switch-003.js + * ECMA Section: + * Description: The switch Statement + * + * This uses variables and objects as case expressions in switch statements. + * This verifies a bunch of bugs: + * + * http://scopus.mcom.com/bugsplat/show_bug.cgi?id=315988 + * http://scopus.mcom.com/bugsplat/show_bug.cgi?id=315975 + * http://scopus.mcom.com/bugsplat/show_bug.cgi?id=315954 + * + * Author: christine@netscape.com + * Date: 11 August 1998 + * + */ +var SECTION = "switch-003"; +var VERSION = "ECMA_2"; +var TITLE = "The switch statement"; +var BUGNUMBER= "315988"; + +startTest(); +writeHeaderToLog( SECTION + " "+ TITLE); + +ONE = new Number(1); +ZERO = new Number(0); +var A = new String("A"); +var B = new String("B"); +TRUE = new Boolean( true ); +FALSE = new Boolean( false ); +UNDEFINED = void 0; +NULL = null; + +SwitchTest( ZERO, "ZERO" ); +SwitchTest( NULL, "NULL" ); +SwitchTest( UNDEFINED, "UNDEFINED" ); +SwitchTest( FALSE, "FALSE" ); +SwitchTest( false, "false" ); +SwitchTest( 0, "0" ); + +SwitchTest ( TRUE, "TRUE" ); +SwitchTest( 1, "1" ); +SwitchTest( ONE, "ONE" ); +SwitchTest( true, "true" ); + +SwitchTest( "a", "a" ); +SwitchTest( A, "A" ); +SwitchTest( "b", "b" ); +SwitchTest( B, "B" ); + +SwitchTest( new Boolean( true ), "default" ); +SwitchTest( new Boolean(false ), "default" ); +SwitchTest( new String( "A" ), "default" ); +SwitchTest( new Number( 0 ), "default" ); + +test(); + +function SwitchTest( input, expect ) { + var result = ""; + + switch ( input ) { + default: result += "default"; break; + case "a": result += "a"; break; + case "b": result += "b"; break; + case A: result += "A"; break; + case B: result += "B"; break; + case new Boolean(true): result += "new TRUE"; break; + case new Boolean(false): result += "new FALSE"; break; + case NULL: result += "NULL"; break; + case UNDEFINED: result += "UNDEFINED"; break; + case true: result += "true"; break; + case false: result += "false"; break; + case TRUE: result += "TRUE"; break; + case FALSE: result += "FALSE"; break; + case 0: result += "0"; break; + case 1: result += "1"; break; + case new Number(0) : result += "new ZERO"; break; + case new Number(1) : result += "new ONE"; break; + case ONE: result += "ONE"; break; + case ZERO: result += "ZERO"; break; + } + + new TestCase( + SECTION, + "switch with no breaks: input is " + input, + expect, + result ); +} diff --git a/tests/auto/qml/parserstress/tests/ecma_2/Statements/try-001.js b/tests/auto/qml/parserstress/tests/ecma_2/Statements/try-001.js new file mode 100644 index 0000000000..c7b430dabe --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma_2/Statements/try-001.js @@ -0,0 +1,118 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is JavaScript Engine testing utilities. + * + * The Initial Developer of the Original Code is + * Netscape Communication Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = 'try-001.js'; + +/** + * File Name: try-001.js + * ECMA Section: + * Description: The try statement + * + * This test contains try, catch, and finally blocks. An exception is + * sometimes thrown by a function called from within the try block. + * + * This test doesn't actually make any LiveConnect calls. + * + * + * Author: christine@netscape.com + * Date: 11 August 1998 + */ +var SECTION = ""; +var VERSION = "ECMA_2"; +var TITLE = "The try statement"; + +startTest(); +writeHeaderToLog( SECTION + " "+ TITLE); + +var INVALID_JAVA_INTEGER_VALUE = "Invalid value for java.lang.Integer constructor"; + +TryNewJavaInteger( "3.14159", INVALID_JAVA_INTEGER_VALUE ); +TryNewJavaInteger( NaN, INVALID_JAVA_INTEGER_VALUE ); +TryNewJavaInteger( 0, 0 ); +TryNewJavaInteger( -1, -1 ); +TryNewJavaInteger( 1, 1 ); +TryNewJavaInteger( Infinity, Infinity ); + +test(); + +/** + * Check to see if the input is valid for java.lang.Integer. If it is + * not valid, throw INVALID_JAVA_INTEGER_VALUE. If input is valid, + * return Number( v ) + * + */ + +function newJavaInteger( v ) { + value = Number( v ); + if ( Math.floor(value) != value || isNaN(value) ) { + throw ( INVALID_JAVA_INTEGER_VALUE ); + } else { + return value; + } +} + +/** + * Call newJavaInteger( value ) from within a try block. Catch any + * exception, and store it in result. Verify that we got the right + * return value from newJavaInteger in cases in which we do not expect + * exceptions, and that we got the exception in cases where an exception + * was expected. + */ +function TryNewJavaInteger( value, expect ) { + var finalTest = false; + + try { + result = newJavaInteger( value ); + } catch ( e ) { + result = String( e ); + } finally { + finalTest = true; + } + new TestCase( + SECTION, + "newJavaValue( " + value +" )", + expect, + result); + + new TestCase( + SECTION, + "newJavaValue( " + value +" ) hit finally block", + true, + finalTest); + +} + diff --git a/tests/auto/qml/parserstress/tests/ecma_2/Statements/try-003.js b/tests/auto/qml/parserstress/tests/ecma_2/Statements/try-003.js new file mode 100644 index 0000000000..2c39aac243 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma_2/Statements/try-003.js @@ -0,0 +1,115 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is JavaScript Engine testing utilities. + * + * The Initial Developer of the Original Code is + * Netscape Communication Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = 'try-003.js'; + +/** + * File Name: try-003.js + * ECMA Section: + * Description: The try statement + * + * This test has a try with no catch, and a finally. + * + * Author: christine@netscape.com + * Date: 11 August 1998 + */ +var SECTION = "try-003"; +var VERSION = "ECMA_2"; +var TITLE = "The try statement"; +var BUGNUMBER="http://scopus.mcom.com/bugsplat/show_bug.cgi?id=313585"; + +startTest(); +writeHeaderToLog( SECTION + " "+ TITLE); + +// Tests start here. + +TrySomething( "x = \"hi\"", false ); +TrySomething( "throw \"boo\"", true ); +TrySomething( "throw 3", true ); + +test(); + +/** + * This function contains a try block with no catch block, + * but it does have a finally block. Try to evaluate expressions + * that do and do not throw exceptions. + */ + +function TrySomething( expression, throwing ) { + innerFinally = "FAIL: DID NOT HIT INNER FINALLY BLOCK"; + if (throwing) { + outerCatch = "FAILED: NO EXCEPTION CAUGHT"; + } else { + outerCatch = "PASS"; + } + outerFinally = "FAIL: DID NOT HIT OUTER FINALLY BLOCK"; + + try { + try { + eval( expression ); + } finally { + innerFinally = "PASS"; + } + } catch ( e ) { + if (throwing) { + outerCatch = "PASS"; + } else { + outerCatch = "FAIL: HIT OUTER CATCH BLOCK"; + } + } finally { + outerFinally = "PASS"; + } + + + new TestCase( + SECTION, + "eval( " + expression +" )", + "PASS", + innerFinally ); + new TestCase( + SECTION, + "eval( " + expression +" )", + "PASS", + outerCatch ); + new TestCase( + SECTION, + "eval( " + expression +" )", + "PASS", + outerFinally ); + + +} diff --git a/tests/auto/qml/parserstress/tests/ecma_2/Statements/try-004.js b/tests/auto/qml/parserstress/tests/ecma_2/Statements/try-004.js new file mode 100644 index 0000000000..d41903de18 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma_2/Statements/try-004.js @@ -0,0 +1,87 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is JavaScript Engine testing utilities. + * + * The Initial Developer of the Original Code is + * Netscape Communication Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = 'try-004.js'; + +/** + * File Name: try-004.js + * ECMA Section: + * Description: The try statement + * + * This test has a try with one catch block but no finally. + * + * Author: christine@netscape.com + * Date: 11 August 1998 + */ +var SECTION = "try-004"; +var VERSION = "ECMA_2"; +var TITLE = "The try statement"; + +startTest(); +writeHeaderToLog( SECTION + " "+ TITLE); + +TryToCatch( "Math.PI", Math.PI ); +TryToCatch( "Thrower(5)", "Caught 5" ); +TryToCatch( "Thrower(\"some random exception\")", "Caught some random exception" ); + +test(); + +function Thrower( v ) { + throw "Caught " + v; +} + +/** + * Evaluate a string. Catch any exceptions thrown. If no exception is + * expected, verify the result of the evaluation. If an exception is + * expected, verify that we got the right exception. + */ + +function TryToCatch( value, expect ) { + try { + result = eval( value ); + } catch ( e ) { + result = e; + } + + new TestCase( + SECTION, + "eval( " + value +" )", + expect, + result ); +} + + diff --git a/tests/auto/qml/parserstress/tests/ecma_2/Statements/try-005.js b/tests/auto/qml/parserstress/tests/ecma_2/Statements/try-005.js new file mode 100644 index 0000000000..0b9a055325 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma_2/Statements/try-005.js @@ -0,0 +1,90 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is JavaScript Engine testing utilities. + * + * The Initial Developer of the Original Code is + * Netscape Communication Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = 'try-005.js'; + +/** + * File Name: try-005.js + * ECMA Section: + * Description: The try statement + * + * This test has a try with one catch block but no finally. Same + * as try-004, but the eval statement is called from a function, not + * directly from within the try block. + * + * Author: christine@netscape.com + * Date: 11 August 1998 + */ +var SECTION = "try-005"; +var VERSION = "ECMA_2"; +var TITLE = "The try statement"; + +startTest(); +writeHeaderToLog( SECTION + " "+ TITLE); + +TryToCatch( "Math.PI", Math.PI ); +TryToCatch( "Thrower(5)", "Caught 5" ); +TryToCatch( "Thrower(\"some random exception\")", "Caught some random exception" ); + +test(); + +function Thrower( v ) { + throw "Caught " + v; +} +function Eval( v ) { + return eval( v ); +} + +/** + * Evaluate a string. Catch any exceptions thrown. If no exception is + * expected, verify the result of the evaluation. If an exception is + * expected, verify that we got the right exception. + */ + +function TryToCatch( value, expect ) { + try { + result = Eval( value ); + } catch ( e ) { + result = e; + } + + new TestCase( + SECTION, + "eval( " + value +" )", + expect, + result ); +} diff --git a/tests/auto/qml/parserstress/tests/ecma_2/Statements/try-006.js b/tests/auto/qml/parserstress/tests/ecma_2/Statements/try-006.js new file mode 100644 index 0000000000..1cfbd28656 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma_2/Statements/try-006.js @@ -0,0 +1,120 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is JavaScript Engine testing utilities. + * + * The Initial Developer of the Original Code is + * Netscape Communication Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = 'try-006.js'; + +/** + * File Name: try-006.js + * ECMA Section: + * Description: The try statement + * + * Throw an exception from within a With block in a try block. Verify + * that any expected exceptions are caught. + * + * Author: christine@netscape.com + * Date: 11 August 1998 + */ +var SECTION = "try-006"; +var VERSION = "ECMA_2"; +var TITLE = "The try statement"; + +startTest(); +writeHeaderToLog( SECTION + " "+ TITLE); + +/** + * This is the "check" function for test objects that will + * throw an exception. + */ +function throwException() { + throw EXCEPTION_STRING +": " + this.valueOf(); +} +var EXCEPTION_STRING = "Exception thrown:"; + +/** + * This is the "check" function for test objects that do not + * throw an exception + */ +function noException() { + return this.valueOf(); +} + +/** + * Add test cases here + */ +TryWith( new TryObject( "hello", throwException, true )); +TryWith( new TryObject( "hola", noException, false )); + +/** + * Run the test. + */ + +test(); + +/** + * This is the object that will be the "this" in a with block. + */ +function TryObject( value, fun, exception ) { + this.value = value; + this.exception = exception; + + this.valueOf = new Function ( "return this.value" ); + this.check = fun; +} + +/** + * This function has the try block that has a with block within it. + * Test cases are added in this function. Within the with block, the + * object's "check" function is called. If the test object's exception + * property is true, we expect the result to be the exception value. + * If exception is false, then we expect the result to be the value of + * the object. + */ +function TryWith( object ) { + try { + with ( object ) { + result = check(); + } + } catch ( e ) { + result = e; + } + + new TestCase( + SECTION, + "TryWith( " + object.value +" )", + (object.exception ? EXCEPTION_STRING +": " + object.valueOf() : object.valueOf()), + result ); +} diff --git a/tests/auto/qml/parserstress/tests/ecma_2/Statements/try-007.js b/tests/auto/qml/parserstress/tests/ecma_2/Statements/try-007.js new file mode 100644 index 0000000000..566166755c --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma_2/Statements/try-007.js @@ -0,0 +1,125 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is JavaScript Engine testing utilities. + * + * The Initial Developer of the Original Code is + * Netscape Communication Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = 'try-007.js'; + +/** + * File Name: try-007.js + * ECMA Section: + * Description: The try statement + * + * This test has a for-in statement within a try block. + * + * + * Author: christine@netscape.com + * Date: 11 August 1998 + */ +var SECTION = "try-007"; +var VERSION = "ECMA_2"; +var TITLE = "The try statement: for-in"; + +startTest(); +writeHeaderToLog( SECTION + " "+ TITLE); + +/** + * This is the "check" function for test objects that will + * throw an exception. + */ +function throwException() { + throw EXCEPTION_STRING +": " + this.valueOf(); +} +var EXCEPTION_STRING = "Exception thrown:"; + +/** + * This is the "check" function for test objects that do not + * throw an exception + */ +function noException() { + return this.valueOf(); +} + +/** + * Add test cases here + */ +TryForIn( new TryObject( "hello", throwException, true )); +TryForIn( new TryObject( "hola", noException, false )); + +/** + * Run the test. + */ + +test(); + +/** + * This is the object that will be the "this" in a with block. + * The check function is either throwException() or noException(). + * See above. + * + */ +function TryObject( value, fun, exception ) { + this.value = value; + this.exception = exception; + + this.check = fun; + this.valueOf = function () { return this.value; } +} + +/** + * This function has a for-in statement within a try block. Test cases + * are added after the try-catch-finally statement. Within the for-in + * block, call a function that can throw an exception. Verify that any + * exceptions are properly caught. + */ + +function TryForIn( object ) { + try { + for ( p in object ) { + if ( typeof object[p] == "function" ) { + result = object[p](); + } + } + } catch ( e ) { + result = e; + } + + new TestCase( + SECTION, + "TryForIn( " + object+ " )", + (object.exception ? EXCEPTION_STRING +": " + object.value : object.value), + result ); + +} diff --git a/tests/auto/qml/parserstress/tests/ecma_2/Statements/try-008.js b/tests/auto/qml/parserstress/tests/ecma_2/Statements/try-008.js new file mode 100644 index 0000000000..016ab29a31 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma_2/Statements/try-008.js @@ -0,0 +1,92 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is JavaScript Engine testing utilities. + * + * The Initial Developer of the Original Code is + * Netscape Communication Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = 'try-008.js'; + +/** + * File Name: try-008.js + * ECMA Section: + * Description: The try statement + * + * This test has a try block in a constructor. + * + * + * Author: christine@netscape.com + * Date: 11 August 1998 + */ +var SECTION = "try-008"; +var VERSION = "ECMA_2"; +var TITLE = "The try statement: try in a constructor"; + +startTest(); +writeHeaderToLog( SECTION + " "+ TITLE); + +function Integer( value, exception ) { + try { + this.value = checkValue( value ); + } catch ( e ) { + this.value = e.toString(); + } + + new TestCase( + SECTION, + "Integer( " + value +" )", + (exception ? INVALID_INTEGER_VALUE +": " + value : this.value), + this.value ); +} + +var INVALID_INTEGER_VALUE = "Invalid value for java.lang.Integer constructor"; + +function checkValue( value ) { + if ( Math.floor(value) != value || isNaN(value) ) { + throw ( INVALID_INTEGER_VALUE +": " + value ); + } else { + return value; + } +} + +// add test cases + +new Integer( 3, false ); +new Integer( NaN, true ); +new Integer( 0, false ); +new Integer( Infinity, false ); +new Integer( -2.12, true ); +new Integer( Math.LN2, true ); + + +test(); diff --git a/tests/auto/qml/parserstress/tests/ecma_2/Statements/try-009.js b/tests/auto/qml/parserstress/tests/ecma_2/Statements/try-009.js new file mode 100644 index 0000000000..d6ce368638 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma_2/Statements/try-009.js @@ -0,0 +1,99 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is JavaScript Engine testing utilities. + * + * The Initial Developer of the Original Code is + * Netscape Communication Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = 'try-009.js'; + +/** + * File Name: try-009.js + * ECMA Section: + * Description: The try statement + * + * This test has a try block within a while block. Verify that an exception + * breaks out of the while. I don't really know why this is an interesting + * test case but Mike Shaver had two of these so what the hey. + * + * Author: christine@netscape.com + * Date: 11 August 1998 + */ +var SECTION = "try-009"; +var VERSION = "ECMA_2"; +var TITLE = "The try statement: try in a while block"; + +startTest(); +writeHeaderToLog( SECTION + " "+ TITLE); + +var EXCEPTION_STRING = "Exception thrown: "; +var NO_EXCEPTION_STRING = "No exception thrown: "; + + +TryInWhile( new TryObject( "hello", ThrowException, true ) ); +TryInWhile( new TryObject( "aloha", NoException, false )); + +test(); + +function TryObject( value, throwFunction, result ) { + this.value = value; + this.thrower = throwFunction; + this.result = result; +} +function ThrowException() { + throw EXCEPTION_STRING + this.value; +} +function NoException() { + return NO_EXCEPTION_STRING + this.value; +} +function TryInWhile( object ) { + result = null; + while ( true ) { + try { + object.thrower(); + result = NO_EXCEPTION_STRING + object.value; + break; + } catch ( e ) { + result = e; + break; + } + } + + new TestCase( + SECTION, + "( "+ object +".thrower() )", + (object.result + ? EXCEPTION_STRING + object.value : + NO_EXCEPTION_STRING + object.value), + result ); +} diff --git a/tests/auto/qml/parserstress/tests/ecma_2/Statements/try-010.js b/tests/auto/qml/parserstress/tests/ecma_2/Statements/try-010.js new file mode 100644 index 0000000000..27e712c895 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma_2/Statements/try-010.js @@ -0,0 +1,106 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is JavaScript Engine testing utilities. + * + * The Initial Developer of the Original Code is + * Netscape Communication Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = 'try-010.js'; + +/** + * File Name: try-010.js + * ECMA Section: + * Description: The try statement + * + * This has a try block nested in the try block. Verify that the + * exception is caught by the right try block, and all finally blocks + * are executed. + * + * Author: christine@netscape.com + * Date: 11 August 1998 + */ +var SECTION = "try-010"; +var VERSION = "ECMA_2"; +var TITLE = "The try statement: try in a tryblock"; + +startTest(); +writeHeaderToLog( SECTION + " "+ TITLE); + +var EXCEPTION_STRING = "Exception thrown: "; +var NO_EXCEPTION_STRING = "No exception thrown: "; + + +NestedTry( new TryObject( "No Exceptions Thrown", NoException, NoException, 43 ) ); +NestedTry( new TryObject( "Throw Exception in Outer Try", ThrowException, NoException, 48 )); +NestedTry( new TryObject( "Throw Exception in Inner Try", NoException, ThrowException, 45 )); +NestedTry( new TryObject( "Throw Exception in Both Trys", ThrowException, ThrowException, 48 )); + +test(); + +function TryObject( description, tryOne, tryTwo, result ) { + this.description = description; + this.tryOne = tryOne; + this.tryTwo = tryTwo; + this.result = result; +} +function ThrowException() { + throw EXCEPTION_STRING + this.value; +} +function NoException() { + return NO_EXCEPTION_STRING + this.value; +} +function NestedTry( object ) { + result = 0; + try { + object.tryOne(); + result += 1; + try { + object.tryTwo(); + result += 2; + } catch ( e ) { + result +=4; + } finally { + result += 8; + } + } catch ( e ) { + result += 16; + } finally { + result += 32; + } + + new TestCase( + SECTION, + object.description, + object.result, + result ); +} diff --git a/tests/auto/qml/parserstress/tests/ecma_2/Statements/try-012.js b/tests/auto/qml/parserstress/tests/ecma_2/Statements/try-012.js new file mode 100644 index 0000000000..79dfca2f03 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma_2/Statements/try-012.js @@ -0,0 +1,128 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is JavaScript Engine testing utilities. + * + * The Initial Developer of the Original Code is + * Netscape Communication Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = 'try-012.js'; + +/** + * File Name: try-012.js + * ECMA Section: + * Description: The try statement + * + * This test has a try with no catch, and a finally. This is like try-003, + * but throws from a finally block, not the try block. + * + * Author: christine@netscape.com + * Date: 11 August 1998 + */ +var SECTION = "try-012"; +var VERSION = "ECMA_2"; +var TITLE = "The try statement"; +var BUGNUMBER="336872"; + +startTest(); +writeHeaderToLog( SECTION + " "+ TITLE); + +// Tests start here. + +TrySomething( "x = \"hi\"", true ); +TrySomething( "throw \"boo\"", true ); +TrySomething( "throw 3", true ); + +test(); + +/** + * This function contains a try block with no catch block, + * but it does have a finally block. Try to evaluate expressions + * that do and do not throw exceptions. + * + * The productioni TryStatement Block Finally is evaluated as follows: + * 1. Evaluate Block + * 2. Evaluate Finally + * 3. If Result(2).type is normal return result 1 (in the test case, result 1 has + * the completion type throw) + * 4. return result 2 (does not get hit in this case) + * + */ + +function TrySomething( expression, throwing ) { + innerFinally = "FAIL: DID NOT HIT INNER FINALLY BLOCK"; + if (throwing) { + outerCatch = "FAILED: NO EXCEPTION CAUGHT"; + } else { + outerCatch = "PASS"; + } + outerFinally = "FAIL: DID NOT HIT OUTER FINALLY BLOCK"; + + + // If the inner finally does not throw an exception, the result + // of the try block should be returned. (Type of inner return + // value should be throw if finally executes correctly + + try { + try { + throw 0; + } finally { + innerFinally = "PASS"; + eval( expression ); + } + } catch ( e ) { + if (throwing) { + outerCatch = "PASS"; + } else { + outerCatch = "FAIL: HIT OUTER CATCH BLOCK"; + } + } finally { + outerFinally = "PASS"; + } + + + new TestCase( + SECTION, + "eval( " + expression +" ): evaluated inner finally block", + "PASS", + innerFinally ); + new TestCase( + SECTION, + "eval( " + expression +" ): evaluated outer catch block ", + "PASS", + outerCatch ); + new TestCase( + SECTION, + "eval( " + expression +" ): evaluated outer finally block", + "PASS", + outerFinally ); +} diff --git a/tests/auto/qml/parserstress/tests/ecma_2/Statements/while-001.js b/tests/auto/qml/parserstress/tests/ecma_2/Statements/while-001.js new file mode 100644 index 0000000000..467efe7f02 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma_2/Statements/while-001.js @@ -0,0 +1,75 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is JavaScript Engine testing utilities. + * + * The Initial Developer of the Original Code is + * Netscape Communication Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = 'while-001.js'; + +/** + * File Name: while-001 + * ECMA Section: + * Description: while statement + * + * Verify that the while statement is not executed if the while expression is + * false + * + * Author: christine@netscape.com + * Date: 11 August 1998 + */ +var SECTION = "while-001"; +var VERSION = "ECMA_2"; +var TITLE = "while statement"; + +startTest(); +writeHeaderToLog( SECTION + " "+ TITLE); + +DoWhile(); +test(); + +function DoWhile() { + result = "pass"; + + while (false) { + result = "fail"; + break; + } + + new TestCase( + SECTION, + "while statement: don't evaluate statement is expression is false", + "pass", + result ); + +} diff --git a/tests/auto/qml/parserstress/tests/ecma_2/Statements/while-002.js b/tests/auto/qml/parserstress/tests/ecma_2/Statements/while-002.js new file mode 100644 index 0000000000..c89e195497 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma_2/Statements/while-002.js @@ -0,0 +1,119 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is JavaScript Engine testing utilities. + * + * The Initial Developer of the Original Code is + * Netscape Communication Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = 'while-002.js'; + +/** + * File Name: while-002 + * ECMA Section: + * Description: while statement + * + * Verify that the while statement is not executed if the while expression is + * false + * + * Author: christine@netscape.com + * Date: 11 August 1998 + */ +var SECTION = "while-002"; +var VERSION = "ECMA_2"; +var TITLE = "while statement"; + +startTest(); +writeHeaderToLog( SECTION + " "+ TITLE); + +DoWhile( new DoWhileObject( + "while expression is null", + null, + "result = \"fail: should not have evaluated statements in while block;break" + ) ); + +DoWhile( new DoWhileObject( + "while expression is undefined", + void 0, + "result = \"fail: should not have evaluated statements in while block; break" + )); + +DoWhile( new DoWhileObject( + "while expression is 0", + 0, + "result = \"fail: should not have evaluated statements in while block; break;" + )); + +DoWhile( new DoWhileObject( + "while expression is eval(\"\")", + eval(""), + "result = \"fail: should not have evaluated statements in while block; break" + )); + +DoWhile( new DoWhileObject( + "while expression is NaN", + NaN, + "result = \"fail: should not have evaluated statements in while block; break" + )); + +test(); + +function DoWhileObject( d, e, s ) { + this.description = d; + this.whileExpression = e; + this.statements = s; +} + +function DoWhile( object ) { + result = "pass"; + + while ( expression = object.whileExpression ) { + eval( object.statements ); + } + + // verify that the while expression was evaluated + + new TestCase( + SECTION, + "verify that while expression was evaluated (should be "+ + object.whileExpression +")", + "pass", + (object.whileExpression == expression || + ( isNaN(object.whileExpression) && isNaN(expression) ) + ) ? "pass" : "fail" ); + + new TestCase( + SECTION, + object.description, + "pass", + result ); +} diff --git a/tests/auto/qml/parserstress/tests/ecma_2/Statements/while-003.js b/tests/auto/qml/parserstress/tests/ecma_2/Statements/while-003.js new file mode 100644 index 0000000000..5fb734cce6 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma_2/Statements/while-003.js @@ -0,0 +1,120 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is JavaScript Engine testing utilities. + * + * The Initial Developer of the Original Code is + * Netscape Communication Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = 'while-003.js'; + +/** + * File Name: while-003 + * ECMA Section: + * Description: while statement + * + * The while expression evaluates to true, Statement returns abrupt completion. + * + * Author: christine@netscape.com + * Date: 11 August 1998 + */ +var SECTION = "while-003"; +var VERSION = "ECMA_2"; +var TITLE = "while statement"; + +startTest(); +writeHeaderToLog( SECTION + " "+ TITLE); + +DoWhile( new DoWhileObject( + "while expression is true", + true, + "result = \"pass\";" )); + +DoWhile( new DoWhileObject( + "while expression is 1", + 1, + "result = \"pass\";" )); + +DoWhile( new DoWhileObject( + "while expression is new Boolean(false)", + new Boolean(false), + "result = \"pass\";" )); + +DoWhile( new DoWhileObject( + "while expression is new Object()", + new Object(), + "result = \"pass\";" )); + +DoWhile( new DoWhileObject( + "while expression is \"hi\"", + "hi", + "result = \"pass\";" )); +/* + DoWhile( new DoWhileObject( + "while expression has a continue in it", + "true", + "if ( i == void 0 ) i = 0; result=\"pass\"; if ( ++i == 1 ) {continue;} else {break;} result=\"fail\";" + )); +*/ +test(); + +function DoWhileObject( d, e, s ) { + this.description = d; + this.whileExpression = e; + this.statements = s; +} + +function DoWhile( object ) { + result = "fail: statements in while block were not evaluated"; + + while ( expression = object.whileExpression ) { + eval( object.statements ); + break; + } + + // verify that the while expression was evaluated + + new TestCase( + SECTION, + "verify that while expression was evaluated (should be "+ + object.whileExpression +")", + "pass", + (object.whileExpression == expression || + ( isNaN(object.whileExpression) && isNaN(expression) ) + ) ? "pass" : "fail" ); + + new TestCase( + SECTION, + object.description, + "pass", + result ); +} diff --git a/tests/auto/qml/parserstress/tests/ecma_2/Statements/while-004.js b/tests/auto/qml/parserstress/tests/ecma_2/Statements/while-004.js new file mode 100644 index 0000000000..c5e2472816 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma_2/Statements/while-004.js @@ -0,0 +1,250 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is JavaScript Engine testing utilities. + * + * The Initial Developer of the Original Code is + * Netscape Communication Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = 'while-004.js'; + +/** + * File Name: while-004 + * ECMA Section: + * Description: while statement + * + * Author: christine@netscape.com + * Date: 11 August 1998 + */ +var SECTION = "while-004"; +var VERSION = "ECMA_2"; +var TITLE = "while statement"; +var BUGNUMBER="316725"; + +startTest(); +writeHeaderToLog( SECTION + " "+ TITLE); + +DoWhile_1(); +DoWhile_2(); +DoWhile_3(); +DoWhile_4(); +DoWhile_5(); + +test(); + +/** + * Break out of a while by calling return. + * + * Tests: 12.6.2 step 6. + */ +function dowhile() { + result = "pass"; + + while (true) { + return result; + result = "fail: hit code after return statement"; + break; + } +} + +function DoWhile_1() { + description = "return statement in a while block"; + + result = dowhile(); + + new TestCase( + SECTION, + "DoWhile_1" + description, + "pass", + result ); +} + +/** + * While with a labeled continue statement. Verify that statements + * after the continue statement are not evaluated. + * + * Tests: 12.6.2 step 8. + * + */ +function DoWhile_2() { + var description = "while with a labeled continue statement"; + var result1 = "pass"; + var result2 = "fail: did not execute code after loop, but inside label"; + var i = 0; + var j = 0; + +theloop: + while( i++ < 10 ) { + j++; + continue theloop; + result1 = "failed: hit code after continue statement"; + } + result2 = "pass"; + + new TestCase( + SECTION, + "DoWhile_2: " +description + " - code inside the loop, before the continue should be executed ("+j+")", + true, + j == 10 ); + + new TestCase( + SECTION, + "DoWhile_2: " +description +" - code after labeled continue should not be executed", + "pass", + result1 ); + + new TestCase( + SECTION, + "DoWhile_2: " +description +" - code after loop but inside label should be executed", + "pass", + result2 ); +} + +/** + * While with a labeled break. + * + */ +function DoWhile_3() { + var description = "while with a labeled break statement"; + var result1 = "pass"; + var result2 = "pass"; + var result3 = "fail: did not get to code after label"; + +woohoo: { + while( true ) { + break woohoo; + result1 = "fail: got to code after a break"; + } + result2 = "fail: got to code outside of loop but inside label"; + } + + result3 = "pass"; + + new TestCase( + SECTION, + "DoWhile_3: " +description +" - verify break out of loop", + "pass", + result1 ); + + + new TestCase( + SECTION, + "DoWhile_3: " +description +" - verify break out of label", + "pass", + result2 ); + + new TestCase( + SECTION, + "DoWhile_3: " +description + " - verify correct exit from label", + "pass", + result3 ); +} + + +/** + * Labled while with an unlabeled break + * + */ +function DoWhile_4() { + var description = "labeled while with an unlabeled break"; + var result1 = "pass"; + var result2 = "pass"; + var result3 = "fail: did not evaluate statement after label"; + +woohooboy: { + while( true ) { + break woohooboy; + result1 = "fail: got to code after the break"; + } + result2 = "fail: broke out of while, but not out of label"; + } + result3 = "pass"; + + new TestCase( + SECTION, + "DoWhile_4: " +description +" - verify break out of while loop", + "pass", + result1 ); + + new TestCase( + SECTION, + "DoWhile_4: " +description + " - verify break out of label", + "pass", + result2 ); + + new TestCase( + SECTION, + "DoWhile_4: " +description +" - verify that statements after label are evaluated", + "pass", + result3 ); +} + +/** + * in this case, should behave the same way as + * + * + */ +function DoWhile_5() { + var description = "while with a labeled continue statement"; + var result1 = "pass"; + var result2 = "fail: did not execute code after loop, but inside label"; + var i = 0; + var j = 0; + +theloop: { + j++; + while( i++ < 10 ) { + continue; + result1 = "failed: hit code after continue statement"; + } + result2 = "pass"; + } + + new TestCase( + SECTION, + "DoWhile_5: " +description + " - continue should not execute statements above the loop", + true, + ( j == 1 ) ); + + new TestCase( + SECTION, + "DoWhile_5: " +description +" - code after labeled continue should not be executed", + "pass", + result1 ); + + new TestCase( + SECTION, + "DoWhile_5: " +description +" - code after loop but inside label should be executed", + "pass", + result2 ); +} + diff --git a/tests/auto/qml/parserstress/tests/ecma_2/String/browser.js b/tests/auto/qml/parserstress/tests/ecma_2/String/browser.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/auto/qml/parserstress/tests/ecma_2/String/match-001.js b/tests/auto/qml/parserstress/tests/ecma_2/String/match-001.js new file mode 100644 index 0000000000..de2275b5d6 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma_2/String/match-001.js @@ -0,0 +1,139 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is JavaScript Engine testing utilities. + * + * The Initial Developer of the Original Code is + * Netscape Communication Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = 'match-001.js'; + +/** + * File Name: String/match-001.js + * ECMA Section: 15.6.4.9 + * Description: Based on ECMA 2 Draft 7 February 1999 + * + * Author: christine@netscape.com + * Date: 19 February 1999 + */ + +/* + * String.match( regexp ) + * + * If regexp is not an object of type RegExp, it is replaced with result + * of the expression new RegExp(regexp). Let string denote the result of + * converting the this value to a string. If regexp.global is false, + * return the result obtained by invoking RegExp.prototype.exec (see + * section 15.7.5.3) on regexp with string as parameter. + * + * Otherwise, set the regexp.lastIndex property to 0 and invoke + * RegExp.prototype.exec repeatedly until there is no match. If there is a + * match with an empty string (in other words, if the value of + * regexp.lastIndex is left unchanged) increment regexp.lastIndex by 1. + * The value returned is an array with the properties 0 through n-1 + * corresponding to the first element of the result of each matching + * invocation of RegExp.prototype.exec. + * + * Note that the match function is intentionally generic; it does not + * require that its this value be a string object. Therefore, it can be + * transferred to other kinds of objects for use as a method. + */ + +var SECTION = "String/match-001.js"; +var VERSION = "ECMA_2"; +var TITLE = "String.prototype.match( regexp )"; + +startTest(); + +// the regexp argument is not a RegExp object +// this is not a string object + +// cases in which the regexp global property is false + +AddRegExpCases( 3, "3", "1234567890", 1, 2, ["3"] ); + +// cases in which the regexp object global property is true + +AddGlobalRegExpCases( /34/g, "/34/g", "343443444", 3, ["34", "34", "34"] ); +AddGlobalRegExpCases( /\d{1}/g, "/d{1}/g", "123456abcde7890", 10, + ["1", "2", "3", "4", "5", "6", "7", "8", "9", "0"] ); + +AddGlobalRegExpCases( /\d{2}/g, "/d{2}/g", "123456abcde7890", 5, + ["12", "34", "56", "78", "90"] ); + +AddGlobalRegExpCases( /\D{2}/g, "/d{2}/g", "123456abcde7890", 2, + ["ab", "cd"] ); + +test(); + + +function AddRegExpCases( + regexp, str_regexp, string, length, index, matches_array ) { + + AddTestCase( + "( " + string + " ).match(" + str_regexp +").length", + length, + string.match(regexp).length ); + + AddTestCase( + "( " + string + " ).match(" + str_regexp +").index", + index, + string.match(regexp).index ); + + AddTestCase( + "( " + string + " ).match(" + str_regexp +").input", + string, + string.match(regexp).input ); + + for ( var matches = 0; matches < matches_array.length; matches++ ) { + AddTestCase( + "( " + string + " ).match(" + str_regexp +")[" + matches +"]", + matches_array[matches], + string.match(regexp)[matches] ); + } +} + +function AddGlobalRegExpCases( + regexp, str_regexp, string, length, matches_array ) { + + AddTestCase( + "( " + string + " ).match(" + str_regexp +").length", + length, + string.match(regexp).length ); + + for ( var matches = 0; matches < matches_array.length; matches++ ) { + AddTestCase( + "( " + string + " ).match(" + str_regexp +")[" + matches +"]", + matches_array[matches], + string.match(regexp)[matches] ); + } +} diff --git a/tests/auto/qml/parserstress/tests/ecma_2/String/match-002.js b/tests/auto/qml/parserstress/tests/ecma_2/String/match-002.js new file mode 100644 index 0000000000..a57da2f77f --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma_2/String/match-002.js @@ -0,0 +1,207 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is JavaScript Engine testing utilities. + * + * The Initial Developer of the Original Code is + * Netscape Communication Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = 'match-002.js'; + +/** + * File Name: String/match-002.js + * ECMA Section: 15.6.4.9 + * Description: Based on ECMA 2 Draft 7 February 1999 + * + * Author: christine@netscape.com + * Date: 19 February 1999 + */ + +/* + * String.match( regexp ) + * + * If regexp is not an object of type RegExp, it is replaced with result + * of the expression new RegExp(regexp). Let string denote the result of + * converting the this value to a string. If regexp.global is false, + * return the result obtained by invoking RegExp.prototype.exec (see + * section 15.7.5.3) on regexp with string as parameter. + * + * Otherwise, set the regexp.lastIndex property to 0 and invoke + * RegExp.prototype.exec repeatedly until there is no match. If there is a + * match with an empty string (in other words, if the value of + * regexp.lastIndex is left unchanged) increment regexp.lastIndex by 1. + * The value returned is an array with the properties 0 through n-1 + * corresponding to the first element of the result of each matching + * invocation of RegExp.prototype.exec. + * + * Note that the match function is intentionally generic; it does not + * require that its this value be a string object. Therefore, it can be + * transferred to other kinds of objects for use as a method. + * + * This file tests cases in which regexp.global is false. Therefore, + * results should behave as regexp.exec with string passed as a parameter. + * + */ + +var SECTION = "String/match-002.js"; +var VERSION = "ECMA_2"; +var TITLE = "String.prototype.match( regexp )"; + +startTest(); + +// the regexp argument is not a RegExp object +// this is not a string object + +AddRegExpCases( /([\d]{5})([-\ ]?[\d]{4})?$/, + "/([\d]{5})([-\ ]?[\d]{4})?$/", + "Boston, Mass. 02134", + 14, + ["02134", "02134", undefined]); + +AddGlobalRegExpCases( /([\d]{5})([-\ ]?[\d]{4})?$/g, + "/([\d]{5})([-\ ]?[\d]{4})?$/g", + "Boston, Mass. 02134", + ["02134"]); + +// set the value of lastIndex +re = /([\d]{5})([-\ ]?[\d]{4})?$/; +re.lastIndex = 0; + +s = "Boston, MA 02134"; + +AddRegExpCases( re, + "re = /([\d]{5})([-\ ]?[\d]{4})?$/; re.lastIndex =0", + s, + s.lastIndexOf("0"), + ["02134", "02134", undefined]); + + +re.lastIndex = s.length; + +AddRegExpCases( re, + "re = /([\d]{5})([-\ ]?[\d]{4})?$/; re.lastIndex = " + + s.length, + s, + s.lastIndexOf("0"), + ["02134", "02134", undefined] ); + +re.lastIndex = s.lastIndexOf("0"); + +AddRegExpCases( re, + "re = /([\d]{5})([-\ ]?[\d]{4})?$/; re.lastIndex = " + + s.lastIndexOf("0"), + s, + s.lastIndexOf("0"), + ["02134", "02134", undefined]); + +re.lastIndex = s.lastIndexOf("0") + 1; + +AddRegExpCases( re, + "re = /([\d]{5})([-\ ]?[\d]{4})?$/; re.lastIndex = " + + s.lastIndexOf("0") +1, + s, + s.lastIndexOf("0"), + ["02134", "02134", undefined]); + +test(); + +function AddRegExpCases( + regexp, str_regexp, string, index, matches_array ) { + + // prevent a runtime error + + if ( regexp.exec(string) == null || matches_array == null ) { + AddTestCase( + string + ".match(" + regexp +")", + matches_array, + string.match(regexp) ); + + return; + } + + AddTestCase( + "( " + string + " ).match(" + str_regexp +").length", + matches_array.length, + string.match(regexp).length ); + + AddTestCase( + "( " + string + " ).match(" + str_regexp +").index", + index, + string.match(regexp).index ); + + AddTestCase( + "( " + string + " ).match(" + str_regexp +").input", + string, + string.match(regexp).input ); + + var limit = matches_array.length > string.match(regexp).length ? + matches_array.length : + string.match(regexp).length; + + for ( var matches = 0; matches < limit; matches++ ) { + AddTestCase( + "( " + string + " ).match(" + str_regexp +")[" + matches +"]", + matches_array[matches], + string.match(regexp)[matches] ); + } +} + +function AddGlobalRegExpCases( + regexp, str_regexp, string, matches_array ) { + + // prevent a runtime error + + if ( regexp.exec(string) == null || matches_array == null ) { + AddTestCase( + regexp + ".exec(" + string +")", + matches_array, + regexp.exec(string) ); + + return; + } + + AddTestCase( + "( " + string + " ).match(" + str_regexp +").length", + matches_array.length, + string.match(regexp).length ); + + var limit = matches_array.length > string.match(regexp).length ? + matches_array.length : + string.match(regexp).length; + + for ( var matches = 0; matches < limit; matches++ ) { + AddTestCase( + "( " + string + " ).match(" + str_regexp +")[" + matches +"]", + matches_array[matches], + string.match(regexp)[matches] ); + } +} diff --git a/tests/auto/qml/parserstress/tests/ecma_2/String/match-003.js b/tests/auto/qml/parserstress/tests/ecma_2/String/match-003.js new file mode 100644 index 0000000000..cd3d80c919 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma_2/String/match-003.js @@ -0,0 +1,165 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is JavaScript Engine testing utilities. + * + * The Initial Developer of the Original Code is + * Netscape Communication Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = 'match-003.js'; + +/** + * File Name: String/match-003.js + * ECMA Section: 15.6.4.9 + * Description: Based on ECMA 2 Draft 7 February 1999 + * + * Author: christine@netscape.com + * Date: 19 February 1999 + */ + +/* + * String.match( regexp ) + * + * If regexp is not an object of type RegExp, it is replaced with result + * of the expression new RegExp(regexp). Let string denote the result of + * converting the this value to a string. If regexp.global is false, + * return the result obtained by invoking RegExp.prototype.exec (see + * section 15.7.5.3) on regexp with string as parameter. + * + * Otherwise, set the regexp.lastIndex property to 0 and invoke + * RegExp.prototype.exec repeatedly until there is no match. If there is a + * match with an empty string (in other words, if the value of + * regexp.lastIndex is left unchanged) increment regexp.lastIndex by 1. + * The value returned is an array with the properties 0 through n-1 + * corresponding to the first element of the result of each matching + * invocation of RegExp.prototype.exec. + * + * Note that the match function is intentionally generic; it does not + * require that its this value be a string object. Therefore, it can be + * transferred to other kinds of objects for use as a method. + */ + +var SECTION = "String/match-003.js"; +var VERSION = "ECMA_2"; +var TITLE = "String.prototype.match( regexp )"; + +startTest(); + +// the regexp argument is not a RegExp object +// this is not a string object + + +// [if regexp.global is true] set the regexp.lastIndex property to 0 and +// invoke RegExp.prototype.exec repeatedly until there is no match. If +// there is a match with an empty string (in other words, if the value of +// regexp.lastIndex is left unchanged) increment regexp.lastIndex by 1. +// The value returned is an array with the properties 0 through n-1 +// corresponding to the first element of the result of each matching invocation +// of RegExp.prototype.exec. + + +// set the value of lastIndex +re = /([\d]{5})([-\ ]?[\d]{4})?$/g; + + +s = "Boston, MA 02134"; + +AddGlobalRegExpCases( re, + "re = " + re, + s, + ["02134" ]); + +re.lastIndex = 0; + +AddGlobalRegExpCases( + re, + "re = " + re + "; re.lastIndex = 0 ", + s, + ["02134"]); + + +re.lastIndex = s.length; + +AddGlobalRegExpCases( + re, + "re = " + re + "; re.lastIndex = " + s.length, + s, + ["02134"] ); + +re.lastIndex = s.lastIndexOf("0"); + +AddGlobalRegExpCases( + re, + "re = "+ re +"; re.lastIndex = " + s.lastIndexOf("0"), + s, + ["02134"]); + +re.lastIndex = s.lastIndexOf("0") + 1; + +AddGlobalRegExpCases( + re, + "re = " +re+ "; re.lastIndex = " + (s.lastIndexOf("0") +1), + s, + ["02134"]); + +test(); + +function AddGlobalRegExpCases( + regexp, str_regexp, string, matches_array ) { + + // prevent a runtime error + + if ( string.match(regexp) == null || matches_array == null ) { + AddTestCase( + string + ".match(" + str_regexp +")", + matches_array, + string.match(regexp) ); + + return; + } + + AddTestCase( + "( " + string + " ).match(" + str_regexp +").length", + matches_array.length, + string.match(regexp).length ); + + var limit = matches_array.length > string.match(regexp).length ? + matches_array.length : + string.match(regexp).length; + + for ( var matches = 0; matches < limit; matches++ ) { + AddTestCase( + "( " + string + " ).match(" + str_regexp +")[" + matches +"]", + matches_array[matches], + string.match(regexp)[matches] ); + } +} diff --git a/tests/auto/qml/parserstress/tests/ecma_2/String/match-004.js b/tests/auto/qml/parserstress/tests/ecma_2/String/match-004.js new file mode 100644 index 0000000000..5c26de8b61 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma_2/String/match-004.js @@ -0,0 +1,206 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is JavaScript Engine testing utilities. + * + * The Initial Developer of the Original Code is + * Netscape Communication Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = 'match-004.js'; + +/** + * File Name: String/match-004.js + * ECMA Section: 15.6.4.9 + * Description: Based on ECMA 2 Draft 7 February 1999 + * + * Author: christine@netscape.com + * Date: 19 February 1999 + */ + +/* + * String.match( regexp ) + * + * If regexp is not an object of type RegExp, it is replaced with result + * of the expression new RegExp(regexp). Let string denote the result of + * converting the this value to a string. If regexp.global is false, + * return the result obtained by invoking RegExp.prototype.exec (see + * section 15.7.5.3) on regexp with string as parameter. + * + * Otherwise, set the regexp.lastIndex property to 0 and invoke + * RegExp.prototype.exec repeatedly until there is no match. If there is a + * match with an empty string (in other words, if the value of + * regexp.lastIndex is left unchanged) increment regexp.lastIndex by 1. + * The value returned is an array with the properties 0 through n-1 + * corresponding to the first element of the result of each matching + * invocation of RegExp.prototype.exec. + * + * Note that the match function is intentionally generic; it does not + * require that its this value be a string object. Therefore, it can be + * transferred to other kinds of objects for use as a method. + * + * + * The match function should be intentionally generic, and not require + * this to be a string. + * + */ + +var SECTION = "String/match-004.js"; +var VERSION = "ECMA_2"; +var TITLE = "String.prototype.match( regexp )"; + +var BUGNUMBER="http://scopus/bugsplat/show_bug.cgi?id=345818"; + +startTest(); + +// set the value of lastIndex +re = /0./; +s = 10203040506070809000; + +Number.prototype.match = String.prototype.match; + +AddRegExpCases( re, + "re = " + re , + s, + String(s), + 1, + ["02"]); + + +re.lastIndex = 0; +AddRegExpCases( re, + "re = " + re +" [lastIndex is " + re.lastIndex+"]", + s, + String(s), + 1, + ["02"]); +/* + +re.lastIndex = s.length; + +AddRegExpCases( re, +"re = /([\d]{5})([-\ ]?[\d]{4})?$/; re.lastIndex = " + +s.length, +s, +s.lastIndexOf("0"), +null ); + +re.lastIndex = s.lastIndexOf("0"); + +AddRegExpCases( re, +"re = /([\d]{5})([-\ ]?[\d]{4})?$/; re.lastIndex = " + +s.lastIndexOf("0"), +s, +s.lastIndexOf("0"), +["02134"]); + +re.lastIndex = s.lastIndexOf("0") + 1; + +AddRegExpCases( re, +"re = /([\d]{5})([-\ ]?[\d]{4})?$/; re.lastIndex = " + +s.lastIndexOf("0") +1, +s, +0, +null); +*/ +test(); + +function AddRegExpCases( + regexp, str_regexp, string, str_string, index, matches_array ) { + + // prevent a runtime error + + if ( regexp.exec(string) == null || matches_array == null ) { + AddTestCase( + string + ".match(" + regexp +")", + matches_array, + string.match(regexp) ); + + return; + } + + AddTestCase( + "( " + string + " ).match(" + str_regexp +").length", + matches_array.length, + string.match(regexp).length ); + + AddTestCase( + "( " + string + " ).match(" + str_regexp +").index", + index, + string.match(regexp).index ); + + AddTestCase( + "( " + string + " ).match(" + str_regexp +").input", + str_string, + string.match(regexp).input ); + + var limit = matches_array.length > string.match(regexp).length ? + matches_array.length : + string.match(regexp).length; + + for ( var matches = 0; matches < limit; matches++ ) { + AddTestCase( + "( " + string + " ).match(" + str_regexp +")[" + matches +"]", + matches_array[matches], + string.match(regexp)[matches] ); + } +} + +function AddGlobalRegExpCases( + regexp, str_regexp, string, matches_array ) { + + // prevent a runtime error + + if ( regexp.exec(string) == null || matches_array == null ) { + AddTestCase( + regexp + ".exec(" + string +")", + matches_array, + regexp.exec(string) ); + + return; + } + + AddTestCase( + "( " + string + " ).match(" + str_regexp +").length", + matches_array.length, + string.match(regexp).length ); + + var limit = matches_array.length > string.match(regexp).length ? + matches_array.length : + string.match(regexp).length; + + for ( var matches = 0; matches < limit; matches++ ) { + AddTestCase( + "( " + string + " ).match(" + str_regexp +")[" + matches +"]", + matches_array[matches], + string.match(regexp)[matches] ); + } +} diff --git a/tests/auto/qml/parserstress/tests/ecma_2/String/replace-001.js b/tests/auto/qml/parserstress/tests/ecma_2/String/replace-001.js new file mode 100644 index 0000000000..f0ae3cdbfa --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma_2/String/replace-001.js @@ -0,0 +1,99 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is JavaScript Engine testing utilities. + * + * The Initial Developer of the Original Code is + * Netscape Communication Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = 'replace-001.js'; + +/** + * File Name: String/replace-001.js + * ECMA Section: 15.6.4.10 + * Description: Based on ECMA 2 Draft 7 February 1999 + * + * Author: christine@netscape.com + * Date: 19 February 1999 + */ + +var SECTION = "String/replace-001.js"; +var VERSION = "ECMA_2"; +var TITLE = "String.prototype.replace( regexp, replaceValue )"; + +startTest(); + +/* + * If regexp is not an object of type RegExp, it is replaced with the + * result of the expression new RegExp(regexp). Let string denote the + * result of converting the this value to a string. String is searched + * for the first occurrence of the regular expression pattern regexp if + * regexp.global is false, or all occurrences if regexp.global is true. + * + * The match is performed as in String.prototype.match, including the + * update of regexp.lastIndex. Let m be the number of matched + * parenthesized subexpressions as specified in section 15.7.5.3. + * + * If replaceValue is a function, then for each matched substring, call + * the function with the following m + 3 arguments. Argument 1 is the + * substring that matched. The next m arguments are all of the matched + * subexpressions. Argument m + 2 is the length of the left context, and + * argument m + 3 is string. + * + * The result is a string value derived from the original input by + * replacing each matched substring with the corresponding return value + * of the function call, converted to a string if need be. + * + * Otherwise, let newstring denote the result of converting replaceValue + * to a string. The result is a string value derived from the original + * input string by replacing each matched substring with a string derived + * from newstring by replacing characters in newstring by replacement text + * as specified in the following table: + * + * $& The matched substring. + * $‘ The portion of string that precedes the matched substring. + * $’ The portion of string that follows the matched substring. + * $+ The substring matched by the last parenthesized subexpressions in + * the regular expression. + * $n The corresponding matched parenthesized subexpression n, where n + * is a single digit 0-9. If there are fewer than n subexpressions, “$n + * is left unchanged. + * + * Note that the replace function is intentionally generic; it does not + * require that its this value be a string object. Therefore, it can be + * transferred to other kinds of objects for use as a method. + */ + + +AddTestCase( "NO TESTS EXIST", "PASSED", "Test not implemented"); + +test(); diff --git a/tests/auto/qml/parserstress/tests/ecma_2/String/shell.js b/tests/auto/qml/parserstress/tests/ecma_2/String/shell.js new file mode 100644 index 0000000000..7d850446cc --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma_2/String/shell.js @@ -0,0 +1 @@ +gTestsubsuite = 'String'; diff --git a/tests/auto/qml/parserstress/tests/ecma_2/String/split-001.js b/tests/auto/qml/parserstress/tests/ecma_2/String/split-001.js new file mode 100644 index 0000000000..bbab3b0428 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma_2/String/split-001.js @@ -0,0 +1,145 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is JavaScript Engine testing utilities. + * + * The Initial Developer of the Original Code is + * Netscape Communication Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = 'split-001.js'; + +/** + * File Name: String/split-001.js + * ECMA Section: 15.6.4.9 + * Description: Based on ECMA 2 Draft 7 February 1999 + * + * Author: christine@netscape.com + * Date: 19 February 1999 + */ + +/* + * Since regular expressions have been part of JavaScript since 1.2, there + * are already tests for regular expressions in the js1_2/regexp folder. + * + * These new tests try to supplement the existing tests, and verify that + * our implementation of RegExp conforms to the ECMA specification, but + * does not try to be as exhaustive as in previous tests. + * + * The [,limit] argument to String.split is new, and not covered in any + * existing tests. + * + * String.split cases are covered in ecma/String/15.5.4.8-*.js. + * String.split where separator is a RegExp are in + * js1_2/regexp/string_split.js + * + */ + +var SECTION = "ecma_2/String/split-001.js"; +var VERSION = "ECMA_2"; +var TITLE = "String.prototype.split( regexp, [,limit] )"; + +startTest(); + +// the separator is not supplied +// separator is undefined +// separator is an empty string + +AddSplitCases( "splitme", "", "''", ["s", "p", "l", "i", "t", "m", "e"] ); +AddSplitCases( "splitme", new RegExp(), "new RegExp()", ["s", "p", "l", "i", "t", "m", "e"] ); + +// separartor is a regexp +// separator regexp value global setting is set +// string is an empty string +// if separator is an empty string, split each by character + +// this is not a String object + +// limit is not a number +// limit is undefined +// limit is larger than 2^32-1 +// limit is a negative number + +test(); + +function AddSplitCases( string, separator, str_sep, split_array ) { + + // verify that the result of split is an object of type Array + AddTestCase( + "( " + string + " ).split(" + str_sep +").constructor == Array", + true, + string.split(separator).constructor == Array ); + + // check the number of items in the array + AddTestCase( + "( " + string + " ).split(" + str_sep +").length", + split_array.length, + string.split(separator).length ); + + // check the value of each array item + var limit = (split_array.length > string.split(separator).length ) + ? split_array.length : string.split(separator).length; + + for ( var matches = 0; matches < split_array.length; matches++ ) { + AddTestCase( + "( " + string + " ).split(" + str_sep +")[" + matches +"]", + split_array[matches], + string.split( separator )[matches] ); + } +} + +function AddLimitedSplitCases( + string, separator, str_sep, limit, str_limit, split_array ) { + + // verify that the result of split is an object of type Array + + AddTestCase( + "( " + string + " ).split(" + str_sep +", " + str_limit + + " ).constructor == Array", + true, + string.split(separator, limit).constructor == Array ); + + // check the length of the array + + AddTestCase( + "( " + string + " ).split(" + str_sep +", " + str_limit + " ).length", + length, + string.split(separator).length ); + + // check the value of each array item + + for ( var matches = 0; matches < split_array.length; matches++ ) { + AddTestCase( + "( " + string + " ).split(" + str_sep +", " + str_limit + " )[" + matches +"]", + split_array[matches], + string.split( separator )[matches] ); + } +} diff --git a/tests/auto/qml/parserstress/tests/ecma_2/String/split-002.js b/tests/auto/qml/parserstress/tests/ecma_2/String/split-002.js new file mode 100644 index 0000000000..9ae000790e --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma_2/String/split-002.js @@ -0,0 +1,303 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is JavaScript Engine testing utilities. + * + * The Initial Developer of the Original Code is + * Netscape Communication Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = 'split-002.js'; + +/** + * File Name: String/split-002.js + * ECMA Section: 15.6.4.9 + * Description: Based on ECMA 2 Draft 7 February 1999 + * + * Author: christine@netscape.com + * Date: 19 February 1999 + */ + +/* + * Since regular expressions have been part of JavaScript since 1.2, there + * are already tests for regular expressions in the js1_2/regexp folder. + * + * These new tests try to supplement the existing tests, and verify that + * our implementation of RegExp conforms to the ECMA specification, but + * does not try to be as exhaustive as in previous tests. + * + * The [,limit] argument to String.split is new, and not covered in any + * existing tests. + * + * String.split cases are covered in ecma/String/15.5.4.8-*.js. + * String.split where separator is a RegExp are in + * js1_2/regexp/string_split.js + * + */ + +var SECTION = "ecma_2/String/split-002.js"; +var VERSION = "ECMA_2"; +var TITLE = "String.prototype.split( regexp, [,limit] )"; + +startTest(); + +// the separator is not supplied +// separator is undefined +// separator is an empty string + +// AddSplitCases( "splitme", "", "''", ["s", "p", "l", "i", "t", "m", "e"] ); +// AddSplitCases( "splitme", new RegExp(), "new RegExp()", ["s", "p", "l", "i", "t", "m", "e"] ); + +// separator is an empty regexp +// separator is not supplied + +CompareSplit( "hello", "ll" ); + +CompareSplit( "hello", "l" ); +CompareSplit( "hello", "x" ); +CompareSplit( "hello", "h" ); +CompareSplit( "hello", "o" ); +CompareSplit( "hello", "hello" ); +CompareSplit( "hello", undefined ); + +CompareSplit( "hello", ""); +CompareSplit( "hello", "hellothere" ); + +CompareSplit( new String("hello" ) ); + + +Number.prototype.split = String.prototype.split; + +CompareSplit( new Number(100111122133144155), 1 ); +CompareSplitWithLimit(new Number(100111122133144155), 1, 1 ); + +CompareSplitWithLimit(new Number(100111122133144155), 1, 2 ); +CompareSplitWithLimit(new Number(100111122133144155), 1, 0 ); +CompareSplitWithLimit(new Number(100111122133144155), 1, 100 ); +CompareSplitWithLimit(new Number(100111122133144155), 1, void 0 ); +CompareSplitWithLimit(new Number(100111122133144155), 1, Math.pow(2,32)-1 ); +CompareSplitWithLimit(new Number(100111122133144155), 1, "boo" ); +CompareSplitWithLimit(new Number(100111122133144155), 1, -(Math.pow(2,32)-1) ); +CompareSplitWithLimit( "hello", "l", NaN ); +CompareSplitWithLimit( "hello", "l", 0 ); +CompareSplitWithLimit( "hello", "l", 1 ); +CompareSplitWithLimit( "hello", "l", 2 ); +CompareSplitWithLimit( "hello", "l", 3 ); +CompareSplitWithLimit( "hello", "l", 4 ); + + +/* + CompareSplitWithLimit( "hello", "ll", 0 ); + CompareSplitWithLimit( "hello", "ll", 1 ); + CompareSplitWithLimit( "hello", "ll", 2 ); + CompareSplit( "", " " ); + CompareSplit( "" ); +*/ + +// separartor is a regexp +// separator regexp value global setting is set +// string is an empty string +// if separator is an empty string, split each by character + +// this is not a String object + +// limit is not a number +// limit is undefined +// limit is larger than 2^32-1 +// limit is a negative number + +test(); + +function CompareSplit( string, separator ) { + split_1 = string.split( separator ); + split_2 = string_split( string, separator ); + + AddTestCase( + "( " + string +".split(" + separator + ") ).length" , + split_2.length, + split_1.length ); + + var limit = split_1.length > split_2.length ? + split_1.length : split_2.length; + + for ( var split_item = 0; split_item < limit; split_item++ ) { + AddTestCase( + string + ".split(" + separator + ")["+split_item+"]", + split_2[split_item], + split_1[split_item] ); + } +} + +function CompareSplitWithLimit( string, separator, splitlimit ) { + split_1 = string.split( separator, splitlimit ); + split_2 = string_split( string, separator, splitlimit ); + + AddTestCase( + "( " + string +".split(" + separator + ", " + splitlimit+") ).length" , + split_2.length, + split_1.length ); + + var limit = split_1.length > split_2.length ? + split_1.length : split_2.length; + + for ( var split_item = 0; split_item < limit; split_item++ ) { + AddTestCase( + string + ".split(" + separator + ", " + splitlimit+")["+split_item+"]", + split_2[split_item], + split_1[split_item] ); + } +} + +function string_split ( __this, separator, limit ) { + var S = String(__this ); // 1 + + var A = new Array(); // 2 + + if ( limit == undefined ) { // 3 + lim = Math.pow(2, 31 ) -1; + } else { + lim = ToUint32( limit ); + } + + var s = S.length; // 4 + var p = 0; // 5 + + if ( separator == undefined ) { // 8 + A[0] = S; + return A; + } + + if ( separator.constructor == RegExp ) // 6 + R = separator; + else + R = separator.toString(); + + if (lim == 0) return A; // 7 + + if ( separator == undefined ) { // 8 + A[0] = S; + return A; + } + + if (s == 0) { // 9 + z = SplitMatch(R, S, 0); + if (z != false) return A; + A[0] = S; + return A; + } + + var q = p; // 10 +loop: + while (true ) { + + if ( q == s ) break; // 11 + + z = SplitMatch(R, S, q); // 12 + +//print("Returned ", z); + + if (z != false) { // 13 + e = z.endIndex; // 14 + cap = z.captures; // 14 + if (e != p) { // 15 +//print("S = ", S, ", p = ", p, ", q = ", q); + T = S.slice(p, q); // 16 +//print("T = ", T); + A[A.length] = T; // 17 + if (A.length == lim) return A; // 18 + p = e; // 19 + i = 0; // 20 + while (true) { // 25 + if (i == cap.length) { // 21 + q = p; // 10 + continue loop; + } + i = i + 1; // 22 + A[A.length] = cap[i] // 23 + if (A.length == lim) return A; // 24 + } + } + } + + q = q + 1; // 26 + } + + T = S.slice(p, q); + A[A.length] = T; + return A; +} + +function SplitMatch(R, S, q) +{ + if (R.constructor == RegExp) { // 1 + var reResult = R.match(S, q); // 8 + if (reResult == undefined) + return false; + else { + a = new Array(reResult.length - 1); + for (var i = 1; i < reResult.length; i++) + a[a.length] = reResult[i]; + return { endIndex : reResult.index + reResult[0].length, captures : cap }; + } + } + else { + var r = R.length; // 2 + s = S.length; // 3 + if ((q + r) > s) return false; // 4 + for (var i = 0; i < r; i++) { +//print("S.charAt(", q + i, ") = ", S.charAt(q + i), ", R.charAt(", i, ") = ", R.charAt(i)); + if (S.charAt(q + i) != R.charAt(i)) // 5 + return false; + } + cap = new Array(); // 6 + return { endIndex : q + r, captures : cap }; // 7 + } +} + +function ToUint32( n ) { + n = Number( n ); + var sign = ( n < 0 ) ? -1 : 1; + + if ( Math.abs( n ) == 0 + || Math.abs( n ) == Number.POSITIVE_INFINITY + || n != n) { + return 0; + } + n = sign * Math.floor( Math.abs(n) ) + + n = n % Math.pow(2,32); + + if ( n < 0 ){ + n += Math.pow(2,32); + } + + return ( n ); +} diff --git a/tests/auto/qml/parserstress/tests/ecma_2/String/split-003.js b/tests/auto/qml/parserstress/tests/ecma_2/String/split-003.js new file mode 100644 index 0000000000..5029fc98f9 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma_2/String/split-003.js @@ -0,0 +1,156 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is JavaScript Engine testing utilities. + * + * The Initial Developer of the Original Code is + * Netscape Communication Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = 'split-003.js'; + +/** + * File Name: String/split-003.js + * ECMA Section: 15.6.4.9 + * Description: Based on ECMA 2 Draft 7 February 1999 + * + * Author: christine@netscape.com + * Date: 19 February 1999 + */ + +/* + * Since regular expressions have been part of JavaScript since 1.2, there + * are already tests for regular expressions in the js1_2/regexp folder. + * + * These new tests try to supplement the existing tests, and verify that + * our implementation of RegExp conforms to the ECMA specification, but + * does not try to be as exhaustive as in previous tests. + * + * The [,limit] argument to String.split is new, and not covered in any + * existing tests. + * + * String.split cases are covered in ecma/String/15.5.4.8-*.js. + * String.split where separator is a RegExp are in + * js1_2/regexp/string_split.js + * + */ + +var SECTION = "ecma_2/String/split-003.js"; +var VERSION = "ECMA_2"; +var TITLE = "String.prototype.split( regexp, [,limit] )"; + +startTest(); + +// separator is a regexp +// separator regexp value global setting is set +// string is an empty string +// if separator is an empty string, split each by character + + +AddSplitCases( "hello", new RegExp, "new RegExp", ["h","e","l","l","o"] ); + +AddSplitCases( "hello", /l/, "/l/", ["he","","o"] ); +AddLimitedSplitCases( "hello", /l/, "/l/", 0, [] ); +AddLimitedSplitCases( "hello", /l/, "/l/", 1, ["he"] ); +AddLimitedSplitCases( "hello", /l/, "/l/", 2, ["he",""] ); +AddLimitedSplitCases( "hello", /l/, "/l/", 3, ["he","","o"] ); +AddLimitedSplitCases( "hello", /l/, "/l/", 4, ["he","","o"] ); +AddLimitedSplitCases( "hello", /l/, "/l/", void 0, ["he","","o"] ); +AddLimitedSplitCases( "hello", /l/, "/l/", "hi", [] ); +AddLimitedSplitCases( "hello", /l/, "/l/", undefined, ["he","","o"] ); + +AddSplitCases( "hello", new RegExp, "new RegExp", ["h","e","l","l","o"] ); +AddLimitedSplitCases( "hello", new RegExp, "new RegExp", 0, [] ); +AddLimitedSplitCases( "hello", new RegExp, "new RegExp", 1, ["h"] ); +AddLimitedSplitCases( "hello", new RegExp, "new RegExp", 2, ["h","e"] ); +AddLimitedSplitCases( "hello", new RegExp, "new RegExp", 3, ["h","e","l"] ); +AddLimitedSplitCases( "hello", new RegExp, "new RegExp", 4, ["h","e","l","l"] ); +AddLimitedSplitCases( "hello", new RegExp, "new RegExp", void 0, ["h","e","l","l","o"] ); +AddLimitedSplitCases( "hello", new RegExp, "new RegExp", "hi", [] ); +AddLimitedSplitCases( "hello", new RegExp, "new RegExp", undefined, ["h","e","l","l","o"] ); + +test(); + +function AddSplitCases( string, separator, str_sep, split_array ) { + // verify that the result of split is an object of type Array + AddTestCase( + "( " + string + " ).split(" + str_sep +").constructor == Array", + true, + string.split(separator).constructor == Array ); + + // check the number of items in the array + AddTestCase( + "( " + string + " ).split(" + str_sep +").length", + split_array.length, + string.split(separator).length ); + + // check the value of each array item + var limit = (split_array.length > string.split(separator).length ) + ? split_array.length : string.split(separator).length; + + for ( var matches = 0; matches < split_array.length; matches++ ) { + AddTestCase( + "( " + string + " ).split(" + str_sep +")[" + matches +"]", + split_array[matches], + string.split( separator )[matches] ); + } +} + +function AddLimitedSplitCases( + string, separator, str_sep, limit, split_array ) { + + // verify that the result of split is an object of type Array + + AddTestCase( + "( " + string + " ).split(" + str_sep +", " + limit + + " ).constructor == Array", + true, + string.split(separator, limit).constructor == Array ); + + // check the length of the array + + AddTestCase( + "( " + string + " ).split(" + str_sep +", " + limit + " ).length", + split_array.length, + string.split(separator, limit).length ); + + // check the value of each array item + + var slimit = (split_array.length > string.split(separator).length ) + ? split_array.length : string.split(separator, limit).length; + + for ( var matches = 0; matches < slimit; matches++ ) { + AddTestCase( + "( " + string + " ).split(" + str_sep +", " + limit + " )[" + matches +"]", + split_array[matches], + string.split( separator, limit )[matches] ); + } +} diff --git a/tests/auto/qml/parserstress/tests/ecma_2/browser.js b/tests/auto/qml/parserstress/tests/ecma_2/browser.js new file mode 100644 index 0000000000..4cde9b0629 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma_2/browser.js @@ -0,0 +1,37 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is mozilla.org code. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + diff --git a/tests/auto/qml/parserstress/tests/ecma_2/extensions/browser.js b/tests/auto/qml/parserstress/tests/ecma_2/extensions/browser.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/auto/qml/parserstress/tests/ecma_2/extensions/constructor-001.js b/tests/auto/qml/parserstress/tests/ecma_2/extensions/constructor-001.js new file mode 100755 index 0000000000..cc7907d006 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma_2/extensions/constructor-001.js @@ -0,0 +1,74 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is JavaScript Engine testing utilities. + * + * The Initial Developer of the Original Code is + * Netscape Communication Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = 'constructor-001.js'; + +/** + * File Name: RegExp/constructor-001.js + * ECMA Section: 15.7.3.3 + * Description: Based on ECMA 2 Draft 7 February 1999 + * + * Author: christine@netscape.com + * Date: 19 February 1999 + */ +var SECTION = "RegExp/constructor-001"; +var VERSION = "ECMA_2"; +var TITLE = "new RegExp()"; + +startTest(); + +/* + * for each test case, verify: + * - verify that [[Class]] property is RegExp + * - prototype property should be set to RegExp.prototype + * - source is set to the empty string + * - global property is set to false + * - ignoreCase property is set to false + * - multiline property is set to false + * - lastIndex property is set to 0 + */ + +RegExp.prototype.getClassProperty = Object.prototype.toString; +var re = new RegExp(); + +AddTestCase( + "new RegExp().__proto__", + RegExp.prototype, + re.__proto__ + ); + +test() diff --git a/tests/auto/qml/parserstress/tests/ecma_2/extensions/function-001.js b/tests/auto/qml/parserstress/tests/ecma_2/extensions/function-001.js new file mode 100755 index 0000000000..5153d25f9d --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma_2/extensions/function-001.js @@ -0,0 +1,74 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is JavaScript Engine testing utilities. + * + * The Initial Developer of the Original Code is + * Netscape Communication Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = 'function-001.js'; + +/** + * File Name: RegExp/function-001.js + * ECMA Section: 15.7.2.1 + * Description: Based on ECMA 2 Draft 7 February 1999 + * + * Author: christine@netscape.com + * Date: 19 February 1999 + */ +var SECTION = "RegExp/function-001"; +var VERSION = "ECMA_2"; +var TITLE = "RegExp( pattern, flags )"; + +startTest(); + +/* + * for each test case, verify: + * - verify that [[Class]] property is RegExp + * - prototype property should be set to RegExp.prototype + * - source is set to the empty string + * - global property is set to false + * - ignoreCase property is set to false + * - multiline property is set to false + * - lastIndex property is set to 0 + */ + +RegExp.prototype.getClassProperty = Object.prototype.toString; +var re = new RegExp(); + +AddTestCase( + "new RegExp().__proto__", + RegExp.prototype, + re.__proto__ + ); + +test() diff --git a/tests/auto/qml/parserstress/tests/ecma_2/extensions/instanceof-001.js b/tests/auto/qml/parserstress/tests/ecma_2/extensions/instanceof-001.js new file mode 100755 index 0000000000..8ea446a248 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma_2/extensions/instanceof-001.js @@ -0,0 +1,144 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is JavaScript Engine testing utilities. + * + * The Initial Developer of the Original Code is + * Netscape Communication Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = 'instanceof-001.js'; + +/** + * File Name: instanceof-001.js + * ECMA Section: 11.8.6 + * Description: + * + * RelationalExpression instanceof Identifier + * + * Author: christine@netscape.com + * Date: 2 September 1998 + */ +var SECTION = "instanceof-001"; +var VERSION = "ECMA_2"; +var TITLE = "instanceof" + + startTest(); +writeHeaderToLog( SECTION + " "+ TITLE); + +function InstanceOf( object_1, object_2, expect ) { + result = object_1 instanceof object_2; + + new TestCase( + SECTION, + "(" + object_1 + ") instanceof " + object_2, + expect, + result ); +} + +function Gen3(value) { + this.value = value; + this.generation = 3; + this.toString = new Function ( "return \"(Gen\"+this.generation+\" instance)\"" ); +} +Gen3.name = 3; +Gen3.__proto__.toString = new Function( "return \"(\"+this.name+\" object)\""); + +function Gen2(value) { + this.value = value; + this.generation = 2; +} +Gen2.name = 2; +Gen2.prototype = new Gen3(); + +function Gen1(value) { + this.value = value; + this.generation = 1; +} +Gen1.name = 1; +Gen1.prototype = new Gen2(); + +function Gen0(value) { + this.value = value; + this.generation = 0; +} +Gen0.name = 0; +Gen0.prototype = new Gen1(); + + +function GenA(value) { + this.value = value; + this.generation = "A"; + this.toString = new Function ( "return \"(instance of Gen\"+this.generation+\")\"" ); + +} +GenA.prototype = new Gen0(); +GenA.name = "A"; + +function GenB(value) { + this.value = value; + this.generation = "B"; + this.toString = new Function ( "return \"(instance of Gen\"+this.generation+\")\"" ); +} +GenB.name = "B" + GenB.prototype = void 0; + +// RelationalExpression is not an object. + +InstanceOf( true, Boolean, false ); +InstanceOf( new Boolean(false), Boolean, true ); + +// __proto__ of RelationalExpression is null. should return false +genA = new GenA(); +genA.__proto__ = null; + +InstanceOf( genA, GenA, false ); + +// RelationalExpression.__proto__ == (but not ===) Identifier.prototype + +InstanceOf( new Gen2(), Gen0, false ); +InstanceOf( new Gen2(), Gen1, false ); +InstanceOf( new Gen2(), Gen2, true ); +InstanceOf( new Gen2(), Gen3, true ); + +// RelationalExpression.__proto__.__proto__ === Identifier.prototype +InstanceOf( new Gen0(), Gen0, true ); +InstanceOf( new Gen0(), Gen1, true ); +InstanceOf( new Gen0(), Gen2, true ); +InstanceOf( new Gen0(), Gen3, true ); + +InstanceOf( new Gen0(), Object, true ); +InstanceOf( new Gen0(), Function, false ); + +InstanceOf( Gen0, Function, true ); +InstanceOf( Gen0, Object, true ); + +test(); diff --git a/tests/auto/qml/parserstress/tests/ecma_2/extensions/instanceof-002.js b/tests/auto/qml/parserstress/tests/ecma_2/extensions/instanceof-002.js new file mode 100755 index 0000000000..9cc837d8ef --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma_2/extensions/instanceof-002.js @@ -0,0 +1,160 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is JavaScript Engine testing utilities. + * + * The Initial Developer of the Original Code is + * Netscape Communication Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = 'instanceof-002.js'; + +/** + File Name: instanceof-002.js + Section: + Description: Determining Instance Relationships + + This test is the same as js1_3/inherit/proto-002, except that it uses + the builtin instanceof operator rather than a user-defined function + called InstanceOf. + + This tests Object Hierarchy and Inheritance, as described in the document + Object Hierarchy and Inheritance in JavaScript, last modified on 12/18/97 + 15:19:34 on http://devedge.netscape.com/. Current URL: + http://devedge.netscape.com/docs/manuals/communicator/jsobj/contents.htm + + This tests the syntax ObjectName.prototype = new PrototypeObject using the + Employee example in the document referenced above. + + Author: christine@netscape.com + Date: 12 november 1997 +*/ +// onerror = err; + +var SECTION = "instanceof-002"; +var VERSION = "ECMA_2"; +var TITLE = "Determining Instance Relationships"; + +startTest(); +writeHeaderToLog( SECTION + " "+ TITLE); + +function InstanceOf( object, constructor ) { + while ( object != null ) { + if ( object == constructor.prototype ) { + return true; + } + object = object.__proto__; + } + return false; +} + +function Employee ( name, dept ) { + this.name = name || ""; + this.dept = dept || "general"; +} + +function Manager () { + this.reports = []; +} +Manager.prototype = new Employee(); + +function WorkerBee ( name, dept, projs ) { + this.base = Employee; + this.base( name, dept) + this.projects = projs || new Array(); +} +WorkerBee.prototype = new Employee(); + +function SalesPerson () { + this.dept = "sales"; + this.quota = 100; +} +SalesPerson.prototype = new WorkerBee(); + +function Engineer ( name, projs, machine ) { + this.base = WorkerBee; + this.base( name, "engineering", projs ) + this.machine = machine || ""; +} +Engineer.prototype = new WorkerBee(); + +var pat = new Engineer(); + +new TestCase( SECTION, + "pat.__proto__ == Engineer.prototype", + true, + pat.__proto__ == Engineer.prototype ); + +new TestCase( SECTION, + "pat.__proto__.__proto__ == WorkerBee.prototype", + true, + pat.__proto__.__proto__ == WorkerBee.prototype ); + +new TestCase( SECTION, + "pat.__proto__.__proto__.__proto__ == Employee.prototype", + true, + pat.__proto__.__proto__.__proto__ == Employee.prototype ); + +new TestCase( SECTION, + "pat.__proto__.__proto__.__proto__.__proto__ == Object.prototype", + true, + pat.__proto__.__proto__.__proto__.__proto__ == Object.prototype ); + +new TestCase( SECTION, + "pat.__proto__.__proto__.__proto__.__proto__.__proto__ == null", + true, + pat.__proto__.__proto__.__proto__.__proto__.__proto__ == null ); + +new TestCase( SECTION, + "pat instanceof Engineer", + true, + pat instanceof Engineer ); + +new TestCase( SECTION, + "pat instanceof WorkerBee )", + true, + pat instanceof WorkerBee ); + +new TestCase( SECTION, + "pat instanceof Employee )", + true, + pat instanceof Employee ); + +new TestCase( SECTION, + "pat instanceof Object )", + true, + pat instanceof Object ); + +new TestCase( SECTION, + "pat instanceof SalesPerson )", + false, + pat instanceof SalesPerson ); +test(); diff --git a/tests/auto/qml/parserstress/tests/ecma_2/extensions/instanceof-003-n.js b/tests/auto/qml/parserstress/tests/ecma_2/extensions/instanceof-003-n.js new file mode 100755 index 0000000000..7a763a895c --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma_2/extensions/instanceof-003-n.js @@ -0,0 +1,121 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is JavaScript Engine testing utilities. + * + * The Initial Developer of the Original Code is + * Netscape Communication Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = 'instanceof-003-n.js'; + +/** + * File Name: instanceof-001.js + * ECMA Section: 11.8.6 + * Description: + * + * RelationalExpression instanceof Identifier + * + * Author: christine@netscape.com + * Date: 2 September 1998 + */ +var SECTION = "instanceof-003-n"; +var VERSION = "ECMA_2"; +var TITLE = "instanceof" + + startTest(); +writeHeaderToLog( SECTION + " "+ TITLE); + +function InstanceOf( object_1, object_2, expect ) { + + result = object_1 instanceof object_2; + + new TestCase( + SECTION, + "(" + object_1 + ") instanceof " + object_2, + expect, + result ); +} + +function Gen3(value) { + this.value = value; + this.generation = 3; + this.toString = new Function ( "return \"(Gen\"+this.generation+\" instance)\"" ); +} +Gen3.name = 3; +Gen3.__proto__.toString = new Function( "return \"(\"+this.name+\" object)\""); + +function Gen2(value) { + this.value = value; + this.generation = 2; +} +Gen2.name = 2; +Gen2.prototype = new Gen3(); + +function Gen1(value) { + this.value = value; + this.generation = 1; +} +Gen1.name = 1; +Gen1.prototype = new Gen2(); + +function Gen0(value) { + this.value = value; + this.generation = 0; +} +Gen0.name = 0; +Gen0.prototype = new Gen1(); + + +function GenA(value) { + this.value = value; + this.generation = "A"; + this.toString = new Function ( "return \"(instance of Gen\"+this.generation+\")\"" ); + +} +GenA.prototype = new Gen0(); +GenA.name = "A"; + +function GenB(value) { + this.value = value; + this.generation = "B"; + this.toString = new Function ( "return \"(instance of Gen\"+this.generation+\")\"" ); +} +GenB.name = "B" + GenB.prototype = void 0; + +// Identifier is not a function +DESCRIPTION = "Identifier is not a function"; +EXPECTED = "error"; + +InstanceOf( true, true, "error" ); + +test(); diff --git a/tests/auto/qml/parserstress/tests/ecma_2/extensions/instanceof-004-n.js b/tests/auto/qml/parserstress/tests/ecma_2/extensions/instanceof-004-n.js new file mode 100755 index 0000000000..1662ae566b --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma_2/extensions/instanceof-004-n.js @@ -0,0 +1,121 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is JavaScript Engine testing utilities. + * + * The Initial Developer of the Original Code is + * Netscape Communication Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = 'instanceof-004-n.js'; + +/** + * File Name: instanceof-001.js + * ECMA Section: 11.8.6 + * Description: + * + * RelationalExpression instanceof Identifier + * + * Author: christine@netscape.com + * Date: 2 September 1998 + */ +var SECTION = "instanceof-004-n"; +var VERSION = "ECMA_2"; +var TITLE = "instanceof" + + startTest(); +writeHeaderToLog( SECTION + " "+ TITLE); + +function InstanceOf( object_1, object_2, expect ) { + result = object_1 instanceof object_2; + + new TestCase( + SECTION, + "(" + object_1 + ") instanceof " + object_2, + expect, + result ); +} + +function Gen3(value) { + this.value = value; + this.generation = 3; + this.toString = new Function ( "return \"(Gen\"+this.generation+\" instance)\"" ); +} +Gen3.name = 3; +Gen3.__proto__.toString = new Function( "return \"(\"+this.name+\" object)\""); + +function Gen2(value) { + this.value = value; + this.generation = 2; +} +Gen2.name = 2; +Gen2.prototype = new Gen3(); + +function Gen1(value) { + this.value = value; + this.generation = 1; +} +Gen1.name = 1; +Gen1.prototype = new Gen2(); + +function Gen0(value) { + this.value = value; + this.generation = 0; +} +Gen0.name = 0; +Gen0.prototype = new Gen1(); + + +function GenA(value) { + this.value = value; + this.generation = "A"; + this.toString = new Function ( "return \"(instance of Gen\"+this.generation+\")\"" ); + +} +GenA.prototype = new Gen0(); +GenA.name = "A"; + +function GenB(value) { + this.value = value; + this.generation = "B"; + this.toString = new Function ( "return \"(instance of Gen\"+this.generation+\")\"" ); +} +GenB.name = "B" + GenB.prototype = void 0; + +// Identifier is not a function + +DESCRIPTION = "Identifier is not a function"; +EXPECTED = "error"; + +InstanceOf( new Boolean(true), false, "error" ); + +test(); diff --git a/tests/auto/qml/parserstress/tests/ecma_2/extensions/instanceof-005-n.js b/tests/auto/qml/parserstress/tests/ecma_2/extensions/instanceof-005-n.js new file mode 100755 index 0000000000..1a9b1b3437 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma_2/extensions/instanceof-005-n.js @@ -0,0 +1,122 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is JavaScript Engine testing utilities. + * + * The Initial Developer of the Original Code is + * Netscape Communication Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = 'instanceof-005-n.js'; + +/** + * File Name: instanceof-001.js + * ECMA Section: 11.8.6 + * Description: + * + * RelationalExpression instanceof Identifier + * + * Author: christine@netscape.com + * Date: 2 September 1998 + */ +var SECTION = "instanceof-005-n"; +var VERSION = "ECMA_2"; +var TITLE = "instanceof" + + startTest(); +writeHeaderToLog( SECTION + " "+ TITLE); + +function InstanceOf( object_1, object_2, expect ) { + result = object_1 instanceof object_2; + + new TestCase( + SECTION, + "(" + object_1 + ") instanceof " + object_2, + expect, + result ); +} + +function Gen3(value) { + this.value = value; + this.generation = 3; + this.toString = new Function ( "return \"(Gen\"+this.generation+\" instance)\"" ); +} +Gen3.name = 3; +Gen3.__proto__.toString = new Function( "return \"(\"+this.name+\" object)\""); + +function Gen2(value) { + this.value = value; + this.generation = 2; +} +Gen2.name = 2; +Gen2.prototype = new Gen3(); + +function Gen1(value) { + this.value = value; + this.generation = 1; +} +Gen1.name = 1; +Gen1.prototype = new Gen2(); + +function Gen0(value) { + this.value = value; + this.generation = 0; +} +Gen0.name = 0; +Gen0.prototype = new Gen1(); + + +function GenA(value) { + this.value = value; + this.generation = "A"; + this.toString = new Function ( "return \"(instance of Gen\"+this.generation+\")\"" ); + +} +GenA.prototype = new Gen0(); +GenA.name = "A"; + +function GenB(value) { + this.value = value; + this.generation = "B"; + this.toString = new Function ( "return \"(instance of Gen\"+this.generation+\")\"" ); +} +GenB.name = "B" + GenB.prototype = void 0; + + +// Identifier is a function, prototype of Identifier is not an object + +DESCRIPTION = "Identifier is a function, prototype of Identifier is not an object"; +EXPECTED = "error"; + +InstanceOf( new GenB(), GenB, "error" ); + +test(); diff --git a/tests/auto/qml/parserstress/tests/ecma_2/extensions/instanceof-006.js b/tests/auto/qml/parserstress/tests/ecma_2/extensions/instanceof-006.js new file mode 100755 index 0000000000..03c0f16fb9 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma_2/extensions/instanceof-006.js @@ -0,0 +1,119 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is JavaScript Engine testing utilities. + * + * The Initial Developer of the Original Code is + * Netscape Communication Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = 'instanceof-006.js'; + +/** + * File Name: instanceof-001.js + * ECMA Section: 11.8.6 + * Description: + * + * RelationalExpression instanceof Identifier + * + * Author: christine@netscape.com + * Date: 2 September 1998 + */ +var SECTION = "instanceof-001"; +var VERSION = "ECMA_2"; +var TITLE = "instanceof" + + startTest(); +writeHeaderToLog( SECTION + " "+ TITLE); + +function InstanceOf( object_1, object_2, expect ) { + result = object_1 instanceof object_2; + + new TestCase( + SECTION, + "(" + object_1 + ") instanceof " + object_2, + expect, + result ); +} + +function Gen3(value) { + this.value = value; + this.generation = 3; + this.toString = new Function ( "return \"(Gen\"+this.generation+\" instance)\"" ); +} +Gen3.name = 3; +Gen3.__proto__.toString = new Function( "return \"(\"+this.name+\" object)\""); + +function Gen2(value) { + this.value = value; + this.generation = 2; +} +Gen2.name = 2; +Gen2.prototype = new Gen3(); + +function Gen1(value) { + this.value = value; + this.generation = 1; +} +Gen1.name = 1; +Gen1.prototype = new Gen2(); + +function Gen0(value) { + this.value = value; + this.generation = 0; +} +Gen0.name = 0; +Gen0.prototype = new Gen1(); + + +function GenA(value) { + this.value = value; + this.generation = "A"; + this.toString = new Function ( "return \"(instance of Gen\"+this.generation+\")\"" ); + +} +GenA.prototype = new Gen0(); +GenA.name = "A"; + +function GenB(value) { + this.value = value; + this.generation = "B"; + this.toString = new Function ( "return \"(instance of Gen\"+this.generation+\")\"" ); +} +GenB.name = "B" + GenB.prototype = void 0; + +// RelationalExpression is not an object. + +// InstanceOf( true, Boolean, false ); +InstanceOf( new Boolean(false), Boolean, true ); + +test(); diff --git a/tests/auto/qml/parserstress/tests/ecma_2/extensions/shell.js b/tests/auto/qml/parserstress/tests/ecma_2/extensions/shell.js new file mode 100644 index 0000000000..3f52cffbc0 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma_2/extensions/shell.js @@ -0,0 +1 @@ +gTestsubsuite = 'extensions'; diff --git a/tests/auto/qml/parserstress/tests/ecma_2/instanceof/browser.js b/tests/auto/qml/parserstress/tests/ecma_2/instanceof/browser.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/auto/qml/parserstress/tests/ecma_2/instanceof/instanceof-001.js b/tests/auto/qml/parserstress/tests/ecma_2/instanceof/instanceof-001.js new file mode 100644 index 0000000000..39ae96fa5b --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma_2/instanceof/instanceof-001.js @@ -0,0 +1,67 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is JavaScript Engine testing utilities. + * + * The Initial Developer of the Original Code is + * Netscape Communication Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = 'instanceof-001.js'; + +/** + File Name: instanceof-1.js + ECMA Section: + Description: instanceof operator + + Author: christine@netscape.com + Date: 12 november 1997 +*/ +var SECTION = ""; +var VERSION = "ECMA_2"; +var TITLE = "instanceof operator"; + +startTest(); +writeHeaderToLog( SECTION + " "+ TITLE); + +var b = new Boolean(); + +new TestCase( SECTION, + "var b = new Boolean(); b instanceof Boolean", + true, + b instanceof Boolean ); + +new TestCase( SECTION, + "b instanceof Object", + true, + b instanceof Object ); + +test(); diff --git a/tests/auto/qml/parserstress/tests/ecma_2/instanceof/instanceof-002.js b/tests/auto/qml/parserstress/tests/ecma_2/instanceof/instanceof-002.js new file mode 100644 index 0000000000..c35fcb0486 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma_2/instanceof/instanceof-002.js @@ -0,0 +1,84 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is JavaScript Engine testing utilities. + * + * The Initial Developer of the Original Code is + * Netscape Communication Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = 'instanceof-002.js'; + +/** + File Name: + ECMA Section: + Description: Call Objects + + + + Author: christine@netscape.com + Date: 12 november 1997 +*/ +var SECTION = ""; +var VERSION = "ECMA_2"; +var TITLE = "The Call Constructor"; + +startTest(); +writeHeaderToLog( SECTION + " "+ TITLE); + +var b = new Boolean(); + +new TestCase( SECTION, + "var b = new Boolean(); b instanceof Boolean", + true, + b instanceof Boolean ); + +new TestCase( SECTION, + "b instanceof Object", + true, + b instanceof Object ); + +new TestCase( SECTION, + "b instanceof Array", + false, + b instanceof Array ); + +new TestCase( SECTION, + "true instanceof Boolean", + false, + true instanceof Boolean ); + +new TestCase( SECTION, + "Boolean instanceof Object", + true, + Boolean instanceof Object ); +test(); + diff --git a/tests/auto/qml/parserstress/tests/ecma_2/instanceof/instanceof-003.js b/tests/auto/qml/parserstress/tests/ecma_2/instanceof/instanceof-003.js new file mode 100644 index 0000000000..6c1279f865 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma_2/instanceof/instanceof-003.js @@ -0,0 +1,98 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is JavaScript Engine testing utilities. + * + * The Initial Developer of the Original Code is + * Netscape Communication Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = 'instanceof-003.js'; + +/** + File Name: instanceof-003.js + ECMA Section: + Description: http://bugzilla.mozilla.org/show_bug.cgi?id=7635 + + js> function Foo() {} + js> theproto = {}; + [object Object] + js> Foo.prototype = theproto + [object Object] + js> theproto instanceof Foo + true + + I think this should be 'false' + + + Author: christine@netscape.com + Date: 12 november 1997 + + Modified to conform to ECMA3 + https://bugzilla.mozilla.org/show_bug.cgi?id=281606 +*/ +var SECTION = "instanceof-003"; +var VERSION = "ECMA_2"; +var TITLE = "instanceof operator"; +var BUGNUMBER ="7635"; + +startTest(); + +function Foo() {}; +theproto = {}; +Foo.prototype = theproto; + +AddTestCase( + "function Foo() = {}; theproto = {}; Foo.prototype = theproto; " + + "theproto instanceof Foo", + false, + theproto instanceof Foo ); + + +var o = {}; + +// https://bugzilla.mozilla.org/show_bug.cgi?id=281606 +try +{ + AddTestCase( + "o = {}; o instanceof o", + "error", + o instanceof o ); +} +catch(e) +{ + AddTestCase( + "o = {}; o instanceof o", + "error", + "error" ); +} + +test(); diff --git a/tests/auto/qml/parserstress/tests/ecma_2/instanceof/regress-7635.js b/tests/auto/qml/parserstress/tests/ecma_2/instanceof/regress-7635.js new file mode 100644 index 0000000000..c643920b04 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma_2/instanceof/regress-7635.js @@ -0,0 +1,88 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is mozilla.org code. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = 'regress-7635.js'; + +/** + * File Name: regress-7635.js + * Reference: http://bugzilla.mozilla.org/show_bug.cgi?id=7635 + * Description: instanceof tweaks + * Author: + */ + +var SECTION = "instanceof"; // provide a document reference (ie, ECMA section) +var VERSION = "ECMA_2"; // Version of JavaScript or ECMA +var TITLE = "Regression test for Bugzilla #7635"; // Provide ECMA section title or a description +var BUGNUMBER = "7635"; // Provide URL to bugsplat or bugzilla report + +startTest(); // leave this alone + +/* + * Calls to AddTestCase here. AddTestCase is a function that is defined + * in shell.js and takes three arguments: + * - a string representation of what is being tested + * - the expected result + * - the actual result + * + * For example, a test might look like this: + * + * var zip = /[\d]{5}$/; + * + * AddTestCase( + * "zip = /[\d]{5}$/; \"PO Box 12345 Boston, MA 02134\".match(zip)", // description of the test + * "02134", // expected result + * "PO Box 12345 Boston, MA 02134".match(zip) ); // actual result + * + */ + +function Foo() {} +theproto = {}; +Foo.prototype = theproto + theproto instanceof Foo + + + AddTestCase( "function Foo() {}; theproto = {}; Foo.prototype = theproto; theproto instanceof Foo", + false, + theproto instanceof Foo ); + +var f = new Function(); + +AddTestCase( "var f = new Function(); f instanceof f", false, f instanceof f ); + + +test(); // leave this alone. this executes the test cases and +// displays results. diff --git a/tests/auto/qml/parserstress/tests/ecma_2/instanceof/shell.js b/tests/auto/qml/parserstress/tests/ecma_2/instanceof/shell.js new file mode 100644 index 0000000000..b390356c38 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma_2/instanceof/shell.js @@ -0,0 +1 @@ +gTestsubsuite = 'instanceof'; diff --git a/tests/auto/qml/parserstress/tests/ecma_2/jsref.js b/tests/auto/qml/parserstress/tests/ecma_2/jsref.js new file mode 100644 index 0000000000..e5a3ddfeed --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma_2/jsref.js @@ -0,0 +1,591 @@ +var completed = false; +var testcases; +var tc = 0; + +SECTION = ""; +VERSION = ""; +BUGNUMBER = ""; +EXCLUDE = ""; +BUGNUMBER = ""; + + +TZ_DIFF = -8; + +var TT = ""; +var TT_ = ""; +var BR = ""; +var NBSP = " "; +var CR = "\n"; +var FONT = ""; +var FONT_ = ""; +var FONT_RED = ""; +var FONT_GREEN = ""; +var B = ""; +var B_ = "" +var H2 = ""; +var H2_ = ""; +var HR = ""; +var DEBUG = false; + + +var PASSED = " PASSED!" +var FAILED = " FAILED! expected: "; +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} + +function TestCase( n, d, e, a ) { + this.name = n; + this.description = d; + this.expect = e; + this.actual = a; + this.passed = true; + this.reason = ""; + this.bugnumber = BUGNUMBER; + + this.passed = getTestCaseResult( this.expect, this.actual ); + if ( DEBUG ) { + print( "added " + this.description ); + } +} +function startTest() { + // JavaScript 1.3 is supposed to be compliant ecma version 1.0 + if ( VERSION == "ECMA_1" ) { + version ( "130" ); + } + if ( VERSION == "JS_13" ) { + version ( "130" ); + } + if ( VERSION == "JS_12" ) { + version ( "120" ); + } + if ( VERSION == "JS_11" ) { + version ( "110" ); + } + // for ecma version 2.0, we will leave the javascript version to + // the default ( for now ). + writeHeaderToLog( SECTION + " "+ TITLE); + testcases = new Array(); + tc = 0; + +} +function getTestCaseResult( expect, actual ) { + // because ( NaN == NaN ) always returns false, need to do + // a special compare to see if we got the right result. + if ( actual != actual ) { + if ( typeof actual == "object" ) { + actual = "NaN object"; + } else { + actual = "NaN number"; + } + } + if ( expect != expect ) { + if ( typeof expect == "object" ) { + expect = "NaN object"; + } else { + expect = "NaN number"; + } + } + + var passed = ( expect == actual ) ? true : false; + + // if both objects are numbers + // need to replace w/ IEEE standard for rounding + if ( !passed + && typeof(actual) == "number" + && typeof(expect) == "number" + ) { + if ( Math.abs(actual-expect) < 0.0000001 ) { + passed = true; + } + } + + // verify type is the same + if ( typeof(expect) != typeof(actual) ) { + passed = false; + } + + return passed; +} +function writeTestCaseResult( expect, actual, string ) { + var passed = getTestCaseResult( expect, actual ); + writeFormattedResult( expect, actual, string, passed ); + return passed; +} +function writeFormattedResult( expect, actual, string, passed ) { + var s = TT + string ; + + for ( k = 0; + k < (60 - string.length >= 0 ? 60 - string.length : 5) ; + k++ ) { + } + + s += B ; + s += ( passed ) ? FONT_GREEN + NBSP + PASSED : FONT_RED + NBSP + FAILED + expect + TT_ ; + + print( s + FONT_ + B_ + TT_ ); + + return passed; +} + +function writeHeaderToLog( string ) { + print( H2 + string + H2_ ); +} +function stopTest() +{ + var sizeTag = "<#TEST CASES SIZE>"; + var doneTag = "<#TEST CASES DONE>"; + var beginTag = "<#TEST CASE "; + var endTag = ">"; + + print(sizeTag); + print(testcases.length); + for (tc = 0; tc < testcases.length; tc++) + { + print(beginTag + 'PASSED' + endTag); + print(testcases[tc].passed); + print(beginTag + 'NAME' + endTag); + print(testcases[tc].name); + print(beginTag + 'EXPECTED' + endTag); + print(testcases[tc].expect); + print(beginTag + 'ACTUAL' + endTag); + print(testcases[tc].actual); + print(beginTag + 'DESCRIPTION' + endTag); + print(testcases[tc].description); + print(beginTag + 'REASON' + endTag); + print(( testcases[tc].passed ) ? "" : "wrong value "); + print(beginTag + 'BUGNUMBER' + endTag); + print( BUGNUMBER ); + } + print(doneTag); + print( HR ); + gc(); +} +function getFailedCases() { + for ( var i = 0; i < testcases.length; i++ ) { + if ( ! testcases[i].passed ) { + print( testcases[i].description +" = " +testcases[i].actual +" expected: "+ testcases[i].expect ); + } + } +} +function err( msg, page, line ) { + testcases[tc].actual = "error"; + testcases[tc].reason = msg; + writeTestCaseResult( testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ testcases[tc].actual + + ": " + testcases[tc].reason ); + stopTest(); + return true; +} + +/** + * Type Conversion functions used by Type Conversion + * + */ + + + + /* + * Date functions used by tests in Date suite + * + */ +var msPerDay = 86400000; +var HoursPerDay = 24; +var MinutesPerHour = 60; +var SecondsPerMinute = 60; +var msPerSecond = 1000; +var msPerMinute = 60000; // msPerSecond * SecondsPerMinute +var msPerHour = 3600000; // msPerMinute * MinutesPerHour + +var TIME_1970 = 0; +var TIME_2000 = 946684800000; +var TIME_1900 = -2208988800000; + +function Day( t ) { + return ( Math.floor(t/msPerDay ) ); +} +function DaysInYear( y ) { + if ( y % 4 != 0 ) { + return 365; + } + if ( (y % 4 == 0) && (y % 100 != 0) ) { + return 366; + } + if ( (y % 100 == 0) && (y % 400 != 0) ) { + return 365; + } + if ( (y % 400 == 0) ){ + return 366; + } else { + return "ERROR: DaysInYear(" + y + ") case not covered"; + } +} +function TimeInYear( y ) { + return ( DaysInYear(y) * msPerDay ); +} +function DayNumber( t ) { + return ( Math.floor( t / msPerDay ) ); +} +function TimeWithinDay( t ) { + if ( t < 0 ) { + return ( (t % msPerDay) + msPerDay ); + } else { + return ( t % msPerDay ); + } +} +function YearNumber( t ) { +} +function TimeFromYear( y ) { + return ( msPerDay * DayFromYear(y) ); +} +function DayFromYear( y ) { + return ( 365*(y-1970) + + Math.floor((y-1969)/4) - + Math.floor((y-1901)/100) + + Math.floor((y-1601)/400) ); +} +function InLeapYear( t ) { + if ( DaysInYear(YearFromTime(t)) == 365 ) { + return 0; + } + if ( DaysInYear(YearFromTime(t)) == 366 ) { + return 1; + } else { + return "ERROR: InLeapYear("+t+") case not covered"; + } +} +function YearFromTime( t ) { + t = Number( t ); + var sign = ( t < 0 ) ? -1 : 1; + var year = ( sign < 0 ) ? 1969 : 1970; + for ( var timeToTimeZero = t; ; ) { + // subtract the current year's time from the time that's left. + timeToTimeZero -= sign * TimeInYear(year) + + // if there's less than the current year's worth of time left, then break. + if ( sign < 0 ) { + if ( sign * timeToTimeZero <= 0 ) { + break; + } else { + year += sign; + } + } else { + if ( sign * timeToTimeZero < 0 ) { + break; + } else { + year += sign; + } + } + } + return ( year ); +} +function MonthFromTime( t ) { + // i know i could use switch but i'd rather not until it's part of ECMA + var day = DayWithinYear( t ); + var leap = InLeapYear(t); + + if ( (0 <= day) && (day < 31) ) { + return 0; + } + if ( (31 <= day) && (day < (59+leap)) ) { + return 1; + } + if ( ((59+leap) <= day) && (day < (90+leap)) ) { + return 2; + } + if ( ((90+leap) <= day) && (day < (120+leap)) ) { + return 3; + } + if ( ((120+leap) <= day) && (day < (151+leap)) ) { + return 4; + } + if ( ((151+leap) <= day) && (day < (181+leap)) ) { + return 5; + } + if ( ((181+leap) <= day) && (day < (212+leap)) ) { + return 6; + } + if ( ((212+leap) <= day) && (day < (243+leap)) ) { + return 7; + } + if ( ((243+leap) <= day) && (day < (273+leap)) ) { + return 8; + } + if ( ((273+leap) <= day) && (day < (304+leap)) ) { + return 9; + } + if ( ((304+leap) <= day) && (day < (334+leap)) ) { + return 10; + } + if ( ((334+leap) <= day) && (day < (365+leap)) ) { + return 11; + } else { + return "ERROR: MonthFromTime("+t+") not known"; + } +} +function DayWithinYear( t ) { + return( Day(t) - DayFromYear(YearFromTime(t))); +} +function DateFromTime( t ) { + var day = DayWithinYear(t); + var month = MonthFromTime(t); + + if ( month == 0 ) { + return ( day + 1 ); + } + if ( month == 1 ) { + return ( day - 30 ); + } + if ( month == 2 ) { + return ( day - 58 - InLeapYear(t) ); + } + if ( month == 3 ) { + return ( day - 89 - InLeapYear(t)); + } + if ( month == 4 ) { + return ( day - 119 - InLeapYear(t)); + } + if ( month == 5 ) { + return ( day - 150- InLeapYear(t)); + } + if ( month == 6 ) { + return ( day - 180- InLeapYear(t)); + } + if ( month == 7 ) { + return ( day - 211- InLeapYear(t)); + } + if ( month == 8 ) { + return ( day - 242- InLeapYear(t)); + } + if ( month == 9 ) { + return ( day - 272- InLeapYear(t)); + } + if ( month == 10 ) { + return ( day - 303- InLeapYear(t)); + } + if ( month == 11 ) { + return ( day - 333- InLeapYear(t)); + } + + return ("ERROR: DateFromTime("+t+") not known" ); +} +function WeekDay( t ) { + var weekday = (Day(t)+4) % 7; + return( weekday < 0 ? 7 + weekday : weekday ); +} + +// missing daylight savins time adjustment + +function HourFromTime( t ) { + var h = Math.floor( t / msPerHour ) % HoursPerDay; + return ( (h<0) ? HoursPerDay + h : h ); +} +function MinFromTime( t ) { + var min = Math.floor( t / msPerMinute ) % MinutesPerHour; + return( ( min < 0 ) ? MinutesPerHour + min : min ); +} +function SecFromTime( t ) { + var sec = Math.floor( t / msPerSecond ) % SecondsPerMinute; + return ( (sec < 0 ) ? SecondsPerMinute + sec : sec ); +} +function msFromTime( t ) { + var ms = t % msPerSecond; + return ( (ms < 0 ) ? msPerSecond + ms : ms ); +} +function LocalTZA() { + return ( TZ_DIFF * msPerHour ); +} +function UTC( t ) { + return ( t - LocalTZA() - DaylightSavingTA(t - LocalTZA()) ); +} +function DaylightSavingTA( t ) { + t = t - LocalTZA(); + + var dst_start = GetFirstSundayInApril(t) + 2*msPerHour; + var dst_end = GetLastSundayInOctober(t)+ 2*msPerHour; + + if ( t >= dst_start && t < dst_end ) { + return msPerHour; + } else { + return 0; + } + + // Daylight Savings Time starts on the first Sunday in April at 2:00AM in + // PST. Other time zones will need to override this function. + + print( new Date( UTC(dst_start + LocalTZA())) ); + + return UTC(dst_start + LocalTZA()); +} +function GetFirstSundayInApril( t ) { + var year = YearFromTime(t); + var leap = InLeapYear(t); + + var april = TimeFromYear(year) + TimeInMonth(0, leap) + TimeInMonth(1,leap) + + TimeInMonth(2,leap); + + for ( var first_sunday = april; WeekDay(first_sunday) > 0; + first_sunday += msPerDay ) + { + ; + } + + return first_sunday; +} +function GetLastSundayInOctober( t ) { + var year = YearFromTime(t); + var leap = InLeapYear(t); + + for ( var oct = TimeFromYear(year), m = 0; m < 9; m++ ) { + oct += TimeInMonth(m, leap); + } + for ( var last_sunday = oct + 30*msPerDay; WeekDay(last_sunday) > 0; + last_sunday -= msPerDay ) + { + ; + } + return last_sunday; +} +function LocalTime( t ) { + return ( t + LocalTZA() + DaylightSavingTA(t) ); +} +function MakeTime( hour, min, sec, ms ) { + if ( isNaN( hour ) || isNaN( min ) || isNaN( sec ) || isNaN( ms ) ) { + return Number.NaN; + } + + hour = ToInteger(hour); + min = ToInteger( min); + sec = ToInteger( sec); + ms = ToInteger( ms ); + + return( (hour*msPerHour) + (min*msPerMinute) + + (sec*msPerSecond) + ms ); +} +function MakeDay( year, month, date ) { + if ( isNaN(year) || isNaN(month) || isNaN(date) ) { + return Number.NaN; + } + year = ToInteger(year); + month = ToInteger(month); + date = ToInteger(date ); + + var sign = ( year < 1970 ) ? -1 : 1; + var t = ( year < 1970 ) ? 1 : 0; + var y = ( year < 1970 ) ? 1969 : 1970; + + var result5 = year + Math.floor( month/12 ); + var result6 = month % 12; + + if ( year < 1970 ) { + for ( y = 1969; y >= year; y += sign ) { + t += sign * TimeInYear(y); + } + } else { + for ( y = 1970 ; y < year; y += sign ) { + t += sign * TimeInYear(y); + } + } + + var leap = InLeapYear( t ); + + for ( var m = 0; m < month; m++ ) { + t += TimeInMonth( m, leap ); + } + + if ( YearFromTime(t) != result5 ) { + return Number.NaN; + } + if ( MonthFromTime(t) != result6 ) { + return Number.NaN; + } + if ( DateFromTime(t) != 1 ) { + return Number.NaN; + } + + return ( (Day(t)) + date - 1 ); +} +function TimeInMonth( month, leap ) { + // september april june november + // jan 0 feb 1 mar 2 apr 3 may 4 june 5 jul 6 + // aug 7 sep 8 oct 9 nov 10 dec 11 + + if ( month == 3 || month == 5 || month == 8 || month == 10 ) { + return ( 30*msPerDay ); + } + + // all the rest + if ( month == 0 || month == 2 || month == 4 || month == 6 || + month == 7 || month == 9 || month == 11 ) { + return ( 31*msPerDay ); + } + + // save february + return ( (leap == 0) ? 28*msPerDay : 29*msPerDay ); +} +function MakeDate( day, time ) { + if ( day == Number.POSITIVE_INFINITY || + day == Number.NEGATIVE_INFINITY || + day == Number.NaN ) { + return Number.NaN; + } + if ( time == Number.POSITIVE_INFINITY || + time == Number.POSITIVE_INFINITY || + day == Number.NaN) { + return Number.NaN; + } + return ( day * msPerDay ) + time; +} +function TimeClip( t ) { + if ( isNaN( t ) ) { + return ( Number.NaN ); + } + if ( Math.abs( t ) > 8.64e15 ) { + return ( Number.NaN ); + } + + return ( ToInteger( t ) ); +} +function ToInteger( t ) { + t = Number( t ); + + if ( isNaN( t ) ){ + return ( Number.NaN ); + } + if ( t == 0 || t == -0 || + t == Number.POSITIVE_INFINITY || t == Number.NEGATIVE_INFINITY ) { + return 0; + } + + var sign = ( t < 0 ) ? -1 : 1; + + return ( sign * Math.floor( Math.abs( t ) ) ); +} +function Enumerate ( o ) { + var properties = new Array(); + for ( p in o ) { + properties[ properties.length ] = new Array( p, o[p] ); + } + return properties; +} +function AddTestCase( description, expect, actual ) { + testcases[tc++] = new TestCase( SECTION, description, expect, actual ); +} +function getFailedCases() { + for ( var i = 0; i < testcases.length; i++ ) { + if ( ! testcases[i].passed ) { + print( testcases[i].description +" = " +testcases[i].actual +" expected: "+ testcases[i].expect ); + } + } +} diff --git a/tests/auto/qml/parserstress/tests/ecma_2/shell.js b/tests/auto/qml/parserstress/tests/ecma_2/shell.js new file mode 100644 index 0000000000..a83dd68ec2 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma_2/shell.js @@ -0,0 +1,51 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is mozilla.org code. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestsuite = 'ecma_2'; + +var TZ_DIFF = getTimeZoneDiff(); + +/* + * Originally, the test suite used a hard-coded value TZ_DIFF = -8. + * But that was only valid for testers in the Pacific Standard Time Zone! + * We calculate the proper number dynamically for any tester. We just + * have to be careful to use a date not subject to Daylight Savings Time... + */ +function getTimeZoneDiff() +{ + return -((new Date(2000, 1, 1)).getTimezoneOffset())/60; +} diff --git a/tests/auto/qml/parserstress/tests/ecma_2/template.js b/tests/auto/qml/parserstress/tests/ecma_2/template.js new file mode 100644 index 0000000000..83397ba7b3 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma_2/template.js @@ -0,0 +1,57 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is JavaScript Engine testing utilities. + * + * The Initial Developer of the Original Code is + * Mozilla Foundation. + * Portions created by the Initial Developer are Copyright (C) 2008 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +gTestfile = 'template.js'; + +/** + * File Name: template.js + * Reference: ** replace with bugzilla URL or document reference ** + * Description: ** replace with description of test ** + * Author: ** replace with your e-mail address ** + */ + +var SECTION = ""; // if ECMA test, provide section number +var VERSION = "ECMA_2"; // Version of JavaScript or ECMA +var TITLE = ""; // Provide ECMA section title or description +var BUGNUMBER = ""; // Provide URL to bugsplat or bugzilla report + +startTest(); // leave this alone + + +/* Calls to AddTestCase here */ + +test(); // leave this alone diff --git a/tests/auto/qml/parserstress/tests/ecma_3/Array/15.4.4.11-01.js b/tests/auto/qml/parserstress/tests/ecma_3/Array/15.4.4.11-01.js new file mode 100755 index 0000000000..0436b8c1e0 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma_3/Array/15.4.4.11-01.js @@ -0,0 +1,61 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is JavaScript Engine testing utilities. + * + * The Initial Developer of the Original Code is + * Mozilla Foundation. + * Portions created by the Initial Developer are Copyright (C) 2005 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): Igor Bukanov + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +var gTestfile = '15.4.4.11-01.js'; +//----------------------------------------------------------------------------- +var BUGNUMBER = 312138; +var summary = 'Array.sort should not eat exceptions'; +var actual = ''; +var expect = ''; + +printBugNumber(BUGNUMBER); +printStatus (summary); + +expect = "e=1 N=1"; + +var N = 0; +var array = [4,3,2,1]; + +try { + array.sort(function() { + throw ++N; + }); +} catch (e) { + actual = ("e="+e+" N="+N); +} + +reportCompare(expect, actual, summary); diff --git a/tests/auto/qml/parserstress/tests/ecma_3/Array/15.4.4.3-1.js b/tests/auto/qml/parserstress/tests/ecma_3/Array/15.4.4.3-1.js new file mode 100644 index 0000000000..e3de6fb116 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma_3/Array/15.4.4.3-1.js @@ -0,0 +1,88 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is mozilla.org code. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * pschwartau@netscape.com + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +/* + * Date: 12 Mar 2001 + * + * + * SUMMARY: Testing Array.prototype.toLocaleString() + * See http://bugzilla.mozilla.org/show_bug.cgi?id=56883 + * See http://bugzilla.mozilla.org/show_bug.cgi?id=58031 + * + * By ECMA3 15.4.4.3, myArray.toLocaleString() means that toLocaleString() + * should be applied to each element of the array, and the results should be + * concatenated with an implementation-specific delimiter. For example: + * + * myArray[0].toLocaleString() + ',' + myArray[1].toLocaleString() + etc. + * + * In this testcase toLocaleString is a user-defined property of each + * array element; therefore it is the function that should be + * invoked. This function increments a global variable. Therefore the + * end value of this variable should be myArray.length. + */ +//----------------------------------------------------------------------------- +var gTestfile = '15.4.4.3-1.js'; +var BUGNUMBER = 56883; +var summary = 'Testing Array.prototype.toLocaleString() -'; +var actual = ''; +var expect = ''; +var n = 0; +var obj = {toLocaleString: function() {n++}}; +var myArray = [obj, obj, obj]; + + +myArray.toLocaleString(); +actual = n; +expect = 3; // (see explanation above) + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + + +function test() +{ + enterFunc ('test'); + printBugNumber(BUGNUMBER); + printStatus (summary); + + reportCompare(expect, actual, summary); + + exitFunc ('test'); +} diff --git a/tests/auto/qml/parserstress/tests/ecma_3/Array/15.4.4.4-001.js b/tests/auto/qml/parserstress/tests/ecma_3/Array/15.4.4.4-001.js new file mode 100644 index 0000000000..b87233ea97 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma_3/Array/15.4.4.4-001.js @@ -0,0 +1,153 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is JavaScript Engine testing utilities. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corp. + * Portions created by the Initial Developer are Copyright (C) 2002 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * george@vanous.com, igor@icesoft.no, pschwartau@netscape.com + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +/* + * + * Date: 19 September 2002 + * SUMMARY: Testing Array.prototype.concat() + * See http://bugzilla.mozilla.org/show_bug.cgi?id=169795 + * + */ +//----------------------------------------------------------------------------- +var gTestfile = '15.4.4.4-001.js'; +var UBound = 0; +var BUGNUMBER = 169795; +var summary = 'Testing Array.prototype.concat()'; +var status = ''; +var statusitems = []; +var actual = ''; +var actualvalues = []; +var expect= ''; +var expectedvalues = []; +var x; + + +status = inSection(1); +x = "Hello"; +actual = [].concat(x).toString(); +expect = x.toString(); +addThis(); + +status = inSection(2); +x = 999; +actual = [].concat(x).toString(); +expect = x.toString(); +addThis(); + +status = inSection(3); +x = /Hello/g; +actual = [].concat(x).toString(); +expect = x.toString(); +addThis(); + +status = inSection(4); +x = new Error("Hello"); +actual = [].concat(x).toString(); +expect = x.toString(); +addThis(); + +status = inSection(5); +x = function() {return "Hello";}; +actual = [].concat(x).toString(); +expect = x.toString(); +addThis(); + +status = inSection(6); +x = [function() {return "Hello";}]; +actual = [].concat(x).toString(); +expect = x.toString(); +addThis(); + +status = inSection(7); +x = [1,2,3].concat([4,5,6]); +actual = [].concat(x).toString(); +expect = x.toString(); +addThis(); + +status = inSection(8); +x = eval('this'); +actual = [].concat(x).toString(); +expect = x.toString(); +addThis(); + +/* + * The next two sections are by igor@icesoft.no; see + * http://bugzilla.mozilla.org/show_bug.cgi?id=169795#c3 + */ +status = inSection(9); +x={length:0}; +actual = [].concat(x).toString(); +expect = x.toString(); +addThis(); + +status = inSection(10); +x={length:2, 0:0, 1:1}; +actual = [].concat(x).toString(); +expect = x.toString(); +addThis(); + + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + + + +function addThis() +{ + statusitems[UBound] = status; + actualvalues[UBound] = actual; + expectedvalues[UBound] = expect; + UBound++; +} + + +function test() +{ + enterFunc('test'); + printBugNumber(BUGNUMBER); + printStatus(summary); + + for (var i=0; i + * See http://bugzilla.mozilla.org/show_bug.cgi?id=101488 + * + * Without the "new" keyword, assigning arr.length = Number(n) worked. + * But with it, Rhino was giving an error "Inappropriate array length" + * and SpiderMonkey was exiting without giving any error or return value - + * + * Comments on the Rhino code by igor@icesoft.no: + * + * jsSet_length requires that the new length value should be an instance + * of Number. But according to Ecma 15.4.5.1, item 12-13, an error should + * be thrown only if ToUint32(length_value) != ToNumber(length_value) + */ +//----------------------------------------------------------------------------- +var gTestfile = 'regress-101488.js'; +var UBound = 0; +var BUGNUMBER = 101488; +var summary = 'Try assigning arr.length = new Number(n)'; +var status = ''; +var statusitems = []; +var actual = ''; +var actualvalues = []; +var expect= ''; +var expectedvalues = []; +var arr = []; + + +status = inSection(1); +arr = Array(); +tryThis('arr.length = new Number(1);'); +actual = arr.length; +expect = 1; +addThis(); + +status = inSection(2); +arr = Array(5); +tryThis('arr.length = new Number(1);'); +actual = arr.length; +expect = 1; +addThis(); + +status = inSection(3); +arr = Array(); +tryThis('arr.length = new Number(17);'); +actual = arr.length; +expect = 17; +addThis(); + +status = inSection(4); +arr = Array(5); +tryThis('arr.length = new Number(17);'); +actual = arr.length; +expect = 17; +addThis(); + + +/* + * Also try the above with the "new" keyword before Array(). + * Array() and new Array() should be equivalent, by ECMA 15.4.1.1 + */ +status = inSection(5); +arr = new Array(); +tryThis('arr.length = new Number(1);'); +actual = arr.length; +expect = 1; +addThis(); + +status = inSection(6); +arr = new Array(5); +tryThis('arr.length = new Number(1);'); +actual = arr.length; +expect = 1; +addThis(); + +arr = new Array(); +tryThis('arr.length = new Number(17);'); +actual = arr.length; +expect = 17; +addThis(); + +status = inSection(7); +arr = new Array(5); +tryThis('arr.length = new Number(17);'); +actual = arr.length; +expect = 17; +addThis(); + + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + + + +function tryThis(s) +{ + try + { + eval(s); + } + catch(e) + { + // keep going + } +} + + +function addThis() +{ + statusitems[UBound] = status; + actualvalues[UBound] = actual; + expectedvalues[UBound] = expect; + UBound++; +} + + +function test() +{ + enterFunc ('test'); + printBugNumber(BUGNUMBER); + printStatus (summary); + + for (var i=0; i= dst_start && t < dst_end ) + return msPerHour; + + return 0; +} + +function GetFirstSundayInMonth( t, m ) { + var year = YearFromTime(t); + var leap = InLeapYear(t); + +// month m 0..11 +// april == 3 +// march == 2 + + // set time to first day of month m + var time = TimeFromYear(year); + for (var i = 0; i < m; ++i) + { + time += TimeInMonth(i, leap); + } + + for ( var first_sunday = time; WeekDay(first_sunday) > 0; + first_sunday += msPerDay ) + { + ; + } + + return first_sunday; +} + +function GetLastSundayInMonth( t, m ) { + var year = YearFromTime(t); + var leap = InLeapYear(t); + +// month m 0..11 +// april == 3 +// march == 2 + + // first day of following month + var time = TimeFromYear(year); + for (var i = 0; i <= m; ++i) + { + time += TimeInMonth(i, leap); + } + // prev day == last day of month + time -= msPerDay; + + for ( var last_sunday = time; WeekDay(last_sunday) > 0; + last_sunday -= msPerDay ) + { + ; + } + return last_sunday; +} + +/* + 15.9.1.9 Daylight Saving Time Adjustment + + The implementation of ECMAScript should not try to determine whether + the exact time was subject to daylight saving time, but just whether + daylight saving time would have been in effect if the current + daylight saving time algorithm had been used at the time. This avoids + complications such as taking into account the years that the locale + observed daylight saving time year round. +*/ + +/* + US DST algorithm + + Before 2007, DST starts first Sunday in April at 2 AM and ends last + Sunday in October at 2 AM + + Starting in 2007, DST starts second Sunday in March at 2 AM and ends + first Sunday in November at 2 AM + + Note that different operating systems behave differently. + + Fully patched Windows XP uses the 2007 algorithm for all dates while + fully patched Fedora Core 6 and RHEL 4 Linux use the algorithm in + effect at the time. + + Since pre-2007 DST is a subset of 2007 DST rules, this only affects + tests that occur in the period Mar-Apr and Oct-Nov where the two + algorithms do not agree. + +*/ + +function GetDSTStart( t ) +{ + return (GetFirstSundayInMonth(t, 2) + 7*msPerDay + 2*msPerHour - LocalTZA()); +} + +function GetDSTEnd( t ) +{ + return (GetFirstSundayInMonth(t, 10) + 2*msPerHour - LocalTZA()); +} + +function GetOldDSTStart( t ) +{ + return (GetFirstSundayInMonth(t, 3) + 2*msPerHour - LocalTZA()); +} + +function GetOldDSTEnd( t ) +{ + return (GetLastSundayInMonth(t, 9) + 2*msPerHour - LocalTZA()); +} + +function LocalTime( t ) { + return ( t + LocalTZA() + DaylightSavingTA(t) ); +} +function MakeTime( hour, min, sec, ms ) { + if ( isNaN( hour ) || isNaN( min ) || isNaN( sec ) || isNaN( ms ) ) { + return Number.NaN; + } + + hour = ToInteger(hour); + min = ToInteger( min); + sec = ToInteger( sec); + ms = ToInteger( ms ); + + return( (hour*msPerHour) + (min*msPerMinute) + + (sec*msPerSecond) + ms ); +} +function MakeDay( year, month, date ) { + if ( isNaN(year) || isNaN(month) || isNaN(date) ) { + return Number.NaN; + } + year = ToInteger(year); + month = ToInteger(month); + date = ToInteger(date ); + + var sign = ( year < 1970 ) ? -1 : 1; + var t = ( year < 1970 ) ? 1 : 0; + var y = ( year < 1970 ) ? 1969 : 1970; + + var result5 = year + Math.floor( month/12 ); + var result6 = month % 12; + + if ( year < 1970 ) { + for ( y = 1969; y >= year; y += sign ) { + t += sign * TimeInYear(y); + } + } else { + for ( y = 1970 ; y < year; y += sign ) { + t += sign * TimeInYear(y); + } + } + + var leap = InLeapYear( t ); + + for ( var m = 0; m < month; m++ ) { + t += TimeInMonth( m, leap ); + } + + if ( YearFromTime(t) != result5 ) { + return Number.NaN; + } + if ( MonthFromTime(t) != result6 ) { + return Number.NaN; + } + if ( DateFromTime(t) != 1 ) { + return Number.NaN; + } + + return ( (Day(t)) + date - 1 ); +} +function TimeInMonth( month, leap ) { + // september april june november + // jan 0 feb 1 mar 2 apr 3 may 4 june 5 jul 6 + // aug 7 sep 8 oct 9 nov 10 dec 11 + + if ( month == 3 || month == 5 || month == 8 || month == 10 ) { + return ( 30*msPerDay ); + } + + // all the rest + if ( month == 0 || month == 2 || month == 4 || month == 6 || + month == 7 || month == 9 || month == 11 ) { + return ( 31*msPerDay ); + } + + // save february + return ( (leap == 0) ? 28*msPerDay : 29*msPerDay ); +} +function MakeDate( day, time ) { + if ( day == Number.POSITIVE_INFINITY || + day == Number.NEGATIVE_INFINITY ) { + return Number.NaN; + } + if ( time == Number.POSITIVE_INFINITY || + time == Number.NEGATIVE_INFINITY ) { + return Number.NaN; + } + return ( day * msPerDay ) + time; +} +function TimeClip( t ) { + if ( isNaN( t ) ) { + return ( Number.NaN ); + } + if ( Math.abs( t ) > 8.64e15 ) { + return ( Number.NaN ); + } + + return ( ToInteger( t ) ); +} +function ToInteger( t ) { + t = Number( t ); + + if ( isNaN( t ) ){ + return ( Number.NaN ); + } + if ( t == 0 || t == -0 || + t == Number.POSITIVE_INFINITY || t == Number.NEGATIVE_INFINITY ) { + return 0; + } + + var sign = ( t < 0 ) ? -1 : 1; + + return ( sign * Math.floor( Math.abs( t ) ) ); +} +function Enumerate ( o ) { + var p; + for ( p in o ) { + print( p +": " + o[p] ); + } +} + diff --git a/tests/auto/qml/parserstress/tests/ecma_3/Exceptions/15.11.1.1.js b/tests/auto/qml/parserstress/tests/ecma_3/Exceptions/15.11.1.1.js new file mode 100644 index 0000000000..6910d76f15 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma_3/Exceptions/15.11.1.1.js @@ -0,0 +1,137 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is JavaScript Engine testing utilities. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corp. + * Portions created by the Initial Developer are Copyright (C) 2002 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * joerg.schaible@gmx.de + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +/* + * + * Date: 27 Nov 2002 + * SUMMARY: Ensuring normal function call of Error (ECMA-262 Ed.3 15.11.1.1). + */ +//----------------------------------------------------------------------------- +var gTestfile = '15.11.1.1.js'; +var UBound = 0; +var BUGNUMBER = ''; +var summary = 'Ensuring normal function call of Error (ECMA-262 Ed.3 15.11.1.1)'; +var status = ''; +var statusitems = []; +var actual = ''; +var actualvalues = []; +var expect= ''; +var expectedvalues = []; +var EMPTY_STRING = ''; +var EXPECTED_FORMAT = 0; + + +function otherScope(msg) +{ + return Error(msg); +} + + +status = inSection(1); +var err1 = Error('msg1'); +actual = examineThis(err1, 'msg1'); +expect = EXPECTED_FORMAT; +addThis(); + +status = inSection(2); +var err2 = otherScope('msg2'); +actual = examineThis(err2, 'msg2'); +expect = EXPECTED_FORMAT; +addThis(); + +status = inSection(3); +var err3 = otherScope(); +actual = examineThis(err3, EMPTY_STRING); +expect = EXPECTED_FORMAT; +addThis(); + +status = inSection(4); +var err4 = eval("Error('msg4')"); +actual = examineThis(err4, 'msg4'); +expect = EXPECTED_FORMAT; +addThis(); + + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + + + +/* + * Searches err.toString() for err.name + ':' + err.message, + * with possible whitespace on each side of the colon sign. + * + * We allow for no colon in case err.message was not provided by the user. + * In such a case, SpiderMonkey and Rhino currently set err.message = '', + * as allowed for by ECMA 15.11.4.3. This makes |pattern| work in this case. + * + * If this is ever changed to a non-empty string, e.g. 'undefined', + * you may have to modify |pattern| to take that into account - + * + */ +function examineThis(err, msg) +{ + var pattern = err.name + '\\s*:?\\s*' + msg; + return err.toString().search(RegExp(pattern)); +} + + +function addThis() +{ + statusitems[UBound] = status; + actualvalues[UBound] = actual; + expectedvalues[UBound] = expect; + UBound++; +} + + +function test() +{ + enterFunc ('test'); + printBugNumber(BUGNUMBER); + printStatus (summary); + + for (var i = 0; i < UBound; i++) + { + reportCompare(expectedvalues[i], actualvalues[i], statusitems[i]); + } + + exitFunc ('test'); +} diff --git a/tests/auto/qml/parserstress/tests/ecma_3/Exceptions/15.11.4.4-1.js b/tests/auto/qml/parserstress/tests/ecma_3/Exceptions/15.11.4.4-1.js new file mode 100644 index 0000000000..00f9503041 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma_3/Exceptions/15.11.4.4-1.js @@ -0,0 +1,174 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is JavaScript Engine testing utilities. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corp. + * Portions created by the Initial Developer are Copyright (C) 2001 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * d-russo@ti.com, pschwartau@netscape.com, joerg.schaible@gmx.de + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +/* + * + * Date: 22 Jan 2002 + * SUMMARY: Testing Error.prototype.toString() + * + * Revised: 25 Nov 2002 + * See http://bugzilla.mozilla.org/show_bug.cgi?id=181909 + * + * Note that ECMA-262 3rd Edition Final, Section 15.11.4.4 states that + * Error.prototype.toString() returns an implementation-dependent string. + * Therefore any testcase on this property is somewhat arbitrary. + * + * However, d-russo@ti.com pointed out that Rhino was returning this: + * + * js> err = new Error() + * undefined: undefined + * + * js> err = new Error("msg") + * undefined: msg + * + * + * We expect Rhino to return what SpiderMonkey currently does: + * + * js> err = new Error() + * Error + * + * js> err = new Error("msg") + * Error: msg + * + * + * i.e. we expect err.toString() === err.name if err.message is not defined; + * otherwise, we expect err.toString() === err.name + ': ' + err.message. + * + * See also ECMA 15.11.4.2, 15.11.4.3 + */ +//----------------------------------------------------------------------------- +var gTestfile = '15.11.4.4-1.js'; +var UBound = 0; +var BUGNUMBER = '(none)'; +var summary = 'Testing Error.prototype.toString()'; +var status = ''; +var statusitems = []; +var actual = ''; +var actualvalues = []; +var expect= ''; +var expectedvalues = []; +var EMPTY_STRING = ''; +var EXPECTED_FORMAT = 0; + + +status = inSection(1); +var err1 = new Error('msg1'); +actual = examineThis(err1, 'msg1'); +expect = EXPECTED_FORMAT; +addThis(); + +status = inSection(2); +var err2 = new Error(err1); +actual = examineThis(err2, err1); +expect = EXPECTED_FORMAT; +addThis(); + +status = inSection(3); +var err3 = new Error(); +actual = examineThis(err3, EMPTY_STRING); +expect = EXPECTED_FORMAT; +addThis(); + +status = inSection(4); +var err4 = new Error(EMPTY_STRING); +actual = examineThis(err4, EMPTY_STRING); +expect = EXPECTED_FORMAT; +addThis(); + +// now generate a run-time error - +status = inSection(5); +try +{ + eval('1=2'); +} +catch(err5) +{ + actual = examineThis(err5, '.*'); +} +expect = EXPECTED_FORMAT; +addThis(); + + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + + + +/* + * Searches err.toString() for err.name + ':' + err.message, + * with possible whitespace on each side of the colon sign. + * + * We allow for no colon in case err.message was not provided by the user. + * In such a case, SpiderMonkey and Rhino currently set err.message = '', + * as allowed for by ECMA 15.11.4.3. This makes |pattern| work in this case. + * + * If this is ever changed to a non-empty string, e.g. 'undefined', + * you may have to modify |pattern| to take that into account - + * + */ +function examineThis(err, msg) +{ + var pattern = err.name + '\\s*:?\\s*' + msg; + return err.toString().search(RegExp(pattern)); +} + + +function addThis() +{ + statusitems[UBound] = status; + actualvalues[UBound] = actual; + expectedvalues[UBound] = expect; + UBound++; +} + + +function test() +{ + enterFunc ('test'); + printBugNumber(BUGNUMBER); + printStatus (summary); + + for (var i = 0; i < UBound; i++) + { + reportCompare(expectedvalues[i], actualvalues[i], statusitems[i]); + } + + exitFunc ('test'); +} diff --git a/tests/auto/qml/parserstress/tests/ecma_3/Exceptions/15.11.7.6-001.js b/tests/auto/qml/parserstress/tests/ecma_3/Exceptions/15.11.7.6-001.js new file mode 100644 index 0000000000..c6248cc7c1 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma_3/Exceptions/15.11.7.6-001.js @@ -0,0 +1,130 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is JavaScript Engine testing utilities. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corp. + * Portions created by the Initial Developer are Copyright (C) 2003 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * igor@fastmail.fm, pschwartau@netscape.com + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +/* + * + * Date: 14 April 2003 + * SUMMARY: Prototype of predefined error objects should be DontEnum + * See http://bugzilla.mozilla.org/show_bug.cgi?id=201989 + * + */ +//----------------------------------------------------------------------------- +var gTestfile = '15.11.7.6-001.js'; +var UBound = 0; +var BUGNUMBER = 201989; +var summary = 'Prototype of predefined error objects should be DontEnum'; +var status = ''; +var statusitems = []; +var actual = ''; +var actualvalues = []; +var expect= ''; +var expectedvalues = []; + + +/* + * Tests that |F.prototype| is not enumerable in |F| + */ +function testDontEnum(F) +{ + var proto = F.prototype; + + for (var prop in F) + { + if (F[prop] === proto) + return false; + } + return true; +} + + +var list = [ + "Error", + "ConversionError", + "EvalError", + "RangeError", + "ReferenceError", + "SyntaxError", + "TypeError", + "URIError" + ]; + + +for (i in list) +{ + var F = this[list[i]]; + + // Test for |F|; e.g. Rhino defines |ConversionError| while SM does not. + if (F) + { + status = 'Testing DontEnum attribute of |' + list[i] + '.prototype|'; + actual = testDontEnum(F); + expect = true; + addThis(); + } +} + + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + + + +function addThis() +{ + statusitems[UBound] = status; + actualvalues[UBound] = actual; + expectedvalues[UBound] = expect; + UBound++; +} + + +function test() +{ + enterFunc('test'); + printBugNumber(BUGNUMBER); + printStatus(summary); + + for (var i=0; i -1); + expect = true; + addThis(); +} + + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + + +function addThis() +{ + statusitems[UBound] = status; + actualvalues[UBound] = isReferenceError(actual); + expectedvalues[UBound] = isReferenceError(expect); + UBound++; +} + + +function test() +{ + enterFunc ('test'); + printBugNumber(BUGNUMBER); + printStatus (summary); + + for (var i = 0; i < UBound; i++) + { + reportCompare(expectedvalues[i], actualvalues[i], statusitems[i]); + } + + exitFunc ('test'); +} + + +// converts a Boolean result into a textual result - +function isReferenceError(bResult) +{ + return bResult? ERR_REF_YES : ERR_REF_NO; +} diff --git a/tests/auto/qml/parserstress/tests/ecma_3/Exceptions/browser.js b/tests/auto/qml/parserstress/tests/ecma_3/Exceptions/browser.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/auto/qml/parserstress/tests/ecma_3/Exceptions/regress-181654.js b/tests/auto/qml/parserstress/tests/ecma_3/Exceptions/regress-181654.js new file mode 100644 index 0000000000..3fe80f15ac --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma_3/Exceptions/regress-181654.js @@ -0,0 +1,155 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is JavaScript Engine testing utilities. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corp. + * Portions created by the Initial Developer are Copyright (C) 2002 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * joerg.schaible@gmx.de + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +/* + * + * Date: 23 Nov 2002 + * SUMMARY: Calling toString for an object derived from the Error class + * results in an TypeError (Rhino only) + * See http://bugzilla.mozilla.org/show_bug.cgi?id=181654 + */ +//----------------------------------------------------------------------------- +var gTestfile = 'regress-181654.js'; +var UBound = 0; +var BUGNUMBER = '181654'; +var summary = 'Calling toString for an object derived from the Error class should be possible.'; +var status = ''; +var statusitems = []; +var actual = ''; +var actualvalues = []; +var expect= ''; +var expectedvalues = []; +var EMPTY_STRING = ''; +var EXPECTED_FORMAT = 0; + + +// derive MyError from Error +function MyError( msg ) +{ + this.message = msg; +} +MyError.prototype = new Error(); +MyError.prototype.name = "MyError"; + + +status = inSection(1); +var err1 = new MyError('msg1'); +actual = examineThis(err1, 'msg1'); +expect = EXPECTED_FORMAT; +addThis(); + +status = inSection(2); +var err2 = new MyError(String(err1)); +actual = examineThis(err2, err1); +expect = EXPECTED_FORMAT; +addThis(); + +status = inSection(3); +var err3 = new MyError(); +actual = examineThis(err3, EMPTY_STRING); +expect = EXPECTED_FORMAT; +addThis(); + +status = inSection(4); +var err4 = new MyError(EMPTY_STRING); +actual = examineThis(err4, EMPTY_STRING); +expect = EXPECTED_FORMAT; +addThis(); + +// now generate an error - +status = inSection(5); +try +{ + throw new MyError("thrown"); +} +catch(err5) +{ + actual = examineThis(err5, "thrown"); +} +expect = EXPECTED_FORMAT; +addThis(); + + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + + + +/* + * Searches err.toString() for err.name + ':' + err.message, + * with possible whitespace on each side of the colon sign. + * + * We allow for no colon in case err.message was not provided by the user. + * In such a case, SpiderMonkey and Rhino currently set err.message = '', + * as allowed for by ECMA 15.11.4.3. This makes |pattern| work in this case. + * + * If this is ever changed to a non-empty string, e.g. 'undefined', + * you may have to modify |pattern| to take that into account - + * + */ +function examineThis(err, msg) +{ + var pattern = err.name + '\\s*:?\\s*' + msg; + return err.toString().search(RegExp(pattern)); +} + + +function addThis() +{ + statusitems[UBound] = status; + actualvalues[UBound] = actual; + expectedvalues[UBound] = expect; + UBound++; +} + + +function test() +{ + enterFunc ('test'); + printBugNumber(BUGNUMBER); + printStatus (summary); + + for (var i = 0; i < UBound; i++) + { + reportCompare(expectedvalues[i], actualvalues[i], statusitems[i]); + } + + exitFunc ('test'); +} diff --git a/tests/auto/qml/parserstress/tests/ecma_3/Exceptions/regress-181914.js b/tests/auto/qml/parserstress/tests/ecma_3/Exceptions/regress-181914.js new file mode 100644 index 0000000000..f4d1f224c8 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma_3/Exceptions/regress-181914.js @@ -0,0 +1,194 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is JavaScript Engine testing utilities. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corp. + * Portions created by the Initial Developer are Copyright (C) 2002 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * joerg.schaible@gmx.de, pschwartau@netscape.com + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +/* + * + * Date: 25 Nov 2002 + * SUMMARY: Calling a user-defined superconstructor + * See http://bugzilla.mozilla.org/show_bug.cgi?id=181914, esp. Comment 10. + * + */ +//----------------------------------------------------------------------------- +var gTestfile = 'regress-181914.js'; +var UBound = 0; +var BUGNUMBER = '181914'; +var summary = 'Calling a user-defined superconstructor'; +var status = ''; +var statusitems = []; +var actual = ''; +var actualvalues = []; +var expect= ''; +var expectedvalues = []; +var EMPTY_STRING = ''; +var EXPECTED_FORMAT = 0; + + +// make a user-defined version of the Error constructor +function _Error(msg) +{ + this.message = msg; +} +_Error.prototype = new Error(); +_Error.prototype.name = '_Error'; + + +// derive MyApplyError from _Error +function MyApplyError(msg) +{ + if(this instanceof MyApplyError) + _Error.apply(this, arguments); + else + return new MyApplyError(msg); +} +MyApplyError.prototype = new _Error(); +MyApplyError.prototype.name = "MyApplyError"; + + +// derive MyCallError from _Error +function MyCallError(msg) +{ + if(this instanceof MyCallError) + _Error.call(this, msg); + else + return new MyCallError(msg); +} +MyCallError.prototype = new _Error(); +MyCallError.prototype.name = "MyCallError"; + + +function otherScope(msg) +{ + return MyApplyError(msg); +} + + +status = inSection(1); +var err1 = new MyApplyError('msg1'); +actual = examineThis(err1, 'msg1'); +expect = EXPECTED_FORMAT; +addThis(); + +status = inSection(2); +var err2 = new MyCallError('msg2'); +actual = examineThis(err2, 'msg2'); +expect = EXPECTED_FORMAT; +addThis(); + +status = inSection(3); +var err3 = MyApplyError('msg3'); +actual = examineThis(err3, 'msg3'); +expect = EXPECTED_FORMAT; +addThis(); + +status = inSection(4); +var err4 = MyCallError('msg4'); +actual = examineThis(err4, 'msg4'); +expect = EXPECTED_FORMAT; +addThis(); + +status = inSection(5); +var err5 = otherScope('msg5'); +actual = examineThis(err5, 'msg5'); +expect = EXPECTED_FORMAT; +addThis(); + +status = inSection(6); +var err6 = otherScope(); +actual = examineThis(err6, EMPTY_STRING); +expect = EXPECTED_FORMAT; +addThis(); + +status = inSection(7); +var err7 = eval("MyApplyError('msg7')"); +actual = examineThis(err7, 'msg7'); +expect = EXPECTED_FORMAT; +addThis(); + +status = inSection(8); +var err8; +try +{ + throw MyApplyError('msg8'); +} +catch(e) +{ + if(e instanceof Error) + err8 = e; +} +actual = examineThis(err8, 'msg8'); +expect = EXPECTED_FORMAT; +addThis(); + + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + + + +// Searches |err.toString()| for |err.name + ':' + err.message| +function examineThis(err, msg) +{ + var pattern = err.name + '\\s*:?\\s*' + msg; + return err.toString().search(RegExp(pattern)); +} + + +function addThis() +{ + statusitems[UBound] = status; + actualvalues[UBound] = actual; + expectedvalues[UBound] = expect; + UBound++; +} + + +function test() +{ + enterFunc ('test'); + printBugNumber(BUGNUMBER); + printStatus (summary); + + for (var i = 0; i < UBound; i++) + { + reportCompare(expectedvalues[i], actualvalues[i], statusitems[i]); + } + + exitFunc ('test'); +} diff --git a/tests/auto/qml/parserstress/tests/ecma_3/Exceptions/regress-58946.js b/tests/auto/qml/parserstress/tests/ecma_3/Exceptions/regress-58946.js new file mode 100644 index 0000000000..97212c88a0 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma_3/Exceptions/regress-58946.js @@ -0,0 +1,71 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- + * + * ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is mozilla.org code. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * pschwartau@netscape.com + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +var gTestfile = 'regress-58946.js'; +//------------------------------------------------------------------------------------------------- +var BUGNUMBER = '58946'; +var stat = 'Testing a return statement inside a catch statement inside a function'; + +test(); + +function test() { + enterFunc ("test"); + printBugNumber(BUGNUMBER); + printStatus (stat); + + expect = 'PASS'; + + function f() + { + try + { + throw 'PASS'; + } + catch(e) + { + return e; + } + } + + actual = f(); + + reportCompare(expect, actual, stat); + + exitFunc ("test"); +} diff --git a/tests/auto/qml/parserstress/tests/ecma_3/Exceptions/regress-95101.js b/tests/auto/qml/parserstress/tests/ecma_3/Exceptions/regress-95101.js new file mode 100644 index 0000000000..b7ef074350 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma_3/Exceptions/regress-95101.js @@ -0,0 +1,118 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is mozilla.org code. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * pschwartau@netscape.com + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +/* + * Date: 13 August 2001 + * + * SUMMARY: Invoking an undefined function should produce a ReferenceError + * See http://bugzilla.mozilla.org/show_bug.cgi?id=95101 + */ +//----------------------------------------------------------------------------- +var gTestfile = 'regress-95101.js'; +var UBound = 0; +var BUGNUMBER = 95101; +var summary = 'Invoking an undefined function should produce a ReferenceError'; +var msgERR_REF_YES = 'ReferenceError'; +var msgERR_REF_NO = 'did NOT generate a ReferenceError'; +var status = ''; +var statusitems = []; +var actual = ''; +var actualvalues = []; +var expect= ''; +var expectedvalues = []; + + +try +{ + xxxyyyzzz(); +} +catch (e) +{ + status = 'Section 1 of test'; + actual = e instanceof ReferenceError; + expect = true; + addThis(); + + + /* + * This test is more literal, and may one day be invalid. + * Searching for literal string "ReferenceError" in e.toString() + */ + status = 'Section 2 of test'; + var match = e.toString().search(/ReferenceError/); + actual = (match > -1); + expect = true; + addThis(); +} + + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + + +function addThis() +{ + statusitems[UBound] = status; + actualvalues[UBound] = isReferenceError(actual); + expectedvalues[UBound] = isReferenceError(expect); + UBound++; +} + + +function test() +{ + enterFunc ('test'); + printBugNumber(BUGNUMBER); + printStatus (summary); + + for (var i = 0; i < UBound; i++) + { + reportCompare(expectedvalues[i], actualvalues[i], statusitems[i]); + } + + exitFunc ('test'); +} + + +// converts a Boolean result into a textual result - +function isReferenceError(bResult) +{ + return bResult? msgERR_REF_YES : msgERR_REF_NO; +} diff --git a/tests/auto/qml/parserstress/tests/ecma_3/Exceptions/shell.js b/tests/auto/qml/parserstress/tests/ecma_3/Exceptions/shell.js new file mode 100644 index 0000000000..6c671f1eea --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma_3/Exceptions/shell.js @@ -0,0 +1 @@ +gTestsubsuite = 'Exceptions'; diff --git a/tests/auto/qml/parserstress/tests/ecma_3/ExecutionContexts/10.1.3-1.js b/tests/auto/qml/parserstress/tests/ecma_3/ExecutionContexts/10.1.3-1.js new file mode 100644 index 0000000000..1e7e0254bf --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma_3/ExecutionContexts/10.1.3-1.js @@ -0,0 +1,201 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is JavaScript Engine testing utilities. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corp. + * Portions created by the Initial Developer are Copyright (C) 2002 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * pschwartau@netscape.com + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +/* + * + * Date: 11 Feb 2002 + * SUMMARY: Testing functions having duplicate formal parameter names + * + * Note: given function f(x,x,x,x) {return x;}; f(1,2,3,4) should return 4. + * See ECMA-262 3rd Edition Final Section 10.1.3: Variable Instantiation + * + * Also see http://bugzilla.mozilla.org/show_bug.cgi?id=124900 + */ +//----------------------------------------------------------------------------- +var gTestfile = '10.1.3-1.js'; +var UBound = 0; +var BUGNUMBER = 124900; +var summary = 'Testing functions having duplicate formal parameter names'; +var status = ''; +var statusitems = []; +var actual = ''; +var actualvalues = []; +var expect= ''; +var expectedvalues = []; + + +function f1(x,x) +{ + return x; +} +status = inSection(1); +actual = f1(1,2); +expect = 2; +addThis(); + + +function f2(x,x,x) +{ + return x*x*x; +} +status = inSection(2); +actual = f2(1,2,3); +expect = 27; +addThis(); + + +function f3(x,x,x,x) +{ + return 'a' + x + 'b' + x + 'c' + x ; +} +status = inSection(3); +actual = f3(1,2,3,4); +expect = 'a4b4c4'; +addThis(); + + +/* + * If the value of the last duplicate parameter is not provided by + * the function caller, the value of this parameter is undefined + */ +function f4(x,a,b,x,z) +{ + return x; +} +status = inSection(4); +actual = f4(1,2); +expect = undefined; +addThis(); + + +/* + * f.toString() should preserve any duplicate formal parameter names that exist + */ +function f5(x,x,x,x) +{ +} +status = inSection(5); +actual = f5.toString().match(/\((.*)\)/)[1]; +actual = actual.replace(/\s/g, ''); // for definiteness, remove any white space +expect = 'x,x,x,x'; +addThis(); + + +function f6(x,x,x,x) +{ + var ret = []; + + for (var i=0; i> p); + + reportCompare(expectval, actualval, summary + ': value'); + reportCompare(expect, actual, summary + ': order'); + + exitFunc ('test'); +} diff --git a/tests/auto/qml/parserstress/tests/ecma_3/Expressions/11.7.3-01.js b/tests/auto/qml/parserstress/tests/ecma_3/Expressions/11.7.3-01.js new file mode 100755 index 0000000000..d5af3b86d4 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma_3/Expressions/11.7.3-01.js @@ -0,0 +1,76 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is JavaScript Engine testing utilities. + * + * The Initial Developer of the Original Code is + * Mozilla Foundation. + * Portions created by the Initial Developer are Copyright (C) 2007 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): Brendan Eich + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +var gTestfile = '11.7.3-01.js'; +//----------------------------------------------------------------------------- +var BUGNUMBER = 396969; +var summary = '11.7.3 - >>> should evaluate operands in order'; +var actual = ''; +var expect = ''; + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + enterFunc ('test'); + printBugNumber(BUGNUMBER); + printStatus (summary); + + expect = 'o.valueOf, p.valueOf'; + var actualval; + var expectval = 10; + + var o = { + valueOf: (function (){ actual += 'o.valueOf'; return this.value}), + value:42 + }; + + var p = { + valueOf: (function (){ actual += ', p.valueOf'; return this.value}), + value:2 + }; + + actualval = (o >>> p); + + reportCompare(expectval, actualval, summary + ': value'); + reportCompare(expect, actual, summary + ': order'); + + exitFunc ('test'); +} diff --git a/tests/auto/qml/parserstress/tests/ecma_3/Expressions/11.9.6-1.js b/tests/auto/qml/parserstress/tests/ecma_3/Expressions/11.9.6-1.js new file mode 100644 index 0000000000..1e8f59e400 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma_3/Expressions/11.9.6-1.js @@ -0,0 +1,213 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is JavaScript Engine testing utilities. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corp. + * Portions created by the Initial Developer are Copyright (C) 2002 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * pschwartau@netscape.com + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +/* + * + * Date: 20 Feb 2002 + * SUMMARY: Testing the comparison |undefined === null| + * See http://bugzilla.mozilla.org/show_bug.cgi?id=126722 + * + */ +//----------------------------------------------------------------------------- +var gTestfile = '11.9.6-1.js'; +var UBound = 0; +var BUGNUMBER = 126722; +var summary = 'Testing the comparison |undefined === null|'; +var status = ''; +var statusitems = []; +var actual = ''; +var actualvalues = []; +var expect= ''; +var expectedvalues = []; + + +status = inSection(1); +if (undefined === null) + actual = true; +else + actual = false; +expect = false; +addThis(); + + + +status = inSection(2); +switch(true) +{ +case (undefined === null) : + actual = true; + break; + +default: + actual = false; +} +expect = false; +addThis(); + + + +status = inSection(3); +function f3(x) +{ + var res = false; + + switch(true) + { + case (x === null) : + res = true; + break; + + default: + // do nothing + } + + return res; +} + +actual = f3(undefined); +expect = false; +addThis(); + + + +status = inSection(4); +function f4(arr) +{ + var elt = ''; + var res = false; + + for (i=0; i function f\u02B1 () {} + * + * js> f\u02B1.toSource(); + * function f¦() {} + * + * js> f\u02B1.toSource().toSource(); + * (new String("function f\xB1() {}")) + * + * + * See how the high-byte information (the 02) has been lost? + * The same thing was happening with the toString() method: + * + * js> f\u02B1.toString(); + * + * function f¦() { + * } + * + * js> f\u02B1.toString().toSource(); + * (new String("\nfunction f\xB1() {\n}\n")) + * + */ +//----------------------------------------------------------------------------- +var gTestfile = 'regress-58274.js'; +var UBound = 0; +var BUGNUMBER = 58274; +var summary = 'Testing functions with double-byte names'; +var ERR = 'UNEXPECTED ERROR! \n'; +var ERR_MALFORMED_NAME = ERR + 'Could not find function name in: \n\n'; +var status = ''; +var statusitems = []; +var actual = ''; +var actualvalues = []; +var expect= ''; +var expectedvalues = []; +var sEval; +var sName; + + +sEval = "function f\u02B2() {return 42;}"; +eval(sEval); +sName = getFunctionName(f\u02B2); + +// Test function call - +status = inSection(1); +actual = f\u02B2(); +expect = 42; +addThis(); + +// Test both characters of function name - +status = inSection(2); +actual = sName[0]; +expect = sEval[9]; +addThis(); + +status = inSection(3); +actual = sName[1]; +expect = sEval[10]; +addThis(); + + + +sEval = "function f\u02B2\u0AAA () {return 84;}"; +eval(sEval); +sName = getFunctionName(f\u02B2\u0AAA); + +// Test function call - +status = inSection(4); +actual = f\u02B2\u0AAA(); +expect = 84; +addThis(); + +// Test all three characters of function name - +status = inSection(5); +actual = sName[0]; +expect = sEval[9]; +addThis(); + +status = inSection(6); +actual = sName[1]; +expect = sEval[10]; +addThis(); + +status = inSection(7); +actual = sName[2]; +expect = sEval[11]; +addThis(); + + + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + + + +/* + * Goal: test that f.toString() contains the proper function name. + * + * Note, however, f.toString() is implementation-independent. For example, + * it may begin with '\nfunction' instead of 'function'. Therefore we use + * a regexp to make sure we extract the name properly. + * + * Here we assume that f has been defined by means of a function statement, + * and not a function expression (where it wouldn't have to have a name). + * + * Rhino uses a Unicode representation for f.toString(); whereas + * SpiderMonkey uses an ASCII representation, putting escape sequences + * for non-ASCII characters. For example, if a function is called f\u02B1, + * then in Rhino the toString() method will present a 2-character Unicode + * string for its name, whereas SpiderMonkey will present a 7-character + * ASCII string for its name: the string literal 'f\u02B1'. + * + * So we force the lexer to condense the string before using it. + * This will give uniform results in Rhino and SpiderMonkey. + */ +function getFunctionName(f) +{ + var s = condenseStr(f.toString()); + var re = /\s*function\s+(\S+)\s*\(/; + var arr = s.match(re); + + if (!(arr && arr[1])) + return ERR_MALFORMED_NAME + s; + return arr[1]; +} + + +/* + * This function is the opposite of functions like escape(), which take + * Unicode characters and return escape sequences for them. Here, we force + * the lexer to turn escape sequences back into single characters. + * + * Note we can't simply do |eval(str)|, since in practice |str| will be an + * identifier somewhere in the program (e.g. a function name); thus |eval(str)| + * would return the object that the identifier represents: not what we want. + * + * So we surround |str| lexicographically with quotes to force the lexer to + * evaluate it as a string. Have to strip out any linefeeds first, however - + */ +function condenseStr(str) +{ + /* + * You won't be able to do the next step if |str| has + * any carriage returns or linefeeds in it. For example: + * + * js> eval("'" + '\nHello' + "'"); + * 1: SyntaxError: unterminated string literal: + * 1: ' + * 1: ^ + * + * So replace them with the empty string - + */ + str = str.replace(/[\r\n]/g, '') + return eval("'" + str + "'"); +} + + +function addThis() +{ + statusitems[UBound] = status; + actualvalues[UBound] = actual; + expectedvalues[UBound] = expect; + UBound++; +} + + +function test() +{ + enterFunc('test'); + printBugNumber(BUGNUMBER); + printStatus(summary); + + for (var i=0; i + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +var gTestfile = '8.6.1-01.js'; +//----------------------------------------------------------------------------- + +var BUGNUMBER = 315436; +var summary = 'In strict mode, setting a read-only property should generate a warning'; + +printBugNumber(BUGNUMBER); +printStatus (summary); + +enterFunc (String (BUGNUMBER)); + +// should throw an error in strict mode +var actual = ''; +var expect = 's.length is read-only'; +var status = summary + ': Throw if STRICT and WERROR is enabled'; + +if (!options().match(/strict/)) +{ + options('strict'); +} +if (!options().match(/werror/)) +{ + options('werror'); +} + +try +{ + var s = new String ('abc'); + s.length = 0; +} +catch (e) +{ + actual = e.message; +} + +reportCompare(expect, actual, status); + +// should not throw an error if in strict mode and WERROR is false + +actual = 'did not throw'; +expect = 'did not throw'; +var status = summary + ': Do not throw if STRICT is enabled and WERROR is disabled'; + +// toggle werror off +options('werror'); + +try +{ + s.length = 0; +} +catch (e) +{ + actual = e.message; +} + +reportCompare(expect, actual, status); + +// should not throw an error if not in strict mode + +actual = 'did not throw'; +expect = 'did not throw'; +var status = summary + ': Do not throw if not in strict mode'; + +// toggle strict off +options('strict'); + +try +{ + s.length = 0; +} +catch (e) +{ + actual = e.message; +} + +reportCompare(expect, actual, status); diff --git a/tests/auto/qml/parserstress/tests/ecma_3/Object/8.6.2.6-001.js b/tests/auto/qml/parserstress/tests/ecma_3/Object/8.6.2.6-001.js new file mode 100644 index 0000000000..8fe2b23f4a --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma_3/Object/8.6.2.6-001.js @@ -0,0 +1,113 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is JavaScript Engine testing utilities. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corp. + * Portions created by the Initial Developer are Copyright (C) 2002 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * pschwartau@netscape.com + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +/* + * + * Date: 09 September 2002 + * SUMMARY: Test for TypeError on invalid default string value of object + * See ECMA reference at http://bugzilla.mozilla.org/show_bug.cgi?id=167325 + * + */ +//----------------------------------------------------------------------------- +var gTestfile = '8.6.2.6-001.js'; +var UBound = 0; +var BUGNUMBER = 167325; +var summary = "Test for TypeError on invalid default string value of object"; +var TEST_PASSED = 'TypeError'; +var TEST_FAILED = 'Generated an error, but NOT a TypeError!'; +var TEST_FAILED_BADLY = 'Did not generate ANY error!!!'; +var status = ''; +var statusitems = []; +var actual = ''; +var actualvalues = []; +var expect= ''; +var expectedvalues = []; + + +status = inSection(1); +expect = TEST_PASSED; +actual = TEST_FAILED_BADLY; +/* + * This should generate a TypeError. See ECMA reference + * at http://bugzilla.mozilla.org/show_bug.cgi?id=167325 + */ +try +{ + var obj = {toString: function() {return new Object();}} + obj == 'abc'; +} +catch(e) +{ + if (e instanceof TypeError) + actual = TEST_PASSED; + else + actual = TEST_FAILED; +} +addThis(); + + + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + + + +function addThis() +{ + statusitems[UBound] = status; + actualvalues[UBound] = actual; + expectedvalues[UBound] = expect; + UBound++; +} + + +function test() +{ + enterFunc('test'); + printBugNumber(BUGNUMBER); + printStatus(summary); + + for (var i=0; i>'}, + {section: '11.7.3', operator: '>>>'}, + {section: '11.8.1', operator: '<'}, + {section: '11.8.2', operator: '>'}, + {section: '11.8.3', operator: '<='}, + {section: '11.8.4', operator: '>='}, + {section: '11.10', operator: '&'}, + {section: '11.10', operator: '^'}, + {section: '11.10', operator: '|'}, + {section: '11.13.2', operator: '*='}, + {section: '11.13.2', operator: '/='}, + {section: '11.13.2', operator: '%='}, + {section: '11.13.2', operator: '+='}, + {section: '11.13.2', operator: '<<='}, + {section: '11.13.2', operator: '>>='}, + {section: '11.13.2', operator: '>>>='}, + {section: '11.13.2', operator: '&='}, + {section: '11.13.2', operator: '^='}, + {section: '11.13.2', operator: '|='}, + ]; + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + enterFunc ('test'); + printBugNumber(BUGNUMBER); + printStatus (summary); + + for (var i = 0; i < operators.length; i++) + { + expect = 'left valueOf, left toString, right valueOf, right toString, '; + actual = ''; + + var left = makeObject('left'); + var right = makeObject('right'); + + eval('left ' + operators[i].operator + ' right'); + + reportCompare(expect, actual, summary + ': ' + operators[i].section + ' ' + operators[i].operator); + } + + exitFunc ('test'); +} diff --git a/tests/auto/qml/parserstress/tests/ecma_3/Operators/shell.js b/tests/auto/qml/parserstress/tests/ecma_3/Operators/shell.js new file mode 100644 index 0000000000..910515cfe4 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma_3/Operators/shell.js @@ -0,0 +1 @@ +gTestsubsuite = 'Operators'; diff --git a/tests/auto/qml/parserstress/tests/ecma_3/README b/tests/auto/qml/parserstress/tests/ecma_3/README new file mode 100755 index 0000000000..eebd421c2e --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma_3/README @@ -0,0 +1 @@ +ECMA 262 Edition 3 diff --git a/tests/auto/qml/parserstress/tests/ecma_3/RegExp/15.10.2-1.js b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/15.10.2-1.js new file mode 100644 index 0000000000..9439a2ccd6 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/15.10.2-1.js @@ -0,0 +1,181 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is JavaScript Engine testing utilities. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corp. + * Portions created by the Initial Developer are Copyright (C) 2002 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * rogerl@netscape.com, pschwartau@netscape.com + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +/* + * + * Date: 09 July 2002 + * SUMMARY: RegExp conformance test + * + * These gTestcases are derived from the examples in the ECMA-262 Ed.3 spec + * scattered through section 15.10.2. + * + */ +//----------------------------------------------------------------------------- +var gTestfile = '15.10.2-1.js'; +var i = 0; +var BUGNUMBER = '(none)'; +var summary = 'RegExp conformance test'; +var status = ''; +var statusmessages = new Array(); +var pattern = ''; +var patterns = new Array(); +var string = ''; +var strings = new Array(); +var actualmatch = ''; +var actualmatches = new Array(); +var expectedmatch = ''; +var expectedmatches = new Array(); + + +status = inSection(1); +pattern = /a|ab/; +string = 'abc'; +actualmatch = string.match(pattern); +expectedmatch = Array('a'); +addThis(); + +status = inSection(2); +pattern = /((a)|(ab))((c)|(bc))/; +string = 'abc'; +actualmatch = string.match(pattern); +expectedmatch = Array('abc', 'a', 'a', undefined, 'bc', undefined, 'bc'); +addThis(); + +status = inSection(3); +pattern = /a[a-z]{2,4}/; +string = 'abcdefghi'; +actualmatch = string.match(pattern); +expectedmatch = Array('abcde'); +addThis(); + +status = inSection(4); +pattern = /a[a-z]{2,4}?/; +string = 'abcdefghi'; +actualmatch = string.match(pattern); +expectedmatch = Array('abc'); +addThis(); + +status = inSection(5); +pattern = /(aa|aabaac|ba|b|c)*/; +string = 'aabaac'; +actualmatch = string.match(pattern); +expectedmatch = Array('aaba', 'ba'); +addThis(); + +status = inSection(6); +pattern = /^(a+)\1*,\1+$/; +string = 'aaaaaaaaaa,aaaaaaaaaaaaaaa'; +actualmatch = string.match(pattern); +expectedmatch = Array('aaaaaaaaaa,aaaaaaaaaaaaaaa', 'aaaaa'); +addThis(); + +status = inSection(7); +pattern = /(z)((a+)?(b+)?(c))*/; +string = 'zaacbbbcac'; +actualmatch = string.match(pattern); +expectedmatch = Array('zaacbbbcac', 'z', 'ac', 'a', undefined, 'c'); +addThis(); + +status = inSection(8); +pattern = /(a*)*/; +string = 'b'; +actualmatch = string.match(pattern); +expectedmatch = Array('', undefined); +addThis(); + +status = inSection(9); +pattern = /(a*)b\1+/; +string = 'baaaac'; +actualmatch = string.match(pattern); +expectedmatch = Array('b', ''); +addThis(); + +status = inSection(10); +pattern = /(?=(a+))/; +string = 'baaabac'; +actualmatch = string.match(pattern); +expectedmatch = Array('', 'aaa'); +addThis(); + +status = inSection(11); +pattern = /(?=(a+))a*b\1/; +string = 'baaabac'; +actualmatch = string.match(pattern); +expectedmatch = Array('aba', 'a'); +addThis(); + +status = inSection(12); +pattern = /(.*?)a(?!(a+)b\2c)\2(.*)/; +string = 'baaabaac'; +actualmatch = string.match(pattern); +expectedmatch = Array('baaabaac', 'ba', undefined, 'abaac'); +addThis(); + +status = inSection(13); +pattern = /(?=(a+))/; +string = 'baaabac'; +actualmatch = string.match(pattern); +expectedmatch = Array('', 'aaa'); +addThis(); + + + +//------------------------------------------------------------------------------------------------- +test(); +//------------------------------------------------------------------------------------------------- + + +function addThis() +{ + statusmessages[i] = status; + patterns[i] = pattern; + strings[i] = string; + actualmatches[i] = actualmatch; + expectedmatches[i] = expectedmatch; + i++; +} + + +function test() +{ + enterFunc ('test'); + printBugNumber(BUGNUMBER); + printStatus (summary); + testRegExp(statusmessages, patterns, strings, actualmatches, expectedmatches); + exitFunc ('test'); +} diff --git a/tests/auto/qml/parserstress/tests/ecma_3/RegExp/15.10.2.12.js b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/15.10.2.12.js new file mode 100755 index 0000000000..d68b86c2ed --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/15.10.2.12.js @@ -0,0 +1,63 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is JavaScript Engine testing utilities. + * + * The Initial Developer of the Original Code is + * Mozilla Foundation. + * Portions created by the Initial Developer are Copyright (C) 2007 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): Igor Tandetnik + * Martin Honnen + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +var gTestfile = '15.10.2.12.js'; +//----------------------------------------------------------------------------- +var BUGNUMBER = 378738; +var summary = '15.10.2.12 - CharacterClassEscape \d'; +var actual = ''; +var expect = ''; + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + enterFunc ('test'); + printBugNumber(BUGNUMBER); + printStatus (summary); + + expect = false; + actual = /\d/.test("\uFF11"); + + reportCompare(expect, actual, summary); + + exitFunc ('test'); +} diff --git a/tests/auto/qml/parserstress/tests/ecma_3/RegExp/15.10.3.1-1.js b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/15.10.3.1-1.js new file mode 100644 index 0000000000..7286cea297 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/15.10.3.1-1.js @@ -0,0 +1,136 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is mozilla.org code. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * pschwartau@netscape.com + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +/* + * Date: 26 November 2000 + * + * + * SUMMARY: Passing (RegExp object, flag) to RegExp() function. + * This test arose from Bugzilla bug 61266. The ECMA3 section is: + * + * 15.10.3 The RegExp Constructor Called as a Function + * + * 15.10.3.1 RegExp(pattern, flags) + * + * If pattern is an object R whose [[Class]] property is "RegExp" + * and flags is undefined, then return R unchanged. Otherwise + * call the RegExp constructor (section 15.10.4.1), passing it the + * pattern and flags arguments and return the object constructed + * by that constructor. + * + * + * The current test will check the first scenario outlined above: + * + * "pattern" is itself a RegExp object R + * "flags" is undefined + * + * The flags parameter will be undefined in the sense of not being + * provided. We check that RegExp(R) returns R - + */ +//----------------------------------------------------------------------------- +var gTestfile = '15.10.3.1-1.js'; +var BUGNUMBER = '61266'; +var summary = 'Passing (RegExp object,flag) to RegExp() function'; +var statprefix = 'RegExp(new RegExp('; +var comma = ', '; var singlequote = "'"; var closeparens = '))'; +var cnSUCCESS = 'RegExp() returned the supplied RegExp object'; +var cnFAILURE = 'RegExp() did NOT return the supplied RegExp object'; +var i = -1; var j = -1; var s = ''; var f = ''; +var obj = {}; +var status = ''; var actual = ''; var expect = ''; +var patterns = new Array(); +var flags = new Array(); + + +// various regular expressions to try - +patterns[0] = ''; +patterns[1] = 'abc'; +patterns[2] = '(.*)(3-1)\s\w'; +patterns[3] = '(.*)(...)\\s\\w'; +patterns[4] = '[^A-Za-z0-9_]'; +patterns[5] = '[^\f\n\r\t\v](123.5)([4 - 8]$)'; + +// various flags to try - +flags[0] = 'i'; +flags[1] = 'g'; +flags[2] = 'm'; +flags[3] = undefined; + + + +//------------------------------------------------------------------------------------------------- +test(); +//------------------------------------------------------------------------------------------------- + + +function test() +{ + enterFunc ('test'); + printBugNumber(BUGNUMBER); + printStatus (summary); + + for (i in patterns) + { + s = patterns[i]; + + for (j in flags) + { + f = flags[j]; + status = getStatus(s, f); + obj = new RegExp(s, f); + + actual = (obj == RegExp(obj))? cnSUCCESS : cnFAILURE; + expect = cnSUCCESS; + reportCompare (expect, actual, status); + } + } + + exitFunc ('test'); +} + + +function getStatus(regexp, flag) +{ + return (statprefix + quote(regexp) + comma + flag + closeparens); +} + + +function quote(text) +{ + return (singlequote + text + singlequote); +} diff --git a/tests/auto/qml/parserstress/tests/ecma_3/RegExp/15.10.3.1-2.js b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/15.10.3.1-2.js new file mode 100644 index 0000000000..d78be13c25 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/15.10.3.1-2.js @@ -0,0 +1,144 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is mozilla.org code. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * pschwartau@netscape.com + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +/* + * Date: 26 November 2000 + * + * + * SUMMARY: Passing (RegExp object, flag) to RegExp() function. + * This test arose from Bugzilla bug 61266. The ECMA3 section is: + * + * 15.10.3 The RegExp Constructor Called as a Function + * + * 15.10.3.1 RegExp(pattern, flags) + * + * If pattern is an object R whose [[Class]] property is "RegExp" + * and flags is undefined, then return R unchanged. Otherwise + * call the RegExp constructor (section 15.10.4.1), passing it the + * pattern and flags arguments and return the object constructed + * by that constructor. + * + * + * The current test will check the first scenario outlined above: + * + * "pattern" is itself a RegExp object R + * "flags" is undefined + * + * This test is identical to test 15.10.3.1-1.js, except here we do: + * + * RegExp(R, undefined); + * + * instead of: + * + * RegExp(R); + * + * + * We check that RegExp(R, undefined) returns R - + */ +//----------------------------------------------------------------------------- +var gTestfile = '15.10.3.1-2.js'; +var BUGNUMBER = '61266'; +var summary = 'Passing (RegExp object,flag) to RegExp() function'; +var statprefix = 'RegExp(new RegExp('; +var comma = ', '; var singlequote = "'"; var closeparens = '))'; +var cnSUCCESS = 'RegExp() returned the supplied RegExp object'; +var cnFAILURE = 'RegExp() did NOT return the supplied RegExp object'; +var i = -1; var j = -1; var s = ''; var f = ''; +var obj = {}; +var status = ''; var actual = ''; var expect = ''; +var patterns = new Array(); +var flags = new Array(); + + +// various regular expressions to try - +patterns[0] = ''; +patterns[1] = 'abc'; +patterns[2] = '(.*)(3-1)\s\w'; +patterns[3] = '(.*)(...)\\s\\w'; +patterns[4] = '[^A-Za-z0-9_]'; +patterns[5] = '[^\f\n\r\t\v](123.5)([4 - 8]$)'; + +// various flags to try - +flags[0] = 'i'; +flags[1] = 'g'; +flags[2] = 'm'; +flags[3] = undefined; + + + +//------------------------------------------------------------------------------------------------- +test(); +//------------------------------------------------------------------------------------------------- + + +function test() +{ + enterFunc ('test'); + printBugNumber(BUGNUMBER); + printStatus (summary); + + for (i in patterns) + { + s = patterns[i]; + + for (j in flags) + { + f = flags[j]; + status = getStatus(s, f); + obj = new RegExp(s, f); + + actual = (obj == RegExp(obj, undefined))? cnSUCCESS : cnFAILURE ; + expect = cnSUCCESS; + reportCompare (expect, actual, status); + } + } + + exitFunc ('test'); +} + + +function getStatus(regexp, flag) +{ + return (statprefix + quote(regexp) + comma + flag + closeparens); +} + + +function quote(text) +{ + return (singlequote + text + singlequote); +} diff --git a/tests/auto/qml/parserstress/tests/ecma_3/RegExp/15.10.4.1-1.js b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/15.10.4.1-1.js new file mode 100644 index 0000000000..47faf0051b --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/15.10.4.1-1.js @@ -0,0 +1,127 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is mozilla.org code. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * pschwartau@netscape.com + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +/* + * Date: 26 November 2000 + * + * + *SUMMARY: Passing a RegExp object to a RegExp() constructor. + *This test arose from Bugzilla bug 61266. The ECMA3 section is: + * + * 15.10.4.1 new RegExp(pattern, flags) + * + * If pattern is an object R whose [[Class]] property is "RegExp" and + * flags is undefined, then let P be the pattern used to construct R + * and let F be the flags used to construct R. If pattern is an object R + * whose [[Class]] property is "RegExp" and flags is not undefined, + * then throw a TypeError exception. Otherwise, let P be the empty string + * if pattern is undefined and ToString(pattern) otherwise, and let F be + * the empty string if flags is undefined and ToString(flags) otherwise. + * + * + *The current test will check the first scenario outlined above: + * + * "pattern" is itself a RegExp object R + * "flags" is undefined + * + * We check that a new RegExp object obj2 defined from these parameters + * is morally the same as the original RegExp object obj1. Of course, they + * can't be equal as objects - so we check their enumerable properties... + * + * In this test, the initial RegExp object obj1 will not include a + * flag. The flags parameter for obj2 will be undefined in the sense + * of not being provided. + */ +//----------------------------------------------------------------------------- +var gTestfile = '15.10.4.1-1.js'; +var BUGNUMBER = '61266'; +var summary = 'Passing a RegExp object to a RegExp() constructor'; +var statprefix = 'Applying RegExp() twice to pattern '; +var statsuffix = '; testing property '; +var singlequote = "'"; +var i = -1; var s = ''; +var obj1 = {}; var obj2 = {}; +var status = ''; var actual = ''; var expect = ''; var msg = ''; +var patterns = new Array(); + + +// various regular expressions to try - +patterns[0] = ''; +patterns[1] = 'abc'; +patterns[2] = '(.*)(3-1)\s\w'; +patterns[3] = '(.*)(...)\\s\\w'; +patterns[4] = '[^A-Za-z0-9_]'; +patterns[5] = '[^\f\n\r\t\v](123.5)([4 - 8]$)'; + + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + + +function test() +{ + enterFunc ('test'); + printBugNumber(BUGNUMBER); + printStatus (summary); + + for (i in patterns) + { + s = patterns[i]; + status =getStatus(s); + obj1 = new RegExp(s); + obj2 = new RegExp(obj1); + + reportCompare (obj1 + '', obj2 + '', status); + } + + exitFunc ('test'); +} + + +function getStatus(regexp) +{ + return (statprefix + quote(regexp) + statsuffix); +} + + +function quote(text) +{ + return (singlequote + text + singlequote); +} diff --git a/tests/auto/qml/parserstress/tests/ecma_3/RegExp/15.10.4.1-2.js b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/15.10.4.1-2.js new file mode 100644 index 0000000000..1d67b8afe6 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/15.10.4.1-2.js @@ -0,0 +1,133 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is mozilla.org code. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * pschwartau@netscape.com + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +/* + * Date: 26 November 2000 + * + * + *SUMMARY: Passing a RegExp object to a RegExp() constructor. + *This test arose from Bugzilla bug 61266. The ECMA3 section is: + * + * 15.10.4.1 new RegExp(pattern, flags) + * + * If pattern is an object R whose [[Class]] property is "RegExp" and + * flags is undefined, then let P be the pattern used to construct R + * and let F be the flags used to construct R. If pattern is an object R + * whose [[Class]] property is "RegExp" and flags is not undefined, + * then throw a TypeError exception. Otherwise, let P be the empty string + * if pattern is undefined and ToString(pattern) otherwise, and let F be + * the empty string if flags is undefined and ToString(flags) otherwise. + * + * + *The current test will check the first scenario outlined above: + * + * "pattern" is itself a RegExp object R + * "flags" is undefined + * + * We check that a new RegExp object obj2 defined from these parameters + * is morally the same as the original RegExp object obj1. Of course, they + * can't be equal as objects - so we check their enumerable properties... + * + * In this test, the initial RegExp object obj1 will not include a + * flag. This test is identical to test 15.10.4.1-1.js, except that + * here we use this syntax: + * + * obj2 = new RegExp(obj1, undefined); + * + * instead of: + * + * obj2 = new RegExp(obj1); + */ +//----------------------------------------------------------------------------- +var gTestfile = '15.10.4.1-2.js'; +var BUGNUMBER = '61266'; +var summary = 'Passing a RegExp object to a RegExp() constructor'; +var statprefix = 'Applying RegExp() twice to pattern '; +var statsuffix = '; testing property '; +var singlequote = "'"; +var i = -1; var s = ''; +var obj1 = {}; var obj2 = {}; +var status = ''; var actual = ''; var expect = ''; var msg = ''; +var patterns = new Array(); + + +// various regular expressions to try - +patterns[0] = ''; +patterns[1] = 'abc'; +patterns[2] = '(.*)(3-1)\s\w'; +patterns[3] = '(.*)(...)\\s\\w'; +patterns[4] = '[^A-Za-z0-9_]'; +patterns[5] = '[^\f\n\r\t\v](123.5)([4 - 8]$)'; + + + +//------------------------------------------------------------------------------------------------- +test(); +//------------------------------------------------------------------------------------------------- + + +function test() +{ + enterFunc ('test'); + printBugNumber(BUGNUMBER); + printStatus (summary); + + for (i in patterns) + { + s = patterns[i]; + status =getStatus(s); + obj1 = new RegExp(s); + obj2 = new RegExp(obj1, undefined); // see introduction to bug + + reportCompare (obj1 + '', obj2 + '', status); + } + + exitFunc ('test'); +} + + +function getStatus(regexp) +{ + return (statprefix + quote(regexp) + statsuffix); +} + + +function quote(text) +{ + return (singlequote + text + singlequote); +} diff --git a/tests/auto/qml/parserstress/tests/ecma_3/RegExp/15.10.4.1-3.js b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/15.10.4.1-3.js new file mode 100644 index 0000000000..12ef46bde8 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/15.10.4.1-3.js @@ -0,0 +1,139 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is mozilla.org code. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * pschwartau@netscape.com + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +/* + * Date: 26 November 2000 + * + * + *SUMMARY: Passing a RegExp object to a RegExp() constructor. + *This test arose from Bugzilla bug 61266. The ECMA3 section is: + * + * 15.10.4.1 new RegExp(pattern, flags) + * + * If pattern is an object R whose [[Class]] property is "RegExp" and + * flags is undefined, then let P be the pattern used to construct R + * and let F be the flags used to construct R. If pattern is an object R + * whose [[Class]] property is "RegExp" and flags is not undefined, + * then throw a TypeError exception. Otherwise, let P be the empty string + * if pattern is undefined and ToString(pattern) otherwise, and let F be + * the empty string if flags is undefined and ToString(flags) otherwise. + * + * + *The current test will check the first scenario outlined above: + * + * "pattern" is itself a RegExp object R + * "flags" is undefined + * + * We check that a new RegExp object obj2 defined from these parameters + * is morally the same as the original RegExp object obj1. Of course, they + * can't be equal as objects - so we check their enumerable properties... + * + * In this test, the initial RegExp obj1 will include a flag. The flags + * parameter for obj2 will be undefined in the sense of not being provided. + */ +//----------------------------------------------------------------------------- +var gTestfile = '15.10.4.1-3.js'; +var BUGNUMBER = '61266'; +var summary = 'Passing a RegExp object to a RegExp() constructor'; +var statprefix = 'Applying RegExp() twice to pattern '; +var statmiddle = ' and flag '; +var statsuffix = '; testing property '; +var singlequote = "'"; +var i = -1; var j = -1; var s = ''; +var obj1 = {}; var obj2 = {}; +var status = ''; var actual = ''; var expect = ''; var msg = ''; +var patterns = new Array(); +var flags = new Array(); + + +// various regular expressions to try - +patterns[0] = ''; +patterns[1] = 'abc'; +patterns[2] = '(.*)(3-1)\s\w'; +patterns[3] = '(.*)(...)\\s\\w'; +patterns[4] = '[^A-Za-z0-9_]'; +patterns[5] = '[^\f\n\r\t\v](123.5)([4 - 8]$)'; + +// various flags to try - +flags[0] = 'i'; +flags[1] = 'g'; +flags[2] = 'm'; +flags[3] = undefined; + + + +//------------------------------------------------------------------------------------------------- +test(); +//------------------------------------------------------------------------------------------------- + + +function test() +{ + enterFunc ('test'); + printBugNumber(BUGNUMBER); + printStatus (summary); + + for (i in patterns) + { + s = patterns[i]; + + for (j in flags) + { + f = flags[j]; + status = getStatus(s, f); + obj1 = new RegExp(s, f); + obj2 = new RegExp(obj1); + + reportCompare (obj1 + '', obj2 + '', status); + } + } + + exitFunc ('test'); +} + + +function getStatus(regexp, flag) +{ + return (statprefix + quote(regexp) + statmiddle + flag + statsuffix); +} + + +function quote(text) +{ + return (singlequote + text + singlequote); +} diff --git a/tests/auto/qml/parserstress/tests/ecma_3/RegExp/15.10.4.1-4.js b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/15.10.4.1-4.js new file mode 100644 index 0000000000..3b4245851e --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/15.10.4.1-4.js @@ -0,0 +1,146 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is mozilla.org code. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * pschwartau@netscape.com + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +/* + * Date: 26 November 2000 + * + * + *SUMMARY: Passing a RegExp object to a RegExp() constructor. + *This test arose from Bugzilla bug 61266. The ECMA3 section is: + * + * 15.10.4.1 new RegExp(pattern, flags) + * + * If pattern is an object R whose [[Class]] property is "RegExp" and + * flags is undefined, then let P be the pattern used to construct R + * and let F be the flags used to construct R. If pattern is an object R + * whose [[Class]] property is "RegExp" and flags is not undefined, + * then throw a TypeError exception. Otherwise, let P be the empty string + * if pattern is undefined and ToString(pattern) otherwise, and let F be + * the empty string if flags is undefined and ToString(flags) otherwise. + * + * + *The current test will check the first scenario outlined above: + * + * "pattern" is itself a RegExp object R + * "flags" is undefined + * + * We check that a new RegExp object obj2 defined from these parameters + * is morally the same as the original RegExp object obj1. Of course, they + * can't be equal as objects - so we check their enumerable properties... + * + * In this test, the initial RegExp object obj1 will include a + * flag. This test is identical to test 15.10.4.1-3.js, except that + * here we use this syntax: + * + * obj2 = new RegExp(obj1, undefined); + * + * instead of: + * + * obj2 = new RegExp(obj1); + */ +//----------------------------------------------------------------------------- +var gTestfile = '15.10.4.1-4.js'; +var BUGNUMBER = '61266'; +var summary = 'Passing a RegExp object to a RegExp() constructor'; +var statprefix = 'Applying RegExp() twice to pattern '; +var statmiddle = ' and flag '; +var statsuffix = '; testing property '; +var singlequote = "'"; +var i = -1; var j = -1; var s = ''; +var obj1 = {}; var obj2 = {}; +var status = ''; var actual = ''; var expect = ''; var msg = ''; +var patterns = new Array(); +var flags = new Array(); + + +// various regular expressions to try - +patterns[0] = ''; +patterns[1] = 'abc'; +patterns[2] = '(.*)(3-1)\s\w'; +patterns[3] = '(.*)(...)\\s\\w'; +patterns[4] = '[^A-Za-z0-9_]'; +patterns[5] = '[^\f\n\r\t\v](123.5)([4 - 8]$)'; + +// various flags to try - +flags[0] = 'i'; +flags[1] = 'g'; +flags[2] = 'm'; +flags[3] = undefined; + + + +//------------------------------------------------------------------------------------------------- +test(); +//------------------------------------------------------------------------------------------------- + + +function test() +{ + enterFunc ('test'); + printBugNumber(BUGNUMBER); + printStatus (summary); + + for (i in patterns) + { + s = patterns[i]; + + for (j in flags) + { + f = flags[j]; + status = getStatus(s, f); + obj1 = new RegExp(s, f); + obj2 = new RegExp(obj1, undefined); // see introduction to bug + + reportCompare (obj1 + '', obj2 + '', status); + } + } + + exitFunc ('test'); +} + + +function getStatus(regexp, flag) +{ + return (statprefix + quote(regexp) + statmiddle + flag + statsuffix); +} + + +function quote(text) +{ + return (singlequote + text + singlequote); +} diff --git a/tests/auto/qml/parserstress/tests/ecma_3/RegExp/15.10.4.1-5-n.js b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/15.10.4.1-5-n.js new file mode 100644 index 0000000000..592fb03ac7 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/15.10.4.1-5-n.js @@ -0,0 +1,139 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is mozilla.org code. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * pschwartau@netscape.com + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +var gTestfile = '15.10.4.1-5-n.js'; +/* + * + * Date: 26 November 2000 + * + * + *SUMMARY: Passing a RegExp object to a RegExp() constructor. + *This test arose from Bugzilla bug 61266. The ECMA3 section is: + * + * 15.10.4.1 new RegExp(pattern, flags) + * + * If pattern is an object R whose [[Class]] property is "RegExp" and + * flags is undefined, then let P be the pattern used to construct R + * and let F be the flags used to construct R. If pattern is an object R + * whose [[Class]] property is "RegExp" and flags is not undefined, + * then throw a TypeError exception. Otherwise, let P be the empty string + * if pattern is undefined and ToString(pattern) otherwise, and let F be + * the empty string if flags is undefined and ToString(flags) otherwise. + * + * + *The current test will check the second scenario outlined above: + * + * "pattern" is itself a RegExp object R + * "flags" is NOT undefined + * + * This should throw an exception ... we test for this. + * + */ + +//------------------------------------------------------------------------------------------------- +var BUGNUMBER = '61266'; +var summary = 'Negative test: Passing (RegExp object, flag) to RegExp() constructor'; +var statprefix = 'Passing RegExp object on pattern '; +var statsuffix = '; passing flag '; +var cnFAILURE = 'Expected an exception to be thrown, but none was -'; +var singlequote = "'"; +var i = -1; var j = -1; var s = ''; var f = ''; +var obj1 = {}; var obj2 = {}; +var patterns = new Array(); +var flags = new Array(); + + +// various regular expressions to try - +patterns[0] = ''; +patterns[1] = 'abc'; +patterns[2] = '(.*)(3-1)\s\w'; +patterns[3] = '(.*)(...)\\s\\w'; +patterns[4] = '[^A-Za-z0-9_]'; +patterns[5] = '[^\f\n\r\t\v](123.5)([4 - 8]$)'; + +// various flags to try - +flags[0] = 'i'; +flags[1] = 'g'; +flags[2] = 'm'; + + +DESCRIPTION = "Negative test: Passing (RegExp object, flag) to RegExp() constructor" + EXPECTED = "error"; + + +//------------------------------------------------------------------------------------------------- +test(); +//------------------------------------------------------------------------------------------------- + + +function test() +{ + enterFunc ('test'); + printBugNumber(BUGNUMBER); + printStatus (summary); + + for (i in patterns) + { + s = patterns[i]; + + for (j in flags) + { + f = flags[j]; + printStatus(getStatus(s, f)); + obj1 = new RegExp(s, f); + obj2 = new RegExp(obj1, f); // this should cause an exception + + // WE SHOULD NEVER REACH THIS POINT - + reportCompare('PASS', 'FAIL', cnFAILURE); + } + } + + exitFunc ('test'); +} + + +function getStatus(regexp, flag) +{ + return (statprefix + quote(regexp) + statsuffix + flag); +} + + +function quote(text) +{ + return (singlequote + text + singlequote); +} diff --git a/tests/auto/qml/parserstress/tests/ecma_3/RegExp/15.10.6.2-1.js b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/15.10.6.2-1.js new file mode 100644 index 0000000000..8203da4967 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/15.10.6.2-1.js @@ -0,0 +1,140 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is mozilla.org code. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * pschwartau@netscape.com + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +/* + * Date: 23 October 2001 + * + * SUMMARY: Testing regexps with the global flag set. + * NOT every substring fitting the given pattern will be matched. + * The parent string is CONSUMED as successive matches are found. + * + * From the ECMA-262 Final spec: + * + * 15.10.6.2 RegExp.prototype.exec(string) + * Performs a regular expression match of string against the regular + * expression and returns an Array object containing the results of + * the match, or null if the string did not match. + * + * The string ToString(string) is searched for an occurrence of the + * regular expression pattern as follows: + * + * 1. Let S be the value of ToString(string). + * 2. Let length be the length of S. + * 3. Let lastIndex be the value of the lastIndex property. + * 4. Let i be the value of ToInteger(lastIndex). + * 5. If the global property is false, let i = 0. + * 6. If i < 0 or i > length then set lastIndex to 0 and return null. + * 7. Call [[Match]], giving it the arguments S and i. + * If [[Match]] returned failure, go to step 8; + * otherwise let r be its State result and go to step 10. + * 8. Let i = i+1. + * 9. Go to step 6. + * 10. Let e be r's endIndex value. + * 11. If the global property is true, set lastIndex to e. + * + * etc. + * + * + * So when the global flag is set, |lastIndex| is incremented every time + * there is a match; not from i to i+1, but from i to "endIndex" e: + * + * e = (index of last input character matched so far by the pattern) + 1 + * + * Thus in the example below, the first endIndex e occurs after the + * first match 'a b'. The next match will begin AFTER this, and so + * will NOT be 'b c', but rather 'c d'. Similarly, 'd e' won't be matched. + */ +//----------------------------------------------------------------------------- +var gTestfile = '15.10.6.2-1.js'; +var i = 0; +var BUGNUMBER = '(none)'; +var summary = 'Testing regexps with the global flag set'; +var status = ''; +var statusmessages = new Array(); +var pattern = ''; +var patterns = new Array(); +var string = ''; +var strings = new Array(); +var actualmatch = ''; +var actualmatches = new Array(); +var expectedmatch = ''; +var expectedmatches = new Array(); + + +status = inSection(1); +string = 'a b c d e'; +pattern = /\w\s\w/g; +actualmatch = string.match(pattern); +expectedmatch = ['a b','c d']; // see above explanation - +addThis(); + + +status = inSection(2); +string = '12345678'; +pattern = /\d\d\d/g; +actualmatch = string.match(pattern); +expectedmatch = ['123','456']; +addThis(); + + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + + + +function addThis() +{ + statusmessages[i] = status; + patterns[i] = pattern; + strings[i] = string; + actualmatches[i] = actualmatch; + expectedmatches[i] = expectedmatch; + i++; +} + + +function test() +{ + enterFunc ('test'); + printBugNumber(BUGNUMBER); + printStatus (summary); + testRegExp(statusmessages, patterns, strings, actualmatches, expectedmatches); + exitFunc ('test'); +} diff --git a/tests/auto/qml/parserstress/tests/ecma_3/RegExp/15.10.6.2-2.js b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/15.10.6.2-2.js new file mode 100644 index 0000000000..e6fd6c6311 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/15.10.6.2-2.js @@ -0,0 +1,367 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is JavaScript Engine testing utilities. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corp. + * Portions created by the Initial Developer are Copyright (C) 2002 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * pschwartau@netscape.com + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +/* + * + * Date: 18 Feb 2002 + * SUMMARY: Testing re.exec(str) when re.lastIndex is < 0 or > str.length + * + * Case 1: If re has the global flag set, then re(str) should be null + * Case 2: If re doesn't have this set, then re(str) should be unaffected + * + * See http://bugzilla.mozilla.org/show_bug.cgi?id=76717 + * + * + * From the ECMA-262 Final spec: + * + * 15.10.6.2 RegExp.prototype.exec(string) + * Performs a regular expression match of string against the regular + * expression and returns an Array object containing the results of + * the match, or null if the string did not match. + * + * The string ToString(string) is searched for an occurrence of the + * regular expression pattern as follows: + * + * 1. Let S be the value of ToString(string). + * 2. Let length be the length of S. + * 3. Let lastIndex be the value of the lastIndex property. + * 4. Let i be the value of ToInteger(lastIndex). + * 5. If the global property is false, let i = 0. + * 6. If i < 0 or i > length then set lastIndex to 0 and return null. + * 7. Call [[Match]], giving it the arguments S and i. + * If [[Match]] returned failure, go to step 8; + * otherwise let r be its State result and go to step 10. + * 8. Let i = i+1. + * 9. Go to step 6. + * 10. Let e be r's endIndex value. + * 11. If the global property is true, set lastIndex to e. + * + * etc. + * + * + * So: + * + * A. If the global flag is not set, |lastIndex| is set to 0 + * before the match is attempted; thus the match is unaffected. + * + * B. If the global flag IS set and re.lastIndex is >= 0 and <= str.length, + * |lastIndex| is incremented every time there is a match; not from + * i to i+1, but from i to "endIndex" e: + * + * e = (index of last input character matched so far by the pattern) + 1 + * + * The match is then attempted from this position in the string (Step 7). + * + * C. When the global flag IS set and re.lastIndex is < 0 or > str.length, + * |lastIndex| is set to 0 and the match returns null. + * + * + * Note the |lastIndex| property is writeable, and may be set arbitrarily + * by the programmer - and we will do that below. + * + */ +//----------------------------------------------------------------------------- +var gTestfile = '15.10.6.2-2.js'; +var i = 0; +var BUGNUMBER = 76717; +var summary = 'Testing re.exec(str) when re.lastIndex is < 0 or > str.length'; +var status = ''; +var statusmessages = new Array(); +var pattern = ''; +var patterns = new Array(); +var string = ''; +var strings = new Array(); +var actualmatch = ''; +var actualmatches = new Array(); +var expectedmatch = ''; +var expectedmatches = new Array(); + + +/****************************************************************************** + * + * Case 1 : when the global flag is set - + * + *****************************************************************************/ +pattern = /abc/gi; +string = 'AbcaBcabC'; + +status = inSection(1); +actualmatch = pattern.exec(string); +expectedmatch = Array('Abc'); +addThis(); + +status = inSection(2); +actualmatch = pattern.exec(string); +expectedmatch = Array('aBc'); +addThis(); + +status = inSection(3); +actualmatch = pattern.exec(string); +expectedmatch = Array('abC'); +addThis(); + +/* + * At this point |lastIndex| is > string.length, so the match should be null - + */ +status = inSection(4); +actualmatch = pattern.exec(string); +expectedmatch = null; +addThis(); + +/* + * Now let's set |lastIndex| to -1, so the match should again be null - + */ +status = inSection(5); +pattern.lastIndex = -1; +actualmatch = pattern.exec(string); +expectedmatch = null; +addThis(); + +/* + * Now try some edge-case values. Thanks to the work done in + * http://bugzilla.mozilla.org/show_bug.cgi?id=124339, |lastIndex| + * is now stored as a double instead of a uint32 (unsigned integer). + * + * Note 2^32 -1 is the upper bound for uint32's, but doubles can go + * all the way up to Number.MAX_VALUE. So that's why we need cases + * between those two numbers. + */ +status = inSection(6); +pattern.lastIndex = Math.pow(2,32); +actualmatch = pattern.exec(string); +expectedmatch = null; +addThis(); + +status = inSection(7); +pattern.lastIndex = -Math.pow(2,32); +actualmatch = pattern.exec(string); +expectedmatch = null; +addThis(); + +status = inSection(8); +pattern.lastIndex = Math.pow(2,32) + 1; +actualmatch = pattern.exec(string); +expectedmatch = null; +addThis(); + +status = inSection(9); +pattern.lastIndex = -(Math.pow(2,32) + 1); +actualmatch = pattern.exec(string); +expectedmatch = null; +addThis(); + +status = inSection(10); +pattern.lastIndex = Math.pow(2,32) * 2; +actualmatch = pattern.exec(string); +expectedmatch = null; +addThis(); + +status = inSection(11); +pattern.lastIndex = -Math.pow(2,32) * 2; +actualmatch = pattern.exec(string); +expectedmatch = null; +addThis(); + +status = inSection(12); +pattern.lastIndex = Math.pow(2,40); +actualmatch = pattern.exec(string); +expectedmatch = null; +addThis(); + +status = inSection(13); +pattern.lastIndex = -Math.pow(2,40); +actualmatch = pattern.exec(string); +expectedmatch = null; +addThis(); + +status = inSection(14); +pattern.lastIndex = Number.MAX_VALUE; +actualmatch = pattern.exec(string); +expectedmatch = null; +addThis(); + +status = inSection(15); +pattern.lastIndex = -Number.MAX_VALUE; +actualmatch = pattern.exec(string); +expectedmatch = null; +addThis(); + + + +/****************************************************************************** + * + * Case 2: repeat all the above cases WITHOUT the global flag set. + * According to EMCA. |lastIndex| should get set to 0 before the match. + * + * Therefore re.exec(str) should be unaffected; thus our expected values + * below are now DIFFERENT when |lastIndex| is < 0 or > str.length + * + *****************************************************************************/ + +pattern = /abc/i; +string = 'AbcaBcabC'; + +status = inSection(16); +actualmatch = pattern.exec(string); +expectedmatch = Array('Abc'); +addThis(); + +status = inSection(17); +actualmatch = pattern.exec(string); +expectedmatch = Array('Abc'); // NOT Array('aBc') as before - +addThis(); + +status = inSection(18); +actualmatch = pattern.exec(string); +expectedmatch = Array('Abc'); // NOT Array('abC') as before - +addThis(); + +/* + * At this point above, |lastIndex| WAS > string.length, but not here - + */ +status = inSection(19); +actualmatch = pattern.exec(string); +expectedmatch = Array('Abc') // NOT null as before - + addThis(); + +/* + * Now let's set |lastIndex| to -1 + */ +status = inSection(20); +pattern.lastIndex = -1; +actualmatch = pattern.exec(string); +expectedmatch = Array('Abc') // NOT null as before - + addThis(); + +/* + * Now try some edge-case values. Thanks to the work done in + * http://bugzilla.mozilla.org/show_bug.cgi?id=124339, |lastIndex| + * is now stored as a double instead of a uint32 (unsigned integer). + * + * Note 2^32 -1 is the upper bound for uint32's, but doubles can go + * all the way up to Number.MAX_VALUE. So that's why we need cases + * between those two numbers. + */ +status = inSection(21); +pattern.lastIndex = Math.pow(2,32); +actualmatch = pattern.exec(string); +expectedmatch = Array('Abc') // NOT null as before - + addThis(); + +status = inSection(22); +pattern.lastIndex = -Math.pow(2,32); +actualmatch = pattern.exec(string); +expectedmatch = Array('Abc') // NOT null as before - + addThis(); + +status = inSection(23); +pattern.lastIndex = Math.pow(2,32) + 1; +actualmatch = pattern.exec(string); +expectedmatch = Array('Abc') // NOT null as before - + addThis(); + +status = inSection(24); +pattern.lastIndex = -(Math.pow(2,32) + 1); +actualmatch = pattern.exec(string); +expectedmatch = Array('Abc') // NOT null as before - + addThis(); + +status = inSection(25); +pattern.lastIndex = Math.pow(2,32) * 2; +actualmatch = pattern.exec(string); +expectedmatch = Array('Abc') // NOT null as before - + addThis(); + +status = inSection(26); +pattern.lastIndex = -Math.pow(2,32) * 2; +actualmatch = pattern.exec(string); +expectedmatch = Array('Abc') // NOT null as before - + addThis(); + +status = inSection(27); +pattern.lastIndex = Math.pow(2,40); +actualmatch = pattern.exec(string); +expectedmatch = Array('Abc') // NOT null as before -; + addThis(); + +status = inSection(28); +pattern.lastIndex = -Math.pow(2,40); +actualmatch = pattern.exec(string); +expectedmatch = Array('Abc') // NOT null as before - + addThis(); + +status = inSection(29); +pattern.lastIndex = Number.MAX_VALUE; +actualmatch = pattern.exec(string); +expectedmatch = Array('Abc') // NOT null as before - + addThis(); + +status = inSection(30); +pattern.lastIndex = -Number.MAX_VALUE; +actualmatch = pattern.exec(string); +expectedmatch = Array('Abc') // NOT null as before - + addThis(); + + + + +//------------------------------------------------------------------------------------------------- +test(); +//------------------------------------------------------------------------------------------------- + + + +function addThis() +{ + statusmessages[i] = status; + patterns[i] = pattern; + strings[i] = string; + actualmatches[i] = actualmatch; + expectedmatches[i] = expectedmatch; + i++; +} + + +function test() +{ + enterFunc ('test'); + printBugNumber(BUGNUMBER); + printStatus (summary); + testRegExp(statusmessages, patterns, strings, actualmatches, expectedmatches); + exitFunc ('test'); +} diff --git a/tests/auto/qml/parserstress/tests/ecma_3/RegExp/browser.js b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/browser.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/auto/qml/parserstress/tests/ecma_3/RegExp/octal-001.js b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/octal-001.js new file mode 100644 index 0000000000..f35724e47b --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/octal-001.js @@ -0,0 +1,136 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is JavaScript Engine testing utilities. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corp. + * Portions created by the Initial Developer are Copyright (C) 2002 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * pschwartau@netscape.com + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +/* + * + * Date: 18 July 2002 + * SUMMARY: Testing octal sequences in regexps + * See http://bugzilla.mozilla.org/show_bug.cgi?id=141078 + * + */ +//----------------------------------------------------------------------------- +var gTestfile = 'octal-001.js'; +var i = 0; +var BUGNUMBER = 141078; +var summary = 'Testing octal sequences in regexps'; +var status = ''; +var statusmessages = new Array(); +var pattern = ''; +var patterns = new Array(); +var string = ''; +var strings = new Array(); +var actualmatch = ''; +var actualmatches = new Array(); +var expectedmatch = ''; +var expectedmatches = new Array(); + + +status = inSection(1); +pattern = /\240/; +string = 'abc'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +/* + * In the following sections, we test the octal escape sequence '\052'. + * This is character code 42, representing the asterisk character '*'. + * The Unicode escape for it would be '\u002A', the hex escape '\x2A'. + */ +status = inSection(2); +pattern = /ab\052c/; +string = 'ab*c'; +actualmatch = string.match(pattern); +expectedmatch = Array('ab*c'); +addThis(); + +status = inSection(3); +pattern = /ab\052*c/; +string = 'abc'; +actualmatch = string.match(pattern); +expectedmatch = Array('abc'); +addThis(); + +status = inSection(4); +pattern = /ab(\052)+c/; +string = 'ab****c'; +actualmatch = string.match(pattern); +expectedmatch = Array('ab****c', '*'); +addThis(); + +status = inSection(5); +pattern = /ab((\052)+)c/; +string = 'ab****c'; +actualmatch = string.match(pattern); +expectedmatch = Array('ab****c', '****', '*'); +addThis(); + +status = inSection(6); +pattern = /(?:\052)c/; +string = 'ab****c'; +actualmatch = string.match(pattern); +expectedmatch = Array('*c'); +addThis(); + + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + + + +function addThis() +{ + statusmessages[i] = status; + patterns[i] = pattern; + strings[i] = string; + actualmatches[i] = actualmatch; + expectedmatches[i] = expectedmatch; + i++; +} + + +function test() +{ + enterFunc('test'); + printBugNumber(BUGNUMBER); + printStatus(summary); + testRegExp(statusmessages, patterns, strings, actualmatches, expectedmatches); + exitFunc ('test'); +} diff --git a/tests/auto/qml/parserstress/tests/ecma_3/RegExp/octal-002.js b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/octal-002.js new file mode 100644 index 0000000000..401ad43c11 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/octal-002.js @@ -0,0 +1,218 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is JavaScript Engine testing utilities. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corp. + * Portions created by the Initial Developer are Copyright (C) 2002 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * pschwartau@netscape.com + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +/* + * + * Date: 31 July 2002 + * SUMMARY: Testing regexps containing octal escape sequences + * This is an elaboration of mozilla/js/tests/ecma_2/RegExp/octal-003.js + * + * See http://bugzilla.mozilla.org/show_bug.cgi?id=141078 + * for a reference on octal escape sequences in regexps. + * + * NOTE: + * We will use the identities '\011' === '\u0009' === '\x09' === '\t' + * + * The first is an octal escape sequence (\(0-3)OO; O an octal digit). + * See ECMA-262 Edition 2, Section 7.7.4 "String Literals". These were + * dropped in Edition 3 but we support them for backward compatibility. + * + * The second is a Unicode escape sequence (\uHHHH; H a hex digit). + * Since octal 11 = hex 9, the two escapes define the same character. + * + * The third is a hex escape sequence (\xHH; H a hex digit). + * Since hex 09 = hex 0009, this defines the same character. + * + * The fourth is the familiar escape sequence for a horizontal tab, + * defined in the ECMA spec as having Unicode value \u0009. + */ +//----------------------------------------------------------------------------- +var gTestfile = 'octal-002.js'; +var i = 0; +var BUGNUMBER = 141078; +var summary = 'Testing regexps containing octal escape sequences'; +var status = ''; +var statusmessages = new Array(); +var pattern = ''; +var patterns = new Array(); +var string = ''; +var strings = new Array(); +var actualmatch = ''; +var actualmatches = new Array(); +var expectedmatch = ''; +var expectedmatches = new Array(); + + +/* + * Test a string containing the null character '\0' followed by the string '11' + * + * 'a' + String.fromCharCode(0) + '11'; + * + * Note we can't simply write 'a\011', because '\011' would be interpreted + * as the octal escape sequence for the tab character (see above). + * + * We should get no match from the regexp /.\011/, because it should be + * looking for the octal escape sequence \011, i.e. the tab character - + * + */ +status = inSection(1); +pattern = /.\011/; +string = 'a' + String.fromCharCode(0) + '11'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + + +/* + * Try same thing with 'xx' in place of '11'. + * + * Should get a match now, because the octal escape sequence in the regexp + * has been reduced from \011 to \0, and '\0' is present in the string - + */ +status = inSection(2); +pattern = /.\0xx/; +string = 'a' + String.fromCharCode(0) + 'xx'; +actualmatch = string.match(pattern); +expectedmatch = Array(string); +addThis(); + + +/* + * Same thing; don't use |String.fromCharCode(0)| this time. + * There is no ambiguity in '\0xx': it is the null character + * followed by two x's, no other interpretation is possible. + */ +status = inSection(3); +pattern = /.\0xx/; +string = 'a\0xx'; +actualmatch = string.match(pattern); +expectedmatch = Array(string); +addThis(); + + +/* + * This one should produce a match. The two-character string + * 'a' + '\011' is duplicated in the pattern and test string: + */ +status = inSection(4); +pattern = /.\011/; +string = 'a\011'; +actualmatch = string.match(pattern); +expectedmatch = Array(string); +addThis(); + + +/* + * Same as above, only now, for the second character of the string, + * use the Unicode escape '\u0009' instead of the octal escape '\011' + */ +status = inSection(5); +pattern = /.\011/; +string = 'a\u0009'; +actualmatch = string.match(pattern); +expectedmatch = Array(string); +addThis(); + + +/* + * Same as above, only now for the second character of the string, + * use the hex escape '\x09' instead of the octal escape '\011' + */ +status = inSection(6); +pattern = /.\011/; +string = 'a\x09'; +actualmatch = string.match(pattern); +expectedmatch = Array(string); +addThis(); + + +/* + * Same as above, only now for the second character of the string, + * use the escape '\t' instead of the octal escape '\011' + */ +status = inSection(7); +pattern = /.\011/; +string = 'a\t'; +actualmatch = string.match(pattern); +expectedmatch = Array(string); +addThis(); + + +/* + * Return to the string from Section 1. + * + * Unlike Section 1, use the RegExp() function to create the + * regexp pattern: null character followed by the string '11'. + * + * Since this is exactly what the string is, we should get a match - + */ +status = inSection(8); +string = 'a' + String.fromCharCode(0) + '11'; +pattern = RegExp(string); +actualmatch = string.match(pattern); +expectedmatch = Array(string); +addThis(); + + + + +//------------------------------------------------------------------------------------------------- +test(); +//------------------------------------------------------------------------------------------------- + + + +function addThis() +{ + statusmessages[i] = status; + patterns[i] = pattern; + strings[i] = string; + actualmatches[i] = actualmatch; + expectedmatches[i] = expectedmatch; + i++; +} + + +function test() +{ + enterFunc ('test'); + printBugNumber(BUGNUMBER); + printStatus (summary); + testRegExp(statusmessages, patterns, strings, actualmatches, expectedmatches); + exitFunc ('test'); +} diff --git a/tests/auto/qml/parserstress/tests/ecma_3/RegExp/perlstress-001.js b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/perlstress-001.js new file mode 100644 index 0000000000..0b27529a32 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/perlstress-001.js @@ -0,0 +1,3230 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is JavaScript Engine testing utilities. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corp. + * Portions created by the Initial Developer are Copyright (C) 2002 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * pschwartau@netscape.com, rogerl@netscape.com + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +/* + * + * Date: 2002-07-07 + * SUMMARY: Testing JS RegExp engine against Perl 5 RegExp engine. + * Adjust cnLBOUND, cnUBOUND below to restrict which sections are tested. + * + * This test was created by running various patterns and strings through the + * Perl 5 RegExp engine. We saved the results below to test the JS engine. + * + * NOTE: ECMA/JS and Perl do differ on certain points. We have either commented + * out such sections altogether, or modified them to fit what we expect from JS. + * + * EXAMPLES: + * + * - In JS, regexp captures (/(a) etc./) must hold |undefined| if not used. + * See http://bugzilla.mozilla.org/show_bug.cgi?id=123437. + * By contrast, in Perl, unmatched captures hold the empty string. + * We have modified such sections accordingly. Example: + + pattern = /^([^a-z])|(\^)$/; + string = '.'; + actualmatch = string.match(pattern); + //expectedmatch = Array('.', '.', ''); <<<--- Perl + expectedmatch = Array('.', '.', undefined); <<<--- JS + addThis(); + + + * - In JS, you can't refer to a capture before it's encountered & completed + * + * - Perl supports ] & ^] inside a [], ECMA does not + * + * - ECMA does support (?: (?= and (?! operators, but doesn't support (?< etc. + * + * - ECMA doesn't support (?imsx or (?-imsx + * + * - ECMA doesn't support (?(condition) + * + * - Perl has \Z has end-of-line, ECMA doesn't + * + * - In ECMA, ^ matches only the empty string before the first character + * + * - In ECMA, $ matches only the empty string at end of input (unless multiline) + * + * - ECMA spec says that each atom in a range must be a single character + * + * - ECMA doesn't support \A + * + * - ECMA doesn't have rules for [: + * + */ +//----------------------------------------------------------------------------- +var gTestfile = 'perlstress-001.js'; +var i = 0; +var BUGNUMBER = 85721; +var summary = 'Testing regular expression edge cases'; +var cnSingleSpace = ' '; +var status = ''; +var statusmessages = new Array(); +var pattern = ''; +var patterns = new Array(); +var string = ''; +var strings = new Array(); +var actualmatch = ''; +var actualmatches = new Array(); +var expectedmatch = ''; +var expectedmatches = new Array(); +var cnLBOUND = 1; +var cnUBOUND = 1000; + + +status = inSection(1); +pattern = /abc/; +string = 'abc'; +actualmatch = string.match(pattern); +expectedmatch = Array('abc'); +addThis(); + +status = inSection(2); +pattern = /abc/; +string = 'xabcy'; +actualmatch = string.match(pattern); +expectedmatch = Array('abc'); +addThis(); + +status = inSection(3); +pattern = /abc/; +string = 'ababc'; +actualmatch = string.match(pattern); +expectedmatch = Array('abc'); +addThis(); + +status = inSection(4); +pattern = /ab*c/; +string = 'abc'; +actualmatch = string.match(pattern); +expectedmatch = Array('abc'); +addThis(); + +status = inSection(5); +pattern = /ab*bc/; +string = 'abc'; +actualmatch = string.match(pattern); +expectedmatch = Array('abc'); +addThis(); + +status = inSection(6); +pattern = /ab*bc/; +string = 'abbc'; +actualmatch = string.match(pattern); +expectedmatch = Array('abbc'); +addThis(); + +status = inSection(7); +pattern = /ab*bc/; +string = 'abbbbc'; +actualmatch = string.match(pattern); +expectedmatch = Array('abbbbc'); +addThis(); + +status = inSection(8); +pattern = /.{1}/; +string = 'abbbbc'; +actualmatch = string.match(pattern); +expectedmatch = Array('a'); +addThis(); + +status = inSection(9); +pattern = /.{3,4}/; +string = 'abbbbc'; +actualmatch = string.match(pattern); +expectedmatch = Array('abbb'); +addThis(); + +status = inSection(10); +pattern = /ab{0,}bc/; +string = 'abbbbc'; +actualmatch = string.match(pattern); +expectedmatch = Array('abbbbc'); +addThis(); + +status = inSection(11); +pattern = /ab+bc/; +string = 'abbc'; +actualmatch = string.match(pattern); +expectedmatch = Array('abbc'); +addThis(); + +status = inSection(12); +pattern = /ab+bc/; +string = 'abbbbc'; +actualmatch = string.match(pattern); +expectedmatch = Array('abbbbc'); +addThis(); + +status = inSection(13); +pattern = /ab{1,}bc/; +string = 'abbbbc'; +actualmatch = string.match(pattern); +expectedmatch = Array('abbbbc'); +addThis(); + +status = inSection(14); +pattern = /ab{1,3}bc/; +string = 'abbbbc'; +actualmatch = string.match(pattern); +expectedmatch = Array('abbbbc'); +addThis(); + +status = inSection(15); +pattern = /ab{3,4}bc/; +string = 'abbbbc'; +actualmatch = string.match(pattern); +expectedmatch = Array('abbbbc'); +addThis(); + +status = inSection(16); +pattern = /ab?bc/; +string = 'abbc'; +actualmatch = string.match(pattern); +expectedmatch = Array('abbc'); +addThis(); + +status = inSection(17); +pattern = /ab?bc/; +string = 'abc'; +actualmatch = string.match(pattern); +expectedmatch = Array('abc'); +addThis(); + +status = inSection(18); +pattern = /ab{0,1}bc/; +string = 'abc'; +actualmatch = string.match(pattern); +expectedmatch = Array('abc'); +addThis(); + +status = inSection(19); +pattern = /ab?c/; +string = 'abc'; +actualmatch = string.match(pattern); +expectedmatch = Array('abc'); +addThis(); + +status = inSection(20); +pattern = /ab{0,1}c/; +string = 'abc'; +actualmatch = string.match(pattern); +expectedmatch = Array('abc'); +addThis(); + +status = inSection(21); +pattern = /^abc$/; +string = 'abc'; +actualmatch = string.match(pattern); +expectedmatch = Array('abc'); +addThis(); + +status = inSection(22); +pattern = /^abc/; +string = 'abcc'; +actualmatch = string.match(pattern); +expectedmatch = Array('abc'); +addThis(); + +status = inSection(23); +pattern = /abc$/; +string = 'aabc'; +actualmatch = string.match(pattern); +expectedmatch = Array('abc'); +addThis(); + +status = inSection(24); +pattern = /^/; +string = 'abc'; +actualmatch = string.match(pattern); +expectedmatch = Array(''); +addThis(); + +status = inSection(25); +pattern = /$/; +string = 'abc'; +actualmatch = string.match(pattern); +expectedmatch = Array(''); +addThis(); + +status = inSection(26); +pattern = /a.c/; +string = 'abc'; +actualmatch = string.match(pattern); +expectedmatch = Array('abc'); +addThis(); + +status = inSection(27); +pattern = /a.c/; +string = 'axc'; +actualmatch = string.match(pattern); +expectedmatch = Array('axc'); +addThis(); + +status = inSection(28); +pattern = /a.*c/; +string = 'axyzc'; +actualmatch = string.match(pattern); +expectedmatch = Array('axyzc'); +addThis(); + +status = inSection(29); +pattern = /a[bc]d/; +string = 'abd'; +actualmatch = string.match(pattern); +expectedmatch = Array('abd'); +addThis(); + +status = inSection(30); +pattern = /a[b-d]e/; +string = 'ace'; +actualmatch = string.match(pattern); +expectedmatch = Array('ace'); +addThis(); + +status = inSection(31); +pattern = /a[b-d]/; +string = 'aac'; +actualmatch = string.match(pattern); +expectedmatch = Array('ac'); +addThis(); + +status = inSection(32); +pattern = /a[-b]/; +string = 'a-'; +actualmatch = string.match(pattern); +expectedmatch = Array('a-'); +addThis(); + +status = inSection(33); +pattern = /a[b-]/; +string = 'a-'; +actualmatch = string.match(pattern); +expectedmatch = Array('a-'); +addThis(); + +status = inSection(34); +pattern = /a]/; +string = 'a]'; +actualmatch = string.match(pattern); +expectedmatch = Array('a]'); +addThis(); + +/* Perl supports ] & ^] inside a [], ECMA does not + pattern = /a[]]b/; + status = inSection(35); + string = 'a]b'; + actualmatch = string.match(pattern); + expectedmatch = Array('a]b'); + addThis(); +*/ + +status = inSection(36); +pattern = /a[^bc]d/; +string = 'aed'; +actualmatch = string.match(pattern); +expectedmatch = Array('aed'); +addThis(); + +status = inSection(37); +pattern = /a[^-b]c/; +string = 'adc'; +actualmatch = string.match(pattern); +expectedmatch = Array('adc'); +addThis(); + +/* Perl supports ] & ^] inside a [], ECMA does not + status = inSection(38); + pattern = /a[^]b]c/; + string = 'adc'; + actualmatch = string.match(pattern); + expectedmatch = Array('adc'); + addThis(); +*/ + +status = inSection(39); +pattern = /\ba\b/; +string = 'a-'; +actualmatch = string.match(pattern); +expectedmatch = Array('a'); +addThis(); + +status = inSection(40); +pattern = /\ba\b/; +string = '-a'; +actualmatch = string.match(pattern); +expectedmatch = Array('a'); +addThis(); + +status = inSection(41); +pattern = /\ba\b/; +string = '-a-'; +actualmatch = string.match(pattern); +expectedmatch = Array('a'); +addThis(); + +status = inSection(42); +pattern = /\By\b/; +string = 'xy'; +actualmatch = string.match(pattern); +expectedmatch = Array('y'); +addThis(); + +status = inSection(43); +pattern = /\by\B/; +string = 'yz'; +actualmatch = string.match(pattern); +expectedmatch = Array('y'); +addThis(); + +status = inSection(44); +pattern = /\By\B/; +string = 'xyz'; +actualmatch = string.match(pattern); +expectedmatch = Array('y'); +addThis(); + +status = inSection(45); +pattern = /\w/; +string = 'a'; +actualmatch = string.match(pattern); +expectedmatch = Array('a'); +addThis(); + +status = inSection(46); +pattern = /\W/; +string = '-'; +actualmatch = string.match(pattern); +expectedmatch = Array('-'); +addThis(); + +status = inSection(47); +pattern = /a\Sb/; +string = 'a-b'; +actualmatch = string.match(pattern); +expectedmatch = Array('a-b'); +addThis(); + +status = inSection(48); +pattern = /\d/; +string = '1'; +actualmatch = string.match(pattern); +expectedmatch = Array('1'); +addThis(); + +status = inSection(49); +pattern = /\D/; +string = '-'; +actualmatch = string.match(pattern); +expectedmatch = Array('-'); +addThis(); + +status = inSection(50); +pattern = /[\w]/; +string = 'a'; +actualmatch = string.match(pattern); +expectedmatch = Array('a'); +addThis(); + +status = inSection(51); +pattern = /[\W]/; +string = '-'; +actualmatch = string.match(pattern); +expectedmatch = Array('-'); +addThis(); + +status = inSection(52); +pattern = /a[\S]b/; +string = 'a-b'; +actualmatch = string.match(pattern); +expectedmatch = Array('a-b'); +addThis(); + +status = inSection(53); +pattern = /[\d]/; +string = '1'; +actualmatch = string.match(pattern); +expectedmatch = Array('1'); +addThis(); + +status = inSection(54); +pattern = /[\D]/; +string = '-'; +actualmatch = string.match(pattern); +expectedmatch = Array('-'); +addThis(); + +status = inSection(55); +pattern = /ab|cd/; +string = 'abc'; +actualmatch = string.match(pattern); +expectedmatch = Array('ab'); +addThis(); + +status = inSection(56); +pattern = /ab|cd/; +string = 'abcd'; +actualmatch = string.match(pattern); +expectedmatch = Array('ab'); +addThis(); + +status = inSection(57); +pattern = /()ef/; +string = 'def'; +actualmatch = string.match(pattern); +expectedmatch = Array('ef', ''); +addThis(); + +status = inSection(58); +pattern = /a\(b/; +string = 'a(b'; +actualmatch = string.match(pattern); +expectedmatch = Array('a(b'); +addThis(); + +status = inSection(59); +pattern = /a\(*b/; +string = 'ab'; +actualmatch = string.match(pattern); +expectedmatch = Array('ab'); +addThis(); + +status = inSection(60); +pattern = /a\(*b/; +string = 'a((b'; +actualmatch = string.match(pattern); +expectedmatch = Array('a((b'); +addThis(); + +status = inSection(61); +pattern = /a\\b/; +string = 'a\\b'; +actualmatch = string.match(pattern); +expectedmatch = Array('a\\b'); +addThis(); + +status = inSection(62); +pattern = /((a))/; +string = 'abc'; +actualmatch = string.match(pattern); +expectedmatch = Array('a', 'a', 'a'); +addThis(); + +status = inSection(63); +pattern = /(a)b(c)/; +string = 'abc'; +actualmatch = string.match(pattern); +expectedmatch = Array('abc', 'a', 'c'); +addThis(); + +status = inSection(64); +pattern = /a+b+c/; +string = 'aabbabc'; +actualmatch = string.match(pattern); +expectedmatch = Array('abc'); +addThis(); + +status = inSection(65); +pattern = /a{1,}b{1,}c/; +string = 'aabbabc'; +actualmatch = string.match(pattern); +expectedmatch = Array('abc'); +addThis(); + +status = inSection(66); +pattern = /a.+?c/; +string = 'abcabc'; +actualmatch = string.match(pattern); +expectedmatch = Array('abc'); +addThis(); + +status = inSection(67); +pattern = /(a+|b)*/; +string = 'ab'; +actualmatch = string.match(pattern); +expectedmatch = Array('ab', 'b'); +addThis(); + +status = inSection(68); +pattern = /(a+|b){0,}/; +string = 'ab'; +actualmatch = string.match(pattern); +expectedmatch = Array('ab', 'b'); +addThis(); + +status = inSection(69); +pattern = /(a+|b)+/; +string = 'ab'; +actualmatch = string.match(pattern); +expectedmatch = Array('ab', 'b'); +addThis(); + +status = inSection(70); +pattern = /(a+|b){1,}/; +string = 'ab'; +actualmatch = string.match(pattern); +expectedmatch = Array('ab', 'b'); +addThis(); + +status = inSection(71); +pattern = /(a+|b)?/; +string = 'ab'; +actualmatch = string.match(pattern); +expectedmatch = Array('a', 'a'); +addThis(); + +status = inSection(72); +pattern = /(a+|b){0,1}/; +string = 'ab'; +actualmatch = string.match(pattern); +expectedmatch = Array('a', 'a'); +addThis(); + +status = inSection(73); +pattern = /[^ab]*/; +string = 'cde'; +actualmatch = string.match(pattern); +expectedmatch = Array('cde'); +addThis(); + +status = inSection(74); +pattern = /([abc])*d/; +string = 'abbbcd'; +actualmatch = string.match(pattern); +expectedmatch = Array('abbbcd', 'c'); +addThis(); + +status = inSection(75); +pattern = /([abc])*bcd/; +string = 'abcd'; +actualmatch = string.match(pattern); +expectedmatch = Array('abcd', 'a'); +addThis(); + +status = inSection(76); +pattern = /a|b|c|d|e/; +string = 'e'; +actualmatch = string.match(pattern); +expectedmatch = Array('e'); +addThis(); + +status = inSection(77); +pattern = /(a|b|c|d|e)f/; +string = 'ef'; +actualmatch = string.match(pattern); +expectedmatch = Array('ef', 'e'); +addThis(); + +status = inSection(78); +pattern = /abcd*efg/; +string = 'abcdefg'; +actualmatch = string.match(pattern); +expectedmatch = Array('abcdefg'); +addThis(); + +status = inSection(79); +pattern = /ab*/; +string = 'xabyabbbz'; +actualmatch = string.match(pattern); +expectedmatch = Array('ab'); +addThis(); + +status = inSection(80); +pattern = /ab*/; +string = 'xayabbbz'; +actualmatch = string.match(pattern); +expectedmatch = Array('a'); +addThis(); + +status = inSection(81); +pattern = /(ab|cd)e/; +string = 'abcde'; +actualmatch = string.match(pattern); +expectedmatch = Array('cde', 'cd'); +addThis(); + +status = inSection(82); +pattern = /[abhgefdc]ij/; +string = 'hij'; +actualmatch = string.match(pattern); +expectedmatch = Array('hij'); +addThis(); + +status = inSection(83); +pattern = /(abc|)ef/; +string = 'abcdef'; +actualmatch = string.match(pattern); +expectedmatch = Array('ef', ''); +addThis(); + +status = inSection(84); +pattern = /(a|b)c*d/; +string = 'abcd'; +actualmatch = string.match(pattern); +expectedmatch = Array('bcd', 'b'); +addThis(); + +status = inSection(85); +pattern = /(ab|ab*)bc/; +string = 'abc'; +actualmatch = string.match(pattern); +expectedmatch = Array('abc', 'a'); +addThis(); + +status = inSection(86); +pattern = /a([bc]*)c*/; +string = 'abc'; +actualmatch = string.match(pattern); +expectedmatch = Array('abc', 'bc'); +addThis(); + +status = inSection(87); +pattern = /a([bc]*)(c*d)/; +string = 'abcd'; +actualmatch = string.match(pattern); +expectedmatch = Array('abcd', 'bc', 'd'); +addThis(); + +status = inSection(88); +pattern = /a([bc]+)(c*d)/; +string = 'abcd'; +actualmatch = string.match(pattern); +expectedmatch = Array('abcd', 'bc', 'd'); +addThis(); + +status = inSection(89); +pattern = /a([bc]*)(c+d)/; +string = 'abcd'; +actualmatch = string.match(pattern); +expectedmatch = Array('abcd', 'b', 'cd'); +addThis(); + +status = inSection(90); +pattern = /a[bcd]*dcdcde/; +string = 'adcdcde'; +actualmatch = string.match(pattern); +expectedmatch = Array('adcdcde'); +addThis(); + +status = inSection(91); +pattern = /(ab|a)b*c/; +string = 'abc'; +actualmatch = string.match(pattern); +expectedmatch = Array('abc', 'ab'); +addThis(); + +status = inSection(92); +pattern = /((a)(b)c)(d)/; +string = 'abcd'; +actualmatch = string.match(pattern); +expectedmatch = Array('abcd', 'abc', 'a', 'b', 'd'); +addThis(); + +status = inSection(93); +pattern = /[a-zA-Z_][a-zA-Z0-9_]*/; +string = 'alpha'; +actualmatch = string.match(pattern); +expectedmatch = Array('alpha'); +addThis(); + +status = inSection(94); +pattern = /^a(bc+|b[eh])g|.h$/; +string = 'abh'; +actualmatch = string.match(pattern); +expectedmatch = Array('bh', undefined); +addThis(); + +status = inSection(95); +pattern = /(bc+d$|ef*g.|h?i(j|k))/; +string = 'effgz'; +actualmatch = string.match(pattern); +expectedmatch = Array('effgz', 'effgz', undefined); +addThis(); + +status = inSection(96); +pattern = /(bc+d$|ef*g.|h?i(j|k))/; +string = 'ij'; +actualmatch = string.match(pattern); +expectedmatch = Array('ij', 'ij', 'j'); +addThis(); + +status = inSection(97); +pattern = /(bc+d$|ef*g.|h?i(j|k))/; +string = 'reffgz'; +actualmatch = string.match(pattern); +expectedmatch = Array('effgz', 'effgz', undefined); +addThis(); + +status = inSection(98); +pattern = /((((((((((a))))))))))/; +string = 'a'; +actualmatch = string.match(pattern); +expectedmatch = Array('a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a'); +addThis(); + +status = inSection(99); +pattern = /((((((((((a))))))))))\10/; +string = 'aa'; +actualmatch = string.match(pattern); +expectedmatch = Array('aa', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a'); +addThis(); + +status = inSection(100); +pattern = /((((((((((a))))))))))/; +string = 'a!'; +actualmatch = string.match(pattern); +expectedmatch = Array('a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a'); +addThis(); + +status = inSection(101); +pattern = /(((((((((a)))))))))/; +string = 'a'; +actualmatch = string.match(pattern); +expectedmatch = Array('a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a'); +addThis(); + +status = inSection(102); +pattern = /(.*)c(.*)/; +string = 'abcde'; +actualmatch = string.match(pattern); +expectedmatch = Array('abcde', 'ab', 'de'); +addThis(); + +status = inSection(103); +pattern = /abcd/; +string = 'abcd'; +actualmatch = string.match(pattern); +expectedmatch = Array('abcd'); +addThis(); + +status = inSection(104); +pattern = /a(bc)d/; +string = 'abcd'; +actualmatch = string.match(pattern); +expectedmatch = Array('abcd', 'bc'); +addThis(); + +status = inSection(105); +pattern = /a[-]?c/; +string = 'ac'; +actualmatch = string.match(pattern); +expectedmatch = Array('ac'); +addThis(); + +status = inSection(106); +pattern = /(abc)\1/; +string = 'abcabc'; +actualmatch = string.match(pattern); +expectedmatch = Array('abcabc', 'abc'); +addThis(); + +status = inSection(107); +pattern = /([a-c]*)\1/; +string = 'abcabc'; +actualmatch = string.match(pattern); +expectedmatch = Array('abcabc', 'abc'); +addThis(); + +status = inSection(108); +pattern = /(a)|\1/; +string = 'a'; +actualmatch = string.match(pattern); +expectedmatch = Array('a', 'a'); +addThis(); + +status = inSection(109); +pattern = /(([a-c])b*?\2)*/; +string = 'ababbbcbc'; +actualmatch = string.match(pattern); +expectedmatch = Array('ababb', 'bb', 'b'); +addThis(); + +status = inSection(110); +pattern = /(([a-c])b*?\2){3}/; +string = 'ababbbcbc'; +actualmatch = string.match(pattern); +expectedmatch = Array('ababbbcbc', 'cbc', 'c'); +addThis(); + +/* Can't refer to a capture before it's encountered & completed + status = inSection(111); + pattern = /((\3|b)\2(a)x)+/; + string = 'aaaxabaxbaaxbbax'; + actualmatch = string.match(pattern); + expectedmatch = Array('bbax', 'bbax', 'b', 'a'); + addThis(); + + status = inSection(112); + pattern = /((\3|b)\2(a)){2,}/; + string = 'bbaababbabaaaaabbaaaabba'; + actualmatch = string.match(pattern); + expectedmatch = Array('bbaaaabba', 'bba', 'b', 'a'); + addThis(); +*/ + +status = inSection(113); +pattern = /abc/i; +string = 'ABC'; +actualmatch = string.match(pattern); +expectedmatch = Array('ABC'); +addThis(); + +status = inSection(114); +pattern = /abc/i; +string = 'XABCY'; +actualmatch = string.match(pattern); +expectedmatch = Array('ABC'); +addThis(); + +status = inSection(115); +pattern = /abc/i; +string = 'ABABC'; +actualmatch = string.match(pattern); +expectedmatch = Array('ABC'); +addThis(); + +status = inSection(116); +pattern = /ab*c/i; +string = 'ABC'; +actualmatch = string.match(pattern); +expectedmatch = Array('ABC'); +addThis(); + +status = inSection(117); +pattern = /ab*bc/i; +string = 'ABC'; +actualmatch = string.match(pattern); +expectedmatch = Array('ABC'); +addThis(); + +status = inSection(118); +pattern = /ab*bc/i; +string = 'ABBC'; +actualmatch = string.match(pattern); +expectedmatch = Array('ABBC'); +addThis(); + +status = inSection(119); +pattern = /ab*?bc/i; +string = 'ABBBBC'; +actualmatch = string.match(pattern); +expectedmatch = Array('ABBBBC'); +addThis(); + +status = inSection(120); +pattern = /ab{0,}?bc/i; +string = 'ABBBBC'; +actualmatch = string.match(pattern); +expectedmatch = Array('ABBBBC'); +addThis(); + +status = inSection(121); +pattern = /ab+?bc/i; +string = 'ABBC'; +actualmatch = string.match(pattern); +expectedmatch = Array('ABBC'); +addThis(); + +status = inSection(122); +pattern = /ab+bc/i; +string = 'ABBBBC'; +actualmatch = string.match(pattern); +expectedmatch = Array('ABBBBC'); +addThis(); + +status = inSection(123); +pattern = /ab{1,}?bc/i; +string = 'ABBBBC'; +actualmatch = string.match(pattern); +expectedmatch = Array('ABBBBC'); +addThis(); + +status = inSection(124); +pattern = /ab{1,3}?bc/i; +string = 'ABBBBC'; +actualmatch = string.match(pattern); +expectedmatch = Array('ABBBBC'); +addThis(); + +status = inSection(125); +pattern = /ab{3,4}?bc/i; +string = 'ABBBBC'; +actualmatch = string.match(pattern); +expectedmatch = Array('ABBBBC'); +addThis(); + +status = inSection(126); +pattern = /ab??bc/i; +string = 'ABBC'; +actualmatch = string.match(pattern); +expectedmatch = Array('ABBC'); +addThis(); + +status = inSection(127); +pattern = /ab??bc/i; +string = 'ABC'; +actualmatch = string.match(pattern); +expectedmatch = Array('ABC'); +addThis(); + +status = inSection(128); +pattern = /ab{0,1}?bc/i; +string = 'ABC'; +actualmatch = string.match(pattern); +expectedmatch = Array('ABC'); +addThis(); + +status = inSection(129); +pattern = /ab??c/i; +string = 'ABC'; +actualmatch = string.match(pattern); +expectedmatch = Array('ABC'); +addThis(); + +status = inSection(130); +pattern = /ab{0,1}?c/i; +string = 'ABC'; +actualmatch = string.match(pattern); +expectedmatch = Array('ABC'); +addThis(); + +status = inSection(131); +pattern = /^abc$/i; +string = 'ABC'; +actualmatch = string.match(pattern); +expectedmatch = Array('ABC'); +addThis(); + +status = inSection(132); +pattern = /^abc/i; +string = 'ABCC'; +actualmatch = string.match(pattern); +expectedmatch = Array('ABC'); +addThis(); + +status = inSection(133); +pattern = /abc$/i; +string = 'AABC'; +actualmatch = string.match(pattern); +expectedmatch = Array('ABC'); +addThis(); + +status = inSection(134); +pattern = /^/i; +string = 'ABC'; +actualmatch = string.match(pattern); +expectedmatch = Array(''); +addThis(); + +status = inSection(135); +pattern = /$/i; +string = 'ABC'; +actualmatch = string.match(pattern); +expectedmatch = Array(''); +addThis(); + +status = inSection(136); +pattern = /a.c/i; +string = 'ABC'; +actualmatch = string.match(pattern); +expectedmatch = Array('ABC'); +addThis(); + +status = inSection(137); +pattern = /a.c/i; +string = 'AXC'; +actualmatch = string.match(pattern); +expectedmatch = Array('AXC'); +addThis(); + +status = inSection(138); +pattern = /a.*?c/i; +string = 'AXYZC'; +actualmatch = string.match(pattern); +expectedmatch = Array('AXYZC'); +addThis(); + +status = inSection(139); +pattern = /a[bc]d/i; +string = 'ABD'; +actualmatch = string.match(pattern); +expectedmatch = Array('ABD'); +addThis(); + +status = inSection(140); +pattern = /a[b-d]e/i; +string = 'ACE'; +actualmatch = string.match(pattern); +expectedmatch = Array('ACE'); +addThis(); + +status = inSection(141); +pattern = /a[b-d]/i; +string = 'AAC'; +actualmatch = string.match(pattern); +expectedmatch = Array('AC'); +addThis(); + +status = inSection(142); +pattern = /a[-b]/i; +string = 'A-'; +actualmatch = string.match(pattern); +expectedmatch = Array('A-'); +addThis(); + +status = inSection(143); +pattern = /a[b-]/i; +string = 'A-'; +actualmatch = string.match(pattern); +expectedmatch = Array('A-'); +addThis(); + +status = inSection(144); +pattern = /a]/i; +string = 'A]'; +actualmatch = string.match(pattern); +expectedmatch = Array('A]'); +addThis(); + +/* Perl supports ] & ^] inside a [], ECMA does not + status = inSection(145); + pattern = /a[]]b/i; + string = 'A]B'; + actualmatch = string.match(pattern); + expectedmatch = Array('A]B'); + addThis(); +*/ + +status = inSection(146); +pattern = /a[^bc]d/i; +string = 'AED'; +actualmatch = string.match(pattern); +expectedmatch = Array('AED'); +addThis(); + +status = inSection(147); +pattern = /a[^-b]c/i; +string = 'ADC'; +actualmatch = string.match(pattern); +expectedmatch = Array('ADC'); +addThis(); + +/* Perl supports ] & ^] inside a [], ECMA does not + status = inSection(148); + pattern = /a[^]b]c/i; + string = 'ADC'; + actualmatch = string.match(pattern); + expectedmatch = Array('ADC'); + addThis(); +*/ + +status = inSection(149); +pattern = /ab|cd/i; +string = 'ABC'; +actualmatch = string.match(pattern); +expectedmatch = Array('AB'); +addThis(); + +status = inSection(150); +pattern = /ab|cd/i; +string = 'ABCD'; +actualmatch = string.match(pattern); +expectedmatch = Array('AB'); +addThis(); + +status = inSection(151); +pattern = /()ef/i; +string = 'DEF'; +actualmatch = string.match(pattern); +expectedmatch = Array('EF', ''); +addThis(); + +status = inSection(152); +pattern = /a\(b/i; +string = 'A(B'; +actualmatch = string.match(pattern); +expectedmatch = Array('A(B'); +addThis(); + +status = inSection(153); +pattern = /a\(*b/i; +string = 'AB'; +actualmatch = string.match(pattern); +expectedmatch = Array('AB'); +addThis(); + +status = inSection(154); +pattern = /a\(*b/i; +string = 'A((B'; +actualmatch = string.match(pattern); +expectedmatch = Array('A((B'); +addThis(); + +status = inSection(155); +pattern = /a\\b/i; +string = 'A\\B'; +actualmatch = string.match(pattern); +expectedmatch = Array('A\\B'); +addThis(); + +status = inSection(156); +pattern = /((a))/i; +string = 'ABC'; +actualmatch = string.match(pattern); +expectedmatch = Array('A', 'A', 'A'); +addThis(); + +status = inSection(157); +pattern = /(a)b(c)/i; +string = 'ABC'; +actualmatch = string.match(pattern); +expectedmatch = Array('ABC', 'A', 'C'); +addThis(); + +status = inSection(158); +pattern = /a+b+c/i; +string = 'AABBABC'; +actualmatch = string.match(pattern); +expectedmatch = Array('ABC'); +addThis(); + +status = inSection(159); +pattern = /a{1,}b{1,}c/i; +string = 'AABBABC'; +actualmatch = string.match(pattern); +expectedmatch = Array('ABC'); +addThis(); + +status = inSection(160); +pattern = /a.+?c/i; +string = 'ABCABC'; +actualmatch = string.match(pattern); +expectedmatch = Array('ABC'); +addThis(); + +status = inSection(161); +pattern = /a.*?c/i; +string = 'ABCABC'; +actualmatch = string.match(pattern); +expectedmatch = Array('ABC'); +addThis(); + +status = inSection(162); +pattern = /a.{0,5}?c/i; +string = 'ABCABC'; +actualmatch = string.match(pattern); +expectedmatch = Array('ABC'); +addThis(); + +status = inSection(163); +pattern = /(a+|b)*/i; +string = 'AB'; +actualmatch = string.match(pattern); +expectedmatch = Array('AB', 'B'); +addThis(); + +status = inSection(164); +pattern = /(a+|b){0,}/i; +string = 'AB'; +actualmatch = string.match(pattern); +expectedmatch = Array('AB', 'B'); +addThis(); + +status = inSection(165); +pattern = /(a+|b)+/i; +string = 'AB'; +actualmatch = string.match(pattern); +expectedmatch = Array('AB', 'B'); +addThis(); + +status = inSection(166); +pattern = /(a+|b){1,}/i; +string = 'AB'; +actualmatch = string.match(pattern); +expectedmatch = Array('AB', 'B'); +addThis(); + +status = inSection(167); +pattern = /(a+|b)?/i; +string = 'AB'; +actualmatch = string.match(pattern); +expectedmatch = Array('A', 'A'); +addThis(); + +status = inSection(168); +pattern = /(a+|b){0,1}/i; +string = 'AB'; +actualmatch = string.match(pattern); +expectedmatch = Array('A', 'A'); +addThis(); + +status = inSection(169); +pattern = /(a+|b){0,1}?/i; +string = 'AB'; +actualmatch = string.match(pattern); +expectedmatch = Array('', undefined); +addThis(); + +status = inSection(170); +pattern = /[^ab]*/i; +string = 'CDE'; +actualmatch = string.match(pattern); +expectedmatch = Array('CDE'); +addThis(); + +status = inSection(171); +pattern = /([abc])*d/i; +string = 'ABBBCD'; +actualmatch = string.match(pattern); +expectedmatch = Array('ABBBCD', 'C'); +addThis(); + +status = inSection(172); +pattern = /([abc])*bcd/i; +string = 'ABCD'; +actualmatch = string.match(pattern); +expectedmatch = Array('ABCD', 'A'); +addThis(); + +status = inSection(173); +pattern = /a|b|c|d|e/i; +string = 'E'; +actualmatch = string.match(pattern); +expectedmatch = Array('E'); +addThis(); + +status = inSection(174); +pattern = /(a|b|c|d|e)f/i; +string = 'EF'; +actualmatch = string.match(pattern); +expectedmatch = Array('EF', 'E'); +addThis(); + +status = inSection(175); +pattern = /abcd*efg/i; +string = 'ABCDEFG'; +actualmatch = string.match(pattern); +expectedmatch = Array('ABCDEFG'); +addThis(); + +status = inSection(176); +pattern = /ab*/i; +string = 'XABYABBBZ'; +actualmatch = string.match(pattern); +expectedmatch = Array('AB'); +addThis(); + +status = inSection(177); +pattern = /ab*/i; +string = 'XAYABBBZ'; +actualmatch = string.match(pattern); +expectedmatch = Array('A'); +addThis(); + +status = inSection(178); +pattern = /(ab|cd)e/i; +string = 'ABCDE'; +actualmatch = string.match(pattern); +expectedmatch = Array('CDE', 'CD'); +addThis(); + +status = inSection(179); +pattern = /[abhgefdc]ij/i; +string = 'HIJ'; +actualmatch = string.match(pattern); +expectedmatch = Array('HIJ'); +addThis(); + +status = inSection(180); +pattern = /(abc|)ef/i; +string = 'ABCDEF'; +actualmatch = string.match(pattern); +expectedmatch = Array('EF', ''); +addThis(); + +status = inSection(181); +pattern = /(a|b)c*d/i; +string = 'ABCD'; +actualmatch = string.match(pattern); +expectedmatch = Array('BCD', 'B'); +addThis(); + +status = inSection(182); +pattern = /(ab|ab*)bc/i; +string = 'ABC'; +actualmatch = string.match(pattern); +expectedmatch = Array('ABC', 'A'); +addThis(); + +status = inSection(183); +pattern = /a([bc]*)c*/i; +string = 'ABC'; +actualmatch = string.match(pattern); +expectedmatch = Array('ABC', 'BC'); +addThis(); + +status = inSection(184); +pattern = /a([bc]*)(c*d)/i; +string = 'ABCD'; +actualmatch = string.match(pattern); +expectedmatch = Array('ABCD', 'BC', 'D'); +addThis(); + +status = inSection(185); +pattern = /a([bc]+)(c*d)/i; +string = 'ABCD'; +actualmatch = string.match(pattern); +expectedmatch = Array('ABCD', 'BC', 'D'); +addThis(); + +status = inSection(186); +pattern = /a([bc]*)(c+d)/i; +string = 'ABCD'; +actualmatch = string.match(pattern); +expectedmatch = Array('ABCD', 'B', 'CD'); +addThis(); + +status = inSection(187); +pattern = /a[bcd]*dcdcde/i; +string = 'ADCDCDE'; +actualmatch = string.match(pattern); +expectedmatch = Array('ADCDCDE'); +addThis(); + +status = inSection(188); +pattern = /(ab|a)b*c/i; +string = 'ABC'; +actualmatch = string.match(pattern); +expectedmatch = Array('ABC', 'AB'); +addThis(); + +status = inSection(189); +pattern = /((a)(b)c)(d)/i; +string = 'ABCD'; +actualmatch = string.match(pattern); +expectedmatch = Array('ABCD', 'ABC', 'A', 'B', 'D'); +addThis(); + +status = inSection(190); +pattern = /[a-zA-Z_][a-zA-Z0-9_]*/i; +string = 'ALPHA'; +actualmatch = string.match(pattern); +expectedmatch = Array('ALPHA'); +addThis(); + +status = inSection(191); +pattern = /^a(bc+|b[eh])g|.h$/i; +string = 'ABH'; +actualmatch = string.match(pattern); +expectedmatch = Array('BH', undefined); +addThis(); + +status = inSection(192); +pattern = /(bc+d$|ef*g.|h?i(j|k))/i; +string = 'EFFGZ'; +actualmatch = string.match(pattern); +expectedmatch = Array('EFFGZ', 'EFFGZ', undefined); +addThis(); + +status = inSection(193); +pattern = /(bc+d$|ef*g.|h?i(j|k))/i; +string = 'IJ'; +actualmatch = string.match(pattern); +expectedmatch = Array('IJ', 'IJ', 'J'); +addThis(); + +status = inSection(194); +pattern = /(bc+d$|ef*g.|h?i(j|k))/i; +string = 'REFFGZ'; +actualmatch = string.match(pattern); +expectedmatch = Array('EFFGZ', 'EFFGZ', undefined); +addThis(); + +status = inSection(195); +pattern = /((((((((((a))))))))))/i; +string = 'A'; +actualmatch = string.match(pattern); +expectedmatch = Array('A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A'); +addThis(); + +status = inSection(196); +pattern = /((((((((((a))))))))))\10/i; +string = 'AA'; +actualmatch = string.match(pattern); +expectedmatch = Array('AA', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A'); +addThis(); + +status = inSection(197); +pattern = /((((((((((a))))))))))/i; +string = 'A!'; +actualmatch = string.match(pattern); +expectedmatch = Array('A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A'); +addThis(); + +status = inSection(198); +pattern = /(((((((((a)))))))))/i; +string = 'A'; +actualmatch = string.match(pattern); +expectedmatch = Array('A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A'); +addThis(); + +status = inSection(199); +pattern = /(?:(?:(?:(?:(?:(?:(?:(?:(?:(a))))))))))/i; +string = 'A'; +actualmatch = string.match(pattern); +expectedmatch = Array('A', 'A'); +addThis(); + +status = inSection(200); +pattern = /(?:(?:(?:(?:(?:(?:(?:(?:(?:(a|b|c))))))))))/i; +string = 'C'; +actualmatch = string.match(pattern); +expectedmatch = Array('C', 'C'); +addThis(); + +status = inSection(201); +pattern = /(.*)c(.*)/i; +string = 'ABCDE'; +actualmatch = string.match(pattern); +expectedmatch = Array('ABCDE', 'AB', 'DE'); +addThis(); + +status = inSection(202); +pattern = /abcd/i; +string = 'ABCD'; +actualmatch = string.match(pattern); +expectedmatch = Array('ABCD'); +addThis(); + +status = inSection(203); +pattern = /a(bc)d/i; +string = 'ABCD'; +actualmatch = string.match(pattern); +expectedmatch = Array('ABCD', 'BC'); +addThis(); + +status = inSection(204); +pattern = /a[-]?c/i; +string = 'AC'; +actualmatch = string.match(pattern); +expectedmatch = Array('AC'); +addThis(); + +status = inSection(205); +pattern = /(abc)\1/i; +string = 'ABCABC'; +actualmatch = string.match(pattern); +expectedmatch = Array('ABCABC', 'ABC'); +addThis(); + +status = inSection(206); +pattern = /([a-c]*)\1/i; +string = 'ABCABC'; +actualmatch = string.match(pattern); +expectedmatch = Array('ABCABC', 'ABC'); +addThis(); + +status = inSection(207); +pattern = /a(?!b)./; +string = 'abad'; +actualmatch = string.match(pattern); +expectedmatch = Array('ad'); +addThis(); + +status = inSection(208); +pattern = /a(?=d)./; +string = 'abad'; +actualmatch = string.match(pattern); +expectedmatch = Array('ad'); +addThis(); + +status = inSection(209); +pattern = /a(?=c|d)./; +string = 'abad'; +actualmatch = string.match(pattern); +expectedmatch = Array('ad'); +addThis(); + +status = inSection(210); +pattern = /a(?:b|c|d)(.)/; +string = 'ace'; +actualmatch = string.match(pattern); +expectedmatch = Array('ace', 'e'); +addThis(); + +status = inSection(211); +pattern = /a(?:b|c|d)*(.)/; +string = 'ace'; +actualmatch = string.match(pattern); +expectedmatch = Array('ace', 'e'); +addThis(); + +status = inSection(212); +pattern = /a(?:b|c|d)+?(.)/; +string = 'ace'; +actualmatch = string.match(pattern); +expectedmatch = Array('ace', 'e'); +addThis(); + +status = inSection(213); +pattern = /a(?:b|c|d)+?(.)/; +string = 'acdbcdbe'; +actualmatch = string.match(pattern); +expectedmatch = Array('acd', 'd'); +addThis(); + +status = inSection(214); +pattern = /a(?:b|c|d)+(.)/; +string = 'acdbcdbe'; +actualmatch = string.match(pattern); +expectedmatch = Array('acdbcdbe', 'e'); +addThis(); + +status = inSection(215); +pattern = /a(?:b|c|d){2}(.)/; +string = 'acdbcdbe'; +actualmatch = string.match(pattern); +expectedmatch = Array('acdb', 'b'); +addThis(); + +status = inSection(216); +pattern = /a(?:b|c|d){4,5}(.)/; +string = 'acdbcdbe'; +actualmatch = string.match(pattern); +expectedmatch = Array('acdbcdb', 'b'); +addThis(); + +status = inSection(217); +pattern = /a(?:b|c|d){4,5}?(.)/; +string = 'acdbcdbe'; +actualmatch = string.match(pattern); +expectedmatch = Array('acdbcd', 'd'); +addThis(); + +// MODIFIED - ECMA has different rules for paren contents +status = inSection(218); +pattern = /((foo)|(bar))*/; +string = 'foobar'; +actualmatch = string.match(pattern); +//expectedmatch = Array('foobar', 'bar', 'foo', 'bar'); +expectedmatch = Array('foobar', 'bar', undefined, 'bar'); +addThis(); + +status = inSection(219); +pattern = /a(?:b|c|d){6,7}(.)/; +string = 'acdbcdbe'; +actualmatch = string.match(pattern); +expectedmatch = Array('acdbcdbe', 'e'); +addThis(); + +status = inSection(220); +pattern = /a(?:b|c|d){6,7}?(.)/; +string = 'acdbcdbe'; +actualmatch = string.match(pattern); +expectedmatch = Array('acdbcdbe', 'e'); +addThis(); + +status = inSection(221); +pattern = /a(?:b|c|d){5,6}(.)/; +string = 'acdbcdbe'; +actualmatch = string.match(pattern); +expectedmatch = Array('acdbcdbe', 'e'); +addThis(); + +status = inSection(222); +pattern = /a(?:b|c|d){5,6}?(.)/; +string = 'acdbcdbe'; +actualmatch = string.match(pattern); +expectedmatch = Array('acdbcdb', 'b'); +addThis(); + +status = inSection(223); +pattern = /a(?:b|c|d){5,7}(.)/; +string = 'acdbcdbe'; +actualmatch = string.match(pattern); +expectedmatch = Array('acdbcdbe', 'e'); +addThis(); + +status = inSection(224); +pattern = /a(?:b|c|d){5,7}?(.)/; +string = 'acdbcdbe'; +actualmatch = string.match(pattern); +expectedmatch = Array('acdbcdb', 'b'); +addThis(); + +status = inSection(225); +pattern = /a(?:b|(c|e){1,2}?|d)+?(.)/; +string = 'ace'; +actualmatch = string.match(pattern); +expectedmatch = Array('ace', 'c', 'e'); +addThis(); + +status = inSection(226); +pattern = /^(.+)?B/; +string = 'AB'; +actualmatch = string.match(pattern); +expectedmatch = Array('AB', 'A'); +addThis(); + +/* MODIFIED - ECMA has different rules for paren contents */ +status = inSection(227); +pattern = /^([^a-z])|(\^)$/; +string = '.'; +actualmatch = string.match(pattern); +//expectedmatch = Array('.', '.', ''); +expectedmatch = Array('.', '.', undefined); +addThis(); + +status = inSection(228); +pattern = /^[<>]&/; +string = '<&OUT'; +actualmatch = string.match(pattern); +expectedmatch = Array('<&'); +addThis(); + +/* Can't refer to a capture before it's encountered & completed + status = inSection(229); + pattern = /^(a\1?){4}$/; + string = 'aaaaaaaaaa'; + actualmatch = string.match(pattern); + expectedmatch = Array('aaaaaaaaaa', 'aaaa'); + addThis(); + + status = inSection(230); + pattern = /^(a(?(1)\1)){4}$/; + string = 'aaaaaaaaaa'; + actualmatch = string.match(pattern); + expectedmatch = Array('aaaaaaaaaa', 'aaaa'); + addThis(); +*/ + +status = inSection(231); +pattern = /((a{4})+)/; +string = 'aaaaaaaaa'; +actualmatch = string.match(pattern); +expectedmatch = Array('aaaaaaaa', 'aaaaaaaa', 'aaaa'); +addThis(); + +status = inSection(232); +pattern = /(((aa){2})+)/; +string = 'aaaaaaaaaa'; +actualmatch = string.match(pattern); +expectedmatch = Array('aaaaaaaa', 'aaaaaaaa', 'aaaa', 'aa'); +addThis(); + +status = inSection(233); +pattern = /(((a{2}){2})+)/; +string = 'aaaaaaaaaa'; +actualmatch = string.match(pattern); +expectedmatch = Array('aaaaaaaa', 'aaaaaaaa', 'aaaa', 'aa'); +addThis(); + +status = inSection(234); +pattern = /(?:(f)(o)(o)|(b)(a)(r))*/; +string = 'foobar'; +actualmatch = string.match(pattern); +//expectedmatch = Array('foobar', 'f', 'o', 'o', 'b', 'a', 'r'); +expectedmatch = Array('foobar', undefined, undefined, undefined, 'b', 'a', 'r'); +addThis(); + +/* ECMA supports (?: (?= and (?! but doesn't support (?< etc. + status = inSection(235); + pattern = /(?<=a)b/; + string = 'ab'; + actualmatch = string.match(pattern); + expectedmatch = Array('b'); + addThis(); + + status = inSection(236); + pattern = /(? + status = inSection(311); + pattern = /(?>a+)b/; + string = 'aaab'; + actualmatch = string.match(pattern); + expectedmatch = Array('aaab'); + addThis(); +*/ + +status = inSection(312); +pattern = /([[:]+)/; + string = 'a:[b]:'; + actualmatch = string.match(pattern); + expectedmatch = Array(':[', ':['); + addThis(); + + status = inSection(313); + pattern = /([[=]+)/; + string = 'a=[b]='; + actualmatch = string.match(pattern); + expectedmatch = Array('=[', '=['); + addThis(); + + status = inSection(314); + pattern = /([[.]+)/; + string = 'a.[b].'; + actualmatch = string.match(pattern); + expectedmatch = Array('.[', '.['); + addThis(); + +/* ECMA doesn't have rules for [: + status = inSection(315); + pattern = /[a[:]b[:c]/; + string = 'abc'; + actualmatch = string.match(pattern); + expectedmatch = Array('abc'); + addThis(); +*/ + +/* ECMA doesn't support (?> + status = inSection(316); + pattern = /((?>a+)b)/; + string = 'aaab'; + actualmatch = string.match(pattern); + expectedmatch = Array('aaab', 'aaab'); + addThis(); + + status = inSection(317); + pattern = /(?>(a+))b/; + string = 'aaab'; + actualmatch = string.match(pattern); + expectedmatch = Array('aaab', 'aaa'); + addThis(); + + status = inSection(318); + pattern = /((?>[^()]+)|\([^()]*\))+/; + string = '((abc(ade)ufh()()x'; + actualmatch = string.match(pattern); + expectedmatch = Array('abc(ade)ufh()()x', 'x'); + addThis(); +*/ + +/* Perl has \Z has end-of-line, ECMA doesn't + status = inSection(319); + pattern = /\Z/; + string = 'a\nb\n'; + actualmatch = string.match(pattern); + expectedmatch = Array(''); + addThis(); + + status = inSection(320); + pattern = /\z/; + string = 'a\nb\n'; + actualmatch = string.match(pattern); + expectedmatch = Array(''); + addThis(); +*/ + + status = inSection(321); + pattern = /$/; + string = 'a\nb\n'; + actualmatch = string.match(pattern); + expectedmatch = Array(''); + addThis(); + +/* Perl has \Z has end-of-line, ECMA doesn't + status = inSection(322); + pattern = /\Z/; + string = 'b\na\n'; + actualmatch = string.match(pattern); + expectedmatch = Array(''); + addThis(); + + status = inSection(323); + pattern = /\z/; + string = 'b\na\n'; + actualmatch = string.match(pattern); + expectedmatch = Array(''); + addThis(); +*/ + + status = inSection(324); + pattern = /$/; + string = 'b\na\n'; + actualmatch = string.match(pattern); + expectedmatch = Array(''); + addThis(); + +/* Perl has \Z has end-of-line, ECMA doesn't + status = inSection(325); + pattern = /\Z/; + string = 'b\na'; + actualmatch = string.match(pattern); + expectedmatch = Array(''); + addThis(); + + status = inSection(326); + pattern = /\z/; + string = 'b\na'; + actualmatch = string.match(pattern); + expectedmatch = Array(''); + addThis(); +*/ + + status = inSection(327); + pattern = /$/; + string = 'b\na'; + actualmatch = string.match(pattern); + expectedmatch = Array(''); + addThis(); + +/* Perl has \Z has end-of-line, ECMA doesn't + status = inSection(328); + pattern = /\Z/m; + string = 'a\nb\n'; + actualmatch = string.match(pattern); + expectedmatch = Array(''); + addThis(); + + status = inSection(329); + pattern = /\z/m; + string = 'a\nb\n'; + actualmatch = string.match(pattern); + expectedmatch = Array(''); + addThis(); +*/ + + status = inSection(330); + pattern = /$/m; + string = 'a\nb\n'; + actualmatch = string.match(pattern); + expectedmatch = Array(''); + addThis(); + +/* Perl has \Z has end-of-line, ECMA doesn't + status = inSection(331); + pattern = /\Z/m; + string = 'b\na\n'; + actualmatch = string.match(pattern); + expectedmatch = Array(''); + addThis(); + + status = inSection(332); + pattern = /\z/m; + string = 'b\na\n'; + actualmatch = string.match(pattern); + expectedmatch = Array(''); + addThis(); +*/ + + status = inSection(333); + pattern = /$/m; + string = 'b\na\n'; + actualmatch = string.match(pattern); + expectedmatch = Array(''); + addThis(); + +/* Perl has \Z has end-of-line, ECMA doesn't + status = inSection(334); + pattern = /\Z/m; + string = 'b\na'; + actualmatch = string.match(pattern); + expectedmatch = Array(''); + addThis(); + + status = inSection(335); + pattern = /\z/m; + string = 'b\na'; + actualmatch = string.match(pattern); + expectedmatch = Array(''); + addThis(); +*/ + + status = inSection(336); + pattern = /$/m; + string = 'b\na'; + actualmatch = string.match(pattern); + expectedmatch = Array(''); + addThis(); + +/* Perl has \Z has end-of-line, ECMA doesn't + status = inSection(337); + pattern = /a\Z/; + string = 'b\na\n'; + actualmatch = string.match(pattern); + expectedmatch = Array('a'); + addThis(); +*/ + +/* $ only matches end of input unless multiline + status = inSection(338); + pattern = /a$/; + string = 'b\na\n'; + actualmatch = string.match(pattern); + expectedmatch = Array('a'); + addThis(); +*/ + +/* Perl has \Z has end-of-line, ECMA doesn't + status = inSection(339); + pattern = /a\Z/; + string = 'b\na'; + actualmatch = string.match(pattern); + expectedmatch = Array('a'); + addThis(); + + status = inSection(340); + pattern = /a\z/; + string = 'b\na'; + actualmatch = string.match(pattern); + expectedmatch = Array('a'); + addThis(); +*/ + + status = inSection(341); + pattern = /a$/; + string = 'b\na'; + actualmatch = string.match(pattern); + expectedmatch = Array('a'); + addThis(); + + status = inSection(342); + pattern = /a$/m; + string = 'a\nb\n'; + actualmatch = string.match(pattern); + expectedmatch = Array('a'); + addThis(); + +/* Perl has \Z has end-of-line, ECMA doesn't + status = inSection(343); + pattern = /a\Z/m; + string = 'b\na\n'; + actualmatch = string.match(pattern); + expectedmatch = Array('a'); + addThis(); +*/ + + status = inSection(344); + pattern = /a$/m; + string = 'b\na\n'; + actualmatch = string.match(pattern); + expectedmatch = Array('a'); + addThis(); + +/* Perl has \Z has end-of-line, ECMA doesn't + status = inSection(345); + pattern = /a\Z/m; + string = 'b\na'; + actualmatch = string.match(pattern); + expectedmatch = Array('a'); + addThis(); + + status = inSection(346); + pattern = /a\z/m; + string = 'b\na'; + actualmatch = string.match(pattern); + expectedmatch = Array('a'); + addThis(); +*/ + + status = inSection(347); + pattern = /a$/m; + string = 'b\na'; + actualmatch = string.match(pattern); + expectedmatch = Array('a'); + addThis(); + +/* Perl has \Z has end-of-line, ECMA doesn't + status = inSection(348); + pattern = /aa\Z/; + string = 'b\naa\n'; + actualmatch = string.match(pattern); + expectedmatch = Array('aa'); + addThis(); +*/ + +/* $ only matches end of input unless multiline + status = inSection(349); + pattern = /aa$/; + string = 'b\naa\n'; + actualmatch = string.match(pattern); + expectedmatch = Array('aa'); + addThis(); +*/ + +/* Perl has \Z has end-of-line, ECMA doesn't + status = inSection(350); + pattern = /aa\Z/; + string = 'b\naa'; + actualmatch = string.match(pattern); + expectedmatch = Array('aa'); + addThis(); + + status = inSection(351); + pattern = /aa\z/; + string = 'b\naa'; + actualmatch = string.match(pattern); + expectedmatch = Array('aa'); + addThis(); +*/ + + status = inSection(352); + pattern = /aa$/; + string = 'b\naa'; + actualmatch = string.match(pattern); + expectedmatch = Array('aa'); + addThis(); + + status = inSection(353); + pattern = /aa$/m; + string = 'aa\nb\n'; + actualmatch = string.match(pattern); + expectedmatch = Array('aa'); + addThis(); + +/* Perl has \Z has end-of-line, ECMA doesn't + status = inSection(354); + pattern = /aa\Z/m; + string = 'b\naa\n'; + actualmatch = string.match(pattern); + expectedmatch = Array('aa'); + addThis(); +*/ + + status = inSection(355); + pattern = /aa$/m; + string = 'b\naa\n'; + actualmatch = string.match(pattern); + expectedmatch = Array('aa'); + addThis(); + +/* Perl has \Z has end-of-line, ECMA doesn't + status = inSection(356); + pattern = /aa\Z/m; + string = 'b\naa'; + actualmatch = string.match(pattern); + expectedmatch = Array('aa'); + addThis(); + + status = inSection(357); + pattern = /aa\z/m; + string = 'b\naa'; + actualmatch = string.match(pattern); + expectedmatch = Array('aa'); + addThis(); +*/ + + status = inSection(358); + pattern = /aa$/m; + string = 'b\naa'; + actualmatch = string.match(pattern); + expectedmatch = Array('aa'); + addThis(); + +/* Perl has \Z has end-of-line, ECMA doesn't + status = inSection(359); + pattern = /ab\Z/; + string = 'b\nab\n'; + actualmatch = string.match(pattern); + expectedmatch = Array('ab'); + addThis(); +*/ + +/* $ only matches end of input unless multiline + status = inSection(360); + pattern = /ab$/; + string = 'b\nab\n'; + actualmatch = string.match(pattern); + expectedmatch = Array('ab'); + addThis(); +*/ + +/* Perl has \Z has end-of-line, ECMA doesn't + status = inSection(361); + pattern = /ab\Z/; + string = 'b\nab'; + actualmatch = string.match(pattern); + expectedmatch = Array('ab'); + addThis(); + + status = inSection(362); + pattern = /ab\z/; + string = 'b\nab'; + actualmatch = string.match(pattern); + expectedmatch = Array('ab'); + addThis(); +*/ + + status = inSection(363); + pattern = /ab$/; + string = 'b\nab'; + actualmatch = string.match(pattern); + expectedmatch = Array('ab'); + addThis(); + + status = inSection(364); + pattern = /ab$/m; + string = 'ab\nb\n'; + actualmatch = string.match(pattern); + expectedmatch = Array('ab'); + addThis(); + +/* Perl has \Z has end-of-line, ECMA doesn't + status = inSection(365); + pattern = /ab\Z/m; + string = 'b\nab\n'; + actualmatch = string.match(pattern); + expectedmatch = Array('ab'); + addThis(); +*/ + + status = inSection(366); + pattern = /ab$/m; + string = 'b\nab\n'; + actualmatch = string.match(pattern); + expectedmatch = Array('ab'); + addThis(); + +/* Perl has \Z has end-of-line, ECMA doesn't + status = inSection(367); + pattern = /ab\Z/m; + string = 'b\nab'; + actualmatch = string.match(pattern); + expectedmatch = Array('ab'); + addThis(); + + status = inSection(368); + pattern = /ab\z/m; + string = 'b\nab'; + actualmatch = string.match(pattern); + expectedmatch = Array('ab'); + addThis(); +*/ + + status = inSection(369); + pattern = /ab$/m; + string = 'b\nab'; + actualmatch = string.match(pattern); + expectedmatch = Array('ab'); + addThis(); + +/* Perl has \Z has end-of-line, ECMA doesn't + status = inSection(370); + pattern = /abb\Z/; + string = 'b\nabb\n'; + actualmatch = string.match(pattern); + expectedmatch = Array('abb'); + addThis(); +*/ + +/* $ only matches end of input unless multiline + status = inSection(371); + pattern = /abb$/; + string = 'b\nabb\n'; + actualmatch = string.match(pattern); + expectedmatch = Array('abb'); + addThis(); +*/ + +/* Perl has \Z has end-of-line, ECMA doesn't + status = inSection(372); + pattern = /abb\Z/; + string = 'b\nabb'; + actualmatch = string.match(pattern); + expectedmatch = Array('abb'); + addThis(); + + status = inSection(373); + pattern = /abb\z/; + string = 'b\nabb'; + actualmatch = string.match(pattern); + expectedmatch = Array('abb'); + addThis(); +*/ + + status = inSection(374); + pattern = /abb$/; + string = 'b\nabb'; + actualmatch = string.match(pattern); + expectedmatch = Array('abb'); + addThis(); + + status = inSection(375); + pattern = /abb$/m; + string = 'abb\nb\n'; + actualmatch = string.match(pattern); + expectedmatch = Array('abb'); + addThis(); + +/* Perl has \Z has end-of-line, ECMA doesn't + status = inSection(376); + pattern = /abb\Z/m; + string = 'b\nabb\n'; + actualmatch = string.match(pattern); + expectedmatch = Array('abb'); + addThis(); +*/ + + status = inSection(377); + pattern = /abb$/m; + string = 'b\nabb\n'; + actualmatch = string.match(pattern); + expectedmatch = Array('abb'); + addThis(); + +/* Perl has \Z has end-of-line, ECMA doesn't + status = inSection(378); + pattern = /abb\Z/m; + string = 'b\nabb'; + actualmatch = string.match(pattern); + expectedmatch = Array('abb'); + addThis(); + + status = inSection(379); + pattern = /abb\z/m; + string = 'b\nabb'; + actualmatch = string.match(pattern); + expectedmatch = Array('abb'); + addThis(); +*/ + + status = inSection(380); + pattern = /abb$/m; + string = 'b\nabb'; + actualmatch = string.match(pattern); + expectedmatch = Array('abb'); + addThis(); + + status = inSection(381); + pattern = /(^|x)(c)/; + string = 'ca'; + actualmatch = string.match(pattern); + expectedmatch = Array('c', '', 'c'); + addThis(); + + status = inSection(382); + pattern = /foo.bart/; + string = 'foo.bart'; + actualmatch = string.match(pattern); + expectedmatch = Array('foo.bart'); + addThis(); + + status = inSection(383); + pattern = /^d[x][x][x]/m; + string = 'abcd\ndxxx'; + actualmatch = string.match(pattern); + expectedmatch = Array('dxxx'); + addThis(); + + status = inSection(384); + pattern = /tt+$/; + string = 'xxxtt'; + actualmatch = string.match(pattern); + expectedmatch = Array('tt'); + addThis(); + +/* ECMA spec says that each atom in a range must be a single character + status = inSection(385); + pattern = /([a-\d]+)/; + string = 'za-9z'; + actualmatch = string.match(pattern); + expectedmatch = Array('9', '9'); + addThis(); + + status = inSection(386); + pattern = /([\d-z]+)/; + string = 'a0-za'; + actualmatch = string.match(pattern); + expectedmatch = Array('0-z', '0-z'); + addThis(); +*/ + +/* ECMA doesn't support [: + status = inSection(387); + pattern = /([a-[:digit:]]+)/; + string = 'za-9z'; + actualmatch = string.match(pattern); + expectedmatch = Array('a-9', 'a-9'); + addThis(); + + status = inSection(388); + pattern = /([[:digit:]-z]+)/; + string = '=0-z='; + actualmatch = string.match(pattern); + expectedmatch = Array('0-z', '0-z'); + addThis(); + + status = inSection(389); + pattern = /([[:digit:]-[:alpha:]]+)/; + string = '=0-z='; + actualmatch = string.match(pattern); + expectedmatch = Array('0-z', '0-z'); + addThis(); +*/ + + status = inSection(390); + pattern = /(\d+\.\d+)/; + string = '3.1415926'; + actualmatch = string.match(pattern); + expectedmatch = Array('3.1415926', '3.1415926'); + addThis(); + + status = inSection(391); + pattern = /\.c(pp|xx|c)?$/i; + string = 'IO.c'; + actualmatch = string.match(pattern); + expectedmatch = Array('.c', undefined); + addThis(); + + status = inSection(392); + pattern = /(\.c(pp|xx|c)?$)/i; + string = 'IO.c'; + actualmatch = string.match(pattern); + expectedmatch = Array('.c', '.c', undefined); + addThis(); + + status = inSection(393); + pattern = /(^|a)b/; + string = 'ab'; + actualmatch = string.match(pattern); + expectedmatch = Array('ab', 'a'); + addThis(); + + status = inSection(394); + pattern = /^([ab]*?)(b)?(c)$/; + string = 'abac'; + actualmatch = string.match(pattern); + expectedmatch = Array('abac', 'aba', undefined, 'c'); + addThis(); + + status = inSection(395); + pattern = /^(?:.,){2}c/i; + string = 'a,b,c'; + actualmatch = string.match(pattern); + expectedmatch = Array('a,b,c'); + addThis(); + + status = inSection(396); + pattern = /^(.,){2}c/i; + string = 'a,b,c'; + actualmatch = string.match(pattern); + expectedmatch = Array('a,b,c', 'b,'); + addThis(); + + status = inSection(397); + pattern = /^(?:[^,]*,){2}c/; + string = 'a,b,c'; + actualmatch = string.match(pattern); + expectedmatch = Array('a,b,c'); + addThis(); + + status = inSection(398); + pattern = /^([^,]*,){2}c/; + string = 'a,b,c'; + actualmatch = string.match(pattern); + expectedmatch = Array('a,b,c', 'b,'); + addThis(); + + status = inSection(399); + pattern = /^([^,]*,){3}d/; + string = 'aaa,b,c,d'; + actualmatch = string.match(pattern); + expectedmatch = Array('aaa,b,c,d', 'c,'); + addThis(); + + status = inSection(400); + pattern = /^([^,]*,){3,}d/; + string = 'aaa,b,c,d'; + actualmatch = string.match(pattern); + expectedmatch = Array('aaa,b,c,d', 'c,'); + addThis(); + + status = inSection(401); + pattern = /^([^,]*,){0,3}d/; + string = 'aaa,b,c,d'; + actualmatch = string.match(pattern); + expectedmatch = Array('aaa,b,c,d', 'c,'); + addThis(); + + status = inSection(402); + pattern = /^([^,]{1,3},){3}d/i; + string = 'aaa,b,c,d'; + actualmatch = string.match(pattern); + expectedmatch = Array('aaa,b,c,d', 'c,'); + addThis(); + + status = inSection(403); + pattern = /^([^,]{1,3},){3,}d/; + string = 'aaa,b,c,d'; + actualmatch = string.match(pattern); + expectedmatch = Array('aaa,b,c,d', 'c,'); + addThis(); + + status = inSection(404); + pattern = /^([^,]{1,3},){0,3}d/; + string = 'aaa,b,c,d'; + actualmatch = string.match(pattern); + expectedmatch = Array('aaa,b,c,d', 'c,'); + addThis(); + + status = inSection(405); + pattern = /^([^,]{1,},){3}d/; + string = 'aaa,b,c,d'; + actualmatch = string.match(pattern); + expectedmatch = Array('aaa,b,c,d', 'c,'); + addThis(); + + status = inSection(406); + pattern = /^([^,]{1,},){3,}d/; + string = 'aaa,b,c,d'; + actualmatch = string.match(pattern); + expectedmatch = Array('aaa,b,c,d', 'c,'); + addThis(); + + status = inSection(407); + pattern = /^([^,]{1,},){0,3}d/; + string = 'aaa,b,c,d'; + actualmatch = string.match(pattern); + expectedmatch = Array('aaa,b,c,d', 'c,'); + addThis(); + + status = inSection(408); + pattern = /^([^,]{0,3},){3}d/i; + string = 'aaa,b,c,d'; + actualmatch = string.match(pattern); + expectedmatch = Array('aaa,b,c,d', 'c,'); + addThis(); + + status = inSection(409); + pattern = /^([^,]{0,3},){3,}d/; + string = 'aaa,b,c,d'; + actualmatch = string.match(pattern); + expectedmatch = Array('aaa,b,c,d', 'c,'); + addThis(); + + status = inSection(410); + pattern = /^([^,]{0,3},){0,3}d/; + string = 'aaa,b,c,d'; + actualmatch = string.match(pattern); + expectedmatch = Array('aaa,b,c,d', 'c,'); + addThis(); + +/* ECMA doesn't support \A + status = inSection(411); + pattern = /(?!\A)x/m; + string = 'a\nxb\n'; + actualmatch = string.match(pattern); + expectedmatch = Array('\n'); + addThis(); +*/ + + status = inSection(412); + pattern = /^(a(b)?)+$/; + string = 'aba'; + actualmatch = string.match(pattern); + expectedmatch = Array('aba', 'a', undefined); + addThis(); + + status = inSection(413); + pattern = /^(aa(bb)?)+$/; + string = 'aabbaa'; + actualmatch = string.match(pattern); + expectedmatch = Array('aabbaa', 'aa', undefined); + addThis(); + + status = inSection(414); + pattern = /^.{9}abc.*\n/m; + string = '123\nabcabcabcabc\n'; + actualmatch = string.match(pattern); + expectedmatch = Array('abcabcabcabc\n'); + addThis(); + + status = inSection(415); + pattern = /^(a)?a$/; + string = 'a'; + actualmatch = string.match(pattern); + expectedmatch = Array('a', undefined); + addThis(); + + status = inSection(416); + pattern = /^(a\1?)(a\1?)(a\2?)(a\3?)$/; + string = 'aaaaaa'; + actualmatch = string.match(pattern); + expectedmatch = Array('aaaaaa', 'a', 'aa', 'a', 'aa'); + addThis(); + +/* Can't refer to a capture before it's encountered & completed + status = inSection(417); + pattern = /^(a\1?){4}$/; + string = 'aaaaaa'; + actualmatch = string.match(pattern); + expectedmatch = Array('aaaaaa', 'aaa'); + addThis(); +*/ + + status = inSection(418); + pattern = /^(0+)?(?:x(1))?/; + string = 'x1'; + actualmatch = string.match(pattern); + expectedmatch = Array('x1', undefined, '1'); + addThis(); + + status = inSection(419); + pattern = /^([0-9a-fA-F]+)(?:x([0-9a-fA-F]+)?)(?:x([0-9a-fA-F]+))?/; + string = '012cxx0190'; + actualmatch = string.match(pattern); + expectedmatch = Array('012cxx0190', '012c', undefined, '0190'); + addThis(); + + status = inSection(420); + pattern = /^(b+?|a){1,2}c/; + string = 'bbbac'; + actualmatch = string.match(pattern); + expectedmatch = Array('bbbac', 'a'); + addThis(); + + status = inSection(421); + pattern = /^(b+?|a){1,2}c/; + string = 'bbbbac'; + actualmatch = string.match(pattern); + expectedmatch = Array('bbbbac', 'a'); + addThis(); + + status = inSection(422); + pattern = /((?:aaaa|bbbb)cccc)?/; + string = 'aaaacccc'; + actualmatch = string.match(pattern); + expectedmatch = Array('aaaacccc', 'aaaacccc'); + addThis(); + + status = inSection(423); + pattern = /((?:aaaa|bbbb)cccc)?/; + string = 'bbbbcccc'; + actualmatch = string.match(pattern); + expectedmatch = Array('bbbbcccc', 'bbbbcccc'); + addThis(); + + + + +//----------------------------------------------------------------------------- + test(); +//----------------------------------------------------------------------------- + + + + function addThis() + { + if(omitCurrentSection()) + return; + + statusmessages[i] = status; + patterns[i] = pattern; + strings[i] = string; + actualmatches[i] = actualmatch; + expectedmatches[i] = expectedmatch; + i++; + } + + + function omitCurrentSection() + { + try + { + // current section number is in global status variable + var n = status.match(/(\d+)/)[1]; + return ((n < cnLBOUND) || (n > cnUBOUND)); + } + catch(e) + { + return false; + } + } + + + function test() + { + enterFunc ('test'); + printBugNumber(BUGNUMBER); + printStatus (summary); + testRegExp(statusmessages, patterns, strings, actualmatches, expectedmatches); + exitFunc ('test'); + } diff --git a/tests/auto/qml/parserstress/tests/ecma_3/RegExp/perlstress-002.js b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/perlstress-002.js new file mode 100644 index 0000000000..a9b147b977 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/perlstress-002.js @@ -0,0 +1,1842 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is JavaScript Engine testing utilities. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corp. + * Portions created by the Initial Developer are Copyright (C) 2002 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * pschwartau@netscape.com, rogerl@netscape.com + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +/* + * + * Date: 2002-07-07 + * SUMMARY: Testing JS RegExp engine against Perl 5 RegExp engine. + * Adjust cnLBOUND, cnUBOUND below to restrict which sections are tested. + * + * This test was created by running various patterns and strings through the + * Perl 5 RegExp engine. We saved the results below to test the JS engine. + * + * Each of the examples below is a negative test; that is, each produces a + * null match in Perl. Thus we set |expectedmatch| = |null| in each section. + * + * NOTE: ECMA/JS and Perl do differ on certain points. We have either commented + * out such sections altogether, or modified them to fit what we expect from JS. + * + * EXAMPLES: + * + * - ECMA does support (?: (?= and (?! operators, but doesn't support (?< etc. + * + * - ECMA doesn't support (?(condition) + * + */ +//----------------------------------------------------------------------------- +var gTestfile = 'perlstress-002.js'; +var i = 0; +var BUGNUMBER = 85721; +var summary = 'Testing regular expression edge cases'; +var cnSingleSpace = ' '; +var status = ''; +var statusmessages = new Array(); +var pattern = ''; +var patterns = new Array(); +var string = ''; +var strings = new Array(); +var actualmatch = ''; +var actualmatches = new Array(); +var expectedmatch = ''; +var expectedmatches = new Array(); +var cnLBOUND = 0; +var cnUBOUND = 1000; + + +status = inSection(1); +pattern = /abc/; +string = 'xbc'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(2); +pattern = /abc/; +string = 'axc'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(3); +pattern = /abc/; +string = 'abx'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(4); +pattern = /ab+bc/; +string = 'abc'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(5); +pattern = /ab+bc/; +string = 'abq'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(6); +pattern = /ab{1,}bc/; +string = 'abq'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(7); +pattern = /ab{4,5}bc/; +string = 'abbbbc'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(8); +pattern = /ab?bc/; +string = 'abbbbc'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(9); +pattern = /^abc$/; +string = 'abcc'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(10); +pattern = /^abc$/; +string = 'aabc'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(11); +pattern = /abc$/; +string = 'aabcd'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(12); +pattern = /a.*c/; +string = 'axyzd'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(13); +pattern = /a[bc]d/; +string = 'abc'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(14); +pattern = /a[b-d]e/; +string = 'abd'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(15); +pattern = /a[^bc]d/; +string = 'abd'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(16); +pattern = /a[^-b]c/; +string = 'a-c'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(17); +pattern = /a[^]b]c/; +string = 'a]c'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(18); +pattern = /\by\b/; +string = 'xy'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(19); +pattern = /\by\b/; +string = 'yz'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(20); +pattern = /\by\b/; +string = 'xyz'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(21); +pattern = /\Ba\B/; +string = 'a-'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(22); +pattern = /\Ba\B/; +string = '-a'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(23); +pattern = /\Ba\B/; +string = '-a-'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(24); +pattern = /\w/; +string = '-'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(25); +pattern = /\W/; +string = 'a'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(26); +pattern = /a\sb/; +string = 'a-b'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(27); +pattern = /\d/; +string = '-'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(28); +pattern = /\D/; +string = '1'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(29); +pattern = /[\w]/; +string = '-'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(30); +pattern = /[\W]/; +string = 'a'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(31); +pattern = /a[\s]b/; +string = 'a-b'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(32); +pattern = /[\d]/; +string = '-'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(33); +pattern = /[\D]/; +string = '1'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(34); +pattern = /$b/; +string = 'b'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(35); +pattern = /^(ab|cd)e/; +string = 'abcde'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(36); +pattern = /a[bcd]+dcdcde/; +string = 'adcdcde'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(37); +pattern = /(bc+d$|ef*g.|h?i(j|k))/; +string = 'effg'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(38); +pattern = /(bc+d$|ef*g.|h?i(j|k))/; +string = 'bcdd'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(39); +pattern = /[k]/; +string = 'ab'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +// MODIFIED - ECMA has different rules for paren contents. +status = inSection(40); +pattern = /(a)|\1/; +string = 'x'; +actualmatch = string.match(pattern); +//expectedmatch = null; +expectedmatch = Array("", undefined); +addThis(); + +// MODIFIED - ECMA has different rules for paren contents. +status = inSection(41); +pattern = /((\3|b)\2(a)x)+/; +string = 'aaxabxbaxbbx'; +actualmatch = string.match(pattern); +//expectedmatch = null; +expectedmatch = Array("ax", "ax", "", "a"); +addThis(); + +status = inSection(42); +pattern = /abc/i; +string = 'XBC'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(43); +pattern = /abc/i; +string = 'AXC'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(44); +pattern = /abc/i; +string = 'ABX'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(45); +pattern = /ab+bc/i; +string = 'ABC'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(46); +pattern = /ab+bc/i; +string = 'ABQ'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(47); +pattern = /ab{1,}bc/i; +string = 'ABQ'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(48); +pattern = /ab{4,5}?bc/i; +string = 'ABBBBC'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(49); +pattern = /ab??bc/i; +string = 'ABBBBC'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(50); +pattern = /^abc$/i; +string = 'ABCC'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(51); +pattern = /^abc$/i; +string = 'AABC'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(52); +pattern = /a.*c/i; +string = 'AXYZD'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(53); +pattern = /a[bc]d/i; +string = 'ABC'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(54); +pattern = /a[b-d]e/i; +string = 'ABD'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(55); +pattern = /a[^bc]d/i; +string = 'ABD'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(56); +pattern = /a[^-b]c/i; +string = 'A-C'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(57); +pattern = /a[^]b]c/i; +string = 'A]C'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(58); +pattern = /$b/i; +string = 'B'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(59); +pattern = /^(ab|cd)e/i; +string = 'ABCDE'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(60); +pattern = /a[bcd]+dcdcde/i; +string = 'ADCDCDE'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(61); +pattern = /(bc+d$|ef*g.|h?i(j|k))/i; +string = 'EFFG'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(62); +pattern = /(bc+d$|ef*g.|h?i(j|k))/i; +string = 'BCDD'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(63); +pattern = /[k]/i; +string = 'AB'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(64); +pattern = /^(a\1?){4}$/; +string = 'aaaaaaaaa'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(65); +pattern = /^(a\1?){4}$/; +string = 'aaaaaaaaaaa'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +/* ECMA doesn't support (?( + status = inSection(66); + pattern = /^(a(?(1)\1)){4}$/; + string = 'aaaaaaaaa'; + actualmatch = string.match(pattern); + expectedmatch = null; + addThis(); + + status = inSection(67); + pattern = /^(a(?(1)\1)){4}$/; + string = 'aaaaaaaaaaa'; + actualmatch = string.match(pattern); + expectedmatch = null; + addThis(); +*/ + +/* ECMA doesn't support (?< + status = inSection(68); + pattern = /(?<=a)b/; + string = 'cb'; + actualmatch = string.match(pattern); + expectedmatch = null; + addThis(); + + status = inSection(69); + pattern = /(?<=a)b/; + string = 'b'; + actualmatch = string.match(pattern); + expectedmatch = null; + addThis(); + + status = inSection(70); + pattern = /(?a+)ab/; +string = 'aaab'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(106); +pattern = /a\Z/; +string = 'a\nb\n'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(107); +pattern = /a\z/; +string = 'a\nb\n'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(108); +pattern = /a$/; +string = 'a\nb\n'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(109); +pattern = /a\z/; +string = 'b\na\n'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(110); +pattern = /a\z/m; +string = 'a\nb\n'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(111); +pattern = /a\z/m; +string = 'b\na\n'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(112); +pattern = /aa\Z/; +string = 'aa\nb\n'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(113); +pattern = /aa\z/; +string = 'aa\nb\n'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(114); +pattern = /aa$/; +string = 'aa\nb\n'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(115); +pattern = /aa\z/; +string = 'b\naa\n'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(116); +pattern = /aa\z/m; +string = 'aa\nb\n'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(117); +pattern = /aa\z/m; +string = 'b\naa\n'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(118); +pattern = /aa\Z/; +string = 'ac\nb\n'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(119); +pattern = /aa\z/; +string = 'ac\nb\n'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(120); +pattern = /aa$/; +string = 'ac\nb\n'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(121); +pattern = /aa\Z/; +string = 'b\nac\n'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(122); +pattern = /aa\z/; +string = 'b\nac\n'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(123); +pattern = /aa$/; +string = 'b\nac\n'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(124); +pattern = /aa\Z/; +string = 'b\nac'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(125); +pattern = /aa\z/; +string = 'b\nac'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(126); +pattern = /aa$/; +string = 'b\nac'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(127); +pattern = /aa\Z/m; +string = 'ac\nb\n'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(128); +pattern = /aa\z/m; +string = 'ac\nb\n'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(129); +pattern = /aa$/m; +string = 'ac\nb\n'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(130); +pattern = /aa\Z/m; +string = 'b\nac\n'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(131); +pattern = /aa\z/m; +string = 'b\nac\n'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(132); +pattern = /aa$/m; +string = 'b\nac\n'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(133); +pattern = /aa\Z/m; +string = 'b\nac'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(134); +pattern = /aa\z/m; +string = 'b\nac'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(135); +pattern = /aa$/m; +string = 'b\nac'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(136); +pattern = /aa\Z/; +string = 'ca\nb\n'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(137); +pattern = /aa\z/; +string = 'ca\nb\n'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(138); +pattern = /aa$/; +string = 'ca\nb\n'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(139); +pattern = /aa\Z/; +string = 'b\nca\n'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(140); +pattern = /aa\z/; +string = 'b\nca\n'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(141); +pattern = /aa$/; +string = 'b\nca\n'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(142); +pattern = /aa\Z/; +string = 'b\nca'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(143); +pattern = /aa\z/; +string = 'b\nca'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(144); +pattern = /aa$/; +string = 'b\nca'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(145); +pattern = /aa\Z/m; +string = 'ca\nb\n'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(146); +pattern = /aa\z/m; +string = 'ca\nb\n'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(147); +pattern = /aa$/m; +string = 'ca\nb\n'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(148); +pattern = /aa\Z/m; +string = 'b\nca\n'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(149); +pattern = /aa\z/m; +string = 'b\nca\n'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(150); +pattern = /aa$/m; +string = 'b\nca\n'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(151); +pattern = /aa\Z/m; +string = 'b\nca'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(152); +pattern = /aa\z/m; +string = 'b\nca'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(153); +pattern = /aa$/m; +string = 'b\nca'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(154); +pattern = /ab\Z/; +string = 'ab\nb\n'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(155); +pattern = /ab\z/; +string = 'ab\nb\n'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(156); +pattern = /ab$/; +string = 'ab\nb\n'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(157); +pattern = /ab\z/; +string = 'b\nab\n'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(158); +pattern = /ab\z/m; +string = 'ab\nb\n'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(159); +pattern = /ab\z/m; +string = 'b\nab\n'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(160); +pattern = /ab\Z/; +string = 'ac\nb\n'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(161); +pattern = /ab\z/; +string = 'ac\nb\n'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(162); +pattern = /ab$/; +string = 'ac\nb\n'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(163); +pattern = /ab\Z/; +string = 'b\nac\n'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(164); +pattern = /ab\z/; +string = 'b\nac\n'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(165); +pattern = /ab$/; +string = 'b\nac\n'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(166); +pattern = /ab\Z/; +string = 'b\nac'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(167); +pattern = /ab\z/; +string = 'b\nac'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(168); +pattern = /ab$/; +string = 'b\nac'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(169); +pattern = /ab\Z/m; +string = 'ac\nb\n'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(170); +pattern = /ab\z/m; +string = 'ac\nb\n'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(171); +pattern = /ab$/m; +string = 'ac\nb\n'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(172); +pattern = /ab\Z/m; +string = 'b\nac\n'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(173); +pattern = /ab\z/m; +string = 'b\nac\n'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(174); +pattern = /ab$/m; +string = 'b\nac\n'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(175); +pattern = /ab\Z/m; +string = 'b\nac'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(176); +pattern = /ab\z/m; +string = 'b\nac'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(177); +pattern = /ab$/m; +string = 'b\nac'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(178); +pattern = /ab\Z/; +string = 'ca\nb\n'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(179); +pattern = /ab\z/; +string = 'ca\nb\n'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(180); +pattern = /ab$/; +string = 'ca\nb\n'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(181); +pattern = /ab\Z/; +string = 'b\nca\n'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(182); +pattern = /ab\z/; +string = 'b\nca\n'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(183); +pattern = /ab$/; +string = 'b\nca\n'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(184); +pattern = /ab\Z/; +string = 'b\nca'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(185); +pattern = /ab\z/; +string = 'b\nca'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(186); +pattern = /ab$/; +string = 'b\nca'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(187); +pattern = /ab\Z/m; +string = 'ca\nb\n'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(188); +pattern = /ab\z/m; +string = 'ca\nb\n'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(189); +pattern = /ab$/m; +string = 'ca\nb\n'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(190); +pattern = /ab\Z/m; +string = 'b\nca\n'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(191); +pattern = /ab\z/m; +string = 'b\nca\n'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(192); +pattern = /ab$/m; +string = 'b\nca\n'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(193); +pattern = /ab\Z/m; +string = 'b\nca'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(194); +pattern = /ab\z/m; +string = 'b\nca'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(195); +pattern = /ab$/m; +string = 'b\nca'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(196); +pattern = /abb\Z/; +string = 'abb\nb\n'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(197); +pattern = /abb\z/; +string = 'abb\nb\n'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(198); +pattern = /abb$/; +string = 'abb\nb\n'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(199); +pattern = /abb\z/; +string = 'b\nabb\n'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(200); +pattern = /abb\z/m; +string = 'abb\nb\n'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(201); +pattern = /abb\z/m; +string = 'b\nabb\n'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(202); +pattern = /abb\Z/; +string = 'ac\nb\n'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(203); +pattern = /abb\z/; +string = 'ac\nb\n'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(204); +pattern = /abb$/; +string = 'ac\nb\n'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(205); +pattern = /abb\Z/; +string = 'b\nac\n'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(206); +pattern = /abb\z/; +string = 'b\nac\n'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(207); +pattern = /abb$/; +string = 'b\nac\n'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(208); +pattern = /abb\Z/; +string = 'b\nac'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(209); +pattern = /abb\z/; +string = 'b\nac'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(210); +pattern = /abb$/; +string = 'b\nac'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(211); +pattern = /abb\Z/m; +string = 'ac\nb\n'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(212); +pattern = /abb\z/m; +string = 'ac\nb\n'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(213); +pattern = /abb$/m; +string = 'ac\nb\n'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(214); +pattern = /abb\Z/m; +string = 'b\nac\n'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(215); +pattern = /abb\z/m; +string = 'b\nac\n'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(216); +pattern = /abb$/m; +string = 'b\nac\n'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(217); +pattern = /abb\Z/m; +string = 'b\nac'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(218); +pattern = /abb\z/m; +string = 'b\nac'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(219); +pattern = /abb$/m; +string = 'b\nac'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(220); +pattern = /abb\Z/; +string = 'ca\nb\n'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(221); +pattern = /abb\z/; +string = 'ca\nb\n'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(222); +pattern = /abb$/; +string = 'ca\nb\n'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(223); +pattern = /abb\Z/; +string = 'b\nca\n'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(224); +pattern = /abb\z/; +string = 'b\nca\n'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(225); +pattern = /abb$/; +string = 'b\nca\n'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(226); +pattern = /abb\Z/; +string = 'b\nca'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(227); +pattern = /abb\z/; +string = 'b\nca'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(228); +pattern = /abb$/; +string = 'b\nca'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(229); +pattern = /abb\Z/m; +string = 'ca\nb\n'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(230); +pattern = /abb\z/m; +string = 'ca\nb\n'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(231); +pattern = /abb$/m; +string = 'ca\nb\n'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(232); +pattern = /abb\Z/m; +string = 'b\nca\n'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(233); +pattern = /abb\z/m; +string = 'b\nca\n'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(234); +pattern = /abb$/m; +string = 'b\nca\n'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(235); +pattern = /abb\Z/m; +string = 'b\nca'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(236); +pattern = /abb\z/m; +string = 'b\nca'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(237); +pattern = /abb$/m; +string = 'b\nca'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(238); +pattern = /a*abc?xyz+pqr{3}ab{2,}xy{4,5}pq{0,6}AB{0,}zz/; +string = 'x'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(239); +pattern = /\GX.*X/; +string = 'aaaXbX'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(240); +pattern = /\.c(pp|xx|c)?$/i; +string = 'Changes'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(241); +pattern = /^([a-z]:)/; +string = 'C:/'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(242); +pattern = /(\w)?(abc)\1b/; +string = 'abcab'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +/* ECMA doesn't support (?( + status = inSection(243); + pattern = /^(a)?(?(1)a|b)+$/; + string = 'a'; + actualmatch = string.match(pattern); + expectedmatch = null; + addThis(); +*/ + + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + + + +function addThis() +{ + if(omitCurrentSection()) + return; + + statusmessages[i] = status; + patterns[i] = pattern; + strings[i] = string; + actualmatches[i] = actualmatch; + expectedmatches[i] = expectedmatch; + i++; +} + + +function omitCurrentSection() +{ + try + { + // current section number is in global status variable + var n = status.match(/(\d+)/)[1]; + return ((n < cnLBOUND) || (n > cnUBOUND)); + } + catch(e) + { + return false; + } +} + + +function test() +{ + enterFunc ('test'); + printBugNumber(BUGNUMBER); + printStatus (summary); + testRegExp(statusmessages, patterns, strings, actualmatches, expectedmatches); + exitFunc ('test'); +} diff --git a/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-100199.js b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-100199.js new file mode 100644 index 0000000000..8c88aa7f52 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-100199.js @@ -0,0 +1,307 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is mozilla.org code. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * pschwartau@netscape.com + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +/* + * Date: 17 September 2001 + * + * SUMMARY: Regression test for Bugzilla bug 100199 + * See http://bugzilla.mozilla.org/show_bug.cgi?id=100199 + * + * The empty character class [] is a valid RegExp construct: the condition + * that a given character belong to a set containing no characters. As such, + * it can never be met and is always FALSE. Similarly, [^] is a condition + * that matches any given character and is always TRUE. + * + * Neither one of these conditions should cause syntax errors in a RegExp. + */ +//----------------------------------------------------------------------------- +var gTestfile = 'regress-100199.js'; +var i = 0; +var BUGNUMBER = 100199; +var summary = '[], [^] are valid RegExp conditions. Should not cause errors -'; +var status = ''; +var statusmessages = new Array(); +var pattern = ''; +var patterns = new Array(); +var string = ''; +var strings = new Array(); +var actualmatch = ''; +var actualmatches = new Array(); +var expectedmatch = ''; +var expectedmatches = new Array(); + + +pattern = /[]/; +string = 'abc'; +status = inSection(1); +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +string = ''; +status = inSection(2); +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +string = '['; +status = inSection(3); +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +string = '/'; +status = inSection(4); +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +string = '['; +status = inSection(5); +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +string = ']'; +status = inSection(6); +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +string = '[]'; +status = inSection(7); +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +string = '[ ]'; +status = inSection(8); +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +string = ']['; +status = inSection(9); +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + + +pattern = /a[]/; +string = 'abc'; +status = inSection(10); +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +string = ''; +status = inSection(11); +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +string = 'a['; +status = inSection(12); +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +string = 'a[]'; +status = inSection(13); +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +string = '['; +status = inSection(14); +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +string = ']'; +status = inSection(15); +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +string = '[]'; +status = inSection(16); +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +string = '[ ]'; +status = inSection(17); +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +string = ']['; +status = inSection(18); +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + + +pattern = /[^]/; +string = 'abc'; +status = inSection(19); +actualmatch = string.match(pattern); +expectedmatch = Array('a'); +addThis(); + +string = ''; +status = inSection(20); +actualmatch = string.match(pattern); +expectedmatch = null; //there are no characters to test against the condition +addThis(); + +string = '\/'; +status = inSection(21); +actualmatch = string.match(pattern); +expectedmatch = Array('/'); +addThis(); + +string = '\['; +status = inSection(22); +actualmatch = string.match(pattern); +expectedmatch = Array('['); +addThis(); + +string = '['; +status = inSection(23); +actualmatch = string.match(pattern); +expectedmatch = Array('['); +addThis(); + +string = ']'; +status = inSection(24); +actualmatch = string.match(pattern); +expectedmatch = Array(']'); +addThis(); + +string = '[]'; +status = inSection(25); +actualmatch = string.match(pattern); +expectedmatch = Array('['); +addThis(); + +string = '[ ]'; +status = inSection(26); +actualmatch = string.match(pattern); +expectedmatch = Array('['); +addThis(); + +string = ']['; +status = inSection(27); +actualmatch = string.match(pattern); +expectedmatch = Array(']'); +addThis(); + + +pattern = /a[^]/; +string = 'abc'; +status = inSection(28); +actualmatch = string.match(pattern); +expectedmatch = Array('ab'); +addThis(); + +string = ''; +status = inSection(29); +actualmatch = string.match(pattern); +expectedmatch = null; //there are no characters to test against the condition +addThis(); + +string = 'a['; +status = inSection(30); +actualmatch = string.match(pattern); +expectedmatch = Array('a['); +addThis(); + +string = 'a]'; +status = inSection(31); +actualmatch = string.match(pattern); +expectedmatch = Array('a]'); +addThis(); + +string = 'a[]'; +status = inSection(32); +actualmatch = string.match(pattern); +expectedmatch = Array('a['); +addThis(); + +string = 'a[ ]'; +status = inSection(33); +actualmatch = string.match(pattern); +expectedmatch = Array('a['); +addThis(); + +string = 'a]['; +status = inSection(34); +actualmatch = string.match(pattern); +expectedmatch = Array('a]'); +addThis(); + + + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + + + +function addThis() +{ + statusmessages[i] = status; + patterns[i] = pattern; + strings[i] = string; + actualmatches[i] = actualmatch; + expectedmatches[i] = expectedmatch; + i++; +} + + +function test() +{ + enterFunc ('test'); + printBugNumber(BUGNUMBER); + printStatus (summary); + testRegExp(statusmessages, patterns, strings, actualmatches, expectedmatches); + exitFunc ('test'); +} diff --git a/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-105972.js b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-105972.js new file mode 100644 index 0000000000..e691c518b4 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-105972.js @@ -0,0 +1,157 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is mozilla.org code. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * mozilla@pdavis.cx, pschwartau@netscape.com + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +/* + * Date: 22 October 2001 + * + * SUMMARY: Regression test for Bugzilla bug 105972: + * "/^.*?$/ will not match anything" + * + * See http://bugzilla.mozilla.org/show_bug.cgi?id=105972 + */ +//----------------------------------------------------------------------------- +var gTestfile = 'regress-105972.js'; +var i = 0; +var BUGNUMBER = 105972; +var summary = 'Regression test for Bugzilla bug 105972'; +var cnEmptyString = ''; +var status = ''; +var statusmessages = new Array(); +var pattern = ''; +var patterns = new Array(); +var string = ''; +var strings = new Array(); +var actualmatch = ''; +var actualmatches = new Array(); +var expectedmatch = ''; +var expectedmatches = new Array(); + + +/* + * The bug: this match was coming up null in Rhino and SpiderMonkey. + * It should match the whole string. The reason: + * + * The * operator is greedy, but *? is non-greedy: it will stop + * at the simplest match it can find. But the pattern here asks us + * to match till the end of the string. So the simplest match must + * go all the way out to the end, and *? has no choice but to do it. + */ +status = inSection(1); +pattern = /^.*?$/; +string = 'Hello World'; +actualmatch = string.match(pattern); +expectedmatch = Array(string); +addThis(); + + +/* + * Leave off the '$' condition - here we expect the empty string. + * Unlike the above pattern, we don't have to match till the end of + * the string, so the non-greedy operator *? doesn't try to... + */ +status = inSection(2); +pattern = /^.*?/; +string = 'Hello World'; +actualmatch = string.match(pattern); +expectedmatch = Array(cnEmptyString); +addThis(); + + +/* + * Try '$' combined with an 'or' operator. + * + * The operator *? will consume the string from left to right, + * attempting to satisfy the condition (:|$). When it hits ':', + * the match will stop because the operator *? is non-greedy. + * + * The submatch $1 = (:|$) will contain the ':' + */ +status = inSection(3); +pattern = /^.*?(:|$)/; +string = 'Hello: World'; +actualmatch = string.match(pattern); +expectedmatch = Array('Hello:', ':'); +addThis(); + + +/* + * Again, '$' combined with an 'or' operator. + * + * The operator * will consume the string from left to right, + * attempting to satisfy the condition (:|$). When it hits ':', + * the match will not stop since * is greedy. The match will + * continue until it hits $, the end-of-string boundary. + * + * The submatch $1 = (:|$) will contain the empty string + * conceived to exist at the end-of-string boundary. + */ +status = inSection(4); +pattern = /^.*(:|$)/; +string = 'Hello: World'; +actualmatch = string.match(pattern); +expectedmatch = Array(string, cnEmptyString); +addThis(); + + + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + + + +function addThis() +{ + statusmessages[i] = status; + patterns[i] = pattern; + strings[i] = string; + actualmatches[i] = actualmatch; + expectedmatches[i] = expectedmatch; + i++; +} + + +function test() +{ + enterFunc ('test'); + printBugNumber(BUGNUMBER); + printStatus (summary); + testRegExp(statusmessages, patterns, strings, actualmatches, expectedmatches); + exitFunc ('test'); +} diff --git a/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-119909.js b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-119909.js new file mode 100644 index 0000000000..97f6414bc7 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-119909.js @@ -0,0 +1,92 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is JavaScript Engine testing utilities. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corp. + * Portions created by the Initial Developer are Copyright (C) 2001 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * 1010mozilla@Ostermiller.com, pschwartau@netscape.com + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +/* + * + * Date: 14 Jan 2002 + * SUMMARY: Shouldn't crash on regexps with many nested parentheses + * See http://bugzilla.mozilla.org/show_bug.cgi?id=119909 + * + */ +//----------------------------------------------------------------------------- +var gTestfile = 'regress-119909.js'; +var BUGNUMBER = 119909; +var summary = "Shouldn't crash on regexps with many nested parentheses"; +var NO_BACKREFS = false; +var DO_BACKREFS = true; + + +//-------------------------------------------------- +test(); +//-------------------------------------------------- + + +function test() +{ + enterFunc('test'); + printBugNumber(BUGNUMBER); + printStatus(summary); + + testThis(500, NO_BACKREFS, 'hello', 'goodbye'); + testThis(500, DO_BACKREFS, 'hello', 'goodbye'); + + reportCompare('No Crash', 'No Crash', ''); + + exitFunc('test'); +} + + +/* + * Creates a regexp pattern like (((((((((hello))))))))) + * and tests str.search(), str.match(), str.replace() + */ +function testThis(numParens, doBackRefs, strOriginal, strReplace) +{ + var openParen = doBackRefs? '(' : '(?:'; + var closeParen = ')'; + var pattern = ''; + + for (var i=0; i((.*\n?)*?)<\/body>/i; +actualmatch = string.match(pattern); +expectedmatch = Array(sBody, '\n

Kibology for all

\n

All for Kibology

\n', '

All for Kibology

\n'); +addThis(); + + + +//------------------------------------------------------------------------------------------------- +test(); +//------------------------------------------------------------------------------------------------- + + +function addThis() +{ + statusmessages[i] = status; + patterns[i] = pattern; + strings[i] = string; + actualmatches[i] = actualmatch; + expectedmatches[i] = expectedmatch; + i++; +} + + +function test() +{ + enterFunc ('test'); + printBugNumber(BUGNUMBER); + printStatus (summary); + testRegExp(statusmessages, patterns, strings, actualmatches, expectedmatches); + exitFunc ('test'); +} diff --git a/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-169534.js b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-169534.js new file mode 100644 index 0000000000..c736631bd7 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-169534.js @@ -0,0 +1,95 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is JavaScript Engine testing utilities. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corp. + * Portions created by the Initial Developer are Copyright (C) 2002 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * pschwartau@netscape.com + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +/* + * + * Date: 20 Sep 2002 + * SUMMARY: RegExp conformance test + * See http://bugzilla.mozilla.org/show_bug.cgi?id=169534 + * + */ +//----------------------------------------------------------------------------- +var gTestfile = 'regress-169534.js'; +var UBound = 0; +var BUGNUMBER = 169534; +var summary = 'RegExp conformance test'; +var status = ''; +var statusitems = []; +var actual = ''; +var actualvalues = []; +var expect= ''; +var expectedvalues = []; + + +status = inSection(1); +var re = /(\|)([\w\x81-\xff ]*)(\|)([\/a-z][\w:\/\.]*\.[a-z]{3,4})(\|)/ig; +var str = "To sign up click |here|https://www.xxxx.org/subscribe.htm|"; +actual = str.replace(re, '$2'); +expect = 'To sign up click here'; +addThis(); + + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + + + +function addThis() +{ + statusitems[UBound] = status; + actualvalues[UBound] = actual; + expectedvalues[UBound] = expect; + UBound++; +} + + +function test() +{ + enterFunc('test'); + printBugNumber(BUGNUMBER); + printStatus(summary); + + for (var i=0; i/g,'>'); + } + + h+='\n'; + h=h.replace(/&([^\s]+;)/g,'<&$1>'); + h=h.replace(new RegExp('','g'), S); + h=h.replace(/"[^"]*"/g,S); + h=h.replace(/'[^']*'/g,S); + + + h=h.replace(/<([^>]*)>/g, + function(s,p) + { + if(s.match(/!doctype/i)) + return'<' + p + '>'; + + p=p.replace(/\\'/g,'\\'').replace(/\\"/g,'\\"').replace(/^\s/,''); +p=p.replace(/(\s)([^<]+)$/g, + function(s,p1,p2) + { + p2=p2.replace(/(=)(\s*[^"'][^\s]*)(\s|$)/g,'$1$2$3'); + p2=p2.replace(/("[^"]*")/g,'$1'); + p2=p2.replace(/('[^']*')/g,'$1'); + return p1 + ''+p2+''; + } + ) + + return'<' + p + '>'; + } + ) + + + h=h.replace(/<(&[^\s]+;)>/g,'$1'); + h=h.replace(/(<!--[\s\S]*-->)/g,'$1'); + + + numer=1; + h=h.replace(/(.*\n)/g, + function(s,p) + { + return (numer++) +'. ' + p; + } + ) + + + return'' + h + ''; +} + + + +/* + * sanity check + */ +status = inSection(1); +actual = formatHTML('abc'); +expect = '1. abc\n'; +addThis(); + + +/* + * The real test: can we run this without crashing? + * We are not validating the result, just running it. + */ +status = inSection(2); +var HUGE_TEST_STRING = hugeString(); +formatHTML(HUGE_TEST_STRING); + + + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + + + +function addThis() +{ + statusitems[UBound] = status; + actualvalues[UBound] = actual; + expectedvalues[UBound] = expect; + UBound++; +} + + +function test() +{ + enterFunc('test'); + printBugNumber(BUGNUMBER); + printStatus(summary); + + for (var i=0; i','g'),""); + stra=stra.replace(new RegExp('','g'),"
"); +} + +function runTest() { + for (var j = 1000; j <= 10000; j += 1000) + { + neurodna(j); + } +} + +function neurodna(limit) { + var prepare=""; + for(var i=0;i])*-->', 'g'), ''); +printStatus(data); + +reportCompare(expect, actual, summary); diff --git a/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-309840.js b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-309840.js new file mode 100755 index 0000000000..8680b7bcfd --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-309840.js @@ -0,0 +1,58 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is JavaScript Engine testing utilities. + * + * The Initial Developer of the Original Code is + * Mozilla Foundation. + * Portions created by the Initial Developer are Copyright (C) 2005 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): Phil Schwartau + * Bob Clary + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +var gTestfile = 'regress-309840.js'; +//----------------------------------------------------------------------------- +var BUGNUMBER = 309840; +var summary = 'Treat / in a literal regexp class as valid'; +var actual = 'No error'; +var expect = 'No error'; + +printBugNumber(BUGNUMBER); +printStatus (summary); + +try +{ + var re = eval('/[/]/'); +} +catch(e) +{ + actual = e.toString(); +} + +reportCompare(expect, actual, summary); diff --git a/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-311414.js b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-311414.js new file mode 100755 index 0000000000..a24a07bb2b --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-311414.js @@ -0,0 +1,101 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is JavaScript Engine testing utilities. + * + * The Initial Developer of the Original Code is + * Mozilla Foundation. + * Portions created by the Initial Developer are Copyright (C) 2005 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): timeless + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +var gTestfile = 'regress-311414.js'; +//----------------------------------------------------------------------------- +var BUGNUMBER = 311414; +var summary = 'RegExp captured tail match should be O(N)'; +var actual = ''; +var expect = ''; + +printBugNumber(BUGNUMBER); +printStatus (summary); + +function q1(n) { + var c = []; + c[n] = 1; + c = c.join(" "); + var d = Date.now(); + var e = c.match(/(.*)foo$/); + var f = Date.now(); + return (f - d); +} + +function q2(n) { + var c = []; + c[n] = 1; + c = c.join(" "); + var d = Date.now(); + var e = /foo$/.test(c) && c.match(/(.*)foo$/); + var f = Date.now(); + return (f - d); +} + +var data1 = {X:[], Y:[]}; +var data2 = {X:[], Y:[]}; + +for (var x = 500; x < 5000; x += 500) +{ + var y1 = q1(x); + var y2 = q2(x); + data1.X.push(x); + data1.Y.push(y1); + data2.X.push(x); + data2.Y.push(y2); + gc(); +} + +var order1 = BigO(data1); +var order2 = BigO(data2); + +var msg = ''; +for (var p = 0; p < data1.X.length; p++) +{ + msg += '(' + data1.X[p] + ', ' + data1.Y[p] + '); '; +} +printStatus(msg); +printStatus('Order: ' + order1); +reportCompare(true, order1 < 2 , summary + ' BigO ' + order1 + ' < 2'); + +msg = ''; +for (var p = 0; p < data2.X.length; p++) +{ + msg += '(' + data2.X[p] + ', ' + data2.Y[p] + '); '; +} +printStatus(msg); +printStatus('Order: ' + order2); +reportCompare(true, order2 < 2 , summary + ' BigO ' + order2 + ' < 2'); diff --git a/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-312351.js b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-312351.js new file mode 100755 index 0000000000..a9b00d317c --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-312351.js @@ -0,0 +1,50 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is JavaScript Engine testing utilities. + * + * The Initial Developer of the Original Code is + * Mozilla Foundation. + * Portions created by the Initial Developer are Copyright (C) 2005 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): drimbk@yahoo.com + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +var gTestfile = 'regress-312351.js'; +//----------------------------------------------------------------------------- +var BUGNUMBER = 312351; +var summary = 'Do not crash on RegExp(null)'; +var actual = 'No Crash'; +var expect = 'No Crash'; + +printBugNumber(BUGNUMBER); +printStatus (summary); + +var x = RegExp(null); + +reportCompare(expect, actual, summary); diff --git a/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-31316.js b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-31316.js new file mode 100644 index 0000000000..594913f07c --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-31316.js @@ -0,0 +1,96 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is mozilla.org code. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * pschwartau@netscape.com + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +/* + * Date: 01 May 2001 + * + * SUMMARY: Regression test for Bugzilla bug 31316: + * "Rhino: Regexp matches return garbage" + * + * See http://bugzilla.mozilla.org/show_bug.cgi?id=31316 + */ +//----------------------------------------------------------------------------- +var gTestfile = 'regress-31316.js'; +var i = 0; +var BUGNUMBER = 31316; +var summary = 'Regression test for Bugzilla bug 31316'; +var cnEmptyString = ''; +var status = ''; +var statusmessages = new Array(); +var pattern = ''; +var patterns = new Array(); +var string = ''; +var strings = new Array(); +var actualmatch = ''; +var actualmatches = new Array(); +var expectedmatch = ''; +var expectedmatches = new Array(); + + +status = inSection(1); +pattern = /<([^\/<>][^<>]*[^\/])>|<([^\/<>])>/; +string = '

Some
test

'; +actualmatch = string.match(pattern); +expectedmatch = Array('

', undefined, 'p'); +addThis(); + + +//------------------------------------------------------------------------------------------------- +test(); +//------------------------------------------------------------------------------------------------- + + +function addThis() +{ + statusmessages[i] = status; + patterns[i] = pattern; + strings[i] = string; + actualmatches[i] = actualmatch; + expectedmatches[i] = expectedmatch; + i++; +} + + +function test() +{ + enterFunc ('test'); + printBugNumber(BUGNUMBER); + printStatus (summary); + testRegExp(statusmessages, patterns, strings, actualmatches, expectedmatches); + exitFunc ('test'); +} diff --git a/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-330684.js b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-330684.js new file mode 100755 index 0000000000..b097fbc3d7 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-330684.js @@ -0,0 +1,53 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is JavaScript Engine testing utilities. + * + * The Initial Developer of the Original Code is + * Mozilla Foundation. + * Portions created by the Initial Developer are Copyright (C) 2006 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): Shaohua Wen + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +var gTestfile = 'regress-330684.js'; +//----------------------------------------------------------------------------- +var BUGNUMBER = 330684; +var summary = 'Do not hang on RegExp'; +var actual = 'Do not hang on RegExp'; +var expect = ''; + +printBugNumber(BUGNUMBER); +printStatus (summary); + +var re = /^(?:(?:%[0-9A-Fa-f]{2})*[!\$&'\*-;=\?-Z_a-z]*)+$/; +var url = "http://tw.yimg.com/a/tw/wenchuan/cam_240x400_381615_030806_2.swf?clickTAG=javascript:VRECopenWindow(1)"; + +printStatus(re.test(url)); + +reportCompare(expect, actual, summary); diff --git a/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-334158.js b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-334158.js new file mode 100755 index 0000000000..41ebf0a731 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-334158.js @@ -0,0 +1,58 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is JavaScript Engine testing utilities. + * + * The Initial Developer of the Original Code is + * Mozilla Foundation. + * Portions created by the Initial Developer are Copyright (C) 2006 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): Andreas + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +var gTestfile = 'regress-334158.js'; +//----------------------------------------------------------------------------- +var BUGNUMBER = 334158; +var summary = 'Parse error in control letter escapes (RegExp)'; +var actual = ''; +var expect = ''; + +printBugNumber(BUGNUMBER); +printStatus (summary); + +expect = true; +actual = /\ca/.test( "\x01" ); +reportCompare(expect, actual, summary + ':/\ca/.test( "\x01" )'); + +expect = false + actual = /\ca/.test( "\\ca" ); +reportCompare(expect, actual, summary + ': /\ca/.test( "\\ca" )'); + +expect = false + actual = /\c[a/]/.test( "\x1ba/]" ); +reportCompare(expect, actual, summary + ': /\c[a/]/.test( "\x1ba/]" )'); diff --git a/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-346090.js b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-346090.js new file mode 100755 index 0000000000..dfd53a9922 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-346090.js @@ -0,0 +1,63 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is JavaScript Engine testing utilities. + * + * The Initial Developer of the Original Code is + * Mozilla Foundation. + * Portions created by the Initial Developer are Copyright (C) 2006 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): Priit Laes + * Brian Crowder + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +var gTestfile = 'regress-346090.js'; +//----------------------------------------------------------------------------- +var BUGNUMBER = 346090; +var summary = 'Do not crash with this regexp'; +var actual = 'No Crash'; +var expect = 'No Crash'; + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + enterFunc ('test'); + printBugNumber(BUGNUMBER); + printStatus (summary); + + var r = /%((h[^l]+)|(l[^h]+)){0,2}?a/g; + r.exec('%lld %d'); + + reportCompare(expect, actual, summary); + + exitFunc ('test'); +} diff --git a/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-367888.js b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-367888.js new file mode 100755 index 0000000000..923c1e5ab3 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-367888.js @@ -0,0 +1,62 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is JavaScript Engine testing utilities. + * + * The Initial Developer of the Original Code is + * Mozilla Foundation. + * Portions created by the Initial Developer are Copyright (C) 2007 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): Jesse Ruderman + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +var gTestfile = 'regress-367888.js'; +//----------------------------------------------------------------------------- +var BUGNUMBER = 367888; +var summary = 'RegExp /(|)??x/g.exec("y") barfs'; +var actual = ''; +var expect = ''; + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + enterFunc ('test'); + printBugNumber(BUGNUMBER); + printStatus (summary); + + expect = null; + actual = /(|)??x/g.exec("y"); + + reportCompare(expect, actual, summary); + + exitFunc ('test'); +} diff --git a/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-375642.js b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-375642.js new file mode 100755 index 0000000000..236eb00d28 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-375642.js @@ -0,0 +1,61 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is JavaScript Engine testing utilities. + * + * The Initial Developer of the Original Code is + * Mozilla Foundation. + * Portions created by the Initial Developer are Copyright (C) 2007 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): Jesse Ruderman + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +var gTestfile = 'regress-375642.js'; +//----------------------------------------------------------------------------- +var BUGNUMBER = 375642; +var summary = 'RegExp /(?:a??)+?/.exec("")'; +var actual = ''; +var expect = ''; + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + enterFunc ('test'); + printBugNumber(BUGNUMBER); + printStatus (summary); + + /(?:a??)+?/.exec("") + + reportCompare(expect, actual, summary); + + exitFunc ('test'); +} diff --git a/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-375711.js b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-375711.js new file mode 100755 index 0000000000..6e7339f9e9 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-375711.js @@ -0,0 +1,118 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is JavaScript Engine testing utilities. + * + * The Initial Developer of the Original Code is + * Mozilla Foundation. + * Portions created by the Initial Developer are Copyright (C) 2007 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): Jesse Ruderman + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +var gTestfile = 'regress-375711.js'; +//----------------------------------------------------------------------------- +var BUGNUMBER = 375711; +var summary = 'Do not assert with /[Q-b]/i.exec("")'; +var actual = ''; +var expect = ''; + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + enterFunc ('test'); + printBugNumber(BUGNUMBER); + printStatus (summary); + + var s; + + // see bug 416933 + print('see bug 416933 for changed behavior on Gecko 1.9'); + + try + { + s = '/[Q-b]/.exec("")'; + expect = 'No Error'; + print(s + ' expect ' + expect); + eval(s); + actual = 'No Error'; + } + catch(ex) + { + actual = ex + ''; + } + reportCompare(expect, actual, summary + ': ' + s); + + try + { + s ='/[Q-b]/i.exec("")'; + expect = 'No Error'; + print(s + ' expect ' + expect); + eval(s); + actual = 'No Error'; + } + catch(ex) + { + actual = ex + ''; + } + reportCompare(expect, actual, summary + ': ' + s); + + try + { + s = '/[q-b]/.exec("")'; + expect = 'SyntaxError: invalid range in character class'; + print(s + ' expect ' + expect); + eval(s); + actual = 'No Error'; + } + catch(ex) + { + actual = ex + ''; + } + reportCompare(expect, actual, summary + ': ' + s); + + try + { + s ='/[q-b]/i.exec("")'; + expect = 'SyntaxError: invalid range in character class'; + print(s + ' expect ' + expect); + eval(s); + actual = 'No Error'; + } + catch(ex) + { + actual = ex + ''; + } + reportCompare(expect, actual, summary + ': ' + s); + + exitFunc ('test'); +} diff --git a/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-375715-01-n.js b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-375715-01-n.js new file mode 100755 index 0000000000..437dcbd5c5 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-375715-01-n.js @@ -0,0 +1,63 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is JavaScript Engine testing utilities. + * + * The Initial Developer of the Original Code is + * Mozilla Foundation. + * Portions created by the Initial Developer are Copyright (C) 2007 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): Jesse Ruderman + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +var gTestfile = 'regress-375715-01-n.js'; +//----------------------------------------------------------------------------- +var BUGNUMBER = 375715; +var summary = 'Do not assert: (c2 <= cs->length) && (c1 <= c2)'; +var actual = ''; +var expect = ''; + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + enterFunc ('test'); + printBugNumber(BUGNUMBER); + printStatus (summary); + + // note that the assertion does not fire if the regexp is + // evald or used in new RegExp, so this test must be an -n + // with uncaught SyntaxError. + + /[\Wb-G]/.exec(""); + reportCompare(expect, actual, summary + ' /[\Wb-G]/.exec("")'); + + exitFunc ('test'); +} diff --git a/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-375715-02.js b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-375715-02.js new file mode 100755 index 0000000000..3cd858e845 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-375715-02.js @@ -0,0 +1,60 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is JavaScript Engine testing utilities. + * + * The Initial Developer of the Original Code is + * Mozilla Foundation. + * Portions created by the Initial Developer are Copyright (C) 2007 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): Jesse Ruderman + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +var gTestfile = 'regress-375715-02.js'; +//----------------------------------------------------------------------------- +var BUGNUMBER = 375715; +var summary = 'Do not assert: (c2 <= cs->length) && (c1 <= c2)'; +var actual = ''; +var expect = ''; + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + enterFunc ('test'); + printBugNumber(BUGNUMBER); + printStatus (summary); + + /[\s-:]/; + reportCompare(expect, actual, summary + '/[\s-:]/'); + + exitFunc ('test'); +} diff --git a/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-375715-03.js b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-375715-03.js new file mode 100755 index 0000000000..ffc5c5a4cc --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-375715-03.js @@ -0,0 +1,60 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is JavaScript Engine testing utilities. + * + * The Initial Developer of the Original Code is + * Mozilla Foundation. + * Portions created by the Initial Developer are Copyright (C) 2007 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): Jesse Ruderman + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +var gTestfile = 'regress-375715-03.js'; +//----------------------------------------------------------------------------- +var BUGNUMBER = 375715; +var summary = 'Do not assert: (c2 <= cs->length) && (c1 <= c2)'; +var actual = ''; +var expect = ''; + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + enterFunc ('test'); + printBugNumber(BUGNUMBER); + printStatus (summary); + + /[_-t]/i.exec(""); + reportCompare(expect, actual, summary + '/[_-t]/i.exec("")'); + + exitFunc ('test'); +} diff --git a/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-375715-04.js b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-375715-04.js new file mode 100755 index 0000000000..0c78a372ee --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-375715-04.js @@ -0,0 +1,68 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is JavaScript Engine testing utilities. + * + * The Initial Developer of the Original Code is + * Mozilla Foundation. + * Portions created by the Initial Developer are Copyright (C) 2007 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): Jesse Ruderman + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +var gTestfile = 'regress-375715-04.js'; +//----------------------------------------------------------------------------- +var BUGNUMBER = 375715; +var summary = 'Do not assert: (c2 <= cs->length) && (c1 <= c2)'; +var actual = ''; +var expect = ''; + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + enterFunc ('test'); + printBugNumber(BUGNUMBER); + printStatus (summary); + + try + { + expect = 'SyntaxError: invalid range in character class'; + (new RegExp("[\xDF-\xC7]]", "i")).exec(""); + } + catch(ex) + { + actual = ex + ''; + } + reportCompare(expect, actual, summary + '(new RegExp("[\xDF-\xC7]]", "i")).exec("")'); + + exitFunc ('test'); +} diff --git a/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-57572.js b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-57572.js new file mode 100644 index 0000000000..c7abd410bf --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-57572.js @@ -0,0 +1,150 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is mozilla.org code. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * pschwartau@netscape.com + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +/* + * Date: 28 December 2000 + * + * SUMMARY: Testing regular expressions containing the ? character. + * Arose from Bugzilla bug 57572: "RegExp with ? matches incorrectly" + * + * See http://bugzilla.mozilla.org/show_bug.cgi?id=57572 + * + */ +//----------------------------------------------------------------------------- +var gTestfile = 'regress-57572.js'; +var i = 0; +var BUGNUMBER = 57572; +var summary = 'Testing regular expressions containing "?"'; +var cnEmptyString = ''; var cnSingleSpace = ' '; +var status = ''; +var statusmessages = new Array(); +var pattern = ''; +var patterns = new Array(); +var string = ''; +var strings = new Array(); +var actualmatch = ''; +var actualmatches = new Array(); +var expectedmatch = ''; +var expectedmatches = new Array(); + + +status = inSection(1); +pattern = /(\S+)?(.*)/; +string = 'Test this'; +actualmatch = string.match(pattern); +expectedmatch = Array(string, 'Test', ' this'); //single space in front of 'this' +addThis(); + +status = inSection(2); +pattern = /(\S+)? ?(.*)/; //single space between the ? characters +string= 'Test this'; +actualmatch = string.match(pattern); +expectedmatch = Array(string, 'Test', 'this'); //NO space in front of 'this' +addThis(); + +status = inSection(3); +pattern = /(\S+)?(.*)/; +string = 'Stupid phrase, with six - (short) words'; +actualmatch = string.match(pattern); +expectedmatch = Array(string, 'Stupid', ' phrase, with six - (short) words'); //single space in front of 'phrase' +addThis(); + +status = inSection(4); +pattern = /(\S+)? ?(.*)/; //single space between the ? characters +string = 'Stupid phrase, with six - (short) words'; +actualmatch = string.match(pattern); +expectedmatch = Array(string, 'Stupid', 'phrase, with six - (short) words'); //NO space in front of 'phrase' +addThis(); + + +// let's add an extra back-reference this time - three instead of two - +status = inSection(5); +pattern = /(\S+)?( ?)(.*)/; //single space before second ? character +string = 'Stupid phrase, with six - (short) words'; +actualmatch = string.match(pattern); +expectedmatch = Array(string, 'Stupid', cnSingleSpace, 'phrase, with six - (short) words'); +addThis(); + +status = inSection(6); +pattern = /^(\S+)?( ?)(B+)$/; //single space before second ? character +string = 'AAABBB'; +actualmatch = string.match(pattern); +expectedmatch = Array(string, 'AAABB', cnEmptyString, 'B'); +addThis(); + +status = inSection(7); +pattern = /(\S+)?(!?)(.*)/; +string = 'WOW !!! !!!'; +actualmatch = string.match(pattern); +expectedmatch = Array(string, 'WOW', cnEmptyString, ' !!! !!!'); +addThis(); + +status = inSection(8); +pattern = /(.+)?(!?)(!+)/; +string = 'WOW !!! !!!'; +actualmatch = string.match(pattern); +expectedmatch = Array(string, 'WOW !!! !!', cnEmptyString, '!'); +addThis(); + + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + + + +function addThis() +{ + statusmessages[i] = status; + patterns[i] = pattern; + strings[i] = string; + actualmatches[i] = actualmatch; + expectedmatches[i] = expectedmatch; + i++; +} + + +function test() +{ + enterFunc ('test'); + printBugNumber(BUGNUMBER); + printStatus (summary); + testRegExp(statusmessages, patterns, strings, actualmatches, expectedmatches); + exitFunc ('test'); +} diff --git a/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-57631.js b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-57631.js new file mode 100644 index 0000000000..dc222bfc0f --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-57631.js @@ -0,0 +1,152 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is mozilla.org code. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * pschwartau@netscape.com, zack-weg@gmx.de + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +/* + * Date: 26 November 2000 + * + * + * SUMMARY: This test arose from Bugzilla bug 57631: + * "RegExp with invalid pattern or invalid flag causes segfault" + * + * Either error should throw an exception of type SyntaxError, + * and we check to see that it does... + */ +//----------------------------------------------------------------------------- +var gTestfile = 'regress-57631.js'; +var BUGNUMBER = '57631'; +var summary = 'Testing new RegExp(pattern,flag) with illegal pattern or flag'; +var statprefix = 'Testing for error creating illegal RegExp object on pattern '; +var statsuffix = 'and flag '; +var cnSUCCESS = 'SyntaxError'; +var cnFAILURE = 'not a SyntaxError'; +var singlequote = "'"; +var i = -1; var j = -1; var s = ''; var f = ''; +var obj = {}; +var status = ''; var actual = ''; var expect = ''; var msg = ''; +var legalpatterns = new Array(); var illegalpatterns = new Array(); +var legalflags = new Array(); var illegalflags = new Array(); + + +// valid regular expressions to try - +legalpatterns[0] = ''; +legalpatterns[1] = 'abc'; +legalpatterns[2] = '(.*)(3-1)\s\w'; +legalpatterns[3] = '(.*)(...)\\s\\w'; +legalpatterns[4] = '[^A-Za-z0-9_]'; +legalpatterns[5] = '[^\f\n\r\t\v](123.5)([4 - 8]$)'; + +// invalid regular expressions to try - +illegalpatterns[0] = '(?)'; +illegalpatterns[1] = '(a'; +illegalpatterns[2] = '( ]'; +//illegalpatterns[3] = '\d{1,s}'; + +// valid flags to try - +legalflags[0] = 'i'; +legalflags[1] = 'g'; +legalflags[2] = 'm'; +legalflags[3] = undefined; + +// invalid flags to try - +illegalflags[0] = 'a'; +illegalflags[1] = 123; +illegalflags[2] = new RegExp(); + + + +//------------------------------------------------------------------------------------------------- +test(); +//------------------------------------------------------------------------------------------------- + + +function test() +{ + enterFunc ('test'); + printBugNumber(BUGNUMBER); + printStatus (summary); + + testIllegalRegExps(legalpatterns, illegalflags); + testIllegalRegExps(illegalpatterns, legalflags); + testIllegalRegExps(illegalpatterns, illegalflags); + + exitFunc ('test'); +} + + +// This function will only be called where all the patterns are illegal, or all the flags +function testIllegalRegExps(patterns, flags) +{ + for (i in patterns) + { + s = patterns[i]; + + for (j in flags) + { + f = flags[j]; + status = getStatus(s, f); + actual = cnFAILURE; + expect = cnSUCCESS; + + try + { + // This should cause an exception if either s or f is illegal - + eval('obj = new RegExp(s, f);'); + } + catch(e) + { + // We expect to get a SyntaxError - test for this: + if (e instanceof SyntaxError) + actual = cnSUCCESS; + } + + reportCompare(expect, actual, status); + } + } +} + + +function getStatus(regexp, flag) +{ + return (statprefix + quote(regexp) + statsuffix + quote(flag)); +} + + +function quote(text) +{ + return (singlequote + text + singlequote); +} diff --git a/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-67773.js b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-67773.js new file mode 100644 index 0000000000..4ee0d52854 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-67773.js @@ -0,0 +1,211 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is mozilla.org code. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * pschwartau@netscape.com + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +/* + * Date: 06 February 2001 + * + * SUMMARY: Arose from Bugzilla bug 67773: + * "Regular subexpressions followed by + failing to run to completion" + * + * See http://bugzilla.mozilla.org/show_bug.cgi?id=67773 + * See http://bugzilla.mozilla.org/show_bug.cgi?id=69989 + */ +//----------------------------------------------------------------------------- +var gTestfile = 'regress-67773.js'; +var i = 0; +var BUGNUMBER = 67773; +var summary = 'Testing regular subexpressions followed by ? or +\n'; +var cnSingleSpace = ' '; +var status = ''; +var statusmessages = new Array(); +var pattern = ''; +var patterns = new Array(); +var string = ''; +var strings = new Array(); +var actualmatch = ''; +var actualmatches = new Array(); +var expectedmatch = ''; +var expectedmatches = new Array(); + + +pattern = /^(\S+)?( ?)(B+)$/; //single space before second ? character +status = inSection(1); +string = 'AAABBB AAABBB '; //single space at middle and at end - +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(2); +string = 'AAABBB BBB'; //single space in the middle +actualmatch = string.match(pattern); +expectedmatch = Array(string, 'AAABBB', cnSingleSpace, 'BBB'); +addThis(); + +status = inSection(3); +string = 'AAABBB AAABBB'; //single space in the middle +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + + +pattern = /^(A+B)+$/; +status = inSection(4); +string = 'AABAAB'; +actualmatch = string.match(pattern); +expectedmatch = Array(string, 'AAB'); +addThis(); + +status = inSection(5); +string = 'ABAABAAAAAAB'; +actualmatch = string.match(pattern); +expectedmatch = Array(string, 'AAAAAAB'); +addThis(); + +status = inSection(6); +string = 'ABAABAABAB'; +actualmatch = string.match(pattern); +expectedmatch = Array(string, 'AB'); +addThis(); + +status = inSection(7); +string = 'ABAABAABABB'; +actualmatch = string.match(pattern); +expectedmatch = null; // because string doesn't match at end +addThis(); + + +pattern = /^(A+1)+$/; +status = inSection(8); +string = 'AA1AA1'; +actualmatch = string.match(pattern); +expectedmatch = Array(string, 'AA1'); +addThis(); + + +pattern = /^(\w+\-)+$/; +status = inSection(9); +string = ''; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(10); +string = 'bla-'; +actualmatch = string.match(pattern); +expectedmatch = Array(string, string); +addThis(); + +status = inSection(11); +string = 'bla-bla'; // hyphen missing at end - +actualmatch = string.match(pattern); +expectedmatch = null; //because string doesn't match at end +addThis(); + +status = inSection(12); +string = 'bla-bla-'; +actualmatch = string.match(pattern); +expectedmatch = Array(string, 'bla-'); +addThis(); + + +pattern = /^(\S+)+(A+)$/; +status = inSection(13); +string = 'asdldflkjAAA'; +actualmatch = string.match(pattern); +expectedmatch = Array(string, 'asdldflkjAA', 'A'); +addThis(); + +status = inSection(14); +string = 'asdldflkj AAA'; // space in middle +actualmatch = string.match(pattern); +expectedmatch = null; //because of the space +addThis(); + + +pattern = /^(\S+)+(\d+)$/; +status = inSection(15); +string = 'asdldflkj122211'; +actualmatch = string.match(pattern); +expectedmatch = Array(string, 'asdldflkj12221', '1'); +addThis(); + +status = inSection(16); +string = 'asdldflkj1111111aaa1'; +actualmatch = string.match(pattern); +expectedmatch = Array(string, 'asdldflkj1111111aaa', '1'); +addThis(); + + +/* + * This one comes from Stephen Ostermiller. + * See http://bugzilla.mozilla.org/show_bug.cgi?id=69989 + */ +pattern = /^[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)+$/; +status = inSection(17); +string = 'some.host.tld'; +actualmatch = string.match(pattern); +expectedmatch = Array(string, '.tld', '.'); +addThis(); + + + +//------------------------------------------------------------------------------------------------- +test(); +//------------------------------------------------------------------------------------------------- + + + +function addThis() +{ + statusmessages[i] = status; + patterns[i] = pattern; + strings[i] = string; + actualmatches[i] = actualmatch; + expectedmatches[i] = expectedmatch; + i++; +} + + +function test() +{ + enterFunc ('test'); + printBugNumber(BUGNUMBER); + printStatus (summary); + testRegExp(statusmessages, patterns, strings, actualmatches, expectedmatches); + exitFunc ('test'); +} diff --git a/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-72964.js b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-72964.js new file mode 100644 index 0000000000..67a41e505c --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-72964.js @@ -0,0 +1,121 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is mozilla.org code. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * pschwartau@netscape.com + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +/* + * Date: 2001-07-17 + * + * SUMMARY: Regression test for Bugzilla bug 72964: + * "String method for pattern matching failed for Chinese Simplified (GB2312)" + * + * See http://bugzilla.mozilla.org/show_bug.cgi?id=72964 + */ +//----------------------------------------------------------------------------- +var gTestfile = 'regress-72964.js'; +var i = 0; +var BUGNUMBER = 72964; +var summary = 'Testing regular expressions containing non-Latin1 characters'; +var cnSingleSpace = ' '; +var status = ''; +var statusmessages = new Array(); +var pattern = ''; +var patterns = new Array(); +var string = ''; +var strings = new Array(); +var actualmatch = ''; +var actualmatches = new Array(); +var expectedmatch = ''; +var expectedmatches = new Array(); + + +pattern = /[\S]+/; +// 4 low Unicode chars = Latin1; whole string should match +status = inSection(1); +string = '\u00BF\u00CD\u00BB\u00A7'; +actualmatch = string.match(pattern); +expectedmatch = Array(string); +addThis(); + +// Now put a space in the middle; first half of string should match +status = inSection(2); +string = '\u00BF\u00CD \u00BB\u00A7'; +actualmatch = string.match(pattern); +expectedmatch = Array('\u00BF\u00CD'); +addThis(); + + +// 4 high Unicode chars = non-Latin1; whole string should match +status = inSection(3); +string = '\u4e00\uac00\u4e03\u4e00'; +actualmatch = string.match(pattern); +expectedmatch = Array(string); +addThis(); + +// Now put a space in the middle; first half of string should match +status = inSection(4); +string = '\u4e00\uac00 \u4e03\u4e00'; +actualmatch = string.match(pattern); +expectedmatch = Array('\u4e00\uac00'); +addThis(); + + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + + + +function addThis() +{ + statusmessages[i] = status; + patterns[i] = pattern; + strings[i] = string; + actualmatches[i] = actualmatch; + expectedmatches[i] = expectedmatch; + i++; +} + + +function test() +{ + enterFunc ('test'); + printBugNumber(BUGNUMBER); + printStatus (summary); + testRegExp(statusmessages, patterns, strings, actualmatches, expectedmatches); + exitFunc ('test'); +} diff --git a/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-76683.js b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-76683.js new file mode 100644 index 0000000000..8792e379ca --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-76683.js @@ -0,0 +1,114 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is mozilla.org code. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * pschwartau@netscape.com + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +/* + * Date: 01 May 2001 + * + * SUMMARY: Regression test for Bugzilla bug 76683 on Rhino: + * "RegExp regression (NullPointerException)" + * + * See http://bugzilla.mozilla.org/show_bug.cgi?id=76683 + */ +//----------------------------------------------------------------------------- +var gTestfile = 'regress-76683.js'; +var i = 0; +var BUGNUMBER = 76683; +var summary = 'Regression test for Bugzilla bug 76683'; +var status = ''; +var statusmessages = new Array(); +var pattern = ''; +var patterns = new Array(); +var string = ''; +var strings = new Array(); +var actualmatch = ''; +var actualmatches = new Array(); +var expectedmatch = ''; +var expectedmatches = new Array(); + + +/* + * Rhino (2001-04-19) crashed on the 3rd regular expression below. + * It didn't matter what the string was. No problem in SpiderMonkey - + */ +string = 'abc'; +status = inSection(1); +pattern = /()|(<([\$\w:\.\-]+)((([ ][^\/>]*)?\/>)|(([ ][^>]*)?>)))/; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(2); +pattern = /()|(<(tagPattern)((([ ][^\/>]*)?\/>)|(([ ][^>]*)?>)))/; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +// This was the one causing a Rhino crash - +status = inSection(3); +pattern = /()|(<(tagPattern)((([ ][^\/>]*)?\/>)|(([ ][^>]*)?>)))|(<\/tagPattern[^>]*>)/; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + + + +//------------------------------------------------------------------------------------------------- +test(); +//------------------------------------------------------------------------------------------------- + + + +function addThis() +{ + statusmessages[i] = status; + patterns[i] = pattern; + strings[i] = string; + actualmatches[i] = actualmatch; + expectedmatches[i] = expectedmatch; + i++; +} + + +function test() +{ + enterFunc ('test'); + printBugNumber(BUGNUMBER); + printStatus (summary); + testRegExp(statusmessages, patterns, strings, actualmatches, expectedmatches); + exitFunc ('test'); +} diff --git a/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-78156.js b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-78156.js new file mode 100644 index 0000000000..dd42ce060b --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-78156.js @@ -0,0 +1,123 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is mozilla.org code. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * pschwartau@netscape.com + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +/* + * Date: 06 February 2001 + * + * SUMMARY: Arose from Bugzilla bug 78156: + * "m flag of regular expression does not work with $" + * + * See http://bugzilla.mozilla.org/show_bug.cgi?id=78156 + * + * The m flag means a regular expression should search strings + * across multiple lines, i.e. across '\n', '\r'. + */ +//----------------------------------------------------------------------------- +var gTestfile = 'regress-78156.js'; +var i = 0; +var BUGNUMBER = 78156; +var summary = 'Testing regular expressions with ^, $, and the m flag -'; +var status = ''; +var statusmessages = new Array(); +var pattern = ''; +var patterns = new Array(); +var string = ''; +var strings = new Array(); +var actualmatch = ''; +var actualmatches = new Array(); +var expectedmatch = ''; +var expectedmatches = new Array(); + +/* + * All patterns have an m flag; all strings are multiline. + * Looking for digit characters at beginning/end of lines. + */ + +string = 'aaa\n789\r\nccc\r\n345'; +status = inSection(1); +pattern = /^\d/gm; +actualmatch = string.match(pattern); +expectedmatch = ['7','3']; +addThis(); + +status = inSection(2); +pattern = /\d$/gm; +actualmatch = string.match(pattern); +expectedmatch = ['9','5']; +addThis(); + +string = 'aaa\n789\r\nccc\r\nddd'; +status = inSection(3); +pattern = /^\d/gm; +actualmatch = string.match(pattern); +expectedmatch = ['7']; +addThis(); + +status = inSection(4); +pattern = /\d$/gm; +actualmatch = string.match(pattern); +expectedmatch = ['9']; +addThis(); + + + +//------------------------------------------------------------------------------------------------- +test(); +//------------------------------------------------------------------------------------------------- + + + +function addThis() +{ + statusmessages[i] = status; + patterns[i] = pattern; + strings[i] = string; + actualmatches[i] = actualmatch; + expectedmatches[i] = expectedmatch; + i++; +} + + +function test() +{ + enterFunc ('test'); + printBugNumber(BUGNUMBER); + printStatus (summary); + testRegExp(statusmessages, patterns, strings, actualmatches, expectedmatches); + exitFunc ('test'); +} diff --git a/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-85721.js b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-85721.js new file mode 100644 index 0000000000..bca1a15e19 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-85721.js @@ -0,0 +1,276 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is JavaScript Engine testing utilities. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corp. + * Portions created by the Initial Developer are Copyright (C) 2002 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * rogerl@netscape.com, pschwartau@netscape.com + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +/* + * + * Date: 14 Feb 2002 + * SUMMARY: Performance: Regexp performance degraded from 4.7 + * See http://bugzilla.mozilla.org/show_bug.cgi?id=85721 + * + * Adjust this testcase if necessary. The FAST constant defines + * an upper bound in milliseconds for any execution to take. + * + */ +//----------------------------------------------------------------------------- +var gTestfile = 'regress-85721.js'; +var BUGNUMBER = 85721; +var summary = 'Performance: execution of regular expression'; +var FAST = 100; // execution should be 100 ms or less to pass the test +var MSG_FAST = 'Execution took less than ' + FAST + ' ms'; +var MSG_SLOW = 'Execution took '; +var MSG_MS = ' ms'; +var str = ''; +var re = ''; +var status = ''; +var actual = ''; +var expect= ''; + +printBugNumber(BUGNUMBER); +printStatus (summary); + + +function elapsedTime(startTime) +{ + return new Date() - startTime; +} + + +function isThisFast(ms) +{ + if (ms <= FAST) + return MSG_FAST; + return MSG_SLOW + ms + MSG_MS; +} + + + +/* + * The first regexp. We'll test for performance (Section 1) and accuracy (Section 2). + */ +str=' www.m.com drive.class\nfoo goo '; +re = /\s*\s*([^\r\n]*?)\s*<\/sql:url>\s*\s*([^\r\n]*?)\s*<\/sql:driver>\s*(\s*\s*([^\r\n]*?)\s*<\/sql:userId>\s*)?\s*(\s*\s*([^\r\n]*?)\s*<\/sql:password>\s*)?\s*<\/sql:connection>/; +expect = Array(" www.m.com drive.class\nfoo goo ","conn1","www.m.com","drive.class","foo ","foo","goo ","goo"); + +/* + * Check performance - + */ +status = inSection(1); +var start = new Date(); +var result = re.exec(str); +actual = elapsedTime(start); +reportCompare(isThisFast(FAST), isThisFast(actual), status); + +/* + * Check accuracy - + */ +status = inSection(2); +testRegExp([status], [re], [str], [result], [expect]); + + + +/* + * The second regexp (HUGE!). We'll test for performance (Section 3) and accuracy (Section 4). + * It comes from the O'Reilly book "Mastering Regular Expressions" by Jeffrey Friedl, Appendix B + */ + +//# Some things for avoiding backslashitis later on. +$esc = '\\\\'; +$Period = '\.'; +$space = '\040'; $tab = '\t'; +$OpenBR = '\\['; $CloseBR = '\\]'; +$OpenParen = '\\('; $CloseParen = '\\)'; +$NonASCII = '\x80-\xff'; $ctrl = '\000-\037'; +$CRlist = '\n\015'; //# note: this should really be only \015. +// Items 19, 20, 21 +$qtext = '[^' + $esc + $NonASCII + $CRlist + '\"]'; // # for within "..." +$dtext = '[^' + $esc + $NonASCII + $CRlist + $OpenBR + $CloseBR + ']'; // # for within [...] +$quoted_pair = $esc + '[^' + $NonASCII + ']'; // # an escaped character + +//############################################################################## +//# Items 22 and 23, comment. +//# Impossible to do properly with a regex, I make do by allowing at most one level of nesting. +$ctext = '[^' + $esc + $NonASCII + $CRlist + '()]'; + +//# $Cnested matches one non-nested comment. +//# It is unrolled, with normal of $ctext, special of $quoted_pair. +$Cnested = + $OpenParen + // # ( + $ctext + '*' + // # normal* + '(?:' + $quoted_pair + $ctext + '*)*' + // # (special normal*)* + $CloseParen; // # ) + + +//# $comment allows one level of nested parentheses +//# It is unrolled, with normal of $ctext, special of ($quoted_pair|$Cnested) +$comment = + $OpenParen + // # ( + $ctext + '*' + // # normal* + '(?:' + // # ( + '(?:' + $quoted_pair + '|' + $Cnested + ')' + // # special + $ctext + '*' + // # normal* + ')*' + // # )* + $CloseParen; // # ) + + +//############################################################################## +//# $X is optional whitespace/comments. +$X = + '[' + $space + $tab + ']*' + // # Nab whitespace. + '(?:' + $comment + '[' + $space + $tab + ']*)*'; // # If comment found, allow more spaces. + + +//# Item 10: atom +$atom_char = '[^(' + $space + '<>\@,;:\".' + $esc + $OpenBR + $CloseBR + $ctrl + $NonASCII + ']'; +$atom = + $atom_char + '+' + // # some number of atom characters... + '(?!' + $atom_char + ')'; // # ..not followed by something that could be part of an atom + +// # Item 11: doublequoted string, unrolled. +$quoted_str = + '\"' + // # " + $qtext + '*' + // # normal + '(?:' + $quoted_pair + $qtext + '*)*' + // # ( special normal* )* + '\"'; // # " + +//# Item 7: word is an atom or quoted string +$word = + '(?:' + + $atom + // # Atom + '|' + // # or + $quoted_str + // # Quoted string + ')' + +//# Item 12: domain-ref is just an atom + $domain_ref = $atom; + +//# Item 13: domain-literal is like a quoted string, but [...] instead of "..." +$domain_lit = + $OpenBR + // # [ + '(?:' + $dtext + '|' + $quoted_pair + ')*' + // # stuff + $CloseBR; // # ] + +// # Item 9: sub-domain is a domain-ref or domain-literal +$sub_domain = + '(?:' + + $domain_ref + + '|' + + $domain_lit + + ')' + + $X; // # optional trailing comments + +// # Item 6: domain is a list of subdomains separated by dots. +$domain = + $sub_domain + + '(?:' + + $Period + $X + $sub_domain + + ')*'; + +//# Item 8: a route. A bunch of "@ $domain" separated by commas, followed by a colon. +$route = + '\@' + $X + $domain + + '(?:,' + $X + '\@' + $X + $domain + ')*' + // # additional domains + ':' + + $X; // # optional trailing comments + +//# Item 6: local-part is a bunch of $word separated by periods +$local_part = + $word + $X + '(?:' + + $Period + $X + $word + $X + // # additional words + ')*'; + +// # Item 2: addr-spec is local@domain +$addr_spec = + $local_part + '\@' + $X + $domain; + +//# Item 4: route-addr is +$route_addr = + '<' + $X + // # < + '(?:' + $route + ')?' + // # optional route + $addr_spec + // # address spec + '>'; // # > + +//# Item 3: phrase........ +$phrase_ctrl = '\000-\010\012-\037'; // # like ctrl, but without tab + +//# Like atom-char, but without listing space, and uses phrase_ctrl. +//# Since the class is negated, this matches the same as atom-char plus space and tab +$phrase_char = + '[^()<>\@,;:\".' + $esc + $OpenBR + $CloseBR + $NonASCII + $phrase_ctrl + ']'; + +// # We've worked it so that $word, $comment, and $quoted_str to not consume trailing $X +// # because we take care of it manually. +$phrase = + $word + // # leading word + $phrase_char + '*' + // # "normal" atoms and/or spaces + '(?:' + + '(?:' + $comment + '|' + $quoted_str + ')' + // # "special" comment or quoted string + $phrase_char + '*' + // # more "normal" + ')*'; + +// ## Item #1: mailbox is an addr_spec or a phrase/route_addr +$mailbox = + $X + // # optional leading comment + '(?:' + + $phrase + $route_addr + // # name and address + '|' + // # or + $addr_spec + // # address + ')'; + + +//########################################################################### + + +re = new RegExp($mailbox, "g"); +str = 'Jeffy<"That Tall Guy"@ora.com (this address is no longer active)>'; +expect = Array('Jeffy<"That Tall Guy"@ora.com (this address is no longer active)>'); + +/* + * Check performance - + */ +status = inSection(3); +var start = new Date(); +var result = re.exec(str); +actual = elapsedTime(start); +reportCompare(isThisFast(FAST), isThisFast(actual), status); + +/* + * Check accuracy - + */ +status = inSection(4); +testRegExp([status], [re], [str], [result], [expect]); diff --git a/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-87231.js b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-87231.js new file mode 100644 index 0000000000..b5467322eb --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-87231.js @@ -0,0 +1,145 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is mozilla.org code. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * pschwartau@netscape.com + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +/* + * Date: 22 June 2001 + * + * SUMMARY: Regression test for Bugzilla bug 87231: + * "Regular expression /(A)?(A.*)/ picks 'A' twice" + * + * See http://bugzilla.mozilla.org/show_bug.cgi?id=87231 + * Key case: + * + * pattern = /^(A)?(A.*)$/; + * string = 'A'; + * expectedmatch = Array('A', '', 'A'); + * + * + * We expect the 1st subexpression (A)? NOT to consume the single 'A'. + * Recall that "?" means "match 0 or 1 times". Here, it should NOT do + * greedy matching: it should match 0 times instead of 1. This allows + * the 2nd subexpression to make the only match it can: the single 'A'. + * Such "altruism" is the only way there can be a successful global match... + */ +//----------------------------------------------------------------------------- +var gTestfile = 'regress-87231.js'; +var i = 0; +var BUGNUMBER = 87231; +var cnEmptyString = ''; +var summary = 'Testing regular expression /(A)?(A.*)/'; +var status = ''; +var statusmessages = new Array(); +var pattern = ''; +var patterns = new Array(); +var string = ''; +var strings = new Array(); +var actualmatch = ''; +var actualmatches = new Array(); +var expectedmatch = ''; +var expectedmatches = new Array(); + + +pattern = /^(A)?(A.*)$/; +status = inSection(1); +string = 'AAA'; +actualmatch = string.match(pattern); +expectedmatch = Array('AAA', 'A', 'AA'); +addThis(); + +status = inSection(2); +string = 'AA'; +actualmatch = string.match(pattern); +expectedmatch = Array('AA', 'A', 'A'); +addThis(); + +status = inSection(3); +string = 'A'; +actualmatch = string.match(pattern); +expectedmatch = Array('A', undefined, 'A'); // 'altruistic' case: see above +addThis(); + + +pattern = /(A)?(A.*)/; +var strL = 'zxcasd;fl\\\ ^'; +var strR = 'aaAAaaaf;lrlrzs'; + +status = inSection(4); +string = strL + 'AAA' + strR; +actualmatch = string.match(pattern); +expectedmatch = Array('AAA' + strR, 'A', 'AA' + strR); +addThis(); + +status = inSection(5); +string = strL + 'AA' + strR; +actualmatch = string.match(pattern); +expectedmatch = Array('AA' + strR, 'A', 'A' + strR); +addThis(); + +status = inSection(6); +string = strL + 'A' + strR; +actualmatch = string.match(pattern); +expectedmatch = Array('A' + strR, undefined, 'A' + strR); // 'altruistic' case: see above +addThis(); + + + +//------------------------------------------------------------------------------------------------- +test(); +//------------------------------------------------------------------------------------------------- + + + +function addThis() +{ + statusmessages[i] = status; + patterns[i] = pattern; + strings[i] = string; + actualmatches[i] = actualmatch; + expectedmatches[i] = expectedmatch; + i++; +} + + +function test() +{ + enterFunc ('test'); + printBugNumber(BUGNUMBER); + printStatus (summary); + testRegExp(statusmessages, patterns, strings, actualmatches, expectedmatches); + exitFunc ('test'); +} diff --git a/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-98306.js b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-98306.js new file mode 100644 index 0000000000..a2bfc2bf93 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-98306.js @@ -0,0 +1,99 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is mozilla.org code. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * jrgm@netscape.com, pschwartau@netscape.com + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +/* + * Date: 04 September 2001 + * + * SUMMARY: Regression test for Bugzilla bug 98306 + * "JS parser crashes in ParseAtom for script using Regexp()" + * + * See http://bugzilla.mozilla.org/show_bug.cgi?id=98306 + */ +//----------------------------------------------------------------------------- +var gTestfile = 'regress-98306.js'; +var BUGNUMBER = 98306; +var summary = "Testing that we don't crash on this code -"; +var cnUBOUND = 10; +var re; +var s; + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + + +function test() +{ + enterFunc ('test'); + printBugNumber(BUGNUMBER); + printStatus (summary); + + s = '"Hello".match(/[/]/)'; + tryThis(s); + + s = 're = /[/'; + tryThis(s); + + s = 're = /[/]/'; + tryThis(s); + + s = 're = /[//]/'; + tryThis(s); + + reportCompare('No Crash', 'No Crash', ''); + exitFunc ('test'); +} + + +// Try to provoke a crash - +function tryThis(sCode) +{ + // sometimes more than one attempt is necessary - + for (var i=0; i 5) + throw "bad"; + i++; + continue; + } + } + catch(ex) + { + actual = ex + ''; + } + reportCompare(expect, actual, summary); + + exitFunc ('test'); +} diff --git a/tests/auto/qml/parserstress/tests/ecma_3/Regress/shell.js b/tests/auto/qml/parserstress/tests/ecma_3/Regress/shell.js new file mode 100644 index 0000000000..8c83369020 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma_3/Regress/shell.js @@ -0,0 +1 @@ +gTestsubsuite = 'Regress'; diff --git a/tests/auto/qml/parserstress/tests/ecma_3/Statements/12.6.3.js b/tests/auto/qml/parserstress/tests/ecma_3/Statements/12.6.3.js new file mode 100755 index 0000000000..97c3ca3136 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma_3/Statements/12.6.3.js @@ -0,0 +1,80 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is JavaScript Engine testing utilities. + * + * The Initial Developer of the Original Code is + * Mozilla Foundation. + * Portions created by the Initial Developer are Copyright (C) 2005 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): Bryant Chen + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +var gTestfile = '12.6.3.js'; +//----------------------------------------------------------------------------- +var BUGNUMBER = 292731; +var summary = 'for-in should not call valueOf method'; +var actual = ''; +var expect = ''; +var i; + +printBugNumber(BUGNUMBER); +printStatus (summary); + +function MyObject() +{ +} + +MyObject.prototype.valueOf = function() +{ + actual += 'MyObject.prototype.valueOf called. '; +} + + var myobject = new MyObject(); + +var myfunction = new function() +{ + this.valueOf = function() + { + actual += 'this.valueOf called. '; + } +} + + actual = ''; +for (i in myobject) +{ + //calls valueOf +} +reportCompare(expect, actual, 'for-in custom object'); + +actual = ''; +for (i in myfunction) +{ + //calls valueOf +} +reportCompare(expect, actual, 'for-in function expression'); diff --git a/tests/auto/qml/parserstress/tests/ecma_3/Statements/browser.js b/tests/auto/qml/parserstress/tests/ecma_3/Statements/browser.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/auto/qml/parserstress/tests/ecma_3/Statements/regress-121744.js b/tests/auto/qml/parserstress/tests/ecma_3/Statements/regress-121744.js new file mode 100644 index 0000000000..828cc5d8d5 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma_3/Statements/regress-121744.js @@ -0,0 +1,217 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is JavaScript Engine testing utilities. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corp. + * Portions created by the Initial Developer are Copyright (C) 2002 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * pschwartau@netscape.com + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +/* + * + * Date: 30 Jan 2002 + * Revised: 10 Apr 2002 + * Revised: 14 July 2002 + * + * SUMMARY: JS should error on |for(i in undefined)|, |for(i in null)| + * See http://bugzilla.mozilla.org/show_bug.cgi?id=121744 + * + * ECMA-262 3rd Edition Final spec says such statements should error. See: + * + * Section 12.6.4 The for-in Statement + * Section 9.9 ToObject + * + * + * BUT: SpiderMonkey has decided NOT to follow this; it's a bug in the spec. + * See http://bugzilla.mozilla.org/show_bug.cgi?id=131348 + * + * UPDATE: Rhino has also decided not to follow the spec on this. + * See http://bugzilla.mozilla.org/show_bug.cgi?id=136893 + * + + |--------------------------------------------------------------------| + | | + | So for now, adding an early return for this test so it won't run. | + | | + |--------------------------------------------------------------------| + + * + */ +//----------------------------------------------------------------------------- +var gTestfile = 'regress-121744.js'; +var UBound = 0; +var BUGNUMBER = 121744; +var summary = 'JS should error on |for(i in undefined)|, |for(i in null)|'; +var TEST_PASSED = 'TypeError'; +var TEST_FAILED = 'Generated an error, but NOT a TypeError!'; +var TEST_FAILED_BADLY = 'Did not generate ANY error!!!'; +var status = ''; +var statusitems = []; +var actual = ''; +var actualvalues = []; +var expect= ''; +var expectedvalues = []; + +/* + * AS OF 14 JULY 2002, DON'T RUN THIS TEST IN EITHER RHINO OR SPIDERMONKEY - + */ +quit(); + + +status = inSection(1); +expect = TEST_PASSED; +actual = TEST_FAILED_BADLY; +/* + * OK, this should generate a TypeError + */ +try +{ + for (var i in undefined) + { + print(i); + } +} +catch(e) +{ + if (e instanceof TypeError) + actual = TEST_PASSED; + else + actual = TEST_FAILED; +} +addThis(); + + + +status = inSection(2); +expect = TEST_PASSED; +actual = TEST_FAILED_BADLY; +/* + * OK, this should generate a TypeError + */ +try +{ + for (var i in null) + { + print(i); + } +} +catch(e) +{ + if (e instanceof TypeError) + actual = TEST_PASSED; + else + actual = TEST_FAILED; +} +addThis(); + + + +status = inSection(3); +expect = TEST_PASSED; +actual = TEST_FAILED_BADLY; +/* + * Variable names that cannot be looked up generate ReferenceErrors; however, + * property names like obj.ZZZ that cannot be looked up are set to |undefined| + * + * Therefore, this should indirectly test | for (var i in undefined) | + */ +try +{ + for (var i in this.ZZZ) + { + print(i); + } +} +catch(e) +{ + if(e instanceof TypeError) + actual = TEST_PASSED; + else + actual = TEST_FAILED; +} +addThis(); + + + +status = inSection(4); +expect = TEST_PASSED; +actual = TEST_FAILED_BADLY; +/* + * The result of an unsuccessful regexp match is the null value + * Therefore, this should indirectly test | for (var i in null) | + */ +try +{ + for (var i in 'bbb'.match(/aaa/)) + { + print(i); + } +} +catch(e) +{ + if(e instanceof TypeError) + actual = TEST_PASSED; + else + actual = TEST_FAILED; +} +addThis(); + + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + + + +function addThis() +{ + statusitems[UBound] = status; + actualvalues[UBound] = actual; + expectedvalues[UBound] = expect; + UBound++; +} + + +function test() +{ + enterFunc('test'); + printBugNumber(BUGNUMBER); + printStatus(summary); + + for (var i=0; i + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +var gTestfile = '15.5.4.11.js'; +var BUGNUMBER = 392378; +var summary = '15.5.4.11 - String.prototype.replace'; +var rex, f, a, i; + +reportCompare( + 2, + String.prototype.replace.length, + "Section 1" +); + +reportCompare( + "321", + String.prototype.replace.call(123, "123", "321"), + "Section 2" +); + +reportCompare( + "ok", + "ok".replace(), + "Section 3" +); + +reportCompare( + "undefined**", + "***".replace("*"), + "Section 4" +); + +reportCompare( + "xnullz", + "xyz".replace("y", null), + "Section 5" +); + +reportCompare( + "x123", + "xyz".replace("yz", 123), + "Section 6" +); + +reportCompare( + "/x/g/x/g/x/g", + "xxx".replace(/x/g, /x/g), + "Section 7" +); + +reportCompare( + "ok", + "undefined".replace(undefined, "ok"), + "Section 8" +); + +reportCompare( + "ok", + "null".replace(null, "ok"), + "Section 9" +); + +reportCompare( + "ok", + "123".replace(123, "ok"), + "Section 10" +); + +reportCompare( + "xzyxyz", + "xyzxyz".replace("yz", "zy"), + "Section 11" +); + +reportCompare( + "ok", + "(xyz)".replace("(xyz)", "ok"), + "Section 12" +); + +reportCompare( + "*$&yzxyz", + "xyzxyz".replace("x", "*$$&"), + "Section 13" +); + +reportCompare( + "xy*z*", + "xyz".replace("z", "*$&*"), + "Section 14" +); + +reportCompare( + "xyxyzxyz", + "xyzxyzxyz".replace("zxy", "$`"), + "Section 15" +); + +reportCompare( + "zxyzxyzzxyz", + "xyzxyz".replace("xy", "$'xyz"), + "Section 16" +); + +reportCompare( + "$", + "xyzxyz".replace("xyzxyz", "$"), + "Section 17" +); + +reportCompare( + "x$0$00xyz", + "xyzxyz".replace("yz", "$0$00"), + "Section 18" +); + +// Result for $1/$01 .. $99 is implementation-defined if searchValue is no +// regular expression. $+ is a non-standard Mozilla extension. + +reportCompare( + "$!$\"$-1$*$#$.$xyz$$", + "xyzxyz$$".replace("xyz", "$!$\"$-1$*$#$.$"), + "Section 19" +); + +reportCompare( + "$$$&$$$&$&", + "$$$&".replace("$$", "$$$$$$&$&$$&"), + "Section 20" +); + +reportCompare( + "yxx", + "xxx".replace(/x/, "y"), + "Section 21" +); + +reportCompare( + "yyy", + "xxx".replace(/x/g, "y"), + "Section 22" +); + +rex = /x/, rex.lastIndex = 1; +reportCompare( + "yxx1", + "xxx".replace(rex, "y") + rex.lastIndex, + "Section 23" +); + +rex = /x/g, rex.lastIndex = 1; +reportCompare( + "yyy0", + "xxx".replace(rex, "y") + rex.lastIndex, + "Section 24" +); + +rex = /y/, rex.lastIndex = 1; +reportCompare( + "xxx1", + "xxx".replace(rex, "y") + rex.lastIndex, + "Section 25" +); + +rex = /y/g, rex.lastIndex = 1; +reportCompare( + "xxx0", + "xxx".replace(rex, "y") + rex.lastIndex, + "Section 26" +); + +rex = /x?/, rex.lastIndex = 1; +reportCompare( + "(x)xx1", + "xxx".replace(rex, "($&)") + rex.lastIndex, + "Section 27" +); + +rex = /x?/g, rex.lastIndex = 1; +reportCompare( + "(x)(x)(x)()0", + "xxx".replace(rex, "($&)") + rex.lastIndex, + "Section 28" +); + +rex = /y?/, rex.lastIndex = 1; +reportCompare( + "()xxx1", + "xxx".replace(rex, "($&)") + rex.lastIndex, + "Section 29" +); + +rex = /y?/g, rex.lastIndex = 1; +reportCompare( + "()x()x()x()0", + "xxx".replace(rex, "($&)") + rex.lastIndex, + "Section 30" +); + +reportCompare( + "xy$0xy$zxy$zxyz$zxyz", + "xyzxyzxyz".replace(/zxy/, "$0$`$$$&$$$'$"), + "Section 31" +); + +reportCompare( + "xy$0xy$zxy$zxyz$$0xyzxy$zxy$z$z", + "xyzxyzxyz".replace(/zxy/g, "$0$`$$$&$$$'$"), + "Section 32" +); + +reportCompare( + "xyxyxyzxyxyxyz", + "xyzxyz".replace(/(((x)(y)()()))()()()(z)/g, "$01$2$3$04$5$6$7$8$09$10"), + "Section 33" +); + +rex = RegExp( + "()()()()()()()()()()" + + "()()()()()()()()()()" + + "()()()()()()()()()()" + + "()()()()()()()()()()" + + "()()()()()()()()()()" + + "()()()()()()()()()()" + + "()()()()()()()()()()" + + "()()()()()()()()()()" + + "()()()()()()()()()()" + + "()()()()()()()()(y)"); +reportCompare( + "x(y)z", + "xyz".replace(rex, "($99)"), + "Section 34" +); + +rex = RegExp( + "()()()()()()()()()(x)" + + "()()()()()()()()()()" + + "()()()()()()()()()()" + + "()()()()()()()()()()" + + "()()()()()()()()()()" + + "()()()()()()()()()()" + + "()()()()()()()()()()" + + "()()()()()()()()()()" + + "()()()()()()()()()()" + + "()()()()()()()()()(y)"); +reportCompare( + "(x0)z", + "xyz".replace(rex, "($100)"), + "Section 35" +); + +reportCompare( + "xyz(XYZ)", + "xyzXYZ".replace(/XYZ/g, "($&)"), + "Section 36" +); + +reportCompare( + "(xyz)(XYZ)", + "xyzXYZ".replace(/xYz/gi, "($&)"), + "Section 37" +); + +reportCompare( + "xyz\rxyz\n", + "xyz\rxyz\n".replace(/xyz$/g, "($&)"), + "Section 38" +); + +reportCompare( + "(xyz)\r(xyz)\n", + "xyz\rxyz\n".replace(/xyz$/gm, "($&)"), + "Section 39" +); + +f = function () { return "failure" }; + +reportCompare( + "ok", + "ok".replace("x", f), + "Section 40" +); + +reportCompare( + "ok", + "ok".replace(/(?=k)ok/, f), + "Section 41" +); + +reportCompare( + "ok", + "ok".replace(/(?!)ok/, f), + "Section 42" +); + +reportCompare( + "ok", + "ok".replace(/ok(?!$)/, f), + "Section 43" +); + +f = function (sub, offs, str) { + return ["", sub, typeof sub, offs, typeof offs, str, typeof str, ""] + .join("|"); +}; + +reportCompare( + "x|y|string|1|number|xyz|string|z", + "xyz".replace("y", f), + "Section 44" +); + +reportCompare( + "x|(y)|string|1|number|x(y)z|string|z", + "x(y)z".replace("(y)", f), + "Section 45" +); + +reportCompare( + "x|y*|string|1|number|xy*z|string|z", + "xy*z".replace("y*", f), + "Section 46" +); + +reportCompare( + "12|3|string|2|number|12345|string|45", + String.prototype.replace.call(1.2345e4, 3, f), + "Section 47" +); + +reportCompare( + "|x|string|0|number|xxx|string|xx", + "xxx".replace(/^x/g, f), + "Section 48" +); + +reportCompare( + "xx|x|string|2|number|xxx|string|", + "xxx".replace(/x$/g, f), + "Section 49" +); + +f = function (sub, paren, offs, str) { + return ["", sub, typeof sub, paren, typeof paren, offs, typeof offs, + str, typeof str, ""].join("|"); +}; + +reportCompare( + "xy|z|string|z|string|2|number|xyz|string|", + "xyz".replace(/(z)/g, f), + "Section 50" +); + +reportCompare( + "xyz||string||string|3|number|xyz|string|", + "xyz".replace(/($)/g, f), + "Section 51" +); + +reportCompare( + "|xy|string|y|string|0|number|xyz|string|z", + "xyz".replace(/(?:x)(y)/g, f), + "Section 52" +); + +reportCompare( + "|x|string|x|string|0|number|xyz|string|yz", + "xyz".replace(/((?=xy)x)/g, f), + "Section 53" +); + +reportCompare( + "|x|string|x|string|0|number|xyz|string|yz", + "xyz".replace(/(x(?=y))/g, f), + "Section 54" +); + +reportCompare( + "x|y|string|y|string|1|number|xyz|string|z", + "xyz".replace(/((?!x)y)/g, f), + "Section 55" +); + +reportCompare( + "|x|string|x|string|0|number|xyz|string|" + + "|y|string||undefined|1|number|xyz|string|z", + "xyz".replace(/y|(x)/g, f), + "Section 56" +); + +reportCompare( + "xy|z|string||string|2|number|xyz|string|", + "xyz".replace(/(z?)z/, f), + "Section 57" +); + +reportCompare( + "xy|z|string||undefined|2|number|xyz|string|", + "xyz".replace(/(z)?z/, f), + "Section 58" +); + +reportCompare( + "xy|z|string||undefined|2|number|xyz|string|", + "xyz".replace(/(z)?\1z/, f), + "Section 59" +); + +reportCompare( + "xy|z|string||undefined|2|number|xyz|string|", + "xyz".replace(/\1(z)?z/, f), + "Section 60" +); + +reportCompare( + "xy|z|string||string|2|number|xyz|string|", + "xyz".replace(/(z?\1)z/, f), + "Section 61" +); + +f = function (sub, paren1, paren2, offs, str) { + return ["", sub, typeof sub, paren1, typeof paren1, paren2, typeof paren2, + offs, typeof offs, str, typeof str, ""].join("|"); +}; + +reportCompare( + "x|y|string|y|string||undefined|1|number|xyz|string|z", + "xyz".replace(/(y)(\1)?/, f), + "Section 62" +); + +reportCompare( + "x|yy|string|y|string|y|string|1|number|xyyz|string|z", + "xyyz".replace(/(y)(\1)?/g, f), + "Section 63" +); + +reportCompare( + "x|y|string|y|string||undefined|1|number|xyyz|string|" + + "|y|string|y|string||undefined|2|number|xyyz|string|z", + "xyyz".replace(/(y)(\1)??/g, f), + "Section 64" +); + +reportCompare( + "x|y|string|y|string|y|string|1|number|xyz|string|z", + "xyz".replace(/(?=(y))(\1)?/, f), + "Section 65" +); + +reportCompare( + "xyy|z|string||undefined||string|3|number|xyyz|string|", + "xyyz".replace(/(?!(y)y)(\1)z/, f), + "Section 66" +); + +rex = RegExp( + "()()()()()()()()()()" + + "()()()()()()()()()()" + + "()()()()()()()()()()" + + "()()()()()()()()()()" + + "()()()()()()()()()()" + + "()()()()()()()()()()" + + "()()()()()()()()()()" + + "()()()()()()()()()()" + + "()()()()()()()()()()" + + "()()()()()()()()()()(z)?(y)"); +a = ["sub"]; +for (i = 1; i <= 102; ++i) + a[i] = "p" + i; +a[103] = "offs"; +a[104] = "str"; +a[105] = "return ['', sub, typeof sub, offs, typeof offs, str, typeof str, " + + "p100, typeof p100, p101, typeof p101, p102, typeof p102, ''].join('|');"; +f = Function.apply(null, a); +reportCompare( + "x|y|string|1|number|xyz|string||string||undefined|y|string|z", + "xyz".replace(rex, f), + "Section 67" +); + +reportCompare( + "undefined", + "".replace(/.*/g, function () {}), + "Section 68" +); + +reportCompare( + "nullxnullynullznull", + "xyz".replace(/.??/g, function () { return null; }), + "Section 69" +); + +reportCompare( + "111", + "xyz".replace(/./g, function () { return 1; }), + "Section 70" +); diff --git a/tests/auto/qml/parserstress/tests/ecma_3/String/15.5.4.14.js b/tests/auto/qml/parserstress/tests/ecma_3/String/15.5.4.14.js new file mode 100644 index 0000000000..aa6c7354c2 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma_3/String/15.5.4.14.js @@ -0,0 +1,50 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is JavaScript Engine testing utilities. + * + * The Initial Developer of the Original Code is + * Mozilla Foundation. + * Portions created by the Initial Developer are Copyright (C) 2005 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): Karsten Sperling + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +var gTestfile = '15.5.4.14.js'; +//----------------------------------------------------------------------------- +var BUGNUMBER = 287630; +var summary = '15.5.4.14 - String.prototype.split(/()/)'; +var actual = ''; +var expect = ['a'].toString(); + +printBugNumber(BUGNUMBER); +printStatus (summary); + +actual = 'a'.split(/()/).toString(); + +reportCompare(expect, actual, summary); diff --git a/tests/auto/qml/parserstress/tests/ecma_3/String/browser.js b/tests/auto/qml/parserstress/tests/ecma_3/String/browser.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/auto/qml/parserstress/tests/ecma_3/String/regress-104375.js b/tests/auto/qml/parserstress/tests/ecma_3/String/regress-104375.js new file mode 100644 index 0000000000..c5593948d7 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma_3/String/regress-104375.js @@ -0,0 +1,116 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is mozilla.org code. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * k.mike@gmx.net, pschwartau@netscape.com + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +/* + * Date: 12 October 2001 + * + * SUMMARY: Regression test for string.replace bug 104375 + * See http://bugzilla.mozilla.org/show_bug.cgi?id=104375 + */ +//----------------------------------------------------------------------------- +var gTestfile = 'regress-104375.js'; +var UBound = 0; +var BUGNUMBER = 104375; +var summary = 'Testing string.replace() with backreferences'; +var status = ''; +var statusitems = []; +var actual = ''; +var actualvalues = []; +var expect= ''; +var expectedvalues = []; + + +/* + * Use the regexp to replace 'uid=31' with 'uid=15' + * + * In the second parameter of string.replace() method, + * "$1" refers to the first backreference: 'uid=' + */ +var str = 'uid=31'; +var re = /(uid=)(\d+)/; + +// try the numeric literal 15 +status = inSection(1); +actual = str.replace (re, "$1" + 15); +expect = 'uid=15'; +addThis(); + +// try the string literal '15' +status = inSection(2); +actual = str.replace (re, "$1" + '15'); +expect = 'uid=15'; +addThis(); + +// try a letter before the '15' +status = inSection(3); +actual = str.replace (re, "$1" + 'A15'); +expect = 'uid=A15'; +addThis(); + + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + + + +function addThis() +{ + statusitems[UBound] = status; + actualvalues[UBound] = actual; + expectedvalues[UBound] = expect; + UBound++; +} + + +function test() +{ + enterFunc ('test'); + printBugNumber(BUGNUMBER); + printStatus (summary); + + for (var i=0; i 'aaZaa' + expect = strJim.replace(new RegExp(strA), strB); // expect 'aa$aaZ' + reportCompare(expect, actual, status); + + + * + * Note: 'Zabc' is the result we expect for 'abc'.replace('', 'Z'). + * + * The string '' is supposed to be equivalent to new RegExp('') = //. + * The regexp // means we should match the "empty string" conceived of + * at the beginning boundary of the word, before the first character. + * + status = 'Section F of test'; + strA = cnEmptyString; + actual = str.replace(strA, strB); + expect = 'Zabc'; + reportCompare(expect, actual, status); + + status = 'Section G of test'; + strA = cnEmptyString; + actual = str.replace(strA, strB); + expect = str.replace(new RegExp(strA), strB); + reportCompare(expect, actual, status); + + ************************* END OF INCORRECT CASES ****************************/ + + +////////////////////////// OK, LET'S START OVER ////////////////////////////// + + status = 'Section 1 of test'; + actual = 'abc'.replace('a', 'Z'); + expect = 'Zbc'; + reportCompare(expect, actual, status); + + status = 'Section 2 of test'; + actual = 'abc'.replace('b', 'Z'); + expect = 'aZc'; + reportCompare(expect, actual, status); + + status = 'Section 3 of test'; + actual = 'abc'.replace(undefined, 'Z'); + expect = 'abc'; // String(undefined) == 'undefined'; no replacement possible + reportCompare(expect, actual, status); + + status = 'Section 4 of test'; + actual = 'abc'.replace(null, 'Z'); + expect = 'abc'; // String(null) == 'null'; no replacement possible + reportCompare(expect, actual, status); + + status = 'Section 5 of test'; + actual = 'abc'.replace(true, 'Z'); + expect = 'abc'; // String(true) == 'true'; no replacement possible + reportCompare(expect, actual, status); + + status = 'Section 6 of test'; + actual = 'abc'.replace(false, 'Z'); + expect = 'abc'; // String(false) == 'false'; no replacement possible + reportCompare(expect, actual, status); + + status = 'Section 7 of test'; + actual = 'aa$aa'.replace('$', 'Z'); + expect = 'aaZaa'; // NOT 'aa$aaZ' as in ECMA Final Draft; see above + reportCompare(expect, actual, status); + + status = 'Section 8 of test'; + actual = 'abc'.replace('.*', 'Z'); + expect = 'abc'; // not 'Z' as in EMCA Final Draft + reportCompare(expect, actual, status); + + status = 'Section 9 of test'; + actual = 'abc'.replace('', 'Z'); + expect = 'Zabc'; // Still expect 'Zabc' for this + reportCompare(expect, actual, status); + + exitFunc ('test'); +} diff --git a/tests/auto/qml/parserstress/tests/ecma_3/String/shell.js b/tests/auto/qml/parserstress/tests/ecma_3/String/shell.js new file mode 100644 index 0000000000..7d850446cc --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma_3/String/shell.js @@ -0,0 +1 @@ +gTestsubsuite = 'String'; diff --git a/tests/auto/qml/parserstress/tests/ecma_3/Unicode/browser.js b/tests/auto/qml/parserstress/tests/ecma_3/Unicode/browser.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/auto/qml/parserstress/tests/ecma_3/Unicode/regress-352044-01.js b/tests/auto/qml/parserstress/tests/ecma_3/Unicode/regress-352044-01.js new file mode 100755 index 0000000000..bb10ac6f7a --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma_3/Unicode/regress-352044-01.js @@ -0,0 +1,72 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is JavaScript Engine testing utilities. + * + * The Initial Developer of the Original Code is + * Mozilla Foundation. + * Portions created by the Initial Developer are Copyright (C) 2007 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): Martin Honnen + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +var gTestfile = 'regress-352044-01.js'; +//----------------------------------------------------------------------------- +var BUGNUMBER = 352044; +var summary = 'issues with Unicode escape sequences in JavaScript source code'; +var actual = ''; +var expect = ''; + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + enterFunc ('test'); + printBugNumber(BUGNUMBER); + printStatus (summary); + + expect = 'SyntaxError: illegal character'; + + try + { + var i = 1; + eval('i \\u002b= 1'); + print(i); + } + catch(ex) + { + actual = ex + ''; + } + + reportCompare(expect, actual, summary); + + exitFunc ('test'); +} diff --git a/tests/auto/qml/parserstress/tests/ecma_3/Unicode/regress-352044-02-n.js b/tests/auto/qml/parserstress/tests/ecma_3/Unicode/regress-352044-02-n.js new file mode 100755 index 0000000000..0e3c4b0189 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma_3/Unicode/regress-352044-02-n.js @@ -0,0 +1,72 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is JavaScript Engine testing utilities. + * + * The Initial Developer of the Original Code is + * Mozilla Foundation. + * Portions created by the Initial Developer are Copyright (C) 2007 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): Martin Honnen + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +var gTestfile = 'regress-352044-02-n.js'; +//----------------------------------------------------------------------------- +var BUGNUMBER = 352044; +var summary = 'issues with Unicode escape sequences in JavaScript source code'; +var actual = 'No Error'; +var expect = 'SyntaxError'; + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + enterFunc ('test'); + printBugNumber(BUGNUMBER); + printStatus (summary); + + print('This test case is expected to throw an uncaught SyntaxError'); + + try + { + var i = 1; + i \u002b= 1; + print(i); + } + catch(ex) + { + actual = ex + ''; + } + + reportCompare(expect, actual, summary); + + exitFunc ('test'); +} diff --git a/tests/auto/qml/parserstress/tests/ecma_3/Unicode/shell.js b/tests/auto/qml/parserstress/tests/ecma_3/Unicode/shell.js new file mode 100644 index 0000000000..97a64fe83d --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma_3/Unicode/shell.js @@ -0,0 +1 @@ +gTestsubsuite = 'Unicode'; diff --git a/tests/auto/qml/parserstress/tests/ecma_3/Unicode/uc-001-n.js b/tests/auto/qml/parserstress/tests/ecma_3/Unicode/uc-001-n.js new file mode 100644 index 0000000000..31a13f70e2 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma_3/Unicode/uc-001-n.js @@ -0,0 +1,62 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- + * + * ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * Rob Ginda rginda@netscape.com + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +var gTestfile = 'uc-001-n.js'; + +test(); + +function test() +{ + enterFunc ("test"); + + printStatus ("Unicode Characters 1C-1F negative test."); + printBugNumber (23612); + + reportCompare ("error", eval ("'no'\u001C+' error'"), + "Unicode whitespace test (1C.)"); + reportCompare ("error", eval ("'no'\u001D+' error'"), + "Unicode whitespace test (1D.)"); + reportCompare ("error", eval ("'no'\u001E+' error'"), + "Unicode whitespace test (1E.)"); + reportCompare ("error", eval ("'no'\u001F+' error'"), + "Unicode whitespace test (1F.)"); + + exitFunc ("test"); +} diff --git a/tests/auto/qml/parserstress/tests/ecma_3/Unicode/uc-001.js b/tests/auto/qml/parserstress/tests/ecma_3/Unicode/uc-001.js new file mode 100644 index 0000000000..3fc0c8d927 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma_3/Unicode/uc-001.js @@ -0,0 +1,56 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- + * + * ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * Rob Ginda rginda@netscape.com + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +var gTestfile = 'uc-001.js'; + +test(); + +function test() +{ + enterFunc ("test"); + + printStatus ("Unicode format-control character (Category Cf) test."); + printBugNumber (23610); + + reportCompare ("no error", eval('"no\u200E error"'), + "Unicode format-control character test (Category Cf.)"); + + exitFunc ("test"); +} diff --git a/tests/auto/qml/parserstress/tests/ecma_3/Unicode/uc-002-n.js b/tests/auto/qml/parserstress/tests/ecma_3/Unicode/uc-002-n.js new file mode 100644 index 0000000000..f1ae9a749d --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma_3/Unicode/uc-002-n.js @@ -0,0 +1,55 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- + * + * ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * Rob Ginda rginda@netscape.com + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +var gTestfile = 'uc-002-n.js'; + +DESCRIPTION = "Non-character escapes in identifiers negative test."; +EXPECTED = "error"; + +enterFunc ("test"); + +printStatus ("Non-character escapes in identifiers negative test."); +printBugNumber (23607); + +eval("\u0020 = 5"); +reportCompare('PASS', 'FAIL', "Previous statement should have thrown an error."); + +exitFunc ("test"); + diff --git a/tests/auto/qml/parserstress/tests/ecma_3/Unicode/uc-002.js b/tests/auto/qml/parserstress/tests/ecma_3/Unicode/uc-002.js new file mode 100644 index 0000000000..d19b2c4786 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma_3/Unicode/uc-002.js @@ -0,0 +1,60 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- + * + * ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * Rob Ginda rginda@netscape.com + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +var gTestfile = 'uc-002.js'; + +test(); + +function test() +{ + enterFunc ("test"); + + printStatus ("Unicode non-breaking space character test."); + printBugNumber (23613); + + reportCompare ("no error", eval("'no'\u00A0+ ' error'"), + "Unicode non-breaking space character test."); + + var str = "\u00A0foo"; + reportCompare (0, str.search(/^\sfoo$/), + "Unicode non-breaking space character regexp test."); + + exitFunc ("test"); +} diff --git a/tests/auto/qml/parserstress/tests/ecma_3/Unicode/uc-003.js b/tests/auto/qml/parserstress/tests/ecma_3/Unicode/uc-003.js new file mode 100644 index 0000000000..66c3f09860 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma_3/Unicode/uc-003.js @@ -0,0 +1,71 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- + * + * ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * Rob Ginda rginda@netscape.com + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +var gTestfile = 'uc-003.js'; + +test(); + +function test() +{ + enterFunc ("test"); + + var \u0041 = 5; + var A\u03B2 = 15; + var c\u0061se = 25; + + printStatus ("Escapes in identifiers test."); + printBugNumber (23608); + printBugNumber (23607); + + reportCompare (5, eval("\u0041"), + "Escaped ASCII Identifier test."); + reportCompare (6, eval("++\u0041"), + "Escaped ASCII Identifier test"); + reportCompare (15, eval("A\u03B2"), + "Escaped non-ASCII Identifier test"); + reportCompare (16, eval("++A\u03B2"), + "Escaped non-ASCII Identifier test"); + reportCompare (25, eval("c\\u00" + "61se"), + "Escaped keyword Identifier test"); + reportCompare (26, eval("++c\\u00" + "61se"), + "Escaped keyword Identifier test"); + + exitFunc ("test"); +} diff --git a/tests/auto/qml/parserstress/tests/ecma_3/Unicode/uc-004.js b/tests/auto/qml/parserstress/tests/ecma_3/Unicode/uc-004.js new file mode 100644 index 0000000000..a54923c525 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma_3/Unicode/uc-004.js @@ -0,0 +1,65 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- + * + * ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * Rob Ginda rginda@netscape.com + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +var gTestfile = 'uc-004.js'; + +test(); + +function test() +{ + enterFunc ("test"); + + printStatus ("Unicode Characters 1C-1F with regexps test."); + printBugNumber (23612); + + var ary = ["\u001Cfoo", "\u001Dfoo", "\u001Efoo", "\u001Ffoo"]; + + for (var i in ary) + { + reportCompare (0, ary[Number(i)].search(/^\Sfoo$/), + "Unicode characters 1C-1F in regexps, ary[" + + i + "] did not match \\S test (it should not.)"); + reportCompare (-1, ary[Number(i)].search(/^\sfoo$/), + "Unicode characters 1C-1F in regexps, ary[" + + i + "] matched \\s test (it should not.)"); + } + + exitFunc ("test"); +} diff --git a/tests/auto/qml/parserstress/tests/ecma_3/Unicode/uc-005.js b/tests/auto/qml/parserstress/tests/ecma_3/Unicode/uc-005.js new file mode 100644 index 0000000000..3727042046 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma_3/Unicode/uc-005.js @@ -0,0 +1,276 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is JavaScript Engine testing utilities. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corp. + * Portions created by the Initial Developer are Copyright (C) 2002 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * rogerl@netscape.com, pschwartau@netscape.com + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +/* + * + * Date: 15 July 2002 + * SUMMARY: Testing identifiers with double-byte names + * See http://bugzilla.mozilla.org/show_bug.cgi?id=58274 + * + * Here is a sample of the problem: + * + * js> function f\u02B1 () {} + * + * js> f\u02B1.toSource(); + * function f¦() {} + * + * js> f\u02B1.toSource().toSource(); + * (new String("function f\xB1() {}")) + * + * + * See how the high-byte information (the 02) has been lost? + * The same thing was happening with the toString() method: + * + * js> f\u02B1.toString(); + * + * function f¦() { + * } + * + * js> f\u02B1.toString().toSource(); + * (new String("\nfunction f\xB1() {\n}\n")) + * + */ +//----------------------------------------------------------------------------- +var gTestfile = 'uc-005.js'; +var UBound = 0; +var BUGNUMBER = 58274; +var summary = 'Testing identifiers with double-byte names'; +var status = ''; +var statusitems = []; +var actual = ''; +var actualvalues = []; +var expect= ''; +var expectedvalues = []; + + +/* + * Define a function that uses double-byte identifiers in + * "every possible way" + * + * Then recover each double-byte identifier via f.toString(). + * To make this easier, put a 'Z' token before every one. + * + * Our eval string will be: + * + * sEval = "function Z\u02b1(Z\u02b2, b) { + * try { Z\u02b3 : var Z\u02b4 = Z\u02b1; } + * catch (Z\u02b5) { for (var Z\u02b6 in Z\u02b5) + * {for (1; 1<0; Z\u02b7++) {new Array()[Z\u02b6] = 1;} };} }"; + * + * It will be helpful to build this string in stages: + */ +var s0 = 'function Z'; +var s1 = '\u02b1(Z'; +var s2 = '\u02b2, b) {try { Z'; +var s3 = '\u02b3 : var Z'; +var s4 = '\u02b4 = Z'; +var s5 = '\u02b1; } catch (Z' + var s6 = '\u02b5) { for (var Z'; +var s7 = '\u02b6 in Z'; +var s8 = '\u02b5){for (1; 1<0; Z'; +var s9 = '\u02b7++) {new Array()[Z'; +var s10 = '\u02b6] = 1;} };} }'; + + +/* + * Concatenate these and eval() to create the function Z\u02b1 + */ +var sEval = s0 + s1 + s2 + s3 + s4 + s5 + s6 + s7 + s8 + s9 + s10; +eval(sEval); + + +/* + * Recover all the double-byte identifiers via Z\u02b1.toString(). + * We'll recover the 1st one as arrID[1], the 2nd one as arrID[2], + * and so on ... + */ +var arrID = getIdentifiers(Z\u02b1); + + +/* + * Now check that we got back what we put in - + */ +status = inSection(1); +actual = arrID[1]; +expect = s1.charAt(0); +addThis(); + +status = inSection(2); +actual = arrID[2]; +expect = s2.charAt(0); +addThis(); + +status = inSection(3); +actual = arrID[3]; +expect = s3.charAt(0); +addThis(); + +status = inSection(4); +actual = arrID[4]; +expect = s4.charAt(0); +addThis(); + +status = inSection(5); +actual = arrID[5]; +expect = s5.charAt(0); +addThis(); + +status = inSection(6); +actual = arrID[6]; +expect = s6.charAt(0); +addThis(); + +status = inSection(7); +actual = arrID[7]; +expect = s7.charAt(0); +addThis(); + +status = inSection(8); +actual = arrID[8]; +expect = s8.charAt(0); +addThis(); + +status = inSection(9); +actual = arrID[9]; +expect = s9.charAt(0); +addThis(); + +status = inSection(10); +actual = arrID[10]; +expect = s10.charAt(0); +addThis(); + + + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + + + +/* + * Goal: recover the double-byte identifiers from f.toString() + * by getting the very next character after each 'Z' token. + * + * The return value will be an array |arr| indexed such that + * |arr[1]| is the 1st identifier, |arr[2]| the 2nd, and so on. + * + * Note, however, f.toString() is implementation-independent. + * For example, it may begin with '\nfunction' instead of 'function'. + * + * Rhino uses a Unicode representation for f.toString(); whereas + * SpiderMonkey uses an ASCII representation, putting escape sequences + * for non-ASCII characters. For example, if a function is called f\u02B1, + * then in Rhino the toString() method will present a 2-character Unicode + * string for its name, whereas SpiderMonkey will present a 7-character + * ASCII string for its name: the string literal 'f\u02B1'. + * + * So we force the lexer to condense the string before we use it. + * This will give uniform results in Rhino and SpiderMonkey. + */ +function getIdentifiers(f) +{ + var str = condenseStr(f.toString()); + var arr = str.split('Z'); + + /* + * The identifiers are the 1st char of each split substring + * EXCEPT the first one, which is just ('\n' +) 'function '. + * + * Thus note the 1st identifier will be stored in |arr[1]|, + * the 2nd one in |arr[2]|, etc., making the indexing easy - + */ + for (i in arr) + arr[i] = arr[i].charAt(0); + return arr; +} + + +/* + * This function is the opposite of a functions like escape(), which take + * Unicode characters and return escape sequences for them. Here, we force + * the lexer to turn escape sequences back into single characters. + * + * Note we can't simply do |eval(str)|, since in practice |str| will be an + * identifier somewhere in the program (e.g. a function name); thus |eval(str)| + * would return the object that the identifier represents: not what we want. + * + * So we surround |str| lexicographically with quotes to force the lexer to + * evaluate it as a string. Have to strip out any linefeeds first, however - + */ +function condenseStr(str) +{ + /* + * You won't be able to do the next step if |str| has + * any carriage returns or linefeeds in it. For example: + * + * js> eval("'" + '\nHello' + "'"); + * 1: SyntaxError: unterminated string literal: + * 1: ' + * 1: ^ + * + * So replace them with the empty string - + */ + str = str.replace(/[\r\n]/g, '') + return eval("'" + str + "'") + } + + +function addThis() +{ + statusitems[UBound] = status; + actualvalues[UBound] = actual; + expectedvalues[UBound] = expect; + UBound++; +} + + +function test() +{ + enterFunc('test'); + printBugNumber(BUGNUMBER); + printStatus(summary); + + for (var i=0; i?"; +var UntilRSBs = "[^]]*]([^]]+])*]+"; +var CDATA_CE = UntilRSBs + "([^]>]" + UntilRSBs + ")*>"; +var S = "[ \\n\\t\\r]+"; +var QuoteSE = '"[^"]' + "*" + '"' + "|'[^']*'"; +var DT_IdentSE = S + Name + "(" + S + "(" + Name + "|" + QuoteSE + "))*"; +var MarkupDeclCE = "([^]\"'><]+|" + QuoteSE + ")*>"; +var S1 = "[\\n\\r\\t ]"; +var UntilQMs = "[^?]*\\?+"; +var PI_Tail = "\\?>|" + S1 + UntilQMs + "([^>?]" + UntilQMs + ")*>"; +var DT_ItemSE = "<(!(--" + Until2Hyphens + ">|[^-]" + MarkupDeclCE + ")|\\?" + Name + "(" + PI_Tail + "))|%" + Name + ";|" + S; +var DocTypeCE = DT_IdentSE + "(" + S + ")?(\\[(" + DT_ItemSE + ")*](" + S + ")?)?>?"; +var DeclCE = "--(" + CommentCE + ")?|\\[CDATA\\[(" + CDATA_CE + ")?|DOCTYPE(" + DocTypeCE + ")?"; +var PI_CE = Name + "(" + PI_Tail + ")?"; +var EndTagCE = Name + "(" + S + ")?>?"; +var AttValSE = '"[^<"]' + "*" + '"' + "|'[^<']*'"; +var ElemTagCE = Name + "(" + S + Name + "(" + S + ")?=(" + S + ")?(" + AttValSE + "))*(" + S + ")?/?>?"; +var MarkupSPE = "<(!(" + DeclCE + ")?|\\?(" + PI_CE + ")?|/(" + EndTagCE + ")?|(" + ElemTagCE + ")?)"; +var XML_SPE = TextSE + "|" + MarkupSPE; +var CommentRE = " casting fails + { + Bar *pbar = qscriptvalue_cast(baz2Value); + QVERIFY(pbar == 0); + } + + { + QScriptValue ret = toBaz.callWithInstance(scriptZoo, QScriptValueList() << baz2Value); + QVERIFY(ret.isError()); + QCOMPARE(ret.toString(), QLatin1String("TypeError: incompatible type of argument(s) in call to toBaz(); candidates were\n toBaz(Bar*)")); + } + + // establish chain -- now casting should work + // Why? because qscriptvalue_cast() does magic again. + // It the instance itself is not of type T, qscriptvalue_cast() + // searches the prototype chain for T, and if it finds one, it infers + // that the instance can also be casted to that type. This cast is + // _not_ safe and thus relies on the developer doing the right thing. + // This is an undocumented feature to enable qscriptvalue_cast() to + // be used by prototype functions to cast the JS this-object to C++. + bazProto.setPrototype(barProto); + + { + Bar *pbar = qscriptvalue_cast(baz2Value); + QVERIFY(pbar != 0); + QCOMPARE(pbar->a, baz2.a); + } + + { + QScriptValue ret = toBaz.callWithInstance(scriptZoo, QScriptValueList() << baz2Value); + QEXPECT_FAIL("", "Cannot convert Baz* to Bar*", Continue); + QVERIFY(!ret.isError()); + QEXPECT_FAIL("", "Cannot convert Baz* to Bar*", Continue); + QCOMPARE(qscriptvalue_cast(ret), pbaz); + } + } + + bazProto.setPrototype(barProto.prototype()); // kill chain + { + Baz *pbaz = qscriptvalue_cast(baz2Value); + QVERIFY(pbaz != 0); + // should not work anymore + Bar *pbar = qscriptvalue_cast(baz2Value); + QVERIFY(pbar == 0); + } + + bazProto.setPrototype(eng.newQObject(this)); + { + Baz *pbaz = qscriptvalue_cast(baz2Value); + QVERIFY(pbaz != 0); + // should not work now either + Bar *pbar = qscriptvalue_cast(baz2Value); + QVERIFY(pbar == 0); + } + + { + QScriptValue b = eng.toScriptValue(QBrush()); + b.setPrototype(barProto); + // this shows that a "wrong" cast is possible, if you + // don't play by the rules (the pointer is actually a QBrush*)... + Bar *pbar = qscriptvalue_cast(b); + QVERIFY(pbar != 0); + } + + { + QScriptValue gradientProto = eng.toScriptValue(QGradient()); + QScriptValue linearGradientProto = eng.toScriptValue(QLinearGradient()); + linearGradientProto.setPrototype(gradientProto); + QLinearGradient lg(10, 20, 30, 40); + QScriptValue linearGradient = eng.toScriptValue(lg); + { + QGradient *pgrad = qscriptvalue_cast(linearGradient); + QVERIFY(pgrad == 0); + } + linearGradient.setPrototype(linearGradientProto); + { + QGradient *pgrad = qscriptvalue_cast(linearGradient); + QVERIFY(pgrad != 0); + QCOMPARE(pgrad->type(), QGradient::LinearGradient); + QLinearGradient *plingrad = static_cast(pgrad); + QCOMPARE(plingrad->start(), lg.start()); + QCOMPARE(plingrad->finalStop(), lg.finalStop()); + } + } +} +#endif + +class Klazz : public QWidget, + public QStandardItem, + public QGraphicsItem +{ + Q_INTERFACES(QGraphicsItem) + Q_OBJECT +public: + Klazz(QWidget *parent = 0) : QWidget(parent) { } + virtual QRectF boundingRect() const { return QRectF(); } + virtual void paint(QPainter*, const QStyleOptionGraphicsItem*, QWidget*) { } +}; + +Q_DECLARE_METATYPE(Klazz*) +Q_DECLARE_METATYPE(QStandardItem*) + +void tst_QJSEngine::castWithMultipleInheritance() +{ + QJSEngine eng; + Klazz klz; + QJSValue v = eng.newQObject(&klz); + + QCOMPARE(qjsvalue_cast(v), &klz); + QCOMPARE(qjsvalue_cast(v), (QWidget *)&klz); + QCOMPARE(qjsvalue_cast(v), (QObject *)&klz); + QCOMPARE(qjsvalue_cast(v), (QStandardItem *)&klz); + QCOMPARE(qjsvalue_cast(v), (QGraphicsItem *)&klz); +} + +void tst_QJSEngine::collectGarbage() +{ + QJSEngine eng; + eng.evaluate("a = new Object(); a = new Object(); a = new Object()"); + QJSValue a = eng.newObject(); + a = eng.newObject(); + a = eng.newObject(); + QPointer ptr = new QObject(); + QVERIFY(ptr != 0); + (void)eng.newQObject(ptr); + collectGarbage_helper(eng); + if (ptr) + QGuiApplication::sendPostedEvents(ptr, QEvent::DeferredDelete); + QVERIFY(ptr == 0); +} + +#if 0 // ###FIXME: no reportAdditionalMemoryCost API +void tst_QJSEngine::reportAdditionalMemoryCost() +{ + QScriptEngine eng; + // There isn't any reliable way to test whether calling + // this function affects garbage collection responsiveness; + // the best we can do is call it with a few different values. + for (int x = 0; x < 100; ++x) { + eng.reportAdditionalMemoryCost(0); + eng.reportAdditionalMemoryCost(10); + eng.reportAdditionalMemoryCost(1000); + eng.reportAdditionalMemoryCost(10000); + eng.reportAdditionalMemoryCost(100000); + eng.reportAdditionalMemoryCost(1000000); + eng.reportAdditionalMemoryCost(10000000); + eng.reportAdditionalMemoryCost(-1); + eng.reportAdditionalMemoryCost(-1000); + QScriptValue obj = eng.newObject(); + eng.collectGarbage(); + } +} +#endif + +void tst_QJSEngine::gcWithNestedDataStructure() +{ + // The GC must be able to traverse deeply nested objects, otherwise this + // test would crash. + QJSEngine eng; + eng.evaluate( + "function makeList(size)" + "{" + " var head = { };" + " var l = head;" + " for (var i = 0; i < size; ++i) {" + " l.data = i + \"\";" + " l.next = { }; l = l.next;" + " }" + " l.next = null;" + " return head;" + "}"); + QCOMPARE(eng.hasUncaughtException(), false); + const int size = 200; + QJSValue head = eng.evaluate(QString::fromLatin1("makeList(%0)").arg(size)); + QCOMPARE(eng.hasUncaughtException(), false); + for (int x = 0; x < 2; ++x) { + if (x == 1) + eng.evaluate("gc()"); + QJSValue l = head; + // Make sure all the nodes are still alive. + for (int i = 0; i < 200; ++i) { + QCOMPARE(l.property("data").toString(), QString::number(i)); + l = l.property("next"); + } + } +} + +#if 0 // ###FIXME: No processEvents handling +class EventReceiver : public QObject +{ +public: + EventReceiver() { + received = false; + } + + bool event(QEvent *e) { + received |= (e->type() == QEvent::User + 1); + return QObject::event(e); + } + + bool received; +}; + +void tst_QJSEngine::processEventsWhileRunning() +{ + for (int x = 0; x < 2; ++x) { + QScriptEngine eng; + if (x == 0) + eng.pushContext(); + + // This is running for a silly amount of time just to make sure + // the script doesn't finish before event processing is triggered. + QString script = QString::fromLatin1( + "var end = Number(new Date()) + 2000;" + "var x = 0;" + "while (Number(new Date()) < end) {" + " ++x;" + "}"); + + EventReceiver receiver; + QCoreApplication::postEvent(&receiver, new QEvent(QEvent::Type(QEvent::User+1))); + + eng.evaluate(script); + QVERIFY(!eng.hasUncaughtException()); + QVERIFY(!receiver.received); + + QCOMPARE(eng.processEventsInterval(), -1); + eng.setProcessEventsInterval(100); + eng.evaluate(script); + QVERIFY(!eng.hasUncaughtException()); + QVERIFY(receiver.received); + + if (x == 0) + eng.popContext(); + } +} + +void tst_QJSEngine::processEventsWhileRunning_function() +{ + QScriptEngine eng; + QScriptValue script = eng.evaluate(QString::fromLatin1( + "(function() { var end = Number(new Date()) + 2000;" + "var x = 0;" + "while (Number(new Date()) < end) {" + " ++x;" + "} })")); + + eng.setProcessEventsInterval(100); + + for (int x = 0; x < 2; ++x) { + EventReceiver receiver; + QCoreApplication::postEvent(&receiver, new QEvent(QEvent::Type(QEvent::User+1))); + QVERIFY(!eng.hasUncaughtException()); + QVERIFY(!receiver.received); + QCOMPARE(eng.processEventsInterval(), 100); + + if (x) script.call(); + else script.callAsConstructor(); + + QVERIFY(!eng.hasUncaughtException()); + QVERIFY(receiver.received); + } +} + + +class EventReceiver2 : public QObject +{ +public: + EventReceiver2(QScriptEngine *eng) { + engine = eng; + } + + bool event(QEvent *e) { + if (e->type() == QEvent::User + 1) { + engine->currentContext()->throwError("Killed"); + } + return QObject::event(e); + } + + QScriptEngine *engine; +}; + +void tst_QJSEngine::throwErrorFromProcessEvents_data() +{ + QTest::addColumn("script"); + QTest::addColumn("error"); + + QTest::newRow("while (1)") + << QString::fromLatin1("while (1) { }") + << QString::fromLatin1("Error: Killed"); + QTest::newRow("while (1) i++") + << QString::fromLatin1("i = 0; while (1) { i++; }") + << QString::fromLatin1("Error: Killed"); + // Unlike abortEvaluation(), scripts should be able to catch the + // exception. + QTest::newRow("try catch") + << QString::fromLatin1("try {" + " while (1) { }" + "} catch(e) {" + " throw new Error('Caught');" + "}") + << QString::fromLatin1("Error: Caught"); +} + +void tst_QJSEngine::throwErrorFromProcessEvents() +{ + QFETCH(QString, script); + QFETCH(QString, error); + + QScriptEngine eng; + + EventReceiver2 receiver(&eng); + QCoreApplication::postEvent(&receiver, new QEvent(QEvent::Type(QEvent::User+1))); + + eng.setProcessEventsInterval(100); + QScriptValue ret = eng.evaluate(script); + QVERIFY(ret.isError()); + QCOMPARE(ret.toString(), error); +} + +void tst_QJSEngine::disableProcessEventsInterval() +{ + QScriptEngine eng; + eng.setProcessEventsInterval(100); + QCOMPARE(eng.processEventsInterval(), 100); + eng.setProcessEventsInterval(0); + QCOMPARE(eng.processEventsInterval(), 0); + eng.setProcessEventsInterval(-1); + QCOMPARE(eng.processEventsInterval(), -1); + eng.setProcessEventsInterval(-100); + QCOMPARE(eng.processEventsInterval(), -100); +} +#endif + + +void tst_QJSEngine::stacktrace() +{ + QString script = QString::fromLatin1( + "function foo(counter) {\n" + " switch (counter) {\n" + " case 0: foo(counter+1); break;\n" + " case 1: foo(counter+1); break;\n" + " case 2: foo(counter+1); break;\n" + " case 3: foo(counter+1); break;\n" + " case 4: foo(counter+1); break;\n" + " default:\n" + " throw new Error('blah');\n" + " }\n" + "}\n" + "foo(0);"); + + const QString fileName("testfile"); + + QStringList backtrace; + backtrace << "foo(5)@testfile:9" + << "foo(4)@testfile:7" + << "foo(3)@testfile:6" + << "foo(2)@testfile:5" + << "foo(1)@testfile:4" + << "foo(0)@testfile:3" + << "()@testfile:12"; + + QJSEngine eng; + QJSValue result = eng.evaluate(script, fileName); + QVERIFY(eng.hasUncaughtException()); + QVERIFY(result.isError()); + + // QEXPECT_FAIL("", "QTBUG-6139: uncaughtExceptionBacktrace() doesn't give the full backtrace", Abort); + // ###FIXME: no uncahgutExceptionBacktrace: QCOMPARE(eng.uncaughtExceptionBacktrace(), backtrace); + QVERIFY(eng.hasUncaughtException()); + QVERIFY(result.strictlyEquals(eng.uncaughtException())); + + // FIXME? it is not standard. + //QCOMPARE(result.property("fileName").toString(), fileName); + //QCOMPARE(result.property("lineNumber").toInt(), 9); + + QJSValue stack = result.property("stack"); + + // FIXME? it is not standard. + // QVERIFY(stack.isArray()); + //QCOMPARE(stack.property("length").toInt(), 7); + + QJSValueIterator it(stack); + int counter = 5; + while (it.hasNext()) { + it.next(); + QJSValue obj = it.value(); + QJSValue frame = obj.property("frame"); + + QCOMPARE(obj.property("fileName").toString(), fileName); + if (counter >= 0) { + QJSValue callee = frame.property("arguments").property("callee"); + QVERIFY(callee.strictlyEquals(eng.globalObject().property("foo"))); + QCOMPARE(obj.property("functionName").toString(), QString("foo")); + int line = obj.property("lineNumber").toInt(); + if (counter == 5) + QCOMPARE(line, 9); + else + QCOMPARE(line, 3 + counter); + } else { + QVERIFY(frame.strictlyEquals(eng.globalObject())); + QVERIFY(obj.property("functionName").toString().isEmpty()); + } + + --counter; + } + +// FIXME? it is not standard. +// { +// QJSValue bt = result.property("backtrace").call(result); +// QCOMPARE(qjsvalue_cast(bt), backtrace); +// } + + // throw something that isn't an Error object + eng.clearExceptions(); + // ###FIXME: No uncaughtExceptionBacktrace: QVERIFY(eng.uncaughtExceptionBacktrace().isEmpty()); + QString script2 = QString::fromLatin1( + "function foo(counter) {\n" + " switch (counter) {\n" + " case 0: foo(counter+1); break;\n" + " case 1: foo(counter+1); break;\n" + " case 2: foo(counter+1); break;\n" + " case 3: foo(counter+1); break;\n" + " case 4: foo(counter+1); break;\n" + " default:\n" + " throw 'just a string';\n" + " }\n" + "}\n" + "foo(0);"); + + QJSValue result2 = eng.evaluate(script2, fileName); + QVERIFY(eng.hasUncaughtException()); + QVERIFY(!result2.isError()); + QVERIFY(result2.isString()); + + // ###FIXME: No uncaughtExceptionBacktrace: QCOMPARE(eng.uncaughtExceptionBacktrace(), backtrace); + QVERIFY(eng.hasUncaughtException()); + + eng.clearExceptions(); + QVERIFY(!eng.hasUncaughtException()); + // ###FIXME: No uncaughtExceptionBacktrace: QVERIFY(eng.uncaughtExceptionBacktrace().isEmpty()); +} + +void tst_QJSEngine::numberParsing_data() +{ + QTest::addColumn("string"); + QTest::addColumn("expect"); + + QTest::newRow("decimal 0") << QString("0") << qreal(0); + QTest::newRow("octal 0") << QString("00") << qreal(00); + QTest::newRow("hex 0") << QString("0x0") << qreal(0x0); + QTest::newRow("decimal 100") << QString("100") << qreal(100); + QTest::newRow("hex 100") << QString("0x100") << qreal(0x100); + QTest::newRow("octal 100") << QString("0100") << qreal(0100); + QTest::newRow("decimal 4G") << QString("4294967296") << qreal(Q_UINT64_C(4294967296)); + QTest::newRow("hex 4G") << QString("0x100000000") << qreal(Q_UINT64_C(0x100000000)); + QTest::newRow("octal 4G") << QString("040000000000") << qreal(Q_UINT64_C(040000000000)); + QTest::newRow("0.5") << QString("0.5") << qreal(0.5); + QTest::newRow("1.5") << QString("1.5") << qreal(1.5); + QTest::newRow("1e2") << QString("1e2") << qreal(100); +} + +void tst_QJSEngine::numberParsing() +{ + QFETCH(QString, string); + QFETCH(qreal, expect); + + QJSEngine eng; + QJSValue ret = eng.evaluate(string); + QVERIFY(ret.isNumber()); + qreal actual = ret.toNumber(); + QCOMPARE(actual, expect); +} + +// see ECMA-262, section 7.9 +// This is testing ECMA compliance, not our C++ API, but it's important that +// the back-end is conformant in this regard. +void tst_QJSEngine::automaticSemicolonInsertion() +{ + QJSEngine eng; + { + QJSValue ret = eng.evaluate("{ 1 2 } 3"); + QVERIFY(ret.isError()); + QVERIFY(ret.toString().contains("SyntaxError")); + } + { + QJSValue ret = eng.evaluate("{ 1\n2 } 3"); + QVERIFY(ret.isNumber()); + QCOMPARE(ret.toInt(), 3); + } + { + QJSValue ret = eng.evaluate("for (a; b\n)"); + QVERIFY(ret.isError()); + QVERIFY(ret.toString().contains("SyntaxError")); + } + { + QJSValue ret = eng.evaluate("(function() { return\n1 + 2 })()"); + QVERIFY(ret.isUndefined()); + } + { + eng.evaluate("c = 2; b = 1"); + QJSValue ret = eng.evaluate("a = b\n++c"); + QVERIFY(ret.isNumber()); + QCOMPARE(ret.toInt(), 3); + } + { + QJSValue ret = eng.evaluate("if (a > b)\nelse c = d"); + QVERIFY(ret.isError()); + QVERIFY(ret.toString().contains("SyntaxError")); + } + { + eng.evaluate("function c() { return { foo: function() { return 5; } } }"); + eng.evaluate("b = 1; d = 2; e = 3"); + QJSValue ret = eng.evaluate("a = b + c\n(d + e).foo()"); + QVERIFY(ret.isNumber()); + QCOMPARE(ret.toInt(), 6); + } + { + QJSValue ret = eng.evaluate("throw\n1"); + QVERIFY(ret.isError()); + QVERIFY(ret.toString().contains("SyntaxError")); + } + { + QJSValue ret = eng.evaluate("a = Number(1)\n++a"); + QVERIFY(ret.isNumber()); + QCOMPARE(ret.toInt(), 2); + } + + // "a semicolon is never inserted automatically if the semicolon + // would then be parsed as an empty statement" + { + eng.evaluate("a = 123"); + QJSValue ret = eng.evaluate("if (0)\n ++a; a"); + QVERIFY(ret.isNumber()); + QCOMPARE(ret.toInt(), 123); + } + { + eng.evaluate("a = 123"); + QJSValue ret = eng.evaluate("if (0)\n --a; a"); + QVERIFY(ret.isNumber()); + QCOMPARE(ret.toInt(), 123); + } + { + eng.evaluate("a = 123"); + QJSValue ret = eng.evaluate("if ((0))\n ++a; a"); + QVERIFY(ret.isNumber()); + QCOMPARE(ret.toInt(), 123); + } + { + eng.evaluate("a = 123"); + QJSValue ret = eng.evaluate("if ((0))\n --a; a"); + QVERIFY(ret.isNumber()); + QCOMPARE(ret.toInt(), 123); + } + { + eng.evaluate("a = 123"); + QJSValue ret = eng.evaluate("if (0\n)\n ++a; a"); + QVERIFY(ret.isNumber()); + QCOMPARE(ret.toInt(), 123); + } + { + eng.evaluate("a = 123"); + QJSValue ret = eng.evaluate("if (0\n ++a; a"); + QVERIFY(ret.isError()); + } + { + eng.evaluate("a = 123"); + QJSValue ret = eng.evaluate("if (0))\n ++a; a"); + QVERIFY(ret.isError()); + } + { + QJSValue ret = eng.evaluate("n = 0; for (i = 0; i < 10; ++i)\n ++n; n"); + QVERIFY(ret.isNumber()); + QCOMPARE(ret.toInt(), 10); + } + { + QJSValue ret = eng.evaluate("n = 30; for (i = 0; i < 10; ++i)\n --n; n"); + QVERIFY(ret.isNumber()); + QCOMPARE(ret.toInt(), 20); + } + { + QJSValue ret = eng.evaluate("n = 0; for (var i = 0; i < 10; ++i)\n ++n; n"); + QVERIFY(ret.isNumber()); + QCOMPARE(ret.toInt(), 10); + } + { + QJSValue ret = eng.evaluate("n = 30; for (var i = 0; i < 10; ++i)\n --n; n"); + QVERIFY(ret.isNumber()); + QCOMPARE(ret.toInt(), 20); + } + { + QJSValue ret = eng.evaluate("n = 0; i = 0; while (i++ < 10)\n ++n; n"); + QVERIFY(ret.isNumber()); + QCOMPARE(ret.toInt(), 10); + } + { + QJSValue ret = eng.evaluate("n = 30; i = 0; while (i++ < 10)\n --n; n"); + QVERIFY(ret.isNumber()); + QCOMPARE(ret.toInt(), 20); + } + { + QJSValue ret = eng.evaluate("o = { a: 0, b: 1, c: 2 }; n = 0; for (i in o)\n ++n; n"); + QVERIFY(ret.isNumber()); + QCOMPARE(ret.toInt(), 3); + } + { + QJSValue ret = eng.evaluate("o = { a: 0, b: 1, c: 2 }; n = 9; for (i in o)\n --n; n"); + QVERIFY(ret.isNumber()); + QCOMPARE(ret.toInt(), 6); + } + { + QJSValue ret = eng.evaluate("o = { a: 0, b: 1, c: 2 }; n = 0; for (var i in o)\n ++n; n"); + QVERIFY(ret.isNumber()); + QCOMPARE(ret.toInt(), 3); + } + { + QJSValue ret = eng.evaluate("o = { a: 0, b: 1, c: 2 }; n = 9; for (var i in o)\n --n; n"); + QVERIFY(ret.isNumber()); + QCOMPARE(ret.toInt(), 6); + } + { + QJSValue ret = eng.evaluate("o = { n: 3 }; n = 5; with (o)\n ++n; n"); + QVERIFY(ret.isNumber()); + QCOMPARE(ret.toInt(), 5); + } + { + QJSValue ret = eng.evaluate("o = { n: 3 }; n = 10; with (o)\n --n; n"); + QVERIFY(ret.isNumber()); + QCOMPARE(ret.toInt(), 10); + } + { + QJSValue ret = eng.evaluate("n = 5; i = 0; do\n ++n; while (++i < 10); n"); + QVERIFY(ret.isNumber()); + QCOMPARE(ret.toInt(), 15); + } + { + QJSValue ret = eng.evaluate("n = 20; i = 0; do\n --n; while (++i < 10); n"); + QVERIFY(ret.isNumber()); + QCOMPARE(ret.toInt(), 10); + } + + { + QJSValue ret = eng.evaluate("n = 1; i = 0; if (n) i\n++n; n"); + QVERIFY(ret.isNumber()); + QCOMPARE(ret.toInt(), 2); + } + { + QJSValue ret = eng.evaluate("n = 1; i = 0; if (n) i\n--n; n"); + QVERIFY(ret.isNumber()); + QCOMPARE(ret.toInt(), 0); + } + + { + QJSValue ret = eng.evaluate("if (0)"); + QVERIFY(ret.isError()); + } + { + QJSValue ret = eng.evaluate("while (0)"); + QVERIFY(ret.isError()); + } + { + QJSValue ret = eng.evaluate("for (;;)"); + QVERIFY(ret.isError()); + } + { + QJSValue ret = eng.evaluate("for (p in this)"); + QVERIFY(ret.isError()); + } + { + QJSValue ret = eng.evaluate("with (this)"); + QVERIFY(ret.isError()); + } + { + QJSValue ret = eng.evaluate("do"); + QVERIFY(ret.isError()); + } +} + +#if 0 // ###FIXME: no abortEvaluation API +class EventReceiver3 : public QObject +{ +public: + enum AbortionResult { + None = 0, + String = 1, + Error = 2, + Number = 3 + }; + + EventReceiver3(QScriptEngine *eng) { + engine = eng; + resultType = None; + } + + bool event(QEvent *e) { + if (e->type() == QEvent::User + 1) { + switch (resultType) { + case None: + engine->abortEvaluation(); + break; + case String: + engine->abortEvaluation(QScriptValue(engine, QString::fromLatin1("Aborted"))); + break; + case Error: + engine->abortEvaluation(engine->currentContext()->throwError("AbortedWithError")); + break; + case Number: + engine->abortEvaluation(QScriptValue(1234)); + } + } + return QObject::event(e); + } + + AbortionResult resultType; + QScriptEngine *engine; +}; + +static QScriptValue myFunctionAbortingEvaluation(QScriptContext *, QScriptEngine *eng) +{ + eng->abortEvaluation(); + return eng->nullValue(); // should be ignored +} + +void tst_QJSEngine::abortEvaluation_notEvaluating() +{ + QScriptEngine eng; + + eng.abortEvaluation(); + QVERIFY(!eng.hasUncaughtException()); + + eng.abortEvaluation(123); + { + QScriptValue ret = eng.evaluate("'ciao'"); + QVERIFY(ret.isString()); + QCOMPARE(ret.toString(), QString::fromLatin1("ciao")); + } +} + +void tst_QJSEngine::abortEvaluation_data() +{ + QTest::addColumn("script"); + + QTest::newRow("while (1)") + << QString::fromLatin1("while (1) { }"); + QTest::newRow("while (1) i++") + << QString::fromLatin1("i = 0; while (1) { i++; }"); + QTest::newRow("try catch") + << QString::fromLatin1("try {" + " while (1) { }" + "} catch(e) {" + " throw new Error('Caught');" + "}"); +} + +void tst_QJSEngine::abortEvaluation() +{ + QFETCH(QString, script); + + QScriptEngine eng; + EventReceiver3 receiver(&eng); + + eng.setProcessEventsInterval(100); + for (int x = 0; x < 4; ++x) { + QCoreApplication::postEvent(&receiver, new QEvent(QEvent::Type(QEvent::User+1))); + receiver.resultType = EventReceiver3::AbortionResult(x); + QScriptValue ret = eng.evaluate(script); + switch (receiver.resultType) { + case EventReceiver3::None: + QVERIFY(!eng.hasUncaughtException()); + QVERIFY(ret.isUndefined()); + break; + case EventReceiver3::Number: + QVERIFY(!eng.hasUncaughtException()); + QVERIFY(ret.isNumber()); + QCOMPARE(ret.toInt(), 1234); + break; + case EventReceiver3::String: + QVERIFY(!eng.hasUncaughtException()); + QVERIFY(ret.isString()); + QCOMPARE(ret.toString(), QString::fromLatin1("Aborted")); + break; + case EventReceiver3::Error: + QVERIFY(eng.hasUncaughtException()); + QVERIFY(ret.isError()); + QCOMPARE(ret.toString(), QString::fromLatin1("Error: AbortedWithError")); + break; + } + } + +} + +void tst_QJSEngine::abortEvaluation_tryCatch() +{ + QSKIP("It crashes"); + QScriptEngine eng; + EventReceiver3 receiver(&eng); + eng.setProcessEventsInterval(100); + // scripts cannot intercept the abortion with try/catch + for (int y = 0; y < 4; ++y) { + QCoreApplication::postEvent(&receiver, new QEvent(QEvent::Type(QEvent::User+1))); + receiver.resultType = EventReceiver3::AbortionResult(y); + QScriptValue ret = eng.evaluate(QString::fromLatin1( + "while (1) {\n" + " try {\n" + " (function() { while (1) { } })();\n" + " } catch (e) {\n" + " ;\n" + " }\n" + "}")); + switch (receiver.resultType) { + case EventReceiver3::None: + QVERIFY(!eng.hasUncaughtException()); + QVERIFY(ret.isUndefined()); + break; + case EventReceiver3::Number: + QVERIFY(!eng.hasUncaughtException()); + QVERIFY(ret.isNumber()); + QCOMPARE(ret.toInt(), 1234); + break; + case EventReceiver3::String: + QVERIFY(!eng.hasUncaughtException()); + QVERIFY(ret.isString()); + QCOMPARE(ret.toString(), QString::fromLatin1("Aborted")); + break; + case EventReceiver3::Error: + QVERIFY(eng.hasUncaughtException()); + QVERIFY(ret.isError()); + break; + } + } +} + +void tst_QJSEngine::abortEvaluation_fromNative() +{ + QScriptEngine eng; + QScriptValue fun = eng.newFunction(myFunctionAbortingEvaluation); + eng.globalObject().setProperty("myFunctionAbortingEvaluation", fun); + QScriptValue ret = eng.evaluate("myFunctionAbortingEvaluation()"); + QVERIFY(ret.isUndefined()); +} + +class ThreadedEngine : public QThread { + Q_OBJECT; + +private: + QScriptEngine* m_engine; +protected: + void run() { + m_engine = new QScriptEngine(); + m_engine->setGlobalObject(m_engine->newQObject(this)); + m_engine->evaluate("while (1) { sleep(); }"); + delete m_engine; + } + +public slots: + void sleep() + { + QTest::qSleep(25); + m_engine->abortEvaluation(); + } +}; + +void tst_QJSEngine::abortEvaluation_QTBUG9433() +{ + ThreadedEngine engine; + engine.start(); + QVERIFY(engine.isRunning()); + QTest::qSleep(50); + for (uint i = 0; i < 50; ++i) { // up to ~2500 ms + if (engine.isFinished()) + return; + QTest::qSleep(50); + } + if (!engine.isFinished()) { + engine.terminate(); + engine.wait(7000); + QFAIL("abortEvaluation doesn't work"); + } + +} +#endif + +#if 0 // ###FIXME: no QScriptEngine::isEvaluating +static QScriptValue myFunctionReturningIsEvaluating(QScriptContext *, QScriptEngine *eng) +{ + return QScriptValue(eng, eng->isEvaluating()); +} + +class EventReceiver4 : public QObject +{ +public: + EventReceiver4(QScriptEngine *eng) { + engine = eng; + wasEvaluating = false; + } + + bool event(QEvent *e) { + if (e->type() == QEvent::User + 1) { + wasEvaluating = engine->isEvaluating(); + } + return QObject::event(e); + } + + QScriptEngine *engine; + bool wasEvaluating; +}; + +void tst_QJSEngine::isEvaluating_notEvaluating() +{ + QScriptEngine eng; + + QVERIFY(!eng.isEvaluating()); + + eng.evaluate(""); + QVERIFY(!eng.isEvaluating()); + eng.evaluate("123"); + QVERIFY(!eng.isEvaluating()); + eng.evaluate("0 = 0"); + QVERIFY(!eng.isEvaluating()); +} + +void tst_QJSEngine::isEvaluating_fromNative() +{ + QScriptEngine eng; + QScriptValue fun = eng.newFunction(myFunctionReturningIsEvaluating); + eng.globalObject().setProperty("myFunctionReturningIsEvaluating", fun); + QScriptValue ret = eng.evaluate("myFunctionReturningIsEvaluating()"); + QVERIFY(ret.isBool()); + QVERIFY(ret.toBool()); + ret = fun.call(); + QVERIFY(ret.isBool()); + QVERIFY(ret.toBool()); + ret = myFunctionReturningIsEvaluating(eng.currentContext(), &eng); + QVERIFY(ret.isBool()); + QVERIFY(!ret.toBool()); +} + +void tst_QJSEngine::isEvaluating_fromEvent() +{ + QScriptEngine eng; + EventReceiver4 receiver(&eng); + QCoreApplication::postEvent(&receiver, new QEvent(QEvent::Type(QEvent::User+1))); + + QString script = QString::fromLatin1( + "var end = Number(new Date()) + 1000;" + "var x = 0;" + "while (Number(new Date()) < end) {" + " ++x;" + "}"); + + eng.setProcessEventsInterval(100); + eng.evaluate(script); + QVERIFY(receiver.wasEvaluating); +} +#endif + +static QtMsgType theMessageType; +static QString theMessage; + +static void myMsgHandler(QtMsgType type, const char *msg) +{ + theMessageType = type; + theMessage = QString::fromLatin1(msg); +} + +#if 0 +void tst_QJSEngine::printFunctionWithCustomHandler() +{ + // The built-in print() function passes the output to Qt's message + // handler. By installing a custom message handler, the output can be + // redirected without changing the print() function itself. + // This behavior is not documented. + QJSEngine eng; + QtMsgHandler oldHandler = qInstallMsgHandler(myMsgHandler); + QVERIFY(eng.globalObject().property("print").isCallable()); + + theMessageType = QtSystemMsg; + QVERIFY(theMessage.isEmpty()); + QVERIFY(eng.evaluate("print('test')").isUndefined()); + QCOMPARE(theMessageType, QtDebugMsg); + QCOMPARE(theMessage, QString::fromLatin1("test")); + + theMessageType = QtSystemMsg; + theMessage.clear(); + QVERIFY(eng.evaluate("print(3, true, 'little pigs')").isUndefined()); + QCOMPARE(theMessageType, QtDebugMsg); + QCOMPARE(theMessage, QString::fromLatin1("3 true little pigs")); + + qInstallMsgHandler(oldHandler); +} + +void tst_QJSEngine::printThrowsException() +{ + // If an argument to print() causes an exception to be thrown when + // it's converted to a string, print() should propagate the exception. + QJSEngine eng; + QJSValue ret = eng.evaluate("print({ toString: function() { throw 'foo'; } });"); + QVERIFY(eng.hasUncaughtException()); + QVERIFY(ret.strictlyEquals(eng.toScriptValue(QLatin1String("foo")))); +} +#endif + +void tst_QJSEngine::errorConstructors() +{ + QJSEngine eng; + QStringList prefixes; + prefixes << "" << "Eval" << "Range" << "Reference" << "Syntax" << "Type" << "URI"; + for (int x = 0; x < 3; ++x) { + for (int i = 0; i < prefixes.size(); ++i) { + QString name = prefixes.at(i) + QLatin1String("Error"); + QString code = QString(i+1, QLatin1Char('\n')); + if (x == 0) + code += QLatin1String("throw "); + else if (x == 1) + code += QLatin1String("new "); + code += name + QLatin1String("()"); + QJSValue ret = eng.evaluate(code); + QVERIFY(ret.isError()); + QCOMPARE(eng.hasUncaughtException(), x == 0); + eng.clearExceptions(); + QVERIFY(ret.toString().startsWith(name)); + //QTBUG-6138: JSC doesn't assign lineNumber when errors are not thrown + QEXPECT_FAIL("", "we have no more lineNumber property ", Continue); + QCOMPARE(ret.property("lineNumber").toInt(), i+2); + } + } +} + +void tst_QJSEngine::argumentsProperty_globalContext() +{ + QJSEngine eng; + { + // Unlike function calls, the global context doesn't have an + // arguments property. + QJSValue ret = eng.evaluate("arguments"); + QVERIFY(ret.isError()); + QVERIFY(ret.toString().contains(QString::fromLatin1("ReferenceError"))); + } + eng.evaluate("arguments = 10"); + { + QJSValue ret = eng.evaluate("arguments"); + QVERIFY(ret.isNumber()); + QCOMPARE(ret.toInt(), 10); + } + QVERIFY(eng.evaluate("delete arguments").toBool()); + QVERIFY(eng.globalObject().property("arguments").isUndefined()); +} + +void tst_QJSEngine::argumentsProperty_JS() +{ + { + QJSEngine eng; + eng.evaluate("o = { arguments: 123 }"); + QJSValue ret = eng.evaluate("with (o) { arguments; }"); + QVERIFY(ret.isNumber()); + QCOMPARE(ret.toInt(), 123); + } + { + QJSEngine eng; + QVERIFY(eng.globalObject().property("arguments").isUndefined()); + // This is testing ECMA-262 compliance. In function calls, "arguments" + // appears like a local variable, and it can be replaced. + QJSValue ret = eng.evaluate("(function() { arguments = 456; return arguments; })()"); + QVERIFY(ret.isNumber()); + QCOMPARE(ret.toInt(), 456); + QVERIFY(eng.globalObject().property("arguments").isUndefined()); + } +} + +#if 0 // ###FIXME: no QScriptContext API +static QScriptValue argumentsProperty_fun(QScriptContext *, QScriptEngine *eng) +{ + // Since evaluate() is done in the current context, "arguments" should + // refer to currentContext()->argumentsObject(). + // This is for consistency with the built-in JS eval() function. + eng->evaluate("var a = arguments[0];"); + eng->evaluate("arguments[0] = 200;"); + return eng->evaluate("a + arguments[0]"); +} + +void tst_QJSEngine::argumentsProperty_evaluateInNativeFunction() +{ + QScriptEngine eng; + QScriptValue fun = eng.newFunction(argumentsProperty_fun); + eng.globalObject().setProperty("fun", eng.newFunction(argumentsProperty_fun)); + QScriptValue result = eng.evaluate("fun(18)"); + QVERIFY(result.isNumber()); + QCOMPARE(result.toInt(), 200+18); +} +#endif + +void tst_QJSEngine::jsNumberClass() +{ + // See ECMA-262 Section 15.7, "Number Objects". + + QJSEngine eng; + + QJSValue ctor = eng.globalObject().property("Number"); + QVERIFY(ctor.property("length").isNumber()); + QCOMPARE(ctor.property("length").toNumber(), qreal(1)); + QJSValue proto = ctor.property("prototype"); + QVERIFY(proto.isObject()); + { + QVERIFY(ctor.property("MAX_VALUE").isNumber()); + QVERIFY(ctor.property("MIN_VALUE").isNumber()); + QVERIFY(ctor.property("NaN").isNumber()); + QVERIFY(ctor.property("NEGATIVE_INFINITY").isNumber()); + QVERIFY(ctor.property("POSITIVE_INFINITY").isNumber()); + } + QCOMPARE(proto.toNumber(), qreal(0)); + QVERIFY(proto.property("constructor").strictlyEquals(ctor)); + + { + QJSValue ret = eng.evaluate("Number()"); + QVERIFY(ret.isNumber()); + QCOMPARE(ret.toNumber(), qreal(0)); + } + { + QJSValue ret = eng.evaluate("Number(123)"); + QVERIFY(ret.isNumber()); + QCOMPARE(ret.toNumber(), qreal(123)); + } + { + QJSValue ret = eng.evaluate("Number('456')"); + QVERIFY(ret.isNumber()); + QCOMPARE(ret.toNumber(), qreal(456)); + } + { + QJSValue ret = eng.evaluate("new Number()"); + QVERIFY(!ret.isNumber()); + QVERIFY(ret.isObject()); + QCOMPARE(ret.toNumber(), qreal(0)); + } + { + QJSValue ret = eng.evaluate("new Number(123)"); + QVERIFY(!ret.isNumber()); + QVERIFY(ret.isObject()); + QCOMPARE(ret.toNumber(), qreal(123)); + } + { + QJSValue ret = eng.evaluate("new Number('456')"); + QVERIFY(!ret.isNumber()); + QVERIFY(ret.isObject()); + QCOMPARE(ret.toNumber(), qreal(456)); + } + + QVERIFY(proto.property("toString").isCallable()); + { + QJSValue ret = eng.evaluate("new Number(123).toString()"); + QVERIFY(ret.isString()); + QCOMPARE(ret.toString(), QString::fromLatin1("123")); + } + { + QJSValue ret = eng.evaluate("new Number(123).toString(8)"); + QVERIFY(ret.isString()); + QCOMPARE(ret.toString(), QString::fromLatin1("173")); + } + { + QJSValue ret = eng.evaluate("new Number(123).toString(16)"); + QVERIFY(ret.isString()); + QCOMPARE(ret.toString(), QString::fromLatin1("7b")); + } + QVERIFY(proto.property("toLocaleString").isCallable()); + { + QJSValue ret = eng.evaluate("new Number(123).toLocaleString()"); + QVERIFY(ret.isString()); + QCOMPARE(ret.toString(), QString::fromLatin1("123")); + } + QVERIFY(proto.property("valueOf").isCallable()); + { + QJSValue ret = eng.evaluate("new Number(123).valueOf()"); + QVERIFY(ret.isNumber()); + QCOMPARE(ret.toNumber(), qreal(123)); + } + QVERIFY(proto.property("toExponential").isCallable()); + { + QJSValue ret = eng.evaluate("new Number(123).toExponential()"); + QVERIFY(ret.isString()); + QCOMPARE(ret.toString(), QString::fromLatin1("1.23e+2")); + } + QVERIFY(proto.property("toFixed").isCallable()); + { + QJSValue ret = eng.evaluate("new Number(123).toFixed()"); + QVERIFY(ret.isString()); + QCOMPARE(ret.toString(), QString::fromLatin1("123")); + } + QVERIFY(proto.property("toPrecision").isCallable()); + { + QJSValue ret = eng.evaluate("new Number(123).toPrecision()"); + QVERIFY(ret.isString()); + QCOMPARE(ret.toString(), QString::fromLatin1("123")); + } +} + +void tst_QJSEngine::jsForInStatement_simple() +{ + QJSEngine eng; + { + QJSValue ret = eng.evaluate("o = { }; r = []; for (var p in o) r[r.length] = p; r"); + QStringList lst = qjsvalue_cast(ret); + QVERIFY(lst.isEmpty()); + } + { + QJSValue ret = eng.evaluate("o = { p: 123 }; r = [];" + "for (var p in o) r[r.length] = p; r"); + QStringList lst = qjsvalue_cast(ret); + QCOMPARE(lst.size(), 1); + QCOMPARE(lst.at(0), QString::fromLatin1("p")); + } + { + QJSValue ret = eng.evaluate("o = { p: 123, q: 456 }; r = [];" + "for (var p in o) r[r.length] = p; r"); + QStringList lst = qjsvalue_cast(ret); + QCOMPARE(lst.size(), 2); + QCOMPARE(lst.at(0), QString::fromLatin1("p")); + QCOMPARE(lst.at(1), QString::fromLatin1("q")); + } +} + +void tst_QJSEngine::jsForInStatement_prototypeProperties() +{ + QJSEngine eng; + { + QJSValue ret = eng.evaluate("o = { }; o.__proto__ = { p: 123 }; r = [];" + "for (var p in o) r[r.length] = p; r"); + QStringList lst = qjsvalue_cast(ret); + QCOMPARE(lst.size(), 1); + QCOMPARE(lst.at(0), QString::fromLatin1("p")); + } + { + QJSValue ret = eng.evaluate("o = { p: 123 }; o.__proto__ = { q: 456 }; r = [];" + "for (var p in o) r[r.length] = p; r"); + QStringList lst = qjsvalue_cast(ret); + QCOMPARE(lst.size(), 2); + QCOMPARE(lst.at(0), QString::fromLatin1("p")); + QCOMPARE(lst.at(1), QString::fromLatin1("q")); + } + { + // shadowed property + QJSValue ret = eng.evaluate("o = { p: 123 }; o.__proto__ = { p: 456 }; r = [];" + "for (var p in o) r[r.length] = p; r"); + QStringList lst = qjsvalue_cast(ret); + QCOMPARE(lst.size(), 1); + QCOMPARE(lst.at(0), QString::fromLatin1("p")); + } + +} + +void tst_QJSEngine::jsForInStatement_mutateWhileIterating() +{ + QJSEngine eng; + // deleting property during enumeration + { + QJSValue ret = eng.evaluate("o = { p: 123 }; r = [];" + "for (var p in o) { r[r.length] = p; delete r[p]; } r"); + QStringList lst = qjsvalue_cast(ret); + QCOMPARE(lst.size(), 1); + QCOMPARE(lst.at(0), QString::fromLatin1("p")); + } + { + QJSValue ret = eng.evaluate("o = { p: 123, q: 456 }; r = [];" + "for (var p in o) { r[r.length] = p; delete o.q; } r"); + QStringList lst = qjsvalue_cast(ret); + QCOMPARE(lst.size(), 1); + QCOMPARE(lst.at(0), QString::fromLatin1("p")); + } + + // adding property during enumeration + { + QJSValue ret = eng.evaluate("o = { p: 123 }; r = [];" + "for (var p in o) { r[r.length] = p; o.q = 456; } r"); + QStringList lst = qjsvalue_cast(ret); + QCOMPARE(lst.size(), 1); + QCOMPARE(lst.at(0), QString::fromLatin1("p")); + } + +} + +void tst_QJSEngine::jsForInStatement_arrays() +{ + QJSEngine eng; + { + QJSValue ret = eng.evaluate("a = [123, 456]; r = [];" + "for (var p in a) r[r.length] = p; r"); + QStringList lst = qjsvalue_cast(ret); + QCOMPARE(lst.size(), 2); + QCOMPARE(lst.at(0), QString::fromLatin1("0")); + QCOMPARE(lst.at(1), QString::fromLatin1("1")); + } + { + QJSValue ret = eng.evaluate("a = [123, 456]; a.foo = 'bar'; r = [];" + "for (var p in a) r[r.length] = p; r"); + QStringList lst = qjsvalue_cast(ret); + QCOMPARE(lst.size(), 3); + QCOMPARE(lst.at(0), QString::fromLatin1("0")); + QCOMPARE(lst.at(1), QString::fromLatin1("1")); + QCOMPARE(lst.at(2), QString::fromLatin1("foo")); + } + { + QJSValue ret = eng.evaluate("a = [123, 456]; a.foo = 'bar';" + "b = [111, 222, 333]; b.bar = 'baz';" + "a.__proto__ = b; r = [];" + "for (var p in a) r[r.length] = p; r"); + QStringList lst = qjsvalue_cast(ret); + QCOMPARE(lst.size(), 5); + QCOMPARE(lst.at(0), QString::fromLatin1("0")); + QCOMPARE(lst.at(1), QString::fromLatin1("1")); + QCOMPARE(lst.at(2), QString::fromLatin1("foo")); + QCOMPARE(lst.at(3), QString::fromLatin1("2")); + QCOMPARE(lst.at(4), QString::fromLatin1("bar")); + } +} + +void tst_QJSEngine::jsForInStatement_nullAndUndefined() +{ + QJSEngine eng; + { + QJSValue ret = eng.evaluate("r = true; for (var p in undefined) r = false; r"); + QVERIFY(ret.isBool()); + QVERIFY(ret.toBool()); + } + { + QJSValue ret = eng.evaluate("r = true; for (var p in null) r = false; r"); + QVERIFY(ret.isBool()); + QVERIFY(ret.toBool()); + } +} + +void tst_QJSEngine::jsFunctionDeclarationAsStatement() +{ + // ECMA-262 does not allow function declarations to be used as statements, + // but several popular implementations (including JSC) do. See the NOTE + // at the beginning of chapter 12 in ECMA-262 5th edition, where it's + // recommended that implementations either disallow this usage or issue + // a warning. + // Since we had a bug report long ago about QtScript not supporting this + // "feature" (and thus deviating from other implementations), we still + // check this behavior. + + QJSEngine eng; + QVERIFY(eng.globalObject().property("bar").isUndefined()); + eng.evaluate("function foo(arg) {\n" + " if (arg == 'bar')\n" + " function bar() { return 'bar'; }\n" + " else\n" + " function baz() { return 'baz'; }\n" + " return (arg == 'bar') ? bar : baz;\n" + "}"); + QVERIFY(eng.globalObject().property("bar").isUndefined()); + QVERIFY(eng.globalObject().property("baz").isUndefined()); + QVERIFY(eng.evaluate("foo").isCallable()); + { + QJSValue ret = eng.evaluate("foo('bar')"); + QVERIFY(ret.isCallable()); + QJSValue ret2 = ret.call(); + QCOMPARE(ret2.toString(), QString::fromLatin1("bar")); + QVERIFY(eng.globalObject().property("bar").isUndefined()); + QVERIFY(eng.globalObject().property("baz").isUndefined()); + } + { + QJSValue ret = eng.evaluate("foo('baz')"); + QVERIFY(ret.isCallable()); + QJSValue ret2 = ret.call(); + QCOMPARE(ret2.toString(), QString::fromLatin1("baz")); + QVERIFY(eng.globalObject().property("bar").isUndefined()); + QVERIFY(eng.globalObject().property("baz").isUndefined()); + } +} + +void tst_QJSEngine::stringObjects() +{ + // See ECMA-262 Section 15.5, "String Objects". + + QJSEngine eng; + QString str("ciao"); + // in C++ + { + QJSValue obj = eng.evaluate(QString::fromLatin1("new String('%0')").arg(str)); + QCOMPARE(obj.property("length").toInt(), str.length()); + for (int i = 0; i < str.length(); ++i) { + QString pname = QString::number(i); + QVERIFY(obj.property(pname).isString()); + QCOMPARE(obj.property(pname).toString(), QString(str.at(i))); + QEXPECT_FAIL("", "FIXME: This is V8 issue 862. ECMA script standard 15.5.5.2 compliance.", Continue); + QVERIFY(!obj.deleteProperty(pname)); + obj.setProperty(pname, 123); + QVERIFY(obj.property(pname).isString()); + QCOMPARE(obj.property(pname).toString(), QString(str.at(i))); + } + QVERIFY(obj.property("-1").isUndefined()); + QVERIFY(obj.property(QString::number(str.length())).isUndefined()); + + QJSValue val = eng.toScriptValue(123); + obj.setProperty("-1", val); + QVERIFY(obj.property("-1").strictlyEquals(val)); + obj.setProperty("100", val); + QVERIFY(obj.property("100").strictlyEquals(val)); + } + + { + QJSValue ret = eng.evaluate("s = new String('ciao'); r = []; for (var p in s) r.push(p); r"); + QVERIFY(ret.isArray()); + QStringList lst = qjsvalue_cast(ret); + QCOMPARE(lst.size(), str.length()); + for (int i = 0; i < str.length(); ++i) + QCOMPARE(lst.at(i), QString::number(i)); + + QJSValue ret2 = eng.evaluate("s[0] = 123; s[0]"); + QVERIFY(ret2.isString()); + QCOMPARE(ret2.toString().length(), 1); + QCOMPARE(ret2.toString().at(0), str.at(0)); + + QJSValue ret3 = eng.evaluate("s[-1] = 123; s[-1]"); + QVERIFY(ret3.isNumber()); + QCOMPARE(ret3.toInt(), 123); + + QJSValue ret4 = eng.evaluate("s[s.length] = 456; s[s.length]"); + QVERIFY(ret4.isNumber()); + QCOMPARE(ret4.toInt(), 456); + + QJSValue ret5 = eng.evaluate("delete s[0]"); + QVERIFY(ret5.isBool()); + QEXPECT_FAIL("", "FIXME: This is V8 bug, please report it! ECMA script standard 15.5.5.2", Abort); + QVERIFY(!ret5.toBool()); + + QJSValue ret6 = eng.evaluate("delete s[-1]"); + QVERIFY(ret6.isBool()); + QVERIFY(ret6.toBool()); + + QJSValue ret7 = eng.evaluate("delete s[s.length]"); + QVERIFY(ret7.isBool()); + QVERIFY(ret7.toBool()); + } +} + +void tst_QJSEngine::jsStringPrototypeReplaceBugs() +{ + QJSEngine eng; + // task 212440 + { + QJSValue ret = eng.evaluate("replace_args = []; \"a a a\".replace(/(a)/g, function() { replace_args.push(arguments); }); replace_args"); + QVERIFY(ret.isArray()); + int len = ret.property("length").toInt(); + QCOMPARE(len, 3); + for (int i = 0; i < len; ++i) { + QJSValue args = ret.property(i); + QCOMPARE(args.property("length").toInt(), 4); + QCOMPARE(args.property(0).toString(), QString::fromLatin1("a")); // matched string + QCOMPARE(args.property(1).toString(), QString::fromLatin1("a")); // capture + QVERIFY(args.property(2).isNumber()); + QCOMPARE(args.property(2).toInt(), i*2); // index of match + QCOMPARE(args.property(3).toString(), QString::fromLatin1("a a a")); + } + } + // task 212501 + { + QJSValue ret = eng.evaluate("\"foo\".replace(/a/g, function() {})"); + QVERIFY(ret.isString()); + QCOMPARE(ret.toString(), QString::fromLatin1("foo")); + } +} + +void tst_QJSEngine::getterSetterThisObject_global() +{ + { + QJSEngine eng; + // read + eng.evaluate("__defineGetter__('x', function() { return this; });"); + { + QJSValue ret = eng.evaluate("x"); + QVERIFY(ret.equals(eng.globalObject())); + } + { + QJSValue ret = eng.evaluate("(function() { return x; })()"); + QVERIFY(ret.equals(eng.globalObject())); + } + { + QJSValue ret = eng.evaluate("with (this) x"); + QVERIFY(ret.equals(eng.globalObject())); + } + { + QJSValue ret = eng.evaluate("with ({}) x"); + QVERIFY(ret.equals(eng.globalObject())); + } + { + QJSValue ret = eng.evaluate("(function() { with ({}) return x; })()"); + QVERIFY(ret.equals(eng.globalObject())); + } + // write + eng.evaluate("__defineSetter__('x', function() { return this; });"); + { + QJSValue ret = eng.evaluate("x = 'foo'"); + // SpiderMonkey says setter return value, JSC says RHS. + QVERIFY(ret.isString()); + QCOMPARE(ret.toString(), QString::fromLatin1("foo")); + } + { + QJSValue ret = eng.evaluate("(function() { return x = 'foo'; })()"); + // SpiderMonkey says setter return value, JSC says RHS. + QVERIFY(ret.isString()); + QCOMPARE(ret.toString(), QString::fromLatin1("foo")); + } + { + QJSValue ret = eng.evaluate("with (this) x = 'foo'"); + // SpiderMonkey says setter return value, JSC says RHS. + QVERIFY(ret.isString()); + QCOMPARE(ret.toString(), QString::fromLatin1("foo")); + } + { + QJSValue ret = eng.evaluate("with ({}) x = 'foo'"); + // SpiderMonkey says setter return value, JSC says RHS. + QVERIFY(ret.isString()); + QCOMPARE(ret.toString(), QString::fromLatin1("foo")); + } + { + QJSValue ret = eng.evaluate("(function() { with ({}) return x = 'foo'; })()"); + // SpiderMonkey says setter return value, JSC says RHS. + QVERIFY(ret.isString()); + QCOMPARE(ret.toString(), QString::fromLatin1("foo")); + } + } +} + +void tst_QJSEngine::getterSetterThisObject_plain() +{ + { + QJSEngine eng; + eng.evaluate("o = {}"); + // read + eng.evaluate("o.__defineGetter__('x', function() { return this; })"); + QVERIFY(eng.evaluate("o.x === o").toBool()); + QVERIFY(eng.evaluate("with (o) x").equals(eng.evaluate("o"))); + QVERIFY(eng.evaluate("(function() { with (o) return x; })() === o").toBool()); + eng.evaluate("q = {}; with (o) with (q) x").equals(eng.evaluate("o")); + // write + eng.evaluate("o.__defineSetter__('x', function() { return this; });"); + // SpiderMonkey says setter return value, JSC says RHS. + QVERIFY(eng.evaluate("(o.x = 'foo') === 'foo'").toBool()); + QVERIFY(eng.evaluate("with (o) x = 'foo'").equals("foo")); + QVERIFY(eng.evaluate("with (o) with (q) x = 'foo'").equals("foo")); + } +} + +void tst_QJSEngine::getterSetterThisObject_prototypeChain() +{ + { + QJSEngine eng; + eng.evaluate("o = {}; p = {}; o.__proto__ = p"); + // read + eng.evaluate("p.__defineGetter__('x', function() { return this; })"); + QVERIFY(eng.evaluate("o.x === o").toBool()); + QVERIFY(eng.evaluate("with (o) x").equals(eng.evaluate("o"))); + QVERIFY(eng.evaluate("(function() { with (o) return x; })() === o").toBool()); + eng.evaluate("q = {}; with (o) with (q) x").equals(eng.evaluate("o")); + eng.evaluate("with (q) with (o) x").equals(eng.evaluate("o")); + // write + eng.evaluate("o.__defineSetter__('x', function() { return this; });"); + // SpiderMonkey says setter return value, JSC says RHS. + QVERIFY(eng.evaluate("(o.x = 'foo') === 'foo'").toBool()); + QVERIFY(eng.evaluate("with (o) x = 'foo'").equals("foo")); + QVERIFY(eng.evaluate("with (o) with (q) x = 'foo'").equals("foo")); + } +} + +#if 0 // ###FIXME: no QScriptContext API +void tst_QJSEngine::getterSetterThisObject_activation() +{ + { + QScriptEngine eng; + QScriptContext *ctx = eng.pushContext(); + QVERIFY(ctx != 0); + QScriptValue act = ctx->activationObject(); + act.setProperty("act", act); + // read + eng.evaluate("act.__defineGetter__('x', function() { return this; })"); + QVERIFY(eng.evaluate("x === act").toBool()); + QEXPECT_FAIL("", "QTBUG-17605: Not possible to implement local variables as getter/setter properties", Abort); + QVERIFY(!eng.hasUncaughtException()); + QVERIFY(eng.evaluate("with (act) x").equals("foo")); + QVERIFY(eng.evaluate("(function() { with (act) return x; })() === act").toBool()); + eng.evaluate("q = {}; with (act) with (q) x").equals(eng.evaluate("act")); + eng.evaluate("with (q) with (act) x").equals(eng.evaluate("act")); + // write + eng.evaluate("act.__defineSetter__('x', function() { return this; });"); + QVERIFY(eng.evaluate("(x = 'foo') === 'foo'").toBool()); + QVERIFY(eng.evaluate("with (act) x = 'foo'").equals("foo")); + QVERIFY(eng.evaluate("with (act) with (q) x = 'foo'").equals("foo")); + eng.popContext(); + } +} +#endif + +void tst_QJSEngine::jsContinueInSwitch() +{ + // This is testing ECMA-262 compliance, not C++ API. + + QJSEngine eng; + // switch - continue + { + QJSValue ret = eng.evaluate("switch (1) { default: continue; }"); + QVERIFY(ret.isError()); + } + // for - switch - case - continue + { + QJSValue ret = eng.evaluate("j = 0; for (i = 0; i < 100000; ++i) {\n" + " switch (i) {\n" + " case 1: ++j; continue;\n" + " case 100: ++j; continue;\n" + " case 1000: ++j; continue;\n" + " }\n" + "}; j"); + QVERIFY(ret.isNumber()); + QCOMPARE(ret.toInt(), 3); + } + // for - switch - case - default - continue + { + QJSValue ret = eng.evaluate("j = 0; for (i = 0; i < 100000; ++i) {\n" + " switch (i) {\n" + " case 1: ++j; continue;\n" + " case 100: ++j; continue;\n" + " case 1000: ++j; continue;\n" + " default: if (i < 50000) break; else continue;\n" + " }\n" + "}; j"); + QVERIFY(ret.isNumber()); + QCOMPARE(ret.toInt(), 3); + } + // switch - for - continue + { + QJSValue ret = eng.evaluate("j = 123; switch (j) {\n" + " case 123:\n" + " for (i = 0; i < 100000; ++i) {\n" + " continue;\n" + " }\n" + "}; i\n"); + QVERIFY(ret.isNumber()); + QCOMPARE(ret.toInt(), 100000); + } + // switch - switch - continue + { + QJSValue ret = eng.evaluate("i = 1; switch (i) { default: switch (i) { case 1: continue; } }"); + QVERIFY(ret.isError()); + } + // for - switch - switch - continue + { + QJSValue ret = eng.evaluate("j = 0; for (i = 0; i < 100000; ++i) {\n" + " switch (i) {\n" + " case 1:\n" + " switch (i) {\n" + " case 1: ++j; continue;\n" + " }\n" + " }\n" + "}; j"); + QVERIFY(ret.isNumber()); + QCOMPARE(ret.toInt(), 1); + } + // switch - for - switch - continue + { + QJSValue ret = eng.evaluate("j = 123; switch (j) {\n" + " case 123:\n" + " for (i = 0; i < 100000; ++i) {\n" + " switch (i) {\n" + " case 1:\n" + " ++j; continue;\n" + " }\n" + " }\n" + "}; i\n"); + QVERIFY(ret.isNumber()); + QCOMPARE(ret.toInt(), 100000); + } +} + +void tst_QJSEngine::jsShadowReadOnlyPrototypeProperty() +{ + // SpiderMonkey has different behavior than JSC and V8; it disallows + // creating a property on the instance if there's a property with the + // same name in the prototype, and that property is read-only. We + // adopted that behavior in the old (4.5) QtScript back-end, but it + // just seems weird -- and non-compliant. Adopt the JSC behavior instead. + QJSEngine eng; + QVERIFY(eng.evaluate("o = {}; o.__proto__ = parseInt; o.length").isNumber()); + QCOMPARE(eng.evaluate("o.length = 123; o.length").toInt(), 123); + QVERIFY(eng.evaluate("o.hasOwnProperty('length')").toBool()); +} + +void tst_QJSEngine::jsReservedWords_data() +{ + QTest::addColumn("word"); + QTest::newRow("break") << QString("break"); + QTest::newRow("case") << QString("case"); + QTest::newRow("catch") << QString("catch"); + QTest::newRow("continue") << QString("continue"); + QTest::newRow("default") << QString("default"); + QTest::newRow("delete") << QString("delete"); + QTest::newRow("do") << QString("do"); + QTest::newRow("else") << QString("else"); + QTest::newRow("false") << QString("false"); + QTest::newRow("finally") << QString("finally"); + QTest::newRow("for") << QString("for"); + QTest::newRow("function") << QString("function"); + QTest::newRow("if") << QString("if"); + QTest::newRow("in") << QString("in"); + QTest::newRow("instanceof") << QString("instanceof"); + QTest::newRow("new") << QString("new"); + QTest::newRow("null") << QString("null"); + QTest::newRow("return") << QString("return"); + QTest::newRow("switch") << QString("switch"); + QTest::newRow("this") << QString("this"); + QTest::newRow("throw") << QString("throw"); + QTest::newRow("true") << QString("true"); + QTest::newRow("try") << QString("try"); + QTest::newRow("typeof") << QString("typeof"); + QTest::newRow("var") << QString("var"); + QTest::newRow("void") << QString("void"); + QTest::newRow("while") << QString("while"); + QTest::newRow("with") << QString("with"); +} + +void tst_QJSEngine::jsReservedWords() +{ + // See ECMA-262 Section 7.6.1, "Reserved Words". + // We prefer that the implementation is less strict than the spec; e.g. + // it's good to allow reserved words as identifiers in object literals, + // and when accessing properties using dot notation. + + QFETCH(QString, word); + { + QJSEngine eng; + QJSValue ret = eng.evaluate(word + " = 123"); + QVERIFY(ret.isError()); + QString str = ret.toString(); + QVERIFY(str.startsWith("SyntaxError") || str.startsWith("ReferenceError")); + } + { + QJSEngine eng; + QJSValue ret = eng.evaluate("var " + word + " = 123"); + QVERIFY(ret.isError()); + QVERIFY(ret.toString().startsWith("SyntaxError")); + } + { + QJSEngine eng; + QJSValue ret = eng.evaluate("o = {}; o." + word + " = 123"); + // in the old back-end, in SpiderMonkey and in v8, this is allowed, but not in JSC + QVERIFY(!ret.isError()); + QVERIFY(ret.strictlyEquals(eng.evaluate("o." + word))); + } + { + QJSEngine eng; + QJSValue ret = eng.evaluate("o = { " + word + ": 123 }"); + // in the old back-end, in SpiderMonkey and in v8, this is allowed, but not in JSC + QVERIFY(!ret.isError()); + QVERIFY(ret.property(word).isNumber()); + } + { + // SpiderMonkey allows this, but we don't + QJSEngine eng; + QJSValue ret = eng.evaluate("function " + word + "() {}"); + QVERIFY(ret.isError()); + QVERIFY(ret.toString().startsWith("SyntaxError")); + } +} + +void tst_QJSEngine::jsFutureReservedWords_data() +{ + QTest::addColumn("word"); + QTest::addColumn("allowed"); + QTest::newRow("abstract") << QString("abstract") << true; + QTest::newRow("boolean") << QString("boolean") << true; + QTest::newRow("byte") << QString("byte") << true; + QTest::newRow("char") << QString("char") << true; + QTest::newRow("class") << QString("class") << false; + QTest::newRow("const") << QString("const") << false; + QTest::newRow("debugger") << QString("debugger") << false; + QTest::newRow("double") << QString("double") << true; + QTest::newRow("enum") << QString("enum") << false; + QTest::newRow("export") << QString("export") << false; + QTest::newRow("extends") << QString("extends") << false; + QTest::newRow("final") << QString("final") << true; + QTest::newRow("float") << QString("float") << true; + QTest::newRow("goto") << QString("goto") << true; + QTest::newRow("implements") << QString("implements") << true; + QTest::newRow("import") << QString("import") << false; + QTest::newRow("int") << QString("int") << true; + QTest::newRow("interface") << QString("interface") << true; + QTest::newRow("long") << QString("long") << true; + QTest::newRow("native") << QString("native") << true; + QTest::newRow("package") << QString("package") << true; + QTest::newRow("private") << QString("private") << true; + QTest::newRow("protected") << QString("protected") << true; + QTest::newRow("public") << QString("public") << true; + QTest::newRow("short") << QString("short") << true; + QTest::newRow("static") << QString("static") << true; + QTest::newRow("super") << QString("super") << false; + QTest::newRow("synchronized") << QString("synchronized") << true; + QTest::newRow("throws") << QString("throws") << true; + QTest::newRow("transient") << QString("transient") << true; + QTest::newRow("volatile") << QString("volatile") << true; +} + +void tst_QJSEngine::jsFutureReservedWords() +{ + QSKIP("Fails"); + // See ECMA-262 Section 7.6.1.2, "Future Reserved Words". + // In real-world implementations, most of these words are + // actually allowed as normal identifiers. + + QFETCH(QString, word); + QFETCH(bool, allowed); + { + QJSEngine eng; + QJSValue ret = eng.evaluate(word + " = 123"); + QCOMPARE(!ret.isError(), allowed); + } + { + QJSEngine eng; + QJSValue ret = eng.evaluate("var " + word + " = 123"); + QCOMPARE(!ret.isError(), allowed); + } + { + // this should probably be allowed (see task 162567) + QJSEngine eng; + QJSValue ret = eng.evaluate("o = {}; o." + word + " = 123"); + QCOMPARE(ret.isNumber(), allowed); + QCOMPARE(!ret.isError(), allowed); + } + { + // this should probably be allowed (see task 162567) + QJSEngine eng; + QJSValue ret = eng.evaluate("o = { " + word + ": 123 }"); + QCOMPARE(!ret.isError(), allowed); + } +} + +void tst_QJSEngine::jsThrowInsideWithStatement() +{ + // This is testing ECMA-262 compliance, not C++ API. + + // task 209988 + QJSEngine eng; + { + QJSValue ret = eng.evaluate( + "try {" + " o = { bad : \"bug\" };" + " with (o) {" + " throw 123;" + " }" + "} catch (e) {" + " bad;" + "}"); + QVERIFY(ret.isError()); + QVERIFY(ret.toString().contains(QString::fromLatin1("ReferenceError"))); + } + { + QJSValue ret = eng.evaluate( + "try {" + " o = { bad : \"bug\" };" + " with (o) {" + " throw 123;" + " }" + "} finally {" + " bad;" + "}"); + QVERIFY(ret.isError()); + QVERIFY(ret.toString().contains(QString::fromLatin1("ReferenceError"))); + } + { + eng.clearExceptions(); + QJSValue ret = eng.evaluate( + "o = { bug : \"no bug\" };" + "with (o) {" + " try {" + " throw 123;" + " } finally {" + " bug;" + " }" + "}"); + QVERIFY(ret.isNumber()); + QCOMPARE(ret.toInt(), 123); + QVERIFY(eng.hasUncaughtException()); + } + { + eng.clearExceptions(); + QJSValue ret = eng.evaluate( + "o = { bug : \"no bug\" };" + "with (o) {" + " throw 123;" + "}"); + QVERIFY(ret.isNumber()); + QJSValue ret2 = eng.evaluate("bug"); + QVERIFY(ret2.isError()); + QVERIFY(ret2.toString().contains(QString::fromLatin1("ReferenceError"))); + } +} + +#if 0 // ###FIXME: No QScriptEngineAgent API +class TestAgent : public QScriptEngineAgent +{ +public: + TestAgent(QScriptEngine *engine) : QScriptEngineAgent(engine) {} +}; + +void tst_QJSEngine::getSetAgent_ownership() +{ + // engine deleted before agent --> agent deleted too + QScriptEngine *eng = new QScriptEngine; + QCOMPARE(eng->agent(), (QScriptEngineAgent*)0); + TestAgent *agent = new TestAgent(eng); + eng->setAgent(agent); + QCOMPARE(eng->agent(), (QScriptEngineAgent*)agent); + eng->setAgent(0); // the engine maintains ownership of the old agent + QCOMPARE(eng->agent(), (QScriptEngineAgent*)0); + delete eng; +} + +void tst_QJSEngine::getSetAgent_deleteAgent() +{ + // agent deleted before engine --> engine's agent should become 0 + QScriptEngine *eng = new QScriptEngine; + TestAgent *agent = new TestAgent(eng); + eng->setAgent(agent); + QCOMPARE(eng->agent(), (QScriptEngineAgent*)agent); + delete agent; + QCOMPARE(eng->agent(), (QScriptEngineAgent*)0); + eng->evaluate("(function(){ return 123; })()"); + delete eng; +} + +void tst_QJSEngine::getSetAgent_differentEngine() +{ + QScriptEngine eng; + QScriptEngine eng2; + TestAgent *agent = new TestAgent(&eng); + QTest::ignoreMessage(QtWarningMsg, "QScriptEngine::setAgent(): cannot set agent belonging to different engine"); + eng2.setAgent(agent); + QCOMPARE(eng2.agent(), (QScriptEngineAgent*)0); +} +#endif + +#if 0 // ###FIXME: No QScriptString API +void tst_QJSEngine::reentrancy_stringHandles() +{ + QScriptEngine eng1; + QScriptEngine eng2; + QScriptString s1 = eng1.toStringHandle("foo"); + QScriptString s2 = eng2.toStringHandle("foo"); + QVERIFY(s1 != s2); +} +#endif + +#if 0 // ###FIXME: No processEventsInterval API +void tst_QJSEngine::reentrancy_processEventsInterval() +{ + QScriptEngine eng1; + QScriptEngine eng2; + eng1.setProcessEventsInterval(123); + QCOMPARE(eng2.processEventsInterval(), -1); + eng2.setProcessEventsInterval(456); + QCOMPARE(eng1.processEventsInterval(), 123); +} +#endif + +#if 0 // FIXME: No support for custom types +void tst_QJSEngine::reentrancy_typeConversion() +{ + QScriptEngine eng1; + QScriptEngine eng2; + qScriptRegisterMetaType(&eng1, fooToScriptValue, fooFromScriptValue); + Foo foo; + foo.x = 12; + foo.y = 34; + { + QScriptValue fooVal = qScriptValueFromValue(&eng1, foo); + QVERIFY(fooVal.isObject()); + QVERIFY(!fooVal.isVariant()); + QCOMPARE(fooVal.property("x").toInt(), 12); + QCOMPARE(fooVal.property("y").toInt(), 34); + fooVal.setProperty("x", 56); + fooVal.setProperty("y", 78); + + Foo foo2 = eng.fromScriptValue(fooVal); + QCOMPARE(foo2.x, 56); + QCOMPARE(foo2.y, 78); + } + { + QScriptValue fooVal = qScriptValueFromValue(&eng2, foo); + QVERIFY(fooVal.isVariant()); + + Foo foo2 = eng.fromScriptValue(fooVal); + QCOMPARE(foo2.x, 12); + QCOMPARE(foo2.y, 34); + } + QVERIFY(eng1.defaultPrototype(qMetaTypeId()).isUndefined()); + QVERIFY(eng2.defaultPrototype(qMetaTypeId()).isUndefined()); + QScriptValue proto1 = eng1.newObject(); + eng1.setDefaultPrototype(qMetaTypeId(), proto1); + QVERIFY(eng2.defaultPrototype(qMetaTypeId()).isUndefined()); + QScriptValue proto2 = eng2.newObject(); + eng2.setDefaultPrototype(qMetaTypeId(), proto2); + QVERIFY(!eng2.defaultPrototype(qMetaTypeId()).isUndefined()); + QVERIFY(eng1.defaultPrototype(qMetaTypeId()).strictlyEquals(proto1)); +} +#endif + +void tst_QJSEngine::reentrancy_globalObjectProperties() +{ + QJSEngine eng1; + QJSEngine eng2; + QVERIFY(eng2.globalObject().property("a").isUndefined()); + eng1.evaluate("a = 10"); + QVERIFY(eng1.globalObject().property("a").isNumber()); + QVERIFY(eng2.globalObject().property("a").isUndefined()); + eng2.evaluate("a = 20"); + QVERIFY(eng2.globalObject().property("a").isNumber()); + QCOMPARE(eng1.globalObject().property("a").toInt(), 10); +} + +void tst_QJSEngine::reentrancy_Array() +{ + // weird bug with JSC backend + { + QJSEngine eng; + QCOMPARE(eng.evaluate("Array()").toString(), QString()); + eng.evaluate("Array.prototype.toString"); + QCOMPARE(eng.evaluate("Array()").toString(), QString()); + } + { + QJSEngine eng; + QCOMPARE(eng.evaluate("Array()").toString(), QString()); + } +} + +void tst_QJSEngine::reentrancy_objectCreation() +{ + QJSEngine eng1; + QJSEngine eng2; + { + QDateTime dt = QDateTime::currentDateTime(); + QJSValue d1 = eng1.toScriptValue(dt); + QJSValue d2 = eng2.toScriptValue(dt); + QCOMPARE(d1.toDateTime(), d2.toDateTime()); + QCOMPARE(d2.toDateTime(), d1.toDateTime()); + } + { + QJSValue r1 = eng1.evaluate("new RegExp('foo', 'gim')"); + QJSValue r2 = eng2.evaluate("new RegExp('foo', 'gim')"); + QCOMPARE(qjsvalue_cast(r1), qjsvalue_cast(r2)); + QCOMPARE(qjsvalue_cast(r2), qjsvalue_cast(r1)); + } + { + QJSValue o1 = eng1.newQObject(this); + QJSValue o2 = eng2.newQObject(this); + QCOMPARE(o1.toQObject(), o2.toQObject()); + QCOMPARE(o2.toQObject(), o1.toQObject()); + } +#if 0 // ###FIXME: No QScriptEngine::newQMetaObject API + { + QScriptValue mo1 = eng1.newQMetaObject(&staticMetaObject); + QScriptValue mo2 = eng2.newQMetaObject(&staticMetaObject); + QCOMPARE(mo1.toQMetaObject(), mo2.toQMetaObject()); + QCOMPARE(mo2.toQMetaObject(), mo1.toQMetaObject()); + } +#endif +} + +void tst_QJSEngine::jsIncDecNonObjectProperty() +{ + // This is testing ECMA-262 compliance, not C++ API. + + QJSEngine eng; + { + QJSValue ret = eng.evaluate("var a; a.n++"); + QVERIFY(ret.isError()); + QVERIFY(ret.toString().contains(QString::fromLatin1("TypeError"))); + } + { + QJSValue ret = eng.evaluate("var a; a.n--"); + QVERIFY(ret.isError()); + QVERIFY(ret.toString().contains(QString::fromLatin1("TypeError"))); + } + { + QJSValue ret = eng.evaluate("var a = null; a.n++"); + QVERIFY(ret.isError()); + QVERIFY(ret.toString().contains(QString::fromLatin1("TypeError"))); + } + { + QJSValue ret = eng.evaluate("var a = null; a.n--"); + QVERIFY(ret.isError()); + QVERIFY(ret.toString().contains(QString::fromLatin1("TypeError"))); + } + { + QJSValue ret = eng.evaluate("var a; ++a.n"); + QVERIFY(ret.isError()); + QVERIFY(ret.toString().contains(QString::fromLatin1("TypeError"))); + } + { + QJSValue ret = eng.evaluate("var a; --a.n"); + QVERIFY(ret.isError()); + QVERIFY(ret.toString().contains(QString::fromLatin1("TypeError"))); + } + { + QJSValue ret = eng.evaluate("var a; a.n += 1"); + QVERIFY(ret.isError()); + QVERIFY(ret.toString().contains(QString::fromLatin1("TypeError"))); + } + { + QJSValue ret = eng.evaluate("var a; a.n -= 1"); + QVERIFY(ret.isError()); + QVERIFY(ret.toString().contains(QString::fromLatin1("TypeError"))); + } + { + QJSValue ret = eng.evaluate("var a = 'ciao'; a.length++"); + QVERIFY(ret.isNumber()); + QCOMPARE(ret.toInt(), 4); + } + { + QJSValue ret = eng.evaluate("var a = 'ciao'; a.length--"); + QVERIFY(ret.isNumber()); + QCOMPARE(ret.toInt(), 4); + } + { + QJSValue ret = eng.evaluate("var a = 'ciao'; ++a.length"); + QVERIFY(ret.isNumber()); + QCOMPARE(ret.toInt(), 5); + } + { + QJSValue ret = eng.evaluate("var a = 'ciao'; --a.length"); + QVERIFY(ret.isNumber()); + QCOMPARE(ret.toInt(), 3); + } +} + +#if 0 // ###FIXME: no installTranslatorFunctions API +void tst_QJSEngine::installTranslatorFunctions() +{ + QScriptEngine eng; + QScriptValue global = eng.globalObject(); + QVERIFY(global.property("qsTranslate").isUndefined()); + QVERIFY(global.property("QT_TRANSLATE_NOOP").isUndefined()); + QVERIFY(global.property("qsTr").isUndefined()); + QVERIFY(global.property("QT_TR_NOOP").isUndefined()); + QVERIFY(global.property("qsTrId").isUndefined()); + QVERIFY(global.property("QT_TRID_NOOP").isUndefined()); + QVERIFY(global.property("String").property("prototype").property("arg").isUndefined()); + + eng.installTranslatorFunctions(); + QVERIFY(global.property("qsTranslate").isCallable()); + QVERIFY(global.property("QT_TRANSLATE_NOOP").isCallable()); + QVERIFY(global.property("qsTr").isCallable()); + QVERIFY(global.property("QT_TR_NOOP").isCallable()); + QVERIFY(global.property("qsTrId").isCallable()); + QVERIFY(global.property("QT_TRID_NOOP").isCallable()); + QVERIFY(global.property("String").property("prototype").property("arg").isCallable()); + + { + QScriptValue ret = eng.evaluate("qsTr('foo')"); + QVERIFY(ret.isString()); + QCOMPARE(ret.toString(), QString::fromLatin1("foo")); + } + { + QScriptValue ret = eng.evaluate("qsTranslate('foo', 'bar')"); + QVERIFY(ret.isString()); + QCOMPARE(ret.toString(), QString::fromLatin1("bar")); + } + { + QScriptValue ret = eng.evaluate("QT_TR_NOOP('foo')"); + QVERIFY(ret.isString()); + QCOMPARE(ret.toString(), QString::fromLatin1("foo")); + } + { + QScriptValue ret = eng.evaluate("QT_TRANSLATE_NOOP('foo', 'bar')"); + QVERIFY(ret.isString()); + QCOMPARE(ret.toString(), QString::fromLatin1("bar")); + } + { + QScriptValue ret = eng.evaluate("'foo%0'.arg('bar')"); + QEXPECT_FAIL("Custom global object", "FIXME: why we expect that String prototype exists?", Abort); + QVERIFY(ret.isString()); + QCOMPARE(ret.toString(), QString::fromLatin1("foobar")); + } + { + QScriptValue ret = eng.evaluate("'foo%0'.arg(123)"); + QVERIFY(ret.isString()); + QCOMPARE(ret.toString(), QString::fromLatin1("foo123")); + } + { + // Maybe this should throw an error? + QScriptValue ret = eng.evaluate("'foo%0'.arg()"); + QVERIFY(ret.isString()); + QCOMPARE(ret.toString(), QString()); + } + + { + QScriptValue ret = eng.evaluate("qsTrId('foo')"); + QVERIFY(ret.isString()); + QCOMPARE(ret.toString(), QString::fromLatin1("foo")); + } + { + QScriptValue ret = eng.evaluate("QT_TRID_NOOP('foo')"); + QVERIFY(ret.isString()); + QCOMPARE(ret.toString(), QString::fromLatin1("foo")); + } + QVERIFY(eng.evaluate("QT_TRID_NOOP()").isUndefined()); +} + +class TranslationScope +{ +public: + TranslationScope(const QString &fileName) + { + translator.load(fileName); + QCoreApplication::instance()->installTranslator(&translator); + } + ~TranslationScope() + { + QCoreApplication::instance()->removeTranslator(&translator); + } + +private: + QTranslator translator; +}; + +void tst_QJSEngine::translateScript_data() +{ + QTest::addColumn("expression"); + QTest::addColumn("fileName"); + QTest::addColumn("expectedTranslation"); + + QString fileName = QString::fromLatin1("translatable.js"); + // Top-level + QTest::newRow("qsTr('One')@translatable.js") + << QString::fromLatin1("qsTr('One')") << fileName << QString::fromLatin1("En"); + QTest::newRow("qsTr('Hello')@translatable.js") + << QString::fromLatin1("qsTr('Hello')") << fileName << QString::fromLatin1("Hallo"); + // From function + QTest::newRow("(function() { return qsTr('One'); })()@translatable.js") + << QString::fromLatin1("(function() { return qsTr('One'); })()") << fileName << QString::fromLatin1("En"); + QTest::newRow("(function() { return qsTr('Hello'); })()@translatable.js") + << QString::fromLatin1("(function() { return qsTr('Hello'); })()") << fileName << QString::fromLatin1("Hallo"); + // From eval + QTest::newRow("eval('qsTr(\\'One\\')')@translatable.js") + << QString::fromLatin1("eval('qsTr(\\'One\\')')") << fileName << QString::fromLatin1("En"); + QTest::newRow("eval('qsTr(\\'Hello\\')')@translatable.js") + << QString::fromLatin1("eval('qsTr(\\'Hello\\')')") << fileName << QString::fromLatin1("Hallo"); + // Plural + QTest::newRow("qsTr('%n message(s) saved', '', 1)@translatable.js") + << QString::fromLatin1("qsTr('%n message(s) saved', '', 1)") << fileName << QString::fromLatin1("1 melding lagret"); + QTest::newRow("qsTr('%n message(s) saved', '', 3).arg@translatable.js") + << QString::fromLatin1("qsTr('%n message(s) saved', '', 3)") << fileName << QString::fromLatin1("3 meldinger lagret"); + + // Top-level + QTest::newRow("qsTranslate('FooContext', 'Two')@translatable.js") + << QString::fromLatin1("qsTranslate('FooContext', 'Two')") << fileName << QString::fromLatin1("To"); + QTest::newRow("qsTranslate('FooContext', 'Goodbye')@translatable.js") + << QString::fromLatin1("qsTranslate('FooContext', 'Goodbye')") << fileName << QString::fromLatin1("Farvel"); + // From eval + QTest::newRow("eval('qsTranslate(\\'FooContext\\', \\'Two\\')')@translatable.js") + << QString::fromLatin1("eval('qsTranslate(\\'FooContext\\', \\'Two\\')')") << fileName << QString::fromLatin1("To"); + QTest::newRow("eval('qsTranslate(\\'FooContext\\', \\'Goodbye\\')')@translatable.js") + << QString::fromLatin1("eval('qsTranslate(\\'FooContext\\', \\'Goodbye\\')')") << fileName << QString::fromLatin1("Farvel"); + + QTest::newRow("qsTranslate('FooContext', 'Goodbye', '', 'UnicodeUTF8')@translatable.js") + << QString::fromLatin1("qsTranslate('FooContext', 'Goodbye', '', 'UnicodeUTF8')") << fileName << QString::fromLatin1("Farvel"); + QTest::newRow("qsTranslate('FooContext', 'Goodbye', '', 'CodecForTr')@translatable.js") + << QString::fromLatin1("qsTranslate('FooContext', 'Goodbye', '', 'CodecForTr')") << fileName << QString::fromLatin1("Farvel"); + + QTest::newRow("qsTranslate('FooContext', 'Goodbye', '', 'UnicodeUTF8', 42)@translatable.js") + << QString::fromLatin1("qsTranslate('FooContext', 'Goodbye', '', 'UnicodeUTF8', 42)") << fileName << QString::fromLatin1("Goodbye"); + + QTest::newRow("qsTr('One', 'not the same one')@translatable.js") + << QString::fromLatin1("qsTr('One', 'not the same one')") << fileName << QString::fromLatin1("Enda en"); + + QTest::newRow("qsTr('One', 'not the same one', 42)@translatable.js") + << QString::fromLatin1("qsTr('One', 'not the same one', 42)") << fileName << QString::fromLatin1("One"); + + // Plural + QTest::newRow("qsTranslate('FooContext', '%n fooish bar(s) found', '', 'UnicodeUTF8', 1)@translatable.js") + << QString::fromLatin1("qsTranslate('FooContext', '%n fooish bar(s) found', '', 'UnicodeUTF8', 1)") << fileName << QString::fromLatin1("1 fooaktig bar funnet"); + QTest::newRow("qsTranslate('FooContext', '%n fooish bar(s) found', '', 'UnicodeUTF8', 2)@translatable.js") + << QString::fromLatin1("qsTranslate('FooContext', '%n fooish bar(s) found', '', 'UnicodeUTF8', 2)") << fileName << QString::fromLatin1("2 fooaktige barer funnet"); + + // Don't exist in translation + QTest::newRow("qsTr('Three')@translatable.js") + << QString::fromLatin1("qsTr('Three')") << fileName << QString::fromLatin1("Three"); + QTest::newRow("qsTranslate('FooContext', 'So long')@translatable.js") + << QString::fromLatin1("qsTranslate('FooContext', 'So long')") << fileName << QString::fromLatin1("So long"); + QTest::newRow("qsTranslate('BarContext', 'Goodbye')@translatable.js") + << QString::fromLatin1("qsTranslate('BarContext', 'Goodbye')") << fileName << QString::fromLatin1("Goodbye"); + + // Translate strings from the second script (translatable2.js) + + QString fileName2 = QString::fromLatin1("translatable2.js"); + QTest::newRow("qsTr('Three')@translatable2.js") + << QString::fromLatin1("qsTr('Three')") << fileName2 << QString::fromLatin1("Tre"); + QTest::newRow("qsTr('Happy birthday!')@translatable2.js") + << QString::fromLatin1("qsTr('Happy birthday!')") << fileName2 << QString::fromLatin1("Gratulerer med dagen!"); + + // Not translated because translation is only in translatable.js + QTest::newRow("qsTr('One')@translatable2.js") + << QString::fromLatin1("qsTr('One')") << fileName2 << QString::fromLatin1("One"); + QTest::newRow("(function() { return qsTr('One'); })()@translatable2.js") + << QString::fromLatin1("(function() { return qsTr('One'); })()") << fileName2 << QString::fromLatin1("One"); + + // For qsTranslate() the filename shouldn't matter + QTest::newRow("qsTranslate('FooContext', 'Two')@translatable2.js") + << QString::fromLatin1("qsTranslate('FooContext', 'Two')") << fileName2 << QString::fromLatin1("To"); + QTest::newRow("qsTranslate('BarContext', 'Congratulations!')@translatable.js") + << QString::fromLatin1("qsTranslate('BarContext', 'Congratulations!')") << fileName << QString::fromLatin1("Gratulerer!"); +} + +void tst_QJSEngine::translateScript() +{ + QFETCH(QString, expression); + QFETCH(QString, fileName); + QFETCH(QString, expectedTranslation); + + QScriptEngine engine; + + TranslationScope tranScope(":/translations/translatable_la"); + engine.installTranslatorFunctions(); + + QCOMPARE(engine.evaluate(expression, fileName).toString(), expectedTranslation); + QVERIFY(!engine.hasUncaughtException()); +} + +void tst_QJSEngine::translateScript_crossScript() +{ + QScriptEngine engine; + TranslationScope tranScope(":/translations/translatable_la"); + engine.installTranslatorFunctions(); + + QString fileName = QString::fromLatin1("translatable.js"); + QString fileName2 = QString::fromLatin1("translatable2.js"); + // qsTr() should use the innermost filename as context + engine.evaluate("function foo(s) { return bar(s); }", fileName); + engine.evaluate("function bar(s) { return qsTr(s); }", fileName2); + QCOMPARE(engine.evaluate("bar('Three')", fileName2).toString(), QString::fromLatin1("Tre")); + QCOMPARE(engine.evaluate("bar('Three')", fileName).toString(), QString::fromLatin1("Tre")); + QCOMPARE(engine.evaluate("bar('One')", fileName2).toString(), QString::fromLatin1("One")); + + engine.evaluate("function foo(s) { return bar(s); }", fileName2); + engine.evaluate("function bar(s) { return qsTr(s); }", fileName); + QCOMPARE(engine.evaluate("bar('Three')", fileName2).toString(), QString::fromLatin1("Three")); + QCOMPARE(engine.evaluate("bar('One')", fileName).toString(), QString::fromLatin1("En")); + QCOMPARE(engine.evaluate("bar('One')", fileName2).toString(), QString::fromLatin1("En")); +} + +static QScriptValue callQsTr(QScriptContext *ctx, QScriptEngine *eng) +{ + return eng->globalObject().property("qsTr").callWithInstance(ctx->thisObject(), ctx->argumentsObject()); +} + +void tst_QJSEngine::translateScript_callQsTrFromNative() +{ + QScriptEngine engine; + TranslationScope tranScope(":/translations/translatable_la"); + engine.installTranslatorFunctions(); + + QString fileName = QString::fromLatin1("translatable.js"); + QString fileName2 = QString::fromLatin1("translatable2.js"); + // Calling qsTr() from a native function + engine.globalObject().setProperty("qsTrProxy", engine.newFunction(callQsTr)); + QCOMPARE(engine.evaluate("qsTrProxy('One')", fileName).toString(), QString::fromLatin1("En")); + QCOMPARE(engine.evaluate("qsTrProxy('One')", fileName2).toString(), QString::fromLatin1("One")); + QCOMPARE(engine.evaluate("qsTrProxy('Three')", fileName).toString(), QString::fromLatin1("Three")); + QCOMPARE(engine.evaluate("qsTrProxy('Three')", fileName2).toString(), QString::fromLatin1("Tre")); +} + +void tst_QJSEngine::translateScript_trNoOp() +{ + QScriptEngine engine; + TranslationScope tranScope(":/translations/translatable_la"); + engine.installTranslatorFunctions(); + + QVERIFY(engine.evaluate("QT_TR_NOOP()").isUndefined()); + QCOMPARE(engine.evaluate("QT_TR_NOOP('One')").toString(), QString::fromLatin1("One")); + + QVERIFY(engine.evaluate("QT_TRANSLATE_NOOP()").isUndefined()); + QVERIFY(engine.evaluate("QT_TRANSLATE_NOOP('FooContext')").isUndefined()); + QCOMPARE(engine.evaluate("QT_TRANSLATE_NOOP('FooContext', 'Two')").toString(), QString::fromLatin1("Two")); +} + +void tst_QJSEngine::translateScript_callQsTrFromCpp() +{ + QScriptEngine engine; + TranslationScope tranScope(":/translations/translatable_la"); + engine.installTranslatorFunctions(); + + // There is no context, but it shouldn't crash + QCOMPARE(engine.globalObject().property("qsTr").call( + QScriptValueList() << "One").toString(), QString::fromLatin1("One")); +} + +void tst_QJSEngine::translateWithInvalidArgs_data() +{ + QTest::addColumn("expression"); + QTest::addColumn("expectedError"); + + QTest::newRow("qsTr()") << "qsTr()" << "Error: qsTr() requires at least one argument"; + QTest::newRow("qsTr(123)") << "qsTr(123)" << "Error: qsTr(): first argument (text) must be a string"; + QTest::newRow("qsTr('foo', 123)") << "qsTr('foo', 123)" << "Error: qsTr(): second argument (comment) must be a string"; + QTest::newRow("qsTr('foo', 'bar', 'baz')") << "qsTr('foo', 'bar', 'baz')" << "Error: qsTr(): third argument (n) must be a number"; + QTest::newRow("qsTr('foo', 'bar', true)") << "qsTr('foo', 'bar', true)" << "Error: qsTr(): third argument (n) must be a number"; + + QTest::newRow("qsTranslate()") << "qsTranslate()" << "Error: qsTranslate() requires at least two arguments"; + QTest::newRow("qsTranslate('foo')") << "qsTranslate('foo')" << "Error: qsTranslate() requires at least two arguments"; + QTest::newRow("qsTranslate(123, 'foo')") << "qsTranslate(123, 'foo')" << "Error: qsTranslate(): first argument (context) must be a string"; + QTest::newRow("qsTranslate('foo', 123)") << "qsTranslate('foo', 123)" << "Error: qsTranslate(): second argument (text) must be a string"; + QTest::newRow("qsTranslate('foo', 'bar', 123)") << "qsTranslate('foo', 'bar', 123)" << "Error: qsTranslate(): third argument (comment) must be a string"; + QTest::newRow("qsTranslate('foo', 'bar', 'baz', 123)") << "qsTranslate('foo', 'bar', 'baz', 123)" << "Error: qsTranslate(): fourth argument (encoding) must be a string"; + QTest::newRow("qsTranslate('foo', 'bar', 'baz', 'zab', 'rab')") << "qsTranslate('foo', 'bar', 'baz', 'zab', 'rab')" << "Error: qsTranslate(): fifth argument (n) must be a number"; + QTest::newRow("qsTranslate('foo', 'bar', 'baz', 'zab', 123)") << "qsTranslate('foo', 'bar', 'baz', 'zab', 123)" << "Error: qsTranslate(): invalid encoding 'zab'"; + + QTest::newRow("qsTrId()") << "qsTrId()" << "Error: qsTrId() requires at least one argument"; + QTest::newRow("qsTrId(123)") << "qsTrId(123)" << "TypeError: qsTrId(): first argument (id) must be a string"; + QTest::newRow("qsTrId('foo', 'bar')") << "qsTrId('foo', 'bar')" << "TypeError: qsTrId(): second argument (n) must be a number"; +} + +void tst_QJSEngine::translateWithInvalidArgs() +{ + QFETCH(QString, expression); + QFETCH(QString, expectedError); + QScriptEngine engine; + engine.installTranslatorFunctions(); + QScriptValue result = engine.evaluate(expression); + QVERIFY(result.isError()); + QCOMPARE(result.toString(), expectedError); +} + +void tst_QJSEngine::translationContext_data() +{ + QTest::addColumn("path"); + QTest::addColumn("text"); + QTest::addColumn("expectedTranslation"); + + QTest::newRow("translatable.js") << "translatable.js" << "One" << "En"; + QTest::newRow("/translatable.js") << "/translatable.js" << "One" << "En"; + QTest::newRow("/foo/translatable.js") << "/foo/translatable.js" << "One" << "En"; + QTest::newRow("/foo/bar/translatable.js") << "/foo/bar/translatable.js" << "One" << "En"; + QTest::newRow("./translatable.js") << "./translatable.js" << "One" << "En"; + QTest::newRow("../translatable.js") << "../translatable.js" << "One" << "En"; + QTest::newRow("foo/translatable.js") << "foo/translatable.js" << "One" << "En"; + QTest::newRow("file:///home/qt/translatable.js") << "file:///home/qt/translatable.js" << "One" << "En"; + QTest::newRow(":/resources/translatable.js") << ":/resources/translatable.js" << "One" << "En"; + QTest::newRow("/translatable.js.foo") << "/translatable.js.foo" << "One" << "En"; + QTest::newRow("/translatable.txt") << "/translatable.txt" << "One" << "En"; + QTest::newRow("translatable") << "translatable" << "One" << "En"; + QTest::newRow("foo/translatable") << "foo/translatable" << "One" << "En"; + + QTest::newRow("native separators") + << (QDir::toNativeSeparators(QDir::currentPath()) + QDir::separator() + "translatable.js") + << "One" << "En"; + + QTest::newRow("translatable.js/") << "translatable.js/" << "One" << "One"; + QTest::newRow("nosuchscript.js") << "" << "One" << "One"; + QTest::newRow("(empty)") << "" << "One" << "One"; +} + +void tst_QJSEngine::translationContext() +{ + TranslationScope tranScope(":/translations/translatable_la"); + + QScriptEngine engine; + engine.installTranslatorFunctions(); + + QFETCH(QString, path); + QFETCH(QString, text); + QFETCH(QString, expectedTranslation); + QScriptValue ret = engine.evaluate(QString::fromLatin1("qsTr('%0')").arg(text), path); + QVERIFY(ret.isString()); + QCOMPARE(ret.toString(), expectedTranslation); +} + +void tst_QJSEngine::translateScriptIdBased() +{ + QScriptEngine engine; + + TranslationScope tranScope(":/translations/idtranslatable_la"); + engine.installTranslatorFunctions(); + + QString fileName = QString::fromLatin1("idtranslatable.js"); + + QHash expectedTranslations; + expectedTranslations["qtn_foo_bar"] = "First string"; + expectedTranslations["qtn_needle"] = "Second string"; + expectedTranslations["qtn_haystack"] = "Third string"; + expectedTranslations["qtn_bar_baz"] = "Fourth string"; + + QHash::const_iterator it; + for (it = expectedTranslations.constBegin(); it != expectedTranslations.constEnd(); ++it) { + for (int x = 0; x < 2; ++x) { + QString fn; + if (x) + fn = fileName; + // Top-level + QCOMPARE(engine.evaluate(QString::fromLatin1("qsTrId('%0')") + .arg(it.key()), fn).toString(), + it.value()); + QCOMPARE(engine.evaluate(QString::fromLatin1("QT_TRID_NOOP('%0')") + .arg(it.key()), fn).toString(), + it.key()); + // From function + QCOMPARE(engine.evaluate(QString::fromLatin1("(function() { return qsTrId('%0'); })()") + .arg(it.key()), fn).toString(), + it.value()); + QCOMPARE(engine.evaluate(QString::fromLatin1("(function() { return QT_TRID_NOOP('%0'); })()") + .arg(it.key()), fn).toString(), + it.key()); + } + } + + // Plural form + QCOMPARE(engine.evaluate("qsTrId('qtn_bar_baz', 10)").toString(), + QString::fromLatin1("10 fooish bar(s) found")); + QCOMPARE(engine.evaluate("qsTrId('qtn_foo_bar', 10)").toString(), + QString::fromLatin1("qtn_foo_bar")); // Doesn't have plural +} + +// How to add a new test row: +// - Find a nice list of Unicode characters to choose from +// - Write source string/context/comment in .js using Unicode escape sequences (\uABCD) +// - Update corresponding .ts file (e.g. lupdate foo.js -ts foo.ts -codecfortr UTF-8) +// - Enter translation in Linguist +// - Update corresponding .qm file (e.g. lrelease foo.ts) +// - Evaluate script that performs translation; make sure the correct result is returned +// (e.g. by setting the resulting string as the text of a QLabel and visually verifying +// that it looks the same as what you entered in Linguist :-) ) +// - Generate the expectedTranslation column data using toUtf8().toHex() +void tst_QJSEngine::translateScriptUnicode_data() +{ + QTest::addColumn("expression"); + QTest::addColumn("fileName"); + QTest::addColumn("expectedTranslation"); + + QString fileName = QString::fromLatin1("translatable-unicode.js"); + QTest::newRow("qsTr('H\\u2082O')@translatable-unicode.js") + << QString::fromLatin1("qsTr('H\\u2082O')") << fileName << QString::fromUtf8("\xcd\xbb\xcd\xbc\xcd\xbd"); + QTest::newRow("qsTranslate('\\u010C\\u0101\\u011F\\u0115', 'CO\\u2082')@translatable-unicode.js") + << QString::fromLatin1("qsTranslate('\\u010C\\u0101\\u011F\\u0115', 'CO\\u2082')") << fileName << QString::fromUtf8("\xd7\x91\xd7\x9a\xd7\xa2"); + QTest::newRow("qsTr('\\u0391\\u0392\\u0393')@translatable-unicode.js") + << QString::fromLatin1("qsTr('\\u0391\\u0392\\u0393')") << fileName << QString::fromUtf8("\xd3\x9c\xd2\xb4\xd1\xbc"); + QTest::newRow("qsTranslate('\\u010C\\u0101\\u011F\\u0115', '\\u0414\\u0415\\u0416')@translatable-unicode.js") + << QString::fromLatin1("qsTranslate('\\u010C\\u0101\\u011F\\u0115', '\\u0414\\u0415\\u0416')") << fileName << QString::fromUtf8("\xd8\xae\xd8\xb3\xd8\xb3"); + QTest::newRow("qsTr('H\\u2082O', 'not the same H\\u2082O')@translatable-unicode.js") + << QString::fromLatin1("qsTr('H\\u2082O', 'not the same H\\u2082O')") << fileName << QString::fromUtf8("\xd4\xb6\xd5\x8a\xd5\x92"); + QTest::newRow("qsTr('H\\u2082O')") + << QString::fromLatin1("qsTr('H\\u2082O')") << QString() << QString::fromUtf8("\x48\xe2\x82\x82\x4f"); + QTest::newRow("qsTranslate('\\u010C\\u0101\\u011F\\u0115', 'CO\\u2082')") + << QString::fromLatin1("qsTranslate('\\u010C\\u0101\\u011F\\u0115', 'CO\\u2082')") << QString() << QString::fromUtf8("\xd7\x91\xd7\x9a\xd7\xa2"); +} + +void tst_QJSEngine::translateScriptUnicode() +{ + QFETCH(QString, expression); + QFETCH(QString, fileName); + QFETCH(QString, expectedTranslation); + + QScriptEngine engine; + + TranslationScope tranScope(":/translations/translatable-unicode"); + engine.installTranslatorFunctions(); + + QCOMPARE(engine.evaluate(expression, fileName).toString(), expectedTranslation); + QVERIFY(!engine.hasUncaughtException()); +} + +void tst_QJSEngine::translateScriptUnicodeIdBased_data() +{ + QTest::addColumn("expression"); + QTest::addColumn("expectedTranslation"); + + QTest::newRow("qsTrId('\\u01F8\\u01D2\\u0199\\u01D0\\u01E1'')") + << QString::fromLatin1("qsTrId('\\u01F8\\u01D2\\u0199\\u01D0\\u01E1')") << QString::fromUtf8("\xc6\xa7\xc6\xb0\xc6\x88\xc8\xbc\xc8\x9d\xc8\xbf\xc8\x99"); + QTest::newRow("qsTrId('\\u0191\\u01CE\\u0211\\u0229\\u019C\\u018E\\u019A\\u01D0')") + << QString::fromLatin1("qsTrId('\\u0191\\u01CE\\u0211\\u0229\\u019C\\u018E\\u019A\\u01D0')") << QString::fromUtf8("\xc7\xa0\xc8\xa1\xc8\x8b\xc8\x85\xc8\x95"); + QTest::newRow("qsTrId('\\u0181\\u01A1\\u0213\\u018F\\u018C', 10)") + << QString::fromLatin1("qsTrId('\\u0181\\u01A1\\u0213\\u018F\\u018C', 10)") << QString::fromUtf8("\x31\x30\x20\xc6\x92\xc6\xa1\xc7\x92\x28\xc8\x99\x29"); + QTest::newRow("qsTrId('\\u0181\\u01A1\\u0213\\u018F\\u018C')") + << QString::fromLatin1("qsTrId('\\u0181\\u01A1\\u0213\\u018F\\u018C')") << QString::fromUtf8("\xc6\x91\xc6\xb0\xc7\xb9"); + QTest::newRow("qsTrId('\\u01CD\\u0180\\u01A8\\u0190\\u019E\\u01AB')") + << QString::fromLatin1("qsTrId('\\u01CD\\u0180\\u01A8\\u0190\\u019E\\u01AB')") << QString::fromUtf8("\xc7\x8d\xc6\x80\xc6\xa8\xc6\x90\xc6\x9e\xc6\xab"); +} + +void tst_QJSEngine::translateScriptUnicodeIdBased() +{ + QFETCH(QString, expression); + QFETCH(QString, expectedTranslation); + + QScriptEngine engine; + + TranslationScope tranScope(":/translations/idtranslatable-unicode"); + engine.installTranslatorFunctions(); + + QCOMPARE(engine.evaluate(expression).toString(), expectedTranslation); + QVERIFY(!engine.hasUncaughtException()); +} + +void tst_QJSEngine::translateFromBuiltinCallback() +{ + QScriptEngine eng; + eng.installTranslatorFunctions(); + + // Callback has no translation context. + eng.evaluate("function foo() { qsTr('foo'); }"); + + // Stack at translation time will be: + // qsTr, foo, forEach, global + // qsTr() needs to walk to the outer-most (global) frame before it finds + // a translation context, and this should not crash. + eng.evaluate("[10,20].forEach(foo)", "script.js"); +} +#endif + +#if 0 // ###FIXME: No QScriptValue::scope API +void tst_QJSEngine::functionScopes() +{ + QScriptEngine eng; + { + // top-level functions have only the global object in their scope + QScriptValue fun = eng.evaluate("(function() {})"); + QVERIFY(fun.isCallable()); + QEXPECT_FAIL("", "QScriptValue::scope() is internal, not implemented", Abort); + QVERIFY(fun.scope().isObject()); + QVERIFY(fun.scope().strictlyEquals(eng.globalObject())); + QVERIFY(eng.globalObject().scope().isUndefined()); + } + { + QScriptValue fun = eng.globalObject().property("Object"); + QVERIFY(fun.isCallable()); + // native built-in functions don't have scope + QVERIFY(fun.scope().isUndefined()); + } + { + // closure + QScriptValue fun = eng.evaluate("(function(arg) { var foo = arg; return function() { return foo; }; })(123)"); + QVERIFY(fun.isCallable()); + { + QScriptValue ret = fun.call(); + QVERIFY(ret.isNumber()); + QCOMPARE(ret.toInt(), 123); + } + QScriptValue scope = fun.scope(); + QVERIFY(scope.isObject()); + { + QScriptValue ret = scope.property("foo"); + QVERIFY(ret.isNumber()); + QCOMPARE(ret.toInt(), 123); + } + { + QScriptValue ret = scope.property("arg"); + QVERIFY(ret.isNumber()); + QCOMPARE(ret.toInt(), 123); + } + + scope.setProperty("foo", 456); + { + QScriptValue ret = fun.call(); + QVERIFY(ret.isNumber()); + QCOMPARE(ret.toInt(), 456); + } + + scope = scope.scope(); + QVERIFY(scope.isObject()); + QVERIFY(scope.strictlyEquals(eng.globalObject())); + } +} +#endif + +#if 0 // ###FIXME: No QScriptContext API +static QScriptValue counter_inner(QScriptContext *ctx, QScriptEngine *) +{ + QScriptValue outerAct = ctx->callee().scope(); + double count = outerAct.property("count").toNumber(); + outerAct.setProperty("count", count+1); + return count; +} + +static QScriptValue counter(QScriptContext *ctx, QScriptEngine *eng) +{ + QScriptValue act = ctx->activationObject(); + act.setProperty("count", ctx->argument(0).toInt()); + QScriptValue result = eng->newFunction(counter_inner); + result.setScope(act); + return result; +} + +static QScriptValue counter_hybrid(QScriptContext *ctx, QScriptEngine *eng) +{ + QScriptValue act = ctx->activationObject(); + act.setProperty("count", ctx->argument(0).toInt()); + return eng->evaluate("(function() { return count++; })"); +} + +void tst_QJSEngine::nativeFunctionScopes() +{ + QScriptEngine eng; + { + QScriptValue fun = eng.newFunction(counter); + QScriptValue cnt = fun.call(QScriptValueList() << 123); + QVERIFY(cnt.isCallable()); + { + QScriptValue ret = cnt.call(); + QVERIFY(ret.isNumber()); + QEXPECT_FAIL("", "QScriptValue::setScope not implemented", Continue); + QCOMPARE(ret.toInt(), 123); + } + } + { + QScriptValue fun = eng.newFunction(counter_hybrid); + QScriptValue cnt = fun.call(QScriptValueList() << 123); + QVERIFY(cnt.isCallable()); + { + QScriptValue ret = cnt.call(); + QVERIFY(ret.isNumber()); + QCOMPARE(ret.toInt(), 123); + } + } + + //from http://doc.trolltech.com/latest/qtscript.html#nested-functions-and-the-scope-chain + { + QScriptEngine eng; + eng.evaluate("function counter() { var count = 0; return function() { return count++; } }\n" + "var c1 = counter(); var c2 = counter(); "); + QCOMPARE(eng.evaluate("c1()").toString(), QString::fromLatin1("0")); + QCOMPARE(eng.evaluate("c1()").toString(), QString::fromLatin1("1")); + QCOMPARE(eng.evaluate("c2()").toString(), QString::fromLatin1("0")); + QCOMPARE(eng.evaluate("c2()").toString(), QString::fromLatin1("1")); + QVERIFY(!eng.hasUncaughtException()); + } + { + QScriptEngine eng; + eng.globalObject().setProperty("counter", eng.newFunction(counter)); + eng.evaluate("var c1 = counter(); var c2 = counter(); "); + QCOMPARE(eng.evaluate("c1()").toString(), QString::fromLatin1("0")); + QEXPECT_FAIL("", "QScriptValue::setScope not implemented", Continue); + QCOMPARE(eng.evaluate("c1()").toString(), QString::fromLatin1("1")); + QCOMPARE(eng.evaluate("c2()").toString(), QString::fromLatin1("0")); + QEXPECT_FAIL("", "QScriptValue::setScope not implemented", Continue); + QCOMPARE(eng.evaluate("c2()").toString(), QString::fromLatin1("1")); + QVERIFY(!eng.hasUncaughtException()); + } + { + QScriptEngine eng; + eng.globalObject().setProperty("counter", eng.newFunction(counter_hybrid)); + eng.evaluate("var c1 = counter(); var c2 = counter(); "); + QCOMPARE(eng.evaluate("c1()").toString(), QString::fromLatin1("0")); + QCOMPARE(eng.evaluate("c1()").toString(), QString::fromLatin1("1")); + QCOMPARE(eng.evaluate("c2()").toString(), QString::fromLatin1("0")); + QCOMPARE(eng.evaluate("c2()").toString(), QString::fromLatin1("1")); + QVERIFY(!eng.hasUncaughtException()); + } +} +#endif + +#if 0 // ###FIXME: No QScriptProgram API +static QScriptValue createProgram(QScriptContext *ctx, QScriptEngine *eng) +{ + QString code = ctx->argument(0).toString(); + QScriptProgram result(code); + return qScriptValueFromValue(eng, result); +} + +void tst_QJSEngine::evaluateProgram() +{ + QScriptEngine eng; + + { + QString code("1 + 2"); + QString fileName("hello.js"); + int lineNumber(123); + QScriptProgram program(code, fileName, lineNumber); + QVERIFY(!program.isNull()); + QCOMPARE(program.sourceCode(), code); + QCOMPARE(program.fileName(), fileName); + QCOMPARE(program.firstLineNumber(), lineNumber); + + QScriptValue expected = eng.evaluate(code); + for (int x = 0; x < 10; ++x) { + QScriptValue ret = eng.evaluate(program); + QVERIFY(ret.equals(expected)); + } + + // operator= + QScriptProgram sameProgram = program; + QVERIFY(sameProgram == program); + QVERIFY(eng.evaluate(sameProgram).equals(expected)); + + // copy constructor + QScriptProgram sameProgram2(program); + QVERIFY(sameProgram2 == program); + QVERIFY(eng.evaluate(sameProgram2).equals(expected)); + + QScriptProgram differentProgram("2 + 3"); + QVERIFY(differentProgram != program); + QVERIFY(!eng.evaluate(differentProgram).equals(expected)); + } +} + +void tst_QJSEngine::evaluateProgram_customScope() +{ + QScriptEngine eng; + { + QScriptProgram program("a"); + QVERIFY(!program.isNull()); + { + QScriptValue ret = eng.evaluate(program); + QVERIFY(ret.isError()); + QCOMPARE(ret.toString(), QString::fromLatin1("ReferenceError: a is not defined")); + } + + QScriptValue obj = eng.newObject(); + obj.setProperty("a", 123); + QScriptContext *ctx = eng.currentContext(); + ctx->pushScope(obj); + { + QScriptValue ret = eng.evaluate(program); + QVERIFY(!ret.isError()); + QVERIFY(ret.equals(obj.property("a"))); + } + + obj.setProperty("a", QScriptValue()); + { + QScriptValue ret = eng.evaluate(program); + QVERIFY(ret.isError()); + } + + QScriptValue obj2 = eng.newObject(); + obj2.setProperty("a", 456); + ctx->pushScope(obj2); + { + QScriptValue ret = eng.evaluate(program); + QVERIFY(!ret.isError()); + QVERIFY(ret.equals(obj2.property("a"))); + } + + ctx->popScope(); + } +} + +void tst_QJSEngine::evaluateProgram_closure() +{ + QScriptEngine eng; + { + QScriptProgram program("(function() { var count = 0; return function() { return count++; }; })"); + QVERIFY(!program.isNull()); + QScriptValue createCounter = eng.evaluate(program); + QVERIFY(createCounter.isCallable()); + QScriptValue counter = createCounter.call(); + QVERIFY(counter.isCallable()); + { + QScriptValue ret = counter.call(); + QVERIFY(ret.isNumber()); + } + QScriptValue counter2 = createCounter.call(); + QVERIFY(counter2.isCallable()); + QVERIFY(!counter2.equals(counter)); + { + QScriptValue ret = counter2.call(); + QVERIFY(ret.isNumber()); + } + } +} + +void tst_QJSEngine::evaluateProgram_executeLater() +{ + QScriptEngine eng; + // Program created in a function call, then executed later + { + QScriptValue fun = eng.newFunction(createProgram); + QScriptProgram program = qscriptvalue_cast( + fun.call(QScriptValueList() << "a + 1")); + QVERIFY(!program.isNull()); + eng.globalObject().setProperty("a", QScriptValue()); + { + QScriptValue ret = eng.evaluate(program); + QVERIFY(ret.isError()); + QCOMPARE(ret.toString(), QString::fromLatin1("ReferenceError: a is not defined")); + } + eng.globalObject().setProperty("a", 122); + { + QScriptValue ret = eng.evaluate(program); + QVERIFY(!ret.isError()); + QVERIFY(ret.isNumber()); + QCOMPARE(ret.toInt(), 123); + } + } +} + +void tst_QJSEngine::evaluateProgram_multipleEngines() +{ + QScriptEngine eng; + { + QString code("1 + 2"); + QScriptProgram program(code); + QVERIFY(!program.isNull()); + double expected = eng.evaluate(program).toNumber(); + for (int x = 0; x < 2; ++x) { + QScriptEngine eng2; + for (int y = 0; y < 2; ++y) { + double ret = eng2.evaluate(program).toNumber(); + QCOMPARE(ret, expected); + } + } + } +} + +void tst_QJSEngine::evaluateProgram_empty() +{ + QScriptEngine eng; + { + QScriptProgram program; + QVERIFY(program.isNull()); + QScriptValue ret = eng.evaluate(program); + QVERIFY(ret.isUndefined()); + } +} +#endif + +#if 0 // ###FIXME: No ScriptOwnership API +void tst_QJSEngine::collectGarbageAfterConnect() +{ + // QTBUG-6366 + QScriptEngine engine; + QPointer widget = new QWidget; + engine.globalObject().setProperty( + "widget", engine.newQObject(widget, QScriptEngine::ScriptOwnership)); + QVERIFY(engine.evaluate("widget.customContextMenuRequested.connect(\n" + " function() { print('hello'); }\n" + ");") + .isUndefined()); + QVERIFY(widget != 0); + engine.evaluate("widget = null;"); + // The connection should not keep the widget alive. + collectGarbage_helper(engine); + QVERIFY(widget == 0); +} +#endif + +#if 0 // ###FIXME: No QScriptContext API +void tst_QJSEngine::collectGarbageAfterNativeArguments() +{ + // QTBUG-17788 + QScriptEngine eng; + QScriptContext *ctx = eng.pushContext(); + QScriptValue arguments = ctx->argumentsObject(); + // Shouldn't crash when marking the arguments object. + collectGarbage_helper(eng); +} + +static QScriptValue constructQObjectFromThisObject(QScriptContext *ctx, QScriptEngine *eng) +{ + if (!ctx->isCalledAsConstructor()) { + qWarning("%s: ctx->isCalledAsConstructor() returned false", Q_FUNC_INFO); + return QScriptValue(); + } + return eng->newQObject(ctx->thisObject(), new QObject, QScriptEngine::ScriptOwnership); +} + +void tst_QJSEngine::promoteThisObjectToQObjectInConstructor() +{ + QScriptEngine engine; + QScriptValue ctor = engine.newFunction(constructQObjectFromThisObject); + engine.globalObject().setProperty("Ctor", ctor); + QScriptValue object = engine.evaluate("new Ctor"); + QVERIFY(!object.isError()); + QVERIFY(object.isQObject()); + QVERIFY(object.toQObject() != 0); + QVERIFY(object.property("objectName").isString()); + QVERIFY(object.property("deleteLater").isCallable()); +} +#endif + +static QRegExp minimal(QRegExp r) { r.setMinimal(true); return r; } + +void tst_QJSEngine::qRegExpInport_data() +{ + QTest::addColumn("rx"); + QTest::addColumn("string"); + QTest::addColumn("matched"); + + QTest::newRow("normal") << QRegExp("(test|foo)") << "test _ foo _ test _ Foo"; + QTest::newRow("normal2") << QRegExp("(Test|Foo)") << "test _ foo _ test _ Foo"; + QTest::newRow("case insensitive)") << QRegExp("(test|foo)", Qt::CaseInsensitive) << "test _ foo _ test _ Foo"; + QTest::newRow("case insensitive2)") << QRegExp("(Test|Foo)", Qt::CaseInsensitive) << "test _ foo _ test _ Foo"; + QTest::newRow("b(a*)(b*)") << QRegExp("b(a*)(b*)", Qt::CaseInsensitive) << "aaabbBbaAabaAaababaaabbaaab"; + QTest::newRow("greedy") << QRegExp("a*(a*)", Qt::CaseInsensitive, QRegExp::RegExp2) << "aaaabaaba"; + // this one will fail because we do not support the QRegExp::RegExp in JSC + //QTest::newRow("not_greedy") << QRegExp("a*(a*)", Qt::CaseInsensitive, QRegExp::RegExp) << "aaaabaaba"; + QTest::newRow("willcard") << QRegExp("*.txt", Qt::CaseSensitive, QRegExp::Wildcard) << "file.txt"; + QTest::newRow("willcard 2") << QRegExp("a?b.txt", Qt::CaseSensitive, QRegExp::Wildcard) << "ab.txt abb.rtc acb.txt"; + QTest::newRow("slash") << QRegExp("g/.*/s", Qt::CaseInsensitive, QRegExp::RegExp2) << "string/string/string"; + QTest::newRow("slash2") << QRegExp("g / .* / s", Qt::CaseInsensitive, QRegExp::RegExp2) << "string / string / string"; + QTest::newRow("fixed") << QRegExp("a*aa.a(ba)*a\\ba", Qt::CaseInsensitive, QRegExp::FixedString) << "aa*aa.a(ba)*a\\ba"; + QTest::newRow("fixed insensitive") << QRegExp("A*A", Qt::CaseInsensitive, QRegExp::FixedString) << "a*A A*a A*A a*a"; + QTest::newRow("fixed sensitive") << QRegExp("A*A", Qt::CaseSensitive, QRegExp::FixedString) << "a*A A*a A*A a*a"; + QTest::newRow("html") << QRegExp("(.*)", Qt::CaseSensitive, QRegExp::RegExp2) << "bolditalicbold"; + QTest::newRow("html minimal") << minimal(QRegExp("(.*)", Qt::CaseSensitive, QRegExp::RegExp2)) << "bolditalicbold"; + QTest::newRow("aaa") << QRegExp("a{2,5}") << "aAaAaaaaaAa"; + QTest::newRow("aaa minimal") << minimal(QRegExp("a{2,5}")) << "aAaAaaaaaAa"; + QTest::newRow("minimal") << minimal(QRegExp(".*\\} [*8]")) << "}?} ?} *"; + QTest::newRow(".? minimal") << minimal(QRegExp(".?")) << ".?"; + QTest::newRow(".+ minimal") << minimal(QRegExp(".+")) << ".+"; + QTest::newRow("[.?] minimal") << minimal(QRegExp("[.?]")) << ".?"; + QTest::newRow("[.+] minimal") << minimal(QRegExp("[.+]")) << ".+"; +} + +void tst_QJSEngine::qRegExpInport() +{ + QSKIP("Test failing - QTBUG-22238"); + QFETCH(QRegExp, rx); + QFETCH(QString, string); + + QJSEngine eng; + QJSValue rexp; + rexp = eng.toScriptValue(rx); + + QCOMPARE(rexp.isRegExp(), true); + QVERIFY(rexp.isCallable()); + + QJSValue func = eng.evaluate("(function(string, regexp) { return string.match(regexp); })"); + QJSValue result = func.call(QJSValueList() << string << rexp); + + rx.indexIn(string); + for (int i = 0; i <= rx.captureCount(); i++) { + QCOMPARE(result.property(i).toString(), rx.cap(i)); + } +} + +// QScriptValue::toDateTime() returns a local time, whereas JS dates +// are always stored as UTC. QtScript must respect the current time +// zone, and correctly adjust for daylight saving time that may be in +// effect at a given date (QTBUG-9770). +void tst_QJSEngine::dateRoundtripJSQtJS() +{ + uint secs = QDateTime(QDate(2009, 1, 1)).toUTC().toTime_t(); + QJSEngine eng; + for (int i = 0; i < 8000; ++i) { + QJSValue jsDate = eng.evaluate(QString::fromLatin1("new Date(%0)").arg(secs * 1000.0)); + QDateTime qtDate = jsDate.toDateTime(); + QJSValue jsDate2 = eng.toScriptValue(qtDate); + if (jsDate2.toNumber() != jsDate.toNumber()) + QFAIL(qPrintable(jsDate.toString())); + secs += 2*60*60; + } +} + +void tst_QJSEngine::dateRoundtripQtJSQt() +{ + QDateTime qtDate = QDateTime(QDate(2009, 1, 1)); + QJSEngine eng; + for (int i = 0; i < 8000; ++i) { + QJSValue jsDate = eng.toScriptValue(qtDate); + QDateTime qtDate2 = jsDate.toDateTime(); + if (qtDate2 != qtDate) + QFAIL(qPrintable(qtDate.toString())); + qtDate = qtDate.addSecs(2*60*60); + } +} + +void tst_QJSEngine::dateConversionJSQt() +{ + uint secs = QDateTime(QDate(2009, 1, 1)).toUTC().toTime_t(); + QJSEngine eng; + for (int i = 0; i < 8000; ++i) { + QJSValue jsDate = eng.evaluate(QString::fromLatin1("new Date(%0)").arg(secs * 1000.0)); + QDateTime qtDate = jsDate.toDateTime(); + QString qtUTCDateStr = qtDate.toUTC().toString(Qt::ISODate); + QString jsUTCDateStr = jsDate.property("toISOString").callWithInstance(jsDate).toString(); + jsUTCDateStr.remove(jsUTCDateStr.length() - 5, 4); // get rid of milliseconds (".000") + if (qtUTCDateStr != jsUTCDateStr) + QFAIL(qPrintable(jsDate.toString())); + secs += 2*60*60; + } +} + +void tst_QJSEngine::dateConversionQtJS() +{ + QDateTime qtDate = QDateTime(QDate(2009, 1, 1)); + QJSEngine eng; + for (int i = 0; i < 8000; ++i) { + QJSValue jsDate = eng.toScriptValue(qtDate); + QString jsUTCDateStr = jsDate.property("toISOString").callWithInstance(jsDate).toString(); + jsUTCDateStr.remove(jsUTCDateStr.length() - 5, 4); // get rid of milliseconds (".000") + QString qtUTCDateStr = qtDate.toUTC().toString(Qt::ISODate); + if (jsUTCDateStr != qtUTCDateStr) + QFAIL(qPrintable(qtDate.toString())); + qtDate = qtDate.addSecs(2*60*60); + } +} + +#if 0 // ###FIXME: No QScriptContext API +static QScriptValue createAnotherEngine(QScriptContext *, QScriptEngine *) +{ + QScriptEngine eng; + eng.evaluate("function foo(x, y) { return x + y; }" ); + eng.evaluate("hello = 5; world = 6" ); + return eng.evaluate("foo(hello,world)").toInt(); +} + + +void tst_QJSEngine::reentrency() +{ + QScriptEngine eng; + eng.globalObject().setProperty("foo", eng.newFunction(createAnotherEngine)); + eng.evaluate("function bar() { return foo(); } hello = 9; function getHello() { return hello; }"); + QCOMPARE(eng.evaluate("foo() + getHello() + foo()").toInt(), 5+6 + 9 + 5+6); + QCOMPARE(eng.evaluate("foo").call().toInt(), 5+6); + QCOMPARE(eng.evaluate("hello").toInt(), 9); + QCOMPARE(eng.evaluate("foo() + hello").toInt(), 5+6+9); +} +#endif + +#if 0 // ###FIXME: No QSCriptDeclarativeClass API +void tst_QJSEngine::newFixedStaticScopeObject() +{ + // "Static scope objects" is an optimization we do for QML. + // It enables the creation of JS objects that can guarantee to the + // compiler that no properties will be added or removed. This enables + // the compiler to generate a very simple (fast) property access, as + // opposed to a full virtual lookup. Due to the inherent use of scope + // chains in QML, this can make a huge difference (10x improvement for + // benchmark in QTBUG-8576). + // Ideally we would not need a special object type for this, and the + // VM would dynamically optimize it to be fast... + // See also QScriptEngine benchmark. + + QScriptEngine eng; + static const int propertyCount = 4; + QString names[] = { "foo", "bar", "baz", "Math" }; + QScriptValue values[] = { 123, "ciao", true, false }; + QScriptValue::PropertyFlags flags[] = { QScriptValue::Undeletable, + QScriptValue::ReadOnly | QScriptValue::Undeletable, + QScriptValue::SkipInEnumeration | QScriptValue::Undeletable, + QScriptValue::Undeletable }; + QScriptValue scope = QScriptDeclarativeClass::newStaticScopeObject(&eng, propertyCount, names, values, flags); + + // Query property. + for (int i = 0; i < propertyCount; ++i) { + for (int x = 0; x < 2; ++x) { + if (x) { + // Properties can't be deleted. + scope.setProperty(names[i], QScriptValue()); + } + QVERIFY(scope.property(names[i]).equals(values[i])); + } + } + + // Property that doesn't exist. + QVERIFY(scope.property("noSuchProperty").isUndefined()); + + // Write to writable property. + { + QScriptValue oldValue = scope.property("foo"); + QVERIFY(oldValue.isNumber()); + QScriptValue newValue = oldValue.toNumber() * 2; + scope.setProperty("foo", newValue); + QVERIFY(scope.property("foo").equals(newValue)); + scope.setProperty("foo", oldValue); + QVERIFY(scope.property("foo").equals(oldValue)); + } + + // Write to read-only property. + scope.setProperty("bar", 456); + QVERIFY(scope.property("bar").equals("ciao")); + + // Iterate. + { + QScriptValueIterator it(scope); + QSet iteratedNames; + while (it.hasNext()) { + it.next(); + iteratedNames.insert(it.name()); + } + for (int i = 0; i < propertyCount; ++i) + QVERIFY(iteratedNames.contains(names[i])); + } + + // Push it on the scope chain of a new context. + QScriptContext *ctx = eng.pushContext(); + ctx->pushScope(scope); + QCOMPARE(ctx->scopeChain().size(), 3); // Global Object, native activation, custom scope + QEXPECT_FAIL("", "activationObject has not been implemented yet", Continue); + QVERIFY(ctx->activationObject().equals(scope)); + + // Read property from JS. + for (int i = 0; i < propertyCount; ++i) { + for (int x = 0; x < 2; ++x) { + if (x) { + // Property can't be deleted from JS. + QScriptValue ret = eng.evaluate(QString::fromLatin1("delete %0").arg(names[i])); + QVERIFY(ret.equals(false)); + } + QVERIFY(eng.evaluate(names[i]).equals(values[i])); + } + } + + // Property that doesn't exist. + QVERIFY(eng.evaluate("noSuchProperty").equals("ReferenceError: noSuchProperty is not defined")); + + // Write property from JS. + { + QScriptValue oldValue = eng.evaluate("foo"); + QVERIFY(oldValue.isNumber()); + QScriptValue newValue = oldValue.toNumber() * 2; + QVERIFY(eng.evaluate("foo = foo * 2; foo").equals(newValue)); + scope.setProperty("foo", oldValue); + QVERIFY(eng.evaluate("foo").equals(oldValue)); + } + + // Write to read-only property. + QVERIFY(eng.evaluate("bar = 456; bar").equals("ciao")); + + // Create a closure and return properties from there. + { + QScriptValue props = eng.evaluate("(function() { var baz = 'shadow'; return [foo, bar, baz, Math, Array]; })()"); + QVERIFY(props.isArray()); + // "foo" and "bar" come from scope object. + QVERIFY(props.property(0).equals(scope.property("foo"))); + QVERIFY(props.property(1).equals(scope.property("bar"))); + // "baz" shadows property in scope object. + QVERIFY(props.property(2).equals("shadow")); + // "Math" comes from scope object, and shadows Global Object's "Math". + QVERIFY(props.property(3).equals(scope.property("Math"))); + QVERIFY(!props.property(3).equals(eng.globalObject().property("Math"))); + // "Array" comes from Global Object. + QVERIFY(props.property(4).equals(eng.globalObject().property("Array"))); + } + + // As with normal JS, assigning to an undefined variable will create + // the property on the Global Object, not the inner scope. + QVERIFY(eng.globalObject().property("newProperty").isUndefined()); + QVERIFY(eng.evaluate("(function() { newProperty = 789; })()").isUndefined()); + QVERIFY(!scope.property("newProperty").isUndefined()); + QVERIFY(eng.globalObject().property("newProperty").isNumber()); + + // Nested static scope. + { + static const int propertyCount2 = 2; + QString names2[] = { "foo", "hum" }; + QScriptValue values2[] = { 321, "hello" }; + QScriptValue::PropertyFlags flags2[] = { QScriptValue::Undeletable, + QScriptValue::ReadOnly | QScriptValue::Undeletable }; + QScriptValue scope2 = QScriptDeclarativeClass::newStaticScopeObject(&eng, propertyCount2, names2, values2, flags2); + ctx->pushScope(scope2); + + // "foo" shadows scope.foo. + QVERIFY(eng.evaluate("foo").equals(scope2.property("foo"))); + QVERIFY(!eng.evaluate("foo").equals(scope.property("foo"))); + // "hum" comes from scope2. + QVERIFY(eng.evaluate("hum").equals(scope2.property("hum"))); + // "Array" comes from Global Object. + QVERIFY(eng.evaluate("Array").equals(eng.globalObject().property("Array"))); + + ctx->popScope(); + } + + QScriptValue fun = eng.evaluate("(function() { return foo; })"); + QVERIFY(fun.isCallable()); + eng.popContext(); + // Function's scope chain persists after popContext(). + QVERIFY(fun.call().equals(scope.property("foo"))); +} + +void tst_QJSEngine::newGrowingStaticScopeObject() +{ + // The main use case for a growing static scope object is to set it as + // the activation object of a QScriptContext, so that all JS variable + // declarations end up in that object. It needs to be "growable" since + // we don't know in advance how many variables a script will declare. + + QScriptEngine eng; + QScriptValue scope = QScriptDeclarativeClass::newStaticScopeObject(&eng); + + // Initially empty. + QVERIFY(!QScriptValueIterator(scope).hasNext()); + QVERIFY(scope.property("foo").isUndefined()); + + // Add a static property. + scope.setProperty("foo", 123); + QVERIFY(scope.property("foo").equals(123)); + QEXPECT_FAIL("", "FIXME: newStaticScopeObject not properly implemented", Abort); + + // Modify existing property. + scope.setProperty("foo", 456); + QVERIFY(scope.property("foo").equals(456)); + + // Add a read-only property. + scope.setProperty("bar", "ciao", QScriptValue::ReadOnly); + QVERIFY(scope.property("bar").equals("ciao")); + + // Attempt to modify read-only property. + scope.setProperty("bar", "hello"); + QVERIFY(scope.property("bar").equals("ciao")); + + // Properties can't be deleted. + scope.setProperty("foo", QScriptValue()); + QVERIFY(scope.property("foo").equals(456)); + scope.setProperty("bar", QScriptValue()); + QVERIFY(scope.property("bar").equals("ciao")); + + // Iterate. + { + QScriptValueIterator it(scope); + QSet iteratedNames; + while (it.hasNext()) { + it.next(); + iteratedNames.insert(it.name()); + } + QCOMPARE(iteratedNames.size(), 2); + QVERIFY(iteratedNames.contains("foo")); + QVERIFY(iteratedNames.contains("bar")); + } + + // Push it on the scope chain of a new context. + QScriptContext *ctx = eng.pushContext(); + ctx->pushScope(scope); + QCOMPARE(ctx->scopeChain().size(), 3); // Global Object, native activation, custom scope + QVERIFY(ctx->activationObject().equals(scope)); + + // Read property from JS. + QVERIFY(eng.evaluate("foo").equals(scope.property("foo"))); + QVERIFY(eng.evaluate("bar").equals(scope.property("bar"))); + + // Write property from JS. + { + QScriptValue oldValue = eng.evaluate("foo"); + QVERIFY(oldValue.isNumber()); + QScriptValue newValue = oldValue.toNumber() * 2; + QVERIFY(eng.evaluate("foo = foo * 2; foo").equals(newValue)); + scope.setProperty("foo", oldValue); + QVERIFY(eng.evaluate("foo").equals(oldValue)); + } + + // Write to read-only property. + QVERIFY(eng.evaluate("bar = 456; bar").equals("ciao")); + + // Shadow property. + QVERIFY(eng.evaluate("Math").equals(eng.globalObject().property("Math"))); + scope.setProperty("Math", "fake Math"); + QVERIFY(eng.evaluate("Math").equals(scope.property("Math"))); + + // Variable declarations will create properties on the scope. + eng.evaluate("var baz = 456"); + QVERIFY(scope.property("baz").equals(456)); + + // Function declarations will create properties on the scope. + eng.evaluate("function fun() { return baz; }"); + QVERIFY(scope.property("fun").isCallable()); + QVERIFY(scope.property("fun").call().equals(scope.property("baz"))); + + // Demonstrate the limitation of a growable static scope: Once a function that + // uses the scope has been compiled, it won't pick up properties that are added + // to the scope later. + { + QScriptValue fun = eng.evaluate("(function() { return futureProperty; })"); + QVERIFY(fun.isCallable()); + QVERIFY(fun.call().toString().contains(QString::fromLatin1("ReferenceError"))); + scope.setProperty("futureProperty", "added after the function was compiled"); + // If scope were dynamic, this would return the new property. + QVERIFY(fun.call().toString().contains(QString::fromLatin1("ReferenceError"))); + } + + eng.popContext(); +} +#endif + +#if 0 // ###FIXME: No QScript MetaObject API +QT_BEGIN_NAMESPACE +Q_SCRIPT_DECLARE_QMETAOBJECT(QStandardItemModel, QObject*) +QT_END_NAMESPACE + +void tst_QJSEngine::scriptValueFromQMetaObject() +{ + QScriptEngine eng; + { + QScriptValue meta = eng.scriptValueFromQMetaObject(); + QVERIFY(meta.isQMetaObject()); + QCOMPARE(meta.toQMetaObject(), &QScriptEngine::staticMetaObject); + // Because of missing Q_SCRIPT_DECLARE_QMETAOBJECT() for QScriptEngine. + QEXPECT_FAIL("", "FIXME: because construct never returns invalid values", Continue); + QVERIFY(meta.callAsConstructor().isUndefined()); + } + { + QScriptValue meta = eng.scriptValueFromQMetaObject(); + QVERIFY(meta.isQMetaObject()); + QCOMPARE(meta.toQMetaObject(), &QStandardItemModel::staticMetaObject); + QScriptValue obj = meta.callAsConstructor(QScriptValueList() << eng.newQObject(&eng)); + QVERIFY(obj.isQObject()); + QStandardItemModel *model = qobject_cast(obj.toQObject()); + QVERIFY(model != 0); + QCOMPARE(model->parent(), (QObject*)&eng); + } +} +#endif + +void tst_QJSEngine::functionPrototypeExtensions() +{ + // QJS adds connect and disconnect properties to Function.prototype. + QJSEngine eng; + QJSValue funProto = eng.globalObject().property("Function").property("prototype"); + QVERIFY(funProto.isCallable()); + QVERIFY(funProto.property("connect").isCallable()); + QVERIFY(funProto.property("disconnect").isCallable()); + + // No properties should appear in for-in statements. + QJSValue props = eng.evaluate("props = []; for (var p in Function.prototype) props.push(p); props"); + QVERIFY(!eng.hasUncaughtException()); + QVERIFY(props.isArray()); + QCOMPARE(props.property("length").toInt(), 0); +} + +class ThreadedTestEngine : public QThread { + Q_OBJECT; + +public: + int result; + + ThreadedTestEngine() + : result(0) {} + + void run() { + QJSEngine firstEngine; + QJSEngine secondEngine; + QJSValue value = firstEngine.evaluate("1"); + result = secondEngine.evaluate("1 + " + QString::number(value.toInt())).toInt(); + } +}; + +void tst_QJSEngine::threadedEngine() +{ + ThreadedTestEngine thread1; + ThreadedTestEngine thread2; + thread1.start(); + thread2.start(); + thread1.wait(); + thread2.wait(); + QCOMPARE(thread1.result, 2); + QCOMPARE(thread2.result, 2); +} + +QTEST_MAIN(tst_QJSEngine) + +#include "tst_qjsengine.moc" + diff --git a/tests/auto/qml/qjsvalue/qjsvalue.pro b/tests/auto/qml/qjsvalue/qjsvalue.pro new file mode 100644 index 0000000000..19b983e549 --- /dev/null +++ b/tests/auto/qml/qjsvalue/qjsvalue.pro @@ -0,0 +1,6 @@ +CONFIG += testcase +TARGET = tst_qjsvalue +macx:CONFIG -= app_bundle +QT += qml widgets testlib +SOURCES += tst_qjsvalue.cpp +HEADERS += tst_qjsvalue.h diff --git a/tests/auto/qml/qjsvalue/tst_qjsvalue.cpp b/tests/auto/qml/qjsvalue/tst_qjsvalue.cpp new file mode 100644 index 0000000000..cec10ccf38 --- /dev/null +++ b/tests/auto/qml/qjsvalue/tst_qjsvalue.cpp @@ -0,0 +1,3655 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "tst_qjsvalue.h" +#include + +QT_BEGIN_NAMESPACE +extern bool qt_script_isJITEnabled(); +QT_END_NAMESPACE + +tst_QJSValue::tst_QJSValue() + : engine(0) +{ +} + +tst_QJSValue::~tst_QJSValue() +{ + if (engine) + delete engine; +} + +void tst_QJSValue::ctor_invalid() +{ + QJSEngine eng; + { + QJSValue v; + QVERIFY(v.isUndefined()); + QCOMPARE(v.engine(), (QJSEngine *)0); + } +} + +void tst_QJSValue::ctor_undefinedWithEngine() +{ + QJSEngine eng; + { + QJSValue v = eng.toScriptValue(QVariant()); + QVERIFY(v.isUndefined()); + QCOMPARE(v.isObject(), false); + QCOMPARE(v.engine(), &eng); + } +} + +void tst_QJSValue::ctor_nullWithEngine() +{ + QJSEngine eng; + { + QJSValue v = eng.evaluate("null"); + QVERIFY(!v.isUndefined()); + QCOMPARE(v.isNull(), true); + QCOMPARE(v.isObject(), false); + QCOMPARE(v.engine(), &eng); + } +} + +void tst_QJSValue::ctor_boolWithEngine() +{ + QJSEngine eng; + { + QJSValue v = eng.toScriptValue(false); + QVERIFY(!v.isUndefined()); + QCOMPARE(v.isBool(), true); + QCOMPARE(v.isObject(), false); + QCOMPARE(v.toBool(), false); + QCOMPARE(v.engine(), &eng); + } +} + +void tst_QJSValue::ctor_intWithEngine() +{ + QJSEngine eng; + { + QJSValue v = eng.toScriptValue(int(1)); + QVERIFY(!v.isUndefined()); + QCOMPARE(v.isNumber(), true); + QCOMPARE(v.isObject(), false); + QCOMPARE(v.toNumber(), 1.0); + QCOMPARE(v.engine(), &eng); + } +} + +void tst_QJSValue::ctor_int() +{ + { + QJSValue v(int(0x43211234)); + QVERIFY(v.isNumber()); + QCOMPARE(v.toInt(), 0x43211234); + } + { + QJSValue v(int(1)); + QVERIFY(!v.isUndefined()); + QCOMPARE(v.isNumber(), true); + QCOMPARE(v.isObject(), false); + QCOMPARE(v.toNumber(), 1.0); + QCOMPARE(v.engine(), (QJSEngine *)0); + } +} + +void tst_QJSValue::ctor_uintWithEngine() +{ + QJSEngine eng; + { + QJSValue v = eng.toScriptValue(uint(1)); + QVERIFY(!v.isUndefined()); + QCOMPARE(v.isNumber(), true); + QCOMPARE(v.isObject(), false); + QCOMPARE(v.toNumber(), 1.0); + QCOMPARE(v.engine(), &eng); + } +} + +void tst_QJSValue::ctor_uint() +{ + { + QJSValue v(uint(0x43211234)); + QVERIFY(v.isNumber()); + QCOMPARE(v.toUInt(), uint(0x43211234)); + } + { + QJSValue v(uint(1)); + QVERIFY(!v.isUndefined()); + QCOMPARE(v.isNumber(), true); + QCOMPARE(v.isObject(), false); + QCOMPARE(v.toNumber(), 1.0); + QCOMPARE(v.engine(), (QJSEngine *)0); + } +} + +void tst_QJSValue::ctor_floatWithEngine() +{ + QJSEngine eng; + { + QJSValue v = eng.toScriptValue(float(1.0)); + QVERIFY(!v.isUndefined()); + QCOMPARE(v.isNumber(), true); + QCOMPARE(v.isObject(), false); + QCOMPARE(v.toNumber(), 1.0); + QCOMPARE(v.engine(), &eng); + } +} + +void tst_QJSValue::ctor_float() +{ + { + QJSValue v(12345678910.5); + QVERIFY(v.isNumber()); + QCOMPARE(v.toNumber(), 12345678910.5); + } + { + QJSValue v(1.0); + QVERIFY(!v.isUndefined()); + QCOMPARE(v.isNumber(), true); + QCOMPARE(v.isObject(), false); + QCOMPARE(v.toNumber(), 1.0); + QCOMPARE(v.engine(), (QJSEngine *)0); + } +} + +void tst_QJSValue::ctor_stringWithEngine() +{ + QJSEngine eng; + { + QJSValue v = eng.toScriptValue(QString::fromLatin1("ciao")); + QVERIFY(!v.isUndefined()); + QCOMPARE(v.isString(), true); + QCOMPARE(v.isObject(), false); + QCOMPARE(v.toString(), QLatin1String("ciao")); + QCOMPARE(v.engine(), &eng); + } +} + +void tst_QJSValue::ctor_string() +{ + { + QJSValue v(QString("ciao")); + QVERIFY(!v.isUndefined()); + QCOMPARE(v.isString(), true); + QCOMPARE(v.isObject(), false); + QCOMPARE(v.toString(), QLatin1String("ciao")); + QCOMPARE(v.engine(), (QJSEngine *)0); + } + { + QJSValue v("ciao"); + QVERIFY(!v.isUndefined()); + QCOMPARE(v.isString(), true); + QCOMPARE(v.isObject(), false); + QCOMPARE(v.toString(), QLatin1String("ciao")); + QCOMPARE(v.engine(), (QJSEngine *)0); + } +} + +void tst_QJSValue::ctor_copyAndAssignWithEngine() +{ + QJSEngine eng; + // copy constructor, operator= + { + QJSValue v = eng.toScriptValue(1.0); + QJSValue v2(v); + QCOMPARE(v2.strictlyEquals(v), true); + QCOMPARE(v2.engine(), &eng); + + QJSValue v3(v); + QCOMPARE(v3.strictlyEquals(v), true); + QCOMPARE(v3.strictlyEquals(v2), true); + QCOMPARE(v3.engine(), &eng); + + QJSValue v4 = eng.toScriptValue(2.0); + QCOMPARE(v4.strictlyEquals(v), false); + v3 = v4; + QCOMPARE(v3.strictlyEquals(v), false); + QCOMPARE(v3.strictlyEquals(v4), true); + + v2 = QJSValue(); + QCOMPARE(v2.strictlyEquals(v), false); + QCOMPARE(v.toNumber(), 1.0); + + QJSValue v5(v); + QCOMPARE(v5.strictlyEquals(v), true); + v = QJSValue(); + QCOMPARE(v5.strictlyEquals(v), false); + QCOMPARE(v5.toNumber(), 1.0); + } +} + +void tst_QJSValue::ctor_undefined() +{ + QJSValue v(QJSValue::UndefinedValue); + QVERIFY(v.isUndefined()); + QCOMPARE(v.isObject(), false); + QCOMPARE(v.engine(), (QJSEngine *)0); +} + +void tst_QJSValue::ctor_null() +{ + QJSValue v(QJSValue::NullValue); + QVERIFY(!v.isUndefined()); + QCOMPARE(v.isNull(), true); + QCOMPARE(v.isObject(), false); + QCOMPARE(v.engine(), (QJSEngine *)0); +} + +void tst_QJSValue::ctor_bool() +{ + QJSValue v(false); + QVERIFY(!v.isUndefined()); + QCOMPARE(v.isBool(), true); + QCOMPARE(v.isBool(), true); + QCOMPARE(v.isObject(), false); + QCOMPARE(v.toBool(), false); + QCOMPARE(v.engine(), (QJSEngine *)0); +} + +void tst_QJSValue::ctor_copyAndAssign() +{ + QJSValue v(1.0); + QJSValue v2(v); + QCOMPARE(v2.strictlyEquals(v), true); + QCOMPARE(v2.engine(), (QJSEngine *)0); + + QJSValue v3(v); + QCOMPARE(v3.strictlyEquals(v), true); + QCOMPARE(v3.strictlyEquals(v2), true); + QCOMPARE(v3.engine(), (QJSEngine *)0); + + QJSValue v4(2.0); + QCOMPARE(v4.strictlyEquals(v), false); + v3 = v4; + QCOMPARE(v3.strictlyEquals(v), false); + QCOMPARE(v3.strictlyEquals(v4), true); + + v2 = QJSValue(); + QCOMPARE(v2.strictlyEquals(v), false); + QCOMPARE(v.toNumber(), 1.0); + + QJSValue v5(v); + QCOMPARE(v5.strictlyEquals(v), true); + v = QJSValue(); + QCOMPARE(v5.strictlyEquals(v), false); + QCOMPARE(v5.toNumber(), 1.0); +} + +#if 0 // FIXME: No c-style callbacks currently +static QJSValue myFunction(QScriptContext *, QScriptEngine *eng) +{ + return eng->undefinedValue(); +} +#endif + +void tst_QJSValue::toString() +{ + QJSEngine eng; + + QJSValue undefined = eng.toScriptValue(QVariant()); + QCOMPARE(undefined.toString(), QString("undefined")); + QCOMPARE(qjsvalue_cast(undefined), QString()); + + QJSValue null = eng.evaluate("null"); + QCOMPARE(null.toString(), QString("null")); + QCOMPARE(qjsvalue_cast(null), QString()); + + { + QJSValue falskt = eng.toScriptValue(false); + QCOMPARE(falskt.toString(), QString("false")); + QCOMPARE(qjsvalue_cast(falskt), QString("false")); + + QJSValue sant = eng.toScriptValue(true); + QCOMPARE(sant.toString(), QString("true")); + QCOMPARE(qjsvalue_cast(sant), QString("true")); + } + { + QJSValue number = eng.toScriptValue(123); + QCOMPARE(number.toString(), QString("123")); + QCOMPARE(qjsvalue_cast(number), QString("123")); + } + { + QJSValue number = eng.toScriptValue(6.37e-8); + QCOMPARE(number.toString(), QString("6.37e-8")); + } + { + QJSValue number = eng.toScriptValue(-6.37e-8); + QCOMPARE(number.toString(), QString("-6.37e-8")); + + QJSValue str = eng.toScriptValue(QString("ciao")); + QCOMPARE(str.toString(), QString("ciao")); + QCOMPARE(qjsvalue_cast(str), QString("ciao")); + } + + QJSValue object = eng.newObject(); + QCOMPARE(object.toString(), QString("[object Object]")); + QCOMPARE(qjsvalue_cast(object), QString("[object Object]")); + + // FIXME: No c-style callbacks currently +#if 0 + QJSValue fun = eng.newFunction(myFunction); + QCOMPARE(fun.toString().simplified(), QString("function () { [native code] }")); + QCOMPARE(qscriptvalue_cast(fun).simplified(), QString("function () { [native code] }")); +#endif + + // toString() that throws exception + { + QJSValue objectObject = eng.evaluate( + "(function(){" + " o = { };" + " o.toString = function() { throw new Error('toString'); };" + " return o;" + "})()"); + QCOMPARE(objectObject.toString(), QLatin1String("Error: toString")); + QVERIFY(eng.hasUncaughtException()); + QCOMPARE(eng.uncaughtException().toString(), QLatin1String("Error: toString")); + } + { + eng.clearExceptions(); + QJSValue objectObject = eng.evaluate( + "(function(){" + " var f = function() {};" + " f.prototype = Date;" + " return new f;" + "})()"); + QVERIFY(!eng.hasUncaughtException()); + QVERIFY(objectObject.isObject()); + QCOMPARE(objectObject.toString(), QString::fromLatin1("TypeError: Function.prototype.toString is not generic")); + QVERIFY(eng.hasUncaughtException()); + eng.clearExceptions(); + } + + QJSValue inv = QJSValue(); + QCOMPARE(inv.toString(), QString::fromLatin1("undefined")); + + // V2 constructors + { + QJSValue falskt = QJSValue(false); + QCOMPARE(falskt.toString(), QString("false")); + QCOMPARE(qjsvalue_cast(falskt), QString("false")); + + QJSValue sant = QJSValue(true); + QCOMPARE(sant.toString(), QString("true")); + QCOMPARE(qjsvalue_cast(sant), QString("true")); + + QJSValue number = QJSValue(123); + QCOMPARE(number.toString(), QString("123")); + QCOMPARE(qjsvalue_cast(number), QString("123")); + + QJSValue number2(int(0x43211234)); + QCOMPARE(number2.toString(), QString("1126240820")); + + QJSValue str = QJSValue(QString("ciao")); + QCOMPARE(str.toString(), QString("ciao")); + QCOMPARE(qjsvalue_cast(str), QString("ciao")); + } + + // variant should use internal valueOf(), then fall back to QVariant::toString(), + // then fall back to "QVariant(typename)" + QJSValue variant = eng.toScriptValue(QPoint(10, 20)); + QVERIFY(variant.isVariant()); + QCOMPARE(variant.toString(), QString::fromLatin1("QVariant(QPoint)")); + variant = eng.toScriptValue(QUrl()); + QVERIFY(variant.isVariant()); + QVERIFY(variant.toString().isEmpty()); +} + +void tst_QJSValue::toNumber() +{ + QJSEngine eng; + + QJSValue undefined = eng.toScriptValue(QVariant()); + QCOMPARE(qIsNaN(undefined.toNumber()), true); + QCOMPARE(qIsNaN(qjsvalue_cast(undefined)), true); + + QJSValue null = eng.evaluate("null"); + QCOMPARE(null.toNumber(), 0.0); + QCOMPARE(qjsvalue_cast(null), 0.0); + + { + QJSValue falskt = eng.toScriptValue(false); + QCOMPARE(falskt.toNumber(), 0.0); + QCOMPARE(qjsvalue_cast(falskt), 0.0); + + QJSValue sant = eng.toScriptValue(true); + QCOMPARE(sant.toNumber(), 1.0); + QCOMPARE(qjsvalue_cast(sant), 1.0); + + QJSValue number = eng.toScriptValue(123.0); + QCOMPARE(number.toNumber(), 123.0); + QCOMPARE(qjsvalue_cast(number), 123.0); + + QJSValue str = eng.toScriptValue(QString("ciao")); + QCOMPARE(qIsNaN(str.toNumber()), true); + QCOMPARE(qIsNaN(qjsvalue_cast(str)), true); + + QJSValue str2 = eng.toScriptValue(QString("123")); + QCOMPARE(str2.toNumber(), 123.0); + QCOMPARE(qjsvalue_cast(str2), 123.0); + } + + QJSValue object = eng.newObject(); + QCOMPARE(qIsNaN(object.toNumber()), true); + QCOMPARE(qIsNaN(qjsvalue_cast(object)), true); + + // FIXME: No c-style callbacks currently +#if 0 + QJSValue fun = eng.newFunction(myFunction); + QCOMPARE(qIsNaN(fun.toNumber()), true); + QCOMPARE(qIsNaN(qscriptvalue_cast(fun)), true); +#endif + + QJSValue inv = QJSValue(); + QVERIFY(qIsNaN(inv.toNumber())); + QVERIFY(qIsNaN(qjsvalue_cast(inv))); + + // V2 constructors + { + QJSValue falskt = QJSValue(false); + QCOMPARE(falskt.toNumber(), 0.0); + QCOMPARE(qjsvalue_cast(falskt), 0.0); + + QJSValue sant = QJSValue(true); + QCOMPARE(sant.toNumber(), 1.0); + QCOMPARE(qjsvalue_cast(sant), 1.0); + + QJSValue number = QJSValue(123.0); + QCOMPARE(number.toNumber(), 123.0); + QCOMPARE(qjsvalue_cast(number), 123.0); + + QJSValue number2(int(0x43211234)); + QCOMPARE(number2.toNumber(), 1126240820.0); + + QJSValue str = QJSValue(QString("ciao")); + QCOMPARE(qIsNaN(str.toNumber()), true); + QCOMPARE(qIsNaN(qjsvalue_cast(str)), true); + + QJSValue str2 = QJSValue(QString("123")); + QCOMPARE(str2.toNumber(), 123.0); + QCOMPARE(qjsvalue_cast(str2), 123.0); + } +} + +void tst_QJSValue::toBoolean() // deprecated +{ + QJSEngine eng; + + QJSValue undefined = eng.toScriptValue(QVariant()); + QCOMPARE(undefined.toBool(), false); + QCOMPARE(qjsvalue_cast(undefined), false); + + QJSValue null = eng.evaluate("null"); + QCOMPARE(null.toBool(), false); + QCOMPARE(qjsvalue_cast(null), false); + + { + QJSValue falskt = eng.toScriptValue(false); + QCOMPARE(falskt.toBool(), false); + QCOMPARE(qjsvalue_cast(falskt), false); + + QJSValue sant = eng.toScriptValue(true); + QCOMPARE(sant.toBool(), true); + QCOMPARE(qjsvalue_cast(sant), true); + + QJSValue number = eng.toScriptValue(0.0); + QCOMPARE(number.toBool(), false); + QCOMPARE(qjsvalue_cast(number), false); + + QJSValue number2 = eng.toScriptValue(qSNaN()); + QCOMPARE(number2.toBool(), false); + QCOMPARE(qjsvalue_cast(number2), false); + + QJSValue number3 = eng.toScriptValue(123.0); + QCOMPARE(number3.toBool(), true); + QCOMPARE(qjsvalue_cast(number3), true); + + QJSValue number4 = eng.toScriptValue(-456.0); + QCOMPARE(number4.toBool(), true); + QCOMPARE(qjsvalue_cast(number4), true); + + QJSValue str = eng.toScriptValue(QString("")); + QCOMPARE(str.toBool(), false); + QCOMPARE(qjsvalue_cast(str), false); + + QJSValue str2 = eng.toScriptValue(QString("123")); + QCOMPARE(str2.toBool(), true); + QCOMPARE(qjsvalue_cast(str2), true); + } + + QJSValue object = eng.newObject(); + QCOMPARE(object.toBool(), true); + QCOMPARE(qjsvalue_cast(object), true); + + // FIXME: No c-style callbacks currently +#if 0 + QJSValue fun = eng.newFunction(myFunction); + QCOMPARE(fun.toBoolean(), true); + QCOMPARE(qscriptvalue_cast(fun), true); +#endif + + QJSValue inv = QJSValue(); + QCOMPARE(inv.toBool(), false); + QCOMPARE(qjsvalue_cast(inv), false); + + // V2 constructors + { + QJSValue falskt = QJSValue(false); + QCOMPARE(falskt.toBool(), false); + QCOMPARE(qjsvalue_cast(falskt), false); + + QJSValue sant = QJSValue(true); + QCOMPARE(sant.toBool(), true); + QCOMPARE(qjsvalue_cast(sant), true); + + QJSValue number = QJSValue(0.0); + QCOMPARE(number.toBool(), false); + QCOMPARE(qjsvalue_cast(number), false); + + QJSValue number2 = QJSValue(qSNaN()); + QCOMPARE(number2.toBool(), false); + QCOMPARE(qjsvalue_cast(number2), false); + + QJSValue number3 = QJSValue(123.0); + QCOMPARE(number3.toBool(), true); + QCOMPARE(qjsvalue_cast(number3), true); + + QJSValue number4 = QJSValue(-456.0); + QCOMPARE(number4.toBool(), true); + QCOMPARE(qjsvalue_cast(number4), true); + + QJSValue number5 = QJSValue(0x43211234); + QCOMPARE(number5.toBool(), true); + + QJSValue str = QJSValue(QString("")); + QCOMPARE(str.toBool(), false); + QCOMPARE(qjsvalue_cast(str), false); + + QJSValue str2 = QJSValue(QString("123")); + QCOMPARE(str2.toBool(), true); + QCOMPARE(qjsvalue_cast(str2), true); + } +} + +void tst_QJSValue::toBool() +{ + QJSEngine eng; + + QJSValue undefined = eng.toScriptValue(QVariant()); + QCOMPARE(undefined.toBool(), false); + QCOMPARE(qjsvalue_cast(undefined), false); + + QJSValue null = eng.evaluate("null"); + QCOMPARE(null.toBool(), false); + QCOMPARE(qjsvalue_cast(null), false); + + { + QJSValue falskt = eng.toScriptValue(false); + QCOMPARE(falskt.toBool(), false); + QCOMPARE(qjsvalue_cast(falskt), false); + + QJSValue sant = eng.toScriptValue(true); + QCOMPARE(sant.toBool(), true); + QCOMPARE(qjsvalue_cast(sant), true); + + QJSValue number = eng.toScriptValue(0.0); + QCOMPARE(number.toBool(), false); + QCOMPARE(qjsvalue_cast(number), false); + + QJSValue number2 = eng.toScriptValue(qSNaN()); + QCOMPARE(number2.toBool(), false); + QCOMPARE(qjsvalue_cast(number2), false); + + QJSValue number3 = eng.toScriptValue(123.0); + QCOMPARE(number3.toBool(), true); + QCOMPARE(qjsvalue_cast(number3), true); + + QJSValue number4 = eng.toScriptValue(-456.0); + QCOMPARE(number4.toBool(), true); + QCOMPARE(qjsvalue_cast(number4), true); + + QJSValue str = eng.toScriptValue(QString("")); + QCOMPARE(str.toBool(), false); + QCOMPARE(qjsvalue_cast(str), false); + + QJSValue str2 = eng.toScriptValue(QString("123")); + QCOMPARE(str2.toBool(), true); + QCOMPARE(qjsvalue_cast(str2), true); + } + + QJSValue object = eng.newObject(); + QCOMPARE(object.toBool(), true); + QCOMPARE(qjsvalue_cast(object), true); + + // FIXME: No c-style callbacks currently +#if 0 + QJSValue fun = eng.newFunction(myFunction); + QCOMPARE(fun.toBool(), true); + QCOMPARE(qscriptvalue_cast(fun), true); +#endif + + QJSValue inv = QJSValue(); + QCOMPARE(inv.toBool(), false); + QCOMPARE(qjsvalue_cast(inv), false); + + // V2 constructors + { + QJSValue falskt = QJSValue(false); + QCOMPARE(falskt.toBool(), false); + QCOMPARE(qjsvalue_cast(falskt), false); + + QJSValue sant = QJSValue(true); + QCOMPARE(sant.toBool(), true); + QCOMPARE(qjsvalue_cast(sant), true); + + QJSValue number = QJSValue(0.0); + QCOMPARE(number.toBool(), false); + QCOMPARE(qjsvalue_cast(number), false); + + QJSValue number2 = QJSValue(qSNaN()); + QCOMPARE(number2.toBool(), false); + QCOMPARE(qjsvalue_cast(number2), false); + + QJSValue number3 = QJSValue(123.0); + QCOMPARE(number3.toBool(), true); + QCOMPARE(qjsvalue_cast(number3), true); + + QJSValue number4 = QJSValue(-456.0); + QCOMPARE(number4.toBool(), true); + QCOMPARE(qjsvalue_cast(number4), true); + + QJSValue number5 = QJSValue(0x43211234); + QCOMPARE(number5.toBool(), true); + + QJSValue str = QJSValue(QString("")); + QCOMPARE(str.toBool(), false); + QCOMPARE(qjsvalue_cast(str), false); + + QJSValue str2 = QJSValue(QString("123")); + QCOMPARE(str2.toBool(), true); + QCOMPARE(qjsvalue_cast(str2), true); + } +} + +void tst_QJSValue::toInt() +{ + QJSEngine eng; + + { + QJSValue zer0 = eng.toScriptValue(0.0); + QCOMPARE(zer0.toInt(), 0); + QCOMPARE(qjsvalue_cast(zer0), 0); + + QJSValue number = eng.toScriptValue(123.0); + QCOMPARE(number.toInt(), 123); + QCOMPARE(qjsvalue_cast(number), 123); + + QJSValue number2 = eng.toScriptValue(qSNaN()); + QCOMPARE(number2.toInt(), 0); + QCOMPARE(qjsvalue_cast(number2), 0); + + QJSValue number3 = eng.toScriptValue(+qInf()); + QCOMPARE(number3.toInt(), 0); + QCOMPARE(qjsvalue_cast(number3), 0); + + QJSValue number3_2 = eng.toScriptValue(-qInf()); + QCOMPARE(number3_2.toInt(), 0); + QCOMPARE(qjsvalue_cast(number3_2), 0); + + QJSValue number4 = eng.toScriptValue(0.5); + QCOMPARE(number4.toInt(), 0); + QCOMPARE(qjsvalue_cast(number4), 0); + + QJSValue number5 = eng.toScriptValue(123.5); + QCOMPARE(number5.toInt(), 123); + QCOMPARE(qjsvalue_cast(number5), 123); + + QJSValue number6 = eng.toScriptValue(-456.5); + QCOMPARE(number6.toInt(), -456); + QCOMPARE(qjsvalue_cast(number6), -456); + + QJSValue str = eng.toScriptValue(QString::fromLatin1("123.0")); + QCOMPARE(str.toInt(), 123); + QCOMPARE(qjsvalue_cast(str), 123); + + QJSValue str2 = eng.toScriptValue(QString::fromLatin1("NaN")); + QCOMPARE(str2.toInt(), 0); + QCOMPARE(qjsvalue_cast(str2), 0); + + QJSValue str3 = eng.toScriptValue(QString::fromLatin1("Infinity")); + QCOMPARE(str3.toInt(), 0); + QCOMPARE(qjsvalue_cast(str3), 0); + + QJSValue str3_2 = eng.toScriptValue(QString::fromLatin1("-Infinity")); + QCOMPARE(str3_2.toInt(), 0); + QCOMPARE(qjsvalue_cast(str3_2), 0); + + QJSValue str4 = eng.toScriptValue(QString::fromLatin1("0.5")); + QCOMPARE(str4.toInt(), 0); + QCOMPARE(qjsvalue_cast(str4), 0); + + QJSValue str5 = eng.toScriptValue(QString::fromLatin1("123.5")); + QCOMPARE(str5.toInt(), 123); + QCOMPARE(qjsvalue_cast(str5), 123); + + QJSValue str6 = eng.toScriptValue(QString::fromLatin1("-456.5")); + QCOMPARE(str6.toInt(), -456); + QCOMPARE(qjsvalue_cast(str6), -456); + } + // V2 constructors + { + QJSValue zer0 = QJSValue(0.0); + QCOMPARE(zer0.toInt(), 0); + QCOMPARE(qjsvalue_cast(zer0), 0); + + QJSValue number = QJSValue(123.0); + QCOMPARE(number.toInt(), 123); + QCOMPARE(qjsvalue_cast(number), 123); + + QJSValue number2 = QJSValue(qSNaN()); + QCOMPARE(number2.toInt(), 0); + QCOMPARE(qjsvalue_cast(number2), 0); + + QJSValue number3 = QJSValue(+qInf()); + QCOMPARE(number3.toInt(), 0); + QCOMPARE(qjsvalue_cast(number3), 0); + + QJSValue number3_2 = QJSValue(-qInf()); + QCOMPARE(number3_2.toInt(), 0); + QCOMPARE(qjsvalue_cast(number3_2), 0); + + QJSValue number4 = QJSValue(0.5); + QCOMPARE(number4.toInt(), 0); + QCOMPARE(qjsvalue_cast(number4), 0); + + QJSValue number5 = QJSValue(123.5); + QCOMPARE(number5.toInt(), 123); + QCOMPARE(qjsvalue_cast(number5), 123); + + QJSValue number6 = QJSValue(-456.5); + QCOMPARE(number6.toInt(), -456); + QCOMPARE(qjsvalue_cast(number6), -456); + + QJSValue number7 = QJSValue(0x43211234); + QCOMPARE(number7.toInt(), 0x43211234); + + QJSValue str = QJSValue("123.0"); + QCOMPARE(str.toInt(), 123); + QCOMPARE(qjsvalue_cast(str), 123); + + QJSValue str2 = QJSValue("NaN"); + QCOMPARE(str2.toInt(), 0); + QCOMPARE(qjsvalue_cast(str2), 0); + + QJSValue str3 = QJSValue("Infinity"); + QCOMPARE(str3.toInt(), 0); + QCOMPARE(qjsvalue_cast(str3), 0); + + QJSValue str3_2 = QJSValue("-Infinity"); + QCOMPARE(str3_2.toInt(), 0); + QCOMPARE(qjsvalue_cast(str3_2), 0); + + QJSValue str4 = QJSValue("0.5"); + QCOMPARE(str4.toInt(), 0); + QCOMPARE(qjsvalue_cast(str4), 0); + + QJSValue str5 = QJSValue("123.5"); + QCOMPARE(str5.toInt(), 123); + QCOMPARE(qjsvalue_cast(str5), 123); + + QJSValue str6 = QJSValue("-456.5"); + QCOMPARE(str6.toInt(), -456); + QCOMPARE(qjsvalue_cast(str6), -456); + } + + QJSValue inv; + QCOMPARE(inv.toInt(), 0); + QCOMPARE(qjsvalue_cast(inv), 0); +} + +void tst_QJSValue::toUInt() +{ + QJSEngine eng; + + { + QJSValue zer0 = eng.toScriptValue(0.0); + QCOMPARE(zer0.toUInt(), quint32(0)); + QCOMPARE(qjsvalue_cast(zer0), quint32(0)); + + QJSValue number = eng.toScriptValue(123.0); + QCOMPARE(number.toUInt(), quint32(123)); + QCOMPARE(qjsvalue_cast(number), quint32(123)); + + QJSValue number2 = eng.toScriptValue(qSNaN()); + QCOMPARE(number2.toUInt(), quint32(0)); + QCOMPARE(qjsvalue_cast(number2), quint32(0)); + + QJSValue number3 = eng.toScriptValue(+qInf()); + QCOMPARE(number3.toUInt(), quint32(0)); + QCOMPARE(qjsvalue_cast(number3), quint32(0)); + + QJSValue number3_2 = eng.toScriptValue(-qInf()); + QCOMPARE(number3_2.toUInt(), quint32(0)); + QCOMPARE(qjsvalue_cast(number3_2), quint32(0)); + + QJSValue number4 = eng.toScriptValue(0.5); + QCOMPARE(number4.toUInt(), quint32(0)); + + QJSValue number5 = eng.toScriptValue(123.5); + QCOMPARE(number5.toUInt(), quint32(123)); + + QJSValue number6 = eng.toScriptValue(-456.5); + QCOMPARE(number6.toUInt(), quint32(-456)); + QCOMPARE(qjsvalue_cast(number6), quint32(-456)); + + QJSValue str = eng.toScriptValue(QString::fromLatin1("123.0")); + QCOMPARE(str.toUInt(), quint32(123)); + QCOMPARE(qjsvalue_cast(str), quint32(123)); + + QJSValue str2 = eng.toScriptValue(QString::fromLatin1("NaN")); + QCOMPARE(str2.toUInt(), quint32(0)); + QCOMPARE(qjsvalue_cast(str2), quint32(0)); + + QJSValue str3 = eng.toScriptValue(QString::fromLatin1("Infinity")); + QCOMPARE(str3.toUInt(), quint32(0)); + QCOMPARE(qjsvalue_cast(str3), quint32(0)); + + QJSValue str3_2 = eng.toScriptValue(QString::fromLatin1("-Infinity")); + QCOMPARE(str3_2.toUInt(), quint32(0)); + QCOMPARE(qjsvalue_cast(str3_2), quint32(0)); + + QJSValue str4 = eng.toScriptValue(QString::fromLatin1("0.5")); + QCOMPARE(str4.toUInt(), quint32(0)); + QCOMPARE(qjsvalue_cast(str4), quint32(0)); + + QJSValue str5 = eng.toScriptValue(QString::fromLatin1("123.5")); + QCOMPARE(str5.toUInt(), quint32(123)); + QCOMPARE(qjsvalue_cast(str5), quint32(123)); + + QJSValue str6 = eng.toScriptValue(QString::fromLatin1("-456.5")); + QCOMPARE(str6.toUInt(), quint32(-456)); + QCOMPARE(qjsvalue_cast(str6), quint32(-456)); + } + // V2 constructors + { + QJSValue zer0 = QJSValue(0.0); + QCOMPARE(zer0.toUInt(), quint32(0)); + QCOMPARE(qjsvalue_cast(zer0), quint32(0)); + + QJSValue number = QJSValue(123.0); + QCOMPARE(number.toUInt(), quint32(123)); + QCOMPARE(qjsvalue_cast(number), quint32(123)); + + QJSValue number2 = QJSValue(qSNaN()); + QCOMPARE(number2.toUInt(), quint32(0)); + QCOMPARE(qjsvalue_cast(number2), quint32(0)); + + QJSValue number3 = QJSValue(+qInf()); + QCOMPARE(number3.toUInt(), quint32(0)); + QCOMPARE(qjsvalue_cast(number3), quint32(0)); + + QJSValue number3_2 = QJSValue(-qInf()); + QCOMPARE(number3_2.toUInt(), quint32(0)); + QCOMPARE(qjsvalue_cast(number3_2), quint32(0)); + + QJSValue number4 = QJSValue(0.5); + QCOMPARE(number4.toUInt(), quint32(0)); + + QJSValue number5 = QJSValue(123.5); + QCOMPARE(number5.toUInt(), quint32(123)); + + QJSValue number6 = QJSValue(-456.5); + QCOMPARE(number6.toUInt(), quint32(-456)); + QCOMPARE(qjsvalue_cast(number6), quint32(-456)); + + QJSValue number7 = QJSValue(0x43211234); + QCOMPARE(number7.toUInt(), quint32(0x43211234)); + + QJSValue str = QJSValue(QLatin1String("123.0")); + QCOMPARE(str.toUInt(), quint32(123)); + QCOMPARE(qjsvalue_cast(str), quint32(123)); + + QJSValue str2 = QJSValue(QLatin1String("NaN")); + QCOMPARE(str2.toUInt(), quint32(0)); + QCOMPARE(qjsvalue_cast(str2), quint32(0)); + + QJSValue str3 = QJSValue(QLatin1String("Infinity")); + QCOMPARE(str3.toUInt(), quint32(0)); + QCOMPARE(qjsvalue_cast(str3), quint32(0)); + + QJSValue str3_2 = QJSValue(QLatin1String("-Infinity")); + QCOMPARE(str3_2.toUInt(), quint32(0)); + QCOMPARE(qjsvalue_cast(str3_2), quint32(0)); + + QJSValue str4 = QJSValue(QLatin1String("0.5")); + QCOMPARE(str4.toUInt(), quint32(0)); + QCOMPARE(qjsvalue_cast(str4), quint32(0)); + + QJSValue str5 = QJSValue(QLatin1String("123.5")); + QCOMPARE(str5.toUInt(), quint32(123)); + QCOMPARE(qjsvalue_cast(str5), quint32(123)); + + QJSValue str6 = QJSValue(QLatin1String("-456.5")); + QCOMPARE(str6.toUInt(), quint32(-456)); + QCOMPARE(qjsvalue_cast(str6), quint32(-456)); + } + + QJSValue inv; + QCOMPARE(inv.toUInt(), quint32(0)); + QCOMPARE(qjsvalue_cast(inv), quint32(0)); +} + +#if defined Q_CC_MSVC && _MSC_VER < 1300 +Q_DECLARE_METATYPE(QVariant) +#endif + +void tst_QJSValue::toVariant() +{ + QJSEngine eng; + + QJSValue undefined = eng.toScriptValue(QVariant()); + QCOMPARE(undefined.toVariant(), QVariant()); + QCOMPARE(qjsvalue_cast(undefined), QVariant()); + + QJSValue null = eng.evaluate("null"); + QCOMPARE(null.toVariant(), QVariant()); + QCOMPARE(qjsvalue_cast(null), QVariant()); + + { + QJSValue number = eng.toScriptValue(123.0); + QCOMPARE(number.toVariant(), QVariant(123.0)); + QCOMPARE(qjsvalue_cast(number), QVariant(123.0)); + + QJSValue intNumber = eng.toScriptValue((qint32)123); + QCOMPARE(intNumber.toVariant().type(), QVariant((qint32)123).type()); + QCOMPARE((qjsvalue_cast(number)).type(), QVariant((qint32)123).type()); + + QJSValue falskt = eng.toScriptValue(false); + QCOMPARE(falskt.toVariant(), QVariant(false)); + QCOMPARE(qjsvalue_cast(falskt), QVariant(false)); + + QJSValue sant = eng.toScriptValue(true); + QCOMPARE(sant.toVariant(), QVariant(true)); + QCOMPARE(qjsvalue_cast(sant), QVariant(true)); + + QJSValue str = eng.toScriptValue(QString("ciao")); + QCOMPARE(str.toVariant(), QVariant(QString("ciao"))); + QCOMPARE(qjsvalue_cast(str), QVariant(QString("ciao"))); + } + + QJSValue object = eng.newObject(); + QCOMPARE(object.toVariant(), QVariant(QVariantMap())); + + QJSValue qobject = eng.newQObject(this); + { + QVariant var = qobject.toVariant(); + QCOMPARE(var.userType(), int(QMetaType::QObjectStar)); + QCOMPARE(qVariantValue(var), (QObject *)this); + } + + { + QDateTime dateTime = QDateTime(QDate(1980, 10, 4)); + QJSValue dateObject = eng.toScriptValue(dateTime); + QVariant var = dateObject.toVariant(); + QCOMPARE(var, QVariant(dateTime)); + } + + { + QRegExp rx = QRegExp("[0-9a-z]+", Qt::CaseSensitive, QRegExp::RegExp2); + QJSValue rxObject = eng.toScriptValue(rx); + QVERIFY(rxObject.isRegExp()); + QVariant var = rxObject.toVariant(); + QCOMPARE(var, QVariant(rx)); + } + + QJSValue inv; + QCOMPARE(inv.toVariant(), QVariant()); + QCOMPARE(qjsvalue_cast(inv), QVariant()); + + // V2 constructors + { + QJSValue number = QJSValue(123.0); + QCOMPARE(number.toVariant(), QVariant(123.0)); + QCOMPARE(qjsvalue_cast(number), QVariant(123.0)); + + QJSValue falskt = QJSValue(false); + QCOMPARE(falskt.toVariant(), QVariant(false)); + QCOMPARE(qjsvalue_cast(falskt), QVariant(false)); + + QJSValue sant = QJSValue(true); + QCOMPARE(sant.toVariant(), QVariant(true)); + QCOMPARE(qjsvalue_cast(sant), QVariant(true)); + + QJSValue str = QJSValue(QString("ciao")); + QCOMPARE(str.toVariant(), QVariant(QString("ciao"))); + QCOMPARE(qjsvalue_cast(str), QVariant(QString("ciao"))); + } + +#if 0 // FIXME: No automatic sequence conversion + // array + { + QVariantList listIn; + listIn << 123 << "hello"; + QJSValue array = qScriptValueFromValue(&eng, listIn); + QVERIFY(array.isArray()); + QCOMPARE(array.property("length").toInt(), 2); + QVariant ret = array.toVariant(); + QCOMPARE(ret.type(), QVariant::List); + QVariantList listOut = ret.toList(); + QCOMPARE(listOut.size(), listIn.size()); + for (int i = 0; i < listIn.size(); ++i) + QVERIFY(listOut.at(i) == listIn.at(i)); + // round-trip conversion + QJSValue array2 = qScriptValueFromValue(&eng, ret); + QVERIFY(array2.isArray()); + QCOMPARE(array2.property("length").toInt(), array.property("length").toInt()); + for (int i = 0; i < array.property("length").toInt(); ++i) + QVERIFY(array2.property(i).strictlyEquals(array.property(i))); + } +#endif +} + +void tst_QJSValue::toQObject_nonQObject_data() +{ + newEngine(); + QTest::addColumn("value"); + + QTest::newRow("invalid") << QJSValue(); + QTest::newRow("bool(false)") << QJSValue(false); + QTest::newRow("bool(true)") << QJSValue(true); + QTest::newRow("int") << QJSValue(123); + QTest::newRow("string") << QJSValue(QString::fromLatin1("ciao")); + QTest::newRow("undefined") << QJSValue(QJSValue::UndefinedValue); + QTest::newRow("null") << QJSValue(QJSValue::NullValue); + + QTest::newRow("bool bound(false)") << engine->toScriptValue(false); + QTest::newRow("bool bound(true)") << engine->toScriptValue(true); + QTest::newRow("int bound") << engine->toScriptValue(123); + QTest::newRow("string bound") << engine->toScriptValue(QString::fromLatin1("ciao")); + QTest::newRow("undefined bound") << engine->toScriptValue(QVariant()); + QTest::newRow("null bound") << engine->evaluate("null"); + QTest::newRow("object") << engine->newObject(); + QTest::newRow("array") << engine->newArray(); + QTest::newRow("date") << engine->evaluate("new Date(124)"); + QTest::newRow("variant(12345)") << engine->toScriptValue(QVariant(12345)); + QTest::newRow("variant((QObject*)0)") << engine->toScriptValue(qVariantFromValue((QObject*)0)); + QTest::newRow("newQObject(0)") << engine->newQObject(0); +} + + +void tst_QJSValue::toQObject_nonQObject() +{ + QFETCH(QJSValue, value); + QCOMPARE(value.toQObject(), (QObject *)0); + QCOMPARE(qjsvalue_cast(value), (QObject *)0); +} + +// unfortunately, this is necessary in order to do qscriptvalue_cast(...) +Q_DECLARE_METATYPE(QPushButton*); + +void tst_QJSValue::toQObject() +{ + QJSEngine eng; + + QJSValue qobject = eng.newQObject(this); + QCOMPARE(qobject.toQObject(), (QObject *)this); + QCOMPARE(qjsvalue_cast(qobject), (QObject *)this); + QCOMPARE(qjsvalue_cast(qobject), (QWidget *)0); + + QWidget widget; + QJSValue qwidget = eng.newQObject(&widget); + QCOMPARE(qwidget.toQObject(), (QObject *)&widget); + QCOMPARE(qjsvalue_cast(qwidget), (QObject *)&widget); + QCOMPARE(qjsvalue_cast(qwidget), &widget); + + QPushButton button; + QJSValue qbutton = eng.newQObject(&button); + QCOMPARE(qbutton.toQObject(), (QObject *)&button); + QCOMPARE(qjsvalue_cast(qbutton), (QObject *)&button); + QCOMPARE(qjsvalue_cast(qbutton), (QWidget *)&button); + QCOMPARE(qjsvalue_cast(qbutton), &button); +} + +void tst_QJSValue::toDateTime() +{ + QJSEngine eng; + QDateTime dt = eng.evaluate("new Date(0)").toDateTime(); + QVERIFY(dt.isValid()); + QCOMPARE(dt.timeSpec(), Qt::LocalTime); + QCOMPARE(dt.toUTC(), QDateTime(QDate(1970, 1, 1), QTime(0, 0, 0), Qt::UTC)); + + QVERIFY(!eng.evaluate("[]").toDateTime().isValid()); + QVERIFY(!eng.evaluate("{}").toDateTime().isValid()); + QVERIFY(!eng.globalObject().toDateTime().isValid()); + QVERIFY(!QJSValue().toDateTime().isValid()); + QVERIFY(!QJSValue(123).toDateTime().isValid()); + QVERIFY(!QJSValue(false).toDateTime().isValid()); + QVERIFY(!eng.evaluate("null").toDateTime().isValid()); + QVERIFY(!eng.toScriptValue(QVariant()).toDateTime().isValid()); +} + +void tst_QJSValue::toRegExp() +{ + QJSEngine eng; + { + QRegExp rx = qjsvalue_cast(eng.evaluate("/foo/")); + QVERIFY(rx.isValid()); + QCOMPARE(rx.patternSyntax(), QRegExp::RegExp2); + QCOMPARE(rx.pattern(), QString::fromLatin1("foo")); + QCOMPARE(rx.caseSensitivity(), Qt::CaseSensitive); + QVERIFY(!rx.isMinimal()); + } + { + QRegExp rx = qjsvalue_cast(eng.evaluate("/bar/gi")); + QVERIFY(rx.isValid()); + QCOMPARE(rx.patternSyntax(), QRegExp::RegExp2); + QCOMPARE(rx.pattern(), QString::fromLatin1("bar")); + QCOMPARE(rx.caseSensitivity(), Qt::CaseInsensitive); + QVERIFY(!rx.isMinimal()); + } + + QVERIFY(qjsvalue_cast(eng.evaluate("[]")).isEmpty()); + QVERIFY(qjsvalue_cast(eng.evaluate("{}")).isEmpty()); + QVERIFY(qjsvalue_cast(eng.globalObject()).isEmpty()); + QVERIFY(qjsvalue_cast(QJSValue()).isEmpty()); + QVERIFY(qjsvalue_cast(QJSValue(123)).isEmpty()); + QVERIFY(qjsvalue_cast(QJSValue(false)).isEmpty()); + QVERIFY(qjsvalue_cast(eng.evaluate("null")).isEmpty()); + QVERIFY(qjsvalue_cast(eng.toScriptValue(QVariant())).isEmpty()); +} + +void tst_QJSValue::isArray_data() +{ + newEngine(); + + QTest::addColumn("value"); + QTest::addColumn("array"); + + QTest::newRow("[]") << engine->evaluate("[]") << true; + QTest::newRow("{}") << engine->evaluate("{}") << false; + QTest::newRow("globalObject") << engine->globalObject() << false; + QTest::newRow("invalid") << QJSValue() << false; + QTest::newRow("number") << QJSValue(123) << false; + QTest::newRow("bool") << QJSValue(false) << false; + QTest::newRow("null") << engine->evaluate("null") << false; + QTest::newRow("undefined") << engine->toScriptValue(QVariant()) << false; +} + +void tst_QJSValue::isArray() +{ + QFETCH(QJSValue, value); + QFETCH(bool, array); + + QCOMPARE(value.isArray(), array); +} + +void tst_QJSValue::isDate_data() +{ + newEngine(); + + QTest::addColumn("value"); + QTest::addColumn("date"); + + QTest::newRow("date") << engine->evaluate("new Date()") << true; + QTest::newRow("[]") << engine->evaluate("[]") << false; + QTest::newRow("{}") << engine->evaluate("{}") << false; + QTest::newRow("globalObject") << engine->globalObject() << false; + QTest::newRow("invalid") << QJSValue() << false; + QTest::newRow("number") << QJSValue(123) << false; + QTest::newRow("bool") << QJSValue(false) << false; + QTest::newRow("null") << engine->evaluate("null") << false; + QTest::newRow("undefined") << engine->toScriptValue(QVariant()) << false; +} + +void tst_QJSValue::isDate() +{ + QFETCH(QJSValue, value); + QFETCH(bool, date); + + QCOMPARE(value.isDate(), date); +} + +void tst_QJSValue::isError_propertiesOfGlobalObject() +{ + QStringList errors; + errors << "Error" + << "EvalError" + << "RangeError" + << "ReferenceError" + << "SyntaxError" + << "TypeError" + << "URIError"; + QJSEngine eng; + for (int i = 0; i < errors.size(); ++i) { + QJSValue ctor = eng.globalObject().property(errors.at(i)); + QVERIFY(ctor.isCallable()); + QVERIFY(ctor.property("prototype").isError()); + } +} + +void tst_QJSValue::isError_data() +{ + newEngine(); + + QTest::addColumn("value"); + QTest::addColumn("error"); + + QTest::newRow("syntax error") << engine->evaluate("%fsdg's") << true; + QTest::newRow("[]") << engine->evaluate("[]") << false; + QTest::newRow("{}") << engine->evaluate("{}") << false; + QTest::newRow("globalObject") << engine->globalObject() << false; + QTest::newRow("invalid") << QJSValue() << false; + QTest::newRow("number") << QJSValue(123) << false; + QTest::newRow("bool") << QJSValue(false) << false; + QTest::newRow("null") << engine->evaluate("null") << false; + QTest::newRow("undefined") << engine->toScriptValue(QVariant()) << false; + QTest::newRow("newObject") << engine->newObject() << false; + QTest::newRow("new Object") << engine->evaluate("new Object()") << false; +} + +void tst_QJSValue::isError() +{ + QFETCH(QJSValue, value); + QFETCH(bool, error); + + QCOMPARE(value.isError(), error); +} + +void tst_QJSValue::isRegExp_data() +{ + newEngine(); + + QTest::addColumn("value"); + QTest::addColumn("regexp"); + + QTest::newRow("/foo/") << engine->evaluate("/foo/") << true; + QTest::newRow("[]") << engine->evaluate("[]") << false; + QTest::newRow("{}") << engine->evaluate("{}") << false; + QTest::newRow("globalObject") << engine->globalObject() << false; + QTest::newRow("invalid") << QJSValue() << false; + QTest::newRow("number") << QJSValue(123) << false; + QTest::newRow("bool") << QJSValue(false) << false; + QTest::newRow("null") << engine->evaluate("null") << false; + QTest::newRow("undefined") << engine->toScriptValue(QVariant()) << false; +} + +void tst_QJSValue::isRegExp() +{ + QFETCH(QJSValue, value); + QFETCH(bool, regexp); + + QCOMPARE(value.isRegExp(), regexp); +} + +#if 0 // FIXME: No c-style callbacks currently +static QJSValue getter(QScriptContext *ctx, QScriptEngine *) +{ + return ctx->thisObject().property("x"); +} + +static QJSValue setter(QScriptContext *ctx, QScriptEngine *) +{ + ctx->thisObject().setProperty("x", ctx->argument(0)); + return ctx->argument(0); +} + +static QJSValue getterSetter(QScriptContext *ctx, QScriptEngine *) +{ + if (ctx->argumentCount() > 0) + ctx->thisObject().setProperty("x", ctx->argument(0)); + return ctx->thisObject().property("x"); +} + +static QJSValue getterSetterThrowingError(QScriptContext *ctx, QScriptEngine *) +{ + if (ctx->argumentCount() > 0) + return ctx->throwError("set foo"); + else + return ctx->throwError("get foo"); +} + +static QJSValue getSet__proto__(QScriptContext *ctx, QScriptEngine *) +{ + if (ctx->argumentCount() > 0) + ctx->callee().setProperty("value", ctx->argument(0)); + return ctx->callee().property("value"); +} +#endif + +void tst_QJSValue::hasProperty_basic() +{ + QJSEngine eng; + QJSValue obj = eng.newObject(); + QVERIFY(obj.hasProperty("hasOwnProperty")); // inherited from Object.prototype + QVERIFY(!obj.hasOwnProperty("hasOwnProperty")); + + QVERIFY(!obj.hasProperty("foo")); + QVERIFY(!obj.hasOwnProperty("foo")); + obj.setProperty("foo", 123); + QVERIFY(obj.hasProperty("foo")); + QVERIFY(obj.hasOwnProperty("foo")); + + QVERIFY(!obj.hasProperty("bar")); + QVERIFY(!obj.hasOwnProperty("bar")); +} + +void tst_QJSValue::hasProperty_globalObject() +{ + QJSEngine eng; + QJSValue global = eng.globalObject(); + QVERIFY(global.hasProperty("Math")); + QVERIFY(global.hasOwnProperty("Math")); + QVERIFY(!global.hasProperty("NoSuchStandardProperty")); + QVERIFY(!global.hasOwnProperty("NoSuchStandardProperty")); + + QVERIFY(!global.hasProperty("foo")); + QVERIFY(!global.hasOwnProperty("foo")); + global.setProperty("foo", 123); + QVERIFY(global.hasProperty("foo")); + QVERIFY(global.hasOwnProperty("foo")); +} + +void tst_QJSValue::hasProperty_changePrototype() +{ + QJSEngine eng; + QJSValue obj = eng.newObject(); + QJSValue proto = eng.newObject(); + obj.setPrototype(proto); + + QVERIFY(!obj.hasProperty("foo")); + QVERIFY(!obj.hasOwnProperty("foo")); + proto.setProperty("foo", 123); + QVERIFY(obj.hasProperty("foo")); + QVERIFY(!obj.hasOwnProperty("foo")); + + obj.setProperty("foo", 456); // override prototype property + QVERIFY(obj.hasProperty("foo")); + QVERIFY(obj.hasOwnProperty("foo")); +} + +void tst_QJSValue::deleteProperty_basic() +{ + QJSEngine eng; + QJSValue obj = eng.newObject(); + // deleteProperty() behavior matches JS delete operator + QVERIFY(obj.deleteProperty("foo")); + + obj.setProperty("foo", 123); + QVERIFY(obj.deleteProperty("foo")); + QVERIFY(!obj.hasOwnProperty("foo")); +} + +void tst_QJSValue::deleteProperty_globalObject() +{ + QJSEngine eng; + QJSValue global = eng.globalObject(); + // deleteProperty() behavior matches JS delete operator + QVERIFY(global.deleteProperty("foo")); + + global.setProperty("foo", 123); + QVERIFY(global.deleteProperty("foo")); + QVERIFY(!global.hasProperty("foo")); + + QVERIFY(global.deleteProperty("Math")); + QVERIFY(!global.hasProperty("Math")); + + QVERIFY(!global.deleteProperty("NaN")); // read-only + QVERIFY(global.hasProperty("NaN")); +} + +void tst_QJSValue::deleteProperty_inPrototype() +{ + QJSEngine eng; + QJSValue obj = eng.newObject(); + QJSValue proto = eng.newObject(); + obj.setPrototype(proto); + + proto.setProperty("foo", 123); + QVERIFY(obj.hasProperty("foo")); + // deleteProperty() behavior matches JS delete operator + QVERIFY(obj.deleteProperty("foo")); + QVERIFY(obj.hasProperty("foo")); +} + +void tst_QJSValue::getSetProperty_HooliganTask162051() +{ + QJSEngine eng; + // task 162051 -- detecting whether the property is an array index or not + QVERIFY(eng.evaluate("a = []; a['00'] = 123; a['00']").strictlyEquals(eng.toScriptValue(123))); + QVERIFY(eng.evaluate("a.length").strictlyEquals(eng.toScriptValue(0))); + QVERIFY(eng.evaluate("a.hasOwnProperty('00')").strictlyEquals(eng.toScriptValue(true))); + QVERIFY(eng.evaluate("a.hasOwnProperty('0')").strictlyEquals(eng.toScriptValue(false))); + QVERIFY(eng.evaluate("a[0]").isUndefined()); + QVERIFY(eng.evaluate("a[0.5] = 456; a[0.5]").strictlyEquals(eng.toScriptValue(456))); + QVERIFY(eng.evaluate("a.length").strictlyEquals(eng.toScriptValue(0))); + QVERIFY(eng.evaluate("a.hasOwnProperty('0.5')").strictlyEquals(eng.toScriptValue(true))); + QVERIFY(eng.evaluate("a[0]").isUndefined()); + QVERIFY(eng.evaluate("a[0] = 789; a[0]").strictlyEquals(eng.toScriptValue(789))); + QVERIFY(eng.evaluate("a.length").strictlyEquals(eng.toScriptValue(1))); +} + +void tst_QJSValue::getSetProperty_HooliganTask183072() +{ + QJSEngine eng; + // task 183072 -- 0x800000000 is not an array index + eng.evaluate("a = []; a[0x800000000] = 123"); + QVERIFY(eng.evaluate("a.length").strictlyEquals(eng.toScriptValue(0))); + QVERIFY(eng.evaluate("a[0]").isUndefined()); + QVERIFY(eng.evaluate("a[0x800000000]").strictlyEquals(eng.toScriptValue(123))); +} + +void tst_QJSValue::getSetProperty_propertyRemoval() +{ + QJSEngine eng; + QJSValue object = eng.newObject(); + QJSValue str = eng.toScriptValue(QString::fromLatin1("bar")); + QJSValue num = eng.toScriptValue(123.0); + + object.setProperty("foo", num); + QCOMPARE(object.property("foo").strictlyEquals(num), true); + object.setProperty("bar", str); + QCOMPARE(object.property("bar").strictlyEquals(str), true); + QVERIFY(object.deleteProperty("foo")); + QVERIFY(!object.hasOwnProperty("foo")); + QCOMPARE(object.property("bar").strictlyEquals(str), true); + object.setProperty("foo", num); + QCOMPARE(object.property("foo").strictlyEquals(num), true); + QCOMPARE(object.property("bar").strictlyEquals(str), true); + QVERIFY(object.deleteProperty("bar")); + QVERIFY(!object.hasOwnProperty("bar")); + QCOMPARE(object.property("foo").strictlyEquals(num), true); + QVERIFY(object.deleteProperty("foo")); + QVERIFY(!object.hasOwnProperty("foo")); + + eng.globalObject().setProperty("object3", object); + QCOMPARE(eng.evaluate("object3.hasOwnProperty('foo')") + .strictlyEquals(eng.toScriptValue(false)), true); + object.setProperty("foo", num); + QCOMPARE(eng.evaluate("object3.hasOwnProperty('foo')") + .strictlyEquals(eng.toScriptValue(true)), true); + QVERIFY(eng.globalObject().deleteProperty("object3")); + QCOMPARE(eng.evaluate("this.hasOwnProperty('object3')") + .strictlyEquals(eng.toScriptValue(false)), true); +} + +void tst_QJSValue::getSetProperty_resolveMode() +{ + // test ResolveMode + QJSEngine eng; + QJSValue object = eng.newObject(); + QJSValue prototype = eng.newObject(); + object.setPrototype(prototype); + QJSValue num2 = eng.toScriptValue(456.0); + prototype.setProperty("propertyInPrototype", num2); + // default is ResolvePrototype + QCOMPARE(object.property("propertyInPrototype") + .strictlyEquals(num2), true); +#if 0 // FIXME: ResolveFlags removed from API + QCOMPARE(object.property("propertyInPrototype", QJSValue::ResolvePrototype) + .strictlyEquals(num2), true); + QCOMPARE(object.property("propertyInPrototype", QJSValue::ResolveLocal) + .isValid(), false); + QCOMPARE(object.property("propertyInPrototype", QJSValue::ResolveScope) + .strictlyEquals(num2), false); + QCOMPARE(object.property("propertyInPrototype", QJSValue::ResolveFull) + .strictlyEquals(num2), true); +#endif +} + +void tst_QJSValue::getSetProperty_twoEngines() +{ + QJSEngine engine; + QJSValue object = engine.newObject(); + + QJSEngine otherEngine; + QJSValue otherNum = otherEngine.toScriptValue(123); + QTest::ignoreMessage(QtWarningMsg, "QJSValue::setProperty(oof) failed: cannot set value created in a different engine"); + object.setProperty("oof", otherNum); + QVERIFY(!object.hasOwnProperty("oof")); + QVERIFY(object.property("oof").isUndefined()); +} + + +void tst_QJSValue::getSetProperty_gettersAndSetters() +{ +#if 0 // FIXME: No setters/getters right now + QScriptEngine eng; + QJSValue str = eng.toScriptValue(QString::fromLatin1("bar")); + QJSValue num = eng.toScriptValue(123.0); + QJSValue object = eng.newObject(); + for (int x = 0; x < 2; ++x) { + object.deleteProperty("foo"); + // getter() returns this.x + object.setProperty("foo", eng.newFunction(getter), + QJSValue::PropertyGetter | QJSValue::UserRange); + QCOMPARE(object.propertyFlags("foo") & ~QJSValue::UserRange, + QJSValue::PropertyGetter ); + + QEXPECT_FAIL("", "QTBUG-17615: User-range flags are not retained for getter/setter properties", Continue); + QCOMPARE(object.propertyFlags("foo"), + QJSValue::PropertyGetter | QJSValue::UserRange); + object.setProperty("x", num); + QCOMPARE(object.property("foo").strictlyEquals(num), true); + + // setter() sets this.x + object.setProperty("foo", eng.newFunction(setter), + QJSValue::PropertySetter); + QCOMPARE(object.propertyFlags("foo") & ~QJSValue::UserRange, + QJSValue::PropertySetter | QJSValue::PropertyGetter); + + QCOMPARE(object.propertyFlags("foo"), + QJSValue::PropertySetter | QJSValue::PropertyGetter); + object.setProperty("foo", str); + QCOMPARE(object.property("x").strictlyEquals(str), true); + QCOMPARE(object.property("foo").strictlyEquals(str), true); + + // kill the getter + object.setProperty("foo", QJSValue(), QJSValue::PropertyGetter); + QVERIFY(!(object.propertyFlags("foo") & QJSValue::PropertyGetter)); + QVERIFY(object.propertyFlags("foo") & QJSValue::PropertySetter); + QCOMPARE(object.property("foo").isUndefined(), true); + + // setter should still work + object.setProperty("foo", num); + QCOMPARE(object.property("x").strictlyEquals(num), true); + + // kill the setter too + object.setProperty("foo", QJSValue(), QJSValue::PropertySetter); + QVERIFY(!(object.propertyFlags("foo") & QJSValue::PropertySetter)); + // now foo is just a regular property + object.setProperty("foo", str); + QCOMPARE(object.property("x").strictlyEquals(num), true); + QCOMPARE(object.property("foo").strictlyEquals(str), true); + } + + for (int x = 0; x < 2; ++x) { + object.deleteProperty("foo"); + // setter() sets this.x + object.setProperty("foo", eng.newFunction(setter), QJSValue::PropertySetter); + object.setProperty("foo", str); + QCOMPARE(object.property("x").strictlyEquals(str), true); + QCOMPARE(object.property("foo").isUndefined(), true); + + // getter() returns this.x + object.setProperty("foo", eng.newFunction(getter), QJSValue::PropertyGetter); + object.setProperty("x", num); + QCOMPARE(object.property("foo").strictlyEquals(num), true); + + // kill the setter + object.setProperty("foo", QJSValue(), QJSValue::PropertySetter); + object.setProperty("foo", str); + + // getter should still work + QCOMPARE(object.property("foo").strictlyEquals(num), true); + + // kill the getter too + object.setProperty("foo", QJSValue(), QJSValue::PropertyGetter); + // now foo is just a regular property + object.setProperty("foo", str); + QCOMPARE(object.property("x").strictlyEquals(num), true); + QCOMPARE(object.property("foo").strictlyEquals(str), true); + } + + // use a single function as both getter and setter + object.deleteProperty("foo"); + object.setProperty("foo", eng.newFunction(getterSetter), + QJSValue::PropertyGetter | QJSValue::PropertySetter); + QCOMPARE(object.propertyFlags("foo"), + QJSValue::PropertyGetter | QJSValue::PropertySetter); + object.setProperty("x", num); + QCOMPARE(object.property("foo").strictlyEquals(num), true); + + // killing the getter will preserve the setter, even though they are the same function + object.setProperty("foo", QJSValue(), QJSValue::PropertyGetter); + QVERIFY(object.propertyFlags("foo") & QJSValue::PropertySetter); + QCOMPARE(object.property("foo").isUndefined(), true); +#endif +} + +void tst_QJSValue::getSetProperty_gettersAndSettersThrowErrorNative() +{ +#if 0 // FIXME: No setters/getters right now + // getter/setter that throws an error + QScriptEngine eng; + QJSValue str = eng.toScriptValue("bar"); + QJSValue object = eng.newObject(); + + object.setProperty("foo", eng.newFunction(getterSetterThrowingError), + QJSValue::PropertyGetter | QJSValue::PropertySetter); + QVERIFY(!eng.hasUncaughtException()); + QJSValue ret = object.property("foo"); + QVERIFY(ret.isError()); + QVERIFY(eng.hasUncaughtException()); + QVERIFY(ret.strictlyEquals(eng.uncaughtException())); + QCOMPARE(ret.toString(), QLatin1String("Error: get foo")); + eng.evaluate("Object"); // clear exception state... + QVERIFY(!eng.hasUncaughtException()); + object.setProperty("foo", str); + QVERIFY(eng.hasUncaughtException()); + QCOMPARE(eng.uncaughtException().toString(), QLatin1String("Error: set foo")); +#endif +} + +void tst_QJSValue::getSetProperty_gettersAndSettersThrowErrorJS() +{ + // getter/setter that throws an error (from js function) + QJSEngine eng; + QJSValue str = eng.toScriptValue(QString::fromLatin1("bar")); + + eng.evaluate("o = new Object; " + "o.__defineGetter__('foo', function() { throw new Error('get foo') }); " + "o.__defineSetter__('foo', function() { throw new Error('set foo') }); "); + QJSValue object = eng.evaluate("o"); + QVERIFY(!eng.hasUncaughtException()); + QJSValue ret = object.property("foo"); + QVERIFY(ret.isError()); + QVERIFY(eng.hasUncaughtException()); + QVERIFY(ret.strictlyEquals(eng.uncaughtException())); + QCOMPARE(ret.toString(), QLatin1String("Error: get foo")); + eng.evaluate("Object"); // clear exception state... + QVERIFY(!eng.hasUncaughtException()); + object.setProperty("foo", str); + QVERIFY(eng.hasUncaughtException()); + QCOMPARE(eng.uncaughtException().toString(), QLatin1String("Error: set foo")); +} + +void tst_QJSValue::getSetProperty_gettersAndSettersOnNative() +{ +#if 0 // FIXME: No c-style functions right now + // attempt to install getter+setter on built-in (native) property + QScriptEngine eng; + QJSValue object = eng.newObject(); + QVERIFY(object.property("__proto__").strictlyEquals(object.prototype())); + + QJSValue fun = eng.newFunction(getSet__proto__); + fun.setProperty("value", eng.toScriptValue("boo")); +/* QTest::ignoreMessage(QtWarningMsg, "QJSValue::setProperty() failed: " + "cannot set getter or setter of native property " + "`__proto__'");*/ + object.setProperty("__proto__", fun, + QJSValue::PropertyGetter | QJSValue::PropertySetter + | QJSValue::UserRange); + QVERIFY(object.property("__proto__").strictlyEquals(object.prototype())); + + object.setProperty("__proto__", QJSValue(), + QJSValue::PropertyGetter | QJSValue::PropertySetter); + QVERIFY(object.property("__proto__").strictlyEquals(object.prototype())); +#endif +} + +void tst_QJSValue::getSetProperty_gettersAndSettersOnGlobalObject() +{ +#if 0 // FIXME: No c-style functions right now + // global property that's a getter+setter + QScriptEngine eng; + eng.globalObject().setProperty("globalGetterSetterProperty", eng.newFunction(getterSetter), + QJSValue::PropertyGetter | QJSValue::PropertySetter); + eng.evaluate("globalGetterSetterProperty = 123"); + { + QJSValue ret = eng.evaluate("globalGetterSetterProperty"); + QVERIFY(ret.isNumber()); + QVERIFY(ret.strictlyEquals(eng.toScriptValue(123))); + } + QCOMPARE(eng.evaluate("typeof globalGetterSetterProperty").toString(), + QString::fromLatin1("number")); + { + QJSValue ret = eng.evaluate("this.globalGetterSetterProperty()"); + QVERIFY(ret.isError()); + QCOMPARE(ret.toString(), QString::fromLatin1("TypeError: Property 'globalGetterSetterProperty' of object # is not a function")); + } + { + QJSValue ret = eng.evaluate("new this.globalGetterSetterProperty()"); + QVERIFY(ret.isError()); + QCOMPARE(ret.toString(), QString::fromLatin1("TypeError: number is not a function")); + } +#endif +} + +void tst_QJSValue::getSetProperty_gettersAndSettersChange() +{ +#if 0 // FIXME: No setters/getters API right now + // "upgrading" an existing property to become a getter+setter + QScriptEngine eng; + QJSValue object = eng.newObject(); + QJSValue num(&eng, 123); + object.setProperty("foo", num); + object.setProperty("foo", eng.newFunction(getterSetter), + QJSValue::PropertyGetter | QJSValue::PropertySetter); + QVERIFY(!object.property("x").isValid()); + object.setProperty("foo", num); + QVERIFY(object.property("x").equals(num)); + + eng.globalObject().setProperty("object", object); + QJSValue res = eng.evaluate("object.x = 89; var a = object.foo; object.foo = 65; a"); + QCOMPARE(res.toInt(), 89); + QCOMPARE(object.property("x").toInt(), 65); + QCOMPARE(object.property("foo").toInt(), 65); +#endif +} + +void tst_QJSValue::getSetProperty_array() +{ + QJSEngine eng; + QJSValue str = eng.toScriptValue(QString::fromLatin1("bar")); + QJSValue num = eng.toScriptValue(123.0); + QJSValue array = eng.newArray(); + + QVERIFY(array.isArray()); + array.setProperty(0, num); + QCOMPARE(array.property(0).toNumber(), num.toNumber()); + QCOMPARE(array.property("0").toNumber(), num.toNumber()); + QCOMPARE(array.property("length").toUInt(), quint32(1)); + array.setProperty(1, str); + QCOMPARE(array.property(1).toString(), str.toString()); + QCOMPARE(array.property("1").toString(), str.toString()); + QCOMPARE(array.property("length").toUInt(), quint32(2)); + array.setProperty("length", eng.toScriptValue(1)); + QCOMPARE(array.property("length").toUInt(), quint32(1)); + QVERIFY(array.property(1).isUndefined()); +} + +void tst_QJSValue::getSetProperty_gettersAndSettersStupid() +{ +#if 0 // FIXME: No setters/getters API right now + //removing unexisting Setter or Getter should not crash. + QScriptEngine eng; + QJSValue num = eng.toScriptValue(123.0); + + { + QJSValue object = eng.newObject(); + object.setProperty("foo", QJSValue(), QJSValue::PropertyGetter); + QVERIFY(!object.property("foo").isValid()); + object.setProperty("foo", num); + QCOMPARE(object.property("foo").strictlyEquals(num), true); + } + + { + QJSValue object = eng.newObject(); + object.setProperty("foo", QJSValue(), QJSValue::PropertySetter); + QVERIFY(!object.property("foo").isValid()); + object.setProperty("foo", num); + QCOMPARE(object.property("foo").strictlyEquals(num), true); + } + + { + QJSValue object = eng.globalObject(); + object.setProperty("foo", QJSValue(), QJSValue::PropertySetter); + object.setProperty("foo", QJSValue(), QJSValue::PropertyGetter); + QVERIFY(!object.property("foo").isValid()); + object.setProperty("foo", num); + QCOMPARE(object.property("foo").strictlyEquals(num), true); + } +#endif +} + +void tst_QJSValue::getSetProperty() +{ + QJSEngine eng; + + QJSValue object = eng.newObject(); + + QJSValue str = eng.toScriptValue(QString::fromLatin1("bar")); + object.setProperty("foo", str); + QCOMPARE(object.property("foo").toString(), str.toString()); + + QJSValue num = eng.toScriptValue(123.0); + object.setProperty("baz", num); + QCOMPARE(object.property("baz").toNumber(), num.toNumber()); + + QJSValue strstr = QJSValue("bar"); + QCOMPARE(strstr.engine(), (QJSEngine *)0); + object.setProperty("foo", strstr); + QCOMPARE(object.property("foo").toString(), strstr.toString()); + QCOMPARE(strstr.engine(), &eng); // the value has been bound to the engine + + QJSValue numnum = QJSValue(123.0); + object.setProperty("baz", numnum); + QCOMPARE(object.property("baz").toNumber(), numnum.toNumber()); + + QJSValue inv; + inv.setProperty("foo", num); + QCOMPARE(inv.property("foo").isUndefined(), true); + + eng.globalObject().setProperty("object", object); + +#if 0 // FIXME: no setProperty API with flags + // ReadOnly + object.setProperty("readOnlyProperty", num, QJSValue::ReadOnly); + QCOMPARE(object.propertyFlags("readOnlyProperty"), QJSValue::ReadOnly); + QCOMPARE(object.property("readOnlyProperty").strictlyEquals(num), true); + eng.evaluate("object.readOnlyProperty = !object.readOnlyProperty"); + QCOMPARE(object.property("readOnlyProperty").strictlyEquals(num), true); + // should still be part of enumeration + { + QJSValue ret = eng.evaluate( + "found = false;" + "for (var p in object) {" + " if (p == 'readOnlyProperty') {" + " found = true; break;" + " }" + "} found"); + QCOMPARE(ret.strictlyEquals(eng.toScriptValue(true)), true); + } + // should still be deletable + { + QJSValue ret = eng.evaluate("delete object.readOnlyProperty"); + QCOMPARE(ret.strictlyEquals(eng.toScriptValue(true)), true); + QCOMPARE(object.property("readOnlyProperty").isValid(), false); + } + + // Undeletable + object.setProperty("undeletableProperty", num, QJSValue::Undeletable); + QCOMPARE(object.propertyFlags("undeletableProperty"), QJSValue::Undeletable); + QCOMPARE(object.property("undeletableProperty").strictlyEquals(num), true); + { + QJSValue ret = eng.evaluate("delete object.undeletableProperty"); + QCOMPARE(ret.strictlyEquals(eng.toScriptValue(true)), false); + QCOMPARE(object.property("undeletableProperty").strictlyEquals(num), true); + } + // should still be writable + eng.evaluate("object.undeletableProperty = object.undeletableProperty + 1"); + QCOMPARE(object.property("undeletableProperty").toNumber(), num.toNumber() + 1); + // should still be part of enumeration + { + QJSValue ret = eng.evaluate( + "found = false;" + "for (var p in object) {" + " if (p == 'undeletableProperty') {" + " found = true; break;" + " }" + "} found"); + QCOMPARE(ret.strictlyEquals(eng.toScriptValue(true)), true); + } + // should still be deletable from C++ + object.deleteProperty("undeletableProperty"); + QEXPECT_FAIL("", "QTBUG-17617: With JSC-based back-end, undeletable properties can't be deleted from C++", Continue); + QVERIFY(!object.property("undeletableProperty").isValid()); + QEXPECT_FAIL("", "QTBUG-17617: With JSC-based back-end, undeletable properties can't be deleted from C++", Continue); + QCOMPARE(object.propertyFlags("undeletableProperty"), 0); + + // SkipInEnumeration + object.setProperty("dontEnumProperty", num, QJSValue::SkipInEnumeration); + QCOMPARE(object.propertyFlags("dontEnumProperty"), QJSValue::SkipInEnumeration); + QCOMPARE(object.property("dontEnumProperty").strictlyEquals(num), true); + // should not be part of enumeration + { + QJSValue ret = eng.evaluate( + "found = false;" + "for (var p in object) {" + " if (p == 'dontEnumProperty') {" + " found = true; break;" + " }" + "} found"); + QCOMPARE(ret.strictlyEquals(eng.toScriptValue(false)), true); + } + // should still be writable + eng.evaluate("object.dontEnumProperty = object.dontEnumProperty + 1"); + QCOMPARE(object.property("dontEnumProperty").toNumber(), num.toNumber() + 1); + // should still be deletable + { + QJSValue ret = eng.evaluate("delete object.dontEnumProperty"); + QCOMPARE(ret.strictlyEquals(eng.toScriptValue(true)), true); + QCOMPARE(object.property("dontEnumProperty").isValid(), false); + } + + // change flags + object.setProperty("flagProperty", str); + QCOMPARE(object.propertyFlags("flagProperty"), static_cast(0)); + + QEXPECT_FAIL("", "FIXME: v8 does not support changing flags of existing properties", Continue); + //v8::i::JSObject::SetProperty(LookupResult* result, ... ) does not take in account the attributes + // if the result->isFound() + object.setProperty("flagProperty", str, QJSValue::ReadOnly); + QCOMPARE(object.propertyFlags("flagProperty"), QJSValue::ReadOnly); + + QEXPECT_FAIL("", "FIXME: v8 does not support changing flags of existing properties", Continue); + object.setProperty("flagProperty", str, object.propertyFlags("flagProperty") | QJSValue::SkipInEnumeration); + QCOMPARE(object.propertyFlags("flagProperty"), QJSValue::ReadOnly | QJSValue::SkipInEnumeration); + + QEXPECT_FAIL("", "FIXME: v8 does not support changing flags of existing properties", Continue); + object.setProperty("flagProperty", str, QJSValue::KeepExistingFlags); + QCOMPARE(object.propertyFlags("flagProperty"), QJSValue::ReadOnly | QJSValue::SkipInEnumeration); + + QEXPECT_FAIL("", "FIXME: v8 does not support UserRange", Continue); + object.setProperty("flagProperty", str, QJSValue::UserRange); + QCOMPARE(object.propertyFlags("flagProperty"), QJSValue::UserRange); + + // flags of property in the prototype + { + QJSValue object2 = eng.newObject(); + object2.setPrototype(object); + QCOMPARE(object2.propertyFlags("flagProperty", QJSValue::ResolveLocal), 0); + QEXPECT_FAIL("", "FIXME: v8 does not support UserRange", Continue); + QCOMPARE(object2.propertyFlags("flagProperty"), QJSValue::UserRange); + } + + // using interned strings + QScriptString foo = eng.toStringHandle("foo"); + + QVERIFY(object.deleteProperty(foo)); + QVERIFY(!object.property(foo).isValid()); + + object.setProperty(foo, num); + QVERIFY(object.property(foo).strictlyEquals(num)); + QVERIFY(object.property("foo").strictlyEquals(num)); + QVERIFY(object.propertyFlags(foo) == 0); +#endif + + // Setting index property on non-Array + object.setProperty(13, num); + QVERIFY(object.property(13).equals(num)); +} + +void tst_QJSValue::arrayElementGetterSetter() +{ +#if 0 // FIXME: No c-style functions + QScriptEngine eng; + QJSValue obj = eng.newObject(); + obj.setProperty(1, eng.newFunction(getterSetter), QJSValue::PropertyGetter|QJSValue::PropertySetter); + { + QJSValue num(123); + obj.setProperty("x", num); + QJSValue ret = obj.property(1); + QVERIFY(ret.isValid()); + QVERIFY(ret.equals(num)); + } + { + QJSValue num(456); + obj.setProperty(1, num); + QJSValue ret = obj.property(1); + QVERIFY(ret.isValid()); + QVERIFY(ret.equals(num)); + QVERIFY(ret.equals(obj.property("1"))); + } + QCOMPARE(obj.propertyFlags("1"), QJSValue::PropertyGetter|QJSValue::PropertySetter); + + obj.setProperty(1, QJSValue(), QJSValue::PropertyGetter|QJSValue::PropertySetter); + QVERIFY(obj.propertyFlags("1") == 0); +#endif +} + +void tst_QJSValue::getSetPrototype_cyclicPrototype() +{ + QJSEngine eng; + QJSValue prototype = eng.newObject(); + QJSValue object = eng.newObject(); + object.setPrototype(prototype); + + QJSValue previousPrototype = prototype.prototype(); + QTest::ignoreMessage(QtWarningMsg, "QJSValue::setPrototype() failed: cyclic prototype value"); + prototype.setPrototype(prototype); + QCOMPARE(prototype.prototype().strictlyEquals(previousPrototype), true); + + object.setPrototype(prototype); + QTest::ignoreMessage(QtWarningMsg, "QJSValue::setPrototype() failed: cyclic prototype value"); + prototype.setPrototype(object); + QCOMPARE(prototype.prototype().strictlyEquals(previousPrototype), true); + +} + +void tst_QJSValue::getSetPrototype_evalCyclicPrototype() +{ + QJSEngine eng; + QJSValue ret = eng.evaluate("o = { }; p = { }; o.__proto__ = p; p.__proto__ = o"); + QCOMPARE(eng.hasUncaughtException(), true); + QVERIFY(ret.strictlyEquals(eng.uncaughtException())); + QCOMPARE(ret.isError(), true); + QCOMPARE(ret.toString(), QLatin1String("Error: Cyclic __proto__ value")); +} + +void tst_QJSValue::getSetPrototype_eval() +{ + QJSEngine eng; + QJSValue ret = eng.evaluate("p = { }; p.__proto__ = { }"); + QCOMPARE(eng.hasUncaughtException(), false); + QCOMPARE(ret.isError(), false); +} + +void tst_QJSValue::getSetPrototype_invalidPrototype() +{ + QJSEngine eng; + QJSValue inv; + QJSValue object = eng.newObject(); + QJSValue proto = object.prototype(); + QVERIFY(object.prototype().strictlyEquals(proto)); + inv.setPrototype(object); + QVERIFY(inv.prototype().isUndefined()); + object.setPrototype(inv); + QVERIFY(object.prototype().strictlyEquals(proto)); +} + +void tst_QJSValue::getSetPrototype_twoEngines() +{ + QJSEngine eng; + QJSValue prototype = eng.newObject(); + QJSValue object = eng.newObject(); + object.setPrototype(prototype); + QJSEngine otherEngine; + QJSValue newPrototype = otherEngine.newObject(); + QTest::ignoreMessage(QtWarningMsg, "QJSValue::setPrototype() failed: cannot set a prototype created in a different engine"); + object.setPrototype(newPrototype); + QCOMPARE(object.prototype().strictlyEquals(prototype), true); + +} + +void tst_QJSValue::getSetPrototype_null() +{ + QJSEngine eng; + QJSValue object = eng.newObject(); + object.setPrototype(QJSValue(QJSValue::NullValue)); + QVERIFY(object.prototype().isNull()); + + QJSValue newProto = eng.newObject(); + object.setPrototype(newProto); + QVERIFY(object.prototype().equals(newProto)); + + object.setPrototype(eng.evaluate("null")); + QVERIFY(object.prototype().isNull()); +} + +void tst_QJSValue::getSetPrototype_notObjectOrNull() +{ + QJSEngine eng; + QJSValue object = eng.newObject(); + QJSValue originalProto = object.prototype(); + + // bool + object.setPrototype(true); + QVERIFY(object.prototype().equals(originalProto)); + object.setPrototype(eng.toScriptValue(true)); + QVERIFY(object.prototype().equals(originalProto)); + + // number + object.setPrototype(123); + QVERIFY(object.prototype().equals(originalProto)); + object.setPrototype(eng.toScriptValue(123)); + QVERIFY(object.prototype().equals(originalProto)); + + // string + object.setPrototype("foo"); + QVERIFY(object.prototype().equals(originalProto)); + object.setPrototype(eng.toScriptValue(QString::fromLatin1("foo"))); + QVERIFY(object.prototype().equals(originalProto)); + + // undefined + object.setPrototype(QJSValue(QJSValue::UndefinedValue)); + QVERIFY(object.prototype().equals(originalProto)); + object.setPrototype(eng.toScriptValue(QVariant())); + QVERIFY(object.prototype().equals(originalProto)); +} + +void tst_QJSValue::getSetPrototype() +{ + QJSEngine eng; + QJSValue prototype = eng.newObject(); + QJSValue object = eng.newObject(); + object.setPrototype(prototype); + QCOMPARE(object.prototype().strictlyEquals(prototype), true); +} + +void tst_QJSValue::getSetScope() +{ +#if 0 // FIXME: No QJSValue::scope + QScriptEngine eng; + + QJSValue object = eng.newObject(); + QCOMPARE(object.scope().isValid(), false); + + QJSValue object2 = eng.newObject(); + object2.setScope(object); + + QEXPECT_FAIL("", "FIXME: scope not implemented yet", Abort); + QCOMPARE(object2.scope().strictlyEquals(object), true); + + object.setProperty("foo", 123); + QVERIFY(!object2.property("foo").isValid()); + { + QJSValue ret = object2.property("foo", QJSValue::ResolveScope); + QVERIFY(ret.isNumber()); + QCOMPARE(ret.toInt(), 123); + } + + QJSValue inv; + inv.setScope(object); + QCOMPARE(inv.scope().isValid(), false); + + QScriptEngine otherEngine; + QJSValue object3 = otherEngine.newObject(); + QTest::ignoreMessage(QtWarningMsg, "QJSValue::setScope() failed: cannot set a scope object created in a different engine"); + object2.setScope(object3); + QCOMPARE(object2.scope().strictlyEquals(object), true); + + object2.setScope(QJSValue()); + QVERIFY(!object2.scope().isValid()); +#endif +} + +void tst_QJSValue::getSetData_objects_data() +{ +#if 0 // FIXME: no setData/data API + newEngine(); + + QTest::addColumn("object"); + + QTest::newRow("object from evaluate") << engine->evaluate("new Object()"); + QTest::newRow("object from engine") << engine->newObject(); + QTest::newRow("Array") << engine->newArray(); + QTest::newRow("Date") << engine->evaluate("new Date(12324)"); + QTest::newRow("QObject") << engine->newQObject(this); + QTest::newRow("RegExp") << engine->newRegExp(QRegExp()); +#endif +} + +void tst_QJSValue::getSetData_objects() +{ +#if 0 // FIXME: no setData/data API + QFETCH(QJSValue, object); + + QVERIFY(!object.data().isValid()); + QJSValue v1(true); + object.setData(v1); + QVERIFY(object.data().strictlyEquals(v1)); + QJSValue v2(123); + object.setData(v2); + QVERIFY(object.data().strictlyEquals(v2)); + QJSValue v3 = engine->newObject(); + object.setData(v3); + QVERIFY(object.data().strictlyEquals(v3)); + object.setData(QJSValue()); + QVERIFY(!object.data().isValid()); +#endif +} + +void tst_QJSValue::getSetData_nonObjects_data() +{ +#if 0 // FIXME: no setData/data API + newEngine(); + + QTest::addColumn("value"); + + QTest::newRow("undefined (bound)") << engine->toScriptValue(QVariant()); + QTest::newRow("null (bound)") << engine->evaluate("null"); + QTest::newRow("string (bound)") << engine->toScriptValue("Pong"); + QTest::newRow("bool (bound)") << engine->toScriptValue(false); + + QTest::newRow("undefined") << QJSValue(QJSValue::UndefinedValue); + QTest::newRow("null") << QJSValue(QJSValue::NullValue); + QTest::newRow("string") << QJSValue("Pong"); + QTest::newRow("bool") << QJSValue(true); +#endif +} + +void tst_QJSValue::getSetData_nonObjects() +{ +#if 0 // FIXME: no setData/data API + QFETCH(QJSValue, value); + + QVERIFY(!value.data().isValid()); + QJSValue v1(true); + value.setData(v1); + QVERIFY(!value.data().isValid()); + QJSValue v2(123); + value.setData(v2); + QVERIFY(!value.data().isValid()); + QJSValue v3 = engine->newObject(); + value.setData(v3); + QVERIFY(!value.data().isValid()); + value.setData(QJSValue()); + QVERIFY(!value.data().isValid()); +#endif +} + +void tst_QJSValue::setData_QTBUG15144() +{ +#if 0 // FIXME: no setData/data API + QScriptEngine eng; + QJSValue obj = eng.newObject(); + for (int i = 0; i < 10000; ++i) { + // Create an object with property 'fooN' on it, and immediately kill + // the reference to the object so it and the property name become garbage. + eng.evaluate(QString::fromLatin1("o = {}; o.foo%0 = 10; o = null;").arg(i)); + // Setting the data will cause a JS string to be allocated, which could + // trigger a GC. This should not cause a crash. + obj.setData("foodfight"); + } +#endif +} + +#if 0 // FIXME: no QScriptClass +class TestScriptClass : public QScriptClass +{ +public: + TestScriptClass(QScriptEngine *engine) : QScriptClass(engine) {} +}; + +void tst_QJSValue::getSetScriptClass_emptyClass_data() +{ + newEngine(); + QTest::addColumn("value"); + + QTest::newRow("invalid") << QJSValue(); + QTest::newRow("number") << QJSValue(123); + QTest::newRow("string") << QJSValue("pong"); + QTest::newRow("bool") << QJSValue(false); + QTest::newRow("null") << QJSValue(QJSValue::NullValue); + QTest::newRow("undefined") << QJSValue(QJSValue::UndefinedValue); + + QTest::newRow("number") << engine->toScriptValue(123); + QTest::newRow("string") << engine->toScriptValue("pong"); + QTest::newRow("bool") << engine->toScriptValue(true); + QTest::newRow("null") << QJSValue(engine->evaluate("null")); + QTest::newRow("undefined") << QJSValue(engine->toScriptValue(QVariant())); + QTest::newRow("object") << QJSValue(engine->newObject()); + QTest::newRow("date") << QJSValue(engine->evaluate("new Date()")); + QTest::newRow("qobject") << QJSValue(engine->newQObject(this)); +} + +void tst_QJSValue::getSetScriptClass_emptyClass() +{ + QFETCH(QJSValue, value); + QCOMPARE(value.scriptClass(), (QScriptClass*)0); +} + +void tst_QJSValue::getSetScriptClass_JSObjectFromCpp() +{ + QScriptEngine eng; + TestScriptClass testClass(&eng); + // object created in C++ (newObject()) + { + QJSValue obj = eng.newObject(); + obj.setScriptClass(&testClass); + QCOMPARE(obj.scriptClass(), (QScriptClass*)&testClass); + obj.setScriptClass(0); + QCOMPARE(obj.scriptClass(), (QScriptClass*)0); + } +} + +void tst_QJSValue::getSetScriptClass_JSObjectFromJS() +{ + QScriptEngine eng; + TestScriptClass testClass(&eng); + // object created in JS + { + QJSValue obj = eng.evaluate("new Object"); + QVERIFY(!eng.hasUncaughtException()); + QVERIFY(obj.isObject()); + QCOMPARE(obj.scriptClass(), (QScriptClass*)0); + obj.setScriptClass(&testClass); + QCOMPARE(obj.scriptClass(), (QScriptClass*)&testClass); + obj.setScriptClass(0); + QCOMPARE(obj.scriptClass(), (QScriptClass*)0); + } +} + +void tst_QJSValue::getSetScriptClass_QVariant() +{ + QScriptEngine eng; + TestScriptClass testClass(&eng); + // object that already has a(n internal) class + { + QJSValue obj = eng.toScriptValue(QUrl("http://example.com")); + QVERIFY(obj.isVariant()); + QCOMPARE(obj.scriptClass(), (QScriptClass*)0); + obj.setScriptClass(&testClass); + QCOMPARE(obj.scriptClass(), (QScriptClass*)&testClass); + QVERIFY(obj.isObject()); + QVERIFY(!obj.isVariant()); + QCOMPARE(obj.toVariant(), QVariant(QVariantMap())); + } +} + +void tst_QJSValue::getSetScriptClass_QObject() +{ + QScriptEngine eng; + TestScriptClass testClass(&eng); + { + QJSValue obj = eng.newQObject(this); + QVERIFY(obj.isQObject()); + obj.setScriptClass(&testClass); + QCOMPARE(obj.scriptClass(), (QScriptClass*)&testClass); + QVERIFY(obj.isObject()); + QVERIFY(!obj.isQObject()); + QVERIFY(obj.toQObject() == 0); + } +} +#endif + +#if 0 // FIXME: No c-style callbacks +static QJSValue getArg(QScriptContext *ctx, QScriptEngine *) +{ + return ctx->argument(0); +} + +static QJSValue evaluateArg(QScriptContext *, QScriptEngine *eng) +{ + return eng->evaluate("arguments[0]"); +} + +static QJSValue addArgs(QScriptContext *, QScriptEngine *eng) +{ + return eng->evaluate("arguments[0] + arguments[1]"); +} + +static QJSValue returnInvalidValue(QScriptContext *, QScriptEngine *) +{ + return QJSValue(); +} +#endif + +void tst_QJSValue::call_function() +{ + QJSEngine eng; + QJSValue fun = eng.evaluate("(function() { return 1; })"); + QVERIFY(fun.isCallable()); + QJSValue result = fun.call(); + QVERIFY(result.isNumber()); + QCOMPARE(result.toInt(), 1); +} + +void tst_QJSValue::call_object() +{ + QJSEngine eng; + QJSValue Object = eng.evaluate("Object"); + QCOMPARE(Object.isCallable(), true); + QJSValue result = Object.callWithInstance(Object); + QCOMPARE(result.isObject(), true); +} + +void tst_QJSValue::call_newObjects() +{ + QJSEngine eng; + // test that call() doesn't construct new objects + QJSValue Number = eng.evaluate("Number"); + QJSValue Object = eng.evaluate("Object"); + QCOMPARE(Object.isCallable(), true); + QJSValueList args; + args << eng.toScriptValue(123); + QJSValue result = Number.callWithInstance(Object, args); + QCOMPARE(result.strictlyEquals(args.at(0)), true); +} + +void tst_QJSValue::call_this() +{ + QJSEngine eng; + // test that correct "this" object is used + QJSValue fun = eng.evaluate("(function() { return this; })"); + QCOMPARE(fun.isCallable(), true); + + QJSValue numberObject = eng.evaluate("new Number(123)"); + QJSValue result = fun.callWithInstance(numberObject); + QCOMPARE(result.isObject(), true); + QCOMPARE(result.toNumber(), 123.0); +} + +void tst_QJSValue::call_arguments() +{ + QJSEngine eng; + // test that correct arguments are passed + + QJSValue fun = eng.evaluate("(function() { return arguments[0]; })"); + QCOMPARE(fun.isCallable(), true); + { + QJSValue result = fun.callWithInstance(eng.toScriptValue(QVariant())); + QCOMPARE(result.isUndefined(), true); + } + { + QJSValueList args; + args << eng.toScriptValue(123.0); + QJSValue result = fun.callWithInstance(eng.toScriptValue(QVariant()), args); + QCOMPARE(result.isNumber(), true); + QCOMPARE(result.toNumber(), 123.0); + } + // V2 constructors + { + QJSValueList args; + args << QJSValue(123.0); + QJSValue result = fun.callWithInstance(eng.toScriptValue(QVariant()), args); + QCOMPARE(result.isNumber(), true); + QCOMPARE(result.toNumber(), 123.0); + } +#if 0 // FIXME: The feature of interpreting a passed array as argument list has been removed from the API + { + QJSValue args = eng.newArray(); + args.setProperty(0, 123); + QJSValue result = fun.callWithInstance(eng.toScriptValue(QVariant()), args); + QVERIFY(result.isNumber()); + QCOMPARE(result.toNumber(), 123.0); + } +#endif +} + +void tst_QJSValue::call() +{ + QJSEngine eng; + { + QJSValue fun = eng.evaluate("(function() { return arguments[1]; })"); + QCOMPARE(fun.isCallable(), true); + + { + QJSValueList args; + args << eng.toScriptValue(123.0) << eng.toScriptValue(456.0); + QJSValue result = fun.callWithInstance(eng.toScriptValue(QVariant()), args); + QCOMPARE(result.isNumber(), true); + QCOMPARE(result.toNumber(), 456.0); + } +#if 0 // FIXME: The feature of interpreting a passed array as argument list has been removed from the API + { + QJSValue args = eng.newArray(); + args.setProperty(0, 123); + args.setProperty(1, 456); + QJSValue result = fun.callWithInstance(eng.toScriptValue(QVariant()), args); + QVERIFY(result.isNumber()); + QCOMPARE(result.toNumber(), 456.0); + } +#endif + } + { + QJSValue fun = eng.evaluate("(function() { throw new Error('foo'); })"); + QCOMPARE(fun.isCallable(), true); + QVERIFY(!eng.hasUncaughtException()); + + { + QJSValue result = fun.call(); + QCOMPARE(result.isError(), true); + QCOMPARE(eng.hasUncaughtException(), true); + QVERIFY(result.strictlyEquals(eng.uncaughtException())); + } + } +#if 0 // FIXME: No c-style callbacks + { + eng.clearExceptions(); + QJSValue fun = eng.newFunction(getArg); + { + QJSValueList args; + args << eng.toScriptValue(123.0); + QJSValue result = fun.callWithInstance(eng.toScriptValue(QVariant()), args); + QVERIFY(!eng.hasUncaughtException()); + QCOMPARE(result.isNumber(), true); + QCOMPARE(result.toNumber(), 123.0); + } + // V2 constructors + { + QJSValueList args; + args << QJSValue(123.0); + QJSValue result = fun.callWithInstance(eng.toScriptValue(QVariant()), args); + QCOMPARE(result.isNumber(), true); + QCOMPARE(result.toNumber(), 123.0); + } +#if 0 // FIXME: The feature of interpreting a passed array as argument list has been removed from the API + { + QJSValue args = eng.newArray(); + args.setProperty(0, 123); + QJSValue result = fun.callWithInstance(eng.toScriptValue(QVariant()), args); + QVERIFY(result.isNumber()); + QCOMPARE(result.toNumber(), 123.0); + } +#endif + } + { + QJSValue fun = eng.newFunction(evaluateArg); + { + QJSValueList args; + args << eng.toScriptValue(123.0); + QJSValue result = fun.callWithInstance(eng.toScriptValue(QVariant()), args); + QVERIFY(!eng.hasUncaughtException()); + QCOMPARE(result.isNumber(), true); + QCOMPARE(result.toNumber(), 123.0); + } + } +#endif +} + +void tst_QJSValue::call_invalidArguments() +{ +#if 0 // FIXME: No c-style callbacks + // test that invalid arguments are handled gracefully + QScriptEngine eng; + { + QJSValue fun = eng.newFunction(getArg); + { + QJSValueList args; + args << QJSValue(); + QJSValue ret = fun.callWithInstance(args); + QVERIFY(!eng.hasUncaughtException()); + QVERIFY(ret.isUndefined()); + } + } + { + QJSValue fun = eng.newFunction(evaluateArg); + { + QJSValueList args; + args << QJSValue(); + QJSValue ret = fun.call(args); + QVERIFY(ret.isUndefined()); + } + } + { + QJSValue fun = eng.newFunction(addArgs); + { + QJSValueList args; + args << QJSValue() << QJSValue(); + QJSValue ret = fun.call(args); + QVERIFY(!ret.isUndefined()); + QCOMPARE(ret.isNumber(), true); + QCOMPARE(qIsNaN(ret.toNumber()), true); + } + } +#endif +} + +void tst_QJSValue::call_invalidReturn() +{ +#if 0 // FIXME: No c-style callbacks + // test that invalid return value is handled gracefully + QScriptEngine eng; + QJSValue fun = eng.newFunction(returnInvalidValue); + eng.globalObject().setProperty("returnInvalidValue", fun); + QJSValue ret = eng.evaluate("returnInvalidValue() + returnInvalidValue()"); + QVERIFY(!ret.isUndefined()); + QCOMPARE(ret.isNumber(), true); + QCOMPARE(qIsNaN(ret.toNumber()), true); +#endif +} + +void tst_QJSValue::call_twoEngines() +{ + QJSEngine eng; + QJSValue object = eng.evaluate("Object"); + QJSEngine otherEngine; + QJSValue fun = otherEngine.evaluate("(function() { return 1; })"); + QVERIFY(fun.isCallable()); + QTest::ignoreMessage(QtWarningMsg, "JSValue can't be rassigned to an another engine."); + QTest::ignoreMessage(QtWarningMsg, "QJSValue::call() failed: " + "cannot call function with thisObject created in " + "a different engine"); + QVERIFY(fun.callWithInstance(object).isUndefined()); + QTest::ignoreMessage(QtWarningMsg, "QJSValue::call() failed: " + "cannot call function with argument created in " + "a different engine"); + QVERIFY(fun.call(QJSValueList() << eng.toScriptValue(123)).isUndefined()); + { + QJSValue fun = eng.evaluate("Object"); + QVERIFY(fun.isCallable()); + QJSEngine eng2; + QJSValue objectInDifferentEngine = eng2.newObject(); + QJSValueList args; + args << objectInDifferentEngine; + QTest::ignoreMessage(QtWarningMsg, "QJSValue::call() failed: cannot call function with argument created in a different engine"); + fun.call(args); + } +} + +void tst_QJSValue::call_array() +{ +#if 0 // FIXME: The feature of interpreting an array as argument list has been removed from the API + QScriptEngine eng; + QJSValue fun = eng.evaluate("(function() { return arguments; })"); + QVERIFY(fun.isCallable()); + QJSValue array = eng.newArray(3); + array.setProperty(0, eng.toScriptValue(123.0)); + array.setProperty(1, eng.toScriptValue(456.0)); + array.setProperty(2, eng.toScriptValue(789.0)); + // call with single array object as arguments + QJSValue ret = fun.call(QJSValue(), array); + QVERIFY(!eng.hasUncaughtException()); + QCOMPARE(ret.isError(), false); + QCOMPARE(ret.property(0).strictlyEquals(array.property(0)), true); + QCOMPARE(ret.property(1).strictlyEquals(array.property(1)), true); + QCOMPARE(ret.property(2).strictlyEquals(array.property(2)), true); + // call with arguments object as arguments + QJSValue ret2 = fun.call(QJSValue(), ret); + QCOMPARE(ret2.isError(), false); + QCOMPARE(ret2.property(0).strictlyEquals(ret.property(0)), true); + QCOMPARE(ret2.property(1).strictlyEquals(ret.property(1)), true); + QCOMPARE(ret2.property(2).strictlyEquals(ret.property(2)), true); + // call with null as arguments + QJSValue ret3 = fun.call(QJSValue(), eng.evaluate("null")); + QCOMPARE(ret3.isError(), false); + QCOMPARE(ret3.property("length").isNumber(), true); + QCOMPARE(ret3.property("length").toNumber(), 0.0); + // call with undefined as arguments + QJSValue ret4 = fun.call(QJSValue(), eng.toScriptValue(QVariant())); + QCOMPARE(ret4.isError(), false); + QCOMPARE(ret4.property("length").isNumber(), true); + QCOMPARE(ret4.property("length").toNumber(), 0.0); + // call with something else as arguments + QJSValue ret5 = fun.call(QJSValue(), eng.toScriptValue(123.0)); + QCOMPARE(ret5.isError(), true); + // call with a non-array object as arguments + QJSValue ret6 = fun.call(QJSValue(), eng.globalObject()); + QVERIFY(ret6.isError()); + QCOMPARE(ret6.toString(), QString::fromLatin1("TypeError: Arguments must be an array")); +#endif +} + + +void tst_QJSValue::call_nonFunction_data() +{ + newEngine(); + QTest::addColumn("value"); + + QTest::newRow("invalid") << QJSValue(); + QTest::newRow("bool") << QJSValue(false); + QTest::newRow("int") << QJSValue(123); + QTest::newRow("string") << QJSValue(QString::fromLatin1("ciao")); + QTest::newRow("undefined") << QJSValue(QJSValue::UndefinedValue); + QTest::newRow("null") << QJSValue(QJSValue::NullValue); + + QTest::newRow("bool bound") << engine->toScriptValue(false); + QTest::newRow("int bound") << engine->toScriptValue(123); + QTest::newRow("string bound") << engine->toScriptValue(QString::fromLatin1("ciao")); + QTest::newRow("undefined bound") << engine->toScriptValue(QVariant()); + QTest::newRow("null bound") << engine->evaluate("null"); +} + +void tst_QJSValue::call_nonFunction() +{ + // calling things that are not functions + QFETCH(QJSValue, value); + QVERIFY(value.call().isUndefined()); +} + +#if 0 // FIXME: no c-style callbacks +static QJSValue ctorReturningUndefined(QScriptContext *ctx, QScriptEngine *) +{ + ctx->thisObject().setProperty("foo", 123); + return QJSValue(QJSValue::UndefinedValue); +} + +static QJSValue ctorReturningNewObject(QScriptContext *, QScriptEngine *eng) +{ + QJSValue result = eng->newObject(); + result.setProperty("bar", 456); + return result; +} +#endif + +void tst_QJSValue::construct_nonFunction_data() +{ + newEngine(); + QTest::addColumn("value"); + + QTest::newRow("invalid") << QJSValue(); + QTest::newRow("bool") << QJSValue(false); + QTest::newRow("int") << QJSValue(123); + QTest::newRow("string") << QJSValue(QString::fromLatin1("ciao")); + QTest::newRow("undefined") << QJSValue(QJSValue::UndefinedValue); + QTest::newRow("null") << QJSValue(QJSValue::NullValue); + + QTest::newRow("bool bound") << engine->toScriptValue(false); + QTest::newRow("int bound") << engine->toScriptValue(123); + QTest::newRow("string bound") << engine->toScriptValue(QString::fromLatin1("ciao")); + QTest::newRow("undefined bound") << engine->toScriptValue(QVariant()); + QTest::newRow("null bound") << engine->evaluate("null"); +} + +void tst_QJSValue::construct_nonFunction() +{ + QFETCH(QJSValue, value); + QVERIFY(value.callAsConstructor().isUndefined()); +} + +void tst_QJSValue::construct_simple() +{ + QJSEngine eng; + QJSValue fun = eng.evaluate("(function () { this.foo = 123; })"); + QVERIFY(fun.isCallable()); + QJSValue ret = fun.callAsConstructor(); + QVERIFY(!ret.isUndefined()); + QVERIFY(ret.isObject()); + QVERIFY(ret.prototype().strictlyEquals(fun.property("prototype"))); + QCOMPARE(ret.property("foo").toInt(), 123); +} + +void tst_QJSValue::construct_newObjectJS() +{ + QJSEngine eng; + // returning a different object overrides the default-constructed one + QJSValue fun = eng.evaluate("(function () { return { bar: 456 }; })"); + QVERIFY(fun.isCallable()); + QJSValue ret = fun.callAsConstructor(); + QVERIFY(ret.isObject()); + QVERIFY(!ret.prototype().strictlyEquals(fun.property("prototype"))); + QCOMPARE(ret.property("bar").toInt(), 456); +} + +#if 0 // FIXME: no c-style callbacks +void tst_QJSValue::construct_undefined() +{ + QScriptEngine eng; + QJSValue fun = eng.newFunction(ctorReturningUndefined); + QJSValue ret = fun.callAsConstructor(); + QVERIFY(ret.isObject()); + QVERIFY(ret.instanceOf(fun)); + QCOMPARE(ret.property("foo").toInt(), 123); +} + +void tst_QJSValue::construct_newObjectCpp() +{ + QScriptEngine eng; + QJSValue fun = eng.newFunction(ctorReturningNewObject); + QJSValue ret = fun.callAsConstructor(); + QVERIFY(ret.isObject()); + QVERIFY(!ret.instanceOf(fun)); + QCOMPARE(ret.property("bar").toInt(), 456); +} +#endif + +void tst_QJSValue::construct_arg() +{ + QJSEngine eng; + QJSValue Number = eng.evaluate("Number"); + QCOMPARE(Number.isCallable(), true); + QJSValueList args; + args << eng.toScriptValue(123); + QJSValue ret = Number.callAsConstructor(args); + QCOMPARE(ret.isObject(), true); + QCOMPARE(ret.toNumber(), args.at(0).toNumber()); +} + +void tst_QJSValue::construct_proto() +{ + QJSEngine eng; + // test that internal prototype is set correctly + QJSValue fun = eng.evaluate("(function() { return this.__proto__; })"); + QCOMPARE(fun.isCallable(), true); + QCOMPARE(fun.property("prototype").isObject(), true); + QJSValue ret = fun.callAsConstructor(); + QCOMPARE(fun.property("prototype").strictlyEquals(ret), true); +} + +void tst_QJSValue::construct_returnInt() +{ + QJSEngine eng; + // test that we return the new object even if a non-object value is returned from the function + QJSValue fun = eng.evaluate("(function() { return 123; })"); + QCOMPARE(fun.isCallable(), true); + QJSValue ret = fun.callAsConstructor(); + QCOMPARE(ret.isObject(), true); +} + +void tst_QJSValue::construct_throw() +{ + QJSEngine eng; + QJSValue fun = eng.evaluate("(function() { throw new Error('foo'); })"); + QCOMPARE(fun.isCallable(), true); + QJSValue ret = fun.callAsConstructor(); + QCOMPARE(ret.isError(), true); + QCOMPARE(eng.hasUncaughtException(), true); + QVERIFY(ret.strictlyEquals(eng.uncaughtException())); +} + +#if 0 // FIXME: The feature of interpreting an array as argument list has been removed from the API +void tst_QJSValue::construct() +{ + QScriptEngine eng; + QJSValue fun = eng.evaluate("(function() { return arguments; })"); + QVERIFY(fun.isCallable()); + QJSValue array = eng.newArray(3); + array.setProperty(0, eng.toScriptValue(123.0)); + array.setProperty(1, eng.toScriptValue(456.0)); + array.setProperty(2, eng.toScriptValue(789.0)); + // construct with single array object as arguments + QJSValue ret = fun.callAsConstructor(array); + QVERIFY(!eng.hasUncaughtException()); + QVERIFY(ret.isObject()); + QCOMPARE(ret.property(0).strictlyEquals(array.property(0)), true); + QCOMPARE(ret.property(1).strictlyEquals(array.property(1)), true); + QCOMPARE(ret.property(2).strictlyEquals(array.property(2)), true); + // construct with arguments object as arguments + QJSValue ret2 = fun.callAsConstructor(ret); + QCOMPARE(ret2.property(0).strictlyEquals(ret.property(0)), true); + QCOMPARE(ret2.property(1).strictlyEquals(ret.property(1)), true); + QCOMPARE(ret2.property(2).strictlyEquals(ret.property(2)), true); + // construct with null as arguments + QJSValue ret3 = fun.callAsConstructor(eng.evaluate("null"); + QCOMPARE(ret3.isError(), false); + QCOMPARE(ret3.property("length").isNumber(), true); + QCOMPARE(ret3.property("length").toNumber(), 0.0); + // construct with undefined as arguments + QJSValue ret4 = fun.callAsConstructor(eng.toScriptValue(QVariant())); + QCOMPARE(ret4.isError(), false); + QCOMPARE(ret4.property("length").isNumber(), true); + QCOMPARE(ret4.property("length").toNumber(), 0.0); + // construct with something else as arguments + QJSValue ret5 = fun.callAsConstructor(eng.toScriptValue(123.0)); + QCOMPARE(ret5.isError(), true); + // construct with a non-array object as arguments + QJSValue ret6 = fun.callAsConstructor(eng.globalObject()); + QVERIFY(ret6.isError()); + QCOMPARE(ret6.toString(), QString::fromLatin1("TypeError: Arguments must be an array")); +} +#endif + +void tst_QJSValue::construct_twoEngines() +{ + QJSEngine engine; + QJSEngine otherEngine; + QJSValue ctor = engine.evaluate("(function (a, b) { this.foo = 123; })"); + QJSValue arg = otherEngine.toScriptValue(124567); + QTest::ignoreMessage(QtWarningMsg, "QJSValue::callAsConstructor() failed: cannot construct function with argument created in a different engine"); + QVERIFY(ctor.callAsConstructor(QJSValueList() << arg).isUndefined()); + QTest::ignoreMessage(QtWarningMsg, "QJSValue::callAsConstructor() failed: cannot construct function with argument created in a different engine"); + QVERIFY(ctor.callAsConstructor(QJSValueList() << arg << otherEngine.newObject()).isUndefined()); +} + +void tst_QJSValue::construct_constructorThrowsPrimitive() +{ + QJSEngine eng; + QJSValue fun = eng.evaluate("(function() { throw 123; })"); + QVERIFY(fun.isCallable()); + // construct(QJSValueList) + { + QJSValue ret = fun.callAsConstructor(); + QVERIFY(ret.isNumber()); + QCOMPARE(ret.toNumber(), 123.0); + QVERIFY(eng.hasUncaughtException()); + QVERIFY(ret.strictlyEquals(eng.uncaughtException())); + eng.clearExceptions(); + } +#if 0 // FIXME: The feature of interpreting an array as argument list has been removed from the API + // construct(QJSValue) + { + QJSValue ret = fun.callAsConstructor(eng.newArray()); + QVERIFY(ret.isNumber()); + QCOMPARE(ret.toNumber(), 123.0); + QVERIFY(eng.hasUncaughtException()); + QVERIFY(ret.strictlyEquals(eng.uncaughtException())); + eng.clearExceptions(); + } +#endif +} + +#if 0 // FIXME: No QJSValue::lessThan +void tst_QJSValue::lessThan() +{ + QScriptEngine eng; + + QVERIFY(!QJSValue().lessThan(QJSValue())); + + QJSValue num = eng.toScriptValue(123); + QCOMPARE(num.lessThan(eng.toScriptValue(124)), true); + QCOMPARE(num.lessThan(eng.toScriptValue(122)), false); + QCOMPARE(num.lessThan(eng.toScriptValue(123)), false); + QCOMPARE(num.lessThan(eng.toScriptValue("124")), true); + QCOMPARE(num.lessThan(eng.toScriptValue("122")), false); + QCOMPARE(num.lessThan(eng.toScriptValue("123")), false); + QCOMPARE(num.lessThan(eng.toScriptValue(qSNaN())), false); + QCOMPARE(num.lessThan(eng.toScriptValue(+qInf())), true); + QCOMPARE(num.lessThan(eng.toScriptValue(-qInf())), false); + QCOMPARE(num.lessThan(num), false); + QCOMPARE(num.lessThan(eng.toScriptValue(124).toObject()), true); + QCOMPARE(num.lessThan(eng.toScriptValue(122).toObject()), false); + QCOMPARE(num.lessThan(eng.toScriptValue(123).toObject()), false); + QCOMPARE(num.lessThan(eng.toScriptValue("124").toObject()), true); + QCOMPARE(num.lessThan(eng.toScriptValue("122").toObject()), false); + QCOMPARE(num.lessThan(eng.toScriptValue("123").toObject()), false); + QCOMPARE(num.lessThan(eng.toScriptValue(qSNaN()).toObject()), false); + QCOMPARE(num.lessThan(eng.toScriptValue(+qInf()).toObject()), true); + QCOMPARE(num.lessThan(eng.toScriptValue(-qInf()).toObject()), false); + QCOMPARE(num.lessThan(num.toObject()), false); + QCOMPARE(num.lessThan(QJSValue()), false); + + QJSValue str = eng.toScriptValue("123"); + QCOMPARE(str.lessThan(eng.toScriptValue("124")), true); + QCOMPARE(str.lessThan(eng.toScriptValue("122")), false); + QCOMPARE(str.lessThan(eng.toScriptValue("123")), false); + QCOMPARE(str.lessThan(eng.toScriptValue(124)), true); + QCOMPARE(str.lessThan(eng.toScriptValue(122)), false); + QCOMPARE(str.lessThan(eng.toScriptValue(123)), false); + QCOMPARE(str.lessThan(str), false); + QCOMPARE(str.lessThan(eng.toScriptValue("124").toObject()), true); + QCOMPARE(str.lessThan(eng.toScriptValue("122").toObject()), false); + QCOMPARE(str.lessThan(eng.toScriptValue("123").toObject()), false); + QCOMPARE(str.lessThan(eng.toScriptValue(124).toObject()), true); + QCOMPARE(str.lessThan(eng.toScriptValue(122).toObject()), false); + QCOMPARE(str.lessThan(eng.toScriptValue(123).toObject()), false); + QCOMPARE(str.lessThan(str.toObject()), false); + QCOMPARE(str.lessThan(QJSValue()), false); + + // V2 constructors + QJSValue num2 = QJSValue(123); + QCOMPARE(num2.lessThan(QJSValue(124)), true); + QCOMPARE(num2.lessThan(QJSValue(122)), false); + QCOMPARE(num2.lessThan(QJSValue(123)), false); + QCOMPARE(num2.lessThan(QJSValue("124")), true); + QCOMPARE(num2.lessThan(QJSValue("122")), false); + QCOMPARE(num2.lessThan(QJSValue("123")), false); + QCOMPARE(num2.lessThan(QJSValue(qSNaN())), false); + QCOMPARE(num2.lessThan(QJSValue(+qInf())), true); + QCOMPARE(num2.lessThan(QJSValue(-qInf())), false); + QCOMPARE(num2.lessThan(num), false); + QCOMPARE(num2.lessThan(QJSValue()), false); + + QJSValue str2 = QJSValue("123"); + QCOMPARE(str2.lessThan(QJSValue("124")), true); + QCOMPARE(str2.lessThan(QJSValue("122")), false); + QCOMPARE(str2.lessThan(QJSValue("123")), false); + QCOMPARE(str2.lessThan(QJSValue(124)), true); + QCOMPARE(str2.lessThan(QJSValue(122)), false); + QCOMPARE(str2.lessThan(QJSValue(123)), false); + QCOMPARE(str2.lessThan(str), false); + QCOMPARE(str2.lessThan(QJSValue()), false); + + QJSValue obj1 = eng.newObject(); + QJSValue obj2 = eng.newObject(); + QCOMPARE(obj1.lessThan(obj2), false); + QCOMPARE(obj2.lessThan(obj1), false); + QCOMPARE(obj1.lessThan(obj1), false); + QCOMPARE(obj2.lessThan(obj2), false); + + QJSValue date1 = eng.toScriptValue(QDateTime(QDate(2000, 1, 1))); + QJSValue date2 = eng.toScriptValue(QDateTime(QDate(1999, 1, 1))); + QCOMPARE(date1.lessThan(date2), false); + QCOMPARE(date2.lessThan(date1), true); + QCOMPARE(date1.lessThan(date1), false); + QCOMPARE(date2.lessThan(date2), false); + QCOMPARE(date1.lessThan(QJSValue()), false); + + QCOMPARE(QJSValue().lessThan(date2), false); + + QScriptEngine otherEngine; + QTest::ignoreMessage(QtWarningMsg, "QJSValue::lessThan: " + "cannot compare to a value created in " + "a different engine"); + QCOMPARE(date1.lessThan(otherEngine.toScriptValue(123)), false); +} +#endif + +void tst_QJSValue::equals() +{ + QJSEngine eng; + + QVERIFY(QJSValue().equals(QJSValue())); + + QJSValue num = eng.toScriptValue(123); + QCOMPARE(num.equals(eng.toScriptValue(123)), true); + QCOMPARE(num.equals(eng.toScriptValue(321)), false); + QCOMPARE(num.equals(eng.toScriptValue(QString::fromLatin1("123"))), true); + QCOMPARE(num.equals(eng.toScriptValue(QString::fromLatin1("321"))), false); + QCOMPARE(num.equals(eng.evaluate("new Number(123)")), true); + QCOMPARE(num.equals(eng.evaluate("new Number(321)")), false); + QCOMPARE(num.equals(eng.evaluate("new String('123')")), true); + QCOMPARE(num.equals(eng.evaluate("new String('321')")), false); + QVERIFY(eng.evaluate("new Number(123)").equals(num)); + QCOMPARE(num.equals(QJSValue()), false); + + QJSValue str = eng.toScriptValue(QString::fromLatin1("123")); + QCOMPARE(str.equals(eng.toScriptValue(QString::fromLatin1("123"))), true); + QCOMPARE(str.equals(eng.toScriptValue(QString::fromLatin1("321"))), false); + QCOMPARE(str.equals(eng.toScriptValue(123)), true); + QCOMPARE(str.equals(eng.toScriptValue(321)), false); + QCOMPARE(str.equals(eng.evaluate("new String('123')")), true); + QCOMPARE(str.equals(eng.evaluate("new String('321')")), false); + QCOMPARE(str.equals(eng.evaluate("new Number(123)")), true); + QCOMPARE(str.equals(eng.evaluate("new Number(321)")), false); + QVERIFY(eng.evaluate("new String('123')").equals(str)); + QCOMPARE(str.equals(QJSValue()), false); + + QJSValue num2 = QJSValue(123); + QCOMPARE(num2.equals(QJSValue(123)), true); + QCOMPARE(num2.equals(QJSValue(321)), false); + QCOMPARE(num2.equals(QJSValue("123")), true); + QCOMPARE(num2.equals(QJSValue("321")), false); + QCOMPARE(num2.equals(QJSValue()), false); + + QJSValue str2 = QJSValue("123"); + QCOMPARE(str2.equals(QJSValue("123")), true); + QCOMPARE(str2.equals(QJSValue("321")), false); + QCOMPARE(str2.equals(QJSValue(123)), true); + QCOMPARE(str2.equals(QJSValue(321)), false); + QCOMPARE(str2.equals(QJSValue()), false); + + QJSValue date1 = eng.toScriptValue(QDateTime(QDate(2000, 1, 1))); + QJSValue date2 = eng.toScriptValue(QDateTime(QDate(1999, 1, 1))); + QCOMPARE(date1.equals(date2), false); + QCOMPARE(date1.equals(date1), true); + QCOMPARE(date2.equals(date2), true); + + QJSValue undefined = eng.toScriptValue(QVariant()); + QJSValue null = eng.evaluate("null"); + QCOMPARE(undefined.equals(undefined), true); + QCOMPARE(null.equals(null), true); + QCOMPARE(undefined.equals(null), true); + QCOMPARE(null.equals(undefined), true); + QVERIFY(undefined.equals(QJSValue())); + QVERIFY(null.equals(QJSValue())); + QVERIFY(!null.equals(num)); + QVERIFY(!undefined.equals(num)); + + QJSValue sant = eng.toScriptValue(true); + QVERIFY(sant.equals(eng.toScriptValue(1))); + QVERIFY(sant.equals(eng.toScriptValue(QString::fromLatin1("1")))); + QVERIFY(sant.equals(sant)); + QVERIFY(sant.equals(eng.evaluate("new Number(1)"))); + QVERIFY(sant.equals(eng.evaluate("new String('1')"))); + QVERIFY(sant.equals(eng.evaluate("new Boolean(true)"))); + QVERIFY(eng.evaluate("new Boolean(true)").equals(sant)); + QVERIFY(!sant.equals(eng.toScriptValue(0))); + QVERIFY(!sant.equals(undefined)); + QVERIFY(!sant.equals(null)); + + QJSValue falskt = eng.toScriptValue(false); + QVERIFY(falskt.equals(eng.toScriptValue(0))); + QVERIFY(falskt.equals(eng.toScriptValue(QString::fromLatin1("0")))); + QVERIFY(falskt.equals(falskt)); + QVERIFY(falskt.equals(eng.evaluate("new Number(0)"))); + QVERIFY(falskt.equals(eng.evaluate("new String('0')"))); + QVERIFY(falskt.equals(eng.evaluate("new Boolean(false)"))); + QVERIFY(eng.evaluate("new Boolean(false)").equals(falskt)); + QVERIFY(!falskt.equals(sant)); + QVERIFY(!falskt.equals(undefined)); + QVERIFY(!falskt.equals(null)); + + QJSValue obj1 = eng.newObject(); + QJSValue obj2 = eng.newObject(); + QCOMPARE(obj1.equals(obj2), false); + QCOMPARE(obj2.equals(obj1), false); + QCOMPARE(obj1.equals(obj1), true); + QCOMPARE(obj2.equals(obj2), true); + + QJSValue qobj1 = eng.newQObject(this); + QJSValue qobj2 = eng.newQObject(this); + QJSValue qobj3 = eng.newQObject(0); + + // FIXME: No ScriptOwnership: QJSValue qobj4 = eng.newQObject(new QObject(), QScriptEngine::ScriptOwnership); + QJSValue qobj4 = eng.newQObject(new QObject()); + + QVERIFY(qobj1.equals(qobj2)); // compares the QObject pointers + QVERIFY(!qobj2.equals(qobj4)); // compares the QObject pointers + QVERIFY(!qobj2.equals(obj2)); // compares the QObject pointers + + QJSValue compareFun = eng.evaluate("(function(a, b) { return a == b; })"); + QVERIFY(compareFun.isCallable()); + { + QJSValue ret = compareFun.call(QJSValueList() << qobj1 << qobj2); + QVERIFY(ret.isBool()); + ret = compareFun.call(QJSValueList() << qobj1 << qobj3); + QVERIFY(ret.isBool()); + QVERIFY(!ret.toBool()); + ret = compareFun.call(QJSValueList() << qobj1 << qobj4); + QVERIFY(ret.isBool()); + QVERIFY(!ret.toBool()); + ret = compareFun.call(QJSValueList() << qobj1 << obj1); + QVERIFY(ret.isBool()); + QVERIFY(!ret.toBool()); + } + + { + QJSValue var1 = eng.toScriptValue(QVariant(QPoint(1, 2))); + QJSValue var2 = eng.toScriptValue(QVariant(QPoint(1, 2))); + QEXPECT_FAIL("", "FIXME: QVariant comparison does not work with v8", Continue); + QVERIFY(var1.equals(var2)); + } + { + QJSValue var1 = eng.toScriptValue(QVariant(QPoint(1, 2))); + QJSValue var2 = eng.toScriptValue(QVariant(QPoint(3, 4))); + QVERIFY(!var1.equals(var2)); + } + + QJSEngine otherEngine; + QTest::ignoreMessage(QtWarningMsg, "QJSValue::equals: " + "cannot compare to a value created in " + "a different engine"); + QCOMPARE(date1.equals(otherEngine.toScriptValue(123)), false); +} + +void tst_QJSValue::strictlyEquals() +{ + QJSEngine eng; + + QVERIFY(QJSValue().strictlyEquals(QJSValue())); + + QJSValue num = eng.toScriptValue(123); + QCOMPARE(num.strictlyEquals(eng.toScriptValue(123)), true); + QCOMPARE(num.strictlyEquals(eng.toScriptValue(321)), false); + QCOMPARE(num.strictlyEquals(eng.toScriptValue(QString::fromLatin1("123"))), false); + QCOMPARE(num.strictlyEquals(eng.toScriptValue(QString::fromLatin1("321"))), false); + QCOMPARE(num.strictlyEquals(eng.evaluate("new Number(123)")), false); + QCOMPARE(num.strictlyEquals(eng.evaluate("new Number(321)")), false); + QCOMPARE(num.strictlyEquals(eng.evaluate("new String('123')")), false); + QCOMPARE(num.strictlyEquals(eng.evaluate("new String('321')")), false); + QVERIFY(!eng.evaluate("new Number(123)").strictlyEquals(num)); + QVERIFY(!num.strictlyEquals(QJSValue())); + QVERIFY(!QJSValue().strictlyEquals(num)); + + QJSValue str = eng.toScriptValue(QString::fromLatin1("123")); + QCOMPARE(str.strictlyEquals(eng.toScriptValue(QString::fromLatin1("123"))), true); + QCOMPARE(str.strictlyEquals(eng.toScriptValue(QString::fromLatin1("321"))), false); + QCOMPARE(str.strictlyEquals(eng.toScriptValue(123)), false); + QCOMPARE(str.strictlyEquals(eng.toScriptValue(321)), false); + QCOMPARE(str.strictlyEquals(eng.evaluate("new String('123')")), false); + QCOMPARE(str.strictlyEquals(eng.evaluate("new String('321')")), false); + QCOMPARE(str.strictlyEquals(eng.evaluate("new Number(123)")), false); + QCOMPARE(str.strictlyEquals(eng.evaluate("new Number(321)")), false); + QVERIFY(!eng.evaluate("new String('123')").strictlyEquals(str)); + QVERIFY(!str.strictlyEquals(QJSValue())); + + QJSValue num2 = QJSValue(123); + QCOMPARE(num2.strictlyEquals(QJSValue(123)), true); + QCOMPARE(num2.strictlyEquals(QJSValue(321)), false); + QCOMPARE(num2.strictlyEquals(QJSValue("123")), false); + QCOMPARE(num2.strictlyEquals(QJSValue("321")), false); + QVERIFY(!num2.strictlyEquals(QJSValue())); + + QJSValue str2 = QJSValue("123"); + QCOMPARE(str2.strictlyEquals(QJSValue("123")), true); + QCOMPARE(str2.strictlyEquals(QJSValue("321")), false); + QCOMPARE(str2.strictlyEquals(QJSValue(123)), false); + QCOMPARE(str2.strictlyEquals(QJSValue(321)), false); + QVERIFY(!str2.strictlyEquals(QJSValue())); + + QJSValue date1 = eng.toScriptValue(QDateTime(QDate(2000, 1, 1))); + QJSValue date2 = eng.toScriptValue(QDateTime(QDate(1999, 1, 1))); + QCOMPARE(date1.strictlyEquals(date2), false); + QCOMPARE(date1.strictlyEquals(date1), true); + QCOMPARE(date2.strictlyEquals(date2), true); + QVERIFY(!date1.strictlyEquals(QJSValue())); + + QJSValue undefined = eng.toScriptValue(QVariant()); + QJSValue null = eng.evaluate("null"); + QCOMPARE(undefined.strictlyEquals(undefined), true); + QCOMPARE(null.strictlyEquals(null), true); + QCOMPARE(undefined.strictlyEquals(null), false); + QCOMPARE(null.strictlyEquals(undefined), false); + QVERIFY(!null.strictlyEquals(QJSValue())); + + QJSValue sant = eng.toScriptValue(true); + QVERIFY(!sant.strictlyEquals(eng.toScriptValue(1))); + QVERIFY(!sant.strictlyEquals(eng.toScriptValue(QString::fromLatin1("1")))); + QVERIFY(sant.strictlyEquals(sant)); + QVERIFY(!sant.strictlyEquals(eng.evaluate("new Number(1)"))); + QVERIFY(!sant.strictlyEquals(eng.evaluate("new String('1')"))); + QVERIFY(!sant.strictlyEquals(eng.evaluate("new Boolean(true)"))); + QVERIFY(!eng.evaluate("new Boolean(true)").strictlyEquals(sant)); + QVERIFY(!sant.strictlyEquals(eng.toScriptValue(0))); + QVERIFY(!sant.strictlyEquals(undefined)); + QVERIFY(!sant.strictlyEquals(null)); + QVERIFY(!sant.strictlyEquals(QJSValue())); + + QJSValue falskt = eng.toScriptValue(false); + QVERIFY(!falskt.strictlyEquals(eng.toScriptValue(0))); + QVERIFY(!falskt.strictlyEquals(eng.toScriptValue(QString::fromLatin1("0")))); + QVERIFY(falskt.strictlyEquals(falskt)); + QVERIFY(!falskt.strictlyEquals(eng.evaluate("new Number(0)"))); + QVERIFY(!falskt.strictlyEquals(eng.evaluate("new String('0')"))); + QVERIFY(!falskt.strictlyEquals(eng.evaluate("new Boolean(false)"))); + QVERIFY(!eng.evaluate("new Boolean(false)").strictlyEquals(falskt)); + QVERIFY(!falskt.strictlyEquals(sant)); + QVERIFY(!falskt.strictlyEquals(undefined)); + QVERIFY(!falskt.strictlyEquals(null)); + QVERIFY(!falskt.strictlyEquals(QJSValue())); + + QVERIFY(!QJSValue(false).strictlyEquals(123)); + QVERIFY(!QJSValue(QJSValue::UndefinedValue).strictlyEquals(123)); + QVERIFY(!QJSValue(QJSValue::NullValue).strictlyEquals(123)); + QVERIFY(!QJSValue(false).strictlyEquals("ciao")); + QVERIFY(!QJSValue(QJSValue::UndefinedValue).strictlyEquals("ciao")); + QVERIFY(!QJSValue(QJSValue::NullValue).strictlyEquals("ciao")); + QVERIFY(eng.toScriptValue(QString::fromLatin1("ciao")).strictlyEquals("ciao")); + QVERIFY(QJSValue("ciao").strictlyEquals(eng.toScriptValue(QString::fromLatin1("ciao")))); + QVERIFY(!QJSValue("ciao").strictlyEquals(123)); + QVERIFY(!QJSValue("ciao").strictlyEquals(eng.toScriptValue(123))); + QVERIFY(!QJSValue(123).strictlyEquals("ciao")); + QVERIFY(!QJSValue(123).strictlyEquals(eng.toScriptValue(QString::fromLatin1("ciao")))); + QVERIFY(!eng.toScriptValue(123).strictlyEquals("ciao")); + + QJSValue obj1 = eng.newObject(); + QJSValue obj2 = eng.newObject(); + QCOMPARE(obj1.strictlyEquals(obj2), false); + QCOMPARE(obj2.strictlyEquals(obj1), false); + QCOMPARE(obj1.strictlyEquals(obj1), true); + QCOMPARE(obj2.strictlyEquals(obj2), true); + QVERIFY(!obj1.strictlyEquals(QJSValue())); + + QJSValue qobj1 = eng.newQObject(this); + QJSValue qobj2 = eng.newQObject(this); + QVERIFY(qobj1.strictlyEquals(qobj2)); + + { + QJSValue var1 = eng.toScriptValue(QVariant(QStringList() << "a")); + QJSValue var2 = eng.toScriptValue(QVariant(QStringList() << "a")); + QVERIFY(var1.isArray()); + QVERIFY(var2.isArray()); + QVERIFY(!var1.strictlyEquals(var2)); + } + { + QJSValue var1 = eng.toScriptValue(QVariant(QStringList() << "a")); + QJSValue var2 = eng.toScriptValue(QVariant(QStringList() << "b")); + QVERIFY(!var1.strictlyEquals(var2)); + } + { + QJSValue var1 = eng.toScriptValue(QVariant(QPoint(1, 2))); + QJSValue var2 = eng.toScriptValue(QVariant(QPoint(1, 2))); + QVERIFY(!var1.strictlyEquals(var2)); + } + { + QJSValue var1 = eng.toScriptValue(QVariant(QPoint(1, 2))); + QJSValue var2 = eng.toScriptValue(QVariant(QPoint(3, 4))); + QVERIFY(!var1.strictlyEquals(var2)); + } + + QJSEngine otherEngine; + QTest::ignoreMessage(QtWarningMsg, "QJSValue::strictlyEquals: " + "cannot compare to a value created in " + "a different engine"); + QCOMPARE(date1.strictlyEquals(otherEngine.toScriptValue(123)), false); +} + +Q_DECLARE_METATYPE(int*) +Q_DECLARE_METATYPE(double*) +Q_DECLARE_METATYPE(QColor*) +Q_DECLARE_METATYPE(QBrush*) + +void tst_QJSValue::castToPointer() +{ + QJSEngine eng; + { + QColor c(123, 210, 231); + QJSValue v = eng.toScriptValue(c); + QColor *cp = qjsvalue_cast(v); + QVERIFY(cp != 0); + QCOMPARE(*cp, c); + + QBrush *bp = qjsvalue_cast(v); + QVERIFY(bp == 0); + + QJSValue v2 = eng.toScriptValue(qVariantFromValue(cp)); + QCOMPARE(qjsvalue_cast(v2), cp); + } +} + +void tst_QJSValue::prettyPrinter_data() +{ + QTest::addColumn("function"); + QTest::addColumn("expected"); + QTest::newRow("function() { }") << QString("function() { }") << QString("function () { }"); + QTest::newRow("function foo() { }") << QString("(function foo() { })") << QString("function foo() { }"); + QTest::newRow("function foo(bar) { }") << QString("(function foo(bar) { })") << QString("function foo(bar) { }"); + QTest::newRow("function foo(bar, baz) { }") << QString("(function foo(bar, baz) { })") << QString("function foo(bar, baz) { }"); + QTest::newRow("this") << QString("function() { this; }") << QString("function () { this; }"); + QTest::newRow("identifier") << QString("function(a) { a; }") << QString("function (a) { a; }"); + QTest::newRow("null") << QString("function() { null; }") << QString("function () { null; }"); + QTest::newRow("true") << QString("function() { true; }") << QString("function () { true; }"); + QTest::newRow("false") << QString("function() { false; }") << QString("function () { false; }"); + QTest::newRow("string") << QString("function() { 'test'; }") << QString("function () { \'test\'; }"); + QTest::newRow("string") << QString("function() { \"test\"; }") << QString("function () { \"test\"; }"); + QTest::newRow("number") << QString("function() { 123; }") << QString("function () { 123; }"); + QTest::newRow("number") << QString("function() { 123.456; }") << QString("function () { 123.456; }"); + QTest::newRow("regexp") << QString("function() { /hello/; }") << QString("function () { /hello/; }"); + QTest::newRow("regexp") << QString("function() { /hello/gim; }") << QString("function () { /hello/gim; }"); + QTest::newRow("array") << QString("function() { []; }") << QString("function () { []; }"); + QTest::newRow("array") << QString("function() { [10]; }") << QString("function () { [10]; }"); + QTest::newRow("array") << QString("function() { [10, 20, 30]; }") << QString("function () { [10, 20, 30]; }"); + QTest::newRow("array") << QString("function() { [10, 20, , 40]; }") << QString("function () { [10, 20, , 40]; }"); + QTest::newRow("array") << QString("function() { [,]; }") << QString("function () { [,]; }"); + QTest::newRow("array") << QString("function() { [, 10]; }") << QString("function () { [, 10]; }"); + QTest::newRow("array") << QString("function() { [, 10, ]; }") << QString("function () { [, 10, ]; }"); + QTest::newRow("array") << QString("function() { [, 10, ,]; }") << QString("function () { [, 10, ,]; }"); + QTest::newRow("array") << QString("function() { [[10], [20]]; }") << QString("function () { [[10], [20]]; }"); + QTest::newRow("member") << QString("function() { a.b; }") << QString("function () { a.b; }"); + QTest::newRow("member") << QString("function() { a.b.c; }") << QString("function () { a.b.c; }"); + QTest::newRow("call") << QString("function() { f(); }") << QString("function () { f(); }"); + QTest::newRow("call") << QString("function() { f(a); }") << QString("function () { f(a); }"); + QTest::newRow("call") << QString("function() { f(a, b); }") << QString("function () { f(a, b); }"); + QTest::newRow("new") << QString("function() { new C(); }") << QString("function () { new C(); }"); + QTest::newRow("new") << QString("function() { new C(a); }") << QString("function () { new C(a); }"); + QTest::newRow("new") << QString("function() { new C(a, b); }") << QString("function () { new C(a, b); }"); + QTest::newRow("++") << QString("function() { a++; }") << QString("function () { a++; }"); + QTest::newRow("++") << QString("function() { ++a; }") << QString("function () { ++a; }"); + QTest::newRow("--") << QString("function() { a--; }") << QString("function () { a--; }"); + QTest::newRow("--") << QString("function() { --a; }") << QString("function () { --a; }"); + QTest::newRow("delete") << QString("function() { delete a; }") << QString("function () { delete a; }"); + QTest::newRow("void") << QString("function() { void a; }") << QString("function () { void a; }"); + QTest::newRow("typeof") << QString("function() { typeof a; }") << QString("function () { typeof a; }"); + QTest::newRow("+") << QString("function() { +a; }") << QString("function () { +a; }"); + QTest::newRow("-") << QString("function() { -a; }") << QString("function () { -a; }"); + QTest::newRow("~") << QString("function() { ~a; }") << QString("function () { ~a; }"); + QTest::newRow("!") << QString("function() { !a; }") << QString("function () { !a; }"); + QTest::newRow("+") << QString("function() { a + b; }") << QString("function () { a + b; }"); + QTest::newRow("&&") << QString("function() { a && b; }") << QString("function () { a && b; }"); + QTest::newRow("&=") << QString("function() { a &= b; }") << QString("function () { a &= b; }"); + QTest::newRow("=") << QString("function() { a = b; }") << QString("function () { a = b; }"); + QTest::newRow("&") << QString("function() { a & b; }") << QString("function () { a & b; }"); + QTest::newRow("|") << QString("function() { a | b; }") << QString("function () { a | b; }"); + QTest::newRow("^") << QString("function() { a ^ b; }") << QString("function () { a ^ b; }"); + QTest::newRow("-=") << QString("function() { a -= b; }") << QString("function () { a -= b; }"); + QTest::newRow("/") << QString("function() { a / b; }") << QString("function () { a / b; }"); + QTest::newRow("/=") << QString("function() { a /= b; }") << QString("function () { a /= b; }"); + QTest::newRow("==") << QString("function() { a == b; }") << QString("function () { a == b; }"); + QTest::newRow(">=") << QString("function() { a >= b; }") << QString("function () { a >= b; }"); + QTest::newRow(">") << QString("function() { a > b; }") << QString("function () { a > b; }"); + QTest::newRow("in") << QString("function() { a in b; }") << QString("function () { a in b; }"); + QTest::newRow("+=") << QString("function() { a += b; }") << QString("function () { a += b; }"); + QTest::newRow("instanceof") << QString("function() { a instanceof b; }") << QString("function () { a instanceof b; }"); + QTest::newRow("<=") << QString("function() { a <= b; }") << QString("function () { a <= b; }"); + QTest::newRow("<<") << QString("function() { a << b; }") << QString("function () { a << b; }"); + QTest::newRow("<<=") << QString("function() { a <<= b; }") << QString("function () { a <<= b; }"); + QTest::newRow("<") << QString("function() { a < b; }") << QString("function () { a < b; }"); + QTest::newRow("%") << QString("function() { a % b; }") << QString("function () { a % b; }"); + QTest::newRow("%=") << QString("function() { a %= b; }") << QString("function () { a %= b; }"); + QTest::newRow("*") << QString("function() { a * b; }") << QString("function () { a * b; }"); + QTest::newRow("*=") << QString("function() { a *= b; }") << QString("function () { a *= b; }"); + QTest::newRow("!=") << QString("function() { a != b; }") << QString("function () { a != b; }"); + QTest::newRow("||") << QString("function() { a || b; }") << QString("function () { a || b; }"); + QTest::newRow("|=") << QString("function() { a |= b; }") << QString("function () { a |= b; }"); + QTest::newRow(">>") << QString("function() { a >> b; }") << QString("function () { a >> b; }"); + QTest::newRow(">>=") << QString("function() { a >>= b; }") << QString("function () { a >>= b; }"); + QTest::newRow("===") << QString("function() { a === b; }") << QString("function () { a === b; }"); + QTest::newRow("!==") << QString("function() { a !== b; }") << QString("function () { a !== b; }"); + QTest::newRow("-") << QString("function() { a - b; }") << QString("function () { a - b; }"); + QTest::newRow(">>>") << QString("function() { a >>> b; }") << QString("function () { a >>> b; }"); + QTest::newRow(">>>=") << QString("function() { a >>>= b; }") << QString("function () { a >>>= b; }"); + QTest::newRow("^=") << QString("function() { a ^= b; }") << QString("function () { a ^= b; }"); + QTest::newRow("? :") << QString("function() { a ? b : c; }") << QString("function () { a ? b : c; }"); + QTest::newRow("a; b; c") << QString("function() { a; b; c; }") << QString("function () { a; b; c; }"); + QTest::newRow("var a;") << QString("function() { var a; }") << QString("function () { var a; }"); + QTest::newRow("var a, b;") << QString("function() { var a, b; }") << QString("function () { var a, b; }"); + QTest::newRow("var a = 10;") << QString("function() { var a = 10; }") << QString("function () { var a = 10; }"); + QTest::newRow("var a, b = 20;") << QString("function() { var a, b = 20; }") << QString("function () { var a, b = 20; }"); + QTest::newRow("var a = 10, b = 20;") << QString("function() { var a = 10, b = 20; }") << QString("function () { var a = 10, b = 20; }"); + QTest::newRow("if") << QString("function() { if (a) b; }") << QString("function () { if (a) b; }"); + QTest::newRow("if") << QString("function() { if (a) { b; c; } }") << QString("function () { if (a) { b; c; } }"); + QTest::newRow("if-else") << QString("function() { if (a) b; else c; }") << QString("function () { if (a) b; else c; }"); + QTest::newRow("if-else") << QString("function() { if (a) { b; c; } else { d; e; } }") << QString("function () { if (a) { b; c; } else { d; e; } }"); + QTest::newRow("do-while") << QString("function() { do { a; } while (b); }") << QString("function () { do { a; } while (b); }"); + QTest::newRow("do-while") << QString("function() { do { a; b; c; } while (d); }") << QString("function () { do { a; b; c; } while (d); }"); + QTest::newRow("while") << QString("function() { while (a) { b; } }") << QString("function () { while (a) { b; } }"); + QTest::newRow("while") << QString("function() { while (a) { b; c; } }") << QString("function () { while (a) { b; c; } }"); + QTest::newRow("for") << QString("function() { for (a; b; c) { } }") << QString("function () { for (a; b; c) { } }"); + QTest::newRow("for") << QString("function() { for (; a; b) { } }") << QString("function () { for (; a; b) { } }"); + QTest::newRow("for") << QString("function() { for (; ; a) { } }") << QString("function () { for (; ; a) { } }"); + QTest::newRow("for") << QString("function() { for (; ; ) { } }") << QString("function () { for (; ; ) { } }"); + QTest::newRow("for") << QString("function() { for (var a; b; c) { } }") << QString("function () { for (var a; b; c) { } }"); + QTest::newRow("for") << QString("function() { for (var a, b, c; d; e) { } }") << QString("function () { for (var a, b, c; d; e) { } }"); + QTest::newRow("continue") << QString("function() { for (; ; ) { continue; } }") << QString("function () { for (; ; ) { continue; } }"); + QTest::newRow("break") << QString("function() { for (; ; ) { break; } }") << QString("function () { for (; ; ) { break; } }"); + QTest::newRow("return") << QString("function() { return; }") << QString("function () { return; }"); + QTest::newRow("return") << QString("function() { return 10; }") << QString("function () { return 10; }"); + QTest::newRow("with") << QString("function() { with (a) { b; } }") << QString("function () { with (a) { b; } }"); + QTest::newRow("with") << QString("function() { with (a) { b; c; } }") << QString("function () { with (a) { b; c; } }"); + QTest::newRow("switch") << QString("function() { switch (a) { } }") << QString("function () { switch (a) { } }"); + QTest::newRow("switch") << QString("function() { switch (a) { case 1: ; } }") << QString("function () { switch (a) { case 1: ; } }"); + QTest::newRow("switch") << QString("function() { switch (a) { case 1: b; break; } }") << QString("function () { switch (a) { case 1: b; break; } }"); + QTest::newRow("switch") << QString("function() { switch (a) { case 1: b; break; case 2: break; } }") << QString("function () { switch (a) { case 1: b; break; case 2: break; } }"); + QTest::newRow("switch") << QString("function() { switch (a) { case 1: case 2: ; } }") << QString("function () { switch (a) { case 1: case 2: ; } }"); + QTest::newRow("switch") << QString("function() { switch (a) { case 1: default: ; } }") << QString("function () { switch (a) { case 1: default: ; } }"); + QTest::newRow("switch") << QString("function() { switch (a) { case 1: default: ; case 3: ; } }") << QString("function () { switch (a) { case 1: default: ; case 3: ; } }"); + QTest::newRow("label") << QString("function() { a: b; }") << QString("function () { a: b; }"); + QTest::newRow("throw") << QString("function() { throw a; }") << QString("function () { throw a; }"); + QTest::newRow("try-catch") << QString("function() { try { a; } catch (e) { b; } }") << QString("function () { try { a; } catch (e) { b; } }"); + QTest::newRow("try-finally") << QString("function() { try { a; } finally { b; } }") << QString("function () { try { a; } finally { b; } }"); + QTest::newRow("try-catch-finally") << QString("function() { try { a; } catch (e) { b; } finally { c; } }") << QString("function () { try { a; } catch (e) { b; } finally { c; } }"); + QTest::newRow("a + b + c + d") << QString("function() { a + b + c + d; }") << QString("function () { a + b + c + d; }"); + QTest::newRow("a + b - c") << QString("function() { a + b - c; }") << QString("function () { a + b - c; }"); + QTest::newRow("a + -b") << QString("function() { a + -b; }") << QString("function () { a + -b; }"); + QTest::newRow("a + ~b") << QString("function() { a + ~b; }") << QString("function () { a + ~b; }"); + QTest::newRow("a + !b") << QString("function() { a + !b; }") << QString("function () { a + !b; }"); + QTest::newRow("a + +b") << QString("function() { a + +b; }") << QString("function () { a + +b; }"); + QTest::newRow("(a + b) - c") << QString("function() { (a + b) - c; }") << QString("function () { (a + b) - c; }"); + QTest::newRow("(a - b + c") << QString("function() { a - b + c; }") << QString("function () { a - b + c; }"); + QTest::newRow("(a - (b + c)") << QString("function() { a - (b + c); }") << QString("function () { a - (b + c); }"); + QTest::newRow("a + -(b + c)") << QString("function() { a + -(b + c); }") << QString("function () { a + -(b + c); }"); + QTest::newRow("a + ~(b + c)") << QString("function() { a + ~(b + c); }") << QString("function () { a + ~(b + c); }"); + QTest::newRow("a + !(b + c)") << QString("function() { a + !(b + c); }") << QString("function () { a + !(b + c); }"); + QTest::newRow("a + +(b + c)") << QString("function() { a + +(b + c); }") << QString("function () { a + +(b + c); }"); + QTest::newRow("a + b * c") << QString("function() { a + b * c; }") << QString("function () { a + b * c; }"); + QTest::newRow("(a + b) * c") << QString("function() { (a + b) * c; }") << QString("function () { (a + b) * c; }"); + QTest::newRow("(a + b) * (c + d)") << QString("function() { (a + b) * (c + d); }") << QString("function () { (a + b) * (c + d); }"); + QTest::newRow("a + (b * c)") << QString("function() { a + (b * c); }") << QString("function () { a + (b * c); }"); + QTest::newRow("a + (b / c)") << QString("function() { a + (b / c); }") << QString("function () { a + (b / c); }"); + QTest::newRow("(a / b) * c") << QString("function() { (a / b) * c; }") << QString("function () { (a / b) * c; }"); + QTest::newRow("a / (b * c)") << QString("function() { a / (b * c); }") << QString("function () { a / (b * c); }"); + QTest::newRow("a / (b % c)") << QString("function() { a / (b % c); }") << QString("function () { a / (b % c); }"); + QTest::newRow("a && b || c") << QString("function() { a && b || c; }") << QString("function () { a && b || c; }"); + QTest::newRow("a && (b || c)") << QString("function() { a && (b || c); }") << QString("function () { a && (b || c); }"); + QTest::newRow("a & b | c") << QString("function() { a & b | c; }") << QString("function () { a & b | c; }"); + QTest::newRow("a & (b | c)") << QString("function() { a & (b | c); }") << QString("function () { a & (b | c); }"); + QTest::newRow("a & b | c ^ d") << QString("function() { a & b | c ^ d; }") << QString("function () { a & b | c ^ d; }"); + QTest::newRow("a & (b | c ^ d)") << QString("function() { a & (b | c ^ d); }") << QString("function () { a & (b | c ^ d); }"); + QTest::newRow("(a & b | c) ^ d") << QString("function() { (a & b | c) ^ d; }") << QString("function () { (a & b | c) ^ d; }"); + QTest::newRow("a << b + c") << QString("function() { a << b + c; }") << QString("function () { a << b + c; }"); + QTest::newRow("(a << b) + c") << QString("function() { (a << b) + c; }") << QString("function () { (a << b) + c; }"); + QTest::newRow("a >> b + c") << QString("function() { a >> b + c; }") << QString("function () { a >> b + c; }"); + QTest::newRow("(a >> b) + c") << QString("function() { (a >> b) + c; }") << QString("function () { (a >> b) + c; }"); + QTest::newRow("a >>> b + c") << QString("function() { a >>> b + c; }") << QString("function () { a >>> b + c; }"); + QTest::newRow("(a >>> b) + c") << QString("function() { (a >>> b) + c; }") << QString("function () { (a >>> b) + c; }"); + QTest::newRow("a == b || c != d") << QString("function() { a == b || c != d; }") << QString("function () { a == b || c != d; }"); + QTest::newRow("a == (b || c != d)") << QString("function() { a == (b || c != d); }") << QString("function () { a == (b || c != d); }"); + QTest::newRow("a === b || c !== d") << QString("function() { a === b || c !== d; }") << QString("function () { a === b || c !== d; }"); + QTest::newRow("a === (b || c !== d)") << QString("function() { a === (b || c !== d); }") << QString("function () { a === (b || c !== d); }"); + QTest::newRow("a &= b + c") << QString("function() { a &= b + c; }") << QString("function () { a &= b + c; }"); + QTest::newRow("debugger") << QString("function() { debugger; }") << QString("function () { debugger; }"); +} + +void tst_QJSValue::prettyPrinter() +{ + QFETCH(QString, function); + QFETCH(QString, expected); + QJSEngine eng; + QJSValue val = eng.evaluate("(" + function + ")"); + QVERIFY(val.isCallable()); + QString actual = val.toString(); + int count = qMin(actual.size(), expected.size()); +// qDebug() << actual << expected; + for (int i = 0; i < count; ++i) { +// qDebug() << i << actual.at(i) << expected.at(i); + QCOMPARE(actual.at(i), expected.at(i)); + } + QCOMPARE(actual.size(), expected.size()); +} + +void tst_QJSValue::engineDeleted() +{ + QJSEngine *eng = new QJSEngine; + QJSValue v1 = eng->toScriptValue(123); + QVERIFY(v1.isNumber()); + QJSValue v2 = eng->toScriptValue(QString("ciao")); + QVERIFY(v2.isString()); + QJSValue v3 = eng->newObject(); + QVERIFY(v3.isObject()); + QJSValue v4 = eng->newQObject(this); + QVERIFY(v4.isQObject()); + QJSValue v5 = "Hello"; + QVERIFY(v2.isString()); + + delete eng; + + QVERIFY(v1.isUndefined()); + QVERIFY(v1.engine() == 0); + QVERIFY(v2.isUndefined()); + QVERIFY(v2.engine() == 0); + QVERIFY(v3.isUndefined()); + QVERIFY(v3.engine() == 0); + QVERIFY(v4.isUndefined()); + QVERIFY(v4.engine() == 0); + QVERIFY(v5.isString()); // was not bound to engine + QVERIFY(v5.engine() == 0); + + QVERIFY(v3.property("foo").isUndefined()); +} + +void tst_QJSValue::valueOfWithClosure() +{ + QJSEngine eng; + // valueOf() + { + QJSValue obj = eng.evaluate("o = {}; (function(foo) { o.valueOf = function() { return foo; } })(123); o"); + QVERIFY(obj.isObject()); + QCOMPARE(obj.toInt(), 123); + } + // toString() + { + QJSValue obj = eng.evaluate("o = {}; (function(foo) { o.toString = function() { return foo; } })('ciao'); o"); + QVERIFY(obj.isObject()); + QCOMPARE(obj.toString(), QString::fromLatin1("ciao")); + } +} + +#if 0 // FIXME: no objectId() +void tst_QJSValue::objectId() +{ + QCOMPARE(QJSValue().objectId(), (qint64)-1); + QCOMPARE(QJSValue(QJSValue::UndefinedValue).objectId(), (qint64)-1); + QCOMPARE(QJSValue(QJSValue::NullValue).objectId(), (qint64)-1); + QCOMPARE(QJSValue(false).objectId(), (qint64)-1); + QCOMPARE(QJSValue(123).objectId(), (qint64)-1); + QCOMPARE(QJSValue(uint(123)).objectId(), (qint64)-1); + QCOMPARE(QJSValue(123.5).objectId(), (qint64)-1); + QCOMPARE(QJSValue("ciao").objectId(), (qint64)-1); + + QScriptEngine eng; + QJSValue o1 = eng.newObject(); + QVERIFY(o1.objectId() != -1); + QJSValue o2 = eng.newObject(); + QVERIFY(o2.objectId() != -1); + QVERIFY(o1.objectId() != o2.objectId()); + + QVERIFY(eng.objectById(o1.objectId()).strictlyEquals(o1)); + QVERIFY(eng.objectById(o2.objectId()).strictlyEquals(o2)); + + qint64 globalObjectId = -1; + { + QJSValue global = eng.globalObject(); + globalObjectId = global.objectId(); + QVERIFY(globalObjectId != -1); + QVERIFY(eng.objectById(globalObjectId).strictlyEquals(global)); + } + QJSValue obj = eng.objectById(globalObjectId); + QVERIFY(obj.isObject()); + QVERIFY(obj.strictlyEquals(eng.globalObject())); +} +#endif + +void tst_QJSValue::nestedObjectToVariant_data() +{ + QTest::addColumn("program"); + QTest::addColumn("expected"); + + // Array literals + QTest::newRow("[[]]") + << QString::fromLatin1("[[]]") + << QVariant(QVariantList() << (QVariant(QVariantList()))); + QTest::newRow("[[123]]") + << QString::fromLatin1("[[123]]") + << QVariant(QVariantList() << (QVariant(QVariantList() << 123))); + QTest::newRow("[[], 123]") + << QString::fromLatin1("[[], 123]") + << QVariant(QVariantList() << QVariant(QVariantList()) << 123); + + // Cyclic arrays + QTest::newRow("var a=[]; a.push(a)") + << QString::fromLatin1("var a=[]; a.push(a); a") + << QVariant(QVariantList() << QVariant(QVariantList())); + QTest::newRow("var a=[]; a.push(123, a)") + << QString::fromLatin1("var a=[]; a.push(123, a); a") + << QVariant(QVariantList() << 123 << QVariant(QVariantList())); + QTest::newRow("var a=[]; var b=[]; a.push(b); b.push(a)") + << QString::fromLatin1("var a=[]; var b=[]; a.push(b); b.push(a); a") + << QVariant(QVariantList() << QVariant(QVariantList() << QVariant(QVariantList()))); + QTest::newRow("var a=[]; var b=[]; a.push(123, b); b.push(456, a)") + << QString::fromLatin1("var a=[]; var b=[]; a.push(123, b); b.push(456, a); a") + << QVariant(QVariantList() << 123 << QVariant(QVariantList() << 456 << QVariant(QVariantList()))); + + // Object literals + { + QVariantMap m; + QTest::newRow("{}") + << QString::fromLatin1("({})") + << QVariant(m); + } + { + QVariantMap m; + m["a"] = QVariantMap(); + QTest::newRow("{ a:{} }") + << QString::fromLatin1("({ a:{} })") + << QVariant(m); + } + { + QVariantMap m, m2; + m2["b"] = 10; + m2["c"] = 20; + m["a"] = m2; + QTest::newRow("{ a:{b:10, c:20} }") + << QString::fromLatin1("({ a:{b:10, c:20} })") + << QVariant(m); + } + { + QVariantMap m; + m["a"] = 10; + m["b"] = QVariantList() << 20 << 30; + QTest::newRow("{ a:10, b:[20, 30]}") + << QString::fromLatin1("({ a:10, b:[20,30]})") + << QVariant(m); + } + + // Cyclic objects + { + QVariantMap m; + m["p"] = QVariantMap(); + QTest::newRow("var o={}; o.p=o") + << QString::fromLatin1("var o={}; o.p=o; o") + << QVariant(m); + } + { + QVariantMap m; + m["p"] = 123; + m["q"] = QVariantMap(); + QTest::newRow("var o={}; o.p=123; o.q=o") + << QString::fromLatin1("var o={}; o.p=123; o.q=o; o") + << QVariant(m); + } +} + +void tst_QJSValue::nestedObjectToVariant() +{ + QJSEngine eng; + QFETCH(QString, program); + QFETCH(QVariant, expected); + QJSValue o = eng.evaluate(program); + QVERIFY(!o.isError()); + QVERIFY(o.isObject()); + QCOMPARE(o.toVariant(), expected); +} + +QTEST_MAIN(tst_QJSValue) diff --git a/tests/auto/qml/qjsvalue/tst_qjsvalue.h b/tests/auto/qml/qjsvalue/tst_qjsvalue.h new file mode 100644 index 0000000000..0e7f7405a6 --- /dev/null +++ b/tests/auto/qml/qjsvalue/tst_qjsvalue.h @@ -0,0 +1,204 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef TST_QJSVALUE_H +#define TST_QJSVALUE_H + +#include +#include +#include +#include +#include + +Q_DECLARE_METATYPE(QVariant) +Q_DECLARE_METATYPE(QJSValue) + +class tst_QJSValue : public QObject +{ + Q_OBJECT + +public: + tst_QJSValue(); + virtual ~tst_QJSValue(); + +private slots: + void ctor_invalid(); + void ctor_undefinedWithEngine(); + void ctor_undefined(); + void ctor_nullWithEngine(); + void ctor_null(); + void ctor_boolWithEngine(); + void ctor_bool(); + void ctor_intWithEngine(); + void ctor_int(); + void ctor_uintWithEngine(); + void ctor_uint(); + void ctor_floatWithEngine(); + void ctor_float(); + void ctor_stringWithEngine(); + void ctor_string(); + void ctor_copyAndAssignWithEngine(); + void ctor_copyAndAssign(); + + void toString(); + void toNumber(); + void toBoolean(); + void toBool(); + void toInt(); + void toUInt(); + void toVariant(); + void toQObject_nonQObject_data(); + void toQObject_nonQObject(); + void toQObject(); + void toDateTime(); + void toRegExp(); + void isArray_data(); + void isArray(); + void isDate(); + void isDate_data(); + void isError_propertiesOfGlobalObject(); + void isError_data(); + void isError(); + void isRegExp_data(); + void isRegExp(); + +#if 0 // FIXME: No QScriptValue::lessThan + void lessThan(); +#endif + void equals(); + void strictlyEquals(); + + void hasProperty_basic(); + void hasProperty_globalObject(); + void hasProperty_changePrototype(); + + void deleteProperty_basic(); + void deleteProperty_globalObject(); + void deleteProperty_inPrototype(); + + void getSetPrototype_cyclicPrototype(); + void getSetPrototype_evalCyclicPrototype(); + void getSetPrototype_eval(); + void getSetPrototype_invalidPrototype(); + void getSetPrototype_twoEngines(); + void getSetPrototype_null(); + void getSetPrototype_notObjectOrNull(); + void getSetPrototype(); + void getSetScope(); + void getSetProperty_HooliganTask162051(); + void getSetProperty_HooliganTask183072(); + void getSetProperty_propertyRemoval(); + void getSetProperty_resolveMode(); + void getSetProperty_twoEngines(); + void getSetProperty_gettersAndSetters(); + void getSetProperty_gettersAndSettersThrowErrorNative(); + void getSetProperty_gettersAndSettersThrowErrorJS(); + void getSetProperty_gettersAndSettersOnNative(); + void getSetProperty_gettersAndSettersOnGlobalObject(); + void getSetProperty_gettersAndSettersChange(); + void getSetProperty_gettersAndSettersStupid(); + void getSetProperty_array(); + void getSetProperty(); + void arrayElementGetterSetter(); + void getSetData_objects_data(); + void getSetData_objects(); + void getSetData_nonObjects_data(); + void getSetData_nonObjects(); + void setData_QTBUG15144(); +#if 0 // FIXME: no QScriptClass + void getSetScriptClass_emptyClass_data(); + void getSetScriptClass_emptyClass(); + void getSetScriptClass_JSObjectFromCpp(); + void getSetScriptClass_JSObjectFromJS(); + void getSetScriptClass_QVariant(); + void getSetScriptClass_QObject(); +#endif + void call_function(); + void call_object(); + void call_newObjects(); + void call_this(); + void call_arguments(); + void call(); + void call_invalidArguments(); + void call_invalidReturn(); + void call_twoEngines(); + void call_array(); + void call_nonFunction_data(); + void call_nonFunction(); + void construct_nonFunction_data(); + void construct_nonFunction(); + void construct_simple(); + void construct_newObjectJS(); +#if 0 // FIXME: no c-style callbacks + void construct_undefined(); + void construct_newObjectCpp(); +#endif + void construct_arg(); + void construct_proto(); + void construct_returnInt(); + void construct_throw(); +#if 0 // FIXME: The feature of interpreting an array as argument list has been removed from the API + void construct(); +#endif + void construct_twoEngines(); + void construct_constructorThrowsPrimitive(); + void castToPointer(); + void prettyPrinter_data(); + void prettyPrinter(); + void engineDeleted(); + void valueOfWithClosure(); +#if 0 // FIXME: no objectId() + void objectId(); +#endif + void nestedObjectToVariant_data(); + void nestedObjectToVariant(); + +private: + void newEngine() + { + if (engine) + delete engine; + engine = new QJSEngine(); + } + QJSEngine *engine; +}; + +#endif diff --git a/tests/auto/qml/qjsvalueiterator/qjsvalueiterator.pro b/tests/auto/qml/qjsvalueiterator/qjsvalueiterator.pro new file mode 100644 index 0000000000..4ee1693ad8 --- /dev/null +++ b/tests/auto/qml/qjsvalueiterator/qjsvalueiterator.pro @@ -0,0 +1,7 @@ +CONFIG += testcase +TARGET = tst_qjsvalueiterator +macx:CONFIG -= app_bundle +QT = core qml testlib +SOURCES += tst_qjsvalueiterator.cpp + + diff --git a/tests/auto/qml/qjsvalueiterator/tst_qjsvalueiterator.cpp b/tests/auto/qml/qjsvalueiterator/tst_qjsvalueiterator.cpp new file mode 100644 index 0000000000..eade3de1a7 --- /dev/null +++ b/tests/auto/qml/qjsvalueiterator/tst_qjsvalueiterator.cpp @@ -0,0 +1,522 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + + +#include + +#include +#include +#include + +Q_DECLARE_METATYPE(QJSValue); + +class tst_QJSValueIterator : public QObject +{ + Q_OBJECT + +public: + tst_QJSValueIterator(); + virtual ~tst_QJSValueIterator(); + +private slots: + void iterateForward_data(); + void iterateForward(); + void iterateArray_data(); + void iterateArray(); + void iterateString(); +#if 0 + void iterateGetterSetter(); +#endif + void assignObjectToIterator(); + void iterateNonObject(); + void iterateOverObjectFromDeletedEngine(); +}; + +tst_QJSValueIterator::tst_QJSValueIterator() +{ +} + +tst_QJSValueIterator::~tst_QJSValueIterator() +{ +} + +void tst_QJSValueIterator::iterateForward_data() +{ + QTest::addColumn("propertyNames"); + QTest::addColumn("propertyValues"); + + QTest::newRow("no properties") + << QStringList() << QStringList(); + QTest::newRow("foo=bar") + << (QStringList() << "foo") + << (QStringList() << "bar"); + QTest::newRow("foo=bar, baz=123") + << (QStringList() << "foo" << "baz") + << (QStringList() << "bar" << "123"); + QTest::newRow("foo=bar, baz=123, rab=oof") + << (QStringList() << "foo" << "baz" << "rab") + << (QStringList() << "bar" << "123" << "oof"); +} + +void tst_QJSValueIterator::iterateForward() +{ + QFETCH(QStringList, propertyNames); + QFETCH(QStringList, propertyValues); + QMap pmap; + QVERIFY(propertyNames.size() == propertyValues.size()); + + QJSEngine engine; + QJSValue object = engine.newObject(); + for (int i = 0; i < propertyNames.size(); ++i) { + QString name = propertyNames.at(i); + QString value = propertyValues.at(i); + pmap.insert(name, value); + object.setProperty(name, engine.toScriptValue(value)); + } + QJSValue otherObject = engine.newObject(); + otherObject.setProperty("foo", engine.toScriptValue(123456)); + otherObject.setProperty("protoProperty", engine.toScriptValue(654321)); + object.setPrototype(otherObject); // should not affect iterator + + QStringList lst; + QJSValueIterator it(object); + while (!pmap.isEmpty()) { + QCOMPARE(it.hasNext(), true); + QCOMPARE(it.hasNext(), true); + it.next(); + QString name = it.name(); + QCOMPARE(pmap.contains(name), true); + QCOMPARE(it.name(), name); + QCOMPARE(it.value().strictlyEquals(engine.toScriptValue(pmap.value(name))), true); + pmap.remove(name); + lst.append(name); + } + + QCOMPARE(it.hasNext(), false); + QCOMPARE(it.hasNext(), false); + + it = object; + for (int i = 0; i < lst.count(); ++i) { + QCOMPARE(it.hasNext(), true); + it.next(); + QCOMPARE(it.name(), lst.at(i)); + } +} + +void tst_QJSValueIterator::iterateArray_data() +{ + QTest::addColumn("propertyNames"); + QTest::addColumn("propertyValues"); + + QTest::newRow("no elements") << QStringList() << QStringList(); + + QTest::newRow("0=foo, 1=barr") + << (QStringList() << "0" << "1") + << (QStringList() << "foo" << "bar"); + + + QTest::newRow("0=foo, 3=barr") + << (QStringList() << "0" << "1" << "2" << "3") + << (QStringList() << "foo" << "" << "" << "bar"); +} + +void tst_QJSValueIterator::iterateArray() +{ + QFETCH(QStringList, propertyNames); + QFETCH(QStringList, propertyValues); + + QJSEngine engine; + QJSValue array = engine.newArray(); + + // Fill the array + for (int i = 0; i < propertyNames.size(); ++i) { + array.setProperty(propertyNames.at(i), propertyValues.at(i)); + } + + // Iterate thru array properties. Note that the QJSValueIterator doesn't guarantee + // any order on the iteration! + int length = array.property("length").toInt(); + QCOMPARE(length, propertyNames.size()); + + bool iteratedThruLength = false; + QHash arrayProperties; + QJSValueIterator it(array); + + // Iterate forward + while (it.hasNext()) { + it.next(); + + const QString name = it.name(); + if (name == QString::fromLatin1("length")) { + QVERIFY(it.value().isNumber()); + QCOMPARE(it.value().toInt(), length); + QVERIFY2(!iteratedThruLength, "'length' appeared more than once during iteration."); + iteratedThruLength = true; + continue; + } + + // Storing the properties we iterate in a hash to compare with test data. + QVERIFY2(!arrayProperties.contains(name), "property appeared more than once during iteration."); + arrayProperties.insert(name, it.value()); + QVERIFY(it.value().strictlyEquals(array.property(name))); + } + + // Verify properties + QVERIFY(iteratedThruLength); + QCOMPARE(arrayProperties.size(), propertyNames.size()); + for (int i = 0; i < propertyNames.size(); ++i) { + QVERIFY(arrayProperties.contains(propertyNames.at(i))); + QCOMPARE(arrayProperties.value(propertyNames.at(i)).toString(), propertyValues.at(i)); + } + +#if 0 + + // Iterate backwards + arrayProperties.clear(); + iteratedThruLength = false; + it.toBack(); + + while (it.hasPrevious()) { + it.previous(); + + const QString name = it.name(); + if (name == QString::fromLatin1("length")) { + QVERIFY(it.value().isNumber()); + QCOMPARE(it.value().toInt(), length); + QCOMPARE(it.flags(), QScriptValue::SkipInEnumeration | QScriptValue::Undeletable); + QVERIFY2(!iteratedThruLength, "'length' appeared more than once during iteration."); + iteratedThruLength = true; + continue; + } + + // Storing the properties we iterate in a hash to compare with test data. + QVERIFY2(!arrayProperties.contains(name), "property appeared more than once during iteration."); + arrayProperties.insert(name, it.value()); + QCOMPARE(it.flags(), array.propertyFlags(name)); + QVERIFY(it.value().strictlyEquals(array.property(name))); + } + + // Verify properties + QVERIFY(iteratedThruLength); + QCOMPARE(arrayProperties.size(), propertyNames.size()); + for (int i = 0; i < propertyNames.size(); ++i) { + QVERIFY(arrayProperties.contains(propertyNames.at(i))); + QCOMPARE(arrayProperties.value(propertyNames.at(i)).toString(), propertyValues.at(i)); + } + + // ### Do we still need this test? + // Forward test again but as object + arrayProperties.clear(); + iteratedThruLength = false; + QJSValue arrayObject = engine.toObject(array); + QJSValueIterator it2(arrayObject); + + while (it2.hasNext()) { + it2.next(); + + const QString name = it2.name(); + if (name == QString::fromLatin1("length")) { + QVERIFY(it2.value().isNumber()); + QCOMPARE(it2.value().toInt(), length); + QCOMPARE(it2.flags(), QScriptValue::SkipInEnumeration | QScriptValue::Undeletable); + QVERIFY2(!iteratedThruLength, "'length' appeared more than once during iteration."); + iteratedThruLength = true; + continue; + } + + // Storing the properties we iterate in a hash to compare with test data. + QVERIFY2(!arrayProperties.contains(name), "property appeared more than once during iteration."); + arrayProperties.insert(name, it2.value()); + QCOMPARE(it2.flags(), arrayObject.propertyFlags(name)); + QVERIFY(it2.value().strictlyEquals(arrayObject.property(name))); + } + + // Verify properties + QVERIFY(iteratedThruLength); + QCOMPARE(arrayProperties.size(), propertyNames.size()); + for (int i = 0; i < propertyNames.size(); ++i) { + QVERIFY(arrayProperties.contains(propertyNames.at(i))); + QCOMPARE(arrayProperties.value(propertyNames.at(i)).toString(), propertyValues.at(i)); + } +#endif +} + +void tst_QJSValueIterator::iterateString() +{ + QJSEngine engine; + QJSValue obj = engine.evaluate("new String('ciao')"); + QVERIFY(obj.property("length").isNumber()); + int length = obj.property("length").toInt(); + QCOMPARE(length, 4); + + QJSValueIterator it(obj); + QHash stringProperties; + bool iteratedThruLength = false; + + while (it.hasNext()) { + it.next(); + const QString name = it.name(); + + if (name == QString::fromLatin1("length")) { + QVERIFY(it.value().isNumber()); + QCOMPARE(it.value().toInt(), length); + QVERIFY2(!iteratedThruLength, "'length' appeared more than once during iteration."); + iteratedThruLength = true; + continue; + } + + QVERIFY2(!stringProperties.contains(name), "property appeared more than once during iteration."); + stringProperties.insert(name, it.value()); + QVERIFY(it.value().strictlyEquals(obj.property(name))); + } + + QVERIFY(iteratedThruLength); + QCOMPARE(stringProperties.size(), length); +#if 0 + // And going backwards + iteratedThruLength = false; + stringProperties.clear(); + it.toBack(); + + while (it.hasPrevious()) { + it.previous(); + const QString name = it.name(); + + if (name == QString::fromLatin1("length")) { + QVERIFY(it.value().isNumber()); + QCOMPARE(it.value().toInt(), length); + QVERIFY2(!iteratedThruLength, "'length' appeared more than once during iteration."); + iteratedThruLength = true; + continue; + } + + QVERIFY2(!stringProperties.contains(name), "property appeared more than once during iteration."); + stringProperties.insert(name, it.value()); + QVERIFY(it.value().strictlyEquals(obj.property(name))); + } +#endif +} + +#if 0 // FIXME what we should to keep from here? +static QJSValue myGetterSetter(QScriptContext *ctx, QJSEngine *) +{ + if (ctx->argumentCount() == 1) + ctx->thisObject().setProperty("bar", ctx->argument(0)); + return ctx->thisObject().property("bar"); +} + +static QJSValue myGetter(QScriptContext *ctx, QJSEngine *) +{ + return ctx->thisObject().property("bar"); +} + +static QJSValue mySetter(QScriptContext *ctx, QJSEngine *) +{ + ctx->thisObject().setProperty("bar", ctx->argument(0)); + return ctx->argument(0); +} + +void tst_QJSValueIterator::iterateGetterSetter() +{ + // unified getter/setter function + { + QJSEngine eng; + QJSValue obj = eng.newObject(); + obj.setProperty("foo", eng.newFunction(myGetterSetter), + QScriptValue::PropertyGetter | QScriptValue::PropertySetter); + QJSValue val(&eng, 123); + obj.setProperty("foo", val); + QVERIFY(obj.property("bar").strictlyEquals(val)); + QVERIFY(obj.property("foo").strictlyEquals(val)); + + QJSValueIterator it(obj); + QVERIFY(it.hasNext()); + it.next(); + QCOMPARE(it.name(), QString::fromLatin1("foo")); + QCOMPARE(it.flags(), QScriptValue::PropertyFlags(QScriptValue::PropertyGetter | QScriptValue::PropertySetter)); + QVERIFY(it.value().strictlyEquals(val)); + QJSValue val2(&eng, 456); + it.setValue(val2); + QVERIFY(obj.property("bar").strictlyEquals(val2)); + QVERIFY(obj.property("foo").strictlyEquals(val2)); + + QVERIFY(it.hasNext()); + it.next(); + QCOMPARE(it.name(), QString::fromLatin1("bar")); + QVERIFY(!it.hasNext()); + + QVERIFY(it.hasPrevious()); + it.previous(); + QCOMPARE(it.name(), QString::fromLatin1("bar")); + QVERIFY(it.hasPrevious()); + it.previous(); + QCOMPARE(it.name(), QString::fromLatin1("foo")); + QCOMPARE(it.flags(), QScriptValue::PropertyFlags(QScriptValue::PropertyGetter | QScriptValue::PropertySetter)); + QVERIFY(it.value().strictlyEquals(val2)); + it.setValue(val); + QVERIFY(obj.property("bar").strictlyEquals(val)); + QVERIFY(obj.property("foo").strictlyEquals(val)); + } + // separate getter/setter function + for (int x = 0; x < 2; ++x) { + QJSEngine eng; + QJSValue obj = eng.newObject(); + if (x == 0) { + obj.setProperty("foo", eng.newFunction(myGetter), QScriptValue::PropertyGetter); + obj.setProperty("foo", eng.newFunction(mySetter), QScriptValue::PropertySetter); + } else { + obj.setProperty("foo", eng.newFunction(mySetter), QScriptValue::PropertySetter); + obj.setProperty("foo", eng.newFunction(myGetter), QScriptValue::PropertyGetter); + } + QJSValue val(&eng, 123); + obj.setProperty("foo", val); + QVERIFY(obj.property("bar").strictlyEquals(val)); + QVERIFY(obj.property("foo").strictlyEquals(val)); + + QJSValueIterator it(obj); + QVERIFY(it.hasNext()); + it.next(); + QCOMPARE(it.name(), QString::fromLatin1("foo")); + QVERIFY(it.value().strictlyEquals(val)); + QJSValue val2(&eng, 456); + it.setValue(val2); + QVERIFY(obj.property("bar").strictlyEquals(val2)); + QVERIFY(obj.property("foo").strictlyEquals(val2)); + + QVERIFY(it.hasNext()); + it.next(); + QCOMPARE(it.name(), QString::fromLatin1("bar")); + QVERIFY(!it.hasNext()); + + QVERIFY(it.hasPrevious()); + it.previous(); + QCOMPARE(it.name(), QString::fromLatin1("bar")); + QVERIFY(it.hasPrevious()); + it.previous(); + QCOMPARE(it.name(), QString::fromLatin1("foo")); + QVERIFY(it.value().strictlyEquals(val2)); + it.setValue(val); + QVERIFY(obj.property("bar").strictlyEquals(val)); + QVERIFY(obj.property("foo").strictlyEquals(val)); + } +} +#endif + +void tst_QJSValueIterator::assignObjectToIterator() +{ + QJSEngine eng; + QJSValue obj1 = eng.newObject(); + obj1.setProperty("foo", 123); + QJSValue obj2 = eng.newObject(); + obj2.setProperty("bar", 456); + + QJSValueIterator it(obj1); + QVERIFY(it.hasNext()); + it.next(); + it = obj2; + QVERIFY(it.hasNext()); + it.next(); + QCOMPARE(it.name(), QString::fromLatin1("bar")); + + it = obj1; + QVERIFY(it.hasNext()); + it.next(); + QCOMPARE(it.name(), QString::fromLatin1("foo")); + + it = obj2; + QVERIFY(it.hasNext()); + it.next(); + QCOMPARE(it.name(), QString::fromLatin1("bar")); + + it = obj2; + QVERIFY(it.hasNext()); + it.next(); + QCOMPARE(it.name(), QString::fromLatin1("bar")); +} + +void tst_QJSValueIterator::iterateNonObject() +{ + QJSValueIterator it(123); + QVERIFY(!it.hasNext()); + it.next(); + it.name(); + it.value(); + QJSValue num(5); + it = num; + QVERIFY(!it.hasNext()); +} + +void tst_QJSValueIterator::iterateOverObjectFromDeletedEngine() +{ + QJSEngine *engine = new QJSEngine; + QJSValue objet = engine->newObject(); + + // populate object with properties + QHash properties; + properties.insert("foo",1235); + properties.insert("oof",5321); + properties.insert("ofo",3521); + QHash::const_iterator i = properties.constBegin(); + for (; i != properties.constEnd(); ++i) { + objet.setProperty(i.key(), i.value()); + } + + // start iterating + QJSValueIterator it(objet); + it.next(); + QVERIFY(properties.contains(it.name())); + + delete engine; + + QVERIFY(objet.isUndefined()); + QVERIFY(it.name().isEmpty()); + QVERIFY(it.value().isUndefined()); + + QVERIFY(!it.hasNext()); + it.next(); + + QVERIFY(it.name().isEmpty()); + QVERIFY(it.value().isUndefined()); + +} + +QTEST_MAIN(tst_QJSValueIterator) +#include "tst_qjsvalueiterator.moc" diff --git a/tests/auto/qml/qml.pro b/tests/auto/qml/qml.pro new file mode 100644 index 0000000000..7a62a71df1 --- /dev/null +++ b/tests/auto/qml/qml.pro @@ -0,0 +1,55 @@ +TEMPLATE = subdirs + +METATYPETESTS += \ + qqmlmetatype + +PUBLICTESTS += \ + parserstress \ + qjsengine \ + qjsvalue \ + qjsvalueiterator \ + qmlmin \ + qmlplugindump \ + qqmlcomponent \ + qqmlconsole \ + qqmlcontext \ + qqmlengine \ + qqmlerror \ + qqmlincubator \ + qqmlinfo \ + qqmllistreference \ + qqmllocale \ + qqmlmoduleplugin \ + qqmlqt \ + qqmltranslation \ + qqmlxmlhttprequest \ + qqmlparser \ + qquickfolderlistmodel + +PRIVATETESTS += \ + animation \ + qqmlcpputils \ + qqmlecmascript \ + qqmlexpression \ + qqmlimageprovider \ + qqmlinstruction \ + qqmllanguage \ + qqmlproperty \ + qqmlpropertymap \ + qqmlsqldatabase \ + qqmlvaluetypes \ + qquickbinding \ + qquickchangeset \ + qquickconnection \ + qquicklistcompositor \ + qquicklistmodel \ + qquickworkerscript \ + v4 + +SUBDIRS += $$PUBLICTESTS +SUBDIRS += $$METATYPETESTS +SUBDIRS += debugger + +contains(QT_CONFIG, private_tests) { + SUBDIRS += $$PRIVATETESTS +} diff --git a/tests/auto/qml/qmlmin/qmlmin.pro b/tests/auto/qml/qmlmin/qmlmin.pro new file mode 100644 index 0000000000..49a4e7ff58 --- /dev/null +++ b/tests/auto/qml/qmlmin/qmlmin.pro @@ -0,0 +1,9 @@ +CONFIG += testcase +TARGET = tst_qmlmin +QT += qml testlib +macx:CONFIG -= app_bundle + +SOURCES += tst_qmlmin.cpp +DEFINES += SRCDIR=\\\"$$PWD\\\" + +CONFIG += parallel_test diff --git a/tests/auto/qml/qmlmin/tst_qmlmin.cpp b/tests/auto/qml/qmlmin/tst_qmlmin.cpp new file mode 100644 index 0000000000..2d764317c5 --- /dev/null +++ b/tests/auto/qml/qmlmin/tst_qmlmin.cpp @@ -0,0 +1,192 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include +#include +#include +#include +#include +#include + +class tst_qmlmin : public QObject +{ + Q_OBJECT +public: + tst_qmlmin(); + +private slots: + void initTestCase(); + void qmlMinify_data(); + void qmlMinify(); + +private: + QString qmlminPath; + QStringList excludedDirs; + QStringList invalidFiles; + + QStringList findFiles(const QDir &); + bool isInvalidFile(const QFileInfo &fileName) const; +}; + +tst_qmlmin::tst_qmlmin() +{ +} + +void tst_qmlmin::initTestCase() +{ + qmlminPath = QLibraryInfo::location(QLibraryInfo::BinariesPath) + QLatin1String("/qmlmin"); +#ifdef Q_OS_WIN + qmlminPath += QLatin1String(".exe"); +#endif + if (!QFileInfo(qmlminPath).exists()) { + QString message = QString::fromLatin1("qmlmin executable not found (looked for %0)") + .arg(qmlminPath); + QFAIL(qPrintable(message)); + } + + // Add directories you want excluded here + + // These snippets are not expected to run on their own. + excludedDirs << "doc/src/snippets/qml/visualdatamodel_rootindex"; + excludedDirs << "doc/src/snippets/qml/qtbinding"; + excludedDirs << "doc/src/snippets/qml/imports"; + excludedDirs << "doc/src/snippets/qtquick1/visualdatamodel_rootindex"; + excludedDirs << "doc/src/snippets/qtquick1/qtbinding"; + excludedDirs << "doc/src/snippets/qtquick1/imports"; + + // Add invalid files (i.e. files with syntax errors) + invalidFiles << "tests/auto/quick/qquickloader/data/InvalidSourceComponent.qml"; + invalidFiles << "tests/auto/qml/qqmllanguage/data/dynamicObjectProperties.2.qml"; + invalidFiles << "tests/auto/qml/qqmllanguage/data/signal.3.qml"; + invalidFiles << "tests/auto/qml/qqmllanguage/data/property.4.qml"; + invalidFiles << "tests/auto/qml/qqmllanguage/data/empty.qml"; + invalidFiles << "tests/auto/qml/qqmllanguage/data/signal.2.qml"; + invalidFiles << "tests/auto/qml/qqmllanguage/data/missingObject.qml"; + invalidFiles << "tests/auto/qml/qqmllanguage/data/insertedSemicolon.1.qml"; + invalidFiles << "tests/auto/qml/qqmllanguage/data/nonexistantProperty.5.qml"; + invalidFiles << "tests/auto/qml/qqmllanguage/data/invalidRoot.1.qml"; + invalidFiles << "tests/auto/qml/qquickfolderlistmodel/data/dummy.qml"; + invalidFiles << "tests/auto/qml/qqmlecmascript/data/qtbug_22843.js"; + invalidFiles << "tests/auto/qml/qqmlecmascript/data/qtbug_22843.library.js"; + invalidFiles << "tests/auto/qml/qquickworkerscript/data/script_error_onLoad.js"; + invalidFiles << "tests/auto/qml/parserstress/tests/ecma_3/Unicode/regress-352044-02-n.js"; +} + +QStringList tst_qmlmin::findFiles(const QDir &d) +{ + for (int ii = 0; ii < excludedDirs.count(); ++ii) { + QString s = excludedDirs.at(ii); + if (d.absolutePath().endsWith(s)) + return QStringList(); + } + + QStringList rv; + + QStringList files = d.entryList(QStringList() << QLatin1String("*.qml") << QLatin1String("*.js"), + QDir::Files); + foreach (const QString &file, files) { + rv << d.absoluteFilePath(file); + } + + QStringList dirs = d.entryList(QDir::Dirs | QDir::NoDotAndDotDot | + QDir::NoSymLinks); + foreach (const QString &dir, dirs) { + QDir sub = d; + sub.cd(dir); + rv << findFiles(sub); + } + + return rv; +} + +bool tst_qmlmin::isInvalidFile(const QFileInfo &fileName) const +{ + foreach (const QString &invalidFile, invalidFiles) { + if (fileName.absoluteFilePath().endsWith(invalidFile)) + return true; + } + return false; +} + +/* +This test runs all the examples in the QtQml UI source tree and ensures +that they start and exit cleanly. + +Examples are any .qml files under the examples/ directory that start +with a lower case letter. +*/ + +void tst_qmlmin::qmlMinify_data() +{ + QTest::addColumn("file"); + + QString examples = QLatin1String(SRCDIR) + "/../../../../examples/"; + QString tests = QLatin1String(SRCDIR) + "/../../../../tests/"; + + QStringList files; + files << findFiles(QDir(examples)); + files << findFiles(QDir(tests)); + + foreach (const QString &file, files) + QTest::newRow(qPrintable(file)) << file; +} + +void tst_qmlmin::qmlMinify() +{ + QFETCH(QString, file); + + QProcess qmlminify; + qmlminify.start(qmlminPath, QStringList() << QLatin1String("--verify-only") << file); + qmlminify.waitForFinished(); + + QCOMPARE(qmlminify.error(), QProcess::UnknownError); + QCOMPARE(qmlminify.exitStatus(), QProcess::NormalExit); + + if (isInvalidFile(file)) + QCOMPARE(qmlminify.exitCode(), EXIT_FAILURE); // cannot minify files with syntax errors + else + QCOMPARE(qmlminify.exitCode(), 0); +} + +QTEST_MAIN(tst_qmlmin) + +#include "tst_qmlmin.moc" diff --git a/tests/auto/qml/qmlplugindump/qmlplugindump.pro b/tests/auto/qml/qmlplugindump/qmlplugindump.pro new file mode 100644 index 0000000000..498a520873 --- /dev/null +++ b/tests/auto/qml/qmlplugindump/qmlplugindump.pro @@ -0,0 +1,7 @@ +CONFIG += testcase +TARGET = tst_qmlplugindump +QT += testlib +macx:CONFIG -= app_bundle +CONFIG += parallel_test + +SOURCES += tst_qmlplugindump.cpp diff --git a/tests/auto/qml/qmlplugindump/tst_qmlplugindump.cpp b/tests/auto/qml/qmlplugindump/tst_qmlplugindump.cpp new file mode 100644 index 0000000000..5512cfdfe8 --- /dev/null +++ b/tests/auto/qml/qmlplugindump/tst_qmlplugindump.cpp @@ -0,0 +1,117 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include +#include +#include +#include +#include + +class tst_qmlplugindump : public QObject +{ + Q_OBJECT +public: + tst_qmlplugindump(); + +private slots: + void initTestCase(); + void builtins(); + +private: + QString qmlplugindumpPath; +}; + +tst_qmlplugindump::tst_qmlplugindump() +{ +} + +void tst_qmlplugindump::initTestCase() +{ + qmlplugindumpPath = QLibraryInfo::location(QLibraryInfo::BinariesPath); + +#if defined(Q_OS_MAC) + qmlplugindumpPath += QLatin1String("/qmlplugindump.app/Contents/MacOS/qmlplugindump"); +#elif defined(Q_OS_WIN) + qmlplugindumpPath += QLatin1String("/qmlplugindump.exe"); +#else + qmlplugindumpPath += QLatin1String("/qmlplugindump"); +#endif + + if (!QFileInfo(qmlplugindumpPath).exists()) { + QString message = QString::fromLatin1("qmlplugindump executable not found (looked for %0)") + .arg(qmlplugindumpPath); + QFAIL(qPrintable(message)); + } +} + +void tst_qmlplugindump::builtins() +{ + QProcess dumper; + QStringList args; + args += QLatin1String("-builtins"); + dumper.start(qmlplugindumpPath, args); + dumper.waitForFinished(); + + if (dumper.error() != QProcess::UnknownError + || dumper.exitStatus() != QProcess::NormalExit) { + qWarning() << QString("Error while running '%1 %2'").arg( + qmlplugindumpPath, args.join(QLatin1String(" "))); + } + + if (dumper.error() == QProcess::FailedToStart) { + QFAIL("failed to start"); + } + if (dumper.error() == QProcess::Crashed) { + qWarning() << "stderr:\n" << dumper.readAllStandardError(); + QFAIL("crashed"); + } + + QCOMPARE(dumper.error(), QProcess::UnknownError); + QCOMPARE(dumper.exitStatus(), QProcess::NormalExit); + + const QString &result = dumper.readAllStandardOutput(); + QVERIFY(result.contains(QLatin1String("Module {"))); +} + +QTEST_MAIN(tst_qmlplugindump) + +#include "tst_qmlplugindump.moc" diff --git a/tests/auto/qml/qqmlcomponent/data/createObject.qml b/tests/auto/qml/qqmlcomponent/data/createObject.qml new file mode 100644 index 0000000000..da5db8e8e6 --- /dev/null +++ b/tests/auto/qml/qqmlcomponent/data/createObject.qml @@ -0,0 +1,13 @@ +import QtQuick 2.0 + +Item{ + id: root + property QtObject qobject : null + property QtObject declarativeitem : null + Component{id: a; QtObject{} } + Component{id: b; Item{} } + Component.onCompleted: { + root.qobject = a.createObject(root); + root.declarativeitem = b.createObject(root); + } +} diff --git a/tests/auto/qml/qqmlcomponent/data/createObjectWithScript.qml b/tests/auto/qml/qqmlcomponent/data/createObjectWithScript.qml new file mode 100644 index 0000000000..122c6a87c8 --- /dev/null +++ b/tests/auto/qml/qqmlcomponent/data/createObjectWithScript.qml @@ -0,0 +1,43 @@ +import QtQuick 2.0 + +Item{ + id: root + property QtObject declarativerectangle : null + property QtObject declarativeitem : null + + property QtObject bindingTestObject : null + property QtObject bindingThisTestObject : null + + Component{ + id: a + Rectangle { + property Rectangle innerRect: Rectangle { border.width: 20 } + } + } + Component{ + id: b + Item{ + property bool testBool: false + property int testInt: null + property QtObject testObject: null + } + } + + // test passing in bindings + width: 100 + Component { + id: c + Item { + property int testValue + width: 300 + } + } + + Component.onCompleted: { + root.declarativerectangle = a.createObject(root, {"x":17,"y":17, "color":"white", "border.width":3, "innerRect.border.width": 20}); + root.declarativeitem = b.createObject(root, {"x":17,"y":17,"testBool":true,"testInt":17,"testObject":root}); + + root.bindingTestObject = c.createObject(root, {'testValue': (function(){return width * 3}) }) // use root.width + root.bindingThisTestObject = c.createObject(root, {'testValue': (function(){return this.width * 3}) }) // use width of Item within 'c' + } +} diff --git a/tests/auto/qml/qqmlcomponent/data/incubateObject.qml b/tests/auto/qml/qqmlcomponent/data/incubateObject.qml new file mode 100644 index 0000000000..c11319db30 --- /dev/null +++ b/tests/auto/qml/qqmlcomponent/data/incubateObject.qml @@ -0,0 +1,36 @@ +import QtQuick 2.0 + +Item{ + id: root + + property bool test1: false + property bool test2: false + + property var i + + Component{ + id: component + Item { + property int dummy: 13 + property int dummy2: 26 + } + } + + Component.onCompleted: { + i = component.incubateObject(null, { dummy2: 19 }); + + if (i.status != Component.Loading) return; + if (i.object != null) return; + + i.onStatusChanged = function(status) { + if (status != Component.Ready) return; + if (i.object == null) return; + if (i.object.dummy != 13) return; + if (i.object.dummy2 != 19) return; + test2 = true; + } + + test1 = true; + } +} + diff --git a/tests/auto/qml/qqmlcomponent/qqmlcomponent.pro b/tests/auto/qml/qqmlcomponent/qqmlcomponent.pro new file mode 100644 index 0000000000..7cef181a4a --- /dev/null +++ b/tests/auto/qml/qqmlcomponent/qqmlcomponent.pro @@ -0,0 +1,15 @@ +CONFIG += testcase +TARGET = tst_qqmlcomponent +macx:CONFIG -= app_bundle + +SOURCES += tst_qqmlcomponent.cpp + +include (../../shared/util.pri) + +testDataFiles.files = data +testDataFiles.path = . +DEPLOYMENT += testDataFiles + +CONFIG += parallel_test + +QT += core-private gui-private qml-private network testlib diff --git a/tests/auto/qml/qqmlcomponent/tst_qqmlcomponent.cpp b/tests/auto/qml/qqmlcomponent/tst_qqmlcomponent.cpp new file mode 100644 index 0000000000..d277952f22 --- /dev/null +++ b/tests/auto/qml/qqmlcomponent/tst_qqmlcomponent.cpp @@ -0,0 +1,186 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include +#include + +#include +#include +#include +#include +#include +#include "../../shared/util.h" + +class MyIC : public QObject, public QQmlIncubationController +{ + Q_OBJECT +public: + MyIC() { startTimer(5); } +protected: + virtual void timerEvent(QTimerEvent*) { + incubateFor(5); + } +}; + +class tst_qqmlcomponent : public QQmlDataTest +{ + Q_OBJECT +public: + tst_qqmlcomponent() { engine.setIncubationController(&ic); } + +private slots: + void null(); + void loadEmptyUrl(); + void qmlCreateObject(); + void qmlCreateObjectWithProperties(); + void qmlIncubateObject(); + +private: + QQmlEngine engine; + MyIC ic; +}; + +void tst_qqmlcomponent::null() +{ + { + QQmlComponent c; + QVERIFY(c.isNull()); + } + + { + QQmlComponent c(&engine); + QVERIFY(c.isNull()); + } +} + + +void tst_qqmlcomponent::loadEmptyUrl() +{ + QQmlComponent c(&engine); + c.loadUrl(QUrl()); + + QVERIFY(c.isError()); + QCOMPARE(c.errors().count(), 1); + QQmlError error = c.errors().first(); + QCOMPARE(error.url(), QUrl()); + QCOMPARE(error.line(), -1); + QCOMPARE(error.column(), -1); + QCOMPARE(error.description(), QLatin1String("Invalid empty URL")); +} + +void tst_qqmlcomponent::qmlIncubateObject() +{ + QQmlComponent component(&engine, testFileUrl("incubateObject.qml")); + QObject *object = component.create(); + QVERIFY(object != 0); + QCOMPARE(object->property("test1").toBool(), true); + QCOMPARE(object->property("test2").toBool(), false); + + QTRY_VERIFY(object->property("test2").toBool() == true); + + delete object; +} + +void tst_qqmlcomponent::qmlCreateObject() +{ + QQmlEngine engine; + QQmlComponent component(&engine, testFileUrl("createObject.qml")); + QObject *object = component.create(); + QVERIFY(object != 0); + + QObject *testObject1 = object->property("qobject").value(); + QVERIFY(testObject1); + QVERIFY(testObject1->parent() == object); + + QObject *testObject2 = object->property("declarativeitem").value(); + QVERIFY(testObject2); + QVERIFY(testObject2->parent() == object); + QCOMPARE(testObject2->metaObject()->className(), "QQuickItem"); +} + +void tst_qqmlcomponent::qmlCreateObjectWithProperties() +{ + QQmlEngine engine; + QQmlComponent component(&engine, testFileUrl("createObjectWithScript.qml")); + QVERIFY2(component.errorString().isEmpty(), component.errorString().toUtf8()); + QObject *object = component.create(); + QVERIFY(object != 0); + + QObject *testObject1 = object->property("declarativerectangle").value(); + QVERIFY(testObject1); + QVERIFY(testObject1->parent() == object); + QCOMPARE(testObject1->property("x").value(), 17); + QCOMPARE(testObject1->property("y").value(), 17); + QCOMPARE(testObject1->property("color").value(), QColor(255,255,255)); + QCOMPARE(QQmlProperty::read(testObject1,"border.width").toInt(), 3); + QCOMPARE(QQmlProperty::read(testObject1,"innerRect.border.width").toInt(), 20); + delete testObject1; + + QObject *testObject2 = object->property("declarativeitem").value(); + QVERIFY(testObject2); + QVERIFY(testObject2->parent() == object); + //QCOMPARE(testObject2->metaObject()->className(), "QDeclarativeItem_QML_2"); + QCOMPARE(testObject2->property("x").value(), 17); + QCOMPARE(testObject2->property("y").value(), 17); + QCOMPARE(testObject2->property("testBool").value(), true); + QCOMPARE(testObject2->property("testInt").value(), 17); + QCOMPARE(testObject2->property("testObject").value(), object); + delete testObject2; + + QObject *testBindingObj = object->property("bindingTestObject").value(); + QVERIFY(testBindingObj); + QCOMPARE(testBindingObj->parent(), object); + QCOMPARE(testBindingObj->property("testValue").value(), 300); + object->setProperty("width", 150); + QCOMPARE(testBindingObj->property("testValue").value(), 150 * 3); + delete testBindingObj; + + QObject *testBindingThisObj = object->property("bindingThisTestObject").value(); + QVERIFY(testBindingThisObj); + QCOMPARE(testBindingThisObj->parent(), object); + QCOMPARE(testBindingThisObj->property("testValue").value(), 900); + testBindingThisObj->setProperty("width", 200); + QCOMPARE(testBindingThisObj->property("testValue").value(), 200 * 3); + delete testBindingThisObj; +} + +QTEST_MAIN(tst_qqmlcomponent) + +#include "tst_qqmlcomponent.moc" diff --git a/tests/auto/qml/qqmlconsole/data/assert.qml b/tests/auto/qml/qqmlconsole/data/assert.qml new file mode 100644 index 0000000000..43ca893809 --- /dev/null +++ b/tests/auto/qml/qqmlconsole/data/assert.qml @@ -0,0 +1,62 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +QtObject { + property int q:1 + function assertFail() { + console.assert(0, "This will fail too") + } + + Component.onCompleted: { + var x = 12; + console.assert(x == 12, "This will pass"); + try { + console.assert(x < 12, "This will fail"); + } catch (e) { + console.log(e); + } + console.assert("x < 12", "This will pass too") + assertFail(); + console.assert(1) + } +} diff --git a/tests/auto/qml/qqmlconsole/data/exception.qml b/tests/auto/qml/qqmlconsole/data/exception.qml new file mode 100644 index 0000000000..1cda37a9f4 --- /dev/null +++ b/tests/auto/qml/qqmlconsole/data/exception.qml @@ -0,0 +1,58 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +QtObject { + function exceptionFail() { + console.exception("Exception 2") + } + + Component.onCompleted: { + try { + console.exception("Exception 1") + } catch (e) { + console.log(e); + } + + exceptionFail(); + } +} diff --git a/tests/auto/qml/qqmlconsole/data/logging.qml b/tests/auto/qml/qqmlconsole/data/logging.qml new file mode 100644 index 0000000000..44009b5db9 --- /dev/null +++ b/tests/auto/qml/qqmlconsole/data/logging.qml @@ -0,0 +1,90 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + + +import QtQuick 2.0 + +QtObject { + id:root + + function consoleCount() { + console.count("console.count", "Ignore additonal argument"); + console.count(); + } + + Component.onCompleted: { + console.debug("console.debug"); + console.log("console.log"); + console.info("console.info"); + console.warn("console.warn"); + console.error("console.error"); + + consoleCount(); + consoleCount(); + + var a = [1, 2]; + var b = {a: "hello", d: 1 }; + var c + var d = 12; + var e = function() { return 5;}; + var f = true; + var g = {toString: function() { throw new Error('toString'); }}; + + console.log(a); + console.log(b); + console.log(c); + console.log(d); + console.log(e); + console.log(f); + console.log(root); + console.log(g); + console.log(1, "pong!", new Object); + console.log(1, ["ping","pong"], new Object, 2); + + try { + console.log(exception); + } catch (e) { + return; + } + + throw ("console.log(exception) should have raised an exception"); + } +} diff --git a/tests/auto/qml/qqmlconsole/data/profiling.qml b/tests/auto/qml/qqmlconsole/data/profiling.qml new file mode 100644 index 0000000000..9a0ca354a5 --- /dev/null +++ b/tests/auto/qml/qqmlconsole/data/profiling.qml @@ -0,0 +1,51 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +QtObject { + Component.onCompleted: { + console.profile("profile1"); + console.time("timer1"); + console.timeEnd("timer1"); + console.profileEnd("profile1"); + } +} diff --git a/tests/auto/qml/qqmlconsole/data/tracing.qml b/tests/auto/qml/qqmlconsole/data/tracing.qml new file mode 100644 index 0000000000..9586829f8f --- /dev/null +++ b/tests/auto/qml/qqmlconsole/data/tracing.qml @@ -0,0 +1,56 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +// moving lines in here requires fixing tst_qqmlconsole.cpp +QtObject { + id: root + + function tracing() + { + console.trace(); + } + + Component.onCompleted: { + tracing(); + } +} diff --git a/tests/auto/qml/qqmlconsole/qqmlconsole.pro b/tests/auto/qml/qqmlconsole/qqmlconsole.pro new file mode 100644 index 0000000000..9ae23316a1 --- /dev/null +++ b/tests/auto/qml/qqmlconsole/qqmlconsole.pro @@ -0,0 +1,15 @@ +CONFIG += testcase +TARGET = tst_qqmlconsole +SOURCES += tst_qqmlconsole.cpp + +include (../../shared/util.pri) + +macx:CONFIG -= app_bundle + +testDataFiles.files = data +testDataFiles.path = . +DEPLOYMENT += testDataFiles + +CONFIG += parallel_test + +QT += qml testlib diff --git a/tests/auto/qml/qqmlconsole/tst_qqmlconsole.cpp b/tests/auto/qml/qqmlconsole/tst_qqmlconsole.cpp new file mode 100644 index 0000000000..d96da678e2 --- /dev/null +++ b/tests/auto/qml/qqmlconsole/tst_qqmlconsole.cpp @@ -0,0 +1,170 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include +#include +#include +#include +#include "../../shared/util.h" + +class tst_qqmlconsole : public QQmlDataTest +{ + Q_OBJECT +public: + tst_qqmlconsole() {} + +private slots: + void logging(); + void tracing(); + void profiling(); + void assert(); + void exception(); + +private: + QQmlEngine engine; +}; + +void tst_qqmlconsole::logging() +{ + QUrl testUrl = testFileUrl("logging.qml"); + + QTest::ignoreMessage(QtDebugMsg, "console.debug"); + QTest::ignoreMessage(QtDebugMsg, "console.log"); + QTest::ignoreMessage(QtDebugMsg, "console.info"); + QTest::ignoreMessage(QtWarningMsg, "console.warn"); + QTest::ignoreMessage(QtCriticalMsg, "console.error"); + + QTest::ignoreMessage(QtDebugMsg, "console.count: 1"); + QTest::ignoreMessage(QtDebugMsg, ": 1"); + QTest::ignoreMessage(QtDebugMsg, "console.count: 2"); + QTest::ignoreMessage(QtDebugMsg, ": 2"); + + QTest::ignoreMessage(QtDebugMsg, "[1,2]"); + QTest::ignoreMessage(QtDebugMsg, "Object"); + QTest::ignoreMessage(QtDebugMsg, "undefined"); + QTest::ignoreMessage(QtDebugMsg, "12"); + QTest::ignoreMessage(QtDebugMsg, "function () { return 5;}"); + QTest::ignoreMessage(QtDebugMsg, "true"); + QTest::ignoreMessage(QtDebugMsg, "Object"); + QTest::ignoreMessage(QtDebugMsg, "Object"); + QTest::ignoreMessage(QtDebugMsg, "1 pong! Object"); + QTest::ignoreMessage(QtDebugMsg, "1 [ping,pong] Object 2"); + + QQmlComponent component(&engine, testUrl); + QObject *object = component.create(); + QVERIFY(object != 0); + delete object; +} + +void tst_qqmlconsole::tracing() +{ + QUrl testUrl = testFileUrl("tracing.qml"); + + QString traceText = + QString::fromLatin1("tracing (%1:%2:%3)\n").arg(testUrl.toString()).arg(50).arg(17) + + QString::fromLatin1("onCompleted (%1:%2:%3)").arg(testUrl.toString()).arg(54).arg(9); + + QTest::ignoreMessage(QtDebugMsg, qPrintable(traceText)); + + QQmlComponent component(&engine, testUrl); + QObject *object = component.create(); + QVERIFY(object != 0); + delete object; +} + +void tst_qqmlconsole::profiling() +{ + QUrl testUrl = testFileUrl("profiling.qml"); + + // profiling() + QTest::ignoreMessage(QtDebugMsg, "Profiling started."); + QTest::ignoreMessage(QtDebugMsg, "Profiling ended."); + + QQmlComponent component(&engine, testUrl); + QObject *object = component.create(); + QVERIFY(object != 0); + delete object; +} + +void tst_qqmlconsole::assert() +{ + QUrl testUrl = testFileUrl("assert.qml"); + + // assert() + QString assert1 = "This will fail\n" + + QString::fromLatin1("onCompleted (%1:%2:%3)").arg(testUrl.toString()).arg(54).arg(17); + + QString assert2 = "This will fail too\n" + + QString::fromLatin1("assertFail (%1:%2:%3)\n").arg(testUrl.toString()).arg(47).arg(17) + + QString::fromLatin1("onCompleted (%1:%2:%3)").arg(testUrl.toString()).arg(59).arg(9); + + QTest::ignoreMessage(QtCriticalMsg, qPrintable(assert1)); + QTest::ignoreMessage(QtCriticalMsg, qPrintable(assert2)); + + QQmlComponent component(&engine, testUrl); + QObject *object = component.create(); + QVERIFY(object != 0); + delete object; +} + +void tst_qqmlconsole::exception() +{ + QUrl testUrl = testFileUrl("exception.qml"); + + // exception() + QString exception1 = "Exception 1\n" + + QString::fromLatin1("onCompleted (%1:%2:%3)").arg(testUrl.toString()).arg(51).arg(21); + + QString exception2 = "Exception 2\n" + + QString::fromLatin1("exceptionFail (%1:%2:%3)\n").arg(testUrl.toString()).arg(46).arg(17) + + QString::fromLatin1("onCompleted (%1:%2:%3)").arg(testUrl.toString()).arg(56).arg(9); + + QTest::ignoreMessage(QtCriticalMsg, qPrintable(exception1)); + QTest::ignoreMessage(QtCriticalMsg, qPrintable(exception2)); + + QQmlComponent component(&engine, testUrl); + QObject *object = component.create(); + QVERIFY(object != 0); + delete object; +} + +QTEST_MAIN(tst_qqmlconsole) + +#include "tst_qqmlconsole.moc" diff --git a/tests/auto/qml/qqmlcontext/data/Object_22535.qml b/tests/auto/qml/qqmlcontext/data/Object_22535.qml new file mode 100644 index 0000000000..294c744317 --- /dev/null +++ b/tests/auto/qml/qqmlcontext/data/Object_22535.qml @@ -0,0 +1,8 @@ +import QtQuick 2.0 + +QtObject { + + function goodBye() + { + } +} diff --git a/tests/auto/qml/qqmlcontext/data/RefreshExpressionsType.qml b/tests/auto/qml/qqmlcontext/data/RefreshExpressionsType.qml new file mode 100644 index 0000000000..b7c3427c85 --- /dev/null +++ b/tests/auto/qml/qqmlcontext/data/RefreshExpressionsType.qml @@ -0,0 +1,5 @@ +import QtQuick 2.0 + +QtObject { + property var dummy: countCommand.doCommand(); +} diff --git a/tests/auto/qml/qqmlcontext/data/qtbug_22535.qml b/tests/auto/qml/qqmlcontext/data/qtbug_22535.qml new file mode 100644 index 0000000000..3553f6c03b --- /dev/null +++ b/tests/auto/qml/qqmlcontext/data/qtbug_22535.qml @@ -0,0 +1,10 @@ +import QtQuick 2.0 + +Rectangle { + width: 64 + height: 64 + + Object_22535 { id:o } + + Component.onDestruction: o.goodBye() +} diff --git a/tests/auto/qml/qqmlcontext/data/refreshExpressions.qml b/tests/auto/qml/qqmlcontext/data/refreshExpressions.qml new file mode 100644 index 0000000000..01e503f8dc --- /dev/null +++ b/tests/auto/qml/qqmlcontext/data/refreshExpressions.qml @@ -0,0 +1,6 @@ +import QtQuick 2.0 + +QtObject { + property variant v1: RefreshExpressionsType {} + property variant v2: RefreshExpressionsType {} +} diff --git a/tests/auto/qml/qqmlcontext/data/refreshExpressionsRootContext.qml b/tests/auto/qml/qqmlcontext/data/refreshExpressionsRootContext.qml new file mode 100644 index 0000000000..bd82cd9552 --- /dev/null +++ b/tests/auto/qml/qqmlcontext/data/refreshExpressionsRootContext.qml @@ -0,0 +1,6 @@ +import QtQuick 2.0 + +QtObject { + property var dummy: countCommand.doCommand(), unresolvedName +} + diff --git a/tests/auto/qml/qqmlcontext/qqmlcontext.pro b/tests/auto/qml/qqmlcontext/qqmlcontext.pro new file mode 100644 index 0000000000..9920766d61 --- /dev/null +++ b/tests/auto/qml/qqmlcontext/qqmlcontext.pro @@ -0,0 +1,15 @@ +CONFIG += testcase +TARGET = tst_qqmlcontext +SOURCES += tst_qqmlcontext.cpp + +include (../../shared/util.pri) + +macx:CONFIG -= app_bundle + +testDataFiles.files = data +testDataFiles.path = . +DEPLOYMENT += testDataFiles + +CONFIG += parallel_test + +QT += core-private gui-private qml-private testlib v8-private diff --git a/tests/auto/qml/qqmlcontext/tst_qqmlcontext.cpp b/tests/auto/qml/qqmlcontext/tst_qqmlcontext.cpp new file mode 100644 index 0000000000..6125362365 --- /dev/null +++ b/tests/auto/qml/qqmlcontext/tst_qqmlcontext.cpp @@ -0,0 +1,652 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include +#include +#include +#include +#include +#include +#include "../../shared/util.h" + +class tst_qqmlcontext : public QQmlDataTest +{ + Q_OBJECT +public: + tst_qqmlcontext() {} + +private slots: + void baseUrl(); + void resolvedUrl(); + void engineMethod(); + void parentContext(); + void setContextProperty(); + void setContextObject(); + void destruction(); + void idAsContextProperty(); + void readOnlyContexts(); + void nameForObject(); + + void refreshExpressions(); + void refreshExpressionsCrash(); + void refreshExpressionsRootContext(); + + void qtbug_22535(); +private: + QQmlEngine engine; +}; + +void tst_qqmlcontext::baseUrl() +{ + QQmlContext ctxt(&engine); + + QCOMPARE(ctxt.baseUrl(), QUrl()); + + ctxt.setBaseUrl(QUrl("http://www.nokia.com/")); + + QCOMPARE(ctxt.baseUrl(), QUrl("http://www.nokia.com/")); +} + +void tst_qqmlcontext::resolvedUrl() +{ + // Relative to the component + { + QQmlContext ctxt(&engine); + ctxt.setBaseUrl(QUrl("http://www.nokia.com/")); + + QCOMPARE(ctxt.resolvedUrl(QUrl("main.qml")), QUrl("http://www.nokia.com/main.qml")); + } + + // Relative to a parent + { + QQmlContext ctxt(&engine); + ctxt.setBaseUrl(QUrl("http://www.nokia.com/")); + + QQmlContext ctxt2(&ctxt); + QCOMPARE(ctxt2.resolvedUrl(QUrl("main2.qml")), QUrl("http://www.nokia.com/main2.qml")); + } + + // Relative to the engine + { + QQmlContext ctxt(&engine); + QCOMPARE(ctxt.resolvedUrl(QUrl("main.qml")), engine.baseUrl().resolved(QUrl("main.qml"))); + } + + // Relative to a deleted parent + { + QQmlContext *ctxt = new QQmlContext(&engine); + ctxt->setBaseUrl(QUrl("http://www.nokia.com/")); + + QQmlContext ctxt2(ctxt); + QCOMPARE(ctxt2.resolvedUrl(QUrl("main2.qml")), QUrl("http://www.nokia.com/main2.qml")); + + delete ctxt; ctxt = 0; + + QCOMPARE(ctxt2.resolvedUrl(QUrl("main2.qml")), QUrl()); + } + + // Absolute + { + QQmlContext ctxt(&engine); + + QCOMPARE(ctxt.resolvedUrl(QUrl("http://www.nokia.com/main2.qml")), QUrl("http://www.nokia.com/main2.qml")); + QCOMPARE(ctxt.resolvedUrl(QUrl("file:///main2.qml")), QUrl("file:///main2.qml")); + } +} + +void tst_qqmlcontext::engineMethod() +{ + QQmlEngine *engine = new QQmlEngine; + + QQmlContext ctxt(engine); + QQmlContext ctxt2(&ctxt); + QQmlContext ctxt3(&ctxt2); + QQmlContext ctxt4(&ctxt2); + + QCOMPARE(ctxt.engine(), engine); + QCOMPARE(ctxt2.engine(), engine); + QCOMPARE(ctxt3.engine(), engine); + QCOMPARE(ctxt4.engine(), engine); + + delete engine; engine = 0; + + QCOMPARE(ctxt.engine(), engine); + QCOMPARE(ctxt2.engine(), engine); + QCOMPARE(ctxt3.engine(), engine); + QCOMPARE(ctxt4.engine(), engine); +} + +void tst_qqmlcontext::parentContext() +{ + QQmlEngine *engine = new QQmlEngine; + + QCOMPARE(engine->rootContext()->parentContext(), (QQmlContext *)0); + + QQmlContext *ctxt = new QQmlContext(engine); + QQmlContext *ctxt2 = new QQmlContext(ctxt); + QQmlContext *ctxt3 = new QQmlContext(ctxt2); + QQmlContext *ctxt4 = new QQmlContext(ctxt2); + QQmlContext *ctxt5 = new QQmlContext(ctxt); + QQmlContext *ctxt6 = new QQmlContext(engine); + QQmlContext *ctxt7 = new QQmlContext(engine->rootContext()); + + QCOMPARE(ctxt->parentContext(), engine->rootContext()); + QCOMPARE(ctxt2->parentContext(), ctxt); + QCOMPARE(ctxt3->parentContext(), ctxt2); + QCOMPARE(ctxt4->parentContext(), ctxt2); + QCOMPARE(ctxt5->parentContext(), ctxt); + QCOMPARE(ctxt6->parentContext(), engine->rootContext()); + QCOMPARE(ctxt7->parentContext(), engine->rootContext()); + + delete ctxt2; ctxt2 = 0; + + QCOMPARE(ctxt->parentContext(), engine->rootContext()); + QCOMPARE(ctxt3->parentContext(), (QQmlContext *)0); + QCOMPARE(ctxt4->parentContext(), (QQmlContext *)0); + QCOMPARE(ctxt5->parentContext(), ctxt); + QCOMPARE(ctxt6->parentContext(), engine->rootContext()); + QCOMPARE(ctxt7->parentContext(), engine->rootContext()); + + delete engine; engine = 0; + + QCOMPARE(ctxt->parentContext(), (QQmlContext *)0); + QCOMPARE(ctxt3->parentContext(), (QQmlContext *)0); + QCOMPARE(ctxt4->parentContext(), (QQmlContext *)0); + QCOMPARE(ctxt5->parentContext(), (QQmlContext *)0); + QCOMPARE(ctxt6->parentContext(), (QQmlContext *)0); + QCOMPARE(ctxt7->parentContext(), (QQmlContext *)0); + + delete ctxt7; + delete ctxt6; + delete ctxt5; + delete ctxt4; + delete ctxt3; + delete ctxt; +} + +class TestObject : public QObject +{ + Q_OBJECT + Q_PROPERTY(int a READ a NOTIFY aChanged) + Q_PROPERTY(int b READ b NOTIFY bChanged) + Q_PROPERTY(int c READ c NOTIFY cChanged) + +public: + TestObject() : _a(10), _b(10), _c(10) {} + + int a() const { return _a; } + void setA(int a) { _a = a; emit aChanged(); } + + int b() const { return _b; } + void setB(int b) { _b = b; emit bChanged(); } + + int c() const { return _c; } + void setC(int c) { _c = c; emit cChanged(); } + +signals: + void aChanged(); + void bChanged(); + void cChanged(); + +private: + int _a; + int _b; + int _c; +}; + +#define TEST_CONTEXT_PROPERTY(ctxt, name, value) \ +{ \ + QQmlComponent component(&engine); \ + component.setData("import QtQuick 2.0; QtObject { property variant test: " #name " }", QUrl()); \ +\ + QObject *obj = component.create(ctxt); \ +\ + QCOMPARE(obj->property("test"), value); \ +\ + delete obj; \ +} + +void tst_qqmlcontext::setContextProperty() +{ + QQmlContext ctxt(&engine); + QQmlContext ctxt2(&ctxt); + + TestObject obj1; + obj1.setA(3345); + TestObject obj2; + obj2.setA(-19); + + // Static context properties + ctxt.setContextProperty("a", QVariant(10)); + ctxt.setContextProperty("b", QVariant(9)); + ctxt2.setContextProperty("d", &obj2); + ctxt2.setContextProperty("b", QVariant(19)); + ctxt2.setContextProperty("c", QVariant(QString("Hello World!"))); + ctxt.setContextProperty("d", &obj1); + ctxt.setContextProperty("e", &obj1); + + TEST_CONTEXT_PROPERTY(&ctxt2, a, QVariant(10)); + TEST_CONTEXT_PROPERTY(&ctxt2, b, QVariant(19)); + TEST_CONTEXT_PROPERTY(&ctxt2, c, QVariant(QString("Hello World!"))); + TEST_CONTEXT_PROPERTY(&ctxt2, d.a, QVariant(-19)); + TEST_CONTEXT_PROPERTY(&ctxt2, e.a, QVariant(3345)); + + ctxt.setContextProperty("a", QVariant(13)); + ctxt.setContextProperty("b", QVariant(4)); + ctxt2.setContextProperty("b", QVariant(8)); + ctxt2.setContextProperty("c", QVariant(QString("Hi World!"))); + ctxt2.setContextProperty("d", &obj1); + obj1.setA(12); + + TEST_CONTEXT_PROPERTY(&ctxt2, a, QVariant(13)); + TEST_CONTEXT_PROPERTY(&ctxt2, b, QVariant(8)); + TEST_CONTEXT_PROPERTY(&ctxt2, c, QVariant(QString("Hi World!"))); + TEST_CONTEXT_PROPERTY(&ctxt2, d.a, QVariant(12)); + TEST_CONTEXT_PROPERTY(&ctxt2, e.a, QVariant(12)); + + // Changes in context properties + { + QQmlComponent component(&engine); + component.setData("import QtQuick 2.0; QtObject { property variant test: a }", QUrl()); + + QObject *obj = component.create(&ctxt2); + + QCOMPARE(obj->property("test"), QVariant(13)); + ctxt.setContextProperty("a", QVariant(19)); + QCOMPARE(obj->property("test"), QVariant(19)); + + delete obj; + } + { + QQmlComponent component(&engine); + component.setData("import QtQuick 2.0; QtObject { property variant test: b }", QUrl()); + + QObject *obj = component.create(&ctxt2); + + QCOMPARE(obj->property("test"), QVariant(8)); + ctxt.setContextProperty("b", QVariant(5)); + QCOMPARE(obj->property("test"), QVariant(8)); + ctxt2.setContextProperty("b", QVariant(1912)); + QCOMPARE(obj->property("test"), QVariant(1912)); + + delete obj; + } + { + QQmlComponent component(&engine); + component.setData("import QtQuick 2.0; QtObject { property variant test: e.a }", QUrl()); + + QObject *obj = component.create(&ctxt2); + + QCOMPARE(obj->property("test"), QVariant(12)); + obj1.setA(13); + QCOMPARE(obj->property("test"), QVariant(13)); + + delete obj; + } + + // New context properties + { + QQmlComponent component(&engine); + component.setData("import QtQuick 2.0; QtObject { property variant test: a }", QUrl()); + + QObject *obj = component.create(&ctxt2); + + QCOMPARE(obj->property("test"), QVariant(19)); + ctxt2.setContextProperty("a", QVariant(1945)); + QCOMPARE(obj->property("test"), QVariant(1945)); + + delete obj; + } + + // Setting an object-variant context property + { + QQmlComponent component(&engine); + component.setData("import QtQuick 2.0; QtObject { id: root; property int a: 10; property int test: ctxtProp.a; property variant obj: root; }", QUrl()); + + QQmlContext ctxt(engine.rootContext()); + ctxt.setContextProperty("ctxtProp", QVariant()); + + QTest::ignoreMessage(QtWarningMsg, ":1: TypeError: Cannot read property 'a' of undefined"); + QObject *obj = component.create(&ctxt); + + QVariant v = obj->property("obj"); + + ctxt.setContextProperty("ctxtProp", v); + + QCOMPARE(obj->property("test"), QVariant(10)); + + delete obj; + } +} + +void tst_qqmlcontext::setContextObject() +{ + QQmlContext ctxt(&engine); + + TestObject to; + + to.setA(2); + to.setB(192); + to.setC(18); + + ctxt.setContextObject(&to); + ctxt.setContextProperty("c", QVariant(9)); + + // Static context properties + TEST_CONTEXT_PROPERTY(&ctxt, a, QVariant(2)); + TEST_CONTEXT_PROPERTY(&ctxt, b, QVariant(192)); + TEST_CONTEXT_PROPERTY(&ctxt, c, QVariant(9)); + + to.setA(12); + to.setB(100); + to.setC(7); + ctxt.setContextProperty("c", QVariant(3)); + + TEST_CONTEXT_PROPERTY(&ctxt, a, QVariant(12)); + TEST_CONTEXT_PROPERTY(&ctxt, b, QVariant(100)); + TEST_CONTEXT_PROPERTY(&ctxt, c, QVariant(3)); + + // Changes in context properties + { + QQmlComponent component(&engine); + component.setData("import QtQuick 2.0; QtObject { property variant test: a }", QUrl()); + + QObject *obj = component.create(&ctxt); + + QCOMPARE(obj->property("test"), QVariant(12)); + to.setA(14); + QCOMPARE(obj->property("test"), QVariant(14)); + + delete obj; + } +} + +void tst_qqmlcontext::destruction() +{ + QQmlContext *ctxt = new QQmlContext(&engine); + + QObject obj; + QQmlEngine::setContextForObject(&obj, ctxt); + QQmlExpression expr(ctxt, 0, "a"); + + QCOMPARE(ctxt, QQmlEngine::contextForObject(&obj)); + QCOMPARE(ctxt, expr.context()); + + delete ctxt; ctxt = 0; + + QCOMPARE(ctxt, QQmlEngine::contextForObject(&obj)); + QCOMPARE(ctxt, expr.context()); +} + +void tst_qqmlcontext::idAsContextProperty() +{ + QQmlComponent component(&engine); + component.setData("import QtQuick 2.0; QtObject { property variant a; a: QtObject { id: myObject } }", QUrl()); + + QObject *obj = component.create(); + QVERIFY(obj); + + QVariant a = obj->property("a"); + QVERIFY(a.userType() == QMetaType::QObjectStar); + + QVariant ctxt = qmlContext(obj)->contextProperty("myObject"); + QVERIFY(ctxt.userType() == QMetaType::QObjectStar); + + QVERIFY(a == ctxt); + + delete obj; +} + +// Internal contexts should be read-only +void tst_qqmlcontext::readOnlyContexts() +{ + QQmlComponent component(&engine); + component.setData("import QtQuick 2.0; QtObject { id: me }", QUrl()); + + QObject *obj = component.create(); + QVERIFY(obj); + + QQmlContext *context = qmlContext(obj); + QVERIFY(context); + + QVERIFY(qvariant_cast(context->contextProperty("me")) == obj); + QVERIFY(context->contextObject() == obj); + + QTest::ignoreMessage(QtWarningMsg, "QQmlContext: Cannot set property on internal context."); + context->setContextProperty("hello", 12); + QVERIFY(context->contextProperty("hello") == QVariant()); + + QTest::ignoreMessage(QtWarningMsg, "QQmlContext: Cannot set property on internal context."); + context->setContextProperty("hello", obj); + QVERIFY(context->contextProperty("hello") == QVariant()); + + QTest::ignoreMessage(QtWarningMsg, "QQmlContext: Cannot set context object for internal context."); + context->setContextObject(0); + QVERIFY(context->contextObject() == obj); + + delete obj; +} + +void tst_qqmlcontext::nameForObject() +{ + QObject o1; + QObject o2; + QObject o3; + + QQmlEngine engine; + + // As a context property + engine.rootContext()->setContextProperty("o1", &o1); + engine.rootContext()->setContextProperty("o2", &o2); + engine.rootContext()->setContextProperty("o1_2", &o1); + + QCOMPARE(engine.rootContext()->nameForObject(&o1), QString("o1")); + QCOMPARE(engine.rootContext()->nameForObject(&o2), QString("o2")); + QCOMPARE(engine.rootContext()->nameForObject(&o3), QString()); + + // As an id + QQmlComponent component(&engine); + component.setData("import QtQuick 2.0; QtObject { id: root; property QtObject o: QtObject { id: nested } }", QUrl()); + + QObject *o = component.create(); + QVERIFY(o != 0); + + QCOMPARE(qmlContext(o)->nameForObject(o), QString("root")); + QCOMPARE(qmlContext(o)->nameForObject(qvariant_cast(o->property("o"))), QString("nested")); + QCOMPARE(qmlContext(o)->nameForObject(&o1), QString()); + + delete o; +} + +class DeleteCommand : public QObject +{ +Q_OBJECT +public: + DeleteCommand() : object(0) {} + + QObject *object; + +public slots: + void doCommand() { if (object) delete object; object = 0; } +}; + +// Calling refresh expressions would crash if an expression or context was deleted during +// the refreshing +void tst_qqmlcontext::refreshExpressionsCrash() +{ + { + QQmlEngine engine; + + DeleteCommand command; + engine.rootContext()->setContextProperty("deleteCommand", &command); + // We use a fresh context here to bypass any root-context optimizations in + // the engine + QQmlContext ctxt(engine.rootContext()); + + QQmlComponent component(&engine); + component.setData("import QtQuick 2.0; QtObject { property var binding: deleteCommand.doCommand() }", QUrl()); + QVERIFY(component.isReady()); + + QObject *o1 = component.create(&ctxt); + QObject *o2 = component.create(&ctxt); + + command.object = o2; + + QQmlContextData::get(&ctxt)->refreshExpressions(); + + delete o1; + } + { + QQmlEngine engine; + + DeleteCommand command; + engine.rootContext()->setContextProperty("deleteCommand", &command); + // We use a fresh context here to bypass any root-context optimizations in + // the engine + QQmlContext ctxt(engine.rootContext()); + + QQmlComponent component(&engine); + component.setData("import QtQuick 2.0; QtObject { property var binding: deleteCommand.doCommand() }", QUrl()); + QVERIFY(component.isReady()); + + QObject *o1 = component.create(&ctxt); + QObject *o2 = component.create(&ctxt); + + command.object = o1; + + QQmlContextData::get(&ctxt)->refreshExpressions(); + + delete o2; + } +} + +class CountCommand : public QObject +{ +Q_OBJECT +public: + CountCommand() : count(0) {} + + int count; + +public slots: + void doCommand() { ++count; } +}; + + +// Test that calling refresh expressions causes all the expressions to refresh +void tst_qqmlcontext::refreshExpressions() +{ + QQmlEngine engine; + QQmlComponent component(&engine, testFileUrl("refreshExpressions.qml")); + QQmlComponent component2(&engine, testFileUrl("RefreshExpressionsType.qml")); + + CountCommand command; + engine.rootContext()->setContextProperty("countCommand", &command); + + // We use a fresh context here to bypass any root-context optimizations in + // the engine + QQmlContext context(engine.rootContext()); + QQmlContext context2(&context); + + QObject *o1 = component.create(&context); + QObject *o2 = component.create(&context2); + QObject *o3 = component2.create(&context); + + QCOMPARE(command.count, 5); + + QQmlContextData::get(&context)->refreshExpressions(); + + QCOMPARE(command.count, 10); + + delete o3; + delete o2; + delete o1; +} + +// Test that updating the root context, only causes expressions in contexts with an +// unresolved name to reevaluate +void tst_qqmlcontext::refreshExpressionsRootContext() +{ + QQmlEngine engine; + + CountCommand command; + engine.rootContext()->setContextProperty("countCommand", &command); + + QQmlComponent component(&engine, testFileUrl("refreshExpressions.qml")); + QQmlComponent component2(&engine, testFileUrl("refreshExpressionsRootContext.qml")); + + QQmlContext context(engine.rootContext()); + QQmlContext context2(engine.rootContext()); + + QString warning = component2.url().toString() + QLatin1String(":4: ReferenceError: Can't find variable: unresolvedName"); + + QObject *o1 = component.create(&context); + + QTest::ignoreMessage(QtWarningMsg, qPrintable(warning)); + QObject *o2 = component2.create(&context2); + + QCOMPARE(command.count, 3); + + QTest::ignoreMessage(QtWarningMsg, qPrintable(warning)); + QQmlContextData::get(engine.rootContext())->refreshExpressions(); + + QCOMPARE(command.count, 4); + + delete o2; + delete o1; +} + +void tst_qqmlcontext::qtbug_22535() +{ + QQmlEngine engine; + QQmlComponent component(&engine, testFileUrl("qtbug_22535.qml")); + QQmlContext context(engine.rootContext()); + + QObject *o = component.create(&context); + + // Don't crash! + delete o; +} + +QTEST_MAIN(tst_qqmlcontext) + +#include "tst_qqmlcontext.moc" diff --git a/tests/auto/qml/qqmlcpputils/qqmlcpputils.pro b/tests/auto/qml/qqmlcpputils/qqmlcpputils.pro new file mode 100644 index 0000000000..1c088860e5 --- /dev/null +++ b/tests/auto/qml/qqmlcpputils/qqmlcpputils.pro @@ -0,0 +1,9 @@ +CONFIG += testcase +TARGET = tst_qqmlcpputils +macx:CONFIG -= app_bundle + +SOURCES += tst_qqmlcpputils.cpp + +CONFIG += parallel_test + +QT += core-private gui-private qml-private testlib diff --git a/tests/auto/qml/qqmlcpputils/tst_qqmlcpputils.cpp b/tests/auto/qml/qqmlcpputils/tst_qqmlcpputils.cpp new file mode 100644 index 0000000000..186b82a0a8 --- /dev/null +++ b/tests/auto/qml/qqmlcpputils/tst_qqmlcpputils.cpp @@ -0,0 +1,106 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include +#include + +class tst_qqmlcpputils : public QObject +{ + Q_OBJECT +public: + tst_qqmlcpputils() {} + +private slots: + void fastConnect(); +}; + +class MyObject : public QObject { + Q_OBJECT +public: + MyObject() : slotCount(0) {} + friend class tst_qqmlcpputils; + + int slotCount; + +signals: + void signal1(); + void signal2(); + +public slots: + void slot1() { slotCount++; } +}; + +void tst_qqmlcpputils::fastConnect() +{ + { + MyObject *obj = new MyObject; + FAST_CONNECT(obj, SIGNAL(signal1()), obj, SLOT(slot1())); + + obj->signal1(); + QCOMPARE(obj->slotCount, 1); + + delete obj; + } + + { + MyObject obj; + FAST_CONNECT(&obj, SIGNAL(signal1()), &obj, SLOT(slot1())) + + obj.signal1(); + QCOMPARE(obj.slotCount, 1); + } + + { + MyObject *obj = new MyObject; + QSignalSpy spy(obj, SIGNAL(signal2())); + FAST_CONNECT(obj, SIGNAL(signal1()), obj, SIGNAL(signal2())); + + obj->signal1(); + QCOMPARE(spy.count(), 1); + + delete obj; + } +} + +QTEST_MAIN(tst_qqmlcpputils) + +#include "tst_qqmlcpputils.moc" diff --git a/tests/auto/qml/qqmlecmascript/data/AliasBindingsAssignCorrectlyType.qml b/tests/auto/qml/qqmlecmascript/data/AliasBindingsAssignCorrectlyType.qml new file mode 100644 index 0000000000..e8e108fa44 --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/AliasBindingsAssignCorrectlyType.qml @@ -0,0 +1,9 @@ +import QtQuick 2.0 + +QtObject { + id: root + + property real realProperty + property alias aliasProperty: root.realProperty +} + diff --git a/tests/auto/qml/qqmlecmascript/data/AliasBindingsOverrideTargetType.qml b/tests/auto/qml/qqmlecmascript/data/AliasBindingsOverrideTargetType.qml new file mode 100644 index 0000000000..062772106b --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/AliasBindingsOverrideTargetType.qml @@ -0,0 +1,14 @@ +import QtQuick 2.0 +import Qt.test 1.0 + +MyTypeObject { + id: root + + property int data: 7 + + property int targetProperty: root.data * 43 - root.data + property alias aliasProperty: root.targetProperty + + pointProperty: Qt.point(data, data); + property alias pointAliasProperty: root.pointProperty +} diff --git a/tests/auto/qml/qqmlecmascript/data/AliasBindingsOverrideTargetType3.qml b/tests/auto/qml/qqmlecmascript/data/AliasBindingsOverrideTargetType3.qml new file mode 100644 index 0000000000..823c0ef367 --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/AliasBindingsOverrideTargetType3.qml @@ -0,0 +1,9 @@ +import QtQuick 2.0 + +QtObject { + id: root + + property int testProperty + property alias aliasProperty: root.testProperty +} + diff --git a/tests/auto/qml/qqmlecmascript/data/AliasToCompositeElementType1.qml b/tests/auto/qml/qqmlecmascript/data/AliasToCompositeElementType1.qml new file mode 100644 index 0000000000..cef8ae09ea --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/AliasToCompositeElementType1.qml @@ -0,0 +1,6 @@ +import QtQuick 2.0 + +QtObject { + property alias group: obj + property variant foo: AliasToCompositeElementType2 { id: obj } +} diff --git a/tests/auto/qml/qqmlecmascript/data/AliasToCompositeElementType2.qml b/tests/auto/qml/qqmlecmascript/data/AliasToCompositeElementType2.qml new file mode 100644 index 0000000000..4a45535a50 --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/AliasToCompositeElementType2.qml @@ -0,0 +1,5 @@ +import QtQuick 2.0 + +QtObject { + property int value +} diff --git a/tests/auto/qml/qqmlecmascript/data/ConstantsOverrideBindings.qml b/tests/auto/qml/qqmlecmascript/data/ConstantsOverrideBindings.qml new file mode 100644 index 0000000000..07bb16b0d8 --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/ConstantsOverrideBindings.qml @@ -0,0 +1,12 @@ +import Qt.test 1.0 + +MyQmlObject { + property int c1: 0 + property int c2: c1 + property alias c3: inner.ic1 + + objectProperty: MyQmlObject { + id: inner + property int ic1: c1 + } +} diff --git a/tests/auto/qml/qqmlecmascript/data/CustomObject.qml b/tests/auto/qml/qqmlecmascript/data/CustomObject.qml new file mode 100644 index 0000000000..aa1a1d6061 --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/CustomObject.qml @@ -0,0 +1,5 @@ +import QtQuick 2.0 + +QtObject { + property string greeting: "hello world" +} diff --git a/tests/auto/qml/qqmlecmascript/data/ElementAssignType.qml b/tests/auto/qml/qqmlecmascript/data/ElementAssignType.qml new file mode 100644 index 0000000000..4a45535a50 --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/ElementAssignType.qml @@ -0,0 +1,5 @@ +import QtQuick 2.0 + +QtObject { + property int value +} diff --git a/tests/auto/qml/qqmlecmascript/data/MethodsObject.qml b/tests/auto/qml/qqmlecmascript/data/MethodsObject.qml new file mode 100644 index 0000000000..eaca0a7f92 --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/MethodsObject.qml @@ -0,0 +1,6 @@ +import QtQuick 2.0 + +QtObject { + function testFunction() { return 19; } + function testFunction2() { return 18; } +} diff --git a/tests/auto/qml/qqmlecmascript/data/NestedTypeTransientErrors.qml b/tests/auto/qml/qqmlecmascript/data/NestedTypeTransientErrors.qml new file mode 100644 index 0000000000..3b3e84a900 --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/NestedTypeTransientErrors.qml @@ -0,0 +1,11 @@ +import QtQuick 2.0 + +QtObject { + property int b: obj.prop.a + + property variant prop; + prop: QtObject { + property int a: 10 + } +} + diff --git a/tests/auto/qml/qqmlecmascript/data/PropertyVarBaseItem.qml b/tests/auto/qml/qqmlecmascript/data/PropertyVarBaseItem.qml new file mode 100644 index 0000000000..5f28833fe7 --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/PropertyVarBaseItem.qml @@ -0,0 +1,5 @@ +import QtQuick 2.0 + +Item { + property var random: null +} diff --git a/tests/auto/qml/qqmlecmascript/data/PropertyVarCircularComponent.qml b/tests/auto/qml/qqmlecmascript/data/PropertyVarCircularComponent.qml new file mode 100644 index 0000000000..36c025401f --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/PropertyVarCircularComponent.qml @@ -0,0 +1,23 @@ +import QtQuick 2.0 +import Qt.test 1.0 + +Item { + id: first + property var vp: Item { + id: second + property var vp: Item { + id: third + property var vp: Item { + id: fourth + property var vp: Item { + id: fifth + property int fifthCanary: 5 + property var circ: third.vp + property MyScarceResourceObject srp; + srp: MyScarceResourceObject { id: scarceResourceProvider } + property variant memoryHog: scarceResourceProvider.newScarceResource() + } + } + } + } +} diff --git a/tests/auto/qml/qqmlecmascript/data/PropertyVarCircularComponent2.qml b/tests/auto/qml/qqmlecmascript/data/PropertyVarCircularComponent2.qml new file mode 100644 index 0000000000..6a49cb9317 --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/PropertyVarCircularComponent2.qml @@ -0,0 +1,26 @@ +import QtQuick 2.0 +import Qt.test 1.0 + +// Similar to PVCC.qml except that it has another var property +// It will have a different metaobject. +Item { + id: first + property var anotherVp: 6 + property var vp: Item { + id: second + property var vp: Item { + id: third + property var vp: Item { + id: fourth + property var vp: Item { + id: fifth + property int fifthCanary: 5 + property var circ: third.vp + property MyScarceResourceObject srp; + srp: MyScarceResourceObject { id: scarceResourceProvider } + property variant memoryHog2: scarceResourceProvider.newScarceResource() + } + } + } + } +} diff --git a/tests/auto/qml/qqmlecmascript/data/PropertyVarCircularComponent3.qml b/tests/auto/qml/qqmlecmascript/data/PropertyVarCircularComponent3.qml new file mode 100644 index 0000000000..a90725016e --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/PropertyVarCircularComponent3.qml @@ -0,0 +1,16 @@ +import QtQuick 2.0 + +Rectangle { + id: rectangle // will have JS ownership + objectName: "rectangle" + width: 10 + height: 10 + property var rectCanary: 5 + + Text { + id: text // will have Eventual-JS ownership + objectName: "text" + property var vp: rectangle + property var textCanary: 10 + } +} diff --git a/tests/auto/qml/qqmlecmascript/data/PropertyVarCircularComponent4.qml b/tests/auto/qml/qqmlecmascript/data/PropertyVarCircularComponent4.qml new file mode 100644 index 0000000000..9273a52f54 --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/PropertyVarCircularComponent4.qml @@ -0,0 +1,28 @@ +import QtQuick 2.0 + +Rectangle { + id: rectangle // will have JS ownership + objectName: "rectangle" + width: 10 + height: 10 + property var rectCanary: 5 + + Text { + id: text // will have Eventual-JS ownership + objectName: "text" + property var vp + property var textCanary: 10 + + // The varProperties array of "text" is weak + // (due to eventual JS ownership since parent is JS owned) + // but nonetheless, the reference to the created QObject + // should cause that QObject to NOT be collected. + function constructQObject() { + var component = Qt.createComponent("PropertyVarCircularComponent5.qml"); + if (component.status == Component.Ready) { + text.vp = component.createObject(null); // has JavaScript ownership + } + gc(); + } + } +} diff --git a/tests/auto/qml/qqmlecmascript/data/PropertyVarCircularComponent5.qml b/tests/auto/qml/qqmlecmascript/data/PropertyVarCircularComponent5.qml new file mode 100644 index 0000000000..94ef338792 --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/PropertyVarCircularComponent5.qml @@ -0,0 +1,7 @@ +import QtQuick 2.0 + +Image { + id: image + objectName: "image" + property var imageCanary: 13 +} diff --git a/tests/auto/qml/qqmlecmascript/data/PropertyVarInheritanceComponent.qml b/tests/auto/qml/qqmlecmascript/data/PropertyVarInheritanceComponent.qml new file mode 100644 index 0000000000..b01cf6ed84 --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/PropertyVarInheritanceComponent.qml @@ -0,0 +1,22 @@ +import QtQuick 2.0 +import Qt.test 1.0 + +PropertyVarCircularComponent { + id: inheritanceComponent + property int inheritanceIntProperty: 6 + property var inheritanceVarProperty + + function constructGarbage() { + var retn = 1; + var component = Qt.createComponent("PropertyVarCircularComponent2.qml"); + if (component.status == Component.Ready) { + retn = component.createObject(null); // has JavaScript ownership + } + return retn; + } + + Component.onCompleted: { + inheritanceVarProperty = constructGarbage(); + gc(); + } +} diff --git a/tests/auto/qml/qqmlecmascript/data/PropertyVarOwnershipComponent.qml b/tests/auto/qml/qqmlecmascript/data/PropertyVarOwnershipComponent.qml new file mode 100644 index 0000000000..c1f73d3bac --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/PropertyVarOwnershipComponent.qml @@ -0,0 +1,37 @@ +import QtQuick 2.0 + +Rectangle { + id: rectangle // will have JS ownership + objectName: "rectangle" + width: 10 + height: 10 + property var rectCanary: 5 + + Text { + id: textOne // will have Eventual-JS ownership + objectName: "textOne" + property var textCanary: 11 + property var vp + } + + Text { + id: textTwo + objectName: "textTwo" + property var textCanary: 12 + property var vp + + function constructQObject() { + var component = Qt.createComponent("PropertyVarCircularComponent5.qml"); + if (component.status == Component.Ready) { + textTwo.vp = component.createObject(null); // has JavaScript ownership + } + gc(); + } + + function deassignVp() { + textTwo.textCanary = 22; + textTwo.vp = textTwo.textCanary; + gc(); + } + } +} diff --git a/tests/auto/qml/qqmlecmascript/data/ScarceResourceSignalComponentVar.qml b/tests/auto/qml/qqmlecmascript/data/ScarceResourceSignalComponentVar.qml new file mode 100644 index 0000000000..d56bd41a99 --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/ScarceResourceSignalComponentVar.qml @@ -0,0 +1,9 @@ +import QtQuick 2.0 + +QtObject { + property var scarceResourceCopy + property int width: 5 + signal testSignal + signal testSignal2 +} + diff --git a/tests/auto/qml/qqmlecmascript/data/ScarceResourceSignalComponentVariant.qml b/tests/auto/qml/qqmlecmascript/data/ScarceResourceSignalComponentVariant.qml new file mode 100644 index 0000000000..e10fcfe36a --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/ScarceResourceSignalComponentVariant.qml @@ -0,0 +1,9 @@ +import QtQuick 2.0 + +QtObject { + property variant scarceResourceCopy + property int width: 5 + signal testSignal + signal testSignal2 +} + diff --git a/tests/auto/qml/qqmlecmascript/data/ScarceResourceVarComponent.qml b/tests/auto/qml/qqmlecmascript/data/ScarceResourceVarComponent.qml new file mode 100644 index 0000000000..2cf6b4223b --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/ScarceResourceVarComponent.qml @@ -0,0 +1,13 @@ +import QtQuick 2.0 +import Qt.test 1.0 + +Item { + id: first + property var vp: Item { + id: second + property MyScarceResourceObject srp; + srp: MyScarceResourceObject { id: scarceResourceProvider } + property var sr: scarceResourceProvider.scarceResource + property var canary: 5 + } +} diff --git a/tests/auto/qml/qqmlecmascript/data/Scope6Nested.qml b/tests/auto/qml/qqmlecmascript/data/Scope6Nested.qml new file mode 100644 index 0000000000..a3794df22b --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/Scope6Nested.qml @@ -0,0 +1,7 @@ +import Qt.test 1.0 + +MyQmlObject { + function runtest(obj) { + return obj.MyQmlObject.value == 19; + } +} diff --git a/tests/auto/qml/qqmlecmascript/data/ScopeObject.qml b/tests/auto/qml/qqmlecmascript/data/ScopeObject.qml new file mode 100644 index 0000000000..f341cce3c9 --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/ScopeObject.qml @@ -0,0 +1,12 @@ +import QtQuick 2.0 + +Item { + property int a: 3 + property int binding: myFunction(); + property int binding2: myCompFunction(); + + function myCompFunction() { + return a; + } +} + diff --git a/tests/auto/qml/qqmlecmascript/data/SequenceConversionComponent.qml b/tests/auto/qml/qqmlecmascript/data/SequenceConversionComponent.qml new file mode 100644 index 0000000000..0c7f60b062 --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/SequenceConversionComponent.qml @@ -0,0 +1,7 @@ +import QtQuick 2.0 +import Qt.test 1.0 + +MySequenceConversionObject { + id: sccmsco + objectName: "sccmsco" +} diff --git a/tests/auto/qml/qqmlecmascript/data/SpuriousWarning.qml b/tests/auto/qml/qqmlecmascript/data/SpuriousWarning.qml new file mode 100644 index 0000000000..f6398d254d --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/SpuriousWarning.qml @@ -0,0 +1,5 @@ +import QtQuick 2.0 + +Item { + property int children: root.children.length +} diff --git a/tests/auto/qml/qqmlecmascript/data/TypeForDynamicCreation.qml b/tests/auto/qml/qqmlecmascript/data/TypeForDynamicCreation.qml new file mode 100644 index 0000000000..56e06252c4 --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/TypeForDynamicCreation.qml @@ -0,0 +1,2 @@ +import Qt.test 1.0 +MyQmlObject{objectName:"objectThree"} diff --git a/tests/auto/qml/qqmlecmascript/data/aliasBindingsAssignCorrectly.qml b/tests/auto/qml/qqmlecmascript/data/aliasBindingsAssignCorrectly.qml new file mode 100644 index 0000000000..ff6c553c31 --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/aliasBindingsAssignCorrectly.qml @@ -0,0 +1,59 @@ +import QtQuick 2.0 + +Item { + id: root + + property bool test: false + + property real testData: 9 + property real testData2: 9 + + states: State { + name: "change" + PropertyChanges { + target: myType + realProperty: if (testData2 > 3) 9; else 11; + } + } + + AliasBindingsAssignCorrectlyType { + id: myType + + aliasProperty: if (testData > 3) 14; else 12; + } + + Component.onCompleted: { + // Check original binding works + if (myType.aliasProperty != 14) return; + + testData = 2; + if (myType.aliasProperty != 12) return; + + // Change binding indirectly by modifying the "realProperty" + root.state = "change"; + if (myType.aliasProperty != 9) return; + + // Check the new binding works + testData2 = 1; + if (myType.aliasProperty != 11) return; + + // Try and trigger the old binding (that should have been removed) + testData = 6; + if (myType.aliasProperty != 11) return; + + // Restore the original binding + root.state = ""; + if (myType.aliasProperty != 14) return; + + // Test the restored binding works + testData = 0; + if (myType.aliasProperty != 12) return; + + // Test the old binding isn't somehow hanging around and still in effect + testData2 = 13; + if (myType.aliasProperty != 12) return; + + test = true; + } +} + diff --git a/tests/auto/qml/qqmlecmascript/data/aliasBindingsOverrideTarget.2.qml b/tests/auto/qml/qqmlecmascript/data/aliasBindingsOverrideTarget.2.qml new file mode 100644 index 0000000000..bba9033235 --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/aliasBindingsOverrideTarget.2.qml @@ -0,0 +1,29 @@ +import QtQuick 2.0 + +Item { + id: me + property bool test: false + + property int value: 9 + + AliasBindingsOverrideTargetType { + id: aliasType + pointAliasProperty.x: me.value + } + + Component.onCompleted: { + if (aliasType.pointAliasProperty.x != 9) return; + + me.value = 11; + if (aliasType.pointAliasProperty.x != 11) return; + + aliasType.data = 8; + if (aliasType.pointAliasProperty.x != 11) return; + + me.value = 4; + if (aliasType.pointAliasProperty.x != 4) return; + + test = true; + } +} + diff --git a/tests/auto/qml/qqmlecmascript/data/aliasBindingsOverrideTarget.3.qml b/tests/auto/qml/qqmlecmascript/data/aliasBindingsOverrideTarget.3.qml new file mode 100644 index 0000000000..3e4cda6ba3 --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/aliasBindingsOverrideTarget.3.qml @@ -0,0 +1,24 @@ +import QtQuick 2.0 + +Item { + id: root + property bool test: false; + + property int value1: 10 + property int value2: 11 + + AliasBindingsOverrideTargetType3 { + id: obj + + testProperty: root.value1 * 9 + aliasProperty: root.value2 * 10 + } + + Component.onCompleted: { + if (obj.testProperty != 110) return; + if (obj.aliasProperty != 110) return; + + test = true; + } +} + diff --git a/tests/auto/qml/qqmlecmascript/data/aliasBindingsOverrideTarget.qml b/tests/auto/qml/qqmlecmascript/data/aliasBindingsOverrideTarget.qml new file mode 100644 index 0000000000..de5f49ffc5 --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/aliasBindingsOverrideTarget.qml @@ -0,0 +1,28 @@ +import QtQuick 2.0 + +Item { + id: me + property bool test: false + + property int value: 9 + + AliasBindingsOverrideTargetType { + id: aliasType + aliasProperty: me.value + } + + Component.onCompleted: { + if (aliasType.aliasProperty != 9) return; + + me.value = 11; + if (aliasType.aliasProperty != 11) return; + + aliasType.data = 8; + if (aliasType.aliasProperty != 11) return; + + me.value = 4; + if (aliasType.aliasProperty != 4) return; + + test = true; + } +} diff --git a/tests/auto/qml/qqmlecmascript/data/aliasPropertyAndBinding.qml b/tests/auto/qml/qqmlecmascript/data/aliasPropertyAndBinding.qml new file mode 100644 index 0000000000..f228b2c19f --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/aliasPropertyAndBinding.qml @@ -0,0 +1,14 @@ +import QtQuick 2.0 +import Qt.test 1.0 + +MyQmlObject { + property alias c1: myObject.c1 + property int c2: 3 + property int c3: c2 + objectProperty: QtObject { + id: myObject + property int c1 + } +} + + diff --git a/tests/auto/qml/qqmlecmascript/data/aliasToCompositeElement.qml b/tests/auto/qml/qqmlecmascript/data/aliasToCompositeElement.qml new file mode 100644 index 0000000000..79d6e6887c --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/aliasToCompositeElement.qml @@ -0,0 +1,6 @@ +import QtQuick 2.0 + +AliasToCompositeElementType1 { + group.value: 13 +} + diff --git a/tests/auto/qml/qqmlecmascript/data/aliasWritesOverrideBindings.2.qml b/tests/auto/qml/qqmlecmascript/data/aliasWritesOverrideBindings.2.qml new file mode 100644 index 0000000000..b5bc280d11 --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/aliasWritesOverrideBindings.2.qml @@ -0,0 +1,29 @@ +import QtQuick 2.0 + +Item { + id: me + property bool test: false + + property int value: 9 + + AliasBindingsOverrideTargetType { + id: aliasType + } + + Component.onCompleted: { + if (aliasType.aliasProperty != 294) return; + + aliasType.data = 8; + if (aliasType.aliasProperty != 336) return; + + aliasType.aliasProperty = 4; + if (aliasType.aliasProperty != 4) return; + + aliasType.data = 7; + if (aliasType.aliasProperty != 4) return; + + test = true; + } +} + + diff --git a/tests/auto/qml/qqmlecmascript/data/aliasWritesOverrideBindings.3.qml b/tests/auto/qml/qqmlecmascript/data/aliasWritesOverrideBindings.3.qml new file mode 100644 index 0000000000..6c16ff5604 --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/aliasWritesOverrideBindings.3.qml @@ -0,0 +1,23 @@ +import QtQuick 2.0 + +Item { + id: me + property bool test: false + + property int value: 9 + + AliasBindingsOverrideTargetType { + id: aliasType + pointAliasProperty.x: 9 + } + + Component.onCompleted: { + if (aliasType.pointAliasProperty.x != 9) return; + + aliasType.data = 8; + if (aliasType.pointAliasProperty.x != 9) return; + + test = true; + } +} + diff --git a/tests/auto/qml/qqmlecmascript/data/aliasWritesOverrideBindings.qml b/tests/auto/qml/qqmlecmascript/data/aliasWritesOverrideBindings.qml new file mode 100644 index 0000000000..441098bd39 --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/aliasWritesOverrideBindings.qml @@ -0,0 +1,23 @@ +import QtQuick 2.0 + +Item { + id: me + property bool test: false + + property int value: 9 + + AliasBindingsOverrideTargetType { + id: aliasType + aliasProperty: 11 + } + + Component.onCompleted: { + if (aliasType.aliasProperty != 11) return; + + aliasType.data = 8; + if (aliasType.aliasProperty != 11) return; + + test = true; + } +} + diff --git a/tests/auto/qml/qqmlecmascript/data/aliasreset/AliasPropertyComponent.qml b/tests/auto/qml/qqmlecmascript/data/aliasreset/AliasPropertyComponent.qml new file mode 100644 index 0000000000..9135e79469 --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/aliasreset/AliasPropertyComponent.qml @@ -0,0 +1,17 @@ +import QtQuick 2.0 + +Item { + id: apc + property alias sourceComponent: loader.sourceComponent + + Component { + id: redSquare + Rectangle { color: "red"; width: 10; height: 10 } + } + + Loader { + id: loader + objectName: "loader" + sourceComponent: redSquare + } +} diff --git a/tests/auto/qml/qqmlecmascript/data/aliasreset/aliasPropertyReset.1.qml b/tests/auto/qml/qqmlecmascript/data/aliasreset/aliasPropertyReset.1.qml new file mode 100644 index 0000000000..b855a183ee --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/aliasreset/aliasPropertyReset.1.qml @@ -0,0 +1,23 @@ +import QtQuick 2.0 +import Qt.test 1.0 + +Item { + id: first + property bool aliasIsUndefined: false + property alias sourceComponentAlias: loader.sourceComponent + + Component { + id: redSquare + Rectangle { color: "red"; width: 10; height: 10 } + } + + Loader { + id: loader + sourceComponent: redSquare + } + + function resetAliased() { + loader.sourceComponent = undefined; + aliasIsUndefined = (sourceComponentAlias == undefined); + } +} diff --git a/tests/auto/qml/qqmlecmascript/data/aliasreset/aliasPropertyReset.2.qml b/tests/auto/qml/qqmlecmascript/data/aliasreset/aliasPropertyReset.2.qml new file mode 100644 index 0000000000..b0bb3681cf --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/aliasreset/aliasPropertyReset.2.qml @@ -0,0 +1,23 @@ +import QtQuick 2.0 +import Qt.test 1.0 + +Item { + id: first + property bool loaderSourceComponentIsUndefined: false + property alias sourceComponentAlias: loader.sourceComponent + + Component { + id: redSquare + Rectangle { color: "red"; width: 10; height: 10 } + } + + Loader { + id: loader + sourceComponent: redSquare + } + + function resetAlias() { + sourceComponentAlias = undefined; + loaderSourceComponentIsUndefined = (loader.sourceComponent == undefined); + } +} diff --git a/tests/auto/qml/qqmlecmascript/data/aliasreset/aliasPropertyReset.3.qml b/tests/auto/qml/qqmlecmascript/data/aliasreset/aliasPropertyReset.3.qml new file mode 100644 index 0000000000..b318af0138 --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/aliasreset/aliasPropertyReset.3.qml @@ -0,0 +1,31 @@ +import QtQuick 2.0 +import Qt.test 1.0 + +Item { + id: first + property bool loaderTwoSourceComponentIsUndefined: false + property bool loaderOneSourceComponentIsUndefined: false + property alias sourceComponentAlias: loaderOne.sourceComponent + + Component { + id: redSquare + Rectangle { color: "red"; width: 10; height: 10 } + } + + Loader { + id: loaderOne + sourceComponent: loaderTwo.sourceComponent + } + + Loader { + id: loaderTwo + sourceComponent: redSquare + x: 15 + } + + function resetAlias() { + sourceComponentAlias = undefined; // loaderOne.sourceComponent should be set to undefined instead of l2.sc + loaderOneSourceComponentIsUndefined = (loaderOne.sourceComponent == undefined); // should be true + loaderTwoSourceComponentIsUndefined = (loaderTwo.sourceComponent == undefined); // should be false + } +} diff --git a/tests/auto/qml/qqmlecmascript/data/aliasreset/aliasPropertyReset.4.qml b/tests/auto/qml/qqmlecmascript/data/aliasreset/aliasPropertyReset.4.qml new file mode 100644 index 0000000000..c5f56a8798 --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/aliasreset/aliasPropertyReset.4.qml @@ -0,0 +1,26 @@ +import QtQuick 2.0 +import Qt.test 1.0 + +Item { + id: first + property alias sourceComponentAlias: loader.sourceComponent + + Component { + id: redSquare + Rectangle { color: "red"; width: 10; height: 10 } + } + + Loader { + id: loader + objectName: "loader" + sourceComponent: redSquare + } + + function resetAlias() { + sourceComponentAlias = undefined; // ensure we don't crash after deletion of loader. + } + + function setAlias() { + sourceComponentAlias = redSquare; + } +} diff --git a/tests/auto/qml/qqmlecmascript/data/aliasreset/aliasPropertyReset.5.qml b/tests/auto/qml/qqmlecmascript/data/aliasreset/aliasPropertyReset.5.qml new file mode 100644 index 0000000000..b07db8ba40 --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/aliasreset/aliasPropertyReset.5.qml @@ -0,0 +1,14 @@ +import QtQuick 2.0 +import Qt.test 1.0 + +Item { + id: root + + AliasPropertyComponent { + sourceComponent: returnsUndefined() + } + + function returnsUndefined() { + return undefined; + } +} diff --git a/tests/auto/qml/qqmlecmascript/data/aliasreset/aliasPropertyReset.error.1.qml b/tests/auto/qml/qqmlecmascript/data/aliasreset/aliasPropertyReset.error.1.qml new file mode 100644 index 0000000000..35c9d6fd5d --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/aliasreset/aliasPropertyReset.error.1.qml @@ -0,0 +1,18 @@ +import QtQuick 2.0 +import Qt.test 1.0 + +MyQmlObject { + id: first + property bool aliasedIntIsUndefined: false + property alias intAlias: objprop.intp + + objectProperty: QtObject { + id: objprop + property int intp: 12 + } + + function resetAlias() { + intAlias = undefined; // should error + aliasedIntIsUndefined = (objprop.intp == undefined); + } +} diff --git a/tests/auto/qml/qqmlecmascript/data/assignBasicTypes.2.qml b/tests/auto/qml/qqmlecmascript/data/assignBasicTypes.2.qml new file mode 100644 index 0000000000..2c79729651 --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/assignBasicTypes.2.qml @@ -0,0 +1,26 @@ +import Qt.test 1.0 + +MyTypeObject { + flagProperty: if(1) "FlagVal1 | FlagVal3" + enumProperty: if(1) "EnumVal2" + stringProperty: if(1) "Hello World!" + uintProperty: if(1) 10 + intProperty: if(1) -19 + realProperty: if(1) 23.2 + doubleProperty: if(1) -19.75 + floatProperty: if(1) 8.5 + colorProperty: if(1) "red" + dateProperty: if(1) "1982-11-25" + timeProperty: if(1) "11:11:32" + dateTimeProperty: if(1) "2009-05-12T13:22:01" + pointProperty: if(1) "99,13" + pointFProperty: if(1) "-10.1,12.3" + sizeProperty: if(1) "99x13" + sizeFProperty: if(1) "0.1x0.2" + rectProperty: if(1) "9,7,100x200" + rectFProperty: if(1) "1000.1,-10.9,400x90.99" + boolProperty: if(1) true + variantProperty: if(1) "Hello World!" + vectorProperty: if(1) "10,1,2.2" + urlProperty: if(1) "main.qml" +} diff --git a/tests/auto/qml/qqmlecmascript/data/assignBasicTypes.qml b/tests/auto/qml/qqmlecmascript/data/assignBasicTypes.qml new file mode 100644 index 0000000000..86ff6b6bb3 --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/assignBasicTypes.qml @@ -0,0 +1,29 @@ +import Qt.test 1.0 +import QtQuick 2.0 + +MyTypeObject { + Component.onCompleted: { + flagProperty = "FlagVal1 | FlagVal3" + enumProperty = "EnumVal2" + stringProperty = "Hello World!" + uintProperty = 10 + intProperty = -19 + realProperty = 23.2 + doubleProperty = -19.75 + floatProperty = 8.5 + colorProperty = "red" + dateProperty = "1982-11-25" + timeProperty = "11:11:32" + dateTimeProperty = "2009-05-12T13:22:01" + pointProperty = "99,13" + pointFProperty = "-10.1,12.3" + sizeProperty = "99x13" + sizeFProperty = "0.1x0.2" + rectProperty = "9,7,100x200" + rectFProperty = "1000.1,-10.9,400x90.99" + boolProperty = true + variantProperty = "Hello World!" + vectorProperty = "10,1,2.2" + urlProperty = "main.qml" + } +} diff --git a/tests/auto/qml/qqmlecmascript/data/assignSequenceTypes.1.qml b/tests/auto/qml/qqmlecmascript/data/assignSequenceTypes.1.qml new file mode 100644 index 0000000000..be283fdda1 --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/assignSequenceTypes.1.qml @@ -0,0 +1,11 @@ +import QtQuick 2.0 +import Qt.test 1.0 + +MySequenceConversionObject { + intListProperty: [1, 2] + qrealListProperty: [1.1, 2.2] + boolListProperty: [false, true] + urlListProperty: [ "http://www.example1.com", "http://www.example2.com" ] + stringListProperty: [ "one", "two" ] + qstringListProperty: [ "one", "two" ] +} diff --git a/tests/auto/qml/qqmlecmascript/data/assignSequenceTypes.2.qml b/tests/auto/qml/qqmlecmascript/data/assignSequenceTypes.2.qml new file mode 100644 index 0000000000..c8fb28b04e --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/assignSequenceTypes.2.qml @@ -0,0 +1,11 @@ +import QtQuick 2.0 +import Qt.test 1.0 + +MySequenceConversionObject { + intListProperty: 1 + qrealListProperty: 1.1 + boolListProperty: false + urlListProperty: "http://www.example1.com" + stringListProperty: "one" + qstringListProperty: "two" +} diff --git a/tests/auto/qml/qqmlecmascript/data/assignSequenceTypes.3.qml b/tests/auto/qml/qqmlecmascript/data/assignSequenceTypes.3.qml new file mode 100644 index 0000000000..ad8a92e317 --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/assignSequenceTypes.3.qml @@ -0,0 +1,9 @@ +import QtQuick 2.0 +import Qt.test 1.0 + +MySequenceConversionObject { + intListProperty: 1 + qrealListProperty: 1.1 + boolListProperty: false + urlListProperty: Qt.resolvedUrl("example.html") +} diff --git a/tests/auto/qml/qqmlecmascript/data/assignSequenceTypes.4.qml b/tests/auto/qml/qqmlecmascript/data/assignSequenceTypes.4.qml new file mode 100644 index 0000000000..a9f2e642d1 --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/assignSequenceTypes.4.qml @@ -0,0 +1,13 @@ +import QtQuick 2.0 +import Qt.test 1.0 + +MySequenceConversionObject { + Component.onCompleted: { + intListProperty = [1, 2] + qrealListProperty = [1.1, 2.2] + boolListProperty = [false, true] + urlListProperty = [ "http://www.example1.com", "http://www.example2.com" ] + stringListProperty = [ "one", "two" ] + qstringListProperty = [ "one", "two" ] + } +} diff --git a/tests/auto/qml/qqmlecmascript/data/assignSequenceTypes.5.qml b/tests/auto/qml/qqmlecmascript/data/assignSequenceTypes.5.qml new file mode 100644 index 0000000000..b8697e4290 --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/assignSequenceTypes.5.qml @@ -0,0 +1,13 @@ +import QtQuick 2.0 +import Qt.test 1.0 + +MySequenceConversionObject { + Component.onCompleted: { + intListProperty = 1; + qrealListProperty = 1.1; + boolListProperty = false; + urlListProperty = "http://www.example1.com"; + stringListProperty = "one"; + qstringListProperty = "two"; + } +} diff --git a/tests/auto/qml/qqmlecmascript/data/assignSequenceTypes.6.qml b/tests/auto/qml/qqmlecmascript/data/assignSequenceTypes.6.qml new file mode 100644 index 0000000000..7a794eb694 --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/assignSequenceTypes.6.qml @@ -0,0 +1,11 @@ +import QtQuick 2.0 +import Qt.test 1.0 + +MySequenceConversionObject { + Component.onCompleted: { + intListProperty = 1; + qrealListProperty = 1.1; + boolListProperty = false; + urlListProperty = Qt.resolvedUrl("example.html"); + } +} diff --git a/tests/auto/qml/qqmlecmascript/data/assignSequenceTypes.7.qml b/tests/auto/qml/qqmlecmascript/data/assignSequenceTypes.7.qml new file mode 100644 index 0000000000..96c0684939 --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/assignSequenceTypes.7.qml @@ -0,0 +1,42 @@ +import QtQuick 2.0 +import Qt.test 1.0 + +Item { + // single url assignment to url list property + MySequenceConversionObject { + id: msco1 + objectName: "msco1" + } + + // single url binding to url list property + MySequenceConversionObject { + id: msco2 + objectName: "msco2" + urlListProperty: "example.html" + } + + // multiple url assignment to url list property + MySequenceConversionObject { + id: msco3 + objectName: "msco3" + } + + // multiple url binding to url list property + MySequenceConversionObject { + id: msco4 + objectName: "msco4" + urlListProperty: [ "example.html", "example2.html" ] + } + + // multiple url binding to url list property - already resolved + MySequenceConversionObject { + id: msco5 + objectName: "msco5" + urlListProperty: [ Qt.resolvedUrl("example.html"), Qt.resolvedUrl("example2.html") ] + } + + Component.onCompleted: { + msco1.urlListProperty = "example.html"; + msco3.urlListProperty = [ "example.html", "example2.html" ]; + } +} diff --git a/tests/auto/qml/qqmlecmascript/data/attachedProperty.2.qml b/tests/auto/qml/qqmlecmascript/data/attachedProperty.2.qml new file mode 100644 index 0000000000..a7184c9200 --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/attachedProperty.2.qml @@ -0,0 +1,22 @@ +import Qt.test 1.0 +import Qt.test 1.0 as Namespace + +MyQmlObject { + property alias a: me.a + property alias b: me.a + property alias c: me.a + property alias d: me.a + + property MyQmlObject obj + obj: MyQmlObject { + MyQmlObject.value2: 13 + + id: me + property int a: MyQmlObject.value2 * 2 + property int b: Namespace.MyQmlObject.value2 * 2 + property int c: me.Namespace.MyQmlObject.value * 2 + property int d: me.Namespace.MyQmlObject.value * 2 + } +} + + diff --git a/tests/auto/qml/qqmlecmascript/data/attachedProperty.qml b/tests/auto/qml/qqmlecmascript/data/attachedProperty.qml new file mode 100644 index 0000000000..061eda0e54 --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/attachedProperty.qml @@ -0,0 +1,11 @@ +import Qt.test 1.0 +import Qt.test 1.0 as Namespace + +MyQmlObject { + id: me + property int a: MyQmlObject.value + property int b: Namespace.MyQmlObject.value + property int c: me.Namespace.MyQmlObject.value + property int d: me.Namespace.MyQmlObject.value +} + diff --git a/tests/auto/qml/qqmlecmascript/data/attachedPropertyScope.qml b/tests/auto/qml/qqmlecmascript/data/attachedPropertyScope.qml new file mode 100644 index 0000000000..11fb7ccad2 --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/attachedPropertyScope.qml @@ -0,0 +1,9 @@ +import QtQuick 2.0 +import Qt.test 1.0 + +QtObject { + property int value: 9 + property int value2 + + MyQmlObject.onMySignal: value2 = value +} diff --git a/tests/auto/qml/qqmlecmascript/data/automaticSemicolon.qml b/tests/auto/qml/qqmlecmascript/data/automaticSemicolon.qml new file mode 100644 index 0000000000..6db68f2328 --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/automaticSemicolon.qml @@ -0,0 +1,11 @@ + +import QtQuick 2.0 + +QtObject { + function code() { + if (1) { + var a; + function f1(){}a=1; + } + } +} diff --git a/tests/auto/qml/qqmlecmascript/data/bindingLoop.qml b/tests/auto/qml/qqmlecmascript/data/bindingLoop.qml new file mode 100644 index 0000000000..80545cf72b --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/bindingLoop.qml @@ -0,0 +1,14 @@ +import Qt.test 1.0 + +MyQmlContainer { + children : [ + MyQmlObject { + id: object1 + stringProperty: "hello" + object2.stringProperty + }, + MyQmlObject { + id: object2 + stringProperty: "hello" + object1.stringProperty + } + ] +} diff --git a/tests/auto/qml/qqmlecmascript/data/blank.js b/tests/auto/qml/qqmlecmascript/data/blank.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/auto/qml/qqmlecmascript/data/boolPropertiesEvaluateAsBool.1.qml b/tests/auto/qml/qqmlecmascript/data/boolPropertiesEvaluateAsBool.1.qml new file mode 100644 index 0000000000..3147f63989 --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/boolPropertiesEvaluateAsBool.1.qml @@ -0,0 +1,5 @@ +import Qt.test 1.0 + +MyQmlObject { + stringProperty: trueProperty?'pass':'fail' +} diff --git a/tests/auto/qml/qqmlecmascript/data/boolPropertiesEvaluateAsBool.2.qml b/tests/auto/qml/qqmlecmascript/data/boolPropertiesEvaluateAsBool.2.qml new file mode 100644 index 0000000000..c89bb49b45 --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/boolPropertiesEvaluateAsBool.2.qml @@ -0,0 +1,5 @@ +import Qt.test 1.0 + +MyQmlObject { + stringProperty: falseProperty?'fail':'pass' +} diff --git a/tests/auto/qml/qqmlecmascript/data/booleanConversion.qml b/tests/auto/qml/qqmlecmascript/data/booleanConversion.qml new file mode 100644 index 0000000000..a363cf4dd1 --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/booleanConversion.qml @@ -0,0 +1,28 @@ +import QtQuick 2.0 + +QtObject { + id: root + + property bool test_true1: false + property bool test_true2: false + property bool test_true3: false + property bool test_true4: false + property bool test_true5: false + + property bool test_false1: true + property bool test_false2: true + property bool test_false3: true + + + Component.onCompleted: { + test_true1 = 11 + test_true2 = "Hello" + test_true3 = root + test_true4 = { a: 10, b: 11 } + test_true5 = true + + test_false1 = 0 + test_false2 = null + test_false3 = false + } +} diff --git a/tests/auto/qml/qqmlecmascript/data/bug.1.qml b/tests/auto/qml/qqmlecmascript/data/bug.1.qml new file mode 100644 index 0000000000..31f7c44fcc --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/bug.1.qml @@ -0,0 +1,10 @@ +import QtQuick 2.0 + +QtObject { + property int a: 10 + property bool b: false + + property int test + + test: ((a == 10)?(a + 1):0) + ((b == true)?9:3) +} diff --git a/tests/auto/qml/qqmlecmascript/data/canAssignNullToQObject.1.qml b/tests/auto/qml/qqmlecmascript/data/canAssignNullToQObject.1.qml new file mode 100644 index 0000000000..3fd9131b2f --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/canAssignNullToQObject.1.qml @@ -0,0 +1,9 @@ +import Qt.test 1.0 + +MyQmlObject { + property bool runTest: false + + property variant a: MyQmlObject {} + + objectProperty: (runTest == false)?a:null +} diff --git a/tests/auto/qml/qqmlecmascript/data/canAssignNullToQObject.2.qml b/tests/auto/qml/qqmlecmascript/data/canAssignNullToQObject.2.qml new file mode 100644 index 0000000000..3fbf931fca --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/canAssignNullToQObject.2.qml @@ -0,0 +1,11 @@ +import Qt.test 1.0 +import QtQuick 2.0 + +MyQmlObject { + objectProperty: MyQmlObject {} + + Component.onCompleted: { + objectProperty = null; + } +} + diff --git a/tests/auto/qml/qqmlecmascript/data/changeslots/propertyChangeSlotErrors.1.qml b/tests/auto/qml/qqmlecmascript/data/changeslots/propertyChangeSlotErrors.1.qml new file mode 100644 index 0000000000..1e92aca825 --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/changeslots/propertyChangeSlotErrors.1.qml @@ -0,0 +1,12 @@ +import QtQuick 2.0 + +Item { + property int changeCount: 0 + + property bool _nameWithUnderscore: false + + // this should error, since the first alpha isn't capitalised. + on_nameWithUnderscoreChanged: { + changeCount = changeCount + 2; + } +} diff --git a/tests/auto/qml/qqmlecmascript/data/changeslots/propertyChangeSlotErrors.2.qml b/tests/auto/qml/qqmlecmascript/data/changeslots/propertyChangeSlotErrors.2.qml new file mode 100644 index 0000000000..3549d8c556 --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/changeslots/propertyChangeSlotErrors.2.qml @@ -0,0 +1,12 @@ +import QtQuick 2.0 + +Item { + property int changeCount: 0 + + property bool ____nameWithUnderscores: false + + // this should error, since the first alpha isn't capitalised + on____nameWithUnderscoresChanged: { + changeCount = changeCount + 3; + } +} diff --git a/tests/auto/qml/qqmlecmascript/data/changeslots/propertyChangeSlotErrors.3.qml b/tests/auto/qml/qqmlecmascript/data/changeslots/propertyChangeSlotErrors.3.qml new file mode 100644 index 0000000000..d611e0fe30 --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/changeslots/propertyChangeSlotErrors.3.qml @@ -0,0 +1,12 @@ +import QtQuick 2.0 + +Item { + property int changeCount: 0 + + // invalid property name - we don't allow $ + property bool $nameWithDollarsign: false + + on$NameWithDollarsignChanged: { + changeCount = changeCount + 4; + } +} diff --git a/tests/auto/qml/qqmlecmascript/data/changeslots/propertyChangeSlotErrors.4.qml b/tests/auto/qml/qqmlecmascript/data/changeslots/propertyChangeSlotErrors.4.qml new file mode 100644 index 0000000000..a6862517c6 --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/changeslots/propertyChangeSlotErrors.4.qml @@ -0,0 +1,12 @@ +import QtQuick 2.0 + +Item { + property int changeCount: 0 + + property bool _6nameWithUnderscoreNumber: false + + // invalid property name - the first character after an underscore must be a letter + on_6NameWithUnderscoreNumberChanged: { + changeCount = changeCount + 3; + } +} diff --git a/tests/auto/qml/qqmlecmascript/data/changeslots/propertyChangeSlots.qml b/tests/auto/qml/qqmlecmascript/data/changeslots/propertyChangeSlots.qml new file mode 100644 index 0000000000..f91fb71f1f --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/changeslots/propertyChangeSlots.qml @@ -0,0 +1,27 @@ +import QtQuick 2.0 + +Item { + property int changeCount: 0 + + property bool normalName: false + property bool _nameWithUnderscore: false + property bool ____nameWithUnderscores: false + + onNormalNameChanged: { + changeCount = changeCount + 1; + } + + on_NameWithUnderscoreChanged: { + changeCount = changeCount + 2; + } + + on____NameWithUnderscoresChanged: { + changeCount = changeCount + 3; + } + + Component.onCompleted: { + normalName = true; + _nameWithUnderscore = true; + ____nameWithUnderscores = true; + } +} diff --git a/tests/auto/qml/qqmlecmascript/data/compiled.qml b/tests/auto/qml/qqmlecmascript/data/compiled.qml new file mode 100644 index 0000000000..7c46306772 --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/compiled.qml @@ -0,0 +1,48 @@ +import QtQuick 2.0 + +QtObject { + //real + property real test1: a + b + property real test2: a - b + property bool test3: (a < b) + property bool test4: (a > b) + property bool test5: (a == b) + property bool test6: (a != b) + + //int + property int test7: c + d + property int test8: d - c + property bool test9: (c < d) + property bool test10: (c > d) + property bool test11: (c == d) + property bool test12: (c != d) + + //string + property string test13: e + f + property string test14: e + " " + f + property bool test15: (e == f) + property bool test16: (e != f) + + //type conversion + property int test17: a + property real test18: d + property int test19: g + property real test20: g + property string test21: g + property string test22: h + property bool test23: i + property color test24: j + property color test25: k + + property real a: 4.5 + property real b: 11.2 + property int c: 9 + property int d: 176 + property string e: "Hello" + property string f: "World" + property variant g: 6.7 + property variant h: "!" + property variant i: true + property string j: "#112233" + property string k: "#aa112233" +} diff --git a/tests/auto/qml/qqmlecmascript/data/compositePropertyType.qml b/tests/auto/qml/qqmlecmascript/data/compositePropertyType.qml new file mode 100644 index 0000000000..e97b75c8d0 --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/compositePropertyType.qml @@ -0,0 +1,8 @@ +import QtQuick 2.0 + +QtObject { + property CustomObject myObject + myObject: CustomObject { } + + Component.onCompleted: console.log(myObject.greeting) +} diff --git a/tests/auto/qml/qqmlecmascript/data/constantsOverrideBindings.1.qml b/tests/auto/qml/qqmlecmascript/data/constantsOverrideBindings.1.qml new file mode 100644 index 0000000000..13c5ae5fff --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/constantsOverrideBindings.1.qml @@ -0,0 +1,8 @@ +import Qt.test 1.0 + +MyQmlObject { + property int c1: 0 + property int c2: c1 + + onBasicSignal: c2 = 13 +} diff --git a/tests/auto/qml/qqmlecmascript/data/constantsOverrideBindings.2.qml b/tests/auto/qml/qqmlecmascript/data/constantsOverrideBindings.2.qml new file mode 100644 index 0000000000..207a06b700 --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/constantsOverrideBindings.2.qml @@ -0,0 +1,11 @@ +import Qt.test 1.0 + +MyQmlObject { + property alias c1: myConstants.c1 + property alias c2: myConstants.c2 + + objectProperty: ConstantsOverrideBindings { + id: myConstants + c2: 10 + } +} diff --git a/tests/auto/qml/qqmlecmascript/data/constantsOverrideBindings.3.qml b/tests/auto/qml/qqmlecmascript/data/constantsOverrideBindings.3.qml new file mode 100644 index 0000000000..ca9d1d8ab9 --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/constantsOverrideBindings.3.qml @@ -0,0 +1,7 @@ +import Qt.test 1.0 + +MyQmlObject { + property int c1: 0 + property int c2: c1 +} + diff --git a/tests/auto/qml/qqmlecmascript/data/constantsOverrideBindings.4.qml b/tests/auto/qml/qqmlecmascript/data/constantsOverrideBindings.4.qml new file mode 100644 index 0000000000..5a2091f71c --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/constantsOverrideBindings.4.qml @@ -0,0 +1,11 @@ +import Qt.test 1.0 + +MyQmlObject { + property alias c1: myConstants.c1 + property alias c3: myConstants.c3 + + objectProperty: ConstantsOverrideBindings { + id: myConstants + c3: 10 + } +} diff --git a/tests/auto/qml/qqmlecmascript/data/deferredProperties.qml b/tests/auto/qml/qqmlecmascript/data/deferredProperties.qml new file mode 100644 index 0000000000..e01f708a07 --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/deferredProperties.qml @@ -0,0 +1,10 @@ +import Qt.test 1.0 + +MyDeferredObject { + id: root + value: 10 + objectProperty: MyQmlObject { + value: root.value + } + objectProperty2: MyQmlObject { id: blah } +} diff --git a/tests/auto/qml/qqmlecmascript/data/deferredPropertiesErrors.qml b/tests/auto/qml/qqmlecmascript/data/deferredPropertiesErrors.qml new file mode 100644 index 0000000000..308a01ce6f --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/deferredPropertiesErrors.qml @@ -0,0 +1,10 @@ +import Qt.test 1.0 +import QtQuick 2.0 + +MyDeferredObject { + value: undefined // error is resolved before complete + objectProperty: undefined // immediate error + objectProperty2: QtObject { + Component.onCompleted: value = 10 + } +} diff --git a/tests/auto/qml/qqmlecmascript/data/deleteLater.qml b/tests/auto/qml/qqmlecmascript/data/deleteLater.qml new file mode 100644 index 0000000000..2a9ce44b20 --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/deleteLater.qml @@ -0,0 +1,14 @@ +import QtQuick 2.0 + +QtObject { + id: root + property bool test: false + + Component.onCompleted: { + try { + root.deleteLater() + } catch(e) { + test = true; + } + } +} diff --git a/tests/auto/qml/qqmlecmascript/data/deleteWhileBindingRunning.qml b/tests/auto/qml/qqmlecmascript/data/deleteWhileBindingRunning.qml new file mode 100644 index 0000000000..b5cc59e2c0 --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/deleteWhileBindingRunning.qml @@ -0,0 +1,5 @@ +import Qt.test 1.0 + +MyDeleteObject { + property int result: nestedObject.intProperty + deleteNestedObject +} diff --git a/tests/auto/qml/qqmlecmascript/data/deletedEngine.qml b/tests/auto/qml/qqmlecmascript/data/deletedEngine.qml new file mode 100644 index 0000000000..97acddf5fc --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/deletedEngine.qml @@ -0,0 +1,11 @@ +import QtQuick 2.0 + +QtObject { + function calculate() { + return b * 13; + } + + property int a: calculate() + property int b: 3 +} + diff --git a/tests/auto/qml/qqmlecmascript/data/deletedObject.qml b/tests/auto/qml/qqmlecmascript/data/deletedObject.qml new file mode 100644 index 0000000000..24c12bf694 --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/deletedObject.qml @@ -0,0 +1,25 @@ +import QtQuick 2.0 +import Qt.test 1.0 + +QtObject { + property variant obj + obj: MyQmlObject { + id: myObject + value: 92 + } + + property bool test1: false + property bool test2: false + property bool test3: false + property bool test4: false + + Component.onCompleted: { + test1 = myObject.value == 92; + test2 = obj.value == 92; + + myObject.deleteOnSet = 1; + + test3 = myObject == null + test4 = obj == null + } +} diff --git a/tests/auto/qml/qqmlecmascript/data/doubleEvaluate.qml b/tests/auto/qml/qqmlecmascript/data/doubleEvaluate.qml new file mode 100644 index 0000000000..0532715432 --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/doubleEvaluate.qml @@ -0,0 +1,6 @@ +import Qt.test 1.0 + +WriteCounter { + property int x: 0 + value: if (1) x + x +} diff --git a/tests/auto/qml/qqmlecmascript/data/dynamicCreation.helper.qml b/tests/auto/qml/qqmlecmascript/data/dynamicCreation.helper.qml new file mode 100644 index 0000000000..d790d634e9 --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/dynamicCreation.helper.qml @@ -0,0 +1,6 @@ +import Qt.test 1.0 + +MyQmlObject{ + objectName: "objectTwo" +} + diff --git a/tests/auto/qml/qqmlecmascript/data/dynamicCreation.qml b/tests/auto/qml/qqmlecmascript/data/dynamicCreation.qml new file mode 100644 index 0000000000..7b132e1edf --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/dynamicCreation.qml @@ -0,0 +1,27 @@ +import Qt.test 1.0 + +MyQmlObject{ + id: obj + objectName: "obj" + function createOne() + { + obj.objectProperty = Qt.createQmlObject('import Qt.test 1.0; MyQmlObject{objectName:"objectOne"}', obj); + } + + function createTwo() + { + var component = Qt.createComponent('dynamicCreation.helper.qml'); + obj.objectProperty = component.createObject(obj); + } + + function createThree() + { + obj.objectProperty = Qt.createQmlObject('TypeForDynamicCreation{}', obj); + } + + function dontCrash() + { + var component = Qt.createComponent('file-doesnt-exist.qml'); + obj.objectProperty = component.createObject(obj); + } +} diff --git a/tests/auto/qml/qqmlecmascript/data/dynamicCreationOwnership.qml b/tests/auto/qml/qqmlecmascript/data/dynamicCreationOwnership.qml new file mode 100644 index 0000000000..ed396d49b0 --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/dynamicCreationOwnership.qml @@ -0,0 +1,20 @@ +import QtQuick 2.0 +import Qt.test 1.0 + +Item { + id: obj + objectName: "obj" + + MyDynamicCreationDestructionObject { + id: mdcdo + objectName: "mdcdo" + } + + function dynamicallyCreateJsOwnedObject() { + mdcdo.createNew(); + } + + function performGc() { + gc(); + } +} diff --git a/tests/auto/qml/qqmlecmascript/data/dynamicDeletion.2.qml b/tests/auto/qml/qqmlecmascript/data/dynamicDeletion.2.qml new file mode 100644 index 0000000000..9a5732c194 --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/dynamicDeletion.2.qml @@ -0,0 +1,21 @@ +import QtQuick 2.0 + +QtObject { + id: root + + property QtObject objectProperty + + property Component c: Component { + id: componentObject + QtObject { + } + } + + function create() { + objectProperty = c.createObject(root); + } + + function destroy() { + objectProperty.destroy(); + } +} diff --git a/tests/auto/qml/qqmlecmascript/data/dynamicDeletion.qml b/tests/auto/qml/qqmlecmascript/data/dynamicDeletion.qml new file mode 100644 index 0000000000..f41e5262fd --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/dynamicDeletion.qml @@ -0,0 +1,20 @@ +import Qt.test 1.0 + +MyQmlObject{ + id: obj + objectName: "obj" + function create() + { + obj.objectProperty = Qt.createQmlObject('import Qt.test 1.0; MyQmlObject{objectName:"emptyObject"}', obj); + } + + function killOther() + { + obj.objectProperty.destroy(500); + } + + function killMe() + { + obj.destroy();//Must not segfault + } +} diff --git a/tests/auto/qml/qqmlecmascript/data/dynamicString.qml b/tests/auto/qml/qqmlecmascript/data/dynamicString.qml new file mode 100644 index 0000000000..5693794c71 --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/dynamicString.qml @@ -0,0 +1,16 @@ +import Qt.test 1.0 +import QtQuick 2.0 + +MyTypeObject { + stringProperty:"string:%0 false:%1 true:%2 uint32:%3 int32:%4 double:%5 date:%6!" + Component.onCompleted: { + var date = new Date(); + date.setDate(11); + date.setMonth(1); + date.setFullYear(2011); + date.setHours(5); + date.setMinutes(30); + date.setSeconds(50); + stringProperty = stringProperty.arg("Hello World").arg(false).arg(true).arg(100).arg(-100).arg(3.1415926).arg(Qt.formatDateTime(date, "yyyy-MM-dd hh::mm:ss")); + } +} diff --git a/tests/auto/qml/qqmlecmascript/data/elementAssign.qml b/tests/auto/qml/qqmlecmascript/data/elementAssign.qml new file mode 100644 index 0000000000..0d75cbf6fc --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/elementAssign.qml @@ -0,0 +1,10 @@ +import QtQuick 2.0 + +QtObject { + id: root + + property bool test: bound.value == 1923 + + property ElementAssignType element: ElementAssignType { value: 1923 } + property ElementAssignType bound: root.element +} diff --git a/tests/auto/qml/qqmlecmascript/data/enums.1.qml b/tests/auto/qml/qqmlecmascript/data/enums.1.qml new file mode 100644 index 0000000000..6351823230 --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/enums.1.qml @@ -0,0 +1,20 @@ +import Qt.test 1.0 +import Qt.test 1.0 as Namespace + +MyQmlObject { + // Enums from non-namespaced type + property int a: MyQmlObject.EnumValue1 + property int b: MyQmlObject.EnumValue2 + property int c: MyQmlObject.EnumValue3 + property int d: MyQmlObject.EnumValue4 + + // Enums from namespaced type + property int e: Namespace.MyQmlObject.EnumValue1 + property int f: Namespace.MyQmlObject.EnumValue2 + property int g: Namespace.MyQmlObject.EnumValue3 + property int h: Namespace.MyQmlObject.EnumValue4 + + // Test that enums don't mask attached properties + property int i: MyQmlObject.value + property int j: Namespace.MyQmlObject.value +} diff --git a/tests/auto/qml/qqmlecmascript/data/enums.2.qml b/tests/auto/qml/qqmlecmascript/data/enums.2.qml new file mode 100644 index 0000000000..bdc672fadc --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/enums.2.qml @@ -0,0 +1,8 @@ +import Qt.test 1.0 +import Qt.test 1.0 as Namespace + +MyQmlObject { + property int a: MyQmlObject.EnumValue10 + property int b: Namespace.MyQmlObject.EnumValue10 +} + diff --git a/tests/auto/qml/qqmlecmascript/data/eval.qml b/tests/auto/qml/qqmlecmascript/data/eval.qml new file mode 100644 index 0000000000..a752b8c0d3 --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/eval.qml @@ -0,0 +1,27 @@ +import QtQuick 2.0 + +QtObject { + property bool test1: false; + property bool test2: false; + property bool test3: false; + property bool test4: false; + property bool test5: false; + + + property int a: 7 + property int b: 8 + + Component.onCompleted: { + var b = 9; + + test1 = (eval("a") == 7); + test2 = (eval("b") == 9); + try { + eval("c"); + } catch(e) { + test3 = true; + } + test4 = (eval("console") == console); + test5 = (eval("Qt") == Qt); + } +} diff --git a/tests/auto/qml/qqmlecmascript/data/exception.js b/tests/auto/qml/qqmlecmascript/data/exception.js new file mode 100644 index 0000000000..160bbfa5b6 --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/exception.js @@ -0,0 +1 @@ +throw("Whoops!"); diff --git a/tests/auto/qml/qqmlecmascript/data/exceptionClearsOnReeval.qml b/tests/auto/qml/qqmlecmascript/data/exceptionClearsOnReeval.qml new file mode 100644 index 0000000000..a2f0d1a8b7 --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/exceptionClearsOnReeval.qml @@ -0,0 +1,6 @@ +import Qt.test 1.0 + +MyQmlObject { + property bool test: objectProperty.objectProperty.trueProperty +} + diff --git a/tests/auto/qml/qqmlecmascript/data/exceptionProducesWarning.qml b/tests/auto/qml/qqmlecmascript/data/exceptionProducesWarning.qml new file mode 100644 index 0000000000..b8d5e5e60f --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/exceptionProducesWarning.qml @@ -0,0 +1,8 @@ +import QtQuick 2.0 +import Qt.test 1.0 + +MyQmlObject { + Component.onCompleted: + { throw(new Error("JS exception")) } +} + diff --git a/tests/auto/qml/qqmlecmascript/data/exceptionProducesWarning2.qml b/tests/auto/qml/qqmlecmascript/data/exceptionProducesWarning2.qml new file mode 100644 index 0000000000..a4ce55e245 --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/exceptionProducesWarning2.qml @@ -0,0 +1,7 @@ +import QtQuick 2.0 +import Qt.test 1.0 + +MyQmlObject { + value: { throw(new Error("JS exception")) } +} + diff --git a/tests/auto/qml/qqmlecmascript/data/extendedObjectPropertyLookup.qml b/tests/auto/qml/qqmlecmascript/data/extendedObjectPropertyLookup.qml new file mode 100644 index 0000000000..2c382e871a --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/extendedObjectPropertyLookup.qml @@ -0,0 +1,8 @@ +import Qt.test 1.0 +import QtQuick 2.0 + +QtObject { + property MyExtendedObject a; + a: MyExtendedObject { id: root } + property int b: Math.max(root.extendedProperty, 0) +} diff --git a/tests/auto/qml/qqmlecmascript/data/extendedObjectPropertyLookup2.qml b/tests/auto/qml/qqmlecmascript/data/extendedObjectPropertyLookup2.qml new file mode 100644 index 0000000000..e4af3359d0 --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/extendedObjectPropertyLookup2.qml @@ -0,0 +1,14 @@ +import Qt.test 1.0 +import QtQuick 2.0 + +QtObject { + id: root + property MyExtendedObject a; + a: MyExtendedObject { + id: obj + extendedProperty: 42; + } + function getValue() { + return obj.extendedProperty; + } +} diff --git a/tests/auto/qml/qqmlecmascript/data/extensionObjects.qml b/tests/auto/qml/qqmlecmascript/data/extensionObjects.qml new file mode 100644 index 0000000000..7734a11dd8 --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/extensionObjects.qml @@ -0,0 +1,19 @@ +import Qt.test 1.0 +import QtQuick 2.0 + +MyExtendedObject +{ + baseProperty: baseExtendedProperty + baseExtendedProperty: 13 + + coreProperty: extendedProperty + extendedProperty: 9 + + property QtObject nested: MyExtendedObject { + baseProperty: baseExtendedProperty + baseExtendedProperty: 13 + + coreProperty: extendedProperty + extendedProperty: 9 + } +} diff --git a/tests/auto/qml/qqmlecmascript/data/extensionObjectsPropertyOverride.qml b/tests/auto/qml/qqmlecmascript/data/extensionObjectsPropertyOverride.qml new file mode 100644 index 0000000000..3c443cb975 --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/extensionObjectsPropertyOverride.qml @@ -0,0 +1,7 @@ +import Qt.test 1.0 + +OverrideDefaultPropertyObject +{ + MyBaseExtendedObject { + } +} diff --git a/tests/auto/qml/qqmlecmascript/data/forInLoop.qml b/tests/auto/qml/qqmlecmascript/data/forInLoop.qml new file mode 100644 index 0000000000..f14367f177 --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/forInLoop.qml @@ -0,0 +1,13 @@ +import QtQuick 2.0 + +QtObject { + property list objects + objects: [QtObject { objectName: "obj1" }, QtObject { objectName: "obj2" }, QtObject { objectName: "obj3" }] + property string listResult + + function listProperty() { + for (var i in objects) + listResult += i + "=" + objects[i].objectName + "|" + } +} + diff --git a/tests/auto/qml/qqmlecmascript/data/function.qml b/tests/auto/qml/qqmlecmascript/data/function.qml new file mode 100644 index 0000000000..af2da7023c --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/function.qml @@ -0,0 +1,23 @@ +import QtQuick 2.0 + +QtObject { + property bool test1: false; + property bool test2: false; + property bool test3: false; + + Component.onCompleted: { + var a = 10; + + var func1 = new Function("a", "return a + 7"); + var func2 = new Function("a", "return Qt.atob(a)"); + var func3 = new Function("return a"); + + test1 = (func1(4) == 11); + test2 = (func2("Hello World!") == Qt.atob("Hello World!")); + try { + func3(); + } catch(e) { + test3 = true; + } + } +} diff --git a/tests/auto/qml/qqmlecmascript/data/functionAssignment.1.qml b/tests/auto/qml/qqmlecmascript/data/functionAssignment.1.qml new file mode 100644 index 0000000000..09540f1f6e --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/functionAssignment.1.qml @@ -0,0 +1,5 @@ +import Qt.test 1.0 + +MyQmlObject { + property variant a: function myFunction() { return 2; } +} diff --git a/tests/auto/qml/qqmlecmascript/data/functionAssignment.2.qml b/tests/auto/qml/qqmlecmascript/data/functionAssignment.2.qml new file mode 100644 index 0000000000..0f78eaf1dc --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/functionAssignment.2.qml @@ -0,0 +1,73 @@ +import Qt.test 1.0 +import QtQuick 2.0 + +import "functionAssignment.js" as Script + +MyQmlObject { + property variant a + property int aNumber: 10 + + property bool assignToProperty: false + property bool assignToPropertyFromJsFile: false + + property bool assignWithThis: false + property bool assignWithThisFromJsFile: false + + property bool assignToValueType: false + + property bool assignFuncWithoutReturn: false + property bool assignWrongType: false + property bool assignWrongTypeToValueType: false + + + onAssignToPropertyChanged: { + function myFunction() { + return aNumber * 10; + } + a = myFunction; + } + + property QtObject obj: QtObject { + property int aNumber: 4212 + function myFunction() { + return this.aNumber * 10; // should use the aNumber from root, not this object + } + } + onAssignWithThisChanged: { + a = obj.myFunction; + } + + onAssignToPropertyFromJsFileChanged: { + Script.bindPropertyWithThis() + } + + onAssignWithThisFromJsFileChanged: { + Script.bindProperty() + } + + property Text text: Text { } + onAssignToValueTypeChanged: { + text.font.pixelSize = (function() { return aNumber * 10; }) + a = (function() { return text.font.pixelSize; }) + } + + + // detecting errors: + + onAssignFuncWithoutReturnChanged: { + function myFunction() { + } + a = myFunction; + } + + onAssignWrongTypeChanged: { + function myFunction() { + return 'a string'; + } + aNumber = myFunction; + } + + onAssignWrongTypeToValueTypeChanged: { + text.font.pixelSize = (function() { return 'a string'; }) + } +} diff --git a/tests/auto/qml/qqmlecmascript/data/functionAssignment.js b/tests/auto/qml/qqmlecmascript/data/functionAssignment.js new file mode 100644 index 0000000000..14daa7629f --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/functionAssignment.js @@ -0,0 +1,17 @@ +function bindProperty() +{ + a = (function(){ return aNumber * 10 }) +} + + +function TestObject() { } +TestObject.prototype.aNumber = 928349 +TestObject.prototype.bindFunction = function() { + return this.aNumber * 10 // this should not use the TestObject's aNumber +} +var testObj = new TestObject() + +function bindPropertyWithThis() +{ + a = testObj.bindFunction +} diff --git a/tests/auto/qml/qqmlecmascript/data/functionErrors.qml b/tests/auto/qml/qqmlecmascript/data/functionErrors.qml new file mode 100644 index 0000000000..230a626600 --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/functionErrors.qml @@ -0,0 +1,10 @@ +import QtQuick 2.0 + +QtObject { + function myFunction() { + a = 10; + } + + Component.onCompleted: myFunction(); +} + diff --git a/tests/auto/qml/qqmlecmascript/data/handleReferenceManagement.handle.1.qml b/tests/auto/qml/qqmlecmascript/data/handleReferenceManagement.handle.1.qml new file mode 100644 index 0000000000..8a06c30d8c --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/handleReferenceManagement.handle.1.qml @@ -0,0 +1,21 @@ +import QtQuick 2.0 +import Qt.test 1.0 + +Item { + id: obj + objectName: "obj" + property CircularReferenceHandle first + property CircularReferenceHandle second + + CircularReferenceHandle { + id: crh + objectName: "crh" + } + + function createReference() { + first = crh.generate(crh); + second = crh.generate(crh); + // NOTE: manually add reference from first to second + // in unit test prior reparenting and gc. + } +} diff --git a/tests/auto/qml/qqmlecmascript/data/handleReferenceManagement.handle.2.qml b/tests/auto/qml/qqmlecmascript/data/handleReferenceManagement.handle.2.qml new file mode 100644 index 0000000000..91edc447e2 --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/handleReferenceManagement.handle.2.qml @@ -0,0 +1,22 @@ +import QtQuick 2.0 +import Qt.test 1.0 + +Item { + id: obj + objectName: "obj" + property CircularReferenceHandle first + property CircularReferenceHandle second + + CircularReferenceHandle { + id: crh + objectName: "crh" + } + + function circularReference() { + // generate the circularly referential pair + first = crh.generate(crh); + second = crh.generate(crh); + // note: must manually reparent in unit test + // after setting the handle references. + } +} diff --git a/tests/auto/qml/qqmlecmascript/data/handleReferenceManagement.object.1.qml b/tests/auto/qml/qqmlecmascript/data/handleReferenceManagement.object.1.qml new file mode 100644 index 0000000000..70e8390677 --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/handleReferenceManagement.object.1.qml @@ -0,0 +1,27 @@ +import QtQuick 2.0 +import Qt.test 1.0 + +Item { + id: obj + objectName: "obj" + + property CircularReferenceObject first + property CircularReferenceObject second + + + CircularReferenceObject { + id: cro + objectName: "cro" + } + + function createReference() { + // generate the objects + first = cro.generate(cro); // has parent, so won't be collected + second = cro.generate(); // no parent, but will be kept alive by first's reference + first.addReference(second); + + // remove top level references + first = cro; + second = cro; + } +} diff --git a/tests/auto/qml/qqmlecmascript/data/handleReferenceManagement.object.2.qml b/tests/auto/qml/qqmlecmascript/data/handleReferenceManagement.object.2.qml new file mode 100644 index 0000000000..2ddb9253eb --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/handleReferenceManagement.object.2.qml @@ -0,0 +1,28 @@ +import QtQuick 2.0 +import Qt.test 1.0 + +Item { + id: obj + objectName: "obj" + + property CircularReferenceObject first + property CircularReferenceObject second + + + CircularReferenceObject { + id: cro + objectName: "cro" + } + + function circularReference() { + // generate the circularly referential pair - they should still be collected + first = cro.generate(); // no parent, so should be collected + second = cro.generate(); // no parent, so should be collected + first.addReference(second); + second.addReference(first); + + // remove top level references + first = cro; + second = cro; + } +} diff --git a/tests/auto/qml/qqmlecmascript/data/idShortcutInvalidates.1.qml b/tests/auto/qml/qqmlecmascript/data/idShortcutInvalidates.1.qml new file mode 100644 index 0000000000..ece23269f1 --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/idShortcutInvalidates.1.qml @@ -0,0 +1,13 @@ +import Qt.test 1.0 +import QtQuick 2.0 + +MyQmlObject { + objectProperty: if(1) otherObject + + property variant obj + + obj: QtObject { + id: otherObject + } +} + diff --git a/tests/auto/qml/qqmlecmascript/data/idShortcutInvalidates.qml b/tests/auto/qml/qqmlecmascript/data/idShortcutInvalidates.qml new file mode 100644 index 0000000000..650ed7c73e --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/idShortcutInvalidates.qml @@ -0,0 +1,12 @@ +import Qt.test 1.0 +import QtQuick 2.0 + +MyQmlObject { + objectProperty: otherObject + + property variant obj + + obj: QtObject { + id: otherObject + } +} diff --git a/tests/auto/qml/qqmlecmascript/data/importScope.1.js b/tests/auto/qml/qqmlecmascript/data/importScope.1.js new file mode 100644 index 0000000000..4c556f9e96 --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/importScope.1.js @@ -0,0 +1 @@ +var value = 240 diff --git a/tests/auto/qml/qqmlecmascript/data/importScope.2.js b/tests/auto/qml/qqmlecmascript/data/importScope.2.js new file mode 100644 index 0000000000..291fb9d2cc --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/importScope.2.js @@ -0,0 +1,3 @@ +function getValue() { + return ImportScope1.value +} diff --git a/tests/auto/qml/qqmlecmascript/data/importScope.qml b/tests/auto/qml/qqmlecmascript/data/importScope.qml new file mode 100644 index 0000000000..9b907f11f9 --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/importScope.qml @@ -0,0 +1,7 @@ +import QtQuick 2.0 +import "importScope.1.js" as ImportScope1 +import "importScope.2.js" as ImportScope2 + +QtObject { + property int test: ImportScope2.getValue() +} diff --git a/tests/auto/qml/qqmlecmascript/data/in.qml b/tests/auto/qml/qqmlecmascript/data/in.qml new file mode 100644 index 0000000000..f84c9a1481 --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/in.qml @@ -0,0 +1,7 @@ +import QtQuick 2.0 + +Item { + id: root + property bool test1: "x" in root + property bool test2: !("foo" in root) +} diff --git a/tests/auto/qml/qqmlecmascript/data/include.js b/tests/auto/qml/qqmlecmascript/data/include.js new file mode 100644 index 0000000000..232fd808f8 --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/include.js @@ -0,0 +1,8 @@ +var test1 = true +var test2 = false +var test3 = false + +function go() { + Qt.include("js/include2.js"); +} + diff --git a/tests/auto/qml/qqmlecmascript/data/include.qml b/tests/auto/qml/qqmlecmascript/data/include.qml new file mode 100644 index 0000000000..5ce2ed78ec --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/include.qml @@ -0,0 +1,23 @@ +import QtQuick 2.0 +import "include.js" as IncludeTest + +QtObject { + property int test0: 0 + property bool test1: false + property bool test2: false + property bool test2_1: false + property bool test3: false + property bool test3_1: false + + property int testValue: 99 + + Component.onCompleted: { + IncludeTest.go(); + test0 = IncludeTest.value + test1 = IncludeTest.test1 + test2 = IncludeTest.test2 + test2_1 = IncludeTest.test2_1 + test3 = IncludeTest.test3 + test3_1 = IncludeTest.test3_1 + } +} diff --git a/tests/auto/qml/qqmlecmascript/data/include_callback.js b/tests/auto/qml/qqmlecmascript/data/include_callback.js new file mode 100644 index 0000000000..ea19eba300 --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/include_callback.js @@ -0,0 +1,11 @@ +function go() { + var a = Qt.include("missing.js", function(o) { test2 = o.status == o.NETWORK_ERROR }); + test1 = a.status == a.NETWORK_ERROR + + var b = Qt.include("blank.js", function(o) { test4 = o.status == o.OK }); + test3 = b.status == b.OK + + var c = Qt.include("exception.js", function(o) { test6 = o.status == o.EXCEPTION }); + test5 = c.status == c.EXCEPTION +} + diff --git a/tests/auto/qml/qqmlecmascript/data/include_callback.qml b/tests/auto/qml/qqmlecmascript/data/include_callback.qml new file mode 100644 index 0000000000..fbebcdcd58 --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/include_callback.qml @@ -0,0 +1,15 @@ +import QtQuick 2.0 +import "include_callback.js" as IncludeTest + +QtObject { + property bool test1: false + property bool test2: false + property bool test3: false + property bool test4: false + property bool test5: false + property bool test6: false + + Component.onCompleted: { + IncludeTest.go(); + } +} diff --git a/tests/auto/qml/qqmlecmascript/data/include_pragma.qml b/tests/auto/qml/qqmlecmascript/data/include_pragma.qml new file mode 100644 index 0000000000..7b23c76baa --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/include_pragma.qml @@ -0,0 +1,11 @@ +import QtQuick 2.0 +import "include_pragma_outer.js" as Script + +Item { + property int test1 + + Component.onCompleted: { + test1 = Script.callFunction() + } +} + diff --git a/tests/auto/qml/qqmlecmascript/data/include_pragma_inner.js b/tests/auto/qml/qqmlecmascript/data/include_pragma_inner.js new file mode 100644 index 0000000000..a0380a25df --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/include_pragma_inner.js @@ -0,0 +1,5 @@ +.pragma library + +function getValue() { + return 100; +} diff --git a/tests/auto/qml/qqmlecmascript/data/include_pragma_outer.js b/tests/auto/qml/qqmlecmascript/data/include_pragma_outer.js new file mode 100644 index 0000000000..d87bafc816 --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/include_pragma_outer.js @@ -0,0 +1,6 @@ +Qt.include("include_pragma_inner.js") + +function callFunction() { + return getValue(); +} + diff --git a/tests/auto/qml/qqmlecmascript/data/include_remote.js b/tests/auto/qml/qqmlecmascript/data/include_remote.js new file mode 100644 index 0000000000..e6a4676819 --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/include_remote.js @@ -0,0 +1,26 @@ +var myvar = 10; + +function go() +{ + var a = Qt.include("http://127.0.0.1:8111/remote_file.js", + function(o) { + test2 = o.status == o.OK + test3 = a.status == a.OK + test4 = myvar == 13 + + done = true; + }); + test1 = a.status == a.LOADING + + + var b = Qt.include("http://127.0.0.1:8111/exception.js", + function(o) { + test7 = o.status == o.EXCEPTION + test8 = b.status == a.EXCEPTION + test9 = b.exception.toString() == "Whoops!"; + test10 = o.exception.toString() == "Whoops!"; + + done2 = true; + }); + test6 = b.status == b.LOADING +} diff --git a/tests/auto/qml/qqmlecmascript/data/include_remote.qml b/tests/auto/qml/qqmlecmascript/data/include_remote.qml new file mode 100644 index 0000000000..fe020a55df --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/include_remote.qml @@ -0,0 +1,21 @@ +import QtQuick 2.0 +import "include_remote.js" as IncludeTest + +QtObject { + property bool done: false + property bool done2: false + + property bool test1: false + property bool test2: false + property bool test3: false + property bool test4: false + property bool test5: false + + property bool test6: false + property bool test7: false + property bool test8: false + property bool test9: false + property bool test10: false + + Component.onCompleted: IncludeTest.go(); +} diff --git a/tests/auto/qml/qqmlecmascript/data/include_remote_missing.js b/tests/auto/qml/qqmlecmascript/data/include_remote_missing.js new file mode 100644 index 0000000000..cc90860cc9 --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/include_remote_missing.js @@ -0,0 +1,13 @@ +function go() +{ + var a = Qt.include("http://127.0.0.1:8111/missing.js", + function(o) { + test2 = o.status == o.NETWORK_ERROR + test3 = a.status == a.NETWORK_ERROR + + done = true; + }); + + test1 = a.status == a.LOADING +} + diff --git a/tests/auto/qml/qqmlecmascript/data/include_remote_missing.qml b/tests/auto/qml/qqmlecmascript/data/include_remote_missing.qml new file mode 100644 index 0000000000..e8ef609fed --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/include_remote_missing.qml @@ -0,0 +1,12 @@ +import QtQuick 2.0 +import "include_remote_missing.js" as IncludeTest + +QtObject { + property bool done: false + + property bool test1: false + property bool test2: false + property bool test3: false + + Component.onCompleted: IncludeTest.go(); +} diff --git a/tests/auto/qml/qqmlecmascript/data/include_shared.js b/tests/auto/qml/qqmlecmascript/data/include_shared.js new file mode 100644 index 0000000000..a49c07bbfc --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/include_shared.js @@ -0,0 +1,12 @@ +.pragma library + +var test1 = true +var test2 = false +var test3 = false + +var testValue = 99; + +function go() { + Qt.include("js/include2.js"); +} + diff --git a/tests/auto/qml/qqmlecmascript/data/include_shared.qml b/tests/auto/qml/qqmlecmascript/data/include_shared.qml new file mode 100644 index 0000000000..28b1003fd4 --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/include_shared.qml @@ -0,0 +1,22 @@ +import QtQuick 2.0 +import "include_shared.js" as IncludeTest + +QtObject { + property int test0: 0 + property bool test1: false + property bool test2: false + property bool test2_1: false + property bool test3: false + property bool test3_1: false + + Component.onCompleted: { + IncludeTest.go(); + test0 = IncludeTest.value + test1 = IncludeTest.test1 + test2 = IncludeTest.test2 + test2_1 = IncludeTest.test2_1 + test3 = IncludeTest.test3 + test3_1 = IncludeTest.test3_1 + } +} + diff --git a/tests/auto/qml/qqmlecmascript/data/invokableObjectArg.qml b/tests/auto/qml/qqmlecmascript/data/invokableObjectArg.qml new file mode 100644 index 0000000000..160a90b574 --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/invokableObjectArg.qml @@ -0,0 +1,9 @@ +import Qt.test 1.0 +import QtQuick 2.0 + +MyQmlObject { + id: root + Component.onCompleted: { + root.myinvokable(root); + } +} diff --git a/tests/auto/qml/qqmlecmascript/data/invokableObjectRet.qml b/tests/auto/qml/qqmlecmascript/data/invokableObjectRet.qml new file mode 100644 index 0000000000..4612273727 --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/invokableObjectRet.qml @@ -0,0 +1,11 @@ +import Qt.test 1.0 +import QtQuick 2.0 + +MyQmlObject { + id: root + property bool test: false + Component.onCompleted: { + test = (root.returnme() == root) + } +} + diff --git a/tests/auto/qml/qqmlecmascript/data/js/include2.js b/tests/auto/qml/qqmlecmascript/data/js/include2.js new file mode 100644 index 0000000000..2a0c039dfa --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/js/include2.js @@ -0,0 +1,4 @@ +test2 = true +var test2_1 = true + +Qt.include("include3.js"); diff --git a/tests/auto/qml/qqmlecmascript/data/js/include3.js b/tests/auto/qml/qqmlecmascript/data/js/include3.js new file mode 100644 index 0000000000..84b2770b6f --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/js/include3.js @@ -0,0 +1,3 @@ +test3 = true +var test3_1 = true +var value = testValue diff --git a/tests/auto/qml/qqmlecmascript/data/jsObject.qml b/tests/auto/qml/qqmlecmascript/data/jsObject.qml new file mode 100644 index 0000000000..4223c25f31 --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/jsObject.qml @@ -0,0 +1,12 @@ +import QtQuick 2.0 + +QtObject { + property int test + + Component.onCompleted: { + var o = new Object; + o.test = 92; + test = o.test; + } +} + diff --git a/tests/auto/qml/qqmlecmascript/data/jsimport/SpecialRectangleOne.qml b/tests/auto/qml/qqmlecmascript/data/jsimport/SpecialRectangleOne.qml new file mode 100644 index 0000000000..97c72bd9a6 --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/jsimport/SpecialRectangleOne.qml @@ -0,0 +1,9 @@ +import QtQuick 2.0 + +import "importPragmaLibrary.js" as TestPragmaLibraryImport + +Rectangle { + width: TestPragmaLibraryImport.importIncrementedValue() + height: width + 15 + color: "red" +} diff --git a/tests/auto/qml/qqmlecmascript/data/jsimport/SpecialRectangleTwo.qml b/tests/auto/qml/qqmlecmascript/data/jsimport/SpecialRectangleTwo.qml new file mode 100644 index 0000000000..d006343782 --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/jsimport/SpecialRectangleTwo.qml @@ -0,0 +1,9 @@ +import QtQuick 2.0 + +import "importPragmaLibrary.js" as TestPragmaLibraryImport + +Rectangle { + width: TestPragmaLibraryImport.importIncrementedValue() + height: width + 5 + color: "blue" +} diff --git a/tests/auto/qml/qqmlecmascript/data/jsimport/importFive.js b/tests/auto/qml/qqmlecmascript/data/jsimport/importFive.js new file mode 100644 index 0000000000..e458094552 --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/jsimport/importFive.js @@ -0,0 +1,3 @@ +function importFiveFunction() { + return '5'; +} diff --git a/tests/auto/qml/qqmlecmascript/data/jsimport/importFour.js b/tests/auto/qml/qqmlecmascript/data/jsimport/importFour.js new file mode 100644 index 0000000000..faddc15c9d --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/jsimport/importFour.js @@ -0,0 +1,9 @@ +.pragma library + +function importFourFunction() { + return '4'; +} + +function greetingString() { + return 'Hello, World!'; +} diff --git a/tests/auto/qml/qqmlecmascript/data/jsimport/importOne.js b/tests/auto/qml/qqmlecmascript/data/jsimport/importOne.js new file mode 100644 index 0000000000..338c4e042f --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/jsimport/importOne.js @@ -0,0 +1,13 @@ +.import "importTwo.js" as ImportTwoJs +.import "importThree.js" as ImportThreeJs + +function greetingString() { + if (ImportTwoJs.greetingString().length > 0) { + return ImportTwoJs.greetingString(); + } + return ImportThreeJs.greetingString(); +} + +function importOneFunction() { + return '1'; +} diff --git a/tests/auto/qml/qqmlecmascript/data/jsimport/importPragmaLibrary.js b/tests/auto/qml/qqmlecmascript/data/jsimport/importPragmaLibrary.js new file mode 100644 index 0000000000..c746fef14b --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/jsimport/importPragmaLibrary.js @@ -0,0 +1,9 @@ +.pragma library + +var i = 4; + +// .pragma library, so should be callable from multiple .qml with shared i. +function importIncrementedValue() { + i = i + 1; + return i; +} diff --git a/tests/auto/qml/qqmlecmascript/data/jsimport/importPragmaLibraryWithImports.js b/tests/auto/qml/qqmlecmascript/data/jsimport/importPragmaLibraryWithImports.js new file mode 100644 index 0000000000..3f2e6589dd --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/jsimport/importPragmaLibraryWithImports.js @@ -0,0 +1,9 @@ +.pragma library +.import "importFive.js" as ImportFive + +var i = 4; + +function importIncrementedValue() { + i = i + 1; + return (i + ImportFive.importFiveFunction()); // i + '5' (not i+5) +} diff --git a/tests/auto/qml/qqmlecmascript/data/jsimport/importPragmaLibraryWithPragmaLibraryImports.js b/tests/auto/qml/qqmlecmascript/data/jsimport/importPragmaLibraryWithPragmaLibraryImports.js new file mode 100644 index 0000000000..fa6497d99b --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/jsimport/importPragmaLibraryWithPragmaLibraryImports.js @@ -0,0 +1,11 @@ +.pragma library +.import "importPragmaLibrary.js" as LibraryImport + +var i = 10; + +function importIncrementedValue() { + i = i + 1; + // because LibraryImport is shared, and used in previous tests, + // the value will be large (already incremented a bunch of times). + return (i + LibraryImport.importIncrementedValue()); +} diff --git a/tests/auto/qml/qqmlecmascript/data/jsimport/importThree.js b/tests/auto/qml/qqmlecmascript/data/jsimport/importThree.js new file mode 100644 index 0000000000..3917134ee2 --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/jsimport/importThree.js @@ -0,0 +1,9 @@ +.import "importFour.js" as ImportFourJs + +function greetingString() { + return ImportFourJs.greetingString(); +} + +function importThreeFunction() { + return '3'; +} diff --git a/tests/auto/qml/qqmlecmascript/data/jsimport/importTwo.js b/tests/auto/qml/qqmlecmascript/data/jsimport/importTwo.js new file mode 100644 index 0000000000..45b3c9a74d --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/jsimport/importTwo.js @@ -0,0 +1,10 @@ +.import "importFour.js" as ImportFourJs +.import "importFive.js" as ImportFiveJs + +function greetingString() { + return ImportFourJs.greetingString(); +} + +function importTwoFunction() { + return '2'; +} diff --git a/tests/auto/qml/qqmlecmascript/data/jsimport/importWithNoImports.js b/tests/auto/qml/qqmlecmascript/data/jsimport/importWithNoImports.js new file mode 100644 index 0000000000..83426c425c --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/jsimport/importWithNoImports.js @@ -0,0 +1,11 @@ +// This js file has no imports, and so should inherit +// scope from the QML file which includes it. + +function componentError() { + var i = 5; + var errorIsOne = Component.error == 1; + if (errorIsOne == true) { + i = i + 7; + } + return i; +} diff --git a/tests/auto/qml/qqmlecmascript/data/jsimport/testImport.qml b/tests/auto/qml/qqmlecmascript/data/jsimport/testImport.qml new file mode 100644 index 0000000000..456a10c7f0 --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/jsimport/testImport.qml @@ -0,0 +1,14 @@ +import QtQuick 2.0 + +import "testScriptImport.js" as TestScriptImport +import "testModuleImport.js" as TestModuleImport + +QtObject { + id: testQtObject + + property string importedScriptStringValue: TestScriptImport.greetingText + property int importedScriptFunctionValue: TestScriptImport.randomInteger(1, 20) + + property int importedModuleAttachedPropertyValue: TestModuleImport.importedAttachedPropertyValue(testQtObject) + property int importedModuleEnumValue: TestModuleImport.importedEnumValue +} diff --git a/tests/auto/qml/qqmlecmascript/data/jsimport/testImportPragmaLibrary.qml b/tests/auto/qml/qqmlecmascript/data/jsimport/testImportPragmaLibrary.qml new file mode 100644 index 0000000000..29de15c197 --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/jsimport/testImportPragmaLibrary.qml @@ -0,0 +1,20 @@ +import QtQuick 2.0 + +// We use the components specified in SpecialRectangleOne.qml and SpecialRectangleTwo.qml + +QtObject { + id: testQtObject + + property SpecialRectangleOne a; + property SpecialRectangleTwo b; + + a: SpecialRectangleOne { + id: rectangleOne + } + b: SpecialRectangleTwo { + id: rectangleTwo + } + + // this should be: (5 + 15) + (6 + 5) == 31 + property int testValue: rectangleOne.height + rectangleTwo.height +} diff --git a/tests/auto/qml/qqmlecmascript/data/jsimport/testImportPragmaLibraryWithImports.qml b/tests/auto/qml/qqmlecmascript/data/jsimport/testImportPragmaLibraryWithImports.qml new file mode 100644 index 0000000000..6a7459d3bb --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/jsimport/testImportPragmaLibraryWithImports.qml @@ -0,0 +1,7 @@ +import QtQuick 2.0 +import "importPragmaLibraryWithImports.js" as LibraryImport + +QtObject { + id: root + property int testValue: LibraryImport.importIncrementedValue(); // valueOf(4 + 1 + '5') = valueOf('55') = 55 +} diff --git a/tests/auto/qml/qqmlecmascript/data/jsimport/testImportPragmaLibraryWithPragmaLibraryImports.qml b/tests/auto/qml/qqmlecmascript/data/jsimport/testImportPragmaLibraryWithPragmaLibraryImports.qml new file mode 100644 index 0000000000..01f08dbdc3 --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/jsimport/testImportPragmaLibraryWithPragmaLibraryImports.qml @@ -0,0 +1,7 @@ +import QtQuick 2.0 +import "importPragmaLibraryWithPragmaLibraryImports.js" as LibraryImport + +QtObject { + id: root + property int testValue: LibraryImport.importIncrementedValue(); // 10 + 1 + (7 due to previous tests) = 18 +} diff --git a/tests/auto/qml/qqmlecmascript/data/jsimport/testImportScoping.qml b/tests/auto/qml/qqmlecmascript/data/jsimport/testImportScoping.qml new file mode 100644 index 0000000000..aff61cc436 --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/jsimport/testImportScoping.qml @@ -0,0 +1,11 @@ +import QtQuick 2.0 + +// For backward compatibility, importing a script which has no imports, +// should run the script in the parent context. See QTBUG-17518. + +import "importWithNoImports.js" as TestNoImportScoping + +QtObject { + id: testQtObject + property int componentError: TestNoImportScoping.componentError() +} diff --git a/tests/auto/qml/qqmlecmascript/data/jsimport/testModuleImport.js b/tests/auto/qml/qqmlecmascript/data/jsimport/testModuleImport.js new file mode 100644 index 0000000000..69bc1c9887 --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/jsimport/testModuleImport.js @@ -0,0 +1,8 @@ +.import Qt.test 1.0 as JsQtTest // test that we can import elements from .js files + +function importedAttachedPropertyValue(obj) { + return obj.JsQtTest.MyQmlObject.value; // attached property, value = 19. +} + +var importedEnumValue = JsQtTest.MyQmlObject.EnumValue3 // the actual value of this enum value is "2" + diff --git a/tests/auto/qml/qqmlecmascript/data/jsimport/testScriptImport.js b/tests/auto/qml/qqmlecmascript/data/jsimport/testScriptImport.js new file mode 100644 index 0000000000..2ecccd8816 --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/jsimport/testScriptImport.js @@ -0,0 +1,11 @@ +.import "importOne.js" as ImportOneJs // test that we can import scripts from .js files + +var greetingText = ImportOneJs.greetingString() + +function randomInteger(min, max) { + if (max > min) { + if (min > 10) return min; + return max; + } + return min; +} diff --git a/tests/auto/qml/qqmlecmascript/data/jsimportfail/failFive.qml b/tests/auto/qml/qqmlecmascript/data/jsimportfail/failFive.qml new file mode 100644 index 0000000000..73193a35a5 --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/jsimportfail/failFive.qml @@ -0,0 +1,11 @@ +import QtQuick 2.0 + +// This should fail, since if the script does have imports +// of its own, it should run in its own context. + +import "importWithImports.js" as TestImportScoping + +QtObject { + id: testQtObject + property int componentError: TestImportScoping.componentError() +} diff --git a/tests/auto/qml/qqmlecmascript/data/jsimportfail/failFour.qml b/tests/auto/qml/qqmlecmascript/data/jsimportfail/failFour.qml new file mode 100644 index 0000000000..ef2fc591b3 --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/jsimportfail/failFour.qml @@ -0,0 +1,7 @@ +import QtQuick 2.0 + +import "testModuleImport.js" as TestModuleImport + +QtObject { + property int importedModuleEnumValue: JsQtTest.MyQmlObject.EnumValue3 // should fail - the typenames available in TestModuleImport should not be available in this scope +} diff --git a/tests/auto/qml/qqmlecmascript/data/jsimportfail/failOne.qml b/tests/auto/qml/qqmlecmascript/data/jsimportfail/failOne.qml new file mode 100644 index 0000000000..d0c37ad9ba --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/jsimportfail/failOne.qml @@ -0,0 +1,7 @@ +import QtQuick 2.0 + +import "testScriptImport.js" as TestScriptImport + +QtObject { + property string importScriptFunctionValue: TestScriptImport.ImportOneJs.greetingString() // should fail - the context of TestScriptImport is private to TestScriptImport. +} diff --git a/tests/auto/qml/qqmlecmascript/data/jsimportfail/failThree.qml b/tests/auto/qml/qqmlecmascript/data/jsimportfail/failThree.qml new file mode 100644 index 0000000000..edd103bd82 --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/jsimportfail/failThree.qml @@ -0,0 +1,8 @@ +import QtQuick 2.0 + +import "testModuleImport.js" as TestModuleImport + +QtObject { + id: testQtObject + property int importedModuleAttachedPropertyValue: testQtObject.TestModuleImport.JsQtTest.MyQmlObject.value // should fail - the context of TestScriptImport is private to TestScriptImport. +} diff --git a/tests/auto/qml/qqmlecmascript/data/jsimportfail/failTwo.qml b/tests/auto/qml/qqmlecmascript/data/jsimportfail/failTwo.qml new file mode 100644 index 0000000000..28e2026f8d --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/jsimportfail/failTwo.qml @@ -0,0 +1,7 @@ +import QtQuick 2.0 + +import "testScriptImport.js" as TestScriptImport + +QtObject { + property string importScriptFunctionValue: ImportOneJs.greetingString() // should fail - the typenames in TestScriptImport should not be visible from this scope +} diff --git a/tests/auto/qml/qqmlecmascript/data/jsimportfail/importOne.js b/tests/auto/qml/qqmlecmascript/data/jsimportfail/importOne.js new file mode 100644 index 0000000000..45fd9c75dd --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/jsimportfail/importOne.js @@ -0,0 +1,7 @@ +function greetingString() { + return 'Hello, World!'; +} + +function importOneFunction() { + return '1'; +} diff --git a/tests/auto/qml/qqmlecmascript/data/jsimportfail/importPragmaLibrary.js b/tests/auto/qml/qqmlecmascript/data/jsimportfail/importPragmaLibrary.js new file mode 100644 index 0000000000..ad0e6946a2 --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/jsimportfail/importPragmaLibrary.js @@ -0,0 +1,11 @@ +.pragma library + +// .pragma library, so shouldn't inherit imports from any .qml file. +function importValue() { + var i = 3; + var errorIsOne = Component.error == 1; // this line should fail. + if (errorIsOne == true) { + i = i + 4; + } + return i; +} diff --git a/tests/auto/qml/qqmlecmascript/data/jsimportfail/importWithImports.js b/tests/auto/qml/qqmlecmascript/data/jsimportfail/importWithImports.js new file mode 100644 index 0000000000..6d77ceccb1 --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/jsimportfail/importWithImports.js @@ -0,0 +1,13 @@ +.import "importOne.js" as ImportOne + +// This js file has imports, so should not inherit +// scope from the QML file which includes it. + +function componentError() { + var i = 3; + var errorIsOne = Component.error == 1; // this line should fail. + if (errorIsOne == true) { + i = i + 4; + } + return i; +} diff --git a/tests/auto/qml/qqmlecmascript/data/jsimportfail/testImportPragmaLibrary.qml b/tests/auto/qml/qqmlecmascript/data/jsimportfail/testImportPragmaLibrary.qml new file mode 100644 index 0000000000..f04ce007d8 --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/jsimportfail/testImportPragmaLibrary.qml @@ -0,0 +1,8 @@ +import QtQuick 2.0 + +import "importPragmaLibrary.js" as ImportPragmaLibrary + +QtObject { + id: testQtObject + property int testValue: ImportPragmaLibrary.importValue() +} diff --git a/tests/auto/qml/qqmlecmascript/data/jsimportfail/testModuleImport.js b/tests/auto/qml/qqmlecmascript/data/jsimportfail/testModuleImport.js new file mode 100644 index 0000000000..69bc1c9887 --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/jsimportfail/testModuleImport.js @@ -0,0 +1,8 @@ +.import Qt.test 1.0 as JsQtTest // test that we can import elements from .js files + +function importedAttachedPropertyValue(obj) { + return obj.JsQtTest.MyQmlObject.value; // attached property, value = 19. +} + +var importedEnumValue = JsQtTest.MyQmlObject.EnumValue3 // the actual value of this enum value is "2" + diff --git a/tests/auto/qml/qqmlecmascript/data/jsimportfail/testScriptImport.js b/tests/auto/qml/qqmlecmascript/data/jsimportfail/testScriptImport.js new file mode 100644 index 0000000000..2ecccd8816 --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/jsimportfail/testScriptImport.js @@ -0,0 +1,11 @@ +.import "importOne.js" as ImportOneJs // test that we can import scripts from .js files + +var greetingText = ImportOneJs.greetingString() + +function randomInteger(min, max) { + if (max > min) { + if (min > 10) return min; + return max; + } + return min; +} diff --git a/tests/auto/qml/qqmlecmascript/data/libraryScriptAssert.js b/tests/auto/qml/qqmlecmascript/data/libraryScriptAssert.js new file mode 100644 index 0000000000..3ffdb339ad --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/libraryScriptAssert.js @@ -0,0 +1,6 @@ +.pragma library + +function test(target) +{ + var a = target.a; +} diff --git a/tests/auto/qml/qqmlecmascript/data/libraryScriptAssert.qml b/tests/auto/qml/qqmlecmascript/data/libraryScriptAssert.qml new file mode 100644 index 0000000000..5884e2719b --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/libraryScriptAssert.qml @@ -0,0 +1,7 @@ +import QtQuick 2.0 +import "libraryScriptAssert.js" as Test + +QtObject { + id: root + Component.onCompleted: Test.test(root); +} diff --git a/tests/auto/qml/qqmlecmascript/data/listAssignment.qml b/tests/auto/qml/qqmlecmascript/data/listAssignment.qml new file mode 100644 index 0000000000..6e6039715b --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/listAssignment.qml @@ -0,0 +1,20 @@ +import QtQuick 2.0 +import Qt.test 1.0 + +Item { + id: root + width: 640 + height: 480 + + property int list1length: list1.length + + property list list1 + property list list2: [ + MyQmlObject { id: one; value: 100 }, + MyQmlObject { id: two; value: 300 } + ] + + Component.onCompleted: { + root.list1 = root.list2; + } +} diff --git a/tests/auto/qml/qqmlecmascript/data/listProperties.qml b/tests/auto/qml/qqmlecmascript/data/listProperties.qml new file mode 100644 index 0000000000..bdb1265a21 --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/listProperties.qml @@ -0,0 +1,24 @@ +import Qt.test 1.0 +import QtQuick 2.0 + +MyQmlObject { + id: root + + objectListProperty: [ + QtObject { property int a: 10 }, + QtObject { property int a: 11 } + ] + + function calcTest1() { + var rv = 0; + for (var ii = 0; ii < root.objectListProperty.length; ++ii) { + rv += root.objectListProperty[ii].a; + } + return rv; + } + + property int test1: calcTest1(); + property int test2: root.objectListProperty.length + property bool test3: root.objectListProperty[1] != undefined + property bool test4: root.objectListProperty[100] == undefined +} diff --git a/tests/auto/qml/qqmlecmascript/data/listToVariant.qml b/tests/auto/qml/qqmlecmascript/data/listToVariant.qml new file mode 100644 index 0000000000..690024b928 --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/listToVariant.qml @@ -0,0 +1,5 @@ +import QtQuick 2.0 + +QtObject { + property variant test: children +} diff --git a/tests/auto/qml/qqmlecmascript/data/metaobjectRevision.qml b/tests/auto/qml/qqmlecmascript/data/metaobjectRevision.qml new file mode 100644 index 0000000000..77accd80de --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/metaobjectRevision.qml @@ -0,0 +1,7 @@ +import Qt.test 1.1 + +MyRevisionedClass +{ + prop1: prop2 + onSignal1: method2() +} diff --git a/tests/auto/qml/qqmlecmascript/data/metaobjectRevision2.qml b/tests/auto/qml/qqmlecmascript/data/metaobjectRevision2.qml new file mode 100644 index 0000000000..36057cb902 --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/metaobjectRevision2.qml @@ -0,0 +1,9 @@ +import Qt.test 1.1 + +MyRevisionedSubclass +{ + prop1: prop3 + onSignal1: method2() + prop3: prop4 + onSignal3: method4() +} diff --git a/tests/auto/qml/qqmlecmascript/data/metaobjectRevision3.qml b/tests/auto/qml/qqmlecmascript/data/metaobjectRevision3.qml new file mode 100644 index 0000000000..81769e98f7 --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/metaobjectRevision3.qml @@ -0,0 +1,8 @@ +import Qt.test 1.0 + +MyRevisionedSubclass +{ + prop1: prop3 + onSignal1: method1() + onSignal3: method3() +} diff --git a/tests/auto/qml/qqmlecmascript/data/metaobjectRevision4.qml b/tests/auto/qml/qqmlecmascript/data/metaobjectRevision4.qml new file mode 100644 index 0000000000..6ebe4790bb --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/metaobjectRevision4.qml @@ -0,0 +1,14 @@ +import Qt.test 1.1 +import QtQuick 2.0 + +QtObject { + property variant a + property real test + + a: MyRevisionedClass { + prop2: 11 + + Component.onCompleted: test = prop2 + } +} + diff --git a/tests/auto/qml/qqmlecmascript/data/metaobjectRevisionErrors.qml b/tests/auto/qml/qqmlecmascript/data/metaobjectRevisionErrors.qml new file mode 100644 index 0000000000..8a7e24d788 --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/metaobjectRevisionErrors.qml @@ -0,0 +1,14 @@ +import QtQuick 2.0 +import Qt.test 1.0 + +MyRevisionedClass +{ + // Will not hit optimizer + property real p1: prop1 % 3 + property real p2: prop2 % 3 + + // Should hit optimizer + property real p3: prop2 + + Component.onCompleted: method2() +} diff --git a/tests/auto/qml/qqmlecmascript/data/metaobjectRevisionErrors2.qml b/tests/auto/qml/qqmlecmascript/data/metaobjectRevisionErrors2.qml new file mode 100644 index 0000000000..43e87948cd --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/metaobjectRevisionErrors2.qml @@ -0,0 +1,24 @@ +import QtQuick 2.0 +import Qt.test 1.0 + +MyRevisionedSubclass +{ + // Will not hit optimizer + property real p1: prop1 % 3 + property real p2: prop2 % 3 + property real p3: prop3 % 3 + property real p4: prop4 % 3 + + // Should hit optimizer + property real p5: prop1 + property real p6: prop2 + property real p7: prop3 + property real p8: prop4 + + Component.onCompleted: { + method1() + method2() + method3() + method4() + } +} diff --git a/tests/auto/qml/qqmlecmascript/data/metaobjectRevisionErrors3.qml b/tests/auto/qml/qqmlecmascript/data/metaobjectRevisionErrors3.qml new file mode 100644 index 0000000000..2f82d685fa --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/metaobjectRevisionErrors3.qml @@ -0,0 +1,36 @@ +import QtQuick 2.0 +import Qt.test 1.1 + +MyRevisionedSubclass +{ + // Will not hit optimizer + property real pA: propA % 3 + property real pB: propB % 3 + property real pC: propC % 3 + property real pD: propD % 3 + property real p1: prop1 % 3 + property real p2: prop2 % 3 + property real p3: prop3 % 3 + property real p4: prop4 % 3 + + // Should hit optimizer + property real pE: propA + property real pF: propB + property real pG: propC + property real pH: propD + property real p5: prop1 + property real p6: prop2 + property real p7: prop3 + property real p8: prop4 + + Component.onCompleted: { + methodA() + methodB() + methodC() + methodD() + method1() + method2() + method3() + method4() + } +} diff --git a/tests/auto/qml/qqmlecmascript/data/methods.1.qml b/tests/auto/qml/qqmlecmascript/data/methods.1.qml new file mode 100644 index 0000000000..0bbee16df8 --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/methods.1.qml @@ -0,0 +1,6 @@ +import Qt.test 1.0 + +MyQmlObject { + id: myObject + onBasicSignal: myObject.methodNoArgs() +} diff --git a/tests/auto/qml/qqmlecmascript/data/methods.2.qml b/tests/auto/qml/qqmlecmascript/data/methods.2.qml new file mode 100644 index 0000000000..9f0c6b15fe --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/methods.2.qml @@ -0,0 +1,6 @@ +import Qt.test 1.0 + +MyQmlObject { + id: myObject + onBasicSignal: myObject.method(163) +} diff --git a/tests/auto/qml/qqmlecmascript/data/methods.3.qml b/tests/auto/qml/qqmlecmascript/data/methods.3.qml new file mode 100644 index 0000000000..365780a560 --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/methods.3.qml @@ -0,0 +1,7 @@ +import QtQuick 2.0 + +QtObject { + function testFunction() { return 19; } + + property int test: testFunction() +} diff --git a/tests/auto/qml/qqmlecmascript/data/methods.4.qml b/tests/auto/qml/qqmlecmascript/data/methods.4.qml new file mode 100644 index 0000000000..a3bd7bebf8 --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/methods.4.qml @@ -0,0 +1,11 @@ +import QtQuick 2.0 + +MethodsObject { + function testFunction2() { return 17; } + function testFunction3() { return 16; } + + property int test: testFunction() + property int test2: testFunction2() + property int test3: testFunction3() +} + diff --git a/tests/auto/qml/qqmlecmascript/data/methods.5.qml b/tests/auto/qml/qqmlecmascript/data/methods.5.qml new file mode 100644 index 0000000000..ede2759e2e --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/methods.5.qml @@ -0,0 +1,9 @@ +import QtQuick 2.0 + +Item { + property alias blah: item.x + Item { id: item } + + function testFunction() { return 9; } + property int test: testFunction(); +} diff --git a/tests/auto/qml/qqmlecmascript/data/moduleapi/moduleApiMajorVersionFail.qml b/tests/auto/qml/qqmlecmascript/data/moduleapi/moduleApiMajorVersionFail.qml new file mode 100644 index 0000000000..fb050f65bc --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/moduleapi/moduleApiMajorVersionFail.qml @@ -0,0 +1,10 @@ +import QtQuick 2.0 + +// this qml file attempts to import an invalid version of a qobject module API. + +import Qt.test.qobjectApi 4.0 as QtTestMajorVersionQObjectApi // qobject module API installed into existing uri with nonexistent major version + +QtObject { + property int qobjectMajorVersionTest: QtTestMajorVersionQObjectApi.qobjectTestProperty +} + diff --git a/tests/auto/qml/qqmlecmascript/data/moduleapi/moduleApiMinorVersionFail.qml b/tests/auto/qml/qqmlecmascript/data/moduleapi/moduleApiMinorVersionFail.qml new file mode 100644 index 0000000000..e06be667f7 --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/moduleapi/moduleApiMinorVersionFail.qml @@ -0,0 +1,10 @@ +import QtQuick 2.0 + +// this qml file attempts to import an invalid version of a qobject module API. + +import Qt.test.qobjectApi 1.2 as QtTestMinorVersionQObjectApi // qobject module API installed into existing uri with nonexistent minor version + +QtObject { + property int qobjectMinorVersionTest: QtTestMinorVersionedQObjectApi.qobjectTestProperty +} + diff --git a/tests/auto/qml/qqmlecmascript/data/moduleapi/qobjectModuleApi.qml b/tests/auto/qml/qqmlecmascript/data/moduleapi/qobjectModuleApi.qml new file mode 100644 index 0000000000..718a64652d --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/moduleapi/qobjectModuleApi.qml @@ -0,0 +1,21 @@ +import QtQuick 2.0 + +import Qt.test 1.0 as QtTest // module API installed into existing uri +import Qt.test.qobjectApi 1.0 as QtTestQObjectApi // qobject module API installed into new uri +import Qt.test.qobjectApi 1.3 as QtTestMinorVersionQObjectApi // qobject module API installed into existing uri with new minor version +import Qt.test.qobjectApi 2.0 as QtTestMajorVersionQObjectApi // qobject module API installed into existing uri with new major version +import Qt.test.qobjectApiParented 1.0 as QtTestParentedQObjectApi // qobject (with parent) module API installed into a new uri + +QtObject { + property int existingUriTest: QtTest.qobjectTestProperty + property int qobjectTest: QtTestQObjectApi.qobjectTestProperty + property int qobjectMethodTest: 2 + property int qobjectMinorVersionTest: QtTestMinorVersionQObjectApi.qobjectTestProperty + property int qobjectMajorVersionTest: QtTestMajorVersionQObjectApi.qobjectTestProperty + property int qobjectParentedTest: QtTestParentedQObjectApi.qobjectTestProperty + + Component.onCompleted: { + qobjectMethodTest = QtTestQObjectApi.qobjectTestMethod(); + } +} + diff --git a/tests/auto/qml/qqmlecmascript/data/moduleapi/qobjectModuleApiCaching.qml b/tests/auto/qml/qqmlecmascript/data/moduleapi/qobjectModuleApiCaching.qml new file mode 100644 index 0000000000..56a55e4e9b --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/moduleapi/qobjectModuleApiCaching.qml @@ -0,0 +1,10 @@ +import QtQuick 2.0 + +import Qt.test 1.0 as QtTest // module API installed into existing uri +import Qt.test.qobjectApiParented 1.0 as QtTestParentedQObjectApi // qobject (with parent) module API installed into a new uri + +QtObject { + property int existingUriTest: QtTest.qobjectTestProperty + property int qobjectParentedTest: QtTestParentedQObjectApi.qobjectTestProperty +} + diff --git a/tests/auto/qml/qqmlecmascript/data/moduleapi/qobjectModuleApiEnums.qml b/tests/auto/qml/qqmlecmascript/data/moduleapi/qobjectModuleApiEnums.qml new file mode 100644 index 0000000000..da5ffd5e76 --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/moduleapi/qobjectModuleApiEnums.qml @@ -0,0 +1,8 @@ +import QtQuick 2.0 +import Qt.test.qobjectApi 1.0 as QtTestQObjectApi // qobject module API installed into new uri + +QtObject { + property int enumValue: QtTestQObjectApi.EnumValue2; + property int enumMethod: QtTestQObjectApi.qobjectEnumTestMethod(QtTestQObjectApi.EnumValue1); +} + diff --git a/tests/auto/qml/qqmlecmascript/data/moduleapi/qobjectModuleApiWriting.qml b/tests/auto/qml/qqmlecmascript/data/moduleapi/qobjectModuleApiWriting.qml new file mode 100644 index 0000000000..be647ca57f --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/moduleapi/qobjectModuleApiWriting.qml @@ -0,0 +1,26 @@ +import QtQuick 2.0 +import Qt.test 1.0 as QtTest // qobject module API installed into existing uri + +QtObject { + property int firstProperty: 1 + property int secondProperty: 2 + property int readOnlyProperty: QtTest.qobjectTestProperty + property int writableProperty: QtTest.qobjectTestWritableProperty + + onFirstPropertyChanged: { + // In this case, we want to attempt to set the module API property. + // This should fail, as the module API property is read only. + if (firstProperty != QtTest.qobjectTestProperty) { + QtTest.qobjectTestProperty = firstProperty; // should silently fail. + } + } + + onSecondPropertyChanged: { + // In this case, we want to attempt to set the module API property. + // This should succeed, as the module API property is writable. + if (secondProperty != QtTest.qobjectTestWritableProperty) { + QtTest.qobjectTestWritableProperty = secondProperty; // should succeed. + } + } +} + diff --git a/tests/auto/qml/qqmlecmascript/data/moduleapi/scriptModuleApi.qml b/tests/auto/qml/qqmlecmascript/data/moduleapi/scriptModuleApi.qml new file mode 100644 index 0000000000..7c4e20489d --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/moduleapi/scriptModuleApi.qml @@ -0,0 +1,6 @@ +import QtQuick 2.0 +import Qt.test.scriptApi 1.0 as QtTestScriptApi // script module API installed into new uri + +QtObject { + property int scriptTest: QtTestScriptApi.scriptTestProperty // script module api's only provide properties. +} diff --git a/tests/auto/qml/qqmlecmascript/data/moduleapi/scriptModuleApiCaching.qml b/tests/auto/qml/qqmlecmascript/data/moduleapi/scriptModuleApiCaching.qml new file mode 100644 index 0000000000..90974b5969 --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/moduleapi/scriptModuleApiCaching.qml @@ -0,0 +1,6 @@ +import QtQuick 2.0 +import Qt.test.scriptApi 1.0 as QtTestScriptApi // script module API installed into new uri + +QtObject { + property int scriptTest: QtTestScriptApi.scriptTestProperty +} diff --git a/tests/auto/qml/qqmlecmascript/data/moduleapi/scriptModuleApiWriting.qml b/tests/auto/qml/qqmlecmascript/data/moduleapi/scriptModuleApiWriting.qml new file mode 100644 index 0000000000..02461d59ed --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/moduleapi/scriptModuleApiWriting.qml @@ -0,0 +1,32 @@ +import QtQuick 2.0 +import Qt.test.scriptApi 1.0 as QtTestScriptApi +import Qt.test.scriptApi 2.0 as QtTestScriptApi2 + +QtObject { + property int firstProperty + property int readBack + + property int secondProperty + property int unchanged + + onFirstPropertyChanged: { + if (QtTestScriptApi.scriptTestProperty != firstProperty) { + QtTestScriptApi.scriptTestProperty = firstProperty; + readBack = QtTestScriptApi.scriptTestProperty; + } + } + + onSecondPropertyChanged: { + if (QtTestScriptApi2.scriptTestProperty != secondProperty) { + QtTestScriptApi2.scriptTestProperty = secondProperty; + unchanged = QtTestScriptApi2.scriptTestProperty; + } + } + + Component.onCompleted: { + firstProperty = QtTestScriptApi.scriptTestProperty; + readBack = QtTestScriptApi.scriptTestProperty; + secondProperty = QtTestScriptApi2.scriptTestProperty; + unchanged = QtTestScriptApi2.scriptTestProperty; + } +} diff --git a/tests/auto/qml/qqmlecmascript/data/multiEngineObject.qml b/tests/auto/qml/qqmlecmascript/data/multiEngineObject.qml new file mode 100644 index 0000000000..e349ced98f --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/multiEngineObject.qml @@ -0,0 +1,5 @@ +import QtQuick 2.0 + +QtObject { + property string test: thing.stringProperty +} diff --git a/tests/auto/qml/qqmlecmascript/data/noSpuriousWarningsAtShutdown.2.qml b/tests/auto/qml/qqmlecmascript/data/noSpuriousWarningsAtShutdown.2.qml new file mode 100644 index 0000000000..23276f778d --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/noSpuriousWarningsAtShutdown.2.qml @@ -0,0 +1,10 @@ +import QtQuick 2.0 + +Item { + id: root + + Item {} + + SpuriousWarning {} +} + diff --git a/tests/auto/qml/qqmlecmascript/data/noSpuriousWarningsAtShutdown.qml b/tests/auto/qml/qqmlecmascript/data/noSpuriousWarningsAtShutdown.qml new file mode 100644 index 0000000000..b4a417e04e --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/noSpuriousWarningsAtShutdown.qml @@ -0,0 +1,9 @@ +import QtQuick 2.0 + +Item { + id: root + + property int childrenCount: root.children.length + + Item {} +} diff --git a/tests/auto/qml/qqmlecmascript/data/nonExistentAttachedObject.qml b/tests/auto/qml/qqmlecmascript/data/nonExistentAttachedObject.qml new file mode 100644 index 0000000000..f9585db009 --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/nonExistentAttachedObject.qml @@ -0,0 +1,5 @@ +import Qt.test 1.0 + +MyQmlObject { + stringProperty: MyQmlContainer.prop +} diff --git a/tests/auto/qml/qqmlecmascript/data/nonNotifyable.qml b/tests/auto/qml/qqmlecmascript/data/nonNotifyable.qml new file mode 100644 index 0000000000..2b8b113c34 --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/nonNotifyable.qml @@ -0,0 +1,6 @@ +import Qt.test 1.0 + +MyQmlObject { + id: root + property int test: root.value +} diff --git a/tests/auto/qml/qqmlecmascript/data/nonscriptable.qml b/tests/auto/qml/qqmlecmascript/data/nonscriptable.qml new file mode 100644 index 0000000000..e96df6b40e --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/nonscriptable.qml @@ -0,0 +1,19 @@ +import Qt.test 1.0 +import QtQuick 2.0 + +MyQmlObject { + id: root + + property bool readOk: false; + property bool writeOk: false + + Component.onCompleted: { + readOk = (root.nonscriptable == undefined); + + try { + root.nonscriptable = 10 + } catch (e) { + writeOk = true; + } + } +} diff --git a/tests/auto/qml/qqmlecmascript/data/nullObjectBinding.qml b/tests/auto/qml/qqmlecmascript/data/nullObjectBinding.qml new file mode 100644 index 0000000000..1aee7a1670 --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/nullObjectBinding.qml @@ -0,0 +1,8 @@ +import QtQuick 2.0 + +QtObject { + property QtObject test + test: if (1) model + property ListModel model +} + diff --git a/tests/auto/qml/qqmlecmascript/data/numberAssignment.qml b/tests/auto/qml/qqmlecmascript/data/numberAssignment.qml new file mode 100644 index 0000000000..30a77e8aed --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/numberAssignment.qml @@ -0,0 +1,18 @@ +import Qt.test 1.0 + +NumberAssignment { + test1: if (1) 6.7 + test2: if (1) "6.7" + test3: if (1) 6 + test4: if (1) "6" + + test5: if (1) 6.7 + test6: if (1) "6.7" + test7: if (1) 6 + test8: if (1) "6" + + test9: if (1) 6.7 + test10: if (1) "6.7" + test11: if (1) 6 + test12: if (1) "6" +} diff --git a/tests/auto/qml/qqmlecmascript/data/objectConversion.qml b/tests/auto/qml/qqmlecmascript/data/objectConversion.qml new file mode 100644 index 0000000000..67fc342db3 --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/objectConversion.qml @@ -0,0 +1,16 @@ +import QtQuick 2.0 + +Rectangle { + width: 360 + height: 360 + + function circularObject() { + var a = {} + var b = {} + + a.test = 100; + a.c = b; + b.c = a; + return a; + } +} diff --git a/tests/auto/qml/qqmlecmascript/data/objectName.qml b/tests/auto/qml/qqmlecmascript/data/objectName.qml new file mode 100644 index 0000000000..20b9ec2935 --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/objectName.qml @@ -0,0 +1,8 @@ +import QtQuick 2.0 + +QtObject { + objectName: "hello" + + property string test1: objectName + property string test2: objectName.substr(1, 3) +} diff --git a/tests/auto/qml/qqmlecmascript/data/objectsCompareAsEqual.qml b/tests/auto/qml/qqmlecmascript/data/objectsCompareAsEqual.qml new file mode 100644 index 0000000000..845f74b1aa --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/objectsCompareAsEqual.qml @@ -0,0 +1,15 @@ +import QtQuick 2.0 + +Item { + id: root + + property variant item: child + Item { id: child } + + property bool test1: child == child + property bool test2: child.parent == root + property bool test3: root != child + property bool test4: item == child + property bool test5: item != root +} + diff --git a/tests/auto/qml/qqmlecmascript/data/objectsPassThroughSignals.qml b/tests/auto/qml/qqmlecmascript/data/objectsPassThroughSignals.qml new file mode 100644 index 0000000000..98f9e05bdf --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/objectsPassThroughSignals.qml @@ -0,0 +1,18 @@ +import QtQuick 2.0 + +QtObject { + id: root + + property bool test: false + + signal mysignal(variant object); + function myslot(object) + { + test = (object == root); + } + + Component.onCompleted: { + mysignal.connect(this, myslot); + mysignal(root); + } +} diff --git a/tests/auto/qml/qqmlecmascript/data/outerBindingOverridesInnerBinding.qml b/tests/auto/qml/qqmlecmascript/data/outerBindingOverridesInnerBinding.qml new file mode 100644 index 0000000000..090c948f26 --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/outerBindingOverridesInnerBinding.qml @@ -0,0 +1,15 @@ +import Qt.test 1.0 + +MyQmlObject { + id: obj + property alias c1: myConstants.c1 + property alias c2: myConstants.c2 + property int c3: 0 + + objectProperty: ConstantsOverrideBindings { + id: myConstants + c2: obj.c3 + } + +} + diff --git a/tests/auto/qml/qqmlecmascript/data/ownership.qml b/tests/auto/qml/qqmlecmascript/data/ownership.qml new file mode 100644 index 0000000000..855a264995 --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/ownership.qml @@ -0,0 +1,5 @@ +import QtQuick 2.0 + +QtObject { + Component.onCompleted: { var a = getObject(); a = null; } +} diff --git a/tests/auto/qml/qqmlecmascript/data/propertyAssignmentErrors.qml b/tests/auto/qml/qqmlecmascript/data/propertyAssignmentErrors.qml new file mode 100644 index 0000000000..34523ec1c7 --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/propertyAssignmentErrors.qml @@ -0,0 +1,29 @@ +import QtQuick 2.0 + +QtObject { + id: root + + property int a + property variant b + + property bool test1: false; + property bool test2: false; + + Component.onCompleted: { + try { + root.a = undefined; + } catch(e) { + if (e.message == "Cannot assign [undefined] to int" && + e.stack.indexOf("propertyAssignmentErrors.qml:14") != -1) + root.test1 = true; + } + + try { + root.a = "Hello"; + } catch(e) { + if (e.message == "Cannot assign QString to int" && + e.stack.indexOf("propertyAssignmentErrors.qml:22") != -1) + root.test2 = true; + } + } +} diff --git a/tests/auto/qml/qqmlecmascript/data/propertySplicing.qml b/tests/auto/qml/qqmlecmascript/data/propertySplicing.qml new file mode 100644 index 0000000000..53711db3f4 --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/propertySplicing.qml @@ -0,0 +1,10 @@ +import Qt.test 1.0 +import QtQuick 2.0 + +MyDerivedObject { + property bool test: false + + Component.onCompleted: { + test = intProperty() + } +} diff --git a/tests/auto/qml/qqmlecmascript/data/propertyVar.1.qml b/tests/auto/qml/qqmlecmascript/data/propertyVar.1.qml new file mode 100644 index 0000000000..219e61bf91 --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/propertyVar.1.qml @@ -0,0 +1,22 @@ +import QtQuick 2.0 + +Item { + id: root + property bool test: false + + property var car: new vehicle(4); + property int wheelCount: car.wheels + + function vehicle(wheels) { + this.wheels = wheels; + } + + Component.onCompleted: { + car.wheels = 6; // not bindable, wheelCount shouldn't update + + if (car.wheels != 6) return; + if (wheelCount != 4) return; + + test = true; + } +} diff --git a/tests/auto/qml/qqmlecmascript/data/propertyVar.10.qml b/tests/auto/qml/qqmlecmascript/data/propertyVar.10.qml new file mode 100644 index 0000000000..ac7f2bed57 --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/propertyVar.10.qml @@ -0,0 +1,8 @@ +import QtQuick 2.0 + +PropertyVarBaseItem { + property bool test: false + Component.onCompleted: { + test = true; + } +} diff --git a/tests/auto/qml/qqmlecmascript/data/propertyVar.2.qml b/tests/auto/qml/qqmlecmascript/data/propertyVar.2.qml new file mode 100644 index 0000000000..2ac4807ec5 --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/propertyVar.2.qml @@ -0,0 +1,24 @@ +import QtQuick 2.0 + +Item { + id: root + property bool test: false + + property var truck: new vehicle(8); + property int wheelCount: truck.wheels + + function vehicle(wheels) { + this.wheels = wheels; + } + + Component.onCompleted: { + if (wheelCount != 8) return; + + // not bindable, but wheelCount will update because truck itself changed. + truck = new vehicle(12); + + if (wheelCount != 12) return; + + test = true; + } +} diff --git a/tests/auto/qml/qqmlecmascript/data/propertyVar.3.qml b/tests/auto/qml/qqmlecmascript/data/propertyVar.3.qml new file mode 100644 index 0000000000..cf6a651639 --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/propertyVar.3.qml @@ -0,0 +1,19 @@ +import QtQuick 2.0 + +Item { + id: root + property bool test: false + + property var jsint: 4 + property int bound: jsint + 5 + + Component.onCompleted: { + if (bound != 9) return; + + jsint = jsint + 1; + + if (bound != 10) return; + + test = true; + } +} diff --git a/tests/auto/qml/qqmlecmascript/data/propertyVar.4.qml b/tests/auto/qml/qqmlecmascript/data/propertyVar.4.qml new file mode 100644 index 0000000000..82fc225e71 --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/propertyVar.4.qml @@ -0,0 +1,18 @@ +import QtQuick 2.0 + +Item { + property bool test: false + + property var items: [1, 2, 3, "four", "five"] + property int bound: items[0] + + Component.onCompleted: { + if (bound != 1) return; + + items[0] = 10 // bound should remain 1 + + if (bound != 1) return; + + test = true; + } +} diff --git a/tests/auto/qml/qqmlecmascript/data/propertyVar.5.qml b/tests/auto/qml/qqmlecmascript/data/propertyVar.5.qml new file mode 100644 index 0000000000..a5c7812289 --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/propertyVar.5.qml @@ -0,0 +1,18 @@ +import QtQuick 2.0 + +Item { + property bool test: false + + property var attributes: { 'color': 'red', 'width': 100 } + property int bound: attributes.width + + Component.onCompleted: { + if (bound != 100) return; + + attributes.width = 200 // bound should remain 100 + + if (bound != 100) return; + + test = true; + } +} diff --git a/tests/auto/qml/qqmlecmascript/data/propertyVar.6.qml b/tests/auto/qml/qqmlecmascript/data/propertyVar.6.qml new file mode 100644 index 0000000000..060d24e7bc --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/propertyVar.6.qml @@ -0,0 +1,27 @@ +import QtQuick 2.0 + +Item { + property bool test: false + + property var items: [1, 2, 3, "four", "five"] + property int bound: items[0] + property var funcs: [(function() { return 6; })] + property int bound2: funcs[0]() + + function returnTwenty() { + return 20; + } + + Component.onCompleted: { + if (bound != 1) return false; + if (bound2 != 6) return false; + + items = [10, 2, 3, "four", "five"] // bound should now be 10 + funcs = [returnTwenty] // bound2 should now be 20 + + if (bound != 10) return false; + if (bound2 != 20) return false; + + test = true; + } +} diff --git a/tests/auto/qml/qqmlecmascript/data/propertyVar.7.qml b/tests/auto/qml/qqmlecmascript/data/propertyVar.7.qml new file mode 100644 index 0000000000..1d6c8c0a37 --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/propertyVar.7.qml @@ -0,0 +1,18 @@ +import QtQuick 2.0 + +Item { + property bool test: false + + property var attributes: { 'color': 'red', 'width': 100 } + property int bound: attributes.width + + Component.onCompleted: { + if (bound != 100) return; + + attributes = { 'color': 'blue', 'width': 200 } // bound should now be 200 + + if (bound != 200) return; + + test = true; + } +} diff --git a/tests/auto/qml/qqmlecmascript/data/propertyVar.8.qml b/tests/auto/qml/qqmlecmascript/data/propertyVar.8.qml new file mode 100644 index 0000000000..a9f73db402 --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/propertyVar.8.qml @@ -0,0 +1,12 @@ +import QtQuick 2.0 + +Item { + property bool test: false + + property var literalValue: 6 + + Component.onCompleted: { + if (literalValue != 6) return; + test = true; + } +} diff --git a/tests/auto/qml/qqmlecmascript/data/propertyVar.9.qml b/tests/auto/qml/qqmlecmascript/data/propertyVar.9.qml new file mode 100644 index 0000000000..f5aca28417 --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/propertyVar.9.qml @@ -0,0 +1,19 @@ +import QtQuick 2.0 +import Qt.test 1.0 + +Item { + property bool test: false + + MyQmlObject { + id: qmlobject + intProperty: 5 + } + property var qobjectVar: qmlobject + property int bound: qobjectVar.intProperty + + Component.onCompleted: { + if (bound != 5) return; + + test = true; + } +} diff --git a/tests/auto/qml/qqmlecmascript/data/propertyVar.circular.2.qml b/tests/auto/qml/qqmlecmascript/data/propertyVar.circular.2.qml new file mode 100644 index 0000000000..93c44afcc9 --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/propertyVar.circular.2.qml @@ -0,0 +1,26 @@ +import QtQuick 2.0 + +Item { + id: root + objectName: "separateRootObject" + property var vp + + function constructGarbage() { + var retn = 1; + var component = Qt.createComponent("PropertyVarCircularComponent3.qml"); + if (component.status == Component.Ready) { + retn = component.createObject(null); // has JavaScript ownership + } + return retn; + } + + function assignCircular() { + vp = constructGarbage(); + gc(); + } + + function deassignCircular() { + vp = 2; + gc(); + } +} diff --git a/tests/auto/qml/qqmlecmascript/data/propertyVar.circular.qml b/tests/auto/qml/qqmlecmascript/data/propertyVar.circular.qml new file mode 100644 index 0000000000..171d7747cd --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/propertyVar.circular.qml @@ -0,0 +1,44 @@ +import QtQuick 2.0 +import Qt.test 1.0 + +Item { + id: testCircular + + property var varProperty + property variant canaryResource + property int canaryInt + + function constructGarbage() { + var retn = 1; + var component = Qt.createComponent("PropertyVarCircularComponent.qml"); + if (component.status == Component.Ready) { + retn = component.createObject(null); // has JavaScript ownership + } + return retn; + } + + function deassignCanaryResource() { + canaryResource = 1; + gc(); + } + + function assignCircular() { + varProperty = constructGarbage(); + canaryResource = varProperty.vp.vp.vp.vp.memoryHog; + canaryInt = varProperty.vp.vp.vp.vp.fifthCanary; // == 5 + gc(); + } + + function deassignCircular() { + canaryInt = 2; + varProperty = 2; + gc(); + } + + function assignThenDeassign() { + varProperty = constructGarbage(); + varProperty = 2; + gc(); + } +} + diff --git a/tests/auto/qml/qqmlecmascript/data/propertyVar.inherit.qml b/tests/auto/qml/qqmlecmascript/data/propertyVar.inherit.qml new file mode 100644 index 0000000000..abd0dd7c04 --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/propertyVar.inherit.qml @@ -0,0 +1,34 @@ +import QtQuick 2.0 +import Qt.test 1.0 + +Item { + id: testInheritance + + property var varProperty + + function constructGarbage() { + var retn = 1; + var component = Qt.createComponent("PropertyVarInheritanceComponent.qml"); + if (component.status == Component.Ready) { + retn = component.createObject(null); // has JavaScript ownership + } + return retn; + } + + function assignCircular() { + varProperty = constructGarbage(); + gc(); + } + + function deassignCircular() { + varProperty = 2; + gc(); + } + + function assignThenDeassign() { + varProperty = constructGarbage(); + varProperty = 2; + gc(); + } +} + diff --git a/tests/auto/qml/qqmlecmascript/data/propertyVar.reparent.qml b/tests/auto/qml/qqmlecmascript/data/propertyVar.reparent.qml new file mode 100644 index 0000000000..7b3df674f1 --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/propertyVar.reparent.qml @@ -0,0 +1,27 @@ +import QtQuick 2.0 + +Item { + id: root + objectName: "separateRootObject" + property var vp + + function constructGarbage() { + var retn = 1; + var component = Qt.createComponent("PropertyVarOwnershipComponent.qml"); + if (component.status == Component.Ready) { + retn = component.createObject(null); // has JavaScript ownership + } + return retn; + } + + function assignVarProp() { + vp = constructGarbage(); + gc(); + } + + function deassignVarProp() { + vp = 2; + gc(); + } +} + diff --git a/tests/auto/qml/qqmlecmascript/data/propertyVarCpp.qml b/tests/auto/qml/qqmlecmascript/data/propertyVarCpp.qml new file mode 100644 index 0000000000..cd3147f565 --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/propertyVarCpp.qml @@ -0,0 +1,17 @@ +import QtQuick 2.0 +import Qt.test 1.0 + +Item { + id: testOwnership + property int intProperty: 10 + property var varProperty: intProperty + property var varProperty2: false + property var varBound: varProperty + 5 + property int intBound: varProperty + 5 + property var jsobject: new vehicle(4) + + function vehicle(wheels) { + this.wheels = wheels; + } +} + diff --git a/tests/auto/qml/qqmlecmascript/data/propertyVarImplicitOwnership.qml b/tests/auto/qml/qqmlecmascript/data/propertyVarImplicitOwnership.qml new file mode 100644 index 0000000000..9cebded932 --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/propertyVarImplicitOwnership.qml @@ -0,0 +1,26 @@ +import QtQuick 2.0 + +Item { + id: root + objectName: "separateRootObject" + property var vp + + function constructGarbage() { + var retn = 1; + var component = Qt.createComponent("PropertyVarCircularComponent4.qml"); + if (component.status == Component.Ready) { + retn = component.createObject(null); // has JavaScript ownership + } + return retn; + } + + function assignCircular() { + vp = constructGarbage(); + gc(); + } + + function deassignCircular() { + vp = 2; + gc(); + } +} diff --git a/tests/auto/qml/qqmlecmascript/data/propertyVarOwnership.2.qml b/tests/auto/qml/qqmlecmascript/data/propertyVarOwnership.2.qml new file mode 100644 index 0000000000..14d4f9fd27 --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/propertyVarOwnership.2.qml @@ -0,0 +1,24 @@ +import QtQuick 2.0 +import Qt.test 1.0 + +Item { + id: testOwnership + property bool test: false + + property int dummyProperty // Tests for non-interference of other properties + property var varProperty + + function runTest() { + if (varProperty != undefined) return; + varProperty = { a: 10, b: 11 } + if (varProperty.a != 10) return; + + gc(); // Shouldn't collect + + if (varProperty.a != 10) return; + + test = true; + } +} + + diff --git a/tests/auto/qml/qqmlecmascript/data/propertyVarOwnership.3.qml b/tests/auto/qml/qqmlecmascript/data/propertyVarOwnership.3.qml new file mode 100644 index 0000000000..d5b449c938 --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/propertyVarOwnership.3.qml @@ -0,0 +1,31 @@ +import QtQuick 2.0 + +Item { + property var object + + property bool test1: false + property bool test2: false + + // Test methods are executed in sequential order + + function runTest() { + var c = Qt.createComponent("propertyVarOwnership.3.type.qml"); + object = c.createObject(); + + if (object.dummy != 10) return; + test1 = true; + } + + // Run gc() from C++ + + function runTest2() { + if (object.dummy != 10) return; + + object = undefined; + if (object != undefined) return; + + test2 = true; + } + + // Run gc() from C++ - QObject should be collected +} diff --git a/tests/auto/qml/qqmlecmascript/data/propertyVarOwnership.3.type.qml b/tests/auto/qml/qqmlecmascript/data/propertyVarOwnership.3.type.qml new file mode 100644 index 0000000000..3406553b91 --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/propertyVarOwnership.3.type.qml @@ -0,0 +1,5 @@ +import QtQuick 2.0 + +QtObject { + property int dummy: 10 +} diff --git a/tests/auto/qml/qqmlecmascript/data/propertyVarOwnership.4.qml b/tests/auto/qml/qqmlecmascript/data/propertyVarOwnership.4.qml new file mode 100644 index 0000000000..1eba36ce81 --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/propertyVarOwnership.4.qml @@ -0,0 +1,25 @@ +import QtQuick 2.0 + +Item { + id: root + + property var object + + property bool test: false + + Component.onCompleted: { + var c = Qt.createComponent("propertyVarOwnership.4.type1.qml"); + object = c.createObject(); + + if (object.dummy != 10) return; + if (object.test != true) return; + + object.creatorRef = root; + + test = true; + } + + function runTest() { + object = null; + } +} diff --git a/tests/auto/qml/qqmlecmascript/data/propertyVarOwnership.4.type1.qml b/tests/auto/qml/qqmlecmascript/data/propertyVarOwnership.4.type1.qml new file mode 100644 index 0000000000..9a29b6e17f --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/propertyVarOwnership.4.type1.qml @@ -0,0 +1,23 @@ +import QtQuick 2.0 + +// Has a self reference in selfRef, and a reference to propertyVarOwnership.4.qml in creatorRef +Item { + id: root + + property var creatorRef + property var selfRef + property var object + + property int dummy: 10 + property bool test: false + + Component.onCompleted: { + selfRef = root; + + var c = Qt.createComponent("propertyVarOwnership.4.type2.qml"); + object = c.createObject(); + object.creatorRef = root; + + test = true; + } +} diff --git a/tests/auto/qml/qqmlecmascript/data/propertyVarOwnership.4.type2.qml b/tests/auto/qml/qqmlecmascript/data/propertyVarOwnership.4.type2.qml new file mode 100644 index 0000000000..f82b8a1c1e --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/propertyVarOwnership.4.type2.qml @@ -0,0 +1,6 @@ +import QtQuick 2.0 + +// Has a reference to propertyVarOwnership.4.type1.qml in creatorRef +Item { + property var creatorRef +} diff --git a/tests/auto/qml/qqmlecmascript/data/propertyVarOwnership.qml b/tests/auto/qml/qqmlecmascript/data/propertyVarOwnership.qml new file mode 100644 index 0000000000..7b99c4b6ad --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/propertyVarOwnership.qml @@ -0,0 +1,22 @@ +import QtQuick 2.0 +import Qt.test 1.0 + +Item { + id: testOwnership + property bool test: false + + property var varProperty + + function runTest() { + if (varProperty != undefined) return; + varProperty = { a: 10, b: 11 } + if (varProperty.a != 10) return; + + gc(); // Shouldn't collect + + if (varProperty.a != 10) return; + + test = true; + } +} + diff --git a/tests/auto/qml/qqmlecmascript/data/qlistqobjectMethods.qml b/tests/auto/qml/qqmlecmascript/data/qlistqobjectMethods.qml new file mode 100644 index 0000000000..3c1986d721 --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/qlistqobjectMethods.qml @@ -0,0 +1,6 @@ +import QtQuick 2.0 + +QtObject { + property int test: getObjects().length + property bool test2: getObjects()[0].trueProperty +} diff --git a/tests/auto/qml/qqmlecmascript/data/qmlHasOwnProperty.qml b/tests/auto/qml/qqmlecmascript/data/qmlHasOwnProperty.qml new file mode 100644 index 0000000000..12598b3b9f --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/qmlHasOwnProperty.qml @@ -0,0 +1,72 @@ +import QtQuick 2.0 +import Qt.test 1.0 +import Qt.test.qobjectApi 1.0 as QtTestQObjectApi + +Item { + id: obj + objectName: "objName" + property int someIntProperty: 10 + property bool result: false + + function testHasOwnPropertySuccess() + { + obj.result = obj.hasOwnProperty("someIntProperty"); + } + + function testHasOwnPropertyFailure() + { + obj.result = obj.hasOwnProperty("someNonexistentProperty"); + } + + MyTypeObject { + id: typeObj + objectName: "typeObj" + pointProperty: Qt.point(34, 29) + variantProperty: Qt.vector3d(1, 2, 3) + stringProperty: "test string" + property list listProperty: [ Rectangle { width: 10; height: 10 } ] + property list emptyListProperty + + property bool valueTypeHasOwnProperty + property bool valueTypeHasOwnProperty2 + property bool variantTypeHasOwnProperty + property bool stringTypeHasOwnProperty + property bool listTypeHasOwnProperty + property bool listAtValidHasOwnProperty + property bool emptyListTypeHasOwnProperty + property bool enumTypeHasOwnProperty + property bool typenameHasOwnProperty + property bool typenameHasOwnProperty2 + property bool moduleApiTypeHasOwnProperty + property bool moduleApiPropertyTypeHasOwnProperty + function testHasOwnPropertySuccess() { + valueTypeHasOwnProperty = !typeObj.pointProperty.hasOwnProperty("nonexistentpropertyname"); + valueTypeHasOwnProperty2 = typeObj.pointProperty.hasOwnProperty("x"); // should be true + variantTypeHasOwnProperty = !typeObj.variantProperty.hasOwnProperty("nonexistentpropertyname"); + stringTypeHasOwnProperty = !typeObj.stringProperty.hasOwnProperty("nonexistentpropertyname"); + listTypeHasOwnProperty = !typeObj.listProperty.hasOwnProperty("nonexistentpropertyname"); + listAtValidHasOwnProperty = !typeObj.listProperty[0].hasOwnProperty("nonexistentpropertyname"); + emptyListTypeHasOwnProperty = !typeObj.emptyListProperty.hasOwnProperty("nonexistentpropertyname"); + enumTypeHasOwnProperty = !MyTypeObject.EnumVal1.hasOwnProperty("nonexistentpropertyname"); + typenameHasOwnProperty = !MyTypeObject.hasOwnProperty("nonexistentpropertyname"); + typenameHasOwnProperty2 = MyTypeObject.hasOwnProperty("EnumVal1"); // should be true. + moduleApiTypeHasOwnProperty = !QtTestQObjectApi.hasOwnProperty("nonexistentpropertyname"); + moduleApiPropertyTypeHasOwnProperty = !QtTestQObjectApi.qobjectTestProperty.hasOwnProperty("nonexistentpropertyname"); + } + + property bool enumNonValueHasOwnProperty + function testHasOwnPropertyFailureOne() { + enumNonValueHasOwnProperty = !MyTypeObject.NonexistentEnumVal.hasOwnProperty("nonexistentpropertyname"); + } + + property bool moduleApiNonPropertyHasOwnProperty + function testHasOwnPropertyFailureTwo() { + moduleApiNonPropertyHasOwnProperty = !QtTestQObjectApi.someNonexistentProperty.hasOwnProperty("nonexistentpropertyname"); + } + + property bool listAtInvalidHasOwnProperty + function testHasOwnPropertyFailureThree() { + listAtInvalidHasOwnProperty = !typeObj.listProperty[5].hasOwnProperty("nonexistentpropertyname"); + } + } +} diff --git a/tests/auto/qml/qqmlecmascript/data/qmlToString.qml b/tests/auto/qml/qqmlecmascript/data/qmlToString.qml new file mode 100644 index 0000000000..ac296ce293 --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/qmlToString.qml @@ -0,0 +1,11 @@ +import Qt.test 1.0 + +MyQmlObject{ + id: obj + objectName: "objName" + function testToString() + { + obj.stringProperty = obj.toString(); + } + +} diff --git a/tests/auto/qml/qqmlecmascript/data/qobjectConnectionListExceptionHandling.qml b/tests/auto/qml/qqmlecmascript/data/qobjectConnectionListExceptionHandling.qml new file mode 100644 index 0000000000..acd512a2be --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/qobjectConnectionListExceptionHandling.qml @@ -0,0 +1,24 @@ +import QtQuick 2.0 + +Item { + id: root + property int first: 5 + property bool test: false + + Item { + id: exceptional + function exceptionalFunction() { + var obj = undefined; + var prop = undefined; + return obj[prop]; + } + } + + Component.onCompleted: { + root["firstChanged"].connect(exceptional.exceptionalFunction); + root["firstChanged"].connect(exceptional.exceptionalFunction); + root["firstChanged"].connect(exceptional.exceptionalFunction); + first = 6; + test = true; + } +} diff --git a/tests/auto/qml/qqmlecmascript/data/qobjectDerivedArgument.qml b/tests/auto/qml/qqmlecmascript/data/qobjectDerivedArgument.qml new file mode 100644 index 0000000000..bf4ab6fd7a --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/qobjectDerivedArgument.qml @@ -0,0 +1,17 @@ +import QtQuick 2.0 +import Qt.test 1.0 + +MyQmlObject { + id: root + stringProperty: 'hello' + property var child + + property bool result: false + + Component.onCompleted: { + child = invokable.createMyQmlObject('goodbye'); + + result = (invokable.getStringProperty(root) == 'hello') && + (invokable.getStringProperty(child) == 'goodbye'); + } +} diff --git a/tests/auto/qml/qqmlecmascript/data/qtbug_10696.qml b/tests/auto/qml/qqmlecmascript/data/qtbug_10696.qml new file mode 100644 index 0000000000..90263e5124 --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/qtbug_10696.qml @@ -0,0 +1,26 @@ +import QtQuick 2.0 + +QtObject { + property string test: "aaaa" + + "bbbb" + + "cccc" + + "cccc" + + "cccc" + + "cccc" + + "cccc" + + "cccc" + + "cccc" + + "cccc" + + "cccc" + + "cccc" + + "cccc" + + "cccc" + + "cccc" + + "cccc" + + "cccc" + + "cccc" + + "cccc" + + "cccc" + + "cccc" + + "cccc"; +} diff --git a/tests/auto/qml/qqmlecmascript/data/qtbug_11600.js b/tests/auto/qml/qqmlecmascript/data/qtbug_11600.js new file mode 100644 index 0000000000..092bc2b041 --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/qtbug_11600.js @@ -0,0 +1 @@ +; diff --git a/tests/auto/qml/qqmlecmascript/data/qtbug_11600.qml b/tests/auto/qml/qqmlecmascript/data/qtbug_11600.qml new file mode 100644 index 0000000000..6c7e8806e6 --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/qtbug_11600.qml @@ -0,0 +1,8 @@ +import QtQuick 2.0 +import "qtbug_11600.js" as Test + +QtObject { + id: goo + + property bool test: undefined == goo.Test +} diff --git a/tests/auto/qml/qqmlecmascript/data/qtbug_11606.qml b/tests/auto/qml/qqmlecmascript/data/qtbug_11606.qml new file mode 100644 index 0000000000..b1b062ed35 --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/qtbug_11606.qml @@ -0,0 +1,12 @@ +import QtQuick 2.0 + +QtObject { + property bool test: false + Component.onCompleted: { + try { + console.log(sorryNoSuchProperty); + } catch (e) { + test = true; + } + } +} diff --git a/tests/auto/qml/qqmlecmascript/data/qtbug_20344.qml b/tests/auto/qml/qqmlecmascript/data/qtbug_20344.qml new file mode 100644 index 0000000000..f490848caf --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/qtbug_20344.qml @@ -0,0 +1,6 @@ +import QtQuick 2.0 +import Qt.test 1.0 + +MyQmlObject { + Component.onCompleted: v8function() +} diff --git a/tests/auto/qml/qqmlecmascript/data/qtbug_21580.qml b/tests/auto/qml/qqmlecmascript/data/qtbug_21580.qml new file mode 100644 index 0000000000..dc0066ba3f --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/qtbug_21580.qml @@ -0,0 +1,22 @@ +import QtQuick 2.0 + +QtObject { + property bool test: false + + property list objects: [ + QtObject { + id: first + property alias myAlias: other.myProperty + onMyAliasChanged: if (myAlias == 20) test = true + }, + QtObject { + id: other + property real myProperty + } + ] + + Component.onCompleted: { + other.myProperty = 20; + } +} + diff --git a/tests/auto/qml/qqmlecmascript/data/qtbug_21864.js b/tests/auto/qml/qqmlecmascript/data/qtbug_21864.js new file mode 100644 index 0000000000..e1a688ebbe --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/qtbug_21864.js @@ -0,0 +1,2 @@ +var a = { b: 10 } +var test = (typeof a) == "object" diff --git a/tests/auto/qml/qqmlecmascript/data/qtbug_21864.qml b/tests/auto/qml/qqmlecmascript/data/qtbug_21864.qml new file mode 100644 index 0000000000..0f972d5459 --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/qtbug_21864.qml @@ -0,0 +1,6 @@ +import "qtbug_21864.js" as Test +import QtQuick 2.0 + +QtObject { + property bool test: Test.test +} diff --git a/tests/auto/qml/qqmlecmascript/data/qtbug_22464.qml b/tests/auto/qml/qqmlecmascript/data/qtbug_22464.qml new file mode 100644 index 0000000000..19f26736f1 --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/qtbug_22464.qml @@ -0,0 +1,15 @@ +import QtQuick 2.0 + +QtObject { + property alias value: inner.value + property bool test: false + + property variant dummy: QtObject { + id: inner + property variant value: Qt.rgba(1, 1, 0, 1); + } + + Component.onCompleted: { + test = (value == Qt.rgba(1, 1, 0, 1)); + } +} diff --git a/tests/auto/qml/qqmlecmascript/data/qtbug_22679.qml b/tests/auto/qml/qqmlecmascript/data/qtbug_22679.qml new file mode 100644 index 0000000000..b38a84b4c0 --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/qtbug_22679.qml @@ -0,0 +1,14 @@ +import QtQuick 2.0 + +QtObject { + function accessContextProperty() { + for (var i = 0; i < contextProp.stringProperty.length; ++i) ; + } + + Component.onCompleted: { + for (var i = 0; i < 1000; ++i) + accessContextProperty(); + // Shouldn't cause "Illegal invocation" error. + gc(); + } +} diff --git a/tests/auto/qml/qqmlecmascript/data/qtbug_22843.js b/tests/auto/qml/qqmlecmascript/data/qtbug_22843.js new file mode 100644 index 0000000000..6d19fe0571 --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/qtbug_22843.js @@ -0,0 +1,5 @@ + +function func() +{ + isFinite() ) +} diff --git a/tests/auto/qml/qqmlecmascript/data/qtbug_22843.library.js b/tests/auto/qml/qqmlecmascript/data/qtbug_22843.library.js new file mode 100644 index 0000000000..1a7c8a2e6e --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/qtbug_22843.library.js @@ -0,0 +1,5 @@ +.pragma library +function func() +{ + isFinite() ) +} diff --git a/tests/auto/qml/qqmlecmascript/data/qtbug_22843.library.qml b/tests/auto/qml/qqmlecmascript/data/qtbug_22843.library.qml new file mode 100644 index 0000000000..281765bff6 --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/qtbug_22843.library.qml @@ -0,0 +1,6 @@ +import "qtbug_22843.library.js" as MyScript +import QtQuick 2.0 + +QtObject { + Component.onCompleted: MyScript.func() +} diff --git a/tests/auto/qml/qqmlecmascript/data/qtbug_22843.qml b/tests/auto/qml/qqmlecmascript/data/qtbug_22843.qml new file mode 100644 index 0000000000..90a47c0f4b --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/qtbug_22843.qml @@ -0,0 +1,6 @@ +import "qtbug_22843.js" as MyScript +import QtQuick 2.0 + +QtObject { + Component.onCompleted: MyScript.func() +} diff --git a/tests/auto/qml/qqmlecmascript/data/qtbug_9792.qml b/tests/auto/qml/qqmlecmascript/data/qtbug_9792.qml new file mode 100644 index 0000000000..9ac44308c6 --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/qtbug_9792.qml @@ -0,0 +1,5 @@ +import Qt.test 1.0 + +MyQmlObject { + onBasicSignal: print("Hello world!"); +} diff --git a/tests/auto/qml/qqmlecmascript/data/qtcreatorbug_1289.qml b/tests/auto/qml/qqmlecmascript/data/qtcreatorbug_1289.qml new file mode 100644 index 0000000000..90711c8d09 --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/qtcreatorbug_1289.qml @@ -0,0 +1,13 @@ +import QtQuick 2.0 + +QtObject { + id: root + property QtObject object: QtObject { + id: nested + property QtObject nestedObject + } + + Component.onCompleted: { + nested.nestedObject = root; + } +} diff --git a/tests/auto/qml/qqmlecmascript/data/readonlyDeclaration.qml b/tests/auto/qml/qqmlecmascript/data/readonlyDeclaration.qml new file mode 100644 index 0000000000..5377d2dcbf --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/readonlyDeclaration.qml @@ -0,0 +1,45 @@ +import QtQuick 2.0 + +QtObject { + property int dummy: 13 + + readonly property int test1: 19 + readonly property int test2: dummy * 49 + readonly property alias test3: other.test + + property bool test: false + + property var dummyObj: QtObject { + id: other + property int test: 9 + } + + Component.onCompleted: { + if (test1 != 19) return; + if (test2 != 637) return; + if (test3 != 9) return; + + var caught = false; + + caught = false; + try { test1 = 13 } catch (e) { caught = true; } + if (!caught) return; + + caught = false; + try { test2 = 13 } catch (e) { caught = true; } + if (!caught) return; + + caught = false; + try { test3 = 13 } catch (e) { caught = true; } + if (!caught) return; + + other.test = 13; + dummy = 9; + + if (test1 != 19) return; + if (test2 != 441) return; + if (test3 != 13) return; + + test = true; + } +} diff --git a/tests/auto/qml/qqmlecmascript/data/realToInt.qml b/tests/auto/qml/qqmlecmascript/data/realToInt.qml new file mode 100644 index 0000000000..a9e7dd2a95 --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/realToInt.qml @@ -0,0 +1,11 @@ +import QtQuick 2.0 +import Qt.test 1.0 + +MyQmlObject { + function test1() { + value = 4.2 + } + function test2() { + value = 7.9 + } +} diff --git a/tests/auto/qml/qqmlecmascript/data/regExp.2.qml b/tests/auto/qml/qqmlecmascript/data/regExp.2.qml new file mode 100644 index 0000000000..68cca5733b --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/regExp.2.qml @@ -0,0 +1,7 @@ +import Qt.test 1.0 + +MyQmlObject{ + id: obj + objectName: "obj" + regExp: "[a-zA-z]" +} diff --git a/tests/auto/qml/qqmlecmascript/data/regExp.qml b/tests/auto/qml/qqmlecmascript/data/regExp.qml new file mode 100644 index 0000000000..0dc404b5db --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/regExp.qml @@ -0,0 +1,7 @@ +import Qt.test 1.0 + +MyQmlObject{ + id: obj + objectName: "obj" + regExp: /[a-zA-z]/ +} diff --git a/tests/auto/qml/qqmlecmascript/data/remote_file.js b/tests/auto/qml/qqmlecmascript/data/remote_file.js new file mode 100644 index 0000000000..1b123aee61 --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/remote_file.js @@ -0,0 +1,2 @@ +myvar = 13; +test5 = true; diff --git a/tests/auto/qml/qqmlecmascript/data/rewriteMultiLineStrings.qml b/tests/auto/qml/qqmlecmascript/data/rewriteMultiLineStrings.qml new file mode 100644 index 0000000000..1ae1b162b2 --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/rewriteMultiLineStrings.qml @@ -0,0 +1,35 @@ +import QtQuick 2.0 + +Item { + id: root; + property bool test: str == str2 && (txt != null && txt.str == root.str) + property Text txt: null + //Constant doesn't hit rewriter + property string str: 'same +multiline +string 5 !' + property string str2: ''; + Component { + id: comp + Text { + property var value: 1 + property string str: 'same +multiline +string ' + value + " !" + Component.onCompleted: { //Separate codepath for signal handers in rewriter + root.str2 = 'same +multiline +string ' + value + " !" + } + } + } + Component.onCompleted: txt = comp.createObject(root,{"value" : 5}) + /* + Timer { + interval: 1000 + running: true + repeat: true + onTriggered: console.debug( "Test: " + test + '\n' + str + '\n:\n' + str2 + "\n:\n" + txt.str) + } + */ +} diff --git a/tests/auto/qml/qqmlecmascript/data/scarceResourceCopy.var.qml b/tests/auto/qml/qqmlecmascript/data/scarceResourceCopy.var.qml new file mode 100644 index 0000000000..805655fc17 --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/scarceResourceCopy.var.qml @@ -0,0 +1,14 @@ +import QtQuick 2.0 +import Qt.test 1.0 + +// Here we import a scarce resource directly. +// The instance has a property which is a copy +// of the scarce resource, so it should not be +// detached (but we should automatically release +// the resource from our engine internal list). + +QtObject { + property MyScarceResourceObject a; + a: MyScarceResourceObject { id: scarceResourceProvider } + property var scarceResourceCopy: scarceResourceProvider.scarceResource +} \ No newline at end of file diff --git a/tests/auto/qml/qqmlecmascript/data/scarceResourceCopy.variant.qml b/tests/auto/qml/qqmlecmascript/data/scarceResourceCopy.variant.qml new file mode 100644 index 0000000000..ee5b05b28a --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/scarceResourceCopy.variant.qml @@ -0,0 +1,15 @@ +import QtQuick 2.0 +import Qt.test 1.0 + +// Here we import a scarce resource directly. +// The instance has a property which is a copy +// of the scarce resource, so it should not be +// detached (but we should automatically release +// the resource from our engine internal list). + +QtObject { + property MyScarceResourceObject a; + a: MyScarceResourceObject { id: scarceResourceProvider } + property variant scarceResourceCopy: scarceResourceProvider.scarceResource +} + diff --git a/tests/auto/qml/qqmlecmascript/data/scarceResourceCopyFromJs.var.qml b/tests/auto/qml/qqmlecmascript/data/scarceResourceCopyFromJs.var.qml new file mode 100644 index 0000000000..09868e5e7c --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/scarceResourceCopyFromJs.var.qml @@ -0,0 +1,14 @@ +import QtQuick 2.0 +import Qt.test 1.0 +import "scarceResourceTest.var.js" as ScarceResourceProviderJs + +// Here we import a scarce resource directly, from JS module. +// It is not preserved or released manually, so it should be +// automatically released once evaluation of the binding +// is complete. + +QtObject { + property MyScarceResourceObject a; + a: MyScarceResourceObject { id: scarceResourceProvider } + property var scarceResourceCopy: ScarceResourceProviderJs.importScarceResource(scarceResourceProvider) +} \ No newline at end of file diff --git a/tests/auto/qml/qqmlecmascript/data/scarceResourceCopyFromJs.variant.qml b/tests/auto/qml/qqmlecmascript/data/scarceResourceCopyFromJs.variant.qml new file mode 100644 index 0000000000..a1ebeb4073 --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/scarceResourceCopyFromJs.variant.qml @@ -0,0 +1,15 @@ +import QtQuick 2.0 +import Qt.test 1.0 +import "scarceResourceTest.variant.js" as ScarceResourceProviderJs + +// Here we import a scarce resource directly, from JS module. +// It is not preserved or released manually, so it should be +// automatically released once evaluation of the binding +// is complete. + +QtObject { + property MyScarceResourceObject a; + a: MyScarceResourceObject { id: scarceResourceProvider } + property variant scarceResourceCopy: ScarceResourceProviderJs.importScarceResource(scarceResourceProvider) +} + diff --git a/tests/auto/qml/qqmlecmascript/data/scarceResourceCopyImport.var.js b/tests/auto/qml/qqmlecmascript/data/scarceResourceCopyImport.var.js new file mode 100644 index 0000000000..468a6b4f2e --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/scarceResourceCopyImport.var.js @@ -0,0 +1,25 @@ +.import Qt.test 1.0 as JsQtTest + +// In this case, the "retn" variable will be evaluated during import. +// Since the "importScarceResource()" function depends on this variable, +// we must explicitly preserve the "retn" variable or the scarce +// resource would automatically be released after import completes +// but before the binding is evaluated. + +var component = Qt.createComponent("scarceResourceCopy.var.qml"); +var scarceResourceElement = component.createObject(null); +var scarceResourceProvider = scarceResourceElement.a; +var retn = scarceResourceProvider.scarceResource; +retn.preserve(); // must preserve manually or it will be released! + +function importScarceResource() { + // if called prior to calling destroyScarceResource(), + // this function should return the preserved scarce resource. + // otherwise, it should return an invalid variant. + return retn; +} + +function destroyScarceResource() { + retn.destroy(); +} + diff --git a/tests/auto/qml/qqmlecmascript/data/scarceResourceCopyImport.var.qml b/tests/auto/qml/qqmlecmascript/data/scarceResourceCopyImport.var.qml new file mode 100644 index 0000000000..9321481f45 --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/scarceResourceCopyImport.var.qml @@ -0,0 +1,18 @@ +import QtQuick 2.0 +import Qt.test 1.0 +import "scarceResourceCopyImport.var.js" as ScarceResourceCopyImportJs + +QtObject { + // this binding is evaluated once, prior to the resource being released + property var scarceResourceImportedCopy: ScarceResourceCopyImportJs.importScarceResource() + + property bool arePropertiesEqual + property var scarceResourceAssignedCopyOne; + property var scarceResourceAssignedCopyTwo; + Component.onCompleted: { + scarceResourceAssignedCopyOne = ScarceResourceCopyImportJs.importScarceResource(); + arePropertiesEqual = (scarceResourceAssignedCopyOne == scarceResourceImportedCopy); + ScarceResourceCopyImportJs.destroyScarceResource(); // makes all properties invalid. + scarceResourceAssignedCopyTwo = ScarceResourceCopyImportJs.importScarceResource(); + } +} \ No newline at end of file diff --git a/tests/auto/qml/qqmlecmascript/data/scarceResourceCopyImport.variant.js b/tests/auto/qml/qqmlecmascript/data/scarceResourceCopyImport.variant.js new file mode 100644 index 0000000000..9aeb507487 --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/scarceResourceCopyImport.variant.js @@ -0,0 +1,25 @@ +.import Qt.test 1.0 as JsQtTest + +// In this case, the "retn" variable will be evaluated during import. +// Since the "importScarceResource()" function depends on this variable, +// we must explicitly preserve the "retn" variable or the scarce +// resource would automatically be released after import completes +// but before the binding is evaluated. + +var component = Qt.createComponent("scarceResourceCopy.variant.qml"); +var scarceResourceElement = component.createObject(null); +var scarceResourceProvider = scarceResourceElement.a; +var retn = scarceResourceProvider.scarceResource; +retn.preserve(); // must preserve manually or it will be released! + +function importScarceResource() { + // if called prior to calling destroyScarceResource(), + // this function should return the preserved scarce resource. + // otherwise, it should return an invalid variant. + return retn; +} + +function destroyScarceResource() { + retn.destroy(); +} + diff --git a/tests/auto/qml/qqmlecmascript/data/scarceResourceCopyImport.variant.qml b/tests/auto/qml/qqmlecmascript/data/scarceResourceCopyImport.variant.qml new file mode 100644 index 0000000000..e8b53979dd --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/scarceResourceCopyImport.variant.qml @@ -0,0 +1,18 @@ +import QtQuick 2.0 +import Qt.test 1.0 +import "scarceResourceCopyImport.variant.js" as ScarceResourceCopyImportJs + +QtObject { + // this binding is evaluated once, prior to the resource being released + property variant scarceResourceImportedCopy: ScarceResourceCopyImportJs.importScarceResource() + + // this code is evaluated on completion, and so copy one should be valid, copy two invalid. + property variant scarceResourceAssignedCopyOne; + property variant scarceResourceAssignedCopyTwo; + Component.onCompleted: { + scarceResourceAssignedCopyOne = ScarceResourceCopyImportJs.importScarceResource(); + ScarceResourceCopyImportJs.destroyScarceResource(); + scarceResourceAssignedCopyTwo = ScarceResourceCopyImportJs.importScarceResource(); + } +} + diff --git a/tests/auto/qml/qqmlecmascript/data/scarceResourceCopyImportDifferent.var.js b/tests/auto/qml/qqmlecmascript/data/scarceResourceCopyImportDifferent.var.js new file mode 100644 index 0000000000..000eeddb34 --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/scarceResourceCopyImportDifferent.var.js @@ -0,0 +1,19 @@ +.import Qt.test 1.0 as JsQtTest + +// In this case, we create the returned scarce resource each call, +// so the object will be different every time it is returned. + +var mostRecent + +function importScarceResource() { + var component = Qt.createComponent("scarceResourceCopy.var.qml"); + var scarceResourceElement = component.createObject(null); + var scarceResourceProvider = scarceResourceElement.a; + var retn = scarceResourceProvider.scarceResource; + mostRecent = retn; + return retn; +} + +function destroyScarceResource() { + mostRecent.destroy(); +} \ No newline at end of file diff --git a/tests/auto/qml/qqmlecmascript/data/scarceResourceCopyImportDifferent.var.qml b/tests/auto/qml/qqmlecmascript/data/scarceResourceCopyImportDifferent.var.qml new file mode 100644 index 0000000000..082d132c24 --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/scarceResourceCopyImportDifferent.var.qml @@ -0,0 +1,22 @@ +import QtQuick 2.0 +import Qt.test 1.0 +import "scarceResourceCopyImportDifferent.var.js" as ScarceResourceCopyImportJs + +// in this case, the ScarceResourceCopyImportJs returns a _new_, different +// scarce resource each time. Invalidating one will not invalidate the others. + +QtObject { + // this binding is evaluated once, prior to the resource being released + property var scarceResourceImportedCopy: ScarceResourceCopyImportJs.importScarceResource() + + // the following properties are assigned on component completion. + property bool arePropertiesEqual + property var scarceResourceAssignedCopyOne; + property var scarceResourceAssignedCopyTwo; + Component.onCompleted: { + scarceResourceAssignedCopyOne = ScarceResourceCopyImportJs.importScarceResource(); + arePropertiesEqual = (scarceResourceAssignedCopyOne != scarceResourceImportedCopy); // they're not the same object. + ScarceResourceCopyImportJs.destroyScarceResource(); // makes the MOST RECENT resource invalid (ie, assignedCopyOne). + scarceResourceAssignedCopyTwo = ScarceResourceCopyImportJs.importScarceResource(); + } +} \ No newline at end of file diff --git a/tests/auto/qml/qqmlecmascript/data/scarceResourceCopyImportFail.var.js b/tests/auto/qml/qqmlecmascript/data/scarceResourceCopyImportFail.var.js new file mode 100644 index 0000000000..ba52b323f0 --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/scarceResourceCopyImportFail.var.js @@ -0,0 +1,19 @@ +.import Qt.test 1.0 as JsQtTest + +// In this case, the "retn" variable will be evaluated during import. +// Since the importScarceResource() function depends on this variable, +// because we DO NOT call "retn.preserve()", the scarce resource will +// be released after the import completes but prior to evaluation of +// any binding which calls "importScarceResource()". +// Thus, "importScarceResource()" will return a released (invalid) +// scarce resource. + +var component = Qt.createComponent("scarceResourceCopy.var.qml"); +var scarceResourceElement = component.createObject(null); +var scarceResourceProvider = scarceResourceElement.a; +var retn = scarceResourceProvider.scarceResource; + +function importScarceResource() { + return retn; // should return a released (invalid) scarce resource +} + diff --git a/tests/auto/qml/qqmlecmascript/data/scarceResourceCopyImportFail.var.qml b/tests/auto/qml/qqmlecmascript/data/scarceResourceCopyImportFail.var.qml new file mode 100644 index 0000000000..a1a3c1d66f --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/scarceResourceCopyImportFail.var.qml @@ -0,0 +1,7 @@ +import QtQuick 2.0 +import Qt.test 1.0 +import "scarceResourceCopyImportFail.var.js" as ScarceResourceCopyImportFailJs + +QtObject { + property var scarceResourceCopy: ScarceResourceCopyImportFailJs.importScarceResource() +} \ No newline at end of file diff --git a/tests/auto/qml/qqmlecmascript/data/scarceResourceCopyImportFail.variant.js b/tests/auto/qml/qqmlecmascript/data/scarceResourceCopyImportFail.variant.js new file mode 100644 index 0000000000..b59b5b1fa9 --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/scarceResourceCopyImportFail.variant.js @@ -0,0 +1,19 @@ +.import Qt.test 1.0 as JsQtTest + +// In this case, the "retn" variable will be evaluated during import. +// Since the importScarceResource() function depends on this variable, +// because we DO NOT call "retn.preserve()", the scarce resource will +// be released after the import completes but prior to evaluation of +// any binding which calls "importScarceResource()". +// Thus, "importScarceResource()" will return a released (invalid) +// scarce resource. + +var component = Qt.createComponent("scarceResourceCopy.variant.qml"); +var scarceResourceElement = component.createObject(null); +var scarceResourceProvider = scarceResourceElement.a; +var retn = scarceResourceProvider.scarceResource; + +function importScarceResource() { + return retn; // should return a released (invalid) scarce resource +} + diff --git a/tests/auto/qml/qqmlecmascript/data/scarceResourceCopyImportFail.variant.qml b/tests/auto/qml/qqmlecmascript/data/scarceResourceCopyImportFail.variant.qml new file mode 100644 index 0000000000..8f6dcd6603 --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/scarceResourceCopyImportFail.variant.qml @@ -0,0 +1,8 @@ +import QtQuick 2.0 +import Qt.test 1.0 +import "scarceResourceCopyImportFail.variant.js" as ScarceResourceCopyImportFailJs + +QtObject { + property variant scarceResourceCopy: ScarceResourceCopyImportFailJs.importScarceResource() +} + diff --git a/tests/auto/qml/qqmlecmascript/data/scarceResourceCopyImportNoBinding.var.js b/tests/auto/qml/qqmlecmascript/data/scarceResourceCopyImportNoBinding.var.js new file mode 100644 index 0000000000..130199f78a --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/scarceResourceCopyImportNoBinding.var.js @@ -0,0 +1,15 @@ +.import Qt.test 1.0 as JsQtTest + +// In this case, the "retn" variable will be evaluated during import. +// Since the importScarceResource() function depends on this variable, +// because we DO NOT call "retn.preserve()", the scarce resource will +// be released after the import completes but prior to evaluation of +// any binding which calls "importScarceResource()". +// Thus, "importScarceResource()" will return a released (invalid) +// scarce resource. + +var component = Qt.createComponent("scarceResourceCopyNoBinding.var.qml"); +var scarceResourceElement = component.createObject(null); +var scarceResourceProvider = scarceResourceElement.a; +var retn = scarceResourceProvider.scarceResource; + diff --git a/tests/auto/qml/qqmlecmascript/data/scarceResourceCopyImportNoBinding.var.qml b/tests/auto/qml/qqmlecmascript/data/scarceResourceCopyImportNoBinding.var.qml new file mode 100644 index 0000000000..5284b40cc8 --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/scarceResourceCopyImportNoBinding.var.qml @@ -0,0 +1,12 @@ +import QtQuick 2.0 +import Qt.test 1.0 + +// the following js import doesn't manually preserve or destroy any resources +import "scarceResourceCopyImportNoBinding.var.js" as ScarceResourceCopyImportNoBindingJs + +QtObject { + // in this case, there is an import but no binding evaluated. + // nonetheless, any resources which are not preserved, should + // be automatically released by the engine. +} + diff --git a/tests/auto/qml/qqmlecmascript/data/scarceResourceCopyImportNoBinding.variant.js b/tests/auto/qml/qqmlecmascript/data/scarceResourceCopyImportNoBinding.variant.js new file mode 100644 index 0000000000..14a36a19ea --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/scarceResourceCopyImportNoBinding.variant.js @@ -0,0 +1,15 @@ +.import Qt.test 1.0 as JsQtTest + +// In this case, the "retn" variable will be evaluated during import. +// Since the importScarceResource() function depends on this variable, +// because we DO NOT call "retn.preserve()", the scarce resource will +// be released after the import completes but prior to evaluation of +// any binding which calls "importScarceResource()". +// Thus, "importScarceResource()" will return a released (invalid) +// scarce resource. + +var component = Qt.createComponent("scarceResourceCopyNoBinding.variant.qml"); +var scarceResourceElement = component.createObject(null); +var scarceResourceProvider = scarceResourceElement.a; +var retn = scarceResourceProvider.scarceResource; + diff --git a/tests/auto/qml/qqmlecmascript/data/scarceResourceCopyImportNoBinding.variant.qml b/tests/auto/qml/qqmlecmascript/data/scarceResourceCopyImportNoBinding.variant.qml new file mode 100644 index 0000000000..826cbe49fc --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/scarceResourceCopyImportNoBinding.variant.qml @@ -0,0 +1,12 @@ +import QtQuick 2.0 +import Qt.test 1.0 + +// the following js import doesn't manually preserve or destroy any resources +import "scarceResourceCopyImportNoBinding.variant.js" as ScarceResourceCopyImportNoBindingJs + +QtObject { + // in this case, there is an import but no binding evaluated. + // nonetheless, any resources which are not preserved, should + // be automatically released by the engine. +} + diff --git a/tests/auto/qml/qqmlecmascript/data/scarceResourceCopyNoBinding.var.qml b/tests/auto/qml/qqmlecmascript/data/scarceResourceCopyNoBinding.var.qml new file mode 100644 index 0000000000..4adef39980 --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/scarceResourceCopyNoBinding.var.qml @@ -0,0 +1,14 @@ +import QtQuick 2.0 +import Qt.test 1.0 + +QtObject { + // this component doesn't bind any property to a scarce + // resource from the scarce resource provider, + // so the binding evaluation resource cleanup + // codepath shouldn't be activated; so if the resources + // are released, it will be due to the import evaluation + // resource cleanup codepath being activated correctly. + property MyScarceResourceObject a; + a: MyScarceResourceObject { id: scarceResourceProvider } +} + diff --git a/tests/auto/qml/qqmlecmascript/data/scarceResourceCopyNoBinding.variant.qml b/tests/auto/qml/qqmlecmascript/data/scarceResourceCopyNoBinding.variant.qml new file mode 100644 index 0000000000..4adef39980 --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/scarceResourceCopyNoBinding.variant.qml @@ -0,0 +1,14 @@ +import QtQuick 2.0 +import Qt.test 1.0 + +QtObject { + // this component doesn't bind any property to a scarce + // resource from the scarce resource provider, + // so the binding evaluation resource cleanup + // codepath shouldn't be activated; so if the resources + // are released, it will be due to the import evaluation + // resource cleanup codepath being activated correctly. + property MyScarceResourceObject a; + a: MyScarceResourceObject { id: scarceResourceProvider } +} + diff --git a/tests/auto/qml/qqmlecmascript/data/scarceResourceDestroyedCopy.var.qml b/tests/auto/qml/qqmlecmascript/data/scarceResourceDestroyedCopy.var.qml new file mode 100644 index 0000000000..500f5d5bd7 --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/scarceResourceDestroyedCopy.var.qml @@ -0,0 +1,13 @@ +import QtQuick 2.0 +import Qt.test 1.0 +import "scarceResourceTest.var.js" as ScarceResourceProviderJs + +// In this case, following the evaluation of the binding, +// the scarceResourceTest value should be an invalid variant, +// since the scarce resource will have been released. + +QtObject { + property MyScarceResourceObject a; + a: MyScarceResourceObject { id: scarceResourceProvider } + property var scarceResourceCopy: ScarceResourceProviderJs.importReleasedScarceResource(scarceResourceProvider); +} \ No newline at end of file diff --git a/tests/auto/qml/qqmlecmascript/data/scarceResourceDestroyedCopy.variant.qml b/tests/auto/qml/qqmlecmascript/data/scarceResourceDestroyedCopy.variant.qml new file mode 100644 index 0000000000..7a3b845247 --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/scarceResourceDestroyedCopy.variant.qml @@ -0,0 +1,14 @@ +import QtQuick 2.0 +import Qt.test 1.0 +import "scarceResourceTest.variant.js" as ScarceResourceProviderJs + +// In this case, following the evaluation of the binding, +// the scarceResourceTest value should be an invalid variant, +// since the scarce resource will have been released. + +QtObject { + property MyScarceResourceObject a; + a: MyScarceResourceObject { id: scarceResourceProvider } + property variant scarceResourceCopy: ScarceResourceProviderJs.importReleasedScarceResource(scarceResourceProvider); +} + diff --git a/tests/auto/qml/qqmlecmascript/data/scarceResourceFunction.var.qml b/tests/auto/qml/qqmlecmascript/data/scarceResourceFunction.var.qml new file mode 100644 index 0000000000..23e4c8d15e --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/scarceResourceFunction.var.qml @@ -0,0 +1,23 @@ +import QtQuick 2.0 +import Qt.test 1.0 + +// Here we import a scarce resource directly. +// The copy is only assigned when retrieveScarceResource() +// is called, and so should be detached prior to that. +// The copy should be released when releaseScarceResource() +// is called, and so should be detached after that. + +QtObject { + id: root + property MyScarceResourceObject a: MyScarceResourceObject { id: scarceResourceProvider } + property var scarceResourceCopy; + + function retrieveScarceResource() { + root.scarceResourceCopy = scarceResourceProvider.scarceResource; + } + + function releaseScarceResource() { + root.scarceResourceCopy = null; + } +} + diff --git a/tests/auto/qml/qqmlecmascript/data/scarceResourceFunction.variant.qml b/tests/auto/qml/qqmlecmascript/data/scarceResourceFunction.variant.qml new file mode 100644 index 0000000000..fe3707b5d3 --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/scarceResourceFunction.variant.qml @@ -0,0 +1,23 @@ +import QtQuick 2.0 +import Qt.test 1.0 + +// Here we import a scarce resource directly. +// The copy is only assigned when retrieveScarceResource() +// is called, and so should be detached prior to that. +// The copy should be released when releaseScarceResource() +// is called, and so should be detached after that. + +QtObject { + id: root + property MyScarceResourceObject a: MyScarceResourceObject { id: scarceResourceProvider } + property variant scarceResourceCopy; + + function retrieveScarceResource() { + root.scarceResourceCopy = scarceResourceProvider.scarceResource; + } + + function releaseScarceResource() { + root.scarceResourceCopy = null; + } +} + diff --git a/tests/auto/qml/qqmlecmascript/data/scarceResourceFunctionFail.var.qml b/tests/auto/qml/qqmlecmascript/data/scarceResourceFunctionFail.var.qml new file mode 100644 index 0000000000..9b4b1e6fd9 --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/scarceResourceFunctionFail.var.qml @@ -0,0 +1,23 @@ +import QtQuick 2.0 +import Qt.test 1.0 + +// In this example, a common syntax error will only be "caught" +// when the function is called via: +// QQmlVMEMetaObject::metaCall->invokeMetaMethod() +// We would like to ensure that a useful error message is printed. + +QtObject { + id: root + property MyScarceResourceObject a: MyScarceResourceObject { id: scarceResourceProvider } + property var scarceResourceCopy; + property string srp_name: a.toString(); + + function retrieveScarceResource() { + root.scarceResourceCopy = scarceResourceProvider.scarceResource(); // common syntax error, should throw exception + } + + function releaseScarceResource() { + root.scarceResourceCopy = null; + } +} + diff --git a/tests/auto/qml/qqmlecmascript/data/scarceResourceFunctionFail.variant.qml b/tests/auto/qml/qqmlecmascript/data/scarceResourceFunctionFail.variant.qml new file mode 100644 index 0000000000..57673de3f3 --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/scarceResourceFunctionFail.variant.qml @@ -0,0 +1,23 @@ +import QtQuick 2.0 +import Qt.test 1.0 + +// In this example, a common syntax error will only be "caught" +// when the function is called via: +// QQmlVMEMetaObject::metaCall->invokeMetaMethod() +// We would like to ensure that a useful error message is printed. + +QtObject { + id: root + property MyScarceResourceObject a: MyScarceResourceObject { id: scarceResourceProvider } + property variant scarceResourceCopy; + property string srp_name: a.toString(); + + function retrieveScarceResource() { + root.scarceResourceCopy = scarceResourceProvider.scarceResource(); // common syntax error, should throw exception + } + + function releaseScarceResource() { + root.scarceResourceCopy = null; + } +} + diff --git a/tests/auto/qml/qqmlecmascript/data/scarceResourceMultipleDifferentNoBinding.var.js b/tests/auto/qml/qqmlecmascript/data/scarceResourceMultipleDifferentNoBinding.var.js new file mode 100644 index 0000000000..217f693456 --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/scarceResourceMultipleDifferentNoBinding.var.js @@ -0,0 +1,14 @@ +.import Qt.test 1.0 as JsQtTest + +function importScarceResource() { + var component = Qt.createComponent("scarceResourceCopy.var.qml"); + var scarceResourceElement = component.createObject(null); + var scarceResourceProvider = scarceResourceElement.a; + var retn = scarceResourceProvider.scarceResource; + retn.preserve(); + return retn; +} + +function releaseScarceResource(resource) { + resource.destroy(); +} \ No newline at end of file diff --git a/tests/auto/qml/qqmlecmascript/data/scarceResourceMultipleDifferentNoBinding.var.qml b/tests/auto/qml/qqmlecmascript/data/scarceResourceMultipleDifferentNoBinding.var.qml new file mode 100644 index 0000000000..205131661f --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/scarceResourceMultipleDifferentNoBinding.var.qml @@ -0,0 +1,14 @@ +import QtQuick 2.0 +import Qt.test 1.0 +import "scarceResourceMultipleDifferentNoBinding.var.js" as ScarceResourcesMultipleDifferentNoBinding + +QtObject { + property var resourceOne + property var resourceTwo + + Component.onCompleted: { + resourceOne = ScarceResourcesMultipleDifferentNoBinding.importScarceResource(); + resourceTwo = ScarceResourcesMultipleDifferentNoBinding.importScarceResource(); + ScarceResourcesMultipleDifferentNoBinding.releaseScarceResource(resourceTwo); + } +} \ No newline at end of file diff --git a/tests/auto/qml/qqmlecmascript/data/scarceResourceMultipleSameNoBinding.var.js b/tests/auto/qml/qqmlecmascript/data/scarceResourceMultipleSameNoBinding.var.js new file mode 100644 index 0000000000..5b2494c8e6 --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/scarceResourceMultipleSameNoBinding.var.js @@ -0,0 +1,15 @@ +.import Qt.test 1.0 as JsQtTest + +var component = Qt.createComponent("scarceResourceCopy.var.qml"); +var scarceResourceElement = component.createObject(null); +var scarceResourceProvider = scarceResourceElement.a; +var retn = scarceResourceProvider.scarceResource; +retn.preserve(); + +function importScarceResource() { + return retn; +} + +function releaseScarceResource(resource) { + resource.destroy(); +} \ No newline at end of file diff --git a/tests/auto/qml/qqmlecmascript/data/scarceResourceMultipleSameNoBinding.var.qml b/tests/auto/qml/qqmlecmascript/data/scarceResourceMultipleSameNoBinding.var.qml new file mode 100644 index 0000000000..e7f6d7868f --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/scarceResourceMultipleSameNoBinding.var.qml @@ -0,0 +1,14 @@ +import QtQuick 2.0 +import Qt.test 1.0 +import "scarceResourceMultipleSameNoBinding.var.js" as ScarceResourcesMultipleSameNoBinding + +QtObject { + property var resourceOne + property var resourceTwo + + Component.onCompleted: { + resourceOne = ScarceResourcesMultipleSameNoBinding.importScarceResource(); + resourceTwo = ScarceResourcesMultipleSameNoBinding.importScarceResource(); + ScarceResourcesMultipleSameNoBinding.releaseScarceResource(resourceTwo); + } +} \ No newline at end of file diff --git a/tests/auto/qml/qqmlecmascript/data/scarceResourceMultipleSameWithBinding.var.qml b/tests/auto/qml/qqmlecmascript/data/scarceResourceMultipleSameWithBinding.var.qml new file mode 100644 index 0000000000..34cb97f39c --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/scarceResourceMultipleSameWithBinding.var.qml @@ -0,0 +1,12 @@ +import QtQuick 2.0 +import Qt.test 1.0 +import "scarceResourceMultipleDifferentNoBinding.var.js" as ScarceResourcesMultipleDifferentNoBinding + +QtObject { + property var resourceOne: ScarceResourcesMultipleDifferentNoBinding.importScarceResource() + property var resourceTwo: resourceOne + + Component.onCompleted: { + ScarceResourcesMultipleDifferentNoBinding.releaseScarceResource(resourceTwo); + } +} \ No newline at end of file diff --git a/tests/auto/qml/qqmlecmascript/data/scarceResourceObjectGc.var.qml b/tests/auto/qml/qqmlecmascript/data/scarceResourceObjectGc.var.qml new file mode 100644 index 0000000000..7ec98e6619 --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/scarceResourceObjectGc.var.qml @@ -0,0 +1,30 @@ +import QtQuick 2.0 +import Qt.test 1.0 + +Item { + id: testScarce + + property var varProperty + + property var canary: 4 + + // constructs an Item which contains a scarce resource. + function constructScarceObject() { + var retn = 1; + var component = Qt.createComponent("ScarceResourceVarComponent.qml"); + if (component.status == Component.Ready) { + retn = component.createObject(null); // has JavaScript ownership + } + return retn; + } + + function assignVarProperty() { + varProperty = constructScarceObject(); + gc(); + } + + function deassignVarProperty() { + varProperty = 2; // causes the original object to be garbage collected. + gc(); // image should be detached; ep->sr should be empty! + } +} diff --git a/tests/auto/qml/qqmlecmascript/data/scarceResourceSignal.var.qml b/tests/auto/qml/qqmlecmascript/data/scarceResourceSignal.var.qml new file mode 100644 index 0000000000..0b30e88fa8 --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/scarceResourceSignal.var.qml @@ -0,0 +1,29 @@ +import QtQuick 2.0 +import Qt.test 1.0 + +QtObject { + id: root + + property MyScarceResourceObject a; + a: MyScarceResourceObject { id: scarceResourceProvider } + + property ScarceResourceSignalComponentVar b; + b: ScarceResourceSignalComponentVar { + objectName: "srsc" + + onTestSignal: { + // this signal will be invoked manually in the test. + // the scarce resource should be released automatically after evaluation + // and since we don't keep a copy of it, the pixmap will be detached. + width = (scarceResourceProvider.scarceResource,10) + } + + onTestSignal2: { + // this signal will be invoked manually in the test. + // the scarce resource should be released automatically after evaluation + // but since we assign it to a property, the pixmap won't be detached. + scarceResourceCopy = scarceResourceProvider.scarceResource + } + } +} + diff --git a/tests/auto/qml/qqmlecmascript/data/scarceResourceSignal.variant.qml b/tests/auto/qml/qqmlecmascript/data/scarceResourceSignal.variant.qml new file mode 100644 index 0000000000..1011c7e240 --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/scarceResourceSignal.variant.qml @@ -0,0 +1,29 @@ +import QtQuick 2.0 +import Qt.test 1.0 + +QtObject { + id: root + + property MyScarceResourceObject a; + a: MyScarceResourceObject { id: scarceResourceProvider } + + property ScarceResourceSignalComponentVariant b; + b: ScarceResourceSignalComponentVariant { + objectName: "srsc" + + onTestSignal: { + // this signal will be invoked manually in the test. + // the scarce resource should be released automatically after evaluation + // and since we don't keep a copy of it, the pixmap will be detached. + width = (scarceResourceProvider.scarceResource,10) + } + + onTestSignal2: { + // this signal will be invoked manually in the test. + // the scarce resource should be released automatically after evaluation + // but since we assign it to a property, the pixmap won't be detached. + scarceResourceCopy = scarceResourceProvider.scarceResource + } + } +} + diff --git a/tests/auto/qml/qqmlecmascript/data/scarceResourceTest.var.js b/tests/auto/qml/qqmlecmascript/data/scarceResourceTest.var.js new file mode 100644 index 0000000000..c904eb3564 --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/scarceResourceTest.var.js @@ -0,0 +1,48 @@ +.import Qt.test 1.0 as JsQtTest + +function importScarceResource(scarceResourceProvider) { + // the scarce resource should be automatically released + // after the binding is evaluated if preserve is not + // called. + return scarceResourceProvider.scarceResource; +} + +function importPreservedScarceResource(scarceResourceProvider) { + // the scarce resource is manually preserved + // during the evaluation of the binding. + // it should not be released. + var scarceResource = scarceResourceProvider.scarceResource; + scarceResource.preserve(); + return scarceResource; +} + +function importReleasedScarceResource(scarceResourceProvider) { + // release the scarce resource during the + // evaluation of the binding. The returned + // variant will therefore be invalid. + var scarceResource = scarceResourceProvider.scarceResource; + scarceResource.destroy(); + return scarceResource; +} + +function importPreservedScarceResourceFromMultiple(scarceResourceProvider) { + // some scarce resources are manually preserved, + // some of them are manually destroyed, + // and some are automatically managed. + // We return a preserved resource + var sr1 = scarceResourceProvider.scarceResource; // preserved/destroyed. + sr1.preserve(); + var sr2 = scarceResourceProvider.scarceResource; // preserved/destroyed + sr2.preserve(); + var sr3 = scarceResourceProvider.scarceResource; // automatic. + var sr4 = scarceResourceProvider.scarceResource; // automatic and returned. + var sr5 = scarceResourceProvider.scarceResource; // destroyed + sr5.destroy(); + sr2.destroy(); + var sr6 = scarceResourceProvider.scarceResource; // destroyed + var sr7 = scarceResourceProvider.scarceResource; // automatic + sr1.destroy(); + sr6.destroy(); + return sr4; +} + diff --git a/tests/auto/qml/qqmlecmascript/data/scarceResourceTest.var.qml b/tests/auto/qml/qqmlecmascript/data/scarceResourceTest.var.qml new file mode 100644 index 0000000000..1d4e67055e --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/scarceResourceTest.var.qml @@ -0,0 +1,14 @@ +import QtQuick 2.0 +import Qt.test 1.0 + +// Here we import a scarce resource directly, and use it in a binding. +// It is not preserved or released manually, so it should be +// automatically released once evaluation of the binding +// is complete. + +QtObject { + property MyScarceResourceObject a; + a: MyScarceResourceObject { id: scarceResourceProvider } + property int scarceResourceTest: scarceResourceProvider.scarceResource,100 // return 100, but include the scarceResource in the binding to be evaluated. +} + diff --git a/tests/auto/qml/qqmlecmascript/data/scarceResourceTest.variant.js b/tests/auto/qml/qqmlecmascript/data/scarceResourceTest.variant.js new file mode 100644 index 0000000000..c904eb3564 --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/scarceResourceTest.variant.js @@ -0,0 +1,48 @@ +.import Qt.test 1.0 as JsQtTest + +function importScarceResource(scarceResourceProvider) { + // the scarce resource should be automatically released + // after the binding is evaluated if preserve is not + // called. + return scarceResourceProvider.scarceResource; +} + +function importPreservedScarceResource(scarceResourceProvider) { + // the scarce resource is manually preserved + // during the evaluation of the binding. + // it should not be released. + var scarceResource = scarceResourceProvider.scarceResource; + scarceResource.preserve(); + return scarceResource; +} + +function importReleasedScarceResource(scarceResourceProvider) { + // release the scarce resource during the + // evaluation of the binding. The returned + // variant will therefore be invalid. + var scarceResource = scarceResourceProvider.scarceResource; + scarceResource.destroy(); + return scarceResource; +} + +function importPreservedScarceResourceFromMultiple(scarceResourceProvider) { + // some scarce resources are manually preserved, + // some of them are manually destroyed, + // and some are automatically managed. + // We return a preserved resource + var sr1 = scarceResourceProvider.scarceResource; // preserved/destroyed. + sr1.preserve(); + var sr2 = scarceResourceProvider.scarceResource; // preserved/destroyed + sr2.preserve(); + var sr3 = scarceResourceProvider.scarceResource; // automatic. + var sr4 = scarceResourceProvider.scarceResource; // automatic and returned. + var sr5 = scarceResourceProvider.scarceResource; // destroyed + sr5.destroy(); + sr2.destroy(); + var sr6 = scarceResourceProvider.scarceResource; // destroyed + var sr7 = scarceResourceProvider.scarceResource; // automatic + sr1.destroy(); + sr6.destroy(); + return sr4; +} + diff --git a/tests/auto/qml/qqmlecmascript/data/scarceResourceTest.variant.qml b/tests/auto/qml/qqmlecmascript/data/scarceResourceTest.variant.qml new file mode 100644 index 0000000000..1d4e67055e --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/scarceResourceTest.variant.qml @@ -0,0 +1,14 @@ +import QtQuick 2.0 +import Qt.test 1.0 + +// Here we import a scarce resource directly, and use it in a binding. +// It is not preserved or released manually, so it should be +// automatically released once evaluation of the binding +// is complete. + +QtObject { + property MyScarceResourceObject a; + a: MyScarceResourceObject { id: scarceResourceProvider } + property int scarceResourceTest: scarceResourceProvider.scarceResource,100 // return 100, but include the scarceResource in the binding to be evaluated. +} + diff --git a/tests/auto/qml/qqmlecmascript/data/scarceResourceTestMultiple.var.qml b/tests/auto/qml/qqmlecmascript/data/scarceResourceTestMultiple.var.qml new file mode 100644 index 0000000000..5e6c2d97f9 --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/scarceResourceTestMultiple.var.qml @@ -0,0 +1,16 @@ +import QtQuick 2.0 +import Qt.test 1.0 +import "scarceResourceTest.var.js" as ScarceResourceProviderJs + +// In this case, multiple scarce resource are explicity preserved +// and then explicitly destroyed, while others are automatically +// managed. Since none are manually preserved without subsequently +// being destroyed, after the evaluation of the binding the +// scarce resource should be detached. + +QtObject { + property MyScarceResourceObject a; + a: MyScarceResourceObject { id: scarceResourceProvider } + property int scarceResourceTest: ScarceResourceProviderJs.importPreservedScarceResourceFromMultiple(scarceResourceProvider), 100 +} + diff --git a/tests/auto/qml/qqmlecmascript/data/scarceResourceTestMultiple.variant.qml b/tests/auto/qml/qqmlecmascript/data/scarceResourceTestMultiple.variant.qml new file mode 100644 index 0000000000..2970bcb26c --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/scarceResourceTestMultiple.variant.qml @@ -0,0 +1,15 @@ +import QtQuick 2.0 +import Qt.test 1.0 +import "scarceResourceTest.variant.js" as ScarceResourceProviderJs + +// In this case, multiple scarce resource are explicity preserved +// and then explicitly destroyed, while others are automatically +// managed. Since none are manually preserved without subsequently +// being destroyed, after the evaluation of the binding the +// scarce resource should be detached. + +QtObject { + property MyScarceResourceObject a; + a: MyScarceResourceObject { id: scarceResourceProvider } + property int scarceResourceTest: ScarceResourceProviderJs.importPreservedScarceResourceFromMultiple(scarceResourceProvider), 100 +} diff --git a/tests/auto/qml/qqmlecmascript/data/scarceResourceTestPreserve.var.qml b/tests/auto/qml/qqmlecmascript/data/scarceResourceTestPreserve.var.qml new file mode 100644 index 0000000000..9e9495c0fa --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/scarceResourceTestPreserve.var.qml @@ -0,0 +1,15 @@ +import QtQuick 2.0 +import Qt.test 1.0 +import "scarceResourceTest.var.js" as ScarceResourceProviderJs + +// In this case, the scarce resource is explicity preserved. +// It should not be automatically released after the evaluation +// of the binding is complete, but instead will be kept in +// memory until the JS garbage collector runs. + +QtObject { + property MyScarceResourceObject a; + a: MyScarceResourceObject { id: scarceResourceProvider } + property int scarceResourceTest: ScarceResourceProviderJs.importPreservedScarceResource(scarceResourceProvider),100 // return 100, but the resource should be preserved. +} + diff --git a/tests/auto/qml/qqmlecmascript/data/scarceResourceTestPreserve.variant.qml b/tests/auto/qml/qqmlecmascript/data/scarceResourceTestPreserve.variant.qml new file mode 100644 index 0000000000..022067beca --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/scarceResourceTestPreserve.variant.qml @@ -0,0 +1,15 @@ +import QtQuick 2.0 +import Qt.test 1.0 +import "scarceResourceTest.variant.js" as ScarceResourceProviderJs + +// In this case, the scarce resource is explicity preserved. +// It should not be automatically released after the evaluation +// of the binding is complete, but instead will be kept in +// memory until the JS garbage collector runs. + +QtObject { + property MyScarceResourceObject a; + a: MyScarceResourceObject { id: scarceResourceProvider } + property int scarceResourceTest: ScarceResourceProviderJs.importPreservedScarceResource(scarceResourceProvider),100 // return 100, but the resource should be preserved. +} + diff --git a/tests/auto/qml/qqmlecmascript/data/scope.2.qml b/tests/auto/qml/qqmlecmascript/data/scope.2.qml new file mode 100644 index 0000000000..fe1c4c7931 --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/scope.2.qml @@ -0,0 +1,40 @@ +import QtQuick 2.0 + +Item { + property int a: 0 + property int b: 14 + + function b() { return 11; } + function c() { return 33; } + + QtObject { + id: a + property int value: 19 + } + + QtObject { + id: c + property int value: 24 + } + + QtObject { + id: nested + property int a: 1 + property int test: a.value + property int test2: b + property int test3: c.value + } + + + // id takes precedence over local, and root properties + property int test1: a.value + property alias test2: nested.test + + // properties takes precedence over local, and root methods + property int test3: b + property alias test4: nested.test2 + + // id takes precedence over methods + property int test5: c.value + property alias test6: nested.test3 +} diff --git a/tests/auto/qml/qqmlecmascript/data/scope.3.qml b/tests/auto/qml/qqmlecmascript/data/scope.3.qml new file mode 100644 index 0000000000..9add81809c --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/scope.3.qml @@ -0,0 +1,13 @@ +import QtQuick 2.0 +import Qt.test 1.0 + +MyQmlObject { + id: root + + property int foo: 12 + + property bool test1: foo == 12 + property bool test2: console != 11 + property bool test3: root.console == 11 +} + diff --git a/tests/auto/qml/qqmlecmascript/data/scope.4.qml b/tests/auto/qml/qqmlecmascript/data/scope.4.qml new file mode 100644 index 0000000000..d65b6e7c7c --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/scope.4.qml @@ -0,0 +1,12 @@ +import Qt.test 1.0 + +MyQmlObject { + id: a + property int b: 9 + + property int test + property string test2 + + // Should resolve to signal arguments, not to other elements in the file + onArgumentSignal: { test = a; test2 = b; } +} diff --git a/tests/auto/qml/qqmlecmascript/data/scope.5.qml b/tests/auto/qml/qqmlecmascript/data/scope.5.qml new file mode 100644 index 0000000000..6dbcbe2a40 --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/scope.5.qml @@ -0,0 +1,27 @@ +import QtQuick 2.0 + +Item { + property bool test1: false; + property bool test2: false; + + property int a: 10 + + Item { + id: nested + property int a: 11 + + function mynestedfunction() { + return a; + } + } + + function myouterfunction() { + return a; + } + + Component.onCompleted: { + test1 = (myouterfunction() == 10); + test2 = (nested.mynestedfunction() == 11); + } +} + diff --git a/tests/auto/qml/qqmlecmascript/data/scope.6.qml b/tests/auto/qml/qqmlecmascript/data/scope.6.qml new file mode 100644 index 0000000000..5897b533d7 --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/scope.6.qml @@ -0,0 +1,10 @@ +import QtQuick 2.0 + +Item { + id: me + property bool test: nested.runtest(me); + + Scope6Nested { + id: nested + } +} diff --git a/tests/auto/qml/qqmlecmascript/data/scope.qml b/tests/auto/qml/qqmlecmascript/data/scope.qml new file mode 100644 index 0000000000..a00352b684 --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/scope.qml @@ -0,0 +1,44 @@ +import QtQuick 2.0 + +Item { + id: root + + property int a: 1 + property int binding: a + property string binding2: a + "Test" + property int binding3: myFunction() + property int binding4: nestedObject.myNestedFunction() + + function myFunction() { + return a; + } + + Item { + id: nestedObject + + function myNestedFunction() { + return a; + } + + property int a: 2 + property int binding: a + property string binding2: a + "Test" + property int binding3: myFunction() + property int binding4: myNestedFunction() + } + + ScopeObject { + id: compObject + } + + property alias test1: root.binding + property alias test2: nestedObject.binding + property alias test3: root.binding2 + property alias test4: nestedObject.binding2 + property alias test5: root.binding3 + property alias test6: nestedObject.binding3 + property alias test7: root.binding4 + property alias test8: nestedObject.binding4 + property alias test9: compObject.binding + property alias test10: compObject.binding2 +} diff --git a/tests/auto/qml/qqmlecmascript/data/scriptConnect.1.js b/tests/auto/qml/qqmlecmascript/data/scriptConnect.1.js new file mode 100644 index 0000000000..54284fea47 --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/scriptConnect.1.js @@ -0,0 +1,4 @@ +function testFunction() { + test = true; +} + diff --git a/tests/auto/qml/qqmlecmascript/data/scriptConnect.1.qml b/tests/auto/qml/qqmlecmascript/data/scriptConnect.1.qml new file mode 100644 index 0000000000..ace473756e --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/scriptConnect.1.qml @@ -0,0 +1,10 @@ +import Qt.test 1.0 +import QtQuick 2.0 +import "scriptConnect.1.js" as Script +MyQmlObject { + property bool test: false + + id: root + + Component.onCompleted: root.argumentSignal.connect(Script.testFunction); +} diff --git a/tests/auto/qml/qqmlecmascript/data/scriptConnect.2.js b/tests/auto/qml/qqmlecmascript/data/scriptConnect.2.js new file mode 100644 index 0000000000..595c778aa7 --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/scriptConnect.2.js @@ -0,0 +1,5 @@ +function testFunction() { + if (this.b == 12) + test = true; +} + diff --git a/tests/auto/qml/qqmlecmascript/data/scriptConnect.2.qml b/tests/auto/qml/qqmlecmascript/data/scriptConnect.2.qml new file mode 100644 index 0000000000..cdf2d6ad98 --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/scriptConnect.2.qml @@ -0,0 +1,16 @@ +import Qt.test 1.0 +import QtQuick 2.0 +import "scriptConnect.2.js" as Script + +MyQmlObject { + property bool test: false + + id: root + + Component.onCompleted: { + var a = new Object; + a.b = 12; + root.argumentSignal.connect(a, Script.testFunction); + } +} + diff --git a/tests/auto/qml/qqmlecmascript/data/scriptConnect.3.qml b/tests/auto/qml/qqmlecmascript/data/scriptConnect.3.qml new file mode 100644 index 0000000000..b0e40565c0 --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/scriptConnect.3.qml @@ -0,0 +1,15 @@ +import Qt.test 1.0 +import QtQuick 2.0 + +MyQmlObject { + property bool test: false + + id: root + + function testFunction() { + test = true; + } + + Component.onCompleted: root.argumentSignal.connect(testFunction); +} + diff --git a/tests/auto/qml/qqmlecmascript/data/scriptConnect.4.qml b/tests/auto/qml/qqmlecmascript/data/scriptConnect.4.qml new file mode 100644 index 0000000000..ef5331c94a --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/scriptConnect.4.qml @@ -0,0 +1,12 @@ +import Qt.test 1.0 +import QtQuick 2.0 + +MyQmlObject { + property bool test: false + + id: root + + Component.onCompleted: root.argumentSignal.connect(methodNoArgs); +} + + diff --git a/tests/auto/qml/qqmlecmascript/data/scriptConnect.5.qml b/tests/auto/qml/qqmlecmascript/data/scriptConnect.5.qml new file mode 100644 index 0000000000..8dcacbcbb7 --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/scriptConnect.5.qml @@ -0,0 +1,11 @@ +import Qt.test 1.0 +import QtQuick 2.0 + +MyQmlObject { + property bool test: false + + id: root + + Component.onCompleted: root.argumentSignal.connect(root, methodNoArgs); +} + diff --git a/tests/auto/qml/qqmlecmascript/data/scriptConnect.6.js b/tests/auto/qml/qqmlecmascript/data/scriptConnect.6.js new file mode 100644 index 0000000000..71bdd088a2 --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/scriptConnect.6.js @@ -0,0 +1,3 @@ +function testFunction() { + test++; +} diff --git a/tests/auto/qml/qqmlecmascript/data/scriptConnect.6.qml b/tests/auto/qml/qqmlecmascript/data/scriptConnect.6.qml new file mode 100644 index 0000000000..06b6f0fa62 --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/scriptConnect.6.qml @@ -0,0 +1,15 @@ +import Qt.test 1.0 +import QtQuick 2.0 +import "scriptConnect.6.js" as Script + +MyQmlObject { + property int test: 0 + + id: root + + Component.onCompleted: { + root.argumentSignal.connect(Script.testFunction); + root.argumentSignal.connect(Script.testFunction); + } +} + diff --git a/tests/auto/qml/qqmlecmascript/data/scriptDisconnect.1.js b/tests/auto/qml/qqmlecmascript/data/scriptDisconnect.1.js new file mode 100644 index 0000000000..407426fcd1 --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/scriptDisconnect.1.js @@ -0,0 +1,6 @@ +function testFunction() { + test++; +} + +function otherFunction() { +} diff --git a/tests/auto/qml/qqmlecmascript/data/scriptDisconnect.1.qml b/tests/auto/qml/qqmlecmascript/data/scriptDisconnect.1.qml new file mode 100644 index 0000000000..e546ee44d8 --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/scriptDisconnect.1.qml @@ -0,0 +1,13 @@ +import Qt.test 1.0 +import QtQuick 2.0 +import "scriptDisconnect.1.js" as Script + +MyQmlObject { + property int test: 0 + + id: root + + Component.onCompleted: root.argumentSignal.connect(Script.testFunction); + + onBasicSignal: root.argumentSignal.disconnect(Script.testFunction); +} diff --git a/tests/auto/qml/qqmlecmascript/data/scriptDisconnect.2.qml b/tests/auto/qml/qqmlecmascript/data/scriptDisconnect.2.qml new file mode 100644 index 0000000000..e70cd8b900 --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/scriptDisconnect.2.qml @@ -0,0 +1,14 @@ +import Qt.test 1.0 +import QtQuick 2.0 +import "scriptDisconnect.1.js" as Script + +MyQmlObject { + property int test: 0 + + id: root + + Component.onCompleted: root.argumentSignal.connect(root, Script.testFunction); + + onBasicSignal: root.argumentSignal.disconnect(root, Script.testFunction); +} + diff --git a/tests/auto/qml/qqmlecmascript/data/scriptDisconnect.3.qml b/tests/auto/qml/qqmlecmascript/data/scriptDisconnect.3.qml new file mode 100644 index 0000000000..6f47776ea5 --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/scriptDisconnect.3.qml @@ -0,0 +1,14 @@ +import Qt.test 1.0 +import QtQuick 2.0 +import "scriptDisconnect.1.js" as Script + +MyQmlObject { + property int test: 0 + + id: root + + Component.onCompleted: root.argumentSignal.connect(root, Script.testFunction); + + onBasicSignal: root.argumentSignal.disconnect(Script.testFunction); +} + diff --git a/tests/auto/qml/qqmlecmascript/data/scriptDisconnect.4.qml b/tests/auto/qml/qqmlecmascript/data/scriptDisconnect.4.qml new file mode 100644 index 0000000000..b3887545fb --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/scriptDisconnect.4.qml @@ -0,0 +1,13 @@ +import Qt.test 1.0 +import QtQuick 2.0 +import "scriptDisconnect.1.js" as Script + +MyQmlObject { + property int test: 0 + + id: root + + Component.onCompleted: root.argumentSignal.connect(Script.testFunction); + + onBasicSignal: root.argumentSignal.disconnect(Script.otherFunction); +} diff --git a/tests/auto/qml/qqmlecmascript/data/scriptErrors.js b/tests/auto/qml/qqmlecmascript/data/scriptErrors.js new file mode 100644 index 0000000000..d22f623edb --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/scriptErrors.js @@ -0,0 +1,4 @@ +// Comment +a = 10 + +function getValue() { a = 10; return 0; } diff --git a/tests/auto/qml/qqmlecmascript/data/scriptErrors.qml b/tests/auto/qml/qqmlecmascript/data/scriptErrors.qml new file mode 100644 index 0000000000..4998f63929 --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/scriptErrors.qml @@ -0,0 +1,18 @@ +import Qt.test 1.0 +import "scriptErrors.js" as Script + +MyQmlObject { + property int t: a.value + property int w: Script.getValue(); + property int d: undefined + ? 0 // multi-line binding + : 1 + property int x: undefined + property int y: (a.value, undefinedObject) + + onBasicSignal: { console.log(a.value); } + id: myObj + onAnotherBasicSignal: myObj.trueProperty = false; + onThirdBasicSignal: myObj.fakeProperty = ""; +} + diff --git a/tests/auto/qml/qqmlecmascript/data/selfDeletingBinding.2.qml b/tests/auto/qml/qqmlecmascript/data/selfDeletingBinding.2.qml new file mode 100644 index 0000000000..58cf8051f0 --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/selfDeletingBinding.2.qml @@ -0,0 +1,17 @@ +import Qt.test 1.0 + +MyQmlContainer { + property bool triggerDelete: false + + children: [ + MyQmlObject { + // Will trigger deletion on binding assignment + deleteOnSet: Math.max(0, 1) + }, + + MyQmlObject { + // Will trigger deletion on binding assignment, but after component creation + deleteOnSet: if (triggerDelete) 1; else 0; + } + ] +} diff --git a/tests/auto/qml/qqmlecmascript/data/selfDeletingBinding.qml b/tests/auto/qml/qqmlecmascript/data/selfDeletingBinding.qml new file mode 100644 index 0000000000..074851a67b --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/selfDeletingBinding.qml @@ -0,0 +1,18 @@ +import Qt.test 1.0 + +MyQmlContainer { + property bool triggerDelete: false + + children: [ + MyQmlObject { + // Will trigger deletion during binding evaluation + stringProperty: {deleteMe(), "Hello"} + }, + + MyQmlObject { + // Will trigger deletion during binding evaluation, but after component creation + stringProperty: if (triggerDelete) { deleteMe(), "Hello" } else { "World" } + } + + ] +} diff --git a/tests/auto/qml/qqmlecmascript/data/sequenceConversion.array.qml b/tests/auto/qml/qqmlecmascript/data/sequenceConversion.array.qml new file mode 100644 index 0000000000..52abda1e55 --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/sequenceConversion.array.qml @@ -0,0 +1,193 @@ +import QtQuick 2.0 +import Qt.test 1.0 + +Item { + id: root + objectName: "root" + + MySequenceConversionObject { + id: msco + objectName: "msco" + } + + property bool success: false + + property variant intList + property variant qrealList + property variant boolList + property variant stringList + + function indexedAccess() { + intList = msco.intListProperty; + var jsIntList = msco.intListProperty; + qrealList = msco.qrealListProperty; + var jsQrealList = msco.qrealListProperty; + boolList = msco.boolListProperty; + var jsBoolList = msco.boolListProperty; + stringList = msco.stringListProperty; + var jsStringList = msco.stringListProperty; + + // Three cases: direct property modification, variant copy modification, js var reference modification. + // Only the first and third should "write back" to the original QObject Q_PROPERTY; the second one + // should have no effect whatsoever to maintain "property variant" semantics (see e.g., valuetype). + success = true; + + msco.intListProperty[1] = 33; + if (msco.intListProperty[1] != 33) success = false; // ensure write back + intList[1] = 44; + if (intList[1] == 44) success = false; // ensure no effect + jsIntList[1] = 55; + if (jsIntList[1] != 55 + || jsIntList[1] != msco.intListProperty[1]) success = false; // ensure write back + + msco.qrealListProperty[1] = 33.3; + if (msco.qrealListProperty[1] != 33.3) success = false; // ensure write back + qrealList[1] = 44.4; + if (qrealList[1] == 44.4) success = false; // ensure no effect + jsQrealList[1] = 55.5; + if (jsQrealList[1] != 55.5 + || jsQrealList[1] != msco.qrealListProperty[1]) success = false; // ensure write back + + msco.boolListProperty[1] = true; + if (msco.boolListProperty[1] != true) success = false; // ensure write back + boolList[1] = true; + if (boolList[1] != false) success = false; // ensure no effect + jsBoolList[1] = false; + if (jsBoolList[1] != false + || jsBoolList[1] != msco.boolListProperty[1]) success = false; // ensure write back + + msco.stringListProperty[1] = "changed"; + if (msco.stringListProperty[1] != "changed") success = false; // ensure write back + stringList[1] = "changed"; + if (stringList[1] != "second") success = false; // ensure no effect + jsStringList[1] = "different"; + if (jsStringList[1] != "different" + || jsStringList[1] != msco.stringListProperty[1]) success = false; // ensure write back + } + + function arrayOperations() { + success = true; + var expected = 0; + var expectedStr = ""; + + // ecma262r3 defines array as implementing Length and Put. Test put here. + msco.intListProperty.asdf = 5; // shouldn't work, only indexes are valid names. + if (msco.intListProperty.asdf == 5) success = false; + msco.intListProperty[3] = 38; // should work. + if (msco.intListProperty[3] != 38) success = false; + msco.intListProperty[199] = 200; // should work, and should set length to 200. + if (msco.intListProperty[199] != 200) success = false; + if (msco.intListProperty.length != 200) success = false; + + // test indexed deleter + msco.intListProperty = [ 1, 2, 3, 4, 5 ]; + delete msco.intListProperty[-1]; + expected = [ 1, 2, 3, 4, 5 ]; + if (msco.intListProperty.toString() != expected.toString()) success = false; + delete msco.intListProperty[0]; + expected = [ 0, 2, 3, 4, 5 ]; + if (msco.intListProperty.toString() != expected.toString()) success = false; + delete msco.intListProperty[2]; + expected = [ 0, 2, 0, 4, 5 ]; + if (msco.intListProperty.toString() != expected.toString()) success = false; + delete msco.intListProperty[7]; + expected = [ 0, 2, 0, 4, 5 ]; + if (msco.intListProperty.toString() != expected.toString()) success = false; + + // other operations are defined on the array prototype; see if they work. + + // splice + msco.intListProperty = [ 0, 1, 2, 3, 4, 5, 6, 7 ]; + msco.intListProperty.splice(1,3, 33, 44, 55, 66); + expected = [ 0, 33, 44, 55, 66, 4, 5, 6, 7 ]; + if (msco.intListProperty.toString() != expected.toString()) success = false; + msco.intListProperty = [ 0, 1, 2, 3, 4, 5, 6, 7 ]; + msco.intListProperty.splice(1, 3); + expected = [ 0, 4, 5, 6, 7 ]; + if (msco.intListProperty.toString() != expected.toString()) success = false; + + msco.qrealListProperty = [ 0.1, 1.1, 2.1, 3.1, 4.1, 5.1, 6.1, 7.1 ]; + msco.qrealListProperty.splice(1,3, 33.33, 44.44, 55.55, 66.66); + expected = [ 0.1, 33.33, 44.44, 55.55, 66.66, 4.1, 5.1, 6.1, 7.1 ]; + if (msco.qrealListProperty.toString() != expected.toString()) success = false; + msco.qrealListProperty = [ 0.1, 1.1, 2.1, 3.1, 4.1, 5.1, 6.1, 7.1 ]; + msco.qrealListProperty.splice(1,3); + expected = [ 0.1, 4.1, 5.1, 6.1, 7.1 ]; + if (msco.qrealListProperty.toString() != expected.toString()) success = false; + + msco.boolListProperty = [ false, true, true, false, false, true, false, true ]; + msco.boolListProperty.splice(1,3, false, true, false, false); + expected = [ false, false, true, false, false, false, true, false, true ]; + if (msco.boolListProperty.toString() != expected.toString()) success = false; + msco.boolListProperty = [ false, true, true, false, false, true, false, true ]; + msco.boolListProperty.splice(1,3); + expected = [ false, false, true, false, true ]; + if (msco.boolListProperty.toString() != expected.toString()) success = false; + + msco.stringListProperty = [ "one", "two", "three", "four", "five", "six", "seven", "eight" ]; + msco.stringListProperty.splice(1,3, "nine", "ten", "eleven", "twelve"); + expected = [ "one", "nine", "ten", "eleven", "twelve", "five", "six", "seven", "eight" ]; + if (msco.stringListProperty.toString() != expected.toString()) success = false; + msco.stringListProperty = [ "one", "two", "three", "four", "five", "six", "seven", "eight" ]; + msco.stringListProperty.splice(0,3); + expected = [ "four", "five", "six", "seven", "eight" ]; + if (msco.stringListProperty.toString() != expected.toString()) success = false; + + // pop + msco.intListProperty = [ 0, 1, 2, 3, 4, 5, 6, 7 ]; + var poppedVal = msco.intListProperty.pop(); + expected = [ 0, 1, 2, 3, 4, 5, 6 ]; + if (msco.intListProperty.toString() != expected.toString()) success = false; + expected = 7; + if (poppedVal != expected) success = false; + } + + property variant variantList: [ 1, 2, 3, 4, 5 ]; + property variant variantList2: [ 1, 2, 3, 4, 5 ]; + function testEqualitySemantics() { + // ensure equality semantics match JS array equality semantics + success = true; + + msco.intListProperty = [ 1, 2, 3, 4, 5 ]; + msco.intListProperty2 = [ 1, 2, 3, 4, 5 ]; + var jsIntList = [ 1, 2, 3, 4, 5 ]; + var jsIntList2 = [ 1, 2, 3, 4, 5 ]; + + if (jsIntList != jsIntList) success = false; + if (jsIntList == jsIntList2) success = false; + if (jsIntList == msco.intListProperty) success = false; + if (jsIntList == variantList) success = false; + + if (msco.intListProperty != msco.intListProperty) success = false; + if (msco.intListProperty == msco.intListProperty2) success = false; + if (msco.intListProperty == jsIntList) success = false; + if (msco.intListProperty == variantList) success = false; + + if (variantList == variantList) return false; + if (variantList == variantList2) return false; + if (variantList == msco.intListProperty) return false; + if (variantList == jsIntList) return false; + + if ((jsIntList == jsIntList2) != (jsIntList == msco.intListProperty)) success = false; + if ((jsIntList == jsIntList2) != (msco.intListProperty == msco.intListProperty2)) success = false; + if ((jsIntList == jsIntList) != (msco.intListProperty == msco.intListProperty)) success = false; + if ((jsIntList == variantList) != (msco.intListProperty == variantList)) success = false; + if ((variantList == jsIntList) != (variantList == msco.intListProperty)) success = false; + if ((msco.intListProperty == variantList) != (variantList == msco.intListProperty)) success = false; + } + + property bool referenceDeletion: false + function testReferenceDeletion() { + referenceDeletion = true; + var testObj = msco.generateTestObject(); + testObj.intListProperty = [1, 2, 3, 4, 5]; + var testSequence = testObj.intListProperty; + var prevString = testSequence.toString(); + var prevValueOf = testSequence.valueOf(); + var prevLength = testSequence.length; + msco.deleteTestObject(testObj); // delete referenced object. + if (testSequence.toString() == prevString) referenceDeletion = false; + if (testSequence.valueOf() == prevValueOf) referenceDeletion = false; + if (testSequence.length == prevLength) referenceDeletion = false; + } +} diff --git a/tests/auto/qml/qqmlecmascript/data/sequenceConversion.bindings.error.qml b/tests/auto/qml/qqmlecmascript/data/sequenceConversion.bindings.error.qml new file mode 100644 index 0000000000..9c87dd293e --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/sequenceConversion.bindings.error.qml @@ -0,0 +1,19 @@ +import QtQuick 2.0 +import Qt.test 1.0 + +Item { + id: root + objectName: "root" + + MySequenceConversionObject { + id: msco + objectName: "msco" + intListProperty: [ 1, 2, 3, 6, 7 ] + } + + MySequenceConversionObject { + id: mscoTwo + objectName: "mscoTwo" + boolListProperty: msco.intListProperty + } +} diff --git a/tests/auto/qml/qqmlecmascript/data/sequenceConversion.bindings.qml b/tests/auto/qml/qqmlecmascript/data/sequenceConversion.bindings.qml new file mode 100644 index 0000000000..8d83e9f9f5 --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/sequenceConversion.bindings.qml @@ -0,0 +1,28 @@ +import QtQuick 2.0 +import Qt.test 1.0 + +Item { + id: root + objectName: "root" + + MySequenceConversionObject { + id: msco + objectName: "msco" + intListProperty: [ 1, 2, 3, 6, 7 ] + } + + MySequenceConversionObject { + id: mscoTwo + objectName: "mscoTwo" + intListProperty: msco.intListProperty + } + + property variant boundSequence: msco.intListProperty + property int boundElement: msco.intListProperty[3] + property variant boundSequenceTwo: mscoTwo.intListProperty + + Component.onCompleted: { + msco.intListProperty[3] = 12; + mscoTwo.intListProperty[4] = 14; + } +} diff --git a/tests/auto/qml/qqmlecmascript/data/sequenceConversion.copy.qml b/tests/auto/qml/qqmlecmascript/data/sequenceConversion.copy.qml new file mode 100644 index 0000000000..f6614dad0c --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/sequenceConversion.copy.qml @@ -0,0 +1,160 @@ +import QtQuick 2.0 +import Qt.test 1.0 + +Item { + id: root + objectName: "root" + + MySequenceConversionObject { + id: msco + objectName: "msco" + } + + property bool success: true + + property variant intList + property variant qrealList + property variant boolList + property variant stringList + property variant urlList + property variant qstringList + + // this test ensures that the "copy resource" codepaths work + function testCopySequences() { + success = true; + + // create "copy resource" sequences + var jsIntList = msco.generateIntSequence(); + var jsQrealList = msco.generateQrealSequence(); + var jsBoolList = msco.generateBoolSequence(); + var jsStringList = msco.generateStringSequence(); + var jsUrlList = msco.generateUrlSequence(); + var jsQStringList = msco.generateQStringSequence(); + + if (jsIntList.toString() != [1, 2, 3].toString()) + success = false; + if (jsQrealList.toString() != [1.1, 2.2, 3.3].toString()) + success = false; + if (jsBoolList.toString() != [true, false, true].toString()) + success = false; + if (jsStringList.toString() != ["one", "two", "three"].toString()) + success = false; + if (jsUrlList.toString() != ["http://www.example1.com", "http://www.example2.com", "http://www.example3.com"].toString()) + success = false; + if (jsQStringList.toString() != ["one", "two", "three"].toString()) + success = false; + + // copy the sequence; should result in a new copy + intList = jsIntList; + qrealList = jsQrealList; + boolList = jsBoolList; + stringList = jsStringList; + urlList = jsUrlList; + qstringList = jsQStringList; + + // these operations shouldn't modify either variables - because + // we don't handle writing to the intermediate variant at list[index] + // for variant properties. + intList[1] = 8; + qrealList[1] = 8.8; + boolList[1] = true; + stringList[1] = "eight"; + urlList[1] = "http://www.example8.com"; + qstringList[1] = "eight"; + + if (jsIntList[1] == 8) + success = false; + if (jsQrealList[1] == 8.8) + success = false; + if (jsBoolList[1] == true) + success = false; + if (jsStringList[1] == "eight") + success = false; + if (jsUrlList[1] == "http://www.example8.com") + success = false; + if (jsQStringList[1] == "eight") + success = false; + + // assign a "copy resource" sequence to a QObject Q_PROPERTY + msco.intListProperty = intList; + msco.qrealListProperty = qrealList; + msco.boolListProperty = boolList; + msco.stringListProperty = stringList; + msco.urlListProperty = urlList; + msco.qstringListProperty = qstringList; + + if (msco.intListProperty.toString() != [1, 2, 3].toString()) + success = false; + if (msco.qrealListProperty.toString() != [1.1, 2.2, 3.3].toString()) + success = false; + if (msco.boolListProperty.toString() != [true, false, true].toString()) + success = false; + if (msco.stringListProperty.toString() != ["one", "two", "three"].toString()) + success = false; + if (msco.urlListProperty.toString() != ["http://www.example1.com", "http://www.example2.com", "http://www.example3.com"].toString()) + success = false; + if (msco.qstringListProperty.toString() != ["one", "two", "three"].toString()) + success = false; + + // now modify the QObject Q_PROPERTY (reference resource) sequences - shouldn't modify the copy resource sequences. + msco.intListProperty[2] = 9; + msco.qrealListProperty[2] = 9.9; + msco.boolListProperty[2] = false; + msco.stringListProperty[2] = "nine"; + msco.urlListProperty[2] = "http://www.example9.com"; + msco.qstringListProperty[2] = "nine"; + + if (intList[2] == 9) + success = false; + if (qrealList[2] == 9.9) + success = false; + if (boolList[2] == false) + success = false; + if (stringList[2] == "nine") + success = false; + if (urlList[2] == "http://www.example9.com") + success = false; + if (qstringList[2] == "nine") + success = false; + } + + property int intVal + property real qrealVal + property bool boolVal + property string stringVal + + // this test ensures that indexed access works for copy resource sequences. + function readSequenceCopyElements() { + success = true; + + var jsIntList = msco.generateIntSequence(); + var jsQrealList = msco.generateQrealSequence(); + var jsBoolList = msco.generateBoolSequence(); + var jsStringList = msco.generateStringSequence(); + + intVal = jsIntList[1]; + qrealVal = jsQrealList[1]; + boolVal = jsBoolList[1]; + stringVal = jsStringList[1]; + + if (intVal != 2) + success = false; + if (qrealVal != 2.2) + success = false; + if (boolVal != false) + success = false; + if (stringVal != "two") + success = false; + } + + // this test ensures that equality works for copy resource sequences. + function testEqualitySemantics() { + success = true; + + var jsIntList = msco.generateIntSequence(); + var jsIntList2 = msco.generateIntSequence(); + + if (jsIntList == jsIntList2) success = false; + if (jsIntList != jsIntList) success = false; + } +} diff --git a/tests/auto/qml/qqmlecmascript/data/sequenceConversion.indexes.qml b/tests/auto/qml/qqmlecmascript/data/sequenceConversion.indexes.qml new file mode 100644 index 0000000000..23f1e90417 --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/sequenceConversion.indexes.qml @@ -0,0 +1,89 @@ +import QtQuick 2.0 +import Qt.test 1.0 + +Item { + id: root + objectName: "root" + + MySequenceConversionObject { + id: msco + objectName: "msco" + } + + property bool success: false + + function verifyExpected(array, idx) { + for (var i = 0; i < idx; ++i) { + if (array[i] != i) { + return false; + } + } + return true; + } + + function indexedAccess() { + success = true; + + msco.intListProperty = [ 0, 1, 2, 3, 4 ]; + var expectedLength = msco.intListProperty.length; + var maxIndex = msco.maxIndex; + var tooBigIndex = msco.tooBigIndex; + var negativeIndex = msco.negativeIndex; + + // shouldn't be able to set the length > maxIndex. + msco.intListProperty.length = tooBigIndex; + if (msco.intListProperty.length != expectedLength) + success = false; + if (!verifyExpected(msco.intListProperty, 4)) + success = false; + + // shouldn't be able to set any index > maxIndex. + msco.intListProperty[tooBigIndex] = 12; + if (msco.intListProperty.length != expectedLength) + success = false; + if (!verifyExpected(msco.intListProperty, 4)) + success = false; + + // shouldn't be able to access any index > maxIndex. + var valueAtTBI = msco.intListProperty[tooBigIndex]; + if (valueAtTBI != undefined) + success = false; + if (!verifyExpected(msco.intListProperty, 4)) + success = false; + + // shouldn't be able to set the length to < 0 + msco.intListProperty.length = negativeIndex; + if (msco.intListProperty.length != expectedLength) + success = false; // shouldn't have changed. + if (!verifyExpected(msco.intListProperty, 4)) + success = false; + + // shouldn't be able to set any index < 0. + msco.intListProperty[negativeIndex] = 12; + if (msco.intListProperty.length != expectedLength) + success = false; + if (!verifyExpected(msco.intListProperty, 4)) + success = false; + + // shouldn't be able to access any index < 0. + var valueAtNI = msco.intListProperty[negativeIndex]; + if (valueAtNI != undefined) + success = false; + if (!verifyExpected(msco.intListProperty, 4)) + success = false; + + // NOTE: while these two operations are technically + // fine, we expect std::bad_alloc exceptions here + // which we handle in the sequence wrapper. + msco.intListProperty.length = maxIndex; + if (msco.intListProperty.length != expectedLength) + success = false; + if (!verifyExpected(msco.intListProperty, 4)) + success = false; + msco.intListProperty[maxIndex] = 15; + if (msco.intListProperty.length != expectedLength) + success = false; + if (!verifyExpected(msco.intListProperty, 4)) + success = false; + } +} diff --git a/tests/auto/qml/qqmlecmascript/data/sequenceConversion.read.error.qml b/tests/auto/qml/qqmlecmascript/data/sequenceConversion.read.error.qml new file mode 100644 index 0000000000..12a76d7e7d --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/sequenceConversion.read.error.qml @@ -0,0 +1,21 @@ +import QtQuick 2.0 +import Qt.test 1.0 + +Item { + id: root + objectName: "root" + + MySequenceConversionObject { + id: msco + objectName: "msco" + } + + property int pointListLength: 0 + property variant pointList + + function performTest() { + // we have NOT registered QList as a type + pointListLength = msco.pointListProperty.length; + pointList = msco.pointListProperty; + } +} diff --git a/tests/auto/qml/qqmlecmascript/data/sequenceConversion.read.qml b/tests/auto/qml/qqmlecmascript/data/sequenceConversion.read.qml new file mode 100644 index 0000000000..4a8a4a17b2 --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/sequenceConversion.read.qml @@ -0,0 +1,105 @@ +import QtQuick 2.0 +import Qt.test 1.0 + +Item { + id: root + objectName: "root" + + MySequenceConversionObject { + id: msco + objectName: "msco" + } + + property int intListLength: 0 + property variant intList + property int qrealListLength: 0 + property variant qrealList + property int boolListLength: 0 + property variant boolList + property int stringListLength: 0 + property variant stringList + property int urlListLength: 0 + property variant urlList + property int qstringListLength: 0 + property variant qstringList + + function readSequences() { + intListLength = msco.intListProperty.length; + intList = msco.intListProperty; + qrealListLength = msco.qrealListProperty.length; + qrealList = msco.qrealListProperty; + boolListLength = msco.boolListProperty.length; + boolList = msco.boolListProperty; + stringListLength = msco.stringListProperty.length; + stringList = msco.stringListProperty; + urlListLength = msco.urlListProperty.length; + urlList = msco.urlListProperty; + qstringListLength = msco.qstringListProperty.length; + qstringList = msco.qstringListProperty; + } + + property int intVal + property real qrealVal + property bool boolVal + property string stringVal + property url urlVal + property string qstringVal + + function readSequenceElements() { + intVal = msco.intListProperty[1]; + qrealVal = msco.qrealListProperty[1]; + boolVal = msco.boolListProperty[1]; + stringVal = msco.stringListProperty[1]; + urlVal = msco.urlListProperty[1]; + qstringVal = msco.qstringListProperty[1]; + } + + property bool enumerationMatches + function enumerateSequenceElements() { + var jsIntList = [1, 2, 3, 4, 5]; + msco.intListProperty = [1, 2, 3, 4, 5]; + + var jsIntListProps = [] + var seqIntListProps = [] + + enumerationMatches = true; + for (var i in jsIntList) { + jsIntListProps.push(i); + if (jsIntList[i] != msco.intListProperty[i]) { + enumerationMatches = false; + } + } + for (var j in msco.intListProperty) { + seqIntListProps.push(j); + if (jsIntList[j] != msco.intListProperty[j]) { + enumerationMatches = false; + } + } + + if (jsIntListProps.length != seqIntListProps.length) { + enumerationMatches = false; + } + + var emptyList = []; + msco.stringListProperty = [] + if (emptyList.toString() != msco.stringListProperty.toString()) { + enumerationMatches = false; + } + if (emptyList.valueOf() != msco.stringListProperty.valueOf()) { + enumerationMatches = false; + } + } + + property bool referenceDeletion: false + function testReferenceDeletion() { + referenceDeletion = true; + var testObj = msco.generateTestObject(); + testObj.intListProperty = [1, 2, 3, 4, 5]; + var testSequence = testObj.intListProperty; + if (testSequence[4] != 5) + referenceDeletion = false; + msco.deleteTestObject(testObj); // delete referenced object. + if (testSequence[4] == 5) + referenceDeletion = false; + } +} diff --git a/tests/auto/qml/qqmlecmascript/data/sequenceConversion.threads.qml b/tests/auto/qml/qqmlecmascript/data/sequenceConversion.threads.qml new file mode 100644 index 0000000000..aefad89ca4 --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/sequenceConversion.threads.qml @@ -0,0 +1,74 @@ +import QtQuick 2.0 +import Qt.test 1.0 + +Item { + id: root + objectName: "root" + + MySequenceConversionObject { + id: msco + objectName: "msco" + } + + property bool success: false + property bool finished: false + + function testIntSequence() { + msco.intListProperty = [ 0, 1, 2, 3, 4, 5, 6, 7 ]; + worker.sendSequence(msco.intListProperty); + } + + function testQrealSequence() { + msco.qrealListProperty = [ 0.1, 1.1, 2.1, 3.1, 4.1, 5.1, 6.1, 7.1 ]; + worker.sendSequence(msco.qrealListProperty); + } + + function testBoolSequence() { + msco.boolListProperty = [ false, true, true, false, false, true, false, true ]; + worker.sendSequence(msco.boolListProperty); + } + + function testStringSequence() { + msco.stringListProperty = [ "one", "two", "three", "four" ]; + worker.sendSequence(msco.stringListProperty); + } + + function testQStringSequence() { + msco.qstringListProperty = [ "one", "two", "three", "four" ]; + worker.sendSequence(msco.qstringListProperty); + } + + function testUrlSequence() { + msco.urlListProperty = [ "www.example1.com", "www.example2.com", "www.example3.com", "www.example4.com" ]; + worker.sendSequence(msco.urlListProperty); + } + + function testVariantSequence() { + msco.variantListProperty = [ "one", true, 3, "four" ]; + worker.sendSequence(msco.variantListProperty); + } + + WorkerScript { + id: worker + source: "threadScript.js" + + property variant expected + property variant response + + function sendSequence(seq) { + root.success = false; + root.finished = false; + worker.expected = seq; + worker.sendMessage(seq); + } + + onMessage: { + worker.response = messageObject; + if (worker.response.toString() == worker.expected.toString()) + root.success = true; + else + root.success = false; + root.finished = true; + } + } +} diff --git a/tests/auto/qml/qqmlecmascript/data/sequenceConversion.write.error.qml b/tests/auto/qml/qqmlecmascript/data/sequenceConversion.write.error.qml new file mode 100644 index 0000000000..75beafd1ee --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/sequenceConversion.write.error.qml @@ -0,0 +1,18 @@ +import QtQuick 2.0 +import Qt.test 1.0 + +Item { + id: root + objectName: "root" + + MySequenceConversionObject { + id: msco + objectName: "msco" + } + + function performTest() { + // we have NOT registered QList as a type + var pointList = [ Qt.point(7,7), Qt.point(8,8), Qt.point(9,9) ]; + msco.pointListProperty = pointList; // error. + } +} diff --git a/tests/auto/qml/qqmlecmascript/data/sequenceConversion.write.qml b/tests/auto/qml/qqmlecmascript/data/sequenceConversion.write.qml new file mode 100644 index 0000000000..812de043b7 --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/sequenceConversion.write.qml @@ -0,0 +1,109 @@ +import QtQuick 2.0 +import Qt.test 1.0 + +Item { + id: root + objectName: "root" + + MySequenceConversionObject { + id: msco + objectName: "msco" + } + + property bool success + + function writeSequences() { + success = true; + + var intList = [ 9, 8, 7, 6 ]; + msco.intListProperty = intList; + var qrealList = [ 9.9, 8.8, 7.7, 6.6 ]; + msco.qrealListProperty = qrealList; + var boolList = [ false, false, false, true ]; + msco.boolListProperty = boolList; + var stringList = [ "nine", "eight", "seven", "six" ] + msco.stringListProperty = stringList; + var urlList = [ "http://www.example9.com", "http://www.example8.com", "http://www.example7.com", "http://www.example6.com" ] + msco.urlListProperty = urlList; + var qstringList = [ "nine", "eight", "seven", "six" ] + msco.qstringListProperty = qstringList; + + if (msco.intListProperty[0] != 9 || msco.intListProperty[1] != 8 || msco.intListProperty[2] != 7 || msco.intListProperty[3] != 6) + success = false; + if (msco.qrealListProperty[0] != 9.9 || msco.qrealListProperty[1] != 8.8 || msco.qrealListProperty[2] != 7.7 || msco.qrealListProperty[3] != 6.6) + success = false; + if (msco.boolListProperty[0] != false || msco.boolListProperty[1] != false || msco.boolListProperty[2] != false || msco.boolListProperty[3] != true) + success = false; + if (msco.stringListProperty[0] != "nine" || msco.stringListProperty[1] != "eight" || msco.stringListProperty[2] != "seven" || msco.stringListProperty[3] != "six") + success = false; + if (msco.urlListProperty[0] != "http://www.example9.com" || msco.urlListProperty[1] != "http://www.example8.com" || msco.urlListProperty[2] != "http://www.example7.com" || msco.urlListProperty[3] != "http://www.example6.com") + success = false; + if (msco.qstringListProperty[0] != "nine" || msco.qstringListProperty[1] != "eight" || msco.qstringListProperty[2] != "seven" || msco.qstringListProperty[3] != "six") + success = false; + } + + function writeSequenceElements() { + // set up initial conditions. + writeSequences(); + success = true; + + // element set. + msco.intListProperty[3] = 2; + msco.qrealListProperty[3] = 2.2; + msco.boolListProperty[3] = false; + msco.stringListProperty[3] = "changed"; + msco.urlListProperty[3] = "http://www.examplechanged.com"; + msco.qstringListProperty[3] = "changed"; + + if (msco.intListProperty[0] != 9 || msco.intListProperty[1] != 8 || msco.intListProperty[2] != 7 || msco.intListProperty[3] != 2) + success = false; + if (msco.qrealListProperty[0] != 9.9 || msco.qrealListProperty[1] != 8.8 || msco.qrealListProperty[2] != 7.7 || msco.qrealListProperty[3] != 2.2) + success = false; + if (msco.boolListProperty[0] != false || msco.boolListProperty[1] != false || msco.boolListProperty[2] != false || msco.boolListProperty[3] != false) + success = false; + if (msco.stringListProperty[0] != "nine" || msco.stringListProperty[1] != "eight" || msco.stringListProperty[2] != "seven" || msco.stringListProperty[3] != "changed") + success = false; + if (msco.urlListProperty[0] != "http://www.example9.com" || msco.urlListProperty[1] != "http://www.example8.com" || msco.urlListProperty[2] != "http://www.example7.com" || msco.urlListProperty[3] != "http://www.examplechanged.com") + success = false; + if (msco.qstringListProperty[0] != "nine" || msco.qstringListProperty[1] != "eight" || msco.qstringListProperty[2] != "seven" || msco.qstringListProperty[3] != "changed") + success = false; + } + + function writeOtherElements() { + success = true; + var jsIntList = [1, 2, 3, 4, 5]; + msco.intListProperty = [1, 2, 3, 4, 5]; + + jsIntList[8] = 8; + msco.intListProperty[8] = 8; + if (jsIntList[8] != msco.intListProperty[8]) + success = false; + if (jsIntList.length != msco.intListProperty.length) + success = false; + + // NOTE: we can't exactly match the spec here -- we fill the sequence with a default (rather than empty) value + if (msco.intListProperty[5] != 0 || msco.intListProperty[6] != 0 || msco.intListProperty[7] != 0) + success = false; + + // should have no effect + var currLength = jsIntList.length; + jsIntList.someThing = 9; + msco.intListProperty.someThing = 9; + if (msco.intListProperty.length != currLength) + success = false; + } + + property bool referenceDeletion: false + function testReferenceDeletion() { + referenceDeletion = true; + var testObj = msco.generateTestObject(); + testObj.intListProperty = [1, 2, 3, 4, 5]; + var testSequence = testObj.intListProperty; + if (testSequence[4] != 5) + referenceDeletion = false; + msco.deleteTestObject(testObj); // delete referenced object. + testSequence[4] = 5; // shouldn't work, since referenced object no longer exists. + if (testSequence[4] == 5) + referenceDeletion = false; + } +} diff --git a/tests/auto/qml/qqmlecmascript/data/sharedAttachedObject.qml b/tests/auto/qml/qqmlecmascript/data/sharedAttachedObject.qml new file mode 100644 index 0000000000..b967f0984c --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/sharedAttachedObject.qml @@ -0,0 +1,16 @@ +import Qt.test 1.0 +import QtQuick 2.0 + +MyQmlObject { + id: root + property bool test1: false + property bool test2: false + + MyQmlObject.value2: 7 + + Component.onCompleted: { + test1 = root.MyQmlObject.value2 == 7; + test2 = root.MyQmlObjectAlias.value2 == 7; + } +} + diff --git a/tests/auto/qml/qqmlecmascript/data/shutdownErrors.qml b/tests/auto/qml/qqmlecmascript/data/shutdownErrors.qml new file mode 100644 index 0000000000..b30aa8b4cd --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/shutdownErrors.qml @@ -0,0 +1,13 @@ +import QtQuick 2.0 + +Item { + property int test: myObject.object.a + + Item { + id: myObject + property QtObject object; + object: QtObject { + property int a: 10 + } + } +} diff --git a/tests/auto/qml/qqmlecmascript/data/signalAssignment.1.qml b/tests/auto/qml/qqmlecmascript/data/signalAssignment.1.qml new file mode 100644 index 0000000000..fbd09142f7 --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/signalAssignment.1.qml @@ -0,0 +1,5 @@ +import Qt.test 1.0 + +MyQmlObject { + onBasicSignal: setString('pass') +} diff --git a/tests/auto/qml/qqmlecmascript/data/signalAssignment.2.qml b/tests/auto/qml/qqmlecmascript/data/signalAssignment.2.qml new file mode 100644 index 0000000000..6467c42bb9 --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/signalAssignment.2.qml @@ -0,0 +1,5 @@ +import Qt.test 1.0 + +MyQmlObject { + onArgumentSignal: setString('pass ' + a + ' ' + b + ' ' + c + ' ' + d + ' ' + e) +} diff --git a/tests/auto/qml/qqmlecmascript/data/signalHandlers.qml b/tests/auto/qml/qqmlecmascript/data/signalHandlers.qml new file mode 100644 index 0000000000..975be1b2ad --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/signalHandlers.qml @@ -0,0 +1,60 @@ +import Qt.test 1.0 +import QtQuick 2.0 + +QtObject { + id: root + + property int count: 0 + signal testSignal + onTestSignal: count++ + + property int funcCount: 0 + function testFunction() { + funcCount++; + } + + //should increment count + function testSignalCall() { + testSignal() + } + + //should NOT increment count, and should throw an exception + property string errorString + function testSignalHandlerCall() { + try { + onTestSignal() + } catch (error) { + errorString = error.toString(); + } + } + + //should increment funcCount once + function testSignalConnection() { + testSignal.connect(testFunction) + testSignal(); + testSignal.disconnect(testFunction) + testSignal(); + } + + //should increment funcCount once + function testSignalHandlerConnection() { + onTestSignal.connect(testFunction) + testSignal(); + onTestSignal.disconnect(testFunction) + testSignal(); + } + + //should be defined + property bool definedResult: false + function testSignalDefined() { + if (testSignal !== undefined) + definedResult = true; + } + + //should be defined + property bool definedHandlerResult: false + function testSignalHandlerDefined() { + if (onTestSignal !== undefined) + definedHandlerResult = true; + } +} diff --git a/tests/auto/qml/qqmlecmascript/data/signalParameterTypes.qml b/tests/auto/qml/qqmlecmascript/data/signalParameterTypes.qml new file mode 100644 index 0000000000..4fc2dab943 --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/signalParameterTypes.qml @@ -0,0 +1,18 @@ +import Qt.test 1.0 + +MyQmlObject +{ + id: root + property int intProperty + property real realProperty + property color colorProperty + property variant variantProperty + property int enumProperty + property int qtEnumProperty + + signal mySignal(int a, real b, color c, variant d, int e, int f) + + onMySignal: { intProperty = a; realProperty = b; colorProperty = c; variantProperty = d; enumProperty = e; qtEnumProperty = f; } + + onBasicSignal: root.mySignal(10, 19.2, Qt.rgba(1, 1, 0, 1), Qt.rgba(1, 0, 1, 1), MyQmlObject.EnumValue3, Qt.LeftButton) +} diff --git a/tests/auto/qml/qqmlecmascript/data/signalTriggeredBindings.qml b/tests/auto/qml/qqmlecmascript/data/signalTriggeredBindings.qml new file mode 100644 index 0000000000..d98d7e9c81 --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/signalTriggeredBindings.qml @@ -0,0 +1,20 @@ +import Qt.test 1.0 +import QtQuick 2.0 + +MyQmlObject { + property real base: 50 + property alias test1: myObject.test1 + property alias test2: myObject.test2 + + objectProperty: QtObject { + id: myObject + property real test1: base + property real test2: Math.max(0, base) + } + + // Signal with no args + onBasicSignal: base = 200 + // Signal with args + onArgumentSignal: base = 400 +} + diff --git a/tests/auto/qml/qqmlecmascript/data/signalWithJSValueInVariant.qml b/tests/auto/qml/qqmlecmascript/data/signalWithJSValueInVariant.qml new file mode 100644 index 0000000000..a6f1aa381a --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/signalWithJSValueInVariant.qml @@ -0,0 +1,12 @@ +import Qt.test 1.0 + +MyQmlObject { + property string expression + property string compare + property bool pass: false + onSignalWithVariant: + { + var expected = eval(expression); + pass = eval(compare)(arg, expected); + } +} diff --git a/tests/auto/qml/qqmlecmascript/data/signalWithQJSValue.qml b/tests/auto/qml/qqmlecmascript/data/signalWithQJSValue.qml new file mode 100644 index 0000000000..36f481d533 --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/signalWithQJSValue.qml @@ -0,0 +1,14 @@ +import Qt.test 1.0 + +MyQmlObject { + property string expression + property string compare + property bool pass: false + + onSignalWithQJSValue: + { + qjsvalueMethod(arg); + var expected = eval(expression); + pass = eval(compare)(arg, expected); + } +} diff --git a/tests/auto/qml/qqmlecmascript/data/signalWithUnknownTypes.qml b/tests/auto/qml/qqmlecmascript/data/signalWithUnknownTypes.qml new file mode 100644 index 0000000000..49293edfb3 --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/signalWithUnknownTypes.qml @@ -0,0 +1,5 @@ +import Qt.test 1.0 + +MyQmlObject { + onSignalWithUnknownType: variantMethod(arg); +} diff --git a/tests/auto/qml/qqmlecmascript/data/strictlyEquals.qml b/tests/auto/qml/qqmlecmascript/data/strictlyEquals.qml new file mode 100644 index 0000000000..e709e3a8bd --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/strictlyEquals.qml @@ -0,0 +1,17 @@ +import QtQuick 2.0 + +QtObject { + property bool test1: (a === true) + property bool test2: !(a === false) + property bool test3: (b === 11.2) + property bool test4: !(b === 9) + property bool test5: (c === 9) + property bool test6: !(c === 13) + property bool test7: (d === "Hello world") + property bool test8: !(d === "Hi") + + property bool a: true + property real b: 11.2 + property int c: 9 + property string d: "Hello world" +} diff --git a/tests/auto/qml/qqmlecmascript/data/stringArg.qml b/tests/auto/qml/qqmlecmascript/data/stringArg.qml new file mode 100644 index 0000000000..7019af9da5 --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/stringArg.qml @@ -0,0 +1,49 @@ +import QtQuick 2.0 + +Item { + id: root + property bool returnValue: false + + property string first + property string second + property string third + property string fourth + property string fifth + property string sixth + property string seventh + property string eighth + property string ninth + + function success() { + var a = "Value is %1"; + for (var ii = 0; ii < 10; ++ii) { + first = a.arg("string"); + second = a.arg(1); + third = a.arg(true); + fourth = a.arg(3.345); + fifth = a.arg(undefined); + sixth = a.arg(null); + seventh = a.arg({"test":5}); + eighth = a.arg({"test":5, "again":6}); + } + + if (first != "Value is string") returnValue = false; + if (second != "Value is 1") returnValue = false; + if (third != "Value is true") returnValue = false; + if (fourth != "Value is 3.345") returnValue = false; + if (fifth != "Value is undefined") returnValue = false; + if (sixth != "Value is null") returnValue = false; + if (seventh != "Value is [Object object]") returnValue = false; + if (eighth != "Value is [Object object]") returnValue = false; + returnValue = true; + } + + function failure() { + returnValue = true; + var a = "Value is %1"; + for (var ii = 0; ii < 10; ++ii) { + ninth = a.arg(1,2,3,4); + } + returnValue = false; + } +} diff --git a/tests/auto/qml/qqmlecmascript/data/switchStatement.1.qml b/tests/auto/qml/qqmlecmascript/data/switchStatement.1.qml new file mode 100644 index 0000000000..3c7870839d --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/switchStatement.1.qml @@ -0,0 +1,33 @@ +import Qt.test 1.0 + +MyQmlObject { + value: { + var value = 0 + switch (stringProperty) { + case "A": + value = value + 1 + value = value + 1 + /* should fall through */ + case "S": + value = value + 1 + value = value + 1 + value = value + 1 + break; + case "D": { // with curly braces + value = value + 1 + value = value + 1 + value = value + 1 + break; + } + case "F": { + value = value + 1 + value = value + 1 + value = value + 1 + } + /* should fall through */ + default: + value = value + 1 + } + } +} + diff --git a/tests/auto/qml/qqmlecmascript/data/switchStatement.2.qml b/tests/auto/qml/qqmlecmascript/data/switchStatement.2.qml new file mode 100644 index 0000000000..928d36be1f --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/switchStatement.2.qml @@ -0,0 +1,33 @@ +import Qt.test 1.0 + +MyQmlObject { + value: { + var value = 0 + switch (stringProperty) { + case "A": + value = value + 1 + value = value + 1 + /* should fall through */ + case "S": + value = value + 1 + value = value + 1 + value = value + 1 + break; + default: + value = value + 1 + case "D": { // with curly braces + value = value + 1 + value = value + 1 + value = value + 1 + break; + } + case "F": { + value = value + 1 + value = value + 1 + value = value + 1 + } + /* should fall through */ + } + } +} + diff --git a/tests/auto/qml/qqmlecmascript/data/switchStatement.3.qml b/tests/auto/qml/qqmlecmascript/data/switchStatement.3.qml new file mode 100644 index 0000000000..5b05d88767 --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/switchStatement.3.qml @@ -0,0 +1,33 @@ +import Qt.test 1.0 + +MyQmlObject { + value: { + var value = 0 + switch (stringProperty) { + default: + value = value + 1 + case "A": + value = value + 1 + value = value + 1 + /* should fall through */ + case "S": + value = value + 1 + value = value + 1 + value = value + 1 + break; + case "D": { // with curly braces + value = value + 1 + value = value + 1 + value = value + 1 + break; + } + case "F": { + value = value + 1 + value = value + 1 + value = value + 1 + } + /* should fall through */ + } + } +} + diff --git a/tests/auto/qml/qqmlecmascript/data/switchStatement.4.qml b/tests/auto/qml/qqmlecmascript/data/switchStatement.4.qml new file mode 100644 index 0000000000..43ba199a04 --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/switchStatement.4.qml @@ -0,0 +1,31 @@ +import Qt.test 1.0 + +MyQmlObject { + value: { + var value = 0 + switch (stringProperty) { + case "A": + value = value + 1 + value = value + 1 + /* should fall through */ + case "S": + value = value + 1 + value = value + 1 + value = value + 1 + break; + case "D": { // with curly braces + value = value + 1 + value = value + 1 + value = value + 1 + break; + } + case "F": { + value = value + 1 + value = value + 1 + value = value + 1 + } + /* should fall through */ + } + } +} + diff --git a/tests/auto/qml/qqmlecmascript/data/switchStatement.5.qml b/tests/auto/qml/qqmlecmascript/data/switchStatement.5.qml new file mode 100644 index 0000000000..e0fc62e392 --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/switchStatement.5.qml @@ -0,0 +1,12 @@ +import Qt.test 1.0 + +MyQmlObject { + value: { + var value = 0 + switch (stringProperty) { + default: + value = value + 1 + } + } +} + diff --git a/tests/auto/qml/qqmlecmascript/data/switchStatement.6.qml b/tests/auto/qml/qqmlecmascript/data/switchStatement.6.qml new file mode 100644 index 0000000000..6fb71eb345 --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/switchStatement.6.qml @@ -0,0 +1,13 @@ +import Qt.test 1.0 + +MyQmlObject { + function one(kind) { return 123 } + function two(kind) { return 321 } + + value: switch (stringProperty) { + case "A": case "S": one(stringProperty); break; + case "D": case "F": two(stringProperty); break; + default: 0 + } +} + diff --git a/tests/auto/qml/qqmlecmascript/data/threadScript.js b/tests/auto/qml/qqmlecmascript/data/threadScript.js new file mode 100644 index 0000000000..9f94de1bc1 --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/threadScript.js @@ -0,0 +1,4 @@ +WorkerScript.onMessage = function(msg) { + WorkerScript.sendMessage(msg); +} + diff --git a/tests/auto/qml/qqmlecmascript/data/transientErrors.2.qml b/tests/auto/qml/qqmlecmascript/data/transientErrors.2.qml new file mode 100644 index 0000000000..c44acf4fd1 --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/transientErrors.2.qml @@ -0,0 +1,14 @@ +import QtQuick 2.0 + +QtObject { + id: root + + property variant a: 10 + property int x: 10 + property int test: a.x + + Component.onCompleted: { + a = 11; + a = root; + } +} diff --git a/tests/auto/qml/qqmlecmascript/data/transientErrors.qml b/tests/auto/qml/qqmlecmascript/data/transientErrors.qml new file mode 100644 index 0000000000..451bb51996 --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/transientErrors.qml @@ -0,0 +1,10 @@ +import QtQuick 2.0 + +QtObject { + property variant obj: nested + + property variant obj2 + obj2: NestedTypeTransientErrors { + id: nested + } +} diff --git a/tests/auto/qml/qqmlecmascript/data/tryStatement.1.qml b/tests/auto/qml/qqmlecmascript/data/tryStatement.1.qml new file mode 100644 index 0000000000..71cc67a941 --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/tryStatement.1.qml @@ -0,0 +1,13 @@ +import Qt.test 1.0 + +MyQmlObject { + property int defaultValue: 123 + + function go() { + undefinedObject.method() // this call will throw an exception + return 321 + } + + value: try { go() } catch(e) { defaultValue } +} + diff --git a/tests/auto/qml/qqmlecmascript/data/tryStatement.2.qml b/tests/auto/qml/qqmlecmascript/data/tryStatement.2.qml new file mode 100644 index 0000000000..e7fca0bff7 --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/tryStatement.2.qml @@ -0,0 +1,11 @@ +import Qt.test 1.0 + +MyQmlObject { + property int defaultValue: 123 + + function go() { + return 321 + } + + value: try { go() } catch(e) { defaultValue } +} diff --git a/tests/auto/qml/qqmlecmascript/data/tryStatement.3.qml b/tests/auto/qml/qqmlecmascript/data/tryStatement.3.qml new file mode 100644 index 0000000000..04b39f73d5 --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/tryStatement.3.qml @@ -0,0 +1,13 @@ +import Qt.test 1.0 + +MyQmlObject { + property int defaultValue: 123 + + function go() { + undefinedObject.method() // this call will throw an exception + return 321 + } + + value: try { var p = go() } catch(e) { var p = defaultValue } finally { p == 123 } +} + diff --git a/tests/auto/qml/qqmlecmascript/data/tryStatement.4.qml b/tests/auto/qml/qqmlecmascript/data/tryStatement.4.qml new file mode 100644 index 0000000000..231aaf0683 --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/tryStatement.4.qml @@ -0,0 +1,12 @@ +import Qt.test 1.0 + +MyQmlObject { + property int defaultValue: 123 + + function go() { + return 321 + } + + value: try { var p = go() } catch(e) { var p = defaultValue } finally { p == 321 } +} + diff --git a/tests/auto/qml/qqmlecmascript/data/typeOf.js b/tests/auto/qml/qqmlecmascript/data/typeOf.js new file mode 100644 index 0000000000..16a34234c0 --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/typeOf.js @@ -0,0 +1,25 @@ +var test1 = typeof a + +var b = {} +var test2 = typeof b + +var c = 5 +var test3 = typeof c + +var d = "hello world" +var test4 = typeof d + +var e = function() {} +var test5 = typeof e + +var f = null +var test6 = typeof f + +var g = undefined +var test7 = typeof g + +var h = true +var test8 = typeof h + +var i = [] +var test9 = typeof i diff --git a/tests/auto/qml/qqmlecmascript/data/typeOf.qml b/tests/auto/qml/qqmlecmascript/data/typeOf.qml new file mode 100644 index 0000000000..28f7debed5 --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/typeOf.qml @@ -0,0 +1,26 @@ +import QtQuick 2.0 +import "typeOf.js" as TypeOf + +QtObject { + property string test1 + property string test2 + property string test3 + property string test4 + property string test5 + property string test6 + property string test7 + property string test8 + property string test9 + + Component.onCompleted: { + test1 = TypeOf.test1 + test2 = TypeOf.test2 + test3 = TypeOf.test3 + test4 = TypeOf.test4 + test5 = TypeOf.test5 + test6 = TypeOf.test6 + test7 = TypeOf.test7 + test8 = TypeOf.test8 + test9 = TypeOf.test9 + } +} diff --git a/tests/auto/qml/qqmlecmascript/data/unaryExpression.qml b/tests/auto/qml/qqmlecmascript/data/unaryExpression.qml new file mode 100644 index 0000000000..0d40bec710 --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/unaryExpression.qml @@ -0,0 +1,9 @@ +import QtQuick 2.0 + +Item { + + Component.onCompleted: +++bar + + property int bar: 0 +} diff --git a/tests/auto/qml/qqmlecmascript/data/undefinedResetsProperty.2.qml b/tests/auto/qml/qqmlecmascript/data/undefinedResetsProperty.2.qml new file mode 100644 index 0000000000..e73d38e2ce --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/undefinedResetsProperty.2.qml @@ -0,0 +1,10 @@ +import Qt.test 1.0 + +MyQmlObject { + resettableProperty: 19 + + function doReset() { + resettableProperty = undefined; + } +} + diff --git a/tests/auto/qml/qqmlecmascript/data/undefinedResetsProperty.qml b/tests/auto/qml/qqmlecmascript/data/undefinedResetsProperty.qml new file mode 100644 index 0000000000..eceff60aa1 --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/undefinedResetsProperty.qml @@ -0,0 +1,7 @@ +import Qt.test 1.0 + +MyQmlObject { + property bool setUndefined: false + + resettableProperty: setUndefined?undefined:92 +} diff --git a/tests/auto/qml/qqmlecmascript/data/urlListProperty.qml b/tests/auto/qml/qqmlecmascript/data/urlListProperty.qml new file mode 100644 index 0000000000..eeb0815f09 --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/urlListProperty.qml @@ -0,0 +1,41 @@ +import QtQuick 2.0 +import Qt.test 1.0 + +Item { + // single url assignment to url list property + MySequenceConversionObject { + id: msco1 + objectName: "msco1" + } + + // single url binding to url list property + MySequenceConversionObject { + id: msco2 + objectName: "msco2" + urlListProperty: "http://qt-project.org/?get%3cDATA%3e"; + } + + // multiple url assignment to url list property + MySequenceConversionObject { + id: msco3 + objectName: "msco3" + } + + // multiple url binding to url list property + MySequenceConversionObject { + id: msco4 + objectName: "msco4" + urlListProperty: [ + "http://qt-project.org/?get%3cDATA%3e", + "http://qt-project.org/?get%3cDATA%3e" + ]; + } + + Component.onCompleted: { + msco1.urlListProperty = "http://qt-project.org/?get%3cDATA%3e"; + msco3.urlListProperty = [ + "http://qt-project.org/?get%3cDATA%3e", + "http://qt-project.org/?get%3cDATA%3e" + ]; + } +} diff --git a/tests/auto/qml/qqmlecmascript/data/urlProperty.1.qml b/tests/auto/qml/qqmlecmascript/data/urlProperty.1.qml new file mode 100644 index 0000000000..451cb03206 --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/urlProperty.1.qml @@ -0,0 +1,10 @@ +import QtQuick 2.0 +import Qt.test 1.0 + +MyQmlObject { + property bool result + urlProperty: stringProperty + "/index.html" + intProperty: if (urlProperty) 123; else 321 + value: urlProperty == stringProperty + "/index.html" + result: urlProperty == urlProperty +} diff --git a/tests/auto/qml/qqmlecmascript/data/urlProperty.2.qml b/tests/auto/qml/qqmlecmascript/data/urlProperty.2.qml new file mode 100644 index 0000000000..0e8bdaec96 --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/urlProperty.2.qml @@ -0,0 +1,10 @@ +import QtQuick 2.0 +import Qt.test 1.0 + +MyQmlObject { + property bool result + stringProperty: "http://example.org" + urlProperty: stringProperty + "/?get%3cDATA%3e" + value: urlProperty == stringProperty + "/?get%3cDATA%3e" + result: urlProperty == urlProperty +} diff --git a/tests/auto/qml/qqmlecmascript/data/v8bindingException.qml b/tests/auto/qml/qqmlecmascript/data/v8bindingException.qml new file mode 100644 index 0000000000..ff203e23e3 --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/v8bindingException.qml @@ -0,0 +1,21 @@ +import QtQuick 2.0 + +// This test uses a multi-line string which has \r-terminated +// string fragments. The expression rewriter deliberately doesn't +// handle \r-terminated string fragments (see QTBUG-24064) and thus +// this test ensures that we don't crash when we encounter a +// non-compilable binding such as this one. + +Item { + id: root + + Component { + id: comp + Text { + property var value: "," + text: 'multi line ' + value + 'str ings' + } + } + + Component.onCompleted: comp.createObject(root, { "value": undefined }) +} diff --git a/tests/auto/qml/qqmlecmascript/data/v8functionException.qml b/tests/auto/qml/qqmlecmascript/data/v8functionException.qml new file mode 100644 index 0000000000..51df1c65d8 --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/v8functionException.qml @@ -0,0 +1,15 @@ +import QtQuick 2.0 + +// This test uses a multi-line string which has \r-terminated +// string fragments. The expression rewriter deliberately doesn't +// handle \r-terminated string fragments (see QTBUG-24064) and thus +// this test ensures that we don't crash when the client attempts +// to invoke a non-compiled dynamic slot. + +Item { + id: root + + function dynamicSlot() { + var someString = "Hello, this is a multiline string"; + } +} diff --git a/tests/auto/qml/qqmlecmascript/data/valueTypeFunctions.qml b/tests/auto/qml/qqmlecmascript/data/valueTypeFunctions.qml new file mode 100644 index 0000000000..33b4a68c40 --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/valueTypeFunctions.qml @@ -0,0 +1,6 @@ +import Qt.test 1.0 + +MyTypeObject { + rectProperty: Qt.rect(0,0,100,100) + rectFProperty: Qt.rect(0,0.5,100,99.5) +} diff --git a/tests/auto/qml/qqmlecmascript/data/variantsAssignedUndefined.qml b/tests/auto/qml/qqmlecmascript/data/variantsAssignedUndefined.qml new file mode 100644 index 0000000000..6aa8480365 --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/variantsAssignedUndefined.qml @@ -0,0 +1,9 @@ +import QtQuick 2.0 + +QtObject { + property bool runTest: false + onRunTestChanged: test1 = undefined + + property variant test1: 10 + property variant test2: (runTest == false)?11:undefined +} diff --git a/tests/auto/qml/qqmlecmascript/data/withStatement.1.qml b/tests/auto/qml/qqmlecmascript/data/withStatement.1.qml new file mode 100644 index 0000000000..28f0c08451 --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/withStatement.1.qml @@ -0,0 +1,14 @@ +import Qt.test 1.0 + +MyQmlObject { + property var other: MyQmlObject { + intProperty: 123 + + function go() { + return intProperty; + } + } + + value: with(other) go() +} + diff --git a/tests/auto/qml/qqmlecmascript/data/writeAttachedProperty.qml b/tests/auto/qml/qqmlecmascript/data/writeAttachedProperty.qml new file mode 100644 index 0000000000..3854b069a0 --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/writeAttachedProperty.qml @@ -0,0 +1,6 @@ +import QtQuick 2.0 +import Qt.test 1.0 + +QtObject { + function writeValue2() { MyQmlObject.value2 = 9 } +} diff --git a/tests/auto/qml/qqmlecmascript/data/writeRemovesBinding.qml b/tests/auto/qml/qqmlecmascript/data/writeRemovesBinding.qml new file mode 100644 index 0000000000..a1ba5df071 --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/writeRemovesBinding.qml @@ -0,0 +1,46 @@ +import QtQuick 2.0 + +QtObject { + id: root + + property bool test: false + + property real data: 9 + property real binding: data + + property alias aliasProperty: root.aliasBinding + property real aliasBinding: data + + Component.onCompleted: { + // Non-aliased properties + if (binding != 9) return; + + data = 11; + if (binding != 11) return; + + binding = 6; + if (binding != 6) return; + + data = 3; + if (binding != 6) return; + + + // Writing through an aliased property + if (aliasProperty != 3) return; + if (aliasBinding != 3) return; + + data = 4; + if (aliasProperty != 4) return; + if (aliasBinding != 4) return; + + aliasProperty = 19; + if (aliasProperty != 19) return; + if (aliasBinding != 19) return; + + data = 5; + if (aliasProperty != 19) return; + if (aliasBinding != 19) return; + + test = true; + } +} diff --git a/tests/auto/qml/qqmlecmascript/qqmlecmascript.pro b/tests/auto/qml/qqmlecmascript/qqmlecmascript.pro new file mode 100644 index 0000000000..b07e4393a9 --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/qqmlecmascript.pro @@ -0,0 +1,22 @@ +CONFIG += testcase +TARGET = tst_qqmlecmascript +macx:CONFIG -= app_bundle + +SOURCES += tst_qqmlecmascript.cpp \ + testtypes.cpp \ + ../../shared/testhttpserver.cpp +HEADERS += testtypes.h \ + ../../shared/testhttpserver.h +INCLUDEPATH += ../../shared + +include (../../shared/util.pri) + +# QMAKE_CXXFLAGS = -fprofile-arcs -ftest-coverage +# LIBS += -lgcov + +testDataFiles.files = data +testDataFiles.path = . +DEPLOYMENT += testDataFiles + +CONFIG += parallel_test +QT += core-private gui-private v8-private qml-private network widgets testlib diff --git a/tests/auto/qml/qqmlecmascript/testtypes.cpp b/tests/auto/qml/qqmlecmascript/testtypes.cpp new file mode 100644 index 0000000000..78119cb776 --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/testtypes.cpp @@ -0,0 +1,210 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include "testtypes.h" +#include +#include +#include +#include + +class BaseExtensionObject : public QObject +{ + Q_OBJECT + Q_PROPERTY(int baseExtendedProperty READ extendedProperty WRITE setExtendedProperty NOTIFY extendedPropertyChanged) +public: + BaseExtensionObject(QObject *parent) : QObject(parent), m_value(0) {} + + int extendedProperty() const { return m_value; } + void setExtendedProperty(int v) { m_value = v; emit extendedPropertyChanged(); } + +signals: + void extendedPropertyChanged(); +private: + int m_value; +}; + +class ExtensionObject : public QObject +{ + Q_OBJECT + Q_PROPERTY(int extendedProperty READ extendedProperty WRITE setExtendedProperty NOTIFY extendedPropertyChanged) +public: + ExtensionObject(QObject *parent) : QObject(parent), m_value(0) {} + + int extendedProperty() const { return m_value; } + void setExtendedProperty(int v) { m_value = v; emit extendedPropertyChanged(); } + +signals: + void extendedPropertyChanged(); +private: + int m_value; +}; + +class DefaultPropertyExtensionObject : public QObject +{ + Q_OBJECT + Q_CLASSINFO("DefaultProperty", "firstProperty") +public: + DefaultPropertyExtensionObject(QObject *parent) : QObject(parent) {} +}; + +class QWidgetDeclarativeUI : public QObject +{ + Q_OBJECT + + Q_PROPERTY(int width READ width WRITE setWidth NOTIFY widthChanged) + +signals: + void widthChanged(); + +public: + QWidgetDeclarativeUI(QObject *other) : QObject(other) { } + +public: + int width() const { return 0; } + void setWidth(int) { } +}; + +void MyQmlObject::v8function(QQmlV8Function *args) +{ + const char *error = "Exception thrown from within QObject slot"; + v8::ThrowException(v8::Exception::Error(v8::String::New(error))); +} + +static QJSValue script_api(QQmlEngine *engine, QJSEngine *scriptEngine) +{ + Q_UNUSED(engine) + + static int testProperty = 13; + QJSValue v = scriptEngine->newObject(); + v.setProperty("scriptTestProperty", testProperty++); + return v; +} + +static QJSValue readonly_script_api(QQmlEngine *engine, QJSEngine *scriptEngine) +{ + Q_UNUSED(engine) + + static int testProperty = 42; + QJSValue v = scriptEngine->newObject(); + v.setProperty("scriptTestProperty", testProperty++); + + // now freeze it so that it's read-only + QJSValue freezeFunction = scriptEngine->evaluate("(function(obj) { return Object.freeze(obj); })"); + v = freezeFunction.call(QJSValueList() << v); + + return v; +} + +static QObject *qobject_api(QQmlEngine *engine, QJSEngine *scriptEngine) +{ + Q_UNUSED(engine) + Q_UNUSED(scriptEngine) + + testQObjectApi *o = new testQObjectApi(); + o->setQObjectTestProperty(20); + o->setQObjectTestWritableProperty(50); + return o; +} + +static QObject *qobject_api_engine_parent(QQmlEngine *engine, QJSEngine *scriptEngine) +{ + Q_UNUSED(scriptEngine) + + static int testProperty = 26; + testQObjectApi *o = new testQObjectApi(engine); + o->setQObjectTestProperty(testProperty++); + return o; +} + +void registerTypes() +{ + qmlRegisterType("Qt.test", 1,0, "MyQmlObjectAlias"); + qmlRegisterType("Qt.test", 1,0, "MyQmlObject"); + qmlRegisterType("Qt.test", 1,0, "MyDeferredObject"); + qmlRegisterType("Qt.test", 1,0, "MyQmlContainer"); + qmlRegisterExtendedType("Qt.test", 1,0, "MyBaseExtendedObject"); + qmlRegisterExtendedType("Qt.test", 1,0, "MyExtendedObject"); + qmlRegisterType("Qt.test", 1,0, "MyTypeObject"); + qmlRegisterType("Qt.test", 1,0, "MyDerivedObject"); + qmlRegisterType("Qt.test", 1,0, "NumberAssignment"); + qmlRegisterExtendedType("Qt.test", 1,0, "DefaultPropertyExtendedObject"); + qmlRegisterType("Qt.test", 1,0, "OverrideDefaultPropertyObject"); + qmlRegisterType("Qt.test",1,0,"MyRevisionedClass"); + qmlRegisterType("Qt.test", 1,0, "MyDeleteObject"); + qmlRegisterType("Qt.test",1,1,"MyRevisionedClass"); + + // test scarce resource property binding post-evaluation optimisation + // and for testing memory usage in property var circular reference test + qmlRegisterType("Qt.test", 1,0, "MyScarceResourceObject"); + + // Register the uncreatable base class + qmlRegisterRevision("Qt.test",1,1); + // MyRevisionedSubclass 1.0 uses MyRevisionedClass revision 0 + qmlRegisterType("Qt.test",1,0,"MyRevisionedSubclass"); + // MyRevisionedSubclass 1.1 uses MyRevisionedClass revision 1 + qmlRegisterType("Qt.test",1,1,"MyRevisionedSubclass"); + + qmlRegisterExtendedType("Qt.test",1,0,"QWidget"); + qmlRegisterType("Qt.test",1,0,"QPlainTextEdit"); + + qRegisterMetaType("MyQmlObject::MyType"); + + qmlRegisterModuleApi("Qt.test",1,0,script_api); // register (script) module API for an existing uri which contains elements + qmlRegisterModuleApi("Qt.test",1,0,qobject_api); // register (qobject) for an existing uri for which another module API was previously regd. Should replace! + qmlRegisterModuleApi("Qt.test.scriptApi",1,0,script_api); // register (script) module API for a uri which doesn't contain elements + qmlRegisterModuleApi("Qt.test.scriptApi",2,0,readonly_script_api); // register (script) module API for a uri which doesn't contain elements - will be made read-only + qmlRegisterModuleApi("Qt.test.qobjectApi",1,0,qobject_api); // register (qobject) module API for a uri which doesn't contain elements + qmlRegisterModuleApi("Qt.test.qobjectApi",1,3,qobject_api); // register (qobject) module API for a uri which doesn't contain elements, minor version set + qmlRegisterModuleApi("Qt.test.qobjectApi",2,0,qobject_api); // register (qobject) module API for a uri which doesn't contain elements, major version set + qmlRegisterModuleApi("Qt.test.qobjectApiParented",1,0,qobject_api_engine_parent); // register (parented qobject) module API for a uri which doesn't contain elements + + qRegisterMetaType("MyEnum2"); + qRegisterMetaType("Qt::MouseButtons"); + + qmlRegisterType("Qt.test", 1, 0, "CircularReferenceObject"); + qmlRegisterType("Qt.test", 1, 0, "CircularReferenceHandle"); + + qmlRegisterType("Qt.test", 1, 0, "MyDynamicCreationDestructionObject"); + qmlRegisterType("Qt.test", 1, 0, "WriteCounter"); + + qmlRegisterType("Qt.test", 1, 0, "MySequenceConversionObject"); +} + +#include "testtypes.moc" diff --git a/tests/auto/qml/qqmlecmascript/testtypes.h b/tests/auto/qml/qqmlecmascript/testtypes.h new file mode 100644 index 0000000000..154e6f019c --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/testtypes.h @@ -0,0 +1,1311 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#ifndef TESTTYPES_H +#define TESTTYPES_H + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +class MyQmlAttachedObject : public QObject +{ + Q_OBJECT + Q_PROPERTY(int value READ value CONSTANT) + Q_PROPERTY(int value2 READ value2 WRITE setValue2 NOTIFY value2Changed) +public: + MyQmlAttachedObject(QObject *parent) : QObject(parent), m_value2(0) {} + + int value() const { return 19; } + int value2() const { return m_value2; } + void setValue2(int v) { if (m_value2 == v) return; m_value2 = v; emit value2Changed(); } + + void emitMySignal() { emit mySignal(); } + +signals: + void value2Changed(); + void mySignal(); + +private: + int m_value2; +}; + +class MyQmlObject : public QObject +{ + Q_OBJECT + Q_ENUMS(MyEnum) + Q_ENUMS(MyEnum2) + Q_PROPERTY(int deleteOnSet READ deleteOnSet WRITE setDeleteOnSet) + Q_PROPERTY(bool trueProperty READ trueProperty CONSTANT) + Q_PROPERTY(bool falseProperty READ falseProperty CONSTANT) + Q_PROPERTY(int value READ value WRITE setValue) + Q_PROPERTY(int console READ console CONSTANT) + Q_PROPERTY(QString stringProperty READ stringProperty WRITE setStringProperty NOTIFY stringChanged) + Q_PROPERTY(QUrl urlProperty READ urlProperty WRITE setUrlProperty NOTIFY urlChanged) + Q_PROPERTY(QObject *objectProperty READ objectProperty WRITE setObjectProperty NOTIFY objectChanged) + Q_PROPERTY(QQmlListProperty objectListProperty READ objectListProperty CONSTANT) + Q_PROPERTY(int resettableProperty READ resettableProperty WRITE setResettableProperty RESET resetProperty) + Q_PROPERTY(QRegExp regExp READ regExp WRITE setRegExp) + Q_PROPERTY(int nonscriptable READ nonscriptable WRITE setNonscriptable SCRIPTABLE false) + Q_PROPERTY(int intProperty READ intProperty WRITE setIntProperty NOTIFY intChanged) + +public: + MyQmlObject(): myinvokableObject(0), m_methodCalled(false), m_methodIntCalled(false), m_object(0), m_value(0), m_resetProperty(13), m_intProperty(0) {} + + enum MyEnum { EnumValue1 = 0, EnumValue2 = 1 }; + enum MyEnum2 { EnumValue3 = 2, EnumValue4 = 3 }; + + bool trueProperty() const { return true; } + bool falseProperty() const { return false; } + + QString stringProperty() const { return m_string; } + void setStringProperty(const QString &s) + { + if (s == m_string) + return; + m_string = s; + emit stringChanged(); + } + + QUrl urlProperty() const { return m_url; } + void setUrlProperty(const QUrl &url) + { + if (url == m_url) + return; + m_url = url; + emit urlChanged(); + } + + QObject *objectProperty() const { return m_object; } + void setObjectProperty(QObject *obj) { + if (obj == m_object) + return; + m_object = obj; + emit objectChanged(); + } + + QQmlListProperty objectListProperty() { return QQmlListProperty(this, m_objectQList); } + + bool methodCalled() const { return m_methodCalled; } + bool methodIntCalled() const { return m_methodIntCalled; } + + QString string() const { return m_string; } + + static MyQmlAttachedObject *qmlAttachedProperties(QObject *o) { + return new MyQmlAttachedObject(o); + } + + int deleteOnSet() const { return 1; } + void setDeleteOnSet(int v) { if(v) delete this; } + + int value() const { return m_value; } + void setValue(int v) { m_value = v; } + + int resettableProperty() const { return m_resetProperty; } + void setResettableProperty(int v) { m_resetProperty = v; } + void resetProperty() { m_resetProperty = 13; } + + QRegExp regExp() { return m_regExp; } + void setRegExp(const QRegExp ®Exp) { m_regExp = regExp; } + + int console() const { return 11; } + + int nonscriptable() const { return 0; } + void setNonscriptable(int) {} + + MyQmlObject *myinvokableObject; + Q_INVOKABLE MyQmlObject *returnme() { return this; } + + struct MyType { + int value; + }; + QVariant variant() const { return m_variant; } + QJSValue qjsvalue() const { return m_qjsvalue; } + + int intProperty() const { return m_intProperty; } + void setIntProperty(int i) { m_intProperty = i; emit intChanged(); } + +signals: + void basicSignal(); + void argumentSignal(int a, QString b, qreal c, MyEnum2 d, Qt::MouseButtons e); + void stringChanged(); + void urlChanged(); + void objectChanged(); + void anotherBasicSignal(); + void thirdBasicSignal(); + void signalWithUnknownType(const MyQmlObject::MyType &arg); + void signalWithVariant(const QVariant &arg); + void signalWithQJSValue(const QJSValue &arg); + void intChanged(); + +public slots: + void deleteMe() { delete this; } + void methodNoArgs() { m_methodCalled = true; } + void method(int a) { if(a == 163) m_methodIntCalled = true; } + void setString(const QString &s) { m_string = s; } + void myinvokable(MyQmlObject *o) { myinvokableObject = o; } + void variantMethod(const QVariant &v) { m_variant = v; } + void qjsvalueMethod(const QJSValue &v) { m_qjsvalue = v; } + void v8function(QQmlV8Function*); + +private: + friend class tst_qqmlecmascript; + bool m_methodCalled; + bool m_methodIntCalled; + + QObject *m_object; + QString m_string; + QUrl m_url; + QList m_objectQList; + int m_value; + int m_resetProperty; + QRegExp m_regExp; + QVariant m_variant; + QJSValue m_qjsvalue; + int m_intProperty; +}; + +QML_DECLARE_TYPEINFO(MyQmlObject, QML_HAS_ATTACHED_PROPERTIES) + +class MyQmlContainer : public QObject +{ + Q_OBJECT + Q_PROPERTY(QQmlListProperty children READ children CONSTANT) +public: + MyQmlContainer() {} + + QQmlListProperty children() { return QQmlListProperty(this, m_children); } + +private: + QList m_children; +}; + + +class MyExpression : public QQmlExpression +{ + Q_OBJECT +public: + MyExpression(QQmlContext *ctxt, const QString &expr) + : QQmlExpression(ctxt, 0, expr), changed(false) + { + QObject::connect(this, SIGNAL(valueChanged()), this, SLOT(expressionValueChanged())); + setNotifyOnValueChanged(true); + } + + bool changed; + +public slots: + void expressionValueChanged() { + changed = true; + } +}; + + +class MyDefaultObject1 : public QObject +{ + Q_OBJECT + Q_PROPERTY(int horseLegs READ horseLegs CONSTANT) + Q_PROPERTY(int antLegs READ antLegs CONSTANT) + Q_PROPERTY(int emuLegs READ emuLegs CONSTANT) +public: + int horseLegs() const { return 4; } + int antLegs() const { return 6; } + int emuLegs() const { return 2; } +}; + +class MyDefaultObject3 : public QObject +{ + Q_OBJECT + Q_PROPERTY(int antLegs READ antLegs CONSTANT) + Q_PROPERTY(int humanLegs READ humanLegs CONSTANT) +public: + int antLegs() const { return 7; } // Mutant + int humanLegs() const { return 2; } + int millipedeLegs() const { return 1000; } +}; + +class MyDeferredObject : public QObject +{ + Q_OBJECT + Q_PROPERTY(int value READ value WRITE setValue NOTIFY valueChanged) + Q_PROPERTY(QObject *objectProperty READ objectProperty WRITE setObjectProperty) + Q_PROPERTY(QObject *objectProperty2 READ objectProperty2 WRITE setObjectProperty2) + Q_CLASSINFO("DeferredPropertyNames", "value,objectProperty,objectProperty2") + +public: + MyDeferredObject() : m_value(0), m_object(0), m_object2(0) {} + + int value() const { return m_value; } + void setValue(int v) { m_value = v; emit valueChanged(); } + + QObject *objectProperty() const { return m_object; } + void setObjectProperty(QObject *obj) { m_object = obj; } + + QObject *objectProperty2() const { return m_object2; } + void setObjectProperty2(QObject *obj) { m_object2 = obj; } + +signals: + void valueChanged(); + +private: + int m_value; + QObject *m_object; + QObject *m_object2; +}; + +class MyBaseExtendedObject : public QObject +{ +Q_OBJECT +Q_PROPERTY(int baseProperty READ baseProperty WRITE setBaseProperty) +public: + MyBaseExtendedObject() : m_value(0) {} + + int baseProperty() const { return m_value; } + void setBaseProperty(int v) { m_value = v; } + +private: + int m_value; +}; + +class MyExtendedObject : public MyBaseExtendedObject +{ +Q_OBJECT +Q_PROPERTY(int coreProperty READ coreProperty WRITE setCoreProperty) +public: + MyExtendedObject() : m_value(0) {} + + int coreProperty() const { return m_value; } + void setCoreProperty(int v) { m_value = v; } + +private: + int m_value; +}; + +class MyTypeObject : public QObject +{ + Q_OBJECT + Q_ENUMS(MyEnum) + Q_FLAGS(MyFlags) + + Q_PROPERTY(QString id READ id WRITE setId) + Q_PROPERTY(QObject *objectProperty READ objectProperty WRITE setObjectProperty) + Q_PROPERTY(QQmlComponent *componentProperty READ componentProperty WRITE setComponentProperty) + Q_PROPERTY(MyFlags flagProperty READ flagProperty WRITE setFlagProperty) + Q_PROPERTY(MyEnum enumProperty READ enumProperty WRITE setEnumProperty) + Q_PROPERTY(QString stringProperty READ stringProperty WRITE setStringProperty) + Q_PROPERTY(uint uintProperty READ uintProperty WRITE setUintProperty) + Q_PROPERTY(int intProperty READ intProperty WRITE setIntProperty) + Q_PROPERTY(qreal realProperty READ realProperty WRITE setRealProperty) + Q_PROPERTY(double doubleProperty READ doubleProperty WRITE setDoubleProperty) + Q_PROPERTY(float floatProperty READ floatProperty WRITE setFloatProperty) + Q_PROPERTY(QColor colorProperty READ colorProperty WRITE setColorProperty) + Q_PROPERTY(QDate dateProperty READ dateProperty WRITE setDateProperty) + Q_PROPERTY(QTime timeProperty READ timeProperty WRITE setTimeProperty) + Q_PROPERTY(QDateTime dateTimeProperty READ dateTimeProperty WRITE setDateTimeProperty) + Q_PROPERTY(QPoint pointProperty READ pointProperty WRITE setPointProperty) + Q_PROPERTY(QPointF pointFProperty READ pointFProperty WRITE setPointFProperty) + Q_PROPERTY(QSize sizeProperty READ sizeProperty WRITE setSizeProperty) + Q_PROPERTY(QSizeF sizeFProperty READ sizeFProperty WRITE setSizeFProperty) + Q_PROPERTY(QRect rectProperty READ rectProperty WRITE setRectProperty NOTIFY rectPropertyChanged) + Q_PROPERTY(QRect rectProperty2 READ rectProperty2 WRITE setRectProperty2) + Q_PROPERTY(QRectF rectFProperty READ rectFProperty WRITE setRectFProperty) + Q_PROPERTY(bool boolProperty READ boolProperty WRITE setBoolProperty) + Q_PROPERTY(QVariant variantProperty READ variantProperty WRITE setVariantProperty) + Q_PROPERTY(QVector3D vectorProperty READ vectorProperty WRITE setVectorProperty) + Q_PROPERTY(QUrl urlProperty READ urlProperty WRITE setUrlProperty) + + Q_PROPERTY(QQmlScriptString scriptProperty READ scriptProperty WRITE setScriptProperty) + +public: + MyTypeObject() + : objectPropertyValue(0), componentPropertyValue(0) {} + + QString idValue; + QString id() const { + return idValue; + } + void setId(const QString &v) { + idValue = v; + } + + QObject *objectPropertyValue; + QObject *objectProperty() const { + return objectPropertyValue; + } + void setObjectProperty(QObject *v) { + objectPropertyValue = v; + } + + QQmlComponent *componentPropertyValue; + QQmlComponent *componentProperty() const { + return componentPropertyValue; + } + void setComponentProperty(QQmlComponent *v) { + componentPropertyValue = v; + } + + enum MyFlag { FlagVal1 = 0x01, FlagVal2 = 0x02, FlagVal3 = 0x04 }; + Q_DECLARE_FLAGS(MyFlags, MyFlag) + MyFlags flagPropertyValue; + MyFlags flagProperty() const { + return flagPropertyValue; + } + void setFlagProperty(MyFlags v) { + flagPropertyValue = v; + } + + enum MyEnum { EnumVal1, EnumVal2 }; + MyEnum enumPropertyValue; + MyEnum enumProperty() const { + return enumPropertyValue; + } + void setEnumProperty(MyEnum v) { + enumPropertyValue = v; + } + + QString stringPropertyValue; + QString stringProperty() const { + return stringPropertyValue; + } + void setStringProperty(const QString &v) { + stringPropertyValue = v; + } + + uint uintPropertyValue; + uint uintProperty() const { + return uintPropertyValue; + } + void setUintProperty(const uint &v) { + uintPropertyValue = v; + } + + int intPropertyValue; + int intProperty() const { + return intPropertyValue; + } + void setIntProperty(const int &v) { + intPropertyValue = v; + } + + qreal realPropertyValue; + qreal realProperty() const { + return realPropertyValue; + } + void setRealProperty(const qreal &v) { + realPropertyValue = v; + } + + double doublePropertyValue; + double doubleProperty() const { + return doublePropertyValue; + } + void setDoubleProperty(const double &v) { + doublePropertyValue = v; + } + + float floatPropertyValue; + float floatProperty() const { + return floatPropertyValue; + } + void setFloatProperty(const float &v) { + floatPropertyValue = v; + } + + QColor colorPropertyValue; + QColor colorProperty() const { + return colorPropertyValue; + } + void setColorProperty(const QColor &v) { + colorPropertyValue = v; + } + + QDate datePropertyValue; + QDate dateProperty() const { + return datePropertyValue; + } + void setDateProperty(const QDate &v) { + datePropertyValue = v; + } + + QTime timePropertyValue; + QTime timeProperty() const { + return timePropertyValue; + } + void setTimeProperty(const QTime &v) { + timePropertyValue = v; + } + + QDateTime dateTimePropertyValue; + QDateTime dateTimeProperty() const { + return dateTimePropertyValue; + } + void setDateTimeProperty(const QDateTime &v) { + dateTimePropertyValue = v; + } + + QPoint pointPropertyValue; + QPoint pointProperty() const { + return pointPropertyValue; + } + void setPointProperty(const QPoint &v) { + pointPropertyValue = v; + } + + QPointF pointFPropertyValue; + QPointF pointFProperty() const { + return pointFPropertyValue; + } + void setPointFProperty(const QPointF &v) { + pointFPropertyValue = v; + } + + QSize sizePropertyValue; + QSize sizeProperty() const { + return sizePropertyValue; + } + void setSizeProperty(const QSize &v) { + sizePropertyValue = v; + } + + QSizeF sizeFPropertyValue; + QSizeF sizeFProperty() const { + return sizeFPropertyValue; + } + void setSizeFProperty(const QSizeF &v) { + sizeFPropertyValue = v; + } + + QRect rectPropertyValue; + QRect rectProperty() const { + return rectPropertyValue; + } + void setRectProperty(const QRect &v) { + rectPropertyValue = v; + emit rectPropertyChanged(); + } + + QRect rectPropertyValue2; + QRect rectProperty2() const { + return rectPropertyValue2; + } + void setRectProperty2(const QRect &v) { + rectPropertyValue2 = v; + } + + QRectF rectFPropertyValue; + QRectF rectFProperty() const { + return rectFPropertyValue; + } + void setRectFProperty(const QRectF &v) { + rectFPropertyValue = v; + } + + bool boolPropertyValue; + bool boolProperty() const { + return boolPropertyValue; + } + void setBoolProperty(const bool &v) { + boolPropertyValue = v; + } + + QVariant variantPropertyValue; + QVariant variantProperty() const { + return variantPropertyValue; + } + void setVariantProperty(const QVariant &v) { + variantPropertyValue = v; + } + + QVector3D vectorPropertyValue; + QVector3D vectorProperty() const { + return vectorPropertyValue; + } + void setVectorProperty(const QVector3D &v) { + vectorPropertyValue = v; + } + + QUrl urlPropertyValue; + QUrl urlProperty() const { + return urlPropertyValue; + } + void setUrlProperty(const QUrl &v) { + urlPropertyValue = v; + } + + QQmlScriptString scriptPropertyValue; + QQmlScriptString scriptProperty() const { + return scriptPropertyValue; + } + void setScriptProperty(const QQmlScriptString &v) { + scriptPropertyValue = v; + } + + void doAction() { emit action(); } +signals: + void action(); + void rectPropertyChanged(); +}; +Q_DECLARE_OPERATORS_FOR_FLAGS(MyTypeObject::MyFlags) + +class MyDerivedObject : public MyTypeObject +{ + Q_OBJECT +public: + Q_INVOKABLE bool intProperty() const { + return true; + } +}; + +Q_DECLARE_METATYPE(QJSValue); +class MyInvokableBaseObject : public QObject +{ + Q_OBJECT +public: + inline ~MyInvokableBaseObject() = 0; + + Q_INVOKABLE inline void method_inherited(int a); + Q_INVOKABLE inline void method_overload(); +}; + +class MyInvokableObject : public MyInvokableBaseObject +{ + Q_OBJECT + Q_ENUMS(TestEnum) +public: + enum TestEnum { EnumValue1, EnumValue2 }; + MyInvokableObject() { reset(); } + + int invoked() const { return m_invoked; } + bool error() const { return m_invokedError; } + const QVariantList &actuals() const { return m_actuals; } + void reset() { m_invoked = -1; m_invokedError = false; m_actuals.clear(); } + + Q_INVOKABLE QPointF method_get_QPointF() { return QPointF(99.3, -10.2); } + Q_INVOKABLE QPoint method_get_QPoint() { return QPoint(9, 12); } + + Q_INVOKABLE void method_NoArgs() { invoke(0); } + Q_INVOKABLE int method_NoArgs_int() { invoke(1); return 6; } + Q_INVOKABLE qreal method_NoArgs_real() { invoke(2); return 19.75; } + Q_INVOKABLE QPointF method_NoArgs_QPointF() { invoke(3); return QPointF(123, 4.5); } + Q_INVOKABLE QObject *method_NoArgs_QObject() { invoke(4); return this; } + Q_INVOKABLE MyInvokableObject *method_NoArgs_unknown() { invoke(5); return this; } + Q_INVOKABLE QJSValue method_NoArgs_QScriptValue() { invoke(6); return QJSValue("Hello world"); } + Q_INVOKABLE QVariant method_NoArgs_QVariant() { invoke(7); return QVariant("QML rocks"); } + + Q_INVOKABLE void method_int(int a) { invoke(8); m_actuals << a; } + Q_INVOKABLE void method_intint(int a, int b) { invoke(9); m_actuals << a << b; } + Q_INVOKABLE void method_real(qreal a) { invoke(10); m_actuals << a; } + Q_INVOKABLE void method_QString(QString a) { invoke(11); m_actuals << a; } + Q_INVOKABLE void method_QPointF(QPointF a) { invoke(12); m_actuals << a; } + Q_INVOKABLE void method_QObject(QObject *a) { invoke(13); m_actuals << qVariantFromValue(a); } + Q_INVOKABLE void method_QScriptValue(QJSValue a) { invoke(14); m_actuals << qVariantFromValue(a); } + Q_INVOKABLE void method_intQScriptValue(int a, QJSValue b) { invoke(15); m_actuals << a << qVariantFromValue(b); } + + Q_INVOKABLE void method_overload(int a) { invoke(16); m_actuals << a; } + Q_INVOKABLE void method_overload(int a, int b) { invoke(17); m_actuals << a << b; } + Q_INVOKABLE void method_overload(QString a) { invoke(18); m_actuals << a; } + + Q_INVOKABLE void method_with_enum(TestEnum e) { invoke(19); m_actuals << (int)e; } + + Q_INVOKABLE int method_default(int a, int b = 19) { invoke(20); m_actuals << a << b; return b; } + + Q_INVOKABLE void method_QVariant(QVariant a, QVariant b = QVariant()) { invoke(21); m_actuals << a << b; } + +private: + friend class MyInvokableBaseObject; + void invoke(int idx) { if (m_invoked != -1) m_invokedError = true; m_invoked = idx;} + int m_invoked; + bool m_invokedError; + QVariantList m_actuals; +}; + +MyInvokableBaseObject::~MyInvokableBaseObject() {} + +void MyInvokableBaseObject::method_inherited(int a) +{ + static_cast(this)->invoke(-3); + static_cast(this)->m_actuals << a; +} + +// This is a hidden overload of the MyInvokableObject::method_overload() method +void MyInvokableBaseObject::method_overload() +{ + static_cast(this)->invoke(-2); +} + +class NumberAssignment : public QObject +{ + Q_OBJECT +public: + Q_PROPERTY(qreal test1 READ test1 WRITE setTest1) + qreal _test1; + qreal test1() const { return _test1; } + void setTest1(qreal v) { _test1 = v; } + + Q_PROPERTY(qreal test2 READ test2 WRITE setTest2) + qreal _test2; + qreal test2() const { return _test2; } + void setTest2(qreal v) { _test2 = v; } + + Q_PROPERTY(qreal test3 READ test3 WRITE setTest3) + qreal _test3; + qreal test3() const { return _test3; } + void setTest3(qreal v) { _test3 = v; } + + Q_PROPERTY(qreal test4 READ test4 WRITE setTest4) + qreal _test4; + qreal test4() const { return _test4; } + void setTest4(qreal v) { _test4 = v; } + + Q_PROPERTY(int test5 READ test5 WRITE setTest5) + int _test5; + int test5() const { return _test5; } + void setTest5(int v) { _test5 = v; } + + Q_PROPERTY(int test6 READ test6 WRITE setTest6) + int _test6; + int test6() const { return _test6; } + void setTest6(int v) { _test6 = v; } + + Q_PROPERTY(int test7 READ test7 WRITE setTest7) + int _test7; + int test7() const { return _test7; } + void setTest7(int v) { _test7 = v; } + + Q_PROPERTY(int test8 READ test8 WRITE setTest8) + int _test8; + int test8() const { return _test8; } + void setTest8(int v) { _test8 = v; } + + Q_PROPERTY(unsigned int test9 READ test9 WRITE setTest9) + unsigned int _test9; + unsigned int test9() const { return _test9; } + void setTest9(unsigned int v) { _test9 = v; } + + Q_PROPERTY(unsigned int test10 READ test10 WRITE setTest10) + unsigned int _test10; + unsigned int test10() const { return _test10; } + void setTest10(unsigned int v) { _test10 = v; } + + Q_PROPERTY(unsigned int test11 READ test11 WRITE setTest11) + unsigned int _test11; + unsigned int test11() const { return _test11; } + void setTest11(unsigned int v) { _test11 = v; } + + Q_PROPERTY(unsigned int test12 READ test12 WRITE setTest12) + unsigned int _test12; + unsigned int test12() const { return _test12; } + void setTest12(unsigned int v) { _test12 = v; } +}; + +class DefaultPropertyExtendedObject : public QObject +{ + Q_OBJECT + Q_PROPERTY(QObject *firstProperty READ firstProperty WRITE setFirstProperty) + Q_PROPERTY(QObject *secondProperty READ secondProperty WRITE setSecondProperty) +public: + DefaultPropertyExtendedObject(QObject *parent = 0) : QObject(parent), m_firstProperty(0), m_secondProperty(0) {} + + QObject *firstProperty() const { return m_firstProperty; } + QObject *secondProperty() const { return m_secondProperty; } + void setFirstProperty(QObject *property) { m_firstProperty = property; } + void setSecondProperty(QObject *property) { m_secondProperty = property; } +private: + QObject* m_firstProperty; + QObject* m_secondProperty; +}; + +class OverrideDefaultPropertyObject : public DefaultPropertyExtendedObject +{ + Q_OBJECT + Q_CLASSINFO("DefaultProperty", "secondProperty") +public: + OverrideDefaultPropertyObject() {} +}; + +class MyRevisionedBaseClassRegistered : public QObject +{ +Q_OBJECT + Q_PROPERTY(qreal propA READ propA WRITE setPropA NOTIFY propAChanged) + Q_PROPERTY(qreal propB READ propB WRITE setPropB NOTIFY propBChanged REVISION 1) + +public: + MyRevisionedBaseClassRegistered() : m_pa(1), m_pb(2) {} + + qreal propA() const { return m_pa; } + void setPropA(qreal p) { + if (p != m_pa) { + m_pa = p; + emit propAChanged(); + } + } + qreal propB() const { return m_pb; } + void setPropB(qreal p) { + if (p != m_pb) { + m_pb = p; + emit propBChanged(); + } + } + + Q_INVOKABLE void methodA() { } + Q_INVOKABLE Q_REVISION(1) void methodB() { } + +signals: + void propAChanged(); + void propBChanged(); + + void signalA(); + Q_REVISION(1) void signalB(); + +protected: + qreal m_pa; + qreal m_pb; +}; + +class MyRevisionedBaseClassUnregistered : public MyRevisionedBaseClassRegistered +{ +Q_OBJECT + Q_PROPERTY(qreal propC READ propC WRITE setPropC NOTIFY propCChanged) + Q_PROPERTY(qreal propD READ propD WRITE setPropD NOTIFY propDChanged REVISION 1) + +public: + MyRevisionedBaseClassUnregistered() : m_pc(1), m_pd(2) {} + + qreal propC() const { return m_pc; } + void setPropC(qreal p) { + if (p != m_pc) { + m_pc = p; + emit propCChanged(); + } + } + qreal propD() const { return m_pd; } + void setPropD(qreal p) { + if (p != m_pd) { + m_pd = p; + emit propDChanged(); + } + } + + Q_INVOKABLE void methodC() { } + Q_INVOKABLE Q_REVISION(1) void methodD() { } + +signals: + void propCChanged(); + void propDChanged(); + + void signalC(); + Q_REVISION(1) void signalD(); + +protected: + qreal m_pc; + qreal m_pd; +}; + +class MyRevisionedClass : public MyRevisionedBaseClassUnregistered +{ + Q_OBJECT + Q_PROPERTY(qreal prop1 READ prop1 WRITE setProp1 NOTIFY prop1Changed) + Q_PROPERTY(qreal prop2 READ prop2 WRITE setProp2 NOTIFY prop2Changed REVISION 1) + +public: + MyRevisionedClass() {} + + qreal prop1() const { return m_p1; } + void setProp1(qreal p) { + if (p != m_p1) { + m_p1 = p; + emit prop1Changed(); + } + } + qreal prop2() const { return m_p2; } + void setProp2(qreal p) { + if (p != m_p2) { + m_p2 = p; + emit prop2Changed(); + } + } + + Q_INVOKABLE void method1() { } + Q_INVOKABLE Q_REVISION(1) void method2() { } + +signals: + void prop1Changed(); + void prop2Changed(); + + void signal1(); + Q_REVISION(1) void signal2(); + +protected: + qreal m_p1; + qreal m_p2; +}; + +class MyRevisionedSubclass : public MyRevisionedClass +{ + Q_OBJECT + Q_PROPERTY(qreal prop3 READ prop3 WRITE setProp3 NOTIFY prop3Changed) + Q_PROPERTY(qreal prop4 READ prop4 WRITE setProp4 NOTIFY prop4Changed REVISION 1) + +public: + MyRevisionedSubclass() : m_p3(3), m_p4(4) {} + + qreal prop3() const { return m_p3; } + void setProp3(qreal p) { + if (p != m_p3) { + m_p3 = p; + emit prop3Changed(); + } + } + qreal prop4() const { return m_p4; } + void setProp4(qreal p) { + if (p != m_p4) { + m_p4 = p; + emit prop4Changed(); + } + } + + Q_INVOKABLE void method3() { } + Q_INVOKABLE Q_REVISION(1) void method4() { } + +signals: + void prop3Changed(); + void prop4Changed(); + + void signal3(); + Q_REVISION(1) void signal4(); + +protected: + qreal m_p3; + qreal m_p4; +}; + +QML_DECLARE_TYPE(MyRevisionedBaseClassRegistered) +QML_DECLARE_TYPE(MyRevisionedBaseClassUnregistered) +QML_DECLARE_TYPE(MyRevisionedClass) +QML_DECLARE_TYPE(MyRevisionedSubclass) +Q_DECLARE_METATYPE(MyQmlObject::MyType) + + +class ScarceResourceObject : public QObject +{ + Q_OBJECT + Q_PROPERTY(QPixmap scarceResource READ scarceResource WRITE setScarceResource NOTIFY scarceResourceChanged) +public: + ScarceResourceObject(QObject *parent = 0) : QObject(parent), m_value(100, 100) { m_value.fill(Qt::blue); } + ~ScarceResourceObject() {} + + QPixmap scarceResource() const { return m_value; } + void setScarceResource(QPixmap v) { m_value = v; emit scarceResourceChanged(); } + + bool scarceResourceIsDetached() const { return m_value.isDetached(); } + + // this particular one returns a new one each time + // this means that every Scarce Resource Copy will + // consume resources (so that we can track disposal + // of v8 handles with circular references). + Q_INVOKABLE QPixmap newScarceResource() const + { + QPixmap retn(800, 600); + retn.fill(QColor(100, 110, 120, 45)); + return retn; + } + +signals: + void scarceResourceChanged(); + +private: + QPixmap m_value; +}; +QML_DECLARE_TYPE(ScarceResourceObject) + +class testQObjectApi : public QObject +{ + Q_OBJECT + Q_ENUMS(MyEnum) + Q_PROPERTY (int qobjectTestProperty READ qobjectTestProperty NOTIFY qobjectTestPropertyChanged) + Q_PROPERTY (int qobjectTestWritableProperty READ qobjectTestWritableProperty WRITE setQObjectTestWritableProperty NOTIFY qobjectTestWritablePropertyChanged) + +public: + testQObjectApi(QObject* parent = 0) + : QObject(parent), m_testProperty(0), m_testWritableProperty(0), m_methodCallCount(0) + { + } + + ~testQObjectApi() {} + + enum MyEnum { EnumValue1 = 25, EnumValue2 = 42 }; + Q_INVOKABLE int qobjectEnumTestMethod(MyEnum val) { return (static_cast(val) + 5); } + Q_INVOKABLE int qobjectTestMethod(int increment = 1) { m_methodCallCount += increment; return m_methodCallCount; } + + int qobjectTestProperty() const { return m_testProperty; } + void setQObjectTestProperty(int tp) { m_testProperty = tp; emit qobjectTestPropertyChanged(tp); } + + int qobjectTestWritableProperty() const { return m_testWritableProperty; } + void setQObjectTestWritableProperty(int tp) { m_testWritableProperty = tp; emit qobjectTestWritablePropertyChanged(tp); } + +signals: + void qobjectTestPropertyChanged(int testProperty); + void qobjectTestWritablePropertyChanged(int testWritableProperty); + +private: + int m_testProperty; + int m_testWritableProperty; + int m_methodCallCount; +}; + +class CircularReferenceObject : public QObject, + public QV8GCCallback::Node +{ + Q_OBJECT + +public: + CircularReferenceObject(QObject *parent = 0) + : QObject(parent), QV8GCCallback::Node(callback), m_referenced(0), m_dtorCount(0) + { + QV8GCCallback::addGcCallbackNode(this); + } + + ~CircularReferenceObject() + { + if (m_dtorCount) *m_dtorCount = *m_dtorCount + 1; + } + + Q_INVOKABLE void setDtorCount(int *dtorCount) + { + m_dtorCount = dtorCount; + } + + Q_INVOKABLE CircularReferenceObject *generate(QObject *parent = 0) + { + CircularReferenceObject *retn = new CircularReferenceObject(parent); + retn->m_dtorCount = m_dtorCount; + retn->m_engine = m_engine; + return retn; + } + + Q_INVOKABLE void addReference(QObject *other) + { + m_referenced = other; + } + + static void callback(QV8GCCallback::Node *n) + { + CircularReferenceObject *cro = static_cast(n); + if (cro->m_referenced) { + cro->m_engine->addRelationshipForGC(cro, cro->m_referenced); + } + } + + void setEngine(QQmlEngine* declarativeEngine) + { + m_engine = QQmlEnginePrivate::get(declarativeEngine)->v8engine(); + } + +private: + QObject *m_referenced; + int *m_dtorCount; + QV8Engine* m_engine; +}; +Q_DECLARE_METATYPE(CircularReferenceObject*) + +class CircularReferenceHandle : public QObject, + public QV8GCCallback::Node +{ + Q_OBJECT + +public: + CircularReferenceHandle(QObject *parent = 0) + : QObject(parent), QV8GCCallback::Node(gccallback), m_dtorCount(0), m_engine(0) + { + QV8GCCallback::addGcCallbackNode(this); + } + + ~CircularReferenceHandle() + { + if (m_dtorCount) *m_dtorCount = *m_dtorCount + 1; + } + + Q_INVOKABLE void setDtorCount(int *dtorCount) + { + m_dtorCount = dtorCount; + } + + Q_INVOKABLE CircularReferenceHandle *generate(QObject *parent = 0) + { + CircularReferenceHandle *retn = new CircularReferenceHandle(parent); + retn->m_dtorCount = m_dtorCount; + retn->m_engine = m_engine; + return retn; + } + + Q_INVOKABLE void addReference(v8::Persistent handle) + { + m_referenced = qPersistentNew(handle); + m_referenced.MakeWeak(static_cast(this), wrcallback); + } + + static void wrcallback(v8::Persistent handle, void *params) + { + CircularReferenceHandle *crh = static_cast(params); + qPersistentDispose(handle); + crh->m_referenced.Clear(); + } + + static void gccallback(QV8GCCallback::Node *n) + { + CircularReferenceHandle *crh = static_cast(n); + crh->m_engine->addRelationshipForGC(crh, crh->m_referenced); + } + + void setEngine(QQmlEngine* declarativeEngine) + { + m_engine = QQmlEnginePrivate::get(declarativeEngine)->v8engine(); + } + +private: + v8::Persistent m_referenced; + int *m_dtorCount; + QV8Engine* m_engine; +}; +Q_DECLARE_METATYPE(CircularReferenceHandle*) + +class MyDynamicCreationDestructionObject : public QObject +{ + Q_OBJECT + Q_PROPERTY (int intProperty READ intProperty WRITE setIntProperty NOTIFY intPropertyChanged) + +public: + MyDynamicCreationDestructionObject(QObject *parent = 0) : QObject(parent), m_intProperty(0), m_dtorCount(0) + { + } + + ~MyDynamicCreationDestructionObject() + { + if (m_dtorCount) { + (*m_dtorCount)++; + } + } + + int intProperty() const { return m_intProperty; } + void setIntProperty(int val) { m_intProperty = val; emit intPropertyChanged(); } + + Q_INVOKABLE MyDynamicCreationDestructionObject *createNew() + { + // no parent == ownership transfers to JS; same dtor counter. + MyDynamicCreationDestructionObject *retn = new MyDynamicCreationDestructionObject; + retn->setDtorCount(m_dtorCount); + return retn; + } + + void setDtorCount(int *dtorCount) + { + m_dtorCount = dtorCount; + } + +signals: + void intPropertyChanged(); + +private: + int m_intProperty; + int *m_dtorCount; +}; + +class WriteCounter : public QObject +{ + Q_OBJECT + Q_PROPERTY(int value READ value WRITE setValue); +public: + WriteCounter() : m_value(0), m_count(0) {} + + int value() const { return m_value; } + void setValue(int v) { m_value = v; ++m_count; } + + int count() const { return m_count; } + +private: + int m_value; + int m_count; +}; + +class MySequenceConversionObject : public QObject +{ + Q_OBJECT + + Q_PROPERTY (QList intListProperty READ intListProperty WRITE setIntListProperty NOTIFY intListPropertyChanged) + Q_PROPERTY (QList intListProperty2 READ intListProperty2 WRITE setIntListProperty2 NOTIFY intListProperty2Changed) + Q_PROPERTY (QList qrealListProperty READ qrealListProperty WRITE setQrealListProperty NOTIFY qrealListPropertyChanged) + Q_PROPERTY (QList boolListProperty READ boolListProperty WRITE setBoolListProperty NOTIFY boolListPropertyChanged) + Q_PROPERTY (QList stringListProperty READ stringListProperty WRITE setStringListProperty NOTIFY stringListPropertyChanged) + Q_PROPERTY (QList urlListProperty READ urlListProperty WRITE setUrlListProperty NOTIFY urlListPropertyChanged) + Q_PROPERTY (QStringList qstringListProperty READ qstringListProperty WRITE setQStringListProperty NOTIFY qstringListPropertyChanged) + + Q_PROPERTY (QList pointListProperty READ pointListProperty WRITE setPointListProperty NOTIFY pointListPropertyChanged) + Q_PROPERTY (QList variantListProperty READ variantListProperty WRITE setVariantListProperty NOTIFY variantListPropertyChanged) + + Q_PROPERTY (qint32 maxIndex READ maxIndex CONSTANT) + Q_PROPERTY (quint32 tooBigIndex READ tooBigIndex CONSTANT) + Q_PROPERTY (qint32 negativeIndex READ negativeIndex CONSTANT) + +public: + MySequenceConversionObject() + { + m_intList << 1 << 2 << 3 << 4; + m_intList2 << 1 << 2 << 3 << 4; + m_qrealList << 1.1 << 2.2 << 3.3 << 4.4; + m_boolList << true << false << true << false; + m_stringList << QLatin1String("first") << QLatin1String("second") << QLatin1String("third") << QLatin1String("fourth"); + m_urlList << QUrl("http://www.example1.com") << QUrl("http://www.example2.com") << QUrl("http://www.example3.com"); + m_qstringList << QLatin1String("first") << QLatin1String("second") << QLatin1String("third") << QLatin1String("fourth"); + + m_pointList << QPoint(1, 2) << QPoint(3, 4) << QPoint(5, 6); + m_variantList << QVariant(QLatin1String("one")) << QVariant(true) << QVariant(3); + } + + ~MySequenceConversionObject() {} + + qint32 maxIndex() const + { + return INT_MAX; + } + quint32 tooBigIndex() const + { + quint32 retn = 7; + retn += INT_MAX; + return retn; + } + qint32 negativeIndex() const + { + return -5; + } + + QList intListProperty() const { return m_intList; } + void setIntListProperty(const QList &list) { m_intList = list; emit intListPropertyChanged(); } + QList intListProperty2() const { return m_intList2; } + void setIntListProperty2(const QList &list) { m_intList2 = list; emit intListProperty2Changed(); } + QList qrealListProperty() const { return m_qrealList; } + void setQrealListProperty(const QList &list) { m_qrealList = list; emit qrealListPropertyChanged(); } + QList boolListProperty() const { return m_boolList; } + void setBoolListProperty(const QList &list) { m_boolList = list; emit boolListPropertyChanged(); } + QList stringListProperty() const { return m_stringList; } + void setStringListProperty(const QList &list) { m_stringList = list; emit stringListPropertyChanged(); } + QList urlListProperty() const { return m_urlList; } + void setUrlListProperty(const QList &list) { m_urlList = list; emit urlListPropertyChanged(); } + QStringList qstringListProperty() const { return m_qstringList; } + void setQStringListProperty(const QStringList &list) { m_qstringList = list; emit qstringListPropertyChanged(); } + QList pointListProperty() const { return m_pointList; } + void setPointListProperty(const QList &list) { m_pointList = list; emit pointListPropertyChanged(); } + QList variantListProperty() const { return m_variantList; } + void setVariantListProperty(const QList &list) { m_variantList = list; emit variantListPropertyChanged(); } + + // now for "copy resource" sequences: + Q_INVOKABLE QList generateIntSequence() const { QList retn; retn << 1 << 2 << 3; return retn; } + Q_INVOKABLE QList generateQrealSequence() const { QList retn; retn << 1.1 << 2.2 << 3.3; return retn; } + Q_INVOKABLE QList generateBoolSequence() const { QList retn; retn << true << false << true; return retn; } + Q_INVOKABLE QList generateStringSequence() const { QList retn; retn << "one" << "two" << "three"; return retn; } + Q_INVOKABLE QList generateUrlSequence() const { QList retn; retn << QUrl("http://www.example1.com") << QUrl("http://www.example2.com") << QUrl("http://www.example3.com"); return retn; } + Q_INVOKABLE QStringList generateQStringSequence() const { QStringList retn; retn << "one" << "two" << "three"; return retn; } + + // "reference resource" underlying qobject deletion test: + Q_INVOKABLE MySequenceConversionObject *generateTestObject() const { return new MySequenceConversionObject; } + Q_INVOKABLE void deleteTestObject(QObject *object) const { delete object; } + +signals: + void intListPropertyChanged(); + void intListProperty2Changed(); + void qrealListPropertyChanged(); + void boolListPropertyChanged(); + void stringListPropertyChanged(); + void urlListPropertyChanged(); + void qstringListPropertyChanged(); + void pointListPropertyChanged(); + void variantListPropertyChanged(); + +private: + QList m_intList; + QList m_intList2; + QList m_qrealList; + QList m_boolList; + QList m_stringList; + QList m_urlList; + QStringList m_qstringList; + + QList m_pointList; // not a supported sequence type + QList m_variantList; // not a supported sequence type, but QVariantList support is hardcoded. +}; + +class MyDeleteObject : public QObject +{ + Q_OBJECT + Q_PROPERTY(QObject *nestedObject READ nestedObject NOTIFY nestedObjectChanged); + Q_PROPERTY(int deleteNestedObject READ deleteNestedObject NOTIFY deleteNestedObjectChanged); + +public: + MyDeleteObject() : m_nestedObject(new MyQmlObject) {} + + QObject *nestedObject() const { return m_nestedObject; } + int deleteNestedObject() { delete m_nestedObject; m_nestedObject = 0; return 1; } + +signals: + void nestedObjectChanged(); + void deleteNestedObjectChanged(); + +private: + MyQmlObject *m_nestedObject; +}; + +void registerTypes(); + +#endif // TESTTYPES_H + diff --git a/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp b/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp new file mode 100644 index 0000000000..af219c8826 --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp @@ -0,0 +1,6062 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "testtypes.h" +#include "testhttpserver.h" +#include "../../shared/util.h" + +/* +This test covers evaluation of ECMAScript expressions and bindings from within +QML. This does not include static QML language issues. + +Static QML language issues are covered in qmllanguage +*/ + +class tst_qqmlecmascript : public QQmlDataTest +{ + Q_OBJECT +public: + tst_qqmlecmascript() {} + +private slots: + void initTestCase(); + void assignBasicTypes(); + void idShortcutInvalidates(); + void boolPropertiesEvaluateAsBool(); + void methods(); + void signalAssignment(); + void bindingLoop(); + void basicExpressions(); + void basicExpressions_data(); + void arrayExpressions(); + void contextPropertiesTriggerReeval(); + void objectPropertiesTriggerReeval(); + void deferredProperties(); + void deferredPropertiesErrors(); + void extensionObjects(); + void overrideExtensionProperties(); + void attachedProperties(); + void enums(); + void valueTypeFunctions(); + void constantsOverrideBindings(); + void outerBindingOverridesInnerBinding(); + void aliasPropertyAndBinding(); + void aliasPropertyReset(); + void nonExistentAttachedObject(); + void scope(); + void importScope(); + void signalParameterTypes(); + void objectsCompareAsEqual(); + void dynamicCreation_data(); + void dynamicCreation(); + void dynamicDestruction(); + void objectToString(); + void objectHasOwnProperty(); + void selfDeletingBinding(); + void extendedObjectPropertyLookup(); + void extendedObjectPropertyLookup2(); + void scriptErrors(); + void functionErrors(); + void propertyAssignmentErrors(); + void signalTriggeredBindings(); + void listProperties(); + void exceptionClearsOnReeval(); + void exceptionSlotProducesWarning(); + void exceptionBindingProducesWarning(); + void compileInvalidBinding(); + void transientErrors(); + void shutdownErrors(); + void compositePropertyType(); + void jsObject(); + void undefinedResetsProperty(); + void listToVariant(); + void listAssignment(); + void multiEngineObject(); + void deletedObject(); + void attachedPropertyScope(); + void scriptConnect(); + void scriptDisconnect(); + void ownership(); + void cppOwnershipReturnValue(); + void ownershipCustomReturnValue(); + void qlistqobjectMethods(); + void strictlyEquals(); + void compiled(); + void numberAssignment(); + void propertySplicing(); + void signalWithUnknownTypes(); + void signalWithJSValueInVariant_data(); + void signalWithJSValueInVariant(); + void signalWithJSValueInVariant_twoEngines_data(); + void signalWithJSValueInVariant_twoEngines(); + void signalWithQJSValue_data(); + void signalWithQJSValue(); + void moduleApi_data(); + void moduleApi(); + void importScripts_data(); + void importScripts(); + void scarceResources(); + void scarceResources_data(); + void scarceResources_other(); + void propertyChangeSlots(); + void propertyVar_data(); + void propertyVar(); + void propertyVarCpp(); + void propertyVarOwnership(); + void propertyVarImplicitOwnership(); + void propertyVarReparent(); + void propertyVarReparentNullContext(); + void propertyVarCircular(); + void propertyVarCircular2(); + void propertyVarInheritance(); + void propertyVarInheritance2(); + void elementAssign(); + void objectPassThroughSignals(); + void objectConversion(); + void booleanConversion(); + void handleReferenceManagement(); + void stringArg(); + void readonlyDeclaration(); + void sequenceConversionRead(); + void sequenceConversionWrite(); + void sequenceConversionArray(); + void sequenceConversionIndexes(); + void sequenceConversionThreads(); + void sequenceConversionBindings(); + void sequenceConversionCopy(); + void assignSequenceTypes(); + void qtbug_22464(); + void qtbug_21580(); + + void bug1(); + void bug2(); + void dynamicCreationCrash(); + void dynamicCreationOwnership(); + void regExpBug(); + void nullObjectBinding(); + void deletedEngine(); + void libraryScriptAssert(); + void variantsAssignedUndefined(); + void qtbug_9792(); + void qtcreatorbug_1289(); + void noSpuriousWarningsAtShutdown(); + void canAssignNullToQObject(); + void functionAssignment_fromBinding(); + void functionAssignment_fromJS(); + void functionAssignment_fromJS_data(); + void functionAssignmentfromJS_invalid(); + void eval(); + void function(); + void functionException(); + void qtbug_10696(); + void qtbug_11606(); + void qtbug_11600(); + void qtbug_21864(); + void qobjectConnectionListExceptionHandling(); + void nonscriptable(); + void deleteLater(); + void in(); + void typeOf(); + void sharedAttachedObject(); + void objectName(); + void writeRemovesBinding(); + void aliasBindingsAssignCorrectly(); + void aliasBindingsOverrideTarget(); + void aliasWritesOverrideBindings(); + void aliasToCompositeElement(); + void realToInt(); + void urlProperty(); + void urlPropertyWithEncoding(); + void urlListPropertyWithEncoding(); + void dynamicString(); + void include(); + void signalHandlers(); + void doubleEvaluate(); + void forInLoop(); + void nonNotifyable(); + void deleteWhileBindingRunning(); + void callQtInvokables(); + void invokableObjectArg(); + void invokableObjectRet(); + void qtbug_20344(); + void qtbug_22679(); + void qtbug_22843_data(); + void qtbug_22843(); + void rewriteMultiLineStrings(); + void revisionErrors(); + void revision(); + void invokableWithQObjectDerived(); + + void automaticSemicolon(); + void unaryExpression(); + void switchStatement(); + void withStatement(); + void tryStatement(); + +private: + static void propertyVarWeakRefCallback(v8::Persistent object, void* parameter); + QQmlEngine engine; +}; + +void tst_qqmlecmascript::initTestCase() +{ + QQmlDataTest::initTestCase(); + registerTypes(); +} + +void tst_qqmlecmascript::assignBasicTypes() +{ + { + QQmlComponent component(&engine, testFileUrl("assignBasicTypes.qml")); + MyTypeObject *object = qobject_cast(component.create()); + QVERIFY(object != 0); + QCOMPARE(object->flagProperty(), MyTypeObject::FlagVal1 | MyTypeObject::FlagVal3); + QCOMPARE(object->enumProperty(), MyTypeObject::EnumVal2); + QCOMPARE(object->stringProperty(), QString("Hello World!")); + QCOMPARE(object->uintProperty(), uint(10)); + QCOMPARE(object->intProperty(), -19); + QCOMPARE((float)object->realProperty(), float(23.2)); + QCOMPARE((float)object->doubleProperty(), float(-19.75)); + QCOMPARE((float)object->floatProperty(), float(8.5)); + QCOMPARE(object->colorProperty(), QColor("red")); + QCOMPARE(object->dateProperty(), QDate(1982, 11, 25)); + QCOMPARE(object->timeProperty(), QTime(11, 11, 32)); + QCOMPARE(object->dateTimeProperty(), QDateTime(QDate(2009, 5, 12), QTime(13, 22, 1))); + QCOMPARE(object->pointProperty(), QPoint(99,13)); + QCOMPARE(object->pointFProperty(), QPointF(-10.1, 12.3)); + QCOMPARE(object->sizeProperty(), QSize(99, 13)); + QCOMPARE(object->sizeFProperty(), QSizeF(0.1, 0.2)); + QCOMPARE(object->rectProperty(), QRect(9, 7, 100, 200)); + QCOMPARE(object->rectFProperty(), QRectF(1000.1, -10.9, 400, 90.99)); + QCOMPARE(object->boolProperty(), true); + QCOMPARE(object->variantProperty(), QVariant("Hello World!")); + QCOMPARE(object->vectorProperty(), QVector3D(10, 1, 2.2)); + QCOMPARE(object->urlProperty(), component.url().resolved(QUrl("main.qml"))); + delete object; + } + { + QQmlComponent component(&engine, testFileUrl("assignBasicTypes.2.qml")); + MyTypeObject *object = qobject_cast(component.create()); + QVERIFY(object != 0); + QCOMPARE(object->flagProperty(), MyTypeObject::FlagVal1 | MyTypeObject::FlagVal3); + QCOMPARE(object->enumProperty(), MyTypeObject::EnumVal2); + QCOMPARE(object->stringProperty(), QString("Hello World!")); + QCOMPARE(object->uintProperty(), uint(10)); + QCOMPARE(object->intProperty(), -19); + QCOMPARE((float)object->realProperty(), float(23.2)); + QCOMPARE((float)object->doubleProperty(), float(-19.75)); + QCOMPARE((float)object->floatProperty(), float(8.5)); + QCOMPARE(object->colorProperty(), QColor("red")); + QCOMPARE(object->dateProperty(), QDate(1982, 11, 25)); + QCOMPARE(object->timeProperty(), QTime(11, 11, 32)); + QCOMPARE(object->dateTimeProperty(), QDateTime(QDate(2009, 5, 12), QTime(13, 22, 1))); + QCOMPARE(object->pointProperty(), QPoint(99,13)); + QCOMPARE(object->pointFProperty(), QPointF(-10.1, 12.3)); + QCOMPARE(object->sizeProperty(), QSize(99, 13)); + QCOMPARE(object->sizeFProperty(), QSizeF(0.1, 0.2)); + QCOMPARE(object->rectProperty(), QRect(9, 7, 100, 200)); + QCOMPARE(object->rectFProperty(), QRectF(1000.1, -10.9, 400, 90.99)); + QCOMPARE(object->boolProperty(), true); + QCOMPARE(object->variantProperty(), QVariant("Hello World!")); + QCOMPARE(object->vectorProperty(), QVector3D(10, 1, 2.2)); + QCOMPARE(object->urlProperty(), component.url().resolved(QUrl("main.qml"))); + delete object; + } +} + +void tst_qqmlecmascript::idShortcutInvalidates() +{ + { + QQmlComponent component(&engine, testFileUrl("idShortcutInvalidates.qml")); + MyQmlObject *object = qobject_cast(component.create()); + QVERIFY(object != 0); + QVERIFY(object->objectProperty() != 0); + delete object->objectProperty(); + QVERIFY(object->objectProperty() == 0); + delete object; + } + + { + QQmlComponent component(&engine, testFileUrl("idShortcutInvalidates.1.qml")); + MyQmlObject *object = qobject_cast(component.create()); + QVERIFY(object != 0); + QVERIFY(object->objectProperty() != 0); + delete object->objectProperty(); + QVERIFY(object->objectProperty() == 0); + delete object; + } +} + +void tst_qqmlecmascript::boolPropertiesEvaluateAsBool() +{ + { + QQmlComponent component(&engine, testFileUrl("boolPropertiesEvaluateAsBool.1.qml")); + MyQmlObject *object = qobject_cast(component.create()); + QVERIFY(object != 0); + QCOMPARE(object->stringProperty(), QLatin1String("pass")); + delete object; + } + { + QQmlComponent component(&engine, testFileUrl("boolPropertiesEvaluateAsBool.2.qml")); + MyQmlObject *object = qobject_cast(component.create()); + QVERIFY(object != 0); + QCOMPARE(object->stringProperty(), QLatin1String("pass")); + delete object; + } +} + +void tst_qqmlecmascript::signalAssignment() +{ + { + QQmlComponent component(&engine, testFileUrl("signalAssignment.1.qml")); + MyQmlObject *object = qobject_cast(component.create()); + QVERIFY(object != 0); + QCOMPARE(object->string(), QString()); + emit object->basicSignal(); + QCOMPARE(object->string(), QString("pass")); + delete object; + } + + { + QQmlComponent component(&engine, testFileUrl("signalAssignment.2.qml")); + MyQmlObject *object = qobject_cast(component.create()); + QVERIFY(object != 0); + QCOMPARE(object->string(), QString()); + emit object->argumentSignal(19, "Hello world!", 10.25, MyQmlObject::EnumValue4, Qt::RightButton); + QCOMPARE(object->string(), QString("pass 19 Hello world! 10.25 3 2")); + delete object; + } +} + +void tst_qqmlecmascript::methods() +{ + { + QQmlComponent component(&engine, testFileUrl("methods.1.qml")); + MyQmlObject *object = qobject_cast(component.create()); + QVERIFY(object != 0); + QCOMPARE(object->methodCalled(), false); + QCOMPARE(object->methodIntCalled(), false); + emit object->basicSignal(); + QCOMPARE(object->methodCalled(), true); + QCOMPARE(object->methodIntCalled(), false); + delete object; + } + + { + QQmlComponent component(&engine, testFileUrl("methods.2.qml")); + MyQmlObject *object = qobject_cast(component.create()); + QVERIFY(object != 0); + QCOMPARE(object->methodCalled(), false); + QCOMPARE(object->methodIntCalled(), false); + emit object->basicSignal(); + QCOMPARE(object->methodCalled(), false); + QCOMPARE(object->methodIntCalled(), true); + delete object; + } + + { + QQmlComponent component(&engine, testFileUrl("methods.3.qml")); + QObject *object = component.create(); + QVERIFY(object != 0); + QCOMPARE(object->property("test").toInt(), 19); + delete object; + } + + { + QQmlComponent component(&engine, testFileUrl("methods.4.qml")); + QObject *object = component.create(); + QVERIFY(object != 0); + QCOMPARE(object->property("test").toInt(), 19); + QCOMPARE(object->property("test2").toInt(), 17); + QCOMPARE(object->property("test3").toInt(), 16); + delete object; + } + + { + QQmlComponent component(&engine, testFileUrl("methods.5.qml")); + QObject *object = component.create(); + QVERIFY(object != 0); + QCOMPARE(object->property("test").toInt(), 9); + delete object; + } +} + +void tst_qqmlecmascript::bindingLoop() +{ + QQmlComponent component(&engine, testFileUrl("bindingLoop.qml")); + QString warning = component.url().toString() + ":5:9: QML MyQmlObject: Binding loop detected for property \"stringProperty\""; + QTest::ignoreMessage(QtWarningMsg, warning.toLatin1().constData()); + QObject *object = component.create(); + QVERIFY(object != 0); + delete object; +} + +void tst_qqmlecmascript::basicExpressions_data() +{ + QTest::addColumn("expression"); + QTest::addColumn("result"); + QTest::addColumn("nest"); + + QTest::newRow("Syntax error (self test)") << "{console.log({'a':1'}.a)}" << QVariant() << false; + QTest::newRow("Context property") << "a" << QVariant(1944) << false; + QTest::newRow("Context property") << "a" << QVariant(1944) << true; + QTest::newRow("Context property expression") << "a * 2" << QVariant(3888) << false; + QTest::newRow("Context property expression") << "a * 2" << QVariant(3888) << true; + QTest::newRow("Overridden context property") << "b" << QVariant("Milk") << false; + QTest::newRow("Overridden context property") << "b" << QVariant("Cow") << true; + QTest::newRow("Object property") << "object.stringProperty" << QVariant("Object1") << false; + QTest::newRow("Object property") << "object.stringProperty" << QVariant("Object1") << true; + QTest::newRow("Overridden object property") << "objectOverride.stringProperty" << QVariant("Object2") << false; + QTest::newRow("Overridden object property") << "objectOverride.stringProperty" << QVariant("Object3") << true; + QTest::newRow("Default object property") << "horseLegs" << QVariant(4) << false; + QTest::newRow("Default object property") << "antLegs" << QVariant(6) << false; + QTest::newRow("Default object property") << "emuLegs" << QVariant(2) << false; + QTest::newRow("Nested default object property") << "horseLegs" << QVariant(4) << true; + QTest::newRow("Nested default object property") << "antLegs" << QVariant(7) << true; + QTest::newRow("Nested default object property") << "emuLegs" << QVariant(2) << true; + QTest::newRow("Nested default object property") << "humanLegs" << QVariant(2) << true; + QTest::newRow("Context property override default object property") << "millipedeLegs" << QVariant(100) << true; +} + +void tst_qqmlecmascript::basicExpressions() +{ + QFETCH(QString, expression); + QFETCH(QVariant, result); + QFETCH(bool, nest); + + MyQmlObject object1; + MyQmlObject object2; + MyQmlObject object3; + MyDefaultObject1 default1; + MyDefaultObject3 default3; + object1.setStringProperty("Object1"); + object2.setStringProperty("Object2"); + object3.setStringProperty("Object3"); + + QQmlContext context(engine.rootContext()); + QQmlContext nestedContext(&context); + + context.setContextObject(&default1); + context.setContextProperty("a", QVariant(1944)); + context.setContextProperty("b", QVariant("Milk")); + context.setContextProperty("object", &object1); + context.setContextProperty("objectOverride", &object2); + nestedContext.setContextObject(&default3); + nestedContext.setContextProperty("b", QVariant("Cow")); + nestedContext.setContextProperty("objectOverride", &object3); + nestedContext.setContextProperty("millipedeLegs", QVariant(100)); + + MyExpression expr(nest?&nestedContext:&context, expression); + QCOMPARE(expr.evaluate(), result); +} + +void tst_qqmlecmascript::arrayExpressions() +{ + QObject obj1; + QObject obj2; + QObject obj3; + + QQmlContext context(engine.rootContext()); + context.setContextProperty("a", &obj1); + context.setContextProperty("b", &obj2); + context.setContextProperty("c", &obj3); + + MyExpression expr(&context, "[a, b, c, 10]"); + QVariant result = expr.evaluate(); + QCOMPARE(result.userType(), qMetaTypeId >()); + QList list = qvariant_cast >(result); + QCOMPARE(list.count(), 4); + QCOMPARE(list.at(0), &obj1); + QCOMPARE(list.at(1), &obj2); + QCOMPARE(list.at(2), &obj3); + QCOMPARE(list.at(3), (QObject *)0); +} + +// Tests that modifying a context property will reevaluate expressions +void tst_qqmlecmascript::contextPropertiesTriggerReeval() +{ + QQmlContext context(engine.rootContext()); + MyQmlObject object1; + MyQmlObject object2; + MyQmlObject *object3 = new MyQmlObject; + + object1.setStringProperty("Hello"); + object2.setStringProperty("World"); + + context.setContextProperty("testProp", QVariant(1)); + context.setContextProperty("testObj", &object1); + context.setContextProperty("testObj2", object3); + + { + MyExpression expr(&context, "testProp + 1"); + QCOMPARE(expr.changed, false); + QCOMPARE(expr.evaluate(), QVariant(2)); + + context.setContextProperty("testProp", QVariant(2)); + QCOMPARE(expr.changed, true); + QCOMPARE(expr.evaluate(), QVariant(3)); + } + + { + MyExpression expr(&context, "testProp + testProp + testProp"); + QCOMPARE(expr.changed, false); + QCOMPARE(expr.evaluate(), QVariant(6)); + + context.setContextProperty("testProp", QVariant(4)); + QCOMPARE(expr.changed, true); + QCOMPARE(expr.evaluate(), QVariant(12)); + } + + { + MyExpression expr(&context, "testObj.stringProperty"); + QCOMPARE(expr.changed, false); + QCOMPARE(expr.evaluate(), QVariant("Hello")); + + context.setContextProperty("testObj", &object2); + QCOMPARE(expr.changed, true); + QCOMPARE(expr.evaluate(), QVariant("World")); + } + + { + MyExpression expr(&context, "testObj.stringProperty /**/"); + QCOMPARE(expr.changed, false); + QCOMPARE(expr.evaluate(), QVariant("World")); + + context.setContextProperty("testObj", &object1); + QCOMPARE(expr.changed, true); + QCOMPARE(expr.evaluate(), QVariant("Hello")); + } + + { + MyExpression expr(&context, "testObj2"); + QCOMPARE(expr.changed, false); + QCOMPARE(expr.evaluate(), QVariant::fromValue((QObject *)object3)); + } + + delete object3; +} + +void tst_qqmlecmascript::objectPropertiesTriggerReeval() +{ + QQmlContext context(engine.rootContext()); + MyQmlObject object1; + MyQmlObject object2; + MyQmlObject object3; + context.setContextProperty("testObj", &object1); + + object1.setStringProperty(QLatin1String("Hello")); + object2.setStringProperty(QLatin1String("Dog")); + object3.setStringProperty(QLatin1String("Cat")); + + { + MyExpression expr(&context, "testObj.stringProperty"); + QCOMPARE(expr.changed, false); + QCOMPARE(expr.evaluate(), QVariant("Hello")); + + object1.setStringProperty(QLatin1String("World")); + QCOMPARE(expr.changed, true); + QCOMPARE(expr.evaluate(), QVariant("World")); + } + + { + MyExpression expr(&context, "testObj.objectProperty.stringProperty"); + QCOMPARE(expr.changed, false); + QCOMPARE(expr.evaluate(), QVariant()); + + object1.setObjectProperty(&object2); + QCOMPARE(expr.changed, true); + expr.changed = false; + QCOMPARE(expr.evaluate(), QVariant("Dog")); + + object1.setObjectProperty(&object3); + QCOMPARE(expr.changed, true); + expr.changed = false; + QCOMPARE(expr.evaluate(), QVariant("Cat")); + + object1.setObjectProperty(0); + QCOMPARE(expr.changed, true); + expr.changed = false; + QCOMPARE(expr.evaluate(), QVariant()); + + object1.setObjectProperty(&object3); + QCOMPARE(expr.changed, true); + expr.changed = false; + QCOMPARE(expr.evaluate(), QVariant("Cat")); + + object3.setStringProperty("Donkey"); + QCOMPARE(expr.changed, true); + expr.changed = false; + QCOMPARE(expr.evaluate(), QVariant("Donkey")); + } +} + +void tst_qqmlecmascript::deferredProperties() +{ + QQmlComponent component(&engine, testFileUrl("deferredProperties.qml")); + MyDeferredObject *object = + qobject_cast(component.create()); + QVERIFY(object != 0); + QCOMPARE(object->value(), 0); + QVERIFY(object->objectProperty() == 0); + QVERIFY(object->objectProperty2() != 0); + qmlExecuteDeferred(object); + QCOMPARE(object->value(), 10); + QVERIFY(object->objectProperty() != 0); + MyQmlObject *qmlObject = + qobject_cast(object->objectProperty()); + QVERIFY(qmlObject != 0); + QCOMPARE(qmlObject->value(), 10); + object->setValue(19); + QCOMPARE(qmlObject->value(), 19); + + delete object; +} + +// Check errors on deferred properties are correctly emitted +void tst_qqmlecmascript::deferredPropertiesErrors() +{ + QQmlComponent component(&engine, testFileUrl("deferredPropertiesErrors.qml")); + MyDeferredObject *object = + qobject_cast(component.create()); + QVERIFY(object != 0); + QCOMPARE(object->value(), 0); + QVERIFY(object->objectProperty() == 0); + QVERIFY(object->objectProperty2() == 0); + + QString warning = component.url().toString() + ":6: Unable to assign [undefined] to QObject*"; + QTest::ignoreMessage(QtWarningMsg, qPrintable(warning)); + + qmlExecuteDeferred(object); + + delete object; +} + +void tst_qqmlecmascript::extensionObjects() +{ + QQmlComponent component(&engine, testFileUrl("extensionObjects.qml")); + MyExtendedObject *object = + qobject_cast(component.create()); + QVERIFY(object != 0); + QCOMPARE(object->baseProperty(), 13); + QCOMPARE(object->coreProperty(), 9); + object->setProperty("extendedProperty", QVariant(11)); + object->setProperty("baseExtendedProperty", QVariant(92)); + QCOMPARE(object->coreProperty(), 11); + QCOMPARE(object->baseProperty(), 92); + + MyExtendedObject *nested = qobject_cast(qvariant_cast(object->property("nested"))); + QVERIFY(nested); + QCOMPARE(nested->baseProperty(), 13); + QCOMPARE(nested->coreProperty(), 9); + nested->setProperty("extendedProperty", QVariant(11)); + nested->setProperty("baseExtendedProperty", QVariant(92)); + QCOMPARE(nested->coreProperty(), 11); + QCOMPARE(nested->baseProperty(), 92); + + delete object; +} + +void tst_qqmlecmascript::overrideExtensionProperties() +{ + QQmlComponent component(&engine, testFileUrl("extensionObjectsPropertyOverride.qml")); + OverrideDefaultPropertyObject *object = + qobject_cast(component.create()); + QVERIFY(object != 0); + QVERIFY(object->secondProperty() != 0); + QVERIFY(object->firstProperty() == 0); + + delete object; +} + +void tst_qqmlecmascript::attachedProperties() +{ + { + QQmlComponent component(&engine, testFileUrl("attachedProperty.qml")); + QObject *object = component.create(); + QVERIFY(object != 0); + QCOMPARE(object->property("a").toInt(), 19); + QCOMPARE(object->property("b").toInt(), 19); + QCOMPARE(object->property("c").toInt(), 19); + QCOMPARE(object->property("d").toInt(), 19); + delete object; + } + + { + QQmlComponent component(&engine, testFileUrl("attachedProperty.2.qml")); + QObject *object = component.create(); + QVERIFY(object != 0); + QCOMPARE(object->property("a").toInt(), 26); + QCOMPARE(object->property("b").toInt(), 26); + QCOMPARE(object->property("c").toInt(), 26); + QCOMPARE(object->property("d").toInt(), 26); + + delete object; + } + + { + QQmlComponent component(&engine, testFileUrl("writeAttachedProperty.qml")); + QObject *object = component.create(); + QVERIFY(object != 0); + + QMetaObject::invokeMethod(object, "writeValue2"); + + MyQmlAttachedObject *attached = + qobject_cast(qmlAttachedPropertiesObject(object)); + QVERIFY(attached != 0); + + QCOMPARE(attached->value2(), 9); + delete object; + } +} + +void tst_qqmlecmascript::enums() +{ + // Existent enums + { + QQmlComponent component(&engine, testFileUrl("enums.1.qml")); + QObject *object = component.create(); + QVERIFY(object != 0); + + QCOMPARE(object->property("a").toInt(), 0); + QCOMPARE(object->property("b").toInt(), 1); + QCOMPARE(object->property("c").toInt(), 2); + QCOMPARE(object->property("d").toInt(), 3); + QCOMPARE(object->property("e").toInt(), 0); + QCOMPARE(object->property("f").toInt(), 1); + QCOMPARE(object->property("g").toInt(), 2); + QCOMPARE(object->property("h").toInt(), 3); + QCOMPARE(object->property("i").toInt(), 19); + QCOMPARE(object->property("j").toInt(), 19); + + delete object; + } + // Non-existent enums + { + QQmlComponent component(&engine, testFileUrl("enums.2.qml")); + + QString warning1 = component.url().toString() + ":5: Unable to assign [undefined] to int"; + QString warning2 = component.url().toString() + ":6: Unable to assign [undefined] to int"; + QTest::ignoreMessage(QtWarningMsg, qPrintable(warning1)); + QTest::ignoreMessage(QtWarningMsg, qPrintable(warning2)); + + QObject *object = component.create(); + QVERIFY(object != 0); + QCOMPARE(object->property("a").toInt(), 0); + QCOMPARE(object->property("b").toInt(), 0); + + delete object; + } +} + +void tst_qqmlecmascript::valueTypeFunctions() +{ + QQmlComponent component(&engine, testFileUrl("valueTypeFunctions.qml")); + MyTypeObject *obj = qobject_cast(component.create()); + QVERIFY(obj != 0); + QCOMPARE(obj->rectProperty(), QRect(0,0,100,100)); + QCOMPARE(obj->rectFProperty(), QRectF(0,0.5,100,99.5)); + + delete obj; +} + +/* +Tests that writing a constant to a property with a binding on it disables the +binding. +*/ +void tst_qqmlecmascript::constantsOverrideBindings() +{ + // From ECMAScript + { + QQmlComponent component(&engine, testFileUrl("constantsOverrideBindings.1.qml")); + MyQmlObject *object = qobject_cast(component.create()); + QVERIFY(object != 0); + + QCOMPARE(object->property("c2").toInt(), 0); + object->setProperty("c1", QVariant(9)); + QCOMPARE(object->property("c2").toInt(), 9); + + emit object->basicSignal(); + + QCOMPARE(object->property("c2").toInt(), 13); + object->setProperty("c1", QVariant(8)); + QCOMPARE(object->property("c2").toInt(), 13); + + delete object; + } + + // During construction + { + QQmlComponent component(&engine, testFileUrl("constantsOverrideBindings.2.qml")); + MyQmlObject *object = qobject_cast(component.create()); + QVERIFY(object != 0); + + QCOMPARE(object->property("c1").toInt(), 0); + QCOMPARE(object->property("c2").toInt(), 10); + object->setProperty("c1", QVariant(9)); + QCOMPARE(object->property("c1").toInt(), 9); + QCOMPARE(object->property("c2").toInt(), 10); + + delete object; + } + +#if 0 + // From C++ + { + QQmlComponent component(&engine, testFileUrl("constantsOverrideBindings.3.qml")); + MyQmlObject *object = qobject_cast(component.create()); + QVERIFY(object != 0); + + QCOMPARE(object->property("c2").toInt(), 0); + object->setProperty("c1", QVariant(9)); + QCOMPARE(object->property("c2").toInt(), 9); + + object->setProperty("c2", QVariant(13)); + QCOMPARE(object->property("c2").toInt(), 13); + object->setProperty("c1", QVariant(7)); + QCOMPARE(object->property("c1").toInt(), 7); + QCOMPARE(object->property("c2").toInt(), 13); + + delete object; + } +#endif + + // Using an alias + { + QQmlComponent component(&engine, testFileUrl("constantsOverrideBindings.4.qml")); + MyQmlObject *object = qobject_cast(component.create()); + QVERIFY(object != 0); + + QCOMPARE(object->property("c1").toInt(), 0); + QCOMPARE(object->property("c3").toInt(), 10); + object->setProperty("c1", QVariant(9)); + QCOMPARE(object->property("c1").toInt(), 9); + QCOMPARE(object->property("c3").toInt(), 10); + + delete object; + } +} + +/* +Tests that assigning a binding to a property that already has a binding causes +the original binding to be disabled. +*/ +void tst_qqmlecmascript::outerBindingOverridesInnerBinding() +{ + QQmlComponent component(&engine, + testFileUrl("outerBindingOverridesInnerBinding.qml")); + MyQmlObject *object = qobject_cast(component.create()); + QVERIFY(object != 0); + + QCOMPARE(object->property("c1").toInt(), 0); + QCOMPARE(object->property("c2").toInt(), 0); + QCOMPARE(object->property("c3").toInt(), 0); + + object->setProperty("c1", QVariant(9)); + QCOMPARE(object->property("c1").toInt(), 9); + QCOMPARE(object->property("c2").toInt(), 0); + QCOMPARE(object->property("c3").toInt(), 0); + + object->setProperty("c3", QVariant(8)); + QCOMPARE(object->property("c1").toInt(), 9); + QCOMPARE(object->property("c2").toInt(), 8); + QCOMPARE(object->property("c3").toInt(), 8); + + delete object; +} + +/* +Access a non-existent attached object. + +Tests for a regression where this used to crash. +*/ +void tst_qqmlecmascript::nonExistentAttachedObject() +{ + QQmlComponent component(&engine, testFileUrl("nonExistentAttachedObject.qml")); + + QString warning = component.url().toString() + ":4: Unable to assign [undefined] to QString"; + QTest::ignoreMessage(QtWarningMsg, qPrintable(warning)); + + QObject *object = component.create(); + QVERIFY(object != 0); + + delete object; +} + +void tst_qqmlecmascript::scope() +{ + { + QQmlComponent component(&engine, testFileUrl("scope.qml")); + QObject *object = component.create(); + QVERIFY(object != 0); + + QCOMPARE(object->property("test1").toInt(), 1); + QCOMPARE(object->property("test2").toInt(), 2); + QCOMPARE(object->property("test3").toString(), QString("1Test")); + QCOMPARE(object->property("test4").toString(), QString("2Test")); + QCOMPARE(object->property("test5").toInt(), 1); + QCOMPARE(object->property("test6").toInt(), 1); + QCOMPARE(object->property("test7").toInt(), 2); + QCOMPARE(object->property("test8").toInt(), 2); + QCOMPARE(object->property("test9").toInt(), 1); + QCOMPARE(object->property("test10").toInt(), 3); + + delete object; + } + + { + QQmlComponent component(&engine, testFileUrl("scope.2.qml")); + QObject *object = component.create(); + QVERIFY(object != 0); + + QCOMPARE(object->property("test1").toInt(), 19); + QCOMPARE(object->property("test2").toInt(), 19); + QCOMPARE(object->property("test3").toInt(), 14); + QCOMPARE(object->property("test4").toInt(), 14); + QCOMPARE(object->property("test5").toInt(), 24); + QCOMPARE(object->property("test6").toInt(), 24); + + delete object; + } + + { + QQmlComponent component(&engine, testFileUrl("scope.3.qml")); + QObject *object = component.create(); + QVERIFY(object != 0); + + QCOMPARE(object->property("test1").toBool(), true); + QCOMPARE(object->property("test2").toBool(), true); + QCOMPARE(object->property("test3").toBool(), true); + + delete object; + } + + // Signal argument scope + { + QQmlComponent component(&engine, testFileUrl("scope.4.qml")); + MyQmlObject *object = qobject_cast(component.create()); + QVERIFY(object != 0); + + QCOMPARE(object->property("test").toInt(), 0); + QCOMPARE(object->property("test2").toString(), QString()); + + emit object->argumentSignal(13, "Argument Scope", 9, MyQmlObject::EnumValue4, Qt::RightButton); + + QCOMPARE(object->property("test").toInt(), 13); + QCOMPARE(object->property("test2").toString(), QString("Argument Scope")); + + delete object; + } + + { + QQmlComponent component(&engine, testFileUrl("scope.5.qml")); + QObject *object = component.create(); + QVERIFY(object != 0); + + QCOMPARE(object->property("test1").toBool(), true); + QCOMPARE(object->property("test2").toBool(), true); + + delete object; + } + + { + QQmlComponent component(&engine, testFileUrl("scope.6.qml")); + QObject *object = component.create(); + QVERIFY(object != 0); + + QCOMPARE(object->property("test").toBool(), true); + + delete object; + } +} + +// In 4.7, non-library javascript files that had no imports shared the imports of their +// importing context +void tst_qqmlecmascript::importScope() +{ + QQmlComponent component(&engine, testFileUrl("importScope.qml")); + QObject *o = component.create(); + QVERIFY(o != 0); + + QCOMPARE(o->property("test").toInt(), 240); + + delete o; +} + +/* +Tests that "any" type passes through a synthesized signal parameter. This +is essentially a test of QQmlMetaType::copy() +*/ +void tst_qqmlecmascript::signalParameterTypes() +{ + QQmlComponent component(&engine, testFileUrl("signalParameterTypes.qml")); + MyQmlObject *object = qobject_cast(component.create()); + QVERIFY(object != 0); + + emit object->basicSignal(); + + QCOMPARE(object->property("intProperty").toInt(), 10); + QCOMPARE(object->property("realProperty").toReal(), 19.2); + QVERIFY(object->property("colorProperty").value() == QColor(255, 255, 0, 255)); + QVERIFY(object->property("variantProperty") == QVariant::fromValue(QColor(255, 0, 255, 255))); + QVERIFY(object->property("enumProperty") == MyQmlObject::EnumValue3); + QVERIFY(object->property("qtEnumProperty") == Qt::LeftButton); + + delete object; +} + +/* +Test that two JS objects for the same QObject compare as equal. +*/ +void tst_qqmlecmascript::objectsCompareAsEqual() +{ + QQmlComponent component(&engine, testFileUrl("objectsCompareAsEqual.qml")); + QObject *object = component.create(); + QVERIFY(object != 0); + + QCOMPARE(object->property("test1").toBool(), true); + QCOMPARE(object->property("test2").toBool(), true); + QCOMPARE(object->property("test3").toBool(), true); + QCOMPARE(object->property("test4").toBool(), true); + QCOMPARE(object->property("test5").toBool(), true); + + delete object; +} + +/* +Confirm bindings and alias properties can coexist. + +Tests for a regression where the binding would not reevaluate. +*/ +void tst_qqmlecmascript::aliasPropertyAndBinding() +{ + QQmlComponent component(&engine, testFileUrl("aliasPropertyAndBinding.qml")); + QObject *object = component.create(); + QVERIFY(object != 0); + + QCOMPARE(object->property("c2").toInt(), 3); + QCOMPARE(object->property("c3").toInt(), 3); + + object->setProperty("c2", QVariant(19)); + + QCOMPARE(object->property("c2").toInt(), 19); + QCOMPARE(object->property("c3").toInt(), 19); + + delete object; +} + +/* +Ensure that we can write undefined value to an alias property, +and that the aliased property is reset correctly if possible. +*/ +void tst_qqmlecmascript::aliasPropertyReset() +{ + QObject *object = 0; + + // test that a manual write (of undefined) to a resettable aliased property succeeds + QQmlComponent c1(&engine, testFileUrl("aliasreset/aliasPropertyReset.1.qml")); + object = c1.create(); + QVERIFY(object != 0); + QVERIFY(object->property("sourceComponentAlias").value() != 0); + QCOMPARE(object->property("aliasIsUndefined"), QVariant(false)); + QMetaObject::invokeMethod(object, "resetAliased"); + QVERIFY(object->property("sourceComponentAlias").value() == 0); + QCOMPARE(object->property("aliasIsUndefined"), QVariant(true)); + delete object; + + // test that a manual write (of undefined) to a resettable alias property succeeds + QQmlComponent c2(&engine, testFileUrl("aliasreset/aliasPropertyReset.2.qml")); + object = c2.create(); + QVERIFY(object != 0); + QVERIFY(object->property("sourceComponentAlias").value() != 0); + QCOMPARE(object->property("loaderSourceComponentIsUndefined"), QVariant(false)); + QMetaObject::invokeMethod(object, "resetAlias"); + QVERIFY(object->property("sourceComponentAlias").value() == 0); + QCOMPARE(object->property("loaderSourceComponentIsUndefined"), QVariant(true)); + delete object; + + // test that an alias to a bound property works correctly + QQmlComponent c3(&engine, testFileUrl("aliasreset/aliasPropertyReset.3.qml")); + object = c3.create(); + QVERIFY(object != 0); + QVERIFY(object->property("sourceComponentAlias").value() != 0); + QCOMPARE(object->property("loaderOneSourceComponentIsUndefined"), QVariant(false)); + QCOMPARE(object->property("loaderTwoSourceComponentIsUndefined"), QVariant(false)); + QMetaObject::invokeMethod(object, "resetAlias"); + QVERIFY(object->property("sourceComponentAlias").value() == 0); + QCOMPARE(object->property("loaderOneSourceComponentIsUndefined"), QVariant(true)); + QCOMPARE(object->property("loaderTwoSourceComponentIsUndefined"), QVariant(false)); + delete object; + + // test that a manual write (of undefined) to a resettable alias property + // whose aliased property's object has been deleted, does not crash. + QQmlComponent c4(&engine, testFileUrl("aliasreset/aliasPropertyReset.4.qml")); + object = c4.create(); + QVERIFY(object != 0); + QVERIFY(object->property("sourceComponentAlias").value() != 0); + QObject *loader = object->findChild("loader"); + QVERIFY(loader != 0); + delete loader; + QVERIFY(object->property("sourceComponentAlias").value() == 0); // deletion should have caused value unset. + QMetaObject::invokeMethod(object, "resetAlias"); // shouldn't crash. + QVERIFY(object->property("sourceComponentAlias").value() == 0); + QMetaObject::invokeMethod(object, "setAlias"); // shouldn't crash, and shouldn't change value (since it's no longer referencing anything). + QVERIFY(object->property("sourceComponentAlias").value() == 0); + delete object; + + // test that binding an alias property to an undefined value works correctly + QQmlComponent c5(&engine, testFileUrl("aliasreset/aliasPropertyReset.5.qml")); + object = c5.create(); + QVERIFY(object != 0); + QVERIFY(object->property("sourceComponentAlias").value() == 0); // bound to undefined value. + delete object; + + // test that a manual write (of undefined) to a non-resettable property fails properly + QUrl url = testFileUrl("aliasreset/aliasPropertyReset.error.1.qml"); + QString warning1 = url.toString() + QLatin1String(":15: Error: Cannot assign [undefined] to int"); + QQmlComponent e1(&engine, url); + object = e1.create(); + QVERIFY(object != 0); + QCOMPARE(object->property("intAlias").value(), 12); + QCOMPARE(object->property("aliasedIntIsUndefined"), QVariant(false)); + QTest::ignoreMessage(QtWarningMsg, warning1.toLatin1().constData()); + QMetaObject::invokeMethod(object, "resetAlias"); + QCOMPARE(object->property("intAlias").value(), 12); + QCOMPARE(object->property("aliasedIntIsUndefined"), QVariant(false)); + delete object; +} + +void tst_qqmlecmascript::dynamicCreation_data() +{ + QTest::addColumn("method"); + QTest::addColumn("createdName"); + + QTest::newRow("One") << "createOne" << "objectOne"; + QTest::newRow("Two") << "createTwo" << "objectTwo"; + QTest::newRow("Three") << "createThree" << "objectThree"; +} + +/* +Test using createQmlObject to dynamically generate an item +Also using createComponent is tested. +*/ +void tst_qqmlecmascript::dynamicCreation() +{ + QFETCH(QString, method); + QFETCH(QString, createdName); + + QQmlComponent component(&engine, testFileUrl("dynamicCreation.qml")); + MyQmlObject *object = qobject_cast(component.create()); + QVERIFY(object != 0); + + QMetaObject::invokeMethod(object, method.toUtf8()); + QObject *created = object->objectProperty(); + QVERIFY(created); + QCOMPARE(created->objectName(), createdName); + + delete object; +} + +/* + Tests the destroy function +*/ +void tst_qqmlecmascript::dynamicDestruction() +{ + { + QQmlComponent component(&engine, testFileUrl("dynamicDeletion.qml")); + QQmlGuard object = qobject_cast(component.create()); + QVERIFY(object != 0); + QQmlGuard createdQmlObject = 0; + + QMetaObject::invokeMethod(object, "create"); + createdQmlObject = object->objectProperty(); + QVERIFY(createdQmlObject); + QCOMPARE(createdQmlObject->objectName(), QString("emptyObject")); + + QMetaObject::invokeMethod(object, "killOther"); + QVERIFY(createdQmlObject); + + QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete); + QCoreApplication::processEvents(); + QVERIFY(createdQmlObject); + for (int ii = 0; createdQmlObject && ii < 50; ++ii) { // After 5 seconds we should give up + if (createdQmlObject) { + QTest::qWait(100); + QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete); + QCoreApplication::processEvents(); + } + } + QVERIFY(!createdQmlObject); + + QQmlEngine::setObjectOwnership(object, QQmlEngine::JavaScriptOwnership); + QMetaObject::invokeMethod(object, "killMe"); + QVERIFY(object); + QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete); + QCoreApplication::processEvents(); + QVERIFY(!object); + } + + { + QQmlComponent component(&engine, testFileUrl("dynamicDeletion.2.qml")); + QObject *o = component.create(); + QVERIFY(o != 0); + + QVERIFY(qvariant_cast(o->property("objectProperty")) == 0); + + QMetaObject::invokeMethod(o, "create"); + + QVERIFY(qvariant_cast(o->property("objectProperty")) != 0); + + QMetaObject::invokeMethod(o, "destroy"); + + QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete); + QCoreApplication::processEvents(); + + QVERIFY(qvariant_cast(o->property("objectProperty")) == 0); + + delete o; + } +} + +/* + tests that id.toString() works +*/ +void tst_qqmlecmascript::objectToString() +{ + QQmlComponent component(&engine, testFileUrl("qmlToString.qml")); + MyQmlObject *object = qobject_cast(component.create()); + QVERIFY(object != 0); + QMetaObject::invokeMethod(object, "testToString"); + QVERIFY(object->stringProperty().startsWith("MyQmlObject_QML_")); + QVERIFY(object->stringProperty().endsWith(", \"objName\")")); + + delete object; +} + +/* + tests that id.hasOwnProperty() works +*/ +void tst_qqmlecmascript::objectHasOwnProperty() +{ + QUrl url = testFileUrl("qmlHasOwnProperty.qml"); + QString warning1 = url.toString() + ":59: TypeError: Cannot call method 'hasOwnProperty' of undefined"; + QString warning2 = url.toString() + ":64: TypeError: Cannot call method 'hasOwnProperty' of undefined"; + QString warning3 = url.toString() + ":69: TypeError: Cannot call method 'hasOwnProperty' of undefined"; + + QQmlComponent component(&engine, url); + QObject *object = component.create(); + QVERIFY(object != 0); + + // test QObjects in QML + QMetaObject::invokeMethod(object, "testHasOwnPropertySuccess"); + QVERIFY(object->property("result").value() == true); + QMetaObject::invokeMethod(object, "testHasOwnPropertyFailure"); + QVERIFY(object->property("result").value() == false); + + // now test other types in QML + QObject *child = object->findChild("typeObj"); + QVERIFY(child != 0); + QMetaObject::invokeMethod(child, "testHasOwnPropertySuccess"); + QCOMPARE(child->property("valueTypeHasOwnProperty").toBool(), true); + QCOMPARE(child->property("valueTypeHasOwnProperty2").toBool(), true); + QCOMPARE(child->property("variantTypeHasOwnProperty").toBool(), true); + QCOMPARE(child->property("stringTypeHasOwnProperty").toBool(), true); + QCOMPARE(child->property("listTypeHasOwnProperty").toBool(), true); + QCOMPARE(child->property("emptyListTypeHasOwnProperty").toBool(), true); + QCOMPARE(child->property("enumTypeHasOwnProperty").toBool(), true); + QCOMPARE(child->property("typenameHasOwnProperty").toBool(), true); + QCOMPARE(child->property("typenameHasOwnProperty2").toBool(), true); + QCOMPARE(child->property("moduleApiTypeHasOwnProperty").toBool(), true); + QCOMPARE(child->property("moduleApiPropertyTypeHasOwnProperty").toBool(), true); + + QTest::ignoreMessage(QtWarningMsg, warning1.toLatin1().constData()); + QMetaObject::invokeMethod(child, "testHasOwnPropertyFailureOne"); + QCOMPARE(child->property("enumNonValueHasOwnProperty").toBool(), false); + QTest::ignoreMessage(QtWarningMsg, warning2.toLatin1().constData()); + QMetaObject::invokeMethod(child, "testHasOwnPropertyFailureTwo"); + QCOMPARE(child->property("moduleApiNonPropertyHasOwnProperty").toBool(), false); + QTest::ignoreMessage(QtWarningMsg, warning3.toLatin1().constData()); + QMetaObject::invokeMethod(child, "testHasOwnPropertyFailureThree"); + QCOMPARE(child->property("listAtInvalidHasOwnProperty").toBool(), false); + + delete object; +} + +/* +Tests bindings that indirectly cause their own deletion work. + +This test is best run under valgrind to ensure no invalid memory access occur. +*/ +void tst_qqmlecmascript::selfDeletingBinding() +{ + { + QQmlComponent component(&engine, testFileUrl("selfDeletingBinding.qml")); + QObject *object = component.create(); + QVERIFY(object != 0); + object->setProperty("triggerDelete", true); + delete object; + } + + { + QQmlComponent component(&engine, testFileUrl("selfDeletingBinding.2.qml")); + QObject *object = component.create(); + QVERIFY(object != 0); + object->setProperty("triggerDelete", true); + delete object; + } +} + +/* +Test that extended object properties can be accessed. + +This test a regression where this used to crash. The issue was specificially +for extended objects that did not include a synthesized meta object (so non-root +and no synthesiszed properties). +*/ +void tst_qqmlecmascript::extendedObjectPropertyLookup() +{ + QQmlComponent component(&engine, testFileUrl("extendedObjectPropertyLookup.qml")); + QObject *object = component.create(); + QVERIFY(object != 0); + delete object; +} + +/* +Test that extended object properties can be accessed correctly. +*/ +void tst_qqmlecmascript::extendedObjectPropertyLookup2() +{ + QQmlComponent component(&engine, testFileUrl("extendedObjectPropertyLookup2.qml")); + QObject *object = component.create(); + QVERIFY(object != 0); + + QVariant returnValue; + QVERIFY(QMetaObject::invokeMethod(object, "getValue", Q_RETURN_ARG(QVariant, returnValue))); + QCOMPARE(returnValue.toInt(), 42); + + delete object; +} +/* +Test file/lineNumbers for binding/Script errors. +*/ +void tst_qqmlecmascript::scriptErrors() +{ + QQmlComponent component(&engine, testFileUrl("scriptErrors.qml")); + QString url = component.url().toString(); + + QString warning1 = url.left(url.length() - 3) + "js:2: Error: Invalid write to global property \"a\""; + QString warning2 = url + ":5: ReferenceError: Can't find variable: a"; + QString warning3 = url.left(url.length() - 3) + "js:4: Error: Invalid write to global property \"a\""; + QString warning4 = url + ":13: ReferenceError: Can't find variable: a"; + QString warning5 = url + ":11: ReferenceError: Can't find variable: a"; + QString warning6 = url + ":10: Unable to assign [undefined] to int"; + QString warning7 = url + ":15: Error: Cannot assign to read-only property \"trueProperty\""; + QString warning8 = url + ":16: Error: Cannot assign to non-existent property \"fakeProperty\""; + + QTest::ignoreMessage(QtWarningMsg, warning1.toLatin1().constData()); + QTest::ignoreMessage(QtWarningMsg, warning2.toLatin1().constData()); + QTest::ignoreMessage(QtWarningMsg, warning3.toLatin1().constData()); + QTest::ignoreMessage(QtWarningMsg, warning5.toLatin1().constData()); + QTest::ignoreMessage(QtWarningMsg, warning6.toLatin1().constData()); + MyQmlObject *object = qobject_cast(component.create()); + QVERIFY(object != 0); + + QTest::ignoreMessage(QtWarningMsg, warning4.toLatin1().constData()); + emit object->basicSignal(); + + QTest::ignoreMessage(QtWarningMsg, warning7.toLatin1().constData()); + emit object->anotherBasicSignal(); + + QTest::ignoreMessage(QtWarningMsg, warning8.toLatin1().constData()); + emit object->thirdBasicSignal(); + + delete object; +} + +/* +Test file/lineNumbers for inline functions. +*/ +void tst_qqmlecmascript::functionErrors() +{ + QQmlComponent component(&engine, testFileUrl("functionErrors.qml")); + QString url = component.url().toString(); + + QString warning = url + ":5: Error: Invalid write to global property \"a\""; + + QTest::ignoreMessage(QtWarningMsg, warning.toLatin1().constData()); + + QObject *object = component.create(); + QVERIFY(object != 0); + delete object; + + // test that if an exception occurs while invoking js function from cpp, it is reported as expected. + QQmlComponent componentTwo(&engine, testFileUrl("scarceResourceFunctionFail.var.qml")); + url = componentTwo.url().toString(); + object = componentTwo.create(); + QVERIFY(object != 0); + + QString srpname = object->property("srp_name").toString(); + + warning = url + QLatin1String(":16: TypeError: Property 'scarceResource' of object ") + srpname + + QLatin1String(" is not a function"); + QTest::ignoreMessage(QtWarningMsg, warning.toLatin1().constData()); // we expect a meaningful warning to be printed. + QMetaObject::invokeMethod(object, "retrieveScarceResource"); + delete object; +} + +/* +Test various errors that can occur when assigning a property from script +*/ +void tst_qqmlecmascript::propertyAssignmentErrors() +{ + QQmlComponent component(&engine, testFileUrl("propertyAssignmentErrors.qml")); + + QString url = component.url().toString(); + + QObject *object = component.create(); + QVERIFY(object != 0); + + QCOMPARE(object->property("test1").toBool(), true); + QCOMPARE(object->property("test2").toBool(), true); + + delete object; +} + +/* +Test bindings still work when the reeval is triggered from within +a signal script. +*/ +void tst_qqmlecmascript::signalTriggeredBindings() +{ + QQmlComponent component(&engine, testFileUrl("signalTriggeredBindings.qml")); + MyQmlObject *object = qobject_cast(component.create()); + QVERIFY(object != 0); + + QCOMPARE(object->property("base").toReal(), 50.); + QCOMPARE(object->property("test1").toReal(), 50.); + QCOMPARE(object->property("test2").toReal(), 50.); + + object->basicSignal(); + + QCOMPARE(object->property("base").toReal(), 200.); + QCOMPARE(object->property("test1").toReal(), 200.); + QCOMPARE(object->property("test2").toReal(), 200.); + + object->argumentSignal(10, QString(), 10, MyQmlObject::EnumValue4, Qt::RightButton); + + QCOMPARE(object->property("base").toReal(), 400.); + QCOMPARE(object->property("test1").toReal(), 400.); + QCOMPARE(object->property("test2").toReal(), 400.); + + delete object; +} + +/* +Test that list properties can be iterated from ECMAScript +*/ +void tst_qqmlecmascript::listProperties() +{ + QQmlComponent component(&engine, testFileUrl("listProperties.qml")); + MyQmlObject *object = qobject_cast(component.create()); + QVERIFY(object != 0); + + QCOMPARE(object->property("test1").toInt(), 21); + QCOMPARE(object->property("test2").toInt(), 2); + QCOMPARE(object->property("test3").toBool(), true); + QCOMPARE(object->property("test4").toBool(), true); + + delete object; +} + +void tst_qqmlecmascript::exceptionClearsOnReeval() +{ + QQmlComponent component(&engine, testFileUrl("exceptionClearsOnReeval.qml")); + QString url = component.url().toString(); + + QString warning = url + ":4: TypeError: Cannot read property 'objectProperty' of null"; + + QTest::ignoreMessage(QtWarningMsg, warning.toLatin1().constData()); + MyQmlObject *object = qobject_cast(component.create()); + QVERIFY(object != 0); + + QCOMPARE(object->property("test").toBool(), false); + + MyQmlObject object2; + MyQmlObject object3; + object2.setObjectProperty(&object3); + object->setObjectProperty(&object2); + + QCOMPARE(object->property("test").toBool(), true); + + delete object; +} + +void tst_qqmlecmascript::exceptionSlotProducesWarning() +{ + QQmlComponent component(&engine, testFileUrl("exceptionProducesWarning.qml")); + QString url = component.url().toString(); + + QString warning = component.url().toString() + ":6: Error: JS exception"; + + QTest::ignoreMessage(QtWarningMsg, warning.toLatin1().constData()); + MyQmlObject *object = qobject_cast(component.create()); + QVERIFY(object != 0); + delete object; +} + +void tst_qqmlecmascript::exceptionBindingProducesWarning() +{ + QQmlComponent component(&engine, testFileUrl("exceptionProducesWarning2.qml")); + QString url = component.url().toString(); + + QString warning = component.url().toString() + ":5: Error: JS exception"; + + QTest::ignoreMessage(QtWarningMsg, warning.toLatin1().constData()); + MyQmlObject *object = qobject_cast(component.create()); + QVERIFY(object != 0); + delete object; +} + +void tst_qqmlecmascript::compileInvalidBinding() +{ + // QTBUG-23387: ensure that invalid bindings don't cause a crash. + QQmlComponent component(&engine, testFileUrl("v8bindingException.qml")); + QString warning = component.url().toString() + ":16: SyntaxError: Unexpected token ILLEGAL"; + QTest::ignoreMessage(QtWarningMsg, warning.toLatin1().constData()); + QObject *object = component.create(); + QVERIFY(object != 0); + delete object; +} + +static int transientErrorsMsgCount = 0; +static void transientErrorsMsgHandler(QtMsgType, const char *) +{ + ++transientErrorsMsgCount; +} + +// Check that transient binding errors are not displayed +void tst_qqmlecmascript::transientErrors() +{ + { + QQmlComponent component(&engine, testFileUrl("transientErrors.qml")); + + transientErrorsMsgCount = 0; + QtMsgHandler old = qInstallMsgHandler(transientErrorsMsgHandler); + + QObject *object = component.create(); + QVERIFY(object != 0); + + qInstallMsgHandler(old); + + QCOMPARE(transientErrorsMsgCount, 0); + + delete object; + } + + // One binding erroring multiple times, but then resolving + { + QQmlComponent component(&engine, testFileUrl("transientErrors.2.qml")); + + transientErrorsMsgCount = 0; + QtMsgHandler old = qInstallMsgHandler(transientErrorsMsgHandler); + + QObject *object = component.create(); + QVERIFY(object != 0); + + qInstallMsgHandler(old); + + QCOMPARE(transientErrorsMsgCount, 0); + + delete object; + } +} + +// Check that errors during shutdown are minimized +void tst_qqmlecmascript::shutdownErrors() +{ + QQmlComponent component(&engine, testFileUrl("shutdownErrors.qml")); + QObject *object = component.create(); + QVERIFY(object != 0); + + transientErrorsMsgCount = 0; + QtMsgHandler old = qInstallMsgHandler(transientErrorsMsgHandler); + + delete object; + + qInstallMsgHandler(old); + QCOMPARE(transientErrorsMsgCount, 0); +} + +void tst_qqmlecmascript::compositePropertyType() +{ + QQmlComponent component(&engine, testFileUrl("compositePropertyType.qml")); + + QTest::ignoreMessage(QtDebugMsg, "hello world"); + QObject *object = qobject_cast(component.create()); + delete object; +} + +// QTBUG-5759 +void tst_qqmlecmascript::jsObject() +{ + QQmlComponent component(&engine, testFileUrl("jsObject.qml")); + QObject *object = component.create(); + QVERIFY(object != 0); + + QCOMPARE(object->property("test").toInt(), 92); + + delete object; +} + +void tst_qqmlecmascript::undefinedResetsProperty() +{ + { + QQmlComponent component(&engine, testFileUrl("undefinedResetsProperty.qml")); + QObject *object = component.create(); + QVERIFY(object != 0); + + QCOMPARE(object->property("resettableProperty").toInt(), 92); + + object->setProperty("setUndefined", true); + + QCOMPARE(object->property("resettableProperty").toInt(), 13); + + object->setProperty("setUndefined", false); + + QCOMPARE(object->property("resettableProperty").toInt(), 92); + + delete object; + } + { + QQmlComponent component(&engine, testFileUrl("undefinedResetsProperty.2.qml")); + QObject *object = component.create(); + QVERIFY(object != 0); + + QCOMPARE(object->property("resettableProperty").toInt(), 19); + + QMetaObject::invokeMethod(object, "doReset"); + + QCOMPARE(object->property("resettableProperty").toInt(), 13); + + delete object; + } +} + +// Aliases to variant properties should work +void tst_qqmlecmascript::qtbug_22464() +{ + QQmlComponent component(&engine, testFileUrl("qtbug_22464.qml")); + QObject *object = component.create(); + QVERIFY(object != 0); + + QCOMPARE(object->property("test").toBool(), true); + + delete object; +} + +void tst_qqmlecmascript::qtbug_21580() +{ + QQmlComponent component(&engine, testFileUrl("qtbug_21580.qml")); + + QObject *object = component.create(); + QVERIFY(object != 0); + + QCOMPARE(object->property("test").toBool(), true); + + delete object; +} + +// QTBUG-6781 +void tst_qqmlecmascript::bug1() +{ + QQmlComponent component(&engine, testFileUrl("bug.1.qml")); + QObject *object = component.create(); + QVERIFY(object != 0); + + QCOMPARE(object->property("test").toInt(), 14); + + object->setProperty("a", 11); + + QCOMPARE(object->property("test").toInt(), 3); + + object->setProperty("b", true); + + QCOMPARE(object->property("test").toInt(), 9); + + delete object; +} + +void tst_qqmlecmascript::bug2() +{ + QQmlComponent component(&engine); + component.setData("import Qt.test 1.0;\nQPlainTextEdit { width: 100 }", QUrl()); + + QObject *object = component.create(); + QVERIFY(object != 0); + + delete object; +} + +// Don't crash in createObject when the component has errors. +void tst_qqmlecmascript::dynamicCreationCrash() +{ + QQmlComponent component(&engine, testFileUrl("dynamicCreation.qml")); + MyQmlObject *object = qobject_cast(component.create()); + QVERIFY(object != 0); + + QTest::ignoreMessage(QtWarningMsg, "QQmlComponent: Component is not ready"); + QMetaObject::invokeMethod(object, "dontCrash"); + QObject *created = object->objectProperty(); + QVERIFY(created == 0); + + delete object; +} + +// ownership transferred to JS, ensure that GC runs the dtor +void tst_qqmlecmascript::dynamicCreationOwnership() +{ + int dtorCount = 0; + int expectedDtorCount = 1; // start at 1 since we expect mdcdo to dtor too. + + // allow the engine to go out of scope too. + { + QQmlEngine dcoEngine; + QQmlComponent component(&dcoEngine, testFileUrl("dynamicCreationOwnership.qml")); + QObject *object = component.create(); + QVERIFY(object != 0); + MyDynamicCreationDestructionObject *mdcdo = object->findChild("mdcdo"); + QVERIFY(mdcdo != 0); + mdcdo->setDtorCount(&dtorCount); + + for (int i = 1; i < 105; ++i, ++expectedDtorCount) { + QMetaObject::invokeMethod(object, "dynamicallyCreateJsOwnedObject"); + if (i % 90 == 0) { + // we do this once manually, but it should be done automatically + // when the engine goes out of scope (since it should gc in dtor) + QMetaObject::invokeMethod(object, "performGc"); + } + if (i % 10 == 0) { + QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete); + QCoreApplication::processEvents(); + } + } + + delete object; + } + QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete); + QCoreApplication::processEvents(); + QCOMPARE(dtorCount, expectedDtorCount); +} + +void tst_qqmlecmascript::regExpBug() +{ + //QTBUG-9367 + { + QQmlComponent component(&engine, testFileUrl("regExp.qml")); + MyQmlObject *object = qobject_cast(component.create()); + QVERIFY(object != 0); + QCOMPARE(object->regExp().pattern(), QLatin1String("[a-zA-z]")); + delete object; + } + + //QTBUG-23068 + { + QString err = QString(QLatin1String("%1:6 Invalid property assignment: regular expression expected; use /pattern/ syntax\n")).arg(testFileUrl("regExp.2.qml").toString()); + QQmlComponent component(&engine, testFileUrl("regExp.2.qml")); + QTest::ignoreMessage(QtWarningMsg, "QQmlComponent: Component is not ready"); + MyQmlObject *object = qobject_cast(component.create()); + QVERIFY(!object); + QCOMPARE(component.errorString(), err); + } +} + +static inline bool evaluate_error(QV8Engine *engine, v8::Handle o, const char *source) +{ + QString functionSource = QLatin1String("(function(object) { return ") + + QLatin1String(source) + QLatin1String(" })"); + v8::TryCatch tc; + v8::Local program = v8::Script::Compile(engine->toString(functionSource)); + if (tc.HasCaught()) + return false; + v8::Handle function = v8::Handle::Cast(program->Run()); + if (function.IsEmpty()) + return false; + v8::Handle args[] = { o }; + function->Call(engine->global(), 1, args); + return tc.HasCaught(); +} + +static inline bool evaluate_value(QV8Engine *engine, v8::Handle o, + const char *source, v8::Handle result) +{ + QString functionSource = QLatin1String("(function(object) { return ") + + QLatin1String(source) + QLatin1String(" })"); + v8::TryCatch tc; + v8::Local program = v8::Script::Compile(engine->toString(functionSource)); + if (tc.HasCaught()) + return false; + v8::Handle function = v8::Handle::Cast(program->Run()); + if (function.IsEmpty()) + return false; + v8::Handle args[] = { o }; + + v8::Handle value = function->Call(engine->global(), 1, args); + + if (tc.HasCaught()) + return false; + + return value->StrictEquals(result); +} + +static inline v8::Handle evaluate(QV8Engine *engine, v8::Handle o, + const char *source) +{ + QString functionSource = QLatin1String("(function(object) { return ") + + QLatin1String(source) + QLatin1String(" })"); + v8::TryCatch tc; + v8::Local program = v8::Script::Compile(engine->toString(functionSource)); + if (tc.HasCaught()) + return v8::Handle(); + v8::Handle function = v8::Handle::Cast(program->Run()); + if (function.IsEmpty()) + return v8::Handle(); + v8::Handle args[] = { o }; + + v8::Handle value = function->Call(engine->global(), 1, args); + + if (tc.HasCaught()) + return v8::Handle(); + return value; +} + +#define EVALUATE_ERROR(source) evaluate_error(engine, object, source) +#define EVALUATE_VALUE(source, result) evaluate_value(engine, object, source, result) +#define EVALUATE(source) evaluate(engine, object, source) + +void tst_qqmlecmascript::callQtInvokables() +{ + MyInvokableObject o; + + QQmlEngine qmlengine; + QQmlEnginePrivate *ep = QQmlEnginePrivate::get(&qmlengine); + + QV8Engine *engine = ep->v8engine(); + + v8::HandleScope handle_scope; + v8::Context::Scope scope(engine->context()); + + v8::Local object = engine->newQObject(&o)->ToObject(); + + // Non-existent methods + o.reset(); + QVERIFY(EVALUATE_ERROR("object.method_nonexistent()")); + QCOMPARE(o.error(), false); + QCOMPARE(o.invoked(), -1); + QCOMPARE(o.actuals().count(), 0); + + o.reset(); + QVERIFY(EVALUATE_ERROR("object.method_nonexistent(10, 11)")); + QCOMPARE(o.error(), false); + QCOMPARE(o.invoked(), -1); + QCOMPARE(o.actuals().count(), 0); + + // Insufficient arguments + o.reset(); + QVERIFY(EVALUATE_ERROR("object.method_int()")); + QCOMPARE(o.error(), false); + QCOMPARE(o.invoked(), -1); + QCOMPARE(o.actuals().count(), 0); + + o.reset(); + QVERIFY(EVALUATE_ERROR("object.method_intint(10)")); + QCOMPARE(o.error(), false); + QCOMPARE(o.invoked(), -1); + QCOMPARE(o.actuals().count(), 0); + + // Excessive arguments + o.reset(); + QVERIFY(EVALUATE_VALUE("object.method_int(10, 11)", v8::Undefined())); + QCOMPARE(o.error(), false); + QCOMPARE(o.invoked(), 8); + QCOMPARE(o.actuals().count(), 1); + QCOMPARE(o.actuals().at(0), QVariant(10)); + + o.reset(); + QVERIFY(EVALUATE_VALUE("object.method_intint(10, 11, 12)", v8::Undefined())); + QCOMPARE(o.error(), false); + QCOMPARE(o.invoked(), 9); + QCOMPARE(o.actuals().count(), 2); + QCOMPARE(o.actuals().at(0), QVariant(10)); + QCOMPARE(o.actuals().at(1), QVariant(11)); + + // Test return types + o.reset(); + QVERIFY(EVALUATE_VALUE("object.method_NoArgs()", v8::Undefined())); + QCOMPARE(o.error(), false); + QCOMPARE(o.invoked(), 0); + QCOMPARE(o.actuals().count(), 0); + + o.reset(); + QVERIFY(EVALUATE_VALUE("object.method_NoArgs_int()", v8::Integer::New(6))); + QCOMPARE(o.error(), false); + QCOMPARE(o.invoked(), 1); + QCOMPARE(o.actuals().count(), 0); + + o.reset(); + QVERIFY(EVALUATE_VALUE("object.method_NoArgs_real()", v8::Number::New(19.75))); + QCOMPARE(o.error(), false); + QCOMPARE(o.invoked(), 2); + QCOMPARE(o.actuals().count(), 0); + + o.reset(); + { + v8::Handle ret = EVALUATE("object.method_NoArgs_QPointF()"); + QVERIFY(!ret.IsEmpty()); + QCOMPARE(engine->toVariant(ret, -1), QVariant(QPointF(123, 4.5))); + QCOMPARE(o.error(), false); + QCOMPARE(o.invoked(), 3); + QCOMPARE(o.actuals().count(), 0); + } + + o.reset(); + { + v8::Handle ret = EVALUATE("object.method_NoArgs_QObject()"); + QCOMPARE(engine->toQObject(ret), (QObject *)&o); + QCOMPARE(o.error(), false); + QCOMPARE(o.invoked(), 4); + QCOMPARE(o.actuals().count(), 0); + } + + o.reset(); + QVERIFY(EVALUATE_VALUE("object.method_NoArgs_unknown()", v8::Undefined())); + QCOMPARE(o.error(), false); + QCOMPARE(o.invoked(), 5); + QCOMPARE(o.actuals().count(), 0); + + o.reset(); + { + v8::Handle ret = EVALUATE("object.method_NoArgs_QScriptValue()"); + QVERIFY(ret->IsString()); + QCOMPARE(engine->toString(ret), QString("Hello world")); + QCOMPARE(o.error(), false); + QCOMPARE(o.invoked(), 6); + QCOMPARE(o.actuals().count(), 0); + } + + o.reset(); + QVERIFY(EVALUATE_VALUE("object.method_NoArgs_QVariant()", engine->toString("QML rocks"))); + QCOMPARE(o.error(), false); + QCOMPARE(o.invoked(), 7); + QCOMPARE(o.actuals().count(), 0); + + // Test arg types + o.reset(); + QVERIFY(EVALUATE_VALUE("object.method_int(94)", v8::Undefined())); + QCOMPARE(o.error(), false); + QCOMPARE(o.invoked(), 8); + QCOMPARE(o.actuals().count(), 1); + QCOMPARE(o.actuals().at(0), QVariant(94)); + + o.reset(); + QVERIFY(EVALUATE_VALUE("object.method_int(\"94\")", v8::Undefined())); + QCOMPARE(o.error(), false); + QCOMPARE(o.invoked(), 8); + QCOMPARE(o.actuals().count(), 1); + QCOMPARE(o.actuals().at(0), QVariant(94)); + + o.reset(); + QVERIFY(EVALUATE_VALUE("object.method_int(\"not a number\")", v8::Undefined())); + QCOMPARE(o.error(), false); + QCOMPARE(o.invoked(), 8); + QCOMPARE(o.actuals().count(), 1); + QCOMPARE(o.actuals().at(0), QVariant(0)); + + o.reset(); + QVERIFY(EVALUATE_VALUE("object.method_int(null)", v8::Undefined())); + QCOMPARE(o.error(), false); + QCOMPARE(o.invoked(), 8); + QCOMPARE(o.actuals().count(), 1); + QCOMPARE(o.actuals().at(0), QVariant(0)); + + o.reset(); + QVERIFY(EVALUATE_VALUE("object.method_int(undefined)", v8::Undefined())); + QCOMPARE(o.error(), false); + QCOMPARE(o.invoked(), 8); + QCOMPARE(o.actuals().count(), 1); + QCOMPARE(o.actuals().at(0), QVariant(0)); + + o.reset(); + QVERIFY(EVALUATE_VALUE("object.method_int(object)", v8::Undefined())); + QCOMPARE(o.error(), false); + QCOMPARE(o.invoked(), 8); + QCOMPARE(o.actuals().count(), 1); + QCOMPARE(o.actuals().at(0), QVariant(0)); + + o.reset(); + QVERIFY(EVALUATE_VALUE("object.method_intint(122, 9)", v8::Undefined())); + QCOMPARE(o.error(), false); + QCOMPARE(o.invoked(), 9); + QCOMPARE(o.actuals().count(), 2); + QCOMPARE(o.actuals().at(0), QVariant(122)); + QCOMPARE(o.actuals().at(1), QVariant(9)); + + o.reset(); + QVERIFY(EVALUATE_VALUE("object.method_real(94.3)", v8::Undefined())); + QCOMPARE(o.error(), false); + QCOMPARE(o.invoked(), 10); + QCOMPARE(o.actuals().count(), 1); + QCOMPARE(o.actuals().at(0), QVariant(94.3)); + + o.reset(); + QVERIFY(EVALUATE_VALUE("object.method_real(\"94.3\")", v8::Undefined())); + QCOMPARE(o.error(), false); + QCOMPARE(o.invoked(), 10); + QCOMPARE(o.actuals().count(), 1); + QCOMPARE(o.actuals().at(0), QVariant(94.3)); + + o.reset(); + QVERIFY(EVALUATE_VALUE("object.method_real(\"not a number\")", v8::Undefined())); + QCOMPARE(o.error(), false); + QCOMPARE(o.invoked(), 10); + QCOMPARE(o.actuals().count(), 1); + QVERIFY(qIsNaN(o.actuals().at(0).toDouble())); + + o.reset(); + QVERIFY(EVALUATE_VALUE("object.method_real(null)", v8::Undefined())); + QCOMPARE(o.error(), false); + QCOMPARE(o.invoked(), 10); + QCOMPARE(o.actuals().count(), 1); + QCOMPARE(o.actuals().at(0), QVariant(0)); + + o.reset(); + QVERIFY(EVALUATE_VALUE("object.method_real(undefined)", v8::Undefined())); + QCOMPARE(o.error(), false); + QCOMPARE(o.invoked(), 10); + QCOMPARE(o.actuals().count(), 1); + QVERIFY(qIsNaN(o.actuals().at(0).toDouble())); + + o.reset(); + QVERIFY(EVALUATE_VALUE("object.method_real(object)", v8::Undefined())); + QCOMPARE(o.error(), false); + QCOMPARE(o.invoked(), 10); + QCOMPARE(o.actuals().count(), 1); + QVERIFY(qIsNaN(o.actuals().at(0).toDouble())); + + o.reset(); + QVERIFY(EVALUATE_VALUE("object.method_QString(\"Hello world\")", v8::Undefined())); + QCOMPARE(o.error(), false); + QCOMPARE(o.invoked(), 11); + QCOMPARE(o.actuals().count(), 1); + QCOMPARE(o.actuals().at(0), QVariant("Hello world")); + + o.reset(); + QVERIFY(EVALUATE_VALUE("object.method_QString(19)", v8::Undefined())); + QCOMPARE(o.error(), false); + QCOMPARE(o.invoked(), 11); + QCOMPARE(o.actuals().count(), 1); + QCOMPARE(o.actuals().at(0), QVariant("19")); + + o.reset(); + { + QString expected = "MyInvokableObject(0x" + QString::number((quintptr)&o, 16) + ")"; + QVERIFY(EVALUATE_VALUE("object.method_QString(object)", v8::Undefined())); + QCOMPARE(o.error(), false); + QCOMPARE(o.invoked(), 11); + QCOMPARE(o.actuals().count(), 1); + QCOMPARE(o.actuals().at(0), QVariant(expected)); + } + + o.reset(); + QVERIFY(EVALUATE_VALUE("object.method_QString(null)", v8::Undefined())); + QCOMPARE(o.error(), false); + QCOMPARE(o.invoked(), 11); + QCOMPARE(o.actuals().count(), 1); + QCOMPARE(o.actuals().at(0), QVariant(QString())); + + o.reset(); + QVERIFY(EVALUATE_VALUE("object.method_QString(undefined)", v8::Undefined())); + QCOMPARE(o.error(), false); + QCOMPARE(o.invoked(), 11); + QCOMPARE(o.actuals().count(), 1); + QCOMPARE(o.actuals().at(0), QVariant(QString())); + + o.reset(); + QVERIFY(EVALUATE_VALUE("object.method_QPointF(0)", v8::Undefined())); + QCOMPARE(o.error(), false); + QCOMPARE(o.invoked(), 12); + QCOMPARE(o.actuals().count(), 1); + QCOMPARE(o.actuals().at(0), QVariant(QPointF())); + + o.reset(); + QVERIFY(EVALUATE_VALUE("object.method_QPointF(null)", v8::Undefined())); + QCOMPARE(o.error(), false); + QCOMPARE(o.invoked(), 12); + QCOMPARE(o.actuals().count(), 1); + QCOMPARE(o.actuals().at(0), QVariant(QPointF())); + + o.reset(); + QVERIFY(EVALUATE_VALUE("object.method_QPointF(undefined)", v8::Undefined())); + QCOMPARE(o.error(), false); + QCOMPARE(o.invoked(), 12); + QCOMPARE(o.actuals().count(), 1); + QCOMPARE(o.actuals().at(0), QVariant(QPointF())); + + o.reset(); + QVERIFY(EVALUATE_VALUE("object.method_QPointF(object)", v8::Undefined())); + QCOMPARE(o.error(), false); + QCOMPARE(o.invoked(), 12); + QCOMPARE(o.actuals().count(), 1); + QCOMPARE(o.actuals().at(0), QVariant(QPointF())); + + o.reset(); + QVERIFY(EVALUATE_VALUE("object.method_QPointF(object.method_get_QPointF())", v8::Undefined())); + QCOMPARE(o.error(), false); + QCOMPARE(o.invoked(), 12); + QCOMPARE(o.actuals().count(), 1); + QCOMPARE(o.actuals().at(0), QVariant(QPointF(99.3, -10.2))); + + o.reset(); + QVERIFY(EVALUATE_VALUE("object.method_QPointF(object.method_get_QPoint())", v8::Undefined())); + QCOMPARE(o.error(), false); + QCOMPARE(o.invoked(), 12); + QCOMPARE(o.actuals().count(), 1); + QCOMPARE(o.actuals().at(0), QVariant(QPointF(9, 12))); + + o.reset(); + QVERIFY(EVALUATE_VALUE("object.method_QObject(0)", v8::Undefined())); + QCOMPARE(o.error(), false); + QCOMPARE(o.invoked(), 13); + QCOMPARE(o.actuals().count(), 1); + QCOMPARE(o.actuals().at(0), qVariantFromValue((QObject *)0)); + + o.reset(); + QVERIFY(EVALUATE_VALUE("object.method_QObject(\"Hello world\")", v8::Undefined())); + QCOMPARE(o.error(), false); + QCOMPARE(o.invoked(), 13); + QCOMPARE(o.actuals().count(), 1); + QCOMPARE(o.actuals().at(0), qVariantFromValue((QObject *)0)); + + o.reset(); + QVERIFY(EVALUATE_VALUE("object.method_QObject(null)", v8::Undefined())); + QCOMPARE(o.error(), false); + QCOMPARE(o.invoked(), 13); + QCOMPARE(o.actuals().count(), 1); + QCOMPARE(o.actuals().at(0), qVariantFromValue((QObject *)0)); + + o.reset(); + QVERIFY(EVALUATE_VALUE("object.method_QObject(undefined)", v8::Undefined())); + QCOMPARE(o.error(), false); + QCOMPARE(o.invoked(), 13); + QCOMPARE(o.actuals().count(), 1); + QCOMPARE(o.actuals().at(0), qVariantFromValue((QObject *)0)); + + o.reset(); + QVERIFY(EVALUATE_VALUE("object.method_QObject(object)", v8::Undefined())); + QCOMPARE(o.error(), false); + QCOMPARE(o.invoked(), 13); + QCOMPARE(o.actuals().count(), 1); + QCOMPARE(o.actuals().at(0), qVariantFromValue((QObject *)&o)); + + o.reset(); + QVERIFY(EVALUATE_VALUE("object.method_QScriptValue(null)", v8::Undefined())); + QCOMPARE(o.error(), false); + QCOMPARE(o.invoked(), 14); + QCOMPARE(o.actuals().count(), 1); + QVERIFY(qvariant_cast(o.actuals().at(0)).isNull()); + + o.reset(); + QVERIFY(EVALUATE_VALUE("object.method_QScriptValue(undefined)", v8::Undefined())); + QCOMPARE(o.error(), false); + QCOMPARE(o.invoked(), 14); + QCOMPARE(o.actuals().count(), 1); + QVERIFY(qvariant_cast(o.actuals().at(0)).isUndefined()); + + o.reset(); + QVERIFY(EVALUATE_VALUE("object.method_QScriptValue(19)", v8::Undefined())); + QCOMPARE(o.error(), false); + QCOMPARE(o.invoked(), 14); + QCOMPARE(o.actuals().count(), 1); + QVERIFY(qvariant_cast(o.actuals().at(0)).strictlyEquals(QJSValue(19))); + + o.reset(); + QVERIFY(EVALUATE_VALUE("object.method_QScriptValue([19, 20])", v8::Undefined())); + QCOMPARE(o.error(), false); + QCOMPARE(o.invoked(), 14); + QCOMPARE(o.actuals().count(), 1); + QVERIFY(qvariant_cast(o.actuals().at(0)).isArray()); + + o.reset(); + QVERIFY(EVALUATE_VALUE("object.method_intQScriptValue(4, null)", v8::Undefined())); + QCOMPARE(o.error(), false); + QCOMPARE(o.invoked(), 15); + QCOMPARE(o.actuals().count(), 2); + QCOMPARE(o.actuals().at(0), QVariant(4)); + QVERIFY(qvariant_cast(o.actuals().at(1)).isNull()); + + o.reset(); + QVERIFY(EVALUATE_VALUE("object.method_intQScriptValue(8, undefined)", v8::Undefined())); + QCOMPARE(o.error(), false); + QCOMPARE(o.invoked(), 15); + QCOMPARE(o.actuals().count(), 2); + QCOMPARE(o.actuals().at(0), QVariant(8)); + QVERIFY(qvariant_cast(o.actuals().at(1)).isUndefined()); + + o.reset(); + QVERIFY(EVALUATE_VALUE("object.method_intQScriptValue(3, 19)", v8::Undefined())); + QCOMPARE(o.error(), false); + QCOMPARE(o.invoked(), 15); + QCOMPARE(o.actuals().count(), 2); + QCOMPARE(o.actuals().at(0), QVariant(3)); + QVERIFY(qvariant_cast(o.actuals().at(1)).strictlyEquals(QJSValue(19))); + + o.reset(); + QVERIFY(EVALUATE_VALUE("object.method_intQScriptValue(44, [19, 20])", v8::Undefined())); + QCOMPARE(o.error(), false); + QCOMPARE(o.invoked(), 15); + QCOMPARE(o.actuals().count(), 2); + QCOMPARE(o.actuals().at(0), QVariant(44)); + QVERIFY(qvariant_cast(o.actuals().at(1)).isArray()); + + o.reset(); + QVERIFY(EVALUATE_ERROR("object.method_overload()")); + QCOMPARE(o.error(), false); + QCOMPARE(o.invoked(), -1); + QCOMPARE(o.actuals().count(), 0); + + o.reset(); + QVERIFY(EVALUATE_VALUE("object.method_overload(10)", v8::Undefined())); + QCOMPARE(o.error(), false); + QCOMPARE(o.invoked(), 16); + QCOMPARE(o.actuals().count(), 1); + QCOMPARE(o.actuals().at(0), QVariant(10)); + + o.reset(); + QVERIFY(EVALUATE_VALUE("object.method_overload(10, 11)", v8::Undefined())); + QCOMPARE(o.error(), false); + QCOMPARE(o.invoked(), 17); + QCOMPARE(o.actuals().count(), 2); + QCOMPARE(o.actuals().at(0), QVariant(10)); + QCOMPARE(o.actuals().at(1), QVariant(11)); + + o.reset(); + QVERIFY(EVALUATE_VALUE("object.method_overload(\"Hello\")", v8::Undefined())); + QCOMPARE(o.error(), false); + QCOMPARE(o.invoked(), 18); + QCOMPARE(o.actuals().count(), 1); + QCOMPARE(o.actuals().at(0), QVariant(QString("Hello"))); + + o.reset(); + QVERIFY(EVALUATE_VALUE("object.method_with_enum(9)", v8::Undefined())); + QCOMPARE(o.error(), false); + QCOMPARE(o.invoked(), 19); + QCOMPARE(o.actuals().count(), 1); + QCOMPARE(o.actuals().at(0), QVariant(9)); + + o.reset(); + QVERIFY(EVALUATE_VALUE("object.method_default(10)", v8::Integer::New(19))); + QCOMPARE(o.error(), false); + QCOMPARE(o.invoked(), 20); + QCOMPARE(o.actuals().count(), 2); + QCOMPARE(o.actuals().at(0), QVariant(10)); + QCOMPARE(o.actuals().at(1), QVariant(19)); + + o.reset(); + QVERIFY(EVALUATE_VALUE("object.method_default(10, 13)", v8::Integer::New(13))); + QCOMPARE(o.error(), false); + QCOMPARE(o.invoked(), 20); + QCOMPARE(o.actuals().count(), 2); + QCOMPARE(o.actuals().at(0), QVariant(10)); + QCOMPARE(o.actuals().at(1), QVariant(13)); + + o.reset(); + QVERIFY(EVALUATE_VALUE("object.method_inherited(9)", v8::Undefined())); + QCOMPARE(o.error(), false); + QCOMPARE(o.invoked(), -3); + QCOMPARE(o.actuals().count(), 1); + QCOMPARE(o.actuals().at(0), QVariant(9)); + + o.reset(); + QVERIFY(EVALUATE_VALUE("object.method_QVariant(9)", v8::Undefined())); + QCOMPARE(o.error(), false); + QCOMPARE(o.invoked(), 21); + QCOMPARE(o.actuals().count(), 2); + QCOMPARE(o.actuals().at(0), QVariant(9)); + QCOMPARE(o.actuals().at(1), QVariant()); + + o.reset(); + QVERIFY(EVALUATE_VALUE("object.method_QVariant(\"Hello\", \"World\")", v8::Undefined())); + QCOMPARE(o.error(), false); + QCOMPARE(o.invoked(), 21); + QCOMPARE(o.actuals().count(), 2); + QCOMPARE(o.actuals().at(0), QVariant(QString("Hello"))); + QCOMPARE(o.actuals().at(1), QVariant(QString("World"))); +} + +// QTBUG-13047 (check that you can pass registered object types as args) +void tst_qqmlecmascript::invokableObjectArg() +{ + QQmlComponent component(&engine, testFileUrl("invokableObjectArg.qml")); + + QObject *o = component.create(); + QVERIFY(o); + MyQmlObject *qmlobject = qobject_cast(o); + QVERIFY(qmlobject); + QCOMPARE(qmlobject->myinvokableObject, qmlobject); + + delete o; +} + +// QTBUG-13047 (check that you can return registered object types from methods) +void tst_qqmlecmascript::invokableObjectRet() +{ + QQmlComponent component(&engine, testFileUrl("invokableObjectRet.qml")); + + QObject *o = component.create(); + QVERIFY(o); + QCOMPARE(o->property("test").toBool(), true); + delete o; +} + +// QTBUG-5675 +void tst_qqmlecmascript::listToVariant() +{ + QQmlComponent component(&engine, testFileUrl("listToVariant.qml")); + + MyQmlContainer container; + + QQmlContext context(engine.rootContext()); + context.setContextObject(&container); + + QObject *object = component.create(&context); + QVERIFY(object != 0); + + QVariant v = object->property("test"); + QCOMPARE(v.userType(), qMetaTypeId()); + QVERIFY(qvariant_cast(v).object() == &container); + + delete object; +} + +// QTBUG-16316 +Q_DECLARE_METATYPE(QQmlListProperty) +void tst_qqmlecmascript::listAssignment() +{ + QQmlComponent component(&engine, testFileUrl("listAssignment.qml")); + QObject *obj = component.create(); + QCOMPARE(obj->property("list1length").toInt(), 2); + QQmlListProperty list1 = obj->property("list1").value >(); + QQmlListProperty list2 = obj->property("list2").value >(); + QCOMPARE(list1.count(&list1), list2.count(&list2)); + QCOMPARE(list1.at(&list1, 0), list2.at(&list2, 0)); + QCOMPARE(list1.at(&list1, 1), list2.at(&list2, 1)); + delete obj; +} + +// QTBUG-7957 +void tst_qqmlecmascript::multiEngineObject() +{ + MyQmlObject obj; + obj.setStringProperty("Howdy planet"); + + QQmlEngine e1; + e1.rootContext()->setContextProperty("thing", &obj); + QQmlComponent c1(&e1, testFileUrl("multiEngineObject.qml")); + + QQmlEngine e2; + e2.rootContext()->setContextProperty("thing", &obj); + QQmlComponent c2(&e2, testFileUrl("multiEngineObject.qml")); + + QObject *o1 = c1.create(); + QObject *o2 = c2.create(); + + QCOMPARE(o1->property("test").toString(), QString("Howdy planet")); + QCOMPARE(o2->property("test").toString(), QString("Howdy planet")); + + delete o2; + delete o1; +} + +// Test that references to QObjects are cleanup when the object is destroyed +void tst_qqmlecmascript::deletedObject() +{ + QQmlComponent component(&engine, testFileUrl("deletedObject.qml")); + + QObject *object = component.create(); + + QCOMPARE(object->property("test1").toBool(), true); + QCOMPARE(object->property("test2").toBool(), true); + QCOMPARE(object->property("test3").toBool(), true); + QCOMPARE(object->property("test4").toBool(), true); + + delete object; +} + +void tst_qqmlecmascript::attachedPropertyScope() +{ + QQmlComponent component(&engine, testFileUrl("attachedPropertyScope.qml")); + + QObject *object = component.create(); + QVERIFY(object != 0); + + MyQmlAttachedObject *attached = + qobject_cast(qmlAttachedPropertiesObject(object)); + QVERIFY(attached != 0); + + QCOMPARE(object->property("value2").toInt(), 0); + + attached->emitMySignal(); + + QCOMPARE(object->property("value2").toInt(), 9); + + delete object; +} + +void tst_qqmlecmascript::scriptConnect() +{ + { + QQmlComponent component(&engine, testFileUrl("scriptConnect.1.qml")); + + MyQmlObject *object = qobject_cast(component.create()); + QVERIFY(object != 0); + + QCOMPARE(object->property("test").toBool(), false); + emit object->argumentSignal(19, "Hello world!", 10.25, MyQmlObject::EnumValue4, Qt::RightButton); + QCOMPARE(object->property("test").toBool(), true); + + delete object; + } + + { + QQmlComponent component(&engine, testFileUrl("scriptConnect.2.qml")); + + MyQmlObject *object = qobject_cast(component.create()); + QVERIFY(object != 0); + + QCOMPARE(object->property("test").toBool(), false); + emit object->argumentSignal(19, "Hello world!", 10.25, MyQmlObject::EnumValue4, Qt::RightButton); + QCOMPARE(object->property("test").toBool(), true); + + delete object; + } + + { + QQmlComponent component(&engine, testFileUrl("scriptConnect.3.qml")); + + MyQmlObject *object = qobject_cast(component.create()); + QVERIFY(object != 0); + + QCOMPARE(object->property("test").toBool(), false); + emit object->argumentSignal(19, "Hello world!", 10.25, MyQmlObject::EnumValue4, Qt::RightButton); + QCOMPARE(object->property("test").toBool(), true); + + delete object; + } + + { + QQmlComponent component(&engine, testFileUrl("scriptConnect.4.qml")); + + MyQmlObject *object = qobject_cast(component.create()); + QVERIFY(object != 0); + + QCOMPARE(object->methodCalled(), false); + emit object->argumentSignal(19, "Hello world!", 10.25, MyQmlObject::EnumValue4, Qt::RightButton); + QCOMPARE(object->methodCalled(), true); + + delete object; + } + + { + QQmlComponent component(&engine, testFileUrl("scriptConnect.5.qml")); + + MyQmlObject *object = qobject_cast(component.create()); + QVERIFY(object != 0); + + QCOMPARE(object->methodCalled(), false); + emit object->argumentSignal(19, "Hello world!", 10.25, MyQmlObject::EnumValue4, Qt::RightButton); + QCOMPARE(object->methodCalled(), true); + + delete object; + } + + { + QQmlComponent component(&engine, testFileUrl("scriptConnect.6.qml")); + + MyQmlObject *object = qobject_cast(component.create()); + QVERIFY(object != 0); + + QCOMPARE(object->property("test").toInt(), 0); + emit object->argumentSignal(19, "Hello world!", 10.25, MyQmlObject::EnumValue4, Qt::RightButton); + QCOMPARE(object->property("test").toInt(), 2); + + delete object; + } +} + +void tst_qqmlecmascript::scriptDisconnect() +{ + { + QQmlComponent component(&engine, testFileUrl("scriptDisconnect.1.qml")); + + MyQmlObject *object = qobject_cast(component.create()); + QVERIFY(object != 0); + + QCOMPARE(object->property("test").toInt(), 0); + emit object->argumentSignal(19, "Hello world!", 10.25, MyQmlObject::EnumValue4, Qt::RightButton); + QCOMPARE(object->property("test").toInt(), 1); + emit object->argumentSignal(19, "Hello world!", 10.25, MyQmlObject::EnumValue4, Qt::RightButton); + QCOMPARE(object->property("test").toInt(), 2); + emit object->basicSignal(); + QCOMPARE(object->property("test").toInt(), 2); + emit object->argumentSignal(19, "Hello world!", 10.25, MyQmlObject::EnumValue4, Qt::RightButton); + QCOMPARE(object->property("test").toInt(), 2); + + delete object; + } + + { + QQmlComponent component(&engine, testFileUrl("scriptDisconnect.2.qml")); + + MyQmlObject *object = qobject_cast(component.create()); + QVERIFY(object != 0); + + QCOMPARE(object->property("test").toInt(), 0); + emit object->argumentSignal(19, "Hello world!", 10.25, MyQmlObject::EnumValue4, Qt::RightButton); + QCOMPARE(object->property("test").toInt(), 1); + emit object->argumentSignal(19, "Hello world!", 10.25, MyQmlObject::EnumValue4, Qt::RightButton); + QCOMPARE(object->property("test").toInt(), 2); + emit object->basicSignal(); + QCOMPARE(object->property("test").toInt(), 2); + emit object->argumentSignal(19, "Hello world!", 10.25, MyQmlObject::EnumValue4, Qt::RightButton); + QCOMPARE(object->property("test").toInt(), 2); + + delete object; + } + + { + QQmlComponent component(&engine, testFileUrl("scriptDisconnect.3.qml")); + + MyQmlObject *object = qobject_cast(component.create()); + QVERIFY(object != 0); + + QCOMPARE(object->property("test").toInt(), 0); + emit object->argumentSignal(19, "Hello world!", 10.25, MyQmlObject::EnumValue4, Qt::RightButton); + QCOMPARE(object->property("test").toInt(), 1); + emit object->argumentSignal(19, "Hello world!", 10.25, MyQmlObject::EnumValue4, Qt::RightButton); + QCOMPARE(object->property("test").toInt(), 2); + emit object->basicSignal(); + QCOMPARE(object->property("test").toInt(), 2); + emit object->argumentSignal(19, "Hello world!", 10.25, MyQmlObject::EnumValue4, Qt::RightButton); + QCOMPARE(object->property("test").toInt(), 3); + + delete object; + } + { + QQmlComponent component(&engine, testFileUrl("scriptDisconnect.4.qml")); + + MyQmlObject *object = qobject_cast(component.create()); + QVERIFY(object != 0); + + QCOMPARE(object->property("test").toInt(), 0); + emit object->argumentSignal(19, "Hello world!", 10.25, MyQmlObject::EnumValue4, Qt::RightButton); + QCOMPARE(object->property("test").toInt(), 1); + emit object->argumentSignal(19, "Hello world!", 10.25, MyQmlObject::EnumValue4, Qt::RightButton); + QCOMPARE(object->property("test").toInt(), 2); + emit object->basicSignal(); + QCOMPARE(object->property("test").toInt(), 2); + emit object->argumentSignal(19, "Hello world!", 10.25, MyQmlObject::EnumValue4, Qt::RightButton); + QCOMPARE(object->property("test").toInt(), 3); + + delete object; + } +} + +class OwnershipObject : public QObject +{ + Q_OBJECT +public: + OwnershipObject() { object = new QObject; } + + QPointer object; + +public slots: + QObject *getObject() { return object; } +}; + +void tst_qqmlecmascript::ownership() +{ + OwnershipObject own; + QQmlContext *context = new QQmlContext(engine.rootContext()); + context->setContextObject(&own); + + { + QQmlComponent component(&engine, testFileUrl("ownership.qml")); + + QVERIFY(own.object != 0); + + QObject *object = component.create(context); + + engine.collectGarbage(); + + QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete); + QCoreApplication::processEvents(); + + QVERIFY(own.object == 0); + + delete object; + } + + own.object = new QObject(&own); + + { + QQmlComponent component(&engine, testFileUrl("ownership.qml")); + + QVERIFY(own.object != 0); + + QObject *object = component.create(context); + + engine.collectGarbage(); + + QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete); + QCoreApplication::processEvents(); + + QVERIFY(own.object != 0); + + delete object; + } + + delete context; +} + +class CppOwnershipReturnValue : public QObject +{ + Q_OBJECT +public: + CppOwnershipReturnValue() : value(0) {} + ~CppOwnershipReturnValue() { delete value; } + + Q_INVOKABLE QObject *create() { + value = new QObject; + QQmlEngine::setObjectOwnership(value, QQmlEngine::CppOwnership); + return value; + } + + Q_INVOKABLE MyQmlObject *createQmlObject() { + MyQmlObject *rv = new MyQmlObject; + value = rv; + return rv; + } + + QPointer value; +}; + +// QTBUG-15695. +// Test setObjectOwnership(CppOwnership) works even when there is no QQmlData +void tst_qqmlecmascript::cppOwnershipReturnValue() +{ + CppOwnershipReturnValue source; + + { + QQmlEngine engine; + engine.rootContext()->setContextProperty("source", &source); + + QVERIFY(source.value == 0); + + QQmlComponent component(&engine); + component.setData("import QtQuick 2.0\nQtObject {\nComponent.onCompleted: { var a = source.create(); }\n}\n", QUrl()); + + QObject *object = component.create(); + + QVERIFY(object != 0); + QVERIFY(source.value != 0); + + delete object; + } + + QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete); + QCoreApplication::processEvents(); + + QVERIFY(source.value != 0); +} + +// QTBUG-15697 +void tst_qqmlecmascript::ownershipCustomReturnValue() +{ + CppOwnershipReturnValue source; + + { + QQmlEngine engine; + engine.rootContext()->setContextProperty("source", &source); + + QVERIFY(source.value == 0); + + QQmlComponent component(&engine); + component.setData("import QtQuick 2.0\nQtObject {\nComponent.onCompleted: { var a = source.createQmlObject(); }\n}\n", QUrl()); + + QObject *object = component.create(); + + QVERIFY(object != 0); + QVERIFY(source.value != 0); + + delete object; + } + + engine.collectGarbage(); + QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete); + QCoreApplication::processEvents(); + + QVERIFY(source.value == 0); +} + +class QListQObjectMethodsObject : public QObject +{ + Q_OBJECT +public: + QListQObjectMethodsObject() { + m_objects.append(new MyQmlObject()); + m_objects.append(new MyQmlObject()); + } + + ~QListQObjectMethodsObject() { + qDeleteAll(m_objects); + } + +public slots: + QList getObjects() { return m_objects; } + +private: + QList m_objects; +}; + +// Tests that returning a QList from a method works +void tst_qqmlecmascript::qlistqobjectMethods() +{ + QListQObjectMethodsObject obj; + QQmlContext *context = new QQmlContext(engine.rootContext()); + context->setContextObject(&obj); + + QQmlComponent component(&engine, testFileUrl("qlistqobjectMethods.qml")); + + QObject *object = component.create(context); + + QCOMPARE(object->property("test").toInt(), 2); + QCOMPARE(object->property("test2").toBool(), true); + + delete object; + delete context; +} + +// QTBUG-9205 +void tst_qqmlecmascript::strictlyEquals() +{ + QQmlComponent component(&engine, testFileUrl("strictlyEquals.qml")); + + QObject *object = component.create(); + QVERIFY(object != 0); + + QCOMPARE(object->property("test1").toBool(), true); + QCOMPARE(object->property("test2").toBool(), true); + QCOMPARE(object->property("test3").toBool(), true); + QCOMPARE(object->property("test4").toBool(), true); + QCOMPARE(object->property("test5").toBool(), true); + QCOMPARE(object->property("test6").toBool(), true); + QCOMPARE(object->property("test7").toBool(), true); + QCOMPARE(object->property("test8").toBool(), true); + + delete object; +} + +void tst_qqmlecmascript::compiled() +{ + QQmlComponent component(&engine, testFileUrl("compiled.qml")); + + QObject *object = component.create(); + QVERIFY(object != 0); + + QCOMPARE(object->property("test1").toReal(), qreal(15.7)); + QCOMPARE(object->property("test2").toReal(), qreal(-6.7)); + QCOMPARE(object->property("test3").toBool(), true); + QCOMPARE(object->property("test4").toBool(), false); + QCOMPARE(object->property("test5").toBool(), false); + QCOMPARE(object->property("test6").toBool(), true); + + QCOMPARE(object->property("test7").toInt(), 185); + QCOMPARE(object->property("test8").toInt(), 167); + QCOMPARE(object->property("test9").toBool(), true); + QCOMPARE(object->property("test10").toBool(), false); + QCOMPARE(object->property("test11").toBool(), false); + QCOMPARE(object->property("test12").toBool(), true); + + QCOMPARE(object->property("test13").toString(), QLatin1String("HelloWorld")); + QCOMPARE(object->property("test14").toString(), QLatin1String("Hello World")); + QCOMPARE(object->property("test15").toBool(), false); + QCOMPARE(object->property("test16").toBool(), true); + + QCOMPARE(object->property("test17").toInt(), 5); + QCOMPARE(object->property("test18").toReal(), qreal(176)); + QCOMPARE(object->property("test19").toInt(), 7); + QCOMPARE(object->property("test20").toReal(), qreal(6.7)); + QCOMPARE(object->property("test21").toString(), QLatin1String("6.7")); + QCOMPARE(object->property("test22").toString(), QLatin1String("!")); + QCOMPARE(object->property("test23").toBool(), true); + QCOMPARE(qvariant_cast(object->property("test24")), QColor(0x11,0x22,0x33)); + QCOMPARE(qvariant_cast(object->property("test25")), QColor(0x11,0x22,0x33,0xAA)); + + delete object; +} + +// Test that numbers assigned in bindings as strings work consistently +void tst_qqmlecmascript::numberAssignment() +{ + QQmlComponent component(&engine, testFileUrl("numberAssignment.qml")); + + QObject *object = component.create(); + QVERIFY(object != 0); + + QCOMPARE(object->property("test1"), QVariant((qreal)6.7)); + QCOMPARE(object->property("test2"), QVariant((qreal)6.7)); + QCOMPARE(object->property("test2"), QVariant((qreal)6.7)); + QCOMPARE(object->property("test3"), QVariant((qreal)6)); + QCOMPARE(object->property("test4"), QVariant((qreal)6)); + + QCOMPARE(object->property("test5"), QVariant((int)7)); + QCOMPARE(object->property("test6"), QVariant((int)7)); + QCOMPARE(object->property("test7"), QVariant((int)6)); + QCOMPARE(object->property("test8"), QVariant((int)6)); + + QCOMPARE(object->property("test9"), QVariant((unsigned int)7)); + QCOMPARE(object->property("test10"), QVariant((unsigned int)7)); + QCOMPARE(object->property("test11"), QVariant((unsigned int)6)); + QCOMPARE(object->property("test12"), QVariant((unsigned int)6)); + + delete object; +} + +void tst_qqmlecmascript::propertySplicing() +{ + QQmlComponent component(&engine, testFileUrl("propertySplicing.qml")); + + QObject *object = component.create(); + QVERIFY(object != 0); + + QCOMPARE(object->property("test").toBool(), true); + + delete object; +} + +// QTBUG-16683 +void tst_qqmlecmascript::signalWithUnknownTypes() +{ + QQmlComponent component(&engine, testFileUrl("signalWithUnknownTypes.qml")); + + MyQmlObject *object = qobject_cast(component.create()); + QVERIFY(object != 0); + + MyQmlObject::MyType type; + type.value = 0x8971123; + emit object->signalWithUnknownType(type); + + MyQmlObject::MyType result = qvariant_cast(object->variant()); + + QCOMPARE(result.value, type.value); + + + delete object; +} + +void tst_qqmlecmascript::signalWithJSValueInVariant_data() +{ + QTest::addColumn("expression"); + QTest::addColumn("compare"); + + QString compareStrict("(function(a, b) { return a === b; })"); + QTest::newRow("true") << "true" << compareStrict; + QTest::newRow("undefined") << "undefined" << compareStrict; + QTest::newRow("null") << "null" << compareStrict; + QTest::newRow("123") << "123" << compareStrict; + QTest::newRow("'ciao'") << "'ciao'" << compareStrict; + + QString comparePropertiesStrict( + "(function(a, b) {" + " if (typeof b != 'object')" + " return a === b;" + " var props = Object.getOwnPropertyNames(b);" + " for (var i = 0; i < props.length; ++i) {" + " var p = props[i];" + " return arguments.callee(a[p], b[p]);" + " }" + "})"); + QTest::newRow("{ foo: 'bar' }") << "({ foo: 'bar' })" << comparePropertiesStrict; + QTest::newRow("[10,20,30]") << "[10,20,30]" << comparePropertiesStrict; +} + +void tst_qqmlecmascript::signalWithJSValueInVariant() +{ + QFETCH(QString, expression); + QFETCH(QString, compare); + + QQmlComponent component(&engine, testFileUrl("signalWithJSValueInVariant.qml")); + QScopedPointer object(qobject_cast(component.create())); + QVERIFY(object != 0); + + QJSValue value = engine.evaluate(expression); + QVERIFY(!engine.hasUncaughtException()); + object->setProperty("expression", expression); + object->setProperty("compare", compare); + object->setProperty("pass", false); + + emit object->signalWithVariant(QVariant::fromValue(value)); + QVERIFY(object->property("pass").toBool()); +} + +void tst_qqmlecmascript::signalWithJSValueInVariant_twoEngines_data() +{ + signalWithJSValueInVariant_data(); +} + +void tst_qqmlecmascript::signalWithJSValueInVariant_twoEngines() +{ + QFETCH(QString, expression); + QFETCH(QString, compare); + + QQmlComponent component(&engine, testFileUrl("signalWithJSValueInVariant.qml")); + QScopedPointer object(qobject_cast(component.create())); + QVERIFY(object != 0); + + QJSEngine engine2; + QJSValue value = engine2.evaluate(expression); + QVERIFY(!engine2.hasUncaughtException()); + object->setProperty("expression", expression); + object->setProperty("compare", compare); + object->setProperty("pass", false); + + QTest::ignoreMessage(QtWarningMsg, "JSValue can't be rassigned to an another engine."); + emit object->signalWithVariant(QVariant::fromValue(value)); + QVERIFY(!object->property("pass").toBool()); +} + +void tst_qqmlecmascript::signalWithQJSValue_data() +{ + signalWithJSValueInVariant_data(); +} + +void tst_qqmlecmascript::signalWithQJSValue() +{ + QFETCH(QString, expression); + QFETCH(QString, compare); + + QQmlComponent component(&engine, testFileUrl("signalWithQJSValue.qml")); + QScopedPointer object(qobject_cast(component.create())); + QVERIFY(object != 0); + + QJSValue value = engine.evaluate(expression); + QVERIFY(!engine.hasUncaughtException()); + object->setProperty("expression", expression); + object->setProperty("compare", compare); + object->setProperty("pass", false); + + emit object->signalWithQJSValue(value); + + QVERIFY(object->property("pass").toBool()); + QVERIFY(object->qjsvalue().strictlyEquals(value)); +} + +void tst_qqmlecmascript::moduleApi_data() +{ + QTest::addColumn("testfile"); + QTest::addColumn("errorMessage"); + QTest::addColumn("warningMessages"); + QTest::addColumn("readProperties"); + QTest::addColumn("readExpectedValues"); + QTest::addColumn("writeProperties"); + QTest::addColumn("writeValues"); + QTest::addColumn("readBackProperties"); + QTest::addColumn("readBackExpectedValues"); + + QTest::newRow("qobject, register + read + method") + << testFileUrl("moduleapi/qobjectModuleApi.qml") + << QString() + << QStringList() + << (QStringList() << "existingUriTest" << "qobjectTest" << "qobjectMethodTest" + << "qobjectMinorVersionTest" << "qobjectMajorVersionTest" << "qobjectParentedTest") + << (QVariantList() << 20 << 20 << 1 << 20 << 20 << 26) + << QStringList() + << QVariantList() + << QStringList() + << QVariantList(); + + QTest::newRow("script, register + read") + << testFileUrl("moduleapi/scriptModuleApi.qml") + << QString() + << QStringList() + << (QStringList() << "scriptTest") + << (QVariantList() << 13) + << QStringList() + << QVariantList() + << QStringList() + << QVariantList(); + + QTest::newRow("qobject, caching + read") + << testFileUrl("moduleapi/qobjectModuleApiCaching.qml") + << QString() + << QStringList() + << (QStringList() << "existingUriTest" << "qobjectParentedTest") + << (QVariantList() << 20 << 26) // 26, shouldn't have incremented to 27. + << QStringList() + << QVariantList() + << QStringList() + << QVariantList(); + + QTest::newRow("script, caching + read") + << testFileUrl("moduleapi/scriptModuleApiCaching.qml") + << QString() + << QStringList() + << (QStringList() << "scriptTest") + << (QVariantList() << 13) // 13, shouldn't have incremented to 14. + << QStringList() + << QVariantList() + << QStringList() + << QVariantList(); + + QTest::newRow("qobject, writing + readonly constraints") + << testFileUrl("moduleapi/qobjectModuleApiWriting.qml") + << QString() + << (QStringList() << QString(QLatin1String("file://") + testFileUrl("moduleapi/qobjectModuleApiWriting.qml").toLocalFile() + QLatin1String(":14: Error: Cannot assign to read-only property \"qobjectTestProperty\""))) + << (QStringList() << "readOnlyProperty" << "writableProperty") + << (QVariantList() << 20 << 50) + << (QStringList() << "firstProperty" << "writableProperty") + << (QVariantList() << 30 << 30) + << (QStringList() << "readOnlyProperty" << "writableProperty") + << (QVariantList() << 20 << 30); + + QTest::newRow("script, writing + readonly constraints") + << testFileUrl("moduleapi/scriptModuleApiWriting.qml") + << QString() + << (QStringList() << QString(QLatin1String("file://") + testFileUrl("moduleapi/scriptModuleApiWriting.qml").toLocalFile() + QLatin1String(":21: Error: Cannot assign to read-only property \"scriptTestProperty\""))) + << (QStringList() << "readBack" << "unchanged") + << (QVariantList() << 13 << 42) + << (QStringList() << "firstProperty" << "secondProperty") + << (QVariantList() << 30 << 30) + << (QStringList() << "readBack" << "unchanged") + << (QVariantList() << 30 << 42); + + QTest::newRow("qobject module API enum values in JS") + << testFileUrl("moduleapi/qobjectModuleApiEnums.qml") + << QString() + << QStringList() + << (QStringList() << "enumValue" << "enumMethod") + << (QVariantList() << 42 << 30) + << QStringList() + << QVariantList() + << QStringList() + << QVariantList(); + + QTest::newRow("qobject, invalid major version fail") + << testFileUrl("moduleapi/moduleApiMajorVersionFail.qml") + << QString("QQmlComponent: Component is not ready") + << QStringList() + << QStringList() + << QVariantList() + << QStringList() + << QVariantList() + << QStringList() + << QVariantList(); + + QTest::newRow("qobject, invalid minor version fail") + << testFileUrl("moduleapi/moduleApiMinorVersionFail.qml") + << QString("QQmlComponent: Component is not ready") + << QStringList() + << QStringList() + << QVariantList() + << QStringList() + << QVariantList() + << QStringList() + << QVariantList(); +} + +void tst_qqmlecmascript::moduleApi() +{ + QFETCH(QUrl, testfile); + QFETCH(QString, errorMessage); + QFETCH(QStringList, warningMessages); + QFETCH(QStringList, readProperties); + QFETCH(QVariantList, readExpectedValues); + QFETCH(QStringList, writeProperties); + QFETCH(QVariantList, writeValues); + QFETCH(QStringList, readBackProperties); + QFETCH(QVariantList, readBackExpectedValues); + + QQmlComponent component(&engine, testfile); + + if (!errorMessage.isEmpty()) + QTest::ignoreMessage(QtWarningMsg, errorMessage.toAscii().constData()); + + if (warningMessages.size()) + foreach (const QString &warning, warningMessages) + QTest::ignoreMessage(QtWarningMsg, warning.toAscii().constData()); + + QObject *object = component.create(); + if (!errorMessage.isEmpty()) { + QVERIFY(object == 0); + } else { + QVERIFY(object != 0); + for (int i = 0; i < readProperties.size(); ++i) + QCOMPARE(object->property(readProperties.at(i).toAscii().constData()), readExpectedValues.at(i)); + for (int i = 0; i < writeProperties.size(); ++i) + QVERIFY(object->setProperty(writeProperties.at(i).toAscii().constData(), writeValues.at(i))); + for (int i = 0; i < readBackProperties.size(); ++i) + QCOMPARE(object->property(readBackProperties.at(i).toAscii().constData()), readBackExpectedValues.at(i)); + delete object; + } +} + +void tst_qqmlecmascript::importScripts_data() +{ + QTest::addColumn("testfile"); + QTest::addColumn("errorMessage"); + QTest::addColumn("warningMessages"); + QTest::addColumn("propertyNames"); + QTest::addColumn("propertyValues"); + + QTest::newRow("basic functionality") + << testFileUrl("jsimport/testImport.qml") + << QString() + << QStringList() + << (QStringList() << QLatin1String("importedScriptStringValue") + << QLatin1String("importedScriptFunctionValue") + << QLatin1String("importedModuleAttachedPropertyValue") + << QLatin1String("importedModuleEnumValue")) + << (QVariantList() << QVariant(QLatin1String("Hello, World!")) + << QVariant(20) + << QVariant(19) + << QVariant(2)); + + QTest::newRow("import scoping") + << testFileUrl("jsimport/testImportScoping.qml") + << QString() + << QStringList() + << (QStringList() << QLatin1String("componentError")) + << (QVariantList() << QVariant(5)); + + QTest::newRow("parent scope shouldn't be inherited by import with imports") + << testFileUrl("jsimportfail/failOne.qml") + << QString() + << (QStringList() << QString(QLatin1String("file://") + testFileUrl("jsimportfail/failOne.qml").toLocalFile() + QLatin1String(":6: TypeError: Cannot call method 'greetingString' of undefined"))) + << (QStringList() << QLatin1String("importScriptFunctionValue")) + << (QVariantList() << QVariant(QString())); + + QTest::newRow("javascript imports in an import should be private to the import scope") + << testFileUrl("jsimportfail/failTwo.qml") + << QString() + << (QStringList() << QString(QLatin1String("file://") + testFileUrl("jsimportfail/failTwo.qml").toLocalFile() + QLatin1String(":6: ReferenceError: Can't find variable: ImportOneJs"))) + << (QStringList() << QLatin1String("importScriptFunctionValue")) + << (QVariantList() << QVariant(QString())); + + QTest::newRow("module imports in an import should be private to the import scope") + << testFileUrl("jsimportfail/failThree.qml") + << QString() + << (QStringList() << QString(QLatin1String("file://") + testFileUrl("jsimportfail/failThree.qml").toLocalFile() + QLatin1String(":7: TypeError: Cannot read property 'JsQtTest' of undefined"))) + << (QStringList() << QLatin1String("importedModuleAttachedPropertyValue")) + << (QVariantList() << QVariant(false)); + + QTest::newRow("typenames in an import should be private to the import scope") + << testFileUrl("jsimportfail/failFour.qml") + << QString() + << (QStringList() << QString(QLatin1String("file://") + testFileUrl("jsimportfail/failFour.qml").toLocalFile() + QLatin1String(":6: ReferenceError: Can't find variable: JsQtTest"))) + << (QStringList() << QLatin1String("importedModuleEnumValue")) + << (QVariantList() << QVariant(0)); + + QTest::newRow("import with imports has it's own activation scope") + << testFileUrl("jsimportfail/failFive.qml") + << QString() + << (QStringList() << QString(QLatin1String("file://") + testFileUrl("jsimportfail/importWithImports.js").toLocalFile() + QLatin1String(":8: ReferenceError: Can't find variable: Component"))) + << (QStringList() << QLatin1String("componentError")) + << (QVariantList() << QVariant(0)); + + QTest::newRow("import pragma library script") + << testFileUrl("jsimport/testImportPragmaLibrary.qml") + << QString() + << QStringList() + << (QStringList() << QLatin1String("testValue")) + << (QVariantList() << QVariant(31)); + + QTest::newRow("pragma library imports shouldn't inherit parent imports or scope") + << testFileUrl("jsimportfail/testImportPragmaLibrary.qml") + << QString() + << (QStringList() << QString(QLatin1String("file://") + testFileUrl("jsimportfail/importPragmaLibrary.js").toLocalFile() + QLatin1String(":6: ReferenceError: Can't find variable: Component"))) + << (QStringList() << QLatin1String("testValue")) + << (QVariantList() << QVariant(0)); + + QTest::newRow("import pragma library script which has an import") + << testFileUrl("jsimport/testImportPragmaLibraryWithImports.qml") + << QString() + << QStringList() + << (QStringList() << QLatin1String("testValue")) + << (QVariantList() << QVariant(55)); + + QTest::newRow("import pragma library script which has a pragma library import") + << testFileUrl("jsimport/testImportPragmaLibraryWithPragmaLibraryImports.qml") + << QString() + << QStringList() + << (QStringList() << QLatin1String("testValue")) + << (QVariantList() << QVariant(18)); +} + +void tst_qqmlecmascript::importScripts() +{ + QFETCH(QUrl, testfile); + QFETCH(QString, errorMessage); + QFETCH(QStringList, warningMessages); + QFETCH(QStringList, propertyNames); + QFETCH(QVariantList, propertyValues); + + QQmlComponent component(&engine, testfile); + + if (!errorMessage.isEmpty()) + QTest::ignoreMessage(QtWarningMsg, errorMessage.toAscii().constData()); + + if (warningMessages.size()) + foreach (const QString &warning, warningMessages) + QTest::ignoreMessage(QtWarningMsg, warning.toAscii().constData()); + + QObject *object = component.create(); + if (!errorMessage.isEmpty()) { + QVERIFY(object == 0); + } else { + QVERIFY(object != 0); + for (int i = 0; i < propertyNames.size(); ++i) + QCOMPARE(object->property(propertyNames.at(i).toAscii().constData()), propertyValues.at(i)); + delete object; + } +} + +void tst_qqmlecmascript::scarceResources_other() +{ + /* These tests require knowledge of state, since we test values after + performing signal or function invocation. */ + + QPixmap origPixmap(100, 100); + origPixmap.fill(Qt::blue); + QString srp_name, expectedWarning; + QQmlEnginePrivate *ep = QQmlEnginePrivate::get(&engine); + ScarceResourceObject *eo = 0; + QObject *srsc = 0; + QObject *object = 0; + + /* property var semantics */ + + // test that scarce resources are handled properly in signal invocation + QQmlComponent varComponentTen(&engine, testFileUrl("scarceResourceSignal.var.qml")); + object = varComponentTen.create(); + srsc = object->findChild("srsc"); + QVERIFY(srsc); + QVERIFY(!srsc->property("scarceResourceCopy").isValid()); // hasn't been instantiated yet. + QCOMPARE(srsc->property("width"), QVariant(5)); // default value is 5. + eo = qobject_cast(QQmlProperty::read(object, "a").value()); + QVERIFY(eo->scarceResourceIsDetached()); // should be no other copies of it at this stage. + QMetaObject::invokeMethod(srsc, "testSignal"); + QVERIFY(!srsc->property("scarceResourceCopy").isValid()); // still hasn't been instantiated + QCOMPARE(srsc->property("width"), QVariant(10)); // but width was assigned to 10. + eo = qobject_cast(QQmlProperty::read(object, "a").value()); + QVERIFY(eo->scarceResourceIsDetached()); // should still be no other copies of it at this stage. + QMetaObject::invokeMethod(srsc, "testSignal2"); // assigns scarceResourceCopy to the scarce pixmap. + QVERIFY(srsc->property("scarceResourceCopy").isValid()); + QCOMPARE(srsc->property("scarceResourceCopy").value(), origPixmap); + eo = qobject_cast(QQmlProperty::read(object, "a").value()); + QVERIFY(!(eo->scarceResourceIsDetached())); // should be another copy of the resource now. + QVERIFY(ep->scarceResources.isEmpty()); // should have been released by this point. + delete object; + + // test that scarce resources are handled properly from js functions in qml files + QQmlComponent varComponentEleven(&engine, testFileUrl("scarceResourceFunction.var.qml")); + object = varComponentEleven.create(); + QVERIFY(object != 0); + QVERIFY(!object->property("scarceResourceCopy").isValid()); // not yet assigned, so should not be valid + eo = qobject_cast(QQmlProperty::read(object, "a").value()); + QVERIFY(eo->scarceResourceIsDetached()); // should be no other copies of it at this stage. + QMetaObject::invokeMethod(object, "retrieveScarceResource"); + QVERIFY(object->property("scarceResourceCopy").isValid()); // assigned, so should be valid. + QCOMPARE(object->property("scarceResourceCopy").value(), origPixmap); + eo = qobject_cast(QQmlProperty::read(object, "a").value()); + QVERIFY(!eo->scarceResourceIsDetached()); // should be a copy of the resource at this stage. + QMetaObject::invokeMethod(object, "releaseScarceResource"); + QVERIFY(!object->property("scarceResourceCopy").isValid()); // just released, so should not be valid + eo = qobject_cast(QQmlProperty::read(object, "a").value()); + QVERIFY(eo->scarceResourceIsDetached()); // should be no other copies of it at this stage. + QVERIFY(ep->scarceResources.isEmpty()); // should have been released by this point. + delete object; + + // test that if an exception occurs while invoking js function from cpp, that the resources are released. + QQmlComponent varComponentTwelve(&engine, testFileUrl("scarceResourceFunctionFail.var.qml")); + object = varComponentTwelve.create(); + QVERIFY(object != 0); + QVERIFY(!object->property("scarceResourceCopy").isValid()); // not yet assigned, so should not be valid + eo = qobject_cast(QQmlProperty::read(object, "a").value()); + QVERIFY(eo->scarceResourceIsDetached()); // should be no other copies of it at this stage. + srp_name = object->property("srp_name").toString(); + expectedWarning = varComponentTwelve.url().toString() + QLatin1String(":16: TypeError: Property 'scarceResource' of object ") + srp_name + QLatin1String(" is not a function"); + QTest::ignoreMessage(QtWarningMsg, qPrintable(expectedWarning)); // we expect a meaningful warning to be printed. + QMetaObject::invokeMethod(object, "retrieveScarceResource"); + QVERIFY(!object->property("scarceResourceCopy").isValid()); // due to exception, assignment will NOT have occurred. + eo = qobject_cast(QQmlProperty::read(object, "a").value()); + QVERIFY(eo->scarceResourceIsDetached()); // should be no other copies of it at this stage. + QVERIFY(ep->scarceResources.isEmpty()); // should have been released by this point. + delete object; + + // test that if an Item which has JS ownership but has a scarce resource property is garbage collected, + // that the scarce resource is removed from the engine's list of scarce resources to clean up. + QQmlComponent varComponentThirteen(&engine, testFileUrl("scarceResourceObjectGc.var.qml")); + object = varComponentThirteen.create(); + QVERIFY(object != 0); + QVERIFY(!object->property("varProperty").isValid()); // not assigned yet + QMetaObject::invokeMethod(object, "assignVarProperty"); + QVERIFY(ep->scarceResources.isEmpty()); // the scarce resource is a VME property. + QMetaObject::invokeMethod(object, "deassignVarProperty"); + QVERIFY(ep->scarceResources.isEmpty()); // should still be empty; the resource should have been released on gc. + delete object; + + /* property variant semantics */ + + // test that scarce resources are handled properly in signal invocation + QQmlComponent variantComponentTen(&engine, testFileUrl("scarceResourceSignal.variant.qml")); + object = variantComponentTen.create(); + QVERIFY(object != 0); + srsc = object->findChild("srsc"); + QVERIFY(srsc); + QVERIFY(!srsc->property("scarceResourceCopy").isValid()); // hasn't been instantiated yet. + QCOMPARE(srsc->property("width"), QVariant(5)); // default value is 5. + eo = qobject_cast(QQmlProperty::read(object, "a").value()); + QVERIFY(eo->scarceResourceIsDetached()); // should be no other copies of it at this stage. + QMetaObject::invokeMethod(srsc, "testSignal"); + QVERIFY(!srsc->property("scarceResourceCopy").isValid()); // still hasn't been instantiated + QCOMPARE(srsc->property("width"), QVariant(10)); // but width was assigned to 10. + eo = qobject_cast(QQmlProperty::read(object, "a").value()); + QVERIFY(eo->scarceResourceIsDetached()); // should still be no other copies of it at this stage. + QMetaObject::invokeMethod(srsc, "testSignal2"); // assigns scarceResourceCopy to the scarce pixmap. + QVERIFY(srsc->property("scarceResourceCopy").isValid()); + QCOMPARE(srsc->property("scarceResourceCopy").value(), origPixmap); + eo = qobject_cast(QQmlProperty::read(object, "a").value()); + QVERIFY(!(eo->scarceResourceIsDetached())); // should be another copy of the resource now. + QVERIFY(ep->scarceResources.isEmpty()); // should have been released by this point. + delete object; + + // test that scarce resources are handled properly from js functions in qml files + QQmlComponent variantComponentEleven(&engine, testFileUrl("scarceResourceFunction.variant.qml")); + object = variantComponentEleven.create(); + QVERIFY(object != 0); + QVERIFY(!object->property("scarceResourceCopy").isValid()); // not yet assigned, so should not be valid + eo = qobject_cast(QQmlProperty::read(object, "a").value()); + QVERIFY(eo->scarceResourceIsDetached()); // should be no other copies of it at this stage. + QMetaObject::invokeMethod(object, "retrieveScarceResource"); + QVERIFY(object->property("scarceResourceCopy").isValid()); // assigned, so should be valid. + QCOMPARE(object->property("scarceResourceCopy").value(), origPixmap); + eo = qobject_cast(QQmlProperty::read(object, "a").value()); + QVERIFY(!eo->scarceResourceIsDetached()); // should be a copy of the resource at this stage. + QMetaObject::invokeMethod(object, "releaseScarceResource"); + QVERIFY(!object->property("scarceResourceCopy").isValid()); // just released, so should not be valid + eo = qobject_cast(QQmlProperty::read(object, "a").value()); + QVERIFY(eo->scarceResourceIsDetached()); // should be no other copies of it at this stage. + QVERIFY(ep->scarceResources.isEmpty()); // should have been released by this point. + delete object; + + // test that if an exception occurs while invoking js function from cpp, that the resources are released. + QQmlComponent variantComponentTwelve(&engine, testFileUrl("scarceResourceFunctionFail.variant.qml")); + object = variantComponentTwelve.create(); + QVERIFY(object != 0); + QVERIFY(!object->property("scarceResourceCopy").isValid()); // not yet assigned, so should not be valid + eo = qobject_cast(QQmlProperty::read(object, "a").value()); + QVERIFY(eo->scarceResourceIsDetached()); // should be no other copies of it at this stage. + srp_name = object->property("srp_name").toString(); + expectedWarning = variantComponentTwelve.url().toString() + QLatin1String(":16: TypeError: Property 'scarceResource' of object ") + srp_name + QLatin1String(" is not a function"); + QTest::ignoreMessage(QtWarningMsg, qPrintable(expectedWarning)); // we expect a meaningful warning to be printed. + QMetaObject::invokeMethod(object, "retrieveScarceResource"); + QVERIFY(!object->property("scarceResourceCopy").isValid()); // due to exception, assignment will NOT have occurred. + eo = qobject_cast(QQmlProperty::read(object, "a").value()); + QVERIFY(eo->scarceResourceIsDetached()); // should be no other copies of it at this stage. + QVERIFY(ep->scarceResources.isEmpty()); // should have been released by this point. + delete object; +} + +void tst_qqmlecmascript::scarceResources_data() +{ + QTest::addColumn("qmlFile"); + QTest::addColumn("readDetachStatus"); + QTest::addColumn("expectedDetachStatus"); + QTest::addColumn("propertyNames"); + QTest::addColumn("expectedValidity"); + QTest::addColumn("expectedValues"); + QTest::addColumn("expectedErrors"); + + QPixmap origPixmap(100, 100); + origPixmap.fill(Qt::blue); + + /* property var semantics */ + + // in the following three cases, the instance created from the component + // has a property which is a copy of the scarce resource; hence, the + // resource should NOT be detached prior to deletion of the object instance, + // unless the resource is destroyed explicitly. + QTest::newRow("var: import scarce resource copy directly") + << testFileUrl("scarceResourceCopy.var.qml") + << true + << false // won't be detached, because assigned to property and not explicitly released + << (QStringList() << QLatin1String("scarceResourceCopy")) + << (QList() << true) + << (QList() << origPixmap) + << QStringList(); + + QTest::newRow("var: import scarce resource copy from JS") + << testFileUrl("scarceResourceCopyFromJs.var.qml") + << true + << false // won't be detached, because assigned to property and not explicitly released + << (QStringList() << QLatin1String("scarceResourceCopy")) + << (QList() << true) + << (QList() << origPixmap) + << QStringList(); + + QTest::newRow("var: import released scarce resource copy from JS") + << testFileUrl("scarceResourceDestroyedCopy.var.qml") + << true + << true // explicitly released, so it will be detached + << (QStringList() << QLatin1String("scarceResourceCopy")) + << (QList() << false) + << (QList() << QVariant()) + << QStringList(); + + // in the following three cases, no other copy should exist in memory, + // and so it should be detached (unless explicitly preserved). + QTest::newRow("var: import auto-release SR from JS in binding side-effect") + << testFileUrl("scarceResourceTest.var.qml") + << true + << true // auto released, so it will be detached + << (QStringList() << QLatin1String("scarceResourceTest")) + << (QList() << true) + << (QList() << QVariant(100)) + << QStringList(); + QTest::newRow("var: import explicit-preserve SR from JS in binding side-effect") + << testFileUrl("scarceResourceTestPreserve.var.qml") + << true + << false // won't be detached because we explicitly preserve it + << (QStringList() << QLatin1String("scarceResourceTest")) + << (QList() << true) + << (QList() << QVariant(100)) + << QStringList(); + QTest::newRow("var: import explicit-preserve SR from JS in binding side-effect") + << testFileUrl("scarceResourceTestMultiple.var.qml") + << true + << true // will be detached because all resources were released manually or automatically. + << (QStringList() << QLatin1String("scarceResourceTest")) + << (QList() << true) + << (QList() << QVariant(100)) + << QStringList(); + + // In the following three cases, test that scarce resources are handled + // correctly for imports. + QTest::newRow("var: import with no binding") + << testFileUrl("scarceResourceCopyImportNoBinding.var.qml") + << false // cannot check detach status. + << false + << QStringList() + << QList() + << QList() + << QStringList(); + QTest::newRow("var: import with binding without explicit preserve") + << testFileUrl("scarceResourceCopyImportNoBinding.var.qml") + << false + << false + << (QStringList() << QLatin1String("scarceResourceCopy")) + << (QList() << false) // will have been released prior to evaluation of binding. + << (QList() << QVariant()) + << QStringList(); + QTest::newRow("var: import with explicit release after binding evaluation") + << testFileUrl("scarceResourceCopyImport.var.qml") + << false + << false + << (QStringList() << QLatin1String("scarceResourceImportedCopy") << QLatin1String("scarceResourceAssignedCopyOne") << QLatin1String("scarceResourceAssignedCopyTwo") << QLatin1String("arePropertiesEqual")) + << (QList() << false << false << false << true) // since property var = JS object reference, by releasing the provider's resource, all handles are invalidated. + << (QList() << QVariant() << QVariant() << QVariant() << QVariant(true)) + << QStringList(); + QTest::newRow("var: import with different js objects") + << testFileUrl("scarceResourceCopyImportDifferent.var.qml") + << false + << false + << (QStringList() << QLatin1String("scarceResourceAssignedCopyOne") << QLatin1String("scarceResourceAssignedCopyTwo") << QLatin1String("arePropertiesEqual")) + << (QList() << false << true << true) // invalidating one shouldn't invalidate the other, because they're not references to the same JS object. + << (QList() << QVariant() << QVariant(origPixmap) << QVariant(false)) + << QStringList(); + QTest::newRow("var: import with different js objects and explicit release") + << testFileUrl("scarceResourceMultipleDifferentNoBinding.var.qml") + << false + << false + << (QStringList() << QLatin1String("resourceOne") << QLatin1String("resourceTwo")) + << (QList() << true << false) // invalidating one shouldn't invalidate the other, because they're not references to the same JS object. + << (QList() << QVariant(origPixmap) << QVariant()) + << QStringList(); + QTest::newRow("var: import with same js objects and explicit release") + << testFileUrl("scarceResourceMultipleSameNoBinding.var.qml") + << false + << false + << (QStringList() << QLatin1String("resourceOne") << QLatin1String("resourceTwo")) + << (QList() << false << false) // invalidating one should invalidate the other, because they're references to the same JS object. + << (QList() << QVariant() << QVariant()) + << QStringList(); + QTest::newRow("var: binding with same js objects and explicit release") + << testFileUrl("scarceResourceMultipleSameWithBinding.var.qml") + << false + << false + << (QStringList() << QLatin1String("resourceOne") << QLatin1String("resourceTwo")) + << (QList() << false << false) // invalidating one should invalidate the other, because they're references to the same JS object. + << (QList() << QVariant() << QVariant()) + << QStringList(); + + + /* property variant semantics */ + + // in the following three cases, the instance created from the component + // has a property which is a copy of the scarce resource; hence, the + // resource should NOT be detached prior to deletion of the object instance, + // unless the resource is destroyed explicitly. + QTest::newRow("variant: import scarce resource copy directly") + << testFileUrl("scarceResourceCopy.variant.qml") + << true + << false // won't be detached, because assigned to property and not explicitly released + << (QStringList() << QLatin1String("scarceResourceCopy")) + << (QList() << true) + << (QList() << origPixmap) + << QStringList(); + + QTest::newRow("variant: import scarce resource copy from JS") + << testFileUrl("scarceResourceCopyFromJs.variant.qml") + << true + << false // won't be detached, because assigned to property and not explicitly released + << (QStringList() << QLatin1String("scarceResourceCopy")) + << (QList() << true) + << (QList() << origPixmap) + << QStringList(); + + QTest::newRow("variant: import released scarce resource copy from JS") + << testFileUrl("scarceResourceDestroyedCopy.variant.qml") + << true + << true // explicitly released, so it will be detached + << (QStringList() << QLatin1String("scarceResourceCopy")) + << (QList() << false) + << (QList() << QVariant()) + << QStringList(); + + // in the following three cases, no other copy should exist in memory, + // and so it should be detached (unless explicitly preserved). + QTest::newRow("variant: import auto-release SR from JS in binding side-effect") + << testFileUrl("scarceResourceTest.variant.qml") + << true + << true // auto released, so it will be detached + << (QStringList() << QLatin1String("scarceResourceTest")) + << (QList() << true) + << (QList() << QVariant(100)) + << QStringList(); + QTest::newRow("variant: import explicit-preserve SR from JS in binding side-effect") + << testFileUrl("scarceResourceTestPreserve.variant.qml") + << true + << false // won't be detached because we explicitly preserve it + << (QStringList() << QLatin1String("scarceResourceTest")) + << (QList() << true) + << (QList() << QVariant(100)) + << QStringList(); + QTest::newRow("variant: import multiple scarce resources") + << testFileUrl("scarceResourceTestMultiple.variant.qml") + << true + << true // will be detached because all resources were released manually or automatically. + << (QStringList() << QLatin1String("scarceResourceTest")) + << (QList() << true) + << (QList() << QVariant(100)) + << QStringList(); + + // In the following three cases, test that scarce resources are handled + // correctly for imports. + QTest::newRow("variant: import with no binding") + << testFileUrl("scarceResourceCopyImportNoBinding.variant.qml") + << false // cannot check detach status. + << false + << QStringList() + << QList() + << QList() + << QStringList(); + QTest::newRow("variant: import with binding without explicit preserve") + << testFileUrl("scarceResourceCopyImportNoBinding.variant.qml") + << false + << false + << (QStringList() << QLatin1String("scarceResourceCopy")) + << (QList() << false) // will have been released prior to evaluation of binding. + << (QList() << QVariant()) + << QStringList(); + QTest::newRow("variant: import with explicit release after binding evaluation") + << testFileUrl("scarceResourceCopyImport.variant.qml") + << false + << false + << (QStringList() << QLatin1String("scarceResourceImportedCopy") << QLatin1String("scarceResourceAssignedCopyOne") << QLatin1String("scarceResourceAssignedCopyTwo")) + << (QList() << true << true << false) // since property variant = variant copy, releasing the provider's resource does not invalidate previously assigned copies. + << (QList() << origPixmap << origPixmap << QVariant()) + << QStringList(); +} + +void tst_qqmlecmascript::scarceResources() +{ + QFETCH(QUrl, qmlFile); + QFETCH(bool, readDetachStatus); + QFETCH(bool, expectedDetachStatus); + QFETCH(QStringList, propertyNames); + QFETCH(QVariantList, expectedValidity); + QFETCH(QVariantList, expectedValues); + QFETCH(QStringList, expectedErrors); + + QQmlEnginePrivate *ep = QQmlEnginePrivate::get(&engine); + ScarceResourceObject *eo = 0; + QObject *object = 0; + + QQmlComponent c(&engine, qmlFile); + object = c.create(); + QVERIFY(object != 0); + for (int i = 0; i < propertyNames.size(); ++i) { + QString prop = propertyNames.at(i); + bool validity = expectedValidity.at(i).toBool(); + QVariant value = expectedValues.at(i); + + QCOMPARE(object->property(prop.toLatin1().constData()).isValid(), validity); + if (value.type() == QVariant::Int) { + QCOMPARE(object->property(prop.toLatin1().constData()).toInt(), value.toInt()); + } else if (value.type() == QVariant::Pixmap) { + QCOMPARE(object->property(prop.toLatin1().constData()).value(), value.value()); + } + } + + if (readDetachStatus) { + eo = qobject_cast(QQmlProperty::read(object, "a").value()); + QCOMPARE(eo->scarceResourceIsDetached(), expectedDetachStatus); + } + + QVERIFY(ep->scarceResources.isEmpty()); + delete object; +} + +void tst_qqmlecmascript::propertyChangeSlots() +{ + // ensure that allowable property names are allowed and onPropertyNameChanged slots are generated correctly. + QQmlComponent component(&engine, testFileUrl("changeslots/propertyChangeSlots.qml")); + QObject *object = component.create(); + QVERIFY(object != 0); + delete object; + + // ensure that invalid property names fail properly. + QTest::ignoreMessage(QtWarningMsg, "QQmlComponent: Component is not ready"); + QQmlComponent e1(&engine, testFileUrl("changeslots/propertyChangeSlotErrors.1.qml")); + QString expectedErrorString = e1.url().toString() + QLatin1String(":9:5: Cannot assign to non-existent property \"on_nameWithUnderscoreChanged\""); + QCOMPARE(e1.errors().at(0).toString(), expectedErrorString); + object = e1.create(); + QVERIFY(object == 0); + delete object; + + QTest::ignoreMessage(QtWarningMsg, "QQmlComponent: Component is not ready"); + QQmlComponent e2(&engine, testFileUrl("changeslots/propertyChangeSlotErrors.2.qml")); + expectedErrorString = e2.url().toString() + QLatin1String(":9:5: Cannot assign to non-existent property \"on____nameWithUnderscoresChanged\""); + QCOMPARE(e2.errors().at(0).toString(), expectedErrorString); + object = e2.create(); + QVERIFY(object == 0); + delete object; + + QTest::ignoreMessage(QtWarningMsg, "QQmlComponent: Component is not ready"); + QQmlComponent e3(&engine, testFileUrl("changeslots/propertyChangeSlotErrors.3.qml")); + expectedErrorString = e3.url().toString() + QLatin1String(":9:5: Cannot assign to non-existent property \"on$NameWithDollarsignChanged\""); + QCOMPARE(e3.errors().at(0).toString(), expectedErrorString); + object = e3.create(); + QVERIFY(object == 0); + delete object; + + QTest::ignoreMessage(QtWarningMsg, "QQmlComponent: Component is not ready"); + QQmlComponent e4(&engine, testFileUrl("changeslots/propertyChangeSlotErrors.4.qml")); + expectedErrorString = e4.url().toString() + QLatin1String(":9:5: Cannot assign to non-existent property \"on_6NameWithUnderscoreNumberChanged\""); + QCOMPARE(e4.errors().at(0).toString(), expectedErrorString); + object = e4.create(); + QVERIFY(object == 0); + delete object; +} + +void tst_qqmlecmascript::propertyVar_data() +{ + QTest::addColumn("qmlFile"); + + // valid + QTest::newRow("non-bindable object subproperty changed") << testFileUrl("propertyVar.1.qml"); + QTest::newRow("non-bindable object changed") << testFileUrl("propertyVar.2.qml"); + QTest::newRow("primitive changed") << testFileUrl("propertyVar.3.qml"); + QTest::newRow("javascript array modification") << testFileUrl("propertyVar.4.qml"); + QTest::newRow("javascript map modification") << testFileUrl("propertyVar.5.qml"); + QTest::newRow("javascript array assignment") << testFileUrl("propertyVar.6.qml"); + QTest::newRow("javascript map assignment") << testFileUrl("propertyVar.7.qml"); + QTest::newRow("literal property assignment") << testFileUrl("propertyVar.8.qml"); + QTest::newRow("qobject property assignment") << testFileUrl("propertyVar.9.qml"); + QTest::newRow("base class var property assignment") << testFileUrl("propertyVar.10.qml"); +} + +void tst_qqmlecmascript::propertyVar() +{ + QFETCH(QUrl, qmlFile); + + QQmlComponent component(&engine, qmlFile); + QObject *object = component.create(); + QVERIFY(object != 0); + + QCOMPARE(object->property("test").toBool(), true); + + delete object; +} + +// Tests that we can write QVariant values to var properties from C++ +void tst_qqmlecmascript::propertyVarCpp() +{ + QObject *object = 0; + + // ensure that writing to and reading from a var property from cpp works as required. + // Literal values stored in var properties can be read and written as QVariants + // of a specific type, whereas object values are read as QVariantMaps. + QQmlComponent component(&engine, testFileUrl("propertyVarCpp.qml")); + object = component.create(); + QVERIFY(object != 0); + // assign int to property var that currently has int assigned + QVERIFY(object->setProperty("varProperty", QVariant::fromValue(10))); + QCOMPARE(object->property("varBound"), QVariant(15)); + QCOMPARE(object->property("intBound"), QVariant(15)); + QCOMPARE(object->property("varProperty").userType(), (int)QVariant::Int); + QCOMPARE(object->property("varBound").userType(), (int)QVariant::Int); + // assign string to property var that current has bool assigned + QCOMPARE(object->property("varProperty2").userType(), (int)QVariant::Bool); + QVERIFY(object->setProperty("varProperty2", QVariant(QLatin1String("randomString")))); + QCOMPARE(object->property("varProperty2"), QVariant(QLatin1String("randomString"))); + QCOMPARE(object->property("varProperty2").userType(), (int)QVariant::String); + // now enforce behaviour when accessing JavaScript objects from cpp. + QCOMPARE(object->property("jsobject").userType(), (int)QVariant::Map); + delete object; +} + +static void gc(QQmlEngine &engine) +{ + engine.collectGarbage(); + QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete); + QCoreApplication::processEvents(); +} + +void tst_qqmlecmascript::propertyVarOwnership() +{ + // Referenced JS objects are not collected + { + QQmlComponent component(&engine, testFileUrl("propertyVarOwnership.qml")); + QObject *object = component.create(); + QVERIFY(object != 0); + QCOMPARE(object->property("test").toBool(), false); + QMetaObject::invokeMethod(object, "runTest"); + QCOMPARE(object->property("test").toBool(), true); + delete object; + } + // Referenced JS objects are not collected + { + QQmlComponent component(&engine, testFileUrl("propertyVarOwnership.2.qml")); + QObject *object = component.create(); + QVERIFY(object != 0); + QCOMPARE(object->property("test").toBool(), false); + QMetaObject::invokeMethod(object, "runTest"); + QCOMPARE(object->property("test").toBool(), true); + delete object; + } + // Qt objects are not collected until they've been dereferenced + { + QQmlComponent component(&engine, testFileUrl("propertyVarOwnership.3.qml")); + QObject *object = component.create(); + QVERIFY(object != 0); + + QCOMPARE(object->property("test2").toBool(), false); + QCOMPARE(object->property("test2").toBool(), false); + + QMetaObject::invokeMethod(object, "runTest"); + QCOMPARE(object->property("test1").toBool(), true); + + QPointer referencedObject = object->property("object").value(); + QVERIFY(!referencedObject.isNull()); + gc(engine); + QVERIFY(!referencedObject.isNull()); + + QMetaObject::invokeMethod(object, "runTest2"); + QCOMPARE(object->property("test2").toBool(), true); + gc(engine); + QVERIFY(referencedObject.isNull()); + + delete object; + } + // Self reference does not prevent Qt object collection + { + QQmlComponent component(&engine, testFileUrl("propertyVarOwnership.4.qml")); + QObject *object = component.create(); + QVERIFY(object != 0); + + QCOMPARE(object->property("test").toBool(), true); + + QPointer referencedObject = object->property("object").value(); + QVERIFY(!referencedObject.isNull()); + gc(engine); + QVERIFY(!referencedObject.isNull()); + + QMetaObject::invokeMethod(object, "runTest"); + gc(engine); + QVERIFY(referencedObject.isNull()); + + delete object; + } +} + +void tst_qqmlecmascript::propertyVarImplicitOwnership() +{ + // The childObject has a reference to a different QObject. We want to ensure + // that the different item will not be cleaned up until required. IE, the childObject + // has implicit ownership of the constructed QObject. + QQmlComponent component(&engine, testFileUrl("propertyVarImplicitOwnership.qml")); + QObject *object = component.create(); + QVERIFY(object != 0); + QMetaObject::invokeMethod(object, "assignCircular"); + QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete); // process deleteLater() events from QV8QObjectWrapper. + QCoreApplication::processEvents(); + QObject *rootObject = object->property("vp").value(); + QVERIFY(rootObject != 0); + QObject *childObject = rootObject->findChild("text"); + QVERIFY(childObject != 0); + QCOMPARE(rootObject->property("rectCanary").toInt(), 5); + QCOMPARE(childObject->property("textCanary").toInt(), 10); + QMetaObject::invokeMethod(childObject, "constructQObject"); // creates a reference to a constructed QObject. + QWeakPointer qobjectGuard(childObject->property("vp").value()); // get the pointer prior to processing deleteLater events. + QVERIFY(!qobjectGuard.isNull()); + QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete); // process deleteLater() events from QV8QObjectWrapper. + QCoreApplication::processEvents(); + QVERIFY(!qobjectGuard.isNull()); + QMetaObject::invokeMethod(object, "deassignCircular"); + QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete); // process deleteLater() events from QV8QObjectWrapper. + QCoreApplication::processEvents(); + QVERIFY(qobjectGuard.isNull()); // should have been collected now. + delete object; +} + +void tst_qqmlecmascript::propertyVarReparent() +{ + // ensure that nothing breaks if we re-parent objects + QQmlComponent component(&engine, testFileUrl("propertyVar.reparent.qml")); + QObject *object = component.create(); + QVERIFY(object != 0); + QMetaObject::invokeMethod(object, "assignVarProp"); + QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete); // process deleteLater() events from QV8QObjectWrapper. + QCoreApplication::processEvents(); + QObject *rect = object->property("vp").value(); + QObject *text = rect->findChild("textOne"); + QObject *text2 = rect->findChild("textTwo"); + QWeakPointer rectGuard(rect); + QWeakPointer textGuard(text); + QWeakPointer text2Guard(text2); + QVERIFY(!rectGuard.isNull()); + QVERIFY(!textGuard.isNull()); + QVERIFY(!text2Guard.isNull()); + QCOMPARE(text->property("textCanary").toInt(), 11); + QCOMPARE(text2->property("textCanary").toInt(), 12); + // now construct an image which we will reparent. + QMetaObject::invokeMethod(text2, "constructQObject"); + QObject *image = text2->property("vp").value(); + QWeakPointer imageGuard(image); + QVERIFY(!imageGuard.isNull()); + QCOMPARE(image->property("imageCanary").toInt(), 13); + // now reparent the "Image" object (currently, it has JS ownership) + image->setParent(text); // shouldn't be collected after deassignVp now, since has a parent. + QMetaObject::invokeMethod(text2, "deassignVp"); + QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete); // process deleteLater() events from QV8QObjectWrapper. + QCoreApplication::processEvents(); + QCOMPARE(text->property("textCanary").toInt(), 11); + QCOMPARE(text2->property("textCanary").toInt(), 22); + QVERIFY(!imageGuard.isNull()); // should still be alive. + QCOMPARE(image->property("imageCanary").toInt(), 13); // still able to access var properties + QMetaObject::invokeMethod(object, "deassignVarProp"); // now deassign the root-object's vp, causing gc of rect+text+text2 + QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete); // process deleteLater() events from QV8QObjectWrapper. + QCoreApplication::processEvents(); + QVERIFY(imageGuard.isNull()); // should now have been deleted, due to parent being deleted. + delete object; +} + +void tst_qqmlecmascript::propertyVarReparentNullContext() +{ + // sometimes reparenting can cause problems + // (eg, if the ctxt is collected, varproperties are no longer available) + // this test ensures that no crash occurs in that situation. + QQmlComponent component(&engine, testFileUrl("propertyVar.reparent.qml")); + QObject *object = component.create(); + QVERIFY(object != 0); + QMetaObject::invokeMethod(object, "assignVarProp"); + QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete); // process deleteLater() events from QV8QObjectWrapper. + QCoreApplication::processEvents(); + QObject *rect = object->property("vp").value(); + QObject *text = rect->findChild("textOne"); + QObject *text2 = rect->findChild("textTwo"); + QWeakPointer rectGuard(rect); + QWeakPointer textGuard(text); + QWeakPointer text2Guard(text2); + QVERIFY(!rectGuard.isNull()); + QVERIFY(!textGuard.isNull()); + QVERIFY(!text2Guard.isNull()); + QCOMPARE(text->property("textCanary").toInt(), 11); + QCOMPARE(text2->property("textCanary").toInt(), 12); + // now construct an image which we will reparent. + QMetaObject::invokeMethod(text2, "constructQObject"); + QObject *image = text2->property("vp").value(); + QWeakPointer imageGuard(image); + QVERIFY(!imageGuard.isNull()); + QCOMPARE(image->property("imageCanary").toInt(), 13); + // now reparent the "Image" object (currently, it has JS ownership) + image->setParent(object); // reparented to base object. after deassignVarProp, the ctxt will be invalid. + QMetaObject::invokeMethod(object, "deassignVarProp"); // now deassign the root-object's vp, causing gc of rect+text+text2 + QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete); // process deleteLater() events from QV8QObjectWrapper. + QCoreApplication::processEvents(); + QVERIFY(!imageGuard.isNull()); // should still be alive. + QVERIFY(!image->property("imageCanary").isValid()); // but varProperties won't be available (null context). + delete object; + QVERIFY(imageGuard.isNull()); // should now be dead. +} + +void tst_qqmlecmascript::propertyVarCircular() +{ + // enforce behaviour regarding circular references - ensure qdvmemo deletion. + QQmlComponent component(&engine, testFileUrl("propertyVar.circular.qml")); + QObject *object = component.create(); + QVERIFY(object != 0); + QMetaObject::invokeMethod(object, "assignCircular"); // cause assignment and gc + QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete); // process deleteLater() events from QV8QObjectWrapper. + QCoreApplication::processEvents(); + QCOMPARE(object->property("canaryInt"), QVariant(5)); + QVariant canaryResourceVariant = object->property("canaryResource"); + QVERIFY(canaryResourceVariant.isValid()); + QPixmap canaryResourcePixmap = canaryResourceVariant.value(); + canaryResourceVariant = QVariant(); // invalidate it to remove one copy of the pixmap from memory. + QMetaObject::invokeMethod(object, "deassignCanaryResource"); // remove one copy of the pixmap from memory + QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete); // process deleteLater() events from QV8QObjectWrapper. + QCoreApplication::processEvents(); + QVERIFY(!canaryResourcePixmap.isDetached()); // two copies extant - this and the propertyVar.vp.vp.vp.vp.memoryHog. + QMetaObject::invokeMethod(object, "deassignCircular"); // cause deassignment and gc + QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete); // process deleteLater() events from QV8QObjectWrapper. + QCoreApplication::processEvents(); + QCOMPARE(object->property("canaryInt"), QVariant(2)); + QCOMPARE(object->property("canaryResource"), QVariant(1)); + QVERIFY(canaryResourcePixmap.isDetached()); // now detached, since orig copy was member of qdvmemo which was deleted. + delete object; +} + +void tst_qqmlecmascript::propertyVarCircular2() +{ + // track deletion of JS-owned parent item with Cpp-owned child + // where the child has a var property referencing its parent. + QQmlComponent component(&engine, testFileUrl("propertyVar.circular.2.qml")); + QObject *object = component.create(); + QVERIFY(object != 0); + QMetaObject::invokeMethod(object, "assignCircular"); + QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete); // process deleteLater() events from QV8QObjectWrapper. + QCoreApplication::processEvents(); + QObject *rootObject = object->property("vp").value(); + QVERIFY(rootObject != 0); + QObject *childObject = rootObject->findChild("text"); + QVERIFY(childObject != 0); + QWeakPointer rootObjectTracker(rootObject); + QVERIFY(!rootObjectTracker.isNull()); + QWeakPointer childObjectTracker(childObject); + QVERIFY(!childObjectTracker.isNull()); + gc(engine); + QCOMPARE(rootObject->property("rectCanary").toInt(), 5); + QCOMPARE(childObject->property("textCanary").toInt(), 10); + QMetaObject::invokeMethod(object, "deassignCircular"); + QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete); // process deleteLater() events from QV8QObjectWrapper. + QCoreApplication::processEvents(); + QVERIFY(rootObjectTracker.isNull()); // should have been collected + QVERIFY(childObjectTracker.isNull()); // should have been collected + delete object; +} + +void tst_qqmlecmascript::propertyVarWeakRefCallback(v8::Persistent object, void* parameter) +{ + *(int*)(parameter) += 1; + qPersistentDispose(object); +} + +void tst_qqmlecmascript::propertyVarInheritance() +{ + int propertyVarWeakRefCallbackCount = 0; + + // enforce behaviour regarding element inheritance - ensure handle disposal. + // The particular component under test here has a chain of references. + QQmlComponent component(&engine, testFileUrl("propertyVar.inherit.qml")); + QObject *object = component.create(); + QVERIFY(object != 0); + QMetaObject::invokeMethod(object, "assignCircular"); // cause assignment and gc + QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete); // process deleteLater() events from QV8QObjectWrapper. + QCoreApplication::processEvents(); + // we want to be able to track when the varProperties array of the last metaobject is disposed + QObject *cco5 = object->property("varProperty").value()->property("vp").value()->property("vp").value()->property("vp").value()->property("vp").value(); + QObject *ico5 = object->property("varProperty").value()->property("inheritanceVarProperty").value()->property("vp").value()->property("vp").value()->property("vp").value()->property("vp").value(); + QQmlVMEMetaObject *icovmemo = ((QQmlVMEMetaObject *)(ico5->metaObject())); + QQmlVMEMetaObject *ccovmemo = ((QQmlVMEMetaObject *)(cco5->metaObject())); + v8::Persistent icoCanaryHandle; + v8::Persistent ccoCanaryHandle; + { + v8::HandleScope hs; + // XXX NOTE: this is very implementation dependent. QDVMEMO->vmeProperty() is the only + // public function which can return us a handle to something in the varProperties array. + icoCanaryHandle = qPersistentNew(icovmemo->vmeProperty(ico5->metaObject()->indexOfProperty("circ"))); + ccoCanaryHandle = qPersistentNew(ccovmemo->vmeProperty(cco5->metaObject()->indexOfProperty("circ"))); + // we make them weak and invoke the gc, but we should not hit the weak-callback yet + // as the varproperties array of each vmemo still references the resource. + icoCanaryHandle.MakeWeak(&propertyVarWeakRefCallbackCount, propertyVarWeakRefCallback); + ccoCanaryHandle.MakeWeak(&propertyVarWeakRefCallbackCount, propertyVarWeakRefCallback); + gc(engine); + QVERIFY(propertyVarWeakRefCallbackCount == 0); + } + // now we deassign the var prop, which should trigger collection of item subtrees. + QMetaObject::invokeMethod(object, "deassignCircular"); // cause deassignment and gc + QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete); // process deleteLater() events from QV8QObjectWrapper. + QCoreApplication::processEvents(); + // ensure that there are only weak handles to the underlying varProperties array remaining. + gc(engine); + QCOMPARE(propertyVarWeakRefCallbackCount, 2); // should have been called for both, since all refs should be weak. + delete object; + // since there are no parent vmemo's to keep implicit references alive, and the only handles + // to what remains are weak, all varProperties arrays must have been collected. +} + +void tst_qqmlecmascript::propertyVarInheritance2() +{ + int propertyVarWeakRefCallbackCount = 0; + + // The particular component under test here does NOT have a chain of references; the + // only link between rootObject and childObject is that rootObject is the parent of childObject. + QQmlComponent component(&engine, testFileUrl("propertyVar.circular.2.qml")); + QObject *object = component.create(); + QVERIFY(object != 0); + QMetaObject::invokeMethod(object, "assignCircular"); + QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete); // process deleteLater() events from QV8QObjectWrapper. + QCoreApplication::processEvents(); + QObject *rootObject = object->property("vp").value(); + QVERIFY(rootObject != 0); + QObject *childObject = rootObject->findChild("text"); + QVERIFY(childObject != 0); + QCOMPARE(rootObject->property("rectCanary").toInt(), 5); + QCOMPARE(childObject->property("textCanary").toInt(), 10); + v8::Persistent childObjectVarArrayValueHandle; + { + v8::HandleScope hs; + propertyVarWeakRefCallbackCount = 0; // reset callback count. + childObjectVarArrayValueHandle = qPersistentNew(((QQmlVMEMetaObject *)(childObject->metaObject()))->vmeProperty(childObject->metaObject()->indexOfProperty("vp"))); + childObjectVarArrayValueHandle.MakeWeak(&propertyVarWeakRefCallbackCount, propertyVarWeakRefCallback); + gc(engine); + QVERIFY(propertyVarWeakRefCallbackCount == 0); // should not have been collected yet. + QCOMPARE(childObject->property("vp").value(), rootObject); + QCOMPARE(childObject->property("textCanary").toInt(), 10); + } + QMetaObject::invokeMethod(object, "deassignCircular"); + QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete); // process deleteLater() events from QV8QObjectWrapper. + QCoreApplication::processEvents(); + QVERIFY(propertyVarWeakRefCallbackCount == 1); // should have been collected now. + delete object; +} + +// Ensure that QObject type conversion works on binding assignment +void tst_qqmlecmascript::elementAssign() +{ + QQmlComponent component(&engine, testFileUrl("elementAssign.qml")); + + QObject *object = component.create(); + QVERIFY(object != 0); + + QCOMPARE(object->property("test").toBool(), true); + + delete object; +} + +// QTBUG-12457 +void tst_qqmlecmascript::objectPassThroughSignals() +{ + QQmlComponent component(&engine, testFileUrl("objectsPassThroughSignals.qml")); + + QObject *object = component.create(); + QVERIFY(object != 0); + + QCOMPARE(object->property("test").toBool(), true); + + delete object; +} + +// QTBUG-21626 +void tst_qqmlecmascript::objectConversion() +{ + QQmlComponent component(&engine, testFileUrl("objectConversion.qml")); + + QObject *object = component.create(); + QVERIFY(object != 0); + QVariant retn; + QMetaObject::invokeMethod(object, "circularObject", Q_RETURN_ARG(QVariant, retn)); + QCOMPARE(retn.value().value("test"), QVariant(100)); + + delete object; +} + + +// QTBUG-20242 +void tst_qqmlecmascript::booleanConversion() +{ + QQmlComponent component(&engine, testFileUrl("booleanConversion.qml")); + + QObject *object = component.create(); + QVERIFY(object != 0); + + QCOMPARE(object->property("test_true1").toBool(), true); + QCOMPARE(object->property("test_true2").toBool(), true); + QCOMPARE(object->property("test_true3").toBool(), true); + QCOMPARE(object->property("test_true4").toBool(), true); + QCOMPARE(object->property("test_true5").toBool(), true); + + QCOMPARE(object->property("test_false1").toBool(), false); + QCOMPARE(object->property("test_false2").toBool(), false); + QCOMPARE(object->property("test_false3").toBool(), false); + + delete object; +} + +void tst_qqmlecmascript::handleReferenceManagement() +{ + + int dtorCount = 0; + { + // Linear QObject reference + QQmlEngine hrmEngine; + QQmlComponent component(&hrmEngine, testFileUrl("handleReferenceManagement.object.1.qml")); + QObject *object = component.create(); + QVERIFY(object != 0); + CircularReferenceObject *cro = object->findChild("cro"); + cro->setEngine(&hrmEngine); + cro->setDtorCount(&dtorCount); + QMetaObject::invokeMethod(object, "createReference"); + gc(engine); + QCOMPARE(dtorCount, 0); // second has JS ownership, kept alive by first's reference + delete object; + hrmEngine.collectGarbage(); + QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete); + QCoreApplication::processEvents(); + QCOMPARE(dtorCount, 3); + } + + dtorCount = 0; + { + // Circular QObject reference + QQmlEngine hrmEngine; + QQmlComponent component(&hrmEngine, testFileUrl("handleReferenceManagement.object.2.qml")); + QObject *object = component.create(); + QVERIFY(object != 0); + CircularReferenceObject *cro = object->findChild("cro"); + cro->setEngine(&hrmEngine); + cro->setDtorCount(&dtorCount); + QMetaObject::invokeMethod(object, "circularReference"); + gc(engine); + QCOMPARE(dtorCount, 2); // both should be cleaned up, since circular references shouldn't keep alive. + delete object; + hrmEngine.collectGarbage(); + QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete); + QCoreApplication::processEvents(); + QCOMPARE(dtorCount, 3); + } + + dtorCount = 0; + { + // Linear handle reference + QQmlEngine hrmEngine; + QQmlComponent component(&hrmEngine, testFileUrl("handleReferenceManagement.handle.1.qml")); + QObject *object = component.create(); + QVERIFY(object != 0); + CircularReferenceHandle *crh = object->findChild("crh"); + QVERIFY(crh != 0); + crh->setEngine(&hrmEngine); + crh->setDtorCount(&dtorCount); + QMetaObject::invokeMethod(object, "createReference"); + CircularReferenceHandle *first = object->property("first").value(); + CircularReferenceHandle *second = object->property("second").value(); + QVERIFY(first != 0); + QVERIFY(second != 0); + first->addReference(QQmlData::get(second)->v8object); // create reference + // now we have to reparent second and make second owned by JS. + second->setParent(0); + QQmlEngine::setObjectOwnership(second, QQmlEngine::JavaScriptOwnership); + gc(engine); + QCOMPARE(dtorCount, 0); // due to reference from first to second, second shouldn't be collected. + delete object; + hrmEngine.collectGarbage(); + QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete); + QCoreApplication::processEvents(); + QCOMPARE(dtorCount, 3); + } + + dtorCount = 0; + { + // Circular handle reference + QQmlEngine hrmEngine; + QQmlComponent component(&hrmEngine, testFileUrl("handleReferenceManagement.handle.2.qml")); + QObject *object = component.create(); + QVERIFY(object != 0); + CircularReferenceHandle *crh = object->findChild("crh"); + QVERIFY(crh != 0); + crh->setEngine(&hrmEngine); + crh->setDtorCount(&dtorCount); + QMetaObject::invokeMethod(object, "circularReference"); + CircularReferenceHandle *first = object->property("first").value(); + CircularReferenceHandle *second = object->property("second").value(); + QVERIFY(first != 0); + QVERIFY(second != 0); + first->addReference(QQmlData::get(second)->v8object); // create circular reference + second->addReference(QQmlData::get(first)->v8object); // note: must be weak. + // now we have to reparent and change ownership. + first->setParent(0); + second->setParent(0); + QQmlEngine::setObjectOwnership(first, QQmlEngine::JavaScriptOwnership); + QQmlEngine::setObjectOwnership(second, QQmlEngine::JavaScriptOwnership); + gc(engine); + QCOMPARE(dtorCount, 2); // despite circular references, both will be collected. + delete object; + hrmEngine.collectGarbage(); + QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete); + QCoreApplication::processEvents(); + QCOMPARE(dtorCount, 3); + } + + dtorCount = 0; + { + // multiple engine interaction - linear reference + QQmlEngine hrmEngine1; + QQmlEngine hrmEngine2; + QQmlComponent component1(&hrmEngine1, testFileUrl("handleReferenceManagement.handle.1.qml")); + QQmlComponent component2(&hrmEngine2, testFileUrl("handleReferenceManagement.handle.1.qml")); + QObject *object1 = component1.create(); + QObject *object2 = component2.create(); + QVERIFY(object1 != 0); + QVERIFY(object2 != 0); + CircularReferenceHandle *crh1 = object1->findChild("crh"); + CircularReferenceHandle *crh2 = object2->findChild("crh"); + QVERIFY(crh1 != 0); + QVERIFY(crh2 != 0); + crh1->setEngine(&hrmEngine1); + crh2->setEngine(&hrmEngine2); + crh1->setDtorCount(&dtorCount); + crh2->setDtorCount(&dtorCount); + QMetaObject::invokeMethod(object1, "createReference"); + QMetaObject::invokeMethod(object2, "createReference"); + CircularReferenceHandle *first1 = object1->property("first").value(); + CircularReferenceHandle *second1 = object1->property("second").value(); + CircularReferenceHandle *first2 = object2->property("first").value(); + CircularReferenceHandle *second2 = object2->property("second").value(); + QVERIFY(first1 != 0); + QVERIFY(second1 != 0); + QVERIFY(first2 != 0); + QVERIFY(second2 != 0); + first1->addReference(QQmlData::get(second2)->v8object); // create reference across engines + // now we have to reparent second2 and make second2 owned by JS. + second2->setParent(0); + QQmlEngine::setObjectOwnership(second2, QQmlEngine::JavaScriptOwnership); + gc(engine); + QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete); + QCoreApplication::processEvents(); + QCOMPARE(dtorCount, 0); // due to reference from first1 to second2, second2 shouldn't be collected. + delete object1; + delete object2; + hrmEngine1.collectGarbage(); + hrmEngine2.collectGarbage(); + QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete); + QCoreApplication::processEvents(); + QCOMPARE(dtorCount, 6); + } + + dtorCount = 0; + { + // multiple engine interaction - circular reference + QQmlEngine hrmEngine1; + QQmlEngine hrmEngine2; + QQmlComponent component1(&hrmEngine1, testFileUrl("handleReferenceManagement.handle.1.qml")); + QQmlComponent component2(&hrmEngine2, testFileUrl("handleReferenceManagement.handle.1.qml")); + QObject *object1 = component1.create(); + QObject *object2 = component2.create(); + QVERIFY(object1 != 0); + QVERIFY(object2 != 0); + CircularReferenceHandle *crh1 = object1->findChild("crh"); + CircularReferenceHandle *crh2 = object2->findChild("crh"); + QVERIFY(crh1 != 0); + QVERIFY(crh2 != 0); + crh1->setEngine(&hrmEngine1); + crh2->setEngine(&hrmEngine2); + crh1->setDtorCount(&dtorCount); + crh2->setDtorCount(&dtorCount); + QMetaObject::invokeMethod(object1, "createReference"); + QMetaObject::invokeMethod(object2, "createReference"); + CircularReferenceHandle *first1 = object1->property("first").value(); + CircularReferenceHandle *second1 = object1->property("second").value(); + CircularReferenceHandle *first2 = object2->property("first").value(); + CircularReferenceHandle *second2 = object2->property("second").value(); + QVERIFY(first1 != 0); + QVERIFY(second1 != 0); + QVERIFY(first2 != 0); + QVERIFY(second2 != 0); + first1->addReference(QQmlData::get(second1)->v8object); // create linear reference within engine1 + second1->addReference(QQmlData::get(second2)->v8object); // create linear reference across engines + second2->addReference(QQmlData::get(first2)->v8object); // create linear reference within engine2 + first2->addReference(QQmlData::get(first1)->v8object); // close the loop - circular ref across engines + // now we have to reparent and change ownership to JS. + first1->setParent(0); + second1->setParent(0); + first2->setParent(0); + second2->setParent(0); + QQmlEngine::setObjectOwnership(first1, QQmlEngine::JavaScriptOwnership); + QQmlEngine::setObjectOwnership(second1, QQmlEngine::JavaScriptOwnership); + QQmlEngine::setObjectOwnership(first2, QQmlEngine::JavaScriptOwnership); + QQmlEngine::setObjectOwnership(second2, QQmlEngine::JavaScriptOwnership); + gc(engine); + QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete); + QCoreApplication::processEvents(); + QCOMPARE(dtorCount, 4); // circular references shouldn't keep them alive. + delete object1; + delete object2; + hrmEngine1.collectGarbage(); + hrmEngine2.collectGarbage(); + QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete); + QCoreApplication::processEvents(); + QCOMPARE(dtorCount, 6); + } + + dtorCount = 0; + { + // multiple engine interaction - linear reference with engine deletion + QQmlEngine *hrmEngine1 = new QQmlEngine; + QQmlEngine *hrmEngine2 = new QQmlEngine; + QQmlComponent component1(hrmEngine1, testFileUrl("handleReferenceManagement.handle.1.qml")); + QQmlComponent component2(hrmEngine2, testFileUrl("handleReferenceManagement.handle.1.qml")); + QObject *object1 = component1.create(); + QObject *object2 = component2.create(); + QVERIFY(object1 != 0); + QVERIFY(object2 != 0); + CircularReferenceHandle *crh1 = object1->findChild("crh"); + CircularReferenceHandle *crh2 = object2->findChild("crh"); + QVERIFY(crh1 != 0); + QVERIFY(crh2 != 0); + crh1->setEngine(hrmEngine1); + crh2->setEngine(hrmEngine2); + crh1->setDtorCount(&dtorCount); + crh2->setDtorCount(&dtorCount); + QMetaObject::invokeMethod(object1, "createReference"); + QMetaObject::invokeMethod(object2, "createReference"); + CircularReferenceHandle *first1 = object1->property("first").value(); + CircularReferenceHandle *second1 = object1->property("second").value(); + CircularReferenceHandle *first2 = object2->property("first").value(); + CircularReferenceHandle *second2 = object2->property("second").value(); + QVERIFY(first1 != 0); + QVERIFY(second1 != 0); + QVERIFY(first2 != 0); + QVERIFY(second2 != 0); + first1->addReference(QQmlData::get(second1)->v8object); // create linear reference within engine1 + second1->addReference(QQmlData::get(second2)->v8object); // create linear reference across engines + second2->addReference(QQmlData::get(first2)->v8object); // create linear reference within engine2 + // now we have to reparent and change ownership to JS. + first1->setParent(crh1); + second1->setParent(0); + first2->setParent(0); + second2->setParent(0); + QQmlEngine::setObjectOwnership(second1, QQmlEngine::JavaScriptOwnership); + QQmlEngine::setObjectOwnership(first2, QQmlEngine::JavaScriptOwnership); + QQmlEngine::setObjectOwnership(second2, QQmlEngine::JavaScriptOwnership); + gc(engine); + QCOMPARE(dtorCount, 0); + delete hrmEngine2; + gc(engine); + QCOMPARE(dtorCount, 0); + delete object1; + delete object2; + hrmEngine1->collectGarbage(); + QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete); + QCoreApplication::processEvents(); + QCOMPARE(dtorCount, 6); + delete hrmEngine1; + } +} + +void tst_qqmlecmascript::stringArg() +{ + QQmlComponent component(&engine, testFileUrl("stringArg.qml")); + QObject *object = component.create(); + QVERIFY(object != 0); + QMetaObject::invokeMethod(object, "success"); + QVERIFY(object->property("returnValue").toBool()); + + QString w1 = testFileUrl("stringArg.qml").toString() + QLatin1String(":45: Error: String.arg(): Invalid arguments"); + QTest::ignoreMessage(QtWarningMsg, w1.toAscii().constData()); + QMetaObject::invokeMethod(object, "failure"); + QVERIFY(object->property("returnValue").toBool()); + + delete object; +} + +void tst_qqmlecmascript::readonlyDeclaration() +{ + QQmlComponent component(&engine, testFileUrl("readonlyDeclaration.qml")); + + QObject *object = component.create(); + QVERIFY(object != 0); + + QCOMPARE(object->property("test").toBool(), true); + + delete object; +} + +Q_DECLARE_METATYPE(QList) +Q_DECLARE_METATYPE(QList) +Q_DECLARE_METATYPE(QList) +Q_DECLARE_METATYPE(QList) +Q_DECLARE_METATYPE(QList) +void tst_qqmlecmascript::sequenceConversionRead() +{ + { + QUrl qmlFile = testFileUrl("sequenceConversion.read.qml"); + QQmlComponent component(&engine, qmlFile); + QObject *object = component.create(); + QVERIFY(object != 0); + MySequenceConversionObject *seq = object->findChild("msco"); + QVERIFY(seq != 0); + + QMetaObject::invokeMethod(object, "readSequences"); + QList intList; intList << 1 << 2 << 3 << 4; + QCOMPARE(object->property("intListLength").toInt(), intList.length()); + QCOMPARE(object->property("intList").value >(), intList); + QList qrealList; qrealList << 1.1 << 2.2 << 3.3 << 4.4; + QCOMPARE(object->property("qrealListLength").toInt(), qrealList.length()); + QCOMPARE(object->property("qrealList").value >(), qrealList); + QList boolList; boolList << true << false << true << false; + QCOMPARE(object->property("boolListLength").toInt(), boolList.length()); + QCOMPARE(object->property("boolList").value >(), boolList); + QList stringList; stringList << QLatin1String("first") << QLatin1String("second") << QLatin1String("third") << QLatin1String("fourth"); + QCOMPARE(object->property("stringListLength").toInt(), stringList.length()); + QCOMPARE(object->property("stringList").value >(), stringList); + QList urlList; urlList << QUrl("http://www.example1.com") << QUrl("http://www.example2.com") << QUrl("http://www.example3.com"); + QCOMPARE(object->property("urlListLength").toInt(), urlList.length()); + QCOMPARE(object->property("urlList").value >(), urlList); + QStringList qstringList; qstringList << QLatin1String("first") << QLatin1String("second") << QLatin1String("third") << QLatin1String("fourth"); + QCOMPARE(object->property("qstringListLength").toInt(), qstringList.length()); + QCOMPARE(object->property("qstringList").value(), qstringList); + + QMetaObject::invokeMethod(object, "readSequenceElements"); + QCOMPARE(object->property("intVal").toInt(), 2); + QCOMPARE(object->property("qrealVal").toReal(), 2.2); + QCOMPARE(object->property("boolVal").toBool(), false); + QCOMPARE(object->property("stringVal").toString(), QString(QLatin1String("second"))); + QCOMPARE(object->property("urlVal").toUrl(), QUrl("http://www.example2.com")); + QCOMPARE(object->property("qstringVal").toString(), QString(QLatin1String("second"))); + + QMetaObject::invokeMethod(object, "enumerateSequenceElements"); + QCOMPARE(object->property("enumerationMatches").toBool(), true); + + intList.clear(); intList << 1 << 2 << 3 << 4 << 5; // set by the enumerateSequenceElements test. + QQmlProperty seqProp(seq, "intListProperty"); + QCOMPARE(seqProp.read().value >(), intList); + QQmlProperty seqProp2(seq, "intListProperty", &engine); + QCOMPARE(seqProp2.read().value >(), intList); + + QMetaObject::invokeMethod(object, "testReferenceDeletion"); + QCOMPARE(object->property("referenceDeletion").toBool(), true); + + delete object; + } + + { + QUrl qmlFile = testFileUrl("sequenceConversion.read.error.qml"); + QQmlComponent component(&engine, qmlFile); + QObject *object = component.create(); + QVERIFY(object != 0); + MySequenceConversionObject *seq = object->findChild("msco"); + QVERIFY(seq != 0); + + // we haven't registered QList as a sequence type. + QString warningOne = QLatin1String("QMetaProperty::read: Unable to handle unregistered datatype 'QList' for property 'MySequenceConversionObject::pointListProperty'"); + QString warningTwo = qmlFile.toString() + QLatin1String(":18: TypeError: Cannot read property 'length' of undefined"); + QTest::ignoreMessage(QtWarningMsg, warningOne.toAscii().constData()); + QTest::ignoreMessage(QtWarningMsg, warningTwo.toAscii().constData()); + + QMetaObject::invokeMethod(object, "performTest"); + + // QList has not been registered as a sequence type. + QCOMPARE(object->property("pointListLength").toInt(), 0); + QVERIFY(!object->property("pointList").isValid()); + QTest::ignoreMessage(QtWarningMsg, "QMetaProperty::read: Unable to handle unregistered datatype 'QList' for property 'MySequenceConversionObject::pointListProperty'"); + QQmlProperty seqProp(seq, "pointListProperty", &engine); + QVERIFY(!seqProp.read().isValid()); // not a valid/known sequence type + + delete object; + } +} + +void tst_qqmlecmascript::sequenceConversionWrite() +{ + { + QUrl qmlFile = testFileUrl("sequenceConversion.write.qml"); + QQmlComponent component(&engine, qmlFile); + QObject *object = component.create(); + QVERIFY(object != 0); + MySequenceConversionObject *seq = object->findChild("msco"); + QVERIFY(seq != 0); + + QMetaObject::invokeMethod(object, "writeSequences"); + QCOMPARE(object->property("success").toBool(), true); + + QMetaObject::invokeMethod(object, "writeSequenceElements"); + QCOMPARE(object->property("success").toBool(), true); + + QMetaObject::invokeMethod(object, "writeOtherElements"); + QCOMPARE(object->property("success").toBool(), true); + + QMetaObject::invokeMethod(object, "testReferenceDeletion"); + QCOMPARE(object->property("referenceDeletion").toBool(), true); + + delete object; + } + + { + QUrl qmlFile = testFileUrl("sequenceConversion.write.error.qml"); + QQmlComponent component(&engine, qmlFile); + QObject *object = component.create(); + QVERIFY(object != 0); + MySequenceConversionObject *seq = object->findChild("msco"); + QVERIFY(seq != 0); + + // we haven't registered QList as a sequence type, so writing shouldn't work. + QString warningOne = qmlFile.toString() + QLatin1String(":16: Error: Cannot assign QVariantList to void"); + QTest::ignoreMessage(QtWarningMsg, warningOne.toAscii().constData()); + + QMetaObject::invokeMethod(object, "performTest"); + + QList pointList; pointList << QPoint(1, 2) << QPoint(3, 4) << QPoint(5, 6); // original values, shouldn't have changed + QCOMPARE(seq->pointListProperty(), pointList); + + delete object; + } +} + +void tst_qqmlecmascript::sequenceConversionArray() +{ + // ensure that in JS the returned sequences act just like normal JS Arrays. + QUrl qmlFile = testFileUrl("sequenceConversion.array.qml"); + QQmlComponent component(&engine, qmlFile); + QObject *object = component.create(); + QVERIFY(object != 0); + QMetaObject::invokeMethod(object, "indexedAccess"); + QVERIFY(object->property("success").toBool()); + QMetaObject::invokeMethod(object, "arrayOperations"); + QVERIFY(object->property("success").toBool()); + QMetaObject::invokeMethod(object, "testEqualitySemantics"); + QVERIFY(object->property("success").toBool()); + QMetaObject::invokeMethod(object, "testReferenceDeletion"); + QCOMPARE(object->property("referenceDeletion").toBool(), true); + delete object; +} + + +void tst_qqmlecmascript::sequenceConversionIndexes() +{ + // ensure that we gracefully fail if unsupported index values are specified. + // Qt container classes only support non-negative, signed integer index values. + QUrl qmlFile = testFileUrl("sequenceConversion.indexes.qml"); + QQmlComponent component(&engine, qmlFile); + QObject *object = component.create(); + QVERIFY(object != 0); + QString w1 = qmlFile.toString() + QLatin1String(":34: Index out of range during length set"); + QString w2 = qmlFile.toString() + QLatin1String(":41: Index out of range during indexed set"); + QString w3 = qmlFile.toString() + QLatin1String(":48: Index out of range during indexed get"); + QString w4 = qmlFile.toString() + QLatin1String(":78: std::bad_alloc during length set"); + QString w5 = qmlFile.toString() + QLatin1String(":83: std::bad_alloc during indexed set"); + QTest::ignoreMessage(QtWarningMsg, qPrintable(w1)); + QTest::ignoreMessage(QtWarningMsg, qPrintable(w2)); + QTest::ignoreMessage(QtWarningMsg, qPrintable(w3)); + QTest::ignoreMessage(QtWarningMsg, qPrintable(w4)); + QTest::ignoreMessage(QtWarningMsg, qPrintable(w5)); + QMetaObject::invokeMethod(object, "indexedAccess"); + QVERIFY(object->property("success").toBool()); + delete object; +} + +void tst_qqmlecmascript::sequenceConversionThreads() +{ + // ensure that sequence conversion operations work correctly in a worker thread + // and that serialisation between the main and worker thread succeeds. + QUrl qmlFile = testFileUrl("sequenceConversion.threads.qml"); + QQmlComponent component(&engine, qmlFile); + QObject *object = component.create(); + QVERIFY(object != 0); + + QMetaObject::invokeMethod(object, "testIntSequence"); + QTRY_VERIFY(object->property("finished").toBool()); + QVERIFY(object->property("success").toBool()); + + QMetaObject::invokeMethod(object, "testQrealSequence"); + QTRY_VERIFY(object->property("finished").toBool()); + QVERIFY(object->property("success").toBool()); + + QMetaObject::invokeMethod(object, "testBoolSequence"); + QTRY_VERIFY(object->property("finished").toBool()); + QVERIFY(object->property("success").toBool()); + + QMetaObject::invokeMethod(object, "testStringSequence"); + QTRY_VERIFY(object->property("finished").toBool()); + QVERIFY(object->property("success").toBool()); + + QMetaObject::invokeMethod(object, "testQStringSequence"); + QTRY_VERIFY(object->property("finished").toBool()); + QVERIFY(object->property("success").toBool()); + + QMetaObject::invokeMethod(object, "testUrlSequence"); + QTRY_VERIFY(object->property("finished").toBool()); + QVERIFY(object->property("success").toBool()); + + QMetaObject::invokeMethod(object, "testVariantSequence"); + QTRY_VERIFY(object->property("finished").toBool()); + QVERIFY(object->property("success").toBool()); + + delete object; +} + +void tst_qqmlecmascript::sequenceConversionBindings() +{ + { + QUrl qmlFile = testFileUrl("sequenceConversion.bindings.qml"); + QQmlComponent component(&engine, qmlFile); + QObject *object = component.create(); + QVERIFY(object != 0); + QList intList; intList << 1 << 2 << 3 << 12 << 7; + QCOMPARE(object->property("boundSequence").value >(), intList); + QCOMPARE(object->property("boundElement").toInt(), intList.at(3)); + QList intListTwo; intListTwo << 1 << 2 << 3 << 12 << 14; + QCOMPARE(object->property("boundSequenceTwo").value >(), intListTwo); + delete object; + } + + { + QUrl qmlFile = testFileUrl("sequenceConversion.bindings.error.qml"); + QString warning = QString(QLatin1String("%1:17: Unable to assign QList to QList")).arg(qmlFile.toString()); + QTest::ignoreMessage(QtWarningMsg, warning.toAscii().constData()); + QQmlComponent component(&engine, qmlFile); + QObject *object = component.create(); + QVERIFY(object != 0); + delete object; + } +} + +void tst_qqmlecmascript::sequenceConversionCopy() +{ + QUrl qmlFile = testFileUrl("sequenceConversion.copy.qml"); + QQmlComponent component(&engine, qmlFile); + QObject *object = component.create(); + QVERIFY(object != 0); + QMetaObject::invokeMethod(object, "testCopySequences"); + QCOMPARE(object->property("success").toBool(), true); + QMetaObject::invokeMethod(object, "readSequenceCopyElements"); + QCOMPARE(object->property("success").toBool(), true); + QMetaObject::invokeMethod(object, "testEqualitySemantics"); + QCOMPARE(object->property("success").toBool(), true); + delete object; +} + +void tst_qqmlecmascript::assignSequenceTypes() +{ + // test binding array to sequence type property + { + QQmlComponent component(&engine, testFileUrl("assignSequenceTypes.1.qml")); + MySequenceConversionObject *object = qobject_cast(component.create()); + QVERIFY(object != 0); + QCOMPARE(object->intListProperty(), (QList() << 1 << 2)); + QCOMPARE(object->qrealListProperty(), (QList() << 1.1 << 2.2)); + QCOMPARE(object->boolListProperty(), (QList() << false << true)); + QCOMPARE(object->urlListProperty(), (QList() << QUrl("http://www.example1.com") << QUrl("http://www.example2.com"))); + QCOMPARE(object->stringListProperty(), (QList() << QLatin1String("one") << QLatin1String("two"))); + QCOMPARE(object->qstringListProperty(), (QStringList() << QLatin1String("one") << QLatin1String("two"))); + delete object; + } + + // test binding literal to sequence type property + { + QQmlComponent component(&engine, testFileUrl("assignSequenceTypes.2.qml")); + MySequenceConversionObject *object = qobject_cast(component.create()); + QVERIFY(object != 0); + QCOMPARE(object->intListProperty(), (QList() << 1)); + QCOMPARE(object->qrealListProperty(), (QList() << 1.1)); + QCOMPARE(object->boolListProperty(), (QList() << false)); + QCOMPARE(object->urlListProperty(), (QList() << QUrl("http://www.example1.com"))); + QCOMPARE(object->stringListProperty(), (QList() << QLatin1String("one"))); + QCOMPARE(object->qstringListProperty(), (QStringList() << QLatin1String("two"))); + delete object; + } + + // test binding single value to sequence type property + { + QQmlComponent component(&engine, testFileUrl("assignSequenceTypes.3.qml")); + MySequenceConversionObject *object = qobject_cast(component.create()); + QVERIFY(object != 0); + QCOMPARE(object->intListProperty(), (QList() << 1)); + QCOMPARE(object->qrealListProperty(), (QList() << 1.1)); + QCOMPARE(object->boolListProperty(), (QList() << false)); + QCOMPARE(object->urlListProperty(), (QList() << QUrl(testFileUrl("example.html")))); + delete object; + } + + // test assigning array to sequence type property in js function + { + QQmlComponent component(&engine, testFileUrl("assignSequenceTypes.4.qml")); + MySequenceConversionObject *object = qobject_cast(component.create()); + QVERIFY(object != 0); + QCOMPARE(object->intListProperty(), (QList() << 1 << 2)); + QCOMPARE(object->qrealListProperty(), (QList() << 1.1 << 2.2)); + QCOMPARE(object->boolListProperty(), (QList() << false << true)); + QCOMPARE(object->urlListProperty(), (QList() << QUrl("http://www.example1.com") << QUrl("http://www.example2.com"))); + QCOMPARE(object->stringListProperty(), (QList() << QLatin1String("one") << QLatin1String("two"))); + QCOMPARE(object->qstringListProperty(), (QStringList() << QLatin1String("one") << QLatin1String("two"))); + delete object; + } + + // test assigning literal to sequence type property in js function + { + QQmlComponent component(&engine, testFileUrl("assignSequenceTypes.5.qml")); + MySequenceConversionObject *object = qobject_cast(component.create()); + QVERIFY(object != 0); + QCOMPARE(object->intListProperty(), (QList() << 1)); + QCOMPARE(object->qrealListProperty(), (QList() << 1.1)); + QCOMPARE(object->boolListProperty(), (QList() << false)); + QCOMPARE(object->urlListProperty(), (QList() << QUrl("http://www.example1.com"))); + QCOMPARE(object->stringListProperty(), (QList() << QLatin1String("one"))); + QCOMPARE(object->qstringListProperty(), (QStringList() << QLatin1String("two"))); + delete object; + } + + // test assigning single value to sequence type property in js function + { + QQmlComponent component(&engine, testFileUrl("assignSequenceTypes.6.qml")); + MySequenceConversionObject *object = qobject_cast(component.create()); + QVERIFY(object != 0); + QCOMPARE(object->intListProperty(), (QList() << 1)); + QCOMPARE(object->qrealListProperty(), (QList() << 1.1)); + QCOMPARE(object->boolListProperty(), (QList() << false)); + QCOMPARE(object->urlListProperty(), (QList() << QUrl(testFileUrl("example.html")))); + delete object; + } + + // test QList literal assignment and binding assignment causes url resolution when required + { + QQmlComponent component(&engine, testFileUrl("assignSequenceTypes.7.qml")); + QObject *object = component.create(); + QVERIFY(object != 0); + MySequenceConversionObject *msco1 = object->findChild(QLatin1String("msco1")); + MySequenceConversionObject *msco2 = object->findChild(QLatin1String("msco2")); + MySequenceConversionObject *msco3 = object->findChild(QLatin1String("msco3")); + MySequenceConversionObject *msco4 = object->findChild(QLatin1String("msco4")); + MySequenceConversionObject *msco5 = object->findChild(QLatin1String("msco5")); + QVERIFY(msco1 != 0 && msco2 != 0 && msco3 != 0 && msco4 != 0 && msco5 != 0); + QCOMPARE(msco1->urlListProperty(), (QList() << QUrl(testFileUrl("example.html")))); + QCOMPARE(msco2->urlListProperty(), (QList() << QUrl(testFileUrl("example.html")))); + QCOMPARE(msco3->urlListProperty(), (QList() << QUrl(testFileUrl("example.html")) << QUrl(testFileUrl("example2.html")))); + QCOMPARE(msco4->urlListProperty(), (QList() << QUrl(testFileUrl("example.html")) << QUrl(testFileUrl("example2.html")))); + QCOMPARE(msco5->urlListProperty(), (QList() << QUrl(testFileUrl("example.html")) << QUrl(testFileUrl("example2.html")))); + delete object; + } +} + +// Test that assigning a null object works +// Regressed with: df1788b4dbbb2826ae63f26bdf166342595343f4 +void tst_qqmlecmascript::nullObjectBinding() +{ + QQmlComponent component(&engine, testFileUrl("nullObjectBinding.qml")); + + QObject *object = component.create(); + QVERIFY(object != 0); + + QVERIFY(object->property("test") == QVariant::fromValue((QObject *)0)); + + delete object; +} + +// Test that bindings don't evaluate once the engine has been destroyed +void tst_qqmlecmascript::deletedEngine() +{ + QQmlEngine *engine = new QQmlEngine; + QQmlComponent component(engine, testFileUrl("deletedEngine.qml")); + + QObject *object = component.create(); + QVERIFY(object != 0); + + QCOMPARE(object->property("a").toInt(), 39); + object->setProperty("b", QVariant(9)); + QCOMPARE(object->property("a").toInt(), 117); + + delete engine; + + QCOMPARE(object->property("a").toInt(), 117); + object->setProperty("b", QVariant(10)); + QCOMPARE(object->property("a").toInt(), 117); + + delete object; +} + +// Test the crashing part of QTBUG-9705 +void tst_qqmlecmascript::libraryScriptAssert() +{ + QQmlComponent component(&engine, testFileUrl("libraryScriptAssert.qml")); + + QObject *object = component.create(); + QVERIFY(object != 0); + + delete object; +} + +void tst_qqmlecmascript::variantsAssignedUndefined() +{ + QQmlComponent component(&engine, testFileUrl("variantsAssignedUndefined.qml")); + + QObject *object = component.create(); + QVERIFY(object != 0); + + QCOMPARE(object->property("test1").toInt(), 10); + QCOMPARE(object->property("test2").toInt(), 11); + + object->setProperty("runTest", true); + + QCOMPARE(object->property("test1"), QVariant()); + QCOMPARE(object->property("test2"), QVariant()); + + + delete object; +} + +void tst_qqmlecmascript::qtbug_9792() +{ + QQmlComponent component(&engine, testFileUrl("qtbug_9792.qml")); + + QQmlContext *context = new QQmlContext(engine.rootContext()); + + MyQmlObject *object = qobject_cast(component.create(context)); + QVERIFY(object != 0); + + QTest::ignoreMessage(QtDebugMsg, "Hello world!"); + object->basicSignal(); + + delete context; + + transientErrorsMsgCount = 0; + QtMsgHandler old = qInstallMsgHandler(transientErrorsMsgHandler); + + object->basicSignal(); + + qInstallMsgHandler(old); + + QCOMPARE(transientErrorsMsgCount, 0); + + delete object; +} + +// Verifies that QQmlGuard<>s used in the vmemetaobject are cleaned correctly +void tst_qqmlecmascript::qtcreatorbug_1289() +{ + QQmlComponent component(&engine, testFileUrl("qtcreatorbug_1289.qml")); + + QObject *o = component.create(); + QVERIFY(o != 0); + + QObject *nested = qvariant_cast(o->property("object")); + QVERIFY(nested != 0); + + QVERIFY(qvariant_cast(nested->property("nestedObject")) == o); + + delete nested; + nested = qvariant_cast(o->property("object")); + QVERIFY(nested == 0); + + // If the bug is present, the next line will crash + delete o; +} + +// Test that we shut down without stupid warnings +void tst_qqmlecmascript::noSpuriousWarningsAtShutdown() +{ + { + QQmlComponent component(&engine, testFileUrl("noSpuriousWarningsAtShutdown.qml")); + + QObject *o = component.create(); + + transientErrorsMsgCount = 0; + QtMsgHandler old = qInstallMsgHandler(transientErrorsMsgHandler); + + delete o; + + qInstallMsgHandler(old); + + QCOMPARE(transientErrorsMsgCount, 0); + } + + + { + QQmlComponent component(&engine, testFileUrl("noSpuriousWarningsAtShutdown.2.qml")); + + QObject *o = component.create(); + + transientErrorsMsgCount = 0; + QtMsgHandler old = qInstallMsgHandler(transientErrorsMsgHandler); + + delete o; + + qInstallMsgHandler(old); + + QCOMPARE(transientErrorsMsgCount, 0); + } +} + +void tst_qqmlecmascript::canAssignNullToQObject() +{ + { + QQmlComponent component(&engine, testFileUrl("canAssignNullToQObject.1.qml")); + + MyQmlObject *o = qobject_cast(component.create()); + QVERIFY(o != 0); + + QVERIFY(o->objectProperty() != 0); + + o->setProperty("runTest", true); + + QVERIFY(o->objectProperty() == 0); + + delete o; + } + + { + QQmlComponent component(&engine, testFileUrl("canAssignNullToQObject.2.qml")); + + MyQmlObject *o = qobject_cast(component.create()); + QVERIFY(o != 0); + + QVERIFY(o->objectProperty() == 0); + + delete o; + } +} + +void tst_qqmlecmascript::functionAssignment_fromBinding() +{ + QQmlComponent component(&engine, testFileUrl("functionAssignment.1.qml")); + + QString url = component.url().toString(); + QString warning = url + ":4: Unable to assign a function to a property."; + QTest::ignoreMessage(QtWarningMsg, warning.toLatin1().constData()); + + MyQmlObject *o = qobject_cast(component.create()); + QVERIFY(o != 0); + + QVERIFY(!o->property("a").isValid()); + + delete o; +} + +void tst_qqmlecmascript::functionAssignment_fromJS() +{ + QFETCH(QString, triggerProperty); + + QQmlComponent component(&engine, testFileUrl("functionAssignment.2.qml")); + QVERIFY2(component.errorString().isEmpty(), qPrintable(component.errorString())); + + MyQmlObject *o = qobject_cast(component.create()); + QVERIFY(o != 0); + QVERIFY(!o->property("a").isValid()); + + o->setProperty("aNumber", QVariant(5)); + o->setProperty(triggerProperty.toUtf8().constData(), true); + QCOMPARE(o->property("a"), QVariant(50)); + + o->setProperty("aNumber", QVariant(10)); + QCOMPARE(o->property("a"), QVariant(100)); + + delete o; +} + +void tst_qqmlecmascript::functionAssignment_fromJS_data() +{ + QTest::addColumn("triggerProperty"); + + QTest::newRow("assign to property") << "assignToProperty"; + QTest::newRow("assign to property, from JS file") << "assignToPropertyFromJsFile"; + + QTest::newRow("assign to value type") << "assignToValueType"; + + QTest::newRow("use 'this'") << "assignWithThis"; + QTest::newRow("use 'this' from JS file") << "assignWithThisFromJsFile"; +} + +void tst_qqmlecmascript::functionAssignmentfromJS_invalid() +{ + QQmlComponent component(&engine, testFileUrl("functionAssignment.2.qml")); + QVERIFY2(component.errorString().isEmpty(), qPrintable(component.errorString())); + + MyQmlObject *o = qobject_cast(component.create()); + QVERIFY(o != 0); + QVERIFY(!o->property("a").isValid()); + + o->setProperty("assignFuncWithoutReturn", true); + QVERIFY(!o->property("a").isValid()); + + QString url = component.url().toString(); + QString warning = url + ":67: Unable to assign QString to int"; + QTest::ignoreMessage(QtWarningMsg, warning.toLatin1().constData()); + o->setProperty("assignWrongType", true); + + warning = url + ":71: Unable to assign QString to int"; + QTest::ignoreMessage(QtWarningMsg, warning.toLatin1().constData()); + o->setProperty("assignWrongTypeToValueType", true); + + delete o; +} + +void tst_qqmlecmascript::eval() +{ + QQmlComponent component(&engine, testFileUrl("eval.qml")); + + QObject *o = component.create(); + QVERIFY(o != 0); + + QCOMPARE(o->property("test1").toBool(), true); + QCOMPARE(o->property("test2").toBool(), true); + QCOMPARE(o->property("test3").toBool(), true); + QCOMPARE(o->property("test4").toBool(), true); + QCOMPARE(o->property("test5").toBool(), true); + + delete o; +} + +void tst_qqmlecmascript::function() +{ + QQmlComponent component(&engine, testFileUrl("function.qml")); + + QObject *o = component.create(); + QVERIFY(o != 0); + + QCOMPARE(o->property("test1").toBool(), true); + QCOMPARE(o->property("test2").toBool(), true); + QCOMPARE(o->property("test3").toBool(), true); + + delete o; +} + +void tst_qqmlecmascript::functionException() +{ + // QTBUG-24037 - shouldn't crash. + QString errstr = testFileUrl("v8functionException.qml").toString() + QLatin1String(":13: SyntaxError: Unexpected token ILLEGAL"); + QTest::ignoreMessage(QtWarningMsg, qPrintable(errstr)); + QTest::ignoreMessage(QtWarningMsg, ": Exception occurred during compilation of function: dynamicSlot()"); + QQmlComponent component(&engine, testFileUrl("v8functionException.qml")); + QObject *o = component.create(); + QVERIFY(o != 0); + QMetaObject::invokeMethod(o, "dynamicSlot"); + delete o; +} + +// Test the "Qt.include" method +void tst_qqmlecmascript::include() +{ + // Non-library relative include + { + QQmlComponent component(&engine, testFileUrl("include.qml")); + QObject *o = component.create(); + QVERIFY(o != 0); + + QCOMPARE(o->property("test0").toInt(), 99); + QCOMPARE(o->property("test1").toBool(), true); + QCOMPARE(o->property("test2").toBool(), true); + QCOMPARE(o->property("test2_1").toBool(), true); + QCOMPARE(o->property("test3").toBool(), true); + QCOMPARE(o->property("test3_1").toBool(), true); + + delete o; + } + + // Library relative include + { + QQmlComponent component(&engine, testFileUrl("include_shared.qml")); + QObject *o = component.create(); + QVERIFY(o != 0); + + QCOMPARE(o->property("test0").toInt(), 99); + QCOMPARE(o->property("test1").toBool(), true); + QCOMPARE(o->property("test2").toBool(), true); + QCOMPARE(o->property("test2_1").toBool(), true); + QCOMPARE(o->property("test3").toBool(), true); + QCOMPARE(o->property("test3_1").toBool(), true); + + delete o; + } + + // Callback + { + QQmlComponent component(&engine, testFileUrl("include_callback.qml")); + QObject *o = component.create(); + QVERIFY(o != 0); + + QCOMPARE(o->property("test1").toBool(), true); + QCOMPARE(o->property("test2").toBool(), true); + QCOMPARE(o->property("test3").toBool(), true); + QCOMPARE(o->property("test4").toBool(), true); + QCOMPARE(o->property("test5").toBool(), true); + QCOMPARE(o->property("test6").toBool(), true); + + delete o; + } + + // Including file with ".pragma library" + { + QQmlComponent component(&engine, testFileUrl("include_pragma.qml")); + QObject *o = component.create(); + QVERIFY(o != 0); + QCOMPARE(o->property("test1").toInt(), 100); + + delete o; + } + + // Remote - success + { + TestHTTPServer server(8111); + QVERIFY(server.isValid()); + server.serveDirectory(dataDirectory()); + + QQmlComponent component(&engine, testFileUrl("include_remote.qml")); + QObject *o = component.create(); + QVERIFY(o != 0); + + QTRY_VERIFY(o->property("done").toBool() == true); + QTRY_VERIFY(o->property("done2").toBool() == true); + + QCOMPARE(o->property("test1").toBool(), true); + QCOMPARE(o->property("test2").toBool(), true); + QCOMPARE(o->property("test3").toBool(), true); + QCOMPARE(o->property("test4").toBool(), true); + QCOMPARE(o->property("test5").toBool(), true); + + QCOMPARE(o->property("test6").toBool(), true); + QCOMPARE(o->property("test7").toBool(), true); + QCOMPARE(o->property("test8").toBool(), true); + QCOMPARE(o->property("test9").toBool(), true); + QCOMPARE(o->property("test10").toBool(), true); + + delete o; + } + + // Remote - error + { + TestHTTPServer server(8111); + QVERIFY(server.isValid()); + server.serveDirectory(dataDirectory()); + + QQmlComponent component(&engine, testFileUrl("include_remote_missing.qml")); + QObject *o = component.create(); + QVERIFY(o != 0); + + QTRY_VERIFY(o->property("done").toBool() == true); + + QCOMPARE(o->property("test1").toBool(), true); + QCOMPARE(o->property("test2").toBool(), true); + QCOMPARE(o->property("test3").toBool(), true); + + delete o; + } +} + +void tst_qqmlecmascript::signalHandlers() +{ + QQmlComponent component(&engine, testFileUrl("signalHandlers.qml")); + QObject *o = component.create(); + QVERIFY(o != 0); + + QVERIFY(o->property("count").toInt() == 0); + QMetaObject::invokeMethod(o, "testSignalCall"); + QCOMPARE(o->property("count").toInt(), 1); + + QMetaObject::invokeMethod(o, "testSignalHandlerCall"); + QCOMPARE(o->property("count").toInt(), 1); + QCOMPARE(o->property("errorString").toString(), QLatin1String("TypeError: Property 'onTestSignal' of object [object Object] is not a function")); + + QVERIFY(o->property("funcCount").toInt() == 0); + QMetaObject::invokeMethod(o, "testSignalConnection"); + QCOMPARE(o->property("funcCount").toInt(), 1); + + QMetaObject::invokeMethod(o, "testSignalHandlerConnection"); + QCOMPARE(o->property("funcCount").toInt(), 2); + + QMetaObject::invokeMethod(o, "testSignalDefined"); + QCOMPARE(o->property("definedResult").toBool(), true); + + QMetaObject::invokeMethod(o, "testSignalHandlerDefined"); + QCOMPARE(o->property("definedHandlerResult").toBool(), true); + + delete o; +} + +void tst_qqmlecmascript::qtbug_10696() +{ + QQmlComponent component(&engine, testFileUrl("qtbug_10696.qml")); + QObject *o = component.create(); + QVERIFY(o != 0); + delete o; +} + +void tst_qqmlecmascript::qtbug_11606() +{ + QQmlComponent component(&engine, testFileUrl("qtbug_11606.qml")); + QObject *o = component.create(); + QVERIFY(o != 0); + QCOMPARE(o->property("test").toBool(), true); + delete o; +} + +void tst_qqmlecmascript::qtbug_11600() +{ + QQmlComponent component(&engine, testFileUrl("qtbug_11600.qml")); + QObject *o = component.create(); + QVERIFY(o != 0); + QCOMPARE(o->property("test").toBool(), true); + delete o; +} + +void tst_qqmlecmascript::qtbug_21864() +{ + QQmlComponent component(&engine, testFileUrl("qtbug_21864.qml")); + QObject *o = component.create(); + QVERIFY(o != 0); + QCOMPARE(o->property("test").toBool(), true); + delete o; +} + +void tst_qqmlecmascript::rewriteMultiLineStrings() +{ + // QTBUG-23387 + QQmlComponent component(&engine, testFileUrl("rewriteMultiLineStrings.qml")); + QObject *o = component.create(); + QVERIFY(o != 0); + QTRY_COMPARE(o->property("test").toBool(), true); + delete o; +} + +void tst_qqmlecmascript::qobjectConnectionListExceptionHandling() +{ + // QTBUG-23375 + QQmlComponent component(&engine, testFileUrl("qobjectConnectionListExceptionHandling.qml")); + QString warning = component.url().toString() + QLatin1String(":13: TypeError: Cannot read property 'undefined' of undefined"); + QTest::ignoreMessage(QtWarningMsg, qPrintable(warning)); + QTest::ignoreMessage(QtWarningMsg, qPrintable(warning)); + QTest::ignoreMessage(QtWarningMsg, qPrintable(warning)); + QObject *o = component.create(); + QVERIFY(o != 0); + QCOMPARE(o->property("test").toBool(), true); + delete o; +} + +// Reading and writing non-scriptable properties should fail +void tst_qqmlecmascript::nonscriptable() +{ + QQmlComponent component(&engine, testFileUrl("nonscriptable.qml")); + QObject *o = component.create(); + QVERIFY(o != 0); + QCOMPARE(o->property("readOk").toBool(), true); + QCOMPARE(o->property("writeOk").toBool(), true); + delete o; +} + +// deleteLater() should not be callable from QML +void tst_qqmlecmascript::deleteLater() +{ + QQmlComponent component(&engine, testFileUrl("deleteLater.qml")); + QObject *o = component.create(); + QVERIFY(o != 0); + QCOMPARE(o->property("test").toBool(), true); + delete o; +} + +void tst_qqmlecmascript::in() +{ + QQmlComponent component(&engine, testFileUrl("in.qml")); + QObject *o = component.create(); + QVERIFY(o != 0); + QCOMPARE(o->property("test1").toBool(), true); + QCOMPARE(o->property("test2").toBool(), true); + delete o; +} + +void tst_qqmlecmascript::typeOf() +{ + QQmlComponent component(&engine, testFileUrl("typeOf.qml")); + + // These warnings should not happen once QTBUG-21864 is fixed + QString warning1 = component.url().toString() + QLatin1String(":16: Error: Cannot assign [undefined] to QString"); + QString warning2 = component.url().resolved(QUrl("typeOf.js")).toString() + QLatin1String(":1: ReferenceError: Can't find variable: a"); + + QTest::ignoreMessage(QtWarningMsg, qPrintable(warning1)); + QTest::ignoreMessage(QtWarningMsg, qPrintable(warning2)); + + QObject *o = component.create(); + QVERIFY(o != 0); + + QEXPECT_FAIL("", "QTBUG-21864", Abort); + QCOMPARE(o->property("test1").toString(), QLatin1String("undefined")); + QCOMPARE(o->property("test2").toString(), QLatin1String("object")); + QCOMPARE(o->property("test3").toString(), QLatin1String("number")); + QCOMPARE(o->property("test4").toString(), QLatin1String("string")); + QCOMPARE(o->property("test5").toString(), QLatin1String("function")); + QCOMPARE(o->property("test6").toString(), QLatin1String("object")); + QCOMPARE(o->property("test7").toString(), QLatin1String("undefined")); + QCOMPARE(o->property("test8").toString(), QLatin1String("boolean")); + QCOMPARE(o->property("test9").toString(), QLatin1String("object")); + + delete o; +} + +void tst_qqmlecmascript::sharedAttachedObject() +{ + QQmlComponent component(&engine, testFileUrl("sharedAttachedObject.qml")); + QObject *o = component.create(); + QVERIFY(o != 0); + QCOMPARE(o->property("test1").toBool(), true); + QCOMPARE(o->property("test2").toBool(), true); + delete o; +} + +// QTBUG-13999 +void tst_qqmlecmascript::objectName() +{ + QQmlComponent component(&engine, testFileUrl("objectName.qml")); + QObject *o = component.create(); + QVERIFY(o != 0); + + QCOMPARE(o->property("test1").toString(), QString("hello")); + QCOMPARE(o->property("test2").toString(), QString("ell")); + + o->setObjectName("world"); + + QCOMPARE(o->property("test1").toString(), QString("world")); + QCOMPARE(o->property("test2").toString(), QString("orl")); + + delete o; +} + +void tst_qqmlecmascript::writeRemovesBinding() +{ + QQmlComponent component(&engine, testFileUrl("writeRemovesBinding.qml")); + QObject *o = component.create(); + QVERIFY(o != 0); + + QCOMPARE(o->property("test").toBool(), true); + + delete o; +} + +// Test bindings assigned to alias properties actually assign to the alias' target +void tst_qqmlecmascript::aliasBindingsAssignCorrectly() +{ + QQmlComponent component(&engine, testFileUrl("aliasBindingsAssignCorrectly.qml")); + QObject *o = component.create(); + QVERIFY(o != 0); + + QCOMPARE(o->property("test").toBool(), true); + + delete o; +} + +// Test bindings assigned to alias properties override a binding on the target (QTBUG-13719) +void tst_qqmlecmascript::aliasBindingsOverrideTarget() +{ + { + QQmlComponent component(&engine, testFileUrl("aliasBindingsOverrideTarget.qml")); + QObject *o = component.create(); + QVERIFY(o != 0); + + QCOMPARE(o->property("test").toBool(), true); + + delete o; + } + + { + QQmlComponent component(&engine, testFileUrl("aliasBindingsOverrideTarget.2.qml")); + QObject *o = component.create(); + QVERIFY(o != 0); + + QCOMPARE(o->property("test").toBool(), true); + + delete o; + } + + { + QQmlComponent component(&engine, testFileUrl("aliasBindingsOverrideTarget.3.qml")); + QObject *o = component.create(); + QVERIFY(o != 0); + + QCOMPARE(o->property("test").toBool(), true); + + delete o; + } +} + +// Test that writes to alias properties override bindings on the alias target (QTBUG-13719) +void tst_qqmlecmascript::aliasWritesOverrideBindings() +{ + { + QQmlComponent component(&engine, testFileUrl("aliasWritesOverrideBindings.qml")); + QObject *o = component.create(); + QVERIFY(o != 0); + + QCOMPARE(o->property("test").toBool(), true); + + delete o; + } + + { + QQmlComponent component(&engine, testFileUrl("aliasWritesOverrideBindings.2.qml")); + QObject *o = component.create(); + QVERIFY(o != 0); + + QCOMPARE(o->property("test").toBool(), true); + + delete o; + } + + { + QQmlComponent component(&engine, testFileUrl("aliasWritesOverrideBindings.3.qml")); + QObject *o = component.create(); + QVERIFY(o != 0); + + QCOMPARE(o->property("test").toBool(), true); + + delete o; + } +} + +// Allow an alais to a composite element +// QTBUG-20200 +void tst_qqmlecmascript::aliasToCompositeElement() +{ + QQmlComponent component(&engine, testFileUrl("aliasToCompositeElement.qml")); + + QObject *object = component.create(); + QVERIFY(object != 0); + + delete object; +} + +void tst_qqmlecmascript::qtbug_20344() +{ + QQmlComponent component(&engine, testFileUrl("qtbug_20344.qml")); + + QString warning = component.url().toString() + ":5: Error: Exception thrown from within QObject slot"; + QTest::ignoreMessage(QtWarningMsg, qPrintable(warning)); + + QObject *object = component.create(); + QVERIFY(object != 0); + + delete object; +} + +void tst_qqmlecmascript::revisionErrors() +{ + { + QQmlComponent component(&engine, testFileUrl("metaobjectRevisionErrors.qml")); + QString url = component.url().toString(); + + QString warning1 = url + ":8: ReferenceError: Can't find variable: prop2"; + QString warning2 = url + ":11: ReferenceError: Can't find variable: prop2"; + QString warning3 = url + ":13: ReferenceError: Can't find variable: method2"; + + QTest::ignoreMessage(QtWarningMsg, warning1.toLatin1().constData()); + QTest::ignoreMessage(QtWarningMsg, warning2.toLatin1().constData()); + QTest::ignoreMessage(QtWarningMsg, warning3.toLatin1().constData()); + MyRevisionedClass *object = qobject_cast(component.create()); + QVERIFY(object != 0); + delete object; + } + { + QQmlComponent component(&engine, testFileUrl("metaobjectRevisionErrors2.qml")); + QString url = component.url().toString(); + + // MyRevisionedSubclass 1.0 uses MyRevisionedClass revision 0 + // method2, prop2 from MyRevisionedClass not available + // method4, prop4 from MyRevisionedSubclass not available + QString warning1 = url + ":8: ReferenceError: Can't find variable: prop2"; + QString warning2 = url + ":14: ReferenceError: Can't find variable: prop2"; + QString warning3 = url + ":10: ReferenceError: Can't find variable: prop4"; + QString warning4 = url + ":16: ReferenceError: Can't find variable: prop4"; + QString warning5 = url + ":20: ReferenceError: Can't find variable: method2"; + + QTest::ignoreMessage(QtWarningMsg, warning1.toLatin1().constData()); + QTest::ignoreMessage(QtWarningMsg, warning2.toLatin1().constData()); + QTest::ignoreMessage(QtWarningMsg, warning3.toLatin1().constData()); + QTest::ignoreMessage(QtWarningMsg, warning4.toLatin1().constData()); + QTest::ignoreMessage(QtWarningMsg, warning5.toLatin1().constData()); + MyRevisionedClass *object = qobject_cast(component.create()); + QVERIFY(object != 0); + delete object; + } + { + QQmlComponent component(&engine, testFileUrl("metaobjectRevisionErrors3.qml")); + QString url = component.url().toString(); + + // MyRevisionedSubclass 1.1 uses MyRevisionedClass revision 1 + // All properties/methods available, except MyRevisionedBaseClassUnregistered rev 1 + QString warning1 = url + ":30: ReferenceError: Can't find variable: methodD"; + QString warning2 = url + ":10: ReferenceError: Can't find variable: propD"; + QString warning3 = url + ":20: ReferenceError: Can't find variable: propD"; + QTest::ignoreMessage(QtWarningMsg, warning1.toLatin1().constData()); + QTest::ignoreMessage(QtWarningMsg, warning2.toLatin1().constData()); + QTest::ignoreMessage(QtWarningMsg, warning3.toLatin1().constData()); + MyRevisionedClass *object = qobject_cast(component.create()); + QVERIFY(object != 0); + delete object; + } +} + +void tst_qqmlecmascript::revision() +{ + { + QQmlComponent component(&engine, testFileUrl("metaobjectRevision.qml")); + QString url = component.url().toString(); + + MyRevisionedClass *object = qobject_cast(component.create()); + QVERIFY(object != 0); + delete object; + } + { + QQmlComponent component(&engine, testFileUrl("metaobjectRevision2.qml")); + QString url = component.url().toString(); + + MyRevisionedClass *object = qobject_cast(component.create()); + QVERIFY(object != 0); + delete object; + } + { + QQmlComponent component(&engine, testFileUrl("metaobjectRevision3.qml")); + QString url = component.url().toString(); + + MyRevisionedClass *object = qobject_cast(component.create()); + QVERIFY(object != 0); + delete object; + } + // Test that non-root classes can resolve revisioned methods + { + QQmlComponent component(&engine, testFileUrl("metaobjectRevision4.qml")); + + QObject *object = component.create(); + QVERIFY(object != 0); + QCOMPARE(object->property("test").toReal(), 11.); + delete object; + } +} + +void tst_qqmlecmascript::realToInt() +{ + QQmlComponent component(&engine, testFileUrl("realToInt.qml")); + MyQmlObject *object = qobject_cast(component.create()); + QVERIFY(object != 0); + + QMetaObject::invokeMethod(object, "test1"); + QCOMPARE(object->value(), int(4)); + QMetaObject::invokeMethod(object, "test2"); + QCOMPARE(object->value(), int(8)); +} + +void tst_qqmlecmascript::urlProperty() +{ + { + QQmlComponent component(&engine, testFileUrl("urlProperty.1.qml")); + MyQmlObject *object = qobject_cast(component.create()); + QVERIFY(object != 0); + object->setStringProperty("http://qt-project.org"); + QCOMPARE(object->urlProperty(), QUrl("http://qt-project.org/index.html")); + QCOMPARE(object->intProperty(), 123); + QCOMPARE(object->value(), 1); + QCOMPARE(object->property("result").toBool(), true); + } +} + +void tst_qqmlecmascript::urlPropertyWithEncoding() +{ + { + QQmlComponent component(&engine, testFileUrl("urlProperty.2.qml")); + MyQmlObject *object = qobject_cast(component.create()); + QVERIFY(object != 0); + object->setStringProperty("http://qt-project.org"); + QUrl encoded; + encoded.setEncodedUrl("http://qt-project.org/?get%3cDATA%3e", QUrl::TolerantMode); + QCOMPARE(object->urlProperty(), encoded); + QCOMPARE(object->value(), 0); // Interpreting URL as string yields canonicalised version + QCOMPARE(object->property("result").toBool(), true); + } +} + +void tst_qqmlecmascript::urlListPropertyWithEncoding() +{ + { + QQmlComponent component(&engine, testFileUrl("urlListProperty.qml")); + QObject *object = component.create(); + QVERIFY(object != 0); + MySequenceConversionObject *msco1 = object->findChild(QLatin1String("msco1")); + MySequenceConversionObject *msco2 = object->findChild(QLatin1String("msco2")); + MySequenceConversionObject *msco3 = object->findChild(QLatin1String("msco3")); + MySequenceConversionObject *msco4 = object->findChild(QLatin1String("msco4")); + QVERIFY(msco1 != 0 && msco2 != 0 && msco3 != 0 && msco4 != 0); + QUrl encoded; + encoded.setEncodedUrl("http://qt-project.org/?get%3cDATA%3e", QUrl::TolerantMode); + QCOMPARE(msco1->urlListProperty(), (QList() << encoded)); + QCOMPARE(msco2->urlListProperty(), (QList() << encoded)); + QCOMPARE(msco3->urlListProperty(), (QList() << encoded << encoded)); + QCOMPARE(msco4->urlListProperty(), (QList() << encoded << encoded)); + delete object; + } +} + +void tst_qqmlecmascript::dynamicString() +{ + QQmlComponent component(&engine, testFileUrl("dynamicString.qml")); + QObject *object = component.create(); + QVERIFY(object != 0); + QCOMPARE(object->property("stringProperty").toString(), + QString::fromLatin1("string:Hello World false:0 true:1 uint32:100 int32:-100 double:3.14159 date:2011-02-11 05::30:50!")); +} + +void tst_qqmlecmascript::automaticSemicolon() +{ + QQmlComponent component(&engine, testFileUrl("automaticSemicolon.qml")); + QObject *object = component.create(); + QVERIFY(object != 0); +} + +void tst_qqmlecmascript::unaryExpression() +{ + QQmlComponent component(&engine, testFileUrl("unaryExpression.qml")); + QObject *object = component.create(); + QVERIFY(object != 0); +} + +// Makes sure that a binding isn't double re-evaluated when it depends on the same variable twice +void tst_qqmlecmascript::doubleEvaluate() +{ + QQmlComponent component(&engine, testFileUrl("doubleEvaluate.qml")); + QObject *object = component.create(); + QVERIFY(object != 0); + WriteCounter *wc = qobject_cast(object); + QVERIFY(wc != 0); + QCOMPARE(wc->count(), 1); + + wc->setProperty("x", 9); + + QCOMPARE(wc->count(), 2); + + delete object; +} + +static QStringList messages; +static void captureMsgHandler(QtMsgType, const char *msg) +{ + messages.append(QLatin1String(msg)); +} + +void tst_qqmlecmascript::nonNotifyable() +{ + QV4Compiler::enableV4(false); + QQmlComponent component(&engine, testFileUrl("nonNotifyable.qml")); + QV4Compiler::enableV4(true); + + QtMsgHandler old = qInstallMsgHandler(captureMsgHandler); + messages.clear(); + QObject *object = component.create(); + qInstallMsgHandler(old); + + QVERIFY(object != 0); + + QString expected1 = QLatin1String("QQmlExpression: Expression ") + + component.url().toString() + + QLatin1String(":5 depends on non-NOTIFYable properties:"); + QString expected2 = QLatin1String(" ") + + QLatin1String(object->metaObject()->className()) + + QLatin1String("::value"); + + QCOMPARE(messages.length(), 2); + QCOMPARE(messages.at(0), expected1); + QCOMPARE(messages.at(1), expected2); + + delete object; +} + +void tst_qqmlecmascript::forInLoop() +{ + QQmlComponent component(&engine, testFileUrl("forInLoop.qml")); + QObject *object = component.create(); + QVERIFY(object != 0); + + QMetaObject::invokeMethod(object, "listProperty"); + + QStringList r = object->property("listResult").toString().split("|", QString::SkipEmptyParts); + QCOMPARE(r.size(), 3); + QCOMPARE(r[0],QLatin1String("0=obj1")); + QCOMPARE(r[1],QLatin1String("1=obj2")); + QCOMPARE(r[2],QLatin1String("2=obj3")); + + //TODO: should test for in loop for other objects (such as QObjects) as well. + + delete object; +} + +// An object the binding depends on is deleted while the binding is still running +void tst_qqmlecmascript::deleteWhileBindingRunning() +{ + QQmlComponent component(&engine, testFileUrl("deleteWhileBindingRunning.qml")); + QObject *object = component.create(); + QVERIFY(object != 0); + delete object; +} + +void tst_qqmlecmascript::qtbug_22679() +{ + MyQmlObject object; + object.setStringProperty(QLatin1String("Please work correctly")); + engine.rootContext()->setContextProperty("contextProp", &object); + + QQmlComponent component(&engine, testFileUrl("qtbug_22679.qml")); + qRegisterMetaType >("QList"); + QSignalSpy warningsSpy(&engine, SIGNAL(warnings(QList))); + + QObject *o = component.create(); + QVERIFY(o != 0); + QCOMPARE(warningsSpy.count(), 0); + delete o; +} + +void tst_qqmlecmascript::qtbug_22843_data() +{ + QTest::addColumn("library"); + + QTest::newRow("without .pragma library") << false; + QTest::newRow("with .pragma library") << true; +} + +void tst_qqmlecmascript::qtbug_22843() +{ + QFETCH(bool, library); + + QString fileName("qtbug_22843"); + if (library) + fileName += QLatin1String(".library"); + fileName += QLatin1String(".qml"); + + QQmlComponent component(&engine, testFileUrl(fileName)); + QString url = component.url().toString(); + QString warning1 = url.left(url.length()-3) + QLatin1String("js:4: SyntaxError: Unexpected token )"); + QString warning2 = url + QLatin1String(":5: TypeError: Object [object Object] has no method 'func'"); + + qRegisterMetaType >("QList"); + QSignalSpy warningsSpy(&engine, SIGNAL(warnings(QList))); + for (int x = 0; x < 3; ++x) { + warningsSpy.clear(); + // For libraries, only the first import attempt should produce a + // SyntaxError warning; subsequent component creation should not + // attempt to reload the script. + bool expectSyntaxError = !library || (x == 0); + if (expectSyntaxError) + QTest::ignoreMessage(QtWarningMsg, qPrintable(warning1)); + QTest::ignoreMessage(QtWarningMsg, qPrintable(warning2)); + QObject *object = component.create(); + QVERIFY(object != 0); + QCOMPARE(warningsSpy.count(), 1 + (expectSyntaxError?1:0)); + delete object; + } +} + + +void tst_qqmlecmascript::switchStatement() +{ + { + QQmlComponent component(&engine, testFileUrl("switchStatement.1.qml")); + MyQmlObject *object = qobject_cast(component.create()); + QVERIFY(object != 0); + + // `object->value()' is the number of executed statements + + object->setStringProperty("A"); + QCOMPARE(object->value(), 5); + + object->setStringProperty("S"); + QCOMPARE(object->value(), 3); + + object->setStringProperty("D"); + QCOMPARE(object->value(), 3); + + object->setStringProperty("F"); + QCOMPARE(object->value(), 4); + + object->setStringProperty("something else"); + QCOMPARE(object->value(), 1); + } + + { + QQmlComponent component(&engine, testFileUrl("switchStatement.2.qml")); + MyQmlObject *object = qobject_cast(component.create()); + QVERIFY(object != 0); + + // `object->value()' is the number of executed statements + + object->setStringProperty("A"); + QCOMPARE(object->value(), 5); + + object->setStringProperty("S"); + QCOMPARE(object->value(), 3); + + object->setStringProperty("D"); + QCOMPARE(object->value(), 3); + + object->setStringProperty("F"); + QCOMPARE(object->value(), 3); + + object->setStringProperty("something else"); + QCOMPARE(object->value(), 4); + } + + { + QQmlComponent component(&engine, testFileUrl("switchStatement.3.qml")); + MyQmlObject *object = qobject_cast(component.create()); + QVERIFY(object != 0); + + // `object->value()' is the number of executed statements + + object->setStringProperty("A"); + QCOMPARE(object->value(), 5); + + object->setStringProperty("S"); + QCOMPARE(object->value(), 3); + + object->setStringProperty("D"); + QCOMPARE(object->value(), 3); + + object->setStringProperty("F"); + QCOMPARE(object->value(), 3); + + object->setStringProperty("something else"); + QCOMPARE(object->value(), 6); + } + + { + QQmlComponent component(&engine, testFileUrl("switchStatement.4.qml")); + + QString warning = component.url().toString() + ":4: Unable to assign [undefined] to int"; + QTest::ignoreMessage(QtWarningMsg, qPrintable(warning)); + + MyQmlObject *object = qobject_cast(component.create()); + QVERIFY(object != 0); + + // `object->value()' is the number of executed statements + + object->setStringProperty("A"); + QCOMPARE(object->value(), 5); + + object->setStringProperty("S"); + QCOMPARE(object->value(), 3); + + object->setStringProperty("D"); + QCOMPARE(object->value(), 3); + + object->setStringProperty("F"); + QCOMPARE(object->value(), 3); + + QTest::ignoreMessage(QtWarningMsg, qPrintable(warning)); + + object->setStringProperty("something else"); + } + + { + QQmlComponent component(&engine, testFileUrl("switchStatement.5.qml")); + MyQmlObject *object = qobject_cast(component.create()); + QVERIFY(object != 0); + + // `object->value()' is the number of executed statements + + object->setStringProperty("A"); + QCOMPARE(object->value(), 1); + + object->setStringProperty("S"); + QCOMPARE(object->value(), 1); + + object->setStringProperty("D"); + QCOMPARE(object->value(), 1); + + object->setStringProperty("F"); + QCOMPARE(object->value(), 1); + + object->setStringProperty("something else"); + QCOMPARE(object->value(), 1); + } + + { + QQmlComponent component(&engine, testFileUrl("switchStatement.6.qml")); + MyQmlObject *object = qobject_cast(component.create()); + QVERIFY(object != 0); + + // `object->value()' is the number of executed statements + + object->setStringProperty("A"); + QCOMPARE(object->value(), 123); + + object->setStringProperty("S"); + QCOMPARE(object->value(), 123); + + object->setStringProperty("D"); + QCOMPARE(object->value(), 321); + + object->setStringProperty("F"); + QCOMPARE(object->value(), 321); + + object->setStringProperty("something else"); + QCOMPARE(object->value(), 0); + } +} + +void tst_qqmlecmascript::withStatement() +{ + { + QQmlComponent component(&engine, testFileUrl("withStatement.1.qml")); + MyQmlObject *object = qobject_cast(component.create()); + QVERIFY(object != 0); + + QCOMPARE(object->value(), 123); + } +} + +void tst_qqmlecmascript::tryStatement() +{ + { + QQmlComponent component(&engine, testFileUrl("tryStatement.1.qml")); + MyQmlObject *object = qobject_cast(component.create()); + QVERIFY(object != 0); + + QCOMPARE(object->value(), 123); + } + + { + QQmlComponent component(&engine, testFileUrl("tryStatement.2.qml")); + MyQmlObject *object = qobject_cast(component.create()); + QVERIFY(object != 0); + + QCOMPARE(object->value(), 321); + } + + { + QQmlComponent component(&engine, testFileUrl("tryStatement.3.qml")); + MyQmlObject *object = qobject_cast(component.create()); + QVERIFY(object != 0); + + QCOMPARE(object->value(), 1); + } + + { + QQmlComponent component(&engine, testFileUrl("tryStatement.4.qml")); + MyQmlObject *object = qobject_cast(component.create()); + QVERIFY(object != 0); + + QCOMPARE(object->value(), 1); + } +} + +class CppInvokableWithQObjectDerived : public QObject +{ + Q_OBJECT +public: + CppInvokableWithQObjectDerived() {} + ~CppInvokableWithQObjectDerived() {} + + Q_INVOKABLE MyQmlObject *createMyQmlObject(QString data) + { + MyQmlObject *obj = new MyQmlObject(); + obj->setStringProperty(data); + return obj; + } + + Q_INVOKABLE QString getStringProperty(MyQmlObject *obj) + { + return obj->stringProperty(); + } +}; + +void tst_qqmlecmascript::invokableWithQObjectDerived() +{ + CppInvokableWithQObjectDerived invokable; + + { + QQmlEngine engine; + engine.rootContext()->setContextProperty("invokable", &invokable); + + QQmlComponent component(&engine, testFileUrl("qobjectDerivedArgument.qml")); + + QObject *object = component.create(); + + QVERIFY(object != 0); + QVERIFY(object->property("result").value() == true); + + delete object; + } +} + +QTEST_MAIN(tst_qqmlecmascript) + +#include "tst_qqmlecmascript.moc" diff --git a/tests/auto/qml/qqmlengine/qqmlengine.pro b/tests/auto/qml/qqmlengine/qqmlengine.pro new file mode 100644 index 0000000000..e87b4e30aa --- /dev/null +++ b/tests/auto/qml/qqmlengine/qqmlengine.pro @@ -0,0 +1,9 @@ +CONFIG += testcase +TARGET = tst_qqmlengine +macx:CONFIG -= app_bundle + +SOURCES += tst_qqmlengine.cpp + +CONFIG += parallel_test + +QT += core-private gui-private qml-private network testlib diff --git a/tests/auto/qml/qqmlengine/tst_qqmlengine.cpp b/tests/auto/qml/qqmlengine/tst_qqmlengine.cpp new file mode 100644 index 0000000000..af2c897d7a --- /dev/null +++ b/tests/auto/qml/qqmlengine/tst_qqmlengine.cpp @@ -0,0 +1,365 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +class tst_qqmlengine : public QObject +{ + Q_OBJECT +public: + tst_qqmlengine() {} + +private slots: + void rootContext(); + void networkAccessManager(); + void baseUrl(); + void contextForObject(); + void offlineStoragePath(); + void clearComponentCache(); + void outputWarningsToStandardError(); + void objectOwnership(); + void multipleEngines(); +}; + +void tst_qqmlengine::rootContext() +{ + QQmlEngine engine; + + QVERIFY(engine.rootContext()); + + QCOMPARE(engine.rootContext()->engine(), &engine); + QVERIFY(engine.rootContext()->parentContext() == 0); +} + +class NetworkAccessManagerFactory : public QQmlNetworkAccessManagerFactory +{ +public: + NetworkAccessManagerFactory() : manager(0) {} + + QNetworkAccessManager *create(QObject *parent) { + manager = new QNetworkAccessManager(parent); + return manager; + } + + QNetworkAccessManager *manager; +}; + +void tst_qqmlengine::networkAccessManager() +{ + QQmlEngine *engine = new QQmlEngine; + + // Test QQmlEngine created manager + QPointer manager = engine->networkAccessManager(); + QVERIFY(manager != 0); + delete engine; + + // Test factory created manager + engine = new QQmlEngine; + NetworkAccessManagerFactory factory; + engine->setNetworkAccessManagerFactory(&factory); + QVERIFY(engine->networkAccessManagerFactory() == &factory); + QVERIFY(engine->networkAccessManager() == factory.manager); + delete engine; +} + +void tst_qqmlengine::baseUrl() +{ + QQmlEngine engine; + + QUrl cwd = QUrl::fromLocalFile(QDir::currentPath() + QDir::separator()); + + QCOMPARE(engine.baseUrl(), cwd); + QCOMPARE(engine.rootContext()->resolvedUrl(QUrl("main.qml")), cwd.resolved(QUrl("main.qml"))); + + QDir dir = QDir::current(); + dir.cdUp(); + QVERIFY(dir != QDir::current()); + QDir::setCurrent(dir.path()); + QVERIFY(QDir::current() == dir); + + QUrl cwd2 = QUrl::fromLocalFile(QDir::currentPath() + QDir::separator()); + QCOMPARE(engine.baseUrl(), cwd2); + QCOMPARE(engine.rootContext()->resolvedUrl(QUrl("main.qml")), cwd2.resolved(QUrl("main.qml"))); + + engine.setBaseUrl(cwd); + QCOMPARE(engine.baseUrl(), cwd); + QCOMPARE(engine.rootContext()->resolvedUrl(QUrl("main.qml")), cwd.resolved(QUrl("main.qml"))); +} + +void tst_qqmlengine::contextForObject() +{ + QQmlEngine *engine = new QQmlEngine; + + // Test null-object + QVERIFY(QQmlEngine::contextForObject(0) == 0); + + // Test an object with no context + QObject object; + QVERIFY(QQmlEngine::contextForObject(&object) == 0); + + // Test setting null-object + QQmlEngine::setContextForObject(0, engine->rootContext()); + + // Test setting null-context + QQmlEngine::setContextForObject(&object, 0); + + // Test setting context + QQmlEngine::setContextForObject(&object, engine->rootContext()); + QVERIFY(QQmlEngine::contextForObject(&object) == engine->rootContext()); + + QQmlContext context(engine->rootContext()); + + // Try changing context + QTest::ignoreMessage(QtWarningMsg, "QQmlEngine::setContextForObject(): Object already has a QQmlContext"); + QQmlEngine::setContextForObject(&object, &context); + QVERIFY(QQmlEngine::contextForObject(&object) == engine->rootContext()); + + // Delete context + delete engine; engine = 0; + QVERIFY(QQmlEngine::contextForObject(&object) == 0); +} + +void tst_qqmlengine::offlineStoragePath() +{ + // Without these set, QDesktopServices::storageLocation returns + // strings with extra "//" at the end. We set them to ignore this problem. + qApp->setApplicationName("tst_qqmlengine"); + qApp->setOrganizationName("Nokia"); + qApp->setOrganizationDomain("nokia.com"); + + QQmlEngine engine; + + QDir dir(QStandardPaths::writableLocation(QStandardPaths::DataLocation)); + dir.mkpath("QML"); + dir.cd("QML"); + dir.mkpath("OfflineStorage"); + dir.cd("OfflineStorage"); + + QCOMPARE(QDir::fromNativeSeparators(engine.offlineStoragePath()), dir.path()); + + engine.setOfflineStoragePath(QDir::homePath()); + QCOMPARE(engine.offlineStoragePath(), QDir::homePath()); +} + +void tst_qqmlengine::clearComponentCache() +{ + QQmlEngine engine; + + // Create original qml file + { + QFile file("temp.qml"); + QVERIFY(file.open(QIODevice::WriteOnly)); + file.write("import QtQuick 2.0\nQtObject {\nproperty int test: 10\n}\n"); + file.close(); + } + + // Test "test" property + { + QQmlComponent component(&engine, "temp.qml"); + QObject *obj = component.create(); + QVERIFY(obj != 0); + QCOMPARE(obj->property("test").toInt(), 10); + delete obj; + } + + // Modify qml file + { + QFile file("temp.qml"); + QVERIFY(file.open(QIODevice::WriteOnly)); + file.write("import QtQuick 2.0\nQtObject {\nproperty int test: 11\n}\n"); + file.close(); + } + + // Test cache hit + { + QQmlComponent component(&engine, "temp.qml"); + QObject *obj = component.create(); + QVERIFY(obj != 0); + QCOMPARE(obj->property("test").toInt(), 10); + delete obj; + } + + // Clear cache + engine.clearComponentCache(); + + // Test cache refresh + { + QQmlComponent component(&engine, "temp.qml"); + QObject *obj = component.create(); + QVERIFY(obj != 0); + QCOMPARE(obj->property("test").toInt(), 11); + delete obj; + } +} + +static QStringList warnings; +static void msgHandler(QtMsgType, const char *warning) +{ + warnings << QString::fromUtf8(warning); +} + +void tst_qqmlengine::outputWarningsToStandardError() +{ + QQmlEngine engine; + + QCOMPARE(engine.outputWarningsToStandardError(), true); + + QQmlComponent c(&engine); + c.setData("import QtQuick 2.0; QtObject { property int a: undefined }", QUrl()); + + QVERIFY(c.isReady() == true); + + warnings.clear(); + QtMsgHandler old = qInstallMsgHandler(msgHandler); + + QObject *o = c.create(); + + qInstallMsgHandler(old); + + QVERIFY(o != 0); + delete o; + + QCOMPARE(warnings.count(), 1); + QCOMPARE(warnings.at(0), QLatin1String(":1: Unable to assign [undefined] to int")); + warnings.clear(); + + + engine.setOutputWarningsToStandardError(false); + QCOMPARE(engine.outputWarningsToStandardError(), false); + + + old = qInstallMsgHandler(msgHandler); + + o = c.create(); + + qInstallMsgHandler(old); + + QVERIFY(o != 0); + delete o; + + QCOMPARE(warnings.count(), 0); +} + +void tst_qqmlengine::objectOwnership() +{ + { + QCOMPARE(QQmlEngine::objectOwnership(0), QQmlEngine::CppOwnership); + QQmlEngine::setObjectOwnership(0, QQmlEngine::JavaScriptOwnership); + QCOMPARE(QQmlEngine::objectOwnership(0), QQmlEngine::CppOwnership); + } + + { + QObject o; + QCOMPARE(QQmlEngine::objectOwnership(&o), QQmlEngine::CppOwnership); + QQmlEngine::setObjectOwnership(&o, QQmlEngine::CppOwnership); + QCOMPARE(QQmlEngine::objectOwnership(&o), QQmlEngine::CppOwnership); + QQmlEngine::setObjectOwnership(&o, QQmlEngine::JavaScriptOwnership); + QCOMPARE(QQmlEngine::objectOwnership(&o), QQmlEngine::JavaScriptOwnership); + QQmlEngine::setObjectOwnership(&o, QQmlEngine::CppOwnership); + QCOMPARE(QQmlEngine::objectOwnership(&o), QQmlEngine::CppOwnership); + } + + { + QQmlEngine engine; + QQmlComponent c(&engine); + c.setData("import QtQuick 2.0; QtObject { property QtObject object: QtObject {} }", QUrl()); + + QObject *o = c.create(); + QVERIFY(o != 0); + + QCOMPARE(QQmlEngine::objectOwnership(o), QQmlEngine::CppOwnership); + + QObject *o2 = qvariant_cast(o->property("object")); + QCOMPARE(QQmlEngine::objectOwnership(o2), QQmlEngine::JavaScriptOwnership); + + delete o; + } + +} + +// Test an object can be accessed by multiple engines +void tst_qqmlengine::multipleEngines() +{ + QObject o; + o.setObjectName("TestName"); + + // Simultaneous engines + { + QQmlEngine engine1; + QQmlEngine engine2; + engine1.rootContext()->setContextProperty("object", &o); + engine2.rootContext()->setContextProperty("object", &o); + + QQmlExpression expr1(engine1.rootContext(), 0, QString("object.objectName")); + QQmlExpression expr2(engine2.rootContext(), 0, QString("object.objectName")); + + QCOMPARE(expr1.evaluate().toString(), QString("TestName")); + QCOMPARE(expr2.evaluate().toString(), QString("TestName")); + } + + // Serial engines + { + QQmlEngine engine1; + engine1.rootContext()->setContextProperty("object", &o); + QQmlExpression expr1(engine1.rootContext(), 0, QString("object.objectName")); + QCOMPARE(expr1.evaluate().toString(), QString("TestName")); + } + { + QQmlEngine engine1; + engine1.rootContext()->setContextProperty("object", &o); + QQmlExpression expr1(engine1.rootContext(), 0, QString("object.objectName")); + QCOMPARE(expr1.evaluate().toString(), QString("TestName")); + } +} + +QTEST_MAIN(tst_qqmlengine) + +#include "tst_qqmlengine.moc" diff --git a/tests/auto/qml/qqmlerror/data/test.txt b/tests/auto/qml/qqmlerror/data/test.txt new file mode 100644 index 0000000000..cdafd9ed82 --- /dev/null +++ b/tests/auto/qml/qqmlerror/data/test.txt @@ -0,0 +1,3 @@ +Line Content +Line2 Content +Line3 Content diff --git a/tests/auto/qml/qqmlerror/qqmlerror.pro b/tests/auto/qml/qqmlerror/qqmlerror.pro new file mode 100644 index 0000000000..be2b9ab24f --- /dev/null +++ b/tests/auto/qml/qqmlerror/qqmlerror.pro @@ -0,0 +1,15 @@ +CONFIG += testcase +TARGET = tst_qqmlerror +SOURCES += tst_qqmlerror.cpp + +include (../../shared/util.pri) + +macx:CONFIG -= app_bundle + +CONFIG += parallel_test + +testDataFiles.files = data +testDataFiles.path = . +DEPLOYMENT += testDataFiles + +QT += core-private gui-private qml-private testlib diff --git a/tests/auto/qml/qqmlerror/tst_qqmlerror.cpp b/tests/auto/qml/qqmlerror/tst_qqmlerror.cpp new file mode 100644 index 0000000000..b0e9f50a17 --- /dev/null +++ b/tests/auto/qml/qqmlerror/tst_qqmlerror.cpp @@ -0,0 +1,243 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include +#include +#include "../../shared/util.h" + +class tst_qqmlerror : public QQmlDataTest +{ + Q_OBJECT +private slots: + void url(); + void description(); + void line(); + void column(); + void toString(); + + void copy(); + void debug(); +}; + +void tst_qqmlerror::url() +{ + QQmlError error; + + QCOMPARE(error.url(), QUrl()); + + error.setUrl(QUrl("http://www.nokia.com/main.qml")); + + QCOMPARE(error.url(), QUrl("http://www.nokia.com/main.qml")); + + QQmlError error2 = error; + + QCOMPARE(error2.url(), QUrl("http://www.nokia.com/main.qml")); + + error.setUrl(QUrl("http://qt.nokia.com/main.qml")); + + QCOMPARE(error.url(), QUrl("http://qt.nokia.com/main.qml")); + QCOMPARE(error2.url(), QUrl("http://www.nokia.com/main.qml")); +} + +void tst_qqmlerror::description() +{ + QQmlError error; + + QCOMPARE(error.description(), QString()); + + error.setDescription("An Error"); + + QCOMPARE(error.description(), QString("An Error")); + + QQmlError error2 = error; + + QCOMPARE(error2.description(), QString("An Error")); + + error.setDescription("Another Error"); + + QCOMPARE(error.description(), QString("Another Error")); + QCOMPARE(error2.description(), QString("An Error")); +} + +void tst_qqmlerror::line() +{ + QQmlError error; + + QCOMPARE(error.line(), -1); + + error.setLine(102); + + QCOMPARE(error.line(), 102); + + QQmlError error2 = error; + + QCOMPARE(error2.line(), 102); + + error.setLine(4); + + QCOMPARE(error.line(), 4); + QCOMPARE(error2.line(), 102); +} + +void tst_qqmlerror::column() +{ + QQmlError error; + + QCOMPARE(error.column(), -1); + + error.setColumn(16); + + QCOMPARE(error.column(), 16); + + QQmlError error2 = error; + + QCOMPARE(error2.column(), 16); + + error.setColumn(3); + + QCOMPARE(error.column(), 3); + QCOMPARE(error2.column(), 16); +} + +void tst_qqmlerror::toString() +{ + { + QQmlError error; + error.setUrl(QUrl("http://www.nokia.com/main.qml")); + error.setDescription("An Error"); + error.setLine(92); + error.setColumn(13); + + QCOMPARE(error.toString(), QString("http://www.nokia.com/main.qml:92:13: An Error")); + } + + { + QQmlError error; + error.setUrl(QUrl("http://www.nokia.com/main.qml")); + error.setDescription("An Error"); + error.setLine(92); + + QCOMPARE(error.toString(), QString("http://www.nokia.com/main.qml:92: An Error")); + } +} + +void tst_qqmlerror::copy() +{ + QQmlError error; + error.setUrl(QUrl("http://www.nokia.com/main.qml")); + error.setDescription("An Error"); + error.setLine(92); + error.setColumn(13); + + QQmlError error2(error); + QQmlError error3; + error3 = error; + + error.setUrl(QUrl("http://qt.nokia.com/main.qml")); + error.setDescription("Another Error"); + error.setLine(2); + error.setColumn(33); + + QCOMPARE(error.url(), QUrl("http://qt.nokia.com/main.qml")); + QCOMPARE(error.description(), QString("Another Error")); + QCOMPARE(error.line(), 2); + QCOMPARE(error.column(), 33); + + QCOMPARE(error2.url(), QUrl("http://www.nokia.com/main.qml")); + QCOMPARE(error2.description(), QString("An Error")); + QCOMPARE(error2.line(), 92); + QCOMPARE(error2.column(), 13); + + QCOMPARE(error3.url(), QUrl("http://www.nokia.com/main.qml")); + QCOMPARE(error3.description(), QString("An Error")); + QCOMPARE(error3.line(), 92); + QCOMPARE(error3.column(), 13); + +} + +void tst_qqmlerror::debug() +{ + { + QQmlError error; + error.setUrl(QUrl("http://www.nokia.com/main.qml")); + error.setDescription("An Error"); + error.setLine(92); + error.setColumn(13); + + QTest::ignoreMessage(QtWarningMsg, "http://www.nokia.com/main.qml:92:13: An Error "); + qWarning() << error; + } + + { + QUrl url(dataDirectoryUrl().resolved(QUrl("test.txt"))); + QQmlError error; + error.setUrl(url); + error.setDescription("An Error"); + error.setLine(2); + error.setColumn(5); + + QString out = url.toString() + ":2:5: An Error \n Line2 Content \n ^ "; + QTest::ignoreMessage(QtWarningMsg, qPrintable(out)); + + qWarning() << error; + } + + { + QUrl url(dataDirectoryUrl().resolved(QUrl("foo.txt"))); + QQmlError error; + error.setUrl(url); + error.setDescription("An Error"); + error.setLine(2); + error.setColumn(5); + + QString out = url.toString() + ":2:5: An Error "; + QTest::ignoreMessage(QtWarningMsg, qPrintable(out)); + + qWarning() << error; + } +} + + + +QTEST_MAIN(tst_qqmlerror) + +#include "tst_qqmlerror.moc" diff --git a/tests/auto/qml/qqmlexpression/data/scriptString.qml b/tests/auto/qml/qqmlexpression/data/scriptString.qml new file mode 100644 index 0000000000..38c3d1b456 --- /dev/null +++ b/tests/auto/qml/qqmlexpression/data/scriptString.qml @@ -0,0 +1,9 @@ +import QtQuick 2.0 +import Test 1.0 + +TestObject { + property int value1: 10 + property int value2: 5 + scriptString: value1 + value2 + scriptStringError: value3 * 5 +} diff --git a/tests/auto/qml/qqmlexpression/qqmlexpression.pro b/tests/auto/qml/qqmlexpression/qqmlexpression.pro new file mode 100644 index 0000000000..c2c1aa86e3 --- /dev/null +++ b/tests/auto/qml/qqmlexpression/qqmlexpression.pro @@ -0,0 +1,15 @@ +CONFIG += testcase +TARGET = tst_qqmlexpression +macx:CONFIG -= app_bundle + +SOURCES += tst_qqmlexpression.cpp + +include (../../shared/util.pri) + +testDataFiles.files = data +testDataFiles.path = . +DEPLOYMENT += testDataFiles + +CONFIG += parallel_test + +QT += core-private gui-private qml-private testlib diff --git a/tests/auto/qml/qqmlexpression/tst_qqmlexpression.cpp b/tests/auto/qml/qqmlexpression/tst_qqmlexpression.cpp new file mode 100644 index 0000000000..5cc6289212 --- /dev/null +++ b/tests/auto/qml/qqmlexpression/tst_qqmlexpression.cpp @@ -0,0 +1,121 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include +#include +#include +#include +#include "../../shared/util.h" + +class tst_qqmlexpression : public QQmlDataTest +{ + Q_OBJECT +public: + tst_qqmlexpression() {} + +private slots: + void scriptString(); + void syntaxError(); +}; + +class TestObject : public QObject +{ + Q_OBJECT + Q_PROPERTY(QQmlScriptString scriptString READ scriptString WRITE setScriptString) + Q_PROPERTY(QQmlScriptString scriptStringError READ scriptStringError WRITE setScriptStringError) +public: + TestObject(QObject *parent = 0) : QObject(parent) {} + + QQmlScriptString scriptString() const { return m_scriptString; } + void setScriptString(QQmlScriptString scriptString) { m_scriptString = scriptString; } + + QQmlScriptString scriptStringError() const { return m_scriptStringError; } + void setScriptStringError(QQmlScriptString scriptString) { m_scriptStringError = scriptString; } + +private: + QQmlScriptString m_scriptString; + QQmlScriptString m_scriptStringError; +}; + +QML_DECLARE_TYPE(TestObject) + +void tst_qqmlexpression::scriptString() +{ + qmlRegisterType("Test", 1, 0, "TestObject"); + + QQmlEngine engine; + QQmlComponent c(&engine, testFileUrl("scriptString.qml")); + TestObject *testObj = qobject_cast(c.create()); + QVERIFY(testObj != 0); + + QQmlScriptString script = testObj->scriptString(); + QCOMPARE(script.script(), QLatin1String("value1 + value2")); + + QQmlExpression expression(script); + QVariant value = expression.evaluate(); + QCOMPARE(value.toInt(), 15); + + QQmlScriptString scriptError = testObj->scriptStringError(); + QCOMPARE(scriptError.script(), QLatin1String("value3 * 5")); + + //verify that the expression has the correct error location information + QQmlExpression expressionError(scriptError); + QVariant valueError = expressionError.evaluate(); + QVERIFY(!valueError.isValid()); + QVERIFY(expressionError.hasError()); + QQmlError error = expressionError.error(); + QCOMPARE(error.url(), c.url()); + QCOMPARE(error.line(), 8); +} + +// QTBUG-21310 - crash test +void tst_qqmlexpression::syntaxError() +{ + QQmlEngine engine; + QQmlExpression expression(engine.rootContext(), 0, "asd asd"); + QVariant v = expression.evaluate(); + QCOMPARE(v, QVariant()); +} + +QTEST_MAIN(tst_qqmlexpression) + +#include "tst_qqmlexpression.moc" diff --git a/tests/auto/qml/qqmlimageprovider/qqmlimageprovider.pro b/tests/auto/qml/qqmlimageprovider/qqmlimageprovider.pro new file mode 100644 index 0000000000..9feeee15fd --- /dev/null +++ b/tests/auto/qml/qqmlimageprovider/qqmlimageprovider.pro @@ -0,0 +1,9 @@ +CONFIG += testcase +TARGET = tst_qqmlimageprovider +macx:CONFIG -= app_bundle + +SOURCES += tst_qqmlimageprovider.cpp + +CONFIG += parallel_test + +QT += core-private gui-private qml-private quick-private network testlib diff --git a/tests/auto/qml/qqmlimageprovider/tst_qqmlimageprovider.cpp b/tests/auto/qml/qqmlimageprovider/tst_qqmlimageprovider.cpp new file mode 100644 index 0000000000..bc53544566 --- /dev/null +++ b/tests/auto/qml/qqmlimageprovider/tst_qqmlimageprovider.cpp @@ -0,0 +1,424 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include +#include +#include +#include +#include +#include +#include + +Q_DECLARE_METATYPE(QQmlImageProvider*); + +class tst_qqmlimageprovider : public QObject +{ + Q_OBJECT +public: + tst_qqmlimageprovider() + { + } + +private slots: + void requestImage_sync_data(); + void requestImage_sync(); + void requestImage_async_data(); + void requestImage_async(); + + void requestPixmap_sync_data(); + void requestPixmap_sync(); + void requestPixmap_async(); + + void removeProvider_data(); + void removeProvider(); + + void threadTest(); + +private: + QString newImageFileName() const; + void fillRequestTestsData(const QString &id); + void runTest(bool async, QQmlImageProvider *provider); +}; + + +class TestQImageProvider : public QQmlImageProvider +{ +public: + TestQImageProvider(bool *deleteWatch = 0) + : QQmlImageProvider(Image), deleteWatch(deleteWatch) + { + } + + ~TestQImageProvider() + { + if (deleteWatch) + *deleteWatch = true; + } + + QImage requestImage(const QString &id, QSize *size, const QSize& requestedSize) + { + lastImageId = id; + + if (id == QLatin1String("no-such-file.png")) + return QImage(); + + int width = 100; + int height = 100; + QImage image(width, height, QImage::Format_RGB32); + if (size) + *size = QSize(width, height); + if (requestedSize.isValid()) + image = image.scaled(requestedSize); + return image; + } + + bool *deleteWatch; + QString lastImageId; +}; +Q_DECLARE_METATYPE(TestQImageProvider*); + + +class TestQPixmapProvider : public QQmlImageProvider +{ +public: + TestQPixmapProvider(bool *deleteWatch = 0) + : QQmlImageProvider(Pixmap), deleteWatch(deleteWatch) + { + } + + ~TestQPixmapProvider() + { + if (deleteWatch) + *deleteWatch = true; + } + + QPixmap requestPixmap(const QString &id, QSize *size, const QSize& requestedSize) + { + lastImageId = id; + + if (id == QLatin1String("no-such-file.png")) + return QPixmap(); + + int width = 100; + int height = 100; + QPixmap image(width, height); + if (size) + *size = QSize(width, height); + if (requestedSize.isValid()) + image = image.scaled(requestedSize); + return image; + } + + bool *deleteWatch; + QString lastImageId; +}; +Q_DECLARE_METATYPE(TestQPixmapProvider*); + + +QString tst_qqmlimageprovider::newImageFileName() const +{ + // need to generate new filenames each time or else images are loaded + // from cache and we won't get loading status changes when testing + // async loading + static int count = 0; + return QString("image://test/image-%1.png").arg(count++); +} + +void tst_qqmlimageprovider::fillRequestTestsData(const QString &id) +{ + QTest::addColumn("source"); + QTest::addColumn("imageId"); + QTest::addColumn("properties"); + QTest::addColumn("size"); + QTest::addColumn("error"); + + QString fileName = newImageFileName(); + QTest::newRow(QTest::toString(id + " simple test")) + << "image://test/" + fileName << fileName << "" << QSize(100,100) << ""; + + fileName = newImageFileName(); + QTest::newRow(QTest::toString(id + " simple test with capitalization"))//As it's a URL, should make no difference + << "image://Test/" + fileName << fileName << "" << QSize(100,100) << ""; + + fileName = newImageFileName(); + QTest::newRow(QTest::toString(id + " url with no id")) + << "image://test/" + fileName << "" + fileName << "" << QSize(100,100) << ""; + + fileName = newImageFileName(); + QTest::newRow(QTest::toString(id + " url with path")) + << "image://test/test/path" + fileName << "test/path" + fileName << "" << QSize(100,100) << ""; + + fileName = newImageFileName(); + QTest::newRow(QTest::toString(id + " url with fragment")) + << "image://test/faq.html?#question13" + fileName << "faq.html?#question13" + fileName << "" << QSize(100,100) << ""; + + fileName = newImageFileName(); + QTest::newRow(QTest::toString(id + " url with query")) + << "image://test/cgi-bin/drawgraph.cgi?type=pie&color=green" + fileName << "cgi-bin/drawgraph.cgi?type=pie&color=green" + fileName + << "" << QSize(100,100) << ""; + + fileName = newImageFileName(); + QTest::newRow(QTest::toString(id + " scaled image")) + << "image://test/" + fileName << fileName << "sourceSize: \"80x30\"" << QSize(80,30) << ""; + + QTest::newRow(QTest::toString(id + " missing")) + << "image://test/no-such-file.png" << "no-such-file.png" << "" << QSize(100,100) + << "file::2:1: QML Image: Failed to get image from provider: image://test/no-such-file.png"; + + QTest::newRow(QTest::toString(id + " unknown provider")) + << "image://bogus/exists.png" << "" << "" << QSize() + << "file::2:1: QML Image: Invalid image provider: image://bogus/exists.png"; +} + +void tst_qqmlimageprovider::runTest(bool async, QQmlImageProvider *provider) +{ + QFETCH(QString, source); + QFETCH(QString, imageId); + QFETCH(QString, properties); + QFETCH(QSize, size); + QFETCH(QString, error); + + if (!error.isEmpty()) + QTest::ignoreMessage(QtWarningMsg, error.toUtf8()); + + QQmlEngine engine; + + engine.addImageProvider("test", provider); + QVERIFY(engine.imageProvider("test") != 0); + + QString componentStr = "import QtQuick 2.0\nImage { source: \"" + source + "\"; " + + (async ? "asynchronous: true; " : "") + + properties + " }"; + QQmlComponent component(&engine); + component.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); + QQuickImage *obj = qobject_cast(component.create()); + QVERIFY(obj != 0); + + if (async) + QTRY_VERIFY(obj->status() == QQuickImage::Loading); + + QCOMPARE(obj->source(), QUrl(source)); + + if (error.isEmpty()) { + if (async) + QTRY_VERIFY(obj->status() == QQuickImage::Ready); + else + QVERIFY(obj->status() == QQuickImage::Ready); + if (QByteArray(QTest::currentDataTag()).startsWith("qimage")) + QCOMPARE(static_cast(provider)->lastImageId, imageId); + else + QCOMPARE(static_cast(provider)->lastImageId, imageId); + + QCOMPARE(obj->width(), qreal(size.width())); + QCOMPARE(obj->height(), qreal(size.height())); + QCOMPARE(obj->fillMode(), QQuickImage::Stretch); + QCOMPARE(obj->progress(), 1.0); + } else { + if (async) + QTRY_VERIFY(obj->status() == QQuickImage::Error); + else + QVERIFY(obj->status() == QQuickImage::Error); + } + + delete obj; +} + +void tst_qqmlimageprovider::requestImage_sync_data() +{ + fillRequestTestsData("qimage|sync"); +} + +void tst_qqmlimageprovider::requestImage_sync() +{ + bool deleteWatch = false; + runTest(false, new TestQImageProvider(&deleteWatch)); + QVERIFY(deleteWatch); +} + +void tst_qqmlimageprovider::requestImage_async_data() +{ + fillRequestTestsData("qimage|async"); +} + +void tst_qqmlimageprovider::requestImage_async() +{ + bool deleteWatch = false; + runTest(true, new TestQImageProvider(&deleteWatch)); + QVERIFY(deleteWatch); +} + +void tst_qqmlimageprovider::requestPixmap_sync_data() +{ + fillRequestTestsData("qpixmap"); +} + +void tst_qqmlimageprovider::requestPixmap_sync() +{ + bool deleteWatch = false; + runTest(false, new TestQPixmapProvider(&deleteWatch)); + QVERIFY(deleteWatch); +} + +void tst_qqmlimageprovider::requestPixmap_async() +{ + QQmlEngine engine; + QQmlImageProvider *provider = new TestQPixmapProvider(); + + engine.addImageProvider("test", provider); + QVERIFY(engine.imageProvider("test") != 0); + + // pixmaps are loaded synchronously regardless of 'asynchronous' value + QString componentStr = "import QtQuick 2.0\nImage { asynchronous: true; source: \"image://test/pixmap-async-test.png\" }"; + QQmlComponent component(&engine); + component.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); + QQuickImage *obj = qobject_cast(component.create()); + QVERIFY(obj != 0); + + delete obj; +} + +void tst_qqmlimageprovider::removeProvider_data() +{ + QTest::addColumn("provider"); + + QTest::newRow("qimage") << static_cast(new TestQImageProvider); + QTest::newRow("qpixmap") << static_cast(new TestQPixmapProvider); +} + +void tst_qqmlimageprovider::removeProvider() +{ + QFETCH(QQmlImageProvider*, provider); + + QQmlEngine engine; + + engine.addImageProvider("test", provider); + QVERIFY(engine.imageProvider("test") != 0); + + // add provider, confirm it works + QString componentStr = "import QtQuick 2.0\nImage { source: \"" + newImageFileName() + "\" }"; + QQmlComponent component(&engine); + component.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); + QQuickImage *obj = qobject_cast(component.create()); + QVERIFY(obj != 0); + + QCOMPARE(obj->status(), QQuickImage::Ready); + + // remove the provider and confirm + QString fileName = newImageFileName(); + QString error("file::2:1: QML Image: Invalid image provider: " + fileName); + QTest::ignoreMessage(QtWarningMsg, error.toUtf8()); + + engine.removeImageProvider("test"); + + obj->setSource(QUrl(fileName)); + QCOMPARE(obj->status(), QQuickImage::Error); + + delete obj; +} + +class TestThreadProvider : public QQmlImageProvider +{ + public: + TestThreadProvider() : QQmlImageProvider(Image), ok(false) {} + + ~TestThreadProvider() {} + + QImage requestImage(const QString &id, QSize *size, const QSize& requestedSize) + { + mutex.lock(); + if (!ok) + cond.wait(&mutex); + mutex.unlock(); + QVector v; + for (int i = 0; i < 10000; i++) + v.prepend(i); //do some computation + QImage image(50,50, QImage::Format_RGB32); + image.fill(QColor(id).rgb()); + if (size) + *size = image.size(); + if (requestedSize.isValid()) + image = image.scaled(requestedSize); + return image; + } + + QWaitCondition cond; + QMutex mutex; + bool ok; +}; + + +void tst_qqmlimageprovider::threadTest() +{ + QQmlEngine engine; + + TestThreadProvider *provider = new TestThreadProvider; + + engine.addImageProvider("test_thread", provider); + QVERIFY(engine.imageProvider("test_thread") != 0); + + QString componentStr = "import QtQuick 2.0\nItem { \n" + "Image { source: \"image://test_thread/blue\"; asynchronous: true; }\n" + "Image { source: \"image://test_thread/red\"; asynchronous: true; }\n" + "Image { source: \"image://test_thread/green\"; asynchronous: true; }\n" + "Image { source: \"image://test_thread/yellow\"; asynchronous: true; }\n" + " }"; + QQmlComponent component(&engine); + component.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); + QObject *obj = component.create(); + //MUST not deadlock + QVERIFY(obj != 0); + QList images = obj->findChildren(); + QCOMPARE(images.count(), 4); + QTest::qWait(100); + foreach (QQuickImage *img, images) { + QCOMPARE(img->status(), QQuickImage::Loading); + } + provider->ok = true; + provider->cond.wakeAll(); + QTest::qWait(250); + foreach (QQuickImage *img, images) { + QTRY_VERIFY(img->status() == QQuickImage::Ready); + } +} + + +QTEST_MAIN(tst_qqmlimageprovider) + +#include "tst_qqmlimageprovider.moc" diff --git a/tests/auto/qml/qqmlincubator/data/AsynchronousIfNestedType.qml b/tests/auto/qml/qqmlincubator/data/AsynchronousIfNestedType.qml new file mode 100644 index 0000000000..8a3f46ee72 --- /dev/null +++ b/tests/auto/qml/qqmlincubator/data/AsynchronousIfNestedType.qml @@ -0,0 +1,7 @@ +import Qt.test 1.0 + +SelfRegistering { + property int dummy1: 11 + property int dummy2: 19 +} + diff --git a/tests/auto/qml/qqmlincubator/data/asynchronousIfNested.1.qml b/tests/auto/qml/qqmlincubator/data/asynchronousIfNested.1.qml new file mode 100644 index 0000000000..18ff4aabb7 --- /dev/null +++ b/tests/auto/qml/qqmlincubator/data/asynchronousIfNested.1.qml @@ -0,0 +1,5 @@ +import QtQuick 2.0 + +QtObject { + property int a: 10 +} diff --git a/tests/auto/qml/qqmlincubator/data/asynchronousIfNested.2.qml b/tests/auto/qml/qqmlincubator/data/asynchronousIfNested.2.qml new file mode 100644 index 0000000000..3f6cd932de --- /dev/null +++ b/tests/auto/qml/qqmlincubator/data/asynchronousIfNested.2.qml @@ -0,0 +1,6 @@ +import QtQuick 2.0 + +QtObject { + property QtObject o: AsynchronousIfNestedType { } + property int dummy: 11 +} diff --git a/tests/auto/qml/qqmlincubator/data/asynchronousIfNested.3.qml b/tests/auto/qml/qqmlincubator/data/asynchronousIfNested.3.qml new file mode 100644 index 0000000000..7e5ee7cf5c --- /dev/null +++ b/tests/auto/qml/qqmlincubator/data/asynchronousIfNested.3.qml @@ -0,0 +1,5 @@ +import Qt.test 1.0 + +CallbackRegistering { + value: 19 +} diff --git a/tests/auto/qml/qqmlincubator/data/chainInCompletion.qml b/tests/auto/qml/qqmlincubator/data/chainInCompletion.qml new file mode 100644 index 0000000000..e79fed356a --- /dev/null +++ b/tests/auto/qml/qqmlincubator/data/chainInCompletion.qml @@ -0,0 +1,5 @@ +import Qt.test 1.0 + +SelfRegistering { + property variant a: CompletionCallback {} +} diff --git a/tests/auto/qml/qqmlincubator/data/chainedAsynchronousIfNested.qml b/tests/auto/qml/qqmlincubator/data/chainedAsynchronousIfNested.qml new file mode 100644 index 0000000000..1300426cfa --- /dev/null +++ b/tests/auto/qml/qqmlincubator/data/chainedAsynchronousIfNested.qml @@ -0,0 +1,5 @@ +import Qt.test 1.0 + +SelfRegistering { + property int dummy: 10 +} diff --git a/tests/auto/qml/qqmlincubator/data/clear.qml b/tests/auto/qml/qqmlincubator/data/clear.qml new file mode 100644 index 0000000000..f00f975923 --- /dev/null +++ b/tests/auto/qml/qqmlincubator/data/clear.qml @@ -0,0 +1,8 @@ +import QtQuick 2.0 +import Qt.test 1.0 + +Item { + SelfRegistering { + value: 11 + } +} diff --git a/tests/auto/qml/qqmlincubator/data/clearDuringCompletion.qml b/tests/auto/qml/qqmlincubator/data/clearDuringCompletion.qml new file mode 100644 index 0000000000..556f460d58 --- /dev/null +++ b/tests/auto/qml/qqmlincubator/data/clearDuringCompletion.qml @@ -0,0 +1,6 @@ +import Qt.test 1.0 + +SelfRegistering { + property variant a: CompletionRegistering {} + property variant b: CompletionRegistering {} +} diff --git a/tests/auto/qml/qqmlincubator/data/contextDelete.qml b/tests/auto/qml/qqmlincubator/data/contextDelete.qml new file mode 100644 index 0000000000..c3952074f1 --- /dev/null +++ b/tests/auto/qml/qqmlincubator/data/contextDelete.qml @@ -0,0 +1,5 @@ +import QtQuick 2.0 + +QtObject { + property int dummy: 12 +} diff --git a/tests/auto/qml/qqmlincubator/data/forceCompletion.qml b/tests/auto/qml/qqmlincubator/data/forceCompletion.qml new file mode 100644 index 0000000000..9b76701c1b --- /dev/null +++ b/tests/auto/qml/qqmlincubator/data/forceCompletion.qml @@ -0,0 +1,9 @@ +import QtQuick 2.0 +import Qt.test 1.0 + +Item { + property int testValue: 3499 + SelfRegistering { + property int testValue2: 19 + } +} diff --git a/tests/auto/qml/qqmlincubator/data/nestedComponent.js b/tests/auto/qml/qqmlincubator/data/nestedComponent.js new file mode 100644 index 0000000000..4b6b0bde43 --- /dev/null +++ b/tests/auto/qml/qqmlincubator/data/nestedComponent.js @@ -0,0 +1 @@ +var value = 19988 diff --git a/tests/auto/qml/qqmlincubator/data/nestedComponent.qml b/tests/auto/qml/qqmlincubator/data/nestedComponent.qml new file mode 100644 index 0000000000..dd20707456 --- /dev/null +++ b/tests/auto/qml/qqmlincubator/data/nestedComponent.qml @@ -0,0 +1,10 @@ +import QtQuick 2.0 +import "nestedComponent.js" as NestedJS + +QtObject { + property Component c: Component { + QtObject { + property int value: NestedJS.value + } + } +} diff --git a/tests/auto/qml/qqmlincubator/data/noIncubationController.qml b/tests/auto/qml/qqmlincubator/data/noIncubationController.qml new file mode 100644 index 0000000000..7d93e856f0 --- /dev/null +++ b/tests/auto/qml/qqmlincubator/data/noIncubationController.qml @@ -0,0 +1,5 @@ +import QtQuick 2.0 + +QtObject { + property int testValue: 1913 +} diff --git a/tests/auto/qml/qqmlincubator/data/objectDeleted.errors.txt b/tests/auto/qml/qqmlincubator/data/objectDeleted.errors.txt new file mode 100644 index 0000000000..eeda289d35 --- /dev/null +++ b/tests/auto/qml/qqmlincubator/data/objectDeleted.errors.txt @@ -0,0 +1 @@ +-1:-1:Object destroyed during incubation diff --git a/tests/auto/qml/qqmlincubator/data/objectDeleted.qml b/tests/auto/qml/qqmlincubator/data/objectDeleted.qml new file mode 100644 index 0000000000..f00f975923 --- /dev/null +++ b/tests/auto/qml/qqmlincubator/data/objectDeleted.qml @@ -0,0 +1,8 @@ +import QtQuick 2.0 +import Qt.test 1.0 + +Item { + SelfRegistering { + value: 11 + } +} diff --git a/tests/auto/qml/qqmlincubator/data/recursiveClear.1.qml b/tests/auto/qml/qqmlincubator/data/recursiveClear.1.qml new file mode 100644 index 0000000000..748a3f0cbf --- /dev/null +++ b/tests/auto/qml/qqmlincubator/data/recursiveClear.1.qml @@ -0,0 +1,9 @@ +import QtQuick 2.0 + +Rectangle { + objectName: "switchMe" + signal switchMe + width: 100; height: 100 + color: "green" + Component.onCompleted: switchMe() +} diff --git a/tests/auto/qml/qqmlincubator/data/recursiveClear.2.qml b/tests/auto/qml/qqmlincubator/data/recursiveClear.2.qml new file mode 100644 index 0000000000..e96ac00f21 --- /dev/null +++ b/tests/auto/qml/qqmlincubator/data/recursiveClear.2.qml @@ -0,0 +1,8 @@ +import QtQuick 2.0 + +Rectangle { + objectName: "blue" + width: 100 + height: 100 + color: "blue" +} diff --git a/tests/auto/qml/qqmlincubator/data/selfDelete.qml b/tests/auto/qml/qqmlincubator/data/selfDelete.qml new file mode 100644 index 0000000000..c3952074f1 --- /dev/null +++ b/tests/auto/qml/qqmlincubator/data/selfDelete.qml @@ -0,0 +1,5 @@ +import QtQuick 2.0 + +QtObject { + property int dummy: 12 +} diff --git a/tests/auto/qml/qqmlincubator/data/setInitialState.qml b/tests/auto/qml/qqmlincubator/data/setInitialState.qml new file mode 100644 index 0000000000..0fd61abfd2 --- /dev/null +++ b/tests/auto/qml/qqmlincubator/data/setInitialState.qml @@ -0,0 +1,17 @@ +import QtQuick 2.0 + +QtObject { + property int test1: (testData1 * 32 + 99) / testData2 + property int test2: myValueFunction() + + property bool myValueFunctionCalled: false + + property int testData1: 19 + property int testData2: 13 + + function myValueFunction() { + myValueFunctionCalled = true; + return 13; + } +} + diff --git a/tests/auto/qml/qqmlincubator/data/statusChanged.nested.qml b/tests/auto/qml/qqmlincubator/data/statusChanged.nested.qml new file mode 100644 index 0000000000..3a496ea6fe --- /dev/null +++ b/tests/auto/qml/qqmlincubator/data/statusChanged.nested.qml @@ -0,0 +1,12 @@ +import QtQuick 2.0 + +QtObject { + id: root + + property bool test: false + + Component.onCompleted: { + var c = Qt.createComponent("statusChanged.qml"); + c.incubateObject(root, null, Qt.Synchronous); + } +} diff --git a/tests/auto/qml/qqmlincubator/data/statusChanged.qml b/tests/auto/qml/qqmlincubator/data/statusChanged.qml new file mode 100644 index 0000000000..18ff4aabb7 --- /dev/null +++ b/tests/auto/qml/qqmlincubator/data/statusChanged.qml @@ -0,0 +1,5 @@ +import QtQuick 2.0 + +QtObject { + property int a: 10 +} diff --git a/tests/auto/qml/qqmlincubator/qqmlincubator.pro b/tests/auto/qml/qqmlincubator/qqmlincubator.pro new file mode 100644 index 0000000000..956d72402c --- /dev/null +++ b/tests/auto/qml/qqmlincubator/qqmlincubator.pro @@ -0,0 +1,18 @@ +CONFIG += testcase +TARGET = tst_qqmlincubator +macx:CONFIG -= app_bundle + +SOURCES += tst_qqmlincubator.cpp \ + testtypes.cpp + +HEADERS += testtypes.h + +include (../../shared/util.pri) + +testDataFiles.files = data +testDataFiles.path = . +DEPLOYMENT += testDataFiles + +CONFIG += parallel_test + +QT += core-private gui-private v8-private qml-private network widgets testlib diff --git a/tests/auto/qml/qqmlincubator/testtypes.cpp b/tests/auto/qml/qqmlincubator/testtypes.cpp new file mode 100644 index 0000000000..7936fc146c --- /dev/null +++ b/tests/auto/qml/qqmlincubator/testtypes.cpp @@ -0,0 +1,137 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include "testtypes.h" +#include + +SelfRegisteringType *SelfRegisteringType::m_me = 0; +SelfRegisteringType::SelfRegisteringType() +: m_v(0) +{ + m_me = this; +} + +SelfRegisteringType *SelfRegisteringType::me() +{ + return m_me; +} + +void SelfRegisteringType::clearMe() +{ + m_me = 0; +} + +CompletionRegisteringType *CompletionRegisteringType::m_me = 0; +CompletionRegisteringType::CompletionRegisteringType() +{ +} + +void CompletionRegisteringType::classBegin() +{ +} + +void CompletionRegisteringType::componentComplete() +{ + m_me = this; +} + +CompletionRegisteringType *CompletionRegisteringType::me() +{ + return m_me; +} + +void CompletionRegisteringType::clearMe() +{ + m_me = 0; +} + +CallbackRegisteringType::callback CallbackRegisteringType::m_callback = 0; +void *CallbackRegisteringType::m_data = 0; +CallbackRegisteringType::CallbackRegisteringType() +: m_v(0) +{ +} + +void CallbackRegisteringType::clearCallback() +{ + m_callback = 0; + m_data = 0; +} + +void CallbackRegisteringType::registerCallback(callback c, void *d) +{ + m_callback = c; + m_data = d; +} + +CompletionCallbackType::callback CompletionCallbackType::m_callback = 0; +void *CompletionCallbackType::m_data = 0; +CompletionCallbackType::CompletionCallbackType() +{ +} + +void CompletionCallbackType::classBegin() +{ +} + +void CompletionCallbackType::componentComplete() +{ + if (m_callback) m_callback(this, m_data); +} + +void CompletionCallbackType::clearCallback() +{ + m_callback = 0; + m_data = 0; +} + +void CompletionCallbackType::registerCallback(callback c, void *d) +{ + m_callback = c; + m_data = d; +} + +void registerTypes() +{ + qmlRegisterType("Qt.test", 1,0, "SelfRegistering"); + qmlRegisterType("Qt.test", 1,0, "CompletionRegistering"); + qmlRegisterType("Qt.test", 1,0, "CallbackRegistering"); + qmlRegisterType("Qt.test", 1,0, "CompletionCallback"); +} diff --git a/tests/auto/qml/qqmlincubator/testtypes.h b/tests/auto/qml/qqmlincubator/testtypes.h new file mode 100644 index 0000000000..8ca7ee34ee --- /dev/null +++ b/tests/auto/qml/qqmlincubator/testtypes.h @@ -0,0 +1,125 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#ifndef TESTTYPES_H +#define TESTTYPES_H + +#include +#include + +class SelfRegisteringType : public QObject +{ +Q_OBJECT +Q_PROPERTY(int value READ value WRITE setValue); +public: + SelfRegisteringType(); + + int value() const { return m_v; } + void setValue(int v) { m_v = v; } + + static SelfRegisteringType *me(); + static void clearMe(); + +private: + static SelfRegisteringType *m_me; + + int m_v; +}; + +class CallbackRegisteringType : public QObject +{ +Q_OBJECT +Q_PROPERTY(int value READ value WRITE setValue) +public: + CallbackRegisteringType(); + + int value() const { return m_v; } + void setValue(int v) { if (m_callback) m_callback(this, m_data); m_v = v; } + + typedef void (*callback)(CallbackRegisteringType *, void *); + static void clearCallback(); + static void registerCallback(callback, void *); + +private: + static callback m_callback; + static void *m_data; + + int m_v; +}; + +class CompletionRegisteringType : public QObject, public QQmlParserStatus +{ + Q_OBJECT + Q_INTERFACES(QQmlParserStatus) +public: + CompletionRegisteringType(); + + virtual void classBegin(); + virtual void componentComplete(); + + static CompletionRegisteringType *me(); + static void clearMe(); + +private: + static CompletionRegisteringType *m_me; +}; + +class CompletionCallbackType : public QObject, public QQmlParserStatus +{ + Q_OBJECT + Q_INTERFACES(QQmlParserStatus) +public: + CompletionCallbackType(); + + virtual void classBegin(); + virtual void componentComplete(); + + typedef void (*callback)(CompletionCallbackType *, void *); + static void clearCallback(); + static void registerCallback(callback, void *); + +private: + static callback m_callback; + static void *m_data; +}; + +void registerTypes(); + +#endif // TESTTYPES_H diff --git a/tests/auto/qml/qqmlincubator/tst_qqmlincubator.cpp b/tests/auto/qml/qqmlincubator/tst_qqmlincubator.cpp new file mode 100644 index 0000000000..fc54f715c9 --- /dev/null +++ b/tests/auto/qml/qqmlincubator/tst_qqmlincubator.cpp @@ -0,0 +1,1030 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include "testtypes.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "../../shared/util.h" + +class tst_qqmlincubator : public QQmlDataTest +{ + Q_OBJECT +public: + tst_qqmlincubator() {} + +private slots: + void initTestCase(); + + void incubationMode(); + void objectDeleted(); + void clear(); + void noIncubationController(); + void forceCompletion(); + void setInitialState(); + void clearDuringCompletion(); + void objectDeletionAfterInit(); + void recursiveClear(); + void statusChanged(); + void asynchronousIfNested(); + void nestedComponent(); + void chainedAsynchronousIfNested(); + void chainedAsynchronousIfNestedOnCompleted(); + void selfDelete(); + void contextDelete(); + +private: + QQmlIncubationController controller; + QQmlEngine engine; +}; + +#define VERIFY_ERRORS(component, errorfile) \ + if (!errorfile) { \ + if (qgetenv("DEBUG") != "" && !component.errors().isEmpty()) \ + qWarning() << "Unexpected Errors:" << component.errors(); \ + QVERIFY(!component.isError()); \ + QVERIFY(component.errors().isEmpty()); \ + } else { \ + QFile file(QQmlDataTest::instance()->testFile(errorfile)); \ + QVERIFY(file.open(QIODevice::ReadOnly | QIODevice::Text)); \ + QByteArray data = file.readAll(); \ + file.close(); \ + QList expected = data.split('\n'); \ + expected.removeAll(QByteArray("")); \ + QList errors = component.errors(); \ + QList actual; \ + for (int ii = 0; ii < errors.count(); ++ii) { \ + const QQmlError &error = errors.at(ii); \ + QByteArray errorStr = QByteArray::number(error.line()) + ":" + \ + QByteArray::number(error.column()) + ":" + \ + error.description().toUtf8(); \ + actual << errorStr; \ + } \ + if (qgetenv("DEBUG") != "" && expected != actual) \ + qWarning() << "Expected:" << expected << "Actual:" << actual; \ + QCOMPARE(expected, actual); \ + } + +void tst_qqmlincubator::initTestCase() +{ + QQmlDataTest::initTestCase(); + registerTypes(); + engine.setIncubationController(&controller); +} + +void tst_qqmlincubator::incubationMode() +{ + { + QQmlIncubator incubator; + QCOMPARE(incubator.incubationMode(), QQmlIncubator::Asynchronous); + } + { + QQmlIncubator incubator(QQmlIncubator::Asynchronous); + QCOMPARE(incubator.incubationMode(), QQmlIncubator::Asynchronous); + } + { + QQmlIncubator incubator(QQmlIncubator::Synchronous); + QCOMPARE(incubator.incubationMode(), QQmlIncubator::Synchronous); + } + { + QQmlIncubator incubator(QQmlIncubator::AsynchronousIfNested); + QCOMPARE(incubator.incubationMode(), QQmlIncubator::AsynchronousIfNested); + } +} + +void tst_qqmlincubator::objectDeleted() +{ + SelfRegisteringType::clearMe(); + + QQmlComponent component(&engine, testFileUrl("objectDeleted.qml")); + QVERIFY(component.isReady()); + + QQmlIncubator incubator; + component.create(incubator); + + QCOMPARE(incubator.status(), QQmlIncubator::Loading); + QVERIFY(SelfRegisteringType::me() == 0); + + while (SelfRegisteringType::me() == 0 && incubator.isLoading()) { + bool b = false; + controller.incubateWhile(&b); + } + + QVERIFY(SelfRegisteringType::me() != 0); + QVERIFY(incubator.isLoading()); + + delete SelfRegisteringType::me(); + + { + bool b = true; + controller.incubateWhile(&b); + } + + QVERIFY(incubator.isError()); + VERIFY_ERRORS(incubator, "objectDeleted.errors.txt"); + QVERIFY(incubator.object() == 0); +} + +void tst_qqmlincubator::clear() +{ + SelfRegisteringType::clearMe(); + + QQmlComponent component(&engine, testFileUrl("clear.qml")); + QVERIFY(component.isReady()); + + // Clear in null state + { + QQmlIncubator incubator; + QVERIFY(incubator.isNull()); + incubator.clear(); // no effect + QVERIFY(incubator.isNull()); + } + + // Clear in loading state + { + QQmlIncubator incubator; + component.create(incubator); + QVERIFY(incubator.isLoading()); + incubator.clear(); + QVERIFY(incubator.isNull()); + } + + // Clear mid load + { + QQmlIncubator incubator; + component.create(incubator); + + while (SelfRegisteringType::me() == 0 && incubator.isLoading()) { + bool b = false; + controller.incubateWhile(&b); + } + + QVERIFY(incubator.isLoading()); + QVERIFY(SelfRegisteringType::me() != 0); + QPointer srt = SelfRegisteringType::me(); + + incubator.clear(); + QVERIFY(incubator.isNull()); + QVERIFY(srt.isNull()); + } + + // Clear in ready state + { + QQmlIncubator incubator; + component.create(incubator); + + { + bool b = true; + controller.incubateWhile(&b); + } + + QVERIFY(incubator.isReady()); + QVERIFY(incubator.object() != 0); + QPointer obj = incubator.object(); + + incubator.clear(); + QVERIFY(incubator.isNull()); + QVERIFY(incubator.object() == 0); + QVERIFY(!obj.isNull()); + + delete obj; + QVERIFY(obj.isNull()); + } +} + +void tst_qqmlincubator::noIncubationController() +{ + // All incubators should behave synchronously when there is no controller + + QQmlEngine engine; + QQmlComponent component(&engine, testFileUrl("noIncubationController.qml")); + + QVERIFY(component.isReady()); + + { + QQmlIncubator incubator(QQmlIncubator::Asynchronous); + component.create(incubator); + QVERIFY(incubator.isReady()); + QVERIFY(incubator.object()); + QCOMPARE(incubator.object()->property("testValue").toInt(), 1913); + delete incubator.object(); + } + + { + QQmlIncubator incubator(QQmlIncubator::AsynchronousIfNested); + component.create(incubator); + QVERIFY(incubator.isReady()); + QVERIFY(incubator.object()); + QCOMPARE(incubator.object()->property("testValue").toInt(), 1913); + delete incubator.object(); + } + + { + QQmlIncubator incubator(QQmlIncubator::Synchronous); + component.create(incubator); + QVERIFY(incubator.isReady()); + QVERIFY(incubator.object()); + QCOMPARE(incubator.object()->property("testValue").toInt(), 1913); + delete incubator.object(); + } +} + +void tst_qqmlincubator::forceCompletion() +{ + QQmlComponent component(&engine, testFileUrl("forceCompletion.qml")); + QVERIFY(component.isReady()); + + { + // forceCompletion on a null incubator does nothing + QQmlIncubator incubator; + QVERIFY(incubator.isNull()); + incubator.forceCompletion(); + QVERIFY(incubator.isNull()); + } + + { + // forceCompletion immediately after creating an asynchronous object completes it + QQmlIncubator incubator; + QVERIFY(incubator.isNull()); + component.create(incubator); + QVERIFY(incubator.isLoading()); + + incubator.forceCompletion(); + + QVERIFY(incubator.isReady()); + QVERIFY(incubator.object() != 0); + QCOMPARE(incubator.object()->property("testValue").toInt(), 3499); + + delete incubator.object(); + } + + { + // forceCompletion during creation completes it + SelfRegisteringType::clearMe(); + + QQmlIncubator incubator; + QVERIFY(incubator.isNull()); + component.create(incubator); + QVERIFY(incubator.isLoading()); + + while (SelfRegisteringType::me() == 0 && incubator.isLoading()) { + bool b = false; + controller.incubateWhile(&b); + } + + QVERIFY(SelfRegisteringType::me() != 0); + QVERIFY(incubator.isLoading()); + + incubator.forceCompletion(); + + QVERIFY(incubator.isReady()); + QVERIFY(incubator.object() != 0); + QCOMPARE(incubator.object()->property("testValue").toInt(), 3499); + + delete incubator.object(); + } + + { + // forceCompletion on a ready incubator has no effect + QQmlIncubator incubator; + QVERIFY(incubator.isNull()); + component.create(incubator); + QVERIFY(incubator.isLoading()); + + incubator.forceCompletion(); + + QVERIFY(incubator.isReady()); + QVERIFY(incubator.object() != 0); + QCOMPARE(incubator.object()->property("testValue").toInt(), 3499); + + incubator.forceCompletion(); + + QVERIFY(incubator.isReady()); + QVERIFY(incubator.object() != 0); + QCOMPARE(incubator.object()->property("testValue").toInt(), 3499); + + delete incubator.object(); + } +} + +void tst_qqmlincubator::setInitialState() +{ + QQmlComponent component(&engine, testFileUrl("setInitialState.qml")); + QVERIFY(component.isReady()); + + struct MyIncubator : public QQmlIncubator + { + MyIncubator(QQmlIncubator::IncubationMode mode) + : QQmlIncubator(mode) {} + + virtual void setInitialState(QObject *o) { + QQmlProperty::write(o, "test2", 19); + QQmlProperty::write(o, "testData1", 201); + } + }; + + { + MyIncubator incubator(QQmlIncubator::Asynchronous); + component.create(incubator); + QVERIFY(incubator.isLoading()); + bool b = true; + controller.incubateWhile(&b); + QVERIFY(incubator.isReady()); + QVERIFY(incubator.object()); + QCOMPARE(incubator.object()->property("myValueFunctionCalled").toBool(), false); + QCOMPARE(incubator.object()->property("test1").toInt(), 502); + QCOMPARE(incubator.object()->property("test2").toInt(), 19); + delete incubator.object(); + } + + { + MyIncubator incubator(QQmlIncubator::Synchronous); + component.create(incubator); + QVERIFY(incubator.isReady()); + QVERIFY(incubator.object()); + QCOMPARE(incubator.object()->property("myValueFunctionCalled").toBool(), false); + QCOMPARE(incubator.object()->property("test1").toInt(), 502); + QCOMPARE(incubator.object()->property("test2").toInt(), 19); + delete incubator.object(); + } +} + +void tst_qqmlincubator::clearDuringCompletion() +{ + CompletionRegisteringType::clearMe(); + SelfRegisteringType::clearMe(); + + QQmlComponent component(&engine, testFileUrl("clearDuringCompletion.qml")); + QVERIFY(component.isReady()); + + QQmlIncubator incubator; + component.create(incubator); + + QCOMPARE(incubator.status(), QQmlIncubator::Loading); + QVERIFY(CompletionRegisteringType::me() == 0); + + while (CompletionRegisteringType::me() == 0 && incubator.isLoading()) { + bool b = false; + controller.incubateWhile(&b); + } + + QVERIFY(CompletionRegisteringType::me() != 0); + QVERIFY(SelfRegisteringType::me() != 0); + QVERIFY(incubator.isLoading()); + + QPointer srt = SelfRegisteringType::me(); + + incubator.clear(); + QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete); + QCoreApplication::processEvents(); + QVERIFY(incubator.isNull()); + QVERIFY(srt.isNull()); +} + +void tst_qqmlincubator::objectDeletionAfterInit() +{ + QQmlComponent component(&engine, testFileUrl("clear.qml")); + QVERIFY(component.isReady()); + + struct MyIncubator : public QQmlIncubator + { + MyIncubator(QQmlIncubator::IncubationMode mode) + : QQmlIncubator(mode), obj(0) {} + + virtual void setInitialState(QObject *o) { + obj = o; + } + + QObject *obj; + }; + + SelfRegisteringType::clearMe(); + MyIncubator incubator(QQmlIncubator::Asynchronous); + component.create(incubator); + + while (!incubator.obj && incubator.isLoading()) { + bool b = false; + controller.incubateWhile(&b); + } + + QVERIFY(incubator.isLoading()); + QVERIFY(SelfRegisteringType::me() != 0); + + delete incubator.obj; + + incubator.clear(); + QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete); + QCoreApplication::processEvents(); + QVERIFY(incubator.isNull()); +} + +class Switcher : public QObject +{ + Q_OBJECT +public: + Switcher(QQmlEngine *e) : QObject(), engine(e) { } + + struct MyIncubator : public QQmlIncubator + { + MyIncubator(QQmlIncubator::IncubationMode mode, QObject *s) + : QQmlIncubator(mode), switcher(s) {} + + virtual void setInitialState(QObject *o) { + if (o->objectName() == "switchMe") + connect(o, SIGNAL(switchMe()), switcher, SLOT(switchIt())); + } + + QObject *switcher; + }; + + void start() + { + incubator = new MyIncubator(QQmlIncubator::Synchronous, this); + component = new QQmlComponent(engine, QQmlDataTest::instance()->testFileUrl("recursiveClear.1.qml")); + component->create(*incubator); + } + + QQmlEngine *engine; + MyIncubator *incubator; + QQmlComponent *component; + +public slots: + void switchIt() { + component->deleteLater(); + incubator->clear(); + component = new QQmlComponent(engine, QQmlDataTest::instance()->testFileUrl("recursiveClear.2.qml")); + component->create(*incubator); + } +}; + +void tst_qqmlincubator::recursiveClear() +{ + Switcher switcher(&engine); + switcher.start(); +} + +void tst_qqmlincubator::statusChanged() +{ + class MyIncubator : public QQmlIncubator + { + public: + MyIncubator(QQmlIncubator::IncubationMode mode = QQmlIncubator::Asynchronous) + : QQmlIncubator(mode) {} + + QList statuses; + protected: + virtual void statusChanged(Status s) { statuses << s; } + virtual void setInitialState(QObject *) { statuses << -1; } + }; + + { + QQmlComponent component(&engine, testFileUrl("statusChanged.qml")); + QVERIFY(component.isReady()); + + MyIncubator incubator(QQmlIncubator::Synchronous); + component.create(incubator); + QVERIFY(incubator.isReady()); + QCOMPARE(incubator.statuses.count(), 3); + QCOMPARE(incubator.statuses.at(0), int(QQmlIncubator::Loading)); + QCOMPARE(incubator.statuses.at(1), -1); + QCOMPARE(incubator.statuses.at(2), int(QQmlIncubator::Ready)); + delete incubator.object(); + } + + { + QQmlComponent component(&engine, testFileUrl("statusChanged.qml")); + QVERIFY(component.isReady()); + + MyIncubator incubator(QQmlIncubator::Asynchronous); + component.create(incubator); + QVERIFY(incubator.isLoading()); + QCOMPARE(incubator.statuses.count(), 1); + QCOMPARE(incubator.statuses.at(0), int(QQmlIncubator::Loading)); + + { + bool b = true; + controller.incubateWhile(&b); + } + + QCOMPARE(incubator.statuses.count(), 3); + QCOMPARE(incubator.statuses.at(0), int(QQmlIncubator::Loading)); + QCOMPARE(incubator.statuses.at(1), -1); + QCOMPARE(incubator.statuses.at(2), int(QQmlIncubator::Ready)); + delete incubator.object(); + } + + { + QQmlComponent component2(&engine, testFileUrl("statusChanged.nested.qml")); + QVERIFY(component2.isReady()); + + MyIncubator incubator(QQmlIncubator::Asynchronous); + component2.create(incubator); + QVERIFY(incubator.isLoading()); + QCOMPARE(incubator.statuses.count(), 1); + QCOMPARE(incubator.statuses.at(0), int(QQmlIncubator::Loading)); + + { + bool b = true; + controller.incubateWhile(&b); + } + + QVERIFY(incubator.isReady()); + QCOMPARE(incubator.statuses.count(), 3); + QCOMPARE(incubator.statuses.at(0), int(QQmlIncubator::Loading)); + QCOMPARE(incubator.statuses.at(1), -1); + QCOMPARE(incubator.statuses.at(2), int(QQmlIncubator::Ready)); + delete incubator.object(); + } +} + +void tst_qqmlincubator::asynchronousIfNested() +{ + // Asynchronous if nested within a finalized context behaves synchronously + { + QQmlComponent component(&engine, testFileUrl("asynchronousIfNested.1.qml")); + QVERIFY(component.isReady()); + + QObject *object = component.create(); + QVERIFY(object != 0); + QCOMPARE(object->property("a").toInt(), 10); + + QQmlIncubator incubator(QQmlIncubator::AsynchronousIfNested); + component.create(incubator, 0, qmlContext(object)); + + QVERIFY(incubator.isReady()); + QVERIFY(incubator.object()); + QCOMPARE(incubator.object()->property("a").toInt(), 10); + delete incubator.object(); + delete object; + } + + // Asynchronous if nested within an executing context behaves asynchronously, but prevents + // the parent from finishing + { + SelfRegisteringType::clearMe(); + + QQmlComponent component(&engine, testFileUrl("asynchronousIfNested.2.qml")); + QVERIFY(component.isReady()); + + QQmlIncubator incubator; + component.create(incubator); + + QVERIFY(incubator.isLoading()); + QVERIFY(SelfRegisteringType::me() == 0); + while (SelfRegisteringType::me() == 0 && incubator.isLoading()) { + bool b = false; + controller.incubateWhile(&b); + } + + QVERIFY(SelfRegisteringType::me() != 0); + QVERIFY(incubator.isLoading()); + + QQmlIncubator nested(QQmlIncubator::AsynchronousIfNested); + component.create(nested, 0, qmlContext(SelfRegisteringType::me())); + QVERIFY(nested.isLoading()); + + while (nested.isLoading()) { + QVERIFY(incubator.isLoading()); + bool b = false; + controller.incubateWhile(&b); + } + + QVERIFY(nested.isReady()); + QVERIFY(incubator.isLoading()); + + { + bool b = true; + controller.incubateWhile(&b); + } + + QVERIFY(nested.isReady()); + QVERIFY(incubator.isReady()); + + delete nested.object(); + delete incubator.object(); + } + + // AsynchronousIfNested within a synchronous AsynchronousIfNested behaves synchronously + { + SelfRegisteringType::clearMe(); + + QQmlComponent component(&engine, testFileUrl("asynchronousIfNested.3.qml")); + QVERIFY(component.isReady()); + + struct CallbackData { + CallbackData(QQmlEngine *e) : engine(e), pass(false) {} + QQmlEngine *engine; + bool pass; + static void callback(CallbackRegisteringType *o, void *data) { + CallbackData *d = (CallbackData *)data; + + QQmlComponent c(d->engine, QQmlDataTest::instance()->testFileUrl("asynchronousIfNested.1.qml")); + if (!c.isReady()) return; + + QQmlIncubator incubator(QQmlIncubator::AsynchronousIfNested); + c.create(incubator, 0, qmlContext(o)); + + if (!incubator.isReady()) return; + + if (incubator.object()->property("a").toInt() != 10) return; + + d->pass = true; + } + }; + + CallbackData cd(&engine); + CallbackRegisteringType::registerCallback(&CallbackData::callback, &cd); + + QQmlIncubator incubator(QQmlIncubator::AsynchronousIfNested); + component.create(incubator); + + QVERIFY(incubator.isReady()); + QCOMPARE(cd.pass, true); + + delete incubator.object(); + } +} + +void tst_qqmlincubator::nestedComponent() +{ + QQmlComponent component(&engine, testFileUrl("nestedComponent.qml")); + QVERIFY(component.isReady()); + + QObject *object = component.create(); + + QQmlComponent *nested = object->property("c").value(); + QVERIFY(nested); + QVERIFY(nested->isReady()); + + // Test without incubator + { + QObject *nestedObject = nested->create(); + QCOMPARE(nestedObject->property("value").toInt(), 19988); + delete nestedObject; + } + + // Test with incubator + { + QQmlIncubator incubator(QQmlIncubator::Synchronous); + nested->create(incubator); + QVERIFY(incubator.isReady()); + QVERIFY(incubator.object()); + QCOMPARE(incubator.object()->property("value").toInt(), 19988); + delete incubator.object(); + } + + delete object; +} + +// Checks that a new AsynchronousIfNested incubator can be correctly started in the +// statusChanged() callback of another. +void tst_qqmlincubator::chainedAsynchronousIfNested() +{ + SelfRegisteringType::clearMe(); + + QQmlComponent component(&engine, testFileUrl("chainedAsynchronousIfNested.qml")); + QVERIFY(component.isReady()); + + QQmlIncubator incubator(QQmlIncubator::Asynchronous); + component.create(incubator); + + QVERIFY(incubator.isLoading()); + QVERIFY(SelfRegisteringType::me() == 0); + + while (SelfRegisteringType::me() == 0 && incubator.isLoading()) { + bool b = false; + controller.incubateWhile(&b); + } + + QVERIFY(SelfRegisteringType::me() != 0); + QVERIFY(incubator.isLoading()); + + struct MyIncubator : public QQmlIncubator { + MyIncubator(MyIncubator *next, QQmlComponent *component, QQmlContext *ctxt) + : QQmlIncubator(AsynchronousIfNested), next(next), component(component), ctxt(ctxt) {} + + protected: + virtual void statusChanged(Status s) { + if (s == Ready && next) + component->create(*next, 0, ctxt); + } + + private: + MyIncubator *next; + QQmlComponent *component; + QQmlContext *ctxt; + }; + + MyIncubator incubator2(0, &component, 0); + MyIncubator incubator1(&incubator2, &component, qmlContext(SelfRegisteringType::me())); + + component.create(incubator1, 0, qmlContext(SelfRegisteringType::me())); + + QVERIFY(incubator.isLoading()); + QVERIFY(incubator1.isLoading()); + QVERIFY(incubator2.isNull()); + + while (incubator1.isLoading()) { + QVERIFY(incubator.isLoading()); + QVERIFY(incubator1.isLoading()); + QVERIFY(incubator2.isNull()); + + bool b = false; + controller.incubateWhile(&b); + } + + QVERIFY(incubator.isLoading()); + QVERIFY(incubator1.isReady()); + QVERIFY(incubator2.isLoading()); + + while (incubator2.isLoading()) { + QVERIFY(incubator.isLoading()); + QVERIFY(incubator1.isReady()); + QVERIFY(incubator2.isLoading()); + + bool b = false; + controller.incubateWhile(&b); + } + + QVERIFY(incubator.isLoading()); + QVERIFY(incubator1.isReady()); + QVERIFY(incubator2.isReady()); + + { + bool b = true; + controller.incubateWhile(&b); + } + + QVERIFY(incubator.isReady()); + QVERIFY(incubator1.isReady()); + QVERIFY(incubator2.isReady()); +} + +// Checks that new AsynchronousIfNested incubators can be correctly chained if started in +// componentCompleted(). +void tst_qqmlincubator::chainedAsynchronousIfNestedOnCompleted() +{ + SelfRegisteringType::clearMe(); + + QQmlComponent component(&engine, testFileUrl("chainInCompletion.qml")); + QVERIFY(component.isReady()); + + QQmlComponent c1(&engine, testFileUrl("chainedAsynchronousIfNested.qml")); + QVERIFY(c1.isReady()); + + struct MyIncubator : public QQmlIncubator { + MyIncubator(MyIncubator *next, QQmlComponent *component, QQmlContext *ctxt) + : QQmlIncubator(AsynchronousIfNested), next(next), component(component), ctxt(ctxt) {} + + protected: + virtual void statusChanged(Status s) { + if (s == Ready && next) { + component->create(*next, 0, ctxt); + } + } + + private: + MyIncubator *next; + QQmlComponent *component; + QQmlContext *ctxt; + }; + + struct CallbackData { + CallbackData(QQmlComponent *c, MyIncubator *i, QQmlContext *ct) + : component(c), incubator(i), ctxt(ct) {} + QQmlComponent *component; + MyIncubator *incubator; + QQmlContext *ctxt; + static void callback(CompletionCallbackType *, void *data) { + CallbackData *d = (CallbackData *)data; + d->component->create(*d->incubator, 0, d->ctxt); + } + }; + + QQmlIncubator incubator(QQmlIncubator::Asynchronous); + component.create(incubator); + + QVERIFY(incubator.isLoading()); + QVERIFY(SelfRegisteringType::me() == 0); + + while (SelfRegisteringType::me() == 0 && incubator.isLoading()) { + bool b = false; + controller.incubateWhile(&b); + } + + QVERIFY(SelfRegisteringType::me() != 0); + QVERIFY(incubator.isLoading()); + + MyIncubator incubator3(0, &c1, qmlContext(SelfRegisteringType::me())); + MyIncubator incubator2(&incubator3, &c1, qmlContext(SelfRegisteringType::me())); + MyIncubator incubator1(&incubator2, &c1, qmlContext(SelfRegisteringType::me())); + + // start incubator1 in componentComplete + CallbackData cd(&c1, &incubator1, qmlContext(SelfRegisteringType::me())); + CompletionCallbackType::registerCallback(&CallbackData::callback, &cd); + + while (!incubator1.isLoading()) { + QVERIFY(incubator.isLoading()); + QVERIFY(incubator2.isNull()); + QVERIFY(incubator3.isNull()); + + bool b = false; + controller.incubateWhile(&b); + } + + QVERIFY(incubator.isLoading()); + QVERIFY(incubator1.isLoading()); + QVERIFY(incubator2.isNull()); + QVERIFY(incubator3.isNull()); + + while (incubator1.isLoading()) { + QVERIFY(incubator.isLoading()); + QVERIFY(incubator1.isLoading()); + QVERIFY(incubator2.isNull()); + QVERIFY(incubator3.isNull()); + + bool b = false; + controller.incubateWhile(&b); + } + + QVERIFY(incubator.isLoading()); + QVERIFY(incubator1.isReady()); + QVERIFY(incubator2.isLoading()); + QVERIFY(incubator3.isNull()); + + while (incubator2.isLoading()) { + QVERIFY(incubator.isLoading()); + QVERIFY(incubator1.isReady()); + QVERIFY(incubator2.isLoading()); + QVERIFY(incubator3.isNull()); + + bool b = false; + controller.incubateWhile(&b); + } + + QVERIFY(incubator.isLoading()); + QVERIFY(incubator1.isReady()); + QVERIFY(incubator2.isReady()); + QVERIFY(incubator3.isLoading()); + + while (incubator3.isLoading()) { + QVERIFY(incubator.isLoading()); + QVERIFY(incubator1.isReady()); + QVERIFY(incubator2.isReady()); + QVERIFY(incubator3.isLoading()); + + bool b = false; + controller.incubateWhile(&b); + } + + { + bool b = true; + controller.incubateWhile(&b); + } + + QVERIFY(incubator.isReady()); + QVERIFY(incubator1.isReady()); + QVERIFY(incubator2.isReady()); + QVERIFY(incubator3.isReady()); +} + +void tst_qqmlincubator::selfDelete() +{ + struct MyIncubator : public QQmlIncubator { + MyIncubator(bool *done, Status status, IncubationMode mode) + : QQmlIncubator(mode), done(done), status(status) {} + + protected: + virtual void statusChanged(Status s) { + if (s == status) { + *done = true; + if (s == Ready) delete object(); + delete this; + } + } + + private: + bool *done; + Status status; + }; + + { + QQmlComponent component(&engine, testFileUrl("selfDelete.qml")); + +#define DELETE_TEST(status, mode) { \ + bool done = false; \ + component.create(*(new MyIncubator(&done, status, mode))); \ + bool True = true; \ + controller.incubateWhile(&True); \ + QVERIFY(done == true); \ + } + + DELETE_TEST(QQmlIncubator::Loading, QQmlIncubator::Synchronous); + DELETE_TEST(QQmlIncubator::Ready, QQmlIncubator::Synchronous); + DELETE_TEST(QQmlIncubator::Loading, QQmlIncubator::Asynchronous); + DELETE_TEST(QQmlIncubator::Ready, QQmlIncubator::Asynchronous); + +#undef DELETE_TEST + } + + // Delete within error status + { + SelfRegisteringType::clearMe(); + + QQmlComponent component(&engine, testFileUrl("objectDeleted.qml")); + QVERIFY(component.isReady()); + + bool done = false; + MyIncubator *incubator = new MyIncubator(&done, QQmlIncubator::Error, + QQmlIncubator::Asynchronous); + component.create(*incubator); + + QCOMPARE(incubator->QQmlIncubator::status(), QQmlIncubator::Loading); + QVERIFY(SelfRegisteringType::me() == 0); + + while (SelfRegisteringType::me() == 0 && incubator->isLoading()) { + bool b = false; + controller.incubateWhile(&b); + } + + QVERIFY(SelfRegisteringType::me() != 0); + QVERIFY(incubator->isLoading()); + + delete SelfRegisteringType::me(); + + { + bool b = true; + controller.incubateWhile(&b); + } + + QVERIFY(done); + } +} + +// Test that QML doesn't crash if the context is deleted prior to the incubator +// first executing. +void tst_qqmlincubator::contextDelete() +{ + QQmlContext *context = new QQmlContext(engine.rootContext()); + QQmlComponent component(&engine, testFileUrl("contextDelete.qml")); + + QQmlIncubator incubator; + component.create(incubator, context); + + delete context; + + { + bool b = false; + controller.incubateWhile(&b); + } +} + +QTEST_MAIN(tst_qqmlincubator) + +#include "tst_qqmlincubator.moc" diff --git a/tests/auto/qml/qqmlinfo/data/NestedComponent.qml b/tests/auto/qml/qqmlinfo/data/NestedComponent.qml new file mode 100644 index 0000000000..cfe47589df --- /dev/null +++ b/tests/auto/qml/qqmlinfo/data/NestedComponent.qml @@ -0,0 +1,23 @@ +import QtQuick 2.0 + +QtObject { + property variant nested + property variant nested2: nested.nested + + property variant component + component: Component { + id: myComponent + NestedObject { property string testProp: "test" } + } + + property variant component2 + component2: Component { + id: myComponent2 + Image { property string testProp: "test" } + } + + Component.onCompleted: { + nested = myComponent.createObject(0); + nested2 = myComponent2.createObject(0); + } +} diff --git a/tests/auto/qml/qqmlinfo/data/NestedObject.qml b/tests/auto/qml/qqmlinfo/data/NestedObject.qml new file mode 100644 index 0000000000..4b19b11699 --- /dev/null +++ b/tests/auto/qml/qqmlinfo/data/NestedObject.qml @@ -0,0 +1,8 @@ +import QtQuick 2.0 + +QtObject { + property variant nested + + nested: QtObject {} +} + diff --git a/tests/auto/qml/qqmlinfo/data/nestedQmlObject.qml b/tests/auto/qml/qqmlinfo/data/nestedQmlObject.qml new file mode 100644 index 0000000000..d199a612c4 --- /dev/null +++ b/tests/auto/qml/qqmlinfo/data/nestedQmlObject.qml @@ -0,0 +1,8 @@ +import QtQuick 2.0 + +QtObject { + property variant nested + nested: NestedObject { } + property variant nested2: nested.nested +} + diff --git a/tests/auto/qml/qqmlinfo/data/qmlObject.qml b/tests/auto/qml/qqmlinfo/data/qmlObject.qml new file mode 100644 index 0000000000..6a8e2fbc90 --- /dev/null +++ b/tests/auto/qml/qqmlinfo/data/qmlObject.qml @@ -0,0 +1,8 @@ +import QtQuick 2.0 + +QtObject { + property variant nested + + nested: QtObject { + } +} diff --git a/tests/auto/qml/qqmlinfo/qqmlinfo.pro b/tests/auto/qml/qqmlinfo/qqmlinfo.pro new file mode 100644 index 0000000000..21dc2c76a6 --- /dev/null +++ b/tests/auto/qml/qqmlinfo/qqmlinfo.pro @@ -0,0 +1,14 @@ +CONFIG += testcase +TARGET = tst_qqmlinfo +macx:CONFIG -= app_bundle + +SOURCES += tst_qqmlinfo.cpp + +include (../../shared/util.pri) + +testDataFiles.files = data +testDataFiles.path = . +DEPLOYMENT += testDataFiles + +CONFIG += parallel_test +QT += core-private gui-private qml-private widgets testlib diff --git a/tests/auto/qml/qqmlinfo/tst_qqmlinfo.cpp b/tests/auto/qml/qqmlinfo/tst_qqmlinfo.cpp new file mode 100644 index 0000000000..ed53cbd1aa --- /dev/null +++ b/tests/auto/qml/qqmlinfo/tst_qqmlinfo.cpp @@ -0,0 +1,221 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include +#include +#include +#include +#include +#include "../../shared/util.h" + +class tst_qqmlinfo : public QQmlDataTest +{ + Q_OBJECT +public: + tst_qqmlinfo() {} + +private slots: + void qmlObject(); + void nestedQmlObject(); + void nestedComponent(); + void nonQmlObject(); + void nullObject(); + void nonQmlContextedObject(); + void types(); + void chaining(); + +private: + QQmlEngine engine; +}; + +void tst_qqmlinfo::qmlObject() +{ + QQmlComponent component(&engine, testFileUrl("qmlObject.qml")); + + QObject *object = component.create(); + QVERIFY(object != 0); + + QString message = component.url().toString() + ":3:1: QML QtObject: Test Message"; + QTest::ignoreMessage(QtWarningMsg, qPrintable(message)); + qmlInfo(object) << "Test Message"; + + QObject *nested = qvariant_cast(object->property("nested")); + QVERIFY(nested != 0); + + message = component.url().toString() + ":6:13: QML QtObject: Second Test Message"; + QTest::ignoreMessage(QtWarningMsg, qPrintable(message)); + qmlInfo(nested) << "Second Test Message"; +} + +void tst_qqmlinfo::nestedQmlObject() +{ + QQmlComponent component(&engine, testFileUrl("nestedQmlObject.qml")); + + QObject *object = component.create(); + QVERIFY(object != 0); + + QObject *nested = qvariant_cast(object->property("nested")); + QVERIFY(nested != 0); + QObject *nested2 = qvariant_cast(object->property("nested2")); + QVERIFY(nested2 != 0); + + QString message = component.url().toString() + ":5:13: QML NestedObject: Outer Object"; + QTest::ignoreMessage(QtWarningMsg, qPrintable(message)); + qmlInfo(nested) << "Outer Object"; + + message = testFileUrl("NestedObject.qml").toString() + ":6:14: QML QtObject: Inner Object"; + QTest::ignoreMessage(QtWarningMsg, qPrintable(message)); + qmlInfo(nested2) << "Inner Object"; +} + +void tst_qqmlinfo::nestedComponent() +{ + QQmlComponent component(&engine, testFileUrl("NestedComponent.qml")); + + QObject *object = component.create(); + QVERIFY(object != 0); + + QObject *nested = qvariant_cast(object->property("nested")); + QVERIFY(nested != 0); + QObject *nested2 = qvariant_cast(object->property("nested2")); + QVERIFY(nested2 != 0); + + QString message = component.url().toString() + ":10:9: QML NestedObject: Complex Object"; + QTest::ignoreMessage(QtWarningMsg, qPrintable(message)); + qmlInfo(nested) << "Complex Object"; + + message = component.url().toString() + ":16:9: QML Image: Simple Object"; + QTest::ignoreMessage(QtWarningMsg, qPrintable(message)); + qmlInfo(nested2) << "Simple Object"; +} + +void tst_qqmlinfo::nonQmlObject() +{ + QObject object; + QTest::ignoreMessage(QtWarningMsg, ": QML QtObject: Test Message"); + qmlInfo(&object) << "Test Message"; + + QTimer nonQmlObject; + QTest::ignoreMessage(QtWarningMsg, ": QML QTimer: Test Message"); + qmlInfo(&nonQmlObject) << "Test Message"; +} + +void tst_qqmlinfo::nullObject() +{ + QTest::ignoreMessage(QtWarningMsg, ": Null Object Test Message"); + qmlInfo(0) << "Null Object Test Message"; +} + +void tst_qqmlinfo::nonQmlContextedObject() +{ + QObject object; + QQmlContext context(&engine); + QQmlEngine::setContextForObject(&object, &context); + QTest::ignoreMessage(QtWarningMsg, ": QML QtObject: Test Message"); + qmlInfo(&object) << "Test Message"; +} + +void tst_qqmlinfo::types() +{ + QTest::ignoreMessage(QtWarningMsg, ": false"); + qmlInfo(0) << false; + + QTest::ignoreMessage(QtWarningMsg, ": 1.1"); + qmlInfo(0) << 1.1; + + QTest::ignoreMessage(QtWarningMsg, ": 1.2"); + qmlInfo(0) << 1.2f; + + QTest::ignoreMessage(QtWarningMsg, ": 15"); + qmlInfo(0) << 15; + + QTest::ignoreMessage(QtWarningMsg, ": 'b'"); + qmlInfo(0) << QChar('b'); + + QTest::ignoreMessage(QtWarningMsg, ": \"Qt\""); + qmlInfo(0) << QByteArray("Qt"); + + QTest::ignoreMessage(QtWarningMsg, ": true"); + qmlInfo(0) << bool(true); + + //### do we actually want QUrl to show up in the output? + //### why the extra space at the end? + QTest::ignoreMessage(QtWarningMsg, ": QUrl(\"http://qt.nokia.com\") "); + qmlInfo(0) << QUrl("http://qt.nokia.com"); + + //### should this be quoted? + QTest::ignoreMessage(QtWarningMsg, ": hello"); + qmlInfo(0) << QLatin1String("hello"); + + //### should this be quoted? + QTest::ignoreMessage(QtWarningMsg, ": World"); + QString str("Hello World"); + QStringRef ref(&str, 6, 5); + qmlInfo(0) << ref; + + //### should this be quoted? + QTest::ignoreMessage(QtWarningMsg, ": Quick"); + qmlInfo(0) << QString ("Quick"); +} + +void tst_qqmlinfo::chaining() +{ + //### should more of these be automatically inserting spaces? + QString str("Hello World"); + QStringRef ref(&str, 6, 5); + QTest::ignoreMessage(QtWarningMsg, ": false 1.1 1.2 15 hello 'b' QUrl(\"http://qt.nokia.com\") World \"Qt\" true Quick "); + qmlInfo(0) << false << ' ' + << 1.1 << ' ' + << 1.2f << ' ' + << 15 << ' ' + << QLatin1String("hello") << ' ' + << QChar('b') << ' ' + << QUrl("http://qt.nokia.com") + << ref + << QByteArray("Qt") + << bool(true) + << QString ("Quick"); +} + +QTEST_MAIN(tst_qqmlinfo) + +#include "tst_qqmlinfo.moc" diff --git a/tests/auto/qml/qqmlinstruction/qqmlinstruction.pro b/tests/auto/qml/qqmlinstruction/qqmlinstruction.pro new file mode 100644 index 0000000000..093b190bbf --- /dev/null +++ b/tests/auto/qml/qqmlinstruction/qqmlinstruction.pro @@ -0,0 +1,8 @@ +CONFIG += testcase +TARGET = tst_qqmlinstruction +SOURCES += tst_qqmlinstruction.cpp +macx:CONFIG -= app_bundle + +CONFIG += parallel_test + +QT += core-private gui-private v8-private qml-private testlib diff --git a/tests/auto/qml/qqmlinstruction/tst_qqmlinstruction.cpp b/tests/auto/qml/qqmlinstruction/tst_qqmlinstruction.cpp new file mode 100644 index 0000000000..07b89af0a3 --- /dev/null +++ b/tests/auto/qml/qqmlinstruction/tst_qqmlinstruction.cpp @@ -0,0 +1,678 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include + +class tst_qqmlinstruction : public QObject +{ + Q_OBJECT +public: + tst_qqmlinstruction() {} + +private slots: + void dump(); + + void point(); + void pointf(); + void size(); + void sizef(); + void rect(); + void rectf(); + void vector3d(); + void vector4d(); + void time(); +}; + +static QStringList messages; +static void msgHandler(QtMsgType, const char *msg) +{ + messages << QLatin1String(msg); +} + +void tst_qqmlinstruction::dump() +{ + QQmlEngine engine; + QQmlCompiledData *data = new QQmlCompiledData(&engine); + + { + QQmlCompiledData::Instruction::Init i; + i.bindingsSize = 0; + i.parserStatusSize = 3; + i.contextCache = -1; + i.compiledBinding = -1; + data->addInstruction(i); + } + + { + QQmlCompiledData::TypeReference ref; + ref.className = "Test"; + data->types << ref; + + QQmlCompiledData::Instruction::CreateCppObject i; + i.type = 0; + i.data = -1; + i.column = 10; + data->addInstruction(i); + } + + { + data->primitives << "testId"; + + QQmlCompiledData::Instruction::SetId i; + i.value = data->primitives.count() - 1; + i.index = 0; + data->addInstruction(i); + } + + { + QQmlCompiledData::Instruction::SetDefault i; + data->addInstruction(i); + } + + { + QQmlCompiledData::Instruction::CreateComponent i; + i.count = 3; + i.column = 4; + i.endLine = 14; + i.metaObject = 0; + + data->addInstruction(i); + } + + { + QQmlCompiledData::Instruction::StoreMetaObject i; + i.data = 3; + i.aliasData = 6; + i.propertyCache = 7; + + data->addInstruction(i); + } + + { + QQmlCompiledData::Instruction::StoreFloat i; + i.propertyIndex = 3; + i.value = 11.3; + data->addInstruction(i); + } + + { + QQmlCompiledData::Instruction::StoreDouble i; + i.propertyIndex = 4; + i.value = 14.8; + data->addInstruction(i); + } + + { + QQmlCompiledData::Instruction::StoreInteger i; + i.propertyIndex = 5; + i.value = 9; + data->addInstruction(i); + } + + { + QQmlCompiledData::Instruction::StoreBool i; + i.propertyIndex = 6; + i.value = true; + + data->addInstruction(i); + } + + { + data->primitives << "Test String"; + QQmlCompiledData::Instruction::StoreString i; + i.propertyIndex = 7; + i.value = data->primitives.count() - 1; + data->addInstruction(i); + } + + { + data->urls << QUrl("http://www.nokia.com"); + QQmlCompiledData::Instruction::StoreUrl i; + i.propertyIndex = 8; + i.value = data->urls.count() - 1; + data->addInstruction(i); + } + + { + QQmlCompiledData::Instruction::StoreColor i; + i.propertyIndex = 9; + i.value = 0xFF00FF00; + data->addInstruction(i); + } + + { + QQmlCompiledData::Instruction::StoreDate i; + i.propertyIndex = 10; + i.value = 9; + data->addInstruction(i); + } + + { + QQmlCompiledData::Instruction::StoreTime i; + i.propertyIndex = 11; + data->addInstruction(i); + } + + { + QQmlCompiledData::Instruction::StoreDateTime i; + i.propertyIndex = 12; + data->addInstruction(i); + } + + { + QQmlCompiledData::Instruction::StorePoint i; + i.propertyIndex = 13; + i.point.xp = 3; + i.point.yp = 7; + data->addInstruction(i); + } + + { + QQmlCompiledData::Instruction::StorePointF i; + i.propertyIndex = 13; + i.point.xp = 3; + i.point.yp = 7; + data->addInstruction(i); + } + + { + QQmlCompiledData::Instruction::StoreSize i; + i.propertyIndex = 15; + i.size.wd = 8; + i.size.ht = 11; + data->addInstruction(i); + } + + { + QQmlCompiledData::Instruction::StoreSizeF i; + i.propertyIndex = 15; + i.size.wd = 8; + i.size.ht = 11; + data->addInstruction(i); + } + + { + QQmlCompiledData::Instruction::StoreRect i; + i.propertyIndex = 17; + i.rect.x1 = 7; + i.rect.y1 = 9; + i.rect.x2 = 11; + i.rect.y2 = 13; + data->addInstruction(i); + } + + { + QQmlCompiledData::Instruction::StoreRectF i; + i.propertyIndex = 18; + i.rect.xp = 11.3; + i.rect.yp = 9.8; + i.rect.w = 3; + i.rect.h = 2.1; + data->addInstruction(i); + } + + { + QQmlCompiledData::Instruction::StoreVector3D i; + i.propertyIndex = 19; + i.vector.xp = 9; + i.vector.yp = 3; + i.vector.zp = 92; + data->addInstruction(i); + } + + { + data->primitives << "color(1, 1, 1, 1)"; + QQmlCompiledData::Instruction::StoreVariant i; + i.propertyIndex = 20; + i.value = data->primitives.count() - 1; + + data->addInstruction(i); + } + + { + QQmlCompiledData::Instruction::StoreObject i; + i.propertyIndex = 21; + data->addInstruction(i); + } + + { + QQmlCompiledData::Instruction::StoreVariantObject i; + i.propertyIndex = 22; + data->addInstruction(i); + } + + { + QQmlCompiledData::Instruction::StoreInterface i; + i.propertyIndex = 23; + data->addInstruction(i); + } + + { + data->primitives << "console.log(1921)"; + + QQmlCompiledData::Instruction::StoreSignal i; + i.signalIndex = 2; + i.value = data->primitives.count() - 1; + data->addInstruction(i); + } + + { + QQmlCompiledData::Instruction::StoreScriptString i; + i.propertyIndex = 24; + i.value = 3; + i.scope = 1; + i.bindingId = 4; + data->addInstruction(i); + } + + { + data->primitives << "mySignal"; + + QQmlCompiledData::Instruction::AssignSignalObject i; + i.signal = data->primitives.count() - 1; + data->addInstruction(i); + } + + { + QQmlCompiledData::Instruction::AssignCustomType i; + i.propertyIndex = 25; + i.primitive = 6; + i.type = 9; + data->addInstruction(i); + } + + { + QQmlCompiledData::Instruction::StoreBinding i; + i.property.coreIndex = 26; + i.value = 3; + i.context = 2; + i.owner = 0; + data->addInstruction(i); + } + + { + QQmlCompiledData::Instruction::StoreV4Binding i; + i.property = 27; + i.value = 2; + i.context = 4; + i.owner = 0; + data->addInstruction(i); + } + + { + QQmlCompiledData::Instruction::StoreValueSource i; + i.property.coreIndex = 29; + i.owner = 1; + i.castValue = 4; + data->addInstruction(i); + } + + { + QQmlCompiledData::Instruction::StoreValueInterceptor i; + i.property.coreIndex = 30; + i.owner = 2; + i.castValue = -4; + data->addInstruction(i); + } + + { + QQmlCompiledData::Instruction::BeginObject i; + i.castValue = 4; + data->addInstruction(i); + } + + { + QQmlCompiledData::Instruction::StoreObjectQList i; + data->addInstruction(i); + } + + { + QQmlCompiledData::Instruction::AssignObjectList i; + data->addInstruction(i); + } + + { + QQmlCompiledData::Instruction::FetchAttached i; + i.id = 23; + data->addInstruction(i); + } + + { + QQmlCompiledData::Instruction::FetchQList i; + i.property = 32; + data->addInstruction(i); + } + + { + QQmlCompiledData::Instruction::FetchObject i; + i.property = 33; + data->addInstruction(i); + } + + { + QQmlCompiledData::Instruction::FetchValueType i; + i.property = 34; + i.type = 6; + i.bindingSkipList = 7; + data->addInstruction(i); + } + + { + QQmlCompiledData::Instruction::PopFetchedObject i; + data->addInstruction(i); + } + + { + QQmlCompiledData::Instruction::PopQList i; + data->addInstruction(i); + } + + { + QQmlCompiledData::Instruction::PopValueType i; + i.property = 35; + i.type = 8; + data->addInstruction(i); + } + + { + QQmlCompiledData::Instruction::Defer i; + i.deferCount = 7; + data->addInstruction(i); + } + + { + QQmlCompiledData::Instruction::Defer i; + i.deferCount = 7; + data->addInstruction(i); + } + + { + QQmlCompiledData::Instruction::StoreImportedScript i; + i.value = 2; + data->addInstruction(i); + } + + { + QQmlCompiledData::Instruction::StoreVariantInteger i; + i.value = 11; + i.propertyIndex = 32; + data->addInstruction(i); + } + + { + QQmlCompiledData::Instruction::StoreVariantDouble i; + i.value = 33.7; + i.propertyIndex = 19; + data->addInstruction(i); + } + + { + QQmlCompiledData::Instruction::Done i; + data->addInstruction(i); + } + + { + QQmlCompiledData::Instruction::StoreTrString i; + i.propertyIndex = 99; + i.context = 3; + i.text = 14; + i.comment = 14; + i.n = 2; + data->addInstruction(i); + } + + { + QQmlCompiledData::Instruction::StoreTrIdString i; + i.propertyIndex = 78; + i.text = 7; + i.n = -1; + data->addInstruction(i); + } + + QStringList expect; + expect + << "Index\tOperation\t\tData1\tData2\tData3\tComments" + << "-------------------------------------------------------------------------------" + << "0\t\tINIT\t\t\t0\t3\t-1\t-1" + << "1\t\tCREATECPP\t\t\t0\t\t\t\"Test\"" + << "2\t\tSETID\t\t\t0\t\t\t\"testId\"" + << "3\t\tSET_DEFAULT" + << "4\t\tCREATE_COMPONENT\t3" + << "5\t\tSTORE_META\t\t3" + << "6\t\tSTORE_FLOAT\t\t3\t11.3" + << "7\t\tSTORE_DOUBLE\t\t4\t14.8" + << "8\t\tSTORE_INTEGER\t\t5\t9" + << "9\t\tSTORE_BOOL\t\t6\ttrue" + << "10\t\tSTORE_STRING\t\t7\t1\t\t\"Test String\"" + << "11\t\tSTORE_URL\t\t8\t0\t\tQUrl(\"http://www.nokia.com\") " + << "12\t\tSTORE_COLOR\t\t9\t\t\t\"ff00ff00\"" + << "13\t\tSTORE_DATE\t\t10\t9" + << "14\t\tSTORE_TIME\t\t11" + << "15\t\tSTORE_DATETIME\t\t12" + << "16\t\tSTORE_POINT\t\t13\t3\t7" + << "17\t\tSTORE_POINTF\t\t13\t3\t7" + << "18\t\tSTORE_SIZE\t\t15\t8\t11" + << "19\t\tSTORE_SIZEF\t\t15\t8\t11" + << "20\t\tSTORE_RECT\t\t17\t7\t9\t11\t13" + << "21\t\tSTORE_RECTF\t\t18\t11.3\t9.8\t3\t2.1" + << "22\t\tSTORE_VECTOR3D\t\t19\t9\t3\t92" + << "23\t\tSTORE_VARIANT\t\t20\t2\t\t\"color(1, 1, 1, 1)\"" + << "24\t\tSTORE_OBJECT\t\t21" + << "25\t\tSTORE_VARIANT_OBJECT\t22" + << "26\t\tSTORE_INTERFACE\t\t23" + << "27\t\tSTORE_SIGNAL\t\t2\t3\t\t\"console.log(1921)\"" + << "28\t\tSTORE_SCRIPT_STRING\t24\t3\t1\t4" + << "29\t\tASSIGN_SIGNAL_OBJECT\t4\t\t\t\"mySignal\"" + << "30\t\tASSIGN_CUSTOMTYPE\t25\t6\t9" + << "31\t\tSTORE_BINDING\t26\t3\t2" + << "32\t\tSTORE_COMPILED_BINDING\t27\t2\t4" + << "33\t\tSTORE_VALUE_SOURCE\t29\t4" + << "34\t\tSTORE_VALUE_INTERCEPTOR\t30\t-4" + << "35\t\tBEGIN\t\t\t4" + << "36\t\tSTORE_OBJECT_QLIST" + << "37\t\tASSIGN_OBJECT_LIST" + << "38\t\tFETCH_ATTACHED\t\t23" + << "39\t\tFETCH_QLIST\t\t32" + << "40\t\tFETCH\t\t\t33" + << "41\t\tFETCH_VALUE\t\t34\t6\t7" + << "42\t\tPOP" + << "43\t\tPOP_QLIST" + << "44\t\tPOP_VALUE\t\t35\t8" + << "45\t\tDEFER\t\t\t7" + << "46\t\tDEFER\t\t\t7" + << "47\t\tSTORE_IMPORTED_SCRIPT\t2" + << "48\t\tSTORE_VARIANT_INTEGER\t\t32\t11" + << "49\t\tSTORE_VARIANT_DOUBLE\t\t19\t33.7" + << "50\t\tDONE" + << "51\t\tSTORE_TR_STRING\t99\t3\t14\t14\t2" + << "52\t\tSTORE_TRID_STRING\t78\t7\t-1" + << "-------------------------------------------------------------------------------"; + + messages = QStringList(); + QtMsgHandler old = qInstallMsgHandler(msgHandler); + + data->dumpInstructions(); + qInstallMsgHandler(old); + + QCOMPARE(messages.count(), expect.count()); + for (int ii = 0; ii < messages.count(); ++ii) { + QCOMPARE(messages.at(ii), expect.at(ii)); + } + + data->release(); +} + +void tst_qqmlinstruction::point() +{ + QCOMPARE(sizeof(QQmlInstruction::instr_storePoint::QPoint), sizeof(QPoint)); + QCOMPARE(Q_ALIGNOF(QQmlInstruction::instr_storePoint::QPoint), Q_ALIGNOF(QPoint)); + + QQmlInstruction i; + i.storePoint.point.xp = 8; + i.storePoint.point.yp = 11; + + const QPoint &point = (const QPoint &)(i.storePoint.point); + QCOMPARE(point.x(), 8); + QCOMPARE(point.y(), 11); +} + +void tst_qqmlinstruction::pointf() +{ + QCOMPARE(sizeof(QQmlInstruction::instr_storePointF::QPointF), sizeof(QPointF)); + QCOMPARE(Q_ALIGNOF(QQmlInstruction::instr_storePointF::QPointF), Q_ALIGNOF(QPointF)); + + QQmlInstruction i; + i.storePointF.point.xp = 8.7; + i.storePointF.point.yp = 11.3; + + const QPointF &point = (const QPointF &)(i.storePointF.point); + QCOMPARE(point.x(), 8.7); + QCOMPARE(point.y(), 11.3); +} + +void tst_qqmlinstruction::size() +{ + QCOMPARE(sizeof(QQmlInstruction::instr_storeSize::QSize), sizeof(QSize)); + QCOMPARE(Q_ALIGNOF(QQmlInstruction::instr_storeSize::QSize), Q_ALIGNOF(QSize)); + + QQmlInstruction i; + i.storeSize.size.wd = 8; + i.storeSize.size.ht = 11; + + const QSize &size = (const QSize &)(i.storeSize.size); + QCOMPARE(size.width(), 8); + QCOMPARE(size.height(), 11); +} + +void tst_qqmlinstruction::sizef() +{ + QCOMPARE(sizeof(QQmlInstruction::instr_storeSizeF::QSizeF), sizeof(QSizeF)); + QCOMPARE(Q_ALIGNOF(QQmlInstruction::instr_storeSizeF::QSizeF), Q_ALIGNOF(QSizeF)); + + QQmlInstruction i; + i.storeSizeF.size.wd = 8; + i.storeSizeF.size.ht = 11; + + const QSizeF &size = (const QSizeF &)(i.storeSizeF.size); + QCOMPARE(size.width(), (qreal)8); + QCOMPARE(size.height(), (qreal)11); +} + +void tst_qqmlinstruction::rect() +{ + QCOMPARE(sizeof(QQmlInstruction::instr_storeRect::QRect), sizeof(QRect)); + QCOMPARE(Q_ALIGNOF(QQmlInstruction::instr_storeRect::QRect), Q_ALIGNOF(QRect)); + + QQmlInstruction i; + i.storeRect.rect.x1 = 8; + i.storeRect.rect.y1 = 11; + i.storeRect.rect.x2 = 13; + i.storeRect.rect.y2 = 19; + + const QRect &rect = (const QRect &)(i.storeRect.rect); + QCOMPARE(rect.left(), 8); + QCOMPARE(rect.top(), 11); + QCOMPARE(rect.right(), 13); + QCOMPARE(rect.bottom(), 19); +} + +void tst_qqmlinstruction::rectf() +{ + QCOMPARE(sizeof(QQmlInstruction::instr_storeRectF::QRectF), sizeof(QRectF)); + QCOMPARE(Q_ALIGNOF(QQmlInstruction::instr_storeRectF::QRectF), Q_ALIGNOF(QRectF)); + + QQmlInstruction i; + i.storeRectF.rect.xp = 8; + i.storeRectF.rect.yp = 11; + i.storeRectF.rect.w = 13; + i.storeRectF.rect.h = 19; + + const QRectF &rect = (const QRectF &)(i.storeRectF.rect); + QCOMPARE(rect.left(), (qreal)8); + QCOMPARE(rect.top(), (qreal)11); + QCOMPARE(rect.width(), (qreal)13); + QCOMPARE(rect.height(), (qreal)19); +} + +void tst_qqmlinstruction::vector3d() +{ + QCOMPARE(sizeof(QQmlInstruction::instr_storeVector3D::QVector3D), sizeof(QVector3D)); + QCOMPARE(Q_ALIGNOF(QQmlInstruction::instr_storeVector3D::QVector3D), Q_ALIGNOF(QVector3D)); + + QQmlInstruction i; + i.storeVector3D.vector.xp = 8.2; + i.storeVector3D.vector.yp = 99.3; + i.storeVector3D.vector.zp = 12.0; + + const QVector3D &vector = (const QVector3D &)(i.storeVector3D.vector); + QCOMPARE(vector.x(), (qreal)(float)8.2); + QCOMPARE(vector.y(), (qreal)(float)99.3); + QCOMPARE(vector.z(), (qreal)(float)12.0); +} + +void tst_qqmlinstruction::vector4d() +{ + QCOMPARE(sizeof(QQmlInstruction::instr_storeVector4D::QVector4D), sizeof(QVector4D)); + QCOMPARE(Q_ALIGNOF(QQmlInstruction::instr_storeVector4D::QVector4D), Q_ALIGNOF(QVector4D)); + + QQmlInstruction i; + i.storeVector4D.vector.xp = 8.2; + i.storeVector4D.vector.yp = 99.3; + i.storeVector4D.vector.zp = 12.0; + i.storeVector4D.vector.wp = 121.1; + + const QVector4D &vector = (const QVector4D &)(i.storeVector4D.vector); + QCOMPARE(vector.x(), (qreal)(float)8.2); + QCOMPARE(vector.y(), (qreal)(float)99.3); + QCOMPARE(vector.z(), (qreal)(float)12.0); + QCOMPARE(vector.w(), (qreal)(float)121.1); +} + +void tst_qqmlinstruction::time() +{ + QCOMPARE(sizeof(QQmlInstruction::instr_storeTime::QTime), sizeof(QTime)); + QCOMPARE(Q_ALIGNOF(QQmlInstruction::instr_storeTime::QTime), Q_ALIGNOF(QTime)); +} + +QTEST_MAIN(tst_qqmlinstruction) + +#include "tst_qqmlinstruction.moc" diff --git a/tests/auto/qml/qqmllanguage/data/Alias.qml b/tests/auto/qml/qqmllanguage/data/Alias.qml new file mode 100644 index 0000000000..2cb7cbe2e0 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/Alias.qml @@ -0,0 +1,8 @@ +import QtQuick 2.0 + +QtObject { + id: root + property int value: 1892 + property alias aliasValue: root.value +} + diff --git a/tests/auto/qml/qqmllanguage/data/Alias2.qml b/tests/auto/qml/qqmllanguage/data/Alias2.qml new file mode 100644 index 0000000000..134e1440b5 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/Alias2.qml @@ -0,0 +1,9 @@ +import Test 1.0 +import QtQuick 2.0 + +QtObject { + property variant other + other: MyTypeObject { id: obj } + property alias enumAlias: obj.enumProperty; +} + diff --git a/tests/auto/qml/qqmllanguage/data/Alias3.qml b/tests/auto/qml/qqmllanguage/data/Alias3.qml new file mode 100644 index 0000000000..54b548e049 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/Alias3.qml @@ -0,0 +1,12 @@ +import Test 1.0 +import QtQuick 2.0 + +QtObject { + property alias obj : otherObj + property variant child + child: QtObject { + id: otherObj + property int myValue: 10 + } +} + diff --git a/tests/auto/qml/qqmllanguage/data/Alias4.qml b/tests/auto/qml/qqmllanguage/data/Alias4.qml new file mode 100644 index 0000000000..e09eca2ff3 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/Alias4.qml @@ -0,0 +1,5 @@ +import Test 1.0 +import QtQuick 2.0 + +Alias3 {} + diff --git a/tests/auto/qml/qqmllanguage/data/AliasPropertyChangeSignalsType.qml b/tests/auto/qml/qqmllanguage/data/AliasPropertyChangeSignalsType.qml new file mode 100644 index 0000000000..9265ffb1df --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/AliasPropertyChangeSignalsType.qml @@ -0,0 +1,20 @@ +import QtQuick 2.0 + +QtObject { + id: root + + signal sig1 + signal sig2 + signal sig3 + signal sig4 + + property alias aliasProperty: root.realProperty + + property int realProperty: 0 + + property bool test: false + + Component.onCompleted: { + root.realProperty = 10; + } +} diff --git a/tests/auto/qml/qqmllanguage/data/ComponentComposite.qml b/tests/auto/qml/qqmllanguage/data/ComponentComposite.qml new file mode 100644 index 0000000000..889450b565 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/ComponentComposite.qml @@ -0,0 +1,5 @@ +import QtQuick 2.0 + +Component { + QtObject {} +} diff --git a/tests/auto/qml/qqmllanguage/data/CompositeType.qml b/tests/auto/qml/qqmllanguage/data/CompositeType.qml new file mode 100644 index 0000000000..addc4265a9 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/CompositeType.qml @@ -0,0 +1,4 @@ +import QtQuick 2.0 + +QtObject { +} diff --git a/tests/auto/qml/qqmllanguage/data/CompositeType2.qml b/tests/auto/qml/qqmllanguage/data/CompositeType2.qml new file mode 100644 index 0000000000..86210e9072 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/CompositeType2.qml @@ -0,0 +1,5 @@ +import Test 1.0 + +MyQmlObject { +} + diff --git a/tests/auto/qml/qqmllanguage/data/CompositeType3.qml b/tests/auto/qml/qqmllanguage/data/CompositeType3.qml new file mode 100644 index 0000000000..f48a77598c --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/CompositeType3.qml @@ -0,0 +1,5 @@ +import QtQuick 2.0 + +QtObject { + property int a +} diff --git a/tests/auto/qml/qqmllanguage/data/CompositeType4.qml b/tests/auto/qml/qqmllanguage/data/CompositeType4.qml new file mode 100644 index 0000000000..a6a8168d8f --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/CompositeType4.qml @@ -0,0 +1,6 @@ +import Test 1.0 + +MyQmlObject { + property int a +} + diff --git a/tests/auto/qml/qqmllanguage/data/DontDoubleCallClassBeginItem.qml b/tests/auto/qml/qqmllanguage/data/DontDoubleCallClassBeginItem.qml new file mode 100644 index 0000000000..1f8eac8a3b --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/DontDoubleCallClassBeginItem.qml @@ -0,0 +1,4 @@ +import Test 1.0 + +MyParserStatus { +} diff --git a/tests/auto/qml/qqmllanguage/data/DynamicPropertiesNestedType.qml b/tests/auto/qml/qqmllanguage/data/DynamicPropertiesNestedType.qml new file mode 100644 index 0000000000..4667adda14 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/DynamicPropertiesNestedType.qml @@ -0,0 +1,6 @@ +import QtQuick 2.0 + +QtObject { + property int super_a: 10 + property int super_c: 14 +} diff --git a/tests/auto/qml/qqmllanguage/data/HelperAlias.qml b/tests/auto/qml/qqmllanguage/data/HelperAlias.qml new file mode 100644 index 0000000000..c2ab70ffd6 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/HelperAlias.qml @@ -0,0 +1,9 @@ +import Test 1.0 +import QtQuick 2.0 + +QtObject { + property variant child + child: QtObject { id: obj } + property alias objAlias: obj; +} + diff --git a/tests/auto/qml/qqmllanguage/data/I18n.qml b/tests/auto/qml/qqmllanguage/data/I18n.qml new file mode 100644 index 0000000000..558c836e52 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/I18n.qml @@ -0,0 +1,6 @@ +import Test 1.0 + +MyTypeObject { + property int áâãäå: 10 + stringProperty: "Test áâãäå: " + áâãäå +} diff --git a/tests/auto/qml/qqmllanguage/data/I18nType30.qml b/tests/auto/qml/qqmllanguage/data/I18nType30.qml new file mode 100644 index 0000000000..42dbc69044 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/I18nType30.qml @@ -0,0 +1,5 @@ +import Test 1.0 + +MyTypeObject { + stringProperty: "Test áâãäå: 30" +} diff --git a/tests/auto/qml/qqmllanguage/data/InlineAssignmentsOverrideBindingsType.qml b/tests/auto/qml/qqmllanguage/data/InlineAssignmentsOverrideBindingsType.qml new file mode 100644 index 0000000000..42513e463f --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/InlineAssignmentsOverrideBindingsType.qml @@ -0,0 +1,7 @@ +import QtQuick 2.0 + +QtObject { + property InlineAssignmentsOverrideBindingsType2 nested: InlineAssignmentsOverrideBindingsType2 { + value: 19 * 33 + } +} diff --git a/tests/auto/qml/qqmllanguage/data/InlineAssignmentsOverrideBindingsType2.qml b/tests/auto/qml/qqmllanguage/data/InlineAssignmentsOverrideBindingsType2.qml new file mode 100644 index 0000000000..4a45535a50 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/InlineAssignmentsOverrideBindingsType2.qml @@ -0,0 +1,5 @@ +import QtQuick 2.0 + +QtObject { + property int value +} diff --git a/tests/auto/qml/qqmllanguage/data/LocalLast.qml b/tests/auto/qml/qqmllanguage/data/LocalLast.qml new file mode 100644 index 0000000000..59df88216e --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/LocalLast.qml @@ -0,0 +1,2 @@ +import QtQuick 2.0 +Text {} diff --git a/tests/auto/qml/qqmllanguage/data/MyComponent.qml b/tests/auto/qml/qqmllanguage/data/MyComponent.qml new file mode 100644 index 0000000000..1a23277ff8 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/MyComponent.qml @@ -0,0 +1,6 @@ +import Test 1.0 + +MyQmlObject { + property real x; + property real y; +} diff --git a/tests/auto/qml/qqmllanguage/data/MyCompositeValueSource.qml b/tests/auto/qml/qqmllanguage/data/MyCompositeValueSource.qml new file mode 100644 index 0000000000..e620e26490 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/MyCompositeValueSource.qml @@ -0,0 +1,6 @@ +import Test 1.0 + +MyPropertyValueSource { + property int x +} + diff --git a/tests/auto/qml/qqmllanguage/data/MyContainerComponent.qml b/tests/auto/qml/qqmllanguage/data/MyContainerComponent.qml new file mode 100644 index 0000000000..61f54c5eb8 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/MyContainerComponent.qml @@ -0,0 +1,5 @@ +import Test 1.0 + +MyContainer { + property int x +} diff --git a/tests/auto/qml/qqmllanguage/data/NestedAlias.qml b/tests/auto/qml/qqmllanguage/data/NestedAlias.qml new file mode 100644 index 0000000000..7d49b0ac98 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/NestedAlias.qml @@ -0,0 +1,14 @@ +import QtQuick 2.0 + +QtObject { + property QtObject o1 + property QtObject o2 + + property alias a: object2.a + + o1: QtObject { id: object1 } + o2: QtObject { + id: object2 + property int a: 1923 + } +} diff --git a/tests/auto/qml/qqmllanguage/data/NestedComponentRoot.qml b/tests/auto/qml/qqmllanguage/data/NestedComponentRoot.qml new file mode 100644 index 0000000000..887d7fae50 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/NestedComponentRoot.qml @@ -0,0 +1,6 @@ +import QtQuick 2.0 + +Component { + Item { + } +} diff --git a/tests/auto/qml/qqmllanguage/data/NestedErrorsType.qml b/tests/auto/qml/qqmllanguage/data/NestedErrorsType.qml new file mode 100644 index 0000000000..06a3212916 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/NestedErrorsType.qml @@ -0,0 +1,5 @@ +import QtQuick 2.0 + +Item { + x: "You can't assign a string to a real!" +} diff --git a/tests/auto/qml/qqmllanguage/data/OnCompletedType.qml b/tests/auto/qml/qqmllanguage/data/OnCompletedType.qml new file mode 100644 index 0000000000..947f14811f --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/OnCompletedType.qml @@ -0,0 +1,8 @@ +import Test 1.0 +import QtQuick 2.0 + +MyQmlObject { + property int a: Math.max(10, 9) + property int b: 11 + Component.onCompleted: console.log("Completed " + a + " " + b); +} diff --git a/tests/auto/qml/qqmllanguage/data/OnDestructionType.qml b/tests/auto/qml/qqmllanguage/data/OnDestructionType.qml new file mode 100644 index 0000000000..11fb9d9578 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/OnDestructionType.qml @@ -0,0 +1,8 @@ +import Test 1.0 +import QtQuick 2.0 + +MyQmlObject { + property int a: Math.max(10, 9) + property int b: 11 + Component.onDestruction: console.log("Destruction " + a + " " + b); +} diff --git a/tests/auto/qml/qqmllanguage/data/ReadOnlyType.qml b/tests/auto/qml/qqmllanguage/data/ReadOnlyType.qml new file mode 100644 index 0000000000..456ac762fc --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/ReadOnlyType.qml @@ -0,0 +1,5 @@ +import QtQuick 2.0 + +QtObject { + readonly property int readOnlyProperty: 19 +} diff --git a/tests/auto/qml/qqmllanguage/data/alias.1.qml b/tests/auto/qml/qqmllanguage/data/alias.1.qml new file mode 100644 index 0000000000..dbb3f06d32 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/alias.1.qml @@ -0,0 +1,8 @@ +import Test 1.0 +import QtQuick 2.0 + +QtObject { + id: root + property int value: 10 + property alias valueAlias: root.value +} diff --git a/tests/auto/qml/qqmllanguage/data/alias.10.qml b/tests/auto/qml/qqmllanguage/data/alias.10.qml new file mode 100644 index 0000000000..bf6352e82b --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/alias.10.qml @@ -0,0 +1,8 @@ +import Test 1.0 + +MyTypeObject { + id: root + property alias valueAlias: root.rectProperty + + rectProperty: "10,11,9x8" +} diff --git a/tests/auto/qml/qqmllanguage/data/alias.11.qml b/tests/auto/qml/qqmllanguage/data/alias.11.qml new file mode 100644 index 0000000000..fbd50d9dc9 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/alias.11.qml @@ -0,0 +1,8 @@ +import Test 1.0 + +MyTypeObject { + id: root + + property alias aliasProperty: root.rectProperty.x + rectProperty: "19,13,100x120" +} diff --git a/tests/auto/qml/qqmllanguage/data/alias.2.qml b/tests/auto/qml/qqmllanguage/data/alias.2.qml new file mode 100644 index 0000000000..5c922709fe --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/alias.2.qml @@ -0,0 +1,8 @@ +import Test 1.0 + +MyQmlObject { + id: root + property alias aliasObject: root.qmlobjectProperty + + qmlobjectProperty: MyQmlObject { value : 10 } +} diff --git a/tests/auto/qml/qqmllanguage/data/alias.3.qml b/tests/auto/qml/qqmllanguage/data/alias.3.qml new file mode 100644 index 0000000000..16a6d9d903 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/alias.3.qml @@ -0,0 +1,10 @@ +import QtQuick 2.0 + +QtObject { + property variant other + other: Alias { id: myAliasObject } + + property alias value: myAliasObject.aliasValue + property alias value2: myAliasObject.value +} + diff --git a/tests/auto/qml/qqmllanguage/data/alias.4.qml b/tests/auto/qml/qqmllanguage/data/alias.4.qml new file mode 100644 index 0000000000..bd6a769367 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/alias.4.qml @@ -0,0 +1,6 @@ +import Test 1.0 + +Alias2 { + enumAlias: MyTypeObject.EnumVal2 +} + diff --git a/tests/auto/qml/qqmllanguage/data/alias.5.qml b/tests/auto/qml/qqmllanguage/data/alias.5.qml new file mode 100644 index 0000000000..cee2a88cf7 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/alias.5.qml @@ -0,0 +1,13 @@ +import QtQuick 2.0 +import Test 1.0 + +QtObject { + property alias otherAlias: otherObject + + property variant other + other: MyQmlObject { + id: otherObject + value: 10 + } +} + diff --git a/tests/auto/qml/qqmllanguage/data/alias.6.qml b/tests/auto/qml/qqmllanguage/data/alias.6.qml new file mode 100644 index 0000000000..54d3c320e0 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/alias.6.qml @@ -0,0 +1,8 @@ +import QtQuick 2.0 + +QtObject { + property QtObject o; + property alias a: object.a + o: NestedAlias { id: object } +} + diff --git a/tests/auto/qml/qqmllanguage/data/alias.7.qml b/tests/auto/qml/qqmllanguage/data/alias.7.qml new file mode 100644 index 0000000000..0dc54d6787 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/alias.7.qml @@ -0,0 +1,14 @@ +import QtQuick 2.0 + +QtObject { + property QtObject object + property alias aliasedObject: target.object + + object: QtObject { + id: target + + property QtObject object + object: QtObject {} + } +} + diff --git a/tests/auto/qml/qqmllanguage/data/alias.8.qml b/tests/auto/qml/qqmllanguage/data/alias.8.qml new file mode 100644 index 0000000000..3cb280ef47 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/alias.8.qml @@ -0,0 +1,9 @@ +import QtQuick 2.0 + +QtObject { + property variant other + other: Alias3 { id: myAliasObject } + + property int value: myAliasObject.obj.myValue +} + diff --git a/tests/auto/qml/qqmllanguage/data/alias.9.qml b/tests/auto/qml/qqmllanguage/data/alias.9.qml new file mode 100644 index 0000000000..01cf9142b2 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/alias.9.qml @@ -0,0 +1,9 @@ +import QtQuick 2.0 + +QtObject { + property variant other + other: Alias4 { id: myAliasObject } + + property int value: myAliasObject.obj.myValue +} + diff --git a/tests/auto/qml/qqmllanguage/data/aliasPropertiesAndSignals.qml b/tests/auto/qml/qqmllanguage/data/aliasPropertiesAndSignals.qml new file mode 100644 index 0000000000..60e66921d2 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/aliasPropertiesAndSignals.qml @@ -0,0 +1,14 @@ +import QtQuick 2.0 + +QtObject { + id: root + + property bool test: false + property alias myalias: root.objectName + signal go + onGo: test = true + + Component.onCompleted: { + root.go(); + } +} diff --git a/tests/auto/qml/qqmllanguage/data/aliasPropertyChangeSignals.2.qml b/tests/auto/qml/qqmllanguage/data/aliasPropertyChangeSignals.2.qml new file mode 100644 index 0000000000..089130d14c --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/aliasPropertyChangeSignals.2.qml @@ -0,0 +1,10 @@ +import QtQuick 2.0 + +AliasPropertyChangeSignalsType { + id: root + onAliasPropertyChanged: root.test = true + + function blah() {} + property int a +} + diff --git a/tests/auto/qml/qqmllanguage/data/aliasPropertyChangeSignals.qml b/tests/auto/qml/qqmllanguage/data/aliasPropertyChangeSignals.qml new file mode 100644 index 0000000000..4e11b9174a --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/aliasPropertyChangeSignals.qml @@ -0,0 +1,16 @@ +import QtQuick 2.0 + +QtObject { + id: root + + property alias aliasProperty: root.realProperty + onAliasPropertyChanged: root.test = true + + property int realProperty: 0 + + property bool test: false + + Component.onCompleted: { + root.realProperty = 10; + } +} diff --git a/tests/auto/qml/qqmllanguage/data/allowedRevisionOverloads.qml b/tests/auto/qml/qqmllanguage/data/allowedRevisionOverloads.qml new file mode 100644 index 0000000000..64acbd1576 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/allowedRevisionOverloads.qml @@ -0,0 +1,6 @@ +import Test 1.0 + +MyRevisionedLegalOverload +{ +} + diff --git a/tests/auto/qml/qqmllanguage/data/assignBasicTypes.qml b/tests/auto/qml/qqmllanguage/data/assignBasicTypes.qml new file mode 100644 index 0000000000..28a340128d --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/assignBasicTypes.qml @@ -0,0 +1,28 @@ +import Test 1.0 +MyTypeObject { + flagProperty: "FlagVal1 | FlagVal3" + enumProperty: "EnumVal2" + stringProperty: "Hello World!" + uintProperty: 10 + intProperty: -19 + realProperty: 23.2 + doubleProperty: -19.7 + floatProperty: 8.5 + colorProperty: "red" + dateProperty: "1982-11-25" + timeProperty: "11:11:32" + dateTimeProperty: "2009-05-12T13:22:01" + pointProperty: "99,13" + pointFProperty: "-10.1,12.3" + sizeProperty: "99x13" + sizeFProperty: "0.1x0.2" + rectProperty: "9,7,100x200" + rectFProperty: "1000.1,-10.9,400x90.99" + boolProperty: true + variantProperty: "Hello World!" + vectorProperty: "10,1,2.2" + vector4Property: "10,1,2.2,2.3" + urlProperty: "main.qml?with%3cencoded%3edata" + + objectProperty: MyTypeObject { intProperty: 8 } +} diff --git a/tests/auto/qml/qqmllanguage/data/assignCompositeToType.qml b/tests/auto/qml/qqmllanguage/data/assignCompositeToType.qml new file mode 100644 index 0000000000..717cd84536 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/assignCompositeToType.qml @@ -0,0 +1,18 @@ +import QtQuick 2.0 +import Test 1.0 + +QtObject { + property QtObject myProperty + property QtObject myProperty2 + property QtObject myProperty3 + property QtObject myProperty4 + property MyQmlObject myProperty5 + property MyQmlObject myProperty6 + + myProperty: CompositeType {} + myProperty2: CompositeType2 {} + myProperty3: CompositeType3 {} + myProperty4: CompositeType4 {} + myProperty5: CompositeType2 {} + myProperty6: CompositeType4 {} +} diff --git a/tests/auto/qml/qqmllanguage/data/assignLiteralSignalProperty.qml b/tests/auto/qml/qqmllanguage/data/assignLiteralSignalProperty.qml new file mode 100644 index 0000000000..399fcea04d --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/assignLiteralSignalProperty.qml @@ -0,0 +1,4 @@ +import Test 1.0 +MyQmlObject { + onLiteralSignal: 10 +} diff --git a/tests/auto/qml/qqmllanguage/data/assignLiteralToVar.qml b/tests/auto/qml/qqmllanguage/data/assignLiteralToVar.qml new file mode 100644 index 0000000000..89e66c6172 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/assignLiteralToVar.qml @@ -0,0 +1,32 @@ +// This tests assigning literals to "var" properties. +// These properties store JavaScript object references. + +import QtQuick 2.0 + +QtObject { + property var test1: 1 + property var test2: 1.7 + property var test3: "Hello world!" + property var test4: "#FF008800" + property var test5: "10,10,10x10" + property var test6: "10,10" + property var test7: "10x10" + property var test8: "100,100,100" + property var test9: String("#FF008800") + property var test10: true + property var test11: false + + property variant variantTest1Bound: test1 + 4 // 1 + 4 + 4 = 9 + + property var test12: Qt.rgba(0.2, 0.3, 0.4, 0.5) + property var test13: Qt.rect(10, 10, 10, 10) + property var test14: Qt.point(10, 10) + property var test15: Qt.size(10, 10) + property var test16: Qt.vector3d(100, 100, 100) + + property var test1Bound: test1 + 6 // 1 + 4 + 6 = 11 + + Component.onCompleted: { + test1 = test1 + 4; + } +} diff --git a/tests/auto/qml/qqmllanguage/data/assignLiteralToVariant.qml b/tests/auto/qml/qqmllanguage/data/assignLiteralToVariant.qml new file mode 100644 index 0000000000..f6f9a139dc --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/assignLiteralToVariant.qml @@ -0,0 +1,17 @@ +import QtQuick 2.0 + +QtObject { + property variant test1: 1 + property variant test2: 1.7 + property variant test3: "Hello world!" + property variant test4: "#FF008800" + property variant test5: "10,10,10x10" + property variant test6: "10,10" + property variant test7: "10x10" + property variant test8: "100,100,100" + property variant test9: String("#FF008800") + property variant test10: true + property variant test11: false + property variant test12: "100,100,100,100" +} + diff --git a/tests/auto/qml/qqmllanguage/data/assignObjectToSignal.qml b/tests/auto/qml/qqmllanguage/data/assignObjectToSignal.qml new file mode 100644 index 0000000000..789cc66215 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/assignObjectToSignal.qml @@ -0,0 +1,4 @@ +import Test 1.0 +MyQmlObject { + onBasicSignal: MyQmlObject {} +} diff --git a/tests/auto/qml/qqmllanguage/data/assignObjectToVariant.qml b/tests/auto/qml/qqmllanguage/data/assignObjectToVariant.qml new file mode 100644 index 0000000000..1f731c539c --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/assignObjectToVariant.qml @@ -0,0 +1,7 @@ +import Test 1.0 +import QtQuick 2.0 + +QtObject { + property variant a; + a: MyQmlObject {} +} diff --git a/tests/auto/qml/qqmllanguage/data/assignQmlComponent.qml b/tests/auto/qml/qqmllanguage/data/assignQmlComponent.qml new file mode 100644 index 0000000000..20bdc559c1 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/assignQmlComponent.qml @@ -0,0 +1,4 @@ +import Test 1.0 +MyContainer { + MyComponent { x: 10; y: 11; } +} diff --git a/tests/auto/qml/qqmllanguage/data/assignSignal.qml b/tests/auto/qml/qqmllanguage/data/assignSignal.qml new file mode 100644 index 0000000000..2a48df8fcf --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/assignSignal.qml @@ -0,0 +1,5 @@ +import Test 1.0 +MyQmlObject { + onBasicSignal: basicSlot() + onBasicParameterizedSignal: basicSlotWithArgs(parameter) +} diff --git a/tests/auto/qml/qqmllanguage/data/assignToNamespace.errors.txt b/tests/auto/qml/qqmllanguage/data/assignToNamespace.errors.txt new file mode 100644 index 0000000000..78aa4713fb --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/assignToNamespace.errors.txt @@ -0,0 +1 @@ +4:5:Invalid use of namespace diff --git a/tests/auto/qml/qqmllanguage/data/assignToNamespace.qml b/tests/auto/qml/qqmllanguage/data/assignToNamespace.qml new file mode 100644 index 0000000000..54fef61ef0 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/assignToNamespace.qml @@ -0,0 +1,5 @@ +import QtQuick 2.0 as Qt47 + +Qt47.QtObject { + Qt47: 10 +} diff --git a/tests/auto/qml/qqmllanguage/data/assignTypeExtremes.qml b/tests/auto/qml/qqmllanguage/data/assignTypeExtremes.qml new file mode 100644 index 0000000000..60ede525e4 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/assignTypeExtremes.qml @@ -0,0 +1,5 @@ +import Test 1.0 +MyTypeObject { + uintProperty: 4000000000 + intProperty: -2000000000 +} diff --git a/tests/auto/qml/qqmllanguage/data/assignValueToSignal.errors.txt b/tests/auto/qml/qqmllanguage/data/assignValueToSignal.errors.txt new file mode 100644 index 0000000000..eb1430a715 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/assignValueToSignal.errors.txt @@ -0,0 +1 @@ +4:5:Cannot assign a value to a signal (expecting a script to be run) diff --git a/tests/auto/qml/qqmllanguage/data/assignValueToSignal.qml b/tests/auto/qml/qqmllanguage/data/assignValueToSignal.qml new file mode 100644 index 0000000000..6fa1259f39 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/assignValueToSignal.qml @@ -0,0 +1,6 @@ +import Test 1.0 + +MyQmlObject { + onBasicSignal: "hello world" +} + diff --git a/tests/auto/qml/qqmllanguage/data/attachedProperties.qml b/tests/auto/qml/qqmllanguage/data/attachedProperties.qml new file mode 100644 index 0000000000..3637ded26f --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/attachedProperties.qml @@ -0,0 +1,8 @@ +import Test 1.0 +import Test 1.0 as Namespace +import QtQuick 2.0 + +QtObject { + MyQmlObject.value: 10 + Namespace.MyQmlObject.value2: 13 +} diff --git a/tests/auto/qml/qqmllanguage/data/autoComponentCreation.qml b/tests/auto/qml/qqmllanguage/data/autoComponentCreation.qml new file mode 100644 index 0000000000..5d00144eaf --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/autoComponentCreation.qml @@ -0,0 +1,4 @@ +import Test 1.0 +MyTypeObject { + componentProperty : MyTypeObject { realProperty: 9 } +} diff --git a/tests/auto/qml/qqmllanguage/data/autoNotifyConnection.qml b/tests/auto/qml/qqmllanguage/data/autoNotifyConnection.qml new file mode 100644 index 0000000000..640fb54f99 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/autoNotifyConnection.qml @@ -0,0 +1,6 @@ +import Test 1.0 +MyQmlObject { + property bool receivedNotify : false + onPropertyWithNotifyChanged: { receivedNotify = true; } +} + diff --git a/tests/auto/qml/qqmllanguage/data/component.1.errors.txt b/tests/auto/qml/qqmllanguage/data/component.1.errors.txt new file mode 100644 index 0000000000..091aad61fa --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/component.1.errors.txt @@ -0,0 +1 @@ +3:1:Cannot create empty component specification diff --git a/tests/auto/qml/qqmllanguage/data/component.1.qml b/tests/auto/qml/qqmllanguage/data/component.1.qml new file mode 100644 index 0000000000..a22772bd89 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/component.1.qml @@ -0,0 +1,4 @@ +import QtQuick 2.0 + +Component { +} diff --git a/tests/auto/qml/qqmllanguage/data/component.2.errors.txt b/tests/auto/qml/qqmllanguage/data/component.2.errors.txt new file mode 100644 index 0000000000..76e7656a62 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/component.2.errors.txt @@ -0,0 +1 @@ +6:9:id is not unique diff --git a/tests/auto/qml/qqmllanguage/data/component.2.qml b/tests/auto/qml/qqmllanguage/data/component.2.qml new file mode 100644 index 0000000000..fbe315f771 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/component.2.qml @@ -0,0 +1,9 @@ +import QtQuick 2.0 + +Item { + id: myId + Component { + id: myId + QtObject {} + } +} diff --git a/tests/auto/qml/qqmllanguage/data/component.3.errors.txt b/tests/auto/qml/qqmllanguage/data/component.3.errors.txt new file mode 100644 index 0000000000..450fc163bd --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/component.3.errors.txt @@ -0,0 +1 @@ +6:9:Property value set multiple times diff --git a/tests/auto/qml/qqmllanguage/data/component.3.qml b/tests/auto/qml/qqmllanguage/data/component.3.qml new file mode 100644 index 0000000000..bac23ef903 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/component.3.qml @@ -0,0 +1,9 @@ +import QtQuick 2.0 + +Item { + Component { + id: myId + id: myId2 + QtObject {} + } +} diff --git a/tests/auto/qml/qqmllanguage/data/component.4.errors.txt b/tests/auto/qml/qqmllanguage/data/component.4.errors.txt new file mode 100644 index 0000000000..2ab18685c8 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/component.4.errors.txt @@ -0,0 +1 @@ +3:1:Invalid component body specification diff --git a/tests/auto/qml/qqmllanguage/data/component.4.qml b/tests/auto/qml/qqmllanguage/data/component.4.qml new file mode 100644 index 0000000000..d07695477d --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/component.4.qml @@ -0,0 +1,6 @@ +import QtQuick 2.0 + +Component { + QtObject {} + QtObject {} +} diff --git a/tests/auto/qml/qqmllanguage/data/component.5.errors.txt b/tests/auto/qml/qqmllanguage/data/component.5.errors.txt new file mode 100644 index 0000000000..e3c2df755f --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/component.5.errors.txt @@ -0,0 +1 @@ +4:5:Component elements may not contain properties other than id diff --git a/tests/auto/qml/qqmllanguage/data/component.5.qml b/tests/auto/qml/qqmllanguage/data/component.5.qml new file mode 100644 index 0000000000..9867377bb9 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/component.5.qml @@ -0,0 +1,6 @@ +import QtQuick 2.0 + +Component { + x: 10 + QtObject {} +} diff --git a/tests/auto/qml/qqmllanguage/data/component.6.errors.txt b/tests/auto/qml/qqmllanguage/data/component.6.errors.txt new file mode 100644 index 0000000000..2b1c6ca606 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/component.6.errors.txt @@ -0,0 +1 @@ +4:5:Invalid component id specification diff --git a/tests/auto/qml/qqmllanguage/data/component.6.qml b/tests/auto/qml/qqmllanguage/data/component.6.qml new file mode 100644 index 0000000000..010949a35f --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/component.6.qml @@ -0,0 +1,6 @@ +import QtQuick 2.0 + +Component { + id: QtObject {} + QtObject {} +} diff --git a/tests/auto/qml/qqmllanguage/data/component.7.errors.txt b/tests/auto/qml/qqmllanguage/data/component.7.errors.txt new file mode 100644 index 0000000000..b144814a70 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/component.7.errors.txt @@ -0,0 +1 @@ +3:1:Component objects cannot declare new properties. diff --git a/tests/auto/qml/qqmllanguage/data/component.7.qml b/tests/auto/qml/qqmllanguage/data/component.7.qml new file mode 100644 index 0000000000..b1a31195eb --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/component.7.qml @@ -0,0 +1,7 @@ +import QtQuick 2.0 + +Component { + property int a + QtObject {} +} + diff --git a/tests/auto/qml/qqmllanguage/data/component.8.errors.txt b/tests/auto/qml/qqmllanguage/data/component.8.errors.txt new file mode 100644 index 0000000000..6f2d0d201d --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/component.8.errors.txt @@ -0,0 +1 @@ +3:1:Component objects cannot declare new signals. diff --git a/tests/auto/qml/qqmllanguage/data/component.8.qml b/tests/auto/qml/qqmllanguage/data/component.8.qml new file mode 100644 index 0000000000..fb7a079d39 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/component.8.qml @@ -0,0 +1,7 @@ +import QtQuick 2.0 + +Component { + signal a + QtObject {} +} + diff --git a/tests/auto/qml/qqmllanguage/data/component.9.errors.txt b/tests/auto/qml/qqmllanguage/data/component.9.errors.txt new file mode 100644 index 0000000000..92f1456895 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/component.9.errors.txt @@ -0,0 +1 @@ +3:1:Component objects cannot declare new functions. diff --git a/tests/auto/qml/qqmllanguage/data/component.9.qml b/tests/auto/qml/qqmllanguage/data/component.9.qml new file mode 100644 index 0000000000..17824b4ede --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/component.9.qml @@ -0,0 +1,7 @@ +import QtQuick 2.0 + +Component { + function a() {} + QtObject {} +} + diff --git a/tests/auto/qml/qqmllanguage/data/componentCompositeType.qml b/tests/auto/qml/qqmllanguage/data/componentCompositeType.qml new file mode 100644 index 0000000000..232b320fb0 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/componentCompositeType.qml @@ -0,0 +1,8 @@ +import QtQuick 2.0 + +QtObject { + property variant test + + test: ComponentComposite {} +} + diff --git a/tests/auto/qml/qqmllanguage/data/cppnamespace.2.qml b/tests/auto/qml/qqmllanguage/data/cppnamespace.2.qml new file mode 100644 index 0000000000..e3b32ca5d8 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/cppnamespace.2.qml @@ -0,0 +1,5 @@ +import Test 1.0 + +MySecondNamespacedType { + list: [ MyNamespacedType {} ] +} diff --git a/tests/auto/qml/qqmllanguage/data/cppnamespace.qml b/tests/auto/qml/qqmllanguage/data/cppnamespace.qml new file mode 100644 index 0000000000..e1daf3b78f --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/cppnamespace.qml @@ -0,0 +1,4 @@ +import Test 1.0 + +MyNamespacedType { +} diff --git a/tests/auto/qml/qqmllanguage/data/crash2.qml b/tests/auto/qml/qqmllanguage/data/crash2.qml new file mode 100644 index 0000000000..2b8d285348 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/crash2.qml @@ -0,0 +1,5 @@ +import QtQuick 2.0 + +QtObject { + objectName: "Hello" + "World" +} diff --git a/tests/auto/qml/qqmllanguage/data/customOnProperty.qml b/tests/auto/qml/qqmllanguage/data/customOnProperty.qml new file mode 100644 index 0000000000..57241ffc28 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/customOnProperty.qml @@ -0,0 +1,7 @@ +import QtQuick 2.0 + +QtObject { + property int on + + Component.onCompleted: on = 10 +} diff --git a/tests/auto/qml/qqmllanguage/data/customParserIdNotAllowed.errors.txt b/tests/auto/qml/qqmllanguage/data/customParserIdNotAllowed.errors.txt new file mode 100644 index 0000000000..43a8bb28b3 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/customParserIdNotAllowed.errors.txt @@ -0,0 +1 @@ +4:19:ListElement: cannot use reserved "id" property diff --git a/tests/auto/qml/qqmllanguage/data/customParserIdNotAllowed.qml b/tests/auto/qml/qqmllanguage/data/customParserIdNotAllowed.qml new file mode 100644 index 0000000000..c42173ddfb --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/customParserIdNotAllowed.qml @@ -0,0 +1,5 @@ +import QtQuick 2.0 +ListModel { + ListElement { a: 10 } + ListElement { id: foo; a: 12 } +} diff --git a/tests/auto/qml/qqmllanguage/data/customParserTypes.qml b/tests/auto/qml/qqmllanguage/data/customParserTypes.qml new file mode 100644 index 0000000000..76a8a4773f --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/customParserTypes.qml @@ -0,0 +1,5 @@ +import QtQuick 2.0 +ListModel { + ListElement { a: 10 } + ListElement { a: 12 } +} diff --git a/tests/auto/qml/qqmllanguage/data/customVariantTypes.qml b/tests/auto/qml/qqmllanguage/data/customVariantTypes.qml new file mode 100644 index 0000000000..0263ed20f2 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/customVariantTypes.qml @@ -0,0 +1,4 @@ +import Test 1.0 +MyQmlObject { + customType: "10" +} diff --git a/tests/auto/qml/qqmllanguage/data/declaredPropertyValues.qml b/tests/auto/qml/qqmllanguage/data/declaredPropertyValues.qml new file mode 100644 index 0000000000..03f5c1ff7e --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/declaredPropertyValues.qml @@ -0,0 +1,8 @@ +import QtQuick 2.0 + +QtObject { + property int a: 10 + property int b: 10 + a + property QtObject c: QtObject {} + property list d: [ QtObject {}, QtObject {} ] +} diff --git a/tests/auto/qml/qqmllanguage/data/defaultGrouped.errors.txt b/tests/auto/qml/qqmllanguage/data/defaultGrouped.errors.txt new file mode 100644 index 0000000000..32055f6608 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/defaultGrouped.errors.txt @@ -0,0 +1 @@ +7:9:Cannot assign a value directly to a grouped property diff --git a/tests/auto/qml/qqmllanguage/data/defaultGrouped.qml b/tests/auto/qml/qqmllanguage/data/defaultGrouped.qml new file mode 100644 index 0000000000..66a78eb67f --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/defaultGrouped.qml @@ -0,0 +1,10 @@ +import Test 1.0 +import QtQuick 2.0 + +MyTypeObject { + grouped { + script: console.log(1921) + QtObject {} + } +} + diff --git a/tests/auto/qml/qqmllanguage/data/defaultPropertyListOrder.qml b/tests/auto/qml/qqmllanguage/data/defaultPropertyListOrder.qml new file mode 100644 index 0000000000..31d17fd55f --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/defaultPropertyListOrder.qml @@ -0,0 +1,29 @@ +import Test 1.0 +import QtQuick 2.0 + +MyContainer { + QtObject { + property int index: 0 + } + + QtObject { + property int index: 1 + } + + children: [ + QtObject { + property int index: 2 + }, + QtObject { + property int index: 3 + } + ] + + QtObject { + property int index: 4 + } + + QtObject { + property int index: 5 + } +} diff --git a/tests/auto/qml/qqmllanguage/data/destroyedSignal.errors.txt b/tests/auto/qml/qqmllanguage/data/destroyedSignal.errors.txt new file mode 100644 index 0000000000..3348494a8f --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/destroyedSignal.errors.txt @@ -0,0 +1 @@ +4:5:Cannot assign to non-existent property "onDestroyed" diff --git a/tests/auto/qml/qqmllanguage/data/destroyedSignal.qml b/tests/auto/qml/qqmllanguage/data/destroyedSignal.qml new file mode 100644 index 0000000000..b5b29148a2 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/destroyedSignal.qml @@ -0,0 +1,5 @@ +import QtQuick 2.0 + +QtObject { + onDestroyed: print("Hello World!") +} diff --git a/tests/auto/qml/qqmllanguage/data/disallowedRevisionOverloads.errors.txt b/tests/auto/qml/qqmllanguage/data/disallowedRevisionOverloads.errors.txt new file mode 100644 index 0000000000..e9b449d8d9 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/disallowedRevisionOverloads.errors.txt @@ -0,0 +1 @@ +3:1:Type Test/MyRevisionedIllegalOverload 1.0 contains an illegal property "propA". This is an error in the type's implementation. diff --git a/tests/auto/qml/qqmllanguage/data/disallowedRevisionOverloads.qml b/tests/auto/qml/qqmllanguage/data/disallowedRevisionOverloads.qml new file mode 100644 index 0000000000..612bcfe0ea --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/disallowedRevisionOverloads.qml @@ -0,0 +1,7 @@ +import Test 1.0 + +MyRevisionedIllegalOverload +{ +} + + diff --git a/tests/auto/qml/qqmllanguage/data/dontDoubleCallClassBegin.qml b/tests/auto/qml/qqmllanguage/data/dontDoubleCallClassBegin.qml new file mode 100644 index 0000000000..905ee48e0b --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/dontDoubleCallClassBegin.qml @@ -0,0 +1,5 @@ +import QtQuick 2.0 + +Item { + property QtObject object: DontDoubleCallClassBeginItem {} +} diff --git a/tests/auto/qml/qqmllanguage/data/doubleSignal.errors.txt b/tests/auto/qml/qqmllanguage/data/doubleSignal.errors.txt new file mode 100644 index 0000000000..e1f7ec5bc2 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/doubleSignal.errors.txt @@ -0,0 +1 @@ +5:5:Property value set multiple times diff --git a/tests/auto/qml/qqmllanguage/data/doubleSignal.qml b/tests/auto/qml/qqmllanguage/data/doubleSignal.qml new file mode 100644 index 0000000000..fb07b9f659 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/doubleSignal.qml @@ -0,0 +1,7 @@ +import Test 1.0 + +MyQmlObject { + onBasicSignal: console.log(1921) + onBasicSignal: console.log(1921) +} + diff --git a/tests/auto/qml/qqmllanguage/data/duplicateIDs.errors.txt b/tests/auto/qml/qqmllanguage/data/duplicateIDs.errors.txt new file mode 100644 index 0000000000..66241cf1f2 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/duplicateIDs.errors.txt @@ -0,0 +1 @@ +4:19:id is not unique diff --git a/tests/auto/qml/qqmllanguage/data/duplicateIDs.qml b/tests/auto/qml/qqmllanguage/data/duplicateIDs.qml new file mode 100644 index 0000000000..a993abdd37 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/duplicateIDs.qml @@ -0,0 +1,6 @@ +import Test 1.0 +MyContainer { + MyQmlObject { id: myID } + MyQmlObject { id: myID } +} + diff --git a/tests/auto/qml/qqmllanguage/data/dynamicMeta.1.errors.txt b/tests/auto/qml/qqmllanguage/data/dynamicMeta.1.errors.txt new file mode 100644 index 0000000000..1f9f9169e9 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/dynamicMeta.1.errors.txt @@ -0,0 +1 @@ +5:5:Duplicate default property diff --git a/tests/auto/qml/qqmllanguage/data/dynamicMeta.1.qml b/tests/auto/qml/qqmllanguage/data/dynamicMeta.1.qml new file mode 100644 index 0000000000..3dbd5b0b2e --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/dynamicMeta.1.qml @@ -0,0 +1,6 @@ +import QtQuick 2.0 + +QtObject { + default property QtObject a + default property QtObject b +} diff --git a/tests/auto/qml/qqmllanguage/data/dynamicMeta.2.errors.txt b/tests/auto/qml/qqmllanguage/data/dynamicMeta.2.errors.txt new file mode 100644 index 0000000000..713d5f6272 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/dynamicMeta.2.errors.txt @@ -0,0 +1 @@ +5:19:Duplicate property name diff --git a/tests/auto/qml/qqmllanguage/data/dynamicMeta.2.qml b/tests/auto/qml/qqmllanguage/data/dynamicMeta.2.qml new file mode 100644 index 0000000000..5d4efeebb2 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/dynamicMeta.2.qml @@ -0,0 +1,6 @@ +import QtQuick 2.0 + +QtObject { + property int a + property bool a +} diff --git a/tests/auto/qml/qqmllanguage/data/dynamicMeta.3.errors.txt b/tests/auto/qml/qqmllanguage/data/dynamicMeta.3.errors.txt new file mode 100644 index 0000000000..8226c16a1e --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/dynamicMeta.3.errors.txt @@ -0,0 +1 @@ +5:12:Duplicate signal name diff --git a/tests/auto/qml/qqmllanguage/data/dynamicMeta.3.qml b/tests/auto/qml/qqmllanguage/data/dynamicMeta.3.qml new file mode 100644 index 0000000000..f084947eaf --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/dynamicMeta.3.qml @@ -0,0 +1,6 @@ +import QtQuick 2.0 + +QtObject { + signal a + signal a +} diff --git a/tests/auto/qml/qqmllanguage/data/dynamicMeta.4.errors.txt b/tests/auto/qml/qqmllanguage/data/dynamicMeta.4.errors.txt new file mode 100644 index 0000000000..028e25c37f --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/dynamicMeta.4.errors.txt @@ -0,0 +1 @@ +5:14:Duplicate method name diff --git a/tests/auto/qml/qqmllanguage/data/dynamicMeta.4.qml b/tests/auto/qml/qqmllanguage/data/dynamicMeta.4.qml new file mode 100644 index 0000000000..3691529aa9 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/dynamicMeta.4.qml @@ -0,0 +1,6 @@ +import QtQuick 2.0 + +QtObject { + function a() {} + function a() {} +} diff --git a/tests/auto/qml/qqmllanguage/data/dynamicMeta.5.errors.txt b/tests/auto/qml/qqmllanguage/data/dynamicMeta.5.errors.txt new file mode 100644 index 0000000000..015d55b03b --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/dynamicMeta.5.errors.txt @@ -0,0 +1 @@ +3:1:UnknownType is not a type diff --git a/tests/auto/qml/qqmllanguage/data/dynamicMeta.5.qml b/tests/auto/qml/qqmllanguage/data/dynamicMeta.5.qml new file mode 100644 index 0000000000..64ba907415 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/dynamicMeta.5.qml @@ -0,0 +1,5 @@ +import QtQuick 2.0 + +QtObject { + property UnknownType a +} diff --git a/tests/auto/qml/qqmllanguage/data/dynamicObject.1.qml b/tests/auto/qml/qqmllanguage/data/dynamicObject.1.qml new file mode 100644 index 0000000000..2214bacda0 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/dynamicObject.1.qml @@ -0,0 +1,8 @@ +import Test 1.0 +import QtQuick 2.0 +MyCustomParserType { + propa: a + 10 + propb: Math.min(a, 10) + propc: MyPropertyValueSource {} + onPropA: a +} diff --git a/tests/auto/qml/qqmllanguage/data/dynamicObjectProperties.2.qml b/tests/auto/qml/qqmllanguage/data/dynamicObjectProperties.2.qml new file mode 100644 index 0000000000..6f822ba157 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/dynamicObjectProperties.2.qml @@ -0,0 +1,11 @@ +import QtQuick 2.0 +import QtQuick 2.0 as Qt47 + +Qt.QtObject { + property Qt47.QtObject objectProperty + property list objectPropertyList + + objectProperty: QtObject {} + objectPropertyList: QtObject {} +} + diff --git a/tests/auto/qml/qqmllanguage/data/dynamicObjectProperties.qml b/tests/auto/qml/qqmllanguage/data/dynamicObjectProperties.qml new file mode 100644 index 0000000000..5d072b160a --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/dynamicObjectProperties.qml @@ -0,0 +1,13 @@ +import Test 1.0 +import QtQuick 2.0 +import QtQuick 2.0 as Qt47 + +QtObject { + property QtObject objectProperty + property QtObject objectProperty2 + objectProperty2: QtObject {} + + property MyComponent myComponentProperty + property MyComponent myComponentProperty2 + myComponentProperty2: MyComponent {} +} diff --git a/tests/auto/qml/qqmllanguage/data/dynamicProperties.qml b/tests/auto/qml/qqmllanguage/data/dynamicProperties.qml new file mode 100644 index 0000000000..cd403b3d46 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/dynamicProperties.qml @@ -0,0 +1,13 @@ +import Test 1.0 +import QtQuick 2.0 +QtObject { + default property int intProperty : 10 + property bool boolProperty: false + property double doubleProperty: -10.1 + property real realProperty: -19.9 + property string stringProperty: "Hello World!" + property color colorProperty: "red" + property url urlProperty: "main.qml" + property date dateProperty: "1945-09-02" + property variant varProperty: "Hello World!" +} diff --git a/tests/auto/qml/qqmllanguage/data/dynamicPropertiesNested.qml b/tests/auto/qml/qqmllanguage/data/dynamicPropertiesNested.qml new file mode 100644 index 0000000000..b86e89b5e7 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/dynamicPropertiesNested.qml @@ -0,0 +1,9 @@ +import QtQuick 2.0 + +DynamicPropertiesNestedType { + property int a: 13 + property int b: 12 + + super_a: 11 +} + diff --git a/tests/auto/qml/qqmllanguage/data/dynamicSignalsAndSlots.qml b/tests/auto/qml/qqmllanguage/data/dynamicSignalsAndSlots.qml new file mode 100644 index 0000000000..d80d94be09 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/dynamicSignalsAndSlots.qml @@ -0,0 +1,10 @@ +import QtQuick 2.0 +QtObject { + signal signal1 + function slot1() {} + signal signal2 + function slot2() {} + + property int test: 0 + function slot3(a) { console.log(1921); test = a; } +} diff --git a/tests/auto/qml/qqmllanguage/data/empty.errors.txt b/tests/auto/qml/qqmllanguage/data/empty.errors.txt new file mode 100644 index 0000000000..620db2bbba --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/empty.errors.txt @@ -0,0 +1,2 @@ +1:1:Expected token `numeric literal' +1:1:Expected a qualified name id diff --git a/tests/auto/qml/qqmllanguage/data/empty.qml b/tests/auto/qml/qqmllanguage/data/empty.qml new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/auto/qml/qqmllanguage/data/emptySignal.errors.txt b/tests/auto/qml/qqmllanguage/data/emptySignal.errors.txt new file mode 100644 index 0000000000..8b20434973 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/emptySignal.errors.txt @@ -0,0 +1 @@ +4:5:Incorrectly specified signal assignment diff --git a/tests/auto/qml/qqmllanguage/data/emptySignal.qml b/tests/auto/qml/qqmllanguage/data/emptySignal.qml new file mode 100644 index 0000000000..c84fea3fe6 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/emptySignal.qml @@ -0,0 +1,7 @@ +import Test 1.0 + +MyQmlObject { + onBasicSignal { + } +} + diff --git a/tests/auto/qml/qqmllanguage/data/enumTypes.errors.txt b/tests/auto/qml/qqmllanguage/data/enumTypes.errors.txt new file mode 100644 index 0000000000..d4e0cc0bc4 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/enumTypes.errors.txt @@ -0,0 +1 @@ +3:1:Element is not creatable. diff --git a/tests/auto/qml/qqmllanguage/data/enumTypes.qml b/tests/auto/qml/qqmllanguage/data/enumTypes.qml new file mode 100644 index 0000000000..ff083250f0 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/enumTypes.qml @@ -0,0 +1,4 @@ +import QtQuick 2.0 + +Font { +} diff --git a/tests/auto/qml/qqmllanguage/data/failingComponent.errors.txt b/tests/auto/qml/qqmllanguage/data/failingComponent.errors.txt new file mode 100644 index 0000000000..364ca6747f --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/failingComponent.errors.txt @@ -0,0 +1 @@ +3:5:FailingComponent is not a type diff --git a/tests/auto/qml/qqmllanguage/data/failingComponentTest.qml b/tests/auto/qml/qqmllanguage/data/failingComponentTest.qml new file mode 100644 index 0000000000..74a6acfc49 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/failingComponentTest.qml @@ -0,0 +1,4 @@ +import Test 1.0 +MyContainer { + FailingComponent {} +} diff --git a/tests/auto/qml/qqmllanguage/data/fakeDotProperty.errors.txt b/tests/auto/qml/qqmllanguage/data/fakeDotProperty.errors.txt new file mode 100644 index 0000000000..30748234bc --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/fakeDotProperty.errors.txt @@ -0,0 +1 @@ +3:5:Invalid grouped property access diff --git a/tests/auto/qml/qqmllanguage/data/fakeDotProperty.qml b/tests/auto/qml/qqmllanguage/data/fakeDotProperty.qml new file mode 100644 index 0000000000..d971eee4d0 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/fakeDotProperty.qml @@ -0,0 +1,4 @@ +import Test 1.0 +MyQmlObject { + value.something: "hello" +} diff --git a/tests/auto/qml/qqmllanguage/data/finalOverride.errors.txt b/tests/auto/qml/qqmllanguage/data/finalOverride.errors.txt new file mode 100644 index 0000000000..49e06cbdf5 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/finalOverride.errors.txt @@ -0,0 +1 @@ +3:5:Cannot override FINAL property diff --git a/tests/auto/qml/qqmllanguage/data/finalOverride.qml b/tests/auto/qml/qqmllanguage/data/finalOverride.qml new file mode 100644 index 0000000000..a84393af94 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/finalOverride.qml @@ -0,0 +1,4 @@ +import Test 1.0 +MyQmlObject { + property int value: 10 +} diff --git a/tests/auto/qml/qqmllanguage/data/i18nDeclaredPropertyNames.qml b/tests/auto/qml/qqmllanguage/data/i18nDeclaredPropertyNames.qml new file mode 100644 index 0000000000..558c836e52 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/i18nDeclaredPropertyNames.qml @@ -0,0 +1,6 @@ +import Test 1.0 + +MyTypeObject { + property int áâãäå: 10 + stringProperty: "Test áâãäå: " + áâãäå +} diff --git a/tests/auto/qml/qqmllanguage/data/i18nDeclaredPropertyUse.qml b/tests/auto/qml/qqmllanguage/data/i18nDeclaredPropertyUse.qml new file mode 100644 index 0000000000..74918e2764 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/i18nDeclaredPropertyUse.qml @@ -0,0 +1,3 @@ +I18n { + áâãäå: 15 +} diff --git a/tests/auto/qml/qqmllanguage/data/i18nNameSpace.qml b/tests/auto/qml/qqmllanguage/data/i18nNameSpace.qml new file mode 100644 index 0000000000..c0b2f94857 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/i18nNameSpace.qml @@ -0,0 +1,5 @@ +import Test 1.0 as Ãâãäå + +Ãâãäå.MyTypeObject { + stringProperty: "Test áâãäå: 40" +} diff --git a/tests/auto/qml/qqmllanguage/data/i18nScript.qml b/tests/auto/qml/qqmllanguage/data/i18nScript.qml new file mode 100644 index 0000000000..e77cb52074 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/i18nScript.qml @@ -0,0 +1,9 @@ +import Test 1.0 + +MyTypeObject { + function val() { + var áâãäå = 20 + return "Test áâãäå: " + áâãäå + } + stringProperty: val() +} diff --git a/tests/auto/qml/qqmllanguage/data/i18nStrings.qml b/tests/auto/qml/qqmllanguage/data/i18nStrings.qml new file mode 100644 index 0000000000..764c92639a --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/i18nStrings.qml @@ -0,0 +1,5 @@ +import Test 1.0 + +MyTypeObject { + stringProperty: "Test áâãäå (5 accented 'a' letters)" +} diff --git a/tests/auto/qml/qqmllanguage/data/i18nType.qml b/tests/auto/qml/qqmllanguage/data/i18nType.qml new file mode 100644 index 0000000000..d7954ef718 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/i18nType.qml @@ -0,0 +1 @@ +I18nTypeÃâãäå { } diff --git a/tests/auto/qml/qqmllanguage/data/idProperty.qml b/tests/auto/qml/qqmllanguage/data/idProperty.qml new file mode 100644 index 0000000000..bf048ea60a --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/idProperty.qml @@ -0,0 +1,8 @@ +import Test 1.0 +MyContainer { + property variant object : myObjectId + + MyTypeObject { + id: "myObjectId" + } +} diff --git a/tests/auto/qml/qqmllanguage/data/importFile.errors.txt b/tests/auto/qml/qqmllanguage/data/importFile.errors.txt new file mode 100644 index 0000000000..3fdac0921e --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/importFile.errors.txt @@ -0,0 +1 @@ +1:1:"MyComponent.qml": no such directory diff --git a/tests/auto/qml/qqmllanguage/data/importFile.qml b/tests/auto/qml/qqmllanguage/data/importFile.qml new file mode 100644 index 0000000000..a0d8410ca3 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/importFile.qml @@ -0,0 +1,3 @@ +import "MyComponent.qml" 1.0 + +MyComponent { text: "Hello" } diff --git a/tests/auto/qml/qqmllanguage/data/importIncorrectCase.qml b/tests/auto/qml/qqmllanguage/data/importIncorrectCase.qml new file mode 100644 index 0000000000..804e76b932 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/importIncorrectCase.qml @@ -0,0 +1,5 @@ +import QtQuick 2.0 +import com.Nokia.installedtest 1.0 + +QtObject { +} diff --git a/tests/auto/qml/qqmllanguage/data/importJs.1.errors.txt b/tests/auto/qml/qqmllanguage/data/importJs.1.errors.txt new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/auto/qml/qqmllanguage/data/importJs.1.qml b/tests/auto/qml/qqmllanguage/data/importJs.1.qml new file mode 100644 index 0000000000..eaba98ecd2 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/importJs.1.qml @@ -0,0 +1,12 @@ +import com.nokia.PureJsModule 1.0 +import QtQuick 2.0 + +Item { + property bool test: false + + Component.onCompleted: { + test = ((FirstAPI.greeting() == "Hello") && + (FirstAPI.major == 1) && + (FirstAPI.minor == 0)) + } +} diff --git a/tests/auto/qml/qqmllanguage/data/importJs.10.errors.txt b/tests/auto/qml/qqmllanguage/data/importJs.10.errors.txt new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/auto/qml/qqmllanguage/data/importJs.10.qml b/tests/auto/qml/qqmllanguage/data/importJs.10.qml new file mode 100644 index 0000000000..578ca47ea5 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/importJs.10.qml @@ -0,0 +1,16 @@ +import com.nokia.PureJsModule 1.0 as PJM +import com.nokia.PureJsModule 1.0 as AnotherName +import QtQuick 2.0 + +Item { + property bool test: false + + Component.onCompleted: { + test = ((PJM.FirstAPI.greeting() == "Hello") && + (PJM.FirstAPI.major == 1) && + (PJM.FirstAPI.minor == 0) && + (AnotherName.FirstAPI.greeting() == "Hello") && + (AnotherName.FirstAPI.major == 1) && + (AnotherName.FirstAPI.minor == 0)) + } +} diff --git a/tests/auto/qml/qqmllanguage/data/importJs.2.errors.txt b/tests/auto/qml/qqmllanguage/data/importJs.2.errors.txt new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/auto/qml/qqmllanguage/data/importJs.2.qml b/tests/auto/qml/qqmllanguage/data/importJs.2.qml new file mode 100644 index 0000000000..dd3d65c5dd --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/importJs.2.qml @@ -0,0 +1,12 @@ +import com.nokia.VersionedOnlyJsModule 9.0 +import QtQuick 2.0 + +Item { + property bool test: false + + Component.onCompleted: { + test = ((SomeAPI.greeting() == "Hey hey hey") && + (SomeAPI.major == 9) && + (SomeAPI.minor == 0)) + } +} diff --git a/tests/auto/qml/qqmllanguage/data/importJs.3.errors.txt b/tests/auto/qml/qqmllanguage/data/importJs.3.errors.txt new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/auto/qml/qqmllanguage/data/importJs.3.qml b/tests/auto/qml/qqmllanguage/data/importJs.3.qml new file mode 100644 index 0000000000..f59d445a56 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/importJs.3.qml @@ -0,0 +1,16 @@ +import com.nokia.PureJsModule 1.0 +import QtQuick 2.0 + +Item { + property bool test: false + + Component.onCompleted: { + test = ((FirstAPI.greeting() == "Hello") && + (FirstAPI.major == 1) && + (FirstAPI.minor == 0) && + (SecondAPI.greeting() == "Howdy") && + (SecondAPI.major == 1) && + (SecondAPI.minor == 5)) + + } +} diff --git a/tests/auto/qml/qqmllanguage/data/importJs.4.errors.txt b/tests/auto/qml/qqmllanguage/data/importJs.4.errors.txt new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/auto/qml/qqmllanguage/data/importJs.4.qml b/tests/auto/qml/qqmllanguage/data/importJs.4.qml new file mode 100644 index 0000000000..e7b74bac0a --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/importJs.4.qml @@ -0,0 +1,15 @@ +import com.nokia.PureJsModule 1.6 +import QtQuick 2.0 + +Item { + property bool test: false + + Component.onCompleted: { + test = ((FirstAPI.greeting() == "Good news, everybody!") && + (FirstAPI.major == 1) && + (FirstAPI.minor == 6) && + (SecondAPI.greeting() == "Howdy") && + (SecondAPI.major == 1) && + (SecondAPI.minor == 5)) + } +} diff --git a/tests/auto/qml/qqmllanguage/data/importJs.5.errors.txt b/tests/auto/qml/qqmllanguage/data/importJs.5.errors.txt new file mode 100644 index 0000000000..10dbc80297 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/importJs.5.errors.txt @@ -0,0 +1 @@ +1:1:module "com.nokia.VersionedOnlyJsModule" is not installed diff --git a/tests/auto/qml/qqmllanguage/data/importJs.5.qml b/tests/auto/qml/qqmllanguage/data/importJs.5.qml new file mode 100644 index 0000000000..a9ec20c72b --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/importJs.5.qml @@ -0,0 +1,6 @@ +import com.nokia.VersionedOnlyJsModule 1.0 +import QtQuick 2.0 + +Item { + property bool test: false +} diff --git a/tests/auto/qml/qqmllanguage/data/importJs.6.errors.txt b/tests/auto/qml/qqmllanguage/data/importJs.6.errors.txt new file mode 100644 index 0000000000..41c99702a2 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/importJs.6.errors.txt @@ -0,0 +1 @@ +2:1:"com.nokia.VersionedOnlyJsModule" is ambiguous. diff --git a/tests/auto/qml/qqmllanguage/data/importJs.6.qml b/tests/auto/qml/qqmllanguage/data/importJs.6.qml new file mode 100644 index 0000000000..6c4eb89551 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/importJs.6.qml @@ -0,0 +1,13 @@ +import com.nokia.VersionedOnlyJsModule 9.0 +import com.nokia.VersionedOnlyJsModule 9.0 +import QtQuick 2.0 + +Item { + property bool test: false + + Component.onCompleted: { + test = ((SomeAPI.greeting() == "Hey hey hey") && + (SomeAPI.major == 9) && + (SomeAPI.minor == 0)) + } +} diff --git a/tests/auto/qml/qqmllanguage/data/importJs.7.errors.txt b/tests/auto/qml/qqmllanguage/data/importJs.7.errors.txt new file mode 100644 index 0000000000..56bc4c548f --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/importJs.7.errors.txt @@ -0,0 +1 @@ +2:1:"com.nokia.PureJsModule" is ambiguous. diff --git a/tests/auto/qml/qqmllanguage/data/importJs.7.qml b/tests/auto/qml/qqmllanguage/data/importJs.7.qml new file mode 100644 index 0000000000..5523a158bd --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/importJs.7.qml @@ -0,0 +1,13 @@ +import com.nokia.PureJsModule 1.0 +import com.nokia.PureJsModule 1.6 +import QtQuick 2.0 + +Item { + property bool test: false + + Component.onCompleted: { + test = ((FirstAPI.greeting() == "Hello") && + (FirstAPI.major == 1) && + (FirstAPI.minor == 0)) + } +} diff --git a/tests/auto/qml/qqmllanguage/data/importJs.8.errors.txt b/tests/auto/qml/qqmllanguage/data/importJs.8.errors.txt new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/auto/qml/qqmllanguage/data/importJs.8.qml b/tests/auto/qml/qqmllanguage/data/importJs.8.qml new file mode 100644 index 0000000000..4ddedc31a8 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/importJs.8.qml @@ -0,0 +1,15 @@ +import com.nokia.PureJsModule 1.5 as PJM +import QtQuick 2.0 + +Item { + property bool test: false + + Component.onCompleted: { + test = ((PJM.FirstAPI.greeting() == "Hello") && + (PJM.FirstAPI.major == 1) && + (PJM.FirstAPI.minor == 0) && + (PJM.SecondAPI.greeting() == "Howdy") && + (PJM.SecondAPI.major == 1) && + (PJM.SecondAPI.minor == 5)) + } +} diff --git a/tests/auto/qml/qqmllanguage/data/importJs.9.errors.txt b/tests/auto/qml/qqmllanguage/data/importJs.9.errors.txt new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/auto/qml/qqmllanguage/data/importJs.9.qml b/tests/auto/qml/qqmllanguage/data/importJs.9.qml new file mode 100644 index 0000000000..351164ba41 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/importJs.9.qml @@ -0,0 +1,19 @@ +import com.nokia.PureJsModule 1.5 as PJM_1_5 +import com.nokia.PureJsModule 1.6 as PJM_1_6 +import QtQuick 2.0 + +Item { + property bool test: false + + Component.onCompleted: { + test = ((PJM_1_5.FirstAPI.greeting() == "Hello") && + (PJM_1_5.FirstAPI.major == 1) && + (PJM_1_5.FirstAPI.minor == 0) && + (PJM_1_5.SecondAPI.greeting() == "Howdy") && + (PJM_1_5.SecondAPI.major == 1) && + (PJM_1_5.SecondAPI.minor == 5) && + (PJM_1_6.FirstAPI.greeting() == "Good news, everybody!") && + (PJM_1_6.FirstAPI.major == 1) && + (PJM_1_6.FirstAPI.minor == 6)) + } +} diff --git a/tests/auto/qml/qqmllanguage/data/importNamespaceConflict.errors.txt b/tests/auto/qml/qqmllanguage/data/importNamespaceConflict.errors.txt new file mode 100644 index 0000000000..231998daf7 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/importNamespaceConflict.errors.txt @@ -0,0 +1 @@ +4:1:Namespace Rectangle cannot be used as a type diff --git a/tests/auto/qml/qqmllanguage/data/importNamespaceConflict.qml b/tests/auto/qml/qqmllanguage/data/importNamespaceConflict.qml new file mode 100644 index 0000000000..45ad40501b --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/importNamespaceConflict.qml @@ -0,0 +1,4 @@ +import Test 1.0 as Rectangle +import QtQuick 2.0 + +Rectangle { } diff --git a/tests/auto/qml/qqmllanguage/data/importNewerVersion.errors.txt b/tests/auto/qml/qqmllanguage/data/importNewerVersion.errors.txt new file mode 100644 index 0000000000..413f096384 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/importNewerVersion.errors.txt @@ -0,0 +1 @@ +1:1:module "Test" version 2.0 is not installed diff --git a/tests/auto/qml/qqmllanguage/data/importNewerVersion.qml b/tests/auto/qml/qqmllanguage/data/importNewerVersion.qml new file mode 100644 index 0000000000..c4a0d386a4 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/importNewerVersion.qml @@ -0,0 +1,3 @@ +import Test 2.0 + +MyTypeObject { } diff --git a/tests/auto/qml/qqmllanguage/data/importNonExist.errors.txt b/tests/auto/qml/qqmllanguage/data/importNonExist.errors.txt new file mode 100644 index 0000000000..1baf05cee0 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/importNonExist.errors.txt @@ -0,0 +1 @@ +2:1:"will-not-be-found": no such directory diff --git a/tests/auto/qml/qqmllanguage/data/importNonExist.qml b/tests/auto/qml/qqmllanguage/data/importNonExist.qml new file mode 100644 index 0000000000..5cbee0264b --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/importNonExist.qml @@ -0,0 +1,5 @@ +// imports... +import "will-not-be-found" +import QtQuick 2.0 + +Rectangle { } diff --git a/tests/auto/qml/qqmllanguage/data/importNonExistOlder.errors.txt b/tests/auto/qml/qqmllanguage/data/importNonExistOlder.errors.txt new file mode 100644 index 0000000000..dfa7a369ff --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/importNonExistOlder.errors.txt @@ -0,0 +1 @@ +1:1:module "Test" version 0.1 is not installed diff --git a/tests/auto/qml/qqmllanguage/data/importNonExistOlder.qml b/tests/auto/qml/qqmllanguage/data/importNonExistOlder.qml new file mode 100644 index 0000000000..18514b1efa --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/importNonExistOlder.qml @@ -0,0 +1,3 @@ +import Test 0.1 + +MyTypeObject { } diff --git a/tests/auto/qml/qqmllanguage/data/importVersionMissingBuiltIn.errors.txt b/tests/auto/qml/qqmllanguage/data/importVersionMissingBuiltIn.errors.txt new file mode 100644 index 0000000000..c7d880e79e --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/importVersionMissingBuiltIn.errors.txt @@ -0,0 +1 @@ +1:16:Library import requires a version diff --git a/tests/auto/qml/qqmllanguage/data/importVersionMissingBuiltIn.qml b/tests/auto/qml/qqmllanguage/data/importVersionMissingBuiltIn.qml new file mode 100644 index 0000000000..23ed566e15 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/importVersionMissingBuiltIn.qml @@ -0,0 +1,7 @@ +import Test as S + +S.MyQmlObject { + property real x; + property real y; +} + diff --git a/tests/auto/qml/qqmllanguage/data/importVersionMissingInstalled.errors.txt b/tests/auto/qml/qqmllanguage/data/importVersionMissingInstalled.errors.txt new file mode 100644 index 0000000000..89e58ee764 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/importVersionMissingInstalled.errors.txt @@ -0,0 +1 @@ +1:35:Library import requires a version diff --git a/tests/auto/qml/qqmllanguage/data/importVersionMissingInstalled.qml b/tests/auto/qml/qqmllanguage/data/importVersionMissingInstalled.qml new file mode 100644 index 0000000000..97ec22280f --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/importVersionMissingInstalled.qml @@ -0,0 +1,3 @@ +import com.nokia.installedtest as T + +T.InstalledTest {} diff --git a/tests/auto/qml/qqmllanguage/data/importscript.1.errors.txt b/tests/auto/qml/qqmllanguage/data/importscript.1.errors.txt new file mode 100644 index 0000000000..ebc936d153 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/importscript.1.errors.txt @@ -0,0 +1 @@ +1:8:Script import requires a qualifier diff --git a/tests/auto/qml/qqmllanguage/data/importscript.1.qml b/tests/auto/qml/qqmllanguage/data/importscript.1.qml new file mode 100644 index 0000000000..2b2ab6ba0d --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/importscript.1.qml @@ -0,0 +1,3 @@ +import "test.js" + +Item { } diff --git a/tests/auto/qml/qqmllanguage/data/incorrectCase.errors.insensitive.txt b/tests/auto/qml/qqmllanguage/data/incorrectCase.errors.insensitive.txt new file mode 100644 index 0000000000..3813680562 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/incorrectCase.errors.insensitive.txt @@ -0,0 +1,2 @@ +3:1:Type IncorrectCaseType unavailable +-1:-1:File name case mismatch diff --git a/tests/auto/qml/qqmllanguage/data/incorrectCase.errors.sensitive.txt b/tests/auto/qml/qqmllanguage/data/incorrectCase.errors.sensitive.txt new file mode 100644 index 0000000000..abed1a73f5 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/incorrectCase.errors.sensitive.txt @@ -0,0 +1 @@ +3:1:IncorrectCaseType is not a type diff --git a/tests/auto/qml/qqmllanguage/data/incorrectCase.qml b/tests/auto/qml/qqmllanguage/data/incorrectCase.qml new file mode 100644 index 0000000000..15b6dc3a6e --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/incorrectCase.qml @@ -0,0 +1,4 @@ +import QtQuick 2.0 + +IncorrectCaseType { +} diff --git a/tests/auto/qml/qqmllanguage/data/incorrectCaseType.qml b/tests/auto/qml/qqmllanguage/data/incorrectCaseType.qml new file mode 100644 index 0000000000..addc4265a9 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/incorrectCaseType.qml @@ -0,0 +1,4 @@ +import QtQuick 2.0 + +QtObject { +} diff --git a/tests/auto/qml/qqmllanguage/data/inlineAssignmentsOverrideBindings.qml b/tests/auto/qml/qqmllanguage/data/inlineAssignmentsOverrideBindings.qml new file mode 100644 index 0000000000..4390d22d45 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/inlineAssignmentsOverrideBindings.qml @@ -0,0 +1,6 @@ +import QtQuick 2.0 + +InlineAssignmentsOverrideBindingsType { + property int test: nested.value + nested.value: 11 +} diff --git a/tests/auto/qml/qqmllanguage/data/inlineQmlComponents.qml b/tests/auto/qml/qqmllanguage/data/inlineQmlComponents.qml new file mode 100644 index 0000000000..a6f277adb2 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/inlineQmlComponents.qml @@ -0,0 +1,10 @@ +import Test 1.0 +import QtQuick 2.0 +MyContainer { + Component { + id: myComponent + MyQmlObject { + value: 11 + } + } +} diff --git a/tests/auto/qml/qqmllanguage/data/insertedSemicolon.1.errors.txt b/tests/auto/qml/qqmllanguage/data/insertedSemicolon.1.errors.txt new file mode 100644 index 0000000000..651009cf05 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/insertedSemicolon.1.errors.txt @@ -0,0 +1 @@ +9:5:Expected a qualified name id diff --git a/tests/auto/qml/qqmllanguage/data/insertedSemicolon.1.qml b/tests/auto/qml/qqmllanguage/data/insertedSemicolon.1.qml new file mode 100644 index 0000000000..4e561b48b2 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/insertedSemicolon.1.qml @@ -0,0 +1,10 @@ +import Test 1.0 + +MyQmlObject { + function foo() + { + return + } + + 1223 +} diff --git a/tests/auto/qml/qqmllanguage/data/interfaceProperty.qml b/tests/auto/qml/qqmllanguage/data/interfaceProperty.qml new file mode 100644 index 0000000000..f85e3e4e5b --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/interfaceProperty.qml @@ -0,0 +1,5 @@ +import Test 1.0 +import QtQuick 2.0 +MyQmlObject { + interfaceProperty: MyQmlObject {} +} diff --git a/tests/auto/qml/qqmllanguage/data/interfaceQList.qml b/tests/auto/qml/qqmllanguage/data/interfaceQList.qml new file mode 100644 index 0000000000..c87dfae785 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/interfaceQList.qml @@ -0,0 +1,7 @@ +import Test 1.0 +MyContainer { + qlistInterfaces: [ + MyQmlObject {}, + MyQmlObject {} + ] +} diff --git a/tests/auto/qml/qqmllanguage/data/invalidAlias.1.errors.txt b/tests/auto/qml/qqmllanguage/data/invalidAlias.1.errors.txt new file mode 100644 index 0000000000..9848e48579 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/invalidAlias.1.errors.txt @@ -0,0 +1 @@ +3:1:No property alias location diff --git a/tests/auto/qml/qqmllanguage/data/invalidAlias.1.qml b/tests/auto/qml/qqmllanguage/data/invalidAlias.1.qml new file mode 100644 index 0000000000..8aab61e49e --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/invalidAlias.1.qml @@ -0,0 +1,5 @@ +import QtQuick 2.0 + +QtObject { + property alias a +} diff --git a/tests/auto/qml/qqmllanguage/data/invalidAlias.10.errors.txt b/tests/auto/qml/qqmllanguage/data/invalidAlias.10.errors.txt new file mode 100644 index 0000000000..93652a7042 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/invalidAlias.10.errors.txt @@ -0,0 +1 @@ +5:23:Invalid alias location diff --git a/tests/auto/qml/qqmllanguage/data/invalidAlias.10.qml b/tests/auto/qml/qqmllanguage/data/invalidAlias.10.qml new file mode 100644 index 0000000000..3ff7b16fd8 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/invalidAlias.10.qml @@ -0,0 +1,6 @@ +import Test 1.0 + +MyTypeObject { + id: root + property alias a: root.rectProperty.blah +} diff --git a/tests/auto/qml/qqmllanguage/data/invalidAlias.2.errors.txt b/tests/auto/qml/qqmllanguage/data/invalidAlias.2.errors.txt new file mode 100644 index 0000000000..3e15628a13 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/invalidAlias.2.errors.txt @@ -0,0 +1 @@ +4:23:Invalid alias location diff --git a/tests/auto/qml/qqmllanguage/data/invalidAlias.2.qml b/tests/auto/qml/qqmllanguage/data/invalidAlias.2.qml new file mode 100644 index 0000000000..b85b2584eb --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/invalidAlias.2.qml @@ -0,0 +1,6 @@ +import QtQuick 2.0 + +QtObject { + property alias a: 10 +} + diff --git a/tests/auto/qml/qqmllanguage/data/invalidAlias.3.errors.txt b/tests/auto/qml/qqmllanguage/data/invalidAlias.3.errors.txt new file mode 100644 index 0000000000..fbf1b580e2 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/invalidAlias.3.errors.txt @@ -0,0 +1 @@ +5:23:Invalid alias reference. An alias reference must be specified as , . or .. diff --git a/tests/auto/qml/qqmllanguage/data/invalidAlias.3.qml b/tests/auto/qml/qqmllanguage/data/invalidAlias.3.qml new file mode 100644 index 0000000000..a363373734 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/invalidAlias.3.qml @@ -0,0 +1,6 @@ +import Test 1.0 + +MyTypeObject { + id: root + property alias a: root.rectProperty.x.y +} diff --git a/tests/auto/qml/qqmllanguage/data/invalidAlias.4.errors.txt b/tests/auto/qml/qqmllanguage/data/invalidAlias.4.errors.txt new file mode 100644 index 0000000000..fbf1b580e2 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/invalidAlias.4.errors.txt @@ -0,0 +1 @@ +5:23:Invalid alias reference. An alias reference must be specified as , . or .. diff --git a/tests/auto/qml/qqmllanguage/data/invalidAlias.4.qml b/tests/auto/qml/qqmllanguage/data/invalidAlias.4.qml new file mode 100644 index 0000000000..cfdfca0590 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/invalidAlias.4.qml @@ -0,0 +1,7 @@ +import Test 1.0 + +MyTypeObject { + id: root + property alias a: print("Hello!") +} + diff --git a/tests/auto/qml/qqmllanguage/data/invalidAlias.5.errors.txt b/tests/auto/qml/qqmllanguage/data/invalidAlias.5.errors.txt new file mode 100644 index 0000000000..6f78e599d4 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/invalidAlias.5.errors.txt @@ -0,0 +1 @@ +5:23:Invalid alias reference. Unable to find id "otherroot" diff --git a/tests/auto/qml/qqmllanguage/data/invalidAlias.5.qml b/tests/auto/qml/qqmllanguage/data/invalidAlias.5.qml new file mode 100644 index 0000000000..0c1d5d7ef1 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/invalidAlias.5.qml @@ -0,0 +1,7 @@ +import Test 1.0 + +MyTypeObject { + id: root + property alias a: otherroot +} + diff --git a/tests/auto/qml/qqmllanguage/data/invalidAlias.6.errors.txt b/tests/auto/qml/qqmllanguage/data/invalidAlias.6.errors.txt new file mode 100644 index 0000000000..93652a7042 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/invalidAlias.6.errors.txt @@ -0,0 +1 @@ +5:23:Invalid alias location diff --git a/tests/auto/qml/qqmllanguage/data/invalidAlias.6.qml b/tests/auto/qml/qqmllanguage/data/invalidAlias.6.qml new file mode 100644 index 0000000000..edfdb24bcc --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/invalidAlias.6.qml @@ -0,0 +1,7 @@ +import Test 1.0 + +MyTypeObject { + id: root + property alias a: root.foobar +} + diff --git a/tests/auto/qml/qqmllanguage/data/invalidAlias.7.errors.txt b/tests/auto/qml/qqmllanguage/data/invalidAlias.7.errors.txt new file mode 100644 index 0000000000..93652a7042 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/invalidAlias.7.errors.txt @@ -0,0 +1 @@ +5:23:Invalid alias location diff --git a/tests/auto/qml/qqmllanguage/data/invalidAlias.7.qml b/tests/auto/qml/qqmllanguage/data/invalidAlias.7.qml new file mode 100644 index 0000000000..2a09648d57 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/invalidAlias.7.qml @@ -0,0 +1,6 @@ +import Test 1.0 + +MyTypeObject { + id: root + property alias a: root.nonScriptable +} diff --git a/tests/auto/qml/qqmllanguage/data/invalidAlias.8.errors.txt b/tests/auto/qml/qqmllanguage/data/invalidAlias.8.errors.txt new file mode 100644 index 0000000000..93652a7042 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/invalidAlias.8.errors.txt @@ -0,0 +1 @@ +5:23:Invalid alias location diff --git a/tests/auto/qml/qqmllanguage/data/invalidAlias.8.qml b/tests/auto/qml/qqmllanguage/data/invalidAlias.8.qml new file mode 100644 index 0000000000..4faa52d250 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/invalidAlias.8.qml @@ -0,0 +1,7 @@ +import Test 1.0 + +MyTypeObject { + id: root + property alias a: root.imaginary.x +} + diff --git a/tests/auto/qml/qqmllanguage/data/invalidAlias.9.errors.txt b/tests/auto/qml/qqmllanguage/data/invalidAlias.9.errors.txt new file mode 100644 index 0000000000..93652a7042 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/invalidAlias.9.errors.txt @@ -0,0 +1 @@ +5:23:Invalid alias location diff --git a/tests/auto/qml/qqmllanguage/data/invalidAlias.9.qml b/tests/auto/qml/qqmllanguage/data/invalidAlias.9.qml new file mode 100644 index 0000000000..f1839127b0 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/invalidAlias.9.qml @@ -0,0 +1,6 @@ +import Test 1.0 + +MyTypeObject { + id: root + property alias a: root.floatProperty.x +} diff --git a/tests/auto/qml/qqmllanguage/data/invalidAttachedProperty.1.errors.txt b/tests/auto/qml/qqmllanguage/data/invalidAttachedProperty.1.errors.txt new file mode 100644 index 0000000000..492bbb48fa --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/invalidAttachedProperty.1.errors.txt @@ -0,0 +1 @@ +5:17:Cannot assign to non-existent property "foo" diff --git a/tests/auto/qml/qqmllanguage/data/invalidAttachedProperty.1.qml b/tests/auto/qml/qqmllanguage/data/invalidAttachedProperty.1.qml new file mode 100644 index 0000000000..20864b9a41 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/invalidAttachedProperty.1.qml @@ -0,0 +1,7 @@ +import Test 1.0 +import QtQuick 2.0 + +QtObject { + MyQmlObject.foo: 10 +} + diff --git a/tests/auto/qml/qqmllanguage/data/invalidAttachedProperty.10.errors.txt b/tests/auto/qml/qqmllanguage/data/invalidAttachedProperty.10.errors.txt new file mode 100644 index 0000000000..ff2409bd2d --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/invalidAttachedProperty.10.errors.txt @@ -0,0 +1 @@ +5:15:Non-existent attached object diff --git a/tests/auto/qml/qqmllanguage/data/invalidAttachedProperty.10.qml b/tests/auto/qml/qqmllanguage/data/invalidAttachedProperty.10.qml new file mode 100644 index 0000000000..20906de606 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/invalidAttachedProperty.10.qml @@ -0,0 +1,6 @@ +import Test 1.0 as Namespace +import QtQuick 2.0 + +QtObject { + Namespace.MadeUpClass.foo: 10 +} diff --git a/tests/auto/qml/qqmllanguage/data/invalidAttachedProperty.11.errors.txt b/tests/auto/qml/qqmllanguage/data/invalidAttachedProperty.11.errors.txt new file mode 100644 index 0000000000..fee5050743 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/invalidAttachedProperty.11.errors.txt @@ -0,0 +1 @@ +5:15:Not an attached property name diff --git a/tests/auto/qml/qqmllanguage/data/invalidAttachedProperty.11.qml b/tests/auto/qml/qqmllanguage/data/invalidAttachedProperty.11.qml new file mode 100644 index 0000000000..95add15147 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/invalidAttachedProperty.11.qml @@ -0,0 +1,7 @@ +import Test 1.0 as Namespace +import QtQuick 2.0 + +QtObject { + Namespace.madeUpClass.foo: 10 +} + diff --git a/tests/auto/qml/qqmllanguage/data/invalidAttachedProperty.12.errors.txt b/tests/auto/qml/qqmllanguage/data/invalidAttachedProperty.12.errors.txt new file mode 100644 index 0000000000..189a795837 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/invalidAttachedProperty.12.errors.txt @@ -0,0 +1 @@ +4:13:Attached properties cannot be used here diff --git a/tests/auto/qml/qqmllanguage/data/invalidAttachedProperty.12.qml b/tests/auto/qml/qqmllanguage/data/invalidAttachedProperty.12.qml new file mode 100644 index 0000000000..7de503e766 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/invalidAttachedProperty.12.qml @@ -0,0 +1,6 @@ +import Test 1.0 + +MyTypeObject { + grouped.MyQmlObject.value: 10 +} + diff --git a/tests/auto/qml/qqmllanguage/data/invalidAttachedProperty.13.errors.txt b/tests/auto/qml/qqmllanguage/data/invalidAttachedProperty.13.errors.txt new file mode 100644 index 0000000000..46d7be2ac3 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/invalidAttachedProperty.13.errors.txt @@ -0,0 +1 @@ +5:9:Attached properties cannot be used here diff --git a/tests/auto/qml/qqmllanguage/data/invalidAttachedProperty.13.qml b/tests/auto/qml/qqmllanguage/data/invalidAttachedProperty.13.qml new file mode 100644 index 0000000000..986ab855c5 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/invalidAttachedProperty.13.qml @@ -0,0 +1,8 @@ +import Test 1.0 + +MyTypeObject { + grouped { + MyQmlObject.value: 10 + } +} + diff --git a/tests/auto/qml/qqmllanguage/data/invalidAttachedProperty.2.errors.txt b/tests/auto/qml/qqmllanguage/data/invalidAttachedProperty.2.errors.txt new file mode 100644 index 0000000000..34de769e13 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/invalidAttachedProperty.2.errors.txt @@ -0,0 +1 @@ +5:27:Cannot assign to non-existent property "foo" diff --git a/tests/auto/qml/qqmllanguage/data/invalidAttachedProperty.2.qml b/tests/auto/qml/qqmllanguage/data/invalidAttachedProperty.2.qml new file mode 100644 index 0000000000..050e619ff2 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/invalidAttachedProperty.2.qml @@ -0,0 +1,6 @@ +import Test 1.0 as Namespace +import QtQuick 2.0 + +QtObject { + Namespace.MyQmlObject.foo: 10 +} diff --git a/tests/auto/qml/qqmllanguage/data/invalidAttachedProperty.3.errors.txt b/tests/auto/qml/qqmllanguage/data/invalidAttachedProperty.3.errors.txt new file mode 100644 index 0000000000..05161c4d10 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/invalidAttachedProperty.3.errors.txt @@ -0,0 +1 @@ +5:5:Invalid attached object assignment diff --git a/tests/auto/qml/qqmllanguage/data/invalidAttachedProperty.3.qml b/tests/auto/qml/qqmllanguage/data/invalidAttachedProperty.3.qml new file mode 100644 index 0000000000..24b09a53d5 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/invalidAttachedProperty.3.qml @@ -0,0 +1,8 @@ +import Test 1.0 +import QtQuick 2.0 + +QtObject { + MyQmlObject: 10 +} + + diff --git a/tests/auto/qml/qqmllanguage/data/invalidAttachedProperty.4.errors.txt b/tests/auto/qml/qqmllanguage/data/invalidAttachedProperty.4.errors.txt new file mode 100644 index 0000000000..a208bcfaa7 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/invalidAttachedProperty.4.errors.txt @@ -0,0 +1 @@ +5:15:Invalid attached object assignment diff --git a/tests/auto/qml/qqmllanguage/data/invalidAttachedProperty.4.qml b/tests/auto/qml/qqmllanguage/data/invalidAttachedProperty.4.qml new file mode 100644 index 0000000000..fb38ee9536 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/invalidAttachedProperty.4.qml @@ -0,0 +1,7 @@ +import Test 1.0 as Namespace +import QtQuick 2.0 + +QtObject { + Namespace.MyQmlObject: 10 +} + diff --git a/tests/auto/qml/qqmllanguage/data/invalidAttachedProperty.5.errors.txt b/tests/auto/qml/qqmllanguage/data/invalidAttachedProperty.5.errors.txt new file mode 100644 index 0000000000..05161c4d10 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/invalidAttachedProperty.5.errors.txt @@ -0,0 +1 @@ +5:5:Invalid attached object assignment diff --git a/tests/auto/qml/qqmllanguage/data/invalidAttachedProperty.5.qml b/tests/auto/qml/qqmllanguage/data/invalidAttachedProperty.5.qml new file mode 100644 index 0000000000..789e42f7ef --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/invalidAttachedProperty.5.qml @@ -0,0 +1,7 @@ +import Test 1.0 +import QtQuick 2.0 + +QtObject { + MyQmlObject: QtObject {} +} + diff --git a/tests/auto/qml/qqmllanguage/data/invalidAttachedProperty.6.errors.txt b/tests/auto/qml/qqmllanguage/data/invalidAttachedProperty.6.errors.txt new file mode 100644 index 0000000000..6770e1f30b --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/invalidAttachedProperty.6.errors.txt @@ -0,0 +1 @@ +5:5:Non-existent attached object diff --git a/tests/auto/qml/qqmllanguage/data/invalidAttachedProperty.6.qml b/tests/auto/qml/qqmllanguage/data/invalidAttachedProperty.6.qml new file mode 100644 index 0000000000..9060a55d00 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/invalidAttachedProperty.6.qml @@ -0,0 +1,7 @@ +import Test 1.0 +import QtQuick 2.0 + +QtObject { + Test.MyQmlObject: QtObject {} +} + diff --git a/tests/auto/qml/qqmllanguage/data/invalidAttachedProperty.7.errors.txt b/tests/auto/qml/qqmllanguage/data/invalidAttachedProperty.7.errors.txt new file mode 100644 index 0000000000..6770e1f30b --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/invalidAttachedProperty.7.errors.txt @@ -0,0 +1 @@ +5:5:Non-existent attached object diff --git a/tests/auto/qml/qqmllanguage/data/invalidAttachedProperty.7.qml b/tests/auto/qml/qqmllanguage/data/invalidAttachedProperty.7.qml new file mode 100644 index 0000000000..47b6cc37d8 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/invalidAttachedProperty.7.qml @@ -0,0 +1,6 @@ +import Test 1.0 +import QtQuick 2.0 + +QtObject { + MyTypeObject.foo: 10 +} diff --git a/tests/auto/qml/qqmllanguage/data/invalidAttachedProperty.8.errors.txt b/tests/auto/qml/qqmllanguage/data/invalidAttachedProperty.8.errors.txt new file mode 100644 index 0000000000..ff2409bd2d --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/invalidAttachedProperty.8.errors.txt @@ -0,0 +1 @@ +5:15:Non-existent attached object diff --git a/tests/auto/qml/qqmllanguage/data/invalidAttachedProperty.8.qml b/tests/auto/qml/qqmllanguage/data/invalidAttachedProperty.8.qml new file mode 100644 index 0000000000..146934f7ac --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/invalidAttachedProperty.8.qml @@ -0,0 +1,6 @@ +import Test 1.0 as Namespace +import QtQuick 2.0 + +QtObject { + Namespace.MyTypeObject.foo: 10 +} diff --git a/tests/auto/qml/qqmllanguage/data/invalidAttachedProperty.9.errors.txt b/tests/auto/qml/qqmllanguage/data/invalidAttachedProperty.9.errors.txt new file mode 100644 index 0000000000..6770e1f30b --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/invalidAttachedProperty.9.errors.txt @@ -0,0 +1 @@ +5:5:Non-existent attached object diff --git a/tests/auto/qml/qqmllanguage/data/invalidAttachedProperty.9.qml b/tests/auto/qml/qqmllanguage/data/invalidAttachedProperty.9.qml new file mode 100644 index 0000000000..73724aa6e7 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/invalidAttachedProperty.9.qml @@ -0,0 +1,7 @@ +import Test 1.0 +import QtQuick 2.0 + +QtObject { + MadeUpClass.foo: 10 +} + diff --git a/tests/auto/qml/qqmllanguage/data/invalidGroupedProperty.1.errors.txt b/tests/auto/qml/qqmllanguage/data/invalidGroupedProperty.1.errors.txt new file mode 100644 index 0000000000..810fd31b41 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/invalidGroupedProperty.1.errors.txt @@ -0,0 +1 @@ +5:5:Invalid grouped property access diff --git a/tests/auto/qml/qqmllanguage/data/invalidGroupedProperty.1.qml b/tests/auto/qml/qqmllanguage/data/invalidGroupedProperty.1.qml new file mode 100644 index 0000000000..fa46b8242a --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/invalidGroupedProperty.1.qml @@ -0,0 +1,6 @@ +import QtQuick 2.0 + +QtObject { + property variant o; + o.blah: 10 +} diff --git a/tests/auto/qml/qqmllanguage/data/invalidGroupedProperty.10.errors.txt b/tests/auto/qml/qqmllanguage/data/invalidGroupedProperty.10.errors.txt new file mode 100644 index 0000000000..1fcb1b65f5 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/invalidGroupedProperty.10.errors.txt @@ -0,0 +1 @@ +4:14:Cannot assign a value directly to a grouped property diff --git a/tests/auto/qml/qqmllanguage/data/invalidGroupedProperty.10.qml b/tests/auto/qml/qqmllanguage/data/invalidGroupedProperty.10.qml new file mode 100644 index 0000000000..41aa3e2923 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/invalidGroupedProperty.10.qml @@ -0,0 +1,7 @@ +import Test 1.0 + +MyTypeObject { + grouped: "10x10" + grouped.value: 10 +} + diff --git a/tests/auto/qml/qqmllanguage/data/invalidGroupedProperty.2.errors.txt b/tests/auto/qml/qqmllanguage/data/invalidGroupedProperty.2.errors.txt new file mode 100644 index 0000000000..810fd31b41 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/invalidGroupedProperty.2.errors.txt @@ -0,0 +1 @@ +5:5:Invalid grouped property access diff --git a/tests/auto/qml/qqmllanguage/data/invalidGroupedProperty.2.qml b/tests/auto/qml/qqmllanguage/data/invalidGroupedProperty.2.qml new file mode 100644 index 0000000000..3e516738d6 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/invalidGroupedProperty.2.qml @@ -0,0 +1,7 @@ +import QtQuick 2.0 + +QtObject { + property int o; + o.blah: 10 +} + diff --git a/tests/auto/qml/qqmllanguage/data/invalidGroupedProperty.3.errors.txt b/tests/auto/qml/qqmllanguage/data/invalidGroupedProperty.3.errors.txt new file mode 100644 index 0000000000..f6d6f29fbf --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/invalidGroupedProperty.3.errors.txt @@ -0,0 +1 @@ +4:5:Invalid grouped property access diff --git a/tests/auto/qml/qqmllanguage/data/invalidGroupedProperty.3.qml b/tests/auto/qml/qqmllanguage/data/invalidGroupedProperty.3.qml new file mode 100644 index 0000000000..0bbfc4f529 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/invalidGroupedProperty.3.qml @@ -0,0 +1,5 @@ +import Test 1.0 + +MyQmlObject { + customType.x: 10 +} diff --git a/tests/auto/qml/qqmllanguage/data/invalidGroupedProperty.4.errors.txt b/tests/auto/qml/qqmllanguage/data/invalidGroupedProperty.4.errors.txt new file mode 100644 index 0000000000..69c68716d9 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/invalidGroupedProperty.4.errors.txt @@ -0,0 +1 @@ +4:5:Cannot assign to non-existent property "foo" diff --git a/tests/auto/qml/qqmllanguage/data/invalidGroupedProperty.4.qml b/tests/auto/qml/qqmllanguage/data/invalidGroupedProperty.4.qml new file mode 100644 index 0000000000..134fef9b0a --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/invalidGroupedProperty.4.qml @@ -0,0 +1,5 @@ +import Test 1.0 + +MyQmlObject { + foo.x: 10 +} diff --git a/tests/auto/qml/qqmllanguage/data/invalidGroupedProperty.5.errors.txt b/tests/auto/qml/qqmllanguage/data/invalidGroupedProperty.5.errors.txt new file mode 100644 index 0000000000..2c8a970da7 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/invalidGroupedProperty.5.errors.txt @@ -0,0 +1 @@ +4:18:Property assignment expected diff --git a/tests/auto/qml/qqmllanguage/data/invalidGroupedProperty.5.qml b/tests/auto/qml/qqmllanguage/data/invalidGroupedProperty.5.qml new file mode 100644 index 0000000000..55cefe66b9 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/invalidGroupedProperty.5.qml @@ -0,0 +1,5 @@ +import Test 1.0 + +MyTypeObject { + rectProperty.x.foo: 100 +} diff --git a/tests/auto/qml/qqmllanguage/data/invalidGroupedProperty.6.errors.txt b/tests/auto/qml/qqmllanguage/data/invalidGroupedProperty.6.errors.txt new file mode 100644 index 0000000000..e1f7ec5bc2 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/invalidGroupedProperty.6.errors.txt @@ -0,0 +1 @@ +5:5:Property value set multiple times diff --git a/tests/auto/qml/qqmllanguage/data/invalidGroupedProperty.6.qml b/tests/auto/qml/qqmllanguage/data/invalidGroupedProperty.6.qml new file mode 100644 index 0000000000..9ec33abe7b --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/invalidGroupedProperty.6.qml @@ -0,0 +1,6 @@ +import Test 1.0 + +MyTypeObject { + rectProperty.x: 100 + rectProperty.x: 101 +} diff --git a/tests/auto/qml/qqmllanguage/data/invalidGroupedProperty.7.errors.txt b/tests/auto/qml/qqmllanguage/data/invalidGroupedProperty.7.errors.txt new file mode 100644 index 0000000000..4a7e3830a8 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/invalidGroupedProperty.7.errors.txt @@ -0,0 +1 @@ +4:-1:Cannot set properties on nullGrouped as it is null diff --git a/tests/auto/qml/qqmllanguage/data/invalidGroupedProperty.7.qml b/tests/auto/qml/qqmllanguage/data/invalidGroupedProperty.7.qml new file mode 100644 index 0000000000..977539a357 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/invalidGroupedProperty.7.qml @@ -0,0 +1,5 @@ +import Test 1.0 + +MyTypeObject { + nullGrouped.script: console.log(1921) +} diff --git a/tests/auto/qml/qqmllanguage/data/invalidGroupedProperty.8.errors.txt b/tests/auto/qml/qqmllanguage/data/invalidGroupedProperty.8.errors.txt new file mode 100644 index 0000000000..fa0da21c55 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/invalidGroupedProperty.8.errors.txt @@ -0,0 +1 @@ +5:19:Property has already been assigned a value diff --git a/tests/auto/qml/qqmllanguage/data/invalidGroupedProperty.8.qml b/tests/auto/qml/qqmllanguage/data/invalidGroupedProperty.8.qml new file mode 100644 index 0000000000..56fca9b990 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/invalidGroupedProperty.8.qml @@ -0,0 +1,6 @@ +import Test 1.0 + +MyTypeObject { + pointProperty: "10x10" + pointProperty.x: 10 +} diff --git a/tests/auto/qml/qqmllanguage/data/invalidGroupedProperty.9.errors.txt b/tests/auto/qml/qqmllanguage/data/invalidGroupedProperty.9.errors.txt new file mode 100644 index 0000000000..6d837a7222 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/invalidGroupedProperty.9.errors.txt @@ -0,0 +1 @@ +5:20:Property has already been assigned a value diff --git a/tests/auto/qml/qqmllanguage/data/invalidGroupedProperty.9.qml b/tests/auto/qml/qqmllanguage/data/invalidGroupedProperty.9.qml new file mode 100644 index 0000000000..982ab26051 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/invalidGroupedProperty.9.qml @@ -0,0 +1,6 @@ +import Test 1.0 + +MyTypeObject { + pointProperty.x: 10 + pointProperty: "10x10" +} diff --git a/tests/auto/qml/qqmllanguage/data/invalidID.2.errors.txt b/tests/auto/qml/qqmllanguage/data/invalidID.2.errors.txt new file mode 100644 index 0000000000..2c6b8bf0f3 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/invalidID.2.errors.txt @@ -0,0 +1,2 @@ +3:9:Invalid empty ID + diff --git a/tests/auto/qml/qqmllanguage/data/invalidID.2.qml b/tests/auto/qml/qqmllanguage/data/invalidID.2.qml new file mode 100644 index 0000000000..4fb3b298dd --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/invalidID.2.qml @@ -0,0 +1,5 @@ +import Test 1.0 +MyQmlObject { + id: "" +} + diff --git a/tests/auto/qml/qqmllanguage/data/invalidID.3.errors.txt b/tests/auto/qml/qqmllanguage/data/invalidID.3.errors.txt new file mode 100644 index 0000000000..bb811cfe9d --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/invalidID.3.errors.txt @@ -0,0 +1 @@ +3:5:Invalid use of id property diff --git a/tests/auto/qml/qqmllanguage/data/invalidID.3.qml b/tests/auto/qml/qqmllanguage/data/invalidID.3.qml new file mode 100644 index 0000000000..668417286b --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/invalidID.3.qml @@ -0,0 +1,5 @@ +import Test 1.0 +MyQmlObject { + id.other: 10 +} + diff --git a/tests/auto/qml/qqmllanguage/data/invalidID.4.errors.txt b/tests/auto/qml/qqmllanguage/data/invalidID.4.errors.txt new file mode 100644 index 0000000000..c721fe91bf --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/invalidID.4.errors.txt @@ -0,0 +1 @@ +4:5:Property value set multiple times diff --git a/tests/auto/qml/qqmllanguage/data/invalidID.4.qml b/tests/auto/qml/qqmllanguage/data/invalidID.4.qml new file mode 100644 index 0000000000..86010bf792 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/invalidID.4.qml @@ -0,0 +1,6 @@ +import Test 1.0 +MyQmlObject { + id: hello + id: world +} + diff --git a/tests/auto/qml/qqmllanguage/data/invalidID.5.errors.txt b/tests/auto/qml/qqmllanguage/data/invalidID.5.errors.txt new file mode 100644 index 0000000000..c167de382e --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/invalidID.5.errors.txt @@ -0,0 +1 @@ +2:20:Invalid import qualifier ID diff --git a/tests/auto/qml/qqmllanguage/data/invalidID.5.qml b/tests/auto/qml/qqmllanguage/data/invalidID.5.qml new file mode 100644 index 0000000000..5b92a1a0eb --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/invalidID.5.qml @@ -0,0 +1,6 @@ +import Test 1.0 +import Test 1.0 as hello +MyQmlObject { + id: hello +} + diff --git a/tests/auto/qml/qqmllanguage/data/invalidID.6.errors.txt b/tests/auto/qml/qqmllanguage/data/invalidID.6.errors.txt new file mode 100644 index 0000000000..7251de118f --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/invalidID.6.errors.txt @@ -0,0 +1 @@ +3:9:IDs cannot start with an uppercase letter diff --git a/tests/auto/qml/qqmllanguage/data/invalidID.6.qml b/tests/auto/qml/qqmllanguage/data/invalidID.6.qml new file mode 100644 index 0000000000..62187d9473 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/invalidID.6.qml @@ -0,0 +1,5 @@ +import Test 1.0 +MyQmlObject { + id: StartsWithUpperCase +} + diff --git a/tests/auto/qml/qqmllanguage/data/invalidID.7.errors.txt b/tests/auto/qml/qqmllanguage/data/invalidID.7.errors.txt new file mode 100644 index 0000000000..e4fd1db3f0 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/invalidID.7.errors.txt @@ -0,0 +1 @@ +3:9:ID illegally masks global JavaScript property diff --git a/tests/auto/qml/qqmllanguage/data/invalidID.7.qml b/tests/auto/qml/qqmllanguage/data/invalidID.7.qml new file mode 100644 index 0000000000..d4bc539650 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/invalidID.7.qml @@ -0,0 +1,5 @@ +import Test 1.0 +MyQmlObject { + id: gc +} + diff --git a/tests/auto/qml/qqmllanguage/data/invalidID.8.errors.txt b/tests/auto/qml/qqmllanguage/data/invalidID.8.errors.txt new file mode 100644 index 0000000000..b03ec6ccea --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/invalidID.8.errors.txt @@ -0,0 +1 @@ +3:9:IDs must contain only letters, numbers, and underscores diff --git a/tests/auto/qml/qqmllanguage/data/invalidID.8.qml b/tests/auto/qml/qqmllanguage/data/invalidID.8.qml new file mode 100644 index 0000000000..1ea615c32e --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/invalidID.8.qml @@ -0,0 +1,5 @@ +import Test 1.0 +MyQmlObject { + id: hello.world +} + diff --git a/tests/auto/qml/qqmllanguage/data/invalidID.9.errors.txt b/tests/auto/qml/qqmllanguage/data/invalidID.9.errors.txt new file mode 100644 index 0000000000..c010e79492 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/invalidID.9.errors.txt @@ -0,0 +1 @@ +3:9:IDs must start with a letter or underscore diff --git a/tests/auto/qml/qqmllanguage/data/invalidID.9.qml b/tests/auto/qml/qqmllanguage/data/invalidID.9.qml new file mode 100644 index 0000000000..57474b7212 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/invalidID.9.qml @@ -0,0 +1,5 @@ +import Test 1.0 +MyQmlObject { + id: "3hello" +} + diff --git a/tests/auto/qml/qqmllanguage/data/invalidID.errors.txt b/tests/auto/qml/qqmllanguage/data/invalidID.errors.txt new file mode 100644 index 0000000000..c010e79492 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/invalidID.errors.txt @@ -0,0 +1 @@ +3:9:IDs must start with a letter or underscore diff --git a/tests/auto/qml/qqmllanguage/data/invalidID.qml b/tests/auto/qml/qqmllanguage/data/invalidID.qml new file mode 100644 index 0000000000..04db3eb67c --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/invalidID.qml @@ -0,0 +1,4 @@ +import Test 1.0 +MyQmlObject { + id: 1 +} diff --git a/tests/auto/qml/qqmllanguage/data/invalidImportID.errors.txt b/tests/auto/qml/qqmllanguage/data/invalidImportID.errors.txt new file mode 100644 index 0000000000..034e937366 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/invalidImportID.errors.txt @@ -0,0 +1 @@ +2:23:Invalid import qualifier ID diff --git a/tests/auto/qml/qqmllanguage/data/invalidImportID.qml b/tests/auto/qml/qqmllanguage/data/invalidImportID.qml new file mode 100644 index 0000000000..37e7c5d4d0 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/invalidImportID.qml @@ -0,0 +1,4 @@ +import QtQuick 2.0 +import QtQuick 2.0 as qt + +QtObject {} diff --git a/tests/auto/qml/qqmllanguage/data/invalidOn.errors.txt b/tests/auto/qml/qqmllanguage/data/invalidOn.errors.txt new file mode 100644 index 0000000000..b4210a11fc --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/invalidOn.errors.txt @@ -0,0 +1 @@ +3:5:"MyQmlObject" cannot operate on "value" diff --git a/tests/auto/qml/qqmllanguage/data/invalidOn.qml b/tests/auto/qml/qqmllanguage/data/invalidOn.qml new file mode 100644 index 0000000000..d748bf4755 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/invalidOn.qml @@ -0,0 +1,4 @@ +import Test 1.0 +MyQmlObject { + MyQmlObject on value {} +} diff --git a/tests/auto/qml/qqmllanguage/data/invalidProperty.errors.txt b/tests/auto/qml/qqmllanguage/data/invalidProperty.errors.txt new file mode 100644 index 0000000000..e9e27c479b --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/invalidProperty.errors.txt @@ -0,0 +1 @@ +4:18:Illegal property name diff --git a/tests/auto/qml/qqmllanguage/data/invalidProperty.qml b/tests/auto/qml/qqmllanguage/data/invalidProperty.qml new file mode 100644 index 0000000000..f9b322e35c --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/invalidProperty.qml @@ -0,0 +1,5 @@ +import QtQuick 2.0 + +QtObject { + property int parseInt +} diff --git a/tests/auto/qml/qqmllanguage/data/invalidRoot.1.errors.txt b/tests/auto/qml/qqmllanguage/data/invalidRoot.1.errors.txt new file mode 100644 index 0000000000..eff7c0e6c4 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/invalidRoot.1.errors.txt @@ -0,0 +1 @@ +1:1:Expected a qualified name id diff --git a/tests/auto/qml/qqmllanguage/data/invalidRoot.1.qml b/tests/auto/qml/qqmllanguage/data/invalidRoot.1.qml new file mode 100644 index 0000000000..2c63c08510 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/invalidRoot.1.qml @@ -0,0 +1,2 @@ +{ +} diff --git a/tests/auto/qml/qqmllanguage/data/invalidRoot.2.errors.txt b/tests/auto/qml/qqmllanguage/data/invalidRoot.2.errors.txt new file mode 100644 index 0000000000..4bcc948e92 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/invalidRoot.2.errors.txt @@ -0,0 +1 @@ +1:1:Expected type name diff --git a/tests/auto/qml/qqmllanguage/data/invalidRoot.2.qml b/tests/auto/qml/qqmllanguage/data/invalidRoot.2.qml new file mode 100644 index 0000000000..427827ca89 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/invalidRoot.2.qml @@ -0,0 +1,2 @@ +foo { +} diff --git a/tests/auto/qml/qqmllanguage/data/invalidRoot.3.errors.txt b/tests/auto/qml/qqmllanguage/data/invalidRoot.3.errors.txt new file mode 100644 index 0000000000..fdce1abf06 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/invalidRoot.3.errors.txt @@ -0,0 +1 @@ +3:5:Expected type name diff --git a/tests/auto/qml/qqmllanguage/data/invalidRoot.3.qml b/tests/auto/qml/qqmllanguage/data/invalidRoot.3.qml new file mode 100644 index 0000000000..65e93ed55d --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/invalidRoot.3.qml @@ -0,0 +1,4 @@ +import QtQuick 2.0 as Foo + +Foo.foo { +} diff --git a/tests/auto/qml/qqmllanguage/data/invalidRoot.4.errors.txt b/tests/auto/qml/qqmllanguage/data/invalidRoot.4.errors.txt new file mode 100644 index 0000000000..3b90f573a2 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/invalidRoot.4.errors.txt @@ -0,0 +1 @@ +3:1:Bar.Item - Bar is not a namespace diff --git a/tests/auto/qml/qqmllanguage/data/invalidRoot.4.qml b/tests/auto/qml/qqmllanguage/data/invalidRoot.4.qml new file mode 100644 index 0000000000..ba4c8ae1f7 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/invalidRoot.4.qml @@ -0,0 +1,4 @@ +import QtQuick 2.0 as Foo + +Bar.Item { +} diff --git a/tests/auto/qml/qqmllanguage/data/invalidTypeName.1.errors.txt b/tests/auto/qml/qqmllanguage/data/invalidTypeName.1.errors.txt new file mode 100644 index 0000000000..4bcc948e92 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/invalidTypeName.1.errors.txt @@ -0,0 +1 @@ +1:1:Expected type name diff --git a/tests/auto/qml/qqmllanguage/data/invalidTypeName.1.qml b/tests/auto/qml/qqmllanguage/data/invalidTypeName.1.qml new file mode 100644 index 0000000000..658b72d9f2 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/invalidTypeName.1.qml @@ -0,0 +1,2 @@ +item { +} diff --git a/tests/auto/qml/qqmllanguage/data/invalidTypeName.2.errors.txt b/tests/auto/qml/qqmllanguage/data/invalidTypeName.2.errors.txt new file mode 100644 index 0000000000..fdce1abf06 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/invalidTypeName.2.errors.txt @@ -0,0 +1 @@ +3:5:Expected type name diff --git a/tests/auto/qml/qqmllanguage/data/invalidTypeName.2.qml b/tests/auto/qml/qqmllanguage/data/invalidTypeName.2.qml new file mode 100644 index 0000000000..9c83238282 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/invalidTypeName.2.qml @@ -0,0 +1,5 @@ +import QtQuick 2.0 as Foo + +Foo.item { +} + diff --git a/tests/auto/qml/qqmllanguage/data/invalidTypeName.3.errors.txt b/tests/auto/qml/qqmllanguage/data/invalidTypeName.3.errors.txt new file mode 100644 index 0000000000..208df2b84a --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/invalidTypeName.3.errors.txt @@ -0,0 +1 @@ +5:9:Expected type name diff --git a/tests/auto/qml/qqmllanguage/data/invalidTypeName.3.qml b/tests/auto/qml/qqmllanguage/data/invalidTypeName.3.qml new file mode 100644 index 0000000000..2f7027081e --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/invalidTypeName.3.qml @@ -0,0 +1,7 @@ +import QtQuick 2.0 as Foo + +Foo.Item { + + Foo.item { + } +} diff --git a/tests/auto/qml/qqmllanguage/data/invalidTypeName.4.errors.txt b/tests/auto/qml/qqmllanguage/data/invalidTypeName.4.errors.txt new file mode 100644 index 0000000000..3b90f573a2 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/invalidTypeName.4.errors.txt @@ -0,0 +1 @@ +3:1:Bar.Item - Bar is not a namespace diff --git a/tests/auto/qml/qqmllanguage/data/invalidTypeName.4.qml b/tests/auto/qml/qqmllanguage/data/invalidTypeName.4.qml new file mode 100644 index 0000000000..ba4c8ae1f7 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/invalidTypeName.4.qml @@ -0,0 +1,4 @@ +import QtQuick 2.0 as Foo + +Bar.Item { +} diff --git a/tests/auto/qml/qqmllanguage/data/lib/com/nokia/PureJsModule.1.6/FirstAPI.1.6.js b/tests/auto/qml/qqmllanguage/data/lib/com/nokia/PureJsModule.1.6/FirstAPI.1.6.js new file mode 100644 index 0000000000..c7b3c8b6ca --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/lib/com/nokia/PureJsModule.1.6/FirstAPI.1.6.js @@ -0,0 +1,5 @@ +var major = 1 +var minor = 6 + +function greeting() { return "Good news, everybody!" } + diff --git a/tests/auto/qml/qqmllanguage/data/lib/com/nokia/PureJsModule.1.6/FirstAPI.js b/tests/auto/qml/qqmllanguage/data/lib/com/nokia/PureJsModule.1.6/FirstAPI.js new file mode 100644 index 0000000000..b90033eeb4 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/lib/com/nokia/PureJsModule.1.6/FirstAPI.js @@ -0,0 +1,5 @@ +var major = 1 +var minor = 0 + +function greeting() { return "Hello" } + diff --git a/tests/auto/qml/qqmllanguage/data/lib/com/nokia/PureJsModule.1.6/SecondAPI.js b/tests/auto/qml/qqmllanguage/data/lib/com/nokia/PureJsModule.1.6/SecondAPI.js new file mode 100644 index 0000000000..b802477cb6 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/lib/com/nokia/PureJsModule.1.6/SecondAPI.js @@ -0,0 +1,5 @@ +var major = 1 +var minor = 5 + +function greeting() { return "Howdy" } + diff --git a/tests/auto/qml/qqmllanguage/data/lib/com/nokia/PureJsModule.1.6/qmldir b/tests/auto/qml/qqmllanguage/data/lib/com/nokia/PureJsModule.1.6/qmldir new file mode 100644 index 0000000000..083afb051c --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/lib/com/nokia/PureJsModule.1.6/qmldir @@ -0,0 +1,3 @@ +FirstAPI 1.0 FirstAPI.js +FirstAPI 1.6 FirstAPI.1.6.js +SecondAPI 1.5 SecondAPI.js diff --git a/tests/auto/qml/qqmllanguage/data/lib/com/nokia/PureJsModule/FirstAPI.js b/tests/auto/qml/qqmllanguage/data/lib/com/nokia/PureJsModule/FirstAPI.js new file mode 100644 index 0000000000..b90033eeb4 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/lib/com/nokia/PureJsModule/FirstAPI.js @@ -0,0 +1,5 @@ +var major = 1 +var minor = 0 + +function greeting() { return "Hello" } + diff --git a/tests/auto/qml/qqmllanguage/data/lib/com/nokia/PureJsModule/SecondAPI.js b/tests/auto/qml/qqmllanguage/data/lib/com/nokia/PureJsModule/SecondAPI.js new file mode 100644 index 0000000000..b802477cb6 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/lib/com/nokia/PureJsModule/SecondAPI.js @@ -0,0 +1,5 @@ +var major = 1 +var minor = 5 + +function greeting() { return "Howdy" } + diff --git a/tests/auto/qml/qqmllanguage/data/lib/com/nokia/PureJsModule/qmldir b/tests/auto/qml/qqmllanguage/data/lib/com/nokia/PureJsModule/qmldir new file mode 100644 index 0000000000..5c3acebd39 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/lib/com/nokia/PureJsModule/qmldir @@ -0,0 +1,2 @@ +FirstAPI 1.0 FirstAPI.js +SecondAPI 1.5 SecondAPI.js diff --git a/tests/auto/qml/qqmllanguage/data/lib/com/nokia/VersionedOnlyJsModule.9.0/SomeAPI.js b/tests/auto/qml/qqmllanguage/data/lib/com/nokia/VersionedOnlyJsModule.9.0/SomeAPI.js new file mode 100644 index 0000000000..efac613fc2 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/lib/com/nokia/VersionedOnlyJsModule.9.0/SomeAPI.js @@ -0,0 +1,5 @@ +var major = 9 +var minor = 0 + +function greeting() { return "Hey hey hey" } + diff --git a/tests/auto/qml/qqmllanguage/data/lib/com/nokia/VersionedOnlyJsModule.9.0/qmldir b/tests/auto/qml/qqmllanguage/data/lib/com/nokia/VersionedOnlyJsModule.9.0/qmldir new file mode 100644 index 0000000000..5c1b182028 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/lib/com/nokia/VersionedOnlyJsModule.9.0/qmldir @@ -0,0 +1 @@ +SomeAPI 9.0 SomeAPI.js diff --git a/tests/auto/qml/qqmllanguage/data/lib/com/nokia/installedtest/InstalledTest.qml b/tests/auto/qml/qqmllanguage/data/lib/com/nokia/installedtest/InstalledTest.qml new file mode 100644 index 0000000000..56daa9c09a --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/lib/com/nokia/installedtest/InstalledTest.qml @@ -0,0 +1,2 @@ +import QtQuick 2.0 as Qt47 +Qt47.Rectangle {} diff --git a/tests/auto/qml/qqmllanguage/data/lib/com/nokia/installedtest/InstalledTest2.qml b/tests/auto/qml/qqmllanguage/data/lib/com/nokia/installedtest/InstalledTest2.qml new file mode 100644 index 0000000000..59df88216e --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/lib/com/nokia/installedtest/InstalledTest2.qml @@ -0,0 +1,2 @@ +import QtQuick 2.0 +Text {} diff --git a/tests/auto/qml/qqmllanguage/data/lib/com/nokia/installedtest/LocalLast.qml b/tests/auto/qml/qqmllanguage/data/lib/com/nokia/installedtest/LocalLast.qml new file mode 100644 index 0000000000..26a5d6bba9 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/lib/com/nokia/installedtest/LocalLast.qml @@ -0,0 +1,2 @@ +import QtQuick 2.0 +Rectangle {} diff --git a/tests/auto/qml/qqmllanguage/data/lib/com/nokia/installedtest/PrivateType.qml b/tests/auto/qml/qqmllanguage/data/lib/com/nokia/installedtest/PrivateType.qml new file mode 100644 index 0000000000..ed1b09e419 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/lib/com/nokia/installedtest/PrivateType.qml @@ -0,0 +1,2 @@ +import QtQuick 2.0 +Image {} diff --git a/tests/auto/qml/qqmllanguage/data/lib/com/nokia/installedtest/qmldir b/tests/auto/qml/qqmllanguage/data/lib/com/nokia/installedtest/qmldir new file mode 100644 index 0000000000..d15720a154 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/lib/com/nokia/installedtest/qmldir @@ -0,0 +1,4 @@ +Rectangle 1.5 InstalledTest2.qml +LocalLast 1.0 LocalLast.qml +InstalledTest 1.4 InstalledTest2.qml +InstalledTest 1.0 InstalledTest.qml diff --git a/tests/auto/qml/qqmllanguage/data/lib/com/nokia/installedtest0/InstalledTest.qml b/tests/auto/qml/qqmllanguage/data/lib/com/nokia/installedtest0/InstalledTest.qml new file mode 100644 index 0000000000..56daa9c09a --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/lib/com/nokia/installedtest0/InstalledTest.qml @@ -0,0 +1,2 @@ +import QtQuick 2.0 as Qt47 +Qt47.Rectangle {} diff --git a/tests/auto/qml/qqmllanguage/data/lib/com/nokia/installedtest0/InstalledTest2.qml b/tests/auto/qml/qqmllanguage/data/lib/com/nokia/installedtest0/InstalledTest2.qml new file mode 100644 index 0000000000..59df88216e --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/lib/com/nokia/installedtest0/InstalledTest2.qml @@ -0,0 +1,2 @@ +import QtQuick 2.0 +Text {} diff --git a/tests/auto/qml/qqmllanguage/data/lib/com/nokia/installedtest0/qmldir b/tests/auto/qml/qqmllanguage/data/lib/com/nokia/installedtest0/qmldir new file mode 100644 index 0000000000..b301226099 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/lib/com/nokia/installedtest0/qmldir @@ -0,0 +1,2 @@ +InstalledTest 1.4 InstalledTest2.qml +InstalledTestTP 0.0 InstalledTest.qml diff --git a/tests/auto/qml/qqmllanguage/data/listAssignment.1.errors.txt b/tests/auto/qml/qqmllanguage/data/listAssignment.1.errors.txt new file mode 100644 index 0000000000..35d2d3510e --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/listAssignment.1.errors.txt @@ -0,0 +1 @@ +4:24:Cannot assign object to list diff --git a/tests/auto/qml/qqmllanguage/data/listAssignment.1.qml b/tests/auto/qml/qqmllanguage/data/listAssignment.1.qml new file mode 100644 index 0000000000..1af190633d --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/listAssignment.1.qml @@ -0,0 +1,6 @@ +import Test 1.0 +import QtQuick 2.0 +MyContainer { + containerChildren: QtObject {} +} + diff --git a/tests/auto/qml/qqmllanguage/data/listAssignment.2.errors.txt b/tests/auto/qml/qqmllanguage/data/listAssignment.2.errors.txt new file mode 100644 index 0000000000..8b40aa3ebb --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/listAssignment.2.errors.txt @@ -0,0 +1,2 @@ +3:15:Cannot assign primitives to lists + diff --git a/tests/auto/qml/qqmllanguage/data/listAssignment.2.qml b/tests/auto/qml/qqmllanguage/data/listAssignment.2.qml new file mode 100644 index 0000000000..e3baadb46c --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/listAssignment.2.qml @@ -0,0 +1,4 @@ +import Test 1.0 +MyContainer { + children: 2 +} diff --git a/tests/auto/qml/qqmllanguage/data/listAssignment.3.errors.txt b/tests/auto/qml/qqmllanguage/data/listAssignment.3.errors.txt new file mode 100644 index 0000000000..c721fe91bf --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/listAssignment.3.errors.txt @@ -0,0 +1 @@ +4:5:Property value set multiple times diff --git a/tests/auto/qml/qqmllanguage/data/listAssignment.3.qml b/tests/auto/qml/qqmllanguage/data/listAssignment.3.qml new file mode 100644 index 0000000000..00c4c6b543 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/listAssignment.3.qml @@ -0,0 +1,6 @@ +import Test 1.0 +MyContainer { + children: childBinding.expression + children: childBinding2.expression +} + diff --git a/tests/auto/qml/qqmllanguage/data/listItemDeleteSelf.qml b/tests/auto/qml/qqmllanguage/data/listItemDeleteSelf.qml new file mode 100644 index 0000000000..74439c66d4 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/listItemDeleteSelf.qml @@ -0,0 +1,38 @@ +import QtQuick 2.0 + +Item { + ListModel { + id: fruitModel + ListElement { + name: "Apple" + cost: 2.45 + } + ListElement { + name: "Orange" + cost: 3.25 + } + ListElement { + name: "Banana" + cost: 1.95 + } + } + + Component { + id: fruitDelegate + Item { + width: 200; height: 50 + Text { text: name } + Text { text: '$'+cost; anchors.right: parent.right } + MouseArea { + anchors.fill: parent + onClicked: fruitModel.remove(index) + } + } + } + + ListView { + model: fruitModel + delegate: fruitDelegate + anchors.fill: parent + } +} diff --git a/tests/auto/qml/qqmllanguage/data/listProperties.qml b/tests/auto/qml/qqmllanguage/data/listProperties.qml new file mode 100644 index 0000000000..dcfe37d6fc --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/listProperties.qml @@ -0,0 +1,9 @@ +import QtQuick 2.0 + +QtObject { + property list listProperty + property int test: listProperty.length + + listProperty: [ QtObject{}, QtObject {} ] +} + diff --git a/tests/auto/qml/qqmllanguage/data/majorVersionIsolation.errors.txt b/tests/auto/qml/qqmllanguage/data/majorVersionIsolation.errors.txt new file mode 100644 index 0000000000..07d05d3d21 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/majorVersionIsolation.errors.txt @@ -0,0 +1 @@ +3:1:MyQmlObject is not a type diff --git a/tests/auto/qml/qqmllanguage/data/majorVersionIsolation.qml b/tests/auto/qml/qqmllanguage/data/majorVersionIsolation.qml new file mode 100644 index 0000000000..717ca76f05 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/majorVersionIsolation.qml @@ -0,0 +1,4 @@ +import Test.Version 2.0 + +MyQmlObject { +} diff --git a/tests/auto/qml/qqmllanguage/data/metaobjectRevision.1.errors.txt b/tests/auto/qml/qqmllanguage/data/metaobjectRevision.1.errors.txt new file mode 100644 index 0000000000..29342dc46e --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/metaobjectRevision.1.errors.txt @@ -0,0 +1 @@ +8:5:"MyRevisionedClass.prop2" is not available in Test 1.0. diff --git a/tests/auto/qml/qqmllanguage/data/metaobjectRevision.1.qml b/tests/auto/qml/qqmllanguage/data/metaobjectRevision.1.qml new file mode 100644 index 0000000000..fbb37705a1 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/metaobjectRevision.1.qml @@ -0,0 +1,9 @@ +// Check that a property in a later revision (prop2) cannot be assigned +import QtQuick 2.0 +import Test 1.0 + +MyRevisionedClass +{ + prop1: 1 + prop2: 2 +} diff --git a/tests/auto/qml/qqmllanguage/data/metaobjectRevision.2.errors.txt b/tests/auto/qml/qqmllanguage/data/metaobjectRevision.2.errors.txt new file mode 100644 index 0000000000..57b5764b08 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/metaobjectRevision.2.errors.txt @@ -0,0 +1 @@ +6:5:"MyRevisionedClass.onSignal2" is not available in Test 1.0. diff --git a/tests/auto/qml/qqmllanguage/data/metaobjectRevision.2.qml b/tests/auto/qml/qqmllanguage/data/metaobjectRevision.2.qml new file mode 100644 index 0000000000..8da7a2558f --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/metaobjectRevision.2.qml @@ -0,0 +1,7 @@ +import Test 1.0 + +MyRevisionedClass +{ + onSignal1: prop1 = 2 + onSignal2: prop1 = 3 +} diff --git a/tests/auto/qml/qqmllanguage/data/metaobjectRevision.3.errors.txt b/tests/auto/qml/qqmllanguage/data/metaobjectRevision.3.errors.txt new file mode 100644 index 0000000000..45364a044f --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/metaobjectRevision.3.errors.txt @@ -0,0 +1 @@ +9:5:"MyRevisionedClass.propD" is not available in Test 1.1. diff --git a/tests/auto/qml/qqmllanguage/data/metaobjectRevision.3.qml b/tests/auto/qml/qqmllanguage/data/metaobjectRevision.3.qml new file mode 100644 index 0000000000..195be2116a --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/metaobjectRevision.3.qml @@ -0,0 +1,10 @@ +import Test 1.1 + +MyRevisionedClass +{ + propA: 10 + propB: 10 + propC: 10 + // propD is in rev 1 of MyRevisionedClassUnregistered, but not registered in 1.1 + propD: 10 +} diff --git a/tests/auto/qml/qqmllanguage/data/method.1.errors.txt b/tests/auto/qml/qqmllanguage/data/method.1.errors.txt new file mode 100644 index 0000000000..98d0b9cefb --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/method.1.errors.txt @@ -0,0 +1 @@ +4:14:Method names cannot begin with an upper case letter diff --git a/tests/auto/qml/qqmllanguage/data/method.1.qml b/tests/auto/qml/qqmllanguage/data/method.1.qml new file mode 100644 index 0000000000..a888b1aaf4 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/method.1.qml @@ -0,0 +1,5 @@ +import QtQuick 2.0 + +QtObject { + function MyMethod() {} +} diff --git a/tests/auto/qml/qqmllanguage/data/missingObject.errors.txt b/tests/auto/qml/qqmllanguage/data/missingObject.errors.txt new file mode 100644 index 0000000000..b31b562de1 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/missingObject.errors.txt @@ -0,0 +1 @@ +1:10:Expected token `{' diff --git a/tests/auto/qml/qqmllanguage/data/missingObject.qml b/tests/auto/qml/qqmllanguage/data/missingObject.qml new file mode 100644 index 0000000000..2f17045869 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/missingObject.qml @@ -0,0 +1 @@ +something: 24 diff --git a/tests/auto/qml/qqmllanguage/data/missingSignal.errors.txt b/tests/auto/qml/qqmllanguage/data/missingSignal.errors.txt new file mode 100644 index 0000000000..f562246288 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/missingSignal.errors.txt @@ -0,0 +1 @@ +4:5:Cannot assign to non-existent property "onClicked" diff --git a/tests/auto/qml/qqmllanguage/data/missingSignal.qml b/tests/auto/qml/qqmllanguage/data/missingSignal.qml new file mode 100644 index 0000000000..92aefef8c4 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/missingSignal.qml @@ -0,0 +1,5 @@ +import Test 1.0 +import QtQuick 2.0 +QtObject { + onClicked: console.log("Hello world!") +} diff --git a/tests/auto/qml/qqmllanguage/data/missingValueTypeProperty.errors.txt b/tests/auto/qml/qqmllanguage/data/missingValueTypeProperty.errors.txt new file mode 100644 index 0000000000..caf7e55ba2 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/missingValueTypeProperty.errors.txt @@ -0,0 +1 @@ +4:18:Cannot assign to non-existent property "foo" diff --git a/tests/auto/qml/qqmllanguage/data/missingValueTypeProperty.qml b/tests/auto/qml/qqmllanguage/data/missingValueTypeProperty.qml new file mode 100644 index 0000000000..9a0fa6a26b --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/missingValueTypeProperty.qml @@ -0,0 +1,5 @@ +import Test 1.0 + +MyTypeObject { + rectProperty.foo: 9 +} diff --git a/tests/auto/qml/qqmllanguage/data/multiSet.1.errors.txt b/tests/auto/qml/qqmllanguage/data/multiSet.1.errors.txt new file mode 100644 index 0000000000..e1f7ec5bc2 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/multiSet.1.errors.txt @@ -0,0 +1 @@ +5:5:Property value set multiple times diff --git a/tests/auto/qml/qqmllanguage/data/multiSet.1.qml b/tests/auto/qml/qqmllanguage/data/multiSet.1.qml new file mode 100644 index 0000000000..649c49ee3a --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/multiSet.1.qml @@ -0,0 +1,7 @@ +import Test 1.0 + +MyTypeObject { + intProperty: 10 + intProperty: 11 +} + diff --git a/tests/auto/qml/qqmllanguage/data/multiSet.10.errors.txt b/tests/auto/qml/qqmllanguage/data/multiSet.10.errors.txt new file mode 100644 index 0000000000..e1f7ec5bc2 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/multiSet.10.errors.txt @@ -0,0 +1 @@ +5:5:Property value set multiple times diff --git a/tests/auto/qml/qqmllanguage/data/multiSet.10.qml b/tests/auto/qml/qqmllanguage/data/multiSet.10.qml new file mode 100644 index 0000000000..bc21db98f8 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/multiSet.10.qml @@ -0,0 +1,6 @@ +import Test 1.0 + +MyTypeObject { + property int a: 10 + a: 11 +} diff --git a/tests/auto/qml/qqmllanguage/data/multiSet.11.errors.txt b/tests/auto/qml/qqmllanguage/data/multiSet.11.errors.txt new file mode 100644 index 0000000000..e1f7ec5bc2 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/multiSet.11.errors.txt @@ -0,0 +1 @@ +5:5:Property value set multiple times diff --git a/tests/auto/qml/qqmllanguage/data/multiSet.11.qml b/tests/auto/qml/qqmllanguage/data/multiSet.11.qml new file mode 100644 index 0000000000..7d03139056 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/multiSet.11.qml @@ -0,0 +1,6 @@ +import Test 1.0 + +MyTypeObject { + rectProperty.x: 10 + rectProperty.x: 11 +} diff --git a/tests/auto/qml/qqmllanguage/data/multiSet.2.errors.txt b/tests/auto/qml/qqmllanguage/data/multiSet.2.errors.txt new file mode 100644 index 0000000000..e1f7ec5bc2 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/multiSet.2.errors.txt @@ -0,0 +1 @@ +5:5:Property value set multiple times diff --git a/tests/auto/qml/qqmllanguage/data/multiSet.2.qml b/tests/auto/qml/qqmllanguage/data/multiSet.2.qml new file mode 100644 index 0000000000..abcd216744 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/multiSet.2.qml @@ -0,0 +1,7 @@ +import Test 1.0 + +MyTypeObject { + intProperty: 10 + intProperty: a + 10 +} + diff --git a/tests/auto/qml/qqmllanguage/data/multiSet.3.errors.txt b/tests/auto/qml/qqmllanguage/data/multiSet.3.errors.txt new file mode 100644 index 0000000000..e1f7ec5bc2 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/multiSet.3.errors.txt @@ -0,0 +1 @@ +5:5:Property value set multiple times diff --git a/tests/auto/qml/qqmllanguage/data/multiSet.3.qml b/tests/auto/qml/qqmllanguage/data/multiSet.3.qml new file mode 100644 index 0000000000..77eaba0b32 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/multiSet.3.qml @@ -0,0 +1,7 @@ +import Test 1.0 + +MyTypeObject { + intProperty: a + 10 + intProperty: 10 +} + diff --git a/tests/auto/qml/qqmllanguage/data/multiSet.4.errors.txt b/tests/auto/qml/qqmllanguage/data/multiSet.4.errors.txt new file mode 100644 index 0000000000..e1f7ec5bc2 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/multiSet.4.errors.txt @@ -0,0 +1 @@ +5:5:Property value set multiple times diff --git a/tests/auto/qml/qqmllanguage/data/multiSet.4.qml b/tests/auto/qml/qqmllanguage/data/multiSet.4.qml new file mode 100644 index 0000000000..c16d04fea6 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/multiSet.4.qml @@ -0,0 +1,7 @@ +import Test 1.0 + +MyTypeObject { + intProperty: 10 + intProperty: MyTypeObject {} +} + diff --git a/tests/auto/qml/qqmllanguage/data/multiSet.5.errors.txt b/tests/auto/qml/qqmllanguage/data/multiSet.5.errors.txt new file mode 100644 index 0000000000..e1f7ec5bc2 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/multiSet.5.errors.txt @@ -0,0 +1 @@ +5:5:Property value set multiple times diff --git a/tests/auto/qml/qqmllanguage/data/multiSet.5.qml b/tests/auto/qml/qqmllanguage/data/multiSet.5.qml new file mode 100644 index 0000000000..2980c5b28c --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/multiSet.5.qml @@ -0,0 +1,6 @@ +import Test 1.0 + +MyContainer { + children: MyContainer {} + children: MyContainer {} +} diff --git a/tests/auto/qml/qqmllanguage/data/multiSet.6.errors.txt b/tests/auto/qml/qqmllanguage/data/multiSet.6.errors.txt new file mode 100644 index 0000000000..e1f7ec5bc2 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/multiSet.6.errors.txt @@ -0,0 +1 @@ +5:5:Property value set multiple times diff --git a/tests/auto/qml/qqmllanguage/data/multiSet.6.qml b/tests/auto/qml/qqmllanguage/data/multiSet.6.qml new file mode 100644 index 0000000000..492c720edc --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/multiSet.6.qml @@ -0,0 +1,7 @@ +import Test 1.0 + +MyContainer { + children: MyContainer {} + children: [ MyContainer {}, MyContainer {} ] +} + diff --git a/tests/auto/qml/qqmllanguage/data/multiSet.7.errors.txt b/tests/auto/qml/qqmllanguage/data/multiSet.7.errors.txt new file mode 100644 index 0000000000..e1f7ec5bc2 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/multiSet.7.errors.txt @@ -0,0 +1 @@ +5:5:Property value set multiple times diff --git a/tests/auto/qml/qqmllanguage/data/multiSet.7.qml b/tests/auto/qml/qqmllanguage/data/multiSet.7.qml new file mode 100644 index 0000000000..2a9c1d0de8 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/multiSet.7.qml @@ -0,0 +1,7 @@ +import Test 1.0 + +MyContainer { + children: [ MyContainer {}, MyContainer {} ] + children: MyContainer {} +} + diff --git a/tests/auto/qml/qqmllanguage/data/multiSet.8.errors.txt b/tests/auto/qml/qqmllanguage/data/multiSet.8.errors.txt new file mode 100644 index 0000000000..450fc163bd --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/multiSet.8.errors.txt @@ -0,0 +1 @@ +6:9:Property value set multiple times diff --git a/tests/auto/qml/qqmllanguage/data/multiSet.8.qml b/tests/auto/qml/qqmllanguage/data/multiSet.8.qml new file mode 100644 index 0000000000..052437ea18 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/multiSet.8.qml @@ -0,0 +1,8 @@ +import Test 1.0 + +MyTypeObject { + grouped { + value: 10 + value: 11 + } +} diff --git a/tests/auto/qml/qqmllanguage/data/multiSet.9.errors.txt b/tests/auto/qml/qqmllanguage/data/multiSet.9.errors.txt new file mode 100644 index 0000000000..e1f7ec5bc2 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/multiSet.9.errors.txt @@ -0,0 +1 @@ +5:5:Property value set multiple times diff --git a/tests/auto/qml/qqmllanguage/data/multiSet.9.qml b/tests/auto/qml/qqmllanguage/data/multiSet.9.qml new file mode 100644 index 0000000000..e2e954f778 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/multiSet.9.qml @@ -0,0 +1,6 @@ +import Test 1.0 + +MyTypeObject { + grouped.value: 10 + grouped.value: 11 +} diff --git a/tests/auto/qml/qqmllanguage/data/nestedComponentRoots.qml b/tests/auto/qml/qqmllanguage/data/nestedComponentRoots.qml new file mode 100644 index 0000000000..5e6c2a91c9 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/nestedComponentRoots.qml @@ -0,0 +1,4 @@ +import QtQuick 2.0 + +NestedComponentRoot { +} diff --git a/tests/auto/qml/qqmllanguage/data/nestedErrors.errors.txt b/tests/auto/qml/qqmllanguage/data/nestedErrors.errors.txt new file mode 100644 index 0000000000..53e752b641 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/nestedErrors.errors.txt @@ -0,0 +1,2 @@ +4:5:Type NestedErrorsType unavailable +4:8:Invalid property assignment: number expected diff --git a/tests/auto/qml/qqmllanguage/data/nestedErrors.qml b/tests/auto/qml/qqmllanguage/data/nestedErrors.qml new file mode 100644 index 0000000000..cc1df4d181 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/nestedErrors.qml @@ -0,0 +1,6 @@ +import QtQuick 2.0 + +Item { + NestedErrorsType {} +} + diff --git a/tests/auto/qml/qqmllanguage/data/noCreation.errors.txt b/tests/auto/qml/qqmllanguage/data/noCreation.errors.txt new file mode 100644 index 0000000000..23cd3f3504 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/noCreation.errors.txt @@ -0,0 +1 @@ +3:1:Keys is only available via attached properties diff --git a/tests/auto/qml/qqmllanguage/data/noCreation.qml b/tests/auto/qml/qqmllanguage/data/noCreation.qml new file mode 100644 index 0000000000..28852f1a0c --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/noCreation.qml @@ -0,0 +1,4 @@ +import QtQuick 2.0 + +Keys { +} diff --git a/tests/auto/qml/qqmllanguage/data/nonScriptableProperty.errors.txt b/tests/auto/qml/qqmllanguage/data/nonScriptableProperty.errors.txt new file mode 100644 index 0000000000..cdfa4b2ef2 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/nonScriptableProperty.errors.txt @@ -0,0 +1 @@ +4:5:Cannot assign to non-existent property "nonScriptable" diff --git a/tests/auto/qml/qqmllanguage/data/nonScriptableProperty.qml b/tests/auto/qml/qqmllanguage/data/nonScriptableProperty.qml new file mode 100644 index 0000000000..bd59bc80f9 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/nonScriptableProperty.qml @@ -0,0 +1,5 @@ +import Test 1.0 + +MyQmlObject { + nonScriptable: 11 +} diff --git a/tests/auto/qml/qqmllanguage/data/nonexistantProperty.1.errors.txt b/tests/auto/qml/qqmllanguage/data/nonexistantProperty.1.errors.txt new file mode 100644 index 0000000000..6bfce9a2c9 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/nonexistantProperty.1.errors.txt @@ -0,0 +1 @@ +2:15:Cannot assign to non-existent property "something" diff --git a/tests/auto/qml/qqmllanguage/data/nonexistantProperty.1.qml b/tests/auto/qml/qqmllanguage/data/nonexistantProperty.1.qml new file mode 100644 index 0000000000..df7406ce98 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/nonexistantProperty.1.qml @@ -0,0 +1,2 @@ +import Test 1.0 +MyQmlObject { something: 24 } diff --git a/tests/auto/qml/qqmllanguage/data/nonexistantProperty.2.errors.txt b/tests/auto/qml/qqmllanguage/data/nonexistantProperty.2.errors.txt new file mode 100644 index 0000000000..4b30056d59 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/nonexistantProperty.2.errors.txt @@ -0,0 +1 @@ +3:5:Cannot assign to non-existent property "something" diff --git a/tests/auto/qml/qqmllanguage/data/nonexistantProperty.2.qml b/tests/auto/qml/qqmllanguage/data/nonexistantProperty.2.qml new file mode 100644 index 0000000000..06ccd37905 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/nonexistantProperty.2.qml @@ -0,0 +1,4 @@ +import Test 1.0 +MyQmlObject { + something: 24 +} diff --git a/tests/auto/qml/qqmllanguage/data/nonexistantProperty.3.errors.txt b/tests/auto/qml/qqmllanguage/data/nonexistantProperty.3.errors.txt new file mode 100644 index 0000000000..4b30056d59 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/nonexistantProperty.3.errors.txt @@ -0,0 +1 @@ +3:5:Cannot assign to non-existent property "something" diff --git a/tests/auto/qml/qqmllanguage/data/nonexistantProperty.3.qml b/tests/auto/qml/qqmllanguage/data/nonexistantProperty.3.qml new file mode 100644 index 0000000000..5b08608862 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/nonexistantProperty.3.qml @@ -0,0 +1,4 @@ +import Test 1.0 +MyQmlObject { + something: 1 + 1 +} diff --git a/tests/auto/qml/qqmllanguage/data/nonexistantProperty.4.errors.txt b/tests/auto/qml/qqmllanguage/data/nonexistantProperty.4.errors.txt new file mode 100644 index 0000000000..4b30056d59 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/nonexistantProperty.4.errors.txt @@ -0,0 +1 @@ +3:5:Cannot assign to non-existent property "something" diff --git a/tests/auto/qml/qqmllanguage/data/nonexistantProperty.4.qml b/tests/auto/qml/qqmllanguage/data/nonexistantProperty.4.qml new file mode 100644 index 0000000000..65791919ba --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/nonexistantProperty.4.qml @@ -0,0 +1,4 @@ +import Test 1.0 +MyQmlObject { + something: ; +} diff --git a/tests/auto/qml/qqmllanguage/data/nonexistantProperty.5.errors.txt b/tests/auto/qml/qqmllanguage/data/nonexistantProperty.5.errors.txt new file mode 100644 index 0000000000..c07f2b99a2 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/nonexistantProperty.5.errors.txt @@ -0,0 +1 @@ +3:5:Expected a qualified name id diff --git a/tests/auto/qml/qqmllanguage/data/nonexistantProperty.5.qml b/tests/auto/qml/qqmllanguage/data/nonexistantProperty.5.qml new file mode 100644 index 0000000000..37af05731e --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/nonexistantProperty.5.qml @@ -0,0 +1,4 @@ +import Test 1.0 +MyQmlObject { + 24 +} diff --git a/tests/auto/qml/qqmllanguage/data/nonexistantProperty.6.errors.txt b/tests/auto/qml/qqmllanguage/data/nonexistantProperty.6.errors.txt new file mode 100644 index 0000000000..89925b74c2 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/nonexistantProperty.6.errors.txt @@ -0,0 +1 @@ +3:5:Cannot assign to non-existent default property diff --git a/tests/auto/qml/qqmllanguage/data/nonexistantProperty.6.qml b/tests/auto/qml/qqmllanguage/data/nonexistantProperty.6.qml new file mode 100644 index 0000000000..5cd55d0856 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/nonexistantProperty.6.qml @@ -0,0 +1,4 @@ +import Test 1.0 +MyQmlObject { + MyQmlObject {} +} diff --git a/tests/auto/qml/qqmllanguage/data/notAvailable.errors.txt b/tests/auto/qml/qqmllanguage/data/notAvailable.errors.txt new file mode 100644 index 0000000000..af95a53cc7 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/notAvailable.errors.txt @@ -0,0 +1 @@ +3:1:UnavailableType is unavailable for testing diff --git a/tests/auto/qml/qqmllanguage/data/notAvailable.qml b/tests/auto/qml/qqmllanguage/data/notAvailable.qml new file mode 100644 index 0000000000..7c3c7ee08d --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/notAvailable.qml @@ -0,0 +1,4 @@ +import Test 1.0 + +UnavailableType { +} diff --git a/tests/auto/qml/qqmllanguage/data/nullDotProperty.errors.txt b/tests/auto/qml/qqmllanguage/data/nullDotProperty.errors.txt new file mode 100644 index 0000000000..07a40949cd --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/nullDotProperty.errors.txt @@ -0,0 +1 @@ +3:-1:Cannot set properties on obj as it is null diff --git a/tests/auto/qml/qqmllanguage/data/nullDotProperty.qml b/tests/auto/qml/qqmllanguage/data/nullDotProperty.qml new file mode 100644 index 0000000000..4e36779b5c --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/nullDotProperty.qml @@ -0,0 +1,4 @@ +import Test 1.0 +MyDotPropertyObject { + obj.value: 1 +} diff --git a/tests/auto/qml/qqmllanguage/data/objectValueTypeProperty.errors.txt b/tests/auto/qml/qqmllanguage/data/objectValueTypeProperty.errors.txt new file mode 100644 index 0000000000..db7d9c0f60 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/objectValueTypeProperty.errors.txt @@ -0,0 +1 @@ +4:18:Unexpected object assignment diff --git a/tests/auto/qml/qqmllanguage/data/objectValueTypeProperty.qml b/tests/auto/qml/qqmllanguage/data/objectValueTypeProperty.qml new file mode 100644 index 0000000000..99247735dd --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/objectValueTypeProperty.qml @@ -0,0 +1,6 @@ +import Test 1.0 + +MyTypeObject { + rectProperty.x: MyTypeObject {} +} + diff --git a/tests/auto/qml/qqmllanguage/data/onCompleted.qml b/tests/auto/qml/qqmllanguage/data/onCompleted.qml new file mode 100644 index 0000000000..89e6777f8a --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/onCompleted.qml @@ -0,0 +1,17 @@ +import Test 1.0 +import QtQuick 2.0 + +MyTypeObject { + // We set a and b to ensure that onCompleted is executed after bindings and + // constants have been assigned + property int a: Math.min(6, 7) + Component.onCompleted: console.log("Completed " + a + " " + nestedObject.b) + + objectProperty: OnCompletedType { + qmlobjectProperty: MyQmlObject { + id: nestedObject + property int b: 10 + Component.onCompleted: console.log("Completed " + a + " " + nestedObject.b) + } + } +} diff --git a/tests/auto/qml/qqmllanguage/data/onDestruction.qml b/tests/auto/qml/qqmllanguage/data/onDestruction.qml new file mode 100644 index 0000000000..7d6da260b4 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/onDestruction.qml @@ -0,0 +1,17 @@ +import Test 1.0 +import QtQuick 2.0 + +MyTypeObject { + // We set a and b to ensure that onCompleted is executed after bindings and + // constants have been assigned + property int a: Math.min(6, 7) + Component.onDestruction: console.log("Destruction " + a + " " + nestedObject.b) + + objectProperty: OnDestructionType { + qmlobjectProperty: MyQmlObject { + id: nestedObject + property int b: 10 + Component.onDestruction: console.log("Destruction " + a + " " + nestedObject.b) + } + } +} diff --git a/tests/auto/qml/qqmllanguage/data/property.1.errors.txt b/tests/auto/qml/qqmllanguage/data/property.1.errors.txt new file mode 100644 index 0000000000..3ae6c4601b --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/property.1.errors.txt @@ -0,0 +1 @@ +4:14:Expected property type diff --git a/tests/auto/qml/qqmllanguage/data/property.1.qml b/tests/auto/qml/qqmllanguage/data/property.1.qml new file mode 100644 index 0000000000..6b43e6cc89 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/property.1.qml @@ -0,0 +1,5 @@ +import QtQuick 2.0 + +QtObject { + property blah a; +} diff --git a/tests/auto/qml/qqmllanguage/data/property.2.errors.txt b/tests/auto/qml/qqmllanguage/data/property.2.errors.txt new file mode 100644 index 0000000000..a18e21a01c --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/property.2.errors.txt @@ -0,0 +1 @@ +4:14:Unexpected property type modifier diff --git a/tests/auto/qml/qqmllanguage/data/property.2.qml b/tests/auto/qml/qqmllanguage/data/property.2.qml new file mode 100644 index 0000000000..e6aa00e730 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/property.2.qml @@ -0,0 +1,6 @@ +import QtQuick 2.0 + +QtObject { + property invalidmodifier a; +} + diff --git a/tests/auto/qml/qqmllanguage/data/property.3.errors.txt b/tests/auto/qml/qqmllanguage/data/property.3.errors.txt new file mode 100644 index 0000000000..5e09a25b57 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/property.3.errors.txt @@ -0,0 +1 @@ +4:14:Invalid property type modifier diff --git a/tests/auto/qml/qqmllanguage/data/property.3.qml b/tests/auto/qml/qqmllanguage/data/property.3.qml new file mode 100644 index 0000000000..978c1aa80b --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/property.3.qml @@ -0,0 +1,7 @@ +import QtQuick 2.0 + +QtObject { + property invalidmodifier a; +} + + diff --git a/tests/auto/qml/qqmllanguage/data/property.4.errors.txt b/tests/auto/qml/qqmllanguage/data/property.4.errors.txt new file mode 100644 index 0000000000..b447186849 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/property.4.errors.txt @@ -0,0 +1 @@ +5:1:Syntax error diff --git a/tests/auto/qml/qqmllanguage/data/property.4.qml b/tests/auto/qml/qqmllanguage/data/property.4.qml new file mode 100644 index 0000000000..bb94e84244 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/property.4.qml @@ -0,0 +1,5 @@ +import QtQuick 2.0 + +QtObject { + readonly property int a +} diff --git a/tests/auto/qml/qqmllanguage/data/property.6.errors.txt b/tests/auto/qml/qqmllanguage/data/property.6.errors.txt new file mode 100644 index 0000000000..985c083cc3 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/property.6.errors.txt @@ -0,0 +1 @@ +4:18:Property names cannot begin with an upper case letter diff --git a/tests/auto/qml/qqmllanguage/data/property.6.qml b/tests/auto/qml/qqmllanguage/data/property.6.qml new file mode 100644 index 0000000000..88f493f9a9 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/property.6.qml @@ -0,0 +1,6 @@ +import QtQuick 2.0 + +QtObject { + property int Hello +} + diff --git a/tests/auto/qml/qqmllanguage/data/property.7.errors.txt b/tests/auto/qml/qqmllanguage/data/property.7.errors.txt new file mode 100644 index 0000000000..985c083cc3 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/property.7.errors.txt @@ -0,0 +1 @@ +4:18:Property names cannot begin with an upper case letter diff --git a/tests/auto/qml/qqmllanguage/data/property.7.qml b/tests/auto/qml/qqmllanguage/data/property.7.qml new file mode 100644 index 0000000000..05eb319947 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/property.7.qml @@ -0,0 +1,5 @@ +import QtQuick 2.0 + +QtObject { + property int Hello: 10 +} diff --git a/tests/auto/qml/qqmllanguage/data/propertyInit.1.qml b/tests/auto/qml/qqmllanguage/data/propertyInit.1.qml new file mode 100644 index 0000000000..7d6fea24db --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/propertyInit.1.qml @@ -0,0 +1,5 @@ +import QtQuick 2.0 + +QtObject { + property int test: { var _ = 1; _ } +} diff --git a/tests/auto/qml/qqmllanguage/data/propertyInit.2.qml b/tests/auto/qml/qqmllanguage/data/propertyInit.2.qml new file mode 100644 index 0000000000..fa690ba6bc --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/propertyInit.2.qml @@ -0,0 +1,6 @@ +import QtQuick 2.0 + +QtObject { + property int test: if (b == 1) 123; else 321; + property int b: 1 +} diff --git a/tests/auto/qml/qqmllanguage/data/propertyValueSource.2.qml b/tests/auto/qml/qqmllanguage/data/propertyValueSource.2.qml new file mode 100644 index 0000000000..e48526abec --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/propertyValueSource.2.qml @@ -0,0 +1,5 @@ +import Test 1.0 +MyTypeObject { + MyCompositeValueSource on intProperty {} +} + diff --git a/tests/auto/qml/qqmllanguage/data/propertyValueSource.qml b/tests/auto/qml/qqmllanguage/data/propertyValueSource.qml new file mode 100644 index 0000000000..22aa68250e --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/propertyValueSource.qml @@ -0,0 +1,4 @@ +import Test 1.0 +MyTypeObject { + MyPropertyValueSource on intProperty {} +} diff --git a/tests/auto/qml/qqmllanguage/data/qmlAttachedPropertiesObjectMethod.1.qml b/tests/auto/qml/qqmllanguage/data/qmlAttachedPropertiesObjectMethod.1.qml new file mode 100644 index 0000000000..55c507f67e --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/qmlAttachedPropertiesObjectMethod.1.qml @@ -0,0 +1,5 @@ +import Test 1.0 +import QtQuick 2.0 +QtObject { +} + diff --git a/tests/auto/qml/qqmllanguage/data/qmlAttachedPropertiesObjectMethod.2.qml b/tests/auto/qml/qqmllanguage/data/qmlAttachedPropertiesObjectMethod.2.qml new file mode 100644 index 0000000000..db8a3da2b2 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/qmlAttachedPropertiesObjectMethod.2.qml @@ -0,0 +1,6 @@ +import Test 1.0 +import QtQuick 2.0 +QtObject { + MyQmlObject.value: 10 +} + diff --git a/tests/auto/qml/qqmllanguage/data/qtest/qml/qqmllanguage/LocalInternal.qml b/tests/auto/qml/qqmllanguage/data/qtest/qml/qqmllanguage/LocalInternal.qml new file mode 100644 index 0000000000..4ce04c46d2 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/qtest/qml/qqmllanguage/LocalInternal.qml @@ -0,0 +1,3 @@ +import QtQuick 2.0 + +Image { source: "pics/blue.png" } diff --git a/tests/auto/qml/qqmllanguage/data/qtest/qml/qqmllanguage/Test.qml b/tests/auto/qml/qqmllanguage/data/qtest/qml/qqmllanguage/Test.qml new file mode 100644 index 0000000000..f789a905f2 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/qtest/qml/qqmllanguage/Test.qml @@ -0,0 +1,2 @@ +import QtQuick 2.0 +Rectangle { } diff --git a/tests/auto/qml/qqmllanguage/data/qtest/qml/qqmllanguage/TestLocal.qml b/tests/auto/qml/qqmllanguage/data/qtest/qml/qqmllanguage/TestLocal.qml new file mode 100644 index 0000000000..11443ca6d5 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/qtest/qml/qqmllanguage/TestLocal.qml @@ -0,0 +1 @@ +LocalInternal {} diff --git a/tests/auto/qml/qqmllanguage/data/qtest/qml/qqmllanguage/TestNamed.qml b/tests/auto/qml/qqmllanguage/data/qtest/qml/qqmllanguage/TestNamed.qml new file mode 100644 index 0000000000..672cb8f201 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/qtest/qml/qqmllanguage/TestNamed.qml @@ -0,0 +1 @@ +NamedLocal { } diff --git a/tests/auto/qml/qqmllanguage/data/qtest/qml/qqmllanguage/TestSubDir.qml b/tests/auto/qml/qqmllanguage/data/qtest/qml/qqmllanguage/TestSubDir.qml new file mode 100644 index 0000000000..0dfede4093 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/qtest/qml/qqmllanguage/TestSubDir.qml @@ -0,0 +1,2 @@ +import "subdir" +SubTest { } diff --git a/tests/auto/qml/qqmllanguage/data/qtest/qml/qqmllanguage/UndeclaredLocal.qml b/tests/auto/qml/qqmllanguage/data/qtest/qml/qqmllanguage/UndeclaredLocal.qml new file mode 100644 index 0000000000..4ce04c46d2 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/qtest/qml/qqmllanguage/UndeclaredLocal.qml @@ -0,0 +1,3 @@ +import QtQuick 2.0 + +Image { source: "pics/blue.png" } diff --git a/tests/auto/qml/qqmllanguage/data/qtest/qml/qqmllanguage/WrongTestLocal.qml b/tests/auto/qml/qqmllanguage/data/qtest/qml/qqmllanguage/WrongTestLocal.qml new file mode 100644 index 0000000000..8dcb7be231 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/qtest/qml/qqmllanguage/WrongTestLocal.qml @@ -0,0 +1 @@ +UndeclaredInternal {} diff --git a/tests/auto/qml/qqmllanguage/data/qtest/qml/qqmllanguage/noqmldir/Test.qml b/tests/auto/qml/qqmllanguage/data/qtest/qml/qqmllanguage/noqmldir/Test.qml new file mode 100644 index 0000000000..f789a905f2 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/qtest/qml/qqmllanguage/noqmldir/Test.qml @@ -0,0 +1,2 @@ +import QtQuick 2.0 +Rectangle { } diff --git a/tests/auto/qml/qqmllanguage/data/qtest/qml/qqmllanguage/pics/blue.png b/tests/auto/qml/qqmllanguage/data/qtest/qml/qqmllanguage/pics/blue.png new file mode 100644 index 0000000000..46f815f1ed Binary files /dev/null and b/tests/auto/qml/qqmllanguage/data/qtest/qml/qqmllanguage/pics/blue.png differ diff --git a/tests/auto/qml/qqmllanguage/data/qtest/qml/qqmllanguage/qmldir b/tests/auto/qml/qqmllanguage/data/qtest/qml/qqmllanguage/qmldir new file mode 100644 index 0000000000..60150f837c --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/qtest/qml/qqmllanguage/qmldir @@ -0,0 +1,5 @@ +Test Test.qml +TestSubDir TestSubDir.qml +TestLocal TestLocal.qml +NamedLocal LocalInternal.qml +internal LocalInternal LocalInternal.qml diff --git a/tests/auto/qml/qqmllanguage/data/qtest/qml/qqmllanguage/subdir/SubTest.qml b/tests/auto/qml/qqmllanguage/data/qtest/qml/qqmllanguage/subdir/SubTest.qml new file mode 100644 index 0000000000..1480ae8683 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/qtest/qml/qqmllanguage/subdir/SubTest.qml @@ -0,0 +1,3 @@ +import QtQuick 2.0 + +Text {} diff --git a/tests/auto/qml/qqmllanguage/data/qtest/qml/qqmllanguage/subdir/qmldir b/tests/auto/qml/qqmllanguage/data/qtest/qml/qqmllanguage/subdir/qmldir new file mode 100644 index 0000000000..a54f7dfa61 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/qtest/qml/qqmllanguage/subdir/qmldir @@ -0,0 +1 @@ +SubTest SubTest.qml diff --git a/tests/auto/qml/qqmllanguage/data/readOnly.1.errors.txt b/tests/auto/qml/qqmllanguage/data/readOnly.1.errors.txt new file mode 100644 index 0000000000..b8c34042be --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/readOnly.1.errors.txt @@ -0,0 +1 @@ +3:21:Invalid property assignment: "readOnlyString" is a read-only property diff --git a/tests/auto/qml/qqmllanguage/data/readOnly.1.qml b/tests/auto/qml/qqmllanguage/data/readOnly.1.qml new file mode 100644 index 0000000000..60757bd005 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/readOnly.1.qml @@ -0,0 +1,4 @@ +import Test 1.0 +MyQmlObject { + readOnlyString: "Hello World" +} diff --git a/tests/auto/qml/qqmllanguage/data/readOnly.2.errors.txt b/tests/auto/qml/qqmllanguage/data/readOnly.2.errors.txt new file mode 100644 index 0000000000..d857a0440e --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/readOnly.2.errors.txt @@ -0,0 +1 @@ +3:5:Invalid property assignment: "readOnlyString" is a read-only property diff --git a/tests/auto/qml/qqmllanguage/data/readOnly.2.qml b/tests/auto/qml/qqmllanguage/data/readOnly.2.qml new file mode 100644 index 0000000000..8f1633cc11 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/readOnly.2.qml @@ -0,0 +1,4 @@ +import Test 1.0 +MyQmlObject { + readOnlyString: "Hello" + "World" +} diff --git a/tests/auto/qml/qqmllanguage/data/readOnly.3.errors.txt b/tests/auto/qml/qqmllanguage/data/readOnly.3.errors.txt new file mode 100644 index 0000000000..c7e9e1bb2f --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/readOnly.3.errors.txt @@ -0,0 +1 @@ +6:36:Invalid property assignment: "objAlias" is a read-only property diff --git a/tests/auto/qml/qqmllanguage/data/readOnly.3.qml b/tests/auto/qml/qqmllanguage/data/readOnly.3.qml new file mode 100644 index 0000000000..e3c56b701a --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/readOnly.3.qml @@ -0,0 +1,8 @@ +import Test 1.0 +import QtQuick 2.0 + +QtObject { + property variant child + child: HelperAlias { objAlias: QtObject {} } +} + diff --git a/tests/auto/qml/qqmllanguage/data/readOnly.4.errors.txt b/tests/auto/qml/qqmllanguage/data/readOnly.4.errors.txt new file mode 100644 index 0000000000..d857a0440e --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/readOnly.4.errors.txt @@ -0,0 +1 @@ +3:5:Invalid property assignment: "readOnlyString" is a read-only property diff --git a/tests/auto/qml/qqmllanguage/data/readOnly.4.qml b/tests/auto/qml/qqmllanguage/data/readOnly.4.qml new file mode 100644 index 0000000000..5338ac77bc --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/readOnly.4.qml @@ -0,0 +1,4 @@ +import Test 1.0 +MyQmlObject { + MyPropertyValueSource on readOnlyString {} +} diff --git a/tests/auto/qml/qqmllanguage/data/readOnly.5.errors.txt b/tests/auto/qml/qqmllanguage/data/readOnly.5.errors.txt new file mode 100644 index 0000000000..e71ae4447c --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/readOnly.5.errors.txt @@ -0,0 +1 @@ +2:23:Invalid property assignment: "readOnlyProperty" is a read-only property diff --git a/tests/auto/qml/qqmllanguage/data/readOnly.5.qml b/tests/auto/qml/qqmllanguage/data/readOnly.5.qml new file mode 100644 index 0000000000..d80b27a1e3 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/readOnly.5.qml @@ -0,0 +1,3 @@ +ReadOnlyType { + readOnlyProperty: 13 +} diff --git a/tests/auto/qml/qqmllanguage/data/readonly.qml b/tests/auto/qml/qqmllanguage/data/readonly.qml new file mode 100644 index 0000000000..493a9ad502 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/readonly.qml @@ -0,0 +1,17 @@ +import Test 1.0 + +MyQmlObject { + property int testData: 9 + property alias testData2: myObject.test1 + + readonly property int test1: 10 + readonly property int test2: testData + 9 + readonly property alias test3: myObject.test1 + + + property variant dummy: MyQmlObject { + id: myObject + property int test1: 13 + } +} + diff --git a/tests/auto/qml/qqmllanguage/data/registrationOrder.qml b/tests/auto/qml/qqmllanguage/data/registrationOrder.qml new file mode 100644 index 0000000000..14217ad521 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/registrationOrder.qml @@ -0,0 +1,4 @@ +import Test.VersionOrder 2.0 + +MyQmlObject { +} diff --git a/tests/auto/qml/qqmllanguage/data/remoteLoadCrash.qml b/tests/auto/qml/qqmllanguage/data/remoteLoadCrash.qml new file mode 100644 index 0000000000..5f237d39a2 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/remoteLoadCrash.qml @@ -0,0 +1,3 @@ +import QtQuick 2.0 +Text { +} diff --git a/tests/auto/qml/qqmllanguage/data/revisions11.qml b/tests/auto/qml/qqmllanguage/data/revisions11.qml new file mode 100644 index 0000000000..823439acdd --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/revisions11.qml @@ -0,0 +1,10 @@ +import QtQuick 2.0 +import Test 1.1 + +MyRevisionedClass +{ + prop1: 1 + prop2: 10 + + onSignal2: prop2 = 3 +} diff --git a/tests/auto/qml/qqmllanguage/data/revisionsbasesub11.qml b/tests/auto/qml/qqmllanguage/data/revisionsbasesub11.qml new file mode 100644 index 0000000000..78ab51a4b7 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/revisionsbasesub11.qml @@ -0,0 +1,16 @@ +import QtQuick 2.0 +import Test 1.1 + +MyRevisionedSubclass +{ + propA: 10 + propB: 10 + propC: 10 + // propD is not registered in 1.1 + prop1: 10 + prop2: 10 + prop3: 10 + prop4: 10 + + onSignal4: prop4 = 2 +} diff --git a/tests/auto/qml/qqmllanguage/data/revisionssub11.qml b/tests/auto/qml/qqmllanguage/data/revisionssub11.qml new file mode 100644 index 0000000000..d00758387e --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/revisionssub11.qml @@ -0,0 +1,12 @@ +import QtQuick 2.0 +import Test 1.1 + +MyRevisionedSubclass +{ + prop1: 10 + prop2: 10 + prop3: 10 + prop4: 10 + + onSignal4: prop4 = 2 +} diff --git a/tests/auto/qml/qqmllanguage/data/rootAsQmlComponent.qml b/tests/auto/qml/qqmllanguage/data/rootAsQmlComponent.qml new file mode 100644 index 0000000000..8d72cd3844 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/rootAsQmlComponent.qml @@ -0,0 +1,6 @@ +import Test 1.0 +MyContainerComponent { + x: 11 + MyQmlObject {} + MyQmlObject {} +} diff --git a/tests/auto/qml/qqmllanguage/data/scriptString.1.errors.txt b/tests/auto/qml/qqmllanguage/data/scriptString.1.errors.txt new file mode 100644 index 0000000000..14463e0941 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/scriptString.1.errors.txt @@ -0,0 +1 @@ +4:21:Invalid property assignment: script expected diff --git a/tests/auto/qml/qqmllanguage/data/scriptString.1.qml b/tests/auto/qml/qqmllanguage/data/scriptString.1.qml new file mode 100644 index 0000000000..f07d2231fe --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/scriptString.1.qml @@ -0,0 +1,5 @@ +import Test 1.0 + +MyTypeObject { + scriptProperty: MyTypeObject {} +} diff --git a/tests/auto/qml/qqmllanguage/data/scriptString.2.errors.txt b/tests/auto/qml/qqmllanguage/data/scriptString.2.errors.txt new file mode 100644 index 0000000000..f8a776f9a0 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/scriptString.2.errors.txt @@ -0,0 +1 @@ +4:40:Cannot assign multiple values to a script property diff --git a/tests/auto/qml/qqmllanguage/data/scriptString.2.qml b/tests/auto/qml/qqmllanguage/data/scriptString.2.qml new file mode 100644 index 0000000000..dc825c7511 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/scriptString.2.qml @@ -0,0 +1,6 @@ +import Test 1.0 + +MyTypeObject { + scriptProperty: [ MyTypeObject {}, MyTypeObject {} ] +} + diff --git a/tests/auto/qml/qqmllanguage/data/scriptString.qml b/tests/auto/qml/qqmllanguage/data/scriptString.qml new file mode 100644 index 0000000000..40a3bbeede --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/scriptString.qml @@ -0,0 +1,6 @@ +import Test 1.0 + +MyTypeObject { + scriptProperty: foo + bar + grouped.script: console.log(1921) +} diff --git a/tests/auto/qml/qqmllanguage/data/scriptString2.qml b/tests/auto/qml/qqmllanguage/data/scriptString2.qml new file mode 100644 index 0000000000..c42da2b9e1 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/scriptString2.qml @@ -0,0 +1,5 @@ +import Test 1.0 + +MyTypeObject { + scriptProperty: "hello\n\"world\"" +} diff --git a/tests/auto/qml/qqmllanguage/data/scriptString3.qml b/tests/auto/qml/qqmllanguage/data/scriptString3.qml new file mode 100644 index 0000000000..0cd82ff58f --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/scriptString3.qml @@ -0,0 +1,5 @@ +import Test 1.0 + +MyTypeObject { + scriptProperty: 12.345 +} diff --git a/tests/auto/qml/qqmllanguage/data/scriptString4.qml b/tests/auto/qml/qqmllanguage/data/scriptString4.qml new file mode 100644 index 0000000000..3e2f9a49f1 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/scriptString4.qml @@ -0,0 +1,5 @@ +import Test 1.0 + +MyTypeObject { + scriptProperty: true +} diff --git a/tests/auto/qml/qqmllanguage/data/signal.1.errors.txt b/tests/auto/qml/qqmllanguage/data/signal.1.errors.txt new file mode 100644 index 0000000000..78d996016a --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/signal.1.errors.txt @@ -0,0 +1 @@ +4:12:Expected parameter type diff --git a/tests/auto/qml/qqmllanguage/data/signal.1.qml b/tests/auto/qml/qqmllanguage/data/signal.1.qml new file mode 100644 index 0000000000..1c27baa4e8 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/signal.1.qml @@ -0,0 +1,5 @@ +import QtQuick 2.0 + +QtObject { + signal mySignal(nontype a) +} diff --git a/tests/auto/qml/qqmllanguage/data/signal.2.errors.txt b/tests/auto/qml/qqmllanguage/data/signal.2.errors.txt new file mode 100644 index 0000000000..0d4c33d750 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/signal.2.errors.txt @@ -0,0 +1 @@ +4:21:Unexpected token `,' diff --git a/tests/auto/qml/qqmllanguage/data/signal.2.qml b/tests/auto/qml/qqmllanguage/data/signal.2.qml new file mode 100644 index 0000000000..2b00ab80bb --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/signal.2.qml @@ -0,0 +1,6 @@ +import QtQuick 2.0 + +QtObject { + signal mySignal(,) +} + diff --git a/tests/auto/qml/qqmllanguage/data/signal.3.errors.txt b/tests/auto/qml/qqmllanguage/data/signal.3.errors.txt new file mode 100644 index 0000000000..bf043ac85a --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/signal.3.errors.txt @@ -0,0 +1 @@ +4:22:Expected token `identifier' diff --git a/tests/auto/qml/qqmllanguage/data/signal.3.qml b/tests/auto/qml/qqmllanguage/data/signal.3.qml new file mode 100644 index 0000000000..1bfcfff7b5 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/signal.3.qml @@ -0,0 +1,6 @@ +import QtQuick 2.0 + +QtObject { + signal mySignal(a) +} + diff --git a/tests/auto/qml/qqmllanguage/data/signal.4.errors.txt b/tests/auto/qml/qqmllanguage/data/signal.4.errors.txt new file mode 100644 index 0000000000..513ff60ae6 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/signal.4.errors.txt @@ -0,0 +1 @@ +4:12:Signal names cannot begin with an upper case letter diff --git a/tests/auto/qml/qqmllanguage/data/signal.4.qml b/tests/auto/qml/qqmllanguage/data/signal.4.qml new file mode 100644 index 0000000000..653c14e6aa --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/signal.4.qml @@ -0,0 +1,6 @@ +import QtQuick 2.0 + +QtObject { + signal MySignal +} + diff --git a/tests/auto/qml/qqmllanguage/data/simpleBindings.qml b/tests/auto/qml/qqmllanguage/data/simpleBindings.qml new file mode 100644 index 0000000000..2fcd1a5a4f --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/simpleBindings.qml @@ -0,0 +1,18 @@ +import Test 1.0 +MyTypeObject { + id: me + property int v1: 10 + property int v2: 11 + + property int value1 + property int value2 + property int value3 + property int value4 + + value1: v1 + value2: me.v1 + value3: v1 + v2 + value4: Math.min(v1, v2) + + objectProperty: me +} diff --git a/tests/auto/qml/qqmllanguage/data/simpleContainer.qml b/tests/auto/qml/qqmllanguage/data/simpleContainer.qml new file mode 100644 index 0000000000..c3a795f536 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/simpleContainer.qml @@ -0,0 +1,5 @@ +import Test 1.0 +MyContainer { + MyQmlObject {} + MyQmlObject {} +} diff --git a/tests/auto/qml/qqmllanguage/data/simpleObject.qml b/tests/auto/qml/qqmllanguage/data/simpleObject.qml new file mode 100644 index 0000000000..30c78237de --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/simpleObject.qml @@ -0,0 +1,2 @@ +import Test 1.0 +MyQmlObject {} diff --git a/tests/auto/qml/qqmllanguage/data/singularProperty.2.errors.txt b/tests/auto/qml/qqmllanguage/data/singularProperty.2.errors.txt new file mode 100644 index 0000000000..beae562ff0 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/singularProperty.2.errors.txt @@ -0,0 +1 @@ +5:10:Cannot assign multiple values to a singular property diff --git a/tests/auto/qml/qqmllanguage/data/singularProperty.2.qml b/tests/auto/qml/qqmllanguage/data/singularProperty.2.qml new file mode 100644 index 0000000000..e2760cb418 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/singularProperty.2.qml @@ -0,0 +1,7 @@ +import QtQuick 2.0 + +QtObject { + property QtObject a + a: [ QtObject {}, QtObject {} ] +} + diff --git a/tests/auto/qml/qqmllanguage/data/singularProperty.errors.txt b/tests/auto/qml/qqmllanguage/data/singularProperty.errors.txt new file mode 100644 index 0000000000..beae562ff0 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/singularProperty.errors.txt @@ -0,0 +1 @@ +5:10:Cannot assign multiple values to a singular property diff --git a/tests/auto/qml/qqmllanguage/data/singularProperty.qml b/tests/auto/qml/qqmllanguage/data/singularProperty.qml new file mode 100644 index 0000000000..ccbc6f0849 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/singularProperty.qml @@ -0,0 +1,6 @@ +import QtQuick 2.0 + +QtObject { + property variant a + a: [ QtObject {}, QtObject {} ] +} diff --git a/tests/auto/qml/qqmllanguage/data/subdir/Test.qml b/tests/auto/qml/qqmllanguage/data/subdir/Test.qml new file mode 100644 index 0000000000..f789a905f2 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/subdir/Test.qml @@ -0,0 +1,2 @@ +import QtQuick 2.0 +Rectangle { } diff --git a/tests/auto/qml/qqmllanguage/data/subdir/subsubdir/SubTest.qml b/tests/auto/qml/qqmllanguage/data/subdir/subsubdir/SubTest.qml new file mode 100644 index 0000000000..f789a905f2 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/subdir/subsubdir/SubTest.qml @@ -0,0 +1,2 @@ +import QtQuick 2.0 +Rectangle { } diff --git a/tests/auto/qml/qqmllanguage/data/test.js b/tests/auto/qml/qqmllanguage/data/test.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/auto/qml/qqmllanguage/data/test2.js b/tests/auto/qml/qqmllanguage/data/test2.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/auto/qml/qqmllanguage/data/unregisteredObject.errors.txt b/tests/auto/qml/qqmllanguage/data/unregisteredObject.errors.txt new file mode 100644 index 0000000000..10e5fb2d96 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/unregisteredObject.errors.txt @@ -0,0 +1 @@ +2:1:UnregisteredObjectType is not a type diff --git a/tests/auto/qml/qqmllanguage/data/unregisteredObject.qml b/tests/auto/qml/qqmllanguage/data/unregisteredObject.qml new file mode 100644 index 0000000000..4969f62ad5 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/unregisteredObject.qml @@ -0,0 +1,2 @@ +import Test 1.0 +UnregisteredObjectType {} diff --git a/tests/auto/qml/qqmllanguage/data/unsupportedProperty.errors.txt b/tests/auto/qml/qqmllanguage/data/unsupportedProperty.errors.txt new file mode 100644 index 0000000000..3cd626de86 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/unsupportedProperty.errors.txt @@ -0,0 +1 @@ +3:13:Invalid property assignment: unsupported type "QMatrix" diff --git a/tests/auto/qml/qqmllanguage/data/unsupportedProperty.qml b/tests/auto/qml/qqmllanguage/data/unsupportedProperty.qml new file mode 100644 index 0000000000..9f19680368 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/unsupportedProperty.qml @@ -0,0 +1,4 @@ +import Test 1.0 +MyQmlObject { + matrix: "1,0,0,0,1,0,0,0,1" +} diff --git a/tests/auto/qml/qqmllanguage/data/valueTypes.qml b/tests/auto/qml/qqmllanguage/data/valueTypes.qml new file mode 100644 index 0000000000..bf325a74ee --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/valueTypes.qml @@ -0,0 +1,13 @@ +import Test 1.0 +MyTypeObject { + rectProperty.x: 10 + rectProperty.y: 11 + rectProperty.width: rectProperty.x + 2 + rectProperty.height: 13 + + intProperty: rectProperty.x + + onAction: { var a = rectProperty; a.x = 12; } + + rectProperty2: rectProperty +} diff --git a/tests/auto/qml/qqmllanguage/data/variantNotify.qml b/tests/auto/qml/qqmllanguage/data/variantNotify.qml new file mode 100644 index 0000000000..169b245450 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/variantNotify.qml @@ -0,0 +1,13 @@ +import QtQuick 2.0 + +QtObject { + property int notifyCount: 0 + + property variant foo + onFooChanged: notifyCount++ + + Component.onCompleted: { + foo = 1; + foo = 1; + } +} diff --git a/tests/auto/qml/qqmllanguage/data/versionedbase.qml b/tests/auto/qml/qqmllanguage/data/versionedbase.qml new file mode 100644 index 0000000000..3e8bca0368 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/versionedbase.qml @@ -0,0 +1,8 @@ +import QtQuick 2.0 +import Test 1.1 + +MySubclass +{ + prop1: 10 + prop2: 10 +} diff --git a/tests/auto/qml/qqmllanguage/data/wrongType.1.errors.txt b/tests/auto/qml/qqmllanguage/data/wrongType.1.errors.txt new file mode 100644 index 0000000000..ba7a0766b2 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/wrongType.1.errors.txt @@ -0,0 +1 @@ +3:12:Invalid property assignment: int expected diff --git a/tests/auto/qml/qqmllanguage/data/wrongType.1.qml b/tests/auto/qml/qqmllanguage/data/wrongType.1.qml new file mode 100644 index 0000000000..289d37f050 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/wrongType.1.qml @@ -0,0 +1,4 @@ +import Test 1.0 +MyQmlObject { + value: "hello" +} diff --git a/tests/auto/qml/qqmllanguage/data/wrongType.10.errors.txt b/tests/auto/qml/qqmllanguage/data/wrongType.10.errors.txt new file mode 100644 index 0000000000..ae75b5289d --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/wrongType.10.errors.txt @@ -0,0 +1 @@ +3:23:Invalid property assignment: datetime expected diff --git a/tests/auto/qml/qqmllanguage/data/wrongType.10.qml b/tests/auto/qml/qqmllanguage/data/wrongType.10.qml new file mode 100644 index 0000000000..2cf0e50277 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/wrongType.10.qml @@ -0,0 +1,5 @@ +import Test 1.0 +MyTypeObject { + dateTimeProperty: 12 +} + diff --git a/tests/auto/qml/qqmllanguage/data/wrongType.11.errors.txt b/tests/auto/qml/qqmllanguage/data/wrongType.11.errors.txt new file mode 100644 index 0000000000..23a4cda4c2 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/wrongType.11.errors.txt @@ -0,0 +1 @@ +3:20:Invalid property assignment: point expected diff --git a/tests/auto/qml/qqmllanguage/data/wrongType.11.qml b/tests/auto/qml/qqmllanguage/data/wrongType.11.qml new file mode 100644 index 0000000000..ae77ba1fe8 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/wrongType.11.qml @@ -0,0 +1,5 @@ +import Test 1.0 +MyTypeObject { + pointProperty: "apples" +} + diff --git a/tests/auto/qml/qqmllanguage/data/wrongType.12.errors.txt b/tests/auto/qml/qqmllanguage/data/wrongType.12.errors.txt new file mode 100644 index 0000000000..3092100280 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/wrongType.12.errors.txt @@ -0,0 +1 @@ +3:19:Invalid property assignment: size expected diff --git a/tests/auto/qml/qqmllanguage/data/wrongType.12.qml b/tests/auto/qml/qqmllanguage/data/wrongType.12.qml new file mode 100644 index 0000000000..b7a366f567 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/wrongType.12.qml @@ -0,0 +1,5 @@ +import Test 1.0 +MyTypeObject { + sizeProperty: "red" +} + diff --git a/tests/auto/qml/qqmllanguage/data/wrongType.13.errors.txt b/tests/auto/qml/qqmllanguage/data/wrongType.13.errors.txt new file mode 100644 index 0000000000..ba7a0766b2 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/wrongType.13.errors.txt @@ -0,0 +1 @@ +3:12:Invalid property assignment: int expected diff --git a/tests/auto/qml/qqmllanguage/data/wrongType.13.qml b/tests/auto/qml/qqmllanguage/data/wrongType.13.qml new file mode 100644 index 0000000000..477aff1dbe --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/wrongType.13.qml @@ -0,0 +1,4 @@ +import Test 1.0 +MyQmlObject { + value: "12" +} diff --git a/tests/auto/qml/qqmllanguage/data/wrongType.14.errors.txt b/tests/auto/qml/qqmllanguage/data/wrongType.14.errors.txt new file mode 100644 index 0000000000..d621fdd6cd --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/wrongType.14.errors.txt @@ -0,0 +1 @@ +3:21:Invalid property assignment: string expected diff --git a/tests/auto/qml/qqmllanguage/data/wrongType.14.qml b/tests/auto/qml/qqmllanguage/data/wrongType.14.qml new file mode 100644 index 0000000000..672d693c72 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/wrongType.14.qml @@ -0,0 +1,5 @@ +import Test 1.0 +MyTypeObject { + stringProperty: 10 +} + diff --git a/tests/auto/qml/qqmllanguage/data/wrongType.15.errors.txt b/tests/auto/qml/qqmllanguage/data/wrongType.15.errors.txt new file mode 100644 index 0000000000..44768e30cb --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/wrongType.15.errors.txt @@ -0,0 +1 @@ +3:18:Invalid property assignment: url expected diff --git a/tests/auto/qml/qqmllanguage/data/wrongType.15.qml b/tests/auto/qml/qqmllanguage/data/wrongType.15.qml new file mode 100644 index 0000000000..633a5ba2ba --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/wrongType.15.qml @@ -0,0 +1,4 @@ +import Test 1.0 +MyTypeObject { + urlProperty: 12 +} diff --git a/tests/auto/qml/qqmllanguage/data/wrongType.16.errors.txt b/tests/auto/qml/qqmllanguage/data/wrongType.16.errors.txt new file mode 100644 index 0000000000..77cf210918 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/wrongType.16.errors.txt @@ -0,0 +1 @@ +4:24:Cannot assign object to property diff --git a/tests/auto/qml/qqmllanguage/data/wrongType.16.qml b/tests/auto/qml/qqmllanguage/data/wrongType.16.qml new file mode 100644 index 0000000000..973fdada24 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/wrongType.16.qml @@ -0,0 +1,5 @@ +import Test 1.0 +import QtQuick 2.0 +MyQmlObject { + qmlobjectProperty: QtObject {} +} diff --git a/tests/auto/qml/qqmllanguage/data/wrongType.17.errors.txt b/tests/auto/qml/qqmllanguage/data/wrongType.17.errors.txt new file mode 100644 index 0000000000..ef34d0ea95 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/wrongType.17.errors.txt @@ -0,0 +1 @@ +3:19:Invalid property assignment: unknown enumeration diff --git a/tests/auto/qml/qqmllanguage/data/wrongType.17.qml b/tests/auto/qml/qqmllanguage/data/wrongType.17.qml new file mode 100644 index 0000000000..f678fb3136 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/wrongType.17.qml @@ -0,0 +1,5 @@ +import Test 1.0 +MyTypeObject { + enumProperty: 6 +} + diff --git a/tests/auto/qml/qqmllanguage/data/wrongType.2.errors.txt b/tests/auto/qml/qqmllanguage/data/wrongType.2.errors.txt new file mode 100644 index 0000000000..9ff9f250c0 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/wrongType.2.errors.txt @@ -0,0 +1 @@ +3:14:Invalid property assignment: boolean expected diff --git a/tests/auto/qml/qqmllanguage/data/wrongType.2.qml b/tests/auto/qml/qqmllanguage/data/wrongType.2.qml new file mode 100644 index 0000000000..34b74f7e01 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/wrongType.2.qml @@ -0,0 +1,4 @@ +import Test 1.0 +MyQmlObject { + enabled: 5 +} diff --git a/tests/auto/qml/qqmllanguage/data/wrongType.3.errors.txt b/tests/auto/qml/qqmllanguage/data/wrongType.3.errors.txt new file mode 100644 index 0000000000..6d971c6499 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/wrongType.3.errors.txt @@ -0,0 +1 @@ +3:11:Invalid property assignment: rect expected diff --git a/tests/auto/qml/qqmllanguage/data/wrongType.3.qml b/tests/auto/qml/qqmllanguage/data/wrongType.3.qml new file mode 100644 index 0000000000..384181a17f --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/wrongType.3.qml @@ -0,0 +1,4 @@ +import Test 1.0 +MyQmlObject { + rect: "5,5x10" +} diff --git a/tests/auto/qml/qqmllanguage/data/wrongType.4.errors.txt b/tests/auto/qml/qqmllanguage/data/wrongType.4.errors.txt new file mode 100644 index 0000000000..ef34d0ea95 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/wrongType.4.errors.txt @@ -0,0 +1 @@ +3:19:Invalid property assignment: unknown enumeration diff --git a/tests/auto/qml/qqmllanguage/data/wrongType.4.qml b/tests/auto/qml/qqmllanguage/data/wrongType.4.qml new file mode 100644 index 0000000000..0787bf5fda --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/wrongType.4.qml @@ -0,0 +1,4 @@ +import Test 1.0 +MyTypeObject { + enumProperty: "InvalidEnumName" +} diff --git a/tests/auto/qml/qqmllanguage/data/wrongType.5.errors.txt b/tests/auto/qml/qqmllanguage/data/wrongType.5.errors.txt new file mode 100644 index 0000000000..cab10bddb8 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/wrongType.5.errors.txt @@ -0,0 +1 @@ +3:19:Invalid property assignment: unsigned int expected diff --git a/tests/auto/qml/qqmllanguage/data/wrongType.5.qml b/tests/auto/qml/qqmllanguage/data/wrongType.5.qml new file mode 100644 index 0000000000..c50ae9a26d --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/wrongType.5.qml @@ -0,0 +1,5 @@ +import Test 1.0 +MyTypeObject { + uintProperty: -13 +} + diff --git a/tests/auto/qml/qqmllanguage/data/wrongType.6.errors.txt b/tests/auto/qml/qqmllanguage/data/wrongType.6.errors.txt new file mode 100644 index 0000000000..d2b8c54c5b --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/wrongType.6.errors.txt @@ -0,0 +1 @@ +3:19:Invalid property assignment: number expected diff --git a/tests/auto/qml/qqmllanguage/data/wrongType.6.qml b/tests/auto/qml/qqmllanguage/data/wrongType.6.qml new file mode 100644 index 0000000000..da10b7895f --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/wrongType.6.qml @@ -0,0 +1,5 @@ +import Test 1.0 +MyTypeObject { + realProperty: "Hello" +} + diff --git a/tests/auto/qml/qqmllanguage/data/wrongType.7.errors.txt b/tests/auto/qml/qqmllanguage/data/wrongType.7.errors.txt new file mode 100644 index 0000000000..614346bd2b --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/wrongType.7.errors.txt @@ -0,0 +1 @@ +3:20:Invalid property assignment: color expected diff --git a/tests/auto/qml/qqmllanguage/data/wrongType.7.qml b/tests/auto/qml/qqmllanguage/data/wrongType.7.qml new file mode 100644 index 0000000000..ddc3835199 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/wrongType.7.qml @@ -0,0 +1,5 @@ +import Test 1.0 +MyTypeObject { + colorProperty: 12 +} + diff --git a/tests/auto/qml/qqmllanguage/data/wrongType.8.errors.txt b/tests/auto/qml/qqmllanguage/data/wrongType.8.errors.txt new file mode 100644 index 0000000000..1773c00825 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/wrongType.8.errors.txt @@ -0,0 +1 @@ +3:19:Invalid property assignment: date expected diff --git a/tests/auto/qml/qqmllanguage/data/wrongType.8.qml b/tests/auto/qml/qqmllanguage/data/wrongType.8.qml new file mode 100644 index 0000000000..a5f6756399 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/wrongType.8.qml @@ -0,0 +1,5 @@ +import Test 1.0 +MyTypeObject { + dateProperty: 12 +} + diff --git a/tests/auto/qml/qqmllanguage/data/wrongType.9.errors.txt b/tests/auto/qml/qqmllanguage/data/wrongType.9.errors.txt new file mode 100644 index 0000000000..8630975c57 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/wrongType.9.errors.txt @@ -0,0 +1 @@ +3:19:Invalid property assignment: time expected diff --git a/tests/auto/qml/qqmllanguage/data/wrongType.9.qml b/tests/auto/qml/qqmllanguage/data/wrongType.9.qml new file mode 100644 index 0000000000..a3db732692 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/wrongType.9.qml @@ -0,0 +1,5 @@ +import Test 1.0 +MyTypeObject { + timeProperty: 12 +} + diff --git a/tests/auto/qml/qqmllanguage/qqmllanguage.pro b/tests/auto/qml/qqmllanguage/qqmllanguage.pro new file mode 100644 index 0000000000..41b1d11764 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/qqmllanguage.pro @@ -0,0 +1,18 @@ +CONFIG += testcase +TARGET = tst_qqmllanguage +macx:CONFIG -= app_bundle + +SOURCES += tst_qqmllanguage.cpp \ + testtypes.cpp +HEADERS += testtypes.h + +INCLUDEPATH += ../../shared/ +HEADERS += ../../shared/testhttpserver.h +SOURCES += ../../shared/testhttpserver.cpp + +importFiles.files = data +importFiles.path = . +DEPLOYMENT += importFiles + +CONFIG += parallel_test +QT += core-private gui-private v8-private qml-private network testlib diff --git a/tests/auto/qml/qqmllanguage/testtypes.cpp b/tests/auto/qml/qqmllanguage/testtypes.cpp new file mode 100644 index 0000000000..3c7a7c2058 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/testtypes.cpp @@ -0,0 +1,88 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include "testtypes.h" + +void registerTypes() +{ + qmlRegisterInterface("MyInterface"); + qmlRegisterType("Test",1,0,"MyQmlObject"); + qmlRegisterType("Test",1,0,"MyTypeObject"); + qmlRegisterType("Test",1,0,"MyContainer"); + qmlRegisterType("Test",1,0,"MyPropertyValueSource"); + qmlRegisterType("Test",1,0,"MyDotPropertyObject"); + qmlRegisterType("Test",1,0,"MyNamespacedType"); + qmlRegisterType("Test",1,0,"MySecondNamespacedType"); + qmlRegisterType("Test",1,0,"MyParserStatus"); + qmlRegisterType(); + qmlRegisterType("Test",1,0,"MyRevisionedClass"); + qmlRegisterType("Test",1,1,"MyRevisionedClass"); + qmlRegisterType("Test",1,0,"MyRevisionedIllegalOverload"); + qmlRegisterType("Test",1,0,"MyRevisionedLegalOverload"); + + // Register the uncreatable base class + qmlRegisterRevision("Test",1,1); + // MyRevisionedSubclass 1.0 uses MyRevisionedClass revision 0 + qmlRegisterType("Test",1,0,"MyRevisionedSubclass"); + // MyRevisionedSubclass 1.1 uses MyRevisionedClass revision 1 + qmlRegisterType("Test",1,1,"MyRevisionedSubclass"); + + // Only version 1.0, but its super class is registered in version 1.1 also + qmlRegisterType("Test",1,0,"MySubclass"); + + qmlRegisterCustomType("Test", 1, 0, "MyCustomParserType", new MyCustomParserTypeParser); + + qmlRegisterTypeNotAvailable("Test",1,0,"UnavailableType", "UnavailableType is unavailable for testing"); + + qmlRegisterType("Test.Version",1,0,"MyQmlObject"); + qmlRegisterType("Test.Version",1,0,"MyTypeObject"); + qmlRegisterType("Test.Version",2,0,"MyTypeObject"); + + qmlRegisterType("Test.VersionOrder", 2,0, "MyQmlObject"); + qmlRegisterType("Test.VersionOrder", 1,0, "MyQmlObject"); +} + +QVariant myCustomVariantTypeConverter(const QString &data) +{ + MyCustomVariantType rv; + rv.a = data.toInt(); + return QVariant::fromValue(rv); +} + diff --git a/tests/auto/qml/qqmllanguage/testtypes.h b/tests/auto/qml/qqmllanguage/testtypes.h new file mode 100644 index 0000000000..e9898bd039 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/testtypes.h @@ -0,0 +1,823 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#ifndef TESTTYPES_H +#define TESTTYPES_H + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +QVariant myCustomVariantTypeConverter(const QString &data); + +class MyInterface +{ +public: + MyInterface() : id(913) {} + int id; +}; + +QT_BEGIN_NAMESPACE +Q_DECLARE_INTERFACE(MyInterface, "com.trolltech.Qt.Test.MyInterface"); +QT_END_NAMESPACE +QML_DECLARE_INTERFACE(MyInterface); + +struct MyCustomVariantType +{ + MyCustomVariantType() : a(0) {} + int a; +}; +Q_DECLARE_METATYPE(MyCustomVariantType); + +class MyAttachedObject : public QObject +{ + Q_OBJECT + Q_PROPERTY(int value READ value WRITE setValue NOTIFY valueChanged) + Q_PROPERTY(int value2 READ value2 WRITE setValue2) +public: + MyAttachedObject(QObject *parent) : QObject(parent), m_value(0), m_value2(0) {} + + int value() const { return m_value; } + void setValue(int v) { if (m_value != v) { m_value = v; emit valueChanged(); } } + + int value2() const { return m_value2; } + void setValue2(int v) { m_value2 = v; } + +signals: + void valueChanged(); + +private: + int m_value; + int m_value2; +}; + +class MyQmlObject : public QObject, public MyInterface +{ + Q_OBJECT + Q_PROPERTY(int value READ value WRITE setValue FINAL) + Q_PROPERTY(QString readOnlyString READ readOnlyString) + Q_PROPERTY(bool enabled READ enabled WRITE setEnabled) + Q_PROPERTY(QRect rect READ rect WRITE setRect) + Q_PROPERTY(QMatrix matrix READ matrix WRITE setMatrix) //assumed to be unsupported by QML + Q_PROPERTY(MyInterface *interfaceProperty READ interface WRITE setInterface) + Q_PROPERTY(int onLiteralSignal READ onLiteralSignal WRITE setOnLiteralSignal) + Q_PROPERTY(MyCustomVariantType customType READ customType WRITE setCustomType) + Q_PROPERTY(MyQmlObject *qmlobjectProperty READ qmlobject WRITE setQmlobject) + Q_PROPERTY(int propertyWithNotify READ propertyWithNotify WRITE setPropertyWithNotify NOTIFY oddlyNamedNotifySignal) + Q_PROPERTY(int nonScriptable READ nonScriptable WRITE setNonScriptable SCRIPTABLE false) + + Q_INTERFACES(MyInterface) +public: + MyQmlObject() : m_value(-1), m_interface(0), m_qmlobject(0) { qRegisterMetaType("MyCustomVariantType"); } + + int value() const { return m_value; } + void setValue(int v) { m_value = v; } + + QString readOnlyString() const { return QLatin1String(""); } + + bool enabled() const { return false; } + void setEnabled(bool) {} + + QRect rect() const { return QRect(); } + void setRect(const QRect&) {} + + QMatrix matrix() const { return QMatrix(); } + void setMatrix(const QMatrix&) {} + + MyInterface *interface() const { return m_interface; } + void setInterface(MyInterface *iface) { m_interface = iface; } + + static MyAttachedObject *qmlAttachedProperties(QObject *other) { + return new MyAttachedObject(other); + } + Q_CLASSINFO("DefaultMethod", "basicSlot()") + + int onLiteralSignal() const { return m_value; } + void setOnLiteralSignal(int v) { m_value = v; } + + MyQmlObject *qmlobject() const { return m_qmlobject; } + void setQmlobject(MyQmlObject *o) { m_qmlobject = o; } + + MyCustomVariantType customType() const { return m_custom; } + void setCustomType(const MyCustomVariantType &v) { m_custom = v; } + + int propertyWithNotify() const { return m_propertyWithNotify; } + void setPropertyWithNotify(int i) { m_propertyWithNotify = i; emit oddlyNamedNotifySignal(); } + + int nonScriptable() const { return 0; } + void setNonScriptable(int) {} +public slots: + void basicSlot() { qWarning("MyQmlObject::basicSlot"); } + void basicSlotWithArgs(int v) { qWarning("MyQmlObject::basicSlotWithArgs(%d)", v); } + +signals: + void basicSignal(); + void basicParameterizedSignal(int parameter); + void oddlyNamedNotifySignal(); + +private: + friend class tst_qqmllanguage; + int m_value; + MyInterface *m_interface; + MyQmlObject *m_qmlobject; + MyCustomVariantType m_custom; + int m_propertyWithNotify; +}; +QML_DECLARE_TYPE(MyQmlObject) +QML_DECLARE_TYPEINFO(MyQmlObject, QML_HAS_ATTACHED_PROPERTIES) + +class MyGroupedObject : public QObject +{ + Q_OBJECT + Q_PROPERTY(QQmlScriptString script READ script WRITE setScript) + Q_PROPERTY(int value READ value WRITE setValue) +public: + QQmlScriptString script() const { return m_script; } + void setScript(const QQmlScriptString &s) { m_script = s; } + + int value() const { return m_value; } + void setValue(int v) { m_value = v; } + +private: + int m_value; + QQmlScriptString m_script; +}; + + +class MyTypeObject : public QObject +{ + Q_OBJECT + Q_ENUMS(MyEnum) + Q_FLAGS(MyFlags) + + Q_PROPERTY(QString id READ id WRITE setId) + Q_PROPERTY(QObject *objectProperty READ objectProperty WRITE setObjectProperty) + Q_PROPERTY(QQmlComponent *componentProperty READ componentProperty WRITE setComponentProperty) + Q_PROPERTY(MyFlags flagProperty READ flagProperty WRITE setFlagProperty) + Q_PROPERTY(MyEnum enumProperty READ enumProperty WRITE setEnumProperty) + Q_PROPERTY(MyEnum readOnlyEnumProperty READ readOnlyEnumProperty) + Q_PROPERTY(QString stringProperty READ stringProperty WRITE setStringProperty) + Q_PROPERTY(uint uintProperty READ uintProperty WRITE setUintProperty) + Q_PROPERTY(int intProperty READ intProperty WRITE setIntProperty) + Q_PROPERTY(qreal realProperty READ realProperty WRITE setRealProperty) + Q_PROPERTY(double doubleProperty READ doubleProperty WRITE setDoubleProperty) + Q_PROPERTY(float floatProperty READ floatProperty WRITE setFloatProperty) + Q_PROPERTY(QColor colorProperty READ colorProperty WRITE setColorProperty) + Q_PROPERTY(QDate dateProperty READ dateProperty WRITE setDateProperty) + Q_PROPERTY(QTime timeProperty READ timeProperty WRITE setTimeProperty) + Q_PROPERTY(QDateTime dateTimeProperty READ dateTimeProperty WRITE setDateTimeProperty) + Q_PROPERTY(QPoint pointProperty READ pointProperty WRITE setPointProperty) + Q_PROPERTY(QPointF pointFProperty READ pointFProperty WRITE setPointFProperty) + Q_PROPERTY(QSize sizeProperty READ sizeProperty WRITE setSizeProperty) + Q_PROPERTY(QSizeF sizeFProperty READ sizeFProperty WRITE setSizeFProperty) + Q_PROPERTY(QRect rectProperty READ rectProperty WRITE setRectProperty NOTIFY rectPropertyChanged) + Q_PROPERTY(QRect rectProperty2 READ rectProperty2 WRITE setRectProperty2) + Q_PROPERTY(QRectF rectFProperty READ rectFProperty WRITE setRectFProperty) + Q_PROPERTY(bool boolProperty READ boolProperty WRITE setBoolProperty) + Q_PROPERTY(QVariant variantProperty READ variantProperty WRITE setVariantProperty) + Q_PROPERTY(QVector3D vectorProperty READ vectorProperty WRITE setVectorProperty) + Q_PROPERTY(QVector4D vector4Property READ vector4Property WRITE setVector4Property) + Q_PROPERTY(QUrl urlProperty READ urlProperty WRITE setUrlProperty) + + Q_PROPERTY(QQmlScriptString scriptProperty READ scriptProperty WRITE setScriptProperty) + Q_PROPERTY(MyGroupedObject *grouped READ grouped CONSTANT) + Q_PROPERTY(MyGroupedObject *nullGrouped READ nullGrouped CONSTANT) + +public: + MyTypeObject() + : objectPropertyValue(0), componentPropertyValue(0) {} + + QString idValue; + QString id() const { + return idValue; + } + void setId(const QString &v) { + idValue = v; + } + + QObject *objectPropertyValue; + QObject *objectProperty() const { + return objectPropertyValue; + } + void setObjectProperty(QObject *v) { + objectPropertyValue = v; + } + + QQmlComponent *componentPropertyValue; + QQmlComponent *componentProperty() const { + return componentPropertyValue; + } + void setComponentProperty(QQmlComponent *v) { + componentPropertyValue = v; + } + + enum MyFlag { FlagVal1 = 0x01, FlagVal2 = 0x02, FlagVal3 = 0x04 }; + Q_DECLARE_FLAGS(MyFlags, MyFlag) + MyFlags flagPropertyValue; + MyFlags flagProperty() const { + return flagPropertyValue; + } + void setFlagProperty(MyFlags v) { + flagPropertyValue = v; + } + + enum MyEnum { EnumVal1, EnumVal2 }; + MyEnum enumPropertyValue; + MyEnum enumProperty() const { + return enumPropertyValue; + } + void setEnumProperty(MyEnum v) { + enumPropertyValue = v; + } + + MyEnum readOnlyEnumProperty() const { + return EnumVal1; + } + + QString stringPropertyValue; + QString stringProperty() const { + return stringPropertyValue; + } + void setStringProperty(const QString &v) { + stringPropertyValue = v; + } + + uint uintPropertyValue; + uint uintProperty() const { + return uintPropertyValue; + } + void setUintProperty(const uint &v) { + uintPropertyValue = v; + } + + int intPropertyValue; + int intProperty() const { + return intPropertyValue; + } + void setIntProperty(const int &v) { + intPropertyValue = v; + } + + qreal realPropertyValue; + qreal realProperty() const { + return realPropertyValue; + } + void setRealProperty(const qreal &v) { + realPropertyValue = v; + } + + double doublePropertyValue; + double doubleProperty() const { + return doublePropertyValue; + } + void setDoubleProperty(const double &v) { + doublePropertyValue = v; + } + + float floatPropertyValue; + float floatProperty() const { + return floatPropertyValue; + } + void setFloatProperty(const float &v) { + floatPropertyValue = v; + } + + QColor colorPropertyValue; + QColor colorProperty() const { + return colorPropertyValue; + } + void setColorProperty(const QColor &v) { + colorPropertyValue = v; + } + + QDate datePropertyValue; + QDate dateProperty() const { + return datePropertyValue; + } + void setDateProperty(const QDate &v) { + datePropertyValue = v; + } + + QTime timePropertyValue; + QTime timeProperty() const { + return timePropertyValue; + } + void setTimeProperty(const QTime &v) { + timePropertyValue = v; + } + + QDateTime dateTimePropertyValue; + QDateTime dateTimeProperty() const { + return dateTimePropertyValue; + } + void setDateTimeProperty(const QDateTime &v) { + dateTimePropertyValue = v; + } + + QPoint pointPropertyValue; + QPoint pointProperty() const { + return pointPropertyValue; + } + void setPointProperty(const QPoint &v) { + pointPropertyValue = v; + } + + QPointF pointFPropertyValue; + QPointF pointFProperty() const { + return pointFPropertyValue; + } + void setPointFProperty(const QPointF &v) { + pointFPropertyValue = v; + } + + QSize sizePropertyValue; + QSize sizeProperty() const { + return sizePropertyValue; + } + void setSizeProperty(const QSize &v) { + sizePropertyValue = v; + } + + QSizeF sizeFPropertyValue; + QSizeF sizeFProperty() const { + return sizeFPropertyValue; + } + void setSizeFProperty(const QSizeF &v) { + sizeFPropertyValue = v; + } + + QRect rectPropertyValue; + QRect rectProperty() const { + return rectPropertyValue; + } + void setRectProperty(const QRect &v) { + rectPropertyValue = v; + emit rectPropertyChanged(); + } + + QRect rectPropertyValue2; + QRect rectProperty2() const { + return rectPropertyValue2; + } + void setRectProperty2(const QRect &v) { + rectPropertyValue2 = v; + } + + QRectF rectFPropertyValue; + QRectF rectFProperty() const { + return rectFPropertyValue; + } + void setRectFProperty(const QRectF &v) { + rectFPropertyValue = v; + } + + bool boolPropertyValue; + bool boolProperty() const { + return boolPropertyValue; + } + void setBoolProperty(const bool &v) { + boolPropertyValue = v; + } + + QVariant variantPropertyValue; + QVariant variantProperty() const { + return variantPropertyValue; + } + void setVariantProperty(const QVariant &v) { + variantPropertyValue = v; + } + + QVector3D vectorPropertyValue; + QVector3D vectorProperty() const { + return vectorPropertyValue; + } + void setVectorProperty(const QVector3D &v) { + vectorPropertyValue = v; + } + + QVector4D vector4PropertyValue; + QVector4D vector4Property() const { + return vector4PropertyValue; + } + void setVector4Property(const QVector4D &v) { + vector4PropertyValue = v; + } + + QUrl urlPropertyValue; + QUrl urlProperty() const { + return urlPropertyValue; + } + void setUrlProperty(const QUrl &v) { + urlPropertyValue = v; + } + + QQmlScriptString scriptPropertyValue; + QQmlScriptString scriptProperty() const { + return scriptPropertyValue; + } + void setScriptProperty(const QQmlScriptString &v) { + scriptPropertyValue = v; + } + + MyGroupedObject groupedValue; + MyGroupedObject *grouped() { return &groupedValue; } + + MyGroupedObject *nullGrouped() { return 0; } + + void doAction() { emit action(); } +signals: + void action(); + void rectPropertyChanged(); +}; +Q_DECLARE_OPERATORS_FOR_FLAGS(MyTypeObject::MyFlags) + + +class MyContainer : public QObject +{ + Q_OBJECT + Q_PROPERTY(QQmlListProperty children READ children) + Q_PROPERTY(QQmlListProperty containerChildren READ containerChildren) + Q_PROPERTY(QQmlListProperty qlistInterfaces READ qlistInterfaces) + Q_CLASSINFO("DefaultProperty", "children") +public: + MyContainer() {} + + QQmlListProperty children() { return QQmlListProperty(this, m_children); } + QQmlListProperty containerChildren() { return QQmlListProperty(this, m_containerChildren); } + QList *getChildren() { return &m_children; } + QQmlListProperty qlistInterfaces() { return QQmlListProperty(this, m_interfaces); } + QList *getQListInterfaces() { return &m_interfaces; } + + QList m_containerChildren; + QList m_children; + QList m_interfaces; +}; + + +class MyPropertyValueSource : public QObject, public QQmlPropertyValueSource +{ + Q_OBJECT + Q_INTERFACES(QQmlPropertyValueSource) +public: + MyPropertyValueSource() + : QQmlPropertyValueSource() {} + + QQmlProperty prop; + virtual void setTarget(const QQmlProperty &p) + { + prop = p; + } +}; + +class UnavailableType : public QObject +{ + Q_OBJECT +public: + UnavailableType() {} +}; + +class MyDotPropertyObject : public QObject +{ + Q_OBJECT + Q_PROPERTY(MyQmlObject *obj READ obj) + Q_PROPERTY(MyQmlObject *readWriteObj READ readWriteObj WRITE setReadWriteObj) +public: + MyDotPropertyObject() : m_rwobj(0), m_ownRWObj(false) {} + ~MyDotPropertyObject() + { + if (m_ownRWObj) + delete m_rwobj; + } + + MyQmlObject *obj() { return 0; } + + MyQmlObject *readWriteObj() + { + if (!m_rwobj) { + m_rwobj = new MyQmlObject; + m_ownRWObj = true; + } + return m_rwobj; + } + + void setReadWriteObj(MyQmlObject *obj) + { + if (m_ownRWObj) { + delete m_rwobj; + m_ownRWObj = false; + } + + m_rwobj = obj; + } + +private: + MyQmlObject *m_rwobj; + bool m_ownRWObj; +}; + + +namespace MyNamespace { + class MyNamespacedType : public QObject + { + Q_OBJECT + }; + + class MySecondNamespacedType : public QObject + { + Q_OBJECT + Q_PROPERTY(QQmlListProperty list READ list) + public: + QQmlListProperty list() { return QQmlListProperty(this, m_list); } + + private: + QList m_list; + }; +} + +class MyCustomParserType : public QObject +{ + Q_OBJECT +}; + +class MyCustomParserTypeParser : public QQmlCustomParser +{ +public: + QByteArray compile(const QList &) { return QByteArray(); } + void setCustomData(QObject *, const QByteArray &) {} +}; + +class MyParserStatus : public QObject, public QQmlParserStatus +{ + Q_INTERFACES(QQmlParserStatus) + Q_OBJECT +public: + MyParserStatus() : m_cbc(0), m_ccc(0) {} + + int classBeginCount() const { return m_cbc; } + int componentCompleteCount() const { return m_ccc; } + + virtual void classBegin() { m_cbc++; } + virtual void componentComplete() { m_ccc++; } +private: + int m_cbc; + int m_ccc; +}; + +class MyRevisionedBaseClassRegistered : public QObject +{ + Q_OBJECT + Q_PROPERTY(qreal propA READ propA WRITE setPropA NOTIFY propAChanged) + Q_PROPERTY(qreal propB READ propB WRITE setPropB NOTIFY propBChanged REVISION 1) + +public: + MyRevisionedBaseClassRegistered() : m_pa(1), m_pb(2) {} + + qreal propA() const { return m_pa; } + void setPropA(qreal p) { + if (p != m_pa) { + m_pa = p; + emit propAChanged(); + } + } + qreal propB() const { return m_pb; } + void setPropB(qreal p) { + if (p != m_pb) { + m_pb = p; + emit propBChanged(); + } + } + + Q_INVOKABLE void methodA() { } + Q_INVOKABLE Q_REVISION(1) void methodB() { } + +signals: + void propAChanged(); + void propBChanged(); + + void signalA(); + Q_REVISION(1) void signalB(); + +protected: + qreal m_pa; + qreal m_pb; +}; + +class MyRevisionedIllegalOverload : public MyRevisionedBaseClassRegistered +{ + Q_OBJECT + Q_PROPERTY(qreal propA READ propA WRITE setPropA REVISION 1); +}; + +class MyRevisionedLegalOverload : public MyRevisionedBaseClassRegistered +{ + Q_OBJECT + Q_PROPERTY(qreal propB READ propB WRITE setPropB REVISION 1); +}; + +class MyRevisionedBaseClassUnregistered : public MyRevisionedBaseClassRegistered +{ + Q_OBJECT + Q_PROPERTY(qreal propC READ propC WRITE setPropC NOTIFY propCChanged) + Q_PROPERTY(qreal propD READ propD WRITE setPropD NOTIFY propDChanged REVISION 1) + +public: + MyRevisionedBaseClassUnregistered() : m_pc(1), m_pd(2) {} + + qreal propC() const { return m_pc; } + void setPropC(qreal p) { + if (p != m_pc) { + m_pc = p; + emit propCChanged(); + } + } + qreal propD() const { return m_pd; } + void setPropD(qreal p) { + if (p != m_pd) { + m_pd = p; + emit propDChanged(); + } + } + + Q_INVOKABLE void methodC() { } + Q_INVOKABLE Q_REVISION(1) void methodD() { } + +signals: + void propCChanged(); + void propDChanged(); + + void signalC(); + Q_REVISION(1) void signalD(); + +protected: + qreal m_pc; + qreal m_pd; +}; + +class MyRevisionedClass : public MyRevisionedBaseClassUnregistered +{ + Q_OBJECT + Q_PROPERTY(qreal prop1 READ prop1 WRITE setProp1 NOTIFY prop1Changed) + Q_PROPERTY(qreal prop2 READ prop2 WRITE setProp2 NOTIFY prop2Changed REVISION 1) + +public: + MyRevisionedClass() : m_p1(1), m_p2(2) {} + + qreal prop1() const { return m_p1; } + void setProp1(qreal p) { + if (p != m_p1) { + m_p1 = p; + emit prop1Changed(); + } + } + qreal prop2() const { return m_p2; } + void setProp2(qreal p) { + if (p != m_p2) { + m_p2 = p; + emit prop2Changed(); + } + } + + Q_INVOKABLE void method1() { } + Q_INVOKABLE Q_REVISION(1) void method2() { } + +signals: + void prop1Changed(); + void prop2Changed(); + + void signal1(); + Q_REVISION(1) void signal2(); + +protected: + qreal m_p1; + qreal m_p2; +}; + +class MyRevisionedSubclass : public MyRevisionedClass +{ + Q_OBJECT + Q_PROPERTY(qreal prop3 READ prop3 WRITE setProp3 NOTIFY prop3Changed) + Q_PROPERTY(qreal prop4 READ prop4 WRITE setProp4 NOTIFY prop4Changed REVISION 1) + +public: + MyRevisionedSubclass() : m_p3(3), m_p4(4) {} + + qreal prop3() const { return m_p3; } + void setProp3(qreal p) { + if (p != m_p3) { + m_p3 = p; + emit prop3Changed(); + } + } + qreal prop4() const { return m_p4; } + void setProp4(qreal p) { + if (p != m_p4) { + m_p4 = p; + emit prop4Changed(); + } + } + + Q_INVOKABLE void method3() { } + Q_INVOKABLE Q_REVISION(1) void method4() { } + +signals: + void prop3Changed(); + void prop4Changed(); + + void signal3(); + Q_REVISION(1) void signal4(); + +protected: + qreal m_p3; + qreal m_p4; +}; + +class MySubclass : public MyRevisionedClass +{ + Q_OBJECT + Q_PROPERTY(qreal prop5 READ prop5 WRITE setProp5 NOTIFY prop5Changed) + +public: + MySubclass() : m_p5(5) {} + + qreal prop5() const { return m_p5; } + void setProp5(qreal p) { + if (p != m_p5) { + m_p5 = p; + emit prop5Changed(); + } + } + + Q_INVOKABLE void method5() { } + +signals: + void prop5Changed(); + +protected: + qreal m_p5; +}; + +class MyVersion2Class : public QObject +{ + Q_OBJECT +}; + +QML_DECLARE_TYPE(MyRevisionedBaseClassRegistered) +QML_DECLARE_TYPE(MyRevisionedBaseClassUnregistered) +QML_DECLARE_TYPE(MyRevisionedClass) +QML_DECLARE_TYPE(MyRevisionedSubclass) +QML_DECLARE_TYPE(MySubclass) + + + +void registerTypes(); + +#endif // TESTTYPES_H diff --git a/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp b/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp new file mode 100644 index 0000000000..379c32d4b8 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp @@ -0,0 +1,2289 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +#include "testtypes.h" +#include "testhttpserver.h" + +DEFINE_BOOL_CONFIG_OPTION(qmlCheckTypes, QML_CHECK_TYPES) + +/* + Returns the path to some testdata file or directory. +*/ +QString testdata(QString const& name = QString()) +{ + static const QString dataDirectory = QDir::currentPath() + QLatin1String("/data"); + QString result = dataDirectory; + if (!name.isEmpty()) { + result += QLatin1Char('/'); + result += name; + } + return result; +} + +/* +This test case covers QML language issues. This covers everything that does not +involve evaluating ECMAScript expressions and bindings. + +Evaluation of expressions and bindings is covered in qmlecmascript +*/ +class tst_qqmllanguage : public QObject +{ + Q_OBJECT +public: + tst_qqmllanguage() { + QQmlMetaType::registerCustomStringConverter(qMetaTypeId(), myCustomVariantTypeConverter); + engine.addImportPath(testdata("lib")); + } + +private slots: + void initTestCase(); + void cleanupTestCase(); + + void errors_data(); + void errors(); + + void insertedSemicolon_data(); + void insertedSemicolon(); + + void simpleObject(); + void simpleContainer(); + void interfaceProperty(); + void interfaceQList(); + void assignObjectToSignal(); + void assignObjectToVariant(); + void assignLiteralSignalProperty(); + void assignQmlComponent(); + void assignBasicTypes(); + void assignTypeExtremes(); + void assignCompositeToType(); + void assignLiteralToVariant(); + void assignLiteralToVar(); + void customParserTypes(); + void rootAsQmlComponent(); + void inlineQmlComponents(); + void idProperty(); + void autoNotifyConnection(); + void assignSignal(); + void dynamicProperties(); + void dynamicPropertiesNested(); + void listProperties(); + void dynamicObjectProperties(); + void dynamicSignalsAndSlots(); + void simpleBindings(); + void autoComponentCreation(); + void propertyValueSource(); + void attachedProperties(); + void dynamicObjects(); + void customVariantTypes(); + void valueTypes(); + void cppnamespace(); + void aliasProperties(); + void aliasPropertiesAndSignals(); + void aliasPropertyChangeSignals(); + void componentCompositeType(); + void i18n(); + void i18n_data(); + void onCompleted(); + void onDestruction(); + void scriptString(); + void defaultPropertyListOrder(); + void declaredPropertyValues(); + void dontDoubleCallClassBegin(); + void reservedWords_data(); + void reservedWords(); + void inlineAssignmentsOverrideBindings(); + void nestedComponentRoots(); + void registrationOrder(); + void readonly(); + + void basicRemote_data(); + void basicRemote(); + void importsBuiltin_data(); + void importsBuiltin(); + void importsLocal_data(); + void importsLocal(); + void importsRemote_data(); + void importsRemote(); + void importsInstalled_data(); + void importsInstalled(); + void importsOrder_data(); + void importsOrder(); + void importIncorrectCase(); + void importJs_data(); + void importJs(); + + void qmlAttachedPropertiesObjectMethod(); + void customOnProperty(); + void variantNotify(); + + void revisions(); + void revisionOverloads(); + + void propertyInit(); + void remoteLoadCrash(); + + // regression tests for crashes + void crash1(); + void crash2(); + +private: + QQmlEngine engine; + void testType(const QString& qml, const QString& type, const QString& error); +}; + +#define DETERMINE_ERRORS(errorfile,expected,actual)\ + QList expected; \ + QList actual; \ + do { \ + QFile file(testdata(QLatin1String(errorfile))); \ + QVERIFY(file.open(QIODevice::ReadOnly | QIODevice::Text)); \ + QByteArray data = file.readAll(); \ + file.close(); \ + expected = data.split('\n'); \ + expected.removeAll(QByteArray("")); \ + QList errors = component.errors(); \ + for (int ii = 0; ii < errors.count(); ++ii) { \ + const QQmlError &error = errors.at(ii); \ + QByteArray errorStr = QByteArray::number(error.line()) + ":" + \ + QByteArray::number(error.column()) + ":" + \ + error.description().toUtf8(); \ + actual << errorStr; \ + } \ + } while (false); + +#define VERIFY_ERRORS(errorfile) \ + if (!errorfile) { \ + if (qgetenv("DEBUG") != "" && !component.errors().isEmpty()) \ + qWarning() << "Unexpected Errors:" << component.errors(); \ + QVERIFY(!component.isError()); \ + QVERIFY(component.errors().isEmpty()); \ + } else { \ + DETERMINE_ERRORS(errorfile,actual,expected);\ + if (qgetenv("DEBUG") != "" && expected != actual) \ + qWarning() << "Expected:" << expected << "Actual:" << actual; \ + if (qgetenv("QDECLARATIVELANGUAGE_UPDATEERRORS") != "" && expected != actual) {\ + QFile file(QLatin1String("data/") + QLatin1String(errorfile)); \ + QVERIFY(file.open(QIODevice::WriteOnly)); \ + for (int ii = 0; ii < actual.count(); ++ii) { \ + file.write(actual.at(ii)); file.write("\n"); \ + } \ + file.close(); \ + } else { \ + QCOMPARE(expected, actual); \ + } \ + } + +inline QUrl TEST_FILE(const QString &filename) +{ + return QUrl::fromLocalFile(testdata(filename)); +} + +inline QUrl TEST_FILE(const char *filename) +{ + return TEST_FILE(QLatin1String(filename)); +} + +void tst_qqmllanguage::cleanupTestCase() +{ + QVERIFY(QFile::remove(TEST_FILE(QString::fromUtf8("I18nType\303\201\303\242\303\243\303\244\303\245.qml")).toLocalFile())); +} + +void tst_qqmllanguage::insertedSemicolon_data() +{ + QTest::addColumn("file"); + QTest::addColumn("errorFile"); + QTest::addColumn("create"); + + QTest::newRow("insertedSemicolon.1") << "insertedSemicolon.1.qml" << "insertedSemicolon.1.errors.txt" << false; +} + +void tst_qqmllanguage::insertedSemicolon() +{ + QFETCH(QString, file); + QFETCH(QString, errorFile); + QFETCH(bool, create); + + QQmlComponent component(&engine, TEST_FILE(file)); + + if(create) { + QObject *object = component.create(); + QVERIFY(object == 0); + } + + VERIFY_ERRORS(errorFile.toLatin1().constData()); +} + +void tst_qqmllanguage::errors_data() +{ + QTest::addColumn("file"); + QTest::addColumn("errorFile"); + QTest::addColumn("create"); + + QTest::newRow("nonexistantProperty.1") << "nonexistantProperty.1.qml" << "nonexistantProperty.1.errors.txt" << false; + QTest::newRow("nonexistantProperty.2") << "nonexistantProperty.2.qml" << "nonexistantProperty.2.errors.txt" << false; + QTest::newRow("nonexistantProperty.3") << "nonexistantProperty.3.qml" << "nonexistantProperty.3.errors.txt" << false; + QTest::newRow("nonexistantProperty.4") << "nonexistantProperty.4.qml" << "nonexistantProperty.4.errors.txt" << false; + QTest::newRow("nonexistantProperty.5") << "nonexistantProperty.5.qml" << "nonexistantProperty.5.errors.txt" << false; + QTest::newRow("nonexistantProperty.6") << "nonexistantProperty.6.qml" << "nonexistantProperty.6.errors.txt" << false; + + QTest::newRow("wrongType (string for int)") << "wrongType.1.qml" << "wrongType.1.errors.txt" << false; + QTest::newRow("wrongType (int for bool)") << "wrongType.2.qml" << "wrongType.2.errors.txt" << false; + QTest::newRow("wrongType (bad rect)") << "wrongType.3.qml" << "wrongType.3.errors.txt" << false; + + QTest::newRow("wrongType (invalid enum)") << "wrongType.4.qml" << "wrongType.4.errors.txt" << false; + QTest::newRow("wrongType (int for uint)") << "wrongType.5.qml" << "wrongType.5.errors.txt" << false; + QTest::newRow("wrongType (string for real)") << "wrongType.6.qml" << "wrongType.6.errors.txt" << false; + QTest::newRow("wrongType (int for color)") << "wrongType.7.qml" << "wrongType.7.errors.txt" << false; + QTest::newRow("wrongType (int for date)") << "wrongType.8.qml" << "wrongType.8.errors.txt" << false; + QTest::newRow("wrongType (int for time)") << "wrongType.9.qml" << "wrongType.9.errors.txt" << false; + QTest::newRow("wrongType (int for datetime)") << "wrongType.10.qml" << "wrongType.10.errors.txt" << false; + QTest::newRow("wrongType (string for point)") << "wrongType.11.qml" << "wrongType.11.errors.txt" << false; + QTest::newRow("wrongType (color for size)") << "wrongType.12.qml" << "wrongType.12.errors.txt" << false; + QTest::newRow("wrongType (number string for int)") << "wrongType.13.qml" << "wrongType.13.errors.txt" << false; + QTest::newRow("wrongType (int for string)") << "wrongType.14.qml" << "wrongType.14.errors.txt" << false; + QTest::newRow("wrongType (int for url)") << "wrongType.15.qml" << "wrongType.15.errors.txt" << false; + QTest::newRow("wrongType (invalid object)") << "wrongType.16.qml" << "wrongType.16.errors.txt" << false; + QTest::newRow("wrongType (int for enum)") << "wrongType.17.qml" << "wrongType.17.errors.txt" << false; + + QTest::newRow("readOnly.1") << "readOnly.1.qml" << "readOnly.1.errors.txt" << false; + QTest::newRow("readOnly.2") << "readOnly.2.qml" << "readOnly.2.errors.txt" << false; + QTest::newRow("readOnly.3") << "readOnly.3.qml" << "readOnly.3.errors.txt" << false; + QTest::newRow("readOnly.4") << "readOnly.4.qml" << "readOnly.4.errors.txt" << false; + QTest::newRow("readOnly.5") << "readOnly.5.qml" << "readOnly.5.errors.txt" << false; + + QTest::newRow("listAssignment.1") << "listAssignment.1.qml" << "listAssignment.1.errors.txt" << false; + QTest::newRow("listAssignment.2") << "listAssignment.2.qml" << "listAssignment.2.errors.txt" << false; + QTest::newRow("listAssignment.3") << "listAssignment.3.qml" << "listAssignment.3.errors.txt" << false; + + QTest::newRow("invalidID.1") << "invalidID.qml" << "invalidID.errors.txt" << false; + QTest::newRow("invalidID.2") << "invalidID.2.qml" << "invalidID.2.errors.txt" << false; + QTest::newRow("invalidID.3") << "invalidID.3.qml" << "invalidID.3.errors.txt" << false; + QTest::newRow("invalidID.4") << "invalidID.4.qml" << "invalidID.4.errors.txt" << false; + QTest::newRow("invalidID.5") << "invalidID.5.qml" << "invalidID.5.errors.txt" << false; + QTest::newRow("invalidID.6") << "invalidID.6.qml" << "invalidID.6.errors.txt" << false; + QTest::newRow("invalidID.7") << "invalidID.7.qml" << "invalidID.7.errors.txt" << false; + QTest::newRow("invalidID.8") << "invalidID.8.qml" << "invalidID.8.errors.txt" << false; + QTest::newRow("invalidID.9") << "invalidID.9.qml" << "invalidID.9.errors.txt" << false; + + QTest::newRow("scriptString.1") << "scriptString.1.qml" << "scriptString.1.errors.txt" << false; + QTest::newRow("scriptString.2") << "scriptString.2.qml" << "scriptString.2.errors.txt" << false; + + QTest::newRow("unsupportedProperty") << "unsupportedProperty.qml" << "unsupportedProperty.errors.txt" << false; + QTest::newRow("nullDotProperty") << "nullDotProperty.qml" << "nullDotProperty.errors.txt" << true; + QTest::newRow("fakeDotProperty") << "fakeDotProperty.qml" << "fakeDotProperty.errors.txt" << false; + QTest::newRow("duplicateIDs") << "duplicateIDs.qml" << "duplicateIDs.errors.txt" << false; + QTest::newRow("unregisteredObject") << "unregisteredObject.qml" << "unregisteredObject.errors.txt" << false; + QTest::newRow("empty") << "empty.qml" << "empty.errors.txt" << false; + QTest::newRow("missingObject") << "missingObject.qml" << "missingObject.errors.txt" << false; + QTest::newRow("failingComponent") << "failingComponentTest.qml" << "failingComponent.errors.txt" << false; + QTest::newRow("missingSignal") << "missingSignal.qml" << "missingSignal.errors.txt" << false; + QTest::newRow("finalOverride") << "finalOverride.qml" << "finalOverride.errors.txt" << false; + QTest::newRow("customParserIdNotAllowed") << "customParserIdNotAllowed.qml" << "customParserIdNotAllowed.errors.txt" << false; + + QTest::newRow("invalidGroupedProperty.1") << "invalidGroupedProperty.1.qml" << "invalidGroupedProperty.1.errors.txt" << false; + QTest::newRow("invalidGroupedProperty.2") << "invalidGroupedProperty.2.qml" << "invalidGroupedProperty.2.errors.txt" << false; + QTest::newRow("invalidGroupedProperty.3") << "invalidGroupedProperty.3.qml" << "invalidGroupedProperty.3.errors.txt" << false; + QTest::newRow("invalidGroupedProperty.4") << "invalidGroupedProperty.4.qml" << "invalidGroupedProperty.4.errors.txt" << false; + QTest::newRow("invalidGroupedProperty.5") << "invalidGroupedProperty.5.qml" << "invalidGroupedProperty.5.errors.txt" << false; + QTest::newRow("invalidGroupedProperty.6") << "invalidGroupedProperty.6.qml" << "invalidGroupedProperty.6.errors.txt" << false; + QTest::newRow("invalidGroupedProperty.7") << "invalidGroupedProperty.7.qml" << "invalidGroupedProperty.7.errors.txt" << true; + QTest::newRow("invalidGroupedProperty.8") << "invalidGroupedProperty.8.qml" << "invalidGroupedProperty.8.errors.txt" << false; + QTest::newRow("invalidGroupedProperty.9") << "invalidGroupedProperty.9.qml" << "invalidGroupedProperty.9.errors.txt" << false; + QTest::newRow("invalidGroupedProperty.10") << "invalidGroupedProperty.10.qml" << "invalidGroupedProperty.10.errors.txt" << false; + + QTest::newRow("importNamespaceConflict") << "importNamespaceConflict.qml" << "importNamespaceConflict.errors.txt" << false; + QTest::newRow("importVersionMissing (builtin)") << "importVersionMissingBuiltIn.qml" << "importVersionMissingBuiltIn.errors.txt" << false; + QTest::newRow("importVersionMissing (installed)") << "importVersionMissingInstalled.qml" << "importVersionMissingInstalled.errors.txt" << false; + QTest::newRow("importNonExist (installed)") << "importNonExist.qml" << "importNonExist.errors.txt" << false; + QTest::newRow("importNonExistOlder (installed)") << "importNonExistOlder.qml" << "importNonExistOlder.errors.txt" << false; + QTest::newRow("importNewerVersion (installed)") << "importNewerVersion.qml" << "importNewerVersion.errors.txt" << false; + QTest::newRow("invalidImportID") << "invalidImportID.qml" << "invalidImportID.errors.txt" << false; + QTest::newRow("importFile") << "importFile.qml" << "importFile.errors.txt" << false; + + QTest::newRow("signal.1") << "signal.1.qml" << "signal.1.errors.txt" << false; + QTest::newRow("signal.2") << "signal.2.qml" << "signal.2.errors.txt" << false; + QTest::newRow("signal.3") << "signal.3.qml" << "signal.3.errors.txt" << false; + QTest::newRow("signal.4") << "signal.4.qml" << "signal.4.errors.txt" << false; + + QTest::newRow("method.1") << "method.1.qml" << "method.1.errors.txt" << false; + + QTest::newRow("property.1") << "property.1.qml" << "property.1.errors.txt" << false; + QTest::newRow("property.2") << "property.2.qml" << "property.2.errors.txt" << false; + QTest::newRow("property.3") << "property.3.qml" << "property.3.errors.txt" << false; + QTest::newRow("property.4") << "property.4.qml" << "property.4.errors.txt" << false; + QTest::newRow("property.6") << "property.6.qml" << "property.6.errors.txt" << false; + QTest::newRow("property.7") << "property.7.qml" << "property.7.errors.txt" << false; + + QTest::newRow("importScript.1") << "importscript.1.qml" << "importscript.1.errors.txt" << false; + + QTest::newRow("Component.1") << "component.1.qml" << "component.1.errors.txt" << false; + QTest::newRow("Component.2") << "component.2.qml" << "component.2.errors.txt" << false; + QTest::newRow("Component.3") << "component.3.qml" << "component.3.errors.txt" << false; + QTest::newRow("Component.4") << "component.4.qml" << "component.4.errors.txt" << false; + QTest::newRow("Component.5") << "component.5.qml" << "component.5.errors.txt" << false; + QTest::newRow("Component.6") << "component.6.qml" << "component.6.errors.txt" << false; + QTest::newRow("Component.7") << "component.7.qml" << "component.7.errors.txt" << false; + QTest::newRow("Component.8") << "component.8.qml" << "component.8.errors.txt" << false; + QTest::newRow("Component.9") << "component.9.qml" << "component.9.errors.txt" << false; + + QTest::newRow("MultiSet.1") << "multiSet.1.qml" << "multiSet.1.errors.txt" << false; + QTest::newRow("MultiSet.2") << "multiSet.2.qml" << "multiSet.2.errors.txt" << false; + QTest::newRow("MultiSet.3") << "multiSet.3.qml" << "multiSet.3.errors.txt" << false; + QTest::newRow("MultiSet.4") << "multiSet.4.qml" << "multiSet.4.errors.txt" << false; + QTest::newRow("MultiSet.5") << "multiSet.5.qml" << "multiSet.5.errors.txt" << false; + QTest::newRow("MultiSet.6") << "multiSet.6.qml" << "multiSet.6.errors.txt" << false; + QTest::newRow("MultiSet.7") << "multiSet.7.qml" << "multiSet.7.errors.txt" << false; + QTest::newRow("MultiSet.8") << "multiSet.8.qml" << "multiSet.8.errors.txt" << false; + QTest::newRow("MultiSet.9") << "multiSet.9.qml" << "multiSet.9.errors.txt" << false; + QTest::newRow("MultiSet.10") << "multiSet.10.qml" << "multiSet.10.errors.txt" << false; + QTest::newRow("MultiSet.11") << "multiSet.11.qml" << "multiSet.11.errors.txt" << false; + + QTest::newRow("dynamicMeta.1") << "dynamicMeta.1.qml" << "dynamicMeta.1.errors.txt" << false; + QTest::newRow("dynamicMeta.2") << "dynamicMeta.2.qml" << "dynamicMeta.2.errors.txt" << false; + QTest::newRow("dynamicMeta.3") << "dynamicMeta.3.qml" << "dynamicMeta.3.errors.txt" << false; + QTest::newRow("dynamicMeta.4") << "dynamicMeta.4.qml" << "dynamicMeta.4.errors.txt" << false; + QTest::newRow("dynamicMeta.5") << "dynamicMeta.5.qml" << "dynamicMeta.5.errors.txt" << false; + + QTest::newRow("invalidAlias.1") << "invalidAlias.1.qml" << "invalidAlias.1.errors.txt" << false; + QTest::newRow("invalidAlias.2") << "invalidAlias.2.qml" << "invalidAlias.2.errors.txt" << false; + QTest::newRow("invalidAlias.3") << "invalidAlias.3.qml" << "invalidAlias.3.errors.txt" << false; + QTest::newRow("invalidAlias.4") << "invalidAlias.4.qml" << "invalidAlias.4.errors.txt" << false; + QTest::newRow("invalidAlias.5") << "invalidAlias.5.qml" << "invalidAlias.5.errors.txt" << false; + QTest::newRow("invalidAlias.6") << "invalidAlias.6.qml" << "invalidAlias.6.errors.txt" << false; + QTest::newRow("invalidAlias.7") << "invalidAlias.7.qml" << "invalidAlias.7.errors.txt" << false; + QTest::newRow("invalidAlias.8") << "invalidAlias.8.qml" << "invalidAlias.8.errors.txt" << false; + QTest::newRow("invalidAlias.9") << "invalidAlias.9.qml" << "invalidAlias.9.errors.txt" << false; + QTest::newRow("invalidAlias.10") << "invalidAlias.10.qml" << "invalidAlias.10.errors.txt" << false; + + QTest::newRow("invalidAttachedProperty.1") << "invalidAttachedProperty.1.qml" << "invalidAttachedProperty.1.errors.txt" << false; + QTest::newRow("invalidAttachedProperty.2") << "invalidAttachedProperty.2.qml" << "invalidAttachedProperty.2.errors.txt" << false; + QTest::newRow("invalidAttachedProperty.3") << "invalidAttachedProperty.3.qml" << "invalidAttachedProperty.3.errors.txt" << false; + QTest::newRow("invalidAttachedProperty.4") << "invalidAttachedProperty.4.qml" << "invalidAttachedProperty.4.errors.txt" << false; + QTest::newRow("invalidAttachedProperty.5") << "invalidAttachedProperty.5.qml" << "invalidAttachedProperty.5.errors.txt" << false; + QTest::newRow("invalidAttachedProperty.6") << "invalidAttachedProperty.6.qml" << "invalidAttachedProperty.6.errors.txt" << false; + QTest::newRow("invalidAttachedProperty.7") << "invalidAttachedProperty.7.qml" << "invalidAttachedProperty.7.errors.txt" << false; + QTest::newRow("invalidAttachedProperty.8") << "invalidAttachedProperty.8.qml" << "invalidAttachedProperty.8.errors.txt" << false; + QTest::newRow("invalidAttachedProperty.9") << "invalidAttachedProperty.9.qml" << "invalidAttachedProperty.9.errors.txt" << false; + QTest::newRow("invalidAttachedProperty.10") << "invalidAttachedProperty.10.qml" << "invalidAttachedProperty.10.errors.txt" << false; + QTest::newRow("invalidAttachedProperty.11") << "invalidAttachedProperty.11.qml" << "invalidAttachedProperty.11.errors.txt" << false; + QTest::newRow("invalidAttachedProperty.12") << "invalidAttachedProperty.12.qml" << "invalidAttachedProperty.12.errors.txt" << false; + QTest::newRow("invalidAttachedProperty.13") << "invalidAttachedProperty.13.qml" << "invalidAttachedProperty.13.errors.txt" << false; + + QTest::newRow("assignValueToSignal") << "assignValueToSignal.qml" << "assignValueToSignal.errors.txt" << false; + QTest::newRow("emptySignal") << "emptySignal.qml" << "emptySignal.errors.txt" << false; + + QTest::newRow("nestedErrors") << "nestedErrors.qml" << "nestedErrors.errors.txt" << false; + QTest::newRow("defaultGrouped") << "defaultGrouped.qml" << "defaultGrouped.errors.txt" << false; + QTest::newRow("doubleSignal") << "doubleSignal.qml" << "doubleSignal.errors.txt" << false; + QTest::newRow("missingValueTypeProperty") << "missingValueTypeProperty.qml" << "missingValueTypeProperty.errors.txt" << false; + QTest::newRow("objectValueTypeProperty") << "objectValueTypeProperty.qml" << "objectValueTypeProperty.errors.txt" << false; + QTest::newRow("enumTypes") << "enumTypes.qml" << "enumTypes.errors.txt" << false; + QTest::newRow("noCreation") << "noCreation.qml" << "noCreation.errors.txt" << false; + QTest::newRow("destroyedSignal") << "destroyedSignal.qml" << "destroyedSignal.errors.txt" << false; + QTest::newRow("assignToNamespace") << "assignToNamespace.qml" << "assignToNamespace.errors.txt" << false; + QTest::newRow("invalidOn") << "invalidOn.qml" << "invalidOn.errors.txt" << false; + QTest::newRow("invalidProperty") << "invalidProperty.qml" << "invalidProperty.errors.txt" << false; + QTest::newRow("nonScriptableProperty") << "nonScriptableProperty.qml" << "nonScriptableProperty.errors.txt" << false; + QTest::newRow("notAvailable") << "notAvailable.qml" << "notAvailable.errors.txt" << false; + QTest::newRow("singularProperty") << "singularProperty.qml" << "singularProperty.errors.txt" << false; + QTest::newRow("singularProperty.2") << "singularProperty.2.qml" << "singularProperty.2.errors.txt" << false; + QTest::newRow("incorrectCase") << "incorrectCase.qml" +#if defined(Q_OS_MAC) || defined(Q_OS_WIN32) + << "incorrectCase.errors.insensitive.txt" +#else + << "incorrectCase.errors.sensitive.txt" +#endif + << false; + + QTest::newRow("metaobjectRevision.1") << "metaobjectRevision.1.qml" << "metaobjectRevision.1.errors.txt" << false; + QTest::newRow("metaobjectRevision.2") << "metaobjectRevision.2.qml" << "metaobjectRevision.2.errors.txt" << false; + QTest::newRow("metaobjectRevision.3") << "metaobjectRevision.3.qml" << "metaobjectRevision.3.errors.txt" << false; + + QTest::newRow("invalidRoot.1") << "invalidRoot.1.qml" << "invalidRoot.1.errors.txt" << false; + QTest::newRow("invalidRoot.2") << "invalidRoot.2.qml" << "invalidRoot.2.errors.txt" << false; + QTest::newRow("invalidRoot.3") << "invalidRoot.3.qml" << "invalidRoot.3.errors.txt" << false; + QTest::newRow("invalidRoot.4") << "invalidRoot.4.qml" << "invalidRoot.4.errors.txt" << false; + + QTest::newRow("invalidTypeName.1") << "invalidTypeName.1.qml" << "invalidTypeName.1.errors.txt" << false; + QTest::newRow("invalidTypeName.2") << "invalidTypeName.2.qml" << "invalidTypeName.2.errors.txt" << false; + QTest::newRow("invalidTypeName.3") << "invalidTypeName.3.qml" << "invalidTypeName.3.errors.txt" << false; + QTest::newRow("invalidTypeName.4") << "invalidTypeName.4.qml" << "invalidTypeName.4.errors.txt" << false; + + QTest::newRow("Major version isolation") << "majorVersionIsolation.qml" << "majorVersionIsolation.errors.txt" << false; +} + + +void tst_qqmllanguage::errors() +{ + QFETCH(QString, file); + QFETCH(QString, errorFile); + QFETCH(bool, create); + + QQmlComponent component(&engine, TEST_FILE(file)); + + if(create) { + QObject *object = component.create(); + QVERIFY(object == 0); + } + + VERIFY_ERRORS(errorFile.toLatin1().constData()); +} + +void tst_qqmllanguage::simpleObject() +{ + QQmlComponent component(&engine, TEST_FILE("simpleObject.qml")); + VERIFY_ERRORS(0); + QObject *object = component.create(); + QVERIFY(object != 0); +} + +void tst_qqmllanguage::simpleContainer() +{ + QQmlComponent component(&engine, TEST_FILE("simpleContainer.qml")); + VERIFY_ERRORS(0); + MyContainer *container= qobject_cast(component.create()); + QVERIFY(container != 0); + QCOMPARE(container->getChildren()->count(),2); +} + +void tst_qqmllanguage::interfaceProperty() +{ + QQmlComponent component(&engine, TEST_FILE("interfaceProperty.qml")); + VERIFY_ERRORS(0); + MyQmlObject *object = qobject_cast(component.create()); + QVERIFY(object != 0); + QVERIFY(object->interface()); + QVERIFY(object->interface()->id == 913); +} + +void tst_qqmllanguage::interfaceQList() +{ + QQmlComponent component(&engine, TEST_FILE("interfaceQList.qml")); + VERIFY_ERRORS(0); + MyContainer *container= qobject_cast(component.create()); + QVERIFY(container != 0); + QVERIFY(container->getQListInterfaces()->count() == 2); + for(int ii = 0; ii < 2; ++ii) + QVERIFY(container->getQListInterfaces()->at(ii)->id == 913); +} + +void tst_qqmllanguage::assignObjectToSignal() +{ + QQmlComponent component(&engine, TEST_FILE("assignObjectToSignal.qml")); + VERIFY_ERRORS(0); + MyQmlObject *object = qobject_cast(component.create()); + QVERIFY(object != 0); + QTest::ignoreMessage(QtWarningMsg, "MyQmlObject::basicSlot"); + emit object->basicSignal(); +} + +void tst_qqmllanguage::assignObjectToVariant() +{ + QQmlComponent component(&engine, TEST_FILE("assignObjectToVariant.qml")); + VERIFY_ERRORS(0); + QObject *object = component.create(); + QVERIFY(object != 0); + QVariant v = object->property("a"); + QVERIFY(v.userType() == qMetaTypeId()); +} + +void tst_qqmllanguage::assignLiteralSignalProperty() +{ + QQmlComponent component(&engine, TEST_FILE("assignLiteralSignalProperty.qml")); + VERIFY_ERRORS(0); + MyQmlObject *object = qobject_cast(component.create()); + QVERIFY(object != 0); + QCOMPARE(object->onLiteralSignal(), 10); +} + +// Test is an external component can be loaded and assigned (to a qlist) +void tst_qqmllanguage::assignQmlComponent() +{ + QQmlComponent component(&engine, TEST_FILE("assignQmlComponent.qml")); + VERIFY_ERRORS(0); + MyContainer *object = qobject_cast(component.create()); + QVERIFY(object != 0); + QVERIFY(object->getChildren()->count() == 1); + QObject *child = object->getChildren()->at(0); + QCOMPARE(child->property("x"), QVariant(10)); + QCOMPARE(child->property("y"), QVariant(11)); +} + +// Test literal assignment to all the basic types +void tst_qqmllanguage::assignBasicTypes() +{ + QQmlComponent component(&engine, TEST_FILE("assignBasicTypes.qml")); + VERIFY_ERRORS(0); + MyTypeObject *object = qobject_cast(component.create()); + QVERIFY(object != 0); + QCOMPARE(object->flagProperty(), MyTypeObject::FlagVal1 | MyTypeObject::FlagVal3); + QCOMPARE(object->enumProperty(), MyTypeObject::EnumVal2); + QCOMPARE(object->stringProperty(), QString("Hello World!")); + QCOMPARE(object->uintProperty(), uint(10)); + QCOMPARE(object->intProperty(), -19); + QCOMPARE((float)object->realProperty(), float(23.2)); + QCOMPARE((float)object->doubleProperty(), float(-19.7)); + QCOMPARE((float)object->floatProperty(), float(8.5)); + QCOMPARE(object->colorProperty(), QColor("red")); + QCOMPARE(object->dateProperty(), QDate(1982, 11, 25)); + QCOMPARE(object->timeProperty(), QTime(11, 11, 32)); + QCOMPARE(object->dateTimeProperty(), QDateTime(QDate(2009, 5, 12), QTime(13, 22, 1))); + QCOMPARE(object->pointProperty(), QPoint(99,13)); + QCOMPARE(object->pointFProperty(), QPointF(-10.1, 12.3)); + QCOMPARE(object->sizeProperty(), QSize(99, 13)); + QCOMPARE(object->sizeFProperty(), QSizeF(0.1, 0.2)); + QCOMPARE(object->rectProperty(), QRect(9, 7, 100, 200)); + QCOMPARE(object->rectFProperty(), QRectF(1000.1, -10.9, 400, 90.99)); + QCOMPARE(object->boolProperty(), true); + QCOMPARE(object->variantProperty(), QVariant("Hello World!")); + QCOMPARE(object->vectorProperty(), QVector3D(10, 1, 2.2)); + QCOMPARE(object->vector4Property(), QVector4D(10, 1, 2.2, 2.3)); + QUrl encoded; + encoded.setEncodedUrl("main.qml?with%3cencoded%3edata", QUrl::TolerantMode); + QCOMPARE(object->urlProperty(), component.url().resolved(encoded)); + QVERIFY(object->objectProperty() != 0); + MyTypeObject *child = qobject_cast(object->objectProperty()); + QVERIFY(child != 0); + QCOMPARE(child->intProperty(), 8); +} + +// Test edge case type assignments +void tst_qqmllanguage::assignTypeExtremes() +{ + QQmlComponent component(&engine, TEST_FILE("assignTypeExtremes.qml")); + VERIFY_ERRORS(0); + MyTypeObject *object = qobject_cast(component.create()); + QVERIFY(object != 0); + QCOMPARE(object->uintProperty(), 0xEE6B2800); + QCOMPARE(object->intProperty(), -0x77359400); +} + +// Test that a composite type can assign to a property of its base type +void tst_qqmllanguage::assignCompositeToType() +{ + QQmlComponent component(&engine, TEST_FILE("assignCompositeToType.qml")); + VERIFY_ERRORS(0); + QObject *object = component.create(); + QVERIFY(object != 0); +} + +// Test that literals are stored correctly in variant properties +void tst_qqmllanguage::assignLiteralToVariant() +{ + QQmlComponent component(&engine, TEST_FILE("assignLiteralToVariant.qml")); + VERIFY_ERRORS(0); + QObject *object = component.create(); + QVERIFY(object != 0); + + QCOMPARE(object->property("test1").userType(), (int)QVariant::Int); + QCOMPARE(object->property("test2").userType(), (int)QMetaType::Double); + QCOMPARE(object->property("test3").userType(), (int)QVariant::String); + QCOMPARE(object->property("test4").userType(), (int)QVariant::Color); + QCOMPARE(object->property("test5").userType(), (int)QVariant::RectF); + QCOMPARE(object->property("test6").userType(), (int)QVariant::PointF); + QCOMPARE(object->property("test7").userType(), (int)QVariant::SizeF); + QCOMPARE(object->property("test8").userType(), (int)QVariant::Vector3D); + QCOMPARE(object->property("test9").userType(), (int)QVariant::String); + QCOMPARE(object->property("test10").userType(), (int)QVariant::Bool); + QCOMPARE(object->property("test11").userType(), (int)QVariant::Bool); + QCOMPARE(object->property("test12").userType(), (int)QVariant::Vector4D); + + QVERIFY(object->property("test1") == QVariant(1)); + QVERIFY(object->property("test2") == QVariant((double)1.7)); + QVERIFY(object->property("test3") == QVariant(QString(QLatin1String("Hello world!")))); + QVERIFY(object->property("test4") == QVariant(QColor::fromRgb(0xFF008800))); + QVERIFY(object->property("test5") == QVariant(QRectF(10, 10, 10, 10))); + QVERIFY(object->property("test6") == QVariant(QPointF(10, 10))); + QVERIFY(object->property("test7") == QVariant(QSizeF(10, 10))); + QVERIFY(object->property("test8") == QVariant(QVector3D(100, 100, 100))); + QVERIFY(object->property("test9") == QVariant(QString(QLatin1String("#FF008800")))); + QVERIFY(object->property("test10") == QVariant(bool(true))); + QVERIFY(object->property("test11") == QVariant(bool(false))); + QVERIFY(object->property("test12") == QVariant(QVector4D(100, 100, 100, 100))); + + delete object; +} + +// Test that literals are stored correctly in "var" properties +// Note that behaviour differs from "variant" properties in that +// no conversion from "special strings" to QVariants is performed. +void tst_qqmllanguage::assignLiteralToVar() +{ + QQmlComponent component(&engine, TEST_FILE("assignLiteralToVar.qml")); + VERIFY_ERRORS(0); + QObject *object = component.create(); + QVERIFY(object != 0); + + QCOMPARE(object->property("test1").userType(), (int)QMetaType::Int); + QCOMPARE(object->property("test2").userType(), (int)QMetaType::Double); + QCOMPARE(object->property("test3").userType(), (int)QVariant::String); + QCOMPARE(object->property("test4").userType(), (int)QVariant::String); + QCOMPARE(object->property("test5").userType(), (int)QVariant::String); + QCOMPARE(object->property("test6").userType(), (int)QVariant::String); + QCOMPARE(object->property("test7").userType(), (int)QVariant::String); + QCOMPARE(object->property("test8").userType(), (int)QVariant::String); + QCOMPARE(object->property("test9").userType(), (int)QVariant::String); + QCOMPARE(object->property("test10").userType(), (int)QVariant::Bool); + QCOMPARE(object->property("test11").userType(), (int)QVariant::Bool); + QCOMPARE(object->property("test12").userType(), (int)QVariant::Color); + QCOMPARE(object->property("test13").userType(), (int)QVariant::RectF); + QCOMPARE(object->property("test14").userType(), (int)QVariant::PointF); + QCOMPARE(object->property("test15").userType(), (int)QVariant::SizeF); + QCOMPARE(object->property("test16").userType(), (int)QVariant::Vector3D); + QCOMPARE(object->property("variantTest1Bound").userType(), (int)QMetaType::Int); + QCOMPARE(object->property("test1Bound").userType(), (int)QMetaType::Int); + + QCOMPARE(object->property("test1"), QVariant(5)); + QCOMPARE(object->property("test2"), QVariant((double)1.7)); + QCOMPARE(object->property("test3"), QVariant(QString(QLatin1String("Hello world!")))); + QCOMPARE(object->property("test4"), QVariant(QString(QLatin1String("#FF008800")))); + QCOMPARE(object->property("test5"), QVariant(QString(QLatin1String("10,10,10x10")))); + QCOMPARE(object->property("test6"), QVariant(QString(QLatin1String("10,10")))); + QCOMPARE(object->property("test7"), QVariant(QString(QLatin1String("10x10")))); + QCOMPARE(object->property("test8"), QVariant(QString(QLatin1String("100,100,100")))); + QCOMPARE(object->property("test9"), QVariant(QString(QLatin1String("#FF008800")))); + QCOMPARE(object->property("test10"), QVariant(bool(true))); + QCOMPARE(object->property("test11"), QVariant(bool(false))); + QCOMPARE(object->property("test12"), QVariant(QColor::fromRgbF(0.2, 0.3, 0.4, 0.5))); + QCOMPARE(object->property("test13"), QVariant(QRectF(10, 10, 10, 10))); + QCOMPARE(object->property("test14"), QVariant(QPointF(10, 10))); + QCOMPARE(object->property("test15"), QVariant(QSizeF(10, 10))); + QCOMPARE(object->property("test16"), QVariant(QVector3D(100, 100, 100))); + QCOMPARE(object->property("variantTest1Bound"), QVariant(9)); + QCOMPARE(object->property("test1Bound"), QVariant(11)); + + delete object; +} + +// Tests that custom parser types can be instantiated +void tst_qqmllanguage::customParserTypes() +{ + QQmlComponent component(&engine, TEST_FILE("customParserTypes.qml")); + VERIFY_ERRORS(0); + QObject *object = component.create(); + QVERIFY(object != 0); + QVERIFY(object->property("count") == QVariant(2)); +} + +// Tests that the root item can be a custom component +void tst_qqmllanguage::rootAsQmlComponent() +{ + QQmlComponent component(&engine, TEST_FILE("rootAsQmlComponent.qml")); + VERIFY_ERRORS(0); + MyContainer *object = qobject_cast(component.create()); + QVERIFY(object != 0); + QCOMPARE(object->property("x"), QVariant(11)); + QCOMPARE(object->getChildren()->count(), 2); +} + +// Tests that components can be specified inline +void tst_qqmllanguage::inlineQmlComponents() +{ + QQmlComponent component(&engine, TEST_FILE("inlineQmlComponents.qml")); + VERIFY_ERRORS(0); + MyContainer *object = qobject_cast(component.create()); + QVERIFY(object != 0); + QCOMPARE(object->getChildren()->count(), 1); + QQmlComponent *comp = qobject_cast(object->getChildren()->at(0)); + QVERIFY(comp != 0); + MyQmlObject *compObject = qobject_cast(comp->create()); + QVERIFY(compObject != 0); + QCOMPARE(compObject->value(), 11); +} + +// Tests that types that have an id property have it set +void tst_qqmllanguage::idProperty() +{ + QQmlComponent component(&engine, TEST_FILE("idProperty.qml")); + VERIFY_ERRORS(0); + MyContainer *object = qobject_cast(component.create()); + QVERIFY(object != 0); + QCOMPARE(object->getChildren()->count(), 1); + MyTypeObject *child = + qobject_cast(object->getChildren()->at(0)); + QVERIFY(child != 0); + QCOMPARE(child->id(), QString("myObjectId")); + QCOMPARE(object->property("object"), QVariant::fromValue((QObject *)child)); +} + +// Tests automatic connection to notify signals if "onBlahChanged" syntax is used +// even if the notify signal for "blah" is not called "blahChanged" +void tst_qqmllanguage::autoNotifyConnection() +{ + QQmlComponent component(&engine, TEST_FILE("autoNotifyConnection.qml")); + VERIFY_ERRORS(0); + MyQmlObject *object = qobject_cast(component.create()); + QVERIFY(object != 0); + QMetaProperty prop = object->metaObject()->property(object->metaObject()->indexOfProperty("receivedNotify")); + QVERIFY(prop.isValid()); + + QCOMPARE(prop.read(object), QVariant::fromValue(false)); + object->setPropertyWithNotify(1); + QCOMPARE(prop.read(object), QVariant::fromValue(true)); +} + +// Tests that signals can be assigned to +void tst_qqmllanguage::assignSignal() +{ + QQmlComponent component(&engine, TEST_FILE("assignSignal.qml")); + VERIFY_ERRORS(0); + MyQmlObject *object = qobject_cast(component.create()); + QVERIFY(object != 0); + QTest::ignoreMessage(QtWarningMsg, "MyQmlObject::basicSlot"); + emit object->basicSignal(); + QTest::ignoreMessage(QtWarningMsg, "MyQmlObject::basicSlotWithArgs(9)"); + emit object->basicParameterizedSignal(9); +} + +// Tests the creation and assignment of dynamic properties +void tst_qqmllanguage::dynamicProperties() +{ + QQmlComponent component(&engine, TEST_FILE("dynamicProperties.qml")); + VERIFY_ERRORS(0); + QObject *object = component.create(); + QVERIFY(object != 0); + QCOMPARE(object->property("intProperty"), QVariant(10)); + QCOMPARE(object->property("boolProperty"), QVariant(false)); + QCOMPARE(object->property("doubleProperty"), QVariant(-10.1)); + QCOMPARE(object->property("realProperty"), QVariant((qreal)-19.9)); + QCOMPARE(object->property("stringProperty"), QVariant("Hello World!")); + QCOMPARE(object->property("urlProperty"), QVariant(TEST_FILE("main.qml"))); + QCOMPARE(object->property("colorProperty"), QVariant(QColor("red"))); + QCOMPARE(object->property("dateProperty"), QVariant(QDate(1945, 9, 2))); + QCOMPARE(object->property("varProperty"), QVariant("Hello World!")); +} + +// Test that nested types can use dynamic properties +void tst_qqmllanguage::dynamicPropertiesNested() +{ + QQmlComponent component(&engine, TEST_FILE("dynamicPropertiesNested.qml")); + VERIFY_ERRORS(0); + QObject *object = component.create(); + QVERIFY(object != 0); + + QCOMPARE(object->property("super_a").toInt(), 11); // Overridden + QCOMPARE(object->property("super_c").toInt(), 14); // Inherited + QCOMPARE(object->property("a").toInt(), 13); // New + QCOMPARE(object->property("b").toInt(), 12); // New + + delete object; +} + +// Tests the creation and assignment to dynamic list properties +void tst_qqmllanguage::listProperties() +{ + QQmlComponent component(&engine, TEST_FILE("listProperties.qml")); + VERIFY_ERRORS(0); + QObject *object = component.create(); + QVERIFY(object != 0); + + QCOMPARE(object->property("test").toInt(), 2); +} + +// Tests the creation and assignment of dynamic object properties +// ### Not complete +void tst_qqmllanguage::dynamicObjectProperties() +{ + { + QQmlComponent component(&engine, TEST_FILE("dynamicObjectProperties.qml")); + VERIFY_ERRORS(0); + QObject *object = component.create(); + QVERIFY(object != 0); + + QVERIFY(object->property("objectProperty") == qVariantFromValue((QObject*)0)); + QVERIFY(object->property("objectProperty2") != qVariantFromValue((QObject*)0)); + } + { + QQmlComponent component(&engine, TEST_FILE("dynamicObjectProperties.2.qml")); + QEXPECT_FAIL("", "QTBUG-10822", Abort); + VERIFY_ERRORS(0); + QObject *object = component.create(); + QVERIFY(object != 0); + + QVERIFY(object->property("objectProperty") != qVariantFromValue((QObject*)0)); + } +} + +// Tests the declaration of dynamic signals and slots +void tst_qqmllanguage::dynamicSignalsAndSlots() +{ + QTest::ignoreMessage(QtDebugMsg, "1921"); + + QQmlComponent component(&engine, TEST_FILE("dynamicSignalsAndSlots.qml")); + VERIFY_ERRORS(0); + QObject *object = component.create(); + QVERIFY(object != 0); + QVERIFY(object->metaObject()->indexOfMethod("signal1()") != -1); + QVERIFY(object->metaObject()->indexOfMethod("signal2()") != -1); + QVERIFY(object->metaObject()->indexOfMethod("slot1()") != -1); + QVERIFY(object->metaObject()->indexOfMethod("slot2()") != -1); + + QCOMPARE(object->property("test").toInt(), 0); + QMetaObject::invokeMethod(object, "slot3", Qt::DirectConnection, Q_ARG(QVariant, QVariant(10))); + QCOMPARE(object->property("test").toInt(), 10); +} + +void tst_qqmllanguage::simpleBindings() +{ + QQmlComponent component(&engine, TEST_FILE("simpleBindings.qml")); + VERIFY_ERRORS(0); + QObject *object = component.create(); + QVERIFY(object != 0); + QCOMPARE(object->property("value1"), QVariant(10)); + QCOMPARE(object->property("value2"), QVariant(10)); + QCOMPARE(object->property("value3"), QVariant(21)); + QCOMPARE(object->property("value4"), QVariant(10)); + QCOMPARE(object->property("objectProperty"), QVariant::fromValue(object)); +} + +void tst_qqmllanguage::autoComponentCreation() +{ + QQmlComponent component(&engine, TEST_FILE("autoComponentCreation.qml")); + VERIFY_ERRORS(0); + MyTypeObject *object = qobject_cast(component.create()); + QVERIFY(object != 0); + QVERIFY(object->componentProperty() != 0); + MyTypeObject *child = qobject_cast(object->componentProperty()->create()); + QVERIFY(child != 0); + QCOMPARE(child->realProperty(), qreal(9)); +} + +void tst_qqmllanguage::propertyValueSource() +{ + { + QQmlComponent component(&engine, TEST_FILE("propertyValueSource.qml")); + VERIFY_ERRORS(0); + MyTypeObject *object = qobject_cast(component.create()); + QVERIFY(object != 0); + + QList valueSources; + QObjectList allChildren = object->findChildren(); + foreach (QObject *child, allChildren) { + if (qobject_cast(child)) + valueSources.append(child); + } + + QCOMPARE(valueSources.count(), 1); + MyPropertyValueSource *valueSource = + qobject_cast(valueSources.at(0)); + QVERIFY(valueSource != 0); + QCOMPARE(valueSource->prop.object(), qobject_cast(object)); + QCOMPARE(valueSource->prop.name(), QString(QLatin1String("intProperty"))); + } + + { + QQmlComponent component(&engine, TEST_FILE("propertyValueSource.2.qml")); + VERIFY_ERRORS(0); + MyTypeObject *object = qobject_cast(component.create()); + QVERIFY(object != 0); + + QList valueSources; + QObjectList allChildren = object->findChildren(); + foreach (QObject *child, allChildren) { + if (qobject_cast(child)) + valueSources.append(child); + } + + QCOMPARE(valueSources.count(), 1); + MyPropertyValueSource *valueSource = + qobject_cast(valueSources.at(0)); + QVERIFY(valueSource != 0); + QCOMPARE(valueSource->prop.object(), qobject_cast(object)); + QCOMPARE(valueSource->prop.name(), QString(QLatin1String("intProperty"))); + } +} + +void tst_qqmllanguage::attachedProperties() +{ + QQmlComponent component(&engine, TEST_FILE("attachedProperties.qml")); + VERIFY_ERRORS(0); + QObject *object = component.create(); + QVERIFY(object != 0); + QObject *attached = qmlAttachedPropertiesObject(object); + QVERIFY(attached != 0); + QCOMPARE(attached->property("value"), QVariant(10)); + QCOMPARE(attached->property("value2"), QVariant(13)); +} + +// Tests non-static object properties +void tst_qqmllanguage::dynamicObjects() +{ + QQmlComponent component(&engine, TEST_FILE("dynamicObject.1.qml")); + VERIFY_ERRORS(0); + QObject *object = component.create(); + QVERIFY(object != 0); +} + +// Tests the registration of custom variant string converters +void tst_qqmllanguage::customVariantTypes() +{ + QQmlComponent component(&engine, TEST_FILE("customVariantTypes.qml")); + VERIFY_ERRORS(0); + MyQmlObject *object = qobject_cast(component.create()); + QVERIFY(object != 0); + QCOMPARE(object->customType().a, 10); +} + +void tst_qqmllanguage::valueTypes() +{ + QQmlComponent component(&engine, TEST_FILE("valueTypes.qml")); + VERIFY_ERRORS(0); + + QString message = component.url().toString() + ":2:1: QML MyTypeObject: Binding loop detected for property \"rectProperty.width\""; + QTest::ignoreMessage(QtWarningMsg, qPrintable(message)); + QTest::ignoreMessage(QtWarningMsg, qPrintable(message)); + + MyTypeObject *object = qobject_cast(component.create()); + QVERIFY(object != 0); + + + QCOMPARE(object->rectProperty(), QRect(10, 11, 12, 13)); + QCOMPARE(object->rectProperty2(), QRect(10, 11, 12, 13)); + QCOMPARE(object->intProperty(), 10); + object->doAction(); + QCOMPARE(object->rectProperty(), QRect(12, 11, 14, 13)); + QCOMPARE(object->rectProperty2(), QRect(12, 11, 14, 13)); + QCOMPARE(object->intProperty(), 12); + + // ### +#if 0 + QQmlProperty p(object, "rectProperty.x"); + QCOMPARE(p.read(), QVariant(12)); + p.write(13); + QCOMPARE(p.read(), QVariant(13)); + + quint32 r = QQmlPropertyPrivate::saveValueType(p.coreIndex(), p.valueTypeCoreIndex()); + QQmlProperty p2; + QQmlPropertyPrivate::restore(p2, r, object); + QCOMPARE(p2.read(), QVariant(13)); +#endif +} + +void tst_qqmllanguage::cppnamespace() +{ + { + QQmlComponent component(&engine, TEST_FILE("cppnamespace.qml")); + VERIFY_ERRORS(0); + QObject *object = component.create(); + QVERIFY(object != 0); + delete object; + } + + { + QQmlComponent component(&engine, TEST_FILE("cppnamespace.2.qml")); + VERIFY_ERRORS(0); + QObject *object = component.create(); + QVERIFY(object != 0); + delete object; + } +} + +void tst_qqmllanguage::aliasProperties() +{ + // Simple "int" alias + { + QQmlComponent component(&engine, TEST_FILE("alias.1.qml")); + VERIFY_ERRORS(0); + QObject *object = component.create(); + QVERIFY(object != 0); + + // Read through alias + QCOMPARE(object->property("valueAlias").toInt(), 10); + object->setProperty("value", QVariant(13)); + QCOMPARE(object->property("valueAlias").toInt(), 13); + + // Write through alias + object->setProperty("valueAlias", QVariant(19)); + QCOMPARE(object->property("valueAlias").toInt(), 19); + QCOMPARE(object->property("value").toInt(), 19); + + delete object; + } + + // Complex object alias + { + QQmlComponent component(&engine, TEST_FILE("alias.2.qml")); + VERIFY_ERRORS(0); + QObject *object = component.create(); + QVERIFY(object != 0); + + // Read through alias + MyQmlObject *v = + qvariant_cast(object->property("aliasObject")); + QVERIFY(v != 0); + QCOMPARE(v->value(), 10); + + // Write through alias + MyQmlObject *v2 = new MyQmlObject(); + v2->setParent(object); + object->setProperty("aliasObject", qVariantFromValue(v2)); + MyQmlObject *v3 = + qvariant_cast(object->property("aliasObject")); + QVERIFY(v3 != 0); + QCOMPARE(v3, v2); + + delete object; + } + + // Nested aliases + { + QQmlComponent component(&engine, TEST_FILE("alias.3.qml")); + VERIFY_ERRORS(0); + QObject *object = component.create(); + QVERIFY(object != 0); + + QCOMPARE(object->property("value").toInt(), 1892); + QCOMPARE(object->property("value2").toInt(), 1892); + + object->setProperty("value", QVariant(1313)); + QCOMPARE(object->property("value").toInt(), 1313); + QCOMPARE(object->property("value2").toInt(), 1313); + + object->setProperty("value2", QVariant(8080)); + QCOMPARE(object->property("value").toInt(), 8080); + QCOMPARE(object->property("value2").toInt(), 8080); + + delete object; + } + + // Enum aliases + { + QQmlComponent component(&engine, TEST_FILE("alias.4.qml")); + VERIFY_ERRORS(0); + QObject *object = component.create(); + QVERIFY(object != 0); + + QCOMPARE(object->property("enumAlias").toInt(), 1); + + delete object; + } + + // Id aliases + { + QQmlComponent component(&engine, TEST_FILE("alias.5.qml")); + VERIFY_ERRORS(0); + QObject *object = component.create(); + QVERIFY(object != 0); + + QVariant v = object->property("otherAlias"); + QCOMPARE(v.userType(), qMetaTypeId()); + MyQmlObject *o = qvariant_cast(v); + QCOMPARE(o->value(), 10); + + delete o; + + v = object->property("otherAlias"); + QCOMPARE(v.userType(), qMetaTypeId()); + o = qvariant_cast(v); + QVERIFY(o == 0); + + delete object; + } + + // Nested aliases - this used to cause a crash + { + QQmlComponent component(&engine, TEST_FILE("alias.6.qml")); + VERIFY_ERRORS(0); + QObject *object = component.create(); + QVERIFY(object != 0); + + QCOMPARE(object->property("a").toInt(), 1923); + } + + // Ptr Alias Cleanup - check that aliases to ptr types return 0 + // if the object aliased to is removed + { + QQmlComponent component(&engine, TEST_FILE("alias.7.qml")); + VERIFY_ERRORS(0); + + QObject *object = component.create(); + QVERIFY(object != 0); + + QObject *object1 = qvariant_cast(object->property("object")); + QVERIFY(object1 != 0); + QObject *object2 = qvariant_cast(object1->property("object")); + QVERIFY(object2 != 0); + + QObject *alias = qvariant_cast(object->property("aliasedObject")); + QVERIFY(alias == object2); + + delete object1; + + QObject *alias2 = object; // "Random" start value + int status = -1; + void *a[] = { &alias2, 0, &status }; + QMetaObject::metacall(object, QMetaObject::ReadProperty, + object->metaObject()->indexOfProperty("aliasedObject"), a); + QVERIFY(alias2 == 0); + } + + // Simple composite type + { + QQmlComponent component(&engine, TEST_FILE("alias.8.qml")); + VERIFY_ERRORS(0); + QObject *object = component.create(); + QVERIFY(object != 0); + + QCOMPARE(object->property("value").toInt(), 10); + + delete object; + } + + // Complex composite type + { + QQmlComponent component(&engine, TEST_FILE("alias.9.qml")); + VERIFY_ERRORS(0); + QObject *object = component.create(); + QVERIFY(object != 0); + + QCOMPARE(object->property("value").toInt(), 10); + + delete object; + } + + // Valuetype alias + // Simple "int" alias + { + QQmlComponent component(&engine, TEST_FILE("alias.10.qml")); + VERIFY_ERRORS(0); + QObject *object = component.create(); + QVERIFY(object != 0); + + // Read through alias + QCOMPARE(object->property("valueAlias").toRect(), QRect(10, 11, 9, 8)); + object->setProperty("rectProperty", QVariant(QRect(33, 12, 99, 100))); + QCOMPARE(object->property("valueAlias").toRect(), QRect(33, 12, 99, 100)); + + // Write through alias + object->setProperty("valueAlias", QVariant(QRect(3, 3, 4, 9))); + QCOMPARE(object->property("valueAlias").toRect(), QRect(3, 3, 4, 9)); + QCOMPARE(object->property("rectProperty").toRect(), QRect(3, 3, 4, 9)); + + delete object; + } + + // Valuetype sub-alias + { + QQmlComponent component(&engine, TEST_FILE("alias.11.qml")); + VERIFY_ERRORS(0); + QObject *object = component.create(); + QVERIFY(object != 0); + + // Read through alias + QCOMPARE(object->property("aliasProperty").toInt(), 19); + object->setProperty("rectProperty", QVariant(QRect(33, 8, 102, 111))); + QCOMPARE(object->property("aliasProperty").toInt(), 33); + + // Write through alias + object->setProperty("aliasProperty", QVariant(4)); + QCOMPARE(object->property("aliasProperty").toInt(), 4); + QCOMPARE(object->property("rectProperty").toRect(), QRect(4, 8, 102, 111)); + + delete object; + } +} + +// QTBUG-13374 Test that alias properties and signals can coexist +void tst_qqmllanguage::aliasPropertiesAndSignals() +{ + QQmlComponent component(&engine, TEST_FILE("aliasPropertiesAndSignals.qml")); + VERIFY_ERRORS(0); + QObject *o = component.create(); + QVERIFY(o); + QCOMPARE(o->property("test").toBool(), true); + delete o; +} + +// Test that the root element in a composite type can be a Component +void tst_qqmllanguage::componentCompositeType() +{ + QQmlComponent component(&engine, TEST_FILE("componentCompositeType.qml")); + VERIFY_ERRORS(0); + QObject *object = component.create(); + QVERIFY(object != 0); +} + +class TestType : public QObject { + Q_OBJECT +public: + TestType(QObject *p=0) : QObject(p) {} +}; + +class TestType2 : public QObject { + Q_OBJECT +public: + TestType2(QObject *p=0) : QObject(p) {} +}; + +void tst_qqmllanguage::i18n_data() +{ + QTest::addColumn("file"); + QTest::addColumn("stringProperty"); + QTest::newRow("i18nStrings") << "i18nStrings.qml" << QString::fromUtf8("Test \303\241\303\242\303\243\303\244\303\245 (5 accented 'a' letters)"); + QTest::newRow("i18nDeclaredPropertyNames") << "i18nDeclaredPropertyNames.qml" << QString::fromUtf8("Test \303\241\303\242\303\243\303\244\303\245: 10"); + QTest::newRow("i18nDeclaredPropertyUse") << "i18nDeclaredPropertyUse.qml" << QString::fromUtf8("Test \303\241\303\242\303\243\303\244\303\245: 15"); + QTest::newRow("i18nScript") << "i18nScript.qml" << QString::fromUtf8("Test \303\241\303\242\303\243\303\244\303\245: 20"); + QTest::newRow("i18nType") << "i18nType.qml" << QString::fromUtf8("Test \303\241\303\242\303\243\303\244\303\245: 30"); + QTest::newRow("i18nNameSpace") << "i18nNameSpace.qml" << QString::fromUtf8("Test \303\241\303\242\303\243\303\244\303\245: 40"); +} + +void tst_qqmllanguage::i18n() +{ + QFETCH(QString, file); + QFETCH(QString, stringProperty); + QQmlComponent component(&engine, TEST_FILE(file)); + VERIFY_ERRORS(0); + MyTypeObject *object = qobject_cast(component.create()); + QVERIFY(object != 0); + QCOMPARE(object->stringProperty(), stringProperty); + + delete object; +} + +// Check that the Component::onCompleted attached property works +void tst_qqmllanguage::onCompleted() +{ + QQmlComponent component(&engine, TEST_FILE("onCompleted.qml")); + VERIFY_ERRORS(0); + QTest::ignoreMessage(QtDebugMsg, "Completed 6 10"); + QTest::ignoreMessage(QtDebugMsg, "Completed 6 10"); + QTest::ignoreMessage(QtDebugMsg, "Completed 10 11"); + QObject *object = component.create(); + QVERIFY(object != 0); +} + +// Check that the Component::onDestruction attached property works +void tst_qqmllanguage::onDestruction() +{ + QQmlComponent component(&engine, TEST_FILE("onDestruction.qml")); + VERIFY_ERRORS(0); + QObject *object = component.create(); + QVERIFY(object != 0); + QTest::ignoreMessage(QtDebugMsg, "Destruction 6 10"); + QTest::ignoreMessage(QtDebugMsg, "Destruction 6 10"); + QTest::ignoreMessage(QtDebugMsg, "Destruction 10 11"); + delete object; +} + +// Check that assignments to QQmlScriptString properties work +void tst_qqmllanguage::scriptString() +{ + { + QQmlComponent component(&engine, TEST_FILE("scriptString.qml")); + VERIFY_ERRORS(0); + + MyTypeObject *object = qobject_cast(component.create()); + QVERIFY(object != 0); + QCOMPARE(object->scriptProperty().script(), QString("foo + bar")); + QCOMPARE(object->scriptProperty().scopeObject(), qobject_cast(object)); + QCOMPARE(object->scriptProperty().context(), qmlContext(object)); + + QVERIFY(object->grouped() != 0); + QCOMPARE(object->grouped()->script().script(), QString("console.log(1921)")); + QCOMPARE(object->grouped()->script().scopeObject(), qobject_cast(object)); + QCOMPARE(object->grouped()->script().context(), qmlContext(object)); + } + + { + QQmlComponent component(&engine, TEST_FILE("scriptString2.qml")); + VERIFY_ERRORS(0); + + MyTypeObject *object = qobject_cast(component.create()); + QVERIFY(object != 0); + QCOMPARE(object->scriptProperty().script(), QString("\"hello\\n\\\"world\\\"\"")); + } + + { + QQmlComponent component(&engine, TEST_FILE("scriptString3.qml")); + VERIFY_ERRORS(0); + + MyTypeObject *object = qobject_cast(component.create()); + QVERIFY(object != 0); + QCOMPARE(object->scriptProperty().script(), QString("12.345")); + } + + { + QQmlComponent component(&engine, TEST_FILE("scriptString4.qml")); + VERIFY_ERRORS(0); + + MyTypeObject *object = qobject_cast(component.create()); + QVERIFY(object != 0); + QCOMPARE(object->scriptProperty().script(), QString("true")); + } +} + +// Check that default property assignments are correctly spliced into explicit +// property assignments +void tst_qqmllanguage::defaultPropertyListOrder() +{ + QQmlComponent component(&engine, TEST_FILE("defaultPropertyListOrder.qml")); + VERIFY_ERRORS(0); + + MyContainer *container = qobject_cast(component.create()); + QVERIFY(container != 0); + + QCOMPARE(container->getChildren()->count(), 6); + QCOMPARE(container->getChildren()->at(0)->property("index"), QVariant(0)); + QCOMPARE(container->getChildren()->at(1)->property("index"), QVariant(1)); + QCOMPARE(container->getChildren()->at(2)->property("index"), QVariant(2)); + QCOMPARE(container->getChildren()->at(3)->property("index"), QVariant(3)); + QCOMPARE(container->getChildren()->at(4)->property("index"), QVariant(4)); + QCOMPARE(container->getChildren()->at(5)->property("index"), QVariant(5)); +} + +void tst_qqmllanguage::declaredPropertyValues() +{ + QQmlComponent component(&engine, TEST_FILE("declaredPropertyValues.qml")); + VERIFY_ERRORS(0); +} + +void tst_qqmllanguage::dontDoubleCallClassBegin() +{ + QQmlComponent component(&engine, TEST_FILE("dontDoubleCallClassBegin.qml")); + QObject *o = component.create(); + QVERIFY(o); + + MyParserStatus *o2 = qobject_cast(qvariant_cast(o->property("object"))); + QVERIFY(o2); + QCOMPARE(o2->classBeginCount(), 1); + QCOMPARE(o2->componentCompleteCount(), 1); + + delete o; +} + +void tst_qqmllanguage::reservedWords_data() +{ + QTest::addColumn("word"); + + QTest::newRow("abstract") << QByteArray("abstract"); + QTest::newRow("as") << QByteArray("as"); + QTest::newRow("boolean") << QByteArray("boolean"); + QTest::newRow("break") << QByteArray("break"); + QTest::newRow("byte") << QByteArray("byte"); + QTest::newRow("case") << QByteArray("case"); + QTest::newRow("catch") << QByteArray("catch"); + QTest::newRow("char") << QByteArray("char"); + QTest::newRow("class") << QByteArray("class"); + QTest::newRow("continue") << QByteArray("continue"); + QTest::newRow("const") << QByteArray("const"); + QTest::newRow("debugger") << QByteArray("debugger"); + QTest::newRow("default") << QByteArray("default"); + QTest::newRow("delete") << QByteArray("delete"); + QTest::newRow("do") << QByteArray("do"); + QTest::newRow("double") << QByteArray("double"); + QTest::newRow("else") << QByteArray("else"); + QTest::newRow("enum") << QByteArray("enum"); + QTest::newRow("export") << QByteArray("export"); + QTest::newRow("extends") << QByteArray("extends"); + QTest::newRow("false") << QByteArray("false"); + QTest::newRow("final") << QByteArray("final"); + QTest::newRow("finally") << QByteArray("finally"); + QTest::newRow("float") << QByteArray("float"); + QTest::newRow("for") << QByteArray("for"); + QTest::newRow("function") << QByteArray("function"); + QTest::newRow("goto") << QByteArray("goto"); + QTest::newRow("if") << QByteArray("if"); + QTest::newRow("implements") << QByteArray("implements"); + QTest::newRow("import") << QByteArray("import"); + QTest::newRow("in") << QByteArray("in"); + QTest::newRow("instanceof") << QByteArray("instanceof"); + QTest::newRow("int") << QByteArray("int"); + QTest::newRow("interface") << QByteArray("interface"); + QTest::newRow("long") << QByteArray("long"); + QTest::newRow("native") << QByteArray("native"); + QTest::newRow("new") << QByteArray("new"); + QTest::newRow("null") << QByteArray("null"); + QTest::newRow("package") << QByteArray("package"); + QTest::newRow("private") << QByteArray("private"); + QTest::newRow("protected") << QByteArray("protected"); + QTest::newRow("public") << QByteArray("public"); + QTest::newRow("return") << QByteArray("return"); + QTest::newRow("short") << QByteArray("short"); + QTest::newRow("static") << QByteArray("static"); + QTest::newRow("super") << QByteArray("super"); + QTest::newRow("switch") << QByteArray("switch"); + QTest::newRow("synchronized") << QByteArray("synchronized"); + QTest::newRow("this") << QByteArray("this"); + QTest::newRow("throw") << QByteArray("throw"); + QTest::newRow("throws") << QByteArray("throws"); + QTest::newRow("transient") << QByteArray("transient"); + QTest::newRow("true") << QByteArray("true"); + QTest::newRow("try") << QByteArray("try"); + QTest::newRow("typeof") << QByteArray("typeof"); + QTest::newRow("var") << QByteArray("var"); + QTest::newRow("void") << QByteArray("void"); + QTest::newRow("volatile") << QByteArray("volatile"); + QTest::newRow("while") << QByteArray("while"); + QTest::newRow("with") << QByteArray("with"); +} + +void tst_qqmllanguage::reservedWords() +{ + QFETCH(QByteArray, word); + QQmlComponent component(&engine); + component.setData("import QtQuick 2.0\nQtObject { property string " + word + " }", QUrl()); + QCOMPARE(component.errorString(), QLatin1String(":2 Expected token `identifier'\n")); +} + +// Check that first child of qml is of given type. Empty type insists on error. +void tst_qqmllanguage::testType(const QString& qml, const QString& type, const QString& expectederror) +{ + QQmlComponent component(&engine); + component.setData(qml.toUtf8(), TEST_FILE("empty.qml")); // just a file for relative local imports + + QTRY_VERIFY(!component.isLoading()); + + if (type.isEmpty()) { + QVERIFY(component.isError()); + QString actualerror; + foreach (const QQmlError e, component.errors()) { + if (!actualerror.isEmpty()) + actualerror.append("; "); + actualerror.append(e.description()); + } + QCOMPARE(actualerror,expectederror); + } else { + VERIFY_ERRORS(0); + QObject *object = component.create(); + QVERIFY(object != 0); + QCOMPARE(QString(object->metaObject()->className()), type); + delete object; + } +} + +// QTBUG-17276 +void tst_qqmllanguage::inlineAssignmentsOverrideBindings() +{ + QQmlComponent component(&engine, TEST_FILE("inlineAssignmentsOverrideBindings.qml")); + + QObject *o = component.create(); + QVERIFY(o != 0); + QCOMPARE(o->property("test").toInt(), 11); + delete o; +} + +// QTBUG-19354 +void tst_qqmllanguage::nestedComponentRoots() +{ + QQmlComponent component(&engine, TEST_FILE("nestedComponentRoots.qml")); +} + +// Import tests (QT-558) +void tst_qqmllanguage::importsBuiltin_data() +{ + // QT-610 + + QTest::addColumn("qml"); + QTest::addColumn("type"); + QTest::addColumn("error"); + + // import built-ins + QTest::newRow("missing import") + << "Test {}" + << "" + << "Test is not a type"; + QTest::newRow("not in version 0.0") + << "import com.nokia.Test 0.0\n" + "Test {}" + << "" + << "Test is not a type"; + QTest::newRow("version not installed") + << "import com.nokia.Test 99.0\n" + "Test {}" + << "" + << "module \"com.nokia.Test\" version 99.0 is not installed"; + QTest::newRow("in version 0.0") + << "import com.nokia.Test 0.0\n" + "TestTP {}" + << "TestType" + << ""; + QTest::newRow("qualified in version 0.0") + << "import com.nokia.Test 0.0 as T\n" + "T.TestTP {}" + << "TestType" + << ""; + QTest::newRow("in version 1.0") + << "import com.nokia.Test 1.0\n" + "Test {}" + << "TestType" + << ""; + QTest::newRow("qualified wrong") + << "import com.nokia.Test 1.0 as T\n" // QT-610 + "Test {}" + << "" + << "Test is not a type"; + QTest::newRow("qualified right") + << "import com.nokia.Test 1.0 as T\n" + "T.Test {}" + << "TestType" + << ""; + QTest::newRow("qualified right but not in version 0.0") + << "import com.nokia.Test 0.0 as T\n" + "T.Test {}" + << "" + << "T.Test is not a type"; + QTest::newRow("in version 1.1") + << "import com.nokia.Test 1.1\n" + "Test {}" + << "TestType" + << ""; + QTest::newRow("in version 1.3") + << "import com.nokia.Test 1.3\n" + "Test {}" + << "TestType" + << ""; + QTest::newRow("in version 1.5") + << "import com.nokia.Test 1.5\n" + "Test {}" + << "TestType" + << ""; + QTest::newRow("changed in version 1.8") + << "import com.nokia.Test 1.8\n" + "Test {}" + << "TestType2" + << ""; + QTest::newRow("in version 1.12") + << "import com.nokia.Test 1.12\n" + "Test {}" + << "TestType2" + << ""; + QTest::newRow("old in version 1.9") + << "import com.nokia.Test 1.9\n" + "OldTest {}" + << "TestType" + << ""; + QTest::newRow("old in version 1.11") + << "import com.nokia.Test 1.11\n" + "OldTest {}" + << "TestType" + << ""; + QTest::newRow("multiversion 1") + << "import com.nokia.Test 1.11\n" + "import com.nokia.Test 1.12\n" + "Test {}" + << (!qmlCheckTypes()?"TestType2":"") + << (!qmlCheckTypes()?"":"Test is ambiguous. Found in com/nokia/Test in version 1.12 and 1.11"); + QTest::newRow("multiversion 2") + << "import com.nokia.Test 1.11\n" + "import com.nokia.Test 1.12\n" + "OldTest {}" + << (!qmlCheckTypes()?"TestType":"") + << (!qmlCheckTypes()?"":"OldTest is ambiguous. Found in com/nokia/Test in version 1.12 and 1.11"); + QTest::newRow("qualified multiversion 3") + << "import com.nokia.Test 1.0 as T0\n" + "import com.nokia.Test 1.8 as T8\n" + "T0.Test {}" + << "TestType" + << ""; + QTest::newRow("qualified multiversion 4") + << "import com.nokia.Test 1.0 as T0\n" + "import com.nokia.Test 1.8 as T8\n" + "T8.Test {}" + << "TestType2" + << ""; +} + +void tst_qqmllanguage::importsBuiltin() +{ + QFETCH(QString, qml); + QFETCH(QString, type); + QFETCH(QString, error); + testType(qml,type,error); +} + +void tst_qqmllanguage::importsLocal_data() +{ + QTest::addColumn("qml"); + QTest::addColumn("type"); + QTest::addColumn("error"); + + // import locals + QTest::newRow("local import") + << "import \"subdir\"\n" // QT-613 + "Test {}" + << "QQuickRectangle" + << ""; + QTest::newRow("local import second") + << "import QtQuick 2.0\nimport \"subdir\"\n" + "Test {}" + << "QQuickRectangle" + << ""; + QTest::newRow("local import subsubdir") + << "import QtQuick 2.0\nimport \"subdir/subsubdir\"\n" + "SubTest {}" + << "QQuickRectangle" + << ""; + QTest::newRow("local import QTBUG-7721 A") + << "subdir.Test {}" // no longer allowed (QTBUG-7721) + << "" + << "subdir.Test - subdir is not a namespace"; + QTest::newRow("local import QTBUG-7721 B") + << "import \"subdir\" as X\n" + "X.subsubdir.SubTest {}" // no longer allowed (QTBUG-7721) + << "" + << "X.subsubdir.SubTest - nested namespaces not allowed"; + QTest::newRow("local import as") + << "import \"subdir\" as T\n" + "T.Test {}" + << "QQuickRectangle" + << ""; + QTest::newRow("wrong local import as") + << "import \"subdir\" as T\n" + "Test {}" + << "" + << "Test is not a type"; + QTest::newRow("library precedence over local import") + << "import \"subdir\"\n" + "import com.nokia.Test 1.0\n" + "Test {}" + << (!qmlCheckTypes()?"TestType":"") + << (!qmlCheckTypes()?"":"Test is ambiguous. Found in com/nokia/Test and in subdir"); +} + +void tst_qqmllanguage::importsLocal() +{ + QFETCH(QString, qml); + QFETCH(QString, type); + QFETCH(QString, error); + testType(qml,type,error); +} + +void tst_qqmllanguage::basicRemote_data() +{ + QTest::addColumn("url"); + QTest::addColumn("type"); + QTest::addColumn("error"); + + QString serverdir = "http://127.0.0.1:14447/qtest/qml/qqmllanguage/"; + + QTest::newRow("no need for qmldir") << QUrl(serverdir+"Test.qml") << "" << ""; + QTest::newRow("absent qmldir") << QUrl(serverdir+"/noqmldir/Test.qml") << "" << ""; + QTest::newRow("need qmldir") << QUrl(serverdir+"TestLocal.qml") << "" << ""; +} + +void tst_qqmllanguage::basicRemote() +{ + QFETCH(QUrl, url); + QFETCH(QString, type); + QFETCH(QString, error); + + TestHTTPServer server(14447); + server.serveDirectory(testdata()); + + QQmlComponent component(&engine, url); + + QTRY_VERIFY(!component.isLoading()); + + if (error.isEmpty()) { + if (component.isError()) + qDebug() << component.errors(); + QVERIFY(!component.isError()); + } else { + QVERIFY(component.isError()); + } +} + +void tst_qqmllanguage::importsRemote_data() +{ + QTest::addColumn("qml"); + QTest::addColumn("type"); + QTest::addColumn("error"); + + QString serverdir = "http://127.0.0.1:14447/qtest/qml/qqmllanguage"; + + QTest::newRow("remote import") << "import \""+serverdir+"\"\nTest {}" << "QQuickRectangle" + << ""; + QTest::newRow("remote import with subdir") << "import \""+serverdir+"\"\nTestSubDir {}" << "QQuickText" + << ""; + QTest::newRow("remote import with local") << "import \""+serverdir+"\"\nTestLocal {}" << "QQuickImage" + << ""; + QTest::newRow("wrong remote import with undeclared local") << "import \""+serverdir+"\"\nWrongTestLocal {}" << "" + << "WrongTestLocal is not a type"; + QTest::newRow("wrong remote import of internal local") << "import \""+serverdir+"\"\nLocalInternal {}" << "" + << "LocalInternal is not a type"; + QTest::newRow("wrong remote import of undeclared local") << "import \""+serverdir+"\"\nUndeclaredLocal {}" << "" + << "UndeclaredLocal is not a type"; +} + +void tst_qqmllanguage::importsRemote() +{ + QFETCH(QString, qml); + QFETCH(QString, type); + QFETCH(QString, error); + + TestHTTPServer server(14447); + server.serveDirectory(testdata()); + + testType(qml,type,error); +} + +void tst_qqmllanguage::importsInstalled_data() +{ + // QT-610 + + QTest::addColumn("qml"); + QTest::addColumn("type"); + QTest::addColumn("error"); + + // import installed + QTest::newRow("installed import 0") + << "import com.nokia.installedtest0 0.0\n" + "InstalledTestTP {}" + << "QQuickRectangle" + << ""; + QTest::newRow("installed import 0 as TP") + << "import com.nokia.installedtest0 0.0 as TP\n" + "TP.InstalledTestTP {}" + << "QQuickRectangle" + << ""; + QTest::newRow("installed import 1") + << "import com.nokia.installedtest 1.0\n" + "InstalledTest {}" + << "QQuickRectangle" + << ""; + QTest::newRow("installed import 2") + << "import com.nokia.installedtest 1.3\n" + "InstalledTest {}" + << "QQuickRectangle" + << ""; + QTest::newRow("installed import 3") + << "import com.nokia.installedtest 1.4\n" + "InstalledTest {}" + << "QQuickText" + << ""; + QTest::newRow("installed import minor version not available") // QTBUG-11936 + << "import com.nokia.installedtest 0.1\n" + "InstalledTest {}" + << "" + << "module \"com.nokia.installedtest\" version 0.1 is not installed"; + QTest::newRow("installed import minor version not available") // QTBUG-9627 + << "import com.nokia.installedtest 1.10\n" + "InstalledTest {}" + << "" + << "module \"com.nokia.installedtest\" version 1.10 is not installed"; + QTest::newRow("installed import major version not available") // QTBUG-9627 + << "import com.nokia.installedtest 9.0\n" + "InstalledTest {}" + << "" + << "module \"com.nokia.installedtest\" version 9.0 is not installed"; + QTest::newRow("installed import visibility") // QT-614 + << "import com.nokia.installedtest 1.4\n" + "PrivateType {}" + << "" + << "PrivateType is not a type"; +} + +void tst_qqmllanguage::importsInstalled() +{ + QFETCH(QString, qml); + QFETCH(QString, type); + QFETCH(QString, error); + testType(qml,type,error); +} + + +void tst_qqmllanguage::importsOrder_data() +{ + QTest::addColumn("qml"); + QTest::addColumn("type"); + QTest::addColumn("error"); + + QTest::newRow("double import") << + "import com.nokia.installedtest 1.4\n" + "import com.nokia.installedtest 1.4\n" + "InstalledTest {}" + << (!qmlCheckTypes()?"QQuickText":"") + << (!qmlCheckTypes()?"":"InstalledTest is ambiguous. Found in lib/com/nokia/installedtest in version 1.4 and 1.4"); + QTest::newRow("installed import overrides 1") << + "import com.nokia.installedtest 1.0\n" + "import com.nokia.installedtest 1.4\n" + "InstalledTest {}" + << (!qmlCheckTypes()?"QQuickText":"") + << (!qmlCheckTypes()?"":"InstalledTest is ambiguous. Found in lib/com/nokia/installedtest in version 1.4 and 1.0"); + QTest::newRow("installed import overrides 2") << + "import com.nokia.installedtest 1.4\n" + "import com.nokia.installedtest 1.0\n" + "InstalledTest {}" + << (!qmlCheckTypes()?"QQuickRectangle":"") + << (!qmlCheckTypes()?"":"InstalledTest is ambiguous. Found in lib/com/nokia/installedtest in version 1.0 and 1.4"); + QTest::newRow("installed import re-overrides 1") << + "import com.nokia.installedtest 1.4\n" + "import com.nokia.installedtest 1.0\n" + "import com.nokia.installedtest 1.4\n" + "InstalledTest {}" + << (!qmlCheckTypes()?"QQuickText":"") + << (!qmlCheckTypes()?"":"InstalledTest is ambiguous. Found in lib/com/nokia/installedtest in version 1.4 and 1.0"); + QTest::newRow("installed import re-overrides 2") << + "import com.nokia.installedtest 1.4\n" + "import com.nokia.installedtest 1.0\n" + "import com.nokia.installedtest 1.4\n" + "import com.nokia.installedtest 1.0\n" + "InstalledTest {}" + << (!qmlCheckTypes()?"QQuickRectangle":"") + << (!qmlCheckTypes()?"":"InstalledTest is ambiguous. Found in lib/com/nokia/installedtest in version 1.0 and 1.4"); + + QTest::newRow("installed import versus builtin 1") << + "import com.nokia.installedtest 1.5\n" + "import QtQuick 2.0\n" + "Rectangle {}" + << (!qmlCheckTypes()?"QQuickRectangle":"") + << (!qmlCheckTypes()?"":"Rectangle is ambiguous. Found in Qt and in lib/com/nokia/installedtest"); + QTest::newRow("installed import versus builtin 2") << + "import QtQuick 2.0\n" + "import com.nokia.installedtest 1.5\n" + "Rectangle {}" + << (!qmlCheckTypes()?"QQuickText":"") + << (!qmlCheckTypes()?"":"Rectangle is ambiguous. Found in lib/com/nokia/installedtest and in Qt"); + QTest::newRow("namespaces cannot be overridden by types 1") << + "import QtQuick 2.0 as Rectangle\n" + "import com.nokia.installedtest 1.5\n" + "Rectangle {}" + << "" + << "Namespace Rectangle cannot be used as a type"; + QTest::newRow("namespaces cannot be overridden by types 2") << + "import QtQuick 2.0 as Rectangle\n" + "import com.nokia.installedtest 1.5\n" + "Rectangle.Image {}" + << "QQuickImage" + << ""; + QTest::newRow("local last 1") << + "LocalLast {}" + << "QQuickText" + << ""; + QTest::newRow("local last 2") << + "import com.nokia.installedtest 1.0\n" + "LocalLast {}" + << (!qmlCheckTypes()?"QQuickRectangle":"")// i.e. from com.nokia.installedtest, not data/LocalLast.qml + << (!qmlCheckTypes()?"":"LocalLast is ambiguous. Found in lib/com/nokia/installedtest and in local directory"); +} + +void tst_qqmllanguage::importsOrder() +{ + QFETCH(QString, qml); + QFETCH(QString, type); + QFETCH(QString, error); + testType(qml,type,error); +} + +void tst_qqmllanguage::importIncorrectCase() +{ + QQmlComponent component(&engine, TEST_FILE("importIncorrectCase.qml")); + + QList errors = component.errors(); + QCOMPARE(errors.count(), 1); + +#if defined(Q_OS_MAC) || defined(Q_OS_WIN32) + QString expectedError = QLatin1String("cannot load module \"com.Nokia.installedtest\": File name case mismatch for \"") + testdata("lib/com/Nokia/installedtest/qmldir") + QLatin1String("\""); +#else + QString expectedError = QLatin1String("module \"com.Nokia.installedtest\" is not installed"); +#endif + + QCOMPARE(errors.at(0).description(), expectedError); +} + +void tst_qqmllanguage::importJs_data() +{ + QTest::addColumn("file"); + QTest::addColumn("errorFile"); + QTest::addColumn("performTest"); + + QTest::newRow("defaultVersion") + << "importJs.1.qml" + << "importJs.1.errors.txt" + << true; + + QTest::newRow("specifiedVersion") + << "importJs.2.qml" + << "importJs.2.errors.txt" + << true; + + QTest::newRow("excludeExcessiveVersion") + << "importJs.3.qml" + << "importJs.3.errors.txt" + << false; + + QTest::newRow("includeAppropriateVersion") + << "importJs.4.qml" + << "importJs.4.errors.txt" + << true; + + QTest::newRow("noDefaultVersion") + << "importJs.5.qml" + << "importJs.5.errors.txt" + << false; + + QTest::newRow("repeatImportFails") + << "importJs.6.qml" + << "importJs.6.errors.txt" + << false; + + QTest::newRow("multipleVersionImportFails") + << "importJs.7.qml" + << "importJs.7.errors.txt" + << false; + + QTest::newRow("namespacedImport") + << "importJs.8.qml" + << "importJs.8.errors.txt" + << true; + + QTest::newRow("namespacedVersionedImport") + << "importJs.9.qml" + << "importJs.9.errors.txt" + << true; + + QTest::newRow("namespacedRepeatImport") + << "importJs.10.qml" + << "importJs.10.errors.txt" + << true; +} + +void tst_qqmllanguage::importJs() +{ + QFETCH(QString, file); + QFETCH(QString, errorFile); + QFETCH(bool, performTest); + + QQmlComponent component(&engine, TEST_FILE(file)); + + { + DETERMINE_ERRORS(errorFile.toLatin1().constData(),expected,actual); + QCOMPARE(expected.size(), actual.size()); + for (int i = 0; i < expected.size(); ++i) + { + size_t compareLen = std::min(expected.at(i).length(), actual.at(i).length()); + QCOMPARE(expected.at(i).left(compareLen), actual.at(i).left(compareLen)); + } + } + + if (performTest) { + QObject *object = component.create(); + QVERIFY(object != 0); + QCOMPARE(object->property("test").toBool(),true); + delete object; + } +} + +void tst_qqmllanguage::qmlAttachedPropertiesObjectMethod() +{ + QObject object; + + QCOMPARE(qmlAttachedPropertiesObject(&object, false), (QObject *)0); + QCOMPARE(qmlAttachedPropertiesObject(&object, true), (QObject *)0); + + { + QQmlComponent component(&engine, TEST_FILE("qmlAttachedPropertiesObjectMethod.1.qml")); + VERIFY_ERRORS(0); + QObject *object = component.create(); + QVERIFY(object != 0); + + QCOMPARE(qmlAttachedPropertiesObject(object, false), (QObject *)0); + QVERIFY(qmlAttachedPropertiesObject(object, true) != 0); + } + + { + QQmlComponent component(&engine, TEST_FILE("qmlAttachedPropertiesObjectMethod.2.qml")); + VERIFY_ERRORS(0); + QObject *object = component.create(); + QVERIFY(object != 0); + + QVERIFY(qmlAttachedPropertiesObject(object, false) != 0); + QVERIFY(qmlAttachedPropertiesObject(object, true) != 0); + } +} + +void tst_qqmllanguage::crash1() +{ + QQmlComponent component(&engine); + component.setData("import QtQuick 2.0\nComponent {}", QUrl()); +} + +void tst_qqmllanguage::crash2() +{ + QQmlComponent component(&engine, TEST_FILE("crash2.qml")); +} + +// QTBUG-8676 +void tst_qqmllanguage::customOnProperty() +{ + QQmlComponent component(&engine, TEST_FILE("customOnProperty.qml")); + + VERIFY_ERRORS(0); + QObject *object = component.create(); + QVERIFY(object != 0); + + QCOMPARE(object->property("on").toInt(), 10); + + delete object; +} + +// QTBUG-12601 +void tst_qqmllanguage::variantNotify() +{ + QQmlComponent component(&engine, TEST_FILE("variantNotify.qml")); + + VERIFY_ERRORS(0); + QObject *object = component.create(); + QVERIFY(object != 0); + + QCOMPARE(object->property("notifyCount").toInt(), 1); + + delete object; +} + +void tst_qqmllanguage::revisions() +{ + { + QQmlComponent component(&engine, TEST_FILE("revisions11.qml")); + + VERIFY_ERRORS(0); + MyRevisionedClass *object = qobject_cast(component.create()); + QVERIFY(object != 0); + + QCOMPARE(object->prop2(), 10.0); + + delete object; + } + { + QQmlEngine myEngine; + QQmlComponent component(&myEngine, TEST_FILE("revisionssub11.qml")); + + VERIFY_ERRORS(0); + MyRevisionedSubclass *object = qobject_cast(component.create()); + QVERIFY(object != 0); + + QCOMPARE(object->prop1(), 10.0); + QCOMPARE(object->prop2(), 10.0); + QCOMPARE(object->prop3(), 10.0); + QCOMPARE(object->prop4(), 10.0); + + delete object; + } + { + QQmlComponent component(&engine, TEST_FILE("versionedbase.qml")); + VERIFY_ERRORS(0); + MySubclass *object = qobject_cast(component.create()); + QVERIFY(object != 0); + + QCOMPARE(object->prop1(), 10.0); + QCOMPARE(object->prop2(), 10.0); + + delete object; + } +} + +void tst_qqmllanguage::revisionOverloads() +{ + { + QQmlComponent component(&engine, TEST_FILE("allowedRevisionOverloads.qml")); + VERIFY_ERRORS(0); + } + { + QQmlComponent component(&engine, TEST_FILE("disallowedRevisionOverloads.qml")); + QEXPECT_FAIL("", "QTBUG-13849", Abort); + QVERIFY(0); + VERIFY_ERRORS("disallowedRevisionOverloads.errors.txt"); + } +} + +void tst_qqmllanguage::initTestCase() +{ + QString testdataDir = QFileInfo(QFINDTESTDATA("data")).absolutePath(); + QVERIFY2(QDir::setCurrent(testdataDir), qPrintable("Could not chdir to " + testdataDir)); + + registerTypes(); + + // Registering the TestType class in other modules should have no adverse effects + qmlRegisterType("com.nokia.TestPre", 1, 0, "Test"); + + qmlRegisterType("com.nokia.Test", 0, 0, "TestTP"); + qmlRegisterType("com.nokia.Test", 1, 0, "Test"); + qmlRegisterType("com.nokia.Test", 1, 5, "Test"); + qmlRegisterType("com.nokia.Test", 1, 8, "Test"); + qmlRegisterType("com.nokia.Test", 1, 9, "OldTest"); + qmlRegisterType("com.nokia.Test", 1, 12, "Test"); + + // Registering the TestType class in other modules should have no adverse effects + qmlRegisterType("com.nokia.TestPost", 1, 0, "Test"); + + // Create locale-specific file + // For POSIX, this will just be data/I18nType.qml, since POSIX is 7-bit + // For iso8859-1 locale, this will just be data/I18nType?????.qml where ????? is 5 8-bit characters + // For utf-8 locale, this will be data/I18nType??????????.qml where ?????????? is 5 8-bit characters, UTF-8 encoded + QFile in(TEST_FILE(QLatin1String("I18nType30.qml")).toLocalFile()); + QVERIFY2(in.open(QIODevice::ReadOnly), qPrintable(QString::fromLatin1("Cannot open '%1': %2").arg(in.fileName(), in.errorString()))); + QFile out(TEST_FILE(QString::fromUtf8("I18nType\303\201\303\242\303\243\303\244\303\245.qml")).toLocalFile()); + QVERIFY2(out.open(QIODevice::WriteOnly), qPrintable(QString::fromLatin1("Cannot open '%1': %2").arg(out.fileName(), out.errorString()))); + out.write(in.readAll()); +} + +void tst_qqmllanguage::aliasPropertyChangeSignals() +{ + { + QQmlComponent component(&engine, TEST_FILE("aliasPropertyChangeSignals.qml")); + + VERIFY_ERRORS(0); + QObject *o = component.create(); + QVERIFY(o != 0); + + QCOMPARE(o->property("test").toBool(), true); + + delete o; + } + + // QTCREATORBUG-2769 + { + QQmlComponent component(&engine, TEST_FILE("aliasPropertyChangeSignals.2.qml")); + + VERIFY_ERRORS(0); + QObject *o = component.create(); + QVERIFY(o != 0); + + QCOMPARE(o->property("test").toBool(), true); + + delete o; + } +} + +// Tests property initializers +void tst_qqmllanguage::propertyInit() +{ + { + QQmlComponent component(&engine, TEST_FILE("propertyInit.1.qml")); + + VERIFY_ERRORS(0); + QObject *o = component.create(); + QVERIFY(o != 0); + + QCOMPARE(o->property("test").toInt(), 1); + + delete o; + } + + { + QQmlComponent component(&engine, TEST_FILE("propertyInit.2.qml")); + + VERIFY_ERRORS(0); + QObject *o = component.create(); + QVERIFY(o != 0); + + QCOMPARE(o->property("test").toInt(), 123); + + delete o; + } +} + +// Test that registration order doesn't break type availability +// QTBUG-16878 +void tst_qqmllanguage::registrationOrder() +{ + QQmlComponent component(&engine, TEST_FILE("registrationOrder.qml")); + + QObject *o = component.create(); + QVERIFY(o != 0); + QVERIFY(o->metaObject() == &MyVersion2Class::staticMetaObject); + delete o; +} + +void tst_qqmllanguage::readonly() +{ + QQmlComponent component(&engine, TEST_FILE("readonly.qml")); + + QObject *o = component.create(); + QVERIFY(o != 0); + + QCOMPARE(o->property("test1").toInt(), 10); + QCOMPARE(o->property("test2").toInt(), 18); + QCOMPARE(o->property("test3").toInt(), 13); + + o->setProperty("testData", 13); + + QCOMPARE(o->property("test1").toInt(), 10); + QCOMPARE(o->property("test2").toInt(), 22); + QCOMPARE(o->property("test3").toInt(), 13); + + o->setProperty("testData2", 2); + + QCOMPARE(o->property("test1").toInt(), 10); + QCOMPARE(o->property("test2").toInt(), 22); + QCOMPARE(o->property("test3").toInt(), 2); + + o->setProperty("test1", 11); + o->setProperty("test2", 11); + o->setProperty("test3", 11); + + QCOMPARE(o->property("test1").toInt(), 10); + QCOMPARE(o->property("test2").toInt(), 22); + QCOMPARE(o->property("test3").toInt(), 2); + + delete o; +} + +// QTBUG-18268 +void tst_qqmllanguage::remoteLoadCrash() +{ + TestHTTPServer server(14448); + server.serveDirectory(testdata()); + + QQmlComponent component(&engine); + component.setData("import QtQuick 2.0; Text {}", QUrl("http://127.0.0.1:14448/remoteLoadCrash.qml")); + while (component.isLoading()) + QCoreApplication::processEvents( QEventLoop::ExcludeUserInputEvents | QEventLoop::WaitForMoreEvents, 50); + + QObject *o = component.create(); + delete o; +} + +QTEST_MAIN(tst_qqmllanguage) + +#include "tst_qqmllanguage.moc" diff --git a/tests/auto/qml/qqmllistreference/data/MyType.qml b/tests/auto/qml/qqmllistreference/data/MyType.qml new file mode 100644 index 0000000000..f48a77598c --- /dev/null +++ b/tests/auto/qml/qqmllistreference/data/MyType.qml @@ -0,0 +1,5 @@ +import QtQuick 2.0 + +QtObject { + property int a +} diff --git a/tests/auto/qml/qqmllistreference/data/engineTypes.qml b/tests/auto/qml/qqmllistreference/data/engineTypes.qml new file mode 100644 index 0000000000..99a61a7680 --- /dev/null +++ b/tests/auto/qml/qqmllistreference/data/engineTypes.qml @@ -0,0 +1,9 @@ +import QtQuick 2.0 + +QtObject { + property list myList + + myList: [ MyType { a: 1 }, + MyType { a: 9 } ] + +} diff --git a/tests/auto/qml/qqmllistreference/data/variantToList.qml b/tests/auto/qml/qqmllistreference/data/variantToList.qml new file mode 100644 index 0000000000..3728cd0311 --- /dev/null +++ b/tests/auto/qml/qqmllistreference/data/variantToList.qml @@ -0,0 +1,10 @@ +import QtQuick 2.0 + +QtObject { + property list myList; + myList: QtObject {} + + property variant value: myList + property int test: value.length +} + diff --git a/tests/auto/qml/qqmllistreference/qqmllistreference.pro b/tests/auto/qml/qqmllistreference/qqmllistreference.pro new file mode 100644 index 0000000000..baca1e7c71 --- /dev/null +++ b/tests/auto/qml/qqmllistreference/qqmllistreference.pro @@ -0,0 +1,15 @@ +CONFIG += testcase +TARGET = tst_qqmllistreference +macx:CONFIG -= app_bundle + +SOURCES += tst_qqmllistreference.cpp + +include (../../shared/util.pri) + +testDataFiles.files = data +testDataFiles.path = . +DEPLOYMENT += testDataFiles + +CONFIG += parallel_test + +QT += core-private gui-private qml-private testlib diff --git a/tests/auto/qml/qqmllistreference/tst_qqmllistreference.cpp b/tests/auto/qml/qqmllistreference/tst_qqmllistreference.cpp new file mode 100644 index 0000000000..bcb8ee8963 --- /dev/null +++ b/tests/auto/qml/qqmllistreference/tst_qqmllistreference.cpp @@ -0,0 +1,570 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "../../shared/util.h" + +class tst_qqmllistreference : public QQmlDataTest +{ + Q_OBJECT +public: + tst_qqmllistreference() {} + +private slots: + void initTestCase(); + void qmllistreference(); + void qmllistreference_invalid(); + void isValid(); + void object(); + void listElementType(); + void canAppend(); + void canAt(); + void canClear(); + void canCount(); + void append(); + void at(); + void clear(); + void count(); + void copy(); + void qmlmetaproperty(); + void engineTypes(); + void variantToList(); +}; + +class TestType : public QObject +{ + Q_OBJECT + Q_PROPERTY(QQmlListProperty data READ dataProperty) + Q_PROPERTY(int intProperty READ intProperty) + +public: + TestType() : property(this, data) {} + QQmlListProperty dataProperty() { return property; } + int intProperty() const { return 10; } + + QList data; + QQmlListProperty property; +}; + +void tst_qqmllistreference::initTestCase() +{ + QQmlDataTest::initTestCase(); + qmlRegisterType(); +} + +void tst_qqmllistreference::qmllistreference() +{ + TestType tt; + + QQmlListReference r(&tt, "data"); + QVERIFY(r.isValid() == true); + QCOMPARE(r.count(), 0); + + tt.data.append(&tt); + QCOMPARE(r.count(), 1); +} + +void tst_qqmllistreference::qmllistreference_invalid() +{ + TestType tt; + + // Invalid + { + QQmlListReference r; + QVERIFY(r.isValid() == false); + QVERIFY(r.object() == 0); + QVERIFY(r.listElementType() == 0); + QVERIFY(r.canAt() == false); + QVERIFY(r.canClear() == false); + QVERIFY(r.canCount() == false); + QVERIFY(r.append(0) == false); + QVERIFY(r.at(10) == 0); + QVERIFY(r.clear() == false); + QVERIFY(r.count() == 0); + } + + // Non-property + { + QQmlListReference r(&tt, "blah"); + QVERIFY(r.isValid() == false); + QVERIFY(r.object() == 0); + QVERIFY(r.listElementType() == 0); + QVERIFY(r.canAt() == false); + QVERIFY(r.canClear() == false); + QVERIFY(r.canCount() == false); + QVERIFY(r.append(0) == false); + QVERIFY(r.at(10) == 0); + QVERIFY(r.clear() == false); + QVERIFY(r.count() == 0); + } + + // Non-list property + { + QQmlListReference r(&tt, "intProperty"); + QVERIFY(r.isValid() == false); + QVERIFY(r.object() == 0); + QVERIFY(r.listElementType() == 0); + QVERIFY(r.canAt() == false); + QVERIFY(r.canClear() == false); + QVERIFY(r.canCount() == false); + QVERIFY(r.append(0) == false); + QVERIFY(r.at(10) == 0); + QVERIFY(r.clear() == false); + QVERIFY(r.count() == 0); + } +} + +void tst_qqmllistreference::isValid() +{ + TestType *tt = new TestType; + + { + QQmlListReference ref; + QVERIFY(ref.isValid() == false); + } + + { + QQmlListReference ref(tt, "blah"); + QVERIFY(ref.isValid() == false); + } + + { + QQmlListReference ref(tt, "data"); + QVERIFY(ref.isValid() == true); + delete tt; + QVERIFY(ref.isValid() == false); + } +} + +void tst_qqmllistreference::object() +{ + TestType *tt = new TestType; + + { + QQmlListReference ref; + QVERIFY(ref.object() == 0); + } + + { + QQmlListReference ref(tt, "blah"); + QVERIFY(ref.object() == 0); + } + + { + QQmlListReference ref(tt, "data"); + QVERIFY(ref.object() == tt); + delete tt; + QVERIFY(ref.object() == 0); + } +} + +void tst_qqmllistreference::listElementType() +{ + TestType *tt = new TestType; + + { + QQmlListReference ref; + QVERIFY(ref.listElementType() == 0); + } + + { + QQmlListReference ref(tt, "blah"); + QVERIFY(ref.listElementType() == 0); + } + + { + QQmlListReference ref(tt, "data"); + QVERIFY(ref.listElementType() == &TestType::staticMetaObject); + delete tt; + QVERIFY(ref.listElementType() == 0); + } +} + +void tst_qqmllistreference::canAppend() +{ + TestType *tt = new TestType; + + { + QQmlListReference ref; + QVERIFY(ref.canAppend() == false); + } + + { + QQmlListReference ref(tt, "blah"); + QVERIFY(ref.canAppend() == false); + } + + { + QQmlListReference ref(tt, "data"); + QVERIFY(ref.canAppend() == true); + delete tt; + QVERIFY(ref.canAppend() == false); + } + + { + TestType tt; + tt.property.append = 0; + QQmlListReference ref(&tt, "data"); + QVERIFY(ref.canAppend() == false); + } +} + +void tst_qqmllistreference::canAt() +{ + TestType *tt = new TestType; + + { + QQmlListReference ref; + QVERIFY(ref.canAt() == false); + } + + { + QQmlListReference ref(tt, "blah"); + QVERIFY(ref.canAt() == false); + } + + { + QQmlListReference ref(tt, "data"); + QVERIFY(ref.canAt() == true); + delete tt; + QVERIFY(ref.canAt() == false); + } + + { + TestType tt; + tt.property.at = 0; + QQmlListReference ref(&tt, "data"); + QVERIFY(ref.canAt() == false); + } +} + +void tst_qqmllistreference::canClear() +{ + TestType *tt = new TestType; + + { + QQmlListReference ref; + QVERIFY(ref.canClear() == false); + } + + { + QQmlListReference ref(tt, "blah"); + QVERIFY(ref.canClear() == false); + } + + { + QQmlListReference ref(tt, "data"); + QVERIFY(ref.canClear() == true); + delete tt; + QVERIFY(ref.canClear() == false); + } + + { + TestType tt; + tt.property.clear = 0; + QQmlListReference ref(&tt, "data"); + QVERIFY(ref.canClear() == false); + } +} + +void tst_qqmllistreference::canCount() +{ + TestType *tt = new TestType; + + { + QQmlListReference ref; + QVERIFY(ref.canCount() == false); + } + + { + QQmlListReference ref(tt, "blah"); + QVERIFY(ref.canCount() == false); + } + + { + QQmlListReference ref(tt, "data"); + QVERIFY(ref.canCount() == true); + delete tt; + QVERIFY(ref.canCount() == false); + } + + { + TestType tt; + tt.property.count = 0; + QQmlListReference ref(&tt, "data"); + QVERIFY(ref.canCount() == false); + } +} + +void tst_qqmllistreference::append() +{ + TestType *tt = new TestType; + QObject object; + + { + QQmlListReference ref; + QVERIFY(ref.append(tt) == false); + } + + { + QQmlListReference ref(tt, "blah"); + QVERIFY(ref.append(tt) == false); + } + + { + QQmlListReference ref(tt, "data"); + QVERIFY(ref.append(tt) == true); + QVERIFY(tt->data.count() == 1); + QVERIFY(tt->data.at(0) == tt); + QVERIFY(ref.append(&object) == false); + QVERIFY(tt->data.count() == 1); + QVERIFY(tt->data.at(0) == tt); + QVERIFY(ref.append(0) == true); + QVERIFY(tt->data.count() == 2); + QVERIFY(tt->data.at(0) == tt); + QVERIFY(tt->data.at(1) == 0); + delete tt; + QVERIFY(ref.append(0) == false); + } + + { + TestType tt; + tt.property.append = 0; + QQmlListReference ref(&tt, "data"); + QVERIFY(ref.append(&tt) == false); + } +} + +void tst_qqmllistreference::at() +{ + TestType *tt = new TestType; + tt->data.append(tt); + tt->data.append(0); + tt->data.append(tt); + + { + QQmlListReference ref; + QVERIFY(ref.at(0) == 0); + } + + { + QQmlListReference ref(tt, "blah"); + QVERIFY(ref.at(0) == 0); + } + + { + QQmlListReference ref(tt, "data"); + QVERIFY(ref.at(0) == tt); + QVERIFY(ref.at(1) == 0); + QVERIFY(ref.at(2) == tt); + delete tt; + QVERIFY(ref.at(0) == 0); + } + + { + TestType tt; + tt.data.append(&tt); + tt.property.at = 0; + QQmlListReference ref(&tt, "data"); + QVERIFY(ref.at(0) == 0); + } +} + +void tst_qqmllistreference::clear() +{ + TestType *tt = new TestType; + tt->data.append(tt); + tt->data.append(0); + tt->data.append(tt); + + { + QQmlListReference ref; + QVERIFY(ref.clear() == false); + } + + { + QQmlListReference ref(tt, "blah"); + QVERIFY(ref.clear() == false); + } + + { + QQmlListReference ref(tt, "data"); + QVERIFY(ref.clear() == true); + QVERIFY(tt->data.count() == 0); + delete tt; + QVERIFY(ref.clear() == false); + } + + { + TestType tt; + tt.property.clear = 0; + QQmlListReference ref(&tt, "data"); + QVERIFY(ref.clear() == false); + } +} + +void tst_qqmllistreference::count() +{ + TestType *tt = new TestType; + tt->data.append(tt); + tt->data.append(0); + tt->data.append(tt); + + { + QQmlListReference ref; + QVERIFY(ref.count() == 0); + } + + { + QQmlListReference ref(tt, "blah"); + QVERIFY(ref.count() == 0); + } + + { + QQmlListReference ref(tt, "data"); + QVERIFY(ref.count() == 3); + tt->data.removeAt(1); + QVERIFY(ref.count() == 2); + delete tt; + QVERIFY(ref.count() == 0); + } + + { + TestType tt; + tt.data.append(&tt); + tt.property.count = 0; + QQmlListReference ref(&tt, "data"); + QVERIFY(ref.count() == 0); + } +} + +void tst_qqmllistreference::copy() +{ + TestType tt; + tt.data.append(&tt); + tt.data.append(0); + tt.data.append(&tt); + + QQmlListReference *r1 = new QQmlListReference(&tt, "data"); + QVERIFY(r1->count() == 3); + + QQmlListReference r2(*r1); + QQmlListReference r3; + r3 = *r1; + + QVERIFY(r2.count() == 3); + QVERIFY(r3.count() == 3); + + delete r1; + + QVERIFY(r2.count() == 3); + QVERIFY(r3.count() == 3); + + tt.data.removeAt(2); + + QVERIFY(r2.count() == 2); + QVERIFY(r3.count() == 2); +} + +void tst_qqmllistreference::qmlmetaproperty() +{ + TestType tt; + tt.data.append(&tt); + tt.data.append(0); + tt.data.append(&tt); + + QQmlProperty prop(&tt, QLatin1String("data")); + QVariant v = prop.read(); + QVERIFY(v.userType() == qMetaTypeId()); + QQmlListReference ref = qvariant_cast(v); + QVERIFY(ref.count() == 3); + QVERIFY(ref.listElementType() == &TestType::staticMetaObject); +} + +void tst_qqmllistreference::engineTypes() +{ + QQmlEngine engine; + QQmlComponent component(&engine, testFileUrl("engineTypes.qml")); + + QObject *o = component.create(); + QVERIFY(o); + + QQmlProperty p1(o, QLatin1String("myList")); + QVERIFY(p1.propertyTypeCategory() == QQmlProperty::Normal); + + QQmlProperty p2(o, QLatin1String("myList"), engine.rootContext()); + QVERIFY(p2.propertyTypeCategory() == QQmlProperty::List); + QVariant v = p2.read(); + QVERIFY(v.userType() == qMetaTypeId()); + QQmlListReference ref = qvariant_cast(v); + QVERIFY(ref.count() == 2); + QVERIFY(ref.listElementType()); + QVERIFY(ref.listElementType() != &QObject::staticMetaObject); + + delete o; +} + +void tst_qqmllistreference::variantToList() +{ + QQmlEngine engine; + QQmlComponent component(&engine, testFileUrl("variantToList.qml")); + + QObject *o = component.create(); + QVERIFY(o); + + QVERIFY(o->property("value").userType() == qMetaTypeId()); + QCOMPARE(o->property("test").toInt(), 1); + + delete o; +} + +QTEST_MAIN(tst_qqmllistreference) + +#include "tst_qqmllistreference.moc" diff --git a/tests/auto/qml/qqmllocale/data/date.qml b/tests/auto/qml/qqmllocale/data/date.qml new file mode 100644 index 0000000000..3f58497d22 --- /dev/null +++ b/tests/auto/qml/qqmllocale/data/date.qml @@ -0,0 +1,45 @@ +import QtQuick 2.0 + +QtObject { + property var locale: Qt.locale() + + function setLocale(l) { + locale = Qt.locale(l) + } + + function toLocaleString(fmt) { + var d = new Date(2011, 9, 7, 18, 53, 48, 345); + if (fmt < 0) + return d.toLocaleString(locale); + else + return d.toLocaleString(locale, fmt); + } + + function toLocaleDateString(fmt) { + var d = new Date(2011, 9, 7, 18, 53, 48, 345); + if (fmt < 0) + return d.toLocaleDateString(locale); + else + return d.toLocaleDateString(locale, fmt); + } + + function toLocaleTimeString(fmt) { + var d = new Date(2011, 9, 7, 18, 53, 48, 345); + if (fmt < 0) + return d.toLocaleTimeString(locale); + else + return d.toLocaleTimeString(locale, fmt); + } + + function fromLocaleString(d,fmt) { + return Date.fromLocaleString(locale, d, fmt) + } + + function fromLocaleDateString(d,fmt) { + return Date.fromLocaleDateString(locale, d, fmt) + } + + function fromLocaleTimeString(d,fmt) { + return Date.fromLocaleTimeString(locale, d, fmt) + } +} diff --git a/tests/auto/qml/qqmllocale/data/functions.qml b/tests/auto/qml/qqmllocale/data/functions.qml new file mode 100644 index 0000000000..5fef6a26fb --- /dev/null +++ b/tests/auto/qml/qqmllocale/data/functions.qml @@ -0,0 +1,65 @@ +import QtQuick 2.0 + +QtObject { + property var locale: Qt.locale() + + function setLocale(l) { + locale = Qt.locale(l) + } + + function currencySymbol(type) { + if (type < 0) + return locale.currencySymbol() + else + return locale.currencySymbol(type) + } + + function monthName(month,type) { + if (type < 0) + return locale.monthName(month) + else + return locale.monthName(month, type) + } + + function standaloneMonthName(month,type) { + if (type < 0) + return locale.standaloneMonthName(month) + else + return locale.standaloneMonthName(month, type) + } + + function dayName(month,type) { + if (type < 0) + return locale.dayName(month) + else + return locale.dayName(month, type) + } + + function standaloneDayName(month,type) { + if (type < 0) + return locale.standaloneDayName(month) + else + return locale.standaloneDayName(month, type) + } + + function dateTimeFormat(fmt) { + if (fmt < 0) + return locale.dateTimeFormat() + else + return locale.dateTimeFormat(fmt) + } + + function dateFormat(fmt) { + if (fmt < 0) + return locale.dateFormat() + else + return locale.dateFormat(fmt) + } + + function timeFormat(fmt) { + if (fmt < 0) + return locale.timeFormat() + else + return locale.timeFormat(fmt) + } +} diff --git a/tests/auto/qml/qqmllocale/data/localeCompare.qml b/tests/auto/qml/qqmllocale/data/localeCompare.qml new file mode 100644 index 0000000000..6851af6ef9 --- /dev/null +++ b/tests/auto/qml/qqmllocale/data/localeCompare.qml @@ -0,0 +1,7 @@ +import QtQuick 2.0 + +QtObject { + property var string1: "a" + property var string2: "a" + property var comparison: string1.localeCompare(string2) +} diff --git a/tests/auto/qml/qqmllocale/data/number.qml b/tests/auto/qml/qqmllocale/data/number.qml new file mode 100644 index 0000000000..51a6c15dce --- /dev/null +++ b/tests/auto/qml/qqmllocale/data/number.qml @@ -0,0 +1,30 @@ +import QtQuick 2.0 + +QtObject { + property var locale: Qt.locale() + + function setLocale(l) { + locale = Qt.locale(l) + } + + function toLocaleString(n,fmt,prec) { + if (prec < 0) + return n.toLocaleString(locale, fmt); + else + return n.toLocaleString(locale, fmt, prec); + } + + function toLocaleCurrencyString(n,symbol) { + if (symbol.length == 0) + return n.toLocaleCurrencyString(locale); + else + return n.toLocaleCurrencyString(locale, symbol); + } + + function fromLocaleString(n) { + return Number.fromLocaleString(locale, n) + } + + property var const1: 1234.56.toLocaleString(locale); + property var const2: 1234..toLocaleString(locale); +} diff --git a/tests/auto/qml/qqmllocale/data/properties.qml b/tests/auto/qml/qqmllocale/data/properties.qml new file mode 100644 index 0000000000..16d1f4092a --- /dev/null +++ b/tests/auto/qml/qqmllocale/data/properties.qml @@ -0,0 +1,27 @@ +import QtQuick 2.0 + +QtObject { + property var locale: Qt.locale() + + function setLocale(l) { + locale = Qt.locale(l); + } + + property var name: locale.name + property var amText: locale.amText + property var pmText: locale.pmText + property var nativeLanguageName: locale.nativeLanguageName + property var nativeCountryName: locale.nativeCountryName + property var decimalPoint: locale.decimalPoint + property var groupSeparator: locale.groupSeparator + property var percent: locale.percent + property var zeroDigit: locale.zeroDigit + property var negativeSign: locale.negativeSign + property var positiveSign: locale.positiveSign + property var exponential: locale.exponential + property var firstDayOfWeek: locale.firstDayOfWeek + property var measurementSystem: locale.measurementSystem + property var textDirection: locale.textDirection + property var weekDays: locale.weekDays + property var uiLanguages: locale.uiLanguages +} diff --git a/tests/auto/qml/qqmllocale/qqmllocale.pro b/tests/auto/qml/qqmllocale/qqmllocale.pro new file mode 100644 index 0000000000..1773f83f91 --- /dev/null +++ b/tests/auto/qml/qqmllocale/qqmllocale.pro @@ -0,0 +1,15 @@ +CONFIG += testcase +TARGET = tst_qqmllocale +macx:CONFIG -= app_bundle + +SOURCES += tst_qqmllocale.cpp + +include (../../shared/util.pri) + +testDataFiles.files = data +testDataFiles.path = . +DEPLOYMENT += testDataFiles + +CONFIG += parallel_test + +QT += qml testlib diff --git a/tests/auto/qml/qqmllocale/tst_qqmllocale.cpp b/tests/auto/qml/qqmllocale/tst_qqmllocale.cpp new file mode 100644 index 0000000000..af1a81847b --- /dev/null +++ b/tests/auto/qml/qqmllocale/tst_qqmllocale.cpp @@ -0,0 +1,1183 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include +#include + +#include +#include +#include +#include +#include "../../shared/util.h" + +class tst_qqmllocale : public QQmlDataTest +{ + Q_OBJECT +public: + tst_qqmllocale() { } + +private slots: + void defaultLocale(); + + void properties_data(); + void properties(); + void currencySymbol_data(); + void currencySymbol(); + void monthName_data(); + void monthName(); + void standaloneMonthName_data(); + void standaloneMonthName(); + void dayName_data(); + void dayName(); + void standaloneDayName_data(); + void standaloneDayName(); + void weekDays_data(); + void weekDays(); + void uiLanguages_data(); + void uiLanguages(); + void dateFormat_data(); + void dateFormat(); + void dateTimeFormat_data(); + void dateTimeFormat(); + void timeFormat_data(); + void timeFormat(); + + void dateToLocaleString_data(); + void dateToLocaleString(); + void dateToLocaleStringFormatted_data(); + void dateToLocaleStringFormatted(); + void dateToLocaleDateString_data(); + void dateToLocaleDateString(); + void dateToLocaleDateStringFormatted_data(); + void dateToLocaleDateStringFormatted(); + void dateToLocaleTimeString_data(); + void dateToLocaleTimeString(); + void dateToLocaleTimeStringFormatted_data(); + void dateToLocaleTimeStringFormatted(); + void dateFromLocaleString_data(); + void dateFromLocaleString(); + void dateFromLocaleDateString_data(); + void dateFromLocaleDateString(); + void dateFromLocaleTimeString_data(); + void dateFromLocaleTimeString(); + + void numberToLocaleString_data(); + void numberToLocaleString(); + void numberToLocaleCurrencyString_data(); + void numberToLocaleCurrencyString(); + void numberFromLocaleString_data(); + void numberFromLocaleString(); + void numberConstToLocaleString(); + + void stringLocaleCompare_data(); + void stringLocaleCompare(); + +private: + void addPropertyData(const QString &l); + QVariant getProperty(QObject *obj, const QString &locale, const QString &property); + void addCurrencySymbolData(const QString &locale); + void addStandardFormatData(); + void addFormatNameData(const QString &locale); + void addDateTimeFormatData(const QString &l); + void addDateFormatData(const QString &l); + void addTimeFormatData(const QString &l); + QQmlEngine engine; +}; + +void tst_qqmllocale::defaultLocale() +{ + QQmlComponent c(&engine, testFileUrl("properties.qml")); + + QObject *obj = c.create(); + QVERIFY(obj); + + QCOMPARE(obj->property("name").toString(), QLocale().name()); +} + +#define LOCALE_PROP(type,prop) { #prop, QVariant(type(qlocale.prop())) } + +void tst_qqmllocale::addPropertyData(const QString &l) +{ + QLocale qlocale(l); + + struct { + const char *name; + QVariant value; + } + values[] = { + LOCALE_PROP(QString,name), + LOCALE_PROP(QString,amText), + LOCALE_PROP(QString,pmText), + LOCALE_PROP(QString,nativeLanguageName), + LOCALE_PROP(QString,nativeCountryName), + LOCALE_PROP(QString,decimalPoint), + LOCALE_PROP(QString,groupSeparator), + LOCALE_PROP(QString,percent), + LOCALE_PROP(QString,zeroDigit), + LOCALE_PROP(QString,negativeSign), + LOCALE_PROP(QString,positiveSign), + LOCALE_PROP(QString,exponential), + LOCALE_PROP(int,firstDayOfWeek), + LOCALE_PROP(int,measurementSystem), + LOCALE_PROP(int,textDirection), + { 0, QVariant() } + }; + + int i = 0; + while (values[i].name) { + QByteArray n = l.toLatin1() + ':' + values[i].name; + QTest::newRow(n.constData()) << l << QByteArray(values[i].name) << values[i].value; + ++i; + } +} + +void tst_qqmllocale::properties_data() +{ + QTest::addColumn("locale"); + QTest::addColumn("property"); + QTest::addColumn("value"); + + addPropertyData("en_US"); + addPropertyData("de_DE"); + addPropertyData("ar_SA"); + addPropertyData("hi_IN"); + addPropertyData("zh_CN"); + addPropertyData("th_TH"); +} + +void tst_qqmllocale::properties() +{ + QFETCH(QString, locale); + QFETCH(QByteArray, property); + QFETCH(QVariant, value); + + QQmlComponent c(&engine, testFileUrl("properties.qml")); + + QObject *obj = c.create(); + QVERIFY(obj); + + QMetaObject::invokeMethod(obj, "setLocale", Qt::DirectConnection, + Q_ARG(QVariant, QVariant(locale))); + + QCOMPARE(obj->property(property), value); + + delete obj; +} + +void tst_qqmllocale::addCurrencySymbolData(const QString &l) +{ + QByteArray locale = l.toLatin1(); + QTest::newRow(locale.constData()) << l << -1; + QByteArray t(locale); + t += " CurrencyIsoCode"; + QTest::newRow(t.constData()) << l << (int)QLocale::CurrencyIsoCode; + t = locale + " CurrencySymbol"; + QTest::newRow(t.constData()) << l << (int)QLocale::CurrencySymbol; + t = locale + " CurrencyDisplayName"; + QTest::newRow(t.constData()) << l << (int)QLocale::CurrencyDisplayName; +} + +void tst_qqmllocale::currencySymbol_data() +{ + QTest::addColumn("locale"); + QTest::addColumn("param"); + + addCurrencySymbolData("en_US"); + addCurrencySymbolData("de_DE"); + addCurrencySymbolData("ar_SA"); + addCurrencySymbolData("hi_IN"); + addCurrencySymbolData("zh_CN"); + addCurrencySymbolData("th_TH"); +} + +void tst_qqmllocale::currencySymbol() +{ + QFETCH(QString, locale); + QFETCH(int, param); + + QQmlComponent c(&engine, testFileUrl("functions.qml")); + + QObject *obj = c.create(); + QVERIFY(obj); + + QLocale l(locale); + QVariant val; + QLocale::CurrencySymbolFormat format = QLocale::CurrencySymbol; + + if (param >= 0) + format = QLocale::CurrencySymbolFormat(param); + + QMetaObject::invokeMethod(obj, "setLocale", Qt::DirectConnection, + Q_ARG(QVariant, QVariant(locale))); + + QMetaObject::invokeMethod(obj, "currencySymbol", Qt::DirectConnection, + Q_RETURN_ARG(QVariant, val), + Q_ARG(QVariant, QVariant(int(format)))); + + QCOMPARE(val.toString(), l.currencySymbol(format)); + + delete obj; +} + +void tst_qqmllocale::addFormatNameData(const QString &l) +{ + QByteArray locale = l.toLatin1(); + QTest::newRow(locale.constData()) << l << -1; + QByteArray t(locale); + t += " LongFormat"; + QTest::newRow(t.constData()) << l << (int)QLocale::LongFormat; + t = locale + " ShortFormat"; + QTest::newRow(t.constData()) << l << (int)QLocale::ShortFormat; + t = locale + " NarrowFormat"; + QTest::newRow(t.constData()) << l << (int)QLocale::NarrowFormat; +} + +void tst_qqmllocale::addStandardFormatData() +{ + QTest::addColumn("locale"); + QTest::addColumn("param"); + + addFormatNameData("en_US"); + addFormatNameData("de_DE"); + addFormatNameData("ar_SA"); + addFormatNameData("hi_IN"); + addFormatNameData("zh_CN"); + addFormatNameData("th_TH"); +} + +void tst_qqmllocale::monthName_data() +{ + addStandardFormatData(); +} + +void tst_qqmllocale::monthName() +{ + QFETCH(QString, locale); + QFETCH(int, param); + + QQmlComponent c(&engine, testFileUrl("functions.qml")); + + QObject *obj = c.create(); + QVERIFY(obj); + + QLocale l(locale); + QVariant val; + QLocale::FormatType format = QLocale::LongFormat; + if (param >= 0) + format = QLocale::FormatType(param); + + QMetaObject::invokeMethod(obj, "setLocale", Qt::DirectConnection, + Q_ARG(QVariant, QVariant(locale))); + + for (int i = 0; i <= 11; ++i) { + QMetaObject::invokeMethod(obj, "monthName", Qt::DirectConnection, + Q_RETURN_ARG(QVariant, val), + Q_ARG(QVariant, QVariant(i)), + Q_ARG(QVariant, QVariant(int(format)))); + + // QLocale January == 1, JS Date January == 0 + QCOMPARE(val.toString(), l.monthName(i+1, format)); + } + + delete obj; +} + +void tst_qqmllocale::standaloneMonthName_data() +{ + addStandardFormatData(); +} + +void tst_qqmllocale::standaloneMonthName() +{ + QFETCH(QString, locale); + QFETCH(int, param); + + QQmlComponent c(&engine, testFileUrl("functions.qml")); + + QObject *obj = c.create(); + QVERIFY(obj); + + QLocale l(locale); + QVariant val; + QLocale::FormatType format = QLocale::LongFormat; + if (param >= 0) + format = QLocale::FormatType(param); + + QMetaObject::invokeMethod(obj, "setLocale", Qt::DirectConnection, + Q_ARG(QVariant, QVariant(locale))); + + for (int i = 0; i <= 11; ++i) { + QMetaObject::invokeMethod(obj, "standaloneMonthName", Qt::DirectConnection, + Q_RETURN_ARG(QVariant, val), + Q_ARG(QVariant, QVariant(i)), + Q_ARG(QVariant, QVariant(int(format)))); + + // QLocale January == 1, JS Date January == 0 + QCOMPARE(val.toString(), l.standaloneMonthName(i+1, format)); + } + + delete obj; +} + +void tst_qqmllocale::dayName_data() +{ + addStandardFormatData(); +} + +void tst_qqmllocale::dayName() +{ + QFETCH(QString, locale); + QFETCH(int, param); + + QQmlComponent c(&engine, testFileUrl("functions.qml")); + + QObject *obj = c.create(); + QVERIFY(obj); + + QLocale l(locale); + QVariant val; + QLocale::FormatType format = QLocale::LongFormat; + if (param >= 0) + format = QLocale::FormatType(param); + + QMetaObject::invokeMethod(obj, "setLocale", Qt::DirectConnection, + Q_ARG(QVariant, QVariant(locale))); + + for (int i = 1; i <= 7; ++i) { + QMetaObject::invokeMethod(obj, "dayName", Qt::DirectConnection, + Q_RETURN_ARG(QVariant, val), + Q_ARG(QVariant, QVariant(i)), + Q_ARG(QVariant, QVariant(int(format)))); + + QCOMPARE(val.toString(), l.dayName(i, format)); + } + + delete obj; +} + +void tst_qqmllocale::standaloneDayName_data() +{ + addStandardFormatData(); +} + +void tst_qqmllocale::standaloneDayName() +{ + QFETCH(QString, locale); + QFETCH(int, param); + + QQmlComponent c(&engine, testFileUrl("functions.qml")); + + QObject *obj = c.create(); + QVERIFY(obj); + + QLocale l(locale); + QVariant val; + QLocale::FormatType format = param < 0 ? QLocale::LongFormat : QLocale::FormatType(param); + + QMetaObject::invokeMethod(obj, "setLocale", Qt::DirectConnection, + Q_ARG(QVariant, QVariant(locale))); + + for (int i = 1; i <= 7; ++i) { + QMetaObject::invokeMethod(obj, "standaloneDayName", Qt::DirectConnection, + Q_RETURN_ARG(QVariant, val), + Q_ARG(QVariant, QVariant(i)), + Q_ARG(QVariant, QVariant(int(format)))); + + QCOMPARE(val.toString(), l.standaloneDayName(i, format)); + } + + delete obj; +} + +void tst_qqmllocale::weekDays_data() +{ + QTest::addColumn("locale"); + + QTest::newRow("en_US") << "en_US"; + QTest::newRow("de_DE") << "de_DE"; + QTest::newRow("ar_SA") << "ar_SA"; + QTest::newRow("hi_IN") << "hi_IN"; + QTest::newRow("zh_CN") << "zh_CN"; + QTest::newRow("th_TH") << "th_TH"; +} + +void tst_qqmllocale::weekDays() +{ + QFETCH(QString, locale); + + QQmlComponent c(&engine, testFileUrl("properties.qml")); + + QObject *obj = c.create(); + QVERIFY(obj); + + QMetaObject::invokeMethod(obj, "setLocale", Qt::DirectConnection, + Q_ARG(QVariant, QVariant(locale))); + + QVariant val = obj->property("weekDays"); + QVERIFY(val.type() == QVariant::List); + + QList qmlDays = val.toList(); + QList days = QLocale(locale).weekdays(); + + QVERIFY(days.count() == qmlDays.count()); + + for (int i = 0; i < days.count(); ++i) { + int day = int(days.at(i)); + if (day == 7) // JS Date days in range 0(Sunday) to 6(Saturday) + day = 0; + QCOMPARE(day, qmlDays.at(i).toInt()); + } + + delete obj; +} + +void tst_qqmllocale::uiLanguages_data() +{ + QTest::addColumn("locale"); + + QTest::newRow("en_US") << "en_US"; + QTest::newRow("de_DE") << "de_DE"; + QTest::newRow("ar_SA") << "ar_SA"; + QTest::newRow("hi_IN") << "hi_IN"; + QTest::newRow("zh_CN") << "zh_CN"; + QTest::newRow("th_TH") << "th_TH"; +} + +void tst_qqmllocale::uiLanguages() +{ + QFETCH(QString, locale); + + QQmlComponent c(&engine, testFileUrl("properties.qml")); + + QObject *obj = c.create(); + QVERIFY(obj); + + QMetaObject::invokeMethod(obj, "setLocale", Qt::DirectConnection, + Q_ARG(QVariant, QVariant(locale))); + + QVariant val = obj->property("uiLanguages"); + QVERIFY(val.type() == QVariant::List); + + QList qmlLangs = val.toList(); + QStringList langs = QLocale(locale).uiLanguages(); + + QVERIFY(langs.count() == qmlLangs.count()); + + for (int i = 0; i < langs.count(); ++i) { + QCOMPARE(langs.at(i), qmlLangs.at(i).toString()); + } + + delete obj; +} + + +void tst_qqmllocale::dateTimeFormat_data() +{ + addStandardFormatData(); +} + +void tst_qqmllocale::dateTimeFormat() +{ + QFETCH(QString, locale); + QFETCH(int, param); + + QQmlComponent c(&engine, testFileUrl("functions.qml")); + + QObject *obj = c.create(); + QVERIFY(obj); + + QLocale l(locale); + QVariant val; + + QMetaObject::invokeMethod(obj, "setLocale", Qt::DirectConnection, + Q_ARG(QVariant, QVariant(locale))); + + QLocale::FormatType format = param < 0 ? QLocale::LongFormat : QLocale::FormatType(param); + QMetaObject::invokeMethod(obj, "dateTimeFormat", Qt::DirectConnection, + Q_RETURN_ARG(QVariant, val), + Q_ARG(QVariant, QVariant(param))); + + QCOMPARE(val.toString(), l.dateTimeFormat(format)); +} + +void tst_qqmllocale::dateFormat_data() +{ + addStandardFormatData(); +} + +void tst_qqmllocale::dateFormat() +{ + QFETCH(QString, locale); + QFETCH(int, param); + + QQmlComponent c(&engine, testFileUrl("functions.qml")); + + QObject *obj = c.create(); + QVERIFY(obj); + + QLocale l(locale); + QVariant val; + + QMetaObject::invokeMethod(obj, "setLocale", Qt::DirectConnection, + Q_ARG(QVariant, QVariant(locale))); + + QLocale::FormatType format = param < 0 ? QLocale::LongFormat : QLocale::FormatType(param); + QMetaObject::invokeMethod(obj, "dateFormat", Qt::DirectConnection, + Q_RETURN_ARG(QVariant, val), + Q_ARG(QVariant, QVariant(param))); + + QCOMPARE(val.toString(), l.dateFormat(format)); +} + +void tst_qqmllocale::timeFormat_data() +{ + addStandardFormatData(); +} + +void tst_qqmllocale::timeFormat() +{ + QFETCH(QString, locale); + QFETCH(int, param); + + QQmlComponent c(&engine, testFileUrl("functions.qml")); + + QObject *obj = c.create(); + QVERIFY(obj); + + QLocale l(locale); + QVariant val; + + QMetaObject::invokeMethod(obj, "setLocale", Qt::DirectConnection, + Q_ARG(QVariant, QVariant(locale))); + + QLocale::FormatType format = param < 0 ? QLocale::LongFormat : QLocale::FormatType(param); + QMetaObject::invokeMethod(obj, "timeFormat", Qt::DirectConnection, + Q_RETURN_ARG(QVariant, val), + Q_ARG(QVariant, QVariant(param))); + + QCOMPARE(val.toString(), l.timeFormat(format)); +} + +void tst_qqmllocale::dateToLocaleString_data() +{ + addStandardFormatData(); +} + +void tst_qqmllocale::dateToLocaleString() +{ + QFETCH(QString, locale); + QFETCH(int, param); + + QQmlComponent c(&engine, testFileUrl("date.qml")); + + QObject *obj = c.create(); + QVERIFY(obj); + + QDateTime dt; + dt.setDate(QDate(2011, 10, 7)); // weirdly, JS Date month range is 0-11 + dt.setTime(QTime(18, 53, 48, 345)); + + QMetaObject::invokeMethod(obj, "setLocale", Qt::DirectConnection, + Q_ARG(QVariant, QVariant(locale))); + + QLocale::FormatType format = param < 0 ? QLocale::LongFormat : QLocale::FormatType(param); + + QVariant val; + QMetaObject::invokeMethod(obj, "toLocaleString", Qt::DirectConnection, + Q_RETURN_ARG(QVariant, val), + Q_ARG(QVariant, QVariant(param))); + + QLocale l(locale); + QCOMPARE(val.toString(), l.toString(dt, format)); +} + +void tst_qqmllocale::addDateTimeFormatData(const QString &l) +{ + const char *formats[] = { + "hh:mm dd.MM.yyyy", + "h:m:sap ddd MMMM d yy", + "'The date and time is: 'H:mm:ss:zzz dd/MM/yy", + "MMM d yyyy HH:mm t", + 0 + }; + QByteArray locale = l.toLatin1(); + int i = 0; + while (formats[i]) { + QByteArray t(locale); + t += " "; + t += formats[i]; + QTest::newRow(t.constData()) << l << QString(formats[i]); + ++i; + } +} + +void tst_qqmllocale::dateToLocaleStringFormatted_data() +{ + QTest::addColumn("locale"); + QTest::addColumn("format"); + + addDateTimeFormatData("en_US"); + addDateTimeFormatData("de_DE"); + addDateTimeFormatData("ar_SA"); + addDateTimeFormatData("hi_IN"); + addDateTimeFormatData("zh_CN"); + addDateTimeFormatData("th_TH"); +} + +void tst_qqmllocale::dateToLocaleStringFormatted() +{ + QFETCH(QString, locale); + QFETCH(QString, format); + + QQmlComponent c(&engine, testFileUrl("date.qml")); + + QObject *obj = c.create(); + QVERIFY(obj); + + QDateTime dt; + dt.setDate(QDate(2011, 10, 7)); // weirdly, JS Date month range is 0-11 + dt.setTime(QTime(18, 53, 48, 345)); + + QMetaObject::invokeMethod(obj, "setLocale", Qt::DirectConnection, + Q_ARG(QVariant, QVariant(locale))); + + QVariant val; + QMetaObject::invokeMethod(obj, "toLocaleString", Qt::DirectConnection, + Q_RETURN_ARG(QVariant, val), + Q_ARG(QVariant, QVariant(format))); + + QLocale l(locale); + QCOMPARE(val.toString(), l.toString(dt, format)); +} + +void tst_qqmllocale::dateToLocaleDateString_data() +{ + addStandardFormatData(); +} + +void tst_qqmllocale::dateToLocaleDateString() +{ + QFETCH(QString, locale); + QFETCH(int, param); + + QQmlComponent c(&engine, testFileUrl("date.qml")); + + QObject *obj = c.create(); + QVERIFY(obj); + + QDateTime dt; + dt.setDate(QDate(2011, 10, 7)); // weirdly, JS Date month range is 0-11 + dt.setTime(QTime(18, 53, 48, 345)); + + QMetaObject::invokeMethod(obj, "setLocale", Qt::DirectConnection, + Q_ARG(QVariant, QVariant(locale))); + + QLocale::FormatType format = param < 0 ? QLocale::LongFormat : QLocale::FormatType(param); + + QVariant val; + QMetaObject::invokeMethod(obj, "toLocaleDateString", Qt::DirectConnection, + Q_RETURN_ARG(QVariant, val), + Q_ARG(QVariant, QVariant(param))); + + QLocale l(locale); + QCOMPARE(val.toString(), l.toString(dt.date(), format)); +} + +void tst_qqmllocale::addDateFormatData(const QString &l) +{ + const char *formats[] = { + "dd.MM.yyyy", + "ddd MMMM d yy", + "'The date is: 'dd/MM/yy", + "MMM d yyyy", + 0 + }; + QByteArray locale = l.toLatin1(); + int i = 0; + while (formats[i]) { + QByteArray t(locale); + t += " "; + t += formats[i]; + QTest::newRow(t.constData()) << l << QString(formats[i]); + ++i; + } +} + +void tst_qqmllocale::dateToLocaleDateStringFormatted_data() +{ + QTest::addColumn("locale"); + QTest::addColumn("format"); + + addDateFormatData("en_US"); + addDateFormatData("de_DE"); + addDateFormatData("ar_SA"); + addDateFormatData("hi_IN"); + addDateFormatData("zh_CN"); + addDateFormatData("th_TH"); +} + +void tst_qqmllocale::dateToLocaleDateStringFormatted() +{ + QFETCH(QString, locale); + QFETCH(QString, format); + + QQmlComponent c(&engine, testFileUrl("date.qml")); + + QObject *obj = c.create(); + QVERIFY(obj); + + QDateTime dt; + dt.setDate(QDate(2011, 10, 7)); // weirdly, JS Date month range is 0-11 + dt.setTime(QTime(18, 53, 48, 345)); + + QMetaObject::invokeMethod(obj, "setLocale", Qt::DirectConnection, + Q_ARG(QVariant, QVariant(locale))); + + QVariant val; + QMetaObject::invokeMethod(obj, "toLocaleString", Qt::DirectConnection, + Q_RETURN_ARG(QVariant, val), + Q_ARG(QVariant, QVariant(format))); + + QLocale l(locale); + QCOMPARE(val.toString(), l.toString(dt.date(), format)); +} + +void tst_qqmllocale::dateToLocaleTimeString_data() +{ + addStandardFormatData(); +} + +void tst_qqmllocale::dateToLocaleTimeString() +{ + QFETCH(QString, locale); + QFETCH(int, param); + + QQmlComponent c(&engine, testFileUrl("date.qml")); + + QObject *obj = c.create(); + QVERIFY(obj); + + QDateTime dt; + dt.setDate(QDate(2011, 10, 7)); // weirdly, JS Date month range is 0-11 + dt.setTime(QTime(18, 53, 48, 345)); + + QMetaObject::invokeMethod(obj, "setLocale", Qt::DirectConnection, + Q_ARG(QVariant, QVariant(locale))); + + QLocale::FormatType format = param < 0 ? QLocale::LongFormat : QLocale::FormatType(param); + + QVariant val; + QMetaObject::invokeMethod(obj, "toLocaleTimeString", Qt::DirectConnection, + Q_RETURN_ARG(QVariant, val), + Q_ARG(QVariant, QVariant(param))); + + QLocale l(locale); + QCOMPARE(val.toString(), l.toString(dt.time(), format)); +} + +void tst_qqmllocale::addTimeFormatData(const QString &l) +{ + const char *formats[] = { + "hh:mm", + "h:m:sap", + "'The time is: 'H:mm:ss:zzz", + "HH:mm t", + 0 + }; + QByteArray locale = l.toLatin1(); + int i = 0; + while (formats[i]) { + QByteArray t(locale); + t += " "; + t += formats[i]; + QTest::newRow(t.constData()) << l << QString(formats[i]); + ++i; + } +} + +void tst_qqmllocale::dateToLocaleTimeStringFormatted_data() +{ + QTest::addColumn("locale"); + QTest::addColumn("format"); + + addTimeFormatData("en_US"); + addTimeFormatData("de_DE"); + addTimeFormatData("ar_SA"); + addTimeFormatData("hi_IN"); + addTimeFormatData("zh_CN"); + addTimeFormatData("th_TH"); +} + +void tst_qqmllocale::dateToLocaleTimeStringFormatted() +{ + QFETCH(QString, locale); + QFETCH(QString, format); + + QQmlComponent c(&engine, testFileUrl("date.qml")); + + QObject *obj = c.create(); + QVERIFY(obj); + + QDateTime dt; + dt.setDate(QDate(2011, 10, 7)); // weirdly, JS Date month range is 0-11 + dt.setTime(QTime(18, 53, 48, 345)); + + QMetaObject::invokeMethod(obj, "setLocale", Qt::DirectConnection, + Q_ARG(QVariant, QVariant(locale))); + + QVariant val; + QMetaObject::invokeMethod(obj, "toLocaleString", Qt::DirectConnection, + Q_RETURN_ARG(QVariant, val), + Q_ARG(QVariant, QVariant(format))); + + QLocale l(locale); + QCOMPARE(val.toString(), l.toString(dt.time(), format)); +} + +void tst_qqmllocale::dateFromLocaleString_data() +{ + QTest::addColumn("locale"); + QTest::addColumn("format"); + + QTest::newRow("en_US 1") << "en_US" << "dddd, MMMM d, yyyy h:mm:ss AP"; + QTest::newRow("en_US long") << "en_US" << QLocale("en_US").dateTimeFormat(); + QTest::newRow("en_US short") << "en_US" << QLocale("en_US").dateTimeFormat(QLocale::ShortFormat); + QTest::newRow("de_DE long") << "de_DE" << QLocale("de_DE").dateTimeFormat(); + QTest::newRow("de_DE short") << "de_DE" << QLocale("de_DE").dateTimeFormat(QLocale::ShortFormat); + QTest::newRow("ar_SA long") << "ar_SA" << QLocale("ar_SA").dateTimeFormat(); + QTest::newRow("ar_SA short") << "ar_SA" << QLocale("ar_SA").dateTimeFormat(QLocale::ShortFormat); + QTest::newRow("zh_CN long") << "zh_CN" << QLocale("zh_CN").dateTimeFormat(); + QTest::newRow("zh_CN short") << "zh_CN" << QLocale("zh_CN").dateTimeFormat(QLocale::ShortFormat); +} + +void tst_qqmllocale::dateFromLocaleString() +{ + QFETCH(QString, locale); + QFETCH(QString, format); + + QQmlComponent c(&engine, testFileUrl("date.qml")); + + QObject *obj = c.create(); + QVERIFY(obj); + + QDateTime dt; + dt.setDate(QDate(2011, 10, 7)); + dt.setTime(QTime(18, 53, 48, 345)); + + QMetaObject::invokeMethod(obj, "setLocale", Qt::DirectConnection, + Q_ARG(QVariant, QVariant(locale))); + + QLocale l(locale); + QVariant val; + QMetaObject::invokeMethod(obj, "fromLocaleString", Qt::DirectConnection, + Q_RETURN_ARG(QVariant, val), + Q_ARG(QVariant, QVariant(l.toString(dt, format))), + Q_ARG(QVariant, QVariant(format))); + + QDateTime pd = l.toDateTime(l.toString(dt, format), format); + QCOMPARE(val.toDateTime(), pd); +} + +void tst_qqmllocale::dateFromLocaleDateString_data() +{ + QTest::addColumn("locale"); + QTest::addColumn("format"); + + QTest::newRow("en_US 1") << "en_US" << "dddd, MMMM d, yyyy h:mm:ss AP"; + QTest::newRow("en_US long") << "en_US" << QLocale("en_US").dateTimeFormat(); + QTest::newRow("en_US short") << "en_US" << QLocale("en_US").dateTimeFormat(QLocale::ShortFormat); + QTest::newRow("de_DE long") << "de_DE" << QLocale("de_DE").dateTimeFormat(); + QTest::newRow("de_DE short") << "de_DE" << QLocale("de_DE").dateTimeFormat(QLocale::ShortFormat); + QTest::newRow("ar_SA long") << "ar_SA" << QLocale("ar_SA").dateTimeFormat(); + QTest::newRow("ar_SA short") << "ar_SA" << QLocale("ar_SA").dateTimeFormat(QLocale::ShortFormat); + QTest::newRow("zh_CN long") << "zh_CN" << QLocale("zh_CN").dateTimeFormat(); + QTest::newRow("zh_CN short") << "zh_CN" << QLocale("zh_CN").dateTimeFormat(QLocale::ShortFormat); +} + +void tst_qqmllocale::dateFromLocaleDateString() +{ + QFETCH(QString, locale); + QFETCH(QString, format); + + QQmlComponent c(&engine, testFileUrl("date.qml")); + + QObject *obj = c.create(); + QVERIFY(obj); + + QDateTime dt; + dt.setDate(QDate(2011, 10, 7)); + dt.setTime(QTime(18, 53, 48, 345)); + + QMetaObject::invokeMethod(obj, "setLocale", Qt::DirectConnection, + Q_ARG(QVariant, QVariant(locale))); + + QLocale l(locale); + QVariant val; + QMetaObject::invokeMethod(obj, "fromLocaleDateString", Qt::DirectConnection, + Q_RETURN_ARG(QVariant, val), + Q_ARG(QVariant, QVariant(l.toString(dt, format))), + Q_ARG(QVariant, QVariant(format))); + + QDate pd = l.toDate(l.toString(dt, format), format); + QCOMPARE(val.toDate(), pd); +} + +void tst_qqmllocale::dateFromLocaleTimeString_data() +{ + QTest::addColumn("locale"); + QTest::addColumn("format"); + + QTest::newRow("en_US 1") << "en_US" << "dddd, MMMM d, yyyy h:mm:ss AP"; + QTest::newRow("en_US long") << "en_US" << QLocale("en_US").dateTimeFormat(); + QTest::newRow("en_US short") << "en_US" << QLocale("en_US").dateTimeFormat(QLocale::ShortFormat); + QTest::newRow("de_DE long") << "de_DE" << QLocale("de_DE").dateTimeFormat(); + QTest::newRow("de_DE short") << "de_DE" << QLocale("de_DE").dateTimeFormat(QLocale::ShortFormat); + QTest::newRow("ar_SA long") << "ar_SA" << QLocale("ar_SA").dateTimeFormat(); + QTest::newRow("ar_SA short") << "ar_SA" << QLocale("ar_SA").dateTimeFormat(QLocale::ShortFormat); + QTest::newRow("zh_CN long") << "zh_CN" << QLocale("zh_CN").dateTimeFormat(); + QTest::newRow("zh_CN short") << "zh_CN" << QLocale("zh_CN").dateTimeFormat(QLocale::ShortFormat); +} + +void tst_qqmllocale::dateFromLocaleTimeString() +{ + QFETCH(QString, locale); + QFETCH(QString, format); + + QQmlComponent c(&engine, testFileUrl("date.qml")); + + QObject *obj = c.create(); + QVERIFY(obj); + + QDateTime dt; + dt.setDate(QDate(2011, 10, 7)); + dt.setTime(QTime(18, 53, 48, 345)); + + QMetaObject::invokeMethod(obj, "setLocale", Qt::DirectConnection, + Q_ARG(QVariant, QVariant(locale))); + + QLocale l(locale); + QVariant val; + QMetaObject::invokeMethod(obj, "fromLocaleTimeString", Qt::DirectConnection, + Q_RETURN_ARG(QVariant, val), + Q_ARG(QVariant, QVariant(l.toString(dt, format))), + Q_ARG(QVariant, QVariant(format))); + + QTime pd = l.toTime(l.toString(dt, format), format); + QCOMPARE(val.toTime(), pd); +} + +void tst_qqmllocale::numberToLocaleString_data() +{ + QTest::addColumn("locale"); + QTest::addColumn("format"); + QTest::addColumn("prec"); + + QTest::newRow("en_US 1") << "en_US" << 'f' << 2; + QTest::newRow("en_US 2") << "en_US" << 'g' << 3; + QTest::newRow("en_US 3") << "en_US" << 'f' << 0; + QTest::newRow("en_US 4") << "en_US" << 'f' << -1; + QTest::newRow("de_DE 1") << "de_DE" << 'f' << 2; + QTest::newRow("de_DE 2") << "de_DE" << 'g' << 3; + QTest::newRow("ar_SA 1") << "ar_SA" << 'f' << 2; + QTest::newRow("ar_SA 2") << "ar_SA" << 'g' << 3; +} + +void tst_qqmllocale::numberToLocaleString() +{ + QFETCH(QString, locale); + QFETCH(char, format); + QFETCH(int, prec); + + QQmlComponent c(&engine, testFileUrl("number.qml")); + + QObject *obj = c.create(); + QVERIFY(obj); + + double number = 2344423.3289; + + QMetaObject::invokeMethod(obj, "setLocale", Qt::DirectConnection, + Q_ARG(QVariant, QVariant(locale))); + + QLocale l(locale); + QVariant val; + QMetaObject::invokeMethod(obj, "toLocaleString", Qt::DirectConnection, + Q_RETURN_ARG(QVariant, val), + Q_ARG(QVariant, QVariant(number)), + Q_ARG(QVariant, QVariant(QString(format))), + Q_ARG(QVariant, QVariant(prec))); + + if (prec < 0) prec = 2; + QCOMPARE(val.toString(), l.toString(number, format, prec)); +} + +void tst_qqmllocale::numberToLocaleCurrencyString_data() +{ + QTest::addColumn("locale"); + QTest::addColumn("symbol"); + + QTest::newRow("en_US 1") << "en_US" << QString(); + QTest::newRow("en_US 2") << "en_US" << "USD"; + QTest::newRow("de_DE") << "de_DE" << QString(); + QTest::newRow("ar_SA") << "ar_SA" << QString(); + QTest::newRow("hi_IN") << "hi_IN" << QString(); + QTest::newRow("zh_CN") << "zh_CN" << QString(); + QTest::newRow("th_TH") << "th_TH" << QString(); +} + +void tst_qqmllocale::numberToLocaleCurrencyString() +{ + QFETCH(QString, locale); + QFETCH(QString, symbol); + + QQmlComponent c(&engine, testFileUrl("number.qml")); + + QObject *obj = c.create(); + QVERIFY(obj); + + double number = 2344423.3289; + + QMetaObject::invokeMethod(obj, "setLocale", Qt::DirectConnection, + Q_ARG(QVariant, QVariant(locale))); + + QLocale l(locale); + QVariant val; + QMetaObject::invokeMethod(obj, "toLocaleCurrencyString", Qt::DirectConnection, + Q_RETURN_ARG(QVariant, val), + Q_ARG(QVariant, QVariant(number)), + Q_ARG(QVariant, QVariant(symbol))); + + QCOMPARE(val.toString(), l.toCurrencyString(number, symbol)); +} + +void tst_qqmllocale::numberFromLocaleString_data() +{ + QTest::addColumn("locale"); + QTest::addColumn("number"); + + QTest::newRow("en_US 1") << "en_US" << 1234567.2345; + QTest::newRow("en_US 2") << "en_US" << 0.234; + QTest::newRow("en_US 3") << "en_US" << 234.0; + QTest::newRow("de_DE") << "de_DE" << 1234567.2345; + QTest::newRow("ar_SA") << "ar_SA" << 1234567.2345; + QTest::newRow("hi_IN") << "hi_IN" << 1234567.2345; + QTest::newRow("zh_CN") << "zh_CN" << 1234567.2345; + QTest::newRow("th_TH") << "th_TH" << 1234567.2345; +} + +void tst_qqmllocale::numberFromLocaleString() +{ + QFETCH(QString, locale); + QFETCH(double, number); + + QQmlComponent c(&engine, testFileUrl("number.qml")); + + QObject *obj = c.create(); + QVERIFY(obj); + + QLocale l(locale); + QString strNumber = l.toString(number, 'f'); + + QMetaObject::invokeMethod(obj, "setLocale", Qt::DirectConnection, + Q_ARG(QVariant, QVariant(locale))); + + QVariant val; + QMetaObject::invokeMethod(obj, "fromLocaleString", Qt::DirectConnection, + Q_RETURN_ARG(QVariant, val), + Q_ARG(QVariant, QVariant(strNumber))); + + QCOMPARE(val.toDouble(), l.toDouble(strNumber)); +} + +void tst_qqmllocale::numberConstToLocaleString() +{ + QQmlComponent c(&engine, testFileUrl("number.qml")); + + QObject *obj = c.create(); + QVERIFY(obj); + + QMetaObject::invokeMethod(obj, "setLocale", Qt::DirectConnection, + Q_ARG(QVariant, QVariant("en_US"))); + + QLocale l("en_US"); + QCOMPARE(obj->property("const1").toString(), l.toString(1234.56, 'f', 2)); + QCOMPARE(obj->property("const2").toString(), l.toString(1234., 'f', 2)); +} + +void tst_qqmllocale::stringLocaleCompare_data() +{ + QTest::addColumn("string1"); + QTest::addColumn("string2"); + + QTest::newRow("before") << "a" << "b"; + QTest::newRow("equal") << "a" << "a"; + QTest::newRow("after") << "b" << "a"; + + // Copied from QString::localeAwareCompare tests + // We don't actually change locale - we just care that String.localeCompare() + // matches QString::localeAwareCompare(); + QTest::newRow("swedish1") << QString("\xe5") << QString("\xe4"); + QTest::newRow("swedish2") << QString("\xe4") << QString("\xf6"); + QTest::newRow("swedish3") << QString("\xe5") << QString("\xf6"); + QTest::newRow("swedish4") << QString("z") << QString("\xe5"); + + QTest::newRow("german1") << QString("z") << QString("\xe4"); + QTest::newRow("german2") << QString("\xe4") << QString("\xf6"); + QTest::newRow("german3") << QString("z") << QString("\xf6"); +} + +void tst_qqmllocale::stringLocaleCompare() +{ + QFETCH(QString, string1); + QFETCH(QString, string2); + + QQmlComponent c(&engine, testFileUrl("localeCompare.qml")); + + QObject *obj = c.create(); + QVERIFY(obj); + + obj->setProperty("string1", string1); + obj->setProperty("string2", string2); + + QCOMPARE(obj->property("comparison").toInt(), QString::localeAwareCompare(string1, string2)); +} + +QTEST_MAIN(tst_qqmllocale) + +#include "tst_qqmllocale.moc" diff --git a/tests/auto/qml/qqmlmetatype/qqmlmetatype.pro b/tests/auto/qml/qqmlmetatype/qqmlmetatype.pro new file mode 100644 index 0000000000..7c781dd9db --- /dev/null +++ b/tests/auto/qml/qqmlmetatype/qqmlmetatype.pro @@ -0,0 +1,7 @@ +CONFIG += testcase +TARGET = tst_qqmlmetatype +SOURCES += tst_qqmlmetatype.cpp +macx:CONFIG -= app_bundle + +CONFIG += parallel_test +QT += core-private gui-private qml-private widgets testlib diff --git a/tests/auto/qml/qqmlmetatype/tst_qqmlmetatype.cpp b/tests/auto/qml/qqmlmetatype/tst_qqmlmetatype.cpp new file mode 100644 index 0000000000..6e577ec095 --- /dev/null +++ b/tests/auto/qml/qqmlmetatype/tst_qqmlmetatype.cpp @@ -0,0 +1,202 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include + +#include +#include + +class tst_qqmlmetatype : public QObject +{ + Q_OBJECT +public: + tst_qqmlmetatype() {} + +private slots: + void initTestCase(); + + void qmlParserStatusCast(); + void qmlPropertyValueSourceCast(); + void qmlPropertyValueInterceptorCast(); + + void isList(); + + void defaultObject(); +}; + +class TestType : public QObject +{ + Q_OBJECT + Q_PROPERTY(int foo READ foo) + + Q_CLASSINFO("DefaultProperty", "foo") +public: + int foo() { return 0; } +}; +QML_DECLARE_TYPE(TestType); + +class ParserStatusTestType : public QObject, public QQmlParserStatus +{ + Q_OBJECT + void classBegin(){} + void componentComplete(){} + Q_CLASSINFO("DefaultProperty", "foo") // Missing default property + Q_INTERFACES(QQmlParserStatus) +}; +QML_DECLARE_TYPE(ParserStatusTestType); + +class ValueSourceTestType : public QObject, public QQmlPropertyValueSource +{ + Q_OBJECT + Q_INTERFACES(QQmlPropertyValueSource) +public: + virtual void setTarget(const QQmlProperty &) {} +}; +QML_DECLARE_TYPE(ValueSourceTestType); + +class ValueInterceptorTestType : public QObject, public QQmlPropertyValueInterceptor +{ + Q_OBJECT + Q_INTERFACES(QQmlPropertyValueInterceptor) +public: + virtual void setTarget(const QQmlProperty &) {} + virtual void write(const QVariant &) {} +}; +QML_DECLARE_TYPE(ValueInterceptorTestType); + +void tst_qqmlmetatype::initTestCase() +{ + qmlRegisterType("Test", 1, 0, "TestType"); + qmlRegisterType("Test", 1, 0, "ParserStatusTestType"); + qmlRegisterType("Test", 1, 0, "ValueSourceTestType"); + qmlRegisterType("Test", 1, 0, "ValueInterceptorTestType"); +} + +void tst_qqmlmetatype::qmlParserStatusCast() +{ + QVERIFY(QQmlMetaType::qmlType(QVariant::Int) == 0); + QVERIFY(QQmlMetaType::qmlType(qMetaTypeId()) != 0); + QCOMPARE(QQmlMetaType::qmlType(qMetaTypeId())->parserStatusCast(), -1); + QVERIFY(QQmlMetaType::qmlType(qMetaTypeId()) != 0); + QCOMPARE(QQmlMetaType::qmlType(qMetaTypeId())->parserStatusCast(), -1); + + QVERIFY(QQmlMetaType::qmlType(qMetaTypeId()) != 0); + int cast = QQmlMetaType::qmlType(qMetaTypeId())->parserStatusCast(); + QVERIFY(cast != -1); + QVERIFY(cast != 0); + + ParserStatusTestType t; + QVERIFY(reinterpret_cast((QObject *)&t) != reinterpret_cast((QQmlParserStatus *)&t)); + + QQmlParserStatus *status = reinterpret_cast(reinterpret_cast((QObject *)&t) + cast); + QCOMPARE(status, (QQmlParserStatus*)&t); +} + +void tst_qqmlmetatype::qmlPropertyValueSourceCast() +{ + QVERIFY(QQmlMetaType::qmlType(QVariant::Int) == 0); + QVERIFY(QQmlMetaType::qmlType(qMetaTypeId()) != 0); + QCOMPARE(QQmlMetaType::qmlType(qMetaTypeId())->propertyValueSourceCast(), -1); + QVERIFY(QQmlMetaType::qmlType(qMetaTypeId()) != 0); + QCOMPARE(QQmlMetaType::qmlType(qMetaTypeId())->propertyValueSourceCast(), -1); + + QVERIFY(QQmlMetaType::qmlType(qMetaTypeId()) != 0); + int cast = QQmlMetaType::qmlType(qMetaTypeId())->propertyValueSourceCast(); + QVERIFY(cast != -1); + QVERIFY(cast != 0); + + ValueSourceTestType t; + QVERIFY(reinterpret_cast((QObject *)&t) != reinterpret_cast((QQmlPropertyValueSource *)&t)); + + QQmlPropertyValueSource *source = reinterpret_cast(reinterpret_cast((QObject *)&t) + cast); + QCOMPARE(source, (QQmlPropertyValueSource*)&t); +} + +void tst_qqmlmetatype::qmlPropertyValueInterceptorCast() +{ + QVERIFY(QQmlMetaType::qmlType(QVariant::Int) == 0); + QVERIFY(QQmlMetaType::qmlType(qMetaTypeId()) != 0); + QCOMPARE(QQmlMetaType::qmlType(qMetaTypeId())->propertyValueInterceptorCast(), -1); + QVERIFY(QQmlMetaType::qmlType(qMetaTypeId()) != 0); + QCOMPARE(QQmlMetaType::qmlType(qMetaTypeId())->propertyValueInterceptorCast(), -1); + + QVERIFY(QQmlMetaType::qmlType(qMetaTypeId()) != 0); + int cast = QQmlMetaType::qmlType(qMetaTypeId())->propertyValueInterceptorCast(); + QVERIFY(cast != -1); + QVERIFY(cast != 0); + + ValueInterceptorTestType t; + QVERIFY(reinterpret_cast((QObject *)&t) != reinterpret_cast((QQmlPropertyValueInterceptor *)&t)); + + QQmlPropertyValueInterceptor *interceptor = reinterpret_cast(reinterpret_cast((QObject *)&t) + cast); + QCOMPARE(interceptor, (QQmlPropertyValueInterceptor*)&t); +} + +void tst_qqmlmetatype::isList() +{ + QCOMPARE(QQmlMetaType::isList(QVariant::Invalid), false); + QCOMPARE(QQmlMetaType::isList(QVariant::Int), false); + + QQmlListProperty list; + + QCOMPARE(QQmlMetaType::isList(qMetaTypeId >()), true); +} + +void tst_qqmlmetatype::defaultObject() +{ + QVERIFY(QQmlMetaType::defaultProperty(&QObject::staticMetaObject).name() == 0); + QVERIFY(QQmlMetaType::defaultProperty(&ParserStatusTestType::staticMetaObject).name() == 0); + QCOMPARE(QString(QQmlMetaType::defaultProperty(&TestType::staticMetaObject).name()), QString("foo")); + + QObject o; + TestType t; + ParserStatusTestType p; + + QVERIFY(QQmlMetaType::defaultProperty((QObject *)0).name() == 0); + QVERIFY(QQmlMetaType::defaultProperty(&o).name() == 0); + QVERIFY(QQmlMetaType::defaultProperty(&p).name() == 0); + QCOMPARE(QString(QQmlMetaType::defaultProperty(&t).name()), QString("foo")); +} + +QTEST_MAIN(tst_qqmlmetatype) + +#include "tst_qqmlmetatype.moc" diff --git a/tests/auto/qml/qqmlmoduleplugin/data/implicit1/implicitQmldir.errors.txt b/tests/auto/qml/qqmlmoduleplugin/data/implicit1/implicitQmldir.errors.txt new file mode 100644 index 0000000000..ce3b796e16 --- /dev/null +++ b/tests/auto/qml/qqmlmoduleplugin/data/implicit1/implicitQmldir.errors.txt @@ -0,0 +1 @@ +-1:-1:module "" plugin "AType" not found diff --git a/tests/auto/qml/qqmlmoduleplugin/data/implicit1/qmldir b/tests/auto/qml/qqmlmoduleplugin/data/implicit1/qmldir new file mode 100644 index 0000000000..7f5b3a362d --- /dev/null +++ b/tests/auto/qml/qqmlmoduleplugin/data/implicit1/qmldir @@ -0,0 +1,2 @@ +plugin AType + diff --git a/tests/auto/qml/qqmlmoduleplugin/data/implicit1/temptest.qml b/tests/auto/qml/qqmlmoduleplugin/data/implicit1/temptest.qml new file mode 100644 index 0000000000..67fb18feb0 --- /dev/null +++ b/tests/auto/qml/qqmlmoduleplugin/data/implicit1/temptest.qml @@ -0,0 +1,14 @@ +import QtQuick 2.0 + +// this qml file uses a type which is meant to be defined +// in a plugin which is specified in the qmldir file. +// however, that plugin doesn't exist, so it cannot be +// loaded, and hence the AItem type will be an unknown type. + +Item { + id: root + + AItem { + id: unknown + } +} diff --git a/tests/auto/qml/qqmlmoduleplugin/data/implicit2/Test.qml b/tests/auto/qml/qqmlmoduleplugin/data/implicit2/Test.qml new file mode 100644 index 0000000000..ea9611691e --- /dev/null +++ b/tests/auto/qml/qqmlmoduleplugin/data/implicit2/Test.qml @@ -0,0 +1,5 @@ +import QtQuick 2.0 + +Item { + id: moduleRoot +} diff --git a/tests/auto/qml/qqmlmoduleplugin/data/implicit2/implicitQmldir.2.errors.txt b/tests/auto/qml/qqmlmoduleplugin/data/implicit2/implicitQmldir.2.errors.txt new file mode 100644 index 0000000000..9cafb78740 --- /dev/null +++ b/tests/auto/qml/qqmlmoduleplugin/data/implicit2/implicitQmldir.2.errors.txt @@ -0,0 +1,3 @@ +1:12:unexpected token +1:-1:expected '.' +2:17:unexpected token diff --git a/tests/auto/qml/qqmlmoduleplugin/data/implicit2/qmldir b/tests/auto/qml/qqmlmoduleplugin/data/implicit2/qmldir new file mode 100644 index 0000000000..7c4def92fc --- /dev/null +++ b/tests/auto/qml/qqmlmoduleplugin/data/implicit2/qmldir @@ -0,0 +1,3 @@ +foo bar foo bar +internal foo bar foo +Test 1.0 Test.qml diff --git a/tests/auto/qml/qqmlmoduleplugin/data/implicit2/temptest2.qml b/tests/auto/qml/qqmlmoduleplugin/data/implicit2/temptest2.qml new file mode 100644 index 0000000000..0fa9f6e051 --- /dev/null +++ b/tests/auto/qml/qqmlmoduleplugin/data/implicit2/temptest2.qml @@ -0,0 +1,8 @@ +import QtQuick 2.0 + +// the type loader will implicitly search "." for a qmldir +// and the qmldir has various syntax errors in it. + +Item { + id: root +} diff --git a/tests/auto/qml/qqmlmoduleplugin/data/importsMixedQmlCppPlugin.2.qml b/tests/auto/qml/qqmlmoduleplugin/data/importsMixedQmlCppPlugin.2.qml new file mode 100644 index 0000000000..a0ac0c72c7 --- /dev/null +++ b/tests/auto/qml/qqmlmoduleplugin/data/importsMixedQmlCppPlugin.2.qml @@ -0,0 +1,21 @@ +import com.nokia.AutoTestQmlMixedPluginType 1.5 +import QtQuick 2.0 + +Item { + property bool test: false + property bool test2: false + + Bar { + id: bar + } + + Foo { + id: foo + } + + Component.onCompleted: { + test = (bar.value == 16); + test2 = (foo.value == 89); + } +} + diff --git a/tests/auto/qml/qqmlmoduleplugin/data/importsMixedQmlCppPlugin.qml b/tests/auto/qml/qqmlmoduleplugin/data/importsMixedQmlCppPlugin.qml new file mode 100644 index 0000000000..1346cbdb7b --- /dev/null +++ b/tests/auto/qml/qqmlmoduleplugin/data/importsMixedQmlCppPlugin.qml @@ -0,0 +1,13 @@ +import com.nokia.AutoTestQmlMixedPluginType 1.0 +import QtQuick 2.0 + +Item { + property bool test: false + Bar { + id: bar + } + + Component.onCompleted: { + test = (bar.value == 16); + } +} diff --git a/tests/auto/qml/qqmlmoduleplugin/data/incorrectCase.qml b/tests/auto/qml/qqmlmoduleplugin/data/incorrectCase.qml new file mode 100644 index 0000000000..a21ece7058 --- /dev/null +++ b/tests/auto/qml/qqmlmoduleplugin/data/incorrectCase.qml @@ -0,0 +1,4 @@ +import com.nokia.WrongCase 1.0 + +MyPluginType { value: 123 } + diff --git a/tests/auto/qml/qqmlmoduleplugin/data/pluginWithQmlFile.qml b/tests/auto/qml/qqmlmoduleplugin/data/pluginWithQmlFile.qml new file mode 100644 index 0000000000..a9e28e5d8b --- /dev/null +++ b/tests/auto/qml/qqmlmoduleplugin/data/pluginWithQmlFile.qml @@ -0,0 +1,3 @@ +import com.nokia.AutoTestPluginWithQmlFile 1.0 + +MyQmlFile {} diff --git a/tests/auto/qml/qqmlmoduleplugin/data/versionNotInstalled.2.errors.txt b/tests/auto/qml/qqmlmoduleplugin/data/versionNotInstalled.2.errors.txt new file mode 100644 index 0000000000..a40c1c8211 --- /dev/null +++ b/tests/auto/qml/qqmlmoduleplugin/data/versionNotInstalled.2.errors.txt @@ -0,0 +1 @@ +1:1:module "com.nokia.AutoTestQmlVersionPluginType" version 1.9 is not installed diff --git a/tests/auto/qml/qqmlmoduleplugin/data/versionNotInstalled.2.qml b/tests/auto/qml/qqmlmoduleplugin/data/versionNotInstalled.2.qml new file mode 100644 index 0000000000..bda59f0a32 --- /dev/null +++ b/tests/auto/qml/qqmlmoduleplugin/data/versionNotInstalled.2.qml @@ -0,0 +1,5 @@ +import com.nokia.AutoTestQmlVersionPluginType 1.9 +import QtQuick 2.0 + +QtObject { +} diff --git a/tests/auto/qml/qqmlmoduleplugin/data/versionNotInstalled.errors.txt b/tests/auto/qml/qqmlmoduleplugin/data/versionNotInstalled.errors.txt new file mode 100644 index 0000000000..2634223de7 --- /dev/null +++ b/tests/auto/qml/qqmlmoduleplugin/data/versionNotInstalled.errors.txt @@ -0,0 +1 @@ +1:1:module "com.nokia.AutoTestQmlVersionPluginType" version 1.1 is not installed diff --git a/tests/auto/qml/qqmlmoduleplugin/data/versionNotInstalled.qml b/tests/auto/qml/qqmlmoduleplugin/data/versionNotInstalled.qml new file mode 100644 index 0000000000..2e556e76d6 --- /dev/null +++ b/tests/auto/qml/qqmlmoduleplugin/data/versionNotInstalled.qml @@ -0,0 +1,6 @@ +import com.nokia.AutoTestQmlVersionPluginType 1.1 +import QtQuick 2.0 + +QtObject { +} + diff --git a/tests/auto/qml/qqmlmoduleplugin/data/works.qml b/tests/auto/qml/qqmlmoduleplugin/data/works.qml new file mode 100644 index 0000000000..f29ae24ea2 --- /dev/null +++ b/tests/auto/qml/qqmlmoduleplugin/data/works.qml @@ -0,0 +1,3 @@ +import com.nokia.AutoTestQmlPluginType 1.0 + +MyPluginType { value: 123 } diff --git a/tests/auto/qml/qqmlmoduleplugin/data/works2.qml b/tests/auto/qml/qqmlmoduleplugin/data/works2.qml new file mode 100644 index 0000000000..cc322bf26b --- /dev/null +++ b/tests/auto/qml/qqmlmoduleplugin/data/works2.qml @@ -0,0 +1,3 @@ +import com.nokia.AutoTestQmlPluginType 2.0 + +MyPluginType { valueOnlyIn2: 123 } diff --git a/tests/auto/qml/qqmlmoduleplugin/data/works21.qml b/tests/auto/qml/qqmlmoduleplugin/data/works21.qml new file mode 100644 index 0000000000..c08160ac5a --- /dev/null +++ b/tests/auto/qml/qqmlmoduleplugin/data/works21.qml @@ -0,0 +1,3 @@ +import com.nokia.AutoTestQmlPluginType 2.1 + +MyPluginType { valueOnlyIn2: 123 } diff --git a/tests/auto/qml/qqmlmoduleplugin/imports/com/nokia/AutoTestPluginWithQmlFile/MyQmlFile.qml b/tests/auto/qml/qqmlmoduleplugin/imports/com/nokia/AutoTestPluginWithQmlFile/MyQmlFile.qml new file mode 100644 index 0000000000..617bdaaf67 --- /dev/null +++ b/tests/auto/qml/qqmlmoduleplugin/imports/com/nokia/AutoTestPluginWithQmlFile/MyQmlFile.qml @@ -0,0 +1,3 @@ +import QtQuick 2.0 + +Item {} diff --git a/tests/auto/qml/qqmlmoduleplugin/imports/com/nokia/AutoTestPluginWithQmlFile/qmldir b/tests/auto/qml/qqmlmoduleplugin/imports/com/nokia/AutoTestPluginWithQmlFile/qmldir new file mode 100644 index 0000000000..858ba1450e --- /dev/null +++ b/tests/auto/qml/qqmlmoduleplugin/imports/com/nokia/AutoTestPluginWithQmlFile/qmldir @@ -0,0 +1,3 @@ +MyQmlFile 1.0 MyQmlFile.qml +plugin pluginWithQmlFile + diff --git a/tests/auto/qml/qqmlmoduleplugin/imports/com/nokia/AutoTestQmlMixedPluginType/Foo.qml b/tests/auto/qml/qqmlmoduleplugin/imports/com/nokia/AutoTestQmlMixedPluginType/Foo.qml new file mode 100644 index 0000000000..36d69e901f --- /dev/null +++ b/tests/auto/qml/qqmlmoduleplugin/imports/com/nokia/AutoTestQmlMixedPluginType/Foo.qml @@ -0,0 +1,5 @@ +import QtQuick 2.0 + +Item { + property int value: 89 +} diff --git a/tests/auto/qml/qqmlmoduleplugin/imports/com/nokia/AutoTestQmlMixedPluginType/qmldir b/tests/auto/qml/qqmlmoduleplugin/imports/com/nokia/AutoTestQmlMixedPluginType/qmldir new file mode 100644 index 0000000000..065dc3b21f --- /dev/null +++ b/tests/auto/qml/qqmlmoduleplugin/imports/com/nokia/AutoTestQmlMixedPluginType/qmldir @@ -0,0 +1,2 @@ +plugin pluginMixed +Foo 1.5 Foo.qml diff --git a/tests/auto/qml/qqmlmoduleplugin/imports/com/nokia/AutoTestQmlPluginType.2.1/qmldir b/tests/auto/qml/qqmlmoduleplugin/imports/com/nokia/AutoTestQmlPluginType.2.1/qmldir new file mode 100644 index 0000000000..0a8b5d46eb --- /dev/null +++ b/tests/auto/qml/qqmlmoduleplugin/imports/com/nokia/AutoTestQmlPluginType.2.1/qmldir @@ -0,0 +1 @@ +plugin plugin diff --git a/tests/auto/qml/qqmlmoduleplugin/imports/com/nokia/AutoTestQmlPluginType.2/qmldir b/tests/auto/qml/qqmlmoduleplugin/imports/com/nokia/AutoTestQmlPluginType.2/qmldir new file mode 100644 index 0000000000..0a8b5d46eb --- /dev/null +++ b/tests/auto/qml/qqmlmoduleplugin/imports/com/nokia/AutoTestQmlPluginType.2/qmldir @@ -0,0 +1 @@ +plugin plugin diff --git a/tests/auto/qml/qqmlmoduleplugin/imports/com/nokia/AutoTestQmlPluginType/qmldir b/tests/auto/qml/qqmlmoduleplugin/imports/com/nokia/AutoTestQmlPluginType/qmldir new file mode 100644 index 0000000000..0a8b5d46eb --- /dev/null +++ b/tests/auto/qml/qqmlmoduleplugin/imports/com/nokia/AutoTestQmlPluginType/qmldir @@ -0,0 +1 @@ +plugin plugin diff --git a/tests/auto/qml/qqmlmoduleplugin/imports/com/nokia/AutoTestQmlVersionPluginType/qmldir b/tests/auto/qml/qqmlmoduleplugin/imports/com/nokia/AutoTestQmlVersionPluginType/qmldir new file mode 100644 index 0000000000..640967fe40 --- /dev/null +++ b/tests/auto/qml/qqmlmoduleplugin/imports/com/nokia/AutoTestQmlVersionPluginType/qmldir @@ -0,0 +1 @@ +plugin pluginVersion diff --git a/tests/auto/qml/qqmlmoduleplugin/imports/com/nokia/PureQmlModule/ComponentA.qml b/tests/auto/qml/qqmlmoduleplugin/imports/com/nokia/PureQmlModule/ComponentA.qml new file mode 100644 index 0000000000..617bdaaf67 --- /dev/null +++ b/tests/auto/qml/qqmlmoduleplugin/imports/com/nokia/PureQmlModule/ComponentA.qml @@ -0,0 +1,3 @@ +import QtQuick 2.0 + +Item {} diff --git a/tests/auto/qml/qqmlmoduleplugin/imports/com/nokia/PureQmlModule/ComponentB.qml b/tests/auto/qml/qqmlmoduleplugin/imports/com/nokia/PureQmlModule/ComponentB.qml new file mode 100644 index 0000000000..fac5d8f4b9 --- /dev/null +++ b/tests/auto/qml/qqmlmoduleplugin/imports/com/nokia/PureQmlModule/ComponentB.qml @@ -0,0 +1,4 @@ +import QtQuick 2.0 + +Item {} + diff --git a/tests/auto/qml/qqmlmoduleplugin/imports/com/nokia/PureQmlModule/qmldir b/tests/auto/qml/qqmlmoduleplugin/imports/com/nokia/PureQmlModule/qmldir new file mode 100644 index 0000000000..167bb10c21 --- /dev/null +++ b/tests/auto/qml/qqmlmoduleplugin/imports/com/nokia/PureQmlModule/qmldir @@ -0,0 +1,3 @@ +ComponentA 1.0 ComponentA.qml +ComponentB 1.0 ComponentB.qml + diff --git a/tests/auto/qml/qqmlmoduleplugin/imports/com/nokia/WrongCase/qmldir b/tests/auto/qml/qqmlmoduleplugin/imports/com/nokia/WrongCase/qmldir new file mode 100644 index 0000000000..6c8787498f --- /dev/null +++ b/tests/auto/qml/qqmlmoduleplugin/imports/com/nokia/WrongCase/qmldir @@ -0,0 +1 @@ +plugin PluGin diff --git a/tests/auto/qml/qqmlmoduleplugin/plugin.2.1/plugin.2.1.pro b/tests/auto/qml/qqmlmoduleplugin/plugin.2.1/plugin.2.1.pro new file mode 100644 index 0000000000..ccb66abe0e --- /dev/null +++ b/tests/auto/qml/qqmlmoduleplugin/plugin.2.1/plugin.2.1.pro @@ -0,0 +1,7 @@ +TEMPLATE = lib +CONFIG += plugin +SOURCES = plugin.cpp +QT = core qml +DESTDIR = ../imports/com/nokia/AutoTestQmlPluginType.2.1 + +QT += core-private gui-private qml-private diff --git a/tests/auto/qml/qqmlmoduleplugin/plugin.2.1/plugin.cpp b/tests/auto/qml/qqmlmoduleplugin/plugin.2.1/plugin.cpp new file mode 100644 index 0000000000..53696b3598 --- /dev/null +++ b/tests/auto/qml/qqmlmoduleplugin/plugin.2.1/plugin.cpp @@ -0,0 +1,84 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include +#include +#include +#include + +class MyPluginType : public QObject +{ + Q_OBJECT + Q_PROPERTY(int value READ value WRITE setValue) + Q_PROPERTY(int valueOnlyIn2 READ value WRITE setValue) + +public: + MyPluginType(QObject *parent=0) : QObject(parent) + { + qWarning("import2.1 worked"); + } + + int value() const { return v; } + void setValue(int i) { v = i; } + +private: + int v; +}; + + +class MyPlugin : public QQmlExtensionPlugin +{ + Q_OBJECT +public: + MyPlugin() + { + qWarning("plugin2.1 created"); + } + + void registerTypes(const char *uri) + { + Q_ASSERT(QLatin1String(uri) == "com.nokia.AutoTestQmlPluginType"); + qmlRegisterType(uri, 2, 1, "MyPluginType"); + } +}; + +#include "plugin.moc" + +Q_EXPORT_PLUGIN2(plugin, MyPlugin); diff --git a/tests/auto/qml/qqmlmoduleplugin/plugin.2/plugin.2.pro b/tests/auto/qml/qqmlmoduleplugin/plugin.2/plugin.2.pro new file mode 100644 index 0000000000..7f3904f695 --- /dev/null +++ b/tests/auto/qml/qqmlmoduleplugin/plugin.2/plugin.2.pro @@ -0,0 +1,7 @@ +TEMPLATE = lib +CONFIG += plugin +SOURCES = plugin.cpp +QT = core qml +DESTDIR = ../imports/com/nokia/AutoTestQmlPluginType.2 + +QT += core-private gui-private qml-private diff --git a/tests/auto/qml/qqmlmoduleplugin/plugin.2/plugin.cpp b/tests/auto/qml/qqmlmoduleplugin/plugin.2/plugin.cpp new file mode 100644 index 0000000000..f62b8addd4 --- /dev/null +++ b/tests/auto/qml/qqmlmoduleplugin/plugin.2/plugin.cpp @@ -0,0 +1,84 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include +#include +#include +#include + +class MyPluginType : public QObject +{ + Q_OBJECT + Q_PROPERTY(int value READ value WRITE setValue) + Q_PROPERTY(int valueOnlyIn2 READ value WRITE setValue) + +public: + MyPluginType(QObject *parent=0) : QObject(parent) + { + qWarning("import2 worked"); + } + + int value() const { return v; } + void setValue(int i) { v = i; } + +private: + int v; +}; + + +class MyPlugin : public QQmlExtensionPlugin +{ + Q_OBJECT +public: + MyPlugin() + { + qWarning("plugin2 created"); + } + + void registerTypes(const char *uri) + { + Q_ASSERT(QLatin1String(uri) == "com.nokia.AutoTestQmlPluginType"); + qmlRegisterType(uri, 2, 0, "MyPluginType"); + } +}; + +#include "plugin.moc" + +Q_EXPORT_PLUGIN2(plugin, MyPlugin); diff --git a/tests/auto/qml/qqmlmoduleplugin/plugin/plugin.cpp b/tests/auto/qml/qqmlmoduleplugin/plugin/plugin.cpp new file mode 100644 index 0000000000..470aa7a37c --- /dev/null +++ b/tests/auto/qml/qqmlmoduleplugin/plugin/plugin.cpp @@ -0,0 +1,83 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include +#include +#include +#include + +class MyPluginType : public QObject +{ + Q_OBJECT + Q_PROPERTY(int value READ value WRITE setValue) + +public: + MyPluginType(QObject *parent=0) : QObject(parent) + { + qWarning("import worked"); + } + + int value() const { return v; } + void setValue(int i) { v = i; } + +private: + int v; +}; + + +class MyPlugin : public QQmlExtensionPlugin +{ + Q_OBJECT +public: + MyPlugin() + { + qWarning("plugin created"); + } + + void registerTypes(const char *uri) + { + Q_ASSERT(QLatin1String(uri) == "com.nokia.AutoTestQmlPluginType"); + qmlRegisterType(uri, 1, 0, "MyPluginType"); + } +}; + +#include "plugin.moc" + +Q_EXPORT_PLUGIN2(plugin, MyPlugin); diff --git a/tests/auto/qml/qqmlmoduleplugin/plugin/plugin.pro b/tests/auto/qml/qqmlmoduleplugin/plugin/plugin.pro new file mode 100644 index 0000000000..dae8696cc8 --- /dev/null +++ b/tests/auto/qml/qqmlmoduleplugin/plugin/plugin.pro @@ -0,0 +1,7 @@ +TEMPLATE = lib +CONFIG += plugin +SOURCES = plugin.cpp +QT = core qml +DESTDIR = ../imports/com/nokia/AutoTestQmlPluginType + +QT += core-private gui-private qml-private diff --git a/tests/auto/qml/qqmlmoduleplugin/pluginMixed/plugin.cpp b/tests/auto/qml/qqmlmoduleplugin/pluginMixed/plugin.cpp new file mode 100644 index 0000000000..eec8e3f3af --- /dev/null +++ b/tests/auto/qml/qqmlmoduleplugin/pluginMixed/plugin.cpp @@ -0,0 +1,73 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include +#include +#include +#include + +class BarPluginType : public QObject +{ + Q_OBJECT + Q_PROPERTY(int value READ value) + +public: + int value() const { return 16; } +}; + + +class MyMixedPlugin : public QQmlExtensionPlugin +{ + Q_OBJECT +public: + MyMixedPlugin() + { + } + + void registerTypes(const char *uri) + { + Q_ASSERT(QLatin1String(uri) == "com.nokia.AutoTestQmlMixedPluginType"); + qmlRegisterType(uri, 1, 0, "Bar"); + } +}; + +#include "plugin.moc" + +Q_EXPORT_PLUGIN2(plugin, MyMixedPlugin); diff --git a/tests/auto/qml/qqmlmoduleplugin/pluginMixed/pluginMixed.pro b/tests/auto/qml/qqmlmoduleplugin/pluginMixed/pluginMixed.pro new file mode 100644 index 0000000000..c0f314ab5e --- /dev/null +++ b/tests/auto/qml/qqmlmoduleplugin/pluginMixed/pluginMixed.pro @@ -0,0 +1,7 @@ +TEMPLATE = lib +CONFIG += plugin +SOURCES = plugin.cpp +QT = core qml +DESTDIR = ../imports/com/nokia/AutoTestQmlMixedPluginType + +QT += core-private gui-private qml-private diff --git a/tests/auto/qml/qqmlmoduleplugin/pluginVersion/plugin.cpp b/tests/auto/qml/qqmlmoduleplugin/pluginVersion/plugin.cpp new file mode 100644 index 0000000000..8645028317 --- /dev/null +++ b/tests/auto/qml/qqmlmoduleplugin/pluginVersion/plugin.cpp @@ -0,0 +1,73 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include +#include +#include +#include + +class FloorPluginType : public QObject +{ + Q_OBJECT + Q_PROPERTY(int value READ value); + +public: + int value() const { return 16; } +}; + + +class MyMixedPlugin : public QQmlExtensionPlugin +{ + Q_OBJECT +public: + MyMixedPlugin() + { + } + + void registerTypes(const char *uri) + { + Q_ASSERT(QLatin1String(uri) == "com.nokia.AutoTestQmlVersionPluginType"); + qmlRegisterType(uri, 1, 4, "Floor"); + } +}; + +#include "plugin.moc" + +Q_EXPORT_PLUGIN2(plugin, MyMixedPlugin); diff --git a/tests/auto/qml/qqmlmoduleplugin/pluginVersion/pluginVersion.pro b/tests/auto/qml/qqmlmoduleplugin/pluginVersion/pluginVersion.pro new file mode 100644 index 0000000000..ba9e4846ea --- /dev/null +++ b/tests/auto/qml/qqmlmoduleplugin/pluginVersion/pluginVersion.pro @@ -0,0 +1,7 @@ +TEMPLATE = lib +CONFIG += plugin +SOURCES = plugin.cpp +QT = core qml +DESTDIR = ../imports/com/nokia/AutoTestQmlVersionPluginType + +QT += core-private gui-private qml-private diff --git a/tests/auto/qml/qqmlmoduleplugin/pluginWithQmlFile/plugin.cpp b/tests/auto/qml/qqmlmoduleplugin/pluginWithQmlFile/plugin.cpp new file mode 100644 index 0000000000..1217df4d0e --- /dev/null +++ b/tests/auto/qml/qqmlmoduleplugin/pluginWithQmlFile/plugin.cpp @@ -0,0 +1,58 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include +#include +#include +#include + +class MyPlugin : public QQmlExtensionPlugin +{ + Q_OBJECT +public: + void registerTypes(const char *uri) + { + Q_ASSERT(QLatin1String(uri) == "com.nokia.AutoTestPluginWithQmlFile"); + } +}; + +#include "plugin.moc" + +Q_EXPORT_PLUGIN2(plugin, MyPlugin); diff --git a/tests/auto/qml/qqmlmoduleplugin/pluginWithQmlFile/pluginWithQmlFile.pro b/tests/auto/qml/qqmlmoduleplugin/pluginWithQmlFile/pluginWithQmlFile.pro new file mode 100644 index 0000000000..15fe8d2f3e --- /dev/null +++ b/tests/auto/qml/qqmlmoduleplugin/pluginWithQmlFile/pluginWithQmlFile.pro @@ -0,0 +1,7 @@ +TEMPLATE = lib +CONFIG += plugin +SOURCES = plugin.cpp +QT = core qml +DESTDIR = ../imports/com/nokia/AutoTestPluginWithQmlFile + +QT += core-private gui-private qml-private diff --git a/tests/auto/qml/qqmlmoduleplugin/pluginWrongCase/plugin.cpp b/tests/auto/qml/qqmlmoduleplugin/pluginWrongCase/plugin.cpp new file mode 100644 index 0000000000..e0257fe249 --- /dev/null +++ b/tests/auto/qml/qqmlmoduleplugin/pluginWrongCase/plugin.cpp @@ -0,0 +1,83 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include +#include +#include +#include + +class MyPluginType : public QObject +{ + Q_OBJECT + Q_PROPERTY(int value READ value WRITE setValue) + +public: + MyPluginType(QObject *parent=0) : QObject(parent) + { + qWarning("import worked"); + } + + int value() const { return v; } + void setValue(int i) { v = i; } + +private: + int v; +}; + + +class MyPlugin : public QQmlExtensionPlugin +{ + Q_OBJECT +public: + MyPlugin() + { + qWarning("plugin created"); + } + + void registerTypes(const char *uri) + { + Q_ASSERT(QLatin1String(uri) == "com.nokia.WrongCase"); + qmlRegisterType(uri, 1, 0, "MyPluginType"); + } +}; + +#include "plugin.moc" + +Q_EXPORT_PLUGIN2(plugin, MyPlugin); diff --git a/tests/auto/qml/qqmlmoduleplugin/pluginWrongCase/pluginWrongCase.pro b/tests/auto/qml/qqmlmoduleplugin/pluginWrongCase/pluginWrongCase.pro new file mode 100644 index 0000000000..d604613300 --- /dev/null +++ b/tests/auto/qml/qqmlmoduleplugin/pluginWrongCase/pluginWrongCase.pro @@ -0,0 +1,8 @@ +TEMPLATE = lib +CONFIG += plugin +SOURCES = plugin.cpp +QT = core qml +TARGET = Plugin +DESTDIR = ../imports/com/nokia/WrongCase + +QT += core-private gui-private qml-private diff --git a/tests/auto/qml/qqmlmoduleplugin/qqmlmoduleplugin.pro b/tests/auto/qml/qqmlmoduleplugin/qqmlmoduleplugin.pro new file mode 100644 index 0000000000..42eedc20f2 --- /dev/null +++ b/tests/auto/qml/qqmlmoduleplugin/qqmlmoduleplugin.pro @@ -0,0 +1,9 @@ +QT = core +TEMPLATE = subdirs +SUBDIRS = plugin plugin.2 plugin.2.1 pluginWrongCase pluginWithQmlFile pluginMixed pluginVersion +tst_qqmlmoduleplugin_pro.depends += plugin +SUBDIRS += tst_qqmlmoduleplugin.pro + +CONFIG += parallel_test + +QT += core-private gui-private qml-private diff --git a/tests/auto/qml/qqmlmoduleplugin/tst_qqmlmoduleplugin.cpp b/tests/auto/qml/qqmlmoduleplugin/tst_qqmlmoduleplugin.cpp new file mode 100644 index 0000000000..b574bad595 --- /dev/null +++ b/tests/auto/qml/qqmlmoduleplugin/tst_qqmlmoduleplugin.cpp @@ -0,0 +1,353 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include +#include +#include +#include +#include + +#include "../../shared/testhttpserver.h" +#include "../../shared/util.h" + +#define SERVER_ADDR "http://127.0.0.1:14450" +#define SERVER_PORT 14450 + + +class tst_qqmlmoduleplugin : public QQmlDataTest +{ + Q_OBJECT +public: + +private slots: + virtual void initTestCase(); + void importsPlugin(); + void importsPlugin2(); + void importsPlugin21(); + void importsMixedQmlCppPlugin(); + void incorrectPluginCase(); + void importPluginWithQmlFile(); + void remoteImportWithQuotedUrl(); + void remoteImportWithUnquotedUri(); + void versionNotInstalled(); + void versionNotInstalled_data(); + void implicitQmldir(); + void implicitQmldir_data(); + +private: + QString m_importsDirectory; +}; + +void tst_qqmlmoduleplugin::initTestCase() +{ + QQmlDataTest::initTestCase(); + m_importsDirectory = directory() + QStringLiteral("/imports"); + QVERIFY2(QFileInfo(m_importsDirectory).isDir(), + qPrintable(QString::fromLatin1("Imports directory '%1' does not exist.").arg(m_importsDirectory))); +} + +#define VERIFY_ERRORS(errorfile) \ + if (!errorfile) { \ + if (qgetenv("DEBUG") != "" && !component.errors().isEmpty()) \ + qWarning() << "Unexpected Errors:" << component.errors(); \ + QVERIFY(!component.isError()); \ + QVERIFY(component.errors().isEmpty()); \ + } else { \ + QString verify_errors_file_name = testFile(errorfile); \ + QFile file(verify_errors_file_name); \ + QVERIFY(file.open(QIODevice::ReadOnly | QIODevice::Text)); \ + QByteArray data = file.readAll(); \ + file.close(); \ + QList expected = data.split('\n'); \ + expected.removeAll(QByteArray("")); \ + QList errors = component.errors(); \ + QList actual; \ + for (int ii = 0; ii < errors.count(); ++ii) { \ + const QQmlError &error = errors.at(ii); \ + QByteArray errorStr = QByteArray::number(error.line()) + ":" + \ + QByteArray::number(error.column()) + ":" + \ + error.description().toUtf8(); \ + actual << errorStr; \ + } \ + if (qgetenv("DEBUG") != "" && expected != actual) { \ + qWarning() << "Expected:" << expected << "Actual:" << actual; \ + } \ + if (qgetenv("QDECLARATIVELANGUAGE_UPDATEERRORS") != "" && expected != actual) {\ + QFile file(testFile(errorfile)); \ + QVERIFY(file.open(QIODevice::WriteOnly)); \ + for (int ii = 0; ii < actual.count(); ++ii) { \ + file.write(actual.at(ii)); file.write("\n"); \ + } \ + file.close(); \ + } else { \ + QCOMPARE(expected, actual); \ + } \ + } + +void tst_qqmlmoduleplugin::importsPlugin() +{ + QQmlEngine engine; + engine.addImportPath(m_importsDirectory); + QTest::ignoreMessage(QtWarningMsg, "plugin created"); + QTest::ignoreMessage(QtWarningMsg, "import worked"); + QQmlComponent component(&engine, testFileUrl(QStringLiteral("works.qml"))); + foreach (QQmlError err, component.errors()) + qWarning() << err; + VERIFY_ERRORS(0); + QObject *object = component.create(); + QVERIFY(object != 0); + QCOMPARE(object->property("value").toInt(),123); + delete object; +} + +void tst_qqmlmoduleplugin::importsPlugin2() +{ + QQmlEngine engine; + engine.addImportPath(m_importsDirectory); + QTest::ignoreMessage(QtWarningMsg, "plugin2 created"); + QTest::ignoreMessage(QtWarningMsg, "import2 worked"); + QQmlComponent component(&engine, testFileUrl(QStringLiteral("works2.qml"))); + foreach (QQmlError err, component.errors()) + qWarning() << err; + VERIFY_ERRORS(0); + QObject *object = component.create(); + QVERIFY(object != 0); + QCOMPARE(object->property("value").toInt(),123); + delete object; +} + +void tst_qqmlmoduleplugin::importsPlugin21() +{ + QQmlEngine engine; + engine.addImportPath(m_importsDirectory); + QTest::ignoreMessage(QtWarningMsg, "plugin2.1 created"); + QTest::ignoreMessage(QtWarningMsg, "import2.1 worked"); + QQmlComponent component(&engine, testFileUrl(QStringLiteral("works21.qml"))); + foreach (QQmlError err, component.errors()) + qWarning() << err; + VERIFY_ERRORS(0); + QObject *object = component.create(); + QVERIFY(object != 0); + QCOMPARE(object->property("value").toInt(),123); + delete object; +} + +void tst_qqmlmoduleplugin::incorrectPluginCase() +{ + QQmlEngine engine; + engine.addImportPath(m_importsDirectory); + + QQmlComponent component(&engine, testFileUrl(QStringLiteral("incorrectCase.qml"))); + + QList errors = component.errors(); + QCOMPARE(errors.count(), 1); + +#if defined(Q_OS_MAC) || defined(Q_OS_WIN32) +#if defined(Q_OS_MAC) + QString libname = "libPluGin.dylib"; +#elif defined(Q_OS_WIN32) + QString libname = "PluGin.dll"; +#endif + QString expectedError = QLatin1String("plugin cannot be loaded for module \"com.nokia.WrongCase\": File name case mismatch for \"") + QDir(m_importsDirectory).filePath("com/nokia/WrongCase/" + libname) + QLatin1String("\""); +#else + QString expectedError = QLatin1String("module \"com.nokia.WrongCase\" plugin \"PluGin\" not found"); +#endif + + QCOMPARE(errors.at(0).description(), expectedError); +} + +void tst_qqmlmoduleplugin::importPluginWithQmlFile() +{ + QString path = m_importsDirectory; + + // QTBUG-16885: adding an import path with a lower-case "c:" causes assert failure + // (this only happens if the plugin includes pure QML files) + #ifdef Q_OS_WIN + QVERIFY(path.at(0).isUpper() && path.at(1) == QLatin1Char(':')); + path = path.at(0).toLower() + path.mid(1); + #endif + + QQmlEngine engine; + engine.addImportPath(path); + + QQmlComponent component(&engine, testFileUrl(QStringLiteral("pluginWithQmlFile.qml"))); + foreach (QQmlError err, component.errors()) + qWarning() << err; + VERIFY_ERRORS(0); + QObject *object = component.create(); + QVERIFY(object != 0); + delete object; +} + +void tst_qqmlmoduleplugin::remoteImportWithQuotedUrl() +{ + TestHTTPServer server(SERVER_PORT); + QVERIFY(server.isValid()); + server.serveDirectory(m_importsDirectory); + + QQmlEngine engine; + QQmlComponent component(&engine); + component.setData("import \"http://127.0.0.1:14450/com/nokia/PureQmlModule\" \nComponentA { width: 300; ComponentB{} }", QUrl()); + + QTRY_COMPARE(component.status(), QQmlComponent::Ready); + QObject *object = component.create(); + QCOMPARE(object->property("width").toInt(), 300); + QVERIFY(object != 0); + delete object; + + foreach (QQmlError err, component.errors()) + qWarning() << err; + VERIFY_ERRORS(0); +} + +void tst_qqmlmoduleplugin::remoteImportWithUnquotedUri() +{ + TestHTTPServer server(SERVER_PORT); + QVERIFY(server.isValid()); + server.serveDirectory(m_importsDirectory); + + QQmlEngine engine; + engine.addImportPath(m_importsDirectory); + QQmlComponent component(&engine); + component.setData("import com.nokia.PureQmlModule 1.0 \nComponentA { width: 300; ComponentB{} }", QUrl()); + + + QTRY_COMPARE(component.status(), QQmlComponent::Ready); + QObject *object = component.create(); + QVERIFY(object != 0); + QCOMPARE(object->property("width").toInt(), 300); + delete object; + + foreach (QQmlError err, component.errors()) + qWarning() << err; + VERIFY_ERRORS(0); +} + +// QTBUG-17324 + +void tst_qqmlmoduleplugin::importsMixedQmlCppPlugin() +{ + QQmlEngine engine; + engine.addImportPath(m_importsDirectory); + + { + QQmlComponent component(&engine, testFileUrl(QStringLiteral("importsMixedQmlCppPlugin.qml"))); + + QObject *o = component.create(); + QVERIFY2(o != 0, QQmlDataTest::msgComponentError(component, &engine)); + QCOMPARE(o->property("test").toBool(), true); + delete o; + } + + { + QQmlComponent component(&engine, testFileUrl(QStringLiteral("importsMixedQmlCppPlugin.2.qml"))); + + QObject *o = component.create(); + QVERIFY2(o != 0, QQmlDataTest::msgComponentError(component, &engine)); + QCOMPARE(o->property("test").toBool(), true); + QCOMPARE(o->property("test2").toBool(), true); + delete o; + } + + +} + +void tst_qqmlmoduleplugin::versionNotInstalled_data() +{ + QTest::addColumn("file"); + QTest::addColumn("errorFile"); + + QTest::newRow("versionNotInstalled") << "versionNotInstalled.qml" << "versionNotInstalled.errors.txt"; + QTest::newRow("versionNotInstalled") << "versionNotInstalled.2.qml" << "versionNotInstalled.2.errors.txt"; +} + +void tst_qqmlmoduleplugin::versionNotInstalled() +{ + QFETCH(QString, file); + QFETCH(QString, errorFile); + + QQmlEngine engine; + engine.addImportPath(m_importsDirectory); + + QQmlComponent component(&engine, testFileUrl(file)); + VERIFY_ERRORS(errorFile.toLatin1().constData()); +} + + +// test that errors are reporting correctly for plugin loading and qmldir parsing +void tst_qqmlmoduleplugin::implicitQmldir_data() +{ + QTest::addColumn("directory"); + QTest::addColumn("file"); + QTest::addColumn("errorFile"); + + // parsing qmldir succeeds, but plugin specified in the qmldir file doesn't exist + QTest::newRow("implicitQmldir") << "implicit1" << "temptest.qml" << "implicitQmldir.errors.txt"; + + // parsing qmldir fails due to syntax errors, etc. + QTest::newRow("implicitQmldir2") << "implicit2" << "temptest2.qml" << "implicitQmldir.2.errors.txt"; +} +void tst_qqmlmoduleplugin::implicitQmldir() +{ + QFETCH(QString, directory); + QFETCH(QString, file); + QFETCH(QString, errorFile); + + QString importPath = testFile(directory); + QString fileName = directory + QDir::separator() + file; + QString errorFileName = directory + QDir::separator() + errorFile; + QUrl testUrl = testFileUrl(fileName); + + QQmlEngine engine; + engine.addImportPath(importPath); + + QQmlComponent component(&engine, testUrl); + QList errors = component.errors(); + VERIFY_ERRORS(errorFileName.toLatin1().constData()); + QTest::ignoreMessage(QtWarningMsg, "QQmlComponent: Component is not ready"); + QObject *obj = component.create(); + QVERIFY(!obj); + delete obj; +} + + +QTEST_MAIN(tst_qqmlmoduleplugin) + +#include "tst_qqmlmoduleplugin.moc" diff --git a/tests/auto/qml/qqmlmoduleplugin/tst_qqmlmoduleplugin.pro b/tests/auto/qml/qqmlmoduleplugin/tst_qqmlmoduleplugin.pro new file mode 100644 index 0000000000..3d5fe7d6ae --- /dev/null +++ b/tests/auto/qml/qqmlmoduleplugin/tst_qqmlmoduleplugin.pro @@ -0,0 +1,19 @@ +CONFIG += testcase +TARGET = tst_qqmlmoduleplugin + +HEADERS = ../../shared/testhttpserver.h +SOURCES = tst_qqmlmoduleplugin.cpp \ + ../../shared/testhttpserver.cpp +CONFIG -= app_bundle + +include (../../shared/util.pri) + +testDataFiles.files = data +testDataFiles.path = . +DEPLOYMENT += testDataFiles + +testImportFiles.files = imports +testImportFiles.path = . +DEPLOYMENT += testImportFiles + +QT += core-private gui-private qml-private network testlib diff --git a/tests/auto/qml/qqmlparser/qqmlparser.pro b/tests/auto/qml/qqmlparser/qqmlparser.pro new file mode 100644 index 0000000000..e1b7b39402 --- /dev/null +++ b/tests/auto/qml/qqmlparser/qqmlparser.pro @@ -0,0 +1,9 @@ +CONFIG += testcase +TARGET = tst_qqmlparser +QT += qmldevtools-private testlib +macx:CONFIG -= app_bundle + +SOURCES += tst_qqmlparser.cpp +DEFINES += SRCDIR=\\\"$$PWD\\\" + +CONFIG += parallel_test diff --git a/tests/auto/qml/qqmlparser/tst_qqmlparser.cpp b/tests/auto/qml/qqmlparser/tst_qqmlparser.cpp new file mode 100644 index 0000000000..5fb5b71533 --- /dev/null +++ b/tests/auto/qml/qqmlparser/tst_qqmlparser.cpp @@ -0,0 +1,210 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +class tst_qqmlparser : public QObject +{ + Q_OBJECT +public: + tst_qqmlparser(); + +private slots: + void initTestCase(); + void qmlParser_data(); + void qmlParser(); + +private: + QStringList excludedDirs; + + QStringList findFiles(const QDir &); +}; + +namespace check { + +using namespace QQmlJS; + +class Check: public AST::Visitor +{ + Engine *engine; + QList nodeStack; + +public: + Check(Engine *engine) + : engine(engine) + { + } + + void operator()(AST::Node *node) + { + AST::Node::accept(node, this); + } + + void checkNode(AST::Node *node) + { + if (! nodeStack.isEmpty()) { + AST::Node *parent = nodeStack.last(); + const quint32 parentBegin = parent->firstSourceLocation().begin(); + const quint32 parentEnd = parent->lastSourceLocation().end(); + + QVERIFY(node->firstSourceLocation().begin() >= parentBegin); + QVERIFY(node->lastSourceLocation().end() <= parentEnd); + } + } + + virtual bool preVisit(AST::Node *node) + { + checkNode(node); + nodeStack.append(node); + return true; + } + + virtual void postVisit(AST::Node *) + { + nodeStack.removeLast(); + } +}; + +} + +tst_qqmlparser::tst_qqmlparser() +{ +} + +void tst_qqmlparser::initTestCase() +{ + // Add directories you want excluded here + + // These snippets are not expected to run on their own. + excludedDirs << "doc/src/snippets/qml/visualdatamodel_rootindex"; + excludedDirs << "doc/src/snippets/qml/qtbinding"; + excludedDirs << "doc/src/snippets/qml/imports"; + excludedDirs << "doc/src/snippets/qtquick1/visualdatamodel_rootindex"; + excludedDirs << "doc/src/snippets/qtquick1/qtbinding"; + excludedDirs << "doc/src/snippets/qtquick1/imports"; +} + +QStringList tst_qqmlparser::findFiles(const QDir &d) +{ + for (int ii = 0; ii < excludedDirs.count(); ++ii) { + QString s = excludedDirs.at(ii); + if (d.absolutePath().endsWith(s)) + return QStringList(); + } + + QStringList rv; + + QStringList files = d.entryList(QStringList() << QLatin1String("*.qml") << QLatin1String("*.js"), + QDir::Files); + foreach (const QString &file, files) { + rv << d.absoluteFilePath(file); + } + + QStringList dirs = d.entryList(QDir::Dirs | QDir::NoDotAndDotDot | + QDir::NoSymLinks); + foreach (const QString &dir, dirs) { + QDir sub = d; + sub.cd(dir); + rv << findFiles(sub); + } + + return rv; +} + +/* +This test checks all the qml and js files in the QtQml UI source tree +and ensures that the subnode's source locations are inside parent node's source locations +*/ + +void tst_qqmlparser::qmlParser_data() +{ + QTest::addColumn("file"); + + QString examples = QLatin1String(SRCDIR) + "/../../../../examples/"; + QString tests = QLatin1String(SRCDIR) + "/../../../../tests/"; + + QStringList files; + files << findFiles(QDir(examples)); + files << findFiles(QDir(tests)); + + foreach (const QString &file, files) + QTest::newRow(qPrintable(file)) << file; +} + +void tst_qqmlparser::qmlParser() +{ + QFETCH(QString, file); + + using namespace QQmlJS; + + QString code; + + QFile f(file); + if (f.open(QFile::ReadOnly)) + code = QString::fromUtf8(f.readAll()); + + const bool qmlMode = file.endsWith(QLatin1String(".qml")); + + Engine engine; + Lexer lexer(&engine); + lexer.setCode(code, 1, qmlMode); + Parser parser(&engine); + if (qmlMode) + parser.parse(); + else + parser.parseProgram(); + + check::Check chk(&engine); + chk(parser.rootNode()); +} + +QTEST_MAIN(tst_qqmlparser) + +#include "tst_qqmlparser.moc" diff --git a/tests/auto/qml/qqmlpixmapcache/data/dataLeak.qml b/tests/auto/qml/qqmlpixmapcache/data/dataLeak.qml new file mode 100644 index 0000000000..724ce5d816 --- /dev/null +++ b/tests/auto/qml/qqmlpixmapcache/data/dataLeak.qml @@ -0,0 +1,18 @@ +import QtQuick 2.0 + +Item { + id: root + width: 800 + height: 800 + + Image { + id: i1 + source: "exists1.png"; + anchors.top: parent.top; + } + Image { + id: i2 + source: "exists2.png" + anchors.top: i1.bottom; + } +} diff --git a/tests/auto/qml/qqmlproperty/data/NoContextTypeA.qml b/tests/auto/qml/qqmlproperty/data/NoContextTypeA.qml new file mode 100644 index 0000000000..f58967cbb2 --- /dev/null +++ b/tests/auto/qml/qqmlproperty/data/NoContextTypeA.qml @@ -0,0 +1,5 @@ +import QtQuick 2.0 + +QtObject { + property string someString +} diff --git a/tests/auto/qml/qqmlproperty/data/NoContextTypeB.qml b/tests/auto/qml/qqmlproperty/data/NoContextTypeB.qml new file mode 100644 index 0000000000..4b3672873d --- /dev/null +++ b/tests/auto/qml/qqmlproperty/data/NoContextTypeB.qml @@ -0,0 +1,5 @@ +import QtQuick 2.0 + +QtObject { + property NoContextTypeA myTypeA +} diff --git a/tests/auto/qml/qqmlproperty/data/TestType.qml b/tests/auto/qml/qqmlproperty/data/TestType.qml new file mode 100644 index 0000000000..1fe150548a --- /dev/null +++ b/tests/auto/qml/qqmlproperty/data/TestType.qml @@ -0,0 +1,6 @@ +import QtQuick 2.0 + +QtObject { + property int a: 10 +} + diff --git a/tests/auto/qml/qqmlproperty/data/aliasPropertyBindings.qml b/tests/auto/qml/qqmlproperty/data/aliasPropertyBindings.qml new file mode 100644 index 0000000000..f101f38a2d --- /dev/null +++ b/tests/auto/qml/qqmlproperty/data/aliasPropertyBindings.qml @@ -0,0 +1,19 @@ +import QtQuick 2.0 + +Item { + id: root + + property real test: 9 + property real test2: 3 + + property real realProperty: test * test + test + property alias aliasProperty: root.realProperty + + states: State { + name: "switch" + PropertyChanges { + target: root + aliasProperty: 32 * test2 + } + } +} diff --git a/tests/auto/qml/qqmlproperty/data/assignEmptyVariantMap.qml b/tests/auto/qml/qqmlproperty/data/assignEmptyVariantMap.qml new file mode 100644 index 0000000000..a9e51c1255 --- /dev/null +++ b/tests/auto/qml/qqmlproperty/data/assignEmptyVariantMap.qml @@ -0,0 +1,5 @@ +import QtQuick 2.0 + +Item { + Component.onCompleted: { o.variantMap = {}; } +} diff --git a/tests/auto/qml/qqmlproperty/data/readSynthesizedObject.qml b/tests/auto/qml/qqmlproperty/data/readSynthesizedObject.qml new file mode 100644 index 0000000000..55010b69a9 --- /dev/null +++ b/tests/auto/qml/qqmlproperty/data/readSynthesizedObject.qml @@ -0,0 +1,9 @@ +import QtQuick 2.0 + +QtObject { + property TestType test + + test: TestType { + property int b: 19 + } +} diff --git a/tests/auto/qml/qqmlproperty/qqmlproperty.pro b/tests/auto/qml/qqmlproperty/qqmlproperty.pro new file mode 100644 index 0000000000..689db4d7cf --- /dev/null +++ b/tests/auto/qml/qqmlproperty/qqmlproperty.pro @@ -0,0 +1,15 @@ +CONFIG += testcase +TARGET = tst_qqmlproperty +macx:CONFIG -= app_bundle + +SOURCES += tst_qqmlproperty.cpp + +include (../../shared/util.pri) + +testDataFiles.files = data +testDataFiles.path = . +DEPLOYMENT += testDataFiles + +CONFIG += parallel_test + +QT += core-private gui-private v8-private qml-private widgets testlib diff --git a/tests/auto/qml/qqmlproperty/tst_qqmlproperty.cpp b/tests/auto/qml/qqmlproperty/tst_qqmlproperty.cpp new file mode 100644 index 0000000000..ae300900c9 --- /dev/null +++ b/tests/auto/qml/qqmlproperty/tst_qqmlproperty.cpp @@ -0,0 +1,1721 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "../../shared/util.h" + +#include +class MyQmlObject : public QObject +{ + Q_OBJECT +public: + MyQmlObject() {} +}; + +QML_DECLARE_TYPE(MyQmlObject); + +class MyAttached : public QObject +{ + Q_OBJECT + Q_PROPERTY(int foo READ foo WRITE setFoo) +public: + MyAttached(QObject *parent) : QObject(parent), m_foo(13) {} + + int foo() const { return m_foo; } + void setFoo(int f) { m_foo = f; } + +private: + int m_foo; +}; + +class MyContainer : public QObject +{ + Q_OBJECT + Q_PROPERTY(QQmlListProperty children READ children) +public: + MyContainer() {} + + QQmlListProperty children() { return QQmlListProperty(this, m_children); } + + static MyAttached *qmlAttachedProperties(QObject *o) { + return new MyAttached(o); + } + +private: + QList m_children; +}; + +QML_DECLARE_TYPE(MyContainer); +QML_DECLARE_TYPEINFO(MyContainer, QML_HAS_ATTACHED_PROPERTIES) + +class tst_qqmlproperty : public QQmlDataTest +{ + Q_OBJECT +public: + tst_qqmlproperty() {} + +private slots: + void initTestCase(); + + // Constructors + void qmlmetaproperty(); + void qmlmetaproperty_object(); + void qmlmetaproperty_object_string(); + void qmlmetaproperty_object_context(); + void qmlmetaproperty_object_string_context(); + + // Methods + void name(); + void read(); + void write(); + void reset(); + + // Functionality + void writeObjectToList(); + void writeListToList(); + + //writeToReadOnly(); + + void urlHandling_data(); + void urlHandling(); + + void variantMapHandling_data(); + void variantMapHandling(); + + // Bugs + void crashOnValueProperty(); + void aliasPropertyBindings(); + void noContext(); + void assignEmptyVariantMap(); + + void copy(); +private: + QQmlEngine engine; +}; + +void tst_qqmlproperty::qmlmetaproperty() +{ + QQmlProperty prop; + + QWeakPointer binding(new QQmlBinding(QLatin1String("null"), 0, engine.rootContext())); + QVERIFY(binding != 0); + QWeakPointer expression(new QQmlExpression()); + QVERIFY(expression != 0); + + QObject *obj = new QObject; + + QCOMPARE(prop.name(), QString()); + QCOMPARE(prop.read(), QVariant()); + QCOMPARE(prop.write(QVariant()), false); + QCOMPARE(prop.hasNotifySignal(), false); + QCOMPARE(prop.needsNotifySignal(), false); + QCOMPARE(prop.connectNotifySignal(0, SLOT(deleteLater())), false); + QCOMPARE(prop.connectNotifySignal(obj, SLOT(deleteLater())), false); + QCOMPARE(prop.connectNotifySignal(obj, 0), false); + QCOMPARE(prop.connectNotifySignal(0, obj->metaObject()->indexOfMethod("deleteLater()")), false); + QCOMPARE(prop.connectNotifySignal(obj, obj->metaObject()->indexOfMethod("deleteLater()")), false); + QCOMPARE(prop.connectNotifySignal(obj, -1), false); + QVERIFY(prop.method().signature() == 0); + QCOMPARE(prop.type(), QQmlProperty::Invalid); + QCOMPARE(prop.isProperty(), false); + QCOMPARE(prop.isWritable(), false); + QCOMPARE(prop.isDesignable(), false); + QCOMPARE(prop.isResettable(), false); + QCOMPARE(prop.isSignalProperty(), false); + QCOMPARE(prop.isValid(), false); + QCOMPARE(prop.object(), (QObject *)0); + QCOMPARE(prop.propertyTypeCategory(), QQmlProperty::InvalidCategory); + QCOMPARE(prop.propertyType(), 0); + QCOMPARE(prop.propertyTypeName(), (const char *)0); + QVERIFY(prop.property().name() == 0); + QVERIFY(QQmlPropertyPrivate::binding(prop) == 0); + QVERIFY(QQmlPropertyPrivate::setBinding(prop, binding.data()) == 0); + QVERIFY(binding == 0); + QVERIFY(QQmlPropertyPrivate::signalExpression(prop) == 0); + QVERIFY(QQmlPropertyPrivate::setSignalExpression(prop, expression.data()) == 0); + QVERIFY(expression == 0); + QCOMPARE(prop.index(), -1); + QCOMPARE(QQmlPropertyPrivate::valueTypeCoreIndex(prop), -1); + + delete obj; +} + +class PropertyObject : public QObject +{ + Q_OBJECT + Q_PROPERTY(int defaultProperty READ defaultProperty) + Q_PROPERTY(QRect rectProperty READ rectProperty) + Q_PROPERTY(QRect wrectProperty READ wrectProperty WRITE setWRectProperty) + Q_PROPERTY(QUrl url READ url WRITE setUrl) + Q_PROPERTY(QVariantMap variantMap READ variantMap WRITE setVariantMap) + Q_PROPERTY(int resettableProperty READ resettableProperty WRITE setResettableProperty RESET resetProperty) + Q_PROPERTY(int propertyWithNotify READ propertyWithNotify WRITE setPropertyWithNotify NOTIFY oddlyNamedNotifySignal) + Q_PROPERTY(MyQmlObject *qmlObject READ qmlObject) + + Q_CLASSINFO("DefaultProperty", "defaultProperty") +public: + PropertyObject() : m_resetProperty(9) {} + + int defaultProperty() { return 10; } + QRect rectProperty() { return QRect(10, 10, 1, 209); } + + QRect wrectProperty() { return m_rect; } + void setWRectProperty(const QRect &r) { m_rect = r; } + + QUrl url() { return m_url; } + void setUrl(const QUrl &u) { m_url = u; } + + QVariantMap variantMap() const { return m_variantMap; } + void setVariantMap(const QVariantMap &variantMap) { m_variantMap = variantMap; } + + int resettableProperty() const { return m_resetProperty; } + void setResettableProperty(int r) { m_resetProperty = r; } + void resetProperty() { m_resetProperty = 9; } + + int propertyWithNotify() const { return m_propertyWithNotify; } + void setPropertyWithNotify(int i) { m_propertyWithNotify = i; emit oddlyNamedNotifySignal(); } + + MyQmlObject *qmlObject() { return &m_qmlObject; } + +signals: + void clicked(); + void oddlyNamedNotifySignal(); + +private: + int m_resetProperty; + QRect m_rect; + QUrl m_url; + QVariantMap m_variantMap; + int m_propertyWithNotify; + MyQmlObject m_qmlObject; +}; + +QML_DECLARE_TYPE(PropertyObject); + +void tst_qqmlproperty::qmlmetaproperty_object() +{ + QObject object; // Has no default property + PropertyObject dobject; // Has default property + + { + QQmlProperty prop(&object); + + QWeakPointer binding(new QQmlBinding(QLatin1String("null"), 0, engine.rootContext())); + QVERIFY(binding != 0); + QWeakPointer expression(new QQmlExpression()); + QVERIFY(expression != 0); + + QObject *obj = new QObject; + + QCOMPARE(prop.name(), QString()); + QCOMPARE(prop.read(), QVariant()); + QCOMPARE(prop.write(QVariant()), false); + QCOMPARE(prop.hasNotifySignal(), false); + QCOMPARE(prop.needsNotifySignal(), false); + QCOMPARE(prop.connectNotifySignal(0, SLOT(deleteLater())), false); + QCOMPARE(prop.connectNotifySignal(obj, SLOT(deleteLater())), false); + QCOMPARE(prop.connectNotifySignal(obj, 0), false); + QCOMPARE(prop.connectNotifySignal(0, obj->metaObject()->indexOfMethod("deleteLater()")), false); + QCOMPARE(prop.connectNotifySignal(obj, obj->metaObject()->indexOfMethod("deleteLater()")), false); + QCOMPARE(prop.connectNotifySignal(obj, -1), false); + QVERIFY(prop.method().signature() == 0); + QCOMPARE(prop.type(), QQmlProperty::Invalid); + QCOMPARE(prop.isProperty(), false); + QCOMPARE(prop.isWritable(), false); + QCOMPARE(prop.isDesignable(), false); + QCOMPARE(prop.isResettable(), false); + QCOMPARE(prop.isSignalProperty(), false); + QCOMPARE(prop.isValid(), false); + QCOMPARE(prop.object(), (QObject *)0); + QCOMPARE(prop.propertyTypeCategory(), QQmlProperty::InvalidCategory); + QCOMPARE(prop.propertyType(), 0); + QCOMPARE(prop.propertyTypeName(), (const char *)0); + QVERIFY(prop.property().name() == 0); + QVERIFY(QQmlPropertyPrivate::binding(prop) == 0); + QVERIFY(QQmlPropertyPrivate::setBinding(prop, binding.data()) == 0); + QVERIFY(binding == 0); + QVERIFY(QQmlPropertyPrivate::signalExpression(prop) == 0); + QVERIFY(QQmlPropertyPrivate::setSignalExpression(prop, expression.data()) == 0); + QVERIFY(expression == 0); + QCOMPARE(prop.index(), -1); + QCOMPARE(QQmlPropertyPrivate::valueTypeCoreIndex(prop), -1); + + delete obj; + } + + { + QQmlProperty prop(&dobject); + + QWeakPointer binding(new QQmlBinding(QLatin1String("null"), 0, engine.rootContext())); + binding.data()->setTarget(prop); + QVERIFY(binding != 0); + QWeakPointer expression(new QQmlExpression()); + QVERIFY(expression != 0); + + QObject *obj = new QObject; + + QCOMPARE(prop.name(), QString("defaultProperty")); + QCOMPARE(prop.read(), QVariant(10)); + QCOMPARE(prop.write(QVariant()), false); + QCOMPARE(prop.hasNotifySignal(), false); + QCOMPARE(prop.needsNotifySignal(), true); + QCOMPARE(prop.connectNotifySignal(0, SLOT(deleteLater())), false); + QCOMPARE(prop.connectNotifySignal(obj, SLOT(deleteLater())), false); + QCOMPARE(prop.connectNotifySignal(obj, 0), false); + QCOMPARE(prop.connectNotifySignal(0, obj->metaObject()->indexOfMethod("deleteLater()")), false); + QCOMPARE(prop.connectNotifySignal(obj, obj->metaObject()->indexOfMethod("deleteLater()")), false); + QCOMPARE(prop.connectNotifySignal(obj, -1), false); + QVERIFY(prop.method().signature() == 0); + QCOMPARE(prop.type(), QQmlProperty::Property); + QCOMPARE(prop.isProperty(), true); + QCOMPARE(prop.isWritable(), false); + QCOMPARE(prop.isDesignable(), true); + QCOMPARE(prop.isResettable(), false); + QCOMPARE(prop.isSignalProperty(), false); + QCOMPARE(prop.isValid(), true); + QCOMPARE(prop.object(), qobject_cast(&dobject)); + QCOMPARE(prop.propertyTypeCategory(), QQmlProperty::Normal); + QCOMPARE(prop.propertyType(), (int)QVariant::Int); + QCOMPARE(prop.propertyTypeName(), "int"); + QCOMPARE(QString(prop.property().name()), QString("defaultProperty")); + QVERIFY(QQmlPropertyPrivate::binding(prop) == 0); + QTest::ignoreMessage(QtWarningMsg, ": Unable to assign null to int"); + QVERIFY(QQmlPropertyPrivate::setBinding(prop, binding.data()) == 0); + QVERIFY(binding != 0); + QVERIFY(QQmlPropertyPrivate::binding(prop) == binding.data()); + QVERIFY(QQmlPropertyPrivate::signalExpression(prop) == 0); + QVERIFY(QQmlPropertyPrivate::setSignalExpression(prop, expression.data()) == 0); + QVERIFY(expression == 0); + QCOMPARE(prop.index(), dobject.metaObject()->indexOfProperty("defaultProperty")); + QCOMPARE(QQmlPropertyPrivate::valueTypeCoreIndex(prop), -1); + + delete obj; + } +} + +void tst_qqmlproperty::qmlmetaproperty_object_string() +{ + QObject object; + PropertyObject dobject; + + { + QQmlProperty prop(&object, QString("defaultProperty")); + + QWeakPointer binding(new QQmlBinding(QLatin1String("null"), 0, engine.rootContext())); + QVERIFY(binding != 0); + QWeakPointer expression(new QQmlExpression()); + QVERIFY(expression != 0); + + QObject *obj = new QObject; + + QCOMPARE(prop.name(), QString()); + QCOMPARE(prop.read(), QVariant()); + QCOMPARE(prop.write(QVariant()), false); + QCOMPARE(prop.hasNotifySignal(), false); + QCOMPARE(prop.needsNotifySignal(), false); + QCOMPARE(prop.connectNotifySignal(0, SLOT(deleteLater())), false); + QCOMPARE(prop.connectNotifySignal(obj, SLOT(deleteLater())), false); + QCOMPARE(prop.connectNotifySignal(obj, 0), false); + QCOMPARE(prop.connectNotifySignal(0, obj->metaObject()->indexOfMethod("deleteLater()")), false); + QCOMPARE(prop.connectNotifySignal(obj, obj->metaObject()->indexOfMethod("deleteLater()")), false); + QCOMPARE(prop.connectNotifySignal(obj, -1), false); + QVERIFY(prop.method().signature() == 0); + QCOMPARE(prop.type(), QQmlProperty::Invalid); + QCOMPARE(prop.isProperty(), false); + QCOMPARE(prop.isWritable(), false); + QCOMPARE(prop.isDesignable(), false); + QCOMPARE(prop.isResettable(), false); + QCOMPARE(prop.isSignalProperty(), false); + QCOMPARE(prop.isValid(), false); + QCOMPARE(prop.object(), (QObject *)0); + QCOMPARE(prop.propertyTypeCategory(), QQmlProperty::InvalidCategory); + QCOMPARE(prop.propertyType(), 0); + QCOMPARE(prop.propertyTypeName(), (const char *)0); + QVERIFY(prop.property().name() == 0); + QVERIFY(QQmlPropertyPrivate::binding(prop) == 0); + QVERIFY(QQmlPropertyPrivate::setBinding(prop, binding.data()) == 0); + QVERIFY(binding == 0); + QVERIFY(QQmlPropertyPrivate::signalExpression(prop) == 0); + QVERIFY(QQmlPropertyPrivate::setSignalExpression(prop, expression.data()) == 0); + QVERIFY(expression == 0); + QCOMPARE(prop.index(), -1); + QCOMPARE(QQmlPropertyPrivate::valueTypeCoreIndex(prop), -1); + + delete obj; + } + + { + QQmlProperty prop(&dobject, QString("defaultProperty")); + + QWeakPointer binding(new QQmlBinding(QLatin1String("null"), 0, engine.rootContext())); + binding.data()->setTarget(prop); + QVERIFY(binding != 0); + QWeakPointer expression(new QQmlExpression()); + QVERIFY(expression != 0); + + QObject *obj = new QObject; + + QCOMPARE(prop.name(), QString("defaultProperty")); + QCOMPARE(prop.read(), QVariant(10)); + QCOMPARE(prop.write(QVariant()), false); + QCOMPARE(prop.hasNotifySignal(), false); + QCOMPARE(prop.needsNotifySignal(), true); + QCOMPARE(prop.connectNotifySignal(0, SLOT(deleteLater())), false); + QCOMPARE(prop.connectNotifySignal(obj, SLOT(deleteLater())), false); + QCOMPARE(prop.connectNotifySignal(obj, 0), false); + QCOMPARE(prop.connectNotifySignal(0, obj->metaObject()->indexOfMethod("deleteLater()")), false); + QCOMPARE(prop.connectNotifySignal(obj, obj->metaObject()->indexOfMethod("deleteLater()")), false); + QCOMPARE(prop.connectNotifySignal(obj, -1), false); + QVERIFY(prop.method().signature() == 0); + QCOMPARE(prop.type(), QQmlProperty::Property); + QCOMPARE(prop.isProperty(), true); + QCOMPARE(prop.isWritable(), false); + QCOMPARE(prop.isDesignable(), true); + QCOMPARE(prop.isResettable(), false); + QCOMPARE(prop.isSignalProperty(), false); + QCOMPARE(prop.isValid(), true); + QCOMPARE(prop.object(), qobject_cast(&dobject)); + QCOMPARE(prop.propertyTypeCategory(), QQmlProperty::Normal); + QCOMPARE(prop.propertyType(), (int)QVariant::Int); + QCOMPARE(prop.propertyTypeName(), "int"); + QCOMPARE(QString(prop.property().name()), QString("defaultProperty")); + QVERIFY(QQmlPropertyPrivate::binding(prop) == 0); + QTest::ignoreMessage(QtWarningMsg, ": Unable to assign null to int"); + QVERIFY(QQmlPropertyPrivate::setBinding(prop, binding.data()) == 0); + QVERIFY(binding != 0); + QVERIFY(QQmlPropertyPrivate::binding(prop) == binding.data()); + QVERIFY(QQmlPropertyPrivate::signalExpression(prop) == 0); + QVERIFY(QQmlPropertyPrivate::setSignalExpression(prop, expression.data()) == 0); + QVERIFY(expression == 0); + QCOMPARE(prop.index(), dobject.metaObject()->indexOfProperty("defaultProperty")); + QCOMPARE(QQmlPropertyPrivate::valueTypeCoreIndex(prop), -1); + + delete obj; + } + + { + QQmlProperty prop(&dobject, QString("onClicked")); + + QWeakPointer binding(new QQmlBinding(QLatin1String("null"), 0, engine.rootContext())); + binding.data()->setTarget(prop); + QVERIFY(binding != 0); + QWeakPointer expression(new QQmlExpression()); + QVERIFY(expression != 0); + + QObject *obj = new QObject; + + QCOMPARE(prop.name(), QString("onClicked")); + QCOMPARE(prop.read(), QVariant()); + QCOMPARE(prop.write(QVariant("Hello")), false); + QCOMPARE(prop.hasNotifySignal(), false); + QCOMPARE(prop.needsNotifySignal(), false); + QCOMPARE(prop.connectNotifySignal(0, SLOT(deleteLater())), false); + QCOMPARE(prop.connectNotifySignal(obj, SLOT(deleteLater())), false); + QCOMPARE(prop.connectNotifySignal(obj, 0), false); + QCOMPARE(prop.connectNotifySignal(0, obj->metaObject()->indexOfMethod("deleteLater()")), false); + QCOMPARE(prop.connectNotifySignal(obj, obj->metaObject()->indexOfMethod("deleteLater()")), false); + QCOMPARE(prop.connectNotifySignal(obj, -1), false); + QCOMPARE(QString(prop.method().signature()), QString("clicked()")); + QCOMPARE(prop.type(), QQmlProperty::SignalProperty); + QCOMPARE(prop.isProperty(), false); + QCOMPARE(prop.isWritable(), false); + QCOMPARE(prop.isDesignable(), false); + QCOMPARE(prop.isResettable(), false); + QCOMPARE(prop.isSignalProperty(), true); + QCOMPARE(prop.isValid(), true); + QCOMPARE(prop.object(), qobject_cast(&dobject)); + QCOMPARE(prop.propertyTypeCategory(), QQmlProperty::InvalidCategory); + QCOMPARE(prop.propertyType(), 0); + QCOMPARE(prop.propertyTypeName(), (const char *)0); + QCOMPARE(prop.property().name(), (const char *)0); + QVERIFY(QQmlPropertyPrivate::binding(prop) == 0); + QVERIFY(QQmlPropertyPrivate::setBinding(prop, binding.data()) == 0); + QVERIFY(binding == 0); + QVERIFY(QQmlPropertyPrivate::signalExpression(prop) == 0); + QVERIFY(QQmlPropertyPrivate::setSignalExpression(prop, expression.data()) == 0); + QVERIFY(expression != 0); + QVERIFY(QQmlPropertyPrivate::signalExpression(prop) == expression.data()); + QCOMPARE(prop.index(), dobject.metaObject()->indexOfMethod("clicked()")); + QCOMPARE(QQmlPropertyPrivate::valueTypeCoreIndex(prop), -1); + + delete obj; + } + + { + QQmlProperty prop(&dobject, QString("onPropertyWithNotifyChanged")); + + QWeakPointer binding(new QQmlBinding(QLatin1String("null"), 0, engine.rootContext())); + binding.data()->setTarget(prop); + QVERIFY(binding != 0); + QWeakPointer expression(new QQmlExpression()); + QVERIFY(expression != 0); + + QObject *obj = new QObject; + + QCOMPARE(prop.name(), QString("onOddlyNamedNotifySignal")); + QCOMPARE(prop.read(), QVariant()); + QCOMPARE(prop.write(QVariant("Hello")), false); + QCOMPARE(prop.hasNotifySignal(), false); + QCOMPARE(prop.needsNotifySignal(), false); + QCOMPARE(prop.connectNotifySignal(0, SLOT(deleteLater())), false); + QCOMPARE(prop.connectNotifySignal(obj, SLOT(deleteLater())), false); + QCOMPARE(prop.connectNotifySignal(obj, 0), false); + QCOMPARE(prop.connectNotifySignal(0, obj->metaObject()->indexOfMethod("deleteLater()")), false); + QCOMPARE(prop.connectNotifySignal(obj, obj->metaObject()->indexOfMethod("deleteLater()")), false); + QCOMPARE(prop.connectNotifySignal(obj, -1), false); + QCOMPARE(QString(prop.method().signature()), QString("oddlyNamedNotifySignal()")); + QCOMPARE(prop.type(), QQmlProperty::SignalProperty); + QCOMPARE(prop.isProperty(), false); + QCOMPARE(prop.isWritable(), false); + QCOMPARE(prop.isDesignable(), false); + QCOMPARE(prop.isResettable(), false); + QCOMPARE(prop.isSignalProperty(), true); + QCOMPARE(prop.isValid(), true); + QCOMPARE(prop.object(), qobject_cast(&dobject)); + QCOMPARE(prop.propertyTypeCategory(), QQmlProperty::InvalidCategory); + QCOMPARE(prop.propertyType(), 0); + QCOMPARE(prop.propertyTypeName(), (const char *)0); + QCOMPARE(prop.property().name(), (const char *)0); + QVERIFY(QQmlPropertyPrivate::binding(prop) == 0); + QVERIFY(QQmlPropertyPrivate::setBinding(prop, binding.data()) == 0); + QVERIFY(binding == 0); + QVERIFY(QQmlPropertyPrivate::signalExpression(prop) == 0); + QVERIFY(QQmlPropertyPrivate::setSignalExpression(prop, expression.data()) == 0); + QVERIFY(expression != 0); + QVERIFY(QQmlPropertyPrivate::signalExpression(prop) == expression.data()); + QCOMPARE(prop.index(), dobject.metaObject()->indexOfMethod("oddlyNamedNotifySignal()")); + QCOMPARE(QQmlPropertyPrivate::valueTypeCoreIndex(prop), -1); + + delete obj; + } +} + +void tst_qqmlproperty::qmlmetaproperty_object_context() +{ + QObject object; // Has no default property + PropertyObject dobject; // Has default property + + { + QQmlProperty prop(&object, engine.rootContext()); + + QWeakPointer binding(new QQmlBinding(QLatin1String("null"), 0, engine.rootContext())); + QVERIFY(binding != 0); + QWeakPointer expression(new QQmlExpression()); + QVERIFY(expression != 0); + + QObject *obj = new QObject; + + QCOMPARE(prop.name(), QString()); + QCOMPARE(prop.read(), QVariant()); + QCOMPARE(prop.write(QVariant()), false); + QCOMPARE(prop.hasNotifySignal(), false); + QCOMPARE(prop.needsNotifySignal(), false); + QCOMPARE(prop.connectNotifySignal(0, SLOT(deleteLater())), false); + QCOMPARE(prop.connectNotifySignal(obj, SLOT(deleteLater())), false); + QCOMPARE(prop.connectNotifySignal(obj, 0), false); + QCOMPARE(prop.connectNotifySignal(0, obj->metaObject()->indexOfMethod("deleteLater()")), false); + QCOMPARE(prop.connectNotifySignal(obj, obj->metaObject()->indexOfMethod("deleteLater()")), false); + QCOMPARE(prop.connectNotifySignal(obj, -1), false); + QVERIFY(prop.method().signature() == 0); + QCOMPARE(prop.type(), QQmlProperty::Invalid); + QCOMPARE(prop.isProperty(), false); + QCOMPARE(prop.isWritable(), false); + QCOMPARE(prop.isDesignable(), false); + QCOMPARE(prop.isResettable(), false); + QCOMPARE(prop.isSignalProperty(), false); + QCOMPARE(prop.isValid(), false); + QCOMPARE(prop.object(), (QObject *)0); + QCOMPARE(prop.propertyTypeCategory(), QQmlProperty::InvalidCategory); + QCOMPARE(prop.propertyType(), 0); + QCOMPARE(prop.propertyTypeName(), (const char *)0); + QVERIFY(prop.property().name() == 0); + QVERIFY(QQmlPropertyPrivate::binding(prop) == 0); + QVERIFY(QQmlPropertyPrivate::setBinding(prop, binding.data()) == 0); + QVERIFY(binding == 0); + QVERIFY(QQmlPropertyPrivate::signalExpression(prop) == 0); + QVERIFY(QQmlPropertyPrivate::setSignalExpression(prop, expression.data()) == 0); + QVERIFY(expression == 0); + QCOMPARE(prop.index(), -1); + QCOMPARE(QQmlPropertyPrivate::valueTypeCoreIndex(prop), -1); + + delete obj; + } + + { + QQmlProperty prop(&dobject, engine.rootContext()); + + QWeakPointer binding(new QQmlBinding(QLatin1String("null"), 0, engine.rootContext())); + binding.data()->setTarget(prop); + QVERIFY(binding != 0); + QWeakPointer expression(new QQmlExpression()); + QVERIFY(expression != 0); + + QObject *obj = new QObject; + + QCOMPARE(prop.name(), QString("defaultProperty")); + QCOMPARE(prop.read(), QVariant(10)); + QCOMPARE(prop.write(QVariant()), false); + QCOMPARE(prop.hasNotifySignal(), false); + QCOMPARE(prop.needsNotifySignal(), true); + QCOMPARE(prop.connectNotifySignal(0, SLOT(deleteLater())), false); + QCOMPARE(prop.connectNotifySignal(obj, SLOT(deleteLater())), false); + QCOMPARE(prop.connectNotifySignal(obj, 0), false); + QCOMPARE(prop.connectNotifySignal(0, obj->metaObject()->indexOfMethod("deleteLater()")), false); + QCOMPARE(prop.connectNotifySignal(obj, obj->metaObject()->indexOfMethod("deleteLater()")), false); + QCOMPARE(prop.connectNotifySignal(obj, -1), false); + QVERIFY(prop.method().signature() == 0); + QCOMPARE(prop.type(), QQmlProperty::Property); + QCOMPARE(prop.isProperty(), true); + QCOMPARE(prop.isWritable(), false); + QCOMPARE(prop.isDesignable(), true); + QCOMPARE(prop.isResettable(), false); + QCOMPARE(prop.isSignalProperty(), false); + QCOMPARE(prop.isValid(), true); + QCOMPARE(prop.object(), qobject_cast(&dobject)); + QCOMPARE(prop.propertyTypeCategory(), QQmlProperty::Normal); + QCOMPARE(prop.propertyType(), (int)QVariant::Int); + QCOMPARE(prop.propertyTypeName(), "int"); + QCOMPARE(QString(prop.property().name()), QString("defaultProperty")); + QVERIFY(QQmlPropertyPrivate::binding(prop) == 0); + QTest::ignoreMessage(QtWarningMsg, ": Unable to assign null to int"); + QVERIFY(QQmlPropertyPrivate::setBinding(prop, binding.data()) == 0); + QVERIFY(binding != 0); + QVERIFY(QQmlPropertyPrivate::binding(prop) == binding.data()); + QVERIFY(QQmlPropertyPrivate::signalExpression(prop) == 0); + QVERIFY(QQmlPropertyPrivate::setSignalExpression(prop, expression.data()) == 0); + QVERIFY(expression == 0); + QCOMPARE(prop.index(), dobject.metaObject()->indexOfProperty("defaultProperty")); + QCOMPARE(QQmlPropertyPrivate::valueTypeCoreIndex(prop), -1); + + delete obj; + } +} + +void tst_qqmlproperty::qmlmetaproperty_object_string_context() +{ + QObject object; + PropertyObject dobject; + + { + QQmlProperty prop(&object, QString("defaultProperty"), engine.rootContext()); + + QWeakPointer binding(new QQmlBinding(QLatin1String("null"), 0, engine.rootContext())); + QVERIFY(binding != 0); + QWeakPointer expression(new QQmlExpression()); + QVERIFY(expression != 0); + + QObject *obj = new QObject; + + QCOMPARE(prop.name(), QString()); + QCOMPARE(prop.read(), QVariant()); + QCOMPARE(prop.write(QVariant()), false); + QCOMPARE(prop.hasNotifySignal(), false); + QCOMPARE(prop.needsNotifySignal(), false); + QCOMPARE(prop.connectNotifySignal(0, SLOT(deleteLater())), false); + QCOMPARE(prop.connectNotifySignal(obj, SLOT(deleteLater())), false); + QCOMPARE(prop.connectNotifySignal(obj, 0), false); + QCOMPARE(prop.connectNotifySignal(0, obj->metaObject()->indexOfMethod("deleteLater()")), false); + QCOMPARE(prop.connectNotifySignal(obj, obj->metaObject()->indexOfMethod("deleteLater()")), false); + QCOMPARE(prop.connectNotifySignal(obj, -1), false); + QVERIFY(prop.method().signature() == 0); + QCOMPARE(prop.type(), QQmlProperty::Invalid); + QCOMPARE(prop.isProperty(), false); + QCOMPARE(prop.isWritable(), false); + QCOMPARE(prop.isDesignable(), false); + QCOMPARE(prop.isResettable(), false); + QCOMPARE(prop.isSignalProperty(), false); + QCOMPARE(prop.isValid(), false); + QCOMPARE(prop.object(), (QObject *)0); + QCOMPARE(prop.propertyTypeCategory(), QQmlProperty::InvalidCategory); + QCOMPARE(prop.propertyType(), 0); + QCOMPARE(prop.propertyTypeName(), (const char *)0); + QVERIFY(prop.property().name() == 0); + QVERIFY(QQmlPropertyPrivate::binding(prop) == 0); + QVERIFY(QQmlPropertyPrivate::setBinding(prop, binding.data()) == 0); + QVERIFY(binding == 0); + QVERIFY(QQmlPropertyPrivate::signalExpression(prop) == 0); + QVERIFY(QQmlPropertyPrivate::setSignalExpression(prop, expression.data()) == 0); + QVERIFY(expression == 0); + QCOMPARE(prop.index(), -1); + QCOMPARE(QQmlPropertyPrivate::valueTypeCoreIndex(prop), -1); + + delete obj; + } + + { + QQmlProperty prop(&dobject, QString("defaultProperty"), engine.rootContext()); + + QWeakPointer binding(new QQmlBinding(QLatin1String("null"), 0, engine.rootContext())); + binding.data()->setTarget(prop); + QVERIFY(binding != 0); + QWeakPointer expression(new QQmlExpression()); + QVERIFY(expression != 0); + + QObject *obj = new QObject; + + QCOMPARE(prop.name(), QString("defaultProperty")); + QCOMPARE(prop.read(), QVariant(10)); + QCOMPARE(prop.write(QVariant()), false); + QCOMPARE(prop.hasNotifySignal(), false); + QCOMPARE(prop.needsNotifySignal(), true); + QCOMPARE(prop.connectNotifySignal(0, SLOT(deleteLater())), false); + QCOMPARE(prop.connectNotifySignal(obj, SLOT(deleteLater())), false); + QCOMPARE(prop.connectNotifySignal(obj, 0), false); + QCOMPARE(prop.connectNotifySignal(0, obj->metaObject()->indexOfMethod("deleteLater()")), false); + QCOMPARE(prop.connectNotifySignal(obj, obj->metaObject()->indexOfMethod("deleteLater()")), false); + QCOMPARE(prop.connectNotifySignal(obj, -1), false); + QVERIFY(prop.method().signature() == 0); + QCOMPARE(prop.type(), QQmlProperty::Property); + QCOMPARE(prop.isProperty(), true); + QCOMPARE(prop.isWritable(), false); + QCOMPARE(prop.isDesignable(), true); + QCOMPARE(prop.isResettable(), false); + QCOMPARE(prop.isSignalProperty(), false); + QCOMPARE(prop.isValid(), true); + QCOMPARE(prop.object(), qobject_cast(&dobject)); + QCOMPARE(prop.propertyTypeCategory(), QQmlProperty::Normal); + QCOMPARE(prop.propertyType(), (int)QVariant::Int); + QCOMPARE(prop.propertyTypeName(), "int"); + QCOMPARE(QString(prop.property().name()), QString("defaultProperty")); + QVERIFY(QQmlPropertyPrivate::binding(prop) == 0); + QTest::ignoreMessage(QtWarningMsg, ": Unable to assign null to int"); + QVERIFY(QQmlPropertyPrivate::setBinding(prop, binding.data()) == 0); + QVERIFY(binding != 0); + QVERIFY(QQmlPropertyPrivate::binding(prop) == binding.data()); + QVERIFY(QQmlPropertyPrivate::signalExpression(prop) == 0); + QVERIFY(QQmlPropertyPrivate::setSignalExpression(prop, expression.data()) == 0); + QVERIFY(expression == 0); + QCOMPARE(prop.index(), dobject.metaObject()->indexOfProperty("defaultProperty")); + QCOMPARE(QQmlPropertyPrivate::valueTypeCoreIndex(prop), -1); + + delete obj; + } + + { + QQmlProperty prop(&dobject, QString("onClicked"), engine.rootContext()); + + QWeakPointer binding(new QQmlBinding(QLatin1String("null"), 0, engine.rootContext())); + binding.data()->setTarget(prop); + QVERIFY(binding != 0); + QWeakPointer expression(new QQmlExpression()); + QVERIFY(expression != 0); + + QObject *obj = new QObject; + + QCOMPARE(prop.name(), QString("onClicked")); + QCOMPARE(prop.read(), QVariant()); + QCOMPARE(prop.write(QVariant("Hello")), false); + QCOMPARE(prop.hasNotifySignal(), false); + QCOMPARE(prop.needsNotifySignal(), false); + QCOMPARE(prop.connectNotifySignal(0, SLOT(deleteLater())), false); + QCOMPARE(prop.connectNotifySignal(obj, SLOT(deleteLater())), false); + QCOMPARE(prop.connectNotifySignal(obj, 0), false); + QCOMPARE(prop.connectNotifySignal(0, obj->metaObject()->indexOfMethod("deleteLater()")), false); + QCOMPARE(prop.connectNotifySignal(obj, obj->metaObject()->indexOfMethod("deleteLater()")), false); + QCOMPARE(prop.connectNotifySignal(obj, -1), false); + QCOMPARE(QString(prop.method().signature()), QString("clicked()")); + QCOMPARE(prop.type(), QQmlProperty::SignalProperty); + QCOMPARE(prop.isProperty(), false); + QCOMPARE(prop.isWritable(), false); + QCOMPARE(prop.isDesignable(), false); + QCOMPARE(prop.isResettable(), false); + QCOMPARE(prop.isSignalProperty(), true); + QCOMPARE(prop.isValid(), true); + QCOMPARE(prop.object(), qobject_cast(&dobject)); + QCOMPARE(prop.propertyTypeCategory(), QQmlProperty::InvalidCategory); + QCOMPARE(prop.propertyType(), 0); + QCOMPARE(prop.propertyTypeName(), (const char *)0); + QCOMPARE(prop.property().name(), (const char *)0); + QVERIFY(QQmlPropertyPrivate::binding(prop) == 0); + QVERIFY(QQmlPropertyPrivate::setBinding(prop, binding.data()) == 0); + QVERIFY(binding == 0); + QVERIFY(QQmlPropertyPrivate::signalExpression(prop) == 0); + QVERIFY(QQmlPropertyPrivate::setSignalExpression(prop, expression.data()) == 0); + QVERIFY(expression != 0); + QVERIFY(QQmlPropertyPrivate::signalExpression(prop) == expression.data()); + QCOMPARE(prop.index(), dobject.metaObject()->indexOfMethod("clicked()")); + QCOMPARE(QQmlPropertyPrivate::valueTypeCoreIndex(prop), -1); + + delete obj; + } + + { + QQmlProperty prop(&dobject, QString("onPropertyWithNotifyChanged"), engine.rootContext()); + + QWeakPointer binding(new QQmlBinding(QLatin1String("null"), 0, engine.rootContext())); + binding.data()->setTarget(prop); + QVERIFY(binding != 0); + QWeakPointer expression(new QQmlExpression()); + QVERIFY(expression != 0); + + QObject *obj = new QObject; + + QCOMPARE(prop.name(), QString("onOddlyNamedNotifySignal")); + QCOMPARE(prop.read(), QVariant()); + QCOMPARE(prop.write(QVariant("Hello")), false); + QCOMPARE(prop.hasNotifySignal(), false); + QCOMPARE(prop.needsNotifySignal(), false); + QCOMPARE(prop.connectNotifySignal(0, SLOT(deleteLater())), false); + QCOMPARE(prop.connectNotifySignal(obj, SLOT(deleteLater())), false); + QCOMPARE(prop.connectNotifySignal(obj, 0), false); + QCOMPARE(prop.connectNotifySignal(0, obj->metaObject()->indexOfMethod("deleteLater()")), false); + QCOMPARE(prop.connectNotifySignal(obj, obj->metaObject()->indexOfMethod("deleteLater()")), false); + QCOMPARE(prop.connectNotifySignal(obj, -1), false); + QCOMPARE(QString(prop.method().signature()), QString("oddlyNamedNotifySignal()")); + QCOMPARE(prop.type(), QQmlProperty::SignalProperty); + QCOMPARE(prop.isProperty(), false); + QCOMPARE(prop.isWritable(), false); + QCOMPARE(prop.isDesignable(), false); + QCOMPARE(prop.isResettable(), false); + QCOMPARE(prop.isSignalProperty(), true); + QCOMPARE(prop.isValid(), true); + QCOMPARE(prop.object(), qobject_cast(&dobject)); + QCOMPARE(prop.propertyTypeCategory(), QQmlProperty::InvalidCategory); + QCOMPARE(prop.propertyType(), 0); + QCOMPARE(prop.propertyTypeName(), (const char *)0); + QCOMPARE(prop.property().name(), (const char *)0); + QVERIFY(QQmlPropertyPrivate::binding(prop) == 0); + QVERIFY(QQmlPropertyPrivate::setBinding(prop, binding.data()) == 0); + QVERIFY(binding == 0); + QVERIFY(QQmlPropertyPrivate::signalExpression(prop) == 0); + QVERIFY(QQmlPropertyPrivate::setSignalExpression(prop, expression.data()) == 0); + QVERIFY(expression != 0); + QVERIFY(QQmlPropertyPrivate::signalExpression(prop) == expression.data()); + QCOMPARE(prop.index(), dobject.metaObject()->indexOfMethod("oddlyNamedNotifySignal()")); + QCOMPARE(QQmlPropertyPrivate::valueTypeCoreIndex(prop), -1); + + delete obj; + } +} + +void tst_qqmlproperty::name() +{ + { + QQmlProperty p; + QCOMPARE(p.name(), QString()); + } + + { + PropertyObject o; + QQmlProperty p(&o); + QCOMPARE(p.name(), QString("defaultProperty")); + } + + { + QObject o; + QQmlProperty p(&o, QString("objectName")); + QCOMPARE(p.name(), QString("objectName")); + } + + { + PropertyObject o; + QQmlProperty p(&o, "onClicked"); + QCOMPARE(p.name(), QString("onClicked")); + } + + { + QObject o; + QQmlProperty p(&o, "onClicked"); + QCOMPARE(p.name(), QString()); + } + + { + PropertyObject o; + QQmlProperty p(&o, "onPropertyWithNotifyChanged"); + QCOMPARE(p.name(), QString("onOddlyNamedNotifySignal")); + } + + { + QObject o; + QQmlProperty p(&o, "onPropertyWithNotifyChanged"); + QCOMPARE(p.name(), QString()); + } + + { + QObject o; + QQmlProperty p(&o, "foo"); + QCOMPARE(p.name(), QString()); + } + + { + QQmlProperty p(0, "foo"); + QCOMPARE(p.name(), QString()); + } + + { + PropertyObject o; + QQmlProperty p(&o, "rectProperty"); + QCOMPARE(p.name(), QString("rectProperty")); + } + + { + PropertyObject o; + QQmlProperty p(&o, "rectProperty.x"); + QCOMPARE(p.name(), QString("rectProperty.x")); + } + + { + PropertyObject o; + QQmlProperty p(&o, "rectProperty.foo"); + QCOMPARE(p.name(), QString()); + } +} + +void tst_qqmlproperty::read() +{ + // Invalid + { + QQmlProperty p; + QCOMPARE(p.read(), QVariant()); + } + + // Default prop + { + PropertyObject o; + QQmlProperty p(&o); + QCOMPARE(p.read(), QVariant(10)); + } + + // Invalid default prop + { + QObject o; + QQmlProperty p(&o); + QCOMPARE(p.read(), QVariant()); + } + + // Value prop by name + { + QObject o; + + QQmlProperty p(&o, "objectName"); + QCOMPARE(p.read(), QVariant(QString())); + + o.setObjectName("myName"); + + QCOMPARE(p.read(), QVariant("myName")); + } + + // Value prop by name (static) + { + QObject o; + + QCOMPARE(QQmlProperty::read(&o, "objectName"), QVariant(QString())); + + o.setObjectName("myName"); + + QCOMPARE(QQmlProperty::read(&o, "objectName"), QVariant("myName")); + } + + // Value-type prop + { + PropertyObject o; + QQmlProperty p(&o, "rectProperty.x"); + QCOMPARE(p.read(), QVariant(10)); + } + + // Invalid value-type prop + { + PropertyObject o; + QQmlProperty p(&o, "rectProperty.foo"); + QCOMPARE(p.read(), QVariant()); + } + + // Signal property + { + PropertyObject o; + QQmlProperty p(&o, "onClicked"); + QCOMPARE(p.read(), QVariant()); + + QVERIFY(0 == QQmlPropertyPrivate::setSignalExpression(p, new QQmlExpression())); + QVERIFY(0 != QQmlPropertyPrivate::signalExpression(p)); + + QCOMPARE(p.read(), QVariant()); + } + + // Automatic signal property + { + PropertyObject o; + QQmlProperty p(&o, "onPropertyWithNotifyChanged"); + QCOMPARE(p.read(), QVariant()); + + QVERIFY(0 == QQmlPropertyPrivate::setSignalExpression(p, new QQmlExpression())); + QVERIFY(0 != QQmlPropertyPrivate::signalExpression(p)); + + QCOMPARE(p.read(), QVariant()); + } + + // Deleted object + { + PropertyObject *o = new PropertyObject; + QQmlProperty p(o, "rectProperty.x"); + QCOMPARE(p.read(), QVariant(10)); + delete o; + QCOMPARE(p.read(), QVariant()); + } + + // Object property + { + PropertyObject o; + QQmlProperty p(&o, "qmlObject"); + QCOMPARE(p.propertyTypeCategory(), QQmlProperty::Object); + QCOMPARE(p.propertyType(), qMetaTypeId()); + QVariant v = p.read(); + QVERIFY(v.userType() == QMetaType::QObjectStar); + QVERIFY(qvariant_cast(v) == o.qmlObject()); + } + { + QQmlComponent component(&engine, testFileUrl("readSynthesizedObject.qml")); + QObject *object = component.create(); + QVERIFY(object != 0); + + QQmlProperty p(object, "test", &engine); + + QCOMPARE(p.propertyTypeCategory(), QQmlProperty::Object); + QVERIFY(p.propertyType() != QMetaType::QObjectStar); + + QVariant v = p.read(); + QVERIFY(v.userType() == QMetaType::QObjectStar); + QCOMPARE(qvariant_cast(v)->property("a").toInt(), 10); + QCOMPARE(qvariant_cast(v)->property("b").toInt(), 19); + } + { // static + QQmlComponent component(&engine, testFileUrl("readSynthesizedObject.qml")); + QObject *object = component.create(); + QVERIFY(object != 0); + + QVariant v = QQmlProperty::read(object, "test", &engine); + QVERIFY(v.userType() == QMetaType::QObjectStar); + QCOMPARE(qvariant_cast(v)->property("a").toInt(), 10); + QCOMPARE(qvariant_cast(v)->property("b").toInt(), 19); + } + + // Attached property + { + QQmlComponent component(&engine); + component.setData("import Test 1.0\nMyContainer { }", QUrl()); + QObject *object = component.create(); + QVERIFY(object != 0); + + QQmlProperty p(object, "MyContainer.foo", qmlContext(object)); + QCOMPARE(p.read(), QVariant(13)); + delete object; + } + { + QQmlComponent component(&engine); + component.setData("import Test 1.0\nMyContainer { MyContainer.foo: 10 }", QUrl()); + QObject *object = component.create(); + QVERIFY(object != 0); + + QQmlProperty p(object, "MyContainer.foo", qmlContext(object)); + QCOMPARE(p.read(), QVariant(10)); + delete object; + } + { + QQmlComponent component(&engine); + component.setData("import Test 1.0 as Foo\nFoo.MyContainer { Foo.MyContainer.foo: 10 }", QUrl()); + QObject *object = component.create(); + QVERIFY(object != 0); + + QQmlProperty p(object, "Foo.MyContainer.foo", qmlContext(object)); + QCOMPARE(p.read(), QVariant(10)); + delete object; + } + { // static + QQmlComponent component(&engine); + component.setData("import Test 1.0 as Foo\nFoo.MyContainer { Foo.MyContainer.foo: 10 }", QUrl()); + QObject *object = component.create(); + QVERIFY(object != 0); + + QCOMPARE(QQmlProperty::read(object, "Foo.MyContainer.foo", qmlContext(object)), QVariant(10)); + delete object; + } +} + +void tst_qqmlproperty::write() +{ + // Invalid + { + QQmlProperty p; + QCOMPARE(p.write(QVariant(10)), false); + } + + // Read-only default prop + { + PropertyObject o; + QQmlProperty p(&o); + QCOMPARE(p.write(QVariant(10)), false); + } + + // Invalid default prop + { + QObject o; + QQmlProperty p(&o); + QCOMPARE(p.write(QVariant(10)), false); + } + + // Read-only prop by name + { + PropertyObject o; + QQmlProperty p(&o, QString("defaultProperty")); + QCOMPARE(p.write(QVariant(10)), false); + } + + // Writable prop by name + { + PropertyObject o; + QQmlProperty p(&o, QString("objectName")); + QCOMPARE(o.objectName(), QString()); + QCOMPARE(p.write(QVariant(QString("myName"))), true); + QCOMPARE(o.objectName(), QString("myName")); + } + + // Writable prop by name (static) + { + PropertyObject o; + QCOMPARE(QQmlProperty::write(&o, QString("objectName"), QVariant(QString("myName"))), true); + QCOMPARE(o.objectName(), QString("myName")); + } + + // Deleted object + { + PropertyObject *o = new PropertyObject; + QQmlProperty p(o, QString("objectName")); + QCOMPARE(p.write(QVariant(QString("myName"))), true); + QCOMPARE(o->objectName(), QString("myName")); + + delete o; + + QCOMPARE(p.write(QVariant(QString("myName"))), false); + } + + // Signal property + { + PropertyObject o; + QQmlProperty p(&o, "onClicked"); + QCOMPARE(p.write(QVariant("console.log(1921)")), false); + + QVERIFY(0 == QQmlPropertyPrivate::setSignalExpression(p, new QQmlExpression())); + QVERIFY(0 != QQmlPropertyPrivate::signalExpression(p)); + + QCOMPARE(p.write(QVariant("console.log(1921)")), false); + + QVERIFY(0 != QQmlPropertyPrivate::signalExpression(p)); + } + + // Automatic signal property + { + PropertyObject o; + QQmlProperty p(&o, "onPropertyWithNotifyChanged"); + QCOMPARE(p.write(QVariant("console.log(1921)")), false); + + QVERIFY(0 == QQmlPropertyPrivate::setSignalExpression(p, new QQmlExpression())); + QVERIFY(0 != QQmlPropertyPrivate::signalExpression(p)); + + QCOMPARE(p.write(QVariant("console.log(1921)")), false); + + QVERIFY(0 != QQmlPropertyPrivate::signalExpression(p)); + } + + // Value-type property + { + PropertyObject o; + QQmlProperty p(&o, "wrectProperty"); + + QCOMPARE(o.wrectProperty(), QRect()); + QCOMPARE(p.write(QRect(1, 13, 99, 8)), true); + QCOMPARE(o.wrectProperty(), QRect(1, 13, 99, 8)); + + QQmlProperty p2(&o, "wrectProperty.x"); + QCOMPARE(p2.read(), QVariant(1)); + QCOMPARE(p2.write(QVariant(6)), true); + QCOMPARE(p2.read(), QVariant(6)); + QCOMPARE(o.wrectProperty(), QRect(6, 13, 99, 8)); + } + + // URL-property + { + PropertyObject o; + QQmlProperty p(&o, "url"); + + QCOMPARE(p.write(QUrl("main.qml")), true); + QCOMPARE(o.url(), QUrl("main.qml")); + + QQmlProperty p2(&o, "url", engine.rootContext()); + + QUrl result = engine.baseUrl().resolved(QUrl("main.qml")); + QVERIFY(result != QUrl("main.qml")); + + QCOMPARE(p2.write(QUrl("main.qml")), true); + QCOMPARE(o.url(), result); + } + { // static + PropertyObject o; + + QCOMPARE(QQmlProperty::write(&o, "url", QUrl("main.qml")), true); + QCOMPARE(o.url(), QUrl("main.qml")); + + QUrl result = engine.baseUrl().resolved(QUrl("main.qml")); + QVERIFY(result != QUrl("main.qml")); + + QCOMPARE(QQmlProperty::write(&o, "url", QUrl("main.qml"), engine.rootContext()), true); + QCOMPARE(o.url(), result); + } + + // VariantMap-property + QVariantMap vm; + vm.insert("key", "value"); + + { + PropertyObject o; + QQmlProperty p(&o, "variantMap"); + + QCOMPARE(p.write(vm), true); + QCOMPARE(o.variantMap(), vm); + + QQmlProperty p2(&o, "variantMap", engine.rootContext()); + + QCOMPARE(p2.write(vm), true); + QCOMPARE(o.variantMap(), vm); + } + { // static + PropertyObject o; + + QCOMPARE(QQmlProperty::write(&o, "variantMap", vm), true); + QCOMPARE(o.variantMap(), vm); + + QCOMPARE(QQmlProperty::write(&o, "variantMap", vm, engine.rootContext()), true); + QCOMPARE(o.variantMap(), vm); + } + + // Attached property + { + QQmlComponent component(&engine); + component.setData("import Test 1.0\nMyContainer { }", QUrl()); + QObject *object = component.create(); + QVERIFY(object != 0); + + QQmlProperty p(object, "MyContainer.foo", qmlContext(object)); + p.write(QVariant(99)); + QCOMPARE(p.read(), QVariant(99)); + delete object; + } + { + QQmlComponent component(&engine); + component.setData("import Test 1.0 as Foo\nFoo.MyContainer { Foo.MyContainer.foo: 10 }", QUrl()); + QObject *object = component.create(); + QVERIFY(object != 0); + + QQmlProperty p(object, "Foo.MyContainer.foo", qmlContext(object)); + p.write(QVariant(99)); + QCOMPARE(p.read(), QVariant(99)); + delete object; + } +} + +void tst_qqmlproperty::reset() +{ + // Invalid + { + QQmlProperty p; + QCOMPARE(p.isResettable(), false); + QCOMPARE(p.reset(), false); + } + + // Read-only default prop + { + PropertyObject o; + QQmlProperty p(&o); + QCOMPARE(p.isResettable(), false); + QCOMPARE(p.reset(), false); + } + + // Invalid default prop + { + QObject o; + QQmlProperty p(&o); + QCOMPARE(p.isResettable(), false); + QCOMPARE(p.reset(), false); + } + + // Non-resettable-only prop by name + { + PropertyObject o; + QQmlProperty p(&o, QString("defaultProperty")); + QCOMPARE(p.isResettable(), false); + QCOMPARE(p.reset(), false); + } + + // Resettable prop by name + { + PropertyObject o; + QQmlProperty p(&o, QString("resettableProperty")); + + QCOMPARE(p.read(), QVariant(9)); + QCOMPARE(p.write(QVariant(11)), true); + QCOMPARE(p.read(), QVariant(11)); + + QCOMPARE(p.isResettable(), true); + QCOMPARE(p.reset(), true); + + QCOMPARE(p.read(), QVariant(9)); + } + + // Deleted object + { + PropertyObject *o = new PropertyObject; + + QQmlProperty p(o, QString("resettableProperty")); + + QCOMPARE(p.isResettable(), true); + QCOMPARE(p.reset(), true); + + delete o; + + QCOMPARE(p.isResettable(), false); + QCOMPARE(p.reset(), false); + } + + // Signal property + { + PropertyObject o; + QQmlProperty p(&o, "onClicked"); + + QCOMPARE(p.isResettable(), false); + QCOMPARE(p.reset(), false); + } + + // Automatic signal property + { + PropertyObject o; + QQmlProperty p(&o, "onPropertyWithNotifyChanged"); + + QCOMPARE(p.isResettable(), false); + QCOMPARE(p.reset(), false); + } +} + +void tst_qqmlproperty::writeObjectToList() +{ + QQmlComponent containerComponent(&engine); + containerComponent.setData("import Test 1.0\nMyContainer { children: MyQmlObject {} }", QUrl()); + MyContainer *container = qobject_cast(containerComponent.create()); + QVERIFY(container != 0); + QQmlListReference list(container, "children"); + QVERIFY(list.count() == 1); + + MyQmlObject *object = new MyQmlObject; + QQmlProperty prop(container, "children"); + prop.write(qVariantFromValue(object)); + QCOMPARE(list.count(), 1); + QCOMPARE(list.at(0), qobject_cast(object)); +} + +void tst_qqmlproperty::writeListToList() +{ + QQmlComponent containerComponent(&engine); + containerComponent.setData("import Test 1.0\nMyContainer { children: MyQmlObject {} }", QUrl()); + MyContainer *container = qobject_cast(containerComponent.create()); + QVERIFY(container != 0); + QQmlListReference list(container, "children"); + QVERIFY(list.count() == 1); + + QList objList; + objList << new MyQmlObject() << new MyQmlObject() << new MyQmlObject() << new MyQmlObject(); + QQmlProperty prop(container, "children"); + prop.write(qVariantFromValue(objList)); + QCOMPARE(list.count(), 4); + + //XXX need to try this with read/write prop (for read-only it correctly doesn't write) + /*QList typedObjList; + typedObjList << new MyQmlObject(); + prop.write(qVariantFromValue(&typedObjList)); + QCOMPARE(container->children()->size(), 1);*/ +} + +void tst_qqmlproperty::urlHandling_data() +{ + QTest::addColumn("input"); + QTest::addColumn("scheme"); + QTest::addColumn("path"); + QTest::addColumn("encoded"); + + QTest::newRow("unspecifiedFile") + << QByteArray("main.qml") + << QString("") + << QString("main.qml") + << QByteArray("main.qml"); + + QTest::newRow("specifiedFile") + << QByteArray("file:///main.qml") + << QString("file") + << QString("/main.qml") + << QByteArray("file:///main.qml"); + + QTest::newRow("httpFile") + << QByteArray("http://www.example.com/main.qml") + << QString("http") + << QString("/main.qml") + << QByteArray("http://www.example.com/main.qml"); + + QTest::newRow("pathFile") + << QByteArray("http://www.example.com/resources/main.qml") + << QString("http") + << QString("/resources/main.qml") + << QByteArray("http://www.example.com/resources/main.qml"); + + QTest::newRow("encodableName") + << QByteArray("http://www.example.com/main file.qml") + << QString("http") + << QString("/main file.qml") + << QByteArray("http://www.example.com/main%20file.qml"); + + QTest::newRow("preencodedName") + << QByteArray("http://www.example.com/resources%7cmain%20file.qml") + << QString("http") + << QString("/resources|main file.qml") + << QByteArray("http://www.example.com/resources%7cmain%20file.qml"); + + QTest::newRow("encodableQuery") + << QByteArray("http://www.example.com/main.qml?type=text/qml&comment=now working?") + << QString("http") + << QString("/main.qml") + << QByteArray("http://www.example.com/main.qml?type=text/qml&comment=now%20working?"); + + QTest::newRow("preencodedQuery") + << QByteArray("http://www.example.com/main.qml?type=text%2fqml&comment=now working%3f") + << QString("http") + << QString("/main.qml") + << QByteArray("http://www.example.com/main.qml?type=text%2fqml&comment=now%20working%3f"); + + QTest::newRow("encodableFragment") + << QByteArray("http://www.example.com/main.qml?type=text/qml#start+30000|volume+50%") + << QString("http") + << QString("/main.qml") + << QByteArray("http://www.example.com/main.qml?type=text/qml#start+30000%7Cvolume+50%25"); + + QTest::newRow("preencodedFragment") + << QByteArray("http://www.example.com/main.qml?type=text/qml#start+30000%7cvolume%2b50%") + << QString("http") + << QString("/main.qml") + << QByteArray("http://www.example.com/main.qml?type=text/qml#start+30000%7cvolume%2b50%25"); +} + +void tst_qqmlproperty::urlHandling() +{ + QFETCH(QByteArray, input); + QFETCH(QString, scheme); + QFETCH(QString, path); + QFETCH(QByteArray, encoded); + + QString inputString(QString::fromUtf8(input)); + + { + PropertyObject o; + QQmlProperty p(&o, "url"); + + // Test url written as QByteArray + QCOMPARE(p.write(input), true); + QUrl byteArrayResult(o.url()); + + QCOMPARE(byteArrayResult.scheme(), scheme); + QCOMPARE(byteArrayResult.path(), path); + QCOMPARE(byteArrayResult.toEncoded(), encoded); + } + + { + PropertyObject o; + QQmlProperty p(&o, "url"); + + // Test url written as QString + QCOMPARE(p.write(inputString), true); + QUrl stringResult(o.url()); + + QCOMPARE(stringResult.scheme(), scheme); + QCOMPARE(stringResult.path(), path); + QCOMPARE(stringResult.toEncoded(), encoded); + } +} + +void tst_qqmlproperty::variantMapHandling_data() +{ + QTest::addColumn("vm"); + + // Object literals + { + QVariantMap m; + QTest::newRow("{}") << m; + } + { + QVariantMap m; + m["a"] = QVariantMap(); + QTest::newRow("{ a:{} }") << m; + } + { + QVariantMap m, m2; + m2["b"] = 10; + m2["c"] = 20; + m["a"] = m2; + QTest::newRow("{ a:{b:10, c:20} }") << m; + } + { + QVariantMap m; + m["a"] = 10; + m["b"] = QVariantList() << 20 << 30; + QTest::newRow("{ a:10, b:[20, 30]}") << m; + } + + // Cyclic objects + { + QVariantMap m; + m["p"] = QVariantMap(); + QTest::newRow("var o={}; o.p=o") << m; + } + { + QVariantMap m; + m["p"] = 123; + m["q"] = QVariantMap(); + QTest::newRow("var o={}; o.p=123; o.q=o") << m; + } +} + +void tst_qqmlproperty::variantMapHandling() +{ + QFETCH(QVariantMap, vm); + + PropertyObject o; + QQmlProperty p(&o, "variantMap"); + + QCOMPARE(p.write(vm), true); + QCOMPARE(o.variantMap(), vm); +} + +void tst_qqmlproperty::crashOnValueProperty() +{ + QQmlEngine *engine = new QQmlEngine; + QQmlComponent component(engine); + + component.setData("import Test 1.0\nPropertyObject { wrectProperty.x: 10 }", QUrl()); + PropertyObject *obj = qobject_cast(component.create()); + QVERIFY(obj != 0); + + QQmlProperty p(obj, "wrectProperty.x", qmlContext(obj)); + QCOMPARE(p.name(), QString("wrectProperty.x")); + + QCOMPARE(p.read(), QVariant(10)); + + //don't crash once the engine is deleted + delete engine; + engine = 0; + + QCOMPARE(p.propertyTypeName(), "int"); + QCOMPARE(p.read(), QVariant(10)); + p.write(QVariant(20)); + QCOMPARE(p.read(), QVariant(20)); +} + +// QTBUG-13719 +void tst_qqmlproperty::aliasPropertyBindings() +{ + QQmlComponent component(&engine, testFileUrl("aliasPropertyBindings.qml")); + + QObject *object = component.create(); + QVERIFY(object != 0); + + QCOMPARE(object->property("realProperty").toReal(), 90.); + QCOMPARE(object->property("aliasProperty").toReal(), 90.); + + object->setProperty("test", 10); + + QCOMPARE(object->property("realProperty").toReal(), 110.); + QCOMPARE(object->property("aliasProperty").toReal(), 110.); + + QQmlProperty realProperty(object, QLatin1String("realProperty")); + QQmlProperty aliasProperty(object, QLatin1String("aliasProperty")); + + // Check there is a binding on these two properties + QVERIFY(QQmlPropertyPrivate::binding(realProperty) != 0); + QVERIFY(QQmlPropertyPrivate::binding(aliasProperty) != 0); + + // Check that its the same binding on these two properties + QCOMPARE(QQmlPropertyPrivate::binding(realProperty), + QQmlPropertyPrivate::binding(aliasProperty)); + + // Change the binding + object->setProperty("state", QString("switch")); + + QVERIFY(QQmlPropertyPrivate::binding(realProperty) != 0); + QVERIFY(QQmlPropertyPrivate::binding(aliasProperty) != 0); + QCOMPARE(QQmlPropertyPrivate::binding(realProperty), + QQmlPropertyPrivate::binding(aliasProperty)); + + QCOMPARE(object->property("realProperty").toReal(), 96.); + QCOMPARE(object->property("aliasProperty").toReal(), 96.); + + // Check the old binding really has not effect any more + object->setProperty("test", 4); + + QCOMPARE(object->property("realProperty").toReal(), 96.); + QCOMPARE(object->property("aliasProperty").toReal(), 96.); + + object->setProperty("test2", 9); + + QCOMPARE(object->property("realProperty").toReal(), 288.); + QCOMPARE(object->property("aliasProperty").toReal(), 288.); + + // Revert + object->setProperty("state", QString("")); + + QVERIFY(QQmlPropertyPrivate::binding(realProperty) != 0); + QVERIFY(QQmlPropertyPrivate::binding(aliasProperty) != 0); + QCOMPARE(QQmlPropertyPrivate::binding(realProperty), + QQmlPropertyPrivate::binding(aliasProperty)); + + QCOMPARE(object->property("realProperty").toReal(), 20.); + QCOMPARE(object->property("aliasProperty").toReal(), 20.); + + object->setProperty("test2", 3); + + QCOMPARE(object->property("realProperty").toReal(), 20.); + QCOMPARE(object->property("aliasProperty").toReal(), 20.); + + delete object; +} + +void tst_qqmlproperty::copy() +{ + PropertyObject object; + + QQmlProperty *property = new QQmlProperty(&object, QLatin1String("defaultProperty")); + QCOMPARE(property->name(), QString("defaultProperty")); + QCOMPARE(property->read(), QVariant(10)); + QCOMPARE(property->type(), QQmlProperty::Property); + QCOMPARE(property->propertyTypeCategory(), QQmlProperty::Normal); + QCOMPARE(property->propertyType(), (int)QVariant::Int); + + QQmlProperty p1(*property); + QCOMPARE(p1.name(), QString("defaultProperty")); + QCOMPARE(p1.read(), QVariant(10)); + QCOMPARE(p1.type(), QQmlProperty::Property); + QCOMPARE(p1.propertyTypeCategory(), QQmlProperty::Normal); + QCOMPARE(p1.propertyType(), (int)QVariant::Int); + + QQmlProperty p2(&object, QLatin1String("url")); + QCOMPARE(p2.name(), QString("url")); + p2 = *property; + QCOMPARE(p2.name(), QString("defaultProperty")); + QCOMPARE(p2.read(), QVariant(10)); + QCOMPARE(p2.type(), QQmlProperty::Property); + QCOMPARE(p2.propertyTypeCategory(), QQmlProperty::Normal); + QCOMPARE(p2.propertyType(), (int)QVariant::Int); + + delete property; property = 0; + + QCOMPARE(p1.name(), QString("defaultProperty")); + QCOMPARE(p1.read(), QVariant(10)); + QCOMPARE(p1.type(), QQmlProperty::Property); + QCOMPARE(p1.propertyTypeCategory(), QQmlProperty::Normal); + QCOMPARE(p1.propertyType(), (int)QVariant::Int); + + QCOMPARE(p2.name(), QString("defaultProperty")); + QCOMPARE(p2.read(), QVariant(10)); + QCOMPARE(p2.type(), QQmlProperty::Property); + QCOMPARE(p2.propertyTypeCategory(), QQmlProperty::Normal); + QCOMPARE(p2.propertyType(), (int)QVariant::Int); +} + +void tst_qqmlproperty::noContext() +{ + QQmlComponent compA(&engine, testFileUrl("NoContextTypeA.qml")); + QQmlComponent compB(&engine, testFileUrl("NoContextTypeB.qml")); + + QObject *a = compA.create(); + QVERIFY(a != 0); + QObject *b = compB.create(); + QVERIFY(b != 0); + + QVERIFY(QQmlProperty::write(b, "myTypeA", QVariant::fromValue(a), &engine)); + + delete a; + delete b; +} + +void tst_qqmlproperty::assignEmptyVariantMap() +{ + PropertyObject o; + + QVariantMap map; + map.insert("key", "value"); + o.setVariantMap(map); + QCOMPARE(o.variantMap().count(), 1); + QCOMPARE(o.variantMap().isEmpty(), false); + + QQmlContext context(&engine); + context.setContextProperty("o", &o); + + QQmlComponent component(&engine, testFileUrl("assignEmptyVariantMap.qml")); + QObject *obj = component.create(&context); + QVERIFY(obj); + + QCOMPARE(o.variantMap().count(), 0); + QCOMPARE(o.variantMap().isEmpty(), true); + + delete obj; +} + +void tst_qqmlproperty::initTestCase() +{ + QQmlDataTest::initTestCase(); + qmlRegisterType("Test",1,0,"MyQmlObject"); + qmlRegisterType("Test",1,0,"PropertyObject"); + qmlRegisterType("Test",1,0,"MyContainer"); +} + +QTEST_MAIN(tst_qqmlproperty) + +#include "tst_qqmlproperty.moc" diff --git a/tests/auto/qml/qqmlpropertycache/qqmlpropertycache.pro b/tests/auto/qml/qqmlpropertycache/qqmlpropertycache.pro new file mode 100644 index 0000000000..4beb961895 --- /dev/null +++ b/tests/auto/qml/qqmlpropertycache/qqmlpropertycache.pro @@ -0,0 +1,8 @@ +CONFIG += testcase +TARGET = tst_qqmlpropertycache +macx:CONFIG -= app_bundle + +SOURCES += tst_qqmlpropertycache.cpp + +CONFIG += parallel_test +QT += core-private gui-private qml-private testlib v8-private diff --git a/tests/auto/qml/qqmlpropertycache/tst_qqmlpropertycache.cpp b/tests/auto/qml/qqmlpropertycache/tst_qqmlpropertycache.cpp new file mode 100644 index 0000000000..b702623fee --- /dev/null +++ b/tests/auto/qml/qqmlpropertycache/tst_qqmlpropertycache.cpp @@ -0,0 +1,281 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include +#include +#include "../../shared/util.h" + +class tst_qqmlpropertycache : public QObject +{ + Q_OBJECT +public: + tst_qqmlpropertycache() {} + +private slots: + void properties(); + void propertiesDerived(); + void methods(); + void methodsDerived(); + void signalHandlers(); + void signalHandlersDerived(); + +private: + QQmlEngine engine; +}; + +class BaseObject : public QObject +{ + Q_OBJECT + Q_PROPERTY(int propertyA READ propertyA NOTIFY propertyAChanged) + Q_PROPERTY(QString propertyB READ propertyB NOTIFY propertyBChanged) +public: + BaseObject(QObject *parent = 0) : QObject(parent) {} + + int propertyA() const { return 0; } + QString propertyB() const { return QString(); } + +public Q_SLOTS: + void slotA() {} + +Q_SIGNALS: + void propertyAChanged(); + void propertyBChanged(); + void signalA(); +}; + +class DerivedObject : public BaseObject +{ + Q_OBJECT + Q_PROPERTY(int propertyC READ propertyC NOTIFY propertyCChanged) + Q_PROPERTY(QString propertyD READ propertyD NOTIFY propertyDChanged) +public: + DerivedObject(QObject *parent = 0) : BaseObject(parent) {} + + int propertyC() const { return 0; } + QString propertyD() const { return QString(); } + +public Q_SLOTS: + void slotB() {} + +Q_SIGNALS: + void propertyCChanged(); + void propertyDChanged(); + void signalB(); +}; + +void tst_qqmlpropertycache::properties() +{ + QQmlEngine engine; + DerivedObject object; + const QMetaObject *metaObject = object.metaObject(); + + QQmlRefPointer cache(new QQmlPropertyCache(&engine, metaObject)); + QQmlPropertyData *data; + + QVERIFY(data = cache->property(QLatin1String("propertyA"))); + QCOMPARE(data->coreIndex, metaObject->indexOfProperty("propertyA")); + + QVERIFY(data = cache->property(QLatin1String("propertyB"))); + QCOMPARE(data->coreIndex, metaObject->indexOfProperty("propertyB")); + + QVERIFY(data = cache->property(QLatin1String("propertyC"))); + QCOMPARE(data->coreIndex, metaObject->indexOfProperty("propertyC")); + + QVERIFY(data = cache->property(QLatin1String("propertyD"))); + QCOMPARE(data->coreIndex, metaObject->indexOfProperty("propertyD")); +} + +void tst_qqmlpropertycache::propertiesDerived() +{ + QQmlEngine engine; + DerivedObject object; + const QMetaObject *metaObject = object.metaObject(); + + QQmlRefPointer parentCache(new QQmlPropertyCache(&engine, &BaseObject::staticMetaObject)); + QQmlRefPointer cache(parentCache->copy()); + cache->append(&engine, object.metaObject()); + QQmlPropertyData *data; + + QVERIFY(data = cache->property(QLatin1String("propertyA"))); + QCOMPARE(data->coreIndex, metaObject->indexOfProperty("propertyA")); + + QVERIFY(data = cache->property(QLatin1String("propertyB"))); + QCOMPARE(data->coreIndex, metaObject->indexOfProperty("propertyB")); + + QVERIFY(data = cache->property(QLatin1String("propertyC"))); + QCOMPARE(data->coreIndex, metaObject->indexOfProperty("propertyC")); + + QVERIFY(data = cache->property(QLatin1String("propertyD"))); + QCOMPARE(data->coreIndex, metaObject->indexOfProperty("propertyD")); +} + +void tst_qqmlpropertycache::methods() +{ + QQmlEngine engine; + DerivedObject object; + const QMetaObject *metaObject = object.metaObject(); + + QQmlRefPointer cache(new QQmlPropertyCache(&engine, metaObject)); + QQmlPropertyData *data; + + QVERIFY(data = cache->property(QLatin1String("slotA"))); + QCOMPARE(data->coreIndex, metaObject->indexOfMethod("slotA()")); + + QVERIFY(data = cache->property(QLatin1String("slotB"))); + QCOMPARE(data->coreIndex, metaObject->indexOfMethod("slotB()")); + + QVERIFY(data = cache->property(QLatin1String("signalA"))); + QCOMPARE(data->coreIndex, metaObject->indexOfMethod("signalA()")); + + QVERIFY(data = cache->property(QLatin1String("signalB"))); + QCOMPARE(data->coreIndex, metaObject->indexOfMethod("signalB()")); + + QVERIFY(data = cache->property(QLatin1String("propertyAChanged"))); + QCOMPARE(data->coreIndex, metaObject->indexOfMethod("propertyAChanged()")); + + QVERIFY(data = cache->property(QLatin1String("propertyBChanged"))); + QCOMPARE(data->coreIndex, metaObject->indexOfMethod("propertyBChanged()")); + + QVERIFY(data = cache->property(QLatin1String("propertyCChanged"))); + QCOMPARE(data->coreIndex, metaObject->indexOfMethod("propertyCChanged()")); + + QVERIFY(data = cache->property(QLatin1String("propertyDChanged"))); + QCOMPARE(data->coreIndex, metaObject->indexOfMethod("propertyDChanged()")); +} + +void tst_qqmlpropertycache::methodsDerived() +{ + QQmlEngine engine; + DerivedObject object; + const QMetaObject *metaObject = object.metaObject(); + + QQmlRefPointer parentCache(new QQmlPropertyCache(&engine, &BaseObject::staticMetaObject)); + QQmlRefPointer cache(parentCache->copy()); + cache->append(&engine, object.metaObject()); + QQmlPropertyData *data; + + QVERIFY(data = cache->property(QLatin1String("slotA"))); + QCOMPARE(data->coreIndex, metaObject->indexOfMethod("slotA()")); + + QVERIFY(data = cache->property(QLatin1String("slotB"))); + QCOMPARE(data->coreIndex, metaObject->indexOfMethod("slotB()")); + + QVERIFY(data = cache->property(QLatin1String("signalA"))); + QCOMPARE(data->coreIndex, metaObject->indexOfMethod("signalA()")); + + QVERIFY(data = cache->property(QLatin1String("signalB"))); + QCOMPARE(data->coreIndex, metaObject->indexOfMethod("signalB()")); + + QVERIFY(data = cache->property(QLatin1String("propertyAChanged"))); + QCOMPARE(data->coreIndex, metaObject->indexOfMethod("propertyAChanged()")); + + QVERIFY(data = cache->property(QLatin1String("propertyBChanged"))); + QCOMPARE(data->coreIndex, metaObject->indexOfMethod("propertyBChanged()")); + + QVERIFY(data = cache->property(QLatin1String("propertyCChanged"))); + QCOMPARE(data->coreIndex, metaObject->indexOfMethod("propertyCChanged()")); + + QVERIFY(data = cache->property(QLatin1String("propertyDChanged"))); + QCOMPARE(data->coreIndex, metaObject->indexOfMethod("propertyDChanged()")); +} + +void tst_qqmlpropertycache::signalHandlers() +{ + QQmlEngine engine; + DerivedObject object; + const QMetaObject *metaObject = object.metaObject(); + + QQmlRefPointer cache(new QQmlPropertyCache(&engine, metaObject)); + QQmlPropertyData *data; + + QVERIFY(data = cache->property(QLatin1String("onSignalA"))); + QCOMPARE(data->coreIndex, metaObject->indexOfMethod("signalA()")); + + QVERIFY(data = cache->property(QLatin1String("onSignalB"))); + QCOMPARE(data->coreIndex, metaObject->indexOfMethod("signalB()")); + + QVERIFY(data = cache->property(QLatin1String("onPropertyAChanged"))); + QCOMPARE(data->coreIndex, metaObject->indexOfMethod("propertyAChanged()")); + + QVERIFY(data = cache->property(QLatin1String("onPropertyBChanged"))); + QCOMPARE(data->coreIndex, metaObject->indexOfMethod("propertyBChanged()")); + + QVERIFY(data = cache->property(QLatin1String("onPropertyCChanged"))); + QCOMPARE(data->coreIndex, metaObject->indexOfMethod("propertyCChanged()")); + + QVERIFY(data = cache->property(QLatin1String("onPropertyDChanged"))); + QCOMPARE(data->coreIndex, metaObject->indexOfMethod("propertyDChanged()")); +} + +void tst_qqmlpropertycache::signalHandlersDerived() +{ + QQmlEngine engine; + DerivedObject object; + const QMetaObject *metaObject = object.metaObject(); + + QQmlRefPointer parentCache(new QQmlPropertyCache(&engine, &BaseObject::staticMetaObject)); + QQmlRefPointer cache(parentCache->copy()); + cache->append(&engine, object.metaObject()); + QQmlPropertyData *data; + + QVERIFY(data = cache->property(QLatin1String("onSignalA"))); + QCOMPARE(data->coreIndex, metaObject->indexOfMethod("signalA()")); + + QVERIFY(data = cache->property(QLatin1String("onSignalB"))); + QCOMPARE(data->coreIndex, metaObject->indexOfMethod("signalB()")); + + QVERIFY(data = cache->property(QLatin1String("onPropertyAChanged"))); + QCOMPARE(data->coreIndex, metaObject->indexOfMethod("propertyAChanged()")); + + QVERIFY(data = cache->property(QLatin1String("onPropertyBChanged"))); + QCOMPARE(data->coreIndex, metaObject->indexOfMethod("propertyBChanged()")); + + QVERIFY(data = cache->property(QLatin1String("onPropertyCChanged"))); + QCOMPARE(data->coreIndex, metaObject->indexOfMethod("propertyCChanged()")); + + QVERIFY(data = cache->property(QLatin1String("onPropertyDChanged"))); + QCOMPARE(data->coreIndex, metaObject->indexOfMethod("propertyDChanged()")); +} + +QTEST_MAIN(tst_qqmlpropertycache) + +#include "tst_qqmlpropertycache.moc" diff --git a/tests/auto/qml/qqmlpropertymap/qqmlpropertymap.pro b/tests/auto/qml/qqmlpropertymap/qqmlpropertymap.pro new file mode 100644 index 0000000000..f67de8cea9 --- /dev/null +++ b/tests/auto/qml/qqmlpropertymap/qqmlpropertymap.pro @@ -0,0 +1,9 @@ +CONFIG += testcase +TARGET = tst_qqmlpropertymap +macx:CONFIG -= app_bundle + +SOURCES += tst_qqmlpropertymap.cpp + +CONFIG += parallel_test + +QT += core-private gui-private qml-private quick-private testlib diff --git a/tests/auto/qml/qqmlpropertymap/tst_qqmlpropertymap.cpp b/tests/auto/qml/qqmlpropertymap/tst_qqmlpropertymap.cpp new file mode 100644 index 0000000000..0ae05ce138 --- /dev/null +++ b/tests/auto/qml/qqmlpropertymap/tst_qqmlpropertymap.cpp @@ -0,0 +1,241 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include +#include +#include +#include +#include +#include +#include + +class tst_QQmlPropertyMap : public QObject +{ + Q_OBJECT +public: + tst_QQmlPropertyMap() {} + +private slots: + void insert(); + void operatorInsert(); + void operatorValue(); + void clear(); + void changed(); + void count(); + + void crashBug(); + void QTBUG_17868(); +}; + +void tst_QQmlPropertyMap::insert() +{ + QQmlPropertyMap map; + map.insert(QLatin1String("key1"),100); + map.insert(QLatin1String("key2"),200); + QVERIFY(map.keys().count() == 2); + QVERIFY(map.contains(QLatin1String("key1"))); + + QCOMPARE(map.value(QLatin1String("key1")), QVariant(100)); + QCOMPARE(map.value(QLatin1String("key2")), QVariant(200)); + + map.insert(QLatin1String("key1"),"Hello World"); + QCOMPARE(map.value(QLatin1String("key1")), QVariant("Hello World")); + + //inserting property names same with existing method(signal, slot, method) names is not allowed + //QQmlPropertyMap has an invokable keys() method + QTest::ignoreMessage(QtWarningMsg, "Creating property with name \"keys\" is not permitted, conflicts with internal symbols. "); + map.insert(QLatin1String("keys"), 1); + QVERIFY(map.keys().count() == 2); + QVERIFY(!map.contains(QLatin1String("keys"))); + QVERIFY(map.value(QLatin1String("keys")).isNull()); + + //QQmlPropertyMap has a deleteLater() slot + QTest::ignoreMessage(QtWarningMsg, "Creating property with name \"deleteLater\" is not permitted, conflicts with internal symbols. "); + map.insert(QLatin1String("deleteLater"), 1); + QVERIFY(map.keys().count() == 2); + QVERIFY(!map.contains(QLatin1String("deleteLater"))); + QVERIFY(map.value(QLatin1String("deleteLater")).isNull()); + + //QQmlPropertyMap has an valueChanged() signal + QTest::ignoreMessage(QtWarningMsg, "Creating property with name \"valueChanged\" is not permitted, conflicts with internal symbols. "); + map.insert(QLatin1String("valueChanged"), 1); + QVERIFY(map.keys().count() == 2); + QVERIFY(!map.contains(QLatin1String("valueChanged"))); + QVERIFY(map.value(QLatin1String("valueChanged")).isNull()); + + //but 'valueChange' should be ok + map.insert(QLatin1String("valueChange"), 1); + QVERIFY(map.keys().count() == 3); + QVERIFY(map.contains(QLatin1String("valueChange"))); + QCOMPARE(map.value(QLatin1String("valueChange")), QVariant(1)); + + //'valueCHANGED' should be ok, too + map.insert(QLatin1String("valueCHANGED"), 1); + QVERIFY(map.keys().count() == 4); + QVERIFY(map.contains(QLatin1String("valueCHANGED"))); + QCOMPARE(map.value(QLatin1String("valueCHANGED")), QVariant(1)); +} + +void tst_QQmlPropertyMap::operatorInsert() +{ + QQmlPropertyMap map; + map[QLatin1String("key1")] = 100; + map[QLatin1String("key2")] = 200; + QVERIFY(map.keys().count() == 2); + + QCOMPARE(map.value(QLatin1String("key1")), QVariant(100)); + QCOMPARE(map.value(QLatin1String("key2")), QVariant(200)); + + map[QLatin1String("key1")] = "Hello World"; + QCOMPARE(map.value(QLatin1String("key1")), QVariant("Hello World")); +} + +void tst_QQmlPropertyMap::operatorValue() +{ + QQmlPropertyMap map; + map.insert(QLatin1String("key1"),100); + map.insert(QLatin1String("key2"),200); + QVERIFY(map.count() == 2); + QVERIFY(map.contains(QLatin1String("key1"))); + + const QQmlPropertyMap &constMap = map; + + QCOMPARE(constMap.value(QLatin1String("key1")), QVariant(100)); + QCOMPARE(constMap.value(QLatin1String("key2")), QVariant(200)); + QCOMPARE(constMap[QLatin1String("key1")], constMap.value(QLatin1String("key1"))); + QCOMPARE(constMap[QLatin1String("key2")], constMap.value(QLatin1String("key2"))); +} + +void tst_QQmlPropertyMap::clear() +{ + QQmlPropertyMap map; + map.insert(QLatin1String("key1"),100); + QVERIFY(map.keys().count() == 1); + + QCOMPARE(map.value(QLatin1String("key1")), QVariant(100)); + + map.clear(QLatin1String("key1")); + QVERIFY(map.keys().count() == 1); + QVERIFY(map.contains(QLatin1String("key1"))); + QCOMPARE(map.value(QLatin1String("key1")), QVariant()); +} + +void tst_QQmlPropertyMap::changed() +{ + QQmlPropertyMap map; + QSignalSpy spy(&map, SIGNAL(valueChanged(const QString&, const QVariant&))); + map.insert(QLatin1String("key1"),100); + map.insert(QLatin1String("key2"),200); + QCOMPARE(spy.count(), 0); + + map.clear(QLatin1String("key1")); + QCOMPARE(spy.count(), 0); + + //make changes in QML + QQmlEngine engine; + QQmlContext *ctxt = engine.rootContext(); + ctxt->setContextProperty(QLatin1String("testdata"), &map); + QQmlComponent component(&engine); + component.setData("import QtQuick 2.0\nText { text: { testdata.key1 = 'Hello World'; 'X' } }", + QUrl::fromLocalFile("")); + QVERIFY(component.isReady()); + QQuickText *txt = qobject_cast(component.create()); + QVERIFY(txt); + QCOMPARE(txt->text(), QString('X')); + QCOMPARE(spy.count(), 1); + QList arguments = spy.takeFirst(); + QCOMPARE(arguments.count(), 2); + QCOMPARE(arguments.at(0).toString(),QLatin1String("key1")); + QCOMPARE(arguments.at(1).value(),QVariant("Hello World")); + QCOMPARE(map.value(QLatin1String("key1")), QVariant("Hello World")); +} + +void tst_QQmlPropertyMap::count() +{ + QQmlPropertyMap map; + QCOMPARE(map.isEmpty(), true); + map.insert(QLatin1String("key1"),100); + map.insert(QLatin1String("key2"),200); + QCOMPARE(map.count(), 2); + QCOMPARE(map.isEmpty(), false); + + map.insert(QLatin1String("key3"),"Hello World"); + QCOMPARE(map.count(), 3); + + //clearing doesn't remove the key + map.clear(QLatin1String("key3")); + QCOMPARE(map.count(), 3); + QCOMPARE(map.size(), map.count()); +} + +void tst_QQmlPropertyMap::crashBug() +{ + QQmlPropertyMap map; + + QQmlEngine engine; + QQmlContext context(&engine); + context.setContextProperty("map", &map); + + QQmlComponent c(&engine); + c.setData("import QtQuick 2.0\nBinding { target: map; property: \"myProp\"; value: 10 + 23 }",QUrl()); + QObject *obj = c.create(&context); + delete obj; +} + +void tst_QQmlPropertyMap::QTBUG_17868() +{ + QQmlPropertyMap map; + + QQmlEngine engine; + QQmlContext context(&engine); + context.setContextProperty("map", &map); + map.insert("key", 1); + QQmlComponent c(&engine); + c.setData("import QtQuick 2.0\nItem {property bool error:false; Component.onCompleted: {try{ map.keys(); }catch(e) {error=true;}}}",QUrl()); + QObject *obj = c.create(&context); + QVERIFY(obj); + QVERIFY(!obj->property("error").toBool()); + delete obj; + +} + +QTEST_MAIN(tst_QQmlPropertyMap) + +#include "tst_qqmlpropertymap.moc" diff --git a/tests/auto/qml/qqmlqt/data/atob.qml b/tests/auto/qml/qqmlqt/data/atob.qml new file mode 100644 index 0000000000..0d684003a1 --- /dev/null +++ b/tests/auto/qml/qqmlqt/data/atob.qml @@ -0,0 +1,7 @@ +import QtQuick 2.0 + +QtObject { + property string test1: Qt.atob() + property string test2: Qt.atob("SGVsbG8gd29ybGQh") +} + diff --git a/tests/auto/qml/qqmlqt/data/btoa.qml b/tests/auto/qml/qqmlqt/data/btoa.qml new file mode 100644 index 0000000000..0ecd01d284 --- /dev/null +++ b/tests/auto/qml/qqmlqt/data/btoa.qml @@ -0,0 +1,6 @@ +import QtQuick 2.0 + +QtObject { + property string test1: Qt.btoa() + property string test2: Qt.btoa("Hello world!") +} diff --git a/tests/auto/qml/qqmlqt/data/createComponent.qml b/tests/auto/qml/qqmlqt/data/createComponent.qml new file mode 100644 index 0000000000..3ebc9f14f8 --- /dev/null +++ b/tests/auto/qml/qqmlqt/data/createComponent.qml @@ -0,0 +1,20 @@ +import QtQuick 2.0 + +QtObject { + property bool emptyArg: false + + property string relativeUrl + property string absoluteUrl + + property QtObject incorectArgCount1: Qt.createComponent() + property QtObject incorectArgCount2: Qt.createComponent("main.qml", 10) + + Component.onCompleted: { + emptyArg = (Qt.createComponent("") == null); + var r = Qt.createComponent("createComponentData.qml"); + relativeUrl = r.url; + + var a = Qt.createComponent("http://www.example.com/test.qml"); + absoluteUrl = a.url; + } +} diff --git a/tests/auto/qml/qqmlqt/data/createComponentData.qml b/tests/auto/qml/qqmlqt/data/createComponentData.qml new file mode 100644 index 0000000000..2a824e5362 --- /dev/null +++ b/tests/auto/qml/qqmlqt/data/createComponentData.qml @@ -0,0 +1,5 @@ +import QtQuick 2.0 + +QtObject { + property int test: 1913 +} diff --git a/tests/auto/qml/qqmlqt/data/createComponent_lib.js b/tests/auto/qml/qqmlqt/data/createComponent_lib.js new file mode 100644 index 0000000000..30499e943e --- /dev/null +++ b/tests/auto/qml/qqmlqt/data/createComponent_lib.js @@ -0,0 +1,11 @@ +.pragma library + +function loadComponent() { + var component = Qt.createComponent("createComponentData.qml"); + return component.status; +} + +function createComponent() { + var component = Qt.createComponent("createComponentData.qml"); + return component.createObject(null); +} diff --git a/tests/auto/qml/qqmlqt/data/createComponent_lib.qml b/tests/auto/qml/qqmlqt/data/createComponent_lib.qml new file mode 100644 index 0000000000..a52453e8fa --- /dev/null +++ b/tests/auto/qml/qqmlqt/data/createComponent_lib.qml @@ -0,0 +1,12 @@ +import QtQuick 2.0 +import "createComponent_lib.js" as Test + +Item { + property int status: Component.Null + property int readValue: 0 + + Component.onCompleted: { + status = Test.loadComponent() + readValue = Test.createComponent().test; + } +} diff --git a/tests/auto/qml/qqmlqt/data/createQmlObject.qml b/tests/auto/qml/qqmlqt/data/createQmlObject.qml new file mode 100644 index 0000000000..87601b1cc8 --- /dev/null +++ b/tests/auto/qml/qqmlqt/data/createQmlObject.qml @@ -0,0 +1,31 @@ +import QtQuick 2.0 + +Item { + id: root + + // errors resulting in exceptions + property QtObject incorrectArgCount1: Qt.createQmlObject() + property QtObject incorrectArgCount2: Qt.createQmlObject("import QtQuick 2.0\nQtObject{}", root, "main.qml", 10) + property QtObject noParent: Qt.createQmlObject("import QtQuick 2.0\nQtObject{\nproperty int test: 13}", 0) + property QtObject notAvailable: Qt.createQmlObject("import QtQuick 2.0\nQtObject{Blah{}}", root) + property QtObject errors: Qt.createQmlObject("import QtQuick 2.0\nQtObject{\nproperty int test: 13\nproperty int test: 13\n}", root, "main.qml") + + property bool emptyArg: false + + property bool success: false + + Component.onCompleted: { + // errors resulting in nulls + emptyArg = (Qt.createQmlObject("", root) == null); + try { + Qt.createQmlObject("import QtQuick 2.0\nQtObject{property int test\nonTestChanged: QtObject{}\n}", root) + } catch (error) { + console.log("RunTimeError: ",error.message); + } + + var o = Qt.createQmlObject("import QtQuick 2.0\nQtObject{\nproperty int test: 13\n}", root); + success = (o.test == 13); + + Qt.createQmlObject("import QtQuick 2.0\nItem {}\n", root); + } +} diff --git a/tests/auto/qml/qqmlqt/data/darker.qml b/tests/auto/qml/qqmlqt/data/darker.qml new file mode 100644 index 0000000000..ce6c705fb4 --- /dev/null +++ b/tests/auto/qml/qqmlqt/data/darker.qml @@ -0,0 +1,12 @@ +import QtQuick 2.0 + +QtObject { + property variant test1: Qt.darker(Qt.rgba(1, 0.8, 0.3)) + property variant test2: Qt.darker() + property variant test3: Qt.darker(Qt.rgba(1, 0.8, 0.3), 2.8) + property variant test4: Qt.darker("red"); + property variant test5: Qt.darker("perfectred"); // Non-existant color + property variant test6: Qt.darker(10); + property variant test7: Qt.darker(Qt.rgba(1, 0.8, 0.3), 2.8, 10) +} + diff --git a/tests/auto/qml/qqmlqt/data/dateTimeConversion.qml b/tests/auto/qml/qqmlqt/data/dateTimeConversion.qml new file mode 100644 index 0000000000..641ba6e1ca --- /dev/null +++ b/tests/auto/qml/qqmlqt/data/dateTimeConversion.qml @@ -0,0 +1,14 @@ +import QtQuick 2.0 + +QtObject { + // months are 0-based - so January = 0, December = 11. + property variant qtime: new Date(2000,0,0,14,15,38,200) // yyyy/MM/dd 14:15:38.200 + property variant qdate: new Date(2008,11,24) // 2008/12/24 hh:mm:ss.zzz + property variant qdatetime: new Date(2008,11,24,14,15,38,200) // 2008/12/24 14:15:38.200 + + property variant qdatetime2: new Date(2852,11,31,23,59,59,500) // 2852/12/31 23:59:59.500 + property variant qdatetime3: new Date(2000,0,1,0,0,0,0) // 2000/01/01 00:00:00.000 + property variant qdatetime4: new Date(2001,1,2) // 2001/02/02 hh:mm:ss.zzz + property variant qdatetime5: new Date(1999,0,1,2,3,4) // 1999/01/01 02:03:04.zzz + property variant qdatetime6: new Date(2008,1,24,14,15,38,200) // 2008/02/24 14:15:38.200 +} diff --git a/tests/auto/qml/qqmlqt/data/enums.qml b/tests/auto/qml/qqmlqt/data/enums.qml new file mode 100644 index 0000000000..5a2ff534af --- /dev/null +++ b/tests/auto/qml/qqmlqt/data/enums.qml @@ -0,0 +1,9 @@ +import QtQuick 2.0 + +QtObject { + property int test1: Qt.Key_Escape + property int test2: Qt.DescendingOrder + property int test3: Qt.ElideMiddle + property int test4: Qt.AlignRight +} + diff --git a/tests/auto/qml/qqmlqt/data/fontFamilies.qml b/tests/auto/qml/qqmlqt/data/fontFamilies.qml new file mode 100644 index 0000000000..70245ab159 --- /dev/null +++ b/tests/auto/qml/qqmlqt/data/fontFamilies.qml @@ -0,0 +1,6 @@ +import QtQuick 2.0 + +QtObject { + property variant test1: Qt.fontFamilies(10) + property variant test2: Qt.fontFamilies(); +} diff --git a/tests/auto/qml/qqmlqt/data/formatting.qml b/tests/auto/qml/qqmlqt/data/formatting.qml new file mode 100644 index 0000000000..7a462c8eeb --- /dev/null +++ b/tests/auto/qml/qqmlqt/data/formatting.qml @@ -0,0 +1,44 @@ +import QtQuick 2.0 + +QtObject { + property date dateFromString: "2008-12-24" + property variant jsdate: new Date(2008,11,24,14,15,38,200) // months are 0-based + + function formatDate(prop) { + var v = eval(prop) + return [ + Qt.formatDate(v), + Qt.formatDate(v, Qt.DefaultLocaleLongDate), + Qt.formatDate(v, "ddd MMMM d yy") + ] + } + + function formatTime(prop) { + var v = eval(prop) + return [ + Qt.formatTime(v), + Qt.formatTime(v, Qt.DefaultLocaleLongDate), + Qt.formatTime(v, "H:m:s a"), + Qt.formatTime(v, "hh:mm:ss.zzz") + ] + } + + function formatDateTime(prop) { + var v = eval(prop) + return [ + Qt.formatDateTime(v), + Qt.formatDateTime(v, Qt.DefaultLocaleLongDate), + Qt.formatDateTime(v, "M/d/yy H:m:s a") + ] + } + + // Error cases + property string err_date1: Qt.formatDate() + property string err_date2: Qt.formatDate(new Date, new Object) + + property string err_time1: Qt.formatTime() + property string err_time2: Qt.formatTime(new Date, new Object) + + property string err_dateTime1: Qt.formatDateTime() + property string err_dateTime2: Qt.formatDateTime(new Date, new Object) +} diff --git a/tests/auto/qml/qqmlqt/data/hsla.qml b/tests/auto/qml/qqmlqt/data/hsla.qml new file mode 100644 index 0000000000..ff9622b339 --- /dev/null +++ b/tests/auto/qml/qqmlqt/data/hsla.qml @@ -0,0 +1,11 @@ +import QtQuick 2.0 + +QtObject { + property color test1: Qt.hsla(1, 0, 0, 0.8); + property color test2: Qt.hsla(1, 0.5, 0.3); + property color test3: Qt.hsla(1, 1); + property color test4: Qt.hsla(1, 1, 1, 1, 1); + property color test5: Qt.hsla(1.2, 1.3, 1.4, 1.5); + property color test6: Qt.hsla(-0.1, -0.2, -0.3, -0.4); +} + diff --git a/tests/auto/qml/qqmlqt/data/isQtObject.qml b/tests/auto/qml/qqmlqt/data/isQtObject.qml new file mode 100644 index 0000000000..6829209518 --- /dev/null +++ b/tests/auto/qml/qqmlqt/data/isQtObject.qml @@ -0,0 +1,14 @@ +import QtQuick 2.0 + +QtObject { + id: root + + property QtObject nullObject + + property bool test1: Qt.isQtObject(root) + property bool test2: Qt.isQtObject(nullObject) + property bool test3: Qt.isQtObject(10) + property bool test4: Qt.isQtObject(null) + property bool test5: Qt.isQtObject({ a: 10, b: 11 }) +} + diff --git a/tests/auto/qml/qqmlqt/data/lighter.qml b/tests/auto/qml/qqmlqt/data/lighter.qml new file mode 100644 index 0000000000..7db5e1edeb --- /dev/null +++ b/tests/auto/qml/qqmlqt/data/lighter.qml @@ -0,0 +1,11 @@ +import QtQuick 2.0 + +QtObject { + property variant test1: Qt.lighter(Qt.rgba(1, 0.8, 0.3)) + property variant test2: Qt.lighter() + property variant test3: Qt.lighter(Qt.rgba(1, 0.8, 0.3), 1.8) + property variant test4: Qt.lighter("red"); + property variant test5: Qt.lighter("perfectred"); // Non-existant color + property variant test6: Qt.lighter(10); + property variant test7: Qt.lighter(Qt.rgba(1, 0.8, 0.3), 1.8, 5) +} diff --git a/tests/auto/qml/qqmlqt/data/md5.qml b/tests/auto/qml/qqmlqt/data/md5.qml new file mode 100644 index 0000000000..bec1ed1fe7 --- /dev/null +++ b/tests/auto/qml/qqmlqt/data/md5.qml @@ -0,0 +1,6 @@ +import QtQuick 2.0 + +QtObject { + property string test1: Qt.md5() + property string test2: Qt.md5("Hello World") +} diff --git a/tests/auto/qml/qqmlqt/data/openUrlExternally.qml b/tests/auto/qml/qqmlqt/data/openUrlExternally.qml new file mode 100644 index 0000000000..37b9f513d9 --- /dev/null +++ b/tests/auto/qml/qqmlqt/data/openUrlExternally.qml @@ -0,0 +1,8 @@ +import QtQuick 2.0 + +QtObject { + Component.onCompleted: Qt.openUrlExternally("test:url") + + property bool testFile + onTestFileChanged: Qt.openUrlExternally("test.html") +} diff --git a/tests/auto/qml/qqmlqt/data/openUrlExternally_lib.js b/tests/auto/qml/qqmlqt/data/openUrlExternally_lib.js new file mode 100644 index 0000000000..702357afbf --- /dev/null +++ b/tests/auto/qml/qqmlqt/data/openUrlExternally_lib.js @@ -0,0 +1,9 @@ +.pragma library + +function loadTest() { + Qt.openUrlExternally("test:url") +} + +function loadFile() { + Qt.openUrlExternally("test.html") +} diff --git a/tests/auto/qml/qqmlqt/data/openUrlExternally_lib.qml b/tests/auto/qml/qqmlqt/data/openUrlExternally_lib.qml new file mode 100644 index 0000000000..4bf584d134 --- /dev/null +++ b/tests/auto/qml/qqmlqt/data/openUrlExternally_lib.qml @@ -0,0 +1,9 @@ +import QtQuick 2.0 +import "openUrlExternally_lib.js" as Test + +Item { + Component.onCompleted: Test.loadTest(); + + property bool testFile + onTestFileChanged: Test.loadFile(); +} diff --git a/tests/auto/qml/qqmlqt/data/point.qml b/tests/auto/qml/qqmlqt/data/point.qml new file mode 100644 index 0000000000..fe12ee6232 --- /dev/null +++ b/tests/auto/qml/qqmlqt/data/point.qml @@ -0,0 +1,9 @@ +import QtQuick 2.0 + +QtObject { + property variant test1: Qt.point(19, 34); + property variant test2: Qt.point(-3, 109.2); + property variant test3: Qt.point(-3); + property variant test4: Qt.point(-3, 109.2, 1); +} + diff --git a/tests/auto/qml/qqmlqt/data/quit.qml b/tests/auto/qml/qqmlqt/data/quit.qml new file mode 100644 index 0000000000..e3b91660e7 --- /dev/null +++ b/tests/auto/qml/qqmlqt/data/quit.qml @@ -0,0 +1,5 @@ +import QtQuick 2.0 + +QtObject { + Component.onCompleted: Qt.quit() +} diff --git a/tests/auto/qml/qqmlqt/data/rect.qml b/tests/auto/qml/qqmlqt/data/rect.qml new file mode 100644 index 0000000000..b294b22c5b --- /dev/null +++ b/tests/auto/qml/qqmlqt/data/rect.qml @@ -0,0 +1,9 @@ +import QtQuick 2.0 + +QtObject { + property variant test1: Qt.rect(10, 13, 100, 109) + property variant test2: Qt.rect(-10, 13, 100, 109.6) + property variant test3: Qt.rect(10, 13); + property variant test4: Qt.rect(10, 13, 100, 109, 10) + property variant test5: Qt.rect(10, 13, 100, -109) +} diff --git a/tests/auto/qml/qqmlqt/data/resolvedUrl.qml b/tests/auto/qml/qqmlqt/data/resolvedUrl.qml new file mode 100644 index 0000000000..06ef48b82b --- /dev/null +++ b/tests/auto/qml/qqmlqt/data/resolvedUrl.qml @@ -0,0 +1,13 @@ +import QtQuick 2.0 + +QtObject { + property string result + property bool isString: false + + Component.onCompleted: { + var a = Qt.resolvedUrl("resolvedUrl.qml"); + result = a; + isString = (typeof a) == "string" + } +} + diff --git a/tests/auto/qml/qqmlqt/data/rgba.qml b/tests/auto/qml/qqmlqt/data/rgba.qml new file mode 100644 index 0000000000..3b010f68cb --- /dev/null +++ b/tests/auto/qml/qqmlqt/data/rgba.qml @@ -0,0 +1,10 @@ +import QtQuick 2.0 + +QtObject { + property color test1: Qt.rgba(1, 0, 0, 0.8); + property color test2: Qt.rgba(1, 0.5, 0.3); + property color test3: Qt.rgba(1, 1); + property color test4: Qt.rgba(1, 1, 1, 1, 1); + property color test5: Qt.rgba(1.2, 1.3, 1.4, 1.5); + property color test6: Qt.rgba(-0.1, -0.2, -0.3, -0.4); +} diff --git a/tests/auto/qml/qqmlqt/data/size.qml b/tests/auto/qml/qqmlqt/data/size.qml new file mode 100644 index 0000000000..41051f4216 --- /dev/null +++ b/tests/auto/qml/qqmlqt/data/size.qml @@ -0,0 +1,11 @@ +import QtQuick 2.0 + +QtObject { + property variant test1: Qt.size(19, 34); + property variant test2: Qt.size(3, 109.2); + property variant test3: Qt.size(-3, 10); + property variant test4: Qt.size(3); + property variant test5: Qt.size(3, 109.2, 1); +} + + diff --git a/tests/auto/qml/qqmlqt/data/tint.qml b/tests/auto/qml/qqmlqt/data/tint.qml new file mode 100644 index 0000000000..816e6e9b08 --- /dev/null +++ b/tests/auto/qml/qqmlqt/data/tint.qml @@ -0,0 +1,9 @@ +import QtQuick 2.0 + +QtObject { + property color test1: Qt.tint("red", "blue"); + property color test2: Qt.tint(Qt.rgba(1, 0, 0), Qt.rgba(0, 0, 0, 0)); + property color test3: Qt.tint("red", Qt.rgba(0, 0, 1, 0.5)); + property color test4: Qt.tint("red", Qt.rgba(0, 0, 1, 0.5), 10); + property color test5: Qt.tint("red") +} diff --git a/tests/auto/qml/qqmlqt/data/vector.qml b/tests/auto/qml/qqmlqt/data/vector.qml new file mode 100644 index 0000000000..5a949515ed --- /dev/null +++ b/tests/auto/qml/qqmlqt/data/vector.qml @@ -0,0 +1,8 @@ +import QtQuick 2.0 + +QtObject { + property variant test1: Qt.vector3d(1, 0, 0.9); + property variant test2: Qt.vector3d(102, -10, -982.1); + property variant test3: Qt.vector3d(102, -10); + property variant test4: Qt.vector3d(102, -10, -982.1, 10); +} diff --git a/tests/auto/qml/qqmlqt/data/vector4.qml b/tests/auto/qml/qqmlqt/data/vector4.qml new file mode 100644 index 0000000000..554dd1e9d4 --- /dev/null +++ b/tests/auto/qml/qqmlqt/data/vector4.qml @@ -0,0 +1,8 @@ +import QtQuick 2.0 + +QtObject { + property variant test1: Qt.vector4d(1, 0, 0.9, 0.6); + property variant test2: Qt.vector4d(102, -10, -982.1, 10); + property variant test3: Qt.vector4d(102, -10, -982.1); + property variant test4: Qt.vector4d(102, -10, -982.1, 10, 15); +} diff --git a/tests/auto/qml/qqmlqt/qqmlqt.pro b/tests/auto/qml/qqmlqt/qqmlqt.pro new file mode 100644 index 0000000000..890a7e7636 --- /dev/null +++ b/tests/auto/qml/qqmlqt/qqmlqt.pro @@ -0,0 +1,15 @@ +CONFIG += testcase +TARGET = tst_qqmlqt +SOURCES += tst_qqmlqt.cpp + +include (../../shared/util.pri) + +macx:CONFIG -= app_bundle + +testDataFiles.files = data +testDataFiles.path = . +DEPLOYMENT += testDataFiles + +CONFIG += parallel_test + +QT += core-private gui-private v8-private qml-private quick-private testlib diff --git a/tests/auto/qml/qqmlqt/tst_qqmlqt.cpp b/tests/auto/qml/qqmlqt/tst_qqmlqt.cpp new file mode 100644 index 0000000000..a679188cb7 --- /dev/null +++ b/tests/auto/qml/qqmlqt/tst_qqmlqt.cpp @@ -0,0 +1,732 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "../../shared/util.h" + +class tst_qqmlqt : public QQmlDataTest +{ + Q_OBJECT +public: + tst_qqmlqt() {} + +private slots: + void enums(); + void rgba(); + void hsla(); + void rect(); + void point(); + void size(); + void vector(); + void vector4d(); + void lighter(); + void darker(); + void tint(); + void openUrlExternally(); + void openUrlExternally_pragmaLibrary(); + void md5(); + void createComponent(); + void createComponent_pragmaLibrary(); + void createQmlObject(); + void dateTimeConversion(); + void dateTimeFormatting(); + void dateTimeFormatting_data(); + void dateTimeFormattingVariants(); + void dateTimeFormattingVariants_data(); + void isQtObject(); + void btoa(); + void atob(); + void fontFamilies(); + void quit(); + void resolvedUrl(); + +private: + QQmlEngine engine; +}; + +void tst_qqmlqt::enums() +{ + QQmlComponent component(&engine, testFileUrl("enums.qml")); + QObject *object = component.create(); + QVERIFY(object != 0); + + QCOMPARE(object->property("test1").toInt(), (int)Qt::Key_Escape); + QCOMPARE(object->property("test2").toInt(), (int)Qt::DescendingOrder); + QCOMPARE(object->property("test3").toInt(), (int)Qt::ElideMiddle); + QCOMPARE(object->property("test4").toInt(), (int)Qt::AlignRight); + + delete object; +} + +void tst_qqmlqt::rgba() +{ + QQmlComponent component(&engine, testFileUrl("rgba.qml")); + + QString warning1 = component.url().toString() + ":6: Error: Qt.rgba(): Invalid arguments"; + QString warning2 = component.url().toString() + ":7: Error: Qt.rgba(): Invalid arguments"; + QTest::ignoreMessage(QtWarningMsg, qPrintable(warning1)); + QTest::ignoreMessage(QtWarningMsg, qPrintable(warning2)); + + QObject *object = component.create(); + QVERIFY(object != 0); + + + QCOMPARE(qvariant_cast(object->property("test1")), QColor::fromRgbF(1, 0, 0, 0.8)); + QCOMPARE(qvariant_cast(object->property("test2")), QColor::fromRgbF(1, 0.5, 0.3, 1)); + QCOMPARE(qvariant_cast(object->property("test3")), QColor()); + QCOMPARE(qvariant_cast(object->property("test4")), QColor()); + QCOMPARE(qvariant_cast(object->property("test5")), QColor::fromRgbF(1, 1, 1, 1)); + QCOMPARE(qvariant_cast(object->property("test6")), QColor::fromRgbF(0, 0, 0, 0)); + + delete object; +} + +void tst_qqmlqt::hsla() +{ + QQmlComponent component(&engine, testFileUrl("hsla.qml")); + + QString warning1 = component.url().toString() + ":6: Error: Qt.hsla(): Invalid arguments"; + QString warning2 = component.url().toString() + ":7: Error: Qt.hsla(): Invalid arguments"; + QTest::ignoreMessage(QtWarningMsg, qPrintable(warning1)); + QTest::ignoreMessage(QtWarningMsg, qPrintable(warning2)); + + QObject *object = component.create(); + QVERIFY(object != 0); + + QCOMPARE(qvariant_cast(object->property("test1")), QColor::fromHslF(1, 0, 0, 0.8)); + QCOMPARE(qvariant_cast(object->property("test2")), QColor::fromHslF(1, 0.5, 0.3, 1)); + QCOMPARE(qvariant_cast(object->property("test3")), QColor()); + QCOMPARE(qvariant_cast(object->property("test4")), QColor()); + QCOMPARE(qvariant_cast(object->property("test5")), QColor::fromHslF(1, 1, 1, 1)); + QCOMPARE(qvariant_cast(object->property("test6")), QColor::fromHslF(0, 0, 0, 0)); + + delete object; +} + +void tst_qqmlqt::rect() +{ + QQmlComponent component(&engine, testFileUrl("rect.qml")); + + QString warning1 = component.url().toString() + ":6: Error: Qt.rect(): Invalid arguments"; + QString warning2 = component.url().toString() + ":7: Error: Qt.rect(): Invalid arguments"; + QTest::ignoreMessage(QtWarningMsg, qPrintable(warning1)); + QTest::ignoreMessage(QtWarningMsg, qPrintable(warning2)); + + QObject *object = component.create(); + QVERIFY(object != 0); + + QCOMPARE(qvariant_cast(object->property("test1")), QRectF(10, 13, 100, 109)); + QCOMPARE(qvariant_cast(object->property("test2")), QRectF(-10, 13, 100, 109.6)); + QCOMPARE(qvariant_cast(object->property("test3")), QRectF()); + QCOMPARE(qvariant_cast(object->property("test4")), QRectF()); + QCOMPARE(qvariant_cast(object->property("test5")), QRectF(10, 13, 100, -109)); + + delete object; +} + +void tst_qqmlqt::point() +{ + QQmlComponent component(&engine, testFileUrl("point.qml")); + + QString warning1 = component.url().toString() + ":6: Error: Qt.point(): Invalid arguments"; + QString warning2 = component.url().toString() + ":7: Error: Qt.point(): Invalid arguments"; + QTest::ignoreMessage(QtWarningMsg, qPrintable(warning1)); + QTest::ignoreMessage(QtWarningMsg, qPrintable(warning2)); + + QObject *object = component.create(); + QVERIFY(object != 0); + + QCOMPARE(qvariant_cast(object->property("test1")), QPointF(19, 34)); + QCOMPARE(qvariant_cast(object->property("test2")), QPointF(-3, 109.2)); + QCOMPARE(qvariant_cast(object->property("test3")), QPointF()); + QCOMPARE(qvariant_cast(object->property("test4")), QPointF()); + + delete object; +} + +void tst_qqmlqt::size() +{ + QQmlComponent component(&engine, testFileUrl("size.qml")); + + QString warning1 = component.url().toString() + ":7: Error: Qt.size(): Invalid arguments"; + QString warning2 = component.url().toString() + ":8: Error: Qt.size(): Invalid arguments"; + QTest::ignoreMessage(QtWarningMsg, qPrintable(warning1)); + QTest::ignoreMessage(QtWarningMsg, qPrintable(warning2)); + + QObject *object = component.create(); + QVERIFY(object != 0); + + QCOMPARE(qvariant_cast(object->property("test1")), QSizeF(19, 34)); + QCOMPARE(qvariant_cast(object->property("test2")), QSizeF(3, 109.2)); + QCOMPARE(qvariant_cast(object->property("test3")), QSizeF(-3, 10)); + QCOMPARE(qvariant_cast(object->property("test4")), QSizeF()); + QCOMPARE(qvariant_cast(object->property("test5")), QSizeF()); + + delete object; +} + +void tst_qqmlqt::vector() +{ + QQmlComponent component(&engine, testFileUrl("vector.qml")); + + QString warning1 = component.url().toString() + ":6: Error: Qt.vector(): Invalid arguments"; + QString warning2 = component.url().toString() + ":7: Error: Qt.vector(): Invalid arguments"; + QTest::ignoreMessage(QtWarningMsg, qPrintable(warning1)); + QTest::ignoreMessage(QtWarningMsg, qPrintable(warning2)); + + QObject *object = component.create(); + QVERIFY(object != 0); + + QCOMPARE(qvariant_cast(object->property("test1")), QVector3D(1, 0, 0.9)); + QCOMPARE(qvariant_cast(object->property("test2")), QVector3D(102, -10, -982.1)); + QCOMPARE(qvariant_cast(object->property("test3")), QVector3D()); + QCOMPARE(qvariant_cast(object->property("test4")), QVector3D()); + + delete object; +} + +void tst_qqmlqt::vector4d() +{ + QQmlComponent component(&engine, testFileUrl("vector4.qml")); + + QString warning1 = component.url().toString() + ":6: Error: Qt.vector4d(): Invalid arguments"; + QString warning2 = component.url().toString() + ":7: Error: Qt.vector4d(): Invalid arguments"; + QTest::ignoreMessage(QtWarningMsg, qPrintable(warning1)); + QTest::ignoreMessage(QtWarningMsg, qPrintable(warning2)); + + QObject *object = component.create(); + QVERIFY(object != 0); + + QCOMPARE(qvariant_cast(object->property("test1")), QVector4D(1, 0, 0.9, 0.6)); + QCOMPARE(qvariant_cast(object->property("test2")), QVector4D(102, -10, -982.1, 10)); + QCOMPARE(qvariant_cast(object->property("test3")), QVector4D()); + QCOMPARE(qvariant_cast(object->property("test4")), QVector4D()); + + delete object; +} + +void tst_qqmlqt::lighter() +{ + QQmlComponent component(&engine, testFileUrl("lighter.qml")); + + QString warning1 = component.url().toString() + ":5: Error: Qt.lighter(): Invalid arguments"; + QString warning2 = component.url().toString() + ":10: Error: Qt.lighter(): Invalid arguments"; + QTest::ignoreMessage(QtWarningMsg, qPrintable(warning1)); + QTest::ignoreMessage(QtWarningMsg, qPrintable(warning2)); + + QObject *object = component.create(); + QVERIFY(object != 0); + + QCOMPARE(qvariant_cast(object->property("test1")), QColor::fromRgbF(1, 0.8, 0.3).lighter()); + QCOMPARE(qvariant_cast(object->property("test2")), QColor()); + QCOMPARE(qvariant_cast(object->property("test3")), QColor::fromRgbF(1, 0.8, 0.3).lighter(180)); + QCOMPARE(qvariant_cast(object->property("test4")), QColor("red").lighter()); + QCOMPARE(qvariant_cast(object->property("test5")), QColor()); + QCOMPARE(qvariant_cast(object->property("test6")), QColor()); + + delete object; +} + +void tst_qqmlqt::darker() +{ + QQmlComponent component(&engine, testFileUrl("darker.qml")); + + QString warning1 = component.url().toString() + ":5: Error: Qt.darker(): Invalid arguments"; + QString warning2 = component.url().toString() + ":10: Error: Qt.darker(): Invalid arguments"; + QTest::ignoreMessage(QtWarningMsg, qPrintable(warning1)); + QTest::ignoreMessage(QtWarningMsg, qPrintable(warning2)); + + QObject *object = component.create(); + QVERIFY(object != 0); + + QCOMPARE(qvariant_cast(object->property("test1")), QColor::fromRgbF(1, 0.8, 0.3).darker()); + QCOMPARE(qvariant_cast(object->property("test2")), QColor()); + QCOMPARE(qvariant_cast(object->property("test3")), QColor::fromRgbF(1, 0.8, 0.3).darker(280)); + QCOMPARE(qvariant_cast(object->property("test4")), QColor("red").darker()); + QCOMPARE(qvariant_cast(object->property("test5")), QColor()); + QCOMPARE(qvariant_cast(object->property("test6")), QColor()); + + delete object; +} + +void tst_qqmlqt::tint() +{ + QQmlComponent component(&engine, testFileUrl("tint.qml")); + + QString warning1 = component.url().toString() + ":7: Error: Qt.tint(): Invalid arguments"; + QString warning2 = component.url().toString() + ":8: Error: Qt.tint(): Invalid arguments"; + + QTest::ignoreMessage(QtWarningMsg, qPrintable(warning1)); + QTest::ignoreMessage(QtWarningMsg, qPrintable(warning2)); + + QObject *object = component.create(); + QVERIFY(object != 0); + + QCOMPARE(qvariant_cast(object->property("test1")), QColor::fromRgbF(0, 0, 1)); + QCOMPARE(qvariant_cast(object->property("test2")), QColor::fromRgbF(1, 0, 0)); + QColor test3 = qvariant_cast(object->property("test3")); + QCOMPARE(test3.rgba(), 0xFF7F0080); + QCOMPARE(qvariant_cast(object->property("test4")), QColor()); + QCOMPARE(qvariant_cast(object->property("test5")), QColor()); + + delete object; +} + +class MyUrlHandler : public QObject +{ + Q_OBJECT +public: + MyUrlHandler() : called(0) { } + int called; + QUrl last; + +public slots: + void noteCall(const QUrl &url) { called++; last = url; } +}; + +void tst_qqmlqt::openUrlExternally() +{ + MyUrlHandler handler; + + QDesktopServices::setUrlHandler("test", &handler, "noteCall"); + QDesktopServices::setUrlHandler("file", &handler, "noteCall"); + + QQmlComponent component(&engine, testFileUrl("openUrlExternally.qml")); + QObject *object = component.create(); + QVERIFY(object != 0); + QCOMPARE(handler.called,1); + QCOMPARE(handler.last, QUrl("test:url")); + + object->setProperty("testFile", true); + + QCOMPARE(handler.called,2); + QCOMPARE(handler.last, testFileUrl("test.html")); + + QDesktopServices::unsetUrlHandler("test"); + QDesktopServices::unsetUrlHandler("file"); +} + +void tst_qqmlqt::openUrlExternally_pragmaLibrary() +{ + MyUrlHandler handler; + + QDesktopServices::setUrlHandler("test", &handler, "noteCall"); + QDesktopServices::setUrlHandler("file", &handler, "noteCall"); + + QQmlComponent component(&engine, testFileUrl("openUrlExternally_lib.qml")); + QObject *object = component.create(); + QVERIFY(object != 0); + QCOMPARE(handler.called,1); + QCOMPARE(handler.last, QUrl("test:url")); + + object->setProperty("testFile", true); + + QCOMPARE(handler.called,2); + QCOMPARE(handler.last, testFileUrl("test.html")); + + QDesktopServices::unsetUrlHandler("test"); + QDesktopServices::unsetUrlHandler("file"); +} + +void tst_qqmlqt::md5() +{ + QQmlComponent component(&engine, testFileUrl("md5.qml")); + + QString warning1 = component.url().toString() + ":4: Error: Qt.md5(): Invalid arguments"; + QTest::ignoreMessage(QtWarningMsg, qPrintable(warning1)); + + QObject *object = component.create(); + QVERIFY(object != 0); + + QCOMPARE(object->property("test2").toString(), QLatin1String(QCryptographicHash::hash("Hello World", QCryptographicHash::Md5).toHex())); + + delete object; +} + +void tst_qqmlqt::createComponent() +{ + QQmlComponent component(&engine, testFileUrl("createComponent.qml")); + + QString warning1 = component.url().toString() + ":9: Error: Qt.createComponent(): Invalid arguments"; + QString warning2 = component.url().toString() + ":10: Error: Qt.createComponent(): Invalid arguments"; + QTest::ignoreMessage(QtWarningMsg, qPrintable(warning1)); + QTest::ignoreMessage(QtWarningMsg, qPrintable(warning2)); + + QObject *object = component.create(); + QVERIFY(object != 0); + + QCOMPARE(object->property("absoluteUrl").toString(), QString("http://www.example.com/test.qml")); + QCOMPARE(object->property("relativeUrl").toString(), testFileUrl("createComponentData.qml").toString()); + + delete object; +} + +void tst_qqmlqt::createComponent_pragmaLibrary() +{ + // Currently, just loading createComponent_lib.qml causes crash on some platforms + QQmlComponent component(&engine, testFileUrl("createComponent_lib.qml")); + QObject *object = component.create(); + QVERIFY(object != 0); + QCOMPARE(object->property("status").toInt(), int(QQmlComponent::Ready)); + QCOMPARE(object->property("readValue").toInt(), int(1913)); + delete object; +} + +void tst_qqmlqt::createQmlObject() +{ + QQmlComponent component(&engine, testFileUrl("createQmlObject.qml")); + + QString warning1 = component.url().toString() + ":7: Error: Qt.createQmlObject(): Invalid arguments"; + QString warning2 = component.url().toString()+ ":10: Error: Qt.createQmlObject(): failed to create object: \n " + testFileUrl("inline").toString() + ":2:10: Blah is not a type"; + QString warning3 = component.url().toString()+ ":11: Error: Qt.createQmlObject(): failed to create object: \n " + testFileUrl("main.qml").toString() + ":4:14: Duplicate property name"; + QString warning4 = component.url().toString()+ ":9: Error: Qt.createQmlObject(): Missing parent object"; + QString warning5 = component.url().toString()+ ":8: Error: Qt.createQmlObject(): Invalid arguments"; + QString warning6 = "RunTimeError: Qt.createQmlObject(): failed to create object: \n " + testFileUrl("inline").toString() + ":3: Cannot assign object type QObject with no default method"; + QTest::ignoreMessage(QtWarningMsg, qPrintable(warning1)); + QTest::ignoreMessage(QtWarningMsg, qPrintable(warning2)); + QTest::ignoreMessage(QtWarningMsg, qPrintable(warning3)); + QTest::ignoreMessage(QtWarningMsg, qPrintable(warning4)); + QTest::ignoreMessage(QtWarningMsg, qPrintable(warning5)); + QTest::ignoreMessage(QtDebugMsg, qPrintable(warning6)); + + QObject *object = component.create(); + QVERIFY(object != 0); + + QCOMPARE(object->property("emptyArg").toBool(), true); + QCOMPARE(object->property("success").toBool(), true); + + QQuickItem *item = qobject_cast(object); + QVERIFY(item != 0); + QVERIFY(item->childItems().count() == 1); + + delete object; +} + + +void tst_qqmlqt::dateTimeConversion() +{ + QDate date(2008,12,24); + QTime time(14,15,38,200); + QDateTime dateTime(date, time); + //Note that when converting Date to QDateTime they can argue over historical DST data when converting to local time. + //Tests should use UTC or recent dates. + QDateTime dateTime2(QDate(2852,12,31), QTime(23,59,59,500)); + QDateTime dateTime3(QDate(2000,1,1), QTime(0,0,0,0)); + QDateTime dateTime4(QDate(2001,2,2), QTime(0,0,0,0)); + QDateTime dateTime5(QDate(1999,1,1), QTime(2,3,4,0)); + QDateTime dateTime6(QDate(2008,2,24), QTime(14,15,38,200)); + + QQmlEngine eng; + QQmlComponent component(&eng, testFileUrl("dateTimeConversion.qml")); + QObject *obj = component.create(); + + QCOMPARE(obj->property("qdate").toDate(), date); + QCOMPARE(obj->property("qtime").toTime(), time); + QCOMPARE(obj->property("qdatetime").toDateTime(), dateTime); + QCOMPARE(obj->property("qdatetime2").toDateTime(), dateTime2); + QCOMPARE(obj->property("qdatetime3").toDateTime(), dateTime3); + QCOMPARE(obj->property("qdatetime4").toDateTime(), dateTime4); + QCOMPARE(obj->property("qdatetime5").toDateTime(), dateTime5); + QCOMPARE(obj->property("qdatetime6").toDateTime(), dateTime6); +} + +void tst_qqmlqt::dateTimeFormatting() +{ + QFETCH(QString, method); + QFETCH(QStringList, inputProperties); + QFETCH(QStringList, expectedResults); + + QDate date(2008,12,24); + QTime time(14,15,38,200); + QDateTime dateTime(date, time); + + QQmlEngine eng; + + eng.rootContext()->setContextProperty("qdate", date); + eng.rootContext()->setContextProperty("qtime", time); + eng.rootContext()->setContextProperty("qdatetime", dateTime); + + QQmlComponent component(&eng, testFileUrl("formatting.qml")); + + QStringList warnings; + warnings << component.url().toString() + ":37: Error: Qt.formatDate(): Invalid date format" + << component.url().toString() + ":36: Error: Qt.formatDate(): Invalid arguments" + << component.url().toString() + ":40: Error: Qt.formatTime(): Invalid time format" + << component.url().toString() + ":39: Error: Qt.formatTime(): Invalid arguments" + << component.url().toString() + ":43: Error: Qt.formatDateTime(): Invalid datetime format" + << component.url().toString() + ":42: Error: Qt.formatDateTime(): Invalid arguments"; + + foreach (const QString &warning, warnings) + QTest::ignoreMessage(QtWarningMsg, qPrintable(warning)); + + QObject *object = component.create(); + QVERIFY2(component.errorString().isEmpty(), qPrintable(component.errorString())); + QVERIFY(object != 0); + + QVERIFY(inputProperties.count() > 0); + QVariant result; + foreach(const QString &prop, inputProperties) { + QVERIFY(QMetaObject::invokeMethod(object, method.toUtf8().constData(), + Q_RETURN_ARG(QVariant, result), + Q_ARG(QVariant, prop))); + QStringList output = result.toStringList(); + QCOMPARE(output.size(), expectedResults.size()); + for (int i=0; i("method"); + QTest::addColumn("inputProperties"); + QTest::addColumn("expectedResults"); + + QDate date(2008,12,24); + QTime time(14,15,38,200); + QDateTime dateTime(date, time); + + QTest::newRow("formatDate") + << "formatDate" + << (QStringList() << "dateFromString" << "jsdate" << "qdate" << "qdatetime") + << (QStringList() << date.toString(Qt::DefaultLocaleShortDate) + << date.toString(Qt::DefaultLocaleLongDate) + << date.toString("ddd MMMM d yy")); + + QTest::newRow("formatTime") + << "formatTime" + << (QStringList() << "jsdate" << "qtime" << "qdatetime") + << (QStringList() << time.toString(Qt::DefaultLocaleShortDate) + << time.toString(Qt::DefaultLocaleLongDate) + << time.toString("H:m:s a") + << time.toString("hh:mm:ss.zzz")); + + QTest::newRow("formatDateTime") + << "formatDateTime" + << (QStringList() << "jsdate" << "qdatetime") + << (QStringList() << dateTime.toString(Qt::DefaultLocaleShortDate) + << dateTime.toString(Qt::DefaultLocaleLongDate) + << dateTime.toString("M/d/yy H:m:s a")); +} + +void tst_qqmlqt::dateTimeFormattingVariants() +{ + QFETCH(QString, method); + QFETCH(QVariant, variant); + QFETCH(QStringList, expectedResults); + + QQmlEngine eng; + eng.rootContext()->setContextProperty("qvariant", variant); + QQmlComponent component(&eng, testFileUrl("formatting.qml")); + + QStringList warnings; + warnings << component.url().toString() + ":37: Error: Qt.formatDate(): Invalid date format" + << component.url().toString() + ":36: Error: Qt.formatDate(): Invalid arguments" + << component.url().toString() + ":40: Error: Qt.formatTime(): Invalid time format" + << component.url().toString() + ":39: Error: Qt.formatTime(): Invalid arguments" + << component.url().toString() + ":43: Error: Qt.formatDateTime(): Invalid datetime format" + << component.url().toString() + ":42: Error: Qt.formatDateTime(): Invalid arguments"; + + foreach (const QString &warning, warnings) + QTest::ignoreMessage(QtWarningMsg, qPrintable(warning)); + + QObject *object = component.create(); + QVERIFY2(component.errorString().isEmpty(), qPrintable(component.errorString())); + QVERIFY(object != 0); + + QVariant result; + QVERIFY(QMetaObject::invokeMethod(object, method.toUtf8().constData(), + Q_RETURN_ARG(QVariant, result), + Q_ARG(QVariant, QString(QLatin1String("qvariant"))))); + QStringList output = result.toStringList(); + QCOMPARE(output, expectedResults); + + delete object; +} + +void tst_qqmlqt::dateTimeFormattingVariants_data() +{ + QTest::addColumn("method"); + QTest::addColumn("variant"); + QTest::addColumn("expectedResults"); + + QDateTime temporary; + + QTime time(11, 16, 39, 755); + temporary = QDateTime(QDate(1970,1,1), time); + QTest::newRow("formatDate, qtime") << "formatDate" << QVariant::fromValue(time) << (QStringList() << temporary.date().toString(Qt::DefaultLocaleShortDate) << temporary.date().toString(Qt::DefaultLocaleLongDate) << temporary.date().toString("ddd MMMM d yy")); + QTest::newRow("formatDateTime, qtime") << "formatDateTime" << QVariant::fromValue(time) << (QStringList() << temporary.toString(Qt::DefaultLocaleShortDate) << temporary.toString(Qt::DefaultLocaleLongDate) << temporary.toString("M/d/yy H:m:s a")); + QTest::newRow("formatTime, qtime") << "formatTime" << QVariant::fromValue(time) << (QStringList() << temporary.time().toString(Qt::DefaultLocaleShortDate) << temporary.time().toString(Qt::DefaultLocaleLongDate) << temporary.time().toString("H:m:s a") << temporary.time().toString("hh:mm:ss.zzz")); + + QDate date(2011,5,31); + temporary = QDateTime(date); + QTest::newRow("formatDate, qdate") << "formatDate" << QVariant::fromValue(date) << (QStringList() << temporary.date().toString(Qt::DefaultLocaleShortDate) << temporary.date().toString(Qt::DefaultLocaleLongDate) << temporary.date().toString("ddd MMMM d yy")); + QTest::newRow("formatDateTime, qdate") << "formatDateTime" << QVariant::fromValue(date) << (QStringList() << temporary.toString(Qt::DefaultLocaleShortDate) << temporary.toString(Qt::DefaultLocaleLongDate) << temporary.toString("M/d/yy H:m:s a")); + QTest::newRow("formatTime, qdate") << "formatTime" << QVariant::fromValue(date) << (QStringList() << temporary.time().toString(Qt::DefaultLocaleShortDate) << temporary.time().toString(Qt::DefaultLocaleLongDate) << temporary.time().toString("H:m:s a") << temporary.time().toString("hh:mm:ss.zzz")); + + QDateTime dateTime(date, time); + temporary = dateTime; + QTest::newRow("formatDate, qdatetime") << "formatDate" << QVariant::fromValue(dateTime) << (QStringList() << temporary.date().toString(Qt::DefaultLocaleShortDate) << temporary.date().toString(Qt::DefaultLocaleLongDate) << temporary.date().toString("ddd MMMM d yy")); + QTest::newRow("formatDateTime, qdatetime") << "formatDateTime" << QVariant::fromValue(dateTime) << (QStringList() << temporary.toString(Qt::DefaultLocaleShortDate) << temporary.toString(Qt::DefaultLocaleLongDate) << temporary.toString("M/d/yy H:m:s a")); + QTest::newRow("formatTime, qdatetime") << "formatTime" << QVariant::fromValue(dateTime) << (QStringList() << temporary.time().toString(Qt::DefaultLocaleShortDate) << temporary.time().toString(Qt::DefaultLocaleLongDate) << temporary.time().toString("H:m:s a") << temporary.time().toString("hh:mm:ss.zzz")); + + QString string(QLatin1String("2011/05/31 11:16:39.755")); + temporary = QDateTime::fromString(string, "yyyy/MM/dd HH:mm:ss.zzz"); + QTest::newRow("formatDate, qstring") << "formatDate" << QVariant::fromValue(string) << (QStringList() << temporary.date().toString(Qt::DefaultLocaleShortDate) << temporary.date().toString(Qt::DefaultLocaleLongDate) << temporary.date().toString("ddd MMMM d yy")); + QTest::newRow("formatDateTime, qstring") << "formatDateTime" << QVariant::fromValue(string) << (QStringList() << temporary.toString(Qt::DefaultLocaleShortDate) << temporary.toString(Qt::DefaultLocaleLongDate) << temporary.toString("M/d/yy H:m:s a")); + QTest::newRow("formatTime, qstring") << "formatTime" << QVariant::fromValue(string) << (QStringList() << temporary.time().toString(Qt::DefaultLocaleShortDate) << temporary.time().toString(Qt::DefaultLocaleLongDate) << temporary.time().toString("H:m:s a") << temporary.time().toString("hh:mm:ss.zzz")); + + QColor color(Qt::red); + temporary = QVariant::fromValue(color).toDateTime(); + QTest::newRow("formatDate, qcolor") << "formatDate" << QVariant::fromValue(color) << (QStringList() << temporary.date().toString(Qt::DefaultLocaleShortDate) << temporary.date().toString(Qt::DefaultLocaleLongDate) << temporary.date().toString("ddd MMMM d yy")); + QTest::newRow("formatDateTime, qcolor") << "formatDateTime" << QVariant::fromValue(color) << (QStringList() << temporary.toString(Qt::DefaultLocaleShortDate) << temporary.toString(Qt::DefaultLocaleLongDate) << temporary.toString("M/d/yy H:m:s a")); + QTest::newRow("formatTime, qcolor") << "formatTime" << QVariant::fromValue(color) << (QStringList() << temporary.time().toString(Qt::DefaultLocaleShortDate) << temporary.time().toString(Qt::DefaultLocaleLongDate) << temporary.time().toString("H:m:s a") << temporary.time().toString("hh:mm:ss.zzz")); + + int integer(4); + temporary = QVariant::fromValue(integer).toDateTime(); + QTest::newRow("formatDate, int") << "formatDate" << QVariant::fromValue(integer) << (QStringList() << temporary.date().toString(Qt::DefaultLocaleShortDate) << temporary.date().toString(Qt::DefaultLocaleLongDate) << temporary.date().toString("ddd MMMM d yy")); + QTest::newRow("formatDateTime, int") << "formatDateTime" << QVariant::fromValue(integer) << (QStringList() << temporary.toString(Qt::DefaultLocaleShortDate) << temporary.toString(Qt::DefaultLocaleLongDate) << temporary.toString("M/d/yy H:m:s a")); + QTest::newRow("formatTime, int") << "formatTime" << QVariant::fromValue(integer) << (QStringList() << temporary.time().toString(Qt::DefaultLocaleShortDate) << temporary.time().toString(Qt::DefaultLocaleLongDate) << temporary.time().toString("H:m:s a") << temporary.time().toString("hh:mm:ss.zzz")); +} + +void tst_qqmlqt::isQtObject() +{ + QQmlComponent component(&engine, testFileUrl("isQtObject.qml")); + QObject *object = component.create(); + QVERIFY(object != 0); + + QCOMPARE(object->property("test1").toBool(), true); + QCOMPARE(object->property("test2").toBool(), false); + QCOMPARE(object->property("test3").toBool(), false); + QCOMPARE(object->property("test4").toBool(), false); + QCOMPARE(object->property("test5").toBool(), false); + + delete object; +} + +void tst_qqmlqt::btoa() +{ + QQmlComponent component(&engine, testFileUrl("btoa.qml")); + + QString warning1 = component.url().toString() + ":4: Error: Qt.btoa(): Invalid arguments"; + QTest::ignoreMessage(QtWarningMsg, qPrintable(warning1)); + + QObject *object = component.create(); + QVERIFY(object != 0); + + QCOMPARE(object->property("test2").toString(), QString("SGVsbG8gd29ybGQh")); + + delete object; +} + +void tst_qqmlqt::atob() +{ + QQmlComponent component(&engine, testFileUrl("atob.qml")); + + QString warning1 = component.url().toString() + ":4: Error: Qt.atob(): Invalid arguments"; + QTest::ignoreMessage(QtWarningMsg, qPrintable(warning1)); + + QObject *object = component.create(); + QVERIFY(object != 0); + + QCOMPARE(object->property("test2").toString(), QString("Hello world!")); + + delete object; +} + +void tst_qqmlqt::fontFamilies() +{ + QQmlComponent component(&engine, testFileUrl("fontFamilies.qml")); + + QString warning1 = component.url().toString() + ":4: Error: Qt.fontFamilies(): Invalid arguments"; + QTest::ignoreMessage(QtWarningMsg, qPrintable(warning1)); + + QObject *object = component.create(); + QVERIFY(object != 0); + + QFontDatabase database; + QCOMPARE(object->property("test2"), QVariant::fromValue(database.families())); + + delete object; +} + +void tst_qqmlqt::quit() +{ + QQmlComponent component(&engine, testFileUrl("quit.qml")); + + QSignalSpy spy(&engine, SIGNAL(quit())); + QObject *object = component.create(); + QVERIFY(object != 0); + QCOMPARE(spy.count(), 1); + + delete object; +} + +void tst_qqmlqt::resolvedUrl() +{ + QQmlComponent component(&engine, testFileUrl("resolvedUrl.qml")); + + QObject *object = component.create(); + QVERIFY(object != 0); + + QCOMPARE(object->property("result").toString(), component.url().toString()); + QCOMPARE(object->property("isString").toBool(), true); + + delete object; +} + +QTEST_MAIN(tst_qqmlqt) + +#include "tst_qqmlqt.moc" diff --git a/tests/auto/qml/qqmlsqldatabase/data/README b/tests/auto/qml/qqmlsqldatabase/data/README new file mode 100644 index 0000000000..7efca3a972 --- /dev/null +++ b/tests/auto/qml/qqmlsqldatabase/data/README @@ -0,0 +1,3 @@ +These tests are executed in sequence - the database persist until the end of the +testing. This is done to better exercise the persistence of the database, since +that is how it is used. diff --git a/tests/auto/qml/qqmlsqldatabase/data/changeversion.js b/tests/auto/qml/qqmlsqldatabase/data/changeversion.js new file mode 100644 index 0000000000..178ff7c4af --- /dev/null +++ b/tests/auto/qml/qqmlsqldatabase/data/changeversion.js @@ -0,0 +1,55 @@ +.import QtQuick.LocalStorage 2.0 as Sql + +function test() { + var r="transaction_not_finished"; + + var db = Sql.openDatabaseSync("QmlTestDB-changeversion", "", "Test database from Qt autotests", 1000000, + function(db) { + db.changeVersion("","1.0") + db.transaction(function(tx){ + tx.executeSql('CREATE TABLE Greeting(salutation TEXT, salutee TEXT)'); + }) + }); + + db.transaction(function(tx){ + tx.executeSql('INSERT INTO Greeting VALUES ("Hello", "world")'); + tx.executeSql('INSERT INTO Greeting VALUES ("Goodbye", "cruel world")'); + }); + + + db = Sql.openDatabaseSync("QmlTestDB-changeversion", "", "Test database from Qt autotests", 1000000); + + if (db.version == "1.0") + db.changeVersion("1.0","2.0",function(tx) + { + tx.executeSql('CREATE TABLE Utterance(type TEXT, phrase TEXT)') + var rs = tx.executeSql('SELECT * FROM Greeting'); + for (var i=0; i +#include +#include +#include +#include +#include +/* +#include +#include +#include +#include +*/ +#include +#include +#include +#include "../../shared/util.h" + +class tst_qqmlsqldatabase : public QQmlDataTest +{ + Q_OBJECT +public: + tst_qqmlsqldatabase() + { + qApp->setApplicationName("tst_qqmlsqldatabase"); + qApp->setOrganizationName("Nokia"); + qApp->setOrganizationDomain("nokia.com"); + engine = new QQmlEngine; + } + + ~tst_qqmlsqldatabase() + { + delete engine; + } + +private slots: + void initTestCase(); + + void checkDatabasePath(); + + void testQml_data(); + void testQml(); + void testQml_cleanopen_data(); + void testQml_cleanopen(); + void totalDatabases(); + + void cleanupTestCase(); + +private: + QString dbDir() const; + QQmlEngine *engine; +}; + +void removeRecursive(const QString& dirname) +{ + QDir dir(dirname); + QFileInfoList entries(dir.entryInfoList(QDir::Dirs|QDir::Files|QDir::NoDotAndDotDot)); + for (int i = 0; i < entries.count(); ++i) + if (entries[i].isDir()) + removeRecursive(entries[i].filePath()); + else + dir.remove(entries[i].fileName()); + QDir().rmdir(dirname); +} + +void tst_qqmlsqldatabase::initTestCase() +{ + QQmlDataTest::initTestCase(); + removeRecursive(dbDir()); + QDir().mkpath(dbDir()); +} + +void tst_qqmlsqldatabase::cleanupTestCase() +{ + removeRecursive(dbDir()); +} + +QString tst_qqmlsqldatabase::dbDir() const +{ + static QString tmpd = QDir::tempPath()+"/tst_qqmlsqldatabase_output-" + + QDateTime::currentDateTime().toString(QLatin1String("yyyyMMddhhmmss")); + return tmpd; +} + +void tst_qqmlsqldatabase::checkDatabasePath() +{ + // Check default storage path (we can't use it since we don't want to mess with user's data) + QVERIFY(engine->offlineStoragePath().contains("tst_qqmlsqldatabase")); + QVERIFY(engine->offlineStoragePath().contains("OfflineStorage")); +} + +static const int total_databases_created_by_tests = 12; +void tst_qqmlsqldatabase::testQml_data() +{ + QTest::addColumn("jsfile"); // The input file + + // Each test should use a newly named DB to avoid inter-test dependencies + QTest::newRow("creation") << "creation.js"; + QTest::newRow("creation-a") << "creation-a.js"; + QTest::newRow("creation") << "creation.js"; + QTest::newRow("error-creation") << "error-creation.js"; // re-uses above DB + QTest::newRow("changeversion") << "changeversion.js"; + QTest::newRow("readonly") << "readonly.js"; + QTest::newRow("readonly-error") << "readonly-error.js"; + QTest::newRow("selection") << "selection.js"; + QTest::newRow("selection-bindnames") << "selection-bindnames.js"; + QTest::newRow("iteration") << "iteration.js"; + QTest::newRow("iteration-forwardonly") << "iteration-forwardonly.js"; + QTest::newRow("error-a") << "error-a.js"; + QTest::newRow("error-notransaction") << "error-notransaction.js"; + QTest::newRow("error-outsidetransaction") << "error-outsidetransaction.js"; // reuse above + QTest::newRow("reopen1") << "reopen1.js"; + QTest::newRow("reopen2") << "reopen2.js"; // re-uses above DB + + // If you add a test, you should usually use a new database in the + // test - in which case increment total_databases_created_by_tests above. +} + +/* +class QWebPageWithJavaScriptConsoleMessages : public QWebPage { +public: + void javaScriptConsoleMessage(const QString& message, int lineNumber, const QString& sourceID) + { + qWarning() << sourceID << ":" << lineNumber << ":" << message; + } +}; + +void tst_qqmlsqldatabase::validateAgainstWebkit() +{ + // Validates tests against WebKit (HTML5) support. + // + QFETCH(QString, jsfile); + QFETCH(QString, result); + QFETCH(int, databases); + + QFile f(jsfile); + QVERIFY(f.open(QIODevice::ReadOnly)); + QString js=f.readAll(); + + QWebPageWithJavaScriptConsoleMessages webpage; + webpage.settings()->setOfflineStoragePath(dbDir()); + webpage.settings()->setAttribute(QWebSettings::OfflineStorageDatabaseEnabled, true); + + QEXPECT_FAIL("","WebKit doesn't support openDatabaseSync yet", Continue); + QCOMPARE(webpage.mainFrame()->evaluateJavaScript(js).toString(),result); + + QTest::qWait(100); // WebKit crashes if you quit it too fast + + QWebSecurityOrigin origin = webpage.mainFrame()->securityOrigin(); + QList dbs = origin.databases(); + QCOMPARE(dbs.count(), databases); +} +*/ + +void tst_qqmlsqldatabase::testQml() +{ + // Tests QML SQL Database support with tests + // that have been validated against Webkit. + // + QFETCH(QString, jsfile); + + QString qml= + "import QtQuick 2.0\n" + "import \""+jsfile+"\" as JS\n" + "Text { text: JS.test() }"; + + engine->setOfflineStoragePath(dbDir()); + QQmlComponent component(engine); + component.setData(qml.toUtf8(), testFileUrl("empty.qml")); // just a file for relative local imports + QVERIFY(!component.isError()); + QQuickText *text = qobject_cast(component.create()); + QVERIFY(text != 0); + QCOMPARE(text->text(),QString("passed")); +} + +void tst_qqmlsqldatabase::testQml_cleanopen_data() +{ + QTest::addColumn("jsfile"); // The input file + QTest::newRow("reopen1") << "reopen1.js"; + QTest::newRow("reopen2") << "reopen2.js"; + QTest::newRow("error-creation") << "error-creation.js"; // re-uses creation DB +} + +void tst_qqmlsqldatabase::testQml_cleanopen() +{ + // Same as testQml, but clean connections between tests, + // making it more like the tests are running in new processes. + testQml(); + + engine->collectGarbage(); + + foreach (QString dbname, QSqlDatabase::connectionNames()) { + QSqlDatabase::removeDatabase(dbname); + } +} + +void tst_qqmlsqldatabase::totalDatabases() +{ + QCOMPARE(QDir(dbDir()+"/Databases").entryInfoList(QDir::Files|QDir::NoDotAndDotDot).count(), total_databases_created_by_tests*2); +} + +QTEST_MAIN(tst_qqmlsqldatabase) + +#include "tst_qqmlsqldatabase.moc" diff --git a/tests/auto/qml/qqmltranslation/data/idtranslation.qml b/tests/auto/qml/qqmltranslation/data/idtranslation.qml new file mode 100644 index 0000000000..b128a1e578 --- /dev/null +++ b/tests/auto/qml/qqmltranslation/data/idtranslation.qml @@ -0,0 +1,8 @@ +import QtQuick 2.0 + +QtObject { + property string _idTranslation2: QT_TRID_NOOP("qtn_hello_world") + property string idTranslation: qsTrId("qtn_hello_world") + property string idTranslation2: qsTrId(_idTranslation2) + property string idTranslation3: if (1) qsTrId("qtn_hello_world") +} diff --git a/tests/auto/qml/qqmltranslation/data/qml_fr.qm b/tests/auto/qml/qqmltranslation/data/qml_fr.qm new file mode 100644 index 0000000000..252022515a Binary files /dev/null and b/tests/auto/qml/qqmltranslation/data/qml_fr.qm differ diff --git a/tests/auto/qml/qqmltranslation/data/qml_fr.ts b/tests/auto/qml/qqmltranslation/data/qml_fr.ts new file mode 100644 index 0000000000..b003e239bc --- /dev/null +++ b/tests/auto/qml/qqmltranslation/data/qml_fr.ts @@ -0,0 +1,43 @@ + + + + + CustomContext + + + + goodbye + au revoir + + + + see ya + informal 'goodbye' + à plus tard + + + + translation + + + + hello + bonjour + + + + hi + informal 'hello' + salut + + + + + %n duck(s) + + %n canard + %n canards + + + + diff --git a/tests/auto/qml/qqmltranslation/data/qmlid_fr.qm b/tests/auto/qml/qqmltranslation/data/qmlid_fr.qm new file mode 100644 index 0000000000..265164916f Binary files /dev/null and b/tests/auto/qml/qqmltranslation/data/qmlid_fr.qm differ diff --git a/tests/auto/qml/qqmltranslation/data/qmlid_fr.ts b/tests/auto/qml/qqmltranslation/data/qmlid_fr.ts new file mode 100644 index 0000000000..bff39b80b6 --- /dev/null +++ b/tests/auto/qml/qqmltranslation/data/qmlid_fr.ts @@ -0,0 +1,13 @@ + + + + + + + + + + bonjour tout le monde + + + diff --git a/tests/auto/qml/qqmltranslation/data/translation.qml b/tests/auto/qml/qqmltranslation/data/translation.qml new file mode 100644 index 0000000000..8435bedb28 --- /dev/null +++ b/tests/auto/qml/qqmltranslation/data/translation.qml @@ -0,0 +1,21 @@ +import QtQuick 2.0 + +QtObject { + property string basic: qsTr("hello") + property string basic2: qsTranslate("CustomContext", "goodbye") + property string basic3: if (1) qsTr("hello") + + property string disambiguation: qsTr("hi", "informal 'hello'") + property string disambiguation2: qsTranslate("CustomContext", "see ya", "informal 'goodbye'") + property string disambiguation3: if (1) qsTr("hi", "informal 'hello'") + + property string _noop: QT_TR_NOOP("hello") + property string _noop2: QT_TRANSLATE_NOOP("CustomContext", "goodbye") + property string noop: qsTr(_noop) + property string noop2: qsTranslate("CustomContext", _noop2) + + property string singular: qsTr("%n duck(s)", "", 1) + property string singular2: if (1) qsTr("%n duck(s)", "", 1) + property string plural: qsTr("%n duck(s)", "", 2) + property string plural2: if (1) qsTr("%n duck(s)", "", 2) +} diff --git a/tests/auto/qml/qqmltranslation/data/translation.qrc b/tests/auto/qml/qqmltranslation/data/translation.qrc new file mode 100644 index 0000000000..2e2d0a0497 --- /dev/null +++ b/tests/auto/qml/qqmltranslation/data/translation.qrc @@ -0,0 +1,6 @@ + + + translation.qml + qml_fr.qm + + diff --git a/tests/auto/qml/qqmltranslation/qqmltranslation.pro b/tests/auto/qml/qqmltranslation/qqmltranslation.pro new file mode 100644 index 0000000000..d3f98e181f --- /dev/null +++ b/tests/auto/qml/qqmltranslation/qqmltranslation.pro @@ -0,0 +1,16 @@ +CONFIG += testcase +TARGET = tst_qqmltranslation +macx:CONFIG -= app_bundle + +SOURCES += tst_qqmltranslation.cpp +RESOURCES += data/translation.qrc + +include (../../shared/util.pri) + +testDataFiles.files = data +testDataFiles.path = . +DEPLOYMENT += testDataFiles + +CONFIG += parallel_test + +QT += core-private gui-private qml-private testlib diff --git a/tests/auto/qml/qqmltranslation/tst_qqmltranslation.cpp b/tests/auto/qml/qqmltranslation/tst_qqmltranslation.cpp new file mode 100644 index 0000000000..077fa18f5f --- /dev/null +++ b/tests/auto/qml/qqmltranslation/tst_qqmltranslation.cpp @@ -0,0 +1,137 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include +#include +#include +#include "../../shared/util.h" + +class tst_qqmltranslation : public QQmlDataTest +{ + Q_OBJECT +public: + tst_qqmltranslation() {} + +private slots: + void translation(); + void idTranslation(); + void translationInQrc(); +}; + +void tst_qqmltranslation::translation() +{ + QTranslator translator; + translator.load(QLatin1String("qml_fr"), dataDirectory()); + QCoreApplication::installTranslator(&translator); + + QQmlEngine engine; + QQmlComponent component(&engine, testFileUrl("translation.qml")); + QObject *object = component.create(); + QVERIFY(object != 0); + + QCOMPARE(object->property("basic").toString(), QLatin1String("bonjour")); + QCOMPARE(object->property("basic2").toString(), QLatin1String("au revoir")); + QCOMPARE(object->property("basic3").toString(), QLatin1String("bonjour")); + QCOMPARE(object->property("disambiguation").toString(), QLatin1String("salut")); + QCOMPARE(object->property("disambiguation2").toString(), QString::fromUtf8("\xc3\xa0 plus tard")); + QCOMPARE(object->property("disambiguation3").toString(), QLatin1String("salut")); + QCOMPARE(object->property("noop").toString(), QLatin1String("bonjour")); + QCOMPARE(object->property("noop2").toString(), QLatin1String("au revoir")); + QCOMPARE(object->property("singular").toString(), QLatin1String("1 canard")); + QCOMPARE(object->property("singular2").toString(), QLatin1String("1 canard")); + QCOMPARE(object->property("plural").toString(), QLatin1String("2 canards")); + QCOMPARE(object->property("plural2").toString(), QLatin1String("2 canards")); + + QCoreApplication::removeTranslator(&translator); + delete object; +} + +void tst_qqmltranslation::idTranslation() +{ + QTranslator translator; + translator.load(QLatin1String("qmlid_fr"), dataDirectory()); + QCoreApplication::installTranslator(&translator); + + QQmlEngine engine; + QQmlComponent component(&engine, testFileUrl("idtranslation.qml")); + QObject *object = component.create(); + QVERIFY(object != 0); + + QCOMPARE(object->property("idTranslation").toString(), QLatin1String("bonjour tout le monde")); + QCOMPARE(object->property("idTranslation2").toString(), QLatin1String("bonjour tout le monde")); + QCOMPARE(object->property("idTranslation3").toString(), QLatin1String("bonjour tout le monde")); + + QCoreApplication::removeTranslator(&translator); + delete object; +} + +void tst_qqmltranslation::translationInQrc() +{ + QTranslator translator; + translator.load(":/qml_fr.qm"); + QCoreApplication::installTranslator(&translator); + + QQmlEngine engine; + QQmlComponent component(&engine, QUrl("qrc:/translation.qml")); + QObject *object = component.create(); + QVERIFY(object != 0); + + QCOMPARE(object->property("basic").toString(), QLatin1String("bonjour")); + QCOMPARE(object->property("basic2").toString(), QLatin1String("au revoir")); + QCOMPARE(object->property("basic3").toString(), QLatin1String("bonjour")); + QCOMPARE(object->property("disambiguation").toString(), QLatin1String("salut")); + QCOMPARE(object->property("disambiguation2").toString(), QString::fromUtf8("\xc3\xa0 plus tard")); + QCOMPARE(object->property("disambiguation3").toString(), QLatin1String("salut")); + QCOMPARE(object->property("noop").toString(), QLatin1String("bonjour")); + QCOMPARE(object->property("noop2").toString(), QLatin1String("au revoir")); + QCOMPARE(object->property("singular").toString(), QLatin1String("1 canard")); + QCOMPARE(object->property("singular2").toString(), QLatin1String("1 canard")); + QCOMPARE(object->property("plural").toString(), QLatin1String("2 canards")); + QCOMPARE(object->property("plural2").toString(), QLatin1String("2 canards")); + + QCoreApplication::removeTranslator(&translator); + delete object; +} + +QTEST_MAIN(tst_qqmltranslation) + +#include "tst_qqmltranslation.moc" diff --git a/tests/auto/qml/qqmlvaluetypes/data/BindingsSpliceCorrectlyType.qml b/tests/auto/qml/qqmlvaluetypes/data/BindingsSpliceCorrectlyType.qml new file mode 100644 index 0000000000..f625d081e5 --- /dev/null +++ b/tests/auto/qml/qqmlvaluetypes/data/BindingsSpliceCorrectlyType.qml @@ -0,0 +1,7 @@ +import Test 1.0 + +MyTypeObject { + property bool boldProperty: false + + font.bold: boldProperty +} diff --git a/tests/auto/qml/qqmlvaluetypes/data/BindingsSpliceCorrectlyType4.qml b/tests/auto/qml/qqmlvaluetypes/data/BindingsSpliceCorrectlyType4.qml new file mode 100644 index 0000000000..0bdccce5be --- /dev/null +++ b/tests/auto/qml/qqmlvaluetypes/data/BindingsSpliceCorrectlyType4.qml @@ -0,0 +1,7 @@ +import Test 1.0 + +MyTypeObject { + property int dataProperty: 7 + + point: Qt.point(dataProperty, dataProperty) +} diff --git a/tests/auto/qml/qqmlvaluetypes/data/BindingsSpliceCorrectlyType5.qml b/tests/auto/qml/qqmlvaluetypes/data/BindingsSpliceCorrectlyType5.qml new file mode 100644 index 0000000000..151c49971e --- /dev/null +++ b/tests/auto/qml/qqmlvaluetypes/data/BindingsSpliceCorrectlyType5.qml @@ -0,0 +1,7 @@ +import Test 1.0 + +MyTypeObject { + property int dataProperty: 7 + + point.x: dataProperty +} diff --git a/tests/auto/qml/qqmlvaluetypes/data/autoBindingRemoval.2.qml b/tests/auto/qml/qqmlvaluetypes/data/autoBindingRemoval.2.qml new file mode 100644 index 0000000000..ce2e82d0f8 --- /dev/null +++ b/tests/auto/qml/qqmlvaluetypes/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/qml/qqmlvaluetypes/data/autoBindingRemoval.3.qml b/tests/auto/qml/qqmlvaluetypes/data/autoBindingRemoval.3.qml new file mode 100644 index 0000000000..d431b4ae08 --- /dev/null +++ b/tests/auto/qml/qqmlvaluetypes/data/autoBindingRemoval.3.qml @@ -0,0 +1,10 @@ +import Test 1.0 + +MyTypeObject { + property variant value + + rect: value + + onRunScript: { rect.x = 44 } +} + diff --git a/tests/auto/qml/qqmlvaluetypes/data/autoBindingRemoval.qml b/tests/auto/qml/qqmlvaluetypes/data/autoBindingRemoval.qml new file mode 100644 index 0000000000..a8a72f515b --- /dev/null +++ b/tests/auto/qml/qqmlvaluetypes/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/qml/qqmlvaluetypes/data/bindingAssignment.qml b/tests/auto/qml/qqmlvaluetypes/data/bindingAssignment.qml new file mode 100644 index 0000000000..a65218669b --- /dev/null +++ b/tests/auto/qml/qqmlvaluetypes/data/bindingAssignment.qml @@ -0,0 +1,7 @@ +import Test 1.0 + +MyTypeObject { + property int value: 10 + + rect.x: value +} diff --git a/tests/auto/qml/qqmlvaluetypes/data/bindingConflict.qml b/tests/auto/qml/qqmlvaluetypes/data/bindingConflict.qml new file mode 100644 index 0000000000..fd25c9f0a7 --- /dev/null +++ b/tests/auto/qml/qqmlvaluetypes/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/qml/qqmlvaluetypes/data/bindingRead.qml b/tests/auto/qml/qqmlvaluetypes/data/bindingRead.qml new file mode 100644 index 0000000000..538d776fba --- /dev/null +++ b/tests/auto/qml/qqmlvaluetypes/data/bindingRead.qml @@ -0,0 +1,5 @@ +import Test 1.0 + +MyTypeObject { + property int value: rect.x +} diff --git a/tests/auto/qml/qqmlvaluetypes/data/bindingVariantCopy.qml b/tests/auto/qml/qqmlvaluetypes/data/bindingVariantCopy.qml new file mode 100644 index 0000000000..3a48c8bdb1 --- /dev/null +++ b/tests/auto/qml/qqmlvaluetypes/data/bindingVariantCopy.qml @@ -0,0 +1,13 @@ +import Test 1.0 + +MyTypeObject { + property variant object + object: MyTypeObject { + rect.x: 19 + rect.y: 33 + rect.width: 5 + rect.height: 99 + } + + rect: object.rect +} diff --git a/tests/auto/qml/qqmlvaluetypes/data/bindingsSpliceCorrectly.1.qml b/tests/auto/qml/qqmlvaluetypes/data/bindingsSpliceCorrectly.1.qml new file mode 100644 index 0000000000..2a1b936da6 --- /dev/null +++ b/tests/auto/qml/qqmlvaluetypes/data/bindingsSpliceCorrectly.1.qml @@ -0,0 +1,29 @@ +import Test 1.0 +import QtQuick 2.0 + +BindingsSpliceCorrectlyType { + property bool test: false + + property bool italicProperty: false + + font.italic: italicProperty + + Component.onCompleted: { + // Test initial state + if (font.italic != false) return; + if (font.bold != false) return; + + // Test italic binding worked + italicProperty = true; + + if (font.italic != true) return; + if (font.bold != false) return; + + // Test bold binding worked + boldProperty = true; + if (font.italic != true) return; + if (font.bold != true) return; + + test = true; + } +} diff --git a/tests/auto/qml/qqmlvaluetypes/data/bindingsSpliceCorrectly.2.qml b/tests/auto/qml/qqmlvaluetypes/data/bindingsSpliceCorrectly.2.qml new file mode 100644 index 0000000000..84b465c565 --- /dev/null +++ b/tests/auto/qml/qqmlvaluetypes/data/bindingsSpliceCorrectly.2.qml @@ -0,0 +1,31 @@ +import Test 1.0 +import QtQuick 2.0 + +BindingsSpliceCorrectlyType { + property bool test: false + + property bool italicProperty: false + + font.italic: italicProperty + font.bold: false + + Component.onCompleted: { + // Test initial state + if (font.italic != false) return; + if (font.bold != false) return; + + // Test italic binding worked + italicProperty = true; + + if (font.italic != true) return; + if (font.bold != false) return; + + // Test bold binding was removed by constant write + boldProperty = true; + if (font.italic != true) return; + if (font.bold != false) return; + + test = true; + } +} + diff --git a/tests/auto/qml/qqmlvaluetypes/data/bindingsSpliceCorrectly.3.qml b/tests/auto/qml/qqmlvaluetypes/data/bindingsSpliceCorrectly.3.qml new file mode 100644 index 0000000000..f1212f8039 --- /dev/null +++ b/tests/auto/qml/qqmlvaluetypes/data/bindingsSpliceCorrectly.3.qml @@ -0,0 +1,36 @@ +import Test 1.0 +import QtQuick 2.0 + +BindingsSpliceCorrectlyType { + property bool test: false + + property bool italicProperty: false + property bool boldProperty2: false + + font.italic: italicProperty + font.bold: boldProperty2 + + Component.onCompleted: { + // Test initial state + if (font.italic != false) return; + if (font.bold != false) return; + + // Test italic binding worked + italicProperty = true; + + if (font.italic != true) return; + if (font.bold != false) return; + + // Test bold binding was overridden + boldProperty = true; + if (font.italic != true) return; + if (font.bold != false) return; + + boldProperty2 = true; + if (font.italic != true) return; + if (font.bold != true) return; + + test = true; + } +} + diff --git a/tests/auto/qml/qqmlvaluetypes/data/bindingsSpliceCorrectly.4.qml b/tests/auto/qml/qqmlvaluetypes/data/bindingsSpliceCorrectly.4.qml new file mode 100644 index 0000000000..9c5e950660 --- /dev/null +++ b/tests/auto/qml/qqmlvaluetypes/data/bindingsSpliceCorrectly.4.qml @@ -0,0 +1,27 @@ +import Test 1.0 +import QtQuick 2.0 + +BindingsSpliceCorrectlyType4 { + property bool test: false + + property int dataProperty2: 8 + + point.x: dataProperty2 + + Component.onCompleted: { + if (point.x != 8) return; + if (point.y != 4) return; + + dataProperty = 9; + + if (point.x != 8) return; + if (point.y != 4) return; + + dataProperty2 = 13; + + if (point.x != 13) return; + if (point.y != 4) return; + + test = true; + } +} diff --git a/tests/auto/qml/qqmlvaluetypes/data/bindingsSpliceCorrectly.5.qml b/tests/auto/qml/qqmlvaluetypes/data/bindingsSpliceCorrectly.5.qml new file mode 100644 index 0000000000..7d87ba1782 --- /dev/null +++ b/tests/auto/qml/qqmlvaluetypes/data/bindingsSpliceCorrectly.5.qml @@ -0,0 +1,27 @@ +import Test 1.0 +import QtQuick 2.0 + +BindingsSpliceCorrectlyType5 { + property bool test: false + + property int dataProperty2: 8 + + point: Qt.point(dataProperty2, dataProperty2); + + Component.onCompleted: { + if (point.x != 8) return; + if (point.y != 8) return; + + dataProperty = 9; + + if (point.x != 8) return; + if (point.y != 8) return; + + dataProperty2 = 13; + + if (point.x != 13) return; + if (point.y != 13) return; + + test = true; + } +} diff --git a/tests/auto/qml/qqmlvaluetypes/data/color_compare.qml b/tests/auto/qml/qqmlvaluetypes/data/color_compare.qml new file mode 100644 index 0000000000..8701dae612 --- /dev/null +++ b/tests/auto/qml/qqmlvaluetypes/data/color_compare.qml @@ -0,0 +1,37 @@ +import Test 1.0 + +MyTypeObject { + property real v_r: color.r + property real v_g: color.g + property real v_b: color.b + property real v_a: color.a + property variant copy: color + property string colorToString: color.toString() + + // compare different colors + property bool colorEqualsIdenticalRgba: (color == Qt.rgba(0.2, 0.88, 0.6, 0.34)) // true + property bool colorEqualsDifferentAlpha: (color == Qt.rgba(0.2, 0.88, 0.6, 0.44)) // false + property bool colorEqualsDifferentRgba: (color == Qt.rgba(0.3, 0.98, 0.7, 0.44)) // false + + // compare different color.toString()s + property bool colorToStringEqualsColorString: (color.toString() == colorToString) // true + property bool colorToStringEqualsDifferentAlphaString: (color.toString() == Qt.rgba(0.2, 0.88, 0.6, 0.44).toString()) // true + property bool colorToStringEqualsDifferentRgbaString: (color.toString() == Qt.rgba(0.3, 0.98, 0.7, 0.44).toString()) // false + + // compare colors to strings + property bool colorEqualsColorString: (color == colorToString) // false + property bool colorEqualsDifferentAlphaString: (color == Qt.rgba(0.2, 0.88, 0.6, 0.44).toString()) // false + property bool colorEqualsDifferentRgbaString: (color == Qt.rgba(0.3, 0.98, 0.7, 0.44).toString()) // false + + // compare colors to various value types + property bool equalsColor: (color == Qt.rgba(0.2, 0.88, 0.6, 0.34)) // true + property bool equalsVector3d: (color == Qt.vector3d(1, 2, 3)) // false + property bool equalsSize: (color == Qt.size(1912, 1913)) // false + property bool equalsPoint: (color == Qt.point(10, 4)) // false + property bool equalsRect: (color == Qt.rect(2, 3, 109, 102)) // false + + // ensure comparison directionality doesn't matter + property bool equalsColorRHS: (Qt.rgba(0.2, 0.88, 0.6, 0.34) == color) // true + property bool colorEqualsCopy: (color == copy) // true + property bool copyEqualsColor: (copy == color) // true +} diff --git a/tests/auto/qml/qqmlvaluetypes/data/color_read.qml b/tests/auto/qml/qqmlvaluetypes/data/color_read.qml new file mode 100644 index 0000000000..bc92b1e5f9 --- /dev/null +++ b/tests/auto/qml/qqmlvaluetypes/data/color_read.qml @@ -0,0 +1,9 @@ +import Test 1.0 + +MyTypeObject { + property real v_r: color.r + property real v_g: color.g + property real v_b: color.b + property real v_a: color.a + property variant copy: color +} diff --git a/tests/auto/qml/qqmlvaluetypes/data/color_write.qml b/tests/auto/qml/qqmlvaluetypes/data/color_write.qml new file mode 100644 index 0000000000..3f1bad4aa6 --- /dev/null +++ b/tests/auto/qml/qqmlvaluetypes/data/color_write.qml @@ -0,0 +1,8 @@ +import Test 1.0 + +MyTypeObject { + color.r: if (true) 0.5 + color.g: if (true) 0.38 + color.b: if (true) 0.3 + color.a: if (true) 0.7 +} diff --git a/tests/auto/qml/qqmlvaluetypes/data/conflicting.1.qml b/tests/auto/qml/qqmlvaluetypes/data/conflicting.1.qml new file mode 100644 index 0000000000..923922c55a --- /dev/null +++ b/tests/auto/qml/qqmlvaluetypes/data/conflicting.1.qml @@ -0,0 +1,42 @@ +import QtQuick 2.0 + +Rectangle { + id: root + + width: 800 + height: 600 + + property alias font: myText.font + + property int myPixelSize: 12 + property int myPixelSize2: 24 + + Text { + id: other + font.pixelSize: 6 + } + + Text { + id: myText + + text: "Hello world!" + font.pixelSize: myPixelSize + } + + states: State { + name: "Swapped" + PropertyChanges { + target: myText + font: other.font + } + } + + function toggle() { + if (root.state == "") root.state = "Swapped"; else root.state = ""; + } + + MouseArea { + anchors.fill: parent + onClicked: { if (root.state == "") root.state = "Swapped"; else root.state = "";} + } +} diff --git a/tests/auto/qml/qqmlvaluetypes/data/conflicting.2.qml b/tests/auto/qml/qqmlvaluetypes/data/conflicting.2.qml new file mode 100644 index 0000000000..9804af4df6 --- /dev/null +++ b/tests/auto/qml/qqmlvaluetypes/data/conflicting.2.qml @@ -0,0 +1,42 @@ +import QtQuick 2.0 + +Rectangle { + id: root + + width: 800 + height: 600 + + property alias font: myText.font + + property int myPixelSize: 12 + property int myPixelSize2: 24 + + Text { + id: other + font.pixelSize: 6 + } + + Text { + id: myText + + text: "Hello world!" + font: other.font + } + + states: State { + name: "Swapped" + PropertyChanges { + target: myText + font.pixelSize: myPixelSize + } + } + + function toggle() { + if (root.state == "") root.state = "Swapped"; else root.state = ""; + } + + MouseArea { + anchors.fill: parent + onClicked: { if (root.state == "") root.state = "Swapped"; else root.state = "";} + } +} diff --git a/tests/auto/qml/qqmlvaluetypes/data/conflicting.3.qml b/tests/auto/qml/qqmlvaluetypes/data/conflicting.3.qml new file mode 100644 index 0000000000..b5bb7f8ccc --- /dev/null +++ b/tests/auto/qml/qqmlvaluetypes/data/conflicting.3.qml @@ -0,0 +1,42 @@ +import QtQuick 2.0 + +Rectangle { + id: root + + width: 800 + height: 600 + + property alias font: myText.font + + property int myPixelSize: 12 + property int myPixelSize2: 24 + + Text { + id: other + font.pixelSize: 6 + } + + Text { + id: myText + + text: "Hello world!" + font.pixelSize: myPixelSize + } + + states: State { + name: "Swapped" + PropertyChanges { + target: myText + font.pixelSize: myPixelSize2 + } + } + + function toggle() { + if (root.state == "") root.state = "Swapped"; else root.state = ""; + } + + MouseArea { + anchors.fill: parent + onClicked: { if (root.state == "") root.state = "Swapped"; else root.state = "";} + } +} diff --git a/tests/auto/qml/qqmlvaluetypes/data/deletedObject.js b/tests/auto/qml/qqmlvaluetypes/data/deletedObject.js new file mode 100644 index 0000000000..af298ffbd0 --- /dev/null +++ b/tests/auto/qml/qqmlvaluetypes/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/qml/qqmlvaluetypes/data/deletedObject.qml b/tests/auto/qml/qqmlvaluetypes/data/deletedObject.qml new file mode 100644 index 0000000000..4f7ad39db0 --- /dev/null +++ b/tests/auto/qml/qqmlvaluetypes/data/deletedObject.qml @@ -0,0 +1,11 @@ +import Test 1.0 +import QtQuick 2.0 +import "deletedObject.js" as JS + +MyTypeObject { + property variant object + + object: MyTypeObject {} + Component.onCompleted: JS.startup() + onRunScript: JS.afterDelete() +} diff --git a/tests/auto/qml/qqmlvaluetypes/data/enums.1.qml b/tests/auto/qml/qqmlvaluetypes/data/enums.1.qml new file mode 100644 index 0000000000..cb01a80669 --- /dev/null +++ b/tests/auto/qml/qqmlvaluetypes/data/enums.1.qml @@ -0,0 +1,6 @@ +import Test 1.0 + +MyTypeObject { + font.capitalization: "AllUppercase" +} + diff --git a/tests/auto/qml/qqmlvaluetypes/data/enums.2.qml b/tests/auto/qml/qqmlvaluetypes/data/enums.2.qml new file mode 100644 index 0000000000..93f1ed59bc --- /dev/null +++ b/tests/auto/qml/qqmlvaluetypes/data/enums.2.qml @@ -0,0 +1,6 @@ +import Test 1.0 + +MyTypeObject { + font.capitalization: if (1) "AllUppercase" +} + diff --git a/tests/auto/qml/qqmlvaluetypes/data/enums.3.qml b/tests/auto/qml/qqmlvaluetypes/data/enums.3.qml new file mode 100644 index 0000000000..cc7861a122 --- /dev/null +++ b/tests/auto/qml/qqmlvaluetypes/data/enums.3.qml @@ -0,0 +1,6 @@ +import Test 1.0 +import QtQuick 2.0 + +MyTypeObject { + font.capitalization: Font.AllUppercase +} diff --git a/tests/auto/qml/qqmlvaluetypes/data/enums.4.qml b/tests/auto/qml/qqmlvaluetypes/data/enums.4.qml new file mode 100644 index 0000000000..cf41c90b90 --- /dev/null +++ b/tests/auto/qml/qqmlvaluetypes/data/enums.4.qml @@ -0,0 +1,7 @@ +import Test 1.0 +import QtQuick 2.0 as MyQt + +MyTypeObject { + font.capitalization: MyQt.Font.AllUppercase +} + diff --git a/tests/auto/qml/qqmlvaluetypes/data/enums.5.qml b/tests/auto/qml/qqmlvaluetypes/data/enums.5.qml new file mode 100644 index 0000000000..de279dba6c --- /dev/null +++ b/tests/auto/qml/qqmlvaluetypes/data/enums.5.qml @@ -0,0 +1,10 @@ +import Test 1.0 +import QtQuick 2.0 as MyQt + +MyTypeObject { + MyQt.Component.onCompleted: { + font.capitalization = MyQt.Font.AllUppercase + } +} + + diff --git a/tests/auto/qml/qqmlvaluetypes/data/font_compare.qml b/tests/auto/qml/qqmlvaluetypes/data/font_compare.qml new file mode 100644 index 0000000000..efbb0e3d0b --- /dev/null +++ b/tests/auto/qml/qqmlvaluetypes/data/font_compare.qml @@ -0,0 +1,31 @@ +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 variant copy: font + property string tostring: font.toString() + + // compare to string + property bool equalsString: (font == tostring) + + // compare fonts to various value types + property bool equalsColor: (font == Qt.rgba(0.2, 0.88, 0.6, 0.34)) // false + property bool equalsVector3d: (font == Qt.vector3d(1, 2, 3)) // false + property bool equalsSize: (font == Qt.size(1912, 1913)) // false + property bool equalsPoint: (font == Qt.point(10, 4)) // false + property bool equalsRect: (font == Qt.rect(2, 3, 109, 102)) // false + + property bool equalsSelf: (font == font) // true +} + diff --git a/tests/auto/qml/qqmlvaluetypes/data/font_read.qml b/tests/auto/qml/qqmlvaluetypes/data/font_read.qml new file mode 100644 index 0000000000..d73bb132d3 --- /dev/null +++ b/tests/auto/qml/qqmlvaluetypes/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 variant copy: font +} + diff --git a/tests/auto/qml/qqmlvaluetypes/data/font_write.2.qml b/tests/auto/qml/qqmlvaluetypes/data/font_write.2.qml new file mode 100644 index 0000000000..b559389efb --- /dev/null +++ b/tests/auto/qml/qqmlvaluetypes/data/font_write.2.qml @@ -0,0 +1,6 @@ +import Test 1.0 + +MyTypeObject { + font.pixelSize: 10 +} + diff --git a/tests/auto/qml/qqmlvaluetypes/data/font_write.3.qml b/tests/auto/qml/qqmlvaluetypes/data/font_write.3.qml new file mode 100644 index 0000000000..913ac50738 --- /dev/null +++ b/tests/auto/qml/qqmlvaluetypes/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/qml/qqmlvaluetypes/data/font_write.4.qml b/tests/auto/qml/qqmlvaluetypes/data/font_write.4.qml new file mode 100644 index 0000000000..2ec69d7281 --- /dev/null +++ b/tests/auto/qml/qqmlvaluetypes/data/font_write.4.qml @@ -0,0 +1,7 @@ +import Test 1.0 + +MyTypeObject { + font.pointSize: 19 + font.pixelSize: 10 +} + diff --git a/tests/auto/qml/qqmlvaluetypes/data/font_write.5.qml b/tests/auto/qml/qqmlvaluetypes/data/font_write.5.qml new file mode 100644 index 0000000000..5297a8260d --- /dev/null +++ b/tests/auto/qml/qqmlvaluetypes/data/font_write.5.qml @@ -0,0 +1,14 @@ +import QtQuick 2.0 +import Test 1.0 + +Item { + MyTypeObject { + objectName: "object1" + font.pixelSize: 19 + } + MyTypeObject { + objectName: "object2" + font.pointSize: 14 + } +} + diff --git a/tests/auto/qml/qqmlvaluetypes/data/font_write.qml b/tests/auto/qml/qqmlvaluetypes/data/font_write.qml new file mode 100644 index 0000000000..ff4d0a1004 --- /dev/null +++ b/tests/auto/qml/qqmlvaluetypes/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/qml/qqmlvaluetypes/data/matrix4x4_compare.qml b/tests/auto/qml/qqmlvaluetypes/data/matrix4x4_compare.qml new file mode 100644 index 0000000000..94292302cc --- /dev/null +++ b/tests/auto/qml/qqmlvaluetypes/data/matrix4x4_compare.qml @@ -0,0 +1,35 @@ +import Test 1.0 + +MyTypeObject { + property real v_m11: matrix.m11 + property real v_m12: matrix.m12 + property real v_m13: matrix.m13 + property real v_m14: matrix.m14 + property real v_m21: matrix.m21 + property real v_m22: matrix.m22 + property real v_m23: matrix.m23 + property real v_m24: matrix.m24 + property real v_m31: matrix.m31 + property real v_m32: matrix.m32 + property real v_m33: matrix.m33 + property real v_m34: matrix.m34 + property real v_m41: matrix.m41 + property real v_m42: matrix.m42 + property real v_m43: matrix.m43 + property real v_m44: matrix.m44 + property variant copy: matrix + property string tostring: matrix.toString() + + // compare to string + property bool equalsString: (matrix == tostring) + + // compare matrix4x4s to various value types + property bool equalsColor: (matrix == Qt.rgba(0.2, 0.88, 0.6, 0.34)) // false + property bool equalsVector3d: (matrix == Qt.vector3d(1, 2, 3)) // false + property bool equalsSize: (matrix == Qt.size(1912, 1913)) // false + property bool equalsPoint: (matrix == Qt.point(10, 4)) // false + property bool equalsRect: (matrix == Qt.rect(2, 3, 109, 102)) // false + + property bool equalsSelf: (matrix == matrix) // true +} + diff --git a/tests/auto/qml/qqmlvaluetypes/data/matrix4x4_read.qml b/tests/auto/qml/qqmlvaluetypes/data/matrix4x4_read.qml new file mode 100644 index 0000000000..6c4a68258c --- /dev/null +++ b/tests/auto/qml/qqmlvaluetypes/data/matrix4x4_read.qml @@ -0,0 +1,22 @@ +import Test 1.0 + +MyTypeObject { + property real v_m11: matrix.m11 + property real v_m12: matrix.m12 + property real v_m13: matrix.m13 + property real v_m14: matrix.m14 + property real v_m21: matrix.m21 + property real v_m22: matrix.m22 + property real v_m23: matrix.m23 + property real v_m24: matrix.m24 + property real v_m31: matrix.m31 + property real v_m32: matrix.m32 + property real v_m33: matrix.m33 + property real v_m34: matrix.m34 + property real v_m41: matrix.m41 + property real v_m42: matrix.m42 + property real v_m43: matrix.m43 + property real v_m44: matrix.m44 + property variant copy: matrix +} + diff --git a/tests/auto/qml/qqmlvaluetypes/data/matrix4x4_write.qml b/tests/auto/qml/qqmlvaluetypes/data/matrix4x4_write.qml new file mode 100644 index 0000000000..2a9f154d6f --- /dev/null +++ b/tests/auto/qml/qqmlvaluetypes/data/matrix4x4_write.qml @@ -0,0 +1,21 @@ +import Test 1.0 + +MyTypeObject { + matrix.m11: if (true) 11 + matrix.m12: if (true) 12 + matrix.m13: if (true) 13 + matrix.m14: if (true) 14 + matrix.m21: if (true) 21 + matrix.m22: if (true) 22 + matrix.m23: if (true) 23 + matrix.m24: if (true) 24 + matrix.m31: if (true) 31 + matrix.m32: if (true) 32 + matrix.m33: if (true) 33 + matrix.m34: if (true) 34 + matrix.m41: if (true) 41 + matrix.m42: if (true) 42 + matrix.m43: if (true) 43 + matrix.m44: if (true) 44 +} + diff --git a/tests/auto/qml/qqmlvaluetypes/data/point_compare.qml b/tests/auto/qml/qqmlvaluetypes/data/point_compare.qml new file mode 100644 index 0000000000..c0041b4bb1 --- /dev/null +++ b/tests/auto/qml/qqmlvaluetypes/data/point_compare.qml @@ -0,0 +1,22 @@ +import Test 1.0 + +MyTypeObject { + property int p_x: point.x + property int p_y: point.y + property variant copy: point + property string tostring: point.toString() + + // compare to string + property bool equalsString: (point == tostring) + + // compare points to various value types + property bool equalsColor: (point == Qt.rgba(0.2, 0.88, 0.6, 0.34)) // false + property bool equalsVector3d: (point == Qt.vector3d(1, 2, 3)) // false + property bool equalsSize: (point == Qt.size(1912, 1913)) // false + property bool equalsPoint: (point == Qt.point(10, 4)) // true + property bool equalsRect: (point == Qt.rect(2, 3, 109, 102)) // false + + property bool equalsSelf: (point == point) // true + property bool equalsOther: (point == Qt.point(15, 4)) // false + property bool pointEqualsPointf: (point == pointfpoint) // true +} diff --git a/tests/auto/qml/qqmlvaluetypes/data/point_read.qml b/tests/auto/qml/qqmlvaluetypes/data/point_read.qml new file mode 100644 index 0000000000..4bb6c5384c --- /dev/null +++ b/tests/auto/qml/qqmlvaluetypes/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 variant copy: point +} diff --git a/tests/auto/qml/qqmlvaluetypes/data/point_write.qml b/tests/auto/qml/qqmlvaluetypes/data/point_write.qml new file mode 100644 index 0000000000..063525a6f0 --- /dev/null +++ b/tests/auto/qml/qqmlvaluetypes/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/qml/qqmlvaluetypes/data/pointf_compare.qml b/tests/auto/qml/qqmlvaluetypes/data/pointf_compare.qml new file mode 100644 index 0000000000..0d70137934 --- /dev/null +++ b/tests/auto/qml/qqmlvaluetypes/data/pointf_compare.qml @@ -0,0 +1,22 @@ +import Test 1.0 + +MyTypeObject { + property int p_x: point.x + property int p_y: point.y + property variant copy: point + property string tostring: pointf.toString() + + // compare to string + property bool equalsString: (pointf == tostring) + + // compare pointfs to various value types + property bool equalsColor: (pointf == Qt.rgba(0.2, 0.88, 0.6, 0.34)) // false + property bool equalsVector3d: (pointf == Qt.vector3d(1, 2, 3)) // false + property bool equalsSize: (pointf == Qt.size(1912, 1913)) // false + property bool equalsPoint: (pointf == Qt.point(11.3, -10.9)) // true + property bool equalsRect: (pointf == Qt.rect(2, 3, 109, 102)) // false + + property bool equalsSelf: (pointf == pointf) // true + property bool equalsOther: (pointf == Qt.point(6.3, -4.9)) // false + property bool pointfEqualsPoint: (pointfpoint == point) // true +} diff --git a/tests/auto/qml/qqmlvaluetypes/data/pointf_read.qml b/tests/auto/qml/qqmlvaluetypes/data/pointf_read.qml new file mode 100644 index 0000000000..0eab6daabe --- /dev/null +++ b/tests/auto/qml/qqmlvaluetypes/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 variant copy: pointf +} + diff --git a/tests/auto/qml/qqmlvaluetypes/data/pointf_write.qml b/tests/auto/qml/qqmlvaluetypes/data/pointf_write.qml new file mode 100644 index 0000000000..9ee3fc1bda --- /dev/null +++ b/tests/auto/qml/qqmlvaluetypes/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/qml/qqmlvaluetypes/data/quaternion_compare.qml b/tests/auto/qml/qqmlvaluetypes/data/quaternion_compare.qml new file mode 100644 index 0000000000..0e82f596af --- /dev/null +++ b/tests/auto/qml/qqmlvaluetypes/data/quaternion_compare.qml @@ -0,0 +1,23 @@ +import Test 1.0 + +MyTypeObject { + property real v_scalar: quaternion.scalar + property real v_x: quaternion.x + property real v_y: quaternion.y + property real v_z: quaternion.z + property variant copy: quaternion + property string tostring: quaternion.toString() + + // compare to string + property bool equalsString: (quaternion == tostring) + + // compare quaternions to various value types + property bool equalsColor: (quaternion == Qt.rgba(0.2, 0.88, 0.6, 0.34)) // false + property bool equalsVector3d: (quaternion == Qt.vector3d(1, 2, 3)) // false + property bool equalsSize: (quaternion == Qt.size(1912, 1913)) // false + property bool equalsPoint: (quaternion == Qt.point(10, 4)) // false + property bool equalsRect: (quaternion == Qt.rect(2, 3, 109, 102)) // false + + property bool equalsSelf: (quaternion == quaternion) // true +} + diff --git a/tests/auto/qml/qqmlvaluetypes/data/quaternion_read.qml b/tests/auto/qml/qqmlvaluetypes/data/quaternion_read.qml new file mode 100644 index 0000000000..d1a21dc926 --- /dev/null +++ b/tests/auto/qml/qqmlvaluetypes/data/quaternion_read.qml @@ -0,0 +1,10 @@ +import Test 1.0 + +MyTypeObject { + property real v_scalar: quaternion.scalar + property real v_x: quaternion.x + property real v_y: quaternion.y + property real v_z: quaternion.z + property variant copy: quaternion +} + diff --git a/tests/auto/qml/qqmlvaluetypes/data/quaternion_write.qml b/tests/auto/qml/qqmlvaluetypes/data/quaternion_write.qml new file mode 100644 index 0000000000..0c3e5afd98 --- /dev/null +++ b/tests/auto/qml/qqmlvaluetypes/data/quaternion_write.qml @@ -0,0 +1,9 @@ +import Test 1.0 + +MyTypeObject { + quaternion.scalar: if (true) 88.5 + quaternion.x: if (true) -0.3 + quaternion.y: if (true) -12.9 + quaternion.z: if (true) 907.4 +} + diff --git a/tests/auto/qml/qqmlvaluetypes/data/rect_compare.qml b/tests/auto/qml/qqmlvaluetypes/data/rect_compare.qml new file mode 100644 index 0000000000..c511c2dfc4 --- /dev/null +++ b/tests/auto/qml/qqmlvaluetypes/data/rect_compare.qml @@ -0,0 +1,25 @@ +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 variant copy: rect + property string tostring: rect.toString() + + // compare to string + property bool equalsString: (rect == tostring) + + // compare rects to various value types + property bool equalsColor: (rect == Qt.rgba(0.2, 0.88, 0.6, 0.34)) // false + property bool equalsVector3d: (rect == Qt.vector3d(1, 2, 3)) // false + property bool equalsSize: (rect == Qt.size(1912, 1913)) // false + property bool equalsPoint: (rect == Qt.point(10, 4)) // false + property bool equalsRect: (rect == Qt.rect(2, 3, 109, 102)) // true + + property bool equalsSelf: (rect == rect) // true + property bool equalsOther: (rect == Qt.rect(6, 9, 99, 92)) // false + property bool rectEqualsRectf: (rect == rectfrect) // true +} + diff --git a/tests/auto/qml/qqmlvaluetypes/data/rect_read.qml b/tests/auto/qml/qqmlvaluetypes/data/rect_read.qml new file mode 100644 index 0000000000..c3b37a7099 --- /dev/null +++ b/tests/auto/qml/qqmlvaluetypes/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 variant copy: rect +} + diff --git a/tests/auto/qml/qqmlvaluetypes/data/rect_write.qml b/tests/auto/qml/qqmlvaluetypes/data/rect_write.qml new file mode 100644 index 0000000000..8add45305c --- /dev/null +++ b/tests/auto/qml/qqmlvaluetypes/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/qml/qqmlvaluetypes/data/rectf_compare.qml b/tests/auto/qml/qqmlvaluetypes/data/rectf_compare.qml new file mode 100644 index 0000000000..6ac4049558 --- /dev/null +++ b/tests/auto/qml/qqmlvaluetypes/data/rectf_compare.qml @@ -0,0 +1,25 @@ +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 variant copy: rectf + property string tostring: rectf.toString() + + // compare to string + property bool equalsString: (rectf == tostring) + + // compare rectfs to various value types + property bool equalsColor: (rectf == Qt.rgba(0.2, 0.88, 0.6, 0.34)) // false + property bool equalsVector3d: (rectf == Qt.vector3d(1, 2, 3)) // false + property bool equalsSize: (rectf == Qt.size(1912, 1913)) // false + property bool equalsPoint: (rectf == Qt.point(10, 4)) // false + property bool equalsRect: (rectf == Qt.rect(103.8, 99.2, 88.1, 77.6)) // true + + property bool equalsSelf: (rectf == rectf) // true + property bool equalsOther: (rectf == Qt.rect(13.8, 9.2, 78.7, 96.2)) // false + property bool rectfEqualsRect: (rectfrect == rect) // true +} + diff --git a/tests/auto/qml/qqmlvaluetypes/data/rectf_read.qml b/tests/auto/qml/qqmlvaluetypes/data/rectf_read.qml new file mode 100644 index 0000000000..6ff3ce30bf --- /dev/null +++ b/tests/auto/qml/qqmlvaluetypes/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 variant copy: rectf +} + diff --git a/tests/auto/qml/qqmlvaluetypes/data/rectf_write.qml b/tests/auto/qml/qqmlvaluetypes/data/rectf_write.qml new file mode 100644 index 0000000000..1e6ff4ff90 --- /dev/null +++ b/tests/auto/qml/qqmlvaluetypes/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/qml/qqmlvaluetypes/data/returnValues.qml b/tests/auto/qml/qqmlvaluetypes/data/returnValues.qml new file mode 100644 index 0000000000..1f9816f666 --- /dev/null +++ b/tests/auto/qml/qqmlvaluetypes/data/returnValues.qml @@ -0,0 +1,17 @@ +import Test 1.0 +import QtQuick 2.0 + +MyTypeObject { + property bool test1: false; + property bool test2: false; + + Component.onCompleted: { + var a = method(); + + test1 = (a.width == 13) + test2 = (a.height == 14) + + size = a; + } +} + diff --git a/tests/auto/qml/qqmlvaluetypes/data/scriptAccess.qml b/tests/auto/qml/qqmlvaluetypes/data/scriptAccess.qml new file mode 100644 index 0000000000..cbecb4379a --- /dev/null +++ b/tests/auto/qml/qqmlvaluetypes/data/scriptAccess.qml @@ -0,0 +1,9 @@ +import QtQuick 2.0 +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/qml/qqmlvaluetypes/data/scriptVariantCopy.qml b/tests/auto/qml/qqmlvaluetypes/data/scriptVariantCopy.qml new file mode 100644 index 0000000000..42fccfac5a --- /dev/null +++ b/tests/auto/qml/qqmlvaluetypes/data/scriptVariantCopy.qml @@ -0,0 +1,14 @@ +import Test 1.0 + +MyTypeObject { + property variant object + object: MyTypeObject { + rect.x: 19 + rect.y: 33 + rect.width: 5 + rect.height: 99 + } + + onRunScript: rect = object.rect +} + diff --git a/tests/auto/qml/qqmlvaluetypes/data/size_compare.qml b/tests/auto/qml/qqmlvaluetypes/data/size_compare.qml new file mode 100644 index 0000000000..1fd4711c15 --- /dev/null +++ b/tests/auto/qml/qqmlvaluetypes/data/size_compare.qml @@ -0,0 +1,23 @@ +import Test 1.0 + +MyTypeObject { + property int s_width: size.width + property int s_height: size.height + property variant copy: size + property string tostring: size.toString() + + // compare to string + property bool equalsString: (size == tostring) + + // compare sizes to various value types + property bool equalsColor: (size == Qt.rgba(0.2, 0.88, 0.6, 0.34)) // false + property bool equalsVector3d: (size == Qt.vector3d(1, 2, 3)) // false + property bool equalsSize: (size == Qt.size(1912, 1913)) // true + property bool equalsPoint: (size == Qt.point(10, 4)) // false + property bool equalsRect: (size == Qt.rect(2, 3, 109, 102)) // false + + property bool equalsSelf: (size == size) // true + property bool equalsOther: (size == Qt.size(1212, 1313)) // false + property bool sizeEqualsSizef: (size == sizefsize) // true +} + diff --git a/tests/auto/qml/qqmlvaluetypes/data/size_read.qml b/tests/auto/qml/qqmlvaluetypes/data/size_read.qml new file mode 100644 index 0000000000..a49fd9f760 --- /dev/null +++ b/tests/auto/qml/qqmlvaluetypes/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 variant copy: size +} + diff --git a/tests/auto/qml/qqmlvaluetypes/data/size_write.qml b/tests/auto/qml/qqmlvaluetypes/data/size_write.qml new file mode 100644 index 0000000000..2f9d10e45f --- /dev/null +++ b/tests/auto/qml/qqmlvaluetypes/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/qml/qqmlvaluetypes/data/sizef_compare.qml b/tests/auto/qml/qqmlvaluetypes/data/sizef_compare.qml new file mode 100644 index 0000000000..c74a049454 --- /dev/null +++ b/tests/auto/qml/qqmlvaluetypes/data/sizef_compare.qml @@ -0,0 +1,24 @@ +import Test 1.0 + +MyTypeObject { + property real s_width: sizef.width + property real s_height: sizef.height + property variant copy: sizef + property string tostring: sizef.toString() + + // compare to string + property bool equalsString: (sizef == tostring) + + // compare sizefs to various value types + property bool equalsColor: (sizef == Qt.rgba(0.2, 0.88, 0.6, 0.34)) // false + property bool equalsVector3d: (sizef == Qt.vector3d(1, 2, 3)) // false + property bool equalsSize: (sizef == Qt.size(0.1, 100923.2)) // true + property bool equalsPoint: (sizef == Qt.point(10, 4)) // false + property bool equalsRect: (sizef == Qt.rect(2, 3, 109, 102)) // false + + property bool equalsSelf: (sizef == sizef) // true + property bool equalsOther: (size == Qt.size(3.1, 923.2)) // false + property bool sizefEqualsSize: (sizefsize == size) // true +} + + diff --git a/tests/auto/qml/qqmlvaluetypes/data/sizef_read.qml b/tests/auto/qml/qqmlvaluetypes/data/sizef_read.qml new file mode 100644 index 0000000000..96cd425f17 --- /dev/null +++ b/tests/auto/qml/qqmlvaluetypes/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 variant copy: sizef +} + + diff --git a/tests/auto/qml/qqmlvaluetypes/data/sizef_write.qml b/tests/auto/qml/qqmlvaluetypes/data/sizef_write.qml new file mode 100644 index 0000000000..f16f0bdf93 --- /dev/null +++ b/tests/auto/qml/qqmlvaluetypes/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/qml/qqmlvaluetypes/data/sizereadonly_read.qml b/tests/auto/qml/qqmlvaluetypes/data/sizereadonly_read.qml new file mode 100644 index 0000000000..7f708a0899 --- /dev/null +++ b/tests/auto/qml/qqmlvaluetypes/data/sizereadonly_read.qml @@ -0,0 +1,8 @@ +import Test 1.0 + +MyTypeObject { + property int s_width: sizereadonly.width + property int s_height: sizereadonly.height + property variant copy: sizereadonly +} + diff --git a/tests/auto/qml/qqmlvaluetypes/data/sizereadonly_writeerror.qml b/tests/auto/qml/qqmlvaluetypes/data/sizereadonly_writeerror.qml new file mode 100644 index 0000000000..3254557014 --- /dev/null +++ b/tests/auto/qml/qqmlvaluetypes/data/sizereadonly_writeerror.qml @@ -0,0 +1,6 @@ +import Test 1.0 + +MyTypeObject { + sizereadonly: "13x88" +} + diff --git a/tests/auto/qml/qqmlvaluetypes/data/sizereadonly_writeerror2.qml b/tests/auto/qml/qqmlvaluetypes/data/sizereadonly_writeerror2.qml new file mode 100644 index 0000000000..656d718b05 --- /dev/null +++ b/tests/auto/qml/qqmlvaluetypes/data/sizereadonly_writeerror2.qml @@ -0,0 +1,7 @@ +import Test 1.0 + +MyTypeObject { + sizereadonly.width: if (true) 13 + sizereadonly.height: if (true) 88 +} + diff --git a/tests/auto/qml/qqmlvaluetypes/data/sizereadonly_writeerror3.qml b/tests/auto/qml/qqmlvaluetypes/data/sizereadonly_writeerror3.qml new file mode 100644 index 0000000000..b8e3f0d41b --- /dev/null +++ b/tests/auto/qml/qqmlvaluetypes/data/sizereadonly_writeerror3.qml @@ -0,0 +1,7 @@ +import Test 1.0 + +MyTypeObject { + sizereadonly.width: 13 + sizereadonly.height: 88 +} + diff --git a/tests/auto/qml/qqmlvaluetypes/data/sizereadonly_writeerror4.qml b/tests/auto/qml/qqmlvaluetypes/data/sizereadonly_writeerror4.qml new file mode 100644 index 0000000000..68b54b571e --- /dev/null +++ b/tests/auto/qml/qqmlvaluetypes/data/sizereadonly_writeerror4.qml @@ -0,0 +1,10 @@ +import Test 1.0 +import QtQuick 2.0 + +MyTypeObject { + Component.onCompleted: { + sizereadonly.width = 13; + } +} + + diff --git a/tests/auto/qml/qqmlvaluetypes/data/staticAssignment.qml b/tests/auto/qml/qqmlvaluetypes/data/staticAssignment.qml new file mode 100644 index 0000000000..b687f89eef --- /dev/null +++ b/tests/auto/qml/qqmlvaluetypes/data/staticAssignment.qml @@ -0,0 +1,5 @@ +import Test 1.0 + +MyTypeObject { + rect.x: 9 +} diff --git a/tests/auto/qml/qqmlvaluetypes/data/valueInterceptors.qml b/tests/auto/qml/qqmlvaluetypes/data/valueInterceptors.qml new file mode 100644 index 0000000000..0897847d2d --- /dev/null +++ b/tests/auto/qml/qqmlvaluetypes/data/valueInterceptors.qml @@ -0,0 +1,8 @@ +import Test 1.0 + +MyTypeObject { + property int value: 13; + + MyOffsetValueInterceptor on rect.x {} + rect.x: value +} diff --git a/tests/auto/qml/qqmlvaluetypes/data/valueSources.qml b/tests/auto/qml/qqmlvaluetypes/data/valueSources.qml new file mode 100644 index 0000000000..717f3502c0 --- /dev/null +++ b/tests/auto/qml/qqmlvaluetypes/data/valueSources.qml @@ -0,0 +1,5 @@ +import Test 1.0 + +MyTypeObject { + MyConstantValueSource on rect.x {} +} diff --git a/tests/auto/qml/qqmlvaluetypes/data/varAssignment.qml b/tests/auto/qml/qqmlvaluetypes/data/varAssignment.qml new file mode 100644 index 0000000000..9b56abbbed --- /dev/null +++ b/tests/auto/qml/qqmlvaluetypes/data/varAssignment.qml @@ -0,0 +1,14 @@ +import QtQuick 2.0 + +QtObject { + property int x; + property int y; + property int z; + + Component.onCompleted: { + var vec3 = Qt.vector3d(1, 2, 3); + x = vec3.x; + y = vec3.y; + z = vec3.z; + } +} diff --git a/tests/auto/qml/qqmlvaluetypes/data/variant_read.qml b/tests/auto/qml/qqmlvaluetypes/data/variant_read.qml new file mode 100644 index 0000000000..a08f3db94f --- /dev/null +++ b/tests/auto/qml/qqmlvaluetypes/data/variant_read.qml @@ -0,0 +1,9 @@ +import Test 1.0 + +MyTypeObject { + property real s_width: variant.width + property real s_height: variant.height + property variant copy: variant +} + + diff --git a/tests/auto/qml/qqmlvaluetypes/data/vector2d_compare.qml b/tests/auto/qml/qqmlvaluetypes/data/vector2d_compare.qml new file mode 100644 index 0000000000..eb8fb5bb76 --- /dev/null +++ b/tests/auto/qml/qqmlvaluetypes/data/vector2d_compare.qml @@ -0,0 +1,21 @@ +import Test 1.0 + +MyTypeObject { + property real v_x: vector2.x + property real v_y: vector2.y + property variant copy: vector2 + property string tostring: vector2.toString() + + // compare to string + property bool equalsString: (vector2 == tostring) + + // compare vector2ds to various value types + property bool equalsColor: (vector2 == Qt.rgba(0.2, 0.88, 0.6, 0.34)) // false + property bool equalsVector3d: (vector2 == Qt.vector3d(1, 2, 3)) // false + property bool equalsSize: (vector2 == Qt.size(1912, 1913)) // false + property bool equalsPoint: (vector2 == Qt.point(10, 4)) // false + property bool equalsRect: (vector2 == Qt.rect(2, 3, 109, 102)) // false + + property bool equalsSelf: (vector2 == vector2) +} + diff --git a/tests/auto/qml/qqmlvaluetypes/data/vector2d_read.qml b/tests/auto/qml/qqmlvaluetypes/data/vector2d_read.qml new file mode 100644 index 0000000000..fc315f7abf --- /dev/null +++ b/tests/auto/qml/qqmlvaluetypes/data/vector2d_read.qml @@ -0,0 +1,8 @@ +import Test 1.0 + +MyTypeObject { + property real v_x: vector2.x + property real v_y: vector2.y + property variant copy: vector2 +} + diff --git a/tests/auto/qml/qqmlvaluetypes/data/vector2d_write.qml b/tests/auto/qml/qqmlvaluetypes/data/vector2d_write.qml new file mode 100644 index 0000000000..f0e35ff200 --- /dev/null +++ b/tests/auto/qml/qqmlvaluetypes/data/vector2d_write.qml @@ -0,0 +1,7 @@ +import Test 1.0 + +MyTypeObject { + vector2.x: if (true) -0.3 + vector2.y: if (true) -12.9 +} + diff --git a/tests/auto/qml/qqmlvaluetypes/data/vector3d_compare.qml b/tests/auto/qml/qqmlvaluetypes/data/vector3d_compare.qml new file mode 100644 index 0000000000..7bda1d17f4 --- /dev/null +++ b/tests/auto/qml/qqmlvaluetypes/data/vector3d_compare.qml @@ -0,0 +1,23 @@ +import Test 1.0 + +MyTypeObject { + property real v_x: vector.x + property real v_y: vector.y + property real v_z: vector.z + property variant copy: vector + property string tostring: vector.toString() + + // compare to string + property bool equalsString: (vector == tostring) + + // compare vector3ds to various value types + property bool equalsColor: (vector == Qt.rgba(0.2, 0.88, 0.6, 0.34)) // false + property bool equalsVector3d: (vector == Qt.vector3d(23.88, 3.1, 4.3)) // true + property bool equalsSize: (vector == Qt.size(1912, 1913)) // false + property bool equalsPoint: (vector == Qt.point(10, 4)) // false + property bool equalsRect: (vector == Qt.rect(2, 3, 109, 102)) // false + + property bool equalsSelf: (vector == vector) // true + property bool equalsOther: (vector == Qt.vector3d(3.1, 2.2, 923.2)) // false +} + diff --git a/tests/auto/qml/qqmlvaluetypes/data/vector3d_read.qml b/tests/auto/qml/qqmlvaluetypes/data/vector3d_read.qml new file mode 100644 index 0000000000..f1e876dbb9 --- /dev/null +++ b/tests/auto/qml/qqmlvaluetypes/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 variant copy: vector +} + diff --git a/tests/auto/qml/qqmlvaluetypes/data/vector3d_write.qml b/tests/auto/qml/qqmlvaluetypes/data/vector3d_write.qml new file mode 100644 index 0000000000..9c1bf7620a --- /dev/null +++ b/tests/auto/qml/qqmlvaluetypes/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/qml/qqmlvaluetypes/data/vector4d_compare.qml b/tests/auto/qml/qqmlvaluetypes/data/vector4d_compare.qml new file mode 100644 index 0000000000..3ea42a59ce --- /dev/null +++ b/tests/auto/qml/qqmlvaluetypes/data/vector4d_compare.qml @@ -0,0 +1,23 @@ +import Test 1.0 + +MyTypeObject { + property real v_x: vector4.x + property real v_y: vector4.y + property real v_z: vector4.z + property real v_w: vector4.w + property variant copy: vector4 + property string tostring: vector4.toString() + + // compare to string + property bool equalsString: (vector4 == tostring) + + // compare vector4ds to various value types + property bool equalsColor: (vector4 == Qt.rgba(0.2, 0.88, 0.6, 0.34)) // false + property bool equalsVector3d: (vector4 == Qt.vector3d(1, 2, 3)) // false + property bool equalsSize: (vector4 == Qt.size(1912, 1913)) // false + property bool equalsPoint: (vector4 == Qt.point(10, 4)) // false + property bool equalsRect: (vector4 == Qt.rect(2, 3, 109, 102)) // false + + property bool equalsSelf: (vector4 == vector4) // true +} + diff --git a/tests/auto/qml/qqmlvaluetypes/data/vector4d_read.qml b/tests/auto/qml/qqmlvaluetypes/data/vector4d_read.qml new file mode 100644 index 0000000000..f9d5d6053e --- /dev/null +++ b/tests/auto/qml/qqmlvaluetypes/data/vector4d_read.qml @@ -0,0 +1,10 @@ +import Test 1.0 + +MyTypeObject { + property real v_x: vector4.x + property real v_y: vector4.y + property real v_z: vector4.z + property real v_w: vector4.w + property variant copy: vector4 +} + diff --git a/tests/auto/qml/qqmlvaluetypes/data/vector4d_write.qml b/tests/auto/qml/qqmlvaluetypes/data/vector4d_write.qml new file mode 100644 index 0000000000..548698126d --- /dev/null +++ b/tests/auto/qml/qqmlvaluetypes/data/vector4d_write.qml @@ -0,0 +1,9 @@ +import Test 1.0 + +MyTypeObject { + vector4.x: if (true) -0.3 + vector4.y: if (true) -12.9 + vector4.z: if (true) 907.4 + vector4.w: if (true) 88.5 +} + diff --git a/tests/auto/qml/qqmlvaluetypes/qqmlvaluetypes.pro b/tests/auto/qml/qqmlvaluetypes/qqmlvaluetypes.pro new file mode 100644 index 0000000000..6051f65936 --- /dev/null +++ b/tests/auto/qml/qqmlvaluetypes/qqmlvaluetypes.pro @@ -0,0 +1,18 @@ +CONFIG += testcase +TARGET = tst_qqmlvaluetypes +macx:CONFIG -= app_bundle + +HEADERS += testtypes.h + +SOURCES += tst_qqmlvaluetypes.cpp \ + testtypes.cpp + +include (../../shared/util.pri) + +testDataFiles.files = data +testDataFiles.path = . +DEPLOYMENT += testDataFiles + +CONFIG += parallel_test + +QT += core-private gui-private v8-private qml-private testlib diff --git a/tests/auto/qml/qqmlvaluetypes/testtypes.cpp b/tests/auto/qml/qqmlvaluetypes/testtypes.cpp new file mode 100644 index 0000000000..ef9f268b2f --- /dev/null +++ b/tests/auto/qml/qqmlvaluetypes/testtypes.cpp @@ -0,0 +1,48 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include "testtypes.h" + +void registerTypes() +{ + qmlRegisterType("Test", 1, 0, "MyTypeObject"); + qmlRegisterType("Test", 1, 0, "MyConstantValueSource"); + qmlRegisterType("Test", 1, 0, "MyOffsetValueInterceptor"); +} diff --git a/tests/auto/qml/qqmlvaluetypes/testtypes.h b/tests/auto/qml/qqmlvaluetypes/testtypes.h new file mode 100644 index 0000000000..813c58567f --- /dev/null +++ b/tests/auto/qml/qqmlvaluetypes/testtypes.h @@ -0,0 +1,219 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#ifndef TESTTYPES_H +#define TESTTYPES_H + +#include +#include +#include +#include +#include +#include +#include +#include +#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(QPointF pointfpoint READ pointfpoint WRITE setPointfpoint NOTIFY changed) + Q_PROPERTY(QSize size READ size WRITE setSize NOTIFY changed) + Q_PROPERTY(QSizeF sizef READ sizef WRITE setSizef NOTIFY changed) + Q_PROPERTY(QSizeF sizefsize READ sizefsize WRITE setSizefsize NOTIFY changed) + Q_PROPERTY(QSize sizereadonly READ size NOTIFY changed) + Q_PROPERTY(QRect rect READ rect WRITE setRect NOTIFY changed) + Q_PROPERTY(QRectF rectf READ rectf WRITE setRectf NOTIFY changed) + Q_PROPERTY(QRectF rectfrect READ rectfrect WRITE setRectfrect NOTIFY changed) + Q_PROPERTY(QVector2D vector2 READ vector2 WRITE setVector2 NOTIFY changed) + Q_PROPERTY(QVector3D vector READ vector WRITE setVector NOTIFY changed) + Q_PROPERTY(QVector4D vector4 READ vector4 WRITE setVector4 NOTIFY changed) + Q_PROPERTY(QQuaternion quaternion READ quaternion WRITE setQuaternion NOTIFY changed) + Q_PROPERTY(QMatrix4x4 matrix READ matrix WRITE setMatrix NOTIFY changed) + Q_PROPERTY(QFont font READ font WRITE setFont NOTIFY changed) + Q_PROPERTY(QColor color READ color WRITE setColor NOTIFY changed) + Q_PROPERTY(QVariant variant READ variant NOTIFY changed) + +public: + MyTypeObject() : + m_point(10, 4), + m_pointf(11.3, -10.9), + m_pointfpoint(10.0, 4.0), + m_size(1912, 1913), + m_sizef(0.1, 100923.2), + m_sizefsize(1912.0, 1913.0), + m_rect(2, 3, 109, 102), + m_rectf(103.8, 99.2, 88.1, 77.6), + m_rectfrect(2.0, 3.0, 109.0, 102.0), + m_vector2(32.88, 1.3), + m_vector(23.88, 3.1, 4.3), + m_vector4(54.2, 23.88, 3.1, 4.3), + m_quaternion(4.3, 54.2, 23.88, 3.1), + m_matrix(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16) + { + m_font.setFamily("Arial"); + m_font.setBold(true); + m_font.setWeight(QFont::DemiBold); + m_font.setItalic(true); + m_font.setUnderline(true); + m_font.setOverline(true); + m_font.setStrikeOut(true); + m_font.setPointSize(29); + m_font.setCapitalization(QFont::AllLowercase); + m_font.setLetterSpacing(QFont::AbsoluteSpacing, 10.2); + m_font.setWordSpacing(19.7); + m_color.setRedF(0.2); + m_color.setGreenF(0.88); + m_color.setBlueF(0.6); + m_color.setAlphaF(0.34); + } + + QPoint m_point; + QPoint point() const { return m_point; } + void setPoint(const QPoint &v) { m_point = v; emit changed(); } + + QPointF m_pointf; + QPointF pointf() const { return m_pointf; } + void setPointf(const QPointF &v) { m_pointf = v; emit changed(); } + + QPointF m_pointfpoint; + QPointF pointfpoint() const { return m_pointfpoint; } + void setPointfpoint(const QPointF &v) { m_pointfpoint = v; emit changed(); } + + QSize m_size; + QSize size() const { return m_size; } + void setSize(const QSize &v) { m_size = v; emit changed(); } + + QSizeF m_sizef; + QSizeF sizef() const { return m_sizef; } + void setSizef(const QSizeF &v) { m_sizef = v; emit changed(); } + + QSizeF m_sizefsize; + QSizeF sizefsize() const { return m_sizefsize; } + void setSizefsize(const QSizeF &v) { m_sizefsize = v; emit changed(); } + + QRect m_rect; + QRect rect() const { return m_rect; } + void setRect(const QRect &v) { m_rect = v; emit changed(); } + + QRectF m_rectf; + QRectF rectf() const { return m_rectf; } + void setRectf(const QRectF &v) { m_rectf = v; emit changed(); } + + QRectF m_rectfrect; + QRectF rectfrect() const { return m_rectfrect; } + void setRectfrect(const QRectF &v) { m_rectfrect = v; emit changed(); } + + QVector2D m_vector2; + QVector2D vector2() const { return m_vector2; } + void setVector2(const QVector2D &v) { m_vector2 = v; emit changed(); } + + QVector3D m_vector; + QVector3D vector() const { return m_vector; } + void setVector(const QVector3D &v) { m_vector = v; emit changed(); } + + QVector4D m_vector4; + QVector4D vector4() const { return m_vector4; } + void setVector4(const QVector4D &v) { m_vector4 = v; emit changed(); } + + QQuaternion m_quaternion; + QQuaternion quaternion() const { return m_quaternion; } + void setQuaternion(const QQuaternion &v) { m_quaternion = v; emit changed(); } + + QMatrix4x4 m_matrix; + QMatrix4x4 matrix() const { return m_matrix; } + void setMatrix(const QMatrix4x4 &v) { m_matrix = v; emit changed(); } + + QFont m_font; + QFont font() const { return m_font; } + void setFont(const QFont &v) { m_font = v; emit changed(); } + + QColor m_color; + QColor color() const { return m_color; } + void setColor(const QColor &v) { m_color = v; emit changed(); } + + QVariant variant() const { return sizef(); } + + void emitRunScript() { emit runScript(); } + +signals: + void changed(); + void runScript(); + +public slots: + QSize method() { return QSize(13, 14); } +}; + +class MyConstantValueSource : public QObject, public QQmlPropertyValueSource +{ + Q_OBJECT + Q_INTERFACES(QQmlPropertyValueSource) +public: + virtual void setTarget(const QQmlProperty &p) { p.write(3345); } +}; + +class MyOffsetValueInterceptor : public QObject, public QQmlPropertyValueInterceptor +{ + Q_OBJECT + Q_INTERFACES(QQmlPropertyValueInterceptor) +public: + virtual void setTarget(const QQmlProperty &p) { prop = p; } + virtual void write(const QVariant &value) { QQmlPropertyPrivate::write(prop, value.toInt() + 13, QQmlPropertyPrivate::BypassInterceptor); } + +private: + QQmlProperty prop; +}; + +void registerTypes(); + +#endif // TESTTYPES_H diff --git a/tests/auto/qml/qqmlvaluetypes/tst_qqmlvaluetypes.cpp b/tests/auto/qml/qqmlvaluetypes/tst_qqmlvaluetypes.cpp new file mode 100644 index 0000000000..695dbe4147 --- /dev/null +++ b/tests/auto/qml/qqmlvaluetypes/tst_qqmlvaluetypes.cpp @@ -0,0 +1,1306 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include +#include +#include +#include +#include "../../shared/util.h" +#include "testtypes.h" + +QT_BEGIN_NAMESPACE +extern int qt_defaultDpi(); +QT_END_NAMESPACE + +class tst_qqmlvaluetypes : public QQmlDataTest +{ + Q_OBJECT +public: + tst_qqmlvaluetypes() {} + +private slots: + void initTestCase(); + + void point(); + void pointf(); + void size(); + void sizef(); + void sizereadonly(); + void rect(); + void rectf(); + void vector2d(); + void vector3d(); + void vector4d(); + void quaternion(); + void matrix4x4(); + void font(); + void color(); + void variant(); + + void bindingAssignment(); + void bindingRead(); + void staticAssignment(); + void scriptAccess(); + void autoBindingRemoval(); + void valueSources(); + void valueInterceptors(); + void bindingConflict(); + void deletedObject(); + void bindingVariantCopy(); + void scriptVariantCopy(); + void cppClasses(); + void enums(); + void conflictingBindings(); + void returnValues(); + void varAssignment(); + void bindingsSpliceCorrectly(); + +private: + QQmlEngine engine; +}; + +void tst_qqmlvaluetypes::initTestCase() +{ + QQmlDataTest::initTestCase(); + registerTypes(); +} + +void tst_qqmlvaluetypes::point() +{ + { + QQmlComponent component(&engine, testFileUrl("point_read.qml")); + MyTypeObject *object = qobject_cast(component.create()); + QVERIFY(object != 0); + + QCOMPARE(object->property("p_x").toInt(), 10); + QCOMPARE(object->property("p_y").toInt(), 4); + QCOMPARE(object->property("copy"), QVariant(QPoint(10, 4))); + + delete object; + } + + { + QQmlComponent component(&engine, testFileUrl("point_write.qml")); + MyTypeObject *object = qobject_cast(component.create()); + QVERIFY(object != 0); + + QCOMPARE(object->point(), QPoint(11, 12)); + + delete object; + } + + { + QQmlComponent component(&engine, testFileUrl("point_compare.qml")); + MyTypeObject *object = qobject_cast(component.create()); + QVERIFY(object != 0); + + QString tostring = QLatin1String("QPoint(10, 4)"); + QCOMPARE(object->property("tostring").toString(), tostring); + QCOMPARE(object->property("equalsString").toBool(), true); + QCOMPARE(object->property("equalsColor").toBool(), false); + QCOMPARE(object->property("equalsVector3d").toBool(), false); + QCOMPARE(object->property("equalsSize").toBool(), false); + QCOMPARE(object->property("equalsPoint").toBool(), true); + QCOMPARE(object->property("equalsRect").toBool(), false); + QCOMPARE(object->property("equalsSelf").toBool(), true); + QCOMPARE(object->property("equalsOther").toBool(), false); + QCOMPARE(object->property("pointEqualsPointf").toBool(), true); + + delete object; + } +} + +void tst_qqmlvaluetypes::pointf() +{ + { + QQmlComponent component(&engine, testFileUrl("pointf_read.qml")); + MyTypeObject *object = qobject_cast(component.create()); + QVERIFY(object != 0); + + QCOMPARE(float(object->property("p_x").toDouble()), float(11.3)); + QCOMPARE(float(object->property("p_y").toDouble()), float(-10.9)); + QCOMPARE(object->property("copy"), QVariant(QPointF(11.3, -10.9))); + + delete object; + } + + { + QQmlComponent component(&engine, testFileUrl("pointf_write.qml")); + MyTypeObject *object = qobject_cast(component.create()); + QVERIFY(object != 0); + + QCOMPARE(object->pointf(), QPointF(6.8, 9.3)); + + delete object; + } + + { + QQmlComponent component(&engine, testFileUrl("pointf_compare.qml")); + MyTypeObject *object = qobject_cast(component.create()); + QVERIFY(object != 0); + + QString tostring = QLatin1String("QPointF(11.3, -10.9)"); + QCOMPARE(object->property("tostring").toString(), tostring); + QCOMPARE(object->property("equalsString").toBool(), true); + QCOMPARE(object->property("equalsColor").toBool(), false); + QCOMPARE(object->property("equalsVector3d").toBool(), false); + QCOMPARE(object->property("equalsSize").toBool(), false); + QCOMPARE(object->property("equalsPoint").toBool(), true); + QCOMPARE(object->property("equalsRect").toBool(), false); + QCOMPARE(object->property("equalsSelf").toBool(), true); + QCOMPARE(object->property("equalsOther").toBool(), false); + QCOMPARE(object->property("pointfEqualsPoint").toBool(), true); + + delete object; + } +} + +void tst_qqmlvaluetypes::size() +{ + { + QQmlComponent component(&engine, testFileUrl("size_read.qml")); + MyTypeObject *object = qobject_cast(component.create()); + QVERIFY(object != 0); + + QCOMPARE(object->property("s_width").toInt(), 1912); + QCOMPARE(object->property("s_height").toInt(), 1913); + QCOMPARE(object->property("copy"), QVariant(QSize(1912, 1913))); + + delete object; + } + + { + QQmlComponent component(&engine, testFileUrl("size_write.qml")); + MyTypeObject *object = qobject_cast(component.create()); + QVERIFY(object != 0); + + QCOMPARE(object->size(), QSize(13, 88)); + + delete object; + } + + { + QQmlComponent component(&engine, testFileUrl("size_compare.qml")); + MyTypeObject *object = qobject_cast(component.create()); + QVERIFY(object != 0); + + QString tostring = QLatin1String("QSize(1912, 1913)"); + QCOMPARE(object->property("tostring").toString(), tostring); + QCOMPARE(object->property("equalsString").toBool(), true); + QCOMPARE(object->property("equalsColor").toBool(), false); + QCOMPARE(object->property("equalsVector3d").toBool(), false); + QCOMPARE(object->property("equalsSize").toBool(), true); + QCOMPARE(object->property("equalsPoint").toBool(), false); + QCOMPARE(object->property("equalsRect").toBool(), false); + QCOMPARE(object->property("equalsSelf").toBool(), true); + QCOMPARE(object->property("equalsOther").toBool(), false); + QCOMPARE(object->property("sizeEqualsSizef").toBool(), true); + + delete object; + } +} + +void tst_qqmlvaluetypes::sizef() +{ + { + QQmlComponent component(&engine, testFileUrl("sizef_read.qml")); + MyTypeObject *object = qobject_cast(component.create()); + QVERIFY(object != 0); + + QCOMPARE(float(object->property("s_width").toDouble()), float(0.1)); + QCOMPARE(float(object->property("s_height").toDouble()), float(100923.2)); + QCOMPARE(object->property("copy"), QVariant(QSizeF(0.1, 100923.2))); + + delete object; + } + + { + QQmlComponent component(&engine, testFileUrl("sizef_write.qml")); + MyTypeObject *object = qobject_cast(component.create()); + QVERIFY(object != 0); + + QCOMPARE(object->sizef(), QSizeF(44.3, 92.8)); + + delete object; + } + + { + QQmlComponent component(&engine, testFileUrl("sizef_compare.qml")); + MyTypeObject *object = qobject_cast(component.create()); + QVERIFY(object != 0); + + QString tostring = QLatin1String("QSizeF(0.1, 100923)"); + QCOMPARE(object->property("tostring").toString(), tostring); + QCOMPARE(object->property("equalsString").toBool(), true); + QCOMPARE(object->property("equalsColor").toBool(), false); + QCOMPARE(object->property("equalsVector3d").toBool(), false); + QCOMPARE(object->property("equalsSize").toBool(), true); + QCOMPARE(object->property("equalsPoint").toBool(), false); + QCOMPARE(object->property("equalsRect").toBool(), false); + QCOMPARE(object->property("equalsSelf").toBool(), true); + QCOMPARE(object->property("equalsOther").toBool(), false); + QCOMPARE(object->property("sizefEqualsSize").toBool(), true); + + delete object; + } +} + +void tst_qqmlvaluetypes::variant() +{ + QQmlComponent component(&engine, testFileUrl("variant_read.qml")); + MyTypeObject *object = qobject_cast(component.create()); + QVERIFY(object != 0); + + QCOMPARE(float(object->property("s_width").toDouble()), float(0.1)); + QCOMPARE(float(object->property("s_height").toDouble()), float(100923.2)); + QCOMPARE(object->property("copy"), QVariant(QSizeF(0.1, 100923.2))); + + delete object; +} + +void tst_qqmlvaluetypes::sizereadonly() +{ + { + QQmlComponent component(&engine, testFileUrl("sizereadonly_read.qml")); + MyTypeObject *object = qobject_cast(component.create()); + QVERIFY(object != 0); + + QCOMPARE(object->property("s_width").toInt(), 1912); + QCOMPARE(object->property("s_height").toInt(), 1913); + QCOMPARE(object->property("copy"), QVariant(QSize(1912, 1913))); + + delete object; + } + + { + QQmlComponent component(&engine, testFileUrl("sizereadonly_writeerror.qml")); + QVERIFY(component.isError()); + QCOMPARE(component.errors().at(0).description(), QLatin1String("Invalid property assignment: \"sizereadonly\" is a read-only property")); + } + + { + QQmlComponent component(&engine, testFileUrl("sizereadonly_writeerror2.qml")); + QVERIFY(component.isError()); + QCOMPARE(component.errors().at(0).description(), QLatin1String("Invalid property assignment: \"sizereadonly\" is a read-only property")); + } + + { + QQmlComponent component(&engine, testFileUrl("sizereadonly_writeerror3.qml")); + QVERIFY(component.isError()); + QCOMPARE(component.errors().at(0).description(), QLatin1String("Invalid property assignment: \"sizereadonly\" is a read-only property")); + } + + { + QQmlComponent component(&engine, testFileUrl("sizereadonly_writeerror4.qml")); + + QObject *object = component.create(); + QVERIFY(object); + + QCOMPARE(object->property("sizereadonly").toSize(), QSize(1912, 1913)); + + delete object; + } +} + +void tst_qqmlvaluetypes::rect() +{ + { + QQmlComponent component(&engine, testFileUrl("rect_read.qml")); + MyTypeObject *object = qobject_cast(component.create()); + QVERIFY(object != 0); + + QCOMPARE(object->property("r_x").toInt(), 2); + QCOMPARE(object->property("r_y").toInt(), 3); + QCOMPARE(object->property("r_width").toInt(), 109); + QCOMPARE(object->property("r_height").toInt(), 102); + QCOMPARE(object->property("copy"), QVariant(QRect(2, 3, 109, 102))); + + delete object; + } + + { + QQmlComponent component(&engine, testFileUrl("rect_write.qml")); + MyTypeObject *object = qobject_cast(component.create()); + QVERIFY(object != 0); + + QCOMPARE(object->rect(), QRect(1234, 7, 56, 63)); + + delete object; + } + + { + QQmlComponent component(&engine, testFileUrl("rect_compare.qml")); + MyTypeObject *object = qobject_cast(component.create()); + QVERIFY(object != 0); + + QString tostring = QLatin1String("QRect(2, 3, 109, 102)"); + QCOMPARE(object->property("tostring").toString(), tostring); + QCOMPARE(object->property("equalsString").toBool(), true); + QCOMPARE(object->property("equalsColor").toBool(), false); + QCOMPARE(object->property("equalsVector3d").toBool(), false); + QCOMPARE(object->property("equalsSize").toBool(), false); + QCOMPARE(object->property("equalsPoint").toBool(), false); + QCOMPARE(object->property("equalsRect").toBool(), true); + QCOMPARE(object->property("equalsSelf").toBool(), true); + QCOMPARE(object->property("equalsOther").toBool(), false); + QCOMPARE(object->property("rectEqualsRectf").toBool(), true); + + delete object; + } +} + +void tst_qqmlvaluetypes::rectf() +{ + { + QQmlComponent component(&engine, testFileUrl("rectf_read.qml")); + MyTypeObject *object = qobject_cast(component.create()); + QVERIFY(object != 0); + + QCOMPARE(float(object->property("r_x").toDouble()), float(103.8)); + QCOMPARE(float(object->property("r_y").toDouble()), float(99.2)); + QCOMPARE(float(object->property("r_width").toDouble()), float(88.1)); + QCOMPARE(float(object->property("r_height").toDouble()), float(77.6)); + QCOMPARE(object->property("copy"), QVariant(QRectF(103.8, 99.2, 88.1, 77.6))); + + delete object; + } + + { + QQmlComponent component(&engine, testFileUrl("rectf_write.qml")); + MyTypeObject *object = qobject_cast(component.create()); + QVERIFY(object != 0); + + QCOMPARE(object->rectf(), QRectF(70.1, -113.2, 80924.8, 99.2)); + + delete object; + } + + { + QQmlComponent component(&engine, testFileUrl("rectf_compare.qml")); + MyTypeObject *object = qobject_cast(component.create()); + QVERIFY(object != 0); + + QString tostring = QLatin1String("QRectF(103.8, 99.2, 88.1, 77.6)"); + QCOMPARE(object->property("tostring").toString(), tostring); + QCOMPARE(object->property("equalsString").toBool(), true); + QCOMPARE(object->property("equalsColor").toBool(), false); + QCOMPARE(object->property("equalsVector3d").toBool(), false); + QCOMPARE(object->property("equalsSize").toBool(), false); + QCOMPARE(object->property("equalsPoint").toBool(), false); + QCOMPARE(object->property("equalsRect").toBool(), true); + QCOMPARE(object->property("equalsSelf").toBool(), true); + QCOMPARE(object->property("equalsOther").toBool(), false); + QCOMPARE(object->property("rectfEqualsRect").toBool(), true); + + delete object; + } +} + +void tst_qqmlvaluetypes::vector2d() +{ + { + QQmlComponent component(&engine, testFileUrl("vector2d_read.qml")); + MyTypeObject *object = qobject_cast(component.create()); + QVERIFY(object != 0); + + QCOMPARE((float)object->property("v_x").toDouble(), (float)32.88); + QCOMPARE((float)object->property("v_y").toDouble(), (float)1.3); + QCOMPARE(object->property("copy"), QVariant(QVector2D(32.88, 1.3))); + + delete object; + } + + { + QQmlComponent component(&engine, testFileUrl("vector2d_write.qml")); + MyTypeObject *object = qobject_cast(component.create()); + QVERIFY(object != 0); + + QCOMPARE(object->vector2(), QVector2D(-0.3, -12.9)); + + delete object; + } + + { + QQmlComponent component(&engine, testFileUrl("vector2d_compare.qml")); + MyTypeObject *object = qobject_cast(component.create()); + QVERIFY(object != 0); + + QString tostring = QLatin1String("QVector2D(32.88, 1.3)"); + QCOMPARE(object->property("tostring").toString(), tostring); + QCOMPARE(object->property("equalsString").toBool(), true); + QCOMPARE(object->property("equalsColor").toBool(), false); + QCOMPARE(object->property("equalsVector3d").toBool(), false); + QCOMPARE(object->property("equalsSize").toBool(), false); + QCOMPARE(object->property("equalsPoint").toBool(), false); + QCOMPARE(object->property("equalsRect").toBool(), false); + QCOMPARE(object->property("equalsSelf").toBool(), true); + + delete object; + } +} + +void tst_qqmlvaluetypes::vector3d() +{ + { + QQmlComponent component(&engine, testFileUrl("vector3d_read.qml")); + MyTypeObject *object = qobject_cast(component.create()); + QVERIFY(object != 0); + + QCOMPARE((float)object->property("v_x").toDouble(), (float)23.88); + QCOMPARE((float)object->property("v_y").toDouble(), (float)3.1); + QCOMPARE((float)object->property("v_z").toDouble(), (float)4.3); + QCOMPARE(object->property("copy"), QVariant(QVector3D(23.88, 3.1, 4.3))); + + delete object; + } + + { + QQmlComponent component(&engine, testFileUrl("vector3d_write.qml")); + MyTypeObject *object = qobject_cast(component.create()); + QVERIFY(object != 0); + + QCOMPARE(object->vector(), QVector3D(-0.3, -12.9, 907.4)); + + delete object; + } + + { + QQmlComponent component(&engine, testFileUrl("vector3d_compare.qml")); + MyTypeObject *object = qobject_cast(component.create()); + QVERIFY(object != 0); + + QString tostring = QLatin1String("QVector3D(23.88, 3.1, 4.3)"); + QCOMPARE(object->property("tostring").toString(), tostring); + QCOMPARE(object->property("equalsString").toBool(), true); + QCOMPARE(object->property("equalsColor").toBool(), false); + QCOMPARE(object->property("equalsVector3d").toBool(), true); + QCOMPARE(object->property("equalsSize").toBool(), false); + QCOMPARE(object->property("equalsPoint").toBool(), false); + QCOMPARE(object->property("equalsRect").toBool(), false); + QCOMPARE(object->property("equalsSelf").toBool(), true); + QCOMPARE(object->property("equalsOther").toBool(), false); + + delete object; + } +} + +void tst_qqmlvaluetypes::vector4d() +{ + { + QQmlComponent component(&engine, testFileUrl("vector4d_read.qml")); + MyTypeObject *object = qobject_cast(component.create()); + QVERIFY(object != 0); + + QCOMPARE((float)object->property("v_x").toDouble(), (float)54.2); + QCOMPARE((float)object->property("v_y").toDouble(), (float)23.88); + QCOMPARE((float)object->property("v_z").toDouble(), (float)3.1); + QCOMPARE((float)object->property("v_w").toDouble(), (float)4.3); + QCOMPARE(object->property("copy"), QVariant(QVector4D(54.2, 23.88, 3.1, 4.3))); + + delete object; + } + + { + QQmlComponent component(&engine, testFileUrl("vector4d_write.qml")); + MyTypeObject *object = qobject_cast(component.create()); + QVERIFY(object != 0); + + QCOMPARE(object->vector4(), QVector4D(-0.3, -12.9, 907.4, 88.5)); + + delete object; + } + + { + QQmlComponent component(&engine, testFileUrl("vector4d_compare.qml")); + MyTypeObject *object = qobject_cast(component.create()); + QVERIFY(object != 0); + + QString tostring = QLatin1String("QVector4D(54.2, 23.88, 3.1, 4.3)"); + QCOMPARE(object->property("tostring").toString(), tostring); + QCOMPARE(object->property("equalsString").toBool(), true); + QCOMPARE(object->property("equalsColor").toBool(), false); + QCOMPARE(object->property("equalsVector3d").toBool(), false); + QCOMPARE(object->property("equalsSize").toBool(), false); + QCOMPARE(object->property("equalsPoint").toBool(), false); + QCOMPARE(object->property("equalsRect").toBool(), false); + QCOMPARE(object->property("equalsSelf").toBool(), true); + + delete object; + } +} + +void tst_qqmlvaluetypes::quaternion() +{ + { + QQmlComponent component(&engine, testFileUrl("quaternion_read.qml")); + MyTypeObject *object = qobject_cast(component.create()); + QVERIFY(object != 0); + + QCOMPARE((float)object->property("v_scalar").toDouble(), (float)4.3); + QCOMPARE((float)object->property("v_x").toDouble(), (float)54.2); + QCOMPARE((float)object->property("v_y").toDouble(), (float)23.88); + QCOMPARE((float)object->property("v_z").toDouble(), (float)3.1); + QCOMPARE(object->property("copy"), QVariant(QQuaternion(4.3, 54.2, 23.88, 3.1))); + + delete object; + } + + { + QQmlComponent component(&engine, testFileUrl("quaternion_write.qml")); + MyTypeObject *object = qobject_cast(component.create()); + QVERIFY(object != 0); + + QCOMPARE(object->quaternion(), QQuaternion(88.5, -0.3, -12.9, 907.4)); + + delete object; + } + + { + QQmlComponent component(&engine, testFileUrl("quaternion_compare.qml")); + MyTypeObject *object = qobject_cast(component.create()); + QVERIFY(object != 0); + + QString tostring = QLatin1String("QQuaternion(4.3, 54.2, 23.88, 3.1)"); + QCOMPARE(object->property("tostring").toString(), tostring); + QCOMPARE(object->property("equalsString").toBool(), true); + QCOMPARE(object->property("equalsColor").toBool(), false); + QCOMPARE(object->property("equalsVector3d").toBool(), false); + QCOMPARE(object->property("equalsSize").toBool(), false); + QCOMPARE(object->property("equalsPoint").toBool(), false); + QCOMPARE(object->property("equalsRect").toBool(), false); + QCOMPARE(object->property("equalsSelf").toBool(), true); + + delete object; + } +} + +void tst_qqmlvaluetypes::matrix4x4() +{ + { + QQmlComponent component(&engine, testFileUrl("matrix4x4_read.qml")); + MyTypeObject *object = qobject_cast(component.create()); + QVERIFY(object != 0); + + QCOMPARE((float)object->property("v_m11").toDouble(), (float)1); + QCOMPARE((float)object->property("v_m12").toDouble(), (float)2); + QCOMPARE((float)object->property("v_m13").toDouble(), (float)3); + QCOMPARE((float)object->property("v_m14").toDouble(), (float)4); + QCOMPARE((float)object->property("v_m21").toDouble(), (float)5); + QCOMPARE((float)object->property("v_m22").toDouble(), (float)6); + QCOMPARE((float)object->property("v_m23").toDouble(), (float)7); + QCOMPARE((float)object->property("v_m24").toDouble(), (float)8); + QCOMPARE((float)object->property("v_m31").toDouble(), (float)9); + QCOMPARE((float)object->property("v_m32").toDouble(), (float)10); + QCOMPARE((float)object->property("v_m33").toDouble(), (float)11); + QCOMPARE((float)object->property("v_m34").toDouble(), (float)12); + QCOMPARE((float)object->property("v_m41").toDouble(), (float)13); + QCOMPARE((float)object->property("v_m42").toDouble(), (float)14); + QCOMPARE((float)object->property("v_m43").toDouble(), (float)15); + QCOMPARE((float)object->property("v_m44").toDouble(), (float)16); + QCOMPARE(object->property("copy"), + QVariant(QMatrix4x4(1, 2, 3, 4, + 5, 6, 7, 8, + 9, 10, 11, 12, + 13, 14, 15, 16))); + + delete object; + } + + { + QQmlComponent component(&engine, testFileUrl("matrix4x4_write.qml")); + MyTypeObject *object = qobject_cast(component.create()); + QVERIFY(object != 0); + + QCOMPARE(object->matrix(), QMatrix4x4(11, 12, 13, 14, + 21, 22, 23, 24, + 31, 32, 33, 34, + 41, 42, 43, 44)); + + delete object; + } + + { + QQmlComponent component(&engine, testFileUrl("matrix4x4_compare.qml")); + MyTypeObject *object = qobject_cast(component.create()); + QVERIFY(object != 0); + + QString tostring = QLatin1String("QMatrix4x4(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16)"); + QCOMPARE(object->property("tostring").toString(), tostring); + QCOMPARE(object->property("equalsString").toBool(), true); + QCOMPARE(object->property("equalsColor").toBool(), false); + QCOMPARE(object->property("equalsVector3d").toBool(), false); + QCOMPARE(object->property("equalsSize").toBool(), false); + QCOMPARE(object->property("equalsPoint").toBool(), false); + QCOMPARE(object->property("equalsRect").toBool(), false); + QCOMPARE(object->property("equalsSelf").toBool(), true); + + delete object; + } +} + +void tst_qqmlvaluetypes::font() +{ + { + QQmlComponent component(&engine, testFileUrl("font_read.qml")); + MyTypeObject *object = qobject_cast(component.create()); + QVERIFY(object != 0); + + QCOMPARE(object->property("f_family").toString(), object->font().family()); + QCOMPARE(object->property("f_bold").toBool(), object->font().bold()); + QCOMPARE(object->property("f_weight").toInt(), object->font().weight()); + QCOMPARE(object->property("f_italic").toBool(), object->font().italic()); + QCOMPARE(object->property("f_underline").toBool(), object->font().underline()); + QCOMPARE(object->property("f_overline").toBool(), object->font().overline()); + QCOMPARE(object->property("f_strikeout").toBool(), object->font().strikeOut()); + QCOMPARE(object->property("f_pointSize").toDouble(), object->font().pointSizeF()); + QCOMPARE(object->property("f_pixelSize").toInt(), int((object->font().pointSizeF() * qt_defaultDpi()) / qreal(72.))); + QCOMPARE(object->property("f_capitalization").toInt(), (int)object->font().capitalization()); + QCOMPARE(object->property("f_letterSpacing").toDouble(), object->font().letterSpacing()); + QCOMPARE(object->property("f_wordSpacing").toDouble(), object->font().wordSpacing()); + + QCOMPARE(object->property("copy"), QVariant(object->font())); + + delete object; + } + + { + QQmlComponent component(&engine, testFileUrl("font_write.qml")); + MyTypeObject *object = qobject_cast(component.create()); + QVERIFY(object != 0); + + QFont font; + font.setFamily("Helvetica"); + font.setBold(false); + font.setWeight(QFont::Normal); + font.setItalic(false); + font.setUnderline(false); + font.setStrikeOut(false); + font.setPointSize(15); + font.setCapitalization(QFont::AllLowercase); + font.setLetterSpacing(QFont::AbsoluteSpacing, 9.7); + font.setWordSpacing(11.2); + + QFont f = object->font(); + QCOMPARE(f.family(), font.family()); + QCOMPARE(f.bold(), font.bold()); + QCOMPARE(f.weight(), font.weight()); + QCOMPARE(f.italic(), font.italic()); + QCOMPARE(f.underline(), font.underline()); + QCOMPARE(f.strikeOut(), font.strikeOut()); + QCOMPARE(f.pointSize(), font.pointSize()); + QCOMPARE(f.capitalization(), font.capitalization()); + QCOMPARE(f.letterSpacing(), font.letterSpacing()); + QCOMPARE(f.wordSpacing(), font.wordSpacing()); + + delete object; + } + + // Test pixelSize + { + QQmlComponent component(&engine, testFileUrl("font_write.2.qml")); + MyTypeObject *object = qobject_cast(component.create()); + QVERIFY(object != 0); + + QCOMPARE(object->font().pixelSize(), 10); + + delete object; + } + + // Test pixelSize and pointSize + { + QQmlComponent component(&engine, testFileUrl("font_write.3.qml")); + QTest::ignoreMessage(QtWarningMsg, "Both point size and pixel size set. Using pixel size. "); + MyTypeObject *object = qobject_cast(component.create()); + QVERIFY(object != 0); + + QCOMPARE(object->font().pixelSize(), 10); + + delete object; + } + { + QQmlComponent component(&engine, testFileUrl("font_write.4.qml")); + QTest::ignoreMessage(QtWarningMsg, "Both point size and pixel size set. Using pixel size. "); + MyTypeObject *object = qobject_cast(component.create()); + QVERIFY(object != 0); + + QCOMPARE(object->font().pixelSize(), 10); + + delete object; + } + { + QQmlComponent component(&engine, testFileUrl("font_write.5.qml")); + QObject *object = qobject_cast(component.create()); + QVERIFY(object != 0); + MyTypeObject *object1 = object->findChild("object1"); + QVERIFY(object1 != 0); + MyTypeObject *object2 = object->findChild("object2"); + QVERIFY(object2 != 0); + + QCOMPARE(object1->font().pixelSize(), 19); + QCOMPARE(object2->font().pointSize(), 14); + + delete object; + } + + { + QQmlComponent component(&engine, testFileUrl("font_compare.qml")); + MyTypeObject *object = qobject_cast(component.create()); + QVERIFY(object != 0); + + QString tostring = QLatin1String("QFont(") + object->font().toString() + QLatin1Char(')'); + QCOMPARE(object->property("tostring").toString(), tostring); + QCOMPARE(object->property("equalsString").toBool(), true); + QCOMPARE(object->property("equalsColor").toBool(), false); + QCOMPARE(object->property("equalsVector3d").toBool(), false); + QCOMPARE(object->property("equalsSize").toBool(), false); + QCOMPARE(object->property("equalsPoint").toBool(), false); + QCOMPARE(object->property("equalsRect").toBool(), false); + QCOMPARE(object->property("equalsSelf").toBool(), true); + + delete object; + } +} + +void tst_qqmlvaluetypes::color() +{ + { + QQmlComponent component(&engine, testFileUrl("color_read.qml")); + MyTypeObject *object = qobject_cast(component.create()); + QVERIFY(object != 0); + + QCOMPARE((float)object->property("v_r").toDouble(), (float)0.2); + QCOMPARE((float)object->property("v_g").toDouble(), (float)0.88); + QCOMPARE((float)object->property("v_b").toDouble(), (float)0.6); + QCOMPARE((float)object->property("v_a").toDouble(), (float)0.34); + QColor comparison; + comparison.setRedF(0.2); + comparison.setGreenF(0.88); + comparison.setBlueF(0.6); + comparison.setAlphaF(0.34); + QCOMPARE(object->property("copy"), QVariant(comparison)); + + delete object; + } + + { + QQmlComponent component(&engine, testFileUrl("color_write.qml")); + MyTypeObject *object = qobject_cast(component.create()); + QVERIFY(object != 0); + + QColor newColor; + newColor.setRedF(0.5); + newColor.setGreenF(0.38); + newColor.setBlueF(0.3); + newColor.setAlphaF(0.7); + QCOMPARE(object->color(), newColor); + + delete object; + } + + { + QQmlComponent component(&engine, testFileUrl("color_compare.qml")); + MyTypeObject *object = qobject_cast(component.create()); + QVERIFY(object != 0); + QString colorString("#33e199"); + QCOMPARE(object->property("colorToString").toString(), colorString); + QCOMPARE(object->property("colorEqualsIdenticalRgba").toBool(), true); + QCOMPARE(object->property("colorEqualsDifferentAlpha").toBool(), false); + QCOMPARE(object->property("colorEqualsDifferentRgba").toBool(), false); + QCOMPARE(object->property("colorToStringEqualsColorString").toBool(), true); + QCOMPARE(object->property("colorToStringEqualsDifferentAlphaString").toBool(), true); + QCOMPARE(object->property("colorToStringEqualsDifferentRgbaString").toBool(), false); + QCOMPARE(object->property("colorEqualsColorString").toBool(), true); // maintaining behaviour with QtQuick 1.0 + QCOMPARE(object->property("colorEqualsDifferentAlphaString").toBool(), true); // maintaining behaviour with QtQuick 1.0 + QCOMPARE(object->property("colorEqualsDifferentRgbaString").toBool(), false); + + QCOMPARE(object->property("equalsColor").toBool(), true); + QCOMPARE(object->property("equalsVector3d").toBool(), false); + QCOMPARE(object->property("equalsSize").toBool(), false); + QCOMPARE(object->property("equalsPoint").toBool(), false); + QCOMPARE(object->property("equalsRect").toBool(), false); + + // Color == Property and Property == Color should return the same result. + QCOMPARE(object->property("equalsColorRHS").toBool(), object->property("equalsColor").toBool()); + QCOMPARE(object->property("colorEqualsCopy").toBool(), true); + QCOMPARE(object->property("copyEqualsColor").toBool(), object->property("colorEqualsCopy").toBool()); + + delete object; + } +} + +// Test bindings can write to value types +void tst_qqmlvaluetypes::bindingAssignment() +{ + QQmlComponent component(&engine, testFileUrl("bindingAssignment.qml")); + MyTypeObject *object = qobject_cast(component.create()); + QVERIFY(object != 0); + + QCOMPARE(object->rect().x(), 10); + + object->setProperty("value", QVariant(92)); + + QCOMPARE(object->rect().x(), 92); + + delete object; +} + +// Test bindings can read from value types +void tst_qqmlvaluetypes::bindingRead() +{ + QQmlComponent component(&engine, testFileUrl("bindingRead.qml")); + MyTypeObject *object = qobject_cast(component.create()); + QVERIFY(object != 0); + + QCOMPARE(object->property("value").toInt(), 2); + + object->setRect(QRect(19, 3, 88, 2)); + + QCOMPARE(object->property("value").toInt(), 19); + + delete object; +} + +// Test static values can assign to value types +void tst_qqmlvaluetypes::staticAssignment() +{ + QQmlComponent component(&engine, testFileUrl("staticAssignment.qml")); + MyTypeObject *object = qobject_cast(component.create()); + QVERIFY(object != 0); + + QCOMPARE(object->rect().x(), 9); + + delete object; +} + +// Test scripts can read/write value types +void tst_qqmlvaluetypes::scriptAccess() +{ + QQmlComponent component(&engine, testFileUrl("scriptAccess.qml")); + MyTypeObject *object = qobject_cast(component.create()); + QVERIFY(object != 0); + + QCOMPARE(object->property("valuePre").toInt(), 2); + QCOMPARE(object->rect().x(), 19); + QCOMPARE(object->property("valuePost").toInt(), 19); + + delete object; +} + +// Test that assigning a constant from script removes any binding +void tst_qqmlvaluetypes::autoBindingRemoval() +{ + { + QQmlComponent component(&engine, testFileUrl("autoBindingRemoval.qml")); + MyTypeObject *object = qobject_cast(component.create()); + QVERIFY(object != 0); + + QCOMPARE(object->rect().x(), 10); + + object->setProperty("value", QVariant(13)); + + QCOMPARE(object->rect().x(), 13); + + object->emitRunScript(); + + QCOMPARE(object->rect().x(), 42); + + object->setProperty("value", QVariant(92)); + + QCOMPARE(object->rect().x(), 42); + + delete object; + } + + /* + { + QQmlComponent component(&engine, testFileUrl("autoBindingRemoval.2.qml")); + MyTypeObject *object = qobject_cast(component.create()); + QVERIFY(object != 0); + + QCOMPARE(object->rect().x(), 10); + + object->setProperty("value", QVariant(13)); + + QCOMPARE(object->rect().x(), 13); + + object->emitRunScript(); + + QCOMPARE(object->rect(), QRect(10, 10, 10, 10)); + + object->setProperty("value", QVariant(92)); + + QCOMPARE(object->rect(), QRect(10, 10, 10, 10)); + + delete object; + } + + { + QQmlComponent component(&engine, testFileUrl("autoBindingRemoval.3.qml")); + MyTypeObject *object = qobject_cast(component.create()); + QVERIFY(object != 0); + + object->setProperty("value", QVariant(QRect(9, 22, 33, 44))); + + QCOMPARE(object->rect(), QRect(9, 22, 33, 44)); + + object->emitRunScript(); + + QCOMPARE(object->rect(), QRect(44, 22, 33, 44)); + + object->setProperty("value", QVariant(QRect(19, 3, 4, 8))); + + QCOMPARE(object->rect(), QRect(44, 22, 33, 44)); + + delete object; + } +*/ +} + +// Test that property value sources assign to value types +void tst_qqmlvaluetypes::valueSources() +{ + QQmlComponent component(&engine, testFileUrl("valueSources.qml")); + MyTypeObject *object = qobject_cast(component.create()); + QVERIFY(object != 0); + + QCOMPARE(object->rect().x(), 3345); + + delete object; +} + +static void checkNoErrors(QQmlComponent& component) +{ + QList errors = component.errors(); + if (errors.isEmpty()) + return; + for (int ii = 0; ii < errors.count(); ++ii) { + const QQmlError &error = errors.at(ii); + qWarning("%d:%d:%s",error.line(),error.column(),error.description().toUtf8().constData()); + } +} + +// Test that property value interceptors can be applied to value types +void tst_qqmlvaluetypes::valueInterceptors() +{ + QQmlComponent component(&engine, testFileUrl("valueInterceptors.qml")); + MyTypeObject *object = qobject_cast(component.create()); + checkNoErrors(component); + QVERIFY(object != 0); + + QCOMPARE(object->rect().x(), 13); + + object->setProperty("value", 99); + + QCOMPARE(object->rect().x(), 112); + + delete object; +} + +// Test that you can't assign a binding to the "root" value type, and a sub-property +void tst_qqmlvaluetypes::bindingConflict() +{ + QQmlComponent component(&engine, testFileUrl("bindingConflict.qml")); + QCOMPARE(component.isError(), true); +} + +#define CPP_TEST(type, v) \ +{ \ + type *t = new type; \ + QVariant value(v); \ + t->setValue(value); \ + QCOMPARE(t->value(), value); \ + delete t; \ +} + +// Test that accessing a reference to a valuetype after the owning object is deleted +// doesn't crash +void tst_qqmlvaluetypes::deletedObject() +{ + QQmlComponent component(&engine, testFileUrl("deletedObject.qml")); + QTest::ignoreMessage(QtDebugMsg, "Test: 2"); + MyTypeObject *object = qobject_cast(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_qqmlvaluetypes::bindingVariantCopy() +{ + QQmlComponent component(&engine, testFileUrl("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_qqmlvaluetypes::scriptVariantCopy() +{ + QQmlComponent component(&engine, testFileUrl("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_qqmlvaluetypes::cppClasses() +{ + CPP_TEST(QQmlPointValueType, QPoint(19, 33)); + CPP_TEST(QQmlPointFValueType, QPointF(33.6, -23)); + CPP_TEST(QQmlSizeValueType, QSize(-100, 18)); + CPP_TEST(QQmlSizeFValueType, QSizeF(-100.7, 18.2)); + CPP_TEST(QQmlRectValueType, QRect(13, 39, 10928, 88)); + CPP_TEST(QQmlRectFValueType, QRectF(88.2, -90.1, 103.2, 118)); + CPP_TEST(QQmlVector2DValueType, QVector2D(19.7, 1002)); + CPP_TEST(QQmlVector3DValueType, QVector3D(18.2, 19.7, 1002)); + CPP_TEST(QQmlVector4DValueType, QVector4D(18.2, 19.7, 1002, 54)); + CPP_TEST(QQmlQuaternionValueType, QQuaternion(18.2, 19.7, 1002, 54)); + CPP_TEST(QQmlMatrix4x4ValueType, + QMatrix4x4(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16)); + CPP_TEST(QQmlFontValueType, QFont("Helvetica")); + +} + +void tst_qqmlvaluetypes::enums() +{ + { + QQmlComponent component(&engine, testFileUrl("enums.1.qml")); + MyTypeObject *object = qobject_cast(component.create()); + QVERIFY(object != 0); + QVERIFY(object->font().capitalization() == QFont::AllUppercase); + delete object; + } + + { + QQmlComponent component(&engine, testFileUrl("enums.2.qml")); + MyTypeObject *object = qobject_cast(component.create()); + QVERIFY(object != 0); + QVERIFY(object->font().capitalization() == QFont::AllUppercase); + delete object; + } + + { + QQmlComponent component(&engine, testFileUrl("enums.3.qml")); + MyTypeObject *object = qobject_cast(component.create()); + QVERIFY(object != 0); + QVERIFY(object->font().capitalization() == QFont::AllUppercase); + delete object; + } + + { + QQmlComponent component(&engine, testFileUrl("enums.4.qml")); + MyTypeObject *object = qobject_cast(component.create()); + QVERIFY(object != 0); + QVERIFY(object->font().capitalization() == QFont::AllUppercase); + delete object; + } + + { + QQmlComponent component(&engine, testFileUrl("enums.5.qml")); + MyTypeObject *object = qobject_cast(component.create()); + QVERIFY(object != 0); + QVERIFY(object->font().capitalization() == QFont::AllUppercase); + delete object; + } +} + +// Tests switching between "conflicting" bindings (eg. a binding on the core +// property, to a binding on the value-type sub-property) +void tst_qqmlvaluetypes::conflictingBindings() +{ + { + QQmlComponent component(&engine, testFileUrl("conflicting.1.qml")); + QObject *object = component.create(); + QVERIFY(object != 0); + + QCOMPARE(qvariant_cast(object->property("font")).pixelSize(), 12); + + QMetaObject::invokeMethod(object, "toggle"); + + QCOMPARE(qvariant_cast(object->property("font")).pixelSize(), 6); + + QMetaObject::invokeMethod(object, "toggle"); + + QCOMPARE(qvariant_cast(object->property("font")).pixelSize(), 12); + + delete object; + } + + { + QQmlComponent component(&engine, testFileUrl("conflicting.2.qml")); + QObject *object = component.create(); + QVERIFY(object != 0); + + QCOMPARE(qvariant_cast(object->property("font")).pixelSize(), 6); + + QMetaObject::invokeMethod(object, "toggle"); + + QCOMPARE(qvariant_cast(object->property("font")).pixelSize(), 12); + + QMetaObject::invokeMethod(object, "toggle"); + + QCOMPARE(qvariant_cast(object->property("font")).pixelSize(), 6); + + delete object; + } + + { + QQmlComponent component(&engine, testFileUrl("conflicting.3.qml")); + QObject *object = component.create(); + QVERIFY(object != 0); + + QCOMPARE(qvariant_cast(object->property("font")).pixelSize(), 12); + + QMetaObject::invokeMethod(object, "toggle"); + + QCOMPARE(qvariant_cast(object->property("font")).pixelSize(), 24); + + QMetaObject::invokeMethod(object, "toggle"); + + QCOMPARE(qvariant_cast(object->property("font")).pixelSize(), 12); + + delete object; + } +} + +void tst_qqmlvaluetypes::returnValues() +{ + QQmlComponent component(&engine, testFileUrl("returnValues.qml")); + QObject *object = component.create(); + QVERIFY(object != 0); + + QCOMPARE(object->property("test1").toBool(), true); + QCOMPARE(object->property("test2").toBool(), true); + QCOMPARE(object->property("size").toSize(), QSize(13, 14)); + + delete object; +} + +void tst_qqmlvaluetypes::varAssignment() +{ + QQmlComponent component(&engine, testFileUrl("varAssignment.qml")); + QObject *object = component.create(); + QVERIFY(object != 0); + + QCOMPARE(object->property("x").toInt(), 1); + QCOMPARE(object->property("y").toInt(), 2); + QCOMPARE(object->property("z").toInt(), 3); + + delete object; +} + +// Test bindings splice together correctly +void tst_qqmlvaluetypes::bindingsSpliceCorrectly() +{ + { + QQmlComponent component(&engine, testFileUrl("bindingsSpliceCorrectly.1.qml")); + QObject *object = component.create(); + QVERIFY(object != 0); + + QCOMPARE(object->property("test").toBool(), true); + + delete object; + } + + { + QQmlComponent component(&engine, testFileUrl("bindingsSpliceCorrectly.2.qml")); + QObject *object = component.create(); + QVERIFY(object != 0); + + QCOMPARE(object->property("test").toBool(), true); + + delete object; + } + + + { + QQmlComponent component(&engine, testFileUrl("bindingsSpliceCorrectly.3.qml")); + QObject *object = component.create(); + QVERIFY(object != 0); + + QCOMPARE(object->property("test").toBool(), true); + + delete object; + } + + { + QQmlComponent component(&engine, testFileUrl("bindingsSpliceCorrectly.4.qml")); + QObject *object = component.create(); + QVERIFY(object != 0); + + QCOMPARE(object->property("test").toBool(), true); + + delete object; + } + + { + QQmlComponent component(&engine, testFileUrl("bindingsSpliceCorrectly.5.qml")); + QObject *object = component.create(); + QVERIFY(object != 0); + + QCOMPARE(object->property("test").toBool(), true); + + delete object; + } +} + +QTEST_MAIN(tst_qqmlvaluetypes) + +#include "tst_qqmlvaluetypes.moc" diff --git a/tests/auto/qml/qqmlxmlhttprequest/data/abort.expect b/tests/auto/qml/qqmlxmlhttprequest/data/abort.expect new file mode 100644 index 0000000000..d6951a8255 --- /dev/null +++ b/tests/auto/qml/qqmlxmlhttprequest/data/abort.expect @@ -0,0 +1,10 @@ +PUT /testdocument.html HTTP/1.1 +Accept-Language: en-US +Content-Type: text/plain;charset=UTF-8 +Content-Length: 9 +Connection: Keep-Alive +Accept-Encoding: gzip, deflate +User-Agent: Mozilla/5.0 +Host: 127.0.0.1:14445 + +Test Data \ No newline at end of file diff --git a/tests/auto/qml/qqmlxmlhttprequest/data/abort.qml b/tests/auto/qml/qqmlxmlhttprequest/data/abort.qml new file mode 100644 index 0000000000..9ba97fac4b --- /dev/null +++ b/tests/auto/qml/qqmlxmlhttprequest/data/abort.qml @@ -0,0 +1,44 @@ +import QtQuick 2.0 + +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.setRequestHeader("Accept-Language", "en-US"); + 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.setRequestHeader("Accept-Language", "en-US"); + x.send("Test Data"); + } +} + + diff --git a/tests/auto/qml/qqmlxmlhttprequest/data/abort.reply b/tests/auto/qml/qqmlxmlhttprequest/data/abort.reply new file mode 100644 index 0000000000..7ae6951f9b --- /dev/null +++ b/tests/auto/qml/qqmlxmlhttprequest/data/abort.reply @@ -0,0 +1,3 @@ +HTTP/1.0 200 OK +Connection: close +Content-type: text/html; charset=UTF-8 diff --git a/tests/auto/qml/qqmlxmlhttprequest/data/abort_opened.qml b/tests/auto/qml/qqmlxmlhttprequest/data/abort_opened.qml new file mode 100644 index 0000000000..d5bb84ddc0 --- /dev/null +++ b/tests/auto/qml/qqmlxmlhttprequest/data/abort_opened.qml @@ -0,0 +1,60 @@ +import QtQuick 2.0 + +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.setRequestHeader("Accept-Language", "en-US"); + + x.abort(); + + x.open("GET", url); + x.setRequestHeader("Accept-Language", "en-US"); + + 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/qml/qqmlxmlhttprequest/data/abort_unsent.qml b/tests/auto/qml/qqmlxmlhttprequest/data/abort_unsent.qml new file mode 100644 index 0000000000..4f58062a26 --- /dev/null +++ b/tests/auto/qml/qqmlxmlhttprequest/data/abort_unsent.qml @@ -0,0 +1,55 @@ +import QtQuick 2.0 + +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); + x.setRequestHeader("Accept-Language", "en-US"); + + 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/qml/qqmlxmlhttprequest/data/attr.qml b/tests/auto/qml/qqmlxmlhttprequest/data/attr.qml new file mode 100644 index 0000000000..b1c081c5fd --- /dev/null +++ b/tests/auto/qml/qqmlxmlhttprequest/data/attr.qml @@ -0,0 +1,78 @@ +import QtQuick 2.0 + +QtObject { + property bool xmlTest: false + property bool dataOK: false + + 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/qml/qqmlxmlhttprequest/data/attr.xml b/tests/auto/qml/qqmlxmlhttprequest/data/attr.xml new file mode 100644 index 0000000000..2aa64a3d00 --- /dev/null +++ b/tests/auto/qml/qqmlxmlhttprequest/data/attr.xml @@ -0,0 +1 @@ + diff --git a/tests/auto/qml/qqmlxmlhttprequest/data/callbackException.qml b/tests/auto/qml/qqmlxmlhttprequest/data/callbackException.qml new file mode 100644 index 0000000000..ee1043f97f --- /dev/null +++ b/tests/auto/qml/qqmlxmlhttprequest/data/callbackException.qml @@ -0,0 +1,25 @@ +import QtQuick 2.0 + +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/qml/qqmlxmlhttprequest/data/cdata.qml b/tests/auto/qml/qqmlxmlhttprequest/data/cdata.qml new file mode 100644 index 0000000000..f558fdadc6 --- /dev/null +++ b/tests/auto/qml/qqmlxmlhttprequest/data/cdata.qml @@ -0,0 +1,133 @@ +import QtQuick 2.0 + +QtObject { + property bool xmlTest: false + property bool dataOK: false + + 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/qml/qqmlxmlhttprequest/data/cdata.xml b/tests/auto/qml/qqmlxmlhttprequest/data/cdata.xml new file mode 100644 index 0000000000..061d37c0b6 --- /dev/null +++ b/tests/auto/qml/qqmlxmlhttprequest/data/cdata.xml @@ -0,0 +1,2 @@ + + diff --git a/tests/auto/qml/qqmlxmlhttprequest/data/constructor.qml b/tests/auto/qml/qqmlxmlhttprequest/data/constructor.qml new file mode 100644 index 0000000000..458066736e --- /dev/null +++ b/tests/auto/qml/qqmlxmlhttprequest/data/constructor.qml @@ -0,0 +1,14 @@ +import QtQuick 2.0 + +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/qml/qqmlxmlhttprequest/data/defaultState.qml b/tests/auto/qml/qqmlxmlhttprequest/data/defaultState.qml new file mode 100644 index 0000000000..913fe59f99 --- /dev/null +++ b/tests/auto/qml/qqmlxmlhttprequest/data/defaultState.qml @@ -0,0 +1,30 @@ +import QtQuick 2.0 + +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/qml/qqmlxmlhttprequest/data/document.qml b/tests/auto/qml/qqmlxmlhttprequest/data/document.qml new file mode 100644 index 0000000000..7695cd76a1 --- /dev/null +++ b/tests/auto/qml/qqmlxmlhttprequest/data/document.qml @@ -0,0 +1,56 @@ +import QtQuick 2.0 + +QtObject { + property bool xmlTest: false + property bool dataOK: false + + 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/qml/qqmlxmlhttprequest/data/document.xml b/tests/auto/qml/qqmlxmlhttprequest/data/document.xml new file mode 100644 index 0000000000..fb693ea193 --- /dev/null +++ b/tests/auto/qml/qqmlxmlhttprequest/data/document.xml @@ -0,0 +1,3 @@ + + + diff --git a/tests/auto/qml/qqmlxmlhttprequest/data/domExceptionCodes.qml b/tests/auto/qml/qqmlxmlhttprequest/data/domExceptionCodes.qml new file mode 100644 index 0000000000..092db3443d --- /dev/null +++ b/tests/auto/qml/qqmlxmlhttprequest/data/domExceptionCodes.qml @@ -0,0 +1,60 @@ +import QtQuick 2.0 + +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/qml/qqmlxmlhttprequest/data/element.qml b/tests/auto/qml/qqmlxmlhttprequest/data/element.qml new file mode 100644 index 0000000000..9b190f3a43 --- /dev/null +++ b/tests/auto/qml/qqmlxmlhttprequest/data/element.qml @@ -0,0 +1,145 @@ +import QtQuick 2.0 + +QtObject { + property bool xmlTest: false + property bool dataOK: false + + 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/qml/qqmlxmlhttprequest/data/element.xml b/tests/auto/qml/qqmlxmlhttprequest/data/element.xml new file mode 100644 index 0000000000..071ffae057 --- /dev/null +++ b/tests/auto/qml/qqmlxmlhttprequest/data/element.xml @@ -0,0 +1 @@ + diff --git a/tests/auto/qml/qqmlxmlhttprequest/data/getAllResponseHeaders.qml b/tests/auto/qml/qqmlxmlhttprequest/data/getAllResponseHeaders.qml new file mode 100644 index 0000000000..580688b835 --- /dev/null +++ b/tests/auto/qml/qqmlxmlhttprequest/data/getAllResponseHeaders.qml @@ -0,0 +1,66 @@ +import QtQuick 2.0 + +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); + x.setRequestHeader("Accept-Language", "en-US"); + + 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 = "connection: close\r\ncontent-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/qml/qqmlxmlhttprequest/data/getAllResponseHeaders_args.qml b/tests/auto/qml/qqmlxmlhttprequest/data/getAllResponseHeaders_args.qml new file mode 100644 index 0000000000..84a0bf3015 --- /dev/null +++ b/tests/auto/qml/qqmlxmlhttprequest/data/getAllResponseHeaders_args.qml @@ -0,0 +1,23 @@ +import QtQuick 2.0 + +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/qml/qqmlxmlhttprequest/data/getAllResponseHeaders_sent.qml b/tests/auto/qml/qqmlxmlhttprequest/data/getAllResponseHeaders_sent.qml new file mode 100644 index 0000000000..27edb4c4b7 --- /dev/null +++ b/tests/auto/qml/qqmlxmlhttprequest/data/getAllResponseHeaders_sent.qml @@ -0,0 +1,20 @@ +import QtQuick 2.0 + +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/qml/qqmlxmlhttprequest/data/getAllResponseHeaders_unsent.qml b/tests/auto/qml/qqmlxmlhttprequest/data/getAllResponseHeaders_unsent.qml new file mode 100644 index 0000000000..3d57348cc5 --- /dev/null +++ b/tests/auto/qml/qqmlxmlhttprequest/data/getAllResponseHeaders_unsent.qml @@ -0,0 +1,16 @@ +import QtQuick 2.0 + +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/qml/qqmlxmlhttprequest/data/getResponseHeader.expect b/tests/auto/qml/qqmlxmlhttprequest/data/getResponseHeader.expect new file mode 100644 index 0000000000..cf5830ed0c --- /dev/null +++ b/tests/auto/qml/qqmlxmlhttprequest/data/getResponseHeader.expect @@ -0,0 +1,7 @@ +GET /testdocument.html HTTP/1.1 +Accept-Language: en-US +Connection: Keep-Alive +Accept-Encoding: gzip, deflate +User-Agent: Mozilla/5.0 +Host: 127.0.0.1:14445 + diff --git a/tests/auto/qml/qqmlxmlhttprequest/data/getResponseHeader.qml b/tests/auto/qml/qqmlxmlhttprequest/data/getResponseHeader.qml new file mode 100644 index 0000000000..203967e539 --- /dev/null +++ b/tests/auto/qml/qqmlxmlhttprequest/data/getResponseHeader.qml @@ -0,0 +1,76 @@ +import QtQuick 2.0 + +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); + x.setRequestHeader("Accept-Language", "en-US"); + + 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/qml/qqmlxmlhttprequest/data/getResponseHeader.reply b/tests/auto/qml/qqmlxmlhttprequest/data/getResponseHeader.reply new file mode 100644 index 0000000000..c4b4bb2763 --- /dev/null +++ b/tests/auto/qml/qqmlxmlhttprequest/data/getResponseHeader.reply @@ -0,0 +1,8 @@ +HTTP/1.0 200 OK +Connection: close +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/qml/qqmlxmlhttprequest/data/getResponseHeader_args.qml b/tests/auto/qml/qqmlxmlhttprequest/data/getResponseHeader_args.qml new file mode 100644 index 0000000000..dccc71dfc3 --- /dev/null +++ b/tests/auto/qml/qqmlxmlhttprequest/data/getResponseHeader_args.qml @@ -0,0 +1,23 @@ +import QtQuick 2.0 + +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/qml/qqmlxmlhttprequest/data/getResponseHeader_sent.qml b/tests/auto/qml/qqmlxmlhttprequest/data/getResponseHeader_sent.qml new file mode 100644 index 0000000000..cff7af79e2 --- /dev/null +++ b/tests/auto/qml/qqmlxmlhttprequest/data/getResponseHeader_sent.qml @@ -0,0 +1,20 @@ +import QtQuick 2.0 + +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/qml/qqmlxmlhttprequest/data/getResponseHeader_unsent.qml b/tests/auto/qml/qqmlxmlhttprequest/data/getResponseHeader_unsent.qml new file mode 100644 index 0000000000..ad2ea0bd33 --- /dev/null +++ b/tests/auto/qml/qqmlxmlhttprequest/data/getResponseHeader_unsent.qml @@ -0,0 +1,16 @@ +import QtQuick 2.0 + +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/qml/qqmlxmlhttprequest/data/instanceStateValues.qml b/tests/auto/qml/qqmlxmlhttprequest/data/instanceStateValues.qml new file mode 100644 index 0000000000..b3a54e9b53 --- /dev/null +++ b/tests/auto/qml/qqmlxmlhttprequest/data/instanceStateValues.qml @@ -0,0 +1,33 @@ +import QtQuick 2.0 + +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/qml/qqmlxmlhttprequest/data/invalidMethodUsage.qml b/tests/auto/qml/qqmlxmlhttprequest/data/invalidMethodUsage.qml new file mode 100644 index 0000000000..5a4093b9f1 --- /dev/null +++ b/tests/auto/qml/qqmlxmlhttprequest/data/invalidMethodUsage.qml @@ -0,0 +1,148 @@ +import QtQuick 2.0 + +QtObject { + 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.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/qml/qqmlxmlhttprequest/data/open.qml b/tests/auto/qml/qqmlxmlhttprequest/data/open.qml new file mode 100644 index 0000000000..6e7681dfb4 --- /dev/null +++ b/tests/auto/qml/qqmlxmlhttprequest/data/open.qml @@ -0,0 +1,54 @@ +import QtQuick 2.0 + +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); + x.setRequestHeader("Accept-Language","en-US"); + + 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/qml/qqmlxmlhttprequest/data/open_arg_count.1.qml b/tests/auto/qml/qqmlxmlhttprequest/data/open_arg_count.1.qml new file mode 100644 index 0000000000..61ef76d488 --- /dev/null +++ b/tests/auto/qml/qqmlxmlhttprequest/data/open_arg_count.1.qml @@ -0,0 +1,18 @@ +import QtQuick 2.0 + +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/qml/qqmlxmlhttprequest/data/open_arg_count.2.qml b/tests/auto/qml/qqmlxmlhttprequest/data/open_arg_count.2.qml new file mode 100644 index 0000000000..677759ccf3 --- /dev/null +++ b/tests/auto/qml/qqmlxmlhttprequest/data/open_arg_count.2.qml @@ -0,0 +1,18 @@ +import QtQuick 2.0 + +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/qml/qqmlxmlhttprequest/data/open_invalid_method.qml b/tests/auto/qml/qqmlxmlhttprequest/data/open_invalid_method.qml new file mode 100644 index 0000000000..0f29031e42 --- /dev/null +++ b/tests/auto/qml/qqmlxmlhttprequest/data/open_invalid_method.qml @@ -0,0 +1,16 @@ +import QtQuick 2.0 + +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/qml/qqmlxmlhttprequest/data/open_network.expect b/tests/auto/qml/qqmlxmlhttprequest/data/open_network.expect new file mode 100644 index 0000000000..cf5830ed0c --- /dev/null +++ b/tests/auto/qml/qqmlxmlhttprequest/data/open_network.expect @@ -0,0 +1,7 @@ +GET /testdocument.html HTTP/1.1 +Accept-Language: en-US +Connection: Keep-Alive +Accept-Encoding: gzip, deflate +User-Agent: Mozilla/5.0 +Host: 127.0.0.1:14445 + diff --git a/tests/auto/qml/qqmlxmlhttprequest/data/open_network.reply b/tests/auto/qml/qqmlxmlhttprequest/data/open_network.reply new file mode 100644 index 0000000000..7ae6951f9b --- /dev/null +++ b/tests/auto/qml/qqmlxmlhttprequest/data/open_network.reply @@ -0,0 +1,3 @@ +HTTP/1.0 200 OK +Connection: close +Content-type: text/html; charset=UTF-8 diff --git a/tests/auto/qml/qqmlxmlhttprequest/data/open_network.wait b/tests/auto/qml/qqmlxmlhttprequest/data/open_network.wait new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/auto/qml/qqmlxmlhttprequest/data/open_sync.qml b/tests/auto/qml/qqmlxmlhttprequest/data/open_sync.qml new file mode 100644 index 0000000000..eafdda761f --- /dev/null +++ b/tests/auto/qml/qqmlxmlhttprequest/data/open_sync.qml @@ -0,0 +1,17 @@ +import QtQuick 2.0 + +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/qml/qqmlxmlhttprequest/data/open_user.qml b/tests/auto/qml/qqmlxmlhttprequest/data/open_user.qml new file mode 100644 index 0000000000..4eaef536b3 --- /dev/null +++ b/tests/auto/qml/qqmlxmlhttprequest/data/open_user.qml @@ -0,0 +1,54 @@ +import QtQuick 2.0 + +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"); + x.setRequestHeader("Accept-Language","en-US"); + + 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/qml/qqmlxmlhttprequest/data/open_username.qml b/tests/auto/qml/qqmlxmlhttprequest/data/open_username.qml new file mode 100644 index 0000000000..b8ce5361f3 --- /dev/null +++ b/tests/auto/qml/qqmlxmlhttprequest/data/open_username.qml @@ -0,0 +1,54 @@ +import QtQuick 2.0 + +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/qml/qqmlxmlhttprequest/data/redirectError.qml b/tests/auto/qml/qqmlxmlhttprequest/data/redirectError.qml new file mode 100644 index 0000000000..e5c7b74553 --- /dev/null +++ b/tests/auto/qml/qqmlxmlhttprequest/data/redirectError.qml @@ -0,0 +1,23 @@ +import QtQuick 2.0 + +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/qml/qqmlxmlhttprequest/data/redirectRecur.qml b/tests/auto/qml/qqmlxmlhttprequest/data/redirectRecur.qml new file mode 100644 index 0000000000..0894573ecc --- /dev/null +++ b/tests/auto/qml/qqmlxmlhttprequest/data/redirectRecur.qml @@ -0,0 +1,23 @@ +import QtQuick 2.0 + +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/qml/qqmlxmlhttprequest/data/redirects.qml b/tests/auto/qml/qqmlxmlhttprequest/data/redirects.qml new file mode 100644 index 0000000000..003d1954e9 --- /dev/null +++ b/tests/auto/qml/qqmlxmlhttprequest/data/redirects.qml @@ -0,0 +1,22 @@ +import QtQuick 2.0 + +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/qml/qqmlxmlhttprequest/data/redirecttarget.html b/tests/auto/qml/qqmlxmlhttprequest/data/redirecttarget.html new file mode 100644 index 0000000000..95f35e01c7 --- /dev/null +++ b/tests/auto/qml/qqmlxmlhttprequest/data/redirecttarget.html @@ -0,0 +1 @@ +Redirected diff --git a/tests/auto/qml/qqmlxmlhttprequest/data/responseText.qml b/tests/auto/qml/qqmlxmlhttprequest/data/responseText.qml new file mode 100644 index 0000000000..4b216d9c85 --- /dev/null +++ b/tests/auto/qml/qqmlxmlhttprequest/data/responseText.qml @@ -0,0 +1,54 @@ +import QtQuick 2.0 + +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); + x.setRequestHeader("Accept-Language", "en-US"); + + 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); + x.setRequestHeader("Accept-Language", "en-US"); + + reset = (x.responseText == ""); + } + } + + x.send() + + sent = (x.responseText == ""); + } +} + diff --git a/tests/auto/qml/qqmlxmlhttprequest/data/responseXML_invalid.qml b/tests/auto/qml/qqmlxmlhttprequest/data/responseXML_invalid.qml new file mode 100644 index 0000000000..e9265e09ef --- /dev/null +++ b/tests/auto/qml/qqmlxmlhttprequest/data/responseXML_invalid.qml @@ -0,0 +1,24 @@ +import QtQuick 2.0 + +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/qml/qqmlxmlhttprequest/data/seconddocument.html b/tests/auto/qml/qqmlxmlhttprequest/data/seconddocument.html new file mode 100644 index 0000000000..a33f44bcb5 --- /dev/null +++ b/tests/auto/qml/qqmlxmlhttprequest/data/seconddocument.html @@ -0,0 +1 @@ +This should not be read! diff --git a/tests/auto/qml/qqmlxmlhttprequest/data/send_alreadySent.qml b/tests/auto/qml/qqmlxmlhttprequest/data/send_alreadySent.qml new file mode 100644 index 0000000000..4e0caa7171 --- /dev/null +++ b/tests/auto/qml/qqmlxmlhttprequest/data/send_alreadySent.qml @@ -0,0 +1,28 @@ +import QtQuick 2.0 + +QtObject { + property bool dataOK: false + property bool test: false + + Component.onCompleted: { + var x = new XMLHttpRequest; + x.open("GET", "testdocument.html"); + x.setRequestHeader("Accept-Language","en-US"); + + // 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/qml/qqmlxmlhttprequest/data/send_data.1.expect b/tests/auto/qml/qqmlxmlhttprequest/data/send_data.1.expect new file mode 100644 index 0000000000..9c07d4b633 --- /dev/null +++ b/tests/auto/qml/qqmlxmlhttprequest/data/send_data.1.expect @@ -0,0 +1,10 @@ +POST /testdocument.html HTTP/1.1 +Accept-Language: en-US +Content-Type: text/plain;charset=UTF-8 +Content-Length: 12 +Connection: Keep-Alive +Accept-Encoding: gzip, deflate +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/qml/qqmlxmlhttprequest/data/send_data.1.qml b/tests/auto/qml/qqmlxmlhttprequest/data/send_data.1.qml new file mode 100644 index 0000000000..6faac0242f --- /dev/null +++ b/tests/auto/qml/qqmlxmlhttprequest/data/send_data.1.qml @@ -0,0 +1,22 @@ +import QtQuick 2.0 + +QtObject { + property string url + + property bool dataOK: false + + Component.onCompleted: { + var x = new XMLHttpRequest; + x.open("POST", url); + x.setRequestHeader("Accept-Language","en-US"); + + // 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/qml/qqmlxmlhttprequest/data/send_data.2.qml b/tests/auto/qml/qqmlxmlhttprequest/data/send_data.2.qml new file mode 100644 index 0000000000..383a76e75e --- /dev/null +++ b/tests/auto/qml/qqmlxmlhttprequest/data/send_data.2.qml @@ -0,0 +1,24 @@ +import QtQuick 2.0 + +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"); + x.setRequestHeader("Accept-Language","en-US"); + + // 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/qml/qqmlxmlhttprequest/data/send_data.3.qml b/tests/auto/qml/qqmlxmlhttprequest/data/send_data.3.qml new file mode 100644 index 0000000000..5cb8c926c2 --- /dev/null +++ b/tests/auto/qml/qqmlxmlhttprequest/data/send_data.3.qml @@ -0,0 +1,24 @@ +import QtQuick 2.0 + +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"); + x.setRequestHeader("Accept-Language","en-US"); + + // 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/qml/qqmlxmlhttprequest/data/send_data.4.expect b/tests/auto/qml/qqmlxmlhttprequest/data/send_data.4.expect new file mode 100644 index 0000000000..c2aba77881 --- /dev/null +++ b/tests/auto/qml/qqmlxmlhttprequest/data/send_data.4.expect @@ -0,0 +1,10 @@ +POST /testdocument.html HTTP/1.1 +Accept-Language: en-US +Content-Type: charset=UTF-8;text/plain +Content-Length: 12 +Connection: Keep-Alive +Accept-Encoding: gzip, deflate +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/qml/qqmlxmlhttprequest/data/send_data.4.qml b/tests/auto/qml/qqmlxmlhttprequest/data/send_data.4.qml new file mode 100644 index 0000000000..884661c8ce --- /dev/null +++ b/tests/auto/qml/qqmlxmlhttprequest/data/send_data.4.qml @@ -0,0 +1,24 @@ +import QtQuick 2.0 + +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"); + x.setRequestHeader("Accept-Language","en-US"); + + // 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/qml/qqmlxmlhttprequest/data/send_data.5.qml b/tests/auto/qml/qqmlxmlhttprequest/data/send_data.5.qml new file mode 100644 index 0000000000..c031b84418 --- /dev/null +++ b/tests/auto/qml/qqmlxmlhttprequest/data/send_data.5.qml @@ -0,0 +1,24 @@ +import QtQuick 2.0 + +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"); + x.setRequestHeader("Accept-Language","en-US"); + + // 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/qml/qqmlxmlhttprequest/data/send_data.6.expect b/tests/auto/qml/qqmlxmlhttprequest/data/send_data.6.expect new file mode 100644 index 0000000000..b09b1bcec5 --- /dev/null +++ b/tests/auto/qml/qqmlxmlhttprequest/data/send_data.6.expect @@ -0,0 +1,10 @@ +PUT /testdocument.html HTTP/1.1 +Accept-Language: en-US +Content-Type: text/plain;charset=UTF-8 +Content-Length: 12 +Connection: Keep-Alive +Accept-Encoding: gzip, deflate +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/qml/qqmlxmlhttprequest/data/send_data.6.qml b/tests/auto/qml/qqmlxmlhttprequest/data/send_data.6.qml new file mode 100644 index 0000000000..42eb360d14 --- /dev/null +++ b/tests/auto/qml/qqmlxmlhttprequest/data/send_data.6.qml @@ -0,0 +1,22 @@ +import QtQuick 2.0 + +QtObject { + property string url + + property bool dataOK: false + + Component.onCompleted: { + var x = new XMLHttpRequest; + x.open("PUT", url); + x.setRequestHeader("Accept-Language","en-US"); + + // 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/qml/qqmlxmlhttprequest/data/send_data.7.qml b/tests/auto/qml/qqmlxmlhttprequest/data/send_data.7.qml new file mode 100644 index 0000000000..5dc252f970 --- /dev/null +++ b/tests/auto/qml/qqmlxmlhttprequest/data/send_data.7.qml @@ -0,0 +1,24 @@ +import QtQuick 2.0 + +QtObject { + property string url + + property bool dataOK: false + + Component.onCompleted: { + var x = new XMLHttpRequest; + x.open("POST", url); + x.setRequestHeader("Content-Type", "text/plain"); + x.setRequestHeader("Accept-Language","en-US"); + + // 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/qml/qqmlxmlhttprequest/data/send_data.reply b/tests/auto/qml/qqmlxmlhttprequest/data/send_data.reply new file mode 100644 index 0000000000..7ae6951f9b --- /dev/null +++ b/tests/auto/qml/qqmlxmlhttprequest/data/send_data.reply @@ -0,0 +1,3 @@ +HTTP/1.0 200 OK +Connection: close +Content-type: text/html; charset=UTF-8 diff --git a/tests/auto/qml/qqmlxmlhttprequest/data/send_ignoreData.qml b/tests/auto/qml/qqmlxmlhttprequest/data/send_ignoreData.qml new file mode 100644 index 0000000000..336971c919 --- /dev/null +++ b/tests/auto/qml/qqmlxmlhttprequest/data/send_ignoreData.qml @@ -0,0 +1,27 @@ +import QtQuick 2.0 + +QtObject { + property string reqType + property string url + + property bool dataOK: false + + Component.onCompleted: { + var x = new XMLHttpRequest; + x.open(reqType, url); + x.setRequestHeader("Accept-Language","en-US"); + + // Test to the end + x.onreadystatechange = function() { + if (x.readyState == XMLHttpRequest.DONE) { + if (reqType == "HEAD" || reqType == "DELETE") + dataOK = (x.responseText == ""); + else + dataOK = (x.responseText == "QML Rocks!\n"); + } + } + + x.send("Data To Ignore"); + } +} + diff --git a/tests/auto/qml/qqmlxmlhttprequest/data/send_ignoreData.reply b/tests/auto/qml/qqmlxmlhttprequest/data/send_ignoreData.reply new file mode 100644 index 0000000000..7ae6951f9b --- /dev/null +++ b/tests/auto/qml/qqmlxmlhttprequest/data/send_ignoreData.reply @@ -0,0 +1,3 @@ +HTTP/1.0 200 OK +Connection: close +Content-type: text/html; charset=UTF-8 diff --git a/tests/auto/qml/qqmlxmlhttprequest/data/send_ignoreData_DELETE.expect b/tests/auto/qml/qqmlxmlhttprequest/data/send_ignoreData_DELETE.expect new file mode 100644 index 0000000000..dd86b837f4 --- /dev/null +++ b/tests/auto/qml/qqmlxmlhttprequest/data/send_ignoreData_DELETE.expect @@ -0,0 +1,7 @@ +DELETE /testdocument.html HTTP/1.1 +Accept-Language: en-US +Connection: Keep-Alive +Accept-Encoding: gzip, deflate +User-Agent: Mozilla/5.0 +Host: 127.0.0.1:14445 + diff --git a/tests/auto/qml/qqmlxmlhttprequest/data/send_ignoreData_GET.expect b/tests/auto/qml/qqmlxmlhttprequest/data/send_ignoreData_GET.expect new file mode 100644 index 0000000000..cf5830ed0c --- /dev/null +++ b/tests/auto/qml/qqmlxmlhttprequest/data/send_ignoreData_GET.expect @@ -0,0 +1,7 @@ +GET /testdocument.html HTTP/1.1 +Accept-Language: en-US +Connection: Keep-Alive +Accept-Encoding: gzip, deflate +User-Agent: Mozilla/5.0 +Host: 127.0.0.1:14445 + diff --git a/tests/auto/qml/qqmlxmlhttprequest/data/send_ignoreData_HEAD.expect b/tests/auto/qml/qqmlxmlhttprequest/data/send_ignoreData_HEAD.expect new file mode 100644 index 0000000000..7b7b282660 --- /dev/null +++ b/tests/auto/qml/qqmlxmlhttprequest/data/send_ignoreData_HEAD.expect @@ -0,0 +1,7 @@ +HEAD /testdocument.html HTTP/1.1 +Accept-Language: en-US +Connection: Keep-Alive +Accept-Encoding: gzip, deflate +User-Agent: Mozilla/5.0 +Host: 127.0.0.1:14445 + diff --git a/tests/auto/qml/qqmlxmlhttprequest/data/send_unsent.qml b/tests/auto/qml/qqmlxmlhttprequest/data/send_unsent.qml new file mode 100644 index 0000000000..ef56517bf5 --- /dev/null +++ b/tests/auto/qml/qqmlxmlhttprequest/data/send_unsent.qml @@ -0,0 +1,16 @@ +import QtQuick 2.0 + +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/qml/qqmlxmlhttprequest/data/setRequestHeader.expect b/tests/auto/qml/qqmlxmlhttprequest/data/setRequestHeader.expect new file mode 100644 index 0000000000..e7f8e10780 --- /dev/null +++ b/tests/auto/qml/qqmlxmlhttprequest/data/setRequestHeader.expect @@ -0,0 +1,9 @@ +GET /testdocument.html HTTP/1.1 +Accept-Language: en-US +Test-header: value +Test-header2: value,value2 +Connection: Keep-Alive +Accept-Encoding: gzip, deflate +User-Agent: Mozilla/5.0 +Host: 127.0.0.1:14445 + diff --git a/tests/auto/qml/qqmlxmlhttprequest/data/setRequestHeader.qml b/tests/auto/qml/qqmlxmlhttprequest/data/setRequestHeader.qml new file mode 100644 index 0000000000..4229584af2 --- /dev/null +++ b/tests/auto/qml/qqmlxmlhttprequest/data/setRequestHeader.qml @@ -0,0 +1,29 @@ +import QtQuick 2.0 + +QtObject { + property string url + + property bool dataOK: false + + Component.onCompleted: { + var x = new XMLHttpRequest; + + x.open("GET", url); + x.setRequestHeader("Accept-Language","en-US"); + + 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/qml/qqmlxmlhttprequest/data/setRequestHeader.reply b/tests/auto/qml/qqmlxmlhttprequest/data/setRequestHeader.reply new file mode 100644 index 0000000000..7ae6951f9b --- /dev/null +++ b/tests/auto/qml/qqmlxmlhttprequest/data/setRequestHeader.reply @@ -0,0 +1,3 @@ +HTTP/1.0 200 OK +Connection: close +Content-type: text/html; charset=UTF-8 diff --git a/tests/auto/qml/qqmlxmlhttprequest/data/setRequestHeader_args.qml b/tests/auto/qml/qqmlxmlhttprequest/data/setRequestHeader_args.qml new file mode 100644 index 0000000000..1cef3e43da --- /dev/null +++ b/tests/auto/qml/qqmlxmlhttprequest/data/setRequestHeader_args.qml @@ -0,0 +1,18 @@ +import QtQuick 2.0 + +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/qml/qqmlxmlhttprequest/data/setRequestHeader_caseInsensitive.qml b/tests/auto/qml/qqmlxmlhttprequest/data/setRequestHeader_caseInsensitive.qml new file mode 100644 index 0000000000..e03f73431a --- /dev/null +++ b/tests/auto/qml/qqmlxmlhttprequest/data/setRequestHeader_caseInsensitive.qml @@ -0,0 +1,30 @@ +import QtQuick 2.0 + +QtObject { + property string url + + property bool dataOK: false + + Component.onCompleted: { + var x = new XMLHttpRequest; + + x.open("GET", url); + x.setRequestHeader("Accept-Language","en-US"); + + x.setRequestHeader("Test-header", "value"); + //Setting headers with just different cases + //will be treated as the same header, and accepted + //as the last setting. + 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/qml/qqmlxmlhttprequest/data/setRequestHeader_illegalName.qml b/tests/auto/qml/qqmlxmlhttprequest/data/setRequestHeader_illegalName.qml new file mode 100644 index 0000000000..cd047cf8dd --- /dev/null +++ b/tests/auto/qml/qqmlxmlhttprequest/data/setRequestHeader_illegalName.qml @@ -0,0 +1,58 @@ +import QtQuick 2.0 + +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("Accept-Language","en-US"); + + 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/qml/qqmlxmlhttprequest/data/setRequestHeader_sent.qml b/tests/auto/qml/qqmlxmlhttprequest/data/setRequestHeader_sent.qml new file mode 100644 index 0000000000..49888fdac8 --- /dev/null +++ b/tests/auto/qml/qqmlxmlhttprequest/data/setRequestHeader_sent.qml @@ -0,0 +1,32 @@ +import QtQuick 2.0 + +QtObject { + property string url + property bool test: false + + property bool dataOK: false + + Component.onCompleted: { + var x = new XMLHttpRequest; + + x.open("GET", url); + x.setRequestHeader("Accept-Language","en-US"); + + // 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/qml/qqmlxmlhttprequest/data/setRequestHeader_unsent.qml b/tests/auto/qml/qqmlxmlhttprequest/data/setRequestHeader_unsent.qml new file mode 100644 index 0000000000..f528aa912c --- /dev/null +++ b/tests/auto/qml/qqmlxmlhttprequest/data/setRequestHeader_unsent.qml @@ -0,0 +1,17 @@ +import QtQuick 2.0 + +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/qml/qqmlxmlhttprequest/data/staticStateValues.qml b/tests/auto/qml/qqmlxmlhttprequest/data/staticStateValues.qml new file mode 100644 index 0000000000..1b701e90ff --- /dev/null +++ b/tests/auto/qml/qqmlxmlhttprequest/data/staticStateValues.qml @@ -0,0 +1,24 @@ +import QtQuick 2.0 + +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/qml/qqmlxmlhttprequest/data/status.200.reply b/tests/auto/qml/qqmlxmlhttprequest/data/status.200.reply new file mode 100644 index 0000000000..7ae6951f9b --- /dev/null +++ b/tests/auto/qml/qqmlxmlhttprequest/data/status.200.reply @@ -0,0 +1,3 @@ +HTTP/1.0 200 OK +Connection: close +Content-type: text/html; charset=UTF-8 diff --git a/tests/auto/qml/qqmlxmlhttprequest/data/status.400.reply b/tests/auto/qml/qqmlxmlhttprequest/data/status.400.reply new file mode 100644 index 0000000000..e3f6944173 --- /dev/null +++ b/tests/auto/qml/qqmlxmlhttprequest/data/status.400.reply @@ -0,0 +1,4 @@ +HTTP/1.0 400 Bad request +Connection: close +Content-type: text/html; charset=UTF-8 + diff --git a/tests/auto/qml/qqmlxmlhttprequest/data/status.404.reply b/tests/auto/qml/qqmlxmlhttprequest/data/status.404.reply new file mode 100644 index 0000000000..2e29f56d41 --- /dev/null +++ b/tests/auto/qml/qqmlxmlhttprequest/data/status.404.reply @@ -0,0 +1,3 @@ +HTTP/1.0 404 Document not found +Connection: close +Content-type: text/html; charset=UTF-8 diff --git a/tests/auto/qml/qqmlxmlhttprequest/data/status.expect b/tests/auto/qml/qqmlxmlhttprequest/data/status.expect new file mode 100644 index 0000000000..cf5830ed0c --- /dev/null +++ b/tests/auto/qml/qqmlxmlhttprequest/data/status.expect @@ -0,0 +1,7 @@ +GET /testdocument.html HTTP/1.1 +Accept-Language: en-US +Connection: Keep-Alive +Accept-Encoding: gzip, deflate +User-Agent: Mozilla/5.0 +Host: 127.0.0.1:14445 + diff --git a/tests/auto/qml/qqmlxmlhttprequest/data/status.qml b/tests/auto/qml/qqmlxmlhttprequest/data/status.qml new file mode 100644 index 0000000000..f5e10d79ad --- /dev/null +++ b/tests/auto/qml/qqmlxmlhttprequest/data/status.qml @@ -0,0 +1,79 @@ +import QtQuick 2.0 + +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); + x.setRequestHeader("Accept-Language", "en-US"); + + 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 != 200) { + dataOK = (x.responseText == ""); + } else { + dataOK = (x.responseText == "QML Rocks!\n"); + } + + x.open("GET", url); + x.setRequestHeader("Accept-Language", "en-US"); + + 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/qml/qqmlxmlhttprequest/data/statusText.qml b/tests/auto/qml/qqmlxmlhttprequest/data/statusText.qml new file mode 100644 index 0000000000..e7f658fc29 --- /dev/null +++ b/tests/auto/qml/qqmlxmlhttprequest/data/statusText.qml @@ -0,0 +1,79 @@ +import QtQuick 2.0 + +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); + x.setRequestHeader("Accept-Language", "en-US"); + + 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); + x.setRequestHeader("Accept-Language", "en-US"); + + 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/qml/qqmlxmlhttprequest/data/testdocument.html b/tests/auto/qml/qqmlxmlhttprequest/data/testdocument.html new file mode 100644 index 0000000000..8fe0f4b0e2 --- /dev/null +++ b/tests/auto/qml/qqmlxmlhttprequest/data/testdocument.html @@ -0,0 +1 @@ +QML Rocks! diff --git a/tests/auto/qml/qqmlxmlhttprequest/data/text.qml b/tests/auto/qml/qqmlxmlhttprequest/data/text.qml new file mode 100644 index 0000000000..b79e0bc7b1 --- /dev/null +++ b/tests/auto/qml/qqmlxmlhttprequest/data/text.qml @@ -0,0 +1,129 @@ +import QtQuick 2.0 + +QtObject { + property bool xmlTest: false + property bool dataOK: false + + 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/qml/qqmlxmlhttprequest/data/text.xml b/tests/auto/qml/qqmlxmlhttprequest/data/text.xml new file mode 100644 index 0000000000..e7416888fd --- /dev/null +++ b/tests/auto/qml/qqmlxmlhttprequest/data/text.xml @@ -0,0 +1 @@ +Hello world! diff --git a/tests/auto/qml/qqmlxmlhttprequest/data/utf16.html b/tests/auto/qml/qqmlxmlhttprequest/data/utf16.html new file mode 100644 index 0000000000..b640733f1e --- /dev/null +++ b/tests/auto/qml/qqmlxmlhttprequest/data/utf16.html @@ -0,0 +1 @@ +უ Σ diff --git a/tests/auto/qml/qqmlxmlhttprequest/data/utf16.qml b/tests/auto/qml/qqmlxmlhttprequest/data/utf16.qml new file mode 100644 index 0000000000..7c024bfda6 --- /dev/null +++ b/tests/auto/qml/qqmlxmlhttprequest/data/utf16.qml @@ -0,0 +1,29 @@ +import QtQuick 2.0 + +QtObject { + property bool dataOK: false + + property string fileName + property string responseText + property string responseXmlRootNodeValue + + function startRequest() { + var x = new XMLHttpRequest; + + x.open("GET", fileName); + + // Test to the end + x.onreadystatechange = function() { + if (x.readyState == XMLHttpRequest.DONE) { + + responseText = x.responseText + if (x.responseXML) + responseXmlRootNodeValue = x.responseXML.documentElement.childNodes[0].nodeValue + + dataOK = true; + } + } + x.send() + } +} + diff --git a/tests/auto/qml/qqmlxmlhttprequest/data/utf16.xml b/tests/auto/qml/qqmlxmlhttprequest/data/utf16.xml new file mode 100644 index 0000000000..0fbb126ed8 Binary files /dev/null and b/tests/auto/qml/qqmlxmlhttprequest/data/utf16.xml differ diff --git a/tests/auto/qml/qqmlxmlhttprequest/qqmlxmlhttprequest.pro b/tests/auto/qml/qqmlxmlhttprequest/qqmlxmlhttprequest.pro new file mode 100644 index 0000000000..ed016fd9b6 --- /dev/null +++ b/tests/auto/qml/qqmlxmlhttprequest/qqmlxmlhttprequest.pro @@ -0,0 +1,19 @@ +CONFIG += testcase +TARGET = tst_qqmlxmlhttprequest +macx:CONFIG -= app_bundle + +INCLUDEPATH += ../../shared/ +HEADERS += ../../shared/testhttpserver.h + +SOURCES += tst_qqmlxmlhttprequest.cpp \ + ../../shared/testhttpserver.cpp + +include (../../shared/util.pri) + +testDataFiles.files = data +testDataFiles.path = . +DEPLOYMENT += testDataFiles + +CONFIG += parallel_test + +QT += core-private gui-private qml-private network testlib diff --git a/tests/auto/qml/qqmlxmlhttprequest/tst_qqmlxmlhttprequest.cpp b/tests/auto/qml/qqmlxmlhttprequest/tst_qqmlxmlhttprequest.cpp new file mode 100644 index 0000000000..f8d74c3cde --- /dev/null +++ b/tests/auto/qml/qqmlxmlhttprequest/tst_qqmlxmlhttprequest.cpp @@ -0,0 +1,1160 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include +#include +#include +#include +#include +#include "testhttpserver.h" +#include "../../shared/util.h" + +#define SERVER_PORT 14445 + +class tst_qqmlxmlhttprequest : public QQmlDataTest +{ + Q_OBJECT +public: + tst_qqmlxmlhttprequest() {} + +private slots: + void domExceptionCodes(); + void callbackException(); + void callbackException_data(); + void staticStateValues(); + void instanceStateValues(); + void constructor(); + void defaultState(); + void open(); + void open_data(); + void open_invalid_method(); + void open_sync(); + void open_arg_count(); + void setRequestHeader(); + void setRequestHeader_caseInsensitive(); + void setRequestHeader_unsent(); + void setRequestHeader_illegalName_data(); + void setRequestHeader_illegalName(); + void setRequestHeader_sent(); + void setRequestHeader_args(); + void send_unsent(); + void send_alreadySent(); + void send_ignoreData(); + void send_withdata(); + void send_withdata_data(); + void abort(); + void abort_unsent(); + void abort_opened(); + void getResponseHeader(); + void getResponseHeader_unsent(); + void getResponseHeader_sent(); + void getResponseHeader_args(); + void getAllResponseHeaders(); + void getAllResponseHeaders_unsent(); + void getAllResponseHeaders_sent(); + void getAllResponseHeaders_args(); + void status(); + void status_data(); + void statusText(); + void statusText_data(); + void responseText(); + void responseText_data(); + void responseXML_invalid(); + void invalidMethodUsage(); + void redirects(); + void nonUtf8(); + void nonUtf8_data(); + + // Attributes + void document(); + void element(); + void attr(); + void text(); + void cdata(); + + // Crashes + // void outstanding_request_at_shutdown(); + + // void network_errors() + // void readyState() + +private: + QQmlEngine engine; +}; + +// Test that the dom exception codes are correct +void tst_qqmlxmlhttprequest::domExceptionCodes() +{ + QQmlComponent component(&engine, testFileUrl("domExceptionCodes.qml")); + QObject *object = component.create(); + QVERIFY(object != 0); + + QCOMPARE(object->property("index_size_err").toInt(), 1); + QCOMPARE(object->property("domstring_size_err").toInt(), 2); + QCOMPARE(object->property("hierarchy_request_err").toInt(), 3); + QCOMPARE(object->property("wrong_document_err").toInt(), 4); + QCOMPARE(object->property("invalid_character_err").toInt(), 5); + QCOMPARE(object->property("no_data_allowed_err").toInt(), 6); + QCOMPARE(object->property("no_modification_allowed_err").toInt(), 7); + QCOMPARE(object->property("not_found_err").toInt(), 8); + QCOMPARE(object->property("not_supported_err").toInt(), 9); + QCOMPARE(object->property("inuse_attribute_err").toInt(), 10); + QCOMPARE(object->property("invalid_state_err").toInt(), 11); + QCOMPARE(object->property("syntax_err").toInt(), 12); + QCOMPARE(object->property("invalid_modification_err").toInt(), 13); + QCOMPARE(object->property("namespace_err").toInt(), 14); + QCOMPARE(object->property("invalid_access_err").toInt(), 15); + QCOMPARE(object->property("validation_err").toInt(), 16); + QCOMPARE(object->property("type_mismatch_err").toInt(), 17); + + delete object; +} + +void tst_qqmlxmlhttprequest::callbackException_data() +{ + QTest::addColumn("which"); + QTest::addColumn("line"); + + QTest::newRow("on-opened") << "1" << 15; + QTest::newRow("on-loading") << "3" << 15; + QTest::newRow("on-done") << "4" << 15; +} + +void tst_qqmlxmlhttprequest::callbackException() +{ + // Test exception reporting for exceptions thrown at various points. + + QFETCH(QString, which); + QFETCH(int, line); + + QString expect = testFileUrl("callbackException.qml").toString() + ":"+QString::number(line)+": Error: Exception from Callback"; + QTest::ignoreMessage(QtWarningMsg, expect.toLatin1()); + + QQmlComponent component(&engine, testFileUrl("callbackException.qml")); + QObject *object = component.beginCreate(engine.rootContext()); + QVERIFY(object != 0); + object->setProperty("url", "testdocument.html"); + object->setProperty("which", which); + component.completeCreate(); + + QTRY_VERIFY(object->property("threw").toBool() == true); + + delete object; +} + +// Test that the state value properties on the XMLHttpRequest constructor have the correct values. +// ### WebKit does not do this, but it seems to fit the standard and QML better +void tst_qqmlxmlhttprequest::staticStateValues() +{ + QQmlComponent component(&engine, testFileUrl("staticStateValues.qml")); + QObject *object = component.create(); + QVERIFY(object != 0); + + QCOMPARE(object->property("unsent").toInt(), 0); + QCOMPARE(object->property("opened").toInt(), 1); + QCOMPARE(object->property("headers_received").toInt(), 2); + QCOMPARE(object->property("loading").toInt(), 3); + QCOMPARE(object->property("done").toInt(), 4); + + delete object; +} + +// Test that the state value properties on instances have the correct values. +void tst_qqmlxmlhttprequest::instanceStateValues() +{ + QQmlComponent component(&engine, testFileUrl("instanceStateValues.qml")); + QObject *object = component.create(); + QVERIFY(object != 0); + + QCOMPARE(object->property("unsent").toInt(), 0); + QCOMPARE(object->property("opened").toInt(), 1); + QCOMPARE(object->property("headers_received").toInt(), 2); + QCOMPARE(object->property("loading").toInt(), 3); + QCOMPARE(object->property("done").toInt(), 4); + + delete object; +} + +// Test calling constructor +void tst_qqmlxmlhttprequest::constructor() +{ + QQmlComponent component(&engine, testFileUrl("constructor.qml")); + QObject *object = component.create(); + QVERIFY(object != 0); + + QCOMPARE(object->property("calledAsConstructor").toBool(), true); + QCOMPARE(object->property("calledAsFunction").toBool(), true); + + delete object; +} + +// Test that all the properties are set correctly before any request is sent +void tst_qqmlxmlhttprequest::defaultState() +{ + QQmlComponent component(&engine, testFileUrl("defaultState.qml")); + QObject *object = component.create(); + QVERIFY(object != 0); + + QCOMPARE(object->property("readState").toInt(), 0); + QCOMPARE(object->property("statusIsException").toBool(), true); + QCOMPARE(object->property("statusTextIsException").toBool(), true); + QCOMPARE(object->property("responseText").toString(), QString()); + QCOMPARE(object->property("responseXMLIsNull").toBool(), true); + + delete object; +} + +// Test valid XMLHttpRequest.open() calls +void tst_qqmlxmlhttprequest::open() +{ + QFETCH(QUrl, qmlFile); + QFETCH(QString, url); + QFETCH(bool, remote); + + QScopedPointer server; // ensure deletion in case test fails + if (remote) { + server.reset(new TestHTTPServer(SERVER_PORT)); + QVERIFY(server->isValid()); + QVERIFY(server->wait(testFileUrl("open_network.expect"), + testFileUrl("open_network.reply"), + testFileUrl("testdocument.html"))); + } + + QQmlComponent component(&engine, qmlFile); + QObject *object = component.beginCreate(engine.rootContext()); + QVERIFY(object != 0); + object->setProperty("url", url); + component.completeCreate(); + + QCOMPARE(object->property("readyState").toBool(), true); + QCOMPARE(object->property("openedState").toBool(), true); + QCOMPARE(object->property("status").toBool(), true); + QCOMPARE(object->property("statusText").toBool(), true); + QCOMPARE(object->property("responseText").toBool(), true); + QCOMPARE(object->property("responseXML").toBool(), true); + + QTRY_VERIFY(object->property("dataOK").toBool() == true); + + delete object; +} + +void tst_qqmlxmlhttprequest::open_data() +{ + QTest::addColumn("qmlFile"); + QTest::addColumn("url"); + QTest::addColumn("remote"); + + QTest::newRow("Relative url)") << testFileUrl("open.qml") << "testdocument.html" << false; + QTest::newRow("Absolute url)") << testFileUrl("open.qml") << testFileUrl("testdocument.html").toString() << false; + QTest::newRow("Absolute network url)") << testFileUrl("open.qml") << "http://127.0.0.1:14445/testdocument.html" << true; + + // ### Check that the username/password were sent to the server + QTest::newRow("User/pass") << testFileUrl("open_user.qml") << "http://127.0.0.1:14445/testdocument.html" << true; +} + +// Test that calling XMLHttpRequest.open() with an invalid method raises an exception +void tst_qqmlxmlhttprequest::open_invalid_method() +{ + QQmlComponent component(&engine, testFileUrl("open_invalid_method.qml")); + QObject *object = component.create(); + QVERIFY(object != 0); + + QCOMPARE(object->property("exceptionThrown").toBool(), true); + + delete object; +} + +// Test that calling XMLHttpRequest.open() with sync raises an exception +void tst_qqmlxmlhttprequest::open_sync() +{ + QQmlComponent component(&engine, testFileUrl("open_sync.qml")); + QObject *object = component.create(); + QVERIFY(object != 0); + + QCOMPARE(object->property("exceptionThrown").toBool(), true); + + delete object; +} + +// Calling with incorrect arg count raises an exception +void tst_qqmlxmlhttprequest::open_arg_count() +{ + { + QQmlComponent component(&engine, testFileUrl("open_arg_count.1.qml")); + QObject *object = component.create(); + QVERIFY(object != 0); + + QCOMPARE(object->property("exceptionThrown").toBool(), true); + + delete object; + } + + { + QQmlComponent component(&engine, testFileUrl("open_arg_count.2.qml")); + QObject *object = component.create(); + QVERIFY(object != 0); + + QCOMPARE(object->property("exceptionThrown").toBool(), true); + + delete object; + } +} + +// Test valid setRequestHeader() calls +void tst_qqmlxmlhttprequest::setRequestHeader() +{ + TestHTTPServer server(SERVER_PORT); + QVERIFY(server.isValid()); + QVERIFY(server.wait(testFileUrl("setRequestHeader.expect"), + testFileUrl("setRequestHeader.reply"), + testFileUrl("testdocument.html"))); + + QQmlComponent component(&engine, testFileUrl("setRequestHeader.qml")); + QObject *object = component.beginCreate(engine.rootContext()); + QVERIFY(object != 0); + object->setProperty("url", "http://127.0.0.1:14445/testdocument.html"); + component.completeCreate(); + + QTRY_VERIFY(object->property("dataOK").toBool() == true); + + delete object; +} + +// Test valid setRequestHeader() calls with different header cases +void tst_qqmlxmlhttprequest::setRequestHeader_caseInsensitive() +{ + TestHTTPServer server(SERVER_PORT); + QVERIFY(server.isValid()); + QVERIFY(server.wait(testFileUrl("setRequestHeader.expect"), + testFileUrl("setRequestHeader.reply"), + testFileUrl("testdocument.html"))); + + QQmlComponent component(&engine, testFileUrl("setRequestHeader_caseInsensitive.qml")); + QObject *object = component.beginCreate(engine.rootContext()); + QVERIFY(object != 0); + object->setProperty("url", "http://127.0.0.1:14445/testdocument.html"); + component.completeCreate(); + + QTRY_VERIFY(object->property("dataOK").toBool() == true); + + delete object; +} +// Test setting headers before open() throws exception +void tst_qqmlxmlhttprequest::setRequestHeader_unsent() +{ + QQmlComponent component(&engine, testFileUrl("setRequestHeader_unsent.qml")); + QObject *object = component.create(); + QVERIFY(object != 0); + + QCOMPARE(object->property("test").toBool(), true); + + delete object; +} + +void tst_qqmlxmlhttprequest::setRequestHeader_illegalName_data() +{ + QTest::addColumn("name"); + + QTest::newRow("Accept-Charset") << "AccePT-CHArset"; + QTest::newRow("Accept-Encoding") << "AccEpt-EnCOding"; + QTest::newRow("Connection") << "ConnECtion"; + QTest::newRow("Content-Length") << "ContEnt-LenGth"; + QTest::newRow("Cookie") << "CookIe"; + QTest::newRow("Cookie2") << "CoOkie2"; + QTest::newRow("Content-Transfer-Encoding") << "ConteNT-tRANSFER-eNCOding"; + QTest::newRow("Date") << "DaTE"; + QTest::newRow("Expect") << "ExPect"; + QTest::newRow("Host") << "HoST"; + QTest::newRow("Keep-Alive") << "KEEP-aLive"; + QTest::newRow("Referer") << "ReferEr"; + QTest::newRow("TE") << "Te"; + QTest::newRow("Trailer") << "TraILEr"; + QTest::newRow("Transfer-Encoding") << "tRANsfer-Encoding"; + QTest::newRow("Upgrade") << "UpgrADe"; + QTest::newRow("User-Agent") << "uSEr-Agent"; + QTest::newRow("Via") << "vIa"; + QTest::newRow("Proxy-") << "ProXy-"; + QTest::newRow("Sec-") << "SeC-"; + QTest::newRow("Proxy-*") << "Proxy-BLAH"; + QTest::newRow("Sec-*") << "Sec-F"; +} + +// Tests that using illegal header names has no effect +void tst_qqmlxmlhttprequest::setRequestHeader_illegalName() +{ + QFETCH(QString, name); + + TestHTTPServer server(SERVER_PORT); + QVERIFY(server.isValid()); + QVERIFY(server.wait(testFileUrl("open_network.expect"), + testFileUrl("open_network.reply"), + testFileUrl("testdocument.html"))); + + QQmlComponent component(&engine, testFileUrl("setRequestHeader_illegalName.qml")); + QObject *object = component.beginCreate(engine.rootContext()); + QVERIFY(object != 0); + object->setProperty("url", "http://127.0.0.1:14445/testdocument.html"); + object->setProperty("header", name); + component.completeCreate(); + + QCOMPARE(object->property("readyState").toBool(), true); + QCOMPARE(object->property("openedState").toBool(), true); + QCOMPARE(object->property("status").toBool(), true); + QCOMPARE(object->property("statusText").toBool(), true); + QCOMPARE(object->property("responseText").toBool(), true); + QCOMPARE(object->property("responseXML").toBool(), true); + + QTRY_VERIFY(object->property("dataOK").toBool() == true); + + delete object; +} + +// Test that attempting to set a header after a request is sent throws an exception +void tst_qqmlxmlhttprequest::setRequestHeader_sent() +{ + TestHTTPServer server(SERVER_PORT); + QVERIFY(server.isValid()); + QVERIFY(server.wait(testFileUrl("open_network.expect"), + testFileUrl("open_network.reply"), + testFileUrl("testdocument.html"))); + + QQmlComponent component(&engine, testFileUrl("setRequestHeader_sent.qml")); + QObject *object = component.beginCreate(engine.rootContext()); + QVERIFY(object != 0); + object->setProperty("url", "http://127.0.0.1:14445/testdocument.html"); + component.completeCreate(); + + QCOMPARE(object->property("test").toBool(), true); + + QTRY_VERIFY(object->property("dataOK").toBool() == true); + + delete object; +} + +// Invalid arg count throws exception +void tst_qqmlxmlhttprequest::setRequestHeader_args() +{ + QQmlComponent component(&engine, testFileUrl("setRequestHeader_args.qml")); + QObject *object = component.create(); + QVERIFY(object != 0); + + QCOMPARE(object->property("exceptionThrown").toBool(), true); + + delete object; +} + +// Test that calling send() in UNSENT state throws an exception +void tst_qqmlxmlhttprequest::send_unsent() +{ + QQmlComponent component(&engine, testFileUrl("send_unsent.qml")); + QObject *object = component.create(); + QVERIFY(object != 0); + + QCOMPARE(object->property("test").toBool(), true); + + delete object; +} + +// Test attempting to resend a sent request throws an exception +void tst_qqmlxmlhttprequest::send_alreadySent() +{ + QQmlComponent component(&engine, testFileUrl("send_alreadySent.qml")); + QObject *object = component.create(); + QVERIFY(object != 0); + + QCOMPARE(object->property("test").toBool(), true); + QTRY_VERIFY(object->property("dataOK").toBool() == true); + + delete object; +} + +// Test that sends for GET, HEAD and DELETE ignore data +void tst_qqmlxmlhttprequest::send_ignoreData() +{ + { + TestHTTPServer server(SERVER_PORT); + QVERIFY(server.isValid()); + QVERIFY(server.wait(testFileUrl("send_ignoreData_GET.expect"), + testFileUrl("send_ignoreData.reply"), + testFileUrl("testdocument.html"))); + + QQmlComponent component(&engine, testFileUrl("send_ignoreData.qml")); + QObject *object = component.beginCreate(engine.rootContext()); + QVERIFY(object != 0); + object->setProperty("reqType", "GET"); + object->setProperty("url", "http://127.0.0.1:14445/testdocument.html"); + component.completeCreate(); + + QTRY_VERIFY(object->property("dataOK").toBool() == true); + + delete object; + } + + { + TestHTTPServer server(SERVER_PORT); + QVERIFY(server.isValid()); + QVERIFY(server.wait(testFileUrl("send_ignoreData_HEAD.expect"), + testFileUrl("send_ignoreData.reply"), + QUrl())); + + QQmlComponent component(&engine, testFileUrl("send_ignoreData.qml")); + QObject *object = component.beginCreate(engine.rootContext()); + QVERIFY(object != 0); + object->setProperty("reqType", "HEAD"); + object->setProperty("url", "http://127.0.0.1:14445/testdocument.html"); + component.completeCreate(); + + QTRY_VERIFY(object->property("dataOK").toBool() == true); + + delete object; + } + + { + TestHTTPServer server(SERVER_PORT); + QVERIFY(server.isValid()); + QVERIFY(server.wait(testFileUrl("send_ignoreData_DELETE.expect"), + testFileUrl("send_ignoreData.reply"), + QUrl())); + + QQmlComponent component(&engine, testFileUrl("send_ignoreData.qml")); + QObject *object = component.beginCreate(engine.rootContext()); + QVERIFY(object != 0); + object->setProperty("reqType", "DELETE"); + object->setProperty("url", "http://127.0.0.1:14445/testdocument.html"); + component.completeCreate(); + + QTRY_VERIFY(object->property("dataOK").toBool() == true); + + delete object; + } +} + +// Test that send()'ing data works +void tst_qqmlxmlhttprequest::send_withdata() +{ + QFETCH(QString, file_expected); + QFETCH(QString, file_qml); + + TestHTTPServer server(SERVER_PORT); + QVERIFY(server.isValid()); + QVERIFY(server.wait(testFileUrl(file_expected), + testFileUrl("send_data.reply"), + testFileUrl("testdocument.html"))); + + QQmlComponent component(&engine, testFileUrl(file_qml)); + QObject *object = component.beginCreate(engine.rootContext()); + QVERIFY(object != 0); + object->setProperty("url", "http://127.0.0.1:14445/testdocument.html"); + component.completeCreate(); + + QTRY_VERIFY(object->property("dataOK").toBool() == true); + + delete object; +} + +void tst_qqmlxmlhttprequest::send_withdata_data() +{ + QTest::addColumn("file_expected"); + QTest::addColumn("file_qml"); + + QTest::newRow("No content-type") << "send_data.1.expect" << "send_data.1.qml"; + QTest::newRow("Correct content-type") << "send_data.1.expect" << "send_data.2.qml"; + QTest::newRow("Incorrect content-type") << "send_data.1.expect" << "send_data.3.qml"; + QTest::newRow("Correct content-type - out of order") << "send_data.4.expect" << "send_data.4.qml"; + QTest::newRow("Incorrect content-type - out of order") << "send_data.4.expect" << "send_data.5.qml"; + QTest::newRow("PUT") << "send_data.6.expect" << "send_data.6.qml"; + QTest::newRow("Correct content-type - no charset") << "send_data.1.expect" << "send_data.7.qml"; +} + +// Test abort() has no effect in unsent state +void tst_qqmlxmlhttprequest::abort_unsent() +{ + QQmlComponent component(&engine, testFileUrl("abort_unsent.qml")); + QObject *object = component.beginCreate(engine.rootContext()); + QVERIFY(object != 0); + object->setProperty("url", "testdocument.html"); + component.completeCreate(); + + QCOMPARE(object->property("readyState").toBool(), true); + QCOMPARE(object->property("openedState").toBool(), true); + QCOMPARE(object->property("status").toBool(), true); + QCOMPARE(object->property("statusText").toBool(), true); + QCOMPARE(object->property("responseText").toBool(), true); + QCOMPARE(object->property("responseXML").toBool(), true); + + QTRY_VERIFY(object->property("dataOK").toBool() == true); + + delete object; +} + +// Test abort() cancels an open (but unsent) request +void tst_qqmlxmlhttprequest::abort_opened() +{ + QQmlComponent component(&engine, testFileUrl("abort_opened.qml")); + QObject *object = component.beginCreate(engine.rootContext()); + QVERIFY(object != 0); + object->setProperty("url", "testdocument.html"); + component.completeCreate(); + + QCOMPARE(object->property("readyState").toBool(), true); + QCOMPARE(object->property("openedState").toBool(), true); + QCOMPARE(object->property("status").toBool(), true); + QCOMPARE(object->property("statusText").toBool(), true); + QCOMPARE(object->property("responseText").toBool(), true); + QCOMPARE(object->property("responseXML").toBool(), true); + + QTRY_VERIFY(object->property("dataOK").toBool() == true); + + delete object; +} + +// Test abort() aborts in progress send +void tst_qqmlxmlhttprequest::abort() +{ + TestHTTPServer server(SERVER_PORT); + QVERIFY(server.isValid()); + QVERIFY(server.wait(testFileUrl("abort.expect"), + testFileUrl("abort.reply"), + testFileUrl("testdocument.html"))); + + QQmlComponent component(&engine, testFileUrl("abort.qml")); + QObject *object = component.beginCreate(engine.rootContext()); + QVERIFY(object != 0); + object->setProperty("urlDummy", "http://127.0.0.1:14449/testdocument.html"); + object->setProperty("url", "http://127.0.0.1:14445/testdocument.html"); + component.completeCreate(); + + QCOMPARE(object->property("seenDone").toBool(), true); + QCOMPARE(object->property("didNotSeeUnsent").toBool(), true); + QCOMPARE(object->property("endStateUnsent").toBool(), true); + + QTRY_VERIFY(object->property("dataOK").toBool() == true); + + delete object; +} + +void tst_qqmlxmlhttprequest::getResponseHeader() +{ + QQmlEngine engine; // Avoid cookie contamination + + TestHTTPServer server(SERVER_PORT); + QVERIFY(server.isValid()); + QVERIFY(server.wait(testFileUrl("getResponseHeader.expect"), + testFileUrl("getResponseHeader.reply"), + testFileUrl("testdocument.html"))); + + + QQmlComponent component(&engine, testFileUrl("getResponseHeader.qml")); + QObject *object = component.beginCreate(engine.rootContext()); + QVERIFY(object != 0); + object->setProperty("url", "http://127.0.0.1:14445/testdocument.html"); + component.completeCreate(); + + QCOMPARE(object->property("unsentException").toBool(), true); + QCOMPARE(object->property("openedException").toBool(), true); + QCOMPARE(object->property("readyState").toBool(), true); + QCOMPARE(object->property("openedState").toBool(), true); + + QTRY_VERIFY(object->property("dataOK").toBool() == true); + + QCOMPARE(object->property("headersReceivedState").toBool(), true); + QCOMPARE(object->property("headersReceivedNullHeader").toBool(), true); + QCOMPARE(object->property("headersReceivedValidHeader").toBool(), true); + QCOMPARE(object->property("headersReceivedMultiValidHeader").toBool(), true); + QCOMPARE(object->property("headersReceivedCookieHeader").toBool(), true); + + QCOMPARE(object->property("doneState").toBool(), true); + QCOMPARE(object->property("doneNullHeader").toBool(), true); + QCOMPARE(object->property("doneValidHeader").toBool(), true); + QCOMPARE(object->property("doneMultiValidHeader").toBool(), true); + QCOMPARE(object->property("doneCookieHeader").toBool(), true); + + delete object; +} + +// Test getResponseHeader throws an exception in an invalid state +void tst_qqmlxmlhttprequest::getResponseHeader_unsent() +{ + QQmlComponent component(&engine, testFileUrl("getResponseHeader_unsent.qml")); + QObject *object = component.create(); + QVERIFY(object != 0); + + QCOMPARE(object->property("test").toBool(), true); + + delete object; +} + +// Test getResponseHeader throws an exception in an invalid state +void tst_qqmlxmlhttprequest::getResponseHeader_sent() +{ + QQmlComponent component(&engine, testFileUrl("getResponseHeader_sent.qml")); + QObject *object = component.create(); + QVERIFY(object != 0); + + QCOMPARE(object->property("test").toBool(), true); + + delete object; +} + +// Invalid arg count throws exception +void tst_qqmlxmlhttprequest::getResponseHeader_args() +{ + QQmlComponent component(&engine, testFileUrl("getResponseHeader_args.qml")); + QObject *object = component.create(); + QVERIFY(object != 0); + + QTRY_VERIFY(object->property("exceptionThrown").toBool() == true); + + delete object; +} + +void tst_qqmlxmlhttprequest::getAllResponseHeaders() +{ + QQmlEngine engine; // Avoid cookie contamination + + TestHTTPServer server(SERVER_PORT); + QVERIFY(server.isValid()); + QVERIFY(server.wait(testFileUrl("getResponseHeader.expect"), + testFileUrl("getResponseHeader.reply"), + testFileUrl("testdocument.html"))); + + QQmlComponent component(&engine, testFileUrl("getAllResponseHeaders.qml")); + QObject *object = component.beginCreate(engine.rootContext()); + QVERIFY(object != 0); + object->setProperty("url", "http://127.0.0.1:14445/testdocument.html"); + component.completeCreate(); + + QCOMPARE(object->property("unsentException").toBool(), true); + QCOMPARE(object->property("openedException").toBool(), true); + QCOMPARE(object->property("readyState").toBool(), true); + QCOMPARE(object->property("openedState").toBool(), true); + + QTRY_VERIFY(object->property("dataOK").toBool() == true); + + QCOMPARE(object->property("headersReceivedState").toBool(), true); + QCOMPARE(object->property("headersReceivedHeader").toBool(), true); + + QCOMPARE(object->property("doneState").toBool(), true); + QCOMPARE(object->property("doneHeader").toBool(), true); + + delete object; +} + +// Test getAllResponseHeaders throws an exception in an invalid state +void tst_qqmlxmlhttprequest::getAllResponseHeaders_unsent() +{ + QQmlComponent component(&engine, testFileUrl("getAllResponseHeaders_unsent.qml")); + QObject *object = component.create(); + QVERIFY(object != 0); + + QCOMPARE(object->property("test").toBool(), true); + + delete object; +} + +// Test getAllResponseHeaders throws an exception in an invalid state +void tst_qqmlxmlhttprequest::getAllResponseHeaders_sent() +{ + QQmlComponent component(&engine, testFileUrl("getAllResponseHeaders_sent.qml")); + QObject *object = component.create(); + QVERIFY(object != 0); + + QCOMPARE(object->property("test").toBool(), true); + + delete object; +} + +// Invalid arg count throws exception +void tst_qqmlxmlhttprequest::getAllResponseHeaders_args() +{ + QQmlComponent component(&engine, testFileUrl("getAllResponseHeaders_args.qml")); + QObject *object = component.create(); + QVERIFY(object != 0); + + QTRY_VERIFY(object->property("exceptionThrown").toBool() == true); + + delete object; +} + +void tst_qqmlxmlhttprequest::status() +{ + QFETCH(QUrl, replyUrl); + QFETCH(int, status); + + TestHTTPServer server(SERVER_PORT); + QVERIFY(server.isValid()); + QVERIFY(server.wait(testFileUrl("status.expect"), + replyUrl, + testFileUrl("testdocument.html"))); + + QQmlComponent component(&engine, testFileUrl("status.qml")); + QObject *object = component.beginCreate(engine.rootContext()); + QVERIFY(object != 0); + object->setProperty("url", "http://127.0.0.1:14445/testdocument.html"); + object->setProperty("expectedStatus", status); + component.completeCreate(); + + QTRY_VERIFY(object->property("dataOK").toBool() == true); + + QCOMPARE(object->property("unsentException").toBool(), true); + QCOMPARE(object->property("openedException").toBool(), true); + QCOMPARE(object->property("sentException").toBool(), true); + QCOMPARE(object->property("headersReceived").toBool(), true); + QCOMPARE(object->property("loading").toBool(), true); + QCOMPARE(object->property("done").toBool(), true); + QCOMPARE(object->property("resetException").toBool(), true); + + delete object; +} + +void tst_qqmlxmlhttprequest::status_data() +{ + QTest::addColumn("replyUrl"); + QTest::addColumn("status"); + + QTest::newRow("OK") << testFileUrl("status.200.reply") << 200; + QTest::newRow("Not Found") << testFileUrl("status.404.reply") << 404; + QTest::newRow("Bad Request") << testFileUrl("status.400.reply") << 400; +} + +void tst_qqmlxmlhttprequest::statusText() +{ + QFETCH(QUrl, replyUrl); + QFETCH(QString, statusText); + + TestHTTPServer server(SERVER_PORT); + QVERIFY(server.isValid()); + QVERIFY(server.wait(testFileUrl("status.expect"), + replyUrl, + testFileUrl("testdocument.html"))); + + QQmlComponent component(&engine, testFileUrl("statusText.qml")); + QObject *object = component.beginCreate(engine.rootContext()); + QVERIFY(object != 0); + object->setProperty("url", "http://127.0.0.1:14445/testdocument.html"); + object->setProperty("expectedStatus", statusText); + component.completeCreate(); + + QTRY_VERIFY(object->property("dataOK").toBool() == true); + + QCOMPARE(object->property("unsentException").toBool(), true); + QCOMPARE(object->property("openedException").toBool(), true); + QCOMPARE(object->property("sentException").toBool(), true); + QCOMPARE(object->property("headersReceived").toBool(), true); + QCOMPARE(object->property("loading").toBool(), true); + QCOMPARE(object->property("done").toBool(), true); + QCOMPARE(object->property("resetException").toBool(), true); + + delete object; +} + +void tst_qqmlxmlhttprequest::statusText_data() +{ + QTest::addColumn("replyUrl"); + QTest::addColumn("statusText"); + + QTest::newRow("OK") << testFileUrl("status.200.reply") << "OK"; + QTest::newRow("Not Found") << testFileUrl("status.404.reply") << "Document not found"; + QTest::newRow("Bad Request") << testFileUrl("status.400.reply") << "Bad request"; +} + +void tst_qqmlxmlhttprequest::responseText() +{ + QFETCH(QUrl, replyUrl); + QFETCH(QUrl, bodyUrl); + QFETCH(QString, responseText); + + TestHTTPServer server(SERVER_PORT); + QVERIFY(server.isValid()); + QVERIFY(server.wait(testFileUrl("status.expect"), + replyUrl, + bodyUrl)); + + QQmlComponent component(&engine, testFileUrl("responseText.qml")); + QObject *object = component.beginCreate(engine.rootContext()); + QVERIFY(object != 0); + object->setProperty("url", "http://127.0.0.1:14445/testdocument.html"); + object->setProperty("expectedText", responseText); + component.completeCreate(); + + QTRY_VERIFY(object->property("dataOK").toBool() == true); + + QCOMPARE(object->property("unsent").toBool(), true); + QCOMPARE(object->property("opened").toBool(), true); + QCOMPARE(object->property("sent").toBool(), true); + QCOMPARE(object->property("headersReceived").toBool(), true); + QCOMPARE(object->property("loading").toBool(), true); + QCOMPARE(object->property("done").toBool(), true); + QCOMPARE(object->property("reset").toBool(), true); + + delete object; +} + +void tst_qqmlxmlhttprequest::responseText_data() +{ + QTest::addColumn("replyUrl"); + QTest::addColumn("bodyUrl"); + QTest::addColumn("responseText"); + + QTest::newRow("OK") << testFileUrl("status.200.reply") << testFileUrl("testdocument.html") << "QML Rocks!\n"; + QTest::newRow("empty body") << testFileUrl("status.200.reply") << QUrl() << ""; + QTest::newRow("Not Found") << testFileUrl("status.404.reply") << testFileUrl("testdocument.html") << ""; + QTest::newRow("Bad Request") << testFileUrl("status.404.reply") << testFileUrl("testdocument.html") << ""; +} + +void tst_qqmlxmlhttprequest::nonUtf8() +{ + QFETCH(QString, fileName); + QFETCH(QString, responseText); + QFETCH(QString, xmlRootNodeValue); + + QQmlComponent component(&engine, testFileUrl("utf16.qml")); + QObject *object = component.create(); + QVERIFY(object != 0); + + object->setProperty("fileName", fileName); + QMetaObject::invokeMethod(object, "startRequest"); + + QTRY_VERIFY(object->property("dataOK").toBool() == true); + + QCOMPARE(object->property("responseText").toString(), responseText); + + if (!xmlRootNodeValue.isEmpty()) { + QString rootNodeValue = object->property("responseXmlRootNodeValue").toString(); + QCOMPARE(rootNodeValue, xmlRootNodeValue); + } + + delete object; +} + +void tst_qqmlxmlhttprequest::nonUtf8_data() +{ + QTest::addColumn("fileName"); + QTest::addColumn("responseText"); + QTest::addColumn("xmlRootNodeValue"); + + QString uc; + uc.resize(3); + uc[0] = QChar(0x10e3); + uc[1] = QChar(' '); + uc[2] = QChar(0x03a3); + + QTest::newRow("responseText") << "utf16.html" << uc + '\n' << ""; + QTest::newRow("responseXML") << "utf16.xml" << "\n\n" + uc + "\n\n" << QString('\n' + uc + '\n'); +} + +// Test that calling hte XMLHttpRequest methods on a non-XMLHttpRequest object +// throws an exception +void tst_qqmlxmlhttprequest::invalidMethodUsage() +{ + QQmlComponent component(&engine, testFileUrl("invalidMethodUsage.qml")); + QObject *object = component.create(); + QVERIFY(object != 0); + + QCOMPARE(object->property("readyState").toBool(), true); + QCOMPARE(object->property("status").toBool(), true); + QCOMPARE(object->property("statusText").toBool(), true); + QCOMPARE(object->property("responseText").toBool(), true); + QCOMPARE(object->property("responseXML").toBool(), true); + + QCOMPARE(object->property("open").toBool(), true); + QCOMPARE(object->property("setRequestHeader").toBool(), true); + QCOMPARE(object->property("send").toBool(), true); + QCOMPARE(object->property("abort").toBool(), true); + QCOMPARE(object->property("getResponseHeader").toBool(), true); + QCOMPARE(object->property("getAllResponseHeaders").toBool(), true); + + delete object; +} + +// Test that XMLHttpRequest transparently redirects +void tst_qqmlxmlhttprequest::redirects() +{ + { + TestHTTPServer server(SERVER_PORT); + QVERIFY(server.isValid()); + server.addRedirect("redirect.html", "http://127.0.0.1:14445/redirecttarget.html"); + server.serveDirectory(dataDirectory()); + + QQmlComponent component(&engine, testFileUrl("redirects.qml")); + QObject *object = component.beginCreate(engine.rootContext()); + QVERIFY(object != 0); + object->setProperty("url", "http://127.0.0.1:14445/redirect.html"); + object->setProperty("expectedText", ""); + component.completeCreate(); + + QTRY_VERIFY(object->property("done").toBool() == true); + QCOMPARE(object->property("dataOK").toBool(), true); + + delete object; + } + + { + TestHTTPServer server(SERVER_PORT); + QVERIFY(server.isValid()); + server.addRedirect("redirect.html", "http://127.0.0.1:14445/redirectmissing.html"); + server.serveDirectory(dataDirectory()); + + QQmlComponent component(&engine, testFileUrl("redirectError.qml")); + QObject *object = component.beginCreate(engine.rootContext()); + QVERIFY(object != 0); + object->setProperty("url", "http://127.0.0.1:14445/redirect.html"); + object->setProperty("expectedText", ""); + component.completeCreate(); + + QTRY_VERIFY(object->property("done").toBool() == true); + QCOMPARE(object->property("dataOK").toBool(), true); + + delete object; + } + + { + TestHTTPServer server(SERVER_PORT); + QVERIFY(server.isValid()); + server.addRedirect("redirect.html", "http://127.0.0.1:14445/redirect.html"); + server.serveDirectory(dataDirectory()); + + QQmlComponent component(&engine, testFileUrl("redirectRecur.qml")); + QObject *object = component.beginCreate(engine.rootContext()); + QVERIFY(object != 0); + object->setProperty("url", "http://127.0.0.1:14445/redirect.html"); + object->setProperty("expectedText", ""); + component.completeCreate(); + + for (int ii = 0; ii < 60; ++ii) { + if (object->property("done").toBool()) break; + QTest::qWait(50); + } + QVERIFY(object->property("done").toBool() == true); + + QCOMPARE(object->property("dataOK").toBool(), true); + + delete object; + } +} + +void tst_qqmlxmlhttprequest::responseXML_invalid() +{ + QQmlComponent component(&engine, testFileUrl("responseXML_invalid.qml")); + QObject *object = component.create(); + QVERIFY(object != 0); + + QTRY_VERIFY(object->property("dataOK").toBool() == true); + + QCOMPARE(object->property("xmlNull").toBool(), true); + + delete object; +} + +// Test the Document DOM element +void tst_qqmlxmlhttprequest::document() +{ + QQmlComponent component(&engine, testFileUrl("document.qml")); + QObject *object = component.create(); + QVERIFY(object != 0); + + QTRY_VERIFY(object->property("dataOK").toBool() == true); + + QCOMPARE(object->property("xmlTest").toBool(), true); + + delete object; +} + +// Test the Element DOM element +void tst_qqmlxmlhttprequest::element() +{ + QQmlComponent component(&engine, testFileUrl("element.qml")); + QObject *object = component.create(); + QVERIFY(object != 0); + + QTRY_VERIFY(object->property("dataOK").toBool() == true); + + QCOMPARE(object->property("xmlTest").toBool(), true); + + delete object; +} + +// Test the Attr DOM element +void tst_qqmlxmlhttprequest::attr() +{ + QQmlComponent component(&engine, testFileUrl("attr.qml")); + QObject *object = component.create(); + QVERIFY(object != 0); + + QTRY_VERIFY(object->property("dataOK").toBool() == true); + + QCOMPARE(object->property("xmlTest").toBool(), true); + + delete object; +} + +// Test the Text DOM element +void tst_qqmlxmlhttprequest::text() +{ + QQmlComponent component(&engine, testFileUrl("text.qml")); + QObject *object = component.create(); + QVERIFY(object != 0); + + QTRY_VERIFY(object->property("dataOK").toBool() == true); + + QCOMPARE(object->property("xmlTest").toBool(), true); + + delete object; +} + +// Test the CDataSection DOM element +void tst_qqmlxmlhttprequest::cdata() +{ + QQmlComponent component(&engine, testFileUrl("cdata.qml")); + QObject *object = component.create(); + QVERIFY(object != 0); + + QTRY_VERIFY(object->property("dataOK").toBool() == true); + + QCOMPARE(object->property("xmlTest").toBool(), true); + + delete object; +} + +QTEST_MAIN(tst_qqmlxmlhttprequest) + +#include "tst_qqmlxmlhttprequest.moc" diff --git a/tests/auto/qml/qquickbinding/data/deletedObject.qml b/tests/auto/qml/qquickbinding/data/deletedObject.qml new file mode 100644 index 0000000000..f9cf869ba3 --- /dev/null +++ b/tests/auto/qml/qquickbinding/data/deletedObject.qml @@ -0,0 +1,24 @@ +import QtQuick 2.0 + +Rectangle { + id: wrapper + width: 400 + height: 400 + + property bool activateBinding: false + + Binding { + id: binding + target: Qt.createQmlObject('import QtQuick 2.0; Item { property real value: 10 }', wrapper) + property: "value" + when: activateBinding + value: x + y + } + + Component.onCompleted: binding.target.destroy(); + +// MouseArea { +// anchors.fill: parent +// onClicked: activateBinding = true; +// } +} diff --git a/tests/auto/qml/qquickbinding/data/restoreBinding.qml b/tests/auto/qml/qquickbinding/data/restoreBinding.qml new file mode 100644 index 0000000000..9491c0f1d3 --- /dev/null +++ b/tests/auto/qml/qquickbinding/data/restoreBinding.qml @@ -0,0 +1,26 @@ +import QtQuick 2.0 + +Rectangle { + width: 400 + height: 400 + + Rectangle { + id: myItem + objectName: "myItem" + width: 100 + height: 100 + color: "green" + x: 100 - myItem.y + + Binding on x { + when: myItem.y > 50 + value: myItem.y + } + + /*NumberAnimation on y { + loops: Animation.Infinite + to: 100 + duration: 1000 + }*/ + } +} diff --git a/tests/auto/qml/qquickbinding/data/restoreBindingWithLoop.qml b/tests/auto/qml/qquickbinding/data/restoreBindingWithLoop.qml new file mode 100644 index 0000000000..ee07104817 --- /dev/null +++ b/tests/auto/qml/qquickbinding/data/restoreBindingWithLoop.qml @@ -0,0 +1,23 @@ +import QtQuick 2.0 + +Rectangle { + width: 400 + height: 400 + + property bool activateBinding: false + + Rectangle { + id: myItem + objectName: "myItem" + width: 100 + height: 100 + color: "green" + x: myItem.y + 100 + onXChanged: { if (x == 188) y = 90; } //create binding loop + + Binding on x { + when: activateBinding + value: myItem.y + } + } +} diff --git a/tests/auto/qml/qquickbinding/data/test-binding.qml b/tests/auto/qml/qquickbinding/data/test-binding.qml new file mode 100644 index 0000000000..87aabe975a --- /dev/null +++ b/tests/auto/qml/qquickbinding/data/test-binding.qml @@ -0,0 +1,16 @@ +import QtQuick 2.0 + +Rectangle { + id: screen + width: 320; height: 240 + property string text + property bool changeColor: false + + Text { id: s1; text: "Hello" } + Rectangle { id: r1; width: 1; height: 1; color: "yellow" } + Rectangle { id: r2; width: 1; height: 1; color: "red" } + + Binding { target: screen; property: "text"; value: s1.text; objectName: "binding1" } + Binding { target: screen; property: "color"; value: r1.color } + Binding { target: screen; property: "color"; when: screen.changeColor == true; value: r2.color; objectName: "binding3" } +} diff --git a/tests/auto/qml/qquickbinding/data/test-binding2.qml b/tests/auto/qml/qquickbinding/data/test-binding2.qml new file mode 100644 index 0000000000..4a08141d11 --- /dev/null +++ b/tests/auto/qml/qquickbinding/data/test-binding2.qml @@ -0,0 +1,16 @@ +import QtQuick 2.0 + +Rectangle { + id: screen + width: 320; height: 240 + property string text + property bool changeColor: false + + Text { id: s1; text: "Hello" } + Rectangle { id: r1; width: 1; height: 1; color: "yellow" } + Rectangle { id: r2; width: 1; height: 1; color: "red" } + + Binding { target: screen; property: "text"; value: s1.text } + Binding { target: screen; property: "color"; value: r1.color } + Binding { target: screen; property: "color"; value: r2.color; when: screen.changeColor == true } +} diff --git a/tests/auto/qml/qquickbinding/qquickbinding.pro b/tests/auto/qml/qquickbinding/qquickbinding.pro new file mode 100644 index 0000000000..b87e93495d --- /dev/null +++ b/tests/auto/qml/qquickbinding/qquickbinding.pro @@ -0,0 +1,15 @@ +CONFIG += testcase +TARGET = tst_qquickbinding +macx:CONFIG -= app_bundle + +SOURCES += tst_qquickbinding.cpp + +include (../../shared/util.pri) + +testDataFiles.files = data +testDataFiles.path = . +DEPLOYMENT += testDataFiles + +CONFIG += parallel_test + +QT += core-private gui-private qml-private quick-private testlib diff --git a/tests/auto/qml/qquickbinding/tst_qquickbinding.cpp b/tests/auto/qml/qquickbinding/tst_qquickbinding.cpp new file mode 100644 index 0000000000..939c4a9e3d --- /dev/null +++ b/tests/auto/qml/qquickbinding/tst_qquickbinding.cpp @@ -0,0 +1,197 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include +#include +#include +#include +#include +#include "../../shared/util.h" + +class tst_qquickbinding : public QQmlDataTest +{ + Q_OBJECT +public: + tst_qquickbinding(); + +private slots: + void binding(); + void whenAfterValue(); + void restoreBinding(); + void restoreBindingWithLoop(); + void deletedObject(); + +private: + QQmlEngine engine; +}; + +tst_qquickbinding::tst_qquickbinding() +{ +} + +void tst_qquickbinding::binding() +{ + QQmlEngine engine; + QQmlComponent c(&engine, testFileUrl("test-binding.qml")); + QQuickRectangle *rect = qobject_cast(c.create()); + QVERIFY(rect != 0); + + QQuickBind *binding3 = qobject_cast(rect->findChild("binding3")); + QVERIFY(binding3 != 0); + + QCOMPARE(rect->color(), QColor("yellow")); + QCOMPARE(rect->property("text").toString(), QString("Hello")); + QCOMPARE(binding3->when(), false); + + rect->setProperty("changeColor", true); + QCOMPARE(rect->color(), QColor("red")); + + QCOMPARE(binding3->when(), true); + + QQuickBind *binding = qobject_cast(rect->findChild("binding1")); + QVERIFY(binding != 0); + QCOMPARE(binding->object(), qobject_cast(rect)); + QCOMPARE(binding->property(), QLatin1String("text")); + QCOMPARE(binding->value().toString(), QLatin1String("Hello")); + + delete rect; +} + +void tst_qquickbinding::whenAfterValue() +{ + QQmlEngine engine; + QQmlComponent c(&engine, testFileUrl("test-binding2.qml")); + QQuickRectangle *rect = qobject_cast(c.create()); + + QVERIFY(rect != 0); + QCOMPARE(rect->color(), QColor("yellow")); + QCOMPARE(rect->property("text").toString(), QString("Hello")); + + rect->setProperty("changeColor", true); + QCOMPARE(rect->color(), QColor("red")); + + delete rect; +} + +void tst_qquickbinding::restoreBinding() +{ + QQmlEngine engine; + QQmlComponent c(&engine, testFileUrl("restoreBinding.qml")); + QQuickRectangle *rect = qobject_cast(c.create()); + QVERIFY(rect != 0); + + QQuickRectangle *myItem = qobject_cast(rect->findChild("myItem")); + QVERIFY(myItem != 0); + + myItem->setY(25); + QCOMPARE(myItem->x(), qreal(100-25)); + + myItem->setY(13); + QCOMPARE(myItem->x(), qreal(100-13)); + + //Binding takes effect + myItem->setY(51); + QCOMPARE(myItem->x(), qreal(51)); + + myItem->setY(88); + QCOMPARE(myItem->x(), qreal(88)); + + //original binding restored + myItem->setY(49); + QCOMPARE(myItem->x(), qreal(100-49)); + + delete rect; +} + +void tst_qquickbinding::restoreBindingWithLoop() +{ + QQmlEngine engine; + QQmlComponent c(&engine, testFileUrl("restoreBindingWithLoop.qml")); + QQuickRectangle *rect = qobject_cast(c.create()); + QVERIFY(rect != 0); + + QQuickRectangle *myItem = qobject_cast(rect->findChild("myItem")); + QVERIFY(myItem != 0); + + myItem->setY(25); + QCOMPARE(myItem->x(), qreal(25 + 100)); + + myItem->setY(13); + QCOMPARE(myItem->x(), qreal(13 + 100)); + + //Binding takes effect + rect->setProperty("activateBinding", true); + myItem->setY(51); + QCOMPARE(myItem->x(), qreal(51)); + + myItem->setY(88); + QCOMPARE(myItem->x(), qreal(88)); + + //original binding restored + QString warning = c.url().toString() + QLatin1String(":9:5: QML Rectangle: Binding loop detected for property \"x\""); + QTest::ignoreMessage(QtWarningMsg, qPrintable(warning)); + rect->setProperty("activateBinding", false); + QCOMPARE(myItem->x(), qreal(88 + 100)); //if loop handling changes this could be 90 + 100 + + myItem->setY(49); + QCOMPARE(myItem->x(), qreal(49 + 100)); + + delete rect; +} + +//QTBUG-20692 +void tst_qquickbinding::deletedObject() +{ + QQmlEngine engine; + QQmlComponent c(&engine, testFileUrl("deletedObject.qml")); + QQuickRectangle *rect = qobject_cast(c.create()); + QVERIFY(rect != 0); + + QGuiApplication::sendPostedEvents(0, QEvent::DeferredDelete); + + //don't crash + rect->setProperty("activateBinding", true); + + delete rect; +} + +QTEST_MAIN(tst_qquickbinding) + +#include "tst_qquickbinding.moc" diff --git a/tests/auto/qml/qquickchangeset/qquickchangeset.pro b/tests/auto/qml/qquickchangeset/qquickchangeset.pro new file mode 100644 index 0000000000..726b18665b --- /dev/null +++ b/tests/auto/qml/qquickchangeset/qquickchangeset.pro @@ -0,0 +1,9 @@ +CONFIG += testcase +TARGET = tst_qquickchangeset +macx:CONFIG -= app_bundle + +SOURCES += tst_qquickchangeset.cpp + +CONFIG += parallel_test + +QT += core-private gui-private qml-private quick-private testlib diff --git a/tests/auto/qml/qquickchangeset/tst_qquickchangeset.cpp b/tests/auto/qml/qquickchangeset/tst_qquickchangeset.cpp new file mode 100644 index 0000000000..4bd3df90ac --- /dev/null +++ b/tests/auto/qml/qquickchangeset/tst_qquickchangeset.cpp @@ -0,0 +1,812 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include +#include + +#define VERIFY_EXPECTED_OUTPUT + +class tst_qquickchangeset : public QObject +{ + Q_OBJECT +public: + struct Signal + { + int index; + int count; + int to; + int moveId; + + bool isInsert() const { return to == -1; } + bool isRemove() const { return to == -2; } + bool isMove() const { return to >= 0; } + bool isChange() const { return to == -3; } + }; + + static Signal Insert(int index, int count, int moveId = -1) { Signal signal = { index, count, -1, moveId }; return signal; } + static Signal Remove(int index, int count, int moveId = -1) { Signal signal = { index, count, -2, moveId }; return signal; } + static Signal Move(int from, int to, int count) { Signal signal = { from, count, to, -1 }; return signal; } + static Signal Change(int index, int count) { Signal signal = { index, count, -3, -1 }; return signal; } + + typedef QVector SignalList; + + +#ifdef VERIFY_EXPECTED_OUTPUT + + template + void move(int from, int to, int n, T *items) + { + if (from > to) { + // Only move forwards - flip if backwards moving + int tfrom = from; + int tto = to; + from = tto; + to = tto+n; + n = tfrom-tto; + } + + T replaced; + int i=0; + typename T::ConstIterator it=items->begin(); it += from+n; + for (; ibegin(); it += from; + for (; ibegin(); t += from; + for (; f != replaced.end(); ++f, ++t) + *t = *f; + } + + QVector applyChanges(const QVector &list, const QVector &changes) + { + QHash > removedValues; + QVector alteredList = list; + foreach (const Signal &signal, changes) { + if (signal.isInsert()) { + if (signal.moveId != -1) { + QVector tail = alteredList.mid(signal.index); + alteredList = alteredList.mid(0, signal.index) + removedValues.take(signal.moveId) + tail; + } else { + alteredList.insert(signal.index, signal.count, 100); + } + } else if (signal.isRemove()) { + if (signal.moveId != -1) + removedValues.insert(signal.moveId, alteredList.mid(signal.index, signal.count)); + alteredList.erase(alteredList.begin() + signal.index, alteredList.begin() + signal.index + signal.count); + } else if (signal.isMove()) { + move(signal.index, signal.to, signal.count, &alteredList); + } else if (signal.isChange()) { + for (int i = signal.index; i < signal.index + signal.count; ++i) { + if (alteredList[i] < 100) + alteredList[i] = 100; + } + } + } + return alteredList; + } + +#endif + +private slots: + void sequence_data(); + void sequence(); +}; + +bool operator ==(const tst_qquickchangeset::Signal &left, const tst_qquickchangeset::Signal &right) +{ + return left.index == right.index + && left.count == right.count + && left.to == right.to + && ((left.moveId == -1 && right.moveId == -1) || (left.moveId != -1 && right.moveId != -1)); +} + + +QDebug operator <<(QDebug debug, const tst_qquickchangeset::Signal &signal) +{ + if (signal.isInsert()) + debug.nospace() << "Insert(" << signal.index << "," << signal.count << "," << signal.moveId << ")"; + else if (signal.isRemove()) + debug.nospace() << "Remove(" << signal.index << "," << signal.count << "," << signal.moveId << ")"; + else if (signal.isMove()) + debug.nospace() << "Move(" << signal.index << "," << signal.to << "," << signal.count << ")"; + else if (signal.isChange()) + debug.nospace() << "Change(" << signal.index << "," << signal.count << ")"; + return debug; +} + +Q_DECLARE_METATYPE(tst_qquickchangeset::SignalList) + +void tst_qquickchangeset::sequence_data() +{ + QTest::addColumn("input"); + QTest::addColumn("output"); + + // Insert + QTest::newRow("i(12,5)") + << (SignalList() << Insert(12,5)) + << (SignalList() << Insert(12,5)); + QTest::newRow("i(2,3),i(12,5)") + << (SignalList() << Insert(2,3) << Insert(12,5)) + << (SignalList() << Insert(2,3) << Insert(12,5)); + QTest::newRow("i(12,5),i(2,3)") + << (SignalList() << Insert(12,5) << Insert(2,3)) + << (SignalList() << Insert(2,3) << Insert(15,5)); + QTest::newRow("i(12,5),i(12,3)") + << (SignalList() << Insert(12,5) << Insert(12,3)) + << (SignalList() << Insert(12,8)); + QTest::newRow("i(12,5),i(17,3)") + << (SignalList() << Insert(12,5) << Insert(17,3)) + << (SignalList() << Insert(12,8)); + QTest::newRow("i(12,5),i(15,3)") + << (SignalList() << Insert(12,5) << Insert(15,3)) + << (SignalList() << Insert(12,8)); + + // Remove + QTest::newRow("r(3,9)") + << (SignalList() << Remove(3,9)) + << (SignalList() << Remove(3,9)); + QTest::newRow("r(3,4),r(3,2)") + << (SignalList() << Remove(3,4) << Remove(3,2)) + << (SignalList() << Remove(3,6)); + QTest::newRow("r(4,3),r(14,5)") + << (SignalList() << Remove(4,3) << Remove(14,5)) + << (SignalList() << Remove(4,3) << Remove(14,5)); + QTest::newRow("r(14,5),r(4,3)") + << (SignalList() << Remove(14,5) << Remove(4,3)) + << (SignalList() << Remove(4,3) << Remove(11,5)); + QTest::newRow("r(4,3),r(2,9)") + << (SignalList() << Remove(4,3) << Remove(2,9)) + << (SignalList() << Remove(2,12)); + + // Move + QTest::newRow("m(8-10,2)") + << (SignalList() << Move(8,10,2)) + << (SignalList() << Remove(8,2,1) << Insert(10,2,1)); + + QTest::newRow("m(23-12,6),m(13-15,5)") + << (SignalList() << Move(23,12,6) << Move(13,15,5)) + << (SignalList() << Remove(23,1,0) << Remove(23,5,1) << Insert(12,1,0) << Insert(15,5,1)); + QTest::newRow("m(23-12,6),m(13-15,2)") + << (SignalList() << Move(23,12,6) << Move(13,20,2)) + << (SignalList() << Remove(23,1,0) << Remove(23,2,1) << Remove(23,3,2) << Insert(12,1,0) << Insert(13,3,2) << Insert(20,2,1)); + QTest::newRow("m(23-12,6),m(13-2,2)") + << (SignalList() << Move(23,12,6) << Move(13,2,2)) + << (SignalList() << Remove(23,1,0) << Remove(23,2,1) << Remove(23,3,2) << Insert(2,2,1) << Insert(14,1,0) << Insert(15,3,2)); + QTest::newRow("m(23-12,6),m(12-6,5)") + << (SignalList() << Move(23,12,6) << Move(12,6,5)) + << (SignalList() << Remove(23,5,0) << Remove(23,1,1) << Insert(6,5,0) << Insert(17,1,1)); + QTest::newRow("m(23-12,6),m(10-5,4)") + << (SignalList() << Move(23,12,6) << Move(10,5,4)) + << (SignalList() << Remove(10,2,0) << Remove(21,2,1) << Remove(21,4,2) << Insert(5,2,0) << Insert(7,2,1) << Insert(14,4,2)); + QTest::newRow("m(23-12,6),m(16-5,4)") + << (SignalList() << Move(23,12,6) << Move(16,5,4)) + << (SignalList() << Remove(12,2,0) << Remove(21,4,1) << Remove(21,2,2) << Insert(5,2,2) << Insert(7,2,0) << Insert(16,4,1)); + QTest::newRow("m(23-12,6),m(13-5,4)") + << (SignalList() << Move(23,12,6) << Move(13,5,4)) + << (SignalList() << Remove(23,1,0) << Remove(23,4,1) << Remove(23,1,2) << Insert(5,4,1) << Insert(16,1,0) << Insert(17,1,2)); + QTest::newRow("m(23-12,6),m(14-5,4)") + << (SignalList() << Move(23,12,6) << Move(14,5,4)) + << (SignalList() << Remove(23,2,0) << Remove(23,4,1) << Insert(5,4,1) << Insert(16,2,0)); + QTest::newRow("m(23-12,6),m(12-5,4)") + << (SignalList() << Move(23,12,6) << Move(12,5,4)) + << (SignalList() << Remove(23,4,0) << Remove(23,2,1) << Insert(5,4,0) << Insert(16,2,1)); + QTest::newRow("m(23-12,6),m(11-5,8)") + << (SignalList() << Move(23,12,6) << Move(11,5,8)) + << (SignalList() << Remove(11,1,0) << Remove(11,1,1) << Remove(21,6,2) << Insert(5,1,0) << Insert(6,6,2) << Insert(12,1,1)); + QTest::newRow("m(23-12,6),m(8-5,4)") + << (SignalList() << Move(23,12,6) << Move(8,5,4)) + << (SignalList() << Remove(8,4,0) << Remove(19,6,1) << Insert(5,4,0) << Insert(12,6,1)); + QTest::newRow("m(23-12,6),m(2-5,4)") + << (SignalList() << Move(23,12,6) << Move(2,5,4)) + << (SignalList() << Remove(2,4,0) << Remove(19,6,1) << Insert(5,4,0) << Insert(12,6,1)); + QTest::newRow("m(23-12,6),m(18-5,4)") + << (SignalList() << Move(23,12,6) << Move(18,5,4)) + << (SignalList() << Remove(12,4,0) << Remove(19,6,1) << Insert(5,4,0) << Insert(16,6,1)); + QTest::newRow("m(23-12,6),m(20-5,4)") + << (SignalList() << Move(23,12,6) << Move(20,5,4)) + << (SignalList() << Remove(14,4,0) << Remove(19,6,1) << Insert(5,4,0) << Insert(16,6,1)); + + QTest::newRow("m(23-12,6),m(5-13,11)") + << (SignalList() << Move(23,12,6) << Move(5,13,11)) + << (SignalList() << Remove(5,7,0) << Remove(16,4,1) << Remove(16,2,2) << Insert(5,2,2) << Insert(13,7,0) << Insert(20,4,1)); + + QTest::newRow("m(23-12,6),m(12-23,6)") + << (SignalList() << Move(23,12,6) << Move(12,23,6)) + << (SignalList() << Remove(23,6,0) << Insert(23,6,0)); // ### These cancel out. + QTest::newRow("m(23-12,6),m(10-23,4)") + << (SignalList() << Move(23,12,6) << Move(10,23,4)) + << (SignalList() << Remove(10,2 ,0) << Remove(21,2,1) << Remove(21,4,2) << Insert(10,4,2) << Insert(23,2,0) << Insert(25,2,1)); + QTest::newRow("m(23-12,6),m(16-23.4)") + << (SignalList() << Move(23,12,6) << Move(16,23,4)) + << (SignalList() << Remove(12,2,0) << Remove(21,4,1) << Remove(21,2,2) << Insert(12,4,1) << Insert(23,2,2) << Insert(25,2,0)); + QTest::newRow("m(23-12,6),m(13-23,4)") + << (SignalList() << Move(23,12,6) << Move(13,23,4)) + << (SignalList() << Remove(23,1,0) << Remove(23,4,1) << Remove(23,1,2) << Insert(12,1,0) << Insert(13,1,2) << Insert(23,4,1)); + QTest::newRow("m(23-12,6),m(14-23,)") + << (SignalList() << Move(23,12,6) << Move(14,23,4)) + << (SignalList() << Remove(23,2,0) << Remove(23,4,1) << Insert(12,2,0) << Insert(23,4,1)); + QTest::newRow("m(23-12,6),m(12-23,4)") + << (SignalList() << Move(23,12,6) << Move(12,23,4)) + << (SignalList() << Remove(23,4,0) << Remove(23,2,1) << Insert(12,2,1) << Insert(23,4,0)); + QTest::newRow("m(23-12,6),m(11-23,8)") + << (SignalList() << Move(23,12,6) << Move(11,23,8)) + << (SignalList() << Remove(11,1,0) << Remove(11,1,1) << Remove(21,6,2) << Insert(23,1,0) << Insert(24,6,2) << Insert(30,1,1)); + QTest::newRow("m(23-12,6),m(8-23,4)") + << (SignalList() << Move(23,12,6) << Move(8,23,4)) + << (SignalList() << Remove(8,4,0) << Remove(19,6,1) << Insert(8,6,1) << Insert(23,4,0)); + QTest::newRow("m(23-12,6),m(2-23,4)") + << (SignalList() << Move(23,12,6) << Move(2,23,4)) + << (SignalList() << Remove(2,4,0) << Remove(19,6,1) << Insert(8,6,1) << Insert(23,4,0)); + QTest::newRow("m(23-12,6),m(18-23,4)") + << (SignalList() << Move(23,12,6) << Move(18,23,4)) + << (SignalList() << Remove(12,4,0) << Remove(19,6,1) << Insert(12,6,1) << Insert(23,4,0)); + QTest::newRow("m(23-12,6),m(20-23,4)") + << (SignalList() << Move(23,12,6) << Move(20,23,4)) + << (SignalList() << Remove(14,4,1) << Remove(19,6,0) << Insert(12,6,0) << Insert(23,4,1)); + + QTest::newRow("m(23-12,6),m(11-23,10)") + << (SignalList() << Move(23,12,6) << Move(11,23,10)) + << (SignalList() << Remove(11,1,3) << Remove(11,3,1) << Remove(19,6,2) << Insert(23,1,3) << Insert(24,6,2) << Insert(30,3,1)); + + QTest::newRow("m(3-9,12),m(13-5,12)") + << (SignalList() << Move(3,9,12) << Move(13,15,5)) + << (SignalList() << Remove(3,4,2) << Remove(3,5,1) << Remove(3,2,0) << Remove(3,1,3) << Insert(9,4,2) << Insert(13,2,0) << Insert(15,5,1) << Insert(20,1,3)); + QTest::newRow("m(3-9,12),m(13-15,20)") + << (SignalList() << Move(3,9,12) << Move(13,15,20)) + << (SignalList() << Remove(3,4,0) << Remove(3,8,1) << Remove(9,12,2) << Insert(9,4,0) << Insert(15,8,1) << Insert(23,12,2)); + QTest::newRow("m(3-9,12),m(13-15,2)") + << (SignalList() << Move(3,9,12) << Move(13,15,2)) + << (SignalList() << Remove(3,4,2) << Remove(3,2,1) << Remove(3,2,0) << Remove(3,4,3) << Insert(9,4,2) << Insert(13,2,0) << Insert(15,2,1) << Insert(17,4,3)); + QTest::newRow("m(3-9,12),m(12-5,6)") + << (SignalList() << Move(3,9,12) << Move(12,5,6)) + << (SignalList() << Remove(3,3,0) << Remove(3,6,1) << Remove(3,3,2) << Insert(5,6,1) << Insert(15,3,0) << Insert(18,3,2)); + QTest::newRow("m(3-9,12),m(10-14,5)") + << (SignalList() << Move(3,9,12) << Move(10,14,5)) + << (SignalList() << Remove(3,1,2) << Remove(3,5,1) << Remove(3,4,0) << Remove(3,2,3) << Insert(9,1,2) << Insert(10,4,0) << Insert(14,5,1) << Insert(19,2,3)); + QTest::newRow("m(3-9,12),m(16-20,5)") + << (SignalList() << Move(3,9,12) << Move(16,20,5)) + << (SignalList() << Remove(3,7,0) << Remove(3,5,1) << Insert(9,7,0) << Insert(20,5,1)); + QTest::newRow("m(3-9,12),m(13-17,5)") + << (SignalList() << Move(3,9,12) << Move(13,17,5)) + << (SignalList() << Remove(3,4,0) << Remove(3,5,1) << Remove(3,3,2) << Insert(9,4,0) << Insert(13,3,2) << Insert(17,5,1)); + QTest::newRow("m(3-9,12),m(14-18,5)") + << (SignalList() << Move(3,9,12) << Move(14,18,5)) + << (SignalList() << Remove(3,5,0) << Remove(3,5,1) << Remove(3,2,2) << Insert(9,5,0) << Insert(14,2,2) << Insert(18,5,1)); + QTest::newRow("m(3-9,12),m(12-16,5)") + << (SignalList() << Move(3,9,12) << Move(12,16,5)) + << (SignalList() << Remove(3,3,2) << Remove(3,5,1) << Remove(3,4,0) << Insert(9,3,2) << Insert(12,4,0) << Insert(16,5,1)); + QTest::newRow("m(3-9,12),m(11-19,5)") + << (SignalList() << Move(3,9,12) << Move(11,19,5)) + << (SignalList() << Remove(3,2,0) << Remove(3,5,1) << Remove(3,5,2) << Insert(9,2,0) << Insert(11,5,2) << Insert(19,5,1)); + QTest::newRow("m(3-9,12),m(8-12,5)") + << (SignalList() << Move(3,9,12) << Move(8,12,5)) + << (SignalList() << Remove(3,4,1) << Remove(3,4,0) << Remove(3,4,4) << Remove(8,1,2) << Insert(8,4,0) << Insert(12,1,2) << Insert(13,4,1) << Insert(17,4,4)); + QTest::newRow("m(3-9,12),m(2-6,5)") + << (SignalList() << Move(3,9,12) << Move(2,6,5)) + << (SignalList() << Remove(2,1,2) << Remove(2,2,0) << Remove(2,10,3) << Remove(2,4,1) << Insert(4,2,0) << Insert(6,1,2) << Insert(7,4,1) << Insert(11,10,3)); + QTest::newRow("m(3-9,12),m(18-22,5)") + << (SignalList() << Move(3,9,12) << Move(18,22,5)) + << (SignalList() << Remove(3,9,0) << Remove(3,3,1) << Remove(9,2,2) << Insert(9,9,0) << Insert(22,3,1) << Insert(25,2,2)); + QTest::newRow("m(3-9,12),m(20-24,5)") + << (SignalList() << Move(3,9,12) << Move(20,24,5)) + << (SignalList() << Remove(3,11,0) << Remove(3,1,1) << Remove(9,4,2) << Insert(9,11,0) << Insert(24,1,1) << Insert(25,4,2)); + + QTest::newRow("m(3-9,12),m(5-11,8)") + << (SignalList() << Move(3,9,12) << Move(5,11,8)) + << (SignalList() << Remove(3,4,1) << Remove(3,6,0) << Remove(3,2,3) << Remove(5,4,2) << Insert(5,6,0) << Insert(11,4,2) << Insert(15,2,3) << Insert(15,4,1)); + + QTest::newRow("m(3-9,12),m(12-23,6)") + << (SignalList() << Move(3,9,12) << Move(12,23,6)) + << (SignalList() << Remove(3,3,2) << Remove(3,6,1) << Remove(3,3,0) << Insert(9,3,2) << Insert(12,3,0) << Insert(23,6,1)); + QTest::newRow("m(3-9,12),m(10-23,4)") + << (SignalList() << Move(3,9,12) << Move(10,23,4)) + << (SignalList() << Remove(3,1,2) << Remove(3,4,1) << Remove(3,7,0) << Insert(9,1,2) << Insert(10,7,0) << Insert(23,4,1)); + QTest::newRow("m(3-9,12),m(16-23,4)") + << (SignalList() << Move(3,9,12) << Move(16,23,4)) + << (SignalList() << Remove(3,7,2) << Remove(3,4,1) << Remove(3,1,0) << Insert(9,7,2) << Insert(16,1,0) << Insert(23,4,1)); + QTest::newRow("m(3-9,12),m(13-23,4)") + << (SignalList() << Move(3,9,12) << Move(13,23,4)) + << (SignalList() << Remove(3,4,2) << Remove(3,4,1) << Remove(3,4,0) << Insert(9,4,2) << Insert(13,4,0) << Insert(23,4,1)); + QTest::newRow("m(3-9,12),m(14-23,4)") + << (SignalList() << Move(3,9,12) << Move(14,23,4)) + << (SignalList() << Remove(3,5,2) << Remove(3,4,1) << Remove(3,3,0) << Insert(9,5,2) << Insert(14,3,0) << Insert(23,4,1)); + QTest::newRow("m(3-9,12),m(12-23,4)") + << (SignalList() << Move(3,9,12) << Move(12,23,4)) + << (SignalList() << Remove(3,3,2) << Remove(3,4,1) << Remove(3,5,0) << Insert(9,3,2) << Insert(12,5,0) << Insert(23,4,1)); + QTest::newRow("m(3-9,12),m(11-23,8)") + << (SignalList() << Move(3,9,12) << Move(11,23,8)) + << (SignalList() << Remove(3,2,2) << Remove(3,8,1) << Remove(3,2,0) << Insert(9,2,2) << Insert(11,2,0) << Insert(23,8,1)); + QTest::newRow("m(3-9,12),m(8-23,4)") + << (SignalList() << Move(3,9,12) << Move(8,23,4)) + << (SignalList() << Remove(3,3,1) << Remove(3,9,0) << Remove(8,1,2) << Insert(8,9,0) << Insert(23,1,2) << Insert(24,3,1)); + QTest::newRow("m(3-9,12),m(2-23,4)") + << (SignalList() << Move(3,9,12) << Move(2,23,4)) + << (SignalList() << Remove(2,1,2) << Remove(2,12,0) << Remove(2,3,1) << Insert(5,12,0) << Insert(23,1,2) << Insert(24,3,1)); + QTest::newRow("m(3-9,12),m(18-23,4)") + << (SignalList() << Move(3,9,12) << Move(18,23,4)) + << (SignalList() << Remove(3,9,3) << Remove(3,3,2) << Remove(9,1,1) << Insert(9,9,3) << Insert(23,3,2) << Insert(26,1,1)); + QTest::newRow("m(3-9,12),m(20-23,4)") + << (SignalList() << Move(3,9,12) << Move(20,23,4)) + << (SignalList() << Remove(3,11,3) << Remove(3,1,2) << Remove(9,3,1) << Insert(9,11,3) << Insert(23,1,2) << Insert(24,3,1)); + + QTest::newRow("m(3-9,12),m(11-23,10)") + << (SignalList() << Move(3,9,12) << Move(11,23,10)) + << (SignalList() << Remove(3,2,2) << Remove(3,10,1) << Insert(9,2,2) << Insert(23,10,1)); + + // Change + QTest::newRow("c(4,5)") + << (SignalList() << Change(4,5)) + << (SignalList() << Change(4,5)); + QTest::newRow("c(4,5),c(12,2)") + << (SignalList() << Change(4,5) << Change(12,2)) + << (SignalList() << Change(4,5) << Change(12,2)); + QTest::newRow("c(12,2),c(4,5)") + << (SignalList() << Change(12,2) << Change(4,5)) + << (SignalList() << Change(4,5) << Change(12,2)); + QTest::newRow("c(4,5),c(2,2)") + << (SignalList() << Change(4,5) << Change(2,2)) + << (SignalList() << Change(2,7)); + QTest::newRow("c(4,5),c(9,2)") + << (SignalList() << Change(4,5) << Change(9,2)) + << (SignalList() << Change(4,7)); + QTest::newRow("c(4,5),c(3,2)") + << (SignalList() << Change(4,5) << Change(3,2)) + << (SignalList() << Change(3,6)); + QTest::newRow("c(4,5),c(8,2)") + << (SignalList() << Change(4,5) << Change(8,2)) + << (SignalList() << Change(4,6)); + QTest::newRow("c(4,5),c(3,2)") + << (SignalList() << Change(4,5) << Change(3,2)) + << (SignalList() << Change(3,6)); + QTest::newRow("c(4,5),c(2,9)") + << (SignalList() << Change(4,5) << Change(2,9)) + << (SignalList() << Change(2,9)); + QTest::newRow("c(4,5),c(12,3),c(8,6)") + << (SignalList() << Change(4,5) << Change(12,3) << Change(8,6)) + << (SignalList() << Change(4,11)); + + // Insert,then remove. + QTest::newRow("i(12,6),r(12,6)") + << (SignalList() << Insert(12,6) << Remove(12,6)) + << (SignalList()); + QTest::newRow("i(12,6),r(10,4)") + << (SignalList() << Insert(12,6) << Remove(10,4)) + << (SignalList() << Remove(10,2) << Insert(10,4)); + QTest::newRow("i(12,6),r(16,4)") + << (SignalList() << Insert(12,6) << Remove(16,4)) + << (SignalList() << Remove(12,2) << Insert(12,4)); + QTest::newRow("i(12,6),r(13,4)") + << (SignalList() << Insert(12,6) << Remove(13,4)) + << (SignalList() << Insert(12,2)); + QTest::newRow("i(12,6),r(14,4)") + << (SignalList() << Insert(12,6) << Remove(14,4)) + << (SignalList() << Insert(12,2)); + QTest::newRow("i(12,6),r(12,4)") + << (SignalList() << Insert(12,6) << Remove(12,4)) + << (SignalList() << Insert(12,2)); + QTest::newRow("i(12,6),r(11,8)") + << (SignalList() << Insert(12,6) << Remove(11,8)) + << (SignalList() << Remove(11,2)); + QTest::newRow("i(12,6),r(8,4)") + << (SignalList() << Insert(12,6) << Remove(8,4)) + << (SignalList() << Remove(8,4) << Insert(8,6)); + QTest::newRow("i(12,6),r(2,4)") + << (SignalList() << Insert(12,6) << Remove(2,4)) + << (SignalList() << Remove(2,4) << Insert(8,6)); + QTest::newRow("i(12,6),r(18,4)") + << (SignalList() << Insert(12,6) << Remove(18,4)) + << (SignalList() << Remove(12,4) << Insert(12,6)); + QTest::newRow("i(12,6),r(20,4)") + << (SignalList() << Insert(12,6) << Remove(20,4)) + << (SignalList() << Remove(14,4) << Insert(12,6)); + + // Insert,then move + QTest::newRow("i(12,6),m(12-5,6)") + << (SignalList() << Insert(12,6) << Move(12,5,6)) + << (SignalList() << Insert(5,6)); + QTest::newRow("i(12,6),m(10-5,4)") + << (SignalList() << Insert(12,6) << Move(10,5,4)) + << (SignalList() << Remove(10,2,0) << Insert(5,2,0) << Insert(7,2) << Insert(14,4)); + QTest::newRow("i(12,6),m(16-5,4)") + << (SignalList() << Insert(12,6) << Move(16,5,4)) + << (SignalList() << Remove(12,2,0) << Insert(5,2) << Insert(7,2,0) << Insert(16,4)); + QTest::newRow("i(12,6),m(13-5,4)") + << (SignalList() << Insert(12,6) << Move(13,5,4)) + << (SignalList() << Insert(5,4) << Insert(16,2)); + QTest::newRow("i(12,6),m(14-5,4)") + << (SignalList() << Insert(12,6) << Move(14,5,4)) + << (SignalList() << Insert(5,4) << Insert(16,2)); + QTest::newRow("i(12,6),m(12-5,4)") + << (SignalList() << Insert(12,6) << Move(12,5,4)) + << (SignalList() << Insert(5,4) << Insert(16,2)); + QTest::newRow("i(12,6),m(11-5,8)") + << (SignalList() << Insert(12,6) << Move(11,5,8)) + << (SignalList() << Remove(11,1,0) << Remove(11,1,1) << Insert(5,1,0) << Insert(6,6) << Insert(12,1,1)); + QTest::newRow("i(12,6),m(8-5,4)") + << (SignalList() << Insert(12,6) << Move(8,5,4)) + << (SignalList() << Remove(8,4,0) << Insert(5,4,0) << Insert(12,6)); + QTest::newRow("i(12,6),m(2-5,4)") + << (SignalList() << Insert(12,6) << Move(2,5,4)) + << (SignalList() << Remove(2,4,0) << Insert(5,4,0) << Insert(12,6)); + QTest::newRow("i(12,6),m(18-5,4)") + << (SignalList() << Insert(12,6) << Move(18,5,4)) + << (SignalList() << Remove(12,4,0) << Insert(5,4,0) << Insert(16,6)); + QTest::newRow("i(12,6),m(20-5,4)") + << (SignalList() << Insert(12,6) << Move(20,5,4)) + << (SignalList() << Remove(14,4,0) << Insert(5,4,0) << Insert(16,6)); + + QTest::newRow("i(12,6),m(5-13,11)") + << (SignalList() << Insert(12,6) << Move(5,11,8)) + << (SignalList() << Remove(5,7,0) << Insert(5,5) << Insert(11,7,0) << Insert(18,1)); + + QTest::newRow("i(12,6),m(12-23,6)") + << (SignalList() << Insert(12,6) << Move(12,23,6)) + << (SignalList() << Insert(23,6)); + QTest::newRow("i(12,6),m(10-23,4)") + << (SignalList() << Insert(12,6) << Move(10,23,4)) + << (SignalList() << Remove(10,2,0) << Insert(10,4) << Insert(23,2,0) << Insert(25,2)); + QTest::newRow("i(12,6),m(16-23,4)") + << (SignalList() << Insert(12,6) << Move(16,23,4)) + << (SignalList() << Remove(12,2,0) << Insert(12,4) << Insert(23,2) << Insert(25,2,0)); + QTest::newRow("i(12,6),m(13-23,4)") + << (SignalList() << Insert(12,6) << Move(13,23,4)) + << (SignalList() << Insert(12,2) << Insert(23,4)); + QTest::newRow("i(12,6),m(14-23,4)") + << (SignalList() << Insert(12,6) << Move(14,23,4)) + << (SignalList() << Insert(12,2) << Insert(23,4)); + QTest::newRow("i(12,6),m(12-23,4)") + << (SignalList() << Insert(12,6) << Move(12,23,4)) + << (SignalList() << Insert(12,2) << Insert(23,4)); + QTest::newRow("i(12,6),m(11-23,8)") + << (SignalList() << Insert(12,6) << Move(11,23,8)) + << (SignalList() << Remove(11,1,0) << Remove(11,1,1) << Insert(23,1,0)<< Insert(24,6) << Insert(30,1,1)); + QTest::newRow("i(12,6),m(8-23,4)") + << (SignalList() << Insert(12,6) << Move(8,23,4)) + << (SignalList() << Remove(8,4,0) << Insert(8,6) << Insert(23,4,0)); + QTest::newRow("i(12,6),m(2-23,4)") + << (SignalList() << Insert(12,6) << Move(2,23,4)) + << (SignalList() << Remove(2,4,0) << Insert(8,6) << Insert(23,4,0)); + QTest::newRow("i(12,6),m(18-23,4)") + << (SignalList() << Insert(12,6) << Move(18,23,4)) + << (SignalList() << Remove(12,4,0) << Insert(12,6) << Insert(23,4,0)); + QTest::newRow("i(12,6),m(20-23,4)") + << (SignalList() << Insert(12,6) << Move(20,23,4)) + << (SignalList() << Remove(14,4,0) << Insert(12,6) << Insert(23,4,0)); + + QTest::newRow("i(12,6),m(11-23,10)") + << (SignalList() << Insert(12,6) << Move(11,23,10)) + << (SignalList() << Remove(11,1,0) << Remove(11,3,1) << Insert(23,1,0) << Insert(24,6) << Insert(30,3,1)); + + // Insert,then change + QTest::newRow("i(12,6),c(12,6)") + << (SignalList() << Insert(12,6) << Change(12,6)) + << (SignalList() << Insert(12,6)); + QTest::newRow("i(12,6),c(10,6)") + << (SignalList() << Insert(12,6) << Change(10,6)) + << (SignalList() << Insert(12,6) << Change(10,2)); + QTest::newRow("i(12,6),c(16,4)") + << (SignalList() << Insert(12,6) << Change(16,4)) + << (SignalList() << Insert(12,6) << Change(18,2)); + QTest::newRow("i(12,6),c(13,4)") + << (SignalList() << Insert(12,6) << Change(13,4)) + << (SignalList() << Insert(12,6)); + QTest::newRow("i(12,6),c(14,4)") + << (SignalList() << Insert(12,6) << Change(14,4)) + << (SignalList() << Insert(12,6)); + QTest::newRow("i(12,6),c(12,4)") + << (SignalList() << Insert(12,6) << Change(12,4)) + << (SignalList() << Insert(12,6)); + QTest::newRow("i(12,6),c(11,8)") + << (SignalList() << Insert(12,6) << Change(11,8)) + << (SignalList() << Insert(12,6) << Change(11,1) << Change(18,1)); + QTest::newRow("i(12,6),c(8,4)") + << (SignalList() << Insert(12,6) << Change(8,4)) + << (SignalList() << Insert(12,6) << Change(8,4)); + QTest::newRow("i(12,6),c(2,4)") + << (SignalList() << Insert(12,6) << Change(2,4)) + << (SignalList() << Insert(12,6) << Change(2,4)); + QTest::newRow("i(12,6),c(18,4)") + << (SignalList() << Insert(12,6) << Change(18,4)) + << (SignalList() << Insert(12,6) << Change(18,4)); + QTest::newRow("i(12,6),c(20,4)") + << (SignalList() << Insert(12,6) << Change(20,4)) + << (SignalList() << Insert(12,6) << Change(20,4)); + + // Remove,then insert + QTest::newRow("r(12,6),i(12,6)") + << (SignalList() << Remove(12,6) << Insert(12,6)) + << (SignalList() << Remove(12,6) << Insert(12,6)); + QTest::newRow("r(12,6),i(10,4)") + << (SignalList() << Remove(12,6) << Insert(10,14)) + << (SignalList() << Remove(12,6) << Insert(10,14)); + QTest::newRow("r(12,6),i(16,4)") + << (SignalList() << Remove(12,6) << Insert(16,4)) + << (SignalList() << Remove(12,6) << Insert(16,4)); + QTest::newRow("r(12,6),i(13,4)") + << (SignalList() << Remove(12,6) << Insert(13,4)) + << (SignalList() << Remove(12,6) << Insert(13,4)); + QTest::newRow("r(12,6),i(14,4)") + << (SignalList() << Remove(12,6) << Insert(14,4)) + << (SignalList() << Remove(12,6) << Insert(14,4)); + QTest::newRow("r(12,6),i(12,4)") + << (SignalList() << Remove(12,6) << Insert(12,4)) + << (SignalList() << Remove(12,6) << Insert(12,4)); + QTest::newRow("r(12,6),i(11,8)") + << (SignalList() << Remove(12,6) << Insert(11,8)) + << (SignalList() << Remove(12,6) << Insert(11,8)); + QTest::newRow("r(12,6),i(8,4)") + << (SignalList() << Remove(12,6) << Insert(8,4)) + << (SignalList() << Remove(12,6) << Insert(8,4)); + QTest::newRow("r(12,6),i(2,4)") + << (SignalList() << Remove(12,6) << Insert(2,4)) + << (SignalList() << Remove(12,6) << Insert(2,4)); + QTest::newRow("r(12,6),i(18,4)") + << (SignalList() << Remove(12,6) << Insert(18,4)) + << (SignalList() << Remove(12,6) << Insert(18,4)); + QTest::newRow("r(12,6),i(20,4)") + << (SignalList() << Remove(12,6) << Insert(20,4)) + << (SignalList() << Remove(12,6) << Insert(20,4)); + + // Move,then insert + QTest::newRow("m(12-5,6),i(12,6)") + << (SignalList() << Move(12,5,6) << Insert(12,6)) + << (SignalList() << Remove(12,6,0) << Insert(5,6,0) << Insert(12,6)); + QTest::newRow("m(12-5,6),i(10,4)") + << (SignalList() << Move(12,5,6) << Insert(10,4)) + << (SignalList() << Remove(12,5,0) << Remove(12,1,1) << Insert(5,5,0) << Insert(10,4) << Insert(14,1,1)); + QTest::newRow("m(12-5,6),i(16,4)") + << (SignalList() << Move(12,5,6) << Insert(16,4)) + << (SignalList() << Remove(12,6,0) << Insert(5,6,0) << Insert(16,4)); + QTest::newRow("m(12-5,6),i(13,4)") + << (SignalList() << Move(12,5,6) << Insert(13,4)) + << (SignalList() << Remove(12,6,0) << Insert(5,6,0) << Insert(13,4)); + QTest::newRow("m(12-5,6),i(14,4)") + << (SignalList() << Move(12,5,6) << Insert(14,4)) + << (SignalList() << Remove(12,6,0) << Insert(5,6,0) << Insert(14,4)); + QTest::newRow("m(12-5,6),i(12,4)") + << (SignalList() << Move(12,5,6) << Insert(12,4)) + << (SignalList() << Remove(12,6,0) << Insert(5,6,0) << Insert(12,4)); + QTest::newRow("m(12-5,6),i(11,8)") + << (SignalList() << Move(12,5,6) << Insert(11,8)) + << (SignalList() << Remove(12,6,0) << Insert(5,6,0) << Insert(11,8)); + QTest::newRow("m(12-5,6),i(8,4)") + << (SignalList() << Move(12,5,6) << Insert(8,4)) + << (SignalList() << Remove(12,3,0) << Remove(12,3,1) << Insert(5,3,0) << Insert(8,4) << Insert(12,3,1)); + QTest::newRow("m(12-5,6),i(2,4)") + << (SignalList() << Move(12,5,6) << Insert(2,4)) + << (SignalList() << Remove(12,6,0) << Insert(2,4) << Insert(9,6,0)); + QTest::newRow("m(12-5,6),i(18,4)") + << (SignalList() << Move(12,5,6) << Insert(18,4)) + << (SignalList() << Remove(12,6,0) << Insert(5,6,0) << Insert(18,4)); + QTest::newRow("m(12-5,6),i(20,4)") + << (SignalList() << Move(12,5,6) << Insert(20,4)) + << (SignalList() << Remove(12,6,0) << Insert(5,6,0) << Insert(20,4)); + + QTest::newRow("m(12-23,6),i(12,6)") + << (SignalList() << Move(12,23,6) << Insert(12,6)) + << (SignalList() << Remove(12,6,0) << Insert(12,6) << Insert(29,6,0)); + QTest::newRow("m(12-23,6),i(10,4)") + << (SignalList() << Move(12,23,6) << Insert(10,4)) + << (SignalList() << Remove(12,6,0) << Insert(10,4) << Insert(27,6,0)); + QTest::newRow("m(12-23,6),i(16,4)") + << (SignalList() << Move(12,23,6) << Insert(16,4)) + << (SignalList() << Remove(12,6,0) << Insert(16,4) << Insert(27,6,0)); + QTest::newRow("m(12-23,6),i(13,4)") + << (SignalList() << Move(12,23,6) << Insert(13,4)) + << (SignalList() << Remove(12,6,0) << Insert(13,4) << Insert(27,6,0)); + QTest::newRow("m(12-23,6),i(14,4)") + << (SignalList() << Move(12,23,6) << Insert(14,4)) + << (SignalList() << Remove(12,6,0) << Insert(14,4) << Insert(27,6,0)); + QTest::newRow("m(12-23,6),i(12,4)") + << (SignalList() << Move(12,23,6) << Insert(12,4)) + << (SignalList() << Remove(12,6,0) << Insert(12,4) << Insert(27,6,0)); + QTest::newRow("m(12-23,6),i(11,8)") + << (SignalList() << Move(12,23,6) << Insert(11,8)) + << (SignalList() << Remove(12,6,0) << Insert(11,8) << Insert(31,6,0)); + QTest::newRow("m(12-23,6),i(8,4)") + << (SignalList() << Move(12,23,6) << Insert(8,4)) + << (SignalList() << Remove(12,6,0) << Insert(8,4) << Insert(27,6,0)); + QTest::newRow("m(12-23,6),i(2,4)") + << (SignalList() << Move(12,23,6) << Insert(2,4)) + << (SignalList() << Remove(12,6,0) << Insert(2,4) << Insert(27,6,0)); + QTest::newRow("m(12-23,6),i(18,4)") + << (SignalList() << Move(12,23,6) << Insert(18,4)) + << (SignalList() << Remove(12,6,0) << Insert(18,4) << Insert(27,6,0)); + QTest::newRow("m(12-23,6),i(20,4)") + << (SignalList() << Move(12,23,6) << Insert(20,4)) + << (SignalList() << Remove(12,6,0) << Insert(20,4) << Insert(27,6,0)); + + // Move,then remove + QTest::newRow("m(12-5,6),r(12,6)") + << (SignalList() << Move(12,5,6) << Remove(12,6)) + << (SignalList() << Remove(6,6) << Remove(6,6,0) << Insert(5,6,0)); + QTest::newRow("m(12-5,6),r(10,4)") + << (SignalList() << Move(12,5,6) << Remove(10,4)) + << (SignalList() << Remove(5,3) << Remove(9,5,0) << Remove(9,1) << Insert(5,5,0)); + QTest::newRow("m(12-5,6),r(16,4)") + << (SignalList() << Move(12,5,6) << Remove(16,4)) + << (SignalList() << Remove(10,2) << Remove(10,6,0) << Remove(10,2) << Insert(5,6,0)); + QTest::newRow("m(12-5,6),r(13,4)") + << (SignalList() << Move(12,5,6) << Remove(13,4)) + << (SignalList() << Remove(7,4) << Remove(8,6,0) << Insert(5,6,0)); + QTest::newRow("m(12-5,6),r(14,4)") + << (SignalList() << Move(12,5,6) << Remove(14,4)) + << (SignalList() << Remove(8,4) << Remove(8,6,0) << Insert(5,6,0)); + QTest::newRow("m(12-5,6),r(12,4)") + << (SignalList() << Move(12,5,6) << Remove(12,4)) + << (SignalList() << Remove(6,4) << Remove(8,6,0) << Insert(5,6,0)); + QTest::newRow("m(12-5,6),r(11,8)") + << (SignalList() << Move(12,5,6) << Remove(11,8)) + << (SignalList() << Remove(5,7) << Remove(5,6,0) << Remove(5,1) << Insert(5,6,0)); + QTest::newRow("m(12-5,6),r(8,4)") + << (SignalList() << Move(12,5,6) << Remove(8,4)) + << (SignalList() << Remove(5,1) << Remove(11,3,0) << Remove(11,3) << Insert(5,3,0)); + QTest::newRow("m(12-5,6),r(2,4)") + << (SignalList() << Move(12,5,6) << Remove(2,4)) + << (SignalList() << Remove(2,3) << Remove(9,1) << Remove(9,5,0) << Insert(2,5,0)); + QTest::newRow("m(12-5,6),r(6,4)") + << (SignalList() << Move(12,5,6) << Remove(6,4)) + << (SignalList() << Remove(12,1,0) << Remove(12,4) << Remove(12,1,1) << Insert(5,1,0) << Insert(6,1,1)); + QTest::newRow("m(12-5,6),r(18,4)") + << (SignalList() << Move(12,5,6) << Remove(18,4)) + << (SignalList() << Remove(12,6,0) << Remove(12,4) << Insert(5,6,0)); + QTest::newRow("m(12-5,6),r(20,4)") + << (SignalList() << Move(12,5,6) << Remove(20,4)) + << (SignalList() << Remove(12,6,0) << Remove(14,4) << Insert(5,6,0)); + + QTest::newRow("m(12-23,6),r(12,6)") + << (SignalList() << Move(12,23,6) << Remove(12,6)) + << (SignalList() << Remove(12,6,0) << Remove(12,6) << Insert(17,6,0)); + QTest::newRow("m(12-23,6),r(10,4)") + << (SignalList() << Move(12,23,6) << Remove(10,4)) + << (SignalList() << Remove(10,2) << Remove(10,6,0) << Remove(10,2) << Insert(19,6,0)); + QTest::newRow("m(12-23,6),r(16,4)") + << (SignalList() << Move(12,23,6) << Remove(16,4)) + << (SignalList() << Remove(12,6,0) << Remove(16,4) << Insert(19,6,0)); + QTest::newRow("m(12-23,6),r(13,4)") + << (SignalList() << Move(12,23,6) << Remove(13,4)) + << (SignalList() << Remove(12,6,0) << Remove(13,4) << Insert(19,6,0)); + QTest::newRow("m(12-23,6),r(14,4)") + << (SignalList() << Move(12,23,6) << Remove(14,4)) + << (SignalList() << Remove(12,6,0) << Remove(14,4) << Insert(19,6,0)); + QTest::newRow("m(12-23,6),r(12,4)") + << (SignalList() << Move(12,23,6) << Remove(12,4)) + << (SignalList() << Remove(12,6,0) << Remove(12,4) << Insert(19,6,0)); + QTest::newRow("m(12-23,6),r(11,8)") + << (SignalList() << Move(12,23,6) << Remove(11,8)) + << (SignalList() << Remove(11,1) << Remove(11,6,0) << Remove(11,7) << Insert(15,6,0)); + QTest::newRow("m(12-23,6),r(8,4)") + << (SignalList() << Move(12,23,6) << Remove(8,4)) + << (SignalList() << Remove(8,4) << Remove(8,6,0) << Insert(19,6,0)); + QTest::newRow("m(12-23,6),r(2,4)") + << (SignalList() << Move(12,23,6) << Remove(2,4)) + << (SignalList() << Remove(2,4) << Remove(8,6,0) << Insert(19,6,0)); + QTest::newRow("m(12-23,6),r(18,4)") + << (SignalList() << Move(12,23,6) << Remove(18,4)) + << (SignalList() << Remove(12,6,0) << Remove(18,4) << Insert(19,6,0)); + QTest::newRow("m(12-23,6),r(20,4)") + << (SignalList() << Move(12,23,6) << Remove(20,4)) + << (SignalList() << Remove(12,1) << Remove(12,5,0) << Remove(20,3) << Insert(20,5,0)); + + + // Complex + QTest::newRow("r(15,1),r(22,1)") + << (SignalList() << Remove(15,1) << Remove(22,1)) + << (SignalList() << Remove(15,1) << Remove(22,1)); + QTest::newRow("r(15,1),r(22,1),r(25,1)") + << (SignalList() << Remove(15,1) << Remove(22,1) << Remove(25,1)) + << (SignalList() << Remove(15,1) << Remove(22,1) << Remove(25,1)); + QTest::newRow("r(15,1),r(22,1),r(25,1),r(15,1)") + << (SignalList() << Remove(15,1) << Remove(22,1) << Remove(25,1) << Remove(15,1)) + << (SignalList() << Remove(15,2) << Remove(21,1) << Remove(24,1)); + QTest::newRow("r(15,1),r(22,1),r(25,1),r(15,1),r(13,1)") + << (SignalList() << Remove(15,1) << Remove(22,1) << Remove(25,1) << Remove(15,1) << Remove(13,1)) + << (SignalList() << Remove(13,1) << Remove(14,2) << Remove(20,1) << Remove(23,1)); + QTest::newRow("r(15,1),r(22,1),r(25,1),r(15,1),r(13,1),r(13,1)") + << (SignalList() << Remove(15,1) << Remove(22,1) << Remove(25,1) << Remove(15,1) << Remove(13,1) << Remove(13,1)) + << (SignalList() << Remove(13,4) << Remove(19,1) << Remove(22,1)); + QTest::newRow("r(15,1),r(22,1),r(25,1),r(15,1),r(13,1),r(13,1),m(12,13,1)") + << (SignalList() << Remove(15,1) << Remove(22,1) << Remove(25,1) << Remove(15,1) << Remove(13,1) << Remove(13,1) << Move(12,13,1)) + << (SignalList() << Remove(12,1,0) << Remove(12,4) << Remove(18,1) << Remove(21,1) << Insert(13,1,0)); + +} + +void tst_qquickchangeset::sequence() +{ + QFETCH(SignalList, input); + QFETCH(SignalList, output); + + QQuickChangeSet set; + + foreach (const Signal &signal, input) { + if (signal.isRemove()) + set.remove(signal.index, signal.count); + else if (signal.isInsert()) + set.insert(signal.index, signal.count); + else if (signal.isMove()) + set.move(signal.index, signal.to, signal.count); + else if (signal.isChange()) + set.change(signal.index, signal.count); + } + + SignalList changes; + foreach (const QQuickChangeSet::Remove &remove, set.removes()) + changes << Remove(remove.index, remove.count, remove.moveId); + foreach (const QQuickChangeSet::Insert &insert, set.inserts()) + changes << Insert(insert.index, insert.count, insert.moveId); + foreach (const QQuickChangeSet::Change &change, set.changes()) + changes << Change(change.index, change.count); + +#ifdef VERIFY_EXPECTED_OUTPUT + QVector list; + for (int i = 0; i < 40; ++i) + list.append(i); + QVector inputList = applyChanges(list, input); + QVector outputList = applyChanges(list, output); + if (outputList != inputList /* || changes != output*/) { + qDebug() << input; + qDebug() << output; + qDebug() << changes; + qDebug() << inputList; + qDebug() << outputList; + } else if (changes != output) { + qDebug() << output; + qDebug() << changes; + } + QCOMPARE(outputList, inputList); +#else + + if (changes != output) { + qDebug() << output; + qDebug() << changes; + } + +#endif + + QCOMPARE(changes, output); +} + + +QTEST_MAIN(tst_qquickchangeset) + +#include "tst_qquickchangeset.moc" diff --git a/tests/auto/qml/qquickconnection/data/connection-targetchange.qml b/tests/auto/qml/qquickconnection/data/connection-targetchange.qml new file mode 100644 index 0000000000..154c309c9c --- /dev/null +++ b/tests/auto/qml/qquickconnection/data/connection-targetchange.qml @@ -0,0 +1,25 @@ +import QtQuick 2.0 + +Item { + Component { + id: item1 + Item { + objectName: "item1" + } + } + Component { + id: item2 + Item { + objectName: "item2" + } + } + Loader { + id: loader + sourceComponent: item1 + } + Connections { + objectName: "connections" + target: loader.item + onWidthChanged: loader.sourceComponent = item2 + } +} diff --git a/tests/auto/qml/qquickconnection/data/connection-unknownsignals-ignored.qml b/tests/auto/qml/qquickconnection/data/connection-unknownsignals-ignored.qml new file mode 100644 index 0000000000..05d06bda94 --- /dev/null +++ b/tests/auto/qml/qquickconnection/data/connection-unknownsignals-ignored.qml @@ -0,0 +1,8 @@ +import QtQuick 2.0 + +Item { + id: screen + + Connections { target: screen; onNotFooBar1: {} ignoreUnknownSignals: true } + Connections { objectName: "connections"; onNotFooBar2: {} ignoreUnknownSignals: true } +} diff --git a/tests/auto/qml/qquickconnection/data/connection-unknownsignals-notarget.qml b/tests/auto/qml/qquickconnection/data/connection-unknownsignals-notarget.qml new file mode 100644 index 0000000000..9d25cba649 --- /dev/null +++ b/tests/auto/qml/qquickconnection/data/connection-unknownsignals-notarget.qml @@ -0,0 +1,7 @@ +import QtQuick 2.0 + +Item { + id: screen + + Connections { objectName: "connections"; target: null; onNotFooBar: {} } +} diff --git a/tests/auto/qml/qquickconnection/data/connection-unknownsignals-parent.qml b/tests/auto/qml/qquickconnection/data/connection-unknownsignals-parent.qml new file mode 100644 index 0000000000..bcd281256f --- /dev/null +++ b/tests/auto/qml/qquickconnection/data/connection-unknownsignals-parent.qml @@ -0,0 +1,7 @@ +import QtQuick 2.0 + +Item { + id: screen + + Connections { objectName: "connections"; onFooBar: {} } +} diff --git a/tests/auto/qml/qquickconnection/data/connection-unknownsignals.qml b/tests/auto/qml/qquickconnection/data/connection-unknownsignals.qml new file mode 100644 index 0000000000..ad8d4d91a8 --- /dev/null +++ b/tests/auto/qml/qquickconnection/data/connection-unknownsignals.qml @@ -0,0 +1,7 @@ +import QtQuick 2.0 + +Item { + id: screen + + Connections { objectName: "connections"; target: screen; onFooBar: {} } +} diff --git a/tests/auto/qml/qquickconnection/data/error-object.qml b/tests/auto/qml/qquickconnection/data/error-object.qml new file mode 100644 index 0000000000..256b2626a7 --- /dev/null +++ b/tests/auto/qml/qquickconnection/data/error-object.qml @@ -0,0 +1,7 @@ +import QtQuick 2.0 + +Item { + Connections { + onClicked: Item {} + } +} diff --git a/tests/auto/qml/qquickconnection/data/error-property.qml b/tests/auto/qml/qquickconnection/data/error-property.qml new file mode 100644 index 0000000000..a602479783 --- /dev/null +++ b/tests/auto/qml/qquickconnection/data/error-property.qml @@ -0,0 +1,5 @@ +import QtQuick 2.0 + +Item { + Connections { fakeProperty: {} } +} diff --git a/tests/auto/qml/qquickconnection/data/error-property2.qml b/tests/auto/qml/qquickconnection/data/error-property2.qml new file mode 100644 index 0000000000..8123afe707 --- /dev/null +++ b/tests/auto/qml/qquickconnection/data/error-property2.qml @@ -0,0 +1,5 @@ +import QtQuick 2.0 + +Item { + Connections { onfakeProperty: {} } +} diff --git a/tests/auto/qml/qquickconnection/data/error-syntax.qml b/tests/auto/qml/qquickconnection/data/error-syntax.qml new file mode 100644 index 0000000000..16c0534b68 --- /dev/null +++ b/tests/auto/qml/qquickconnection/data/error-syntax.qml @@ -0,0 +1,9 @@ +import QtQuick 2.0 + +Item { + Connections { + onClicked { + onPressed: {} + } + } +} diff --git a/tests/auto/qml/qquickconnection/data/moduleapi-target.qml b/tests/auto/qml/qquickconnection/data/moduleapi-target.qml new file mode 100644 index 0000000000..8803f24542 --- /dev/null +++ b/tests/auto/qml/qquickconnection/data/moduleapi-target.qml @@ -0,0 +1,22 @@ +import QtQuick 2.0 +import MyTestModuleApi 1.0 as MyTestModuleApi + +Item { + id: rootObject + objectName: "rootObject" + property int newIntPropValue: 12 + + property int moduleIntPropChangedCount: 0 + property int moduleOtherSignalCount: 0 + + function setModuleIntProp() { + MyTestModuleApi.intProp = newIntPropValue; + newIntPropValue = newIntPropValue + 1; + } + + Connections { + target: MyTestModuleApi + onIntPropChanged: moduleIntPropChangedCount = moduleIntPropChangedCount + 1; + onOtherSignal: moduleOtherSignalCount = moduleOtherSignalCount + 1; + } +} diff --git a/tests/auto/qml/qquickconnection/data/test-connection.qml b/tests/auto/qml/qquickconnection/data/test-connection.qml new file mode 100644 index 0000000000..ce851fc3db --- /dev/null +++ b/tests/auto/qml/qquickconnection/data/test-connection.qml @@ -0,0 +1,10 @@ +import QtQuick 2.0 + +Item { + id: screen; width: 50 + + property bool tested: false + signal testMe + + Connections { target: screen; onWidthChanged: screen.tested = true } +} diff --git a/tests/auto/qml/qquickconnection/data/test-connection2.qml b/tests/auto/qml/qquickconnection/data/test-connection2.qml new file mode 100644 index 0000000000..b23d2fc145 --- /dev/null +++ b/tests/auto/qml/qquickconnection/data/test-connection2.qml @@ -0,0 +1,3 @@ +import QtQuick 2.0 + +Connections { id: connection; target: connection; onTargetChanged: 1 == 1 } diff --git a/tests/auto/qml/qquickconnection/data/test-connection3.qml b/tests/auto/qml/qquickconnection/data/test-connection3.qml new file mode 100644 index 0000000000..9e88f0ff8f --- /dev/null +++ b/tests/auto/qml/qquickconnection/data/test-connection3.qml @@ -0,0 +1,3 @@ +import QtQuick 2.0 + +Connections {} diff --git a/tests/auto/qml/qquickconnection/data/trimming.qml b/tests/auto/qml/qquickconnection/data/trimming.qml new file mode 100644 index 0000000000..6692050deb --- /dev/null +++ b/tests/auto/qml/qquickconnection/data/trimming.qml @@ -0,0 +1,10 @@ +import QtQuick 2.0 + +Item { + id: screen; width: 50 + + property string tested + signal testMe(int param1, string param2) + + Connections { target: screen; onTestMe: screen.tested = param2 + param1 } +} diff --git a/tests/auto/qml/qquickconnection/qquickconnection.pro b/tests/auto/qml/qquickconnection/qquickconnection.pro new file mode 100644 index 0000000000..bea1f1df00 --- /dev/null +++ b/tests/auto/qml/qquickconnection/qquickconnection.pro @@ -0,0 +1,15 @@ +CONFIG += testcase +TARGET = tst_qquickconnection +macx:CONFIG -= app_bundle + +SOURCES += tst_qquickconnection.cpp + +include (../../shared/util.pri) + +testDataFiles.files = data +testDataFiles.path = . +DEPLOYMENT += testDataFiles + +CONFIG += parallel_test + +QT += core-private gui-private v8-private qml-private quick-private opengl-private testlib diff --git a/tests/auto/qml/qquickconnection/tst_qquickconnection.cpp b/tests/auto/qml/qquickconnection/tst_qquickconnection.cpp new file mode 100644 index 0000000000..ad687dd085 --- /dev/null +++ b/tests/auto/qml/qquickconnection/tst_qquickconnection.cpp @@ -0,0 +1,292 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include +#include +#include +#include +#include +#include "../../shared/util.h" +#include + +class tst_qquickconnection : public QQmlDataTest +{ + Q_OBJECT +public: + tst_qquickconnection(); + +private slots: + void defaultValues(); + void properties(); + void connection(); + void trimming(); + void targetChanged(); + void unknownSignals_data(); + void unknownSignals(); + void errors_data(); + void errors(); + void moduleApiTarget(); + +private: + QQmlEngine engine; +}; + +tst_qquickconnection::tst_qquickconnection() +{ +} + +void tst_qquickconnection::defaultValues() +{ + QQmlEngine engine; + QQmlComponent c(&engine, testFileUrl("test-connection3.qml")); + QQuickConnections *item = qobject_cast(c.create()); + + QVERIFY(item != 0); + QVERIFY(item->target() == 0); + + delete item; +} + +void tst_qquickconnection::properties() +{ + QQmlEngine engine; + QQmlComponent c(&engine, testFileUrl("test-connection2.qml")); + QQuickConnections *item = qobject_cast(c.create()); + + QVERIFY(item != 0); + + QVERIFY(item != 0); + QVERIFY(item->target() == item); + + delete item; +} + +void tst_qquickconnection::connection() +{ + QQmlEngine engine; + QQmlComponent c(&engine, testFileUrl("test-connection.qml")); + QQuickItem *item = qobject_cast(c.create()); + + QVERIFY(item != 0); + + QCOMPARE(item->property("tested").toBool(), false); + QCOMPARE(item->width(), 50.); + emit item->setWidth(100.); + QCOMPARE(item->width(), 100.); + QCOMPARE(item->property("tested").toBool(), true); + + delete item; +} + +void tst_qquickconnection::trimming() +{ + QQmlEngine engine; + QQmlComponent c(&engine, testFileUrl("trimming.qml")); + QQuickItem *item = qobject_cast(c.create()); + + QVERIFY(item != 0); + + QCOMPARE(item->property("tested").toString(), QString("")); + int index = item->metaObject()->indexOfSignal("testMe(int,QString)"); + QMetaMethod method = item->metaObject()->method(index); + method.invoke(item, + Qt::DirectConnection, + Q_ARG(int, 5), + Q_ARG(QString, "worked")); + QCOMPARE(item->property("tested").toString(), QString("worked5")); + + delete item; +} + +// Confirm that target can be changed by one of our signal handlers +void tst_qquickconnection::targetChanged() +{ + QQmlEngine engine; + QQmlComponent c(&engine, testFileUrl("connection-targetchange.qml")); + QQuickItem *item = qobject_cast(c.create()); + QVERIFY(item != 0); + + QQuickConnections *connections = item->findChild("connections"); + QVERIFY(connections); + + QQuickItem *item1 = item->findChild("item1"); + QVERIFY(item1); + + item1->setWidth(200); + + QQuickItem *item2 = item->findChild("item2"); + QVERIFY(item2); + QVERIFY(connections->target() == item2); + + // If we don't crash then we're OK + + delete item; +} + +void tst_qquickconnection::unknownSignals_data() +{ + QTest::addColumn("file"); + QTest::addColumn("error"); + + QTest::newRow("basic") << "connection-unknownsignals.qml" << ":6:5: QML Connections: Cannot assign to non-existent property \"onFooBar\""; + QTest::newRow("parent") << "connection-unknownsignals-parent.qml" << ":6:5: QML Connections: Cannot assign to non-existent property \"onFooBar\""; + QTest::newRow("ignored") << "connection-unknownsignals-ignored.qml" << ""; // should be NO error + QTest::newRow("notarget") << "connection-unknownsignals-notarget.qml" << ""; // should be NO error +} + +void tst_qquickconnection::unknownSignals() +{ + QFETCH(QString, file); + QFETCH(QString, error); + + QUrl url = testFileUrl(file); + if (!error.isEmpty()) { + QTest::ignoreMessage(QtWarningMsg, (url.toString() + error).toLatin1()); + } else { + // QTest has no way to insist no message (i.e. fail) + } + + QQmlEngine engine; + QQmlComponent c(&engine, url); + QQuickItem *item = qobject_cast(c.create()); + QVERIFY(item != 0); + + // check that connection is created (they are all runtime errors) + QQuickConnections *connections = item->findChild("connections"); + QVERIFY(connections); + + if (file == "connection-unknownsignals-ignored.qml") + QVERIFY(connections->ignoreUnknownSignals()); + + delete item; +} + +void tst_qquickconnection::errors_data() +{ + QTest::addColumn("file"); + QTest::addColumn("error"); + + QTest::newRow("no \"on\"") << "error-property.qml" << "Cannot assign to non-existent property \"fakeProperty\""; + QTest::newRow("3rd letter lowercase") << "error-property2.qml" << "Cannot assign to non-existent property \"onfakeProperty\""; + QTest::newRow("child object") << "error-object.qml" << "Connections: nested objects not allowed"; + QTest::newRow("grouped object") << "error-syntax.qml" << "Connections: syntax error"; +} + +void tst_qquickconnection::errors() +{ + QFETCH(QString, file); + QFETCH(QString, error); + + QUrl url = testFileUrl(file); + + QQmlEngine engine; + QQmlComponent c(&engine, url); + QVERIFY(c.isError() == true); + QList errors = c.errors(); + QVERIFY(errors.count() == 1); + QCOMPARE(errors.at(0).description(), error); +} + + +class MyTestModuleApi : public QObject +{ +Q_OBJECT +Q_PROPERTY(int intProp READ intProp WRITE setIntProp NOTIFY intPropChanged) + +public: + MyTestModuleApi(QObject *parent = 0) : QObject(parent), m_intProp(0), m_changeCount(0) {} + ~MyTestModuleApi() {} + + Q_INVOKABLE int otherMethod(int val) { return val + 4; } + + int intProp() const { return m_intProp; } + void setIntProp(int val) + { + if (++m_changeCount % 3 == 0) emit otherSignal(); + m_intProp = val; emit intPropChanged(); + } + +signals: + void intPropChanged(); + void otherSignal(); + +private: + int m_intProp; + int m_changeCount; +}; + +static QObject *module_api_factory(QQmlEngine *engine, QJSEngine *scriptEngine) +{ + Q_UNUSED(engine) + Q_UNUSED(scriptEngine) + MyTestModuleApi *api = new MyTestModuleApi(); + return api; +} + +// QTBUG-20937 +void tst_qquickconnection::moduleApiTarget() +{ + qmlRegisterModuleApi("MyTestModuleApi", 1, 0, module_api_factory); + QQmlComponent component(&engine, testFileUrl("moduleapi-target.qml")); + QObject *object = component.create(); + QVERIFY(object != 0); + + QCOMPARE(object->property("moduleIntPropChangedCount").toInt(), 0); + QCOMPARE(object->property("moduleOtherSignalCount").toInt(), 0); + + QMetaObject::invokeMethod(object, "setModuleIntProp"); + QCOMPARE(object->property("moduleIntPropChangedCount").toInt(), 1); + QCOMPARE(object->property("moduleOtherSignalCount").toInt(), 0); + + QMetaObject::invokeMethod(object, "setModuleIntProp"); + QCOMPARE(object->property("moduleIntPropChangedCount").toInt(), 2); + QCOMPARE(object->property("moduleOtherSignalCount").toInt(), 0); + + // the module API emits otherSignal every 3 times the int property changes. + QMetaObject::invokeMethod(object, "setModuleIntProp"); + QCOMPARE(object->property("moduleIntPropChangedCount").toInt(), 3); + QCOMPARE(object->property("moduleOtherSignalCount").toInt(), 1); + + delete object; +} + +QTEST_MAIN(tst_qquickconnection) + +#include "tst_qquickconnection.moc" diff --git a/tests/auto/qml/qquickfolderlistmodel/data/basic.qml b/tests/auto/qml/qquickfolderlistmodel/data/basic.qml new file mode 100644 index 0000000000..2c4977d08b --- /dev/null +++ b/tests/auto/qml/qquickfolderlistmodel/data/basic.qml @@ -0,0 +1,5 @@ +import Qt.labs.folderlistmodel 1.0 + +FolderListModel { + nameFilters: [ "*.qml" ] +} diff --git a/tests/auto/qml/qquickfolderlistmodel/data/dummy.qml b/tests/auto/qml/qquickfolderlistmodel/data/dummy.qml new file mode 100644 index 0000000000..609638bec6 --- /dev/null +++ b/tests/auto/qml/qquickfolderlistmodel/data/dummy.qml @@ -0,0 +1 @@ +// This file is not used, it is just content for QDirModel diff --git a/tests/auto/qml/qquickfolderlistmodel/data/resetFiltering.qml b/tests/auto/qml/qquickfolderlistmodel/data/resetFiltering.qml new file mode 100644 index 0000000000..d9a8ec4535 --- /dev/null +++ b/tests/auto/qml/qquickfolderlistmodel/data/resetFiltering.qml @@ -0,0 +1,5 @@ +import Qt.labs.folderlistmodel 1.0 + +FolderListModel { + showDirs: false +} diff --git a/tests/auto/qml/qquickfolderlistmodel/data/resetfiltering/innerdir/test2.txt b/tests/auto/qml/qquickfolderlistmodel/data/resetfiltering/innerdir/test2.txt new file mode 100644 index 0000000000..97e64bb130 --- /dev/null +++ b/tests/auto/qml/qquickfolderlistmodel/data/resetfiltering/innerdir/test2.txt @@ -0,0 +1 @@ +This file contains some text. diff --git a/tests/auto/qml/qquickfolderlistmodel/data/resetfiltering/test.txt b/tests/auto/qml/qquickfolderlistmodel/data/resetfiltering/test.txt new file mode 100644 index 0000000000..97e64bb130 --- /dev/null +++ b/tests/auto/qml/qquickfolderlistmodel/data/resetfiltering/test.txt @@ -0,0 +1 @@ +This file contains some text. diff --git a/tests/auto/qml/qquickfolderlistmodel/qquickfolderlistmodel.pro b/tests/auto/qml/qquickfolderlistmodel/qquickfolderlistmodel.pro new file mode 100644 index 0000000000..bdf4a45865 --- /dev/null +++ b/tests/auto/qml/qquickfolderlistmodel/qquickfolderlistmodel.pro @@ -0,0 +1,14 @@ +CONFIG += testcase +TARGET = tst_qquickfolderlistmodel +macx:CONFIG -= app_bundle + +SOURCES += tst_qquickfolderlistmodel.cpp + +include (../../shared/util.pri) + +testDataFiles.files = data +testDataFiles.path = . +DEPLOYMENT += testDataFiles + +CONFIG += parallel_test +QT += core-private gui-private qml-private testlib diff --git a/tests/auto/qml/qquickfolderlistmodel/tst_qquickfolderlistmodel.cpp b/tests/auto/qml/qquickfolderlistmodel/tst_qquickfolderlistmodel.cpp new file mode 100644 index 0000000000..a6d90cf688 --- /dev/null +++ b/tests/auto/qml/qquickfolderlistmodel/tst_qquickfolderlistmodel.cpp @@ -0,0 +1,179 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include +#include +#include +#include +#include +#include +#include +#include +#include "../../shared/util.h" + +// From qquickfolderlistmodel.h +const int FileNameRole = Qt::UserRole+1; +const int FilePathRole = Qt::UserRole+2; +enum SortField { Unsorted, Name, Time, Size, Type }; + +class tst_qquickfolderlistmodel : public QQmlDataTest +{ + Q_OBJECT +public: + tst_qquickfolderlistmodel() : removeStart(0), removeEnd(0) {} + +public slots: + void removed(const QModelIndex &, int start, int end) { + removeStart = start; + removeEnd = end; + } + +private slots: + void basicProperties(); + void resetFiltering(); + void refresh(); + +private: + void checkNoErrors(const QQmlComponent& component); + QQmlEngine engine; + + int removeStart; + int removeEnd; +}; + +void tst_qquickfolderlistmodel::checkNoErrors(const QQmlComponent& component) +{ + // Wait until the component is ready + QTRY_VERIFY(component.isReady() || component.isError()); + + if (component.isError()) { + QList errors = component.errors(); + for (int ii = 0; ii < errors.count(); ++ii) { + const QQmlError &error = errors.at(ii); + QByteArray errorStr = QByteArray::number(error.line()) + ":" + + QByteArray::number(error.column()) + ":" + + error.description().toUtf8(); + qWarning() << errorStr; + } + } + QVERIFY(!component.isError()); +} + +void tst_qquickfolderlistmodel::basicProperties() +{ + QQmlComponent component(&engine, testFileUrl("basic.qml")); + checkNoErrors(component); + + QAbstractListModel *flm = qobject_cast(component.create()); + QVERIFY(flm != 0); + + flm->setProperty("folder", dataDirectoryUrl()); + QTRY_COMPARE(flm->property("count").toInt(),4); // wait for refresh + QCOMPARE(flm->property("folder").toUrl(), dataDirectoryUrl()); + QCOMPARE(flm->property("parentFolder").toUrl(), QUrl::fromLocalFile(QDir(directory()).canonicalPath())); + QCOMPARE(flm->property("sortField").toInt(), int(Name)); + QCOMPARE(flm->property("nameFilters").toStringList(), QStringList() << "*.qml"); + QCOMPARE(flm->property("sortReversed").toBool(), false); + QCOMPARE(flm->property("showDirs").toBool(), true); + QCOMPARE(flm->property("showDotAndDotDot").toBool(), false); + QCOMPARE(flm->property("showOnlyReadable").toBool(), false); + QCOMPARE(flm->data(flm->index(0),FileNameRole).toString(), QLatin1String("basic.qml")); + QCOMPARE(flm->data(flm->index(1),FileNameRole).toString(), QLatin1String("dummy.qml")); + + flm->setProperty("folder",QUrl::fromLocalFile("")); + QCOMPARE(flm->property("folder").toUrl(), QUrl::fromLocalFile("")); +} + +void tst_qquickfolderlistmodel::resetFiltering() +{ + // see QTBUG-17837 + QQmlComponent component(&engine, testFileUrl("resetFiltering.qml")); + checkNoErrors(component); + + QAbstractListModel *flm = qobject_cast(component.create()); + QVERIFY(flm != 0); + + connect(flm, SIGNAL(rowsRemoved(const QModelIndex&,int,int)), + this, SLOT(removed(const QModelIndex&,int,int))); + + flm->setProperty("folder", testFileUrl("resetfiltering")); + QTRY_COMPARE(flm->property("count").toInt(),1); // should just be "test.txt" visible + int count = flm->rowCount(); + QCOMPARE(removeStart, 0); + QCOMPARE(removeEnd, count-1); + + flm->setProperty("folder", testFileUrl("resetfiltering/innerdir")); + QTRY_COMPARE(flm->property("count").toInt(),1); // should just be "test2.txt" visible + count = flm->rowCount(); + QCOMPARE(removeStart, 0); + QCOMPARE(removeEnd, count-1); + + flm->setProperty("folder", testFileUrl("resetfiltering")); + QTRY_COMPARE(flm->property("count").toInt(),1); // should just be "test.txt" visible + count = flm->rowCount(); + QCOMPARE(removeStart, 0); + QCOMPARE(removeEnd, count-1); +} + +void tst_qquickfolderlistmodel::refresh() +{ + QQmlComponent component(&engine, testFileUrl("basic.qml")); + checkNoErrors(component); + + QAbstractListModel *flm = qobject_cast(component.create()); + QVERIFY(flm != 0); + + flm->setProperty("folder", dataDirectoryUrl()); + QTRY_COMPARE(flm->property("count").toInt(),4); // wait for refresh + + int count = flm->rowCount(); + + connect(flm, SIGNAL(rowsRemoved(const QModelIndex&,int,int)), + this, SLOT(removed(const QModelIndex&,int,int))); + + flm->setProperty("sortReversed", true); + + QCOMPARE(removeStart, 0); + QCOMPARE(removeEnd, count-1); +} + +QTEST_MAIN(tst_qquickfolderlistmodel) + +#include "tst_qquickfolderlistmodel.moc" diff --git a/tests/auto/qml/qquicklistcompositor/qquicklistcompositor.pro b/tests/auto/qml/qquicklistcompositor/qquicklistcompositor.pro new file mode 100644 index 0000000000..0e7a1af4c5 --- /dev/null +++ b/tests/auto/qml/qquicklistcompositor/qquicklistcompositor.pro @@ -0,0 +1,9 @@ +CONFIG += testcase +TARGET = tst_qquicklistcompositor +macx:CONFIG -= app_bundle + +SOURCES += tst_qquicklistcompositor.cpp + +CONFIG += parallel_test + +QT += core-private gui-private qml-private quick-private testlib diff --git a/tests/auto/qml/qquicklistcompositor/tst_qquicklistcompositor.cpp b/tests/auto/qml/qquicklistcompositor/tst_qquicklistcompositor.cpp new file mode 100644 index 0000000000..a5d66661f0 --- /dev/null +++ b/tests/auto/qml/qquicklistcompositor/tst_qquicklistcompositor.cpp @@ -0,0 +1,1637 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include +#include + +template int lengthOf(const T (&)[N]) { return N; } + +typedef QQuickListCompositor C; + +struct Range +{ + Range() {} + Range(void *list, int index, int count, int flags) + : list(list), index(index), count(count), flags(flags) {} + void *list; + int index; + int count; + int flags; +}; + +template struct Array +{ + Array() : array(0), count(0) {} + template Array(const T (&array)[N]) : array(array), count(N) {} + + T operator [](int index) const { return array[index]; } + + const T *array; + int count; +}; + +typedef Array IndexArray; +typedef Array ListArray; + +typedef QVector RemoveList; +typedef QVector InsertList; +typedef QVector ChangeList; + +typedef QVector RangeList; + +Q_DECLARE_METATYPE(RangeList) +Q_DECLARE_METATYPE(RemoveList) +Q_DECLARE_METATYPE(InsertList) +Q_DECLARE_METATYPE(ChangeList) +Q_DECLARE_METATYPE(void *) +Q_DECLARE_METATYPE(IndexArray) +Q_DECLARE_METATYPE(ListArray) +Q_DECLARE_METATYPE(C::Group) + +QT_BEGIN_NAMESPACE +bool operator ==(const C::Change &left, const C::Change &right) +{ + return left.index[3] == right.index[3] + && left.index[2] == right.index[2] + && left.index[1] == right.index[1] + && left.index[0] == right.index[0] + && left.count == right.count + && left.groups() == right.groups() + && left.inCache() == right.inCache() + && (left.moveId == -1) == (right.moveId == -1); +} +QT_END_NAMESPACE + +static const C::Group Visible = C::Group(2); +static const C::Group Selection = C::Group(3); + +class tst_qquicklistcompositor : public QObject +{ + Q_OBJECT + + enum { + VisibleFlag = 0x04, + SelectionFlag = 0x08 + }; + + void populateChange( + C::Change &change, int sIndex, int vIndex, int dIndex, int cIndex, int count, int flags, int moveId) + { + change.index[Selection] = sIndex; + change.index[Visible] = vIndex; + change.index[C::Default] = dIndex; + change.index[C::Cache] = cIndex; + change.count = count; + change.flags = flags; + change.moveId = moveId; + } + + C::Remove Remove( + int sIndex, int vIndex, int dIndex, int cIndex, int count, int flags, int moveId = -1) + { + C::Remove remove; + populateChange(remove, sIndex, vIndex, dIndex, cIndex, count, flags, moveId); + return remove; + } + + C::Insert Insert( + int sIndex, int vIndex, int dIndex, int cIndex, int count, int flags, int moveId = -1) + { + C::Insert insert; + populateChange(insert, sIndex, vIndex, dIndex, cIndex, count, flags, moveId); + return insert; + } + + C::Change Change( + int sIndex, int vIndex, int dIndex, int cIndex, int count, int flags, int moveId = -1) + { + C::Change change; + populateChange(change, sIndex, vIndex, dIndex, cIndex, count, flags, moveId); + return change; + } + +private slots: + void find_data(); + void find(); + void findInsertPosition_data(); + void findInsertPosition(); + void insert(); + void clearFlags_data(); + void clearFlags(); + void setFlags_data(); + void setFlags(); + void move_data(); + void move(); + void moveFromEnd(); + void clear(); + void listItemsInserted_data(); + void listItemsInserted(); + void listItemsRemoved_data(); + void listItemsRemoved(); + void listItemsMoved_data(); + void listItemsMoved(); + void listItemsChanged_data(); + void listItemsChanged(); +}; + +void tst_qquicklistcompositor::find_data() +{ + QTest::addColumn("ranges"); + QTest::addColumn("startGroup"); + QTest::addColumn("startIndex"); + QTest::addColumn("group"); + QTest::addColumn("index"); + QTest::addColumn("selectionIndex"); + QTest::addColumn("visibleIndex"); + QTest::addColumn("defaultIndex"); + QTest::addColumn("cacheIndex"); + QTest::addColumn("rangeFlags"); + QTest::addColumn("rangeIndex"); + + int listA; void *a = &listA; + + QTest::newRow("Start") + << (RangeList() + << Range(a, 0, 1, int(C::PrependFlag | SelectionFlag | C::DefaultFlag | C::CacheFlag)) + << Range(a, 1, 1, int(C::AppendFlag | C::PrependFlag | C::CacheFlag)) + << Range(0, 0, 1, int(VisibleFlag| C::CacheFlag))) + << C::Cache << 2 + << Selection << 0 + << 0 << 0 << 0 << 0 + << uint(C::PrependFlag | SelectionFlag | C::DefaultFlag | C::CacheFlag) << 0; +} + +void tst_qquicklistcompositor::find() +{ + QFETCH(RangeList, ranges); + QFETCH(C::Group, startGroup); + QFETCH(int, startIndex); + QFETCH(C::Group, group); + QFETCH(int, index); + QFETCH(int, cacheIndex); + QFETCH(int, defaultIndex); + QFETCH(int, visibleIndex); + QFETCH(int, selectionIndex); + QFETCH(uint, rangeFlags); + QFETCH(int, rangeIndex); + + QQuickListCompositor compositor; + compositor.setGroupCount(4); + compositor.setDefaultGroups(VisibleFlag | C::DefaultFlag); + + foreach (const Range &range, ranges) + compositor.append(range.list, range.index, range.count, range.flags); + + compositor.find(startGroup, startIndex); + + QQuickListCompositor::iterator it = compositor.find(group, index); + QCOMPARE(it.index[C::Cache], cacheIndex); + QCOMPARE(it.index[C::Default], defaultIndex); + QCOMPARE(it.index[Visible], visibleIndex); + QCOMPARE(it.index[Selection], selectionIndex); + QCOMPARE(it->flags, rangeFlags); + QCOMPARE(it->index, rangeIndex); +} + +void tst_qquicklistcompositor::findInsertPosition_data() +{ + QTest::addColumn("ranges"); + QTest::addColumn("group"); + QTest::addColumn("index"); + QTest::addColumn("selectionIndex"); + QTest::addColumn("visibleIndex"); + QTest::addColumn("defaultIndex"); + QTest::addColumn("cacheIndex"); + QTest::addColumn("rangeFlags"); + QTest::addColumn("rangeIndex"); + + int listA; void *a = &listA; + + QTest::newRow("Start") + << (RangeList() + << Range(a, 0, 1, int(C::PrependFlag | SelectionFlag | C::DefaultFlag | C::CacheFlag)) + << Range(a, 1, 1, int(C::AppendFlag | C::PrependFlag | C::CacheFlag)) + << Range(0, 0, 1, int(VisibleFlag| C::CacheFlag))) + << Selection << 0 + << 0 << 0 << 0 << 0 + << uint(C::PrependFlag | SelectionFlag | C::DefaultFlag | C::CacheFlag) << 0; + QTest::newRow("1") + << (RangeList() + << Range(a, 0, 1, int(C::PrependFlag | SelectionFlag | C::DefaultFlag | C::CacheFlag)) + << Range(a, 1, 1, int(C::AppendFlag | C::PrependFlag | C::CacheFlag)) + << Range(0, 0, 1, int(VisibleFlag| C::CacheFlag))) + << Selection << 1 + << 1 << 0 << 1 << 1 + << uint(C::AppendFlag | C::PrependFlag | C::CacheFlag) << 1; +} + +void tst_qquicklistcompositor::findInsertPosition() +{ + QFETCH(RangeList, ranges); + QFETCH(C::Group, group); + QFETCH(int, index); + QFETCH(int, cacheIndex); + QFETCH(int, defaultIndex); + QFETCH(int, visibleIndex); + QFETCH(int, selectionIndex); + QFETCH(uint, rangeFlags); + QFETCH(int, rangeIndex); + + QQuickListCompositor compositor; + compositor.setGroupCount(4); + compositor.setDefaultGroups(VisibleFlag | C::DefaultFlag); + + foreach (const Range &range, ranges) + compositor.append(range.list, range.index, range.count, range.flags); + + QQuickListCompositor::insert_iterator it = compositor.findInsertPosition(group, index); + QCOMPARE(it.index[C::Cache], cacheIndex); + QCOMPARE(it.index[C::Default], defaultIndex); + QCOMPARE(it.index[Visible], visibleIndex); + QCOMPARE(it.index[Selection], selectionIndex); + QCOMPARE(it->flags, rangeFlags); + QCOMPARE(it->index, rangeIndex); +} + +void tst_qquicklistcompositor::insert() +{ + QQuickListCompositor compositor; + compositor.setGroupCount(4); + compositor.setDefaultGroups(VisibleFlag | C::DefaultFlag); + + C::iterator it; + + int listA; int *a = &listA; + int listB; int *b = &listB; + int listC; int *c = &listC; + + { + compositor.append(a, 0, 12, C::AppendFlag | C::PrependFlag | C::DefaultFlag); + const int indexes[] = {0,1,2,3,4,5,6,7,8,9,10,11}; + const int *lists[] = {a,a,a,a,a,a,a,a,a,a, a, a}; + QCOMPARE(compositor.count(C::Default), lengthOf(indexes)); + for (int i = 0; i < lengthOf(indexes); ++i) { + it = compositor.find(C::Default, i); + QCOMPARE(it.list(), lists[i]); + if (lists[i]) QCOMPARE(it.modelIndex(), indexes[i]); + } + } { + compositor.append(b, 4, 4, C::DefaultFlag); + const int indexes[] = {0,1,2,3,4,5,6,7,8,9,10,11,4,5,6,7}; + const int *lists[] = {a,a,a,a,a,a,a,a,a,a, a, a,b,b,b,b}; + QCOMPARE(compositor.count(C::Default), lengthOf(indexes)); + for (int i = 0; i < lengthOf(indexes); ++i) { + it = compositor.find(C::Default, i); + QCOMPARE(it.list(), lists[i]); + if (lists[i]) QCOMPARE(it.modelIndex(), indexes[i]); + } + } { // Insert at end. + compositor.insert( + C::Default, 16, c, 2, 2, C::DefaultFlag); + const int indexes[] = {0,1,2,3,4,5,6,7,8,9,10,11,4,5,6,7,2,3}; + const int *lists[] = {a,a,a,a,a,a,a,a,a,a, a, a,b,b,b,b,c,c}; + QCOMPARE(compositor.count(C::Default), lengthOf(indexes)); + for (int i = 0; i < lengthOf(indexes); ++i) { + it = compositor.find(C::Default, i); + QCOMPARE(it.list(), lists[i]); + if (lists[i]) QCOMPARE(it.modelIndex(), indexes[i]); + } + } { // Insert at start + compositor.insert( + C::Default, 0, c, 6, 4, C::DefaultFlag); + const int indexes[] = {6,7,8,9,0,1,2,3,4,5,6,7,8,9,10,11,4,5,6,7,2,3}; + const int *lists[] = {c,c,c,c,a,a,a,a,a,a,a,a,a,a, a, a,b,b,b,b,c,c}; + QCOMPARE(compositor.count(C::Default), lengthOf(indexes)); + for (int i = 0; i < lengthOf(indexes); ++i) { + it = compositor.find(C::Default, i); + QCOMPARE(it.list(), lists[i]); + if (lists[i]) QCOMPARE(it.modelIndex(), indexes[i]); + } + } { // Insert after static range. + compositor.insert( + C::Default, 4, b, 0, 8, C::AppendFlag | C::PrependFlag | C::DefaultFlag); + const int indexes[] = {6,7,8,9,0,1,2,3,4,5,6,7,0,1,2,3,4,5,6,7,8,9,10,11,4,5,6,7,2,3}; + const int *lists[] = {c,c,c,c,b,b,b,b,b,b,b,b,a,a,a,a,a,a,a,a,a,a, a, a,b,b,b,b,c,c}; + QCOMPARE(compositor.count(C::Default), lengthOf(indexes)); + for (int i = 0; i < lengthOf(indexes); ++i) { + it = compositor.find(C::Default, i); + QCOMPARE(it.list(), lists[i]); + if (lists[i]) QCOMPARE(it.modelIndex(), indexes[i]); + } + } { // Insert at end of dynamic range. + compositor.insert( + C::Default, 12, c, 0, 4, C::AppendFlag | C::PrependFlag | C::DefaultFlag); + const int indexes[] = {6,7,8,9,0,1,2,3,4,5,6,7,0,1,2,3,0,1,2,3,4,5,6,7,8,9,10,11,4,5,6,7,2,3}; + const int *lists[] = {c,c,c,c,b,b,b,b,b,b,b,b,c,c,c,c,a,a,a,a,a,a,a,a,a,a, a, a,b,b,b,b,c,c}; + QCOMPARE(compositor.count(C::Default), lengthOf(indexes)); + for (int i = 0; i < lengthOf(indexes); ++i) { + it = compositor.find(C::Default, i); + QCOMPARE(it.list(), lists[i]); + if (lists[i]) QCOMPARE(it.modelIndex(), indexes[i]); + } + } { // Insert into range. + compositor.insert( + C::Default, 8, c, 0, 4, C::AppendFlag | C::PrependFlag | C::DefaultFlag); + const int indexes[] = {6,7,8,9,0,1,2,3,0,1,2,3,4,5,6,7,0,1,2,3,0,1,2,3,4,5,6,7,8,9,10,11,4,5,6,7,2,3}; + const int *lists[] = {c,c,c,c,b,b,b,b,c,c,c,c,b,b,b,b,c,c,c,c,a,a,a,a,a,a,a,a,a,a, a, a,b,b,b,b,c,c}; + QCOMPARE(compositor.count(C::Default), lengthOf(indexes)); + for (int i = 0; i < lengthOf(indexes); ++i) { + it = compositor.find(C::Default, i); + QCOMPARE(it.list(), lists[i]); + if (lists[i]) QCOMPARE(it.modelIndex(), indexes[i]); + } + } +} + +void tst_qquicklistcompositor::clearFlags_data() +{ + QTest::addColumn("ranges"); + QTest::addColumn("group"); + QTest::addColumn("index"); + QTest::addColumn("count"); + QTest::addColumn("flags"); + QTest::addColumn("expectedRemoves"); + QTest::addColumn("cacheIndexes"); + QTest::addColumn("cacheLists"); + QTest::addColumn("defaultIndexes"); + QTest::addColumn("defaultLists"); + QTest::addColumn("visibleIndexes"); + QTest::addColumn("visibleLists"); + QTest::addColumn("selectionIndexes"); + QTest::addColumn("selectionLists"); + + int listA; void *a = &listA; + + { static const int cacheIndexes[] = {0,1,2,3,4,5,6,7,8,9,10,11,0,0,0,0}; + static const void *cacheLists[] = {a,a,a,a,a,a,a,a,a,a, a, a,0,0,0,0}; + static const int defaultIndexes[] = {0,1,2,3,4,5,6,7,8,9,10,11,0,0,0,0}; + static const void *defaultLists[] = {a,a,a,a,a,a,a,a,a,a, a, a,0,0,0,0}; + static const int visibleIndexes[] = {0,1,2,3,4,5,6,7,8,9,10,11,0,0,0,0}; + static const void *visibleLists[] = {a,a,a,a,a,a,a,a,a,a, a, a,0,0,0,0}; + static const int selectionIndexes[] = {0,1,4,5,6,7,8,9,10,11,0,0,0,0}; + static const void *selectionLists[] = {a,a,a,a,a,a,a,a, a, a,0,0,0,0}; + QTest::newRow("Default, 2, 2, Selection") + << (RangeList() + << Range(a, 0, 12, int(C::AppendFlag | C::PrependFlag | SelectionFlag | VisibleFlag | C::DefaultFlag | C::CacheFlag)) + << Range(0, 0, 4, int(SelectionFlag | VisibleFlag | C::DefaultFlag | C::CacheFlag))) + << C::Default << 2 << 2 << int(SelectionFlag) + << (RemoveList() + << Remove(2, 2, 2, 2, 2, SelectionFlag | C::CacheFlag)) + << IndexArray(cacheIndexes) << ListArray(cacheLists) + << IndexArray(defaultIndexes) << ListArray(defaultLists) + << IndexArray(visibleIndexes) << ListArray(visibleLists) + << IndexArray(selectionIndexes) << ListArray(selectionLists); + } { static const int cacheIndexes[] = {0,1,2,3,4,5,6,7,8,9,10,11,0,0,0,0}; + static const void *cacheLists[] = {a,a,a,a,a,a,a,a,a,a, a, a,0,0,0,0}; + static const int defaultIndexes[] = {0,1,2,3,4,5,6,7,8,9,10,11,0,0,0,0}; + static const void *defaultLists[] = {a,a,a,a,a,a,a,a,a,a, a, a,0,0,0,0}; + static const int visibleIndexes[] = {0,2,3,5,6,7,8,9,10,11,0,0,0,0}; + static const void *visibleLists[] = {a,a,a,a,a,a,a,a, a, a,0,0,0,0}; + static const int selectionIndexes[] = {0,1,4,5,6,7,8,9,10,11,0,0,0,0}; + static const void *selectionLists[] = {a,a,a,a,a,a,a,a, a, a,0,0,0,0}; + QTest::newRow("Selection, 1, 2, Visible") + << (RangeList() + << Range(a, 0, 2, int(C::PrependFlag | SelectionFlag | VisibleFlag | C::DefaultFlag | C::CacheFlag)) + << Range(a, 2, 2, int(C::PrependFlag | VisibleFlag | C::DefaultFlag | C::CacheFlag)) + << Range(a, 4, 8, int(C::AppendFlag | C::PrependFlag | SelectionFlag | VisibleFlag | C::DefaultFlag | C::CacheFlag)) + << Range(0, 0, 4, int(SelectionFlag | VisibleFlag | C::DefaultFlag | C::CacheFlag))) + << Selection << 1 << 2 << int(VisibleFlag) + << (RemoveList() + << Remove(1, 1, 1, 1, 1, VisibleFlag | C::CacheFlag) + << Remove(2, 3, 4, 4, 1, VisibleFlag | C::CacheFlag)) + << IndexArray(cacheIndexes) << ListArray(cacheLists) + << IndexArray(defaultIndexes) << ListArray(defaultLists) + << IndexArray(visibleIndexes) << ListArray(visibleLists) + << IndexArray(selectionIndexes) << ListArray(selectionLists); + } { static const int cacheIndexes[] = {0,1,2,3,4,5,6,7,8,9,10,11,0,0,0,0}; + static const void *cacheLists[] = {a,a,a,a,a,a,a,a,a,a, a, a,0,0,0,0}; + static const int defaultIndexes[] = {0,1,2,3,4,5,6,7,8,9,10,11,0,0,0}; + static const void *defaultLists[] = {a,a,a,a,a,a,a,a,a,a, a, a,0,0,0}; + static const int visibleIndexes[] = {0,2,3,5,6,7,8,9,10,11,0,0,0}; + static const void *visibleLists[] = {a,a,a,a,a,a,a,a, a, a,0,0,0}; + static const int selectionIndexes[] = {0,1,4,5,6,7,8,9,10,11,0,0,0}; + static const void *selectionLists[] = {a,a,a,a,a,a,a,a, a, a,0,0,0}; + QTest::newRow("Default, 13, 1, Prepend | Selection | Visible | Default") + << (RangeList() + << Range(a, 0, 1, int(C::PrependFlag | SelectionFlag | VisibleFlag | C::DefaultFlag | C::CacheFlag)) + << Range(a, 1, 1, int(C::PrependFlag | SelectionFlag | C::DefaultFlag | C::CacheFlag)) + << Range(a, 2, 2, int(C::PrependFlag | VisibleFlag | C::DefaultFlag | C::CacheFlag)) + << Range(a, 4, 1, int(C::PrependFlag | SelectionFlag | C::DefaultFlag | C::CacheFlag)) + << Range(a, 5, 7, int(C::AppendFlag | C::PrependFlag | SelectionFlag | VisibleFlag | C::DefaultFlag | C::CacheFlag)) + << Range(0, 0, 4, int(SelectionFlag | VisibleFlag | C::DefaultFlag | C::CacheFlag))) + << C::Default << 13 << 1 << int(C::PrependFlag | SelectionFlag | VisibleFlag | C::DefaultFlag) + << (RemoveList() + << Remove(11, 11, 13, 13, 1, SelectionFlag | VisibleFlag | C::DefaultFlag | C::CacheFlag)) + << IndexArray(cacheIndexes) << ListArray(cacheLists) + << IndexArray(defaultIndexes) << ListArray(defaultLists) + << IndexArray(visibleIndexes) << ListArray(visibleLists) + << IndexArray(selectionIndexes) << ListArray(selectionLists); + } { static const int cacheIndexes[] = {0,1,2,3,4,5,6,7,8,9,10,0}; + static const void *cacheLists[] = {a,a,a,a,a,a,a,a,a,a, a,0}; + static const int defaultIndexes[] = {0,1,2,3,4,5,6,7,8,9,10,11,0,0,0}; + static const void *defaultLists[] = {a,a,a,a,a,a,a,a,a,a, a, a,0,0,0}; + static const int visibleIndexes[] = {0,2,3,5,6,7,8,9,10,11,0,0,0}; + static const void *visibleLists[] = {a,a,a,a,a,a,a,a, a, a,0,0,0}; + static const int selectionIndexes[] = {0,1,4,5,6,7,8,9,10,11,0,0,0}; + static const void *selectionLists[] = {a,a,a,a,a,a,a,a, a, a,0,0,0}; + QTest::newRow("Cache, 11, 4, Cache") + << (RangeList() + << Range(a, 0, 1, int(C::PrependFlag | SelectionFlag | VisibleFlag | C::DefaultFlag | C::CacheFlag)) + << Range(a, 1, 1, int(C::PrependFlag | SelectionFlag | C::DefaultFlag | C::CacheFlag)) + << Range(a, 2, 2, int(C::PrependFlag | VisibleFlag | C::DefaultFlag | C::CacheFlag)) + << Range(a, 4, 1, int(C::PrependFlag | SelectionFlag | C::DefaultFlag | C::CacheFlag)) + << Range(a, 5, 7, int(C::AppendFlag | C::PrependFlag | SelectionFlag | VisibleFlag | C::DefaultFlag | C::CacheFlag)) + << Range(0, 0, 1, int(C::CacheFlag)) + << Range(0, 0, 3, int(SelectionFlag | VisibleFlag | C::DefaultFlag | C::CacheFlag))) + << C::Cache << 11 << 4 << int(C::CacheFlag) + << (RemoveList()) + << IndexArray(cacheIndexes) << ListArray(cacheLists) + << IndexArray(defaultIndexes) << ListArray(defaultLists) + << IndexArray(visibleIndexes) << ListArray(visibleLists) + << IndexArray(selectionIndexes) << ListArray(selectionLists); + } { static const int cacheIndexes[] = {0,1,2,3,4,5,6,7,8,9,10,0}; + static const void *cacheLists[] = {a,a,a,a,a,a,a,a,a,a, a,0}; + static const int defaultIndexes[] = {0,1,2,3,4,5,6,7,8,9,10,0}; + static const void *defaultLists[] = {a,a,a,a,a,a,a,a,a,a, a,0}; + static const int visibleIndexes[] = {0,2,3,5,6,7,8,9,10,0}; + static const void *visibleLists[] = {a,a,a,a,a,a,a,a, a,0}; + static const int selectionIndexes[] = {0,1,4,5,6,7,8,9,10,0}; + static const void *selectionLists[] = {a,a,a,a,a,a,a,a, a,0}; + QTest::newRow("Default, 11, 3, Default | Visible | Selection") + << (RangeList() + << Range(a, 0, 1, int(C::PrependFlag | SelectionFlag | VisibleFlag | C::DefaultFlag | C::CacheFlag)) + << Range(a, 1, 1, int(C::PrependFlag | SelectionFlag | C::DefaultFlag | C::CacheFlag)) + << Range(a, 2, 2, int(C::PrependFlag | VisibleFlag | C::DefaultFlag | C::CacheFlag)) + << Range(a, 4, 1, int(C::PrependFlag | SelectionFlag | C::DefaultFlag | C::CacheFlag)) + << Range(a, 5, 6, int(C::PrependFlag | SelectionFlag | VisibleFlag | C::DefaultFlag | C::CacheFlag)) + << Range(a, 11, 1, int(C::AppendFlag | C::PrependFlag | SelectionFlag | VisibleFlag | C::DefaultFlag)) + << Range(0, 0, 2, int(SelectionFlag | VisibleFlag | C::DefaultFlag)) + << Range(0, 0, 1, int(SelectionFlag | VisibleFlag | C::DefaultFlag | C::CacheFlag))) + << C::Default << 11 << 3 << int(C::DefaultFlag | VisibleFlag| SelectionFlag) + << (RemoveList() + << Remove(9, 9, 11, 11, 1, SelectionFlag | VisibleFlag | C::DefaultFlag) + << Remove(9, 9, 11, 11, 2, SelectionFlag | VisibleFlag | C::DefaultFlag)) + << IndexArray(cacheIndexes) << ListArray(cacheLists) + << IndexArray(defaultIndexes) << ListArray(defaultLists) + << IndexArray(visibleIndexes) << ListArray(visibleLists) + << IndexArray(selectionIndexes) << ListArray(selectionLists); + } +} + +void tst_qquicklistcompositor::clearFlags() +{ + QFETCH(RangeList, ranges); + QFETCH(C::Group, group); + QFETCH(int, index); + QFETCH(int, count); + QFETCH(int, flags); + QFETCH(RemoveList, expectedRemoves); + QFETCH(IndexArray, cacheIndexes); + QFETCH(ListArray, cacheLists); + QFETCH(IndexArray, defaultIndexes); + QFETCH(ListArray, defaultLists); + QFETCH(IndexArray, visibleIndexes); + QFETCH(ListArray, visibleLists); + QFETCH(IndexArray, selectionIndexes); + QFETCH(ListArray, selectionLists); + + QQuickListCompositor compositor; + compositor.setGroupCount(4); + compositor.setDefaultGroups(VisibleFlag | C::DefaultFlag); + + foreach (const Range &range, ranges) + compositor.append(range.list, range.index, range.count, range.flags); + + QVector removes; + compositor.clearFlags(group, index, count, flags, &removes); + + QCOMPARE(removes, expectedRemoves); + + QCOMPARE(compositor.count(C::Cache), cacheIndexes.count); + for (int i = 0; i < cacheIndexes.count; ++i) { + C::iterator it = compositor.find(C::Cache, i); + QCOMPARE(it->list, cacheLists[i]); + if (cacheLists[i]) + QCOMPARE(it.modelIndex(), cacheIndexes[i]); + } + QCOMPARE(compositor.count(C::Default), defaultIndexes.count); + for (int i = 0; i < defaultIndexes.count; ++i) { + C::iterator it = compositor.find(C::Default, i); + QCOMPARE(it->list, defaultLists[i]); + if (defaultLists[i]) + QCOMPARE(it.modelIndex(), defaultIndexes[i]); + } + QCOMPARE(compositor.count(Visible), visibleIndexes.count); + for (int i = 0; i < visibleIndexes.count; ++i) { + C::iterator it = compositor.find(Visible, i); + QCOMPARE(it->list, visibleLists[i]); + if (visibleLists[i]) + QCOMPARE(it.modelIndex(), visibleIndexes[i]); + } + QCOMPARE(compositor.count(Selection), selectionIndexes.count); + for (int i = 0; i < selectionIndexes.count; ++i) { + C::iterator it = compositor.find(Selection, i); + QCOMPARE(it->list, selectionLists[i]); + if (selectionLists[i]) + QCOMPARE(it.modelIndex(), selectionIndexes[i]); + } +} + +void tst_qquicklistcompositor::setFlags_data() +{ + QTest::addColumn("ranges"); + QTest::addColumn("group"); + QTest::addColumn("index"); + QTest::addColumn("count"); + QTest::addColumn("flags"); + QTest::addColumn("expectedInserts"); + QTest::addColumn("cacheIndexes"); + QTest::addColumn("cacheLists"); + QTest::addColumn("defaultIndexes"); + QTest::addColumn("defaultLists"); + QTest::addColumn("visibleIndexes"); + QTest::addColumn("visibleLists"); + QTest::addColumn("selectionIndexes"); + QTest::addColumn("selectionLists"); + + int listA; void *a = &listA; + + { static const int cacheIndexes[] = {0,0,0,0}; + static const void *cacheLists[] = {0,0,0,0}; + static const int defaultIndexes[] = {0,1,2,3,4,5,6,7,8,9,10,11}; + static const void *defaultLists[] = {a,a,a,a,a,a,a,a,a,a, a, a}; + QTest::newRow("Default, 2, 2, Default") + << (RangeList() + << Range(a, 0, 12, C::DefaultFlag) + << Range(0, 0, 4, C::CacheFlag)) + << C::Default << 2 << 2 << int(C::DefaultFlag) + << (InsertList()) + << IndexArray(cacheIndexes) << ListArray(cacheLists) + << IndexArray(defaultIndexes) << ListArray(defaultLists) + << IndexArray() << ListArray() + << IndexArray() << ListArray(); + } { static const int cacheIndexes[] = {0,0,0,0}; + static const void *cacheLists[] = {0,0,0,0}; + static const int defaultIndexes[] = {0,1,2,3,4,5,6,7,8,9,10,11}; + static const void *defaultLists[] = {a,a,a,a,a,a,a,a,a,a, a, a}; + static const int visibleIndexes[] = {2,3}; + static const void *visibleLists[] = {a,a}; + QTest::newRow("Default, 2, 2, Visible") + << (RangeList() + << Range(a, 0, 12, C::DefaultFlag) + << Range(0, 0, 4, C::CacheFlag)) + << C::Default << 2 << 2 << int(VisibleFlag) + << (InsertList() + << Insert(0, 0, 2, 0, 2, VisibleFlag)) + << IndexArray(cacheIndexes) << ListArray(cacheLists) + << IndexArray(defaultIndexes) << ListArray(defaultLists) + << IndexArray(visibleIndexes) << ListArray(visibleLists) + << IndexArray() << ListArray(); + } { static const int cacheIndexes[] = {3,6,0,0,0,0}; + static const void *cacheLists[] = {a,a,0,0,0,0}; + static const int defaultIndexes[] = {0,1,2,3,4,5,6,7,8,9,10,11}; + static const void *defaultLists[] = {a,a,a,a,a,a,a,a,a,a, a, a}; + static const int visibleIndexes[] = {2,3,6,7}; + static const void *visibleLists[] = {a,a,a,a}; + static const int selectionIndexes[] = {3,6}; + static const void *selectionLists[] = {a,a}; + QTest::newRow("Visible, 1, 2, Selection | Cache") + << (RangeList() + << Range(a, 0, 2, C::DefaultFlag) + << Range(a, 2, 2, VisibleFlag | C::DefaultFlag) + << Range(a, 4, 2, C::DefaultFlag) + << Range(a, 6, 2, VisibleFlag | C::DefaultFlag) + << Range(a, 8, 4, C::DefaultFlag) + << Range(0, 0, 4, C::CacheFlag)) + << Visible << 1 << 2 << int(SelectionFlag | C::CacheFlag) + << (InsertList() + << Insert(0, 1, 3, 0, 1, SelectionFlag | C::CacheFlag) + << Insert(1, 2, 6, 1, 1, SelectionFlag | C::CacheFlag)) + << IndexArray(cacheIndexes) << ListArray(cacheLists) + << IndexArray(defaultIndexes) << ListArray(defaultLists) + << IndexArray(visibleIndexes) << ListArray(visibleLists) + << IndexArray(selectionIndexes) << ListArray(selectionLists); + } { static const int cacheIndexes[] = {3,6,0,0,0,0}; + static const void *cacheLists[] = {a,a,0,0,0,0}; + static const int defaultIndexes[] = {0,1,2,3,4,5,6,7,8,9,10,11}; + static const void *defaultLists[] = {a,a,a,a,a,a,a,a,a,a, a, a}; + static const int visibleIndexes[] = {2,3,6,7,0}; + static const void *visibleLists[] = {a,a,a,a,0}; + static const int selectionIndexes[] = {3,6}; + static const void *selectionLists[] = {a,a}; + QTest::newRow("Cache, 3, 1, Visible") + << (RangeList() + << Range(a, 0, 2, C::DefaultFlag) + << Range(a, 2, 1, VisibleFlag | C::DefaultFlag) + << Range(a, 3, 1, SelectionFlag | VisibleFlag | C::DefaultFlag | C::CacheFlag) + << Range(a, 4, 2, C::DefaultFlag) + << Range(a, 6, 1, SelectionFlag | VisibleFlag | C::DefaultFlag | C::CacheFlag) + << Range(a, 7, 1, VisibleFlag | C::DefaultFlag) + << Range(a, 8, 4, C::DefaultFlag) + << Range(0, 0, 4, C::CacheFlag)) + << C::Cache << 3 << 1 << int(VisibleFlag) + << (InsertList() + << Insert(2, 4, 12, 3, 1, VisibleFlag | C::CacheFlag)) + << IndexArray(cacheIndexes) << ListArray(cacheLists) + << IndexArray(defaultIndexes) << ListArray(defaultLists) + << IndexArray(visibleIndexes) << ListArray(visibleLists) + << IndexArray(selectionIndexes) << ListArray(selectionLists); + } { static const int cacheIndexes[] = {0,1,2,3,4,5,6,7,8,9,10,11}; + static const void *cacheLists[] = {a,a,a,a,a,a,a,a,a,a, a, a}; + static const int defaultIndexes[] = {0,1,2,3,4,5,6,7,8,9,10,11}; + static const void *defaultLists[] = {a,a,a,a,a,a,a,a,a,a, a, a}; + static const int visibleIndexes[] = {0,1,3,4,5,6,7,8,9,10,11}; + static const void *visibleLists[] = {a,a,a,a,a,a,a,a,a, a, a}; + static const int selectionIndexes[] = {2,6,7,8,9}; + static const void *selectionLists[] = {a,a,a,a,a}; + QTest::newRow("Existing flag, sparse selection") + << (RangeList() + << Range(a, 0, 2, C::PrependFlag | VisibleFlag | C::DefaultFlag | C::CacheFlag) + << Range(a, 2, 1, C::PrependFlag | SelectionFlag | C::DefaultFlag | C::CacheFlag) + << Range(a, 3, 3, C::PrependFlag | VisibleFlag | C::DefaultFlag | C::CacheFlag) + << Range(a, 6, 4, C::PrependFlag | SelectionFlag | VisibleFlag | C::DefaultFlag | C::CacheFlag) + << Range(a,10, 2, C::AppendFlag | C::PrependFlag | VisibleFlag | C::DefaultFlag | C::CacheFlag)) + << C::Cache << 3 << 1 << int(VisibleFlag) + << InsertList() + << IndexArray(cacheIndexes) << ListArray(cacheLists) + << IndexArray(defaultIndexes) << ListArray(defaultLists) + << IndexArray(visibleIndexes) << ListArray(visibleLists) + << IndexArray(selectionIndexes) << ListArray(selectionLists); + } +} + +void tst_qquicklistcompositor::setFlags() +{ + QFETCH(RangeList, ranges); + QFETCH(C::Group, group); + QFETCH(int, index); + QFETCH(int, count); + QFETCH(int, flags); + QFETCH(InsertList, expectedInserts); + QFETCH(IndexArray, cacheIndexes); + QFETCH(ListArray, cacheLists); + QFETCH(IndexArray, defaultIndexes); + QFETCH(ListArray, defaultLists); + QFETCH(IndexArray, visibleIndexes); + QFETCH(ListArray, visibleLists); + QFETCH(IndexArray, selectionIndexes); + QFETCH(ListArray, selectionLists); + + QQuickListCompositor compositor; + compositor.setGroupCount(4); + compositor.setDefaultGroups(VisibleFlag | C::DefaultFlag); + + foreach (const Range &range, ranges) + compositor.append(range.list, range.index, range.count, range.flags); + + QVector inserts; + compositor.setFlags(group, index, count, flags, &inserts); + + QCOMPARE(inserts, expectedInserts); + + QCOMPARE(compositor.count(C::Cache), cacheIndexes.count); + for (int i = 0; i < cacheIndexes.count; ++i) { + C::iterator it = compositor.find(C::Cache, i); + QCOMPARE(it->list, cacheLists[i]); + if (cacheLists[i]) + QCOMPARE(it.modelIndex(), cacheIndexes[i]); + } + QCOMPARE(compositor.count(C::Default), defaultIndexes.count); + for (int i = 0; i < defaultIndexes.count; ++i) { + C::iterator it = compositor.find(C::Default, i); + QCOMPARE(it->list, defaultLists[i]); + if (defaultLists[i]) + QCOMPARE(it.modelIndex(), defaultIndexes[i]); + } + QCOMPARE(compositor.count(Visible), visibleIndexes.count); + for (int i = 0; i < visibleIndexes.count; ++i) { + C::iterator it = compositor.find(Visible, i); + QCOMPARE(it->list, visibleLists[i]); + if (visibleLists[i]) + QCOMPARE(it.modelIndex(), visibleIndexes[i]); + } + QCOMPARE(compositor.count(Selection), selectionIndexes.count); + for (int i = 0; i < selectionIndexes.count; ++i) { + C::iterator it = compositor.find(Selection, i); + QCOMPARE(it->list, selectionLists[i]); + if (selectionLists[i]) + QCOMPARE(it.modelIndex(), selectionIndexes[i]); + } +} + +void tst_qquicklistcompositor::move_data() +{ + QTest::addColumn("ranges"); + QTest::addColumn("fromGroup"); + QTest::addColumn("from"); + QTest::addColumn("toGroup"); + QTest::addColumn("to"); + QTest::addColumn("count"); + QTest::addColumn("expectedRemoves"); + QTest::addColumn("expectedInserts"); + QTest::addColumn("cacheIndexes"); + QTest::addColumn("cacheLists"); + QTest::addColumn("defaultIndexes"); + QTest::addColumn("defaultLists"); + QTest::addColumn("visibleIndexes"); + QTest::addColumn("visibleLists"); + QTest::addColumn("selectionIndexes"); + QTest::addColumn("selectionLists"); + + int listA; void *a = &listA; + int listB; void *b = &listB; + int listC; void *c = &listC; + + { static const int cacheIndexes[] = {0,0,0,0,2,3}; + static const void *cacheLists[] = {0,0,0,0,c,c}; + static const int defaultIndexes[] = {0,0,1,2,3,4,5,0,1,2,3,4,5,1,2,3,0,1,2,3,4,5}; + static const void *defaultLists[] = {0,a,a,a,a,a,a,b,b,b,b,b,b,0,0,0,c,c,c,c,c,c}; + QTest::newRow("15, 0, 1") + << (RangeList() + << Range(a, 0, 6, C::DefaultFlag) + << Range(b, 0, 6, C::AppendFlag | C::PrependFlag | C::DefaultFlag) + << Range(0, 0, 4, C::DefaultFlag | C::CacheFlag) + << Range(c, 0, 2, C::PrependFlag | C::DefaultFlag) + << Range(c, 2, 2, C::PrependFlag | C::DefaultFlag | C::CacheFlag) + << Range(c, 4, 2, C::AppendFlag | C::PrependFlag | C::DefaultFlag)) + << C::Default << 15 << C::Default << 0 << 1 + << (RemoveList() + << Remove(0, 0, 15, 3, 1, C::DefaultFlag | C::CacheFlag, 0)) + << (InsertList() + << Insert(0, 0, 0, 0, 1, C::DefaultFlag | C::CacheFlag, 0)) + << IndexArray(cacheIndexes) << ListArray(cacheLists) + << IndexArray(defaultIndexes) << ListArray(defaultLists) + << IndexArray() << ListArray() + << IndexArray() << ListArray(); + } { static const int cacheIndexes[] = {0,0,0,0,2,3}; + static const void *cacheLists[] = {0,0,0,0,c,c}; + static const int defaultIndexes[] = {0,1,0,1,2,3,4,5,0,1,2,3,4,5,2,3,0,1,2,3,4,5}; + static const void *defaultLists[] = {0,0,a,a,a,a,a,a,b,b,b,b,b,b,0,0,c,c,c,c,c,c}; + QTest::newRow("15, 1, 1") + << (RangeList() + << Range(0, 0, 1, C::DefaultFlag | C::CacheFlag) + << Range(a, 0, 6, C::DefaultFlag) + << Range(b, 0, 6, C::AppendFlag | C::PrependFlag | C::DefaultFlag) + << Range(0, 0, 3, C::DefaultFlag | C::CacheFlag) + << Range(c, 0, 2, C::PrependFlag | C::DefaultFlag) + << Range(c, 2, 2, C::PrependFlag | C::DefaultFlag | C::CacheFlag) + << Range(c, 4, 2, C::AppendFlag | C::PrependFlag | C::DefaultFlag)) + << C::Default << 15 << C::Default << 1 << 1 + << (RemoveList() + << Remove(0, 0, 15, 3, 1, C::DefaultFlag | C::CacheFlag, 0)) + << (InsertList() + << Insert(0, 0, 1, 1, 1, C::DefaultFlag | C::CacheFlag, 0)) + << IndexArray(cacheIndexes) << ListArray(cacheLists) + << IndexArray(defaultIndexes) << ListArray(defaultLists) + << IndexArray() << ListArray() + << IndexArray() << ListArray(); + } { static const int cacheIndexes[] = {0,0,0,0,2,3}; + static const void *cacheLists[] = {0,0,0,0,c,c}; + static const int defaultIndexes[] = {0,1,2,0,1,3,4,5,0,1,2,3,4,5,2,3,0,1,2,3,4,5}; + static const void *defaultLists[] = {a,a,a,0,0,a,a,a,b,b,b,b,b,b,0,0,c,c,c,c,c,c}; + QTest::newRow("0, 3, 2") + << (RangeList() + << Range(0, 0, 2, C::DefaultFlag | C::CacheFlag) + << Range(a, 0, 6, C::DefaultFlag) + << Range(b, 0, 6, C::AppendFlag | C::PrependFlag | C::DefaultFlag) + << Range(0, 0, 2, C::DefaultFlag | C::CacheFlag) + << Range(c, 0, 2, C::PrependFlag | C::DefaultFlag) + << Range(c, 2, 2, C::PrependFlag | C::DefaultFlag | C::CacheFlag) + << Range(c, 4, 2, C::AppendFlag | C::PrependFlag | C::DefaultFlag)) + << C::Default << 0 << C::Default << 3 << 2 + << (RemoveList() + << Remove(0, 0, 0, 0, 2, C::DefaultFlag | C::CacheFlag, 0)) + << (InsertList() + << Insert(0, 0, 3, 0, 2, C::DefaultFlag | C::CacheFlag, 0)) + << IndexArray(cacheIndexes) << ListArray(cacheLists) + << IndexArray(defaultIndexes) << ListArray(defaultLists) + << IndexArray() << ListArray() + << IndexArray() << ListArray(); + } { static const int cacheIndexes[] = {0,0,0,0,2,3}; + static const void *cacheLists[] = {0,0,0,0,c,c}; + static const int defaultIndexes[] = {0,5,0,1,2,3,4,5,0,1,0,1,2,2,3,3,4,1,2,3,4,5}; + static const void *defaultLists[] = {a,a,b,b,b,b,b,b,0,0,c,a,a,0,0,a,a,c,c,c,c,c}; + QTest::newRow("7, 1, 10") + << (RangeList() + << Range(a, 0, 3, C::DefaultFlag) + << Range(0, 0, 2, C::DefaultFlag | C::CacheFlag) + << Range(a, 3, 3, C::DefaultFlag) + << Range(b, 0, 6, C::AppendFlag | C::PrependFlag | C::DefaultFlag) + << Range(0, 0, 2, C::DefaultFlag | C::CacheFlag) + << Range(c, 0, 2, C::PrependFlag | C::DefaultFlag) + << Range(c, 2, 2, C::PrependFlag | C::DefaultFlag | C::CacheFlag) + << Range(c, 4, 2, C::AppendFlag | C::PrependFlag | C::DefaultFlag)) + << C::Default << 7 << C::Default << 1 << 10 + << (RemoveList() + << Remove(0, 0, 7, 2, 1, C::DefaultFlag, 0) + << Remove(0, 0, 7, 2, 6, C::DefaultFlag, 1) + << Remove(0, 0, 7, 2, 2, C::DefaultFlag | C::CacheFlag, 2) + << Remove(0, 0, 7, 2, 1, C::DefaultFlag, 3)) + << (InsertList() + << Insert(0, 0, 1, 0, 1, C::DefaultFlag, 0) + << Insert(0, 0, 2, 0, 6, C::DefaultFlag, 1) + << Insert(0, 0, 8, 0, 2, C::DefaultFlag | C::CacheFlag, 2) + << Insert(0, 0, 10, 2, 1, C::DefaultFlag, 3)) + << IndexArray(cacheIndexes) << ListArray(cacheLists) + << IndexArray(defaultIndexes) << ListArray(defaultLists) + << IndexArray() << ListArray() + << IndexArray() << ListArray(); + } { static const int cacheIndexes[] = {0,0,0,0,3,2}; + static const void *cacheLists[] = {0,0,0,0,c,c}; + static const int defaultIndexes[] = {0,5,0,1,2,3,4,5,0,1,0,1,2,2,3,3,4,3,4,5,1,2}; + static const void *defaultLists[] = {a,a,b,b,b,b,b,b,0,0,c,a,a,0,0,a,a,c,c,c,c,c}; + QTest::newRow("17, 20, 2") + << (RangeList() + << Range(a, 0, 1, C::DefaultFlag) + << Range(a, 5, 1, C::DefaultFlag) + << Range(b, 0, 6, C::DefaultFlag) + << Range(0, 0, 2, C::DefaultFlag | C::CacheFlag) + << Range(c, 0, 1, C::DefaultFlag) + << Range(a, 1, 2, C::DefaultFlag) + << Range(0, 0, 2, C::DefaultFlag | C::CacheFlag) + << Range(a, 3, 2, C::DefaultFlag) + << Range(b, 0, 6, C::AppendFlag | C::PrependFlag) + << Range(c, 0, 1, C::PrependFlag) + << Range(c, 1, 1, C::PrependFlag | C::DefaultFlag) + << Range(c, 2, 2, C::PrependFlag | C::DefaultFlag | C::CacheFlag) + << Range(c, 4, 2, C::AppendFlag | C::PrependFlag | C::DefaultFlag)) + << C::Default << 17 << C::Default << 20 << 2 + << (RemoveList() + << Remove(0, 0, 17, 4, 1, C::DefaultFlag, 0) + << Remove(0, 0, 17, 4, 1, C::DefaultFlag | C::CacheFlag, 1)) + << (InsertList() + << Insert(0, 0, 20, 5, 1, C::DefaultFlag, 0) + << Insert(0, 0, 21, 5, 1, C::DefaultFlag | C::CacheFlag, 1)) + << IndexArray(cacheIndexes) << ListArray(cacheLists) + << IndexArray(defaultIndexes) << ListArray(defaultLists) + << IndexArray() << ListArray() + << IndexArray() << ListArray(); + } { static const int cacheIndexes[] = {8,9,10,4,11,0,1,2,3,5,6,7}; + static const void *cacheLists[] = {a,a, a,a, a,a,a,a,a,a,a,a}; + static const int defaultIndexes[] = {8,9,10,4,11,0,1,2,3,5,6,7}; + static const void *defaultLists[] = {a,a, a,a, a,a,a,a,a,a,a,a}; + static const int visibleIndexes[] = {8,9,10,4,11,0,1,2,3,5,6,7}; + static const void *visibleLists[] = {a,a, a,a, a,a,a,a,a,a,a,a}; + QTest::newRow("3, 4, 5") + << (RangeList() + << Range(a, 8, 4, VisibleFlag | C::DefaultFlag | C::CacheFlag) + << Range(a, 0, 2, C::PrependFlag | VisibleFlag | C::DefaultFlag | C::CacheFlag) + << Range(a, 2, 1, C::PrependFlag) + << Range(a, 2, 1, VisibleFlag | C::DefaultFlag | C::CacheFlag) + << Range(a, 3, 5, C::PrependFlag | VisibleFlag | C::DefaultFlag | C::CacheFlag) + << Range(a, 8, 4, C::AppendFlag | C::PrependFlag)) + << C::Default << 3 << C::Default << 4 << 5 + << (RemoveList() + << Remove(0, 3, 3, 3, 1, VisibleFlag | C::DefaultFlag | C::CacheFlag, 0) + << Remove(0, 3, 3, 3, 2, VisibleFlag | C::DefaultFlag | C::CacheFlag, 1) + << Remove(0, 3, 3, 3, 1, VisibleFlag | C::DefaultFlag | C::CacheFlag, 2) + << Remove(0, 3, 3, 3, 1, VisibleFlag | C::DefaultFlag | C::CacheFlag, 3)) + << (InsertList() + << Insert(0, 4, 4, 4, 1, VisibleFlag | C::DefaultFlag | C::CacheFlag, 0) + << Insert(0, 5, 5, 5, 2, VisibleFlag | C::DefaultFlag | C::CacheFlag, 1) + << Insert(0, 7, 7, 7, 1, VisibleFlag | C::DefaultFlag | C::CacheFlag, 2) + << Insert(0, 8, 8, 8, 1, VisibleFlag | C::DefaultFlag | C::CacheFlag, 3)) + << IndexArray(cacheIndexes) << ListArray(cacheLists) + << IndexArray(defaultIndexes) << ListArray(defaultLists) + << IndexArray(visibleIndexes) << ListArray(visibleLists) + << IndexArray() << ListArray(); + } { static const int cacheIndexes[] = {0,1}; + static const void *cacheLists[] = {a,a}; + static const int defaultIndexes[] = {0,1}; + static const void *defaultLists[] = {a,a}; + QTest::newRow("0, 1, 1") + << (RangeList() + << Range(a, 0, 1, C::PrependFlag) + << Range(a, 1, 1, C::PrependFlag | C::DefaultFlag | C::CacheFlag) + << Range(a, 2, 0, C::AppendFlag | C::PrependFlag) + << Range(a, 0, 1, C::DefaultFlag | C::CacheFlag)) + << C::Default << 0 << C::Default << 1 << 1 + << (RemoveList() + << Remove(0, 0, 0, 0, 1, C::DefaultFlag | C::CacheFlag, 0)) + << (InsertList() + << Insert(0, 0, 1, 1, 1, C::DefaultFlag | C::CacheFlag, 0)) + << IndexArray(cacheIndexes) << ListArray(cacheLists) + << IndexArray(defaultIndexes) << ListArray(defaultLists) + << IndexArray() << ListArray() + << IndexArray() << ListArray(); + } +} + +void tst_qquicklistcompositor::move() +{ + QFETCH(RangeList, ranges); + QFETCH(C::Group, fromGroup); + QFETCH(int, from); + QFETCH(C::Group, toGroup); + QFETCH(int, to); + QFETCH(int, count); + QFETCH(RemoveList, expectedRemoves); + QFETCH(InsertList, expectedInserts); + QFETCH(IndexArray, cacheIndexes); + QFETCH(ListArray, cacheLists); + QFETCH(IndexArray, defaultIndexes); + QFETCH(ListArray, defaultLists); + QFETCH(IndexArray, visibleIndexes); + QFETCH(ListArray, visibleLists); + QFETCH(IndexArray, selectionIndexes); + QFETCH(ListArray, selectionLists); + + QQuickListCompositor compositor; + compositor.setGroupCount(4); + compositor.setDefaultGroups(VisibleFlag | C::DefaultFlag); + + foreach (const Range &range, ranges) + compositor.append(range.list, range.index, range.count, range.flags); + + QVector removes; + QVector inserts; + compositor.move(fromGroup, from, toGroup, to, count, fromGroup, &removes, &inserts); + + QCOMPARE(removes, expectedRemoves); + QCOMPARE(inserts, expectedInserts); + + QCOMPARE(compositor.count(C::Cache), cacheIndexes.count); + for (int i = 0; i < cacheIndexes.count; ++i) { + C::iterator it = compositor.find(C::Cache, i); + QCOMPARE(it->list, cacheLists[i]); + if (cacheLists[i]) + QCOMPARE(it.modelIndex(), cacheIndexes[i]); + } + QCOMPARE(compositor.count(C::Default), defaultIndexes.count); + for (int i = 0; i < defaultIndexes.count; ++i) { + C::iterator it = compositor.find(C::Default, i); + QCOMPARE(it->list, defaultLists[i]); + if (defaultLists[i]) + QCOMPARE(it.modelIndex(), defaultIndexes[i]); + } + QCOMPARE(compositor.count(Visible), visibleIndexes.count); + for (int i = 0; i < visibleIndexes.count; ++i) { + C::iterator it = compositor.find(Visible, i); + QCOMPARE(it->list, visibleLists[i]); + if (visibleLists[i]) + QCOMPARE(it.modelIndex(), visibleIndexes[i]); + } + QCOMPARE(compositor.count(Selection), selectionIndexes.count); + for (int i = 0; i < selectionIndexes.count; ++i) { + C::iterator it = compositor.find(Selection, i); + QCOMPARE(it->list, selectionLists[i]); + if (selectionLists[i]) + QCOMPARE(it.modelIndex(), selectionIndexes[i]); + } +} + +void tst_qquicklistcompositor::moveFromEnd() +{ + int listA; void *a = &listA; + + QQuickListCompositor compositor; + compositor.append(a, 0, 1, C::AppendFlag | C::PrependFlag | C::DefaultFlag); + + // Moving an item anchors it to that position. + compositor.move(C::Default, 0, C::Default, 0, 1, C::Default); + + // The existing item is anchored at 0 so prepending an item to the source will append it here + QVector inserts; + compositor.listItemsInserted(a, 0, 1, &inserts); + + QCOMPARE(inserts.count(), 1); + QCOMPARE(inserts.at(0).index[1], 1); + QCOMPARE(inserts.at(0).count, 1); + + C::iterator it; + it = compositor.find(C::Default, 0); + QCOMPARE(it.modelIndex(), 1); + + it = compositor.find(C::Default, 1); + QCOMPARE(it.modelIndex(), 0); +} + +void tst_qquicklistcompositor::clear() +{ + QQuickListCompositor compositor; + compositor.setGroupCount(4); + compositor.setDefaultGroups(VisibleFlag | C::DefaultFlag); + + int listA; void *a = &listA; + int listB; void *b = &listB; + + compositor.append(a, 0, 8, C::AppendFlag | C::PrependFlag | VisibleFlag | C::DefaultFlag); + compositor.append(b, 4, 5, VisibleFlag | C::DefaultFlag); + compositor.append(0, 0, 3, VisibleFlag | C::DefaultFlag | C::CacheFlag); + + QCOMPARE(compositor.count(C::Default), 16); + QCOMPARE(compositor.count(Visible), 16); + QCOMPARE(compositor.count(C::Cache), 3); + + compositor.clear(); + QCOMPARE(compositor.count(C::Default), 0); + QCOMPARE(compositor.count(Visible), 0); + QCOMPARE(compositor.count(C::Cache), 0); +} + +void tst_qquicklistcompositor::listItemsInserted_data() +{ + QTest::addColumn("ranges"); + QTest::addColumn("list"); + QTest::addColumn("index"); + QTest::addColumn("count"); + QTest::addColumn("expectedInserts"); + QTest::addColumn("cacheIndexes"); + QTest::addColumn("defaultIndexes"); + QTest::addColumn("visibleIndexes"); + QTest::addColumn("selectionIndexes"); + + int listA; void *a = &listA; + int listB; void *b = &listB; + + { static const int defaultIndexes[] = {/*A*/0,1,5,6,/*B*/0,1,2,3,/*A*/2,3,4}; + QTest::newRow("A 10, 2") + << (RangeList() + << Range(a, 0, 2, C::PrependFlag | C::DefaultFlag) + << Range(a, 2, 3, C::PrependFlag) + << Range(a, 5, 2, C::AppendFlag | C::PrependFlag | C::DefaultFlag) + << Range(b, 0, 4, C::DefaultFlag) + << Range(a, 2, 3, C::DefaultFlag)) + << a << 10 << 2 + << InsertList() + << IndexArray() + << IndexArray(defaultIndexes) + << IndexArray() + << IndexArray(); + } { static const int defaultIndexes[] = {/*A*/0,1,5,6,/*B*/0,1,2,3,/*A*/2,3,4}; + QTest::newRow("B 10, 2") + << (RangeList() + << Range(a, 0, 2, C::PrependFlag | C::DefaultFlag) + << Range(a, 2, 3, C::PrependFlag) + << Range(a, 5, 2, C::AppendFlag | C::PrependFlag | C::DefaultFlag) + << Range(b, 0, 4, C::DefaultFlag) + << Range(a, 2, 3, C::DefaultFlag)) + << b << 10 << 2 + << InsertList() + << IndexArray() + << IndexArray(defaultIndexes) + << IndexArray() + << IndexArray(); + } { static const int defaultIndexes[] = {/*A*/0,1,2,3,7,8,/*B*/0,1,2,3,/*A*/4,5,6}; + static const int visibleIndexes[] = {/*A*/0,1}; + QTest::newRow("A 0, 2") + << (RangeList() + << Range(a, 0, 2, C::PrependFlag | C::DefaultFlag) + << Range(a, 2, 3, C::PrependFlag) + << Range(a, 5, 2, C::AppendFlag | C::PrependFlag | C::DefaultFlag) + << Range(b, 0, 4, C::DefaultFlag) + << Range(a, 2, 3, C::DefaultFlag)) + << a << 0 << 2 + << (InsertList() + << Insert(0, 0, 0, 0, 2, VisibleFlag | C::DefaultFlag)) + << IndexArray() + << IndexArray(defaultIndexes) + << IndexArray(visibleIndexes) + << IndexArray(); + } { static const int defaultIndexes[] = {/*A*/0,1,2,3,5,8,9,/*B*/0,1,2,3,/*A*/4,6,7}; + static const int visibleIndexes[] = {/*A*/0,1,5}; + QTest::newRow("A 5, 1") + << (RangeList() + << Range(a, 0, 2, C::PrependFlag | VisibleFlag | C::DefaultFlag) + << Range(a, 2, 2, C::PrependFlag | C::DefaultFlag) + << Range(a, 4, 3, C::PrependFlag) + << Range(a, 7, 2, C::AppendFlag | C::PrependFlag | C::DefaultFlag) + << Range(b, 0, 4, C::DefaultFlag) + << Range(a, 4, 3, C::DefaultFlag)) + << a << 5 << 1 + << (InsertList() + << Insert(0, 2, 4, 0, 1, VisibleFlag | C::DefaultFlag)) + << IndexArray() + << IndexArray(defaultIndexes) + << IndexArray(visibleIndexes) + << IndexArray(); + } { static const int defaultIndexes[] = {/*A*/0,1,2,3,5,8,9,10,11,/*B*/0,1,2,3,/*A*/4,6,7}; + static const int visibleIndexes[] = {/*A*/0,1,5,10,11}; + QTest::newRow("A 10, 2") + << (RangeList() + << Range(a, 0, 2, C::PrependFlag | VisibleFlag | C::DefaultFlag) + << Range(a, 2, 2, C::PrependFlag | C::DefaultFlag) + << Range(a, 4, 1, C::PrependFlag) + << Range(a, 5, 1, C::PrependFlag | VisibleFlag | C::DefaultFlag) + << Range(a, 6, 2, C::PrependFlag) + << Range(a, 8, 2, C::AppendFlag | C::PrependFlag | C::DefaultFlag) + << Range(b, 0, 4, C::DefaultFlag) + << Range(a, 4, 1, C::DefaultFlag) + << Range(a, 6, 2, C::DefaultFlag)) + << a << 10 << 2 + << (InsertList() + << Insert(0, 3, 7, 0, 2, VisibleFlag | C::DefaultFlag)) + << IndexArray() + << IndexArray(defaultIndexes) + << IndexArray(visibleIndexes) + << IndexArray(); + } { static const int cacheIndexes[] = {/*A*/0,1,-1,-1,-1,2,5,6,7,8,9}; + static const int defaultIndexes[] = {/*A*/0,1,2,3,4,5,6,7,8,9}; + static const int visibleIndexes[] = {/*A*/3,4}; + QTest::newRow("Insert after remove") + << (RangeList() + << Range(a, 0, 2, C::PrependFlag | C::DefaultFlag | C::CacheFlag) + << Range(a, 2, 3, C::CacheFlag) + << Range(a, 2, 6, C::AppendFlag | C::PrependFlag | C::DefaultFlag | C::CacheFlag)) + << a << 3 << 2 + << (InsertList() + << Insert(0, 0, 3, 6, 2, VisibleFlag | C::DefaultFlag)) + << IndexArray(cacheIndexes) + << IndexArray(defaultIndexes) + << IndexArray(visibleIndexes) + << IndexArray(); + } { static const int cacheIndexes[] = {/*A*/0,1,2,3,4}; + static const int defaultIndexes[] = {/*A*/0,1,2,3,4,5,6}; + static const int visibleIndexes[] = {/*A*/0,1,2,3,4,5,6}; + QTest::newRow("Consecutive appends") + << (RangeList() + << Range(a, 0, 5, C::PrependFlag | VisibleFlag | C::DefaultFlag | C::CacheFlag) + << Range(a, 5, 1, C::PrependFlag | VisibleFlag | C::DefaultFlag) + << Range(a, 6, 0, C::AppendFlag | VisibleFlag | C::PrependFlag | C::DefaultFlag | C::CacheFlag)) + << a << 6 << 1 + << (InsertList() + << Insert(0, 6, 6, 5, 1, VisibleFlag | C::DefaultFlag)) + << IndexArray(cacheIndexes) + << IndexArray(defaultIndexes) + << IndexArray(visibleIndexes) + << IndexArray(); + } +} + +void tst_qquicklistcompositor::listItemsInserted() +{ + QFETCH(RangeList, ranges); + QFETCH(void *, list); + QFETCH(int, index); + QFETCH(int, count); + QFETCH(InsertList, expectedInserts); + QFETCH(IndexArray, cacheIndexes); + QFETCH(IndexArray, defaultIndexes); + QFETCH(IndexArray, visibleIndexes); + QFETCH(IndexArray, selectionIndexes); + + QQuickListCompositor compositor; + compositor.setGroupCount(4); + compositor.setDefaultGroups(VisibleFlag | C::DefaultFlag); + + foreach (const Range &range, ranges) + compositor.append(range.list, range.index, range.count, range.flags); + + QVector inserts; + compositor.listItemsInserted(list, index, count, &inserts); + + QCOMPARE(inserts, expectedInserts); + + QCOMPARE(compositor.count(C::Cache), cacheIndexes.count); + for (int i = 0; i < cacheIndexes.count; ++i) { + if (cacheIndexes[i] != -1) { + QCOMPARE(compositor.find(C::Cache, i).modelIndex(), cacheIndexes[i]); + } + } + QCOMPARE(compositor.count(C::Default), defaultIndexes.count); + for (int i = 0; i < defaultIndexes.count; ++i) { + if (defaultIndexes[i] != -1) { + QCOMPARE(compositor.find(C::Default, i).modelIndex(), defaultIndexes[i]); + } + } + QCOMPARE(compositor.count(Visible), visibleIndexes.count); + for (int i = 0; i < visibleIndexes.count; ++i) { + if (visibleIndexes[i] != -1) { + QCOMPARE(compositor.find(Visible, i).modelIndex(), visibleIndexes[i]); + } + } + QCOMPARE(compositor.count(Selection), selectionIndexes.count); + for (int i = 0; i < selectionIndexes.count; ++i) { + if (selectionIndexes[i] != -1) { + QCOMPARE(compositor.find(Selection, i).modelIndex(), selectionIndexes[i]); + } + } +} + +void tst_qquicklistcompositor::listItemsRemoved_data() +{ + QTest::addColumn("ranges"); + QTest::addColumn("list"); + QTest::addColumn("index"); + QTest::addColumn("count"); + QTest::addColumn("expectedRemoves"); + QTest::addColumn("cacheIndexes"); + QTest::addColumn("defaultIndexes"); + QTest::addColumn("visibleIndexes"); + QTest::addColumn("selectionIndexes"); + + int listA; void *a = &listA; + int listB; void *b = &listB; + + { static const int defaultIndexes[] = {/*A*/0,1,5,6,/*B*/0,1,2,3,/*A*/2,3,4}; + QTest::newRow("12, 2") + << (RangeList() + << Range(a, 0, 2, C::PrependFlag | C::DefaultFlag) + << Range(a, 2, 3, C::PrependFlag) + << Range(a, 5, 2, C::AppendFlag | C::PrependFlag | C::DefaultFlag) + << Range(b, 0, 4, C::DefaultFlag) + << Range(a, 2, 3, C::DefaultFlag)) + << a << 12 << 2 + << RemoveList() + << IndexArray() + << IndexArray(defaultIndexes) + << IndexArray() + << IndexArray(); + } { static const int defaultIndexes[] = {/*A*/0,1,/*B*/0,1,2,3,/*A*/2,3}; + QTest::newRow("4, 3") + << (RangeList() + << Range(a, 0, 2, C::PrependFlag | C::DefaultFlag) + << Range(a, 2, 3, C::PrependFlag) + << Range(a, 5, 2, C::AppendFlag | C::PrependFlag | C::DefaultFlag) + << Range(b, 0, 4, C::DefaultFlag) + << Range(a, 2, 3, C::DefaultFlag)) + << a << 4 << 3 + << (RemoveList() + << Remove(0, 0, 2, 0, 2, C::DefaultFlag) + << Remove(0, 0, 8, 0, 1, C::DefaultFlag)) + << IndexArray() + << IndexArray(defaultIndexes) + << IndexArray() + << IndexArray(); + } { static const int cacheIndexes[] = {/*A*/0,1,-1,-1,-1,2,-1,-1,3,4,5}; + static const int defaultIndexes[] = {/*A*/0,1,2,3,4,5}; + QTest::newRow("Remove after remove") + << (RangeList() + << Range(a, 0, 2, C::PrependFlag | C::DefaultFlag | C::CacheFlag) + << Range(a, 2, 3, C::CacheFlag) + << Range(a, 2, 6, C::AppendFlag | C::PrependFlag | C::DefaultFlag | C::CacheFlag)) + << a << 3 << 2 + << (RemoveList() + << Remove(0, 0, 3, 6, 2, C::DefaultFlag | C::CacheFlag)) + << IndexArray(cacheIndexes) + << IndexArray(defaultIndexes) + << IndexArray() + << IndexArray(); + } { static const int cacheIndexes[] = {/*A*/-1,-1,0,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,1}; + static const int defaultIndexes[] = {/*A*/0,1,2,3,4,5,6}; + QTest::newRow("Sparse remove") + << (RangeList() + << Range(a, 0, 2, C::CacheFlag) + << Range(a, 0, 1, C::DefaultFlag | C::CacheFlag) + << Range(a, 0, 1, C::CacheFlag) + << Range(a, 1, 5, C::DefaultFlag | C::CacheFlag) + << Range(a, 0, 1, C::CacheFlag) + << Range(a, 6, 2, C::DefaultFlag | C::CacheFlag) + << Range(a, 0, 1, C::CacheFlag) + << Range(a, 8, 3, C::DefaultFlag | C::CacheFlag) + << Range(a, 0, 1, C::CacheFlag) + << Range(a, 11, 1, C::DefaultFlag | C::CacheFlag) + << Range(a, 12, 5, C::DefaultFlag)) + << a << 1 << 10 + << (RemoveList() + << Remove(0, 0, 1, 4, 5, C::DefaultFlag | C::CacheFlag) + << Remove(0, 0, 1,10, 2, C::DefaultFlag | C::CacheFlag) + << Remove(0, 0, 1,13, 3, C::DefaultFlag | C::CacheFlag)) + << IndexArray(cacheIndexes) + << IndexArray(defaultIndexes) + << IndexArray() + << IndexArray(); + } +} + +void tst_qquicklistcompositor::listItemsRemoved() +{ + QFETCH(RangeList, ranges); + QFETCH(void *, list); + QFETCH(int, index); + QFETCH(int, count); + QFETCH(RemoveList, expectedRemoves); + QFETCH(IndexArray, cacheIndexes); + QFETCH(IndexArray, defaultIndexes); + QFETCH(IndexArray, visibleIndexes); + QFETCH(IndexArray, selectionIndexes); + + QQuickListCompositor compositor; + compositor.setGroupCount(4); + compositor.setDefaultGroups(VisibleFlag | C::DefaultFlag); + + foreach (const Range &range, ranges) + compositor.append(range.list, range.index, range.count, range.flags); + + QVector removes; + compositor.listItemsRemoved(list, index, count, &removes); + + QCOMPARE(removes, expectedRemoves); + + QCOMPARE(compositor.count(C::Cache), cacheIndexes.count); + for (int i = 0; i < cacheIndexes.count; ++i) { + if (cacheIndexes[i] != -1) { + QCOMPARE(compositor.find(C::Cache, i).modelIndex(), cacheIndexes[i]); + } + } + QCOMPARE(compositor.count(C::Default), defaultIndexes.count); + for (int i = 0; i < defaultIndexes.count; ++i) { + if (defaultIndexes[i] != -1) { + QCOMPARE(compositor.find(C::Default, i).modelIndex(), defaultIndexes[i]); + } + } + QCOMPARE(compositor.count(Visible), visibleIndexes.count); + for (int i = 0; i < visibleIndexes.count; ++i) { + if (visibleIndexes[i] != -1) { + QCOMPARE(compositor.find(Visible, i).modelIndex(), visibleIndexes[i]); + } + } + QCOMPARE(compositor.count(Selection), selectionIndexes.count); + for (int i = 0; i < selectionIndexes.count; ++i) { + if (selectionIndexes[i] != -1) { + QCOMPARE(compositor.find(Selection, i).modelIndex(), selectionIndexes[i]); + } + } +} + +void tst_qquicklistcompositor::listItemsMoved_data() +{ + QTest::addColumn("ranges"); + QTest::addColumn("list"); + QTest::addColumn("from"); + QTest::addColumn("to"); + QTest::addColumn("count"); + QTest::addColumn("expectedRemoves"); + QTest::addColumn("expectedInserts"); + QTest::addColumn("cacheIndexes"); + QTest::addColumn("defaultIndexes"); + QTest::addColumn("visibleIndexes"); + QTest::addColumn("selectionIndexes"); + + int listA; void *a = &listA; + int listB; void *b = &listB; + + { static const int defaultIndexes[] = {/*A*/0,2,3,4,/*B*/0,1,2,3,/*A*/5,6,1}; + QTest::newRow("4, 1, 3") + << (RangeList() + << Range(a, 0, 2, C::PrependFlag | C::DefaultFlag) + << Range(a, 2, 3, C::PrependFlag) + << Range(a, 5, 2, C::AppendFlag | C::PrependFlag | C::DefaultFlag) + << Range(b, 0, 4, C::DefaultFlag) + << Range(a, 2, 3, C::DefaultFlag)) + << a << 4 << 1 << 3 + << (RemoveList() + << Remove(0, 0, 2, 0, 2, C::DefaultFlag, 0)) + << (InsertList() + << Insert(0, 0, 1, 0, 2, C::DefaultFlag, 0)) + << IndexArray() + << IndexArray(defaultIndexes) + << IndexArray() + << IndexArray(); + } { static const int defaultIndexes[] = {/*A*/1,2,3,6,/*B*/0,1,2,3,/*A*/4,5,0}; + QTest::newRow("0, 6, 1") + << (RangeList() + << Range(a, 0, 1, C::PrependFlag | C::DefaultFlag) + << Range(a, 1, 1, C::PrependFlag) + << Range(a, 2, 3, C::PrependFlag | C::DefaultFlag) + << Range(a, 5, 2, C::PrependFlag) + << Range(a, 7, 0, C::AppendFlag | C::PrependFlag | C::DefaultFlag) + << Range(b, 0, 4, C::DefaultFlag) + << Range(a, 5, 2, C::DefaultFlag) + << Range(a, 1, 1, C::DefaultFlag)) + << a << 0 << 6 << 1 + << (RemoveList() + << Remove(0, 0, 0, 0, 1, C::DefaultFlag, 0)) + << (InsertList() + << Insert(0, 0, 3, 0, 1, C::DefaultFlag, 0)) + << IndexArray() + << IndexArray(defaultIndexes) + << IndexArray() + << IndexArray(); + } { static const int cacheIndexes[] = {/*A*/0,1,3,4}; + static const int defaultIndexes[] = {/*A*/0,1,2,3,4,5,6,7}; + QTest::newRow("6, 2, 1") + << (RangeList() + << Range(a, 0, 4, C::PrependFlag | C::DefaultFlag | C::CacheFlag) + << Range(a, 4, 4, C::AppendFlag | C::PrependFlag | C::DefaultFlag)) + << a << 6 << 2 << 1 + << (RemoveList() + << Remove(0, 0, 6, 4, 1, C::DefaultFlag, 0)) + << (InsertList() + << Insert(0, 0, 2, 2, 1, C::DefaultFlag, 0)) + << IndexArray(cacheIndexes) + << IndexArray(defaultIndexes) + << IndexArray() + << IndexArray(); + } { static const int cacheIndexes[] = {/*A*/0,1,-1,-1,-1,2,3,4,5,6,7}; + static const int defaultIndexes[] = {/*A*/0,1,2,3,4,5,6,7}; + QTest::newRow("Move after remove") + << (RangeList() + << Range(a, 0, 2, C::PrependFlag | C::DefaultFlag | C::CacheFlag) + << Range(a, 2, 3, C::CacheFlag) + << Range(a, 2, 6, C::AppendFlag | C::PrependFlag | C::DefaultFlag | C::CacheFlag)) + << a << 4 << 2 << 2 + << (RemoveList() + << Remove(0, 0, 4, 7, 2, C::DefaultFlag | C::CacheFlag, 0)) + << (InsertList() + << Insert(0, 0, 2, 5, 2, C::DefaultFlag | C::CacheFlag, 0)) + << IndexArray(cacheIndexes) + << IndexArray(defaultIndexes) + << IndexArray() + << IndexArray(); + } { static const int cacheIndexes[] = {/*A*/0,1,5,6,7,8,9,10,11,12}; + static const int defaultIndexes[] = {/*A*/0,1,2,3,4,5,6,7,8,9,10,11,12}; + QTest::newRow("Move merge tail") + << (RangeList() + << Range(a, 0, 10, C::PrependFlag | C::DefaultFlag | C::CacheFlag) + << Range(a, 10, 3, C::PrependFlag | C::DefaultFlag) + << Range(a, 13, 0, C::AppendFlag | C::PrependFlag | C::DefaultFlag | C::CacheFlag)) + << a << 8 << 0 << 5 + << (RemoveList() + << Remove(0, 0, 8, 8, 2, C::DefaultFlag | C::CacheFlag, 0) + << Remove(0, 0, 8, 8, 3, C::DefaultFlag, 1)) + << (InsertList() + << Insert(0, 0, 0, 0, 2, C::DefaultFlag | C::CacheFlag, 0) + << Insert(0, 0, 2, 2, 3, C::DefaultFlag, 1)) + << IndexArray(cacheIndexes) + << IndexArray(defaultIndexes) + << IndexArray() + << IndexArray(); + } { static const int cacheIndexes[] = {/*A*/0,1,2,3}; + static const int defaultIndexes[] = {/*A*/0,1,2,3}; + static const int selectionIndexes[] = {/*A*/3}; + QTest::newRow("Move selection") + << (RangeList() + << Range(a, 0, 2, C::PrependFlag | C::DefaultFlag | C::CacheFlag) + << Range(a, 2, 1, C::PrependFlag | SelectionFlag | C::DefaultFlag | C::CacheFlag) + << Range(a, 3, 1, C::AppendFlag | C::PrependFlag | C::DefaultFlag | C::CacheFlag)) + << a << 2 << 3 << 1 + << (RemoveList() + << Remove(0, 0, 2, 2, 1, C::PrependFlag | SelectionFlag | C::DefaultFlag | C::CacheFlag, 0)) + << (InsertList() + << Insert(0, 0, 3, 3, 1, C::PrependFlag | SelectionFlag | C::DefaultFlag | C::CacheFlag, 0)) + << IndexArray(cacheIndexes) + << IndexArray(defaultIndexes) + << IndexArray() + << IndexArray(selectionIndexes); + } { static const int cacheIndexes[] = {/*A*/0,1,2,3,4,5,8,9}; + static const int defaultIndexes[] = {/*A*/0,1,2,3,4,5,6,7,8,9,10,11}; + QTest::newRow("move mixed cached items") + << (RangeList() + << Range(a, 0, 1, C::PrependFlag | C::DefaultFlag | C::CacheFlag) + << Range(a, 1, 2, C::PrependFlag | C::DefaultFlag) + << Range(a, 3, 7, C::PrependFlag | C::DefaultFlag | C::CacheFlag) + << Range(a, 10, 2, C::PrependFlag | C::DefaultFlag)) + << a << 1 << 6 << 3 + << (RemoveList() + << Remove(0, 0, 1, 1, 2, C::PrependFlag | C::DefaultFlag, 0) + << Remove(0, 0, 1, 1, 1, C::PrependFlag | C::DefaultFlag | C::CacheFlag, 1)) + << (InsertList() + << Insert(0, 0, 6, 6, 2, C::PrependFlag | C::DefaultFlag, 0) + << Insert(0, 0, 8, 6, 1, C::PrependFlag | C::DefaultFlag | C::CacheFlag, 1)) + << IndexArray(cacheIndexes) + << IndexArray(defaultIndexes) + << IndexArray() + << IndexArray(); + } +} + +void tst_qquicklistcompositor::listItemsMoved() +{ + QFETCH(RangeList, ranges); + QFETCH(void *, list); + QFETCH(int, from); + QFETCH(int, to); + QFETCH(int, count); + QFETCH(RemoveList, expectedRemoves); + QFETCH(InsertList, expectedInserts); + QFETCH(IndexArray, cacheIndexes); + QFETCH(IndexArray, defaultIndexes); + QFETCH(IndexArray, visibleIndexes); + QFETCH(IndexArray, selectionIndexes); + + QQuickListCompositor compositor; + compositor.setGroupCount(4); + compositor.setDefaultGroups(VisibleFlag | C::DefaultFlag); + + foreach (const Range &range, ranges) + compositor.append(range.list, range.index, range.count, range.flags); + + QVector removes; + QVector inserts; + compositor.listItemsMoved(list, from, to, count, &removes, &inserts); + + QCOMPARE(removes, expectedRemoves); + QCOMPARE(inserts, expectedInserts); + + QCOMPARE(compositor.count(C::Cache), cacheIndexes.count); + for (int i = 0; i < cacheIndexes.count; ++i) { + if (cacheIndexes[i] != -1) { + QCOMPARE(compositor.find(C::Cache, i).modelIndex(), cacheIndexes[i]); + } + } + QCOMPARE(compositor.count(C::Default), defaultIndexes.count); + for (int i = 0; i < defaultIndexes.count; ++i) { + if (defaultIndexes[i] != -1) { + QCOMPARE(compositor.find(C::Default, i).modelIndex(), defaultIndexes[i]); + } + } + QCOMPARE(compositor.count(Visible), visibleIndexes.count); + for (int i = 0; i < visibleIndexes.count; ++i) { + if (visibleIndexes[i] != -1) { + QCOMPARE(compositor.find(Visible, i).modelIndex(), visibleIndexes[i]); + } + } + QCOMPARE(compositor.count(Selection), selectionIndexes.count); + for (int i = 0; i < selectionIndexes.count; ++i) { + if (selectionIndexes[i] != -1) { + QCOMPARE(compositor.find(Selection, i).modelIndex(), selectionIndexes[i]); + } + } +} + +void tst_qquicklistcompositor::listItemsChanged_data() +{ + QTest::addColumn("ranges"); + QTest::addColumn("list"); + QTest::addColumn("index"); + QTest::addColumn("count"); + QTest::addColumn("expectedChanges"); + + int listA; void *a = &listA; + int listB; void *b = &listB; + + QTest::newRow("overlapping") + << (RangeList() + << Range(a, 0, 2, C::PrependFlag | C::DefaultFlag) + << Range(a, 2, 3, C::PrependFlag) + << Range(a, 5, 2, C::AppendFlag | C::PrependFlag | C::DefaultFlag) + << Range(b, 0, 4, C::DefaultFlag) + << Range(a, 2, 3, C::DefaultFlag)) + << a << 3 << 4 + << (ChangeList() + << Change(0, 0, 2, 0, 2, C::DefaultFlag) + << Change(0, 0, 9, 0, 2, C::DefaultFlag)); + QTest::newRow("Change after remove") + << (RangeList() + << Range(a, 0, 2, C::PrependFlag | C::DefaultFlag | C::CacheFlag) + << Range(a, 2, 3, C::CacheFlag) + << Range(a, 2, 6, C::AppendFlag | C::PrependFlag | C::DefaultFlag | C::CacheFlag)) + << a << 3 << 2 + << (ChangeList() + << Change(0, 0, 3, 6, 2, C::DefaultFlag | C::CacheFlag)); +} + +void tst_qquicklistcompositor::listItemsChanged() +{ + QFETCH(RangeList, ranges); + QFETCH(void *, list); + QFETCH(int, index); + QFETCH(int, count); + QFETCH(ChangeList, expectedChanges); + + QQuickListCompositor compositor; + compositor.setGroupCount(4); + compositor.setDefaultGroups(VisibleFlag | C::DefaultFlag); + + foreach (const Range &range, ranges) + compositor.append(range.list, range.index, range.count, range.flags); + + QVector changes; + compositor.listItemsChanged(list, index, count, &changes); + + QCOMPARE(changes, expectedChanges); +} + +QTEST_MAIN(tst_qquicklistcompositor) + +#include "tst_qquicklistcompositor.moc" + + diff --git a/tests/auto/qml/qquicklistmodel/data/enumerate.qml b/tests/auto/qml/qquicklistmodel/data/enumerate.qml new file mode 100644 index 0000000000..f73d66b318 --- /dev/null +++ b/tests/auto/qml/qquicklistmodel/data/enumerate.qml @@ -0,0 +1,24 @@ +import QtQuick 2.0 + +Item { + property string result + + ListModel { + id: model + + ListElement { + val1: 1 + val2: 2 + val3: "str" + val4: false + val5: true + } + } + + Component.onCompleted: { + var element = model.get(0); + + for (var i in element) + result += i+"="+element[i]+(element[i] ? "Y" : "N")+":"; + } +} diff --git a/tests/auto/qml/qquicklistmodel/data/model.qml b/tests/auto/qml/qquicklistmodel/data/model.qml new file mode 100644 index 0000000000..5973ea8adf --- /dev/null +++ b/tests/auto/qml/qquicklistmodel/data/model.qml @@ -0,0 +1,26 @@ +import QtQuick 2.0 + +Item { + id: item + property variant model + property bool done: false + property variant result + + function evalExpressionViaWorker(commands) { + done = false + worker.sendMessage({'commands': commands, 'model': model}) + } + + WorkerScript { + id: worker + source: "script.js" + onMessage: { + item.result = messageObject.result + item.done = true + } + } + + function runEval(js) { + eval(js); + } +} diff --git a/tests/auto/qml/qquicklistmodel/data/multipleroles.qml b/tests/auto/qml/qquicklistmodel/data/multipleroles.qml new file mode 100644 index 0000000000..4a331e2b3e --- /dev/null +++ b/tests/auto/qml/qquicklistmodel/data/multipleroles.qml @@ -0,0 +1,25 @@ +import QtQuick 2.0 +ListView { + width: 100 + height: 250 + delegate: Rectangle { + width: 100 + height: 50 + color: black ? "black": "white" + } + model: ListModel { + objectName: "listModel" + ListElement { + black: false + rounded: false + } + ListElement { + black: true + rounded: false + } + ListElement { + black: true + rounded: false + } + } +} diff --git a/tests/auto/qml/qquicklistmodel/data/script.js b/tests/auto/qml/qquicklistmodel/data/script.js new file mode 100644 index 0000000000..66a4acb8a8 --- /dev/null +++ b/tests/auto/qml/qquicklistmodel/data/script.js @@ -0,0 +1,13 @@ +WorkerScript.onMessage = function(msg) { + var result = null + try { + for (var i=0; i +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +#include "../../shared/util.h" + +Q_DECLARE_METATYPE(QList) +Q_DECLARE_METATYPE(QList) + +#define RUNEVAL(object, string) \ + QVERIFY(QMetaObject::invokeMethod(object, "runEval", Q_ARG(QVariant, QString(string)))); + +inline QVariant runexpr(QQmlEngine *engine, const QString &str) +{ + QQmlExpression expr(engine->rootContext(), 0, str); + return expr.evaluate(); +} + +#define RUNEXPR(string) runexpr(&engine, QString(string)) + +static bool isValidErrorMessage(const QString &msg, bool dynamicRoleTest) +{ + bool valid = true; + + if (msg.isEmpty()) { + valid = false; + } else if (dynamicRoleTest) { + if (msg.contains("Can't assign to existing role") || msg.contains("Can't create role for unsupported data type")) + valid = false; + } + + return valid; +} + +class tst_qquicklistmodel : public QQmlDataTest +{ + Q_OBJECT +public: + tst_qquicklistmodel() {} + +private: + int roleFromName(const QQuickListModel *model, const QString &roleName); + QQuickItem *createWorkerTest(QQmlEngine *eng, QQmlComponent *component, QQuickListModel *model); + void waitForWorker(QQuickItem *item); + + static bool compareVariantList(const QVariantList &testList, QVariant object); + +private slots: + void static_types(); + void static_types_data(); + void static_i18n(); + void static_i18n_data(); + void static_nestedElements(); + void static_nestedElements_data(); + void dynamic_data(); + void dynamic(); + void dynamic_worker_data(); + void dynamic_worker(); + void dynamic_worker_sync_data(); + void dynamic_worker_sync(); + void enumerate(); + void error_data(); + void error(); + void syncError(); + void get(); + void set_data(); + void set(); + void get_data(); + void get_worker(); + void get_worker_data(); + void get_nested(); + void get_nested_data(); + void crash_model_with_multiple_roles(); + void set_model_cache(); + void property_changes(); + void property_changes_data(); + void property_changes_worker(); + void property_changes_worker_data(); + void clear_data(); + void clear(); + void signal_handlers_data(); + void signal_handlers(); + void worker_sync_data(); + void worker_sync(); + void worker_remove_element_data(); + void worker_remove_element(); + void worker_remove_list_data(); + void worker_remove_list(); + void role_mode_data(); + void role_mode(); + void dynamic_role(); + void dynamic_role_data(); +}; + +bool tst_qquicklistmodel::compareVariantList(const QVariantList &testList, QVariant object) +{ + bool allOk = true; + + QQuickListModel *model = qobject_cast(object.value()); + if (model == 0) + return false; + + if (model->count() != testList.count()) + return false; + + for (int i=0 ; i < testList.count() ; ++i) { + const QVariant &testVariant = testList.at(i); + if (testVariant.type() != QVariant::Map) + return false; + const QVariantMap &map = testVariant.toMap(); + + const QList &roles = model->roles(); + + QVariantMap::const_iterator it = map.begin(); + QVariantMap::const_iterator end = map.end(); + + while (it != end) { + const QString &testKey = it.key(); + const QVariant &testData = it.value(); + + int roleIndex = -1; + for (int j=0 ; j < roles.count() ; ++j) { + if (model->toString(roles[j]).compare(testKey) == 0) { + roleIndex = j; + break; + } + } + + if (roleIndex == -1) + return false; + + const QVariant &modelData = model->data(i, roleIndex); + + if (testData.type() == QVariant::List) { + const QVariantList &subList = testData.toList(); + allOk = allOk && compareVariantList(subList, modelData); + } else { + allOk = allOk && (testData == modelData); + } + + ++it; + } + } + + return allOk; +} + +int tst_qquicklistmodel::roleFromName(const QQuickListModel *model, const QString &roleName) +{ + QList roles = model->roles(); + for (int i=0; itoString(roles[i]) == roleName) + return roles[i]; + } + return -1; +} + +QQuickItem *tst_qquicklistmodel::createWorkerTest(QQmlEngine *eng, QQmlComponent *component, QQuickListModel *model) +{ + QQuickItem *item = qobject_cast(component->create()); + QQmlEngine::setContextForObject(model, eng->rootContext()); + if (item) + item->setProperty("model", qVariantFromValue(model)); + return item; +} + +void tst_qquicklistmodel::waitForWorker(QQuickItem *item) +{ + QEventLoop loop; + QTimer timer; + timer.setSingleShot(true); + connect(&timer, SIGNAL(timeout()), &loop, SLOT(quit())); + + QQmlProperty prop(item, "done"); + QVERIFY(prop.isValid()); + QVERIFY(prop.connectNotifySignal(&loop, SLOT(quit()))); + timer.start(10000); + loop.exec(); + QVERIFY(timer.isActive()); +} + +void tst_qquicklistmodel::static_types_data() +{ + QTest::addColumn("qml"); + QTest::addColumn("value"); + QTest::addColumn("error"); + + QTest::newRow("string") + << "ListElement { foo: \"bar\" }" + << QVariant(QString("bar")) + << QString(); + + QTest::newRow("real") + << "ListElement { foo: 10.5 }" + << QVariant(10.5) + << QString(); + + QTest::newRow("real0") + << "ListElement { foo: 0 }" + << QVariant(double(0)) + << QString(); + + QTest::newRow("bool") + << "ListElement { foo: false }" + << QVariant(false) + << QString(); + + QTest::newRow("bool") + << "ListElement { foo: true }" + << QVariant(true) + << QString(); + + QTest::newRow("enum") + << "ListElement { foo: Text.AlignHCenter }" + << QVariant(double(QQuickText::AlignHCenter)) + << QString(); + + QTest::newRow("Qt enum") + << "ListElement { foo: Qt.AlignBottom }" + << QVariant(double(Qt::AlignBottom)) + << QString(); + + QTest::newRow("role error") + << "ListElement { foo: 1 } ListElement { foo: 'string' }" + << QVariant() + << QString(": Can't assign to existing role 'foo' of different type [String -> Number]"); + + QTest::newRow("list type error") + << "ListElement { foo: 1 } ListElement { foo: ListElement { bar: 1 } }" + << QVariant() + << QString(": Can't assign to existing role 'foo' of different type [List -> Number]"); +} + +void tst_qquicklistmodel::static_types() +{ + QFETCH(QString, qml); + QFETCH(QVariant, value); + QFETCH(QString, error); + + qml = "import QtQuick 2.0\nItem { property variant test: model.get(0).foo; ListModel { id: model; " + qml + " } }"; + + if (!error.isEmpty()) { + QTest::ignoreMessage(QtWarningMsg, error.toLatin1()); + } + + QQmlEngine engine; + QQmlComponent component(&engine); + component.setData(qml.toUtf8(), + QUrl::fromLocalFile(QString("dummy.qml"))); + + QVERIFY(!component.isError()); + + QObject *obj = component.create(); + QVERIFY(obj != 0); + + if (error.isEmpty()) { + QVariant actual = obj->property("test"); + + QCOMPARE(actual, value); + QCOMPARE(actual.toString(), value.toString()); + } + + delete obj; +} + +void tst_qquicklistmodel::static_i18n_data() +{ + QTest::addColumn("qml"); + QTest::addColumn("value"); + QTest::addColumn("error"); + + QTest::newRow("QT_TR_NOOP") + << QString::fromUtf8("ListElement { foo: QT_TR_NOOP(\"na\303\257ve\") }") + << QVariant(QString::fromUtf8("na\303\257ve")) + << QString(); + + QTest::newRow("QT_TRANSLATE_NOOP") + << "ListElement { foo: QT_TRANSLATE_NOOP(\"MyListModel\", \"hello\") }" + << QVariant(QString("hello")) + << QString(); + + QTest::newRow("QT_TRID_NOOP") + << QString::fromUtf8("ListElement { foo: QT_TRID_NOOP(\"qtn_1st_text\") }") + << QVariant(QString("qtn_1st_text")) + << QString(); + + QTest::newRow("QT_TR_NOOP extra param") + << QString::fromUtf8("ListElement { foo: QT_TR_NOOP(\"hello\",\"world\") }") + << QVariant(QString()) + << QString("ListElement: improperly specified QT_TR_NOOP"); + + QTest::newRow("QT_TRANSLATE_NOOP missing params") + << "ListElement { foo: QT_TRANSLATE_NOOP() }" + << QVariant(QString()) + << QString("ListElement: improperly specified QT_TRANSLATE_NOOP"); + + QTest::newRow("QT_TRID_NOOP missing param") + << QString::fromUtf8("ListElement { foo: QT_TRID_NOOP() }") + << QVariant(QString()) + << QString("ListElement: improperly specified QT_TRID_NOOP"); +} + +void tst_qquicklistmodel::static_i18n() +{ + QFETCH(QString, qml); + QFETCH(QVariant, value); + QFETCH(QString, error); + + qml = "import QtQuick 2.0\nItem { property variant test: model.get(0).foo; ListModel { id: model; " + qml + " } }"; + + QQmlEngine engine; + QQmlComponent component(&engine); + component.setData(qml.toUtf8(), + QUrl::fromLocalFile(QString("dummy.qml"))); + + if (!error.isEmpty()) { + QVERIFY(component.isError()); + QCOMPARE(component.errors().at(0).description(), error); + return; + } + + QVERIFY(!component.isError()); + + QObject *obj = component.create(); + QVERIFY(obj != 0); + + QVariant actual = obj->property("test"); + + QCOMPARE(actual, value); + QCOMPARE(actual.toString(), value.toString()); + + delete obj; +} + +void tst_qquicklistmodel::static_nestedElements() +{ + QFETCH(int, elementCount); + + QStringList elements; + for (int i=0; iproperty("count"); + QCOMPARE(count.type(), QVariant::Int); + QCOMPARE(count.toInt(), elementCount); + + delete obj; +} + +void tst_qquicklistmodel::static_nestedElements_data() +{ + QTest::addColumn("elementCount"); + + QTest::newRow("0 items") << 0; + QTest::newRow("1 item") << 1; + QTest::newRow("2 items") << 2; + QTest::newRow("many items") << 5; +} + +void tst_qquicklistmodel::dynamic_data() +{ + QTest::addColumn("script"); + QTest::addColumn("result"); + QTest::addColumn("warning"); + QTest::addColumn("dynamicRoles"); + + for (int i=0 ; i < 2 ; ++i) { + bool dr = (i != 0); + + // Simple flat model + QTest::newRow("count") << "count" << 0 << "" << dr; + + QTest::newRow("get1") << "{get(0) === undefined}" << 1 << "" << dr; + QTest::newRow("get2") << "{get(-1) === undefined}" << 1 << "" << dr; + QTest::newRow("get3") << "{append({'foo':123});get(0) != undefined}" << 1 << "" << dr; + QTest::newRow("get4") << "{append({'foo':123});get(0).foo}" << 123 << "" << dr; + QTest::newRow("get-modify1") << "{append({'foo':123,'bar':456});get(0).foo = 333;get(0).foo}" << 333 << "" << dr; + QTest::newRow("get-modify2") << "{append({'z':1});append({'foo':123,'bar':456});get(1).bar = 999;get(1).bar}" << 999 << "" << dr; + + QTest::newRow("append1") << "{append({'foo':123});count}" << 1 << "" << dr; + QTest::newRow("append2") << "{append({'foo':123,'bar':456});count}" << 1 << "" << dr; + QTest::newRow("append3a") << "{append({'foo':123});append({'foo':456});get(0).foo}" << 123 << "" << dr; + QTest::newRow("append3b") << "{append({'foo':123});append({'foo':456});get(1).foo}" << 456 << "" << dr; + QTest::newRow("append4a") << "{append(123)}" << 0 << ": QML ListModel: append: value is not an object" << dr; + QTest::newRow("append4b") << "{append([{'foo':123},{'foo':456},{'foo':789}]);count}" << 3 << "" << dr; + QTest::newRow("append4c") << "{append([{'foo':123},{'foo':456},{'foo':789}]);get(1).foo}" << 456 << "" << dr; + + QTest::newRow("clear1") << "{append({'foo':456});clear();count}" << 0 << "" << dr; + QTest::newRow("clear2") << "{append({'foo':123});append({'foo':456});clear();count}" << 0 << "" << dr; + QTest::newRow("clear3") << "{append({'foo':123});clear()}" << 0 << "" << dr; + + QTest::newRow("remove1") << "{append({'foo':123});remove(0);count}" << 0 << "" << dr; + QTest::newRow("remove2a") << "{append({'foo':123});append({'foo':456});remove(0);count}" << 1 << "" << dr; + QTest::newRow("remove2b") << "{append({'foo':123});append({'foo':456});remove(0);get(0).foo}" << 456 << "" << dr; + QTest::newRow("remove2c") << "{append({'foo':123});append({'foo':456});remove(1);get(0).foo}" << 123 << "" << dr; + QTest::newRow("remove3") << "{append({'foo':123});remove(0)}" << 0 << "" << dr; + QTest::newRow("remove3a") << "{append({'foo':123});remove(-1);count}" << 1 << ": QML ListModel: remove: indices [-1 - 0] out of range [0 - 1]" << dr; + QTest::newRow("remove4a") << "{remove(0)}" << 0 << ": QML ListModel: remove: indices [0 - 1] out of range [0 - 0]" << dr; + QTest::newRow("remove4b") << "{append({'foo':123});remove(0);remove(0);count}" << 0 << ": QML ListModel: remove: indices [0 - 1] out of range [0 - 0]" << dr; + QTest::newRow("remove4c") << "{append({'foo':123});remove(1);count}" << 1 << ": QML ListModel: remove: indices [1 - 2] out of range [0 - 1]" << dr; + QTest::newRow("remove5a") << "{append({'foo':123});append({'foo':456});remove(0,2);count}" << 0 << "" << dr; + QTest::newRow("remove5b") << "{append({'foo':123});append({'foo':456});remove(0,1);count}" << 1 << "" << dr; + QTest::newRow("remove5c") << "{append({'foo':123});append({'foo':456});remove(1,1);count}" << 1 << "" << dr; + QTest::newRow("remove5d") << "{append({'foo':123});append({'foo':456});remove(0,1);get(0).foo}" << 456 << "" << dr; + QTest::newRow("remove5e") << "{append({'foo':123});append({'foo':456});remove(1,1);get(0).foo}" << 123 << "" << dr; + QTest::newRow("remove5f") << "{append({'foo':123});append({'foo':456});append({'foo':789});remove(0,1);remove(1,1);get(0).foo}" << 456 << "" << dr; + QTest::newRow("remove6a") << "{remove();count}" << 0 << ": QML ListModel: remove: incorrect number of arguments" << dr; + QTest::newRow("remove6b") << "{remove(1,2,3);count}" << 0 << ": QML ListModel: remove: incorrect number of arguments" << dr; + QTest::newRow("remove7a") << "{append({'foo':123});remove(0,0);count}" << 1 << ": QML ListModel: remove: indices [0 - 0] out of range [0 - 1]" << dr; + QTest::newRow("remove7b") << "{append({'foo':123});remove(0,-1);count}" << 1 << ": QML ListModel: remove: indices [0 - -1] out of range [0 - 1]" << dr; + + QTest::newRow("insert1") << "{insert(0,{'foo':123});count}" << 1 << "" << dr; + QTest::newRow("insert2") << "{insert(1,{'foo':123});count}" << 0 << ": QML ListModel: insert: index 1 out of range" << dr; + QTest::newRow("insert3a") << "{append({'foo':123});insert(1,{'foo':456});count}" << 2 << "" << dr; + QTest::newRow("insert3b") << "{append({'foo':123});insert(1,{'foo':456});get(0).foo}" << 123 << "" << dr; + QTest::newRow("insert3c") << "{append({'foo':123});insert(1,{'foo':456});get(1).foo}" << 456 << "" << dr; + QTest::newRow("insert3d") << "{append({'foo':123});insert(0,{'foo':456});get(0).foo}" << 456 << "" << dr; + QTest::newRow("insert3e") << "{append({'foo':123});insert(0,{'foo':456});get(1).foo}" << 123 << "" << dr; + QTest::newRow("insert4") << "{append({'foo':123});insert(-1,{'foo':456});count}" << 1 << ": QML ListModel: insert: index -1 out of range" << dr; + QTest::newRow("insert5a") << "{insert(0,123)}" << 0 << ": QML ListModel: insert: value is not an object" << dr; + QTest::newRow("insert5b") << "{insert(0,[{'foo':11},{'foo':22},{'foo':33}]);count}" << 3 << "" << dr; + QTest::newRow("insert5c") << "{insert(0,[{'foo':11},{'foo':22},{'foo':33}]);get(2).foo}" << 33 << "" << dr; + + QTest::newRow("set1") << "{append({'foo':123});set(0,{'foo':456});count}" << 1 << "" << dr; + QTest::newRow("set2") << "{append({'foo':123});set(0,{'foo':456});get(0).foo}" << 456 << "" << dr; + QTest::newRow("set3a") << "{append({'foo':123,'bar':456});set(0,{'foo':999});get(0).foo}" << 999 << "" << dr; + QTest::newRow("set3b") << "{append({'foo':123,'bar':456});set(0,{'foo':999});get(0).bar}" << 456 << "" << dr; + QTest::newRow("set4a") << "{set(0,{'foo':456});count}" << 1 << "" << dr; + QTest::newRow("set4c") << "{set(-1,{'foo':456})}" << 0 << ": QML ListModel: set: index -1 out of range" << dr; + QTest::newRow("set5a") << "{append({'foo':123,'bar':456});set(0,123);count}" << 1 << ": QML ListModel: set: value is not an object" << dr; + QTest::newRow("set5b") << "{append({'foo':123,'bar':456});set(0,[1,2,3]);count}" << 1 << ": QML ListModel: set: value is not an object" << dr; + QTest::newRow("set6") << "{append({'foo':123});set(1,{'foo':456});count}" << 2 << "" << dr; + + QTest::newRow("setprop1") << "{append({'foo':123});setProperty(0,'foo',456);count}" << 1 << "" << dr; + QTest::newRow("setprop2") << "{append({'foo':123});setProperty(0,'foo',456);get(0).foo}" << 456 << "" << dr; + QTest::newRow("setprop3a") << "{append({'foo':123,'bar':456});setProperty(0,'foo',999);get(0).foo}" << 999 << "" << dr; + QTest::newRow("setprop3b") << "{append({'foo':123,'bar':456});setProperty(0,'foo',999);get(0).bar}" << 456 << "" << dr; + QTest::newRow("setprop4a") << "{setProperty(0,'foo',456)}" << 0 << ": QML ListModel: set: index 0 out of range" << dr; + QTest::newRow("setprop4b") << "{setProperty(-1,'foo',456)}" << 0 << ": QML ListModel: set: index -1 out of range" << dr; + QTest::newRow("setprop4c") << "{append({'foo':123,'bar':456});setProperty(1,'foo',456);count}" << 1 << ": QML ListModel: set: index 1 out of range" << dr; + QTest::newRow("setprop5") << "{append({'foo':123,'bar':456});append({'foo':111});setProperty(1,'bar',222);get(1).bar}" << 222 << "" << dr; + + QTest::newRow("move1a") << "{append({'foo':123});append({'foo':456});move(0,1,1);count}" << 2 << "" << dr; + QTest::newRow("move1b") << "{append({'foo':123});append({'foo':456});move(0,1,1);get(0).foo}" << 456 << "" << dr; + QTest::newRow("move1c") << "{append({'foo':123});append({'foo':456});move(0,1,1);get(1).foo}" << 123 << "" << dr; + QTest::newRow("move1d") << "{append({'foo':123});append({'foo':456});move(1,0,1);get(0).foo}" << 456 << "" << dr; + QTest::newRow("move1e") << "{append({'foo':123});append({'foo':456});move(1,0,1);get(1).foo}" << 123 << "" << dr; + QTest::newRow("move2a") << "{append({'foo':123});append({'foo':456});append({'foo':789});move(0,1,2);count}" << 3 << "" << dr; + QTest::newRow("move2b") << "{append({'foo':123});append({'foo':456});append({'foo':789});move(0,1,2);get(0).foo}" << 789 << "" << dr; + QTest::newRow("move2c") << "{append({'foo':123});append({'foo':456});append({'foo':789});move(0,1,2);get(1).foo}" << 123 << "" << dr; + QTest::newRow("move2d") << "{append({'foo':123});append({'foo':456});append({'foo':789});move(0,1,2);get(2).foo}" << 456 << "" << dr; + QTest::newRow("move3a") << "{append({'foo':123});append({'foo':456});append({'foo':789});move(1,0,3);count}" << 3 << ": QML ListModel: move: out of range" << dr; + QTest::newRow("move3b") << "{append({'foo':123});append({'foo':456});append({'foo':789});move(1,-1,1);count}" << 3 << ": QML ListModel: move: out of range" << dr; + QTest::newRow("move3c") << "{append({'foo':123});append({'foo':456});append({'foo':789});move(1,0,-1);count}" << 3 << ": QML ListModel: move: out of range" << dr; + QTest::newRow("move3d") << "{append({'foo':123});append({'foo':456});append({'foo':789});move(0,3,1);count}" << 3 << ": QML ListModel: move: out of range" << dr; + + QTest::newRow("large1") << "{append({'a':1,'b':2,'c':3,'d':4,'e':5,'f':6,'g':7,'h':8});get(0).h}" << 8 << "" << dr; + + QTest::newRow("datatypes1") << "{append({'a':1});append({'a':'string'});}" << 0 << ": Can't assign to existing role 'a' of different type [String -> Number]" << dr; + + QTest::newRow("null") << "{append({'a':null});}" << 0 << "" << dr; + QTest::newRow("setNull") << "{append({'a':1});set(0, {'a':null});}" << 0 << "" << dr; + QTest::newRow("setString") << "{append({'a':'hello'});set(0, {'a':'world'});get(0).a == 'world'}" << 1 << "" << dr; + QTest::newRow("setInt") << "{append({'a':5});set(0, {'a':10});get(0).a}" << 10 << "" << dr; + QTest::newRow("setNumber") << "{append({'a':6});set(0, {'a':5.5});get(0).a < 5.6}" << 1 << "" << dr; + QTest::newRow("badType0") << "{append({'a':'hello'});set(0, {'a':1});}" << 0 << ": Can't assign to existing role 'a' of different type [Number -> String]" << dr; + QTest::newRow("invalidInsert0") << "{insert(0);}" << 0 << ": QML ListModel: insert: value is not an object" << dr; + QTest::newRow("invalidAppend0") << "{append();}" << 0 << ": QML ListModel: append: value is not an object" << dr; + QTest::newRow("invalidInsert1") << "{insert(0, 34);}" << 0 << ": QML ListModel: insert: value is not an object" << dr; + QTest::newRow("invalidAppend1") << "{append(37);}" << 0 << ": QML ListModel: append: value is not an object" << dr; + + // QObjects + QTest::newRow("qobject0") << "{append({'a':dummyItem0});}" << 0 << "" << dr; + QTest::newRow("qobject1") << "{append({'a':dummyItem0});set(0,{'a':dummyItem1});get(0).a == dummyItem1;}" << 1 << "" << dr; + QTest::newRow("qobject2") << "{append({'a':dummyItem0});get(0).a == dummyItem0;}" << 1 << "" << dr; + QTest::newRow("qobject3") << "{append({'a':dummyItem0});append({'b':1});}" << 0 << "" << dr; + + // JS objects + QTest::newRow("js1") << "{append({'foo':{'prop':1}});count}" << 1 << "" << dr; + QTest::newRow("js2") << "{append({'foo':{'prop':27}});get(0).foo.prop}" << 27 << "" << dr; + QTest::newRow("js3") << "{append({'foo':{'prop':27}});append({'bar':1});count}" << 2 << "" << dr; + QTest::newRow("js4") << "{append({'foo':{'prop':27}});append({'bar':1});set(0, {'foo':{'prop':28}});get(0).foo.prop}" << 28 << "" << dr; + QTest::newRow("js5") << "{append({'foo':{'prop':27}});append({'bar':1});set(1, {'foo':{'prop':33}});get(1).foo.prop}" << 33 << "" << dr; + QTest::newRow("js6") << "{append({'foo':{'prop':27}});clear();count}" << 0 << "" << dr; + QTest::newRow("js7") << "{append({'foo':{'prop':27}});set(0, {'foo':null});count}" << 1 << "" << dr; + QTest::newRow("js8") << "{append({'foo':{'prop':27}});set(0, {'foo':{'prop2':31}});get(0).foo.prop2}" << 31 << "" << dr; + + // Nested models + QTest::newRow("nested-append1") << "{append({'foo':123,'bars':[{'a':1},{'a':2},{'a':3}]});count}" << 1 << "" << dr; + QTest::newRow("nested-append2") << "{append({'foo':123,'bars':[{'a':1},{'a':2},{'a':3}]});get(0).bars.get(1).a}" << 2 << "" << dr; + QTest::newRow("nested-append3") << "{append({'foo':123,'bars':[{'a':1},{'a':2},{'a':3}]});get(0).bars.append({'a':4});get(0).bars.get(3).a}" << 4 << "" << dr; + + QTest::newRow("nested-insert") << "{append({'foo':123});insert(0,{'bars':[{'a':1},{'b':2},{'c':3}]});get(0).bars.get(0).a}" << 1 << "" << dr; + QTest::newRow("nested-set") << "{append({'foo':[{'x':1}]});set(0,{'foo':[{'x':123}]});get(0).foo.get(0).x}" << 123 << "" << dr; + + QTest::newRow("nested-count") << "{append({'foo':123,'bars':[{'a':1},{'a':2},{'a':3}]}); get(0).bars.count}" << 3 << "" << dr; + QTest::newRow("nested-clear") << "{append({'foo':123,'bars':[{'a':1},{'a':2},{'a':3}]}); get(0).bars.clear(); get(0).bars.count}" << 0 << "" << dr; + } +} + +void tst_qquicklistmodel::dynamic() +{ + QFETCH(QString, script); + QFETCH(int, result); + QFETCH(QString, warning); + QFETCH(bool, dynamicRoles); + + QQuickItem dummyItem0, dummyItem1; + QQmlEngine engine; + QQuickListModel model; + model.setDynamicRoles(dynamicRoles); + QQmlEngine::setContextForObject(&model,engine.rootContext()); + engine.rootContext()->setContextObject(&model); + engine.rootContext()->setContextProperty("dummyItem0", QVariant::fromValue(&dummyItem0)); + engine.rootContext()->setContextProperty("dummyItem1", QVariant::fromValue(&dummyItem1)); + QQmlExpression e(engine.rootContext(), &model, script); + if (isValidErrorMessage(warning, dynamicRoles)) + QTest::ignoreMessage(QtWarningMsg, warning.toLatin1()); + + QSignalSpy spyCount(&model, SIGNAL(countChanged())); + + int actual = e.evaluate().toInt(); + if (e.hasError()) + qDebug() << e.error(); // errors not expected + + QCOMPARE(actual,result); + + if (model.count() > 0) + QVERIFY(spyCount.count() > 0); +} + +void tst_qquicklistmodel::dynamic_worker_data() +{ + dynamic_data(); +} + +void tst_qquicklistmodel::dynamic_worker() +{ + QFETCH(QString, script); + QFETCH(int, result); + QFETCH(QString, warning); + QFETCH(bool, dynamicRoles); + + if (QByteArray(QTest::currentDataTag()).startsWith("qobject")) + return; + + // This is same as dynamic() except it applies the test to a ListModel called + // from a WorkerScript. + + QQuickListModel model; + model.setDynamicRoles(dynamicRoles); + QQmlEngine eng; + QQmlComponent component(&eng, testFileUrl("model.qml")); + QQuickItem *item = createWorkerTest(&eng, &component, &model); + QVERIFY(item != 0); + + QSignalSpy spyCount(&model, SIGNAL(countChanged())); + + if (script[0] == QLatin1Char('{') && script[script.length()-1] == QLatin1Char('}')) + script = script.mid(1, script.length() - 2); + QVariantList operations; + foreach (const QString &s, script.split(';')) { + if (!s.isEmpty()) + operations << s; + } + + if (isValidErrorMessage(warning, dynamicRoles)) + QTest::ignoreMessage(QtWarningMsg, warning.toLatin1()); + + QVERIFY(QMetaObject::invokeMethod(item, "evalExpressionViaWorker", + Q_ARG(QVariant, operations))); + waitForWorker(item); + QCOMPARE(QQmlProperty(item, "result").read().toInt(), result); + + if (model.count() > 0) + QVERIFY(spyCount.count() > 0); + + delete item; + qApp->processEvents(); +} + +void tst_qquicklistmodel::dynamic_worker_sync_data() +{ + dynamic_data(); +} + +void tst_qquicklistmodel::dynamic_worker_sync() +{ + QFETCH(QString, script); + QFETCH(int, result); + QFETCH(QString, warning); + QFETCH(bool, dynamicRoles); + + if (QByteArray(QTest::currentDataTag()).startsWith("qobject")) + return; + + // This is the same as dynamic_worker() except that it executes a set of list operations + // from the worker script, calls sync(), and tests the changes are reflected in the + // list in the main thread + + QQuickListModel model; + model.setDynamicRoles(dynamicRoles); + QQmlEngine eng; + QQmlComponent component(&eng, testFileUrl("model.qml")); + QQuickItem *item = createWorkerTest(&eng, &component, &model); + QVERIFY(item != 0); + + if (script[0] == QLatin1Char('{') && script[script.length()-1] == QLatin1Char('}')) + script = script.mid(1, script.length() - 2); + QVariantList operations; + foreach (const QString &s, script.split(';')) { + if (!s.isEmpty()) + operations << s; + } + + if (isValidErrorMessage(warning, dynamicRoles)) + QTest::ignoreMessage(QtWarningMsg, warning.toLatin1()); + + // execute a set of commands on the worker list model, then check the + // changes are reflected in the list model in the main thread + QVERIFY(QMetaObject::invokeMethod(item, "evalExpressionViaWorker", + Q_ARG(QVariant, operations.mid(0, operations.length()-1)))); + waitForWorker(item); + + QQmlExpression e(eng.rootContext(), &model, operations.last().toString()); + QCOMPARE(e.evaluate().toInt(), result); + + delete item; + qApp->processEvents(); +} + +void tst_qquicklistmodel::enumerate() +{ + QQmlEngine eng; + QQmlComponent component(&eng, testFileUrl("enumerate.qml")); + QVERIFY(!component.isError()); + QQuickItem *item = qobject_cast(component.create()); + QVERIFY(item != 0); + + QLatin1String expectedStrings[] = { + QLatin1String("val1=1Y"), + QLatin1String("val2=2Y"), + QLatin1String("val3=strY"), + QLatin1String("val4=falseN"), + QLatin1String("val5=trueY") + }; + + int expectedStringCount = sizeof(expectedStrings) / sizeof(expectedStrings[0]); + + QStringList r = item->property("result").toString().split(":"); + + int matchCount = 0; + for (int i=0 ; i < expectedStringCount ; ++i) { + const QLatin1String &expectedString = expectedStrings[i]; + + QStringList::const_iterator it = r.begin(); + QStringList::const_iterator end = r.end(); + + while (it != end) { + if (it->compare(expectedString) == 0) { + ++matchCount; + break; + } + ++it; + } + } + + QVERIFY(matchCount == expectedStringCount); + + delete item; +} + +void tst_qquicklistmodel::error_data() +{ + QTest::addColumn("qml"); + QTest::addColumn("error"); + + QTest::newRow("id not allowed in ListElement") + << "import QtQuick 2.0\nListModel { ListElement { id: fred } }" + << "ListElement: cannot use reserved \"id\" property"; + + QTest::newRow("id allowed in ListModel") + << "import QtQuick 2.0\nListModel { id:model }" + << ""; + + QTest::newRow("random properties not allowed in ListModel") + << "import QtQuick 2.0\nListModel { foo:123 }" + << "ListModel: undefined property 'foo'"; + + QTest::newRow("random properties allowed in ListElement") + << "import QtQuick 2.0\nListModel { ListElement { foo:123 } }" + << ""; + + QTest::newRow("bindings not allowed in ListElement") + << "import QtQuick 2.0\nRectangle { id: rect; ListModel { ListElement { foo: rect.color } } }" + << "ListElement: cannot use script for property value"; + + QTest::newRow("random object list properties allowed in ListElement") + << "import QtQuick 2.0\nListModel { ListElement { foo: [ ListElement { bar: 123 } ] } }" + << ""; + + QTest::newRow("default properties not allowed in ListElement") + << "import QtQuick 2.0\nListModel { ListElement { Item { } } }" + << "ListElement: cannot contain nested elements"; + + QTest::newRow("QML elements not allowed in ListElement") + << "import QtQuick 2.0\nListModel { ListElement { a: Item { } } }" + << "ListElement: cannot contain nested elements"; + + QTest::newRow("qualified ListElement supported") + << "import QtQuick 2.0 as Foo\nFoo.ListModel { Foo.ListElement { a: 123 } }" + << ""; + + QTest::newRow("qualified ListElement required") + << "import QtQuick 2.0 as Foo\nFoo.ListModel { ListElement { a: 123 } }" + << "ListElement is not a type"; + + QTest::newRow("unknown qualified ListElement not allowed") + << "import QtQuick 2.0\nListModel { Foo.ListElement { a: 123 } }" + << "Foo.ListElement - Foo is not a namespace"; +} + +void tst_qquicklistmodel::error() +{ + QFETCH(QString, qml); + QFETCH(QString, error); + + QQmlEngine engine; + QQmlComponent component(&engine); + component.setData(qml.toUtf8(), + QUrl::fromLocalFile(QString("dummy.qml"))); + if (error.isEmpty()) { + QVERIFY(!component.isError()); + } else { + QVERIFY(component.isError()); + QList errors = component.errors(); + QCOMPARE(errors.count(),1); + QCOMPARE(errors.at(0).description(),error); + } +} + +void tst_qquicklistmodel::syncError() +{ + QString qml = "import QtQuick 2.0\nListModel { id: lm; Component.onCompleted: lm.sync() }"; + QString error = "file:dummy.qml:2:1: QML ListModel: List sync() can only be called from a WorkerScript"; + + QQmlEngine engine; + QQmlComponent component(&engine); + component.setData(qml.toUtf8(), + QUrl::fromLocalFile(QString("dummy.qml"))); + QTest::ignoreMessage(QtWarningMsg,error.toUtf8()); + QObject *obj = component.create(); + QVERIFY(obj); + delete obj; +} + +/* + Test model changes from set() are available to the view +*/ +void tst_qquicklistmodel::set_data() +{ + QTest::addColumn("dynamicRoles"); + + QTest::newRow("staticRoles") << false; + QTest::newRow("dynamicRoles") << true; +} + +void tst_qquicklistmodel::set() +{ + QFETCH(bool, dynamicRoles); + + QQmlEngine engine; + QQuickListModel model; + model.setDynamicRoles(dynamicRoles); + QQmlEngine::setContextForObject(&model,engine.rootContext()); + engine.rootContext()->setContextProperty("model", &model); + + RUNEXPR("model.append({test:false})"); + RUNEXPR("model.set(0, {test:true})"); + + QCOMPARE(RUNEXPR("model.get(0).test").toBool(), true); // triggers creation of model cache + QCOMPARE(model.data(0, model.roles()[0]), qVariantFromValue(true)); + + RUNEXPR("model.set(0, {test:false})"); + QCOMPARE(RUNEXPR("model.get(0).test").toBool(), false); // tests model cache is updated + QCOMPARE(model.data(0, model.roles()[0]), qVariantFromValue(false)); + + QString warning = QString::fromLatin1(": Can't create role for unsupported data type"); + if (isValidErrorMessage(warning, dynamicRoles)) + QTest::ignoreMessage(QtWarningMsg, warning.toLatin1()); + QVariant invalidData = QColor(); + model.setProperty(0, "test", invalidData); +} + +/* + Test model changes on values returned by get() are available to the view +*/ +void tst_qquicklistmodel::get() +{ + QFETCH(QString, expression); + QFETCH(int, index); + QFETCH(QString, roleName); + QFETCH(QVariant, roleValue); + QFETCH(bool, dynamicRoles); + + QQmlEngine engine; + QQmlComponent component(&engine); + component.setData( + "import QtQuick 2.0\n" + "ListModel {}\n", QUrl()); + QQuickListModel *model = qobject_cast(component.create()); + model->setDynamicRoles(dynamicRoles); + engine.rootContext()->setContextProperty("model", model); + + RUNEXPR("model.append({roleA: 100})"); + RUNEXPR("model.append({roleA: 200, roleB: 400})"); + RUNEXPR("model.append({roleA: 200, roleB: 400})"); + RUNEXPR("model.append({roleC: {} })"); + RUNEXPR("model.append({roleD: [ { a:1, b:2 }, { c: 3 } ] })"); + + QSignalSpy spy(model, SIGNAL(itemsChanged(int, int, QList))); + QQmlExpression expr(engine.rootContext(), model, expression); + expr.evaluate(); + QVERIFY(!expr.hasError()); + + int role = roleFromName(model, roleName); + QVERIFY(role >= 0); + + if (roleValue.type() == QVariant::List) { + const QVariantList &list = roleValue.toList(); + QVERIFY(compareVariantList(list, model->data(index, role))); + } else { + QCOMPARE(model->data(index, role), roleValue); + } + + QCOMPARE(spy.count(), 1); + + QList spyResult = spy.takeFirst(); + QCOMPARE(spyResult.at(0).toInt(), index); + QCOMPARE(spyResult.at(1).toInt(), 1); // only 1 item is modified at a time + QCOMPARE(spyResult.at(2).value >(), (QList() << role)); + + delete model; +} + +void tst_qquicklistmodel::get_data() +{ + QTest::addColumn("expression"); + QTest::addColumn("index"); + QTest::addColumn("roleName"); + QTest::addColumn("roleValue"); + QTest::addColumn("dynamicRoles"); + + for (int i=0 ; i < 2 ; ++i) { + bool dr = (i != 0); + + QTest::newRow("simple value") << "get(0).roleA = 500" << 0 << "roleA" << QVariant(500) << dr; + QTest::newRow("simple value 2") << "get(1).roleB = 500" << 1 << "roleB" << QVariant(500) << dr; + + QVariantMap map; + QVariantList list; + map.clear(); map["a"] = 50; map["b"] = 500; + list << map; + map.clear(); map["c"] = 1000; + list << map; + QTest::newRow("list of objects") << "get(2).roleD = [{'a': 50, 'b': 500}, {'c': 1000}]" << 2 << "roleD" << QVariant::fromValue(list) << dr; + } +} + +void tst_qquicklistmodel::get_worker() +{ + QFETCH(QString, expression); + QFETCH(int, index); + QFETCH(QString, roleName); + QFETCH(QVariant, roleValue); + QFETCH(bool, dynamicRoles); + + QQuickListModel model; + model.setDynamicRoles(dynamicRoles); + QQmlEngine eng; + QQmlComponent component(&eng, testFileUrl("model.qml")); + QQuickItem *item = createWorkerTest(&eng, &component, &model); + QVERIFY(item != 0); + + // Add some values like get() test + RUNEVAL(item, "model.append({roleA: 100})"); + RUNEVAL(item, "model.append({roleA: 200, roleB: 400})"); + RUNEVAL(item, "model.append({roleA: 200, roleB: 400})"); + RUNEVAL(item, "model.append({roleC: {} })"); + RUNEVAL(item, "model.append({roleD: [ { a:1, b:2 }, { c: 3 } ] })"); + + int role = roleFromName(&model, roleName); + QVERIFY(role >= 0); + + QSignalSpy spy(&model, SIGNAL(itemsChanged(int, int, QList))); + + // in the worker thread, change the model data and call sync() + QVERIFY(QMetaObject::invokeMethod(item, "evalExpressionViaWorker", + Q_ARG(QVariant, QStringList(expression)))); + waitForWorker(item); + + // see if we receive the model changes in the main thread's model + if (roleValue.type() == QVariant::List) { + const QVariantList &list = roleValue.toList(); + QVERIFY(compareVariantList(list, model.data(index, role))); + } else { + QCOMPARE(model.data(index, role), roleValue); + } + + QCOMPARE(spy.count(), 1); + + QList spyResult = spy.takeFirst(); + QCOMPARE(spyResult.at(0).toInt(), index); + QCOMPARE(spyResult.at(1).toInt(), 1); // only 1 item is modified at a time + QVERIFY(spyResult.at(2).value >().contains(role)); +} + +void tst_qquicklistmodel::get_worker_data() +{ + get_data(); +} + +/* + Test that the tests run in get() also work for nested list data +*/ +void tst_qquicklistmodel::get_nested() +{ + QFETCH(QString, expression); + QFETCH(int, index); + QFETCH(QString, roleName); + QFETCH(QVariant, roleValue); + QFETCH(bool, dynamicRoles); + + if (roleValue.type() == QVariant::Map) + return; + + QQmlEngine engine; + QQmlComponent component(&engine); + component.setData( + "import QtQuick 2.0\n" + "ListModel {}", QUrl()); + QQuickListModel *model = qobject_cast(component.create()); + model->setDynamicRoles(dynamicRoles); + QVERIFY(component.errorString().isEmpty()); + QQuickListModel *childModel; + engine.rootContext()->setContextProperty("model", model); + + RUNEXPR("model.append({ listRoleA: [\n" + "{ roleA: 100 },\n" + "{ roleA: 200, roleB: 400 },\n" + "{ roleA: 200, roleB: 400 }, \n" + "{ roleC: {} }, \n" + "{ roleD: [ { a: 1, b:2 }, { c: 3 } ] } \n" + "] })\n"); + + RUNEXPR("model.append({ listRoleA: [\n" + "{ roleA: 100 },\n" + "{ roleA: 200, roleB: 400 },\n" + "{ roleA: 200, roleB: 400 }, \n" + "{ roleC: {} }, \n" + "{ roleD: [ { a: 1, b:2 }, { c: 3 } ] } \n" + "],\n" + "listRoleB: [\n" + "{ roleA: 100 },\n" + "{ roleA: 200, roleB: 400 },\n" + "{ roleA: 200, roleB: 400 }, \n" + "{ roleC: {} }, \n" + "{ roleD: [ { a: 1, b:2 }, { c: 3 } ] } \n" + "],\n" + "listRoleC: [\n" + "{ roleA: 100 },\n" + "{ roleA: 200, roleB: 400 },\n" + "{ roleA: 200, roleB: 400 }, \n" + "{ roleC: {} }, \n" + "{ roleD: [ { a: 1, b:2 }, { c: 3 } ] } \n" + "] })\n"); + + // Test setting the inner list data for: + // get(0).listRoleA + // get(1).listRoleA + // get(1).listRoleB + // get(1).listRoleC + + QList > testData; + testData << qMakePair(0, QString("listRoleA")); + testData << qMakePair(1, QString("listRoleA")); + testData << qMakePair(1, QString("listRoleB")); + testData << qMakePair(1, QString("listRoleC")); + + for (int i=0; i= 0); + + childModel = qobject_cast(model->data(outerListIndex, outerListRole).value()); + QVERIFY(childModel); + + QString extendedExpression = QString("get(%1).%2.%3").arg(outerListIndex).arg(outerListRoleName).arg(expression); + QQmlExpression expr(engine.rootContext(), model, extendedExpression); + + QSignalSpy spy(childModel, SIGNAL(itemsChanged(int, int, QList))); + expr.evaluate(); + QVERIFY(!expr.hasError()); + + int role = roleFromName(childModel, roleName); + QVERIFY(role >= 0); + if (roleValue.type() == QVariant::List) { + QVERIFY(compareVariantList(roleValue.toList(), childModel->data(index, role))); + } else { + QCOMPARE(childModel->data(index, role), roleValue); + } + QCOMPARE(spy.count(), 1); + + QList spyResult = spy.takeFirst(); + QCOMPARE(spyResult.at(0).toInt(), index); + QCOMPARE(spyResult.at(1).toInt(), 1); // only 1 item is modified at a time + QCOMPARE(spyResult.at(2).value >(), (QList() << role)); + } + + delete model; +} + +void tst_qquicklistmodel::get_nested_data() +{ + get_data(); +} + +//QTBUG-13754 +void tst_qquicklistmodel::crash_model_with_multiple_roles() +{ + QQmlEngine eng; + QQmlComponent component(&eng, testFileUrl("multipleroles.qml")); + QObject *rootItem = component.create(); + QVERIFY(component.errorString().isEmpty()); + QVERIFY(rootItem != 0); + QQuickListModel *model = rootItem->findChild("listModel"); + QVERIFY(model != 0); + + // used to cause a crash + model->setProperty(0, "black", true); + + delete rootItem; +} + +//QTBUG-15190 +void tst_qquicklistmodel::set_model_cache() +{ + QQmlEngine eng; + QQmlComponent component(&eng, testFileUrl("setmodelcachelist.qml")); + QObject *model = component.create(); + QVERIFY2(component.errorString().isEmpty(), QTest::toString(component.errorString())); + QVERIFY(model != 0); + QVERIFY(model->property("ok").toBool()); + + delete model; +} + +void tst_qquicklistmodel::property_changes() +{ + QFETCH(QString, script_setup); + QFETCH(QString, script_change); + QFETCH(QString, roleName); + QFETCH(int, listIndex); + QFETCH(bool, itemsChanged); + QFETCH(QString, testExpression); + QFETCH(bool, dynamicRoles); + + QQmlEngine engine; + QQuickListModel model; + model.setDynamicRoles(dynamicRoles); + QQmlEngine::setContextForObject(&model, engine.rootContext()); + engine.rootContext()->setContextObject(&model); + + QQmlExpression expr(engine.rootContext(), &model, script_setup); + expr.evaluate(); + QVERIFY2(!expr.hasError(), QTest::toString(expr.error().toString())); + + QString signalHandler = "on" + QString(roleName[0].toUpper()) + roleName.mid(1, roleName.length()) + "Changed:"; + QString qml = "import QtQuick 2.0\n" + "Connections {\n" + "property bool gotSignal: false\n" + "target: model.get(" + QString::number(listIndex) + ")\n" + + signalHandler + " gotSignal = true\n" + "}\n"; + + QQmlComponent component(&engine); + component.setData(qml.toUtf8(), QUrl::fromLocalFile("")); + engine.rootContext()->setContextProperty("model", &model); + QObject *connectionsObject = component.create(); + QVERIFY2(component.errorString().isEmpty(), QTest::toString(component.errorString())); + + QSignalSpy spyItemsChanged(&model, SIGNAL(itemsChanged(int, int, QList))); + + expr.setExpression(script_change); + expr.evaluate(); + QVERIFY2(!expr.hasError(), QTest::toString(expr.error())); + + // test the object returned by get() emits the correct signals + QCOMPARE(connectionsObject->property("gotSignal").toBool(), itemsChanged); + + // test itemsChanged() is emitted correctly + if (itemsChanged) { + QCOMPARE(spyItemsChanged.count(), 1); + QCOMPARE(spyItemsChanged.at(0).at(0).toInt(), listIndex); + QCOMPARE(spyItemsChanged.at(0).at(1).toInt(), 1); + } else { + QCOMPARE(spyItemsChanged.count(), 0); + } + + expr.setExpression(testExpression); + QCOMPARE(expr.evaluate().toBool(), true); + + delete connectionsObject; +} + +void tst_qquicklistmodel::property_changes_data() +{ + QTest::addColumn("script_setup"); + QTest::addColumn("script_change"); + QTest::addColumn("roleName"); + QTest::addColumn("listIndex"); + QTest::addColumn("itemsChanged"); + QTest::addColumn("testExpression"); + QTest::addColumn("dynamicRoles"); + + for (int i=0 ; i < 2 ; ++i) { + bool dr = (i != 0); + + QTest::newRow("set: plain") << "append({'a':123, 'b':456, 'c':789});" << "set(0,{'b':123});" + << "b" << 0 << true << "get(0).b == 123" << dr; + QTest::newRow("setProperty: plain") << "append({'a':123, 'b':456, 'c':789});" << "setProperty(0, 'b', 123);" + << "b" << 0 << true << "get(0).b == 123" << dr; + + QTest::newRow("set: plain, no changes") << "append({'a':123, 'b':456, 'c':789});" << "set(0,{'b':456});" + << "b" << 0 << false << "get(0).b == 456" << dr; + QTest::newRow("setProperty: plain, no changes") << "append({'a':123, 'b':456, 'c':789});" << "setProperty(0, 'b', 456);" + << "b" << 0 << false << "get(0).b == 456" << dr; + + QTest::newRow("set: inserted item") + << "{append({'a':123, 'b':456, 'c':789}); get(0); insert(0, {'a':0, 'b':0, 'c':0});}" + << "set(1, {'a':456});" + << "a" << 1 << true << "get(1).a == 456" << dr; + QTest::newRow("setProperty: inserted item") + << "{append({'a':123, 'b':456, 'c':789}); get(0); insert(0, {'a':0, 'b':0, 'c':0});}" + << "setProperty(1, 'a', 456);" + << "a" << 1 << true << "get(1).a == 456" << dr; + QTest::newRow("get: inserted item") + << "{append({'a':123, 'b':456, 'c':789}); get(0); insert(0, {'a':0, 'b':0, 'c':0});}" + << "get(1).a = 456;" + << "a" << 1 << true << "get(1).a == 456" << dr; + QTest::newRow("set: removed item") + << "{append({'a':0, 'b':0, 'c':0}); append({'a':123, 'b':456, 'c':789}); get(1); remove(0);}" + << "set(0, {'a':456});" + << "a" << 0 << true << "get(0).a == 456" << dr; + QTest::newRow("setProperty: removed item") + << "{append({'a':0, 'b':0, 'c':0}); append({'a':123, 'b':456, 'c':789}); get(1); remove(0);}" + << "setProperty(0, 'a', 456);" + << "a" << 0 << true << "get(0).a == 456" << dr; + QTest::newRow("get: removed item") + << "{append({'a':0, 'b':0, 'c':0}); append({'a':123, 'b':456, 'c':789}); get(1); remove(0);}" + << "get(0).a = 456;" + << "a" << 0 << true << "get(0).a == 456" << dr; + + // Following tests only call set() since setProperty() only allows plain + // values, not lists, as the argument. + // Note that when a list is changed, itemsChanged() is currently always + // emitted regardless of whether it actually changed or not. + + QTest::newRow("nested-set: list, new size") << "append({'a':123, 'b':[{'a':1},{'a':2},{'a':3}], 'c':789});" << "set(0,{'b':[{'a':1},{'a':2}]});" + << "b" << 0 << true << "get(0).b.get(0).a == 1 && get(0).b.get(1).a == 2" << dr; + + QTest::newRow("nested-set: list, empty -> non-empty") << "append({'a':123, 'b':[], 'c':789});" << "set(0,{'b':[{'a':1},{'a':2},{'a':3}]});" + << "b" << 0 << true << "get(0).b.get(0).a == 1 && get(0).b.get(1).a == 2 && get(0).b.get(2).a == 3" << dr; + + QTest::newRow("nested-set: list, non-empty -> empty") << "append({'a':123, 'b':[{'a':1},{'a':2},{'a':3}], 'c':789});" << "set(0,{'b':[]});" + << "b" << 0 << true << "get(0).b.count == 0" << dr; + + QTest::newRow("nested-set: list, same size, different values") << "append({'a':123, 'b':[{'a':1},{'a':2},{'a':3}], 'c':789});" << "set(0,{'b':[{'a':1},{'a':222},{'a':3}]});" + << "b" << 0 << true << "get(0).b.get(0).a == 1 && get(0).b.get(1).a == 222 && get(0).b.get(2).a == 3" << dr; + + QTest::newRow("nested-set: list, no changes") << "append({'a':123, 'b':[{'a':1},{'a':2},{'a':3}], 'c':789});" << "set(0,{'b':[{'a':1},{'a':2},{'a':3}]});" + << "b" << 0 << true << "get(0).b.get(0).a == 1 && get(0).b.get(1).a == 2 && get(0).b.get(2).a == 3" << dr; + + QTest::newRow("nested-set: list, no changes, empty") << "append({'a':123, 'b':[], 'c':789});" << "set(0,{'b':[]});" + << "b" << 0 << true << "get(0).b.count == 0" << dr; + } +} + +void tst_qquicklistmodel::property_changes_worker() +{ + QFETCH(QString, script_setup); + QFETCH(QString, script_change); + QFETCH(QString, roleName); + QFETCH(int, listIndex); + QFETCH(bool, itemsChanged); + QFETCH(bool, dynamicRoles); + + QQuickListModel model; + model.setDynamicRoles(dynamicRoles); + QQmlEngine engine; + QQmlComponent component(&engine, testFileUrl("model.qml")); + QVERIFY2(component.errorString().isEmpty(), component.errorString().toUtf8()); + QQuickItem *item = createWorkerTest(&engine, &component, &model); + QVERIFY(item != 0); + + QQmlExpression expr(engine.rootContext(), &model, script_setup); + expr.evaluate(); + QVERIFY2(!expr.hasError(), QTest::toString(expr.error().toString())); + + QSignalSpy spyItemsChanged(&model, SIGNAL(itemsChanged(int, int, QList))); + + QVERIFY(QMetaObject::invokeMethod(item, "evalExpressionViaWorker", + Q_ARG(QVariant, QStringList(script_change)))); + waitForWorker(item); + + // test itemsChanged() is emitted correctly + if (itemsChanged) { + QCOMPARE(spyItemsChanged.count(), 1); + QCOMPARE(spyItemsChanged.at(0).at(0).toInt(), listIndex); + QCOMPARE(spyItemsChanged.at(0).at(1).toInt(), 1); + } else { + QCOMPARE(spyItemsChanged.count(), 0); + } + + delete item; + qApp->processEvents(); +} + +void tst_qquicklistmodel::property_changes_worker_data() +{ + property_changes_data(); +} + +void tst_qquicklistmodel::clear_data() +{ + QTest::addColumn("dynamicRoles"); + + QTest::newRow("staticRoles") << false; + QTest::newRow("dynamicRoles") << true; +} + +void tst_qquicklistmodel::clear() +{ + QFETCH(bool, dynamicRoles); + + QQmlEngine engine; + QQuickListModel model; + model.setDynamicRoles(dynamicRoles); + QQmlEngine::setContextForObject(&model, engine.rootContext()); + engine.rootContext()->setContextProperty("model", &model); + + model.clear(); + QCOMPARE(model.count(), 0); + + RUNEXPR("model.append({propertyA: \"value a\", propertyB: \"value b\"})"); + QCOMPARE(model.count(), 1); + + model.clear(); + QCOMPARE(model.count(), 0); + + RUNEXPR("model.append({propertyA: \"value a\", propertyB: \"value b\"})"); + RUNEXPR("model.append({propertyA: \"value a\", propertyB: \"value b\"})"); + QCOMPARE(model.count(), 2); + + model.clear(); + QCOMPARE(model.count(), 0); + + // clearing does not remove the roles + RUNEXPR("model.append({propertyA: \"value a\", propertyB: \"value b\", propertyC: \"value c\"})"); + QList roles = model.roles(); + model.clear(); + QCOMPARE(model.count(), 0); + QCOMPARE(model.roles(), roles); + QCOMPARE(model.toString(roles[0]), QString("propertyA")); + QCOMPARE(model.toString(roles[1]), QString("propertyB")); + QCOMPARE(model.toString(roles[2]), QString("propertyC")); +} + +void tst_qquicklistmodel::signal_handlers_data() +{ + QTest::addColumn("dynamicRoles"); + + QTest::newRow("staticRoles") << false; + QTest::newRow("dynamicRoles") << true; +} + +void tst_qquicklistmodel::signal_handlers() +{ + QFETCH(bool, dynamicRoles); + + QQmlEngine eng; + QQmlComponent component(&eng, testFileUrl("signalhandlers.qml")); + QObject *model = component.create(); + QQuickListModel *lm = qobject_cast(model); + QVERIFY(lm != 0); + lm->setDynamicRoles(dynamicRoles); + QVERIFY2(component.errorString().isEmpty(), QTest::toString(component.errorString())); + QVERIFY(model != 0); + QVERIFY(model->property("ok").toBool()); + + delete model; +} + +void tst_qquicklistmodel::worker_sync_data() +{ + QTest::addColumn("dynamicRoles"); + + QTest::newRow("staticRoles") << false; + QTest::newRow("dynamicRoles") << true; +} + +void tst_qquicklistmodel::worker_sync() +{ + QFETCH(bool, dynamicRoles); + + QQuickListModel model; + model.setDynamicRoles(dynamicRoles); + QQmlEngine eng; + QQmlComponent component(&eng, testFileUrl("workersync.qml")); + QQuickItem *item = createWorkerTest(&eng, &component, &model); + QVERIFY(item != 0); + + QVERIFY(model.count() == 0); + + QVERIFY(QMetaObject::invokeMethod(item, "addItem0")); + + QVERIFY(model.count() == 2); + QVariant childData = model.data(0, 0); + QQuickListModel *childModel = qobject_cast(childData.value()); + QVERIFY(childModel); + QVERIFY(childModel->count() == 1); + + QSignalSpy spyModelInserted(&model, SIGNAL(itemsInserted(int,int))); + QSignalSpy spyChildInserted(childModel, SIGNAL(itemsInserted(int,int))); + + QVERIFY(QMetaObject::invokeMethod(item, "addItemViaWorker")); + waitForWorker(item); + + QVERIFY(model.count() == 2); + QVERIFY(childModel->count() == 1); + QVERIFY(spyModelInserted.count() == 0); + QVERIFY(spyChildInserted.count() == 0); + + QVERIFY(QMetaObject::invokeMethod(item, "doSync")); + waitForWorker(item); + + QVERIFY(model.count() == 2); + QVERIFY(childModel->count() == 2); + QVERIFY(spyModelInserted.count() == 0); + QVERIFY(spyChildInserted.count() == 1); + + QVERIFY(QMetaObject::invokeMethod(item, "addItemViaWorker")); + waitForWorker(item); + + QVERIFY(model.count() == 2); + QVERIFY(childModel->count() == 2); + QVERIFY(spyModelInserted.count() == 0); + QVERIFY(spyChildInserted.count() == 1); + + QVERIFY(QMetaObject::invokeMethod(item, "doSync")); + waitForWorker(item); + + QVERIFY(model.count() == 2); + QVERIFY(childModel->count() == 3); + QVERIFY(spyModelInserted.count() == 0); + QVERIFY(spyChildInserted.count() == 2); + + delete item; + qApp->processEvents(); +} + +void tst_qquicklistmodel::worker_remove_element_data() +{ + worker_sync_data(); +} + +void tst_qquicklistmodel::worker_remove_element() +{ + QFETCH(bool, dynamicRoles); + + QQuickListModel model; + model.setDynamicRoles(dynamicRoles); + QQmlEngine eng; + QQmlComponent component(&eng, testFileUrl("workerremoveelement.qml")); + QQuickItem *item = createWorkerTest(&eng, &component, &model); + QVERIFY(item != 0); + + QSignalSpy spyModelRemoved(&model, SIGNAL(itemsRemoved(int,int))); + + QVERIFY(model.count() == 0); + QVERIFY(spyModelRemoved.count() == 0); + + QVERIFY(QMetaObject::invokeMethod(item, "addItem")); + + QVERIFY(model.count() == 1); + + QVERIFY(QMetaObject::invokeMethod(item, "removeItemViaWorker")); + waitForWorker(item); + + QVERIFY(model.count() == 1); + QVERIFY(spyModelRemoved.count() == 0); + + QVERIFY(QMetaObject::invokeMethod(item, "doSync")); + waitForWorker(item); + + QVERIFY(model.count() == 0); + QVERIFY(spyModelRemoved.count() == 1); + + delete item; + qApp->processEvents(); + + { + //don't crash if model was deleted earlier + QQuickListModel* model = new QQuickListModel; + model->setDynamicRoles(dynamicRoles); + QQmlEngine eng; + QQmlComponent component(&eng, testFileUrl("workerremoveelement.qml")); + QQuickItem *item = createWorkerTest(&eng, &component, model); + QVERIFY(item != 0); + + QVERIFY(QMetaObject::invokeMethod(item, "addItem")); + + QVERIFY(model->count() == 1); + + QVERIFY(QMetaObject::invokeMethod(item, "removeItemViaWorker")); + QVERIFY(QMetaObject::invokeMethod(item, "doSync")); + delete model; + qApp->processEvents(); //must not crash here + waitForWorker(item); + + delete item; + } +} + +void tst_qquicklistmodel::worker_remove_list_data() +{ + worker_sync_data(); +} + +void tst_qquicklistmodel::worker_remove_list() +{ + QFETCH(bool, dynamicRoles); + + QQuickListModel model; + model.setDynamicRoles(dynamicRoles); + QQmlEngine eng; + QQmlComponent component(&eng, testFileUrl("workerremovelist.qml")); + QQuickItem *item = createWorkerTest(&eng, &component, &model); + QVERIFY(item != 0); + + QSignalSpy spyModelRemoved(&model, SIGNAL(itemsRemoved(int,int))); + + QVERIFY(model.count() == 0); + QVERIFY(spyModelRemoved.count() == 0); + + QVERIFY(QMetaObject::invokeMethod(item, "addList")); + + QVERIFY(model.count() == 1); + + QVERIFY(QMetaObject::invokeMethod(item, "removeListViaWorker")); + waitForWorker(item); + + QVERIFY(model.count() == 1); + QVERIFY(spyModelRemoved.count() == 0); + + QVERIFY(QMetaObject::invokeMethod(item, "doSync")); + waitForWorker(item); + + QVERIFY(model.count() == 0); + QVERIFY(spyModelRemoved.count() == 1); + + delete item; + qApp->processEvents(); +} + +void tst_qquicklistmodel::role_mode_data() +{ + QTest::addColumn("script"); + QTest::addColumn("result"); + QTest::addColumn("warning"); + + QTest::newRow("default0") << "{dynamicRoles}" << 0 << ""; + QTest::newRow("default1") << "{append({'a':1});dynamicRoles}" << 0 << ""; + + QTest::newRow("enableDynamic0") << "{dynamicRoles=true;dynamicRoles}" << 1 << ""; + QTest::newRow("enableDynamic1") << "{append({'a':1});dynamicRoles=true;dynamicRoles}" << 0 << ": QML ListModel: unable to enable dynamic roles as this model is not empty!"; + QTest::newRow("enableDynamic2") << "{dynamicRoles=true;append({'a':1});dynamicRoles=false;dynamicRoles}" << 1 << ": QML ListModel: unable to enable static roles as this model is not empty!"; +} + +void tst_qquicklistmodel::role_mode() +{ + QFETCH(QString, script); + QFETCH(int, result); + QFETCH(QString, warning); + + QQmlEngine engine; + QQuickListModel model; + QQmlEngine::setContextForObject(&model,engine.rootContext()); + engine.rootContext()->setContextObject(&model); + QQmlExpression e(engine.rootContext(), &model, script); + if (!warning.isEmpty()) + QTest::ignoreMessage(QtWarningMsg, warning.toLatin1()); + + int actual = e.evaluate().toInt(); + if (e.hasError()) + qDebug() << e.error(); // errors not expected + + QCOMPARE(actual,result); +} + +void tst_qquicklistmodel::dynamic_role_data() +{ + QTest::addColumn("preamble"); + QTest::addColumn("script"); + QTest::addColumn("result"); + + QTest::newRow("sync1") << "{append({'a':[{'b':1},{'b':2}]})}" << "{get(0).a = 'string';count}" << 1; +} + +void tst_qquicklistmodel::dynamic_role() +{ + QFETCH(QString, preamble); + QFETCH(QString, script); + QFETCH(int, result); + + QQuickListModel model; + model.setDynamicRoles(true); + QQmlEngine engine; + QQmlComponent component(&engine, testFileUrl("model.qml")); + QQuickItem *item = createWorkerTest(&engine, &component, &model); + QVERIFY(item != 0); + + QQmlExpression preExp(engine.rootContext(), &model, preamble); + QCOMPARE(preExp.evaluate().toInt(), 0); + + if (script[0] == QLatin1Char('{') && script[script.length()-1] == QLatin1Char('}')) + script = script.mid(1, script.length() - 2); + QVariantList operations; + foreach (const QString &s, script.split(';')) { + if (!s.isEmpty()) + operations << s; + } + + // execute a set of commands on the worker list model, then check the + // changes are reflected in the list model in the main thread + QVERIFY(QMetaObject::invokeMethod(item, "evalExpressionViaWorker", + Q_ARG(QVariant, operations.mid(0, operations.length()-1)))); + waitForWorker(item); + + QQmlExpression e(engine.rootContext(), &model, operations.last().toString()); + QCOMPARE(e.evaluate().toInt(), result); + + delete item; + qApp->processEvents(); +} + +QTEST_MAIN(tst_qquicklistmodel) + +#include "tst_qquicklistmodel.moc" diff --git a/tests/auto/qml/qquickworkerscript/data/BaseWorker.qml b/tests/auto/qml/qquickworkerscript/data/BaseWorker.qml new file mode 100644 index 0000000000..0ac56d9b66 --- /dev/null +++ b/tests/auto/qml/qquickworkerscript/data/BaseWorker.qml @@ -0,0 +1,24 @@ +import QtQuick 2.0 + +WorkerScript { + id: worker + + property variant response + + signal done() + + function testSend(value) { + worker.sendMessage(value) + } + + function compareLiteralResponse(expected) { + var e = eval('(' + expected + ')') + return JSON.stringify(worker.response) == JSON.stringify(e) + } + + onMessage: { + worker.response = messageObject + worker.done() + } +} + diff --git a/tests/auto/qml/qquickworkerscript/data/Global.js b/tests/auto/qml/qquickworkerscript/data/Global.js new file mode 100644 index 0000000000..6bdb4a56b9 --- /dev/null +++ b/tests/auto/qml/qquickworkerscript/data/Global.js @@ -0,0 +1 @@ +var data = "World" diff --git a/tests/auto/qml/qquickworkerscript/data/externalObjectWorker.qml b/tests/auto/qml/qquickworkerscript/data/externalObjectWorker.qml new file mode 100644 index 0000000000..1dae608b50 --- /dev/null +++ b/tests/auto/qml/qquickworkerscript/data/externalObjectWorker.qml @@ -0,0 +1,14 @@ +import QtQuick 2.0 + +Item { + id: root + + function testExternalObject() { + worker.sendMessage(Qt.vector3d(1,2,3)); + } + + WorkerScript { + id: worker + source: "script.js" + } +} diff --git a/tests/auto/qml/qquickworkerscript/data/script.js b/tests/auto/qml/qquickworkerscript/data/script.js new file mode 100644 index 0000000000..90aae263a1 --- /dev/null +++ b/tests/auto/qml/qquickworkerscript/data/script.js @@ -0,0 +1,4 @@ +WorkerScript.onMessage = function(msg) { + WorkerScript.sendMessage(msg) +} + diff --git a/tests/auto/qml/qquickworkerscript/data/script_error_onCall.js b/tests/auto/qml/qquickworkerscript/data/script_error_onCall.js new file mode 100644 index 0000000000..f589b0ef40 --- /dev/null +++ b/tests/auto/qml/qquickworkerscript/data/script_error_onCall.js @@ -0,0 +1,6 @@ +WorkerScript.onMessage = function(msg) { + var a = 123 + var b = 345 + var f = getData() +} + diff --git a/tests/auto/qml/qquickworkerscript/data/script_error_onLoad.js b/tests/auto/qml/qquickworkerscript/data/script_error_onLoad.js new file mode 100644 index 0000000000..1d6eab2285 --- /dev/null +++ b/tests/auto/qml/qquickworkerscript/data/script_error_onLoad.js @@ -0,0 +1,5 @@ +WorkerScript.onMessage = function(msg) { + var a = 123 + aoij awef aljfaow eij +} + diff --git a/tests/auto/qml/qquickworkerscript/data/script_fixed_return.js b/tests/auto/qml/qquickworkerscript/data/script_fixed_return.js new file mode 100644 index 0000000000..14f6f178ae --- /dev/null +++ b/tests/auto/qml/qquickworkerscript/data/script_fixed_return.js @@ -0,0 +1,4 @@ +WorkerScript.onMessage = function(msg) { + WorkerScript.sendMessage('Hello_World') +} + diff --git a/tests/auto/qml/qquickworkerscript/data/script_include.js b/tests/auto/qml/qquickworkerscript/data/script_include.js new file mode 100644 index 0000000000..0385d91170 --- /dev/null +++ b/tests/auto/qml/qquickworkerscript/data/script_include.js @@ -0,0 +1,5 @@ +WorkerScript.onMessage = function(msg) { + var res = Qt.include("Global.js"); + WorkerScript.sendMessage(msg + " " + data) +} + diff --git a/tests/auto/qml/qquickworkerscript/data/script_pragma.js b/tests/auto/qml/qquickworkerscript/data/script_pragma.js new file mode 100644 index 0000000000..cb3b6d3398 --- /dev/null +++ b/tests/auto/qml/qquickworkerscript/data/script_pragma.js @@ -0,0 +1,6 @@ +.pragma library + +WorkerScript.onMessage = function(msg) { + WorkerScript.sendMessage(msg) +} + diff --git a/tests/auto/qml/qquickworkerscript/data/stressDispose.js b/tests/auto/qml/qquickworkerscript/data/stressDispose.js new file mode 100644 index 0000000000..5c4c5ec906 --- /dev/null +++ b/tests/auto/qml/qquickworkerscript/data/stressDispose.js @@ -0,0 +1,6 @@ +WorkerScript.onMessage = function() { +} +for (var ii = 0; ii < 100; ++ii) { + var a = "HELLO WORLD"; +} + diff --git a/tests/auto/qml/qquickworkerscript/data/stressDispose.qml b/tests/auto/qml/qquickworkerscript/data/stressDispose.qml new file mode 100644 index 0000000000..3e8465d6fe --- /dev/null +++ b/tests/auto/qml/qquickworkerscript/data/stressDispose.qml @@ -0,0 +1,13 @@ +import QtQuick 2.0 + +Item { + WorkerScript { + id: worker + source: "stressDispose.js" + } + + Component.onCompleted: { + worker.sendMessage(10); + } +} + diff --git a/tests/auto/qml/qquickworkerscript/data/worker.qml b/tests/auto/qml/qquickworkerscript/data/worker.qml new file mode 100644 index 0000000000..b5a92bf1f5 --- /dev/null +++ b/tests/auto/qml/qquickworkerscript/data/worker.qml @@ -0,0 +1,5 @@ +import QtQuick 2.0 + +BaseWorker { + source: "script.js" +} diff --git a/tests/auto/qml/qquickworkerscript/data/worker_error_onCall.qml b/tests/auto/qml/qquickworkerscript/data/worker_error_onCall.qml new file mode 100644 index 0000000000..aa20783e76 --- /dev/null +++ b/tests/auto/qml/qquickworkerscript/data/worker_error_onCall.qml @@ -0,0 +1,6 @@ +import QtQuick 2.0 + +BaseWorker { + source: "script_error_onCall.js" +} + diff --git a/tests/auto/qml/qquickworkerscript/data/worker_error_onLoad.qml b/tests/auto/qml/qquickworkerscript/data/worker_error_onLoad.qml new file mode 100644 index 0000000000..8a33aeb44c --- /dev/null +++ b/tests/auto/qml/qquickworkerscript/data/worker_error_onLoad.qml @@ -0,0 +1,7 @@ +import QtQuick 2.0 + +BaseWorker { + source: "script_error_onLoad.js" +} + + diff --git a/tests/auto/qml/qquickworkerscript/data/worker_include.qml b/tests/auto/qml/qquickworkerscript/data/worker_include.qml new file mode 100644 index 0000000000..100b8d4551 --- /dev/null +++ b/tests/auto/qml/qquickworkerscript/data/worker_include.qml @@ -0,0 +1,5 @@ +import QtQuick 2.0 + +BaseWorker { + source: "script_include.js" +} diff --git a/tests/auto/qml/qquickworkerscript/data/worker_pragma.qml b/tests/auto/qml/qquickworkerscript/data/worker_pragma.qml new file mode 100644 index 0000000000..7e313b3c42 --- /dev/null +++ b/tests/auto/qml/qquickworkerscript/data/worker_pragma.qml @@ -0,0 +1,6 @@ +import QtQuick 2.0 + +BaseWorker { + source: "script_pragma.js" +} + diff --git a/tests/auto/qml/qquickworkerscript/qquickworkerscript.pro b/tests/auto/qml/qquickworkerscript/qquickworkerscript.pro new file mode 100644 index 0000000000..e9c358c3cc --- /dev/null +++ b/tests/auto/qml/qquickworkerscript/qquickworkerscript.pro @@ -0,0 +1,15 @@ +CONFIG += testcase +TARGET = tst_qquickworkerscript +macx:CONFIG -= app_bundle + +SOURCES += tst_qquickworkerscript.cpp + +include (../../shared/util.pri) + +testDataFiles.files = data +testDataFiles.path = . +DEPLOYMENT += testDataFiles + +CONFIG += parallel_test + +QT += core-private gui-private v8-private qml-private testlib diff --git a/tests/auto/qml/qquickworkerscript/tst_qquickworkerscript.cpp b/tests/auto/qml/qquickworkerscript/tst_qquickworkerscript.cpp new file mode 100644 index 0000000000..6569b877fe --- /dev/null +++ b/tests/auto/qml/qquickworkerscript/tst_qquickworkerscript.cpp @@ -0,0 +1,300 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include +#include +#include +#include +#include +#include + +#include +#include + +#include +#include +#include "../../shared/util.h" + +class tst_QQuickWorkerScript : public QQmlDataTest +{ + Q_OBJECT +public: + tst_QQuickWorkerScript() {} +private slots: + void source(); + void messaging(); + void messaging_data(); + void messaging_sendQObjectList(); + void messaging_sendJsObject(); + void messaging_sendExternalObject(); + void script_with_pragma(); + void script_included(); + void scriptError_onLoad(); + void scriptError_onCall(); + void stressDispose(); + +private: + void waitForEchoMessage(QQuickWorkerScript *worker) { + QEventLoop loop; + QVERIFY(connect(worker, SIGNAL(done()), &loop, SLOT(quit()))); + QTimer timer; + timer.setSingleShot(true); + connect(&timer, SIGNAL(timeout()), &loop, SLOT(quit())); + timer.start(10000); + loop.exec(); + QVERIFY(timer.isActive()); + } + + QQmlEngine m_engine; +}; + +void tst_QQuickWorkerScript::source() +{ + QQmlComponent component(&m_engine, testFileUrl("worker.qml")); + QQuickWorkerScript *worker = qobject_cast(component.create()); + QVERIFY(worker != 0); + const QMetaObject *mo = worker->metaObject(); + + QVariant value(100); + QVERIFY(QMetaObject::invokeMethod(worker, "testSend", Q_ARG(QVariant, value))); + waitForEchoMessage(worker); + QCOMPARE(mo->property(mo->indexOfProperty("response")).read(worker).value(), value); + + QUrl source = testFileUrl("script_fixed_return.js"); + worker->setSource(source); + QCOMPARE(worker->source(), source); + QVERIFY(QMetaObject::invokeMethod(worker, "testSend", Q_ARG(QVariant, value))); + waitForEchoMessage(worker); + QCOMPARE(mo->property(mo->indexOfProperty("response")).read(worker).value(), qVariantFromValue(QString("Hello_World"))); + + qApp->processEvents(); + delete worker; +} + +void tst_QQuickWorkerScript::messaging() +{ + QFETCH(QVariant, value); + + QQmlComponent component(&m_engine, testFileUrl("worker.qml")); + QQuickWorkerScript *worker = qobject_cast(component.create()); + QVERIFY(worker != 0); + + QVERIFY(QMetaObject::invokeMethod(worker, "testSend", Q_ARG(QVariant, value))); + waitForEchoMessage(worker); + + const QMetaObject *mo = worker->metaObject(); + QCOMPARE(mo->property(mo->indexOfProperty("response")).read(worker).value(), value); + + qApp->processEvents(); + delete worker; +} + +void tst_QQuickWorkerScript::messaging_data() +{ + QTest::addColumn("value"); + + QTest::newRow("invalid") << QVariant(); + QTest::newRow("bool") << qVariantFromValue(true); + QTest::newRow("int") << qVariantFromValue(1001); + QTest::newRow("real") << qVariantFromValue(10334.375); + QTest::newRow("string") << qVariantFromValue(QString("More cheeeese, Gromit!")); + QTest::newRow("variant list") << qVariantFromValue((QVariantList() << "a" << "b" << "c")); + QTest::newRow("date time") << qVariantFromValue(QDateTime::currentDateTime()); +#ifndef QT_NO_REGEXP + // QtScript's QScriptValue -> QRegExp uses RegExp2 pattern syntax + QTest::newRow("regexp") << qVariantFromValue(QRegExp("^\\d\\d?$", Qt::CaseInsensitive, QRegExp::RegExp2)); +#endif +} + +void tst_QQuickWorkerScript::messaging_sendQObjectList() +{ + // Not allowed to send QObjects other than QQuickListModelWorkerAgent + // instances. If objects are sent in a list, they will be sent as 'undefined' + // js values. + + QQmlComponent component(&m_engine, testFileUrl("worker.qml")); + QQuickWorkerScript *worker = qobject_cast(component.create()); + QVERIFY(worker != 0); + + QVariantList objects; + for (int i=0; i<3; i++) + objects << qVariantFromValue(new QObject(this)); + + QVERIFY(QMetaObject::invokeMethod(worker, "testSend", Q_ARG(QVariant, qVariantFromValue(objects)))); + waitForEchoMessage(worker); + + const QMetaObject *mo = worker->metaObject(); + QVariantList result = mo->property(mo->indexOfProperty("response")).read(worker).value(); + QCOMPARE(result, (QVariantList() << QVariant() << QVariant() << QVariant())); + + qApp->processEvents(); + delete worker; +} + +void tst_QQuickWorkerScript::messaging_sendJsObject() +{ + QQmlComponent component(&m_engine, testFileUrl("worker.qml")); + QQuickWorkerScript *worker = qobject_cast(component.create()); + QVERIFY(worker != 0); + + // Properties are in alphabetical order to enable string-based comparison after + // QVariant roundtrip, since the properties will be stored in a QVariantMap. + QString jsObject = "{'haste': 1125, 'name': 'zyz', 'spell power': 3101}"; + + QVariantMap map; + map.insert("haste", 1125); + map.insert("name", "zyz"); + map.insert("spell power", 3101); + + QVERIFY(QMetaObject::invokeMethod(worker, "testSend", Q_ARG(QVariant, qVariantFromValue(map)))); + waitForEchoMessage(worker); + + QVariant result = qVariantFromValue(false); + QVERIFY(QMetaObject::invokeMethod(worker, "compareLiteralResponse", Qt::DirectConnection, + Q_RETURN_ARG(QVariant, result), Q_ARG(QVariant, jsObject))); + QVERIFY(result.toBool()); + + qApp->processEvents(); + delete worker; +} + +void tst_QQuickWorkerScript::messaging_sendExternalObject() +{ + QQmlComponent component(&m_engine, testFileUrl("externalObjectWorker.qml")); + QObject *obj = component.create(); + QVERIFY(obj); + QMetaObject::invokeMethod(obj, "testExternalObject"); + QTest::qWait(100); // shouldn't crash. + delete obj; +} + +void tst_QQuickWorkerScript::script_with_pragma() +{ + QVariant value(100); + + QQmlComponent component(&m_engine, testFileUrl("worker_pragma.qml")); + QQuickWorkerScript *worker = qobject_cast(component.create()); + QVERIFY(worker != 0); + + QVERIFY(QMetaObject::invokeMethod(worker, "testSend", Q_ARG(QVariant, value))); + waitForEchoMessage(worker); + + const QMetaObject *mo = worker->metaObject(); + QCOMPARE(mo->property(mo->indexOfProperty("response")).read(worker).value(), value); + + qApp->processEvents(); + delete worker; +} + +void tst_QQuickWorkerScript::script_included() +{ + QQmlComponent component(&m_engine, testFileUrl("worker_include.qml")); + QQuickWorkerScript *worker = qobject_cast(component.create()); + QVERIFY(worker != 0); + + QString value("Hello"); + + QVERIFY(QMetaObject::invokeMethod(worker, "testSend", Q_ARG(QVariant, value))); + waitForEchoMessage(worker); + + const QMetaObject *mo = worker->metaObject(); + QCOMPARE(mo->property(mo->indexOfProperty("response")).read(worker).toString(), value + " World"); + + qApp->processEvents(); + delete worker; +} + +static QString qquickworkerscript_lastWarning; +static void qquickworkerscript_warningsHandler(QtMsgType type, const char *msg) +{ + if (type == QtWarningMsg) + qquickworkerscript_lastWarning = QString::fromUtf8(msg); +} + +void tst_QQuickWorkerScript::scriptError_onLoad() +{ + QQmlComponent component(&m_engine, testFileUrl("worker_error_onLoad.qml")); + + QtMsgHandler previousMsgHandler = qInstallMsgHandler(qquickworkerscript_warningsHandler); + QQuickWorkerScript *worker = qobject_cast(component.create()); + QVERIFY(worker != 0); + + QTRY_COMPARE(qquickworkerscript_lastWarning, + testFileUrl("script_error_onLoad.js").toString() + QLatin1String(":3: SyntaxError: Unexpected identifier")); + + qInstallMsgHandler(previousMsgHandler); + qApp->processEvents(); + delete worker; +} + +void tst_QQuickWorkerScript::scriptError_onCall() +{ + QQmlComponent component(&m_engine, testFileUrl("worker_error_onCall.qml")); + QQuickWorkerScript *worker = qobject_cast(component.create()); + QVERIFY(worker != 0); + + QtMsgHandler previousMsgHandler = qInstallMsgHandler(qquickworkerscript_warningsHandler); + QVariant value; + QVERIFY(QMetaObject::invokeMethod(worker, "testSend", Q_ARG(QVariant, value))); + + QTRY_COMPARE(qquickworkerscript_lastWarning, + testFileUrl("script_error_onCall.js").toString() + QLatin1String(":4: ReferenceError: Can't find variable: getData")); + + qInstallMsgHandler(previousMsgHandler); + qApp->processEvents(); + delete worker; +} + +// Rapidly create and destroy worker scripts to test resources are being disposed +// in the correct isolate +void tst_QQuickWorkerScript::stressDispose() +{ + for (int ii = 0; ii < 100; ++ii) { + QQmlEngine engine; + QQmlComponent component(&engine, testFileUrl("stressDispose.qml")); + QObject *o = component.create(); + QVERIFY(o); + delete o; + } +} + +QTEST_MAIN(tst_QQuickWorkerScript) + +#include "tst_qquickworkerscript.moc" diff --git a/tests/auto/qml/runall.sh b/tests/auto/qml/runall.sh new file mode 100644 index 0000000000..9580d8445e --- /dev/null +++ b/tests/auto/qml/runall.sh @@ -0,0 +1,100 @@ +#!/bin/bash +# +############################################################################# +## +## Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +## Contact: http://www.qt-project.org/ +## +## This file is part of the test suite of the Qt Toolkit. +## +## $QT_BEGIN_LICENSE:LGPL$ +## GNU Lesser General Public License Usage +## This file may be used under the terms of the GNU Lesser General Public +## License version 2.1 as published by the Free Software Foundation and +## appearing in the file LICENSE.LGPL included in the packaging of this +## file. Please review the following information to ensure the GNU Lesser +## General Public License version 2.1 requirements will be met: +## http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +## +## In addition, as a special exception, Nokia gives you certain additional +## rights. These rights are described in the Nokia Qt LGPL Exception +## version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +## +## GNU General Public License Usage +## Alternatively, this file may be used under the terms of the GNU General +## Public License version 3.0 as published by the Free Software Foundation +## and appearing in the file LICENSE.GPL included in the packaging of this +## file. Please review the following information to ensure the GNU General +## Public License version 3.0 requirements will be met: +## http://www.gnu.org/copyleft/gpl.html. +## +## Other Usage +## Alternatively, this file may be used in accordance with the terms and +## conditions contained in a signed written agreement between you and Nokia. +## +## +## +## +## +## +## $QT_END_LICENSE$ +## +############################################################################/ + +if [ "$(uname)" = Linux ] +then + Xnest :7 2>/dev/null & + sleep 1 + trap "kill $!" EXIT + export DISPLAY=:7 + export LANG=en_US + kwin 2>/dev/null & + sleep 1 +fi + +function filter +{ + exe=$1 + skip=0 + while read line + do + if [ $skip != 0 ] + then + let skip=skip-1 + else + case "$line" in + make*Error) echo "$line";; + make*Stop) echo "$line";; + /*/bin/make*) ;; + make*) ;; + install*) ;; + QQmlDebugServer:*Waiting*) ;; + QQmlDebugServer:*Connection*) ;; + */qmake*) ;; + */bin/moc*) ;; + *targ.debug*) ;; + g++*) ;; + cd*) ;; + XFAIL*) skip=1;; + SKIP*) skip=1;; + PASS*) ;; + QDEBUG*) ;; + Makefile*) ;; + Config*) ;; + Totals*) ;; + \**) ;; + ./*) ;; + *tst_*) echo "$line" ;; + *) echo "$exe: $line" + esac + fi + done +} + +make -k -j1 install 2>&1 | filter build +for exe in $(make install | sed -n 's/^install .* "\([^"]*qt4\/tst_[^"]*\)".*/\1/p') +do + echo $exe + $exe 2>&1 | filter $exe +done + diff --git a/tests/auto/qml/v4/data/conditionalExpr.qml b/tests/auto/qml/v4/data/conditionalExpr.qml new file mode 100644 index 0000000000..b74a95a94b --- /dev/null +++ b/tests/auto/qml/v4/data/conditionalExpr.qml @@ -0,0 +1,6 @@ +import Qt.v4 1.0 + +Result { + property int n: 2 + result: !n ? 100 : 0 +} diff --git a/tests/auto/qml/v4/data/doubleBoolJump.qml b/tests/auto/qml/v4/data/doubleBoolJump.qml new file mode 100644 index 0000000000..2eea73b573 --- /dev/null +++ b/tests/auto/qml/v4/data/doubleBoolJump.qml @@ -0,0 +1,18 @@ +import QtQuick 2.0 + +Rectangle { + QtObject { + property real output: i1.p1 || i2.p2 == "text" ? 0.7 : 0 + } + + QtObject { + id: i2 + property string p2 + } + + QtObject { + id: i1 + property bool p1: false + } +} + diff --git a/tests/auto/qml/v4/data/fetchException.qml b/tests/auto/qml/v4/data/fetchException.qml new file mode 100644 index 0000000000..6431fcfae8 --- /dev/null +++ b/tests/auto/qml/v4/data/fetchException.qml @@ -0,0 +1,6 @@ +import QtQuick 2.0 + +Item { + property Item data + property int a: data.x, 1 +} diff --git a/tests/auto/qml/v4/data/logicalOr.2.qml b/tests/auto/qml/v4/data/logicalOr.2.qml new file mode 100644 index 0000000000..54fb78b127 --- /dev/null +++ b/tests/auto/qml/v4/data/logicalOr.2.qml @@ -0,0 +1,6 @@ +import Qt.v4 1.0 + +Result { + property string s: "foo" || "bar" + result: s == "foo" +} diff --git a/tests/auto/qml/v4/data/logicalOr.qml b/tests/auto/qml/v4/data/logicalOr.qml new file mode 100644 index 0000000000..406a7d83eb --- /dev/null +++ b/tests/auto/qml/v4/data/logicalOr.qml @@ -0,0 +1,6 @@ +import Qt.v4 1.0 + +Result { + property int a: 10 + result: a == 1 || a == 2 +} diff --git a/tests/auto/qml/v4/data/nestedLogicalOr.qml b/tests/auto/qml/v4/data/nestedLogicalOr.qml new file mode 100644 index 0000000000..c4478a3e7b --- /dev/null +++ b/tests/auto/qml/v4/data/nestedLogicalOr.qml @@ -0,0 +1,14 @@ +import Qt.v4 1.0 + +Result { + property bool val1: false + property bool val2: true + property bool val3: false + + property bool b1: (false || false || true) + property bool b2: (false || (false || true)) + property bool b3: ((false || false) || true) + property bool b4: (val1 || (val2 || val3)) ? true : false + + result: b1 && b2 && b3 && b4 +} diff --git a/tests/auto/qml/v4/data/nestedObjectAccess.qml b/tests/auto/qml/v4/data/nestedObjectAccess.qml new file mode 100644 index 0000000000..56cd17e41e --- /dev/null +++ b/tests/auto/qml/v4/data/nestedObjectAccess.qml @@ -0,0 +1,5 @@ +import Qt.v4 1.0 + +Result { + result: nested.result +} diff --git a/tests/auto/qml/v4/data/nullQObject.qml b/tests/auto/qml/v4/data/nullQObject.qml new file mode 100644 index 0000000000..00185b3988 --- /dev/null +++ b/tests/auto/qml/v4/data/nullQObject.qml @@ -0,0 +1,7 @@ +import QtQuick 2.0 + +Item { + property QtObject obj + property QtObject test + test: obj +} diff --git a/tests/auto/qml/v4/data/qrealToIntRounding.qml b/tests/auto/qml/v4/data/qrealToIntRounding.qml new file mode 100644 index 0000000000..ee3d405073 --- /dev/null +++ b/tests/auto/qml/v4/data/qrealToIntRounding.qml @@ -0,0 +1,10 @@ +import QtQuick 2.0 + +QtObject { + property int data: 1 + + property int test1: 6.6 + data + property int test2: 6.2 + data + property int test3: 6 + data +} + diff --git a/tests/auto/qml/v4/data/qtbug_21883.qml b/tests/auto/qml/v4/data/qtbug_21883.qml new file mode 100644 index 0000000000..a51f97c944 --- /dev/null +++ b/tests/auto/qml/v4/data/qtbug_21883.qml @@ -0,0 +1,5 @@ +import Qt.v4 1.0 + +Result { + property Result dummy: Result +} diff --git a/tests/auto/qml/v4/data/qtbug_22816.qml b/tests/auto/qml/v4/data/qtbug_22816.qml new file mode 100644 index 0000000000..bfa8d4948c --- /dev/null +++ b/tests/auto/qml/v4/data/qtbug_22816.qml @@ -0,0 +1,18 @@ +import QtQuick 2.0 + +Item { + QtObject { + id: object + property bool prop1: true + function myfunction() { return true; } + property bool prop2: object.prop1 && myfunction(); + } + + property bool test1: object.prop1 && object.prop2 + property bool test2: object.prop1 + + Component.onCompleted: { + object.prop1 = false; + } +} + diff --git a/tests/auto/qml/v4/data/stringComparison.qml b/tests/auto/qml/v4/data/stringComparison.qml new file mode 100644 index 0000000000..64b6798c69 --- /dev/null +++ b/tests/auto/qml/v4/data/stringComparison.qml @@ -0,0 +1,34 @@ +import QtQuick 2.0 + +QtObject { + property string string1: "aaba" + property string string2: "aa" + property string string3: "aaab" + property string string4: "c" + + property bool test1: string1 > string2 + property bool test2: string2 < string1 + property bool test3: string1 > string3 + property bool test4: string3 < string1 + property bool test5: string1 < string4 + property bool test6: string4 > string1 + + property bool test7: string1 == "aaba" + property bool test8: string1 != "baa" + property bool test9: string1 === "aaba" + property bool test10: string1 !== "baa" + property bool test11: string4 == "c" + property bool test12: string4 != "d" + property bool test13: string4 === "c" + property bool test14: string4 !== "d" + + property bool test15: string1 >= string2 + property bool test16: string2 <= string1 + property bool test17: string1 >= string3 + property bool test18: string3 <= string1 + property bool test19: string1 <= string4 + property bool test20: string4 >= string1 + property bool test21: string4 <= "c" + property bool test22: string4 >= "c" +} + diff --git a/tests/auto/qml/v4/data/subscriptionsInConditionalExpressions.qml b/tests/auto/qml/v4/data/subscriptionsInConditionalExpressions.qml new file mode 100644 index 0000000000..a8e05eeda1 --- /dev/null +++ b/tests/auto/qml/v4/data/subscriptionsInConditionalExpressions.qml @@ -0,0 +1,11 @@ +import QtQuick 2.0 + +Item { + id: thisTest + + property bool cond: true + property real a: 1 + property real result: cond ? a : a + + PropertyAction { running: true; target: thisTest; property: "a"; value: 2; } +} diff --git a/tests/auto/qml/v4/data/unaryMinus.qml b/tests/auto/qml/v4/data/unaryMinus.qml new file mode 100644 index 0000000000..410654fc3c --- /dev/null +++ b/tests/auto/qml/v4/data/unaryMinus.qml @@ -0,0 +1,24 @@ +import QtQuick 2.0 + +Item { + property real test1: -i1.p2 + property int test2: -i1.p2 + property real test3: -i1.p1 + property int test4: -i1.p1 + property real test5: -i1.p3 + property int test6: -i1.p3 + property real test7: -i1.p4 + property int test8: -i1.p4 + property real test9: -i1.p5 + property int test10: -i1.p5 + + QtObject { + id: i1 + property real p1: -3.7 + property int p2: 18 + property real p3: -3.3 + property int p4: -7 + property real p5: 4.4 + } + } + diff --git a/tests/auto/qml/v4/data/unaryPlus.qml b/tests/auto/qml/v4/data/unaryPlus.qml new file mode 100644 index 0000000000..cd5315a7cc --- /dev/null +++ b/tests/auto/qml/v4/data/unaryPlus.qml @@ -0,0 +1,24 @@ +import QtQuick 2.0 + +Item { + property real test1: +i1.p2 + property int test2: +i1.p2 + property real test3: +i1.p1 + property int test4: +i1.p1 + property real test5: +i1.p3 + property int test6: +i1.p3 + property real test7: +i1.p4 + property int test8: +i1.p4 + property real test9: +i1.p5 + property int test10: +i1.p5 + + QtObject { + id: i1 + property real p1: -3.7 + property int p2: 18 + property real p3: -3.3 + property int p4: -7 + property real p5: 4.4 + } +} + diff --git a/tests/auto/qml/v4/data/unnecessaryReeval.qml b/tests/auto/qml/v4/data/unnecessaryReeval.qml new file mode 100644 index 0000000000..48662d7a2d --- /dev/null +++ b/tests/auto/qml/v4/data/unnecessaryReeval.qml @@ -0,0 +1,7 @@ +import Qt.v4 1.0 + +Result { + property int a: 8 + property int b: 19 + result: (a == 8)?b:7 +} diff --git a/tests/auto/qml/v4/testtypes.cpp b/tests/auto/qml/v4/testtypes.cpp new file mode 100644 index 0000000000..c879cf2226 --- /dev/null +++ b/tests/auto/qml/v4/testtypes.cpp @@ -0,0 +1,49 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include "testtypes.h" + +#include + +void registerTypes() +{ + qmlRegisterType("Qt.v4", 1,0, "Result"); + qmlRegisterType(); +} diff --git a/tests/auto/qml/v4/testtypes.h b/tests/auto/qml/v4/testtypes.h new file mode 100644 index 0000000000..02ba721839 --- /dev/null +++ b/tests/auto/qml/v4/testtypes.h @@ -0,0 +1,83 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#ifndef TESTTYPES_H +#define TESTTYPES_H + +#include + +class NestedObject : public QObject +{ + Q_OBJECT + Q_PROPERTY(int dummy READ dummy); + Q_PROPERTY(int result READ result FINAL CONSTANT); + +public: + int dummy() const { return 7; } + int result() const { return 37; } +}; + +class ResultObject : public QObject +{ + Q_OBJECT + Q_PROPERTY(int result READ result WRITE setResult FINAL) + Q_PROPERTY(NestedObject *nested READ nested CONSTANT) +public: + ResultObject() : m_result(0), m_resultCounter(0) {} + + int resultCounter() const { return m_resultCounter; } + void resetResultCounter() { m_resultCounter = 0; } + + int result() const { return m_result; } + void setResult(int result) { m_result = result; m_resultCounter++; } + + NestedObject *nested() { return &m_nested; } + +private: + int m_result; + int m_resultCounter; + + NestedObject m_nested; +}; + +void registerTypes(); + +#endif // TESTTYPES_H + diff --git a/tests/auto/qml/v4/tst_v4.cpp b/tests/auto/qml/v4/tst_v4.cpp new file mode 100644 index 0000000000..559abf7388 --- /dev/null +++ b/tests/auto/qml/v4/tst_v4.cpp @@ -0,0 +1,353 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include "../../shared/util.h" +#include "testtypes.h" + +class tst_v4 : public QQmlDataTest +{ + Q_OBJECT +public: + tst_v4() {} + +private slots: + void initTestCase(); + + void unnecessaryReeval(); + void logicalOr(); + void nestedLogicalOr(); + void conditionalExpr(); + void qtscript(); + void qtscript_data(); + void nestedObjectAccess(); + void subscriptionsInConditionalExpressions(); + void qtbug_21883(); + void qtbug_22816(); + void stringComparison(); + void unaryMinus(); + void unaryPlus(); + +private: + QQmlEngine engine; +}; + +void tst_v4::initTestCase() +{ + QQmlDataTest::initTestCase(); + registerTypes(); +} + +static int v4ErrorsMsgCount = 0; +static void v4ErrorsMsgHandler(QtMsgType, const char *message) +{ + QByteArray m(message); + if (m.contains("QV4")) + v4ErrorsMsgCount++; +} + +void tst_v4::qtscript() +{ + QFETCH(QString, file); + QV4Compiler::enableBindingsTest(true); + + QQmlComponent component(&engine, testFileUrl(file)); + + v4ErrorsMsgCount = 0; + QtMsgHandler old = qInstallMsgHandler(v4ErrorsMsgHandler); + + QObject *o = component.create(); + delete o; + + qInstallMsgHandler(old); + + QCOMPARE(v4ErrorsMsgCount, 0); + + QV4Compiler::enableBindingsTest(false); +} + +void tst_v4::qtscript_data() +{ + QTest::addColumn("file"); + + QTest::newRow("qreal -> int rounding") << "qrealToIntRounding.qml"; + QTest::newRow("exception on fetch") << "fetchException.qml"; + QTest::newRow("logical or") << "logicalOr.qml"; + QTest::newRow("conditional expressions") << "conditionalExpr.qml"; + QTest::newRow("double bool jump") << "doubleBoolJump.qml"; + QTest::newRow("unary minus") << "unaryMinus.qml"; + QTest::newRow("null qobject") << "nullQObject.qml"; +} + +void tst_v4::unnecessaryReeval() +{ + QQmlComponent component(&engine, testFileUrl("unnecessaryReeval.qml")); + + QObject *o = component.create(); + QVERIFY(o != 0); + + ResultObject *ro = qobject_cast(o); + QVERIFY(ro != 0); + + QCOMPARE(ro->resultCounter(), 1); + QCOMPARE(ro->result(), 19); + ro->resetResultCounter(); + + ro->setProperty("b", 6); + + QCOMPARE(ro->resultCounter(), 1); + QCOMPARE(ro->result(), 6); + ro->resetResultCounter(); + + ro->setProperty("a", 14); + + QCOMPARE(ro->resultCounter(), 1); + QCOMPARE(ro->result(), 7); + ro->resetResultCounter(); + + ro->setProperty("b", 14); + QCOMPARE(ro->resultCounter(), 0); + QCOMPARE(ro->result(), 7); + + delete o; +} + +void tst_v4::logicalOr() +{ + { + QQmlComponent component(&engine, testFileUrl("logicalOr.qml")); + + QObject *o = component.create(); + QVERIFY(o != 0); + + ResultObject *ro = qobject_cast(o); + QVERIFY(ro != 0); + + QCOMPARE(ro->result(), 0); + delete o; + } + + { + QQmlComponent component(&engine, testFileUrl("logicalOr.2.qml")); + + QObject *o = component.create(); + QVERIFY(o != 0); + + ResultObject *ro = qobject_cast(o); + QVERIFY(ro != 0); + + QCOMPARE(ro->result(), 1); + delete o; + } +} + +void tst_v4::nestedLogicalOr() +{ + //we are primarily testing that v4 does not get caught in a loop (QTBUG-24038) + QQmlComponent component(&engine, testFileUrl("nestedLogicalOr.qml")); + + QObject *o = component.create(); + QVERIFY(o != 0); + + ResultObject *ro = qobject_cast(o); + QVERIFY(ro != 0); + + QCOMPARE(ro->result(), 1); + delete o; +} + +void tst_v4::conditionalExpr() +{ + { + QQmlComponent component(&engine, testFileUrl("conditionalExpr.qml")); + + QObject *o = component.create(); + QVERIFY(o != 0); + + ResultObject *ro = qobject_cast(o); + QVERIFY(ro != 0); + + QCOMPARE(ro->result(), 0); + delete o; + } +} + +// This would previously use the metaObject of the root element to result the nested access. +// That is, the index for accessing "result" would have been RootObject::result, instead of +// NestedObject::result. +void tst_v4::nestedObjectAccess() +{ + QQmlComponent component(&engine, testFileUrl("nestedObjectAccess.qml")); + + QObject *o = component.create(); + QVERIFY(o != 0); + + ResultObject *ro = qobject_cast(o); + QVERIFY(ro != 0); + + QCOMPARE(ro->result(), 37); + + delete o; +} + +void tst_v4::subscriptionsInConditionalExpressions() +{ + QQmlComponent component(&engine, testFileUrl("subscriptionsInConditionalExpressions.qml")); + + QObject *o = component.create(); + QVERIFY(o != 0); + + QObject *ro = qobject_cast(o); + QVERIFY(ro != 0); + + QCOMPARE(ro->property("result").toReal(), qreal(2)); + + delete o; +} + +// Crash test +void tst_v4::qtbug_21883() +{ + QQmlComponent component(&engine, testFileUrl("qtbug_21883.qml")); + + QString warning = component.url().toString() + ":4: Unable to assign null to ResultObject*"; + QTest::ignoreMessage(QtWarningMsg, warning.toLatin1().constData()); + + QObject *o = component.create(); + QVERIFY(o != 0); + delete o; +} + +void tst_v4::qtbug_22816() +{ + QQmlComponent component(&engine, testFileUrl("qtbug_22816.qml")); + + QObject *o = component.create(); + QVERIFY(o != 0); + QCOMPARE(o->property("test1").toBool(), false); + QCOMPARE(o->property("test2").toBool(), false); + delete o; +} + +void tst_v4::stringComparison() +{ + QQmlComponent component(&engine, testFileUrl("stringComparison.qml")); + + QObject *o = component.create(); + QVERIFY(o != 0); + QCOMPARE(o->property("test1").toBool(), true); + QCOMPARE(o->property("test2").toBool(), true); + QCOMPARE(o->property("test3").toBool(), true); + QCOMPARE(o->property("test4").toBool(), true); + QCOMPARE(o->property("test5").toBool(), true); + QCOMPARE(o->property("test6").toBool(), true); + QCOMPARE(o->property("test7").toBool(), true); + QCOMPARE(o->property("test8").toBool(), true); + QCOMPARE(o->property("test9").toBool(), true); + QCOMPARE(o->property("test10").toBool(), true); + QCOMPARE(o->property("test11").toBool(), true); + QCOMPARE(o->property("test12").toBool(), true); + QCOMPARE(o->property("test13").toBool(), true); + QCOMPARE(o->property("test14").toBool(), true); + QCOMPARE(o->property("test15").toBool(), true); + QCOMPARE(o->property("test16").toBool(), true); + QCOMPARE(o->property("test17").toBool(), true); + QCOMPARE(o->property("test18").toBool(), true); + QCOMPARE(o->property("test19").toBool(), true); + QCOMPARE(o->property("test20").toBool(), true); + QCOMPARE(o->property("test21").toBool(), true); + QCOMPARE(o->property("test22").toBool(), true); + delete o; +} + +void tst_v4::unaryMinus() +{ + QQmlComponent component(&engine, testFileUrl("unaryMinus.qml")); + + QObject *o = component.create(); + QVERIFY(o != 0); + + QCOMPARE(o->property("test1").toReal(), qreal(-18)); + QCOMPARE(o->property("test2").toInt(), -18); + QCOMPARE(o->property("test3").toReal(), qreal(3.7)); + QCOMPARE(o->property("test4").toInt(), 4); + QCOMPARE(o->property("test5").toReal(), qreal(3.3)); + QCOMPARE(o->property("test6").toInt(), 3); + QCOMPARE(o->property("test7").toReal(), qreal(7)); + QCOMPARE(o->property("test8").toInt(), 7); + QCOMPARE(o->property("test9").toReal(), qreal(-4.4)); + QCOMPARE(o->property("test10").toInt(), -4); + + delete o; +} + +void tst_v4::unaryPlus() +{ + QQmlComponent component(&engine, testFileUrl("unaryPlus.qml")); + + QObject *o = component.create(); + QVERIFY(o != 0); + + QCOMPARE(o->property("test1").toReal(), qreal(18)); + QCOMPARE(o->property("test2").toInt(), 18); + QCOMPARE(o->property("test3").toReal(), qreal(-3.7)); + QCOMPARE(o->property("test4").toInt(), -4); + QCOMPARE(o->property("test5").toReal(), qreal(-3.3)); + QCOMPARE(o->property("test6").toInt(), -3); + QCOMPARE(o->property("test7").toReal(), qreal(-7)); + QCOMPARE(o->property("test8").toInt(), -7); + QCOMPARE(o->property("test9").toReal(), qreal(4.4)); + QCOMPARE(o->property("test10").toInt(), 4); + + delete o; +} + +QTEST_MAIN(tst_v4) + +#include "tst_v4.moc" diff --git a/tests/auto/qml/v4/v4.pro b/tests/auto/qml/v4/v4.pro new file mode 100644 index 0000000000..df8e7b1c3c --- /dev/null +++ b/tests/auto/qml/v4/v4.pro @@ -0,0 +1,17 @@ +CONFIG += testcase +TARGET = tst_qqmlv4 +macx:CONFIG -= app_bundle + +SOURCES += tst_v4.cpp \ + testtypes.cpp +HEADERS += testtypes.h + +include (../../shared/util.pri) + +testDataFiles.files = data +testDataFiles.path = . +DEPLOYMENT += testDataFiles + +CONFIG += parallel_test + +QT += core-private gui-private v8-private qml-private network testlib diff --git a/tests/auto/qmldevtools/compile/tst_compile.cpp b/tests/auto/qmldevtools/compile/tst_compile.cpp index bcd602b8bc..0955eb4a8e 100644 --- a/tests/auto/qmldevtools/compile/tst_compile.cpp +++ b/tests/auto/qmldevtools/compile/tst_compile.cpp @@ -40,11 +40,11 @@ ****************************************************************************/ #include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include class tst_compile : public QObject { diff --git a/tests/auto/qmltest/createbenchmark/item.qml b/tests/auto/qmltest/createbenchmark/item.qml index ebc50ceb13..af6c2f3f59 100644 --- a/tests/auto/qmltest/createbenchmark/item.qml +++ b/tests/auto/qmltest/createbenchmark/item.qml @@ -3,7 +3,7 @@ ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/ ** -** This file is part of the QtDeclarative module of the Qt Toolkit. +** This file is part of the QtQml module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ ** GNU Lesser General Public License Usage diff --git a/tests/auto/qmltest/qdeclarativebinding/tst_binding.qml b/tests/auto/qmltest/qdeclarativebinding/tst_binding.qml deleted file mode 100644 index 0948046bcf..0000000000 --- a/tests/auto/qmltest/qdeclarativebinding/tst_binding.qml +++ /dev/null @@ -1,75 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 -import QtTest 1.0 - -Rectangle { - id: screen - width: 320; height: 240 - property string text - property bool changeColor: false - - Text { id: s1; text: "Hello" } - Rectangle { id: r1; width: 1; height: 1; color: "yellow" } - Rectangle { id: r2; width: 1; height: 1; color: "red" } - - Binding { target: screen; property: "text"; value: s1.text; id: binding1 } - Binding { target: screen; property: "color"; value: r1.color } - Binding { target: screen; property: "color"; when: screen.changeColor == true; value: r2.color; id: binding3 } - - TestCase { - name: "Binding" - - function test_binding() { - compare(screen.color, "#ffff00") // Yellow - compare(screen.text, "Hello") - verify(!binding3.when) - - screen.changeColor = true - compare(screen.color, "#ff0000") // Red - - verify(binding1.target == screen) - compare(binding1.property, "text") - compare(binding1.value, "Hello") - } - } -} diff --git a/tests/auto/qmltest/qdeclarativebinding/tst_binding2.qml b/tests/auto/qmltest/qdeclarativebinding/tst_binding2.qml deleted file mode 100644 index 87a30e2c14..0000000000 --- a/tests/auto/qmltest/qdeclarativebinding/tst_binding2.qml +++ /dev/null @@ -1,70 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 -import QtTest 1.0 - -Rectangle { - id: screen - width: 320; height: 240 - property string text - property bool changeColor: false - - Text { id: s1; text: "Hello" } - Rectangle { id: r1; width: 1; height: 1; color: "yellow" } - Rectangle { id: r2; width: 1; height: 1; color: "red" } - - Binding { target: screen; property: "text"; value: s1.text } - Binding { target: screen; property: "color"; value: r1.color } - Binding { target: screen; property: "color"; value: r2.color; when: screen.changeColor == true } - - TestCase { - name: "Binding2" - - function test_binding2() { - compare(screen.color, "#ffff00") // Yellow - compare(screen.text, "Hello") - - screen.changeColor = true - compare(screen.color, "#ff0000") // Red - } - } -} diff --git a/tests/auto/qmltest/qmltest.pro b/tests/auto/qmltest/qmltest.pro index d0bc8a89cd..b1b2ee2228 100644 --- a/tests/auto/qmltest/qmltest.pro +++ b/tests/auto/qmltest/qmltest.pro @@ -4,7 +4,7 @@ CONFIG += warn_on qmltestcase SOURCES += tst_qmltest.cpp -importFiles.files = borderimage buttonclick createbenchmark events qdeclarativebinding selftests +importFiles.files = borderimage buttonclick createbenchmark events qqmlbinding selftests importFiles.path = . DEPLOYMENT += importFiles diff --git a/tests/auto/qmltest/qqmlbinding/tst_binding.qml b/tests/auto/qmltest/qqmlbinding/tst_binding.qml new file mode 100644 index 0000000000..0948046bcf --- /dev/null +++ b/tests/auto/qmltest/qqmlbinding/tst_binding.qml @@ -0,0 +1,75 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import QtTest 1.0 + +Rectangle { + id: screen + width: 320; height: 240 + property string text + property bool changeColor: false + + Text { id: s1; text: "Hello" } + Rectangle { id: r1; width: 1; height: 1; color: "yellow" } + Rectangle { id: r2; width: 1; height: 1; color: "red" } + + Binding { target: screen; property: "text"; value: s1.text; id: binding1 } + Binding { target: screen; property: "color"; value: r1.color } + Binding { target: screen; property: "color"; when: screen.changeColor == true; value: r2.color; id: binding3 } + + TestCase { + name: "Binding" + + function test_binding() { + compare(screen.color, "#ffff00") // Yellow + compare(screen.text, "Hello") + verify(!binding3.when) + + screen.changeColor = true + compare(screen.color, "#ff0000") // Red + + verify(binding1.target == screen) + compare(binding1.property, "text") + compare(binding1.value, "Hello") + } + } +} diff --git a/tests/auto/qmltest/qqmlbinding/tst_binding2.qml b/tests/auto/qmltest/qqmlbinding/tst_binding2.qml new file mode 100644 index 0000000000..87a30e2c14 --- /dev/null +++ b/tests/auto/qmltest/qqmlbinding/tst_binding2.qml @@ -0,0 +1,70 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import QtTest 1.0 + +Rectangle { + id: screen + width: 320; height: 240 + property string text + property bool changeColor: false + + Text { id: s1; text: "Hello" } + Rectangle { id: r1; width: 1; height: 1; color: "yellow" } + Rectangle { id: r2; width: 1; height: 1; color: "red" } + + Binding { target: screen; property: "text"; value: s1.text } + Binding { target: screen; property: "color"; value: r1.color } + Binding { target: screen; property: "color"; value: r2.color; when: screen.changeColor == true } + + TestCase { + name: "Binding2" + + function test_binding2() { + compare(screen.color, "#ffff00") // Yellow + compare(screen.text, "Hello") + + screen.changeColor = true + compare(screen.color, "#ff0000") // Red + } + } +} diff --git a/tests/auto/qtquick2/examples/data/dummytest.qml b/tests/auto/qtquick2/examples/data/dummytest.qml deleted file mode 100644 index b20e907f27..0000000000 --- a/tests/auto/qtquick2/examples/data/dummytest.qml +++ /dev/null @@ -1,6 +0,0 @@ -import Qt.VisualTest 4.6 - -VisualTest { - Frame { msec: 0 } - Frame { msec: 10 } -} diff --git a/tests/auto/qtquick2/examples/data/webbrowser/webbrowser.qml b/tests/auto/qtquick2/examples/data/webbrowser/webbrowser.qml deleted file mode 100644 index d31787b939..0000000000 --- a/tests/auto/qtquick2/examples/data/webbrowser/webbrowser.qml +++ /dev/null @@ -1,6 +0,0 @@ -import Qt.VisualTest 4.6 - -VisualTest { - Frame { msec: 0 } - Frame { msec: 2000 } -} diff --git a/tests/auto/qtquick2/examples/examples.pro b/tests/auto/qtquick2/examples/examples.pro deleted file mode 100644 index 577c145e77..0000000000 --- a/tests/auto/qtquick2/examples/examples.pro +++ /dev/null @@ -1,10 +0,0 @@ -CONFIG += testcase -TARGET = tst_examples -macx:CONFIG -= app_bundle - -SOURCES += tst_examples.cpp -DEFINES += SRCDIR=\\\"$$PWD\\\" - -CONFIG += parallel_test -#temporary -QT += core-private gui-private declarative-private quick-private widgets-private v8-private testlib diff --git a/tests/auto/qtquick2/examples/tst_examples.cpp b/tests/auto/qtquick2/examples/tst_examples.cpp deleted file mode 100644 index 0e420f7277..0000000000 --- a/tests/auto/qtquick2/examples/tst_examples.cpp +++ /dev/null @@ -1,307 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -static QtMsgHandler testlibMsgHandler = 0; -void msgHandlerFilter(QtMsgType type, const char *msg) -{ - if (type == QtCriticalMsg || type == QtFatalMsg) - (*testlibMsgHandler)(type, msg); -} - -class tst_examples : public QObject -{ - Q_OBJECT -public: - tst_examples(); - -private slots: - void init(); - void cleanup(); - - void sgexamples_data(); - void sgexamples(); - void sgsnippets_data(); - void sgsnippets(); - - void namingConvention(); -private: - QStringList excludedDirs; - QStringList excludedFiles; - - void namingConvention(const QDir &); - QStringList findQmlFiles(const QDir &); - - QDeclarativeEngine engine; -}; - -tst_examples::tst_examples() -{ - // Add files to exclude here - excludedFiles << "doc/src/snippets/declarative/listmodel.qml"; //Just a ListModel, no root QQuickItem - - // Add directories you want excluded here - excludedDirs << "examples/declarative/text/fonts"; // QTBUG-21415 - excludedDirs << "doc/src/snippets/declarative/path"; //No root QQuickItem - - // Not run in QQuickView - excludedDirs << "examples/declarative/qtquick1"; - - // These snippets are not expected to run on their own. - excludedDirs << "doc/src/snippets/declarative/visualdatamodel_rootindex"; - excludedDirs << "doc/src/snippets/declarative/qtbinding"; - excludedDirs << "doc/src/snippets/declarative/imports"; - excludedDirs << "doc/src/snippets/qtquick1/visualdatamodel_rootindex"; - excludedDirs << "doc/src/snippets/qtquick1/qtbinding"; - excludedDirs << "doc/src/snippets/qtquick1/imports"; - -#ifdef QT_NO_WEBKIT - excludedDirs << "examples/declarative/modelviews/webview"; - excludedDirs << "examples/declarative/webbrowser"; - excludedDirs << "doc/src/snippets/declarative/webview"; - excludedDirs << "doc/src/snippets/qtquick1/webview"; -#endif - -#ifdef QT_NO_XMLPATTERNS - excludedDirs << "examples/declarative/xml/xmldata"; - excludedDirs << "examples/declarative/twitter"; - excludedDirs << "examples/declarative/flickr"; - excludedDirs << "examples/declarative/photoviewer"; -#endif -} - -void tst_examples::init() -{ - if (!qstrcmp(QTest::currentTestFunction(), "sgsnippets")) - testlibMsgHandler = qInstallMsgHandler(msgHandlerFilter); -} - -void tst_examples::cleanup() -{ - if (!qstrcmp(QTest::currentTestFunction(), "sgsnippets")) - qInstallMsgHandler(testlibMsgHandler); -} - -/* -This tests that the examples follow the naming convention required -to have them tested by the examples() test. -*/ -void tst_examples::namingConvention(const QDir &d) -{ - for (int ii = 0; ii < excludedDirs.count(); ++ii) { - QString s = excludedDirs.at(ii); - if (d.absolutePath().endsWith(s)) - return; - } - - QStringList files = d.entryList(QStringList() << QLatin1String("*.qml"), - QDir::Files); - - bool seenQml = !files.isEmpty(); - bool seenLowercase = false; - - foreach (const QString &file, files) { - if (file.at(0).isLower()) - seenLowercase = true; - } - - if (!seenQml) { - QStringList dirs = d.entryList(QDir::Dirs | QDir::NoDotAndDotDot | - QDir::NoSymLinks); - foreach (const QString &dir, dirs) { - QDir sub = d; - sub.cd(dir); - namingConvention(sub); - } - } else if(!seenLowercase) { - QFAIL(qPrintable(QString( - "Directory %1 violates naming convention; expected at least one qml file " - "starting with lower case, got: %2" - ).arg(d.absolutePath()).arg(files.join(",")))); - } -} - -void tst_examples::namingConvention() -{ - QString examples = QLibraryInfo::location(QLibraryInfo::ExamplesPath); - - namingConvention(QDir(examples)); -} - -QStringList tst_examples::findQmlFiles(const QDir &d) -{ - for (int ii = 0; ii < excludedDirs.count(); ++ii) { - QString s = excludedDirs.at(ii); - if (d.absolutePath().endsWith(s)) - return QStringList(); - } - - QStringList rv; - - QStringList cppfiles = d.entryList(QStringList() << QLatin1String("*.cpp"), QDir::Files); - if (cppfiles.isEmpty()) { - QStringList files = d.entryList(QStringList() << QLatin1String("*.qml"), - QDir::Files); - foreach (const QString &file, files) { - if (file.at(0).isLower()) { - bool superContinue = false; - for (int ii = 0; ii < excludedFiles.count(); ++ii) { - QString e = excludedFiles.at(ii); - if (d.absoluteFilePath(file).endsWith(e)) { - superContinue = true; - break; - } - } - if (superContinue) - continue; - rv << d.absoluteFilePath(file); - } - } - } - - - QStringList dirs = d.entryList(QDir::Dirs | QDir::NoDotAndDotDot | - QDir::NoSymLinks); - foreach (const QString &dir, dirs) { - QDir sub = d; - sub.cd(dir); - rv << findQmlFiles(sub); - } - - return rv; -} - -/* -This test runs all the examples in the declarative UI source tree and ensures -that they start and exit cleanly. - -Examples are any .qml files under the examples/ directory that start -with a lower case letter. -*/ -void tst_examples::sgexamples_data() -{ - QTest::addColumn("file"); - - QString examples = QLatin1String(SRCDIR) + "/../../../../examples/declarative/"; - QString tutorials = QLatin1String(SRCDIR) + "/../../../../examples/tutorials/"; //Only declarative tutorials since modularization - - QStringList files; - files << findQmlFiles(QDir(examples)); - files << findQmlFiles(QDir(tutorials)); - - foreach (const QString &file, files) - QTest::newRow(qPrintable(file)) << file; -} - -void tst_examples::sgexamples() -{ - QFETCH(QString, file); - - QDeclarativeComponent component(&engine, QUrl::fromLocalFile(file)); - if (component.status() == QDeclarativeComponent::Error) - qWarning() << component.errors(); - QCOMPARE(component.status(), QDeclarativeComponent::Ready); - - QScopedPointer object(component.beginCreate(engine.rootContext())); - QQuickItem *root = qobject_cast(object.data()); - if (!root) - component.completeCreate(); - QVERIFY(root); - - QQuickCanvas canvas; - root->setParentItem(canvas.rootItem()); - component.completeCreate(); - canvas.show(); - - QTest::qWaitForWindowShown(&canvas); - -} - -void tst_examples::sgsnippets_data() -{ - QTest::addColumn("file"); - - QString snippets = QLatin1String(SRCDIR) + "/../../../../doc/src/snippets/declarative"; - - QStringList files; - files << findQmlFiles(QDir(snippets)); - - foreach (const QString &file, files) - QTest::newRow(qPrintable(file)) << file; -} - -void tst_examples::sgsnippets() -{ - QFETCH(QString, file); - - QDeclarativeComponent component(&engine, QUrl::fromLocalFile(file)); - if (component.status() == QDeclarativeComponent::Error) - qWarning() << component.errors(); - QCOMPARE(component.status(), QDeclarativeComponent::Ready); - - QScopedPointer object(component.beginCreate(engine.rootContext())); - QQuickItem *root = qobject_cast(object.data()); - if (!root) - component.completeCreate(); - QVERIFY(root); - - QQuickCanvas canvas; - root->setParentItem(canvas.rootItem()); - component.completeCreate(); - canvas.show(); - - QTest::qWaitForWindowShown(&canvas); - -} - -QTEST_MAIN(tst_examples) - -#include "tst_examples.moc" diff --git a/tests/auto/qtquick2/geometry/geometry.pro b/tests/auto/qtquick2/geometry/geometry.pro deleted file mode 100644 index 04d529cfb8..0000000000 --- a/tests/auto/qtquick2/geometry/geometry.pro +++ /dev/null @@ -1,9 +0,0 @@ -CONFIG += testcase -TARGET = tst_geometry -macx:CONFIG -= app_bundle - -SOURCES += tst_geometry.cpp - -CONFIG+=parallel_test - -QT += core-private gui-private declarative-private quick-private opengl testlib diff --git a/tests/auto/qtquick2/geometry/tst_geometry.cpp b/tests/auto/qtquick2/geometry/tst_geometry.cpp deleted file mode 100644 index 8d8f45b8cb..0000000000 --- a/tests/auto/qtquick2/geometry/tst_geometry.cpp +++ /dev/null @@ -1,181 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the Qt scene graph research project. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include -#include - -#include - -class GeometryTest : public QObject -{ - Q_OBJECT - -public: - -private Q_SLOTS: - void testPoint2D(); - void testTexturedPoint2D(); - void testCustomGeometry(); - -private: -}; - -void GeometryTest::testPoint2D() -{ - QSGGeometry geometry(QSGGeometry::defaultAttributes_Point2D(), 4, 0); - - QCOMPARE(geometry.attributeCount(), 1); - QCOMPARE(geometry.sizeOfVertex(), (int) sizeof(float) * 2); - QCOMPARE(geometry.vertexCount(), 4); - QCOMPARE(geometry.indexCount(), 0); - QVERIFY(geometry.indexData() == 0); - - QSGGeometry::updateRectGeometry(&geometry, QRectF(1, 2, 3, 4)); - - QSGGeometry::Point2D *pts = geometry.vertexDataAsPoint2D(); - QVERIFY(pts != 0); - - QCOMPARE(pts[0].x, (float) 1); - QCOMPARE(pts[0].y, (float) 2); - QCOMPARE(pts[3].x, (float) 4); - QCOMPARE(pts[3].y, (float) 6); - - // Verify that resize gives me enough allocated data without crashing... - geometry.allocate(100, 100); - pts = geometry.vertexDataAsPoint2D(); - quint16 *is = geometry.indexDataAsUShort(); - for (int i=0; i<100; ++i) { - pts[i].x = i; - pts[i].y = i + 100; - is[i] = i; - } - QVERIFY(true); -} - - -void GeometryTest::testTexturedPoint2D() -{ - QSGGeometry geometry(QSGGeometry::defaultAttributes_TexturedPoint2D(), 4, 0); - - QCOMPARE(geometry.attributeCount(), 2); - QCOMPARE(geometry.sizeOfVertex(), (int) sizeof(float) * 4); - QCOMPARE(geometry.vertexCount(), 4); - QCOMPARE(geometry.indexCount(), 0); - QVERIFY(geometry.indexData() == 0); - - QSGGeometry::updateTexturedRectGeometry(&geometry, QRectF(1, 2, 3, 4), QRectF(5, 6, 7, 8)); - - QSGGeometry::TexturedPoint2D *pts = geometry.vertexDataAsTexturedPoint2D(); - QVERIFY(pts != 0); - - QCOMPARE(pts[0].x, (float) 1); - QCOMPARE(pts[0].y, (float) 2); - QCOMPARE(pts[0].tx, (float) 5); - QCOMPARE(pts[0].ty, (float) 6); - - QCOMPARE(pts[3].x, (float) 4); - QCOMPARE(pts[3].y, (float) 6); - QCOMPARE(pts[3].tx, (float) 12); - QCOMPARE(pts[3].ty, (float) 14); - - // Verify that resize gives me enough allocated data without crashing... - geometry.allocate(100, 100); - pts = geometry.vertexDataAsTexturedPoint2D(); - quint16 *is = geometry.indexDataAsUShort(); - for (int i=0; i<100; ++i) { - pts[i].x = i; - pts[i].y = i + 100; - pts[i].tx = i + 200; - pts[i].ty = i + 300; - is[i] = i; - } - QVERIFY(true); -} - -void GeometryTest::testCustomGeometry() -{ - struct V { - float x, y; - unsigned char r, g, b, a; - float v1, v2, v3, v4; - }; - - static QSGGeometry::Attribute attributes[] = { - { 0, 2, GL_FLOAT }, - { 1, 4, GL_UNSIGNED_BYTE }, - { 2, 4, GL_FLOAT }, - }; - static QSGGeometry::AttributeSet set = { 4, 6 * sizeof(float) + 4 * sizeof(unsigned char), attributes }; - - QSGGeometry geometry(set, 1000, 4000); - - // Verify that space has been allocated. - quint16 *ii = geometry.indexDataAsUShort(); - for (int i=0; i -#include - -#include -#include -#include - -#include -#include -class NodesTest : public QObject -{ - Q_OBJECT - -public: - NodesTest(); - -private Q_SLOTS: - void initTestCase(); - void cleanupTestCase() { - delete widget; - } - - // Root nodes - void propegate(); - void propegateWithMultipleRoots(); - void simulatedEffect_data(); - void simulatedEffect(); - - // Opacity nodes - void basicOpacityNode(); - void opacityPropegation(); - - // QSGNodeUpdater - void isBlockedCheck(); - -private: - QGLWidget *widget; - - QSGNodeUpdater updater; -}; - -void NodesTest::initTestCase() -{ - widget = new QGLWidget(); - widget->resize(100, 30); - widget->show(); -} - -class DummyRenderer : public QSGRenderer -{ -public: - DummyRenderer(QSGRootNode *root) - : QSGRenderer(QSGContext::createDefaultContext()) - , changedNode(0) - , changedState(0) - , renderCount(0) - { - setRootNode(root); - } - - void render() { - ++renderCount; - renderingOrder = ++globalRendereringOrder; - } - - void nodeChanged(QSGNode *node, QSGNode::DirtyState state) { - changedNode = node; - changedState = state; - QSGRenderer::nodeChanged(node, state); - } - - QSGNode *changedNode; - QSGNode::DirtyState changedState; - - int renderCount; - int renderingOrder; - static int globalRendereringOrder; -}; - -int DummyRenderer::globalRendereringOrder; - -NodesTest::NodesTest() -{ -} - - -void NodesTest::propegate() -{ - QSGRootNode root; - QSGNode child; child.setFlag(QSGNode::OwnedByParent, false); - root.appendChildNode(&child); - - DummyRenderer renderer(&root); - - child.markDirty(QSGNode::DirtyGeometry); - - QCOMPARE(&child, renderer.changedNode); - QCOMPARE((int) renderer.changedState, (int) QSGNode::DirtyGeometry); -} - - -void NodesTest::propegateWithMultipleRoots() -{ - QSGRootNode root1; - QSGNode child2; child2.setFlag(QSGNode::OwnedByParent, false); - QSGRootNode root3; root3.setFlag(QSGNode::OwnedByParent, false); - QSGNode child4; child4.setFlag(QSGNode::OwnedByParent, false); - - root1.appendChildNode(&child2); - child2.appendChildNode(&root3); - root3.appendChildNode(&child4); - - DummyRenderer ren1(&root1); - DummyRenderer ren2(&root3); - - child4.markDirty(QSGNode::DirtyGeometry); - - QCOMPARE(ren1.changedNode, &child4); - QCOMPARE(ren2.changedNode, &child4); - - QCOMPARE((int) ren1.changedState, (int) QSGNode::DirtyGeometry); - QCOMPARE((int) ren2.changedState, (int) QSGNode::DirtyGeometry); -} - - - -class SimulatedEffectRenderer : public DummyRenderer -{ -public: - SimulatedEffectRenderer(QSGRootNode *root, QSGBasicGeometryNode *c) - : DummyRenderer(root) - { - child = c; - } - - void render() { - matrix = child->matrix() ? *child->matrix() : QMatrix4x4(); - DummyRenderer::render(); - } - - QSGBasicGeometryNode *child; - QMatrix4x4 matrix; -}; - - -class PseudoEffectNode : public QSGNode { -public: - PseudoEffectNode(QSGRenderer *r) - : renderer(r) - { - setFlag(UsePreprocess); - } - - void preprocess() { - - if (renderer->rootNode()->parent()) { - // Mark the root dirty to build a clean state from the root and down - renderer->rootNode()->markDirty(QSGNode::DirtyForceUpdate); - } - - renderer->renderScene(); - - if (renderer->rootNode()->parent()) { - // Mark the parent of the root dirty to force the root and down to be updated. - renderer->rootNode()->parent()->markDirty(QSGNode::DirtyForceUpdate); - } - } - - QSGRenderer *renderer; -}; - -void NodesTest::simulatedEffect_data() -{ - QTest::addColumn("connected"); - - QTest::newRow("connected") << true; - QTest::newRow("disconnected") << false; -} - -void NodesTest::simulatedEffect() -{ - QFETCH(bool, connected); - - QSGRootNode root; - QSGRootNode source; - QSGTransformNode xform; - QSGSimpleRectNode geometry; - geometry.setRect(QRectF(0, 0, 1, 1)); - geometry.setColor(Qt::red); - - root.setFlag(QSGNode::OwnedByParent, false); - source.setFlag(QSGNode::OwnedByParent, false); - xform.setFlag(QSGNode::OwnedByParent, false); - geometry.setFlag(QSGNode::OwnedByParent, false); - - SimulatedEffectRenderer rootRenderer(&root, &geometry); - SimulatedEffectRenderer sourceRenderer(&source, &geometry); - - PseudoEffectNode effect(&sourceRenderer); - - /* - root Source is redirected into effect using the SimulatedEffectRenderer - / \ - xform effect - | - source - | - geometry - */ - - root.appendChildNode(&xform); - root.appendChildNode(&effect); - if (connected) - xform.appendChildNode(&source); - source.appendChildNode(&geometry); - QMatrix4x4 m; m.translate(1, 2, 3); - xform.setMatrix(m); - - // Clear all dirty states... - updater.updateStates(&root); - - rootRenderer.renderScene(); - - // compare that we got one render call to each - QCOMPARE(rootRenderer.renderCount, 1); - QCOMPARE(sourceRenderer.renderCount, 1); - QVERIFY(sourceRenderer.renderingOrder < rootRenderer.renderingOrder); - if (connected) // geometry is not rendered in this case, so skip it... - QCOMPARE(rootRenderer.matrix, xform.matrix()); - QCOMPARE(sourceRenderer.matrix, QMatrix4x4()); -} - -void NodesTest::basicOpacityNode() -{ - QSGOpacityNode n; - QCOMPARE(n.opacity(), 1.); - - n.setOpacity(0.5); - QCOMPARE(n.opacity(), 0.5); - - n.setOpacity(-1); - QCOMPARE(n.opacity(), 0.); - - n.setOpacity(2); - QCOMPARE(n.opacity(), 1.); -} - -void NodesTest::opacityPropegation() -{ - QSGRootNode root; - QSGOpacityNode *a = new QSGOpacityNode; - QSGOpacityNode *b = new QSGOpacityNode; - QSGOpacityNode *c = new QSGOpacityNode; - - QSGSimpleRectNode *geometry = new QSGSimpleRectNode; - geometry->setRect(0, 0, 100, 100); - - root.appendChildNode(a); - a->appendChildNode(b); - b->appendChildNode(c); - c->appendChildNode(geometry); - - a->setOpacity(0.9); - b->setOpacity(0.8); - c->setOpacity(0.7); - - updater.updateStates(&root); - - QCOMPARE(a->combinedOpacity(), 0.9); - QCOMPARE(b->combinedOpacity(), 0.9 * 0.8); - QCOMPARE(c->combinedOpacity(), 0.9 * 0.8 * 0.7); - QCOMPARE(geometry->inheritedOpacity(), 0.9 * 0.8 * 0.7); - - b->setOpacity(0.1); - updater.updateStates(&root); - - QCOMPARE(a->combinedOpacity(), 0.9); - QCOMPARE(b->combinedOpacity(), 0.9 * 0.1); - QCOMPARE(c->combinedOpacity(), 0.9 * 0.1 * 0.7); - QCOMPARE(geometry->inheritedOpacity(), 0.9 * 0.1 * 0.7); - - b->setOpacity(0); - updater.updateStates(&root); - - QVERIFY(b->isSubtreeBlocked()); - - // Verify that geometry did not get updated as it is in a blocked - // subtree - QCOMPARE(c->combinedOpacity(), 0.9 * 0.1 * 0.7); - QCOMPARE(geometry->inheritedOpacity(), 0.9 * 0.1 * 0.7); -} - -void NodesTest::isBlockedCheck() -{ - QSGRootNode root; - QSGOpacityNode *opacity = new QSGOpacityNode(); - QSGNode *node = new QSGNode(); - - root.appendChildNode(opacity); - opacity->appendChildNode(node); - - QSGNodeUpdater updater; - - opacity->setOpacity(0); - QVERIFY(updater.isNodeBlocked(node, &root)); - - opacity->setOpacity(1); - QVERIFY(!updater.isNodeBlocked(node, &root)); -} - -QTEST_MAIN(NodesTest); - -#include "tst_nodestest.moc" diff --git a/tests/auto/qtquick2/qdeclarativeanimationcontroller/data/tst_numberanimation.qml b/tests/auto/qtquick2/qdeclarativeanimationcontroller/data/tst_numberanimation.qml deleted file mode 100644 index 7c4496b206..0000000000 --- a/tests/auto/qtquick2/qdeclarativeanimationcontroller/data/tst_numberanimation.qml +++ /dev/null @@ -1,38 +0,0 @@ -import QtQuick 2.0 -import QtTest 1.0 - -Rectangle { - id:container - width:50 - height:50 - - Rectangle {id:rect; x:0; y:0; color:"red"; width:10; height:10} - AnimationController { - id:numberAnimationcontroller - progress:1 - animation: NumberAnimation {target: rect; property: "x"; from:0; to:40; duration: 1000} - } - - TestCase { - name:"AnimationController" - when:windowShown - function test_numberAnimation() { - numberAnimationcontroller.progress = 0; - compare(rect.x, 0); - numberAnimationcontroller.progress = 0.5; - compare(rect.x, 20); - - // <=0 -> 0 - numberAnimationcontroller.progress = -1; - compare(rect.x, 0); - - //>=1 -> 1 - numberAnimationcontroller.progress = 1.1; - compare(rect.x, 40); - - //make sure the progress can be set backward - numberAnimationcontroller.progress = 0.5; - compare(rect.x, 20); - } - } -} \ No newline at end of file diff --git a/tests/auto/qtquick2/qdeclarativeanimationcontroller/qdeclarativeanimationcontroller.pro b/tests/auto/qtquick2/qdeclarativeanimationcontroller/qdeclarativeanimationcontroller.pro deleted file mode 100644 index 52cafc33a6..0000000000 --- a/tests/auto/qtquick2/qdeclarativeanimationcontroller/qdeclarativeanimationcontroller.pro +++ /dev/null @@ -1,10 +0,0 @@ -QT += core-private gui-private declarative-private -TEMPLATE=app -TARGET=tst_qdeclarativeanimationcontroller - -CONFIG += warn_on qmltestcase -SOURCES += tst_qdeclarativeanimationcontroller.cpp - -importFiles.files = data -importFiles.path = . -DEPLOYMENT += importFiles diff --git a/tests/auto/qtquick2/qdeclarativeanimationcontroller/tst_qdeclarativeanimationcontroller.cpp b/tests/auto/qtquick2/qdeclarativeanimationcontroller/tst_qdeclarativeanimationcontroller.cpp deleted file mode 100644 index 744f92b99d..0000000000 --- a/tests/auto/qtquick2/qdeclarativeanimationcontroller/tst_qdeclarativeanimationcontroller.cpp +++ /dev/null @@ -1,42 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include -QUICK_TEST_MAIN(qdeclarativeanimationcontroller) diff --git a/tests/auto/qtquick2/qdeclarativeanimations/data/Double.qml b/tests/auto/qtquick2/qdeclarativeanimations/data/Double.qml deleted file mode 100644 index 99ffca1d62..0000000000 --- a/tests/auto/qtquick2/qdeclarativeanimations/data/Double.qml +++ /dev/null @@ -1,14 +0,0 @@ -import QtQuick 2.0 - -Rectangle { - id: container - property bool on: false - border.color: "#ffffff" - color: "green" - width: 50 - height: 50 - NumberAnimation on x { - objectName: "animation" - running: container.on; from: 0; to: 600; loops: Animation.Infinite; duration: 2000 - } -} diff --git a/tests/auto/qtquick2/qdeclarativeanimations/data/attached.qml b/tests/auto/qtquick2/qdeclarativeanimations/data/attached.qml deleted file mode 100644 index 9dcfcd8752..0000000000 --- a/tests/auto/qtquick2/qdeclarativeanimations/data/attached.qml +++ /dev/null @@ -1,34 +0,0 @@ -import QtQuick 2.0 - -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(wrapper.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/qtquick2/qdeclarativeanimations/data/badproperty1.qml b/tests/auto/qtquick2/qdeclarativeanimations/data/badproperty1.qml deleted file mode 100644 index 9634c2c169..0000000000 --- a/tests/auto/qtquick2/qdeclarativeanimations/data/badproperty1.qml +++ /dev/null @@ -1,21 +0,0 @@ -import QtQuick 2.0 - -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/qtquick2/qdeclarativeanimations/data/badproperty2.qml b/tests/auto/qtquick2/qdeclarativeanimations/data/badproperty2.qml deleted file mode 100644 index c121172a99..0000000000 --- a/tests/auto/qtquick2/qdeclarativeanimations/data/badproperty2.qml +++ /dev/null @@ -1,21 +0,0 @@ -import QtQuick 2.0 - -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/qtquick2/qdeclarativeanimations/data/badtype1.qml b/tests/auto/qtquick2/qdeclarativeanimations/data/badtype1.qml deleted file mode 100644 index 43e1ec8572..0000000000 --- a/tests/auto/qtquick2/qdeclarativeanimations/data/badtype1.qml +++ /dev/null @@ -1,12 +0,0 @@ -import QtQuick 2.0 - -Rectangle { - width: 240 - height: 320 - Rectangle { - color: "red" - width: 50; height: 50 - x: 100; y: 100 - PropertyAnimation on x { from: "blue"; to: "green"; } - } -} diff --git a/tests/auto/qtquick2/qdeclarativeanimations/data/badtype2.qml b/tests/auto/qtquick2/qdeclarativeanimations/data/badtype2.qml deleted file mode 100644 index 5341cb3d1c..0000000000 --- a/tests/auto/qtquick2/qdeclarativeanimations/data/badtype2.qml +++ /dev/null @@ -1,12 +0,0 @@ -import QtQuick 2.0 - -Rectangle { - width: 240 - height: 320 - Rectangle { - color: "red" - width: 50; height: 50 - x: 100; y: 100 - NumberAnimation on x { from: "blue"; to: "green"; } - } -} diff --git a/tests/auto/qtquick2/qdeclarativeanimations/data/badtype3.qml b/tests/auto/qtquick2/qdeclarativeanimations/data/badtype3.qml deleted file mode 100644 index 182efa0840..0000000000 --- a/tests/auto/qtquick2/qdeclarativeanimations/data/badtype3.qml +++ /dev/null @@ -1,12 +0,0 @@ -import QtQuick 2.0 - -Rectangle { - width: 240 - height: 320 - Rectangle { - color: "red" - ColorAnimation on color { from: 10; to: 15; } - width: 50; height: 50 - x: 100; y: 100 - } -} diff --git a/tests/auto/qtquick2/qdeclarativeanimations/data/badtype4.qml b/tests/auto/qtquick2/qdeclarativeanimations/data/badtype4.qml deleted file mode 100644 index f091e2430f..0000000000 --- a/tests/auto/qtquick2/qdeclarativeanimations/data/badtype4.qml +++ /dev/null @@ -1,27 +0,0 @@ -import QtQuick 2.0 - -Rectangle { - id: wrapper - width: 240 - height: 320 - Rectangle { - id: myRect - objectName: "MyRect" - color: "red" - width: 50; height: 50 - x: 100; y: 100 - MouseArea { - 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 { properties: "x,color"; duration: 1000 } //x is real, color is color - NumberAnimation { properties: "x,color"; duration: 1000 } //x is real, color is color - } -} diff --git a/tests/auto/qtquick2/qdeclarativeanimations/data/disabledTransition.qml b/tests/auto/qtquick2/qdeclarativeanimations/data/disabledTransition.qml deleted file mode 100644 index 0fbafead8b..0000000000 --- a/tests/auto/qtquick2/qdeclarativeanimations/data/disabledTransition.qml +++ /dev/null @@ -1,30 +0,0 @@ -import QtQuick 2.0 - -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 { - enabled: false - NumberAnimation { targets: theRect; properties: "x" } - } - - MouseArea { - anchors.fill: parent - onClicked: parent.state = "moved" - } -} diff --git a/tests/auto/qtquick2/qdeclarativeanimations/data/dontAutoStart.qml b/tests/auto/qtquick2/qdeclarativeanimations/data/dontAutoStart.qml deleted file mode 100644 index c0c0c65e3f..0000000000 --- a/tests/auto/qtquick2/qdeclarativeanimations/data/dontAutoStart.qml +++ /dev/null @@ -1,18 +0,0 @@ -import QtQuick 2.0 - -Rectangle { - id: wrapper - width: 600 - height: 400 - - Rectangle { - id: redRect - width: 100; height: 100 - color: Qt.rgba(1,0,0) - Behavior on x { - NumberAnimation { id: myAnim; objectName: "MyAnim"; target: redRect; property: "y"; to: 300; loops: Animation.Infinite} - } - - } - -} diff --git a/tests/auto/qtquick2/qdeclarativeanimations/data/dontStart.qml b/tests/auto/qtquick2/qdeclarativeanimations/data/dontStart.qml deleted file mode 100644 index 3eee0cfd35..0000000000 --- a/tests/auto/qtquick2/qdeclarativeanimations/data/dontStart.qml +++ /dev/null @@ -1,19 +0,0 @@ -import QtQuick 2.0 - -Rectangle { - id: wrapper - width: 600 - height: 400 - - Rectangle { - id: redRect - width: 100; height: 100 - color: Qt.rgba(1,0,0) - SequentialAnimation on x { - running: false - NumberAnimation { objectName: "MyAnim"; running: true } - } - - } - -} diff --git a/tests/auto/qtquick2/qdeclarativeanimations/data/dontStart2.qml b/tests/auto/qtquick2/qdeclarativeanimations/data/dontStart2.qml deleted file mode 100644 index e7b4164e4e..0000000000 --- a/tests/auto/qtquick2/qdeclarativeanimations/data/dontStart2.qml +++ /dev/null @@ -1,19 +0,0 @@ -import QtQuick 2.0 - -Rectangle { - id: wrapper - width: 600 - height: 400 - - Rectangle { - id: redRect - width: 100; height: 100 - color: Qt.rgba(1,0,0) - - transitions: Transition { - SequentialAnimation { - NumberAnimation { id: myAnim; objectName: "MyAnim"; running: true } - } - } - } -} diff --git a/tests/auto/qtquick2/qdeclarativeanimations/data/dotproperty.qml b/tests/auto/qtquick2/qdeclarativeanimations/data/dotproperty.qml deleted file mode 100644 index e0e46dcef5..0000000000 --- a/tests/auto/qtquick2/qdeclarativeanimations/data/dotproperty.qml +++ /dev/null @@ -1,24 +0,0 @@ -import QtQuick 2.0 - -Rectangle { - id: wrapper - width: 240 - height: 320 - Rectangle { - id: myRect - color: "red" - width: 50; height: 50 - x: 100; y: 100 - MouseArea { - 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 { properties: "border.color"; duration: 1000 } - } -} diff --git a/tests/auto/qtquick2/qdeclarativeanimations/data/doubleRegistrationBug.qml b/tests/auto/qtquick2/qdeclarativeanimations/data/doubleRegistrationBug.qml deleted file mode 100644 index 9ef3da20c0..0000000000 --- a/tests/auto/qtquick2/qdeclarativeanimations/data/doubleRegistrationBug.qml +++ /dev/null @@ -1,8 +0,0 @@ -import QtQuick 2.0 - -Rectangle { - width: 400; height: 400 - - Double { id: dub; on: parent.width < 800 } - Component.onCompleted: dub.on = false -} diff --git a/tests/auto/qtquick2/qdeclarativeanimations/data/looping.qml b/tests/auto/qtquick2/qdeclarativeanimations/data/looping.qml deleted file mode 100644 index a3d40ae837..0000000000 --- a/tests/auto/qtquick2/qdeclarativeanimations/data/looping.qml +++ /dev/null @@ -1,16 +0,0 @@ -import QtQuick 2.0 - -Item { - width: 200; height: 200 - - Rectangle { - x: 50; y: 50; width: 50; height: 50; color: "red" - - SequentialAnimation on rotation { - NumberAnimation { - from: 0; to: 90; duration: 100 - loops: 3 - } - } - } -} diff --git a/tests/auto/qtquick2/qdeclarativeanimations/data/mixedtype1.qml b/tests/auto/qtquick2/qdeclarativeanimations/data/mixedtype1.qml deleted file mode 100644 index 76129dd15e..0000000000 --- a/tests/auto/qtquick2/qdeclarativeanimations/data/mixedtype1.qml +++ /dev/null @@ -1,25 +0,0 @@ -import QtQuick 2.0 - -Rectangle { - id: wrapper - width: 240 - height: 320 - Rectangle { - id: myRect - objectName: "MyRect" - color: "red" - width: 50; height: 50 - x: 100; y: 100 - MouseArea { - 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 { properties: "x,border.width"; duration: 1000 } //x is real, border.width is int - } -} diff --git a/tests/auto/qtquick2/qdeclarativeanimations/data/mixedtype2.qml b/tests/auto/qtquick2/qdeclarativeanimations/data/mixedtype2.qml deleted file mode 100644 index 1a7166e3f3..0000000000 --- a/tests/auto/qtquick2/qdeclarativeanimations/data/mixedtype2.qml +++ /dev/null @@ -1,25 +0,0 @@ -import QtQuick 2.0 - -Rectangle { - id: wrapper - width: 240 - height: 320 - Rectangle { - id: myRect - objectName: "MyRect" - color: "red" - width: 50; height: 50 - x: 100; y: 100 - MouseArea { - 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 { properties: "x,color"; duration: 1000 } //x is real, color is color - } -} diff --git a/tests/auto/qtquick2/qdeclarativeanimations/data/nonTransitionBug.qml b/tests/auto/qtquick2/qdeclarativeanimations/data/nonTransitionBug.qml deleted file mode 100644 index 909c533e7b..0000000000 --- a/tests/auto/qtquick2/qdeclarativeanimations/data/nonTransitionBug.qml +++ /dev/null @@ -1,30 +0,0 @@ -import QtQuick 2.0 - -Rectangle { - id: root - width: 200 - height: 200 - - Rectangle { - id: mover - objectName: "mover" - } - - states: [ - State { - name: "free" - }, - State { - name: "left" - PropertyChanges { - restoreEntryValues: false - target: mover - x: 0 - } - } - ] - - transitions: Transition { - PropertyAnimation { properties: "x"; duration: 50 } - } -} diff --git a/tests/auto/qtquick2/qdeclarativeanimations/data/pathAnimation.qml b/tests/auto/qtquick2/qdeclarativeanimations/data/pathAnimation.qml deleted file mode 100644 index d2006a1c6a..0000000000 --- a/tests/auto/qtquick2/qdeclarativeanimations/data/pathAnimation.qml +++ /dev/null @@ -1,27 +0,0 @@ -import QtQuick 2.0 - -Rectangle { - width: 400 - height: 400 - - Rectangle { - id: redRect - color: "red" - width: 100; height: 100 - x: 50; y: 50 - } - - PathAnimation { - target: redRect - duration: 100; - path: Path { - startX: 50; startY: 50 - PathCubic { - x: 300; y: 300 - - control1X: 300; control1Y: 50 - control2X: 50; control2Y: 300 - } - } - } -} diff --git a/tests/auto/qtquick2/qdeclarativeanimations/data/pathAnimation2.qml b/tests/auto/qtquick2/qdeclarativeanimations/data/pathAnimation2.qml deleted file mode 100644 index 2f64dac2cc..0000000000 --- a/tests/auto/qtquick2/qdeclarativeanimations/data/pathAnimation2.qml +++ /dev/null @@ -1,26 +0,0 @@ -import QtQuick 2.0 - -Rectangle { - width: 400 - height: 400 - - Rectangle { - id: redRect - color: "red" - width: 100; height: 100 - x: 50; y: 50 - } - - PathAnimation { - target: redRect - duration: 100; - endRotation: 0 - orientationEntryDuration: 10 - orientationExitDuration: 10 - orientation: PathAnimation.RightFirst - path: Path { - startX: 50; startY: 50 - PathLine { x: 300; y: 300 } - } - } -} diff --git a/tests/auto/qtquick2/qdeclarativeanimations/data/pathAnimationNoStart.qml b/tests/auto/qtquick2/qdeclarativeanimations/data/pathAnimationNoStart.qml deleted file mode 100644 index be3501fabb..0000000000 --- a/tests/auto/qtquick2/qdeclarativeanimations/data/pathAnimationNoStart.qml +++ /dev/null @@ -1,27 +0,0 @@ -import QtQuick 2.0 - -Rectangle { - width: 400 - height: 400 - - Rectangle { - id: redRect - color: "red" - width: 100; height: 100 - x: 50; y: 50 - } - - PathAnimation { - target: redRect - duration: 100; - path: Path { - //no startX/Y defined (should automatically start from redRects pos) - PathCubic { - x: 300; y: 300 - - control1X: 300; control1Y: 50 - control2X: 50; control2Y: 300 - } - } - } -} diff --git a/tests/auto/qtquick2/qdeclarativeanimations/data/pathInterpolator.qml b/tests/auto/qtquick2/qdeclarativeanimations/data/pathInterpolator.qml deleted file mode 100644 index 0104412d7c..0000000000 --- a/tests/auto/qtquick2/qdeclarativeanimations/data/pathInterpolator.qml +++ /dev/null @@ -1,13 +0,0 @@ -import QtQuick 2.0 - -PathInterpolator { - path: Path { - startX: 50; startY: 50 - PathCubic { - x: 300; y: 300 - - control1X: 300; control1Y: 50 - control2X: 50; control2Y: 300 - } - } -} diff --git a/tests/auto/qtquick2/qdeclarativeanimations/data/pathInterpolatorBack.qml b/tests/auto/qtquick2/qdeclarativeanimations/data/pathInterpolatorBack.qml deleted file mode 100644 index 41366ef798..0000000000 --- a/tests/auto/qtquick2/qdeclarativeanimations/data/pathInterpolatorBack.qml +++ /dev/null @@ -1,11 +0,0 @@ -import QtQuick 2.0 - -PathInterpolator { - path: Path { - startX: 50; startY: 50 - PathLine { x: 50; y: 100 } - PathLine { x: 100; y: 100 } - PathLine { x: 100; y: 50 } - PathLine { x: 200; y: 50 } - } -} diff --git a/tests/auto/qtquick2/qdeclarativeanimations/data/pathInterpolatorBack2.qml b/tests/auto/qtquick2/qdeclarativeanimations/data/pathInterpolatorBack2.qml deleted file mode 100644 index eb3d4c3f86..0000000000 --- a/tests/auto/qtquick2/qdeclarativeanimations/data/pathInterpolatorBack2.qml +++ /dev/null @@ -1,10 +0,0 @@ -import QtQuick 2.0 - -PathInterpolator { - path: Path { - startX: 200; startY: 280 - PathCurve { x: 150; y: 280 } - PathCurve { x: 150; y: 80 } - PathCurve { x: 0; y: 80 } - } -} diff --git a/tests/auto/qtquick2/qdeclarativeanimations/data/pathTransition.qml b/tests/auto/qtquick2/qdeclarativeanimations/data/pathTransition.qml deleted file mode 100644 index 55ffc33f95..0000000000 --- a/tests/auto/qtquick2/qdeclarativeanimations/data/pathTransition.qml +++ /dev/null @@ -1,41 +0,0 @@ -import QtQuick 2.0 - -Rectangle { - width: 800 - height: 800 - - Rectangle { - id: redRect; objectName: "redRect" - color: "red" - width: 50; height: 50 - x: 500; y: 50 - } - - states: State { - name: "moved" - PropertyChanges { - target: redRect - x: 100; y: 700 - } - } - - transitions: Transition { - to: "moved"; reversible: true - PathAnimation { - id: pathAnim - target: redRect - duration: 300 - path: Path { - PathCurve { x: 100; y: 100 } - PathCurve { x: 200; y: 350 } - PathCurve { x: 600; y: 500 } - PathCurve {} - } - } - } - - MouseArea { - anchors.fill: parent - onClicked: parent.state = parent.state == "moved" ? "" : "moved" - } -} diff --git a/tests/auto/qtquick2/qdeclarativeanimations/data/pauseBindingBug.qml b/tests/auto/qtquick2/qdeclarativeanimations/data/pauseBindingBug.qml deleted file mode 100644 index 359cda166f..0000000000 --- a/tests/auto/qtquick2/qdeclarativeanimations/data/pauseBindingBug.qml +++ /dev/null @@ -1,17 +0,0 @@ -import QtQuick 2.0 - -Rectangle { - id: rect - width: 200 - height: 200 - - property bool animating: false - property int value: 0 - - NumberAnimation on value { - objectName: "animation" - paused: !rect.animating - to: 100 - duration: 50 - } -} diff --git a/tests/auto/qtquick2/qdeclarativeanimations/data/pauseBug.qml b/tests/auto/qtquick2/qdeclarativeanimations/data/pauseBug.qml deleted file mode 100644 index fa2c4be4ba..0000000000 --- a/tests/auto/qtquick2/qdeclarativeanimations/data/pauseBug.qml +++ /dev/null @@ -1,7 +0,0 @@ -import QtQuick 2.0 - -SequentialAnimation { - id: animation - running: true - ScriptAction { script: animation.paused = true } -} diff --git a/tests/auto/qtquick2/qdeclarativeanimations/data/properties.qml b/tests/auto/qtquick2/qdeclarativeanimations/data/properties.qml deleted file mode 100644 index f0f730967c..0000000000 --- a/tests/auto/qtquick2/qdeclarativeanimations/data/properties.qml +++ /dev/null @@ -1,14 +0,0 @@ -import QtQuick 2.0 - -Rectangle { - width: 400 - height: 400 - Rectangle { - id: theRect - objectName: "TheRect" - color: "red" - width: 50; height: 50 - x: 100; y: 100 - NumberAnimation on x { to: 200 } - } -} diff --git a/tests/auto/qtquick2/qdeclarativeanimations/data/properties2.qml b/tests/auto/qtquick2/qdeclarativeanimations/data/properties2.qml deleted file mode 100644 index 6b7f026e0b..0000000000 --- a/tests/auto/qtquick2/qdeclarativeanimations/data/properties2.qml +++ /dev/null @@ -1,14 +0,0 @@ -import QtQuick 2.0 - -Rectangle { - width: 400 - height: 400 - Rectangle { - id: theRect - objectName: "TheRect" - color: "red" - width: 50; height: 50 - x: 100; y: 100 - NumberAnimation on x { targets: theRect; properties: "x"; to: 200; } - } -} diff --git a/tests/auto/qtquick2/qdeclarativeanimations/data/properties3.qml b/tests/auto/qtquick2/qdeclarativeanimations/data/properties3.qml deleted file mode 100644 index 5eb65496d4..0000000000 --- a/tests/auto/qtquick2/qdeclarativeanimations/data/properties3.qml +++ /dev/null @@ -1,14 +0,0 @@ -import QtQuick 2.0 - -Rectangle { - width: 400 - height: 400 - Rectangle { - id: theRect - objectName: "TheRect" - color: "red" - width: 50; height: 50 - x: 100; y: 100 - NumberAnimation on x { target: theRect; property: "x"; to: 300; } - } -} diff --git a/tests/auto/qtquick2/qdeclarativeanimations/data/properties4.qml b/tests/auto/qtquick2/qdeclarativeanimations/data/properties4.qml deleted file mode 100644 index dfe8ad17e7..0000000000 --- a/tests/auto/qtquick2/qdeclarativeanimations/data/properties4.qml +++ /dev/null @@ -1,14 +0,0 @@ -import QtQuick 2.0 - -Rectangle { - width: 400 - height: 400 - Rectangle { - id: theRect - objectName: "TheRect" - color: "red" - width: 50; height: 50 - x: 100; y: 100 - NumberAnimation on x { target: theRect; property: "y"; to: 200; } - } -} diff --git a/tests/auto/qtquick2/qdeclarativeanimations/data/properties5.qml b/tests/auto/qtquick2/qdeclarativeanimations/data/properties5.qml deleted file mode 100644 index 075fc9bc5a..0000000000 --- a/tests/auto/qtquick2/qdeclarativeanimations/data/properties5.qml +++ /dev/null @@ -1,14 +0,0 @@ -import QtQuick 2.0 - -Rectangle { - width: 400 - height: 400 - Rectangle { - id: theRect - objectName: "TheRect" - color: "red" - width: 50; height: 50 - x: 100; y: 100 - NumberAnimation on x { targets: theRect; properties: "y"; to: 200; } - } -} diff --git a/tests/auto/qtquick2/qdeclarativeanimations/data/propertiesTransition.qml b/tests/auto/qtquick2/qdeclarativeanimations/data/propertiesTransition.qml deleted file mode 100644 index 968c5f6285..0000000000 --- a/tests/auto/qtquick2/qdeclarativeanimations/data/propertiesTransition.qml +++ /dev/null @@ -1,29 +0,0 @@ -import QtQuick 2.0 - -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 { targets: theRect; properties: "x" } - } - - MouseArea { - anchors.fill: parent - onClicked: parent.state = "moved" - } -} diff --git a/tests/auto/qtquick2/qdeclarativeanimations/data/propertiesTransition2.qml b/tests/auto/qtquick2/qdeclarativeanimations/data/propertiesTransition2.qml deleted file mode 100644 index f06165604a..0000000000 --- a/tests/auto/qtquick2/qdeclarativeanimations/data/propertiesTransition2.qml +++ /dev/null @@ -1,29 +0,0 @@ -import QtQuick 2.0 - -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 } - } - - MouseArea { - anchors.fill: parent - onClicked: parent.state = "moved" - } -} diff --git a/tests/auto/qtquick2/qdeclarativeanimations/data/propertiesTransition3.qml b/tests/auto/qtquick2/qdeclarativeanimations/data/propertiesTransition3.qml deleted file mode 100644 index 7d3b3b9c6d..0000000000 --- a/tests/auto/qtquick2/qdeclarativeanimations/data/propertiesTransition3.qml +++ /dev/null @@ -1,29 +0,0 @@ -import QtQuick 2.0 - -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 { targets: theRect; properties: "y" } - } - - MouseArea { - anchors.fill: parent - onClicked: parent.state = "moved" - } -} diff --git a/tests/auto/qtquick2/qdeclarativeanimations/data/propertiesTransition4.qml b/tests/auto/qtquick2/qdeclarativeanimations/data/propertiesTransition4.qml deleted file mode 100644 index 1c31a79634..0000000000 --- a/tests/auto/qtquick2/qdeclarativeanimations/data/propertiesTransition4.qml +++ /dev/null @@ -1,29 +0,0 @@ -import QtQuick 2.0 - -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; properties: "x" } - } - - MouseArea { - anchors.fill: parent - onClicked: parent.state = "moved" - } -} diff --git a/tests/auto/qtquick2/qdeclarativeanimations/data/propertiesTransition5.qml b/tests/auto/qtquick2/qdeclarativeanimations/data/propertiesTransition5.qml deleted file mode 100644 index a2ff746900..0000000000 --- a/tests/auto/qtquick2/qdeclarativeanimations/data/propertiesTransition5.qml +++ /dev/null @@ -1,29 +0,0 @@ -import QtQuick 2.0 - -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 { targets: theRect; property: "x" } - } - - MouseArea { - anchors.fill: parent - onClicked: parent.state = "moved" - } -} diff --git a/tests/auto/qtquick2/qdeclarativeanimations/data/propertiesTransition6.qml b/tests/auto/qtquick2/qdeclarativeanimations/data/propertiesTransition6.qml deleted file mode 100644 index d3db01efb0..0000000000 --- a/tests/auto/qtquick2/qdeclarativeanimations/data/propertiesTransition6.qml +++ /dev/null @@ -1,29 +0,0 @@ -import QtQuick 2.0 - -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 { targets: theItem; properties: "x" } - } - - MouseArea { - anchors.fill: parent - onClicked: parent.state = "moved" - } -} diff --git a/tests/auto/qtquick2/qdeclarativeanimations/data/propertiesTransition7.qml b/tests/auto/qtquick2/qdeclarativeanimations/data/propertiesTransition7.qml deleted file mode 100644 index 98898de8ef..0000000000 --- a/tests/auto/qtquick2/qdeclarativeanimations/data/propertiesTransition7.qml +++ /dev/null @@ -1,29 +0,0 @@ -import QtQuick 2.0 - -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 { - SpringAnimation { targets: theRect; properties: "x"; velocity: 10000 } - } - - MouseArea { - anchors.fill: parent - onClicked: parent.state = "moved" - } -} diff --git a/tests/auto/qtquick2/qdeclarativeanimations/data/reanchor.qml b/tests/auto/qtquick2/qdeclarativeanimations/data/reanchor.qml deleted file mode 100644 index 241cc81a96..0000000000 --- a/tests/auto/qtquick2/qdeclarativeanimations/data/reanchor.qml +++ /dev/null @@ -1,46 +0,0 @@ -import QtQuick 2.0 - -Rectangle { - id: container - width: 200; height: 200 - Rectangle { - id: myRect - color: "green"; - anchors.left: parent.left - anchors.right: rightGuideline.left - anchors.top: topGuideline.top - anchors.bottom: container.bottom - } - Item { id: leftGuideline; x: 10 } - Item { id: rightGuideline; x: 150 } - Item { id: topGuideline; y: 10 } - Item { id: bottomGuideline; y: 150 } - Item { id: topGuideline2; y: 50 } - Item { id: bottomGuideline2; y: 175 } - - states: [ State { - name: "reanchored" - AnchorChanges { - target: myRect; - anchors.left: leftGuideline.left - anchors.right: container.right - anchors.top: container.top - anchors.bottom: bottomGuideline.bottom - } - }, State { - name: "reanchored2" - AnchorChanges { - target: myRect; - anchors.left: undefined - anchors.right: undefined - anchors.top: topGuideline2.top - anchors.bottom: bottomGuideline2.bottom - } - }] - - transitions: Transition { - AnchorAnimation { } - } - - state: "reanchored" -} diff --git a/tests/auto/qtquick2/qdeclarativeanimations/data/registrationBug.qml b/tests/auto/qtquick2/qdeclarativeanimations/data/registrationBug.qml deleted file mode 100644 index 633da4e17f..0000000000 --- a/tests/auto/qtquick2/qdeclarativeanimations/data/registrationBug.qml +++ /dev/null @@ -1,18 +0,0 @@ -import QtQuick 2.0 - -Rectangle { - id: rect - width: 200 - height: 200 - - property bool animating: true - property int value: 0 - - NumberAnimation { - target: rect - property: "value" - running: rect.animating - to: 100 - duration: 50 - } -} diff --git a/tests/auto/qtquick2/qdeclarativeanimations/data/reparent.qml b/tests/auto/qtquick2/qdeclarativeanimations/data/reparent.qml deleted file mode 100644 index 39f1e7a6d2..0000000000 --- a/tests/auto/qtquick2/qdeclarativeanimations/data/reparent.qml +++ /dev/null @@ -1,56 +0,0 @@ -import QtQuick 2.0 - -Rectangle { - width: 400; - height: 240; - color: "black"; - - Rectangle { - id: gr - objectName: "target" - color: "green" - width: 50; height: 50 - } - - Rectangle { - id: np - objectName: "newParent" - x: 150 - width: 150; height: 150 - color: "yellow" - clip: true - Rectangle { - color: "red" - x: 50; y: 50; height: 50; width: 50 - } - - } - - Rectangle { - id: vp - objectName: "viaParent" - x: 100; y: 100 - width: 50; height: 50 - color: "blue" - rotation: 45 - scale: 2 - } - - states: State { - name: "state1" - ParentChange { - target: gr - parent: np - x: 50; y: 50; width: 100; - } - } - - transitions: Transition { - reversible: true - to: "state1" - ParentAnimation { - target: gr; via: vp; - NumberAnimation { properties: "x,y,rotation,scale,width" } - } - } -} diff --git a/tests/auto/qtquick2/qdeclarativeanimations/data/rotation.qml b/tests/auto/qtquick2/qdeclarativeanimations/data/rotation.qml deleted file mode 100644 index 4dc42a1bd2..0000000000 --- a/tests/auto/qtquick2/qdeclarativeanimations/data/rotation.qml +++ /dev/null @@ -1,48 +0,0 @@ -import QtQuick 2.0 - -Rectangle { - width: 600; height: 200 - - Row { - spacing: 5 - Rectangle { - id: rr - objectName: "rr" - color: "red" - width: 100; height: 100 - } - Rectangle { - id: rr2 - objectName: "rr2" - color: "red" - width: 100; height: 100 - } - Rectangle { - id: rr3 - objectName: "rr3" - color: "red" - width: 100; height: 100 - } - Rectangle { - id: rr4 - objectName: "rr4" - color: "red" - width: 100; height: 100 - } - } - - states: State { - name: "state1" - PropertyChanges { target: rr; rotation: 370 } - PropertyChanges { target: rr2; rotation: 370 } - PropertyChanges { target: rr3; rotation: 370 } - PropertyChanges { target: rr4; rotation: 370 } - } - - transitions: Transition { - RotationAnimation { target: rr; direction: RotationAnimation.Numerical; duration: 1000 } - RotationAnimation { target: rr2; direction: RotationAnimation.Clockwise; duration: 1000 } - RotationAnimation { target: rr3; direction: RotationAnimation.Counterclockwise; duration: 1000 } - RotationAnimation { target: rr4; direction: RotationAnimation.Shortest; duration: 1000 } - } -} diff --git a/tests/auto/qtquick2/qdeclarativeanimations/data/runningTrueBug.qml b/tests/auto/qtquick2/qdeclarativeanimations/data/runningTrueBug.qml deleted file mode 100644 index bec6fab368..0000000000 --- a/tests/auto/qtquick2/qdeclarativeanimations/data/runningTrueBug.qml +++ /dev/null @@ -1,30 +0,0 @@ -import QtQuick 2.0 -Rectangle { - color: "skyblue" - width: 500 - height: 200 - Rectangle { - objectName: "cloud" - color: "white" - y: 50 - width: 100 - height: 100 - - SequentialAnimation on x { - loops: Animation.Infinite - running: true - NumberAnimation { - id: firstAnimation - from: 0 - to: 500 - duration: 5000 - } - NumberAnimation { - id: secondAnimation - from: -100 - to: 0 - duration: 1000 - } - } - } -} diff --git a/tests/auto/qtquick2/qdeclarativeanimations/data/transitionAssignmentBug.qml b/tests/auto/qtquick2/qdeclarativeanimations/data/transitionAssignmentBug.qml deleted file mode 100644 index 508693e0fc..0000000000 --- a/tests/auto/qtquick2/qdeclarativeanimations/data/transitionAssignmentBug.qml +++ /dev/null @@ -1,12 +0,0 @@ -import QtQuick 2.0 - -Rectangle { - width: 400 - height: 400 - - property bool nullObject - Component.onCompleted: nullObject = transitions.length > 0 && transitions[0] === null - - property list myTransitions: [Transition {}, Transition {}] - transitions: myTransitions -} diff --git a/tests/auto/qtquick2/qdeclarativeanimations/data/valuesource.qml b/tests/auto/qtquick2/qdeclarativeanimations/data/valuesource.qml deleted file mode 100644 index 7a636b4003..0000000000 --- a/tests/auto/qtquick2/qdeclarativeanimations/data/valuesource.qml +++ /dev/null @@ -1,14 +0,0 @@ -import QtQuick 2.0 - -Rectangle { - width: 400 - height: 400 - Rectangle { - id: rect - objectName: "MyRect" - color: "red" - width: 50; height: 50 - x: 100; y: 100 - NumberAnimation on x { id: anim; objectName: "MyAnim"; to: 200 } - } -} diff --git a/tests/auto/qtquick2/qdeclarativeanimations/data/valuesource2.qml b/tests/auto/qtquick2/qdeclarativeanimations/data/valuesource2.qml deleted file mode 100644 index 9788761ee8..0000000000 --- a/tests/auto/qtquick2/qdeclarativeanimations/data/valuesource2.qml +++ /dev/null @@ -1,14 +0,0 @@ -import QtQuick 2.0 - -Rectangle { - width: 400 - height: 400 - Rectangle { - id: rect - objectName: "MyRect" - color: "red" - width: 50; height: 50 - x: 100; y: 100 - NumberAnimation on x { id: anim; objectName: "MyAnim"; running: false; to: 200 } - } -} diff --git a/tests/auto/qtquick2/qdeclarativeanimations/qdeclarativeanimations.pro b/tests/auto/qtquick2/qdeclarativeanimations/qdeclarativeanimations.pro deleted file mode 100644 index e13dbb974e..0000000000 --- a/tests/auto/qtquick2/qdeclarativeanimations/qdeclarativeanimations.pro +++ /dev/null @@ -1,18 +0,0 @@ -CONFIG += testcase -TARGET = tst_qdeclarativeanimations -SOURCES += tst_qdeclarativeanimations.cpp - -include (../../shared/util.pri) - -macx:CONFIG -= app_bundle - -testDataFiles.files = data -testDataFiles.path = . -DEPLOYMENT += testDataFiles - -CONFIG += parallel_test - -QT += core-private gui-private v8-private declarative-private quick-private opengl-private testlib - -# QTBUG-23385 - color mixing tests failing on Ubuntu 11.10 x64 -linux-*:system(". /etc/lsb-release && [ $DISTRIB_CODENAME = oneiric ]"):DEFINES+=UBUNTU_ONEIRIC diff --git a/tests/auto/qtquick2/qdeclarativeanimations/tst_qdeclarativeanimations.cpp b/tests/auto/qtquick2/qdeclarativeanimations/tst_qdeclarativeanimations.cpp deleted file mode 100644 index c7a0717dd3..0000000000 --- a/tests/auto/qtquick2/qdeclarativeanimations/tst_qdeclarativeanimations.cpp +++ /dev/null @@ -1,1319 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -#include "../../shared/util.h" - -class tst_qdeclarativeanimations : public QDeclarativeDataTest -{ - Q_OBJECT -public: - tst_qdeclarativeanimations() {} - -private slots: - void initTestCase() - { - QDeclarativeEngine engine; // ensure types are registered - QDeclarativeDataTest::initTestCase(); - } - - void simpleProperty(); - void simpleNumber(); - void simpleColor(); - void simpleRotation(); - void simplePath(); - void simpleAnchor(); - void reparent(); - void pathInterpolator(); - void pathInterpolatorBackwardJump(); - void pathWithNoStart(); - void alwaysRunToEnd(); - void complete(); - void resume(); - void dotProperty(); - void badTypes(); - void badProperties(); - void mixedTypes(); - void properties(); - void propertiesTransition(); - void pathTransition(); - void disabledTransition(); - void invalidDuration(); - void attached(); - void propertyValueSourceDefaultStart(); - void dontStart(); - void easingProperties(); - void rotation(); - void runningTrueBug(); - void nonTransitionBug(); - void registrationBug(); - void doubleRegistrationBug(); - void alwaysRunToEndRestartBug(); - void transitionAssignmentBug(); - void pauseBindingBug(); - void pauseBug(); - void loopingBug(); -}; - -#define QTIMED_COMPARE(lhs, rhs) do { \ - for (int ii = 0; ii < 5; ++ii) { \ - if (lhs == rhs) \ - break; \ - QTest::qWait(50); \ - } \ - QCOMPARE(lhs, rhs); \ -} while (false) - -void tst_qdeclarativeanimations::simpleProperty() -{ - QQuickRectangle rect; - QDeclarativePropertyAnimation animation; - animation.setTargetObject(&rect); - animation.setProperty("x"); - animation.setTo(200); - QVERIFY(animation.target() == &rect); - QVERIFY(animation.property() == "x"); - QVERIFY(animation.to().toReal() == 200.0); - animation.start(); - QVERIFY(animation.isRunning()); - QTest::qWait(animation.duration()); - QTIMED_COMPARE(rect.x(), 200.0); - - rect.setPos(QPointF(0,0)); - animation.start(); - QVERIFY(animation.isRunning()); - animation.pause(); - QVERIFY(animation.isPaused()); - animation.setCurrentTime(125); - QVERIFY(animation.currentTime() == 125); - QCOMPARE(rect.x(),100.0); -} - -void tst_qdeclarativeanimations::simpleNumber() -{ - QQuickRectangle rect; - QDeclarativeNumberAnimation animation; - animation.setTargetObject(&rect); - animation.setProperty("x"); - animation.setTo(200); - QVERIFY(animation.target() == &rect); - QVERIFY(animation.property() == "x"); - QVERIFY(animation.to() == 200); - animation.start(); - QVERIFY(animation.isRunning()); - QTest::qWait(animation.duration()); - QTIMED_COMPARE(rect.x(), qreal(200)); - - rect.setX(0); - animation.start(); - animation.pause(); - QVERIFY(animation.isRunning()); - QVERIFY(animation.isPaused()); - animation.setCurrentTime(125); - QVERIFY(animation.currentTime() == 125); - QCOMPARE(rect.x(), qreal(100)); -} - -void tst_qdeclarativeanimations::simpleColor() -{ - QQuickRectangle rect; - QDeclarativeColorAnimation animation; - animation.setTargetObject(&rect); - animation.setProperty("color"); - animation.setTo(QColor("red")); - QVERIFY(animation.target() == &rect); - QVERIFY(animation.property() == "color"); - QVERIFY(animation.to() == QColor("red")); - animation.start(); - QVERIFY(animation.isRunning()); - QTest::qWait(animation.duration()); - QTIMED_COMPARE(rect.color(), QColor("red")); - - rect.setColor(QColor("blue")); - animation.start(); - animation.pause(); - QVERIFY(animation.isRunning()); - QVERIFY(animation.isPaused()); - animation.setCurrentTime(125); - QVERIFY(animation.currentTime() == 125); -#if defined(UBUNTU_ONEIRIC) && defined(__x86_64__) - QEXPECT_FAIL("", "Fails on this platform - QTBUG-23385", Abort); -#endif - QCOMPARE(rect.color(), QColor::fromRgbF(0.498039, 0, 0.498039, 1)); - - rect.setColor(QColor("green")); - animation.setFrom(QColor("blue")); - QVERIFY(animation.from() == QColor("blue")); - animation.restart(); - QCOMPARE(rect.color(), QColor("blue")); - QVERIFY(animation.isRunning()); - animation.setCurrentTime(125); - QCOMPARE(rect.color(), QColor::fromRgbF(0.498039, 0, 0.498039, 1)); -} - -void tst_qdeclarativeanimations::simpleRotation() -{ - QQuickRectangle rect; - QDeclarativeRotationAnimation animation; - animation.setTargetObject(&rect); - animation.setProperty("rotation"); - animation.setTo(270); - QVERIFY(animation.target() == &rect); - QVERIFY(animation.property() == "rotation"); - QVERIFY(animation.to() == 270); - QVERIFY(animation.direction() == QDeclarativeRotationAnimation::Numerical); - animation.start(); - QVERIFY(animation.isRunning()); - QTest::qWait(animation.duration()); - QTIMED_COMPARE(rect.rotation(), qreal(270)); - - rect.setRotation(0); - animation.start(); - animation.pause(); - QVERIFY(animation.isRunning()); - QVERIFY(animation.isPaused()); - animation.setCurrentTime(125); - QVERIFY(animation.currentTime() == 125); - QCOMPARE(rect.rotation(), qreal(135)); -} - -void tst_qdeclarativeanimations::simplePath() -{ - { - QDeclarativeEngine engine; - QDeclarativeComponent c(&engine, testFileUrl("pathAnimation.qml")); - QQuickRectangle *rect = qobject_cast(c.create()); - QVERIFY(rect); - - QQuickRectangle *redRect = rect->findChild(); - QVERIFY(redRect); - QQuickPathAnimation *pathAnim = rect->findChild(); - QVERIFY(pathAnim); - - QCOMPARE(pathAnim->duration(), 100); - QCOMPARE(pathAnim->target(), redRect); - - pathAnim->start(); - pathAnim->pause(); - - pathAnim->setCurrentTime(30); - QCOMPARE(redRect->x(), qreal(167)); - QCOMPARE(redRect->y(), qreal(104)); - - pathAnim->setCurrentTime(100); - QCOMPARE(redRect->x(), qreal(300)); - QCOMPARE(redRect->y(), qreal(300)); - - //verify animation runs to end - pathAnim->start(); - QCOMPARE(redRect->x(), qreal(50)); - QCOMPARE(redRect->y(), qreal(50)); - QTRY_COMPARE(redRect->x(), qreal(300)); - QCOMPARE(redRect->y(), qreal(300)); - - pathAnim->setOrientation(QQuickPathAnimation::RightFirst); - QCOMPARE(pathAnim->orientation(), QQuickPathAnimation::RightFirst); - pathAnim->start(); - QTRY_VERIFY(redRect->rotation() != 0); - pathAnim->stop(); - - delete rect; - } - - { - QDeclarativeEngine engine; - QDeclarativeComponent c(&engine, testFileUrl("pathAnimation2.qml")); - QQuickRectangle *rect = qobject_cast(c.create()); - QVERIFY(rect); - - QQuickRectangle *redRect = rect->findChild(); - QVERIFY(redRect); - QQuickPathAnimation *pathAnim = rect->findChild(); - QVERIFY(pathAnim); - - QCOMPARE(pathAnim->orientation(), QQuickPathAnimation::RightFirst); - QCOMPARE(pathAnim->endRotation(), qreal(0)); - QCOMPARE(pathAnim->orientationEntryDuration(), 10); - QCOMPARE(pathAnim->orientationExitDuration(), 10); - - pathAnim->start(); - pathAnim->pause(); - QCOMPARE(redRect->x(), qreal(50)); - QCOMPARE(redRect->y(), qreal(50)); - QCOMPARE(redRect->rotation(), qreal(-360)); - - pathAnim->setCurrentTime(50); - QCOMPARE(redRect->x(), qreal(175)); - QCOMPARE(redRect->y(), qreal(175)); - QCOMPARE(redRect->rotation(), qreal(-315)); - - pathAnim->setCurrentTime(100); - QCOMPARE(redRect->x(), qreal(300)); - QCOMPARE(redRect->y(), qreal(300)); - QCOMPARE(redRect->rotation(), qreal(0)); - - delete rect; - } -} - -void tst_qdeclarativeanimations::simpleAnchor() -{ - QDeclarativeEngine engine; - QDeclarativeComponent c(&engine, testFileUrl("reanchor.qml")); - QQuickRectangle *rect = qobject_cast(c.create()); - QVERIFY(rect); - - QQuickRectangle *greenRect = rect->findChild(); - QVERIFY(greenRect); - - QCOMPARE(rect->state(), QLatin1String("reanchored")); - QCOMPARE(greenRect->x(), qreal(10)); - QCOMPARE(greenRect->y(), qreal(0)); - QCOMPARE(greenRect->width(), qreal(190)); - QCOMPARE(greenRect->height(), qreal(150)); - - rect->setState(""); - - //verify animation in progress - QTRY_VERIFY(greenRect->x() < 10 && greenRect->x() > 0); - QVERIFY(greenRect->y() > 0 && greenRect->y() < 10); - QVERIFY(greenRect->width() < 190 && greenRect->width() > 150); - QVERIFY(greenRect->height() > 150 && greenRect->height() < 190); - - //verify end state ("") - QTRY_COMPARE(greenRect->x(), qreal(0)); - QCOMPARE(greenRect->y(), qreal(10)); - QCOMPARE(greenRect->width(), qreal(150)); - QCOMPARE(greenRect->height(), qreal(190)); - - rect->setState("reanchored2"); - - //verify animation in progress - QTRY_VERIFY(greenRect->y() > 10 && greenRect->y() < 50); - QVERIFY(greenRect->height() > 125 && greenRect->height() < 190); - //NOTE: setting left/right anchors to undefined removes the anchors, but does not resize. - QCOMPARE(greenRect->x(), qreal(0)); - QCOMPARE(greenRect->width(), qreal(150)); - - //verify end state ("reanchored2") - QTRY_COMPARE(greenRect->y(), qreal(50)); - QCOMPARE(greenRect->height(), qreal(125)); - QCOMPARE(greenRect->x(), qreal(0)); - QCOMPARE(greenRect->width(), qreal(150)); - - rect->setState("reanchored"); - - //verify animation in progress - QTRY_VERIFY(greenRect->x() < 10 && greenRect->x() > 0); - QVERIFY(greenRect->y() > 0 && greenRect->y() < 50); - QVERIFY(greenRect->width() < 190 && greenRect->width() > 150); - QVERIFY(greenRect->height() > 125 && greenRect->height() < 150); - - //verify end state ("reanchored") - QTRY_COMPARE(greenRect->x(), qreal(10)); - QCOMPARE(greenRect->y(), qreal(0)); - QCOMPARE(greenRect->width(), qreal(190)); - QCOMPARE(greenRect->height(), qreal(150)); - - rect->setState("reanchored2"); - - //verify animation in progress - QTRY_VERIFY(greenRect->x() < 10 && greenRect->x() > 0); - QVERIFY(greenRect->y() > 0 && greenRect->y() < 50); - QVERIFY(greenRect->width() < 190 && greenRect->width() > 150); - QVERIFY(greenRect->height() > 125 && greenRect->height() < 150); - - //verify end state ("reanchored2") - QTRY_COMPARE(greenRect->x(), qreal(0)); - QCOMPARE(greenRect->y(), qreal(50)); - QCOMPARE(greenRect->width(), qreal(150)); - QCOMPARE(greenRect->height(), qreal(125)); - - delete rect; -} - -void tst_qdeclarativeanimations::reparent() -{ - QDeclarativeEngine engine; - QDeclarativeComponent c(&engine, testFileUrl("reparent.qml")); - QQuickRectangle *rect = qobject_cast(c.create()); - QVERIFY(rect); - - QQuickRectangle *target = rect->findChild("target"); - QVERIFY(target); - - QCOMPARE(target->parentItem(), rect); - QCOMPARE(target->x(), qreal(0)); - QCOMPARE(target->y(), qreal(0)); - QCOMPARE(target->width(), qreal(50)); - QCOMPARE(target->height(), qreal(50)); - QCOMPARE(target->rotation(), qreal(0)); - QCOMPARE(target->scale(), qreal(1)); - - rect->setState("state1"); - - QQuickRectangle *viaParent = rect->findChild("viaParent"); - QVERIFY(viaParent); - - QQuickRectangle *newParent = rect->findChild("newParent"); - QVERIFY(newParent); - - QTest::qWait(100); - - //animation in progress - QTRY_COMPARE(target->parentItem(), viaParent); - QVERIFY(target->x() > -100 && target->x() < 50); - QVERIFY(target->y() > -100 && target->y() < 50); - QVERIFY(target->width() > 50 && target->width() < 100); - QCOMPARE(target->height(), qreal(50)); - QCOMPARE(target->rotation(), qreal(-45)); - QCOMPARE(target->scale(), qreal(.5)); - - //end state - QTRY_COMPARE(target->parentItem(), newParent); - QCOMPARE(target->x(), qreal(50)); - QCOMPARE(target->y(), qreal(50)); - QCOMPARE(target->width(), qreal(100)); - QCOMPARE(target->height(), qreal(50)); - QCOMPARE(target->rotation(), qreal(0)); - QCOMPARE(target->scale(), qreal(1)); - - delete rect; -} - -void tst_qdeclarativeanimations::pathInterpolator() -{ - QDeclarativeEngine engine; - QDeclarativeComponent c(&engine, testFileUrl("pathInterpolator.qml")); - QDeclarativePathInterpolator *interpolator = qobject_cast(c.create()); - QVERIFY(interpolator); - - QCOMPARE(interpolator->progress(), qreal(0)); - QCOMPARE(interpolator->x(), qreal(50)); - QCOMPARE(interpolator->y(), qreal(50)); - QCOMPARE(interpolator->angle(), qreal(0)); - - interpolator->setProgress(.5); - QCOMPARE(interpolator->progress(), qreal(.5)); - QCOMPARE(interpolator->x(), qreal(175)); - QCOMPARE(interpolator->y(), qreal(175)); - QCOMPARE(interpolator->angle(), qreal(90)); - - interpolator->setProgress(1); - QCOMPARE(interpolator->progress(), qreal(1)); - QCOMPARE(interpolator->x(), qreal(300)); - QCOMPARE(interpolator->y(), qreal(300)); - QCOMPARE(interpolator->angle(), qreal(0)); -} - -void tst_qdeclarativeanimations::pathInterpolatorBackwardJump() -{ - { - QDeclarativeEngine engine; - QDeclarativeComponent c(&engine, testFileUrl("pathInterpolatorBack.qml")); - QDeclarativePathInterpolator *interpolator = qobject_cast(c.create()); - QVERIFY(interpolator); - - QCOMPARE(interpolator->progress(), qreal(0)); - QCOMPARE(interpolator->x(), qreal(50)); - QCOMPARE(interpolator->y(), qreal(50)); - QCOMPARE(interpolator->angle(), qreal(90)); - - interpolator->setProgress(.5); - QCOMPARE(interpolator->progress(), qreal(.5)); - QCOMPARE(interpolator->x(), qreal(100)); - QCOMPARE(interpolator->y(), qreal(75)); - QCOMPARE(interpolator->angle(), qreal(270)); - - interpolator->setProgress(1); - QCOMPARE(interpolator->progress(), qreal(1)); - QCOMPARE(interpolator->x(), qreal(200)); - QCOMPARE(interpolator->y(), qreal(50)); - QCOMPARE(interpolator->angle(), qreal(0)); - - //make sure we don't get caught in infinite loop here - interpolator->setProgress(0); - QCOMPARE(interpolator->progress(), qreal(0)); - QCOMPARE(interpolator->x(), qreal(50)); - QCOMPARE(interpolator->y(), qreal(50)); - QCOMPARE(interpolator->angle(), qreal(90)); - } - - { - QDeclarativeEngine engine; - QDeclarativeComponent c(&engine, testFileUrl("pathInterpolatorBack2.qml")); - QDeclarativePathInterpolator *interpolator = qobject_cast(c.create()); - QVERIFY(interpolator); - - QCOMPARE(interpolator->progress(), qreal(0)); - QCOMPARE(interpolator->x(), qreal(200)); - QCOMPARE(interpolator->y(), qreal(280)); - QCOMPARE(interpolator->angle(), qreal(180)); - - interpolator->setProgress(1); - QCOMPARE(interpolator->progress(), qreal(1)); - QCOMPARE(interpolator->x(), qreal(0)); - QCOMPARE(interpolator->y(), qreal(80)); - QCOMPARE(interpolator->angle(), qreal(180)); - - //make sure we don't get caught in infinite loop here - interpolator->setProgress(0); - QCOMPARE(interpolator->progress(), qreal(0)); - QCOMPARE(interpolator->x(), qreal(200)); - QCOMPARE(interpolator->y(), qreal(280)); - QCOMPARE(interpolator->angle(), qreal(180)); - } -} - -void tst_qdeclarativeanimations::pathWithNoStart() -{ - QDeclarativeEngine engine; - QDeclarativeComponent c(&engine, testFileUrl("pathAnimationNoStart.qml")); - QQuickRectangle *rect = qobject_cast(c.create()); - QVERIFY(rect); - - QQuickRectangle *redRect = rect->findChild(); - QVERIFY(redRect); - QQuickPathAnimation *pathAnim = rect->findChild(); - QVERIFY(pathAnim); - - pathAnim->start(); - pathAnim->pause(); - QCOMPARE(redRect->x(), qreal(50)); - QCOMPARE(redRect->y(), qreal(50)); - - pathAnim->setCurrentTime(50); - QCOMPARE(redRect->x(), qreal(175)); - QCOMPARE(redRect->y(), qreal(175)); - - pathAnim->setCurrentTime(100); - QCOMPARE(redRect->x(), qreal(300)); - QCOMPARE(redRect->y(), qreal(300)); - - redRect->setX(100); - redRect->setY(100); - pathAnim->start(); - QCOMPARE(redRect->x(), qreal(100)); - QCOMPARE(redRect->y(), qreal(100)); - QTRY_COMPARE(redRect->x(), qreal(300)); - QCOMPARE(redRect->y(), qreal(300)); -} - -void tst_qdeclarativeanimations::alwaysRunToEnd() -{ - QQuickRectangle rect; - QDeclarativePropertyAnimation animation; - animation.setTargetObject(&rect); - animation.setProperty("x"); - animation.setTo(200); - animation.setDuration(1000); - animation.setLoops(-1); - animation.setAlwaysRunToEnd(true); - QVERIFY(animation.loops() == -1); - QVERIFY(animation.alwaysRunToEnd() == true); - animation.start(); - QTest::qWait(1500); - animation.stop(); - QVERIFY(rect.x() != qreal(200)); - QTest::qWait(500); - QTIMED_COMPARE(rect.x(), qreal(200)); -} - -void tst_qdeclarativeanimations::complete() -{ - QQuickRectangle rect; - QDeclarativePropertyAnimation animation; - animation.setTargetObject(&rect); - animation.setProperty("x"); - animation.setFrom(1); - animation.setTo(200); - animation.setDuration(500); - QVERIFY(animation.from() == 1); - animation.start(); - QTest::qWait(50); - animation.stop(); - QVERIFY(rect.x() != qreal(200)); - animation.start(); - QTest::qWait(50); - QVERIFY(animation.isRunning()); - animation.complete(); - QCOMPARE(rect.x(), qreal(200)); -} - -void tst_qdeclarativeanimations::resume() -{ - QQuickRectangle rect; - QDeclarativePropertyAnimation animation; - animation.setTargetObject(&rect); - animation.setProperty("x"); - animation.setFrom(10); - animation.setTo(200); - animation.setDuration(1000); - QVERIFY(animation.from() == 10); - - animation.start(); - QTest::qWait(400); - animation.pause(); - qreal x = rect.x(); - QVERIFY(x != qreal(200) && x != qreal(10)); - QVERIFY(animation.isRunning()); - QVERIFY(animation.isPaused()); - - animation.resume(); - QVERIFY(animation.isRunning()); - QVERIFY(!animation.isPaused()); - QTest::qWait(400); - animation.stop(); - QVERIFY(rect.x() > x); -} - -void tst_qdeclarativeanimations::dotProperty() -{ - QQuickRectangle rect; - QDeclarativeNumberAnimation animation; - animation.setTargetObject(&rect); - animation.setProperty("border.width"); - animation.setTo(10); - animation.start(); - QTest::qWait(animation.duration()+50); - QTIMED_COMPARE(rect.border()->width(), 10.0); - - rect.border()->setWidth(0); - animation.start(); - animation.pause(); - animation.setCurrentTime(125); - QVERIFY(animation.currentTime() == 125); - QCOMPARE(rect.border()->width(), 5.0); -} - -void tst_qdeclarativeanimations::badTypes() -{ - //don't crash - { - QQuickView *view = new QQuickView; - view->setSource(testFileUrl("badtype1.qml")); - - qApp->processEvents(); - - delete view; - } - - //make sure we get a compiler error - { - QDeclarativeEngine engine; - QDeclarativeComponent c(&engine, testFileUrl("badtype2.qml")); - QTest::ignoreMessage(QtWarningMsg, "QDeclarativeComponent: Component is not ready"); - c.create(); - - QVERIFY(c.errors().count() == 1); - QCOMPARE(c.errors().at(0).description(), QLatin1String("Invalid property assignment: number expected")); - } - - //make sure we get a compiler error - { - QDeclarativeEngine engine; - QDeclarativeComponent c(&engine, testFileUrl("badtype3.qml")); - QTest::ignoreMessage(QtWarningMsg, "QDeclarativeComponent: Component is not ready"); - c.create(); - - QVERIFY(c.errors().count() == 1); - QCOMPARE(c.errors().at(0).description(), QLatin1String("Invalid property assignment: color expected")); - } - - //don't crash - { - QDeclarativeEngine engine; - QDeclarativeComponent c(&engine, testFileUrl("badtype4.qml")); - QQuickRectangle *rect = qobject_cast(c.create()); - QVERIFY(rect); - - QQuickItemPrivate::get(rect)->setState("state1"); - QTest::qWait(1000 + 50); - QQuickRectangle *myRect = rect->findChild("MyRect"); - QVERIFY(myRect); - QCOMPARE(myRect->x(),qreal(200)); - } -} - -void tst_qdeclarativeanimations::badProperties() -{ - //make sure we get a runtime error - { - QDeclarativeEngine engine; - - QDeclarativeComponent c1(&engine, testFileUrl("badproperty1.qml")); - QByteArray message = testFileUrl("badproperty1.qml").toString().toUtf8() + ":18:9: QML ColorAnimation: Cannot animate non-existent property \"border.colr\""; - QTest::ignoreMessage(QtWarningMsg, message); - QQuickRectangle *rect = qobject_cast(c1.create()); - QVERIFY(rect); - - QDeclarativeComponent c2(&engine, testFileUrl("badproperty2.qml")); - message = testFileUrl("badproperty2.qml").toString().toUtf8() + ":18:9: QML ColorAnimation: Cannot animate read-only property \"border\""; - QTest::ignoreMessage(QtWarningMsg, message); - rect = qobject_cast(c2.create()); - QVERIFY(rect); - - //### should we warn here are well? - //rect->setState("state1"); - } -} - -//test animating mixed types with property animation in a transition -//for example, int + real; color + real; etc -void tst_qdeclarativeanimations::mixedTypes() -{ - //assumes border.width stays a real -- not real robust - { - QDeclarativeEngine engine; - QDeclarativeComponent c(&engine, testFileUrl("mixedtype1.qml")); - QQuickRectangle *rect = qobject_cast(c.create()); - QVERIFY(rect); - - QQuickItemPrivate::get(rect)->setState("state1"); - QTest::qWait(500); - QQuickRectangle *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); - } - - { - QDeclarativeEngine engine; - QDeclarativeComponent c(&engine, testFileUrl("mixedtype2.qml")); - QQuickRectangle *rect = qobject_cast(c.create()); - QVERIFY(rect); - - QQuickItemPrivate::get(rect)->setState("state1"); - QTest::qWait(500); - QQuickRectangle *myRect = rect->findChild("MyRect"); - QVERIFY(myRect); - - //rather inexact -- is there a better way? - QVERIFY(myRect->x() > 100 && myRect->x() < 200); -#if defined(UBUNTU_ONEIRIC) && defined(__x86_64__) - QEXPECT_FAIL("", "Fails on this platform - QTBUG-23385", Continue); -#endif - QVERIFY(myRect->color() != QColor("red") && myRect->color() != QColor("blue")); - } -} - -void tst_qdeclarativeanimations::properties() -{ - const int waitDuration = 300; - { - QDeclarativeEngine engine; - QDeclarativeComponent c(&engine, testFileUrl("properties.qml")); - QQuickRectangle *rect = qobject_cast(c.create()); - QVERIFY(rect); - - QQuickRectangle *myRect = rect->findChild("TheRect"); - QVERIFY(myRect); - QTest::qWait(waitDuration); - QTIMED_COMPARE(myRect->x(),qreal(200)); - } - - { - QDeclarativeEngine engine; - QDeclarativeComponent c(&engine, testFileUrl("properties2.qml")); - QQuickRectangle *rect = qobject_cast(c.create()); - QVERIFY(rect); - - QQuickRectangle *myRect = rect->findChild("TheRect"); - QVERIFY(myRect); - QTest::qWait(waitDuration); - QTIMED_COMPARE(myRect->x(),qreal(200)); - } - - { - QDeclarativeEngine engine; - QDeclarativeComponent c(&engine, testFileUrl("properties3.qml")); - QQuickRectangle *rect = qobject_cast(c.create()); - QVERIFY(rect); - - QQuickRectangle *myRect = rect->findChild("TheRect"); - QVERIFY(myRect); - QTest::qWait(waitDuration); - QTIMED_COMPARE(myRect->x(),qreal(300)); - } - - { - QDeclarativeEngine engine; - QDeclarativeComponent c(&engine, testFileUrl("properties4.qml")); - QQuickRectangle *rect = qobject_cast(c.create()); - QVERIFY(rect); - - QQuickRectangle *myRect = rect->findChild("TheRect"); - QVERIFY(myRect); - QTest::qWait(waitDuration); - QTIMED_COMPARE(myRect->y(),qreal(200)); - QTIMED_COMPARE(myRect->x(),qreal(100)); - } - - { - QDeclarativeEngine engine; - QDeclarativeComponent c(&engine, testFileUrl("properties5.qml")); - QQuickRectangle *rect = qobject_cast(c.create()); - QVERIFY(rect); - - QQuickRectangle *myRect = rect->findChild("TheRect"); - QVERIFY(myRect); - QTest::qWait(waitDuration); - QTIMED_COMPARE(myRect->x(),qreal(100)); - QTIMED_COMPARE(myRect->y(),qreal(200)); - } -} - -void tst_qdeclarativeanimations::propertiesTransition() -{ - const int waitDuration = 300; - { - QDeclarativeEngine engine; - QDeclarativeComponent c(&engine, testFileUrl("propertiesTransition.qml")); - QQuickRectangle *rect = qobject_cast(c.create()); - QVERIFY(rect); - - QQuickItemPrivate::get(rect)->setState("moved"); - QQuickRectangle *myRect = rect->findChild("TheRect"); - QVERIFY(myRect); - QTest::qWait(waitDuration); - QTIMED_COMPARE(myRect->x(),qreal(200)); - } - - { - QDeclarativeEngine engine; - QDeclarativeComponent c(&engine, testFileUrl("propertiesTransition2.qml")); - QQuickRectangle *rect = qobject_cast(c.create()); - QVERIFY(rect); - - QQuickRectangle *myRect = rect->findChild("TheRect"); - QVERIFY(myRect); - QQuickItemPrivate::get(rect)->setState("moved"); - QCOMPARE(myRect->x(),qreal(200)); - QCOMPARE(myRect->y(),qreal(100)); - QTest::qWait(waitDuration); - QTIMED_COMPARE(myRect->y(),qreal(200)); - } - - { - QDeclarativeEngine engine; - QDeclarativeComponent c(&engine, testFileUrl("propertiesTransition3.qml")); - QQuickRectangle *rect = qobject_cast(c.create()); - QVERIFY(rect); - - QQuickRectangle *myRect = rect->findChild("TheRect"); - QVERIFY(myRect); - QQuickItemPrivate::get(rect)->setState("moved"); - QCOMPARE(myRect->x(),qreal(200)); - QCOMPARE(myRect->y(),qreal(100)); - } - - { - QDeclarativeEngine engine; - QDeclarativeComponent c(&engine, testFileUrl("propertiesTransition4.qml")); - QQuickRectangle *rect = qobject_cast(c.create()); - QVERIFY(rect); - - QQuickRectangle *myRect = rect->findChild("TheRect"); - QVERIFY(myRect); - QQuickItemPrivate::get(rect)->setState("moved"); - QCOMPARE(myRect->x(),qreal(100)); - QTest::qWait(waitDuration); - QTIMED_COMPARE(myRect->x(),qreal(200)); - } - - { - QDeclarativeEngine engine; - QDeclarativeComponent c(&engine, testFileUrl("propertiesTransition5.qml")); - QQuickRectangle *rect = qobject_cast(c.create()); - QVERIFY(rect); - - QQuickRectangle *myRect = rect->findChild("TheRect"); - QVERIFY(myRect); - QQuickItemPrivate::get(rect)->setState("moved"); - QCOMPARE(myRect->x(),qreal(100)); - QTest::qWait(waitDuration); - QTIMED_COMPARE(myRect->x(),qreal(200)); - } - - /*{ - QDeclarativeEngine engine; - QDeclarativeComponent c(&engine, testFileUrl("propertiesTransition6.qml")); - QQuickRectangle *rect = qobject_cast(c.create()); - QVERIFY(rect); - - QQuickRectangle *myRect = rect->findChild("TheRect"); - QVERIFY(myRect); - QQuickItemPrivate::get(rect)->setState("moved"); - QCOMPARE(myRect->x(),qreal(100)); - QTest::qWait(waitDuration); - QTIMED_COMPARE(myRect->x(),qreal(100)); - }*/ - - { - QDeclarativeEngine engine; - QDeclarativeComponent c(&engine, testFileUrl("propertiesTransition7.qml")); - QQuickRectangle *rect = qobject_cast(c.create()); - QVERIFY(rect); - - QQuickItemPrivate::get(rect)->setState("moved"); - QQuickRectangle *myRect = rect->findChild("TheRect"); - QVERIFY(myRect); - QTest::qWait(waitDuration); - QTIMED_COMPARE(myRect->x(),qreal(200)); - } - -} - -void tst_qdeclarativeanimations::pathTransition() -{ - QDeclarativeEngine engine; - QDeclarativeComponent c(&engine, testFileUrl("pathTransition.qml")); - QQuickRectangle *rect = qobject_cast(c.create()); - QVERIFY(rect); - - QQuickRectangle *myRect = rect->findChild("redRect"); - QVERIFY(myRect); - - QQuickItemPrivate::get(rect)->setState("moved"); - QTRY_VERIFY(myRect->x() < 500 && myRect->x() > 100 && myRect->y() > 50 && myRect->y() < 700 ); //animation started - QTRY_VERIFY(qFuzzyCompare(myRect->x(), qreal(100)) && qFuzzyCompare(myRect->y(), qreal(700))); - QTest::qWait(100); - - QQuickItemPrivate::get(rect)->setState(""); - QTRY_VERIFY(myRect->x() < 500 && myRect->x() > 100 && myRect->y() > 50 && myRect->y() < 700 ); //animation started - QTRY_VERIFY(qFuzzyCompare(myRect->x(), qreal(500)) && qFuzzyCompare(myRect->y(), qreal(50))); -} - -void tst_qdeclarativeanimations::disabledTransition() -{ - QDeclarativeEngine engine; - QDeclarativeComponent c(&engine, testFileUrl("disabledTransition.qml")); - QQuickRectangle *rect = qobject_cast(c.create()); - QVERIFY(rect); - - QQuickRectangle *myRect = rect->findChild("TheRect"); - QVERIFY(myRect); - - QDeclarativeTransition *trans = rect->findChild(); - QVERIFY(trans); - - QCOMPARE(trans->enabled(), false); - - QQuickItemPrivate::get(rect)->setState("moved"); - QCOMPARE(myRect->x(),qreal(200)); - - trans->setEnabled(true); - - QQuickItemPrivate::get(rect)->setState(""); - QCOMPARE(myRect->x(),qreal(200)); - QTest::qWait(300); - QTIMED_COMPARE(myRect->x(),qreal(100)); -} - -void tst_qdeclarativeanimations::invalidDuration() -{ - QDeclarativePropertyAnimation *animation = new QDeclarativePropertyAnimation; - QTest::ignoreMessage(QtWarningMsg, ": QML PropertyAnimation: Cannot set a duration of < 0"); - animation->setDuration(-1); - QCOMPARE(animation->duration(), 250); - - QDeclarativePauseAnimation *pauseAnimation = new QDeclarativePauseAnimation; - QTest::ignoreMessage(QtWarningMsg, ": QML PauseAnimation: Cannot set a duration of < 0"); - pauseAnimation->setDuration(-1); - QCOMPARE(pauseAnimation->duration(), 250); -} - -void tst_qdeclarativeanimations::attached() -{ - QDeclarativeEngine engine; - - QDeclarativeComponent c(&engine, testFileUrl("attached.qml")); - QTest::ignoreMessage(QtDebugMsg, "off"); - QTest::ignoreMessage(QtDebugMsg, "on"); - QQuickRectangle *rect = qobject_cast(c.create()); - QVERIFY(rect); -} - -void tst_qdeclarativeanimations::propertyValueSourceDefaultStart() -{ - { - QDeclarativeEngine engine; - - QDeclarativeComponent c(&engine, testFileUrl("valuesource.qml")); - - QQuickRectangle *rect = qobject_cast(c.create()); - QVERIFY(rect); - - QDeclarativeAbstractAnimation *myAnim = rect->findChild("MyAnim"); - QVERIFY(myAnim); - QVERIFY(myAnim->isRunning()); - } - - { - QDeclarativeEngine engine; - - QDeclarativeComponent c(&engine, testFileUrl("valuesource2.qml")); - - QQuickRectangle *rect = qobject_cast(c.create()); - QVERIFY(rect); - - QDeclarativeAbstractAnimation *myAnim = rect->findChild("MyAnim"); - QVERIFY(myAnim); - QVERIFY(myAnim->isRunning() == false); - } - - { - QDeclarativeEngine engine; - - QDeclarativeComponent c(&engine, testFileUrl("dontAutoStart.qml")); - - QQuickRectangle *rect = qobject_cast(c.create()); - QVERIFY(rect); - - QDeclarativeAbstractAnimation *myAnim = rect->findChild("MyAnim"); - QVERIFY(myAnim && !myAnim->qtAnimation()); - //QVERIFY(myAnim->qtAnimation()->state() == QAbstractAnimationJob::Stopped); - } -} - - -void tst_qdeclarativeanimations::dontStart() -{ - { - QDeclarativeEngine engine; - - QDeclarativeComponent c(&engine, testFileUrl("dontStart.qml")); - - QString warning = c.url().toString() + ":14:13: QML NumberAnimation: setRunning() cannot be used on non-root animation nodes."; - QTest::ignoreMessage(QtWarningMsg, qPrintable(warning)); - QQuickRectangle *rect = qobject_cast(c.create()); - QVERIFY(rect); - - QDeclarativeAbstractAnimation *myAnim = rect->findChild("MyAnim"); - QVERIFY(myAnim && !myAnim->qtAnimation()); - //QVERIFY(myAnim->qtAnimation()->state() == QAbstractAnimationJob::Stopped); - } - - { - QDeclarativeEngine engine; - - QDeclarativeComponent c(&engine, testFileUrl("dontStart2.qml")); - - QString warning = c.url().toString() + ":15:17: QML NumberAnimation: setRunning() cannot be used on non-root animation nodes."; - QTest::ignoreMessage(QtWarningMsg, qPrintable(warning)); - QQuickRectangle *rect = qobject_cast(c.create()); - QVERIFY(rect); - - QDeclarativeAbstractAnimation *myAnim = rect->findChild("MyAnim"); - QVERIFY(myAnim && !myAnim->qtAnimation()); - //QVERIFY(myAnim->qtAnimation()->state() == QAbstractAnimationJob::Stopped); - } -} - -void tst_qdeclarativeanimations::easingProperties() -{ - { - QDeclarativeEngine engine; - QString componentStr = "import QtQuick 2.0\nNumberAnimation { easing.type: \"InOutQuad\" }"; - QDeclarativeComponent animationComponent(&engine); - animationComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); - QDeclarativePropertyAnimation *animObject = qobject_cast(animationComponent.create()); - - QVERIFY(animObject != 0); - QCOMPARE(animObject->easing().type(), QEasingCurve::InOutQuad); - } - - { - QDeclarativeEngine engine; - QString componentStr = "import QtQuick 2.0\nPropertyAnimation { easing.type: \"OutBounce\"; easing.amplitude: 5.0 }"; - QDeclarativeComponent animationComponent(&engine); - animationComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); - QDeclarativePropertyAnimation *animObject = qobject_cast(animationComponent.create()); - - QVERIFY(animObject != 0); - QCOMPARE(animObject->easing().type(), QEasingCurve::OutBounce); - QCOMPARE(animObject->easing().amplitude(), 5.0); - } - - { - QDeclarativeEngine engine; - QString componentStr = "import QtQuick 2.0\nPropertyAnimation { easing.type: \"OutElastic\"; easing.amplitude: 5.0; easing.period: 3.0}"; - QDeclarativeComponent animationComponent(&engine); - animationComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); - QDeclarativePropertyAnimation *animObject = qobject_cast(animationComponent.create()); - - QVERIFY(animObject != 0); - QCOMPARE(animObject->easing().type(), QEasingCurve::OutElastic); - QCOMPARE(animObject->easing().amplitude(), 5.0); - QCOMPARE(animObject->easing().period(), 3.0); - } - - { - QDeclarativeEngine engine; - QString componentStr = "import QtQuick 2.0\nPropertyAnimation { easing.type: \"InOutBack\"; easing.overshoot: 2 }"; - QDeclarativeComponent animationComponent(&engine); - animationComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); - QDeclarativePropertyAnimation *animObject = qobject_cast(animationComponent.create()); - - QVERIFY(animObject != 0); - QCOMPARE(animObject->easing().type(), QEasingCurve::InOutBack); - QCOMPARE(animObject->easing().overshoot(), 2.0); - } - - { - QDeclarativeEngine engine; - QString componentStr = "import QtQuick 2.0\nPropertyAnimation { easing.type: \"Bezier\"; easing.bezierCurve: [0.5, 0.2, 0.13, 0.65, 1.0, 1.0] }"; - QDeclarativeComponent animationComponent(&engine); - animationComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); - QDeclarativePropertyAnimation *animObject = qobject_cast(animationComponent.create()); - - QVERIFY(animObject != 0); - QCOMPARE(animObject->easing().type(), QEasingCurve::BezierSpline); - QList points = animObject->easing().cubicBezierSpline(); - QCOMPARE(points.count(), 3); - QCOMPARE(points.at(0), QPointF(0.5, 0.2)); - QCOMPARE(points.at(1), QPointF(0.13, 0.65)); - QCOMPARE(points.at(2), QPointF(1.0, 1.0)); - } -} - -void tst_qdeclarativeanimations::rotation() -{ - QDeclarativeEngine engine; - QDeclarativeComponent c(&engine, testFileUrl("rotation.qml")); - QQuickRectangle *rect = qobject_cast(c.create()); - QVERIFY(rect); - - QQuickRectangle *rr = rect->findChild("rr"); - QQuickRectangle *rr2 = rect->findChild("rr2"); - QQuickRectangle *rr3 = rect->findChild("rr3"); - QQuickRectangle *rr4 = rect->findChild("rr4"); - - QQuickItemPrivate::get(rect)->setState("state1"); - QTest::qWait(800); - qreal r1 = rr->rotation(); - qreal r2 = rr2->rotation(); - qreal r3 = rr3->rotation(); - qreal r4 = rr4->rotation(); - - QVERIFY(r1 > qreal(0) && r1 < qreal(370)); - QVERIFY(r2 > qreal(0) && r2 < qreal(370)); - QVERIFY(r3 < qreal(0) && r3 > qreal(-350)); - QVERIFY(r4 > qreal(0) && r4 < qreal(10)); - QCOMPARE(r1,r2); - QVERIFY(r4 < r2); - - QTest::qWait(800); - QTIMED_COMPARE(rr->rotation() + rr2->rotation() + rr3->rotation() + rr4->rotation(), qreal(370*4)); -} - -void tst_qdeclarativeanimations::runningTrueBug() -{ - //ensure we start correctly when "running: true" is explicitly set - QDeclarativeEngine engine; - QDeclarativeComponent c(&engine, testFileUrl("runningTrueBug.qml")); - QQuickRectangle *rect = qobject_cast(c.create()); - QVERIFY(rect); - - QQuickRectangle *cloud = rect->findChild("cloud"); - QVERIFY(cloud); - QTest::qWait(1000); - QVERIFY(cloud->x() > qreal(0)); -} - -//QTBUG-12805 -void tst_qdeclarativeanimations::nonTransitionBug() -{ - //tests that the animation values from the previous transition are properly cleared - //in the case where an animation in the transition doesn't match anything (but previously did) - QDeclarativeEngine engine; - - QDeclarativeComponent c(&engine, testFileUrl("nonTransitionBug.qml")); - QQuickRectangle *rect = qobject_cast(c.create()); - QVERIFY(rect != 0); - QQuickItemPrivate *rectPrivate = QQuickItemPrivate::get(rect); - QQuickRectangle *mover = rect->findChild("mover"); - - mover->setX(100); - QCOMPARE(mover->x(), qreal(100)); - - rectPrivate->setState("left"); - QTRY_COMPARE(mover->x(), qreal(0)); - - mover->setX(100); - QCOMPARE(mover->x(), qreal(100)); - - //make sure we don't try to animate back to 0 - rectPrivate->setState("free"); - QTest::qWait(300); - QCOMPARE(mover->x(), qreal(100)); -} - -//QTBUG-14042 -void tst_qdeclarativeanimations::registrationBug() -{ - QDeclarativeEngine engine; - - QDeclarativeComponent c(&engine, testFileUrl("registrationBug.qml")); - QQuickRectangle *rect = qobject_cast(c.create()); - QVERIFY(rect != 0); - QTRY_COMPARE(rect->property("value"), QVariant(int(100))); -} - -void tst_qdeclarativeanimations::doubleRegistrationBug() -{ - QDeclarativeEngine engine; - - QDeclarativeComponent c(&engine, testFileUrl("doubleRegistrationBug.qml")); - QQuickRectangle *rect = qobject_cast(c.create()); - QVERIFY(rect != 0); - - QDeclarativeAbstractAnimation *anim = rect->findChild("animation"); - QVERIFY(anim != 0); - QTRY_COMPARE(anim->qtAnimation()->state(), QAbstractAnimationJob::Stopped); -} - -//QTBUG-16736 -void tst_qdeclarativeanimations::alwaysRunToEndRestartBug() -{ - QQuickRectangle rect; - QDeclarativePropertyAnimation animation; - animation.setTargetObject(&rect); - animation.setProperty("x"); - animation.setTo(200); - animation.setDuration(1000); - animation.setLoops(-1); - animation.setAlwaysRunToEnd(true); - QVERIFY(animation.loops() == -1); - QVERIFY(animation.alwaysRunToEnd() == true); - animation.start(); - animation.stop(); - animation.start(); - animation.stop(); - QTest::qWait(500); - QVERIFY(rect.x() != qreal(200)); - QTest::qWait(800); - QTIMED_COMPARE(rect.x(), qreal(200)); - QCOMPARE(static_cast(&animation)->qtAnimation()->state(), QAbstractAnimationJob::Stopped); -} - -//QTBUG-20227 -void tst_qdeclarativeanimations::transitionAssignmentBug() -{ - QDeclarativeEngine engine; - - QDeclarativeComponent c(&engine, testFileUrl("transitionAssignmentBug.qml")); - QQuickRectangle *rect = qobject_cast(c.create()); - QVERIFY(rect != 0); - - QCOMPARE(rect->property("nullObject").toBool(), false); -} - -//QTBUG-19080 -void tst_qdeclarativeanimations::pauseBindingBug() -{ - QDeclarativeEngine engine; - - QDeclarativeComponent c(&engine, testFileUrl("pauseBindingBug.qml")); - QQuickRectangle *rect = qobject_cast(c.create()); - QVERIFY(rect != 0); - QDeclarativeAbstractAnimation *anim = rect->findChild("animation"); - QVERIFY(anim->qtAnimation()->state() == QAbstractAnimationJob::Paused); - - delete rect; -} - -//QTBUG-13598 -void tst_qdeclarativeanimations::pauseBug() -{ - QDeclarativeEngine engine; - - QDeclarativeComponent c(&engine, testFileUrl("pauseBug.qml")); - QDeclarativeAbstractAnimation *anim = qobject_cast(c.create()); - QVERIFY(anim != 0); - QCOMPARE(anim->qtAnimation()->state(), QAbstractAnimationJob::Paused); - QCOMPARE(anim->isPaused(), true); - QCOMPARE(anim->isRunning(), true); - - delete anim; -} - -//QTBUG-23092 -void tst_qdeclarativeanimations::loopingBug() -{ - QDeclarativeEngine engine; - - QDeclarativeComponent c(&engine, testFileUrl("looping.qml")); - QObject *obj = c.create(); - - QDeclarativeAbstractAnimation *anim = obj->findChild(); - QVERIFY(anim != 0); - QCOMPARE(anim->qtAnimation()->totalDuration(), 300); - QCOMPARE(anim->isRunning(), true); - QTRY_COMPARE(static_cast(anim->qtAnimation())->firstChild()->currentLoop(), 2); - QTRY_COMPARE(anim->isRunning(), false); - - QQuickRectangle *rect = obj->findChild(); - QVERIFY(rect != 0); - QCOMPARE(rect->rotation(), qreal(90)); - - delete obj; -} - -QTEST_MAIN(tst_qdeclarativeanimations) - -#include "tst_qdeclarativeanimations.moc" diff --git a/tests/auto/qtquick2/qdeclarativeapplication/qdeclarativeapplication.pro b/tests/auto/qtquick2/qdeclarativeapplication/qdeclarativeapplication.pro deleted file mode 100644 index b86f431d31..0000000000 --- a/tests/auto/qtquick2/qdeclarativeapplication/qdeclarativeapplication.pro +++ /dev/null @@ -1,7 +0,0 @@ -CONFIG += testcase -TARGET = tst_qdeclarativeapplication -macx:CONFIG -= app_bundle - -SOURCES += tst_qdeclarativeapplication.cpp -QT += core-private gui-private declarative-private quick-private testlib - diff --git a/tests/auto/qtquick2/qdeclarativeapplication/tst_qdeclarativeapplication.cpp b/tests/auto/qtquick2/qdeclarativeapplication/tst_qdeclarativeapplication.cpp deleted file mode 100644 index 6b921a7356..0000000000 --- a/tests/auto/qtquick2/qdeclarativeapplication/tst_qdeclarativeapplication.cpp +++ /dev/null @@ -1,159 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include -#include -#include -#include -#include -#include - -class tst_qdeclarativeapplication : public QObject -{ - Q_OBJECT -public: - tst_qdeclarativeapplication(); - -private slots: - void active(); - void layoutDirection(); - void inputPanel(); - void inputMethod(); - -private: - QDeclarativeEngine engine; -}; - -tst_qdeclarativeapplication::tst_qdeclarativeapplication() -{ -} - -void tst_qdeclarativeapplication::active() -{ - QDeclarativeComponent component(&engine); - component.setData("import QtQuick 2.0; Item { property bool active: Qt.application.active }", QUrl::fromLocalFile("")); - QQuickItem *item = qobject_cast(component.create()); - QVERIFY(item); - QQuickView view; - item->setParentItem(view.rootObject()); - - // not active - QVERIFY(!item->property("active").toBool()); - QCOMPARE(item->property("active").toBool(), QGuiApplication::activeWindow() != 0); - - // active - view.show(); - view.requestActivateWindow(); - QTest::qWait(50); - QEXPECT_FAIL("", "QTBUG-21573", Abort); - QTRY_COMPARE(view.status(), QQuickView::Ready); - QCOMPARE(item->property("active").toBool(), QGuiApplication::activeWindow() != 0); - -#if 0 - // QGuiApplication has no equivalent of setActiveWindow(0). QTBUG-21573 - // Is this different to clearing the active state of the window or can it be removed? - // On Mac, setActiveWindow(0) on mac does not deactivate the current application, - // must switch to a different app or hide the current app to trigger this - // on mac, setActiveWindow(0) on mac does not deactivate the current application - // (you have to switch to a different app or hide the current app to trigger this) - - // not active again - QGuiApplication::setActiveWindow(0); - QVERIFY(!item->property("active").toBool()); - QCOMPARE(item->property("active").toBool(), QGuiApplication::activeWindow() != 0); -#endif - -} - -void tst_qdeclarativeapplication::layoutDirection() -{ - - QDeclarativeComponent component(&engine); - component.setData("import QtQuick 2.0; Item { property bool layoutDirection: Qt.application.layoutDirection }", QUrl::fromLocalFile("")); - QQuickItem *item = qobject_cast(component.create()); - QVERIFY(item); - QQuickView view; - item->setParentItem(view.rootObject()); - - // not mirrored - QCOMPARE(Qt::LayoutDirection(item->property("layoutDirection").toInt()), Qt::LeftToRight); - - // mirrored - QGuiApplication::setLayoutDirection(Qt::RightToLeft); - QEXPECT_FAIL("", "QTBUG-21573", Abort); - QCOMPARE(Qt::LayoutDirection(item->property("layoutDirection").toInt()), Qt::RightToLeft); - - // not mirrored again - QGuiApplication::setLayoutDirection(Qt::LeftToRight); - QCOMPARE(Qt::LayoutDirection(item->property("layoutDirection").toInt()), Qt::LeftToRight); -} - -void tst_qdeclarativeapplication::inputPanel() -{ - QDeclarativeComponent component(&engine); - component.setData("import QtQuick 2.0; Item { property variant inputPanel: Qt.application.inputPanel }", QUrl::fromLocalFile("")); - QQuickItem *item = qobject_cast(component.create()); - QVERIFY(item); - QQuickView view; - item->setParentItem(view.rootObject()); - - // check that the inputPanel property maches with application's input panel - QCOMPARE(qvariant_cast(item->property("inputPanel")), qApp->inputMethod()); -} - -void tst_qdeclarativeapplication::inputMethod() -{ - // technically not in QDeclarativeApplication, but testing anyway here - QDeclarativeComponent component(&engine); - component.setData("import QtQuick 2.0; Item { property variant inputMethod: Qt.inputMethod }", QUrl::fromLocalFile("")); - QQuickItem *item = qobject_cast(component.create()); - QVERIFY(item); - QQuickView view; - item->setParentItem(view.rootObject()); - - // check that the inputMethod property maches with application's input method - QCOMPARE(qvariant_cast(item->property("inputMethod")), qApp->inputMethod()); -} - - -QTEST_MAIN(tst_qdeclarativeapplication) - -#include "tst_qdeclarativeapplication.moc" diff --git a/tests/auto/qtquick2/qdeclarativebehaviors/data/binding.qml b/tests/auto/qtquick2/qdeclarativebehaviors/data/binding.qml deleted file mode 100644 index 5aceefa743..0000000000 --- a/tests/auto/qtquick2/qdeclarativebehaviors/data/binding.qml +++ /dev/null @@ -1,26 +0,0 @@ -import QtQuick 2.0 -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 - Behavior on x { NumberAnimation { duration: 800; } } - } - MouseArea { - id: clicker - anchors.fill: parent - } - states: State { - name: "moved" - when: clicker.pressed - PropertyChanges { - target: rect - x: movedx - } - } -} diff --git a/tests/auto/qtquick2/qdeclarativebehaviors/data/color.qml b/tests/auto/qtquick2/qdeclarativebehaviors/data/color.qml deleted file mode 100644 index a318578a9b..0000000000 --- a/tests/auto/qtquick2/qdeclarativebehaviors/data/color.qml +++ /dev/null @@ -1,24 +0,0 @@ -import QtQuick 2.0 -Rectangle { - width: 400 - height: 400 - Rectangle { - id: rect - objectName: "MyRect" - width: 100; height: 100; - color: "green" - Behavior on color { ColorAnimation { duration: 500; } } - } - MouseArea { - id: clicker - anchors.fill: parent - } - states: State { - name: "red" - when: clicker.pressed - PropertyChanges { - target: rect - color: "red" - } - } -} diff --git a/tests/auto/qtquick2/qdeclarativebehaviors/data/cpptrigger.qml b/tests/auto/qtquick2/qdeclarativebehaviors/data/cpptrigger.qml deleted file mode 100644 index f033ec5aeb..0000000000 --- a/tests/auto/qtquick2/qdeclarativebehaviors/data/cpptrigger.qml +++ /dev/null @@ -1,11 +0,0 @@ -import QtQuick 2.0 -Rectangle { - width: 400 - height: 400 - Rectangle { - id: rect - objectName: "MyRect" - width: 100; height: 100; color: "green" - Behavior on x { NumberAnimation { duration: 500; } } - } -} diff --git a/tests/auto/qtquick2/qdeclarativebehaviors/data/delayedRegistration.qml b/tests/auto/qtquick2/qdeclarativebehaviors/data/delayedRegistration.qml deleted file mode 100644 index ed35a308f7..0000000000 --- a/tests/auto/qtquick2/qdeclarativebehaviors/data/delayedRegistration.qml +++ /dev/null @@ -1,25 +0,0 @@ -import QtQuick 2.0 - -Rectangle { - id: container - - width: 400; height: 400; - property Item myItem - - function doCreate() { - myItem = myComponent.createObject(container) - myItem.x = 100 - } - - Component { - id: myComponent - Rectangle { - width: 100 - height: 100 - color: "green" - Behavior on x { NumberAnimation { duration: 500 } } - } - } - - Component.onCompleted: doCreate() -} diff --git a/tests/auto/qtquick2/qdeclarativebehaviors/data/disabled.qml b/tests/auto/qtquick2/qdeclarativebehaviors/data/disabled.qml deleted file mode 100644 index 20860d8dde..0000000000 --- a/tests/auto/qtquick2/qdeclarativebehaviors/data/disabled.qml +++ /dev/null @@ -1,27 +0,0 @@ -import QtQuick 2.0 -Rectangle { - width: 400 - height: 400 - Rectangle { - id: rect - objectName: "MyRect" - width: 100; height: 100; color: "green" - Behavior on x { - objectName: "MyBehavior"; - enabled: false - NumberAnimation { duration: 200; } - } - } - MouseArea { - id: clicker - anchors.fill: parent - } - states: State { - name: "moved" - when: clicker.pressed - PropertyChanges { - target: rect - x: 200 - } - } -} diff --git a/tests/auto/qtquick2/qdeclarativebehaviors/data/dontStart.qml b/tests/auto/qtquick2/qdeclarativebehaviors/data/dontStart.qml deleted file mode 100644 index 38e1ea9d9e..0000000000 --- a/tests/auto/qtquick2/qdeclarativebehaviors/data/dontStart.qml +++ /dev/null @@ -1,18 +0,0 @@ -import QtQuick 2.0 - -Rectangle { - id: wrapper - width: 600 - height: 400 - - Rectangle { - id: redRect - width: 100; height: 100 - color: Qt.rgba(1,0,0) - Behavior on x { - NumberAnimation {id: myAnim; objectName: "MyAnim"; running: true } - } - - } - -} diff --git a/tests/auto/qtquick2/qdeclarativebehaviors/data/empty.qml b/tests/auto/qtquick2/qdeclarativebehaviors/data/empty.qml deleted file mode 100644 index d8f115390a..0000000000 --- a/tests/auto/qtquick2/qdeclarativebehaviors/data/empty.qml +++ /dev/null @@ -1,23 +0,0 @@ -import QtQuick 2.0 -Rectangle { - width: 400 - height: 400 - Rectangle { - id: rect - objectName: "MyRect" - width: 100; height: 100; color: "green" - Behavior on x {} - } - MouseArea { - id: clicker - anchors.fill: parent - } - states: State { - name: "moved" - when: clicker.pressed - PropertyChanges { - target: rect - x: 200 - } - } -} diff --git a/tests/auto/qtquick2/qdeclarativebehaviors/data/explicit.qml b/tests/auto/qtquick2/qdeclarativebehaviors/data/explicit.qml deleted file mode 100644 index 20875c30e3..0000000000 --- a/tests/auto/qtquick2/qdeclarativebehaviors/data/explicit.qml +++ /dev/null @@ -1,26 +0,0 @@ -import QtQuick 2.0 -Rectangle { - width: 400 - height: 400 - Rectangle { - id: rect - objectName: "MyRect" - width: 100; height: 100; color: "green" - Behavior on x { - objectName: "MyBehavior"; - NumberAnimation { target: rect; property: "x"; duration: 500; } - } - } - MouseArea { - id: clicker - anchors.fill: parent - } - states: State { - name: "moved" - when: clicker.pressed - PropertyChanges { - target: rect - x: 200 - } - } -} diff --git a/tests/auto/qtquick2/qdeclarativebehaviors/data/groupProperty.qml b/tests/auto/qtquick2/qdeclarativebehaviors/data/groupProperty.qml deleted file mode 100644 index a05ab7d54b..0000000000 --- a/tests/auto/qtquick2/qdeclarativebehaviors/data/groupProperty.qml +++ /dev/null @@ -1,23 +0,0 @@ -import QtQuick 2.0 -Rectangle { - width: 400 - height: 400 - Rectangle { - id: rect - objectName: "MyRect" - width: 100; height: 100; color: "green" - Behavior on pos { PropertyAnimation { duration: 500; } } - } - MouseArea { - 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/qtquick2/qdeclarativebehaviors/data/groupProperty2.qml b/tests/auto/qtquick2/qdeclarativebehaviors/data/groupProperty2.qml deleted file mode 100644 index 2f3de5131c..0000000000 --- a/tests/auto/qtquick2/qdeclarativebehaviors/data/groupProperty2.qml +++ /dev/null @@ -1,23 +0,0 @@ -import QtQuick 2.0 -Rectangle { - width: 400 - height: 400 - Rectangle { - id: rect - objectName: "MyRect" - width: 100; height: 100; color: "green" - Behavior on border.width { NumberAnimation { duration: 500; } } - } - MouseArea { - id: clicker - anchors.fill: parent - } - states: State { - name: "moved" - when: clicker.pressed - PropertyChanges { - target: rect - border.width: 4; - } - } -} diff --git a/tests/auto/qtquick2/qdeclarativebehaviors/data/groupedPropertyCrash.qml b/tests/auto/qtquick2/qdeclarativebehaviors/data/groupedPropertyCrash.qml deleted file mode 100644 index 6835902bc5..0000000000 --- a/tests/auto/qtquick2/qdeclarativebehaviors/data/groupedPropertyCrash.qml +++ /dev/null @@ -1,10 +0,0 @@ -import QtQuick 2.0 - -Rectangle { - width: 200 - height: 200 - Text { - Behavior on anchors.verticalCenterOffset { NumberAnimation { duration: 300; } } - text: "Hello World" - } -} diff --git a/tests/auto/qtquick2/qdeclarativebehaviors/data/loop.qml b/tests/auto/qtquick2/qdeclarativebehaviors/data/loop.qml deleted file mode 100644 index 3e8d88734d..0000000000 --- a/tests/auto/qtquick2/qdeclarativebehaviors/data/loop.qml +++ /dev/null @@ -1,19 +0,0 @@ -import QtQuick 2.0 -Rectangle { - width: 400 - height: 400 - Rectangle { - id: rect - objectName: "MyRect" - width: 100; height: 100; color: "green" - Behavior on x { NumberAnimation { duration: 200; } } - onXChanged: x = 100; - } - states: State { - name: "moved" - PropertyChanges { - target: rect - x: 200 - } - } -} diff --git a/tests/auto/qtquick2/qdeclarativebehaviors/data/nonSelecting2.qml b/tests/auto/qtquick2/qdeclarativebehaviors/data/nonSelecting2.qml deleted file mode 100644 index 6357094cfe..0000000000 --- a/tests/auto/qtquick2/qdeclarativebehaviors/data/nonSelecting2.qml +++ /dev/null @@ -1,26 +0,0 @@ -import QtQuick 2.0 -Rectangle { - width: 400 - height: 400 - Rectangle { - id: rect - objectName: "MyRect" - width: 100; height: 100; color: "green" - Behavior on x { - objectName: "MyBehavior"; - NumberAnimation { targets: rect; properties: "y"; duration: 200; } - } - } - MouseArea { - id: clicker - anchors.fill: parent - } - states: State { - name: "moved" - when: clicker.pressed - PropertyChanges { - target: rect - x: 200 - } - } -} diff --git a/tests/auto/qtquick2/qdeclarativebehaviors/data/parent.qml b/tests/auto/qtquick2/qdeclarativebehaviors/data/parent.qml deleted file mode 100644 index f8c2731d86..0000000000 --- a/tests/auto/qtquick2/qdeclarativebehaviors/data/parent.qml +++ /dev/null @@ -1,28 +0,0 @@ -import QtQuick 2.0 -Rectangle { - width: 400 - height: 400 - Rectangle { - id: rect - objectName: "MyRect" - width: 100; height: 100; color: "green" - Behavior on parent { - SequentialAnimation { - PauseAnimation { duration: 500 } - PropertyAction {} - } - } - } - Item { - id: newParent - objectName: "NewParent" - x: 100 - } - states: State { - name: "reparented" - PropertyChanges { - target: rect - parent: newParent - } - } -} diff --git a/tests/auto/qtquick2/qdeclarativebehaviors/data/qtbug12295.qml b/tests/auto/qtquick2/qdeclarativebehaviors/data/qtbug12295.qml deleted file mode 100644 index c6bef581a4..0000000000 --- a/tests/auto/qtquick2/qdeclarativebehaviors/data/qtbug12295.qml +++ /dev/null @@ -1,17 +0,0 @@ -import QtQuick 2.0 - -Rectangle { - width: 200 - height: 200 - color: "blue" - - Rectangle { - id: myRect - objectName: "myRect" - width: 100 - height: 100 - Behavior on x { - NumberAnimation { duration: 500 } - } - } -} diff --git a/tests/auto/qtquick2/qdeclarativebehaviors/data/reassignedAnimation.qml b/tests/auto/qtquick2/qdeclarativebehaviors/data/reassignedAnimation.qml deleted file mode 100644 index 5731cb3efd..0000000000 --- a/tests/auto/qtquick2/qdeclarativebehaviors/data/reassignedAnimation.qml +++ /dev/null @@ -1,32 +0,0 @@ -import QtQuick 2.0 -Rectangle { - width: 400 - height: 400 - Rectangle { - id: rect - objectName: "MyRect" - width: 100; height: 100; color: "green" - Behavior on x { - id: myBehavior - objectName: "MyBehavior" - NumberAnimation {id: na1; duration: 200 } - } - } - MouseArea { - id: clicker - anchors.fill: parent - } - states: State { - name: "moved" - when: clicker.pressed - PropertyChanges { - target: rect - x: 200 - } - } - - NumberAnimation {id: na2; duration: 1000 } - Component.onCompleted: { - myBehavior.animation = na2; - } -} diff --git a/tests/auto/qtquick2/qdeclarativebehaviors/data/runningTrue.qml b/tests/auto/qtquick2/qdeclarativebehaviors/data/runningTrue.qml deleted file mode 100644 index 4fd1136f3a..0000000000 --- a/tests/auto/qtquick2/qdeclarativebehaviors/data/runningTrue.qml +++ /dev/null @@ -1,20 +0,0 @@ -import QtQuick 2.0 - -Rectangle { - id: root - width:200; height:200 - - property real myValue: 0 - - Rectangle { - anchors.centerIn: parent - width: 100 - height: 100 - color: "green" - smooth: true - rotation: myValue - Behavior on rotation { - RotationAnimation { id: rotAnim; objectName: "rotAnim"; direction: RotationAnimation.Shortest } - } - } -} diff --git a/tests/auto/qtquick2/qdeclarativebehaviors/data/scripttrigger.qml b/tests/auto/qtquick2/qdeclarativebehaviors/data/scripttrigger.qml deleted file mode 100644 index ff71f2b1b0..0000000000 --- a/tests/auto/qtquick2/qdeclarativebehaviors/data/scripttrigger.qml +++ /dev/null @@ -1,16 +0,0 @@ -import QtQuick 2.0 -Rectangle { - width: 400 - height: 400 - - onColorChanged: { - rect.x = 200 - } - - Rectangle { - id: rect - objectName: "MyRect" - width: 100; height: 100; color: "green" - Behavior on x { NumberAnimation { duration: 800; } } - } -} diff --git a/tests/auto/qtquick2/qdeclarativebehaviors/data/simple.qml b/tests/auto/qtquick2/qdeclarativebehaviors/data/simple.qml deleted file mode 100644 index c64a6e1928..0000000000 --- a/tests/auto/qtquick2/qdeclarativebehaviors/data/simple.qml +++ /dev/null @@ -1,26 +0,0 @@ -import QtQuick 2.0 -Rectangle { - width: 400 - height: 400 - Rectangle { - id: rect - objectName: "MyRect" - width: 100; height: 100; color: "green" - Behavior on x { - objectName: "MyBehavior"; - NumberAnimation {id: na; duration: 500; } - } - } - MouseArea { - id: clicker - anchors.fill: parent - } - states: State { - name: "moved" - when: clicker.pressed - PropertyChanges { - target: rect - x: 200 - } - } -} diff --git a/tests/auto/qtquick2/qdeclarativebehaviors/data/startOnCompleted.qml b/tests/auto/qtquick2/qdeclarativebehaviors/data/startOnCompleted.qml deleted file mode 100644 index fdc3779a5c..0000000000 --- a/tests/auto/qtquick2/qdeclarativebehaviors/data/startOnCompleted.qml +++ /dev/null @@ -1,15 +0,0 @@ -import QtQuick 2.0 - -Rectangle { - width: 400 - height: 400 - - Rectangle { - id: innerRect - width: 100; height: 100 - color: "green" - Behavior on x { NumberAnimation {} } - } - - Component.onCompleted: innerRect.x = 100 -} diff --git a/tests/auto/qtquick2/qdeclarativebehaviors/data/startup.qml b/tests/auto/qtquick2/qdeclarativebehaviors/data/startup.qml deleted file mode 100644 index 9fa74ca39e..0000000000 --- a/tests/auto/qtquick2/qdeclarativebehaviors/data/startup.qml +++ /dev/null @@ -1,17 +0,0 @@ -import QtQuick 2.0 - -Rectangle { - width: 400 - height: 400 - - Rectangle { - objectName: "innerRect" - height: 100; width: 100; color: "green" - property real targetX: 100 - - x: targetX - Behavior on x { - NumberAnimation {} - } - } -} diff --git a/tests/auto/qtquick2/qdeclarativebehaviors/data/startup2.qml b/tests/auto/qtquick2/qdeclarativebehaviors/data/startup2.qml deleted file mode 100644 index 0654ef3644..0000000000 --- a/tests/auto/qtquick2/qdeclarativebehaviors/data/startup2.qml +++ /dev/null @@ -1,16 +0,0 @@ -import QtQuick 2.0 - -Rectangle { - width: 800; - height: 480; - - Text { id:theText; text: "hello world" } - - Rectangle { - objectName: "innerRect" - color: "red" - x: theText.width - Behavior on x { NumberAnimation {} } - width: 100; height: 100 - } -} diff --git a/tests/auto/qtquick2/qdeclarativebehaviors/data/valueType.qml b/tests/auto/qtquick2/qdeclarativebehaviors/data/valueType.qml deleted file mode 100644 index 7bc8297dc7..0000000000 --- a/tests/auto/qtquick2/qdeclarativebehaviors/data/valueType.qml +++ /dev/null @@ -1,13 +0,0 @@ -import QtQuick 2.0 -Rectangle { - width: 400 - height: 400 - - color.r: 1 - color.g: 0 - color.b: 1 - - Behavior on color.r { NumberAnimation { duration: 500; } } - - function changeR() { color.r = 0 } -} diff --git a/tests/auto/qtquick2/qdeclarativebehaviors/qdeclarativebehaviors.pro b/tests/auto/qtquick2/qdeclarativebehaviors/qdeclarativebehaviors.pro deleted file mode 100644 index 7089f1ce57..0000000000 --- a/tests/auto/qtquick2/qdeclarativebehaviors/qdeclarativebehaviors.pro +++ /dev/null @@ -1,15 +0,0 @@ -CONFIG += testcase -TARGET = tst_qdeclarativebehaviors -SOURCES += tst_qdeclarativebehaviors.cpp - -include (../../shared/util.pri) - -macx:CONFIG -= app_bundle - -testDataFiles.files = data -testDataFiles.path = . -DEPLOYMENT += testDataFiles - -CONFIG += parallel_test - -QT += core-private gui-private v8-private declarative-private quick-private opengl-private testlib diff --git a/tests/auto/qtquick2/qdeclarativebehaviors/tst_qdeclarativebehaviors.cpp b/tests/auto/qtquick2/qdeclarativebehaviors/tst_qdeclarativebehaviors.cpp deleted file mode 100644 index c1e60f1560..0000000000 --- a/tests/auto/qtquick2/qdeclarativebehaviors/tst_qdeclarativebehaviors.cpp +++ /dev/null @@ -1,473 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "../../shared/util.h" - -class tst_qdeclarativebehaviors : public QDeclarativeDataTest -{ - Q_OBJECT -public: - tst_qdeclarativebehaviors() {} - -private slots: - void init() { qApp->processEvents(); } //work around animation timer bug (QTBUG-22865) - void simpleBehavior(); - void scriptTriggered(); - void cppTriggered(); - void loop(); - void colorBehavior(); - void parentBehavior(); - void replaceBinding(); - //void transitionOverrides(); - void group(); - void valueType(); - void emptyBehavior(); - void explicitSelection(); - void nonSelectingBehavior(); - void reassignedAnimation(); - void disabled(); - void dontStart(); - void startup(); - void groupedPropertyCrash(); - void runningTrue(); - void sameValue(); - void delayedRegistration(); - void startOnCompleted(); -}; - -void tst_qdeclarativebehaviors::simpleBehavior() -{ - QDeclarativeEngine engine; - QDeclarativeComponent c(&engine, testFileUrl("simple.qml")); - QQuickRectangle *rect = qobject_cast(c.create()); - QTRY_VERIFY(rect); - QTRY_VERIFY(qobject_cast(rect->findChild("MyBehavior"))->animation()); - - QQuickItemPrivate::get(rect)->setState("moved"); - QTRY_VERIFY(qobject_cast(rect->findChild("MyRect"))->x() > 0); - QTRY_VERIFY(qobject_cast(rect->findChild("MyRect"))->x() < 200); - //i.e. the behavior has been triggered - - delete rect; -} - -void tst_qdeclarativebehaviors::scriptTriggered() -{ - QDeclarativeEngine engine; - QDeclarativeComponent c(&engine, testFileUrl("scripttrigger.qml")); - QQuickRectangle *rect = qobject_cast(c.create()); - QTRY_VERIFY(rect); - - rect->setColor(QColor("red")); - QTRY_VERIFY(qobject_cast(rect->findChild("MyRect"))->x() > 0); - QTRY_VERIFY(qobject_cast(rect->findChild("MyRect"))->x() < 200); - //i.e. the behavior has been triggered - - delete rect; -} - -void tst_qdeclarativebehaviors::cppTriggered() -{ - QDeclarativeEngine engine; - QDeclarativeComponent c(&engine, testFileUrl("cpptrigger.qml")); - QQuickRectangle *rect = qobject_cast(c.create()); - QTRY_VERIFY(rect); - - QQuickRectangle *innerRect = qobject_cast(rect->findChild("MyRect")); - QTRY_VERIFY(innerRect); - - innerRect->setProperty("x", 200); - QTRY_VERIFY(innerRect->x() > 0); - QTRY_VERIFY(innerRect->x() < 200); //i.e. the behavior has been triggered - - delete rect; -} - -void tst_qdeclarativebehaviors::loop() -{ - QDeclarativeEngine engine; - QDeclarativeComponent c(&engine, testFileUrl("loop.qml")); - QQuickRectangle *rect = qobject_cast(c.create()); - QTRY_VERIFY(rect); - - //don't crash - QQuickItemPrivate::get(rect)->setState("moved"); - - delete rect; -} - -void tst_qdeclarativebehaviors::colorBehavior() -{ - QDeclarativeEngine engine; - QDeclarativeComponent c(&engine, testFileUrl("color.qml")); - QQuickRectangle *rect = qobject_cast(c.create()); - QTRY_VERIFY(rect); - - QQuickItemPrivate::get(rect)->setState("red"); - QTRY_VERIFY(qobject_cast(rect->findChild("MyRect"))->color() != QColor("red")); - QTRY_VERIFY(qobject_cast(rect->findChild("MyRect"))->color() != QColor("green")); - //i.e. the behavior has been triggered - - delete rect; -} - -void tst_qdeclarativebehaviors::parentBehavior() -{ - QDeclarativeEngine engine; - QDeclarativeComponent c(&engine, testFileUrl("parent.qml")); - QQuickRectangle *rect = qobject_cast(c.create()); - QTRY_VERIFY(rect); - - QQuickItemPrivate::get(rect)->setState("reparented"); - QTRY_VERIFY(rect->findChild("MyRect")->parentItem() != rect->findChild("NewParent")); - QTRY_VERIFY(rect->findChild("MyRect")->parentItem() == rect->findChild("NewParent")); - - delete rect; -} - -void tst_qdeclarativebehaviors::replaceBinding() -{ - QDeclarativeEngine engine; - QDeclarativeComponent c(&engine, testFileUrl("binding.qml")); - QQuickRectangle *rect = qobject_cast(c.create()); - QTRY_VERIFY(rect); - - QQuickItemPrivate::get(rect)->setState("moved"); - QQuickRectangle *innerRect = qobject_cast(rect->findChild("MyRect")); - QTRY_VERIFY(innerRect); - QTRY_VERIFY(innerRect->x() > 0); - QTRY_VERIFY(innerRect->x() < 200); - //i.e. the behavior has been triggered - QTRY_COMPARE(innerRect->x(), (qreal)200); - rect->setProperty("basex", 10); - QTRY_COMPARE(innerRect->x(), (qreal)200); - rect->setProperty("movedx", 210); - QTRY_COMPARE(innerRect->x(), (qreal)210); - - QQuickItemPrivate::get(rect)->setState(""); - QTRY_VERIFY(innerRect->x() > 10); - QTRY_VERIFY(innerRect->x() < 210); //i.e. the behavior has been triggered - QTRY_COMPARE(innerRect->x(), (qreal)10); - rect->setProperty("movedx", 200); - QTRY_COMPARE(innerRect->x(), (qreal)10); - rect->setProperty("basex", 20); - QTRY_COMPARE(innerRect->x(), (qreal)20); - - delete rect; -} - -void tst_qdeclarativebehaviors::group() -{ - /* XXX TODO Create a test element for this case. - { - QDeclarativeEngine engine; - QDeclarativeComponent c(&engine, testFileUrl("groupProperty.qml"))); - QQuickRectangle *rect = qobject_cast(c.create()); - qDebug() << c.errorString(); - QTRY_VERIFY(rect); - - QQuickItemPrivate::get(rect)->setState("moved"); - //QTest::qWait(200); - QTRY_VERIFY(qobject_cast(rect->findChild("MyRect"))->x() > 0); - QTRY_VERIFY(qobject_cast(rect->findChild("MyRect"))->x() < 200); - //i.e. the behavior has been triggered - - delete rect; - } - */ - - { - QDeclarativeEngine engine; - QDeclarativeComponent c(&engine, testFileUrl("groupProperty2.qml")); - QQuickRectangle *rect = qobject_cast(c.create()); - QTRY_VERIFY(rect); - - QQuickItemPrivate::get(rect)->setState("moved"); - QTRY_VERIFY(qobject_cast(rect->findChild("MyRect"))->border()->width() > 0); - QTRY_VERIFY(qobject_cast(rect->findChild("MyRect"))->border()->width() < 4); - //i.e. the behavior has been triggered - - delete rect; - } -} - -void tst_qdeclarativebehaviors::valueType() -{ - QDeclarativeEngine engine; - QDeclarativeComponent c(&engine, testFileUrl("valueType.qml")); - QQuickRectangle *rect = qobject_cast(c.create()); - QVERIFY(rect); - - //QTBUG-20827 - QCOMPARE(rect->color(), QColor::fromRgb(255,0,255)); - - delete rect; -} - -void tst_qdeclarativebehaviors::emptyBehavior() -{ - QDeclarativeEngine engine; - QDeclarativeComponent c(&engine, testFileUrl("empty.qml")); - QQuickRectangle *rect = qobject_cast(c.create()); - QVERIFY(rect); - - QQuickItemPrivate::get(rect)->setState("moved"); - qreal x = qobject_cast(rect->findChild("MyRect"))->x(); - QCOMPARE(x, qreal(200)); //should change immediately - - delete rect; -} - -void tst_qdeclarativebehaviors::explicitSelection() -{ - QDeclarativeEngine engine; - QDeclarativeComponent c(&engine, testFileUrl("explicit.qml")); - QQuickRectangle *rect = qobject_cast(c.create()); - QVERIFY(rect); - - QQuickItemPrivate::get(rect)->setState("moved"); - QTRY_VERIFY(qobject_cast(rect->findChild("MyRect"))->x() > 0); - QTRY_VERIFY(qobject_cast(rect->findChild("MyRect"))->x() < 200); - //i.e. the behavior has been triggered - - delete rect; -} - -void tst_qdeclarativebehaviors::nonSelectingBehavior() -{ - QDeclarativeEngine engine; - QDeclarativeComponent c(&engine, testFileUrl("nonSelecting2.qml")); - QQuickRectangle *rect = qobject_cast(c.create()); - QVERIFY(rect); - - QQuickItemPrivate::get(rect)->setState("moved"); - qreal x = qobject_cast(rect->findChild("MyRect"))->x(); - QCOMPARE(x, qreal(200)); //should change immediately - - delete rect; -} - -void tst_qdeclarativebehaviors::reassignedAnimation() -{ - QDeclarativeEngine engine; - QDeclarativeComponent c(&engine, testFileUrl("reassignedAnimation.qml")); - QString warning = testFileUrl("reassignedAnimation.qml").toString() + ":9:9: QML Behavior: Cannot change the animation assigned to a Behavior."; - QTest::ignoreMessage(QtWarningMsg, qPrintable(warning)); - QQuickRectangle *rect = qobject_cast(c.create()); - QVERIFY(rect); - QCOMPARE(qobject_cast( - rect->findChild("MyBehavior")->animation())->duration(), 200); - - delete rect; -} - -void tst_qdeclarativebehaviors::disabled() -{ - QDeclarativeEngine engine; - QDeclarativeComponent c(&engine, testFileUrl("disabled.qml")); - QQuickRectangle *rect = qobject_cast(c.create()); - QVERIFY(rect); - QCOMPARE(rect->findChild("MyBehavior")->enabled(), false); - - QQuickItemPrivate::get(rect)->setState("moved"); - qreal x = qobject_cast(rect->findChild("MyRect"))->x(); - QCOMPARE(x, qreal(200)); //should change immediately - - delete rect; -} - -void tst_qdeclarativebehaviors::dontStart() -{ - QDeclarativeEngine engine; - - QDeclarativeComponent c(&engine, testFileUrl("dontStart.qml")); - - QString warning = c.url().toString() + ":13:13: QML NumberAnimation: setRunning() cannot be used on non-root animation nodes."; - QTest::ignoreMessage(QtWarningMsg, qPrintable(warning)); - QQuickRectangle *rect = qobject_cast(c.create()); - QVERIFY(rect); - - QDeclarativeAbstractAnimation *myAnim = rect->findChild("MyAnim"); - QVERIFY(myAnim && !myAnim->qtAnimation()); - - delete rect; -} - -void tst_qdeclarativebehaviors::startup() -{ - { - QDeclarativeEngine engine; - QDeclarativeComponent c(&engine, testFileUrl("startup.qml")); - QQuickRectangle *rect = qobject_cast(c.create()); - QVERIFY(rect); - - QQuickRectangle *innerRect = rect->findChild("innerRect"); - QVERIFY(innerRect); - - QCOMPARE(innerRect->x(), qreal(100)); //should be set immediately - - delete rect; - } - - { - QDeclarativeEngine engine; - QDeclarativeComponent c(&engine, testFileUrl("startup2.qml")); - QQuickRectangle *rect = qobject_cast(c.create()); - QVERIFY(rect); - - QQuickRectangle *innerRect = rect->findChild("innerRect"); - QVERIFY(innerRect); - - QQuickText *text = rect->findChild(); - QVERIFY(text); - - QCOMPARE(innerRect->x(), text->width()); //should be set immediately - - delete rect; - } -} - -//QTBUG-10799 -void tst_qdeclarativebehaviors::groupedPropertyCrash() -{ - QDeclarativeEngine engine; - QDeclarativeComponent c(&engine, testFileUrl("groupedPropertyCrash.qml")); - QQuickRectangle *rect = qobject_cast(c.create()); - QVERIFY(rect); //don't crash - - delete rect; -} - -//QTBUG-5491 -void tst_qdeclarativebehaviors::runningTrue() -{ - QDeclarativeEngine engine; - QDeclarativeComponent c(&engine, testFileUrl("runningTrue.qml")); - QQuickRectangle *rect = qobject_cast(c.create()); - QVERIFY(rect); - - QDeclarativeAbstractAnimation *animation = rect->findChild("rotAnim"); - QVERIFY(animation); - - QSignalSpy runningSpy(animation, SIGNAL(runningChanged(bool))); - rect->setProperty("myValue", 180); - QTRY_VERIFY(runningSpy.count() > 0); - - delete rect; -} - -//QTBUG-12295 -void tst_qdeclarativebehaviors::sameValue() -{ - QDeclarativeEngine engine; - QDeclarativeComponent c(&engine, testFileUrl("qtbug12295.qml")); - QQuickRectangle *rect = qobject_cast(c.create()); - QVERIFY(rect); - - QQuickRectangle *target = rect->findChild("myRect"); - QVERIFY(target); - - target->setX(100); - QCOMPARE(target->x(), qreal(100)); - - target->setProperty("x", 0); - QTRY_VERIFY(target->x() != qreal(0) && target->x() != qreal(100)); - QTRY_VERIFY(target->x() == qreal(0)); //make sure Behavior has finished. - - target->setX(100); - QCOMPARE(target->x(), qreal(100)); - - //this is the main point of the test -- the behavior needs to be triggered again - //even though we set 0 twice in a row. - target->setProperty("x", 0); - QTRY_VERIFY(target->x() != qreal(0) && target->x() != qreal(100)); - - delete rect; -} - -//QTBUG-18362 -void tst_qdeclarativebehaviors::delayedRegistration() -{ - QDeclarativeEngine engine; - - QDeclarativeComponent c(&engine, testFileUrl("delayedRegistration.qml")); - QQuickRectangle *rect = qobject_cast(c.create()); - QVERIFY(rect != 0); - - QQuickItem *innerRect = rect->property("myItem").value(); - QVERIFY(innerRect != 0); - - QCOMPARE(innerRect->property("x").toInt(), int(0)); - - QTRY_COMPARE(innerRect->property("x").toInt(), int(100)); -} - -//QTBUG-22555 -void tst_qdeclarativebehaviors::startOnCompleted() -{ - QDeclarativeEngine engine; - - QDeclarativeComponent c(&engine, testFileUrl("startOnCompleted.qml")); - QQuickRectangle *rect = qobject_cast(c.create()); - QVERIFY(rect != 0); - - QQuickItem *innerRect = rect->findChild(); - QVERIFY(innerRect != 0); - - QCOMPARE(innerRect->property("x").toInt(), int(0)); - - QTRY_COMPARE(innerRect->property("x").toInt(), int(100)); - - delete rect; -} - -QTEST_MAIN(tst_qdeclarativebehaviors) - -#include "tst_qdeclarativebehaviors.moc" diff --git a/tests/auto/qtquick2/qdeclarativefontloader/data/daniel.ttf b/tests/auto/qtquick2/qdeclarativefontloader/data/daniel.ttf deleted file mode 100644 index aae50d5035..0000000000 Binary files a/tests/auto/qtquick2/qdeclarativefontloader/data/daniel.ttf and /dev/null differ diff --git a/tests/auto/qtquick2/qdeclarativefontloader/data/dummy.ttf b/tests/auto/qtquick2/qdeclarativefontloader/data/dummy.ttf deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/tests/auto/qtquick2/qdeclarativefontloader/data/qtbug-20268.qml b/tests/auto/qtquick2/qdeclarativefontloader/data/qtbug-20268.qml deleted file mode 100644 index 0eafdfa17b..0000000000 --- a/tests/auto/qtquick2/qdeclarativefontloader/data/qtbug-20268.qml +++ /dev/null @@ -1,27 +0,0 @@ -import QtQuick 2.0 - -Rectangle { - id: test - property variant fontloader: fontloaderelement - height: 100; width: 100 - property bool usename: false - property int statenum: 1 - property alias name: fontloaderelement.name - property alias source: fontloaderelement.source - property alias status: fontloaderelement.status - - FontLoader { - id: fontloaderelement - } - - states: [ - State { name: "start"; when: !usename - PropertyChanges { target: fontloaderelement; source: "tarzeau_ocr_a.ttf" } - }, - State { name: "changefont"; when: usename - PropertyChanges { target: fontloaderelement; name: "Tahoma" } - } - ] - - Text { id: textelement; text: fontloaderelement.name; color: "black" } -} diff --git a/tests/auto/qtquick2/qdeclarativefontloader/data/tarzeau_ocr_a.ttf b/tests/auto/qtquick2/qdeclarativefontloader/data/tarzeau_ocr_a.ttf deleted file mode 100644 index cf93f9651f..0000000000 Binary files a/tests/auto/qtquick2/qdeclarativefontloader/data/tarzeau_ocr_a.ttf and /dev/null differ diff --git a/tests/auto/qtquick2/qdeclarativefontloader/qdeclarativefontloader.pro b/tests/auto/qtquick2/qdeclarativefontloader/qdeclarativefontloader.pro deleted file mode 100644 index 0e84fc9dce..0000000000 --- a/tests/auto/qtquick2/qdeclarativefontloader/qdeclarativefontloader.pro +++ /dev/null @@ -1,17 +0,0 @@ -CONFIG += testcase -TARGET = tst_qdeclarativefontloader -macx:CONFIG -= app_bundle - -HEADERS += ../../shared/testhttpserver.h -SOURCES += tst_qdeclarativefontloader.cpp \ - ../../shared/testhttpserver.cpp - -include (../../shared/util.pri) - -testDataFiles.files = data -testDataFiles.path = . -DEPLOYMENT += testDataFiles - -CONFIG += parallel_test - -QT += core-private gui-private declarative-private quick-private network testlib diff --git a/tests/auto/qtquick2/qdeclarativefontloader/tst_qdeclarativefontloader.cpp b/tests/auto/qtquick2/qdeclarativefontloader/tst_qdeclarativefontloader.cpp deleted file mode 100644 index e3571a411c..0000000000 --- a/tests/auto/qtquick2/qdeclarativefontloader/tst_qdeclarativefontloader.cpp +++ /dev/null @@ -1,255 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include -#include -#include -#include -#include -#include -#include "../../shared/util.h" -#include "../../shared/testhttpserver.h" -#include -#include - -#define SERVER_PORT 14448 - -class tst_qdeclarativefontloader : public QDeclarativeDataTest -{ - Q_OBJECT -public: - tst_qdeclarativefontloader(); - -private slots: - void initTestCase(); - void noFont(); - void namedFont(); - void localFont(); - void failLocalFont(); - void webFont(); - void redirWebFont(); - void failWebFont(); - void changeFont(); - void changeFontSourceViaState(); - -private: - QDeclarativeEngine engine; - TestHTTPServer server; -}; - -tst_qdeclarativefontloader::tst_qdeclarativefontloader() : - server(SERVER_PORT) -{ -} - -void tst_qdeclarativefontloader::initTestCase() -{ - QDeclarativeDataTest::initTestCase(); - server.serveDirectory(dataDirectory()); - QVERIFY(server.isValid()); -} - -void tst_qdeclarativefontloader::noFont() -{ - QString componentStr = "import QtQuick 2.0\nFontLoader { }"; - QDeclarativeComponent component(&engine); - component.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); - QDeclarativeFontLoader *fontObject = qobject_cast(component.create()); - - QVERIFY(fontObject != 0); - QCOMPARE(fontObject->name(), QString("")); - QCOMPARE(fontObject->source(), QUrl("")); - QTRY_VERIFY(fontObject->status() == QDeclarativeFontLoader::Null); - - delete fontObject; -} - -void tst_qdeclarativefontloader::namedFont() -{ - QString componentStr = "import QtQuick 2.0\nFontLoader { name: \"Helvetica\" }"; - QDeclarativeComponent component(&engine); - component.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); - QDeclarativeFontLoader *fontObject = qobject_cast(component.create()); - - QVERIFY(fontObject != 0); - QCOMPARE(fontObject->source(), QUrl("")); - QCOMPARE(fontObject->name(), QString("Helvetica")); - QTRY_VERIFY(fontObject->status() == QDeclarativeFontLoader::Ready); -} - -void tst_qdeclarativefontloader::localFont() -{ - QString componentStr = "import QtQuick 2.0\nFontLoader { source: \"" + testFile("tarzeau_ocr_a.ttf") + "\" }"; - QDeclarativeComponent component(&engine); - component.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); - QDeclarativeFontLoader *fontObject = qobject_cast(component.create()); - - QVERIFY(fontObject != 0); - QVERIFY(fontObject->source() != QUrl("")); - QTRY_COMPARE(fontObject->name(), QString("OCRA")); - QTRY_VERIFY(fontObject->status() == QDeclarativeFontLoader::Ready); -} - -void tst_qdeclarativefontloader::failLocalFont() -{ - QString componentStr = "import QtQuick 2.0\nFontLoader { source: \"" + testFileUrl("dummy.ttf").toString() + "\" }"; - QTest::ignoreMessage(QtWarningMsg, QString("file::2:1: QML FontLoader: Cannot load font: \"" + testFileUrl("dummy.ttf").toString() + "\"").toUtf8().constData()); - QDeclarativeComponent component(&engine); - component.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); - QDeclarativeFontLoader *fontObject = qobject_cast(component.create()); - - QVERIFY(fontObject != 0); - QVERIFY(fontObject->source() != QUrl("")); - QTRY_COMPARE(fontObject->name(), QString("")); - QTRY_VERIFY(fontObject->status() == QDeclarativeFontLoader::Error); -} - -void tst_qdeclarativefontloader::webFont() -{ - QString componentStr = "import QtQuick 2.0\nFontLoader { source: \"http://localhost:14448/tarzeau_ocr_a.ttf\" }"; - QDeclarativeComponent component(&engine); - - component.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); - QDeclarativeFontLoader *fontObject = qobject_cast(component.create()); - - QVERIFY(fontObject != 0); - QVERIFY(fontObject->source() != QUrl("")); - QTRY_COMPARE(fontObject->name(), QString("OCRA")); - QTRY_VERIFY(fontObject->status() == QDeclarativeFontLoader::Ready); -} - -void tst_qdeclarativefontloader::redirWebFont() -{ - server.addRedirect("olddir/oldname.ttf","../tarzeau_ocr_a.ttf"); - - QString componentStr = "import QtQuick 2.0\nFontLoader { source: \"http://localhost:14448/olddir/oldname.ttf\" }"; - QDeclarativeComponent component(&engine); - - component.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); - QDeclarativeFontLoader *fontObject = qobject_cast(component.create()); - - QVERIFY(fontObject != 0); - QVERIFY(fontObject->source() != QUrl("")); - QTRY_COMPARE(fontObject->name(), QString("OCRA")); - QTRY_VERIFY(fontObject->status() == QDeclarativeFontLoader::Ready); -} - -void tst_qdeclarativefontloader::failWebFont() -{ - QString componentStr = "import QtQuick 2.0\nFontLoader { source: \"http://localhost:14448/nonexist.ttf\" }"; - QTest::ignoreMessage(QtWarningMsg, "file::2:1: QML FontLoader: Cannot load font: \"http://localhost:14448/nonexist.ttf\""); - QDeclarativeComponent component(&engine); - component.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); - QDeclarativeFontLoader *fontObject = qobject_cast(component.create()); - - QVERIFY(fontObject != 0); - QVERIFY(fontObject->source() != QUrl("")); - QTRY_COMPARE(fontObject->name(), QString("")); - QTRY_VERIFY(fontObject->status() == QDeclarativeFontLoader::Error); -} - -void tst_qdeclarativefontloader::changeFont() -{ - QString componentStr = "import QtQuick 2.0\nFontLoader { source: font }"; - QDeclarativeContext *ctxt = engine.rootContext(); - ctxt->setContextProperty("font", testFileUrl("tarzeau_ocr_a.ttf")); - QDeclarativeComponent component(&engine); - component.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); - QDeclarativeFontLoader *fontObject = qobject_cast(component.create()); - - QVERIFY(fontObject != 0); - - QSignalSpy nameSpy(fontObject, SIGNAL(nameChanged())); - QSignalSpy statusSpy(fontObject, SIGNAL(statusChanged())); - - QTRY_VERIFY(fontObject->status() == QDeclarativeFontLoader::Ready); - QCOMPARE(nameSpy.count(), 0); - QCOMPARE(statusSpy.count(), 0); - QTRY_COMPARE(fontObject->name(), QString("OCRA")); - - ctxt->setContextProperty("font", "http://localhost:14448/daniel.ttf"); - QTRY_VERIFY(fontObject->status() == QDeclarativeFontLoader::Loading); - QTRY_VERIFY(fontObject->status() == QDeclarativeFontLoader::Ready); - QCOMPARE(nameSpy.count(), 1); - QCOMPARE(statusSpy.count(), 2); - QTRY_COMPARE(fontObject->name(), QString("Daniel")); - - ctxt->setContextProperty("font", testFileUrl("tarzeau_ocr_a.ttf")); - QTRY_VERIFY(fontObject->status() == QDeclarativeFontLoader::Ready); - QCOMPARE(nameSpy.count(), 2); - QCOMPARE(statusSpy.count(), 2); - QTRY_COMPARE(fontObject->name(), QString("OCRA")); - - ctxt->setContextProperty("font", "http://localhost:14448/daniel.ttf"); - QTRY_VERIFY(fontObject->status() == QDeclarativeFontLoader::Ready); - QCOMPARE(nameSpy.count(), 3); - QCOMPARE(statusSpy.count(), 2); - QTRY_COMPARE(fontObject->name(), QString("Daniel")); -} - -void tst_qdeclarativefontloader::changeFontSourceViaState() -{ - QQuickView canvas(testFileUrl("qtbug-20268.qml")); - canvas.show(); - canvas.requestActivateWindow(); - QTest::qWaitForWindowShown(&canvas); - QTRY_COMPARE(&canvas, qGuiApp->focusWindow()); - - QDeclarativeFontLoader *fontObject = qobject_cast(qvariant_cast(canvas.rootObject()->property("fontloader"))); - QVERIFY(fontObject != 0); - QTRY_VERIFY(fontObject->status() == QDeclarativeFontLoader::Ready); - QVERIFY(fontObject->source() != QUrl("")); - QTRY_COMPARE(fontObject->name(), QString("OCRA")); - - canvas.rootObject()->setProperty("usename", true); - - // This warning should probably not be printed once QTBUG-20268 is fixed - QString warning = QString(testFileUrl("qtbug-20268.qml").toString()) + - QLatin1String(":13:5: QML FontLoader: Cannot load font: \"\""); - QTest::ignoreMessage(QtWarningMsg, qPrintable(warning)); - - QEXPECT_FAIL("", "QTBUG-20268", Abort); - QTRY_VERIFY(fontObject->status() == QDeclarativeFontLoader::Ready); - QCOMPARE(canvas.rootObject()->property("name").toString(), QString("Tahoma")); -} - -QTEST_MAIN(tst_qdeclarativefontloader) - -#include "tst_qdeclarativefontloader.moc" diff --git a/tests/auto/qtquick2/qdeclarativepath/data/arc.qml b/tests/auto/qtquick2/qdeclarativepath/data/arc.qml deleted file mode 100644 index 000221c784..0000000000 --- a/tests/auto/qtquick2/qdeclarativepath/data/arc.qml +++ /dev/null @@ -1,11 +0,0 @@ -import QtQuick 2.0 - -Path { - startX: 0; startY: 0 - - PathArc { - x: 100; y: 100 - radiusX: 100; radiusY: 100 - direction: PathArc.Clockwise - } -} diff --git a/tests/auto/qtquick2/qdeclarativepath/data/closedcurve.qml b/tests/auto/qtquick2/qdeclarativepath/data/closedcurve.qml deleted file mode 100644 index bb4a715e28..0000000000 --- a/tests/auto/qtquick2/qdeclarativepath/data/closedcurve.qml +++ /dev/null @@ -1,9 +0,0 @@ -import QtQuick 2.0 - -Path { - startX: 50; startY: 50 - - PathCurve { x: 100; y: 100 } - PathCurve { x: 50; y: 150 } - PathCurve { x: 50; y: 50 } -} diff --git a/tests/auto/qtquick2/qdeclarativepath/data/curve.qml b/tests/auto/qtquick2/qdeclarativepath/data/curve.qml deleted file mode 100644 index c571186496..0000000000 --- a/tests/auto/qtquick2/qdeclarativepath/data/curve.qml +++ /dev/null @@ -1,9 +0,0 @@ -import QtQuick 2.0 - -Path { - startX: 0; startY: 0 - - PathCurve { x: 100; y: 50 } - PathCurve { x: 50; y: 100 } - PathCurve { x: 100; y: 150 } -} diff --git a/tests/auto/qtquick2/qdeclarativepath/data/svg.qml b/tests/auto/qtquick2/qdeclarativepath/data/svg.qml deleted file mode 100644 index cec0f75061..0000000000 --- a/tests/auto/qtquick2/qdeclarativepath/data/svg.qml +++ /dev/null @@ -1,5 +0,0 @@ -import QtQuick 2.0 - -Path { - PathSvg { path: "M200,300 Q400,50 600,300 T1000,300" } -} diff --git a/tests/auto/qtquick2/qdeclarativepath/qdeclarativepath.pro b/tests/auto/qtquick2/qdeclarativepath/qdeclarativepath.pro deleted file mode 100644 index 1936d53050..0000000000 --- a/tests/auto/qtquick2/qdeclarativepath/qdeclarativepath.pro +++ /dev/null @@ -1,15 +0,0 @@ -CONFIG += testcase -TARGET = tst_qdeclarativepath -macx:CONFIG -= app_bundle - -SOURCES += tst_qdeclarativepath.cpp - -include (../../shared/util.pri) - -testDataFiles.files = data -testDataFiles.path = . -DEPLOYMENT += testDataFiles - -CONFIG += parallel_test - -QT += core-private gui-private v8-private declarative-private quick-private testlib diff --git a/tests/auto/qtquick2/qdeclarativepath/tst_qdeclarativepath.cpp b/tests/auto/qtquick2/qdeclarativepath/tst_qdeclarativepath.cpp deleted file mode 100644 index cdf2566531..0000000000 --- a/tests/auto/qtquick2/qdeclarativepath/tst_qdeclarativepath.cpp +++ /dev/null @@ -1,199 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include -#include -#include -#include - -#include "../../shared/util.h" - -class tst_QDeclarativePath : public QDeclarativeDataTest -{ - Q_OBJECT -public: - tst_QDeclarativePath() {} - -private slots: - void arc(); - void catmullromCurve(); - void closedCatmullromCurve(); - void svg(); -}; - -void tst_QDeclarativePath::arc() -{ - QDeclarativeEngine engine; - QDeclarativeComponent c(&engine, testFileUrl("arc.qml")); - QDeclarativePath *obj = qobject_cast(c.create()); - QVERIFY(obj != 0); - - QCOMPARE(obj->startX(), 0.); - QCOMPARE(obj->startY(), 0.); - - QDeclarativeListReference list(obj, "pathElements"); - QCOMPARE(list.count(), 1); - - QDeclarativePathArc* arc = qobject_cast(list.at(0)); - QVERIFY(arc != 0); - QCOMPARE(arc->x(), 100.); - QCOMPARE(arc->y(), 100.); - QCOMPARE(arc->radiusX(), 100.); - QCOMPARE(arc->radiusY(), 100.); - QCOMPARE(arc->useLargeArc(), false); - QCOMPARE(arc->direction(), QDeclarativePathArc::Clockwise); - - QPainterPath path = obj->path(); - QVERIFY(path != QPainterPath()); - - QPointF pos = obj->pointAt(0); - QCOMPARE(pos, QPointF(0,0)); - pos = obj->pointAt(.25); - QCOMPARE(pos.toPoint(), QPoint(39,8)); //fuzzy compare - pos = obj->pointAt(.75); - QCOMPARE(pos.toPoint(), QPoint(92,61)); //fuzzy compare - pos = obj->pointAt(1); - QCOMPARE(pos, QPointF(100,100)); -} - -void tst_QDeclarativePath::catmullromCurve() -{ - QDeclarativeEngine engine; - QDeclarativeComponent c(&engine, testFileUrl("curve.qml")); - QDeclarativePath *obj = qobject_cast(c.create()); - QVERIFY(obj != 0); - - QCOMPARE(obj->startX(), 0.); - QCOMPARE(obj->startY(), 0.); - - QDeclarativeListReference list(obj, "pathElements"); - QCOMPARE(list.count(), 3); - - QDeclarativePathCatmullRomCurve* curve = qobject_cast(list.at(0)); - QVERIFY(curve != 0); - QCOMPARE(curve->x(), 100.); - QCOMPARE(curve->y(), 50.); - - curve = qobject_cast(list.at(2)); - QVERIFY(curve != 0); - QCOMPARE(curve->x(), 100.); - QCOMPARE(curve->y(), 150.); - - QPainterPath path = obj->path(); - QVERIFY(path != QPainterPath()); - - QPointF pos = obj->pointAt(0); - QCOMPARE(pos, QPointF(0,0)); - pos = obj->pointAt(.25); - QCOMPARE(pos.toPoint(), QPoint(63,26)); //fuzzy compare - pos = obj->pointAt(.75); - QCOMPARE(pos.toPoint(), QPoint(51,105)); //fuzzy compare - pos = obj->pointAt(1); - QCOMPARE(pos, QPointF(100,150)); -} - -void tst_QDeclarativePath::closedCatmullromCurve() -{ - QDeclarativeEngine engine; - QDeclarativeComponent c(&engine, testFileUrl("closedcurve.qml")); - QDeclarativePath *obj = qobject_cast(c.create()); - QVERIFY(obj != 0); - - QCOMPARE(obj->startX(), 50.); - QCOMPARE(obj->startY(), 50.); - - QDeclarativeListReference list(obj, "pathElements"); - QCOMPARE(list.count(), 3); - - QDeclarativePathCatmullRomCurve* curve = qobject_cast(list.at(2)); - QVERIFY(curve != 0); - QCOMPARE(curve->x(), 50.); - QCOMPARE(curve->y(), 50.); - - QVERIFY(obj->isClosed()); - - QPainterPath path = obj->path(); - QVERIFY(path != QPainterPath()); - - QPointF pos = obj->pointAt(0); - QCOMPARE(pos, QPointF(50,50)); - pos = obj->pointAt(.1); - QCOMPARE(pos.toPoint(), QPoint(67,56)); //fuzzy compare - pos = obj->pointAt(.75); - QCOMPARE(pos.toPoint(), QPoint(44,116)); //fuzzy compare - pos = obj->pointAt(1); - QCOMPARE(pos, QPointF(50,50)); -} - -void tst_QDeclarativePath::svg() -{ - QDeclarativeEngine engine; - QDeclarativeComponent c(&engine, testFileUrl("svg.qml")); - QDeclarativePath *obj = qobject_cast(c.create()); - QVERIFY(obj != 0); - - QCOMPARE(obj->startX(), 0.); - QCOMPARE(obj->startY(), 0.); - - QDeclarativeListReference list(obj, "pathElements"); - QCOMPARE(list.count(), 1); - - QDeclarativePathSvg* svg = qobject_cast(list.at(0)); - QVERIFY(svg != 0); - QCOMPARE(svg->path(), QLatin1String("M200,300 Q400,50 600,300 T1000,300")); - - QPainterPath path = obj->path(); - QVERIFY(path != QPainterPath()); - - QPointF pos = obj->pointAt(0); - QCOMPARE(pos, QPointF(200,300)); - pos = obj->pointAt(.25); - QCOMPARE(pos.toPoint(), QPoint(400,175)); //fuzzy compare - pos = obj->pointAt(.75); - QCOMPARE(pos.toPoint(), QPoint(800,425)); //fuzzy compare - pos = obj->pointAt(1); - QCOMPARE(pos, QPointF(1000,300)); -} - - -QTEST_MAIN(tst_QDeclarativePath) - -#include "tst_qdeclarativepath.moc" diff --git a/tests/auto/qtquick2/qdeclarativepixmapcache/data/exists.png b/tests/auto/qtquick2/qdeclarativepixmapcache/data/exists.png deleted file mode 100644 index 399bd0b1d9..0000000000 Binary files a/tests/auto/qtquick2/qdeclarativepixmapcache/data/exists.png and /dev/null differ diff --git a/tests/auto/qtquick2/qdeclarativepixmapcache/data/exists1.png b/tests/auto/qtquick2/qdeclarativepixmapcache/data/exists1.png deleted file mode 100644 index 399bd0b1d9..0000000000 Binary files a/tests/auto/qtquick2/qdeclarativepixmapcache/data/exists1.png and /dev/null differ diff --git a/tests/auto/qtquick2/qdeclarativepixmapcache/data/exists2.png b/tests/auto/qtquick2/qdeclarativepixmapcache/data/exists2.png deleted file mode 100644 index 399bd0b1d9..0000000000 Binary files a/tests/auto/qtquick2/qdeclarativepixmapcache/data/exists2.png and /dev/null differ diff --git a/tests/auto/qtquick2/qdeclarativepixmapcache/data/http/exists.png b/tests/auto/qtquick2/qdeclarativepixmapcache/data/http/exists.png deleted file mode 100644 index 399bd0b1d9..0000000000 Binary files a/tests/auto/qtquick2/qdeclarativepixmapcache/data/http/exists.png and /dev/null differ diff --git a/tests/auto/qtquick2/qdeclarativepixmapcache/data/http/exists1.png b/tests/auto/qtquick2/qdeclarativepixmapcache/data/http/exists1.png deleted file mode 100644 index 399bd0b1d9..0000000000 Binary files a/tests/auto/qtquick2/qdeclarativepixmapcache/data/http/exists1.png and /dev/null differ diff --git a/tests/auto/qtquick2/qdeclarativepixmapcache/data/http/exists2.png b/tests/auto/qtquick2/qdeclarativepixmapcache/data/http/exists2.png deleted file mode 100644 index 399bd0b1d9..0000000000 Binary files a/tests/auto/qtquick2/qdeclarativepixmapcache/data/http/exists2.png and /dev/null differ diff --git a/tests/auto/qtquick2/qdeclarativepixmapcache/data/http/exists3.png b/tests/auto/qtquick2/qdeclarativepixmapcache/data/http/exists3.png deleted file mode 100644 index 399bd0b1d9..0000000000 Binary files a/tests/auto/qtquick2/qdeclarativepixmapcache/data/http/exists3.png and /dev/null differ diff --git a/tests/auto/qtquick2/qdeclarativepixmapcache/data/http/exists4.png b/tests/auto/qtquick2/qdeclarativepixmapcache/data/http/exists4.png deleted file mode 100644 index 399bd0b1d9..0000000000 Binary files a/tests/auto/qtquick2/qdeclarativepixmapcache/data/http/exists4.png and /dev/null differ diff --git a/tests/auto/qtquick2/qdeclarativepixmapcache/data/http/exists5.png b/tests/auto/qtquick2/qdeclarativepixmapcache/data/http/exists5.png deleted file mode 100644 index 399bd0b1d9..0000000000 Binary files a/tests/auto/qtquick2/qdeclarativepixmapcache/data/http/exists5.png and /dev/null differ diff --git a/tests/auto/qtquick2/qdeclarativepixmapcache/data/http/exists6.png b/tests/auto/qtquick2/qdeclarativepixmapcache/data/http/exists6.png deleted file mode 100644 index 399bd0b1d9..0000000000 Binary files a/tests/auto/qtquick2/qdeclarativepixmapcache/data/http/exists6.png and /dev/null differ diff --git a/tests/auto/qtquick2/qdeclarativepixmapcache/data/http/exists7.png b/tests/auto/qtquick2/qdeclarativepixmapcache/data/http/exists7.png deleted file mode 100644 index 399bd0b1d9..0000000000 Binary files a/tests/auto/qtquick2/qdeclarativepixmapcache/data/http/exists7.png and /dev/null differ diff --git a/tests/auto/qtquick2/qdeclarativepixmapcache/data/http/exists8.png b/tests/auto/qtquick2/qdeclarativepixmapcache/data/http/exists8.png deleted file mode 100644 index 399bd0b1d9..0000000000 Binary files a/tests/auto/qtquick2/qdeclarativepixmapcache/data/http/exists8.png and /dev/null differ diff --git a/tests/auto/qtquick2/qdeclarativepixmapcache/data/massive.png b/tests/auto/qtquick2/qdeclarativepixmapcache/data/massive.png deleted file mode 100644 index bc6cc9e6ca..0000000000 Binary files a/tests/auto/qtquick2/qdeclarativepixmapcache/data/massive.png and /dev/null differ diff --git a/tests/auto/qtquick2/qdeclarativepixmapcache/qdeclarativepixmapcache.pro b/tests/auto/qtquick2/qdeclarativepixmapcache/qdeclarativepixmapcache.pro deleted file mode 100644 index 006489cce7..0000000000 --- a/tests/auto/qtquick2/qdeclarativepixmapcache/qdeclarativepixmapcache.pro +++ /dev/null @@ -1,21 +0,0 @@ -CONFIG += testcase -TARGET = tst_qdeclarativepixmapcache -macx:CONFIG -= app_bundle - -SOURCES += tst_qdeclarativepixmapcache.cpp \ - ../../shared/testhttpserver.cpp -HEADERS += ../../shared/testhttpserver.h -INCLUDEPATH += ../../shared/ - -include (../../shared/util.pri) - -importFiles.files = data -importFiles.path = . -DEPLOYMENT += importFiles - -# QMAKE_CXXFLAGS = -fprofile-arcs -ftest-coverage -# LIBS += -lgcov - -CONFIG += parallel_test - -QT += core-private gui-private declarative-private quick-private network testlib concurrent diff --git a/tests/auto/qtquick2/qdeclarativepixmapcache/tst_qdeclarativepixmapcache.cpp b/tests/auto/qtquick2/qdeclarativepixmapcache/tst_qdeclarativepixmapcache.cpp deleted file mode 100644 index 84ea9ec3a9..0000000000 --- a/tests/auto/qtquick2/qdeclarativepixmapcache/tst_qdeclarativepixmapcache.cpp +++ /dev/null @@ -1,467 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include -#include -#include -#include -#include -#include -#include "../../shared/util.h" -#include "testhttpserver.h" - -#ifndef QT_NO_CONCURRENT -#include -#include -#endif - -#define PIXMAP_DATA_LEAK_TEST 0 - -class tst_qdeclarativepixmapcache : public QDeclarativeDataTest -{ - Q_OBJECT -public: - tst_qdeclarativepixmapcache() : server(14452) {} - -private slots: - void initTestCase(); - void single(); - void single_data(); - void parallel(); - void parallel_data(); - void massive(); - void cancelcrash(); - void shrinkcache(); -#ifndef QT_NO_CONCURRENT - void networkCrash(); -#endif - void lockingCrash(); -#if PIXMAP_DATA_LEAK_TEST - void dataLeak(); -#endif -private: - QDeclarativeEngine engine; - TestHTTPServer server; -}; - -static int slotters=0; - -class Slotter : public QObject -{ - Q_OBJECT -public: - Slotter() - { - gotslot = false; - slotters++; - } - bool gotslot; - -public slots: - void got() - { - gotslot = true; - --slotters; - if (slotters==0) - QTestEventLoop::instance().exitLoop(); - } -}; - -#ifndef QT_NO_LOCALFILE_OPTIMIZED_QML -static const bool localfile_optimized = true; -#else -static const bool localfile_optimized = false; -#endif - - -void tst_qdeclarativepixmapcache::initTestCase() -{ - QDeclarativeDataTest::initTestCase(); - server.serveDirectory(testFile("http")); -} - -void tst_qdeclarativepixmapcache::single_data() -{ - // Note, since QDeclarativePixmapCache is shared, tests affect each other! - // so use different files fore all test functions. - - QTest::addColumn("target"); - QTest::addColumn("incache"); - QTest::addColumn("exists"); - QTest::addColumn("neterror"); - - // File URLs are optimized - QTest::newRow("local") << testFileUrl("exists.png") << localfile_optimized << true << false; - QTest::newRow("local") << testFileUrl("notexists.png") << localfile_optimized << false << false; - QTest::newRow("remote") << QUrl("http://127.0.0.1:14452/exists.png") << false << true << false; - QTest::newRow("remote") << QUrl("http://127.0.0.1:14452/notexists.png") << false << false << true; -} - -void tst_qdeclarativepixmapcache::single() -{ - QFETCH(QUrl, target); - QFETCH(bool, incache); - QFETCH(bool, exists); - QFETCH(bool, neterror); - - QString expectedError; - if (neterror) { - expectedError = "Error downloading " + target.toString() + " - server replied: Not found"; - } else if (!exists) { - expectedError = "Cannot open: " + target.toString(); - } - - QDeclarativePixmap pixmap; - QVERIFY(pixmap.width() <= 0); // Check Qt assumption - - pixmap.load(&engine, target); - - if (incache) { - QCOMPARE(pixmap.error(), expectedError); - if (exists) { - QVERIFY(pixmap.status() == QDeclarativePixmap::Ready); - QVERIFY(pixmap.width() > 0); - } else { - QVERIFY(pixmap.status() == QDeclarativePixmap::Error); - QVERIFY(pixmap.width() <= 0); - } - } else { - QVERIFY(pixmap.width() <= 0); - - Slotter getter; - pixmap.connectFinished(&getter, SLOT(got())); - QTestEventLoop::instance().enterLoop(10); - QVERIFY(!QTestEventLoop::instance().timeout()); - QVERIFY(getter.gotslot); - if (exists) { - QVERIFY(pixmap.status() == QDeclarativePixmap::Ready); - QVERIFY(pixmap.width() > 0); - } else { - QVERIFY(pixmap.status() == QDeclarativePixmap::Error); - QVERIFY(pixmap.width() <= 0); - } - QCOMPARE(pixmap.error(), expectedError); - } -} - -void tst_qdeclarativepixmapcache::parallel_data() -{ - // Note, since QDeclarativePixmapCache is shared, tests affect each other! - // so use different files fore all test functions. - - QTest::addColumn("target1"); - QTest::addColumn("target2"); - QTest::addColumn("incache"); - QTest::addColumn("cancel"); // which one to cancel - - QTest::newRow("local") - << testFileUrl("exists1.png") - << testFileUrl("exists2.png") - << (localfile_optimized ? 2 : 0) - << -1; - - QTest::newRow("remote") - << QUrl("http://127.0.0.1:14452/exists2.png") - << QUrl("http://127.0.0.1:14452/exists3.png") - << 0 - << -1; - - QTest::newRow("remoteagain") - << QUrl("http://127.0.0.1:14452/exists2.png") - << QUrl("http://127.0.0.1:14452/exists3.png") - << 2 - << -1; - - QTest::newRow("remotecopy") - << QUrl("http://127.0.0.1:14452/exists4.png") - << QUrl("http://127.0.0.1:14452/exists4.png") - << 0 - << -1; - - QTest::newRow("remotecopycancel") - << QUrl("http://127.0.0.1:14452/exists5.png") - << QUrl("http://127.0.0.1:14452/exists5.png") - << 0 - << 0; -} - -void tst_qdeclarativepixmapcache::parallel() -{ - QFETCH(QUrl, target1); - QFETCH(QUrl, target2); - QFETCH(int, incache); - QFETCH(int, cancel); - - QList targets; - targets << target1 << target2; - - QList pixmaps; - QList pending; - QList getters; - - for (int i=0; iload(&engine, target); - - QVERIFY(pixmap->status() != QDeclarativePixmap::Error); - pixmaps.append(pixmap); - if (pixmap->isReady()) { - QVERIFY(pixmap->width() > 0); - getters.append(0); - pending.append(false); - } else { - QVERIFY(pixmap->width() <= 0); - getters.append(new Slotter); - pixmap->connectFinished(getters[i], SLOT(got())); - pending.append(true); - } - } - - QCOMPARE(incache+slotters, targets.count()); - - if (cancel >= 0) { - pixmaps.at(cancel)->clear(getters[cancel]); - slotters--; - } - - if (slotters) { - QTestEventLoop::instance().enterLoop(10); - QVERIFY(!QTestEventLoop::instance().timeout()); - } - - for (int i=0; igotslot); - } else { - if (pending[i]) - QVERIFY(getters[i]->gotslot); - - QVERIFY(pixmap->isReady()); - QVERIFY(pixmap->width() > 0); - delete getters[i]; - } - } - - qDeleteAll(pixmaps); -} - -void tst_qdeclarativepixmapcache::massive() -{ - QDeclarativeEngine engine; - QUrl url = testFileUrl("massive.png"); - - // Confirm that massive images remain in the cache while they are - // in use by the application. - { - qint64 cachekey = 0; - QDeclarativePixmap p(&engine, url); - QVERIFY(p.isReady()); - QVERIFY(p.image().size() == QSize(10000, 1000)); - cachekey = p.image().cacheKey(); - - QDeclarativePixmap p2(&engine, url); - QVERIFY(p2.isReady()); - QVERIFY(p2.image().size() == QSize(10000, 1000)); - - QVERIFY(p2.image().cacheKey() == cachekey); - } - - // Confirm that massive images are removed from the cache when - // they become unused - { - qint64 cachekey = 0; - { - QDeclarativePixmap p(&engine, url); - QVERIFY(p.isReady()); - QVERIFY(p.image().size() == QSize(10000, 1000)); - cachekey = p.image().cacheKey(); - } - - QDeclarativePixmap p2(&engine, url); - QVERIFY(p2.isReady()); - QVERIFY(p2.image().size() == QSize(10000, 1000)); - - QVERIFY(p2.image().cacheKey() != cachekey); - } -} - -// QTBUG-12729 -void tst_qdeclarativepixmapcache::cancelcrash() -{ - QUrl url("http://127.0.0.1:14452/cancelcrash_notexist.png"); - for (int ii = 0; ii < 1000; ++ii) { - QDeclarativePixmap pix(&engine, url); - } -} - -class MyPixmapProvider : public QDeclarativeImageProvider -{ -public: - MyPixmapProvider() - : QDeclarativeImageProvider(Pixmap) {} - - virtual QPixmap requestPixmap(const QString &d, QSize *, const QSize &) { - Q_UNUSED(d) - QPixmap pix(800, 600); - pix.fill(Qt::red); - return pix; - } -}; - -// QTBUG-13345 -void tst_qdeclarativepixmapcache::shrinkcache() -{ - QDeclarativeEngine engine; - engine.addImageProvider(QLatin1String("mypixmaps"), new MyPixmapProvider); - - for (int ii = 0; ii < 4000; ++ii) { - QUrl url("image://mypixmaps/" + QString::number(ii)); - QDeclarativePixmap p(&engine, url); - } -} - -#ifndef QT_NO_CONCURRENT - -void createNetworkServer() -{ - QEventLoop eventLoop; - TestHTTPServer server(14453); - server.serveDirectory(QDeclarativeDataTest::instance()->testFile("http")); - QTimer::singleShot(100, &eventLoop, SLOT(quit())); - eventLoop.exec(); -} - -#ifndef QT_NO_CONCURRENT -// QT-3957 -void tst_qdeclarativepixmapcache::networkCrash() -{ - QFuture future = QtConcurrent::run(createNetworkServer); - QDeclarativeEngine engine; - for (int ii = 0; ii < 100 ; ++ii) { - QDeclarativePixmap* pixmap = new QDeclarativePixmap; - pixmap->load(&engine, QUrl(QString("http://127.0.0.1:14453/exists.png"))); - QTest::qSleep(1); - pixmap->clear(); - delete pixmap; - } - future.cancel(); -} -#endif - -#endif - -// QTBUG-22125 -void tst_qdeclarativepixmapcache::lockingCrash() -{ - TestHTTPServer server(14453); - server.serveDirectory(testFile("http"), TestHTTPServer::Delay); - - { - QDeclarativePixmap* p = new QDeclarativePixmap; - { - QDeclarativeEngine e; - p->load(&e, QUrl(QString("http://127.0.0.1:14453/exists6.png"))); - } - p->clear(); - QVERIFY(p->isNull()); - delete p; - } -} - - -#if PIXMAP_DATA_LEAK_TEST -// This test should not be enabled by default as it -// produces spurious output in the expected case. -#include -class DataLeakView : public QQuickView -{ - Q_OBJECT - -public: - explicit DataLeakView() : QQuickView() - { - setSource(testFileUrl("dataLeak.qml")); - } - - void showFor2Seconds() - { - showFullScreen(); - QTimer::singleShot(2000, this, SIGNAL(ready())); - } - -signals: - void ready(); -}; - -// QTBUG-22742 -Q_GLOBAL_STATIC(QDeclarativePixmap, dataLeakPixmap) -void tst_qdeclarativepixmapcache::dataLeak() -{ - // Should not leak cached QDeclarativePixmapData. - // Unfortunately, since the QDeclarativePixmapStore - // is a global static, and it releases the cache - // entries on dtor (application exit), we must use - // valgrind to determine whether it leaks or not. - QDeclarativePixmap *p1 = new QDeclarativePixmap; - QDeclarativePixmap *p2 = new QDeclarativePixmap; - { - QScopedPointer test(new DataLeakView); - test->showFor2Seconds(); - dataLeakPixmap()->load(test->engine(), testFileUrl("exists.png")); - p1->load(test->engine(), testFileUrl("exists.png")); - p2->load(test->engine(), testFileUrl("exists2.png")); - QTest::qWait(2005); // 2 seconds + a few more millis. - } - - // When the (global static) dataLeakPixmap is deleted, it - // shouldn't attempt to dereference a QDeclarativePixmapData - // which has been deleted by the QDeclarativePixmapStore - // destructor. -} -#endif -#undef PIXMAP_DATA_LEAK_TEST - -QTEST_MAIN(tst_qdeclarativepixmapcache) - -#include "tst_qdeclarativepixmapcache.moc" diff --git a/tests/auto/qtquick2/qdeclarativesmoothedanimation/data/deleteOnUpdate.qml b/tests/auto/qtquick2/qdeclarativesmoothedanimation/data/deleteOnUpdate.qml deleted file mode 100644 index ff8dfaa846..0000000000 --- a/tests/auto/qtquick2/qdeclarativesmoothedanimation/data/deleteOnUpdate.qml +++ /dev/null @@ -1,27 +0,0 @@ -import QtQuick 2.0 - -Rectangle { - width: 300; height: 300; - - Rectangle { - color: "red" - width: 60; height: 60; - x: 100; y: 100; - - property real prevX: 100 - onXChanged: { - if (x - prevX > 10) { - anim.to += 5 - anim.restart(); //this can cause deletion of backend animation classes - prevX = x; - } - } - - SmoothedAnimation on x { - id: anim - objectName: "anim" - velocity: 100 - to: 150 - } - } -} diff --git a/tests/auto/qtquick2/qdeclarativesmoothedanimation/data/simpleanimation.qml b/tests/auto/qtquick2/qdeclarativesmoothedanimation/data/simpleanimation.qml deleted file mode 100644 index b2be63ec94..0000000000 --- a/tests/auto/qtquick2/qdeclarativesmoothedanimation/data/simpleanimation.qml +++ /dev/null @@ -1,12 +0,0 @@ -import QtQuick 2.0 - -Rectangle { - width: 300; height: 300; - Rectangle { - objectName: "rect" - color: "red" - width: 60; height: 60; - x: 100; y: 100; - } - SmoothedAnimation { objectName: "anim"} -} \ No newline at end of file diff --git a/tests/auto/qtquick2/qdeclarativesmoothedanimation/data/smoothedanimation1.qml b/tests/auto/qtquick2/qdeclarativesmoothedanimation/data/smoothedanimation1.qml deleted file mode 100644 index 3631f971f0..0000000000 --- a/tests/auto/qtquick2/qdeclarativesmoothedanimation/data/smoothedanimation1.qml +++ /dev/null @@ -1,3 +0,0 @@ -import QtQuick 2.0 - -SmoothedAnimation {} diff --git a/tests/auto/qtquick2/qdeclarativesmoothedanimation/data/smoothedanimation2.qml b/tests/auto/qtquick2/qdeclarativesmoothedanimation/data/smoothedanimation2.qml deleted file mode 100644 index b07120234a..0000000000 --- a/tests/auto/qtquick2/qdeclarativesmoothedanimation/data/smoothedanimation2.qml +++ /dev/null @@ -1,5 +0,0 @@ -import QtQuick 2.0 - -SmoothedAnimation { - to: 10; duration: 300; reversingMode: SmoothedAnimation.Immediate -} diff --git a/tests/auto/qtquick2/qdeclarativesmoothedanimation/data/smoothedanimation3.qml b/tests/auto/qtquick2/qdeclarativesmoothedanimation/data/smoothedanimation3.qml deleted file mode 100644 index 8d5dc4a92b..0000000000 --- a/tests/auto/qtquick2/qdeclarativesmoothedanimation/data/smoothedanimation3.qml +++ /dev/null @@ -1,6 +0,0 @@ -import QtQuick 2.0 - -SmoothedAnimation { - to: 10; velocity: 250; reversingMode: SmoothedAnimation.Sync - maximumEasingTime: 150 -} diff --git a/tests/auto/qtquick2/qdeclarativesmoothedanimation/data/smoothedanimationBehavior.qml b/tests/auto/qtquick2/qdeclarativesmoothedanimation/data/smoothedanimationBehavior.qml deleted file mode 100644 index 81d36bf015..0000000000 --- a/tests/auto/qtquick2/qdeclarativesmoothedanimation/data/smoothedanimationBehavior.qml +++ /dev/null @@ -1,24 +0,0 @@ -import QtQuick 2.0 - -Rectangle { - width: 400; height: 400; color: "blue" - - Rectangle { - id: rect1 - color: "red" - width: 60; height: 60; - x: 100; y: 100; - SmoothedAnimation on x { to: 200; velocity: 500 } - SmoothedAnimation on y { to: 200; velocity: 500 } - } - - Rectangle { - objectName: "theRect" - color: "green" - width: 60; height: 60; - x: rect1.x; y: rect1.y; - // id are needed for SmoothedAnimation in order to avoid deferred creation - Behavior on x { SmoothedAnimation { id: anim1; objectName: "easeX"; velocity: 400 } } - Behavior on y { SmoothedAnimation { id: anim2; objectName: "easeY"; velocity: 400 } } - } - } diff --git a/tests/auto/qtquick2/qdeclarativesmoothedanimation/data/smoothedanimationValueSource.qml b/tests/auto/qtquick2/qdeclarativesmoothedanimation/data/smoothedanimationValueSource.qml deleted file mode 100644 index e136df84f6..0000000000 --- a/tests/auto/qtquick2/qdeclarativesmoothedanimation/data/smoothedanimationValueSource.qml +++ /dev/null @@ -1,13 +0,0 @@ -import QtQuick 2.0 - -Rectangle { - width: 300; height: 300; - Rectangle { - objectName: "theRect" - color: "red" - width: 60; height: 60; - x: 100; y: 100; - SmoothedAnimation on x { objectName: "easeX"; to: 200; velocity: 500 } - SmoothedAnimation on y { objectName: "easeY"; to: 200; duration: 250; velocity: 500 } - } -} diff --git a/tests/auto/qtquick2/qdeclarativesmoothedanimation/qdeclarativesmoothedanimation.pro b/tests/auto/qtquick2/qdeclarativesmoothedanimation/qdeclarativesmoothedanimation.pro deleted file mode 100644 index 41650c523f..0000000000 --- a/tests/auto/qtquick2/qdeclarativesmoothedanimation/qdeclarativesmoothedanimation.pro +++ /dev/null @@ -1,15 +0,0 @@ -CONFIG += testcase -TARGET = tst_qdeclarativesmoothedanimation -macx:CONFIG -= app_bundle - -SOURCES += tst_qdeclarativesmoothedanimation.cpp - -include (../../shared/util.pri) - -testDataFiles.files = data -testDataFiles.path = . -DEPLOYMENT += testDataFiles - -CONFIG += parallel_test - -QT += core-private gui-private v8-private declarative-private quick-private testlib diff --git a/tests/auto/qtquick2/qdeclarativesmoothedanimation/tst_qdeclarativesmoothedanimation.cpp b/tests/auto/qtquick2/qdeclarativesmoothedanimation/tst_qdeclarativesmoothedanimation.cpp deleted file mode 100644 index 09bde4ad76..0000000000 --- a/tests/auto/qtquick2/qdeclarativesmoothedanimation/tst_qdeclarativesmoothedanimation.cpp +++ /dev/null @@ -1,242 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include -#include -#include -#include -#include -#include -#include "../../shared/util.h" - -class tst_qdeclarativesmoothedanimation : public QDeclarativeDataTest -{ - Q_OBJECT -public: - tst_qdeclarativesmoothedanimation(); - -private slots: - void defaultValues(); - void values(); - void disabled(); - void simpleAnimation(); - void valueSource(); - void behavior(); - void deleteOnUpdate(); - -private: - QDeclarativeEngine engine; -}; - -tst_qdeclarativesmoothedanimation::tst_qdeclarativesmoothedanimation() -{ -} - -void tst_qdeclarativesmoothedanimation::defaultValues() -{ - QDeclarativeEngine engine; - QDeclarativeComponent c(&engine, testFileUrl("smoothedanimation1.qml")); - QDeclarativeSmoothedAnimation *obj = qobject_cast(c.create()); - - QVERIFY(obj != 0); - - QCOMPARE(obj->to(), 0.); - QCOMPARE(obj->velocity(), 200.); - QCOMPARE(obj->duration(), -1); - QCOMPARE(obj->maximumEasingTime(), -1); - QCOMPARE(obj->reversingMode(), QDeclarativeSmoothedAnimation::Eased); - - delete obj; -} - -void tst_qdeclarativesmoothedanimation::values() -{ - QDeclarativeEngine engine; - QDeclarativeComponent c(&engine, testFileUrl("smoothedanimation2.qml")); - QDeclarativeSmoothedAnimation *obj = qobject_cast(c.create()); - - QVERIFY(obj != 0); - - QCOMPARE(obj->to(), 10.); - QCOMPARE(obj->velocity(), 200.); - QCOMPARE(obj->duration(), 300); - QCOMPARE(obj->maximumEasingTime(), -1); - QCOMPARE(obj->reversingMode(), QDeclarativeSmoothedAnimation::Immediate); - - delete obj; -} - -void tst_qdeclarativesmoothedanimation::disabled() -{ - QDeclarativeEngine engine; - QDeclarativeComponent c(&engine, testFileUrl("smoothedanimation3.qml")); - QDeclarativeSmoothedAnimation *obj = qobject_cast(c.create()); - - QVERIFY(obj != 0); - - QCOMPARE(obj->to(), 10.); - QCOMPARE(obj->velocity(), 250.); - QCOMPARE(obj->maximumEasingTime(), 150); - QCOMPARE(obj->reversingMode(), QDeclarativeSmoothedAnimation::Sync); - - delete obj; -} - -void tst_qdeclarativesmoothedanimation::simpleAnimation() -{ - QDeclarativeEngine engine; - QDeclarativeComponent c(&engine, testFileUrl("simpleanimation.qml")); - QObject *obj = c.create(); - QVERIFY(obj); - - QQuickRectangle *rect = obj->findChild("rect"); - QVERIFY(rect); - - QDeclarativeSmoothedAnimation *animation = obj->findChild("anim"); - QVERIFY(animation); - - animation->setTargetObject(rect); - animation->setProperty("x"); - animation->setTo(200); - animation->setDuration(250); - QVERIFY(animation->target() == rect); - QVERIFY(animation->property() == "x"); - QVERIFY(animation->to() == 200); - animation->start(); - QVERIFY(animation->isRunning()); - QTest::qWait(animation->duration()); - QTRY_COMPARE(rect->x(), qreal(200)); - QTest::qWait(100); //smoothed animation doesn't report stopped until delayed timer fires - - QVERIFY(!animation->isRunning()); - rect->setX(0); - animation->start(); - QVERIFY(animation->isRunning()); - animation->pause(); - QVERIFY(animation->isRunning()); - QVERIFY(animation->isPaused()); - animation->setCurrentTime(125); - QVERIFY(animation->currentTime() == 125); - QCOMPARE(rect->x(), qreal(100)); -} - -void tst_qdeclarativesmoothedanimation::valueSource() -{ - QDeclarativeEngine engine; - - QDeclarativeComponent c(&engine, testFileUrl("smoothedanimationValueSource.qml")); - - QQuickRectangle *rect = qobject_cast(c.create()); - QVERIFY(rect); - - QQuickRectangle *theRect = rect->findChild("theRect"); - QVERIFY(theRect); - - QDeclarativeSmoothedAnimation *easeX = rect->findChild("easeX"); - QVERIFY(easeX); - QVERIFY(easeX->isRunning()); - - QDeclarativeSmoothedAnimation *easeY = rect->findChild("easeY"); - QVERIFY(easeY); - QVERIFY(easeY->isRunning()); - - // XXX get the proper duration - QTest::qWait(100); - - QTRY_VERIFY(!easeX->isRunning()); - QTRY_VERIFY(!easeY->isRunning()); - - QTRY_COMPARE(theRect->x(), qreal(200)); - QTRY_COMPARE(theRect->y(), qreal(200)); - - delete rect; -} - -void tst_qdeclarativesmoothedanimation::behavior() -{ - QDeclarativeEngine engine; - - QDeclarativeComponent c(&engine, testFileUrl("smoothedanimationBehavior.qml")); - - QQuickRectangle *rect = qobject_cast(c.create()); - QVERIFY(rect); - - QQuickRectangle *theRect = rect->findChild("theRect"); - QVERIFY(theRect); - - QDeclarativeSmoothedAnimation *easeX = rect->findChild("easeX"); - QVERIFY(easeX); - - QDeclarativeSmoothedAnimation *easeY = rect->findChild("easeY"); - QVERIFY(easeY); - - // XXX get the proper duration - QTest::qWait(400); - - QTRY_VERIFY(!easeX->isRunning()); - QTRY_VERIFY(!easeY->isRunning()); - - QTRY_COMPARE(theRect->x(), qreal(200)); - QTRY_COMPARE(theRect->y(), qreal(200)); - - delete rect; -} - -void tst_qdeclarativesmoothedanimation::deleteOnUpdate() -{ - QDeclarativeEngine engine; - - QDeclarativeComponent c(&engine, testFileUrl("deleteOnUpdate.qml")); - - QQuickRectangle *rect = qobject_cast(c.create()); - QVERIFY(rect); - - QDeclarativeSmoothedAnimation *anim = rect->findChild("anim"); - QVERIFY(anim); - - //don't crash - QTest::qWait(500); - - delete rect; -} - -QTEST_MAIN(tst_qdeclarativesmoothedanimation) - -#include "tst_qdeclarativesmoothedanimation.moc" diff --git a/tests/auto/qtquick2/qdeclarativespringanimation/data/springanimation1.qml b/tests/auto/qtquick2/qdeclarativespringanimation/data/springanimation1.qml deleted file mode 100644 index 9f52aa56c1..0000000000 --- a/tests/auto/qtquick2/qdeclarativespringanimation/data/springanimation1.qml +++ /dev/null @@ -1,4 +0,0 @@ -import QtQuick 2.0 - -SpringAnimation { -} diff --git a/tests/auto/qtquick2/qdeclarativespringanimation/data/springanimation2.qml b/tests/auto/qtquick2/qdeclarativespringanimation/data/springanimation2.qml deleted file mode 100644 index 9f72e51533..0000000000 --- a/tests/auto/qtquick2/qdeclarativespringanimation/data/springanimation2.qml +++ /dev/null @@ -1,16 +0,0 @@ -import QtQuick 2.0 - -Item { - Item { - id: item - } - - SpringAnimation { - target: item; property: "x" - to: 1.44; velocity: 0.9 - spring: 1.0; damping: 0.5 - epsilon: 0.25; modulus: 360.0 - mass: 2.0; - running: true; - } -} diff --git a/tests/auto/qtquick2/qdeclarativespringanimation/data/springanimation3.qml b/tests/auto/qtquick2/qdeclarativespringanimation/data/springanimation3.qml deleted file mode 100644 index f4dc121eb8..0000000000 --- a/tests/auto/qtquick2/qdeclarativespringanimation/data/springanimation3.qml +++ /dev/null @@ -1,8 +0,0 @@ -import QtQuick 2.0 - -SpringAnimation { - to: 1.44; velocity: 0.9 - spring: 1.0; damping: 0.5 - epsilon: 0.25; modulus: 360.0 - mass: 2.0; running: false -} diff --git a/tests/auto/qtquick2/qdeclarativespringanimation/qdeclarativespringanimation.pro b/tests/auto/qtquick2/qdeclarativespringanimation/qdeclarativespringanimation.pro deleted file mode 100644 index d90cf3dca3..0000000000 --- a/tests/auto/qtquick2/qdeclarativespringanimation/qdeclarativespringanimation.pro +++ /dev/null @@ -1,15 +0,0 @@ -CONFIG += testcase -TARGET = tst_qdeclarativespringanimation -macx:CONFIG -= app_bundle - -SOURCES += tst_qdeclarativespringanimation.cpp - -include (../../shared/util.pri) - -testDataFiles.files = data -testDataFiles.path = . -DEPLOYMENT += testDataFiles - -CONFIG += parallel_test - -QT += core-private gui-private v8-private declarative-private quick-private testlib diff --git a/tests/auto/qtquick2/qdeclarativespringanimation/tst_qdeclarativespringanimation.cpp b/tests/auto/qtquick2/qdeclarativespringanimation/tst_qdeclarativespringanimation.cpp deleted file mode 100644 index 64956d7753..0000000000 --- a/tests/auto/qtquick2/qdeclarativespringanimation/tst_qdeclarativespringanimation.cpp +++ /dev/null @@ -1,133 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include -#include -#include -#include -#include -#include "../../shared/util.h" - -class tst_qdeclarativespringanimation : public QDeclarativeDataTest -{ - Q_OBJECT -public: - tst_qdeclarativespringanimation(); - -private slots: - void defaultValues(); - void values(); - void disabled(); - -private: - QDeclarativeEngine engine; -}; - -tst_qdeclarativespringanimation::tst_qdeclarativespringanimation() -{ -} - -void tst_qdeclarativespringanimation::defaultValues() -{ - QDeclarativeEngine engine; - QDeclarativeComponent c(&engine, testFileUrl("springanimation1.qml")); - QDeclarativeSpringAnimation *obj = qobject_cast(c.create()); - - QVERIFY(obj != 0); - - QCOMPARE(obj->to(), 0.); - QCOMPARE(obj->velocity(), 0.); - QCOMPARE(obj->spring(), 0.); - QCOMPARE(obj->damping(), 0.); - QCOMPARE(obj->epsilon(), 0.01); - QCOMPARE(obj->modulus(), 0.); - QCOMPARE(obj->mass(), 1.); - QCOMPARE(obj->isRunning(), false); - - delete obj; -} - -void tst_qdeclarativespringanimation::values() -{ - QDeclarativeEngine engine; - QDeclarativeComponent c(&engine, testFileUrl("springanimation2.qml")); - QObject *root = c.create(); - - QDeclarativeSpringAnimation *obj = root->findChild(); - - QVERIFY(obj != 0); - - QCOMPARE(obj->to(), 1.44); - QCOMPARE(obj->velocity(), 0.9); - QCOMPARE(obj->spring(), 1.0); - QCOMPARE(obj->damping(), 0.5); - QCOMPARE(obj->epsilon(), 0.25); - QCOMPARE(obj->modulus(), 360.0); - QCOMPARE(obj->mass(), 2.0); - QCOMPARE(obj->isRunning(), true); - - QTRY_COMPARE(obj->isRunning(), false); - - delete obj; -} - -void tst_qdeclarativespringanimation::disabled() -{ - QDeclarativeEngine engine; - QDeclarativeComponent c(&engine, testFileUrl("springanimation3.qml")); - QDeclarativeSpringAnimation *obj = qobject_cast(c.create()); - - QVERIFY(obj != 0); - - QCOMPARE(obj->to(), 1.44); - QCOMPARE(obj->velocity(), 0.9); - QCOMPARE(obj->spring(), 1.0); - QCOMPARE(obj->damping(), 0.5); - QCOMPARE(obj->epsilon(), 0.25); - QCOMPARE(obj->modulus(), 360.0); - QCOMPARE(obj->mass(), 2.0); - QCOMPARE(obj->isRunning(), false); - - delete obj; -} - -QTEST_MAIN(tst_qdeclarativespringanimation) - -#include "tst_qdeclarativespringanimation.moc" diff --git a/tests/auto/qtquick2/qdeclarativestates/data/ExtendedRectangle.qml b/tests/auto/qtquick2/qdeclarativestates/data/ExtendedRectangle.qml deleted file mode 100644 index 1ea346b841..0000000000 --- a/tests/auto/qtquick2/qdeclarativestates/data/ExtendedRectangle.qml +++ /dev/null @@ -1,19 +0,0 @@ -import QtQuick 2.0 -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/qtquick2/qdeclarativestates/data/Implementation/MyType.qml b/tests/auto/qtquick2/qdeclarativestates/data/Implementation/MyType.qml deleted file mode 100644 index 01eb32cd4d..0000000000 --- a/tests/auto/qtquick2/qdeclarativestates/data/Implementation/MyType.qml +++ /dev/null @@ -1,32 +0,0 @@ -import QtQuick 2.0 - -Item { - Column { - anchors.centerIn: parent - Image { id: image1; objectName: "image1" } - Image { id: image2; objectName: "image2" } - Image { id: image3; objectName: "image3" } - } - - states: State { - name: "SetImageState" - PropertyChanges { - target: image1 - source: "images/qt-logo.png" - } - PropertyChanges { - target: image2 - source: "images/" + "qt-logo.png" - } - PropertyChanges { - target: image3 - source: "images/" + (true ? "qt-logo.png" : "") - } - } - - MouseArea { - anchors.fill: parent - onClicked: parent.state = "SetImageState" - } - -} diff --git a/tests/auto/qtquick2/qdeclarativestates/data/Implementation/images/qt-logo.png b/tests/auto/qtquick2/qdeclarativestates/data/Implementation/images/qt-logo.png deleted file mode 100644 index 14ddf2a028..0000000000 Binary files a/tests/auto/qtquick2/qdeclarativestates/data/Implementation/images/qt-logo.png and /dev/null differ diff --git a/tests/auto/qtquick2/qdeclarativestates/data/QTBUG-14830.qml b/tests/auto/qtquick2/qdeclarativestates/data/QTBUG-14830.qml deleted file mode 100644 index 5ba7c3ad6f..0000000000 --- a/tests/auto/qtquick2/qdeclarativestates/data/QTBUG-14830.qml +++ /dev/null @@ -1,29 +0,0 @@ -import QtQuick 2.0 - -Rectangle { - width: 1024 - height: 768 - - Item { - id: area - objectName: "area" - property int numx: 6 - property int cellwidth: 1024/numx - - onWidthChanged: { - width = width>1024?1024:width; - } - - state: 'minimal' - states: [ - State { - name: 'minimal' - PropertyChanges { - target: area - width: cellwidth - } - } - ] - - } -} diff --git a/tests/auto/qtquick2/qdeclarativestates/data/anchorChanges1.qml b/tests/auto/qtquick2/qdeclarativestates/data/anchorChanges1.qml deleted file mode 100644 index 378f5390f9..0000000000 --- a/tests/auto/qtquick2/qdeclarativestates/data/anchorChanges1.qml +++ /dev/null @@ -1,23 +0,0 @@ -import QtQuick 2.0 - -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; - anchors.left: undefined - anchors.right: container.right - } - } -} diff --git a/tests/auto/qtquick2/qdeclarativestates/data/anchorChanges2.qml b/tests/auto/qtquick2/qdeclarativestates/data/anchorChanges2.qml deleted file mode 100644 index dc7f8ef0d1..0000000000 --- a/tests/auto/qtquick2/qdeclarativestates/data/anchorChanges2.qml +++ /dev/null @@ -1,21 +0,0 @@ -import QtQuick 2.0 - -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; - anchors.left: undefined - anchors.right: parent.right - } - } -} diff --git a/tests/auto/qtquick2/qdeclarativestates/data/anchorChanges3.qml b/tests/auto/qtquick2/qdeclarativestates/data/anchorChanges3.qml deleted file mode 100644 index af49575854..0000000000 --- a/tests/auto/qtquick2/qdeclarativestates/data/anchorChanges3.qml +++ /dev/null @@ -1,29 +0,0 @@ -import QtQuick 2.0 - -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; - anchors.left: leftGuideline.left - anchors.right: container.right - anchors.top: container.top - anchors.bottom: bottomGuideline.bottom - } - } -} diff --git a/tests/auto/qtquick2/qdeclarativestates/data/anchorChanges4.qml b/tests/auto/qtquick2/qdeclarativestates/data/anchorChanges4.qml deleted file mode 100644 index 28b55818bd..0000000000 --- a/tests/auto/qtquick2/qdeclarativestates/data/anchorChanges4.qml +++ /dev/null @@ -1,22 +0,0 @@ -import QtQuick 2.0 - -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; - anchors.horizontalCenter: bottomGuideline.horizontalCenter - anchors.verticalCenter: leftGuideline.verticalCenter - } - } -} diff --git a/tests/auto/qtquick2/qdeclarativestates/data/anchorChanges5.qml b/tests/auto/qtquick2/qdeclarativestates/data/anchorChanges5.qml deleted file mode 100644 index b1ca968fb9..0000000000 --- a/tests/auto/qtquick2/qdeclarativestates/data/anchorChanges5.qml +++ /dev/null @@ -1,22 +0,0 @@ -import QtQuick 2.0 - -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; - anchors.horizontalCenter: bottomGuideline.horizontalCenter - anchors.baseline: leftGuideline.baseline - } - } -} diff --git a/tests/auto/qtquick2/qdeclarativestates/data/anchorChangesCrash.qml b/tests/auto/qtquick2/qdeclarativestates/data/anchorChangesCrash.qml deleted file mode 100644 index 9af0e4645a..0000000000 --- a/tests/auto/qtquick2/qdeclarativestates/data/anchorChangesCrash.qml +++ /dev/null @@ -1,14 +0,0 @@ -import QtQuick 2.0 - -Rectangle { - id: container - width: 400 - height: 400 - - states: State { - name: "reanchored" - AnchorChanges { - anchors.top: container.top - } - } -} diff --git a/tests/auto/qtquick2/qdeclarativestates/data/anchorRewindBug.qml b/tests/auto/qtquick2/qdeclarativestates/data/anchorRewindBug.qml deleted file mode 100644 index 60c537b1ed..0000000000 --- a/tests/auto/qtquick2/qdeclarativestates/data/anchorRewindBug.qml +++ /dev/null @@ -1,37 +0,0 @@ -import QtQuick 2.0 -Rectangle { - id: container - color: "red" - height: 200 - width: 200 - Column { - id: column - objectName: "column" - anchors.left: container.right - anchors.bottom: container.bottom - - Rectangle { - id: rectangle - color: "blue" - height: 100 - width: 200 - } - Rectangle { - color: "blue" - height: 100 - width: 200 - } - } - states: State { - name: "reanchored" - AnchorChanges { - target: column - anchors.left: undefined - anchors.right: container.right - } - PropertyChanges { - target: rectangle - visible: false - } - } -} diff --git a/tests/auto/qtquick2/qdeclarativestates/data/anchorRewindBug2.qml b/tests/auto/qtquick2/qdeclarativestates/data/anchorRewindBug2.qml deleted file mode 100644 index 574ef473ce..0000000000 --- a/tests/auto/qtquick2/qdeclarativestates/data/anchorRewindBug2.qml +++ /dev/null @@ -1,25 +0,0 @@ -import QtQuick 2.0 - -Rectangle { - id: root - width:200; height:300 - - Rectangle { - id: rectangle - objectName: "mover" - color: "green" - width:50; height:50 - } - - states: [ - State { - name: "anchored" - AnchorChanges { - target: rectangle - anchors.left: root.left - anchors.right: root.right - anchors.bottom: root.bottom - } - } - ] -} diff --git a/tests/auto/qtquick2/qdeclarativestates/data/attachedPropertyChanges.qml b/tests/auto/qtquick2/qdeclarativestates/data/attachedPropertyChanges.qml deleted file mode 100644 index 413af2ee42..0000000000 --- a/tests/auto/qtquick2/qdeclarativestates/data/attachedPropertyChanges.qml +++ /dev/null @@ -1,20 +0,0 @@ -import Qt.test 1.0 -import QtQuick 2.0 - -Item { - id: item - width: 100; height: 100 - MyRectangle.foo: 0 - - states: State { - name: "foo1" - PropertyChanges { - target: item - MyRectangle.foo: 1 - width: 50 - } - } - - Component.onCompleted: item.state = "foo1" -} - diff --git a/tests/auto/qtquick2/qdeclarativestates/data/autoStateAtStartupRestoreBug.qml b/tests/auto/qtquick2/qdeclarativestates/data/autoStateAtStartupRestoreBug.qml deleted file mode 100644 index 6cbf524ec2..0000000000 --- a/tests/auto/qtquick2/qdeclarativestates/data/autoStateAtStartupRestoreBug.qml +++ /dev/null @@ -1,18 +0,0 @@ -import QtQuick 2.0 - -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/qtquick2/qdeclarativestates/data/avoidFastForward.qml b/tests/auto/qtquick2/qdeclarativestates/data/avoidFastForward.qml deleted file mode 100644 index 519befc31e..0000000000 --- a/tests/auto/qtquick2/qdeclarativestates/data/avoidFastForward.qml +++ /dev/null @@ -1,17 +0,0 @@ -import QtQuick 2.0 - -Rectangle { - id: rect - width: 200 - height: 200 - - property int updateCount: 0 - onColorChanged: updateCount++ - - property color aColor: "green" - - states: State { - name: "a" - PropertyChanges { target: rect; color: aColor } - } -} diff --git a/tests/auto/qtquick2/qdeclarativestates/data/basicBinding.qml b/tests/auto/qtquick2/qdeclarativestates/data/basicBinding.qml deleted file mode 100644 index 59b67d0863..0000000000 --- a/tests/auto/qtquick2/qdeclarativestates/data/basicBinding.qml +++ /dev/null @@ -1,12 +0,0 @@ -import QtQuick 2.0 -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/qtquick2/qdeclarativestates/data/basicBinding2.qml b/tests/auto/qtquick2/qdeclarativestates/data/basicBinding2.qml deleted file mode 100644 index 55f88120aa..0000000000 --- a/tests/auto/qtquick2/qdeclarativestates/data/basicBinding2.qml +++ /dev/null @@ -1,12 +0,0 @@ -import QtQuick 2.0 -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/qtquick2/qdeclarativestates/data/basicBinding3.qml b/tests/auto/qtquick2/qdeclarativestates/data/basicBinding3.qml deleted file mode 100644 index 361ab0b091..0000000000 --- a/tests/auto/qtquick2/qdeclarativestates/data/basicBinding3.qml +++ /dev/null @@ -1,13 +0,0 @@ -import QtQuick 2.0 -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/qtquick2/qdeclarativestates/data/basicBinding4.qml b/tests/auto/qtquick2/qdeclarativestates/data/basicBinding4.qml deleted file mode 100644 index b29f0fcf22..0000000000 --- a/tests/auto/qtquick2/qdeclarativestates/data/basicBinding4.qml +++ /dev/null @@ -1,17 +0,0 @@ -import QtQuick 2.0 -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/qtquick2/qdeclarativestates/data/basicChanges.qml b/tests/auto/qtquick2/qdeclarativestates/data/basicChanges.qml deleted file mode 100644 index 3e2b73acde..0000000000 --- a/tests/auto/qtquick2/qdeclarativestates/data/basicChanges.qml +++ /dev/null @@ -1,10 +0,0 @@ -import QtQuick 2.0 -Rectangle { - id: myRectangle - width: 100; height: 100 - color: "red" - states: State { - name: "blue" - PropertyChanges { target: myRectangle; color: "blue" } - } -} diff --git a/tests/auto/qtquick2/qdeclarativestates/data/basicChanges2.qml b/tests/auto/qtquick2/qdeclarativestates/data/basicChanges2.qml deleted file mode 100644 index 5ff46cc60c..0000000000 --- a/tests/auto/qtquick2/qdeclarativestates/data/basicChanges2.qml +++ /dev/null @@ -1,15 +0,0 @@ -import QtQuick 2.0 -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/qtquick2/qdeclarativestates/data/basicChanges3.qml b/tests/auto/qtquick2/qdeclarativestates/data/basicChanges3.qml deleted file mode 100644 index e46e98f75e..0000000000 --- a/tests/auto/qtquick2/qdeclarativestates/data/basicChanges3.qml +++ /dev/null @@ -1,15 +0,0 @@ -import QtQuick 2.0 -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/qtquick2/qdeclarativestates/data/basicChanges4.qml b/tests/auto/qtquick2/qdeclarativestates/data/basicChanges4.qml deleted file mode 100644 index 7da1e0fb2e..0000000000 --- a/tests/auto/qtquick2/qdeclarativestates/data/basicChanges4.qml +++ /dev/null @@ -1,19 +0,0 @@ -import Qt.test 1.0 -import QtQuick 2.0 - -MyRectangle { - id: rect - width: 100; height: 100 - color: "red" - - states: State { - name: "aBlueDay" - PropertyChanges { - target: rect - onPropertyWithNotifyChanged: { rect.color = "blue"; } - } - } - - Component.onCompleted: rect.state = "aBlueDay" -} - diff --git a/tests/auto/qtquick2/qdeclarativestates/data/basicExtension.qml b/tests/auto/qtquick2/qdeclarativestates/data/basicExtension.qml deleted file mode 100644 index 00f5fee287..0000000000 --- a/tests/auto/qtquick2/qdeclarativestates/data/basicExtension.qml +++ /dev/null @@ -1,16 +0,0 @@ -import QtQuick 2.0 -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/qtquick2/qdeclarativestates/data/deleting.qml b/tests/auto/qtquick2/qdeclarativestates/data/deleting.qml deleted file mode 100644 index b8e8d33c17..0000000000 --- a/tests/auto/qtquick2/qdeclarativestates/data/deleting.qml +++ /dev/null @@ -1,11 +0,0 @@ -import QtQuick 2.0 -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/qtquick2/qdeclarativestates/data/deletingState.qml b/tests/auto/qtquick2/qdeclarativestates/data/deletingState.qml deleted file mode 100644 index 68a9c2a24d..0000000000 --- a/tests/auto/qtquick2/qdeclarativestates/data/deletingState.qml +++ /dev/null @@ -1,13 +0,0 @@ -import QtQuick 2.0 -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/qtquick2/qdeclarativestates/data/editProperties.qml b/tests/auto/qtquick2/qdeclarativestates/data/editProperties.qml deleted file mode 100644 index 9bff3657ba..0000000000 --- a/tests/auto/qtquick2/qdeclarativestates/data/editProperties.qml +++ /dev/null @@ -1,34 +0,0 @@ -import QtQuick 2.0 -Rectangle { - id: myRectangle - - property color sourceColor: "blue" - width: 400; height: 400 - color: "red" - - Rectangle { - id: rect2 - objectName: "rect2" - width: parent.width + 2 - height: 200 - color: "yellow" - } - - states: [ - State { - name: "blue" - PropertyChanges { - target: rect2 - width:50 - height: 40 - } - }, - State { - name: "green" - PropertyChanges { - target: rect2 - width: myRectangle.width / 2 - height: myRectangle.width / 4 - } - }] -} diff --git a/tests/auto/qtquick2/qdeclarativestates/data/explicit.qml b/tests/auto/qtquick2/qdeclarativestates/data/explicit.qml deleted file mode 100644 index d09893a1db..0000000000 --- a/tests/auto/qtquick2/qdeclarativestates/data/explicit.qml +++ /dev/null @@ -1,15 +0,0 @@ -import QtQuick 2.0 -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/qtquick2/qdeclarativestates/data/extendsBug.qml b/tests/auto/qtquick2/qdeclarativestates/data/extendsBug.qml deleted file mode 100644 index 573341520d..0000000000 --- a/tests/auto/qtquick2/qdeclarativestates/data/extendsBug.qml +++ /dev/null @@ -1,26 +0,0 @@ -import QtQuick 2.0 - -Rectangle { - width: 200 - height: 200 - - Rectangle { - id: rect - objectName: "greenRect" - width: 100 - height: 100 - color: "green" - } - - states:[ - State { - name: "a" - PropertyChanges { target: rect; x: 100 } - }, - State { - name: "b" - extend:"a" - PropertyChanges { target: rect; y: 100 } - } - ] -} diff --git a/tests/auto/qtquick2/qdeclarativestates/data/fakeExtension.qml b/tests/auto/qtquick2/qdeclarativestates/data/fakeExtension.qml deleted file mode 100644 index 6a5c7003f6..0000000000 --- a/tests/auto/qtquick2/qdeclarativestates/data/fakeExtension.qml +++ /dev/null @@ -1,16 +0,0 @@ -import QtQuick 2.0 -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/qtquick2/qdeclarativestates/data/illegalObj.qml b/tests/auto/qtquick2/qdeclarativestates/data/illegalObj.qml deleted file mode 100644 index a2bbd5d32b..0000000000 --- a/tests/auto/qtquick2/qdeclarativestates/data/illegalObj.qml +++ /dev/null @@ -1,12 +0,0 @@ -import QtQuick 2.0 - -Rectangle { - id: myItem - - states : State { - PropertyChanges { - target: myItem - children: Item { id: newItem } - } - } -} diff --git a/tests/auto/qtquick2/qdeclarativestates/data/illegalTempState.qml b/tests/auto/qtquick2/qdeclarativestates/data/illegalTempState.qml deleted file mode 100644 index 9cb39c0728..0000000000 --- a/tests/auto/qtquick2/qdeclarativestates/data/illegalTempState.qml +++ /dev/null @@ -1,21 +0,0 @@ -import QtQuick 2.0 - -Rectangle { - id: card - width: 100; height: 100 - - states: [ - State { - name: "placed" - PropertyChanges { target: card; state: "idle" } - }, - State { - name: "idle" - } - ] - - MouseArea { - anchors.fill: parent - onClicked: card.state = "placed" - } -} diff --git a/tests/auto/qtquick2/qdeclarativestates/data/image.png b/tests/auto/qtquick2/qdeclarativestates/data/image.png deleted file mode 100644 index ed1833c95b..0000000000 Binary files a/tests/auto/qtquick2/qdeclarativestates/data/image.png and /dev/null differ diff --git a/tests/auto/qtquick2/qdeclarativestates/data/legalTempState.qml b/tests/auto/qtquick2/qdeclarativestates/data/legalTempState.qml deleted file mode 100644 index a93860f5cc..0000000000 --- a/tests/auto/qtquick2/qdeclarativestates/data/legalTempState.qml +++ /dev/null @@ -1,23 +0,0 @@ -import QtQuick 2.0 - -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") } - } - ] - - MouseArea { - anchors.fill: parent - onClicked: card.state = "placed" - } -} diff --git a/tests/auto/qtquick2/qdeclarativestates/data/nonExistantProp.qml b/tests/auto/qtquick2/qdeclarativestates/data/nonExistantProp.qml deleted file mode 100644 index ce502699bb..0000000000 --- a/tests/auto/qtquick2/qdeclarativestates/data/nonExistantProp.qml +++ /dev/null @@ -1,11 +0,0 @@ -import QtQuick 2.0 -Rectangle { - id: myRectangle - - width: 100; height: 100 - color: "red" - states: State { - name: "blue" - PropertyChanges { target: myRectangle; colr: "blue" } - } -} diff --git a/tests/auto/qtquick2/qdeclarativestates/data/parentChange1.qml b/tests/auto/qtquick2/qdeclarativestates/data/parentChange1.qml deleted file mode 100644 index 663ad1a264..0000000000 --- a/tests/auto/qtquick2/qdeclarativestates/data/parentChange1.qml +++ /dev/null @@ -1,37 +0,0 @@ -import QtQuick 2.0 - -Rectangle { - width: 400; height: 400 - Item { - x: 10; y: 10 - Rectangle { - id: myRect - objectName: "MyRect" - x: 5 - width: 100; height: 100 - color: "red" - } - } - MouseArea { - 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/qtquick2/qdeclarativestates/data/parentChange2.qml b/tests/auto/qtquick2/qdeclarativestates/data/parentChange2.qml deleted file mode 100644 index ae290e961e..0000000000 --- a/tests/auto/qtquick2/qdeclarativestates/data/parentChange2.qml +++ /dev/null @@ -1,31 +0,0 @@ -import QtQuick 2.0 - -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" - } - } - MouseArea { - id: clickable - anchors.fill: parent - } - - states: State { - name: "reparented" - when: clickable.pressed - ParentChange { - target: myRect - parent: newParent - } - } -} diff --git a/tests/auto/qtquick2/qdeclarativestates/data/parentChange3.qml b/tests/auto/qtquick2/qdeclarativestates/data/parentChange3.qml deleted file mode 100644 index 46665cb4c8..0000000000 --- a/tests/auto/qtquick2/qdeclarativestates/data/parentChange3.qml +++ /dev/null @@ -1,42 +0,0 @@ -import QtQuick 2.0 - -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" - } - } - MouseArea { - 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/qtquick2/qdeclarativestates/data/parentChange4.qml b/tests/auto/qtquick2/qdeclarativestates/data/parentChange4.qml deleted file mode 100644 index 22de72f8c9..0000000000 --- a/tests/auto/qtquick2/qdeclarativestates/data/parentChange4.qml +++ /dev/null @@ -1,30 +0,0 @@ -import QtQuick 2.0 - -Rectangle { - width: 400; height: 400 - Rectangle { - id: myRect - objectName: "MyRect" - x: 5; y: 5 - width: 100; height: 100 - color: "red" - } - MouseArea { - id: clickable - anchors.fill: parent - } - - Item { - id: newParent - transform: Scale { xScale: .5; yScale: .7} - } - - states: State { - name: "reparented" - when: clickable.pressed - ParentChange { - target: myRect - parent: newParent - } - } -} diff --git a/tests/auto/qtquick2/qdeclarativestates/data/parentChange5.qml b/tests/auto/qtquick2/qdeclarativestates/data/parentChange5.qml deleted file mode 100644 index c353d2637f..0000000000 --- a/tests/auto/qtquick2/qdeclarativestates/data/parentChange5.qml +++ /dev/null @@ -1,30 +0,0 @@ -import QtQuick 2.0 - -Rectangle { - width: 400; height: 400 - Rectangle { - id: myRect - objectName: "MyRect" - x: 5; y: 5 - width: 100; height: 100 - color: "red" - } - MouseArea { - id: clickable - anchors.fill: parent - } - - Item { - id: newParent - 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/qtquick2/qdeclarativestates/data/parentChange6.qml b/tests/auto/qtquick2/qdeclarativestates/data/parentChange6.qml deleted file mode 100644 index b373dbba20..0000000000 --- a/tests/auto/qtquick2/qdeclarativestates/data/parentChange6.qml +++ /dev/null @@ -1,30 +0,0 @@ -import QtQuick 2.0 - -Rectangle { - width: 400; height: 400 - Rectangle { - id: myRect - objectName: "MyRect" - x: 5; y: 5 - width: 100; height: 100 - color: "red" - } - MouseArea { - id: clickable - anchors.fill: parent - } - - Item { - id: newParent - rotation: 180 - } - - states: State { - name: "reparented" - when: clickable.pressed - ParentChange { - target: myRect - parent: newParent - } - } -} diff --git a/tests/auto/qtquick2/qdeclarativestates/data/propertyErrors.qml b/tests/auto/qtquick2/qdeclarativestates/data/propertyErrors.qml deleted file mode 100644 index ddd636493d..0000000000 --- a/tests/auto/qtquick2/qdeclarativestates/data/propertyErrors.qml +++ /dev/null @@ -1,10 +0,0 @@ -import QtQuick 2.0 -Rectangle { - id: myRectangle - width: 100; height: 100 - color: "red" - states: State { - name: "blue" - PropertyChanges { target: myRectangle; colr: "blue"; activeFocus: true } - } -} diff --git a/tests/auto/qtquick2/qdeclarativestates/data/reset.qml b/tests/auto/qtquick2/qdeclarativestates/data/reset.qml deleted file mode 100644 index f0ecab0950..0000000000 --- a/tests/auto/qtquick2/qdeclarativestates/data/reset.qml +++ /dev/null @@ -1,19 +0,0 @@ -import QtQuick 2.0 - -Rectangle { - width: 640 - height: 480 - Image { - id: image - width: 40 - source: "image.png" - } - - states: State { - name: "state1" - PropertyChanges { - target: image - width: undefined - } - } -} diff --git a/tests/auto/qtquick2/qdeclarativestates/data/restoreEntryValues.qml b/tests/auto/qtquick2/qdeclarativestates/data/restoreEntryValues.qml deleted file mode 100644 index 950a522841..0000000000 --- a/tests/auto/qtquick2/qdeclarativestates/data/restoreEntryValues.qml +++ /dev/null @@ -1,14 +0,0 @@ -import QtQuick 2.0 -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/qtquick2/qdeclarativestates/data/returnToBase.qml b/tests/auto/qtquick2/qdeclarativestates/data/returnToBase.qml deleted file mode 100644 index 9a0ee82397..0000000000 --- a/tests/auto/qtquick2/qdeclarativestates/data/returnToBase.qml +++ /dev/null @@ -1,21 +0,0 @@ -import QtQuick 2.0 - -Rectangle { - id: theRect - property bool triggerState: false - property string stateString: "" - states: [ State { - when: triggerState - PropertyChanges { - target: theRect - stateString: "inState" - } - }, - State { - name: "" - PropertyChanges { - target: theRect - stateString: "originalState" - } - }] -} diff --git a/tests/auto/qtquick2/qdeclarativestates/data/revertListBug.qml b/tests/auto/qtquick2/qdeclarativestates/data/revertListBug.qml deleted file mode 100644 index fbc4bc5ecc..0000000000 --- a/tests/auto/qtquick2/qdeclarativestates/data/revertListBug.qml +++ /dev/null @@ -1,47 +0,0 @@ -import QtQuick 2.0 - -Rectangle { - width: 400; height: 400 - - property Item targetItem: rect1 - - function switchTargetItem() { - if (targetItem === rect1) - targetItem = rect2; - else - targetItem = rect1; - } - - states: State { - name: "reparented" - ParentChange { - target: targetItem - parent: newParent - x: 0; y: 0 - } - } - - Item { - objectName: "originalParent1" - Rectangle { - id: rect1; objectName: "rect1" - width: 50; height: 50 - color: "green" - } - } - - Item { - objectName: "originalParent2" - Rectangle { - id: rect2; objectName: "rect2" - x: 50; y: 50 - width: 50; height: 50 - color: "green" - } - } - - Item { - id: newParent; objectName: "newParent" - x: 200; y: 100 - } -} diff --git a/tests/auto/qtquick2/qdeclarativestates/data/script.qml b/tests/auto/qtquick2/qdeclarativestates/data/script.qml deleted file mode 100644 index 218f0fae74..0000000000 --- a/tests/auto/qtquick2/qdeclarativestates/data/script.qml +++ /dev/null @@ -1,10 +0,0 @@ -import QtQuick 2.0 -Rectangle { - id: myRectangle - width: 100; height: 100 - color: "red" - states: State { - name: "blue" - StateChangeScript { script: myRectangle.color = "blue"; } - } -} diff --git a/tests/auto/qtquick2/qdeclarativestates/data/signalOverride.qml b/tests/auto/qtquick2/qdeclarativestates/data/signalOverride.qml deleted file mode 100644 index 9ab8037e51..0000000000 --- a/tests/auto/qtquick2/qdeclarativestates/data/signalOverride.qml +++ /dev/null @@ -1,18 +0,0 @@ -import QtQuick 2.0 -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/qtquick2/qdeclarativestates/data/signalOverride2.qml b/tests/auto/qtquick2/qdeclarativestates/data/signalOverride2.qml deleted file mode 100644 index 4e5e335b8b..0000000000 --- a/tests/auto/qtquick2/qdeclarativestates/data/signalOverride2.qml +++ /dev/null @@ -1,9 +0,0 @@ -import QtQuick 2.0 -import Qt.test 1.0 - -MyRectangle { - id: rect - onDidSomething: color = "blue" - width: 100; height: 100 - ExtendedRectangle {} -} diff --git a/tests/auto/qtquick2/qdeclarativestates/data/signalOverrideCrash.qml b/tests/auto/qtquick2/qdeclarativestates/data/signalOverrideCrash.qml deleted file mode 100644 index 3e2ae1e93d..0000000000 --- a/tests/auto/qtquick2/qdeclarativestates/data/signalOverrideCrash.qml +++ /dev/null @@ -1,15 +0,0 @@ -import QtQuick 2.0 -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/qtquick2/qdeclarativestates/data/signalOverrideCrash2.qml b/tests/auto/qtquick2/qdeclarativestates/data/signalOverrideCrash2.qml deleted file mode 100644 index 3937874aa2..0000000000 --- a/tests/auto/qtquick2/qdeclarativestates/data/signalOverrideCrash2.qml +++ /dev/null @@ -1,24 +0,0 @@ -import QtQuick 2.0 - -Rectangle { - id: myRect - width: 400 - height: 400 - - states: [ - State { - name: "state1" - PropertyChanges { - target: myRect - onHeightChanged: console.log("Hello World") - color: "green" - } - }, - State { - name: "state2"; extend: "state1" - PropertyChanges { - target: myRect - color: "red" - } - }] -} diff --git a/tests/auto/qtquick2/qdeclarativestates/data/signalOverrideCrash3.qml b/tests/auto/qtquick2/qdeclarativestates/data/signalOverrideCrash3.qml deleted file mode 100644 index 98d4c57219..0000000000 --- a/tests/auto/qtquick2/qdeclarativestates/data/signalOverrideCrash3.qml +++ /dev/null @@ -1,27 +0,0 @@ -import QtQuick 2.0 - -Rectangle { - id: myRect - width: 400 - height: 400 - - onHeightChanged: console.log("base state") - - states: [ - State { - name: "state1" - PropertyChanges { - target: myRect - onHeightChanged: console.log("state1") - color: "green" - } - }, - State { - name: "state2"; - PropertyChanges { - target: myRect - onHeightChanged: console.log("state2") - color: "red" - } - }] -} diff --git a/tests/auto/qtquick2/qdeclarativestates/data/unnamedWhen.qml b/tests/auto/qtquick2/qdeclarativestates/data/unnamedWhen.qml deleted file mode 100644 index 35eacff07b..0000000000 --- a/tests/auto/qtquick2/qdeclarativestates/data/unnamedWhen.qml +++ /dev/null @@ -1,14 +0,0 @@ -import QtQuick 2.0 - -Rectangle { - id: theRect - property bool triggerState: false - property string stateString: "" - states: State { - when: triggerState - PropertyChanges { - target: theRect - stateString: "inState" - } - } -} diff --git a/tests/auto/qtquick2/qdeclarativestates/data/urlResolution.qml b/tests/auto/qtquick2/qdeclarativestates/data/urlResolution.qml deleted file mode 100644 index 516ac034d6..0000000000 --- a/tests/auto/qtquick2/qdeclarativestates/data/urlResolution.qml +++ /dev/null @@ -1,12 +0,0 @@ -import QtQuick 2.0 -import "Implementation" - -Rectangle { - width: 100 - height: 200 - - MyType { - objectName: "MyType" - anchors.fill: parent - } -} diff --git a/tests/auto/qtquick2/qdeclarativestates/data/whenOrdering.qml b/tests/auto/qtquick2/qdeclarativestates/data/whenOrdering.qml deleted file mode 100644 index 92025a2054..0000000000 --- a/tests/auto/qtquick2/qdeclarativestates/data/whenOrdering.qml +++ /dev/null @@ -1,11 +0,0 @@ -import QtQuick 2.0 - -Rectangle { - property bool condition1: false - property bool condition2: false - - states: [ - State { name: "state1"; when: condition1 }, - State { name: "state2"; when: condition2 } - ] -} diff --git a/tests/auto/qtquick2/qdeclarativestates/qdeclarativestates.pro b/tests/auto/qtquick2/qdeclarativestates/qdeclarativestates.pro deleted file mode 100644 index 74f5bef417..0000000000 --- a/tests/auto/qtquick2/qdeclarativestates/qdeclarativestates.pro +++ /dev/null @@ -1,14 +0,0 @@ -CONFIG += testcase -TARGET = tst_qdeclarativestates -macx:CONFIG -= app_bundle - -SOURCES += tst_qdeclarativestates.cpp - -include (../../shared/util.pri) - -testDataFiles.files = data -testDataFiles.path = . -DEPLOYMENT += testDataFiles - -CONFIG += parallel_test -QT += core-private gui-private v8-private declarative-private quick-private opengl-private testlib diff --git a/tests/auto/qtquick2/qdeclarativestates/tst_qdeclarativestates.cpp b/tests/auto/qtquick2/qdeclarativestates/tst_qdeclarativestates.cpp deleted file mode 100644 index 391a4f7cfe..0000000000 --- a/tests/auto/qtquick2/qdeclarativestates/tst_qdeclarativestates.cpp +++ /dev/null @@ -1,1608 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "../../shared/util.h" - -class MyAttached : public QObject -{ - Q_OBJECT - Q_PROPERTY(int foo READ foo WRITE setFoo) -public: - MyAttached(QObject *parent) : QObject(parent), m_foo(13) {} - - int foo() const { return m_foo; } - void setFoo(int f) { m_foo = f; } - -private: - int m_foo; -}; - -class MyRect : public QQuickRectangle -{ - Q_OBJECT - Q_PROPERTY(int propertyWithNotify READ propertyWithNotify WRITE setPropertyWithNotify NOTIFY oddlyNamedNotifySignal) -public: - MyRect() {} - - void doSomething() { emit didSomething(); } - - int propertyWithNotify() const { return m_prop; } - void setPropertyWithNotify(int i) { m_prop = i; emit oddlyNamedNotifySignal(); } - - static MyAttached *qmlAttachedProperties(QObject *o) { - return new MyAttached(o); - } -Q_SIGNALS: - void didSomething(); - void oddlyNamedNotifySignal(); - -private: - int m_prop; -}; - -QML_DECLARE_TYPE(MyRect) -QML_DECLARE_TYPEINFO(MyRect, QML_HAS_ATTACHED_PROPERTIES) - -class tst_qdeclarativestates : public QDeclarativeDataTest -{ - Q_OBJECT -public: - tst_qdeclarativestates() {} - -private: - QByteArray fullDataPath(const QString &path) const; - -private slots: - void initTestCase(); - - void basicChanges(); - void attachedPropertyChanges(); - void basicExtension(); - void basicBinding(); - void signalOverride(); - void signalOverrideCrash(); - void signalOverrideCrash2(); - void signalOverrideCrash3(); - void parentChange(); - void parentChangeErrors(); - void anchorChanges(); - void anchorChanges2(); - void anchorChanges3(); - void anchorChanges4(); - void anchorChanges5(); - void anchorChangesRTL(); - void anchorChangesRTL2(); - void anchorChangesRTL3(); - void anchorChangesCrash(); - void anchorRewindBug(); - void anchorRewindBug2(); - void script(); - void restoreEntryValues(); - void explicitChanges(); - void propertyErrors(); - void incorrectRestoreBug(); - void autoStateAtStartupRestoreBug(); - void deletingChange(); - void deletingState(); - void tempState(); - void illegalTempState(); - void nonExistantProperty(); - void reset(); - void illegalObjectCreation(); - void whenOrdering(); - void urlResolution(); - void unnamedWhen(); - void returnToBase(); - void extendsBug(); - void editProperties(); - void QTBUG_14830(); - void avoidFastForward(); - void revertListBug(); -}; - -void tst_qdeclarativestates::initTestCase() -{ - QDeclarativeDataTest::initTestCase(); - qmlRegisterType("Qt.test", 1, 0, "MyRectangle"); -} - -QByteArray tst_qdeclarativestates::fullDataPath(const QString &path) const -{ - return testFileUrl(path).toString().toUtf8(); -} - -void tst_qdeclarativestates::basicChanges() -{ - QDeclarativeEngine engine; - - { - QDeclarativeComponent rectComponent(&engine, testFileUrl("basicChanges.qml")); - QQuickRectangle *rect = qobject_cast(rectComponent.create()); - QQuickItemPrivate *rectPrivate = QQuickItemPrivate::get(rect); - QVERIFY(rect != 0); - - QCOMPARE(rect->color(),QColor("red")); - - rectPrivate->setState("blue"); - QCOMPARE(rect->color(),QColor("blue")); - - rectPrivate->setState(""); - QCOMPARE(rect->color(),QColor("red")); - } - - { - QDeclarativeComponent rectComponent(&engine, testFileUrl("basicChanges2.qml")); - QQuickRectangle *rect = qobject_cast(rectComponent.create()); - QQuickItemPrivate *rectPrivate = QQuickItemPrivate::get(rect); - QVERIFY(rect != 0); - - QCOMPARE(rect->color(),QColor("red")); - - rectPrivate->setState("blue"); - QCOMPARE(rect->color(),QColor("blue")); - - rectPrivate->setState("green"); - QCOMPARE(rect->color(),QColor("green")); - - rectPrivate->setState(""); - QCOMPARE(rect->color(),QColor("red")); - - rectPrivate->setState("green"); - QCOMPARE(rect->color(),QColor("green")); - } - - { - QDeclarativeComponent rectComponent(&engine, testFileUrl("basicChanges3.qml")); - QQuickRectangle *rect = qobject_cast(rectComponent.create()); - QQuickItemPrivate *rectPrivate = QQuickItemPrivate::get(rect); - QVERIFY(rect != 0); - - QCOMPARE(rect->color(),QColor("red")); - QCOMPARE(rect->border()->width(),1.0); - - rectPrivate->setState("blue"); - QCOMPARE(rect->color(),QColor("blue")); - QCOMPARE(rect->border()->width(),1.0); - - rectPrivate->setState("bordered"); - QCOMPARE(rect->color(),QColor("red")); - QCOMPARE(rect->border()->width(),2.0); - - rectPrivate->setState(""); - QCOMPARE(rect->color(),QColor("red")); - QCOMPARE(rect->border()->width(),1.0); - //### we should be checking that this is an implicit rather than explicit 1 (which currently fails) - - rectPrivate->setState("bordered"); - QCOMPARE(rect->color(),QColor("red")); - QCOMPARE(rect->border()->width(),2.0); - - rectPrivate->setState("blue"); - QCOMPARE(rect->color(),QColor("blue")); - QCOMPARE(rect->border()->width(),1.0); - - } - - { - // Test basicChanges4.qml can magically connect to propertyWithNotify's notify - // signal using 'onPropertyWithNotifyChanged' even though the signal name is - // actually 'oddlyNamedNotifySignal' - - QDeclarativeComponent component(&engine, testFileUrl("basicChanges4.qml")); - QVERIFY(component.isReady()); - - MyRect *rect = qobject_cast(component.create()); - QVERIFY(rect != 0); - - QMetaProperty prop = rect->metaObject()->property(rect->metaObject()->indexOfProperty("propertyWithNotify")); - QVERIFY(prop.hasNotifySignal()); - QString notifySignal = QByteArray(prop.notifySignal().signature()); - QVERIFY(!notifySignal.startsWith("propertyWithNotifyChanged(")); - - QCOMPARE(rect->color(), QColor(Qt::red)); - - rect->setPropertyWithNotify(100); - QCOMPARE(rect->color(), QColor(Qt::blue)); - } -} - -void tst_qdeclarativestates::attachedPropertyChanges() -{ - QDeclarativeEngine engine; - - QDeclarativeComponent component(&engine, testFileUrl("attachedPropertyChanges.qml")); - QVERIFY(component.isReady()); - - QQuickItem *item = qobject_cast(component.create()); - QVERIFY(item != 0); - QCOMPARE(item->width(), 50.0); - - // Ensure attached property has been changed - QObject *attObj = qmlAttachedPropertiesObject(item, false); - QVERIFY(attObj); - - MyAttached *att = qobject_cast(attObj); - QVERIFY(att); - - QCOMPARE(att->foo(), 1); -} - -void tst_qdeclarativestates::basicExtension() -{ - QDeclarativeEngine engine; - - { - QDeclarativeComponent rectComponent(&engine, testFileUrl("basicExtension.qml")); - QQuickRectangle *rect = qobject_cast(rectComponent.create()); - QQuickItemPrivate *rectPrivate = QQuickItemPrivate::get(rect); - QVERIFY(rect != 0); - - QCOMPARE(rect->color(),QColor("red")); - QCOMPARE(rect->border()->width(),1.0); - - rectPrivate->setState("blue"); - QCOMPARE(rect->color(),QColor("blue")); - QCOMPARE(rect->border()->width(),1.0); - - rectPrivate->setState("bordered"); - QCOMPARE(rect->color(),QColor("blue")); - QCOMPARE(rect->border()->width(),2.0); - - rectPrivate->setState("blue"); - QCOMPARE(rect->color(),QColor("blue")); - QCOMPARE(rect->border()->width(),1.0); - - rectPrivate->setState(""); - QCOMPARE(rect->color(),QColor("red")); - QCOMPARE(rect->border()->width(),1.0); - - rectPrivate->setState("bordered"); - QCOMPARE(rect->color(),QColor("blue")); - QCOMPARE(rect->border()->width(),2.0); - - rectPrivate->setState(""); - QCOMPARE(rect->color(),QColor("red")); - QCOMPARE(rect->border()->width(),1.0); - } - - { - QDeclarativeComponent rectComponent(&engine, testFileUrl("fakeExtension.qml")); - QQuickRectangle *rect = qobject_cast(rectComponent.create()); - QQuickItemPrivate *rectPrivate = QQuickItemPrivate::get(rect); - QVERIFY(rect != 0); - - QCOMPARE(rect->color(),QColor("red")); - - rectPrivate->setState("blue"); - QCOMPARE(rect->color(),QColor("blue")); - - rectPrivate->setState("green"); - QCOMPARE(rect->color(),QColor("green")); - - rectPrivate->setState("blue"); - QCOMPARE(rect->color(),QColor("blue")); - - rectPrivate->setState("green"); - QCOMPARE(rect->color(),QColor("green")); - - rectPrivate->setState(""); - QCOMPARE(rect->color(),QColor("red")); - - rectPrivate->setState("green"); - QCOMPARE(rect->color(),QColor("green")); - } -} - -void tst_qdeclarativestates::basicBinding() -{ - QDeclarativeEngine engine; - - { - QDeclarativeComponent rectComponent(&engine, testFileUrl("basicBinding.qml")); - QQuickRectangle *rect = qobject_cast(rectComponent.create()); - QQuickItemPrivate *rectPrivate = QQuickItemPrivate::get(rect); - QVERIFY(rect != 0); - - QCOMPARE(rect->color(),QColor("red")); - - rectPrivate->setState("blue"); - QCOMPARE(rect->color(),QColor("blue")); - - rectPrivate->setState(""); - QCOMPARE(rect->color(),QColor("red")); - - rectPrivate->setState("blue"); - QCOMPARE(rect->color(),QColor("blue")); - rect->setProperty("sourceColor", QColor("green")); - QCOMPARE(rect->color(),QColor("green")); - - rectPrivate->setState(""); - QCOMPARE(rect->color(),QColor("red")); - rect->setProperty("sourceColor", QColor("yellow")); - QCOMPARE(rect->color(),QColor("red")); - - rectPrivate->setState("blue"); - QCOMPARE(rect->color(),QColor("yellow")); - } - - { - QDeclarativeComponent rectComponent(&engine, testFileUrl("basicBinding2.qml")); - QQuickRectangle *rect = qobject_cast(rectComponent.create()); - QQuickItemPrivate *rectPrivate = QQuickItemPrivate::get(rect); - QVERIFY(rect != 0); - - QCOMPARE(rect->color(),QColor("red")); - - rectPrivate->setState("blue"); - QCOMPARE(rect->color(),QColor("blue")); - - rectPrivate->setState(""); - QCOMPARE(rect->color(),QColor("red")); - - rectPrivate->setState("blue"); - QCOMPARE(rect->color(),QColor("blue")); - rect->setProperty("sourceColor", QColor("green")); - QCOMPARE(rect->color(),QColor("blue")); - - rectPrivate->setState(""); - QCOMPARE(rect->color(),QColor("green")); - rect->setProperty("sourceColor", QColor("yellow")); - QCOMPARE(rect->color(),QColor("yellow")); - - rectPrivate->setState("blue"); - QCOMPARE(rect->color(),QColor("blue")); - - rectPrivate->setState(""); - QCOMPARE(rect->color(),QColor("yellow")); - } - - { - QDeclarativeComponent rectComponent(&engine, testFileUrl("basicBinding3.qml")); - QQuickRectangle *rect = qobject_cast(rectComponent.create()); - QQuickItemPrivate *rectPrivate = QQuickItemPrivate::get(rect); - QVERIFY(rect != 0); - - QCOMPARE(rect->color(),QColor("red")); - rect->setProperty("sourceColor", QColor("green")); - QCOMPARE(rect->color(),QColor("green")); - - rectPrivate->setState("blue"); - QCOMPARE(rect->color(),QColor("blue")); - rect->setProperty("sourceColor", QColor("red")); - QCOMPARE(rect->color(),QColor("blue")); - rect->setProperty("sourceColor2", QColor("yellow")); - QCOMPARE(rect->color(),QColor("yellow")); - - rectPrivate->setState(""); - QCOMPARE(rect->color(),QColor("red")); - rect->setProperty("sourceColor2", QColor("green")); - QCOMPARE(rect->color(),QColor("red")); - rect->setProperty("sourceColor", QColor("yellow")); - QCOMPARE(rect->color(),QColor("yellow")); - } - - { - QDeclarativeComponent rectComponent(&engine, testFileUrl("basicBinding4.qml")); - QQuickRectangle *rect = qobject_cast(rectComponent.create()); - QQuickItemPrivate *rectPrivate = QQuickItemPrivate::get(rect); - QVERIFY(rect != 0); - - QCOMPARE(rect->color(),QColor("red")); - - rectPrivate->setState("blue"); - QCOMPARE(rect->color(),QColor("blue")); - rect->setProperty("sourceColor", QColor("yellow")); - QCOMPARE(rect->color(),QColor("yellow")); - - rectPrivate->setState("green"); - QCOMPARE(rect->color(),QColor("green")); - rect->setProperty("sourceColor", QColor("purple")); - QCOMPARE(rect->color(),QColor("green")); - - rectPrivate->setState("blue"); - QCOMPARE(rect->color(),QColor("purple")); - - rectPrivate->setState("green"); - QCOMPARE(rect->color(),QColor("green")); - - rectPrivate->setState(""); - QCOMPARE(rect->color(),QColor("red")); - } -} - -void tst_qdeclarativestates::signalOverride() -{ - QDeclarativeEngine engine; - - { - QDeclarativeComponent rectComponent(&engine, testFileUrl("signalOverride.qml")); - MyRect *rect = qobject_cast(rectComponent.create()); - QVERIFY(rect != 0); - - QCOMPARE(rect->color(),QColor("red")); - rect->doSomething(); - QCOMPARE(rect->color(),QColor("blue")); - - QQuickItemPrivate::get(rect)->setState("green"); - rect->doSomething(); - QCOMPARE(rect->color(),QColor("green")); - } - - { - QDeclarativeComponent rectComponent(&engine, testFileUrl("signalOverride2.qml")); - MyRect *rect = qobject_cast(rectComponent.create()); - QVERIFY(rect != 0); - - QCOMPARE(rect->color(),QColor("white")); - rect->doSomething(); - QCOMPARE(rect->color(),QColor("blue")); - - QQuickRectangle *innerRect = qobject_cast(rect->findChild("extendedRect")); - QQuickItemPrivate::get(innerRect)->setState("green"); - rect->doSomething(); - QCOMPARE(rect->color(),QColor("blue")); - QCOMPARE(innerRect->color(),QColor("green")); - QCOMPARE(innerRect->property("extendedColor").value(),QColor("green")); - } -} - -void tst_qdeclarativestates::signalOverrideCrash() -{ - QDeclarativeEngine engine; - - QDeclarativeComponent rectComponent(&engine, testFileUrl("signalOverrideCrash.qml")); - MyRect *rect = qobject_cast(rectComponent.create()); - QVERIFY(rect != 0); - - QQuickItemPrivate::get(rect)->setState("overridden"); - rect->doSomething(); -} - -void tst_qdeclarativestates::signalOverrideCrash2() -{ - QDeclarativeEngine engine; - - QDeclarativeComponent rectComponent(&engine, testFileUrl("signalOverrideCrash2.qml")); - QQuickRectangle *rect = qobject_cast(rectComponent.create()); - QVERIFY(rect != 0); - - QQuickItemPrivate::get(rect)->setState("state1"); - QQuickItemPrivate::get(rect)->setState("state2"); - QQuickItemPrivate::get(rect)->setState("state1"); - - delete rect; -} - -void tst_qdeclarativestates::signalOverrideCrash3() -{ - QDeclarativeEngine engine; - - QDeclarativeComponent rectComponent(&engine, testFileUrl("signalOverrideCrash3.qml")); - QQuickRectangle *rect = qobject_cast(rectComponent.create()); - QVERIFY(rect != 0); - - QQuickItemPrivate::get(rect)->setState("state1"); - QQuickItemPrivate::get(rect)->setState(""); - QQuickItemPrivate::get(rect)->setState("state2"); - QQuickItemPrivate::get(rect)->setState(""); - - delete rect; -} - -void tst_qdeclarativestates::parentChange() -{ - QDeclarativeEngine engine; - - { - QDeclarativeComponent rectComponent(&engine, testFileUrl("parentChange1.qml")); - QQuickRectangle *rect = qobject_cast(rectComponent.create()); - QVERIFY(rect != 0); - - QQuickRectangle *innerRect = qobject_cast(rect->findChild("MyRect")); - QVERIFY(innerRect != 0); - - QDeclarativeListReference list(rect, "states"); - QDeclarativeState *state = qobject_cast(list.at(0)); - QVERIFY(state != 0); - - qmlExecuteDeferred(state); - QQuickParentChange *pChange = qobject_cast(state->operationAt(0)); - QVERIFY(pChange != 0); - QQuickItem *nParent = qobject_cast(rect->findChild("NewParent")); - QVERIFY(nParent != 0); - - QCOMPARE(pChange->parent(), nParent); - - QQuickItemPrivate::get(rect)->setState("reparented"); - QCOMPARE(innerRect->rotation(), qreal(0)); - QCOMPARE(innerRect->scale(), qreal(1)); - QCOMPARE(innerRect->x(), qreal(-133)); - QCOMPARE(innerRect->y(), qreal(-300)); - } - - { - QDeclarativeComponent rectComponent(&engine, testFileUrl("parentChange2.qml")); - QQuickRectangle *rect = qobject_cast(rectComponent.create()); - QVERIFY(rect != 0); - QQuickItemPrivate *rectPrivate = QQuickItemPrivate::get(rect); - QQuickRectangle *innerRect = qobject_cast(rect->findChild("MyRect")); - QVERIFY(innerRect != 0); - - rectPrivate->setState("reparented"); - QCOMPARE(innerRect->rotation(), qreal(15)); - QCOMPARE(innerRect->scale(), qreal(.5)); - QCOMPARE(QString("%1").arg(innerRect->x()), QString("%1").arg(-19.9075)); - QCOMPARE(QString("%1").arg(innerRect->y()), QString("%1").arg(-8.73433)); - } - - { - QDeclarativeComponent rectComponent(&engine, testFileUrl("parentChange3.qml")); - QQuickRectangle *rect = qobject_cast(rectComponent.create()); - QVERIFY(rect != 0); - QQuickItemPrivate *rectPrivate = QQuickItemPrivate::get(rect); - QQuickRectangle *innerRect = qobject_cast(rect->findChild("MyRect")); - QVERIFY(innerRect != 0); - - rectPrivate->setState("reparented"); - QCOMPARE(innerRect->rotation(), qreal(-37)); - QCOMPARE(innerRect->scale(), qreal(.25)); - QCOMPARE(QString("%1").arg(innerRect->x()), QString("%1").arg(-217.305)); - QCOMPARE(QString("%1").arg(innerRect->y()), QString("%1").arg(-164.413)); - - rectPrivate->setState(""); - QCOMPARE(innerRect->rotation(), qreal(0)); - QCOMPARE(innerRect->scale(), qreal(1)); - QCOMPARE(innerRect->x(), qreal(5)); - //do a non-qFuzzyCompare fuzzy compare - QVERIFY(innerRect->y() < qreal(0.00001) && innerRect->y() > qreal(-0.00001)); - } - - { - QDeclarativeComponent rectComponent(&engine, testFileUrl("parentChange6.qml")); - QQuickRectangle *rect = qobject_cast(rectComponent.create()); - QVERIFY(rect != 0); - - QQuickRectangle *innerRect = qobject_cast(rect->findChild("MyRect")); - QVERIFY(innerRect != 0); - - QQuickItemPrivate::get(rect)->setState("reparented"); - QCOMPARE(innerRect->rotation(), qreal(180)); - QCOMPARE(innerRect->scale(), qreal(1)); - QCOMPARE(innerRect->x(), qreal(-105)); - QCOMPARE(innerRect->y(), qreal(-105)); - } -} - -void tst_qdeclarativestates::parentChangeErrors() -{ - QDeclarativeEngine engine; - - { - QDeclarativeComponent rectComponent(&engine, testFileUrl("parentChange4.qml")); - QQuickRectangle *rect = qobject_cast(rectComponent.create()); - QVERIFY(rect != 0); - - QQuickRectangle *innerRect = qobject_cast(rect->findChild("MyRect")); - QVERIFY(innerRect != 0); - - QTest::ignoreMessage(QtWarningMsg, fullDataPath("parentChange4.qml") + ":25:9: QML ParentChange: Unable to preserve appearance under non-uniform scale"); - QQuickItemPrivate::get(rect)->setState("reparented"); - QCOMPARE(innerRect->rotation(), qreal(0)); - QCOMPARE(innerRect->scale(), qreal(1)); - QCOMPARE(innerRect->x(), qreal(5)); - QCOMPARE(innerRect->y(), qreal(5)); - } - - { - QDeclarativeComponent rectComponent(&engine, testFileUrl("parentChange5.qml")); - QQuickRectangle *rect = qobject_cast(rectComponent.create()); - QVERIFY(rect != 0); - - QQuickRectangle *innerRect = qobject_cast(rect->findChild("MyRect")); - QVERIFY(innerRect != 0); - - QTest::ignoreMessage(QtWarningMsg, fullDataPath("parentChange5.qml") + ":25:9: QML ParentChange: Unable to preserve appearance under complex transform"); - QQuickItemPrivate::get(rect)->setState("reparented"); - QCOMPARE(innerRect->rotation(), qreal(0)); - QCOMPARE(innerRect->scale(), qreal(1)); - QCOMPARE(innerRect->x(), qreal(5)); - QCOMPARE(innerRect->y(), qreal(5)); - } -} - -void tst_qdeclarativestates::anchorChanges() -{ - QDeclarativeEngine engine; - - QDeclarativeComponent rectComponent(&engine, testFileUrl("anchorChanges1.qml")); - QQuickRectangle *rect = qobject_cast(rectComponent.create()); - QVERIFY(rect != 0); - QQuickItemPrivate *rectPrivate = QQuickItemPrivate::get(rect); - - QQuickRectangle *innerRect = qobject_cast(rect->findChild("MyRect")); - QVERIFY(innerRect != 0); - - QDeclarativeListReference list(rect, "states"); - QDeclarativeState *state = qobject_cast(list.at(0)); - QVERIFY(state != 0); - - qmlExecuteDeferred(state); - QQuickAnchorChanges *aChanges = qobject_cast(state->operationAt(0)); - QVERIFY(aChanges != 0); - - QCOMPARE(aChanges->anchors()->left().script(), QLatin1String("undefined")); - QCOMPARE(aChanges->anchors()->right().script(), QLatin1String("container.right")); - - rectPrivate->setState("right"); - QCOMPARE(innerRect->x(), qreal(150)); - QCOMPARE(aChanges->object(), qobject_cast(innerRect)); - QCOMPARE(QQuickItemPrivate::get(aChanges->object())->anchors()->left().anchorLine, QQuickAnchorLine::Invalid); //### was reset (how do we distinguish from not set at all) - QCOMPARE(QQuickItemPrivate::get(aChanges->object())->anchors()->right().item, rectPrivate->right().item); - QCOMPARE(QQuickItemPrivate::get(aChanges->object())->anchors()->right().anchorLine, rectPrivate->right().anchorLine); - - rectPrivate->setState(""); - QCOMPARE(innerRect->x(), qreal(5)); - - delete rect; -} - -void tst_qdeclarativestates::anchorChanges2() -{ - QDeclarativeEngine engine; - - QDeclarativeComponent rectComponent(&engine, testFileUrl("anchorChanges2.qml")); - QQuickRectangle *rect = qobject_cast(rectComponent.create()); - QVERIFY(rect != 0); - QQuickItemPrivate *rectPrivate = QQuickItemPrivate::get(rect); - - QQuickRectangle *innerRect = qobject_cast(rect->findChild("MyRect")); - QVERIFY(innerRect != 0); - - rectPrivate->setState("right"); - QCOMPARE(innerRect->x(), qreal(150)); - - rectPrivate->setState(""); - QCOMPARE(innerRect->x(), qreal(5)); - - delete rect; -} - -void tst_qdeclarativestates::anchorChanges3() -{ - QDeclarativeEngine engine; - - QDeclarativeComponent rectComponent(&engine, testFileUrl("anchorChanges3.qml")); - QQuickRectangle *rect = qobject_cast(rectComponent.create()); - QVERIFY(rect != 0); - QQuickItemPrivate *rectPrivate = QQuickItemPrivate::get(rect); - - QQuickRectangle *innerRect = qobject_cast(rect->findChild("MyRect")); - QVERIFY(innerRect != 0); - - QQuickItem *leftGuideline = qobject_cast(rect->findChild("LeftGuideline")); - QVERIFY(leftGuideline != 0); - - QQuickItem *bottomGuideline = qobject_cast(rect->findChild("BottomGuideline")); - QVERIFY(bottomGuideline != 0); - - QDeclarativeListReference list(rect, "states"); - QDeclarativeState *state = qobject_cast(list.at(0)); - QVERIFY(state != 0); - - qmlExecuteDeferred(state); - QQuickAnchorChanges *aChanges = qobject_cast(state->operationAt(0)); - QVERIFY(aChanges != 0); - - QCOMPARE(aChanges->anchors()->top().script(), QLatin1String("container.top")); - QCOMPARE(aChanges->anchors()->bottom().script(), QLatin1String("bottomGuideline.bottom")); - - rectPrivate->setState("reanchored"); - QCOMPARE(aChanges->object(), qobject_cast(innerRect)); - QCOMPARE(QQuickItemPrivate::get(aChanges->object())->anchors()->left().item, QQuickItemPrivate::get(leftGuideline)->left().item); - QCOMPARE(QQuickItemPrivate::get(aChanges->object())->anchors()->left().anchorLine, QQuickItemPrivate::get(leftGuideline)->left().anchorLine); - QCOMPARE(QQuickItemPrivate::get(aChanges->object())->anchors()->right().item, rectPrivate->right().item); - QCOMPARE(QQuickItemPrivate::get(aChanges->object())->anchors()->right().anchorLine, rectPrivate->right().anchorLine); - QCOMPARE(QQuickItemPrivate::get(aChanges->object())->anchors()->top().item, rectPrivate->top().item); - QCOMPARE(QQuickItemPrivate::get(aChanges->object())->anchors()->top().anchorLine, rectPrivate->top().anchorLine); - QCOMPARE(QQuickItemPrivate::get(aChanges->object())->anchors()->bottom().item, QQuickItemPrivate::get(bottomGuideline)->bottom().item); - QCOMPARE(QQuickItemPrivate::get(aChanges->object())->anchors()->bottom().anchorLine, QQuickItemPrivate::get(bottomGuideline)->bottom().anchorLine); - - QCOMPARE(innerRect->x(), qreal(10)); - QCOMPARE(innerRect->y(), qreal(0)); - QCOMPARE(innerRect->width(), qreal(190)); - QCOMPARE(innerRect->height(), qreal(150)); - - rectPrivate->setState(""); - QCOMPARE(innerRect->x(), qreal(0)); - QCOMPARE(innerRect->y(), qreal(10)); - QCOMPARE(innerRect->width(), qreal(150)); - QCOMPARE(innerRect->height(), qreal(190)); - - delete rect; -} - -void tst_qdeclarativestates::anchorChanges4() -{ - QDeclarativeEngine engine; - - QDeclarativeComponent rectComponent(&engine, testFileUrl("anchorChanges4.qml")); - QQuickRectangle *rect = qobject_cast(rectComponent.create()); - QVERIFY(rect != 0); - - QQuickRectangle *innerRect = qobject_cast(rect->findChild("MyRect")); - QVERIFY(innerRect != 0); - - QQuickItem *leftGuideline = qobject_cast(rect->findChild("LeftGuideline")); - QVERIFY(leftGuideline != 0); - - QQuickItem *bottomGuideline = qobject_cast(rect->findChild("BottomGuideline")); - QVERIFY(bottomGuideline != 0); - - QDeclarativeListReference list(rect, "states"); - QDeclarativeState *state = qobject_cast(list.at(0)); - QVERIFY(state != 0); - - qmlExecuteDeferred(state); - QQuickAnchorChanges *aChanges = qobject_cast(state->operationAt(0)); - QVERIFY(aChanges != 0); - - QCOMPARE(aChanges->anchors()->horizontalCenter().script(), QLatin1String("bottomGuideline.horizontalCenter")); - QCOMPARE(aChanges->anchors()->verticalCenter().script(), QLatin1String("leftGuideline.verticalCenter")); - - QQuickItemPrivate::get(rect)->setState("reanchored"); - QCOMPARE(aChanges->object(), qobject_cast(innerRect)); - QCOMPARE(QQuickItemPrivate::get(aChanges->object())->anchors()->horizontalCenter().item, QQuickItemPrivate::get(bottomGuideline)->horizontalCenter().item); - QCOMPARE(QQuickItemPrivate::get(aChanges->object())->anchors()->horizontalCenter().anchorLine, QQuickItemPrivate::get(bottomGuideline)->horizontalCenter().anchorLine); - QCOMPARE(QQuickItemPrivate::get(aChanges->object())->anchors()->verticalCenter().item, QQuickItemPrivate::get(leftGuideline)->verticalCenter().item); - QCOMPARE(QQuickItemPrivate::get(aChanges->object())->anchors()->verticalCenter().anchorLine, QQuickItemPrivate::get(leftGuideline)->verticalCenter().anchorLine); - - delete rect; -} - -void tst_qdeclarativestates::anchorChanges5() -{ - QDeclarativeEngine engine; - - QDeclarativeComponent rectComponent(&engine, testFileUrl("anchorChanges5.qml")); - QQuickRectangle *rect = qobject_cast(rectComponent.create()); - QVERIFY(rect != 0); - - QQuickRectangle *innerRect = qobject_cast(rect->findChild("MyRect")); - QVERIFY(innerRect != 0); - - QQuickItem *leftGuideline = qobject_cast(rect->findChild("LeftGuideline")); - QVERIFY(leftGuideline != 0); - - QQuickItem *bottomGuideline = qobject_cast(rect->findChild("BottomGuideline")); - QVERIFY(bottomGuideline != 0); - - QDeclarativeListReference list(rect, "states"); - QDeclarativeState *state = qobject_cast(list.at(0)); - QVERIFY(state != 0); - - qmlExecuteDeferred(state); - QQuickAnchorChanges *aChanges = qobject_cast(state->operationAt(0)); - QVERIFY(aChanges != 0); - - QCOMPARE(aChanges->anchors()->baseline().script(), QLatin1String("leftGuideline.baseline")); - - QQuickItemPrivate::get(rect)->setState("reanchored"); - QCOMPARE(aChanges->object(), qobject_cast(innerRect)); - QCOMPARE(QQuickItemPrivate::get(aChanges->object())->anchors()->horizontalCenter().item, QQuickItemPrivate::get(bottomGuideline)->horizontalCenter().item); - QCOMPARE(QQuickItemPrivate::get(aChanges->object())->anchors()->horizontalCenter().anchorLine, QQuickItemPrivate::get(bottomGuideline)->horizontalCenter().anchorLine); - QCOMPARE(QQuickItemPrivate::get(aChanges->object())->anchors()->baseline().item, QQuickItemPrivate::get(leftGuideline)->baseline().item); - QCOMPARE(QQuickItemPrivate::get(aChanges->object())->anchors()->baseline().anchorLine, QQuickItemPrivate::get(leftGuideline)->baseline().anchorLine); - - delete rect; -} - -void mirrorAnchors(QQuickItem *item) { - QQuickItemPrivate *itemPrivate = QQuickItemPrivate::get(item); - itemPrivate->setLayoutMirror(true); -} - -qreal offsetRTL(QQuickItem *anchorItem, QQuickItem *item) { - return anchorItem->width()+2*anchorItem->x()-item->width(); -} - -void tst_qdeclarativestates::anchorChangesRTL() -{ - QDeclarativeEngine engine; - - QDeclarativeComponent rectComponent(&engine, testFileUrl("anchorChanges1.qml")); - QQuickRectangle *rect = qobject_cast(rectComponent.create()); - QVERIFY(rect != 0); - QQuickItemPrivate *rectPrivate = QQuickItemPrivate::get(rect); - - QQuickRectangle *innerRect = qobject_cast(rect->findChild("MyRect")); - QVERIFY(innerRect != 0); - mirrorAnchors(innerRect); - - QDeclarativeListReference list(rect, "states"); - QDeclarativeState *state = qobject_cast(list.at(0)); - QVERIFY(state != 0); - - qmlExecuteDeferred(state); - QQuickAnchorChanges *aChanges = qobject_cast(state->operationAt(0)); - QVERIFY(aChanges != 0); - - rectPrivate->setState("right"); - QCOMPARE(innerRect->x(), offsetRTL(rect, innerRect) - qreal(150)); - QCOMPARE(aChanges->object(), qobject_cast(innerRect)); - QCOMPARE(QQuickItemPrivate::get(aChanges->object())->anchors()->left().anchorLine, QQuickAnchorLine::Invalid); //### was reset (how do we distinguish from not set at all) - QCOMPARE(QQuickItemPrivate::get(aChanges->object())->anchors()->right().item, rectPrivate->right().item); - QCOMPARE(QQuickItemPrivate::get(aChanges->object())->anchors()->right().anchorLine, rectPrivate->right().anchorLine); - - rectPrivate->setState(""); - QCOMPARE(innerRect->x(), offsetRTL(rect, innerRect) -qreal(5)); - - delete rect; -} - -void tst_qdeclarativestates::anchorChangesRTL2() -{ - QDeclarativeEngine engine; - - QDeclarativeComponent rectComponent(&engine, testFileUrl("anchorChanges2.qml")); - QQuickRectangle *rect = qobject_cast(rectComponent.create()); - QVERIFY(rect != 0); - QQuickItemPrivate *rectPrivate = QQuickItemPrivate::get(rect); - - QQuickRectangle *innerRect = qobject_cast(rect->findChild("MyRect")); - QVERIFY(innerRect != 0); - mirrorAnchors(innerRect); - - rectPrivate->setState("right"); - QCOMPARE(innerRect->x(), offsetRTL(rect, innerRect) - qreal(150)); - - rectPrivate->setState(""); - QCOMPARE(innerRect->x(), offsetRTL(rect, innerRect) - qreal(5)); - - delete rect; -} - -void tst_qdeclarativestates::anchorChangesRTL3() -{ - QDeclarativeEngine engine; - - QDeclarativeComponent rectComponent(&engine, testFileUrl("anchorChanges3.qml")); - QQuickRectangle *rect = qobject_cast(rectComponent.create()); - QVERIFY(rect != 0); - QQuickItemPrivate *rectPrivate = QQuickItemPrivate::get(rect); - - QQuickRectangle *innerRect = qobject_cast(rect->findChild("MyRect")); - QVERIFY(innerRect != 0); - mirrorAnchors(innerRect); - - QQuickItem *leftGuideline = qobject_cast(rect->findChild("LeftGuideline")); - QVERIFY(leftGuideline != 0); - - QQuickItem *bottomGuideline = qobject_cast(rect->findChild("BottomGuideline")); - QVERIFY(bottomGuideline != 0); - - QDeclarativeListReference list(rect, "states"); - QDeclarativeState *state = qobject_cast(list.at(0)); - QVERIFY(state != 0); - - qmlExecuteDeferred(state); - QQuickAnchorChanges *aChanges = qobject_cast(state->operationAt(0)); - QVERIFY(aChanges != 0); - - rectPrivate->setState("reanchored"); - QCOMPARE(aChanges->object(), qobject_cast(innerRect)); - QCOMPARE(QQuickItemPrivate::get(aChanges->object())->anchors()->left().item, QQuickItemPrivate::get(leftGuideline)->left().item); - QCOMPARE(QQuickItemPrivate::get(aChanges->object())->anchors()->left().anchorLine, QQuickItemPrivate::get(leftGuideline)->left().anchorLine); - QCOMPARE(QQuickItemPrivate::get(aChanges->object())->anchors()->right().item, rectPrivate->right().item); - QCOMPARE(QQuickItemPrivate::get(aChanges->object())->anchors()->right().anchorLine, rectPrivate->right().anchorLine); - QCOMPARE(QQuickItemPrivate::get(aChanges->object())->anchors()->top().item, rectPrivate->top().item); - QCOMPARE(QQuickItemPrivate::get(aChanges->object())->anchors()->top().anchorLine, rectPrivate->top().anchorLine); - QCOMPARE(QQuickItemPrivate::get(aChanges->object())->anchors()->bottom().item, QQuickItemPrivate::get(bottomGuideline)->bottom().item); - QCOMPARE(QQuickItemPrivate::get(aChanges->object())->anchors()->bottom().anchorLine, QQuickItemPrivate::get(bottomGuideline)->bottom().anchorLine); - - QCOMPARE(innerRect->x(), offsetRTL(leftGuideline, innerRect) - qreal(10)); - QCOMPARE(innerRect->y(), qreal(0)); - // between left side of parent and leftGuideline.x: 10, which has width 0 - QCOMPARE(innerRect->width(), qreal(10)); - QCOMPARE(innerRect->height(), qreal(150)); - - rectPrivate->setState(""); - QCOMPARE(innerRect->x(), offsetRTL(rect, innerRect) - qreal(0)); - QCOMPARE(innerRect->y(), qreal(10)); - // between right side of parent and left side of rightGuideline.x: 150, which has width 0 - QCOMPARE(innerRect->width(), qreal(50)); - QCOMPARE(innerRect->height(), qreal(190)); - - delete rect; -} - -//QTBUG-9609 -void tst_qdeclarativestates::anchorChangesCrash() -{ - QDeclarativeEngine engine; - - QDeclarativeComponent rectComponent(&engine, testFileUrl("anchorChangesCrash.qml")); - QQuickRectangle *rect = qobject_cast(rectComponent.create()); - QVERIFY(rect != 0); - - QQuickItemPrivate::get(rect)->setState("reanchored"); - - delete rect; -} - -// QTBUG-12273 -void tst_qdeclarativestates::anchorRewindBug() -{ - QQuickView *view = new QQuickView; - view->setSource(testFileUrl("anchorRewindBug.qml")); - - view->show(); - view->requestActivateWindow(); - - QTest::qWaitForWindowShown(view); - - QQuickRectangle *rect = qobject_cast(view->rootObject()); - QVERIFY(rect != 0); - - QQuickItem * column = rect->findChild("column"); - - QVERIFY(column != 0); - QVERIFY(!QQuickItemPrivate::get(column)->heightValid); - QVERIFY(!QQuickItemPrivate::get(column)->widthValid); - QCOMPARE(column->height(), 200.0); - QQuickItemPrivate::get(rect)->setState("reanchored"); - - // column height and width should stay implicit - // and column's implicit resizing should still work - QVERIFY(!QQuickItemPrivate::get(column)->heightValid); - QVERIFY(!QQuickItemPrivate::get(column)->widthValid); - QTRY_COMPARE(column->height(), 100.0); - - QQuickItemPrivate::get(rect)->setState(""); - - // column height and width should stay implicit - // and column's implicit resizing should still work - QVERIFY(!QQuickItemPrivate::get(column)->heightValid); - QVERIFY(!QQuickItemPrivate::get(column)->widthValid); - QTRY_COMPARE(column->height(), 200.0); - - delete view; -} - -// QTBUG-11834 -void tst_qdeclarativestates::anchorRewindBug2() -{ - QDeclarativeEngine engine; - - QDeclarativeComponent rectComponent(&engine, testFileUrl("anchorRewindBug2.qml")); - QQuickRectangle *rect = qobject_cast(rectComponent.create()); - QVERIFY(rect != 0); - - QQuickRectangle *mover = rect->findChild("mover"); - - QVERIFY(mover != 0); - QCOMPARE(mover->y(), qreal(0.0)); - QCOMPARE(mover->width(), qreal(50.0)); - - QQuickItemPrivate::get(rect)->setState("anchored"); - QCOMPARE(mover->y(), qreal(250.0)); - QCOMPARE(mover->width(), qreal(200.0)); - - QQuickItemPrivate::get(rect)->setState(""); - QCOMPARE(mover->y(), qreal(0.0)); - QCOMPARE(mover->width(), qreal(50.0)); - - delete rect; -} - -void tst_qdeclarativestates::script() -{ - QDeclarativeEngine engine; - - { - QDeclarativeComponent rectComponent(&engine, testFileUrl("script.qml")); - QQuickRectangle *rect = qobject_cast(rectComponent.create()); - QVERIFY(rect != 0); - QQuickItemPrivate *rectPrivate = QQuickItemPrivate::get(rect); - QCOMPARE(rect->color(),QColor("red")); - - rectPrivate->setState("blue"); - QCOMPARE(rect->color(),QColor("blue")); - - rectPrivate->setState(""); - QCOMPARE(rect->color(),QColor("blue")); // a script isn't reverted - } -} - -void tst_qdeclarativestates::restoreEntryValues() -{ - QDeclarativeEngine engine; - - QDeclarativeComponent rectComponent(&engine, testFileUrl("restoreEntryValues.qml")); - QQuickRectangle *rect = qobject_cast(rectComponent.create()); - QVERIFY(rect != 0); - QQuickItemPrivate *rectPrivate = QQuickItemPrivate::get(rect); - QCOMPARE(rect->color(),QColor("red")); - - rectPrivate->setState("blue"); - QCOMPARE(rect->color(),QColor("blue")); - - rectPrivate->setState(""); - QCOMPARE(rect->color(),QColor("blue")); -} - -void tst_qdeclarativestates::explicitChanges() -{ - QDeclarativeEngine engine; - - QDeclarativeComponent rectComponent(&engine, testFileUrl("explicit.qml")); - QQuickRectangle *rect = qobject_cast(rectComponent.create()); - QVERIFY(rect != 0); - QQuickItemPrivate *rectPrivate = QQuickItemPrivate::get(rect); - QDeclarativeListReference list(rect, "states"); - QDeclarativeState *state = qobject_cast(list.at(0)); - QVERIFY(state != 0); - - qmlExecuteDeferred(state); - QDeclarativePropertyChanges *changes = qobject_cast(rect->findChild("changes")); - QVERIFY(changes != 0); - QVERIFY(changes->isExplicit()); - - QCOMPARE(rect->color(),QColor("red")); - - rectPrivate->setState("blue"); - QCOMPARE(rect->color(),QColor("blue")); - - rect->setProperty("sourceColor", QColor("green")); - QCOMPARE(rect->color(),QColor("blue")); - - rectPrivate->setState(""); - QCOMPARE(rect->color(),QColor("red")); - rect->setProperty("sourceColor", QColor("yellow")); - QCOMPARE(rect->color(),QColor("red")); - - rectPrivate->setState("blue"); - QCOMPARE(rect->color(),QColor("yellow")); -} - -void tst_qdeclarativestates::propertyErrors() -{ - QDeclarativeEngine engine; - QDeclarativeComponent rectComponent(&engine, testFileUrl("propertyErrors.qml")); - QQuickRectangle *rect = qobject_cast(rectComponent.create()); - QVERIFY(rect != 0); - - QCOMPARE(rect->color(),QColor("red")); - - QTest::ignoreMessage(QtWarningMsg, fullDataPath("propertyErrors.qml") + ":8:9: QML PropertyChanges: Cannot assign to non-existent property \"colr\""); - QTest::ignoreMessage(QtWarningMsg, fullDataPath("propertyErrors.qml") + ":8:9: QML PropertyChanges: Cannot assign to read-only property \"activeFocus\""); - QQuickItemPrivate::get(rect)->setState("blue"); -} - -void tst_qdeclarativestates::incorrectRestoreBug() -{ - QDeclarativeEngine engine; - - QDeclarativeComponent rectComponent(&engine, testFileUrl("basicChanges.qml")); - QQuickRectangle *rect = qobject_cast(rectComponent.create()); - QVERIFY(rect != 0); - QQuickItemPrivate *rectPrivate = QQuickItemPrivate::get(rect); - QCOMPARE(rect->color(),QColor("red")); - - rectPrivate->setState("blue"); - QCOMPARE(rect->color(),QColor("blue")); - - rectPrivate->setState(""); - QCOMPARE(rect->color(),QColor("red")); - - // make sure if we change the base state value, we then restore to it correctly - rect->setColor(QColor("green")); - - rectPrivate->setState("blue"); - QCOMPARE(rect->color(),QColor("blue")); - - rectPrivate->setState(""); - QCOMPARE(rect->color(),QColor("green")); -} - -void tst_qdeclarativestates::autoStateAtStartupRestoreBug() -{ - QDeclarativeEngine engine; - - QDeclarativeComponent component(&engine, testFileUrl("autoStateAtStartupRestoreBug.qml")); - QObject *obj = component.create(); - - QVERIFY(obj != 0); - QCOMPARE(obj->property("test").toInt(), 3); - - obj->setProperty("input", 2); - - QCOMPARE(obj->property("test").toInt(), 9); - - delete obj; -} - -void tst_qdeclarativestates::deletingChange() -{ - QDeclarativeEngine engine; - - QDeclarativeComponent rectComponent(&engine, testFileUrl("deleting.qml")); - QQuickRectangle *rect = qobject_cast(rectComponent.create()); - QVERIFY(rect != 0); - QQuickItemPrivate *rectPrivate = QQuickItemPrivate::get(rect); - rectPrivate->setState("blue"); - QCOMPARE(rect->color(),QColor("blue")); - QCOMPARE(rect->radius(),qreal(5)); - - rectPrivate->setState(""); - QCOMPARE(rect->color(),QColor("red")); - QCOMPARE(rect->radius(),qreal(0)); - - QDeclarativePropertyChanges *pc = rect->findChild("pc1"); - QVERIFY(pc != 0); - delete pc; - - QDeclarativeState *state = rect->findChild(); - QVERIFY(state != 0); - qmlExecuteDeferred(state); - QCOMPARE(state->operationCount(), 1); - - rectPrivate->setState("blue"); - QCOMPARE(rect->color(),QColor("red")); - QCOMPARE(rect->radius(),qreal(5)); - - delete rect; -} - -void tst_qdeclarativestates::deletingState() -{ - QDeclarativeEngine engine; - - QDeclarativeComponent rectComponent(&engine, testFileUrl("deletingState.qml")); - QQuickRectangle *rect = qobject_cast(rectComponent.create()); - QVERIFY(rect != 0); - - QDeclarativeStateGroup *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")); - - QDeclarativeState *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_qdeclarativestates::tempState() -{ - QDeclarativeEngine engine; - - QDeclarativeComponent rectComponent(&engine, testFileUrl("legalTempState.qml")); - QQuickRectangle *rect = qobject_cast(rectComponent.create()); - QVERIFY(rect != 0); - QQuickItemPrivate *rectPrivate = QQuickItemPrivate::get(rect); - QTest::ignoreMessage(QtDebugMsg, "entering placed"); - QTest::ignoreMessage(QtDebugMsg, "entering idle"); - rectPrivate->setState("placed"); - QCOMPARE(rectPrivate->state(), QLatin1String("idle")); -} - -void tst_qdeclarativestates::illegalTempState() -{ - QDeclarativeEngine engine; - - QDeclarativeComponent rectComponent(&engine, testFileUrl("illegalTempState.qml")); - QQuickRectangle *rect = qobject_cast(rectComponent.create()); - QVERIFY(rect != 0); - QQuickItemPrivate *rectPrivate = QQuickItemPrivate::get(rect); - QTest::ignoreMessage(QtWarningMsg, ": QML StateGroup: Can't apply a state change as part of a state definition."); - rectPrivate->setState("placed"); - QCOMPARE(rectPrivate->state(), QLatin1String("placed")); -} - -void tst_qdeclarativestates::nonExistantProperty() -{ - QDeclarativeEngine engine; - - QDeclarativeComponent rectComponent(&engine, testFileUrl("nonExistantProp.qml")); - QQuickRectangle *rect = qobject_cast(rectComponent.create()); - QVERIFY(rect != 0); - QQuickItemPrivate *rectPrivate = QQuickItemPrivate::get(rect); - QTest::ignoreMessage(QtWarningMsg, fullDataPath("nonExistantProp.qml") + ":9:9: QML PropertyChanges: Cannot assign to non-existent property \"colr\""); - rectPrivate->setState("blue"); - QCOMPARE(rectPrivate->state(), QLatin1String("blue")); -} - -void tst_qdeclarativestates::reset() -{ - QDeclarativeEngine engine; - - QDeclarativeComponent c(&engine, testFileUrl("reset.qml")); - QQuickRectangle *rect = qobject_cast(c.create()); - QVERIFY(rect != 0); - - QQuickImage *image = rect->findChild(); - QVERIFY(image != 0); - QCOMPARE(image->width(), qreal(40.)); - QCOMPARE(image->height(), qreal(20.)); - - QQuickItemPrivate::get(rect)->setState("state1"); - - QCOMPARE(image->width(), 20.0); - QCOMPARE(image->height(), qreal(20.)); - - delete rect; -} - -void tst_qdeclarativestates::illegalObjectCreation() -{ - QDeclarativeEngine engine; - - QDeclarativeComponent component(&engine, testFileUrl("illegalObj.qml")); - QList errors = component.errors(); - QVERIFY(errors.count() == 1); - const QDeclarativeError &error = errors.at(0); - QCOMPARE(error.line(), 9); - QCOMPARE(error.column(), 23); - QCOMPARE(error.description().toUtf8().constData(), "PropertyChanges does not support creating state-specific objects."); -} - -void tst_qdeclarativestates::whenOrdering() -{ - QDeclarativeEngine engine; - - QDeclarativeComponent c(&engine, testFileUrl("whenOrdering.qml")); - QQuickRectangle *rect = qobject_cast(c.create()); - QVERIFY(rect != 0); - QQuickItemPrivate *rectPrivate = QQuickItemPrivate::get(rect); - - QCOMPARE(rectPrivate->state(), QLatin1String("")); - rect->setProperty("condition2", true); - QCOMPARE(rectPrivate->state(), QLatin1String("state2")); - rect->setProperty("condition1", true); - QCOMPARE(rectPrivate->state(), QLatin1String("state1")); - rect->setProperty("condition2", false); - QCOMPARE(rectPrivate->state(), QLatin1String("state1")); - rect->setProperty("condition2", true); - QCOMPARE(rectPrivate->state(), QLatin1String("state1")); - rect->setProperty("condition1", false); - rect->setProperty("condition2", false); - QCOMPARE(rectPrivate->state(), QLatin1String("")); -} - -void tst_qdeclarativestates::urlResolution() -{ - QDeclarativeEngine engine; - - QDeclarativeComponent c(&engine, testFileUrl("urlResolution.qml")); - QQuickRectangle *rect = qobject_cast(c.create()); - QVERIFY(rect != 0); - - QQuickItem *myType = rect->findChild("MyType"); - QQuickImage *image1 = rect->findChild("image1"); - QQuickImage *image2 = rect->findChild("image2"); - QQuickImage *image3 = rect->findChild("image3"); - QVERIFY(myType != 0 && image1 != 0 && image2 != 0 && image3 != 0); - - QQuickItemPrivate::get(myType)->setState("SetImageState"); - QUrl resolved = testFileUrl("Implementation/images/qt-logo.png"); - QCOMPARE(image1->source(), resolved); - QCOMPARE(image2->source(), resolved); - QCOMPARE(image3->source(), resolved); - - delete rect; -} - -void tst_qdeclarativestates::unnamedWhen() -{ - QDeclarativeEngine engine; - - QDeclarativeComponent c(&engine, testFileUrl("unnamedWhen.qml")); - QQuickRectangle *rect = qobject_cast(c.create()); - QVERIFY(rect != 0); - QQuickItemPrivate *rectPrivate = QQuickItemPrivate::get(rect); - - QCOMPARE(rectPrivate->state(), QLatin1String("")); - QCOMPARE(rect->property("stateString").toString(), QLatin1String("")); - rect->setProperty("triggerState", true); - QCOMPARE(rectPrivate->state(), QLatin1String("anonymousState1")); - QCOMPARE(rect->property("stateString").toString(), QLatin1String("inState")); - rect->setProperty("triggerState", false); - QCOMPARE(rectPrivate->state(), QLatin1String("")); - QCOMPARE(rect->property("stateString").toString(), QLatin1String("")); -} - -void tst_qdeclarativestates::returnToBase() -{ - QDeclarativeEngine engine; - - QDeclarativeComponent c(&engine, testFileUrl("returnToBase.qml")); - QQuickRectangle *rect = qobject_cast(c.create()); - QVERIFY(rect != 0); - QQuickItemPrivate *rectPrivate = QQuickItemPrivate::get(rect); - - QCOMPARE(rectPrivate->state(), QLatin1String("")); - QCOMPARE(rect->property("stateString").toString(), QLatin1String("")); - rect->setProperty("triggerState", true); - QCOMPARE(rectPrivate->state(), QLatin1String("anonymousState1")); - QCOMPARE(rect->property("stateString").toString(), QLatin1String("inState")); - rect->setProperty("triggerState", false); - QCOMPARE(rectPrivate->state(), QLatin1String("")); - QCOMPARE(rect->property("stateString").toString(), QLatin1String("originalState")); -} - -//QTBUG-12559 -void tst_qdeclarativestates::extendsBug() -{ - QDeclarativeEngine engine; - - QDeclarativeComponent c(&engine, testFileUrl("extendsBug.qml")); - QQuickRectangle *rect = qobject_cast(c.create()); - QVERIFY(rect != 0); - QQuickItemPrivate *rectPrivate = QQuickItemPrivate::get(rect); - QQuickRectangle *greenRect = rect->findChild("greenRect"); - - rectPrivate->setState("b"); - QCOMPARE(greenRect->x(), qreal(100)); - QCOMPARE(greenRect->y(), qreal(100)); -} - -void tst_qdeclarativestates::editProperties() -{ - QDeclarativeEngine engine; - - QDeclarativeComponent c(&engine, testFileUrl("editProperties.qml")); - QQuickRectangle *rect = qobject_cast(c.create()); - QVERIFY(rect != 0); - - QQuickItemPrivate *rectPrivate = QQuickItemPrivate::get(rect); - - QDeclarativeStateGroup *stateGroup = rectPrivate->_states(); - QVERIFY(stateGroup != 0); - qmlExecuteDeferred(stateGroup); - - QDeclarativeState *blueState = stateGroup->findState("blue"); - QVERIFY(blueState != 0); - qmlExecuteDeferred(blueState); - - QDeclarativePropertyChanges *propertyChangesBlue = qobject_cast(blueState->operationAt(0)); - QVERIFY(propertyChangesBlue != 0); - - QDeclarativeState *greenState = stateGroup->findState("green"); - QVERIFY(greenState != 0); - qmlExecuteDeferred(greenState); - - QDeclarativePropertyChanges *propertyChangesGreen = qobject_cast(greenState->operationAt(0)); - QVERIFY(propertyChangesGreen != 0); - - QQuickRectangle *childRect = rect->findChild("rect2"); - QVERIFY(childRect != 0); - QCOMPARE(childRect->width(), qreal(402)); - QVERIFY(QDeclarativePropertyPrivate::binding(QDeclarativeProperty(childRect, "width"))); - QCOMPARE(childRect->height(), qreal(200)); - - rectPrivate->setState("blue"); - QCOMPARE(childRect->width(), qreal(50)); - QCOMPARE(childRect->height(), qreal(40)); - QVERIFY(!QDeclarativePropertyPrivate::binding(QDeclarativeProperty(childRect, "width"))); - QVERIFY(blueState->bindingInRevertList(childRect, "width")); - - - rectPrivate->setState("green"); - QCOMPARE(childRect->width(), qreal(200)); - QCOMPARE(childRect->height(), qreal(100)); - QVERIFY(greenState->bindingInRevertList(childRect, "width")); - - - rectPrivate->setState(""); - - - QCOMPARE(propertyChangesBlue->actions().length(), 2); - QVERIFY(propertyChangesBlue->containsValue("width")); - QVERIFY(!propertyChangesBlue->containsProperty("x")); - QCOMPARE(propertyChangesBlue->value("width").toInt(), 50); - QVERIFY(!propertyChangesBlue->value("x").isValid()); - - propertyChangesBlue->changeValue("width", 60); - QCOMPARE(propertyChangesBlue->value("width").toInt(), 60); - QCOMPARE(propertyChangesBlue->actions().length(), 2); - - - propertyChangesBlue->changeExpression("width", "myRectangle.width / 2"); - QVERIFY(!propertyChangesBlue->containsValue("width")); - QVERIFY(propertyChangesBlue->containsExpression("width")); - QCOMPARE(propertyChangesBlue->value("width").toInt(), 0); - QCOMPARE(propertyChangesBlue->actions().length(), 2); - - propertyChangesBlue->changeValue("width", 50); - QVERIFY(propertyChangesBlue->containsValue("width")); - QVERIFY(!propertyChangesBlue->containsExpression("width")); - QCOMPARE(propertyChangesBlue->value("width").toInt(), 50); - QCOMPARE(propertyChangesBlue->actions().length(), 2); - - QVERIFY(QDeclarativePropertyPrivate::binding(QDeclarativeProperty(childRect, "width"))); - rectPrivate->setState("blue"); - QCOMPARE(childRect->width(), qreal(50)); - QCOMPARE(childRect->height(), qreal(40)); - - propertyChangesBlue->changeValue("width", 60); - QCOMPARE(propertyChangesBlue->value("width").toInt(), 60); - QCOMPARE(propertyChangesBlue->actions().length(), 2); - QCOMPARE(childRect->width(), qreal(60)); - QVERIFY(!QDeclarativePropertyPrivate::binding(QDeclarativeProperty(childRect, "width"))); - - propertyChangesBlue->changeExpression("width", "myRectangle.width / 2"); - QVERIFY(!propertyChangesBlue->containsValue("width")); - QVERIFY(propertyChangesBlue->containsExpression("width")); - QCOMPARE(propertyChangesBlue->value("width").toInt(), 0); - QCOMPARE(propertyChangesBlue->actions().length(), 2); - QVERIFY(QDeclarativePropertyPrivate::binding(QDeclarativeProperty(childRect, "width"))); - QCOMPARE(childRect->width(), qreal(200)); - - propertyChangesBlue->changeValue("width", 50); - QCOMPARE(childRect->width(), qreal(50)); - - rectPrivate->setState(""); - QCOMPARE(childRect->width(), qreal(402)); - QVERIFY(QDeclarativePropertyPrivate::binding(QDeclarativeProperty(childRect, "width"))); - - QCOMPARE(propertyChangesGreen->actions().length(), 2); - rectPrivate->setState("green"); - QCOMPARE(childRect->width(), qreal(200)); - QCOMPARE(childRect->height(), qreal(100)); - QVERIFY(QDeclarativePropertyPrivate::binding(QDeclarativeProperty(childRect, "width"))); - QVERIFY(greenState->bindingInRevertList(childRect, "width")); - QCOMPARE(propertyChangesGreen->actions().length(), 2); - - - propertyChangesGreen->removeProperty("height"); - QVERIFY(!QDeclarativePropertyPrivate::binding(QDeclarativeProperty(childRect, "height"))); - QCOMPARE(childRect->height(), qreal(200)); - - QVERIFY(greenState->bindingInRevertList(childRect, "width")); - QVERIFY(greenState->containsPropertyInRevertList(childRect, "width")); - propertyChangesGreen->removeProperty("width"); - QVERIFY(QDeclarativePropertyPrivate::binding(QDeclarativeProperty(childRect, "width"))); - QCOMPARE(childRect->width(), qreal(402)); - QVERIFY(!greenState->bindingInRevertList(childRect, "width")); - QVERIFY(!greenState->containsPropertyInRevertList(childRect, "width")); - - propertyChangesBlue->removeProperty("width"); - QCOMPARE(childRect->width(), qreal(402)); - - rectPrivate->setState("blue"); - QCOMPARE(childRect->width(), qreal(402)); - QCOMPARE(childRect->height(), qreal(40)); -} - -void tst_qdeclarativestates::QTBUG_14830() -{ - QDeclarativeEngine engine; - - QDeclarativeComponent c(&engine, testFileUrl("QTBUG-14830.qml")); - QQuickRectangle *rect = qobject_cast(c.create()); - QVERIFY(rect != 0); - QQuickItem *item = rect->findChild("area"); - - QCOMPARE(item->width(), qreal(171)); -} - -void tst_qdeclarativestates::avoidFastForward() -{ - QDeclarativeEngine engine; - - //shouldn't fast forward if there isn't a transition - QDeclarativeComponent c(&engine, testFileUrl("avoidFastForward.qml")); - QQuickRectangle *rect = qobject_cast(c.create()); - QVERIFY(rect != 0); - - QQuickItemPrivate *rectPrivate = QQuickItemPrivate::get(rect); - rectPrivate->setState("a"); - QCOMPARE(rect->property("updateCount").toInt(), 1); -} - -//QTBUG-22583 -void tst_qdeclarativestates::revertListBug() -{ - QDeclarativeEngine engine; - - QDeclarativeComponent c(&engine, testFileUrl("revertListBug.qml")); - QQuickRectangle *rect = qobject_cast(c.create()); - QVERIFY(rect != 0); - - QQuickRectangle *rect1 = rect->findChild("rect1"); - QQuickRectangle *rect2 = rect->findChild("rect2"); - QQuickItem *origParent1 = rect->findChild("originalParent1"); - QQuickItem *origParent2 = rect->findChild("originalParent2"); - QQuickItem *newParent = rect->findChild("newParent"); - - QCOMPARE(rect1->parentItem(), origParent1); - QCOMPARE(rect2->parentItem(), origParent2); - - QQuickItemPrivate *rectPrivate = QQuickItemPrivate::get(rect); - rectPrivate->setState("reparented"); - - QCOMPARE(rect1->parentItem(), newParent); - QCOMPARE(rect2->parentItem(), origParent2); - - rectPrivate->setState(""); - - QCOMPARE(rect1->parentItem(), origParent1); - QCOMPARE(rect2->parentItem(), origParent2); - - QMetaObject::invokeMethod(rect, "switchTargetItem"); - - rectPrivate->setState("reparented"); - - QCOMPARE(rect1->parentItem(), origParent1); - QCOMPARE(rect2->parentItem(), newParent); - - rectPrivate->setState(""); - - QCOMPARE(rect1->parentItem(), origParent1); - QCOMPARE(rect2->parentItem(), origParent2); //QTBUG-22583 causes rect2's parent item to be origParent1 -} - -QTEST_MAIN(tst_qdeclarativestates) - -#include "tst_qdeclarativestates.moc" diff --git a/tests/auto/qtquick2/qdeclarativestyledtext/qdeclarativestyledtext.pro b/tests/auto/qtquick2/qdeclarativestyledtext/qdeclarativestyledtext.pro deleted file mode 100644 index 84532f611e..0000000000 --- a/tests/auto/qtquick2/qdeclarativestyledtext/qdeclarativestyledtext.pro +++ /dev/null @@ -1,8 +0,0 @@ -CONFIG += testcase -TARGET = tst_qdeclarativestyledtext -macx:CONFIG -= app_bundle - -SOURCES += tst_qdeclarativestyledtext.cpp - -CONFIG += parallel_test -QT += core-private gui-private declarative-private quick-private network testlib diff --git a/tests/auto/qtquick2/qdeclarativestyledtext/tst_qdeclarativestyledtext.cpp b/tests/auto/qtquick2/qdeclarativestyledtext/tst_qdeclarativestyledtext.cpp deleted file mode 100644 index fd0d1abd29..0000000000 --- a/tests/auto/qtquick2/qdeclarativestyledtext/tst_qdeclarativestyledtext.cpp +++ /dev/null @@ -1,185 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include -#include -#include -#include -#include - -class tst_qdeclarativestyledtext : public QObject -{ - Q_OBJECT -public: - tst_qdeclarativestyledtext() - { - } - - struct Format { - enum Type { - Bold = 0x01, - Underline = 0x02, - Italic = 0x04 - }; - Format(int t, int s, int l) - : type(t), start(s), length(l) {} - int type; - int start; - int length; - }; - typedef QList FormatList; - - static const QChar bullet; - static const QChar disc; - static const QChar square; - -private slots: - void textOutput(); - void textOutput_data(); -}; - -Q_DECLARE_METATYPE(tst_qdeclarativestyledtext::FormatList); - -const QChar tst_qdeclarativestyledtext::bullet(0x2022); -const QChar tst_qdeclarativestyledtext::disc(0x25e6); -const QChar tst_qdeclarativestyledtext::square(0x25a1); - -// For malformed input all we test is that we get the expected text and format out. -// -void tst_qdeclarativestyledtext::textOutput_data() -{ - QTest::addColumn("input"); - QTest::addColumn("output"); - QTest::addColumn("formats"); - - QTest::newRow("bold") << "bold" << "bold" << (FormatList() << Format(Format::Bold, 0, 4)); - QTest::newRow("italic") << "italic" << "italic" << (FormatList() << Format(Format::Italic, 0, 6)); - QTest::newRow("underline") << "underline" << "underline" << (FormatList() << Format(Format::Underline, 0, 9)); - QTest::newRow("strong") << "strong" << "strong" << (FormatList() << Format(Format::Bold, 0, 6)); - QTest::newRow("underline") << "underline" << "underline" << (FormatList() << Format(Format::Underline, 0, 9)); - QTest::newRow("missing >") << "text") << "text") << "text<" << "text" << (FormatList() << Format(Format::Bold, 0, 4)); - QTest::newRow("missing ") << "text" << "text" << (FormatList() << Format(Format::Bold, 0, 4)); - QTest::newRow("nested") << "text italic bold" << "text italic bold" << (FormatList() << Format(Format::Bold, 0, 5) << Format(Format::Bold | Format::Italic, 5, 6) << Format(Format::Bold, 11, 5)); - QTest::newRow("bad nest") << "text italic" << "text italic" << (FormatList() << Format(Format::Bold, 0, 5) << Format(Format::Bold | Format::Italic, 5, 6)); - QTest::newRow("font color") << "red text" << "red text" << (FormatList() << Format(0, 0, 8)); - QTest::newRow("font color: single quote") << "red text" << "red text" << (FormatList() << Format(0, 0, 8)); - QTest::newRow("font size") << "text" << "text" << (FormatList() << Format(0, 0, 4)); - QTest::newRow("font empty") << "text" << "text" << FormatList(); - QTest::newRow("font bad 1") << "text" << "text" << FormatList(); - QTest::newRow("font bad 2") << "text" << "" << FormatList(); - QTest::newRow("extra close") << "text" << "text" << (FormatList() << Format(Format::Bold, 0, 4)); - QTest::newRow("extra space") << "text" << "text" << (FormatList() << Format(Format::Bold, 0, 4)); - QTest::newRow("entities") << "<b>this & that</b>" << "this & that" << FormatList(); - QTest::newRow("newline") << "text
more text" << QLatin1String("text") + QChar(QChar::LineSeparator) + QLatin1String("more text") << FormatList(); - QTest::newRow("paragraph") << "text

more text" << QLatin1String("text") + QChar(QChar::LineSeparator) + QLatin1String("more text") << FormatList(); - QTest::newRow("paragraph closed") << "text

more text

more text" << QLatin1String("text") + QChar(QChar::LineSeparator) + QLatin1String("more text") + QChar(QChar::LineSeparator) + QLatin1String("more text") << FormatList(); - QTest::newRow("paragraph closed bold") << "text

more text

more text
" << QLatin1String("text") + QChar(QChar::LineSeparator) + QLatin1String("more text") + QChar(QChar::LineSeparator) + QLatin1String("more text") << (FormatList() << Format(Format::Bold, 0, 24)); - QTest::newRow("self-closing newline") << "text
more text" << QLatin1String("text") + QChar(QChar::LineSeparator) + QLatin1String("more text") << FormatList(); - QTest::newRow("empty") << "" << "" << FormatList(); - QTest::newRow("unknown tag") << "underline not" << "underline not" << (FormatList() << Format(Format::Underline, 0, 9)); - QTest::newRow("ordered list") << "
  1. one
  2. two" << QChar(QChar::LineSeparator) + QString(6, QChar::Nbsp) + QLatin1String("1.") + QString(2, QChar::Nbsp) + QLatin1String("one") + QChar(QChar::LineSeparator) + QString(6, QChar::Nbsp) + QLatin1String("2.") + QString(2, QChar::Nbsp) + QLatin1String("two") << FormatList(); - QTest::newRow("ordered list closed") << "
    1. one
    2. two
    " << QChar(QChar::LineSeparator) + QString(6, QChar::Nbsp) + QLatin1String("1.") + QString(2, QChar::Nbsp) + QLatin1String("one") + QChar(QChar::LineSeparator) + QString(6, QChar::Nbsp) + QLatin1String("2.") + QString(2, QChar::Nbsp) + QLatin1String("two") + QChar(QChar::LineSeparator) << FormatList(); - QTest::newRow("ordered list alpha") << "
    1. one
    2. two
    " << QChar(QChar::LineSeparator) + QString(6, QChar::Nbsp) + QLatin1String("a.") + QString(2, QChar::Nbsp) + QLatin1String("one") + QChar(QChar::LineSeparator) + QString(6, QChar::Nbsp) + QLatin1String("b.") + QString(2, QChar::Nbsp) + QLatin1String("two") + QChar(QChar::LineSeparator) << FormatList(); - QTest::newRow("ordered list upper alpha") << "
    1. one
    2. two
    " << QChar(QChar::LineSeparator) + QString(6, QChar::Nbsp) + QLatin1String("A.") + QString(2, QChar::Nbsp) + QLatin1String("one") + QChar(QChar::LineSeparator) + QString(6, QChar::Nbsp) + QLatin1String("B.") + QString(2, QChar::Nbsp) + QLatin1String("two") + QChar(QChar::LineSeparator) << FormatList(); - QTest::newRow("ordered list roman") << "
    1. one
    2. two
    " << QChar(QChar::LineSeparator) + QString(6, QChar::Nbsp) + QLatin1String("i.") + QString(2, QChar::Nbsp) + QLatin1String("one") + QChar(QChar::LineSeparator) + QString(6, QChar::Nbsp) + QLatin1String("ii.") + QString(2, QChar::Nbsp) + QLatin1String("two") + QChar(QChar::LineSeparator) << FormatList(); - QTest::newRow("ordered list upper roman") << "
    1. one
    2. two
    " << QChar(QChar::LineSeparator) + QString(6, QChar::Nbsp) + QLatin1String("I.") + QString(2, QChar::Nbsp) + QLatin1String("one") + QChar(QChar::LineSeparator) + QString(6, QChar::Nbsp) + QLatin1String("II.") + QString(2, QChar::Nbsp) + QLatin1String("two") + QChar(QChar::LineSeparator) << FormatList(); - QTest::newRow("ordered list bad") << "
    1. one
    2. two
    " << QChar(QChar::LineSeparator) + QString(6, QChar::Nbsp) + QLatin1String("1.") + QString(2, QChar::Nbsp) + QLatin1String("one") + QChar(QChar::LineSeparator) + QString(6, QChar::Nbsp) + QLatin1String("2.") + QString(2, QChar::Nbsp) + QLatin1String("two") + QChar(QChar::LineSeparator) << FormatList(); - QTest::newRow("unordered list") << "
    • one
    • two" << QChar(QChar::LineSeparator) + QString(6, QChar::Nbsp) + bullet + QString(2, QChar::Nbsp) + QLatin1String("one") + QChar(QChar::LineSeparator) + QString(6, QChar::Nbsp) + bullet + QString(2, QChar::Nbsp) + QLatin1String("two") << FormatList(); - QTest::newRow("unordered list closed") << "
      • one
      • two
      " << QChar(QChar::LineSeparator) + QString(6, QChar::Nbsp) + bullet + QString(2, QChar::Nbsp) + QLatin1String("one") + QChar(QChar::LineSeparator) + QString(6, QChar::Nbsp) + bullet + QString(2, QChar::Nbsp) + QLatin1String("two") + QChar(QChar::LineSeparator) << FormatList(); - QTest::newRow("unordered list disc") << "
      • one
      • two
      " << QChar(QChar::LineSeparator) + QString(6, QChar::Nbsp) + disc + QString(2, QChar::Nbsp) + QLatin1String("one") + QChar(QChar::LineSeparator) + QString(6, QChar::Nbsp) + disc + QString(2, QChar::Nbsp) + QLatin1String("two") + QChar(QChar::LineSeparator) << FormatList(); - QTest::newRow("unordered list square") << "
      • one
      • two
      " << QChar(QChar::LineSeparator) + QString(6, QChar::Nbsp) + square + QString(2, QChar::Nbsp) + QLatin1String("one") + QChar(QChar::LineSeparator) + QString(6, QChar::Nbsp) + square + QString(2, QChar::Nbsp) + QLatin1String("two") + QChar(QChar::LineSeparator) << FormatList(); - QTest::newRow("unordered list bad") << "
      • one
      • two
      " << QChar(QChar::LineSeparator) + QString(6, QChar::Nbsp) + bullet + QString(2, QChar::Nbsp) + QLatin1String("one") + QChar(QChar::LineSeparator) + QString(6, QChar::Nbsp) + bullet + QString(2, QChar::Nbsp) + QLatin1String("two") + QChar(QChar::LineSeparator) << FormatList(); - QTest::newRow("header close") << "

      head

      more" << QChar(QChar::LineSeparator) + QLatin1String("head") + QChar(QChar::LineSeparator) + QLatin1String("more") << (FormatList() << Format(Format::Bold, 0, 5)); - QTest::newRow("h0") << "head" << "head" << FormatList(); - QTest::newRow("h1") << "

      head" << QChar(QChar::LineSeparator) + QLatin1String("head") << (FormatList() << Format(Format::Bold, 0, 5)); - QTest::newRow("h2") << "

      head" << QChar(QChar::LineSeparator) + QLatin1String("head") << (FormatList() << Format(Format::Bold, 0, 5)); - QTest::newRow("h3") << "

      head" << QChar(QChar::LineSeparator) + QLatin1String("head") << (FormatList() << Format(Format::Bold, 0, 5)); - QTest::newRow("h4") << "

      head" << QChar(QChar::LineSeparator) + QLatin1String("head") << (FormatList() << Format(Format::Bold, 0, 5)); - QTest::newRow("h5") << "

      head" << QChar(QChar::LineSeparator) + QLatin1String("head") << (FormatList() << Format(Format::Bold, 0, 5)); - QTest::newRow("h6") << "
      head" << QChar(QChar::LineSeparator) + QLatin1String("head") << (FormatList() << Format(Format::Bold, 0, 5)); - QTest::newRow("h7") << "head" << "head" << FormatList(); - QTest::newRow("pre") << "normal
      pre text
      normal" << QLatin1String("normal") + QChar(QChar::LineSeparator) + QLatin1String("pre") + QChar(QChar::Nbsp) + QLatin1String("text") + QChar(QChar::LineSeparator) + QLatin1String("normal") << (FormatList() << Format(0, 6, 9)); - QTest::newRow("pre lb") << "normal
      pre\n text
      normal" << QLatin1String("normal") + QChar(QChar::LineSeparator) + QLatin1String("pre") + QChar(QChar::LineSeparator) + QChar(QChar::Nbsp) + QLatin1String("text") + QChar(QChar::LineSeparator) + QLatin1String("normal") << (FormatList() << Format(0, 6, 10)); - QTest::newRow("line feed") << "line\nfeed" << "line feed" << FormatList(); - QTest::newRow("leading whitespace") << " leading whitespace" << "leading whitespace" << FormatList(); - QTest::newRow("trailing whitespace") << "trailing whitespace " << "trailing whitespace" << FormatList(); - QTest::newRow("consecutive whitespace") << " consecutive \t \n whitespace" << "consecutive whitespace" << FormatList(); - QTest::newRow("space after newline") << "text
      more text" << QLatin1String("text") + QChar(QChar::LineSeparator) + QLatin1String("more text") << FormatList(); - QTest::newRow("space after paragraph") << "text

      more text

      more text" << QLatin1String("text") + QChar(QChar::LineSeparator) + QLatin1String("more text") + QChar(QChar::LineSeparator) + QLatin1String("more text") << FormatList(); - QTest::newRow("space in header") << "

      head

      " << QChar(QChar::LineSeparator) + QLatin1String("head") + QChar(QChar::LineSeparator) << (FormatList() << Format(Format::Bold, 0, 5)); - QTest::newRow("space before bold") << "this is bold" << "this is bold" << (FormatList() << Format(Format::Bold, 8, 4)); - QTest::newRow("space leading bold") << "this is bold" << "this is bold" << (FormatList() << Format(Format::Bold, 7, 5)); - QTest::newRow("space trailing bold") << "this is bold " << "this is bold " << (FormatList() << Format(Format::Bold, 8, 5)); - QTest::newRow("img") << "ab" << "a b" << FormatList(); -} - -void tst_qdeclarativestyledtext::textOutput() -{ - QFETCH(QString, input); - QFETCH(QString, output); - QFETCH(FormatList, formats); - - QTextLayout layout; - QList imgTags; - QDeclarativeStyledText::parse(input, layout, imgTags, QUrl(), 0, false); - - QCOMPARE(layout.text(), output); - - QList layoutFormats = layout.additionalFormats(); - - QCOMPARE(layoutFormats.count(), formats.count()); - for (int i = 0; i < formats.count(); ++i) { - QCOMPARE(layoutFormats.at(i).start, formats.at(i).start); - QCOMPARE(layoutFormats.at(i).length, formats.at(i).length); - if (formats.at(i).type & Format::Bold) - QVERIFY(layoutFormats.at(i).format.fontWeight() == QFont::Bold); - else - QVERIFY(layoutFormats.at(i).format.fontWeight() == QFont::Normal); - QVERIFY(layoutFormats.at(i).format.fontItalic() == bool(formats.at(i).type & Format::Italic)); - QVERIFY(layoutFormats.at(i).format.fontUnderline() == bool(formats.at(i).type & Format::Underline)); - } -} - - -QTEST_MAIN(tst_qdeclarativestyledtext) - -#include "tst_qdeclarativestyledtext.moc" diff --git a/tests/auto/qtquick2/qdeclarativesystempalette/qdeclarativesystempalette.pro b/tests/auto/qtquick2/qdeclarativesystempalette/qdeclarativesystempalette.pro deleted file mode 100644 index 87c2af2190..0000000000 --- a/tests/auto/qtquick2/qdeclarativesystempalette/qdeclarativesystempalette.pro +++ /dev/null @@ -1,8 +0,0 @@ -CONFIG += testcase -TARGET = tst_qdeclarativesystempalette -macx:CONFIG -= app_bundle - -SOURCES += tst_qdeclarativesystempalette.cpp - -CONFIG += parallel_test -QT += core-private gui-private declarative-private quick-private widgets testlib diff --git a/tests/auto/qtquick2/qdeclarativesystempalette/tst_qdeclarativesystempalette.cpp b/tests/auto/qtquick2/qdeclarativesystempalette/tst_qdeclarativesystempalette.cpp deleted file mode 100644 index f2b1eeb602..0000000000 --- a/tests/auto/qtquick2/qdeclarativesystempalette/tst_qdeclarativesystempalette.cpp +++ /dev/null @@ -1,185 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include -#include -#include -#include -#include -#include - -class tst_qdeclarativesystempalette : public QObject -{ - Q_OBJECT -public: - tst_qdeclarativesystempalette(); - -private slots: - void activePalette(); - void inactivePalette(); - void disabledPalette(); - void paletteChanged(); - -private: - QDeclarativeEngine engine; -}; - -tst_qdeclarativesystempalette::tst_qdeclarativesystempalette() -{ -} - -void tst_qdeclarativesystempalette::activePalette() -{ - QString componentStr = "import QtQuick 2.0\nSystemPalette { }"; - QDeclarativeComponent component(&engine); - component.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); - QDeclarativeSystemPalette *object = qobject_cast(component.create()); - - QVERIFY(object != 0); - - QPalette palette; - palette.setCurrentColorGroup(QPalette::Active); - QCOMPARE(palette.window().color(), object->window()); - QCOMPARE(palette.windowText().color(), object->windowText()); - QCOMPARE(palette.base().color(), object->base()); - QCOMPARE(palette.text().color(), object->text()); - QCOMPARE(palette.alternateBase().color(), object->alternateBase()); - QCOMPARE(palette.button().color(), object->button()); - QCOMPARE(palette.buttonText().color(), object->buttonText()); - QCOMPARE(palette.light().color(), object->light()); - QCOMPARE(palette.midlight().color(), object->midlight()); - QCOMPARE(palette.dark().color(), object->dark()); - QCOMPARE(palette.mid().color(), object->mid()); - QCOMPARE(palette.shadow().color(), object->shadow()); - QCOMPARE(palette.highlight().color(), object->highlight()); - QCOMPARE(palette.highlightedText().color(), object->highlightedText()); - - delete object; -} - -void tst_qdeclarativesystempalette::inactivePalette() -{ - QString componentStr = "import QtQuick 2.0\nSystemPalette { colorGroup: SystemPalette.Inactive }"; - QDeclarativeComponent component(&engine); - component.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); - QDeclarativeSystemPalette *object = qobject_cast(component.create()); - - QVERIFY(object != 0); - QVERIFY(object->colorGroup() == QDeclarativeSystemPalette::Inactive); - - QPalette palette; - palette.setCurrentColorGroup(QPalette::Inactive); - QCOMPARE(palette.window().color(), object->window()); - QCOMPARE(palette.windowText().color(), object->windowText()); - QCOMPARE(palette.base().color(), object->base()); - QCOMPARE(palette.text().color(), object->text()); - QCOMPARE(palette.alternateBase().color(), object->alternateBase()); - QCOMPARE(palette.button().color(), object->button()); - QCOMPARE(palette.buttonText().color(), object->buttonText()); - QCOMPARE(palette.light().color(), object->light()); - QCOMPARE(palette.midlight().color(), object->midlight()); - QCOMPARE(palette.dark().color(), object->dark()); - QCOMPARE(palette.mid().color(), object->mid()); - QCOMPARE(palette.shadow().color(), object->shadow()); - QCOMPARE(palette.highlight().color(), object->highlight()); - QCOMPARE(palette.highlightedText().color(), object->highlightedText()); - - delete object; -} - -void tst_qdeclarativesystempalette::disabledPalette() -{ - QString componentStr = "import QtQuick 2.0\nSystemPalette { colorGroup: SystemPalette.Disabled }"; - QDeclarativeComponent component(&engine); - component.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); - QDeclarativeSystemPalette *object = qobject_cast(component.create()); - - QVERIFY(object != 0); - QVERIFY(object->colorGroup() == QDeclarativeSystemPalette::Disabled); - - QPalette palette; - palette.setCurrentColorGroup(QPalette::Disabled); - QCOMPARE(palette.window().color(), object->window()); - QCOMPARE(palette.windowText().color(), object->windowText()); - QCOMPARE(palette.base().color(), object->base()); - QCOMPARE(palette.text().color(), object->text()); - QCOMPARE(palette.alternateBase().color(), object->alternateBase()); - QCOMPARE(palette.button().color(), object->button()); - QCOMPARE(palette.buttonText().color(), object->buttonText()); - QCOMPARE(palette.light().color(), object->light()); - QCOMPARE(palette.midlight().color(), object->midlight()); - QCOMPARE(palette.dark().color(), object->dark()); - QCOMPARE(palette.mid().color(), object->mid()); - QCOMPARE(palette.shadow().color(), object->shadow()); - QCOMPARE(palette.highlight().color(), object->highlight()); - QCOMPARE(palette.highlightedText().color(), object->highlightedText()); - - delete object; -} - -void tst_qdeclarativesystempalette::paletteChanged() -{ - QString componentStr = "import QtQuick 2.0\nSystemPalette { }"; - QDeclarativeComponent component(&engine); - component.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); - QDeclarativeSystemPalette *object = qobject_cast(component.create()); - - QVERIFY(object != 0); - - QPalette p; - p.setCurrentColorGroup(QPalette::Active); - p.setColor(QPalette::Active, QPalette::Text, QColor("red")); - p.setColor(QPalette::Active, QPalette::ButtonText, QColor("green")); - p.setColor(QPalette::Active, QPalette::WindowText, QColor("blue")); - - qApp->setPalette(p); - - object->setColorGroup(QDeclarativeSystemPalette::Active); - QTRY_COMPARE(QColor("red"), object->text()); - QTRY_COMPARE(QColor("green"), object->buttonText()); - QTRY_COMPARE(QColor("blue"), object->windowText()); - - delete object; -} - -QTEST_MAIN(tst_qdeclarativesystempalette) - -#include "tst_qdeclarativesystempalette.moc" diff --git a/tests/auto/qtquick2/qdeclarativetimer/qdeclarativetimer.pro b/tests/auto/qtquick2/qdeclarativetimer/qdeclarativetimer.pro deleted file mode 100644 index d990dc449f..0000000000 --- a/tests/auto/qtquick2/qdeclarativetimer/qdeclarativetimer.pro +++ /dev/null @@ -1,8 +0,0 @@ -CONFIG += testcase -TARGET = tst_qdeclarativetimer -macx:CONFIG -= app_bundle - -SOURCES += tst_qdeclarativetimer.cpp - -CONFIG += parallel_test -QT += core-private gui-private declarative-private quick-private gui testlib diff --git a/tests/auto/qtquick2/qdeclarativetimer/tst_qdeclarativetimer.cpp b/tests/auto/qtquick2/qdeclarativetimer/tst_qdeclarativetimer.cpp deleted file mode 100644 index 4aa35d7488..0000000000 --- a/tests/auto/qtquick2/qdeclarativetimer/tst_qdeclarativetimer.cpp +++ /dev/null @@ -1,393 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include -#include -#include -#include -#include -#include -#include - -class tst_qdeclarativetimer : public QObject -{ - Q_OBJECT -public: - tst_qdeclarativetimer(); - -private slots: - void notRepeating(); - void notRepeatingStart(); - void repeat(); - void noTriggerIfNotRunning(); - void triggeredOnStart(); - void triggeredOnStartRepeat(); - void changeDuration(); - void restart(); - void restartFromTriggered(); - void runningFromTriggered(); - void parentProperty(); -}; - -class TimerHelper : public QObject -{ - Q_OBJECT -public: - TimerHelper() : QObject(), count(0) - { - } - - int count; - -public slots: - void timeout() { - ++count; - } -}; - -#define TIMEOUT_TIMEOUT 200 - -tst_qdeclarativetimer::tst_qdeclarativetimer() -{ -} - -void tst_qdeclarativetimer::notRepeating() -{ - QDeclarativeEngine engine; - QDeclarativeComponent component(&engine); - component.setData(QByteArray("import QtQuick 2.0\nTimer { interval: 100; running: true }"), QUrl::fromLocalFile("")); - QDeclarativeTimer *timer = qobject_cast(component.create()); - QVERIFY(timer != 0); - QVERIFY(timer->isRunning()); - QVERIFY(!timer->isRepeating()); - QCOMPARE(timer->interval(), 100); - - TimerHelper helper; - connect(timer, SIGNAL(triggered()), &helper, SLOT(timeout())); - - QTest::qWait(TIMEOUT_TIMEOUT); - QCOMPARE(helper.count, 1); - QTest::qWait(TIMEOUT_TIMEOUT); - QCOMPARE(helper.count, 1); - QVERIFY(timer->isRunning() == false); -} - -void tst_qdeclarativetimer::notRepeatingStart() -{ - QDeclarativeEngine engine; - QDeclarativeComponent component(&engine); - component.setData(QByteArray("import QtQuick 2.0\nTimer { interval: 100 }"), QUrl::fromLocalFile("")); - QDeclarativeTimer *timer = qobject_cast(component.create()); - QVERIFY(timer != 0); - QVERIFY(!timer->isRunning()); - - TimerHelper helper; - connect(timer, SIGNAL(triggered()), &helper, SLOT(timeout())); - - QTest::qWait(TIMEOUT_TIMEOUT); - QCOMPARE(helper.count, 0); - - timer->start(); - QTest::qWait(TIMEOUT_TIMEOUT); - QCOMPARE(helper.count, 1); - QTest::qWait(TIMEOUT_TIMEOUT); - QCOMPARE(helper.count, 1); - QVERIFY(timer->isRunning() == false); - - delete timer; -} - -void tst_qdeclarativetimer::repeat() -{ - QDeclarativeEngine engine; - QDeclarativeComponent component(&engine); - component.setData(QByteArray("import QtQuick 2.0\nTimer { interval: 100; repeat: true; running: true }"), QUrl::fromLocalFile("")); - QDeclarativeTimer *timer = qobject_cast(component.create()); - QVERIFY(timer != 0); - - TimerHelper helper; - connect(timer, SIGNAL(triggered()), &helper, SLOT(timeout())); - QCOMPARE(helper.count, 0); - - QTest::qWait(TIMEOUT_TIMEOUT); - QVERIFY(helper.count > 0); - int oldCount = helper.count; - - QTest::qWait(TIMEOUT_TIMEOUT); - QVERIFY(helper.count > oldCount); - QVERIFY(timer->isRunning()); - - oldCount = helper.count; - timer->stop(); - - QTest::qWait(TIMEOUT_TIMEOUT); - QVERIFY(helper.count == oldCount); - QVERIFY(timer->isRunning() == false); - - QSignalSpy spy(timer, SIGNAL(repeatChanged())); - - timer->setRepeating(false); - QVERIFY(!timer->isRepeating()); - QCOMPARE(spy.count(),1); - - timer->setRepeating(false); - QCOMPARE(spy.count(),1); - - timer->setRepeating(true); - QCOMPARE(spy.count(),2); - - delete timer; -} - -void tst_qdeclarativetimer::triggeredOnStart() -{ - QDeclarativeEngine engine; - QDeclarativeComponent component(&engine); - component.setData(QByteArray("import QtQuick 2.0\nTimer { interval: 100; running: true; triggeredOnStart: true }"), QUrl::fromLocalFile("")); - QDeclarativeTimer *timer = qobject_cast(component.create()); - QVERIFY(timer != 0); - QVERIFY(timer->triggeredOnStart()); - - TimerHelper helper; - connect(timer, SIGNAL(triggered()), &helper, SLOT(timeout())); - QTest::qWait(1); - QCOMPARE(helper.count, 1); - - QTest::qWait(TIMEOUT_TIMEOUT); - QCOMPARE(helper.count, 2); - QTest::qWait(TIMEOUT_TIMEOUT); - QCOMPARE(helper.count, 2); - QVERIFY(timer->isRunning() == false); - - QSignalSpy spy(timer, SIGNAL(triggeredOnStartChanged())); - - timer->setTriggeredOnStart(false); - QVERIFY(!timer->triggeredOnStart()); - QCOMPARE(spy.count(),1); - - timer->setTriggeredOnStart(false); - QCOMPARE(spy.count(),1); - - timer->setTriggeredOnStart(true); - QCOMPARE(spy.count(),2); - - delete timer; -} - -void tst_qdeclarativetimer::triggeredOnStartRepeat() -{ - QDeclarativeEngine engine; - QDeclarativeComponent component(&engine); - component.setData(QByteArray("import QtQuick 2.0\nTimer { interval: 100; running: true; triggeredOnStart: true; repeat: true }"), QUrl::fromLocalFile("")); - QDeclarativeTimer *timer = qobject_cast(component.create()); - QVERIFY(timer != 0); - - TimerHelper helper; - connect(timer, SIGNAL(triggered()), &helper, SLOT(timeout())); - QTest::qWait(1); - QCOMPARE(helper.count, 1); - - QTest::qWait(TIMEOUT_TIMEOUT); - QVERIFY(helper.count > 1); - int oldCount = helper.count; - QTest::qWait(TIMEOUT_TIMEOUT); - QVERIFY(helper.count > oldCount); - QVERIFY(timer->isRunning()); - - delete timer; -} - -void tst_qdeclarativetimer::noTriggerIfNotRunning() -{ - QDeclarativeEngine engine; - QDeclarativeComponent component(&engine); - component.setData(QByteArray( - "import QtQuick 2.0\n" - "Item { property bool ok: true\n" - "Timer { id: t1; interval: 100; repeat: true; running: true; onTriggered: if (!running) ok=false }" - "Timer { interval: 10; running: true; onTriggered: t1.running=false }" - "}" - ), QUrl::fromLocalFile("")); - QObject *item = component.create(); - QVERIFY(item != 0); - QTest::qWait(TIMEOUT_TIMEOUT); - QCOMPARE(item->property("ok").toBool(), true); - - delete item; -} - -void tst_qdeclarativetimer::changeDuration() -{ - QDeclarativeEngine engine; - QDeclarativeComponent component(&engine); - component.setData(QByteArray("import QtQuick 2.0\nTimer { interval: 200; repeat: true; running: true }"), QUrl::fromLocalFile("")); - QDeclarativeTimer *timer = qobject_cast(component.create()); - QVERIFY(timer != 0); - - TimerHelper helper; - connect(timer, SIGNAL(triggered()), &helper, SLOT(timeout())); - QCOMPARE(helper.count, 0); - - QTest::qWait(500); - QCOMPARE(helper.count, 2); - - timer->setInterval(500); - - QTest::qWait(600); - QCOMPARE(helper.count, 3); - QVERIFY(timer->isRunning()); - - QSignalSpy spy(timer, SIGNAL(intervalChanged())); - - timer->setInterval(200); - QCOMPARE(timer->interval(), 200); - QCOMPARE(spy.count(),1); - - timer->setInterval(200); - QCOMPARE(spy.count(),1); - - timer->setInterval(300); - QCOMPARE(spy.count(),2); - - delete timer; -} - -void tst_qdeclarativetimer::restart() -{ - QDeclarativeEngine engine; - QDeclarativeComponent component(&engine); - component.setData(QByteArray("import QtQuick 2.0\nTimer { interval: 500; repeat: true; running: true }"), QUrl::fromLocalFile("")); - QDeclarativeTimer *timer = qobject_cast(component.create()); - QVERIFY(timer != 0); - - TimerHelper helper; - connect(timer, SIGNAL(triggered()), &helper, SLOT(timeout())); - QCOMPARE(helper.count, 0); - - QTest::qWait(600); - QCOMPARE(helper.count, 1); - - QTest::qWait(300); - - timer->restart(); - - QTest::qWait(700); - - QCOMPARE(helper.count, 2); - QVERIFY(timer->isRunning()); - - delete timer; -} - -void tst_qdeclarativetimer::restartFromTriggered() -{ - QDeclarativeEngine engine; - QDeclarativeComponent component(&engine); - component.setData(QByteArray("import QtQuick 2.0\nTimer { " - "interval: 500; " - "repeat: false; " - "running: true; " - "onTriggered: restart()" - " }"), QUrl::fromLocalFile("")); - QScopedPointer object(component.create()); - QDeclarativeTimer *timer = qobject_cast(object.data()); - QVERIFY(timer != 0); - - TimerHelper helper; - connect(timer, SIGNAL(triggered()), &helper, SLOT(timeout())); - QCOMPARE(helper.count, 0); - - QTest::qWait(600); - QCOMPARE(helper.count, 1); - QVERIFY(timer->isRunning()); - - QTest::qWait(600); - QCOMPARE(helper.count, 2); - QVERIFY(timer->isRunning()); -} - -void tst_qdeclarativetimer::runningFromTriggered() -{ - QDeclarativeEngine engine; - QDeclarativeComponent component(&engine); - component.setData(QByteArray("import QtQuick 2.0\nTimer { " - "property bool ok: false; " - "interval: 500; " - "repeat: false; " - "running: true; " - "onTriggered: { ok = !running; running = true }" - " }"), QUrl::fromLocalFile("")); - QScopedPointer object(component.create()); - QDeclarativeTimer *timer = qobject_cast(object.data()); - QVERIFY(timer != 0); - - TimerHelper helper; - connect(timer, SIGNAL(triggered()), &helper, SLOT(timeout())); - QCOMPARE(helper.count, 0); - - QTest::qWait(600); - QCOMPARE(helper.count, 1); - QVERIFY(timer->property("ok").toBool()); - QVERIFY(timer->isRunning()); - - QTest::qWait(600); - QCOMPARE(helper.count, 2); - QVERIFY(timer->property("ok").toBool()); - QVERIFY(timer->isRunning()); -} - -void tst_qdeclarativetimer::parentProperty() -{ - QDeclarativeEngine engine; - QDeclarativeComponent component(&engine); - component.setData(QByteArray("import QtQuick 2.0\nItem { Timer { objectName: \"timer\"; running: parent.visible } }"), QUrl::fromLocalFile("")); - QQuickItem *item = qobject_cast(component.create()); - QVERIFY(item != 0); - QDeclarativeTimer *timer = item->findChild("timer"); - QVERIFY(timer != 0); - - QVERIFY(timer->isRunning()); - - delete timer; -} - -QTEST_MAIN(tst_qdeclarativetimer) - -#include "tst_qdeclarativetimer.moc" diff --git a/tests/auto/qtquick2/qdeclarativexmllistmodel/data/empty.xml b/tests/auto/qtquick2/qdeclarativexmllistmodel/data/empty.xml deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/tests/auto/qtquick2/qdeclarativexmllistmodel/data/get.qml b/tests/auto/qtquick2/qdeclarativexmllistmodel/data/get.qml deleted file mode 100644 index 509da7174b..0000000000 --- a/tests/auto/qtquick2/qdeclarativexmllistmodel/data/get.qml +++ /dev/null @@ -1,61 +0,0 @@ -import QtQuick 2.0 -import QtQuick.XmlListModel 2.0 - -XmlListModel { - source: "model.xml" - query: "/Pets/Pet" - XmlRole { name: "name"; query: "name/string()" } - XmlRole { name: "type"; query: "type/string()" } - XmlRole { name: "age"; query: "age/number()" } - XmlRole { name: "size"; query: "size/string()" } - - id: root - - property bool preTest: false - property bool postTest: false - - function runPreTest() { - if (root.get(0) != undefined) - return; - - preTest = true; - } - - function runPostTest() { - if (root.get(-1) != undefined) - return; - - var row = root.get(0); - if (row.name != "Polly" || - row.type != "Parrot" || - row.age != 12 || - row.size != "Small") - return; - - row = root.get(1); - if (row.name != "Penny" || - row.type != "Turtle" || - row.age != 4 || - row.size != "Small") - return; - - row = root.get(7); - if (row.name != "Rover" || - row.type != "Dog" || - row.age != 0 || - row.size != "Large") - return; - - row = root.get(8); - if (row.name != "Tiny" || - row.type != "Elephant" || - row.age != 15 || - row.size != "Large") - return; - - if (root.get(9) != undefined) - return; - - postTest = true; - } -} diff --git a/tests/auto/qtquick2/qdeclarativexmllistmodel/data/model.qml b/tests/auto/qtquick2/qdeclarativexmllistmodel/data/model.qml deleted file mode 100644 index 2df3927479..0000000000 --- a/tests/auto/qtquick2/qdeclarativexmllistmodel/data/model.qml +++ /dev/null @@ -1,11 +0,0 @@ -import QtQuick 2.0 -import QtQuick.XmlListModel 2.0 - -XmlListModel { - source: "model.xml" - query: "/Pets/Pet" - XmlRole { name: "name"; query: "name/string()" } - XmlRole { name: "type"; query: "type/string()" } - XmlRole { name: "age"; query: "age/number()" } - XmlRole { name: "size"; query: "size/string()" } -} diff --git a/tests/auto/qtquick2/qdeclarativexmllistmodel/data/model.xml b/tests/auto/qtquick2/qdeclarativexmllistmodel/data/model.xml deleted file mode 100644 index 40cd6d0432..0000000000 --- a/tests/auto/qtquick2/qdeclarativexmllistmodel/data/model.xml +++ /dev/null @@ -1,54 +0,0 @@ - - - Polly - Parrot - 12 - Small - - - Penny - Turtle - 4 - Small - - - Warren - Rabbit - 2 - Small - - - Spot - Dog - 9 - Medium - - - Whiskers - Cat - 2 - Medium - - - Joey - Kangaroo - 1 - - - Kimba - Bunny - 65 - Large - - - Rover - Dog - Large - - - Tiny - Elephant - 15 - Large - - diff --git a/tests/auto/qtquick2/qdeclarativexmllistmodel/data/model2.xml b/tests/auto/qtquick2/qdeclarativexmllistmodel/data/model2.xml deleted file mode 100644 index dab2ec6dc0..0000000000 --- a/tests/auto/qtquick2/qdeclarativexmllistmodel/data/model2.xml +++ /dev/null @@ -1,14 +0,0 @@ - - - Polly - Parrot - 12 - Small - - - Penny - Turtle - 4 - Small - - diff --git a/tests/auto/qtquick2/qdeclarativexmllistmodel/data/propertychanges.qml b/tests/auto/qtquick2/qdeclarativexmllistmodel/data/propertychanges.qml deleted file mode 100644 index f8a97bffc3..0000000000 --- a/tests/auto/qtquick2/qdeclarativexmllistmodel/data/propertychanges.qml +++ /dev/null @@ -1,11 +0,0 @@ -import QtQuick 2.0 -import QtQuick.XmlListModel 2.0 - -XmlListModel { - source: "model.xml" - query: "/Pets/Pet" - XmlRole { objectName: "role"; name: "name"; query: "name/string()" } - XmlRole { name: "type"; query: "type/string()" } - XmlRole { name: "age"; query: "age/number()" } - XmlRole { name: "size"; query: "size/string()" } -} diff --git a/tests/auto/qtquick2/qdeclarativexmllistmodel/data/recipes.qml b/tests/auto/qtquick2/qdeclarativexmllistmodel/data/recipes.qml deleted file mode 100644 index dc609e95e3..0000000000 --- a/tests/auto/qtquick2/qdeclarativexmllistmodel/data/recipes.qml +++ /dev/null @@ -1,11 +0,0 @@ -import QtQuick 2.0 -import QtQuick.XmlListModel 2.0 - -XmlListModel { - source: "recipes.xml" - query: "/recipes/recipe" - XmlRole { name: "title"; query: "@title/string()" } - XmlRole { name: "picture"; query: "picture/string()" } - XmlRole { name: "ingredients"; query: "ingredients/string()" } - XmlRole { name: "preparation"; query: "method/string()" } -} diff --git a/tests/auto/qtquick2/qdeclarativexmllistmodel/data/recipes.xml b/tests/auto/qtquick2/qdeclarativexmllistmodel/data/recipes.xml deleted file mode 100644 index d71de60710..0000000000 --- a/tests/auto/qtquick2/qdeclarativexmllistmodel/data/recipes.xml +++ /dev/null @@ -1,90 +0,0 @@ - - - content/pics/pancakes.jpg - -
        -
      • 1 cup (150g) self-raising flour -
      • 1 tbs caster sugar -
      • 3/4 cup (185ml) milk -
      • 1 egg -
      - - ]]>
      - -
        -
      1. Sift flour and sugar together into a bowl. Add a pinch of salt. -
      2. Beat milk and egg together, then add to dry ingredients. Beat until smooth. -
      3. Pour mixture into a pan on medium heat and cook until bubbles appear on the surface. -
      4. Turn over and cook other side until golden. -
      - - ]]>
      -
      - - content/pics/fruit-salad.jpg - - - - - content/pics/vegetable-soup.jpg - -
        -
      • 1 onion -
      • 1 turnip -
      • 1 potato -
      • 1 carrot -
      • 1 head of celery -
      • 1 1/2 litres of water -
      - - ]]>
      - -
        -
      1. Chop vegetables. -
      2. Boil in water until vegetables soften. -
      3. Season with salt and pepper to taste. -
      - - ]]>
      -
      - - content/pics/hamburger.jpg - -
        -
      • 500g minced beef -
      • Seasoning -
      • lettuce, tomato, onion, cheese -
      • 1 hamburger bun for each burger -
      - - ]]>
      - -
        -
      1. Mix the beef, together with seasoning, in a food processor. -
      2. Shape the beef into burgers. -
      3. Grill the burgers for about 5 mins on each side (until cooked through) -
      4. Serve each burger on a bun with ketchup, cheese, lettuce, tomato and onion. -
      - - ]]>
      -
      - - content/pics/lemonade.jpg - -
        -
      • 1 cup Lemon Juice -
      • 1 cup Sugar -
      • 6 Cups of Water (2 cups warm water, 4 cups cold water) -
      - - ]]>
      - -
        -
      1. Pour 2 cups of warm water into a pitcher and stir in sugar until it dissolves. -
      2. Pour in lemon juice, stir again, and add 4 cups of cold water. -
      3. Chill or serve over ice cubes. -
      - - ]]>
      -
      -
      diff --git a/tests/auto/qtquick2/qdeclarativexmllistmodel/data/roleCrash.qml b/tests/auto/qtquick2/qdeclarativexmllistmodel/data/roleCrash.qml deleted file mode 100644 index 6a7059bb45..0000000000 --- a/tests/auto/qtquick2/qdeclarativexmllistmodel/data/roleCrash.qml +++ /dev/null @@ -1,8 +0,0 @@ -import QtQuick 2.0 -import QtQuick.XmlListModel 2.0 - -XmlListModel { - id: model - XmlRole {} - Component.onCompleted: model.roles = 0 -} diff --git a/tests/auto/qtquick2/qdeclarativexmllistmodel/data/roleErrors.qml b/tests/auto/qtquick2/qdeclarativexmllistmodel/data/roleErrors.qml deleted file mode 100644 index 91664b6d4a..0000000000 --- a/tests/auto/qtquick2/qdeclarativexmllistmodel/data/roleErrors.qml +++ /dev/null @@ -1,11 +0,0 @@ -import QtQuick 2.0 -import QtQuick.XmlListModel 2.0 - -XmlListModel { - source: "model.xml" - query: "/Pets/Pet" - XmlRole { name: "name"; query: "/name/string()" } //starts with '/' - XmlRole { name: "type"; query: "type" } //no type - XmlRole { name: "age"; query: "age/" } //ends with '/' - XmlRole { name: "size"; query: "size/number()" } //wrong type -} diff --git a/tests/auto/qtquick2/qdeclarativexmllistmodel/data/roleKeys.qml b/tests/auto/qtquick2/qdeclarativexmllistmodel/data/roleKeys.qml deleted file mode 100644 index 9f667d86e5..0000000000 --- a/tests/auto/qtquick2/qdeclarativexmllistmodel/data/roleKeys.qml +++ /dev/null @@ -1,13 +0,0 @@ -import QtQuick 2.0 -import QtQuick.XmlListModel 2.0 - -XmlListModel { - query: "/data/item" - XmlRole { id: nameRole; name: "name"; query: "name/string()"; isKey: true } - XmlRole { name: "age"; query: "age/number()"; isKey: true } - XmlRole { name: "sport"; query: "sport/string()" } - - function disableNameKey() { - nameRole.isKey = false; - } -} diff --git a/tests/auto/qtquick2/qdeclarativexmllistmodel/data/testtypes.qml b/tests/auto/qtquick2/qdeclarativexmllistmodel/data/testtypes.qml deleted file mode 100644 index 5ec1ffa35f..0000000000 --- a/tests/auto/qtquick2/qdeclarativexmllistmodel/data/testtypes.qml +++ /dev/null @@ -1,8 +0,0 @@ -import QtQuick 2.0 -import QtQuick.XmlListModel 2.0 - -XmlListModel { - query: "/data" - XmlRole { name: "stringValue"; query: "a-string/string()" } - XmlRole { name: "numberValue"; query: "a-number/number()" } -} diff --git a/tests/auto/qtquick2/qdeclarativexmllistmodel/data/unique.qml b/tests/auto/qtquick2/qdeclarativexmllistmodel/data/unique.qml deleted file mode 100644 index 322a2e4e5c..0000000000 --- a/tests/auto/qtquick2/qdeclarativexmllistmodel/data/unique.qml +++ /dev/null @@ -1,9 +0,0 @@ -import QtQuick 2.0 -import QtQuick.XmlListModel 2.0 - -XmlListModel { - source: "model.xml" - query: "/Pets/Pet" - XmlRole { name: "name"; query: "name/string()" } - XmlRole { name: "name"; query: "type/string()" } -} diff --git a/tests/auto/qtquick2/qdeclarativexmllistmodel/qdeclarativexmllistmodel.pro b/tests/auto/qtquick2/qdeclarativexmllistmodel/qdeclarativexmllistmodel.pro deleted file mode 100644 index 37f1c65c92..0000000000 --- a/tests/auto/qtquick2/qdeclarativexmllistmodel/qdeclarativexmllistmodel.pro +++ /dev/null @@ -1,15 +0,0 @@ -CONFIG += testcase -TARGET = tst_qdeclarativexmllistmodel -macx:CONFIG -= app_bundle - -SOURCES += tst_qdeclarativexmllistmodel.cpp - -include (../../shared/util.pri) - -testDataFiles.files = data -testDataFiles.path = . -DEPLOYMENT += testDataFiles - -CONFIG += parallel_test - -QT += core-private gui-private v8-private declarative-private network testlib xmlpatterns diff --git a/tests/auto/qtquick2/qdeclarativexmllistmodel/tst_qdeclarativexmllistmodel.cpp b/tests/auto/qtquick2/qdeclarativexmllistmodel/tst_qdeclarativexmllistmodel.cpp deleted file mode 100644 index 80ceb9a712..0000000000 --- a/tests/auto/qtquick2/qdeclarativexmllistmodel/tst_qdeclarativexmllistmodel.cpp +++ /dev/null @@ -1,962 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "../../shared/util.h" -#include - -#include -#include -#include -#include "../../../../src/imports/xmllistmodel/qdeclarativexmllistmodel_p.h" - -typedef QPair QDeclarativeXmlListRange; -typedef QList QDeclarativeXmlModelData; - -Q_DECLARE_METATYPE(QList) -Q_DECLARE_METATYPE(QDeclarativeXmlModelData) -Q_DECLARE_METATYPE(QDeclarativeXmlListModel::Status) - -class tst_qdeclarativexmllistmodel : public QDeclarativeDataTest - -{ - Q_OBJECT -public: - tst_qdeclarativexmllistmodel() {} - -private slots: - void initTestCase() { - QDeclarativeDataTest::initTestCase(); - qRegisterMetaType(); - } - - void buildModel(); - void testTypes(); - void testTypes_data(); - void cdata(); - void attributes(); - void roles(); - void roleErrors(); - void uniqueRoleNames(); - void headers(); - void xml(); - void xml_data(); - void source(); - void source_data(); - void data(); - void get(); - void reload(); - void useKeys(); - void useKeys_data(); - void noKeysValueChanges(); - void keysChanged(); - void threading(); - void threading_data(); - void propertyChanges(); - - void roleCrash(); - -private: - QString errorString(QListModelInterface* model) { - QString ret; - QMetaObject::invokeMethod(model, "errorString", Q_RETURN_ARG(QString, ret)); - return ret; - } - - QString makeItemXmlAndData(const QString &data, QDeclarativeXmlModelData *modelData = 0) const - { - if (modelData) - modelData->clear(); - QString xml; - - if (!data.isEmpty()) { - QStringList items = data.split(";"); - foreach(const QString &item, items) { - if (item.isEmpty()) - continue; - QVariantList variants; - xml += QLatin1String(""); - QStringList fields = item.split(","); - foreach(const QString &field, fields) { - QStringList values = field.split("="); - if (values.count() != 2) { - qWarning() << "makeItemXmlAndData: invalid field:" << field; - continue; - } - xml += QString("<%1>%2").arg(values[0], values[1]); - if (!modelData) - continue; - bool isNum = false; - int number = values[1].toInt(&isNum); - if (isNum) - variants << number; - else - variants << values[1]; - } - xml += QLatin1String(""); - if (modelData) - modelData->append(variants); - } - } - - QString decl = ""; - return decl + QLatin1String("") + xml + QLatin1String(""); - } - - QDeclarativeEngine engine; -}; - -class CustomNetworkAccessManagerFactory : public QObject, public QDeclarativeNetworkAccessManagerFactory -{ - Q_OBJECT -public: - QVariantMap lastSentHeaders; - -protected: - QNetworkAccessManager *create(QObject *parent); -}; - -class CustomNetworkAccessManager : public QNetworkAccessManager -{ - Q_OBJECT -public: - CustomNetworkAccessManager(CustomNetworkAccessManagerFactory *factory, QObject *parent) - : QNetworkAccessManager(parent), m_factory(factory) {} - -protected: - QNetworkReply *createRequest(Operation op, const QNetworkRequest &req, QIODevice * outgoingData = 0) - { - if (m_factory) { - QVariantMap map; - foreach (const QString &header, req.rawHeaderList()) - map[header] = req.rawHeader(header.toUtf8()); - m_factory->lastSentHeaders = map; - } - return QNetworkAccessManager::createRequest(op, req, outgoingData); - } - - QPointer m_factory; -}; - -QNetworkAccessManager *CustomNetworkAccessManagerFactory::create(QObject *parent) -{ - return new CustomNetworkAccessManager(this, parent); -} - - -void tst_qdeclarativexmllistmodel::buildModel() -{ - QDeclarativeComponent component(&engine, testFileUrl("model.qml")); - QListModelInterface *model = qobject_cast(component.create()); - QVERIFY(model != 0); - QTRY_COMPARE(model->count(), 9); - - QCOMPARE(model->data(3, Qt::UserRole).toString(), QLatin1String("Spot")); - QCOMPARE(model->data(3, Qt::UserRole+1).toString(), QLatin1String("Dog")); - QCOMPARE(model->data(3, Qt::UserRole+2).toInt(), 9); - QCOMPARE(model->data(3, Qt::UserRole+3).toString(), QLatin1String("Medium")); - - delete model; -} - -void tst_qdeclarativexmllistmodel::testTypes() -{ - QFETCH(QString, xml); - QFETCH(QString, roleName); - QFETCH(QVariant, expectedValue); - - QDeclarativeComponent component(&engine, testFileUrl("testtypes.qml")); - QListModelInterface *model = qobject_cast(component.create()); - QVERIFY(model != 0); - model->setProperty("xml",xml.toUtf8()); - QMetaObject::invokeMethod(model, "reload"); - QTRY_COMPARE(model->count(), 1); - - int role = -1; - foreach (int i, model->roles()) { - if (model->toString(i) == roleName) { - role = i; - break; - } - } - QVERIFY(role >= 0); - - if (expectedValue.toString() == "nan") - QVERIFY(qIsNaN(model->data(0, role).toDouble())); - else - QCOMPARE(model->data(0, role), expectedValue); - - delete model; -} - -void tst_qdeclarativexmllistmodel::testTypes_data() -{ - QTest::addColumn("xml"); - QTest::addColumn("roleName"); - QTest::addColumn("expectedValue"); - - QTest::newRow("missing string field") << "" - << "stringValue" << QVariant(""); - QTest::newRow("empty string") << "" - << "stringValue" << QVariant(""); - QTest::newRow("1-char string") << "5" - << "stringValue" << QVariant("5"); - QTest::newRow("string ok") << "abc def g" - << "stringValue" << QVariant("abc def g"); - - QTest::newRow("missing number field") << "" - << "numberValue" << QVariant(""); - double nan = qQNaN(); - QTest::newRow("empty number field") << "" - << "numberValue" << QVariant(nan); - QTest::newRow("number field with string") << "a string" - << "numberValue" << QVariant(nan); - QTest::newRow("-1") << "-1" - << "numberValue" << QVariant("-1"); - QTest::newRow("-1.5") << "-1.5" - << "numberValue" << QVariant("-1.5"); - QTest::newRow("0") << "0" - << "numberValue" << QVariant("0"); - QTest::newRow("+1") << "1" - << "numberValue" << QVariant("1"); - QTest::newRow("+1.5") << "1.5" - << "numberValue" << QVariant("1.5"); -} - -void tst_qdeclarativexmllistmodel::cdata() -{ - QDeclarativeComponent component(&engine, testFileUrl("recipes.qml")); - QListModelInterface *model = qobject_cast(component.create()); - QVERIFY(model != 0); - QTRY_COMPARE(model->count(), 5); - - QVERIFY(model->data(2, Qt::UserRole+2).toString().startsWith(QLatin1String(""))); - - delete model; -} - -void tst_qdeclarativexmllistmodel::attributes() -{ - QDeclarativeComponent component(&engine, testFileUrl("recipes.qml")); - QListModelInterface *model = qobject_cast(component.create()); - QVERIFY(model != 0); - QTRY_COMPARE(model->count(), 5); - QCOMPARE(model->data(2, Qt::UserRole).toString(), QLatin1String("Vegetable Soup")); - - delete model; -} - -void tst_qdeclarativexmllistmodel::roles() -{ - QDeclarativeComponent component(&engine, testFileUrl("model.qml")); - QListModelInterface *model = qobject_cast(component.create()); - QVERIFY(model != 0); - QTRY_COMPARE(model->count(), 9); - - QList roles = model->roles(); - QCOMPARE(roles.count(), 4); - QCOMPARE(model->toString(roles.at(0)), QLatin1String("name")); - QCOMPARE(model->toString(roles.at(1)), QLatin1String("type")); - QCOMPARE(model->toString(roles.at(2)), QLatin1String("age")); - QCOMPARE(model->toString(roles.at(3)), QLatin1String("size")); - - delete model; -} - -void tst_qdeclarativexmllistmodel::roleErrors() -{ - QDeclarativeComponent component(&engine, testFileUrl("roleErrors.qml")); - QTest::ignoreMessage(QtWarningMsg, (testFileUrl("roleErrors.qml").toString() + ":7:5: QML XmlRole: An XmlRole query must not start with '/'").toUtf8().constData()); - QTest::ignoreMessage(QtWarningMsg, (testFileUrl("roleErrors.qml").toString() + ":10:5: QML XmlRole: invalid query: \"age/\"").toUtf8().constData()); - - //### make sure we receive all expected warning messages. - QListModelInterface *model = qobject_cast(component.create()); - QVERIFY(model != 0); - QTRY_COMPARE(model->count(), 9); - - - //### should any of these return valid values? - QCOMPARE(model->data(3, Qt::UserRole), QVariant()); - QCOMPARE(model->data(3, Qt::UserRole+1), QVariant()); - QCOMPARE(model->data(3, Qt::UserRole+2), QVariant()); - - QEXPECT_FAIL("", "QTBUG-10797", Continue); - QCOMPARE(model->data(3, Qt::UserRole+3), QVariant()); - - delete model; -} - -void tst_qdeclarativexmllistmodel::uniqueRoleNames() -{ - QDeclarativeComponent component(&engine, testFileUrl("unique.qml")); - QTest::ignoreMessage(QtWarningMsg, (testFileUrl("unique.qml").toString() + ":8:5: QML XmlRole: \"name\" duplicates a previous role name and will be disabled.").toUtf8().constData()); - QListModelInterface *model = qobject_cast(component.create()); - QVERIFY(model != 0); - QTRY_COMPARE(model->count(), 9); - - QList roles = model->roles(); - QCOMPARE(roles.count(), 1); - - delete model; -} - - -void tst_qdeclarativexmllistmodel::xml() -{ - QFETCH(QString, xml); - QFETCH(int, count); - - QDeclarativeComponent component(&engine, testFileUrl("model.qml")); - QListModelInterface *model = qobject_cast(component.create()); - - QSignalSpy spy(model, SIGNAL(statusChanged(QDeclarativeXmlListModel::Status))); - QVERIFY(errorString(model).isEmpty()); - QCOMPARE(model->property("progress").toDouble(), qreal(0.0)); - QCOMPARE(qvariant_cast(model->property("status")), - QDeclarativeXmlListModel::Loading); - QTRY_COMPARE(spy.count(), 1); spy.clear(); - QTest::qWait(50); - QCOMPARE(qvariant_cast(model->property("status")), - QDeclarativeXmlListModel::Ready); - QVERIFY(errorString(model).isEmpty()); - QCOMPARE(model->property("progress").toDouble(), qreal(1.0)); - QCOMPARE(model->count(), 9); - - // if xml is empty (i.e. clearing) it won't have any effect if a source is set - if (xml.isEmpty()) - model->setProperty("source",QUrl()); - model->setProperty("xml",xml); - QCOMPARE(model->property("progress").toDouble(), qreal(1.0)); // immediately goes to 1.0 if using setXml() - QTRY_COMPARE(spy.count(), 1); spy.clear(); - QCOMPARE(qvariant_cast(model->property("status")), - QDeclarativeXmlListModel::Loading); - QTRY_COMPARE(spy.count(), 1); spy.clear(); - if (xml.isEmpty()) - QCOMPARE(qvariant_cast(model->property("status")), - QDeclarativeXmlListModel::Null); - else - QCOMPARE(qvariant_cast(model->property("status")), - QDeclarativeXmlListModel::Ready); - QVERIFY(errorString(model).isEmpty()); - QCOMPARE(model->count(), count); - - delete model; -} - -void tst_qdeclarativexmllistmodel::xml_data() -{ - QTest::addColumn("xml"); - QTest::addColumn("count"); - - QTest::newRow("xml with no items") << "" << 0; - QTest::newRow("empty xml") << "" << 0; - QTest::newRow("one item") << "HobbesTiger7Large" << 1; -} - -void tst_qdeclarativexmllistmodel::headers() -{ - // ensure the QNetworkAccessManagers created for this test are immediately deleted - QDeclarativeEngine qmlEng; - - CustomNetworkAccessManagerFactory factory; - qmlEng.setNetworkAccessManagerFactory(&factory); - - QDeclarativeComponent component(&qmlEng, testFileUrl("model.qml")); - QListModelInterface *model = qobject_cast(component.create()); - QVERIFY(model != 0); - QTRY_COMPARE(qvariant_cast(model->property("status")), - QDeclarativeXmlListModel::Ready); - - QVariantMap expectedHeaders; - expectedHeaders["Accept"] = "application/xml,*/*"; - - QCOMPARE(factory.lastSentHeaders.count(), expectedHeaders.count()); - foreach (const QString &header, expectedHeaders.keys()) { - QVERIFY(factory.lastSentHeaders.contains(header)); - QCOMPARE(factory.lastSentHeaders[header].toString(), expectedHeaders[header].toString()); - } - - delete model; -} - -void tst_qdeclarativexmllistmodel::source() -{ - QFETCH(QUrl, source); - QFETCH(int, count); - QFETCH(QDeclarativeXmlListModel::Status, status); - - QDeclarativeComponent component(&engine, testFileUrl("model.qml")); - QListModelInterface *model = qobject_cast(component.create()); - QSignalSpy spy(model, SIGNAL(statusChanged(QDeclarativeXmlListModel::Status))); - - QVERIFY(errorString(model).isEmpty()); - QCOMPARE(model->property("progress").toDouble(), qreal(0.0)); - QCOMPARE(qvariant_cast(model->property("status")), - QDeclarativeXmlListModel::Loading); - QTRY_COMPARE(spy.count(), 1); spy.clear(); - QCOMPARE(qvariant_cast(model->property("status")), - QDeclarativeXmlListModel::Ready); - QVERIFY(errorString(model).isEmpty()); - QCOMPARE(model->property("progress").toDouble(), qreal(1.0)); - QCOMPARE(model->count(), 9); - - model->setProperty("source",source); - if (model->property("source").toString().isEmpty()) - QCOMPARE(qvariant_cast(model->property("status")), - QDeclarativeXmlListModel::Null); - QCOMPARE(model->property("progress").toDouble(), qreal(0.0)); - QTRY_COMPARE(spy.count(), 1); spy.clear(); - QCOMPARE(qvariant_cast(model->property("status")), - QDeclarativeXmlListModel::Loading); - QVERIFY(errorString(model).isEmpty()); - - QEventLoop loop; - QTimer timer; - timer.setSingleShot(true); - connect(model, SIGNAL(statusChanged(QDeclarativeXmlListModel::Status)), &loop, SLOT(quit())); - connect(&timer, SIGNAL(timeout()), &loop, SLOT(quit())); - timer.start(20000); - loop.exec(); - - if (spy.count() == 0 && status != QDeclarativeXmlListModel::Ready) { - qWarning("QDeclarativeXmlListModel invalid source test timed out"); - } else { - QCOMPARE(spy.count(), 1); spy.clear(); - } - - QCOMPARE(qvariant_cast(model->property("status")), status); - QCOMPARE(model->count(), count); - - if (status == QDeclarativeXmlListModel::Ready) - QCOMPARE(model->property("progress").toDouble(), qreal(1.0)); - - QCOMPARE(errorString(model).isEmpty(), status == QDeclarativeXmlListModel::Ready); - - delete model; -} - -void tst_qdeclarativexmllistmodel::source_data() -{ - QTest::addColumn("source"); - QTest::addColumn("count"); - QTest::addColumn("status"); - - QTest::newRow("valid") << testFileUrl("model2.xml") << 2 - << QDeclarativeXmlListModel::Ready; - QTest::newRow("invalid") << QUrl("http://blah.blah/blah.xml") << 0 - << QDeclarativeXmlListModel::Error; - - // empty file - QTemporaryFile *temp = new QTemporaryFile(this); - if (temp->open()) - QTest::newRow("empty file") << QUrl::fromLocalFile(temp->fileName()) << 0 - << QDeclarativeXmlListModel::Ready; - temp->close(); -} - -void tst_qdeclarativexmllistmodel::data() -{ - QDeclarativeComponent component(&engine, testFileUrl("model.qml")); - QListModelInterface *model = qobject_cast(component.create()); - QVERIFY(model != 0); - - for (int i=0; i<9; i++) { - for (int j=0; jroles().count(); j++) { - QCOMPARE(model->data(i, j), QVariant()); - } - } - QTRY_COMPARE(model->count(), 9); - - delete model; -} - -void tst_qdeclarativexmllistmodel::get() -{ - QDeclarativeComponent component(&engine, testFileUrl("get.qml")); - QListModelInterface *model = qobject_cast(component.create()); - - QVERIFY(model != 0); - - QVERIFY(QMetaObject::invokeMethod(model, "runPreTest")); - QCOMPARE(model->property("preTest").toBool(), true); - - QTRY_COMPARE(model->count(), 9); - - QVERIFY(QMetaObject::invokeMethod(model, "runPostTest")); - QCOMPARE(model->property("postTest").toBool(), true); - - delete model; -} - -void tst_qdeclarativexmllistmodel::reload() -{ - // If no keys are used, the model should be rebuilt from scratch when - // reload() is called. - - QDeclarativeComponent component(&engine, testFileUrl("model.qml")); - QListModelInterface *model = qobject_cast(component.create()); - QVERIFY(model != 0); - QTRY_COMPARE(model->count(), 9); - - QSignalSpy spyInsert(model, SIGNAL(itemsInserted(int,int))); - QSignalSpy spyRemove(model, SIGNAL(itemsRemoved(int,int))); - QSignalSpy spyCount(model, SIGNAL(countChanged())); - //reload multiple times to test the xml query aborting - QMetaObject::invokeMethod(model, "reload"); - QMetaObject::invokeMethod(model, "reload"); - QCoreApplication::processEvents(); - QMetaObject::invokeMethod(model, "reload"); - QMetaObject::invokeMethod(model, "reload"); - QTRY_COMPARE(spyCount.count(), 1); - QTRY_COMPARE(spyInsert.count(), 1); - QTRY_COMPARE(spyRemove.count(), 1); - - QCOMPARE(spyInsert[0][0].toInt(), 0); - QCOMPARE(spyInsert[0][1].toInt(), 9); - - QCOMPARE(spyRemove[0][0].toInt(), 0); - QCOMPARE(spyRemove[0][1].toInt(), 9); - - delete model; -} - -void tst_qdeclarativexmllistmodel::useKeys() -{ - // If using incremental updates through keys, the model should only - // insert & remove some of the items, instead of throwing everything - // away and causing the view to repaint the whole view. - - QFETCH(QString, oldXml); - QFETCH(int, oldCount); - QFETCH(QString, newXml); - QFETCH(QDeclarativeXmlModelData, newData); - QFETCH(QList, insertRanges); - QFETCH(QList, removeRanges); - - QDeclarativeComponent component(&engine, testFileUrl("roleKeys.qml")); - QListModelInterface *model = qobject_cast(component.create()); - QVERIFY(model != 0); - - model->setProperty("xml",oldXml); - QTRY_COMPARE(model->count(), oldCount); - - QSignalSpy spyInsert(model, SIGNAL(itemsInserted(int,int))); - QSignalSpy spyRemove(model, SIGNAL(itemsRemoved(int,int))); - QSignalSpy spyCount(model, SIGNAL(countChanged())); - - model->setProperty("xml",newXml); - - if (oldCount != newData.count()) { - QTRY_COMPARE(model->count(), newData.count()); - QCOMPARE(spyCount.count(), 1); - } else { - QTRY_VERIFY(spyInsert.count() > 0 || spyRemove.count() > 0); - QCOMPARE(spyCount.count(), 0); - } - - QList roles = model->roles(); - for (int i=0; icount(); i++) { - for (int j=0; jdata(i, roles[j]), newData[i][j]); - } - - QCOMPARE(spyInsert.count(), insertRanges.count()); - for (int i=0; i("oldXml"); - QTest::addColumn("oldCount"); - QTest::addColumn("newXml"); - QTest::addColumn("newData"); - QTest::addColumn >("insertRanges"); - QTest::addColumn >("removeRanges"); - - QDeclarativeXmlModelData modelData; - - QTest::newRow("append 1") - << makeItemXmlAndData("name=A,age=25,sport=Football") << 1 - << makeItemXmlAndData("name=A,age=25,sport=Football;name=B,age=35,sport=Athletics", &modelData) - << modelData - << (QList() << qMakePair(1, 1)) - << QList(); - - QTest::newRow("append multiple") - << makeItemXmlAndData("name=A,age=25,sport=Football") << 1 - << makeItemXmlAndData("name=A,age=25,sport=Football;name=B,age=35,sport=Athletics;name=C,age=45,sport=Curling", &modelData) - << modelData - << (QList() << qMakePair(1, 2)) - << QList(); - - QTest::newRow("insert in different spots") - << makeItemXmlAndData("name=B,age=35,sport=Athletics") << 1 - << makeItemXmlAndData("name=A,age=25,sport=Football;name=B,age=35,sport=Athletics;name=C,age=45,sport=Curling;name=D,age=55,sport=Golf", &modelData) - << modelData - << (QList() << qMakePair(0, 1) << qMakePair(2,2)) - << QList(); - - QTest::newRow("insert in middle") - << makeItemXmlAndData("name=A,age=25,sport=Football;name=D,age=55,sport=Golf") << 2 - << makeItemXmlAndData("name=A,age=25,sport=Football;name=B,age=35,sport=Athletics;name=C,age=45,sport=Curling;name=D,age=55,sport=Golf", &modelData) - << modelData - << (QList() << qMakePair(1, 2)) - << QList(); - - QTest::newRow("remove first") - << makeItemXmlAndData("name=A,age=25,sport=Football;name=B,age=35,sport=Athletics") << 2 - << makeItemXmlAndData("name=B,age=35,sport=Athletics", &modelData) - << modelData - << QList() - << (QList() << qMakePair(0, 1)); - - QTest::newRow("remove last") - << makeItemXmlAndData("name=A,age=25,sport=Football;name=B,age=35,sport=Athletics") << 2 - << makeItemXmlAndData("name=A,age=25,sport=Football", &modelData) - << modelData - << QList() - << (QList() << qMakePair(1, 1)); - - QTest::newRow("remove from multiple spots") - << makeItemXmlAndData("name=A,age=25,sport=Football;name=B,age=35,sport=Athletics;name=C,age=45,sport=Curling;name=D,age=55,sport=Golf;name=E,age=65,sport=Fencing") << 5 - << makeItemXmlAndData("name=A,age=25,sport=Football;name=C,age=45,sport=Curling", &modelData) - << modelData - << QList() - << (QList() << qMakePair(1, 1) << qMakePair(3,2)); - - QTest::newRow("remove all") - << makeItemXmlAndData("name=A,age=25,sport=Football;name=B,age=35,sport=Athletics;name=C,age=45,sport=Curling") << 3 - << makeItemXmlAndData("", &modelData) - << modelData - << QList() - << (QList() << qMakePair(0, 3)); - - QTest::newRow("replace item") - << makeItemXmlAndData("name=A,age=25,sport=Football") << 1 - << makeItemXmlAndData("name=ZZZ,age=25,sport=Football", &modelData) - << modelData - << (QList() << qMakePair(0, 1)) - << (QList() << qMakePair(0, 1)); - - QTest::newRow("add and remove simultaneously, in different spots") - << makeItemXmlAndData("name=A,age=25,sport=Football;name=B,age=35,sport=Athletics;name=C,age=45,sport=Curling;name=D,age=55,sport=Golf") << 4 - << makeItemXmlAndData("name=B,age=35,sport=Athletics;name=E,age=65,sport=Fencing", &modelData) - << modelData - << (QList() << qMakePair(1, 1)) - << (QList() << qMakePair(0, 1) << qMakePair(2,2)); - - QTest::newRow("insert at start, remove at end i.e. rss feed") - << makeItemXmlAndData("name=C,age=45,sport=Curling;name=D,age=55,sport=Golf;name=E,age=65,sport=Fencing") << 3 - << makeItemXmlAndData("name=A,age=25,sport=Football;name=B,age=35,sport=Athletics;name=C,age=45,sport=Curling", &modelData) - << modelData - << (QList() << qMakePair(0, 2)) - << (QList() << qMakePair(1, 2)); - - QTest::newRow("remove at start, insert at end") - << makeItemXmlAndData("name=A,age=25,sport=Football;name=B,age=35,sport=Athletics;name=C,age=45,sport=Curling") << 3 - << makeItemXmlAndData("name=C,age=45,sport=Curling;name=D,age=55,sport=Golf;name=E,age=65,sport=Fencing", &modelData) - << modelData - << (QList() << qMakePair(1, 2)) - << (QList() << qMakePair(0, 2)); - - QTest::newRow("all data has changed") - << makeItemXmlAndData("name=A,age=25,sport=Football;name=B,age=35") << 2 - << makeItemXmlAndData("name=C,age=45,sport=Curling;name=D,age=55,sport=Golf", &modelData) - << modelData - << (QList() << qMakePair(0, 2)) - << (QList() << qMakePair(0, 2)); -} - -void tst_qdeclarativexmllistmodel::noKeysValueChanges() -{ - // The 'key' roles are 'name' and 'age', as defined in roleKeys.qml. - // If a 'sport' value is changed, the model should not be reloaded, - // since 'sport' is not marked as a key. - - QDeclarativeComponent component(&engine, testFileUrl("roleKeys.qml")); - QListModelInterface *model = qobject_cast(component.create()); - QVERIFY(model != 0); - - QString xml; - - xml = makeItemXmlAndData("name=A,age=25,sport=Football;name=B,age=35,sport=Athletics"); - model->setProperty("xml",xml); - QTRY_COMPARE(model->count(), 2); - - model->setProperty("xml",""); - - QSignalSpy spyInsert(model, SIGNAL(itemsInserted(int,int))); - QSignalSpy spyRemove(model, SIGNAL(itemsRemoved(int,int))); - QSignalSpy spyCount(model, SIGNAL(countChanged())); - - xml = makeItemXmlAndData("name=A,age=25,sport=AussieRules;name=B,age=35,sport=Athletics"); - model->setProperty("xml",xml); - - // wait for the new xml data to be set, and verify no signals were emitted - QTRY_VERIFY(model->data(0, model->roles()[2]).toString() != QLatin1String("Football")); - QCOMPARE(model->data(0, model->roles()[2]).toString(), QLatin1String("AussieRules")); - - QVERIFY(spyInsert.count() == 0); - QVERIFY(spyRemove.count() == 0); - QVERIFY(spyCount.count() == 0); - - QCOMPARE(model->count(), 2); - - delete model; -} - -void tst_qdeclarativexmllistmodel::keysChanged() -{ - // If the key roles change, the next time the data is reloaded, it should - // delete all its data and build a clean model (i.e. same behaviour as - // if no keys are set). - - QDeclarativeComponent component(&engine, testFileUrl("roleKeys.qml")); - QListModelInterface *model = qobject_cast(component.create()); - QVERIFY(model != 0); - - QString xml = makeItemXmlAndData("name=A,age=25,sport=Football;name=B,age=35,sport=Athletics"); - model->setProperty("xml",xml); - QTRY_COMPARE(model->count(), 2); - - model->setProperty("xml",""); - - QSignalSpy spyInsert(model, SIGNAL(itemsInserted(int,int))); - QSignalSpy spyRemove(model, SIGNAL(itemsRemoved(int,int))); - QSignalSpy spyCount(model, SIGNAL(countChanged())); - - QVERIFY(QMetaObject::invokeMethod(model, "disableNameKey")); - model->setProperty("xml",xml); - - QTRY_VERIFY(spyInsert.count() > 0 && spyRemove.count() > 0); - - QCOMPARE(spyInsert.count(), 1); - QCOMPARE(spyInsert[0][0].toInt(), 0); - QCOMPARE(spyInsert[0][1].toInt(), 2); - - QCOMPARE(spyRemove.count(), 1); - QCOMPARE(spyRemove[0][0].toInt(), 0); - QCOMPARE(spyRemove[0][1].toInt(), 2); - - QCOMPARE(spyCount.count(), 0); - - delete model; -} - -void tst_qdeclarativexmllistmodel::threading() -{ - QFETCH(int, xmlDataCount); - - QDeclarativeComponent component(&engine, testFileUrl("roleKeys.qml")); - - QListModelInterface *m1 = qobject_cast(component.create()); - QVERIFY(m1 != 0); - QListModelInterface *m2 = qobject_cast(component.create()); - QVERIFY(m2 != 0); - QListModelInterface *m3 = qobject_cast(component.create()); - QVERIFY(m3 != 0); - - for (int dataCount=0; dataCountsetProperty("xml",makeItemXmlAndData(data1)); - m2->setProperty("xml",makeItemXmlAndData(data2)); - m3->setProperty("xml",makeItemXmlAndData(data3)); - QCoreApplication::processEvents(); - m2->setProperty("xml",makeItemXmlAndData(data2)); - m1->setProperty("xml",makeItemXmlAndData(data1)); - m2->setProperty("xml",makeItemXmlAndData(data2)); - QCoreApplication::processEvents(); - m3->setProperty("xml",makeItemXmlAndData(data3)); - QCoreApplication::processEvents(); - m2->setProperty("xml",makeItemXmlAndData(data2)); - m1->setProperty("xml",makeItemXmlAndData(data1)); - m2->setProperty("xml",makeItemXmlAndData(data2)); - m3->setProperty("xml",makeItemXmlAndData(data3)); - QCoreApplication::processEvents(); - m2->setProperty("xml",makeItemXmlAndData(data2)); - m3->setProperty("xml",makeItemXmlAndData(data3)); - m3->setProperty("xml",makeItemXmlAndData(data3)); - QCoreApplication::processEvents(); - - QTRY_VERIFY(m1->count() == dataCount && m2->count() == dataCount && m3->count() == dataCount); - - for (int i=0; idata(i, m1->roles()[0]).toString(), QString("A" + QString::number(i))); - QCOMPARE(m1->data(i, m1->roles()[1]).toString(), QString("1" + QString::number(i))); - QCOMPARE(m1->data(i, m1->roles()[2]).toString(), QString("Football")); - - QCOMPARE(m2->data(i, m2->roles()[0]).toString(), QString("B" + QString::number(i))); - QCOMPARE(m2->data(i, m2->roles()[1]).toString(), QString("2" + QString::number(i))); - QCOMPARE(m2->data(i, m2->roles()[2]).toString(), QString("Athletics")); - - QCOMPARE(m3->data(i, m3->roles()[0]).toString(), QString("C" + QString::number(i))); - QCOMPARE(m3->data(i, m3->roles()[1]).toString(), QString("3" + QString::number(i))); - QCOMPARE(m3->data(i, m3->roles()[2]).toString(), QString("Curling")); - } - } - - delete m1; - delete m2; - delete m3; -} - -void tst_qdeclarativexmllistmodel::threading_data() -{ - QTest::addColumn("xmlDataCount"); - - QTest::newRow("1") << 1; - QTest::newRow("2") << 2; - QTest::newRow("10") << 10; -} - -void tst_qdeclarativexmllistmodel::propertyChanges() -{ - QDeclarativeComponent component(&engine, testFileUrl("propertychanges.qml")); - QListModelInterface *model = qobject_cast(component.create()); - QVERIFY(model != 0); - QTRY_COMPARE(model->count(), 9); - - QObject *role = model->findChild("role"); - QVERIFY(role); - - QSignalSpy nameSpy(role, SIGNAL(nameChanged())); - QSignalSpy querySpy(role, SIGNAL(queryChanged())); - QSignalSpy isKeySpy(role, SIGNAL(isKeyChanged())); - - role->setProperty("name","size"); - role->setProperty("query","size/string()"); - role->setProperty("isKey",true); - - QCOMPARE(role->property("name").toString(), QString("size")); - QCOMPARE(role->property("query").toString(), QString("size/string()")); - QVERIFY(role->property("isKey").toBool()); - - QCOMPARE(nameSpy.count(),1); - QCOMPARE(querySpy.count(),1); - QCOMPARE(isKeySpy.count(),1); - - role->setProperty("name","size"); - role->setProperty("query","size/string()"); - role->setProperty("isKey",true); - - QCOMPARE(nameSpy.count(),1); - QCOMPARE(querySpy.count(),1); - QCOMPARE(isKeySpy.count(),1); - - QSignalSpy sourceSpy(model, SIGNAL(sourceChanged())); - QSignalSpy xmlSpy(model, SIGNAL(xmlChanged())); - QSignalSpy modelQuerySpy(model, SIGNAL(queryChanged())); - QSignalSpy namespaceDeclarationsSpy(model, SIGNAL(namespaceDeclarationsChanged())); - - model->setProperty("source",QUrl("")); - model->setProperty("xml","PollyParrot12Small"); - model->setProperty("query","/Pets"); - model->setProperty("namespaceDeclarations","declare namespace media=\"http://search.yahoo.com/mrss/\";"); - - QCOMPARE(model->property("source").toUrl(), QUrl("")); - QCOMPARE(model->property("xml").toString(), QString("PollyParrot12Small")); - QCOMPARE(model->property("query").toString(), QString("/Pets")); - QCOMPARE(model->property("namespaceDeclarations").toString(), QString("declare namespace media=\"http://search.yahoo.com/mrss/\";")); - - QTRY_VERIFY(model->count() == 1); - - QCOMPARE(sourceSpy.count(),1); - QCOMPARE(xmlSpy.count(),1); - QCOMPARE(modelQuerySpy.count(),1); - QCOMPARE(namespaceDeclarationsSpy.count(),1); - - model->setProperty("source",QUrl("")); - model->setProperty("xml","PollyParrot12Small"); - model->setProperty("query","/Pets"); - model->setProperty("namespaceDeclarations","declare namespace media=\"http://search.yahoo.com/mrss/\";"); - - QCOMPARE(sourceSpy.count(),1); - QCOMPARE(xmlSpy.count(),1); - QCOMPARE(modelQuerySpy.count(),1); - QCOMPARE(namespaceDeclarationsSpy.count(),1); - - QTRY_VERIFY(model->count() == 1); - delete model; -} - -void tst_qdeclarativexmllistmodel::roleCrash() -{ - // don't crash - QDeclarativeComponent component(&engine, testFileUrl("roleCrash.qml")); - QListModelInterface *model = qobject_cast(component.create()); - QVERIFY(model != 0); - delete model; -} - -QTEST_MAIN(tst_qdeclarativexmllistmodel) - -#include "tst_qdeclarativexmllistmodel.moc" diff --git a/tests/auto/qtquick2/qquickaccessible/data/checkbuttons.qml b/tests/auto/qtquick2/qquickaccessible/data/checkbuttons.qml deleted file mode 100644 index 22cdad1377..0000000000 --- a/tests/auto/qtquick2/qquickaccessible/data/checkbuttons.qml +++ /dev/null @@ -1,47 +0,0 @@ -import QtQuick 2.0 - -Item { - width: 400 - height: 400 - - // button, not checkable - Rectangle { - y: 20 - width: 100; height: 20 - Accessible.role : Accessible.Button - } - - // button, checkable, not checked - Rectangle { - y: 40 - width: 100; height: 20 - Accessible.role : Accessible.Button - property bool checkable: true - property bool checked: false - } - - // button, checkable, checked - Rectangle { - y: 60 - width: 100; height: 20 - Accessible.role : Accessible.Button - property bool checkable: true - property bool checked: true - } - - // check box, checked - Rectangle { - y: 80 - width: 100; height: 20 - Accessible.role : Accessible.CheckBox - property bool checked: true - } - // check box, not checked - Rectangle { - y: 100 - width: 100; height: 20 - Accessible.role : Accessible.CheckBox - property bool checked: false - } -} - diff --git a/tests/auto/qtquick2/qquickaccessible/data/hittest.qml b/tests/auto/qtquick2/qquickaccessible/data/hittest.qml deleted file mode 100644 index 23d3b95157..0000000000 --- a/tests/auto/qtquick2/qquickaccessible/data/hittest.qml +++ /dev/null @@ -1,176 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - - -import QtQuick 2.0 -import "widgets" - -Rectangle { - id: page - width: 640 - height: 480 - color: "white" - Rectangle { - id: header - color: "#c0c0c0" - height: usage.height + chkClip.height - anchors.left: parent.left - anchors.right: parent.right - Text { - id: usage - text: "Use an a11y inspect tool to see if all visible rectangles can be found with hit testing." - } - Rectangle { - id: chkClip - property bool checked: true - - color: (checked ? "#f0f0f0" : "#c0c0c0") - height: label.height - width: label.width - anchors.left: parent.left - anchors.bottom: parent.bottom - - MouseArea { - anchors.fill: parent - onClicked: chkClip.checked = !chkClip.checked - } - Text { - id: label - text: "Click here to toggle clipping" - } - } - } - TextRect { - clip: chkClip.checked - z: 2 - id: rect1 - text: "rect1" - width: 100 - height: 100 - color: "#ffc0c0" - anchors.top: header.bottom - TextRect { - id: rect10 - text: "rect10" - width: 100 - height: 100 - x: 50 - y: 50 - color: "#ffa0a0" - TextRect { - id: rect100 - text: "rect100" - width: 100 - height: 100 - x: 80 - y: 80 - color: "#ff8080" - } - TextRect { - id: rect101 - text: "rect101" - x: 100 - y: 70 - z: 3 - width: 100 - height: 100 - color: "#e06060" - } - TextRect { - id: rect102 - text: "rect102" - width: 100 - height: 100 - x: 150 - y: 60 - color: "#c04040" - } - } - } - - TextRect { - x: 0 - y: 50 - id: rect2 - text: "rect2" - width: 100 - height: 100 - color: "#c0c0ff" - TextRect { - id: rect20 - text: "rect20" - width: 100 - height: 100 - x: 50 - y: 50 - color: "#a0a0ff" - TextRect { - id: rect200 - text: "rect200" - width: 100 - height: 100 - x: 80 - y: 80 - color: "#8080ff" - } - TextRect { - id: rect201 - text: "rect201" - x: 100 - y: 70 - z: 100 - width: 100 - height: 100 - color: "#6060e0" - } - TextRect { - id: rect202 - text: "rect202" - width: 100 - height: 100 - x: 150 - y: 60 - color: "#4040c0" - } - } - } - -} diff --git a/tests/auto/qtquick2/qquickaccessible/data/pushbutton.qml b/tests/auto/qtquick2/qquickaccessible/data/pushbutton.qml deleted file mode 100644 index df19231703..0000000000 --- a/tests/auto/qtquick2/qquickaccessible/data/pushbutton.qml +++ /dev/null @@ -1,15 +0,0 @@ -import QtQuick 2.0 - -Rectangle { - Accessible.role : Accessible.Button - property string text : "test" - - Text { - anchors.fill : parent - text : parent.text - } - - MouseArea { - anchors.fill : parent - } -} diff --git a/tests/auto/qtquick2/qquickaccessible/data/statictext.qml b/tests/auto/qtquick2/qquickaccessible/data/statictext.qml deleted file mode 100644 index a0821cfc4d..0000000000 --- a/tests/auto/qtquick2/qquickaccessible/data/statictext.qml +++ /dev/null @@ -1,25 +0,0 @@ -import QtQuick 2.0 - -Item { - width: 400 - height: 400 - - Text { - x: 100 - y: 20 - width: 200 - height: 50 - text : "Hello Accessibility" - } - - Text { - x: 100 - y: 40 - width: 100 - height: 40 - text : "Hello 2" - Accessible.role: Accessible.StaticText - Accessible.name: "The Hello 2 accessible text" - Accessible.description: "A text description" - } -} diff --git a/tests/auto/qtquick2/qquickaccessible/data/widgets/TextRect.qml b/tests/auto/qtquick2/qquickaccessible/data/widgets/TextRect.qml deleted file mode 100644 index 937686974b..0000000000 --- a/tests/auto/qtquick2/qquickaccessible/data/widgets/TextRect.qml +++ /dev/null @@ -1,26 +0,0 @@ -import QtQuick 2.0 - -Rectangle { - id: button - - property alias text : buttonText.text - Accessible.name: text - Accessible.description: "This button does " + text - Accessible.role: Accessible.Client - - signal clicked - - width: 40 - height: 40 - border.width: 2 - border.color: "black"; - - Text { - id: buttonText - text: "TextRect" - anchors.centerIn: parent - font.pixelSize: parent.height * .1 - style: Text.Sunken; color: "white"; styleColor: "black"; smooth: true - } - -} diff --git a/tests/auto/qtquick2/qquickaccessible/qquickaccessible.pro b/tests/auto/qtquick2/qquickaccessible/qquickaccessible.pro deleted file mode 100644 index dc32316e28..0000000000 --- a/tests/auto/qtquick2/qquickaccessible/qquickaccessible.pro +++ /dev/null @@ -1,25 +0,0 @@ -CONFIG += testcase - -TARGET = tst_qquickaccessible -QT += declarative-private network quick-private testlib -macx:CONFIG -= app_bundle - -SOURCES += tst_qquickaccessible.cpp - -include (../../shared/util.pri) - -OTHER_FILES += data/checkbuttons.qml -OTHER_FILES += data/hittest.qml -OTHER_FILES += data/pushbutton.qml -OTHER_FILES += data/statictext.qml - -DEFINES += SRCDIR=\\\"$$PWD\\\" - -CONFIG += parallel_test - -wince*: { - accessneeded.files = $$QT_BUILD_TREE\\plugins\\accessible\\*.dll - accessneeded.path = accessible - DEPLOYMENT += accessneeded -} - diff --git a/tests/auto/qtquick2/qquickaccessible/tst_qquickaccessible.cpp b/tests/auto/qtquick2/qquickaccessible/tst_qquickaccessible.cpp deleted file mode 100644 index 2e1c2b883c..0000000000 --- a/tests/auto/qtquick2/qquickaccessible/tst_qquickaccessible.cpp +++ /dev/null @@ -1,410 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - - -#include -#include "QtTest/qtestaccessible.h" - -#include - -#include -#include - -#include -#include -#include - -#include "../../shared/util.h" - - -typedef QSharedPointer QAI; - -#define EXPECT(cond) \ - do { \ - if (!errorAt && !(cond)) { \ - errorAt = __LINE__; \ - qWarning("level: %d, middle: %d, role: %d (%s)", treelevel, middle, iface->role(), #cond); \ - } \ - } while (0) - -static int verifyHierarchy(QAccessibleInterface *iface) -{ - int errorAt = 0; - static int treelevel = 0; // for error diagnostics - QAccessibleInterface *middleChild, *if2; - middleChild = 0; - ++treelevel; - int middle = iface->childCount()/2 + 1; - if (iface->childCount() >= 2) { - middleChild = iface->child(middle - 1); - } - for (int i = 0; i < iface->childCount() && !errorAt; ++i) { - if2 = iface->child(i); - EXPECT(if2 != 0); - // navigate Ancestor... - QAccessibleInterface *parent = if2->parent(); - EXPECT(iface->object() == parent->object()); - delete parent; - - // verify children... - if (!errorAt) - errorAt = verifyHierarchy(if2); - delete if2; - } - delete middleChild; - - --treelevel; - return errorAt; -} - - -//TESTED_FILES= - -class tst_QQuickAccessible : public QDeclarativeDataTest -{ - Q_OBJECT -public: - tst_QQuickAccessible(); - virtual ~tst_QQuickAccessible(); - -private slots: - void commonTests_data(); - void commonTests(); - - void declarativeAttachedProperties(); - void basicPropertiesTest(); - void hitTest(); - void checkableTest(); -}; - -tst_QQuickAccessible::tst_QQuickAccessible() -{ - -} - -tst_QQuickAccessible::~tst_QQuickAccessible() -{ - -} - -void tst_QQuickAccessible::commonTests_data() -{ - QTest::addColumn("accessibleRoleFileName"); - - QTest::newRow("StaticText") << SRCDIR "/data/statictext.qml"; - QTest::newRow("PushButton") << SRCDIR "/data/pushbutton.qml"; -} - -void tst_QQuickAccessible::commonTests() -{ - QFETCH(QString, accessibleRoleFileName); - - qDebug() << "testing" << accessibleRoleFileName; - - QQuickView *view = new QQuickView(); -// view->setFixedSize(240,320); - view->setSource(QUrl::fromLocalFile(accessibleRoleFileName)); - view->show(); -// view->setFocus(); - QVERIFY(view->rootObject() != 0); - - QAccessibleInterface *iface = QAccessible::queryAccessibleInterface(view); - QVERIFY(iface); - - delete iface; - delete view; -} - - - -QString eventName(const int ev) -{ - switch (ev) { - case 0x0001: return "SoundPlayed"; - case 0x0002: return "Alert"; - case 0x0003: return "ForegroundChanged"; - case 0x0004: return "MenuStart"; - case 0x0005: return "MenuEnd"; - case 0x0006: return "PopupMenuStart"; - case 0x0007: return "PopupMenuEnd"; - case 0x000C: return "ContextHelpStart"; - case 0x000D: return "ContextHelpEnd"; - case 0x000E: return "DragDropStart"; - case 0x000F: return "DragDropEnd"; - case 0x0010: return "DialogStart"; - case 0x0011: return "DialogEnd"; - case 0x0012: return "ScrollingStart"; - case 0x0013: return "ScrollingEnd"; - case 0x0018: return "MenuCommand"; - case 0x8000: return "ObjectCreated"; - case 0x8001: return "ObjectDestroyed"; - case 0x8002: return "ObjectShow"; - case 0x8003: return "ObjectHide"; - case 0x8004: return "ObjectReorder"; - case 0x8005: return "Focus"; - case 0x8006: return "Selection"; - case 0x8007: return "SelectionAdd"; - case 0x8008: return "SelectionRemove"; - case 0x8009: return "SelectionWithin"; - case 0x800A: return "StateChanged"; - case 0x800B: return "LocationChanged"; - case 0x800C: return "NameChanged"; - case 0x800D: return "DescriptionChanged"; - case 0x800E: return "ValueChanged"; - case 0x800F: return "ParentChanged"; - case 0x80A0: return "HelpChanged"; - case 0x80B0: return "DefaultActionChanged"; - case 0x80C0: return "AcceleratorChanged"; - default: return "Unknown Event"; - } -} - -void tst_QQuickAccessible::declarativeAttachedProperties() -{ - { - QDeclarativeEngine engine; - QDeclarativeComponent component(&engine); - component.setData("import QtQuick 2.0\nItem {\n" - "}", QUrl()); - QObject *object = component.create(); - QVERIFY(object != 0); - - QObject *attachedObject = QQuickAccessibleAttached::attachedProperties(object); - QCOMPARE(attachedObject, static_cast(0)); - delete object; - } - - // Attached property - { - QObject parent; - QQuickAccessibleAttached *attachedObj = new QQuickAccessibleAttached(&parent); - - attachedObj->name(); - - QVariant pp = attachedObj->property("name"); - QDeclarativeEngine engine; - QDeclarativeComponent component(&engine); - component.setData("import QtQuick 2.0\nItem {\n" - "Accessible.role: Accessible.Button\n" - "}", QUrl()); - QObject *object = component.create(); - QVERIFY(object != 0); - - QObject *attachedObject = QQuickAccessibleAttached::attachedProperties(object); - QVERIFY(attachedObject); - if (attachedObject) { - QVariant p = attachedObject->property("role"); - QCOMPARE(p.isNull(), false); - QCOMPARE(p.toInt(), int(QAccessible::PushButton)); - p = attachedObject->property("name"); - QCOMPARE(p.isNull(), true); - p = attachedObject->property("description"); - QCOMPARE(p.isNull(), true); - } - delete object; - } - - // Attached property - { - QDeclarativeEngine engine; - QDeclarativeComponent component(&engine); - component.setData("import QtQuick 2.0\nItem {\n" - "Accessible.role: Accessible.Button\n" - "Accessible.name: \"Donald\"\n" - "Accessible.description: \"Duck\"\n" - "}", QUrl()); - QObject *object = component.create(); - QVERIFY(object != 0); - - QObject *attachedObject = QQuickAccessibleAttached::attachedProperties(object); - QVERIFY(attachedObject); - if (attachedObject) { - QVariant p = attachedObject->property("role"); - QCOMPARE(p.isNull(), false); - QCOMPARE(p.toInt(), int(QAccessible::PushButton)); - p = attachedObject->property("name"); - QCOMPARE(p.isNull(), false); - QCOMPARE(p.toString(), QLatin1String("Donald")); - p = attachedObject->property("description"); - QCOMPARE(p.isNull(), false); - QCOMPARE(p.toString(), QLatin1String("Duck")); - } - delete object; - } -} - - -void tst_QQuickAccessible::basicPropertiesTest() -{ - QAI app = QAI(QAccessible::queryAccessibleInterface(qApp)); - QCOMPARE(app->childCount(), 0); - - QQuickView *canvas = new QQuickView(); - canvas->setSource(testFileUrl("statictext.qml")); - canvas->show(); - QCOMPARE(app->childCount(), 1); - - QAI iface = QAI(QAccessible::queryAccessibleInterface(canvas)); - QVERIFY(iface.data()); - QCOMPARE(iface->childCount(), 1); - - QAI item = QAI(iface->child(0)); - QVERIFY(item.data()); - QCOMPARE(item->childCount(), 2); - QCOMPARE(item->rect().size(), QSize(400, 400)); - QCOMPARE(item->role(), QAccessible::Pane); - QCOMPARE(iface->indexOfChild(item.data()), 0); - - QAI text = QAI(item->child(0)); - QVERIFY(text.data()); - QCOMPARE(text->childCount(), 0); - - QCOMPARE(text->text(QAccessible::Name), QLatin1String("Hello Accessibility")); - QCOMPARE(text->rect().size(), QSize(200, 50)); - QCOMPARE(text->rect().x(), item->rect().x() + 100); - QCOMPARE(text->rect().y(), item->rect().y() + 20); - QCOMPARE(text->role(), QAccessible::StaticText); - QCOMPARE(item->indexOfChild(text.data()), 0); - - QAI text2 = QAI(item->child(1)); - QVERIFY(text2.data()); - QCOMPARE(text2->childCount(), 0); - - QCOMPARE(text2->text(QAccessible::Name), QLatin1String("The Hello 2 accessible text")); - QCOMPARE(text2->rect().size(), QSize(100, 40)); - QCOMPARE(text2->rect().x(), item->rect().x() + 100); - QCOMPARE(text2->rect().y(), item->rect().y() + 40); - QCOMPARE(text2->role(), QAccessible::StaticText); - QCOMPARE(item->indexOfChild(text2.data()), 1); - - QCOMPARE(iface->indexOfChild(text2.data()), -1); - QCOMPARE(text2->indexOfChild(item.data()), -1); - - delete canvas; -} - -QAI topLevelChildAt(QAccessibleInterface *iface, int x, int y) -{ - QAI child = QAI(iface->childAt(x, y)); - if (!child) - return QAI(); - - QAI childOfChild; - while (childOfChild = QAI(child->childAt(x, y))) { - child = childOfChild; - } - return child; -} - -void tst_QQuickAccessible::hitTest() -{ - QQuickView *canvas = new QQuickView; - canvas->setSource(testFileUrl("hittest.qml")); - canvas->show(); - - QAI iface = QAI(QAccessible::queryAccessibleInterface(canvas)); - QVERIFY(iface.data()); - QAI rootItem = QAI(iface->child(0)); - QRect rootRect = rootItem->rect(); - - // hit the root item - QAI itemHit(iface->childAt(rootRect.x() + 200, rootRect.y() + 50)); - QVERIFY(itemHit); - QCOMPARE(rootRect, itemHit->rect()); - - // hit rect1 - QAI rect1(rootItem->child(1)); - QRect rect1Rect = rect1->rect(); - itemHit = QAI(rootItem->childAt(rect1Rect.x() + 10, rect1Rect.y() + 10)); - QVERIFY(itemHit); - QCOMPARE(rect1Rect, itemHit->rect()); - QCOMPARE(itemHit->text(QAccessible::Name), QLatin1String("rect1")); - - // should also work from top level (app) - QAI app(QAccessible::queryAccessibleInterface(qApp)); - QAI itemHit2(topLevelChildAt(app.data(), rect1Rect.x() + 10, rect1Rect.y() + 10)); - QVERIFY(itemHit2); - QCOMPARE(itemHit2->rect(), rect1Rect); - QCOMPARE(itemHit2->text(QAccessible::Name), QLatin1String("rect1")); - - // hit rect201 - QAI rect2(rootItem->child(2)); - QAI rect20(rect2->child(1)); - QAI rect201(rect20->child(2)); - QVERIFY(rect201); - - QRect rect201Rect = rect201->rect(); - itemHit = QAI(iface->childAt(rect201Rect.x() + 20, rect201Rect.y() + 20)); - QVERIFY(itemHit); - QCOMPARE(itemHit->rect(), rect201Rect); - QCOMPARE(itemHit->text(QAccessible::Name), QLatin1String("rect201")); - - delete canvas; -} - -void tst_QQuickAccessible::checkableTest() -{ - QQuickView *canvas = new QQuickView(); - canvas->setSource(testFileUrl("checkbuttons.qml")); - canvas->show(); - - QAI iface = QAI(QAccessible::queryAccessibleInterface(canvas)); - QVERIFY(iface.data()); - QAI root = QAI(iface->child(0)); - - QAI button1 = QAI(root->child(0)); - QCOMPARE(button1->role(), QAccessible::Button); - QVERIFY(!(button1->state().checked)); - QAI button2 = QAI(root->child(1)); - QVERIFY(!(button2->state().checked)); - QAI button3 = QAI(root->child(2)); - QVERIFY(button3->state().checked); - - QAI checkBox1 = QAI(root->child(3)); - QCOMPARE(checkBox1->role(), QAccessible::CheckBox); - QVERIFY((checkBox1->state().checked)); - QAI checkBox2 = QAI(root->child(4)); - QVERIFY(!(checkBox2->state().checked)); -} - -QTEST_MAIN(tst_QQuickAccessible) - -#include "tst_qquickaccessible.moc" diff --git a/tests/auto/qtquick2/qquickanchors/data/anchors.qml b/tests/auto/qtquick2/qquickanchors/data/anchors.qml deleted file mode 100644 index 4be49a3468..0000000000 --- a/tests/auto/qtquick2/qquickanchors/data/anchors.qml +++ /dev/null @@ -1,162 +0,0 @@ -import QtQuick 2.0 - -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/qtquick2/qquickanchors/data/centerin.qml b/tests/auto/qtquick2/qquickanchors/data/centerin.qml deleted file mode 100644 index e6c9179116..0000000000 --- a/tests/auto/qtquick2/qquickanchors/data/centerin.qml +++ /dev/null @@ -1,18 +0,0 @@ -import QtQuick 2.0 - -Rectangle { - width: 200; height: 200 - Rectangle { - objectName: "centered" - width: 50; height: 50; color: "blue" - anchors.centerIn: parent; - anchors.verticalCenterOffset: 30 - anchors.horizontalCenterOffset: 10 - } - - Rectangle { - objectName: "centered2" - width: 11; height: 11; color: "green" - anchors.centerIn: parent; - } -} diff --git a/tests/auto/qtquick2/qquickanchors/data/centerinRotation.qml b/tests/auto/qtquick2/qquickanchors/data/centerinRotation.qml deleted file mode 100644 index 933a25c100..0000000000 --- a/tests/auto/qtquick2/qquickanchors/data/centerinRotation.qml +++ /dev/null @@ -1,17 +0,0 @@ -import QtQuick 2.0 - -Rectangle { - width: 200; height: 200 - Rectangle { - objectName: "outer" - rotation: 90 - width: 101; height: 101; color: "blue" - anchors.centerIn: parent; - - Rectangle { - objectName: "inner" - width: 50; height: 50; color: "blue" - anchors.centerIn: parent; - } - } -} diff --git a/tests/auto/qtquick2/qquickanchors/data/crash1.qml b/tests/auto/qtquick2/qquickanchors/data/crash1.qml deleted file mode 100644 index 98dd6cfa41..0000000000 --- a/tests/auto/qtquick2/qquickanchors/data/crash1.qml +++ /dev/null @@ -1,11 +0,0 @@ -import QtQuick 2.0 - -Column { - Text { - text: "foo" - anchors.fill: parent - } - Text { - text: "bar" - } -} diff --git a/tests/auto/qtquick2/qquickanchors/data/fill.qml b/tests/auto/qtquick2/qquickanchors/data/fill.qml deleted file mode 100644 index 08db199d7b..0000000000 --- a/tests/auto/qtquick2/qquickanchors/data/fill.qml +++ /dev/null @@ -1,14 +0,0 @@ -import QtQuick 2.0 - -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/qtquick2/qquickanchors/data/hvCenter.qml b/tests/auto/qtquick2/qquickanchors/data/hvCenter.qml deleted file mode 100644 index 6763f8eb75..0000000000 --- a/tests/auto/qtquick2/qquickanchors/data/hvCenter.qml +++ /dev/null @@ -1,11 +0,0 @@ -import QtQuick 2.0 - -Rectangle { - width: 77; height: 95 - Rectangle { - objectName: "centered" - width: 57; height: 57; color: "blue" - anchors.verticalCenter: parent.verticalCenter - anchors.horizontalCenter: parent.horizontalCenter - } -} diff --git a/tests/auto/qtquick2/qquickanchors/data/loop1.qml b/tests/auto/qtquick2/qquickanchors/data/loop1.qml deleted file mode 100644 index 342b2af052..0000000000 --- a/tests/auto/qtquick2/qquickanchors/data/loop1.qml +++ /dev/null @@ -1,8 +0,0 @@ -import QtQuick 2.0 - -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/qtquick2/qquickanchors/data/loop2.qml b/tests/auto/qtquick2/qquickanchors/data/loop2.qml deleted file mode 100644 index 044152989e..0000000000 --- a/tests/auto/qtquick2/qquickanchors/data/loop2.qml +++ /dev/null @@ -1,20 +0,0 @@ -import QtQuick 2.0 - -Rectangle { - id: container; - width: 600; - height: 600; - - Image { - id: image1 - source: "http://labs.qt.nokia.com/blogs/wp-content/uploads/2009/03/3311388091_ac2a257feb.jpg" - anchors.right: image2.left - } - - Image { - id: image2 - source: "http://labs.qt.nokia.com/blogs/wp-content/uploads/2009/03/oslo_groupphoto.jpg" - anchors.left: image1.right - anchors.leftMargin: 20 - } -} diff --git a/tests/auto/qtquick2/qquickanchors/data/margins.qml b/tests/auto/qtquick2/qquickanchors/data/margins.qml deleted file mode 100644 index 9403f65a61..0000000000 --- a/tests/auto/qtquick2/qquickanchors/data/margins.qml +++ /dev/null @@ -1,13 +0,0 @@ -import QtQuick 2.0 - -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/qtquick2/qquickanchors/qquickanchors.pro b/tests/auto/qtquick2/qquickanchors/qquickanchors.pro deleted file mode 100644 index bd94f9cceb..0000000000 --- a/tests/auto/qtquick2/qquickanchors/qquickanchors.pro +++ /dev/null @@ -1,16 +0,0 @@ -TARGET = tst_qquickanchors -CONFIG += testcase -SOURCES += tst_qquickanchors.cpp - -include (../../shared/util.pri) -include (../shared/util.pri) - -macx:CONFIG -= app_bundle - -testDataFiles.files = data -testDataFiles.path = . -DEPLOYMENT += testDataFiles - -CONFIG += parallel_test - -QT += core-private gui-private declarative-private quick-private v8-private testlib diff --git a/tests/auto/qtquick2/qquickanchors/tst_qquickanchors.cpp b/tests/auto/qtquick2/qquickanchors/tst_qquickanchors.cpp deleted file mode 100644 index 8d82abc53b..0000000000 --- a/tests/auto/qtquick2/qquickanchors/tst_qquickanchors.cpp +++ /dev/null @@ -1,669 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "../../shared/util.h" -#include "../shared/visualtestutil.h" - -Q_DECLARE_METATYPE(QQuickAnchors::Anchor) -Q_DECLARE_METATYPE(QQuickAnchorLine::AnchorLine) - -using namespace QQuickVisualTestUtil; - -class tst_qquickanchors : public QDeclarativeDataTest -{ - Q_OBJECT -public: - tst_qquickanchors() {} - -private slots: - void basicAnchors(); - void basicAnchorsRTL(); - void loops(); - void illegalSets(); - void illegalSets_data(); - void reset(); - void reset_data(); - void resetConvenience(); - void nullItem(); - void nullItem_data(); - void crash1(); - void centerIn(); - void centerInRTL(); - void centerInRotation(); - void hvCenter(); - void hvCenterRTL(); - void fill(); - void fillRTL(); - void margins(); - void marginsRTL(); -}; - -void tst_qquickanchors::basicAnchors() -{ - QQuickView *view = new QQuickView; - view->setSource(testFileUrl("anchors.qml")); - - qApp->processEvents(); - - //sibling horizontal - QCOMPARE(findItem(view->rootObject(), QLatin1String("rect1"))->x(), 26.0); - QCOMPARE(findItem(view->rootObject(), QLatin1String("rect2"))->x(), 122.0); - QCOMPARE(findItem(view->rootObject(), QLatin1String("rect3"))->x(), 74.0); - QCOMPARE(findItem(view->rootObject(), QLatin1String("rect4"))->x(), 16.0); - QCOMPARE(findItem(view->rootObject(), QLatin1String("rect5"))->x(), 112.0); - QCOMPARE(findItem(view->rootObject(), QLatin1String("rect6"))->x(), 64.0); - - //parent horizontal - QCOMPARE(findItem(view->rootObject(), QLatin1String("rect7"))->x(), 0.0); - QCOMPARE(findItem(view->rootObject(), QLatin1String("rect8"))->x(), 240.0); - QCOMPARE(findItem(view->rootObject(), QLatin1String("rect9"))->x(), 120.0); - QCOMPARE(findItem(view->rootObject(), QLatin1String("rect10"))->x(), -10.0); - QCOMPARE(findItem(view->rootObject(), QLatin1String("rect11"))->x(), 230.0); - QCOMPARE(findItem(view->rootObject(), QLatin1String("rect12"))->x(), 110.0); - - //vertical - QCOMPARE(findItem(view->rootObject(), QLatin1String("rect13"))->y(), 20.0); - QCOMPARE(findItem(view->rootObject(), QLatin1String("rect14"))->y(), 155.0); - - //stretch - QCOMPARE(findItem(view->rootObject(), QLatin1String("rect15"))->x(), 26.0); - QCOMPARE(findItem(view->rootObject(), QLatin1String("rect15"))->width(), 96.0); - QCOMPARE(findItem(view->rootObject(), QLatin1String("rect16"))->x(), 26.0); - QCOMPARE(findItem(view->rootObject(), QLatin1String("rect16"))->width(), 192.0); - QCOMPARE(findItem(view->rootObject(), QLatin1String("rect17"))->x(), -70.0); - QCOMPARE(findItem(view->rootObject(), QLatin1String("rect17"))->width(), 192.0); - - //vertical stretch - QCOMPARE(findItem(view->rootObject(), QLatin1String("rect18"))->y(), 20.0); - QCOMPARE(findItem(view->rootObject(), QLatin1String("rect18"))->height(), 40.0); - - //more parent horizontal - QCOMPARE(findItem(view->rootObject(), QLatin1String("rect19"))->x(), 115.0); - QCOMPARE(findItem(view->rootObject(), QLatin1String("rect20"))->x(), 235.0); - QCOMPARE(findItem(view->rootObject(), QLatin1String("rect21"))->x(), -5.0); - - //centerIn - QCOMPARE(findItem(view->rootObject(), QLatin1String("rect22"))->x(), 69.0); - QCOMPARE(findItem(view->rootObject(), QLatin1String("rect22"))->y(), 5.0); - - //margins - QCOMPARE(findItem(view->rootObject(), QLatin1String("rect23"))->x(), 31.0); - QCOMPARE(findItem(view->rootObject(), QLatin1String("rect23"))->y(), 5.0); - QCOMPARE(findItem(view->rootObject(), QLatin1String("rect23"))->width(), 86.0); - QCOMPARE(findItem(view->rootObject(), QLatin1String("rect23"))->height(), 10.0); - - // offsets - QCOMPARE(findItem(view->rootObject(), QLatin1String("rect24"))->x(), 26.0); - QCOMPARE(findItem(view->rootObject(), QLatin1String("rect25"))->y(), 60.0); - QCOMPARE(findItem(view->rootObject(), QLatin1String("rect26"))->y(), 5.0); - - //baseline - QQuickText *text1 = findItem(view->rootObject(), QLatin1String("text1")); - QQuickText *text2 = findItem(view->rootObject(), QLatin1String("text2")); - QCOMPARE(text1->y(), text2->y()); - - delete view; -} - -QQuickItem* childItem(QQuickItem *parentItem, const char * itemString) { - return findItem(parentItem, QLatin1String(itemString)); -} - -qreal offsetMasterRTL(QQuickItem *rootItem, const char * itemString) { - QQuickItem* masterItem = findItem(rootItem, QLatin1String("masterRect")); - return masterItem->width()+2*masterItem->x()-findItem(rootItem, QLatin1String(itemString))->width(); -} - -qreal offsetParentRTL(QQuickItem *rootItem, const char * itemString) { - return rootItem->width()+2*rootItem->x()-findItem(rootItem, QLatin1String(itemString))->width(); -} - -void mirrorAnchors(QQuickItem *item) { - QQuickItemPrivate *itemPrivate = QQuickItemPrivate::get(item); - itemPrivate->setLayoutMirror(true); -} - -void tst_qquickanchors::basicAnchorsRTL() -{ - QQuickView *view = new QQuickView; - view->setSource(testFileUrl("anchors.qml")); - - qApp->processEvents(); - - QQuickItem* rootItem = qobject_cast(view->rootObject()); - foreach (QObject *child, rootItem->children()) { - bool mirrored = QQuickItemPrivate::get(qobject_cast(child))->anchors()->property("mirrored").toBool(); - QCOMPARE(mirrored, false); - } - - foreach (QObject *child, rootItem->children()) - mirrorAnchors(qobject_cast(child)); - - foreach (QObject *child, rootItem->children()) { - bool mirrored = QQuickItemPrivate::get(qobject_cast(child))->anchors()->property("mirrored").toBool(); - QCOMPARE(mirrored, true); - } - - //sibling horizontal - QCOMPARE(childItem(rootItem, "rect1")->x(), offsetMasterRTL(rootItem, "rect1")-26.0); - QCOMPARE(childItem(rootItem, "rect2")->x(), offsetMasterRTL(rootItem, "rect2")-122.0); - QCOMPARE(childItem(rootItem, "rect3")->x(), offsetMasterRTL(rootItem, "rect3")-74.0); - QCOMPARE(childItem(rootItem, "rect4")->x(), offsetMasterRTL(rootItem, "rect4")-16.0); - QCOMPARE(childItem(rootItem, "rect5")->x(), offsetMasterRTL(rootItem, "rect5")-112.0); - QCOMPARE(childItem(rootItem, "rect6")->x(), offsetMasterRTL(rootItem, "rect6")-64.0); - - //parent horizontal - QCOMPARE(childItem(rootItem, "rect7")->x(), offsetParentRTL(rootItem, "rect7")-0.0); - QCOMPARE(childItem(rootItem, "rect8")->x(), offsetParentRTL(rootItem, "rect8")-240.0); - QCOMPARE(childItem(rootItem, "rect9")->x(), offsetParentRTL(rootItem, "rect9")-120.0); - QCOMPARE(childItem(rootItem, "rect10")->x(), offsetParentRTL(rootItem, "rect10")+10.0); - QCOMPARE(childItem(rootItem, "rect11")->x(), offsetParentRTL(rootItem, "rect11")-230.0); - QCOMPARE(childItem(rootItem, "rect12")->x(), offsetParentRTL(rootItem, "rect12")-110.0); - - //vertical - QCOMPARE(childItem(rootItem, "rect13")->y(), 20.0); - QCOMPARE(childItem(rootItem, "rect14")->y(), 155.0); - - //stretch - QCOMPARE(childItem(rootItem, "rect15")->x(), offsetMasterRTL(rootItem, "rect15")-26.0); - QCOMPARE(childItem(rootItem, "rect15")->width(), 96.0); - QCOMPARE(childItem(rootItem, "rect16")->x(), offsetMasterRTL(rootItem, "rect16")-26.0); - QCOMPARE(childItem(rootItem, "rect16")->width(), 192.0); - QCOMPARE(childItem(rootItem, "rect17")->x(), offsetMasterRTL(rootItem, "rect17")+70.0); - QCOMPARE(childItem(rootItem, "rect17")->width(), 192.0); - - //vertical stretch - QCOMPARE(childItem(rootItem, "rect18")->y(), 20.0); - QCOMPARE(childItem(rootItem, "rect18")->height(), 40.0); - - //more parent horizontal - QCOMPARE(childItem(rootItem, "rect19")->x(), offsetParentRTL(rootItem, "rect19")-115.0); - QCOMPARE(childItem(rootItem, "rect20")->x(), offsetParentRTL(rootItem, "rect20")-235.0); - QCOMPARE(childItem(rootItem, "rect21")->x(), offsetParentRTL(rootItem, "rect21")+5.0); - - //centerIn - QCOMPARE(childItem(rootItem, "rect22")->x(), offsetMasterRTL(rootItem, "rect22")-69.0); - QCOMPARE(childItem(rootItem, "rect22")->y(), 5.0); - - //margins - QCOMPARE(childItem(rootItem, "rect23")->x(), offsetMasterRTL(rootItem, "rect23")-31.0); - QCOMPARE(childItem(rootItem, "rect23")->y(), 5.0); - QCOMPARE(childItem(rootItem, "rect23")->width(), 86.0); - QCOMPARE(childItem(rootItem, "rect23")->height(), 10.0); - - // offsets - QCOMPARE(childItem(rootItem, "rect24")->x(), offsetMasterRTL(rootItem, "rect24")-26.0); - QCOMPARE(childItem(rootItem, "rect25")->y(), 60.0); - QCOMPARE(childItem(rootItem, "rect26")->y(), 5.0); - - //baseline - QQuickText *text1 = findItem(rootItem, QLatin1String("text1")); - QQuickText *text2 = findItem(rootItem, QLatin1String("text2")); - QCOMPARE(text1->y(), text2->y()); - - delete view; -} - -// mostly testing that we don't crash -void tst_qquickanchors::loops() -{ - { - QUrl source(testFileUrl("loop1.qml")); - - QString expect = source.toString() + ":6:5: QML Text: Possible anchor loop detected on horizontal anchor."; - QTest::ignoreMessage(QtWarningMsg, expect.toLatin1()); - QTest::ignoreMessage(QtWarningMsg, expect.toLatin1()); - - QQuickView *view = new QQuickView; - view->setSource(source); - qApp->processEvents(); - - delete view; - } - - { - QUrl source(testFileUrl("loop2.qml")); - - QString expect = source.toString() + ":8:3: QML Image: Possible anchor loop detected on horizontal anchor."; - QTest::ignoreMessage(QtWarningMsg, expect.toLatin1()); - - QQuickView *view = new QQuickView; - view->setSource(source); - qApp->processEvents(); - - delete view; - } -} - -void tst_qquickanchors::illegalSets() -{ - QFETCH(QString, qml); - QFETCH(QString, warning); - - QTest::ignoreMessage(QtWarningMsg, warning.toLatin1()); - - QDeclarativeEngine engine; - QDeclarativeComponent component(&engine); - component.setData(QByteArray("import QtQuick 2.0\n" + qml.toUtf8()), QUrl::fromLocalFile("")); - if (!component.isReady()) - qWarning() << "Test errors:" << component.errors(); - QVERIFY(component.isReady()); - QObject *o = component.create(); - delete o; -} - -void tst_qquickanchors::illegalSets_data() -{ - QTest::addColumn("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 } }" - << "file::2:23: QML Rectangle: Cannot specify left, right, and hcenter anchors."; - - foreach (const QString &side, QStringList() << "left" << "right") { - QTest::newRow("H - anchor to V") - << QString("Rectangle { Rectangle { anchors.%1: parent.top } }").arg(side) - << "file::2:13: QML Rectangle: Cannot anchor a horizontal edge to a vertical edge."; - - QTest::newRow("H - anchor to non parent/sibling") - << QString("Rectangle { Item { Rectangle { id: rect } } Rectangle { anchors.%1: rect.%1 } }").arg(side) - << "file::2:45: QML Rectangle: Cannot anchor to an item that isn't a parent or sibling."; - - QTest::newRow("H - anchor to self") - << QString("Rectangle { id: rect; anchors.%1: rect.%1 }").arg(side) - << "file::2:1: QML Rectangle: Cannot anchor item to self."; - } - - - QTest::newRow("V - too many anchors") - << "Rectangle { id: rect; Rectangle { anchors.top: rect.top; anchors.bottom: rect.bottom; anchors.verticalCenter: rect.verticalCenter } }" - << "file::2:23: QML Rectangle: Cannot specify top, bottom, and vcenter anchors."; - - QTest::newRow("V - too many anchors with baseline") - << "Rectangle { Text { id: text1; text: \"Hello\" } Text { anchors.baseline: text1.baseline; anchors.top: text1.top; } }" - << "file::2:47: QML Text: Baseline anchor cannot be used in conjunction with top, bottom, or vcenter anchors."; - - foreach (const QString &side, QStringList() << "top" << "bottom" << "baseline") { - - QTest::newRow("V - anchor to H") - << QString("Rectangle { Rectangle { anchors.%1: parent.left } }").arg(side) - << "file::2:13: QML Rectangle: Cannot anchor a vertical edge to a horizontal edge."; - - QTest::newRow("V - anchor to non parent/sibling") - << QString("Rectangle { Item { Rectangle { id: rect } } Rectangle { anchors.%1: rect.%1 } }").arg(side) - << "file::2:45: QML Rectangle: Cannot anchor to an item that isn't a parent or sibling."; - - QTest::newRow("V - anchor to self") - << QString("Rectangle { id: rect; anchors.%1: rect.%1 }").arg(side) - << "file::2:1: QML Rectangle: Cannot anchor item to self."; - } - - - QTest::newRow("centerIn - anchor to non parent/sibling") - << "Rectangle { Item { Rectangle { id: rect } } Rectangle { anchors.centerIn: rect} }" - << "file::2:45: QML Rectangle: Cannot anchor to an item that isn't a parent or sibling."; - - - QTest::newRow("fill - anchor to non parent/sibling") - << "Rectangle { Item { Rectangle { id: rect } } Rectangle { anchors.fill: rect} }" - << "file::2:45: QML Rectangle: Cannot anchor to an item that isn't a parent or sibling."; -} - -void tst_qquickanchors::reset() -{ - QFETCH(QString, side); - QFETCH(QQuickAnchorLine::AnchorLine, anchorLine); - QFETCH(QQuickAnchors::Anchor, usedAnchor); - - QQuickItem *baseItem = new QQuickItem; - - QQuickAnchorLine anchor; - anchor.item = baseItem; - anchor.anchorLine = anchorLine; - - QQuickItem *item = new QQuickItem; - QQuickItemPrivate *itemPrivate = QQuickItemPrivate::get(item); - - const QMetaObject *meta = itemPrivate->anchors()->metaObject(); - QMetaProperty p = meta->property(meta->indexOfProperty(side.toUtf8().constData())); - - QVERIFY(p.write(itemPrivate->anchors(), qVariantFromValue(anchor))); - QCOMPARE(itemPrivate->anchors()->usedAnchors().testFlag(usedAnchor), true); - - QVERIFY(p.reset(itemPrivate->anchors())); - QCOMPARE(itemPrivate->anchors()->usedAnchors().testFlag(usedAnchor), false); - - delete item; - delete baseItem; -} - -void tst_qquickanchors::reset_data() -{ - QTest::addColumn("side"); - QTest::addColumn("anchorLine"); - QTest::addColumn("usedAnchor"); - - QTest::newRow("left") << "left" << QQuickAnchorLine::Left << QQuickAnchors::LeftAnchor; - QTest::newRow("top") << "top" << QQuickAnchorLine::Top << QQuickAnchors::TopAnchor; - QTest::newRow("right") << "right" << QQuickAnchorLine::Right << QQuickAnchors::RightAnchor; - QTest::newRow("bottom") << "bottom" << QQuickAnchorLine::Bottom << QQuickAnchors::BottomAnchor; - - QTest::newRow("hcenter") << "horizontalCenter" << QQuickAnchorLine::HCenter << QQuickAnchors::HCenterAnchor; - QTest::newRow("vcenter") << "verticalCenter" << QQuickAnchorLine::VCenter << QQuickAnchors::VCenterAnchor; - QTest::newRow("baseline") << "baseline" << QQuickAnchorLine::Baseline << QQuickAnchors::BaselineAnchor; -} - -void tst_qquickanchors::resetConvenience() -{ - QQuickItem *baseItem = new QQuickItem; - QQuickItem *item = new QQuickItem; - QQuickItemPrivate *itemPrivate = QQuickItemPrivate::get(item); - - //fill - itemPrivate->anchors()->setFill(baseItem); - QVERIFY(itemPrivate->anchors()->fill() == baseItem); - itemPrivate->anchors()->resetFill(); - QVERIFY(itemPrivate->anchors()->fill() == 0); - - //centerIn - itemPrivate->anchors()->setCenterIn(baseItem); - QVERIFY(itemPrivate->anchors()->centerIn() == baseItem); - itemPrivate->anchors()->resetCenterIn(); - QVERIFY(itemPrivate->anchors()->centerIn() == 0); - - delete item; - delete baseItem; -} - -void tst_qquickanchors::nullItem() -{ - QFETCH(QString, side); - - QQuickAnchorLine anchor; - QQuickItem *item = new QQuickItem; - QQuickItemPrivate *itemPrivate = QQuickItemPrivate::get(item); - - const QMetaObject *meta = itemPrivate->anchors()->metaObject(); - QMetaProperty p = meta->property(meta->indexOfProperty(side.toUtf8().constData())); - - QTest::ignoreMessage(QtWarningMsg, ": QML Item: Cannot anchor to a null item."); - QVERIFY(p.write(itemPrivate->anchors(), qVariantFromValue(anchor))); - - delete item; -} - -void tst_qquickanchors::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"; -} - -//QTBUG-5428 -void tst_qquickanchors::crash1() -{ - QUrl source(testFileUrl("crash1.qml")); - - QQuickView *view = new QQuickView(source); - qApp->processEvents(); - - delete view; -} - -void tst_qquickanchors::fill() -{ - QQuickView *view = new QQuickView(testFileUrl("fill.qml")); - - qApp->processEvents(); - QQuickRectangle* rect = findItem(view->rootObject(), QLatin1String("filler")); - QQuickItemPrivate *rectPrivate = QQuickItemPrivate::get(rect); - QCOMPARE(rect->x(), 0.0 + 10.0); - QCOMPARE(rect->y(), 0.0 + 30.0); - QCOMPARE(rect->width(), 200.0 - 10.0 - 20.0); - QCOMPARE(rect->height(), 200.0 - 30.0 - 40.0); - //Alter Offsets (tests QTBUG-6631) - rectPrivate->anchors()->setLeftMargin(20.0); - rectPrivate->anchors()->setRightMargin(0.0); - rectPrivate->anchors()->setBottomMargin(0.0); - rectPrivate->anchors()->setTopMargin(10.0); - QCOMPARE(rect->x(), 0.0 + 20.0); - QCOMPARE(rect->y(), 0.0 + 10.0); - QCOMPARE(rect->width(), 200.0 - 20.0); - QCOMPARE(rect->height(), 200.0 - 10.0); - - delete view; -} - -void tst_qquickanchors::fillRTL() -{ - QQuickView *view = new QQuickView(testFileUrl("fill.qml")); - - qApp->processEvents(); - QQuickRectangle* rect = findItem(view->rootObject(), QLatin1String("filler")); - QQuickItemPrivate *rectPrivate = QQuickItemPrivate::get(rect); - mirrorAnchors(rect); - - QCOMPARE(rect->x(), 0.0 + 20.0); - QCOMPARE(rect->y(), 0.0 + 30.0); - QCOMPARE(rect->width(), 200.0 - 10.0 - 20.0); - QCOMPARE(rect->height(), 200.0 - 30.0 - 40.0); - //Alter Offsets (tests QTBUG-6631) - rectPrivate->anchors()->setLeftMargin(20.0); - rectPrivate->anchors()->setRightMargin(0.0); - rectPrivate->anchors()->setBottomMargin(0.0); - rectPrivate->anchors()->setTopMargin(10.0); - QCOMPARE(rect->x(), 0.0 + 0.0); - QCOMPARE(rect->y(), 0.0 + 10.0); - QCOMPARE(rect->width(), 200.0 - 20.0); - QCOMPARE(rect->height(), 200.0 - 10.0); - - delete view; -} - -void tst_qquickanchors::centerIn() -{ - QQuickView *view = new QQuickView(testFileUrl("centerin.qml")); - - qApp->processEvents(); - QQuickRectangle* rect = findItem(view->rootObject(), QLatin1String("centered")); - QQuickItemPrivate *rectPrivate = QQuickItemPrivate::get(rect); - - QCOMPARE(rect->x(), 75.0 + 10); - QCOMPARE(rect->y(), 75.0 + 30); - //Alter Offsets (tests QTBUG-6631) - rectPrivate->anchors()->setHorizontalCenterOffset(-20.0); - rectPrivate->anchors()->setVerticalCenterOffset(-10.0); - QCOMPARE(rect->x(), 75.0 - 20.0); - QCOMPARE(rect->y(), 75.0 - 10.0); - - //QTBUG-21730 (use actual center to prevent animation jitter) - QQuickRectangle* rect2 = findItem(view->rootObject(), QLatin1String("centered2")); - QCOMPARE(rect2->x(), 94.5); - QCOMPARE(rect2->y(), 94.5); - - delete view; -} - -void tst_qquickanchors::centerInRTL() -{ - QQuickView *view = new QQuickView(testFileUrl("centerin.qml")); - - qApp->processEvents(); - QQuickRectangle* rect = findItem(view->rootObject(), QLatin1String("centered")); - QQuickItemPrivate *rectPrivate = QQuickItemPrivate::get(rect); - mirrorAnchors(rect); - - QCOMPARE(rect->x(), 75.0 - 10); - QCOMPARE(rect->y(), 75.0 + 30); - //Alter Offsets (tests QTBUG-6631) - rectPrivate->anchors()->setHorizontalCenterOffset(-20.0); - rectPrivate->anchors()->setVerticalCenterOffset(-10.0); - QCOMPARE(rect->x(), 75.0 + 20.0); - QCOMPARE(rect->y(), 75.0 - 10.0); - - delete view; -} - -//QTBUG-12441 -void tst_qquickanchors::centerInRotation() -{ - QQuickView *view = new QQuickView(testFileUrl("centerinRotation.qml")); - - qApp->processEvents(); - QQuickRectangle* outer = findItem(view->rootObject(), QLatin1String("outer")); - QQuickRectangle* inner = findItem(view->rootObject(), QLatin1String("inner")); - - QCOMPARE(outer->x(), qreal(49.5)); - QCOMPARE(outer->y(), qreal(49.5)); - QCOMPARE(inner->x(), qreal(25.5)); - QCOMPARE(inner->y(), qreal(25.5)); - - delete view; -} - -void tst_qquickanchors::hvCenter() -{ - QQuickView *view = new QQuickView(testFileUrl("hvCenter.qml")); - - qApp->processEvents(); - QQuickRectangle* rect = findItem(view->rootObject(), QLatin1String("centered")); - QQuickItemPrivate *rectPrivate = QQuickItemPrivate::get(rect); - - // test QTBUG-10999 - QCOMPARE(rect->x(), 10.0); - QCOMPARE(rect->y(), 19.0); - - rectPrivate->anchors()->setHorizontalCenterOffset(-5.0); - rectPrivate->anchors()->setVerticalCenterOffset(5.0); - QCOMPARE(rect->x(), 10.0 - 5.0); - QCOMPARE(rect->y(), 19.0 + 5.0); - - delete view; -} - -void tst_qquickanchors::hvCenterRTL() -{ - QQuickView *view = new QQuickView(testFileUrl("hvCenter.qml")); - - qApp->processEvents(); - QQuickRectangle* rect = findItem(view->rootObject(), QLatin1String("centered")); - QQuickItemPrivate *rectPrivate = QQuickItemPrivate::get(rect); - mirrorAnchors(rect); - - // test QTBUG-10999 - QCOMPARE(rect->x(), 10.0); - QCOMPARE(rect->y(), 19.0); - - rectPrivate->anchors()->setHorizontalCenterOffset(-5.0); - rectPrivate->anchors()->setVerticalCenterOffset(5.0); - QCOMPARE(rect->x(), 10.0 + 5.0); - QCOMPARE(rect->y(), 19.0 + 5.0); - - delete view; -} -void tst_qquickanchors::margins() -{ - QQuickView *view = new QQuickView(testFileUrl("margins.qml")); - - qApp->processEvents(); - QQuickRectangle* rect = findItem(view->rootObject(), QLatin1String("filler")); - QQuickItemPrivate *rectPrivate = QQuickItemPrivate::get(rect); - QCOMPARE(rect->x(), 5.0); - QCOMPARE(rect->y(), 6.0); - QCOMPARE(rect->width(), 200.0 - 5.0 - 10.0); - QCOMPARE(rect->height(), 200.0 - 6.0 - 10.0); - - rectPrivate->anchors()->setTopMargin(0.0); - rectPrivate->anchors()->setMargins(20.0); - - QCOMPARE(rect->x(), 5.0); - QCOMPARE(rect->y(), 20.0); - QCOMPARE(rect->width(), 200.0 - 5.0 - 20.0); - QCOMPARE(rect->height(), 200.0 - 20.0 - 20.0); - - delete view; -} - -void tst_qquickanchors::marginsRTL() -{ - QQuickView *view = new QQuickView(testFileUrl("margins.qml")); - - QQuickRectangle* rect = findItem(view->rootObject(), QLatin1String("filler")); - QQuickItemPrivate *rectPrivate = QQuickItemPrivate::get(rect); - mirrorAnchors(rect); - - QCOMPARE(rect->x(), 10.0); - QCOMPARE(rect->y(), 6.0); - QCOMPARE(rect->width(), 200.0 - 5.0 - 10.0); - QCOMPARE(rect->height(), 200.0 - 6.0 - 10.0); - - rectPrivate->anchors()->setTopMargin(0.0); - rectPrivate->anchors()->setMargins(20.0); - - QCOMPARE(rect->x(), 20.0); - QCOMPARE(rect->y(), 20.0); - QCOMPARE(rect->width(), 200.0 - 5.0 - 20.0); - QCOMPARE(rect->height(), 200.0 - 20.0 - 20.0); - - delete view; -} - - -QTEST_MAIN(tst_qquickanchors) - -#include "tst_qquickanchors.moc" diff --git a/tests/auto/qtquick2/qquickanimatedimage/data/colors.gif b/tests/auto/qtquick2/qquickanimatedimage/data/colors.gif deleted file mode 100644 index 1270bfaa79..0000000000 Binary files a/tests/auto/qtquick2/qquickanimatedimage/data/colors.gif and /dev/null differ diff --git a/tests/auto/qtquick2/qquickanimatedimage/data/colors.qml b/tests/auto/qtquick2/qquickanimatedimage/data/colors.qml deleted file mode 100644 index 5ccc0148dd..0000000000 --- a/tests/auto/qtquick2/qquickanimatedimage/data/colors.qml +++ /dev/null @@ -1,5 +0,0 @@ -import QtQuick 2.0 - -AnimatedImage { - source: "colors.gif" -} diff --git a/tests/auto/qtquick2/qquickanimatedimage/data/hearts.gif b/tests/auto/qtquick2/qquickanimatedimage/data/hearts.gif deleted file mode 100644 index cfb55f27f5..0000000000 Binary files a/tests/auto/qtquick2/qquickanimatedimage/data/hearts.gif and /dev/null differ diff --git a/tests/auto/qtquick2/qquickanimatedimage/data/hearts.qml b/tests/auto/qtquick2/qquickanimatedimage/data/hearts.qml deleted file mode 100644 index 717bab430b..0000000000 --- a/tests/auto/qtquick2/qquickanimatedimage/data/hearts.qml +++ /dev/null @@ -1,6 +0,0 @@ -import QtQuick 2.0 - -AnimatedImage { - source: "hearts.gif" - playing: false -} diff --git a/tests/auto/qtquick2/qquickanimatedimage/data/qmldir b/tests/auto/qtquick2/qquickanimatedimage/data/qmldir deleted file mode 100644 index ef7c1f44f3..0000000000 --- a/tests/auto/qtquick2/qquickanimatedimage/data/qmldir +++ /dev/null @@ -1 +0,0 @@ -# No local types diff --git a/tests/auto/qtquick2/qquickanimatedimage/data/qtbug-16520.qml b/tests/auto/qtquick2/qquickanimatedimage/data/qtbug-16520.qml deleted file mode 100644 index da77a4063b..0000000000 --- a/tests/auto/qtquick2/qquickanimatedimage/data/qtbug-16520.qml +++ /dev/null @@ -1,17 +0,0 @@ -import QtQuick 2.0 - -Rectangle { - width: 500 - height: 500 - - AnimatedImage { - objectName: "anim" - anchors.centerIn: parent - asynchronous: true - opacity: status == AnimatedImage.Ready ? 1 : 0 - - Behavior on opacity { - NumberAnimation { duration: 1000 } - } - } -} diff --git a/tests/auto/qtquick2/qquickanimatedimage/data/stickman.gif b/tests/auto/qtquick2/qquickanimatedimage/data/stickman.gif deleted file mode 100644 index 7c4cd18687..0000000000 Binary files a/tests/auto/qtquick2/qquickanimatedimage/data/stickman.gif and /dev/null differ diff --git a/tests/auto/qtquick2/qquickanimatedimage/data/stickman.qml b/tests/auto/qtquick2/qquickanimatedimage/data/stickman.qml deleted file mode 100644 index a47924de21..0000000000 --- a/tests/auto/qtquick2/qquickanimatedimage/data/stickman.qml +++ /dev/null @@ -1,5 +0,0 @@ -import QtQuick 2.0 - -AnimatedImage { - source: "stickman.gif" -} diff --git a/tests/auto/qtquick2/qquickanimatedimage/data/stickmanerror1.qml b/tests/auto/qtquick2/qquickanimatedimage/data/stickmanerror1.qml deleted file mode 100644 index 4f823b3d70..0000000000 --- a/tests/auto/qtquick2/qquickanimatedimage/data/stickmanerror1.qml +++ /dev/null @@ -1,6 +0,0 @@ -import QtQuick 2.0 - -AnimatedImage { - sourceSize: "240x180" - source: "stickman.gif" -} diff --git a/tests/auto/qtquick2/qquickanimatedimage/data/stickmanpause.qml b/tests/auto/qtquick2/qquickanimatedimage/data/stickmanpause.qml deleted file mode 100644 index ef771ed56f..0000000000 --- a/tests/auto/qtquick2/qquickanimatedimage/data/stickmanpause.qml +++ /dev/null @@ -1,7 +0,0 @@ -import QtQuick 2.0 - -AnimatedImage { - source: "stickman.gif" - paused: true - currentFrame: 2 -} diff --git a/tests/auto/qtquick2/qquickanimatedimage/data/stickmanscaled.qml b/tests/auto/qtquick2/qquickanimatedimage/data/stickmanscaled.qml deleted file mode 100644 index 1ef1f95165..0000000000 --- a/tests/auto/qtquick2/qquickanimatedimage/data/stickmanscaled.qml +++ /dev/null @@ -1,7 +0,0 @@ -import QtQuick 2.0 - -AnimatedImage { - width: 240 - height: 180 - source: "stickman.gif" -} diff --git a/tests/auto/qtquick2/qquickanimatedimage/data/stickmanstopped.qml b/tests/auto/qtquick2/qquickanimatedimage/data/stickmanstopped.qml deleted file mode 100644 index 0bf80b8972..0000000000 --- a/tests/auto/qtquick2/qquickanimatedimage/data/stickmanstopped.qml +++ /dev/null @@ -1,6 +0,0 @@ -import QtQuick 2.0 - -AnimatedImage { - source: "stickman.gif" - playing: false -} diff --git a/tests/auto/qtquick2/qquickanimatedimage/qquickanimatedimage.pro b/tests/auto/qtquick2/qquickanimatedimage/qquickanimatedimage.pro deleted file mode 100644 index d776a73b21..0000000000 --- a/tests/auto/qtquick2/qquickanimatedimage/qquickanimatedimage.pro +++ /dev/null @@ -1,17 +0,0 @@ -CONFIG += testcase -TARGET = tst_qquickanimatedimage -HEADERS += ../../shared/testhttpserver.h -SOURCES += tst_qquickanimatedimage.cpp \ - ../../shared/testhttpserver.cpp - -include (../../shared/util.pri) - -macx:CONFIG -= app_bundle - -testDataFiles.files = data -testDataFiles.path = . -DEPLOYMENT += testDataFiles - -CONFIG += parallel_test - -QT += core-private gui-private declarative-private quick-private network testlib diff --git a/tests/auto/qtquick2/qquickanimatedimage/tst_qquickanimatedimage.cpp b/tests/auto/qtquick2/qquickanimatedimage/tst_qquickanimatedimage.cpp deleted file mode 100644 index c124e4f62b..0000000000 --- a/tests/auto/qtquick2/qquickanimatedimage/tst_qquickanimatedimage.cpp +++ /dev/null @@ -1,374 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "../../shared/testhttpserver.h" -#include "../../shared/util.h" - -Q_DECLARE_METATYPE(QQuickImageBase::Status) - -class tst_qquickanimatedimage : public QDeclarativeDataTest -{ - Q_OBJECT -public: - tst_qquickanimatedimage() {} - -private slots: - void play(); - void pause(); - void stopped(); - void setFrame(); - void frameCount(); - void mirror_running(); - void mirror_notRunning(); - void mirror_notRunning_data(); - void remote(); - void remote_data(); - void sourceSize(); - void sourceSizeReadOnly(); - void invalidSource(); - void qtbug_16520(); - void progressAndStatusChanges(); - -}; - -void tst_qquickanimatedimage::play() -{ - QDeclarativeEngine engine; - QDeclarativeComponent component(&engine, testFileUrl("stickman.qml")); - QQuickAnimatedImage *anim = qobject_cast(component.create()); - QVERIFY(anim); - QVERIFY(anim->isPlaying()); - - delete anim; -} - -void tst_qquickanimatedimage::pause() -{ - QDeclarativeEngine engine; - QDeclarativeComponent component(&engine, testFileUrl("stickmanpause.qml")); - QQuickAnimatedImage *anim = qobject_cast(component.create()); - QVERIFY(anim); - QVERIFY(anim->isPlaying()); - QVERIFY(anim->isPaused()); - - delete anim; -} - -void tst_qquickanimatedimage::stopped() -{ - QDeclarativeEngine engine; - QDeclarativeComponent component(&engine, testFileUrl("stickmanstopped.qml")); - QQuickAnimatedImage *anim = qobject_cast(component.create()); - QVERIFY(anim); - QVERIFY(!anim->isPlaying()); - QCOMPARE(anim->currentFrame(), 0); - - delete anim; -} - -void tst_qquickanimatedimage::setFrame() -{ - QDeclarativeEngine engine; - QDeclarativeComponent component(&engine, testFileUrl("stickmanpause.qml")); - QQuickAnimatedImage *anim = qobject_cast(component.create()); - QVERIFY(anim); - QVERIFY(anim->isPlaying()); - QCOMPARE(anim->currentFrame(), 2); - - delete anim; -} - -void tst_qquickanimatedimage::frameCount() -{ - QDeclarativeEngine engine; - QDeclarativeComponent component(&engine, testFileUrl("colors.qml")); - QQuickAnimatedImage *anim = qobject_cast(component.create()); - QVERIFY(anim); - QVERIFY(anim->isPlaying()); - QCOMPARE(anim->frameCount(), 3); - - delete anim; -} - -void tst_qquickanimatedimage::mirror_running() -{ - // test where mirror is set to true after animation has started - - QQuickView canvas; - canvas.show(); - - canvas.setSource(testFileUrl("hearts.qml")); - QQuickAnimatedImage *anim = qobject_cast(canvas.rootObject()); - QVERIFY(anim); - - int width = anim->property("width").toInt(); - - QCOMPARE(anim->currentFrame(), 0); - QPixmap frame0 = QPixmap::fromImage(canvas.grabFrameBuffer()); - - anim->setCurrentFrame(1); - QPixmap frame1 = QPixmap::fromImage(canvas.grabFrameBuffer()); - - anim->setCurrentFrame(0); - - QSignalSpy spy(anim, SIGNAL(frameChanged())); - anim->setPlaying(true); - - QTRY_VERIFY(spy.count() == 1); spy.clear(); - anim->setProperty("mirror", true); - - QCOMPARE(anim->currentFrame(), 1); - QPixmap frame1_flipped = QPixmap::fromImage(canvas.grabFrameBuffer()); - - QTRY_VERIFY(spy.count() == 1); spy.clear(); - QCOMPARE(anim->currentFrame(), 0); // animation only has 2 frames, should cycle back to first - QPixmap frame0_flipped = QPixmap::fromImage(canvas.grabFrameBuffer()); - - QSKIP("Skip while QTBUG-19351 and QTBUG-19252 are not resolved"); - - QTransform transform; - transform.translate(width, 0).scale(-1, 1.0); - QPixmap frame0_expected = frame0.transformed(transform); - QPixmap frame1_expected = frame1.transformed(transform); - - QCOMPARE(frame0_flipped, frame0_expected); - QCOMPARE(frame1_flipped, frame1_expected); -} - -void tst_qquickanimatedimage::mirror_notRunning() -{ - QFETCH(QUrl, fileUrl); - - QQuickView canvas; - canvas.show(); - - canvas.setSource(fileUrl); - QQuickAnimatedImage *anim = qobject_cast(canvas.rootObject()); - QVERIFY(anim); - - int width = anim->property("width").toInt(); - QPixmap screenshot = QPixmap::fromImage(canvas.grabFrameBuffer()); - - QTransform transform; - transform.translate(width, 0).scale(-1, 1.0); - QPixmap expected = screenshot.transformed(transform); - - int frame = anim->currentFrame(); - bool playing = anim->isPlaying(); - bool paused = anim->isPlaying(); - - anim->setProperty("mirror", true); - screenshot = QPixmap::fromImage(canvas.grabFrameBuffer()); - - QSKIP("Skip while QTBUG-19351 and QTBUG-19252 are not resolved"); - QCOMPARE(screenshot, expected); - - // mirroring should not change the current frame or playing status - QCOMPARE(anim->currentFrame(), frame); - QCOMPARE(anim->isPlaying(), playing); - QCOMPARE(anim->isPaused(), paused); -} - -void tst_qquickanimatedimage::mirror_notRunning_data() -{ - QTest::addColumn("fileUrl"); - - QTest::newRow("paused") << testFileUrl("stickmanpause.qml"); - QTest::newRow("stopped") << testFileUrl("stickmanstopped.qml"); -} - -void tst_qquickanimatedimage::remote() -{ - QFETCH(QString, fileName); - QFETCH(bool, paused); - - TestHTTPServer server(14449); - QVERIFY(server.isValid()); - server.serveDirectory(dataDirectory()); - - QDeclarativeEngine engine; - QDeclarativeComponent component(&engine, QUrl("http://127.0.0.1:14449/" + fileName)); - QTRY_VERIFY(component.isReady()); - - QQuickAnimatedImage *anim = qobject_cast(component.create()); - QVERIFY(anim); - - QTRY_VERIFY(anim->isPlaying()); - if (paused) { - QTRY_VERIFY(anim->isPaused()); - QCOMPARE(anim->currentFrame(), 2); - } - QVERIFY(anim->status() != QQuickAnimatedImage::Error); - - delete anim; -} - -void tst_qquickanimatedimage::sourceSize() -{ - QDeclarativeEngine engine; - QDeclarativeComponent component(&engine, testFileUrl("stickmanscaled.qml")); - QQuickAnimatedImage *anim = qobject_cast(component.create()); - QVERIFY(anim); - QCOMPARE(anim->width(),240.0); - QCOMPARE(anim->height(),180.0); - QCOMPARE(anim->sourceSize(),QSize(160,120)); - - delete anim; -} - -void tst_qquickanimatedimage::sourceSizeReadOnly() -{ - QDeclarativeEngine engine; - QDeclarativeComponent component(&engine, testFileUrl("stickmanerror1.qml")); - QVERIFY(component.isError()); - QCOMPARE(component.errors().at(0).description(), QString("Invalid property assignment: \"sourceSize\" is a read-only property")); -} - -void tst_qquickanimatedimage::remote_data() -{ - QTest::addColumn("fileName"); - QTest::addColumn("paused"); - - QTest::newRow("playing") << "stickman.qml" << false; - QTest::newRow("paused") << "stickmanpause.qml" << true; -} - -void tst_qquickanimatedimage::invalidSource() -{ - QDeclarativeEngine engine; - QDeclarativeComponent component(&engine); - component.setData("import QtQuick 2.0\n AnimatedImage { source: \"no-such-file.gif\" }", QUrl::fromLocalFile("")); - QVERIFY(component.isReady()); - - QTest::ignoreMessage(QtWarningMsg, "file::2:2: QML AnimatedImage: Error Reading Animated Image File file:no-such-file.gif"); - - QQuickAnimatedImage *anim = qobject_cast(component.create()); - QVERIFY(anim); - - QVERIFY(!anim->isPlaying()); - QVERIFY(!anim->isPaused()); - QCOMPARE(anim->currentFrame(), 0); - QCOMPARE(anim->frameCount(), 0); - QTRY_VERIFY(anim->status() == 3); -} - -void tst_qquickanimatedimage::qtbug_16520() -{ - TestHTTPServer server(14449); - QVERIFY(server.isValid()); - server.serveDirectory(dataDirectory()); - - QDeclarativeEngine engine; - QDeclarativeComponent component(&engine, testFileUrl("qtbug-16520.qml")); - QTRY_VERIFY(component.isReady()); - - QQuickRectangle *root = qobject_cast(component.create()); - QVERIFY(root); - QQuickAnimatedImage *anim = root->findChild("anim"); - - anim->setProperty("source", "http://127.0.0.1:14449/stickman.gif"); - - QTRY_VERIFY(anim->opacity() == 0); - QTRY_VERIFY(anim->opacity() == 1); - - delete anim; -} - -void tst_qquickanimatedimage::progressAndStatusChanges() -{ - TestHTTPServer server(14449); - QVERIFY(server.isValid()); - server.serveDirectory(dataDirectory()); - - QDeclarativeEngine engine; - QString componentStr = "import QtQuick 2.0\nAnimatedImage { source: srcImage }"; - QDeclarativeContext *ctxt = engine.rootContext(); - ctxt->setContextProperty("srcImage", testFileUrl("stickman.gif")); - QDeclarativeComponent component(&engine); - component.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); - QQuickImage *obj = qobject_cast(component.create()); - QVERIFY(obj != 0); - QVERIFY(obj->status() == QQuickImage::Ready); - QTRY_VERIFY(obj->progress() == 1.0); - - qRegisterMetaType(); - QSignalSpy sourceSpy(obj, SIGNAL(sourceChanged(const QUrl &))); - QSignalSpy progressSpy(obj, SIGNAL(progressChanged(qreal))); - QSignalSpy statusSpy(obj, SIGNAL(statusChanged(QQuickImageBase::Status))); - - // Loading local file - ctxt->setContextProperty("srcImage", testFileUrl("colors.gif")); - QTRY_VERIFY(obj->status() == QQuickImage::Ready); - QTRY_VERIFY(obj->progress() == 1.0); - QTRY_COMPARE(sourceSpy.count(), 1); - QTRY_COMPARE(progressSpy.count(), 0); - QTRY_COMPARE(statusSpy.count(), 0); - - // Loading remote file - ctxt->setContextProperty("srcImage", "http://127.0.0.1:14449/stickman.gif"); - QTRY_VERIFY(obj->status() == QQuickImage::Loading); - QTRY_VERIFY(obj->progress() == 0.0); - QTRY_VERIFY(obj->status() == QQuickImage::Ready); - QTRY_VERIFY(obj->progress() == 1.0); - QTRY_COMPARE(sourceSpy.count(), 2); - QTRY_VERIFY(progressSpy.count() > 1); - QTRY_COMPARE(statusSpy.count(), 2); - - ctxt->setContextProperty("srcImage", ""); - QTRY_VERIFY(obj->status() == QQuickImage::Null); - QTRY_VERIFY(obj->progress() == 0.0); - QTRY_COMPARE(sourceSpy.count(), 3); - QTRY_VERIFY(progressSpy.count() > 2); - QTRY_COMPARE(statusSpy.count(), 3); -} - -QTEST_MAIN(tst_qquickanimatedimage) - -#include "tst_qquickanimatedimage.moc" diff --git a/tests/auto/qtquick2/qquickborderimage/data/colors-mirror.png b/tests/auto/qtquick2/qquickborderimage/data/colors-mirror.png deleted file mode 100644 index e30870dd1e..0000000000 Binary files a/tests/auto/qtquick2/qquickborderimage/data/colors-mirror.png and /dev/null differ diff --git a/tests/auto/qtquick2/qquickborderimage/data/colors-round-quotes.sci b/tests/auto/qtquick2/qquickborderimage/data/colors-round-quotes.sci deleted file mode 100644 index 294f3cfe48..0000000000 --- a/tests/auto/qtquick2/qquickborderimage/data/colors-round-quotes.sci +++ /dev/null @@ -1,7 +0,0 @@ -border.left:10 -border.top:20 -border.right:30 -border.bottom:40 -horizontalTileRule:Round -verticalTileRule:Repeat -source:"colors.png" diff --git a/tests/auto/qtquick2/qquickborderimage/data/colors-round-remote.sci b/tests/auto/qtquick2/qquickborderimage/data/colors-round-remote.sci deleted file mode 100644 index c673bed598..0000000000 --- a/tests/auto/qtquick2/qquickborderimage/data/colors-round-remote.sci +++ /dev/null @@ -1,7 +0,0 @@ -border.left:10 -border.top:20 -border.right:30 -border.bottom:40 -horizontalTileRule:Round -verticalTileRule:Repeat -source:http://127.0.0.1:14446/colors.png diff --git a/tests/auto/qtquick2/qquickborderimage/data/colors-round.sci b/tests/auto/qtquick2/qquickborderimage/data/colors-round.sci deleted file mode 100644 index 5d2f49f0e1..0000000000 --- a/tests/auto/qtquick2/qquickborderimage/data/colors-round.sci +++ /dev/null @@ -1,7 +0,0 @@ -border.left:10 -border.top:20 -border.right:30 -border.bottom:40 -horizontalTileRule:Round -verticalTileRule:Repeat -source:colors.png diff --git a/tests/auto/qtquick2/qquickborderimage/data/colors.png b/tests/auto/qtquick2/qquickborderimage/data/colors.png deleted file mode 100644 index dfb62f3d64..0000000000 Binary files a/tests/auto/qtquick2/qquickborderimage/data/colors.png and /dev/null differ diff --git a/tests/auto/qtquick2/qquickborderimage/data/heart200.png b/tests/auto/qtquick2/qquickborderimage/data/heart200.png deleted file mode 100644 index 5a31ae8f4d..0000000000 Binary files a/tests/auto/qtquick2/qquickborderimage/data/heart200.png and /dev/null differ diff --git a/tests/auto/qtquick2/qquickborderimage/data/invalid.sci b/tests/auto/qtquick2/qquickborderimage/data/invalid.sci deleted file mode 100644 index 98c72c9bf1..0000000000 --- a/tests/auto/qtquick2/qquickborderimage/data/invalid.sci +++ /dev/null @@ -1,7 +0,0 @@ -border.left:10 -border.top:20 -border.down:30 -border.up:40 -horizontalTileRule:Roun -verticalTileRule:Repea -source:colors.png diff --git a/tests/auto/qtquick2/qquickborderimage/data/mirror.qml b/tests/auto/qtquick2/qquickborderimage/data/mirror.qml deleted file mode 100644 index abab076e08..0000000000 --- a/tests/auto/qtquick2/qquickborderimage/data/mirror.qml +++ /dev/null @@ -1,7 +0,0 @@ -import QtQuick 2.0 - -BorderImage { - source: "colors-mirror.png" - width: 300; height: 300 - border { top: 30; right: 30; bottom: 30; left: 30 } -} diff --git a/tests/auto/qtquick2/qquickborderimage/qquickborderimage.pro b/tests/auto/qtquick2/qquickborderimage/qquickborderimage.pro deleted file mode 100644 index 2073b4492f..0000000000 --- a/tests/auto/qtquick2/qquickborderimage/qquickborderimage.pro +++ /dev/null @@ -1,17 +0,0 @@ -CONFIG += testcase -TARGET = tst_qquickborderimage -macx:CONFIG -= app_bundle - -HEADERS += ../../shared/testhttpserver.h -SOURCES += tst_qquickborderimage.cpp \ - ../../shared/testhttpserver.cpp - -include (../../shared/util.pri) - -testDataFiles.files = data -testDataFiles.path = . -DEPLOYMENT += testDataFiles - -CONFIG += parallel_test - -QT += core-private gui-private declarative-private quick-private network widgets testlib diff --git a/tests/auto/qtquick2/qquickborderimage/tst_qquickborderimage.cpp b/tests/auto/qtquick2/qquickborderimage/tst_qquickborderimage.cpp deleted file mode 100644 index dad44d6ee7..0000000000 --- a/tests/auto/qtquick2/qquickborderimage/tst_qquickborderimage.cpp +++ /dev/null @@ -1,373 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include - -#include "../../shared/testhttpserver.h" -#include "../../shared/util.h" - -#define SERVER_PORT 14446 -#define SERVER_ADDR "http://127.0.0.1:14446" - -class tst_qquickborderimage : public QDeclarativeDataTest - -{ - Q_OBJECT -public: - tst_qquickborderimage(); - -private slots: - void noSource(); - void imageSource(); - void imageSource_data(); - void clearSource(); - void resized(); - void smooth(); - void mirror(); - void tileModes(); - void sciSource(); - void sciSource_data(); - void invalidSciFile(); - void pendingRemoteRequest(); - void pendingRemoteRequest_data(); - -private: - QDeclarativeEngine engine; -}; - -tst_qquickborderimage::tst_qquickborderimage() -{ -} - -void tst_qquickborderimage::noSource() -{ - QString componentStr = "import QtQuick 2.0\nBorderImage { source: \"\" }"; - QDeclarativeComponent component(&engine); - component.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); - QQuickBorderImage *obj = qobject_cast(component.create()); - QVERIFY(obj != 0); - QCOMPARE(obj->source(), QUrl()); - QCOMPARE(obj->width(), 0.); - QCOMPARE(obj->height(), 0.); - QCOMPARE(obj->horizontalTileMode(), QQuickBorderImage::Stretch); - QCOMPARE(obj->verticalTileMode(), QQuickBorderImage::Stretch); - - delete obj; -} - -void tst_qquickborderimage::imageSource_data() -{ - QTest::addColumn("source"); - QTest::addColumn("remote"); - QTest::addColumn("error"); - - QTest::newRow("local") << testFileUrl("colors.png").toString() << false << ""; - QTest::newRow("local not found") << testFileUrl("no-such-file.png").toString() << false - << "file::2:1: QML BorderImage: Cannot open: " + testFileUrl("no-such-file.png").toString(); - QTest::newRow("remote") << SERVER_ADDR "/colors.png" << true << ""; - QTest::newRow("remote not found") << SERVER_ADDR "/no-such-file.png" << true - << "file::2:1: QML BorderImage: Error downloading " SERVER_ADDR "/no-such-file.png - server replied: Not found"; -} - -void tst_qquickborderimage::imageSource() -{ - QFETCH(QString, source); - QFETCH(bool, remote); - QFETCH(QString, error); - - TestHTTPServer *server = 0; - if (remote) { - server = new TestHTTPServer(SERVER_PORT); - QVERIFY(server->isValid()); - server->serveDirectory(dataDirectory()); - } - - if (!error.isEmpty()) - QTest::ignoreMessage(QtWarningMsg, error.toUtf8()); - - QString componentStr = "import QtQuick 2.0\nBorderImage { source: \"" + source + "\" }"; - QDeclarativeComponent component(&engine); - component.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); - QQuickBorderImage *obj = qobject_cast(component.create()); - QVERIFY(obj != 0); - - if (remote) - QTRY_VERIFY(obj->status() == QQuickBorderImage::Loading); - - QCOMPARE(obj->source(), remote ? source : QUrl(source)); - - if (error.isEmpty()) { - QTRY_VERIFY(obj->status() == QQuickBorderImage::Ready); - QCOMPARE(obj->width(), 120.); - QCOMPARE(obj->height(), 120.); - QCOMPARE(obj->sourceSize().width(), 120); - QCOMPARE(obj->sourceSize().height(), 120); - QCOMPARE(obj->horizontalTileMode(), QQuickBorderImage::Stretch); - QCOMPARE(obj->verticalTileMode(), QQuickBorderImage::Stretch); - } else { - QTRY_VERIFY(obj->status() == QQuickBorderImage::Error); - } - - delete obj; - delete server; -} - -void tst_qquickborderimage::clearSource() -{ - QString componentStr = "import QtQuick 2.0\nBorderImage { source: srcImage }"; - QDeclarativeContext *ctxt = engine.rootContext(); - ctxt->setContextProperty("srcImage", testFileUrl("colors.png")); - QDeclarativeComponent component(&engine); - component.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); - QQuickBorderImage *obj = qobject_cast(component.create()); - QVERIFY(obj != 0); - QVERIFY(obj->status() == QQuickBorderImage::Ready); - QCOMPARE(obj->width(), 120.); - QCOMPARE(obj->height(), 120.); - - ctxt->setContextProperty("srcImage", ""); - QVERIFY(obj->source().isEmpty()); - QVERIFY(obj->status() == QQuickBorderImage::Null); - QCOMPARE(obj->width(), 0.); - QCOMPARE(obj->height(), 0.); -} - -void tst_qquickborderimage::resized() -{ - QString componentStr = "import QtQuick 2.0\nBorderImage { source: \"" + testFileUrl("colors.png").toString() + "\"; width: 300; height: 300 }"; - QDeclarativeComponent component(&engine); - component.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); - QQuickBorderImage *obj = qobject_cast(component.create()); - QVERIFY(obj != 0); - QCOMPARE(obj->width(), 300.); - QCOMPARE(obj->height(), 300.); - QCOMPARE(obj->sourceSize().width(), 120); - QCOMPARE(obj->sourceSize().height(), 120); - QCOMPARE(obj->horizontalTileMode(), QQuickBorderImage::Stretch); - QCOMPARE(obj->verticalTileMode(), QQuickBorderImage::Stretch); - - delete obj; -} - -void tst_qquickborderimage::smooth() -{ - QString componentStr = "import QtQuick 2.0\nBorderImage { source: \"" + testFile("colors.png") + "\"; smooth: true; width: 300; height: 300 }"; - QDeclarativeComponent component(&engine); - component.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); - QQuickBorderImage *obj = qobject_cast(component.create()); - QVERIFY(obj != 0); - QCOMPARE(obj->width(), 300.); - QCOMPARE(obj->height(), 300.); - QCOMPARE(obj->smooth(), true); - QCOMPARE(obj->horizontalTileMode(), QQuickBorderImage::Stretch); - QCOMPARE(obj->verticalTileMode(), QQuickBorderImage::Stretch); - - delete obj; -} - -void tst_qquickborderimage::mirror() -{ - QQuickView *canvas = new QQuickView; - canvas->setSource(testFileUrl("mirror.qml")); - QQuickBorderImage *image = qobject_cast(canvas->rootObject()); - QVERIFY(image != 0); - - QImage screenshot = canvas->grabFrameBuffer(); - - QImage srcPixmap(screenshot); - QTransform transform; - transform.translate(image->width(), 0).scale(-1, 1.0); - srcPixmap = srcPixmap.transformed(transform); - - image->setProperty("mirror", true); - screenshot = canvas->grabFrameBuffer(); - QCOMPARE(screenshot, srcPixmap); - - delete canvas; -} - -void tst_qquickborderimage::tileModes() -{ - { - QString componentStr = "import QtQuick 2.0\nBorderImage { source: \"" + testFile("colors.png") + "\"; width: 100; height: 300; horizontalTileMode: BorderImage.Repeat; verticalTileMode: BorderImage.Repeat }"; - QDeclarativeComponent component(&engine); - component.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); - QQuickBorderImage *obj = qobject_cast(component.create()); - QVERIFY(obj != 0); - QCOMPARE(obj->width(), 100.); - QCOMPARE(obj->height(), 300.); - QCOMPARE(obj->horizontalTileMode(), QQuickBorderImage::Repeat); - QCOMPARE(obj->verticalTileMode(), QQuickBorderImage::Repeat); - - delete obj; - } - { - QString componentStr = "import QtQuick 2.0\nBorderImage { source: \"" + testFile("colors.png") + "\"; width: 300; height: 150; horizontalTileMode: BorderImage.Round; verticalTileMode: BorderImage.Round }"; - QDeclarativeComponent component(&engine); - component.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); - QQuickBorderImage *obj = qobject_cast(component.create()); - QVERIFY(obj != 0); - QCOMPARE(obj->width(), 300.); - QCOMPARE(obj->height(), 150.); - QCOMPARE(obj->horizontalTileMode(), QQuickBorderImage::Round); - QCOMPARE(obj->verticalTileMode(), QQuickBorderImage::Round); - - delete obj; - } -} - -void tst_qquickborderimage::sciSource() -{ - QFETCH(QString, source); - QFETCH(bool, valid); - - bool remote = source.startsWith("http"); - TestHTTPServer *server = 0; - if (remote) { - server = new TestHTTPServer(SERVER_PORT); - QVERIFY(server->isValid()); - server->serveDirectory(dataDirectory()); - } - - QString componentStr = "import QtQuick 2.0\nBorderImage { source: \"" + source + "\"; width: 300; height: 300 }"; - QDeclarativeComponent component(&engine); - component.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); - QQuickBorderImage *obj = qobject_cast(component.create()); - QVERIFY(obj != 0); - - if (remote) - QTRY_VERIFY(obj->status() == QQuickBorderImage::Loading); - - QCOMPARE(obj->source(), remote ? source : QUrl(source)); - QCOMPARE(obj->width(), 300.); - QCOMPARE(obj->height(), 300.); - - if (valid) { - QTRY_VERIFY(obj->status() == QQuickBorderImage::Ready); - QCOMPARE(obj->border()->left(), 10); - QCOMPARE(obj->border()->top(), 20); - QCOMPARE(obj->border()->right(), 30); - QCOMPARE(obj->border()->bottom(), 40); - QCOMPARE(obj->horizontalTileMode(), QQuickBorderImage::Round); - QCOMPARE(obj->verticalTileMode(), QQuickBorderImage::Repeat); - } else { - QTRY_VERIFY(obj->status() == QQuickBorderImage::Error); - } - - delete obj; - delete server; -} - -void tst_qquickborderimage::sciSource_data() -{ - QTest::addColumn("source"); - QTest::addColumn("valid"); - - QTest::newRow("local") << testFileUrl("colors-round.sci").toString() << true; - QTest::newRow("local quoted filename") << testFileUrl("colors-round-quotes.sci").toString() << true; - QTest::newRow("local not found") << testFileUrl("no-such-file.sci").toString() << false; - QTest::newRow("remote") << SERVER_ADDR "/colors-round.sci" << true; - QTest::newRow("remote filename quoted") << SERVER_ADDR "/colors-round-quotes.sci" << true; - QTest::newRow("remote image") << SERVER_ADDR "/colors-round-remote.sci" << true; - QTest::newRow("remote not found") << SERVER_ADDR "/no-such-file.sci" << false; -} - -void tst_qquickborderimage::invalidSciFile() -{ - QTest::ignoreMessage(QtWarningMsg, "QQuickGridScaledImage: Invalid tile rule specified. Using Stretch."); // for "Roun" - QTest::ignoreMessage(QtWarningMsg, "QQuickGridScaledImage: Invalid tile rule specified. Using Stretch."); // for "Repea" - - QString componentStr = "import QtQuick 2.0\nBorderImage { source: \"" + testFileUrl("invalid.sci").toString() +"\"; width: 300; height: 300 }"; - QDeclarativeComponent component(&engine); - component.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); - QQuickBorderImage *obj = qobject_cast(component.create()); - QVERIFY(obj != 0); - QCOMPARE(obj->width(), 300.); - QCOMPARE(obj->height(), 300.); - QCOMPARE(obj->status(), QQuickImageBase::Error); - QCOMPARE(obj->horizontalTileMode(), QQuickBorderImage::Stretch); - QCOMPARE(obj->verticalTileMode(), QQuickBorderImage::Stretch); - - delete obj; -} - -void tst_qquickborderimage::pendingRemoteRequest() -{ - QFETCH(QString, source); - - QString componentStr = "import QtQuick 2.0\nBorderImage { source: \"" + source + "\" }"; - QDeclarativeComponent component(&engine); - component.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); - QQuickBorderImage *obj = qobject_cast(component.create()); - QVERIFY(obj != 0); - QCOMPARE(obj->status(), QQuickBorderImage::Loading); - - // verify no crash - // This will cause a delayed "QThread: Destroyed while thread is still running" warning - delete obj; - QTest::qWait(50); -} - -void tst_qquickborderimage::pendingRemoteRequest_data() -{ - QTest::addColumn("source"); - - QTest::newRow("png file") << "http://localhost/none.png"; - QTest::newRow("sci file") << "http://localhost/none.sci"; -} - -QTEST_MAIN(tst_qquickborderimage) - -#include "tst_qquickborderimage.moc" diff --git a/tests/auto/qtquick2/qquickcanvas/data/AnimationsWhileHidden.qml b/tests/auto/qtquick2/qquickcanvas/data/AnimationsWhileHidden.qml deleted file mode 100644 index e95b029210..0000000000 --- a/tests/auto/qtquick2/qquickcanvas/data/AnimationsWhileHidden.qml +++ /dev/null @@ -1,17 +0,0 @@ -import QtQuick 2.0 -import QtQuick.Window 2.0 as Window - -Window.Window -{ - id: win - visible: true - width: 250 - height: 250 - - SequentialAnimation { - PauseAnimation { duration: 500 } - PropertyAction { target: win; property: "visible"; value: true } - loops: Animation.Infinite - running: true - } -} diff --git a/tests/auto/qtquick2/qquickcanvas/data/Headless.qml b/tests/auto/qtquick2/qquickcanvas/data/Headless.qml deleted file mode 100644 index 2e09cb1f24..0000000000 --- a/tests/auto/qtquick2/qquickcanvas/data/Headless.qml +++ /dev/null @@ -1,33 +0,0 @@ -import QtQuick 2.0 -import QtQuick.Window 2.0 as Window - -Window.Window { - - width: 300 - height: 200 - visible: true - - Text { - anchors.left: parent.left - anchors.top: parent.top - text: "Testing headless mode" - } - - Rectangle { - anchors.centerIn: parent - width: 100 - height: 50 - rotation: -30 - gradient: Gradient { - GradientStop { position: 0; color: "lightsteelblue" } - GradientStop { position: 1; color: "black" } - } - } - - Image { - source: "colors.png" - anchors.bottom: parent.bottom - anchors.right: parent.right - } - -} diff --git a/tests/auto/qtquick2/qquickcanvas/data/colors.png b/tests/auto/qtquick2/qquickcanvas/data/colors.png deleted file mode 100644 index dfb62f3d64..0000000000 Binary files a/tests/auto/qtquick2/qquickcanvas/data/colors.png and /dev/null differ diff --git a/tests/auto/qtquick2/qquickcanvas/data/focus.qml b/tests/auto/qtquick2/qquickcanvas/data/focus.qml deleted file mode 100644 index 901f2fcf2e..0000000000 --- a/tests/auto/qtquick2/qquickcanvas/data/focus.qml +++ /dev/null @@ -1,11 +0,0 @@ -import QtQuick 2.0 -import QtQuick.Window 2.0 as Window - -Window.Window { - Item { - objectName: "item1" - } - Item { - objectName: "item2" - } -} diff --git a/tests/auto/qtquick2/qquickcanvas/data/window.qml b/tests/auto/qtquick2/qquickcanvas/data/window.qml deleted file mode 100644 index d79d5161b5..0000000000 --- a/tests/auto/qtquick2/qquickcanvas/data/window.qml +++ /dev/null @@ -1,9 +0,0 @@ -import QtQuick 2.0 -import QtQuick.Window 2.0 as Window - -Window.Window { - color: "#00FF00" - Item { - objectName: "item" - } -} diff --git a/tests/auto/qtquick2/qquickcanvas/qquickcanvas.pro b/tests/auto/qtquick2/qquickcanvas/qquickcanvas.pro deleted file mode 100644 index b21b492e0b..0000000000 --- a/tests/auto/qtquick2/qquickcanvas/qquickcanvas.pro +++ /dev/null @@ -1,20 +0,0 @@ -CONFIG += testcase -TARGET = tst_qquickcanvas -SOURCES += tst_qquickcanvas.cpp - -include (../../shared/util.pri) - -macx:CONFIG -= app_bundle - -CONFIG += parallel_test -QT += core-private gui-private declarative-private quick-private testlib - -testData.files = data -testData.path = . -DEPLOYMENT += testData - -OTHER_FILES += \ - data/AnimationsWhileHidden.qml \ - data/Headless.qml - - diff --git a/tests/auto/qtquick2/qquickcanvas/tst_qquickcanvas.cpp b/tests/auto/qtquick2/qquickcanvas/tst_qquickcanvas.cpp deleted file mode 100644 index 8f0c4e6fce..0000000000 --- a/tests/auto/qtquick2/qquickcanvas/tst_qquickcanvas.cpp +++ /dev/null @@ -1,775 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "../../shared/util.h" -#include - -struct TouchEventData { - QEvent::Type type; - QWidget *widget; - QWindow *window; - Qt::TouchPointStates states; - QList touchPoints; -}; - -static QTouchEvent::TouchPoint makeTouchPoint(QQuickItem *item, const QPointF &p, const QPointF &lastPoint = QPointF()) -{ - QPointF last = lastPoint.isNull() ? p : lastPoint; - - QTouchEvent::TouchPoint tp; - - tp.setPos(p); - tp.setLastPos(last); - tp.setScenePos(item->mapToScene(p)); - tp.setLastScenePos(item->mapToScene(last)); - tp.setScreenPos(item->canvas()->mapToGlobal(tp.scenePos().toPoint())); - tp.setLastScreenPos(item->canvas()->mapToGlobal(tp.lastScenePos().toPoint())); - return tp; -} - -static TouchEventData makeTouchData(QEvent::Type type, QWindow *w, Qt::TouchPointStates states = 0, - const QList& touchPoints = QList()) -{ - TouchEventData d = { type, 0, w, states, touchPoints }; - return d; -} -static TouchEventData makeTouchData(QEvent::Type type, QWindow *w, Qt::TouchPointStates states, const QTouchEvent::TouchPoint &touchPoint) -{ - QList points; - points << touchPoint; - return makeTouchData(type, w, states, points); -} - -#define COMPARE_TOUCH_POINTS(tp1, tp2) \ -{ \ - QCOMPARE(tp1.pos(), tp2.pos()); \ - QCOMPARE(tp1.lastPos(), tp2.lastPos()); \ - QCOMPARE(tp1.scenePos(), tp2.scenePos()); \ - QCOMPARE(tp1.lastScenePos(), tp2.lastScenePos()); \ - QCOMPARE(tp1.screenPos(), tp2.screenPos()); \ - QCOMPARE(tp1.lastScreenPos(), tp2.lastScreenPos()); \ -} - -#define COMPARE_TOUCH_DATA(d1, d2) \ -{ \ - QCOMPARE((int)d1.type, (int)d2.type); \ - QCOMPARE(d1.widget, d2.widget); \ - QCOMPARE((int)d1.states, (int)d2.states); \ - QCOMPARE(d1.touchPoints.count(), d2.touchPoints.count()); \ - for (int i=0; isetWidth(1); - setAcceptedMouseButtons(Qt::LeftButton); - setFiltersChildMouseEvents(true); - } - - void reset() { - acceptEvents = true; - setEnabled(true); - setOpacity(1.0); - - lastEvent = makeTouchData(QEvent::None, canvas(), 0, QList());//CHECK_VALID - } - - static void clearMousePressCounter() - { - mousePressNum = 0; - } - - bool acceptEvents; - TouchEventData lastEvent; - int mousePressId; -protected: - virtual void touchEvent(QTouchEvent *event) { - if (!acceptEvents) { - event->ignore(); - return; - } - lastEvent = makeTouchData(event->type(), event->window(), event->touchPointStates(), event->touchPoints()); - event->accept(); - } - - virtual void mousePressEvent(QMouseEvent *) { - mousePressId = ++mousePressNum; - } - - bool childMouseEventFilter(QQuickItem *, QEvent *event) { - if (event->type() == QEvent::MouseButtonPress) - mousePressId = ++mousePressNum; - return false; - } - - static int mousePressNum; -}; - -int TestTouchItem::mousePressNum = 0; - -class ConstantUpdateItem : public QQuickItem -{ -Q_OBJECT -public: - ConstantUpdateItem(QQuickItem *parent = 0) : QQuickItem(parent), iterations(0) {setFlag(ItemHasContents);} - - int iterations; -protected: - QSGNode* updatePaintNode(QSGNode *, UpdatePaintNodeData *){ - iterations++; - update(); - return 0; - } -}; - -class tst_qquickcanvas : public QDeclarativeDataTest -{ - Q_OBJECT -public: - -private slots: - void initTestCase() - { - QDeclarativeDataTest::initTestCase(); - touchDevice = new QTouchDevice(); - touchDevice->setType(QTouchDevice::TouchScreen); - QWindowSystemInterface::registerTouchDevice(touchDevice); - } - - - void constantUpdates(); - void mouseFiltering(); - void headless(); - - void touchEvent_basic(); - void touchEvent_propagation(); - void touchEvent_propagation_data(); - void touchEvent_cancel(); - - void clearCanvas(); - - void qmlCreation(); - void clearColor(); - - void grab(); - void multipleWindows(); - - void animationsWhileHidden(); - - void focusObject(); - - void ignoreUnhandledMouseEvents(); - -private: - QTouchDevice *touchDevice; -}; - -//If the item calls update inside updatePaintNode, it should schedule another update -void tst_qquickcanvas::constantUpdates() -{ - QQuickCanvas canvas; - canvas.resize(250, 250); - ConstantUpdateItem item(canvas.rootItem()); - canvas.show(); - QTRY_VERIFY(item.iterations > 60); -} - -void tst_qquickcanvas::touchEvent_basic() -{ - TestTouchItem::clearMousePressCounter(); - - QQuickCanvas *canvas = new QQuickCanvas; - canvas->resize(250, 250); - canvas->move(100, 100); - canvas->show(); - - TestTouchItem *bottomItem = new TestTouchItem(canvas->rootItem()); - bottomItem->setObjectName("Bottom Item"); - bottomItem->setSize(QSizeF(150, 150)); - - TestTouchItem *middleItem = new TestTouchItem(bottomItem); - middleItem->setObjectName("Middle Item"); - middleItem->setPos(QPointF(50, 50)); - middleItem->setSize(QSizeF(150, 150)); - - TestTouchItem *topItem = new TestTouchItem(middleItem); - topItem->setObjectName("Top Item"); - topItem->setPos(QPointF(50, 50)); - topItem->setSize(QSizeF(150, 150)); - - QPointF pos(10, 10); - - // press single point - QTest::touchEvent(canvas, touchDevice).press(0, topItem->mapToScene(pos).toPoint(),canvas); - QTest::qWait(50); - - QCOMPARE(topItem->lastEvent.touchPoints.count(), 1); - - QVERIFY(middleItem->lastEvent.touchPoints.isEmpty()); - QVERIFY(bottomItem->lastEvent.touchPoints.isEmpty()); - TouchEventData d = makeTouchData(QEvent::TouchBegin, canvas, Qt::TouchPointPressed, makeTouchPoint(topItem,pos)); - COMPARE_TOUCH_DATA(topItem->lastEvent, makeTouchData(QEvent::TouchBegin, canvas, Qt::TouchPointPressed, makeTouchPoint(topItem, pos))); - topItem->reset(); - - // press multiple points - QTest::touchEvent(canvas, touchDevice).press(0, topItem->mapToScene(pos).toPoint(),canvas) - .press(1, bottomItem->mapToScene(pos).toPoint(), canvas); - QTest::qWait(50); - QCOMPARE(topItem->lastEvent.touchPoints.count(), 1); - QVERIFY(middleItem->lastEvent.touchPoints.isEmpty()); - QCOMPARE(bottomItem->lastEvent.touchPoints.count(), 1); - COMPARE_TOUCH_DATA(topItem->lastEvent, makeTouchData(QEvent::TouchBegin, canvas, Qt::TouchPointPressed, makeTouchPoint(topItem, pos))); - COMPARE_TOUCH_DATA(bottomItem->lastEvent, makeTouchData(QEvent::TouchBegin, canvas, Qt::TouchPointPressed, makeTouchPoint(bottomItem, pos))); - topItem->reset(); - bottomItem->reset(); - - // touch point on top item moves to bottom item, but top item should still receive the event - QTest::touchEvent(canvas, touchDevice).press(0, topItem->mapToScene(pos).toPoint(), canvas); - QTest::qWait(50); - QTest::touchEvent(canvas, touchDevice).move(0, bottomItem->mapToScene(pos).toPoint(), canvas); - QTest::qWait(50); - QCOMPARE(topItem->lastEvent.touchPoints.count(), 1); - COMPARE_TOUCH_DATA(topItem->lastEvent, makeTouchData(QEvent::TouchUpdate, canvas, Qt::TouchPointMoved, - makeTouchPoint(topItem, topItem->mapFromItem(bottomItem, pos), pos))); - topItem->reset(); - - // touch point on bottom item moves to top item, but bottom item should still receive the event - QTest::touchEvent(canvas, touchDevice).press(0, bottomItem->mapToScene(pos).toPoint(), canvas); - QTest::qWait(50); - QTest::touchEvent(canvas, touchDevice).move(0, topItem->mapToScene(pos).toPoint(), canvas); - QTest::qWait(50); - QCOMPARE(bottomItem->lastEvent.touchPoints.count(), 1); - COMPARE_TOUCH_DATA(bottomItem->lastEvent, makeTouchData(QEvent::TouchUpdate, canvas, Qt::TouchPointMoved, - makeTouchPoint(bottomItem, bottomItem->mapFromItem(topItem, pos), pos))); - bottomItem->reset(); - - // a single stationary press on an item shouldn't cause an event - QTest::touchEvent(canvas, touchDevice).press(0, topItem->mapToScene(pos).toPoint(), canvas); - QTest::qWait(50); - QTest::touchEvent(canvas, touchDevice).stationary(0) - .press(1, bottomItem->mapToScene(pos).toPoint(), canvas); - QTest::qWait(50); - QCOMPARE(topItem->lastEvent.touchPoints.count(), 1); // received press only, not stationary - QVERIFY(middleItem->lastEvent.touchPoints.isEmpty()); - QCOMPARE(bottomItem->lastEvent.touchPoints.count(), 1); - COMPARE_TOUCH_DATA(topItem->lastEvent, makeTouchData(QEvent::TouchBegin, canvas, Qt::TouchPointPressed, makeTouchPoint(topItem, pos))); - COMPARE_TOUCH_DATA(bottomItem->lastEvent, makeTouchData(QEvent::TouchBegin, canvas, Qt::TouchPointPressed, makeTouchPoint(bottomItem, pos))); - topItem->reset(); - bottomItem->reset(); - - // move touch point from top item to bottom, and release - QTest::touchEvent(canvas, touchDevice).press(0, topItem->mapToScene(pos).toPoint(),canvas); - QTest::qWait(50); - QTest::touchEvent(canvas, touchDevice).release(0, bottomItem->mapToScene(pos).toPoint(),canvas); - QTest::qWait(50); - QCOMPARE(topItem->lastEvent.touchPoints.count(), 1); - COMPARE_TOUCH_DATA(topItem->lastEvent, makeTouchData(QEvent::TouchEnd, canvas, Qt::TouchPointReleased, - makeTouchPoint(topItem, topItem->mapFromItem(bottomItem, pos), pos))); - topItem->reset(); - - // release while another point is pressed - QTest::touchEvent(canvas, touchDevice).press(0, topItem->mapToScene(pos).toPoint(),canvas) - .press(1, bottomItem->mapToScene(pos).toPoint(), canvas); - QTest::qWait(50); - QTest::touchEvent(canvas, touchDevice).move(0, bottomItem->mapToScene(pos).toPoint(), canvas); - QTest::qWait(50); - QTest::touchEvent(canvas, touchDevice).release(0, bottomItem->mapToScene(pos).toPoint(), canvas) - .stationary(1); - QTest::qWait(50); - QCOMPARE(topItem->lastEvent.touchPoints.count(), 1); - QVERIFY(middleItem->lastEvent.touchPoints.isEmpty()); - QCOMPARE(bottomItem->lastEvent.touchPoints.count(), 1); - COMPARE_TOUCH_DATA(topItem->lastEvent, makeTouchData(QEvent::TouchEnd, canvas, Qt::TouchPointReleased, - makeTouchPoint(topItem, topItem->mapFromItem(bottomItem, pos)))); - COMPARE_TOUCH_DATA(bottomItem->lastEvent, makeTouchData(QEvent::TouchBegin, canvas, Qt::TouchPointPressed, makeTouchPoint(bottomItem, pos))); - topItem->reset(); - bottomItem->reset(); - - delete topItem; - delete middleItem; - delete bottomItem; - delete canvas; -} - -void tst_qquickcanvas::touchEvent_propagation() -{ - TestTouchItem::clearMousePressCounter(); - - QFETCH(bool, acceptEvents); - QFETCH(bool, enableItem); - QFETCH(qreal, itemOpacity); - - QQuickCanvas *canvas = new QQuickCanvas; - canvas->resize(250, 250); - canvas->move(100, 100); - canvas->show(); - - TestTouchItem *bottomItem = new TestTouchItem(canvas->rootItem()); - bottomItem->setObjectName("Bottom Item"); - bottomItem->setSize(QSizeF(150, 150)); - - TestTouchItem *middleItem = new TestTouchItem(bottomItem); - middleItem->setObjectName("Middle Item"); - middleItem->setPos(QPointF(50, 50)); - middleItem->setSize(QSizeF(150, 150)); - - TestTouchItem *topItem = new TestTouchItem(middleItem); - topItem->setObjectName("Top Item"); - topItem->setPos(QPointF(50, 50)); - topItem->setSize(QSizeF(150, 150)); - - QPointF pos(10, 10); - QPoint pointInBottomItem = bottomItem->mapToScene(pos).toPoint(); // (10, 10) - QPoint pointInMiddleItem = middleItem->mapToScene(pos).toPoint(); // (60, 60) overlaps with bottomItem - QPoint pointInTopItem = topItem->mapToScene(pos).toPoint(); // (110, 110) overlaps with bottom & top items - - // disable topItem - topItem->acceptEvents = acceptEvents; - topItem->setEnabled(enableItem); - topItem->setOpacity(itemOpacity); - - // single touch to top item, should be received by middle item - QTest::touchEvent(canvas, touchDevice).press(0, pointInTopItem, canvas); - QTest::qWait(50); - QVERIFY(topItem->lastEvent.touchPoints.isEmpty()); - QCOMPARE(middleItem->lastEvent.touchPoints.count(), 1); - QVERIFY(bottomItem->lastEvent.touchPoints.isEmpty()); - COMPARE_TOUCH_DATA(middleItem->lastEvent, makeTouchData(QEvent::TouchBegin, canvas, Qt::TouchPointPressed, - makeTouchPoint(middleItem, middleItem->mapFromItem(topItem, pos)))); - - // touch top and middle items, middle item should get both events - QTest::touchEvent(canvas, touchDevice).press(0, pointInTopItem, canvas) - .press(1, pointInMiddleItem, canvas); - QTest::qWait(50); - QVERIFY(topItem->lastEvent.touchPoints.isEmpty()); - QCOMPARE(middleItem->lastEvent.touchPoints.count(), 2); - QVERIFY(bottomItem->lastEvent.touchPoints.isEmpty()); - COMPARE_TOUCH_DATA(middleItem->lastEvent, makeTouchData(QEvent::TouchBegin, canvas, Qt::TouchPointPressed, - (QList() << makeTouchPoint(middleItem, middleItem->mapFromItem(topItem, pos)) - << makeTouchPoint(middleItem, pos) ))); - middleItem->reset(); - - // disable middleItem as well - middleItem->acceptEvents = acceptEvents; - middleItem->setEnabled(enableItem); - middleItem->setOpacity(itemOpacity); - - // touch top and middle items, bottom item should get all events - QTest::touchEvent(canvas, touchDevice).press(0, pointInTopItem, canvas) - .press(1, pointInMiddleItem, canvas); - QTest::qWait(50); - QVERIFY(topItem->lastEvent.touchPoints.isEmpty()); - QVERIFY(middleItem->lastEvent.touchPoints.isEmpty()); - QCOMPARE(bottomItem->lastEvent.touchPoints.count(), 2); - COMPARE_TOUCH_DATA(bottomItem->lastEvent, makeTouchData(QEvent::TouchBegin, canvas, Qt::TouchPointPressed, - (QList() << makeTouchPoint(bottomItem, bottomItem->mapFromItem(topItem, pos)) - << makeTouchPoint(bottomItem, bottomItem->mapFromItem(middleItem, pos)) ))); - bottomItem->reset(); - - // disable bottom item as well - bottomItem->acceptEvents = acceptEvents; - bottomItem->setEnabled(enableItem); - bottomItem->setOpacity(itemOpacity); - - // no events should be received - QTest::touchEvent(canvas, touchDevice).press(0, pointInTopItem, canvas) - .press(1, pointInMiddleItem, canvas) - .press(2, pointInBottomItem, canvas); - QTest::qWait(50); - QVERIFY(topItem->lastEvent.touchPoints.isEmpty()); - QVERIFY(middleItem->lastEvent.touchPoints.isEmpty()); - QVERIFY(bottomItem->lastEvent.touchPoints.isEmpty()); - - topItem->reset(); - middleItem->reset(); - bottomItem->reset(); - - // disable middle item, touch on top item - middleItem->acceptEvents = acceptEvents; - middleItem->setEnabled(enableItem); - middleItem->setOpacity(itemOpacity); - QTest::touchEvent(canvas, touchDevice).press(0, pointInTopItem, canvas); - QTest::qWait(50); - if (!enableItem || itemOpacity == 0) { - // middle item is disabled or has 0 opacity, bottom item receives the event - QVERIFY(topItem->lastEvent.touchPoints.isEmpty()); - QVERIFY(middleItem->lastEvent.touchPoints.isEmpty()); - QCOMPARE(bottomItem->lastEvent.touchPoints.count(), 1); - COMPARE_TOUCH_DATA(bottomItem->lastEvent, makeTouchData(QEvent::TouchBegin, canvas, Qt::TouchPointPressed, - makeTouchPoint(bottomItem, bottomItem->mapFromItem(topItem, pos)))); - } else { - // middle item ignores event, sends it to the top item (top-most child) - QCOMPARE(topItem->lastEvent.touchPoints.count(), 1); - QVERIFY(middleItem->lastEvent.touchPoints.isEmpty()); - QVERIFY(bottomItem->lastEvent.touchPoints.isEmpty()); - COMPARE_TOUCH_DATA(topItem->lastEvent, makeTouchData(QEvent::TouchBegin, canvas, Qt::TouchPointPressed, - makeTouchPoint(topItem, pos))); - } - - delete topItem; - delete middleItem; - delete bottomItem; - delete canvas; -} - -void tst_qquickcanvas::touchEvent_propagation_data() -{ - QTest::addColumn("acceptEvents"); - QTest::addColumn("enableItem"); - QTest::addColumn("itemOpacity"); - - QTest::newRow("disable events") << false << true << 1.0; - QTest::newRow("disable item") << true << false << 1.0; - QTest::newRow("opacity of 0") << true << true << 0.0; -} - -void tst_qquickcanvas::touchEvent_cancel() -{ - TestTouchItem::clearMousePressCounter(); - - QQuickCanvas *canvas = new QQuickCanvas; - canvas->resize(250, 250); - canvas->move(100, 100); - canvas->show(); - - TestTouchItem *item = new TestTouchItem(canvas->rootItem()); - item->setPos(QPointF(50, 50)); - item->setSize(QSizeF(150, 150)); - - QPointF pos(10, 10); - QTest::touchEvent(canvas, touchDevice).press(0, item->mapToScene(pos).toPoint(),canvas); - QCoreApplication::processEvents(); - - QTRY_COMPARE(item->lastEvent.touchPoints.count(), 1); - TouchEventData d = makeTouchData(QEvent::TouchBegin, canvas, Qt::TouchPointPressed, makeTouchPoint(item,pos)); - COMPARE_TOUCH_DATA(item->lastEvent, d); - item->reset(); - - QWindowSystemInterface::handleTouchCancelEvent(0, touchDevice); - QCoreApplication::processEvents(); - d = makeTouchData(QEvent::TouchCancel, canvas); - COMPARE_TOUCH_DATA(item->lastEvent, d); - - delete item; - delete canvas; -} - -void tst_qquickcanvas::clearCanvas() -{ - QQuickCanvas *canvas = new QQuickCanvas; - QQuickItem *item = new QQuickItem; - item->setParentItem(canvas->rootItem()); - - QVERIFY(item->canvas() == canvas); - - delete canvas; - - QVERIFY(item->canvas() == 0); - - delete item; -} - -void tst_qquickcanvas::mouseFiltering() -{ - TestTouchItem::clearMousePressCounter(); - - QQuickCanvas *canvas = new QQuickCanvas; - canvas->resize(250, 250); - canvas->move(100, 100); - canvas->show(); - - TestTouchItem *bottomItem = new TestTouchItem(canvas->rootItem()); - bottomItem->setObjectName("Bottom Item"); - bottomItem->setSize(QSizeF(150, 150)); - - TestTouchItem *middleItem = new TestTouchItem(bottomItem); - middleItem->setObjectName("Middle Item"); - middleItem->setPos(QPointF(50, 50)); - middleItem->setSize(QSizeF(150, 150)); - - TestTouchItem *topItem = new TestTouchItem(middleItem); - topItem->setObjectName("Top Item"); - topItem->setPos(QPointF(50, 50)); - topItem->setSize(QSizeF(150, 150)); - - QPoint pos(100, 100); - - QTest::mousePress(canvas, Qt::LeftButton, 0, pos); - - // Mouse filtering propagates down the stack, so the - // correct order is - // 1. middleItem filters event - // 2. bottomItem filters event - // 3. topItem receives event - QTRY_COMPARE(middleItem->mousePressId, 1); - QTRY_COMPARE(bottomItem->mousePressId, 2); - QTRY_COMPARE(topItem->mousePressId, 3); - - delete canvas; -} - -void tst_qquickcanvas::qmlCreation() -{ - QDeclarativeEngine engine; - QDeclarativeComponent component(&engine); - component.loadUrl(testFileUrl("window.qml")); - QObject* created = component.create(); - QVERIFY(created); - - QQuickCanvas* canvas = qobject_cast(created); - QVERIFY(canvas); - QCOMPARE(canvas->clearColor(), QColor(Qt::green)); - - QQuickItem* item = canvas->findChild("item"); - QVERIFY(item); - QCOMPARE(item->canvas(), canvas); - - delete canvas; -} - -void tst_qquickcanvas::clearColor() -{ - //### Can we examine rendering to make sure it is really blue? - QQuickCanvas *canvas = new QQuickCanvas; - canvas->resize(250, 250); - canvas->move(100, 100); - canvas->setClearColor(Qt::blue); - canvas->show(); - QTest::qWaitForWindowShown(canvas); - QCOMPARE(canvas->clearColor(), QColor(Qt::blue)); - delete canvas; -} - -void tst_qquickcanvas::grab() -{ - QQuickCanvas canvas; - canvas.setClearColor(Qt::red); - - canvas.resize(250, 250); - canvas.show(); - - QTest::qWaitForWindowShown(&canvas); - - QImage content = canvas.grabFrameBuffer(); - QCOMPARE(content.width(), canvas.width()); - QCOMPARE(content.height(), canvas.height()); - QCOMPARE((uint) content.convertToFormat(QImage::Format_RGB32).pixel(0, 0), (uint) 0xffff0000); -} - -void tst_qquickcanvas::multipleWindows() -{ - QList windows; - for (int i=0; i<6; ++i) { - QQuickCanvas *c = new QQuickCanvas(); - c->setClearColor(Qt::GlobalColor(Qt::red + i)); - c->resize(300, 200); - c->setPos(100 + i * 30, 100 + i * 20); - c->show(); - windows << c; - QVERIFY(c->visible()); - } - - // move them - for (int i=0; isetPos(c->x() - 10, c->y() - 10); - } - - // resize them - for (int i=0; iresize(200, 150); - } - - qDeleteAll(windows); -} - -void tst_qquickcanvas::animationsWhileHidden() -{ - QDeclarativeEngine engine; - QDeclarativeComponent component(&engine); - component.loadUrl(testFileUrl("AnimationsWhileHidden.qml")); - QObject* created = component.create(); - - QQuickCanvas* canvas = qobject_cast(created); - QVERIFY(canvas); - QVERIFY(canvas->visible()); - - // Now hide the window and verify that it went off screen - canvas->hide(); - QTest::qWait(10); - QVERIFY(!canvas->visible()); - - // Running animaiton should cause it to become visible again shortly. - QTRY_VERIFY(canvas->visible()); - - delete canvas; -} - - -void tst_qquickcanvas::headless() -{ - QDeclarativeEngine engine; - QDeclarativeComponent component(&engine); - component.loadUrl(testFileUrl("Headless.qml")); - QObject* created = component.create(); - - QQuickCanvas* canvas = qobject_cast(created); - QVERIFY(canvas); - - QTest::qWaitForWindowShown(canvas); - QVERIFY(canvas->visible()); - - QSignalSpy initialized(canvas, SIGNAL(sceneGraphInitialized())); - QSignalSpy invalidated(canvas, SIGNAL(sceneGraphInvalidated())); - - // Verify that the canvas is alive and kicking - QVERIFY(canvas->openglContext() != 0); - - // Store the visual result - QImage originalContent = canvas->grabFrameBuffer(); - - // Hide the canvas and verify signal emittion and GL context deletion - canvas->hide(); - canvas->releaseResources(); - - QTRY_COMPARE(invalidated.size(), 1); - QVERIFY(canvas->openglContext() == 0); - - // Destroy the native windowing system buffers - canvas->destroy(); - QVERIFY(canvas->handle() == 0); - - // Show and verify that we are back and running - canvas->show(); - QTest::qWaitForWindowShown(canvas); - - QCOMPARE(initialized.size(), 1); - QVERIFY(canvas->openglContext() != 0); - - // Verify that the visual output is the same - QImage newContent = canvas->grabFrameBuffer(); - - QCOMPARE(originalContent, newContent); - - delete canvas; -} - -void tst_qquickcanvas::focusObject() -{ - QDeclarativeEngine engine; - QDeclarativeComponent component(&engine); - component.loadUrl(testFileUrl("focus.qml")); - QObject *created = component.create(); - QVERIFY(created); - - QQuickCanvas *canvas = qobject_cast(created); - QVERIFY(canvas); - - QQuickItem *item1 = canvas->findChild("item1"); - QVERIFY(item1); - item1->setFocus(true); - QCOMPARE(item1, canvas->focusObject()); - - QQuickItem *item2 = canvas->findChild("item2"); - QVERIFY(item2); - item2->setFocus(true); - QCOMPARE(item2, canvas->focusObject()); - - delete canvas; -} - -void tst_qquickcanvas::ignoreUnhandledMouseEvents() -{ - QQuickCanvas* canvas = new QQuickCanvas; - canvas->resize(100, 100); - canvas->show(); - - QQuickItem* item = new QQuickItem; - item->setSize(QSizeF(100, 100)); - item->setParentItem(canvas->rootItem()); - - { - QMouseEvent me(QEvent::MouseButtonPress, QPointF(50, 50), Qt::LeftButton, Qt::LeftButton, - Qt::NoModifier); - me.setAccepted(true); - QVERIFY(QCoreApplication::sendEvent(canvas, &me)); - QVERIFY(!me.isAccepted()); - } - - { - QMouseEvent me(QEvent::MouseMove, QPointF(51, 51), Qt::LeftButton, Qt::LeftButton, - Qt::NoModifier); - me.setAccepted(true); - QVERIFY(QCoreApplication::sendEvent(canvas, &me)); - QVERIFY(!me.isAccepted()); - } - - { - QMouseEvent me(QEvent::MouseButtonRelease, QPointF(51, 51), Qt::LeftButton, Qt::LeftButton, - Qt::NoModifier); - me.setAccepted(true); - QVERIFY(QCoreApplication::sendEvent(canvas, &me)); - QVERIFY(!me.isAccepted()); - } - - delete canvas; -} - -QTEST_MAIN(tst_qquickcanvas) - -#include "tst_qquickcanvas.moc" diff --git a/tests/auto/qtquick2/qquickcanvasitem/data/anim-gr.gif b/tests/auto/qtquick2/qquickcanvasitem/data/anim-gr.gif deleted file mode 100644 index 45263e0afb..0000000000 Binary files a/tests/auto/qtquick2/qquickcanvasitem/data/anim-gr.gif and /dev/null differ diff --git a/tests/auto/qtquick2/qquickcanvasitem/data/anim-gr.png b/tests/auto/qtquick2/qquickcanvasitem/data/anim-gr.png deleted file mode 100644 index 925e2efc9a..0000000000 Binary files a/tests/auto/qtquick2/qquickcanvasitem/data/anim-gr.png and /dev/null differ diff --git a/tests/auto/qtquick2/qquickcanvasitem/data/anim-poster-gr.png b/tests/auto/qtquick2/qquickcanvasitem/data/anim-poster-gr.png deleted file mode 100644 index 6941207373..0000000000 Binary files a/tests/auto/qtquick2/qquickcanvasitem/data/anim-poster-gr.png and /dev/null differ diff --git a/tests/auto/qtquick2/qquickcanvasitem/data/background.png b/tests/auto/qtquick2/qquickcanvasitem/data/background.png deleted file mode 100644 index 6db6c6b1b9..0000000000 Binary files a/tests/auto/qtquick2/qquickcanvasitem/data/background.png and /dev/null differ diff --git a/tests/auto/qtquick2/qquickcanvasitem/data/broken.png b/tests/auto/qtquick2/qquickcanvasitem/data/broken.png deleted file mode 100644 index f2581017b4..0000000000 Binary files a/tests/auto/qtquick2/qquickcanvasitem/data/broken.png and /dev/null differ diff --git a/tests/auto/qtquick2/qquickcanvasitem/data/ggrr-256x256.png b/tests/auto/qtquick2/qquickcanvasitem/data/ggrr-256x256.png deleted file mode 100644 index 0342e4a384..0000000000 Binary files a/tests/auto/qtquick2/qquickcanvasitem/data/ggrr-256x256.png and /dev/null differ diff --git a/tests/auto/qtquick2/qquickcanvasitem/data/green-16x16.png b/tests/auto/qtquick2/qquickcanvasitem/data/green-16x16.png deleted file mode 100644 index e19a3ffddd..0000000000 Binary files a/tests/auto/qtquick2/qquickcanvasitem/data/green-16x16.png and /dev/null differ diff --git a/tests/auto/qtquick2/qquickcanvasitem/data/green-1x1.png b/tests/auto/qtquick2/qquickcanvasitem/data/green-1x1.png deleted file mode 100644 index 862d1dd10c..0000000000 Binary files a/tests/auto/qtquick2/qquickcanvasitem/data/green-1x1.png and /dev/null differ diff --git a/tests/auto/qtquick2/qquickcanvasitem/data/green-256x256.png b/tests/auto/qtquick2/qquickcanvasitem/data/green-256x256.png deleted file mode 100644 index b06945c310..0000000000 Binary files a/tests/auto/qtquick2/qquickcanvasitem/data/green-256x256.png and /dev/null differ diff --git a/tests/auto/qtquick2/qquickcanvasitem/data/green-2x2.png b/tests/auto/qtquick2/qquickcanvasitem/data/green-2x2.png deleted file mode 100644 index adc059449c..0000000000 Binary files a/tests/auto/qtquick2/qquickcanvasitem/data/green-2x2.png and /dev/null differ diff --git a/tests/auto/qtquick2/qquickcanvasitem/data/green.png b/tests/auto/qtquick2/qquickcanvasitem/data/green.png deleted file mode 100644 index 28a1faab37..0000000000 Binary files a/tests/auto/qtquick2/qquickcanvasitem/data/green.png and /dev/null differ diff --git a/tests/auto/qtquick2/qquickcanvasitem/data/grgr-256x256.png b/tests/auto/qtquick2/qquickcanvasitem/data/grgr-256x256.png deleted file mode 100644 index b8c7189d62..0000000000 Binary files a/tests/auto/qtquick2/qquickcanvasitem/data/grgr-256x256.png and /dev/null differ diff --git a/tests/auto/qtquick2/qquickcanvasitem/data/red-16x16.png b/tests/auto/qtquick2/qquickcanvasitem/data/red-16x16.png deleted file mode 100644 index 9038fef784..0000000000 Binary files a/tests/auto/qtquick2/qquickcanvasitem/data/red-16x16.png and /dev/null differ diff --git a/tests/auto/qtquick2/qquickcanvasitem/data/red.png b/tests/auto/qtquick2/qquickcanvasitem/data/red.png deleted file mode 100644 index a6e195d59c..0000000000 Binary files a/tests/auto/qtquick2/qquickcanvasitem/data/red.png and /dev/null differ diff --git a/tests/auto/qtquick2/qquickcanvasitem/data/redtransparent.png b/tests/auto/qtquick2/qquickcanvasitem/data/redtransparent.png deleted file mode 100644 index 75da08c3d6..0000000000 Binary files a/tests/auto/qtquick2/qquickcanvasitem/data/redtransparent.png and /dev/null differ diff --git a/tests/auto/qtquick2/qquickcanvasitem/data/rgrg-256x256.png b/tests/auto/qtquick2/qquickcanvasitem/data/rgrg-256x256.png deleted file mode 100644 index e6fba3daa5..0000000000 Binary files a/tests/auto/qtquick2/qquickcanvasitem/data/rgrg-256x256.png and /dev/null differ diff --git a/tests/auto/qtquick2/qquickcanvasitem/data/rrgg-256x256.png b/tests/auto/qtquick2/qquickcanvasitem/data/rrgg-256x256.png deleted file mode 100644 index 7f63515654..0000000000 Binary files a/tests/auto/qtquick2/qquickcanvasitem/data/rrgg-256x256.png and /dev/null differ diff --git a/tests/auto/qtquick2/qquickcanvasitem/data/testhelper.js b/tests/auto/qtquick2/qquickcanvasitem/data/testhelper.js deleted file mode 100644 index bac0210e16..0000000000 --- a/tests/auto/qtquick2/qquickcanvasitem/data/testhelper.js +++ /dev/null @@ -1,18 +0,0 @@ -function comparePixel(ctx,x,y,r,g,b,a, d) -{ - var c = ctx.getImageData(x,y,1,1).data; - if (d === undefined) - d = 0; - r = Math.round(r); - g = Math.round(g); - b = Math.round(b); - a = Math.round(a); - - if (Math.abs(c[0]-r)>d || Math.abs(c[1]-g)>d || Math.abs(c[2]-b)>d || Math.abs(c[3]-a)>d) { - console.log('Pixel compare fail:\nactual :[' + c[0]+','+c[1]+','+c[2]+','+c[3] + ']\nexpected:['+r+','+g+','+b+','+a+'] +/- '+d); - return false; - } - return true; -} - - diff --git a/tests/auto/qtquick2/qquickcanvasitem/data/transparent.png b/tests/auto/qtquick2/qquickcanvasitem/data/transparent.png deleted file mode 100644 index 2b498699a8..0000000000 Binary files a/tests/auto/qtquick2/qquickcanvasitem/data/transparent.png and /dev/null differ diff --git a/tests/auto/qtquick2/qquickcanvasitem/data/transparent50.png b/tests/auto/qtquick2/qquickcanvasitem/data/transparent50.png deleted file mode 100644 index 55f8e69325..0000000000 Binary files a/tests/auto/qtquick2/qquickcanvasitem/data/transparent50.png and /dev/null differ diff --git a/tests/auto/qtquick2/qquickcanvasitem/data/tst_arc.qml b/tests/auto/qtquick2/qquickcanvasitem/data/tst_arc.qml deleted file mode 100644 index 6006a5a4c0..0000000000 --- a/tests/auto/qtquick2/qquickcanvasitem/data/tst_arc.qml +++ /dev/null @@ -1,487 +0,0 @@ -import QtQuick 2.0 -import QtTest 1.0 -import "testhelper.js" as Helper - -Canvas { - id:canvas; width:100;height:50; renderTarget: Canvas.Image - TestCase { - name: "arc"; when: windowShown - function test_angle_1() { - var ctx = canvas.getContext('2d'); - ctx.reset(); - - ctx.fillStyle = '#0f0'; - ctx.fillRect(0, 0, 100, 50); - ctx.fillStyle = '#f00'; - ctx.beginPath(); - ctx.moveTo(100, 0); - ctx.arc(100, 0, 150, Math.PI/2, -Math.PI, true); - ctx.fill(); - verify(Helper.comparePixel(ctx,50,25, 0,255,0,255)); - } - function test_angle_2() { - var ctx = canvas.getContext('2d'); - ctx.reset(); - - ctx.fillStyle = '#0f0'; - ctx.fillRect(0, 0, 100, 50); - ctx.fillStyle = '#f00'; - ctx.beginPath(); - ctx.moveTo(100, 0); - ctx.arc(100, 0, 150, -3*Math.PI/2, -Math.PI, true); - ctx.fill(); - verify(Helper.comparePixel(ctx,50,25, 0,255,0,255)); - } - function test_angle_3() { - var ctx = canvas.getContext('2d'); - ctx.reset(); - ctx.fillStyle = '#0f0'; - ctx.fillRect(0, 0, 100, 50); - ctx.fillStyle = '#f00'; - ctx.beginPath(); - ctx.moveTo(100, 0); - ctx.arc(100, 0, 150, (512+1/2)*Math.PI, (1024-1)*Math.PI, true); - ctx.fill(); - //verify(Helper.comparePixel(ctx,50,25, 0,255,0,255)); - } - function test_angle_4() { - var ctx = canvas.getContext('2d'); - ctx.reset(); - - ctx.fillStyle = '#f00'; - ctx.fillRect(0, 0, 100, 50); - ctx.fillStyle = '#0f0'; - ctx.beginPath(); - ctx.moveTo(50, 25); - ctx.arc(50, 25, 60, (512+1/2)*Math.PI, (1024-1)*Math.PI, false); - ctx.fill(); - verify(Helper.comparePixel(ctx,1,1, 0,255,0,255)); - verify(Helper.comparePixel(ctx,98,1, 0,255,0,255)); - verify(Helper.comparePixel(ctx,1,48, 0,255,0,255)); - verify(Helper.comparePixel(ctx,98,48, 0,255,0,255)); - } - function test_angle_5() { - var ctx = canvas.getContext('2d'); - ctx.reset(); - - ctx.fillStyle = '#0f0'; - ctx.fillRect(0, 0, 100, 50); - ctx.fillStyle = '#f00'; - ctx.beginPath(); - ctx.moveTo(100, 0); - ctx.arc(100, 0, 150, (1024-1)*Math.PI, (512+1/2)*Math.PI, false); - ctx.fill(); - /*FIXME: - actual :[255,0,0,255] - expected:[0,255,0,255] +/- 0 - */ - //verify(Helper.comparePixel(ctx,50,25, 0,255,0,255)); - } - - function test_angle_6() { - var ctx = canvas.getContext('2d'); - ctx.reset(); - - ctx.fillStyle = '#f00'; - ctx.fillRect(0, 0, 100, 50); - ctx.fillStyle = '#0f0'; - ctx.beginPath(); - ctx.moveTo(50, 25); - ctx.arc(50, 25, 60, (1024-1)*Math.PI, (512+1/2)*Math.PI, true); - ctx.fill(); - - verify(Helper.comparePixel(ctx,1,1, 0,255,0,255)); - verify(Helper.comparePixel(ctx,98,1, 0,255,0,255)); - verify(Helper.comparePixel(ctx,1,48, 0,255,0,255)); - verify(Helper.comparePixel(ctx,98,48, 0,255,0,255)); - } - - function test_empty() { - var ctx = canvas.getContext('2d'); - ctx.reset(); - - ctx.fillStyle = '#0f0'; - ctx.fillRect(0, 0, 100, 50); - ctx.lineWidth = 50; - ctx.strokeStyle = '#f00'; - ctx.beginPath(); - ctx.arc(200, 25, 5, 0, 2*Math.PI, true); - ctx.stroke(); - /*FIXME: - actual :[255,0,0,255] - expected:[0,255,0,255] +/- 0 - */ - //verify(Helper.comparePixel(ctx,50,25, 0,255,0,255)); - } - function test_nonempty() { - var ctx = canvas.getContext('2d'); - ctx.reset(); - - ctx.fillStyle = '#f00'; - ctx.fillRect(0, 0, 100, 50); - ctx.lineWidth = 50; - ctx.strokeStyle = '#0f0'; - ctx.beginPath(); - ctx.moveTo(0, 25); - ctx.arc(200, 25, 5, 0, 2*Math.PI, true); - ctx.stroke(); - verify(Helper.comparePixel(ctx,50,25, 0,255,0,255)); - } - function test_nonfinite() { - skip("FIXME"); - var ctx = canvas.getContext('2d'); - ctx.reset(); - - ctx.fillStyle = '#f00'; - ctx.fillRect(0, 0, 100, 50); - ctx.moveTo(0, 0); - ctx.lineTo(100, 0); - ctx.arc(Infinity, 0, 50, 0, 2*Math.PI, true); - ctx.arc(-Infinity, 0, 50, 0, 2*Math.PI, true); - ctx.arc(NaN, 0, 50, 0, 2*Math.PI, true); - ctx.arc(0, Infinity, 50, 0, 2*Math.PI, true); - ctx.arc(0, -Infinity, 50, 0, 2*Math.PI, true); - ctx.arc(0, NaN, 50, 0, 2*Math.PI, true); - ctx.arc(0, 0, Infinity, 0, 2*Math.PI, true); - ctx.arc(0, 0, -Infinity, 0, 2*Math.PI, true); - ctx.arc(0, 0, NaN, 0, 2*Math.PI, true); - ctx.arc(0, 0, 50, Infinity, 2*Math.PI, true); - ctx.arc(0, 0, 50, -Infinity, 2*Math.PI, true); - ctx.arc(0, 0, 50, NaN, 2*Math.PI, true); - ctx.arc(0, 0, 50, 0, Infinity, true); - ctx.arc(0, 0, 50, 0, -Infinity, true); - ctx.arc(0, 0, 50, 0, NaN, true); - ctx.arc(Infinity, Infinity, 50, 0, 2*Math.PI, true); - ctx.arc(Infinity, Infinity, Infinity, 0, 2*Math.PI, true); - ctx.arc(Infinity, Infinity, Infinity, Infinity, 2*Math.PI, true); - ctx.arc(Infinity, Infinity, Infinity, Infinity, Infinity, true); - ctx.arc(Infinity, Infinity, Infinity, 0, Infinity, true); - ctx.arc(Infinity, Infinity, 50, Infinity, 2*Math.PI, true); - ctx.arc(Infinity, Infinity, 50, Infinity, Infinity, true); - ctx.arc(Infinity, Infinity, 50, 0, Infinity, true); - ctx.arc(Infinity, 0, Infinity, 0, 2*Math.PI, true); - ctx.arc(Infinity, 0, Infinity, Infinity, 2*Math.PI, true); - ctx.arc(Infinity, 0, Infinity, Infinity, Infinity, true); - ctx.arc(Infinity, 0, Infinity, 0, Infinity, true); - ctx.arc(Infinity, 0, 50, Infinity, 2*Math.PI, true); - ctx.arc(Infinity, 0, 50, Infinity, Infinity, true); - ctx.arc(Infinity, 0, 50, 0, Infinity, true); - ctx.arc(0, Infinity, Infinity, 0, 2*Math.PI, true); - ctx.arc(0, Infinity, Infinity, Infinity, 2*Math.PI, true); - ctx.arc(0, Infinity, Infinity, Infinity, Infinity, true); - ctx.arc(0, Infinity, Infinity, 0, Infinity, true); - ctx.arc(0, Infinity, 50, Infinity, 2*Math.PI, true); - ctx.arc(0, Infinity, 50, Infinity, Infinity, true); - ctx.arc(0, Infinity, 50, 0, Infinity, true); - ctx.arc(0, 0, Infinity, Infinity, 2*Math.PI, true); - ctx.arc(0, 0, Infinity, Infinity, Infinity, true); - ctx.arc(0, 0, Infinity, 0, Infinity, true); - ctx.arc(0, 0, 50, Infinity, Infinity, true); - ctx.lineTo(100, 50); - ctx.lineTo(0, 50); - ctx.fillStyle = '#0f0'; - ctx.fill(); - verify(Helper.comparePixel(ctx,50,25, 0,255,0,255)); - verify(Helper.comparePixel(ctx,90,45, 0,255,0,255)); - } - function test_end() { - var ctx = canvas.getContext('2d'); - ctx.reset(); - - ctx.fillStyle = '#f00'; - ctx.fillRect(0, 0, 100, 50); - ctx.lineWidth = 50; - ctx.strokeStyle = '#0f0'; - ctx.beginPath(); - ctx.moveTo(-100, 0); - ctx.arc(-100, 0, 25, -Math.PI/2, Math.PI/2, true); - ctx.lineTo(100, 25); - ctx.stroke(); - verify(Helper.comparePixel(ctx,50,25, 0,255,0,255)); - } - function test_negative() { - var ctx = canvas.getContext('2d'); - ctx.reset(); - - try { var err = false; - ctx.arc(0, 0, -1, 0, 0, true); - } catch (e) { - if (e.code != DOMException.INDEX_SIZE_ERR) - fail("expected exception of type INDEX_SIZE_ERR, got: "+e.message); - err = true; - } finally { - verify(err, "should throw exception of type INDEX_SIZE_ERR: ctx.arc(0, 0, -1, 0, 0, true)"); - } - - } - - function test_scale_1() { - var ctx = canvas.getContext('2d'); - ctx.reset(); - - ctx.fillStyle = '#f00'; - ctx.fillRect(0, 0, 100, 50); - ctx.scale(2, 0.5); - ctx.fillStyle = '#0f0'; - ctx.beginPath(); - ctx.arc(25, 50, 56, 0, 2*Math.PI, false); - ctx.fill(); - ctx.fillStyle = '#f00'; - ctx.beginPath(); - ctx.moveTo(-25, 50); - ctx.arc(-25, 50, 24, 0, 2*Math.PI, false); - ctx.moveTo(75, 50); - ctx.arc(75, 50, 24, 0, 2*Math.PI, false); - ctx.moveTo(25, -25); - ctx.arc(25, -25, 24, 0, 2*Math.PI, false); - ctx.moveTo(25, 125); - ctx.arc(25, 125, 24, 0, 2*Math.PI, false); - ctx.fill(); - - verify(Helper.comparePixel(ctx, 0,0, 0,255,0,255)); - verify(Helper.comparePixel(ctx, 50,0, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 99,0, 0,255,0,255)); - verify(Helper.comparePixel(ctx, 0,25, 0,255,0,255)); - verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 99,25, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 0,49, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 50,49, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 99,49, 0,255,0,255)); - } - - function test_scale_2() { - var ctx = canvas.getContext('2d'); - ctx.reset(); - - ctx.fillStyle = '#f00'; - ctx.fillRect(0, 0, 100, 50); - ctx.scale(100, 100); - ctx.strokeStyle = '#0f0'; - ctx.lineWidth = 1.2; - ctx.beginPath(); - ctx.arc(0, 0, 0.6, 0, Math.PI/2, false); - ctx.stroke(); - - verify(Helper.comparePixel(ctx, 1,1, 0,255,0,255)); - verify(Helper.comparePixel(ctx, 50,1, 0,255,0,255)); - verify(Helper.comparePixel(ctx, 98,1, 0,255,0,255)); - verify(Helper.comparePixel(ctx, 1,25, 0,255,0,255)); - verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); - verify(Helper.comparePixel(ctx, 98,25, 0,255,0,255)); - verify(Helper.comparePixel(ctx, 1,48, 0,255,0,255)); - verify(Helper.comparePixel(ctx, 50,48, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 98,48, 0,255,0,255)); - } - - function test_selfintersect_1() { - var ctx = canvas.getContext('2d'); - ctx.reset(); - - ctx.fillStyle = '#0f0'; - ctx.fillRect(0, 0, 100, 50); - ctx.lineWidth = 200; - ctx.strokeStyle = '#f00'; - ctx.beginPath(); - ctx.arc(100, 50, 25, 0, -Math.PI/2, true); - ctx.stroke(); - ctx.beginPath(); - ctx.arc(0, 0, 25, 0, -Math.PI/2, true); - ctx.stroke(); - //verify(Helper.comparePixel(ctx, 1,1, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); - } - - function test_selfintersect_2() { - var ctx = canvas.getContext('2d'); - ctx.reset(); - - ctx.fillStyle = '#f00'; - ctx.fillRect(0, 0, 100, 50); - ctx.lineWidth = 180; - ctx.strokeStyle = '#0f0'; - ctx.beginPath(); - ctx.arc(-50, 50, 25, 0, -Math.PI/2, true); - ctx.stroke(); - ctx.beginPath(); - ctx.arc(100, 0, 25, 0, -Math.PI/2, true); - ctx.stroke(); - verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 90,10, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 97,1, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 97,2, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 97,3, 0,255,0,255)); - verify(Helper.comparePixel(ctx, 2,48, 0,255,0,255)); - } - - function test_shape_1() { - var ctx = canvas.getContext('2d'); - ctx.reset(); - - ctx.fillStyle = '#0f0'; - ctx.fillRect(0, 0, 100, 50); - ctx.lineWidth = 50; - ctx.strokeStyle = '#f00'; - ctx.beginPath(); - ctx.arc(50, 50, 50, 0, Math.PI, false); - ctx.stroke(); - //verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 1,1, 0,255,0,255)); - verify(Helper.comparePixel(ctx, 98,1, 0,255,0,255)); - verify(Helper.comparePixel(ctx, 1,48, 0,255,0,255)); - verify(Helper.comparePixel(ctx, 20,48, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 98,48, 0,255,0,255)); - } - - function test_shape_2() { - var ctx = canvas.getContext('2d'); - ctx.reset(); - - ctx.fillStyle = '#f00'; - ctx.fillRect(0, 0, 100, 50); - ctx.lineWidth = 100; - ctx.strokeStyle = '#0f0'; - ctx.beginPath(); - ctx.arc(50, 50, 50, 0, Math.PI, true); - ctx.stroke(); - verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); - verify(Helper.comparePixel(ctx, 1,1, 0,255,0,255)); - verify(Helper.comparePixel(ctx, 98,1, 0,255,0,255)); - verify(Helper.comparePixel(ctx, 1,48, 0,255,0,255)); - verify(Helper.comparePixel(ctx, 20,48, 0,255,0,255)); - verify(Helper.comparePixel(ctx, 98,48, 0,255,0,255)); - } - function test_shape_3() { - var ctx = canvas.getContext('2d'); - ctx.reset(); - - ctx.fillStyle = '#0f0'; - ctx.fillRect(0, 0, 100, 50); - ctx.lineWidth = 100; - ctx.strokeStyle = '#f00'; - ctx.beginPath(); - ctx.arc(0, 50, 50, 0, -Math.PI/2, false); - ctx.stroke(); - //verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 1,1, 0,255,0,255)); - verify(Helper.comparePixel(ctx, 98,1, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 1,48, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 98,48, 0,255,0,255)); - } - - function test_shape_4() { - var ctx = canvas.getContext('2d'); - ctx.reset(); - - ctx.fillStyle = '#f00'; - ctx.fillRect(0, 0, 100, 50); - ctx.lineWidth = 150; - ctx.strokeStyle = '#0f0'; - ctx.beginPath(); - ctx.arc(-50, 50, 100, 0, -Math.PI/2, true); - ctx.stroke(); - verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); - verify(Helper.comparePixel(ctx, 1,1, 0,255,0,255)); - verify(Helper.comparePixel(ctx, 98,1, 0,255,0,255)); - verify(Helper.comparePixel(ctx, 1,48, 0,255,0,255)); - verify(Helper.comparePixel(ctx, 98,48, 0,255,0,255)); - } - - function test_shape_5() { - var ctx = canvas.getContext('2d'); - ctx.reset(); - - ctx.fillStyle = '#0f0'; - ctx.fillRect(0, 0, 100, 50); - ctx.lineWidth = 200; - ctx.strokeStyle = '#f00'; - ctx.beginPath(); - ctx.arc(300, 0, 100, 0, 5*Math.PI, false); - ctx.stroke(); - //verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 1,1, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 98,1, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 1,48, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 98,48, 0,255,0,255)); - } - - function test_twopie() { - var ctx = canvas.getContext('2d'); - ctx.reset(); - - ctx.fillStyle = '#0f0'; - ctx.fillRect(0, 0, 100, 50); - ctx.strokeStyle = '#f00'; - ctx.lineWidth = 100; - ctx.beginPath(); - ctx.arc(50, 25, 50, 0, 2*Math.PI - 1e-4, true); - ctx.stroke(); - //verify(Helper.comparePixel(ctx, 50,20, 0,255,0,255)); - ctx.reset(); - - ctx.fillStyle = '#f00'; - ctx.fillRect(0, 0, 100, 50); - ctx.strokeStyle = '#0f0'; - ctx.lineWidth = 100; - ctx.beginPath(); - ctx.arc(50, 25, 50, 0, 2*Math.PI - 1e-4, false); - ctx.stroke(); - verify(Helper.comparePixel(ctx, 50,20, 0,255,0,255)); - ctx.reset(); - - ctx.fillStyle = '#f00'; - ctx.fillRect(0, 0, 100, 50); - ctx.strokeStyle = '#0f0'; - ctx.lineWidth = 100; - ctx.beginPath(); - ctx.arc(50, 25, 50, 0, 2*Math.PI + 1e-4, true); - ctx.stroke(); - verify(Helper.comparePixel(ctx, 50,20, 0,255,0,255)); - ctx.reset(); - - ctx.fillStyle = '#f00'; - ctx.fillRect(0, 0, 100, 50); - ctx.strokeStyle = '#0f0'; - ctx.lineWidth = 100; - ctx.beginPath(); - ctx.arc(50, 25, 50, 0, 2*Math.PI + 1e-4, false); - ctx.stroke(); - verify(Helper.comparePixel(ctx, 50,20, 0,255,0,255)); - } - - function test_zero() { - var ctx = canvas.getContext('2d'); - ctx.reset(); - - ctx.fillStyle = '#0f0'; - ctx.fillRect(0, 0, 100, 50); - ctx.strokeStyle = '#f00'; - ctx.lineWidth = 100; - ctx.beginPath(); - ctx.arc(50, 25, 50, 0, 0, true); - ctx.stroke(); - //verify(Helper.comparePixel(ctx, 50,20, 0,255,0,255)); - ctx.reset(); - - ctx.fillStyle = '#0f0'; - ctx.fillRect(0, 0, 100, 50); - ctx.strokeStyle = '#f00'; - ctx.lineWidth = 100; - ctx.beginPath(); - ctx.arc(50, 25, 50, 0, 0, false); - ctx.stroke(); - //verify(Helper.comparePixel(ctx, 50,20, 0,255,0,255)); - ctx.reset(); - - ctx.fillStyle = '#f00' - ctx.fillRect(0, 0, 100, 50); - ctx.lineWidth = 50; - ctx.strokeStyle = '#0f0'; - ctx.beginPath(); - ctx.moveTo(0, 25); - ctx.arc(200, 25, 0, 0, Math.PI, true); - ctx.stroke(); - verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); - - } - } -} diff --git a/tests/auto/qtquick2/qquickcanvasitem/data/tst_arcto.qml b/tests/auto/qtquick2/qquickcanvasitem/data/tst_arcto.qml deleted file mode 100644 index cc1d88672b..0000000000 --- a/tests/auto/qtquick2/qquickcanvasitem/data/tst_arcto.qml +++ /dev/null @@ -1,410 +0,0 @@ -import QtQuick 2.0 -import QtTest 1.0 -import "testhelper.js" as Helper - -Canvas { - id:canvas; width:100;height:50; renderTarget: Canvas.Image - TestCase { - name: "arcTo"; when: windowShown - function test_coincide() { - var ctx = canvas.getContext('2d'); - ctx.reset(); - ctx.fillStyle = '#f00'; - ctx.fillRect(0, 0, 100, 50); - ctx.lineWidth = 50; - - ctx.strokeStyle = '#0f0'; - ctx.beginPath(); - ctx.moveTo(0, 25); - ctx.arcTo(0, 25, 50, 1000, 1); - ctx.lineTo(100, 25); - ctx.stroke(); - - ctx.strokeStyle = '#f00'; - ctx.beginPath(); - ctx.moveTo(50, 25); - ctx.arcTo(50, 25, 100, 25, 1); - ctx.stroke(); - - verify(Helper.comparePixel(ctx, 50,1, 0,255,0,255)); - verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); - verify(Helper.comparePixel(ctx, 50,48, 0,255,0,255)); - ctx.reset(); - - ctx.fillStyle = '#f00'; - ctx.fillRect(0, 0, 100, 50); - ctx.lineWidth = 50; - ctx.strokeStyle = '#0f0'; - ctx.beginPath(); - ctx.moveTo(0, 25); - ctx.arcTo(100, 25, 100, 25, 1); - ctx.stroke(); - - verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); - } - function test_collinear() { - var ctx = canvas.getContext('2d'); - ctx.reset(); - - ctx.fillStyle = '#f00'; - ctx.fillRect(0, 0, 100, 50); - ctx.lineWidth = 50; - - ctx.strokeStyle = '#0f0'; - ctx.beginPath(); - ctx.moveTo(0, 25); - ctx.arcTo(100, 25, 200, 25, 1); - ctx.stroke(); - - ctx.strokeStyle = '#f00'; - ctx.beginPath(); - ctx.moveTo(-100, 25); - ctx.arcTo(0, 25, 100, 25, 1); - ctx.stroke(); - - verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); - ctx.reset(); - - ctx.fillStyle = '#f00'; - ctx.fillRect(0, 0, 100, 50); - ctx.lineWidth = 50; - - ctx.strokeStyle = '#0f0'; - ctx.beginPath(); - ctx.moveTo(0, 25); - ctx.arcTo(100, 25, 10, 25, 1); - ctx.stroke(); - - ctx.strokeStyle = '#f00'; - ctx.beginPath(); - ctx.moveTo(100, 25); - ctx.arcTo(200, 25, 110, 25, 1); - ctx.stroke(); - verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); - ctx.reset(); - - ctx.fillStyle = '#f00'; - ctx.fillRect(0, 0, 100, 50); - ctx.lineWidth = 50; - - ctx.strokeStyle = '#0f0'; - ctx.beginPath(); - ctx.moveTo(0, 25); - ctx.arcTo(100, 25, -100, 25, 1); - ctx.stroke(); - - ctx.strokeStyle = '#f00'; - ctx.beginPath(); - ctx.moveTo(100, 25); - ctx.arcTo(200, 25, 0, 25, 1); - ctx.stroke(); - - ctx.beginPath(); - ctx.moveTo(-100, 25); - ctx.arcTo(0, 25, -200, 25, 1); - ctx.stroke(); - - verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); - } - function test_subpath() { - var ctx = canvas.getContext('2d'); - ctx.reset(); - - ctx.fillStyle = '#0f0'; - ctx.fillRect(0, 0, 100, 50); - ctx.lineWidth = 50; - ctx.strokeStyle = '#f00'; - ctx.beginPath(); - ctx.arcTo(100, 50, 200, 50, 0.1); - ctx.stroke(); - //verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); - ctx.reset(); - - ctx.fillStyle = '#f00'; - ctx.fillRect(0, 0, 100, 50); - ctx.lineWidth = 50; - ctx.strokeStyle = '#0f0'; - ctx.beginPath(); - ctx.arcTo(0, 25, 50, 250, 0.1); - ctx.lineTo(100, 25); - ctx.stroke(); - verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); - } - - function test_negative() { - var ctx = canvas.getContext('2d'); - ctx.reset(); - - try { var err = false; - ctx.arcTo(0, 0, 0, 0, -1); - } catch (e) { - if (e.code != DOMException.INDEX_SIZE_ERR) - fail("expectes INDEX_SIZE_ERR, got: "+e.message); - err = true; - } - finally { - verify(err, "should throw INDEX_SIZE_ERR: ctx.arcTo(0, 0, 0, 0, -1)"); - } - } - - function test_nonfinite() { - var ctx = canvas.getContext('2d'); - ctx.reset(); - - skip("FIXME"); - - ctx.moveTo(0, 0); - ctx.lineTo(100, 0); - ctx.arcTo(Infinity, 50, 0, 50, 0); - ctx.arcTo(-Infinity, 50, 0, 50, 0); - ctx.arcTo(NaN, 50, 0, 50, 0); - ctx.arcTo(0, Infinity, 0, 50, 0); - ctx.arcTo(0, -Infinity, 0, 50, 0); - ctx.arcTo(0, NaN, 0, 50, 0); - ctx.arcTo(0, 50, Infinity, 50, 0); - ctx.arcTo(0, 50, -Infinity, 50, 0); - ctx.arcTo(0, 50, NaN, 50, 0); - ctx.arcTo(0, 50, 0, Infinity, 0); - ctx.arcTo(0, 50, 0, -Infinity, 0); - ctx.arcTo(0, 50, 0, NaN, 0); - ctx.arcTo(0, 50, 0, 50, Infinity); - ctx.arcTo(0, 50, 0, 50, -Infinity); - ctx.arcTo(0, 50, 0, 50, NaN); - ctx.arcTo(Infinity, Infinity, 0, 50, 0); - ctx.arcTo(Infinity, Infinity, Infinity, 50, 0); - ctx.arcTo(Infinity, Infinity, Infinity, Infinity, 0); - ctx.arcTo(Infinity, Infinity, Infinity, Infinity, Infinity); - ctx.arcTo(Infinity, Infinity, Infinity, 50, Infinity); - ctx.arcTo(Infinity, Infinity, 0, Infinity, 0); - ctx.arcTo(Infinity, Infinity, 0, Infinity, Infinity); - ctx.arcTo(Infinity, Infinity, 0, 50, Infinity); - ctx.arcTo(Infinity, 50, Infinity, 50, 0); - ctx.arcTo(Infinity, 50, Infinity, Infinity, 0); - ctx.arcTo(Infinity, 50, Infinity, Infinity, Infinity); - ctx.arcTo(Infinity, 50, Infinity, 50, Infinity); - ctx.arcTo(Infinity, 50, 0, Infinity, 0); - ctx.arcTo(Infinity, 50, 0, Infinity, Infinity); - ctx.arcTo(Infinity, 50, 0, 50, Infinity); - ctx.arcTo(0, Infinity, Infinity, 50, 0); - ctx.arcTo(0, Infinity, Infinity, Infinity, 0); - ctx.arcTo(0, Infinity, Infinity, Infinity, Infinity); - ctx.arcTo(0, Infinity, Infinity, 50, Infinity); - ctx.arcTo(0, Infinity, 0, Infinity, 0); - ctx.arcTo(0, Infinity, 0, Infinity, Infinity); - ctx.arcTo(0, Infinity, 0, 50, Infinity); - ctx.arcTo(0, 50, Infinity, Infinity, 0); - ctx.arcTo(0, 50, Infinity, Infinity, Infinity); - ctx.arcTo(0, 50, Infinity, 50, Infinity); - ctx.arcTo(0, 50, 0, Infinity, Infinity); - ctx.lineTo(100, 50); - ctx.lineTo(0, 50); - ctx.fillStyle = '#0f0'; - ctx.fill(); - verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); - verify(Helper.comparePixel(ctx, 90,45, 0,255,0,255)); - - } - function test_scale() { - var ctx = canvas.getContext('2d'); - ctx.reset(); - - ctx.fillStyle = '#f00'; - ctx.fillRect(0, 0, 100, 50); - - ctx.fillStyle = '#0f0'; - ctx.beginPath(); - ctx.moveTo(0, 50); - ctx.translate(100, 0); - ctx.scale(0.1, 1); - ctx.arcTo(50, 50, 50, 0, 50); - ctx.lineTo(-1000, 0); - ctx.fill(); - - skip("FIXME"); - //verify(Helper.comparePixel(ctx, 0,0, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 50,0, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 99,0, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 0,25, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 99,25, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 0,49, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 50,49, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 99,49, 0,255,0,255)); - } - - function test_shape() { - var ctx = canvas.getContext('2d'); - ctx.reset(); - - var tol = 1.5; // tolerance to avoid antialiasing artifacts - - ctx.fillStyle = '#0f0'; - ctx.fillRect(0, 0, 100, 50); - - ctx.strokeStyle = '#f00'; - ctx.lineWidth = 10; - ctx.beginPath(); - ctx.moveTo(10, 25); - ctx.arcTo(75, 25, 75, 60, 20); - ctx.stroke(); - - ctx.fillStyle = '#0f0'; - ctx.beginPath(); - ctx.rect(10, 20, 45, 10); - ctx.moveTo(80, 45); - ctx.arc(55, 45, 25+tol, 0, -Math.PI/2, true); - ctx.arc(55, 45, 15-tol, -Math.PI/2, 0, false); - ctx.fill(); - - verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); - verify(Helper.comparePixel(ctx, 55,19, 0,255,0,255)); - verify(Helper.comparePixel(ctx, 55,20, 0,255,0,255)); - verify(Helper.comparePixel(ctx, 55,21, 0,255,0,255)); - verify(Helper.comparePixel(ctx, 64,22, 0,255,0,255)); - verify(Helper.comparePixel(ctx, 65,21, 0,255,0,255)); - verify(Helper.comparePixel(ctx, 72,28, 0,255,0,255)); - verify(Helper.comparePixel(ctx, 73,27, 0,255,0,255)); - verify(Helper.comparePixel(ctx, 78,36, 0,255,0,255)); - verify(Helper.comparePixel(ctx, 79,35, 0,255,0,255)); - verify(Helper.comparePixel(ctx, 80,44, 0,255,0,255)); - verify(Helper.comparePixel(ctx, 80,45, 0,255,0,255)); - verify(Helper.comparePixel(ctx, 80,46, 0,255,0,255)); - verify(Helper.comparePixel(ctx, 65,45, 0,255,0,255)); - ctx.reset(); - - ctx.fillStyle = '#0f0'; - ctx.fillRect(0, 0, 100, 50); - - ctx.fillStyle = '#f00'; - ctx.beginPath(); - ctx.rect(10, 20, 45, 10); - ctx.moveTo(80, 45); - ctx.arc(55, 45, 25-tol, 0, -Math.PI/2, true); - ctx.arc(55, 45, 15+tol, -Math.PI/2, 0, false); - ctx.fill(); - - ctx.strokeStyle = '#0f0'; - ctx.lineWidth = 10; - ctx.beginPath(); - ctx.moveTo(10, 25); - ctx.arcTo(75, 25, 75, 60, 20); - ctx.stroke(); - - //verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); - verify(Helper.comparePixel(ctx, 55,19, 0,255,0,255)); - verify(Helper.comparePixel(ctx, 55,20, 0,255,0,255)); - verify(Helper.comparePixel(ctx, 55,21, 0,255,0,255)); - verify(Helper.comparePixel(ctx, 64,22, 0,255,0,255)); - verify(Helper.comparePixel(ctx, 65,21, 0,255,0,255)); - verify(Helper.comparePixel(ctx, 72,28, 0,255,0,255)); - verify(Helper.comparePixel(ctx, 73,27, 0,255,0,255)); - verify(Helper.comparePixel(ctx, 78,36, 0,255,0,255)); - verify(Helper.comparePixel(ctx, 79,35, 0,255,0,255)); - verify(Helper.comparePixel(ctx, 80,44, 0,255,0,255)); - verify(Helper.comparePixel(ctx, 80,45, 0,255,0,255)); - verify(Helper.comparePixel(ctx, 80,46, 0,255,0,255)); - ctx.reset(); - - - ctx.fillStyle = '#0f0'; - ctx.fillRect(0, 0, 100, 50); - ctx.strokeStyle = '#f00'; - ctx.lineWidth = 50; - ctx.beginPath(); - ctx.moveTo(-100, -100); - ctx.arcTo(-100, 25, 200, 25, 10); - ctx.stroke(); - - verify(Helper.comparePixel(ctx, 1,1, 0,255,0,255)); - verify(Helper.comparePixel(ctx, 1,48, 0,255,0,255)); - verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); - verify(Helper.comparePixel(ctx, 98,1, 0,255,0,255)); - verify(Helper.comparePixel(ctx, 98,48, 0,255,0,255)); - ctx.reset(); - - ctx.fillStyle = '#f00'; - ctx.fillRect(0, 0, 100, 50); - ctx.strokeStyle = '#0f0'; - ctx.lineWidth = 50; - ctx.beginPath(); - ctx.moveTo(0, 25); - ctx.arcTo(200, 25, 200, 50, 10); - ctx.stroke(); - - //verify(Helper.comparePixel(ctx, 1,1, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 1,48, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 98,1, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 98,48, 0,255,0,255)); - } - - function test_transform() { - var ctx = canvas.getContext('2d'); - ctx.reset(); - - ctx.fillStyle = '#f00'; - ctx.fillRect(0, 0, 100, 50); - - ctx.fillStyle = '#0f0'; - ctx.beginPath(); - ctx.moveTo(0, 50); - ctx.translate(100, 0); - ctx.arcTo(50, 50, 50, 0, 50); - ctx.lineTo(-100, 0); - ctx.fill(); - - skip("FIXME"); - //verify(Helper.comparePixel(ctx, 0,0, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 50,0, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 99,0, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 0,25, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 99,25, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 0,49, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 50,49, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 99,49, 0,255,0,255)); - } - function test_zero() { - var ctx = canvas.getContext('2d'); - ctx.reset(); - - ctx.fillStyle = '#f00'; - ctx.fillRect(0, 0, 100, 50); - ctx.lineWidth = 50; - - ctx.strokeStyle = '#0f0'; - ctx.beginPath(); - ctx.moveTo(0, 25); - ctx.arcTo(100, 25, 100, 100, 0); - ctx.stroke(); - - ctx.strokeStyle = '#f00'; - ctx.beginPath(); - ctx.moveTo(0, -25); - ctx.arcTo(50, -25, 50, 50, 0); - ctx.stroke(); - - verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); - ctx.reset(); - - ctx.fillStyle = '#f00'; - ctx.fillRect(0, 0, 100, 50); - ctx.lineWidth = 50; - - ctx.strokeStyle = '#0f0'; - ctx.beginPath(); - ctx.moveTo(0, 25); - ctx.arcTo(100, 25, -100, 25, 0); - ctx.stroke(); - - ctx.strokeStyle = '#f00'; - ctx.beginPath(); - ctx.moveTo(100, 25); - ctx.arcTo(200, 25, 50, 25, 0); - ctx.stroke(); - - verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); - - } - } -} diff --git a/tests/auto/qtquick2/qquickcanvasitem/data/tst_canvas.qml b/tests/auto/qtquick2/qquickcanvasitem/data/tst_canvas.qml deleted file mode 100644 index a00ccc3c3f..0000000000 --- a/tests/auto/qtquick2/qquickcanvasitem/data/tst_canvas.qml +++ /dev/null @@ -1,278 +0,0 @@ -import QtQuick 2.0 -import QtTest 1.0 - -Rectangle { - id:container - width:100 - height:100 - Component { - id:canvas - Canvas { - id:c - width:100;height:100 - onPaint: { - var context = getContext("2d"); - context.fillStyle = "red"; - context.fillRect(0, 0, 100, 100); - } - property int paintCount:spyPaint.count - property int paintedCount:spyPainted.count - property int canvasSizeChangedCount:spyCanvasSizeChanged.count - property int tileSizeChangedCount:spyTileSizeChanged.count - property int renderStrategyChangedCount:spyRenderStrategyChanged.count - property int canvasWindowChangedCount:spyCanvasWindowChanged.count - property int renderTargetChangedCount:spyRenderTargetChanged.count - property int imageLoadedCount:spyImageLoaded.count - property int availableChangedCount:spyAvailableChanged.count - - SignalSpy {id: spyPaint;target:c;signalName: "paint"} - SignalSpy {id: spyPainted;target:c;signalName: "painted"} - SignalSpy {id: spyCanvasSizeChanged;target:c;signalName: "canvasSizeChanged"} - SignalSpy {id: spyTileSizeChanged;target:c;signalName: "tileSizeChanged"} - SignalSpy {id: spyRenderStrategyChanged;target:c;signalName: "renderStrategyChanged"} - SignalSpy {id: spyCanvasWindowChanged;target:c;signalName: "canvasWindowChanged"} - SignalSpy {id: spyRenderTargetChanged;target:c;signalName: "renderTargetChanged"} - SignalSpy {id: spyImageLoaded;target:c;signalName: "imageLoaded"} - SignalSpy {id: spyAvailableChanged;target:c;signalName: "availableChanged"} - } - } - - TestCase { - name: "Canvas"; when: windowShown - function test_canvasSize() { - var c = canvas.createObject(container); - verify(c); - wait(100); - verify(c.availableChangedCount, 1); - - //by default canvasSize is same with canvas' actual size - // when canvas size changes, canvasSize should be changed as well. - compare(c.canvasSize.width, c.width); - compare(c.canvasSize.height, c.height); - c.width = 20; - compare(c.canvasSize.width, 20); - compare(c.canvasSizeChangedCount, 1); - c.height = 5; - compare(c.canvasSizeChangedCount, 2); - compare(c.canvasSize.height, 5); - - //change canvasSize manually, then canvasSize detaches from canvas - //actual size. - c.canvasSize.width = 100; - compare(c.canvasSizeChangedCount, 3); - compare(c.canvasSize.width, 100); - compare(c.width, 20); - c.canvasSize.height = 50; - compare(c.canvasSizeChangedCount, 4); - compare(c.canvasSize.height, 50); - compare(c.height, 5); - - c.width = 10; - compare(c.canvasSizeChangedCount, 4); - compare(c.canvasSize.width, 100); - compare(c.canvasSize.height, 50); - - c.height = 10; - compare(c.canvasSizeChangedCount, 4); - compare(c.canvasSize.width, 100); - compare(c.canvasSize.height, 50); - c.destroy(); - } - function test_tileSize() { - var c = canvas.createObject(container); - verify(c); - wait(100); - verify(c.availableChangedCount, 1); - - compare(c.tileSize.width, c.width); - compare(c.tileSize.height, c.height); - c.width = 20; - compare(c.tileSize.width, 20); - compare(c.tileSizeChangedCount, 1); - c.height = 5; - compare(c.tileSizeChangedCount, 2); - compare(c.tileSize.height, 5); - - c.tileSize.width = 100; - compare(c.tileSizeChangedCount, 3); - compare(c.tileSize.width, 100); - compare(c.width, 20); - c.tileSize.height = 50; - compare(c.tileSizeChangedCount, 4); - compare(c.tileSize.height, 50); - compare(c.height, 5); - - c.width = 10; - compare(c.tileSizeChangedCount, 4); - compare(c.tileSize.width, 100); - compare(c.tileSize.height, 50); - - c.height = 10; - compare(c.tileSizeChangedCount, 4); - compare(c.tileSize.width, 100); - compare(c.tileSize.height, 50); - c.destroy(); - - } - - function test_canvasWindow() { - var c = canvas.createObject(container); - verify(c); - wait(100); - verify(c.availableChangedCount, 1); - compare(c.canvasWindow.x, 0); - compare(c.canvasWindow.y, 0); - compare(c.canvasWindow.width, c.width); - compare(c.canvasWindow.height, c.height); - - c.width = 20; - compare(c.canvasWindow.width, 20); - compare(c.canvasWindowChangedCount, 1); - c.height = 5; - compare(c.canvasWindowChangedCount, 2); - compare(c.canvasWindow.height, 5); - - c.canvasWindow.x = 5; - c.canvasWindow.y = 6; - c.canvasWindow.width = 10; - c.canvasWindow.height =20; - compare(c.canvasWindowChangedCount, 6); - compare(c.canvasWindow.width, 10); - compare(c.canvasWindow.height, 20); - compare(c.canvasWindow.x, 5); - compare(c.canvasWindow.y, 6); - c.destroy(); - - } - function test_renderTargetAndStrategy() { - var c = canvas.createObject(container); - verify(c); - wait(100); - verify(c.availableChangedCount, 1); - - compare(c.renderTarget, Canvas.Image); - compare(c.renderStrategy, Canvas.Threaded); - c.destroy(); - - } - function test_save() { - var c = canvas.createObject(container); - verify(c); - wait(100); - verify(c.availableChangedCount, 1); - - c.renderTarget = Canvas.Image; - c.requestPaint(); - wait(100); - verify(c.save("c.png")); - c.loadImage("c.png"); - wait(200); - compare(c.imageLoadedCount, 1); - verify(c.isImageLoaded("c.png")); - verify(!c.isImageLoading("c.png")); - verify(!c.isImageError("c.png")); - c.destroy(); - - } - function test_toDataURL_data() { - return [{mimeType:"image/png"}, - {mimeType:"image/bmp"}, - {mimeType:"image/jpeg"}, - {mimeType:"image/x-portable-pixmap"}, - //{mimeType:"image/tiff"}, QTBUG-23980 - {mimeType:"image/xpm"}, - ]; - } - - function test_toDataURL(data) { - var c = canvas.createObject(container); - verify(c); - wait(100); - verify(c.availableChangedCount, 1); - - var ctx = c.getContext("2d"); - ctx.fillStyle = "red"; - ctx.fillRect(0, 0, c.width, c.height); - wait(100); - - var dataUrl = c.toDataURL(); - verify(dataUrl != "data:,"); - dataUrl = c.toDataURL("image/invalid"); - verify(dataUrl == "data:,"); - - dataUrl = c.toDataURL(data.mimeType); - verify(dataUrl != "data:,"); - - ctx.save(); - ctx.fillStyle = "blue"; - ctx.fillRect(0, 0, c.width, c.height); - ctx.restore(); - wait(100); - - var dataUrl2 = c.toDataURL(data.mimeType); - verify (dataUrl2 != "data:,"); - verify (dataUrl2 != dataUrl); - c.destroy(); - - } - function test_paint() { - var c = canvas.createObject(container); - verify(c); - wait(100); - verify(c.availableChangedCount, 1); - - c.renderTarget = Canvas.Image; - c.renderStrategy = Canvas.Immediate; - var ctx = c.getContext("2d"); - ctx.fillRect(0, 0, c.width, c.height); - c.toDataURL(); - wait(100); - - compare(c.paintedCount, 1); - compare(c.paintCount, 1); - c.destroy(); - - } - function test_loadImage() { - var c = canvas.createObject(container); - verify(c); - wait(100); - verify(c.availableChangedCount, 1); - - c.loadImage("red.png"); - wait(200); - compare(c.imageLoadedCount, 1); - verify(c.isImageLoaded("red.png")); - verify(!c.isImageLoading("red.png")); - verify(!c.isImageError("red.png")); - - c.unloadImage("red.png"); - verify(!c.isImageLoaded("red.png")); - verify(!c.isImageLoading("red.png")); - verify(!c.isImageError("red.png")); - c.destroy(); - - } - - function test_getContext() { - var c = canvas.createObject(container); - verify(c); - wait(100); - verify(c.availableChangedCount, 1); - - var ctx = c.getContext("2d"); - verify(ctx); - compare(ctx.canvas, c); - ctx = c.getContext('2d'); - verify(ctx); - compare(ctx.canvas, c); - ctx = c.getContext('2D'); - verify(ctx); - compare(ctx.canvas, c); - ctx = c.getContext('invalid'); - verify(!ctx); - c.destroy(); - - } - } -} diff --git a/tests/auto/qtquick2/qquickcanvasitem/data/tst_composite.qml b/tests/auto/qtquick2/qquickcanvasitem/data/tst_composite.qml deleted file mode 100644 index 11e1dce902..0000000000 --- a/tests/auto/qtquick2/qquickcanvasitem/data/tst_composite.qml +++ /dev/null @@ -1,380 +0,0 @@ -import QtQuick 2.0 -import QtTest 1.0 -import "testhelper.js" as Helper -Canvas { - id:canvas; width:100;height:50; renderTarget:Canvas.Image - TestCase { - name: "composite"; when: windowShown - function test_clearRect() { - var ctx = canvas.getContext('2d'); - ctx.reset(); - ctx.fillStyle = '#f00'; - ctx.fillRect(0, 0, 100, 50); - ctx.globalCompositeOperation = 'destination-atop'; - ctx.clearRect(0, 0, 100, 50); - verify(Helper.comparePixel(ctx, 50,25, 0,0,0,0)); - } - - function test_clip_data() { - return [ {compsite:"copy"}, - {compsite:"destination-atop"}, - {compsite:"destination-in"}, - {compsite:"destination-out"}, - {compsite:"destination-over"}, - {compsite:"lighter"}, - {compsite:"source-atop"}, - {compsite:"source-in"}, - {compsite:"source-out"}, - {compsite:"source-over"}, - {compsite:"xor"} - ]; - } - - function test_clip(data) { - var ctx = canvas.getContext('2d'); - ctx.reset(); - ctx.fillStyle = '#0f0'; - ctx.fillRect(0, 0, 100, 50); - ctx.globalCompositeOperation = data.compsite; - ctx.rect(-20, -20, 10, 10); - ctx.clip(); - ctx.fillStyle = '#f00'; - ctx.fillRect(0, 0, 50, 50); - verify(Helper.comparePixel(ctx, 25,25, 0,255,0,255)); - verify(Helper.comparePixel(ctx, 75,25, 0,255,0,255)); - } - - function test_globalAlpha() { - var ctx = canvas.getContext('2d'); - ctx.reset(); - compare(ctx.globalAlpha, 1.0); - - ctx.fillStyle = '#0f0'; - ctx.fillRect(0, 0, 100, 50); - ctx.globalAlpha = 0.01; // avoid any potential alpha=0 optimisations - ctx.fillStyle = '#f00'; - ctx.fillRect(0, 0, 100, 50); - //verify(Helper.comparePixel(ctx, 50,25, 2,253,0,255, 2)); - - ctx.reset(); - ctx.globalAlpha = 0.5; - var a = ctx.globalAlpha; // might not be exactly 0.5, if it is rounded/quantised, so remember for future comparisons - ctx.globalAlpha = Infinity; - compare(ctx.globalAlpha, a); - ctx.globalAlpha = -Infinity; - compare(ctx.globalAlpha, a); - ctx.globalAlpha = NaN; - compare(ctx.globalAlpha, a); - - ctx.globalAlpha = 0.5; - a = ctx.globalAlpha; // might not be exactly 0.5, if it is rounded/quantised, so remember for future comparisons - ctx.globalAlpha = 1.1; - compare(ctx.globalAlpha, a); - ctx.globalAlpha = -0.1; - compare(ctx.globalAlpha, a); - ctx.globalAlpha = 0; - compare(ctx.globalAlpha, 0); - ctx.globalAlpha = 1; - compare(ctx.globalAlpha, 1); - - } - - function test_operation() { - var ctx = canvas.getContext('2d'); - ctx.reset(); - ctx.globalCompositeOperation = 'xor'; - ctx.globalCompositeOperation = 'Source-over'; - compare(ctx.globalCompositeOperation, 'xor'); - - ctx.reset(); - ctx.globalCompositeOperation = 'xor'; - ctx.globalCompositeOperation = 'clear'; - compare(ctx.globalCompositeOperation, 'xor'); - - ctx.reset(); - ctx.globalCompositeOperation = 'xor'; - ctx.globalCompositeOperation = 'darker'; - compare(ctx.globalCompositeOperation, 'xor'); - - ctx.reset(); - compare(ctx.globalCompositeOperation, 'source-over'); - - - ctx.reset(); - var modes = ['source-atop', 'source-in', 'source-out', 'source-over', - 'destination-atop', 'destination-in', 'destination-out', 'destination-over', - 'lighter', 'copy', 'xor']; - for (var i = 0; i < modes.length; ++i) - { - ctx.globalCompositeOperation = modes[i]; - compare(ctx.globalCompositeOperation, modes[i]); - } - - ctx.reset(); - ctx.globalCompositeOperation = 'xor'; - ctx.globalCompositeOperation = 'highlight'; - compare(ctx.globalCompositeOperation, 'xor'); - - ctx.reset(); - ctx.globalCompositeOperation = 'xor'; - ctx.globalCompositeOperation = 'source-over\\0'; - compare(ctx.globalCompositeOperation, 'xor'); - - ctx.reset(); - ctx.globalCompositeOperation = 'xor'; - ctx.globalCompositeOperation = 'over'; - compare(ctx.globalCompositeOperation, 'xor'); - - - ctx.reset(); - ctx.globalCompositeOperation = 'xor'; - ctx.globalCompositeOperation = 'nonexistent'; - compare(ctx.globalCompositeOperation, 'xor'); - } - - function test_solid() { - skip("FIXME"); - var ctx = canvas.getContext('2d'); - ctx.reset(); - ctx.fillStyle = Qt.rgba(0, 1, 1, 1.0); - ctx.fillRect(0, 0, 100, 50); - ctx.globalCompositeOperation = 'copy'; - ctx.fillStyle = Qt.rgba(1, 1, 0, 1.0); - ctx.fillRect(0, 0, 100, 50); - //verify(Helper.comparePixel(ctx, 50,25, 255,255,0, 5)); - - ctx.reset(); - ctx.fillStyle = 'rgba(0, 255, 255, 1.0)'; - ctx.fillRect(0, 0, 100, 50); - ctx.globalCompositeOperation = 'destination-atop'; - ctx.fillStyle = 'rgba(255, 255, 0, 1.0)'; - ctx.fillRect(0, 0, 100, 50); - //verify(Helper.comparePixel(ctx, 50,25, 0,255,255,255, 5)); - - ctx.reset(); - ctx.fillStyle = 'rgba(0, 255, 255, 1.0)'; - ctx.fillRect(0, 0, 100, 50); - ctx.globalCompositeOperation = 'destination-in'; - ctx.fillStyle = 'rgba(255, 255, 0, 1.0)'; - ctx.fillRect(0, 0, 100, 50); - //verify(Helper.comparePixel(ctx, 50,25, 0,255,255,255, 5)); - - ctx.reset(); - ctx.fillStyle = 'rgba(0, 255, 255, 1.0)'; - ctx.fillRect(0, 0, 100, 50); - ctx.globalCompositeOperation = 'destination-out'; - ctx.fillStyle = 'rgba(255, 255, 0, 1.0)'; - ctx.fillRect(0, 0, 100, 50); - verify(Helper.comparePixel(ctx, 50,25, 0,0,0,0, 5)); - - - ctx.reset(); - ctx.fillStyle = 'rgba(0, 255, 255, 1.0)'; - ctx.fillRect(0, 0, 100, 50); - ctx.globalCompositeOperation = 'destination-over'; - ctx.fillStyle = 'rgba(255, 255, 0, 1.0)'; - ctx.fillRect(0, 0, 100, 50); - //verify(Helper.comparePixel(ctx, 50,25, 0,255,255,255, 5)); - - ctx.reset(); - ctx.fillStyle = 'rgba(0, 255, 255, 1.0)'; - ctx.fillRect(0, 0, 100, 50); - ctx.globalCompositeOperation = 'lighter'; - ctx.fillStyle = 'rgba(255, 255, 0, 1.0)'; - ctx.fillRect(0, 0, 100, 50); - //verify(Helper.comparePixel(ctx, 50,25, 255,255,255,255, 5)); - - - ctx.reset(); - ctx.fillStyle = 'rgba(0, 255, 255, 1.0)'; - ctx.fillRect(0, 0, 100, 50); - ctx.globalCompositeOperation = 'source-atop'; - ctx.fillStyle = 'rgba(255, 255, 0, 1.0)'; - ctx.fillRect(0, 0, 100, 50); - //verify(Helper.comparePixel(ctx, 50,25, 255,255,0, 5)); - - - ctx.reset(); - ctx.fillStyle = 'rgba(0, 255, 255, 1.0)'; - ctx.fillRect(0, 0, 100, 50); - ctx.globalCompositeOperation = 'source-in'; - ctx.fillStyle = 'rgba(255, 255, 0, 1.0)'; - ctx.fillRect(0, 0, 100, 50); - //verify(Helper.comparePixel(ctx, 50,25, 255,255,0, 5)); - - - ctx.reset(); - ctx.fillStyle = 'rgba(0, 255, 255, 1.0)'; - ctx.fillRect(0, 0, 100, 50); - ctx.globalCompositeOperation = 'source-out'; - ctx.fillStyle = 'rgba(255, 255, 0, 1.0)'; - ctx.fillRect(0, 0, 100, 50); - // verify(Helper.comparePixel(ctx, 50,25, 0,0,0,0, 5)); - - - ctx.reset(); - ctx.fillStyle = 'rgba(0, 255, 255, 1.0)'; - ctx.fillRect(0, 0, 100, 50); - ctx.globalCompositeOperation = 'source-over'; - ctx.fillStyle = 'rgba(255, 255, 0, 1.0)'; - ctx.fillRect(0, 0, 100, 50); - //verify(Helper.comparePixel(ctx, 50,25, 255,255,0, 5)); - - ctx.reset(); - ctx.fillStyle = 'rgba(0, 255, 255, 1.0)'; - ctx.fillRect(0, 0, 100, 50); - ctx.globalCompositeOperation = 'xor'; - ctx.fillStyle = 'rgba(255, 255, 0, 1.0)'; - ctx.fillRect(0, 0, 100, 50); - //verify(Helper.comparePixel(ctx, 50,25, 0,0,0,0, 5)); - } - function test_transparent() { - - skip("FIXME"); - var ctx = canvas.getContext('2d'); - ctx.reset(); - ctx.fillStyle = 'rgba(0, 255, 0, 0.5)'; - ctx.fillRect(0, 0, 100, 50); - ctx.globalCompositeOperation = 'copy'; - ctx.fillStyle = 'rgba(0, 0, 255, 0.75)'; - ctx.fillRect(0, 0, 100, 50); - verify(Helper.comparePixel(ctx, 50,25, 0,0,255,191, 5)); - - ctx.reset(); - ctx.fillStyle = 'rgba(0, 255, 0, 0.5)'; - ctx.fillRect(0, 0, 100, 50); - ctx.globalCompositeOperation = 'copy'; - ctx.fillStyle = 'rgba(0, 0, 255, 0.75)'; - ctx.fillRect(0, 0, 100, 50); - verify(Helper.comparePixel(ctx, 50,25, 0,0,255,191, 5)); - - ctx.reset(); - ctx.fillStyle = 'rgba(0, 255, 0, 0.5)'; - ctx.fillRect(0, 0, 100, 50); - ctx.globalCompositeOperation = 'destination-in'; - ctx.fillStyle = 'rgba(0, 0, 255, 0.75)'; - ctx.fillRect(0, 0, 100, 50); - verify(Helper.comparePixel(ctx, 50,25, 0,255,0,95, 5)); - - ctx.reset(); - ctx.fillStyle = 'rgba(0, 255, 0, 0.5)'; - ctx.fillRect(0, 0, 100, 50); - ctx.globalCompositeOperation = 'destination-out'; - ctx.fillStyle = 'rgba(0, 0, 255, 0.75)'; - ctx.fillRect(0, 0, 100, 50); - verify(Helper.comparePixel(ctx, 50,25, 0,255,0,31, 5)); - - ctx.reset(); - ctx.fillStyle = 'rgba(0, 255, 0, 0.5)'; - ctx.fillRect(0, 0, 100, 50); - ctx.globalCompositeOperation = 'destination-over'; - ctx.fillStyle = 'rgba(0, 0, 255, 0.75)'; - ctx.fillRect(0, 0, 100, 50); - verify(Helper.comparePixel(ctx, 50,25, 0,145,109,223, 5)); - - - ctx.reset(); - ctx.fillStyle = 'rgba(0, 255, 0, 0.5)'; - ctx.fillRect(0, 0, 100, 50); - ctx.globalCompositeOperation = 'lighter'; - ctx.fillStyle = 'rgba(0, 0, 255, 0.75)'; - ctx.fillRect(0, 0, 100, 50); - verify(Helper.comparePixel(ctx, 50,25, 0,127,191,255, 5)); - - ctx.reset(); - ctx.fillStyle = 'rgba(0, 255, 0, 0.5)'; - ctx.fillRect(0, 0, 100, 50); - ctx.globalCompositeOperation = 'source-atop'; - ctx.fillStyle = 'rgba(0, 0, 255, 0.75)'; - ctx.fillRect(0, 0, 100, 50); - verify(Helper.comparePixel(ctx, 50,25, 0,63,191,127, 5)); - - ctx.reset(); - ctx.fillStyle = 'rgba(0, 255, 0, 0.5)'; - ctx.fillRect(0, 0, 100, 50); - ctx.globalCompositeOperation = 'source-in'; - ctx.fillStyle = 'rgba(0, 0, 255, 0.75)'; - ctx.fillRect(0, 0, 100, 50); - verify(Helper.comparePixel(ctx, 50,25, 0,0,255,95, 5)); - - ctx.reset(); - ctx.fillStyle = 'rgba(0, 255, 0, 0.5)'; - ctx.fillRect(0, 0, 100, 50); - ctx.globalCompositeOperation = 'source-out'; - ctx.fillStyle = 'rgba(0, 0, 255, 0.75)'; - ctx.fillRect(0, 0, 100, 50); - verify(Helper.comparePixel(ctx, 50,25, 0,0,255,95, 5)); - - - ctx.reset(); - ctx.fillStyle = 'rgba(0, 255, 0, 0.5)'; - ctx.fillRect(0, 0, 100, 50); - ctx.globalCompositeOperation = 'source-over'; - ctx.fillStyle = 'rgba(0, 0, 255, 0.75)'; - ctx.fillRect(0, 0, 100, 50); - verify(Helper.comparePixel(ctx, 50,25, 0,36,218,223, 5)); - - ctx.reset(); - ctx.fillStyle = 'rgba(0, 255, 0, 0.5)'; - ctx.fillRect(0, 0, 100, 50); - ctx.globalCompositeOperation = 'xor'; - ctx.fillStyle = 'rgba(0, 0, 255, 0.75)'; - ctx.fillRect(0, 0, 100, 50); - verify(Helper.comparePixel(ctx, 50,25, 0,63,191,127, 5)); - - } - - function test_uncovered() { - skip("FIXME"); - var ctx = canvas.getContext('2d'); - ctx.reset(); - ctx.fillStyle = 'rgba(0, 255, 0, 0.5)'; - ctx.fillRect(0, 0, 100, 50); - ctx.globalCompositeOperation = 'copy'; - ctx.fillStyle = 'rgba(0, 0, 255, 0.75)'; - ctx.translate(0, 25); - ctx.fillRect(0, 50, 100, 50); - verify(Helper.comparePixel(ctx, 50,25, 0,0,0,0, 5)); - - ctx.reset(); - ctx.fillStyle = 'rgba(0, 255, 0, 0.5)'; - ctx.fillRect(0, 0, 100, 50); - ctx.globalCompositeOperation = 'destination-atop'; - ctx.fillStyle = 'rgba(0, 0, 255, 0.75)'; - ctx.translate(0, 25); - ctx.fillRect(0, 50, 100, 50); - verify(Helper.comparePixel(ctx, 50,25, 0,0,0,0, 5)); - - - - ctx.reset(); - ctx.fillStyle = 'rgba(0, 255, 0, 0.5)'; - ctx.fillRect(0, 0, 100, 50); - ctx.globalCompositeOperation = 'destination-in'; - ctx.fillStyle = 'rgba(0, 0, 255, 0.75)'; - ctx.translate(0, 25); - ctx.fillRect(0, 50, 100, 50); - verify(Helper.comparePixel(ctx, 50,25, 0,0,0,0, 5)); - - ctx.reset(); - ctx.fillStyle = 'rgba(0, 255, 0, 0.5)'; - ctx.fillRect(0, 0, 100, 50); - ctx.globalCompositeOperation = 'source-in'; - ctx.fillStyle = 'rgba(0, 0, 255, 0.75)'; - ctx.translate(0, 25); - ctx.fillRect(0, 50, 100, 50); - verify(Helper.comparePixel(ctx, 50,25, 0,0,0,0, 5)); - - ctx.reset(); - ctx.fillStyle = 'rgba(0, 255, 0, 0.5)'; - ctx.fillRect(0, 0, 100, 50); - ctx.globalCompositeOperation = 'source-out'; - ctx.fillStyle = 'rgba(0, 0, 255, 0.75)'; - ctx.translate(0, 25); - ctx.fillRect(0, 50, 100, 50); - verify(Helper.comparePixel(ctx, 50,25, 0,0,0,0, 5)); - - } - - } -} \ No newline at end of file diff --git a/tests/auto/qtquick2/qquickcanvasitem/data/tst_context.qml b/tests/auto/qtquick2/qquickcanvasitem/data/tst_context.qml deleted file mode 100644 index b72e755ed9..0000000000 --- a/tests/auto/qtquick2/qquickcanvasitem/data/tst_context.qml +++ /dev/null @@ -1,73 +0,0 @@ - -import QtQuick 2.0 -import QtTest 1.0 - -Canvas { - id: canvas - width: 1 - height: 1 - contextType: "2d" - - property var contextInPaint - - SignalSpy { - id: paintedSpy - target: canvas - signalName: "paint" - } - - SignalSpy { - id: contextSpy - target: canvas - signalName: "contextChanged" - } - - onPaint: { - contextInPaint = context; - } - - TestCase { - name: "ContextTypeStored" - when: windowShown - - function test_contextType() { - compare(canvas.contextType, "2d"); - } - } - - TestCase { - name: "ContextValidWhenTypePredefined" - when: canvas.available - - function test_context() { - // Wait for the context to become active - wait(100); - compare(contextSpy.count, 1); - - // Context is available - verify(canvas.context) - } - - function test_contextIsConsistent() { - // Wait for the context to become active - wait(100); - compare(contextSpy.count, 1); - - // getContext("2d") is the same as the context property - compare(canvas.getContext("2d"), canvas.context); - } - - function test_paintHadContext() { - // Make there was a paint signal - wait(100); - verify(paintedSpy.count, 1) - - // Paint was called with a valid context when contextType is - // specified - verify(canvas.contextInPaint) - - // paints context was the correct one - compare(canvas.contextInPaint, canvas.getContext("2d")); - } - } -} diff --git a/tests/auto/qtquick2/qquickcanvasitem/data/tst_drawimage.qml b/tests/auto/qtquick2/qquickcanvasitem/data/tst_drawimage.qml deleted file mode 100644 index 102217dc0c..0000000000 --- a/tests/auto/qtquick2/qquickcanvasitem/data/tst_drawimage.qml +++ /dev/null @@ -1,667 +0,0 @@ -import QtQuick 2.0 -import QtTest 1.0 -import "testhelper.js" as Helper -Canvas { - id:canvas; width:100;height:50; renderTarget: Canvas.Image - Component.onCompleted: { - canvas.loadImage('green.png'); - canvas.loadImage('red.png'); - canvas.loadImage('rgrg-256x256.png'); - canvas.loadImage('ggrr-256x256.png'); - canvas.loadImage('broken.png'); - } - - TestCase { - //TODO - name: "image"; when: windowShown - function test_3args() { - //make sure all images are loaded - wait(200); - var ctx = canvas.getContext('2d'); - ctx.reset(); - ctx.drawImage('green.png', 0, 0); - ctx.drawImage('red.png', -100, 0); - ctx.drawImage('red.png', 100, 0); - ctx.drawImage('red.png', 0, -50); - ctx.drawImage('red.png', 0, 50); - - verify(Helper.comparePixel(ctx, 0,0, 0,255,0,255,2)); - verify(Helper.comparePixel(ctx, 99,0, 0,255,0,255,2)); - verify(Helper.comparePixel(ctx, 0,49, 0,255,0,255,2)); - verify(Helper.comparePixel(ctx, 99,49, 0,255,0,255,2)); - - } - function test_5args() { - var ctx = canvas.getContext('2d'); - ctx.reset(); - ctx.fillStyle = '#f00'; - ctx.fillRect(0, 0, 100, 50); - ctx.drawImage('green.png', 50, 0, 50, 50); - ctx.drawImage('red.png', 0, 0, 50, 50); - ctx.fillStyle = '#0f0'; - ctx.fillRect(0, 0, 50, 50); - - verify(Helper.comparePixel(ctx, 0,0, 0,255,0,255,2)); - verify(Helper.comparePixel(ctx, 99,0, 0,255,0,255,2)); - verify(Helper.comparePixel(ctx, 0,49, 0,255,0,255,2)); - verify(Helper.comparePixel(ctx, 99,49, 0,255,0,255,2)); - - } - function test_9args() { - var ctx = canvas.getContext('2d'); - ctx.reset(); - ctx.fillStyle = '#f00'; - ctx.fillRect(0, 0, 100, 50); - ctx.drawImage('green.png', 0, 0, 100, 50, 0, 0, 100, 50); - verify(Helper.comparePixel(ctx, 0,0, 0,255,0,255,2)); - verify(Helper.comparePixel(ctx, 99,0, 0,255,0,255,2)); - verify(Helper.comparePixel(ctx, 0,49, 0,255,0,255,2)); - verify(Helper.comparePixel(ctx, 99,49, 0,255,0,255,2)); - - ctx.reset(); - - ctx.fillStyle = '#f00'; - ctx.fillRect(0, 0, 100, 50); - ctx.drawImage('green.png', 0, 0, 100, 50, 0, 0, 100, 50); - ctx.drawImage('red.png', 0, 0, 100, 50, -100, 0, 100, 50); - ctx.drawImage('red.png', 0, 0, 100, 50, 100, 0, 100, 50); - ctx.drawImage('red.png', 0, 0, 100, 50, 0, -50, 100, 50); - ctx.drawImage('red.png', 0, 0, 100, 50, 0, 50, 100, 50); - verify(Helper.comparePixel(ctx, 0,0, 0,255,0,255,2)); - verify(Helper.comparePixel(ctx, 99,0, 0,255,0,255,2)); - verify(Helper.comparePixel(ctx, 0,49, 0,255,0,255,2)); - verify(Helper.comparePixel(ctx, 99,49, 0,255,0,255,2)); - - - ctx.fillStyle = '#f00'; - ctx.fillRect(0, 0, 100, 50); - ctx.drawImage('green.png', 1, 1, 1, 1, 0, 0, 100, 50); - ctx.drawImage('red.png', 0, 0, 100, 50, -50, 0, 50, 50); - ctx.drawImage('red.png', 0, 0, 100, 50, 100, 0, 50, 50); - ctx.drawImage('red.png', 0, 0, 100, 50, 0, -25, 100, 25); - ctx.drawImage('red.png', 0, 0, 100, 50, 0, 50, 100, 25); - verify(Helper.comparePixel(ctx, 0,0, 0,255,0,255,2)); - verify(Helper.comparePixel(ctx, 99,0, 0,255,0,255,2)); - verify(Helper.comparePixel(ctx, 0,49, 0,255,0,255,2)); - verify(Helper.comparePixel(ctx, 99,49, 0,255,0,255,2)); - - ctx.fillStyle = '#f00'; - ctx.fillRect(0, 0, 100, 50); - ctx.drawImage('rgrg-256x256.png', 140, 20, 100, 50, 0, 0, 100, 50); - verify(Helper.comparePixel(ctx, 0,0, 0,255,0,255,2)); - verify(Helper.comparePixel(ctx, 99,0, 0,255,0,255,2)); - verify(Helper.comparePixel(ctx, 0,49, 0,255,0,255,2)); - verify(Helper.comparePixel(ctx, 99,49, 0,255,0,255,2)); - - ctx.fillStyle = '#f00'; - ctx.fillRect(0, 0, 100, 50); - ctx.drawImage('rgrg-256x256.png', 0, 0, 256, 256, 0, 0, 100, 50); - ctx.fillStyle = '#0f0'; - ctx.fillRect(0, 0, 51, 26); - ctx.fillRect(49, 24, 51, 26); - verify(Helper.comparePixel(ctx, 0,0, 0,255,0,255,2)); - verify(Helper.comparePixel(ctx, 99,0, 0,255,0,255,2)); - verify(Helper.comparePixel(ctx, 0,49, 0,255,0,255,2)); - verify(Helper.comparePixel(ctx, 99,49, 0,255,0,255,2)); - verify(Helper.comparePixel(ctx, 20,20, 0,255,0,255,2)); - verify(Helper.comparePixel(ctx, 80,20, 0,255,0,255,2)); - verify(Helper.comparePixel(ctx, 20,30, 0,255,0,255,2)); - verify(Helper.comparePixel(ctx, 80,30, 0,255,0,255,2)); - - } - function test_animated() { - var ctx = canvas.getContext('2d'); - ctx.reset(); - //should animated image be supported at all? - } - function test_clip() { - var ctx = canvas.getContext('2d'); - ctx.reset(); - ctx.fillStyle = '#0f0'; - ctx.fillRect(0, 0, 100, 50); - ctx.rect(-10, -10, 1, 1); - ctx.clip(); - ctx.drawImage('red.png', 0, 0); - verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255,2)); - - - } - function test_self() { - var ctx = canvas.getContext('2d'); - ctx.reset(); - ignoreWarning("QImage::scaled: Image is a null image"); - ignoreWarning("QImage::scaled: Image is a null image"); - - ctx.fillStyle = '#0f0'; - ctx.fillRect(0, 0, 50, 50); - ctx.fillStyle = '#f00'; - ctx.fillRect(50, 0, 50, 50); - ctx.drawImage(canvas, 50, 0); - - verify(Helper.comparePixel(ctx, 0,0, 0,255,0,255,2)); - verify(Helper.comparePixel(ctx, 99,0, 0,255,0,255,2)); - verify(Helper.comparePixel(ctx, 0,49, 0,255,0,255,2)); - verify(Helper.comparePixel(ctx, 99,49, 0,255,0,255,2)); - - ctx.reset(); - ctx.fillStyle = '#0f0'; - ctx.fillRect(0, 1, 100, 49); - ctx.fillStyle = '#f00'; - ctx.fillRect(0, 0, 100, 1); - ctx.drawImage(canvas, 0, 1); - ctx.fillStyle = '#0f0'; - ctx.fillRect(0, 0, 100, 2); - - verify(Helper.comparePixel(ctx, 0,0, 0,255,0,255,2)); - verify(Helper.comparePixel(ctx, 99,0, 0,255,0,255,2)); - verify(Helper.comparePixel(ctx, 0,49, 0,255,0,255,2)); - verify(Helper.comparePixel(ctx, 99,49, 0,255,0,255,2)); - - - } - - function test_outsidesource() { - var ctx = canvas.getContext('2d'); - ctx.reset(); - - ctx.drawImage('green.png', 10.5, 10.5, 89.5, 39.5, 0, 0, 100, 50); - ctx.drawImage('green.png', 5.5, 5.5, -5.5, -5.5, 0, 0, 100, 50); - ctx.drawImage('green.png', 100, 50, -5, -5, 0, 0, 100, 50); - try { var err = false; - ctx.drawImage('red.png', -0.001, 0, 100, 50, 0, 0, 100, 50); - } catch (e) { if (e.code != DOMException.INDEX_SIZE_ERR) fail("Failed assertion: expected exception of type INDEX_SIZE_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type INDEX_SIZE_ERR: ctx.drawImage('red.png', -0.001, 0, 100, 50, 0, 0, 100, 50)"); } - try { var err = false; - ctx.drawImage('red.png', 0, -0.001, 100, 50, 0, 0, 100, 50); - } catch (e) { if (e.code != DOMException.INDEX_SIZE_ERR) fail("Failed assertion: expected exception of type INDEX_SIZE_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type INDEX_SIZE_ERR: ctx.drawImage('red.png', 0, -0.001, 100, 50, 0, 0, 100, 50)"); } - try { var err = false; - ctx.drawImage('red.png', 0, 0, 100.001, 50, 0, 0, 100, 50); - } catch (e) { if (e.code != DOMException.INDEX_SIZE_ERR) fail("Failed assertion: expected exception of type INDEX_SIZE_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type INDEX_SIZE_ERR: ctx.drawImage('red.png', 0, 0, 100.001, 50, 0, 0, 100, 50)"); } - try { var err = false; - ctx.drawImage('red.png', 0, 0, 100, 50.001, 0, 0, 100, 50); - } catch (e) { if (e.code != DOMException.INDEX_SIZE_ERR) fail("Failed assertion: expected exception of type INDEX_SIZE_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type INDEX_SIZE_ERR: ctx.drawImage('red.png', 0, 0, 100, 50.001, 0, 0, 100, 50)"); } - try { var err = false; - ctx.drawImage('red.png', 50, 0, 50.001, 50, 0, 0, 100, 50); - } catch (e) { if (e.code != DOMException.INDEX_SIZE_ERR) fail("Failed assertion: expected exception of type INDEX_SIZE_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type INDEX_SIZE_ERR: ctx.drawImage('red.png', 50, 0, 50.001, 50, 0, 0, 100, 50)"); } - try { var err = false; - ctx.drawImage('red.png', 0, 0, -5, 5, 0, 0, 100, 50); - } catch (e) { if (e.code != DOMException.INDEX_SIZE_ERR) fail("Failed assertion: expected exception of type INDEX_SIZE_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type INDEX_SIZE_ERR: ctx.drawImage('red.png', 0, 0, -5, 5, 0, 0, 100, 50)"); } - try { var err = false; - ctx.drawImage('red.png', 0, 0, 5, -5, 0, 0, 100, 50); - } catch (e) { if (e.code != DOMException.INDEX_SIZE_ERR) fail("Failed assertion: expected exception of type INDEX_SIZE_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type INDEX_SIZE_ERR: ctx.drawImage('red.png', 0, 0, 5, -5, 0, 0, 100, 50)"); } -// try { var err = false; -// ctx.drawImage('red.png', 110, 60, -20, -20, 0, 0, 100, 50); -// } catch (e) { if (e.code != DOMException.INDEX_SIZE_ERR) fail("Failed assertion: expected exception of type INDEX_SIZE_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type INDEX_SIZE_ERR: ctx.drawImage('red.png', 110, 60, -20, -20, 0, 0, 100, 50)"); } -// verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255,2)); - - } - - function test_null() { - var ctx = canvas.getContext('2d'); - ctx.reset(); - - try { var err = false; - ctx.drawImage(null, 0, 0); - } catch (e) { if (e.code != DOMException.TYPE_MISMATCH_ERR) fail("Failed assertion: expected exception of type TYPE_MISMATCH_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type TYPE_MISMATCH_ERR: ctx.drawImage(null, 0, 0)"); } - - } - - function test_composite() { - var ctx = canvas.getContext('2d'); - ctx.reset(); - ctx.fillStyle = '#0f0'; - ctx.fillRect(0, 0, 100, 50); - ctx.globalCompositeOperation = 'destination-over'; - ctx.drawImage('red.png', 0, 0); - verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255,2)); - - } - function test_path() { - var ctx = canvas.getContext('2d'); - ctx.reset(); - } - function test_transform() { - var ctx = canvas.getContext('2d'); - ctx.reset(); - ctx.fillStyle = '#0f0'; - ctx.fillRect(0, 0, 100, 50); - ctx.translate(100, 0); - ctx.drawImage('red.png', 0, 0); - verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255,2)); - - } - - function test_imageitem() { - var ctx = canvas.getContext('2d'); - ctx.reset(); - //TODO - } - - function test_imageData() { - var ctx = canvas.getContext('2d'); - ctx.reset(); - //TODO - } - - function test_wrongtype() { - var ctx = canvas.getContext('2d'); - ctx.reset(); - - try { var err = false; - ctx.drawImage(undefined, 0, 0); - } catch (e) { if (e.code != DOMException.TYPE_MISMATCH_ERR) fail("Failed assertion: expected exception of type TYPE_MISMATCH_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type TYPE_MISMATCH_ERR: ctx.drawImage(undefined, 0, 0)"); } - try { var err = false; - ctx.drawImage(0, 0, 0); - } catch (e) { if (e.code != DOMException.TYPE_MISMATCH_ERR) fail("Failed assertion: expected exception of type TYPE_MISMATCH_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type TYPE_MISMATCH_ERR: ctx.drawImage(0, 0, 0)"); } - try { var err = false; - ctx.drawImage("", 0, 0); - } catch (e) { if (e.code != DOMException.TYPE_MISMATCH_ERR) fail("Failed assertion: expected exception of type TYPE_MISMATCH_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type TYPE_MISMATCH_ERR: ctx.drawImage(\"\", 0, 0)"); } - } - - function test_nonfinite() { - var ctx = canvas.getContext('2d'); - ctx.reset(); - ignoreWarning("QImage::scaled: Image is a null image"); - ignoreWarning("QImage::scaled: Image is a null image"); - ignoreWarning("QImage::scaled: Image is a null image"); - ignoreWarning("QImage::scaled: Image is a null image"); - ctx.fillStyle = '#0f0'; - ctx.fillRect(0, 0, 100, 50); - var red = 'red.png'; - ctx.drawImage(red, Infinity, 0); - ctx.drawImage(red, -Infinity, 0); - ctx.drawImage(red, NaN, 0); - ctx.drawImage(red, 0, Infinity); - ctx.drawImage(red, 0, -Infinity); - ctx.drawImage(red, 0, NaN); - ctx.drawImage(red, Infinity, Infinity); - ctx.drawImage(red, Infinity, 0, 100, 50); - ctx.drawImage(red, -Infinity, 0, 100, 50); - ctx.drawImage(red, NaN, 0, 100, 50); - ctx.drawImage(red, 0, Infinity, 100, 50); - ctx.drawImage(red, 0, -Infinity, 100, 50); - ctx.drawImage(red, 0, NaN, 100, 50); - ctx.drawImage(red, 0, 0, Infinity, 50); - ctx.drawImage(red, 0, 0, -Infinity, 50); - ctx.drawImage(red, 0, 0, NaN, 50); - ctx.drawImage(red, 0, 0, 100, Infinity); - ctx.drawImage(red, 0, 0, 100, -Infinity); - ctx.drawImage(red, 0, 0, 100, NaN); - ctx.drawImage(red, Infinity, Infinity, 100, 50); - ctx.drawImage(red, Infinity, Infinity, Infinity, 50); - ctx.drawImage(red, Infinity, Infinity, Infinity, Infinity); - ctx.drawImage(red, Infinity, Infinity, 100, Infinity); - ctx.drawImage(red, Infinity, 0, Infinity, 50); - ctx.drawImage(red, Infinity, 0, Infinity, Infinity); - ctx.drawImage(red, Infinity, 0, 100, Infinity); - ctx.drawImage(red, 0, Infinity, Infinity, 50); - ctx.drawImage(red, 0, Infinity, Infinity, Infinity); - ctx.drawImage(red, 0, Infinity, 100, Infinity); - ctx.drawImage(red, 0, 0, Infinity, Infinity); - ctx.drawImage(red, Infinity, 0, 100, 50, 0, 0, 100, 50); - ctx.drawImage(red, -Infinity, 0, 100, 50, 0, 0, 100, 50); - ctx.drawImage(red, NaN, 0, 100, 50, 0, 0, 100, 50); - ctx.drawImage(red, 0, Infinity, 100, 50, 0, 0, 100, 50); - ctx.drawImage(red, 0, -Infinity, 100, 50, 0, 0, 100, 50); - ctx.drawImage(red, 0, NaN, 100, 50, 0, 0, 100, 50); - ctx.drawImage(red, 0, 0, Infinity, 50, 0, 0, 100, 50); - ctx.drawImage(red, 0, 0, -Infinity, 50, 0, 0, 100, 50); - ctx.drawImage(red, 0, 0, NaN, 50, 0, 0, 100, 50); - ctx.drawImage(red, 0, 0, 100, Infinity, 0, 0, 100, 50); - ctx.drawImage(red, 0, 0, 100, -Infinity, 0, 0, 100, 50); - ctx.drawImage(red, 0, 0, 100, NaN, 0, 0, 100, 50); - ctx.drawImage(red, 0, 0, 100, 50, Infinity, 0, 100, 50); - ctx.drawImage(red, 0, 0, 100, 50, -Infinity, 0, 100, 50); - ctx.drawImage(red, 0, 0, 100, 50, NaN, 0, 100, 50); - ctx.drawImage(red, 0, 0, 100, 50, 0, Infinity, 100, 50); - ctx.drawImage(red, 0, 0, 100, 50, 0, -Infinity, 100, 50); - ctx.drawImage(red, 0, 0, 100, 50, 0, NaN, 100, 50); - ctx.drawImage(red, 0, 0, 100, 50, 0, 0, Infinity, 50); - ctx.drawImage(red, 0, 0, 100, 50, 0, 0, -Infinity, 50); - ctx.drawImage(red, 0, 0, 100, 50, 0, 0, NaN, 50); - ctx.drawImage(red, 0, 0, 100, 50, 0, 0, 100, Infinity); - ctx.drawImage(red, 0, 0, 100, 50, 0, 0, 100, -Infinity); - ctx.drawImage(red, 0, 0, 100, 50, 0, 0, 100, NaN); - ctx.drawImage(red, Infinity, Infinity, 100, 50, 0, 0, 100, 50); - ctx.drawImage(red, Infinity, Infinity, Infinity, 50, 0, 0, 100, 50); - ctx.drawImage(red, Infinity, Infinity, Infinity, Infinity, 0, 0, 100, 50); - ctx.drawImage(red, Infinity, Infinity, Infinity, Infinity, Infinity, 0, 100, 50); - ctx.drawImage(red, Infinity, Infinity, Infinity, Infinity, Infinity, Infinity, 100, 50); - ctx.drawImage(red, Infinity, Infinity, Infinity, Infinity, Infinity, Infinity, Infinity, 50); - ctx.drawImage(red, Infinity, Infinity, Infinity, Infinity, Infinity, Infinity, Infinity, Infinity); - ctx.drawImage(red, Infinity, Infinity, Infinity, Infinity, Infinity, Infinity, 100, Infinity); - ctx.drawImage(red, Infinity, Infinity, Infinity, Infinity, Infinity, 0, Infinity, 50); - ctx.drawImage(red, Infinity, Infinity, Infinity, Infinity, Infinity, 0, Infinity, Infinity); - ctx.drawImage(red, Infinity, Infinity, Infinity, Infinity, Infinity, 0, 100, Infinity); - ctx.drawImage(red, Infinity, Infinity, Infinity, Infinity, 0, Infinity, 100, 50); - ctx.drawImage(red, Infinity, Infinity, Infinity, Infinity, 0, Infinity, Infinity, 50); - ctx.drawImage(red, Infinity, Infinity, Infinity, Infinity, 0, Infinity, Infinity, Infinity); - ctx.drawImage(red, Infinity, Infinity, Infinity, Infinity, 0, Infinity, 100, Infinity); - ctx.drawImage(red, Infinity, Infinity, Infinity, Infinity, 0, 0, Infinity, 50); - ctx.drawImage(red, Infinity, Infinity, Infinity, Infinity, 0, 0, Infinity, Infinity); - ctx.drawImage(red, Infinity, Infinity, Infinity, Infinity, 0, 0, 100, Infinity); - ctx.drawImage(red, Infinity, Infinity, Infinity, 50, Infinity, 0, 100, 50); - ctx.drawImage(red, Infinity, Infinity, Infinity, 50, Infinity, Infinity, 100, 50); - ctx.drawImage(red, Infinity, Infinity, Infinity, 50, Infinity, Infinity, Infinity, 50); - ctx.drawImage(red, Infinity, Infinity, Infinity, 50, Infinity, Infinity, Infinity, Infinity); - ctx.drawImage(red, Infinity, Infinity, Infinity, 50, Infinity, Infinity, 100, Infinity); - ctx.drawImage(red, Infinity, Infinity, Infinity, 50, Infinity, 0, Infinity, 50); - ctx.drawImage(red, Infinity, Infinity, Infinity, 50, Infinity, 0, Infinity, Infinity); - ctx.drawImage(red, Infinity, Infinity, Infinity, 50, Infinity, 0, 100, Infinity); - ctx.drawImage(red, Infinity, Infinity, Infinity, 50, 0, Infinity, 100, 50); - ctx.drawImage(red, Infinity, Infinity, Infinity, 50, 0, Infinity, Infinity, 50); - ctx.drawImage(red, Infinity, Infinity, Infinity, 50, 0, Infinity, Infinity, Infinity); - ctx.drawImage(red, Infinity, Infinity, Infinity, 50, 0, Infinity, 100, Infinity); - ctx.drawImage(red, Infinity, Infinity, Infinity, 50, 0, 0, Infinity, 50); - ctx.drawImage(red, Infinity, Infinity, Infinity, 50, 0, 0, Infinity, Infinity); - ctx.drawImage(red, Infinity, Infinity, Infinity, 50, 0, 0, 100, Infinity); - ctx.drawImage(red, Infinity, Infinity, 100, Infinity, 0, 0, 100, 50); - ctx.drawImage(red, Infinity, Infinity, 100, Infinity, Infinity, 0, 100, 50); - ctx.drawImage(red, Infinity, Infinity, 100, Infinity, Infinity, Infinity, 100, 50); - ctx.drawImage(red, Infinity, Infinity, 100, Infinity, Infinity, Infinity, Infinity, 50); - ctx.drawImage(red, Infinity, Infinity, 100, Infinity, Infinity, Infinity, Infinity, Infinity); - ctx.drawImage(red, Infinity, Infinity, 100, Infinity, Infinity, Infinity, 100, Infinity); - ctx.drawImage(red, Infinity, Infinity, 100, Infinity, Infinity, 0, Infinity, 50); - ctx.drawImage(red, Infinity, Infinity, 100, Infinity, Infinity, 0, Infinity, Infinity); - ctx.drawImage(red, Infinity, Infinity, 100, Infinity, Infinity, 0, 100, Infinity); - ctx.drawImage(red, Infinity, Infinity, 100, Infinity, 0, Infinity, 100, 50); - ctx.drawImage(red, Infinity, Infinity, 100, Infinity, 0, Infinity, Infinity, 50); - ctx.drawImage(red, Infinity, Infinity, 100, Infinity, 0, Infinity, Infinity, Infinity); - ctx.drawImage(red, Infinity, Infinity, 100, Infinity, 0, Infinity, 100, Infinity); - ctx.drawImage(red, Infinity, Infinity, 100, Infinity, 0, 0, Infinity, 50); - ctx.drawImage(red, Infinity, Infinity, 100, Infinity, 0, 0, Infinity, Infinity); - ctx.drawImage(red, Infinity, Infinity, 100, Infinity, 0, 0, 100, Infinity); - ctx.drawImage(red, Infinity, Infinity, 100, 50, Infinity, 0, 100, 50); - ctx.drawImage(red, Infinity, Infinity, 100, 50, Infinity, Infinity, 100, 50); - ctx.drawImage(red, Infinity, Infinity, 100, 50, Infinity, Infinity, Infinity, 50); - ctx.drawImage(red, Infinity, Infinity, 100, 50, Infinity, Infinity, Infinity, Infinity); - ctx.drawImage(red, Infinity, Infinity, 100, 50, Infinity, Infinity, 100, Infinity); - ctx.drawImage(red, Infinity, Infinity, 100, 50, Infinity, 0, Infinity, 50); - ctx.drawImage(red, Infinity, Infinity, 100, 50, Infinity, 0, Infinity, Infinity); - ctx.drawImage(red, Infinity, Infinity, 100, 50, Infinity, 0, 100, Infinity); - ctx.drawImage(red, Infinity, Infinity, 100, 50, 0, Infinity, 100, 50); - ctx.drawImage(red, Infinity, Infinity, 100, 50, 0, Infinity, Infinity, 50); - ctx.drawImage(red, Infinity, Infinity, 100, 50, 0, Infinity, Infinity, Infinity); - ctx.drawImage(red, Infinity, Infinity, 100, 50, 0, Infinity, 100, Infinity); - ctx.drawImage(red, Infinity, Infinity, 100, 50, 0, 0, Infinity, 50); - ctx.drawImage(red, Infinity, Infinity, 100, 50, 0, 0, Infinity, Infinity); - ctx.drawImage(red, Infinity, Infinity, 100, 50, 0, 0, 100, Infinity); - ctx.drawImage(red, Infinity, 0, Infinity, 50, 0, 0, 100, 50); - ctx.drawImage(red, Infinity, 0, Infinity, Infinity, 0, 0, 100, 50); - ctx.drawImage(red, Infinity, 0, Infinity, Infinity, Infinity, 0, 100, 50); - ctx.drawImage(red, Infinity, 0, Infinity, Infinity, Infinity, Infinity, 100, 50); - ctx.drawImage(red, Infinity, 0, Infinity, Infinity, Infinity, Infinity, Infinity, 50); - ctx.drawImage(red, Infinity, 0, Infinity, Infinity, Infinity, Infinity, Infinity, Infinity); - ctx.drawImage(red, Infinity, 0, Infinity, Infinity, Infinity, Infinity, 100, Infinity); - ctx.drawImage(red, Infinity, 0, Infinity, Infinity, Infinity, 0, Infinity, 50); - ctx.drawImage(red, Infinity, 0, Infinity, Infinity, Infinity, 0, Infinity, Infinity); - ctx.drawImage(red, Infinity, 0, Infinity, Infinity, Infinity, 0, 100, Infinity); - ctx.drawImage(red, Infinity, 0, Infinity, Infinity, 0, Infinity, 100, 50); - ctx.drawImage(red, Infinity, 0, Infinity, Infinity, 0, Infinity, Infinity, 50); - ctx.drawImage(red, Infinity, 0, Infinity, Infinity, 0, Infinity, Infinity, Infinity); - ctx.drawImage(red, Infinity, 0, Infinity, Infinity, 0, Infinity, 100, Infinity); - ctx.drawImage(red, Infinity, 0, Infinity, Infinity, 0, 0, Infinity, 50); - ctx.drawImage(red, Infinity, 0, Infinity, Infinity, 0, 0, Infinity, Infinity); - ctx.drawImage(red, Infinity, 0, Infinity, Infinity, 0, 0, 100, Infinity); - ctx.drawImage(red, Infinity, 0, Infinity, 50, Infinity, 0, 100, 50); - ctx.drawImage(red, Infinity, 0, Infinity, 50, Infinity, Infinity, 100, 50); - ctx.drawImage(red, Infinity, 0, Infinity, 50, Infinity, Infinity, Infinity, 50); - ctx.drawImage(red, Infinity, 0, Infinity, 50, Infinity, Infinity, Infinity, Infinity); - ctx.drawImage(red, Infinity, 0, Infinity, 50, Infinity, Infinity, 100, Infinity); - ctx.drawImage(red, Infinity, 0, Infinity, 50, Infinity, 0, Infinity, 50); - ctx.drawImage(red, Infinity, 0, Infinity, 50, Infinity, 0, Infinity, Infinity); - ctx.drawImage(red, Infinity, 0, Infinity, 50, Infinity, 0, 100, Infinity); - ctx.drawImage(red, Infinity, 0, Infinity, 50, 0, Infinity, 100, 50); - ctx.drawImage(red, Infinity, 0, Infinity, 50, 0, Infinity, Infinity, 50); - ctx.drawImage(red, Infinity, 0, Infinity, 50, 0, Infinity, Infinity, Infinity); - ctx.drawImage(red, Infinity, 0, Infinity, 50, 0, Infinity, 100, Infinity); - ctx.drawImage(red, Infinity, 0, Infinity, 50, 0, 0, Infinity, 50); - ctx.drawImage(red, Infinity, 0, Infinity, 50, 0, 0, Infinity, Infinity); - ctx.drawImage(red, Infinity, 0, Infinity, 50, 0, 0, 100, Infinity); - ctx.drawImage(red, Infinity, 0, 100, Infinity, 0, 0, 100, 50); - ctx.drawImage(red, Infinity, 0, 100, Infinity, Infinity, 0, 100, 50); - ctx.drawImage(red, Infinity, 0, 100, Infinity, Infinity, Infinity, 100, 50); - ctx.drawImage(red, Infinity, 0, 100, Infinity, Infinity, Infinity, Infinity, 50); - ctx.drawImage(red, Infinity, 0, 100, Infinity, Infinity, Infinity, Infinity, Infinity); - ctx.drawImage(red, Infinity, 0, 100, Infinity, Infinity, Infinity, 100, Infinity); - ctx.drawImage(red, Infinity, 0, 100, Infinity, Infinity, 0, Infinity, 50); - ctx.drawImage(red, Infinity, 0, 100, Infinity, Infinity, 0, Infinity, Infinity); - ctx.drawImage(red, Infinity, 0, 100, Infinity, Infinity, 0, 100, Infinity); - ctx.drawImage(red, Infinity, 0, 100, Infinity, 0, Infinity, 100, 50); - ctx.drawImage(red, Infinity, 0, 100, Infinity, 0, Infinity, Infinity, 50); - ctx.drawImage(red, Infinity, 0, 100, Infinity, 0, Infinity, Infinity, Infinity); - ctx.drawImage(red, Infinity, 0, 100, Infinity, 0, Infinity, 100, Infinity); - ctx.drawImage(red, Infinity, 0, 100, Infinity, 0, 0, Infinity, 50); - ctx.drawImage(red, Infinity, 0, 100, Infinity, 0, 0, Infinity, Infinity); - ctx.drawImage(red, Infinity, 0, 100, Infinity, 0, 0, 100, Infinity); - ctx.drawImage(red, Infinity, 0, 100, 50, Infinity, 0, 100, 50); - ctx.drawImage(red, Infinity, 0, 100, 50, Infinity, Infinity, 100, 50); - ctx.drawImage(red, Infinity, 0, 100, 50, Infinity, Infinity, Infinity, 50); - ctx.drawImage(red, Infinity, 0, 100, 50, Infinity, Infinity, Infinity, Infinity); - ctx.drawImage(red, Infinity, 0, 100, 50, Infinity, Infinity, 100, Infinity); - ctx.drawImage(red, Infinity, 0, 100, 50, Infinity, 0, Infinity, 50); - ctx.drawImage(red, Infinity, 0, 100, 50, Infinity, 0, Infinity, Infinity); - ctx.drawImage(red, Infinity, 0, 100, 50, Infinity, 0, 100, Infinity); - ctx.drawImage(red, Infinity, 0, 100, 50, 0, Infinity, 100, 50); - ctx.drawImage(red, Infinity, 0, 100, 50, 0, Infinity, Infinity, 50); - ctx.drawImage(red, Infinity, 0, 100, 50, 0, Infinity, Infinity, Infinity); - ctx.drawImage(red, Infinity, 0, 100, 50, 0, Infinity, 100, Infinity); - ctx.drawImage(red, Infinity, 0, 100, 50, 0, 0, Infinity, 50); - ctx.drawImage(red, Infinity, 0, 100, 50, 0, 0, Infinity, Infinity); - ctx.drawImage(red, Infinity, 0, 100, 50, 0, 0, 100, Infinity); - ctx.drawImage(red, 0, Infinity, Infinity, 50, 0, 0, 100, 50); - ctx.drawImage(red, 0, Infinity, Infinity, Infinity, 0, 0, 100, 50); - ctx.drawImage(red, 0, Infinity, Infinity, Infinity, Infinity, 0, 100, 50); - ctx.drawImage(red, 0, Infinity, Infinity, Infinity, Infinity, Infinity, 100, 50); - ctx.drawImage(red, 0, Infinity, Infinity, Infinity, Infinity, Infinity, Infinity, 50); - ctx.drawImage(red, 0, Infinity, Infinity, Infinity, Infinity, Infinity, Infinity, Infinity); - ctx.drawImage(red, 0, Infinity, Infinity, Infinity, Infinity, Infinity, 100, Infinity); - ctx.drawImage(red, 0, Infinity, Infinity, Infinity, Infinity, 0, Infinity, 50); - ctx.drawImage(red, 0, Infinity, Infinity, Infinity, Infinity, 0, Infinity, Infinity); - ctx.drawImage(red, 0, Infinity, Infinity, Infinity, Infinity, 0, 100, Infinity); - ctx.drawImage(red, 0, Infinity, Infinity, Infinity, 0, Infinity, 100, 50); - ctx.drawImage(red, 0, Infinity, Infinity, Infinity, 0, Infinity, Infinity, 50); - ctx.drawImage(red, 0, Infinity, Infinity, Infinity, 0, Infinity, Infinity, Infinity); - ctx.drawImage(red, 0, Infinity, Infinity, Infinity, 0, Infinity, 100, Infinity); - ctx.drawImage(red, 0, Infinity, Infinity, Infinity, 0, 0, Infinity, 50); - ctx.drawImage(red, 0, Infinity, Infinity, Infinity, 0, 0, Infinity, Infinity); - ctx.drawImage(red, 0, Infinity, Infinity, Infinity, 0, 0, 100, Infinity); - ctx.drawImage(red, 0, Infinity, Infinity, 50, Infinity, 0, 100, 50); - ctx.drawImage(red, 0, Infinity, Infinity, 50, Infinity, Infinity, 100, 50); - ctx.drawImage(red, 0, Infinity, Infinity, 50, Infinity, Infinity, Infinity, 50); - ctx.drawImage(red, 0, Infinity, Infinity, 50, Infinity, Infinity, Infinity, Infinity); - ctx.drawImage(red, 0, Infinity, Infinity, 50, Infinity, Infinity, 100, Infinity); - ctx.drawImage(red, 0, Infinity, Infinity, 50, Infinity, 0, Infinity, 50); - ctx.drawImage(red, 0, Infinity, Infinity, 50, Infinity, 0, Infinity, Infinity); - ctx.drawImage(red, 0, Infinity, Infinity, 50, Infinity, 0, 100, Infinity); - ctx.drawImage(red, 0, Infinity, Infinity, 50, 0, Infinity, 100, 50); - ctx.drawImage(red, 0, Infinity, Infinity, 50, 0, Infinity, Infinity, 50); - ctx.drawImage(red, 0, Infinity, Infinity, 50, 0, Infinity, Infinity, Infinity); - ctx.drawImage(red, 0, Infinity, Infinity, 50, 0, Infinity, 100, Infinity); - ctx.drawImage(red, 0, Infinity, Infinity, 50, 0, 0, Infinity, 50); - ctx.drawImage(red, 0, Infinity, Infinity, 50, 0, 0, Infinity, Infinity); - ctx.drawImage(red, 0, Infinity, Infinity, 50, 0, 0, 100, Infinity); - ctx.drawImage(red, 0, Infinity, 100, Infinity, 0, 0, 100, 50); - ctx.drawImage(red, 0, Infinity, 100, Infinity, Infinity, 0, 100, 50); - ctx.drawImage(red, 0, Infinity, 100, Infinity, Infinity, Infinity, 100, 50); - ctx.drawImage(red, 0, Infinity, 100, Infinity, Infinity, Infinity, Infinity, 50); - ctx.drawImage(red, 0, Infinity, 100, Infinity, Infinity, Infinity, Infinity, Infinity); - ctx.drawImage(red, 0, Infinity, 100, Infinity, Infinity, Infinity, 100, Infinity); - ctx.drawImage(red, 0, Infinity, 100, Infinity, Infinity, 0, Infinity, 50); - ctx.drawImage(red, 0, Infinity, 100, Infinity, Infinity, 0, Infinity, Infinity); - ctx.drawImage(red, 0, Infinity, 100, Infinity, Infinity, 0, 100, Infinity); - ctx.drawImage(red, 0, Infinity, 100, Infinity, 0, Infinity, 100, 50); - ctx.drawImage(red, 0, Infinity, 100, Infinity, 0, Infinity, Infinity, 50); - ctx.drawImage(red, 0, Infinity, 100, Infinity, 0, Infinity, Infinity, Infinity); - ctx.drawImage(red, 0, Infinity, 100, Infinity, 0, Infinity, 100, Infinity); - ctx.drawImage(red, 0, Infinity, 100, Infinity, 0, 0, Infinity, 50); - ctx.drawImage(red, 0, Infinity, 100, Infinity, 0, 0, Infinity, Infinity); - ctx.drawImage(red, 0, Infinity, 100, Infinity, 0, 0, 100, Infinity); - ctx.drawImage(red, 0, Infinity, 100, 50, Infinity, 0, 100, 50); - ctx.drawImage(red, 0, Infinity, 100, 50, Infinity, Infinity, 100, 50); - ctx.drawImage(red, 0, Infinity, 100, 50, Infinity, Infinity, Infinity, 50); - ctx.drawImage(red, 0, Infinity, 100, 50, Infinity, Infinity, Infinity, Infinity); - ctx.drawImage(red, 0, Infinity, 100, 50, Infinity, Infinity, 100, Infinity); - ctx.drawImage(red, 0, Infinity, 100, 50, Infinity, 0, Infinity, 50); - ctx.drawImage(red, 0, Infinity, 100, 50, Infinity, 0, Infinity, Infinity); - ctx.drawImage(red, 0, Infinity, 100, 50, Infinity, 0, 100, Infinity); - ctx.drawImage(red, 0, Infinity, 100, 50, 0, Infinity, 100, 50); - ctx.drawImage(red, 0, Infinity, 100, 50, 0, Infinity, Infinity, 50); - ctx.drawImage(red, 0, Infinity, 100, 50, 0, Infinity, Infinity, Infinity); - ctx.drawImage(red, 0, Infinity, 100, 50, 0, Infinity, 100, Infinity); - ctx.drawImage(red, 0, Infinity, 100, 50, 0, 0, Infinity, 50); - ctx.drawImage(red, 0, Infinity, 100, 50, 0, 0, Infinity, Infinity); - ctx.drawImage(red, 0, Infinity, 100, 50, 0, 0, 100, Infinity); - ctx.drawImage(red, 0, 0, Infinity, Infinity, 0, 0, 100, 50); - ctx.drawImage(red, 0, 0, Infinity, Infinity, Infinity, 0, 100, 50); - ctx.drawImage(red, 0, 0, Infinity, Infinity, Infinity, Infinity, 100, 50); - ctx.drawImage(red, 0, 0, Infinity, Infinity, Infinity, Infinity, Infinity, 50); - ctx.drawImage(red, 0, 0, Infinity, Infinity, Infinity, Infinity, Infinity, Infinity); - ctx.drawImage(red, 0, 0, Infinity, Infinity, Infinity, Infinity, 100, Infinity); - ctx.drawImage(red, 0, 0, Infinity, Infinity, Infinity, 0, Infinity, 50); - ctx.drawImage(red, 0, 0, Infinity, Infinity, Infinity, 0, Infinity, Infinity); - ctx.drawImage(red, 0, 0, Infinity, Infinity, Infinity, 0, 100, Infinity); - ctx.drawImage(red, 0, 0, Infinity, Infinity, 0, Infinity, 100, 50); - ctx.drawImage(red, 0, 0, Infinity, Infinity, 0, Infinity, Infinity, 50); - ctx.drawImage(red, 0, 0, Infinity, Infinity, 0, Infinity, Infinity, Infinity); - ctx.drawImage(red, 0, 0, Infinity, Infinity, 0, Infinity, 100, Infinity); - ctx.drawImage(red, 0, 0, Infinity, Infinity, 0, 0, Infinity, 50); - ctx.drawImage(red, 0, 0, Infinity, Infinity, 0, 0, Infinity, Infinity); - ctx.drawImage(red, 0, 0, Infinity, Infinity, 0, 0, 100, Infinity); - ctx.drawImage(red, 0, 0, Infinity, 50, Infinity, 0, 100, 50); - ctx.drawImage(red, 0, 0, Infinity, 50, Infinity, Infinity, 100, 50); - ctx.drawImage(red, 0, 0, Infinity, 50, Infinity, Infinity, Infinity, 50); - ctx.drawImage(red, 0, 0, Infinity, 50, Infinity, Infinity, Infinity, Infinity); - ctx.drawImage(red, 0, 0, Infinity, 50, Infinity, Infinity, 100, Infinity); - ctx.drawImage(red, 0, 0, Infinity, 50, Infinity, 0, Infinity, 50); - ctx.drawImage(red, 0, 0, Infinity, 50, Infinity, 0, Infinity, Infinity); - ctx.drawImage(red, 0, 0, Infinity, 50, Infinity, 0, 100, Infinity); - ctx.drawImage(red, 0, 0, Infinity, 50, 0, Infinity, 100, 50); - ctx.drawImage(red, 0, 0, Infinity, 50, 0, Infinity, Infinity, 50); - ctx.drawImage(red, 0, 0, Infinity, 50, 0, Infinity, Infinity, Infinity); - ctx.drawImage(red, 0, 0, Infinity, 50, 0, Infinity, 100, Infinity); - ctx.drawImage(red, 0, 0, Infinity, 50, 0, 0, Infinity, 50); - ctx.drawImage(red, 0, 0, Infinity, 50, 0, 0, Infinity, Infinity); - ctx.drawImage(red, 0, 0, Infinity, 50, 0, 0, 100, Infinity); - ctx.drawImage(red, 0, 0, 100, Infinity, Infinity, 0, 100, 50); - ctx.drawImage(red, 0, 0, 100, Infinity, Infinity, Infinity, 100, 50); - ctx.drawImage(red, 0, 0, 100, Infinity, Infinity, Infinity, Infinity, 50); - ctx.drawImage(red, 0, 0, 100, Infinity, Infinity, Infinity, Infinity, Infinity); - ctx.drawImage(red, 0, 0, 100, Infinity, Infinity, Infinity, 100, Infinity); - ctx.drawImage(red, 0, 0, 100, Infinity, Infinity, 0, Infinity, 50); - ctx.drawImage(red, 0, 0, 100, Infinity, Infinity, 0, Infinity, Infinity); - ctx.drawImage(red, 0, 0, 100, Infinity, Infinity, 0, 100, Infinity); - ctx.drawImage(red, 0, 0, 100, Infinity, 0, Infinity, 100, 50); - ctx.drawImage(red, 0, 0, 100, Infinity, 0, Infinity, Infinity, 50); - ctx.drawImage(red, 0, 0, 100, Infinity, 0, Infinity, Infinity, Infinity); - ctx.drawImage(red, 0, 0, 100, Infinity, 0, Infinity, 100, Infinity); - ctx.drawImage(red, 0, 0, 100, Infinity, 0, 0, Infinity, 50); - ctx.drawImage(red, 0, 0, 100, Infinity, 0, 0, Infinity, Infinity); - ctx.drawImage(red, 0, 0, 100, Infinity, 0, 0, 100, Infinity); - ctx.drawImage(red, 0, 0, 100, 50, Infinity, Infinity, 100, 50); - ctx.drawImage(red, 0, 0, 100, 50, Infinity, Infinity, Infinity, 50); - ctx.drawImage(red, 0, 0, 100, 50, Infinity, Infinity, Infinity, Infinity); - ctx.drawImage(red, 0, 0, 100, 50, Infinity, Infinity, 100, Infinity); - ctx.drawImage(red, 0, 0, 100, 50, Infinity, 0, Infinity, 50); - ctx.drawImage(red, 0, 0, 100, 50, Infinity, 0, Infinity, Infinity); - ctx.drawImage(red, 0, 0, 100, 50, Infinity, 0, 100, Infinity); - ctx.drawImage(red, 0, 0, 100, 50, 0, Infinity, Infinity, 50); - ctx.drawImage(red, 0, 0, 100, 50, 0, Infinity, Infinity, Infinity); - ctx.drawImage(red, 0, 0, 100, 50, 0, Infinity, 100, Infinity); - ctx.drawImage(red, 0, 0, 100, 50, 0, 0, Infinity, Infinity); - verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); - - } - - function test_negative() { - var ctx = canvas.getContext('2d'); - ctx.reset(); - - ctx.fillStyle = '#f00'; - ctx.fillRect(0, 0, 100, 50); - ctx.drawImage('ggrr-256x256.png', 100, 78, 50, 50, 0, 50, 50, -50); - ctx.drawImage('ggrr-256x256.png', 100, 128, 50, -50, 100, 50, -50, -50); -// verify(Helper.comparePixel(ctx, 1,1, 0,255,0,255,2)); -// verify(Helper.comparePixel(ctx, 1,48, 0,255,0,255,2)); -// verify(Helper.comparePixel(ctx, 98,1, 0,255,0,255,2)); -// verify(Helper.comparePixel(ctx, 98,48, 0,255,0,255,2)); -// verify(Helper.comparePixel(ctx, 48,1, 0,255,0,255,2)); -// verify(Helper.comparePixel(ctx, 48,48, 0,255,0,255,2)); -// verify(Helper.comparePixel(ctx, 51,1, 0,255,0,255,2)); -// verify(Helper.comparePixel(ctx, 51,48, 0,255,0,255,2)); -// verify(Helper.comparePixel(ctx, 25,25, 0,255,0,255,2)); -// verify(Helper.comparePixel(ctx, 75,25, 0,255,0,255,2)); - - ctx.reset(); - ctx.fillStyle = '#f00'; - ctx.fillRect(0, 0, 100, 50); - ctx.drawImage('ggrr-256x256.png', 0, 178, 50, -100, 0, 0, 50, 100); - ctx.drawImage('ggrr-256x256.png', 0, 78, 50, 100, 50, 100, 50, -100); -// verify(Helper.comparePixel(ctx, 1,1, 0,255,0,255,2)); -// verify(Helper.comparePixel(ctx, 1,48, 0,255,0,255,2)); -// verify(Helper.comparePixel(ctx, 98,1, 0,255,0,255,2)); -// verify(Helper.comparePixel(ctx, 98,48, 0,255,0,255,2)); -// verify(Helper.comparePixel(ctx, 48,1, 0,255,0,255,2)); -// verify(Helper.comparePixel(ctx, 48,48, 0,255,0,255,2)); -// verify(Helper.comparePixel(ctx, 51,1, 0,255,0,255,2)); -// verify(Helper.comparePixel(ctx, 51,48, 0,255,0,255,2)); -// verify(Helper.comparePixel(ctx, 25,25, 0,255,0,255,2)); -// verify(Helper.comparePixel(ctx, 75,25, 0,255,0,255,2)); - - ctx.reset(); - ctx.fillStyle = '#f00'; - ctx.fillRect(0, 0, 100, 50); - ctx.drawImage('ggrr-256x256.png', 100, 78, -100, 50, 0, 0, 50, 50); - ctx.drawImage('ggrr-256x256.png', 100, 128, -100, -50, 50, 0, 50, 50); -// verify(Helper.comparePixel(ctx, 1,1, 0,255,0,255,2)); -// verify(Helper.comparePixel(ctx, 1,48, 0,255,0,255,2)); -// verify(Helper.comparePixel(ctx, 98,1, 0,255,0,255,2)); -// verify(Helper.comparePixel(ctx, 98,48, 0,255,0,255,2)); -// verify(Helper.comparePixel(ctx, 48,1, 0,255,0,255,2)); -// verify(Helper.comparePixel(ctx, 48,48, 0,255,0,255,2)); -// verify(Helper.comparePixel(ctx, 51,1, 0,255,0,255,2)); -// verify(Helper.comparePixel(ctx, 51,48, 0,255,0,255,2)); -// verify(Helper.comparePixel(ctx, 25,25, 0,255,0,255,2)); -// verify(Helper.comparePixel(ctx, 75,25, 0,255,0,255,2)); - - } - - function test_canvas() { - var ctx = canvas.getContext('2d'); - ctx.reset(); - var canvas2 = Qt.createQmlObject("import QtQuick 2.0; Canvas{renderTarget:Canvas.Image}", canvas); - canvas2.width = 100; - canvas2.height = 50; - var ctx2 = canvas2.getContext('2d'); - ctx2.fillStyle = '#0f0'; - ctx2.fillRect(0, 0, 100, 50); - - ctx.fillStyle = '#f00'; - ctx.drawImage(canvas2, 0, 0); - - //verify(Helper.comparePixel(ctx, 0,0, 0,255,0,255,2)); - //verify(Helper.comparePixel(ctx, 99,0, 0,255,0,255,2)); - //verify(Helper.comparePixel(ctx, 0,49, 0,255,0,255,2)); - //verify(Helper.comparePixel(ctx, 99,49, 0,255,0,255,2)); - - } - - function test_broken() { - var ctx = canvas.getContext('2d'); - ctx.reset(); - var img = 'broken.png'; - verify(!img.complete); - ctx.drawImage(img, 0, 0); - } - - function test_alpha() { - var ctx=canvas.getContext('2d'); - ctx.reset(); - ctx.fillStyle = '#0f0'; - ctx.fillRect(0, 0, 100, 50); - ctx.globalAlpha = 0; - ctx.drawImage('red.png', 0, 0); - verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255, 2)); - - } - } -} diff --git a/tests/auto/qtquick2/qquickcanvasitem/data/tst_fillStyle.qml b/tests/auto/qtquick2/qquickcanvasitem/data/tst_fillStyle.qml deleted file mode 100644 index 8f5a78cec0..0000000000 --- a/tests/auto/qtquick2/qquickcanvasitem/data/tst_fillStyle.qml +++ /dev/null @@ -1,113 +0,0 @@ -import QtQuick 2.0 -import QtTest 1.0 -import "testhelper.js" as Helper - -Canvas { - id:canvas; width:1;height:1;renderTarget:Canvas.Image - TestCase { - name: "fillStyle"; when: windowShown - function test_default() { - var ctx = canvas.getContext('2d'); - ctx.reset(); - verify(ctx.fillStyle, "#000000"); - ctx.clearRect(0, 0, 1, 1); - compare(ctx.fillStyle, "#000000"); - } - function test_get() { - var ctx = canvas.getContext('2d'); - ctx.reset(); - ctx.fillStyle = '#fa0'; - compare(ctx.fillStyle, '#ffaa00'); - ctx.fillStyle = Qt.rgba(0,0,0,0); - compare(ctx.fillStyle, 'rgba(0, 0, 0, 0.0)'); - } - function test_hex() { - var ctx = canvas.getContext('2d'); - ctx.reset(); - ctx.fillStyle = '#f00'; - compare(ctx.fillStyle, '#ff0000'); - ctx.fillStyle = "#0f0"; - compare(ctx.fillStyle, '#00ff00'); - ctx.fillStyle = "#0fF"; - compare(ctx.fillStyle, '#00ffff'); - ctx.fillStyle = "#0aCCfb"; - compare(ctx.fillStyle, '#0accfb'); - - } - function test_invalid() { - var ctx = canvas.getContext('2d'); - ctx.reset(); - ctx.fillStyle = '#fa0'; - compare(ctx.fillStyle, '#ffaa00'); - ctx.fillStyle = "invalid"; - compare(ctx.fillStyle, '#ffaa00'); - ctx.fillStyle = "rgb (1, 2, 3)"; - compare(ctx.fillStyle, '#ffaa00'); - ctx.fillStyle = '#fa0'; - - ctx.fillStyle = "rgba(3, 1, 2)"; - compare(ctx.fillStyle, '#ffaa00'); - ctx.fillStyle = "rgb((3,4,1)"; - compare(ctx.fillStyle, '#ffaa00'); - ctx.fillStyle = "rgb(1, 3, 4, 0.5)"; - compare(ctx.fillStyle, '#ffaa00'); - ctx.fillStyle = "hsl(2, 3, 4, 0.8)"; - compare(ctx.fillStyle, '#ffaa00'); - ctx.fillStyle = "hsl(2, 3, 4"; - compare(ctx.fillStyle, '#ffaa00'); - } - function test_saverestore() { - var ctx = canvas.getContext('2d'); - var old = ctx.fillStyle; - ctx.save(); - ctx.fillStyle = "#ffaaff"; - ctx.restore(); - compare(ctx.fillStyle, old); - - ctx.fillStyle = "#ffcc88"; - old = ctx.fillStyle; - ctx.save(); - compare(ctx.fillStyle, old); - ctx.restore(); - } - function test_namedColor() { - var ctx = canvas.getContext('2d'); - ctx.reset(); - ctx.fillStyle = "red"; - ctx.fillRect(0,0,1,1); - verify(Helper.comparePixel(ctx,0,0,255,0,0,255)); - - ctx.fillStyle = "black"; - ctx.fillRect(0,0,1,1); - verify(Helper.comparePixel(ctx,0,0,0,0,0,255)); - - ctx.fillStyle = "white"; - ctx.fillRect(0,0,1,1); - verify(Helper.comparePixel(ctx,0,0,255,255,255,255)); - } - function test_rgba() { - var ctx = canvas.getContext('2d'); - ctx.reset(); - ctx.fillStyle = "rgb(-100, 300, 255)"; - compare(ctx.fillStyle, "#00ffff"); - ctx.fillStyle = "rgba(-100, 300, 255, 0.0)"; - compare(ctx.fillStyle, "rgba(0, 255, 255, 0.0)"); - ctx.fillStyle = "rgb(-10%, 110%, 50%)"; - compare(ctx.fillStyle, "#00ff80"); - - ctx.clearRect(0, 0, 1, 1); - ctx.fillStyle = 'rgba(0%, 100%, 0%, 0.499)'; - ctx.fillRect(0, 0, 1, 1); - verify(Helper.comparePixel(ctx, 0,0, 0,255,0,127)); - } - - function test_hsla() { - var ctx = canvas.getContext('2d'); - ctx.reset(); - ctx.fillStyle = "hsla(120, 100%, 50%, 0.499)"; - ctx.fillRect(0, 0, 1, 1); - verify(Helper.comparePixel(ctx,0,0,0,255,0,127)); - } - - } -} diff --git a/tests/auto/qtquick2/qquickcanvasitem/data/tst_fillrect.qml b/tests/auto/qtquick2/qquickcanvasitem/data/tst_fillrect.qml deleted file mode 100644 index 08197816e9..0000000000 --- a/tests/auto/qtquick2/qquickcanvasitem/data/tst_fillrect.qml +++ /dev/null @@ -1,26 +0,0 @@ -import QtQuick 2.0 -import QtTest 1.0 - -Canvas { - id:canvas; width:1;height:1; - renderTarget:Canvas.Image - renderStrategy: Canvas.Immediate - - TestCase { - name: "FillRect"; when: canvas.available - - function test_fillRect() { - var ctx = canvas.getContext('2d'); - ctx.fillStyle = "red"; - ctx.fillRect(0, 0, canvas.width, canvas.height); - - var imageData = ctx.getImageData(0, 0, 1, 1); - var d = imageData.data; - verify(d.length == 4); - verify(d[0] == 255); - verify(d[1] == 0); - verify(d[2] == 0); - verify(d[3] == 255); - } - } -} diff --git a/tests/auto/qtquick2/qquickcanvasitem/data/tst_gradient.qml b/tests/auto/qtquick2/qquickcanvasitem/data/tst_gradient.qml deleted file mode 100644 index d454c2efe1..0000000000 --- a/tests/auto/qtquick2/qquickcanvasitem/data/tst_gradient.qml +++ /dev/null @@ -1,981 +0,0 @@ -import QtQuick 2.0 -import QtTest 1.0 -import "testhelper.js" as Helper -Canvas { - id:canvas; width:100;height:50; renderTarget: Canvas.Image - TestCase { - name: "gradient"; when: windowShown - function test_basic() { - var ctx = canvas.getContext('2d'); - ctx.reset(); - ctx.fillStyle = '#0f0'; - ctx.fillRect(0, 0, 100, 50); - var g = ctx.createLinearGradient(0, 0, 0, 50); - ctx.fillStyle = g; - ctx.fillRect(0, 0, 100, 50); - //verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255,2)); - - } - - function test_interpolate() { - var ctx = canvas.getContext('2d'); - ctx.reset(); - - ctx.fillStyle = '#ff0'; - ctx.fillRect(0, 0, 100, 50); - var g = ctx.createLinearGradient(0, 0, 100, 0); - g.addColorStop(0, 'rgba(0,0,255, 0)'); - g.addColorStop(1, 'rgba(0,0,255, 1)'); - ctx.fillStyle = g; - ctx.fillRect(0, 0, 100, 50); - //verify(Helper.comparePixel(ctx, 25,25, 191,191,63,255,3)); - //verify(Helper.comparePixel(ctx, 50,25, 127,127,127,255,3)); - //verify(Helper.comparePixel(ctx, 75,25, 63,63,191,255,3)); - - ctx.reset(); - var g = ctx.createLinearGradient(0, 0, 100, 0); - g.addColorStop(0, '#ff0'); - g.addColorStop(1, '#00f'); - ctx.fillStyle = g; - ctx.fillRect(0, 0, 100, 50); - //verify(Helper.comparePixel(ctx, 25,25, 191,191,63,255,3)); - //verify(Helper.comparePixel(ctx, 50,25, 127,127,127,255,3)); - //verify(Helper.comparePixel(ctx, 75,25, 63,63,191,255,3)); - - - ctx.reset(); - var g = ctx.createLinearGradient(0, 0, 100, 0); - g.addColorStop(0, 'rgba(255,255,0, 0)'); - g.addColorStop(1, 'rgba(0,0,255, 1)'); - ctx.fillStyle = g; - ctx.fillRect(0, 0, 100, 50); - //verify(Helper.comparePixel(ctx, 25,25, 191,191,63,63,3)); - //verify(Helper.comparePixel(ctx, 50,25, 127,127,127,127,3)); - //verify(Helper.comparePixel(ctx, 75,25, 63,63,191,191,3)); - - ctx.reset(); - canvas.width = 200; - var g = ctx.createLinearGradient(0, 0, 200, 0); - g.addColorStop(0, '#ff0'); - g.addColorStop(0.5, '#0ff'); - g.addColorStop(1, '#f0f'); - ctx.fillStyle = g; - ctx.fillRect(0, 0, 200, 50); - //verify(Helper.comparePixel(ctx, 50,25, 127,255,127,255,3)); - //verify(Helper.comparePixel(ctx, 100,25, 0,255,255,255,3)); - //verify(Helper.comparePixel(ctx, 150,25, 127,127,255,255,3)); - - ctx.reset(); - ctx.fillStyle = '#f00'; - ctx.fillRect(0, 0, 100, 50); - - var g = ctx.createLinearGradient(25, 0, 75, 0); - g.addColorStop(0.4, '#0f0'); - g.addColorStop(0.6, '#0f0'); - - ctx.fillStyle = g; - ctx.fillRect(0, 0, 100, 50); - //verify(Helper.comparePixel(ctx, 20,25, 0,255,0,255,2)); - //verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255,2)); - //verify(Helper.comparePixel(ctx, 80,25, 0,255,0,255,2)); - - - ctx.reset(); - ctx.canvas.width = 200; - var g = ctx.createLinearGradient(0, 0, 200, 0); - g.addColorStop(0, '#f00'); - g.addColorStop(0, '#ff0'); - g.addColorStop(0.25, '#00f'); - g.addColorStop(0.25, '#0f0'); - g.addColorStop(0.25, '#0f0'); - g.addColorStop(0.25, '#0f0'); - g.addColorStop(0.25, '#ff0'); - g.addColorStop(0.5, '#00f'); - g.addColorStop(0.5, '#0f0'); - g.addColorStop(0.75, '#00f'); - g.addColorStop(0.75, '#f00'); - g.addColorStop(0.75, '#ff0'); - g.addColorStop(0.5, '#0f0'); - g.addColorStop(0.5, '#0f0'); - g.addColorStop(0.5, '#ff0'); - g.addColorStop(1, '#00f'); - ctx.fillStyle = g; - ctx.fillRect(0, 0, 200, 50); - //verify(Helper.comparePixel(ctx, 49,25, 0,0,255,255,16)); - //verify(Helper.comparePixel(ctx, 51,25, 255,255,0,255,16)); - //verify(Helper.comparePixel(ctx, 99,25, 0,0,255,255,16)); - //verify(Helper.comparePixel(ctx, 101,25, 255,255,0,255,16)); - //verify(Helper.comparePixel(ctx, 149,25, 0,0,255,255,16)); - //verify(Helper.comparePixel(ctx, 151,25, 255,255,0,255,16)); - ctx.canvas.width = 100; - - ctx.reset(); - var g = ctx.createLinearGradient(0, 0, 100, 0); - var ps = [ 0, 1/10, 1/4, 1/3, 1/2, 3/4, 1 ]; - for (var p = 0; p < ps.length; ++p) - { - g.addColorStop(ps[p], '#0f0'); - for (var i = 0; i < 15; ++i) - g.addColorStop(ps[p], '#f00'); - g.addColorStop(ps[p], '#0f0'); - } - ctx.fillStyle = g; - ctx.fillRect(0, 0, 100, 50); - //verify(Helper.comparePixel(ctx, 1,25, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 30,25, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 40,25, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 60,25, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 80,25, 0,255,0,255)); - - - ctx.reset(); - var g = ctx.createLinearGradient(0, 0, 100, 0); - g.addColorStop(0, '#0f0'); - g.addColorStop(1, '#0f0'); - ctx.fillStyle = g; - ctx.fillRect(0, 0, 100, 50); - //verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); - - - - ctx.reset(); - var g = ctx.createLinearGradient(0, 0, 0, 50); - g.addColorStop(0, '#ff0'); - g.addColorStop(1, '#00f'); - ctx.fillStyle = g; - ctx.fillRect(0, 0, 100, 50); - //verify(Helper.comparePixel(ctx, 50,12, 191,191,63,255,10)); - //verify(Helper.comparePixel(ctx, 50,25, 127,127,127,255,5)); - //verify(Helper.comparePixel(ctx, 50,37, 63,63,191,255,10)); - - - ctx.reset(); - - ctx.fillStyle = '#0f0'; - ctx.fillRect(0, 0, 100, 50); - - var g = ctx.createLinearGradient(50, 25, 50, 25); // zero-length line (undefined direction) - g.addColorStop(0, '#f00'); - g.addColorStop(1, '#f00'); - ctx.fillStyle = g; - ctx.fillRect(0, 0, 100, 50); - //verify(Helper.comparePixel(ctx, 40,20, 0,255,0,255,2)); - - - - } - function test_radial() { - var ctx = canvas.getContext('2d'); - ctx.reset(); - ctx.fillStyle = '#0f0'; - ctx.fillRect(0, 0, 100, 50); - - var g = ctx.createRadialGradient(0, 100, 40, 100, 100, 50); - g.addColorStop(0, '#f00'); - g.addColorStop(1, '#f00'); - ctx.fillStyle = g; - ctx.fillRect(0, 0, 100, 50); - - //verify(Helper.comparePixel(ctx, 1,1, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 50,1, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 98,1, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 1,25, 0,255,0,255,16)); - //verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 98,25, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 1,48, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 50,48, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 98,48, 0,255,0,255)); - - ctx.reset(); - ctx.fillStyle = '#f00'; - ctx.fillRect(0, 0, 100, 50); - - g = ctx.createRadialGradient(210, 25, 100, 230, 25, 101); - g.addColorStop(0, '#0f0'); - g.addColorStop(1, '#f00'); - ctx.fillStyle = g; - ctx.fillRect(0, 0, 100, 50); - - //verify(Helper.comparePixel(ctx, 1,1, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 50,1, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 98,1, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 1,25, 0,255,0,255,16)); - //verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 98,25, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 1,48, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 50,48, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 98,48, 0,255,0,255)); - - - ctx.reset(); - ctx.fillStyle = '#f00'; - ctx.fillRect(0, 0, 100, 50); - - g = ctx.createRadialGradient(210, 25, 100, 230, 25, 100); - g.addColorStop(0, '#0f0'); - g.addColorStop(1, '#f00'); - ctx.fillStyle = g; - ctx.fillRect(0, 0, 100, 50); - - //verify(Helper.comparePixel(ctx, 1,1, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 50,1, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 98,1, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 1,25, 0,255,0,255,16)); - //verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 98,25, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 1,48, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 50,48, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 98,48, 0,255,0,255)); - - ctx.reset(); - ctx.fillStyle = '#f00'; - ctx.fillRect(0, 0, 100, 50); - - g = ctx.createRadialGradient(311, 25, 10, 210, 25, 100); - g.addColorStop(0, '#f00'); - g.addColorStop(1, '#0f0'); - ctx.fillStyle = g; - ctx.fillRect(0, 0, 100, 50); - - //verify(Helper.comparePixel(ctx, 1,1, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 50,1, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 98,1, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 1,25, 0,255,0,255,16)); - //verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 98,25, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 1,48, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 50,48, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 98,48, 0,255,0,255)); - - ctx.reset(); - var tol = 1; // tolerance to avoid antialiasing artifacts - - ctx.fillStyle = '#0f0'; - ctx.fillRect(0, 0, 100, 50); - - ctx.fillStyle = '#f00'; - ctx.beginPath(); - ctx.moveTo(30+tol, 40); - ctx.lineTo(110, -20+tol); - ctx.lineTo(110, 100-tol); - ctx.fill(); - - g = ctx.createRadialGradient(30+10*5/2, 40, 10*3/2, 30+10*15/4, 40, 10*9/4); - g.addColorStop(0, '#0f0'); - g.addColorStop(1, '#0f0'); - ctx.fillStyle = g; - ctx.fillRect(0, 0, 100, 50); - - //verify(Helper.comparePixel(ctx, 1,1, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 50,1, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 98,1, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 1,25, 0,255,0,255,16)); - //verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 98,25, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 1,48, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 50,48, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 98,48, 0,255,0,255)); - - ctx.reset(); - var tol = 1; // tolerance to avoid antialiasing artifacts - - ctx.fillStyle = '#0f0'; - ctx.fillRect(0, 0, 100, 50); - - g = ctx.createRadialGradient(30+10*5/2, 40, 10*3/2, 30+10*15/4, 40, 10*9/4); - g.addColorStop(0, '#f00'); - g.addColorStop(1, '#f00'); - ctx.fillStyle = g; - ctx.fillRect(0, 0, 100, 50); - - ctx.fillStyle = '#0f0'; - ctx.beginPath(); - ctx.moveTo(30-tol, 40); - ctx.lineTo(110, -20-tol); - ctx.lineTo(110, 100+tol); - ctx.fill(); - - //verify(Helper.comparePixel(ctx, 1,1, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 50,1, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 98,1, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 1,25, 0,255,0,255,16)); - //verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 98,25, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 1,48, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 50,48, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 98,48, 0,255,0,255)); - - ctx.reset(); - ctx.fillStyle = '#f00'; - ctx.fillRect(0, 0, 100, 50); - - g = ctx.createRadialGradient(230, 25, 100, 100, 25, 101); - g.addColorStop(0, '#f00'); - g.addColorStop(1, '#0f0'); - ctx.fillStyle = g; - ctx.fillRect(0, 0, 100, 50); - - //verify(Helper.comparePixel(ctx, 1,1, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 50,1, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 98,1, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 1,25, 0,255,0,255,16)); - //verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 98,25, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 1,48, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 50,48, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 98,48, 0,255,0,255)); - - ctx.reset(); - ctx.fillStyle = '#0f0'; - ctx.fillRect(0, 0, 100, 50); - - g = ctx.createRadialGradient(50, 25, 20, 50, 25, 20); - g.addColorStop(0, '#f00'); - g.addColorStop(1, '#f00'); - ctx.fillStyle = g; - ctx.fillRect(0, 0, 100, 50); - - //verify(Helper.comparePixel(ctx, 1,1, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 50,1, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 98,1, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 1,25, 0,255,0,255,16)); - //verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 98,25, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 1,48, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 50,48, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 98,48, 0,255,0,255)); - - ctx.reset(); - ctx.fillStyle = '#f00'; - ctx.fillRect(0, 0, 100, 50); - - g = ctx.createRadialGradient(50, 25, 100, 50, 25, 200); - g.addColorStop(0, '#0f0'); - g.addColorStop(1, '#f00'); - ctx.fillStyle = g; - ctx.fillRect(0, 0, 100, 50); - - //verify(Helper.comparePixel(ctx, 1,1, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 50,1, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 98,1, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 1,25, 0,255,0,255,16)); - //verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 98,25, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 1,48, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 50,48, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 98,48, 0,255,0,255)); - - ctx.reset(); - ctx.fillStyle = '#f00'; - ctx.fillRect(0, 0, 100, 50); - - g = ctx.createRadialGradient(50, 25, 200, 50, 25, 100); - g.addColorStop(0, '#f00'); - g.addColorStop(1, '#0f0'); - ctx.fillStyle = g; - ctx.fillRect(0, 0, 100, 50); - - //verify(Helper.comparePixel(ctx, 1,1, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 50,1, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 98,1, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 1,25, 0,255,0,255,16)); - //verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 98,25, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 1,48, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 50,48, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 98,48, 0,255,0,255)); - - ctx.reset(); - ctx.fillStyle = '#f00'; - ctx.fillRect(0, 0, 100, 50); - - g = ctx.createRadialGradient(50, 25, 200, 50, 25, 100); - g.addColorStop(0, '#f00'); - g.addColorStop(0.993, '#f00'); - g.addColorStop(1, '#0f0'); - ctx.fillStyle = g; - ctx.fillRect(0, 0, 100, 50); - - //verify(Helper.comparePixel(ctx, 1,1, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 50,1, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 98,1, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 1,25, 0,255,0,255,16)); - //verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 98,25, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 1,48, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 50,48, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 98,48, 0,255,0,255)); - - ctx.reset(); - try { var err = false; - ctx.createRadialGradient(0, 0, -0.1, 0, 0, 1); - } catch (e) { if (e.code != DOMException.INDEX_SIZE_ERR) fail("Failed assertion: expected exception of type INDEX_SIZE_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type INDEX_SIZE_ERR: ctx.createRadialGradient(0, 0, -0.1, 0, 0, 1)"); } - try { var err = false; - ctx.createRadialGradient(0, 0, 1, 0, 0, -0.1); - } catch (e) { if (e.code != DOMException.INDEX_SIZE_ERR) fail("Failed assertion: expected exception of type INDEX_SIZE_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type INDEX_SIZE_ERR: ctx.createRadialGradient(0, 0, 1, 0, 0, -0.1)"); } - try { var err = false; - ctx.createRadialGradient(0, 0, -0.1, 0, 0, -0.1); - } catch (e) { if (e.code != DOMException.INDEX_SIZE_ERR) fail("Failed assertion: expected exception of type INDEX_SIZE_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type INDEX_SIZE_ERR: ctx.createRadialGradient(0, 0, -0.1, 0, 0, -0.1)"); } - - - ctx.reset(); - - - try { var err = false; - ctx.createRadialGradient(Infinity, 0, 1, 0, 0, 1); - } catch (e) { if (e.code != DOMException.NOT_SUPPORTED_ERR) fail("Failed assertion: expected exception of type NOT_SUPPORTED_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type NOT_SUPPORTED_ERR: ctx.createRadialGradient(Infinity, 0, 1, 0, 0, 1)"); } - try { var err = false; - ctx.createRadialGradient(-Infinity, 0, 1, 0, 0, 1); - } catch (e) { if (e.code != DOMException.NOT_SUPPORTED_ERR) fail("Failed assertion: expected exception of type NOT_SUPPORTED_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type NOT_SUPPORTED_ERR: ctx.createRadialGradient(-Infinity, 0, 1, 0, 0, 1)"); } - try { var err = false; - ctx.createRadialGradient(NaN, 0, 1, 0, 0, 1); - } catch (e) { if (e.code != DOMException.NOT_SUPPORTED_ERR) fail("Failed assertion: expected exception of type NOT_SUPPORTED_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type NOT_SUPPORTED_ERR: ctx.createRadialGradient(NaN, 0, 1, 0, 0, 1)"); } - try { var err = false; - ctx.createRadialGradient(0, Infinity, 1, 0, 0, 1); - } catch (e) { if (e.code != DOMException.NOT_SUPPORTED_ERR) fail("Failed assertion: expected exception of type NOT_SUPPORTED_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type NOT_SUPPORTED_ERR: ctx.createRadialGradient(0, Infinity, 1, 0, 0, 1)"); } - try { var err = false; - ctx.createRadialGradient(0, -Infinity, 1, 0, 0, 1); - } catch (e) { if (e.code != DOMException.NOT_SUPPORTED_ERR) fail("Failed assertion: expected exception of type NOT_SUPPORTED_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type NOT_SUPPORTED_ERR: ctx.createRadialGradient(0, -Infinity, 1, 0, 0, 1)"); } - try { var err = false; - ctx.createRadialGradient(0, NaN, 1, 0, 0, 1); - } catch (e) { if (e.code != DOMException.NOT_SUPPORTED_ERR) fail("Failed assertion: expected exception of type NOT_SUPPORTED_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type NOT_SUPPORTED_ERR: ctx.createRadialGradient(0, NaN, 1, 0, 0, 1)"); } - try { var err = false; - ctx.createRadialGradient(0, 0, Infinity, 0, 0, 1); - } catch (e) { if (e.code != DOMException.NOT_SUPPORTED_ERR) fail("Failed assertion: expected exception of type NOT_SUPPORTED_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type NOT_SUPPORTED_ERR: ctx.createRadialGradient(0, 0, Infinity, 0, 0, 1)"); } - try { var err = false; - ctx.createRadialGradient(0, 0, -Infinity, 0, 0, 1); - } catch (e) { if (e.code != DOMException.NOT_SUPPORTED_ERR) fail("Failed assertion: expected exception of type NOT_SUPPORTED_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type NOT_SUPPORTED_ERR: ctx.createRadialGradient(0, 0, -Infinity, 0, 0, 1)"); } - try { var err = false; - ctx.createRadialGradient(0, 0, NaN, 0, 0, 1); - } catch (e) { if (e.code != DOMException.NOT_SUPPORTED_ERR) fail("Failed assertion: expected exception of type NOT_SUPPORTED_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type NOT_SUPPORTED_ERR: ctx.createRadialGradient(0, 0, NaN, 0, 0, 1)"); } - try { var err = false; - ctx.createRadialGradient(0, 0, 1, Infinity, 0, 1); - } catch (e) { if (e.code != DOMException.NOT_SUPPORTED_ERR) fail("Failed assertion: expected exception of type NOT_SUPPORTED_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type NOT_SUPPORTED_ERR: ctx.createRadialGradient(0, 0, 1, Infinity, 0, 1)"); } - try { var err = false; - ctx.createRadialGradient(0, 0, 1, -Infinity, 0, 1); - } catch (e) { if (e.code != DOMException.NOT_SUPPORTED_ERR) fail("Failed assertion: expected exception of type NOT_SUPPORTED_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type NOT_SUPPORTED_ERR: ctx.createRadialGradient(0, 0, 1, -Infinity, 0, 1)"); } - try { var err = false; - ctx.createRadialGradient(0, 0, 1, NaN, 0, 1); - } catch (e) { if (e.code != DOMException.NOT_SUPPORTED_ERR) fail("Failed assertion: expected exception of type NOT_SUPPORTED_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type NOT_SUPPORTED_ERR: ctx.createRadialGradient(0, 0, 1, NaN, 0, 1)"); } - try { var err = false; - ctx.createRadialGradient(0, 0, 1, 0, Infinity, 1); - } catch (e) { if (e.code != DOMException.NOT_SUPPORTED_ERR) fail("Failed assertion: expected exception of type NOT_SUPPORTED_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type NOT_SUPPORTED_ERR: ctx.createRadialGradient(0, 0, 1, 0, Infinity, 1)"); } - try { var err = false; - ctx.createRadialGradient(0, 0, 1, 0, -Infinity, 1); - } catch (e) { if (e.code != DOMException.NOT_SUPPORTED_ERR) fail("Failed assertion: expected exception of type NOT_SUPPORTED_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type NOT_SUPPORTED_ERR: ctx.createRadialGradient(0, 0, 1, 0, -Infinity, 1)"); } - try { var err = false; - ctx.createRadialGradient(0, 0, 1, 0, NaN, 1); - } catch (e) { if (e.code != DOMException.NOT_SUPPORTED_ERR) fail("Failed assertion: expected exception of type NOT_SUPPORTED_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type NOT_SUPPORTED_ERR: ctx.createRadialGradient(0, 0, 1, 0, NaN, 1)"); } - try { var err = false; - ctx.createRadialGradient(0, 0, 1, 0, 0, Infinity); - } catch (e) { if (e.code != DOMException.NOT_SUPPORTED_ERR) fail("Failed assertion: expected exception of type NOT_SUPPORTED_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type NOT_SUPPORTED_ERR: ctx.createRadialGradient(0, 0, 1, 0, 0, Infinity)"); } - try { var err = false; - ctx.createRadialGradient(0, 0, 1, 0, 0, -Infinity); - } catch (e) { if (e.code != DOMException.NOT_SUPPORTED_ERR) fail("Failed assertion: expected exception of type NOT_SUPPORTED_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type NOT_SUPPORTED_ERR: ctx.createRadialGradient(0, 0, 1, 0, 0, -Infinity)"); } - try { var err = false; - ctx.createRadialGradient(0, 0, 1, 0, 0, NaN); - } catch (e) { if (e.code != DOMException.NOT_SUPPORTED_ERR) fail("Failed assertion: expected exception of type NOT_SUPPORTED_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type NOT_SUPPORTED_ERR: ctx.createRadialGradient(0, 0, 1, 0, 0, NaN)"); } - try { var err = false; - ctx.createRadialGradient(Infinity, Infinity, 1, 0, 0, 1); - } catch (e) { if (e.code != DOMException.NOT_SUPPORTED_ERR) fail("Failed assertion: expected exception of type NOT_SUPPORTED_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type NOT_SUPPORTED_ERR: ctx.createRadialGradient(Infinity, Infinity, 1, 0, 0, 1)"); } - try { var err = false; - ctx.createRadialGradient(Infinity, Infinity, Infinity, 0, 0, 1); - } catch (e) { if (e.code != DOMException.NOT_SUPPORTED_ERR) fail("Failed assertion: expected exception of type NOT_SUPPORTED_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type NOT_SUPPORTED_ERR: ctx.createRadialGradient(Infinity, Infinity, Infinity, 0, 0, 1)"); } - try { var err = false; - ctx.createRadialGradient(Infinity, Infinity, Infinity, Infinity, 0, 1); - } catch (e) { if (e.code != DOMException.NOT_SUPPORTED_ERR) fail("Failed assertion: expected exception of type NOT_SUPPORTED_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type NOT_SUPPORTED_ERR: ctx.createRadialGradient(Infinity, Infinity, Infinity, Infinity, 0, 1)"); } - try { var err = false; - ctx.createRadialGradient(Infinity, Infinity, Infinity, Infinity, Infinity, 1); - } catch (e) { if (e.code != DOMException.NOT_SUPPORTED_ERR) fail("Failed assertion: expected exception of type NOT_SUPPORTED_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type NOT_SUPPORTED_ERR: ctx.createRadialGradient(Infinity, Infinity, Infinity, Infinity, Infinity, 1)"); } - try { var err = false; - ctx.createRadialGradient(Infinity, Infinity, Infinity, Infinity, Infinity, Infinity); - } catch (e) { if (e.code != DOMException.NOT_SUPPORTED_ERR) fail("Failed assertion: expected exception of type NOT_SUPPORTED_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type NOT_SUPPORTED_ERR: ctx.createRadialGradient(Infinity, Infinity, Infinity, Infinity, Infinity, Infinity)"); } - try { var err = false; - ctx.createRadialGradient(Infinity, Infinity, Infinity, Infinity, 0, Infinity); - } catch (e) { if (e.code != DOMException.NOT_SUPPORTED_ERR) fail("Failed assertion: expected exception of type NOT_SUPPORTED_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type NOT_SUPPORTED_ERR: ctx.createRadialGradient(Infinity, Infinity, Infinity, Infinity, 0, Infinity)"); } - try { var err = false; - ctx.createRadialGradient(Infinity, Infinity, Infinity, 0, Infinity, 1); - } catch (e) { if (e.code != DOMException.NOT_SUPPORTED_ERR) fail("Failed assertion: expected exception of type NOT_SUPPORTED_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type NOT_SUPPORTED_ERR: ctx.createRadialGradient(Infinity, Infinity, Infinity, 0, Infinity, 1)"); } - try { var err = false; - ctx.createRadialGradient(Infinity, Infinity, Infinity, 0, Infinity, Infinity); - } catch (e) { if (e.code != DOMException.NOT_SUPPORTED_ERR) fail("Failed assertion: expected exception of type NOT_SUPPORTED_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type NOT_SUPPORTED_ERR: ctx.createRadialGradient(Infinity, Infinity, Infinity, 0, Infinity, Infinity)"); } - try { var err = false; - ctx.createRadialGradient(Infinity, Infinity, Infinity, 0, 0, Infinity); - } catch (e) { if (e.code != DOMException.NOT_SUPPORTED_ERR) fail("Failed assertion: expected exception of type NOT_SUPPORTED_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type NOT_SUPPORTED_ERR: ctx.createRadialGradient(Infinity, Infinity, Infinity, 0, 0, Infinity)"); } - try { var err = false; - ctx.createRadialGradient(Infinity, Infinity, 1, Infinity, 0, 1); - } catch (e) { if (e.code != DOMException.NOT_SUPPORTED_ERR) fail("Failed assertion: expected exception of type NOT_SUPPORTED_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type NOT_SUPPORTED_ERR: ctx.createRadialGradient(Infinity, Infinity, 1, Infinity, 0, 1)"); } - try { var err = false; - ctx.createRadialGradient(Infinity, Infinity, 1, Infinity, Infinity, 1); - } catch (e) { if (e.code != DOMException.NOT_SUPPORTED_ERR) fail("Failed assertion: expected exception of type NOT_SUPPORTED_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type NOT_SUPPORTED_ERR: ctx.createRadialGradient(Infinity, Infinity, 1, Infinity, Infinity, 1)"); } - try { var err = false; - ctx.createRadialGradient(Infinity, Infinity, 1, Infinity, Infinity, Infinity); - } catch (e) { if (e.code != DOMException.NOT_SUPPORTED_ERR) fail("Failed assertion: expected exception of type NOT_SUPPORTED_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type NOT_SUPPORTED_ERR: ctx.createRadialGradient(Infinity, Infinity, 1, Infinity, Infinity, Infinity)"); } - try { var err = false; - ctx.createRadialGradient(Infinity, Infinity, 1, Infinity, 0, Infinity); - } catch (e) { if (e.code != DOMException.NOT_SUPPORTED_ERR) fail("Failed assertion: expected exception of type NOT_SUPPORTED_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type NOT_SUPPORTED_ERR: ctx.createRadialGradient(Infinity, Infinity, 1, Infinity, 0, Infinity)"); } - try { var err = false; - ctx.createRadialGradient(Infinity, Infinity, 1, 0, Infinity, 1); - } catch (e) { if (e.code != DOMException.NOT_SUPPORTED_ERR) fail("Failed assertion: expected exception of type NOT_SUPPORTED_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type NOT_SUPPORTED_ERR: ctx.createRadialGradient(Infinity, Infinity, 1, 0, Infinity, 1)"); } - try { var err = false; - ctx.createRadialGradient(Infinity, Infinity, 1, 0, Infinity, Infinity); - } catch (e) { if (e.code != DOMException.NOT_SUPPORTED_ERR) fail("Failed assertion: expected exception of type NOT_SUPPORTED_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type NOT_SUPPORTED_ERR: ctx.createRadialGradient(Infinity, Infinity, 1, 0, Infinity, Infinity)"); } - try { var err = false; - ctx.createRadialGradient(Infinity, Infinity, 1, 0, 0, Infinity); - } catch (e) { if (e.code != DOMException.NOT_SUPPORTED_ERR) fail("Failed assertion: expected exception of type NOT_SUPPORTED_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type NOT_SUPPORTED_ERR: ctx.createRadialGradient(Infinity, Infinity, 1, 0, 0, Infinity)"); } - try { var err = false; - ctx.createRadialGradient(Infinity, 0, Infinity, 0, 0, 1); - } catch (e) { if (e.code != DOMException.NOT_SUPPORTED_ERR) fail("Failed assertion: expected exception of type NOT_SUPPORTED_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type NOT_SUPPORTED_ERR: ctx.createRadialGradient(Infinity, 0, Infinity, 0, 0, 1)"); } - try { var err = false; - ctx.createRadialGradient(Infinity, 0, Infinity, Infinity, 0, 1); - } catch (e) { if (e.code != DOMException.NOT_SUPPORTED_ERR) fail("Failed assertion: expected exception of type NOT_SUPPORTED_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type NOT_SUPPORTED_ERR: ctx.createRadialGradient(Infinity, 0, Infinity, Infinity, 0, 1)"); } - try { var err = false; - ctx.createRadialGradient(Infinity, 0, Infinity, Infinity, Infinity, 1); - } catch (e) { if (e.code != DOMException.NOT_SUPPORTED_ERR) fail("Failed assertion: expected exception of type NOT_SUPPORTED_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type NOT_SUPPORTED_ERR: ctx.createRadialGradient(Infinity, 0, Infinity, Infinity, Infinity, 1)"); } - try { var err = false; - ctx.createRadialGradient(Infinity, 0, Infinity, Infinity, Infinity, Infinity); - } catch (e) { if (e.code != DOMException.NOT_SUPPORTED_ERR) fail("Failed assertion: expected exception of type NOT_SUPPORTED_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type NOT_SUPPORTED_ERR: ctx.createRadialGradient(Infinity, 0, Infinity, Infinity, Infinity, Infinity)"); } - try { var err = false; - ctx.createRadialGradient(Infinity, 0, Infinity, Infinity, 0, Infinity); - } catch (e) { if (e.code != DOMException.NOT_SUPPORTED_ERR) fail("Failed assertion: expected exception of type NOT_SUPPORTED_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type NOT_SUPPORTED_ERR: ctx.createRadialGradient(Infinity, 0, Infinity, Infinity, 0, Infinity)"); } - try { var err = false; - ctx.createRadialGradient(Infinity, 0, Infinity, 0, Infinity, 1); - } catch (e) { if (e.code != DOMException.NOT_SUPPORTED_ERR) fail("Failed assertion: expected exception of type NOT_SUPPORTED_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type NOT_SUPPORTED_ERR: ctx.createRadialGradient(Infinity, 0, Infinity, 0, Infinity, 1)"); } - try { var err = false; - ctx.createRadialGradient(Infinity, 0, Infinity, 0, Infinity, Infinity); - } catch (e) { if (e.code != DOMException.NOT_SUPPORTED_ERR) fail("Failed assertion: expected exception of type NOT_SUPPORTED_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type NOT_SUPPORTED_ERR: ctx.createRadialGradient(Infinity, 0, Infinity, 0, Infinity, Infinity)"); } - try { var err = false; - ctx.createRadialGradient(Infinity, 0, Infinity, 0, 0, Infinity); - } catch (e) { if (e.code != DOMException.NOT_SUPPORTED_ERR) fail("Failed assertion: expected exception of type NOT_SUPPORTED_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type NOT_SUPPORTED_ERR: ctx.createRadialGradient(Infinity, 0, Infinity, 0, 0, Infinity)"); } - try { var err = false; - ctx.createRadialGradient(Infinity, 0, 1, Infinity, 0, 1); - } catch (e) { if (e.code != DOMException.NOT_SUPPORTED_ERR) fail("Failed assertion: expected exception of type NOT_SUPPORTED_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type NOT_SUPPORTED_ERR: ctx.createRadialGradient(Infinity, 0, 1, Infinity, 0, 1)"); } - try { var err = false; - ctx.createRadialGradient(Infinity, 0, 1, Infinity, Infinity, 1); - } catch (e) { if (e.code != DOMException.NOT_SUPPORTED_ERR) fail("Failed assertion: expected exception of type NOT_SUPPORTED_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type NOT_SUPPORTED_ERR: ctx.createRadialGradient(Infinity, 0, 1, Infinity, Infinity, 1)"); } - try { var err = false; - ctx.createRadialGradient(Infinity, 0, 1, Infinity, Infinity, Infinity); - } catch (e) { if (e.code != DOMException.NOT_SUPPORTED_ERR) fail("Failed assertion: expected exception of type NOT_SUPPORTED_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type NOT_SUPPORTED_ERR: ctx.createRadialGradient(Infinity, 0, 1, Infinity, Infinity, Infinity)"); } - try { var err = false; - ctx.createRadialGradient(Infinity, 0, 1, Infinity, 0, Infinity); - } catch (e) { if (e.code != DOMException.NOT_SUPPORTED_ERR) fail("Failed assertion: expected exception of type NOT_SUPPORTED_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type NOT_SUPPORTED_ERR: ctx.createRadialGradient(Infinity, 0, 1, Infinity, 0, Infinity)"); } - try { var err = false; - ctx.createRadialGradient(Infinity, 0, 1, 0, Infinity, 1); - } catch (e) { if (e.code != DOMException.NOT_SUPPORTED_ERR) fail("Failed assertion: expected exception of type NOT_SUPPORTED_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type NOT_SUPPORTED_ERR: ctx.createRadialGradient(Infinity, 0, 1, 0, Infinity, 1)"); } - try { var err = false; - ctx.createRadialGradient(Infinity, 0, 1, 0, Infinity, Infinity); - } catch (e) { if (e.code != DOMException.NOT_SUPPORTED_ERR) fail("Failed assertion: expected exception of type NOT_SUPPORTED_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type NOT_SUPPORTED_ERR: ctx.createRadialGradient(Infinity, 0, 1, 0, Infinity, Infinity)"); } - try { var err = false; - ctx.createRadialGradient(Infinity, 0, 1, 0, 0, Infinity); - } catch (e) { if (e.code != DOMException.NOT_SUPPORTED_ERR) fail("Failed assertion: expected exception of type NOT_SUPPORTED_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type NOT_SUPPORTED_ERR: ctx.createRadialGradient(Infinity, 0, 1, 0, 0, Infinity)"); } - try { var err = false; - ctx.createRadialGradient(0, Infinity, Infinity, 0, 0, 1); - } catch (e) { if (e.code != DOMException.NOT_SUPPORTED_ERR) fail("Failed assertion: expected exception of type NOT_SUPPORTED_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type NOT_SUPPORTED_ERR: ctx.createRadialGradient(0, Infinity, Infinity, 0, 0, 1)"); } - try { var err = false; - ctx.createRadialGradient(0, Infinity, Infinity, Infinity, 0, 1); - } catch (e) { if (e.code != DOMException.NOT_SUPPORTED_ERR) fail("Failed assertion: expected exception of type NOT_SUPPORTED_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type NOT_SUPPORTED_ERR: ctx.createRadialGradient(0, Infinity, Infinity, Infinity, 0, 1)"); } - try { var err = false; - ctx.createRadialGradient(0, Infinity, Infinity, Infinity, Infinity, 1); - } catch (e) { if (e.code != DOMException.NOT_SUPPORTED_ERR) fail("Failed assertion: expected exception of type NOT_SUPPORTED_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type NOT_SUPPORTED_ERR: ctx.createRadialGradient(0, Infinity, Infinity, Infinity, Infinity, 1)"); } - try { var err = false; - ctx.createRadialGradient(0, Infinity, Infinity, Infinity, Infinity, Infinity); - } catch (e) { if (e.code != DOMException.NOT_SUPPORTED_ERR) fail("Failed assertion: expected exception of type NOT_SUPPORTED_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type NOT_SUPPORTED_ERR: ctx.createRadialGradient(0, Infinity, Infinity, Infinity, Infinity, Infinity)"); } - try { var err = false; - ctx.createRadialGradient(0, Infinity, Infinity, Infinity, 0, Infinity); - } catch (e) { if (e.code != DOMException.NOT_SUPPORTED_ERR) fail("Failed assertion: expected exception of type NOT_SUPPORTED_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type NOT_SUPPORTED_ERR: ctx.createRadialGradient(0, Infinity, Infinity, Infinity, 0, Infinity)"); } - try { var err = false; - ctx.createRadialGradient(0, Infinity, Infinity, 0, Infinity, 1); - } catch (e) { if (e.code != DOMException.NOT_SUPPORTED_ERR) fail("Failed assertion: expected exception of type NOT_SUPPORTED_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type NOT_SUPPORTED_ERR: ctx.createRadialGradient(0, Infinity, Infinity, 0, Infinity, 1)"); } - try { var err = false; - ctx.createRadialGradient(0, Infinity, Infinity, 0, Infinity, Infinity); - } catch (e) { if (e.code != DOMException.NOT_SUPPORTED_ERR) fail("Failed assertion: expected exception of type NOT_SUPPORTED_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type NOT_SUPPORTED_ERR: ctx.createRadialGradient(0, Infinity, Infinity, 0, Infinity, Infinity)"); } - try { var err = false; - ctx.createRadialGradient(0, Infinity, Infinity, 0, 0, Infinity); - } catch (e) { if (e.code != DOMException.NOT_SUPPORTED_ERR) fail("Failed assertion: expected exception of type NOT_SUPPORTED_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type NOT_SUPPORTED_ERR: ctx.createRadialGradient(0, Infinity, Infinity, 0, 0, Infinity)"); } - try { var err = false; - ctx.createRadialGradient(0, Infinity, 1, Infinity, 0, 1); - } catch (e) { if (e.code != DOMException.NOT_SUPPORTED_ERR) fail("Failed assertion: expected exception of type NOT_SUPPORTED_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type NOT_SUPPORTED_ERR: ctx.createRadialGradient(0, Infinity, 1, Infinity, 0, 1)"); } - try { var err = false; - ctx.createRadialGradient(0, Infinity, 1, Infinity, Infinity, 1); - } catch (e) { if (e.code != DOMException.NOT_SUPPORTED_ERR) fail("Failed assertion: expected exception of type NOT_SUPPORTED_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type NOT_SUPPORTED_ERR: ctx.createRadialGradient(0, Infinity, 1, Infinity, Infinity, 1)"); } - try { var err = false; - ctx.createRadialGradient(0, Infinity, 1, Infinity, Infinity, Infinity); - } catch (e) { if (e.code != DOMException.NOT_SUPPORTED_ERR) fail("Failed assertion: expected exception of type NOT_SUPPORTED_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type NOT_SUPPORTED_ERR: ctx.createRadialGradient(0, Infinity, 1, Infinity, Infinity, Infinity)"); } - try { var err = false; - ctx.createRadialGradient(0, Infinity, 1, Infinity, 0, Infinity); - } catch (e) { if (e.code != DOMException.NOT_SUPPORTED_ERR) fail("Failed assertion: expected exception of type NOT_SUPPORTED_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type NOT_SUPPORTED_ERR: ctx.createRadialGradient(0, Infinity, 1, Infinity, 0, Infinity)"); } - try { var err = false; - ctx.createRadialGradient(0, Infinity, 1, 0, Infinity, 1); - } catch (e) { if (e.code != DOMException.NOT_SUPPORTED_ERR) fail("Failed assertion: expected exception of type NOT_SUPPORTED_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type NOT_SUPPORTED_ERR: ctx.createRadialGradient(0, Infinity, 1, 0, Infinity, 1)"); } - try { var err = false; - ctx.createRadialGradient(0, Infinity, 1, 0, Infinity, Infinity); - } catch (e) { if (e.code != DOMException.NOT_SUPPORTED_ERR) fail("Failed assertion: expected exception of type NOT_SUPPORTED_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type NOT_SUPPORTED_ERR: ctx.createRadialGradient(0, Infinity, 1, 0, Infinity, Infinity)"); } - try { var err = false; - ctx.createRadialGradient(0, Infinity, 1, 0, 0, Infinity); - } catch (e) { if (e.code != DOMException.NOT_SUPPORTED_ERR) fail("Failed assertion: expected exception of type NOT_SUPPORTED_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type NOT_SUPPORTED_ERR: ctx.createRadialGradient(0, Infinity, 1, 0, 0, Infinity)"); } - try { var err = false; - ctx.createRadialGradient(0, 0, Infinity, Infinity, 0, 1); - } catch (e) { if (e.code != DOMException.NOT_SUPPORTED_ERR) fail("Failed assertion: expected exception of type NOT_SUPPORTED_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type NOT_SUPPORTED_ERR: ctx.createRadialGradient(0, 0, Infinity, Infinity, 0, 1)"); } - try { var err = false; - ctx.createRadialGradient(0, 0, Infinity, Infinity, Infinity, 1); - } catch (e) { if (e.code != DOMException.NOT_SUPPORTED_ERR) fail("Failed assertion: expected exception of type NOT_SUPPORTED_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type NOT_SUPPORTED_ERR: ctx.createRadialGradient(0, 0, Infinity, Infinity, Infinity, 1)"); } - try { var err = false; - ctx.createRadialGradient(0, 0, Infinity, Infinity, Infinity, Infinity); - } catch (e) { if (e.code != DOMException.NOT_SUPPORTED_ERR) fail("Failed assertion: expected exception of type NOT_SUPPORTED_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type NOT_SUPPORTED_ERR: ctx.createRadialGradient(0, 0, Infinity, Infinity, Infinity, Infinity)"); } - try { var err = false; - ctx.createRadialGradient(0, 0, Infinity, Infinity, 0, Infinity); - } catch (e) { if (e.code != DOMException.NOT_SUPPORTED_ERR) fail("Failed assertion: expected exception of type NOT_SUPPORTED_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type NOT_SUPPORTED_ERR: ctx.createRadialGradient(0, 0, Infinity, Infinity, 0, Infinity)"); } - try { var err = false; - ctx.createRadialGradient(0, 0, Infinity, 0, Infinity, 1); - } catch (e) { if (e.code != DOMException.NOT_SUPPORTED_ERR) fail("Failed assertion: expected exception of type NOT_SUPPORTED_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type NOT_SUPPORTED_ERR: ctx.createRadialGradient(0, 0, Infinity, 0, Infinity, 1)"); } - try { var err = false; - ctx.createRadialGradient(0, 0, Infinity, 0, Infinity, Infinity); - } catch (e) { if (e.code != DOMException.NOT_SUPPORTED_ERR) fail("Failed assertion: expected exception of type NOT_SUPPORTED_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type NOT_SUPPORTED_ERR: ctx.createRadialGradient(0, 0, Infinity, 0, Infinity, Infinity)"); } - try { var err = false; - ctx.createRadialGradient(0, 0, Infinity, 0, 0, Infinity); - } catch (e) { if (e.code != DOMException.NOT_SUPPORTED_ERR) fail("Failed assertion: expected exception of type NOT_SUPPORTED_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type NOT_SUPPORTED_ERR: ctx.createRadialGradient(0, 0, Infinity, 0, 0, Infinity)"); } - try { var err = false; - ctx.createRadialGradient(0, 0, 1, Infinity, Infinity, 1); - } catch (e) { if (e.code != DOMException.NOT_SUPPORTED_ERR) fail("Failed assertion: expected exception of type NOT_SUPPORTED_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type NOT_SUPPORTED_ERR: ctx.createRadialGradient(0, 0, 1, Infinity, Infinity, 1)"); } - try { var err = false; - ctx.createRadialGradient(0, 0, 1, Infinity, Infinity, Infinity); - } catch (e) { if (e.code != DOMException.NOT_SUPPORTED_ERR) fail("Failed assertion: expected exception of type NOT_SUPPORTED_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type NOT_SUPPORTED_ERR: ctx.createRadialGradient(0, 0, 1, Infinity, Infinity, Infinity)"); } - try { var err = false; - ctx.createRadialGradient(0, 0, 1, Infinity, 0, Infinity); - } catch (e) { if (e.code != DOMException.NOT_SUPPORTED_ERR) fail("Failed assertion: expected exception of type NOT_SUPPORTED_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type NOT_SUPPORTED_ERR: ctx.createRadialGradient(0, 0, 1, Infinity, 0, Infinity)"); } - try { var err = false; - ctx.createRadialGradient(0, 0, 1, 0, Infinity, Infinity); - } catch (e) { if (e.code != DOMException.NOT_SUPPORTED_ERR) fail("Failed assertion: expected exception of type NOT_SUPPORTED_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type NOT_SUPPORTED_ERR: ctx.createRadialGradient(0, 0, 1, 0, Infinity, Infinity)"); } - - - ctx.reset(); - ctx.fillStyle = '#f00'; - ctx.fillRect(0, 0, 100, 50); - g = ctx.createRadialGradient(200, 25, 10, 200, 25, 20); - g.addColorStop(0, '#f00'); - g.addColorStop(1, '#0f0'); - ctx.fillStyle = g;ctx.fillRect(0, 0, 100, 50); - - //verify(Helper.comparePixel(ctx, 1,1, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 50,1, 0,255,0,255));//verify(Helper.comparePixel(ctx, 98,1, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 1,25, 0,255,0,255,16)); - //verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 98,25, 0,255,0,255));//verify(Helper.comparePixel(ctx, 1,48, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 50,48, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 98,48, 0,255,0,255)); - - ctx.reset(); - ctx.fillStyle = '#f00'; - ctx.fillRect(0, 0, 100, 50); - g = ctx.createRadialGradient(200, 25, 20, 200, 25, 10); - g.addColorStop(0, '#0f0'); - g.addColorStop(1, '#f00'); - ctx.fillStyle = g;ctx.fillRect(0, 0, 100, 50); - - //verify(Helper.comparePixel(ctx, 1,1, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 50,1, 0,255,0,255));//verify(Helper.comparePixel(ctx, 98,1, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 1,25, 0,255,0,255,16)); - //verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 98,25, 0,255,0,255));//verify(Helper.comparePixel(ctx, 1,48, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 50,48, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 98,48, 0,255,0,255)); - - ctx.reset(); - ctx.fillStyle = '#f00'; - ctx.fillRect(0, 0, 100, 50); - g = ctx.createRadialGradient(200, 25, 20, 200, 25, 10); - g.addColorStop(0, '#0f0'); - g.addColorStop(0.001, '#f00'); - g.addColorStop(1, '#f00');ctx.fillStyle = g; - ctx.fillRect(0, 0, 100, 50); - - //verify(Helper.comparePixel(ctx, 1,1, 0,255,0,255));//verify(Helper.comparePixel(ctx, 50,1, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 98,1, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 1,25, 0,255,0,255,16)); - //verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255));//verify(Helper.comparePixel(ctx, 98,25, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 1,48, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 50,48, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 98,48, 0,255,0,255)); - - ctx.reset(); - ctx.fillStyle = '#0f0'; - ctx.fillRect(0, 0, 100, 50); - g = ctx.createRadialGradient(150, 25, 50, 200, 25, 100); - g.addColorStop(0, '#f00'); - g.addColorStop(1, '#f00'); - ctx.fillStyle = g;ctx.fillRect(0, 0, 100, 50); - - //verify(Helper.comparePixel(ctx, 1,1, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 50,1, 0,255,0,255));//verify(Helper.comparePixel(ctx, 98,1, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 1,25, 0,255,0,255,16)); - //verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 98,25, 0,255,0,255));//verify(Helper.comparePixel(ctx, 1,48, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 50,48, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 98,48, 0,255,0,255)); - - ctx.reset(); - - ctx.fillStyle = '#f00'; - ctx.fillRect(0, 0, 100, 50); - g = ctx.createRadialGradient(-80, 25, 70, 0, 25, 150); - g.addColorStop(0, '#f00'); - g.addColorStop(0.01, '#0f0'); - g.addColorStop(0.99, '#0f0');g.addColorStop(1, '#f00'); - ctx.fillStyle = g; - ctx.fillRect(0, 0, 100, 50); - //verify(Helper.comparePixel(ctx, 1,1, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 50,1, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 98,1, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 1,25, 0,255,0,255,16));//verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 98,25, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 1,48, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 50,48, 0,255,0,255));//verify(Helper.comparePixel(ctx, 98,48, 0,255,0,255)); - - ctx.reset(); - ctx.fillStyle = '#0f0'; - ctx.fillRect(0, 0, 100, 50); - g = ctx.createRadialGradient(120, -15, 25, 140, -30, 50); - g.addColorStop(0, '#f00'); - g.addColorStop(1, '#f00'); - ctx.fillStyle = g;ctx.fillRect(0, 0, 100, 50); - - //verify(Helper.comparePixel(ctx, 1,1, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 50,1, 0,255,0,255));//verify(Helper.comparePixel(ctx, 98,1, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 1,25, 0,255,0,255,16)); - //verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 98,25, 0,255,0,255));//verify(Helper.comparePixel(ctx, 1,48, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 50,48, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 98,48, 0,255,0,255)); - - ctx.reset(); - g = ctx.createRadialGradient(0, 0, 0, 0, 0, 11.2); - g.addColorStop(0, '#0f0'); - g.addColorStop(0.5, '#0f0');g.addColorStop(0.51, '#f00'); - g.addColorStop(1, '#f00'); - ctx.fillStyle = g; - ctx.translate(50, 25);ctx.scale(10, 10); - ctx.fillRect(-5, -2.5, 10, 5); - //verify(Helper.comparePixel(ctx, 25,25, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255));//verify(Helper.comparePixel(ctx, 75,25, 0,255,0,255)); - - ctx.reset(); - ctx.translate(100, 0); - g = ctx.createRadialGradient(0, 0, 0, 0, 0, 11.2); - g.addColorStop(0, '#0f0');g.addColorStop(0.5, '#0f0'); - g.addColorStop(0.51, '#f00'); - g.addColorStop(1, '#f00'); - ctx.fillStyle = g;ctx.translate(-50, 25); - ctx.scale(10, 10); - ctx.fillRect(-5, -2.5, 10, 5); - //verify(Helper.comparePixel(ctx, 25,25, 0,255,0,255));//verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 75,25, 0,255,0,255)); - - - ctx.reset(); - g = ctx.createRadialGradient(0, 0, 0, 0, 0, 11.2); - g.addColorStop(0, '#0f0'); - g.addColorStop(0.5, '#0f0');g.addColorStop(0.51, '#f00'); - g.addColorStop(1, '#f00'); - ctx.fillStyle = g; - ctx.fillRect(0, 0, 100, 50);ctx.translate(50, 25); - ctx.scale(10, 10); - ctx.fillRect(-5, -2.5, 10, 5); - //verify(Helper.comparePixel(ctx, 25,25, 0,255,0,255));//verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 75,25, 0,255,0,255)); - - - } - function test_linear() { - var ctx = canvas.getContext('2d'); - ctx.reset(); - try { var err = false; - ctx.createLinearGradient(Infinity, 0, 1, 0); - } catch (e) { if (e.code != DOMException.NOT_SUPPORTED_ERR) fail("Failed assertion: expected exception of type NOT_SUPPORTED_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type NOT_SUPPORTED_ERR: ctx.createLinearGradient(Infinity, 0, 1, 0)"); } - try { var err = false; - ctx.createLinearGradient(-Infinity, 0, 1, 0); - } catch (e) { if (e.code != DOMException.NOT_SUPPORTED_ERR) fail("Failed assertion: expected exception of type NOT_SUPPORTED_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type NOT_SUPPORTED_ERR: ctx.createLinearGradient(-Infinity, 0, 1, 0)"); } - try { var err = false; - ctx.createLinearGradient(NaN, 0, 1, 0); - } catch (e) { if (e.code != DOMException.NOT_SUPPORTED_ERR) fail("Failed assertion: expected exception of type NOT_SUPPORTED_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type NOT_SUPPORTED_ERR: ctx.createLinearGradient(NaN, 0, 1, 0)"); } - try { var err = false; - ctx.createLinearGradient(0, Infinity, 1, 0); - } catch (e) { if (e.code != DOMException.NOT_SUPPORTED_ERR) fail("Failed assertion: expected exception of type NOT_SUPPORTED_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type NOT_SUPPORTED_ERR: ctx.createLinearGradient(0, Infinity, 1, 0)"); } - try { var err = false; - ctx.createLinearGradient(0, -Infinity, 1, 0); - } catch (e) { if (e.code != DOMException.NOT_SUPPORTED_ERR) fail("Failed assertion: expected exception of type NOT_SUPPORTED_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type NOT_SUPPORTED_ERR: ctx.createLinearGradient(0, -Infinity, 1, 0)"); } - try { var err = false; - ctx.createLinearGradient(0, NaN, 1, 0); - } catch (e) { if (e.code != DOMException.NOT_SUPPORTED_ERR) fail("Failed assertion: expected exception of type NOT_SUPPORTED_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type NOT_SUPPORTED_ERR: ctx.createLinearGradient(0, NaN, 1, 0)"); } - try { var err = false; - ctx.createLinearGradient(0, 0, Infinity, 0); - } catch (e) { if (e.code != DOMException.NOT_SUPPORTED_ERR) fail("Failed assertion: expected exception of type NOT_SUPPORTED_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type NOT_SUPPORTED_ERR: ctx.createLinearGradient(0, 0, Infinity, 0)"); } - try { var err = false; - ctx.createLinearGradient(0, 0, -Infinity, 0); - } catch (e) { if (e.code != DOMException.NOT_SUPPORTED_ERR) fail("Failed assertion: expected exception of type NOT_SUPPORTED_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type NOT_SUPPORTED_ERR: ctx.createLinearGradient(0, 0, -Infinity, 0)"); } - try { var err = false; - ctx.createLinearGradient(0, 0, NaN, 0); - } catch (e) { if (e.code != DOMException.NOT_SUPPORTED_ERR) fail("Failed assertion: expected exception of type NOT_SUPPORTED_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type NOT_SUPPORTED_ERR: ctx.createLinearGradient(0, 0, NaN, 0)"); } - try { var err = false; - ctx.createLinearGradient(0, 0, 1, Infinity); - } catch (e) { if (e.code != DOMException.NOT_SUPPORTED_ERR) fail("Failed assertion: expected exception of type NOT_SUPPORTED_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type NOT_SUPPORTED_ERR: ctx.createLinearGradient(0, 0, 1, Infinity)"); } - try { var err = false; - ctx.createLinearGradient(0, 0, 1, -Infinity); - } catch (e) { if (e.code != DOMException.NOT_SUPPORTED_ERR) fail("Failed assertion: expected exception of type NOT_SUPPORTED_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type NOT_SUPPORTED_ERR: ctx.createLinearGradient(0, 0, 1, -Infinity)"); } - try { var err = false; - ctx.createLinearGradient(0, 0, 1, NaN); - } catch (e) { if (e.code != DOMException.NOT_SUPPORTED_ERR) fail("Failed assertion: expected exception of type NOT_SUPPORTED_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type NOT_SUPPORTED_ERR: ctx.createLinearGradient(0, 0, 1, NaN)"); } - try { var err = false; - ctx.createLinearGradient(Infinity, Infinity, 1, 0); - } catch (e) { if (e.code != DOMException.NOT_SUPPORTED_ERR) fail("Failed assertion: expected exception of type NOT_SUPPORTED_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type NOT_SUPPORTED_ERR: ctx.createLinearGradient(Infinity, Infinity, 1, 0)"); } - try { var err = false; - ctx.createLinearGradient(Infinity, Infinity, Infinity, 0); - } catch (e) { if (e.code != DOMException.NOT_SUPPORTED_ERR) fail("Failed assertion: expected exception of type NOT_SUPPORTED_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type NOT_SUPPORTED_ERR: ctx.createLinearGradient(Infinity, Infinity, Infinity, 0)"); } - try { var err = false; - ctx.createLinearGradient(Infinity, Infinity, Infinity, Infinity); - } catch (e) { if (e.code != DOMException.NOT_SUPPORTED_ERR) fail("Failed assertion: expected exception of type NOT_SUPPORTED_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type NOT_SUPPORTED_ERR: ctx.createLinearGradient(Infinity, Infinity, Infinity, Infinity)"); } - try { var err = false; - ctx.createLinearGradient(Infinity, Infinity, 1, Infinity); - } catch (e) { if (e.code != DOMException.NOT_SUPPORTED_ERR) fail("Failed assertion: expected exception of type NOT_SUPPORTED_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type NOT_SUPPORTED_ERR: ctx.createLinearGradient(Infinity, Infinity, 1, Infinity)"); } - try { var err = false; - ctx.createLinearGradient(Infinity, 0, Infinity, 0); - } catch (e) { if (e.code != DOMException.NOT_SUPPORTED_ERR) fail("Failed assertion: expected exception of type NOT_SUPPORTED_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type NOT_SUPPORTED_ERR: ctx.createLinearGradient(Infinity, 0, Infinity, 0)"); } - try { var err = false; - ctx.createLinearGradient(Infinity, 0, Infinity, Infinity); - } catch (e) { if (e.code != DOMException.NOT_SUPPORTED_ERR) fail("Failed assertion: expected exception of type NOT_SUPPORTED_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type NOT_SUPPORTED_ERR: ctx.createLinearGradient(Infinity, 0, Infinity, Infinity)"); } - try { var err = false; - ctx.createLinearGradient(Infinity, 0, 1, Infinity); - } catch (e) { if (e.code != DOMException.NOT_SUPPORTED_ERR) fail("Failed assertion: expected exception of type NOT_SUPPORTED_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type NOT_SUPPORTED_ERR: ctx.createLinearGradient(Infinity, 0, 1, Infinity)"); } - try { var err = false; - ctx.createLinearGradient(0, Infinity, Infinity, 0); - } catch (e) { if (e.code != DOMException.NOT_SUPPORTED_ERR) fail("Failed assertion: expected exception of type NOT_SUPPORTED_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type NOT_SUPPORTED_ERR: ctx.createLinearGradient(0, Infinity, Infinity, 0)"); } - try { var err = false; - ctx.createLinearGradient(0, Infinity, Infinity, Infinity); - } catch (e) { if (e.code != DOMException.NOT_SUPPORTED_ERR) fail("Failed assertion: expected exception of type NOT_SUPPORTED_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type NOT_SUPPORTED_ERR: ctx.createLinearGradient(0, Infinity, Infinity, Infinity)"); } - try { var err = false; - ctx.createLinearGradient(0, Infinity, 1, Infinity); - } catch (e) { if (e.code != DOMException.NOT_SUPPORTED_ERR) fail("Failed assertion: expected exception of type NOT_SUPPORTED_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type NOT_SUPPORTED_ERR: ctx.createLinearGradient(0, Infinity, 1, Infinity)"); } - try { var err = false; - ctx.createLinearGradient(0, 0, Infinity, Infinity); - } catch (e) { if (e.code != DOMException.NOT_SUPPORTED_ERR) fail("Failed assertion: expected exception of type NOT_SUPPORTED_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type NOT_SUPPORTED_ERR: ctx.createLinearGradient(0, 0, Infinity, Infinity)"); } - - ctx.reset(); - var g = ctx.createLinearGradient(0, 0, 200, 0); - g.addColorStop(0, '#f00'); - g.addColorStop(0.25, '#0f0'); - g.addColorStop(0.75, '#0f0'); - g.addColorStop(1, '#f00'); - ctx.fillStyle = g; - ctx.translate(-50, 0); - ctx.fillRect(50, 0, 100, 50); - verify(Helper.comparePixel(ctx, 25,25, 0,255,0,255)); - verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); - verify(Helper.comparePixel(ctx, 75,25, 0,255,0,255)); - - ctx.reset(); - ctx.translate(100, 0); - g = ctx.createLinearGradient(0, 0, 200, 0); - g.addColorStop(0, '#f00'); - g.addColorStop(0.25, '#0f0'); - g.addColorStop(0.75, '#0f0'); - g.addColorStop(1, '#f00'); - ctx.fillStyle = g; - ctx.translate(-150, 0); - ctx.fillRect(50, 0, 100, 50); - verify(Helper.comparePixel(ctx, 25,25, 0,255,0,255)); - verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); - verify(Helper.comparePixel(ctx, 75,25, 0,255,0,255)); - - - ctx.reset(); - g = ctx.createLinearGradient(0, 0, 200, 0); - g.addColorStop(0, '#f00'); - g.addColorStop(0.25, '#0f0'); - g.addColorStop(0.75, '#0f0'); - g.addColorStop(1, '#f00'); - ctx.fillStyle = g; - ctx.fillRect(0, 0, 100, 50); - ctx.translate(-50, 0); - ctx.fillRect(50, 0, 100, 50); - verify(Helper.comparePixel(ctx, 25,25, 0,255,0,255)); - verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); - verify(Helper.comparePixel(ctx, 75,25, 0,255,0,255)); - - } - function test_object() { - var ctx = canvas.getContext('2d'); - ctx.reset(); - var g1 = ctx.createLinearGradient(0, 0, 100, 0); - var g2 = ctx.createLinearGradient(0, 0, 100, 0); - ctx.fillStyle = g1; - - - ctx.reset(); - var g = ctx.createLinearGradient(0, 0, 100, 0); - try { var err = false; - g.addColorStop(0, ""); - } catch (e) { if (e.code != DOMException.SYNTAX_ERR) fail("Failed assertion: expected exception of type SYNTAX_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type SYNTAX_ERR: g.addColorStop(0, \"\")"); } - try { var err = false; - g.addColorStop(0, 'undefined'); - } catch (e) { if (e.code != DOMException.SYNTAX_ERR) fail("Failed assertion: expected exception of type SYNTAX_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type SYNTAX_ERR: g.addColorStop(0, 'undefined')"); } - - - ctx.reset(); - g = ctx.createLinearGradient(0, 0, 100, 0); - try { var err = false; - g.addColorStop(-1, '#000'); - } catch (e) { if (e.code != DOMException.INDEX_SIZE_ERR) fail("Failed assertion: expected exception of type INDEX_SIZE_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type INDEX_SIZE_ERR: g.addColorStop(-1, '#000')"); } - try { var err = false; - g.addColorStop(2, '#000'); - } catch (e) { if (e.code != DOMException.INDEX_SIZE_ERR) fail("Failed assertion: expected exception of type INDEX_SIZE_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type INDEX_SIZE_ERR: g.addColorStop(2, '#000')"); } - try { var err = false; - g.addColorStop(Infinity, '#000'); - } catch (e) { if (e.code != DOMException.INDEX_SIZE_ERR) fail("Failed assertion: expected exception of type INDEX_SIZE_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type INDEX_SIZE_ERR: g.addColorStop(Infinity, '#000')"); } - try { var err = false; - g.addColorStop(-Infinity, '#000'); - } catch (e) { if (e.code != DOMException.INDEX_SIZE_ERR) fail("Failed assertion: expected exception of type INDEX_SIZE_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type INDEX_SIZE_ERR: g.addColorStop(-Infinity, '#000')"); } - try { var err = false; - g.addColorStop(NaN, '#000'); - } catch (e) { if (e.code != DOMException.INDEX_SIZE_ERR) fail("Failed assertion: expected exception of type INDEX_SIZE_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type INDEX_SIZE_ERR: g.addColorStop(NaN, '#000')"); } - - - ctx.reset(); - g = ctx.createLinearGradient(-100, 0, 200, 0); - g.addColorStop(0, '#f00'); - g.addColorStop(1, '#f00'); - ctx.fillStyle = g; - g.addColorStop(0.1, '#0f0'); - g.addColorStop(0.9, '#0f0'); - ctx.fillRect(0, 0, 100, 50); - //verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255,2)); - - ctx.reset(); - ctx.fillStyle = '#0f0'; - ctx.fillRect(0, 0, 100, 50); - - g = ctx.createRadialGradient(120, 25, 10, 211, 25, 100); - g.addColorStop(0, '#f00'); - g.addColorStop(1, '#f00'); - ctx.fillStyle = g; - ctx.fillRect(0, 0, 100, 50); - - //verify(Helper.comparePixel(ctx, 1,1, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 50,1, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 98,1, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 1,25, 0,255,0,255,16)); - //verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 98,25, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 1,48, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 50,48, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 98,48, 0,255,0,255)); - - - } - - function test_conical() { - var ctx = canvas.getContext('2d'); - ctx.reset(); - var g = ctx.createConicalGradient(10, 10, 50); - //TODO - } - } -} diff --git a/tests/auto/qtquick2/qquickcanvasitem/data/tst_line.qml b/tests/auto/qtquick2/qquickcanvasitem/data/tst_line.qml deleted file mode 100644 index baf9987ce3..0000000000 --- a/tests/auto/qtquick2/qquickcanvasitem/data/tst_line.qml +++ /dev/null @@ -1,831 +0,0 @@ -import QtQuick 2.0 -import QtTest 1.0 -import"testhelper.js" as Helper -Canvas { - id:canvas; width:100;height:50;renderTarget: Canvas.Image - TestCase { - name: "line"; when: windowShown - function test_default() { - var ctx = canvas.getContext('2d'); - ctx.reset(); - compare(ctx.lineWidth, 1); - compare(ctx.lineCap, 'butt'); - compare(ctx.lineJoin, 'miter'); - compare(ctx.miterLimit, 10); - } - - function test_cross() { - var ctx = canvas.getContext('2d'); - ctx.reset(); - ctx.fillStyle = '#0f0'; - ctx.fillRect(0, 0, 100, 50); - - ctx.lineWidth = 200; - ctx.lineJoin = 'bevel'; - - ctx.strokeStyle = '#f00'; - ctx.beginPath(); - ctx.moveTo(110, 50); - ctx.lineTo(110, 60); - ctx.lineTo(100, 60); - ctx.stroke(); - - verify(Helper.comparePixel(ctx, 1,1, 0,255,0,255)); - verify(Helper.comparePixel(ctx, 48,1, 0,255,0,255)); - verify(Helper.comparePixel(ctx, 48,48, 0,255,0,255)); - verify(Helper.comparePixel(ctx, 1,48, 0,255,0,255)); - - } - - function test_join() { - var ctx = canvas.getContext('2d'); - ctx.reset(); - - ctx.fillStyle = '#0f0'; - ctx.fillRect(0, 0, 100, 50); - - var tol = 1; // tolerance to avoid antialiasing artifacts - - ctx.lineJoin = 'bevel'; - ctx.lineWidth = 20; - - ctx.fillStyle = '#f00'; - ctx.strokeStyle = '#0f0'; - - ctx.fillRect(10, 10, 20, 20); - ctx.fillRect(20, 20, 20, 20); - ctx.beginPath(); - ctx.moveTo(30, 20); - ctx.lineTo(40-tol, 20); - ctx.lineTo(30, 10+tol); - ctx.fill(); - - ctx.beginPath(); - ctx.moveTo(10, 20); - ctx.lineTo(30, 20); - ctx.lineTo(30, 40); - ctx.stroke(); - - - ctx.fillStyle = '#0f0'; - ctx.strokeStyle = '#f00'; - - ctx.beginPath(); - ctx.moveTo(60, 20); - ctx.lineTo(80, 20); - ctx.lineTo(80, 40); - ctx.stroke(); - - ctx.fillRect(60, 10, 20, 20); - ctx.fillRect(70, 20, 20, 20); - ctx.beginPath(); - ctx.moveTo(80, 20); - ctx.lineTo(90+tol, 20); - ctx.lineTo(80, 10-tol); - ctx.fill(); - - verify(Helper.comparePixel(ctx, 34,16, 0,255,0,255)); - verify(Helper.comparePixel(ctx, 34,15, 0,255,0,255)); - verify(Helper.comparePixel(ctx, 35,15, 0,255,0,255)); - verify(Helper.comparePixel(ctx, 36,15, 0,255,0,255)); - verify(Helper.comparePixel(ctx, 36,14, 0,255,0,255)); - - verify(Helper.comparePixel(ctx, 84,16, 0,255,0,255)); - verify(Helper.comparePixel(ctx, 84,15, 0,255,0,255)); - verify(Helper.comparePixel(ctx, 85,15, 0,255,0,255)); - verify(Helper.comparePixel(ctx, 86,15, 0,255,0,255)); - verify(Helper.comparePixel(ctx, 86,14, 0,255,0,255)); - - - ctx.reset(); - ctx.fillStyle = '#f00'; - ctx.strokeStyle = '#0f0'; - ctx.fillRect(0, 0, 100, 50); - - ctx.lineJoin = 'miter'; - ctx.lineWidth = 200; - - ctx.beginPath(); - ctx.moveTo(100, 50); - ctx.lineTo(100, 1000); - ctx.lineTo(1000, 1000); - ctx.lineTo(1000, 50); - ctx.closePath(); - ctx.stroke(); - - verify(Helper.comparePixel(ctx, 1,1, 0,255,0,255)); - verify(Helper.comparePixel(ctx, 48,1, 0,255,0,255)); - verify(Helper.comparePixel(ctx, 48,48, 0,255,0,255)); - verify(Helper.comparePixel(ctx, 1,48, 0,255,0,255)); - - - ctx.reset(); - ctx.lineJoin = 'bevel' - compare(ctx.lineJoin, 'bevel'); - - ctx.lineJoin = 'bevel'; - ctx.lineJoin = 'invalid'; - compare(ctx.lineJoin, 'bevel'); - - ctx.lineJoin = 'bevel'; - ctx.lineJoin = 'ROUND'; - compare(ctx.lineJoin, 'bevel'); - - ctx.lineJoin = 'bevel'; - ctx.lineJoin = 'round\\0'; - compare(ctx.lineJoin, 'bevel'); - - ctx.lineJoin = 'bevel'; - ctx.lineJoin = 'round '; - compare(ctx.lineJoin, 'bevel'); - - ctx.lineJoin = 'bevel'; - ctx.lineJoin = ""; - compare(ctx.lineJoin, 'bevel'); - - ctx.lineJoin = 'bevel'; - ctx.lineJoin = 'butt'; - compare(ctx.lineJoin, 'bevel'); - - ctx.reset(); - ctx.fillStyle = '#0f0'; - ctx.fillRect(0, 0, 100, 50); - - ctx.lineJoin = 'miter'; - ctx.lineWidth = 20; - - ctx.fillStyle = '#f00'; - ctx.strokeStyle = '#0f0'; - - ctx.fillStyle = '#f00'; - ctx.strokeStyle = '#0f0'; - - ctx.fillRect(10, 10, 30, 20); - ctx.fillRect(20, 10, 20, 30); - - ctx.beginPath(); - ctx.moveTo(10, 20); - ctx.lineTo(30, 20); - ctx.lineTo(30, 40); - ctx.stroke(); - - - ctx.fillStyle = '#0f0'; - ctx.strokeStyle = '#f00'; - - ctx.beginPath(); - ctx.moveTo(60, 20); - ctx.lineTo(80, 20); - ctx.lineTo(80, 40); - ctx.stroke(); - - ctx.fillRect(60, 10, 30, 20); - ctx.fillRect(70, 10, 20, 30); - - verify(Helper.comparePixel(ctx, 38,12, 0,255,0,255)); - verify(Helper.comparePixel(ctx, 39,11, 0,255,0,255)); - verify(Helper.comparePixel(ctx, 40,10, 0,255,0,255)); - verify(Helper.comparePixel(ctx, 41,9, 0,255,0,255)); - verify(Helper.comparePixel(ctx, 42,8, 0,255,0,255)); - - verify(Helper.comparePixel(ctx, 88,12, 0,255,0,255)); - verify(Helper.comparePixel(ctx, 89,11, 0,255,0,255)); - verify(Helper.comparePixel(ctx, 90,10, 0,255,0,255)); - verify(Helper.comparePixel(ctx, 91,9, 0,255,0,255)); - verify(Helper.comparePixel(ctx, 92,8, 0,255,0,255)); - - ctx.reset(); - ctx.fillStyle = '#0f0'; - ctx.strokeStyle = '#f00'; - ctx.fillRect(0, 0, 100, 50); - - ctx.lineJoin = 'miter'; - ctx.lineWidth = 200; - - ctx.beginPath(); - ctx.moveTo(100, 50); - ctx.lineTo(100, 1000); - ctx.lineTo(1000, 1000); - ctx.lineTo(1000, 50); - ctx.lineTo(100, 50); - ctx.stroke(); - - //verify(Helper.comparePixel(ctx, 1,1, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 48,1, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 48,48, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 1,48, 0,255,0,255)); - - ctx.reset(); - ctx.fillStyle = '#f00'; - ctx.fillRect(0, 0, 100, 50); - - ctx.strokeStyle = '#0f0'; - ctx.lineWidth = 300; - ctx.lineJoin = 'round'; - ctx.beginPath(); - ctx.moveTo(-100, 25); - ctx.lineTo(0, 25); - ctx.lineTo(-100, 25); - ctx.stroke(); - - verify(Helper.comparePixel(ctx, 1,1, 0,255,0,255)); - verify(Helper.comparePixel(ctx, 48,1, 0,255,0,255)); - verify(Helper.comparePixel(ctx, 48,48, 0,255,0,255)); - verify(Helper.comparePixel(ctx, 1,48, 0,255,0,255)); - - ctx.reset(); - - ctx.fillStyle = '#0f0'; - ctx.fillRect(0, 0, 100, 50); - - var tol = 1; // tolerance to avoid antialiasing artifacts - - ctx.lineJoin = 'round'; - ctx.lineWidth = 20; - - ctx.fillStyle = '#f00'; - ctx.strokeStyle = '#0f0'; - - ctx.fillRect(10, 10, 20, 20); - ctx.fillRect(20, 20, 20, 20); - ctx.beginPath(); - ctx.moveTo(30, 20); - ctx.arc(30, 20, 10-tol, 0, 2*Math.PI, true); - ctx.fill(); - - ctx.beginPath(); - ctx.moveTo(10, 20); - ctx.lineTo(30, 20); - ctx.lineTo(30, 40); - ctx.stroke(); - - - ctx.fillStyle = '#0f0'; - ctx.strokeStyle = '#f00'; - - ctx.beginPath(); - ctx.moveTo(60, 20); - ctx.lineTo(80, 20); - ctx.lineTo(80, 40); - ctx.stroke(); - - ctx.fillRect(60, 10, 20, 20); - ctx.fillRect(70, 20, 20, 20); - ctx.beginPath(); - ctx.moveTo(80, 20); - ctx.arc(80, 20, 10+tol, 0, 2*Math.PI, true); - ctx.fill(); - - verify(Helper.comparePixel(ctx, 36,14, 0,255,0,255)); - verify(Helper.comparePixel(ctx, 36,13, 0,255,0,255)); - verify(Helper.comparePixel(ctx, 37,13, 0,255,0,255)); - verify(Helper.comparePixel(ctx, 38,13, 0,255,0,255)); - verify(Helper.comparePixel(ctx, 38,12, 0,255,0,255)); - - verify(Helper.comparePixel(ctx, 86,14, 0,255,0,255)); - verify(Helper.comparePixel(ctx, 86,13, 0,255,0,255)); - verify(Helper.comparePixel(ctx, 87,13, 0,255,0,255)); - verify(Helper.comparePixel(ctx, 88,13, 0,255,0,255)); - verify(Helper.comparePixel(ctx, 88,12, 0,255,0,255)); - - ctx.reset(); - ctx.lineJoin = 'bevel' - compare(ctx.lineJoin, 'bevel'); - - ctx.lineJoin = 'round'; - compare(ctx.lineJoin, 'round'); - - ctx.lineJoin = 'miter'; - compare(ctx.lineJoin, 'miter'); - - } - function test_miter() { - var ctx = canvas.getContext('2d'); - ctx.reset(); - ctx.fillStyle = '#f00'; - ctx.fillRect(0, 0, 100, 50); - - ctx.lineWidth = 200; - ctx.lineJoin = 'miter'; - - ctx.strokeStyle = '#0f0'; - ctx.miterLimit = 2.614; - ctx.beginPath(); - ctx.moveTo(100, 1000); - ctx.lineTo(100, 100); - ctx.lineTo(1000, 1000); - ctx.stroke(); - - ctx.strokeStyle = '#f00'; - ctx.miterLimit = 2.613; - ctx.beginPath(); - ctx.moveTo(100, 1000); - ctx.lineTo(100, 100); - ctx.lineTo(1000, 1000); - ctx.stroke(); - - //verify(Helper.comparePixel(ctx, 1,1, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 48,1, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 48,48, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 1,48, 0,255,0,255)); - - ctx.reset(); - ctx.fillStyle = '#0f0'; - ctx.fillRect(0, 0, 100, 50); - - ctx.lineWidth = 400; - ctx.lineJoin = 'miter'; - - ctx.strokeStyle = '#f00'; - ctx.miterLimit = 1.414; - ctx.beginPath(); - ctx.moveTo(200, 1000); - ctx.lineTo(200, 200); - ctx.lineTo(1000, 201); // slightly non-right-angle to avoid being a special case - ctx.stroke(); - - //verify(Helper.comparePixel(ctx, 1,1, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 48,1, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 48,48, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 1,48, 0,255,0,255)); - - ctx.reset(); - ctx.miterLimit = 1.5; - compare(ctx.miterLimit, 1.5); - - ctx.miterLimit = 1.5; - ctx.miterLimit = 0; - compare(ctx.miterLimit, 1.5); - - ctx.miterLimit = 1.5; - ctx.miterLimit = -1; - compare(ctx.miterLimit, 1.5); - - ctx.miterLimit = 1.5; - ctx.miterLimit = Infinity; - compare(ctx.miterLimit, 1.5); - - ctx.miterLimit = 1.5; - ctx.miterLimit = -Infinity; - compare(ctx.miterLimit, 1.5); - - ctx.miterLimit = 1.5; - ctx.miterLimit = NaN; - compare(ctx.miterLimit, 1.5); - - ctx.reset(); - ctx.fillStyle = '#0f0'; - ctx.fillRect(0, 0, 100, 50); - - ctx.lineWidth = 200; - ctx.lineJoin = 'miter'; - - ctx.strokeStyle = '#f00'; - ctx.miterLimit = 1.414; - ctx.beginPath(); - ctx.strokeRect(100, 25, 200, 0); - - //verify(Helper.comparePixel(ctx, 1,1, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 48,1, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 48,48, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 1,48, 0,255,0,255)); - - ctx.reset(); - ctx.fillStyle = '#f00'; - ctx.fillRect(0, 0, 100, 50); - - ctx.lineWidth = 1600; - ctx.lineJoin = 'miter'; - - ctx.strokeStyle = '#0f0'; - ctx.miterLimit = 1.083; - ctx.beginPath(); - ctx.moveTo(800, 10000); - ctx.lineTo(800, 300); - ctx.lineTo(10000, -8900); - ctx.stroke(); - - ctx.strokeStyle = '#f00'; - ctx.miterLimit = 1.082; - ctx.beginPath(); - ctx.moveTo(800, 10000); - ctx.lineTo(800, 300); - ctx.lineTo(10000, -8900); - ctx.stroke(); - - //verify(Helper.comparePixel(ctx, 1,1, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 48,1, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 48,48, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 1,48, 0,255,0,255)); - - ctx.reset(); - ctx.fillStyle = '#0f0'; - ctx.fillRect(0, 0, 100, 50); - - ctx.lineWidth = 400; - ctx.lineJoin = 'miter'; - - ctx.strokeStyle = '#f00'; - ctx.miterLimit = 1.414; - ctx.beginPath(); - ctx.moveTo(200, 1000); - ctx.lineTo(200, 200); - ctx.lineTo(1000, 200); - ctx.stroke(); - - //verify(Helper.comparePixel(ctx, 1,1, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 48,1, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 48,48, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 1,48, 0,255,0,255)); - - ctx.reset(); - ctx.miterLimit = 1.5; - compare(ctx.miterLimit, 1.5); - - ctx.miterLimit = "1e1"; - compare(ctx.miterLimit, 10); - - ctx.miterLimit = 1/1024; - compare(ctx.miterLimit, 1/1024); - - ctx.miterLimit = 1000; - compare(ctx.miterLimit, 1000); - - ctx.reset(); - ctx.fillStyle = '#f00'; - ctx.fillRect(0, 0, 100, 50); - - ctx.lineWidth = 400; - ctx.lineJoin = 'miter'; - - ctx.strokeStyle = '#0f0'; - ctx.miterLimit = 1.416; - ctx.beginPath(); - ctx.moveTo(200, 1000); - ctx.lineTo(200, 200); - ctx.lineTo(1000, 201); - ctx.stroke(); - - verify(Helper.comparePixel(ctx, 1,1, 0,255,0,255)); - verify(Helper.comparePixel(ctx, 48,1, 0,255,0,255)); - verify(Helper.comparePixel(ctx, 48,48, 0,255,0,255)); - verify(Helper.comparePixel(ctx, 1,48, 0,255,0,255)); - - - } - function test_width() { - var ctx = canvas.getContext('2d'); - ctx.reset(); - ctx.fillStyle = '#0f0'; - ctx.fillRect(0, 0, 100, 50); - - ctx.lineWidth = 20; - // Draw a green line over a red box, to check the line is not too small - ctx.fillStyle = '#f00'; - ctx.strokeStyle = '#0f0'; - ctx.fillRect(15, 15, 20, 20); - ctx.beginPath(); - ctx.moveTo(25, 15); - ctx.lineTo(25, 35); - ctx.stroke(); - - // Draw a green box over a red line, to check the line is not too large - ctx.fillStyle = '#0f0'; - ctx.strokeStyle = '#f00'; - ctx.beginPath(); - ctx.moveTo(75, 15); - ctx.lineTo(75, 35); - ctx.stroke(); - ctx.fillRect(65, 15, 20, 20); - - verify(Helper.comparePixel(ctx, 14,25, 0,255,0,255)); - verify(Helper.comparePixel(ctx, 15,25, 0,255,0,255)); - verify(Helper.comparePixel(ctx, 16,25, 0,255,0,255)); - verify(Helper.comparePixel(ctx, 25,25, 0,255,0,255)); - verify(Helper.comparePixel(ctx, 34,25, 0,255,0,255)); - verify(Helper.comparePixel(ctx, 35,25, 0,255,0,255)); - verify(Helper.comparePixel(ctx, 36,25, 0,255,0,255)); - - verify(Helper.comparePixel(ctx, 64,25, 0,255,0,255)); - verify(Helper.comparePixel(ctx, 65,25, 0,255,0,255)); - verify(Helper.comparePixel(ctx, 66,25, 0,255,0,255)); - verify(Helper.comparePixel(ctx, 75,25, 0,255,0,255)); - verify(Helper.comparePixel(ctx, 84,25, 0,255,0,255)); - verify(Helper.comparePixel(ctx, 85,25, 0,255,0,255)); - verify(Helper.comparePixel(ctx, 86,25, 0,255,0,255)); - - ctx.reset(); - ctx.lineWidth = 1.5; - compare(ctx.lineWidth, 1.5); - - ctx.lineWidth = 1.5; - ctx.lineWidth = 0; - compare(ctx.lineWidth, 1.5); - - ctx.lineWidth = 1.5; - ctx.lineWidth = -1; - compare(ctx.lineWidth, 1.5); - - ctx.lineWidth = 1.5; - ctx.lineWidth = Infinity; - compare(ctx.lineWidth, 1.5); - - ctx.lineWidth = 1.5; - ctx.lineWidth = -Infinity; - compare(ctx.lineWidth, 1.5); - - ctx.lineWidth = 1.5; - ctx.lineWidth = NaN; - compare(ctx.lineWidth, 1.5); - - ctx.reset(); - ctx.fillStyle = '#f00'; - ctx.fillRect(0, 0, 100, 50); - - ctx.scale(50, 50); - ctx.strokeStyle = '#0f0'; - ctx.moveTo(0, 0.5); - ctx.lineTo(2, 0.5); - ctx.stroke(); - - //verify(Helper.comparePixel(ctx, 25,25, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 75,25, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 50,5, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 50,45, 0,255,0,255)); - - ctx.reset(); - ctx.fillStyle = '#0f0'; - ctx.fillRect(0, 0, 100, 50); - - ctx.lineWidth = 4; - // Draw a green line over a red box, to check the line is not too small - ctx.fillStyle = '#f00'; - ctx.strokeStyle = '#0f0'; - ctx.fillRect(15, 15, 20, 20); - ctx.save(); - ctx.scale(5, 1); - ctx.beginPath(); - ctx.moveTo(5, 15); - ctx.lineTo(5, 35); - ctx.stroke(); - ctx.restore(); - - // Draw a green box over a red line, to check the line is not too large - ctx.fillStyle = '#0f0'; - ctx.strokeStyle = '#f00'; - ctx.save(); - ctx.scale(-5, 1); - ctx.beginPath(); - ctx.moveTo(-15, 15); - ctx.lineTo(-15, 35); - ctx.stroke(); - ctx.restore(); - ctx.fillRect(65, 15, 20, 20); - - verify(Helper.comparePixel(ctx, 14,25, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 15,25, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 16,25, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 25,25, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 34,25, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 35,25, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 36,25, 0,255,0,255)); - - //verify(Helper.comparePixel(ctx, 64,25, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 65,25, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 66,25, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 75,25, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 84,25, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 85,25, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 86,25, 0,255,0,255)); - - ctx.reset(); - ctx.lineWidth = 1.5; - compare(ctx.lineWidth, 1.5); - - ctx.lineWidth = "1e1"; - compare(ctx.lineWidth, 10); - - ctx.lineWidth = 1/1024; - compare(ctx.lineWidth, 1/1024); - - ctx.lineWidth = 1000; - compare(ctx.lineWidth, 1000); - - } - function test_cap() { - var ctx = canvas.getContext('2d'); - ctx.reset(); - - ctx.fillStyle = '#0f0'; - ctx.fillRect(0, 0, 100, 50); - - ctx.lineCap = 'butt'; - ctx.lineWidth = 20; - - ctx.fillStyle = '#f00'; - ctx.strokeStyle = '#0f0'; - ctx.fillRect(15, 15, 20, 20); - ctx.beginPath(); - ctx.moveTo(25, 15); - ctx.lineTo(25, 35); - ctx.stroke(); - - ctx.fillStyle = '#0f0'; - ctx.strokeStyle = '#f00'; - ctx.beginPath(); - ctx.moveTo(75, 15); - ctx.lineTo(75, 35); - ctx.stroke(); - ctx.fillRect(65, 15, 20, 20); - - verify(Helper.comparePixel(ctx, 25,14, 0,255,0,255)); - verify(Helper.comparePixel(ctx, 25,15, 0,255,0,255)); - verify(Helper.comparePixel(ctx, 25,16, 0,255,0,255)); - verify(Helper.comparePixel(ctx, 25,34, 0,255,0,255)); - verify(Helper.comparePixel(ctx, 25,35, 0,255,0,255)); - verify(Helper.comparePixel(ctx, 25,36, 0,255,0,255)); - - verify(Helper.comparePixel(ctx, 75,14, 0,255,0,255)); - verify(Helper.comparePixel(ctx, 75,15, 0,255,0,255)); - verify(Helper.comparePixel(ctx, 75,16, 0,255,0,255)); - verify(Helper.comparePixel(ctx, 75,34, 0,255,0,255)); - verify(Helper.comparePixel(ctx, 75,35, 0,255,0,255)); - verify(Helper.comparePixel(ctx, 75,36, 0,255,0,255)); - - ctx.reset(); - - ctx.fillStyle = '#0f0'; - ctx.strokeStyle = '#f00'; - ctx.fillRect(0, 0, 100, 50); - - ctx.lineJoin = 'bevel'; - ctx.lineCap = 'square'; - ctx.lineWidth = 400; - - ctx.beginPath(); - ctx.moveTo(200, 200); - ctx.lineTo(200, 1000); - ctx.lineTo(1000, 1000); - ctx.lineTo(1000, 200); - ctx.closePath(); - ctx.stroke(); - - verify(Helper.comparePixel(ctx, 1,1, 0,255,0,255)); - verify(Helper.comparePixel(ctx, 48,1, 0,255,0,255)); - verify(Helper.comparePixel(ctx, 48,48, 0,255,0,255)); - verify(Helper.comparePixel(ctx, 1,48, 0,255,0,255)); - ctx.reset(); - - ctx.lineCap = 'butt' - compare(ctx.lineCap, 'butt'); - - ctx.lineCap = 'butt'; - ctx.lineCap = 'invalid'; - compare(ctx.lineCap, 'butt'); - - ctx.lineCap = 'butt'; - ctx.lineCap = 'ROUND'; - compare(ctx.lineCap, 'butt'); - - ctx.lineCap = 'butt'; - ctx.lineCap = 'round\\0'; - compare(ctx.lineCap, 'butt'); - - ctx.lineCap = 'butt'; - ctx.lineCap = 'round '; - compare(ctx.lineCap, 'butt'); - - ctx.lineCap = 'butt'; - ctx.lineCap = ""; - compare(ctx.lineCap, 'butt'); - - ctx.lineCap = 'butt'; - ctx.lineCap = 'bevel'; - compare(ctx.lineCap, 'butt'); - - ctx.fillStyle = '#f00'; - ctx.strokeStyle = '#0f0'; - ctx.fillRect(0, 0, 100, 50); - - ctx.lineJoin = 'bevel'; - ctx.lineCap = 'square'; - ctx.lineWidth = 400; - - ctx.beginPath(); - ctx.moveTo(200, 200); - ctx.lineTo(200, 1000); - ctx.lineTo(1000, 1000); - ctx.lineTo(1000, 200); - ctx.lineTo(200, 200); - ctx.stroke(); - - //FIXME:!!! - //verify(Helper.comparePixel(ctx, 1,1, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 48,1, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 48,48, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 1,48, 0,255,0,255)); - ctx.reset(); - - ctx.fillStyle = '#0f0'; - ctx.fillRect(0, 0, 100, 50); - - var tol = 1; // tolerance to avoid antialiasing artifacts - - ctx.lineCap = 'round'; - ctx.lineWidth = 20; - - - ctx.fillStyle = '#f00'; - ctx.strokeStyle = '#0f0'; - - ctx.beginPath(); - ctx.moveTo(35-tol, 15); - ctx.arc(25, 15, 10-tol, 0, Math.PI, true); - ctx.arc(25, 35, 10-tol, Math.PI, 0, true); - ctx.fill(); - - ctx.beginPath(); - ctx.moveTo(25, 15); - ctx.lineTo(25, 35); - ctx.stroke(); - - - ctx.fillStyle = '#0f0'; - ctx.strokeStyle = '#f00'; - - ctx.beginPath(); - ctx.moveTo(75, 15); - ctx.lineTo(75, 35); - ctx.stroke(); - - ctx.beginPath(); - ctx.moveTo(85+tol, 15); - ctx.arc(75, 15, 10+tol, 0, Math.PI, true); - ctx.arc(75, 35, 10+tol, Math.PI, 0, true); - ctx.fill(); - - verify(Helper.comparePixel(ctx, 17,6, 0,255,0,255)); - verify(Helper.comparePixel(ctx, 25,6, 0,255,0,255)); - verify(Helper.comparePixel(ctx, 32,6, 0,255,0,255)); - verify(Helper.comparePixel(ctx, 17,43, 0,255,0,255)); - verify(Helper.comparePixel(ctx, 25,43, 0,255,0,255)); - verify(Helper.comparePixel(ctx, 32,43, 0,255,0,255)); - - verify(Helper.comparePixel(ctx, 67,6, 0,255,0,255)); - verify(Helper.comparePixel(ctx, 75,6, 0,255,0,255)); - verify(Helper.comparePixel(ctx, 82,6, 0,255,0,255)); - verify(Helper.comparePixel(ctx, 67,43, 0,255,0,255)); - verify(Helper.comparePixel(ctx, 75,43, 0,255,0,255)); - verify(Helper.comparePixel(ctx, 82,43, 0,255,0,255)); - ctx.reset(); - - ctx.fillStyle = '#0f0'; - ctx.fillRect(0, 0, 100, 50); - - ctx.lineCap = 'square'; - ctx.lineWidth = 20; - - ctx.fillStyle = '#f00'; - ctx.strokeStyle = '#0f0'; - ctx.fillRect(15, 5, 20, 40); - ctx.beginPath(); - ctx.moveTo(25, 15); - ctx.lineTo(25, 35); - ctx.stroke(); - - ctx.fillStyle = '#0f0'; - ctx.strokeStyle = '#f00'; - ctx.beginPath(); - ctx.moveTo(75, 15); - ctx.lineTo(75, 35); - ctx.stroke(); - ctx.fillRect(65, 5, 20, 40); - - verify(Helper.comparePixel(ctx, 25,4, 0,255,0,255)); - verify(Helper.comparePixel(ctx, 25,5, 0,255,0,255)); - verify(Helper.comparePixel(ctx, 25,6, 0,255,0,255)); - verify(Helper.comparePixel(ctx, 25,44, 0,255,0,255)); - verify(Helper.comparePixel(ctx, 25,45, 0,255,0,255)); - verify(Helper.comparePixel(ctx, 25,46, 0,255,0,255)); - - verify(Helper.comparePixel(ctx, 75,4, 0,255,0,255)); - verify(Helper.comparePixel(ctx, 75,5, 0,255,0,255)); - verify(Helper.comparePixel(ctx, 75,6, 0,255,0,255)); - verify(Helper.comparePixel(ctx, 75,44, 0,255,0,255)); - verify(Helper.comparePixel(ctx, 75,45, 0,255,0,255)); - verify(Helper.comparePixel(ctx, 75,46, 0,255,0,255)); - - ctx.reset(); - ctx.lineCap = 'butt' - compare(ctx.lineCap, 'butt'); - - ctx.lineCap = 'round'; - compare(ctx.lineCap, 'round'); - - ctx.lineCap = 'square'; - compare(ctx.lineCap, 'square'); - - } - } -} \ No newline at end of file diff --git a/tests/auto/qtquick2/qquickcanvasitem/data/tst_path.qml b/tests/auto/qtquick2/qquickcanvasitem/data/tst_path.qml deleted file mode 100644 index b04ccf5458..0000000000 --- a/tests/auto/qtquick2/qquickcanvasitem/data/tst_path.qml +++ /dev/null @@ -1,1443 +0,0 @@ -import QtQuick 2.0 -import QtTest 1.0 -import "testhelper.js" as Helper - -Canvas { - id:canvas; width:100;height:50; renderTarget: Canvas.Image - TestCase { - name: "path"; when: windowShown - - function test_basic() { - var ctx = canvas.getContext('2d'); - ctx.reset(); - ctx.fillStyle = '#0f0'; - ctx.fillRect(0, 0, 100, 50); - ctx.closePath(); - ctx.fillStyle = '#f00'; - ctx.fill(); - verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); - - ctx.reset(); - ctx.fillStyle = '#f00'; - ctx.fillRect(0, 0, 100, 50); - ctx.save(); - ctx.rect(0, 0, 100, 50); - ctx.restore(); - ctx.fillStyle = '#0f0'; - ctx.fill(); - verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); - - - canvas.width = 100; - ctx.rect(0, 0, 100, 50); - canvas.width = 100; - ctx.fillStyle = '#f00'; - ctx.fill(); - //verify(Helper.comparePixel(ctx, 20,20, 0,0,0,0)); - } - function test_beginPath() { - var ctx = canvas.getContext('2d'); - ctx.fillStyle = '#0f0'; - ctx.fillRect(0, 0, 100, 50); - ctx.rect(0, 0, 100, 50); - ctx.beginPath(); - ctx.fillStyle = '#f00'; - ctx.fill(); - verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); - } - function test_closePath() { - var ctx = canvas.getContext('2d'); - ctx.reset(); - ctx.fillStyle = '#0f0'; - ctx.fillRect(0, 0, 100, 50); - ctx.closePath(); - ctx.fillStyle = '#f00'; - ctx.fill(); - verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); - - ctx.reset(); - ctx.fillStyle = '#f00'; - ctx.fillRect(0, 0, 100, 50); - ctx.strokeStyle = '#0f0'; - ctx.lineWidth = 50; - ctx.moveTo(-100, 25); - ctx.lineTo(-100, -100); - ctx.lineTo(200, -100); - ctx.lineTo(200, 25); - ctx.closePath(); - ctx.stroke(); - verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); - - ctx.reset(); - ctx.fillStyle = '#f00'; - ctx.fillRect(0, 0, 100, 50); - ctx.strokeStyle = '#0f0'; - ctx.lineWidth = 50; - ctx.moveTo(-100, 25); - ctx.lineTo(-100, -1000); - ctx.closePath(); - ctx.lineTo(1000, 25); - ctx.stroke(); - verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); - } - - function test_isPointInPath() { - var ctx = canvas.getContext('2d'); - ctx.reset(); - ctx.arc(50, 25, 10, 0, Math.PI, false); - verify(!ctx.isPointInPath(50, 10)); - verify(!ctx.isPointInPath(50, 20)); - //verify(!ctx.isPointInPath(50, 30)); - verify(!ctx.isPointInPath(50, 40)); - verify(!ctx.isPointInPath(30, 20)); - verify(!ctx.isPointInPath(70, 20)); - verify(!ctx.isPointInPath(30, 30)); - verify(!ctx.isPointInPath(70, 30)); - - ctx.reset(); - ctx.rect(0, 0, 20, 20); - verify(ctx.isPointInPath(10, 10)); - verify(!ctx.isPointInPath(30, 10)); - - ctx.reset(); - ctx.rect(20, 0, 20, 20); - //verify(ctx.isPointInPath(10, 10)); - verify(ctx.isPointInPath(30, 10)); - - ctx.reset(); - ctx.bezierCurveTo(50, -50, 50, 100, 75, 25); - verify(!ctx.isPointInPath(25, 20)); - verify(!ctx.isPointInPath(25, 30)); - //verify(ctx.isPointInPath(30, 20)); - verify(!ctx.isPointInPath(30, 30)); - //verify(!ctx.isPointInPath(40, 2)); - //verify(ctx.isPointInPath(40, 20)); - verify(!ctx.isPointInPath(40, 30)); - verify(!ctx.isPointInPath(40, 47)); - //verify(ctx.isPointInPath(45, 20)); - //verify(!ctx.isPointInPath(45, 30)); - //verify(!ctx.isPointInPath(55, 20)); - //verify(ctx.isPointInPath(55, 30)); - verify(!ctx.isPointInPath(60, 2)); - //verify(!ctx.isPointInPath(60, 20)); - verify(ctx.isPointInPath(60, 30)); - verify(!ctx.isPointInPath(60, 47)); - verify(!ctx.isPointInPath(70, 20)); - verify(ctx.isPointInPath(70, 30)); - verify(!ctx.isPointInPath(75, 20)); - verify(!ctx.isPointInPath(75, 30)); - - ctx.reset(); - ctx.arc(50, 25, 10, 0, 7, false); - verify(!ctx.isPointInPath(50, 10)); - //verify(ctx.isPointInPath(50, 20)); - //verify(ctx.isPointInPath(50, 30)); - verify(!ctx.isPointInPath(50, 40)); - verify(!ctx.isPointInPath(30, 20)); - verify(!ctx.isPointInPath(70, 20)); - verify(!ctx.isPointInPath(30, 30)); - //verify(!ctx.isPointInPath(70, 30)); - - ctx.reset(); - ctx.rect(0, 0, 20, 20); - verify(ctx.isPointInPath(0, 0)); - verify(ctx.isPointInPath(10, 0)); - //verify(ctx.isPointInPath(20, 0)); - //verify(ctx.isPointInPath(20, 10)); - //verify(ctx.isPointInPath(20, 20)); - //verify(ctx.isPointInPath(10, 20)); - //verify(ctx.isPointInPath(0, 20)); - verify(ctx.isPointInPath(0, 10)); - verify(!ctx.isPointInPath(10, -0.01)); - verify(!ctx.isPointInPath(10, 20.01)); - verify(!ctx.isPointInPath(-0.01, 10)); - //verify(!ctx.isPointInPath(20.01, 10)); - - ctx.reset(); - verify(!ctx.isPointInPath(0, 0)); - - - ctx.reset(); - ctx.rect(-100, -50, 200, 100); - //verify(ctx.isPointInPath(Infinity, 0)); - //verify(ctx.isPointInPath(-Infinity, 0)); - //verify(ctx.isPointInPath(NaN, 0)); - //verify(ctx.isPointInPath(0, Infinity)); - //verify(ctx.isPointInPath(0, -Infinity)); - //verify(ctx.isPointInPath(0, NaN)); - //verify(ctx.isPointInPath(NaN, NaN)); - - ctx.reset(); - ctx.rect(0, -100, 20, 20); - ctx.rect(20, -10, 20, 20); - verify(!ctx.isPointInPath(10, -110)); - verify(ctx.isPointInPath(10, -90)); - verify(!ctx.isPointInPath(10, -70)); - //verify(!ctx.isPointInPath(30, -20)); - //verify(ctx.isPointInPath(30, 0)); - //verify(!ctx.isPointInPath(30, 20)); - - ctx.reset(); - ctx.rect(0, 0, 20, 20); - ctx.beginPath(); - ctx.rect(20, 0, 20, 20); - ctx.closePath(); - ctx.rect(40, 0, 20, 20); - verify(!ctx.isPointInPath(10, 10)); - verify(ctx.isPointInPath(30, 10)); - verify(ctx.isPointInPath(50, 10)); - - ctx.reset(); - ctx.translate(50, 0); - ctx.rect(0, 0, 20, 20); - verify(!ctx.isPointInPath(-40, 10)); - verify(!ctx.isPointInPath(10, 10)); - //verify(!ctx.isPointInPath(49, 10)); - verify(ctx.isPointInPath(51, 10)); - verify(ctx.isPointInPath(69, 10)); - verify(!ctx.isPointInPath(71, 10)); - - ctx.reset(); - ctx.rect(50, 0, 20, 20); - ctx.translate(50, 0); - verify(!ctx.isPointInPath(-40, 10)); - verify(!ctx.isPointInPath(10, 10)); - //verify(!ctx.isPointInPath(49, 10)); - verify(ctx.isPointInPath(51, 10)); - verify(ctx.isPointInPath(69, 10)); - verify(!ctx.isPointInPath(71, 10)); - - ctx.reset(); - ctx.scale(-1, 1); - ctx.rect(-70, 0, 20, 20); - verify(!ctx.isPointInPath(-40, 10)); - verify(!ctx.isPointInPath(10, 10)); - //verify(!ctx.isPointInPath(49, 10)); - verify(ctx.isPointInPath(51, 10)); - verify(ctx.isPointInPath(69, 10)); - verify(!ctx.isPointInPath(71, 10)); - - ctx.reset(); - ctx.moveTo(0, 0); - ctx.lineTo(20, 0); - ctx.lineTo(20, 20); - ctx.lineTo(0, 20); - verify(ctx.isPointInPath(10, 10)); - //verify(!ctx.isPointInPath(30, 10)); - - ctx.reset(); - ctx.moveTo(0, 0); - ctx.lineTo(50, 0); - ctx.lineTo(50, 50); - ctx.lineTo(0, 50); - ctx.lineTo(0, 0); - ctx.lineTo(10, 10); - ctx.lineTo(10, 40); - ctx.lineTo(40, 40); - ctx.lineTo(40, 10); - ctx.lineTo(10, 10); - - verify(ctx.isPointInPath(5, 5)); - verify(ctx.isPointInPath(25, 5)); - verify(ctx.isPointInPath(45, 5)); - verify(ctx.isPointInPath(5, 25)); - verify(!ctx.isPointInPath(25, 25)); - verify(ctx.isPointInPath(45, 25)); - verify(ctx.isPointInPath(5, 45)); - verify(ctx.isPointInPath(25, 45)); - verify(ctx.isPointInPath(45, 45)); - } - - - function test_fill() { - var ctx = canvas.getContext('2d'); - ctx.reset(); - ctx.fillStyle = '#f00'; - ctx.fillRect(0, 0, 100, 50); - - ctx.fillStyle = '#0f0'; - ctx.moveTo(0, 0); - ctx.lineTo(100, 0); - ctx.lineTo(100, 50); - ctx.lineTo(0, 50); - ctx.fill(); - - verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); - - - ctx.reset(); - ctx.fillStyle = '#00f'; - ctx.fillRect(0, 0, 100, 50); - - ctx.moveTo(0, 0); - ctx.lineTo(100, 0); - ctx.lineTo(100, 50); - ctx.fillStyle = '#f00'; - ctx.fill(); - ctx.lineTo(0, 50); - ctx.fillStyle = '#0f0'; - ctx.fill(); - - //verify(Helper.comparePixel(ctx, 90,10, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 10,40, 0,255,0,255)); - - ctx.reset(); - ctx.fillStyle = '#000'; - ctx.fillRect(0, 0, 100, 50); - - ctx.fillStyle = 'rgba(0, 255, 0, 0.5)'; - ctx.rect(0, 0, 100, 50); - ctx.closePath(); - ctx.rect(10, 10, 80, 30); - ctx.fill(); - - //verify(Helper.comparePixel(ctx, 50,25, 0,127,0,255, 1)); - - ctx.reset(); - ctx.fillStyle = '#f00'; - ctx.fillRect(0, 0, 100, 50); - - ctx.fillStyle = '#0f0'; - ctx.moveTo(-10, -10); - ctx.lineTo(110, -10); - ctx.lineTo(110, 60); - ctx.lineTo(-10, 60); - ctx.lineTo(-10, -10); - ctx.lineTo(0, 0); - ctx.lineTo(100, 0); - ctx.lineTo(100, 50); - ctx.lineTo(0, 50); - ctx.fill(); - - //verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); - - ctx.reset(); - ctx.fillStyle = '#0f0'; - ctx.fillRect(0, 0, 100, 50); - - ctx.fillStyle = '#f00'; - ctx.moveTo(-10, -10); - ctx.lineTo(110, -10); - ctx.lineTo(110, 60); - ctx.lineTo(-10, 60); - ctx.lineTo(-10, -10); - ctx.lineTo(0, 0); - ctx.lineTo(0, 50); - ctx.lineTo(100, 50); - ctx.lineTo(100, 0); - ctx.fill(); - - verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); - - ctx.reset(); - ctx.fillStyle = '#0f0'; - ctx.fillRect(0, 0, 100, 50); - - ctx.fillStyle = '#f00'; - ctx.moveTo(-10, -10); - ctx.lineTo(110, -10); - ctx.lineTo(110, 60); - ctx.lineTo(-10, 60); - ctx.moveTo(0, 0); - ctx.lineTo(0, 50); - ctx.lineTo(100, 50); - ctx.lineTo(100, 0); - ctx.fill(); - - verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); - - ctx.reset(); - ctx.fillStyle = '#f00'; - ctx.fillRect(0, 0, 100, 50); - - ctx.fillStyle = '#0f0'; - ctx.moveTo(-10, -10); - ctx.lineTo(110, -10); - ctx.lineTo(110, 60); - ctx.lineTo(-10, 60); - ctx.lineTo(-10, -10); - ctx.lineTo(-20, -20); - ctx.lineTo(120, -20); - ctx.lineTo(120, 70); - ctx.lineTo(-20, 70); - ctx.lineTo(-20, -20); - ctx.lineTo(0, 0); - ctx.lineTo(0, 50); - ctx.lineTo(100, 50); - ctx.lineTo(100, 0); - ctx.fill(); - - verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); - - } - function test_stroke() { - var ctx = canvas.getContext('2d'); - ctx.reset(); - ctx.fillStyle = '#0f0'; - ctx.fillRect(0, 0, 100, 50); - - ctx.strokeStyle = '#f00'; - ctx.lineWidth = 100; - ctx.lineCap = 'round'; - ctx.lineJoin = 'round'; - - ctx.beginPath(); - ctx.moveTo(40, 25); - ctx.moveTo(60, 25); - ctx.stroke(); - - verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); - - ctx.reset(); - ctx.fillStyle = '#000'; - ctx.fillRect(0, 0, 100, 50); - - ctx.strokeStyle = 'rgba(0, 255, 0, 0.5)'; - ctx.lineWidth = 50; - ctx.moveTo(0, 20); - ctx.lineTo(100, 20); - ctx.moveTo(0, 30); - ctx.lineTo(100, 30); - ctx.stroke(); - - //verify(Helper.comparePixel(ctx, 50,25, 0,127,0,255)); - - ctx.reset(); - ctx.fillStyle = '#0f0'; - ctx.fillRect(0, 0, 100, 50); - - ctx.strokeStyle = '#f00'; - ctx.lineWidth = 100; - ctx.lineCap = 'round'; - ctx.lineJoin = 'round'; - - ctx.beginPath(); - ctx.moveTo(50, 25); - ctx.arcTo(50, 25, 150, 25, 10); - ctx.stroke(); - - ctx.beginPath(); - ctx.moveTo(50, 25); - ctx.arc(50, 25, 10, 0, 0, false); - ctx.stroke(); - - // verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); - ctx.reset(); - ctx.fillStyle = '#0f0'; - ctx.fillRect(0, 0, 100, 50); - - ctx.strokeStyle = '#f00'; - ctx.lineWidth = 100; - ctx.lineCap = 'round'; - ctx.lineJoin = 'round'; - - ctx.beginPath(); - ctx.moveTo(50, 25); - ctx.lineTo(50, 25); - ctx.closePath(); - ctx.stroke(); - - verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); - ctx.reset(); - - ctx.fillStyle = '#0f0'; - ctx.fillRect(0, 0, 100, 50); - - ctx.strokeStyle = '#f00'; - ctx.lineWidth = 400; - ctx.lineJoin = 'miter'; - ctx.miterLimit = 1.4; - - ctx.beginPath(); - ctx.moveTo(-1000, 200, 0, 0); - ctx.lineTo(-100, 200); - ctx.lineTo(-100, 200); - ctx.lineTo(-100, 200); - ctx.lineTo(-100, 1000); - ctx.stroke(); - - verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); - - ctx.reset(); - ctx.fillStyle = '#0f0'; - ctx.fillRect(0, 0, 100, 50); - - ctx.strokeStyle = '#f00'; - ctx.lineWidth = 100; - ctx.lineCap = 'round'; - ctx.lineJoin = 'round'; - - ctx.beginPath(); - ctx.moveTo(50, 25); - ctx.quadraticCurveTo(50, 25, 50, 25); - ctx.stroke(); - - ctx.beginPath(); - ctx.moveTo(50, 25); - ctx.bezierCurveTo(50, 25, 50, 25, 50, 25); - ctx.stroke(); - - verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); - - ctx.fillStyle = '#0f0'; - ctx.fillRect(0, 0, 100, 50); - - ctx.strokeStyle = '#f00'; - ctx.lineWidth = 100; - ctx.lineCap = 'round'; - ctx.lineJoin = 'round'; - - ctx.beginPath(); - ctx.moveTo(50, 25); - ctx.lineTo(50, 25); - ctx.stroke(); - - verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); - - ctx.reset(); - ctx.fillStyle = '#0f0'; - ctx.fillRect(0, 0, 100, 50); - - ctx.strokeStyle = '#f00'; - ctx.lineWidth = 100; - ctx.lineCap = 'round'; - ctx.lineJoin = 'round'; - - ctx.beginPath(); - ctx.rect(50, 25, 0, 0); - ctx.stroke(); - - ctx.strokeRect(50, 25, 0, 0); - - verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); - - - ctx.fillStyle = '#f00'; - ctx.fillRect(0, 0, 100, 50); - - ctx.beginPath(); - ctx.rect(25, 12.5, 50, 25); - ctx.save(); - ctx.scale(50, 25); - ctx.strokeStyle = '#0f0'; - ctx.stroke(); - ctx.restore(); - - ctx.beginPath(); - ctx.rect(-25, -12.5, 150, 75); - ctx.save(); - ctx.scale(50, 25); - ctx.strokeStyle = '#f00'; - ctx.stroke(); - ctx.restore(); - - //verify(Helper.comparePixel(ctx, 0,0, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 50,0, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 99,0, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 0,25, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 99,25, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 0,49, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 50,49, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 99,49, 0,255,0,255)); - - ctx.reset(); - ctx.fillStyle = '#f00'; - ctx.fillRect(0, 0, 100, 50); - - ctx.beginPath(); - ctx.rect(25, 12.5, 50, 25); - ctx.save(); - ctx.rotate(Math.PI/2); - ctx.scale(25, 50); - ctx.strokeStyle = '#0f0'; - ctx.stroke(); - ctx.restore(); - - ctx.beginPath(); - ctx.rect(-25, -12.5, 150, 75); - ctx.save(); - ctx.rotate(Math.PI/2); - ctx.scale(25, 50); - ctx.strokeStyle = '#f00'; - ctx.stroke(); - ctx.restore(); - - //verify(Helper.comparePixel(ctx, 0,0, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 50,0, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 99,0, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 0,25, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 99,25, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 0,49, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 50,49, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 99,49, 0,255,0,255)); - - ctx.reset(); - ctx.fillStyle = '#f00'; - ctx.fillRect(0, 0, 100, 50); - - ctx.save(); - ctx.beginPath(); - ctx.moveTo(49, -50); - ctx.lineTo(201, -50); - ctx.rotate(Math.PI/4); - ctx.scale(1, 283); - ctx.strokeStyle = '#0f0'; - ctx.stroke(); - ctx.restore(); - - ctx.save(); - ctx.beginPath(); - ctx.translate(-150, 0); - ctx.moveTo(49, -50); - ctx.lineTo(199, -50); - ctx.rotate(Math.PI/4); - ctx.scale(1, 142); - ctx.strokeStyle = '#f00'; - ctx.stroke(); - ctx.restore(); - - ctx.save(); - ctx.beginPath(); - ctx.translate(-150, 0); - ctx.moveTo(49, -50); - ctx.lineTo(199, -50); - ctx.rotate(Math.PI/4); - ctx.scale(1, 142); - ctx.strokeStyle = '#f00'; - ctx.stroke(); - ctx.restore(); - - //verify(Helper.comparePixel(ctx, 0,0, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 50,0, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 99,0, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 0,25, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 99,25, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 0,49, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 50,49, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 99,49, 0,255,0,255)); - - ctx.reset(); - ctx.fillStyle = '#f00'; - ctx.fillRect(0, 0, 100, 50); - - ctx.lineWidth = 50; - ctx.moveTo(-100, 25); - ctx.lineTo(-100, -100); - ctx.lineTo(200, -100); - ctx.lineTo(200, 25); - ctx.strokeStyle = '#f00'; - ctx.stroke(); - - ctx.closePath(); - ctx.strokeStyle = '#0f0'; - ctx.stroke(); - - verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); - - ctx.reset(); - ctx.fillStyle = '#f00'; - ctx.fillRect(0, 0, 100, 50); - - ctx.strokeStyle = '#0f0'; - ctx.lineWidth = 40; - ctx.moveTo(0, 10); - ctx.lineTo(100, 10); - ctx.moveTo(100, 40); - ctx.lineTo(0, 40); - ctx.stroke(); - - verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); - - } - function test_clip() { - var ctx = canvas.getContext('2d'); - ctx.reset(); - ctx.fillStyle = '#f00'; - ctx.fillRect(0, 0, 100, 50); - - ctx.beginPath(); - ctx.rect(0, 0, 100, 50); - ctx.clip(); - - ctx.fillStyle = '#0f0'; - ctx.fillRect(0, 0, 100, 50); - - verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); - - ctx.reset(); - ctx.fillStyle = '#0f0'; - ctx.fillRect(0, 0, 100, 50); - - ctx.beginPath(); - ctx.rect(-100, 0, 100, 50); - ctx.clip(); - - ctx.fillStyle = '#f00'; - ctx.fillRect(0, 0, 100, 50); - - verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); - ctx.reset(); - ctx.fillStyle = '#0f0'; - ctx.fillRect(0, 0, 100, 50); - - ctx.beginPath(); - ctx.clip(); - - ctx.fillStyle = '#f00'; - ctx.fillRect(0, 0, 100, 50); - - verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); - - ctx.fillStyle = '#0f0'; - ctx.fillRect(0, 0, 100, 50); - - ctx.beginPath(); - ctx.rect(0, 0, 50, 50); - ctx.clip(); - ctx.beginPath(); - ctx.rect(50, 0, 50, 50) - ctx.clip(); - - ctx.fillStyle = '#f00'; - ctx.fillRect(0, 0, 100, 50); - - verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); - - ctx.reset(); - ctx.fillStyle = '#f00'; - ctx.fillRect(0, 0, 100, 50); - - ctx.fillStyle = '#0f0'; - - ctx.beginPath(); - ctx.moveTo(0, 0); - ctx.lineTo(0, 50); - ctx.lineTo(100, 50); - ctx.lineTo(100, 0); - ctx.clip(); - - ctx.lineTo(0, 0); - ctx.fill(); - - verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); - - - ctx.reset(); - ctx.fillStyle = '#0f0'; - ctx.fillRect(0, 0, 100, 50); - - ctx.beginPath(); - ctx.moveTo(-10, -10); - ctx.lineTo(110, -10); - ctx.lineTo(110, 60); - ctx.lineTo(-10, 60); - ctx.lineTo(-10, -10); - ctx.lineTo(0, 0); - ctx.lineTo(0, 50); - ctx.lineTo(100, 50); - ctx.lineTo(100, 0); - ctx.clip(); - - ctx.fillStyle = '#f00'; - ctx.fillRect(0, 0, 100, 50); - - verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); - - ctx.reset(); - ctx.fillStyle = '#f00'; - ctx.fillRect(0, 0, 100, 50); - - ctx.beginPath(); - ctx.moveTo(-10, -10); - ctx.lineTo(110, -10); - ctx.lineTo(110, 60); - ctx.lineTo(-10, 60); - ctx.lineTo(-10, -10); - ctx.clip(); - - ctx.beginPath(); - ctx.moveTo(0, 0); - ctx.lineTo(0, 50); - ctx.lineTo(100, 50); - ctx.lineTo(100, 0); - ctx.lineTo(0, 0); - ctx.clip(); - - ctx.fillStyle = '#0f0'; - ctx.fillRect(0, 0, 100, 50); - - verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); - } - - function test_moveTo() { - var ctx = canvas.getContext('2d'); - ctx.reset(); - ctx.fillStyle = '#f00'; - ctx.fillRect(0, 0, 100, 50); - ctx.rect(0, 0, 10, 50); - ctx.moveTo(100, 0); - ctx.lineTo(10, 0); - ctx.lineTo(10, 50); - ctx.lineTo(100, 50); - ctx.fillStyle = '#0f0'; - ctx.fill(); - verify(Helper.comparePixel(ctx, 90,25, 0,255,0,255)); - ctx.reset(); - ctx.fillStyle = '#f00'; - ctx.fillRect(0, 0, 100, 50); - ctx.moveTo(0, 25); - ctx.moveTo(100, 25); - ctx.moveTo(0, 25); - ctx.lineTo(100, 25); - ctx.strokeStyle = '#0f0'; - ctx.lineWidth = 50; - ctx.stroke(); - verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); - - ctx.reset(); - ctx.fillStyle = '#0f0'; - ctx.fillRect(0, 0, 100, 50); - ctx.beginPath(); - ctx.moveTo(0, 0); - ctx.moveTo(100, 0); - ctx.moveTo(100, 50); - ctx.moveTo(0, 50); - ctx.fillStyle = '#f00'; - ctx.fill(); - verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); - - ctx.reset(); - ctx.moveTo(0, 0); - ctx.lineTo(100, 0); - ctx.moveTo(Infinity, 50); - ctx.moveTo(-Infinity, 50); - ctx.moveTo(NaN, 50); - ctx.moveTo(0, Infinity); - ctx.moveTo(0, -Infinity); - ctx.moveTo(0, NaN); - ctx.moveTo(Infinity, Infinity); - ctx.lineTo(100, 50); - ctx.lineTo(0, 50); - ctx.fillStyle = '#0f0'; - ctx.fill(); - verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); - } - function test_lineTo() { - var ctx = canvas.getContext('2d'); - ctx.reset(); - ctx.fillStyle = '#f00'; - ctx.fillRect(0, 0, 100, 50); - ctx.strokeStyle = '#0f0'; - ctx.lineWidth = 50; - ctx.beginPath(); - ctx.moveTo(0, 25); - ctx.lineTo(100, 25); - ctx.stroke(); - verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); - - ctx.reset(); - ctx.fillStyle = '#0f0'; - ctx.fillRect(0, 0, 100, 50); - ctx.strokeStyle = '#f00'; - ctx.lineWidth = 50; - ctx.beginPath(); - ctx.lineTo(100, 50); - ctx.stroke(); - // verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); - - ctx.reset(); - ctx.fillStyle = '#f00'; - ctx.fillRect(0, 0, 100, 50); - ctx.strokeStyle = '#0f0'; - ctx.lineWidth = 50; - ctx.beginPath(); - ctx.lineTo(0, 25); - ctx.lineTo(100, 25); - ctx.stroke(); - verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); - - ctx.reset(); - ctx.fillStyle = '#f00'; - ctx.fillRect(0, 0, 100, 50); - ctx.strokeStyle = '#0f0'; - ctx.lineWidth = 50; - ctx.beginPath(); - ctx.moveTo(-100, -100); - ctx.lineTo(0, 25); - ctx.lineTo(100, 25); - ctx.stroke(); - verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); - - ctx.reset(); - ctx.moveTo(0, 0); - ctx.lineTo(100, 0); - ctx.lineTo(Infinity, 50); - ctx.lineTo(-Infinity, 50); - ctx.lineTo(NaN, 50); - ctx.lineTo(0, Infinity); - ctx.lineTo(0, -Infinity); - ctx.lineTo(0, NaN); - ctx.lineTo(Infinity, Infinity); - ctx.lineTo(100, 50); - ctx.lineTo(0, 50); - ctx.fillStyle = '#0f0'; - ctx.fill(); - verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); - verify(Helper.comparePixel(ctx, 90,45, 0,255,0,255)); - - } - function test_bezierCurveTo() { - var ctx = canvas.getContext('2d'); - ctx.reset(); - ctx.fillStyle = '#f00'; - ctx.fillRect(0, 0, 100, 50); - ctx.strokeStyle = '#0f0'; - ctx.lineWidth = 50; - ctx.beginPath(); - ctx.moveTo(0, 25); - ctx.bezierCurveTo(100, 25, 100, 25, 100, 25); - ctx.stroke(); - verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); - - ctx.reset(); - ctx.fillStyle = '#0f0'; - ctx.fillRect(0, 0, 100, 50); - ctx.strokeStyle = '#f00'; - ctx.lineWidth = 50; - ctx.beginPath(); - ctx.bezierCurveTo(100, 50, 200, 50, 200, 50); - ctx.stroke(); - //verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 95,45, 0,255,0,255)); - - ctx.reset(); - ctx.fillStyle = '#f00'; - ctx.fillRect(0, 0, 100, 50); - ctx.strokeStyle = '#0f0'; - ctx.lineWidth = 50; - ctx.beginPath(); - ctx.bezierCurveTo(0, 25, 100, 25, 100, 25); - ctx.stroke(); - verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 5,45, 0,255,0,255)); - - ctx.reset(); - ctx.moveTo(0, 0); - ctx.lineTo(100, 0); - ctx.bezierCurveTo(Infinity, 50, 0, 50, 0, 50); - ctx.bezierCurveTo(-Infinity, 50, 0, 50, 0, 50); - ctx.bezierCurveTo(NaN, 50, 0, 50, 0, 50); - ctx.bezierCurveTo(0, Infinity, 0, 50, 0, 50); - ctx.bezierCurveTo(0, -Infinity, 0, 50, 0, 50); - ctx.bezierCurveTo(0, NaN, 0, 50, 0, 50); - ctx.bezierCurveTo(0, 50, Infinity, 50, 0, 50); - ctx.bezierCurveTo(0, 50, -Infinity, 50, 0, 50); - ctx.bezierCurveTo(0, 50, NaN, 50, 0, 50); - ctx.bezierCurveTo(0, 50, 0, Infinity, 0, 50); - ctx.bezierCurveTo(0, 50, 0, -Infinity, 0, 50); - ctx.bezierCurveTo(0, 50, 0, NaN, 0, 50); - ctx.bezierCurveTo(0, 50, 0, 50, Infinity, 50); - ctx.bezierCurveTo(0, 50, 0, 50, -Infinity, 50); - ctx.bezierCurveTo(0, 50, 0, 50, NaN, 50); - ctx.bezierCurveTo(0, 50, 0, 50, 0, Infinity); - ctx.bezierCurveTo(0, 50, 0, 50, 0, -Infinity); - ctx.bezierCurveTo(0, 50, 0, 50, 0, NaN); - ctx.bezierCurveTo(Infinity, Infinity, 0, 50, 0, 50); - ctx.bezierCurveTo(Infinity, Infinity, Infinity, 50, 0, 50); - ctx.bezierCurveTo(Infinity, Infinity, Infinity, Infinity, 0, 50); - ctx.bezierCurveTo(Infinity, Infinity, Infinity, Infinity, Infinity, 50); - ctx.bezierCurveTo(Infinity, Infinity, Infinity, Infinity, Infinity, Infinity); - ctx.bezierCurveTo(Infinity, Infinity, Infinity, Infinity, 0, Infinity); - ctx.bezierCurveTo(Infinity, Infinity, Infinity, 50, Infinity, 50); - ctx.bezierCurveTo(Infinity, Infinity, Infinity, 50, Infinity, Infinity); - ctx.bezierCurveTo(Infinity, Infinity, Infinity, 50, 0, Infinity); - ctx.bezierCurveTo(Infinity, Infinity, 0, Infinity, 0, 50); - ctx.bezierCurveTo(Infinity, Infinity, 0, Infinity, Infinity, 50); - ctx.bezierCurveTo(Infinity, Infinity, 0, Infinity, Infinity, Infinity); - ctx.bezierCurveTo(Infinity, Infinity, 0, Infinity, 0, Infinity); - ctx.bezierCurveTo(Infinity, Infinity, 0, 50, Infinity, 50); - ctx.bezierCurveTo(Infinity, Infinity, 0, 50, Infinity, Infinity); - ctx.bezierCurveTo(Infinity, Infinity, 0, 50, 0, Infinity); - ctx.bezierCurveTo(Infinity, 50, Infinity, 50, 0, 50); - ctx.bezierCurveTo(Infinity, 50, Infinity, Infinity, 0, 50); - ctx.bezierCurveTo(Infinity, 50, Infinity, Infinity, Infinity, 50); - ctx.bezierCurveTo(Infinity, 50, Infinity, Infinity, Infinity, Infinity); - ctx.bezierCurveTo(Infinity, 50, Infinity, Infinity, 0, Infinity); - ctx.bezierCurveTo(Infinity, 50, Infinity, 50, Infinity, 50); - ctx.bezierCurveTo(Infinity, 50, Infinity, 50, Infinity, Infinity); - ctx.bezierCurveTo(Infinity, 50, Infinity, 50, 0, Infinity); - ctx.bezierCurveTo(Infinity, 50, 0, Infinity, 0, 50); - ctx.bezierCurveTo(Infinity, 50, 0, Infinity, Infinity, 50); - ctx.bezierCurveTo(Infinity, 50, 0, Infinity, Infinity, Infinity); - ctx.bezierCurveTo(Infinity, 50, 0, Infinity, 0, Infinity); - ctx.bezierCurveTo(Infinity, 50, 0, 50, Infinity, 50); - ctx.bezierCurveTo(Infinity, 50, 0, 50, Infinity, Infinity); - ctx.bezierCurveTo(Infinity, 50, 0, 50, 0, Infinity); - ctx.bezierCurveTo(Infinity, 50, Infinity, 50, 0, 50); - ctx.bezierCurveTo(Infinity, 50, Infinity, Infinity, 0, 50); - ctx.bezierCurveTo(Infinity, 50, Infinity, Infinity, Infinity, 50); - ctx.bezierCurveTo(Infinity, 50, Infinity, Infinity, Infinity, Infinity); - ctx.bezierCurveTo(Infinity, 50, Infinity, Infinity, 0, Infinity); - ctx.bezierCurveTo(Infinity, 50, Infinity, 50, Infinity, 50); - ctx.bezierCurveTo(Infinity, 50, Infinity, 50, Infinity, Infinity); - ctx.bezierCurveTo(Infinity, 50, Infinity, 50, 0, Infinity); - ctx.bezierCurveTo(Infinity, 50, 0, Infinity, 0, 50); - ctx.bezierCurveTo(Infinity, 50, 0, Infinity, Infinity, 50); - ctx.bezierCurveTo(Infinity, 50, 0, Infinity, Infinity, Infinity); - ctx.bezierCurveTo(Infinity, 50, 0, Infinity, 0, Infinity); - ctx.bezierCurveTo(Infinity, 50, 0, 50, Infinity, 50); - ctx.bezierCurveTo(Infinity, 50, 0, 50, Infinity, Infinity); - ctx.bezierCurveTo(Infinity, 50, 0, 50, 0, Infinity); - ctx.bezierCurveTo(0, Infinity, Infinity, 50, 0, 50); - ctx.bezierCurveTo(0, Infinity, Infinity, Infinity, 0, 50); - ctx.bezierCurveTo(0, Infinity, Infinity, Infinity, Infinity, 50); - ctx.bezierCurveTo(0, Infinity, Infinity, Infinity, Infinity, Infinity); - ctx.bezierCurveTo(0, Infinity, Infinity, Infinity, 0, Infinity); - ctx.bezierCurveTo(0, Infinity, Infinity, 50, Infinity, 50); - ctx.bezierCurveTo(0, Infinity, Infinity, 50, Infinity, Infinity); - ctx.bezierCurveTo(0, Infinity, Infinity, 50, 0, Infinity); - ctx.bezierCurveTo(0, Infinity, 0, Infinity, 0, 50); - ctx.bezierCurveTo(0, Infinity, 0, Infinity, Infinity, 50); - ctx.bezierCurveTo(0, Infinity, 0, Infinity, Infinity, Infinity); - ctx.bezierCurveTo(0, Infinity, 0, Infinity, 0, Infinity); - ctx.bezierCurveTo(0, Infinity, 0, 50, Infinity, 50); - ctx.bezierCurveTo(0, Infinity, 0, 50, Infinity, Infinity); - ctx.bezierCurveTo(0, Infinity, 0, 50, 0, Infinity); - ctx.bezierCurveTo(0, 50, Infinity, Infinity, 0, 50); - ctx.bezierCurveTo(0, 50, Infinity, Infinity, Infinity, 50); - ctx.bezierCurveTo(0, 50, Infinity, Infinity, Infinity, Infinity); - ctx.bezierCurveTo(0, 50, Infinity, Infinity, 0, Infinity); - ctx.bezierCurveTo(0, 50, Infinity, 50, Infinity, 50); - ctx.bezierCurveTo(0, 50, Infinity, 50, Infinity, Infinity); - ctx.bezierCurveTo(0, 50, Infinity, 50, 0, Infinity); - ctx.bezierCurveTo(0, 50, 0, Infinity, Infinity, 50); - ctx.bezierCurveTo(0, 50, 0, Infinity, Infinity, Infinity); - ctx.bezierCurveTo(0, 50, 0, Infinity, 0, Infinity); - ctx.bezierCurveTo(0, 50, 0, 50, Infinity, Infinity); - ctx.lineTo(100, 50); - ctx.lineTo(0, 50); - ctx.fillStyle = '#0f0'; - ctx.fill(); - verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); - verify(Helper.comparePixel(ctx, 90,45, 0,255,0,255)); - - ctx.reset(); - ctx.fillStyle = '#f00'; - ctx.fillRect(0, 0, 100, 50); - ctx.scale(1000, 1000); - ctx.strokeStyle = '#0f0'; - ctx.lineWidth = 0.055; - ctx.beginPath(); - ctx.moveTo(-2, 3.1); - ctx.bezierCurveTo(-2, -1, 2.1, -1, 2.1, 3.1); - ctx.stroke(); - //verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 1,1, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 98,1, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 1,48, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 98,48, 0,255,0,255)); - - ctx.reset(); - ctx.fillStyle = '#f00'; - ctx.fillRect(0, 0, 100, 50); - ctx.strokeStyle = '#0f0'; - ctx.lineWidth = 55; - ctx.beginPath(); - ctx.moveTo(-2000, 3100); - ctx.bezierCurveTo(-2000, -1000, 2100, -1000, 2100, 3100); - ctx.stroke(); - verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); - verify(Helper.comparePixel(ctx, 1,1, 0,255,0,255)); - verify(Helper.comparePixel(ctx, 98,1, 0,255,0,255)); - verify(Helper.comparePixel(ctx, 1,48, 0,255,0,255)); - verify(Helper.comparePixel(ctx, 98,48, 0,255,0,255)); - - } - function test_quadraticCurveTo() { - var ctx = canvas.getContext('2d'); - ctx.reset(); - ctx.fillStyle = '#f00'; - ctx.fillRect(0, 0, 100, 50); - ctx.strokeStyle = '#0f0'; - ctx.lineWidth = 50; - ctx.beginPath(); - ctx.moveTo(0, 25); - ctx.quadraticCurveTo(100, 25, 100, 25); - ctx.stroke(); - verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); - - ctx.reset(); - ctx.fillStyle = '#0f0'; - ctx.fillRect(0, 0, 100, 50); - ctx.strokeStyle = '#f00'; - ctx.lineWidth = 50; - ctx.beginPath(); - ctx.quadraticCurveTo(100, 50, 200, 50); - ctx.stroke(); - //verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 95,45, 0,255,0,255)); - - ctx.reset(); - ctx.fillStyle = '#f00'; - ctx.fillRect(0, 0, 100, 50); - ctx.strokeStyle = '#0f0'; - ctx.lineWidth = 50; - ctx.beginPath(); - ctx.quadraticCurveTo(0, 25, 100, 25); - ctx.stroke(); - verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 5,45, 0,255,0,255)); - - ctx.reset(); - ctx.moveTo(0, 0); - ctx.lineTo(100, 0); - ctx.quadraticCurveTo(Infinity, 50, 0, 50); - ctx.quadraticCurveTo(-Infinity, 50, 0, 50); - ctx.quadraticCurveTo(NaN, 50, 0, 50); - ctx.quadraticCurveTo(0, Infinity, 0, 50); - ctx.quadraticCurveTo(0, -Infinity, 0, 50); - ctx.quadraticCurveTo(0, NaN, 0, 50); - ctx.quadraticCurveTo(0, 50, Infinity, 50); - ctx.quadraticCurveTo(0, 50, -Infinity, 50); - ctx.quadraticCurveTo(0, 50, NaN, 50); - ctx.quadraticCurveTo(0, 50, 0, Infinity); - ctx.quadraticCurveTo(0, 50, 0, -Infinity); - ctx.quadraticCurveTo(0, 50, 0, NaN); - ctx.quadraticCurveTo(Infinity, Infinity, 0, 50); - ctx.quadraticCurveTo(Infinity, Infinity, Infinity, 50); - ctx.quadraticCurveTo(Infinity, Infinity, Infinity, Infinity); - ctx.quadraticCurveTo(Infinity, Infinity, 0, Infinity); - ctx.quadraticCurveTo(Infinity, 50, Infinity, 50); - ctx.quadraticCurveTo(Infinity, 50, Infinity, Infinity); - ctx.quadraticCurveTo(Infinity, 50, 0, Infinity); - ctx.quadraticCurveTo(0, Infinity, Infinity, 50); - ctx.quadraticCurveTo(0, Infinity, Infinity, Infinity); - ctx.quadraticCurveTo(0, Infinity, 0, Infinity); - ctx.quadraticCurveTo(0, 50, Infinity, Infinity); - ctx.lineTo(100, 50); - ctx.lineTo(0, 50); - ctx.fillStyle = '#0f0'; - ctx.fill(); - verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); - verify(Helper.comparePixel(ctx, 90,45, 0,255,0,255)); - - ctx.reset(); - ctx.fillStyle = '#f00'; - ctx.fillRect(0, 0, 100, 50); - ctx.scale(1000, 1000); - ctx.strokeStyle = '#0f0'; - ctx.lineWidth = 0.055; - ctx.beginPath(); - ctx.moveTo(-1, 1.05); - ctx.quadraticCurveTo(0, -1, 1.2, 1.05); - ctx.stroke(); - //verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 1,1, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 98,1, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 1,48, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 98,48, 0,255,0,255)); - - ctx.reset(); - ctx.fillStyle = '#f00'; - ctx.fillRect(0, 0, 100, 50); - ctx.strokeStyle = '#0f0'; - ctx.lineWidth = 55; - ctx.beginPath(); - ctx.moveTo(-1000, 1050); - ctx.quadraticCurveTo(0, -1000, 1200, 1050); - ctx.stroke(); - verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 1,1, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 98,1, 0,255,0,255)); - verify(Helper.comparePixel(ctx, 1,48, 0,255,0,255)); - verify(Helper.comparePixel(ctx, 98,48, 0,255,0,255)); - } - function test_rect() { - var ctx = canvas.getContext('2d'); - ctx.reset(); - - ctx.fillStyle = '#f00'; - ctx.fillRect(0, 0, 100, 50); - ctx.fillStyle = '#0f0'; - ctx.rect(0, 0, 100, 50); - ctx.fill(); - verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); - - ctx.reset(); - ctx.fillStyle = '#f00'; - ctx.fillRect(0, 0, 100, 50); - ctx.strokeStyle = '#0f0'; - ctx.lineWidth = 200; - ctx.lineJoin = 'miter'; - ctx.rect(100, 50, 100, 100); - ctx.stroke(); - verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); - - ctx.reset(); - ctx.fillStyle = '#f00'; - ctx.fillRect(0, 0, 100, 50); - ctx.strokeStyle = '#0f0'; - ctx.lineWidth = 100; - ctx.rect(200, 100, 400, 1000); - ctx.lineTo(-2000, -1000); - ctx.stroke(); - verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); - - ctx.reset(); - ctx.fillStyle = '#f00'; - ctx.fillRect(0, 0, 100, 50); - ctx.strokeStyle = '#0f0'; - ctx.lineWidth = 450; - ctx.lineCap = 'round'; - ctx.lineJoin = 'bevel'; - ctx.rect(150, 150, 2000, 2000); - ctx.lineTo(160, 160); - ctx.stroke(); - verify(Helper.comparePixel(ctx, 1,1, 0,255,0,255)); - verify(Helper.comparePixel(ctx, 98,1, 0,255,0,255)); - verify(Helper.comparePixel(ctx, 1,48, 0,255,0,255)); - verify(Helper.comparePixel(ctx, 98,48, 0,255,0,255)); - - ctx.reset(); - ctx.fillStyle = '#f00'; - ctx.fillRect(0, 0, 100, 50); - ctx.beginPath(); - ctx.fillStyle = '#0f0'; - ctx.rect(0, 0, 50, 25); - ctx.rect(100, 0, -50, 25); - ctx.rect(0, 50, 50, -25); - ctx.rect(100, 50, -50, -25); - ctx.fill(); - verify(Helper.comparePixel(ctx, 25,12, 0,255,0,255)); - verify(Helper.comparePixel(ctx, 75,12, 0,255,0,255)); - verify(Helper.comparePixel(ctx, 25,37, 0,255,0,255)); - verify(Helper.comparePixel(ctx, 75,37, 0,255,0,255)); - - ctx.reset(); - ctx.fillStyle = '#0f0'; - ctx.fillRect(0, 0, 100, 50); - ctx.beginPath(); - ctx.strokeStyle = '#f00'; - ctx.lineWidth = 50; - ctx.moveTo(-100, 25); - ctx.lineTo(-50, 25); - ctx.rect(200, 25, 1, 1); - ctx.stroke(); - verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); - - - ctx.reset(); - ctx.moveTo(0, 0); - ctx.lineTo(100, 0); - ctx.rect(Infinity, 50, 1, 1); - ctx.rect(-Infinity, 50, 1, 1); - ctx.rect(NaN, 50, 1, 1); - ctx.rect(0, Infinity, 1, 1); - ctx.rect(0, -Infinity, 1, 1); - ctx.rect(0, NaN, 1, 1); - ctx.rect(0, 50, Infinity, 1); - ctx.rect(0, 50, -Infinity, 1); - ctx.rect(0, 50, NaN, 1); - ctx.rect(0, 50, 1, Infinity); - ctx.rect(0, 50, 1, -Infinity); - ctx.rect(0, 50, 1, NaN); - ctx.rect(Infinity, Infinity, 1, 1); - ctx.rect(Infinity, Infinity, Infinity, 1); - ctx.rect(Infinity, Infinity, Infinity, Infinity); - ctx.rect(Infinity, Infinity, 1, Infinity); - ctx.rect(Infinity, 50, Infinity, 1); - ctx.rect(Infinity, 50, Infinity, Infinity); - ctx.rect(Infinity, 50, 1, Infinity); - ctx.rect(0, Infinity, Infinity, 1); - ctx.rect(0, Infinity, Infinity, Infinity); - ctx.rect(0, Infinity, 1, Infinity); - ctx.rect(0, 50, Infinity, Infinity); - ctx.lineTo(100, 50); - ctx.lineTo(0, 50); - ctx.fillStyle = '#0f0'; - ctx.fill(); - //verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); - //verify(Helper.comparePixel(ctx, 90,45, 0,255,0,255)); - - - ctx.reset(); - ctx.fillStyle = '#f00'; - ctx.fillRect(0, 0, 100, 50); - ctx.strokeStyle = '#0f0'; - ctx.lineWidth = 90; - ctx.beginPath(); - ctx.rect(45, 20, 10, 10); - ctx.stroke(); - verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); - - ctx.reset(); - ctx.fillStyle = '#0f0'; - ctx.fillRect(0, 0, 100, 50); - ctx.beginPath(); - ctx.fillStyle = '#f00'; - ctx.rect(0, 0, 50, 50); - ctx.rect(100, 50, -50, -50); - ctx.rect(0, 25, 100, -25); - ctx.rect(100, 25, -100, 25); - ctx.fill(); - verify(Helper.comparePixel(ctx, 25,12, 0,255,0,255)); - verify(Helper.comparePixel(ctx, 75,12, 0,255,0,255)); - verify(Helper.comparePixel(ctx, 25,37, 0,255,0,255)); - verify(Helper.comparePixel(ctx, 75,37, 0,255,0,255)); - - ctx.reset(); - ctx.fillStyle = '#f00'; - ctx.fillRect(0, 0, 100, 50); - ctx.strokeStyle = '#0f0'; - ctx.lineWidth = 100; - ctx.beginPath(); - ctx.rect(0, 50, 100, 0); - ctx.stroke(); - verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); - - ctx.reset(); - ctx.fillStyle = '#f00'; - ctx.fillRect(0, 0, 100, 50); - ctx.strokeStyle = '#0f0'; - ctx.lineWidth = 100; - ctx.beginPath(); - ctx.rect(50, -100, 0, 250); - ctx.stroke(); - verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); - - ctx.reset(); - ctx.fillStyle = '#0f0'; - ctx.fillRect(0, 0, 100, 50); - ctx.strokeStyle = '#f00'; - ctx.lineWidth = 100; - ctx.beginPath(); - ctx.rect(50, 25, 0, 0); - ctx.stroke(); - verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); - - ctx.reset(); - ctx.fillStyle = '#f00'; - ctx.fillRect(0, 0, 100, 50); - ctx.strokeStyle = '#0f0'; - ctx.lineWidth = 50; - ctx.rect(100, 25, 0, 0); - ctx.lineTo(0, 25); - ctx.stroke(); - verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); - - ctx.reset(); - ctx.fillStyle = '#0f0'; - ctx.fillRect(0, 0, 100, 50); - ctx.strokeStyle = '#f00'; - ctx.lineWidth = 50; - ctx.moveTo(0, 0); - ctx.rect(100, 25, 0, 0); - ctx.stroke(); - verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); - - ctx.reset(); - ctx.fillStyle = '#0f0'; - ctx.fillRect(0, 0, 100, 50); - ctx.strokeStyle = '#f00'; - ctx.lineJoin = 'miter'; - ctx.miterLimit = 1.5; - ctx.lineWidth = 200; - ctx.beginPath(); - ctx.rect(100, 25, 1000, 0); - ctx.stroke(); - //verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); - } - - function test_clearRect() { - var ctx = canvas.getContext('2d'); - ctx.reset(); - ctx.fillStyle = '#0f0'; - ctx.beginPath(); - ctx.rect(0, 0, 100, 50); - ctx.clearRect(0, 0, 16, 16); - ctx.fill(); - verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); - } - function test_fillRect() { - var ctx = canvas.getContext('2d'); - ctx.reset(); - ctx.beginPath(); - ctx.rect(0, 0, 100, 50); - ctx.fillStyle = '#f00'; - ctx.fillRect(0, 0, 16, 16); - ctx.fillStyle = '#0f0'; - ctx.fill(); - verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); - } - - function test_strokeRect() { - var ctx = canvas.getContext('2d'); - ctx.reset(); - ctx.beginPath(); - ctx.rect(0, 0, 100, 50); - ctx.strokeStyle = '#f00'; - ctx.lineWidth = 5; - ctx.strokeRect(0, 0, 16, 16); - ctx.fillStyle = '#0f0'; - ctx.fill(); - - verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); - } - function test_transform() { - var ctx = canvas.getContext('2d'); - ctx.reset(); - ctx.fillStyle = '#f00'; - ctx.fillRect(0, 0, 100, 50); - - ctx.translate(-100, 0); - ctx.rect(100, 0, 100, 50); - ctx.translate(0, -100); - ctx.fillStyle = '#0f0'; - ctx.fill(); - - //verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); - - ctx.reset(); - ctx.fillStyle = '#f00'; - ctx.fillRect(0, 0, 100, 50); - ctx.fillStyle = '#0f0'; - ctx.moveTo(0, 0); - ctx.translate(100, 0); - ctx.lineTo(0, 0); - ctx.translate(0, 50); - ctx.lineTo(0, 0); - ctx.translate(-100, 0); - ctx.lineTo(0, 0); - ctx.translate(1000, 1000); - ctx.rotate(Math.PI/2); - ctx.scale(0.1, 0.1); - ctx.fill(); - //verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); - - ctx.reset(); - ctx.fillStyle = '#0f0'; - ctx.fillRect(0, 0, 100, 50); - - ctx.fillStyle = '#f00'; - ctx.translate(-100, 0); - ctx.rect(0, 0, 100, 50); - ctx.fill(); - ctx.translate(100, 0); - ctx.fill(); - - ctx.beginPath(); - ctx.strokeStyle = '#f00'; - ctx.lineWidth = 50; - ctx.translate(0, -50); - ctx.moveTo(0, 25); - ctx.lineTo(100, 25); - ctx.stroke(); - ctx.translate(0, 50); - ctx.stroke(); - verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); - } - } -} diff --git a/tests/auto/qtquick2/qquickcanvasitem/data/tst_pattern.qml b/tests/auto/qtquick2/qquickcanvasitem/data/tst_pattern.qml deleted file mode 100644 index dd5b6628e8..0000000000 --- a/tests/auto/qtquick2/qquickcanvasitem/data/tst_pattern.qml +++ /dev/null @@ -1,34 +0,0 @@ -import QtQuick 2.0 -import QtTest 1.0 -import "testhelper.js" as Helper -Canvas { - id:canvas; width:100;height:50; renderTarget: Canvas.Image - TestCase { - //TODO - name: "pattern"; when: windowShown - function test_basic() { - var ctx = canvas.getContext('2d'); - ctx.reset(); - } - function test_animated() { - var ctx = canvas.getContext('2d'); - ctx.reset(); - } - function test_image() { - var ctx = canvas.getContext('2d'); - ctx.reset(); - } - function test_modified() { - var ctx = canvas.getContext('2d'); - ctx.reset(); - } - function test_paint() { - var ctx = canvas.getContext('2d'); - ctx.reset(); - } - function test_repeat() { - var ctx = canvas.getContext('2d'); - ctx.reset(); - } - } -} diff --git a/tests/auto/qtquick2/qquickcanvasitem/data/tst_pixel.qml b/tests/auto/qtquick2/qquickcanvasitem/data/tst_pixel.qml deleted file mode 100644 index 1a3793d7a3..0000000000 --- a/tests/auto/qtquick2/qquickcanvasitem/data/tst_pixel.qml +++ /dev/null @@ -1,30 +0,0 @@ -import QtQuick 2.0 -import QtTest 1.0 -import "testhelper.js" as Helper -Canvas { - id:canvas; width:100;height:50; renderTarget: Canvas.Image - TestCase { - //TODO - name: "pixel"; when: windowShown - function test_createImageData() { - var ctx = canvas.getContext('2d'); - ctx.reset(); - } - function test_getImageData() { - var ctx = canvas.getContext('2d'); - ctx.reset(); - } - function test_object() { - var ctx = canvas.getContext('2d'); - ctx.reset(); - } - function test_putImageData() { - var ctx = canvas.getContext('2d'); - ctx.reset(); - } - function test_filters() { - var ctx = canvas.getContext('2d'); - ctx.reset(); - } - } -} diff --git a/tests/auto/qtquick2/qquickcanvasitem/data/tst_shadow.qml b/tests/auto/qtquick2/qquickcanvasitem/data/tst_shadow.qml deleted file mode 100644 index 4405ca6c0e..0000000000 --- a/tests/auto/qtquick2/qquickcanvasitem/data/tst_shadow.qml +++ /dev/null @@ -1,59 +0,0 @@ -import QtQuick 2.0 -import QtTest 1.0 -import "testhelper.js" as Helper -Canvas { - id:canvas; width:100;height:50; renderTarget: Canvas.Image - TestCase { - //TODO - - name: "shadow"; when: windowShown - function test_basic() { - var ctx = canvas.getContext('2d'); - ctx.reset(); - } - function test_blur() { - var ctx = canvas.getContext('2d'); - ctx.reset(); - } - - function test_clip() { - var ctx = canvas.getContext('2d'); - ctx.reset(); - } - - function test_composite() { - var ctx = canvas.getContext('2d'); - ctx.reset(); - } - - function test_enable() { - var ctx = canvas.getContext('2d'); - ctx.reset(); - } - - function test_gradient() { - var ctx = canvas.getContext('2d'); - ctx.reset(); - } - function test_image() { - var ctx = canvas.getContext('2d'); - ctx.reset(); - } - function test_offset() { - var ctx = canvas.getContext('2d'); - ctx.reset(); - } - function test_pattern() { - var ctx = canvas.getContext('2d'); - ctx.reset(); - } - function test_stroke() { - var ctx = canvas.getContext('2d'); - ctx.reset(); - } - function test_tranform() { - var ctx = canvas.getContext('2d'); - ctx.reset(); - } - } -} diff --git a/tests/auto/qtquick2/qquickcanvasitem/data/tst_state.qml b/tests/auto/qtquick2/qquickcanvasitem/data/tst_state.qml deleted file mode 100644 index 8042cf6a1d..0000000000 --- a/tests/auto/qtquick2/qquickcanvasitem/data/tst_state.qml +++ /dev/null @@ -1,390 +0,0 @@ -import QtQuick 2.0 -import QtTest 1.0 -import "testhelper.js" as Helper -Canvas { - id:canvas; width:100;height:50; renderTarget: Canvas.Image - TestCase { - id:testCase - name: "state"; when: windowShown - function test_bitmap() { - var ctx = canvas.getContext('2d'); - ctx.reset(); - ctx.fillStyle = '#f00'; - ctx.fillRect(0, 0, 100, 50); - ctx.save(); - ctx.fillStyle = '#0f0'; - ctx.fillRect(0, 0, 100, 50); - ctx.restore(); - verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); - } - function test_clip() { - var ctx = canvas.getContext('2d'); - ctx.reset(); - - ctx.fillStyle = '#f00'; - ctx.fillRect(0, 0, 100, 50); - ctx.save(); - ctx.rect(0, 0, 1, 1); - ctx.clip(); - ctx.restore(); - ctx.fillStyle = '#0f0'; - ctx.fillRect(0, 0, 100, 50); - //verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); - - } - function test_fillStyle() { - var ctx = canvas.getContext('2d'); - ctx.reset(); - // Test that restore() undoes any modifications - var old = ctx.fillStyle; - ctx.save(); - ctx.fillStyle = "#ff0000"; - ctx.restore(); - compare(ctx.fillStyle, old); - - // Also test that save() doesn't modify the values - ctx.fillStyle = "#ff0000"; - old = ctx.fillStyle; - // we're not interested in failures caused by get(set(x)) != x (e.g. - // from rounding), so compare against 'old' instead of against "#ff0000" - ctx.save(); - compare(ctx.fillStyle, old); - ctx.restore(); - } - function test_font() { - var ctx = canvas.getContext('2d'); - ctx.reset(); - - // Test that restore() undoes any modifications - var old = ctx.font; - ctx.save(); - ctx.font = "25px serif"; - ctx.restore(); - compare(ctx.font, old); - - // Also test that save() doesn't modify the values - ctx.font = "25px serif"; - old = ctx.font; - // we're not interested in failures caused by get(set(x)) != x (e.g. - // from rounding), so compare against 'old' instead of against "25px serif" - ctx.save(); - compare(ctx.font, old); - ctx.restore(); - } - function test_globalAlpha() { - var ctx = canvas.getContext('2d'); - ctx.reset(); - - // Test that restore() undoes any modifications - var old = ctx.globalAlpha; - ctx.save(); - ctx.globalAlpha = 0.5; - ctx.restore(); - compare(ctx.globalAlpha, old); - - // Also test that save() doesn't modify the values - ctx.globalAlpha = 0.5; - old = ctx.globalAlpha; - // we're not interested in failures caused by get(set(x)) != x (e.g. - // from rounding), so compare against 'old' instead of against 0.5 - ctx.save(); - compare(ctx.globalAlpha, old); - ctx.restore(); - } - function test_globalCompositeOperation() { - var ctx = canvas.getContext('2d'); - ctx.reset(); - - // Test that restore() undoes any modifications - var old = ctx.globalCompositeOperation; - ctx.save(); - ctx.globalCompositeOperation = "copy"; - ctx.restore(); - compare(ctx.globalCompositeOperation, old); - - // Also test that save() doesn't modify the values - ctx.globalCompositeOperation = "copy"; - old = ctx.globalCompositeOperation; - // we're not interested in failures caused by get(set(x)) != x (e.g. - // from rounding), so compare against 'old' instead of against "copy" - ctx.save(); - compare(ctx.globalCompositeOperation, old); - ctx.restore(); - } - function test_lineCap() { - var ctx = canvas.getContext('2d'); - ctx.reset(); - - // Test that restore() undoes any modifications - var old = ctx.lineCap; - ctx.save(); - ctx.lineCap = "round"; - ctx.restore(); - compare(ctx.lineCap, old); - - // Also test that save() doesn't modify the values - ctx.lineCap = "round"; - old = ctx.lineCap; - // we're not interested in failures caused by get(set(x)) != x (e.g. - // from rounding), so compare against 'old' instead of against "round" - ctx.save(); - compare(ctx.lineCap, old); - ctx.restore(); - } - function test_lineJoin() { - var ctx = canvas.getContext('2d'); - ctx.reset(); - - // Test that restore() undoes any modifications - var old = ctx.lineJoin; - ctx.save(); - ctx.lineJoin = "round"; - ctx.restore(); - compare(ctx.lineJoin, old); - - // Also test that save() doesn't modify the values - ctx.lineJoin = "round"; - old = ctx.lineJoin; - // we're not interested in failures caused by get(set(x)) != x (e.g. - // from rounding), so compare against 'old' instead of against "round" - ctx.save(); - compare(ctx.lineJoin, old); - ctx.restore(); - } - function test_lineWidth() { - var ctx = canvas.getContext('2d'); - ctx.reset(); - - // Test that restore() undoes any modifications - var old = ctx.lineJoin; - ctx.save(); - ctx.lineJoin = "round"; - ctx.restore(); - compare(ctx.lineJoin, old, "ctx.lineJoin", "old"); - - // Also test that save() doesn't modify the values - ctx.lineJoin = "round"; - old = ctx.lineJoin; - // we're not interested in failures caused by get(set(x)) != x (e.g. - // from rounding), so compare against 'old' instead of against "round" - ctx.save(); - compare(ctx.lineJoin, old); - ctx.restore(); - } - function test_miterLimit() { - var ctx = canvas.getContext('2d'); - ctx.reset(); - - // Test that restore() undoes any modifications - var old = ctx.miterLimit; - ctx.save(); - ctx.miterLimit = 0.5; - ctx.restore(); - compare(ctx.miterLimit, old); - - // Also test that save() doesn't modify the values - ctx.miterLimit = 0.5; - old = ctx.miterLimit; - // we're not interested in failures caused by get(set(x)) != x (e.g. - // from rounding), so compare against 'old' instead of against 0.5 - ctx.save(); - compare(ctx.miterLimit, old); - ctx.restore(); - } - function test_path() { - var ctx = canvas.getContext('2d'); - ctx.reset(); - - ctx.fillStyle = '#f00'; - ctx.fillRect(0, 0, 100, 50); - ctx.save(); - ctx.rect(0, 0, 100, 50); - ctx.restore(); - ctx.fillStyle = '#0f0'; - ctx.fill(); - verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); - } - function test_shadow() { - var ctx = canvas.getContext('2d'); - ctx.reset(); - - // Test that restore() undoes any modifications - var old = ctx.shadowBlur; - ctx.save(); - ctx.shadowBlur = 5; - ctx.restore(); - compare(ctx.shadowBlur, old); - - // Also test that save() doesn't modify the values - ctx.shadowBlur = 5; - old = ctx.shadowBlur; - // we're not interested in failures caused by get(set(x)) != x (e.g. - // from rounding), so compare against 'old' instead of against 5 - ctx.save(); - compare(ctx.shadowBlur, old); - ctx.restore(); - - // Test that restore() undoes any modifications - var old = ctx.shadowColor; - ctx.save(); - ctx.shadowColor = "#ff0000"; - ctx.restore(); - compare(ctx.shadowColor, old); - - // Also test that save() doesn't modify the values - ctx.shadowColor = "#ff0000"; - old = ctx.shadowColor; - // we're not interested in failures caused by get(set(x)) != x (e.g. - // from rounding), so compare against 'old' instead of against "#ff0000" - ctx.save(); - compare(ctx.shadowColor, old); - ctx.restore(); - - // Test that restore() undoes any modifications - var old = ctx.shadowOffsetX; - ctx.save(); - ctx.shadowOffsetX = 5; - ctx.restore(); - compare(ctx.shadowOffsetX, old); - - // Also test that save() doesn't modify the values - ctx.shadowOffsetX = 5; - old = ctx.shadowOffsetX; - // we're not interested in failures caused by get(set(x)) != x (e.g. - // from rounding), so compare against 'old' instead of against 5 - ctx.save(); - compare(ctx.shadowOffsetX, old); - ctx.restore(); - - // Test that restore() undoes any modifications - var old = ctx.shadowOffsetY; - ctx.save(); - ctx.shadowOffsetY = 5; - ctx.restore(); - compare(ctx.shadowOffsetY, old); - - // Also test that save() doesn't modify the values - ctx.shadowOffsetY = 5; - old = ctx.shadowOffsetY; - // we're not interested in failures caused by get(set(x)) != x (e.g. - // from rounding), so compare against 'old' instead of against 5 - ctx.save(); - compare(ctx.shadowOffsetY, old); - ctx.restore(); - - } - function test_stack() { - var ctx = canvas.getContext('2d'); - ctx.reset(); - - ctx.lineWidth = 1; - ctx.save(); - ctx.lineWidth = 2; - ctx.save(); - ctx.lineWidth = 3; - compare(ctx.lineWidth, 3); - ctx.restore(); - compare(ctx.lineWidth, 2); - ctx.restore(); - compare(ctx.lineWidth, 1); - - var limit = 512; - for (var i = 1; i < limit; ++i) - { - ctx.save(); - ctx.lineWidth = i; - } - for (var i = limit-1; i > 0; --i) - { - testCase.compare(ctx.lineWidth, i); //strange javascript error here - ctx.restore(); - } - - for (var i = 0; i < 16; ++i) - ctx.restore(); - ctx.lineWidth = 0.5; - ctx.restore(); - compare(ctx.lineWidth, 0.5); - - } - function test_strokeStyle() { - var ctx = canvas.getContext('2d'); - ctx.reset(); - - // Test that restore() undoes any modifications - var old = ctx.strokeStyle; - ctx.save(); - ctx.strokeStyle = "#ff0000"; - ctx.restore(); - compare(ctx.strokeStyle, old); - - // Also test that save() doesn't modify the values - ctx.strokeStyle = "#ff0000"; - old = ctx.strokeStyle; - // we're not interested in failures caused by get(set(x)) != x (e.g. - // from rounding), so compare against 'old' instead of against "#ff0000" - ctx.save(); - compare(ctx.strokeStyle, old); - ctx.restore(); - - - } - - function test_text() { - var ctx = canvas.getContext('2d'); - ctx.reset(); - - // Test that restore() undoes any modifications - var old = ctx.textAlign; - ctx.save(); - ctx.textAlign = "center"; - ctx.restore(); - compare(ctx.textAlign, old); - - // Also test that save() doesn't modify the values - ctx.textAlign = "center"; - old = ctx.textAlign; - // we're not interested in failures caused by get(set(x)) != x (e.g. - // from rounding), so compare against 'old' instead of against "center" - ctx.save(); - compare(ctx.textAlign, old); - ctx.restore(); - - // Test that restore() undoes any modifications - var old = ctx.textBaseline; - ctx.save(); - ctx.textBaseline = "bottom"; - ctx.restore(); - compare(ctx.textBaseline, old); - - // Also test that save() doesn't modify the values - ctx.textBaseline = "bottom"; - old = ctx.textBaseline; - // we're not interested in failures caused by get(set(x)) != x (e.g. - // from rounding), so compare against 'old' instead of against "bottom" - ctx.save(); - compare(ctx.textBaseline, old); - ctx.restore(); - - - } - - function test_transform() { - var ctx = canvas.getContext('2d'); - ctx.reset(); - - ctx.fillStyle = '#0f0'; - ctx.fillRect(0, 0, 100, 50); - ctx.save(); - ctx.translate(200, 0); - ctx.restore(); - ctx.fillStyle = '#f00'; - ctx.fillRect(-200, 0, 100, 50); - verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); - - - } - - - } -} diff --git a/tests/auto/qtquick2/qquickcanvasitem/data/tst_strokeStyle.qml b/tests/auto/qtquick2/qquickcanvasitem/data/tst_strokeStyle.qml deleted file mode 100644 index 6b42f8a770..0000000000 --- a/tests/auto/qtquick2/qquickcanvasitem/data/tst_strokeStyle.qml +++ /dev/null @@ -1,48 +0,0 @@ -import QtQuick 2.0 -import QtTest 1.0 -import "testhelper.js" as Helper - -Canvas { - id:canvas; width:100;height:50; renderTarget:Canvas.Image - TestCase { - name: "strokeStyle"; when: windowShown - function test_default() { - var ctx = canvas.getContext('2d'); - ctx.reset(); - compare(ctx.strokeStyle, "#000000") - ctx.clearRect(0, 0, 1, 1); - compare(ctx.strokeStyle, "#000000") - } - function test_saverestore() { - var ctx = canvas.getContext('2d'); - var old = ctx.strokeStyle; - ctx.save(); - ctx.strokeStyle = "#ffaaff"; - ctx.restore(); - compare(ctx.strokeStyle, old); - - ctx.strokeStyle = "#ffcc88"; - old = ctx.strokeStyle; - ctx.save(); - compare(ctx.strokeStyle, old); - ctx.restore(); - } - function test_namedColor() { - var ctx = canvas.getContext('2d'); - ctx.reset(); - ctx.strokeStyle = "red"; - ctx.strokeRect(0,0,1,1); - verify(Helper.comparePixel(ctx,0,0,255,0,0,255)); - - ctx.strokeStyle = "black"; - ctx.strokeRect(0,0,1,1); - verify(Helper.comparePixel(ctx,0,0,0,0,0,255)); - - ctx.strokeStyle = "white"; - ctx.strokeRect(0,0,1,1); - verify(Helper.comparePixel(ctx,0,0,255,255,255,255)); - } - - - } -} diff --git a/tests/auto/qtquick2/qquickcanvasitem/data/tst_text.qml b/tests/auto/qtquick2/qquickcanvasitem/data/tst_text.qml deleted file mode 100644 index baeb17c9fb..0000000000 --- a/tests/auto/qtquick2/qquickcanvasitem/data/tst_text.qml +++ /dev/null @@ -1,34 +0,0 @@ -import QtQuick 2.0 -import QtTest 1.0 -import "testhelper.js" as Helper -Canvas { - id:canvas; width:100;height:50; renderTarget: Canvas.Image - TestCase { - //TODO - name: "text"; when: windowShown - function test_baseLine() { - var ctx = canvas.getContext('2d'); - ctx.reset(); - } - function test_align() { - var ctx = canvas.getContext('2d'); - ctx.reset(); - } - function test_stroke() { - var ctx = canvas.getContext('2d'); - ctx.reset(); - } - function test_fill() { - var ctx = canvas.getContext('2d'); - ctx.reset(); - } - function test_font() { - var ctx = canvas.getContext('2d'); - ctx.reset(); - } - function test_measure() { - var ctx = canvas.getContext('2d'); - ctx.reset(); - } - } -} diff --git a/tests/auto/qtquick2/qquickcanvasitem/data/tst_transform.qml b/tests/auto/qtquick2/qquickcanvasitem/data/tst_transform.qml deleted file mode 100644 index 834a22f549..0000000000 --- a/tests/auto/qtquick2/qquickcanvasitem/data/tst_transform.qml +++ /dev/null @@ -1,487 +0,0 @@ -import QtQuick 2.0 -import QtTest 1.0 -import "testhelper.js" as Helper -Canvas { - id:canvas; width:100;height:50; renderTarget: Canvas.Image - TestCase { - name: "transform"; when: windowShown - function test_order() { - var ctx = canvas.getContext('2d'); - ctx.reset(); - ctx.fillStyle = '#f00'; - ctx.fillRect(0, 0, 100, 50); - - ctx.scale(2, 1); - ctx.rotate(Math.PI / 2); - ctx.fillStyle = '#0f0'; - ctx.fillRect(0, -50, 50, 50); - verify(Helper.comparePixel(ctx, 75,25, 0,255,0,255)); - } - function test_rotate() { - var ctx = canvas.getContext('2d'); - ctx.reset(); - ctx.fillStyle = '#f00'; - ctx.fillRect(0, 0, 100, 50); - - ctx.rotate(Math.PI / 2); - ctx.fillStyle = '#0f0'; - ctx.fillRect(0, -100, 50, 100); - verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); - ctx.reset(); - - ctx.fillStyle = '#f00'; - ctx.fillRect(0, 0, 100, 50); - - ctx.translate(100, 10); - ctx.rotate(Infinity); - ctx.rotate(-Infinity); - ctx.rotate(NaN); - - ctx.fillStyle = '#0f0'; - ctx.fillRect(-100, -10, 100, 50); - - verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); - ctx.reset(); - - ctx.fillStyle = '#f00'; - ctx.fillRect(0, 0, 100, 50); - - ctx.rotate(Math.PI); // should fail obviously if this is 3.1 degrees - ctx.fillStyle = '#0f0'; - ctx.fillRect(-100, -50, 100, 50); - verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); - ctx.reset(); - - ctx.fillStyle = '#f00'; - ctx.fillRect(0, 0, 100, 50); - - ctx.rotate(Math.PI * (1 + 4096)); // == pi (mod 2*pi) - // We need about pi +/- 0.001 in order to get correct-looking results - // 32-bit floats can store pi*4097 with precision 2^-10, so that should - // be safe enough on reasonable implementations - ctx.fillStyle = '#0f0'; - ctx.fillRect(-100, -50, 100, 50); - verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); - verify(Helper.comparePixel(ctx, 98,2, 0,255,0,255)); - verify(Helper.comparePixel(ctx, 98,47, 0,255,0,255)); - ctx.reset(); - - ctx.fillStyle = '#f00'; - ctx.fillRect(0, 0, 100, 50); - - ctx.rotate(-Math.PI * (1 + 4096)); - ctx.fillStyle = '#0f0'; - ctx.fillRect(-100, -50, 100, 50); - verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); - verify(Helper.comparePixel(ctx, 98,2, 0,255,0,255)); - verify(Helper.comparePixel(ctx, 98,47, 0,255,0,255)); - ctx.reset(); - - ctx.fillStyle = '#f00'; - ctx.fillRect(0, 0, 100, 50); - - ctx.rotate(0); - ctx.fillStyle = '#0f0'; - ctx.fillRect(0, 0, 100, 50); - verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); - - - } - function test_scale() { - var ctx = canvas.getContext('2d'); - ctx.reset(); - - ctx.fillStyle = '#f00'; - ctx.fillRect(0, 0, 100, 50); - - ctx.scale(2, 4); - ctx.fillStyle = '#0f0'; - ctx.fillRect(0, 0, 50, 12.5); - verify(Helper.comparePixel(ctx, 90,40, 0,255,0,255)); - ctx.reset(); - - ctx.fillStyle = '#f00'; - ctx.fillRect(0, 0, 100, 50); - - ctx.scale(1e5, 1e5); - ctx.fillStyle = '#0f0'; - ctx.fillRect(0, 0, 1, 1); - verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); - ctx.reset(); - - ctx.fillStyle = '#f00'; - ctx.fillRect(0, 0, 100, 50); - - ctx.scale(Math.sqrt(2), Math.sqrt(2)); - ctx.scale(Math.sqrt(2), Math.sqrt(2)); - ctx.fillStyle = '#0f0'; - ctx.fillRect(0, 0, 50, 25); - verify(Helper.comparePixel(ctx, 90,40, 0,255,0,255)); - ctx.reset(); - - ctx.fillStyle = '#f00'; - ctx.fillRect(0, 0, 100, 50); - - ctx.save(); - ctx.scale(-1, 1); - ctx.fillStyle = '#0f0'; - ctx.fillRect(-50, 0, 50, 50); - ctx.restore(); - - ctx.save(); - ctx.scale(1, -1); - ctx.fillStyle = '#0f0'; - ctx.fillRect(50, -50, 50, 50); - ctx.restore(); - verify(Helper.comparePixel(ctx, 25,25, 0,255,0,255)); - verify(Helper.comparePixel(ctx, 75,25, 0,255,0,255)); - ctx.reset(); - - ctx.fillStyle = '#f00'; - ctx.fillRect(0, 0, 100, 50); - - ctx.translate(100, 10); - ctx.scale(Infinity, 0.1); - ctx.scale(-Infinity, 0.1); - ctx.scale(NaN, 0.1); - ctx.scale(0.1, Infinity); - ctx.scale(0.1, -Infinity); - ctx.scale(0.1, NaN); - ctx.scale(Infinity, Infinity); - - ctx.fillStyle = '#0f0'; - ctx.fillRect(-100, -10, 100, 50); - - verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); - ctx.reset(); - - ctx.fillStyle = '#0f0'; - ctx.fillRect(0, 0, 100, 50); - - ctx.save(); - ctx.translate(50, 0); - ctx.scale(0, 1); - ctx.fillStyle = '#f00'; - ctx.fillRect(0, 0, 100, 50); - ctx.restore(); - - ctx.save(); - ctx.translate(0, 25); - ctx.scale(1, 0); - ctx.fillStyle = '#f00'; - ctx.fillRect(0, 0, 100, 50); - ctx.restore(); - - // Firefox has a bug where it renders the canvas as empty and toDataURL throws an exception - canvas.toDataURL(); - - verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); - } - function test_setTransform() { - var ctx = canvas.getContext('2d'); - ctx.reset(); - ctx.fillStyle = '#f00'; - ctx.fillRect(0, 0, 100, 50); - - ctx.setTransform(1/2,0, 0,1/2, 0,0); - ctx.setTransform(2,0, 0,2, 0,0); - ctx.fillStyle = '#0f0'; - ctx.fillRect(0, 0, 50, 25); - verify(Helper.comparePixel(ctx, 75,35, 0,255,0,255)); - ctx.reset(); - - ctx.fillStyle = '#f00'; - ctx.fillRect(0, 0, 100, 50); - - ctx.translate(100, 10); - ctx.setTransform(Infinity, 0, 0, 0, 0, 0); - ctx.setTransform(-Infinity, 0, 0, 0, 0, 0); - ctx.setTransform(NaN, 0, 0, 0, 0, 0); - ctx.setTransform(0, Infinity, 0, 0, 0, 0); - ctx.setTransform(0, -Infinity, 0, 0, 0, 0); - ctx.setTransform(0, NaN, 0, 0, 0, 0); - ctx.setTransform(0, 0, Infinity, 0, 0, 0); - ctx.setTransform(0, 0, -Infinity, 0, 0, 0); - ctx.setTransform(0, 0, NaN, 0, 0, 0); - ctx.setTransform(0, 0, 0, Infinity, 0, 0); - ctx.setTransform(0, 0, 0, -Infinity, 0, 0); - ctx.setTransform(0, 0, 0, NaN, 0, 0); - ctx.setTransform(0, 0, 0, 0, Infinity, 0); - ctx.setTransform(0, 0, 0, 0, -Infinity, 0); - ctx.setTransform(0, 0, 0, 0, NaN, 0); - ctx.setTransform(0, 0, 0, 0, 0, Infinity); - ctx.setTransform(0, 0, 0, 0, 0, -Infinity); - ctx.setTransform(0, 0, 0, 0, 0, NaN); - ctx.setTransform(Infinity, Infinity, 0, 0, 0, 0); - ctx.setTransform(Infinity, Infinity, Infinity, 0, 0, 0); - ctx.setTransform(Infinity, Infinity, Infinity, Infinity, 0, 0); - ctx.setTransform(Infinity, Infinity, Infinity, Infinity, Infinity, 0); - ctx.setTransform(Infinity, Infinity, Infinity, Infinity, Infinity, Infinity); - ctx.setTransform(Infinity, Infinity, Infinity, Infinity, 0, Infinity); - ctx.setTransform(Infinity, Infinity, Infinity, 0, Infinity, 0); - ctx.setTransform(Infinity, Infinity, Infinity, 0, Infinity, Infinity); - ctx.setTransform(Infinity, Infinity, Infinity, 0, 0, Infinity); - ctx.setTransform(Infinity, Infinity, 0, Infinity, 0, 0); - ctx.setTransform(Infinity, Infinity, 0, Infinity, Infinity, 0); - ctx.setTransform(Infinity, Infinity, 0, Infinity, Infinity, Infinity); - ctx.setTransform(Infinity, Infinity, 0, Infinity, 0, Infinity); - ctx.setTransform(Infinity, Infinity, 0, 0, Infinity, 0); - ctx.setTransform(Infinity, Infinity, 0, 0, Infinity, Infinity); - ctx.setTransform(Infinity, Infinity, 0, 0, 0, Infinity); - ctx.setTransform(Infinity, 0, Infinity, 0, 0, 0); - ctx.setTransform(Infinity, 0, Infinity, Infinity, 0, 0); - ctx.setTransform(Infinity, 0, Infinity, Infinity, Infinity, 0); - ctx.setTransform(Infinity, 0, Infinity, Infinity, Infinity, Infinity); - ctx.setTransform(Infinity, 0, Infinity, Infinity, 0, Infinity); - ctx.setTransform(Infinity, 0, Infinity, 0, Infinity, 0); - ctx.setTransform(Infinity, 0, Infinity, 0, Infinity, Infinity); - ctx.setTransform(Infinity, 0, Infinity, 0, 0, Infinity); - ctx.setTransform(Infinity, 0, 0, Infinity, 0, 0); - ctx.setTransform(Infinity, 0, 0, Infinity, Infinity, 0); - ctx.setTransform(Infinity, 0, 0, Infinity, Infinity, Infinity); - ctx.setTransform(Infinity, 0, 0, Infinity, 0, Infinity); - ctx.setTransform(Infinity, 0, 0, 0, Infinity, 0); - ctx.setTransform(Infinity, 0, 0, 0, Infinity, Infinity); - ctx.setTransform(Infinity, 0, 0, 0, 0, Infinity); - ctx.setTransform(0, Infinity, Infinity, 0, 0, 0); - ctx.setTransform(0, Infinity, Infinity, Infinity, 0, 0); - ctx.setTransform(0, Infinity, Infinity, Infinity, Infinity, 0); - ctx.setTransform(0, Infinity, Infinity, Infinity, Infinity, Infinity); - ctx.setTransform(0, Infinity, Infinity, Infinity, 0, Infinity); - ctx.setTransform(0, Infinity, Infinity, 0, Infinity, 0); - ctx.setTransform(0, Infinity, Infinity, 0, Infinity, Infinity); - ctx.setTransform(0, Infinity, Infinity, 0, 0, Infinity); - ctx.setTransform(0, Infinity, 0, Infinity, 0, 0); - ctx.setTransform(0, Infinity, 0, Infinity, Infinity, 0); - ctx.setTransform(0, Infinity, 0, Infinity, Infinity, Infinity); - ctx.setTransform(0, Infinity, 0, Infinity, 0, Infinity); - ctx.setTransform(0, Infinity, 0, 0, Infinity, 0); - ctx.setTransform(0, Infinity, 0, 0, Infinity, Infinity); - ctx.setTransform(0, Infinity, 0, 0, 0, Infinity); - ctx.setTransform(0, 0, Infinity, Infinity, 0, 0); - ctx.setTransform(0, 0, Infinity, Infinity, Infinity, 0); - ctx.setTransform(0, 0, Infinity, Infinity, Infinity, Infinity); - ctx.setTransform(0, 0, Infinity, Infinity, 0, Infinity); - ctx.setTransform(0, 0, Infinity, 0, Infinity, 0); - ctx.setTransform(0, 0, Infinity, 0, Infinity, Infinity); - ctx.setTransform(0, 0, Infinity, 0, 0, Infinity); - ctx.setTransform(0, 0, 0, Infinity, Infinity, 0); - ctx.setTransform(0, 0, 0, Infinity, Infinity, Infinity); - ctx.setTransform(0, 0, 0, Infinity, 0, Infinity); - ctx.setTransform(0, 0, 0, 0, Infinity, Infinity); - - ctx.fillStyle = '#0f0'; - ctx.fillRect(-100, -10, 100, 50); - - verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); - ctx.reset(); - - // Create green with a red square ring inside it - ctx.fillStyle = '#0f0'; - ctx.fillRect(0, 0, 100, 50); - ctx.fillStyle = '#f00'; - ctx.fillRect(20, 10, 60, 30); - ctx.fillStyle = '#0f0'; - ctx.fillRect(40, 20, 20, 10); - - // Draw a skewed shape to fill that gap, to make sure it is aligned correctly - ctx.setTransform(1,4, 2,3, 5,6); - // Post-transform coordinates: - // [[20,10],[80,10],[80,40],[20,40],[20,10],[40,20],[40,30],[60,30],[60,20],[40,20],[20,10]]; - // Hence pre-transform coordinates: - var pts=[[-7.4,11.2],[-43.4,59.2],[-31.4,53.2],[4.6,5.2],[-7.4,11.2], - [-15.4,25.2],[-11.4,23.2],[-23.4,39.2],[-27.4,41.2],[-15.4,25.2], - [-7.4,11.2]]; - ctx.beginPath(); - ctx.moveTo(pts[0][0], pts[0][1]); - for (var i = 0; i < pts.length; ++i) - ctx.lineTo(pts[i][0], pts[i][1]); - ctx.fill(); - /* - //FIXME: - verify(Helper.comparePixel(ctx, 21,11, 0,255,0,255)); - verify(Helper.comparePixel(ctx, 79,11, 0,255,0,255)); - verify(Helper.comparePixel(ctx, 21,39, 0,255,0,255)); - verify(Helper.comparePixel(ctx, 79,39, 0,255,0,255)); - verify(Helper.comparePixel(ctx, 39,19, 0,255,0,255)); - verify(Helper.comparePixel(ctx, 61,19, 0,255,0,255)); - verify(Helper.comparePixel(ctx, 39,31, 0,255,0,255)); - verify(Helper.comparePixel(ctx, 61,31, 0,255,0,255)); - */ - ctx.reset(); - - ctx.fillStyle = '#f00'; - ctx.fillRect(0, 0, 100, 50); - - ctx.transform(1,0, 0,1, 0,0); - ctx.fillStyle = '#0f0'; - ctx.fillRect(0, 0, 100, 50); - verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); - - } - function test_transform() { - var ctx = canvas.getContext('2d'); - ctx.reset(); - ctx.fillStyle = '#f00'; - ctx.fillRect(0, 0, 100, 50); - - ctx.transform(1,2, 3,4, 5,6); - ctx.transform(-2,1, 3/2,-1/2, 1,-2); - ctx.fillStyle = '#0f0'; - ctx.fillRect(0, 0, 100, 50); - verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); - ctx.reset(); - - ctx.fillStyle = '#f00'; - ctx.fillRect(0, 0, 100, 50); - - ctx.translate(100, 10); - ctx.transform(Infinity, 0, 0, 0, 0, 0); - ctx.transform(-Infinity, 0, 0, 0, 0, 0); - ctx.transform(NaN, 0, 0, 0, 0, 0); - ctx.transform(0, Infinity, 0, 0, 0, 0); - ctx.transform(0, -Infinity, 0, 0, 0, 0); - ctx.transform(0, NaN, 0, 0, 0, 0); - ctx.transform(0, 0, Infinity, 0, 0, 0); - ctx.transform(0, 0, -Infinity, 0, 0, 0); - ctx.transform(0, 0, NaN, 0, 0, 0); - ctx.transform(0, 0, 0, Infinity, 0, 0); - ctx.transform(0, 0, 0, -Infinity, 0, 0); - ctx.transform(0, 0, 0, NaN, 0, 0); - ctx.transform(0, 0, 0, 0, Infinity, 0); - ctx.transform(0, 0, 0, 0, -Infinity, 0); - ctx.transform(0, 0, 0, 0, NaN, 0); - ctx.transform(0, 0, 0, 0, 0, Infinity); - ctx.transform(0, 0, 0, 0, 0, -Infinity); - ctx.transform(0, 0, 0, 0, 0, NaN); - ctx.transform(Infinity, Infinity, 0, 0, 0, 0); - ctx.transform(Infinity, Infinity, Infinity, 0, 0, 0); - ctx.transform(Infinity, Infinity, Infinity, Infinity, 0, 0); - ctx.transform(Infinity, Infinity, Infinity, Infinity, Infinity, 0); - ctx.transform(Infinity, Infinity, Infinity, Infinity, Infinity, Infinity); - ctx.transform(Infinity, Infinity, Infinity, Infinity, 0, Infinity); - ctx.transform(Infinity, Infinity, Infinity, 0, Infinity, 0); - ctx.transform(Infinity, Infinity, Infinity, 0, Infinity, Infinity); - ctx.transform(Infinity, Infinity, Infinity, 0, 0, Infinity); - ctx.transform(Infinity, Infinity, 0, Infinity, 0, 0); - ctx.transform(Infinity, Infinity, 0, Infinity, Infinity, 0); - ctx.transform(Infinity, Infinity, 0, Infinity, Infinity, Infinity); - ctx.transform(Infinity, Infinity, 0, Infinity, 0, Infinity); - ctx.transform(Infinity, Infinity, 0, 0, Infinity, 0); - ctx.transform(Infinity, Infinity, 0, 0, Infinity, Infinity); - ctx.transform(Infinity, Infinity, 0, 0, 0, Infinity); - ctx.transform(Infinity, 0, Infinity, 0, 0, 0); - ctx.transform(Infinity, 0, Infinity, Infinity, 0, 0); - ctx.transform(Infinity, 0, Infinity, Infinity, Infinity, 0); - ctx.transform(Infinity, 0, Infinity, Infinity, Infinity, Infinity); - ctx.transform(Infinity, 0, Infinity, Infinity, 0, Infinity); - ctx.transform(Infinity, 0, Infinity, 0, Infinity, 0); - ctx.transform(Infinity, 0, Infinity, 0, Infinity, 0); - ctx.transform(Infinity, 0, Infinity, 0, Infinity, Infinity); - ctx.transform(Infinity, 0, Infinity, 0, 0, Infinity); - ctx.transform(Infinity, 0, 0, Infinity, 0, 0); - ctx.transform(Infinity, 0, 0, Infinity, Infinity, 0); - ctx.transform(Infinity, 0, 0, Infinity, Infinity, Infinity); - ctx.transform(Infinity, 0, 0, Infinity, 0, Infinity); - ctx.transform(Infinity, 0, 0, 0, Infinity, 0); - ctx.transform(Infinity, 0, 0, 0, Infinity, Infinity); - ctx.transform(Infinity, 0, 0, 0, 0, Infinity); - ctx.transform(0, Infinity, Infinity, 0, 0, 0); - ctx.transform(0, Infinity, Infinity, Infinity, 0, 0); - ctx.transform(0, Infinity, Infinity, Infinity, Infinity, 0); - ctx.transform(0, Infinity, Infinity, Infinity, Infinity, Infinity); - ctx.transform(0, Infinity, Infinity, Infinity, 0, Infinity); - ctx.transform(0, Infinity, Infinity, 0, Infinity, 0); - ctx.transform(0, Infinity, Infinity, 0, Infinity, Infinity); - ctx.transform(0, Infinity, Infinity, 0, 0, Infinity); - ctx.transform(0, Infinity, 0, Infinity, 0, 0); - ctx.transform(0, Infinity, 0, Infinity, Infinity, 0); - ctx.transform(0, Infinity, 0, Infinity, Infinity, Infinity); - ctx.transform(0, Infinity, 0, Infinity, 0, Infinity); - ctx.transform(0, Infinity, 0, 0, Infinity, 0); - ctx.transform(0, Infinity, 0, 0, Infinity, Infinity); - ctx.transform(0, Infinity, 0, 0, 0, Infinity); - ctx.transform(0, 0, Infinity, Infinity, 0, 0); - ctx.transform(0, 0, Infinity, Infinity, Infinity, 0); - ctx.transform(0, 0, Infinity, Infinity, Infinity, Infinity); - ctx.transform(0, 0, Infinity, Infinity, 0, Infinity); - ctx.transform(0, 0, Infinity, 0, Infinity, 0); - ctx.transform(0, 0, Infinity, 0, Infinity, Infinity); - ctx.transform(0, 0, Infinity, 0, 0, Infinity); - ctx.transform(0, 0, 0, Infinity, Infinity, 0); - ctx.transform(0, 0, 0, Infinity, Infinity, Infinity); - ctx.transform(0, 0, 0, Infinity, 0, Infinity); - ctx.transform(0, 0, 0, 0, Infinity, Infinity); - - ctx.fillStyle = '#0f0'; - ctx.fillRect(-100, -10, 100, 50); - - verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); - ctx.reset(); - - // Create green with a red square ring inside it - ctx.fillStyle = '#0f0'; - ctx.fillRect(0, 0, 100, 50); - ctx.fillStyle = '#f00'; - ctx.fillRect(20, 10, 60, 30); - ctx.fillStyle = '#0f0'; - ctx.fillRect(40, 20, 20, 10); - - // Draw a skewed shape to fill that gap, to make sure it is aligned correctly - ctx.transform(1,4, 2,3, 5,6); - // Post-transform coordinates: - // [[20,10],[80,10],[80,40],[20,40],[20,10],[40,20],[40,30],[60,30],[60,20],[40,20],[20,10]]; - // Hence pre-transform coordinates: - var pts=[[-7.4,11.2],[-43.4,59.2],[-31.4,53.2],[4.6,5.2],[-7.4,11.2], - [-15.4,25.2],[-11.4,23.2],[-23.4,39.2],[-27.4,41.2],[-15.4,25.2], - [-7.4,11.2]]; - ctx.beginPath(); - ctx.moveTo(pts[0][0], pts[0][1]); - for (var i = 0; i < pts.length; ++i) - ctx.lineTo(pts[i][0], pts[i][1]); - ctx.fill(); - /* - //FIXME: - verify(Helper.comparePixel(ctx, 21,11, 0,255,0,255)); - verify(Helper.comparePixel(ctx, 79,11, 0,255,0,255)); - verify(Helper.comparePixel(ctx, 21,39, 0,255,0,255)); - verify(Helper.comparePixel(ctx, 79,39, 0,255,0,255)); - verify(Helper.comparePixel(ctx, 39,19, 0,255,0,255)); - verify(Helper.comparePixel(ctx, 61,19, 0,255,0,255)); - verify(Helper.comparePixel(ctx, 39,31, 0,255,0,255)); - verify(Helper.comparePixel(ctx, 61,31, 0,255,0,255)); - */ - } - function test_translate() { - var ctx = canvas.getContext('2d'); - ctx.reset(); - ctx.fillStyle = '#f00'; - ctx.fillRect(0, 0, 100, 50); - - ctx.translate(100, 50); - ctx.fillStyle = '#0f0'; - ctx.fillRect(-100, -50, 100, 50); - verify(Helper.comparePixel(ctx, 90,40, 0,255,0,255)); - ctx.reset(); - - ctx.fillStyle = '#f00'; - ctx.fillRect(0, 0, 100, 50); - - ctx.translate(100, 10); - ctx.translate(Infinity, 0.1); - ctx.translate(-Infinity, 0.1); - ctx.translate(NaN, 0.1); - ctx.translate(0.1, Infinity); - ctx.translate(0.1, -Infinity); - ctx.translate(0.1, NaN); - ctx.translate(Infinity, Infinity); - - ctx.fillStyle = '#0f0'; - ctx.fillRect(-100, -10, 100, 50); - - verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); - - - } - } -} diff --git a/tests/auto/qtquick2/qquickcanvasitem/data/yellow.png b/tests/auto/qtquick2/qquickcanvasitem/data/yellow.png deleted file mode 100644 index 51e8aaf38c..0000000000 Binary files a/tests/auto/qtquick2/qquickcanvasitem/data/yellow.png and /dev/null differ diff --git a/tests/auto/qtquick2/qquickcanvasitem/data/yellow75.png b/tests/auto/qtquick2/qquickcanvasitem/data/yellow75.png deleted file mode 100644 index 2bb82c9834..0000000000 Binary files a/tests/auto/qtquick2/qquickcanvasitem/data/yellow75.png and /dev/null differ diff --git a/tests/auto/qtquick2/qquickcanvasitem/qquickcanvasitem.pro b/tests/auto/qtquick2/qquickcanvasitem/qquickcanvasitem.pro deleted file mode 100644 index 93539dab15..0000000000 --- a/tests/auto/qtquick2/qquickcanvasitem/qquickcanvasitem.pro +++ /dev/null @@ -1,34 +0,0 @@ -QT += core-private gui-private declarative-private widgets -TEMPLATE=app -TARGET=tst_qquickcanvasitem - -CONFIG += warn_on qmltestcase -SOURCES += tst_qquickcanvasitem.cpp - -importFiles.files = data -importFiles.path = . -DEPLOYMENT += importFiles - -OTHER_FILES += \ - data/testhelper.js \ - data/tst_transform.qml \ - data/tst_text.qml \ - data/tst_strokeStyle.qml \ - data/tst_state.qml \ - data/tst_shadow.qml \ - data/tst_pattern.qml \ - data/tst_path.qml \ - data/tst_line.qml \ - data/tst_fillStyle.qml \ - data/tst_fillrect.qml \ - data/tst_drawimage.qml \ - data/tst_composite.qml \ - data/tst_canvas.qml \ - data/tst_pixel.qml \ - data/tst_gradient.qml \ - data/tst_arcto.qml \ - data/tst_arc.qml \ - data/tst_context.qml - - - diff --git a/tests/auto/qtquick2/qquickcanvasitem/tst_qquickcanvasitem.cpp b/tests/auto/qtquick2/qquickcanvasitem/tst_qquickcanvasitem.cpp deleted file mode 100644 index 468c7cb9db..0000000000 --- a/tests/auto/qtquick2/qquickcanvasitem/tst_qquickcanvasitem.cpp +++ /dev/null @@ -1,42 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include -QUICK_TEST_MAIN(qquickcanvasitem) diff --git a/tests/auto/qtquick2/qquickdrag/qquickdrag.pro b/tests/auto/qtquick2/qquickdrag/qquickdrag.pro deleted file mode 100644 index 4fdfa7b355..0000000000 --- a/tests/auto/qtquick2/qquickdrag/qquickdrag.pro +++ /dev/null @@ -1,9 +0,0 @@ -TARGET = tst_qquickdrag -CONFIG += testcase -macx:CONFIG -= app_bundle - -SOURCES += tst_qquickdrag.cpp - -CONFIG += parallel_test - -QT += core-private gui-private declarative-private quick-private network testlib diff --git a/tests/auto/qtquick2/qquickdrag/tst_qquickdrag.cpp b/tests/auto/qtquick2/qquickdrag/tst_qquickdrag.cpp deleted file mode 100644 index 91edf8c7b6..0000000000 --- a/tests/auto/qtquick2/qquickdrag/tst_qquickdrag.cpp +++ /dev/null @@ -1,1034 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include -#include -#include -#include -#include -#include -#include - -template static T evaluate(QObject *scope, const QString &expression) -{ - QDeclarativeExpression expr(qmlContext(scope), scope, expression); - QVariant result = expr.evaluate(); - if (expr.hasError()) - qWarning() << expr.error().toString(); - return result.value(); -} - -template <> void evaluate(QObject *scope, const QString &expression) -{ - QDeclarativeExpression expr(qmlContext(scope), scope, expression); - expr.evaluate(); - if (expr.hasError()) - qWarning() << expr.error().toString(); -} - -Q_DECLARE_METATYPE(Qt::DropActions) - -class TestDropTarget : public QQuickItem -{ - Q_OBJECT -public: - TestDropTarget(QQuickItem *parent = 0) - : QQuickItem(parent) - , enterEvents(0) - , moveEvents(0) - , leaveEvents(0) - , dropEvents(0) - , acceptAction(Qt::MoveAction) - , defaultAction(Qt::IgnoreAction) - , proposedAction(Qt::IgnoreAction) - , accept(true) - { - setFlags(ItemAcceptsDrops); - } - - void reset() - { - enterEvents = 0; - moveEvents = 0; - leaveEvents = 0; - dropEvents = 0; - defaultAction = Qt::IgnoreAction; - proposedAction = Qt::IgnoreAction; - supportedActions = Qt::IgnoreAction; - } - - void dragEnterEvent(QDragEnterEvent *event) - { - ++enterEvents; - position = event->pos(); - defaultAction = event->dropAction(); - proposedAction = event->proposedAction(); - supportedActions = event->possibleActions(); - event->setAccepted(accept); - } - - void dragMoveEvent(QDragMoveEvent *event) - { - ++moveEvents; - position = event->pos(); - defaultAction = event->dropAction(); - proposedAction = event->proposedAction(); - supportedActions = event->possibleActions(); - event->setAccepted(accept); - } - - void dragLeaveEvent(QDragLeaveEvent *event) - { - ++leaveEvents; - event->setAccepted(accept); - } - - void dropEvent(QDropEvent *event) - { - ++dropEvents; - position = event->pos(); - defaultAction = event->dropAction(); - proposedAction = event->proposedAction(); - supportedActions = event->possibleActions(); - event->setDropAction(acceptAction); - event->setAccepted(accept); - } - - int enterEvents; - int moveEvents; - int leaveEvents; - int dropEvents; - Qt::DropAction acceptAction; - Qt::DropAction defaultAction; - Qt::DropAction proposedAction; - Qt::DropActions supportedActions; - QPointF position; - bool accept; -}; - -class tst_QQuickDrag: public QObject -{ - Q_OBJECT -private slots: - void initTestCase(); - void cleanupTestCase(); - - void active(); - void drop(); - void move(); - void hotSpot(); - void supportedActions(); - void proposedAction(); - void keys(); - void source(); - void recursion_data(); - void recursion(); - -private: - QDeclarativeEngine engine; -}; - -void tst_QQuickDrag::initTestCase() -{ - -} - -void tst_QQuickDrag::cleanupTestCase() -{ - -} - -void tst_QQuickDrag::active() -{ - QQuickCanvas canvas; - TestDropTarget dropTarget(canvas.rootItem()); - dropTarget.setSize(QSizeF(100, 100)); - QDeclarativeComponent component(&engine); - component.setData( - "import QtQuick 2.0\n" - "Item {\n" - "property bool dragActive: Drag.active\n" - "property Item dragTarget: Drag.target\n" - "x: 50; y: 50\n" - "width: 10; height: 10\n" - "}", QUrl()); - QScopedPointer object(component.create()); - QQuickItem *item = qobject_cast(object.data()); - QVERIFY(item); - item->setParentItem(&dropTarget); - - QCOMPARE(evaluate(item, "Drag.active"), false); - QCOMPARE(evaluate(item, "dragActive"), false); - - evaluate(item, "Drag.active = true"); - QCOMPARE(evaluate(item, "Drag.active"), true); - QCOMPARE(evaluate(item, "dragActive"), true); - QCOMPARE(evaluate(item, "Drag.target"), static_cast(&dropTarget)); - QCOMPARE(evaluate(item, "dragTarget"), static_cast(&dropTarget)); - QCOMPARE(dropTarget.enterEvents, 1); QCOMPARE(dropTarget.leaveEvents, 0); - - dropTarget.reset(); - evaluate(item, "Drag.active = false"); - QCOMPARE(evaluate(item, "Drag.active"), false); - QCOMPARE(evaluate(item, "dragActive"), false); - QCOMPARE(evaluate(item, "Drag.target"), static_cast(0)); - QCOMPARE(evaluate(item, "dragTarget"), static_cast(0)); - QCOMPARE(dropTarget.enterEvents, 0); QCOMPARE(dropTarget.leaveEvents, 1); - - dropTarget.reset(); - evaluate(item, "Drag.cancel()"); - QCOMPARE(evaluate(item, "Drag.active"), false); - QCOMPARE(evaluate(item, "dragActive"), false); - QCOMPARE(evaluate(item, "Drag.target"), static_cast(0)); - QCOMPARE(evaluate(item, "dragTarget"), static_cast(0)); - QCOMPARE(dropTarget.enterEvents, 0); QCOMPARE(dropTarget.leaveEvents, 0); - - dropTarget.reset(); - evaluate(item, "Drag.start()"); - QCOMPARE(evaluate(item, "Drag.active"), true); - QCOMPARE(evaluate(item, "dragActive"), true); - QCOMPARE(evaluate(item, "Drag.target"), static_cast(&dropTarget)); - QCOMPARE(evaluate(item, "dragTarget"), static_cast(&dropTarget)); - QCOMPARE(dropTarget.enterEvents, 1); QCOMPARE(dropTarget.leaveEvents, 0); - - // Start while a drag is active, cancels the previous drag and starts a new one. - dropTarget.reset(); - evaluate(item, "Drag.start()"); - QCOMPARE(evaluate(item, "Drag.active"), true); - QCOMPARE(evaluate(item, "dragActive"), true); - QCOMPARE(evaluate(item, "Drag.target"), static_cast(&dropTarget)); - QCOMPARE(evaluate(item, "dragTarget"), static_cast(&dropTarget)); - QCOMPARE(dropTarget.enterEvents, 1); QCOMPARE(dropTarget.leaveEvents, 1); - - dropTarget.reset(); - evaluate(item, "Drag.cancel()"); - QCOMPARE(evaluate(item, "Drag.active"), false); - QCOMPARE(evaluate(item, "dragActive"), false); - QCOMPARE(evaluate(item, "Drag.target"), static_cast(0)); - QCOMPARE(evaluate(item, "dragTarget"), static_cast(0)); - QCOMPARE(dropTarget.enterEvents, 0); QCOMPARE(dropTarget.leaveEvents, 1); - - // Enter events aren't sent to items without the QQuickItem::ItemAcceptsDrops flag. - dropTarget.setFlags(QQuickItem::Flags()); - - dropTarget.reset(); - evaluate(item, "Drag.active = true"); - QCOMPARE(evaluate(item, "Drag.active"), true); - QCOMPARE(evaluate(item, "dragActive"), true); - QCOMPARE(evaluate(item, "Drag.target"), static_cast(0)); - QCOMPARE(evaluate(item, "dragTarget"), static_cast(0)); - QCOMPARE(dropTarget.enterEvents, 0); QCOMPARE(dropTarget.leaveEvents, 0); - - dropTarget.reset(); - evaluate(item, "Drag.active = false"); - QCOMPARE(evaluate(item, "Drag.active"), false); - QCOMPARE(evaluate(item, "dragActive"), false); - QCOMPARE(evaluate(item, "Drag.target"), static_cast(0)); - QCOMPARE(evaluate(item, "dragTarget"), static_cast(0)); - QCOMPARE(dropTarget.enterEvents, 0); QCOMPARE(dropTarget.leaveEvents, 0); - - dropTarget.setFlags(QQuickItem::ItemAcceptsDrops); - - dropTarget.reset(); - evaluate(item, "Drag.active = true"); - QCOMPARE(evaluate(item, "Drag.active"), true); - QCOMPARE(evaluate(item, "dragActive"), true); - QCOMPARE(evaluate(item, "Drag.target"), static_cast(&dropTarget)); - QCOMPARE(evaluate(item, "dragTarget"), static_cast(&dropTarget)); - QCOMPARE(dropTarget.enterEvents, 1); QCOMPARE(dropTarget.leaveEvents, 0); - - dropTarget.setFlags(QQuickItem::Flags()); - - dropTarget.reset(); - evaluate(item, "Drag.active = false"); - QCOMPARE(evaluate(item, "Drag.active"), false); - QCOMPARE(evaluate(item, "dragActive"), false); - QCOMPARE(evaluate(item, "Drag.target"), static_cast(0)); - QCOMPARE(evaluate(item, "dragTarget"), static_cast(0)); - QCOMPARE(dropTarget.enterEvents, 0); QCOMPARE(dropTarget.leaveEvents, 1); - - // Follow up events aren't sent to items if the enter event isn't accepted. - dropTarget.setFlags(QQuickItem::ItemAcceptsDrops); - dropTarget.accept = false; - - dropTarget.reset(); - evaluate(item, "Drag.active = true"); - QCOMPARE(evaluate(item, "Drag.active"), true); - QCOMPARE(evaluate(item, "dragActive"), true); - QCOMPARE(evaluate(item, "Drag.target"), static_cast(0)); - QCOMPARE(evaluate(item, "dragTarget"), static_cast(0)); - QCOMPARE(dropTarget.enterEvents, 1); QCOMPARE(dropTarget.leaveEvents, 0); - - dropTarget.reset(); - evaluate(item, "Drag.active = false"); - QCOMPARE(evaluate(item, "Drag.active"), false); - QCOMPARE(evaluate(item, "dragActive"), false); - QCOMPARE(evaluate(item, "Drag.target"), static_cast(0)); - QCOMPARE(evaluate(item, "dragTarget"), static_cast(0)); - QCOMPARE(dropTarget.enterEvents, 0); QCOMPARE(dropTarget.leaveEvents, 0); - - dropTarget.accept = true; - - dropTarget.reset(); - evaluate(item, "Drag.active = true"); - QCOMPARE(evaluate(item, "Drag.active"), true); - QCOMPARE(evaluate(item, "dragActive"), true); - QCOMPARE(evaluate(item, "Drag.target"), static_cast(&dropTarget)); - QCOMPARE(evaluate(item, "dragTarget"), static_cast(&dropTarget)); - QCOMPARE(dropTarget.enterEvents, 1); QCOMPARE(dropTarget.leaveEvents, 0); - - dropTarget.accept = false; - - dropTarget.reset(); - evaluate(item, "Drag.active = false"); - QCOMPARE(evaluate(item, "Drag.active"), false); - QCOMPARE(evaluate(item, "dragActive"), false); - QCOMPARE(evaluate(item, "Drag.target"), static_cast(0)); - QCOMPARE(evaluate(item, "dragTarget"), static_cast(0)); - QCOMPARE(dropTarget.enterEvents, 0); QCOMPARE(dropTarget.leaveEvents, 1); - - // Events are sent to hidden or disabled items. - dropTarget.accept = true; - dropTarget.setVisible(false); - dropTarget.reset(); - evaluate(item, "Drag.active = true"); - QCOMPARE(evaluate(item, "Drag.active"), true); - QCOMPARE(evaluate(item, "dragActive"), true); - QCOMPARE(evaluate(item, "Drag.target"), static_cast(0)); - QCOMPARE(evaluate(item, "dragTarget"), static_cast(0)); - QCOMPARE(dropTarget.enterEvents, 0); QCOMPARE(dropTarget.leaveEvents, 0); - - evaluate(item, "Drag.active = false"); - dropTarget.setVisible(true); - - dropTarget.setOpacity(0.0); - dropTarget.reset(); - evaluate(item, "Drag.active = true"); - QCOMPARE(evaluate(item, "Drag.active"), true); - QCOMPARE(evaluate(item, "dragActive"), true); - QCOMPARE(evaluate(item, "Drag.target"), static_cast(0)); - QCOMPARE(evaluate(item, "dragTarget"), static_cast(0)); - QCOMPARE(dropTarget.enterEvents, 0); QCOMPARE(dropTarget.leaveEvents, 0); - - evaluate(item, "Drag.active = false"); - dropTarget.setOpacity(1.0); - - dropTarget.setEnabled(false); - dropTarget.reset(); - evaluate(item, "Drag.active = true"); - QCOMPARE(evaluate(item, "Drag.active"), true); - QCOMPARE(evaluate(item, "dragActive"), true); - QCOMPARE(evaluate(item, "Drag.target"), static_cast(0)); - QCOMPARE(evaluate(item, "dragTarget"), static_cast(0)); - QCOMPARE(dropTarget.enterEvents, 0); QCOMPARE(dropTarget.leaveEvents, 0); -} - -void tst_QQuickDrag::drop() -{ - QQuickCanvas canvas; - TestDropTarget outerTarget(canvas.rootItem()); - outerTarget.setSize(QSizeF(100, 100)); - outerTarget.acceptAction = Qt::CopyAction; - TestDropTarget innerTarget(&outerTarget); - innerTarget.setSize(QSizeF(100, 100)); - innerTarget.acceptAction = Qt::MoveAction; - QDeclarativeComponent component(&engine); - component.setData( - "import QtQuick 2.0\n" - "Item {\n" - "property bool dragActive: Drag.active\n" - "property Item dragTarget: Drag.target\n" - "x: 50; y: 50\n" - "width: 10; height: 10\n" - "}", QUrl()); - QScopedPointer object(component.create()); - QQuickItem *item = qobject_cast(object.data()); - QVERIFY(item); - item->setParentItem(&outerTarget); - - innerTarget.reset(); outerTarget.reset(); - evaluate(item, "Drag.active = true"); - QCOMPARE(evaluate(item, "Drag.active"), true); - QCOMPARE(evaluate(item, "dragActive"), true); - QCOMPARE(evaluate(item, "Drag.target"), static_cast(&innerTarget)); - QCOMPARE(evaluate(item, "dragTarget"), static_cast(&innerTarget)); - QCOMPARE(outerTarget.enterEvents, 1); QCOMPARE(outerTarget.leaveEvents, 0); QCOMPARE(outerTarget.dropEvents, 0); - QCOMPARE(innerTarget.enterEvents, 1); QCOMPARE(innerTarget.leaveEvents, 0); QCOMPARE(innerTarget.dropEvents, 0); - - innerTarget.reset(); outerTarget.reset(); - QCOMPARE(evaluate(item, "Drag.drop() == Qt.MoveAction"), true); - QCOMPARE(evaluate(item, "Drag.active"), false); - QCOMPARE(evaluate(item, "dragActive"), false); - QCOMPARE(evaluate(item, "Drag.target"), static_cast(&innerTarget)); - QCOMPARE(evaluate(item, "dragTarget"), static_cast(&innerTarget)); - QCOMPARE(outerTarget.enterEvents, 0); QCOMPARE(outerTarget.leaveEvents, 1); QCOMPARE(outerTarget.dropEvents, 0); - QCOMPARE(innerTarget.enterEvents, 0); QCOMPARE(innerTarget.leaveEvents, 0); QCOMPARE(innerTarget.dropEvents, 1); - - innerTarget.reset(); outerTarget.reset(); - evaluate(item, "Drag.active = true"); - QCOMPARE(evaluate(item, "Drag.active"), true); - QCOMPARE(evaluate(item, "dragActive"), true); - QCOMPARE(evaluate(item, "Drag.target"), static_cast(&innerTarget)); - QCOMPARE(evaluate(item, "dragTarget"), static_cast(&innerTarget)); - QCOMPARE(outerTarget.enterEvents, 1); QCOMPARE(outerTarget.leaveEvents, 0); QCOMPARE(outerTarget.dropEvents, 0); - QCOMPARE(innerTarget.enterEvents, 1); QCOMPARE(innerTarget.leaveEvents, 0); QCOMPARE(innerTarget.dropEvents, 0); - - // Inner target declines the drop so it is propagated to the outer target. - innerTarget.accept = false; - - innerTarget.reset(); outerTarget.reset(); - QCOMPARE(evaluate(item, "Drag.drop() == Qt.CopyAction"), true); - QCOMPARE(evaluate(item, "Drag.active"), false); - QCOMPARE(evaluate(item, "dragActive"), false); - QCOMPARE(evaluate(item, "Drag.target"), static_cast(&outerTarget)); - QCOMPARE(evaluate(item, "dragTarget"), static_cast(&outerTarget)); - QCOMPARE(outerTarget.enterEvents, 0); QCOMPARE(outerTarget.leaveEvents, 0); QCOMPARE(outerTarget.dropEvents, 1); - QCOMPARE(innerTarget.enterEvents, 0); QCOMPARE(innerTarget.leaveEvents, 0); QCOMPARE(innerTarget.dropEvents, 1); - - - // Inner target doesn't accept enter so drop goes directly to outer. - innerTarget.accept = true; - innerTarget.setFlags(QQuickItem::Flags()); - - innerTarget.reset(); outerTarget.reset(); - evaluate(item, "Drag.active = true"); - QCOMPARE(evaluate(item, "Drag.active"), true); - QCOMPARE(evaluate(item, "dragActive"), true); - QCOMPARE(evaluate(item, "Drag.target"), static_cast(&outerTarget)); - QCOMPARE(evaluate(item, "dragTarget"), static_cast(&outerTarget)); - QCOMPARE(outerTarget.enterEvents, 1); QCOMPARE(outerTarget.leaveEvents, 0); QCOMPARE(outerTarget.dropEvents, 0); - QCOMPARE(innerTarget.enterEvents, 0); QCOMPARE(innerTarget.leaveEvents, 0); QCOMPARE(innerTarget.dropEvents, 0); - - innerTarget.reset(); outerTarget.reset(); - QCOMPARE(evaluate(item, "Drag.drop() == Qt.CopyAction"), true); - QCOMPARE(evaluate(item, "Drag.active"), false); - QCOMPARE(evaluate(item, "dragActive"), false); - QCOMPARE(evaluate(item, "Drag.target"), static_cast(&outerTarget)); - QCOMPARE(evaluate(item, "dragTarget"), static_cast(&outerTarget)); - QCOMPARE(outerTarget.enterEvents, 0); QCOMPARE(outerTarget.leaveEvents, 0); QCOMPARE(outerTarget.dropEvents, 1); - QCOMPARE(innerTarget.enterEvents, 0); QCOMPARE(innerTarget.leaveEvents, 0); QCOMPARE(innerTarget.dropEvents, 0); - - // Neither target accepts drop so Qt::IgnoreAction is returned. - innerTarget.reset(); outerTarget.reset(); - evaluate(item, "Drag.active = true"); - QCOMPARE(evaluate(item, "Drag.active"), true); - QCOMPARE(evaluate(item, "dragActive"), true); - QCOMPARE(evaluate(item, "Drag.target"), static_cast(&outerTarget)); - QCOMPARE(evaluate(item, "dragTarget"), static_cast(&outerTarget)); - QCOMPARE(outerTarget.enterEvents, 1); QCOMPARE(outerTarget.leaveEvents, 0); QCOMPARE(outerTarget.dropEvents, 0); - QCOMPARE(innerTarget.enterEvents, 0); QCOMPARE(innerTarget.leaveEvents, 0); QCOMPARE(innerTarget.dropEvents, 0); - - outerTarget.accept = false; - - innerTarget.reset(); outerTarget.reset(); - QCOMPARE(evaluate(item, "Drag.drop() == Qt.IgnoreAction"), true); - QCOMPARE(evaluate(item, "Drag.active"), false); - QCOMPARE(evaluate(item, "dragActive"), false); - QCOMPARE(evaluate(item, "Drag.target"), static_cast(0)); - QCOMPARE(evaluate(item, "dragTarget"), static_cast(0)); - QCOMPARE(outerTarget.enterEvents, 0); QCOMPARE(outerTarget.leaveEvents, 0); QCOMPARE(outerTarget.dropEvents, 1); - QCOMPARE(innerTarget.enterEvents, 0); QCOMPARE(innerTarget.leaveEvents, 0); QCOMPARE(innerTarget.dropEvents, 0); - - // drop doesn't send an event and returns Qt.IgnoreAction if not active. - innerTarget.accept = true; - outerTarget.accept = true; - innerTarget.reset(); outerTarget.reset(); - QCOMPARE(evaluate(item, "Drag.drop() == Qt.IgnoreAction"), true); - QCOMPARE(evaluate(item, "Drag.active"), false); - QCOMPARE(evaluate(item, "dragActive"), false); - QCOMPARE(evaluate(item, "Drag.target"), static_cast(0)); - QCOMPARE(evaluate(item, "dragTarget"), static_cast(0)); - QCOMPARE(outerTarget.enterEvents, 0); QCOMPARE(outerTarget.leaveEvents, 0); QCOMPARE(outerTarget.dropEvents, 0); - QCOMPARE(innerTarget.enterEvents, 0); QCOMPARE(innerTarget.leaveEvents, 0); QCOMPARE(innerTarget.dropEvents, 0); -} - -void tst_QQuickDrag::move() -{ - QQuickCanvas canvas; - TestDropTarget outerTarget(canvas.rootItem()); - outerTarget.setSize(QSizeF(100, 100)); - TestDropTarget leftTarget(&outerTarget); - leftTarget.setPos(QPointF(0, 35)); - leftTarget.setSize(QSizeF(30, 30)); - TestDropTarget rightTarget(&outerTarget); - rightTarget.setPos(QPointF(70, 35)); - rightTarget.setSize(QSizeF(30, 30)); - QDeclarativeComponent component(&engine); - component.setData( - "import QtQuick 2.0\n" - "Item {\n" - "property bool dragActive: Drag.active\n" - "property Item dragTarget: Drag.target\n" - "x: 50; y: 50\n" - "width: 10; height: 10\n" - "}", QUrl()); - QScopedPointer object(component.create()); - QQuickItem *item = qobject_cast(object.data()); - QVERIFY(item); - item->setParentItem(&outerTarget); - - evaluate(item, "Drag.active = true"); - QCOMPARE(evaluate(item, "Drag.active"), true); - QCOMPARE(evaluate(item, "dragActive"), true); - QCOMPARE(evaluate(item, "Drag.target"), static_cast(&outerTarget)); - QCOMPARE(evaluate(item, "dragTarget"), static_cast(&outerTarget)); - QCOMPARE(outerTarget.enterEvents, 1); QCOMPARE(outerTarget.leaveEvents, 0); QCOMPARE(outerTarget.moveEvents, 0); - QCOMPARE(leftTarget .enterEvents, 0); QCOMPARE(leftTarget .leaveEvents, 0); QCOMPARE(leftTarget .moveEvents, 0); - QCOMPARE(rightTarget.enterEvents, 0); QCOMPARE(rightTarget.leaveEvents, 0); QCOMPARE(rightTarget.moveEvents, 0); - QCOMPARE(outerTarget.position.x(), qreal(50)); QCOMPARE(outerTarget.position.y(), qreal(50)); - - // Move within the outer target. - outerTarget.reset(); leftTarget.reset(); rightTarget.reset(); - item->setPos(QPointF(60, 50)); - QCOMPARE(evaluate(item, "Drag.target"), static_cast(&outerTarget)); - QCOMPARE(evaluate(item, "dragTarget"), static_cast(&outerTarget)); - QCOMPARE(outerTarget.enterEvents, 0); QCOMPARE(outerTarget.leaveEvents, 0); QCOMPARE(outerTarget.moveEvents, 1); - QCOMPARE(leftTarget .enterEvents, 0); QCOMPARE(leftTarget .leaveEvents, 0); QCOMPARE(leftTarget .moveEvents, 0); - QCOMPARE(rightTarget.enterEvents, 0); QCOMPARE(rightTarget.leaveEvents, 0); QCOMPARE(rightTarget.moveEvents, 0); - QCOMPARE(outerTarget.position.x(), qreal(60)); QCOMPARE(outerTarget.position.y(), qreal(50)); - - // Move into the right target. - outerTarget.reset(); leftTarget.reset(); rightTarget.reset(); - item->setPos(QPointF(75, 50)); - QCOMPARE(evaluate(item, "Drag.target"), static_cast(&rightTarget)); - QCOMPARE(evaluate(item, "dragTarget"), static_cast(&rightTarget)); - QCOMPARE(outerTarget.enterEvents, 0); QCOMPARE(outerTarget.leaveEvents, 0); QCOMPARE(outerTarget.moveEvents, 1); - QCOMPARE(leftTarget .enterEvents, 0); QCOMPARE(leftTarget .leaveEvents, 0); QCOMPARE(leftTarget .moveEvents, 0); - QCOMPARE(rightTarget.enterEvents, 1); QCOMPARE(rightTarget.leaveEvents, 0); QCOMPARE(rightTarget.moveEvents, 0); - QCOMPARE(outerTarget.position.x(), qreal(75)); QCOMPARE(outerTarget.position.y(), qreal(50)); - QCOMPARE(rightTarget.position.x(), qreal(5)); QCOMPARE(rightTarget.position.y(), qreal(15)); - - // Move into the left target. - outerTarget.reset(); leftTarget.reset(); rightTarget.reset(); - item->setPos(QPointF(25, 50)); - QCOMPARE(evaluate(item, "Drag.target"), static_cast(&leftTarget)); - QCOMPARE(evaluate(item, "dragTarget"), static_cast(&leftTarget)); - QCOMPARE(outerTarget.enterEvents, 0); QCOMPARE(outerTarget.leaveEvents, 0); QCOMPARE(outerTarget.moveEvents, 1); - QCOMPARE(leftTarget .enterEvents, 1); QCOMPARE(leftTarget .leaveEvents, 0); QCOMPARE(leftTarget .moveEvents, 0); - QCOMPARE(rightTarget.enterEvents, 0); QCOMPARE(rightTarget.leaveEvents, 1); QCOMPARE(rightTarget.moveEvents, 0); - QCOMPARE(outerTarget.position.x(), qreal(25)); QCOMPARE(outerTarget.position.y(), qreal(50)); - QCOMPARE(leftTarget.position.x(), qreal(25)); QCOMPARE(leftTarget.position.y(), qreal(15)); - - // Move within the left target. - outerTarget.reset(); leftTarget.reset(); rightTarget.reset(); - item->setPos(QPointF(25, 40)); - QCOMPARE(evaluate(item, "Drag.target"), static_cast(&leftTarget)); - QCOMPARE(evaluate(item, "dragTarget"), static_cast(&leftTarget)); - QCOMPARE(outerTarget.enterEvents, 0); QCOMPARE(outerTarget.leaveEvents, 0); QCOMPARE(outerTarget.moveEvents, 1); - QCOMPARE(leftTarget .enterEvents, 0); QCOMPARE(leftTarget .leaveEvents, 0); QCOMPARE(leftTarget .moveEvents, 1); - QCOMPARE(rightTarget.enterEvents, 0); QCOMPARE(rightTarget.leaveEvents, 0); QCOMPARE(rightTarget.moveEvents, 0); - QCOMPARE(outerTarget.position.x(), qreal(25)); QCOMPARE(outerTarget.position.y(), qreal(40)); - QCOMPARE(leftTarget.position.x(), qreal(25)); QCOMPARE(leftTarget.position.y(), qreal(5)); - - // Move out of all targets. - outerTarget.reset(); leftTarget.reset(); rightTarget.reset(); - item->setPos(QPointF(110, 50)); - QCOMPARE(evaluate(item, "Drag.target"), static_cast(0)); - QCOMPARE(evaluate(item, "dragTarget"), static_cast(0)); - QCOMPARE(outerTarget.enterEvents, 0); QCOMPARE(outerTarget.leaveEvents, 1); QCOMPARE(outerTarget.moveEvents, 0); - QCOMPARE(leftTarget .enterEvents, 0); QCOMPARE(leftTarget .leaveEvents, 1); QCOMPARE(leftTarget .moveEvents, 0); - QCOMPARE(rightTarget.enterEvents, 0); QCOMPARE(rightTarget.leaveEvents, 0); QCOMPARE(rightTarget.moveEvents, 0); - - // Stop the right target accepting drag events and move into it. - rightTarget.accept = false; - - outerTarget.reset(); leftTarget.reset(); rightTarget.reset(); - item->setPos(QPointF(80, 50)); - QCOMPARE(evaluate(item, "Drag.target"), static_cast(&outerTarget)); - QCOMPARE(evaluate(item, "dragTarget"), static_cast(&outerTarget)); - QCOMPARE(outerTarget.enterEvents, 1); QCOMPARE(outerTarget.leaveEvents, 0); QCOMPARE(outerTarget.moveEvents, 0); - QCOMPARE(leftTarget .enterEvents, 0); QCOMPARE(leftTarget .leaveEvents, 0); QCOMPARE(leftTarget .moveEvents, 0); - QCOMPARE(rightTarget.enterEvents, 1); QCOMPARE(rightTarget.leaveEvents, 0); QCOMPARE(rightTarget.moveEvents, 0); - QCOMPARE(outerTarget.position.x(), qreal(80)); QCOMPARE(outerTarget.position.y(), qreal(50)); - - // Stop the outer target accepting drag events after it has accepted an enter event. - outerTarget.accept = false; - - outerTarget.reset(); leftTarget.reset(); rightTarget.reset(); - item->setPos(QPointF(60, 50)); - QCOMPARE(evaluate(item, "Drag.target"), static_cast(&outerTarget)); - QCOMPARE(evaluate(item, "dragTarget"), static_cast(&outerTarget)); - QCOMPARE(outerTarget.enterEvents, 0); QCOMPARE(outerTarget.leaveEvents, 0); QCOMPARE(outerTarget.moveEvents, 1); - QCOMPARE(leftTarget .enterEvents, 0); QCOMPARE(leftTarget .leaveEvents, 0); QCOMPARE(leftTarget .moveEvents, 0); - QCOMPARE(rightTarget.enterEvents, 0); QCOMPARE(rightTarget.leaveEvents, 0); QCOMPARE(rightTarget.moveEvents, 0); - QCOMPARE(outerTarget.position.x(), qreal(60)); QCOMPARE(outerTarget.position.y(), qreal(50)); - - // Clear the QQuickItem::ItemAcceptsDrops flag from the outer target after it accepted an enter event. - outerTarget.setFlags(QQuickItem::Flags()); - - outerTarget.reset(); leftTarget.reset(); rightTarget.reset(); - item->setPos(QPointF(40, 50)); - QCOMPARE(evaluate(item, "Drag.target"), static_cast(&outerTarget)); - QCOMPARE(evaluate(item, "dragTarget"), static_cast(&outerTarget)); - QCOMPARE(outerTarget.enterEvents, 0); QCOMPARE(outerTarget.leaveEvents, 0); QCOMPARE(outerTarget.moveEvents, 1); - QCOMPARE(leftTarget .enterEvents, 0); QCOMPARE(leftTarget .leaveEvents, 0); QCOMPARE(leftTarget .moveEvents, 0); - QCOMPARE(rightTarget.enterEvents, 0); QCOMPARE(rightTarget.leaveEvents, 0); QCOMPARE(rightTarget.moveEvents, 0); - QCOMPARE(outerTarget.position.x(), qreal(40)); QCOMPARE(outerTarget.position.y(), qreal(50)); - - // Clear the QQuickItem::ItemAcceptsDrops flag from the left target before it accepts an enter event. - leftTarget.setFlags(QQuickItem::Flags()); - - outerTarget.reset(); leftTarget.reset(); rightTarget.reset(); - item->setPos(QPointF(25, 50)); - QCOMPARE(evaluate(item, "Drag.target"), static_cast(&outerTarget)); - QCOMPARE(evaluate(item, "dragTarget"), static_cast(&outerTarget)); - QCOMPARE(outerTarget.enterEvents, 0); QCOMPARE(outerTarget.leaveEvents, 0); QCOMPARE(outerTarget.moveEvents, 1); - QCOMPARE(leftTarget .enterEvents, 0); QCOMPARE(leftTarget .leaveEvents, 0); QCOMPARE(leftTarget .moveEvents, 0); - QCOMPARE(rightTarget.enterEvents, 0); QCOMPARE(rightTarget.leaveEvents, 0); QCOMPARE(rightTarget.moveEvents, 0); - QCOMPARE(outerTarget.position.x(), qreal(25)); QCOMPARE(outerTarget.position.y(), qreal(50)); -} - - -void tst_QQuickDrag::hotSpot() -{ - QQuickCanvas canvas; - TestDropTarget dropTarget(canvas.rootItem()); - dropTarget.setSize(QSizeF(100, 100)); - QDeclarativeComponent component(&engine); - component.setData( - "import QtQuick 2.0\n" - "Item {\n" - "property real hotSpotX: Drag.hotSpot.x\n" - "property real hotSpotY: Drag.hotSpot.y\n" - "x: 50; y: 50\n" - "width: 10; height: 10\n" - "}", QUrl()); - QScopedPointer object(component.create()); - QQuickItem *item = qobject_cast(object.data()); - QVERIFY(item); - item->setParentItem(&dropTarget); - - QCOMPARE(evaluate(item, "Drag.hotSpot.x"), qreal(0)); - QCOMPARE(evaluate(item, "Drag.hotSpot.y"), qreal(0)); - QCOMPARE(evaluate(item, "hotSpotX"), qreal(0)); - QCOMPARE(evaluate(item, "hotSpotY"), qreal(0)); - - evaluate(item, "{ Drag.start(); Drag.cancel() }"); - QCOMPARE(dropTarget.position.x(), qreal(50)); - QCOMPARE(dropTarget.position.y(), qreal(50)); - - evaluate(item, "{ Drag.hotSpot.x = 5, Drag.hotSpot.y = 5 }"); - QCOMPARE(evaluate(item, "Drag.hotSpot.x"), qreal(5)); - QCOMPARE(evaluate(item, "Drag.hotSpot.y"), qreal(5)); - QCOMPARE(evaluate(item, "hotSpotX"), qreal(5)); - QCOMPARE(evaluate(item, "hotSpotY"), qreal(5)); - - evaluate(item, "Drag.start()"); - QCOMPARE(dropTarget.position.x(), qreal(55)); - QCOMPARE(dropTarget.position.y(), qreal(55)); - - item->setPos(QPointF(30, 20)); - QCOMPARE(dropTarget.position.x(), qreal(35)); - QCOMPARE(dropTarget.position.y(), qreal(25)); - - evaluate(item, "{ Drag.hotSpot.x = 10; Drag.hotSpot.y = 10 }"); - QCOMPARE(evaluate(item, "Drag.hotSpot.x"), qreal(10)); - QCOMPARE(evaluate(item, "Drag.hotSpot.y"), qreal(10)); - QCOMPARE(evaluate(item, "hotSpotX"), qreal(10)); - QCOMPARE(evaluate(item, "hotSpotY"), qreal(10)); - // Changing the hotSpot won't generate a move event so the position is unchanged. Should it? - QCOMPARE(dropTarget.position.x(), qreal(35)); - QCOMPARE(dropTarget.position.y(), qreal(25)); - - item->setPos(QPointF(10, 20)); - QCOMPARE(dropTarget.position.x(), qreal(20)); - QCOMPARE(dropTarget.position.y(), qreal(30)); -} - -void tst_QQuickDrag::supportedActions() -{ - QQuickCanvas canvas; - TestDropTarget dropTarget(canvas.rootItem()); - dropTarget.setSize(QSizeF(100, 100)); - QDeclarativeComponent component(&engine); - component.setData( - "import QtQuick 2.0\n" - "Item {\n" - "property int supportedActions: Drag.supportedActions\n" - "x: 50; y: 50\n" - "width: 10; height: 10\n" - "}", QUrl()); - QScopedPointer object(component.create()); - QQuickItem *item = qobject_cast(object.data()); - QVERIFY(item); - item->setParentItem(&dropTarget); - - QCOMPARE(evaluate(item, "Drag.supportedActions == Qt.CopyAction | Qt.MoveAction | Qt.LinkAction"), true); - QCOMPARE(evaluate(item, "supportedActions == Qt.CopyAction | Qt.MoveAction | Qt.LinkAction"), true); - evaluate(item, "{ Drag.start(); Drag.cancel() }"); - QCOMPARE(dropTarget.supportedActions, Qt::CopyAction | Qt::MoveAction | Qt::LinkAction); - - evaluate(item, "Drag.supportedActions = Qt.CopyAction | Qt.MoveAction"); - QCOMPARE(evaluate(item, "Drag.supportedActions == Qt.CopyAction | Qt.MoveAction"), true); - QCOMPARE(evaluate(item, "supportedActions == Qt.CopyAction | Qt.MoveAction"), true); - evaluate(item, "Drag.start()"); - QCOMPARE(dropTarget.supportedActions, Qt::CopyAction | Qt::MoveAction); - - // Once a drag is started the proposed actions are locked in for future events. - evaluate(item, "Drag.supportedActions = Qt.MoveAction"); - QCOMPARE(evaluate(item, "Drag.supportedActions == Qt.MoveAction"), true); - QCOMPARE(evaluate(item, "supportedActions == Qt.MoveAction"), true); - item->setPos(QPointF(60, 60)); - QCOMPARE(dropTarget.supportedActions, Qt::CopyAction | Qt::MoveAction); - - // Calling start with proposed actions will override the current actions for the next sequence. - evaluate(item, "Drag.start(Qt.CopyAction)"); - QCOMPARE(evaluate(item, "Drag.supportedActions == Qt.MoveAction"), true); - QCOMPARE(evaluate(item, "supportedActions == Qt.MoveAction"), true); - QCOMPARE(dropTarget.supportedActions, Qt::CopyAction); - - evaluate(item, "Drag.start()"); - QCOMPARE(evaluate(item, "Drag.supportedActions == Qt.MoveAction"), true); - QCOMPARE(evaluate(item, "supportedActions == Qt.MoveAction"), true); - QCOMPARE(dropTarget.supportedActions, Qt::MoveAction); -} - -void tst_QQuickDrag::proposedAction() -{ - QQuickCanvas canvas; - TestDropTarget dropTarget(canvas.rootItem()); - dropTarget.setSize(QSizeF(100, 100)); - QDeclarativeComponent component(&engine); - component.setData( - "import QtQuick 2.0\n" - "Item {\n" - "property int proposedAction: Drag.proposedAction\n" - "x: 50; y: 50\n" - "width: 10; height: 10\n" - "}", QUrl()); - QScopedPointer object(component.create()); - QQuickItem *item = qobject_cast(object.data()); - QVERIFY(item); - item->setParentItem(&dropTarget); - - - QCOMPARE(evaluate(item, "Drag.proposedAction == Qt.MoveAction"), true); - QCOMPARE(evaluate(item, "proposedAction == Qt.MoveAction"), true); - evaluate(item, "{ Drag.start(); Drag.cancel() }"); - QCOMPARE(dropTarget.defaultAction, Qt::MoveAction); - QCOMPARE(dropTarget.proposedAction, Qt::MoveAction); - - evaluate(item, "Drag.proposedAction = Qt.CopyAction"); - QCOMPARE(evaluate(item, "Drag.proposedAction == Qt.CopyAction"), true); - QCOMPARE(evaluate(item, "proposedAction == Qt.CopyAction"), true); - evaluate(item, "Drag.start()"); - QCOMPARE(dropTarget.defaultAction, Qt::CopyAction); - QCOMPARE(dropTarget.proposedAction, Qt::CopyAction); - - // The proposed action can change during a drag. - evaluate(item, "Drag.proposedAction = Qt.MoveAction"); - QCOMPARE(evaluate(item, "Drag.proposedAction == Qt.MoveAction"), true); - QCOMPARE(evaluate(item, "proposedAction == Qt.MoveAction"), true); - item->setPos(QPointF(60, 60)); - QCOMPARE(dropTarget.defaultAction, Qt::MoveAction); - QCOMPARE(dropTarget.proposedAction, Qt::MoveAction); - - evaluate(item, "Drag.proposedAction = Qt.LinkAction"); - QCOMPARE(evaluate(item, "Drag.proposedAction == Qt.LinkAction"), true); - QCOMPARE(evaluate(item, "proposedAction == Qt.LinkAction"), true); - evaluate(item, "Drag.drop()"); - QCOMPARE(dropTarget.defaultAction, Qt::LinkAction); - QCOMPARE(dropTarget.proposedAction, Qt::LinkAction); -} - -void tst_QQuickDrag::keys() -{ - QDeclarativeComponent component(&engine); - component.setData( - "import QtQuick 2.0\n" - "Item {\n" - "property variant keys: Drag.keys\n" - "x: 50; y: 50\n" - "width: 10; height: 10\n" - "}", QUrl()); - QScopedPointer object(component.create()); - QQuickItem *item = qobject_cast(object.data()); - QVERIFY(item); - -// QCOMPARE(evaluate(item, "Drag.keys"), QStringList()); -// QCOMPARE(evaluate(item, "keys"), QStringList()); - QCOMPARE(item->property("keys").toStringList(), QStringList()); - - evaluate(item, "Drag.keys = [\"red\", \"blue\"]"); -// QCOMPARE(evaluate(item, "Drag.keys"), QStringList() << "red" << "blue"); -// QCOMPARE(evaluate(item, "keys"), QStringList() << "red" << "blue"); - QCOMPARE(item->property("keys").toStringList(), QStringList() << "red" << "blue"); -} - -void tst_QQuickDrag::source() -{ - - QDeclarativeComponent component(&engine); - component.setData( - "import QtQuick 2.0\n" - "Item {\n" - "property Item source: Drag.source\n" - "x: 50; y: 50\n" - "width: 10; height: 10\n" - "Item { id: proxySource; objectName: \"proxySource\" }\n" - "}", QUrl()); - QScopedPointer object(component.create()); - QQuickItem *item = qobject_cast(object.data()); - QVERIFY(item); - - QCOMPARE(evaluate(item, "Drag.source"), static_cast(item)); - QCOMPARE(evaluate(item, "source"), static_cast(item)); - - QQuickItem *proxySource = item->findChild("proxySource"); - QVERIFY(proxySource); - - evaluate(item, "Drag.source = proxySource"); - QCOMPARE(evaluate(item, "Drag.source"), static_cast(proxySource)); - QCOMPARE(evaluate(item, "source"), static_cast(proxySource)); - - evaluate(item, "Drag.source = undefined"); - QCOMPARE(evaluate(item, "Drag.source"), static_cast(item)); - QCOMPARE(evaluate(item, "source"), static_cast(item)); -} - -class RecursingDropTarget : public TestDropTarget -{ -public: - RecursingDropTarget(const QString &script, int type, QQuickItem *parent) - : TestDropTarget(parent), script(script), type(type), item(0) {} - - void setItem(QQuickItem *i) { item = i; } - -protected: - void dragEnterEvent(QDragEnterEvent *event) - { - TestDropTarget::dragEnterEvent(event); - if (type == QEvent::DragEnter && enterEvents < 2) - evaluate(item, script); - } - - void dragMoveEvent(QDragMoveEvent *event) - { - TestDropTarget::dragMoveEvent(event); - if (type == QEvent::DragMove && moveEvents < 2) - evaluate(item, script); - } - - void dragLeaveEvent(QDragLeaveEvent *event) - { - TestDropTarget::dragLeaveEvent(event); - if (type == QEvent::DragLeave && leaveEvents < 2) - evaluate(item, script); - } - - void dropEvent(QDropEvent *event) - { - TestDropTarget::dropEvent(event); - if (type == QEvent::Drop && dropEvents < 2) - evaluate(item, script); - } - -private: - QString script; - int type; - QQuickItem *item; - -}; - -void tst_QQuickDrag::recursion_data() -{ - QTest::addColumn("script"); - QTest::addColumn("type"); - QTest::addColumn("warning"); - - QTest::newRow("Drag.start() in Enter") - << QString("Drag.start()") - << int(QEvent::DragEnter) - << QByteArray(": QML QQuickDragAttached: start() cannot be called from within a drag event handler"); - QTest::newRow("Drag.cancel() in Enter") - << QString("Drag.cancel()") - << int(QEvent::DragEnter) - << QByteArray(": QML QQuickDragAttached: cancel() cannot be called from within a drag event handler"); - QTest::newRow("Drag.drop() in Enter") - << QString("Drag.drop()") - << int(QEvent::DragEnter) - << QByteArray(": QML QQuickDragAttached: drop() cannot be called from within a drag event handler"); - QTest::newRow("Drag.active = true in Enter") - << QString("Drag.active = true") - << int(QEvent::DragEnter) - << QByteArray(); - QTest::newRow("Drag.active = false in Enter") - << QString("Drag.active = false") - << int(QEvent::DragEnter) - << QByteArray(": QML QQuickDragAttached: active cannot be changed from within a drag event handler"); - QTest::newRow("move in Enter") - << QString("x = 23") - << int(QEvent::DragEnter) - << QByteArray(); - - QTest::newRow("Drag.start() in Move") - << QString("Drag.start()") - << int(QEvent::DragMove) - << QByteArray(": QML QQuickDragAttached: start() cannot be called from within a drag event handler"); - QTest::newRow("Drag.cancel() in Move") - << QString("Drag.cancel()") - << int(QEvent::DragMove) - << QByteArray(": QML QQuickDragAttached: cancel() cannot be called from within a drag event handler"); - QTest::newRow("Drag.drop() in Move") - << QString("Drag.drop()") - << int(QEvent::DragMove) - << QByteArray(": QML QQuickDragAttached: drop() cannot be called from within a drag event handler"); - QTest::newRow("Drag.active = true in Move") - << QString("Drag.active = true") - << int(QEvent::DragMove) - << QByteArray(); - QTest::newRow("Drag.active = false in Move") - << QString("Drag.active = false") - << int(QEvent::DragMove) - << QByteArray(": QML QQuickDragAttached: active cannot be changed from within a drag event handler"); - QTest::newRow("move in Move") - << QString("x = 23") - << int(QEvent::DragMove) - << QByteArray(); - - QTest::newRow("Drag.start() in Leave") - << QString("Drag.start()") - << int(QEvent::DragLeave) - << QByteArray(": QML QQuickDragAttached: start() cannot be called from within a drag event handler"); - QTest::newRow("Drag.cancel() in Leave") - << QString("Drag.cancel()") - << int(QEvent::DragLeave) - << QByteArray(": QML QQuickDragAttached: cancel() cannot be called from within a drag event handler"); - QTest::newRow("Drag.drop() in Leave") - << QString("Drag.drop()") - << int(QEvent::DragLeave) - << QByteArray(": QML QQuickDragAttached: drop() cannot be called from within a drag event handler"); - QTest::newRow("Drag.active = true in Leave") - << QString("Drag.active = true") - << int(QEvent::DragLeave) - << QByteArray(": QML QQuickDragAttached: active cannot be changed from within a drag event handler"); - QTest::newRow("Drag.active = false in Leave") - << QString("Drag.active = false") - << int(QEvent::DragLeave) - << QByteArray(); - QTest::newRow("move in Leave") - << QString("x = 23") - << int(QEvent::DragLeave) - << QByteArray(); - - QTest::newRow("Drag.start() in Drop") - << QString("Drag.start()") - << int(QEvent::Drop) - << QByteArray(": QML QQuickDragAttached: start() cannot be called from within a drag event handler"); - QTest::newRow("Drag.cancel() in Drop") - << QString("Drag.cancel()") - << int(QEvent::Drop) - << QByteArray(": QML QQuickDragAttached: cancel() cannot be called from within a drag event handler"); - QTest::newRow("Drag.drop() in Drop") - << QString("Drag.drop()") - << int(QEvent::Drop) - << QByteArray(": QML QQuickDragAttached: drop() cannot be called from within a drag event handler"); - QTest::newRow("Drag.active = true in Drop") - << QString("Drag.active = true") - << int(QEvent::Drop) - << QByteArray(": QML QQuickDragAttached: active cannot be changed from within a drag event handler"); - QTest::newRow("Drag.active = false in Drop") - << QString("Drag.active = false") - << int(QEvent::Drop) - << QByteArray(); - QTest::newRow("move in Drop") - << QString("x = 23") - << int(QEvent::Drop) - << QByteArray(); -} - -void tst_QQuickDrag::recursion() -{ - QFETCH(QString, script); - QFETCH(int, type); - QFETCH(QByteArray, warning); - - if (!warning.isEmpty()) - QTest::ignoreMessage(QtWarningMsg, warning.constData()); - - QQuickCanvas canvas; - RecursingDropTarget dropTarget(script, type, canvas.rootItem()); - dropTarget.setSize(QSizeF(100, 100)); - QDeclarativeComponent component(&engine); - component.setData( - "import QtQuick 2.0\n" - "Item {\n" - "x: 50; y: 50\n" - "width: 10; height: 10\n" - "}", QUrl()); - QScopedPointer object(component.create()); - QQuickItem *item = qobject_cast(object.data()); - QVERIFY(item); - item->setParentItem(canvas.rootItem()); - - dropTarget.setItem(item); - - evaluate(item, "Drag.start()"); - QCOMPARE(dropTarget.enterEvents, 1); - QCOMPARE(dropTarget.moveEvents, 0); - QCOMPARE(dropTarget.dropEvents, 0); - QCOMPARE(dropTarget.leaveEvents, 0); - - evaluate(item, "y = 15"); - QCOMPARE(dropTarget.enterEvents, 1); - QCOMPARE(dropTarget.moveEvents, 1); - QCOMPARE(dropTarget.dropEvents, 0); - QCOMPARE(dropTarget.leaveEvents, 0); - - if (type == QEvent::Drop) { - QCOMPARE(evaluate(item, "Drag.drop() == Qt.MoveAction"), true); - QCOMPARE(dropTarget.enterEvents, 1); - QCOMPARE(dropTarget.moveEvents, 1); - QCOMPARE(dropTarget.dropEvents, 1); - QCOMPARE(dropTarget.leaveEvents, 0); - } else { - evaluate(item, "Drag.cancel()"); - QCOMPARE(dropTarget.enterEvents, 1); - QCOMPARE(dropTarget.moveEvents, 1); - QCOMPARE(dropTarget.dropEvents, 0); - QCOMPARE(dropTarget.leaveEvents, 1); - } -} - - -QTEST_MAIN(tst_QQuickDrag) - -#include "tst_qquickdrag.moc" diff --git a/tests/auto/qtquick2/qquickdroparea/qquickdroparea.pro b/tests/auto/qtquick2/qquickdroparea/qquickdroparea.pro deleted file mode 100644 index 46fe08c145..0000000000 --- a/tests/auto/qtquick2/qquickdroparea/qquickdroparea.pro +++ /dev/null @@ -1,9 +0,0 @@ -TARGET = tst_qquickdroparea -CONFIG += testcase -macx:CONFIG -= app_bundle - -SOURCES += tst_qquickdroparea.cpp - -CONFIG += parallel_test - -QT += core-private gui-private declarative-private quick-private network testlib diff --git a/tests/auto/qtquick2/qquickdroparea/tst_qquickdroparea.cpp b/tests/auto/qtquick2/qquickdroparea/tst_qquickdroparea.cpp deleted file mode 100644 index 0cd3fa9416..0000000000 --- a/tests/auto/qtquick2/qquickdroparea/tst_qquickdroparea.cpp +++ /dev/null @@ -1,1117 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include -#include -#include -#include -#include -#include -#include - -#include - -template static T evaluate(QObject *scope, const QString &expression) -{ - QDeclarativeExpression expr(qmlContext(scope), scope, expression); - QVariant result = expr.evaluate(); - if (expr.hasError()) - qWarning() << expr.error().toString(); - return result.value(); -} - -template <> void evaluate(QObject *scope, const QString &expression) -{ - QDeclarativeExpression expr(qmlContext(scope), scope, expression); - expr.evaluate(); - if (expr.hasError()) - qWarning() << expr.error().toString(); -} - -class tst_QQuickDropArea: public QObject -{ - Q_OBJECT -private slots: - void initTestCase(); - void cleanupTestCase(); - - void containsDrag_internal(); - void containsDrag_external(); - void keys_internal(); - void keys_external(); - void source_internal(); -// void source_external(); - void position_internal(); - void position_external(); - void drop_internal(); -// void drop_external(); - void simultaneousDrags(); - -private: - QDeclarativeEngine engine; -}; - -void tst_QQuickDropArea::initTestCase() -{ - -} - -void tst_QQuickDropArea::cleanupTestCase() -{ - -} - -void tst_QQuickDropArea::containsDrag_internal() -{ - QQuickCanvas canvas; - QDeclarativeComponent component(&engine); - component.setData( - "import QtQuick 2.0\n" - "DropArea {\n" - "property bool hasDrag: containsDrag\n" - "property int enterEvents: 0\n" - "property int exitEvents: 0\n" - "width: 100; height: 100\n" - "onEntered: {++enterEvents}\n" - "onExited: {++exitEvents}\n" - "Item {\n" - "objectName: \"dragItem\"\n" - "x: 50; y: 50\n" - "width: 10; height: 10\n" - "}\n" - "}", QUrl()); - QScopedPointer object(component.create()); - QQuickItem *dropArea = qobject_cast(object.data()); - QVERIFY(dropArea); - dropArea->setParentItem(canvas.rootItem()); - - QQuickItem *dragItem = dropArea->findChild("dragItem"); - QVERIFY(dragItem); - - QCOMPARE(evaluate(dropArea, "containsDrag"), false); - QCOMPARE(evaluate(dropArea, "hasDrag"), false); - - evaluate(dragItem, "Drag.active = true"); - QCOMPARE(evaluate(dropArea, "containsDrag"), true); - QCOMPARE(evaluate(dropArea, "hasDrag"), true); - QCOMPARE(evaluate(dropArea, "enterEvents"), 1); - QCOMPARE(evaluate(dropArea, "exitEvents"), 0); - - evaluate(dropArea, "{ enterEvents = 0; exitEvents = 0 }"); - evaluate(dragItem, "Drag.active = false"); - QCOMPARE(evaluate(dropArea, "containsDrag"), false); - QCOMPARE(evaluate(dropArea, "hasDrag"), false); - QCOMPARE(evaluate(dropArea, "enterEvents"), 0); - QCOMPARE(evaluate(dropArea, "exitEvents"), 1); - - evaluate(dropArea, "{ enterEvents = 0; exitEvents = 0 }"); - - dragItem->setPos(QPointF(150, 50)); - evaluate(dragItem, "Drag.active = true"); - QCOMPARE(evaluate(dropArea, "containsDrag"), false); - QCOMPARE(evaluate(dropArea, "hasDrag"), false); - QCOMPARE(evaluate(dropArea, "enterEvents"), 0); - QCOMPARE(evaluate(dropArea, "exitEvents"), 0); - - dragItem->setPos(QPointF(50, 50)); - QCOMPARE(evaluate(dropArea, "containsDrag"), true); - QCOMPARE(evaluate(dropArea, "hasDrag"), true); - QCOMPARE(evaluate(dropArea, "enterEvents"), 1); - QCOMPARE(evaluate(dropArea, "exitEvents"), 0); - - evaluate(dropArea, "{ enterEvents = 0; exitEvents = 0 }"); - dragItem->setPos(QPointF(150, 50)); - - QCOMPARE(evaluate(dropArea, "containsDrag"), false); - QCOMPARE(evaluate(dropArea, "hasDrag"), false); - QCOMPARE(evaluate(dropArea, "enterEvents"), 0); - QCOMPARE(evaluate(dropArea, "exitEvents"), 1); - - evaluate(dragItem, "Drag.active = false"); -} - -void tst_QQuickDropArea::containsDrag_external() -{ - QQuickCanvas canvas; - QDeclarativeComponent component(&engine); - component.setData( - "import QtQuick 2.0\n" - "DropArea {\n" - "property bool hasDrag: containsDrag\n" - "property int enterEvents: 0\n" - "property int exitEvents: 0\n" - "width: 100; height: 100\n" - "onEntered: {++enterEvents}\n" - "onExited: {++exitEvents}\n" - "}", QUrl()); - QScopedPointer object(component.create()); - QQuickItem *dropArea = qobject_cast(object.data()); - QVERIFY(dropArea); - dropArea->setParentItem(canvas.rootItem()); - - QMimeData data; - QQuickCanvas alternateCanvas; - - QCOMPARE(evaluate(dropArea, "containsDrag"), false); - QCOMPARE(evaluate(dropArea, "hasDrag"), false); - - QWindowSystemInterface::handleDrag(&canvas, &data, QPoint(50, 50)); - QCOMPARE(evaluate(dropArea, "containsDrag"), true); - QCOMPARE(evaluate(dropArea, "hasDrag"), true); - QCOMPARE(evaluate(dropArea, "enterEvents"), 1); - QCOMPARE(evaluate(dropArea, "exitEvents"), 0); - - evaluate(dropArea, "{ enterEvents = 0; exitEvents = 0 }"); - QWindowSystemInterface::handleDrag(&alternateCanvas, &data, QPoint(50, 50)); - QCOMPARE(evaluate(dropArea, "containsDrag"), false); - QCOMPARE(evaluate(dropArea, "hasDrag"), false); - QCOMPARE(evaluate(dropArea, "enterEvents"), 0); - QCOMPARE(evaluate(dropArea, "exitEvents"), 1); - - evaluate(dropArea, "{ enterEvents = 0; exitEvents = 0 }"); - - QWindowSystemInterface::handleDrag(&canvas, &data, QPoint(150, 50)); - QCOMPARE(evaluate(dropArea, "containsDrag"), false); - QCOMPARE(evaluate(dropArea, "hasDrag"), false); - QCOMPARE(evaluate(dropArea, "enterEvents"), 0); - QCOMPARE(evaluate(dropArea, "exitEvents"), 0); - - QWindowSystemInterface::handleDrag(&canvas, &data, QPoint(50, 50)); - QCOMPARE(evaluate(dropArea, "containsDrag"), true); - QCOMPARE(evaluate(dropArea, "hasDrag"), true); - QCOMPARE(evaluate(dropArea, "enterEvents"), 1); - QCOMPARE(evaluate(dropArea, "exitEvents"), 0); - - evaluate(dropArea, "{ enterEvents = 0; exitEvents = 0 }"); - - QWindowSystemInterface::handleDrag(&canvas, &data, QPoint(150, 50)); - QCOMPARE(evaluate(dropArea, "containsDrag"), false); - QCOMPARE(evaluate(dropArea, "hasDrag"), false); - QCOMPARE(evaluate(dropArea, "enterEvents"), 0); - QCOMPARE(evaluate(dropArea, "exitEvents"), 1); - - QWindowSystemInterface::handleDrop(&canvas, &data, QPoint(150, 50)); -} - -void tst_QQuickDropArea::keys_internal() -{ - QQuickCanvas canvas; - QDeclarativeComponent component(&engine); - component.setData( - "import QtQuick 2.0\n" - "DropArea {\n" - "property variant dragKeys\n" - "property variant dropKeys: keys\n" - "property int enterEvents: 0\n" - "width: 100; height: 100\n" - "onEntered: {++enterEvents; dragKeys = drag.keys }\n" - "Item {\n" - "objectName: \"dragItem\"\n" - "x: 50; y: 50\n" - "width: 10; height: 10\n" - "Drag.keys: [\"red\", \"blue\"]\n" - "}\n" - "}", QUrl()); - QScopedPointer object(component.create()); - QQuickItem *dropArea = qobject_cast(object.data()); - QVERIFY(dropArea); - dropArea->setParentItem(canvas.rootItem()); - - QQuickItem *dragItem = dropArea->findChild("dragItem"); - QVERIFY(dragItem); - - QCOMPARE(evaluate(dropArea, "containsDrag"), false); - - evaluate(dragItem, "Drag.active = true"); - QCOMPARE(evaluate(dropArea, "containsDrag"), true); - QCOMPARE(evaluate(dropArea, "enterEvents"), 1); - QCOMPARE(dropArea->property("dragKeys").toStringList(), QStringList() << "red" << "blue"); - - evaluate(dragItem, "Drag.active = false"); - evaluate(dropArea, "keys = \"blue\""); - QCOMPARE(dropArea->property("keys").toStringList(), QStringList() << "blue"); - QCOMPARE(dropArea->property("dropKeys").toStringList(), QStringList() << "blue"); - evaluate(dropArea, "{ enterEvents = 0; dragKeys = undefined }"); - evaluate(dragItem, "Drag.active = true"); - QCOMPARE(evaluate(dropArea, "containsDrag"), true); - QCOMPARE(evaluate(dropArea, "enterEvents"), 1); - QCOMPARE(dropArea->property("dragKeys").toStringList(), QStringList() << "red" << "blue"); - - evaluate(dragItem, "Drag.active = false"); - evaluate(dropArea, "keys = \"red\""); - QCOMPARE(dropArea->property("keys").toStringList(), QStringList() << "red"); - QCOMPARE(dropArea->property("dropKeys").toStringList(), QStringList() << "red"); - evaluate(dropArea, "{ enterEvents = 0; dragKeys = undefined }"); - evaluate(dragItem, "Drag.active = true"); - QCOMPARE(evaluate(dropArea, "containsDrag"), true); - QCOMPARE(evaluate(dropArea, "enterEvents"), 1); - QCOMPARE(dropArea->property("dragKeys").toStringList(), QStringList() << "red" << "blue"); - - evaluate(dragItem, "Drag.active = false"); - evaluate(dropArea, "keys = \"green\""); - QCOMPARE(dropArea->property("keys").toStringList(), QStringList() << "green"); - QCOMPARE(dropArea->property("dropKeys").toStringList(), QStringList() << "green"); - evaluate(dropArea, "{ enterEvents = 0; dragKeys = undefined }"); - evaluate(dragItem, "Drag.active = true"); - QCOMPARE(evaluate(dropArea, "containsDrag"), false); - QCOMPARE(evaluate(dropArea, "enterEvents"), 0); - - evaluate(dragItem, "Drag.active = false"); - evaluate(dropArea, "keys = [\"red\", \"green\"]"); - QCOMPARE(dropArea->property("keys").toStringList(), QStringList() << "red" << "green"); - QCOMPARE(dropArea->property("dropKeys").toStringList(), QStringList() << "red" << "green"); - evaluate(dropArea, "{ enterEvents = 0; dragKeys = undefined }"); - evaluate(dragItem, "Drag.active = true"); - QCOMPARE(evaluate(dropArea, "containsDrag"), true); - QCOMPARE(evaluate(dropArea, "enterEvents"), 1); - QCOMPARE(dropArea->property("dragKeys").toStringList(), QStringList() << "red" << "blue"); - - evaluate(dragItem, "Drag.active = false"); - evaluate(dragItem, "Drag.keys = []"); - evaluate(dropArea, "{ enterEvents = 0; dragKeys = undefined }"); - evaluate(dragItem, "Drag.active = true"); - QCOMPARE(evaluate(dropArea, "containsDrag"), false); - QCOMPARE(evaluate(dropArea, "enterEvents"), 0); - - evaluate(dragItem, "Drag.active = false"); - evaluate(dropArea, "keys = []"); - QCOMPARE(dropArea->property("keys").toStringList(), QStringList()); - QCOMPARE(dropArea->property("dropKeys").toStringList(), QStringList()); - evaluate(dropArea, "{ enterEvents = 0; dragKeys = undefined }"); - evaluate(dragItem, "Drag.active = true"); - QCOMPARE(evaluate(dropArea, "containsDrag"), true); - QCOMPARE(evaluate(dropArea, "enterEvents"), 1); - QCOMPARE(dropArea->property("dragKeys").toStringList(), QStringList()); - - evaluate(dragItem, "Drag.active = false"); - evaluate(dropArea, "keys = []"); - evaluate(dropArea, "{ enterEvents = 0; dragKeys = undefined }"); - evaluate(dragItem, "Drag.active = true"); - QCOMPARE(evaluate(dropArea, "containsDrag"), true); - QCOMPARE(evaluate(dropArea, "enterEvents"), 1); - QCOMPARE(dropArea->property("dragKeys").toStringList(), QStringList()); - - evaluate(dragItem, "Drag.active = false"); - evaluate(dragItem, "Drag.keys = [\"red\", \"blue\"]"); - evaluate(dropArea, "{ enterEvents = 0; dragKeys = undefined }"); - evaluate(dragItem, "Drag.active = true"); - QCOMPARE(evaluate(dropArea, "containsDrag"), true); - QCOMPARE(evaluate(dropArea, "enterEvents"), 1); - QCOMPARE(dropArea->property("dragKeys").toStringList(), QStringList() << "red" << "blue"); -} - -void tst_QQuickDropArea::keys_external() -{ - QQuickCanvas canvas; - QDeclarativeComponent component(&engine); - component.setData( - "import QtQuick 2.0\n" - "DropArea {\n" - "property variant dragKeys\n" - "property variant dropKeys: keys\n" - "property int enterEvents: 0\n" - "width: 100; height: 100\n" - "onEntered: {++enterEvents; dragKeys = drag.keys }\n" - "}", QUrl()); - QScopedPointer object(component.create()); - QQuickItem *dropArea = qobject_cast(object.data()); - dropArea->setParentItem(canvas.rootItem()); - - QMimeData data; - QQuickCanvas alternateCanvas; - - data.setData("text/x-red", "red"); - data.setData("text/x-blue", "blue"); - - QCOMPARE(evaluate(dropArea, "containsDrag"), false); - - QWindowSystemInterface::handleDrag(&canvas, &data, QPoint(50, 50)); - QCOMPARE(evaluate(dropArea, "containsDrag"), true); - QCOMPARE(evaluate(dropArea, "enterEvents"), 1); - QCOMPARE(dropArea->property("dragKeys").toStringList(), QStringList() << "text/x-red" << "text/x-blue"); - - QWindowSystemInterface::handleDrag(&alternateCanvas, &data, QPoint(50, 50)); - evaluate(dropArea, "keys = \"text/x-blue\""); - QCOMPARE(dropArea->property("keys").toStringList(), QStringList() << "text/x-blue"); - QCOMPARE(dropArea->property("dropKeys").toStringList(), QStringList() << "text/x-blue"); - evaluate(dropArea, "{ enterEvents = 0; dragKeys = undefined }"); - QWindowSystemInterface::handleDrag(&canvas, &data, QPoint(50, 50)); - QCOMPARE(evaluate(dropArea, "containsDrag"), true); - QCOMPARE(evaluate(dropArea, "enterEvents"), 1); - QCOMPARE(dropArea->property("dragKeys").toStringList(), QStringList() << "text/x-red" << "text/x-blue"); - - QWindowSystemInterface::handleDrag(&alternateCanvas, &data, QPoint(50, 50)); - evaluate(dropArea, "keys = \"text/x-red\""); - QCOMPARE(dropArea->property("keys").toStringList(), QStringList() << "text/x-red"); - QCOMPARE(dropArea->property("dropKeys").toStringList(), QStringList() << "text/x-red"); - evaluate(dropArea, "{ enterEvents = 0; dragKeys = undefined }"); - QWindowSystemInterface::handleDrag(&canvas, &data, QPoint(50, 50)); - QCOMPARE(evaluate(dropArea, "containsDrag"), true); - QCOMPARE(evaluate(dropArea, "enterEvents"), 1); - QCOMPARE(dropArea->property("dragKeys").toStringList(), QStringList() << "text/x-red" << "text/x-blue"); - - QWindowSystemInterface::handleDrag(&alternateCanvas, &data, QPoint(50, 50)); - evaluate(dropArea, "keys = \"text/x-green\""); - QCOMPARE(dropArea->property("keys").toStringList(), QStringList() << "text/x-green"); - QCOMPARE(dropArea->property("dropKeys").toStringList(), QStringList() << "text/x-green"); - evaluate(dropArea, "{ enterEvents = 0; dragKeys = undefined }"); - QWindowSystemInterface::handleDrag(&canvas, &data, QPoint(50, 50)); - QCOMPARE(evaluate(dropArea, "containsDrag"), false); - QCOMPARE(evaluate(dropArea, "enterEvents"), 0); - - QWindowSystemInterface::handleDrag(&alternateCanvas, &data, QPoint(50, 50)); - evaluate(dropArea, "keys = [\"text/x-red\", \"text/x-green\"]"); - QCOMPARE(dropArea->property("keys").toStringList(), QStringList() << "text/x-red" << "text/x-green"); - QCOMPARE(dropArea->property("dropKeys").toStringList(), QStringList() << "text/x-red" << "text/x-green"); - evaluate(dropArea, "{ enterEvents = 0; dragKeys = undefined }"); - QWindowSystemInterface::handleDrag(&canvas, &data, QPoint(50, 50)); - QCOMPARE(evaluate(dropArea, "containsDrag"), true); - QCOMPARE(evaluate(dropArea, "enterEvents"), 1); - QCOMPARE(dropArea->property("dragKeys").toStringList(), QStringList() << "text/x-red" << "text/x-blue"); - - QWindowSystemInterface::handleDrag(&alternateCanvas, &data, QPoint(50, 50)); - data.removeFormat("text/x-red"); - data.removeFormat("text/x-blue"); - evaluate(dropArea, "{ enterEvents = 0; dragKeys = undefined }"); - QWindowSystemInterface::handleDrag(&canvas, &data, QPoint(50, 50)); - QCOMPARE(evaluate(dropArea, "containsDrag"), false); - QCOMPARE(evaluate(dropArea, "enterEvents"), 0); - - QWindowSystemInterface::handleDrag(&alternateCanvas, &data, QPoint(50, 50)); - evaluate(dropArea, "keys = []"); - QCOMPARE(dropArea->property("keys").toStringList(), QStringList()); - QCOMPARE(dropArea->property("dropKeys").toStringList(), QStringList()); - evaluate(dropArea, "{ enterEvents = 0; dragKeys = undefined }"); - QWindowSystemInterface::handleDrag(&canvas, &data, QPoint(50, 50)); - QCOMPARE(evaluate(dropArea, "containsDrag"), true); - QCOMPARE(evaluate(dropArea, "enterEvents"), 1); - QCOMPARE(dropArea->property("dragKeys").toStringList(), QStringList()); - - QWindowSystemInterface::handleDrag(&alternateCanvas, &data, QPoint(50, 50)); - data.setData("text/x-red", "red"); - data.setData("text/x-blue", "blue"); - QCOMPARE(dropArea->property("keys").toStringList(), QStringList()); - QCOMPARE(dropArea->property("dropKeys").toStringList(), QStringList()); - evaluate(dropArea, "{ enterEvents = 0; dragKeys = undefined }"); - QWindowSystemInterface::handleDrag(&canvas, &data, QPoint(50, 50)); - QCOMPARE(evaluate(dropArea, "containsDrag"), true); - QCOMPARE(evaluate(dropArea, "enterEvents"), 1); - QCOMPARE(dropArea->property("dragKeys").toStringList(), QStringList() << "text/x-red" << "text/x-blue"); - - QWindowSystemInterface::handleDrop(&canvas, &data, QPoint(50, 50)); -} - -void tst_QQuickDropArea::source_internal() -{ - QQuickCanvas canvas; - QDeclarativeComponent component(&engine); - component.setData( - "import QtQuick 2.0\n" - "DropArea {\n" - "property Item source: drag.source\n" - "property Item eventSource\n" - "width: 100; height: 100\n" - "onEntered: {eventSource = drag.source}\n" - "Item {\n" - "objectName: \"dragItem\"\n" - "x: 50; y: 50\n" - "width: 10; height: 10\n" - "}\n" - "Item { id: dragSource; objectName: \"dragSource\" }\n" - "}", QUrl()); - QScopedPointer object(component.create()); - QQuickItem *dropArea = qobject_cast(object.data()); - QVERIFY(dropArea); - dropArea->setParentItem(canvas.rootItem()); - - QQuickItem *dragItem = dropArea->findChild("dragItem"); - QVERIFY(dragItem); - - QQuickItem *dragSource = dropArea->findChild("dragSource"); - QVERIFY(dragSource); - - QCOMPARE(evaluate(dropArea, "source"), static_cast(0)); - QCOMPARE(evaluate(dropArea, "drag.source"), static_cast(0)); - - evaluate(dragItem, "Drag.active = true"); - QCOMPARE(evaluate(dropArea, "source"), static_cast(dragItem)); - QCOMPARE(evaluate(dropArea, "drag.source"), static_cast(dragItem)); - QCOMPARE(evaluate(dropArea, "eventSource"), static_cast(dragItem)); - - evaluate(dragItem, "Drag.active = false"); - QCOMPARE(evaluate(dropArea, "source"), static_cast(0)); - QCOMPARE(evaluate(dropArea, "drag.source"), static_cast(0)); - - - evaluate(dropArea, "{ eventSource = null }"); - evaluate(dragItem, "Drag.source = dragSource"); - - evaluate(dragItem, "Drag.active = true"); - QCOMPARE(evaluate(dropArea, "source"), static_cast(dragSource)); - QCOMPARE(evaluate(dropArea, "drag.source"), static_cast(dragSource)); - QCOMPARE(evaluate(dropArea, "eventSource"), static_cast(dragSource)); - - evaluate(dragItem, "Drag.active = false"); - QCOMPARE(evaluate(dropArea, "source"), static_cast(0)); - QCOMPARE(evaluate(dropArea, "drag.source"), static_cast(0)); -} - -// Setting a source can't be emulated using the QWindowSystemInterface API. - -//void tst_QQuickDropArea::source_external() -//{ -//} - -void tst_QQuickDropArea::position_internal() -{ - QQuickCanvas canvas; - QDeclarativeComponent component(&engine); - component.setData( - "import QtQuick 2.0\n" - "DropArea {\n" - "property real dragX: drag.x\n" - "property real dragY: drag.y\n" - "property real eventX\n" - "property real eventY\n" - "property int enterEvents: 0\n" - "property int moveEvents: 0\n" - "width: 100; height: 100\n" - "onEntered: {++enterEvents; eventX = drag.x; eventY = drag.y}\n" - "onPositionChanged: {++moveEvents; eventX = drag.x; eventY = drag.y}\n" - "Item {\n" - "objectName: \"dragItem\"\n" - "x: 50; y: 50\n" - "width: 10; height: 10\n" - "}\n" - "}", QUrl()); - QScopedPointer object(component.create()); - QQuickItem *dropArea = qobject_cast(object.data()); - QVERIFY(dropArea); - dropArea->setParentItem(canvas.rootItem()); - - QQuickItem *dragItem = dropArea->findChild("dragItem"); - QVERIFY(dragItem); - - evaluate(dragItem, "Drag.active = true"); - QCOMPARE(evaluate(dropArea, "enterEvents"), 1); - QCOMPARE(evaluate(dropArea, "moveEvents"), 0); - QCOMPARE(evaluate(dropArea, "drag.x"), qreal(50)); - QCOMPARE(evaluate(dropArea, "drag.y"), qreal(50)); - QCOMPARE(evaluate(dropArea, "dragX"), qreal(50)); - QCOMPARE(evaluate(dropArea, "dragY"), qreal(50)); - QCOMPARE(evaluate(dropArea, "eventX"), qreal(50)); - QCOMPARE(evaluate(dropArea, "eventY"), qreal(50)); - - evaluate(dropArea, "{ enterEvents = 0; moveEvents = 0; eventX = -1; eventY = -1 }"); - dragItem->setPos(QPointF(40, 50)); - QCOMPARE(evaluate(dropArea, "enterEvents"), 0); - QCOMPARE(evaluate(dropArea, "moveEvents"), 1); - QCOMPARE(evaluate(dropArea, "drag.x"), qreal(40)); - QCOMPARE(evaluate(dropArea, "drag.y"), qreal(50)); - QCOMPARE(evaluate(dropArea, "dragX"), qreal(40)); - QCOMPARE(evaluate(dropArea, "dragY"), qreal(50)); - QCOMPARE(evaluate(dropArea, "eventX"), qreal(40)); - QCOMPARE(evaluate(dropArea, "eventY"), qreal(50)); - - evaluate(dropArea, "{ enterEvents = 0; moveEvents = 0; eventX = -1; eventY = -1 }"); - dragItem->setPos(QPointF(75, 25)); - QCOMPARE(evaluate(dropArea, "enterEvents"), 0); - QCOMPARE(evaluate(dropArea, "moveEvents"), 1); - QCOMPARE(evaluate(dropArea, "drag.x"), qreal(75)); - QCOMPARE(evaluate(dropArea, "drag.y"), qreal(25)); - QCOMPARE(evaluate(dropArea, "dragX"), qreal(75)); - QCOMPARE(evaluate(dropArea, "dragY"), qreal(25)); - QCOMPARE(evaluate(dropArea, "eventX"), qreal(75)); - QCOMPARE(evaluate(dropArea, "eventY"), qreal(25)); - - evaluate(dragItem, "Drag.active = false"); -} - -void tst_QQuickDropArea::position_external() -{ - QQuickCanvas canvas; - QDeclarativeComponent component(&engine); - component.setData( - "import QtQuick 2.0\n" - "DropArea {\n" - "property real dragX: drag.x\n" - "property real dragY: drag.y\n" - "property real eventX\n" - "property real eventY\n" - "property int enterEvents: 0\n" - "property int moveEvents: 0\n" - "width: 100; height: 100\n" - "onEntered: {++enterEvents; eventX = drag.x; eventY = drag.y}\n" - "onPositionChanged: {++moveEvents; eventX = drag.x; eventY = drag.y}\n" - "}", QUrl()); - QScopedPointer object(component.create()); - QQuickItem *dropArea = qobject_cast(object.data()); - QVERIFY(dropArea); - dropArea->setParentItem(canvas.rootItem()); - - QMimeData data; - - QWindowSystemInterface::handleDrag(&canvas, &data, QPoint(50, 50)); - QCOMPARE(evaluate(dropArea, "enterEvents"), 1); - QCOMPARE(evaluate(dropArea, "moveEvents"), 1); - QCOMPARE(evaluate(dropArea, "drag.x"), qreal(50)); - QCOMPARE(evaluate(dropArea, "drag.y"), qreal(50)); - QCOMPARE(evaluate(dropArea, "dragX"), qreal(50)); - QCOMPARE(evaluate(dropArea, "dragY"), qreal(50)); - QCOMPARE(evaluate(dropArea, "eventX"), qreal(50)); - QCOMPARE(evaluate(dropArea, "eventY"), qreal(50)); - - evaluate(dropArea, "{ enterEvents = 0; moveEvents = 0; eventX = -1; eventY = -1 }"); - QWindowSystemInterface::handleDrag(&canvas, &data, QPoint(40, 50)); - QCOMPARE(evaluate(dropArea, "enterEvents"), 0); - QCOMPARE(evaluate(dropArea, "moveEvents"), 1); - QCOMPARE(evaluate(dropArea, "drag.x"), qreal(40)); - QCOMPARE(evaluate(dropArea, "drag.y"), qreal(50)); - QCOMPARE(evaluate(dropArea, "dragX"), qreal(40)); - QCOMPARE(evaluate(dropArea, "dragY"), qreal(50)); - QCOMPARE(evaluate(dropArea, "eventX"), qreal(40)); - QCOMPARE(evaluate(dropArea, "eventY"), qreal(50)); - - evaluate(dropArea, "{ enterEvents = 0; moveEvents = 0; eventX = -1; eventY = -1 }"); - QWindowSystemInterface::handleDrag(&canvas, &data, QPoint(75, 25)); - QCOMPARE(evaluate(dropArea, "enterEvents"), 0); - QCOMPARE(evaluate(dropArea, "moveEvents"), 1); - QCOMPARE(evaluate(dropArea, "drag.x"), qreal(75)); - QCOMPARE(evaluate(dropArea, "drag.y"), qreal(25)); - QCOMPARE(evaluate(dropArea, "dragX"), qreal(75)); - QCOMPARE(evaluate(dropArea, "dragY"), qreal(25)); - QCOMPARE(evaluate(dropArea, "eventX"), qreal(75)); - QCOMPARE(evaluate(dropArea, "eventY"), qreal(25)); - - QWindowSystemInterface::handleDrop(&canvas, &data, QPoint(75, 25)); -} - -void tst_QQuickDropArea::drop_internal() -{ - QQuickCanvas canvas; - QDeclarativeComponent component(&engine); - component.setData( - "import QtQuick 2.0\n" - "DropArea {\n" - "property bool accept: false\n" - "property bool setAccepted: false\n" - "property bool acceptDropAction: false\n" - "property bool setDropAction: false\n" - "property int dropAction: Qt.IgnoreAction\n" - "property int proposedAction: Qt.IgnoreAction\n" - "property int supportedActions: Qt.IgnoreAction\n" - "property int dropEvents: 0\n" - "width: 100; height: 100\n" - "onDropped: {\n" - "++dropEvents\n" - "supportedActions = drop.supportedActions\n" - "proposedAction = drop.action\n" - "if (setDropAction)\n" - "drop.action = dropAction\n" - "if (acceptDropAction)\n" - "drop.accept(dropAction)\n" - "else if (setAccepted)\n" - "drop.accepted = accept\n" - "else if (accept)\n" - "drop.accept()\n" - "}\n" - "Item {\n" - "objectName: \"dragItem\"\n" - "x: 50; y: 50\n" - "width: 10; height: 10\n" - "}\n" - "}", QUrl()); - QScopedPointer object(component.create()); - QQuickItem *dropArea = qobject_cast(object.data()); - QVERIFY(dropArea); - dropArea->setParentItem(canvas.rootItem()); - - QQuickItem *dragItem = dropArea->findChild("dragItem"); - QVERIFY(dragItem); - - evaluate(dragItem, "Drag.active = true"); - QCOMPARE(evaluate(dragItem, "Drag.drop()"), int(Qt::IgnoreAction)); - QCOMPARE(evaluate(dropArea, "dropEvents"), 1); - QCOMPARE(evaluate(dropArea, "supportedActions"), int(Qt::CopyAction | Qt::MoveAction | Qt::LinkAction)); - QCOMPARE(evaluate(dropArea, "proposedAction"), int(Qt::MoveAction)); - - evaluate(dropArea, "{ dropEvents = 0; proposedAction = Qt.IgnoreAction; supportedActions = Qt.IgnoreAction }"); - evaluate(dropArea, "{ accept = true; setDropAction = true; dropAction = Qt.LinkAction }"); - evaluate(dragItem, "Drag.active = true"); - QCOMPARE(evaluate(dragItem, "Drag.drop()"), int(Qt::LinkAction)); - QCOMPARE(evaluate(dropArea, "dropEvents"), 1); - QCOMPARE(evaluate(dropArea, "supportedActions"), int(Qt::CopyAction | Qt::MoveAction | Qt::LinkAction)); - QCOMPARE(evaluate(dropArea, "proposedAction"), int(Qt::MoveAction)); - - evaluate(dropArea, "{ dropEvents = 0; proposedAction = Qt.IgnoreAction; supportedActions = Qt.IgnoreAction }"); - evaluate(dropArea, "{ setAccepted = true; }"); - evaluate(dragItem, "Drag.active = true"); - QCOMPARE(evaluate(dragItem, "Drag.drop()"), int(Qt::LinkAction)); - QCOMPARE(evaluate(dropArea, "dropEvents"), 1); - QCOMPARE(evaluate(dropArea, "supportedActions"), int(Qt::CopyAction | Qt::MoveAction | Qt::LinkAction)); - QCOMPARE(evaluate(dropArea, "proposedAction"), int(Qt::MoveAction)); - - evaluate(dropArea, "{ dropEvents = 0; proposedAction = Qt.IgnoreAction; supportedActions = Qt.IgnoreAction }"); - evaluate(dropArea, "{ accept = false; setAccepted = true; }"); - evaluate(dragItem, "Drag.active = true"); - QCOMPARE(evaluate(dragItem, "Drag.drop()"), int(Qt::IgnoreAction)); - QCOMPARE(evaluate(dropArea, "dropEvents"), 1); - QCOMPARE(evaluate(dropArea, "supportedActions"), int(Qt::CopyAction | Qt::MoveAction | Qt::LinkAction)); - QCOMPARE(evaluate(dropArea, "proposedAction"), int(Qt::MoveAction)); - - evaluate(dropArea, "{ dropEvents = 0; proposedAction = Qt.IgnoreAction; supportedActions = Qt.IgnoreAction }"); - evaluate(dropArea, "{ setAccepted = false; setDropAction = false; acceptDropAction = true; }"); - evaluate(dragItem, "Drag.active = true"); - QCOMPARE(evaluate(dragItem, "Drag.drop()"), int(Qt::LinkAction)); - QCOMPARE(evaluate(dropArea, "dropEvents"), 1); - QCOMPARE(evaluate(dropArea, "supportedActions"), int(Qt::CopyAction | Qt::MoveAction | Qt::LinkAction)); - QCOMPARE(evaluate(dropArea, "proposedAction"), int(Qt::MoveAction)); - - evaluate(dropArea, "{ dropEvents = 0; proposedAction = Qt.IgnoreAction; supportedActions = Qt.IgnoreAction }"); - evaluate(dropArea, "{ acceptDropAction = false; dropAction = Qt.IgnoreAction; accept = true }"); - evaluate(dragItem, "Drag.active = true"); - QCOMPARE(evaluate(dragItem, "Drag.drop()"), int(Qt::MoveAction)); - QCOMPARE(evaluate(dropArea, "dropEvents"), 1); - QCOMPARE(evaluate(dropArea, "supportedActions"), int(Qt::CopyAction | Qt::MoveAction | Qt::LinkAction)); - QCOMPARE(evaluate(dropArea, "proposedAction"), int(Qt::MoveAction)); - - evaluate(dropArea, "{ dropEvents = 0; proposedAction = Qt.IgnoreAction; supportedActions = Qt.IgnoreAction }"); - evaluate(dropArea, "{ setAccepted = true }"); - evaluate(dragItem, "Drag.active = true"); - QCOMPARE(evaluate(dragItem, "Drag.drop()"), int(Qt::MoveAction)); - QCOMPARE(evaluate(dropArea, "dropEvents"), 1); - QCOMPARE(evaluate(dropArea, "supportedActions"), int(Qt::CopyAction | Qt::MoveAction | Qt::LinkAction)); - QCOMPARE(evaluate(dropArea, "proposedAction"), int(Qt::MoveAction)); - - evaluate(dropArea, "{ dropEvents = 0; proposedAction = Qt.IgnoreAction; supportedActions = Qt.IgnoreAction }"); - evaluate(dropArea, "{ setAccepted = false }"); - evaluate(dragItem, "Drag.supportedActions = Qt.LinkAction"); - evaluate(dragItem, "Drag.active = true"); - QCOMPARE(evaluate(dragItem, "Drag.drop()"), int(Qt::MoveAction)); - QCOMPARE(evaluate(dropArea, "dropEvents"), 1); - QCOMPARE(evaluate(dropArea, "supportedActions"), int(Qt::LinkAction)); - QCOMPARE(evaluate(dropArea, "proposedAction"), int(Qt::MoveAction)); - - evaluate(dropArea, "{ dropEvents = 0; proposedAction = Qt.IgnoreAction; supportedActions = Qt.IgnoreAction }"); - evaluate(dropArea, "{ setAccepted = true }"); - evaluate(dragItem, "Drag.active = true"); - QCOMPARE(evaluate(dragItem, "Drag.drop()"), int(Qt::MoveAction)); - QCOMPARE(evaluate(dropArea, "dropEvents"), 1); - QCOMPARE(evaluate(dropArea, "supportedActions"), int(Qt::LinkAction)); - QCOMPARE(evaluate(dropArea, "proposedAction"), int(Qt::MoveAction)); - - evaluate(dropArea, "{ dropEvents = 0; proposedAction = Qt.IgnoreAction; supportedActions = Qt.IgnoreAction }"); - evaluate(dropArea, "{ setAccepted = false }"); - evaluate(dragItem, "Drag.proposedAction = Qt.LinkAction"); - evaluate(dragItem, "Drag.active = true"); - QCOMPARE(evaluate(dragItem, "Drag.drop()"), int(Qt::LinkAction)); - QCOMPARE(evaluate(dropArea, "dropEvents"), 1); - QCOMPARE(evaluate(dropArea, "supportedActions"), int(Qt::LinkAction)); - QCOMPARE(evaluate(dropArea, "proposedAction"), int(Qt::LinkAction)); - - evaluate(dropArea, "{ dropEvents = 0; proposedAction = Qt.IgnoreAction; supportedActions = Qt.IgnoreAction }"); - evaluate(dropArea, "{ setAccepted = true }"); - evaluate(dragItem, "Drag.active = true"); - QCOMPARE(evaluate(dragItem, "Drag.drop()"), int(Qt::LinkAction)); - QCOMPARE(evaluate(dropArea, "dropEvents"), 1); - QCOMPARE(evaluate(dropArea, "supportedActions"), int(Qt::LinkAction)); - QCOMPARE(evaluate(dropArea, "proposedAction"), int(Qt::LinkAction)); -} - -// Setting the supportedActions can't be emulated using the QWindowSystemInterface API. - -//void tst_QQuickDropArea::drop_external() -//{ -//} - -void tst_QQuickDropArea::simultaneousDrags() -{ - QQuickCanvas canvas; - QDeclarativeComponent component(&engine); - component.setData( - "import QtQuick 2.0\n" - "DropArea {\n" - "property int enterEvents: 0\n" - "property int exitEvents: 0\n" - "width: 100; height: 100\n" - "keys: [\"red\", \"text/x-red\"]\n" - "onEntered: {++enterEvents}\n" - "onExited: {++exitEvents}\n" - "DropArea {\n" - "objectName: \"dropArea2\"\n" - "property int enterEvents: 0\n" - "property int exitEvents: 0\n" - "width: 100; height: 100\n" - "keys: [\"blue\", \"text/x-blue\"]\n" - "onEntered: {++enterEvents}\n" - "onExited: {++exitEvents}\n" - "}\n" - "Item {\n" - "objectName: \"dragItem1\"\n" - "x: 50; y: 50\n" - "width: 10; height: 10\n" - "Drag.keys: [\"red\", \"blue\"]" - "}\n" - "Item {\n" - "objectName: \"dragItem2\"\n" - "x: 50; y: 50\n" - "width: 10; height: 10\n" - "Drag.keys: [\"red\", \"blue\"]" - "}\n" - "}", QUrl()); - - QScopedPointer object(component.create()); - QQuickItem *dropArea1 = qobject_cast(object.data()); - QVERIFY(dropArea1); - dropArea1->setParentItem(canvas.rootItem()); - - QQuickItem *dropArea2 = dropArea1->findChild("dropArea2"); - QVERIFY(dropArea2); - - QQuickItem *dragItem1 = dropArea1->findChild("dragItem1"); - QVERIFY(dragItem1); - - QQuickItem *dragItem2 = dropArea1->findChild("dragItem2"); - QVERIFY(dragItem2); - - QMimeData data; - data.setData("text/x-red", "red"); - data.setData("text/x-blue", "blue"); - - QQuickCanvas alternateCanvas; - - // Mixed internal drags. - evaluate(dropArea1, "{ enterEvents = 0; exitEvents = 0 }"); - evaluate(dropArea2, "{ enterEvents = 0; exitEvents = 0 }"); - evaluate(dragItem1, "Drag.active = true"); - QCOMPARE(evaluate(dropArea1, "containsDrag"), true); - QCOMPARE(evaluate(dropArea1, "enterEvents"), 1); - QCOMPARE(evaluate(dropArea1, "exitEvents"), 0); - QCOMPARE(evaluate(dropArea2, "containsDrag"), true); - QCOMPARE(evaluate(dropArea2, "enterEvents"), 1); - QCOMPARE(evaluate(dropArea2, "exitEvents"), 0); - - evaluate(dropArea1, "{ enterEvents = 0; exitEvents = 0 }"); - evaluate(dropArea2, "{ enterEvents = 0; exitEvents = 0 }"); - evaluate(dragItem2, "Drag.active = true"); - QCOMPARE(evaluate(dropArea1, "containsDrag"), true); - QCOMPARE(evaluate(dropArea1, "enterEvents"), 0); - QCOMPARE(evaluate(dropArea1, "exitEvents"), 0); - QCOMPARE(evaluate(dropArea2, "containsDrag"), true); - QCOMPARE(evaluate(dropArea2, "enterEvents"), 0); - QCOMPARE(evaluate(dropArea2, "exitEvents"), 0); - - evaluate(dragItem2, "Drag.active = false"); - QCOMPARE(evaluate(dropArea1, "containsDrag"), true); - QCOMPARE(evaluate(dropArea1, "enterEvents"), 0); - QCOMPARE(evaluate(dropArea1, "exitEvents"), 0); - QCOMPARE(evaluate(dropArea2, "containsDrag"), true); - QCOMPARE(evaluate(dropArea2, "enterEvents"), 0); - QCOMPARE(evaluate(dropArea2, "exitEvents"), 0); - - evaluate(dragItem2, "Drag.active = true"); - QCOMPARE(evaluate(dropArea1, "containsDrag"), true); - QCOMPARE(evaluate(dropArea1, "enterEvents"), 0); - QCOMPARE(evaluate(dropArea1, "exitEvents"), 0); - QCOMPARE(evaluate(dropArea2, "containsDrag"), true); - QCOMPARE(evaluate(dropArea2, "enterEvents"), 0); - QCOMPARE(evaluate(dropArea2, "exitEvents"), 0); - - evaluate(dragItem1, "Drag.active = false"); - QCOMPARE(evaluate(dropArea1, "containsDrag"), false); - QCOMPARE(evaluate(dropArea1, "enterEvents"), 0); - QCOMPARE(evaluate(dropArea1, "exitEvents"), 1); - QCOMPARE(evaluate(dropArea2, "containsDrag"), false); - QCOMPARE(evaluate(dropArea2, "enterEvents"), 0); - QCOMPARE(evaluate(dropArea2, "exitEvents"), 1); - - evaluate(dropArea1, "{ enterEvents = 0; exitEvents = 0 }"); - evaluate(dropArea2, "{ enterEvents = 0; exitEvents = 0 }"); - evaluate(dragItem2, "Drag.active = false"); - QCOMPARE(evaluate(dropArea1, "containsDrag"), false); - QCOMPARE(evaluate(dropArea1, "enterEvents"), 0); - QCOMPARE(evaluate(dropArea1, "exitEvents"), 0); - QCOMPARE(evaluate(dropArea2, "containsDrag"), false); - QCOMPARE(evaluate(dropArea2, "enterEvents"), 0); - QCOMPARE(evaluate(dropArea2, "exitEvents"), 0); - - // internal then external. - evaluate(dropArea1, "{ enterEvents = 0; exitEvents = 0 }"); - evaluate(dropArea2, "{ enterEvents = 0; exitEvents = 0 }"); - evaluate(dragItem1, "Drag.active = true"); - QCOMPARE(evaluate(dropArea1, "containsDrag"), true); - QCOMPARE(evaluate(dropArea1, "enterEvents"), 1); - QCOMPARE(evaluate(dropArea1, "exitEvents"), 0); - QCOMPARE(evaluate(dropArea2, "containsDrag"), true); - QCOMPARE(evaluate(dropArea2, "enterEvents"), 1); - QCOMPARE(evaluate(dropArea2, "exitEvents"), 0); - - evaluate(dropArea1, "{ enterEvents = 0; exitEvents = 0 }"); - evaluate(dropArea2, "{ enterEvents = 0; exitEvents = 0 }"); - QWindowSystemInterface::handleDrag(&canvas, &data, QPoint(50, 50)); - QCOMPARE(evaluate(dropArea1, "containsDrag"), true); - QCOMPARE(evaluate(dropArea1, "enterEvents"), 0); - QCOMPARE(evaluate(dropArea1, "exitEvents"), 0); - QCOMPARE(evaluate(dropArea2, "containsDrag"), true); - QCOMPARE(evaluate(dropArea2, "enterEvents"), 0); - QCOMPARE(evaluate(dropArea2, "exitEvents"), 0); - - QWindowSystemInterface::handleDrag(&alternateCanvas, &data, QPoint(50, 50)); - QCOMPARE(evaluate(dropArea1, "containsDrag"), true); - QCOMPARE(evaluate(dropArea1, "enterEvents"), 0); - QCOMPARE(evaluate(dropArea1, "exitEvents"), 0); - QCOMPARE(evaluate(dropArea2, "containsDrag"), true); - QCOMPARE(evaluate(dropArea2, "enterEvents"), 0); - QCOMPARE(evaluate(dropArea2, "exitEvents"), 0); - - QWindowSystemInterface::handleDrag(&canvas, &data, QPoint(50, 50)); - QCOMPARE(evaluate(dropArea1, "containsDrag"), true); - QCOMPARE(evaluate(dropArea1, "enterEvents"), 0); - QCOMPARE(evaluate(dropArea1, "exitEvents"), 0); - QCOMPARE(evaluate(dropArea2, "containsDrag"), true); - QCOMPARE(evaluate(dropArea2, "enterEvents"), 0); - QCOMPARE(evaluate(dropArea2, "exitEvents"), 0); - - evaluate(dragItem1, "Drag.active = false"); - QCOMPARE(evaluate(dropArea1, "containsDrag"), false); - QCOMPARE(evaluate(dropArea1, "enterEvents"), 0); - QCOMPARE(evaluate(dropArea1, "exitEvents"), 1); - QCOMPARE(evaluate(dropArea2, "containsDrag"), false); - QCOMPARE(evaluate(dropArea2, "enterEvents"), 0); - QCOMPARE(evaluate(dropArea2, "exitEvents"), 1); - - evaluate(dropArea1, "{ enterEvents = 0; exitEvents = 0 }"); - evaluate(dropArea2, "{ enterEvents = 0; exitEvents = 0 }"); - QWindowSystemInterface::handleDrag(&alternateCanvas, &data, QPoint(50, 50)); - QCOMPARE(evaluate(dropArea1, "containsDrag"), false); - QCOMPARE(evaluate(dropArea1, "enterEvents"), 0); - QCOMPARE(evaluate(dropArea1, "exitEvents"), 0); - QCOMPARE(evaluate(dropArea2, "containsDrag"), false); - QCOMPARE(evaluate(dropArea2, "enterEvents"), 0); - QCOMPARE(evaluate(dropArea2, "exitEvents"), 0); - - // external then internal. - evaluate(dropArea1, "{ enterEvents = 0; exitEvents = 0 }"); - evaluate(dropArea2, "{ enterEvents = 0; exitEvents = 0 }"); - QWindowSystemInterface::handleDrag(&canvas, &data, QPoint(50, 50)); - QCOMPARE(evaluate(dropArea1, "containsDrag"), true); - QCOMPARE(evaluate(dropArea1, "enterEvents"), 1); - QCOMPARE(evaluate(dropArea1, "exitEvents"), 0); - QCOMPARE(evaluate(dropArea2, "containsDrag"), true); - QCOMPARE(evaluate(dropArea2, "enterEvents"), 1); - QCOMPARE(evaluate(dropArea2, "exitEvents"), 0); - - evaluate(dropArea1, "{ enterEvents = 0; exitEvents = 0 }"); - evaluate(dropArea2, "{ enterEvents = 0; exitEvents = 0 }"); - evaluate(dragItem2, "Drag.active = true"); - QCOMPARE(evaluate(dropArea1, "containsDrag"), true); - QCOMPARE(evaluate(dropArea1, "enterEvents"), 0); - QCOMPARE(evaluate(dropArea1, "exitEvents"), 0); - QCOMPARE(evaluate(dropArea2, "containsDrag"), true); - QCOMPARE(evaluate(dropArea2, "enterEvents"), 0); - QCOMPARE(evaluate(dropArea2, "exitEvents"), 0); - - evaluate(dragItem2, "Drag.active = false"); - QCOMPARE(evaluate(dropArea1, "containsDrag"), true); - QCOMPARE(evaluate(dropArea1, "enterEvents"), 0); - QCOMPARE(evaluate(dropArea1, "exitEvents"), 0); - QCOMPARE(evaluate(dropArea2, "containsDrag"), true); - QCOMPARE(evaluate(dropArea2, "enterEvents"), 0); - QCOMPARE(evaluate(dropArea2, "exitEvents"), 0); - - evaluate(dragItem2, "Drag.active = true"); - QCOMPARE(evaluate(dropArea1, "containsDrag"), true); - QCOMPARE(evaluate(dropArea1, "enterEvents"), 0); - QCOMPARE(evaluate(dropArea1, "exitEvents"), 0); - QCOMPARE(evaluate(dropArea2, "containsDrag"), true); - QCOMPARE(evaluate(dropArea2, "enterEvents"), 0); - QCOMPARE(evaluate(dropArea2, "exitEvents"), 0); - - QWindowSystemInterface::handleDrag(&alternateCanvas, &data, QPoint(50, 50)); - QCOMPARE(evaluate(dropArea1, "containsDrag"), false); - QCOMPARE(evaluate(dropArea1, "enterEvents"), 0); - QCOMPARE(evaluate(dropArea1, "exitEvents"), 1); - QCOMPARE(evaluate(dropArea2, "containsDrag"), false); - QCOMPARE(evaluate(dropArea2, "enterEvents"), 0); - QCOMPARE(evaluate(dropArea2, "exitEvents"), 1); - - evaluate(dropArea1, "{ enterEvents = 0; exitEvents = 0 }"); - evaluate(dropArea2, "{ enterEvents = 0; exitEvents = 0 }"); - evaluate(dragItem2, "Drag.active = false"); - QCOMPARE(evaluate(dropArea1, "containsDrag"), false); - QCOMPARE(evaluate(dropArea1, "enterEvents"), 0); - QCOMPARE(evaluate(dropArea1, "exitEvents"), 0); - QCOMPARE(evaluate(dropArea2, "containsDrag"), false); - QCOMPARE(evaluate(dropArea2, "enterEvents"), 0); - QCOMPARE(evaluate(dropArea2, "exitEvents"), 0); - - // Different acceptance - evaluate(dragItem1, "Drag.keys = \"red\""); - evaluate(dragItem2, "Drag.keys = \"blue\""); - data.removeFormat("text/x-red"); - - evaluate(dropArea1, "{ enterEvents = 0; exitEvents = 0 }"); - evaluate(dropArea2, "{ enterEvents = 0; exitEvents = 0 }"); - evaluate(dragItem1, "Drag.active = true"); - QCOMPARE(evaluate(dropArea1, "containsDrag"), true); - QCOMPARE(evaluate(dropArea1, "enterEvents"), 1); - QCOMPARE(evaluate(dropArea1, "exitEvents"), 0); - QCOMPARE(evaluate(dropArea2, "containsDrag"), false); - QCOMPARE(evaluate(dropArea2, "enterEvents"), 0); - QCOMPARE(evaluate(dropArea2, "exitEvents"), 0); - - evaluate(dropArea1, "{ enterEvents = 0; exitEvents = 0 }"); - evaluate(dropArea2, "{ enterEvents = 0; exitEvents = 0 }"); - evaluate(dragItem2, "Drag.active = true"); - QCOMPARE(evaluate(dropArea1, "containsDrag"), true); - QCOMPARE(evaluate(dropArea1, "enterEvents"), 0); - QCOMPARE(evaluate(dropArea1, "exitEvents"), 0); - QCOMPARE(evaluate(dropArea2, "containsDrag"), true); - QCOMPARE(evaluate(dropArea2, "enterEvents"), 1); - QCOMPARE(evaluate(dropArea2, "exitEvents"), 0); - - evaluate(dropArea1, "{ enterEvents = 0; exitEvents = 0 }"); - evaluate(dropArea2, "{ enterEvents = 0; exitEvents = 0 }"); - evaluate(dragItem2, "Drag.active = false"); - QCOMPARE(evaluate(dropArea1, "containsDrag"), true); - QCOMPARE(evaluate(dropArea1, "enterEvents"), 0); - QCOMPARE(evaluate(dropArea1, "exitEvents"), 0); - QCOMPARE(evaluate(dropArea2, "containsDrag"), false); - QCOMPARE(evaluate(dropArea2, "enterEvents"), 0); - QCOMPARE(evaluate(dropArea2, "exitEvents"), 1); - - evaluate(dropArea1, "{ enterEvents = 0; exitEvents = 0 }"); - evaluate(dropArea2, "{ enterEvents = 0; exitEvents = 0 }"); - evaluate(dragItem2, "Drag.active = true"); - QCOMPARE(evaluate(dropArea1, "containsDrag"), true); - QCOMPARE(evaluate(dropArea1, "enterEvents"), 0); - QCOMPARE(evaluate(dropArea1, "exitEvents"), 0); - QCOMPARE(evaluate(dropArea2, "containsDrag"), true); - QCOMPARE(evaluate(dropArea2, "enterEvents"), 1); - QCOMPARE(evaluate(dropArea2, "exitEvents"), 0); - - evaluate(dropArea1, "{ enterEvents = 0; exitEvents = 0 }"); - evaluate(dropArea2, "{ enterEvents = 0; exitEvents = 0 }"); - evaluate(dragItem1, "Drag.active = false"); - QCOMPARE(evaluate(dropArea1, "containsDrag"), false); - QCOMPARE(evaluate(dropArea1, "enterEvents"), 0); - QCOMPARE(evaluate(dropArea1, "exitEvents"), 1); - QCOMPARE(evaluate(dropArea2, "containsDrag"), true); - QCOMPARE(evaluate(dropArea2, "enterEvents"), 0); - QCOMPARE(evaluate(dropArea2, "exitEvents"), 0); - - evaluate(dropArea1, "{ enterEvents = 0; exitEvents = 0 }"); - evaluate(dropArea2, "{ enterEvents = 0; exitEvents = 0 }"); - evaluate(dragItem2, "Drag.active = false"); - QCOMPARE(evaluate(dropArea1, "containsDrag"), false); - QCOMPARE(evaluate(dropArea1, "enterEvents"), 0); - QCOMPARE(evaluate(dropArea1, "exitEvents"), 0); - QCOMPARE(evaluate(dropArea2, "containsDrag"), false); - QCOMPARE(evaluate(dropArea2, "enterEvents"), 0); - QCOMPARE(evaluate(dropArea2, "exitEvents"), 1); - - // internal then external - evaluate(dropArea1, "{ enterEvents = 0; exitEvents = 0 }"); - evaluate(dropArea2, "{ enterEvents = 0; exitEvents = 0 }"); - evaluate(dragItem1, "Drag.active = true"); - QCOMPARE(evaluate(dropArea1, "containsDrag"), true); - QCOMPARE(evaluate(dropArea1, "enterEvents"), 1); - QCOMPARE(evaluate(dropArea1, "exitEvents"), 0); - QCOMPARE(evaluate(dropArea2, "containsDrag"), false); - QCOMPARE(evaluate(dropArea2, "enterEvents"), 0); - QCOMPARE(evaluate(dropArea2, "exitEvents"), 0); - - evaluate(dropArea1, "{ enterEvents = 0; exitEvents = 0 }"); - evaluate(dropArea2, "{ enterEvents = 0; exitEvents = 0 }"); - QWindowSystemInterface::handleDrag(&canvas, &data, QPoint(50, 50)); - QCOMPARE(evaluate(dropArea1, "containsDrag"), true); - QCOMPARE(evaluate(dropArea1, "enterEvents"), 0); - QCOMPARE(evaluate(dropArea1, "exitEvents"), 0); - QCOMPARE(evaluate(dropArea2, "containsDrag"), true); - QCOMPARE(evaluate(dropArea2, "enterEvents"), 1); - QCOMPARE(evaluate(dropArea2, "exitEvents"), 0); - - evaluate(dropArea1, "{ enterEvents = 0; exitEvents = 0 }"); - evaluate(dropArea2, "{ enterEvents = 0; exitEvents = 0 }"); - QWindowSystemInterface::handleDrag(&alternateCanvas, &data, QPoint(50, 50)); - QCOMPARE(evaluate(dropArea1, "containsDrag"), true); - QCOMPARE(evaluate(dropArea1, "enterEvents"), 0); - QCOMPARE(evaluate(dropArea1, "exitEvents"), 0); - QCOMPARE(evaluate(dropArea2, "containsDrag"), false); - QCOMPARE(evaluate(dropArea2, "enterEvents"), 0); - QCOMPARE(evaluate(dropArea2, "exitEvents"), 1); - - evaluate(dropArea1, "{ enterEvents = 0; exitEvents = 0 }"); - evaluate(dropArea2, "{ enterEvents = 0; exitEvents = 0 }"); - QWindowSystemInterface::handleDrag(&canvas, &data, QPoint(50, 50)); - QCOMPARE(evaluate(dropArea1, "containsDrag"), true); - QCOMPARE(evaluate(dropArea1, "enterEvents"), 0); - QCOMPARE(evaluate(dropArea1, "exitEvents"), 0); - QCOMPARE(evaluate(dropArea2, "containsDrag"), true); - QCOMPARE(evaluate(dropArea2, "enterEvents"), 1); - QCOMPARE(evaluate(dropArea2, "exitEvents"), 0); - - evaluate(dropArea1, "{ enterEvents = 0; exitEvents = 0 }"); - evaluate(dropArea2, "{ enterEvents = 0; exitEvents = 0 }"); - evaluate(dragItem1, "Drag.active = false"); - QCOMPARE(evaluate(dropArea1, "containsDrag"), false); - QCOMPARE(evaluate(dropArea1, "enterEvents"), 0); - QCOMPARE(evaluate(dropArea1, "exitEvents"), 1); - QCOMPARE(evaluate(dropArea2, "containsDrag"), true); - QCOMPARE(evaluate(dropArea2, "enterEvents"), 0); - QCOMPARE(evaluate(dropArea2, "exitEvents"), 0); - - evaluate(dropArea1, "{ enterEvents = 0; exitEvents = 0 }"); - evaluate(dropArea2, "{ enterEvents = 0; exitEvents = 0 }"); - QWindowSystemInterface::handleDrag(&alternateCanvas, &data, QPoint(50, 50)); - QCOMPARE(evaluate(dropArea1, "containsDrag"), false); - QCOMPARE(evaluate(dropArea1, "enterEvents"), 0); - QCOMPARE(evaluate(dropArea1, "exitEvents"), 0); - QCOMPARE(evaluate(dropArea2, "containsDrag"), false); - QCOMPARE(evaluate(dropArea2, "enterEvents"), 0); - QCOMPARE(evaluate(dropArea2, "exitEvents"), 1); - - QWindowSystemInterface::handleDrop(&alternateCanvas, &data, QPoint(50, 50)); -} - -QTEST_MAIN(tst_QQuickDropArea) - -#include "tst_qquickdroparea.moc" diff --git a/tests/auto/qtquick2/qquickflickable/data/disabled.qml b/tests/auto/qtquick2/qquickflickable/data/disabled.qml deleted file mode 100644 index 9b679827c7..0000000000 --- a/tests/auto/qtquick2/qquickflickable/data/disabled.qml +++ /dev/null @@ -1,30 +0,0 @@ -import QtQuick 2.0 - -Rectangle { - id: root - width: 100; height: 100 - property bool clicked: false - - Flickable { - objectName: "flickable" - width: 100; height: 100 - contentWidth: column.width; contentHeight: column.height - enabled: false - - Column { - id: column - Repeater { - model: 4 - Rectangle { - width: 200; height: 300; color: "blue" - MouseArea { anchors.fill: parent; onClicked: { } } - } - } - } - } - - MouseArea { - width: 100; height: 30 - onClicked: root.clicked = true - } -} diff --git a/tests/auto/qtquick2/qquickflickable/data/flickable01.qml b/tests/auto/qtquick2/qquickflickable/data/flickable01.qml deleted file mode 100644 index cbec44bb4f..0000000000 --- a/tests/auto/qtquick2/qquickflickable/data/flickable01.qml +++ /dev/null @@ -1,4 +0,0 @@ -import QtQuick 2.0 - -Flickable { -} diff --git a/tests/auto/qtquick2/qquickflickable/data/flickable02.qml b/tests/auto/qtquick2/qquickflickable/data/flickable02.qml deleted file mode 100644 index 80caa32da5..0000000000 --- a/tests/auto/qtquick2/qquickflickable/data/flickable02.qml +++ /dev/null @@ -1,14 +0,0 @@ -import QtQuick 2.0 - -Flickable { - width: 100; height: 100 - contentWidth: row.width; contentHeight: row.height - - Row { - id: row - Repeater { - model: 4 - Rectangle { width: 200; height: 300; color: "blue" } - } - } -} diff --git a/tests/auto/qtquick2/qquickflickable/data/flickable03.qml b/tests/auto/qtquick2/qquickflickable/data/flickable03.qml deleted file mode 100644 index 719c682ee6..0000000000 --- a/tests/auto/qtquick2/qquickflickable/data/flickable03.qml +++ /dev/null @@ -1,14 +0,0 @@ -import QtQuick 2.0 - -Flickable { - width: 100; height: 400 - contentWidth: column.width; contentHeight: column.height - - Column { - id: column - Repeater { - model: 20 - Rectangle { width: 200; height: 300; color: "blue" } - } - } -} diff --git a/tests/auto/qtquick2/qquickflickable/data/flickable04.qml b/tests/auto/qtquick2/qquickflickable/data/flickable04.qml deleted file mode 100644 index b2f30b84ec..0000000000 --- a/tests/auto/qtquick2/qquickflickable/data/flickable04.qml +++ /dev/null @@ -1,22 +0,0 @@ -import QtQuick 2.0 - -Flickable { - property bool ok: false - function check() { - if (column.parent == contentItem) - ok = true; - } - - width: 100; height: 100 - contentWidth: column.width; contentHeight: column.height - pressDelay: 200; boundsBehavior: Flickable.StopAtBounds; interactive: false - maximumFlickVelocity: 2000 - - Column { - id: column - Repeater { - model: 4 - Rectangle { width: 200; height: 300; color: "blue" } - } - } -} diff --git a/tests/auto/qtquick2/qquickflickable/data/flickableqgraphicswidget.qml b/tests/auto/qtquick2/qquickflickable/data/flickableqgraphicswidget.qml deleted file mode 100644 index bb8f1eefc6..0000000000 --- a/tests/auto/qtquick2/qquickflickable/data/flickableqgraphicswidget.qml +++ /dev/null @@ -1,7 +0,0 @@ -import QtQuick 2.0 - -Flickable { - width: 100; height: 100 - - QGraphicsWidget { objectName: "widget1"; width: 200; height: 300 } -} diff --git a/tests/auto/qtquick2/qquickflickable/data/margins.qml b/tests/auto/qtquick2/qquickflickable/data/margins.qml deleted file mode 100644 index 4866bd8301..0000000000 --- a/tests/auto/qtquick2/qquickflickable/data/margins.qml +++ /dev/null @@ -1,19 +0,0 @@ -import QtQuick 2.0 - -Flickable { - width: 200; height: 200 - contentWidth: row.width; contentHeight: row.height - - topMargin: 20 - bottomMargin: 30 - leftMargin: 40 - rightMargin: 50 - - Row { - id: row - Repeater { - model: 4 - Rectangle { width: 400; height: 600; color: "blue" } - } - } -} diff --git a/tests/auto/qtquick2/qquickflickable/data/nestedPressDelay.qml b/tests/auto/qtquick2/qquickflickable/data/nestedPressDelay.qml deleted file mode 100644 index 60dadcc73c..0000000000 --- a/tests/auto/qtquick2/qquickflickable/data/nestedPressDelay.qml +++ /dev/null @@ -1,33 +0,0 @@ -import QtQuick 2.0 - -Flickable { - property bool pressed: ma.pressed - width: 240 - height: 320 - contentWidth: 480 - contentHeight: 320 - flickableDirection: Flickable.HorizontalFlick - pressDelay: 50 - Flickable { - objectName: "innerFlickable" - flickableDirection: Flickable.VerticalFlick - width: 480 - height: 320 - contentWidth: 480 - contentHeight: 400 - pressDelay: 10000 - Rectangle { - y: 100 - anchors.horizontalCenter: parent.horizontalCenter - width: 240 - height: 100 - color: ma.pressed ? 'blue' : 'green' - MouseArea { - id: ma - objectName: "mouseArea" - anchors.fill: parent - } - } - } -} - diff --git a/tests/auto/qtquick2/qquickflickable/data/resize.qml b/tests/auto/qtquick2/qquickflickable/data/resize.qml deleted file mode 100644 index 1a9ef54107..0000000000 --- a/tests/auto/qtquick2/qquickflickable/data/resize.qml +++ /dev/null @@ -1,27 +0,0 @@ -import QtQuick 2.0 - -Rectangle { - function resizeContent() { - flick.resizeContent(600, 600, Qt.point(100, 100)) - } - function returnToBounds() { - flick.returnToBounds() - } - width: 400 - height: 360 - color: "gray" - - Flickable { - id: flick - objectName: "flick" - anchors.fill: parent - contentWidth: 300 - contentHeight: 300 - - Rectangle { - width: flick.contentWidth - height: flick.contentHeight - color: "red" - } - } -} diff --git a/tests/auto/qtquick2/qquickflickable/data/wheel.qml b/tests/auto/qtquick2/qquickflickable/data/wheel.qml deleted file mode 100644 index 2928bbcd72..0000000000 --- a/tests/auto/qtquick2/qquickflickable/data/wheel.qml +++ /dev/null @@ -1,25 +0,0 @@ -import QtQuick 2.0 - -Rectangle { - width: 400 - height: 400 - color: "gray" - - Flickable { - id: flick - objectName: "flick" - anchors.fill: parent - contentWidth: 800 - contentHeight: 800 - - Rectangle { - width: flick.contentWidth - height: flick.contentHeight - color: "red" - Rectangle { - width: 50; height: 50; color: "blue" - anchors.centerIn: parent - } - } - } -} diff --git a/tests/auto/qtquick2/qquickflickable/qquickflickable.pro b/tests/auto/qtquick2/qquickflickable/qquickflickable.pro deleted file mode 100644 index d1b8b6948f..0000000000 --- a/tests/auto/qtquick2/qquickflickable/qquickflickable.pro +++ /dev/null @@ -1,15 +0,0 @@ -CONFIG += testcase -TARGET = tst_qquickflickable -macx:CONFIG -= app_bundle - -SOURCES += tst_qquickflickable.cpp - -include (../../shared/util.pri) -include (../shared/util.pri) - -testDataFiles.files = data -testDataFiles.path = . -DEPLOYMENT += testDataFiles - -CONFIG += parallel_test -QT += core-private gui-private v8-private declarative-private quick-private testlib diff --git a/tests/auto/qtquick2/qquickflickable/tst_qquickflickable.cpp b/tests/auto/qtquick2/qquickflickable/tst_qquickflickable.cpp deleted file mode 100644 index d357877ed5..0000000000 --- a/tests/auto/qtquick2/qquickflickable/tst_qquickflickable.cpp +++ /dev/null @@ -1,663 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "../../shared/util.h" -#include "../shared/viewtestutil.h" -#include "../shared/visualtestutil.h" -#include - -using namespace QQuickViewTestUtil; -using namespace QQuickVisualTestUtil; - -class tst_qquickflickable : public QDeclarativeDataTest -{ - Q_OBJECT -public: - -private slots: - void create(); - void horizontalViewportSize(); - void verticalViewportSize(); - void properties(); - void boundsBehavior(); - void maximumFlickVelocity(); - void flickDeceleration(); - void pressDelay(); - void nestedPressDelay(); - void flickableDirection(); - void resizeContent(); - void returnToBounds(); - void wheel(); - void movingAndDragging(); - void disabled(); - void flickVelocity(); - void margins(); - -private: - QDeclarativeEngine engine; -}; - -void tst_qquickflickable::create() -{ - QDeclarativeEngine engine; - QDeclarativeComponent c(&engine, testFileUrl("flickable01.qml")); - QQuickFlickable *obj = qobject_cast(c.create()); - - QVERIFY(obj != 0); - QCOMPARE(obj->isAtXBeginning(), true); - QCOMPARE(obj->isAtXEnd(), false); - QCOMPARE(obj->isAtYBeginning(), true); - QCOMPARE(obj->isAtYEnd(), false); - QCOMPARE(obj->contentX(), 0.); - QCOMPARE(obj->contentY(), 0.); - - QCOMPARE(obj->horizontalVelocity(), 0.); - QCOMPARE(obj->verticalVelocity(), 0.); - - QCOMPARE(obj->isInteractive(), true); - QCOMPARE(obj->boundsBehavior(), QQuickFlickable::DragAndOvershootBounds); - QCOMPARE(obj->pressDelay(), 0); - QCOMPARE(obj->maximumFlickVelocity(), 2500.); - - delete obj; -} - -void tst_qquickflickable::horizontalViewportSize() -{ - QDeclarativeEngine engine; - QDeclarativeComponent c(&engine, testFileUrl("flickable02.qml")); - QQuickFlickable *obj = qobject_cast(c.create()); - - QVERIFY(obj != 0); - QCOMPARE(obj->contentWidth(), 800.); - QCOMPARE(obj->contentHeight(), 300.); - QCOMPARE(obj->isAtXBeginning(), true); - QCOMPARE(obj->isAtXEnd(), false); - QCOMPARE(obj->isAtYBeginning(), true); - QCOMPARE(obj->isAtYEnd(), false); - - delete obj; -} - -void tst_qquickflickable::verticalViewportSize() -{ - QDeclarativeEngine engine; - QDeclarativeComponent c(&engine, testFileUrl("flickable03.qml")); - QQuickFlickable *obj = qobject_cast(c.create()); - - QVERIFY(obj != 0); - QCOMPARE(obj->contentWidth(), 200.); - QCOMPARE(obj->contentHeight(), 6000.); - QCOMPARE(obj->isAtXBeginning(), true); - QCOMPARE(obj->isAtXEnd(), false); - QCOMPARE(obj->isAtYBeginning(), true); - QCOMPARE(obj->isAtYEnd(), false); - - delete obj; -} - -void tst_qquickflickable::properties() -{ - QDeclarativeEngine engine; - QDeclarativeComponent c(&engine, testFileUrl("flickable04.qml")); - QQuickFlickable *obj = qobject_cast(c.create()); - - QVERIFY(obj != 0); - QCOMPARE(obj->isInteractive(), false); - QCOMPARE(obj->boundsBehavior(), QQuickFlickable::StopAtBounds); - QCOMPARE(obj->pressDelay(), 200); - QCOMPARE(obj->maximumFlickVelocity(), 2000.); - - QVERIFY(obj->property("ok").toBool() == false); - QMetaObject::invokeMethod(obj, "check"); - QVERIFY(obj->property("ok").toBool() == true); - - delete obj; -} - -void tst_qquickflickable::boundsBehavior() -{ - QDeclarativeComponent component(&engine); - component.setData("import QtQuick 2.0; Flickable { boundsBehavior: Flickable.StopAtBounds }", QUrl::fromLocalFile("")); - QQuickFlickable *flickable = qobject_cast(component.create()); - QSignalSpy spy(flickable, SIGNAL(boundsBehaviorChanged())); - - QVERIFY(flickable); - QVERIFY(flickable->boundsBehavior() == QQuickFlickable::StopAtBounds); - - flickable->setBoundsBehavior(QQuickFlickable::DragAndOvershootBounds); - QVERIFY(flickable->boundsBehavior() == QQuickFlickable::DragAndOvershootBounds); - QCOMPARE(spy.count(),1); - flickable->setBoundsBehavior(QQuickFlickable::DragAndOvershootBounds); - QCOMPARE(spy.count(),1); - - flickable->setBoundsBehavior(QQuickFlickable::DragOverBounds); - QVERIFY(flickable->boundsBehavior() == QQuickFlickable::DragOverBounds); - QCOMPARE(spy.count(),2); - flickable->setBoundsBehavior(QQuickFlickable::DragOverBounds); - QCOMPARE(spy.count(),2); - - flickable->setBoundsBehavior(QQuickFlickable::StopAtBounds); - QVERIFY(flickable->boundsBehavior() == QQuickFlickable::StopAtBounds); - QCOMPARE(spy.count(),3); - flickable->setBoundsBehavior(QQuickFlickable::StopAtBounds); - QCOMPARE(spy.count(),3); -} - -void tst_qquickflickable::maximumFlickVelocity() -{ - QDeclarativeComponent component(&engine); - component.setData("import QtQuick 2.0; Flickable { maximumFlickVelocity: 1.0; }", QUrl::fromLocalFile("")); - QQuickFlickable *flickable = qobject_cast(component.create()); - QSignalSpy spy(flickable, SIGNAL(maximumFlickVelocityChanged())); - - QVERIFY(flickable); - QCOMPARE(flickable->maximumFlickVelocity(), 1.0); - - flickable->setMaximumFlickVelocity(2.0); - QCOMPARE(flickable->maximumFlickVelocity(), 2.0); - QCOMPARE(spy.count(),1); - flickable->setMaximumFlickVelocity(2.0); - QCOMPARE(spy.count(),1); -} - -void tst_qquickflickable::flickDeceleration() -{ - QDeclarativeComponent component(&engine); - component.setData("import QtQuick 2.0; Flickable { flickDeceleration: 1.0; }", QUrl::fromLocalFile("")); - QQuickFlickable *flickable = qobject_cast(component.create()); - QSignalSpy spy(flickable, SIGNAL(flickDecelerationChanged())); - - QVERIFY(flickable); - QCOMPARE(flickable->flickDeceleration(), 1.0); - - flickable->setFlickDeceleration(2.0); - QCOMPARE(flickable->flickDeceleration(), 2.0); - QCOMPARE(spy.count(),1); - flickable->setFlickDeceleration(2.0); - QCOMPARE(spy.count(),1); -} - -void tst_qquickflickable::pressDelay() -{ - QDeclarativeComponent component(&engine); - component.setData("import QtQuick 2.0; Flickable { pressDelay: 100; }", QUrl::fromLocalFile("")); - QQuickFlickable *flickable = qobject_cast(component.create()); - QSignalSpy spy(flickable, SIGNAL(pressDelayChanged())); - - QVERIFY(flickable); - QCOMPARE(flickable->pressDelay(), 100); - - flickable->setPressDelay(200); - QCOMPARE(flickable->pressDelay(), 200); - QCOMPARE(spy.count(),1); - flickable->setPressDelay(200); - QCOMPARE(spy.count(),1); -} - -// QTBUG-17361 -void tst_qquickflickable::nestedPressDelay() -{ - QQuickView *canvas = new QQuickView; - canvas->setSource(testFileUrl("nestedPressDelay.qml")); - canvas->show(); - canvas->requestActivateWindow(); - QVERIFY(canvas->rootObject() != 0); - - QQuickFlickable *outer = qobject_cast(canvas->rootObject()); - QVERIFY(outer != 0); - - QQuickFlickable *inner = canvas->rootObject()->findChild("innerFlickable"); - QVERIFY(inner != 0); - - QTest::mousePress(canvas, Qt::LeftButton, 0, QPoint(150, 150)); - // the MouseArea is not pressed immediately - QVERIFY(outer->property("pressed").toBool() == false); - - // The outer pressDelay will prevail (50ms, vs. 10sec) - // QTRY_VERIFY() has 5sec timeout, so will timeout well within 10sec. - QTRY_VERIFY(outer->property("pressed").toBool() == true); - - QTest::mouseRelease(canvas, Qt::LeftButton, 0, QPoint(150, 150)); - - delete canvas; -} - -void tst_qquickflickable::flickableDirection() -{ - QDeclarativeComponent component(&engine); - component.setData("import QtQuick 2.0; Flickable { flickableDirection: Flickable.VerticalFlick; }", QUrl::fromLocalFile("")); - QQuickFlickable *flickable = qobject_cast(component.create()); - QSignalSpy spy(flickable, SIGNAL(flickableDirectionChanged())); - - QVERIFY(flickable); - QCOMPARE(flickable->flickableDirection(), QQuickFlickable::VerticalFlick); - - flickable->setFlickableDirection(QQuickFlickable::HorizontalAndVerticalFlick); - QCOMPARE(flickable->flickableDirection(), QQuickFlickable::HorizontalAndVerticalFlick); - QCOMPARE(spy.count(),1); - - flickable->setFlickableDirection(QQuickFlickable::AutoFlickDirection); - QCOMPARE(flickable->flickableDirection(), QQuickFlickable::AutoFlickDirection); - QCOMPARE(spy.count(),2); - - flickable->setFlickableDirection(QQuickFlickable::HorizontalFlick); - QCOMPARE(flickable->flickableDirection(), QQuickFlickable::HorizontalFlick); - QCOMPARE(spy.count(),3); - - flickable->setFlickableDirection(QQuickFlickable::HorizontalFlick); - QCOMPARE(flickable->flickableDirection(), QQuickFlickable::HorizontalFlick); - QCOMPARE(spy.count(),3); -} - -// QtQuick 1.1 -void tst_qquickflickable::resizeContent() -{ - QDeclarativeEngine engine; - QDeclarativeComponent c(&engine, testFileUrl("resize.qml")); - QQuickItem *root = qobject_cast(c.create()); - QQuickFlickable *obj = findItem(root, "flick"); - - QVERIFY(obj != 0); - QCOMPARE(obj->contentX(), 0.); - QCOMPARE(obj->contentY(), 0.); - QCOMPARE(obj->contentWidth(), 300.); - QCOMPARE(obj->contentHeight(), 300.); - - QMetaObject::invokeMethod(root, "resizeContent"); - - QCOMPARE(obj->contentX(), 100.); - QCOMPARE(obj->contentY(), 100.); - QCOMPARE(obj->contentWidth(), 600.); - QCOMPARE(obj->contentHeight(), 600.); - - delete root; -} - -// QtQuick 1.1 -void tst_qquickflickable::returnToBounds() -{ - QDeclarativeEngine engine; - QDeclarativeComponent c(&engine, testFileUrl("resize.qml")); - QQuickItem *root = qobject_cast(c.create()); - QQuickFlickable *obj = findItem(root, "flick"); - - QVERIFY(obj != 0); - QCOMPARE(obj->contentX(), 0.); - QCOMPARE(obj->contentY(), 0.); - QCOMPARE(obj->contentWidth(), 300.); - QCOMPARE(obj->contentHeight(), 300.); - - obj->setContentX(100); - obj->setContentY(400); - QTRY_COMPARE(obj->contentX(), 100.); - QTRY_COMPARE(obj->contentY(), 400.); - - QMetaObject::invokeMethod(root, "returnToBounds"); - - QTRY_COMPARE(obj->contentX(), 0.); - QTRY_COMPARE(obj->contentY(), 0.); - - delete root; -} - -void tst_qquickflickable::wheel() -{ - QQuickView *canvas = new QQuickView; - canvas->setSource(testFileUrl("wheel.qml")); - canvas->show(); - canvas->requestActivateWindow(); - QVERIFY(canvas->rootObject() != 0); - - QQuickFlickable *flick = canvas->rootObject()->findChild("flick"); - QVERIFY(flick != 0); - - { - QWheelEvent event(QPoint(200, 200), -120, Qt::NoButton, Qt::NoModifier, Qt::Vertical); - event.setAccepted(false); - QGuiApplication::sendEvent(canvas, &event); - } - - QTRY_VERIFY(flick->contentY() > 0); - QVERIFY(flick->contentX() == 0); - - flick->setContentY(0); - QVERIFY(flick->contentY() == 0); - - { - QWheelEvent event(QPoint(200, 200), -120, Qt::NoButton, Qt::NoModifier, Qt::Horizontal); - event.setAccepted(false); - QGuiApplication::sendEvent(canvas, &event); - } - - QTRY_VERIFY(flick->contentX() > 0); - QVERIFY(flick->contentY() == 0); - - delete canvas; -} - -void tst_qquickflickable::movingAndDragging() -{ - QQuickView *canvas = new QQuickView; - canvas->setSource(testFileUrl("flickable03.qml")); - canvas->show(); - canvas->requestActivateWindow(); - QTest::qWaitForWindowShown(canvas); - QVERIFY(canvas->rootObject() != 0); - - QQuickFlickable *flickable = qobject_cast(canvas->rootObject()); - QVERIFY(flickable != 0); - - QSignalSpy vDragSpy(flickable, SIGNAL(draggingVerticallyChanged())); - QSignalSpy hDragSpy(flickable, SIGNAL(draggingHorizontallyChanged())); - QSignalSpy dragSpy(flickable, SIGNAL(draggingChanged())); - QSignalSpy vMoveSpy(flickable, SIGNAL(movingVerticallyChanged())); - QSignalSpy hMoveSpy(flickable, SIGNAL(movingHorizontallyChanged())); - QSignalSpy moveSpy(flickable, SIGNAL(movingChanged())); - QSignalSpy dragStartSpy(flickable, SIGNAL(dragStarted())); - QSignalSpy dragEndSpy(flickable, SIGNAL(dragEnded())); - - //Vertical - QTest::mousePress(canvas, Qt::LeftButton, 0, QPoint(50, 90)); - - QTest::mouseMove(canvas, QPoint(50, 80)); - QTest::mouseMove(canvas, QPoint(50, 70)); - QTest::mouseMove(canvas, QPoint(50, 60)); - - QMouseEvent moveEvent(QEvent::MouseMove, QPoint(50, 80), Qt::LeftButton, Qt::LeftButton, 0); - - QVERIFY(!flickable->isDraggingHorizontally()); - QVERIFY(flickable->isDraggingVertically()); - QVERIFY(flickable->isDragging()); - QCOMPARE(vDragSpy.count(), 1); - QCOMPARE(dragSpy.count(), 1); - QCOMPARE(hDragSpy.count(), 0); - QCOMPARE(dragStartSpy.count(), 1); - QCOMPARE(dragEndSpy.count(), 0); - - QVERIFY(!flickable->isMovingHorizontally()); - QVERIFY(flickable->isMovingVertically()); - QVERIFY(flickable->isMoving()); - QCOMPARE(vMoveSpy.count(), 1); - QCOMPARE(moveSpy.count(), 1); - QCOMPARE(hMoveSpy.count(), 0); - - QTest::mouseRelease(canvas, Qt::LeftButton, 0, QPoint(50, 60)); - - QTRY_VERIFY(!flickable->isDraggingVertically()); - QVERIFY(!flickable->isDragging()); - QCOMPARE(vDragSpy.count(), 2); - QCOMPARE(dragSpy.count(), 2); - QCOMPARE(hDragSpy.count(), 0); - QCOMPARE(dragStartSpy.count(), 1); - QCOMPARE(dragEndSpy.count(), 1); - - // wait for any motion to end - QTRY_VERIFY(flickable->isMoving() == false); - - //Horizontal - vDragSpy.clear(); - hDragSpy.clear(); - dragSpy.clear(); - vMoveSpy.clear(); - hMoveSpy.clear(); - moveSpy.clear(); - dragStartSpy.clear(); - dragEndSpy.clear(); - - QTest::mousePress(canvas, Qt::LeftButton, 0, QPoint(90, 50)); - - QTest::mouseMove(canvas, QPoint(80, 50)); - QTest::mouseMove(canvas, QPoint(70, 50)); - QTest::mouseMove(canvas, QPoint(60, 50)); - - QVERIFY(!flickable->isDraggingVertically()); - QVERIFY(flickable->isDraggingHorizontally()); - QVERIFY(flickable->isDragging()); - QCOMPARE(vDragSpy.count(), 0); - QCOMPARE(dragSpy.count(), 1); - QCOMPARE(hDragSpy.count(), 1); - QCOMPARE(dragStartSpy.count(), 1); - QCOMPARE(dragEndSpy.count(), 0); - - QVERIFY(!flickable->isMovingVertically()); - QVERIFY(flickable->isMovingHorizontally()); - QVERIFY(flickable->isMoving()); - QCOMPARE(vMoveSpy.count(), 0); - QCOMPARE(moveSpy.count(), 1); - QCOMPARE(hMoveSpy.count(), 1); - - QTest::mouseRelease(canvas, Qt::LeftButton, 0, QPoint(60, 50)); - - QTRY_VERIFY(!flickable->isDraggingHorizontally()); - QVERIFY(!flickable->isDragging()); - QCOMPARE(vDragSpy.count(), 0); - QCOMPARE(dragSpy.count(), 2); - QCOMPARE(hDragSpy.count(), 2); - QCOMPARE(dragStartSpy.count(), 1); - QCOMPARE(dragEndSpy.count(), 1); - // Don't test moving because a flick could occur - -#ifdef Q_OS_MAC - QSKIP("Producing flicks on Mac CI impossible due to timing problems"); -#endif - - QTRY_VERIFY(!flickable->isMoving()); - - vMoveSpy.clear(); - hMoveSpy.clear(); - moveSpy.clear(); - QSignalSpy vFlickSpy(flickable, SIGNAL(flickingVerticallyChanged())); - QSignalSpy hFlickSpy(flickable, SIGNAL(flickingHorizontallyChanged())); - QSignalSpy flickSpy(flickable, SIGNAL(flickingChanged())); - - // flick then press while it is still moving - // flicking == false, moving == true; - flick(canvas, QPoint(20,190), QPoint(20, 50), 200); - QVERIFY(flickable->verticalVelocity() > 0.0); - QVERIFY(flickable->isFlicking()); - QVERIFY(flickable->isFlickingVertically()); - QVERIFY(!flickable->isFlickingHorizontally()); - QVERIFY(flickable->isMoving()); - QVERIFY(flickable->isMovingVertically()); - QVERIFY(!flickable->isMovingHorizontally()); - QCOMPARE(vMoveSpy.count(), 1); - QCOMPARE(hMoveSpy.count(), 0); - QCOMPARE(moveSpy.count(), 1); - QCOMPARE(vFlickSpy.count(), 1); - QCOMPARE(hFlickSpy.count(), 0); - QCOMPARE(flickSpy.count(), 1); - - QTest::mousePress(canvas, Qt::LeftButton, 0, QPoint(20, 50)); - QTRY_VERIFY(!flickable->isFlicking()); - QVERIFY(!flickable->isFlickingVertically()); - QVERIFY(flickable->isMoving()); - QVERIFY(flickable->isMovingVertically()); - - QTest::mouseRelease(canvas, Qt::LeftButton, 0, QPoint(20,50)); - QVERIFY(!flickable->isFlicking()); - QVERIFY(!flickable->isFlickingVertically()); - QTRY_VERIFY(!flickable->isMoving()); - QVERIFY(!flickable->isMovingVertically()); - - delete canvas; -} - -void tst_qquickflickable::disabled() -{ - QQuickView *canvas = new QQuickView; - canvas->setSource(testFileUrl("disabled.qml")); - canvas->show(); - canvas->requestActivateWindow(); - QVERIFY(canvas->rootObject() != 0); - - QQuickFlickable *flick = canvas->rootObject()->findChild("flickable"); - QVERIFY(flick != 0); - - QTest::mousePress(canvas, Qt::LeftButton, 0, QPoint(50, 90)); - - QTest::mouseMove(canvas, QPoint(50, 80)); - QTest::mouseMove(canvas, QPoint(50, 70)); - QTest::mouseMove(canvas, QPoint(50, 60)); - - QVERIFY(flick->isMoving() == false); - - QTest::mouseRelease(canvas, Qt::LeftButton, 0, QPoint(50, 60)); - - // verify that mouse clicks on other elements still work (QTBUG-20584) - QTest::mousePress(canvas, Qt::LeftButton, 0, QPoint(50, 10)); - QTest::mouseRelease(canvas, Qt::LeftButton, 0, QPoint(50, 10)); - - QTRY_VERIFY(canvas->rootObject()->property("clicked").toBool() == true); -} - -void tst_qquickflickable::flickVelocity() -{ -#ifdef Q_OS_MAC - QSKIP("Producing flicks on Mac CI impossible due to timing problems"); -#endif - - QQuickView *canvas = new QQuickView; - canvas->setSource(testFileUrl("flickable03.qml")); - canvas->show(); - canvas->requestActivateWindow(); - QVERIFY(canvas->rootObject() != 0); - - QQuickFlickable *flickable = qobject_cast(canvas->rootObject()); - QVERIFY(flickable != 0); - - // flick up - flick(canvas, QPoint(20,190), QPoint(20, 50), 200); - QVERIFY(flickable->verticalVelocity() > 0.0); - QTRY_VERIFY(flickable->verticalVelocity() == 0.0); - - // flick down - flick(canvas, QPoint(20,10), QPoint(20, 140), 200); - QVERIFY(flickable->verticalVelocity() < 0.0); - QTRY_VERIFY(flickable->verticalVelocity() == 0.0); - - // Flick multiple times and verify that flick acceleration is applied. - QQuickFlickablePrivate *fp = QQuickFlickablePrivate::get(flickable); - bool boosted = false; - for (int i = 0; i < 6; ++i) { - flick(canvas, QPoint(20,390), QPoint(20, 50), 200); - boosted |= fp->flickBoost > 1.0; - } - QVERIFY(boosted); - - // Flick in opposite direction -> boost cancelled. - flick(canvas, QPoint(20,10), QPoint(20, 340), 200); - QTRY_VERIFY(flickable->verticalVelocity() < 0.0); - QVERIFY(fp->flickBoost == 1.0); - - delete canvas; -} - -void tst_qquickflickable::margins() -{ - QDeclarativeEngine engine; - QDeclarativeComponent c(&engine, testFileUrl("margins.qml")); - QQuickItem *root = qobject_cast(c.create()); - QQuickFlickable *obj = qobject_cast(root); - QVERIFY(obj != 0); - - // starting state - QCOMPARE(obj->contentX(), -40.); - QCOMPARE(obj->contentY(), -20.); - QCOMPARE(obj->contentWidth(), 1600.); - QCOMPARE(obj->contentHeight(), 600.); - QCOMPARE(obj->xOrigin(), 0.); - QCOMPARE(obj->yOrigin(), 0.); - - // Reduce left margin - obj->setLeftMargin(30); - QTRY_COMPARE(obj->contentX(), -30.); - - // Reduce top margin - obj->setTopMargin(20); - QTRY_COMPARE(obj->contentY(), -20.); - - // position to the far right, including margin - obj->setContentX(1600 + 50 - obj->width()); - obj->returnToBounds(); - QTest::qWait(200); - QCOMPARE(obj->contentX(), 1600. + 50. - obj->width()); - - // position beyond the far right, including margin - obj->setContentX(1600 + 50 - obj->width() + 1.); - obj->returnToBounds(); - QTRY_COMPARE(obj->contentX(), 1600. + 50. - obj->width()); - - // Reduce right margin - obj->setRightMargin(40); - QTRY_COMPARE(obj->contentX(), 1600. + 40. - obj->width()); - QCOMPARE(obj->contentWidth(), 1600.); - - // position to the far bottom, including margin - obj->setContentY(600 + 30 - obj->height()); - obj->returnToBounds(); - QTest::qWait(200); - QCOMPARE(obj->contentY(), 600. + 30. - obj->height()); - - // position beyond the far bottom, including margin - obj->setContentY(600 + 30 - obj->height() + 1.); - obj->returnToBounds(); - QTRY_COMPARE(obj->contentY(), 600. + 30. - obj->height()); - - // Reduce bottom margin - obj->setBottomMargin(20); - QTRY_COMPARE(obj->contentY(), 600. + 20. - obj->height()); - QCOMPARE(obj->contentHeight(), 600.); - - delete root; -} - -QTEST_MAIN(tst_qquickflickable) - -#include "tst_qquickflickable.moc" diff --git a/tests/auto/qtquick2/qquickflipable/data/crash.qml b/tests/auto/qtquick2/qquickflipable/data/crash.qml deleted file mode 100644 index a0327918cb..0000000000 --- a/tests/auto/qtquick2/qquickflipable/data/crash.qml +++ /dev/null @@ -1,9 +0,0 @@ -import QtQuick 2.0 - -Flipable { - transform: Rotation { - axis.y: 1 - axis.z: 0 - angle: 180 - } -} diff --git a/tests/auto/qtquick2/qquickflipable/data/flipable-abort.qml b/tests/auto/qtquick2/qquickflipable/data/flipable-abort.qml deleted file mode 100644 index 90fc03a5f9..0000000000 --- a/tests/auto/qtquick2/qquickflipable/data/flipable-abort.qml +++ /dev/null @@ -1,10 +0,0 @@ -import QtQuick 2.0 - -Rectangle { - Flipable { - id: flipable - } - Rectangle { - visible: flipable.side == Flipable.Front - } -} diff --git a/tests/auto/qtquick2/qquickflipable/data/test-flipable.qml b/tests/auto/qtquick2/qquickflipable/data/test-flipable.qml deleted file mode 100644 index dff6d3fe39..0000000000 --- a/tests/auto/qtquick2/qquickflipable/data/test-flipable.qml +++ /dev/null @@ -1,9 +0,0 @@ -import QtQuick 2.0 - -Flipable { - id: flipable - width: 640; height: 480 - - front: Rectangle { anchors.fill: flipable } - back: Rectangle { anchors.fill: flipable } -} diff --git a/tests/auto/qtquick2/qquickflipable/qquickflipable.pro b/tests/auto/qtquick2/qquickflipable/qquickflipable.pro deleted file mode 100644 index 3afad837fe..0000000000 --- a/tests/auto/qtquick2/qquickflipable/qquickflipable.pro +++ /dev/null @@ -1,15 +0,0 @@ -CONFIG += testcase -TARGET = tst_qquickflipable -macx:CONFIG -= app_bundle - -SOURCES += tst_qquickflipable.cpp - -include (../../shared/util.pri) - -testDataFiles.files = data -testDataFiles.path = . -DEPLOYMENT += testDataFiles - -CONFIG += parallel_test - -QT += core-private gui-private v8-private declarative-private quick-private testlib diff --git a/tests/auto/qtquick2/qquickflipable/tst_qquickflipable.cpp b/tests/auto/qtquick2/qquickflipable/tst_qquickflipable.cpp deleted file mode 100644 index c2c40c9746..0000000000 --- a/tests/auto/qtquick2/qquickflipable/tst_qquickflipable.cpp +++ /dev/null @@ -1,135 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "../../shared/util.h" - -class tst_qquickflipable : public QDeclarativeDataTest -{ - Q_OBJECT -public: - -private slots: - void create(); - void checkFrontAndBack(); - void setFrontAndBack(); - - // below here task issues - void QTBUG_9161_crash(); - void QTBUG_8474_qgv_abort(); - -private: - QDeclarativeEngine engine; -}; - -void tst_qquickflipable::create() -{ - QDeclarativeEngine engine; - QDeclarativeComponent c(&engine, testFileUrl("test-flipable.qml")); - QQuickFlipable *obj = qobject_cast(c.create()); - - QVERIFY(obj != 0); - delete obj; -} - -void tst_qquickflipable::checkFrontAndBack() -{ - QDeclarativeEngine engine; - QDeclarativeComponent c(&engine, testFileUrl("test-flipable.qml")); - QQuickFlipable *obj = qobject_cast(c.create()); - - QVERIFY(obj != 0); - QVERIFY(obj->front() != 0); - QVERIFY(obj->back() != 0); - delete obj; -} - -void tst_qquickflipable::setFrontAndBack() -{ - QDeclarativeEngine engine; - QDeclarativeComponent c(&engine, testFileUrl("test-flipable.qml")); - QQuickFlipable *obj = qobject_cast(c.create()); - - QVERIFY(obj != 0); - QVERIFY(obj->front() != 0); - QVERIFY(obj->back() != 0); - - QString message = c.url().toString() + ":3:1: QML Flipable: front is a write-once property"; - QTest::ignoreMessage(QtWarningMsg, qPrintable(message)); - obj->setFront(new QQuickRectangle()); - - message = c.url().toString() + ":3:1: QML Flipable: back is a write-once property"; - QTest::ignoreMessage(QtWarningMsg, qPrintable(message)); - obj->setBack(new QQuickRectangle()); - delete obj; -} - -void tst_qquickflipable::QTBUG_9161_crash() -{ - QQuickView *canvas = new QQuickView; - canvas->setSource(testFileUrl("crash.qml")); - QQuickItem *root = canvas->rootObject(); - QVERIFY(root != 0); - canvas->show(); - delete canvas; -} - -void tst_qquickflipable::QTBUG_8474_qgv_abort() -{ - QQuickView *canvas = new QQuickView; - canvas->setSource(testFileUrl("flipable-abort.qml")); - QQuickItem *root = canvas->rootObject(); - QVERIFY(root != 0); - canvas->show(); - delete canvas; -} - -QTEST_MAIN(tst_qquickflipable) - -#include "tst_qquickflipable.moc" diff --git a/tests/auto/qtquick2/qquickfocusscope/data/canvasFocus.qml b/tests/auto/qtquick2/qquickfocusscope/data/canvasFocus.qml deleted file mode 100644 index 7d8dac5a22..0000000000 --- a/tests/auto/qtquick2/qquickfocusscope/data/canvasFocus.qml +++ /dev/null @@ -1,22 +0,0 @@ -import QtQuick 2.0 - -Column { - FocusScope { - objectName: "scope1" - width: 20 ;height: 20 - focus: true - Rectangle { - objectName: "item1" - anchors.fill: parent - focus: true - } - } - FocusScope { - objectName: "scope2" - width: 20 ;height: 20 - Rectangle { - objectName: "item2" - anchors.fill: parent - } - } -} diff --git a/tests/auto/qtquick2/qquickfocusscope/data/chain.qml b/tests/auto/qtquick2/qquickfocusscope/data/chain.qml deleted file mode 100644 index 4b96662318..0000000000 --- a/tests/auto/qtquick2/qquickfocusscope/data/chain.qml +++ /dev/null @@ -1,28 +0,0 @@ -import QtQuick 2.0 - -Rectangle { - id: root - width:300; height:400 - - property bool focus1: root.activeFocus - property bool focus2: item1.activeFocus - property bool focus3: fs1.activeFocus - property bool focus4: fs2.activeFocus - property bool focus5: theItem.activeFocus - - Item { - id: item1 - FocusScope { - id: fs1 - focus: true - FocusScope { - id: fs2 - focus: true - Item { - id: theItem - focus: true - } - } - } - } -} diff --git a/tests/auto/qtquick2/qquickfocusscope/data/forceActiveFocus.qml b/tests/auto/qtquick2/qquickfocusscope/data/forceActiveFocus.qml deleted file mode 100644 index 74d2106888..0000000000 --- a/tests/auto/qtquick2/qquickfocusscope/data/forceActiveFocus.qml +++ /dev/null @@ -1,26 +0,0 @@ -import QtQuick 2.0 - -Rectangle { - objectName: "root" - FocusScope { - objectName: "scope" - Item { - objectName: "item-a1" - FocusScope { - objectName: "scope-a" - Item { - objectName: "item-a2" - } - } - } - Item { - objectName: "item-b1" - FocusScope { - objectName: "scope-b" - Item { - objectName: "item-b2" - } - } - } - } -} diff --git a/tests/auto/qtquick2/qquickfocusscope/data/forcefocus.qml b/tests/auto/qtquick2/qquickfocusscope/data/forcefocus.qml deleted file mode 100644 index f41582a951..0000000000 --- a/tests/auto/qtquick2/qquickfocusscope/data/forcefocus.qml +++ /dev/null @@ -1,81 +0,0 @@ -import QtQuick 2.0 - -Rectangle { - width: 800; height: 600 - - FocusScope { - focus: true - - FocusScope { - id: firstScope - objectName: "item0" - focus: true - - Rectangle { - height: 120; width: 420 - - color: "transparent" - border.width: 5; border.color: firstScope.activeFocus?"blue":"black" - - Rectangle { - id: item1; objectName: "item1" - x: 10; y: 10; width: 100; height: 100; color: "green" - border.width: 5; border.color: activeFocus?"blue":"black" - focus: true - - Rectangle { - width: 50; height: 50; anchors.centerIn: parent - color: parent.activeFocus?"red":"transparent" - } - } - - Rectangle { - id: item2; objectName: "item2" - x: 310; y: 10; width: 100; height: 100; color: "green" - border.width: 5; border.color: activeFocus?"blue":"black" - - Rectangle { - width: 50; height: 50; anchors.centerIn: parent - color: parent.activeFocus?"red":"transparent" - } - } - } - } - - FocusScope { - id: secondScope - objectName: "item3" - - Rectangle { - y: 160; height: 120; width: 420 - - color: "transparent" - border.width: 5; border.color: secondScope.activeFocus?"blue":"black" - - Rectangle { - id: item4; objectName: "item4" - x: 10; y: 10; width: 100; height: 100; color: "green" - border.width: 5; border.color: activeFocus?"blue":"black" - - Rectangle { - width: 50; height: 50; anchors.centerIn: parent - color: parent.activeFocus?"red":"transparent" - } - } - - Rectangle { - id: item5; objectName: "item5" - x: 310; y: 10; width: 100; height: 100; color: "green" - border.width: 5; border.color: activeFocus?"blue":"black" - - Rectangle { - width: 50; height: 50; anchors.centerIn: parent - color: parent.activeFocus?"red":"transparent" - } - } - } - } - } - Keys.onDigit4Pressed: item4.focus = true - Keys.onDigit5Pressed: item5.forceActiveFocus() -} diff --git a/tests/auto/qtquick2/qquickfocusscope/data/qtBug13380.qml b/tests/auto/qtquick2/qquickfocusscope/data/qtBug13380.qml deleted file mode 100644 index 29de046b38..0000000000 --- a/tests/auto/qtquick2/qquickfocusscope/data/qtBug13380.qml +++ /dev/null @@ -1,24 +0,0 @@ -import QtQuick 2.0 - -Rectangle { - width: 400; height: 400 - - property bool showRect: false - onShowRectChanged: if (showRect) rect.visible = true - property bool noFocus: !fs2.activeFocus - - FocusScope { - id: fs1 - focus: true - } - Rectangle { - id: rect - visible: false - FocusScope { - id: fs2 - Rectangle { - focus: true - } - } - } -} diff --git a/tests/auto/qtquick2/qquickfocusscope/data/signalEmission.qml b/tests/auto/qtquick2/qquickfocusscope/data/signalEmission.qml deleted file mode 100644 index 999a40c5ad..0000000000 --- a/tests/auto/qtquick2/qquickfocusscope/data/signalEmission.qml +++ /dev/null @@ -1,33 +0,0 @@ -import QtQuick 2.0 - -Rectangle { - width: 200 - height: 200 - - FocusScope { - focus: true - Rectangle { - objectName: "item1" - color: "blue" - onFocusChanged: focus ? color = "red" : color = "blue" - } - Rectangle { - objectName: "item2" - color: "blue" - onFocusChanged: focus ? color = "red" : color = "blue" - } - } - - FocusScope { - Rectangle { - objectName: "item3" - color: "blue" - onFocusChanged: focus ? color = "red" : color = "blue" - } - Rectangle { - objectName: "item4" - color: "blue" - onFocusChanged: focus ? color = "red" : color = "blue" - } - } -} diff --git a/tests/auto/qtquick2/qquickfocusscope/data/test.qml b/tests/auto/qtquick2/qquickfocusscope/data/test.qml deleted file mode 100644 index 67be29c3fb..0000000000 --- a/tests/auto/qtquick2/qquickfocusscope/data/test.qml +++ /dev/null @@ -1,77 +0,0 @@ -import QtQuick 2.0 - -Rectangle { - color: "white" - width: 800 - height: 600 - - Keys.onDigit9Pressed: console.log("Error - Root") - - FocusScope { - id: myScope - objectName: "item0" - focus: true - - Keys.onDigit9Pressed: console.log("Error - FocusScope") - - Rectangle { - height: 120 - width: 420 - - color: "transparent" - border.width: 5 - border.color: myScope.activeFocus?"blue":"black" - - Rectangle { - id: item1; objectName: "item1" - x: 10; y: 10 - width: 100; height: 100; color: "green" - border.width: 5 - border.color: activeFocus?"blue":"black" - Keys.onDigit9Pressed: console.debug("Top Left"); - KeyNavigation.right: item2 - focus: true - - Rectangle { - width: 50; height: 50; anchors.centerIn: parent - color: parent.activeFocus?"red":"transparent" - } - } - - Rectangle { - id: item2; objectName: "item2" - x: 310; y: 10 - width: 100; height: 100; color: "green" - border.width: 5 - border.color: activeFocus?"blue":"black" - KeyNavigation.left: item1 - Keys.onDigit9Pressed: console.log("Top Right"); - - Rectangle { - width: 50; height: 50; anchors.centerIn: parent - color: parent.activeFocus?"red":"transparent" - } - } - } - KeyNavigation.down: item3 - } - - Text { x:100; y:170; text: "Blue border indicates scoped focus\nBlack border indicates NOT scoped focus\nRed box indicates active focus\nUse arrow keys to navigate\nPress \"9\" to print currently focused item" } - - Rectangle { - id: item3; objectName: "item3" - x: 10; y: 300 - width: 100; height: 100; color: "green" - border.width: 5 - border.color: activeFocus?"blue":"black" - - Keys.onDigit9Pressed: console.log("Bottom Left"); - KeyNavigation.up: myScope - - Rectangle { - width: 50; height: 50; anchors.centerIn: parent - color: parent.activeFocus?"red":"transparent" - } - } - -} diff --git a/tests/auto/qtquick2/qquickfocusscope/data/test2.qml b/tests/auto/qtquick2/qquickfocusscope/data/test2.qml deleted file mode 100644 index ad74f3e9f4..0000000000 --- a/tests/auto/qtquick2/qquickfocusscope/data/test2.qml +++ /dev/null @@ -1,39 +0,0 @@ -import QtQuick 2.0 - -Rectangle { - color: "white" - width: 800 - height: 600 - - Text { text: "All five rectangles should be red" } - - FocusScope { - y: 100 - focus: true; objectName: "item1" - Rectangle { width: 50; height: 50; color: parent.activeFocus?"red":"blue" } - - FocusScope { - y: 100 - focus: true; objectName: "item2" - Rectangle { width: 50; height: 50; color: parent.activeFocus?"red":"blue" } - - FocusScope { - y: 100 - focus: true; objectName: "item3" - Rectangle { width: 50; height: 50; color: parent.activeFocus?"red":"blue" } - - FocusScope { - y: 100 - focus: true; objectName: "item4" - Rectangle { width: 50; height: 50; color: parent.activeFocus?"red":"blue" } - - FocusScope { - y: 100 - focus: true; objectName: "item5" - Rectangle { width: 50; height: 50; color: parent.activeFocus?"red":"blue" } - } - } - } - } - } -} diff --git a/tests/auto/qtquick2/qquickfocusscope/data/test3.qml b/tests/auto/qtquick2/qquickfocusscope/data/test3.qml deleted file mode 100644 index 537c30816e..0000000000 --- a/tests/auto/qtquick2/qquickfocusscope/data/test3.qml +++ /dev/null @@ -1,52 +0,0 @@ -import QtQuick 2.0 - -Rectangle { - color: "white" - width: 800 - height: 600 - - ListModel { - id: model - ListElement { name: "1" } - ListElement { name: "2" } - ListElement { name: "3" } - ListElement { name: "4" } - ListElement { name: "5" } - ListElement { name: "6" } - ListElement { name: "7" } - ListElement { name: "8" } - ListElement { name: "9" } - } - - Component { - id: verticalDelegate - FocusScope { - id: root - width: 50; height: 50; - Keys.onDigit9Pressed: console.log("Error - " + name) - Rectangle { - focus: true - Keys.onDigit9Pressed: console.log(name) - width: 50; height: 50; - color: root.ListView.isCurrentItem?"red":"green" - Text { text: name; anchors.centerIn: parent } - } - } - } - - ListView { - width: 800; height: 50; orientation: "Horizontal" - focus: true - model: model - delegate: verticalDelegate - preferredHighlightBegin: 100 - preferredHighlightEnd: 100 - highlightRangeMode: "StrictlyEnforceRange" - } - - - Text { - y: 100; x: 50 - text: "Currently selected element should be red\nPressing \"9\" should print the number of the currently selected item\nBe sure to scroll all the way to the right, pause, and then all the way to the left." - } -} diff --git a/tests/auto/qtquick2/qquickfocusscope/data/test4.qml b/tests/auto/qtquick2/qquickfocusscope/data/test4.qml deleted file mode 100644 index 0eea649f5d..0000000000 --- a/tests/auto/qtquick2/qquickfocusscope/data/test4.qml +++ /dev/null @@ -1,76 +0,0 @@ -import QtQuick 2.0 - -Rectangle { - color: "white" - width: 800 - height: 600 - - Keys.onDigit9Pressed: console.log("Error - Root") - - FocusScope { - id: myScope - - Keys.onDigit9Pressed: console.log("Error - FocusScope") - - Rectangle { - objectName: "item0" - height: 120 - width: 420 - - color: "transparent" - border.width: 5 - border.color: myScope.activeFocus?"blue":"black" - - Rectangle { - id: item1; objectName: "item1" - x: 10; y: 10 - width: 100; height: 100; color: "green" - border.width: 5 - border.color: activeFocus?"blue":"black" - Keys.onDigit9Pressed: console.log("Error - Top Left"); - KeyNavigation.right: item2 - focus: true - - Rectangle { - width: 50; height: 50; anchors.centerIn: parent - color: parent.activeFocus?"red":"transparent" - } - } - - Rectangle { - id: item2; objectName: "item2" - x: 310; y: 10 - width: 100; height: 100; color: "green" - border.width: 5 - border.color: activeFocus?"blue":"black" - KeyNavigation.left: item1 - Keys.onDigit9Pressed: console.log("Error - Top Right"); - - Rectangle { - width: 50; height: 50; anchors.centerIn: parent - color: parent.activeFocus?"red":"transparent" - } - } - } - KeyNavigation.down: item3 - } - - Text { x:100; y:170; text: "There should be no blue borders, or red squares.\nPressing \"9\" should do nothing.\nArrow keys should have no effect." } - - Rectangle { - id: item3; objectName: "item3" - x: 10; y: 300 - width: 100; height: 100; color: "green" - border.width: 5 - border.color: activeFocus?"blue":"black" - - Keys.onDigit9Pressed: console.log("Error - Bottom Left"); - KeyNavigation.up: myScope - - Rectangle { - width: 50; height: 50; anchors.centerIn: parent - color: parent.activeFocus?"red":"transparent" - } - } - -} diff --git a/tests/auto/qtquick2/qquickfocusscope/data/test5.qml b/tests/auto/qtquick2/qquickfocusscope/data/test5.qml deleted file mode 100644 index 9c37cd1303..0000000000 --- a/tests/auto/qtquick2/qquickfocusscope/data/test5.qml +++ /dev/null @@ -1,84 +0,0 @@ -import QtQuick 2.0 - -Rectangle { - color: "white" - width: 800 - height: 600 - - Keys.onReturnPressed: console.log("Error - Root") - - FocusScope { - id: myScope - objectName: "item0" - focus: true - - Keys.onReturnPressed: console.log("Error - FocusScope") - - Rectangle { - height: 120 - width: 420 - - color: "transparent" - border.width: 5 - border.color: myScope.activeFocus?"blue":"black" - - Rectangle { - x: 10; y: 10 - width: 100; height: 100; color: "green" - border.width: 5 - border.color: item1.activeFocus?"blue":"black" - } - - TextEdit { - id: item1; objectName: "item1" - x: 20; y: 20 - width: 90; height: 90 - color: "white" - font.pixelSize: 20 - Keys.onReturnPressed: console.log("Top Left"); - KeyNavigation.right: item2 - focus: true - wrapMode: TextEdit.WordWrap - text: "Box 1" - } - - Rectangle { - id: item2; objectName: "item2" - x: 310; y: 10 - width: 100; height: 100; color: "green" - border.width: 5 - border.color: activeFocus?"blue":"black" - KeyNavigation.left: item1 - Keys.onReturnPressed: console.log("Top Right"); - - Rectangle { - width: 50; height: 50; anchors.centerIn: parent - color: parent.activeFocus?"red":"transparent" - } - } - } - KeyNavigation.down: item3 - } - - Text { x:100; y:170; text: "Blue border indicates scoped focus\nBlack border indicates NOT scoped focus\nRed box or flashing cursor indicates active focus\nUse arrow keys to navigate\nPress Ctrl-Return to print currently focused item" } - - Rectangle { - x: 10; y: 300 - width: 100; height: 100; color: "green" - border.width: 5 - border.color: item3.activeFocus?"blue":"black" - } - - TextEdit { - id: item3; objectName: "item3" - x: 20; y: 310 - width: 90; height: 90 - color: "white" - font.pixelSize: 20 - text: "Box 3" - - Keys.onReturnPressed: console.log("Bottom Left"); - KeyNavigation.up: myScope - wrapMode: TextEdit.WordWrap - } -} diff --git a/tests/auto/qtquick2/qquickfocusscope/qquickfocusscope.pro b/tests/auto/qtquick2/qquickfocusscope/qquickfocusscope.pro deleted file mode 100644 index d83f6ca7a3..0000000000 --- a/tests/auto/qtquick2/qquickfocusscope/qquickfocusscope.pro +++ /dev/null @@ -1,14 +0,0 @@ -CONFIG += testcase -TARGET = tst_qquickfocusscope -SOURCES += tst_qquickfocusscope.cpp - -include (../../shared/util.pri) -include (../shared/util.pri) - -macx:CONFIG -= app_bundle - -testDataFiles.files = data -testDataFiles.path = . -DEPLOYMENT += testDataFiles - -QT += core-private gui-private declarative-private quick-private testlib diff --git a/tests/auto/qtquick2/qquickfocusscope/tst_qquickfocusscope.cpp b/tests/auto/qtquick2/qquickfocusscope/tst_qquickfocusscope.cpp deleted file mode 100644 index 4264c68d92..0000000000 --- a/tests/auto/qtquick2/qquickfocusscope/tst_qquickfocusscope.cpp +++ /dev/null @@ -1,636 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "../../shared/util.h" -#include "../shared/visualtestutil.h" - -using namespace QQuickVisualTestUtil; - -class tst_qquickfocusscope : public QDeclarativeDataTest -{ - Q_OBJECT -public: - tst_qquickfocusscope() {} - -private slots: - void basic(); - void nested(); - void noFocus(); - void textEdit(); - void forceFocus(); - void noParentFocus(); - void signalEmission(); - void qtBug13380(); - void forceActiveFocus(); - void canvasFocus(); -}; - -void tst_qquickfocusscope::basic() -{ - QQuickView *view = new QQuickView; - view->setSource(testFileUrl("test.qml")); - - QQuickFocusScope *item0 = findItem(view->rootObject(), QLatin1String("item0")); - QQuickRectangle *item1 = findItem(view->rootObject(), QLatin1String("item1")); - QQuickRectangle *item2 = findItem(view->rootObject(), QLatin1String("item2")); - QQuickRectangle *item3 = findItem(view->rootObject(), QLatin1String("item3")); - QVERIFY(item0 != 0); - QVERIFY(item1 != 0); - QVERIFY(item2 != 0); - QVERIFY(item3 != 0); - - view->show(); - view->requestActivateWindow(); - - QTest::qWaitForWindowShown(view); - QTRY_VERIFY(view == qGuiApp->focusWindow()); - - QVERIFY(view->isTopLevel()); - QVERIFY(item0->hasActiveFocus() == true); - QVERIFY(item1->hasActiveFocus() == true); - QVERIFY(item2->hasActiveFocus() == false); - QVERIFY(item3->hasActiveFocus() == false); - - QTest::keyClick(view, Qt::Key_Right); - QTest::qWait(50); - QVERIFY(item0->hasActiveFocus() == true); - QVERIFY(item1->hasActiveFocus() == false); - QVERIFY(item2->hasActiveFocus() == true); - QVERIFY(item3->hasActiveFocus() == false); - - QTest::keyClick(view, Qt::Key_Down); - QTest::qWait(50); - QVERIFY(item0->hasActiveFocus() == false); - QVERIFY(item1->hasActiveFocus() == false); - QVERIFY(item2->hasActiveFocus() == false); - QVERIFY(item3->hasActiveFocus() == true); - - delete view; -} - -void tst_qquickfocusscope::nested() -{ - QQuickView *view = new QQuickView; - view->setSource(testFileUrl("test2.qml")); - - QQuickFocusScope *item1 = findItem(view->rootObject(), QLatin1String("item1")); - QQuickFocusScope *item2 = findItem(view->rootObject(), QLatin1String("item2")); - QQuickFocusScope *item3 = findItem(view->rootObject(), QLatin1String("item3")); - QQuickFocusScope *item4 = findItem(view->rootObject(), QLatin1String("item4")); - QQuickFocusScope *item5 = findItem(view->rootObject(), QLatin1String("item5")); - QVERIFY(item1 != 0); - QVERIFY(item2 != 0); - QVERIFY(item3 != 0); - QVERIFY(item4 != 0); - QVERIFY(item5 != 0); - - view->show(); - view->requestActivateWindow(); - - QTest::qWaitForWindowShown(view); - QTRY_VERIFY(view == qGuiApp->focusWindow()); - - QVERIFY(item1->hasActiveFocus() == true); - QVERIFY(item2->hasActiveFocus() == true); - QVERIFY(item3->hasActiveFocus() == true); - QVERIFY(item4->hasActiveFocus() == true); - QVERIFY(item5->hasActiveFocus() == true); - delete view; -} - -void tst_qquickfocusscope::noFocus() -{ - QQuickView *view = new QQuickView; - view->setSource(testFileUrl("test4.qml")); - - QQuickRectangle *item0 = findItem(view->rootObject(), QLatin1String("item0")); - QQuickRectangle *item1 = findItem(view->rootObject(), QLatin1String("item1")); - QQuickRectangle *item2 = findItem(view->rootObject(), QLatin1String("item2")); - QQuickRectangle *item3 = findItem(view->rootObject(), QLatin1String("item3")); - QVERIFY(item0 != 0); - QVERIFY(item1 != 0); - QVERIFY(item2 != 0); - QVERIFY(item3 != 0); - - view->show(); - view->requestActivateWindow(); - QTest::qWaitForWindowShown(view); - QTRY_VERIFY(view == qGuiApp->focusWindow()); - - QVERIFY(item0->hasActiveFocus() == false); - QVERIFY(item1->hasActiveFocus() == false); - QVERIFY(item2->hasActiveFocus() == false); - QVERIFY(item3->hasActiveFocus() == false); - - QTest::keyClick(view, Qt::Key_Right); - QVERIFY(item0->hasActiveFocus() == false); - QVERIFY(item1->hasActiveFocus() == false); - QVERIFY(item2->hasActiveFocus() == false); - QVERIFY(item3->hasActiveFocus() == false); - - QTest::keyClick(view, Qt::Key_Down); - QVERIFY(item0->hasActiveFocus() == false); - QVERIFY(item1->hasActiveFocus() == false); - QVERIFY(item2->hasActiveFocus() == false); - QVERIFY(item3->hasActiveFocus() == false); - - delete view; -} - -void tst_qquickfocusscope::textEdit() -{ - QQuickView *view = new QQuickView; - view->setSource(testFileUrl("test5.qml")); - - QQuickFocusScope *item0 = findItem(view->rootObject(), QLatin1String("item0")); - QQuickTextEdit *item1 = findItem(view->rootObject(), QLatin1String("item1")); - QQuickRectangle *item2 = findItem(view->rootObject(), QLatin1String("item2")); - QQuickTextEdit *item3 = findItem(view->rootObject(), QLatin1String("item3")); - QVERIFY(item0 != 0); - QVERIFY(item1 != 0); - QVERIFY(item2 != 0); - QVERIFY(item3 != 0); - - view->show(); - view->requestActivateWindow(); - - QTest::qWaitForWindowShown(view); - - QTRY_VERIFY(view == qGuiApp->focusWindow()); - QVERIFY(item0->hasActiveFocus() == true); - QVERIFY(item1->hasActiveFocus() == true); - QVERIFY(item2->hasActiveFocus() == false); - QVERIFY(item3->hasActiveFocus() == false); - - QTest::keyClick(view, Qt::Key_Right); - QVERIFY(item0->hasActiveFocus() == true); - QVERIFY(item1->hasActiveFocus() == true); - QVERIFY(item2->hasActiveFocus() == false); - QVERIFY(item3->hasActiveFocus() == false); - - QTest::keyClick(view, Qt::Key_Right); - QTest::keyClick(view, Qt::Key_Right); - QTest::keyClick(view, Qt::Key_Right); - QTest::keyClick(view, Qt::Key_Right); - QTest::keyClick(view, Qt::Key_Right); - QVERIFY(item0->hasActiveFocus() == true); - QVERIFY(item1->hasActiveFocus() == false); - QVERIFY(item2->hasActiveFocus() == true); - QVERIFY(item3->hasActiveFocus() == false); - - QTest::keyClick(view, Qt::Key_Down); - QVERIFY(item0->hasActiveFocus() == false); - QVERIFY(item1->hasActiveFocus() == false); - QVERIFY(item2->hasActiveFocus() == false); - QVERIFY(item3->hasActiveFocus() == true); - - delete view; -} - -void tst_qquickfocusscope::forceFocus() -{ - QQuickView *view = new QQuickView; - view->setSource(testFileUrl("forcefocus.qml")); - - QQuickFocusScope *item0 = findItem(view->rootObject(), QLatin1String("item0")); - QQuickRectangle *item1 = findItem(view->rootObject(), QLatin1String("item1")); - QQuickRectangle *item2 = findItem(view->rootObject(), QLatin1String("item2")); - QQuickFocusScope *item3 = findItem(view->rootObject(), QLatin1String("item3")); - QQuickRectangle *item4 = findItem(view->rootObject(), QLatin1String("item4")); - QQuickRectangle *item5 = findItem(view->rootObject(), QLatin1String("item5")); - QVERIFY(item0 != 0); - QVERIFY(item1 != 0); - QVERIFY(item2 != 0); - QVERIFY(item3 != 0); - QVERIFY(item4 != 0); - QVERIFY(item5 != 0); - - view->show(); - view->requestActivateWindow(); - QTest::qWaitForWindowShown(view); - QTRY_VERIFY(view == qGuiApp->focusWindow()); - - QVERIFY(item0->hasActiveFocus() == true); - QVERIFY(item1->hasActiveFocus() == true); - QVERIFY(item2->hasActiveFocus() == false); - QVERIFY(item3->hasActiveFocus() == false); - QVERIFY(item4->hasActiveFocus() == false); - QVERIFY(item5->hasActiveFocus() == false); - - QTest::keyClick(view, Qt::Key_4); - QVERIFY(item0->hasActiveFocus() == true); - QVERIFY(item1->hasActiveFocus() == true); - QVERIFY(item2->hasActiveFocus() == false); - QVERIFY(item3->hasActiveFocus() == false); - QVERIFY(item4->hasActiveFocus() == false); - QVERIFY(item5->hasActiveFocus() == false); - - QTest::keyClick(view, Qt::Key_5); - QVERIFY(item0->hasActiveFocus() == false); - QVERIFY(item1->hasActiveFocus() == false); - QVERIFY(item2->hasActiveFocus() == false); - QVERIFY(item3->hasActiveFocus() == true); - QVERIFY(item4->hasActiveFocus() == false); - QVERIFY(item5->hasActiveFocus() == true); - - delete view; -} - -void tst_qquickfocusscope::noParentFocus() -{ - QQuickView *view = new QQuickView; - view->setSource(testFileUrl("chain.qml")); - QVERIFY(view->rootObject()); - - view->show(); - view->requestActivateWindow(); - QTest::qWaitForWindowShown(view); - QTRY_VERIFY(view == qGuiApp->focusWindow()); - - QVERIFY(view->rootObject()->property("focus1") == false); - QVERIFY(view->rootObject()->property("focus2") == false); - QVERIFY(view->rootObject()->property("focus3") == true); - QVERIFY(view->rootObject()->property("focus4") == true); - QVERIFY(view->rootObject()->property("focus5") == true); - - delete view; -} - -void tst_qquickfocusscope::signalEmission() -{ - QQuickView *view = new QQuickView; - view->setSource(testFileUrl("signalEmission.qml")); - - QQuickRectangle *item1 = findItem(view->rootObject(), QLatin1String("item1")); - QQuickRectangle *item2 = findItem(view->rootObject(), QLatin1String("item2")); - QQuickRectangle *item3 = findItem(view->rootObject(), QLatin1String("item3")); - QQuickRectangle *item4 = findItem(view->rootObject(), QLatin1String("item4")); - QVERIFY(item1 != 0); - QVERIFY(item2 != 0); - QVERIFY(item3 != 0); - QVERIFY(item4 != 0); - - view->show(); - view->requestActivateWindow(); - - QTest::qWaitForWindowShown(view); - QTRY_VERIFY(view == qGuiApp->focusWindow()); - - QVariant blue(QColor("blue")); - QVariant red(QColor("red")); - - item1->setFocus(true); - QCOMPARE(item1->property("color"), red); - QCOMPARE(item2->property("color"), blue); - QCOMPARE(item3->property("color"), blue); - QCOMPARE(item4->property("color"), blue); - - item2->setFocus(true); - QCOMPARE(item1->property("color"), blue); - QCOMPARE(item2->property("color"), red); - QCOMPARE(item3->property("color"), blue); - QCOMPARE(item4->property("color"), blue); - - item3->setFocus(true); - QCOMPARE(item1->property("color"), blue); - QCOMPARE(item2->property("color"), red); - QCOMPARE(item3->property("color"), red); - QCOMPARE(item4->property("color"), blue); - - item4->setFocus(true); - QCOMPARE(item1->property("color"), blue); - QCOMPARE(item2->property("color"), red); - QCOMPARE(item3->property("color"), blue); - QCOMPARE(item4->property("color"), red); - - item4->setFocus(false); - QCOMPARE(item1->property("color"), blue); - QCOMPARE(item2->property("color"), red); - QCOMPARE(item3->property("color"), blue); - QCOMPARE(item4->property("color"), blue); - - delete view; -} - -void tst_qquickfocusscope::qtBug13380() -{ - QQuickView *view = new QQuickView; - view->setSource(testFileUrl("qtBug13380.qml")); - - view->show(); - QVERIFY(view->rootObject()); - view->requestActivateWindow(); - qApp->processEvents(); - - QTest::qWaitForWindowShown(view); - - QTRY_VERIFY(view == qGuiApp->focusWindow()); - QVERIFY(view->rootObject()->property("noFocus").toBool()); - - view->rootObject()->setProperty("showRect", true); - QVERIFY(view->rootObject()->property("noFocus").toBool()); - - delete view; -} - -void tst_qquickfocusscope::forceActiveFocus() -{ - QQuickView *view = new QQuickView; - view->setSource(testFileUrl("forceActiveFocus.qml")); - - view->show(); - view->requestActivateWindow(); - QTest::qWaitForWindowShown(view); - QTRY_VERIFY(view == qGuiApp->focusWindow()); - - QQuickItem *rootObject = view->rootObject(); - QVERIFY(rootObject); - - QQuickItem *scope = findItem(rootObject, QLatin1String("scope")); - QQuickItem *itemA1 = findItem(rootObject, QLatin1String("item-a1")); - QQuickItem *scopeA = findItem(rootObject, QLatin1String("scope-a")); - QQuickItem *itemA2 = findItem(rootObject, QLatin1String("item-a2")); - QQuickItem *itemB1 = findItem(rootObject, QLatin1String("item-b1")); - QQuickItem *scopeB = findItem(rootObject, QLatin1String("scope-b")); - QQuickItem *itemB2 = findItem(rootObject, QLatin1String("item-b2")); - - QVERIFY(scope); - QVERIFY(itemA1); - QVERIFY(scopeA); - QVERIFY(itemA2); - QVERIFY(itemB1); - QVERIFY(scopeB); - QVERIFY(itemB2); - - QSignalSpy rootSpy(rootObject, SIGNAL(activeFocusChanged(bool))); - QSignalSpy scopeSpy(scope, SIGNAL(activeFocusChanged(bool))); - QSignalSpy scopeASpy(scopeA, SIGNAL(activeFocusChanged(bool))); - QSignalSpy scopeBSpy(scopeB, SIGNAL(activeFocusChanged(bool))); - - // First, walk the focus from item-a1 down to item-a2 and back again - itemA1->forceActiveFocus(); - QVERIFY(itemA1->hasActiveFocus()); - QVERIFY(!rootObject->hasActiveFocus()); - QCOMPARE(rootSpy.count(), 0); - QCOMPARE(scopeSpy.count(), 1); - - scopeA->forceActiveFocus(); - QVERIFY(!itemA1->hasActiveFocus()); - QVERIFY(scopeA->hasActiveFocus()); - QCOMPARE(scopeASpy.count(), 1); - QCOMPARE(rootSpy.count(), 0); - QCOMPARE(scopeSpy.count(), 1); - - itemA2->forceActiveFocus(); - QVERIFY(!itemA1->hasActiveFocus()); - QVERIFY(itemA2->hasActiveFocus()); - QVERIFY(scopeA->hasActiveFocus()); - QCOMPARE(scopeASpy.count(), 1); - QCOMPARE(rootSpy.count(), 0); - QCOMPARE(scopeSpy.count(), 1); - - scopeA->forceActiveFocus(); - QVERIFY(!itemA1->hasActiveFocus()); - QVERIFY(itemA2->hasActiveFocus()); - QVERIFY(scopeA->hasActiveFocus()); - QCOMPARE(scopeASpy.count(), 1); - QCOMPARE(rootSpy.count(), 0); - QCOMPARE(scopeSpy.count(), 1); - - itemA1->forceActiveFocus(); - QVERIFY(itemA1->hasActiveFocus()); - QVERIFY(!scopeA->hasActiveFocus()); - QVERIFY(!itemA2->hasActiveFocus()); - QCOMPARE(scopeASpy.count(), 2); - QCOMPARE(rootSpy.count(), 0); - QCOMPARE(scopeSpy.count(), 1); - - // Then jump back and forth between branch 'a' and 'b' - itemB1->forceActiveFocus(); - QVERIFY(itemB1->hasActiveFocus()); - QCOMPARE(rootSpy.count(), 0); - QCOMPARE(scopeSpy.count(), 1); - - scopeA->forceActiveFocus(); - QVERIFY(!itemA1->hasActiveFocus()); - QVERIFY(!itemB1->hasActiveFocus()); - QVERIFY(scopeA->hasActiveFocus()); - QCOMPARE(scopeASpy.count(), 3); - QCOMPARE(rootSpy.count(), 0); - QCOMPARE(scopeSpy.count(), 1); - - scopeB->forceActiveFocus(); - QVERIFY(!scopeA->hasActiveFocus()); - QVERIFY(!itemB1->hasActiveFocus()); - QVERIFY(scopeB->hasActiveFocus()); - QCOMPARE(scopeASpy.count(), 4); - QCOMPARE(scopeBSpy.count(), 1); - QCOMPARE(rootSpy.count(), 0); - QCOMPARE(scopeSpy.count(), 1); - - itemA2->forceActiveFocus(); - QVERIFY(!scopeB->hasActiveFocus()); - QVERIFY(itemA2->hasActiveFocus()); - QCOMPARE(scopeASpy.count(), 5); - QCOMPARE(scopeBSpy.count(), 2); - QCOMPARE(rootSpy.count(), 0); - QCOMPARE(scopeSpy.count(), 1); - - itemB2->forceActiveFocus(); - QVERIFY(!itemA2->hasActiveFocus()); - QVERIFY(itemB2->hasActiveFocus()); - QCOMPARE(scopeASpy.count(), 6); - QCOMPARE(scopeBSpy.count(), 3); - QCOMPARE(rootSpy.count(), 0); - QCOMPARE(scopeSpy.count(), 1); - - delete view; -} - -void tst_qquickfocusscope::canvasFocus() -{ - QQuickView *view = new QQuickView; - view->setSource(testFileUrl("canvasFocus.qml")); - - QQuickView alternateView; - - QQuickItem *rootObject = view->rootObject(); - QVERIFY(rootObject); - - QQuickItem *rootItem = view->rootItem(); - QQuickItem *scope1 = findItem(rootObject, QLatin1String("scope1")); - QQuickItem *item1 = findItem(rootObject, QLatin1String("item1")); - QQuickItem *scope2 = findItem(rootObject, QLatin1String("scope2")); - QQuickItem *item2 = findItem(rootObject, QLatin1String("item2")); - - QVERIFY(scope1); - QVERIFY(item1); - QVERIFY(scope2); - QVERIFY(item2); - - QSignalSpy rootFocusSpy(rootItem, SIGNAL(focusChanged(bool))); - QSignalSpy scope1FocusSpy(scope1, SIGNAL(focusChanged(bool))); - QSignalSpy item1FocusSpy(item1, SIGNAL(focusChanged(bool))); - QSignalSpy scope2FocusSpy(scope2, SIGNAL(focusChanged(bool))); - QSignalSpy item2FocusSpy(item2, SIGNAL(focusChanged(bool))); - QSignalSpy rootActiveFocusSpy(rootItem, SIGNAL(activeFocusChanged(bool))); - QSignalSpy scope1ActiveFocusSpy(scope1, SIGNAL(activeFocusChanged(bool))); - QSignalSpy item1ActiveFocusSpy(item1, SIGNAL(activeFocusChanged(bool))); - QSignalSpy scope2ActiveFocusSpy(scope2, SIGNAL(activeFocusChanged(bool))); - QSignalSpy item2ActiveFocusSpy(item2, SIGNAL(activeFocusChanged(bool))); - - QEXPECT_FAIL("", "QTBUG-22415", Abort); - QCOMPARE(rootItem->hasFocus(), false); - QCOMPARE(rootItem->hasActiveFocus(), false); - QCOMPARE(scope1->hasFocus(), true); - QCOMPARE(scope1->hasActiveFocus(), false); - QCOMPARE(item1->hasFocus(), true); - QCOMPARE(item1->hasActiveFocus(), false); - QCOMPARE(scope2->hasFocus(), false); - QCOMPARE(scope2->hasActiveFocus(), false); - QCOMPARE(item2->hasFocus(), false); - QCOMPARE(item2->hasActiveFocus(), false); - - view->show(); - view->requestActivateWindow(); - - QTest::qWaitForWindowShown(view); - QTRY_VERIFY(view == qGuiApp->focusWindow()); - - // Now the canvas has focus, active focus given to item1 - QCOMPARE(rootItem->hasFocus(), true); - QCOMPARE(rootItem->hasActiveFocus(), true); - QCOMPARE(scope1->hasFocus(), true); - QCOMPARE(scope1->hasActiveFocus(), true); - QCOMPARE(item1->hasFocus(), true); - QCOMPARE(item1->hasActiveFocus(), true); - QCOMPARE(scope2->hasFocus(), false); - QCOMPARE(scope2->hasActiveFocus(), false); - QCOMPARE(item2->hasFocus(), false); - QCOMPARE(item2->hasActiveFocus(), false); - - QCOMPARE(rootFocusSpy.count(), 1); - QCOMPARE(rootActiveFocusSpy.count(), 1); - QCOMPARE(scope1FocusSpy.count(), 0); - QCOMPARE(scope1ActiveFocusSpy.count(), 1); - QCOMPARE(item1FocusSpy.count(), 0); - QCOMPARE(item1ActiveFocusSpy.count(), 1); - - - // view->hide(); // seemingly doesn't remove focus, so have an another view steal it. - alternateView.show(); - alternateView.requestActivateWindow(); - QTest::qWaitForWindowShown(&alternateView); - QTRY_VERIFY(QGuiApplication::focusWindow() == &alternateView); - - QCOMPARE(rootItem->hasFocus(), false); - QCOMPARE(rootItem->hasActiveFocus(), false); - QCOMPARE(scope1->hasFocus(), true); - QCOMPARE(scope1->hasActiveFocus(), false); - QCOMPARE(item1->hasFocus(), true); - QCOMPARE(item1->hasActiveFocus(), false); - - QCOMPARE(rootFocusSpy.count(), 2); - QCOMPARE(rootActiveFocusSpy.count(), 2); - QCOMPARE(scope1FocusSpy.count(), 0); - QCOMPARE(scope1ActiveFocusSpy.count(), 2); - QCOMPARE(item1FocusSpy.count(), 0); - QCOMPARE(item1ActiveFocusSpy.count(), 2); - - - // canvas does not have focus, so item2 will not get active focus - item2->forceActiveFocus(); - - QCOMPARE(rootItem->hasFocus(), false); - QCOMPARE(rootItem->hasActiveFocus(), false); - QCOMPARE(scope1->hasFocus(), false); - QCOMPARE(scope1->hasActiveFocus(), false); - QCOMPARE(item1->hasFocus(), true); - QCOMPARE(item1->hasActiveFocus(), false); - QCOMPARE(scope2->hasFocus(), true); - QCOMPARE(scope2->hasActiveFocus(), false); - QCOMPARE(item2->hasFocus(), true); - QCOMPARE(item2->hasActiveFocus(), false); - - QCOMPARE(rootFocusSpy.count(), 2); - QCOMPARE(rootActiveFocusSpy.count(), 2); - QCOMPARE(scope1FocusSpy.count(), 1); - QCOMPARE(scope1ActiveFocusSpy.count(), 2); - QCOMPARE(item1FocusSpy.count(), 0); - QCOMPARE(item1ActiveFocusSpy.count(), 2); - QCOMPARE(scope2FocusSpy.count(), 1); - QCOMPARE(scope2ActiveFocusSpy.count(), 0); - QCOMPARE(item2FocusSpy.count(), 1); - QCOMPARE(item2ActiveFocusSpy.count(), 0); - - // give the canvas focus, and item2 will get active focus - view->show(); - view->requestActivateWindow(); - QTest::qWaitForWindowShown(view); - QTRY_VERIFY(QGuiApplication::focusWindow() == view); - - QCOMPARE(rootItem->hasFocus(), true); - QCOMPARE(rootItem->hasActiveFocus(), true); - QCOMPARE(scope2->hasFocus(), true); - QCOMPARE(scope2->hasActiveFocus(), true); - QCOMPARE(item2->hasFocus(), true); - QCOMPARE(item2->hasActiveFocus(), true); - QCOMPARE(rootFocusSpy.count(), 3); - QCOMPARE(rootActiveFocusSpy.count(), 3); - QCOMPARE(scope2FocusSpy.count(), 1); - QCOMPARE(scope2ActiveFocusSpy.count(), 1); - QCOMPARE(item2FocusSpy.count(), 1); - QCOMPARE(item2ActiveFocusSpy.count(), 1); - - delete view; -} - -QTEST_MAIN(tst_qquickfocusscope) - -#include "tst_qquickfocusscope.moc" diff --git a/tests/auto/qtquick2/qquickgridview/data/ComponentView.qml b/tests/auto/qtquick2/qquickgridview/data/ComponentView.qml deleted file mode 100644 index 12ab6c92d1..0000000000 --- a/tests/auto/qtquick2/qquickgridview/data/ComponentView.qml +++ /dev/null @@ -1,14 +0,0 @@ -import QtQuick 2.0 - -GridView { - id: view - - property string title - - width: 100; height: 100; - - model: 1 - delegate: Text { objectName: "listItem"; text: view.title } - header: Text { objectName: "header"; text: view.title } - footer: Text { objectName: "footer"; text: view.title } -} diff --git a/tests/auto/qtquick2/qquickgridview/data/addTransitions.qml b/tests/auto/qtquick2/qquickgridview/data/addTransitions.qml deleted file mode 100644 index faea02a50d..0000000000 --- a/tests/auto/qtquick2/qquickgridview/data/addTransitions.qml +++ /dev/null @@ -1,129 +0,0 @@ -import QtQuick 2.0 - -Rectangle { - id: root - width: 550 - height: 600 - - property int duration: 10 - property int count: grid.count - - Component { - id: myDelegate - - Rectangle { - id: wrapper - - property string nameData: name - - objectName: "wrapper" - width: 80 - height: 60 - border.width: 1 - Column { - Text { text: index } - Text { - text: wrapper.x + ", " + wrapper.y - } - Text { - id: textName - objectName: "textName" - text: name - } - } - color: GridView.isCurrentItem ? "lightsteelblue" : "white" - - onXChanged: checkPos() - onYChanged: checkPos() - - function checkPos() { - if (Qt.point(x, y) == targetItems_transitionFrom) - model_targetItems_transitionFrom.addItem(name, "") - if (Qt.point(x, y) == displacedItems_transitionVia) - model_displacedItems_transitionVia.addItem(name, "") - } - } - } - - GridView { - id: grid - - property int targetTransitionsDone - property int displaceTransitionsDone - - property var targetTrans_items: new Object() - property var targetTrans_targetIndexes: new Array() - property var targetTrans_targetItems: new Array() - - property var displacedTrans_items: new Object() - property var displacedTrans_targetIndexes: new Array() - property var displacedTrans_targetItems: new Array() - - objectName: "grid" - width: 240 - height: 320 - cellWidth: 80 - cellHeight: 60 - anchors.centerIn: parent - model: testModel - delegate: myDelegate - - // for QDeclarativeListProperty types - function copyList(propList) { - var temp = new Array() - for (var i=0; iName:
      ' + name } - Text { text: 'Number: ' + number } - } - } - } - Component { - id: highlightRed - Rectangle { - color: "red" - radius: 10 - opacity: 0.5 - } - } - GridView { - cellWidth:180 - cellHeight:40 - objectName: "gridView" - anchors.fill: parent - model: listModel - delegate: delegate - highlight: highlightRed - focus: true - keyNavigationWraps: true - cacheBuffer: 10 - flow: GridView.LeftToRight - } - - data:[ - ListModel { - id: listModel - ListElement { - name: "Bill Smith" - number: "555 3264" - } - ListElement { - name: "John Brown" - number: "555 8426" - } - ListElement { - name: "Sam Wise" - number: "555 0473" - } - }, - ListModel { - objectName: "alternateModel" - ListElement { - name: "Jack" - number: "555 8426" - } - ListElement { - name: "Mary" - number: "555 3264" - } - } - ] -} - - diff --git a/tests/auto/qtquick2/qquickgridview/data/removeTransitions.qml b/tests/auto/qtquick2/qquickgridview/data/removeTransitions.qml deleted file mode 100644 index b07a03580a..0000000000 --- a/tests/auto/qtquick2/qquickgridview/data/removeTransitions.qml +++ /dev/null @@ -1,146 +0,0 @@ -import QtQuick 2.0 - -Rectangle { - id: root - width: 500 - height: 600 - - property int duration: 10 - property int count: grid.count - - Component { - id: myDelegate - Rectangle { - id: wrapper - - property string nameData: name - - objectName: "wrapper" - width: 80 - height: 60 - border.width: 1 - Column { - Text { text: index } - Text { - text: wrapper.x + ", " + wrapper.y - } - Text { - id: textName - objectName: "textName" - text: name - } - } - color: GridView.isCurrentItem ? "lightsteelblue" : "white" - - onXChanged: checkPos() - onYChanged: checkPos() - - function checkPos() { - if (Qt.point(x, y) == targetItems_transitionTo) { - model_targetItems_transitionTo.addItem(nameData, "") // name is invalid once model removes the item - } - if (Qt.point(x, y) == displacedItems_transitionVia) { - model_displacedItems_transitionVia.addItem(name, "") - } - } - } - } - - GridView { - id: grid - - property int targetTransitionsDone - property int displaceTransitionsDone - - property var targetTrans_items: new Object() - property var targetTrans_targetIndexes: new Array() - property var targetTrans_targetItems: new Array() - - property var displacedTrans_items: new Object() - property var displacedTrans_targetIndexes: new Array() - property var displacedTrans_targetItems: new Array() - - objectName: "grid" - width: 240 - height: 320 - cellWidth: 80 - cellHeight: 60 - anchors.centerIn: parent - model: testModel - delegate: myDelegate - - // for QDeclarativeListProperty types - function copyList(propList) { - var temp = new Array() - for (var i=0; i -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "../../shared/util.h" -#include "../shared/viewtestutil.h" -#include "../shared/visualtestutil.h" -#include - -Q_DECLARE_METATYPE(Qt::LayoutDirection) -Q_DECLARE_METATYPE(QQuickGridView::Flow) - -using namespace QQuickViewTestUtil; -using namespace QQuickVisualTestUtil; - -class tst_QQuickGridView : public QDeclarativeDataTest -{ - Q_OBJECT -public: - tst_QQuickGridView(); - -private slots: - void items(); - void changed(); - void inserted(); - void inserted_more(); - void inserted_more_data(); - void insertBeforeVisible(); - void insertBeforeVisible_data(); - void removed(); - void removed_more(); - void removed_more_data(); - void addOrRemoveBeforeVisible(); - void addOrRemoveBeforeVisible_data(); - void clear(); - void moved(); - void moved_data(); - void multipleChanges(); - void multipleChanges_data(); - void swapWithFirstItem(); - void changeFlow(); - void currentIndex(); - void noCurrentIndex(); - void defaultValues(); - void properties(); - void propertyChanges(); - void componentChanges(); - void modelChanges(); - void positionViewAtIndex(); - void positionViewAtIndex_rightToLeft(); - void mirroring(); - void snapping(); - void resetModel(); - void enforceRange(); - void enforceRange_rightToLeft(); - void QTBUG_8456(); - void manualHighlight(); - void footer(); - void footer_data(); - void header(); - void header_data(); - void resizeViewAndRepaint(); - void changeColumnCount(); - void indexAt_itemAt_data(); - void indexAt_itemAt(); - void onAdd(); - void onAdd_data(); - void onRemove(); - void onRemove_data(); - void columnCount(); - void margins(); - void creationContext(); - void snapToRow_data(); - void snapToRow(); - void snapOneRow_data(); - void snapOneRow(); - void unaligned(); - void cacheBuffer(); - void asynchronous(); - void unrequestedVisibility(); - - void populateTransitions(); - void populateTransitions_data(); - void addTransitions(); - void addTransitions_data(); - void moveTransitions(); - void moveTransitions_data(); - void removeTransitions(); - void removeTransitions_data(); - void multipleTransitions(); - void multipleTransitions_data(); - -private: - QList toIntList(const QVariantList &list); - void matchIndexLists(const QVariantList &indexLists, const QList &expectedIndexes); - void matchItemsAndIndexes(const QVariantMap &items, const QaimModel &model, const QList &expectedIndexes); - void matchItemLists(const QVariantList &itemLists, const QList &expectedItems); -}; - -tst_QQuickGridView::tst_QQuickGridView() -{ -} - -void tst_QQuickGridView::items() -{ - QQuickView *canvas = createView(); - - QaimModel model; - model.addItem("Fred", "12345"); - model.addItem("John", "2345"); - model.addItem("Bob", "54321"); - model.addItem("Billy", "22345"); - model.addItem("Sam", "2945"); - model.addItem("Ben", "04321"); - model.addItem("Jim", "0780"); - - QDeclarativeContext *ctxt = canvas->rootContext(); - ctxt->setContextProperty("testModel", &model); - ctxt->setContextProperty("testRightToLeft", QVariant(false)); - ctxt->setContextProperty("testTopToBottom", QVariant(false)); - - canvas->setSource(testFileUrl("gridview1.qml")); - qApp->processEvents(); - - QQuickGridView *gridview = findItem(canvas->rootObject(), "grid"); - QTRY_VERIFY(gridview != 0); - - QQuickItem *contentItem = gridview->contentItem(); - QTRY_VERIFY(contentItem != 0); - - QTRY_COMPARE(gridview->count(), model.count()); - QTRY_COMPARE(canvas->rootObject()->property("count").toInt(), model.count()); - QTRY_COMPARE(contentItem->childItems().count(), model.count()+1); // assumes all are visible, +1 for the (default) highlight item - - for (int i = 0; i < model.count(); ++i) { - QQuickText *name = findItem(contentItem, "textName", i); - QTRY_VERIFY(name != 0); - QTRY_COMPARE(name->text(), model.name(i)); - QQuickText *number = findItem(contentItem, "textNumber", i); - QTRY_VERIFY(number != 0); - QTRY_COMPARE(number->text(), model.number(i)); - } - - // set an empty model and confirm that items are destroyed - QaimModel model2; - ctxt->setContextProperty("testModel", &model2); - - int itemCount = findItems(contentItem, "wrapper").count(); - QTRY_VERIFY(itemCount == 0); - - delete canvas; -} - -void tst_QQuickGridView::changed() -{ - QQuickView *canvas = createView(); - - QaimModel model; - model.addItem("Fred", "12345"); - model.addItem("John", "2345"); - model.addItem("Bob", "54321"); - model.addItem("Billy", "22345"); - model.addItem("Sam", "2945"); - model.addItem("Ben", "04321"); - model.addItem("Jim", "0780"); - - QDeclarativeContext *ctxt = canvas->rootContext(); - ctxt->setContextProperty("testModel", &model); - ctxt->setContextProperty("testRightToLeft", QVariant(false)); - ctxt->setContextProperty("testTopToBottom", QVariant(false)); - - canvas->setSource(testFileUrl("gridview1.qml")); - qApp->processEvents(); - - QQuickFlickable *gridview = findItem(canvas->rootObject(), "grid"); - QTRY_VERIFY(gridview != 0); - - QQuickItem *contentItem = gridview->contentItem(); - QTRY_VERIFY(contentItem != 0); - - model.modifyItem(1, "Will", "9876"); - QQuickText *name = findItem(contentItem, "textName", 1); - QTRY_VERIFY(name != 0); - QTRY_COMPARE(name->text(), model.name(1)); - QQuickText *number = findItem(contentItem, "textNumber", 1); - QTRY_VERIFY(number != 0); - QTRY_COMPARE(number->text(), model.number(1)); - - delete canvas; -} - -void tst_QQuickGridView::inserted() -{ - QQuickView *canvas = createView(); - canvas->show(); - - QaimModel model; - model.addItem("Fred", "12345"); - model.addItem("John", "2345"); - model.addItem("Bob", "54321"); - - QDeclarativeContext *ctxt = canvas->rootContext(); - ctxt->setContextProperty("testModel", &model); - ctxt->setContextProperty("testRightToLeft", QVariant(false)); - ctxt->setContextProperty("testTopToBottom", QVariant(false)); - - canvas->setSource(testFileUrl("gridview1.qml")); - qApp->processEvents(); - - QQuickGridView *gridview = findItem(canvas->rootObject(), "grid"); - QTRY_VERIFY(gridview != 0); - - QQuickItem *contentItem = gridview->contentItem(); - QTRY_VERIFY(contentItem != 0); - - model.insertItem(1, "Will", "9876"); - - QTRY_COMPARE(canvas->rootObject()->property("count").toInt(), model.count()); - QTRY_COMPARE(contentItem->childItems().count(), model.count()+1); // assumes all are visible, +1 for the (default) highlight item - - QQuickText *name = findItem(contentItem, "textName", 1); - QTRY_VERIFY(name != 0); - QTRY_COMPARE(name->text(), model.name(1)); - QQuickText *number = findItem(contentItem, "textNumber", 1); - QTRY_VERIFY(number != 0); - QTRY_COMPARE(number->text(), model.number(1)); - - // Checks that onAdd is called - int added = canvas->rootObject()->property("added").toInt(); - QTRY_COMPARE(added, 1); - - // Confirm items positioned correctly - for (int i = 0; i < model.count(); ++i) { - QQuickItem *item = findItem(contentItem, "wrapper", i); - QTRY_COMPARE(item->x(), (i%3)*80.0); - QTRY_COMPARE(item->y(), (i/3)*60.0); - } - - model.insertItem(0, "Foo", "1111"); // zero index, and current item - - QTRY_COMPARE(contentItem->childItems().count(), model.count()+1); // assumes all are visible, +1 for the (default) highlight item - - name = findItem(contentItem, "textName", 0); - QTRY_VERIFY(name != 0); - QTRY_COMPARE(name->text(), model.name(0)); - number = findItem(contentItem, "textNumber", 0); - QTRY_VERIFY(number != 0); - QTRY_COMPARE(number->text(), model.number(0)); - - QTRY_COMPARE(gridview->currentIndex(), 1); - - // Confirm items positioned correctly - for (int i = 0; i < model.count(); ++i) { - QQuickItem *item = findItem(contentItem, "wrapper", i); - QTRY_VERIFY(item->x() == (i%3)*80); - QTRY_VERIFY(item->y() == (i/3)*60); - } - - for (int i = model.count(); i < 30; ++i) - model.insertItem(i, "Hello", QString::number(i)); - - gridview->setContentY(120); - - // Insert item outside visible area - model.insertItem(1, "Hello", "1324"); - - QTRY_VERIFY(gridview->contentY() == 120); - - delete canvas; -} - -void tst_QQuickGridView::inserted_more() -{ - QFETCH(qreal, contentY); - QFETCH(int, insertIndex); - QFETCH(int, insertCount); - QFETCH(qreal, itemsOffsetAfterMove); - - QaimModel model; - for (int i = 0; i < 30; i++) - model.addItem("Item" + QString::number(i), ""); - - QQuickView *canvas = createView(); - QDeclarativeContext *ctxt = canvas->rootContext(); - ctxt->setContextProperty("testModel", &model); - ctxt->setContextProperty("testRightToLeft", QVariant(false)); - ctxt->setContextProperty("testTopToBottom", QVariant(false)); - - canvas->setSource(testFileUrl("gridview1.qml")); - canvas->show(); - qApp->processEvents(); - - QQuickGridView *gridview = findItem(canvas->rootObject(), "grid"); - QTRY_VERIFY(gridview != 0); - QQuickItem *contentItem = gridview->contentItem(); - QTRY_VERIFY(contentItem != 0); - - gridview->setContentY(contentY); - QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false); - - QList > newData; - for (int i=0; iproperty("count").toInt(), model.count()); - - // check visibleItems.first() is in correct position - QQuickItem *item0 = findItem(contentItem, "wrapper", 0); - QVERIFY(item0); - QCOMPARE(item0->y(), 0.0); - - QList items = findItems(contentItem, "wrapper"); - int firstVisibleIndex = -1; - for (int i=0; iy() >= contentY) { - QDeclarativeExpression e(qmlContext(items[i]), items[i], "index"); - firstVisibleIndex = e.evaluate().toInt(); - break; - } - } - QVERIFY2(firstVisibleIndex >= 0, QTest::toString(firstVisibleIndex)); - - // Confirm items positioned correctly and indexes correct - int itemCount = findItems(contentItem, "wrapper").count(); - QQuickText *name; - QQuickText *number; - for (int i = firstVisibleIndex; i < model.count() && i < itemCount; ++i) { - QQuickItem *item = findItem(contentItem, "wrapper", i); - QVERIFY2(item, QTest::toString(QString("Item %1 not found").arg(i))); - - QCOMPARE(item->x(), (i%3)*80.0); - QCOMPARE(item->y(), (i/3)*60.0 + itemsOffsetAfterMove); - - name = findItem(contentItem, "textName", i); - QVERIFY(name != 0); - QCOMPARE(name->text(), model.name(i)); - number = findItem(contentItem, "textNumber", i); - QVERIFY(number != 0); - QCOMPARE(number->text(), model.number(i)); - } - - delete canvas; -} - -void tst_QQuickGridView::inserted_more_data() -{ - QTest::addColumn("contentY"); - QTest::addColumn("insertIndex"); - QTest::addColumn("insertCount"); - QTest::addColumn("itemsOffsetAfterMove"); - - QTest::newRow("add 1, before visible items") - << 120.0 // show 6-23 - << 5 << 1 - << 0.0; // insert 1 above first visible, grid is rearranged; first visible moves forward within its row - // new 1st visible item is at 0 - - QTest::newRow("add 2, before visible items") - << 120.0 // show 6-23 - << 5 << 2 - << 0.0; // insert 2 above first visible, grid is rearranged; first visible moves forward within its row - - QTest::newRow("add 3, before visible items") - << 120.0 // show 6-23 - << 5 << 3 - << -60.0; // insert 3 (1 row) above first visible in negative pos, first visible does not move - - QTest::newRow("add 5, before visible items") - << 120.0 // show 6-23 - << 5 << 5 - << -60.0; // insert 1 row + 2 items above first visible, 1 row added at negative pos, - // grid is rearranged and first visible moves forward within its row - - QTest::newRow("add 6, before visible items") - << 120.0 // show 6-23 - << 5 << 6 - << -60.0 * 2; // insert 2 rows above first visible in negative pos, first visible does not move - - - - QTest::newRow("add 1, at start of visible, content at start") - << 0.0 - << 0 << 1 - << 0.0; - - QTest::newRow("add multiple, at start of visible, content at start") - << 0.0 - << 0 << 3 - << 0.0; - - QTest::newRow("add 1, at start of visible, content not at start") - << 120.0 // show 6-23 - << 6 << 1 - << 0.0; - - QTest::newRow("add multiple, at start of visible, content not at start") - << 120.0 // show 6-23 - << 6 << 3 - << 0.0; - - - QTest::newRow("add 1, at end of visible, content at start") - << 0.0 - << 17 << 1 - << 0.0; - - QTest::newRow("add 1, at end of visible, content at start") - << 0.0 - << 17 << 3 - << 0.0; - - QTest::newRow("add 1, at end of visible, content not at start") - << 120.0 // show 6-23 - << 23 << 1 - << 0.0; - - QTest::newRow("add multiple, at end of visible, content not at start") - << 120.0 // show 6-23 - << 23 << 3 - << 0.0; - - - QTest::newRow("add 1, after visible, content at start") - << 0.0 - << 20 << 1 - << 0.0; - - QTest::newRow("add 1, after visible, content at start") - << 0.0 - << 20 << 3 - << 0.0; - - QTest::newRow("add 1, after visible, content not at start") - << 120.0 // show 6-23 - << 24 << 1 - << 0.0; - - QTest::newRow("add multiple, after visible, content not at start") - << 120.0 // show 6-23 - << 24 << 3 - << 0.0; -} - -void tst_QQuickGridView::insertBeforeVisible() -{ - QFETCH(int, insertIndex); - QFETCH(int, insertCount); - QFETCH(int, cacheBuffer); - - QQuickText *name; - QQuickView *canvas = createView(); - - QaimModel model; - for (int i = 0; i < 30; i++) - model.addItem("Item" + QString::number(i), ""); - - QDeclarativeContext *ctxt = canvas->rootContext(); - ctxt->setContextProperty("testModel", &model); - ctxt->setContextProperty("testRightToLeft", QVariant(false)); - ctxt->setContextProperty("testTopToBottom", QVariant(false)); - canvas->setSource(testFileUrl("gridview1.qml")); - canvas->show(); - qApp->processEvents(); - - QQuickGridView *gridview = findItem(canvas->rootObject(), "grid"); - QTRY_VERIFY(gridview != 0); - QQuickItem *contentItem = gridview->contentItem(); - QTRY_VERIFY(contentItem != 0); - - gridview->setCacheBuffer(cacheBuffer); - QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false); - - // trigger a refill (not just setting contentY) so that the visibleItems grid is updated - int firstVisibleIndex = 12; // move to an index where the top item is not visible - gridview->setContentY(firstVisibleIndex/3 * 60.0); - gridview->setCurrentIndex(firstVisibleIndex); - QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false); - - QTRY_COMPARE(gridview->currentIndex(), firstVisibleIndex); - QQuickItem *item = findItem(contentItem, "wrapper", firstVisibleIndex); - QVERIFY(item); - QCOMPARE(item->y(), gridview->contentY()); - - QList > newData; - for (int i=0; iproperty("count").toInt(), model.count()); - - // now, moving to the top of the view should position the inserted items correctly - int itemsOffsetAfterMove = (insertCount / 3) * -60.0; - gridview->setCurrentIndex(0); - QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false); - QTRY_COMPARE(gridview->currentIndex(), 0); - QTRY_COMPARE(gridview->contentY(), 0.0 + itemsOffsetAfterMove); - - // Confirm items positioned correctly and indexes correct - int itemCount = findItems(contentItem, "wrapper").count(); - for (int i = 0; i < model.count() && i < itemCount; ++i) { - item = findItem(contentItem, "wrapper", i); - QVERIFY2(item, QTest::toString(QString("Item %1 not found").arg(i))); - QCOMPARE(item->x(), (i%3)*80.0); - QCOMPARE(item->y(), (i/3)*60.0 + itemsOffsetAfterMove); - name = findItem(contentItem, "textName", i); - QVERIFY(name != 0); - QTRY_COMPARE(name->text(), model.name(i)); - } - - delete canvas; -} - -void tst_QQuickGridView::insertBeforeVisible_data() -{ - QTest::addColumn("insertIndex"); - QTest::addColumn("insertCount"); - QTest::addColumn("cacheBuffer"); - - QTest::newRow("insert 1 at 0, 0 buffer") << 0 << 1 << 0; - QTest::newRow("insert 1 at 0, 100 buffer") << 0 << 1 << 100; - QTest::newRow("insert 1 at 0, 500 buffer") << 0 << 1 << 500; - - QTest::newRow("insert 1 at 1, 0 buffer") << 1 << 1 << 0; - QTest::newRow("insert 1 at 1, 100 buffer") << 1 << 1 << 100; - QTest::newRow("insert 1 at 1, 500 buffer") << 1 << 1 << 500; - - QTest::newRow("insert multiple at 0, 0 buffer") << 0 << 6 << 0; - QTest::newRow("insert multiple at 0, 100 buffer") << 0 << 6 << 100; - QTest::newRow("insert multiple at 0, 500 buffer") << 0 << 6 << 500; - - QTest::newRow("insert multiple at 1, 0 buffer") << 1 << 6 << 0; - QTest::newRow("insert multiple at 1, 100 buffer") << 1 << 6 << 100; - QTest::newRow("insert multiple at 1, 500 buffer") << 1 << 6 << 500; -} - -void tst_QQuickGridView::removed() -{ - QQuickView *canvas = createView(); - canvas->show(); - - QaimModel model; - for (int i = 0; i < 40; i++) - model.addItem("Item" + QString::number(i), ""); - - QDeclarativeContext *ctxt = canvas->rootContext(); - ctxt->setContextProperty("testModel", &model); - ctxt->setContextProperty("testRightToLeft", QVariant(false)); - ctxt->setContextProperty("testTopToBottom", QVariant(false)); - - canvas->setSource(testFileUrl("gridview1.qml")); - qApp->processEvents(); - - QQuickGridView *gridview = findItem(canvas->rootObject(), "grid"); - QTRY_VERIFY(gridview != 0); - QQuickItem *contentItem = gridview->contentItem(); - QTRY_VERIFY(contentItem != 0); - QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false); - - model.removeItem(1); - QTRY_COMPARE(canvas->rootObject()->property("count").toInt(), model.count()); - - QQuickText *name = findItem(contentItem, "textName", 1); - QTRY_VERIFY(name != 0); - QTRY_COMPARE(name->text(), model.name(1)); - QQuickText *number = findItem(contentItem, "textNumber", 1); - QTRY_VERIFY(number != 0); - QTRY_COMPARE(number->text(), model.number(1)); - - - // Checks that onRemove is called - QString removed = canvas->rootObject()->property("removed").toString(); - QTRY_COMPARE(removed, QString("Item1")); - - // Confirm items positioned correctly - int itemCount = findItems(contentItem, "wrapper").count(); - for (int i = 0; i < model.count() && i < itemCount; ++i) { - QQuickItem *item = findItem(contentItem, "wrapper", i); - if (!item) qWarning() << "Item" << i << "not found"; - QTRY_VERIFY(item->x() == (i%3)*80); - QTRY_VERIFY(item->y() == (i/3)*60); - } - - // Remove first item (which is the current item); - model.removeItem(0); - QTRY_COMPARE(canvas->rootObject()->property("count").toInt(), model.count()); - - name = findItem(contentItem, "textName", 0); - QTRY_VERIFY(name != 0); - QTRY_COMPARE(name->text(), model.name(0)); - number = findItem(contentItem, "textNumber", 0); - QTRY_VERIFY(number != 0); - QTRY_COMPARE(number->text(), model.number(0)); - - - // Confirm items positioned correctly - itemCount = findItems(contentItem, "wrapper").count(); - for (int i = 0; i < model.count() && i < itemCount; ++i) { - QQuickItem *item = findItem(contentItem, "wrapper", i); - if (!item) qWarning() << "Item" << i << "not found"; - QTRY_VERIFY(item->x() == (i%3)*80); - QTRY_VERIFY(item->y() == (i/3)*60); - } - - // Remove items not visible - model.removeItem(25); - QTRY_COMPARE(canvas->rootObject()->property("count").toInt(), model.count()); - - // Confirm items positioned correctly - itemCount = findItems(contentItem, "wrapper").count(); - for (int i = 0; i < model.count() && i < itemCount; ++i) { - QQuickItem *item = findItem(contentItem, "wrapper", i); - if (!item) qWarning() << "Item" << i << "not found"; - QTRY_VERIFY(item->x() == (i%3)*80); - QTRY_VERIFY(item->y() == (i/3)*60); - } - - // Remove items before visible - gridview->setContentY(120); - gridview->setCurrentIndex(10); - - // Setting currentIndex above shouldn't cause view to scroll - QTRY_COMPARE(gridview->contentY(), 120.0); - - model.removeItem(1); - QTRY_COMPARE(canvas->rootObject()->property("count").toInt(), model.count()); - - // Confirm items positioned correctly - for (int i = 6; i < 18; ++i) { - QQuickItem *item = findItem(contentItem, "wrapper", i); - if (!item) qWarning() << "Item" << i << "not found"; - QTRY_VERIFY(item->x() == (i%3)*80); - QTRY_VERIFY(item->y() == (i/3)*60); - } - - // Remove currentIndex - QQuickItem *oldCurrent = gridview->currentItem(); - model.removeItem(9); - QTRY_COMPARE(canvas->rootObject()->property("count").toInt(), model.count()); - - QTRY_COMPARE(gridview->currentIndex(), 9); - QTRY_VERIFY(gridview->currentItem() != oldCurrent); - - gridview->setContentY(0); - // let transitions settle. - QTest::qWait(300); - - // Confirm items positioned correctly - itemCount = findItems(contentItem, "wrapper").count(); - for (int i = 0; i < model.count() && i < itemCount; ++i) { - QQuickItem *item = findItem(contentItem, "wrapper", i); - QTRY_VERIFY(item->x() == (i%3)*80); - QTRY_VERIFY(item->y() == (i/3)*60); - } - - // remove item outside current view. - gridview->setCurrentIndex(32); - gridview->setContentY(240); - - model.removeItem(30); - QTRY_VERIFY(gridview->currentIndex() == 31); - - // remove current item beyond visible items. - gridview->setCurrentIndex(20); - gridview->setContentY(0); - model.removeItem(20); - - QTRY_COMPARE(gridview->currentIndex(), 20); - QTRY_VERIFY(gridview->currentItem() != 0); - - // remove item before current, but visible - gridview->setCurrentIndex(8); - gridview->setContentY(240); - oldCurrent = gridview->currentItem(); - model.removeItem(6); - - QTRY_COMPARE(gridview->currentIndex(), 7); - QTRY_VERIFY(gridview->currentItem() == oldCurrent); - - delete canvas; -} - -void tst_QQuickGridView::removed_more() -{ - QFETCH(qreal, contentY); - QFETCH(int, removeIndex); - QFETCH(int, removeCount); - QFETCH(qreal, itemsOffsetAfterMove); - QFETCH(QString, firstVisible); - - QQuickText *name; - QQuickText *number; - QQuickView *canvas = createView(); - - QaimModel model; - for (int i = 0; i < 30; i++) - model.addItem("Item" + QString::number(i), ""); - - QDeclarativeContext *ctxt = canvas->rootContext(); - ctxt->setContextProperty("testModel", &model); - ctxt->setContextProperty("testRightToLeft", QVariant(false)); - ctxt->setContextProperty("testTopToBottom", QVariant(false)); - canvas->setSource(testFileUrl("gridview1.qml")); - canvas->show(); - qApp->processEvents(); - - QQuickGridView *gridview = findItem(canvas->rootObject(), "grid"); - QTRY_VERIFY(gridview != 0); - QQuickItem *contentItem = gridview->contentItem(); - QTRY_VERIFY(contentItem != 0); - - gridview->setContentY(contentY); - QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false); - - model.removeItems(removeIndex, removeCount); - QTRY_COMPARE(gridview->property("count").toInt(), model.count()); - - QString firstName; - int firstVisibleIndex = -1; - QList items = findItems(contentItem, "wrapper"); - for (int i=0; iy() >= contentY) { - QDeclarativeExpression e(qmlContext(items[i]), items[i], "index"); - firstVisibleIndex = e.evaluate().toInt(); - QDeclarativeExpression en(qmlContext(items[i]), items[i], "name"); - firstName = en.evaluate().toString(); - break; - } - } - QVERIFY2(firstVisibleIndex >= 0, QTest::toString(firstVisibleIndex)); - QCOMPARE(firstName, firstVisible); - - // Confirm items positioned correctly and indexes correct - int itemCount = findItems(contentItem, "wrapper").count(); - for (int i = firstVisibleIndex; i < model.count() && i < itemCount; ++i) { - QQuickItem *item = findItem(contentItem, "wrapper", i); - QVERIFY2(item, QTest::toString(QString("Item %1 not found").arg(i))); - - QTRY_COMPARE(item->x(), (i%3)*80.0); - QTRY_COMPARE(item->y(), (i/3)*60.0 + itemsOffsetAfterMove); - - name = findItem(contentItem, "textName", i); - QVERIFY(name != 0); - QTRY_COMPARE(name->text(), model.name(i)); - number = findItem(contentItem, "textNumber", i); - QVERIFY(number != 0); - QTRY_COMPARE(number->text(), model.number(i)); - } - - delete canvas; -} - -void tst_QQuickGridView::removed_more_data() -{ - QTest::addColumn("contentY"); - QTest::addColumn("removeIndex"); - QTest::addColumn("removeCount"); - QTest::addColumn("itemsOffsetAfterMove"); - QTest::addColumn("firstVisible"); - - QTest::newRow("remove 1, before visible items") - << 120.0 // show 6-23 - << 2 << 1 - << 0.0 << "Item7"; - - QTest::newRow("remove 1, before visible position") - << 120.0 // show 6-23 - << 3 << 1 - << 0.0 << "Item7"; - - QTest::newRow("remove multiple, all before visible items") - << 120.0 - << 1 << 3 - << 60.0 << "Item6"; // removed top row, slide down by 1 row - - QTest::newRow("remove multiple, all before visible items, remove item 0") - << 120.0 - << 0 << 4 - << 60.0 << "Item7"; // removed top row, slide down by 1 row - - QTest::newRow("remove multiple rows, all before visible items") - << 240.0 // show 12-29 - << 1 << 7 - << 120.0 << "Item13"; - - QTest::newRow("remove one row before visible, content y not on item border") - << 100.0 - << 0 << 3 - << 60.0 << "Item6"; // 1 row removed - - QTest::newRow("remove mix of visible/non-visible") - << 120.0 // show 6-23 - << 2 << 3 - << 60.0 << "Item6"; // 1 row removed - - - // remove 3,4,5 before the visible pos, first row moves down to just before the visible pos, - // items 6,7 are removed from view, item 8 slides up to original pos of item 6 (120px) - QTest::newRow("remove multiple, mix of items from before and within visible items") - << 120.0 - << 3 << 5 - << 60.0 << "Item8"; // adjust for the 1 row removed before the visible - - QTest::newRow("remove multiple, mix of items from before and within visible items, remove item 0") - << 120.0 - << 0 << 8 - << 60.0 * 2 << "Item8"; // adjust for the 2 rows removed before the visible - - - QTest::newRow("remove 1, from start of visible, content at start") - << 0.0 - << 0 << 1 - << 0.0 << "Item1"; - - QTest::newRow("remove multiple, from start of visible, content at start") - << 0.0 - << 0 << 3 - << 0.0 << "Item3"; - - QTest::newRow("remove 1, from start of visible, content not at start") - << 120.0 // show 6-23 - << 4 << 1 - << 0.0 << "Item7"; - - QTest::newRow("remove multiple, from start of visible, content not at start") - << 120.0 // show 6-23 - << 4 << 3 - << 0.0 << "Item9"; - - - QTest::newRow("remove 1, from middle of visible, content at start") - << 0.0 - << 10 << 1 - << 0.0 << "Item0"; - - QTest::newRow("remove multiple, from middle of visible, content at start") - << 0.0 - << 10 << 5 - << 0.0 << "Item0"; - - QTest::newRow("remove 1, from middle of visible, content not at start") - << 120.0 // show 6-23 - << 10 << 1 - << 0.0 << "Item6"; - - QTest::newRow("remove multiple, from middle of visible, content not at start") - << 120.0 // show 6-23 - << 10 << 5 - << 0.0 << "Item6"; - - - QTest::newRow("remove 1, after visible, content at start") - << 0.0 - << 16 << 1 - << 0.0 << "Item0"; - - QTest::newRow("remove multiple, after visible, content at start") - << 0.0 - << 16 << 5 - << 0.0 << "Item0"; - - QTest::newRow("remove 1, after visible, content not at start") - << 120.0 // show 6-23 - << 16+4 << 1 - << 0.0 << "Item6"; - - QTest::newRow("remove multiple, after visible, content not at start") - << 120.0 // show 6-23 - << 16+4 << 5 - << 0.0 << "Item6"; - - QTest::newRow("remove multiple, mix of items from within and after visible items") - << 120.0 // show 6-23 - << 20 << 5 - << 0.0 << "Item6"; -} - -void tst_QQuickGridView::addOrRemoveBeforeVisible() -{ - // QTBUG-21588: ensure re-layout is done on grid after adding or removing - // items from before the visible area - - QFETCH(bool, doAdd); - QFETCH(qreal, newTopContentY); - - QQuickView *canvas = createView(); - canvas->show(); - - QaimModel model; - for (int i = 0; i < 30; i++) - model.addItem("Item" + QString::number(i), ""); - - QDeclarativeContext *ctxt = canvas->rootContext(); - ctxt->setContextProperty("testModel", &model); - ctxt->setContextProperty("testRightToLeft", QVariant(false)); - ctxt->setContextProperty("testTopToBottom", QVariant(false)); - canvas->setSource(testFileUrl("gridview1.qml")); - - QQuickGridView *gridview = findItem(canvas->rootObject(), "grid"); - QTRY_VERIFY(gridview != 0); - QQuickItem *contentItem = gridview->contentItem(); - QTRY_VERIFY(contentItem != 0); - - QQuickText *name = findItem(contentItem, "textName", 0); - QTRY_COMPARE(name->text(), QString("Item0")); - - gridview->setCurrentIndex(0); - qApp->processEvents(); - QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false); - - // scroll down until item 0 is no longer drawn - // (bug not triggered if we just move using content y, since that doesn't - // refill and change the visible items) - gridview->setCurrentIndex(24); - qApp->processEvents(); - - QTRY_COMPARE(gridview->currentIndex(), 24); - QTRY_COMPARE(gridview->contentY(), 220.0); - - QTest::qWait(100); // wait for refill to complete - QTRY_VERIFY(!findItem(contentItem, "wrapper", 0)); // 0 shouldn't be visible - - if (doAdd) { - model.insertItem(0, "New Item", "New Item number"); - QTRY_COMPARE(gridview->count(), 31); - } else { - model.removeItem(0); - QTRY_COMPARE(gridview->count(), 29); - } - - // scroll back up and item 0 should be gone - gridview->setCurrentIndex(0); - qApp->processEvents(); - QTRY_COMPARE(gridview->currentIndex(), 0); - QTRY_COMPARE(gridview->contentY(), newTopContentY); - - name = findItem(contentItem, "textName", 0); - if (doAdd) - QCOMPARE(name->text(), QString("New Item")); - else - QCOMPARE(name->text(), QString("Item1")); - - // Confirm items positioned correctly - int itemCount = findItems(contentItem, "wrapper").count(); - for (int i = 0; i < model.count() && i < itemCount; ++i) { - QTRY_VERIFY(findItem(contentItem, "wrapper", i)); - QQuickItem *item = findItem(contentItem, "wrapper", i); - QTRY_VERIFY(item->x() == (i%3)*80); - QTRY_VERIFY(item->y() == (i/3)*60 + newTopContentY); - } - - delete canvas; -} - -void tst_QQuickGridView::addOrRemoveBeforeVisible_data() -{ - QTest::addColumn("doAdd"); - QTest::addColumn("newTopContentY"); - - QTest::newRow("add") << true << -60.0; - QTest::newRow("remove") << false << -60.0; -} - -void tst_QQuickGridView::clear() -{ - QQuickView *canvas = createView(); - - QaimModel model; - for (int i = 0; i < 30; i++) - model.addItem("Item" + QString::number(i), ""); - - QDeclarativeContext *ctxt = canvas->rootContext(); - ctxt->setContextProperty("testModel", &model); - ctxt->setContextProperty("testRightToLeft", QVariant(false)); - ctxt->setContextProperty("testTopToBottom", QVariant(false)); - - canvas->setSource(testFileUrl("gridview1.qml")); - canvas->show(); - qApp->processEvents(); - - QQuickGridView *gridview = findItem(canvas->rootObject(), "grid"); - QVERIFY(gridview != 0); - QQuickItem *contentItem = gridview->contentItem(); - QVERIFY(contentItem != 0); - QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false); - - model.clear(); - - QVERIFY(gridview->count() == 0); - QVERIFY(gridview->currentItem() == 0); - QVERIFY(gridview->contentY() == 0); - QVERIFY(gridview->currentIndex() == -1); - - // confirm sanity when adding an item to cleared list - model.addItem("New", "1"); - QTRY_COMPARE(gridview->count(), 1); - QVERIFY(gridview->currentItem() != 0); - QVERIFY(gridview->currentIndex() == 0); - - delete canvas; -} - -void tst_QQuickGridView::moved() -{ - QFETCH(qreal, contentY); - QFETCH(int, from); - QFETCH(int, to); - QFETCH(int, count); - QFETCH(qreal, itemsOffsetAfterMove); - - QQuickText *name; - QQuickText *number; - QScopedPointer canvas(createView()); - - QaimModel model; - for (int i = 0; i < 30; i++) - model.addItem("Item" + QString::number(i), ""); - - QDeclarativeContext *ctxt = canvas->rootContext(); - ctxt->setContextProperty("testModel", &model); - ctxt->setContextProperty("testRightToLeft", QVariant(false)); - ctxt->setContextProperty("testTopToBottom", QVariant(false)); - - canvas->setSource(testFileUrl("gridview1.qml")); - canvas->show(); - qApp->processEvents(); - - QQuickGridView *gridview = findItem(canvas->rootObject(), "grid"); - QTRY_VERIFY(gridview != 0); - QQuickItem *contentItem = gridview->contentItem(); - QTRY_VERIFY(contentItem != 0); - QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false); - - QQuickItem *currentItem = gridview->currentItem(); - QTRY_VERIFY(currentItem != 0); - - if (contentY != 0) { - gridview->setContentY(contentY); - QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false); - } - - model.moveItems(from, to, count); - QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false); - - // Confirm items positioned correctly and indexes correct - int firstVisibleIndex = qCeil(contentY / 60.0) * 3; - int itemCount = findItems(contentItem, "wrapper").count(); - for (int i = firstVisibleIndex; i < model.count() && i < itemCount; ++i) { - if (i >= firstVisibleIndex + 18) // index has moved out of view - continue; - QQuickItem *item = findItem(contentItem, "wrapper", i); - QVERIFY2(item, QTest::toString(QString("Item %1 not found").arg(i))); - - QTRY_COMPARE(item->x(), (i%3)*80.0); - QTRY_COMPARE(item->y(), (i/3)*60.0 + itemsOffsetAfterMove); - - name = findItem(contentItem, "textName", i); - QVERIFY(name != 0); - QTRY_COMPARE(name->text(), model.name(i)); - number = findItem(contentItem, "textNumber", i); - QVERIFY(number != 0); - QTRY_COMPARE(number->text(), model.number(i)); - - // current index should have been updated - if (item == currentItem) - QTRY_COMPARE(gridview->currentIndex(), i); - } -} - -void tst_QQuickGridView::moved_data() -{ - QTest::addColumn("contentY"); - QTest::addColumn("from"); - QTest::addColumn("to"); - QTest::addColumn("count"); - QTest::addColumn("itemsOffsetAfterMove"); - - // model starts with 30 items, each 80x60, in area 240x320 - // 18 items should be visible at a time - - // The first visible item should not move upwards and out of the view - // if items are moved/removed before it. - - - QTest::newRow("move 1 forwards, within visible items") - << 0.0 - << 1 << 8 << 1 - << 0.0; - - QTest::newRow("move 1 forwards, from non-visible -> visible") - << 120.0 // show 6-23 - << 1 << 23 << 1 - << 0.0; - - QTest::newRow("move 1 forwards, from non-visible -> visible (move first item)") - << 120.0 // // show 6-23 - << 0 << 6 << 1 - << 0.0; - - QTest::newRow("move 1 forwards, from visible -> non-visible") - << 0.0 - << 1 << 20 << 1 - << 0.0; - - QTest::newRow("move 1 forwards, from visible -> non-visible (move first item)") - << 0.0 - << 0 << 20 << 1 - << 0.0; - - - QTest::newRow("move 1 backwards, within visible items") - << 0.0 - << 10 << 5 << 1 - << 0.0; - - QTest::newRow("move 1 backwards, within visible items (to first index)") - << 0.0 - << 10 << 0 << 1 - << 0.0; - - QTest::newRow("move 1 backwards, from non-visible -> visible") - << 0.0 - << 28 << 8 << 1 - << 0.0; - - QTest::newRow("move 1 backwards, from non-visible -> visible (move last item)") - << 0.0 - << 29 << 14 << 1 - << 0.0; - - QTest::newRow("move 1 backwards, from visible -> non-visible") - << 120.0 // show 6-23 - << 7 << 1 << 1 - << 0.0; // only 1 item moved back, so items shift accordingly and first row doesn't move - - QTest::newRow("move 1 backwards, from visible -> non-visible (move first item)") - << 120.0 // show 6-23 - << 7 << 0 << 1 - << 0.0; // only 1 item moved back, so items shift accordingly and first row doesn't move - - - QTest::newRow("move multiple forwards, within visible items") - << 0.0 - << 0 << 5 << 3 - << 0.0; - - QTest::newRow("move multiple backwards, within visible items (move first item)") - << 0.0 - << 10 << 0 << 3 - << 0.0; - - QTest::newRow("move multiple forwards, before visible items") - << 120.0 // show 6-23 - << 3 << 4 << 3 // 3, 4, 5 move to after 6 - << 60.0; // row of 3,4,5 has moved down - - QTest::newRow("move multiple forwards, from non-visible -> visible") - << 120.0 // show 6-23 - << 1 << 6 << 3 - << 60.0; // 1st row (it's above visible area) disappears, 0 drops down 1 row, first visible item (6) stays where it is - - QTest::newRow("move multiple forwards, from non-visible -> visible (move first item)") - << 120.0 // show 6-23 - << 0 << 6 << 3 - << 60.0; // top row moved and shifted to below 3rd row, all items should shift down by 1 row - - QTest::newRow("move multiple forwards, mix of non-visible/visible") - << 120.0 - << 3 << 16 << 6 - << 60.0; // top two rows removed, third row is now the first visible - - QTest::newRow("move multiple forwards, to bottom of view") - << 0.0 - << 5 << 13 << 5 - << 0.0; - - QTest::newRow("move multiple forwards, to bottom of view, first row -> last") - << 0.0 - << 0 << 15 << 3 - << 0.0; - - QTest::newRow("move multiple forwards, to bottom of view, content y not 0") - << 120.0 - << 5+4 << 13+4 << 5 - << 0.0; - - QTest::newRow("move multiple forwards, from visible -> non-visible") - << 0.0 - << 1 << 16 << 3 - << 0.0; - - QTest::newRow("move multiple forwards, from visible -> non-visible (move first item)") - << 0.0 - << 0 << 16 << 3 - << 0.0; - - - QTest::newRow("move multiple backwards, within visible items") - << 0.0 - << 4 << 1 << 3 - << 0.0; - - QTest::newRow("move multiple backwards, from non-visible -> visible") - << 0.0 - << 20 << 4 << 3 - << 0.0; - - QTest::newRow("move multiple backwards, from non-visible -> visible (move last item)") - << 0.0 - << 27 << 10 << 3 - << 0.0; - - QTest::newRow("move multiple backwards, from visible -> non-visible") - << 120.0 // show 6-23 - << 16 << 1 << 3 - << -60.0; // to minimize movement, items are added above visible area, all items move up by 1 row - - QTest::newRow("move multiple backwards, from visible -> non-visible (move first item)") - << 120.0 // show 6-23 - << 16 << 0 << 3 - << -60.0; // 16,17,18 move to above item 0, all items move up by 1 row -} - -void tst_QQuickGridView::multipleChanges() -{ - QFETCH(int, startCount); - QFETCH(QList, changes); - QFETCH(int, newCount); - QFETCH(int, newCurrentIndex); - - QQuickView *canvas = createView(); - - QaimModel model; - for (int i = 0; i < startCount; i++) - model.addItem("Item" + QString::number(i), ""); - - QDeclarativeContext *ctxt = canvas->rootContext(); - ctxt->setContextProperty("testModel", &model); - ctxt->setContextProperty("testRightToLeft", QVariant(false)); - ctxt->setContextProperty("testTopToBottom", QVariant(false)); - - canvas->setSource(testFileUrl("gridview1.qml")); - canvas->show(); - qApp->processEvents(); - - QQuickGridView *gridview = findItem(canvas->rootObject(), "grid"); - QTRY_VERIFY(gridview != 0); - QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false); - - for (int i=0; i > items; - for (int j=changes[i].index; jpolishScheduled, false); - break; - case ListChange::Moved: - model.moveItems(changes[i].index, changes[i].to, changes[i].count); - QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false); - break; - case ListChange::SetCurrent: - gridview->setCurrentIndex(changes[i].index); - QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false); - break; - case ListChange::SetContentY: - gridview->setContentY(changes[i].pos); - QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false); - break; - } - } - - QTRY_COMPARE(gridview->count(), newCount); - QCOMPARE(gridview->count(), model.count()); - QTRY_COMPARE(gridview->currentIndex(), newCurrentIndex); - - QQuickText *name; - QQuickText *number; - QQuickItem *contentItem = gridview->contentItem(); - QTRY_VERIFY(contentItem != 0); - int itemCount = findItems(contentItem, "wrapper").count(); - for (int i=0; i < model.count() && i < itemCount; ++i) { - QQuickItem *item = findItem(contentItem, "wrapper", i); - QVERIFY2(item, QTest::toString(QString("Item %1 not found").arg(i))); - name = findItem(contentItem, "textName", i); - QVERIFY(name != 0); - QTRY_COMPARE(name->text(), model.name(i)); - number = findItem(contentItem, "textNumber", i); - QVERIFY(number != 0); - QTRY_COMPARE(number->text(), model.number(i)); - } - - delete canvas; -} - -void tst_QQuickGridView::multipleChanges_data() -{ - QTest::addColumn("startCount"); - QTest::addColumn >("changes"); - QTest::addColumn("newCount"); - QTest::addColumn("newCurrentIndex"); - - QList changes; - - for (int i=1; i<30; i++) - changes << ListChange::remove(0); - QTest::newRow("remove all but 1, first->last") << 30 << changes << 1 << 0; - - changes << ListChange::remove(0); - QTest::newRow("remove all") << 30 << changes << 0 << -1; - - changes.clear(); - changes << ListChange::setCurrent(29); - for (int i=29; i>0; i--) - changes << ListChange::remove(i); - QTest::newRow("remove last (current) -> first") << 30 << changes << 1 << 0; - - QTest::newRow("remove then insert at 0") << 10 << (QList() - << ListChange::remove(0, 1) - << ListChange::insert(0, 1) - ) << 10 << 1; - - QTest::newRow("remove then insert at non-zero index") << 10 << (QList() - << ListChange::setCurrent(2) - << ListChange::remove(2, 1) - << ListChange::insert(2, 1) - ) << 10 << 3; - - QTest::newRow("remove current then insert below it") << 10 << (QList() - << ListChange::setCurrent(1) - << ListChange::remove(1, 3) - << ListChange::insert(2, 2) - ) << 9 << 1; - - QTest::newRow("remove current index then move it down") << 10 << (QList() - << ListChange::setCurrent(2) - << ListChange::remove(1, 3) - << ListChange::move(1, 5, 1) - ) << 7 << 5; - - QTest::newRow("remove current index then move it up") << 10 << (QList() - << ListChange::setCurrent(5) - << ListChange::remove(4, 3) - << ListChange::move(4, 1, 1) - ) << 7 << 1; - - - QTest::newRow("insert multiple times") << 0 << (QList() - << ListChange::insert(0, 2) - << ListChange::insert(0, 4) - << ListChange::insert(0, 6) - ) << 12 << 10; - - QTest::newRow("insert multiple times with current index changes") << 0 << (QList() - << ListChange::insert(0, 2) - << ListChange::insert(0, 4) - << ListChange::insert(0, 6) - << ListChange::setCurrent(3) - << ListChange::insert(3, 2) - ) << 14 << 5; - - QTest::newRow("insert and remove all") << 0 << (QList() - << ListChange::insert(0, 30) - << ListChange::remove(0, 30) - ) << 0 << -1; - - QTest::newRow("insert and remove current") << 30 << (QList() - << ListChange::insert(1) - << ListChange::setCurrent(1) - << ListChange::remove(1) - ) << 30 << 1; - - QTest::newRow("insert before 0, then remove cross section of new and old items") << 10 << (QList() - << ListChange::insert(0, 10) - << ListChange::remove(5, 10) - ) << 10 << 5; - - QTest::newRow("insert multiple, then move new items to end") << 10 << (QList() - << ListChange::insert(0, 3) - << ListChange::move(0, 10, 3) - ) << 13 << 0; - - QTest::newRow("insert multiple, then move new and some old items to end") << 10 << (QList() - << ListChange::insert(0, 3) - << ListChange::move(0, 8, 5) - ) << 13 << 11; - - QTest::newRow("insert multiple at end, then move new and some old items to start") << 10 << (QList() - << ListChange::setCurrent(9) - << ListChange::insert(10, 3) - << ListChange::move(8, 0, 5) - ) << 13 << 1; - - - QTest::newRow("move back and forth to same index") << 10 << (QList() - << ListChange::setCurrent(1) - << ListChange::move(1, 2, 2) - << ListChange::move(2, 1, 2) - ) << 10 << 1; - - QTest::newRow("move forwards then back") << 10 << (QList() - << ListChange::setCurrent(2) - << ListChange::move(1, 2, 3) - << ListChange::move(3, 0, 5) - ) << 10 << 0; - - QTest::newRow("move current, then remove it") << 10 << (QList() - << ListChange::setCurrent(5) - << ListChange::move(5, 0, 1) - << ListChange::remove(0) - ) << 9 << 0; - - QTest::newRow("move current, then insert before it") << 10 << (QList() - << ListChange::setCurrent(5) - << ListChange::move(5, 0, 1) - << ListChange::insert(0) - ) << 11 << 1; - - QTest::newRow("move multiple, then remove them") << 10 << (QList() - << ListChange::setCurrent(1) - << ListChange::move(5, 1, 3) - << ListChange::remove(1, 3) - ) << 7 << 1; - - QTest::newRow("move multiple, then insert before them") << 10 << (QList() - << ListChange::setCurrent(5) - << ListChange::move(5, 1, 3) - << ListChange::insert(1, 5) - ) << 15 << 6; - - QTest::newRow("move multiple, then insert after them") << 10 << (QList() - << ListChange::setCurrent(3) - << ListChange::move(0, 1, 2) - << ListChange::insert(3, 5) - ) << 15 << 8; - - - QTest::newRow("clear current") << 0 << (QList() - << ListChange::insert(0, 5) - << ListChange::setCurrent(-1) - << ListChange::remove(0, 5) - << ListChange::insert(0, 5) - ) << 5 << -1; -} - - -void tst_QQuickGridView::swapWithFirstItem() -{ - // QTBUG_9697 - QQuickView *canvas = createView(); - - QaimModel model; - for (int i = 0; i < 30; i++) - model.addItem("Item" + QString::number(i), ""); - - QDeclarativeContext *ctxt = canvas->rootContext(); - ctxt->setContextProperty("testModel", &model); - ctxt->setContextProperty("testRightToLeft", QVariant(false)); - ctxt->setContextProperty("testTopToBottom", QVariant(false)); - - canvas->setSource(testFileUrl("gridview1.qml")); - canvas->show(); - qApp->processEvents(); - - QQuickGridView *gridview = findItem(canvas->rootObject(), "grid"); - QTRY_VERIFY(gridview != 0); - - // ensure content position is stable - gridview->setContentY(0); - model.moveItem(10, 0); - QTRY_VERIFY(gridview->contentY() == 0); - - delete canvas; -} - -void tst_QQuickGridView::currentIndex() -{ - QaimModel model; - for (int i = 0; i < 60; i++) - model.addItem("Item" + QString::number(i), QString::number(i)); - - QQuickView *canvas = new QQuickView(0); - canvas->setGeometry(0,0,240,320); - canvas->show(); - - QDeclarativeContext *ctxt = canvas->rootContext(); - ctxt->setContextProperty("testModel", &model); - - QString filename(testFile("gridview-initCurrent.qml")); - canvas->setSource(QUrl::fromLocalFile(filename)); - - qApp->processEvents(); - - QQuickGridView *gridview = findItem(canvas->rootObject(), "grid"); - QVERIFY(gridview != 0); - QTRY_VERIFY(!QQuickItemPrivate::get(gridview)->polishScheduled); - - QQuickItem *contentItem = gridview->contentItem(); - QVERIFY(contentItem != 0); - - // current item should be third item - QCOMPARE(gridview->currentIndex(), 35); - QCOMPARE(gridview->currentItem(), findItem(contentItem, "wrapper", 35)); - QCOMPARE(gridview->currentItem()->y(), gridview->highlightItem()->y()); - QCOMPARE(gridview->contentY(), 400.0); - - gridview->moveCurrentIndexRight(); - QCOMPARE(gridview->currentIndex(), 36); - gridview->moveCurrentIndexDown(); - QCOMPARE(gridview->currentIndex(), 39); - gridview->moveCurrentIndexUp(); - QCOMPARE(gridview->currentIndex(), 36); - gridview->moveCurrentIndexLeft(); - QCOMPARE(gridview->currentIndex(), 35); - - // wait until motion stops - QTRY_VERIFY(gridview->verticalVelocity() == 0.0); - - // no wrap - gridview->setCurrentIndex(0); - QCOMPARE(gridview->currentIndex(), 0); - // confirm that the velocity is updated - QTRY_VERIFY(gridview->verticalVelocity() != 0.0); - - gridview->moveCurrentIndexUp(); - QCOMPARE(gridview->currentIndex(), 0); - - gridview->moveCurrentIndexLeft(); - QCOMPARE(gridview->currentIndex(), 0); - - gridview->setCurrentIndex(model.count()-1); - QCOMPARE(gridview->currentIndex(), model.count()-1); - - gridview->moveCurrentIndexRight(); - QCOMPARE(gridview->currentIndex(), model.count()-1); - - gridview->moveCurrentIndexDown(); - QCOMPARE(gridview->currentIndex(), model.count()-1); - - // with wrap - gridview->setWrapEnabled(true); - - gridview->setCurrentIndex(0); - QCOMPARE(gridview->currentIndex(), 0); - - gridview->moveCurrentIndexLeft(); - QCOMPARE(gridview->currentIndex(), model.count()-1); - - qApp->processEvents(); - QTRY_COMPARE(gridview->contentY(), 880.0); - - gridview->moveCurrentIndexRight(); - QCOMPARE(gridview->currentIndex(), 0); - - QTRY_COMPARE(gridview->contentY(), 0.0); - - - // footer should become visible if it is out of view, and then current index moves to the first row - canvas->rootObject()->setProperty("showFooter", true); - QTRY_VERIFY(gridview->footerItem()); - gridview->setCurrentIndex(model.count()-3); - QTRY_VERIFY(gridview->footerItem()->y() > gridview->contentY() + gridview->height()); - gridview->setCurrentIndex(model.count()-2); - QTRY_COMPARE(gridview->contentY() + gridview->height(), (60.0 * model.count()/3) + gridview->footerItem()->height()); - canvas->rootObject()->setProperty("showFooter", false); - - // header should become visible if it is out of view, and then current index moves to the last row - canvas->rootObject()->setProperty("showHeader", true); - QTRY_VERIFY(gridview->headerItem()); - gridview->setCurrentIndex(3); - QTRY_VERIFY(gridview->headerItem()->y() + gridview->headerItem()->height() < gridview->contentY()); - gridview->setCurrentIndex(1); - QTRY_COMPARE(gridview->contentY(), -gridview->headerItem()->height()); - canvas->rootObject()->setProperty("showHeader", false); - - - // Test keys - canvas->requestActivateWindow(); - QTest::qWaitForWindowShown(canvas); - QTRY_VERIFY(qGuiApp->focusWindow() == canvas); - - gridview->setCurrentIndex(0); - - QTest::keyClick(canvas, Qt::Key_Down); - QCOMPARE(gridview->currentIndex(), 3); - - QTest::keyClick(canvas, Qt::Key_Up); - QCOMPARE(gridview->currentIndex(), 0); - - // hold down Key_Down - for (int i=0; i<(model.count() / 3) - 1; i++) { - QTest::simulateEvent(canvas, true, Qt::Key_Down, Qt::NoModifier, "", true); - QTRY_COMPARE(gridview->currentIndex(), i*3 + 3); - } - QTest::keyRelease(canvas, Qt::Key_Down); - QTRY_COMPARE(gridview->currentIndex(), 57); - QTRY_COMPARE(gridview->contentY(), 880.0); - - // hold down Key_Up - for (int i=(model.count() / 3) - 1; i > 0; i--) { - QTest::simulateEvent(canvas, true, Qt::Key_Up, Qt::NoModifier, "", true); - QTRY_COMPARE(gridview->currentIndex(), i*3 - 3); - } - QTest::keyRelease(canvas, Qt::Key_Up); - QTRY_COMPARE(gridview->currentIndex(), 0); - QTRY_COMPARE(gridview->contentY(), 0.0); - - - gridview->setFlow(QQuickGridView::TopToBottom); - - canvas->requestActivateWindow(); - QTest::qWaitForWindowShown(canvas); - QVERIFY(qGuiApp->focusWindow() == canvas); - qApp->processEvents(); - - QTest::keyClick(canvas, Qt::Key_Right); - QCOMPARE(gridview->currentIndex(), 5); - - QTest::keyClick(canvas, Qt::Key_Left); - QCOMPARE(gridview->currentIndex(), 0); - - QTest::keyClick(canvas, Qt::Key_Down); - QCOMPARE(gridview->currentIndex(), 1); - - QTest::keyClick(canvas, Qt::Key_Up); - QCOMPARE(gridview->currentIndex(), 0); - - // hold down Key_Right - for (int i=0; i<(model.count() / 5) - 1; i++) { - QTest::simulateEvent(canvas, true, Qt::Key_Right, Qt::NoModifier, "", true); - QTRY_COMPARE(gridview->currentIndex(), i*5 + 5); - } - - QTest::keyRelease(canvas, Qt::Key_Right); - QTRY_COMPARE(gridview->currentIndex(), 55); - QTRY_COMPARE(gridview->contentX(), 720.0); - - // hold down Key_Left - for (int i=(model.count() / 5) - 1; i > 0; i--) { - QTest::simulateEvent(canvas, true, Qt::Key_Left, Qt::NoModifier, "", true); - QTRY_COMPARE(gridview->currentIndex(), i*5 - 5); - } - QTest::keyRelease(canvas, Qt::Key_Left); - QTRY_COMPARE(gridview->currentIndex(), 0); - QTRY_COMPARE(gridview->contentX(), 0.0); - - - // turn off auto highlight - gridview->setHighlightFollowsCurrentItem(false); - QVERIFY(gridview->highlightFollowsCurrentItem() == false); - QVERIFY(gridview->highlightItem()); - qreal hlPosX = gridview->highlightItem()->x(); - qreal hlPosY = gridview->highlightItem()->y(); - - gridview->setCurrentIndex(5); - QTRY_COMPARE(gridview->highlightItem()->x(), hlPosX); - QTRY_COMPARE(gridview->highlightItem()->y(), hlPosY); - - // insert item before currentIndex - gridview->setCurrentIndex(28); - model.insertItem(0, "Foo", "1111"); - QTRY_COMPARE(canvas->rootObject()->property("current").toInt(), 29); - - // check removing highlight by setting currentIndex to -1; - gridview->setCurrentIndex(-1); - - QCOMPARE(gridview->currentIndex(), -1); - QVERIFY(!gridview->highlightItem()); - QVERIFY(!gridview->currentItem()); - - gridview->setHighlightFollowsCurrentItem(true); - - gridview->setFlow(QQuickGridView::LeftToRight); - gridview->setLayoutDirection(Qt::RightToLeft); - - canvas->requestActivateWindow(); - QTest::qWaitForWindowShown(canvas); - QTRY_VERIFY(qGuiApp->focusWindow() == canvas); - qApp->processEvents(); - - gridview->setCurrentIndex(35); - - QTest::keyClick(canvas, Qt::Key_Right); - QCOMPARE(gridview->currentIndex(), 34); - - QTest::keyClick(canvas, Qt::Key_Down); - QCOMPARE(gridview->currentIndex(), 37); - - QTest::keyClick(canvas, Qt::Key_Up); - QCOMPARE(gridview->currentIndex(), 34); - - QTest::keyClick(canvas, Qt::Key_Left); - QCOMPARE(gridview->currentIndex(), 35); - - - // turn off auto highlight - gridview->setHighlightFollowsCurrentItem(false); - QVERIFY(gridview->highlightFollowsCurrentItem() == false); - QVERIFY(gridview->highlightItem()); - hlPosX = gridview->highlightItem()->x(); - hlPosY = gridview->highlightItem()->y(); - - gridview->setCurrentIndex(5); - QTRY_COMPARE(gridview->highlightItem()->x(), hlPosX); - QTRY_COMPARE(gridview->highlightItem()->y(), hlPosY); - - // insert item before currentIndex - gridview->setCurrentIndex(28); - model.insertItem(0, "Foo", "1111"); - QTRY_COMPARE(canvas->rootObject()->property("current").toInt(), 29); - - // check removing highlight by setting currentIndex to -1; - gridview->setCurrentIndex(-1); - - QCOMPARE(gridview->currentIndex(), -1); - QVERIFY(!gridview->highlightItem()); - QVERIFY(!gridview->currentItem()); - - delete canvas; -} - -void tst_QQuickGridView::noCurrentIndex() -{ - QaimModel model; - for (int i = 0; i < 60; i++) - model.addItem("Item" + QString::number(i), QString::number(i)); - - QQuickView *canvas = new QQuickView(0); - canvas->setGeometry(0,0,240,320); - - QDeclarativeContext *ctxt = canvas->rootContext(); - ctxt->setContextProperty("testModel", &model); - - QString filename(testFile("gridview-noCurrent.qml")); - canvas->setSource(QUrl::fromLocalFile(filename)); - canvas->show(); - qApp->processEvents(); - - QQuickGridView *gridview = findItem(canvas->rootObject(), "grid"); - QVERIFY(gridview != 0); - QQuickItem *contentItem = gridview->contentItem(); - QVERIFY(contentItem != 0); - QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false); - - // current index should be -1 - QCOMPARE(gridview->currentIndex(), -1); - QVERIFY(!gridview->currentItem()); - QVERIFY(!gridview->highlightItem()); - QCOMPARE(gridview->contentY(), 0.0); - - gridview->setCurrentIndex(5); - QCOMPARE(gridview->currentIndex(), 5); - QVERIFY(gridview->currentItem()); - QVERIFY(gridview->highlightItem()); - - delete canvas; -} - -void tst_QQuickGridView::changeFlow() -{ - QQuickView *canvas = createView(); - - QaimModel model; - for (int i = 0; i < 30; i++) - model.addItem("Item" + QString::number(i), QString::number(i)); - - QDeclarativeContext *ctxt = canvas->rootContext(); - ctxt->setContextProperty("testModel", &model); - ctxt->setContextProperty("testRightToLeft", QVariant(false)); - ctxt->setContextProperty("testTopToBottom", QVariant(false)); - - canvas->setSource(testFileUrl("gridview1.qml")); - qApp->processEvents(); - - QQuickGridView *gridview = findItem(canvas->rootObject(), "grid"); - QTRY_VERIFY(gridview != 0); - - QQuickItem *contentItem = gridview->contentItem(); - QTRY_VERIFY(contentItem != 0); - - // Confirm items positioned correctly and indexes correct - int itemCount = findItems(contentItem, "wrapper").count(); - for (int i = 0; i < model.count() && i < itemCount; ++i) { - QQuickItem *item = findItem(contentItem, "wrapper", i); - if (!item) qWarning() << "Item" << i << "not found"; - QTRY_VERIFY(item); - QTRY_COMPARE(item->x(), qreal((i%3)*80)); - QTRY_COMPARE(item->y(), qreal((i/3)*60)); - QQuickText *name = findItem(contentItem, "textName", i); - QTRY_VERIFY(name != 0); - QTRY_COMPARE(name->text(), model.name(i)); - QQuickText *number = findItem(contentItem, "textNumber", i); - QTRY_VERIFY(number != 0); - QTRY_COMPARE(number->text(), model.number(i)); - } - - ctxt->setContextProperty("testTopToBottom", QVariant(true)); - - // Confirm items positioned correctly and indexes correct - itemCount = findItems(contentItem, "wrapper").count(); - for (int i = 0; i < model.count() && i < itemCount; ++i) { - QQuickItem *item = findItem(contentItem, "wrapper", i); - if (!item) qWarning() << "Item" << i << "not found"; - QTRY_VERIFY(item); - QTRY_COMPARE(item->x(), qreal((i/5)*80)); - QTRY_COMPARE(item->y(), qreal((i%5)*60)); - QQuickText *name = findItem(contentItem, "textName", i); - QTRY_VERIFY(name != 0); - QTRY_COMPARE(name->text(), model.name(i)); - QQuickText *number = findItem(contentItem, "textNumber", i); - QTRY_VERIFY(number != 0); - QTRY_COMPARE(number->text(), model.number(i)); - } - - ctxt->setContextProperty("testRightToLeft", QVariant(true)); - - // Confirm items positioned correctly and indexes correct - itemCount = findItems(contentItem, "wrapper").count(); - for (int i = 0; i < model.count() && i < itemCount; ++i) { - QQuickItem *item = findItem(contentItem, "wrapper", i); - if (!item) qWarning() << "Item" << i << "not found"; - QTRY_VERIFY(item); - QTRY_COMPARE(item->x(), qreal(-(i/5)*80 - item->width())); - QTRY_COMPARE(item->y(), qreal((i%5)*60)); - QQuickText *name = findItem(contentItem, "textName", i); - QTRY_VERIFY(name != 0); - QTRY_COMPARE(name->text(), model.name(i)); - QQuickText *number = findItem(contentItem, "textNumber", i); - QTRY_VERIFY(number != 0); - QTRY_COMPARE(number->text(), model.number(i)); - } - gridview->setContentX(100); - QTRY_COMPARE(gridview->contentX(), 100.); - ctxt->setContextProperty("testTopToBottom", QVariant(false)); - QTRY_COMPARE(gridview->contentX(), 0.); - - // Confirm items positioned correctly and indexes correct - itemCount = findItems(contentItem, "wrapper").count(); - for (int i = 0; i < model.count() && i < itemCount; ++i) { - QQuickItem *item = findItem(contentItem, "wrapper", i); - if (!item) qWarning() << "Item" << i << "not found"; - QTRY_VERIFY(item); - QTRY_COMPARE(item->x(), qreal(240 - (i%3+1)*80)); - QTRY_COMPARE(item->y(), qreal((i/3)*60)); - QQuickText *name = findItem(contentItem, "textName", i); - QTRY_VERIFY(name != 0); - QTRY_COMPARE(name->text(), model.name(i)); - QQuickText *number = findItem(contentItem, "textNumber", i); - QTRY_VERIFY(number != 0); - QTRY_COMPARE(number->text(), model.number(i)); - } - - delete canvas; -} - -void tst_QQuickGridView::defaultValues() -{ - QDeclarativeEngine engine; - QDeclarativeComponent c(&engine, testFileUrl("gridview3.qml")); - QQuickGridView *obj = qobject_cast(c.create()); - - QTRY_VERIFY(obj != 0); - QTRY_VERIFY(obj->model() == QVariant()); - QTRY_VERIFY(obj->delegate() == 0); - QTRY_COMPARE(obj->currentIndex(), -1); - QTRY_VERIFY(obj->currentItem() == 0); - QTRY_COMPARE(obj->count(), 0); - QTRY_VERIFY(obj->highlight() == 0); - QTRY_VERIFY(obj->highlightItem() == 0); - QTRY_COMPARE(obj->highlightFollowsCurrentItem(), true); - QTRY_VERIFY(obj->flow() == 0); - QTRY_COMPARE(obj->isWrapEnabled(), false); - QTRY_COMPARE(obj->cacheBuffer(), 0); - QTRY_COMPARE(obj->cellWidth(), qreal(100)); //### Should 100 be the default? - QTRY_COMPARE(obj->cellHeight(), qreal(100)); - delete obj; -} - -void tst_QQuickGridView::properties() -{ - QDeclarativeEngine engine; - QDeclarativeComponent c(&engine, testFileUrl("gridview2.qml")); - QQuickGridView *obj = qobject_cast(c.create()); - - QTRY_VERIFY(obj != 0); - QTRY_VERIFY(obj->model() != QVariant()); - QTRY_VERIFY(obj->delegate() != 0); - QTRY_COMPARE(obj->currentIndex(), 0); - QTRY_VERIFY(obj->currentItem() != 0); - QTRY_COMPARE(obj->count(), 4); - QTRY_VERIFY(obj->highlight() != 0); - QTRY_VERIFY(obj->highlightItem() != 0); - QTRY_COMPARE(obj->highlightFollowsCurrentItem(), false); - QTRY_VERIFY(obj->flow() == 0); - QTRY_COMPARE(obj->isWrapEnabled(), true); - QTRY_COMPARE(obj->cacheBuffer(), 200); - QTRY_COMPARE(obj->cellWidth(), qreal(100)); - QTRY_COMPARE(obj->cellHeight(), qreal(100)); - delete obj; -} - -void tst_QQuickGridView::propertyChanges() -{ - QQuickView *canvas = createView(); - QTRY_VERIFY(canvas); - canvas->setSource(testFileUrl("propertychangestest.qml")); - - QQuickGridView *gridView = canvas->rootObject()->findChild("gridView"); - QTRY_VERIFY(gridView); - - QSignalSpy keyNavigationWrapsSpy(gridView, SIGNAL(keyNavigationWrapsChanged())); - QSignalSpy cacheBufferSpy(gridView, SIGNAL(cacheBufferChanged())); - QSignalSpy layoutSpy(gridView, SIGNAL(layoutDirectionChanged())); - QSignalSpy flowSpy(gridView, SIGNAL(flowChanged())); - - QTRY_COMPARE(gridView->isWrapEnabled(), true); - QTRY_COMPARE(gridView->cacheBuffer(), 10); - QTRY_COMPARE(gridView->flow(), QQuickGridView::LeftToRight); - - gridView->setWrapEnabled(false); - gridView->setCacheBuffer(3); - gridView->setFlow(QQuickGridView::TopToBottom); - - QTRY_COMPARE(gridView->isWrapEnabled(), false); - QTRY_COMPARE(gridView->cacheBuffer(), 3); - QTRY_COMPARE(gridView->flow(), QQuickGridView::TopToBottom); - - QTRY_COMPARE(keyNavigationWrapsSpy.count(),1); - QTRY_COMPARE(cacheBufferSpy.count(),1); - QTRY_COMPARE(flowSpy.count(),1); - - gridView->setWrapEnabled(false); - gridView->setCacheBuffer(3); - gridView->setFlow(QQuickGridView::TopToBottom); - - QTRY_COMPARE(keyNavigationWrapsSpy.count(),1); - QTRY_COMPARE(cacheBufferSpy.count(),1); - QTRY_COMPARE(flowSpy.count(),1); - - gridView->setFlow(QQuickGridView::LeftToRight); - QTRY_COMPARE(gridView->flow(), QQuickGridView::LeftToRight); - - gridView->setWrapEnabled(true); - gridView->setCacheBuffer(5); - gridView->setLayoutDirection(Qt::RightToLeft); - - QTRY_COMPARE(gridView->isWrapEnabled(), true); - QTRY_COMPARE(gridView->cacheBuffer(), 5); - QTRY_COMPARE(gridView->layoutDirection(), Qt::RightToLeft); - - QTRY_COMPARE(keyNavigationWrapsSpy.count(),2); - QTRY_COMPARE(cacheBufferSpy.count(),2); - QTRY_COMPARE(layoutSpy.count(),1); - QTRY_COMPARE(flowSpy.count(),2); - - gridView->setWrapEnabled(true); - gridView->setCacheBuffer(5); - gridView->setLayoutDirection(Qt::RightToLeft); - - QTRY_COMPARE(keyNavigationWrapsSpy.count(),2); - QTRY_COMPARE(cacheBufferSpy.count(),2); - QTRY_COMPARE(layoutSpy.count(),1); - QTRY_COMPARE(flowSpy.count(),2); - - gridView->setFlow(QQuickGridView::TopToBottom); - QTRY_COMPARE(gridView->flow(), QQuickGridView::TopToBottom); - QTRY_COMPARE(flowSpy.count(),3); - - gridView->setFlow(QQuickGridView::TopToBottom); - QTRY_COMPARE(flowSpy.count(),3); - - delete canvas; -} - -void tst_QQuickGridView::componentChanges() -{ - QQuickView *canvas = createView(); - QTRY_VERIFY(canvas); - canvas->setSource(testFileUrl("propertychangestest.qml")); - - QQuickGridView *gridView = canvas->rootObject()->findChild("gridView"); - QTRY_VERIFY(gridView); - - QDeclarativeComponent component(canvas->engine()); - component.setData("import QtQuick 1.0; Rectangle { color: \"blue\"; }", QUrl::fromLocalFile("")); - - QDeclarativeComponent delegateComponent(canvas->engine()); - delegateComponent.setData("import QtQuick 1.0; Text { text: 'Name: ' + name }", QUrl::fromLocalFile("")); - - QSignalSpy highlightSpy(gridView, SIGNAL(highlightChanged())); - QSignalSpy delegateSpy(gridView, SIGNAL(delegateChanged())); - QSignalSpy headerSpy(gridView, SIGNAL(headerChanged())); - QSignalSpy footerSpy(gridView, SIGNAL(footerChanged())); - - gridView->setHighlight(&component); - gridView->setDelegate(&delegateComponent); - gridView->setHeader(&component); - gridView->setFooter(&component); - - QTRY_COMPARE(gridView->highlight(), &component); - QTRY_COMPARE(gridView->delegate(), &delegateComponent); - QTRY_COMPARE(gridView->header(), &component); - QTRY_COMPARE(gridView->footer(), &component); - - QTRY_COMPARE(highlightSpy.count(),1); - QTRY_COMPARE(delegateSpy.count(),1); - QTRY_COMPARE(headerSpy.count(),1); - QTRY_COMPARE(footerSpy.count(),1); - - gridView->setHighlight(&component); - gridView->setDelegate(&delegateComponent); - gridView->setHeader(&component); - gridView->setFooter(&component); - - QTRY_COMPARE(highlightSpy.count(),1); - QTRY_COMPARE(delegateSpy.count(),1); - QTRY_COMPARE(headerSpy.count(),1); - QTRY_COMPARE(footerSpy.count(),1); - - delete canvas; -} - -void tst_QQuickGridView::modelChanges() -{ - QQuickView *canvas = createView(); - QTRY_VERIFY(canvas); - canvas->setSource(testFileUrl("propertychangestest.qml")); - - QQuickGridView *gridView = canvas->rootObject()->findChild("gridView"); - QTRY_VERIFY(gridView); - - QDeclarativeListModel *alternateModel = canvas->rootObject()->findChild("alternateModel"); - QTRY_VERIFY(alternateModel); - QVariant modelVariant = QVariant::fromValue(alternateModel); - QSignalSpy modelSpy(gridView, SIGNAL(modelChanged())); - - gridView->setModel(modelVariant); - QTRY_COMPARE(gridView->model(), modelVariant); - QTRY_COMPARE(modelSpy.count(),1); - - gridView->setModel(modelVariant); - QTRY_COMPARE(modelSpy.count(),1); - - gridView->setModel(QVariant()); - QTRY_COMPARE(modelSpy.count(),2); - delete canvas; -} - -void tst_QQuickGridView::positionViewAtIndex() -{ - QQuickView *canvas = createView(); - - QaimModel model; - for (int i = 0; i < 40; i++) - model.addItem("Item" + QString::number(i), ""); - - QDeclarativeContext *ctxt = canvas->rootContext(); - ctxt->setContextProperty("testModel", &model); - ctxt->setContextProperty("testRightToLeft", QVariant(false)); - ctxt->setContextProperty("testTopToBottom", QVariant(false)); - - canvas->setSource(testFileUrl("gridview1.qml")); - canvas->show(); - qApp->processEvents(); - - QQuickGridView *gridview = findItem(canvas->rootObject(), "grid"); - QTRY_VERIFY(gridview != 0); - QQuickItem *contentItem = gridview->contentItem(); - QTRY_VERIFY(contentItem != 0); - QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false); - - // Confirm items positioned correctly - int itemCount = findItems(contentItem, "wrapper").count(); - for (int i = 0; i < model.count() && i < itemCount-1; ++i) { - QQuickItem *item = findItem(contentItem, "wrapper", i); - if (!item) qWarning() << "Item" << i << "not found"; - QTRY_VERIFY(item); - QTRY_COMPARE(item->x(), (i%3)*80.); - QTRY_COMPARE(item->y(), (i/3)*60.); - } - - // Position on a currently visible item - gridview->positionViewAtIndex(4, QQuickGridView::Beginning); - QTRY_COMPARE(gridview->indexAt(120, 90), 4); - QTRY_COMPARE(gridview->contentY(), 60.); - - // Confirm items positioned correctly - itemCount = findItems(contentItem, "wrapper").count(); - for (int i = 3; i < model.count() && i < itemCount-3-1; ++i) { - QQuickItem *item = findItem(contentItem, "wrapper", i); - if (!item) qWarning() << "Item" << i << "not found"; - QTRY_VERIFY(item); - QTRY_COMPARE(item->x(), (i%3)*80.); - QTRY_COMPARE(item->y(), (i/3)*60.); - } - - // Position on an item beyond the visible items - gridview->positionViewAtIndex(21, QQuickGridView::Beginning); - QTRY_COMPARE(gridview->indexAt(40, 450), 21); - QTRY_COMPARE(gridview->contentY(), 420.); - - // Confirm items positioned correctly - itemCount = findItems(contentItem, "wrapper").count(); - for (int i = 22; i < model.count() && i < itemCount-22-1; ++i) { - QQuickItem *item = findItem(contentItem, "wrapper", i); - if (!item) qWarning() << "Item" << i << "not found"; - QTRY_VERIFY(item); - QTRY_COMPARE(item->x(), (i%3)*80.); - QTRY_COMPARE(item->y(), (i/3)*60.); - } - - // Position on an item that would leave empty space if positioned at the top - gridview->positionViewAtIndex(31, QQuickGridView::Beginning); - QTRY_COMPARE(gridview->indexAt(120, 630), 31); - QTRY_COMPARE(gridview->contentY(), 520.); - - // Confirm items positioned correctly - itemCount = findItems(contentItem, "wrapper").count(); - for (int i = 24; i < model.count() && i < itemCount-24-1; ++i) { - QQuickItem *item = findItem(contentItem, "wrapper", i); - if (!item) qWarning() << "Item" << i << "not found"; - QTRY_VERIFY(item); - QTRY_COMPARE(item->x(), (i%3)*80.); - QTRY_COMPARE(item->y(), (i/3)*60.); - } - - // Position at the beginning again - gridview->positionViewAtIndex(0, QQuickGridView::Beginning); - QTRY_COMPARE(gridview->indexAt(0, 0), 0); - QTRY_COMPARE(gridview->indexAt(40, 30), 0); - QTRY_COMPARE(gridview->indexAt(80, 60), 4); - QTRY_COMPARE(gridview->contentY(), 0.); - - // Confirm items positioned correctly - itemCount = findItems(contentItem, "wrapper").count(); - for (int i = 0; i < model.count() && i < itemCount-1; ++i) { - QQuickItem *item = findItem(contentItem, "wrapper", i); - if (!item) qWarning() << "Item" << i << "not found"; - QTRY_VERIFY(item); - QTRY_COMPARE(item->x(), (i%3)*80.); - QTRY_COMPARE(item->y(), (i/3)*60.); - } - - // Position at End - gridview->positionViewAtIndex(30, QQuickGridView::End); - QTRY_COMPARE(gridview->contentY(), 340.); - - // Position in Center - gridview->positionViewAtIndex(15, QQuickGridView::Center); - QTRY_COMPARE(gridview->contentY(), 170.); - - // Ensure at least partially visible - gridview->positionViewAtIndex(15, QQuickGridView::Visible); - QTRY_COMPARE(gridview->contentY(), 170.); - - gridview->setContentY(302); - gridview->positionViewAtIndex(15, QQuickGridView::Visible); - QTRY_COMPARE(gridview->contentY(), 302.); - - gridview->setContentY(360); - gridview->positionViewAtIndex(15, QQuickGridView::Visible); - QTRY_COMPARE(gridview->contentY(), 300.); - - gridview->setContentY(60); - gridview->positionViewAtIndex(20, QQuickGridView::Visible); - QTRY_COMPARE(gridview->contentY(), 60.); - - gridview->setContentY(20); - gridview->positionViewAtIndex(20, QQuickGridView::Visible); - QTRY_COMPARE(gridview->contentY(), 100.); - - // Ensure completely visible - gridview->setContentY(120); - gridview->positionViewAtIndex(20, QQuickGridView::Contain); - QTRY_COMPARE(gridview->contentY(), 120.); - - gridview->setContentY(302); - gridview->positionViewAtIndex(15, QQuickGridView::Contain); - QTRY_COMPARE(gridview->contentY(), 300.); - - gridview->setContentY(60); - gridview->positionViewAtIndex(20, QQuickGridView::Contain); - QTRY_COMPARE(gridview->contentY(), 100.); - - // Test for Top To Bottom layout - ctxt->setContextProperty("testTopToBottom", QVariant(true)); - - // Confirm items positioned correctly - itemCount = findItems(contentItem, "wrapper").count(); - for (int i = 0; i < model.count() && i < itemCount-1; ++i) { - QQuickItem *item = findItem(contentItem, "wrapper", i); - if (!item) qWarning() << "Item" << i << "not found"; - QTRY_VERIFY(item); - QTRY_COMPARE(item->x(), (i/5)*80.); - QTRY_COMPARE(item->y(), (i%5)*60.); - } - - // Position at End - gridview->positionViewAtIndex(30, QQuickGridView::End); - QTRY_COMPARE(gridview->contentX(), 320.); - QTRY_COMPARE(gridview->contentY(), 0.); - - // Position in Center - gridview->positionViewAtIndex(15, QQuickGridView::Center); - QTRY_COMPARE(gridview->contentX(), 160.); - - // Ensure at least partially visible - gridview->positionViewAtIndex(15, QQuickGridView::Visible); - QTRY_COMPARE(gridview->contentX(), 160.); - - gridview->setContentX(170); - gridview->positionViewAtIndex(25, QQuickGridView::Visible); - QTRY_COMPARE(gridview->contentX(), 170.); - - gridview->positionViewAtIndex(30, QQuickGridView::Visible); - QTRY_COMPARE(gridview->contentX(), 320.); - - gridview->setContentX(170); - gridview->positionViewAtIndex(25, QQuickGridView::Contain); - QTRY_COMPARE(gridview->contentX(), 240.); - - // positionViewAtBeginning - gridview->positionViewAtBeginning(); - QTRY_COMPARE(gridview->contentX(), 0.); - - gridview->setContentX(80); - canvas->rootObject()->setProperty("showHeader", true); - gridview->positionViewAtBeginning(); - QTRY_COMPARE(gridview->contentX(), -30.); - - // positionViewAtEnd - gridview->positionViewAtEnd(); - QTRY_COMPARE(gridview->contentX(), 400.); // 8*80 - 240 (8 columns) - - gridview->setContentX(80); - canvas->rootObject()->setProperty("showFooter", true); - gridview->positionViewAtEnd(); - QTRY_COMPARE(gridview->contentX(), 430.); - - // set current item to outside visible view, position at beginning - // and ensure highlight moves to current item - gridview->setCurrentIndex(6); - gridview->positionViewAtBeginning(); - QTRY_COMPARE(gridview->contentX(), -30.); - QVERIFY(gridview->highlightItem()); - QCOMPARE(gridview->highlightItem()->x(), 80.); - - delete canvas; -} - -void tst_QQuickGridView::snapping() -{ - QQuickView *canvas = createView(); - - QaimModel model; - for (int i = 0; i < 40; i++) - model.addItem("Item" + QString::number(i), ""); - - QDeclarativeContext *ctxt = canvas->rootContext(); - ctxt->setContextProperty("testModel", &model); - ctxt->setContextProperty("testTopToBottom", QVariant(false)); - ctxt->setContextProperty("testRightToLeft", QVariant(false)); - - canvas->setSource(testFileUrl("gridview1.qml")); - qApp->processEvents(); - - QQuickGridView *gridview = findItem(canvas->rootObject(), "grid"); - QTRY_VERIFY(gridview != 0); - - gridview->setHeight(220); - QCOMPARE(gridview->height(), 220.); - - gridview->positionViewAtIndex(12, QQuickGridView::Visible); - QCOMPARE(gridview->contentY(), 80.); - - gridview->setContentY(0); - QCOMPARE(gridview->contentY(), 0.); - - gridview->setSnapMode(QQuickGridView::SnapToRow); - QCOMPARE(gridview->snapMode(), QQuickGridView::SnapToRow); - - gridview->positionViewAtIndex(12, QQuickGridView::Visible); - QCOMPARE(gridview->contentY(), 60.); - - gridview->positionViewAtIndex(15, QQuickGridView::End); - QCOMPARE(gridview->contentY(), 120.); - - delete canvas; - -} - -void tst_QQuickGridView::mirroring() -{ - QQuickView *canvasA = createView(); - canvasA->setSource(testFileUrl("mirroring.qml")); - QQuickGridView *gridviewA = findItem(canvasA->rootObject(), "view"); - QTRY_VERIFY(gridviewA != 0); - - QQuickView *canvasB = createView(); - canvasB->setSource(testFileUrl("mirroring.qml")); - QQuickGridView *gridviewB = findItem(canvasB->rootObject(), "view"); - QTRY_VERIFY(gridviewA != 0); - qApp->processEvents(); - - QList objectNames; - objectNames << "item1" << "item2"; // << "item3" - - gridviewA->setProperty("layoutDirection", Qt::LeftToRight); - gridviewB->setProperty("layoutDirection", Qt::RightToLeft); - QCOMPARE(gridviewA->layoutDirection(), gridviewA->effectiveLayoutDirection()); - - // LTR != RTL - foreach (const QString objectName, objectNames) - QVERIFY(findItem(gridviewA, objectName)->x() != findItem(gridviewB, objectName)->x()); - - gridviewA->setProperty("layoutDirection", Qt::LeftToRight); - gridviewB->setProperty("layoutDirection", Qt::LeftToRight); - - // LTR == LTR - foreach (const QString objectName, objectNames) - QCOMPARE(findItem(gridviewA, objectName)->x(), findItem(gridviewB, objectName)->x()); - - QVERIFY(gridviewB->layoutDirection() == gridviewB->effectiveLayoutDirection()); - QQuickItemPrivate::get(gridviewB)->setLayoutMirror(true); - QVERIFY(gridviewB->layoutDirection() != gridviewB->effectiveLayoutDirection()); - - // LTR != LTR+mirror - foreach (const QString objectName, objectNames) - QVERIFY(findItem(gridviewA, objectName)->x() != findItem(gridviewB, objectName)->x()); - - gridviewA->setProperty("layoutDirection", Qt::RightToLeft); - - // RTL == LTR+mirror - foreach (const QString objectName, objectNames) - QCOMPARE(findItem(gridviewA, objectName)->x(), findItem(gridviewB, objectName)->x()); - - gridviewB->setProperty("layoutDirection", Qt::RightToLeft); - - // RTL != RTL+mirror - foreach (const QString objectName, objectNames) - QVERIFY(findItem(gridviewA, objectName)->x() != findItem(gridviewB, objectName)->x()); - - gridviewA->setProperty("layoutDirection", Qt::LeftToRight); - - // LTR == RTL+mirror - foreach (const QString objectName, objectNames) - QCOMPARE(findItem(gridviewA, objectName)->x(), findItem(gridviewB, objectName)->x()); - - delete canvasA; - delete canvasB; -} - -void tst_QQuickGridView::positionViewAtIndex_rightToLeft() -{ - QQuickView *canvas = createView(); - - QaimModel model; - for (int i = 0; i < 40; i++) - model.addItem("Item" + QString::number(i), ""); - - QDeclarativeContext *ctxt = canvas->rootContext(); - ctxt->setContextProperty("testModel", &model); - ctxt->setContextProperty("testTopToBottom", QVariant(true)); - ctxt->setContextProperty("testRightToLeft", QVariant(true)); - - canvas->setSource(testFileUrl("gridview1.qml")); - qApp->processEvents(); - - QQuickGridView *gridview = findItem(canvas->rootObject(), "grid"); - QTRY_VERIFY(gridview != 0); - - QQuickItem *contentItem = gridview->contentItem(); - QTRY_VERIFY(contentItem != 0); - - // Confirm items positioned correctly - int itemCount = findItems(contentItem, "wrapper").count(); - for (int i = 0; i < model.count() && i < itemCount-1; ++i) { - QQuickItem *item = findItem(contentItem, "wrapper", i); - if (!item) qWarning() << "Item" << i << "not found"; - QTRY_VERIFY(item); - QTRY_COMPARE(item->x(), qreal(-(i/5)*80-item->width())); - QTRY_COMPARE(item->y(), qreal((i%5)*60)); - } - - // Position on a currently visible item - gridview->positionViewAtIndex(6, QQuickGridView::Beginning); - QTRY_COMPARE(gridview->contentX(), -320.); - - // Confirm items positioned correctly - itemCount = findItems(contentItem, "wrapper").count(); - for (int i = 3; i < model.count() && i < itemCount-3-1; ++i) { - QQuickItem *item = findItem(contentItem, "wrapper", i); - if (!item) qWarning() << "Item" << i << "not found"; - QTRY_VERIFY(item); - QTRY_COMPARE(item->x(), qreal(-(i/5)*80-item->width())); - QTRY_COMPARE(item->y(), qreal((i%5)*60)); - } - - // Position on an item beyond the visible items - gridview->positionViewAtIndex(21, QQuickGridView::Beginning); - QTRY_COMPARE(gridview->contentX(), -560.); - - // Confirm items positioned correctly - itemCount = findItems(contentItem, "wrapper").count(); - for (int i = 22; i < model.count() && i < itemCount-22-1; ++i) { - QQuickItem *item = findItem(contentItem, "wrapper", i); - if (!item) qWarning() << "Item" << i << "not found"; - QTRY_VERIFY(item); - QTRY_COMPARE(item->x(), qreal(-(i/5)*80-item->width())); - QTRY_COMPARE(item->y(), qreal((i%5)*60)); - } - - // Position on an item that would leave empty space if positioned at the top - gridview->positionViewAtIndex(31, QQuickGridView::Beginning); - QTRY_COMPARE(gridview->contentX(), -640.); - - // Confirm items positioned correctly - itemCount = findItems(contentItem, "wrapper").count(); - for (int i = 24; i < model.count() && i < itemCount-24-1; ++i) { - QQuickItem *item = findItem(contentItem, "wrapper", i); - if (!item) qWarning() << "Item" << i << "not found"; - QTRY_VERIFY(item); - QTRY_COMPARE(item->x(), qreal(-(i/5)*80-item->width())); - QTRY_COMPARE(item->y(), qreal((i%5)*60)); - } - - // Position at the beginning again - gridview->positionViewAtIndex(0, QQuickGridView::Beginning); - QTRY_COMPARE(gridview->contentX(), -240.); - - // Confirm items positioned correctly - itemCount = findItems(contentItem, "wrapper").count(); - for (int i = 0; i < model.count() && i < itemCount-1; ++i) { - QQuickItem *item = findItem(contentItem, "wrapper", i); - if (!item) qWarning() << "Item" << i << "not found"; - QTRY_VERIFY(item); - QTRY_COMPARE(item->x(), qreal(-(i/5)*80-item->width())); - QTRY_COMPARE(item->y(), qreal((i%5)*60)); - } - - // Position at End - gridview->positionViewAtIndex(30, QQuickGridView::End); - QTRY_COMPARE(gridview->contentX(), -560.); - - // Position in Center - gridview->positionViewAtIndex(15, QQuickGridView::Center); - QTRY_COMPARE(gridview->contentX(), -400.); - - // Ensure at least partially visible - gridview->positionViewAtIndex(15, QQuickGridView::Visible); - QTRY_COMPARE(gridview->contentX(), -400.); - - gridview->setContentX(-555.); - gridview->positionViewAtIndex(15, QQuickGridView::Visible); - QTRY_COMPARE(gridview->contentX(), -555.); - - gridview->setContentX(-239); - gridview->positionViewAtIndex(15, QQuickGridView::Visible); - QTRY_COMPARE(gridview->contentX(), -320.); - - gridview->setContentX(-239); - gridview->positionViewAtIndex(20, QQuickGridView::Visible); - QTRY_COMPARE(gridview->contentX(), -400.); - - gridview->setContentX(-640); - gridview->positionViewAtIndex(20, QQuickGridView::Visible); - QTRY_COMPARE(gridview->contentX(), -560.); - - // Ensure completely visible - gridview->setContentX(-400); - gridview->positionViewAtIndex(20, QQuickGridView::Contain); - QTRY_COMPARE(gridview->contentX(), -400.); - - gridview->setContentX(-315); - gridview->positionViewAtIndex(15, QQuickGridView::Contain); - QTRY_COMPARE(gridview->contentX(), -320.); - - gridview->setContentX(-640); - gridview->positionViewAtIndex(20, QQuickGridView::Contain); - QTRY_COMPARE(gridview->contentX(), -560.); - - delete canvas; -} - -void tst_QQuickGridView::resetModel() -{ - QQuickView *canvas = createView(); - - QStringList strings; - strings << "one" << "two" << "three"; - QStringListModel model(strings); - - QDeclarativeContext *ctxt = canvas->rootContext(); - ctxt->setContextProperty("testModel", &model); - - canvas->setSource(testFileUrl("displaygrid.qml")); - canvas->show(); - qApp->processEvents(); - - QQuickGridView *gridview = findItem(canvas->rootObject(), "grid"); - QTRY_VERIFY(gridview != 0); - QQuickItem *contentItem = gridview->contentItem(); - QTRY_VERIFY(contentItem != 0); - QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false); - - QTRY_COMPARE(gridview->count(), model.rowCount()); - - for (int i = 0; i < model.rowCount(); ++i) { - QQuickText *display = findItem(contentItem, "displayText", i); - QTRY_VERIFY(display != 0); - QTRY_COMPARE(display->text(), strings.at(i)); - } - - strings.clear(); - strings << "four" << "five" << "six" << "seven"; - model.setStringList(strings); - - QTRY_COMPARE(gridview->count(), model.rowCount()); - - for (int i = 0; i < model.rowCount(); ++i) { - QQuickText *display = findItem(contentItem, "displayText", i); - QTRY_VERIFY(display != 0); - QTRY_COMPARE(display->text(), strings.at(i)); - } - - delete canvas; -} - -void tst_QQuickGridView::enforceRange() -{ - QQuickView *canvas = createView(); - - QaimModel model; - for (int i = 0; i < 30; i++) - model.addItem("Item" + QString::number(i), ""); - - QDeclarativeContext *ctxt = canvas->rootContext(); - ctxt->setContextProperty("testModel", &model); - ctxt->setContextProperty("testRightToLeft", QVariant(false)); - ctxt->setContextProperty("testTopToBottom", QVariant(false)); - - canvas->setSource(testFileUrl("gridview-enforcerange.qml")); - canvas->show(); - qApp->processEvents(); - QVERIFY(canvas->rootObject() != 0); - - QQuickGridView *gridview = findItem(canvas->rootObject(), "grid"); - QTRY_VERIFY(gridview != 0); - - QTRY_COMPARE(gridview->preferredHighlightBegin(), 100.0); - QTRY_COMPARE(gridview->preferredHighlightEnd(), 100.0); - QTRY_COMPARE(gridview->highlightRangeMode(), QQuickGridView::StrictlyEnforceRange); - QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false); - - QQuickItem *contentItem = gridview->contentItem(); - QTRY_VERIFY(contentItem != 0); - - // view should be positioned at the top of the range. - QQuickItem *item = findItem(contentItem, "wrapper", 0); - QTRY_VERIFY(item); - QTRY_COMPARE(gridview->contentY(), -100.0); - - QQuickText *name = findItem(contentItem, "textName", 0); - QTRY_VERIFY(name != 0); - QTRY_COMPARE(name->text(), model.name(0)); - QQuickText *number = findItem(contentItem, "textNumber", 0); - QTRY_VERIFY(number != 0); - QTRY_COMPARE(number->text(), model.number(0)); - - // Check currentIndex is updated when contentItem moves - gridview->setContentY(0); - QTRY_COMPARE(gridview->currentIndex(), 2); - - gridview->setCurrentIndex(5); - QTRY_COMPARE(gridview->contentY(), 100.); - - QaimModel model2; - for (int i = 0; i < 5; i++) - model2.addItem("Item" + QString::number(i), ""); - - ctxt->setContextProperty("testModel", &model2); - QCOMPARE(gridview->count(), 5); - - delete canvas; -} - -void tst_QQuickGridView::enforceRange_rightToLeft() -{ - QQuickView *canvas = createView(); - - QaimModel model; - for (int i = 0; i < 30; i++) - model.addItem("Item" + QString::number(i), ""); - - QDeclarativeContext *ctxt = canvas->rootContext(); - ctxt->setContextProperty("testModel", &model); - ctxt->setContextProperty("testRightToLeft", QVariant(true)); - ctxt->setContextProperty("testTopToBottom", QVariant(true)); - - canvas->setSource(testFileUrl("gridview-enforcerange.qml")); - qApp->processEvents(); - QVERIFY(canvas->rootObject() != 0); - - QQuickGridView *gridview = findItem(canvas->rootObject(), "grid"); - QTRY_VERIFY(gridview != 0); - - QCOMPARE(gridview->preferredHighlightBegin(), 100.0); - QCOMPARE(gridview->preferredHighlightEnd(), 100.0); - QCOMPARE(gridview->highlightRangeMode(), QQuickGridView::StrictlyEnforceRange); - - QQuickItem *contentItem = gridview->contentItem(); - QVERIFY(contentItem != 0); - - // view should be positioned at the top of the range. - QQuickItem *item = findItem(contentItem, "wrapper", 0); - QVERIFY(item); - QTRY_COMPARE(gridview->contentX(), -140.); - QTRY_COMPARE(gridview->contentY(), 0.0); - - QQuickText *name = findItem(contentItem, "textName", 0); - QTRY_VERIFY(name != 0); - QTRY_COMPARE(name->text(), model.name(0)); - QQuickText *number = findItem(contentItem, "textNumber", 0); - QTRY_VERIFY(number != 0); - QTRY_COMPARE(number->text(), model.number(0)); - - // Check currentIndex is updated when contentItem moves - gridview->setContentX(-240); - QTRY_COMPARE(gridview->currentIndex(), 3); - - gridview->setCurrentIndex(7); - QTRY_COMPARE(gridview->contentX(), -340.); - QTRY_COMPARE(gridview->contentY(), 0.0); - - QaimModel model2; - for (int i = 0; i < 5; i++) - model2.addItem("Item" + QString::number(i), ""); - - ctxt->setContextProperty("testModel", &model2); - QCOMPARE(gridview->count(), 5); - - delete canvas; -} - -void tst_QQuickGridView::QTBUG_8456() -{ - QQuickView *canvas = createView(); - - canvas->setSource(testFileUrl("setindex.qml")); - qApp->processEvents(); - - QQuickGridView *gridview = findItem(canvas->rootObject(), "grid"); - QTRY_VERIFY(gridview != 0); - - QTRY_COMPARE(gridview->currentIndex(), 0); - - delete canvas; -} - -void tst_QQuickGridView::manualHighlight() -{ - QQuickView *canvas = createView(); - - QString filename(testFile("manual-highlight.qml")); - canvas->setSource(QUrl::fromLocalFile(filename)); - - qApp->processEvents(); - - QQuickGridView *gridview = findItem(canvas->rootObject(), "grid"); - QTRY_VERIFY(gridview != 0); - - QQuickItem *contentItem = gridview->contentItem(); - QTRY_VERIFY(contentItem != 0); - - QTRY_COMPARE(gridview->currentIndex(), 0); - QTRY_COMPARE(gridview->currentItem(), findItem(contentItem, "wrapper", 0)); - QTRY_COMPARE(gridview->highlightItem()->y() - 5, gridview->currentItem()->y()); - QTRY_COMPARE(gridview->highlightItem()->x() - 5, gridview->currentItem()->x()); - - gridview->setCurrentIndex(2); - - QTRY_COMPARE(gridview->currentIndex(), 2); - QTRY_COMPARE(gridview->currentItem(), findItem(contentItem, "wrapper", 2)); - QTRY_COMPARE(gridview->highlightItem()->y() - 5, gridview->currentItem()->y()); - QTRY_COMPARE(gridview->highlightItem()->x() - 5, gridview->currentItem()->x()); - - gridview->positionViewAtIndex(8, QQuickGridView::Contain); - - QTRY_COMPARE(gridview->currentIndex(), 2); - QTRY_COMPARE(gridview->currentItem(), findItem(contentItem, "wrapper", 2)); - QTRY_COMPARE(gridview->highlightItem()->y() - 5, gridview->currentItem()->y()); - QTRY_COMPARE(gridview->highlightItem()->x() - 5, gridview->currentItem()->x()); - - gridview->setFlow(QQuickGridView::TopToBottom); - QTRY_COMPARE(gridview->flow(), QQuickGridView::TopToBottom); - - gridview->setCurrentIndex(0); - QTRY_COMPARE(gridview->currentIndex(), 0); - QTRY_COMPARE(gridview->currentItem(), findItem(contentItem, "wrapper", 0)); - QTRY_COMPARE(gridview->highlightItem()->y() - 5, gridview->currentItem()->y()); - QTRY_COMPARE(gridview->highlightItem()->x() - 5, gridview->currentItem()->x()); - - delete canvas; -} - - -void tst_QQuickGridView::footer() -{ - QFETCH(QQuickGridView::Flow, flow); - QFETCH(Qt::LayoutDirection, layoutDirection); - QFETCH(QPointF, initialFooterPos); - QFETCH(QPointF, changedFooterPos); - QFETCH(QPointF, initialContentPos); - QFETCH(QPointF, changedContentPos); - QFETCH(QPointF, firstDelegatePos); - QFETCH(QPointF, resizeContentPos); - - QQuickView *canvas = createView(); - canvas->show(); - - QaimModel model; - for (int i = 0; i < 7; i++) - model.addItem("Item" + QString::number(i), ""); - - QDeclarativeContext *ctxt = canvas->rootContext(); - ctxt->setContextProperty("testModel", &model); - - canvas->setSource(testFileUrl("footer.qml")); - qApp->processEvents(); - - QQuickGridView *gridview = findItem(canvas->rootObject(), "grid"); - QTRY_VERIFY(gridview != 0); - gridview->setFlow(flow); - gridview->setLayoutDirection(layoutDirection); - - QQuickItem *contentItem = gridview->contentItem(); - QTRY_VERIFY(contentItem != 0); - - QQuickText *footer = findItem(contentItem, "footer"); - QVERIFY(footer); - - QVERIFY(footer == gridview->footerItem()); - - QCOMPARE(footer->pos(), initialFooterPos); - QCOMPARE(footer->width(), 100.); - QCOMPARE(footer->height(), 30.); - QCOMPARE(QPointF(gridview->contentX(), gridview->contentY()), initialContentPos); - - QQuickItem *item = findItem(contentItem, "wrapper", 0); - QVERIFY(item); - QCOMPARE(item->pos(), firstDelegatePos); - - if (flow == QQuickGridView::LeftToRight) { - // shrink by one row - model.removeItem(2); - QTRY_COMPARE(footer->y(), initialFooterPos.y() - gridview->cellHeight()); - } else { - // shrink by one column - model.removeItem(2); - model.removeItem(3); - if (layoutDirection == Qt::LeftToRight) - QTRY_COMPARE(footer->x(), initialFooterPos.x() - gridview->cellWidth()); - else - QTRY_COMPARE(footer->x(), initialFooterPos.x() + gridview->cellWidth()); - } - - // remove all items - model.clear(); - - QPointF posWhenNoItems(0, 0); - if (layoutDirection == Qt::RightToLeft) - posWhenNoItems.setX(flow == QQuickGridView::LeftToRight ? gridview->width() - footer->width() : -footer->width()); - QTRY_COMPARE(footer->pos(), posWhenNoItems); - - // if header is present, it's at a negative pos, so the footer should not move - canvas->rootObject()->setProperty("showHeader", true); - QVERIFY(findItem(contentItem, "header") != 0); - QTRY_COMPARE(footer->pos(), posWhenNoItems); - canvas->rootObject()->setProperty("showHeader", false); - - // add 30 items - for (int i = 0; i < 30; i++) - model.addItem("Item" + QString::number(i), ""); - - QSignalSpy footerItemSpy(gridview, SIGNAL(footerItemChanged())); - QMetaObject::invokeMethod(canvas->rootObject(), "changeFooter"); - - QCOMPARE(footerItemSpy.count(), 1); - - footer = findItem(contentItem, "footer"); - QVERIFY(!footer); - footer = findItem(contentItem, "footer2"); - QVERIFY(footer); - - QVERIFY(footer == gridview->footerItem()); - - QCOMPARE(footer->pos(), changedFooterPos); - QCOMPARE(footer->width(), 50.); - QCOMPARE(footer->height(), 20.); - QTRY_COMPARE(QPointF(gridview->contentX(), gridview->contentY()), changedContentPos); - - item = findItem(contentItem, "wrapper", 0); - QVERIFY(item); - QCOMPARE(item->pos(), firstDelegatePos); - - gridview->positionViewAtEnd(); - footer->setHeight(10); - footer->setWidth(40); - QTRY_COMPARE(QPointF(gridview->contentX(), gridview->contentY()), resizeContentPos); - - delete canvas; -} - -void tst_QQuickGridView::footer_data() -{ - QTest::addColumn("flow"); - QTest::addColumn("layoutDirection"); - QTest::addColumn("initialFooterPos"); - QTest::addColumn("changedFooterPos"); - QTest::addColumn("initialContentPos"); - QTest::addColumn("changedContentPos"); - QTest::addColumn("firstDelegatePos"); - QTest::addColumn("resizeContentPos"); - - // footer1 = 100 x 30 - // footer2 = 50 x 20 - // cells = 80 * 60 - // view width = 240 - // view height = 320 - - // footer below items, bottom left - QTest::newRow("flow left to right") << QQuickGridView::LeftToRight << Qt::LeftToRight - << QPointF(0, 3 * 60) // 180 = height of 3 rows (cell height is 60) - << QPointF(0, 10 * 60) // 30 items = 10 rows - << QPointF(0, 0) - << QPointF(0, 0) - << QPointF(0, 0) - << QPointF(0, 10 * 60 - 320 + 10); - - // footer below items, bottom right - QTest::newRow("flow left to right, layout right to left") << QQuickGridView::LeftToRight << Qt::RightToLeft - << QPointF(240 - 100, 3 * 60) - << QPointF((240 - 100) + 50, 10 * 60) // 50 = width diff between old and new footers - << QPointF(0, 0) - << QPointF(0, 0) - << QPointF(240 - 80, 0) - << QPointF(0, 10 * 60 - 320 + 10); - - // footer to right of items - QTest::newRow("flow top to bottom, layout left to right") << QQuickGridView::TopToBottom << Qt::LeftToRight - << QPointF(2 * 80, 0) // 2 columns, cell width 80 - << QPointF(6 * 80, 0) // 30 items = 6 columns - << QPointF(0, 0) - << QPointF(0, 0) - << QPointF(0, 0) - << QPointF(6 * 80 - 240 + 40, 0); - - // footer to left of items - QTest::newRow("flow top to bottom, layout right to left") << QQuickGridView::TopToBottom << Qt::RightToLeft - << QPointF(-(2 * 80) - 100, 0) - << QPointF(-(6 * 80) - 50, 0) // 50 = new footer width - << QPointF(-240, 0) - << QPointF(-240, 0) // unchanged, footer change doesn't change content pos - << QPointF(-80, 0) - << QPointF(-(6 * 80) - 40, 0); -} - -void tst_QQuickGridView::header() -{ - QFETCH(QQuickGridView::Flow, flow); - QFETCH(Qt::LayoutDirection, layoutDirection); - QFETCH(QPointF, initialHeaderPos); - QFETCH(QPointF, changedHeaderPos); - QFETCH(QPointF, initialContentPos); - QFETCH(QPointF, changedContentPos); - QFETCH(QPointF, firstDelegatePos); - QFETCH(QPointF, resizeContentPos); - - QaimModel model; - for (int i = 0; i < 30; i++) - model.addItem("Item" + QString::number(i), ""); - - QQuickView *canvas = createView(); - canvas->rootContext()->setContextProperty("testModel", &model); - canvas->rootContext()->setContextProperty("initialViewWidth", 240); - canvas->rootContext()->setContextProperty("initialViewHeight", 320); - canvas->setSource(testFileUrl("header.qml")); - canvas->show(); - qApp->processEvents(); - - QQuickGridView *gridview = findItem(canvas->rootObject(), "grid"); - QTRY_VERIFY(gridview != 0); - gridview->setFlow(flow); - gridview->setLayoutDirection(layoutDirection); - QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false); - - QQuickItem *contentItem = gridview->contentItem(); - QTRY_VERIFY(contentItem != 0); - - QQuickText *header = findItem(contentItem, "header"); - QVERIFY(header); - - QVERIFY(header == gridview->headerItem()); - - QCOMPARE(header->pos(), initialHeaderPos); - QCOMPARE(header->width(), 100.); - QCOMPARE(header->height(), 30.); - QCOMPARE(QPointF(gridview->contentX(), gridview->contentY()), initialContentPos); - - QQuickItem *item = findItem(contentItem, "wrapper", 0); - QVERIFY(item); - QCOMPARE(item->pos(), firstDelegatePos); - - model.clear(); - QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false); - QCOMPARE(header->pos(), initialHeaderPos); // header should stay where it is - - for (int i = 0; i < 30; i++) - model.addItem("Item" + QString::number(i), ""); - - QSignalSpy headerItemSpy(gridview, SIGNAL(headerItemChanged())); - QMetaObject::invokeMethod(canvas->rootObject(), "changeHeader"); - - QCOMPARE(headerItemSpy.count(), 1); - - header = findItem(contentItem, "header"); - QVERIFY(!header); - header = findItem(contentItem, "header2"); - QVERIFY(header); - - QVERIFY(header == gridview->headerItem()); - - QCOMPARE(header->pos(), changedHeaderPos); - QCOMPARE(header->width(), 50.); - QCOMPARE(header->height(), 20.); - QTRY_COMPARE(QPointF(gridview->contentX(), gridview->contentY()), changedContentPos); - - item = findItem(contentItem, "wrapper", 0); - QVERIFY(item); - QCOMPARE(item->pos(), firstDelegatePos); - - header->setHeight(10); - header->setWidth(40); - QTRY_COMPARE(QPointF(gridview->contentX(), gridview->contentY()), resizeContentPos); - - delete canvas; - - - // QTBUG-21207 header should become visible if view resizes from initial empty size - - canvas = createView(); - canvas->rootContext()->setContextProperty("testModel", &model); - canvas->rootContext()->setContextProperty("initialViewWidth", 240); - canvas->rootContext()->setContextProperty("initialViewHeight", 320); - canvas->setSource(testFileUrl("header.qml")); - canvas->show(); - qApp->processEvents(); - - gridview = findItem(canvas->rootObject(), "grid"); - QTRY_VERIFY(gridview != 0); - gridview->setFlow(flow); - gridview->setLayoutDirection(layoutDirection); - QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false); - - gridview->setWidth(240); - gridview->setHeight(320); - QTRY_COMPARE(gridview->headerItem()->pos(), initialHeaderPos); - QCOMPARE(QPointF(gridview->contentX(), gridview->contentY()), initialContentPos); - - delete canvas; -} - -void tst_QQuickGridView::header_data() -{ - QTest::addColumn("flow"); - QTest::addColumn("layoutDirection"); - QTest::addColumn("initialHeaderPos"); - QTest::addColumn("changedHeaderPos"); - QTest::addColumn("initialContentPos"); - QTest::addColumn("changedContentPos"); - QTest::addColumn("firstDelegatePos"); - QTest::addColumn("resizeContentPos"); - - // header1 = 100 x 30 - // header2 = 50 x 20 - // cells = 80 x 60 - // view width = 240 - - // header above items, top left - QTest::newRow("flow left to right") << QQuickGridView::LeftToRight << Qt::LeftToRight - << QPointF(0, -30) - << QPointF(0, -20) - << QPointF(0, -30) - << QPointF(0, -20) - << QPointF(0, 0) - << QPointF(0, -10); - - // header above items, top right - QTest::newRow("flow left to right, layout right to left") << QQuickGridView::LeftToRight << Qt::RightToLeft - << QPointF(240 - 100, -30) - << QPointF((240 - 100) + 50, -20) // 50 = width diff between old and new headers - << QPointF(0, -30) - << QPointF(0, -20) - << QPointF(160, 0) - << QPointF(0, -10); - - // header to left of items - QTest::newRow("flow top to bottom, layout left to right") << QQuickGridView::TopToBottom << Qt::LeftToRight - << QPointF(-100, 0) - << QPointF(-50, 0) - << QPointF(-100, 0) - << QPointF(-50, 0) - << QPointF(0, 0) - << QPointF(-40, 0); - - // header to right of items - QTest::newRow("flow top to bottom, layout right to left") << QQuickGridView::TopToBottom << Qt::RightToLeft - << QPointF(0, 0) - << QPointF(0, 0) - << QPointF(-(240 - 100), 0) - << QPointF(-(240 - 50), 0) - << QPointF(-80, 0) - << QPointF(-(240 - 40), 0); -} - -void tst_QQuickGridView::resizeViewAndRepaint() -{ - QQuickView *canvas = createView(); - canvas->show(); - - QaimModel model; - for (int i = 0; i < 40; i++) - model.addItem("Item" + QString::number(i), ""); - - QDeclarativeContext *ctxt = canvas->rootContext(); - ctxt->setContextProperty("testModel", &model); - ctxt->setContextProperty("initialWidth", 240); - ctxt->setContextProperty("initialHeight", 100); - - canvas->setSource(testFileUrl("resizeview.qml")); - canvas->show(); - qApp->processEvents(); - - QQuickGridView *gridview = findItem(canvas->rootObject(), "grid"); - QTRY_VERIFY(gridview != 0); - QQuickItem *contentItem = gridview->contentItem(); - QTRY_VERIFY(contentItem != 0); - QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false); - - // item at index 10 should not be currently visible - QVERIFY(!findItem(contentItem, "wrapper", 10)); - - gridview->setHeight(320); - QTRY_VERIFY(findItem(contentItem, "wrapper", 10)); - - gridview->setHeight(100); - QTRY_VERIFY(!findItem(contentItem, "wrapper", 10)); - - // Ensure we handle -ve sizes - gridview->setHeight(-100); - QTRY_COMPARE(findItems(contentItem, "wrapper", false).count(), 3); - - gridview->setCacheBuffer(120); - QTRY_COMPARE(findItems(contentItem, "wrapper", false).count(), 9); - - // ensure items in cache become visible - gridview->setHeight(120); - QTRY_COMPARE(findItems(contentItem, "wrapper", false).count(), 15); - - int itemCount = findItems(contentItem, "wrapper").count(); - for (int i = 0; i < model.count() && i < itemCount; ++i) { - QQuickItem *item = findItem(contentItem, "wrapper", i); - if (!item) qWarning() << "Item" << i << "not found"; - QTRY_VERIFY(item); - QTRY_COMPARE(item->x(), qreal((i%3)*80)); - QTRY_COMPARE(item->y(), qreal((i/3)*60)); - QCOMPARE(item->isVisible(), i < 9); // inside view visible, outside not visible - } - - // ensure items outside view become invisible - gridview->setHeight(60); - QTRY_COMPARE(findItems(contentItem, "wrapper", false).count(), 12); - - itemCount = findItems(contentItem, "wrapper", false).count(); - for (int i = 0; i < model.count() && i < itemCount; ++i) { - QQuickItem *item = findItem(contentItem, "wrapper", i); - if (!item) qWarning() << "Item" << i << "not found"; - QTRY_VERIFY(item); - QTRY_COMPARE(item->x(), qreal((i%3)*80)); - QTRY_COMPARE(item->y(), qreal((i/3)*60)); - QCOMPARE(item->isVisible(), i < 6); // inside view visible, outside not visible - } - - delete canvas; -} - -void tst_QQuickGridView::changeColumnCount() -{ - QmlListModel model; - for (int i = 0; i < 40; i++) - model.addItem("Item" + QString::number(i), ""); - - QQuickView *canvas = createView(); - QDeclarativeContext *ctxt = canvas->rootContext(); - ctxt->setContextProperty("testModel", &model); - ctxt->setContextProperty("initialWidth", 100); - ctxt->setContextProperty("initialHeight", 320); - canvas->setSource(testFileUrl("resizeview.qml")); - canvas->show(); - qApp->processEvents(); - - QQuickGridView *gridview = findItem(canvas->rootObject(), "grid"); - QTRY_VERIFY(gridview != 0); - QQuickItem *contentItem = gridview->contentItem(); - QTRY_VERIFY(contentItem != 0); - QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false); - - // a single column of 6 items are visible - int itemCount = findItems(contentItem, "wrapper").count(); - QCOMPARE(itemCount, 6); - for (int i = 0; i < model.count() && i < itemCount; ++i) { - QQuickItem *item = findItem(contentItem, "wrapper", i); - QVERIFY2(item, QTest::toString(QString("Item %1 not found").arg(i))); - QCOMPARE(item->x(), 0.0); - QCOMPARE(item->y(), qreal(i*60)); - } - - // now 6x3 grid is visible, plus 1 extra below for refill - gridview->setWidth(240); - QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false); - itemCount = findItems(contentItem, "wrapper").count(); - QCOMPARE(itemCount, 6*3 + 1); - for (int i = 0; i < model.count() && i < itemCount; ++i) { - QQuickItem *item = findItem(contentItem, "wrapper", i); - QVERIFY2(item, QTest::toString(QString("Item %1 not found").arg(i))); - QCOMPARE(item->x(), qreal((i%3)*80)); - QCOMPARE(item->y(), qreal((i/3)*60)); - } - - // back to single column - gridview->setWidth(100); - QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false); - itemCount = findItems(contentItem, "wrapper").count(); - QCOMPARE(itemCount, 6); - for (int i = 0; i < model.count() && i < itemCount; ++i) { - QQuickItem *item = findItem(contentItem, "wrapper", i); - QVERIFY2(item, QTest::toString(QString("Item %1 not found").arg(i))); - QCOMPARE(item->x(), 0.0); - QCOMPARE(item->y(), qreal(i*60)); - } - - delete canvas; -} - -void tst_QQuickGridView::indexAt_itemAt_data() -{ - QTest::addColumn("x"); - QTest::addColumn("y"); - QTest::addColumn("index"); - - QTest::newRow("Item 0 - 0, 0") << 0. << 0. << 0; - QTest::newRow("Item 0 - 79, 59") << 79. << 59. << 0; - QTest::newRow("Item 1 - 80, 0") << 80. << 0. << 1; - QTest::newRow("Item 3 - 0, 60") << 0. << 60. << 3; - QTest::newRow("No Item - 240, 0") << 240. << 0. << -1; -} - -void tst_QQuickGridView::indexAt_itemAt() -{ - QFETCH(qreal, x); - QFETCH(qreal, y); - QFETCH(int, index); - - QQuickView *canvas = createView(); - - QaimModel model; - model.addItem("Fred", "12345"); - model.addItem("John", "2345"); - model.addItem("Bob", "54321"); - model.addItem("Billy", "22345"); - model.addItem("Sam", "2945"); - model.addItem("Ben", "04321"); - model.addItem("Jim", "0780"); - - QDeclarativeContext *ctxt = canvas->rootContext(); - ctxt->setContextProperty("testModel", &model); - ctxt->setContextProperty("testRightToLeft", QVariant(false)); - ctxt->setContextProperty("testTopToBottom", QVariant(false)); - - canvas->setSource(testFileUrl("gridview1.qml")); - qApp->processEvents(); - - QQuickGridView *gridview = findItem(canvas->rootObject(), "grid"); - QTRY_VERIFY(gridview != 0); - - QQuickItem *contentItem = gridview->contentItem(); - QTRY_VERIFY(contentItem != 0); - - QTRY_COMPARE(gridview->count(), model.count()); - - QQuickItem *item = 0; - if (index >= 0) { - item = findItem(contentItem, "wrapper", index); - QVERIFY(item); - } - QCOMPARE(gridview->indexAt(x, y), index); - QVERIFY(gridview->itemAt(x, y) == item); - - delete canvas; -} - -void tst_QQuickGridView::onAdd() -{ - QFETCH(int, initialItemCount); - QFETCH(int, itemsToAdd); - - const int delegateWidth = 50; - const int delegateHeight = 100; - QaimModel model; - QQuickView *canvas = createView(); - canvas->setGeometry(0,0,5 * delegateWidth, 5 * delegateHeight); // just ensure all items fit - - // these initial items should not trigger GridView.onAdd - for (int i=0; irootContext(); - ctxt->setContextProperty("testModel", &model); - ctxt->setContextProperty("delegateWidth", delegateWidth); - ctxt->setContextProperty("delegateHeight", delegateHeight); - canvas->setSource(testFileUrl("attachedSignals.qml")); - - QObject *object = canvas->rootObject(); - object->setProperty("width", canvas->width()); - object->setProperty("height", canvas->height()); - qApp->processEvents(); - - QList > items; - for (int i=0; i(canvas->rootObject())->count()); - qApp->processEvents(); - - QVariantList result = object->property("addedDelegates").toList(); - QTRY_COMPARE(result.count(), items.count()); - for (int i=0; i("initialItemCount"); - QTest::addColumn("itemsToAdd"); - - QTest::newRow("0, add 1") << 0 << 1; - QTest::newRow("0, add 2") << 0 << 2; - QTest::newRow("0, add 10") << 0 << 10; - - QTest::newRow("1, add 1") << 1 << 1; - QTest::newRow("1, add 2") << 1 << 2; - QTest::newRow("1, add 10") << 1 << 10; - - QTest::newRow("5, add 1") << 5 << 1; - QTest::newRow("5, add 2") << 5 << 2; - QTest::newRow("5, add 10") << 5 << 10; -} - -void tst_QQuickGridView::onRemove() -{ - QFETCH(int, initialItemCount); - QFETCH(int, indexToRemove); - QFETCH(int, removeCount); - - const int delegateWidth = 50; - const int delegateHeight = 100; - QaimModel model; - for (int i=0; irootContext(); - ctxt->setContextProperty("testModel", &model); - ctxt->setContextProperty("delegateWidth", delegateWidth); - ctxt->setContextProperty("delegateHeight", delegateHeight); - canvas->setSource(testFileUrl("attachedSignals.qml")); - QObject *object = canvas->rootObject(); - - model.removeItems(indexToRemove, removeCount); - QTRY_COMPARE(model.count(), qobject_cast(canvas->rootObject())->count()); - QCOMPARE(object->property("removedDelegateCount"), QVariant(removeCount)); - - delete canvas; -} - -void tst_QQuickGridView::onRemove_data() -{ - QTest::addColumn("initialItemCount"); - QTest::addColumn("indexToRemove"); - QTest::addColumn("removeCount"); - - QTest::newRow("remove first") << 1 << 0 << 1; - QTest::newRow("two items, remove first") << 2 << 0 << 1; - QTest::newRow("two items, remove last") << 2 << 1 << 1; - QTest::newRow("two items, remove all") << 2 << 0 << 2; - - QTest::newRow("four items, remove first") << 4 << 0 << 1; - QTest::newRow("four items, remove 0-2") << 4 << 0 << 2; - QTest::newRow("four items, remove 1-3") << 4 << 1 << 2; - QTest::newRow("four items, remove 2-4") << 4 << 2 << 2; - QTest::newRow("four items, remove last") << 4 << 3 << 1; - QTest::newRow("four items, remove all") << 4 << 0 << 4; - - QTest::newRow("ten items, remove 1-8") << 10 << 0 << 8; - QTest::newRow("ten items, remove 2-7") << 10 << 2 << 5; - QTest::newRow("ten items, remove 4-10") << 10 << 4 << 6; -} - -void tst_QQuickGridView::columnCount() -{ - QQuickView canvas; - canvas.setSource(testFileUrl("gridview4.qml")); - canvas.show(); - canvas.requestActivateWindow(); - QTest::qWaitForWindowShown(&canvas); - - QQuickGridView *view = qobject_cast(canvas.rootObject()); - - QCOMPARE(view->cellWidth(), qreal(405)/qreal(9)); - QCOMPARE(view->cellHeight(), qreal(100)); - - QList items = findItems(view, "delegate"); - QCOMPARE(items.size(), 18); - QCOMPARE(items.at(8)->y(), qreal(0)); - QCOMPARE(items.at(9)->y(), qreal(100)); -} - -void tst_QQuickGridView::margins() -{ - { - QQuickView *canvas = createView(); - - QaimModel model; - for (int i = 0; i < 40; i++) - model.addItem("Item" + QString::number(i), ""); - - QDeclarativeContext *ctxt = canvas->rootContext(); - ctxt->setContextProperty("testModel", &model); - ctxt->setContextProperty("testRightToLeft", QVariant(false)); - - canvas->setSource(testFileUrl("margins.qml")); - canvas->show(); - qApp->processEvents(); - - QQuickGridView *gridview = findItem(canvas->rootObject(), "grid"); - QTRY_VERIFY(gridview != 0); - QQuickItem *contentItem = gridview->contentItem(); - QTRY_VERIFY(contentItem != 0); - QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false); - - QCOMPARE(gridview->contentX(), -30.); - QCOMPARE(gridview->xOrigin(), 0.); - - // check end bound - gridview->positionViewAtEnd(); - qreal pos = gridview->contentX(); - gridview->setContentX(pos + 80); - gridview->returnToBounds(); - QTRY_COMPARE(gridview->contentX(), pos + 50); - - // remove item before visible and check that left margin is maintained - // and xOrigin is updated - gridview->setContentX(200); - model.removeItems(0, 4); - QTest::qWait(100); - gridview->setContentX(-50); - gridview->returnToBounds(); - QCOMPARE(gridview->xOrigin(), 100.); - QTRY_COMPARE(gridview->contentX(), 70.); - - // reduce left margin - gridview->setLeftMargin(20); - QCOMPARE(gridview->xOrigin(), 100.); - QTRY_COMPARE(gridview->contentX(), 80.); - - // check end bound - gridview->positionViewAtEnd(); - QCOMPARE(gridview->xOrigin(), 0.); // positionViewAtEnd() resets origin - pos = gridview->contentX(); - gridview->setContentX(pos + 80); - gridview->returnToBounds(); - QTRY_COMPARE(gridview->contentX(), pos + 50); - - // reduce right margin - pos = gridview->contentX(); - gridview->setRightMargin(40); - QCOMPARE(gridview->xOrigin(), 0.); - QTRY_COMPARE(gridview->contentX(), pos-10); - - delete canvas; - } - { - //RTL - QQuickView *canvas = createView(); - canvas->show(); - - QaimModel model; - for (int i = 0; i < 40; i++) - model.addItem("Item" + QString::number(i), ""); - - QDeclarativeContext *ctxt = canvas->rootContext(); - ctxt->setContextProperty("testModel", &model); - ctxt->setContextProperty("testRightToLeft", QVariant(true)); - - canvas->setSource(testFileUrl("margins.qml")); - qApp->processEvents(); - - QQuickGridView *gridview = findItem(canvas->rootObject(), "grid"); - QTRY_VERIFY(gridview != 0); - - QQuickItem *contentItem = gridview->contentItem(); - QTRY_VERIFY(contentItem != 0); - - QCOMPARE(gridview->contentX(), -240+30.); - QCOMPARE(gridview->xOrigin(), 0.); - - // check end bound - gridview->positionViewAtEnd(); - qreal pos = gridview->contentX(); - gridview->setContentX(pos - 80); - gridview->returnToBounds(); - QTRY_COMPARE(gridview->contentX(), pos - 50); - - // remove item before visible and check that left margin is maintained - // and xOrigin is updated - gridview->setContentX(-400); - model.removeItems(0, 4); - QTest::qWait(100); - gridview->setContentX(-240+50); - gridview->returnToBounds(); - QCOMPARE(gridview->xOrigin(), -100.); - QTRY_COMPARE(gridview->contentX(), -240-70.); - - // reduce left margin (i.e. right side due to RTL) - pos = gridview->contentX(); - gridview->setLeftMargin(20); - QCOMPARE(gridview->xOrigin(), -100.); - QTRY_COMPARE(gridview->contentX(), -240-80.); - - // check end bound - gridview->positionViewAtEnd(); - QCOMPARE(gridview->xOrigin(), 0.); // positionViewAtEnd() resets origin - pos = gridview->contentX(); - gridview->setContentX(pos - 80); - gridview->returnToBounds(); - QTRY_COMPARE(gridview->contentX(), pos - 50); - - // reduce right margin (i.e. left side due to RTL) - pos = gridview->contentX(); - gridview->setRightMargin(40); - QCOMPARE(gridview->xOrigin(), 0.); - QTRY_COMPARE(gridview->contentX(), pos+10); - - delete canvas; - } -} - -void tst_QQuickGridView::creationContext() -{ - QQuickView canvas; - canvas.setGeometry(0,0,240,320); - canvas.setSource(testFileUrl("creationContext.qml")); - qApp->processEvents(); - - QQuickItem *rootItem = qobject_cast(canvas.rootObject()); - QVERIFY(rootItem); - QVERIFY(rootItem->property("count").toInt() > 0); - - QQuickItem *item; - QVERIFY(item = rootItem->findChild("listItem")); - QCOMPARE(item->property("text").toString(), QString("Hello!")); - QVERIFY(item = rootItem->findChild("header")); - QCOMPARE(item->property("text").toString(), QString("Hello!")); - QVERIFY(item = rootItem->findChild("footer")); - QCOMPARE(item->property("text").toString(), QString("Hello!")); -} - -void tst_QQuickGridView::snapToRow_data() -{ - QTest::addColumn("flow"); - QTest::addColumn("layoutDirection"); - QTest::addColumn("highlightRangeMode"); - QTest::addColumn("flickStart"); - QTest::addColumn("flickEnd"); - QTest::addColumn("snapAlignment"); - QTest::addColumn("endExtent"); - QTest::addColumn("startExtent"); - - QTest::newRow("vertical, left to right") << QQuickGridView::LeftToRight << Qt::LeftToRight << int(QQuickItemView::NoHighlightRange) - << QPoint(20, 200) << QPoint(20, 20) << 60.0 << 1200.0 << 0.0; - - QTest::newRow("horizontal, left to right") << QQuickGridView::TopToBottom << Qt::LeftToRight << int(QQuickItemView::NoHighlightRange) - << QPoint(200, 20) << QPoint(20, 20) << 60.0 << 1200.0 << 0.0; - - QTest::newRow("horizontal, right to left") << QQuickGridView::TopToBottom << Qt::RightToLeft << int(QQuickItemView::NoHighlightRange) - << QPoint(20, 20) << QPoint(200, 20) << -60.0 << -1200.0 - 240.0 << -240.0; - - QTest::newRow("vertical, left to right, enforce range") << QQuickGridView::LeftToRight << Qt::LeftToRight << int(QQuickItemView::StrictlyEnforceRange) - << QPoint(20, 200) << QPoint(20, 20) << 60.0 << 1340.0 << -20.0; - - QTest::newRow("horizontal, left to right, enforce range") << QQuickGridView::TopToBottom << Qt::LeftToRight << int(QQuickItemView::StrictlyEnforceRange) - << QPoint(200, 20) << QPoint(20, 20) << 60.0 << 1340.0 << -20.0; - - QTest::newRow("horizontal, right to left, enforce range") << QQuickGridView::TopToBottom << Qt::RightToLeft << int(QQuickItemView::StrictlyEnforceRange) - << QPoint(20, 20) << QPoint(200, 20) << -60.0 << -1200.0 - 240.0 - 140.0 << -220.0; -} - -void tst_QQuickGridView::snapToRow() -{ - QFETCH(QQuickGridView::Flow, flow); - QFETCH(Qt::LayoutDirection, layoutDirection); - QFETCH(int, highlightRangeMode); - QFETCH(QPoint, flickStart); - QFETCH(QPoint, flickEnd); - QFETCH(qreal, snapAlignment); - QFETCH(qreal, endExtent); - QFETCH(qreal, startExtent); - - QQuickView *canvas = createView(); - - canvas->setSource(testFileUrl("snapToRow.qml")); - canvas->show(); - qApp->processEvents(); - - QQuickGridView *gridview = findItem(canvas->rootObject(), "grid"); - QTRY_VERIFY(gridview != 0); - - gridview->setFlow(flow); - gridview->setLayoutDirection(layoutDirection); - gridview->setHighlightRangeMode(QQuickItemView::HighlightRangeMode(highlightRangeMode)); - QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false); - - QQuickItem *contentItem = gridview->contentItem(); - QTRY_VERIFY(contentItem != 0); - - // confirm that a flick hits an item boundary - flick(canvas, flickStart, flickEnd, 180); - QTRY_VERIFY(gridview->isMoving() == false); // wait until it stops - if (flow == QQuickGridView::LeftToRight) - QCOMPARE(qreal(fmod(gridview->contentY(),80.0)), snapAlignment); - else - QCOMPARE(qreal(fmod(gridview->contentX(),80.0)), snapAlignment); - - // flick to end - do { - flick(canvas, flickStart, flickEnd, 180); - QTRY_VERIFY(gridview->isMoving() == false); // wait until it stops - } while (flow == QQuickGridView::LeftToRight - ? !gridview->isAtYEnd() - : layoutDirection == Qt::LeftToRight ? !gridview->isAtXEnd() : !gridview->isAtXBeginning()); - - if (flow == QQuickGridView::LeftToRight) - QCOMPARE(gridview->contentY(), endExtent); - else - QCOMPARE(gridview->contentX(), endExtent); - - // flick to start - do { - flick(canvas, flickEnd, flickStart, 180); - QTRY_VERIFY(gridview->isMoving() == false); // wait until it stops - } while (flow == QQuickGridView::LeftToRight - ? !gridview->isAtYBeginning() - : layoutDirection == Qt::LeftToRight ? !gridview->isAtXBeginning() : !gridview->isAtXEnd()); - - if (flow == QQuickGridView::LeftToRight) - QCOMPARE(gridview->contentY(), startExtent); - else - QCOMPARE(gridview->contentX(), startExtent); - - delete canvas; -} - -void tst_QQuickGridView::snapOneRow_data() -{ - QTest::addColumn("flow"); - QTest::addColumn("layoutDirection"); - QTest::addColumn("highlightRangeMode"); - QTest::addColumn("flickStart"); - QTest::addColumn("flickEnd"); - QTest::addColumn("snapAlignment"); - QTest::addColumn("endExtent"); - QTest::addColumn("startExtent"); - - QTest::newRow("vertical, left to right") << QQuickGridView::LeftToRight << Qt::LeftToRight << int(QQuickItemView::NoHighlightRange) - << QPoint(20, 200) << QPoint(20, 20) << 100.0 << 360.0 << 0.0; - - QTest::newRow("horizontal, left to right") << QQuickGridView::TopToBottom << Qt::LeftToRight << int(QQuickItemView::NoHighlightRange) - << QPoint(200, 20) << QPoint(20, 20) << 100.0 << 360.0 << 0.0; - - QTest::newRow("horizontal, right to left") << QQuickGridView::TopToBottom << Qt::RightToLeft << int(QQuickItemView::NoHighlightRange) - << QPoint(20, 20) << QPoint(200, 20) << -340.0 << -360.0 - 240.0 << -240.0; - - QTest::newRow("vertical, left to right, enforce range") << QQuickGridView::LeftToRight << Qt::LeftToRight << int(QQuickItemView::StrictlyEnforceRange) - << QPoint(20, 200) << QPoint(20, 20) << 100.0 << 460.0 << -20.0; - - QTest::newRow("horizontal, left to right, enforce range") << QQuickGridView::TopToBottom << Qt::LeftToRight << int(QQuickItemView::StrictlyEnforceRange) - << QPoint(200, 20) << QPoint(20, 20) << 100.0 << 460.0 << -20.0; - - QTest::newRow("horizontal, right to left, enforce range") << QQuickGridView::TopToBottom << Qt::RightToLeft << int(QQuickItemView::StrictlyEnforceRange) - << QPoint(20, 20) << QPoint(200, 20) << -340.0 << -360.0 - 240.0 - 100.0 << -220.0; -} - -void tst_QQuickGridView::snapOneRow() -{ - QFETCH(QQuickGridView::Flow, flow); - QFETCH(Qt::LayoutDirection, layoutDirection); - QFETCH(int, highlightRangeMode); - QFETCH(QPoint, flickStart); - QFETCH(QPoint, flickEnd); - QFETCH(qreal, snapAlignment); - QFETCH(qreal, endExtent); - QFETCH(qreal, startExtent); - - QQuickView *canvas = createView(); - - canvas->setSource(testFileUrl("snapOneRow.qml")); - canvas->show(); - qApp->processEvents(); - - QQuickGridView *gridview = findItem(canvas->rootObject(), "grid"); - QTRY_VERIFY(gridview != 0); - - gridview->setFlow(flow); - gridview->setLayoutDirection(layoutDirection); - gridview->setHighlightRangeMode(QQuickItemView::HighlightRangeMode(highlightRangeMode)); - QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false); - - QQuickItem *contentItem = gridview->contentItem(); - QTRY_VERIFY(contentItem != 0); - - QSignalSpy currentIndexSpy(gridview, SIGNAL(currentIndexChanged())); - - // confirm that a flick hits next row boundary - flick(canvas, flickStart, flickEnd, 180); - QTRY_VERIFY(gridview->isMoving() == false); // wait until it stops - if (flow == QQuickGridView::LeftToRight) - QCOMPARE(gridview->contentY(), snapAlignment); - else - QCOMPARE(gridview->contentX(), snapAlignment); - - if (QQuickItemView::HighlightRangeMode(highlightRangeMode) == QQuickItemView::StrictlyEnforceRange) { - QCOMPARE(gridview->currentIndex(), 2); - QCOMPARE(currentIndexSpy.count(), 1); - } - - // flick to end - do { - flick(canvas, flickStart, flickEnd, 180); - QTRY_VERIFY(gridview->isMoving() == false); // wait until it stops - } while (flow == QQuickGridView::LeftToRight - ? !gridview->isAtYEnd() - : layoutDirection == Qt::LeftToRight ? !gridview->isAtXEnd() : !gridview->isAtXBeginning()); - - if (QQuickItemView::HighlightRangeMode(highlightRangeMode) == QQuickItemView::StrictlyEnforceRange) { - QCOMPARE(gridview->currentIndex(), 8); - QCOMPARE(currentIndexSpy.count(), 4); - } - - if (flow == QQuickGridView::LeftToRight) - QCOMPARE(gridview->contentY(), endExtent); - else - QCOMPARE(gridview->contentX(), endExtent); - - // flick to start - do { - flick(canvas, flickEnd, flickStart, 180); - QTRY_VERIFY(gridview->isMoving() == false); // wait until it stops - } while (flow == QQuickGridView::LeftToRight - ? !gridview->isAtYBeginning() - : layoutDirection == Qt::LeftToRight ? !gridview->isAtXBeginning() : !gridview->isAtXEnd()); - - if (flow == QQuickGridView::LeftToRight) - QCOMPARE(gridview->contentY(), startExtent); - else - QCOMPARE(gridview->contentX(), startExtent); - - if (QQuickItemView::HighlightRangeMode(highlightRangeMode) == QQuickItemView::StrictlyEnforceRange) { - QCOMPARE(gridview->currentIndex(), 0); - QCOMPARE(currentIndexSpy.count(), 8); - } - - delete canvas; -} - - -void tst_QQuickGridView::unaligned() -{ - QQuickView *canvas = createView(); - canvas->show(); - - QaimModel model; - for (int i = 0; i < 10; i++) - model.addItem("Item" + QString::number(i), ""); - - QDeclarativeContext *ctxt = canvas->rootContext(); - ctxt->setContextProperty("testModel", &model); - - canvas->setSource(testFileUrl("unaligned.qml")); - qApp->processEvents(); - - QQuickGridView *gridview = qobject_cast(canvas->rootObject()); - QVERIFY(gridview != 0); - - QQuickItem *contentItem = gridview->contentItem(); - QVERIFY(contentItem != 0); - - for (int i = 0; i < 10; ++i) { - QQuickItem *item = findItem(contentItem, "wrapper", i); - if (!item) qWarning() << "Item" << i << "not found"; - QVERIFY(item); - QCOMPARE(item->x(), qreal((i%9)*gridview->cellWidth())); - QCOMPARE(item->y(), qreal((i/9)*gridview->cellHeight())); - } - - // appending - for (int i = 10; i < 18; ++i) { - model.addItem("Item" + QString::number(i), ""); - QQuickItem *item = 0; - QTRY_VERIFY(item = findItem(contentItem, "wrapper", i)); - QCOMPARE(item->x(), qreal((i%9)*gridview->cellWidth())); - QCOMPARE(item->y(), qreal((i/9)*gridview->cellHeight())); - } - - // inserting - for (int i = 0; i < 10; ++i) { - model.insertItem(i, "Item" + QString::number(i), ""); - QQuickItem *item = 0; - QTRY_VERIFY(item = findItem(contentItem, "wrapper", i)); - QCOMPARE(item->x(), qreal((i%9)*gridview->cellWidth())); - QCOMPARE(item->y(), qreal((i/9)*gridview->cellHeight())); - } - - // removing - model.removeItems(7, 10); - QTRY_COMPARE(model.count(), gridview->count()); - for (int i = 0; i < 18; ++i) { - QQuickItem *item = 0; - QTRY_VERIFY(item = findItem(contentItem, "wrapper", i)); - QCOMPARE(item->x(), qreal(i%9)*gridview->cellWidth()); - QCOMPARE(item->y(), qreal(i/9)*gridview->cellHeight()); - } - - delete canvas; -} - -void tst_QQuickGridView::populateTransitions() -{ - QFETCH(bool, staticallyPopulate); - QFETCH(bool, dynamicallyPopulate); - QFETCH(bool, usePopulateTransition); - - QPointF transitionFrom(-50, -50); - QPointF transitionVia(100, 100); - QaimModel model_transitionFrom; - QaimModel model_transitionVia; - - QaimModel model; - if (staticallyPopulate) { - for (int i = 0; i < 30; i++) - model.addItem("item" + QString::number(i), ""); - } - - QQuickView *canvas = createView(); - canvas->rootContext()->setContextProperty("testModel", &model); - canvas->rootContext()->setContextProperty("usePopulateTransition", usePopulateTransition); - canvas->rootContext()->setContextProperty("dynamicallyPopulate", dynamicallyPopulate); - canvas->rootContext()->setContextProperty("transitionFrom", transitionFrom); - canvas->rootContext()->setContextProperty("transitionVia", transitionVia); - canvas->rootContext()->setContextProperty("model_transitionFrom", &model_transitionFrom); - canvas->rootContext()->setContextProperty("model_transitionVia", &model_transitionVia); - canvas->setSource(testFileUrl("populateTransitions.qml")); - canvas->show(); - - QQuickGridView *gridview = findItem(canvas->rootObject(), "grid"); - QVERIFY(gridview); - QQuickItem *contentItem = gridview->contentItem(); - QVERIFY(contentItem); - - if (staticallyPopulate || dynamicallyPopulate) { - // check the populate transition is run - if (usePopulateTransition) { - QTRY_COMPARE(gridview->property("countPopulateTransitions").toInt(), 19); - } else { - QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false); - QTRY_COMPARE(gridview->property("countPopulateTransitions").toInt(), 0); - } - QTRY_COMPARE(gridview->property("countAddTransitions").toInt(), 0); - } else { - QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false); - } - - int itemCount = findItems(contentItem, "wrapper").count(); - if (usePopulateTransition) - QCOMPARE(itemCount, gridview->property("countPopulateTransitions").toInt()); - for (int i=0; i < model.count() && i < itemCount; ++i) { - QQuickItem *item = findItem(contentItem, "wrapper", i); - QVERIFY2(item, QTest::toString(QString("Item %1 not found").arg(i))); - QCOMPARE(item->x(), (i%3)*80.0); - QCOMPARE(item->y(), (i/3)*60.0); - QQuickText *name = findItem(contentItem, "textName", i); - QVERIFY(name != 0); - QTRY_COMPARE(name->text(), model.name(i)); - } - - // add an item and check this is done with add transition, not populate - model.insertItem(0, "another item", ""); - QTRY_COMPARE(gridview->property("countAddTransitions").toInt(), 1); - QTRY_COMPARE(gridview->property("countPopulateTransitions").toInt(), - (usePopulateTransition && (staticallyPopulate || dynamicallyPopulate)) ? 19 : 0); - - // clear the model - canvas->rootContext()->setContextProperty("testModel", QVariant()); - QTRY_COMPARE(gridview->count(), 0); - QTRY_COMPARE(findItems(contentItem, "wrapper").count(), 0); - gridview->setProperty("countPopulateTransitions", 0); - gridview->setProperty("countAddTransitions", 0); - - // set to a valid model and check populate transition is run a second time - model.clear(); - for (int i = 0; i < 30; i++) - model.addItem("item" + QString::number(i), ""); - canvas->rootContext()->setContextProperty("testModel", &model); - QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false); - - QTRY_COMPARE(gridview->property("countPopulateTransitions").toInt(), usePopulateTransition ? 19 : 0); - QTRY_COMPARE(gridview->property("countAddTransitions").toInt(), 0); - - itemCount = findItems(contentItem, "wrapper").count(); - if (usePopulateTransition) - QCOMPARE(itemCount, gridview->property("countPopulateTransitions").toInt()); - for (int i=0; i < model.count() && i < itemCount; ++i) { - QQuickItem *item = findItem(contentItem, "wrapper", i); - QVERIFY2(item, QTest::toString(QString("Item %1 not found").arg(i))); - QCOMPARE(item->x(), (i%3)*80.0); - QCOMPARE(item->y(), (i/3)*60.0); - QQuickText *name = findItem(contentItem, "textName", i); - QVERIFY(name != 0); - QTRY_COMPARE(name->text(), model.name(i)); - } - - // reset model and check populate transition is run again - gridview->setProperty("countPopulateTransitions", 0); - gridview->setProperty("countAddTransitions", 0); - model.reset(); - QTRY_COMPARE(gridview->property("countPopulateTransitions").toInt(), usePopulateTransition ? 19 : 0); - QTRY_COMPARE(gridview->property("countAddTransitions").toInt(), 0); - - itemCount = findItems(contentItem, "wrapper").count(); - if (usePopulateTransition) - QCOMPARE(itemCount, gridview->property("countPopulateTransitions").toInt()); - for (int i=0; i < model.count() && i < itemCount; ++i) { - QQuickItem *item = findItem(contentItem, "wrapper", i); - QVERIFY2(item, QTest::toString(QString("Item %1 not found").arg(i))); - QCOMPARE(item->x(), (i%3)*80.0); - QCOMPARE(item->y(), (i/3)*60.0); - QQuickText *name = findItem(contentItem, "textName", i); - QVERIFY(name != 0); - QTRY_COMPARE(name->text(), model.name(i)); - } - - delete canvas; -} - -void tst_QQuickGridView::populateTransitions_data() -{ - QTest::addColumn("staticallyPopulate"); - QTest::addColumn("dynamicallyPopulate"); - QTest::addColumn("usePopulateTransition"); - - QTest::newRow("static") << true << false << true; - QTest::newRow("static, no populate") << true << false << false; - - QTest::newRow("dynamic") << false << true << true; - QTest::newRow("dynamic, no populate") << false << true << false; - - QTest::newRow("empty to start with") << false << false << true; - QTest::newRow("empty to start with, no populate") << false << false << false; -} - -void tst_QQuickGridView::addTransitions() -{ - QFETCH(int, initialItemCount); - QFETCH(bool, shouldAnimateTargets); - QFETCH(qreal, contentY); - QFETCH(int, insertionIndex); - QFETCH(int, insertionCount); - QFETCH(ListRange, expectedDisplacedIndexes); - - // added items should start here - QPointF targetItems_transitionFrom(-50, -50); - - // displaced items should pass through this point - QPointF displacedItems_transitionVia(100, 100); - - QaimModel model; - for (int i = 0; i < initialItemCount; i++) - model.addItem("Original item" + QString::number(i), ""); - QaimModel model_targetItems_transitionFrom; - QaimModel model_displacedItems_transitionVia; - - QQuickView *canvas = createView(); - QDeclarativeContext *ctxt = canvas->rootContext(); - ctxt->setContextProperty("testModel", &model); - ctxt->setContextProperty("model_targetItems_transitionFrom", &model_targetItems_transitionFrom); - ctxt->setContextProperty("model_displacedItems_transitionVia", &model_displacedItems_transitionVia); - ctxt->setContextProperty("targetItems_transitionFrom", targetItems_transitionFrom); - ctxt->setContextProperty("displacedItems_transitionVia", displacedItems_transitionVia); - canvas->setSource(testFileUrl("addTransitions.qml")); - canvas->show(); - - QQuickGridView *gridview = findItem(canvas->rootObject(), "grid"); - QTRY_VERIFY(gridview != 0); - QQuickItem *contentItem = gridview->contentItem(); - QVERIFY(contentItem != 0); - QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false); - - if (contentY != 0) { - gridview->setContentY(contentY); - QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false); - } - - QList > expectedDisplacedValues = expectedDisplacedIndexes.getModelDataValues(model); - - // only target items that will become visible should be animated - QList > newData; - QList > expectedTargetData; - QList targetIndexes; - if (shouldAnimateTargets) { - for (int i=insertionIndex; i= (contentY / 60)*3 && i < qCeil((contentY + gridview->height()) / 60.0)*3) { - expectedTargetData << newData.last(); - targetIndexes << i; - } - } - QVERIFY(expectedTargetData.count() > 0); - } - - // start animation - if (!newData.isEmpty()) { - model.insertItems(insertionIndex, newData); - QTRY_COMPARE(model.count(), gridview->count()); - } - - QList targetItems = findItems(contentItem, "wrapper", targetIndexes); - - if (shouldAnimateTargets) { - QTRY_COMPARE(gridview->property("targetTransitionsDone").toInt(), expectedTargetData.count()); - QTRY_COMPARE(gridview->property("displaceTransitionsDone").toInt(), - expectedDisplacedIndexes.isValid() ? expectedDisplacedIndexes.count() : 0); - - // check the target and displaced items were animated - model_targetItems_transitionFrom.matchAgainst(expectedTargetData, "wasn't animated from target 'from' pos", "shouldn't have been animated from target 'from' pos"); - model_displacedItems_transitionVia.matchAgainst(expectedDisplacedValues, "wasn't animated with displaced anim", "shouldn't have been animated with displaced anim"); - - // check attached properties - matchItemsAndIndexes(gridview->property("targetTrans_items").toMap(), model, targetIndexes); - matchIndexLists(gridview->property("targetTrans_targetIndexes").toList(), targetIndexes); - matchItemLists(gridview->property("targetTrans_targetItems").toList(), targetItems); - if (expectedDisplacedIndexes.isValid()) { - // adjust expectedDisplacedIndexes to their final values after the move - QList displacedIndexes = adjustIndexesForAddDisplaced(expectedDisplacedIndexes.indexes, insertionIndex, insertionCount); - matchItemsAndIndexes(gridview->property("displacedTrans_items").toMap(), model, displacedIndexes); - matchIndexLists(gridview->property("displacedTrans_targetIndexes").toList(), targetIndexes); - matchItemLists(gridview->property("displacedTrans_targetItems").toList(), targetItems); - } - } else { - QTRY_COMPARE(model_targetItems_transitionFrom.count(), 0); - QTRY_COMPARE(model_displacedItems_transitionVia.count(), 0); - } - - QList items = findItems(contentItem, "wrapper"); - int firstVisibleIndex = -1; - for (int i=0; iy() >= contentY) { - QDeclarativeExpression e(qmlContext(items[i]), items[i], "index"); - firstVisibleIndex = e.evaluate().toInt(); - break; - } - } - QVERIFY2(firstVisibleIndex >= 0, QTest::toString(firstVisibleIndex)); - - // verify all items moved to the correct final positions - int itemCount = findItems(contentItem, "wrapper").count(); - for (int i = firstVisibleIndex; i < model.count() && i < itemCount; ++i) { - QQuickItem *item = findItem(contentItem, "wrapper", i); - QVERIFY2(item, QTest::toString(QString("Item %1 not found").arg(i))); - QCOMPARE(item->x(), (i%3)*80.0); - QCOMPARE(item->y(), (i/3)*60.0); - QQuickText *name = findItem(contentItem, "textName", i); - QVERIFY(name != 0); - QCOMPARE(name->text(), model.name(i)); - } - - delete canvas; -} - -void tst_QQuickGridView::addTransitions_data() -{ - QTest::addColumn("initialItemCount"); - QTest::addColumn("contentY"); - QTest::addColumn("shouldAnimateTargets"); - QTest::addColumn("insertionIndex"); - QTest::addColumn("insertionCount"); - QTest::addColumn("expectedDisplacedIndexes"); - - // if inserting a full row before visible index, items don't appear or animate in, even if there are > 1 new items - QTest::newRow("insert 1, just before start") - << 30 << 20.0 << false - << 0 << 1 << ListRange(); - QTest::newRow("insert 1, way before start") - << 30 << 20.0 << false - << 0 << 1 << ListRange(); - QTest::newRow("insert multiple, just before start") - << 30 << 100.0 << false - << 0 << 3 << ListRange(); - QTest::newRow("insert multiple (< 1 row), just before start") - << 30 << 100.0 << false - << 0 << 2 << ListRange(); - QTest::newRow("insert multiple, way before start") - << 30 << 100.0 << false - << 0 << 3 << ListRange(); - - QTest::newRow("insert 1 at start") - << 30 << 0.0 << true - << 0 << 1 << ListRange(0, 17); - QTest::newRow("insert multiple at start") - << 30 << 0.0 << true - << 0 << 3 << ListRange(0, 17); - QTest::newRow("insert multiple (> 1 row) at start") - << 30 << 0.0 << true - << 0 << 5 << ListRange(0, 17); - QTest::newRow("insert 1 at start, content y not 0") - << 30 << 60.0 << true // first visible is index 3 - << 3 << 1 << ListRange(0 + 3, 17 + 3); - QTest::newRow("insert multiple at start, content y not 0") - << 30 << 60.0 << true // first visible is index 3 - << 3 << 3 << ListRange(0 + 3, 17 + 3); - QTest::newRow("insert multiple (> 1 row) at start, content y not 0") - << 30 << 60.0 << true // first visible is index 3 - << 3 << 5 << ListRange(0 + 3, 17 + 3); - - QTest::newRow("insert 1 at start, to empty grid") - << 0 << 0.0 << true - << 0 << 1 << ListRange(); - QTest::newRow("insert multiple at start, to empty grid") - << 0 << 0.0 << true - << 0 << 3 << ListRange(); - - QTest::newRow("insert 1 at middle") - << 30 << 0.0 << true - << 7 << 1 << ListRange(7, 17); - QTest::newRow("insert multiple at middle") - << 30 << 0.0 << true - << 7 << 3 << ListRange(7, 17); - QTest::newRow("insert multiple (> 1 row) at middle") - << 30 << 0.0 << true - << 7 << 5 << ListRange(7, 17); - - QTest::newRow("insert 1 at bottom") - << 30 << 0.0 << true - << 17 << 1 << ListRange(17, 17); - QTest::newRow("insert multiple at bottom") - << 30 << 0.0 << true - << 17 << 3 << ListRange(17, 17); - QTest::newRow("insert 1 at bottom, content y not 0") - << 30 << 20.0 * 3 << true - << 17 + 3 << 1 << ListRange(17 + 3, 17 + 3); - QTest::newRow("insert multiple at bottom, content y not 0") - << 30 << 20.0 * 3 << true - << 17 + 3 << 3 << ListRange(17 + 3, 17 + 3); - - - // items added after the last visible will not be animated in, since they - // do not appear in the final view - QTest::newRow("insert 1 after end") - << 30 << 0.0 << false - << 18 << 1 << ListRange(); - QTest::newRow("insert multiple after end") - << 30 << 0.0 << false - << 18 << 3 << ListRange(); -} - -void tst_QQuickGridView::moveTransitions() -{ - QFETCH(int, initialItemCount); - QFETCH(qreal, contentY); - QFETCH(qreal, itemsOffsetAfterMove); - QFETCH(int, moveFrom); - QFETCH(int, moveTo); - QFETCH(int, moveCount); - QFETCH(ListRange, expectedDisplacedIndexes); - - // target and displaced items should pass through these points - QPointF targetItems_transitionVia(-50, 50); - QPointF displacedItems_transitionVia(100, 100); - - QaimModel model; - for (int i = 0; i < initialItemCount; i++) - model.addItem("Original item" + QString::number(i), ""); - QaimModel model_targetItems_transitionVia; - QaimModel model_displacedItems_transitionVia; - - QQuickView *canvas = createView(); - QDeclarativeContext *ctxt = canvas->rootContext(); - ctxt->setContextProperty("testModel", &model); - ctxt->setContextProperty("model_targetItems_transitionVia", &model_targetItems_transitionVia); - ctxt->setContextProperty("model_displacedItems_transitionVia", &model_displacedItems_transitionVia); - ctxt->setContextProperty("targetItems_transitionVia", targetItems_transitionVia); - ctxt->setContextProperty("displacedItems_transitionVia", displacedItems_transitionVia); - canvas->setSource(testFileUrl("moveTransitions.qml")); - canvas->show(); - - QQuickGridView *gridview = findItem(canvas->rootObject(), "grid"); - QTRY_VERIFY(gridview != 0); - QQuickItem *contentItem = gridview->contentItem(); - QVERIFY(contentItem != 0); - QQuickText *name; - - if (contentY != 0) { - gridview->setContentY(contentY); - QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false); - } - - QList > expectedDisplacedValues = expectedDisplacedIndexes.getModelDataValues(model); - - // Items moving to *or* from visible positions should be animated. - // Otherwise, they should not be animated. - QList > expectedTargetData; - QList targetIndexes; - for (int i=moveFrom; iheight()) / 60.0)*3) - 1; - if ((i >= firstVisibleIndex && i <= lastVisibleIndex) - || (toIndex >= firstVisibleIndex && toIndex <= lastVisibleIndex)) { - expectedTargetData << qMakePair(model.name(i), model.number(i)); - targetIndexes << i; - } - } - // ViewTransition.index provides the indices that items are moving to, not from - targetIndexes = adjustIndexesForMove(targetIndexes, moveFrom, moveTo, moveCount); - - // start animation - model.moveItems(moveFrom, moveTo, moveCount); - - QTRY_COMPARE(gridview->property("targetTransitionsDone").toInt(), expectedTargetData.count()); - QTRY_COMPARE(gridview->property("displaceTransitionsDone").toInt(), - expectedDisplacedIndexes.isValid() ? expectedDisplacedIndexes.count() : 0); - - QList targetItems = findItems(contentItem, "wrapper", targetIndexes); - - // check the target and displaced items were animated - model_targetItems_transitionVia.matchAgainst(expectedTargetData, "wasn't animated from target 'from' pos", "shouldn't have been animated from target 'from' pos"); - model_displacedItems_transitionVia.matchAgainst(expectedDisplacedValues, "wasn't animated with displaced anim", "shouldn't have been animated with displaced anim"); - - // check attached properties - matchItemsAndIndexes(gridview->property("targetTrans_items").toMap(), model, targetIndexes); - matchIndexLists(gridview->property("targetTrans_targetIndexes").toList(), targetIndexes); - matchItemLists(gridview->property("targetTrans_targetItems").toList(), targetItems); - if (expectedDisplacedIndexes.isValid()) { - // adjust expectedDisplacedIndexes to their final values after the move - QList displacedIndexes = adjustIndexesForMove(expectedDisplacedIndexes.indexes, moveFrom, moveTo, moveCount); - matchItemsAndIndexes(gridview->property("displacedTrans_items").toMap(), model, displacedIndexes); - matchIndexLists(gridview->property("displacedTrans_targetIndexes").toList(), targetIndexes); - matchItemLists(gridview->property("displacedTrans_targetItems").toList(), targetItems); - } - - QList items = findItems(contentItem, "wrapper"); - int firstVisibleIndex = -1; - for (int i=0; iy() >= contentY) { - QDeclarativeExpression e(qmlContext(items[i]), items[i], "index"); - firstVisibleIndex = e.evaluate().toInt(); - break; - } - } - QVERIFY2(firstVisibleIndex >= 0, QTest::toString(firstVisibleIndex)); - - // verify all items moved to the correct final positions - int itemCount = findItems(contentItem, "wrapper").count(); - for (int i=firstVisibleIndex; i < model.count() && i < itemCount; ++i) { - QQuickItem *item = findItem(contentItem, "wrapper", i); - QVERIFY2(item, QTest::toString(QString("Item %1 not found").arg(i))); - QCOMPARE(item->x(), (i%3)*80.0); - QCOMPARE(item->y(), (i/3)*60.0 + itemsOffsetAfterMove); - name = findItem(contentItem, "textName", i); - QVERIFY(name != 0); - QTRY_COMPARE(name->text(), model.name(i)); - } - - delete canvas; -} - -void tst_QQuickGridView::moveTransitions_data() -{ - QTest::addColumn("initialItemCount"); - QTest::addColumn("contentY"); - QTest::addColumn("itemsOffsetAfterMove"); - QTest::addColumn("moveFrom"); - QTest::addColumn("moveTo"); - QTest::addColumn("moveCount"); - QTest::addColumn("expectedDisplacedIndexes"); - - QTest::newRow("move from above view, outside visible items, move 1") << 30 << 120.0 << 0.0 - << 1 << 10 << 1 << ListRange(6, 10); - QTest::newRow("move from above view, outside visible items, move 1 (first item)") << 30 << 120.0 << 0.0 - << 0 << 10 << 1 << ListRange(6, 10); - QTest::newRow("move from above view, outside visible items, move multiple") << 30 << 120.0 << 60.0 - << 1 << 10 << 3 << ListRange(13, 23); - QTest::newRow("move from above view, mix of visible/non-visible") << 30 << 120.0 << 60.0 - << 1 << 10 << 6 << (ListRange(7, 15) + ListRange(16, 23)); - QTest::newRow("move from above view, mix of visible/non-visible (move first)") << 30 << 120.0 << 120.0 - << 0 << 10 << 6 << ListRange(16, 23); - - QTest::newRow("move within view, move 1 down") << 30 << 0.0 << 0.0 - << 1 << 10 << 1 << ListRange(2, 10); - QTest::newRow("move within view, move 1 down, move first item") << 30 << 0.0 << 0.0 - << 0 << 10 << 1 << ListRange(1, 10); - QTest::newRow("move within view, move 1 down, move first item, contentY not 0") << 30 << 120.0 << 0.0 - << 0+6 << 10+6 << 1 << ListRange(1+6, 10+6); - QTest::newRow("move within view, move 1 down, to last item") << 30 << 0.0 << 0.0 - << 10 << 17 << 1 << ListRange(11, 17); - QTest::newRow("move within view, move first->last") << 30 << 0.0 << 0.0 - << 0 << 17 << 1 << ListRange(1, 17); - - QTest::newRow("move within view, move multiple down") << 30 << 0.0 << 0.0 - << 1 << 10 << 3 << ListRange(4, 12); - QTest::newRow("move within view, move multiple down, move first item") << 30 << 0.0 << 0.0 - << 0 << 10 << 3 << ListRange(3, 12); - QTest::newRow("move within view, move multiple down, move first item, contentY not 0") << 30 << 60.0 << 0.0 - << 0+3 << 10+3 << 3 << ListRange(3+3, 12+3); - QTest::newRow("move within view, move multiple down, displace last item") << 30 << 0.0 << 0.0 - << 5 << 15 << 3 << ListRange(8, 17); - QTest::newRow("move within view, move multiple down, move first->last") << 30 << 0.0 << 0.0 - << 0 << 15 << 3 << ListRange(3, 17); - - QTest::newRow("move within view, move 1 up") << 30 << 0.0 << 0.0 - << 10 << 1 << 1 << ListRange(1, 9); - QTest::newRow("move within view, move 1 up, move to first index") << 30 << 0.0 << 0.0 - << 10 << 0 << 1 << ListRange(0, 9); - QTest::newRow("move within view, move 1 up, move to first index, contentY not 0") << 30 << 120.0 << 0.0 - << 10+6 << 0+6 << 1 << ListRange(0+6, 9+6); - QTest::newRow("move within view, move 1 up, move to first index, contentY not on item border") << 30 << 80.0 << 0.0 - << 10+3 << 0+3 << 1 << ListRange(0+3, 9+3); - QTest::newRow("move within view, move 1 up, move last item") << 30 << 0.0 << 0.0 - << 17 << 10 << 1 << ListRange(10, 16); - QTest::newRow("move within view, move 1 up, move last->first") << 30 << 0.0 << 0.0 - << 17 << 0 << 1 << ListRange(0, 16); - - QTest::newRow("move within view, move multiple up") << 30 << 0.0 << 0.0 - << 10 << 1 << 3 << ListRange(1, 9); - QTest::newRow("move within view, move multiple (> 1 row) up") << 30 << 0.0 << 0.0 - << 10 << 1 << 5 << ListRange(1, 9); - QTest::newRow("move within view, move multiple up, move to first index") << 30 << 0.0 << 0.0 - << 10 << 0 << 3 << ListRange(0, 9); - QTest::newRow("move within view, move multiple up, move to first index, contentY not 0") << 30 << 60.0 << 0.0 - << 10+3 << 0+3 << 3 << ListRange(0+3, 9+3); - QTest::newRow("move within view, move multiple up (> 1 row), move to first index, contentY not on border") << 30 << 80.0 << 0.0 - << 10+3 << 0+3 << 5 << ListRange(0+3, 9+3); - QTest::newRow("move within view, move multiple up, move last item") << 30 << 0.0 << 0.0 - << 15 << 5 << 3 << ListRange(5, 14); - QTest::newRow("move within view, move multiple up, move last->first") << 30 << 0.0 << 0.0 - << 15 << 0 << 3 << ListRange(0, 14); - - QTest::newRow("move from below view, move 1 up") << 30 << 0.0 << 0.0 - << 20 << 5 << 1 << ListRange(5, 17); - QTest::newRow("move from below view, move 1 up, move to top") << 30 << 0.0 << 0.0 - << 20 << 0 << 1 << ListRange(0, 17); - QTest::newRow("move from below view, move 1 up, move to top, contentY not 0") << 30 << 60.0 << 0.0 - << 25 << 3 << 1 << ListRange(0+3, 17+3); - QTest::newRow("move from below view, move multiple (> 1 row) up") << 30 << 0.0 << 0.0 - << 20 << 5 << 5 << ListRange(5, 17); - QTest::newRow("move from below view, move multiple up, move to top") << 30 << 0.0 << 0.0 - << 20 << 0 << 3 << ListRange(0, 17); - QTest::newRow("move from below view, move multiple up, move to top, contentY not 0") << 30 << 60.0 << 0.0 - << 25 << 3 << 3 << ListRange(0+3, 17+3); - - QTest::newRow("move from below view, move 1 up, move to bottom") << 30 << 0.0 << 0.0 - << 20 << 17 << 1 << ListRange(17, 17); - QTest::newRow("move from below view, move 1 up, move to bottom, contentY not 0") << 30 << 60.0 << 0.0 - << 25 << 17+3 << 1 << ListRange(17+3, 17+3); - QTest::newRow("move from below view, move multiple up, move to to bottom") << 30 << 0.0 << 0.0 - << 20 << 17 << 3 << ListRange(17, 17); - QTest::newRow("move from below view, move multiple up, move to bottom, contentY not 0") << 30 << 60.0 << 0.0 - << 25 << 17+3 << 3 << ListRange(17+3, 17+3); -} - -void tst_QQuickGridView::removeTransitions() -{ - QFETCH(int, initialItemCount); - QFETCH(bool, shouldAnimateTargets); - QFETCH(qreal, contentY); - QFETCH(int, removalIndex); - QFETCH(int, removalCount); - QFETCH(ListRange, expectedDisplacedIndexes); - - // added items should end here - QPointF targetItems_transitionTo(-50, -50); - - // displaced items should pass through this points - QPointF displacedItems_transitionVia(100, 100); - - QaimModel model; - for (int i = 0; i < initialItemCount; i++) - model.addItem("Original item" + QString::number(i), ""); - QaimModel model_targetItems_transitionTo; - QaimModel model_displacedItems_transitionVia; - - QQuickView *canvas = createView(); - QDeclarativeContext *ctxt = canvas->rootContext(); - ctxt->setContextProperty("testModel", &model); - ctxt->setContextProperty("model_targetItems_transitionTo", &model_targetItems_transitionTo); - ctxt->setContextProperty("model_displacedItems_transitionVia", &model_displacedItems_transitionVia); - ctxt->setContextProperty("targetItems_transitionTo", targetItems_transitionTo); - ctxt->setContextProperty("displacedItems_transitionVia", displacedItems_transitionVia); - canvas->setSource(testFileUrl("removeTransitions.qml")); - canvas->show(); - - QQuickGridView *gridview = findItem(canvas->rootObject(), "grid"); - QTRY_VERIFY(gridview != 0); - QQuickItem *contentItem = gridview->contentItem(); - QVERIFY(contentItem != 0); - QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false); - - if (contentY != 0) { - gridview->setContentY(contentY); - QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false); - } - - QList > expectedDisplacedValues = expectedDisplacedIndexes.getModelDataValues(model); - - // only target items that are visible should be animated - QList > expectedTargetData; - QList targetIndexes; - if (shouldAnimateTargets) { - for (int i=removalIndex; iheight()) / 60.0)*3) - 1; - if (i >= firstVisibleIndex && i <= lastVisibleIndex) { - expectedTargetData << qMakePair(model.name(i), model.number(i)); - targetIndexes << i; - } - } - QVERIFY(expectedTargetData.count() > 0); - } - - // calculate targetItems and expectedTargets before model changes - QList targetItems = findItems(contentItem, "wrapper", targetIndexes); - QVariantMap expectedTargets; - for (int i=0; icount()); - - if (shouldAnimateTargets || expectedDisplacedIndexes.isValid()) { - QTRY_COMPARE(gridview->property("targetTransitionsDone").toInt(), expectedTargetData.count()); - QTRY_COMPARE(gridview->property("displaceTransitionsDone").toInt(), - expectedDisplacedIndexes.isValid() ? expectedDisplacedIndexes.count() : 0); - - // check the target and displaced items were animated - model_targetItems_transitionTo.matchAgainst(expectedTargetData, "wasn't animated to target 'to' pos", "shouldn't have been animated to target 'to' pos"); - model_displacedItems_transitionVia.matchAgainst(expectedDisplacedValues, "wasn't animated with displaced anim", "shouldn't have been animated with displaced anim"); - - // check attached properties - QCOMPARE(gridview->property("targetTrans_items").toMap(), expectedTargets); - matchIndexLists(gridview->property("targetTrans_targetIndexes").toList(), targetIndexes); - matchItemLists(gridview->property("targetTrans_targetItems").toList(), targetItems); - if (expectedDisplacedIndexes.isValid()) { - // adjust expectedDisplacedIndexes to their final values after the move - QList displacedIndexes = adjustIndexesForRemoveDisplaced(expectedDisplacedIndexes.indexes, removalIndex, removalCount); - matchItemsAndIndexes(gridview->property("displacedTrans_items").toMap(), model, displacedIndexes); - matchIndexLists(gridview->property("displacedTrans_targetIndexes").toList(), targetIndexes); - matchItemLists(gridview->property("displacedTrans_targetItems").toList(), targetItems); - } - } else { - QTRY_COMPARE(model_targetItems_transitionTo.count(), 0); - QTRY_COMPARE(model_displacedItems_transitionVia.count(), 0); - } - - QList items = findItems(contentItem, "wrapper"); - int itemCount = items.count(); - int firstVisibleIndex = -1; - for (int i=0; iy() >= contentY) - firstVisibleIndex = index; - else if (index < 0) - itemCount--; // exclude deleted items - } - QVERIFY2(firstVisibleIndex >= 0, QTest::toString(firstVisibleIndex)); - - // verify all items moved to the correct final positions - for (int i=firstVisibleIndex; i < model.count() && i < itemCount; ++i) { - QQuickItem *item = findItem(contentItem, "wrapper", i); - QVERIFY2(item, QTest::toString(QString("Item %1 not found").arg(i))); - QCOMPARE(item->x(), (i%3)*80.0); - QCOMPARE(item->y(), contentY + ((i-firstVisibleIndex)/3) * 60.0); - QQuickText *name = findItem(contentItem, "textName", i); - QVERIFY(name != 0); - QTRY_COMPARE(name->text(), model.name(i)); - } - - delete canvas; -} - -void tst_QQuickGridView::removeTransitions_data() -{ - QTest::addColumn("initialItemCount"); - QTest::addColumn("contentY"); - QTest::addColumn("shouldAnimateTargets"); - QTest::addColumn("removalIndex"); - QTest::addColumn("removalCount"); - QTest::addColumn("expectedDisplacedIndexes"); - - // All items that are visible following the remove operation should be animated. - // Remove targets that are outside of the view should not be animated. - - // For a GridView, removing any number of items other than a full row before the start - // should displace all items in the view - QTest::newRow("remove 1 before start") - << 30 << 120.0 << false - << 2 << 1 << ListRange(6, 24); // 6-24 are displaced - QTest::newRow("remove 1 row, before start") - << 30 << 120.0 << false - << 3 << 3 << ListRange(); - QTest::newRow("remove between 1-2 rows, before start") - << 30 << 120.0 << false - << 0 << 5 << ListRange(6, 25); - QTest::newRow("remove 2 rows, before start") - << 30 << 120.0 << false - << 0 << 6 << ListRange(); - QTest::newRow("remove mix of before and after start") - << 30 << 60.0 << true - << 2 << 3 << ListRange(5, 23); // 5-23 are displaced into view - - - QTest::newRow("remove 1 from start") - << 30 << 0.0 << true - << 0 << 1 << ListRange(1, 18); // 1-18 are displaced into view - QTest::newRow("remove multiple from start") - << 30 << 0.0 << true - << 0 << 3 << ListRange(3, 20); // 3-18 are displaced into view - QTest::newRow("remove 1 from start, content y not 0") - << 30 << 60.0 << true - << 3 << 1 << ListRange(1 + 3, 18 + 3); - QTest::newRow("remove multiple from start, content y not 0") - << 30 << 60.0 << true - << 3 << 3 << ListRange(3 + 3, 20 + 3); - - - QTest::newRow("remove 1 from middle") - << 30 << 0.0 << true - << 5 << 1 << ListRange(6, 18); - QTest::newRow("remove multiple from middle") - << 30 << 0.0 << true - << 5 << 3 << ListRange(8, 20); - - - QTest::newRow("remove 1 from bottom") - << 30 << 0.0 << true - << 17 << 1 << ListRange(18, 18); - QTest::newRow("remove multiple (1 row) from bottom") - << 30 << 0.0 << true - << 15 << 3 << ListRange(18, 20); - QTest::newRow("remove multiple (> 1 row) from bottom") - << 30 << 0.0 << true - << 15 << 5 << ListRange(20, 22); - QTest::newRow("remove 1 from bottom, content y not 0") - << 30 << 60.0 << true - << 17 + 3 << 1 << ListRange(18 + 3, 18 + 3); - QTest::newRow("remove multiple (1 row) from bottom, content y not 0") - << 30 << 60.0 << true - << 15 + 3 << 3 << ListRange(18 + 3, 20 + 3); - - - QTest::newRow("remove 1 after end") - << 30 << 0.0 << false - << 18 << 1 << ListRange(); - QTest::newRow("remove multiple after end") - << 30 << 0.0 << false - << 18 << 3 << ListRange(); -} - -void tst_QQuickGridView::multipleTransitions() -{ - // Tests that if you interrupt a transition in progress with another action that - // cancels the previous transition, the resulting items are still placed correctly. - - QFETCH(int, initialCount); - QFETCH(qreal, contentY); - QFETCH(QList, changes); - - // add transitions on the left, moves on the right - QPointF addTargets_transitionFrom(-50, -50); - QPointF addDisplaced_transitionFrom(-50, 50); - QPointF moveTargets_transitionFrom(50, -50); - QPointF moveDisplaced_transitionFrom(50, 50); - - QmlListModel model; - for (int i = 0; i < initialCount; i++) - model.addItem("Original item" + QString::number(i), ""); - - QQuickView *canvas = createView(); - QDeclarativeContext *ctxt = canvas->rootContext(); - ctxt->setContextProperty("testModel", &model); - ctxt->setContextProperty("addTargets_transitionFrom", addTargets_transitionFrom); - ctxt->setContextProperty("addDisplaced_transitionFrom", addDisplaced_transitionFrom); - ctxt->setContextProperty("moveTargets_transitionFrom", moveTargets_transitionFrom); - ctxt->setContextProperty("moveDisplaced_transitionFrom", moveDisplaced_transitionFrom); - canvas->setSource(testFileUrl("multipleTransitions.qml")); - canvas->show(); - - QQuickGridView *gridview = findItem(canvas->rootObject(), "grid"); - QTRY_VERIFY(gridview != 0); - QQuickItem *contentItem = gridview->contentItem(); - QVERIFY(contentItem != 0); - QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false); - - int timeBetweenActions = canvas->rootObject()->property("timeBetweenActions").toInt(); - - QList > targetItems; - for (int i=0; icount()); - QTRY_VERIFY(gridview->property("runningAddTargets").toBool()); - QTRY_VERIFY(gridview->property("runningAddDisplaced").toBool()); - if (i == changes.count() - 1) { - QTRY_VERIFY(!gridview->property("runningAddTargets").toBool()); - QTRY_VERIFY(!gridview->property("runningAddDisplaced").toBool()); - } else { - QTest::qWait(timeBetweenActions); - } - break; - } - case ListChange::Removed: - for (int j=changes[i].index; jcount()); - QTRY_VERIFY(gridview->property("runningRemoveTargets").toBool()); - QTRY_VERIFY(gridview->property("runningRemoveDisplaced").toBool()); - if (i == changes.count() - 1) { - QTRY_VERIFY(!gridview->property("runningRemoveTargets").toBool()); - QTRY_VERIFY(!gridview->property("runningRemoveDisplaced").toBool()); - } else { - QTest::qWait(timeBetweenActions); - } - break; - case ListChange::Moved: - for (int j=changes[i].index; jproperty("runningMoveTargets").toBool()); - QTRY_VERIFY(gridview->property("runningMoveDisplaced").toBool()); - if (i == changes.count() - 1) { - QTRY_VERIFY(!gridview->property("runningMoveTargets").toBool()); - QTRY_VERIFY(!gridview->property("runningMoveDisplaced").toBool()); - } else { - QTest::qWait(timeBetweenActions); - } - break; - case ListChange::SetCurrent: - gridview->setCurrentIndex(changes[i].index); - QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false); - break; - case ListChange::SetContentY: - gridview->setContentY(changes[i].pos); - QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false); - break; - } - } - QCOMPARE(gridview->count(), model.count()); - - QList items = findItems(contentItem, "wrapper"); - int firstVisibleIndex = -1; - for (int i=0; iy() >= contentY) { - QDeclarativeExpression e(qmlContext(items[i]), items[i], "index"); - firstVisibleIndex = e.evaluate().toInt(); - break; - } - } - QVERIFY2(firstVisibleIndex >= 0, QTest::toString(firstVisibleIndex)); - - // verify all items moved to the correct final positions - int itemCount = findItems(contentItem, "wrapper").count(); - for (int i=firstVisibleIndex; i < model.count() && i < itemCount; ++i) { - QQuickItem *item = findItem(contentItem, "wrapper", i); - QVERIFY2(item, QTest::toString(QString("Item %1 not found").arg(i))); - QCOMPARE(item->x(), (i%3)*80.0); - QCOMPARE(item->y(), (i/3)*60.0); - QQuickText *name = findItem(contentItem, "textName", i); - QVERIFY(name != 0); - QTRY_COMPARE(name->text(), model.name(i)); - } - - delete canvas; -} - -void tst_QQuickGridView::multipleTransitions_data() -{ - QTest::addColumn("initialCount"); - QTest::addColumn("contentY"); - QTest::addColumn >("changes"); - - // the added item and displaced items should move to final dest correctly - QTest::newRow("add item, then move it immediately") << 10 << 0.0 << (QList() - << ListChange::insert(0, 1) - << ListChange::move(0, 3, 1) - ); - - // items affected by the add should change from move to add transition - QTest::newRow("move, then insert item before the moved item") << 20 << 0.0 << (QList() - << ListChange::move(1, 10, 3) - << ListChange::insert(0, 1) - ); - - // items should be placed correctly if you trigger a transition then refill for that index - QTest::newRow("add at 0, flick down, flick back to top and add at 0 again") << 20 << 0.0 << (QList() - << ListChange::insert(0, 1) - << ListChange::setContentY(160.0) - << ListChange::setContentY(0.0) - << ListChange::insert(0, 1) - ); -} - -void tst_QQuickGridView::cacheBuffer() -{ - QQuickView *canvas = createView(); - - QaimModel model; - for (int i = 0; i < 90; i++) - model.addItem("Item" + QString::number(i), ""); - - QDeclarativeContext *ctxt = canvas->rootContext(); - ctxt->setContextProperty("testModel", &model); - ctxt->setContextProperty("testRightToLeft", QVariant(false)); - ctxt->setContextProperty("testTopToBottom", QVariant(false)); - - canvas->setSource(testFileUrl("gridview1.qml")); - canvas->show(); - qApp->processEvents(); - - QQuickGridView *gridview = findItem(canvas->rootObject(), "grid"); - QVERIFY(gridview != 0); - - QQuickItem *contentItem = gridview->contentItem(); - QVERIFY(contentItem != 0); - QVERIFY(gridview->delegate() != 0); - QVERIFY(gridview->model() != 0); - - // Confirm items positioned correctly - int itemCount = findItems(contentItem, "wrapper", false).count(); - for (int i = 0; i < model.count() && i < itemCount; ++i) { - QQuickItem *item = findItem(contentItem, "wrapper", i); - QTRY_COMPARE(item->x(), (i%3)*80.0); - QTRY_COMPARE(item->y(), (i/3)*60.0); - } - - QDeclarativeIncubationController controller; - canvas->engine()->setIncubationController(&controller); - - canvas->rootObject()->setProperty("cacheBuffer", 200); - QTRY_VERIFY(gridview->cacheBuffer() == 200); - - // items will be created one at a time - for (int i = itemCount; i < qMin(itemCount+9,model.count()); ++i) { - QVERIFY(findItem(gridview, "wrapper", i) == 0); - QQuickItem *item = 0; - while (!item) { - bool b = false; - controller.incubateWhile(&b); - item = findItem(gridview, "wrapper", i); - } - } - - { - bool b = true; - controller.incubateWhile(&b); - } - - int newItemCount = 0; - newItemCount = findItems(contentItem, "wrapper", false).count(); - - // Confirm items positioned correctly - for (int i = 0; i < model.count() && i < newItemCount; ++i) { - QQuickItem *item = findItem(contentItem, "wrapper", i); - QVERIFY(item); - QTRY_COMPARE(item->x(), (i%3)*80.0); - QTRY_COMPARE(item->y(), (i/3)*60.0); - } - - // move view and confirm items in view are visible immediately and outside are created async - gridview->setContentY(300); - - for (int i = 15; i < 34; ++i) { // 34 due to staggered item creation - QQuickItem *item = findItem(contentItem, "wrapper", i); - QVERIFY(item); - QTRY_COMPARE(item->x(), (i%3)*80.0); - QTRY_COMPARE(item->y(), (i/3)*60.0); - } - - QVERIFY(findItem(gridview, "wrapper", 34) == 0); - - // ensure buffered items are created - for (int i = 34; i < qMin(44,model.count()); ++i) { - QQuickItem *item = 0; - while (!item) { - qGuiApp->processEvents(); // allow refill to happen - bool b = false; - controller.incubateWhile(&b); - item = findItem(gridview, "wrapper", i); - } - } - - { - bool b = true; - controller.incubateWhile(&b); - } - - delete canvas; -} - -void tst_QQuickGridView::asynchronous() -{ - QQuickView *canvas = createView(); - canvas->show(); - QDeclarativeIncubationController controller; - canvas->engine()->setIncubationController(&controller); - - canvas->setSource(testFile("asyncloader.qml")); - - QQuickItem *rootObject = qobject_cast(canvas->rootObject()); - QVERIFY(rootObject); - - QQuickGridView *gridview = 0; - while (!gridview) { - bool b = false; - controller.incubateWhile(&b); - gridview = rootObject->findChild("view"); - } - - // items will be created one at a time - for (int i = 0; i < 12; ++i) { - QVERIFY(findItem(gridview, "wrapper", i) == 0); - QQuickItem *item = 0; - while (!item) { - bool b = false; - controller.incubateWhile(&b); - item = findItem(gridview, "wrapper", i); - } - } - - { - bool b = true; - controller.incubateWhile(&b); - } - - // verify positioning - QQuickItem *contentItem = gridview->contentItem(); - for (int i = 0; i < 12; ++i) { - QQuickItem *item = findItem(contentItem, "wrapper", i); - if (!item) qWarning() << "Item" << i << "not found"; - QVERIFY(item->x() == (i%3)*100); - QVERIFY(item->y() == (i/3)*100); - } - - delete canvas; -} - -void tst_QQuickGridView::unrequestedVisibility() -{ - QaimModel model; - for (int i = 0; i < 30; i++) - model.addItem("Item" + QString::number(i), QString::number(i)); - - QQuickView *canvas = new QQuickView(0); - canvas->setGeometry(0,0,240,320); - - QDeclarativeContext *ctxt = canvas->rootContext(); - ctxt->setContextProperty("testModel", &model); - ctxt->setContextProperty("testWrap", QVariant(false)); - - canvas->setSource(testFileUrl("unrequestedItems.qml")); - - canvas->show(); - - qApp->processEvents(); - - QQuickGridView *leftview = findItem(canvas->rootObject(), "leftGrid"); - QTRY_VERIFY(leftview != 0); - - QQuickGridView *rightview = findItem(canvas->rootObject(), "rightGrid"); - QTRY_VERIFY(rightview != 0); - - QQuickItem *leftContent = leftview->contentItem(); - QTRY_VERIFY(leftContent != 0); - - QQuickItem *rightContent = rightview->contentItem(); - QTRY_VERIFY(rightContent != 0); - - rightview->setCurrentIndex(12); - - QTRY_COMPARE(leftview->contentY(), 0.0); - QTRY_COMPARE(rightview->contentY(), 240.0); - - QQuickItem *item; - - QVERIFY(item = findItem(leftContent, "wrapper", 1)); - QCOMPARE(item->isVisible(), true); - QVERIFY(item = findItem(rightContent, "wrapper", 1)); - QCOMPARE(item->isVisible(), false); - - QVERIFY(item = findItem(leftContent, "wrapper", 11)); - QCOMPARE(item->isVisible(), false); - QVERIFY(item = findItem(rightContent, "wrapper", 11)); - QCOMPARE(item->isVisible(), true); - - QVERIFY(item = findItem(leftContent, "wrapper", 9)); - QCOMPARE(item->isVisible(), true); - QVERIFY(item = findItem(leftContent, "wrapper", 10)); - QCOMPARE(item->isVisible(), false); - QVERIFY(item = findItem(rightContent, "wrapper", 3)); - QCOMPARE(item->isVisible(), false); - QVERIFY(item = findItem(rightContent, "wrapper", 4)); - QCOMPARE(item->isVisible(), true); - - rightview->setCurrentIndex(0); - - QTRY_COMPARE(leftview->contentY(), 0.0); - QTRY_COMPARE(rightview->contentY(), 0.0); - - QVERIFY(item = findItem(leftContent, "wrapper", 1)); - QCOMPARE(item->isVisible(), true); - QVERIFY(item = findItem(rightContent, "wrapper", 1)); - QTRY_COMPARE(item->isVisible(), true); - - QVERIFY(!findItem(leftContent, "wrapper", 11)); - QVERIFY(!findItem(rightContent, "wrapper", 11)); - - leftview->setCurrentIndex(12); - - QTRY_COMPARE(leftview->contentY(), 240.0); - QTRY_COMPARE(rightview->contentY(), 0.0); - - QVERIFY(item = findItem(leftContent, "wrapper", 1)); - QTRY_COMPARE(item->isVisible(), false); - QVERIFY(item = findItem(rightContent, "wrapper", 1)); - QCOMPARE(item->isVisible(), true); - - QVERIFY(item = findItem(leftContent, "wrapper", 11)); - QCOMPARE(item->isVisible(), true); - QVERIFY(item = findItem(rightContent, "wrapper", 11)); - QCOMPARE(item->isVisible(), false); - - QVERIFY(item = findItem(leftContent, "wrapper", 3)); - QCOMPARE(item->isVisible(), false); - QVERIFY(item = findItem(leftContent, "wrapper", 5)); - QCOMPARE(item->isVisible(), true); - QVERIFY(item = findItem(rightContent, "wrapper", 9)); - QCOMPARE(item->isVisible(), true); - QVERIFY(item = findItem(rightContent, "wrapper", 10)); - QCOMPARE(item->isVisible(), false); - - // move a non-visible item into view - model.moveItems(10, 9, 1); - QTRY_COMPARE(QQuickItemPrivate::get(leftview)->polishScheduled, false); - - QTRY_VERIFY(item = findItem(leftContent, "wrapper", 1)); - QCOMPARE(item->isVisible(), false); - QVERIFY(item = findItem(rightContent, "wrapper", 1)); - QCOMPARE(item->isVisible(), true); - - QVERIFY(item = findItem(leftContent, "wrapper", 11)); - QCOMPARE(item->isVisible(), true); - QVERIFY(item = findItem(rightContent, "wrapper", 11)); - QCOMPARE(item->isVisible(), false); - - QVERIFY(item = findItem(leftContent, "wrapper", 3)); - QCOMPARE(item->isVisible(), false); - QVERIFY(item = findItem(leftContent, "wrapper", 5)); - QCOMPARE(item->isVisible(), true); - QVERIFY(item = findItem(rightContent, "wrapper", 9)); - QCOMPARE(item->isVisible(), true); - QVERIFY(item = findItem(rightContent, "wrapper", 10)); - QCOMPARE(item->isVisible(), false); - - // move a visible item out of view - model.moveItems(5, 3, 1); - QTRY_COMPARE(QQuickItemPrivate::get(leftview)->polishScheduled, false); - - QVERIFY(item = findItem(leftContent, "wrapper", 3)); - QCOMPARE(item->isVisible(), false); - QVERIFY(item = findItem(leftContent, "wrapper", 5)); - QCOMPARE(item->isVisible(), true); - QVERIFY(item = findItem(rightContent, "wrapper", 9)); - QCOMPARE(item->isVisible(), true); - QVERIFY(item = findItem(rightContent, "wrapper", 10)); - QCOMPARE(item->isVisible(), false); - - // move a non-visible item into view - model.moveItems(3, 5, 1); - QTRY_COMPARE(QQuickItemPrivate::get(leftview)->polishScheduled, false); - - QVERIFY(item = findItem(leftContent, "wrapper", 3)); - QCOMPARE(item->isVisible(), false); - QVERIFY(item = findItem(leftContent, "wrapper", 5)); - QCOMPARE(item->isVisible(), true); - QVERIFY(item = findItem(rightContent, "wrapper", 9)); - QCOMPARE(item->isVisible(), true); - QVERIFY(item = findItem(rightContent, "wrapper", 10)); - QCOMPARE(item->isVisible(), false); - - // move a visible item out of view - model.moveItems(9, 10, 1); - QTRY_COMPARE(QQuickItemPrivate::get(leftview)->polishScheduled, false); - - QVERIFY(item = findItem(leftContent, "wrapper", 3)); - QCOMPARE(item->isVisible(), false); - QVERIFY(item = findItem(leftContent, "wrapper", 5)); - QCOMPARE(item->isVisible(), true); - QVERIFY(item = findItem(rightContent, "wrapper", 9)); - QCOMPARE(item->isVisible(), true); - QVERIFY(item = findItem(rightContent, "wrapper", 10)); - QCOMPARE(item->isVisible(), false); - - // move a non-visible item into view - model.moveItems(10, 9, 1); - QTRY_COMPARE(QQuickItemPrivate::get(leftview)->polishScheduled, false); - - QVERIFY(item = findItem(leftContent, "wrapper", 3)); - QCOMPARE(item->isVisible(), false); - QVERIFY(item = findItem(leftContent, "wrapper", 5)); - QCOMPARE(item->isVisible(), true); - QVERIFY(item = findItem(rightContent, "wrapper", 9)); - QCOMPARE(item->isVisible(), true); - QVERIFY(item = findItem(rightContent, "wrapper", 10)); - QCOMPARE(item->isVisible(), false); - - delete canvas; -} - -QList tst_QQuickGridView::toIntList(const QVariantList &list) -{ - QList ret; - bool ok = true; - for (int i=0; i &expectedIndexes) -{ - for (int i=0; i current = indexLists[i].value >().toSet(); - if (current != expectedIndexes.toSet()) - qDebug() << "Cannot match actual targets" << current << "with expected" << expectedIndexes; - QCOMPARE(current, expectedIndexes.toSet()); - } -} - -void tst_QQuickGridView::matchItemsAndIndexes(const QVariantMap &items, const QaimModel &model, const QList &expectedIndexes) -{ - for (QVariantMap::const_iterator it = items.begin(); it != items.end(); ++it) { - QVERIFY(it.value().type() == QVariant::Int); - QString name = it.key(); - int itemIndex = it.value().toInt(); - QVERIFY2(expectedIndexes.contains(itemIndex), QTest::toString(QString("Index %1 not found in expectedIndexes").arg(itemIndex))); - if (model.name(itemIndex) != name) - qDebug() << itemIndex; - QCOMPARE(model.name(itemIndex), name); - } - QCOMPARE(items.count(), expectedIndexes.count()); -} - -void tst_QQuickGridView::matchItemLists(const QVariantList &itemLists, const QList &expectedItems) -{ - for (int i=0; i(current[j].value()); - QVERIFY2(o, QTest::toString(QString("Invalid actual item at %1").arg(j))); - QVERIFY2(expectedItems.contains(o), QTest::toString(QString("Cannot match item %1").arg(j))); - } - QCOMPARE(current.count(), expectedItems.count()); - } -} - -QTEST_MAIN(tst_QQuickGridView) - -#include "tst_qquickgridview.moc" - diff --git a/tests/auto/qtquick2/qquickimage/data/aspectratio.qml b/tests/auto/qtquick2/qquickimage/data/aspectratio.qml deleted file mode 100644 index b26f0e1f04..0000000000 --- a/tests/auto/qtquick2/qquickimage/data/aspectratio.qml +++ /dev/null @@ -1,6 +0,0 @@ -import QtQuick 2.0 - -Image { - source: "heart.png" - fillMode: Image.PreserveAspectFit; -} diff --git a/tests/auto/qtquick2/qquickimage/data/big.jpeg b/tests/auto/qtquick2/qquickimage/data/big.jpeg deleted file mode 100644 index bed7bd65c3..0000000000 Binary files a/tests/auto/qtquick2/qquickimage/data/big.jpeg and /dev/null differ diff --git a/tests/auto/qtquick2/qquickimage/data/big256.png b/tests/auto/qtquick2/qquickimage/data/big256.png deleted file mode 100644 index 1dc1596d03..0000000000 Binary files a/tests/auto/qtquick2/qquickimage/data/big256.png and /dev/null differ diff --git a/tests/auto/qtquick2/qquickimage/data/colors.png b/tests/auto/qtquick2/qquickimage/data/colors.png deleted file mode 100644 index dfb62f3d64..0000000000 Binary files a/tests/auto/qtquick2/qquickimage/data/colors.png and /dev/null differ diff --git a/tests/auto/qtquick2/qquickimage/data/colors1.png b/tests/auto/qtquick2/qquickimage/data/colors1.png deleted file mode 100644 index dfb62f3d64..0000000000 Binary files a/tests/auto/qtquick2/qquickimage/data/colors1.png and /dev/null differ diff --git a/tests/auto/qtquick2/qquickimage/data/green.png b/tests/auto/qtquick2/qquickimage/data/green.png deleted file mode 100644 index 0a2e153ba1..0000000000 Binary files a/tests/auto/qtquick2/qquickimage/data/green.png and /dev/null differ diff --git a/tests/auto/qtquick2/qquickimage/data/heart-win32.png b/tests/auto/qtquick2/qquickimage/data/heart-win32.png deleted file mode 100644 index 351da13772..0000000000 Binary files a/tests/auto/qtquick2/qquickimage/data/heart-win32.png and /dev/null differ diff --git a/tests/auto/qtquick2/qquickimage/data/heart.png b/tests/auto/qtquick2/qquickimage/data/heart.png deleted file mode 100644 index abe97fee4b..0000000000 Binary files a/tests/auto/qtquick2/qquickimage/data/heart.png and /dev/null differ diff --git a/tests/auto/qtquick2/qquickimage/data/heart.svg b/tests/auto/qtquick2/qquickimage/data/heart.svg deleted file mode 100644 index 8c982cd93c..0000000000 --- a/tests/auto/qtquick2/qquickimage/data/heart.svg +++ /dev/null @@ -1,55 +0,0 @@ - - - - - -Heart Left-Highlight -This is a normal valentines day heart. - - -holiday -valentines - -valentine -hash(0x8a091c0) -hash(0x8a0916c) -signs_and_symbols -hash(0x8a091f0) -day - - - - -Jon Phillips - - - - -Jon Phillips - - - - -Jon Phillips - - - -image/svg+xml - - -en - - - - - - - - - - - - - - - diff --git a/tests/auto/qtquick2/qquickimage/data/heart200-win32.png b/tests/auto/qtquick2/qquickimage/data/heart200-win32.png deleted file mode 100644 index 4976ff98ba..0000000000 Binary files a/tests/auto/qtquick2/qquickimage/data/heart200-win32.png and /dev/null differ diff --git a/tests/auto/qtquick2/qquickimage/data/heart200.png b/tests/auto/qtquick2/qquickimage/data/heart200.png deleted file mode 100644 index 7fbb13c5bb..0000000000 Binary files a/tests/auto/qtquick2/qquickimage/data/heart200.png and /dev/null differ diff --git a/tests/auto/qtquick2/qquickimage/data/htiling.qml b/tests/auto/qtquick2/qquickimage/data/htiling.qml deleted file mode 100644 index f192f931c9..0000000000 --- a/tests/auto/qtquick2/qquickimage/data/htiling.qml +++ /dev/null @@ -1,11 +0,0 @@ -import QtQuick 2.0 - -Rectangle { - width: 200; height: 550 - - Image { - objectName: "tiling"; anchors.fill: parent - source: "green.png"; fillMode: Image.TileHorizontally - } -} - diff --git a/tests/auto/qtquick2/qquickimage/data/mirror.qml b/tests/auto/qtquick2/qquickimage/data/mirror.qml deleted file mode 100644 index 98fddf083e..0000000000 --- a/tests/auto/qtquick2/qquickimage/data/mirror.qml +++ /dev/null @@ -1,11 +0,0 @@ -import QtQuick 2.0 - -Rectangle { - width: 300 - height: 250 - Image { - objectName: "image" - anchors.fill: parent - source: "pattern.png" - } -} diff --git a/tests/auto/qtquick2/qquickimage/data/nullpixmap.qml b/tests/auto/qtquick2/qquickimage/data/nullpixmap.qml deleted file mode 100644 index d52f41f164..0000000000 --- a/tests/auto/qtquick2/qquickimage/data/nullpixmap.qml +++ /dev/null @@ -1,6 +0,0 @@ -import QtQuick 2.0 - -Image { - width: 10; height:10; fillMode: Image.PreserveAspectFit - source: "" -} diff --git a/tests/auto/qtquick2/qquickimage/data/pattern.png b/tests/auto/qtquick2/qquickimage/data/pattern.png deleted file mode 100644 index d3d5e1e007..0000000000 Binary files a/tests/auto/qtquick2/qquickimage/data/pattern.png and /dev/null differ diff --git a/tests/auto/qtquick2/qquickimage/data/qtbug_16389.qml b/tests/auto/qtquick2/qquickimage/data/qtbug_16389.qml deleted file mode 100644 index 7b8adecb11..0000000000 --- a/tests/auto/qtquick2/qquickimage/data/qtbug_16389.qml +++ /dev/null @@ -1,30 +0,0 @@ -import QtQuick 2.0 -Rectangle { - width: 400 - height: 400 - - Item { - anchors.top: parent.top - anchors.left: parent.left - anchors.bottom: blueHandle.top - anchors.right: blueHandle.left - - Image { - id: iconImage - objectName: "iconImage" - anchors.top: parent.top - anchors.bottom: parent.bottom - source: "heart200.png" - fillMode: Image.PreserveAspectFit - smooth: true - } - } - - Rectangle { - id: blueHandle - objectName: "blueHandle" - color: "blue" - width: 25 - height: 25 - } -} diff --git a/tests/auto/qtquick2/qquickimage/data/qtbug_22125.qml b/tests/auto/qtquick2/qquickimage/data/qtbug_22125.qml deleted file mode 100644 index 9b68c0a125..0000000000 --- a/tests/auto/qtquick2/qquickimage/data/qtbug_22125.qml +++ /dev/null @@ -1,44 +0,0 @@ -import QtQuick 2.0 - -Item { - id: root - width: 800 - height: 800 - - GridView { - anchors.fill: parent - delegate: Image { - source: imagePath; - asynchronous: true - smooth: true - width: 200 - height: 200 - } - model: ListModel { - ListElement { - imagePath: "http://127.0.0.1:14451/big256.png" - } - ListElement { - imagePath: "http://127.0.0.1:14451/big256.png" - } - ListElement { - imagePath: "http://127.0.0.1:14451/big256.png" - } - ListElement { - imagePath: "http://127.0.0.1:14451/colors.png" - } - ListElement { - imagePath: "http://127.0.0.1:14451/colors1.png" - } - ListElement { - imagePath: "http://127.0.0.1:14451/big.jpeg" - } - ListElement { - imagePath: "http://127.0.0.1:14451/heart.png" - } - ListElement { - imagePath: "http://127.0.0.1:14451/green.png" - } - } - } -} diff --git a/tests/auto/qtquick2/qquickimage/data/rect.png b/tests/auto/qtquick2/qquickimage/data/rect.png deleted file mode 100644 index d564a2d5a5..0000000000 Binary files a/tests/auto/qtquick2/qquickimage/data/rect.png and /dev/null differ diff --git a/tests/auto/qtquick2/qquickimage/data/sourceSize.qml b/tests/auto/qtquick2/qquickimage/data/sourceSize.qml deleted file mode 100644 index 8e25c254d3..0000000000 --- a/tests/auto/qtquick2/qquickimage/data/sourceSize.qml +++ /dev/null @@ -1,7 +0,0 @@ -import QtQuick 2.0 - -Image { - source: "heart.png" - sourceSize.width: srcWidth - sourceSize.height: srcHeight -} diff --git a/tests/auto/qtquick2/qquickimage/data/vtiling.qml b/tests/auto/qtquick2/qquickimage/data/vtiling.qml deleted file mode 100644 index f730f6e050..0000000000 --- a/tests/auto/qtquick2/qquickimage/data/vtiling.qml +++ /dev/null @@ -1,11 +0,0 @@ -import QtQuick 2.0 - -Rectangle { - width: 550; height: 200 - - Image { - objectName: "tiling"; anchors.fill: parent - source: "green.png"; fillMode: Image.TileVertically - } -} - diff --git a/tests/auto/qtquick2/qquickimage/qquickimage.pro b/tests/auto/qtquick2/qquickimage/qquickimage.pro deleted file mode 100644 index 43e95a2bed..0000000000 --- a/tests/auto/qtquick2/qquickimage/qquickimage.pro +++ /dev/null @@ -1,17 +0,0 @@ -CONFIG += testcase -TARGET = tst_qquickimage -macx:CONFIG -= app_bundle - -HEADERS += ../../shared/testhttpserver.h -SOURCES += tst_qquickimage.cpp \ - ../../shared/testhttpserver.cpp - -include (../../shared/util.pri) -include (../shared/util.pri) - -testDataFiles.files = data -testDataFiles.path = . -DEPLOYMENT += testDataFiles - -CONFIG += parallel_test -QT += core-private gui-private declarative-private quick-private network testlib diff --git a/tests/auto/qtquick2/qquickimage/tst_qquickimage.cpp b/tests/auto/qtquick2/qquickimage/tst_qquickimage.cpp deleted file mode 100644 index 7602f1b1d5..0000000000 --- a/tests/auto/qtquick2/qquickimage/tst_qquickimage.cpp +++ /dev/null @@ -1,749 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "../../shared/util.h" -#include "../../shared/testhttpserver.h" -#include "../shared/visualtestutil.h" - -#define SERVER_PORT 14451 -#define SERVER_ADDR "http://127.0.0.1:14451" - - -using namespace QQuickVisualTestUtil; - -Q_DECLARE_METATYPE(QQuickImageBase::Status) - -class tst_qquickimage : public QDeclarativeDataTest -{ - Q_OBJECT -public: - tst_qquickimage(); - -private slots: - void noSource(); - void imageSource(); - void imageSource_data(); - void clearSource(); - void resized(); - void preserveAspectRatio(); - void smooth(); - void mirror(); - void svg(); - void geometry(); - void geometry_data(); - void big(); - void tiling_QTBUG_6716(); - void tiling_QTBUG_6716_data(); - void noLoading(); - void paintedWidthHeight(); - void sourceSize_QTBUG_14303(); - void sourceSize_QTBUG_16389(); - void nullPixmapPaint(); - void imageCrash_QTBUG_22125(); - void sourceSize_data(); - void sourceSize(); - -private: - QDeclarativeEngine engine; -}; - -tst_qquickimage::tst_qquickimage() -{ -} - -void tst_qquickimage::noSource() -{ - QString componentStr = "import QtQuick 2.0\nImage { source: \"\" }"; - QDeclarativeComponent component(&engine); - component.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); - QQuickImage *obj = qobject_cast(component.create()); - QVERIFY(obj != 0); - QCOMPARE(obj->source(), QUrl()); - QVERIFY(obj->status() == QQuickImage::Null); - QCOMPARE(obj->width(), 0.); - QCOMPARE(obj->height(), 0.); - QCOMPARE(obj->fillMode(), QQuickImage::Stretch); - QCOMPARE(obj->progress(), 0.0); - - delete obj; -} - -void tst_qquickimage::imageSource_data() -{ - QTest::addColumn("source"); - QTest::addColumn("width"); - QTest::addColumn("height"); - QTest::addColumn("remote"); - QTest::addColumn("async"); - QTest::addColumn("cache"); - QTest::addColumn("error"); - - QTest::newRow("local") << testFileUrl("colors.png").toString() << 120.0 << 120.0 << false << false << true << ""; - QTest::newRow("local no cache") << testFileUrl("colors.png").toString() << 120.0 << 120.0 << false << false << false << ""; - QTest::newRow("local async") << testFileUrl("colors1.png").toString() << 120.0 << 120.0 << false << true << true << ""; - QTest::newRow("local not found") << testFileUrl("no-such-file.png").toString() << 0.0 << 0.0 << false - << false << true << "file::2:1: QML Image: Cannot open: " + testFileUrl("no-such-file.png").toString(); - QTest::newRow("local async not found") << testFileUrl("no-such-file-1.png").toString() << 0.0 << 0.0 << false - << true << true << "file::2:1: QML Image: Cannot open: " + testFileUrl("no-such-file-1.png").toString(); - QTest::newRow("remote") << SERVER_ADDR "/colors.png" << 120.0 << 120.0 << true << false << true << ""; - QTest::newRow("remote redirected") << SERVER_ADDR "/oldcolors.png" << 120.0 << 120.0 << true << false << false << ""; - if (QImageReader::supportedImageFormats().contains("svg")) - QTest::newRow("remote svg") << SERVER_ADDR "/heart.svg" << 550.0 << 500.0 << true << false << false << ""; - - QTest::newRow("remote not found") << SERVER_ADDR "/no-such-file.png" << 0.0 << 0.0 << true - << false << true << "file::2:1: QML Image: Error downloading " SERVER_ADDR "/no-such-file.png - server replied: Not found"; - -} - -void tst_qquickimage::imageSource() -{ - QFETCH(QString, source); - QFETCH(double, width); - QFETCH(double, height); - QFETCH(bool, remote); - QFETCH(bool, async); - QFETCH(bool, cache); - QFETCH(QString, error); - - TestHTTPServer server(SERVER_PORT); - if (remote) { - QVERIFY(server.isValid()); - server.serveDirectory(dataDirectory()); - server.addRedirect("oldcolors.png", SERVER_ADDR "/colors.png"); - } - - if (!error.isEmpty()) - QTest::ignoreMessage(QtWarningMsg, error.toUtf8()); - - QString componentStr = "import QtQuick 2.0\nImage { source: \"" + source + "\"; asynchronous: " - + (async ? QLatin1String("true") : QLatin1String("false")) + "; cache: " - + (cache ? QLatin1String("true") : QLatin1String("false")) + " }"; - QDeclarativeComponent component(&engine); - component.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); - QQuickImage *obj = qobject_cast(component.create()); - QVERIFY(obj != 0); - - if (async) - QVERIFY(obj->asynchronous() == true); - else - QVERIFY(obj->asynchronous() == false); - - if (cache) - QVERIFY(obj->cache() == true); - else - QVERIFY(obj->cache() == false); - - if (remote || async) - QTRY_VERIFY(obj->status() == QQuickImage::Loading); - - QCOMPARE(obj->source(), remote ? source : QUrl(source)); - - if (error.isEmpty()) { - QTRY_VERIFY(obj->status() == QQuickImage::Ready); - QCOMPARE(obj->width(), qreal(width)); - QCOMPARE(obj->height(), qreal(height)); - QCOMPARE(obj->fillMode(), QQuickImage::Stretch); - QCOMPARE(obj->progress(), 1.0); - } else { - QTRY_VERIFY(obj->status() == QQuickImage::Error); - } - - delete obj; -} - -void tst_qquickimage::clearSource() -{ - QString componentStr = "import QtQuick 2.0\nImage { source: srcImage }"; - QDeclarativeContext *ctxt = engine.rootContext(); - ctxt->setContextProperty("srcImage", testFileUrl("colors.png")); - QDeclarativeComponent component(&engine); - component.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); - QQuickImage *obj = qobject_cast(component.create()); - QVERIFY(obj != 0); - QVERIFY(obj->status() == QQuickImage::Ready); - QCOMPARE(obj->width(), 120.); - QCOMPARE(obj->height(), 120.); - QCOMPARE(obj->progress(), 1.0); - - ctxt->setContextProperty("srcImage", ""); - QVERIFY(obj->source().isEmpty()); - QVERIFY(obj->status() == QQuickImage::Null); - QCOMPARE(obj->width(), 0.); - QCOMPARE(obj->height(), 0.); - QCOMPARE(obj->progress(), 0.0); - - delete obj; -} - -void tst_qquickimage::resized() -{ - QString componentStr = "import QtQuick 2.0\nImage { source: \"" + testFile("colors.png") + "\"; width: 300; height: 300 }"; - QDeclarativeComponent component(&engine); - component.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); - QQuickImage *obj = qobject_cast(component.create()); - QVERIFY(obj != 0); - QCOMPARE(obj->width(), 300.); - QCOMPARE(obj->height(), 300.); - QCOMPARE(obj->fillMode(), QQuickImage::Stretch); - delete obj; -} - - -void tst_qquickimage::preserveAspectRatio() -{ - QQuickView *canvas = new QQuickView(0); - canvas->show(); - - canvas->setSource(testFileUrl("aspectratio.qml")); - QQuickImage *image = qobject_cast(canvas->rootObject()); - QVERIFY(image != 0); - image->setWidth(80.0); - QCOMPARE(image->width(), 80.); - QCOMPARE(image->height(), 80.); - - canvas->setSource(testFileUrl("aspectratio.qml")); - image = qobject_cast(canvas->rootObject()); - image->setHeight(60.0); - QVERIFY(image != 0); - QCOMPARE(image->height(), 60.); - QCOMPARE(image->width(), 60.); - delete canvas; -} - -void tst_qquickimage::smooth() -{ - QString componentStr = "import QtQuick 2.0\nImage { source: \"" + testFile("colors.png") + "\"; smooth: true; width: 300; height: 300 }"; - QDeclarativeComponent component(&engine); - component.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); - QQuickImage *obj = qobject_cast(component.create()); - QVERIFY(obj != 0); - QCOMPARE(obj->width(), 300.); - QCOMPARE(obj->height(), 300.); - QCOMPARE(obj->smooth(), true); - QCOMPARE(obj->fillMode(), QQuickImage::Stretch); - - delete obj; -} - -void tst_qquickimage::mirror() -{ - QSKIP("Test is broken on multiple levels, will need incremental fixes"); - - QMap screenshots; - QList fillModes; - fillModes << QQuickImage::Stretch << QQuickImage::PreserveAspectFit << QQuickImage::PreserveAspectCrop - << QQuickImage::Tile << QQuickImage::TileVertically << QQuickImage::TileHorizontally; - - qreal width = 300; - qreal height = 250; - - foreach (QQuickImage::FillMode fillMode, fillModes) { - QQuickView *canvas = new QQuickView; - canvas->setSource(testFileUrl("mirror.qml")); - - QQuickImage *obj = canvas->rootObject()->findChild("image"); - QVERIFY(obj != 0); - - obj->setFillMode(fillMode); - obj->setProperty("mirror", true); - canvas->show(); - - QImage screenshot = canvas->grabFrameBuffer(); - screenshots[fillMode] = screenshot; - delete canvas; - } - - foreach (QQuickImage::FillMode fillMode, fillModes) { - QPixmap srcPixmap; - QVERIFY(srcPixmap.load(testFile("pattern.png"))); - - QPixmap expected(width, height); - expected.fill(); - QPainter p_e(&expected); - QTransform transform; - transform.translate(width, 0).scale(-1, 1.0); - p_e.setTransform(transform); - - switch (fillMode) { - case QQuickImage::Stretch: - p_e.drawPixmap(QRect(0, 0, width, height), srcPixmap, QRect(0, 0, srcPixmap.width(), srcPixmap.height())); - break; - case QQuickImage::PreserveAspectFit: - p_e.drawPixmap(QRect(25, 0, height, height), srcPixmap, QRect(0, 0, srcPixmap.width(), srcPixmap.height())); - break; - case QQuickImage::PreserveAspectCrop: - { - qreal ratio = width/srcPixmap.width(); // width is the longer side - QRect rect(0, 0, srcPixmap.width()*ratio, srcPixmap.height()*ratio); - rect.moveCenter(QRect(0, 0, width, height).center()); - p_e.drawPixmap(rect, srcPixmap, QRect(0, 0, srcPixmap.width(), srcPixmap.height())); - break; - } - case QQuickImage::Tile: - p_e.drawTiledPixmap(QRect(0, 0, width, height), srcPixmap); - break; - case QQuickImage::TileVertically: - transform.scale(width / srcPixmap.width(), 1.0); - p_e.setTransform(transform); - p_e.drawTiledPixmap(QRect(0, 0, width, height), srcPixmap); - break; - case QQuickImage::TileHorizontally: - transform.scale(1.0, height / srcPixmap.height()); - p_e.setTransform(transform); - p_e.drawTiledPixmap(QRect(0, 0, width, height), srcPixmap); - break; - case QQuickImage::Pad: - break; - } - - QImage img = expected.toImage(); - QEXPECT_FAIL("", "QTBUG-21005 fails", Continue); - QCOMPARE(screenshots[fillMode], img); - } -} - -void tst_qquickimage::svg() -{ - if (!QImageReader::supportedImageFormats().contains("svg")) - QSKIP("svg support not available"); - - QString src = testFileUrl("heart.svg").toString(); - QString componentStr = "import QtQuick 2.0\nImage { source: \"" + src + "\"; sourceSize.width: 300; sourceSize.height: 300 }"; - QDeclarativeComponent component(&engine); - component.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); - QQuickImage *obj = qobject_cast(component.create()); - QVERIFY(obj != 0); - QCOMPARE(obj->width(), 300.0); - QCOMPARE(obj->height(), 300.0); - obj->setSourceSize(QSize(200,200)); - - QCOMPARE(obj->width(), 200.0); - QCOMPARE(obj->height(), 200.0); - delete obj; -} - -void tst_qquickimage::geometry_data() -{ - QTest::addColumn("fillMode"); - QTest::addColumn("explicitWidth"); - QTest::addColumn("explicitHeight"); - QTest::addColumn("itemWidth"); - QTest::addColumn("paintedWidth"); - QTest::addColumn("boundingWidth"); - QTest::addColumn("itemHeight"); - QTest::addColumn("paintedHeight"); - QTest::addColumn("boundingHeight"); - - // tested image has width 200, height 100 - - // bounding rect and item rect are equal with fillMode PreserveAspectFit, painted rect may be smaller if the aspect ratio doesn't match - QTest::newRow("PreserveAspectFit") << "PreserveAspectFit" << false << false << 200.0 << 200.0 << 200.0 << 100.0 << 100.0 << 100.0; - QTest::newRow("PreserveAspectFit explicit width 300") << "PreserveAspectFit" << true << false << 300.0 << 200.0 << 300.0 << 100.0 << 100.0 << 100.0; - QTest::newRow("PreserveAspectFit explicit height 400") << "PreserveAspectFit" << false << true << 200.0 << 200.0 << 200.0 << 400.0 << 100.0 << 400.0; - QTest::newRow("PreserveAspectFit explicit width 300, height 400") << "PreserveAspectFit" << true << true << 300.0 << 300.0 << 300.0 << 400.0 << 150.0 << 400.0; - - // bounding rect and painted rect are equal with fillMode PreserveAspectCrop, item rect may be smaller if the aspect ratio doesn't match - QTest::newRow("PreserveAspectCrop") << "PreserveAspectCrop" << false << false << 200.0 << 200.0 << 200.0 << 100.0 << 100.0 << 100.0; - QTest::newRow("PreserveAspectCrop explicit width 300") << "PreserveAspectCrop" << true << false << 300.0 << 300.0 << 300.0 << 100.0 << 150.0 << 150.0; - QTest::newRow("PreserveAspectCrop explicit height 400") << "PreserveAspectCrop" << false << true << 200.0 << 800.0 << 800.0 << 400.0 << 400.0 << 400.0; - QTest::newRow("PreserveAspectCrop explicit width 300, height 400") << "PreserveAspectCrop" << true << true << 300.0 << 800.0 << 800.0 << 400.0 << 400.0 << 400.0; - - // bounding rect, painted rect and item rect are equal in stretching and tiling images - QStringList fillModes; - fillModes << "Stretch" << "Tile" << "TileVertically" << "TileHorizontally"; - foreach (QString fillMode, fillModes) { - QTest::newRow(fillMode.toLatin1()) << fillMode << false << false << 200.0 << 200.0 << 200.0 << 100.0 << 100.0 << 100.0; - QTest::newRow(QString(fillMode + " explicit width 300").toLatin1()) << fillMode << true << false << 300.0 << 300.0 << 300.0 << 100.0 << 100.0 << 100.0; - QTest::newRow(QString(fillMode + " explicit height 400").toLatin1()) << fillMode << false << true << 200.0 << 200.0 << 200.0 << 400.0 << 400.0 << 400.0; - QTest::newRow(QString(fillMode + " explicit width 300, height 400").toLatin1()) << fillMode << true << true << 300.0 << 300.0 << 300.0 << 400.0 << 400.0 << 400.0; - } -} - -void tst_qquickimage::geometry() -{ - QFETCH(QString, fillMode); - QFETCH(bool, explicitWidth); - QFETCH(bool, explicitHeight); - QFETCH(double, itemWidth); - QFETCH(double, itemHeight); - QFETCH(double, paintedWidth); - QFETCH(double, paintedHeight); - QFETCH(double, boundingWidth); - QFETCH(double, boundingHeight); - - QString src = testFileUrl("rect.png").toString(); - QString componentStr = "import QtQuick 2.0\nImage { source: \"" + src + "\"; fillMode: Image." + fillMode + "; "; - - if (explicitWidth) - componentStr.append("width: 300; "); - if (explicitHeight) - componentStr.append("height: 400; "); - componentStr.append("}"); - QDeclarativeComponent component(&engine); - component.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); - QQuickImage *obj = qobject_cast(component.create()); - QVERIFY(obj != 0); - - QCOMPARE(obj->width(), itemWidth); - QCOMPARE(obj->paintedWidth(), paintedWidth); - QCOMPARE(obj->boundingRect().width(), boundingWidth); - - QCOMPARE(obj->height(), itemHeight); - QCOMPARE(obj->paintedHeight(), paintedHeight); - QCOMPARE(obj->boundingRect().height(), boundingHeight); - delete obj; -} - -void tst_qquickimage::big() -{ - // If the JPEG loader does not implement scaling efficiently, it would - // have to build a 400 MB image. That would be a bug in the JPEG loader. - - QString src = testFileUrl("big.jpeg").toString(); - QString componentStr = "import QtQuick 2.0\nImage { source: \"" + src + "\"; width: 100; sourceSize.height: 256 }"; - - QDeclarativeComponent component(&engine); - component.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); - QQuickImage *obj = qobject_cast(component.create()); - QVERIFY(obj != 0); - QCOMPARE(obj->width(), 100.0); - QCOMPARE(obj->height(), 256.0); - - delete obj; -} - -// As tiling_QTBUG_6716 doesn't complete, it doesn't delete the -// canvas which causes leak warnings. Use this delete on stack -// destruction pattern to work around this. -template -struct AutoDelete { - AutoDelete(T *t) : t(t) {} - ~AutoDelete() { delete t; } -private: - T *t; -}; - -void tst_qquickimage::tiling_QTBUG_6716() -{ - QSKIP("Test is broken on multiple levels, will need incremental fixes"); - - QFETCH(QString, source); - - QQuickView *canvas = new QQuickView(0); - AutoDelete del(canvas); - - canvas->setSource(testFileUrl(source)); - canvas->show(); - qApp->processEvents(); - - QQuickImage *tiling = findItem(canvas->rootObject(), "tiling"); - - QVERIFY(tiling != 0); - QImage img = canvas->grabFrameBuffer(); - for (int x = 0; x < tiling->width(); ++x) { - for (int y = 0; y < tiling->height(); ++y) { - QVERIFY(img.pixel(x, y) == qRgb(0, 255, 0)); - } - } - - delete canvas; -} - -void tst_qquickimage::tiling_QTBUG_6716_data() -{ - QTest::addColumn("source"); - QTest::newRow("vertical_tiling") << "vtiling.qml"; - QTest::newRow("horizontal_tiling") << "htiling.qml"; -} - -void tst_qquickimage::noLoading() -{ - qRegisterMetaType(); - - TestHTTPServer server(SERVER_PORT); - QVERIFY(server.isValid()); - server.serveDirectory(dataDirectory()); - server.addRedirect("oldcolors.png", SERVER_ADDR "/colors.png"); - - QString componentStr = "import QtQuick 2.0\nImage { source: srcImage; cache: true }"; - QDeclarativeContext *ctxt = engine.rootContext(); - ctxt->setContextProperty("srcImage", testFileUrl("heart.png")); - QDeclarativeComponent component(&engine); - component.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); - QQuickImage *obj = qobject_cast(component.create()); - QVERIFY(obj != 0); - QVERIFY(obj->status() == QQuickImage::Ready); - - QSignalSpy sourceSpy(obj, SIGNAL(sourceChanged(const QUrl &))); - QSignalSpy progressSpy(obj, SIGNAL(progressChanged(qreal))); - QSignalSpy statusSpy(obj, SIGNAL(statusChanged(QQuickImageBase::Status))); - - // Loading local file - ctxt->setContextProperty("srcImage", testFileUrl("green.png")); - QTRY_VERIFY(obj->status() == QQuickImage::Ready); - QTRY_VERIFY(obj->progress() == 1.0); - QTRY_COMPARE(sourceSpy.count(), 1); - QTRY_COMPARE(progressSpy.count(), 0); - QTRY_COMPARE(statusSpy.count(), 0); - - // Loading remote file - ctxt->setContextProperty("srcImage", QString(SERVER_ADDR) + "/rect.png"); - QTRY_VERIFY(obj->status() == QQuickImage::Loading); - QTRY_VERIFY(obj->progress() == 0.0); - QTRY_VERIFY(obj->status() == QQuickImage::Ready); - QTRY_VERIFY(obj->progress() == 1.0); - QTRY_COMPARE(sourceSpy.count(), 2); - QTRY_COMPARE(progressSpy.count(), 2); - QTRY_COMPARE(statusSpy.count(), 2); - - // Loading remote file again - should not go through 'Loading' state. - ctxt->setContextProperty("srcImage", testFileUrl("green.png")); - ctxt->setContextProperty("srcImage", QString(SERVER_ADDR) + "/rect.png"); - QTRY_VERIFY(obj->status() == QQuickImage::Ready); - QTRY_VERIFY(obj->progress() == 1.0); - QTRY_COMPARE(sourceSpy.count(), 4); - QTRY_COMPARE(progressSpy.count(), 2); - QTRY_COMPARE(statusSpy.count(), 2); - - delete obj; -} - -void tst_qquickimage::paintedWidthHeight() -{ - { - QString src = testFileUrl("heart.png").toString(); - QString componentStr = "import QtQuick 2.0\nImage { source: \"" + src + "\"; width: 200; height: 25; fillMode: Image.PreserveAspectFit }"; - - QDeclarativeComponent component(&engine); - component.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); - QQuickImage *obj = qobject_cast(component.create()); - QVERIFY(obj != 0); - QCOMPARE(obj->width(), 200.0); - QCOMPARE(obj->height(), 25.0); - QCOMPARE(obj->paintedWidth(), 25.0); - QCOMPARE(obj->paintedHeight(), 25.0); - - delete obj; - } - - { - QString src = testFileUrl("heart.png").toString(); - QString componentStr = "import QtQuick 2.0\nImage { source: \"" + src + "\"; width: 26; height: 175; fillMode: Image.PreserveAspectFit }"; - QDeclarativeComponent component(&engine); - component.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); - QQuickImage *obj = qobject_cast(component.create()); - QVERIFY(obj != 0); - QCOMPARE(obj->width(), 26.0); - QCOMPARE(obj->height(), 175.0); - QCOMPARE(obj->paintedWidth(), 26.0); - QCOMPARE(obj->paintedHeight(), 26.0); - - delete obj; - } -} - -void tst_qquickimage::sourceSize_QTBUG_14303() -{ - QString componentStr = "import QtQuick 2.0\nImage { source: srcImage }"; - QDeclarativeContext *ctxt = engine.rootContext(); - ctxt->setContextProperty("srcImage", testFileUrl("heart200.png")); - QDeclarativeComponent component(&engine); - component.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); - QQuickImage *obj = qobject_cast(component.create()); - - QSignalSpy sourceSizeSpy(obj, SIGNAL(sourceSizeChanged())); - - QTRY_VERIFY(obj != 0); - QTRY_VERIFY(obj->status() == QQuickImage::Ready); - - QTRY_COMPARE(obj->sourceSize().width(), 200); - QTRY_COMPARE(obj->sourceSize().height(), 200); - QTRY_COMPARE(sourceSizeSpy.count(), 0); - - ctxt->setContextProperty("srcImage", testFileUrl("colors.png")); - QTRY_COMPARE(obj->sourceSize().width(), 120); - QTRY_COMPARE(obj->sourceSize().height(), 120); - QTRY_COMPARE(sourceSizeSpy.count(), 1); - - ctxt->setContextProperty("srcImage", testFileUrl("heart200.png")); - QTRY_COMPARE(obj->sourceSize().width(), 200); - QTRY_COMPARE(obj->sourceSize().height(), 200); - QTRY_COMPARE(sourceSizeSpy.count(), 2); - - delete obj; -} - -void tst_qquickimage::sourceSize_QTBUG_16389() -{ - QQuickView *canvas = new QQuickView(0); - canvas->setSource(testFileUrl("qtbug_16389.qml")); - canvas->show(); - qApp->processEvents(); - - QQuickImage *image = findItem(canvas->rootObject(), "iconImage"); - QQuickItem *handle = findItem(canvas->rootObject(), "blueHandle"); - - QCOMPARE(image->sourceSize().width(), 200); - QCOMPARE(image->sourceSize().height(), 200); - QCOMPARE(image->paintedWidth(), 0.0); - QCOMPARE(image->paintedHeight(), 0.0); - - handle->setY(20); - - QCOMPARE(image->sourceSize().width(), 200); - QCOMPARE(image->sourceSize().height(), 200); - QCOMPARE(image->paintedWidth(), 20.0); - QCOMPARE(image->paintedHeight(), 20.0); - - delete canvas; -} - -static int numberOfWarnings = 0; -static void checkWarnings(QtMsgType, const char *msg) -{ - if (!QString(msg).contains("QGLContext::makeCurrent(): Failed.")) - numberOfWarnings++; -} - -// QTBUG-15690 -void tst_qquickimage::nullPixmapPaint() -{ - QQuickView *canvas = new QQuickView(0); - canvas->setSource(testFileUrl("nullpixmap.qml")); - canvas->show(); - - QQuickImage *image = qobject_cast(canvas->rootObject()); - QTRY_VERIFY(image != 0); - image->setSource(SERVER_ADDR + QString("/no-such-file.png")); - - QtMsgHandler previousMsgHandler = qInstallMsgHandler(checkWarnings); - - // used to print "QTransform::translate with NaN called" - QPixmap pm = QPixmap::fromImage(canvas->grabFrameBuffer()); - qInstallMsgHandler(previousMsgHandler); - QVERIFY(numberOfWarnings == 0); - delete image; - - delete canvas; -} - -void tst_qquickimage::imageCrash_QTBUG_22125() -{ - TestHTTPServer server(SERVER_PORT); - QVERIFY(server.isValid()); - server.serveDirectory(dataDirectory(), TestHTTPServer::Delay); - - { - QQuickView view(testFileUrl("qtbug_22125.qml")); - view.show(); - qApp->processEvents(); - qApp->processEvents(); - // shouldn't crash when the view drops out of scope due to - // QDeclarativePixmapData attempting to dereference a pointer to - // the destroyed reader. - } - - // shouldn't crash when deleting cancelled QDeclarativePixmapReplys. - QTest::qWait(520); // Delay mode delays for 500 ms. - QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete); - QCoreApplication::processEvents(); -} - -void tst_qquickimage::sourceSize_data() -{ - QTest::addColumn("sourceWidth"); - QTest::addColumn("sourceHeight"); - QTest::addColumn("implicitWidth"); - QTest::addColumn("implicitHeight"); - - QTest::newRow("unscaled") << 0 << 0 << 300.0 << 300.0; - QTest::newRow("scale width") << 100 << 0 << 100.0 << 100.0; - QTest::newRow("scale height") << 0 << 150 << 150.0 << 150.0; - QTest::newRow("larger sourceSize") << 400 << 400 << 300.0 << 300.0; -} - -void tst_qquickimage::sourceSize() -{ - QFETCH(int, sourceWidth); - QFETCH(int, sourceHeight); - QFETCH(qreal, implicitWidth); - QFETCH(qreal, implicitHeight); - - QQuickView *canvas = new QQuickView(0); - QDeclarativeContext *ctxt = canvas->rootContext(); - ctxt->setContextProperty("srcWidth", sourceWidth); - ctxt->setContextProperty("srcHeight", sourceHeight); - - canvas->setSource(testFileUrl("sourceSize.qml")); - canvas->show(); - qApp->processEvents(); - - QQuickImage *image = qobject_cast(canvas->rootObject()); - QVERIFY(image); - - QCOMPARE(image->sourceSize().width(), sourceWidth); - QCOMPARE(image->sourceSize().height(), sourceHeight); - QCOMPARE(image->implicitWidth(), implicitWidth); - QCOMPARE(image->implicitHeight(), implicitHeight); - - delete canvas; -} - -QTEST_MAIN(tst_qquickimage) - -#include "tst_qquickimage.moc" diff --git a/tests/auto/qtquick2/qquickitem/data/order.1.qml b/tests/auto/qtquick2/qquickitem/data/order.1.qml deleted file mode 100644 index 963288b257..0000000000 --- a/tests/auto/qtquick2/qquickitem/data/order.1.qml +++ /dev/null @@ -1,7 +0,0 @@ -import QtQuick 2.0 - -Item { - Item { objectName: "1" } - Item { objectName: "2" } - Item { objectName: "3" } -} diff --git a/tests/auto/qtquick2/qquickitem/data/order.2.qml b/tests/auto/qtquick2/qquickitem/data/order.2.qml deleted file mode 100644 index 5609c77e28..0000000000 --- a/tests/auto/qtquick2/qquickitem/data/order.2.qml +++ /dev/null @@ -1,7 +0,0 @@ -import QtQuick 2.0 - -Item { - Item { objectName: "1" } - Item { objectName: "2"; z: 1.0 } - Item { objectName: "3" } -} diff --git a/tests/auto/qtquick2/qquickitem/data/polishOnCompleted.qml b/tests/auto/qtquick2/qquickitem/data/polishOnCompleted.qml deleted file mode 100644 index 7008cdc67e..0000000000 --- a/tests/auto/qtquick2/qquickitem/data/polishOnCompleted.qml +++ /dev/null @@ -1,11 +0,0 @@ -import Qt.test 1.0 -import QtQuick 2.0 - -TestPolishItem { - width: 200 - height: 200 - - Component.onCompleted: { - doPolish() - } -} diff --git a/tests/auto/qtquick2/qquickitem/qquickitem.pro b/tests/auto/qtquick2/qquickitem/qquickitem.pro deleted file mode 100644 index 70f6b15b3d..0000000000 --- a/tests/auto/qtquick2/qquickitem/qquickitem.pro +++ /dev/null @@ -1,14 +0,0 @@ -CONFIG += testcase -TARGET = tst_qquickitem -SOURCES += tst_qquickitem.cpp - -include (../../shared/util.pri) - -macx:CONFIG -= app_bundle - -testDataFiles.files = data -testDataFiles.path = . -DEPLOYMENT += testDataFiles - -CONFIG += parallel_test -QT += core-private gui-private v8-private declarative-private quick-private widgets testlib diff --git a/tests/auto/qtquick2/qquickitem/tst_qquickitem.cpp b/tests/auto/qtquick2/qquickitem/tst_qquickitem.cpp deleted file mode 100644 index be3aef80bd..0000000000 --- a/tests/auto/qtquick2/qquickitem/tst_qquickitem.cpp +++ /dev/null @@ -1,1468 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include - -#include -#include -#include -#include -#include "private/qquickfocusscope_p.h" -#include "private/qquickitem_p.h" -#include -#include -#include "../../shared/util.h" - -class TestItem : public QQuickItem -{ -Q_OBJECT -public: - TestItem(QQuickItem *parent = 0) - : QQuickItem(parent), focused(false), pressCount(0), releaseCount(0) - , wheelCount(0), acceptIncomingTouchEvents(true) - , touchEventReached(false) {} - - bool focused; - int pressCount; - int releaseCount; - int wheelCount; - bool acceptIncomingTouchEvents; - bool touchEventReached; -protected: - virtual void focusInEvent(QFocusEvent *) { Q_ASSERT(!focused); focused = true; } - virtual void focusOutEvent(QFocusEvent *) { Q_ASSERT(focused); focused = false; } - virtual void mousePressEvent(QMouseEvent *event) { event->accept(); ++pressCount; } - virtual void mouseReleaseEvent(QMouseEvent *event) { event->accept(); ++releaseCount; } - virtual void touchEvent(QTouchEvent *event) { - touchEventReached = true; - event->setAccepted(acceptIncomingTouchEvents); - } - virtual void wheelEvent(QWheelEvent *event) { event->accept(); ++wheelCount; } -}; - -class TestCanvas: public QQuickCanvas -{ -public: - TestCanvas() - : QQuickCanvas() - {} - - virtual bool event(QEvent *event) - { - return QQuickCanvas::event(event); - } -}; - -class TestPolishItem : public QQuickItem -{ -Q_OBJECT -public: - TestPolishItem(QQuickItem *parent = 0) - : QQuickItem(parent), wasPolished(false) { - - } - - bool wasPolished; - -protected: - virtual void updatePolish() { - wasPolished = true; - } - -public slots: - void doPolish() { - polish(); - } -}; - -class TestFocusScope : public QQuickFocusScope -{ -Q_OBJECT -public: - TestFocusScope(QQuickItem *parent = 0) : QQuickFocusScope(parent), focused(false) {} - - bool focused; -protected: - virtual void focusInEvent(QFocusEvent *) { Q_ASSERT(!focused); focused = true; } - virtual void focusOutEvent(QFocusEvent *) { Q_ASSERT(focused); focused = false; } -}; - -class tst_qquickitem : public QDeclarativeDataTest -{ - Q_OBJECT -public: - -private slots: - void initTestCase(); - - void noCanvas(); - void simpleFocus(); - void scopedFocus(); - void addedToCanvas(); - void changeParent(); - - void constructor(); - void setParentItem(); - - void visible(); - void enabled(); - void enabledFocus(); - - void mouseGrab(); - void touchEventAcceptIgnore_data(); - void touchEventAcceptIgnore(); - void polishOutsideAnimation(); - void polishOnCompleted(); - - void wheelEvent_data(); - void wheelEvent(); - void hoverEvent_data(); - void hoverEvent(); - void hoverEventInParent(); - - void paintOrder_data(); - void paintOrder(); - -private: - - enum PaintOrderOp { - NoOp, Append, Remove, StackBefore, StackAfter, SetZ - }; - - void ensureFocus(QWindow *w) { - w->show(); - w->requestActivateWindow(); - qApp->processEvents(); - } -}; - -void tst_qquickitem::initTestCase() -{ - QDeclarativeDataTest::initTestCase(); - qmlRegisterType("Qt.test", 1, 0, "TestPolishItem"); -} - -// Focus has no effect when outside a canvas -void tst_qquickitem::noCanvas() -{ - QQuickItem *root = new TestItem; - QQuickItem *child = new TestItem(root); - QQuickItem *scope = new TestItem(root); - QQuickFocusScope *scopedChild = new TestFocusScope(scope); - QQuickFocusScope *scopedChild2 = new TestFocusScope(scope); - - QCOMPARE(root->hasFocus(), false); - QCOMPARE(child->hasFocus(), false); - QCOMPARE(scope->hasFocus(), false); - QCOMPARE(scopedChild->hasFocus(), false); - QCOMPARE(scopedChild2->hasFocus(), false); - - root->setFocus(true); - scope->setFocus(true); - scopedChild2->setFocus(true); - QCOMPARE(root->hasFocus(), true); - QCOMPARE(child->hasFocus(), false); - QCOMPARE(scope->hasFocus(), true); - QCOMPARE(scopedChild->hasFocus(), false); - QCOMPARE(scopedChild2->hasFocus(), true); - - root->setFocus(false); - child->setFocus(true); - scopedChild->setFocus(true); - scope->setFocus(false); - QCOMPARE(root->hasFocus(), false); - QCOMPARE(child->hasFocus(), true); - QCOMPARE(scope->hasFocus(), false); - QCOMPARE(scopedChild->hasFocus(), true); - QCOMPARE(scopedChild2->hasFocus(), true); - - delete root; -} - -struct FocusData { - FocusData() : focus(false), activeFocus(false) {} - - void set(bool f, bool af) { focus = f; activeFocus = af; } - bool focus; - bool activeFocus; -}; -struct FocusState : public QHash -{ - FocusState() : activeFocusItem(0) {} - FocusState &operator<<(QQuickItem *item) { - insert(item, FocusData()); - return *this; - } - - void active(QQuickItem *i) { - activeFocusItem = i; - } - QQuickItem *activeFocusItem; -}; - -#define FVERIFY() \ - do { \ - if (focusState.activeFocusItem) { \ - QCOMPARE(canvas.activeFocusItem(), focusState.activeFocusItem); \ - if (qobject_cast(canvas.activeFocusItem())) \ - QCOMPARE(qobject_cast(canvas.activeFocusItem())->focused, true); \ - else if (qobject_cast(canvas.activeFocusItem())) \ - QCOMPARE(qobject_cast(canvas.activeFocusItem())->focused, true); \ - } else { \ - QCOMPARE(canvas.activeFocusItem(), canvas.rootItem()); \ - } \ - for (QHash::Iterator iter = focusState.begin(); \ - iter != focusState.end(); \ - iter++) { \ - QCOMPARE(iter.key()->hasFocus(), iter.value().focus); \ - QCOMPARE(iter.key()->hasActiveFocus(), iter.value().activeFocus); \ - } \ - } while (false) - -// Tests a simple set of top-level scoped items -void tst_qquickitem::simpleFocus() -{ - QQuickCanvas canvas; - ensureFocus(&canvas); - -#ifdef Q_OS_MAC - QSKIP("QTBUG-24094: fails on Mac OS X 10.7"); -#endif - - QTRY_VERIFY(QGuiApplication::focusWindow() == &canvas); - - QQuickItem *l1c1 = new TestItem(canvas.rootItem()); - QQuickItem *l1c2 = new TestItem(canvas.rootItem()); - QQuickItem *l1c3 = new TestItem(canvas.rootItem()); - - QQuickItem *l2c1 = new TestItem(l1c1); - QQuickItem *l2c2 = new TestItem(l1c1); - QQuickItem *l2c3 = new TestItem(l1c3); - - FocusState focusState; - focusState << l1c1 << l1c2 << l1c3 - << l2c1 << l2c2 << l2c3; - FVERIFY(); - - l1c1->setFocus(true); - focusState[l1c1].set(true, true); - focusState.active(l1c1); - FVERIFY(); - - l2c3->setFocus(true); - focusState[l1c1].set(false, false); - focusState[l2c3].set(true, true); - focusState.active(l2c3); - FVERIFY(); - - l1c3->setFocus(true); - focusState[l2c3].set(false, false); - focusState[l1c3].set(true, true); - focusState.active(l1c3); - FVERIFY(); - - l1c2->setFocus(false); - FVERIFY(); - - l1c3->setFocus(false); - focusState[l1c3].set(false, false); - focusState.active(0); - FVERIFY(); - - l2c1->setFocus(true); - focusState[l2c1].set(true, true); - focusState.active(l2c1); - FVERIFY(); -} - -// Items with a focus scope -void tst_qquickitem::scopedFocus() -{ - QQuickCanvas canvas; - ensureFocus(&canvas); - QTRY_VERIFY(QGuiApplication::focusWindow() == &canvas); - - QQuickItem *l1c1 = new TestItem(canvas.rootItem()); - QQuickItem *l1c2 = new TestItem(canvas.rootItem()); - QQuickItem *l1c3 = new TestItem(canvas.rootItem()); - - QQuickItem *l2c1 = new TestItem(l1c1); - QQuickItem *l2c2 = new TestItem(l1c1); - QQuickItem *l2c3 = new TestFocusScope(l1c3); - - QQuickItem *l3c1 = new TestItem(l2c3); - QQuickItem *l3c2 = new TestFocusScope(l2c3); - - QQuickItem *l4c1 = new TestItem(l3c2); - QQuickItem *l4c2 = new TestItem(l3c2); - - FocusState focusState; - focusState << l1c1 << l1c2 << l1c3 - << l2c1 << l2c2 << l2c3 - << l3c1 << l3c2 - << l4c1 << l4c2; - FVERIFY(); - - l4c2->setFocus(true); - focusState[l4c2].set(true, false); - FVERIFY(); - - l4c1->setFocus(true); - focusState[l4c2].set(false, false); - focusState[l4c1].set(true, false); - FVERIFY(); - - l1c1->setFocus(true); - focusState[l1c1].set(true, true); - focusState.active(l1c1); - FVERIFY(); - - l3c2->setFocus(true); - focusState[l3c2].set(true, false); - FVERIFY(); - - l2c3->setFocus(true); - focusState[l1c1].set(false, false); - focusState[l2c3].set(true, true); - focusState[l3c2].set(true, true); - focusState[l4c1].set(true, true); - focusState.active(l4c1); - FVERIFY(); - - l3c2->setFocus(false); - focusState[l3c2].set(false, false); - focusState[l4c1].set(true, false); - focusState.active(l2c3); - FVERIFY(); - - l3c2->setFocus(true); - focusState[l3c2].set(true, true); - focusState[l4c1].set(true, true); - focusState.active(l4c1); - FVERIFY(); - - l4c1->setFocus(false); - focusState[l4c1].set(false, false); - focusState.active(l3c2); - FVERIFY(); - - l1c3->setFocus(true); - focusState[l1c3].set(true, true); - focusState[l2c3].set(false, false); - focusState[l3c2].set(true, false); - focusState.active(l1c3); - FVERIFY(); -} - -// Tests focus corrects itself when a tree is added to a canvas for the first time -void tst_qquickitem::addedToCanvas() -{ - { - QQuickCanvas canvas; - ensureFocus(&canvas); - QTRY_VERIFY(QGuiApplication::focusWindow() == &canvas); - - QQuickItem *item = new TestItem; - - FocusState focusState; - focusState << item; - - item->setFocus(true); - focusState[item].set(true, false); - FVERIFY(); - - item->setParentItem(canvas.rootItem()); - focusState[item].set(true, true); - focusState.active(item); - FVERIFY(); - } - - { - QQuickCanvas canvas; - ensureFocus(&canvas); - QTRY_VERIFY(QGuiApplication::focusWindow() == &canvas); - - QQuickItem *item = new TestItem(canvas.rootItem()); - - QQuickItem *tree = new TestItem; - QQuickItem *c1 = new TestItem(tree); - QQuickItem *c2 = new TestItem(tree); - - FocusState focusState; - focusState << item << tree << c1 << c2; - - item->setFocus(true); - c1->setFocus(true); - c2->setFocus(true); - focusState[item].set(true, true); - focusState[c1].set(true, false); - focusState[c2].set(true, false); - focusState.active(item); - FVERIFY(); - - tree->setParentItem(item); - focusState[c1].set(false, false); - focusState[c2].set(false, false); - FVERIFY(); - } - - { - QQuickCanvas canvas; - ensureFocus(&canvas); - QTRY_VERIFY(QGuiApplication::focusWindow() == &canvas); - - QQuickItem *tree = new TestItem; - QQuickItem *c1 = new TestItem(tree); - QQuickItem *c2 = new TestItem(tree); - - FocusState focusState; - focusState << tree << c1 << c2; - c1->setFocus(true); - c2->setFocus(true); - focusState[c1].set(true, false); - focusState[c2].set(true, false); - FVERIFY(); - - tree->setParentItem(canvas.rootItem()); - focusState[c1].set(true, true); - focusState[c2].set(false, false); - focusState.active(c1); - FVERIFY(); - } - - { - QQuickCanvas canvas; - ensureFocus(&canvas); - QTRY_VERIFY(QGuiApplication::focusWindow() == &canvas); - QQuickItem *tree = new TestFocusScope; - QQuickItem *c1 = new TestItem(tree); - QQuickItem *c2 = new TestItem(tree); - - FocusState focusState; - focusState << tree << c1 << c2; - c1->setFocus(true); - c2->setFocus(true); - focusState[c1].set(true, false); - focusState[c2].set(true, false); - FVERIFY(); - - tree->setParentItem(canvas.rootItem()); - focusState[c1].set(true, false); - focusState[c2].set(false, false); - FVERIFY(); - - tree->setFocus(true); - focusState[tree].set(true, true); - focusState[c1].set(true, true); - focusState.active(c1); - FVERIFY(); - } - - { - QQuickCanvas canvas; - ensureFocus(&canvas); - QTRY_VERIFY(QGuiApplication::focusWindow() == &canvas); - QQuickItem *tree = new TestFocusScope; - QQuickItem *c1 = new TestItem(tree); - QQuickItem *c2 = new TestItem(tree); - - FocusState focusState; - focusState << tree << c1 << c2; - tree->setFocus(true); - c1->setFocus(true); - c2->setFocus(true); - focusState[tree].set(true, false); - focusState[c1].set(true, false); - focusState[c2].set(true, false); - FVERIFY(); - - tree->setParentItem(canvas.rootItem()); - focusState[tree].set(true, true); - focusState[c1].set(true, true); - focusState[c2].set(false, false); - focusState.active(c1); - FVERIFY(); - } - - { - QQuickCanvas canvas; - ensureFocus(&canvas); - QTRY_VERIFY(QGuiApplication::focusWindow() == &canvas); - QQuickItem *child = new TestItem(canvas.rootItem()); - QQuickItem *tree = new TestFocusScope; - QQuickItem *c1 = new TestItem(tree); - QQuickItem *c2 = new TestItem(tree); - - FocusState focusState; - focusState << child << tree << c1 << c2; - child->setFocus(true); - tree->setFocus(true); - c1->setFocus(true); - c2->setFocus(true); - focusState[child].set(true, true); - focusState[tree].set(true, false); - focusState[c1].set(true, false); - focusState[c2].set(true, false); - focusState.active(child); - FVERIFY(); - - tree->setParentItem(canvas.rootItem()); - focusState[tree].set(false, false); - focusState[c1].set(true, false); - focusState[c2].set(false, false); - FVERIFY(); - - tree->setFocus(true); - focusState[child].set(false, false); - focusState[tree].set(true, true); - focusState[c1].set(true, true); - focusState.active(c1); - FVERIFY(); - } -} - -void tst_qquickitem::changeParent() -{ - // Parent to no parent - { - QQuickCanvas canvas; - ensureFocus(&canvas); - QTRY_VERIFY(QGuiApplication::focusWindow() == &canvas); - QQuickItem *child = new TestItem(canvas.rootItem()); - - FocusState focusState; - focusState << child; - FVERIFY(); - - child->setFocus(true); - focusState[child].set(true, true); - focusState.active(child); - FVERIFY(); - - child->setParentItem(0); - focusState[child].set(true, false); - focusState.active(0); - FVERIFY(); - } - - // Different parent, same focus scope - { - QQuickCanvas canvas; - ensureFocus(&canvas); - QTRY_VERIFY(QGuiApplication::focusWindow() == &canvas); - QQuickItem *child = new TestItem(canvas.rootItem()); - QQuickItem *child2 = new TestItem(canvas.rootItem()); - - FocusState focusState; - focusState << child << child2; - FVERIFY(); - - child->setFocus(true); - focusState[child].set(true, true); - focusState.active(child); - FVERIFY(); - - child->setParentItem(child2); - FVERIFY(); - } - - // Different parent, different focus scope - { - QQuickCanvas canvas; - ensureFocus(&canvas); - QTRY_VERIFY(QGuiApplication::focusWindow() == &canvas); - QQuickItem *child = new TestItem(canvas.rootItem()); - QQuickItem *child2 = new TestFocusScope(canvas.rootItem()); - QQuickItem *item = new TestItem(child); - - FocusState focusState; - focusState << child << child2 << item; - FVERIFY(); - - item->setFocus(true); - focusState[item].set(true, true); - focusState.active(item); - FVERIFY(); - - item->setParentItem(child2); - focusState[item].set(true, false); - focusState.active(0); - FVERIFY(); - } - { - QQuickCanvas canvas; - ensureFocus(&canvas); - QTRY_VERIFY(QGuiApplication::focusWindow() == &canvas); - QQuickItem *child = new TestItem(canvas.rootItem()); - QQuickItem *child2 = new TestFocusScope(canvas.rootItem()); - QQuickItem *item = new TestItem(child2); - - FocusState focusState; - focusState << child << child2 << item; - FVERIFY(); - - item->setFocus(true); - focusState[item].set(true, false); - focusState.active(0); - FVERIFY(); - - item->setParentItem(child); - focusState[item].set(true, true); - focusState.active(item); - FVERIFY(); - } - { - QQuickCanvas canvas; - ensureFocus(&canvas); - QTRY_VERIFY(QGuiApplication::focusWindow() == &canvas); - QQuickItem *child = new TestItem(canvas.rootItem()); - QQuickItem *child2 = new TestFocusScope(canvas.rootItem()); - QQuickItem *item = new TestItem(child2); - - FocusState focusState; - focusState << child << child2 << item; - FVERIFY(); - - child->setFocus(true); - item->setFocus(true); - focusState[child].set(true, true); - focusState[item].set(true, false); - focusState.active(child); - FVERIFY(); - - item->setParentItem(child); - focusState[item].set(false, false); - FVERIFY(); - } - -} - -void tst_qquickitem::constructor() -{ - QQuickItem *root = new QQuickItem; - QVERIFY(root->parent() == 0); - QVERIFY(root->parentItem() == 0); - - QQuickItem *child1 = new QQuickItem(root); - QVERIFY(child1->parent() == root); - QVERIFY(child1->parentItem() == root); - QCOMPARE(root->childItems().count(), 1); - QCOMPARE(root->childItems().at(0), child1); - - QQuickItem *child2 = new QQuickItem(root); - QVERIFY(child2->parent() == root); - QVERIFY(child2->parentItem() == root); - QCOMPARE(root->childItems().count(), 2); - QCOMPARE(root->childItems().at(0), child1); - QCOMPARE(root->childItems().at(1), child2); - - delete root; -} - -void tst_qquickitem::setParentItem() -{ - QQuickItem *root = new QQuickItem; - QVERIFY(root->parent() == 0); - QVERIFY(root->parentItem() == 0); - - QQuickItem *child1 = new QQuickItem; - QVERIFY(child1->parent() == 0); - QVERIFY(child1->parentItem() == 0); - - child1->setParentItem(root); - QVERIFY(child1->parent() == 0); - QVERIFY(child1->parentItem() == root); - QCOMPARE(root->childItems().count(), 1); - QCOMPARE(root->childItems().at(0), child1); - - QQuickItem *child2 = new QQuickItem; - QVERIFY(child2->parent() == 0); - QVERIFY(child2->parentItem() == 0); - child2->setParentItem(root); - QVERIFY(child2->parent() == 0); - QVERIFY(child2->parentItem() == root); - QCOMPARE(root->childItems().count(), 2); - QCOMPARE(root->childItems().at(0), child1); - QCOMPARE(root->childItems().at(1), child2); - - child1->setParentItem(0); - QVERIFY(child1->parent() == 0); - QVERIFY(child1->parentItem() == 0); - QCOMPARE(root->childItems().count(), 1); - QCOMPARE(root->childItems().at(0), child2); - - delete root; - - QVERIFY(child1->parent() == 0); - QVERIFY(child1->parentItem() == 0); - QVERIFY(child2->parent() == 0); - QVERIFY(child2->parentItem() == 0); - - delete child1; - delete child2; -} - -void tst_qquickitem::visible() -{ - QQuickItem *root = new QQuickItem; - - QQuickItem *child1 = new QQuickItem; - child1->setParentItem(root); - - QQuickItem *child2 = new QQuickItem; - child2->setParentItem(root); - - QVERIFY(child1->isVisible()); - QVERIFY(child2->isVisible()); - - root->setVisible(false); - QVERIFY(!child1->isVisible()); - QVERIFY(!child2->isVisible()); - - root->setVisible(true); - QVERIFY(child1->isVisible()); - QVERIFY(child2->isVisible()); - - child1->setVisible(false); - QVERIFY(!child1->isVisible()); - QVERIFY(child2->isVisible()); - - child2->setParentItem(child1); - QVERIFY(!child1->isVisible()); - QVERIFY(!child2->isVisible()); - - child2->setParentItem(root); - QVERIFY(!child1->isVisible()); - QVERIFY(child2->isVisible()); - - delete root; - delete child1; - delete child2; -} - -void tst_qquickitem::enabled() -{ - QQuickItem *root = new QQuickItem; - - QQuickItem *child1 = new QQuickItem; - child1->setParentItem(root); - - QQuickItem *child2 = new QQuickItem; - child2->setParentItem(root); - - QVERIFY(child1->isEnabled()); - QVERIFY(child2->isEnabled()); - - root->setEnabled(false); - QVERIFY(!child1->isEnabled()); - QVERIFY(!child2->isEnabled()); - - root->setEnabled(true); - QVERIFY(child1->isEnabled()); - QVERIFY(child2->isEnabled()); - - child1->setEnabled(false); - QVERIFY(!child1->isEnabled()); - QVERIFY(child2->isEnabled()); - - child2->setParentItem(child1); - QVERIFY(!child1->isEnabled()); - QVERIFY(!child2->isEnabled()); - - child2->setParentItem(root); - QVERIFY(!child1->isEnabled()); - QVERIFY(child2->isEnabled()); - - delete root; - delete child1; - delete child2; -} - -void tst_qquickitem::enabledFocus() -{ - QQuickCanvas canvas; - ensureFocus(&canvas); - - QQuickFocusScope root; - - root.setFocus(true); - root.setEnabled(false); - - QCOMPARE(root.isEnabled(), false); - QCOMPARE(root.hasFocus(), true); - QCOMPARE(root.hasActiveFocus(), false); - - root.setParentItem(canvas.rootItem()); - - QCOMPARE(root.isEnabled(), false); - QCOMPARE(root.hasFocus(), true); - QCOMPARE(root.hasActiveFocus(), false); - QCOMPARE(canvas.activeFocusItem(), canvas.rootItem()); - - root.setEnabled(true); - QCOMPARE(root.isEnabled(), true); - QCOMPARE(root.hasFocus(), true); - QCOMPARE(root.hasActiveFocus(), true); - QCOMPARE(canvas.activeFocusItem(), static_cast(&root)); - - QQuickItem child1; - child1.setParentItem(&root); - - QCOMPARE(child1.isEnabled(), true); - QCOMPARE(child1.hasFocus(), false); - QCOMPARE(child1.hasActiveFocus(), false); - QCOMPARE(canvas.activeFocusItem(), static_cast(&root)); - - QQuickItem child2; - child2.setFocus(true); - child2.setParentItem(&root); - - QCOMPARE(root.isEnabled(), true); - QCOMPARE(root.hasFocus(), true); - QCOMPARE(root.hasActiveFocus(), true); - QCOMPARE(child2.isEnabled(), true); - QCOMPARE(child2.hasFocus(), true); - QCOMPARE(child2.hasActiveFocus(), true); - QCOMPARE(canvas.activeFocusItem(), &child2); - - child2.setEnabled(false); - - QCOMPARE(root.isEnabled(), true); - QCOMPARE(root.hasFocus(), true); - QCOMPARE(root.hasActiveFocus(), true); - QCOMPARE(child1.isEnabled(), true); - QCOMPARE(child1.hasFocus(), false); - QCOMPARE(child1.hasActiveFocus(), false); - QCOMPARE(child2.isEnabled(), false); - QCOMPARE(child2.hasFocus(), true); - QCOMPARE(child2.hasActiveFocus(), false); - QCOMPARE(canvas.activeFocusItem(), static_cast(&root)); - - child1.setEnabled(false); - QCOMPARE(child1.isEnabled(), false); - QCOMPARE(child1.hasFocus(), false); - QCOMPARE(child1.hasActiveFocus(), false); - - child1.setFocus(true); - QCOMPARE(child1.isEnabled(), false); - QCOMPARE(child1.hasFocus(), true); - QCOMPARE(child1.hasActiveFocus(), false); - QCOMPARE(child2.isEnabled(), false); - QCOMPARE(child2.hasFocus(), false); - QCOMPARE(child2.hasActiveFocus(), false); - QCOMPARE(canvas.activeFocusItem(), static_cast(&root)); - - child1.setEnabled(true); - QCOMPARE(child1.isEnabled(), true); - QCOMPARE(child1.hasFocus(), true); - QCOMPARE(child1.hasActiveFocus(), true); - QCOMPARE(canvas.activeFocusItem(), static_cast(&child1)); - - root.setFocus(false); - QCOMPARE(root.isEnabled(), true); - QCOMPARE(root.hasFocus(), false); - QCOMPARE(root.hasActiveFocus(), false); - QCOMPARE(child1.isEnabled(), true); - QCOMPARE(child1.hasFocus(), true); - QCOMPARE(child1.hasActiveFocus(), false); - QCOMPARE(canvas.activeFocusItem(), canvas.rootItem()); - - child2.forceActiveFocus(); - QCOMPARE(root.isEnabled(), true); - QCOMPARE(root.hasFocus(), true); - QCOMPARE(root.hasActiveFocus(), true); - QCOMPARE(child1.isEnabled(), true); - QCOMPARE(child1.hasFocus(), false); - QCOMPARE(child1.hasActiveFocus(), false); - QCOMPARE(child2.isEnabled(), false); - QCOMPARE(child2.hasFocus(), true); - QCOMPARE(child2.hasActiveFocus(), false); - QCOMPARE(canvas.activeFocusItem(), static_cast(&root)); - - root.setEnabled(false); - QCOMPARE(root.isEnabled(), false); - QCOMPARE(root.hasFocus(), true); - QCOMPARE(root.hasActiveFocus(), false); - QCOMPARE(child1.isEnabled(), false); - QCOMPARE(child1.hasFocus(), false); - QCOMPARE(child1.hasActiveFocus(), false); - QCOMPARE(child2.isEnabled(), false); - QCOMPARE(child2.hasFocus(), true); - QCOMPARE(child2.hasActiveFocus(), false); - QCOMPARE(canvas.activeFocusItem(), canvas.rootItem()); - - child1.forceActiveFocus(); - QCOMPARE(root.isEnabled(), false); - QCOMPARE(root.hasFocus(), true); - QCOMPARE(root.hasActiveFocus(), false); - QCOMPARE(child1.isEnabled(), false); - QCOMPARE(child1.hasFocus(), true); - QCOMPARE(child1.hasActiveFocus(), false); - QCOMPARE(child2.isEnabled(), false); - QCOMPARE(child2.hasFocus(), false); - QCOMPARE(child2.hasActiveFocus(), false); - QCOMPARE(canvas.activeFocusItem(), canvas.rootItem()); - - root.setEnabled(true); - QCOMPARE(root.isEnabled(), true); - QCOMPARE(root.hasFocus(), true); - QCOMPARE(root.hasActiveFocus(), true); - QCOMPARE(child1.isEnabled(), true); - QCOMPARE(child1.hasFocus(), true); - QCOMPARE(child1.hasActiveFocus(), true); - QCOMPARE(child2.isEnabled(), false); - QCOMPARE(child2.hasFocus(), false); - QCOMPARE(child2.hasActiveFocus(), false); - QCOMPARE(canvas.activeFocusItem(), static_cast(&child1)); -} - -void tst_qquickitem::mouseGrab() -{ - QQuickCanvas *canvas = new QQuickCanvas; - canvas->resize(200, 200); - canvas->show(); - - TestItem *child1 = new TestItem; - child1->setAcceptedMouseButtons(Qt::LeftButton); - child1->setSize(QSizeF(200, 100)); - child1->setParentItem(canvas->rootItem()); - - TestItem *child2 = new TestItem; - child2->setAcceptedMouseButtons(Qt::LeftButton); - child2->setY(51); - child2->setSize(QSizeF(200, 100)); - child2->setParentItem(canvas->rootItem()); - - QTest::mousePress(canvas, Qt::LeftButton, 0, QPoint(50,50)); - QTest::qWait(100); - QVERIFY(canvas->mouseGrabberItem() == child1); - QTest::qWait(100); - - QCOMPARE(child1->pressCount, 1); - QTest::mouseRelease(canvas, Qt::LeftButton, 0, QPoint(50,50)); - QTest::qWait(50); - QVERIFY(canvas->mouseGrabberItem() == 0); - QCOMPARE(child1->releaseCount, 1); - - QTest::mousePress(canvas, Qt::LeftButton, 0, QPoint(50,50)); - QTest::qWait(50); - QVERIFY(canvas->mouseGrabberItem() == child1); - QCOMPARE(child1->pressCount, 2); - child1->setEnabled(false); - QVERIFY(canvas->mouseGrabberItem() == 0); - QTest::mouseRelease(canvas, Qt::LeftButton, 0, QPoint(50,50)); - QTest::qWait(50); - QCOMPARE(child1->releaseCount, 1); - child1->setEnabled(true); - - QTest::mousePress(canvas, Qt::LeftButton, 0, QPoint(50,50)); - QTest::qWait(50); - QVERIFY(canvas->mouseGrabberItem() == child1); - QCOMPARE(child1->pressCount, 3); - child1->setVisible(false); - QVERIFY(canvas->mouseGrabberItem() == 0); - QTest::mouseRelease(canvas, Qt::LeftButton, 0, QPoint(50,50)); - QCOMPARE(child1->releaseCount, 1); - child1->setVisible(true); - - QTest::mousePress(canvas, Qt::LeftButton, 0, QPoint(50,50)); - QTest::qWait(50); - QVERIFY(canvas->mouseGrabberItem() == child1); - QCOMPARE(child1->pressCount, 4); - child2->grabMouse(); - QVERIFY(canvas->mouseGrabberItem() == child2); - QTest::mouseRelease(canvas, Qt::LeftButton, 0, QPoint(50,50)); - QTest::qWait(50); - QCOMPARE(child1->releaseCount, 1); - QCOMPARE(child2->releaseCount, 1); - - child2->grabMouse(); - QVERIFY(canvas->mouseGrabberItem() == child2); - QTest::mousePress(canvas, Qt::LeftButton, 0, QPoint(50,50)); - QTest::qWait(50); - QCOMPARE(child1->pressCount, 4); - QCOMPARE(child2->pressCount, 1); - QTest::mouseRelease(canvas, Qt::LeftButton, 0, QPoint(50,50)); - QTest::qWait(50); - QCOMPARE(child1->releaseCount, 1); - QCOMPARE(child2->releaseCount, 2); - - delete child1; - delete child2; - delete canvas; -} - -void tst_qquickitem::touchEventAcceptIgnore_data() -{ - QTest::addColumn("itemSupportsTouch"); - - QTest::newRow("with touch") << true; - QTest::newRow("without touch") << false; -} - -void tst_qquickitem::touchEventAcceptIgnore() -{ - QFETCH(bool, itemSupportsTouch); - - TestCanvas *canvas = new TestCanvas; - canvas->resize(100, 100); - canvas->show(); - - TestItem *item = new TestItem; - item->setSize(QSizeF(100, 100)); - item->setParentItem(canvas->rootItem()); - item->acceptIncomingTouchEvents = itemSupportsTouch; - - static QTouchDevice* device = 0; - if (!device) { - device =new QTouchDevice; - device->setType(QTouchDevice::TouchScreen); - QWindowSystemInterface::registerTouchDevice(device); - } - - // Send Begin, Update & End touch sequence - { - QTouchEvent::TouchPoint point; - point.setId(1); - point.setPos(QPointF(50, 50)); - point.setScreenPos(point.pos()); - point.setState(Qt::TouchPointPressed); - - QTouchEvent event(QEvent::TouchBegin, device, - Qt::NoModifier, - Qt::TouchPointPressed, - QList() << point); - event.setAccepted(true); - - item->touchEventReached = false; - - bool accepted = canvas->event(&event); - - QVERIFY(item->touchEventReached); - QCOMPARE(accepted && event.isAccepted(), itemSupportsTouch); - } - { - QTouchEvent::TouchPoint point; - point.setId(1); - point.setPos(QPointF(60, 60)); - point.setScreenPos(point.pos()); - point.setState(Qt::TouchPointMoved); - - QTouchEvent event(QEvent::TouchUpdate, device, - Qt::NoModifier, - Qt::TouchPointMoved, - QList() << point); - event.setAccepted(true); - - item->touchEventReached = false; - - bool accepted = canvas->event(&event); - - QCOMPARE(item->touchEventReached, itemSupportsTouch); - QCOMPARE(accepted && event.isAccepted(), itemSupportsTouch); - } - { - QTouchEvent::TouchPoint point; - point.setId(1); - point.setPos(QPointF(60, 60)); - point.setScreenPos(point.pos()); - point.setState(Qt::TouchPointReleased); - - QTouchEvent event(QEvent::TouchEnd, device, - Qt::NoModifier, - Qt::TouchPointReleased, - QList() << point); - event.setAccepted(true); - - item->touchEventReached = false; - - bool accepted = canvas->event(&event); - - QCOMPARE(item->touchEventReached, itemSupportsTouch); - QCOMPARE(accepted && event.isAccepted(), itemSupportsTouch); - } - - delete item; - delete canvas; -} - -void tst_qquickitem::polishOutsideAnimation() -{ - QQuickCanvas *canvas = new QQuickCanvas; - canvas->resize(200, 200); - canvas->show(); - - TestPolishItem *item = new TestPolishItem(canvas->rootItem()); - item->setSize(QSizeF(200, 100)); - QTest::qWait(50); - - QTimer::singleShot(10, item, SLOT(doPolish())); - QTRY_VERIFY(item->wasPolished); - - delete item; - delete canvas; -} - -void tst_qquickitem::polishOnCompleted() -{ - QQuickView *view = new QQuickView; - view->setSource(testFileUrl("polishOnCompleted.qml")); - view->show(); - - TestPolishItem *item = qobject_cast(view->rootObject()); - QVERIFY(item); - -#ifdef Q_OS_MAC - QSKIP("QTBUG-21590 view does not reliably receive polish without a running animation"); -#endif - - QTRY_VERIFY(item->wasPolished); - - delete view; -} - -void tst_qquickitem::wheelEvent_data() -{ - QTest::addColumn("visible"); - QTest::addColumn("enabled"); - - QTest::newRow("visible and enabled") << true << true; - QTest::newRow("visible and disabled") << true << false; - QTest::newRow("invisible and enabled") << false << true; - QTest::newRow("invisible and disabled") << false << false; -} - -void tst_qquickitem::wheelEvent() -{ - QFETCH(bool, visible); - QFETCH(bool, enabled); - - const bool shouldReceiveWheelEvents = visible && enabled; - - QQuickCanvas *canvas = new QQuickCanvas; - canvas->resize(200, 200); - canvas->show(); - - TestItem *item = new TestItem; - item->setSize(QSizeF(200, 100)); - item->setParentItem(canvas->rootItem()); - - item->setEnabled(enabled); - item->setVisible(visible); - - QWheelEvent event(QPoint(100, 50), -120, Qt::NoButton, Qt::NoModifier, Qt::Vertical); - event.setAccepted(false); - QGuiApplication::sendEvent(canvas, &event); - - if (shouldReceiveWheelEvents) { - QVERIFY(event.isAccepted()); - QCOMPARE(item->wheelCount, 1); - } else { - QVERIFY(!event.isAccepted()); - QCOMPARE(item->wheelCount, 0); - } - - delete canvas; -} - -class HoverItem : public QQuickItem -{ -Q_OBJECT -public: - HoverItem(QQuickItem *parent = 0) - : QQuickItem(parent), hoverEnterCount(0), hoverMoveCount(0), hoverLeaveCount(0) - { } - void resetCounters() { - hoverEnterCount = 0; - hoverMoveCount = 0; - hoverLeaveCount = 0; - } - int hoverEnterCount; - int hoverMoveCount; - int hoverLeaveCount; -protected: - virtual void hoverEnterEvent(QHoverEvent *event) { - event->accept(); - ++hoverEnterCount; - } - virtual void hoverMoveEvent(QHoverEvent *event) { - event->accept(); - ++hoverMoveCount; - } - virtual void hoverLeaveEvent(QHoverEvent *event) { - event->accept(); - ++hoverLeaveCount; - } -}; - -void tst_qquickitem::hoverEvent_data() -{ - QTest::addColumn("visible"); - QTest::addColumn("enabled"); - QTest::addColumn("acceptHoverEvents"); - - QTest::newRow("visible, enabled, accept hover") << true << true << true; - QTest::newRow("visible, disabled, accept hover") << true << false << true; - QTest::newRow("invisible, enabled, accept hover") << false << true << true; - QTest::newRow("invisible, disabled, accept hover") << false << false << true; - - QTest::newRow("visible, enabled, not accept hover") << true << true << false; - QTest::newRow("visible, disabled, not accept hover") << true << false << false; - QTest::newRow("invisible, enabled, not accept hover") << false << true << false; - QTest::newRow("invisible, disabled, not accept hover") << false << false << false; -} - -// ### For some unknown reason QTest::mouseMove() isn't working correctly. -static void sendMouseMove(QObject *object, const QPoint &position) -{ - QMouseEvent moveEvent(QEvent::MouseMove, position, Qt::NoButton, Qt::NoButton, 0); - QGuiApplication::sendEvent(object, &moveEvent); -} - -void tst_qquickitem::hoverEvent() -{ - QFETCH(bool, visible); - QFETCH(bool, enabled); - QFETCH(bool, acceptHoverEvents); - - QQuickCanvas *canvas = new QQuickCanvas(); - canvas->resize(200, 200); - canvas->show(); - - HoverItem *item = new HoverItem; - item->setSize(QSizeF(100, 100)); - item->setParentItem(canvas->rootItem()); - - item->setEnabled(enabled); - item->setVisible(visible); - item->setAcceptHoverEvents(acceptHoverEvents); - - const QPoint outside(150, 150); - const QPoint inside(50, 50); - const QPoint anotherInside(51, 51); - - sendMouseMove(canvas, outside); - item->resetCounters(); - - // Enter, then move twice inside, then leave. - sendMouseMove(canvas, inside); - sendMouseMove(canvas, anotherInside); - sendMouseMove(canvas, inside); - sendMouseMove(canvas, outside); - - const bool shouldReceiveHoverEvents = visible && enabled && acceptHoverEvents; - if (shouldReceiveHoverEvents) { - QCOMPARE(item->hoverEnterCount, 1); - QCOMPARE(item->hoverMoveCount, 2); - QCOMPARE(item->hoverLeaveCount, 1); - } else { - QCOMPARE(item->hoverEnterCount, 0); - QCOMPARE(item->hoverMoveCount, 0); - QCOMPARE(item->hoverLeaveCount, 0); - } - - delete canvas; -} - -void tst_qquickitem::hoverEventInParent() -{ - QQuickCanvas *canvas = new QQuickCanvas(); - canvas->resize(200, 200); - canvas->show(); - - HoverItem *parentItem = new HoverItem(canvas->rootItem()); - parentItem->setSize(QSizeF(200, 200)); - parentItem->setAcceptHoverEvents(true); - - HoverItem *leftItem = new HoverItem(parentItem); - leftItem->setSize(QSizeF(100, 200)); - leftItem->setAcceptHoverEvents(true); - - HoverItem *rightItem = new HoverItem(parentItem); - rightItem->setSize(QSizeF(100, 200)); - rightItem->setPos(QPointF(100, 0)); - rightItem->setAcceptHoverEvents(true); - - const QPoint insideLeft(50, 100); - const QPoint insideRight(150, 100); - - sendMouseMove(canvas, insideLeft); - parentItem->resetCounters(); - leftItem->resetCounters(); - rightItem->resetCounters(); - - sendMouseMove(canvas, insideRight); - QCOMPARE(parentItem->hoverEnterCount, 0); - QCOMPARE(parentItem->hoverLeaveCount, 0); - QCOMPARE(leftItem->hoverEnterCount, 0); - QCOMPARE(leftItem->hoverLeaveCount, 1); - QCOMPARE(rightItem->hoverEnterCount, 1); - QCOMPARE(rightItem->hoverLeaveCount, 0); - - sendMouseMove(canvas, insideLeft); - QCOMPARE(parentItem->hoverEnterCount, 0); - QCOMPARE(parentItem->hoverLeaveCount, 0); - QCOMPARE(leftItem->hoverEnterCount, 1); - QCOMPARE(leftItem->hoverLeaveCount, 1); - QCOMPARE(rightItem->hoverEnterCount, 1); - QCOMPARE(rightItem->hoverLeaveCount, 1); - - delete canvas; -} - -void tst_qquickitem::paintOrder_data() -{ - const QUrl order1Url = testFileUrl("order.1.qml"); - const QUrl order2Url = testFileUrl("order.2.qml"); - - QTest::addColumn("source"); - QTest::addColumn("op"); - QTest::addColumn("param1"); - QTest::addColumn("param2"); - QTest::addColumn("expected"); - - QTest::newRow("test 1 noop") << order1Url - << int(NoOp) << QVariant() << QVariant() - << (QStringList() << "1" << "2" << "3"); - QTest::newRow("test 1 add") << order1Url - << int(Append) << QVariant("new") << QVariant() - << (QStringList() << "1" << "2" << "3" << "new"); - QTest::newRow("test 1 remove") << order1Url - << int(Remove) << QVariant(1) << QVariant() - << (QStringList() << "1" << "3"); - QTest::newRow("test 1 stack before") << order1Url - << int(StackBefore) << QVariant(2) << QVariant(1) - << (QStringList() << "1" << "3" << "2"); - QTest::newRow("test 1 stack after") << order1Url - << int(StackAfter) << QVariant(0) << QVariant(1) - << (QStringList() << "2" << "1" << "3"); - QTest::newRow("test 1 set z") << order1Url - << int(SetZ) << QVariant(1) << QVariant(qreal(1.)) - << (QStringList() << "1" << "3" << "2"); - - QTest::newRow("test 2 noop") << order2Url - << int(NoOp) << QVariant() << QVariant() - << (QStringList() << "1" << "3" << "2"); - QTest::newRow("test 2 add") << order2Url - << int(Append) << QVariant("new") << QVariant() - << (QStringList() << "1" << "3" << "new" << "2"); - QTest::newRow("test 2 remove 1") << order2Url - << int(Remove) << QVariant(1) << QVariant() - << (QStringList() << "1" << "3"); - QTest::newRow("test 2 remove 2") << order2Url - << int(Remove) << QVariant(2) << QVariant() - << (QStringList() << "1" << "2"); - QTest::newRow("test 2 stack before 1") << order2Url - << int(StackBefore) << QVariant(1) << QVariant(0) - << (QStringList() << "1" << "3" << "2"); - QTest::newRow("test 2 stack before 2") << order2Url - << int(StackBefore) << QVariant(2) << QVariant(0) - << (QStringList() << "3" << "1" << "2"); - QTest::newRow("test 2 stack after 1") << order2Url - << int(StackAfter) << QVariant(0) << QVariant(1) - << (QStringList() << "1" << "3" << "2"); - QTest::newRow("test 2 stack after 2") << order2Url - << int(StackAfter) << QVariant(0) << QVariant(2) - << (QStringList() << "3" << "1" << "2"); - QTest::newRow("test 1 set z") << order1Url - << int(SetZ) << QVariant(2) << QVariant(qreal(2.)) - << (QStringList() << "1" << "2" << "3"); -} - -void tst_qquickitem::paintOrder() -{ - QFETCH(QUrl, source); - QFETCH(int, op); - QFETCH(QVariant, param1); - QFETCH(QVariant, param2); - QFETCH(QStringList, expected); - - QQuickView view; - view.setSource(source); - - QQuickItem *root = qobject_cast(view.rootObject()); - QVERIFY(root); - - switch (op) { - case Append: { - QQuickItem *item = new QQuickItem(root); - item->setObjectName(param1.toString()); - } - break; - case Remove: { - QQuickItem *item = root->childItems().at(param1.toInt()); - delete item; - } - break; - case StackBefore: { - QQuickItem *item1 = root->childItems().at(param1.toInt()); - QQuickItem *item2 = root->childItems().at(param2.toInt()); - item1->stackBefore(item2); - } - break; - case StackAfter: { - QQuickItem *item1 = root->childItems().at(param1.toInt()); - QQuickItem *item2 = root->childItems().at(param2.toInt()); - item1->stackAfter(item2); - } - break; - case SetZ: { - QQuickItem *item = root->childItems().at(param1.toInt()); - item->setZ(param2.toReal()); - } - break; - default: - break; - } - - QList list = QQuickItemPrivate::get(root)->paintOrderChildItems(); - - QStringList items; - for (int i = 0; i < list.count(); ++i) - items << list.at(i)->objectName(); - - QCOMPARE(items, expected); -} - - -QTEST_MAIN(tst_qquickitem) - -#include "tst_qquickitem.moc" diff --git a/tests/auto/qtquick2/qquickitem2/data/childrenProperty.qml b/tests/auto/qtquick2/qquickitem2/data/childrenProperty.qml deleted file mode 100644 index 85ddbc1446..0000000000 --- a/tests/auto/qtquick2/qquickitem2/data/childrenProperty.qml +++ /dev/null @@ -1,14 +0,0 @@ -import QtQuick 2.0 - -Item { - id: root - - property bool test1: root.children.length == 3 - property bool test2: root.children[0] == item1 - property bool test3: root.children[1] == item2 - property bool test4: root.children[2] == item3 - property bool test5: root.children[3] == null - - children: [ Item { id: item1 }, Item { id: item2 }, Item { id: item3 } ] -} - diff --git a/tests/auto/qtquick2/qquickitem2/data/childrenRect.qml b/tests/auto/qtquick2/qquickitem2/data/childrenRect.qml deleted file mode 100644 index ebc57aefbe..0000000000 --- a/tests/auto/qtquick2/qquickitem2/data/childrenRect.qml +++ /dev/null @@ -1,27 +0,0 @@ -import QtQuick 2.0 - -Rectangle { - width: 400 - height: 400 - - property int childCount: 0; - - Item { - objectName: "testItem" - width: childrenRect.width - height: childrenRect.height - - Repeater { - id: repeater - model: childCount - delegate: Rectangle { - x: index*10 - y: index*20 - width: 10 - height: 20 - - color: "red" - } - } - } -} diff --git a/tests/auto/qtquick2/qquickitem2/data/childrenRectBug.qml b/tests/auto/qtquick2/qquickitem2/data/childrenRectBug.qml deleted file mode 100644 index 86a4f19c5c..0000000000 --- a/tests/auto/qtquick2/qquickitem2/data/childrenRectBug.qml +++ /dev/null @@ -1,23 +0,0 @@ -import QtQuick 2.0 - -Rectangle { - width: 400 - height: 200 - - Item { - objectName: "theItem" - anchors.centerIn: parent - width: childrenRect.width - height: childrenRect.height - Rectangle { - id: text1 - anchors.verticalCenter: parent.verticalCenter - width: 100; height: 100; color: "green" - } - Rectangle { - anchors.left: text1.right - anchors.verticalCenter: parent.verticalCenter - width: 100; height: 100; color: "green" - } - } -} diff --git a/tests/auto/qtquick2/qquickitem2/data/childrenRectBug2.qml b/tests/auto/qtquick2/qquickitem2/data/childrenRectBug2.qml deleted file mode 100644 index 6e80ed28af..0000000000 --- a/tests/auto/qtquick2/qquickitem2/data/childrenRectBug2.qml +++ /dev/null @@ -1,53 +0,0 @@ -import QtQuick 2.0 - -Rectangle { - width:360; - height: 200 - - Item { - objectName: "theItem" - anchors.centerIn: parent - width: childrenRect.width - height: childrenRect.height - Rectangle { - id: header1 - anchors.horizontalCenter: parent.horizontalCenter - anchors.top: parent.top - width: 100; height: 50 - color: "green" - } - Rectangle { - id: text1 - anchors.top: header1.bottom - anchors.topMargin: 10 - anchors.horizontalCenter: parent.horizontalCenter - width: 100; height: 50 - color: "blue" - } - } - - states: [ - State { - name: "row" - AnchorChanges { - target: header1 - anchors.horizontalCenter: undefined - anchors.verticalCenter: parent.verticalCenter - anchors.left: parent.left - anchors.top: undefined - } - AnchorChanges { - target: text1 - anchors.horizontalCenter: undefined - anchors.verticalCenter: parent.verticalCenter - anchors.top: undefined - anchors.left: header1.right - } - PropertyChanges { - target: text1 - anchors.leftMargin: 10 - anchors.topMargin: 0 - } - } - ] -} diff --git a/tests/auto/qtquick2/qquickitem2/data/childrenRectBug3.qml b/tests/auto/qtquick2/qquickitem2/data/childrenRectBug3.qml deleted file mode 100644 index 518e76509e..0000000000 --- a/tests/auto/qtquick2/qquickitem2/data/childrenRectBug3.qml +++ /dev/null @@ -1,15 +0,0 @@ -import QtQuick 2.0 - -Rectangle { - width: 300 - height: 300 - - Rectangle { - height: childrenRect.height - - Repeater { - model: 1 - Rectangle { } - } - } -} diff --git a/tests/auto/qtquick2/qquickitem2/data/implicitsize.qml b/tests/auto/qtquick2/qquickitem2/data/implicitsize.qml deleted file mode 100644 index cc6aaf7d60..0000000000 --- a/tests/auto/qtquick2/qquickitem2/data/implicitsize.qml +++ /dev/null @@ -1,19 +0,0 @@ -import QtQuick 2.0 - -Item { - implicitWidth: 200 - implicitHeight: 100 - - width: 80 - height: 60 - - function resetSize() { - width = undefined - height = undefined - } - - function changeImplicit() { - implicitWidth = 150 - implicitHeight = 80 - } -} diff --git a/tests/auto/qtquick2/qquickitem2/data/keynavigationtest.qml b/tests/auto/qtquick2/qquickitem2/data/keynavigationtest.qml deleted file mode 100644 index aacb621fb0..0000000000 --- a/tests/auto/qtquick2/qquickitem2/data/keynavigationtest.qml +++ /dev/null @@ -1,87 +0,0 @@ -import QtQuick 2.0 - -Grid { - columns: 2 - width: 100; height: 100 - function verify() { - if (item1.KeyNavigation.right != item2) - return false; - if (item1.KeyNavigation.down != item3) - return false; - if (item1.KeyNavigation.tab != item2) - return false; - if (item1.KeyNavigation.backtab != item4) - return false; - - if (item2.KeyNavigation.left != item1) - return false; - if (item2.KeyNavigation.down != item4) - return false; - if (item2.KeyNavigation.tab != item3) - return false; - if (item2.KeyNavigation.backtab != item1) - return false; - - if (item3.KeyNavigation.right != item4) - return false; - if (item3.KeyNavigation.up != item1) - return false; - if (item3.KeyNavigation.tab != item4) - return false; - if (item3.KeyNavigation.backtab != item2) - return false; - - if (item4.KeyNavigation.left != item3) - return false; - if (item4.KeyNavigation.up != item2) - return false; - if (item4.KeyNavigation.tab != item1) - return false; - if (item4.KeyNavigation.backtab != item3) - return false; - - return true; - } - - Rectangle { - id: item1 - objectName: "item1" - focus: true - width: 50; height: 50 - color: focus ? "red" : "lightgray" - KeyNavigation.right: item2 - KeyNavigation.down: item3 - KeyNavigation.tab: item2 - KeyNavigation.backtab: item4 - } - Rectangle { - id: item2 - objectName: "item2" - width: 50; height: 50 - color: focus ? "red" : "lightgray" - KeyNavigation.left: item1 - KeyNavigation.down: item4 - KeyNavigation.tab: item3 - KeyNavigation.backtab: item1 - } - Rectangle { - id: item3 - objectName: "item3" - width: 50; height: 50 - color: focus ? "red" : "lightgray" - KeyNavigation.right: item4 - KeyNavigation.up: item1 - KeyNavigation.tab: item4 - KeyNavigation.backtab: item2 - } - Rectangle { - id: item4 - objectName: "item4" - width: 50; height: 50 - color: focus ? "red" : "lightgray" - KeyNavigation.left: item3 - KeyNavigation.up: item2 - KeyNavigation.tab: item1 - KeyNavigation.backtab: item3 - } -} diff --git a/tests/auto/qtquick2/qquickitem2/data/keynavigationtest_implicit.qml b/tests/auto/qtquick2/qquickitem2/data/keynavigationtest_implicit.qml deleted file mode 100644 index 92d4ae23de..0000000000 --- a/tests/auto/qtquick2/qquickitem2/data/keynavigationtest_implicit.qml +++ /dev/null @@ -1,68 +0,0 @@ -import QtQuick 2.0 - -Grid { - columns: 2 - width: 100; height: 100 - function verify() { - if (item1.KeyNavigation.tab != item2) - return false; - if (item1.KeyNavigation.backtab != item4) - return false; - - if (item2.KeyNavigation.left != item1) - return false; - if (item2.KeyNavigation.down != item4) - return false; - if (item2.KeyNavigation.tab != item3) - return false; - if (item2.KeyNavigation.backtab != item1) - return false; - - if (item3.KeyNavigation.right != item4) - return false; - if (item3.KeyNavigation.up != item1) - return false; - if (item3.KeyNavigation.tab != item4) - return false; - if (item3.KeyNavigation.backtab != item2) - return false; - - return true; - } - - Rectangle { - id: item1 - objectName: "item1" - focus: true - width: 50; height: 50 - color: focus ? "red" : "lightgray" - KeyNavigation.tab: item2 - KeyNavigation.backtab: item4 - } - Rectangle { - id: item2 - objectName: "item2" - width: 50; height: 50 - color: focus ? "red" : "lightgray" - KeyNavigation.left: item1 - KeyNavigation.down: item4 - KeyNavigation.tab: item3 - KeyNavigation.backtab: item1 - } - Rectangle { - id: item3 - objectName: "item3" - width: 50; height: 50 - color: focus ? "red" : "lightgray" - KeyNavigation.right: item4 - KeyNavigation.up: item1 - KeyNavigation.tab: item4 - KeyNavigation.backtab: item2 - } - Rectangle { - id: item4 - objectName: "item4" - width: 50; height: 50 - color: focus ? "red" : "lightgray" - } -} diff --git a/tests/auto/qtquick2/qquickitem2/data/keysim.qml b/tests/auto/qtquick2/qquickitem2/data/keysim.qml deleted file mode 100644 index 7da8a47681..0000000000 --- a/tests/auto/qtquick2/qquickitem2/data/keysim.qml +++ /dev/null @@ -1,11 +0,0 @@ -import QtQuick 2.0 - -Item { - focus: true - - Keys.forwardTo: [ item2 ] - - TextInput { - id: item2 - } -} diff --git a/tests/auto/qtquick2/qquickitem2/data/keyspriority.qml b/tests/auto/qtquick2/qquickitem2/data/keyspriority.qml deleted file mode 100644 index ae51aae776..0000000000 --- a/tests/auto/qtquick2/qquickitem2/data/keyspriority.qml +++ /dev/null @@ -1,11 +0,0 @@ -import QtQuick 2.0 -import Test 1.0 - -KeyTestItem { - focus: true - Keys.onPressed: keysTestObject.keyPress(event.key, event.text, event.modifiers) - Keys.onReleased: { keysTestObject.keyRelease(event.key, event.text, event.modifiers); event.accepted = true; } - Keys.priority: keysTestObject.processLast ? Keys.AfterItem : Keys.BeforeItem - - property int priorityTest: Keys.priority -} diff --git a/tests/auto/qtquick2/qquickitem2/data/keystest.qml b/tests/auto/qtquick2/qquickitem2/data/keystest.qml deleted file mode 100644 index c70e0061f5..0000000000 --- a/tests/auto/qtquick2/qquickitem2/data/keystest.qml +++ /dev/null @@ -1,24 +0,0 @@ -import QtQuick 2.0 - -Item { - focus: true - - property bool isEnabled: Keys.enabled - - Keys.onPressed: keysTestObject.keyPress(event.key, event.text, event.modifiers) - Keys.onReleased: { keysTestObject.keyRelease(event.key, event.text, event.modifiers); event.accepted = true; } - Keys.onReturnPressed: keysTestObject.keyPress(event.key, "Return", event.modifiers) - Keys.onDigit0Pressed: keysTestObject.keyPress(event.key, event.text, event.modifiers) - Keys.onDigit9Pressed: { event.accepted = false; keysTestObject.keyPress(event.key, event.text, event.modifiers) } - Keys.onTabPressed: keysTestObject.keyPress(event.key, "Tab", event.modifiers) - Keys.onBacktabPressed: keysTestObject.keyPress(event.key, "Backtab", event.modifiers) - Keys.forwardTo: [ item2 ] - Keys.enabled: enableKeyHanding - - Item { - id: item2 - visible: forwardeeVisible - Keys.onPressed: keysTestObject.forwardedKey(event.key) - Keys.onReleased: keysTestObject.forwardedKey(event.key) - } -} diff --git a/tests/auto/qtquick2/qquickitem2/data/layoutmirroring.qml b/tests/auto/qtquick2/qquickitem2/data/layoutmirroring.qml deleted file mode 100644 index 036819740c..0000000000 --- a/tests/auto/qtquick2/qquickitem2/data/layoutmirroring.qml +++ /dev/null @@ -1,54 +0,0 @@ -import QtQuick 2.0 - -Item { - property bool childrenInherit: true - Item { - objectName: "mirrored1" - LayoutMirroring.enabled: true - LayoutMirroring.childrenInherit: parent.childrenInherit - Item { - Item { - objectName: "notMirrored1" - LayoutMirroring.enabled: false - Item { - objectName: "inheritedMirror1" - } - } - Item { - objectName: "inheritedMirror2" - } - } - } - Item { - objectName: "mirrored2" - LayoutMirroring.enabled: true - LayoutMirroring.childrenInherit: false - Item { - objectName: "notMirrored2" - } - } - Item { - LayoutMirroring.enabled: true - LayoutMirroring.childrenInherit: true - Loader { - id: loader - } - } - states: State { - name: "newContent" - PropertyChanges { - target: loader - sourceComponent: component - } - } - Component { - id: component - Item { - objectName: "notMirrored3" - LayoutMirroring.enabled: false - Item { - objectName: "inheritedMirror3" - } - } - } -} diff --git a/tests/auto/qtquick2/qquickitem2/data/mapCoordinates.qml b/tests/auto/qtquick2/qquickitem2/data/mapCoordinates.qml deleted file mode 100644 index 7b979a54b3..0000000000 --- a/tests/auto/qtquick2/qquickitem2/data/mapCoordinates.qml +++ /dev/null @@ -1,84 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -Item { - id: root; objectName: "root" - width: 200; height: 200 - - Item { id: itemA; objectName: "itemA"; x: 50; y: 50 } - - Item { - x: 50; y: 50 - Item { id: itemB; objectName: "itemB"; x: 100; y: 100 } - } - - function mapAToB(x, y) { - var pos = itemA.mapToItem(itemB, x, y) - return Qt.point(pos.x, pos.y) - } - - function mapAFromB(x, y) { - var pos = itemA.mapFromItem(itemB, x, y) - return Qt.point(pos.x, pos.y) - } - - function mapAToNull(x, y) { - var pos = itemA.mapToItem(null, x, y) - return Qt.point(pos.x, pos.y) - } - - function mapAFromNull(x, y) { - var pos = itemA.mapFromItem(null, x, y) - return Qt.point(pos.x, pos.y) - } - - function checkMapAToInvalid(x, y) { - var pos = itemA.mapToItem(1122, x, y) - return pos == undefined; - } - - function checkMapAFromInvalid(x, y) { - var pos = itemA.mapFromItem(1122, x, y) - return pos == undefined; - } -} diff --git a/tests/auto/qtquick2/qquickitem2/data/parentLoop.qml b/tests/auto/qtquick2/qquickitem2/data/parentLoop.qml deleted file mode 100644 index 7b6560fbf7..0000000000 --- a/tests/auto/qtquick2/qquickitem2/data/parentLoop.qml +++ /dev/null @@ -1,14 +0,0 @@ -import QtQuick 2.0 - -Item { - Item { - id: item1 - objectName: "item1" - - Item { - id: item2 - objectName: "item2" - } - } - Component.onCompleted: item1.parent = item2 -} diff --git a/tests/auto/qtquick2/qquickitem2/data/propertychanges.qml b/tests/auto/qtquick2/qquickitem2/data/propertychanges.qml deleted file mode 100644 index 3fa5ea9c23..0000000000 --- a/tests/auto/qtquick2/qquickitem2/data/propertychanges.qml +++ /dev/null @@ -1,10 +0,0 @@ -import QtQuick 2.0 - -Item { - Item { - objectName: "item" - } - Item { - objectName: "parentItem" - } -} diff --git a/tests/auto/qtquick2/qquickitem2/data/qtbug_16871.qml b/tests/auto/qtquick2/qquickitem2/data/qtbug_16871.qml deleted file mode 100644 index f1e7377730..0000000000 --- a/tests/auto/qtquick2/qquickitem2/data/qtbug_16871.qml +++ /dev/null @@ -1,5 +0,0 @@ -import QtQuick 2.0 - -Item { - children: [ 10 ] -} diff --git a/tests/auto/qtquick2/qquickitem2/data/resourcesProperty.qml b/tests/auto/qtquick2/qquickitem2/data/resourcesProperty.qml deleted file mode 100644 index b8f18bb375..0000000000 --- a/tests/auto/qtquick2/qquickitem2/data/resourcesProperty.qml +++ /dev/null @@ -1,21 +0,0 @@ -import QtQuick 2.0 - -Item { - id: root - - property bool test1 - property bool test2 - property bool test3 - property bool test4 - property bool test5 - - Component.onCompleted: { - test1 = (root.resources.length >= 3) - test2 = root.resources[0] == item1 - test3 = root.resources[1] == item2 - test4 = root.resources[2] == item3 - test5 = root.resources[10] == null - } - - resources: [ Item { id: item1 }, Item { id: item2 }, Item { id: item3 } ] -} diff --git a/tests/auto/qtquick2/qquickitem2/data/transformCrash.qml b/tests/auto/qtquick2/qquickitem2/data/transformCrash.qml deleted file mode 100644 index 284e85f0e0..0000000000 --- a/tests/auto/qtquick2/qquickitem2/data/transformCrash.qml +++ /dev/null @@ -1,13 +0,0 @@ -import QtQuick 2.0 - -Item { - id: wrapper - width: 200 - height: 200 - - QtObject { - id: object - } - - Component.onCompleted: wrapper.transform = object -} diff --git a/tests/auto/qtquick2/qquickitem2/data/visiblechildren.qml b/tests/auto/qtquick2/qquickitem2/data/visiblechildren.qml deleted file mode 100644 index e51eb3551b..0000000000 --- a/tests/auto/qtquick2/qquickitem2/data/visiblechildren.qml +++ /dev/null @@ -1,143 +0,0 @@ -import QtQuick 2.0 - -Item { - id: root - width: 400 - height: 300 - - Row { - id: row - Item { id: item1 - Item { id: item1_1; visible: true } - Item { id: item1_2; visible: true } - } - Item { id: item2 } - Item { id: item3 - Item { id: item3_1; visible: false } - Item { id: item3_2; visible: false } - } - Item { id: item4; visible: false - Item { id: item4_1 // implicitly invisible - Item { id: item4_1_1 } // implicitly invisible - Item { id: item4_1_2 } // implicitly invisible - } - } - } - - property int row_changeEventCalls: 0 - property int item1_changeEventCalls: 0 - property int item2_changeEventCalls: 0 - property int item3_changeEventCalls: 0 - property int item4_1_changeEventCalls: 0 - property int item4_1_1_changeEventCalls: 0 - Connections { target: row; onVisibleChildrenChanged: row_changeEventCalls++ } - Connections { target: item1; onVisibleChildrenChanged: item1_changeEventCalls++ } - Connections { target: item2; onVisibleChildrenChanged: item2_changeEventCalls++ } - Connections { target: item3; onVisibleChildrenChanged: item3_changeEventCalls++ } - Connections { target: item4_1; onVisibleChildrenChanged: item4_1_changeEventCalls++ } - Connections { target: item4_1_1; onVisibleChildrenChanged: item4_1_1_changeEventCalls++ } - - // Make sure there are three visible children and no signals fired yet - property bool test1_1: row.visibleChildren.length == 3 - property bool test1_2: row.visibleChildren[0] == item1 && row.visibleChildren[1] == item2 && row.visibleChildren[2] == item3 - property bool test1_3: row_changeEventCalls == 0 - property bool test1_4: item1_changeEventCalls == 0 && item2_changeEventCalls == 0 && item3_changeEventCalls == 0 - - // Next test - function hideFirstAndLastRowChild() { - item1.visible = false; - item3.visible = false; - } - - // Make sure row is signaled twice and item1 only once, and item3 not at all, and that item2 is the visible child - property bool test2_1: row.visibleChildren.length == 1 - property bool test2_2: row.visibleChildren[0] == item2 - property bool test2_3: row_changeEventCalls == 2 - property bool test2_4: item1_changeEventCalls == 1 && item2_changeEventCalls == 0 && item3_changeEventCalls == 0 - - // Next test - function showLastRowChildsLastChild() { - item3_2.visible = true; - } - - // Make sure item3_changeEventCalls is not signaled - property bool test3_1: row.visibleChildren.length == 1 - property bool test3_2: row.visibleChildren[0] == item2 - property bool test3_3: row_changeEventCalls == 2 - property bool test3_4: item1_changeEventCalls == 1 && item2_changeEventCalls == 0 && item3_changeEventCalls == 0 - - // Next test - function showLastRowChild() { - item3.visible = true; - } - - // Make sure row and item3 are signaled - property bool test4_1: row.visibleChildren.length == 2 - property bool test4_2: row.visibleChildren[0] == item2 && row.visibleChildren[1] == item3 - property bool test4_3: row_changeEventCalls == 3 - property bool test4_4: item1_changeEventCalls == 1 && item2_changeEventCalls == 0 && item3_changeEventCalls == 1 - - // Next test - function tryWriteToReadonlyVisibleChildren() { - var foo = fooComponent.createObject(root); - if (Qt.isQtObject(foo) && foo.children.length == 3 && foo.visibleChildren.length == 3) { - test5_1 = true; - } - - foo.visibleChildren.length = 10; // make sure this has no effect - test5_1 = (foo.visibleChildren.length == 3); - delete foo; - } - - Component { - id: fooComponent - Item { - children: [ Item {},Item {},Item {} ] - visibleChildren: [ Item {} ] - } - } - - // Make sure visibleChildren.length is 3 and stays that way - property bool test5_1: false - - // Next test - function reparentVisibleItem3() { - item3.parent = hiddenItem; // item3 has one visible children - } - - Item { id: hiddenItem; visible: false } - - property bool test6_1: row.visibleChildren.length == 1 && row_changeEventCalls == 4 - property bool test6_2: item3_changeEventCalls == 2 - property bool test6_3: item3.visible == false - - // Next test - - property bool test6_4: item4_1.visible == false && item4_1_changeEventCalls == 0 - - function reparentImlicitlyInvisibleItem4_1() { - item4_1.parent = visibleItem; - } - - Item { id: visibleItem; visible: true } - property int visibleItem_changeEventCalls: 0 - Connections { target: visibleItem; onVisibleChildrenChanged: visibleItem_changeEventCalls++ } - - - // Make sure that an item with implictly invisible children will be signaled when reparented to a visible parent - property bool test7_1: row.visibleChildren.length == 1 && row_changeEventCalls == 4 - property bool test7_2: item4_1.visible == true - property bool test7_3: item4_1_changeEventCalls == 1 - property bool test7_4: visibleItem_changeEventCalls == 1 - - - - // FINALLY make sure nothing has changes while we weren't paying attention - - property bool test8_1: row.visibleChildren.length == 1 && row.visibleChildren[0] == item2 && row_changeEventCalls == 4 - property bool test8_2: item1_changeEventCalls == 1 && item1.visible == false - property bool test8_3: item2_changeEventCalls == 0 && item2.visible == true - property bool test8_4: item3_changeEventCalls == 2 && item3.visible == false - property bool test8_5: item4_1_1_changeEventCalls == 0 && item4_1_1.visible == true - -} diff --git a/tests/auto/qtquick2/qquickitem2/qquickitem2.pro b/tests/auto/qtquick2/qquickitem2/qquickitem2.pro deleted file mode 100644 index 44d3ba37c8..0000000000 --- a/tests/auto/qtquick2/qquickitem2/qquickitem2.pro +++ /dev/null @@ -1,15 +0,0 @@ -CONFIG += testcase -TARGET = tst_qquickitem2 -macx:CONFIG -= app_bundle - -SOURCES += tst_qquickitem.cpp - -include (../../shared/util.pri) - -testDataFiles.files = data -testDataFiles.path = . -DEPLOYMENT += testDataFiles - -CONFIG += parallel_test - -QT += core-private gui-private v8-private declarative-private quick-private opengl-private testlib diff --git a/tests/auto/qtquick2/qquickitem2/tst_qquickitem.cpp b/tests/auto/qtquick2/qquickitem2/tst_qquickitem.cpp deleted file mode 100644 index 9891b8718a..0000000000 --- a/tests/auto/qtquick2/qquickitem2/tst_qquickitem.cpp +++ /dev/null @@ -1,1380 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "../../shared/util.h" -#include "../shared/visualtestutil.h" -#include "../../shared/platforminputcontext.h" - -using namespace QQuickVisualTestUtil; - -class tst_QQuickItem : public QDeclarativeDataTest -{ - Q_OBJECT -public: - tst_QQuickItem(); - -private slots: - void initTestCase(); - void cleanup(); - - void keys(); - void keysProcessingOrder(); - void keysim(); - void keyNavigation(); - void keyNavigation_RightToLeft(); - void keyNavigation_skipNotVisible(); - void keyNavigation_implicitSetting(); - void layoutMirroring(); - void layoutMirroringIllegalParent(); - void smooth(); - void clip(); - void mapCoordinates(); - void mapCoordinates_data(); - void propertyChanges(); - void transforms(); - void transforms_data(); - void childrenRect(); - void childrenRectBug(); - void childrenRectBug2(); - void childrenRectBug3(); - - void childrenProperty(); - void resourcesProperty(); - - void transformCrash(); - void implicitSize(); - void qtbug_16871(); - void visibleChildren(); - void parentLoop(); -private: - QDeclarativeEngine engine; -}; - -class KeysTestObject : public QObject -{ - Q_OBJECT - - Q_PROPERTY(bool processLast READ processLast NOTIFY processLastChanged) - -public: - KeysTestObject() : mKey(0), mModifiers(0), mForwardedKey(0), mLast(false) {} - - void reset() { - mKey = 0; - mText = QString(); - mModifiers = 0; - mForwardedKey = 0; - } - - bool processLast() const { return mLast; } - void setProcessLast(bool b) { - if (b != mLast) { - mLast = b; - emit processLastChanged(); - } - } - -public slots: - void keyPress(int key, QString text, int modifiers) { - mKey = key; - mText = text; - mModifiers = modifiers; - } - void keyRelease(int key, QString text, int modifiers) { - mKey = key; - mText = text; - mModifiers = modifiers; - } - void forwardedKey(int key) { - mForwardedKey = key; - } - -signals: - void processLastChanged(); - -public: - int mKey; - QString mText; - int mModifiers; - int mForwardedKey; - bool mLast; - -private: -}; - -class KeyTestItem : public QQuickItem -{ - Q_OBJECT -public: - KeyTestItem(QQuickItem *parent=0) : QQuickItem(parent), mKey(0) {} - -protected: - void keyPressEvent(QKeyEvent *e) { - mKey = e->key(); - - if (e->key() == Qt::Key_A) - e->accept(); - else - e->ignore(); - } - - void keyReleaseEvent(QKeyEvent *e) { - if (e->key() == Qt::Key_B) - e->accept(); - else - e->ignore(); - } - -public: - int mKey; -}; - -QML_DECLARE_TYPE(KeyTestItem); - - -tst_QQuickItem::tst_QQuickItem() -{ -} - -void tst_QQuickItem::initTestCase() -{ - QDeclarativeDataTest::initTestCase(); - qmlRegisterType("Test",1,0,"KeyTestItem"); -} - -void tst_QQuickItem::cleanup() -{ - QInputMethodPrivate *inputMethodPrivate = QInputMethodPrivate::get(qApp->inputMethod()); - inputMethodPrivate->testContext = 0; -} - -void tst_QQuickItem::keys() -{ - QQuickView *canvas = new QQuickView(0); - canvas->setBaseSize(QSize(240,320)); - - KeysTestObject *testObject = new KeysTestObject; - canvas->rootContext()->setContextProperty("keysTestObject", testObject); - - canvas->rootContext()->setContextProperty("enableKeyHanding", QVariant(true)); - canvas->rootContext()->setContextProperty("forwardeeVisible", QVariant(true)); - - canvas->setSource(testFileUrl("keystest.qml")); - canvas->show(); - canvas->requestActivateWindow(); - QTest::qWaitForWindowShown(canvas); - QTRY_VERIFY(QGuiApplication::focusWindow() == canvas); - - QVERIFY(canvas->rootObject()); - QCOMPARE(canvas->rootObject()->property("isEnabled").toBool(), true); - - QKeyEvent key(QEvent::KeyPress, Qt::Key_A, Qt::NoModifier, "A", false, 1); - QGuiApplication::sendEvent(canvas, &key); - QCOMPARE(testObject->mKey, int(Qt::Key_A)); - QCOMPARE(testObject->mForwardedKey, int(Qt::Key_A)); - QCOMPARE(testObject->mText, QLatin1String("A")); - QVERIFY(testObject->mModifiers == Qt::NoModifier); - QVERIFY(!key.isAccepted()); - - testObject->reset(); - - key = QKeyEvent(QEvent::KeyRelease, Qt::Key_A, Qt::ShiftModifier, "A", false, 1); - QGuiApplication::sendEvent(canvas, &key); - QCOMPARE(testObject->mKey, int(Qt::Key_A)); - QCOMPARE(testObject->mForwardedKey, int(Qt::Key_A)); - QCOMPARE(testObject->mText, QLatin1String("A")); - QVERIFY(testObject->mModifiers == Qt::ShiftModifier); - QVERIFY(key.isAccepted()); - - testObject->reset(); - - key = QKeyEvent(QEvent::KeyPress, Qt::Key_Return, Qt::NoModifier, "", false, 1); - QGuiApplication::sendEvent(canvas, &key); - QCOMPARE(testObject->mKey, int(Qt::Key_Return)); - QCOMPARE(testObject->mForwardedKey, int(Qt::Key_Return)); - QCOMPARE(testObject->mText, QLatin1String("Return")); - QVERIFY(testObject->mModifiers == Qt::NoModifier); - QVERIFY(key.isAccepted()); - - testObject->reset(); - - key = QKeyEvent(QEvent::KeyPress, Qt::Key_0, Qt::NoModifier, "0", false, 1); - QGuiApplication::sendEvent(canvas, &key); - QCOMPARE(testObject->mKey, int(Qt::Key_0)); - QCOMPARE(testObject->mForwardedKey, int(Qt::Key_0)); - QCOMPARE(testObject->mText, QLatin1String("0")); - QVERIFY(testObject->mModifiers == Qt::NoModifier); - QVERIFY(key.isAccepted()); - - testObject->reset(); - - key = QKeyEvent(QEvent::KeyPress, Qt::Key_9, Qt::NoModifier, "9", false, 1); - QGuiApplication::sendEvent(canvas, &key); - QCOMPARE(testObject->mKey, int(Qt::Key_9)); - QCOMPARE(testObject->mForwardedKey, int(Qt::Key_9)); - QCOMPARE(testObject->mText, QLatin1String("9")); - QVERIFY(testObject->mModifiers == Qt::NoModifier); - QVERIFY(!key.isAccepted()); - - testObject->reset(); - - key = QKeyEvent(QEvent::KeyPress, Qt::Key_Tab, Qt::NoModifier, "", false, 1); - QGuiApplication::sendEvent(canvas, &key); - QCOMPARE(testObject->mKey, int(Qt::Key_Tab)); - QCOMPARE(testObject->mForwardedKey, int(Qt::Key_Tab)); - QCOMPARE(testObject->mText, QLatin1String("Tab")); - QVERIFY(testObject->mModifiers == Qt::NoModifier); - QVERIFY(key.isAccepted()); - - testObject->reset(); - - key = QKeyEvent(QEvent::KeyPress, Qt::Key_Backtab, Qt::NoModifier, "", false, 1); - QGuiApplication::sendEvent(canvas, &key); - QCOMPARE(testObject->mKey, int(Qt::Key_Backtab)); - QCOMPARE(testObject->mForwardedKey, int(Qt::Key_Backtab)); - QCOMPARE(testObject->mText, QLatin1String("Backtab")); - QVERIFY(testObject->mModifiers == Qt::NoModifier); - QVERIFY(key.isAccepted()); - - testObject->reset(); - - canvas->rootContext()->setContextProperty("forwardeeVisible", QVariant(false)); - key = QKeyEvent(QEvent::KeyPress, Qt::Key_A, Qt::NoModifier, "A", false, 1); - QGuiApplication::sendEvent(canvas, &key); - QCOMPARE(testObject->mKey, int(Qt::Key_A)); - QCOMPARE(testObject->mForwardedKey, 0); - QCOMPARE(testObject->mText, QLatin1String("A")); - QVERIFY(testObject->mModifiers == Qt::NoModifier); - QVERIFY(!key.isAccepted()); - - testObject->reset(); - - canvas->rootContext()->setContextProperty("enableKeyHanding", QVariant(false)); - QCOMPARE(canvas->rootObject()->property("isEnabled").toBool(), false); - - key = QKeyEvent(QEvent::KeyPress, Qt::Key_Return, Qt::NoModifier, "", false, 1); - QGuiApplication::sendEvent(canvas, &key); - QCOMPARE(testObject->mKey, 0); - QVERIFY(!key.isAccepted()); - - canvas->rootContext()->setContextProperty("enableKeyHanding", QVariant(true)); - QCOMPARE(canvas->rootObject()->property("isEnabled").toBool(), true); - - key = QKeyEvent(QEvent::KeyPress, Qt::Key_Return, Qt::NoModifier, "", false, 1); - QGuiApplication::sendEvent(canvas, &key); - QCOMPARE(testObject->mKey, int(Qt::Key_Return)); - QVERIFY(key.isAccepted()); - - delete canvas; - delete testObject; -} - -void tst_QQuickItem::keysProcessingOrder() -{ - QQuickView *canvas = new QQuickView(0); - canvas->setBaseSize(QSize(240,320)); - - KeysTestObject *testObject = new KeysTestObject; - canvas->rootContext()->setContextProperty("keysTestObject", testObject); - - canvas->setSource(testFileUrl("keyspriority.qml")); - canvas->show(); - canvas->requestActivateWindow(); - QTest::qWaitForWindowShown(canvas); - QTRY_VERIFY(QGuiApplication::focusWindow() == canvas); - - KeyTestItem *testItem = qobject_cast(canvas->rootObject()); - QVERIFY(testItem); - - QCOMPARE(testItem->property("priorityTest").toInt(), 0); - - QKeyEvent key(QEvent::KeyPress, Qt::Key_A, Qt::NoModifier, "A", false, 1); - QGuiApplication::sendEvent(canvas, &key); - QCOMPARE(testObject->mKey, int(Qt::Key_A)); - QCOMPARE(testObject->mText, QLatin1String("A")); - QVERIFY(testObject->mModifiers == Qt::NoModifier); - QVERIFY(key.isAccepted()); - - testObject->reset(); - - testObject->setProcessLast(true); - - QCOMPARE(testItem->property("priorityTest").toInt(), 1); - - key = QKeyEvent(QEvent::KeyPress, Qt::Key_A, Qt::NoModifier, "A", false, 1); - QGuiApplication::sendEvent(canvas, &key); - QCOMPARE(testObject->mKey, 0); - QVERIFY(key.isAccepted()); - - testObject->reset(); - - key = QKeyEvent(QEvent::KeyPress, Qt::Key_B, Qt::NoModifier, "B", false, 1); - QGuiApplication::sendEvent(canvas, &key); - QCOMPARE(testObject->mKey, int(Qt::Key_B)); - QCOMPARE(testObject->mText, QLatin1String("B")); - QVERIFY(testObject->mModifiers == Qt::NoModifier); - QVERIFY(!key.isAccepted()); - - testObject->reset(); - - key = QKeyEvent(QEvent::KeyRelease, Qt::Key_B, Qt::NoModifier, "B", false, 1); - QGuiApplication::sendEvent(canvas, &key); - QCOMPARE(testObject->mKey, 0); - QVERIFY(key.isAccepted()); - - delete canvas; - delete testObject; -} - -void tst_QQuickItem::keysim() -{ - PlatformInputContext platformInputContext; - QInputMethodPrivate *inputMethodPrivate = QInputMethodPrivate::get(qApp->inputMethod()); - inputMethodPrivate->testContext = &platformInputContext; - - QQuickView *canvas = new QQuickView(0); - canvas->setBaseSize(QSize(240,320)); - - canvas->setSource(testFileUrl("keysim.qml")); - canvas->show(); - canvas->requestActivateWindow(); - QTest::qWaitForWindowShown(canvas); - QTRY_VERIFY(QGuiApplication::focusWindow() == canvas); - - QVERIFY(canvas->rootObject()); - QVERIFY(canvas->rootObject()->hasFocus() && canvas->rootObject()->hasActiveFocus()); - - QQuickTextInput *input = canvas->rootObject()->findChild(); - QVERIFY(input); - - QInputMethodEvent ev("Hello world!", QList()); - QGuiApplication::sendEvent(qGuiApp->focusObject(), &ev); - - QEXPECT_FAIL("", "QTBUG-24280", Continue); - QCOMPARE(input->text(), QLatin1String("Hello world!")); - - delete canvas; -} - -QQuickItemPrivate *childPrivate(QQuickItem *rootItem, const char * itemString) -{ - QQuickItem *item = findItem(rootItem, QString(QLatin1String(itemString))); - QQuickItemPrivate* itemPrivate = QQuickItemPrivate::get(item); - return itemPrivate; -} - -QVariant childProperty(QQuickItem *rootItem, const char * itemString, const char * property) -{ - QQuickItem *item = findItem(rootItem, QString(QLatin1String(itemString))); - return item->property(property); -} - -bool anchorsMirrored(QQuickItem *rootItem, const char * itemString) -{ - QQuickItem *item = findItem(rootItem, QString(QLatin1String(itemString))); - QQuickItemPrivate* itemPrivate = QQuickItemPrivate::get(item); - return itemPrivate->anchors()->mirrored(); -} - -void tst_QQuickItem::layoutMirroring() -{ - QQuickView *canvas = new QQuickView(0); - canvas->setSource(testFileUrl("layoutmirroring.qml")); - canvas->show(); - - QQuickItem *rootItem = qobject_cast(canvas->rootObject()); - QVERIFY(rootItem); - QQuickItemPrivate *rootPrivate = QQuickItemPrivate::get(rootItem); - QVERIFY(rootPrivate); - - QCOMPARE(childPrivate(rootItem, "mirrored1")->effectiveLayoutMirror, true); - QCOMPARE(childPrivate(rootItem, "mirrored2")->effectiveLayoutMirror, true); - QCOMPARE(childPrivate(rootItem, "notMirrored1")->effectiveLayoutMirror, false); - QCOMPARE(childPrivate(rootItem, "notMirrored2")->effectiveLayoutMirror, false); - QCOMPARE(childPrivate(rootItem, "inheritedMirror1")->effectiveLayoutMirror, true); - QCOMPARE(childPrivate(rootItem, "inheritedMirror2")->effectiveLayoutMirror, true); - - QCOMPARE(anchorsMirrored(rootItem, "mirrored1"), true); - QCOMPARE(anchorsMirrored(rootItem, "mirrored2"), true); - QCOMPARE(anchorsMirrored(rootItem, "notMirrored1"), false); - QCOMPARE(anchorsMirrored(rootItem, "notMirrored2"), false); - QCOMPARE(anchorsMirrored(rootItem, "inheritedMirror1"), true); - QCOMPARE(anchorsMirrored(rootItem, "inheritedMirror2"), true); - - QCOMPARE(childPrivate(rootItem, "mirrored1")->inheritedLayoutMirror, true); - QCOMPARE(childPrivate(rootItem, "mirrored2")->inheritedLayoutMirror, false); - QCOMPARE(childPrivate(rootItem, "notMirrored1")->inheritedLayoutMirror, true); - QCOMPARE(childPrivate(rootItem, "notMirrored2")->inheritedLayoutMirror, false); - QCOMPARE(childPrivate(rootItem, "inheritedMirror1")->inheritedLayoutMirror, true); - QCOMPARE(childPrivate(rootItem, "inheritedMirror2")->inheritedLayoutMirror, true); - - QCOMPARE(childPrivate(rootItem, "mirrored1")->isMirrorImplicit, false); - QCOMPARE(childPrivate(rootItem, "mirrored2")->isMirrorImplicit, false); - QCOMPARE(childPrivate(rootItem, "notMirrored1")->isMirrorImplicit, false); - QCOMPARE(childPrivate(rootItem, "notMirrored2")->isMirrorImplicit, true); - QCOMPARE(childPrivate(rootItem, "inheritedMirror1")->isMirrorImplicit, true); - QCOMPARE(childPrivate(rootItem, "inheritedMirror2")->isMirrorImplicit, true); - - QCOMPARE(childPrivate(rootItem, "mirrored1")->inheritMirrorFromParent, true); - QCOMPARE(childPrivate(rootItem, "mirrored2")->inheritMirrorFromParent, false); - QCOMPARE(childPrivate(rootItem, "notMirrored1")->inheritMirrorFromParent, true); - QCOMPARE(childPrivate(rootItem, "notMirrored2")->inheritMirrorFromParent, false); - QCOMPARE(childPrivate(rootItem, "inheritedMirror1")->inheritMirrorFromParent, true); - QCOMPARE(childPrivate(rootItem, "inheritedMirror2")->inheritMirrorFromParent, true); - - QCOMPARE(childPrivate(rootItem, "mirrored1")->inheritMirrorFromItem, true); - QCOMPARE(childPrivate(rootItem, "mirrored2")->inheritMirrorFromItem, false); - QCOMPARE(childPrivate(rootItem, "notMirrored1")->inheritMirrorFromItem, false); - QCOMPARE(childPrivate(rootItem, "notMirrored2")->inheritMirrorFromItem, false); - QCOMPARE(childPrivate(rootItem, "inheritedMirror1")->inheritMirrorFromItem, false); - QCOMPARE(childPrivate(rootItem, "inheritedMirror2")->inheritMirrorFromItem, false); - - // load dynamic content using Loader that needs to inherit mirroring - rootItem->setProperty("state", "newContent"); - QCOMPARE(childPrivate(rootItem, "notMirrored3")->effectiveLayoutMirror, false); - QCOMPARE(childPrivate(rootItem, "inheritedMirror3")->effectiveLayoutMirror, true); - - QCOMPARE(childPrivate(rootItem, "notMirrored3")->inheritedLayoutMirror, true); - QCOMPARE(childPrivate(rootItem, "inheritedMirror3")->inheritedLayoutMirror, true); - - QCOMPARE(childPrivate(rootItem, "notMirrored3")->isMirrorImplicit, false); - QCOMPARE(childPrivate(rootItem, "inheritedMirror3")->isMirrorImplicit, true); - - QCOMPARE(childPrivate(rootItem, "notMirrored3")->inheritMirrorFromParent, true); - QCOMPARE(childPrivate(rootItem, "inheritedMirror3")->inheritMirrorFromParent, true); - - QCOMPARE(childPrivate(rootItem, "notMirrored3")->inheritMirrorFromItem, false); - QCOMPARE(childPrivate(rootItem, "notMirrored3")->inheritMirrorFromItem, false); - - // disable inheritance - rootItem->setProperty("childrenInherit", false); - - QCOMPARE(childPrivate(rootItem, "inheritedMirror1")->effectiveLayoutMirror, false); - QCOMPARE(childPrivate(rootItem, "inheritedMirror2")->effectiveLayoutMirror, false); - QCOMPARE(childPrivate(rootItem, "mirrored1")->effectiveLayoutMirror, true); - QCOMPARE(childPrivate(rootItem, "notMirrored1")->effectiveLayoutMirror, false); - - QCOMPARE(childPrivate(rootItem, "inheritedMirror1")->inheritedLayoutMirror, false); - QCOMPARE(childPrivate(rootItem, "inheritedMirror2")->inheritedLayoutMirror, false); - QCOMPARE(childPrivate(rootItem, "mirrored1")->inheritedLayoutMirror, false); - QCOMPARE(childPrivate(rootItem, "notMirrored1")->inheritedLayoutMirror, false); - - // re-enable inheritance - rootItem->setProperty("childrenInherit", true); - - QCOMPARE(childPrivate(rootItem, "inheritedMirror1")->effectiveLayoutMirror, true); - QCOMPARE(childPrivate(rootItem, "inheritedMirror2")->effectiveLayoutMirror, true); - QCOMPARE(childPrivate(rootItem, "mirrored1")->effectiveLayoutMirror, true); - QCOMPARE(childPrivate(rootItem, "notMirrored1")->effectiveLayoutMirror, false); - - QCOMPARE(childPrivate(rootItem, "inheritedMirror1")->inheritedLayoutMirror, true); - QCOMPARE(childPrivate(rootItem, "inheritedMirror2")->inheritedLayoutMirror, true); - QCOMPARE(childPrivate(rootItem, "mirrored1")->inheritedLayoutMirror, true); - QCOMPARE(childPrivate(rootItem, "notMirrored1")->inheritedLayoutMirror, true); - - // - // dynamic parenting - // - QQuickItem *parentItem1 = new QQuickItem(); - QQuickItemPrivate::get(parentItem1)->effectiveLayoutMirror = true; // LayoutMirroring.enabled: true - QQuickItemPrivate::get(parentItem1)->isMirrorImplicit = false; - QQuickItemPrivate::get(parentItem1)->inheritMirrorFromItem = true; // LayoutMirroring.childrenInherit: true - QQuickItemPrivate::get(parentItem1)->resolveLayoutMirror(); - - // inherit in constructor - QQuickItem *childItem1 = new QQuickItem(parentItem1); - QCOMPARE(QQuickItemPrivate::get(childItem1)->effectiveLayoutMirror, true); - QCOMPARE(QQuickItemPrivate::get(childItem1)->inheritMirrorFromParent, true); - - // inherit through a parent change - QQuickItem *childItem2 = new QQuickItem(); - QCOMPARE(QQuickItemPrivate::get(childItem2)->effectiveLayoutMirror, false); - QCOMPARE(QQuickItemPrivate::get(childItem2)->inheritMirrorFromParent, false); - childItem2->setParentItem(parentItem1); - QCOMPARE(QQuickItemPrivate::get(childItem2)->effectiveLayoutMirror, true); - QCOMPARE(QQuickItemPrivate::get(childItem2)->inheritMirrorFromParent, true); - - // stop inherting through a parent change - QQuickItem *parentItem2 = new QQuickItem(); - QQuickItemPrivate::get(parentItem2)->effectiveLayoutMirror = true; // LayoutMirroring.enabled: true - QQuickItemPrivate::get(parentItem2)->resolveLayoutMirror(); - childItem2->setParentItem(parentItem2); - QCOMPARE(QQuickItemPrivate::get(childItem2)->effectiveLayoutMirror, false); - QCOMPARE(QQuickItemPrivate::get(childItem2)->inheritMirrorFromParent, false); - - delete parentItem1; - delete parentItem2; -} - -void tst_QQuickItem::layoutMirroringIllegalParent() -{ - QDeclarativeComponent component(&engine); - component.setData("import QtQuick 2.0; QtObject { LayoutMirroring.enabled: true; LayoutMirroring.childrenInherit: true }", QUrl::fromLocalFile("")); - QTest::ignoreMessage(QtWarningMsg, "file::1:21: QML QtObject: LayoutDirection attached property only works with Items"); - QObject *object = component.create(); - QVERIFY(object != 0); -} - -void tst_QQuickItem::keyNavigation() -{ - QQuickView *canvas = new QQuickView(0); - canvas->setBaseSize(QSize(240,320)); - - canvas->setSource(testFileUrl("keynavigationtest.qml")); - canvas->show(); - canvas->requestActivateWindow(); - QTest::qWaitForWindowShown(canvas); - QTRY_VERIFY(QGuiApplication::focusWindow() == canvas); - - QQuickItem *item = findItem(canvas->rootObject(), "item1"); - QVERIFY(item); - QVERIFY(item->hasActiveFocus()); - - QVariant result; - QVERIFY(QMetaObject::invokeMethod(canvas->rootObject(), "verify", - Q_RETURN_ARG(QVariant, result))); - QVERIFY(result.toBool()); - - // right - QKeyEvent key(QEvent::KeyPress, Qt::Key_Right, Qt::NoModifier, "", false, 1); - QGuiApplication::sendEvent(canvas, &key); - QVERIFY(key.isAccepted()); - - item = findItem(canvas->rootObject(), "item2"); - QVERIFY(item); - QVERIFY(item->hasActiveFocus()); - - // down - key = QKeyEvent(QEvent::KeyPress, Qt::Key_Down, Qt::NoModifier, "", false, 1); - QGuiApplication::sendEvent(canvas, &key); - QVERIFY(key.isAccepted()); - - item = findItem(canvas->rootObject(), "item4"); - QVERIFY(item); - QVERIFY(item->hasActiveFocus()); - - // left - key = QKeyEvent(QEvent::KeyPress, Qt::Key_Left, Qt::NoModifier, "", false, 1); - QGuiApplication::sendEvent(canvas, &key); - QVERIFY(key.isAccepted()); - - item = findItem(canvas->rootObject(), "item3"); - QVERIFY(item); - QVERIFY(item->hasActiveFocus()); - - // up - key = QKeyEvent(QEvent::KeyPress, Qt::Key_Up, Qt::NoModifier, "", false, 1); - QGuiApplication::sendEvent(canvas, &key); - QVERIFY(key.isAccepted()); - - item = findItem(canvas->rootObject(), "item1"); - QVERIFY(item); - QVERIFY(item->hasActiveFocus()); - - // tab - key = QKeyEvent(QEvent::KeyPress, Qt::Key_Tab, Qt::NoModifier, "", false, 1); - QGuiApplication::sendEvent(canvas, &key); - QVERIFY(key.isAccepted()); - - item = findItem(canvas->rootObject(), "item2"); - QVERIFY(item); - QVERIFY(item->hasActiveFocus()); - - // backtab - key = QKeyEvent(QEvent::KeyPress, Qt::Key_Backtab, Qt::NoModifier, "", false, 1); - QGuiApplication::sendEvent(canvas, &key); - QVERIFY(key.isAccepted()); - - item = findItem(canvas->rootObject(), "item1"); - QVERIFY(item); - QVERIFY(item->hasActiveFocus()); - - delete canvas; -} - -void tst_QQuickItem::keyNavigation_RightToLeft() -{ - QQuickView *canvas = new QQuickView(0); - canvas->setBaseSize(QSize(240,320)); - - canvas->setSource(testFileUrl("keynavigationtest.qml")); - canvas->show(); - canvas->requestActivateWindow(); - QTest::qWaitForWindowShown(canvas); - QTRY_VERIFY(QGuiApplication::focusWindow() == canvas); - - QQuickItem *rootItem = qobject_cast(canvas->rootObject()); - QVERIFY(rootItem); - QQuickItemPrivate* rootItemPrivate = QQuickItemPrivate::get(rootItem); - - rootItemPrivate->effectiveLayoutMirror = true; // LayoutMirroring.mirror: true - rootItemPrivate->isMirrorImplicit = false; - rootItemPrivate->inheritMirrorFromItem = true; // LayoutMirroring.inherit: true - rootItemPrivate->resolveLayoutMirror(); - - QEvent wa(QEvent::WindowActivate); - QGuiApplication::sendEvent(canvas, &wa); - QFocusEvent fe(QEvent::FocusIn); - QGuiApplication::sendEvent(canvas, &fe); - - QQuickItem *item = findItem(canvas->rootObject(), "item1"); - QVERIFY(item); - QVERIFY(item->hasActiveFocus()); - - QVariant result; - QVERIFY(QMetaObject::invokeMethod(canvas->rootObject(), "verify", - Q_RETURN_ARG(QVariant, result))); - QVERIFY(result.toBool()); - - // right - QKeyEvent key(QEvent::KeyPress, Qt::Key_Left, Qt::NoModifier, "", false, 1); - QGuiApplication::sendEvent(canvas, &key); - QVERIFY(key.isAccepted()); - - item = findItem(canvas->rootObject(), "item2"); - QVERIFY(item); - QVERIFY(item->hasActiveFocus()); - - // left - key = QKeyEvent(QEvent::KeyPress, Qt::Key_Right, Qt::NoModifier, "", false, 1); - QGuiApplication::sendEvent(canvas, &key); - QVERIFY(key.isAccepted()); - - item = findItem(canvas->rootObject(), "item1"); - QVERIFY(item); - QVERIFY(item->hasActiveFocus()); - - delete canvas; -} - -void tst_QQuickItem::keyNavigation_skipNotVisible() -{ - QQuickView *canvas = new QQuickView(0); - canvas->setBaseSize(QSize(240,320)); - - canvas->setSource(testFileUrl("keynavigationtest.qml")); - canvas->show(); - canvas->requestActivateWindow(); - QTest::qWaitForWindowShown(canvas); - QTRY_VERIFY(QGuiApplication::focusWindow() == canvas); - - QQuickItem *item = findItem(canvas->rootObject(), "item1"); - QVERIFY(item); - QVERIFY(item->hasActiveFocus()); - - // Set item 2 to not visible - item = findItem(canvas->rootObject(), "item2"); - QVERIFY(item); - item->setVisible(false); - QVERIFY(!item->isVisible()); - - // right - QKeyEvent key(QEvent::KeyPress, Qt::Key_Right, Qt::NoModifier, "", false, 1); - QGuiApplication::sendEvent(canvas, &key); - QVERIFY(key.isAccepted()); - - item = findItem(canvas->rootObject(), "item1"); - QVERIFY(item); - QVERIFY(item->hasActiveFocus()); - - // tab - key = QKeyEvent(QEvent::KeyPress, Qt::Key_Tab, Qt::NoModifier, "", false, 1); - QGuiApplication::sendEvent(canvas, &key); - QVERIFY(key.isAccepted()); - - item = findItem(canvas->rootObject(), "item3"); - QVERIFY(item); - QVERIFY(item->hasActiveFocus()); - - // backtab - key = QKeyEvent(QEvent::KeyPress, Qt::Key_Backtab, Qt::NoModifier, "", false, 1); - QGuiApplication::sendEvent(canvas, &key); - QVERIFY(key.isAccepted()); - - item = findItem(canvas->rootObject(), "item1"); - QVERIFY(item); - QVERIFY(item->hasActiveFocus()); - - //Set item 3 to not visible - item = findItem(canvas->rootObject(), "item3"); - QVERIFY(item); - item->setVisible(false); - QVERIFY(!item->isVisible()); - - // tab - key = QKeyEvent(QEvent::KeyPress, Qt::Key_Tab, Qt::NoModifier, "", false, 1); - QGuiApplication::sendEvent(canvas, &key); - QVERIFY(key.isAccepted()); - - item = findItem(canvas->rootObject(), "item4"); - QVERIFY(item); - QVERIFY(item->hasActiveFocus()); - - // backtab - key = QKeyEvent(QEvent::KeyPress, Qt::Key_Backtab, Qt::NoModifier, "", false, 1); - QGuiApplication::sendEvent(canvas, &key); - QVERIFY(key.isAccepted()); - - item = findItem(canvas->rootObject(), "item1"); - QVERIFY(item); - QVERIFY(item->hasActiveFocus()); - - delete canvas; -} - -void tst_QQuickItem::keyNavigation_implicitSetting() -{ - QQuickView *canvas = new QQuickView(0); - canvas->setBaseSize(QSize(240,320)); - - canvas->setSource(testFileUrl("keynavigationtest_implicit.qml")); - canvas->show(); - canvas->requestActivateWindow(); - QTest::qWaitForWindowShown(canvas); - QTRY_VERIFY(QGuiApplication::focusWindow() == canvas); - - QEvent wa(QEvent::WindowActivate); - QGuiApplication::sendEvent(canvas, &wa); - QFocusEvent fe(QEvent::FocusIn); - QGuiApplication::sendEvent(canvas, &fe); - - QQuickItem *item = findItem(canvas->rootObject(), "item1"); - QVERIFY(item); - QVERIFY(item->hasActiveFocus()); - - QVariant result; - QVERIFY(QMetaObject::invokeMethod(canvas->rootObject(), "verify", - Q_RETURN_ARG(QVariant, result))); - QVERIFY(result.toBool()); - - // right - QKeyEvent key(QEvent::KeyPress, Qt::Key_Right, Qt::NoModifier, "", false, 1); - QGuiApplication::sendEvent(canvas, &key); - QVERIFY(key.isAccepted()); - - item = findItem(canvas->rootObject(), "item2"); - QVERIFY(item); - QVERIFY(item->hasActiveFocus()); - - // back to item1 - key = QKeyEvent(QEvent::KeyPress, Qt::Key_Left, Qt::NoModifier, "", false, 1); - QGuiApplication::sendEvent(canvas, &key); - QVERIFY(key.isAccepted()); - - item = findItem(canvas->rootObject(), "item1"); - QVERIFY(item); - QVERIFY(item->hasActiveFocus()); - - // down - key = QKeyEvent(QEvent::KeyPress, Qt::Key_Down, Qt::NoModifier, "", false, 1); - QGuiApplication::sendEvent(canvas, &key); - QVERIFY(key.isAccepted()); - - item = findItem(canvas->rootObject(), "item3"); - QVERIFY(item); - QVERIFY(item->hasActiveFocus()); - - // move to item4 - key = QKeyEvent(QEvent::KeyPress, Qt::Key_Right, Qt::NoModifier, "", false, 1); - QGuiApplication::sendEvent(canvas, &key); - QVERIFY(key.isAccepted()); - - item = findItem(canvas->rootObject(), "item4"); - QVERIFY(item); - QVERIFY(item->hasActiveFocus()); - - // left - key = QKeyEvent(QEvent::KeyPress, Qt::Key_Left, Qt::NoModifier, "", false, 1); - QGuiApplication::sendEvent(canvas, &key); - QVERIFY(key.isAccepted()); - - item = findItem(canvas->rootObject(), "item3"); - QVERIFY(item); - QVERIFY(item->hasActiveFocus()); - - // back to item4 - key = QKeyEvent(QEvent::KeyPress, Qt::Key_Right, Qt::NoModifier, "", false, 1); - QGuiApplication::sendEvent(canvas, &key); - QVERIFY(key.isAccepted()); - - item = findItem(canvas->rootObject(), "item4"); - QVERIFY(item); - QVERIFY(item->hasActiveFocus()); - - // up - key = QKeyEvent(QEvent::KeyPress, Qt::Key_Up, Qt::NoModifier, "", false, 1); - QGuiApplication::sendEvent(canvas, &key); - QVERIFY(key.isAccepted()); - - item = findItem(canvas->rootObject(), "item2"); - QVERIFY(item); - QVERIFY(item->hasActiveFocus()); - - // back to item4 - key = QKeyEvent(QEvent::KeyPress, Qt::Key_Down, Qt::NoModifier, "", false, 1); - QGuiApplication::sendEvent(canvas, &key); - QVERIFY(key.isAccepted()); - - item = findItem(canvas->rootObject(), "item4"); - QVERIFY(item); - QVERIFY(item->hasActiveFocus()); - - // tab - key = QKeyEvent(QEvent::KeyPress, Qt::Key_Tab, Qt::NoModifier, "", false, 1); - QGuiApplication::sendEvent(canvas, &key); - QVERIFY(key.isAccepted()); - - item = findItem(canvas->rootObject(), "item1"); - QVERIFY(item); - QVERIFY(item->hasActiveFocus()); - - // back to item4 - key = QKeyEvent(QEvent::KeyPress, Qt::Key_Backtab, Qt::NoModifier, "", false, 1); - QGuiApplication::sendEvent(canvas, &key); - QVERIFY(key.isAccepted()); - - item = findItem(canvas->rootObject(), "item4"); - QVERIFY(item); - QVERIFY(item->hasActiveFocus()); - - // backtab - key = QKeyEvent(QEvent::KeyPress, Qt::Key_Backtab, Qt::NoModifier, "", false, 1); - QGuiApplication::sendEvent(canvas, &key); - QVERIFY(key.isAccepted()); - - item = findItem(canvas->rootObject(), "item3"); - QVERIFY(item); - QVERIFY(item->hasActiveFocus()); - - delete canvas; -} - -void tst_QQuickItem::smooth() -{ - QDeclarativeComponent component(&engine); - component.setData("import QtQuick 2.0; Item { smooth: false; }", QUrl::fromLocalFile("")); - QQuickItem *item = qobject_cast(component.create()); - QSignalSpy spy(item, SIGNAL(smoothChanged(bool))); - - QVERIFY(item); - QVERIFY(!item->smooth()); - - item->setSmooth(true); - QVERIFY(item->smooth()); - QCOMPARE(spy.count(),1); - QList arguments = spy.first(); - QVERIFY(arguments.count() == 1); - QVERIFY(arguments.at(0).toBool() == true); - - item->setSmooth(true); - QCOMPARE(spy.count(),1); - - item->setSmooth(false); - QVERIFY(!item->smooth()); - QCOMPARE(spy.count(),2); - item->setSmooth(false); - QCOMPARE(spy.count(),2); - - delete item; -} - -void tst_QQuickItem::clip() -{ - QDeclarativeComponent component(&engine); - component.setData("import QtQuick 2.0\nItem { clip: false\n }", QUrl::fromLocalFile("")); - QQuickItem *item = qobject_cast(component.create()); - QSignalSpy spy(item, SIGNAL(clipChanged(bool))); - - QVERIFY(item); - QVERIFY(!item->clip()); - - item->setClip(true); - QVERIFY(item->clip()); - - QList arguments = spy.first(); - QVERIFY(arguments.count() == 1); - QVERIFY(arguments.at(0).toBool() == true); - - QCOMPARE(spy.count(),1); - item->setClip(true); - QCOMPARE(spy.count(),1); - - item->setClip(false); - QVERIFY(!item->clip()); - QCOMPARE(spy.count(),2); - item->setClip(false); - QCOMPARE(spy.count(),2); - - delete item; -} - -void tst_QQuickItem::mapCoordinates() -{ - QFETCH(int, x); - QFETCH(int, y); - - QQuickView *canvas = new QQuickView(0); - canvas->setBaseSize(QSize(300, 300)); - canvas->setSource(testFileUrl("mapCoordinates.qml")); - canvas->show(); - qApp->processEvents(); - - QQuickItem *root = qobject_cast(canvas->rootObject()); - QVERIFY(root != 0); - QQuickItem *a = findItem(canvas->rootObject(), "itemA"); - QVERIFY(a != 0); - QQuickItem *b = findItem(canvas->rootObject(), "itemB"); - QVERIFY(b != 0); - - QVariant result; - - QVERIFY(QMetaObject::invokeMethod(root, "mapAToB", - Q_RETURN_ARG(QVariant, result), Q_ARG(QVariant, x), Q_ARG(QVariant, y))); - QCOMPARE(result.value(), qobject_cast(a)->mapToItem(b, QPointF(x, y))); - - QVERIFY(QMetaObject::invokeMethod(root, "mapAFromB", - Q_RETURN_ARG(QVariant, result), Q_ARG(QVariant, x), Q_ARG(QVariant, y))); - QCOMPARE(result.value(), qobject_cast(a)->mapFromItem(b, QPointF(x, y))); - - QVERIFY(QMetaObject::invokeMethod(root, "mapAToNull", - Q_RETURN_ARG(QVariant, result), Q_ARG(QVariant, x), Q_ARG(QVariant, y))); - QCOMPARE(result.value(), qobject_cast(a)->mapToScene(QPointF(x, y))); - - QVERIFY(QMetaObject::invokeMethod(root, "mapAFromNull", - Q_RETURN_ARG(QVariant, result), Q_ARG(QVariant, x), Q_ARG(QVariant, y))); - QCOMPARE(result.value(), qobject_cast(a)->mapFromScene(QPointF(x, y))); - - QString warning1 = testFileUrl("mapCoordinates.qml").toString() + ":48:5: QML Item: mapToItem() given argument \"1122\" which is neither null nor an Item"; - QString warning2 = testFileUrl("mapCoordinates.qml").toString() + ":48:5: QML Item: mapFromItem() given argument \"1122\" which is neither null nor an Item"; - - QTest::ignoreMessage(QtWarningMsg, qPrintable(warning1)); - QVERIFY(QMetaObject::invokeMethod(root, "checkMapAToInvalid", - Q_RETURN_ARG(QVariant, result), Q_ARG(QVariant, x), Q_ARG(QVariant, y))); - QVERIFY(result.toBool()); - - QTest::ignoreMessage(QtWarningMsg, qPrintable(warning2)); - QVERIFY(QMetaObject::invokeMethod(root, "checkMapAFromInvalid", - Q_RETURN_ARG(QVariant, result), Q_ARG(QVariant, x), Q_ARG(QVariant, y))); - QVERIFY(result.toBool()); - - delete canvas; -} - -void tst_QQuickItem::mapCoordinates_data() -{ - QTest::addColumn("x"); - QTest::addColumn("y"); - - for (int i=-20; i<=20; i+=10) - QTest::newRow(QTest::toString(i)) << i << i; -} - -void tst_QQuickItem::transforms_data() -{ - QTest::addColumn("qml"); - QTest::addColumn("transform"); - QTest::newRow("translate") << QByteArray("Translate { x: 10; y: 20 }") - << QTransform(1,0,0,0,1,0,10,20,1); - QTest::newRow("rotation") << QByteArray("Rotation { angle: 90 }") - << QTransform(0,1,0,-1,0,0,0,0,1); - QTest::newRow("scale") << QByteArray("Scale { xScale: 1.5; yScale: -2 }") - << QTransform(1.5,0,0,0,-2,0,0,0,1); - QTest::newRow("sequence") << QByteArray("[ Translate { x: 10; y: 20 }, Scale { xScale: 1.5; yScale: -2 } ]") - << QTransform(1,0,0,0,1,0,10,20,1) * QTransform(1.5,0,0,0,-2,0,0,0,1); -} - -void tst_QQuickItem::transforms() -{ - QFETCH(QByteArray, qml); - QFETCH(QTransform, transform); - QDeclarativeComponent component(&engine); - component.setData("import QtQuick 2.0\nItem { transform: "+qml+"}", QUrl::fromLocalFile("")); - QQuickItem *item = qobject_cast(component.create()); - QVERIFY(item); - QCOMPARE(item->itemTransform(0,0), transform); -} - -void tst_QQuickItem::childrenProperty() -{ - QDeclarativeComponent component(&engine, testFileUrl("childrenProperty.qml")); - - QObject *o = component.create(); - QVERIFY(o != 0); - - QCOMPARE(o->property("test1").toBool(), true); - QCOMPARE(o->property("test2").toBool(), true); - QCOMPARE(o->property("test3").toBool(), true); - QCOMPARE(o->property("test4").toBool(), true); - QCOMPARE(o->property("test5").toBool(), true); - delete o; -} - -void tst_QQuickItem::resourcesProperty() -{ - QDeclarativeComponent component(&engine, testFileUrl("resourcesProperty.qml")); - - QObject *o = component.create(); - QVERIFY(o != 0); - - QCOMPARE(o->property("test1").toBool(), true); - QCOMPARE(o->property("test2").toBool(), true); - QCOMPARE(o->property("test3").toBool(), true); - QCOMPARE(o->property("test4").toBool(), true); - QCOMPARE(o->property("test5").toBool(), true); - delete o; -} - -void tst_QQuickItem::propertyChanges() -{ - QQuickView *canvas = new QQuickView(0); - canvas->setBaseSize(QSize(300, 300)); - canvas->setSource(testFileUrl("propertychanges.qml")); - canvas->show(); - canvas->requestActivateWindow(); - QTest::qWaitForWindowShown(canvas); - QTRY_VERIFY(QGuiApplication::focusWindow() == canvas); - - QQuickItem *item = findItem(canvas->rootObject(), "item"); - QQuickItem *parentItem = findItem(canvas->rootObject(), "parentItem"); - - QVERIFY(item); - QVERIFY(parentItem); - - QSignalSpy parentSpy(item, SIGNAL(parentChanged(QQuickItem *))); - QSignalSpy widthSpy(item, SIGNAL(widthChanged())); - QSignalSpy heightSpy(item, SIGNAL(heightChanged())); - QSignalSpy baselineOffsetSpy(item, SIGNAL(baselineOffsetChanged(qreal))); - QSignalSpy childrenRectSpy(parentItem, SIGNAL(childrenRectChanged(QRectF))); - QSignalSpy focusSpy(item, SIGNAL(focusChanged(bool))); - QSignalSpy wantsFocusSpy(parentItem, SIGNAL(activeFocusChanged(bool))); - QSignalSpy childrenChangedSpy(parentItem, SIGNAL(childrenChanged())); - QSignalSpy xSpy(item, SIGNAL(xChanged())); - QSignalSpy ySpy(item, SIGNAL(yChanged())); - - item->setParentItem(parentItem); - item->setWidth(100.0); - item->setHeight(200.0); - item->setFocus(true); - item->setBaselineOffset(10.0); - - QCOMPARE(item->parentItem(), parentItem); - QCOMPARE(parentSpy.count(),1); - QList parentArguments = parentSpy.first(); - QVERIFY(parentArguments.count() == 1); - QCOMPARE(item->parentItem(), qvariant_cast(parentArguments.at(0))); - QCOMPARE(childrenChangedSpy.count(),1); - - item->setParentItem(parentItem); - QCOMPARE(childrenChangedSpy.count(),1); - - QCOMPARE(item->width(), 100.0); - QCOMPARE(widthSpy.count(),1); - - QCOMPARE(item->height(), 200.0); - QCOMPARE(heightSpy.count(),1); - - QCOMPARE(item->baselineOffset(), 10.0); - QCOMPARE(baselineOffsetSpy.count(),1); - QList baselineOffsetArguments = baselineOffsetSpy.first(); - QVERIFY(baselineOffsetArguments.count() == 1); - QCOMPARE(item->baselineOffset(), baselineOffsetArguments.at(0).toReal()); - - QCOMPARE(parentItem->childrenRect(), QRectF(0.0,0.0,100.0,200.0)); - QCOMPARE(childrenRectSpy.count(),1); - QList childrenRectArguments = childrenRectSpy.at(0); - QVERIFY(childrenRectArguments.count() == 1); - QCOMPARE(parentItem->childrenRect(), childrenRectArguments.at(0).toRectF()); - - QCOMPARE(item->hasActiveFocus(), true); - QCOMPARE(focusSpy.count(),1); - QList focusArguments = focusSpy.first(); - QVERIFY(focusArguments.count() == 1); - QCOMPARE(focusArguments.at(0).toBool(), true); - - QCOMPARE(parentItem->hasActiveFocus(), false); - QCOMPARE(parentItem->hasFocus(), false); - QCOMPARE(wantsFocusSpy.count(),0); - - item->setX(10.0); - QCOMPARE(item->x(), 10.0); - QCOMPARE(xSpy.count(), 1); - - item->setY(10.0); - QCOMPARE(item->y(), 10.0); - QCOMPARE(ySpy.count(), 1); - - delete canvas; -} - -void tst_QQuickItem::childrenRect() -{ - QQuickView *canvas = new QQuickView(0); - canvas->setSource(testFileUrl("childrenRect.qml")); - canvas->setBaseSize(QSize(240,320)); - canvas->show(); - - QQuickItem *o = canvas->rootObject(); - QQuickItem *item = o->findChild("testItem"); - QCOMPARE(item->width(), qreal(0)); - QCOMPARE(item->height(), qreal(0)); - - o->setProperty("childCount", 1); - QCOMPARE(item->width(), qreal(10)); - QCOMPARE(item->height(), qreal(20)); - - o->setProperty("childCount", 5); - QCOMPARE(item->width(), qreal(50)); - QCOMPARE(item->height(), qreal(100)); - - o->setProperty("childCount", 0); - QCOMPARE(item->width(), qreal(0)); - QCOMPARE(item->height(), qreal(0)); - - delete o; - delete canvas; -} - -// QTBUG-11383 -void tst_QQuickItem::childrenRectBug() -{ - QQuickView *canvas = new QQuickView(0); - - QString warning = testFileUrl("childrenRectBug.qml").toString() + ":7:5: QML Item: Binding loop detected for property \"height\""; - QTest::ignoreMessage(QtWarningMsg, qPrintable(warning)); - QTest::ignoreMessage(QtWarningMsg, qPrintable(warning)); - - canvas->setSource(testFileUrl("childrenRectBug.qml")); - canvas->show(); - - QQuickItem *o = canvas->rootObject(); - QQuickItem *item = o->findChild("theItem"); - QCOMPARE(item->width(), qreal(200)); - QCOMPARE(item->height(), qreal(100)); - QCOMPARE(item->x(), qreal(100)); - - delete canvas; -} - -// QTBUG-11465 -void tst_QQuickItem::childrenRectBug2() -{ - QQuickView *canvas = new QQuickView(0); - - QString warning1 = testFileUrl("childrenRectBug2.qml").toString() + ":7:5: QML Item: Binding loop detected for property \"width\""; - QTest::ignoreMessage(QtWarningMsg, qPrintable(warning1)); - QTest::ignoreMessage(QtWarningMsg, qPrintable(warning1)); - - QString warning2 = testFileUrl("childrenRectBug2.qml").toString() + ":7:5: QML Item: Binding loop detected for property \"height\""; - QTest::ignoreMessage(QtWarningMsg, qPrintable(warning2)); - QTest::ignoreMessage(QtWarningMsg, qPrintable(warning2)); - QTest::ignoreMessage(QtWarningMsg, qPrintable(warning2)); - QTest::ignoreMessage(QtWarningMsg, qPrintable(warning2)); - - canvas->setSource(testFileUrl("childrenRectBug2.qml")); - canvas->show(); - - QQuickRectangle *rect = qobject_cast(canvas->rootObject()); - QVERIFY(rect); - QQuickItem *item = rect->findChild("theItem"); - QCOMPARE(item->width(), qreal(100)); - QCOMPARE(item->height(), qreal(110)); - QCOMPARE(item->x(), qreal(130)); - - QQuickItemPrivate *rectPrivate = QQuickItemPrivate::get(rect); - rectPrivate->setState("row"); - QCOMPARE(item->width(), qreal(210)); - QCOMPARE(item->height(), qreal(50)); - QCOMPARE(item->x(), qreal(75)); - - delete canvas; -} - -// QTBUG-12722 -void tst_QQuickItem::childrenRectBug3() -{ - QQuickView *canvas = new QQuickView(0); - canvas->setSource(testFileUrl("childrenRectBug3.qml")); - canvas->show(); - - //don't crash on delete - delete canvas; -} - -// QTBUG-13893 -void tst_QQuickItem::transformCrash() -{ - QQuickView *canvas = new QQuickView(0); - canvas->setSource(testFileUrl("transformCrash.qml")); - canvas->show(); - - delete canvas; -} - -void tst_QQuickItem::implicitSize() -{ - QQuickView *canvas = new QQuickView(0); - canvas->setSource(testFileUrl("implicitsize.qml")); - canvas->show(); - - QQuickItem *item = qobject_cast(canvas->rootObject()); - QVERIFY(item); - QCOMPARE(item->width(), qreal(80)); - QCOMPARE(item->height(), qreal(60)); - - QCOMPARE(item->implicitWidth(), qreal(200)); - QCOMPARE(item->implicitHeight(), qreal(100)); - - QMetaObject::invokeMethod(item, "resetSize"); - - QCOMPARE(item->width(), qreal(200)); - QCOMPARE(item->height(), qreal(100)); - - QMetaObject::invokeMethod(item, "changeImplicit"); - - QCOMPARE(item->implicitWidth(), qreal(150)); - QCOMPARE(item->implicitHeight(), qreal(80)); - QCOMPARE(item->width(), qreal(150)); - QCOMPARE(item->height(), qreal(80)); - - delete canvas; -} - -void tst_QQuickItem::qtbug_16871() -{ - QDeclarativeComponent component(&engine, testFileUrl("qtbug_16871.qml")); - QObject *o = component.create(); - QVERIFY(o != 0); - delete o; -} - - -void tst_QQuickItem::visibleChildren() -{ - QQuickView *canvas = new QQuickView(0); - canvas->setSource(testFileUrl("visiblechildren.qml")); - canvas->show(); - - QQuickItem *root = qobject_cast(canvas->rootObject()); - QVERIFY(root); - - QCOMPARE(root->property("test1_1").toBool(), true); - QCOMPARE(root->property("test1_2").toBool(), true); - QCOMPARE(root->property("test1_3").toBool(), true); - QCOMPARE(root->property("test1_4").toBool(), true); - - QMetaObject::invokeMethod(root, "hideFirstAndLastRowChild"); - QCOMPARE(root->property("test2_1").toBool(), true); - QCOMPARE(root->property("test2_2").toBool(), true); - QCOMPARE(root->property("test2_3").toBool(), true); - QCOMPARE(root->property("test2_4").toBool(), true); - - QMetaObject::invokeMethod(root, "showLastRowChildsLastChild"); - QCOMPARE(root->property("test3_1").toBool(), true); - QCOMPARE(root->property("test3_2").toBool(), true); - QCOMPARE(root->property("test3_3").toBool(), true); - QCOMPARE(root->property("test3_4").toBool(), true); - - QMetaObject::invokeMethod(root, "showLastRowChild"); - QCOMPARE(root->property("test4_1").toBool(), true); - QCOMPARE(root->property("test4_2").toBool(), true); - QCOMPARE(root->property("test4_3").toBool(), true); - QCOMPARE(root->property("test4_4").toBool(), true); - - QString warning1 = testFileUrl("visiblechildren.qml").toString() + ":96:32: QML Item: QQuickItem: visibleChildren property is readonly and cannot be assigned to."; - QTest::ignoreMessage(QtWarningMsg, qPrintable(warning1)); - QMetaObject::invokeMethod(root, "tryWriteToReadonlyVisibleChildren"); - QCOMPARE(root->property("test5_1").toBool(), true); - - QMetaObject::invokeMethod(root, "reparentVisibleItem3"); - QCOMPARE(root->property("test6_1").toBool(), true); - QCOMPARE(root->property("test6_2").toBool(), true); - QCOMPARE(root->property("test6_3").toBool(), true); - QCOMPARE(root->property("test6_4").toBool(), true); - - QMetaObject::invokeMethod(root, "reparentImlicitlyInvisibleItem4_1"); - QCOMPARE(root->property("test7_1").toBool(), true); - QCOMPARE(root->property("test7_2").toBool(), true); - QCOMPARE(root->property("test7_3").toBool(), true); - QCOMPARE(root->property("test7_4").toBool(), true); - - // FINALLY TEST THAT EVERYTHING IS AS EXPECTED - QCOMPARE(root->property("test8_1").toBool(), true); - QCOMPARE(root->property("test8_2").toBool(), true); - QCOMPARE(root->property("test8_3").toBool(), true); - QCOMPARE(root->property("test8_4").toBool(), true); - QCOMPARE(root->property("test8_5").toBool(), true); - - delete canvas; -} - -void tst_QQuickItem::parentLoop() -{ - QQuickView *canvas = new QQuickView(0); - - QTest::ignoreMessage(QtWarningMsg, "QQuickItem::setParentItem: Parent is already part of this items subtree."); - canvas->setSource(testFileUrl("parentLoop.qml")); - - QQuickItem *root = qobject_cast(canvas->rootObject()); - QVERIFY(root); - - QQuickItem *item1 = root->findChild("item1"); - QVERIFY(item1); - QCOMPARE(item1->parentItem(), root); - - QQuickItem *item2 = root->findChild("item2"); - QVERIFY(item2); - QCOMPARE(item2->parentItem(), item1); - - delete canvas; -} - -QTEST_MAIN(tst_QQuickItem) - -#include "tst_qquickitem.moc" diff --git a/tests/auto/qtquick2/qquickitemlayer/data/DisableLayer.qml b/tests/auto/qtquick2/qquickitemlayer/data/DisableLayer.qml deleted file mode 100644 index 70fc05e937..0000000000 --- a/tests/auto/qtquick2/qquickitemlayer/data/DisableLayer.qml +++ /dev/null @@ -1,18 +0,0 @@ -import QtQuick 2.0 - -Item { - width: 200 - height: 200 - Rectangle { - width: 100 - height: 100 - color: "red" - layer.enabled: true - Component.onCompleted: { - layer.enabled = false - visible = false - width = 120 - x = 10 - } - } -} diff --git a/tests/auto/qtquick2/qquickitemlayer/data/Effect.qml b/tests/auto/qtquick2/qquickitemlayer/data/Effect.qml deleted file mode 100644 index 630c8f90ed..0000000000 --- a/tests/auto/qtquick2/qquickitemlayer/data/Effect.qml +++ /dev/null @@ -1,34 +0,0 @@ -import QtQuick 2.0 - -Item -{ - width: 100 - height: 100 - - Rectangle { - id: box - width: 100 - height: 100 - - color: "#0000ff" - - Rectangle { - x: 50 - width: 50 - height: 100 - color: "#00ff00" - } - - layer.enabled: true - layer.effect: ShaderEffect { - fragmentShader: " - uniform lowp sampler2D source; - uniform lowp float qt_Opacity; - varying highp vec2 qt_TexCoord0; - void main() { - gl_FragColor = texture2D(source, qt_TexCoord0).bgra * qt_Opacity; - }" - } - - } -} diff --git a/tests/auto/qtquick2/qquickitemlayer/data/Enabled.qml b/tests/auto/qtquick2/qquickitemlayer/data/Enabled.qml deleted file mode 100644 index 0e7d4f56b8..0000000000 --- a/tests/auto/qtquick2/qquickitemlayer/data/Enabled.qml +++ /dev/null @@ -1,25 +0,0 @@ -import QtQuick 2.0 - -Item -{ - width: 200 - height: 200 - - Item { - width: 20 - height: 20 - scale: 10 - - layer.enabled: true - anchors.centerIn: parent - - Rectangle { - width: 20 - height: 20 - gradient: Gradient { - GradientStop { position: 0; color: "white" } - GradientStop { position: 1; color: "black" } - } - } - } -} diff --git a/tests/auto/qtquick2/qquickitemlayer/data/ItemEffect.qml b/tests/auto/qtquick2/qquickitemlayer/data/ItemEffect.qml deleted file mode 100644 index 2f17d78efd..0000000000 --- a/tests/auto/qtquick2/qquickitemlayer/data/ItemEffect.qml +++ /dev/null @@ -1,23 +0,0 @@ -import QtQuick 2.0 - -Item { - width: 200 - height: 200 - Rectangle { - anchors.fill: parent - anchors.margins: 99 - gradient: Gradient { - GradientStop { position: 0.3; color: "red" } - GradientStop { position: 0.7; color: "blue" } - } - layer.enabled: true - layer.effect: Item { - property variant source - ShaderEffect { - anchors.fill: parent - anchors.margins: -99 - property variant source: parent.source - } - } - } -} diff --git a/tests/auto/qtquick2/qquickitemlayer/data/Mipmap.qml b/tests/auto/qtquick2/qquickitemlayer/data/Mipmap.qml deleted file mode 100644 index 8de41076e9..0000000000 --- a/tests/auto/qtquick2/qquickitemlayer/data/Mipmap.qml +++ /dev/null @@ -1,30 +0,0 @@ -import QtQuick 2.0 - -Item -{ - width: 100 - height: 100 - - Rectangle { - id: box - width: 600 - height: 600 - - scale: 1 / 6. - - color: "black" - - layer.enabled: true - layer.mipmap: true - layer.smooth: true - - anchors.centerIn: parent - - Rectangle { - x: 1 - width: 1 - height: parent.height - color: "white" - } - } -} diff --git a/tests/auto/qtquick2/qquickitemlayer/data/RectangleEffect.qml b/tests/auto/qtquick2/qquickitemlayer/data/RectangleEffect.qml deleted file mode 100644 index 94c43f2caf..0000000000 --- a/tests/auto/qtquick2/qquickitemlayer/data/RectangleEffect.qml +++ /dev/null @@ -1,22 +0,0 @@ -import QtQuick 2.0 - -Item { - width: 200 - height: 200 - Rectangle { - width: 100 - height: 100 - x: 50 - y: 50 - scale: 1.5 - z: 1 - rotation: 45 - color: "#ff0000" - layer.enabled: true - layer.effect: Rectangle { color: "#0000ff" } - } - Rectangle { - anchors.fill: parent - color: "#00ff00" - } -} diff --git a/tests/auto/qtquick2/qquickitemlayer/data/SamplerNameChange.qml b/tests/auto/qtquick2/qquickitemlayer/data/SamplerNameChange.qml deleted file mode 100644 index a4c2ebff6b..0000000000 --- a/tests/auto/qtquick2/qquickitemlayer/data/SamplerNameChange.qml +++ /dev/null @@ -1,18 +0,0 @@ -import QtQuick 2.0 - -Rectangle { - width: 200 - height: 200 - color: "blue" - layer.enabled: true - layer.effect: ShaderEffect { - fragmentShader: " - uniform sampler2D foo; - uniform lowp float qt_Opacity; - varying highp vec2 qt_TexCoord0; - void main() { - gl_FragColor = texture2D(foo, qt_TexCoord0) * qt_Opacity; - }" - } - Component.onCompleted: layer.samplerName = "foo" -} diff --git a/tests/auto/qtquick2/qquickitemlayer/data/Smooth.qml b/tests/auto/qtquick2/qquickitemlayer/data/Smooth.qml deleted file mode 100644 index 3f9575bb0b..0000000000 --- a/tests/auto/qtquick2/qquickitemlayer/data/Smooth.qml +++ /dev/null @@ -1,23 +0,0 @@ -import QtQuick 2.0 - - -Item { - width: 200 - height: 100 - - Row { - id: layerRoot - - width: 20 - height: 10 - - Rectangle { width: 10; height: 10; color: "red" } - Rectangle { width: 10; height: 10; color: "blue" } - - layer.enabled: true - layer.smooth: true - - anchors.centerIn: parent - scale: 10 - } -} diff --git a/tests/auto/qtquick2/qquickitemlayer/data/SourceRect.qml b/tests/auto/qtquick2/qquickitemlayer/data/SourceRect.qml deleted file mode 100644 index 7cc7e8b21e..0000000000 --- a/tests/auto/qtquick2/qquickitemlayer/data/SourceRect.qml +++ /dev/null @@ -1,33 +0,0 @@ -import QtQuick 2.0 - -Item -{ - width: 100 - height: 100 - - Rectangle { - id: box - width: 100 - height: 100 - - color: "#ff0000" - - layer.enabled: true - layer.sourceRect: Qt.rect(-10, -10, box.width + 20, box.height + 20); - - // A shader that pads the transparent pixels with blue. - layer.effect: ShaderEffect { - fragmentShader: " - uniform lowp sampler2D source; - uniform lowp float qt_Opacity; - varying highp vec2 qt_TexCoord0; - void main() { - vec4 c = texture2D(source, qt_TexCoord0); - if (c.a == 0.) - c = vec4(0, 0, 1, 1); - gl_FragColor = c * qt_Opacity; - } - " - } - } -} diff --git a/tests/auto/qtquick2/qquickitemlayer/data/TextureProvider.qml b/tests/auto/qtquick2/qquickitemlayer/data/TextureProvider.qml deleted file mode 100644 index ccd515652a..0000000000 --- a/tests/auto/qtquick2/qquickitemlayer/data/TextureProvider.qml +++ /dev/null @@ -1,40 +0,0 @@ -import QtQuick 2.0 - -Item -{ - width: 100 - height: 100 - - Rectangle { - id: box - width: 100 - height: 100 - - color: "#0000ff" - - Rectangle { - x: 50 - width: 50 - height: 100 - color: "#00ff00" - } - - visible: false - - layer.enabled: true - } - - ShaderEffect { - anchors.fill: parent - property variant source: box - - fragmentShader: " - uniform lowp sampler2D source; - uniform lowp float qt_Opacity; - varying highp vec2 qt_TexCoord0; - void main() { - gl_FragColor = texture2D(source, qt_TexCoord0).bgra * qt_Opacity; - }" - } - -} diff --git a/tests/auto/qtquick2/qquickitemlayer/data/ToggleLayerAndEffect.qml b/tests/auto/qtquick2/qquickitemlayer/data/ToggleLayerAndEffect.qml deleted file mode 100644 index 174b669b6c..0000000000 --- a/tests/auto/qtquick2/qquickitemlayer/data/ToggleLayerAndEffect.qml +++ /dev/null @@ -1,23 +0,0 @@ -import QtQuick 2.0 - -Item { - width: 200 - height: 200 - Rectangle { - width: 100 - height: 100 - color: "red" - Component.onCompleted: { - layer.enabled = true - layer.effect = effectComponent - layer.enabled = false - visible = false - width = 120 - x = 10 - } - } - Component { - id: effectComponent - ShaderEffect { } - } -} diff --git a/tests/auto/qtquick2/qquickitemlayer/data/Visible.qml b/tests/auto/qtquick2/qquickitemlayer/data/Visible.qml deleted file mode 100644 index 8267f18250..0000000000 --- a/tests/auto/qtquick2/qquickitemlayer/data/Visible.qml +++ /dev/null @@ -1,56 +0,0 @@ -import QtQuick 2.0 - -Item -{ - id: root - - width: 100 - height: 100 - - property bool layerEffect: false; - onLayerEffectChanged: root.maybeUse(); - Component.onCompleted: root.maybeUse(); - - property real layerOpacity: 1; - property bool layerVisible: true; - - function maybeUse() { - if (root.layerEffect) - box.layer.effect = shaderEffect - } - - Component { - id: shaderEffect - ShaderEffect { - fragmentShader: " - uniform lowp sampler2D source; - uniform lowp float qt_Opacity; - varying highp vec2 qt_TexCoord0; - void main() { - gl_FragColor = texture2D(source, qt_TexCoord0).bgra * qt_Opacity; - } - " - } - - } - - Rectangle { - id: box - width: 100 - height: 100 - - color: "#0000ff" - visible: parent.layerVisible; - opacity: parent.layerOpacity; - - Rectangle { - x: 50 - width: 50 - height: 100 - color: "#00ff00" - } - - layer.enabled: true - - } -} diff --git a/tests/auto/qtquick2/qquickitemlayer/data/ZOrder.qml b/tests/auto/qtquick2/qquickitemlayer/data/ZOrder.qml deleted file mode 100644 index 59ccb32224..0000000000 --- a/tests/auto/qtquick2/qquickitemlayer/data/ZOrder.qml +++ /dev/null @@ -1,52 +0,0 @@ -import QtQuick 2.0 - -Item -{ - id: root - - width: 200 - height: 200 - - Component { - id: shaderEffect - ShaderEffect { } - } - - property bool layerEffect: false; - onLayerEffectChanged: root.maybeUse(); - Component.onCompleted: root.maybeUse(); - - function maybeUse() { - if (root.layerEffect) - box.layer.effect = shaderEffect - } - - - Rectangle { - color: "red" - anchors.left: parent.left - anchors.top: parent.top - width: 100 - height: 100 - z: 1 - } - - Rectangle { - color: "#00ff00" - anchors.bottom: parent.bottom - anchors.right: parent.right - width: 100 - height: 100 - z: 3 - } - - Rectangle { - id: box - color: "blue" - anchors.fill: parent - anchors.margins: 10 - layer.enabled: true - z: 2 - } - -} diff --git a/tests/auto/qtquick2/qquickitemlayer/data/ZOrderChange.qml b/tests/auto/qtquick2/qquickitemlayer/data/ZOrderChange.qml deleted file mode 100644 index ebbd3b7e15..0000000000 --- a/tests/auto/qtquick2/qquickitemlayer/data/ZOrderChange.qml +++ /dev/null @@ -1,50 +0,0 @@ -import QtQuick 2.0 - -Item { - width: 200 - height: 200 - property bool layerEffect: false - property bool layerEnabled: false - property real layerZ: 0 - Rectangle { - anchors.fill: parent - color: "#00ffff" - } - Rectangle { - id: foo - anchors.fill: parent - color: "#ffff00" - Rectangle { - width: 100 - height: 100 - color: "#00ffff" - } - layer.enabled: parent.layerEnabled - layer.effect: parent.layerEffect ? effectComponent : null - opacity: 0.5 - z: layerZ - } - Rectangle { - width: 100 - height: 100 - x: 100 - color: "#ff0000" - } - Rectangle { - width: 100 - height: 100 - y: 100 - color: "#0000ff" - z: 1 - } - Component { - id: effectComponent - ShaderEffect { - fragmentShader: " - uniform sampler2D source; - uniform lowp float qt_Opacity; - varying highp vec2 qt_TexCoord0; - void main() { gl_FragColor = texture2D(source, qt_TexCoord0).xzyw * qt_Opacity; }" - } - } -} diff --git a/tests/auto/qtquick2/qquickitemlayer/qquickitemlayer.pro b/tests/auto/qtquick2/qquickitemlayer/qquickitemlayer.pro deleted file mode 100644 index 557e23d150..0000000000 --- a/tests/auto/qtquick2/qquickitemlayer/qquickitemlayer.pro +++ /dev/null @@ -1,38 +0,0 @@ -CONFIG += testcase -TARGET = tst_qquickitemlayer -SOURCES += tst_qquickitemlayer.cpp - -macx:CONFIG -= app_bundle - -testDataFiles.files = data -testDataFiles.path = . -DEPLOYMENT += testDataFiles - -include(../../shared/util.pri) - -CONFIG += parallel_test -QT += core-private gui-private v8-private declarative-private quick-private testlib - -OTHER_FILES += \ - data/Smooth.qml \ - data/Enabled.qml \ - data/Mipmap.qml \ - data/Effect.qml \ - data/SourceRect.qml \ - data/TextureProvider.qml \ - data/Visible.qml \ - data/ZOrder.qml \ - data/ZOrderChange.qml \ - data/ToggleLayerAndEffect.qml \ - data/DisableLayer.qml \ - data/SamplerNameChange.qml \ - data/ItemEffect.qml \ - data/RectangleEffect.qml - - - - - - - - diff --git a/tests/auto/qtquick2/qquickitemlayer/tst_qquickitemlayer.cpp b/tests/auto/qtquick2/qquickitemlayer/tst_qquickitemlayer.cpp deleted file mode 100644 index 2a856707ba..0000000000 --- a/tests/auto/qtquick2/qquickitemlayer/tst_qquickitemlayer.cpp +++ /dev/null @@ -1,436 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include - -#include -#include -#include - -#include "../../shared/util.h" - -class tst_QQuickItemLayer: public QDeclarativeDataTest -{ - Q_OBJECT -public: - tst_QQuickItemLayer(); - - QImage runTest(const QString &url) - { - QQuickView view; - view.setSource(QUrl(url)); - - view.show(); - QTest::qWaitForWindowShown(&view); - - return view.grabFrameBuffer(); - } - -private slots: - void layerEnabled(); - void layerSmooth(); - void layerMipmap(); - void layerEffect(); - - void layerVisibility_data(); - void layerVisibility(); - - void layerSourceRect(); - - void layerZOrder_data(); - void layerZOrder(); - - void layerIsTextureProvider(); - - void changeZOrder_data(); - void changeZOrder(); - - void toggleLayerAndEffect(); - void disableLayer(); - void changeSamplerName(); - void itemEffect(); - void rectangleEffect(); - -private: - bool m_isMesaSoftwareRasterizer; - int m_mesaVersion; -}; - -tst_QQuickItemLayer::tst_QQuickItemLayer() - : m_mesaVersion(0) -{ - QWindow window; - QOpenGLContext context; - window.setSurfaceType(QWindow::OpenGLSurface); - window.create(); - context.create(); - context.makeCurrent(&window); - const char *vendor = (const char *)glGetString(GL_VENDOR); - const char *renderer = (const char *)glGetString(GL_RENDERER); - m_isMesaSoftwareRasterizer = strcmp(vendor, "Mesa Project") == 0 - && strcmp(renderer, "Software Rasterizer") == 0; - if (m_isMesaSoftwareRasterizer) { - // Expects format: Mesa [-devel] [...] - const char *version = (const char *)glGetString(GL_VERSION); - QList list = QByteArray(version).split(' '); - if (list.size() >= 3) { - list = list.at(2).split('-').at(0).split('.'); - int major = 0; - int minor = 0; - int patch = 0; - if (list.size() >= 1) - major = list.at(0).toInt(); - if (list.size() >= 2) - minor = list.at(1).toInt(); - if (list.size() >= 3) - patch = list.at(2).toInt(); - m_mesaVersion = QT_VERSION_CHECK(major, minor, patch); - } - } -} - -// The test draws a red and a blue box next to each other and tests that the -// output is still red and blue on the left and right and a combination of -// the two in the middle. - -void tst_QQuickItemLayer::layerSmooth() -{ - if (m_isMesaSoftwareRasterizer && m_mesaVersion < QT_VERSION_CHECK(7, 11, 0)) - QSKIP("Mesa Software Rasterizer below version 7.11 does not render this test correctly."); - QImage fb = runTest(testFile("Smooth.qml")); - QCOMPARE(fb.pixel(0, 0), qRgb(0xff, 0, 0)); - QCOMPARE(fb.pixel(fb.width() - 1, 0), qRgb(0, 0, 0xff)); - - uint pixel = fb.pixel(fb.width() / 2, 0); - QVERIFY(qRed(pixel) > 0); - QVERIFY(qBlue(pixel) > 0); -} - - - -// The test draws a gradient at a small size into a layer and scales the -// layer. If the layer is enabled there should be very visible bands in -// the gradient. - -void tst_QQuickItemLayer::layerEnabled() -{ - if (m_isMesaSoftwareRasterizer && m_mesaVersion < QT_VERSION_CHECK(7, 11, 0)) - QSKIP("Mesa Software Rasterizer below version 7.11 does not render this test correctly."); - QImage fb = runTest(testFile("Enabled.qml")); - // Verify the banding - QCOMPARE(fb.pixel(0, 0), fb.pixel(0, 1)); - // Verify the gradient - QVERIFY(fb.pixel(0, 0) != fb.pixel(0, fb.height() - 1)); -} - - - -// The test draws a one pixel wide line and scales it down by more than a a factor 2 -// If mipmpping works, the pixels should be gray, not white or black - -void tst_QQuickItemLayer::layerMipmap() -{ - if (m_isMesaSoftwareRasterizer) - QSKIP("Mipmapping does not work with the Mesa Software Rasterizer."); - QImage fb = runTest(testFile("Mipmap.qml")); - QVERIFY(fb.pixel(0, 0) != 0xff000000); - QVERIFY(fb.pixel(0, 0) != 0xffffffff); -} - - - -// The test implements an rgb swapping effect sourced from a blue rectangle. The -// resulting pixel should be red - -void tst_QQuickItemLayer::layerEffect() -{ - if (m_isMesaSoftwareRasterizer && m_mesaVersion < QT_VERSION_CHECK(7, 11, 0)) - QSKIP("Mesa Software Rasterizer below version 7.11 does not render this test correctly."); - QImage fb = runTest(testFile("Effect.qml")); - QCOMPARE(fb.pixel(0, 0), qRgb(0xff, 0, 0)); - QCOMPARE(fb.pixel(fb.width() - 1, 0), qRgb(0, 0xff, 0)); -} - - - -// The test draws a rectangle and verifies that there is padding on each side -// as the source rect spans outside the item. The padding is verified using -// a shader that pads transparent to blue. Everything else is red. -void tst_QQuickItemLayer::layerSourceRect() -{ - if (m_isMesaSoftwareRasterizer && m_mesaVersion < QT_VERSION_CHECK(7, 11, 0)) - QSKIP("Mesa Software Rasterizer below version 7.11 does not render this test correctly."); - - QImage fb = runTest(testFile("SourceRect.qml")); - - // Check that the edges are converted to blue - QCOMPARE(fb.pixel(0, 0), qRgb(0, 0, 0xff)); - QCOMPARE(fb.pixel(fb.width() - 1, 0), qRgb(0, 0, 0xff)); - QCOMPARE(fb.pixel(0, fb.height() - 1), qRgb(0, 0, 0xff)); - QCOMPARE(fb.pixel(fb.width() - 1, fb.height() - 1), qRgb(0, 0, 0xff)); - - // The center pixel should be red - QCOMPARE(fb.pixel(fb.width() / 2, fb.height() / 2), qRgb(0xff, 0, 0)); -} - - - -// Same as the effect test up above, but this time use the item -// directly in a stand alone ShaderEffect -void tst_QQuickItemLayer::layerIsTextureProvider() -{ - if (m_isMesaSoftwareRasterizer && m_mesaVersion < QT_VERSION_CHECK(7, 11, 0)) - QSKIP("Mesa Software Rasterizer below version 7.11 does not render this test correctly."); - QImage fb = runTest(testFile("TextureProvider.qml")); - QCOMPARE(fb.pixel(0, 0), qRgb(0xff, 0, 0)); - QCOMPARE(fb.pixel(fb.width() - 1, 0), qRgb(0, 0xff, 0)); -} - - -void tst_QQuickItemLayer::layerVisibility_data() -{ - QTest::addColumn("visible"); - QTest::addColumn("effect"); - QTest::addColumn("opacity"); - - QTest::newRow("!effect, !visible, a=1") << false << false << 1.; - QTest::newRow("!effect, visible, a=1") << false << true << 1.; - QTest::newRow("effect, !visible, a=1") << true << false << 1.; - QTest::newRow("effect, visible, a=1") << true << true << 1.; - - QTest::newRow("!effect, !visible, a=.5") << false << false << .5; - QTest::newRow("!effect, visible, a=.5") << false << true << .5; - QTest::newRow("effect, !visible, a=.5") << true << false << .5; - QTest::newRow("effect, visible, a=.5") << true << true << .5; - - QTest::newRow("!effect, !visible, a=0") << false << false << 0.; - QTest::newRow("!effect, visible, a=0") << false << true << 0.; - QTest::newRow("effect, !visible, a=0") << true << false << 0.; - QTest::newRow("effect, visible, a=0") << true << true << 0.; -} - -void tst_QQuickItemLayer::layerVisibility() -{ - if (m_isMesaSoftwareRasterizer && m_mesaVersion < QT_VERSION_CHECK(7, 11, 0)) - QSKIP("Mesa Software Rasterizer below version 7.11 does not render this test correctly."); - - QFETCH(bool, visible); - QFETCH(bool, effect); - QFETCH(qreal, opacity); - - QQuickView view; - view.setSource(testFile("Visible.qml")); - - QQuickItem *child = view.rootItem()->childItems().at(0); - child->setProperty("layerVisible", visible); - child->setProperty("layerEffect", effect); - child->setProperty("layerOpacity", opacity); - - view.show(); - - QTest::qWaitForWindowShown(&view); - - QImage fb = view.grabFrameBuffer(); - uint pixel = fb.pixel(0, 0); - - if (!visible || opacity == 0) { - QCOMPARE(pixel, qRgb(0xff, 0xff, 0xff)); - } else if (effect) { - QCOMPARE(qRed(pixel), 0xff); - QVERIFY(qGreen(pixel) < 0xff); - QVERIFY(qBlue(pixel) < 0xff); - } else { // no effect - QCOMPARE(qBlue(pixel), 0xff); - QVERIFY(qGreen(pixel) < 0xff); - QVERIFY(qRed(pixel) < 0xff); - } -} - - - - -void tst_QQuickItemLayer::layerZOrder_data() -{ - QTest::addColumn("effect"); - - QTest::newRow("!effect") << false; - QTest::newRow("effect") << true; -} - -void tst_QQuickItemLayer::layerZOrder() -{ - if (m_isMesaSoftwareRasterizer && m_mesaVersion < QT_VERSION_CHECK(7, 11, 0)) - QSKIP("Mesa Software Rasterizer below version 7.11 does not render this test correctly."); - - QFETCH(bool, effect); - - QQuickView view; - view.setSource(testFile("ZOrder.qml")); - - QQuickItem *child = view.rootItem()->childItems().at(0); - child->setProperty("layerEffect", effect); - - view.show(); - - QTest::qWaitForWindowShown(&view); - - QImage fb = view.grabFrameBuffer(); - - QCOMPARE(fb.pixel(50, 50), qRgb(0, 0, 0xff)); - QCOMPARE(fb.pixel(150, 150), qRgb(0, 0xff, 00)); - -} - -void tst_QQuickItemLayer::changeZOrder_data() -{ - QTest::addColumn("layered"); - QTest::addColumn("effect"); - - QTest::newRow("layered, effect") << true << true; - QTest::newRow("layered, !effect") << true << false; - QTest::newRow("!layered") << false << false; -} - -void tst_QQuickItemLayer::changeZOrder() -{ - if (m_isMesaSoftwareRasterizer && m_mesaVersion < QT_VERSION_CHECK(7, 11, 0)) - QSKIP("Mesa Software Rasterizer below version 7.11 does not render this test correctly."); - - QFETCH(bool, layered); - QFETCH(bool, effect); - - QQuickView view; - view.setSource(testFile("ZOrderChange.qml")); - - QQuickItem *child = view.rootItem()->childItems().at(0); - child->setProperty("layerEnabled", layered); - child->setProperty("layerEffect", effect); - child->setProperty("layerZ", 1); - - view.show(); - - QTest::qWaitForWindowShown(&view); - - QImage fb = view.grabFrameBuffer(); - - QRgb topLeft = fb.pixel(50, 50); - QRgb topRight = fb.pixel(150, 50); - QRgb bottomLeft = fb.pixel(50, 150); - QRgb bottomRight = fb.pixel(150, 150); - - QCOMPARE(bottomLeft, qRgb(0, 0, 0xff)); - - if (layered) { - QCOMPARE(topLeft, qRgb(0, 0xff, 0xff)); - } else { - QCOMPARE(qGreen(topLeft), 0xff); - QVERIFY(qAbs(qRed(topLeft) - 0x3f) < 4); - QVERIFY(qAbs(qBlue(topLeft) - 0xbf) < 4); - } - - if (layered && effect) { - QCOMPARE(qRed(topRight), 0xff); - QCOMPARE(qGreen(topRight), 0x00); - QVERIFY(qAbs(qBlue(topRight) - 0x7f) < 4); - - QVERIFY(qAbs(qRed(bottomRight) - 0x7f) < 4); - QCOMPARE(qBlue(bottomRight), 0xff); - QVERIFY(qAbs(qGreen(bottomRight) - 0x7f) < 4); - } else { - QCOMPARE(qRed(topRight), 0xff); - QCOMPARE(qBlue(topRight), 0x00); - QVERIFY(qAbs(qGreen(topRight) - 0x7f) < 4); - - QVERIFY(qAbs(qRed(bottomRight) - 0x7f) < 4); - QCOMPARE(qGreen(bottomRight), 0xff); - QVERIFY(qAbs(qBlue(bottomRight) - 0x7f) < 4); - } -} - -void tst_QQuickItemLayer::toggleLayerAndEffect() -{ - // This test passes if it doesn't crash. - runTest(testFile("ToggleLayerAndEffect.qml")); -} - -void tst_QQuickItemLayer::disableLayer() -{ - // This test passes if it doesn't crash. - runTest(testFile("DisableLayer.qml")); -} - -void tst_QQuickItemLayer::changeSamplerName() -{ - if (m_isMesaSoftwareRasterizer && m_mesaVersion < QT_VERSION_CHECK(7, 11, 0)) - QSKIP("Mesa Software Rasterizer below version 7.11 does not render this test correctly."); - QImage fb = runTest(testFile("SamplerNameChange.qml")); - QCOMPARE(fb.pixel(0, 0), qRgb(0, 0, 0xff)); -} - -void tst_QQuickItemLayer::itemEffect() -{ - if (m_isMesaSoftwareRasterizer && m_mesaVersion < QT_VERSION_CHECK(7, 11, 0)) - QSKIP("Mesa Software Rasterizer below version 7.11 does not render this test correctly."); - QImage fb = runTest(testFile("ItemEffect.qml")); - QCOMPARE(fb.pixel(0, 0), qRgb(0xff, 0, 0)); - QCOMPARE(fb.pixel(199, 0), qRgb(0xff, 0, 0)); - QCOMPARE(fb.pixel(0, 199), qRgb(0, 0, 0xff)); - QCOMPARE(fb.pixel(199, 199), qRgb(0, 0, 0xff)); -} - -void tst_QQuickItemLayer::rectangleEffect() -{ - QImage fb = runTest(testFile("RectangleEffect.qml")); - QCOMPARE(fb.pixel(0, 0), qRgb(0, 0xff, 0)); - QCOMPARE(fb.pixel(199, 0), qRgb(0, 0xff, 0)); - QCOMPARE(fb.pixel(0, 199), qRgb(0, 0xff, 0)); - QCOMPARE(fb.pixel(199, 199), qRgb(0, 0xff, 0)); - - QCOMPARE(fb.pixel(100, 0), qRgb(0, 0, 0xff)); - QCOMPARE(fb.pixel(199, 100), qRgb(0, 0, 0xff)); - QCOMPARE(fb.pixel(100, 199), qRgb(0, 0, 0xff)); - QCOMPARE(fb.pixel(0, 100), qRgb(0, 0, 0xff)); -} - - -QTEST_MAIN(tst_QQuickItemLayer) - -#include "tst_qquickitemlayer.moc" diff --git a/tests/auto/qtquick2/qquicklistview/data/ComponentView.qml b/tests/auto/qtquick2/qquicklistview/data/ComponentView.qml deleted file mode 100644 index 3e87be8799..0000000000 --- a/tests/auto/qtquick2/qquicklistview/data/ComponentView.qml +++ /dev/null @@ -1,16 +0,0 @@ -import QtQuick 2.0 - -ListView { - id: view - - property string title - - width: 100; height: 100; - - model: 1 - delegate: Text { objectName: "listItem"; text: view.title } - header: Text { objectName: "header"; text: view.title } - footer: Text { objectName: "footer"; text: view.title } - section.delegate: Text { objectName: "section"; text: view.title } - section.property: "modelData" -} diff --git a/tests/auto/qtquick2/qquicklistview/data/Page.qml b/tests/auto/qtquick2/qquicklistview/data/Page.qml deleted file mode 100644 index abe4364315..0000000000 --- a/tests/auto/qtquick2/qquicklistview/data/Page.qml +++ /dev/null @@ -1,10 +0,0 @@ -import QtQuick 2.0 - -Item { - anchors.fill: parent - default property alias contentArea: contentItem.data - Item { - id: contentItem - anchors.fill: parent - } -} diff --git a/tests/auto/qtquick2/qquicklistview/data/addTransitions.qml b/tests/auto/qtquick2/qquicklistview/data/addTransitions.qml deleted file mode 100644 index ff90ead8a6..0000000000 --- a/tests/auto/qtquick2/qquicklistview/data/addTransitions.qml +++ /dev/null @@ -1,134 +0,0 @@ -import QtQuick 2.0 - -Rectangle { - id: root - width: 500 - height: 600 - - property int duration: 10 - property int count: list.count - - Component { - id: myDelegate - Rectangle { - id: wrapper - - property string nameData: name - - objectName: "wrapper" - height: 20 - width: 240 - Text { text: index } - Text { - x: 30 - id: textName - objectName: "textName" - text: name - } - Text { - x: 200 - text: wrapper.y - } - color: ListView.isCurrentItem ? "lightsteelblue" : "white" - - onXChanged: checkPos() - onYChanged: checkPos() - - function checkPos() { - if (Qt.point(x, y) == targetItems_transitionFrom) - model_targetItems_transitionFrom.addItem(name, "") - if (Qt.point(x, y) == displacedItems_transitionVia) - model_displacedItems_transitionVia.addItem(name, "") - } - } - } - - ListView { - id: list - - property int targetTransitionsDone - property int displaceTransitionsDone - - property var targetTrans_items: new Object() - property var targetTrans_targetIndexes: new Array() - property var targetTrans_targetItems: new Array() - - property var displacedTrans_items: new Object() - property var displacedTrans_targetIndexes: new Array() - property var displacedTrans_targetItems: new Array() - - objectName: "list" - focus: true - anchors.centerIn: parent - width: 240 - height: 320 - model: testModel - delegate: myDelegate - - // for QDeclarativeListProperty types - function copyList(propList) { - var temp = new Array() - for (var i=0; iName: ' + name } - Text { text: 'Number: ' + number } - } - } - } - Component { - id: highlightRed - Rectangle { - color: "red" - radius: 10 - opacity: 0.5 - } - } - ListView { - objectName: "listView" - anchors.fill: parent - model: listModel - delegate: delegate - highlight: highlightRed - focus: true - highlightFollowsCurrentItem: true - preferredHighlightBegin: 0.0 - preferredHighlightEnd: 0.0 - highlightRangeMode: ListView.ApplyRange - keyNavigationWraps: true - cacheBuffer: 10 - snapMode: ListView.SnapToItem - } - - data:[ - ListModel { - id: listModel - ListElement { - name: "Bill Smith" - number: "555 3264" - } - ListElement { - name: "John Brown" - number: "555 8426" - } - ListElement { - name: "Sam Wise" - number: "555 0473" - } - }, - ListModel { - objectName: "alternateModel" - ListElement { - name: "Jack" - number: "555 8426" - } - ListElement { - name: "Mary" - number: "555 3264" - } - } - ] -} - - diff --git a/tests/auto/qtquick2/qquicklistview/data/qtbug-21742.qml b/tests/auto/qtquick2/qquicklistview/data/qtbug-21742.qml deleted file mode 100644 index 774f9041fb..0000000000 --- a/tests/auto/qtquick2/qquicklistview/data/qtbug-21742.qml +++ /dev/null @@ -1,36 +0,0 @@ -import QtQuick 2.0 - -Rectangle { - height: 200 - width: 200 - property int count: menuView.count - - Component.onCompleted: { setModel(); } - - function setModel() - { - menuModel.append({"enabledItem" : true}); - menuView.currentIndex = 0; - } - - ListModel { - id: menuModel - } - - ListView { - id: menuView - anchors.fill: parent - model: menuModel - delegate: mything - } - - Component { - id: mything - Rectangle { - height: 50 - width: 200 - color: index == menuView.currentIndex ? "green" : "blue" - } - } - -} \ No newline at end of file diff --git a/tests/auto/qtquick2/qquicklistview/data/qtbug14821.qml b/tests/auto/qtquick2/qquicklistview/data/qtbug14821.qml deleted file mode 100644 index 0a5e0acbb4..0000000000 --- a/tests/auto/qtquick2/qquicklistview/data/qtbug14821.qml +++ /dev/null @@ -1,31 +0,0 @@ -import QtQuick 2.0 - -ListView { - id: view - width: 300; height: 200 - focus: true - keyNavigationWraps: true - - model: 100 - - preferredHighlightBegin: 90 - preferredHighlightEnd: 110 - - highlightRangeMode: ListView.StrictlyEnforceRange - highlight: Component { - Rectangle { - border.color: "blue" - border.width: 3 - color: "transparent" - width: 300; height: 15 - } - } - - delegate: Component { - Item { - height: 15 + (view.currentIndex == index ? 20 : 0) - width: 200 - Text { text: 'Index: ' + index; anchors.verticalCenter: parent.verticalCenter } - } - } -} diff --git a/tests/auto/qtquick2/qquicklistview/data/qtbug16037.qml b/tests/auto/qtquick2/qquicklistview/data/qtbug16037.qml deleted file mode 100644 index 21faeb3f32..0000000000 --- a/tests/auto/qtquick2/qquicklistview/data/qtbug16037.qml +++ /dev/null @@ -1,37 +0,0 @@ -import QtQuick 2.0 - -Item { - width: 640 - height: 480 - - function setModel() { - listView.model = listModel1 - } - - ListModel { - id: listModel1 - ListElement { text: "Apple" } - ListElement { text: "Banana" } - ListElement { text: "Orange" } - ListElement { text: "Coconut" } - } - - Rectangle { - width: 200 - height: listView.contentHeight - color: "yellow" - anchors.centerIn: parent - - ListView { - id: listView - objectName: "listview" - anchors.fill: parent - - delegate: Item { - width: 200 - height: 20 - Text { text: model.text; anchors.centerIn: parent } - } - } - } -} diff --git a/tests/auto/qtquick2/qquicklistview/data/removeTransitions.qml b/tests/auto/qtquick2/qquicklistview/data/removeTransitions.qml deleted file mode 100644 index 95f76f0200..0000000000 --- a/tests/auto/qtquick2/qquicklistview/data/removeTransitions.qml +++ /dev/null @@ -1,144 +0,0 @@ -import QtQuick 2.0 - -Rectangle { - id: root - width: 500 - height: 600 - - property int duration: 10 - property int count: list.count - - Component { - id: myDelegate - Rectangle { - id: wrapper - - property string nameData: name - - objectName: "wrapper" - height: 20 - width: 240 - Text { text: index } - Text { - x: 30 - id: textName - objectName: "textName" - text: name - } - Text { - x: 200 - text: wrapper.y - } - color: ListView.isCurrentItem ? "lightsteelblue" : "white" - - onXChanged: checkPos() - onYChanged: checkPos() - - function checkPos() { - if (Qt.point(x, y) == targetItems_transitionTo) { - model_targetItems_transitionTo.addItem(nameData, "") // name is invalid once model removes the item - } - if (Qt.point(x, y) == displacedItems_transitionVia) { - model_displacedItems_transitionVia.addItem(name, "") - } - } - } - } - - ListView { - id: list - - property int targetTransitionsDone - property int displaceTransitionsDone - - property var targetTrans_items: new Object() - property var targetTrans_targetIndexes: new Array() - property var targetTrans_targetItems: new Array() - - property var displacedTrans_items: new Object() - property var displacedTrans_targetIndexes: new Array() - property var displacedTrans_targetItems: new Array() - - objectName: "list" - focus: true - anchors.centerIn: parent - width: 240 - height: 320 - model: testModel - delegate: myDelegate - - // for QDeclarativeListProperty types - function copyList(propList) { - var temp = new Array() - for (var i=0; i -#include - -IncrementalModel::IncrementalModel(QObject *parent) - : QAbstractListModel(parent), count(0) -{ - for (int i = 0; i < 100; ++i) - list.append("Item " + QString::number(i)); -} - -int IncrementalModel::rowCount(const QModelIndex & /* parent */) const -{ - return count; -} - -QVariant IncrementalModel::data(const QModelIndex &index, int role) const -{ - if (!index.isValid()) - return QVariant(); - - if (index.row() >= list.size() || index.row() < 0) - return QVariant(); - - if (role == Qt::DisplayRole) - return list.at(index.row()); - return QVariant(); -} - -bool IncrementalModel::canFetchMore(const QModelIndex & /* index */) const -{ - if (count < list.size()) - return true; - else - return false; -} - -void IncrementalModel::fetchMore(const QModelIndex & /* index */) -{ - int remainder = list.size() - count; - int itemsToFetch = qMin(5, remainder); - - beginInsertRows(QModelIndex(), count, count+itemsToFetch-1); - - count += itemsToFetch; - - endInsertRows(); -} diff --git a/tests/auto/qtquick2/qquicklistview/incrementalmodel.h b/tests/auto/qtquick2/qquicklistview/incrementalmodel.h deleted file mode 100644 index bf524d16e6..0000000000 --- a/tests/auto/qtquick2/qquicklistview/incrementalmodel.h +++ /dev/null @@ -1,68 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef IncrementalModel_H -#define IncrementalModel_H - -#include -#include -#include - -class IncrementalModel : public QAbstractListModel -{ - Q_OBJECT - -public: - IncrementalModel(QObject *parent = 0); - - int rowCount(const QModelIndex &parent = QModelIndex()) const; - QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const; - -protected: - bool canFetchMore(const QModelIndex &parent) const; - void fetchMore(const QModelIndex &parent); - -private: - QStringList list; - int count; -}; - -#endif diff --git a/tests/auto/qtquick2/qquicklistview/qquicklistview.pro b/tests/auto/qtquick2/qquicklistview/qquicklistview.pro deleted file mode 100644 index 6828bf2f13..0000000000 --- a/tests/auto/qtquick2/qquicklistview/qquicklistview.pro +++ /dev/null @@ -1,16 +0,0 @@ -CONFIG += testcase -TARGET = tst_qquicklistview -macx:CONFIG -= app_bundle - -HEADERS += incrementalmodel.h -SOURCES += tst_qquicklistview.cpp \ - incrementalmodel.cpp - -include (../../shared/util.pri) -include (../shared/util.pri) - -testDataFiles.files = data -testDataFiles.path = . -DEPLOYMENT += testDataFiles - -QT += core-private gui-private declarative-private quick-private widgets widgets-private v8-private opengl-private testlib diff --git a/tests/auto/qtquick2/qquicklistview/tst_qquicklistview.cpp b/tests/auto/qtquick2/qquicklistview/tst_qquicklistview.cpp deleted file mode 100644 index eb7efd6d33..0000000000 --- a/tests/auto/qtquick2/qquicklistview/tst_qquicklistview.cpp +++ /dev/null @@ -1,5715 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "../../shared/util.h" -#include "../shared/viewtestutil.h" -#include "../shared/visualtestutil.h" -#include "incrementalmodel.h" -#include - -Q_DECLARE_METATYPE(Qt::LayoutDirection) -Q_DECLARE_METATYPE(QQuickListView::Orientation) - -using namespace QQuickViewTestUtil; -using namespace QQuickVisualTestUtil; - -class tst_QQuickListView : public QDeclarativeDataTest -{ - Q_OBJECT -public: - tst_QQuickListView(); - -private slots: - // Test both QListModelInterface and QAbstractItemModel model types - void qListModelInterface_items(); - void qListModelInterface_package_items(); - void qAbstractItemModel_items(); - - void qListModelInterface_changed(); - void qListModelInterface_package_changed(); - void qAbstractItemModel_changed(); - - void qListModelInterface_inserted(); - void qListModelInterface_inserted_more(); - void qListModelInterface_inserted_more_data(); - void qListModelInterface_package_inserted(); - void qAbstractItemModel_inserted(); - void qAbstractItemModel_inserted_more(); - void qAbstractItemModel_inserted_more_data(); - - void qListModelInterface_removed(); - void qListModelInterface_removed_more(); - void qListModelInterface_removed_more_data(); - void qListModelInterface_package_removed(); - void qAbstractItemModel_removed(); - void qAbstractItemModel_removed_more(); - void qAbstractItemModel_removed_more_data(); - - void qListModelInterface_moved(); - void qListModelInterface_moved_data(); - void qListModelInterface_package_moved(); - void qListModelInterface_package_moved_data(); - void qAbstractItemModel_moved(); - void qAbstractItemModel_moved_data(); - - void multipleChanges(); - void multipleChanges_data(); - - void qListModelInterface_clear(); - void qListModelInterface_package_clear(); - void qAbstractItemModel_clear(); - - void insertBeforeVisible(); - void insertBeforeVisible_data(); - void swapWithFirstItem(); - void itemList(); - void currentIndex_delayedItemCreation(); - void currentIndex_delayedItemCreation_data(); - void currentIndex(); - void noCurrentIndex(); - void enforceRange(); - void enforceRange_withoutHighlight(); - void spacing(); - void qListModelInterface_sections(); - void qListModelInterface_package_sections(); - void qAbstractItemModel_sections(); - void sectionsPositioning(); - void sectionsDelegate(); - void cacheBuffer(); - void positionViewAtIndex(); - void resetModel(); - void propertyChanges(); - void componentChanges(); - void modelChanges(); - void manualHighlight(); - void header(); - void header_data(); - void header_delayItemCreation(); - void footer(); - void footer_data(); - void headerFooter(); - void resizeView(); - void resizeViewAndRepaint(); - void sizeLessThan1(); - void QTBUG_14821(); - void resizeDelegate(); - void resizeFirstDelegate(); - void QTBUG_16037(); - void indexAt_itemAt_data(); - void indexAt_itemAt(); - void incrementalModel(); - void onAdd(); - void onAdd_data(); - void onRemove(); - void onRemove_data(); - void rightToLeft(); - void test_mirroring(); - void margins(); - void marginsResize(); - void marginsResize_data(); - void creationContext(); - void snapToItem_data(); - void snapToItem(); - void snapOneItem_data(); - void snapOneItem(); - - void QTBUG_9791(); - void QTBUG_11105(); - void QTBUG_21742(); - - void asynchronous(); - void unrequestedVisibility(); - - void populateTransitions(); - void populateTransitions_data(); - void addTransitions(); - void addTransitions_data(); - void moveTransitions(); - void moveTransitions_data(); - void removeTransitions(); - void removeTransitions_data(); - void multipleTransitions(); - void multipleTransitions_data(); - -private: - template void items(const QUrl &source, bool forceLayout); - template void changed(const QUrl &source, bool forceLayout); - template void inserted(const QUrl &source); - template void inserted_more(); - template void removed(const QUrl &source, bool animated); - template void removed_more(const QUrl &source); - template void moved(const QUrl &source); - template void clear(const QUrl &source); - template void sections(const QUrl &source); - - QList toIntList(const QVariantList &list); - void matchIndexLists(const QVariantList &indexLists, const QList &expectedIndexes); - void matchItemsAndIndexes(const QVariantMap &items, const QaimModel &model, const QList &expectedIndexes); - void matchItemLists(const QVariantList &itemLists, const QList &expectedItems); - - void inserted_more_data(); - void removed_more_data(); - void moved_data(); -}; - -class TestObject : public QObject -{ - Q_OBJECT - - Q_PROPERTY(bool error READ error WRITE setError NOTIFY changedError) - Q_PROPERTY(bool animate READ animate NOTIFY changedAnim) - Q_PROPERTY(bool invalidHighlight READ invalidHighlight NOTIFY changedHl) - Q_PROPERTY(int cacheBuffer READ cacheBuffer NOTIFY changedCacheBuffer) - -public: - TestObject(QObject *parent = 0) - : QObject(parent), mError(true), mAnimate(false), mInvalidHighlight(false) - , mCacheBuffer(0) {} - - bool error() const { return mError; } - void setError(bool err) { mError = err; emit changedError(); } - - bool animate() const { return mAnimate; } - void setAnimate(bool anim) { mAnimate = anim; emit changedAnim(); } - - bool invalidHighlight() const { return mInvalidHighlight; } - void setInvalidHighlight(bool invalid) { mInvalidHighlight = invalid; emit changedHl(); } - - int cacheBuffer() const { return mCacheBuffer; } - void setCacheBuffer(int buffer) { mCacheBuffer = buffer; emit changedCacheBuffer(); } - -signals: - void changedError(); - void changedAnim(); - void changedHl(); - void changedCacheBuffer(); - -public: - bool mError; - bool mAnimate; - bool mInvalidHighlight; - int mCacheBuffer; -}; - -tst_QQuickListView::tst_QQuickListView() -{ -} - -template -void tst_QQuickListView::items(const QUrl &source, bool forceLayout) -{ - QQuickView *canvas = createView(); - - T model; - model.addItem("Fred", "12345"); - model.addItem("John", "2345"); - model.addItem("Bob", "54321"); - - QDeclarativeContext *ctxt = canvas->rootContext(); - ctxt->setContextProperty("testModel", &model); - - TestObject *testObject = new TestObject; - ctxt->setContextProperty("testObject", testObject); - - canvas->setSource(source); - qApp->processEvents(); - - QQuickListView *listview = findItem(canvas->rootObject(), "list"); - QTRY_VERIFY(listview != 0); - - QQuickItem *contentItem = listview->contentItem(); - QTRY_VERIFY(contentItem != 0); - - QMetaObject::invokeMethod(canvas->rootObject(), "checkProperties"); - QTRY_VERIFY(testObject->error() == false); - - QTRY_VERIFY(listview->highlightItem() != 0); - QTRY_COMPARE(listview->count(), model.count()); - QTRY_COMPARE(canvas->rootObject()->property("count").toInt(), model.count()); - QTRY_COMPARE(contentItem->childItems().count(), model.count()+1); // assumes all are visible, +1 for the (default) highlight item - - // current item should be first item - QTRY_COMPARE(listview->currentItem(), findItem(contentItem, "wrapper", 0)); - - for (int i = 0; i < model.count(); ++i) { - QQuickText *name = findItem(contentItem, "textName", i); - QTRY_VERIFY(name != 0); - QTRY_COMPARE(name->text(), model.name(i)); - QQuickText *number = findItem(contentItem, "textNumber", i); - QTRY_VERIFY(number != 0); - QTRY_COMPARE(number->text(), model.number(i)); - } - - // switch to other delegate - testObject->setAnimate(true); - QMetaObject::invokeMethod(canvas->rootObject(), "checkProperties"); - QTRY_VERIFY(testObject->error() == false); - QTRY_VERIFY(listview->currentItem()); - - // set invalid highlight - testObject->setInvalidHighlight(true); - QMetaObject::invokeMethod(canvas->rootObject(), "checkProperties"); - QTRY_VERIFY(testObject->error() == false); - QTRY_VERIFY(listview->currentItem()); - QTRY_VERIFY(listview->highlightItem() == 0); - - // back to normal highlight - testObject->setInvalidHighlight(false); - QMetaObject::invokeMethod(canvas->rootObject(), "checkProperties"); - QTRY_VERIFY(testObject->error() == false); - QTRY_VERIFY(listview->currentItem()); - QTRY_VERIFY(listview->highlightItem() != 0); - - // set an empty model and confirm that items are destroyed - T model2; - ctxt->setContextProperty("testModel", &model2); - - // Force a layout, necessary if ListView is completed before VisualDataModel. - if (forceLayout) - QCOMPARE(listview->property("count").toInt(), 0); - - int itemCount = findItems(contentItem, "wrapper").count(); - QTRY_VERIFY(itemCount == 0); - - QTRY_COMPARE(listview->highlightResizeSpeed(), 1000.0); - QTRY_COMPARE(listview->highlightMoveSpeed(), 1000.0); - - delete canvas; - delete testObject; -} - - -template -void tst_QQuickListView::changed(const QUrl &source, bool forceLayout) -{ - QQuickView *canvas = createView(); - - T model; - model.addItem("Fred", "12345"); - model.addItem("John", "2345"); - model.addItem("Bob", "54321"); - - QDeclarativeContext *ctxt = canvas->rootContext(); - ctxt->setContextProperty("testModel", &model); - - TestObject *testObject = new TestObject; - ctxt->setContextProperty("testObject", testObject); - - canvas->setSource(source); - qApp->processEvents(); - - QQuickFlickable *listview = findItem(canvas->rootObject(), "list"); - QTRY_VERIFY(listview != 0); - - QQuickItem *contentItem = listview->contentItem(); - QTRY_VERIFY(contentItem != 0); - - // Force a layout, necessary if ListView is completed before VisualDataModel. - if (forceLayout) - QCOMPARE(listview->property("count").toInt(), model.count()); - - model.modifyItem(1, "Will", "9876"); - QQuickText *name = findItem(contentItem, "textName", 1); - QTRY_VERIFY(name != 0); - QTRY_COMPARE(name->text(), model.name(1)); - QQuickText *number = findItem(contentItem, "textNumber", 1); - QTRY_VERIFY(number != 0); - QTRY_COMPARE(number->text(), model.number(1)); - - delete canvas; - delete testObject; -} - -template -void tst_QQuickListView::inserted(const QUrl &source) -{ - QQuickView *canvas = createView(); - canvas->show(); - - T model; - model.addItem("Fred", "12345"); - model.addItem("John", "2345"); - model.addItem("Bob", "54321"); - - QDeclarativeContext *ctxt = canvas->rootContext(); - ctxt->setContextProperty("testModel", &model); - - TestObject *testObject = new TestObject; - ctxt->setContextProperty("testObject", testObject); - - canvas->setSource(source); - qApp->processEvents(); - - QQuickListView *listview = findItem(canvas->rootObject(), "list"); - QTRY_VERIFY(listview != 0); - - QQuickItem *contentItem = listview->contentItem(); - QTRY_VERIFY(contentItem != 0); - - model.insertItem(1, "Will", "9876"); - - QTRY_COMPARE(canvas->rootObject()->property("count").toInt(), model.count()); - QTRY_COMPARE(contentItem->childItems().count(), model.count()+1); // assumes all are visible, +1 for the (default) highlight item - - QQuickText *name = findItem(contentItem, "textName", 1); - QTRY_VERIFY(name != 0); - QTRY_COMPARE(name->text(), model.name(1)); - QQuickText *number = findItem(contentItem, "textNumber", 1); - QTRY_VERIFY(number != 0); - QTRY_COMPARE(number->text(), model.number(1)); - - // Confirm items positioned correctly - for (int i = 0; i < model.count(); ++i) { - QQuickItem *item = findItem(contentItem, "wrapper", i); - QTRY_COMPARE(item->y(), i*20.0); - } - - model.insertItem(0, "Foo", "1111"); // zero index, and current item - - QTRY_COMPARE(canvas->rootObject()->property("count").toInt(), model.count()); - QTRY_COMPARE(contentItem->childItems().count(), model.count()+1); // assumes all are visible, +1 for the (default) highlight item - - name = findItem(contentItem, "textName", 0); - QTRY_VERIFY(name != 0); - QTRY_COMPARE(name->text(), model.name(0)); - number = findItem(contentItem, "textNumber", 0); - QTRY_VERIFY(number != 0); - QTRY_COMPARE(number->text(), model.number(0)); - - QTRY_COMPARE(listview->currentIndex(), 1); - - // Confirm items positioned correctly - for (int i = 0; i < model.count(); ++i) { - QQuickItem *item = findItem(contentItem, "wrapper", i); - QTRY_COMPARE(item->y(), i*20.0); - } - - for (int i = model.count(); i < 30; ++i) - model.insertItem(i, "Hello", QString::number(i)); - - listview->setContentY(80); - - // Insert item outside visible area - model.insertItem(1, "Hello", "1324"); - - QTRY_VERIFY(listview->contentY() == 80); - - // Confirm items positioned correctly - for (int i = 5; i < 5+15; ++i) { - QQuickItem *item = findItem(contentItem, "wrapper", i); - if (!item) qWarning() << "Item" << i << "not found"; - QTRY_VERIFY(item); - QTRY_COMPARE(item->y(), i*20.0 - 20.0); - } - -// QTRY_COMPARE(listview->contentItemHeight(), model.count() * 20.0); - - // QTBUG-19675 - model.clear(); - model.insertItem(0, "Hello", "1234"); - QTRY_COMPARE(canvas->rootObject()->property("count").toInt(), model.count()); - - QQuickItem *item = findItem(contentItem, "wrapper", 0); - QVERIFY(item); - QCOMPARE(item->y(), 0.); - QTRY_VERIFY(listview->contentY() == 0); - - delete canvas; - delete testObject; -} - -template -void tst_QQuickListView::inserted_more() -{ - QFETCH(qreal, contentY); - QFETCH(int, insertIndex); - QFETCH(int, insertCount); - QFETCH(qreal, itemsOffsetAfterMove); - - T model; - for (int i = 0; i < 30; i++) - model.addItem("Item" + QString::number(i), ""); - - QQuickView *canvas = createView(); - QDeclarativeContext *ctxt = canvas->rootContext(); - ctxt->setContextProperty("testModel", &model); - - TestObject *testObject = new TestObject; - ctxt->setContextProperty("testObject", testObject); - - canvas->setSource(testFileUrl("listviewtest.qml")); - canvas->show(); - qApp->processEvents(); - - QQuickListView *listview = findItem(canvas->rootObject(), "list"); - QTRY_VERIFY(listview != 0); - QQuickItem *contentItem = listview->contentItem(); - QTRY_VERIFY(contentItem != 0); - - listview->setContentY(contentY); - QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false); - - QList > newData; - for (int i=0; iproperty("count").toInt(), model.count()); - - // check visibleItems.first() is in correct position - QQuickItem *item0 = findItem(contentItem, "wrapper", 0); - QVERIFY(item0); - QCOMPARE(item0->y(), itemsOffsetAfterMove); - - QList items = findItems(contentItem, "wrapper"); - int firstVisibleIndex = -1; - for (int i=0; iy() >= contentY) { - QDeclarativeExpression e(qmlContext(items[i]), items[i], "index"); - firstVisibleIndex = e.evaluate().toInt(); - break; - } - } - QVERIFY2(firstVisibleIndex >= 0, QTest::toString(firstVisibleIndex)); - - // Confirm items positioned correctly and indexes correct - int itemCount = findItems(contentItem, "wrapper").count(); - QQuickText *name; - QQuickText *number; - for (int i = firstVisibleIndex; i < model.count() && i < itemCount; ++i) { - QQuickItem *item = findItem(contentItem, "wrapper", i); - QVERIFY2(item, QTest::toString(QString("Item %1 not found").arg(i))); - QTRY_COMPARE(item->y(), i*20.0 + itemsOffsetAfterMove); - name = findItem(contentItem, "textName", i); - QVERIFY(name != 0); - QTRY_COMPARE(name->text(), model.name(i)); - number = findItem(contentItem, "textNumber", i); - QVERIFY(number != 0); - QTRY_COMPARE(number->text(), model.number(i)); - } - - delete canvas; - delete testObject; -} - -void tst_QQuickListView::inserted_more_data() -{ - QTest::addColumn("contentY"); - QTest::addColumn("insertIndex"); - QTest::addColumn("insertCount"); - QTest::addColumn("itemsOffsetAfterMove"); - - QTest::newRow("add 1, before visible items") - << 80.0 // show 4-19 - << 3 << 1 - << -20.0; // insert above first visible i.e. 0 is at -20, first visible should not move - - QTest::newRow("add multiple, before visible") - << 80.0 // show 4-19 - << 3 << 3 - << -20.0 * 3; // again first visible should not move - - QTest::newRow("add 1, at start of visible, content at start") - << 0.0 - << 0 << 1 - << 0.0; - - QTest::newRow("add multiple, start of visible, content at start") - << 0.0 - << 0 << 3 - << 0.0; - - QTest::newRow("add 1, at start of visible, content not at start") - << 80.0 // show 4-19 - << 4 << 1 - << 0.0; - - QTest::newRow("add multiple, at start of visible, content not at start") - << 80.0 // show 4-19 - << 4 << 3 - << 0.0; - - - QTest::newRow("add 1, at end of visible, content at start") - << 0.0 - << 15 << 1 - << 0.0; - - QTest::newRow("add 1, at end of visible, content at start") - << 0.0 - << 15 << 3 - << 0.0; - - QTest::newRow("add 1, at end of visible, content not at start") - << 80.0 // show 4-19 - << 19 << 1 - << 0.0; - - QTest::newRow("add multiple, at end of visible, content not at start") - << 80.0 // show 4-19 - << 19 << 3 - << 0.0; - - - QTest::newRow("add 1, after visible, content at start") - << 0.0 - << 16 << 1 - << 0.0; - - QTest::newRow("add 1, after visible, content at start") - << 0.0 - << 16 << 3 - << 0.0; - - QTest::newRow("add 1, after visible, content not at start") - << 80.0 // show 4-19 - << 20 << 1 - << 0.0; - - QTest::newRow("add multiple, after visible, content not at start") - << 80.0 // show 4-19 - << 20 << 3 - << 0.0; -} - -void tst_QQuickListView::insertBeforeVisible() -{ - QFETCH(int, insertIndex); - QFETCH(int, insertCount); - QFETCH(int, cacheBuffer); - - QQuickText *name; - QQuickView *canvas = createView(); - - QmlListModel model; - for (int i = 0; i < 30; i++) - model.addItem("Item" + QString::number(i), ""); - - QDeclarativeContext *ctxt = canvas->rootContext(); - ctxt->setContextProperty("testModel", &model); - - TestObject *testObject = new TestObject; - ctxt->setContextProperty("testObject", testObject); - - canvas->setSource(testFileUrl("listviewtest.qml")); - canvas->show(); - qApp->processEvents(); - - QQuickListView *listview = findItem(canvas->rootObject(), "list"); - QTRY_VERIFY(listview != 0); - QQuickItem *contentItem = listview->contentItem(); - QTRY_VERIFY(contentItem != 0); - - listview->setCacheBuffer(cacheBuffer); - QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false); - - // trigger a refill (not just setting contentY) so that the visibleItems grid is updated - int firstVisibleIndex = 20; // move to an index where the top item is not visible - listview->setContentY(firstVisibleIndex * 20.0); - listview->setCurrentIndex(firstVisibleIndex); - - qApp->processEvents(); - QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false); - QTRY_COMPARE(listview->currentIndex(), firstVisibleIndex); - QQuickItem *item = findItem(contentItem, "wrapper", firstVisibleIndex); - QVERIFY(item); - QCOMPARE(item->y(), listview->contentY()); - - QList > newData; - for (int i=0; iproperty("count").toInt(), model.count()); - - // now, moving to the top of the view should position the inserted items correctly - int itemsOffsetAfterMove = -(insertCount * 20); - listview->setCurrentIndex(0); - QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false); - QTRY_COMPARE(listview->currentIndex(), 0); - QTRY_COMPARE(listview->contentY(), 0.0 + itemsOffsetAfterMove); - - // Confirm items positioned correctly and indexes correct - int itemCount = findItems(contentItem, "wrapper").count(); - for (int i = 0; i < model.count() && i < itemCount; ++i) { - item = findItem(contentItem, "wrapper", i); - QVERIFY2(item, QTest::toString(QString("Item %1 not found").arg(i))); - QTRY_COMPARE(item->y(), i*20.0 + itemsOffsetAfterMove); - name = findItem(contentItem, "textName", i); - QVERIFY(name != 0); - QTRY_COMPARE(name->text(), model.name(i)); - } - - delete canvas; - delete testObject; -} - -void tst_QQuickListView::insertBeforeVisible_data() -{ - QTest::addColumn("insertIndex"); - QTest::addColumn("insertCount"); - QTest::addColumn("cacheBuffer"); - - QTest::newRow("insert 1 at 0, 0 buffer") << 0 << 1 << 0; - QTest::newRow("insert 1 at 0, 100 buffer") << 0 << 1 << 100; - QTest::newRow("insert 1 at 0, 500 buffer") << 0 << 1 << 500; - - QTest::newRow("insert 1 at 1, 0 buffer") << 1 << 1 << 0; - QTest::newRow("insert 1 at 1, 100 buffer") << 1 << 1 << 100; - QTest::newRow("insert 1 at 1, 500 buffer") << 1 << 1 << 500; - - QTest::newRow("insert multiple at 0, 0 buffer") << 0 << 3 << 0; - QTest::newRow("insert multiple at 0, 100 buffer") << 0 << 3 << 100; - QTest::newRow("insert multiple at 0, 500 buffer") << 0 << 3 << 500; - - QTest::newRow("insert multiple at 1, 0 buffer") << 1 << 3 << 0; - QTest::newRow("insert multiple at 1, 100 buffer") << 1 << 3 << 100; - QTest::newRow("insert multiple at 1, 500 buffer") << 1 << 3 << 500; -} - -template -void tst_QQuickListView::removed(const QUrl &source, bool /* animated */) -{ - QQuickView *canvas = createView(); - - T model; - for (int i = 0; i < 50; i++) - model.addItem("Item" + QString::number(i), ""); - - QDeclarativeContext *ctxt = canvas->rootContext(); - ctxt->setContextProperty("testModel", &model); - - TestObject *testObject = new TestObject; - ctxt->setContextProperty("testObject", testObject); - - canvas->setSource(source); - canvas->show(); - qApp->processEvents(); - - QQuickListView *listview = findItem(canvas->rootObject(), "list"); - QTRY_VERIFY(listview != 0); - QQuickItem *contentItem = listview->contentItem(); - QTRY_VERIFY(contentItem != 0); - QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false); - - model.removeItem(1); - QTRY_COMPARE(canvas->rootObject()->property("count").toInt(), model.count()); - - QQuickText *name = findItem(contentItem, "textName", 1); - QTRY_VERIFY(name != 0); - QTRY_COMPARE(name->text(), model.name(1)); - QQuickText *number = findItem(contentItem, "textNumber", 1); - QTRY_VERIFY(number != 0); - QTRY_COMPARE(number->text(), model.number(1)); - - // Confirm items positioned correctly - int itemCount = findItems(contentItem, "wrapper").count(); - for (int i = 0; i < model.count() && i < itemCount; ++i) { - QQuickItem *item = findItem(contentItem, "wrapper", i); - if (!item) qWarning() << "Item" << i << "not found"; - QTRY_VERIFY(item); - QTRY_VERIFY(item->y() == i*20); - } - - // Remove first item (which is the current item); - model.removeItem(0); - QTRY_COMPARE(canvas->rootObject()->property("count").toInt(), model.count()); - - name = findItem(contentItem, "textName", 0); - QTRY_VERIFY(name != 0); - QTRY_COMPARE(name->text(), model.name(0)); - number = findItem(contentItem, "textNumber", 0); - QTRY_VERIFY(number != 0); - QTRY_COMPARE(number->text(), model.number(0)); - - // Confirm items positioned correctly - itemCount = findItems(contentItem, "wrapper").count(); - for (int i = 0; i < model.count() && i < itemCount; ++i) { - QQuickItem *item = findItem(contentItem, "wrapper", i); - if (!item) qWarning() << "Item" << i << "not found"; - QTRY_VERIFY(item); - QTRY_COMPARE(item->y(),i*20.0); - } - - // Remove items not visible - model.removeItem(18); - QTRY_COMPARE(canvas->rootObject()->property("count").toInt(), model.count()); - - // Confirm items positioned correctly - itemCount = findItems(contentItem, "wrapper").count(); - for (int i = 0; i < model.count() && i < itemCount; ++i) { - QQuickItem *item = findItem(contentItem, "wrapper", i); - if (!item) qWarning() << "Item" << i << "not found"; - QTRY_VERIFY(item); - QTRY_COMPARE(item->y(),i*20.0); - } - - // Remove items before visible - listview->setContentY(80); - listview->setCurrentIndex(10); - - model.removeItem(1); // post: top item will be at 20 - QTRY_COMPARE(canvas->rootObject()->property("count").toInt(), model.count()); - - // Confirm items positioned correctly - for (int i = 2; i < 18; ++i) { - QQuickItem *item = findItem(contentItem, "wrapper", i); - if (!item) qWarning() << "Item" << i << "not found"; - QTRY_VERIFY(item); - QTRY_COMPARE(item->y(),20+i*20.0); - } - - // Remove current index - QTRY_VERIFY(listview->currentIndex() == 9); - QQuickItem *oldCurrent = listview->currentItem(); - model.removeItem(9); - - QTRY_COMPARE(listview->currentIndex(), 9); - QTRY_VERIFY(listview->currentItem() != oldCurrent); - - listview->setContentY(20); // That's the top now - // let transitions settle. - QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false); - QTest::qWait(300); - - // Confirm items positioned correctly - itemCount = findItems(contentItem, "wrapper").count(); - for (int i = 0; i < model.count() && i < itemCount; ++i) { - QQuickItem *item = findItem(contentItem, "wrapper", i); - if (!item) qWarning() << "Item" << i << "not found"; - QTRY_VERIFY(item); - QTRY_COMPARE(item->y(),20+i*20.0); - } - - // remove current item beyond visible items. - listview->setCurrentIndex(20); - listview->setContentY(40); - QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false); - - model.removeItem(20); - QTRY_COMPARE(listview->currentIndex(), 20); - QTRY_VERIFY(listview->currentItem() != 0); - - // remove item before current, but visible - listview->setCurrentIndex(8); - QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false); - oldCurrent = listview->currentItem(); - model.removeItem(6); - - QTRY_COMPARE(listview->currentIndex(), 7); - QTRY_VERIFY(listview->currentItem() == oldCurrent); - - listview->setContentY(80); - QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false); - QTest::qWait(300); - - // remove all visible items - model.removeItems(1, 18); - QTRY_COMPARE(listview->count() , model.count()); - - // Confirm items positioned correctly - itemCount = findItems(contentItem, "wrapper").count(); - for (int i = 0; i < model.count() && i < itemCount-1; ++i) { - QQuickItem *item = findItem(contentItem, "wrapper", i+1); - if (!item) qWarning() << "Item" << i+1 << "not found"; - QTRY_VERIFY(item); - QTRY_COMPARE(item->y(),80+i*20.0); - } - - model.removeItems(1, 17); - QTRY_COMPARE(listview->count() , model.count()); - - model.removeItems(2, 1); - QTRY_COMPARE(listview->count() , model.count()); - - model.addItem("New", "1"); - QTRY_COMPARE(listview->count() , model.count()); - - QTRY_VERIFY(name = findItem(contentItem, "textName", model.count()-1)); - QCOMPARE(name->text(), QString("New")); - - // Add some more items so that we don't run out - model.clear(); - for (int i = 0; i < 50; i++) - model.addItem("Item" + QString::number(i), ""); - - // QTBUG-QTBUG-20575 - listview->setCurrentIndex(0); - listview->setContentY(30); - model.removeItem(0); - QTRY_VERIFY(name = findItem(contentItem, "textName", 0)); - - // QTBUG-19198 move to end and remove all visible items one at a time. - listview->positionViewAtEnd(); - for (int i = 0; i < 18; ++i) - model.removeItems(model.count() - 1, 1); - QTRY_VERIFY(findItems(contentItem, "wrapper").count() > 16); - - delete canvas; - delete testObject; -} - -template -void tst_QQuickListView::removed_more(const QUrl &source) -{ - QFETCH(qreal, contentY); - QFETCH(int, removeIndex); - QFETCH(int, removeCount); - QFETCH(qreal, itemsOffsetAfterMove); - - QQuickText *name; - QQuickText *number; - QQuickView *canvas = createView(); - - T model; - for (int i = 0; i < 30; i++) - model.addItem("Item" + QString::number(i), ""); - - QDeclarativeContext *ctxt = canvas->rootContext(); - ctxt->setContextProperty("testModel", &model); - - TestObject *testObject = new TestObject; - ctxt->setContextProperty("testObject", testObject); - - canvas->setSource(source); - canvas->show(); - qApp->processEvents(); - - QQuickListView *listview = findItem(canvas->rootObject(), "list"); - QTRY_VERIFY(listview != 0); - QQuickItem *contentItem = listview->contentItem(); - QTRY_VERIFY(contentItem != 0); - - listview->setContentY(contentY); - QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false); - - // wait for refill (after refill, items above the firstVisibleIndex-1 should not be rendered) - int firstVisibleIndex = contentY / 20; - if (firstVisibleIndex - 2 >= 0) - QTRY_VERIFY(!findItem(contentItem, "textName", firstVisibleIndex - 2)); - - model.removeItems(removeIndex, removeCount); - QTRY_COMPARE(listview->property("count").toInt(), model.count()); - - // check visibleItems.first() is in correct position - QQuickItem *item0 = findItem(contentItem, "wrapper", 0); - QVERIFY(item0); - QCOMPARE(item0->y(), itemsOffsetAfterMove); - - QList items = findItems(contentItem, "wrapper"); - for (int i=0; iy() >= contentY) { - QDeclarativeExpression e(qmlContext(items[i]), items[i], "index"); - firstVisibleIndex = e.evaluate().toInt(); - break; - } - } - QVERIFY2(firstVisibleIndex >= 0, QTest::toString(firstVisibleIndex)); - - // Confirm items positioned correctly and indexes correct - int itemCount = findItems(contentItem, "wrapper").count(); - for (int i = firstVisibleIndex; i < model.count() && i < itemCount; ++i) { - QQuickItem *item = findItem(contentItem, "wrapper", i); - QVERIFY2(item, QTest::toString(QString("Item %1 not found").arg(i))); - QTRY_COMPARE(item->y(), i*20.0 + itemsOffsetAfterMove); - name = findItem(contentItem, "textName", i); - QVERIFY(name != 0); - QTRY_COMPARE(name->text(), model.name(i)); - number = findItem(contentItem, "textNumber", i); - QVERIFY(number != 0); - QTRY_COMPARE(number->text(), model.number(i)); - } - - delete canvas; - delete testObject; -} - -void tst_QQuickListView::removed_more_data() -{ - QTest::addColumn("contentY"); - QTest::addColumn("removeIndex"); - QTest::addColumn("removeCount"); - QTest::addColumn("itemsOffsetAfterMove"); - - QTest::newRow("remove 1, before visible items") - << 80.0 // show 4-19 - << 3 << 1 - << 20.0; // visible items slide down by 1 item so that first visible does not move - - QTest::newRow("remove multiple, all before visible items") - << 80.0 - << 1 << 3 - << 20.0 * 3; - - QTest::newRow("remove multiple, all before visible items, remove item 0") - << 80.0 - << 0 << 4 - << 20.0 * 4; - - // remove 1,2,3 before the visible pos, 0 moves down to just before the visible pos, - // items 4,5 are removed from view, item 6 slides up to original pos of item 4 (80px) - QTest::newRow("remove multiple, mix of items from before and within visible items") - << 80.0 - << 1 << 5 - << 20.0 * 3; // adjust for the 3 items removed before the visible - - QTest::newRow("remove multiple, mix of items from before and within visible items, remove item 0") - << 80.0 - << 0 << 6 - << 20.0 * 4; // adjust for the 3 items removed before the visible - - - QTest::newRow("remove 1, from start of visible, content at start") - << 0.0 - << 0 << 1 - << 0.0; - - QTest::newRow("remove multiple, from start of visible, content at start") - << 0.0 - << 0 << 3 - << 0.0; - - QTest::newRow("remove 1, from start of visible, content not at start") - << 80.0 // show 4-19 - << 4 << 1 - << 0.0; - - QTest::newRow("remove multiple, from start of visible, content not at start") - << 80.0 // show 4-19 - << 4 << 3 - << 0.0; - - - QTest::newRow("remove 1, from middle of visible, content at start") - << 0.0 - << 10 << 1 - << 0.0; - - QTest::newRow("remove multiple, from middle of visible, content at start") - << 0.0 - << 10 << 5 - << 0.0; - - QTest::newRow("remove 1, from middle of visible, content not at start") - << 80.0 // show 4-19 - << 10 << 1 - << 0.0; - - QTest::newRow("remove multiple, from middle of visible, content not at start") - << 80.0 // show 4-19 - << 10 << 5 - << 0.0; - - - QTest::newRow("remove 1, after visible, content at start") - << 0.0 - << 16 << 1 - << 0.0; - - QTest::newRow("remove multiple, after visible, content at start") - << 0.0 - << 16 << 5 - << 0.0; - - QTest::newRow("remove 1, after visible, content not at middle") - << 80.0 // show 4-19 - << 16+4 << 1 - << 0.0; - - QTest::newRow("remove multiple, after visible, content not at start") - << 80.0 // show 4-19 - << 16+4 << 5 - << 0.0; - - QTest::newRow("remove multiple, mix of items from within and after visible items") - << 80.0 - << 18 << 5 - << 0.0; -} - -template -void tst_QQuickListView::clear(const QUrl &source) -{ - QQuickView *canvas = createView(); - - T model; - for (int i = 0; i < 30; i++) - model.addItem("Item" + QString::number(i), ""); - - QDeclarativeContext *ctxt = canvas->rootContext(); - ctxt->setContextProperty("testModel", &model); - - TestObject *testObject = new TestObject; - ctxt->setContextProperty("testObject", testObject); - - canvas->setSource(source); - canvas->show(); - qApp->processEvents(); - - QQuickListView *listview = findItem(canvas->rootObject(), "list"); - QTRY_VERIFY(listview != 0); - QQuickItem *contentItem = listview->contentItem(); - QTRY_VERIFY(contentItem != 0); - QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false); - - model.clear(); - - QTRY_VERIFY(listview->count() == 0); - QTRY_VERIFY(listview->currentItem() == 0); - QTRY_VERIFY(listview->contentY() == 0); - QVERIFY(listview->currentIndex() == -1); - - // confirm sanity when adding an item to cleared list - model.addItem("New", "1"); - QTRY_VERIFY(listview->count() == 1); - QVERIFY(listview->currentItem() != 0); - QVERIFY(listview->currentIndex() == 0); - - delete canvas; - delete testObject; -} - -template -void tst_QQuickListView::moved(const QUrl &source) -{ - QFETCH(qreal, contentY); - QFETCH(int, from); - QFETCH(int, to); - QFETCH(int, count); - QFETCH(qreal, itemsOffsetAfterMove); - - QQuickText *name; - QQuickText *number; - QQuickView *canvas = createView(); - - T model; - for (int i = 0; i < 30; i++) - model.addItem("Item" + QString::number(i), ""); - - QDeclarativeContext *ctxt = canvas->rootContext(); - ctxt->setContextProperty("testModel", &model); - - TestObject *testObject = new TestObject; - ctxt->setContextProperty("testObject", testObject); - - canvas->setSource(source); - canvas->show(); - qApp->processEvents(); - - QQuickListView *listview = findItem(canvas->rootObject(), "list"); - QTRY_VERIFY(listview != 0); - QQuickItem *contentItem = listview->contentItem(); - QTRY_VERIFY(contentItem != 0); - QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false); - - QQuickItem *currentItem = listview->currentItem(); - QTRY_VERIFY(currentItem != 0); - - if (contentY != 0) { - listview->setContentY(contentY); - QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false); - } - - model.moveItems(from, to, count); - QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false); - - QList items = findItems(contentItem, "wrapper"); - int firstVisibleIndex = -1; - for (int i=0; iy() >= contentY) { - QDeclarativeExpression e(qmlContext(items[i]), items[i], "index"); - firstVisibleIndex = e.evaluate().toInt(); - break; - } - } - QVERIFY2(firstVisibleIndex >= 0, QTest::toString(firstVisibleIndex)); - - // Confirm items positioned correctly and indexes correct - int itemCount = findItems(contentItem, "wrapper").count(); - for (int i = firstVisibleIndex; i < model.count() && i < itemCount; ++i) { - if (i >= firstVisibleIndex + 16) // index has moved out of view - continue; - QQuickItem *item = findItem(contentItem, "wrapper", i); - QVERIFY2(item, QTest::toString(QString("Item %1 not found").arg(i))); - QTRY_COMPARE(item->y(), i*20.0 + itemsOffsetAfterMove); - name = findItem(contentItem, "textName", i); - QVERIFY(name != 0); - QTRY_COMPARE(name->text(), model.name(i)); - number = findItem(contentItem, "textNumber", i); - QVERIFY(number != 0); - QTRY_COMPARE(number->text(), model.number(i)); - - // current index should have been updated - if (item == currentItem) - QTRY_COMPARE(listview->currentIndex(), i); - } - - delete canvas; - delete testObject; -} - -void tst_QQuickListView::moved_data() -{ - QTest::addColumn("contentY"); - QTest::addColumn("from"); - QTest::addColumn("to"); - QTest::addColumn("count"); - QTest::addColumn("itemsOffsetAfterMove"); - - // model starts with 30 items, each 20px high, in area 320px high - // 16 items should be visible at a time - // itemsOffsetAfterMove should be > 0 whenever items above the visible pos have moved - - QTest::newRow("move 1 forwards, within visible items") - << 0.0 - << 1 << 4 << 1 - << 0.0; - - QTest::newRow("move 1 forwards, from non-visible -> visible") - << 80.0 // show 4-19 - << 1 << 18 << 1 - << 20.0; // removed 1 item above the first visible, so item 0 should drop down by 1 to minimize movement - - QTest::newRow("move 1 forwards, from non-visible -> visible (move first item)") - << 80.0 // show 4-19 - << 0 << 4 << 1 - << 20.0; // first item has moved to below item4, everything drops down by size of 1 item - - QTest::newRow("move 1 forwards, from visible -> non-visible") - << 0.0 - << 1 << 16 << 1 - << 0.0; - - QTest::newRow("move 1 forwards, from visible -> non-visible (move first item)") - << 0.0 - << 0 << 16 << 1 - << 0.0; - - - QTest::newRow("move 1 backwards, within visible items") - << 0.0 - << 4 << 1 << 1 - << 0.0; - - QTest::newRow("move 1 backwards, within visible items (to first index)") - << 0.0 - << 4 << 0 << 1 - << 0.0; - - QTest::newRow("move 1 backwards, from non-visible -> visible") - << 0.0 - << 20 << 4 << 1 - << 0.0; - - QTest::newRow("move 1 backwards, from non-visible -> visible (move last item)") - << 0.0 - << 29 << 15 << 1 - << 0.0; - - QTest::newRow("move 1 backwards, from visible -> non-visible") - << 80.0 // show 4-19 - << 16 << 1 << 1 - << -20.0; // to minimize movement, item 0 moves to -20, and other items do not move - - QTest::newRow("move 1 backwards, from visible -> non-visible (move first item)") - << 80.0 // show 4-19 - << 16 << 0 << 1 - << -20.0; // to minimize movement, item 16 (now at 0) moves to -20, and other items do not move - - - QTest::newRow("move multiple forwards, within visible items") - << 0.0 - << 0 << 5 << 3 - << 0.0; - - QTest::newRow("move multiple forwards, before visible items") - << 140.0 // show 7-22 - << 4 << 5 << 3 // 4,5,6 move to below 7 - << 20.0 * 3; // 4,5,6 moved down - - QTest::newRow("move multiple forwards, from non-visible -> visible") - << 80.0 // show 4-19 - << 1 << 5 << 3 - << 20.0 * 3; // moving 3 from above the content y should adjust y positions accordingly - - QTest::newRow("move multiple forwards, from non-visible -> visible (move first item)") - << 80.0 // show 4-19 - << 0 << 5 << 3 - << 20.0 * 3; // moving 3 from above the content y should adjust y positions accordingly - - QTest::newRow("move multiple forwards, mix of non-visible/visible") - << 40.0 - << 1 << 16 << 2 - << 20.0; // item 1,2 are removed, item 3 is now first visible - - QTest::newRow("move multiple forwards, to bottom of view") - << 0.0 - << 5 << 13 << 3 - << 0.0; - - QTest::newRow("move multiple forwards, to bottom of view, first->last") - << 0.0 - << 0 << 13 << 3 - << 0.0; - - QTest::newRow("move multiple forwards, to bottom of view, content y not 0") - << 80.0 - << 5+4 << 13+4 << 3 - << 0.0; - - QTest::newRow("move multiple forwards, from visible -> non-visible") - << 0.0 - << 1 << 16 << 3 - << 0.0; - - QTest::newRow("move multiple forwards, from visible -> non-visible (move first item)") - << 0.0 - << 0 << 16 << 3 - << 0.0; - - - QTest::newRow("move multiple backwards, within visible items") - << 0.0 - << 4 << 1 << 3 - << 0.0; - - QTest::newRow("move multiple backwards, within visible items (move first item)") - << 0.0 - << 10 << 0 << 3 - << 0.0; - - QTest::newRow("move multiple backwards, from non-visible -> visible") - << 0.0 - << 20 << 4 << 3 - << 0.0; - - QTest::newRow("move multiple backwards, from non-visible -> visible (move last item)") - << 0.0 - << 27 << 10 << 3 - << 0.0; - - QTest::newRow("move multiple backwards, from visible -> non-visible") - << 80.0 // show 4-19 - << 16 << 1 << 3 - << -20.0 * 3; // to minimize movement, 0 moves by -60, and other items do not move - - QTest::newRow("move multiple backwards, from visible -> non-visible (move first item)") - << 80.0 // show 4-19 - << 16 << 0 << 3 - << -20.0 * 3; // to minimize movement, 16,17,18 move to above item 0, and other items do not move -} - -void tst_QQuickListView::multipleChanges() -{ - QFETCH(int, startCount); - QFETCH(QList, changes); - QFETCH(int, newCount); - QFETCH(int, newCurrentIndex); - - QQuickView *canvas = createView(); - - QmlListModel model; - for (int i = 0; i < startCount; i++) - model.addItem("Item" + QString::number(i), ""); - - QDeclarativeContext *ctxt = canvas->rootContext(); - ctxt->setContextProperty("testModel", &model); - - TestObject *testObject = new TestObject; - ctxt->setContextProperty("testObject", testObject); - - canvas->setSource(testFileUrl("listviewtest.qml")); - canvas->show(); - qApp->processEvents(); - - QQuickListView *listview = findItem(canvas->rootObject(), "list"); - QTRY_VERIFY(listview != 0); - QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false); - - for (int i=0; i > items; - for (int j=changes[i].index; jpolishScheduled, false); - break; - } - case ListChange::Removed: - model.removeItems(changes[i].index, changes[i].count); - QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false); - break; - case ListChange::Moved: - model.moveItems(changes[i].index, changes[i].to, changes[i].count); - QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false); - break; - case ListChange::SetCurrent: - listview->setCurrentIndex(changes[i].index); - QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false); - break; - case ListChange::SetContentY: - listview->setContentY(changes[i].pos); - QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false); - break; - } - } - - QTRY_COMPARE(listview->count(), newCount); - QCOMPARE(listview->count(), model.count()); - QTRY_COMPARE(listview->currentIndex(), newCurrentIndex); - - QQuickText *name; - QQuickText *number; - QQuickItem *contentItem = listview->contentItem(); - QTRY_VERIFY(contentItem != 0); - int itemCount = findItems(contentItem, "wrapper").count(); - for (int i=0; i < model.count() && i < itemCount; ++i) { - QQuickItem *item = findItem(contentItem, "wrapper", i); - QVERIFY2(item, QTest::toString(QString("Item %1 not found").arg(i))); - name = findItem(contentItem, "textName", i); - QVERIFY(name != 0); - QTRY_COMPARE(name->text(), model.name(i)); - number = findItem(contentItem, "textNumber", i); - QVERIFY(number != 0); - QTRY_COMPARE(number->text(), model.number(i)); - } - - delete testObject; - delete canvas; -} - -void tst_QQuickListView::multipleChanges_data() -{ - QTest::addColumn("startCount"); - QTest::addColumn >("changes"); - QTest::addColumn("newCount"); - QTest::addColumn("newCurrentIndex"); - - QList changes; - - for (int i=1; i<30; i++) - changes << ListChange::remove(0); - QTest::newRow("remove all but 1, first->last") << 30 << changes << 1 << 0; - - changes << ListChange::remove(0); - QTest::newRow("remove all") << 30 << changes << 0 << -1; - - changes.clear(); - changes << ListChange::setCurrent(29); - for (int i=29; i>0; i--) - changes << ListChange::remove(i); - QTest::newRow("remove last (current) -> first") << 30 << changes << 1 << 0; - - QTest::newRow("remove then insert at 0") << 10 << (QList() - << ListChange::remove(0, 1) - << ListChange::insert(0, 1) - ) << 10 << 1; - - QTest::newRow("remove then insert at non-zero index") << 10 << (QList() - << ListChange::setCurrent(2) - << ListChange::remove(2, 1) - << ListChange::insert(2, 1) - ) << 10 << 3; - - QTest::newRow("remove current then insert below it") << 10 << (QList() - << ListChange::setCurrent(1) - << ListChange::remove(1, 3) - << ListChange::insert(2, 2) - ) << 9 << 1; - - QTest::newRow("remove current index then move it down") << 10 << (QList() - << ListChange::setCurrent(2) - << ListChange::remove(1, 3) - << ListChange::move(1, 5, 1) - ) << 7 << 5; - - QTest::newRow("remove current index then move it up") << 10 << (QList() - << ListChange::setCurrent(5) - << ListChange::remove(4, 3) - << ListChange::move(4, 1, 1) - ) << 7 << 1; - - - QTest::newRow("insert multiple times") << 0 << (QList() - << ListChange::insert(0, 2) - << ListChange::insert(0, 4) - << ListChange::insert(0, 6) - ) << 12 << 10; - - QTest::newRow("insert multiple times with current index changes") << 0 << (QList() - << ListChange::insert(0, 2) - << ListChange::insert(0, 4) - << ListChange::insert(0, 6) - << ListChange::setCurrent(3) - << ListChange::insert(3, 2) - ) << 14 << 5; - - QTest::newRow("insert and remove all") << 0 << (QList() - << ListChange::insert(0, 30) - << ListChange::remove(0, 30) - ) << 0 << -1; - - QTest::newRow("insert and remove current") << 30 << (QList() - << ListChange::insert(1) - << ListChange::setCurrent(1) - << ListChange::remove(1) - ) << 30 << 1; - - QTest::newRow("insert before 0, then remove cross section of new and old items") << 10 << (QList() - << ListChange::insert(0, 10) - << ListChange::remove(5, 10) - ) << 10 << 5; - - QTest::newRow("insert multiple, then move new items to end") << 10 << (QList() - << ListChange::insert(0, 3) - << ListChange::move(0, 10, 3) - ) << 13 << 0; - - QTest::newRow("insert multiple, then move new and some old items to end") << 10 << (QList() - << ListChange::insert(0, 3) - << ListChange::move(0, 8, 5) - ) << 13 << 11; - - QTest::newRow("insert multiple at end, then move new and some old items to start") << 10 << (QList() - << ListChange::setCurrent(9) - << ListChange::insert(10, 3) - << ListChange::move(8, 0, 5) - ) << 13 << 1; - - - QTest::newRow("move back and forth to same index") << 10 << (QList() - << ListChange::setCurrent(1) - << ListChange::move(1, 2, 2) - << ListChange::move(2, 1, 2) - ) << 10 << 1; - - QTest::newRow("move forwards then back") << 10 << (QList() - << ListChange::setCurrent(2) - << ListChange::move(1, 2, 3) - << ListChange::move(3, 0, 5) - ) << 10 << 0; - - QTest::newRow("move current, then remove it") << 10 << (QList() - << ListChange::setCurrent(5) - << ListChange::move(5, 0, 1) - << ListChange::remove(0) - ) << 9 << 0; - - QTest::newRow("move current, then insert before it") << 10 << (QList() - << ListChange::setCurrent(5) - << ListChange::move(5, 0, 1) - << ListChange::insert(0) - ) << 11 << 1; - - QTest::newRow("move multiple, then remove them") << 10 << (QList() - << ListChange::setCurrent(1) - << ListChange::move(5, 1, 3) - << ListChange::remove(1, 3) - ) << 7 << 1; - - QTest::newRow("move multiple, then insert before them") << 10 << (QList() - << ListChange::setCurrent(5) - << ListChange::move(5, 1, 3) - << ListChange::insert(1, 5) - ) << 15 << 6; - - QTest::newRow("move multiple, then insert after them") << 10 << (QList() - << ListChange::setCurrent(3) - << ListChange::move(0, 1, 2) - << ListChange::insert(3, 5) - ) << 15 << 8; - - - QTest::newRow("clear current") << 0 << (QList() - << ListChange::insert(0, 5) - << ListChange::setCurrent(-1) - << ListChange::remove(0, 5) - << ListChange::insert(0, 5) - ) << 5 << -1; -} - -void tst_QQuickListView::swapWithFirstItem() -{ - QQuickView *canvas = createView(); - - QmlListModel model; - for (int i = 0; i < 30; i++) - model.addItem("Item" + QString::number(i), ""); - - QDeclarativeContext *ctxt = canvas->rootContext(); - ctxt->setContextProperty("testModel", &model); - - TestObject *testObject = new TestObject; - ctxt->setContextProperty("testObject", testObject); - - canvas->setSource(testFileUrl("listviewtest.qml")); - canvas->show(); - qApp->processEvents(); - - QQuickListView *listview = findItem(canvas->rootObject(), "list"); - QTRY_VERIFY(listview != 0); - QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false); - - // ensure content position is stable - listview->setContentY(0); - model.moveItem(1, 0); - QTRY_VERIFY(listview->contentY() == 0); - - delete testObject; - delete canvas; -} - -void tst_QQuickListView::enforceRange() -{ - QQuickView *canvas = createView(); - - QmlListModel model; - for (int i = 0; i < 30; i++) - model.addItem("Item" + QString::number(i), ""); - - QDeclarativeContext *ctxt = canvas->rootContext(); - ctxt->setContextProperty("testModel", &model); - - canvas->setSource(testFileUrl("listview-enforcerange.qml")); - canvas->show(); - qApp->processEvents(); - - QQuickListView *listview = findItem(canvas->rootObject(), "list"); - QTRY_VERIFY(listview != 0); - - QTRY_COMPARE(listview->preferredHighlightBegin(), 100.0); - QTRY_COMPARE(listview->preferredHighlightEnd(), 100.0); - QTRY_COMPARE(listview->highlightRangeMode(), QQuickListView::StrictlyEnforceRange); - QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false); - - QQuickItem *contentItem = listview->contentItem(); - QTRY_VERIFY(contentItem != 0); - - // view should be positioned at the top of the range. - QQuickItem *item = findItem(contentItem, "wrapper", 0); - QTRY_VERIFY(item); - QTRY_COMPARE(listview->contentY(), -100.0); - - QQuickText *name = findItem(contentItem, "textName", 0); - QTRY_VERIFY(name != 0); - QTRY_COMPARE(name->text(), model.name(0)); - QQuickText *number = findItem(contentItem, "textNumber", 0); - QTRY_VERIFY(number != 0); - QTRY_COMPARE(number->text(), model.number(0)); - - // Check currentIndex is updated when contentItem moves - listview->setContentY(20); - - QTRY_COMPARE(listview->currentIndex(), 6); - - // change model - QmlListModel model2; - for (int i = 0; i < 5; i++) - model2.addItem("Item" + QString::number(i), ""); - - ctxt->setContextProperty("testModel", &model2); - QCOMPARE(listview->count(), 5); - - delete canvas; -} - -void tst_QQuickListView::enforceRange_withoutHighlight() -{ - // QTBUG-20287 - // If no highlight is set but StrictlyEnforceRange is used, the content should still move - // to the correct position (i.e. to the next/previous item, not next/previous section) - // when moving up/down via incrementCurrentIndex() and decrementCurrentIndex() - - QQuickView *canvas = createView(); - - QmlListModel model; - model.addItem("Item 0", "a"); - model.addItem("Item 1", "b"); - model.addItem("Item 2", "b"); - model.addItem("Item 3", "c"); - - QDeclarativeContext *ctxt = canvas->rootContext(); - ctxt->setContextProperty("testModel", &model); - - canvas->setSource(testFileUrl("listview-enforcerange-nohighlight.qml")); - canvas->show(); - qApp->processEvents(); - - QQuickListView *listview = findItem(canvas->rootObject(), "list"); - QTRY_VERIFY(listview != 0); - QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false); - - qreal expectedPos = -100.0; - - expectedPos += 10.0; // scroll past 1st section's delegate (10px height) - QTRY_COMPARE(listview->contentY(), expectedPos); - - expectedPos += 20 + 10; // scroll past 1st section and section delegate of 2nd section - QTest::keyClick(canvas, Qt::Key_Down); - - QTRY_COMPARE(listview->contentY(), expectedPos); - - expectedPos += 20; // scroll past 1st item of 2nd section - QTest::keyClick(canvas, Qt::Key_Down); - QTRY_COMPARE(listview->contentY(), expectedPos); - - expectedPos += 20 + 10; // scroll past 2nd item of 2nd section and section delegate of 3rd section - QTest::keyClick(canvas, Qt::Key_Down); - QTRY_COMPARE(listview->contentY(), expectedPos); - - delete canvas; -} - -void tst_QQuickListView::spacing() -{ - QQuickView *canvas = createView(); - - QmlListModel model; - for (int i = 0; i < 30; i++) - model.addItem("Item" + QString::number(i), ""); - - QDeclarativeContext *ctxt = canvas->rootContext(); - ctxt->setContextProperty("testModel", &model); - - TestObject *testObject = new TestObject; - ctxt->setContextProperty("testObject", testObject); - - canvas->setSource(testFileUrl("listviewtest.qml")); - canvas->show(); - qApp->processEvents(); - - QQuickListView *listview = findItem(canvas->rootObject(), "list"); - QTRY_VERIFY(listview != 0); - - QQuickItem *contentItem = listview->contentItem(); - QTRY_VERIFY(contentItem != 0); - QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false); - - // Confirm items positioned correctly - int itemCount = findItems(contentItem, "wrapper").count(); - for (int i = 0; i < model.count() && i < itemCount; ++i) { - QQuickItem *item = findItem(contentItem, "wrapper", i); - if (!item) qWarning() << "Item" << i << "not found"; - QTRY_VERIFY(item); - QTRY_VERIFY(item->y() == i*20); - } - - listview->setSpacing(10); - QTRY_VERIFY(listview->spacing() == 10); - - // Confirm items positioned correctly - QTRY_VERIFY(findItems(contentItem, "wrapper").count() == 11); - for (int i = 0; i < 11; ++i) { - QQuickItem *item = findItem(contentItem, "wrapper", i); - if (!item) qWarning() << "Item" << i << "not found"; - QTRY_VERIFY(item); - QTRY_VERIFY(item->y() == i*30); - } - - listview->setSpacing(0); - - // Confirm items positioned correctly - QTRY_VERIFY(findItems(contentItem, "wrapper").count() >= 16); - for (int i = 0; i < 16; ++i) { - QQuickItem *item = findItem(contentItem, "wrapper", i); - if (!item) qWarning() << "Item" << i << "not found"; - QTRY_VERIFY(item); - QTRY_COMPARE(item->y(), i*20.0); - } - - delete canvas; - delete testObject; -} - -template -void tst_QQuickListView::sections(const QUrl &source) -{ - QQuickView *canvas = createView(); - - T model; - for (int i = 0; i < 30; i++) - model.addItem("Item" + QString::number(i), QString::number(i/5)); - - QDeclarativeContext *ctxt = canvas->rootContext(); - ctxt->setContextProperty("testModel", &model); - - canvas->setSource(source); - canvas->show(); - qApp->processEvents(); - - QQuickListView *listview = findItem(canvas->rootObject(), "list"); - QTRY_VERIFY(listview != 0); - - QQuickItem *contentItem = listview->contentItem(); - QTRY_VERIFY(contentItem != 0); - - QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false); - - // Confirm items positioned correctly - int itemCount = findItems(contentItem, "wrapper").count(); - for (int i = 0; i < model.count() && i < itemCount; ++i) { - QQuickItem *item = findItem(contentItem, "wrapper", i); - QTRY_VERIFY(item); - QTRY_COMPARE(item->y(), qreal(i*20 + ((i+4)/5) * 20)); - QQuickText *next = findItem(item, "nextSection"); - QCOMPARE(next->text().toInt(), (i+1)/5); - } - - QSignalSpy currentSectionChangedSpy(listview, SIGNAL(currentSectionChanged())); - - // Remove section boundary - model.removeItem(5); - QTRY_COMPARE(listview->count(), model.count()); - - // New section header created - QQuickItem *item = findItem(contentItem, "wrapper", 5); - QTRY_VERIFY(item); - QTRY_COMPARE(item->height(), 40.0); - - model.insertItem(3, "New Item", "0"); - QTRY_COMPARE(listview->count(), model.count()); - - // Section header moved - item = findItem(contentItem, "wrapper", 5); - QTRY_VERIFY(item); - QTRY_COMPARE(item->height(), 20.0); - - item = findItem(contentItem, "wrapper", 6); - QTRY_VERIFY(item); - QTRY_COMPARE(item->height(), 40.0); - - // insert item which will become a section header - model.insertItem(6, "Replace header", "1"); - QTRY_COMPARE(listview->count(), model.count()); - - item = findItem(contentItem, "wrapper", 6); - QTRY_VERIFY(item); - QTRY_COMPARE(item->height(), 40.0); - - item = findItem(contentItem, "wrapper", 7); - QTRY_VERIFY(item); - QTRY_COMPARE(item->height(), 20.0); - - QTRY_COMPARE(listview->currentSection(), QString("0")); - - listview->setContentY(140); - QTRY_COMPARE(listview->currentSection(), QString("1")); - - QTRY_COMPARE(currentSectionChangedSpy.count(), 1); - - listview->setContentY(20); - QTRY_COMPARE(listview->currentSection(), QString("0")); - - QTRY_COMPARE(currentSectionChangedSpy.count(), 2); - - item = findItem(contentItem, "wrapper", 1); - QTRY_VERIFY(item); - QTRY_COMPARE(item->height(), 20.0); - - // check that headers change when item changes - listview->setContentY(0); - QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false); - model.modifyItem(0, "changed", "2"); - QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false); - - item = findItem(contentItem, "wrapper", 1); - QTRY_VERIFY(item); - QTRY_COMPARE(item->height(), 40.0); - - delete canvas; -} - -void tst_QQuickListView::sectionsDelegate() -{ - QSKIP("QTBUG-24395"); - - QQuickView *canvas = createView(); - - QmlListModel model; - for (int i = 0; i < 30; i++) - model.addItem("Item" + QString::number(i), QString::number(i/5)); - - QDeclarativeContext *ctxt = canvas->rootContext(); - ctxt->setContextProperty("testModel", &model); - - canvas->setSource(testFileUrl("listview-sections_delegate.qml")); - canvas->show(); - qApp->processEvents(); - - QQuickListView *listview = findItem(canvas->rootObject(), "list"); - QTRY_VERIFY(listview != 0); - - QQuickItem *contentItem = listview->contentItem(); - QTRY_VERIFY(contentItem != 0); - - QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false); - - // Confirm items positioned correctly - int itemCount = findItems(contentItem, "wrapper").count(); - for (int i = 0; i < model.count() && i < itemCount; ++i) { - QQuickItem *item = findItem(contentItem, "wrapper", i); - QTRY_VERIFY(item); - QTRY_COMPARE(item->y(), qreal(i*20 + ((i+5)/5) * 20)); - QQuickText *next = findItem(item, "nextSection"); - QCOMPARE(next->text().toInt(), (i+1)/5); - } - - for (int i = 0; i < 3; ++i) { - QQuickItem *item = findItem(contentItem, "sect_" + QString::number(i)); - QVERIFY(item); - QTRY_COMPARE(item->y(), qreal(i*20*6)); - } - - // ensure section header is maintained in view - listview->setCurrentIndex(20); - QTRY_VERIFY(listview->contentY() >= 200.0); - listview->setCurrentIndex(0); - QTRY_COMPARE(listview->contentY(), 0.0); - - // change section - model.modifyItem(0, "One", "aaa"); - model.modifyItem(1, "Two", "aaa"); - model.modifyItem(2, "Three", "aaa"); - model.modifyItem(3, "Four", "aaa"); - model.modifyItem(4, "Five", "aaa"); - QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false); - - for (int i = 0; i < 3; ++i) { - QQuickItem *item = findItem(contentItem, - "sect_" + (i == 0 ? QString("aaa") : QString::number(i))); - QVERIFY(item); - QTRY_COMPARE(item->y(), qreal(i*20*6)); - } - - // remove section boundary - model.removeItem(5); - QTRY_COMPARE(listview->count(), model.count()); - for (int i = 0; i < 3; ++i) { - QQuickItem *item = findItem(contentItem, - "sect_" + (i == 0 ? QString("aaa") : QString::number(i))); - QVERIFY(item); - } - - // QTBUG-17606 - QList items = findItems(contentItem, "sect_1"); - QCOMPARE(items.count(), 1); - - // QTBUG-17759 - model.modifyItem(0, "One", "aaa"); - model.modifyItem(1, "One", "aaa"); - model.modifyItem(2, "One", "aaa"); - model.modifyItem(3, "Four", "aaa"); - model.modifyItem(4, "Four", "aaa"); - model.modifyItem(5, "Four", "aaa"); - model.modifyItem(6, "Five", "aaa"); - model.modifyItem(7, "Five", "aaa"); - model.modifyItem(8, "Five", "aaa"); - model.modifyItem(9, "Two", "aaa"); - model.modifyItem(10, "Two", "aaa"); - model.modifyItem(11, "Two", "aaa"); - QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false); - QTRY_COMPARE(findItems(contentItem, "sect_aaa").count(), 1); - canvas->rootObject()->setProperty("sectionProperty", "name"); - // ensure view has settled. - QTRY_COMPARE(findItems(contentItem, "sect_Four").count(), 1); - for (int i = 0; i < 4; ++i) { - QQuickItem *item = findItem(contentItem, - "sect_" + model.name(i*3)); - QVERIFY(item); - QTRY_COMPARE(item->y(), qreal(i*20*4)); - } - - // QTBUG-17769 - model.removeItems(10, 20); - // ensure view has settled. - QTRY_COMPARE(findItems(contentItem, "wrapper").count(), 10); - // Drag view up beyond bounds - QTest::mousePress(canvas, Qt::LeftButton, 0, QPoint(20,20)); - { - QMouseEvent mv(QEvent::MouseMove, QPoint(20,0), Qt::LeftButton, Qt::LeftButton,Qt::NoModifier); - QGuiApplication::sendEvent(canvas, &mv); - } - { - QMouseEvent mv(QEvent::MouseMove, QPoint(20,-50), Qt::LeftButton, Qt::LeftButton,Qt::NoModifier); - QGuiApplication::sendEvent(canvas, &mv); - } - { - QMouseEvent mv(QEvent::MouseMove, QPoint(20,-200), Qt::LeftButton, Qt::LeftButton,Qt::NoModifier); - QGuiApplication::sendEvent(canvas, &mv); - } - QTest::mouseRelease(canvas, Qt::LeftButton, 0, QPoint(20,-200)); - // view should settle back at 0 - QTRY_COMPARE(listview->contentY(), 0.0); - - delete canvas; -} - -void tst_QQuickListView::sectionsPositioning() -{ - QQuickView *canvas = createView(); - - QmlListModel model; - for (int i = 0; i < 30; i++) - model.addItem("Item" + QString::number(i), QString::number(i/5)); - - QDeclarativeContext *ctxt = canvas->rootContext(); - ctxt->setContextProperty("testModel", &model); - - canvas->setSource(testFileUrl("listview-sections_delegate.qml")); - canvas->show(); - qApp->processEvents(); - canvas->rootObject()->setProperty("sectionPositioning", QVariant(int(QQuickViewSection::InlineLabels | QQuickViewSection::CurrentLabelAtStart | QQuickViewSection::NextLabelAtEnd))); - - QQuickListView *listview = findItem(canvas->rootObject(), "list"); - QTRY_VERIFY(listview != 0); - QQuickItem *contentItem = listview->contentItem(); - QTRY_VERIFY(contentItem != 0); - QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false); - - for (int i = 0; i < 3; ++i) { - QQuickItem *item = findItem(contentItem, "sect_" + QString::number(i)); - QVERIFY(item); - QTRY_COMPARE(item->y(), qreal(i*20*6)); - } - - QQuickItem *topItem = findVisibleChild(contentItem, "sect_0"); // section header - QVERIFY(topItem); - QCOMPARE(topItem->y(), 0.); - - QQuickItem *bottomItem = findVisibleChild(contentItem, "sect_3"); // section footer - QVERIFY(bottomItem); - QCOMPARE(bottomItem->y(), 300.); - - // move down a little and check that section header is at top - listview->setContentY(10); - QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false); - QCOMPARE(topItem->y(), 0.); - - // push the top header up - listview->setContentY(110); - QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false); - topItem = findVisibleChild(contentItem, "sect_0"); // section header - QVERIFY(topItem); - QCOMPARE(topItem->y(), 100.); - - QQuickItem *item = findVisibleChild(contentItem, "sect_1"); - QVERIFY(item); - QCOMPARE(item->y(), 120.); - - bottomItem = findVisibleChild(contentItem, "sect_4"); // section footer - QVERIFY(bottomItem); - QCOMPARE(bottomItem->y(), 410.); - - // Move past section 0 - listview->setContentY(120); - QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false); - topItem = findVisibleChild(contentItem, "sect_0"); // section header - QVERIFY(!topItem); - - // Push section footer down - listview->setContentY(70); - QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false); - bottomItem = findVisibleChild(contentItem, "sect_4"); // section footer - QVERIFY(bottomItem); - QCOMPARE(bottomItem->y(), 380.); - - // Change current section - listview->setContentY(10); - model.modifyItem(0, "One", "aaa"); - model.modifyItem(1, "Two", "aaa"); - model.modifyItem(2, "Three", "aaa"); - model.modifyItem(3, "Four", "aaa"); - model.modifyItem(4, "Five", "aaa"); - QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false); - - QTRY_COMPARE(listview->currentSection(), QString("aaa")); - - for (int i = 0; i < 3; ++i) { - QQuickItem *item = findItem(contentItem, - "sect_" + (i == 0 ? QString("aaa") : QString::number(i))); - QVERIFY(item); - QTRY_COMPARE(item->y(), qreal(i*20*6)); - } - - QTRY_VERIFY(topItem = findVisibleChild(contentItem, "sect_aaa")); // section header - QCOMPARE(topItem->y(), 10.); - - // remove section boundary - listview->setContentY(120); - QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false); - model.removeItem(5); - QTRY_COMPARE(listview->count(), model.count()); - for (int i = 0; i < 3; ++i) { - QQuickItem *item = findItem(contentItem, - "sect_" + (i == 0 ? QString("aaa") : QString::number(i))); - QVERIFY(item); - QTRY_COMPARE(item->y(), qreal(i*20*6)); - } - - QVERIFY(topItem = findVisibleChild(contentItem, "sect_1")); - QTRY_COMPARE(topItem->y(), 120.); - - // Change the next section - listview->setContentY(0); - QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false); - bottomItem = findVisibleChild(contentItem, "sect_3"); // section footer - QVERIFY(bottomItem); - QTRY_COMPARE(bottomItem->y(), 300.); - - model.modifyItem(14, "New", "new"); - QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false); - - QTRY_VERIFY(bottomItem = findVisibleChild(contentItem, "sect_new")); // section footer - QTRY_COMPARE(bottomItem->y(), 300.); - - // Turn sticky footer off - listview->setContentY(20); - QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false); - canvas->rootObject()->setProperty("sectionPositioning", QVariant(int(QQuickViewSection::InlineLabels | QQuickViewSection::CurrentLabelAtStart))); - QTRY_VERIFY(item = findVisibleChild(contentItem, "sect_new")); // inline label restored - QCOMPARE(item->y(), 340.); - - // Turn sticky header off - listview->setContentY(30); - QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false); - canvas->rootObject()->setProperty("sectionPositioning", QVariant(int(QQuickViewSection::InlineLabels))); - QTRY_VERIFY(item = findVisibleChild(contentItem, "sect_aaa")); // inline label restored - QCOMPARE(item->y(), 0.); - - delete canvas; -} - -void tst_QQuickListView::currentIndex_delayedItemCreation() -{ - QFETCH(bool, setCurrentToZero); - - QQuickView *canvas = createView(); - - // test currentIndexChanged() is emitted even if currentIndex = 0 on start up - // (since the currentItem will have changed and that shares the same index) - canvas->rootContext()->setContextProperty("setCurrentToZero", setCurrentToZero); - - canvas->setSource(testFileUrl("fillModelOnComponentCompleted.qml")); - qApp->processEvents(); - - QQuickListView *listview = findItem(canvas->rootObject(), "list"); - QTRY_VERIFY(listview != 0); - QQuickItem *contentItem = listview->contentItem(); - QTRY_VERIFY(contentItem != 0); - - QSignalSpy spy(listview, SIGNAL(currentItemChanged())); - QCOMPARE(listview->currentIndex(), 0); - QTRY_COMPARE(spy.count(), 1); - - delete canvas; -} - -void tst_QQuickListView::currentIndex_delayedItemCreation_data() -{ - QTest::addColumn("setCurrentToZero"); - - QTest::newRow("set to 0") << true; - QTest::newRow("don't set to 0") << false; -} - -void tst_QQuickListView::currentIndex() -{ - QmlListModel model; - for (int i = 0; i < 30; i++) - model.addItem("Item" + QString::number(i), QString::number(i)); - - QQuickView *canvas = new QQuickView(0); - canvas->setGeometry(0,0,240,320); - - QDeclarativeContext *ctxt = canvas->rootContext(); - ctxt->setContextProperty("testModel", &model); - ctxt->setContextProperty("testWrap", QVariant(false)); - - QString filename(testFile("listview-initCurrent.qml")); - canvas->setSource(QUrl::fromLocalFile(filename)); - canvas->show(); - qApp->processEvents(); - - QQuickListView *listview = findItem(canvas->rootObject(), "list"); - QTRY_VERIFY(listview != 0); - QQuickItem *contentItem = listview->contentItem(); - QTRY_VERIFY(contentItem != 0); - QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false); - - // current item should be 20th item at startup - // and current item should be in view - QCOMPARE(listview->currentIndex(), 20); - QCOMPARE(listview->contentY(), 100.0); - QCOMPARE(listview->currentItem(), findItem(contentItem, "wrapper", 20)); - QCOMPARE(listview->highlightItem()->y(), listview->currentItem()->y()); - - // no wrap - listview->setCurrentIndex(0); - QCOMPARE(listview->currentIndex(), 0); - // confirm that the velocity is updated - QTRY_VERIFY(listview->verticalVelocity() != 0.0); - - listview->incrementCurrentIndex(); - QCOMPARE(listview->currentIndex(), 1); - listview->decrementCurrentIndex(); - QCOMPARE(listview->currentIndex(), 0); - - listview->decrementCurrentIndex(); - QCOMPARE(listview->currentIndex(), 0); - - // with wrap - ctxt->setContextProperty("testWrap", QVariant(true)); - QVERIFY(listview->isWrapEnabled()); - - listview->decrementCurrentIndex(); - QCOMPARE(listview->currentIndex(), model.count()-1); - - QTRY_COMPARE(listview->contentY(), 280.0); - - listview->incrementCurrentIndex(); - QCOMPARE(listview->currentIndex(), 0); - - QTRY_COMPARE(listview->contentY(), 0.0); - - - // footer should become visible if it is out of view, and then current index is set to count-1 - canvas->rootObject()->setProperty("showFooter", true); - QTRY_VERIFY(listview->footerItem()); - listview->setCurrentIndex(model.count()-2); - QTRY_VERIFY(listview->footerItem()->y() > listview->contentY() + listview->height()); - listview->setCurrentIndex(model.count()-1); - QTRY_COMPARE(listview->contentY() + listview->height(), (20.0 * model.count()) + listview->footerItem()->height()); - canvas->rootObject()->setProperty("showFooter", false); - - // header should become visible if it is out of view, and then current index is set to 0 - canvas->rootObject()->setProperty("showHeader", true); - QTRY_VERIFY(listview->headerItem()); - listview->setCurrentIndex(1); - QTRY_VERIFY(listview->headerItem()->y() + listview->headerItem()->height() < listview->contentY()); - listview->setCurrentIndex(0); - QTRY_COMPARE(listview->contentY(), -listview->headerItem()->height()); - canvas->rootObject()->setProperty("showHeader", false); - - - // Test keys - canvas->show(); - canvas->requestActivateWindow(); - QTest::qWaitForWindowShown(canvas); - QTRY_VERIFY(qGuiApp->focusWindow() == canvas); - - listview->setCurrentIndex(0); - - QTest::keyClick(canvas, Qt::Key_Down); - QCOMPARE(listview->currentIndex(), 1); - - QTest::keyClick(canvas, Qt::Key_Up); - QCOMPARE(listview->currentIndex(), 0); - - // hold down Key_Down - for (int i=0; icurrentIndex(), i+1); - } - QTest::keyRelease(canvas, Qt::Key_Down); - QTRY_COMPARE(listview->currentIndex(), model.count()-1); - QTRY_COMPARE(listview->contentY(), 280.0); - - // hold down Key_Up - for (int i=model.count()-1; i > 0; i--) { - QTest::simulateEvent(canvas, true, Qt::Key_Up, Qt::NoModifier, "", true); - QTRY_COMPARE(listview->currentIndex(), i-1); - } - QTest::keyRelease(canvas, Qt::Key_Up); - QTRY_COMPARE(listview->currentIndex(), 0); - QTRY_COMPARE(listview->contentY(), 0.0); - - - // turn off auto highlight - listview->setHighlightFollowsCurrentItem(false); - QVERIFY(listview->highlightFollowsCurrentItem() == false); - - QVERIFY(listview->highlightItem()); - qreal hlPos = listview->highlightItem()->y(); - - listview->setCurrentIndex(4); - QTRY_COMPARE(listview->highlightItem()->y(), hlPos); - - // insert item before currentIndex - listview->setCurrentIndex(28); - model.insertItem(0, "Foo", "1111"); - QTRY_COMPARE(canvas->rootObject()->property("current").toInt(), 29); - - // check removing highlight by setting currentIndex to -1; - listview->setCurrentIndex(-1); - - QCOMPARE(listview->currentIndex(), -1); - QVERIFY(!listview->highlightItem()); - QVERIFY(!listview->currentItem()); - - delete canvas; -} - -void tst_QQuickListView::noCurrentIndex() -{ - QmlListModel model; - for (int i = 0; i < 30; i++) - model.addItem("Item" + QString::number(i), QString::number(i)); - - QQuickView *canvas = new QQuickView(0); - canvas->setGeometry(0,0,240,320); - - QDeclarativeContext *ctxt = canvas->rootContext(); - ctxt->setContextProperty("testModel", &model); - - QString filename(testFile("listview-noCurrent.qml")); - canvas->setSource(QUrl::fromLocalFile(filename)); - canvas->show(); - qApp->processEvents(); - - QQuickListView *listview = findItem(canvas->rootObject(), "list"); - QTRY_VERIFY(listview != 0); - QQuickItem *contentItem = listview->contentItem(); - QTRY_VERIFY(contentItem != 0); - QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false); - - // current index should be -1 at startup - // and we should not have a currentItem or highlightItem - QCOMPARE(listview->currentIndex(), -1); - QCOMPARE(listview->contentY(), 0.0); - QVERIFY(!listview->highlightItem()); - QVERIFY(!listview->currentItem()); - - listview->setCurrentIndex(2); - QCOMPARE(listview->currentIndex(), 2); - QVERIFY(listview->highlightItem()); - QVERIFY(listview->currentItem()); - - delete canvas; -} - -void tst_QQuickListView::itemList() -{ - QQuickView *canvas = createView(); - canvas->setSource(testFileUrl("itemlist.qml")); - canvas->show(); - qApp->processEvents(); - - QQuickListView *listview = findItem(canvas->rootObject(), "view"); - QTRY_VERIFY(listview != 0); - - QQuickItem *contentItem = listview->contentItem(); - QTRY_VERIFY(contentItem != 0); - - QQuickVisualItemModel *model = canvas->rootObject()->findChild("itemModel"); - QTRY_VERIFY(model != 0); - - QTRY_VERIFY(model->count() == 3); - QTRY_COMPARE(listview->currentIndex(), 0); - - QQuickItem *item = findItem(contentItem, "item1"); - QTRY_VERIFY(item); - QTRY_COMPARE(item->x(), 0.0); - QCOMPARE(item->height(), listview->height()); - - QQuickText *text = findItem(contentItem, "text1"); - QTRY_VERIFY(text); - QTRY_COMPARE(text->text(), QLatin1String("index: 0")); - - listview->setCurrentIndex(2); - - item = findItem(contentItem, "item3"); - QTRY_VERIFY(item); - QTRY_COMPARE(item->x(), 480.0); - - text = findItem(contentItem, "text3"); - QTRY_VERIFY(text); - QTRY_COMPARE(text->text(), QLatin1String("index: 2")); - - delete canvas; -} - -void tst_QQuickListView::cacheBuffer() -{ - QQuickView *canvas = createView(); - - QmlListModel model; - for (int i = 0; i < 90; i++) - model.addItem("Item" + QString::number(i), ""); - - QDeclarativeContext *ctxt = canvas->rootContext(); - ctxt->setContextProperty("testModel", &model); - - TestObject *testObject = new TestObject; - ctxt->setContextProperty("testObject", testObject); - - canvas->setSource(testFileUrl("listviewtest.qml")); - canvas->show(); - qApp->processEvents(); - - QQuickListView *listview = findItem(canvas->rootObject(), "list"); - QTRY_VERIFY(listview != 0); - - QQuickItem *contentItem = listview->contentItem(); - QTRY_VERIFY(contentItem != 0); - QTRY_VERIFY(listview->delegate() != 0); - QTRY_VERIFY(listview->model() != 0); - QTRY_VERIFY(listview->highlight() != 0); - - // Confirm items positioned correctly - int itemCount = findItems(contentItem, "wrapper").count(); - for (int i = 0; i < model.count() && i < itemCount; ++i) { - QQuickItem *item = findItem(contentItem, "wrapper", i); - if (!item) qWarning() << "Item" << i << "not found"; - QTRY_VERIFY(item); - QTRY_VERIFY(item->y() == i*20); - } - - QDeclarativeIncubationController controller; - canvas->engine()->setIncubationController(&controller); - - testObject->setCacheBuffer(200); - QTRY_VERIFY(listview->cacheBuffer() == 200); - - // items will be created one at a time - for (int i = itemCount; i < qMin(itemCount+10,model.count()); ++i) { - QVERIFY(findItem(listview, "wrapper", i) == 0); - QQuickItem *item = 0; - while (!item) { - bool b = false; - controller.incubateWhile(&b); - item = findItem(listview, "wrapper", i); - } - } - - { - bool b = true; - controller.incubateWhile(&b); - } - - int newItemCount = 0; - newItemCount = findItems(contentItem, "wrapper").count(); - - // Confirm items positioned correctly - for (int i = 0; i < model.count() && i < newItemCount; ++i) { - QQuickItem *item = findItem(contentItem, "wrapper", i); - if (!item) qWarning() << "Item" << i << "not found"; - QTRY_VERIFY(item); - QTRY_VERIFY(item->y() == i*20); - } - - // move view and confirm items in view are visible immediately and outside are created async - listview->setContentY(300); - - for (int i = 15; i < 32; ++i) { - QQuickItem *item = findItem(contentItem, "wrapper", i); - if (!item) qWarning() << "Item" << i << "not found"; - QVERIFY(item); - QVERIFY(item->y() == i*20); - } - - QVERIFY(findItem(listview, "wrapper", 32) == 0); - - // ensure buffered items are created - for (int i = 32; i < qMin(41,model.count()); ++i) { - QQuickItem *item = 0; - while (!item) { - qGuiApp->processEvents(); // allow refill to happen - bool b = false; - controller.incubateWhile(&b); - item = findItem(listview, "wrapper", i); - } - } - - { - bool b = true; - controller.incubateWhile(&b); - } - - delete canvas; - delete testObject; -} - -void tst_QQuickListView::positionViewAtIndex() -{ - QQuickView *canvas = createView(); - - QmlListModel model; - for (int i = 0; i < 40; i++) - model.addItem("Item" + QString::number(i), ""); - - QDeclarativeContext *ctxt = canvas->rootContext(); - ctxt->setContextProperty("testModel", &model); - - TestObject *testObject = new TestObject; - ctxt->setContextProperty("testObject", testObject); - canvas->show(); - canvas->setSource(testFileUrl("listviewtest.qml")); - qApp->processEvents(); - - QQuickListView *listview = findItem(canvas->rootObject(), "list"); - QTRY_VERIFY(listview != 0); - QQuickItem *contentItem = listview->contentItem(); - QTRY_VERIFY(contentItem != 0); - QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false); - - // Confirm items positioned correctly - int itemCount = findItems(contentItem, "wrapper").count(); - for (int i = 0; i < model.count() && i < itemCount; ++i) { - QQuickItem *item = findItem(contentItem, "wrapper", i); - if (!item) qWarning() << "Item" << i << "not found"; - QTRY_VERIFY(item); - QTRY_COMPARE(item->y(), i*20.); - } - - // Position on a currently visible item - listview->positionViewAtIndex(3, QQuickListView::Beginning); - QTRY_COMPARE(listview->contentY(), 60.); - - // Confirm items positioned correctly - itemCount = findItems(contentItem, "wrapper").count(); - for (int i = 3; i < model.count() && i < itemCount-3-1; ++i) { - QQuickItem *item = findItem(contentItem, "wrapper", i); - if (!item) qWarning() << "Item" << i << "not found"; - QTRY_VERIFY(item); - QTRY_COMPARE(item->y(), i*20.); - } - - // Position on an item beyond the visible items - listview->positionViewAtIndex(22, QQuickListView::Beginning); - QTRY_COMPARE(listview->contentY(), 440.); - - // Confirm items positioned correctly - itemCount = findItems(contentItem, "wrapper").count(); - for (int i = 22; i < model.count() && i < itemCount-22-1; ++i) { - QQuickItem *item = findItem(contentItem, "wrapper", i); - if (!item) qWarning() << "Item" << i << "not found"; - QTRY_VERIFY(item); - QTRY_COMPARE(item->y(), i*20.); - } - - // Position on an item that would leave empty space if positioned at the top - listview->positionViewAtIndex(28, QQuickListView::Beginning); - QTRY_COMPARE(listview->contentY(), 480.); - - // Confirm items positioned correctly - itemCount = findItems(contentItem, "wrapper").count(); - for (int i = 24; i < model.count() && i < itemCount-24-1; ++i) { - QQuickItem *item = findItem(contentItem, "wrapper", i); - if (!item) qWarning() << "Item" << i << "not found"; - QTRY_VERIFY(item); - QTRY_COMPARE(item->y(), i*20.); - } - - // Position at the beginning again - listview->positionViewAtIndex(0, QQuickListView::Beginning); - QTRY_COMPARE(listview->contentY(), 0.); - - // Confirm items positioned correctly - itemCount = findItems(contentItem, "wrapper").count(); - for (int i = 0; i < model.count() && i < itemCount-1; ++i) { - QQuickItem *item = findItem(contentItem, "wrapper", i); - if (!item) qWarning() << "Item" << i << "not found"; - QTRY_VERIFY(item); - QTRY_COMPARE(item->y(), i*20.); - } - - // Position at End using last index - listview->positionViewAtIndex(model.count()-1, QQuickListView::End); - QTRY_COMPARE(listview->contentY(), 480.); - - // Confirm items positioned correctly - itemCount = findItems(contentItem, "wrapper").count(); - for (int i = 24; i < model.count(); ++i) { - QQuickItem *item = findItem(contentItem, "wrapper", i); - if (!item) qWarning() << "Item" << i << "not found"; - QTRY_VERIFY(item); - QTRY_COMPARE(item->y(), i*20.); - } - - // Position at End - listview->positionViewAtIndex(20, QQuickListView::End); - QTRY_COMPARE(listview->contentY(), 100.); - - // Position in Center - listview->positionViewAtIndex(15, QQuickListView::Center); - QTRY_COMPARE(listview->contentY(), 150.); - - // Ensure at least partially visible - listview->positionViewAtIndex(15, QQuickListView::Visible); - QTRY_COMPARE(listview->contentY(), 150.); - - listview->setContentY(302); - listview->positionViewAtIndex(15, QQuickListView::Visible); - QTRY_COMPARE(listview->contentY(), 302.); - - listview->setContentY(320); - listview->positionViewAtIndex(15, QQuickListView::Visible); - QTRY_COMPARE(listview->contentY(), 300.); - - listview->setContentY(85); - listview->positionViewAtIndex(20, QQuickListView::Visible); - QTRY_COMPARE(listview->contentY(), 85.); - - listview->setContentY(75); - listview->positionViewAtIndex(20, QQuickListView::Visible); - QTRY_COMPARE(listview->contentY(), 100.); - - // Ensure completely visible - listview->setContentY(120); - listview->positionViewAtIndex(20, QQuickListView::Contain); - QTRY_COMPARE(listview->contentY(), 120.); - - listview->setContentY(302); - listview->positionViewAtIndex(15, QQuickListView::Contain); - QTRY_COMPARE(listview->contentY(), 300.); - - listview->setContentY(85); - listview->positionViewAtIndex(20, QQuickListView::Contain); - QTRY_COMPARE(listview->contentY(), 100.); - - // positionAtBeginnging - listview->positionViewAtBeginning(); - QTRY_COMPARE(listview->contentY(), 0.); - - listview->setContentY(80); - canvas->rootObject()->setProperty("showHeader", true); - listview->positionViewAtBeginning(); - QTRY_COMPARE(listview->contentY(), -30.); - - // positionAtEnd - listview->positionViewAtEnd(); - QTRY_COMPARE(listview->contentY(), 480.); // 40*20 - 320 - - listview->setContentY(80); - canvas->rootObject()->setProperty("showFooter", true); - listview->positionViewAtEnd(); - QTRY_COMPARE(listview->contentY(), 510.); - - // set current item to outside visible view, position at beginning - // and ensure highlight moves to current item - listview->setCurrentIndex(1); - listview->positionViewAtBeginning(); - QTRY_COMPARE(listview->contentY(), -30.); - QVERIFY(listview->highlightItem()); - QCOMPARE(listview->highlightItem()->y(), 20.); - - delete canvas; - delete testObject; -} - -void tst_QQuickListView::resetModel() -{ - QQuickView *canvas = createView(); - - QStringList strings; - strings << "one" << "two" << "three"; - QStringListModel model(strings); - - QDeclarativeContext *ctxt = canvas->rootContext(); - ctxt->setContextProperty("testModel", &model); - - canvas->setSource(testFileUrl("displaylist.qml")); - canvas->show(); - qApp->processEvents(); - - QQuickListView *listview = findItem(canvas->rootObject(), "list"); - QTRY_VERIFY(listview != 0); - QQuickItem *contentItem = listview->contentItem(); - QTRY_VERIFY(contentItem != 0); - QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false); - - QTRY_COMPARE(listview->count(), model.rowCount()); - - for (int i = 0; i < model.rowCount(); ++i) { - QQuickText *display = findItem(contentItem, "displayText", i); - QTRY_VERIFY(display != 0); - QTRY_COMPARE(display->text(), strings.at(i)); - } - - strings.clear(); - strings << "four" << "five" << "six" << "seven"; - model.setStringList(strings); - - QTRY_COMPARE(listview->count(), model.rowCount()); - - for (int i = 0; i < model.rowCount(); ++i) { - QQuickText *display = findItem(contentItem, "displayText", i); - QTRY_VERIFY(display != 0); - QTRY_COMPARE(display->text(), strings.at(i)); - } - - delete canvas; -} - -void tst_QQuickListView::propertyChanges() -{ - QQuickView *canvas = createView(); - QTRY_VERIFY(canvas); - canvas->setSource(testFileUrl("propertychangestest.qml")); - - QQuickListView *listView = canvas->rootObject()->findChild("listView"); - QTRY_VERIFY(listView); - - QSignalSpy highlightFollowsCurrentItemSpy(listView, SIGNAL(highlightFollowsCurrentItemChanged())); - QSignalSpy preferredHighlightBeginSpy(listView, SIGNAL(preferredHighlightBeginChanged())); - QSignalSpy preferredHighlightEndSpy(listView, SIGNAL(preferredHighlightEndChanged())); - QSignalSpy highlightRangeModeSpy(listView, SIGNAL(highlightRangeModeChanged())); - QSignalSpy keyNavigationWrapsSpy(listView, SIGNAL(keyNavigationWrapsChanged())); - QSignalSpy cacheBufferSpy(listView, SIGNAL(cacheBufferChanged())); - QSignalSpy snapModeSpy(listView, SIGNAL(snapModeChanged())); - - QTRY_COMPARE(listView->highlightFollowsCurrentItem(), true); - QTRY_COMPARE(listView->preferredHighlightBegin(), 0.0); - QTRY_COMPARE(listView->preferredHighlightEnd(), 0.0); - QTRY_COMPARE(listView->highlightRangeMode(), QQuickListView::ApplyRange); - QTRY_COMPARE(listView->isWrapEnabled(), true); - QTRY_COMPARE(listView->cacheBuffer(), 10); - QTRY_COMPARE(listView->snapMode(), QQuickListView::SnapToItem); - - listView->setHighlightFollowsCurrentItem(false); - listView->setPreferredHighlightBegin(1.0); - listView->setPreferredHighlightEnd(1.0); - listView->setHighlightRangeMode(QQuickListView::StrictlyEnforceRange); - listView->setWrapEnabled(false); - listView->setCacheBuffer(3); - listView->setSnapMode(QQuickListView::SnapOneItem); - - QTRY_COMPARE(listView->highlightFollowsCurrentItem(), false); - QTRY_COMPARE(listView->preferredHighlightBegin(), 1.0); - QTRY_COMPARE(listView->preferredHighlightEnd(), 1.0); - QTRY_COMPARE(listView->highlightRangeMode(), QQuickListView::StrictlyEnforceRange); - QTRY_COMPARE(listView->isWrapEnabled(), false); - QTRY_COMPARE(listView->cacheBuffer(), 3); - QTRY_COMPARE(listView->snapMode(), QQuickListView::SnapOneItem); - - QTRY_COMPARE(highlightFollowsCurrentItemSpy.count(),1); - QTRY_COMPARE(preferredHighlightBeginSpy.count(),1); - QTRY_COMPARE(preferredHighlightEndSpy.count(),1); - QTRY_COMPARE(highlightRangeModeSpy.count(),1); - QTRY_COMPARE(keyNavigationWrapsSpy.count(),1); - QTRY_COMPARE(cacheBufferSpy.count(),1); - QTRY_COMPARE(snapModeSpy.count(),1); - - listView->setHighlightFollowsCurrentItem(false); - listView->setPreferredHighlightBegin(1.0); - listView->setPreferredHighlightEnd(1.0); - listView->setHighlightRangeMode(QQuickListView::StrictlyEnforceRange); - listView->setWrapEnabled(false); - listView->setCacheBuffer(3); - listView->setSnapMode(QQuickListView::SnapOneItem); - - QTRY_COMPARE(highlightFollowsCurrentItemSpy.count(),1); - QTRY_COMPARE(preferredHighlightBeginSpy.count(),1); - QTRY_COMPARE(preferredHighlightEndSpy.count(),1); - QTRY_COMPARE(highlightRangeModeSpy.count(),1); - QTRY_COMPARE(keyNavigationWrapsSpy.count(),1); - QTRY_COMPARE(cacheBufferSpy.count(),1); - QTRY_COMPARE(snapModeSpy.count(),1); - - delete canvas; -} - -void tst_QQuickListView::componentChanges() -{ - QQuickView *canvas = createView(); - QTRY_VERIFY(canvas); - canvas->setSource(testFileUrl("propertychangestest.qml")); - - QQuickListView *listView = canvas->rootObject()->findChild("listView"); - QTRY_VERIFY(listView); - - QDeclarativeComponent component(canvas->engine()); - component.setData("import QtQuick 2.0; Rectangle { color: \"blue\"; }", QUrl::fromLocalFile("")); - - QDeclarativeComponent delegateComponent(canvas->engine()); - delegateComponent.setData("import QtQuick 2.0; Text { text: 'Name: ' + name }", QUrl::fromLocalFile("")); - - QSignalSpy highlightSpy(listView, SIGNAL(highlightChanged())); - QSignalSpy delegateSpy(listView, SIGNAL(delegateChanged())); - QSignalSpy headerSpy(listView, SIGNAL(headerChanged())); - QSignalSpy footerSpy(listView, SIGNAL(footerChanged())); - - listView->setHighlight(&component); - listView->setHeader(&component); - listView->setFooter(&component); - listView->setDelegate(&delegateComponent); - - QTRY_COMPARE(listView->highlight(), &component); - QTRY_COMPARE(listView->header(), &component); - QTRY_COMPARE(listView->footer(), &component); - QTRY_COMPARE(listView->delegate(), &delegateComponent); - - QTRY_COMPARE(highlightSpy.count(),1); - QTRY_COMPARE(delegateSpy.count(),1); - QTRY_COMPARE(headerSpy.count(),1); - QTRY_COMPARE(footerSpy.count(),1); - - listView->setHighlight(&component); - listView->setHeader(&component); - listView->setFooter(&component); - listView->setDelegate(&delegateComponent); - - QTRY_COMPARE(highlightSpy.count(),1); - QTRY_COMPARE(delegateSpy.count(),1); - QTRY_COMPARE(headerSpy.count(),1); - QTRY_COMPARE(footerSpy.count(),1); - - delete canvas; -} - -void tst_QQuickListView::modelChanges() -{ - QQuickView *canvas = createView(); - QTRY_VERIFY(canvas); - canvas->setSource(testFileUrl("propertychangestest.qml")); - - QQuickListView *listView = canvas->rootObject()->findChild("listView"); - QTRY_VERIFY(listView); - - QDeclarativeListModel *alternateModel = canvas->rootObject()->findChild("alternateModel"); - QTRY_VERIFY(alternateModel); - QVariant modelVariant = QVariant::fromValue(alternateModel); - QSignalSpy modelSpy(listView, SIGNAL(modelChanged())); - - listView->setModel(modelVariant); - QTRY_COMPARE(listView->model(), modelVariant); - QTRY_COMPARE(modelSpy.count(),1); - - listView->setModel(modelVariant); - QTRY_COMPARE(modelSpy.count(),1); - - listView->setModel(QVariant()); - QTRY_COMPARE(modelSpy.count(),2); - - delete canvas; -} - -void tst_QQuickListView::QTBUG_9791() -{ - QQuickView *canvas = createView(); - - canvas->setSource(testFileUrl("strictlyenforcerange.qml")); - qApp->processEvents(); - - QQuickListView *listview = qobject_cast(canvas->rootObject()); - QTRY_VERIFY(listview != 0); - - QQuickItem *contentItem = listview->contentItem(); - QTRY_VERIFY(contentItem != 0); - QTRY_VERIFY(listview->delegate() != 0); - QTRY_VERIFY(listview->model() != 0); - - QMetaObject::invokeMethod(listview, "fillModel"); - qApp->processEvents(); - - // Confirm items positioned correctly - int itemCount = findItems(contentItem, "wrapper", false).count(); - QCOMPARE(itemCount, 3); - - for (int i = 0; i < itemCount; ++i) { - QQuickItem *item = findItem(contentItem, "wrapper", i); - if (!item) qWarning() << "Item" << i << "not found"; - QTRY_VERIFY(item); - QTRY_COMPARE(item->x(), i*300.0); - } - - // check that view is positioned correctly - QTRY_COMPARE(listview->contentX(), 590.0); - - delete canvas; -} - -void tst_QQuickListView::manualHighlight() -{ - QQuickView *canvas = new QQuickView(0); - canvas->setGeometry(0,0,240,320); - - QString filename(testFile("manual-highlight.qml")); - canvas->setSource(QUrl::fromLocalFile(filename)); - - qApp->processEvents(); - - QQuickListView *listview = findItem(canvas->rootObject(), "list"); - QTRY_VERIFY(listview != 0); - - QQuickItem *contentItem = listview->contentItem(); - QTRY_VERIFY(contentItem != 0); - - QTRY_COMPARE(listview->currentIndex(), 0); - QTRY_COMPARE(listview->currentItem(), findItem(contentItem, "wrapper", 0)); - QTRY_COMPARE(listview->highlightItem()->y() - 5, listview->currentItem()->y()); - - listview->setCurrentIndex(2); - - QTRY_COMPARE(listview->currentIndex(), 2); - QTRY_COMPARE(listview->currentItem(), findItem(contentItem, "wrapper", 2)); - QTRY_COMPARE(listview->highlightItem()->y() - 5, listview->currentItem()->y()); - - // QTBUG-15972 - listview->positionViewAtIndex(3, QQuickListView::Contain); - - QTRY_COMPARE(listview->currentIndex(), 2); - QTRY_COMPARE(listview->currentItem(), findItem(contentItem, "wrapper", 2)); - QTRY_COMPARE(listview->highlightItem()->y() - 5, listview->currentItem()->y()); - - delete canvas; -} - -void tst_QQuickListView::QTBUG_11105() -{ - QQuickView *canvas = createView(); - - QmlListModel model; - for (int i = 0; i < 30; i++) - model.addItem("Item" + QString::number(i), ""); - - QDeclarativeContext *ctxt = canvas->rootContext(); - ctxt->setContextProperty("testModel", &model); - - TestObject *testObject = new TestObject; - ctxt->setContextProperty("testObject", testObject); - - canvas->setSource(testFileUrl("listviewtest.qml")); - canvas->show(); - qApp->processEvents(); - - QQuickListView *listview = findItem(canvas->rootObject(), "list"); - QTRY_VERIFY(listview != 0); - QQuickItem *contentItem = listview->contentItem(); - QTRY_VERIFY(contentItem != 0); - QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false); - - // Confirm items positioned correctly - int itemCount = findItems(contentItem, "wrapper").count(); - for (int i = 0; i < model.count() && i < itemCount; ++i) { - QQuickItem *item = findItem(contentItem, "wrapper", i); - if (!item) qWarning() << "Item" << i << "not found"; - QTRY_VERIFY(item); - QTRY_VERIFY(item->y() == i*20); - } - - listview->positionViewAtIndex(20, QQuickListView::Beginning); - QCOMPARE(listview->contentY(), 280.); - - QmlListModel model2; - for (int i = 0; i < 5; i++) - model2.addItem("Item" + QString::number(i), ""); - - ctxt->setContextProperty("testModel", &model2); - - itemCount = findItems(contentItem, "wrapper").count(); - QCOMPARE(itemCount, 5); - - delete canvas; - delete testObject; -} - -void tst_QQuickListView::header() -{ - QFETCH(QQuickListView::Orientation, orientation); - QFETCH(Qt::LayoutDirection, layoutDirection); - QFETCH(QPointF, initialHeaderPos); - QFETCH(QPointF, firstDelegatePos); - QFETCH(QPointF, initialContentPos); - QFETCH(QPointF, changedHeaderPos); - QFETCH(QPointF, changedContentPos); - QFETCH(QPointF, resizeContentPos); - - QmlListModel model; - for (int i = 0; i < 30; i++) - model.addItem("Item" + QString::number(i), ""); - - QQuickView *canvas = createView(); - canvas->rootContext()->setContextProperty("testModel", &model); - canvas->rootContext()->setContextProperty("initialViewWidth", 240); - canvas->rootContext()->setContextProperty("initialViewHeight", 320); - canvas->setSource(testFileUrl("header.qml")); - canvas->show(); - qApp->processEvents(); - - QQuickListView *listview = findItem(canvas->rootObject(), "list"); - QTRY_VERIFY(listview != 0); - listview->setOrientation(orientation); - listview->setLayoutDirection(layoutDirection); - - QQuickItem *contentItem = listview->contentItem(); - QTRY_VERIFY(contentItem != 0); - - QQuickText *header = 0; - QTRY_VERIFY(header = findItem(contentItem, "header")); - QVERIFY(header == listview->headerItem()); - - QCOMPARE(header->width(), 100.); - QCOMPARE(header->height(), 30.); - QCOMPARE(header->pos(), initialHeaderPos); - QCOMPARE(QPointF(listview->contentX(), listview->contentY()), initialContentPos); - - QQuickItem *item = findItem(contentItem, "wrapper", 0); - QVERIFY(item); - QCOMPARE(item->pos(), firstDelegatePos); - - model.clear(); - QTRY_COMPARE(listview->count(), model.count()); - QCOMPARE(header->pos(), initialHeaderPos); // header should stay where it is - - for (int i = 0; i < 30; i++) - model.addItem("Item" + QString::number(i), ""); - - QSignalSpy headerItemSpy(listview, SIGNAL(headerItemChanged())); - QMetaObject::invokeMethod(canvas->rootObject(), "changeHeader"); - - QCOMPARE(headerItemSpy.count(), 1); - - header = findItem(contentItem, "header"); - QVERIFY(!header); - header = findItem(contentItem, "header2"); - QVERIFY(header); - - QVERIFY(header == listview->headerItem()); - - QCOMPARE(header->pos(), changedHeaderPos); - QCOMPARE(header->width(), 50.); - QCOMPARE(header->height(), 20.); - QTRY_COMPARE(QPointF(listview->contentX(), listview->contentY()), changedContentPos); - - item = findItem(contentItem, "wrapper", 0); - QVERIFY(item); - QCOMPARE(item->pos(), firstDelegatePos); - - delete canvas; - - - // QTBUG-21207 header should become visible if view resizes from initial empty size - - canvas = createView(); - canvas->rootContext()->setContextProperty("testModel", &model); - canvas->rootContext()->setContextProperty("initialViewWidth", 0.0); - canvas->rootContext()->setContextProperty("initialViewHeight", 0.0); - canvas->setSource(testFileUrl("header.qml")); - canvas->show(); - qApp->processEvents(); - - listview = findItem(canvas->rootObject(), "list"); - QTRY_VERIFY(listview != 0); - listview->setOrientation(orientation); - listview->setLayoutDirection(layoutDirection); - QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false); - - listview->setWidth(240); - listview->setHeight(320); - QTRY_COMPARE(listview->headerItem()->pos(), initialHeaderPos); - QCOMPARE(QPointF(listview->contentX(), listview->contentY()), initialContentPos); - - - delete canvas; -} - -void tst_QQuickListView::header_data() -{ - QTest::addColumn("orientation"); - QTest::addColumn("layoutDirection"); - QTest::addColumn("initialHeaderPos"); - QTest::addColumn("changedHeaderPos"); - QTest::addColumn("initialContentPos"); - QTest::addColumn("changedContentPos"); - QTest::addColumn("firstDelegatePos"); - QTest::addColumn("resizeContentPos"); - - // header1 = 100 x 30 - // header2 = 50 x 20 - // delegates = 240 x 20 - // view width = 240 - - // header above items, top left - QTest::newRow("vertical, left to right") << QQuickListView::Vertical << Qt::LeftToRight - << QPointF(0, -30) - << QPointF(0, -20) - << QPointF(0, -30) - << QPointF(0, -20) - << QPointF(0, 0) - << QPointF(0, -10); - - // header above items, top right - QTest::newRow("vertical, layout right to left") << QQuickListView::Vertical << Qt::RightToLeft - << QPointF(0, -30) - << QPointF(0, -20) - << QPointF(0, -30) - << QPointF(0, -20) - << QPointF(0, 0) - << QPointF(0, -10); - - // header to left of items - QTest::newRow("horizontal, layout left to right") << QQuickListView::Horizontal << Qt::LeftToRight - << QPointF(-100, 0) - << QPointF(-50, 0) - << QPointF(-100, 0) - << QPointF(-50, 0) - << QPointF(0, 0) - << QPointF(-40, 0); - - // header to right of items - QTest::newRow("horizontal, layout right to left") << QQuickListView::Horizontal << Qt::RightToLeft - << QPointF(0, 0) - << QPointF(0, 0) - << QPointF(-240 + 100, 0) - << QPointF(-240 + 50, 0) - << QPointF(-240, 0) - << QPointF(-240 + 40, 0); -} - -void tst_QQuickListView::header_delayItemCreation() -{ - QQuickView *canvas = createView(); - - QmlListModel model; - - canvas->rootContext()->setContextProperty("setCurrentToZero", QVariant(false)); - canvas->setSource(testFileUrl("fillModelOnComponentCompleted.qml")); - qApp->processEvents(); - - QQuickListView *listview = findItem(canvas->rootObject(), "list"); - QTRY_VERIFY(listview != 0); - - QQuickItem *contentItem = listview->contentItem(); - QTRY_VERIFY(contentItem != 0); - - QQuickText *header = findItem(contentItem, "header"); - QVERIFY(header); - QCOMPARE(header->y(), -header->height()); - - QCOMPARE(listview->contentY(), -header->height()); - - model.clear(); - QTRY_COMPARE(header->y(), -header->height()); - - delete canvas; -} - -void tst_QQuickListView::footer() -{ - QFETCH(QQuickListView::Orientation, orientation); - QFETCH(Qt::LayoutDirection, layoutDirection); - QFETCH(QPointF, initialFooterPos); - QFETCH(QPointF, firstDelegatePos); - QFETCH(QPointF, initialContentPos); - QFETCH(QPointF, changedFooterPos); - QFETCH(QPointF, changedContentPos); - QFETCH(QPointF, resizeContentPos); - - QQuickView *canvas = createView(); - - QmlListModel model; - for (int i = 0; i < 3; i++) - model.addItem("Item" + QString::number(i), ""); - - QDeclarativeContext *ctxt = canvas->rootContext(); - ctxt->setContextProperty("testModel", &model); - - canvas->setSource(testFileUrl("footer.qml")); - canvas->show(); - qApp->processEvents(); - - QQuickListView *listview = findItem(canvas->rootObject(), "list"); - QTRY_VERIFY(listview != 0); - listview->setOrientation(orientation); - listview->setLayoutDirection(layoutDirection); - QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false); - - QQuickItem *contentItem = listview->contentItem(); - QTRY_VERIFY(contentItem != 0); - - QQuickText *footer = findItem(contentItem, "footer"); - QVERIFY(footer); - - QVERIFY(footer == listview->footerItem()); - - QCOMPARE(footer->pos(), initialFooterPos); - QCOMPARE(footer->width(), 100.); - QCOMPARE(footer->height(), 30.); - QCOMPARE(QPointF(listview->contentX(), listview->contentY()), initialContentPos); - - QQuickItem *item = findItem(contentItem, "wrapper", 0); - QVERIFY(item); - QCOMPARE(item->pos(), firstDelegatePos); - - // remove one item - model.removeItem(1); - - if (orientation == QQuickListView::Vertical) { - QTRY_COMPARE(footer->y(), initialFooterPos.y() - 20); // delegate height = 20 - } else { - QTRY_COMPARE(footer->x(), layoutDirection == Qt::LeftToRight ? - initialFooterPos.x() - 40 : initialFooterPos.x() + 40); // delegate width = 40 - } - - // remove all items - model.clear(); - - QPointF posWhenNoItems(0, 0); - if (orientation == QQuickListView::Horizontal && layoutDirection == Qt::RightToLeft) - posWhenNoItems.setX(-100); - QTRY_COMPARE(footer->pos(), posWhenNoItems); - - // if header is present, it's at a negative pos, so the footer should not move - canvas->rootObject()->setProperty("showHeader", true); - QTRY_COMPARE(footer->pos(), posWhenNoItems); - canvas->rootObject()->setProperty("showHeader", false); - - // add 30 items - for (int i = 0; i < 30; i++) - model.addItem("Item" + QString::number(i), ""); - - QSignalSpy footerItemSpy(listview, SIGNAL(footerItemChanged())); - QMetaObject::invokeMethod(canvas->rootObject(), "changeFooter"); - - QCOMPARE(footerItemSpy.count(), 1); - - footer = findItem(contentItem, "footer"); - QVERIFY(!footer); - footer = findItem(contentItem, "footer2"); - QVERIFY(footer); - - QVERIFY(footer == listview->footerItem()); - - QCOMPARE(footer->pos(), changedFooterPos); - QCOMPARE(footer->width(), 50.); - QCOMPARE(footer->height(), 20.); - QTRY_COMPARE(QPointF(listview->contentX(), listview->contentY()), changedContentPos); - - item = findItem(contentItem, "wrapper", 0); - QVERIFY(item); - QCOMPARE(item->pos(), firstDelegatePos); - - listview->positionViewAtEnd(); - footer->setHeight(10); - footer->setWidth(40); - QTRY_COMPARE(QPointF(listview->contentX(), listview->contentY()), resizeContentPos); - - delete canvas; -} - -void tst_QQuickListView::footer_data() -{ - QTest::addColumn("orientation"); - QTest::addColumn("layoutDirection"); - QTest::addColumn("initialFooterPos"); - QTest::addColumn("changedFooterPos"); - QTest::addColumn("initialContentPos"); - QTest::addColumn("changedContentPos"); - QTest::addColumn("firstDelegatePos"); - QTest::addColumn("resizeContentPos"); - - // footer1 = 100 x 30 - // footer2 = 50 x 20 - // delegates = 40 x 20 - // view width = 240 - // view height = 320 - - // footer below items, bottom left - QTest::newRow("vertical, layout left to right") << QQuickListView::Vertical << Qt::LeftToRight - << QPointF(0, 3 * 20) - << QPointF(0, 30 * 20) // added 30 items - << QPointF(0, 0) - << QPointF(0, 0) - << QPointF(0, 0) - << QPointF(0, 30 * 20 - 320 + 10); - - // footer below items, bottom right - QTest::newRow("vertical, layout right to left") << QQuickListView::Vertical << Qt::RightToLeft - << QPointF(0, 3 * 20) - << QPointF(0, 30 * 20) - << QPointF(0, 0) - << QPointF(0, 0) - << QPointF(0, 0) - << QPointF(0, 30 * 20 - 320 + 10); - - // footer to right of items - QTest::newRow("horizontal, layout left to right") << QQuickListView::Horizontal << Qt::LeftToRight - << QPointF(40 * 3, 0) - << QPointF(40 * 30, 0) - << QPointF(0, 0) - << QPointF(0, 0) - << QPointF(0, 0) - << QPointF(40 * 30 - 240 + 40, 0); - - // footer to left of items - QTest::newRow("horizontal, layout right to left") << QQuickListView::Horizontal << Qt::RightToLeft - << QPointF(-(40 * 3) - 100, 0) - << QPointF(-(40 * 30) - 50, 0) // 50 = new footer width - << QPointF(-240, 0) - << QPointF(-240, 0) - << QPointF(-40, 0) - << QPointF(-(40 * 30) - 40, 0); -} - -class LVAccessor : public QQuickListView -{ -public: - qreal minY() const { return minYExtent(); } - qreal maxY() const { return maxYExtent(); } - qreal minX() const { return minXExtent(); } - qreal maxX() const { return maxXExtent(); } -}; - -void tst_QQuickListView::headerFooter() -{ - { - // Vertical - QQuickView *canvas = createView(); - - QmlListModel model; - QDeclarativeContext *ctxt = canvas->rootContext(); - ctxt->setContextProperty("testModel", &model); - - canvas->setSource(testFileUrl("headerfooter.qml")); - qApp->processEvents(); - - QQuickListView *listview = qobject_cast(canvas->rootObject()); - QTRY_VERIFY(listview != 0); - - QQuickItem *contentItem = listview->contentItem(); - QTRY_VERIFY(contentItem != 0); - - QQuickItem *header = findItem(contentItem, "header"); - QVERIFY(header); - QCOMPARE(header->y(), -header->height()); - - QQuickItem *footer = findItem(contentItem, "footer"); - QVERIFY(footer); - QCOMPARE(footer->y(), 0.); - - QCOMPARE(static_cast(listview)->minY(), header->height()); - QCOMPARE(static_cast(listview)->maxY(), header->height()); - - delete canvas; - } - { - // Horizontal - QQuickView *canvas = createView(); - - QmlListModel model; - QDeclarativeContext *ctxt = canvas->rootContext(); - ctxt->setContextProperty("testModel", &model); - - canvas->setSource(testFileUrl("headerfooter.qml")); - canvas->rootObject()->setProperty("horizontal", true); - qApp->processEvents(); - - QQuickListView *listview = qobject_cast(canvas->rootObject()); - QTRY_VERIFY(listview != 0); - - QQuickItem *contentItem = listview->contentItem(); - QTRY_VERIFY(contentItem != 0); - - QQuickItem *header = findItem(contentItem, "header"); - QVERIFY(header); - QCOMPARE(header->x(), -header->width()); - - QQuickItem *footer = findItem(contentItem, "footer"); - QVERIFY(footer); - QCOMPARE(footer->x(), 0.); - - QCOMPARE(static_cast(listview)->minX(), header->width()); - QCOMPARE(static_cast(listview)->maxX(), header->width()); - - delete canvas; - } - { - // Horizontal RTL - QQuickView *canvas = createView(); - - QmlListModel model; - QDeclarativeContext *ctxt = canvas->rootContext(); - ctxt->setContextProperty("testModel", &model); - - canvas->setSource(testFileUrl("headerfooter.qml")); - canvas->rootObject()->setProperty("horizontal", true); - canvas->rootObject()->setProperty("rtl", true); - qApp->processEvents(); - - QQuickListView *listview = qobject_cast(canvas->rootObject()); - QTRY_VERIFY(listview != 0); - - QQuickItem *contentItem = listview->contentItem(); - QTRY_VERIFY(contentItem != 0); - - QQuickItem *header = findItem(contentItem, "header"); - QVERIFY(header); - QCOMPARE(header->x(), 0.); - - QQuickItem *footer = findItem(contentItem, "footer"); - QVERIFY(footer); - QCOMPARE(footer->x(), -footer->width()); - - QCOMPARE(static_cast(listview)->minX(), 240. - header->width()); - QCOMPARE(static_cast(listview)->maxX(), 240. - header->width()); - - delete canvas; - } -} - -void tst_QQuickListView::resizeView() -{ - QQuickView *canvas = createView(); - - QmlListModel model; - for (int i = 0; i < 40; i++) - model.addItem("Item" + QString::number(i), ""); - - QDeclarativeContext *ctxt = canvas->rootContext(); - ctxt->setContextProperty("testModel", &model); - - TestObject *testObject = new TestObject; - ctxt->setContextProperty("testObject", testObject); - - canvas->setSource(testFileUrl("listviewtest.qml")); - canvas->show(); - qApp->processEvents(); - - QQuickListView *listview = findItem(canvas->rootObject(), "list"); - QTRY_VERIFY(listview != 0); - QQuickItem *contentItem = listview->contentItem(); - QTRY_VERIFY(contentItem != 0); - QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false); - - // Confirm items positioned correctly - int itemCount = findItems(contentItem, "wrapper").count(); - for (int i = 0; i < model.count() && i < itemCount; ++i) { - QQuickItem *item = findItem(contentItem, "wrapper", i); - if (!item) qWarning() << "Item" << i << "not found"; - QTRY_VERIFY(item); - QTRY_COMPARE(item->y(), i*20.); - } - - QVariant heightRatio; - QMetaObject::invokeMethod(canvas->rootObject(), "heightRatio", Q_RETURN_ARG(QVariant, heightRatio)); - QCOMPARE(heightRatio.toReal(), 0.4); - - listview->setHeight(200); - QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false); - - QMetaObject::invokeMethod(canvas->rootObject(), "heightRatio", Q_RETURN_ARG(QVariant, heightRatio)); - QCOMPARE(heightRatio.toReal(), 0.25); - - // Ensure we handle -ve sizes - listview->setHeight(-100); - QTRY_COMPARE(findItems(contentItem, "wrapper", false).count(), 1); - - listview->setCacheBuffer(200); - QTRY_COMPARE(findItems(contentItem, "wrapper", false).count(), 11); - - // ensure items in cache become visible - listview->setHeight(200); - QTRY_COMPARE(findItems(contentItem, "wrapper", false).count(), 21); - - itemCount = findItems(contentItem, "wrapper", false).count(); - for (int i = 0; i < model.count() && i < itemCount; ++i) { - QQuickItem *item = findItem(contentItem, "wrapper", i); - if (!item) qWarning() << "Item" << i << "not found"; - QTRY_VERIFY(item); - QTRY_COMPARE(item->y(), i*20.); - QCOMPARE(item->isVisible(), i < 11); // inside view visible, outside not visible - } - - // ensure items outside view become invisible - listview->setHeight(100); - QTRY_COMPARE(findItems(contentItem, "wrapper", false).count(), 16); - - itemCount = findItems(contentItem, "wrapper", false).count(); - for (int i = 0; i < model.count() && i < itemCount; ++i) { - QQuickItem *item = findItem(contentItem, "wrapper", i); - if (!item) qWarning() << "Item" << i << "not found"; - QTRY_VERIFY(item); - QTRY_COMPARE(item->y(), i*20.); - QCOMPARE(item->isVisible(), i < 6); // inside view visible, outside not visible - } - - delete canvas; - delete testObject; -} - -void tst_QQuickListView::resizeViewAndRepaint() -{ - QQuickView *canvas = createView(); - - QmlListModel model; - for (int i = 0; i < 40; i++) - model.addItem("Item" + QString::number(i), ""); - - QDeclarativeContext *ctxt = canvas->rootContext(); - ctxt->setContextProperty("testModel", &model); - ctxt->setContextProperty("initialHeight", 100); - - canvas->setSource(testFileUrl("resizeview.qml")); - canvas->show(); - qApp->processEvents(); - - QQuickListView *listview = findItem(canvas->rootObject(), "list"); - QTRY_VERIFY(listview != 0); - QQuickItem *contentItem = listview->contentItem(); - QTRY_VERIFY(contentItem != 0); - QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false); - - // item at index 10 should not be currently visible - QVERIFY(!findItem(contentItem, "wrapper", 10)); - - listview->setHeight(320); - - QTRY_VERIFY(findItem(contentItem, "wrapper", 10)); - - listview->setHeight(100); - QTRY_VERIFY(!findItem(contentItem, "wrapper", 10)); - - delete canvas; -} - -void tst_QQuickListView::sizeLessThan1() -{ - QQuickView *canvas = createView(); - - QmlListModel model; - for (int i = 0; i < 30; i++) - model.addItem("Item" + QString::number(i), ""); - - QDeclarativeContext *ctxt = canvas->rootContext(); - ctxt->setContextProperty("testModel", &model); - - TestObject *testObject = new TestObject; - ctxt->setContextProperty("testObject", testObject); - - canvas->setSource(testFileUrl("sizelessthan1.qml")); - canvas->show(); - qApp->processEvents(); - - QQuickListView *listview = findItem(canvas->rootObject(), "list"); - QTRY_VERIFY(listview != 0); - QQuickItem *contentItem = listview->contentItem(); - QTRY_VERIFY(contentItem != 0); - QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false); - - // Confirm items positioned correctly - int itemCount = findItems(contentItem, "wrapper").count(); - for (int i = 0; i < model.count() && i < itemCount; ++i) { - QQuickItem *item = findItem(contentItem, "wrapper", i); - if (!item) qWarning() << "Item" << i << "not found"; - QTRY_VERIFY(item); - QTRY_COMPARE(item->y(), i*0.5); - } - - delete canvas; - delete testObject; -} - -void tst_QQuickListView::QTBUG_14821() -{ - QQuickView *canvas = createView(); - - canvas->setSource(testFileUrl("qtbug14821.qml")); - qApp->processEvents(); - - QQuickListView *listview = qobject_cast(canvas->rootObject()); - QVERIFY(listview != 0); - - QQuickItem *contentItem = listview->contentItem(); - QVERIFY(contentItem != 0); - - listview->decrementCurrentIndex(); - QCOMPARE(listview->currentIndex(), 99); - - listview->incrementCurrentIndex(); - QCOMPARE(listview->currentIndex(), 0); - - delete canvas; -} - -void tst_QQuickListView::resizeDelegate() -{ - QQuickView *canvas = createView(); - - QStringList strings; - for (int i = 0; i < 30; ++i) - strings << QString::number(i); - QStringListModel model(strings); - - QDeclarativeContext *ctxt = canvas->rootContext(); - ctxt->setContextProperty("testModel", &model); - - canvas->setSource(testFileUrl("displaylist.qml")); - canvas->show(); - qApp->processEvents(); - - QQuickListView *listview = findItem(canvas->rootObject(), "list"); - QVERIFY(listview != 0); - QQuickItem *contentItem = listview->contentItem(); - QVERIFY(contentItem != 0); - QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false); - - QCOMPARE(listview->count(), model.rowCount()); - - listview->setCurrentIndex(25); - listview->setContentY(0); - QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false); - - for (int i = 0; i < 16; ++i) { - QQuickItem *item = findItem(contentItem, "wrapper", i); - QVERIFY(item != 0); - QCOMPARE(item->y(), i*20.0); - } - - QCOMPARE(listview->currentItem()->y(), 500.0); - QTRY_COMPARE(listview->highlightItem()->y(), 500.0); - - canvas->rootObject()->setProperty("delegateHeight", 30); - QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false); - - for (int i = 0; i < 11; ++i) { - QQuickItem *item = findItem(contentItem, "wrapper", i); - QVERIFY(item != 0); - QTRY_COMPARE(item->y(), i*30.0); - } - - QTRY_COMPARE(listview->currentItem()->y(), 750.0); - QTRY_COMPARE(listview->highlightItem()->y(), 750.0); - - listview->setCurrentIndex(1); - listview->positionViewAtIndex(25, QQuickListView::Beginning); - listview->positionViewAtIndex(5, QQuickListView::Beginning); - QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false); - - for (int i = 5; i < 16; ++i) { - QQuickItem *item = findItem(contentItem, "wrapper", i); - QVERIFY(item != 0); - QCOMPARE(item->y(), i*30.0); - } - - QTRY_COMPARE(listview->currentItem()->y(), 30.0); - QTRY_COMPARE(listview->highlightItem()->y(), 30.0); - - canvas->rootObject()->setProperty("delegateHeight", 20); - QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false); - - for (int i = 5; i < 11; ++i) { - QQuickItem *item = findItem(contentItem, "wrapper", i); - QVERIFY(item != 0); - QTRY_COMPARE(item->y(), 150 + (i-5)*20.0); - } - - QTRY_COMPARE(listview->currentItem()->y(), 70.0); - QTRY_COMPARE(listview->highlightItem()->y(), 70.0); - - delete canvas; -} - -void tst_QQuickListView::resizeFirstDelegate() -{ - // QTBUG-20712: Content Y jumps constantly if first delegate height == 0 - // and other delegates have height > 0 - - QQuickView *canvas = createView(); - - // bug only occurs when all items in the model are visible - QmlListModel model; - for (int i = 0; i < 10; i++) - model.addItem("Item" + QString::number(i), ""); - - QDeclarativeContext *ctxt = canvas->rootContext(); - ctxt->setContextProperty("testModel", &model); - - TestObject *testObject = new TestObject; - ctxt->setContextProperty("testObject", testObject); - - canvas->setSource(testFileUrl("listviewtest.qml")); - canvas->show(); - qApp->processEvents(); - - QQuickListView *listview = findItem(canvas->rootObject(), "list"); - QVERIFY(listview != 0); - QQuickItem *contentItem = listview->contentItem(); - QVERIFY(contentItem != 0); - QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false); - - QQuickItem *item = 0; - for (int i = 0; i < model.count(); ++i) { - item = findItem(contentItem, "wrapper", i); - QVERIFY(item != 0); - QCOMPARE(item->y(), i*20.0); - } - - item = findItem(contentItem, "wrapper", 0); - item->setHeight(0); - - // check the content y has not jumped up and down - QCOMPARE(listview->contentY(), 0.0); - QSignalSpy spy(listview, SIGNAL(contentYChanged())); - QTest::qWait(100); - QCOMPARE(spy.count(), 0); - - for (int i = 1; i < model.count(); ++i) { - item = findItem(contentItem, "wrapper", i); - QVERIFY(item != 0); - QTRY_COMPARE(item->y(), (i-1)*20.0); - } - - - // QTBUG-22014: refill doesn't clear items scrolling off the top of the - // list if they follow a zero-sized delegate - - for (int i = 0; i < 10; i++) - model.addItem("Item" + QString::number(i), ""); - QTRY_COMPARE(listview->count(), model.count()); - - item = findItem(contentItem, "wrapper", 1); - QVERIFY(item); - item->setHeight(0); - - listview->setCurrentIndex(19); - qApp->processEvents(); - QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false); - - // items 0-2 should have been deleted - for (int i=0; i<3; i++) { - QTRY_VERIFY(!findItem(contentItem, "wrapper", i)); - } - - delete testObject; - delete canvas; -} - -void tst_QQuickListView::QTBUG_16037() -{ - QQuickView *canvas = createView(); - canvas->show(); - - canvas->setSource(testFileUrl("qtbug16037.qml")); - qApp->processEvents(); - - QQuickListView *listview = findItem(canvas->rootObject(), "listview"); - QTRY_VERIFY(listview != 0); - - QVERIFY(listview->contentHeight() <= 0.0); - - QMetaObject::invokeMethod(canvas->rootObject(), "setModel"); - - QTRY_COMPARE(listview->contentHeight(), 80.0); - - delete canvas; -} - -void tst_QQuickListView::indexAt_itemAt_data() -{ - QTest::addColumn("x"); - QTest::addColumn("y"); - QTest::addColumn("index"); - - QTest::newRow("Item 0 - 0, 0") << 0. << 0. << 0; - QTest::newRow("Item 0 - 0, 19") << 0. << 19. << 0; - QTest::newRow("Item 0 - 239, 19") << 239. << 19. << 0; - QTest::newRow("Item 1 - 0, 20") << 0. << 20. << 1; - QTest::newRow("No Item - 240, 20") << 240. << 20. << -1; -} - -void tst_QQuickListView::indexAt_itemAt() -{ - QFETCH(qreal, x); - QFETCH(qreal, y); - QFETCH(int, index); - - QQuickView *canvas = createView(); - - QmlListModel model; - for (int i = 0; i < 30; i++) - model.addItem("Item" + QString::number(i), ""); - - QDeclarativeContext *ctxt = canvas->rootContext(); - ctxt->setContextProperty("testModel", &model); - - TestObject *testObject = new TestObject; - ctxt->setContextProperty("testObject", testObject); - - canvas->setSource(testFileUrl("listviewtest.qml")); - canvas->show(); - qApp->processEvents(); - - QQuickListView *listview = findItem(canvas->rootObject(), "list"); - QTRY_VERIFY(listview != 0); - - QQuickItem *contentItem = listview->contentItem(); - QTRY_VERIFY(contentItem != 0); - QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false); - - QQuickItem *item = 0; - if (index >= 0) { - item = findItem(contentItem, "wrapper", index); - QVERIFY(item); - } - QCOMPARE(listview->indexAt(x,y), index); - QVERIFY(listview->itemAt(x,y) == item); - - delete canvas; - delete testObject; -} - -void tst_QQuickListView::incrementalModel() -{ - QQuickView *canvas = createView(); - - IncrementalModel model; - QDeclarativeContext *ctxt = canvas->rootContext(); - ctxt->setContextProperty("testModel", &model); - - canvas->setSource(testFileUrl("displaylist.qml")); - qApp->processEvents(); - - QQuickListView *listview = findItem(canvas->rootObject(), "list"); - QTRY_VERIFY(listview != 0); - - QQuickItem *contentItem = listview->contentItem(); - QTRY_VERIFY(contentItem != 0); - - QTRY_COMPARE(listview->count(), 20); - - listview->positionViewAtIndex(10, QQuickListView::Beginning); - - QTRY_COMPARE(listview->count(), 25); - - delete canvas; -} - -void tst_QQuickListView::onAdd() -{ - QFETCH(int, initialItemCount); - QFETCH(int, itemsToAdd); - - const int delegateHeight = 10; - QaimModel model; - - // these initial items should not trigger ListView.onAdd - for (int i=0; isetGeometry(0,0,200, delegateHeight * (initialItemCount + itemsToAdd)); - QDeclarativeContext *ctxt = canvas->rootContext(); - ctxt->setContextProperty("testModel", &model); - ctxt->setContextProperty("delegateHeight", delegateHeight); - canvas->setSource(testFileUrl("attachedSignals.qml")); - - QObject *object = canvas->rootObject(); - object->setProperty("width", canvas->width()); - object->setProperty("height", canvas->height()); - qApp->processEvents(); - - QList > items; - for (int i=0; irootObject()->property("count").toInt(), model.count()); - - QVariantList result = object->property("addedDelegates").toList(); - QCOMPARE(result.count(), items.count()); - for (int i=0; i("initialItemCount"); - QTest::addColumn("itemsToAdd"); - - QTest::newRow("0, add 1") << 0 << 1; - QTest::newRow("0, add 2") << 0 << 2; - QTest::newRow("0, add 10") << 0 << 10; - - QTest::newRow("1, add 1") << 1 << 1; - QTest::newRow("1, add 2") << 1 << 2; - QTest::newRow("1, add 10") << 1 << 10; - - QTest::newRow("5, add 1") << 5 << 1; - QTest::newRow("5, add 2") << 5 << 2; - QTest::newRow("5, add 10") << 5 << 10; -} - -void tst_QQuickListView::onRemove() -{ - QFETCH(int, initialItemCount); - QFETCH(int, indexToRemove); - QFETCH(int, removeCount); - - const int delegateHeight = 10; - QaimModel model; - for (int i=0; irootContext(); - ctxt->setContextProperty("testModel", &model); - ctxt->setContextProperty("delegateHeight", delegateHeight); - canvas->setSource(testFileUrl("attachedSignals.qml")); - - QObject *object = canvas->rootObject(); - - model.removeItems(indexToRemove, removeCount); - QTRY_COMPARE(canvas->rootObject()->property("count").toInt(), model.count()); - - QCOMPARE(object->property("removedDelegateCount"), QVariant(removeCount)); - - delete canvas; -} - -void tst_QQuickListView::onRemove_data() -{ - QTest::addColumn("initialItemCount"); - QTest::addColumn("indexToRemove"); - QTest::addColumn("removeCount"); - - QTest::newRow("remove first") << 1 << 0 << 1; - QTest::newRow("two items, remove first") << 2 << 0 << 1; - QTest::newRow("two items, remove last") << 2 << 1 << 1; - QTest::newRow("two items, remove all") << 2 << 0 << 2; - - QTest::newRow("four items, remove first") << 4 << 0 << 1; - QTest::newRow("four items, remove 0-2") << 4 << 0 << 2; - QTest::newRow("four items, remove 1-3") << 4 << 1 << 2; - QTest::newRow("four items, remove 2-4") << 4 << 2 << 2; - QTest::newRow("four items, remove last") << 4 << 3 << 1; - QTest::newRow("four items, remove all") << 4 << 0 << 4; - - QTest::newRow("ten items, remove 1-8") << 10 << 0 << 8; - QTest::newRow("ten items, remove 2-7") << 10 << 2 << 5; - QTest::newRow("ten items, remove 4-10") << 10 << 4 << 6; -} - -void tst_QQuickListView::rightToLeft() -{ - QQuickView *canvas = createView(); - canvas->setGeometry(0,0,640,320); - canvas->setSource(testFileUrl("rightToLeft.qml")); - canvas->show(); - qApp->processEvents(); - - QVERIFY(canvas->rootObject() != 0); - QQuickListView *listview = findItem(canvas->rootObject(), "view"); - QTRY_VERIFY(listview != 0); - - QQuickItem *contentItem = listview->contentItem(); - QTRY_VERIFY(contentItem != 0); - - QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false); - - QQuickVisualItemModel *model = canvas->rootObject()->findChild("itemModel"); - QTRY_VERIFY(model != 0); - - QTRY_VERIFY(model->count() == 3); - QTRY_COMPARE(listview->currentIndex(), 0); - - // initial position at first item, right edge aligned - QCOMPARE(listview->contentX(), -640.); - - QQuickItem *item = findItem(contentItem, "item1"); - QTRY_VERIFY(item); - QTRY_COMPARE(item->x(), -100.0); - QCOMPARE(item->height(), listview->height()); - - QQuickText *text = findItem(contentItem, "text1"); - QTRY_VERIFY(text); - QTRY_COMPARE(text->text(), QLatin1String("index: 0")); - - listview->setCurrentIndex(2); - - item = findItem(contentItem, "item3"); - QTRY_VERIFY(item); - QTRY_COMPARE(item->x(), -540.0); - - text = findItem(contentItem, "text3"); - QTRY_VERIFY(text); - QTRY_COMPARE(text->text(), QLatin1String("index: 2")); - - QCOMPARE(listview->contentX(), -640.); - - // Ensure resizing maintains position relative to right edge - qobject_cast(canvas->rootObject())->setWidth(600); - QTRY_COMPARE(listview->contentX(), -600.); - - delete canvas; -} - -void tst_QQuickListView::test_mirroring() -{ - QQuickView *canvasA = createView(); - canvasA->setSource(testFileUrl("rightToLeft.qml")); - QQuickListView *listviewA = findItem(canvasA->rootObject(), "view"); - QTRY_VERIFY(listviewA != 0); - - QQuickView *canvasB = createView(); - canvasB->setSource(testFileUrl("rightToLeft.qml")); - QQuickListView *listviewB = findItem(canvasB->rootObject(), "view"); - QTRY_VERIFY(listviewA != 0); - qApp->processEvents(); - - QList objectNames; - objectNames << "item1" << "item2"; // << "item3" - - listviewA->setProperty("layoutDirection", Qt::LeftToRight); - listviewB->setProperty("layoutDirection", Qt::RightToLeft); - QCOMPARE(listviewA->layoutDirection(), listviewA->effectiveLayoutDirection()); - - // LTR != RTL - foreach (const QString objectName, objectNames) - QVERIFY(findItem(listviewA, objectName)->x() != findItem(listviewB, objectName)->x()); - - listviewA->setProperty("layoutDirection", Qt::LeftToRight); - listviewB->setProperty("layoutDirection", Qt::LeftToRight); - - // LTR == LTR - foreach (const QString objectName, objectNames) - QCOMPARE(findItem(listviewA, objectName)->x(), findItem(listviewB, objectName)->x()); - - QVERIFY(listviewB->layoutDirection() == listviewB->effectiveLayoutDirection()); - QQuickItemPrivate::get(listviewB)->setLayoutMirror(true); - QVERIFY(listviewB->layoutDirection() != listviewB->effectiveLayoutDirection()); - - // LTR != LTR+mirror - foreach (const QString objectName, objectNames) - QVERIFY(findItem(listviewA, objectName)->x() != findItem(listviewB, objectName)->x()); - - listviewA->setProperty("layoutDirection", Qt::RightToLeft); - - // RTL == LTR+mirror - foreach (const QString objectName, objectNames) - QCOMPARE(findItem(listviewA, objectName)->x(), findItem(listviewB, objectName)->x()); - - listviewB->setProperty("layoutDirection", Qt::RightToLeft); - - // RTL != RTL+mirror - foreach (const QString objectName, objectNames) - QVERIFY(findItem(listviewA, objectName)->x() != findItem(listviewB, objectName)->x()); - - listviewA->setProperty("layoutDirection", Qt::LeftToRight); - - // LTR == RTL+mirror - foreach (const QString objectName, objectNames) - QCOMPARE(findItem(listviewA, objectName)->x(), findItem(listviewB, objectName)->x()); - - delete canvasA; - delete canvasB; -} - -void tst_QQuickListView::margins() -{ - QQuickView *canvas = createView(); - - QaimModel model; - for (int i = 0; i < 50; i++) - model.addItem("Item" + QString::number(i), ""); - - QDeclarativeContext *ctxt = canvas->rootContext(); - ctxt->setContextProperty("testModel", &model); - - canvas->setSource(testFileUrl("margins.qml")); - canvas->show(); - qApp->processEvents(); - - QQuickListView *listview = findItem(canvas->rootObject(), "list"); - QTRY_VERIFY(listview != 0); - QQuickItem *contentItem = listview->contentItem(); - QTRY_VERIFY(contentItem != 0); - QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false); - - QCOMPARE(listview->contentY(), -30.); - QCOMPARE(listview->yOrigin(), 0.); - - // check end bound - listview->positionViewAtEnd(); - qreal pos = listview->contentY(); - listview->setContentY(pos + 80); - QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false); - listview->returnToBounds(); - QTRY_COMPARE(listview->contentY(), pos + 50); - - // remove item before visible and check that top margin is maintained - // and yOrigin is updated - listview->setContentY(100); - model.removeItem(1); - QTRY_COMPARE(listview->count(), model.count()); - listview->setContentY(-50); - QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false); - listview->returnToBounds(); - QCOMPARE(listview->yOrigin(), 20.); - QTRY_COMPARE(listview->contentY(), -10.); - - // reduce top margin - listview->setTopMargin(20); - QCOMPARE(listview->yOrigin(), 20.); - QTRY_COMPARE(listview->contentY(), 0.); - - // check end bound - listview->positionViewAtEnd(); - pos = listview->contentY(); - listview->setContentY(pos + 80); - listview->returnToBounds(); - QTRY_COMPARE(listview->contentY(), pos + 50); - - // reduce bottom margin - pos = listview->contentY(); - listview->setBottomMargin(40); - QCOMPARE(listview->yOrigin(), 20.); - QTRY_COMPARE(listview->contentY(), pos-10); - - delete canvas; -} - -// QTBUG-24028 -void tst_QQuickListView::marginsResize() -{ - QFETCH(QQuickListView::Orientation, orientation); - QFETCH(Qt::LayoutDirection, layoutDirection); - QFETCH(qreal, start); - QFETCH(qreal, end); - - QQuickView *canvas = createView(); - - canvas->setSource(testFileUrl("margins2.qml")); - canvas->show(); - qApp->processEvents(); - - QQuickListView *listview = findItem(canvas->rootObject(), "listview"); - QTRY_VERIFY(listview != 0); - - listview->setOrientation(orientation); - listview->setLayoutDirection(layoutDirection); - QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false); - - // view is resized after componentCompleted - top margin should still be visible - if (orientation == QQuickListView::Vertical) - QCOMPARE(listview->contentY(), start); - else - QCOMPARE(listview->contentX(), start); - - // move to last index and ensure bottom margin is visible. - listview->setCurrentIndex(19); - if (orientation == QQuickListView::Vertical) - QTRY_COMPARE(listview->contentY(), end); - else - QTRY_COMPARE(listview->contentX(), end); - - // back to top - top margin should be visible. - listview->setCurrentIndex(0); - if (orientation == QQuickListView::Vertical) - QTRY_COMPARE(listview->contentY(), start); - else - QTRY_COMPARE(listview->contentX(), start); - - delete canvas; -} - -void tst_QQuickListView::marginsResize_data() -{ - QTest::addColumn("orientation"); - QTest::addColumn("layoutDirection"); - QTest::addColumn("start"); - QTest::addColumn("end"); - - QTest::newRow("vertical") << QQuickListView::Vertical << Qt::LeftToRight << -20.0 << 1020.0; - QTest::newRow("horizontal") << QQuickListView::Horizontal << Qt::LeftToRight << -20.0 << 1020.0; - QTest::newRow("horizontal, rtl") << QQuickListView::Horizontal << Qt::RightToLeft << -180.0 << -1220.0; -} - -void tst_QQuickListView::snapToItem_data() -{ - QTest::addColumn("orientation"); - QTest::addColumn("layoutDirection"); - QTest::addColumn("highlightRangeMode"); - QTest::addColumn("flickStart"); - QTest::addColumn("flickEnd"); - QTest::addColumn("snapAlignment"); - QTest::addColumn("endExtent"); - QTest::addColumn("startExtent"); - - QTest::newRow("vertical, left to right") << QQuickListView::Vertical << Qt::LeftToRight << int(QQuickItemView::NoHighlightRange) - << QPoint(20, 200) << QPoint(20, 20) << 60.0 << 1200.0 << 0.0; - - QTest::newRow("horizontal, left to right") << QQuickListView::Horizontal << Qt::LeftToRight << int(QQuickItemView::NoHighlightRange) - << QPoint(200, 20) << QPoint(20, 20) << 60.0 << 1200.0 << 0.0; - - QTest::newRow("horizontal, right to left") << QQuickListView::Horizontal << Qt::RightToLeft << int(QQuickItemView::NoHighlightRange) - << QPoint(20, 20) << QPoint(200, 20) << -60.0 << -1200.0 - 240.0 << -240.0; - - QTest::newRow("vertical, left to right, enforce range") << QQuickListView::Vertical << Qt::LeftToRight << int(QQuickItemView::StrictlyEnforceRange) - << QPoint(20, 200) << QPoint(20, 20) << 60.0 << 1340.0 << -20.0; - - QTest::newRow("horizontal, left to right, enforce range") << QQuickListView::Horizontal << Qt::LeftToRight << int(QQuickItemView::StrictlyEnforceRange) - << QPoint(200, 20) << QPoint(20, 20) << 60.0 << 1340.0 << -20.0; - - QTest::newRow("horizontal, right to left, enforce range") << QQuickListView::Horizontal << Qt::RightToLeft << int(QQuickItemView::StrictlyEnforceRange) - << QPoint(20, 20) << QPoint(200, 20) << -60.0 << -1200.0 - 240.0 - 140.0 << -220.0; -} - -void tst_QQuickListView::snapToItem() -{ - QFETCH(QQuickListView::Orientation, orientation); - QFETCH(Qt::LayoutDirection, layoutDirection); - QFETCH(int, highlightRangeMode); - QFETCH(QPoint, flickStart); - QFETCH(QPoint, flickEnd); - QFETCH(qreal, snapAlignment); - QFETCH(qreal, endExtent); - QFETCH(qreal, startExtent); - - QQuickView *canvas = createView(); - - canvas->setSource(testFileUrl("snapToItem.qml")); - canvas->show(); - qApp->processEvents(); - - QQuickListView *listview = findItem(canvas->rootObject(), "list"); - QTRY_VERIFY(listview != 0); - - listview->setOrientation(orientation); - listview->setLayoutDirection(layoutDirection); - listview->setHighlightRangeMode(QQuickItemView::HighlightRangeMode(highlightRangeMode)); - QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false); - - QQuickItem *contentItem = listview->contentItem(); - QTRY_VERIFY(contentItem != 0); - - // confirm that a flick hits an item boundary - flick(canvas, flickStart, flickEnd, 180); - QTRY_VERIFY(listview->isMoving() == false); // wait until it stops - if (orientation == QQuickListView::Vertical) - QCOMPARE(qreal(fmod(listview->contentY(),80.0)), snapAlignment); - else - QCOMPARE(qreal(fmod(listview->contentX(),80.0)), snapAlignment); - - // flick to end - do { - flick(canvas, flickStart, flickEnd, 180); - QTRY_VERIFY(listview->isMoving() == false); // wait until it stops - } while (orientation == QQuickListView::Vertical - ? !listview->isAtYEnd() - : layoutDirection == Qt::LeftToRight ? !listview->isAtXEnd() : !listview->isAtXBeginning()); - - if (orientation == QQuickListView::Vertical) - QCOMPARE(listview->contentY(), endExtent); - else - QCOMPARE(listview->contentX(), endExtent); - - // flick to start - do { - flick(canvas, flickEnd, flickStart, 180); - QTRY_VERIFY(listview->isMoving() == false); // wait until it stops - } while (orientation == QQuickListView::Vertical - ? !listview->isAtYBeginning() - : layoutDirection == Qt::LeftToRight ? !listview->isAtXBeginning() : !listview->isAtXEnd()); - - if (orientation == QQuickListView::Vertical) - QCOMPARE(listview->contentY(), startExtent); - else - QCOMPARE(listview->contentX(), startExtent); - - delete canvas; -} - -void tst_QQuickListView::qListModelInterface_items() -{ - items(testFileUrl("listviewtest.qml"), false); -} - -void tst_QQuickListView::qListModelInterface_package_items() -{ - items(testFileUrl("listviewtest-package.qml"), true); -} - -void tst_QQuickListView::qAbstractItemModel_items() -{ - items(testFileUrl("listviewtest.qml"), false); -} - -void tst_QQuickListView::qListModelInterface_changed() -{ - changed(testFileUrl("listviewtest.qml"), false); -} - -void tst_QQuickListView::qListModelInterface_package_changed() -{ - changed(testFileUrl("listviewtest-package.qml"), true); -} - -void tst_QQuickListView::qAbstractItemModel_changed() -{ - changed(testFileUrl("listviewtest.qml"), false); -} - -void tst_QQuickListView::qListModelInterface_inserted() -{ - inserted(testFileUrl("listviewtest.qml")); -} - -void tst_QQuickListView::qListModelInterface_package_inserted() -{ - inserted(testFileUrl("listviewtest-package.qml")); -} - -void tst_QQuickListView::qListModelInterface_inserted_more() -{ - inserted_more(); -} - -void tst_QQuickListView::qListModelInterface_inserted_more_data() -{ - inserted_more_data(); -} - -void tst_QQuickListView::qAbstractItemModel_inserted() -{ - inserted(testFileUrl("listviewtest.qml")); -} - -void tst_QQuickListView::qAbstractItemModel_inserted_more() -{ - inserted_more(); -} - -void tst_QQuickListView::qAbstractItemModel_inserted_more_data() -{ - inserted_more_data(); -} - -void tst_QQuickListView::qListModelInterface_removed() -{ - removed(testFileUrl("listviewtest.qml"), false); - removed(testFileUrl("listviewtest.qml"), true); -} - -void tst_QQuickListView::qListModelInterface_removed_more() -{ - removed_more(testFileUrl("listviewtest.qml")); -} - -void tst_QQuickListView::qListModelInterface_removed_more_data() -{ - removed_more_data(); -} - -void tst_QQuickListView::qListModelInterface_package_removed() -{ - removed(testFileUrl("listviewtest-package.qml"), false); - removed(testFileUrl("listviewtest-package.qml"), true); -} - -void tst_QQuickListView::qAbstractItemModel_removed() -{ - removed(testFileUrl("listviewtest.qml"), false); - removed(testFileUrl("listviewtest.qml"), true); -} - -void tst_QQuickListView::qAbstractItemModel_removed_more() -{ - removed_more(testFileUrl("listviewtest.qml")); -} - -void tst_QQuickListView::qAbstractItemModel_removed_more_data() -{ - removed_more_data(); -} - -void tst_QQuickListView::qListModelInterface_moved() -{ - moved(testFileUrl("listviewtest.qml")); -} - -void tst_QQuickListView::qListModelInterface_moved_data() -{ - moved_data(); -} - -void tst_QQuickListView::qListModelInterface_package_moved() -{ - moved(testFileUrl("listviewtest-package.qml")); -} - -void tst_QQuickListView::qListModelInterface_package_moved_data() -{ - moved_data(); -} - -void tst_QQuickListView::qAbstractItemModel_moved() -{ - moved(testFileUrl("listviewtest.qml")); -} - -void tst_QQuickListView::qAbstractItemModel_moved_data() -{ - moved_data(); -} - -void tst_QQuickListView::qListModelInterface_clear() -{ - clear(testFileUrl("listviewtest.qml")); -} - -void tst_QQuickListView::qListModelInterface_package_clear() -{ - clear(testFileUrl("listviewtest-package.qml")); -} - -void tst_QQuickListView::qAbstractItemModel_clear() -{ - clear(testFileUrl("listviewtest.qml")); -} - -void tst_QQuickListView::qListModelInterface_sections() -{ - sections(testFileUrl("listview-sections.qml")); -} - -void tst_QQuickListView::qListModelInterface_package_sections() -{ - sections(testFileUrl("listview-sections-package.qml")); -} - -void tst_QQuickListView::qAbstractItemModel_sections() -{ - sections(testFileUrl("listview-sections.qml")); -} - -void tst_QQuickListView::creationContext() -{ - QQuickView canvas; - canvas.setGeometry(0,0,240,320); - canvas.setSource(testFileUrl("creationContext.qml")); - qApp->processEvents(); - - QQuickItem *rootItem = qobject_cast(canvas.rootObject()); - QVERIFY(rootItem); - QVERIFY(rootItem->property("count").toInt() > 0); - - QQuickItem *item; - QVERIFY(item = rootItem->findChild("listItem")); - QCOMPARE(item->property("text").toString(), QString("Hello!")); - QVERIFY(item = rootItem->findChild("header")); - QCOMPARE(item->property("text").toString(), QString("Hello!")); - QVERIFY(item = rootItem->findChild("footer")); - QCOMPARE(item->property("text").toString(), QString("Hello!")); - QVERIFY(item = rootItem->findChild("section")); - QCOMPARE(item->property("text").toString(), QString("Hello!")); -} - -void tst_QQuickListView::QTBUG_21742() -{ - QQuickView canvas; - canvas.setGeometry(0,0,200,200); - canvas.setSource(testFileUrl("qtbug-21742.qml")); - qApp->processEvents(); - - QQuickItem *rootItem = qobject_cast(canvas.rootObject()); - QVERIFY(rootItem); - QCOMPARE(rootItem->property("count").toInt(), 1); -} - -void tst_QQuickListView::asynchronous() -{ - QQuickView *canvas = createView(); - canvas->show(); - QDeclarativeIncubationController controller; - canvas->engine()->setIncubationController(&controller); - - canvas->setSource(testFileUrl("asyncloader.qml")); - - QQuickItem *rootObject = qobject_cast(canvas->rootObject()); - QVERIFY(rootObject); - - QQuickListView *listview = 0; - while (!listview) { - bool b = false; - controller.incubateWhile(&b); - listview = rootObject->findChild("view"); - } - - // items will be created one at a time - for (int i = 0; i < 8; ++i) { - QVERIFY(findItem(listview, "wrapper", i) == 0); - QQuickItem *item = 0; - while (!item) { - bool b = false; - controller.incubateWhile(&b); - item = findItem(listview, "wrapper", i); - } - } - - { - bool b = true; - controller.incubateWhile(&b); - } - - // verify positioning - QQuickItem *contentItem = listview->contentItem(); - for (int i = 0; i < 8; ++i) { - QQuickItem *item = findItem(contentItem, "wrapper", i); - QTRY_COMPARE(item->y(), i*50.0); - } - - delete canvas; -} - -void tst_QQuickListView::snapOneItem_data() -{ - QTest::addColumn("orientation"); - QTest::addColumn("layoutDirection"); - QTest::addColumn("highlightRangeMode"); - QTest::addColumn("flickStart"); - QTest::addColumn("flickEnd"); - QTest::addColumn("snapAlignment"); - QTest::addColumn("endExtent"); - QTest::addColumn("startExtent"); - - QTest::newRow("vertical, left to right") << QQuickListView::Vertical << Qt::LeftToRight << int(QQuickItemView::NoHighlightRange) - << QPoint(20, 200) << QPoint(20, 20) << 180.0 << 560.0 << 0.0; - - QTest::newRow("horizontal, left to right") << QQuickListView::Horizontal << Qt::LeftToRight << int(QQuickItemView::NoHighlightRange) - << QPoint(200, 20) << QPoint(20, 20) << 180.0 << 560.0 << 0.0; - - QTest::newRow("horizontal, right to left") << QQuickListView::Horizontal << Qt::RightToLeft << int(QQuickItemView::NoHighlightRange) - << QPoint(20, 20) << QPoint(200, 20) << -420.0 << -560.0 - 240.0 << -240.0; - - QTest::newRow("vertical, left to right, enforce range") << QQuickListView::Vertical << Qt::LeftToRight << int(QQuickItemView::StrictlyEnforceRange) - << QPoint(20, 200) << QPoint(20, 20) << 180.0 << 580.0 << -20.0; - - QTest::newRow("horizontal, left to right, enforce range") << QQuickListView::Horizontal << Qt::LeftToRight << int(QQuickItemView::StrictlyEnforceRange) - << QPoint(200, 20) << QPoint(20, 20) << 180.0 << 580.0 << -20.0; - - QTest::newRow("horizontal, right to left, enforce range") << QQuickListView::Horizontal << Qt::RightToLeft << int(QQuickItemView::StrictlyEnforceRange) - << QPoint(20, 20) << QPoint(200, 20) << -420.0 << -580.0 - 240.0 << -220.0; -} - -void tst_QQuickListView::snapOneItem() -{ - QFETCH(QQuickListView::Orientation, orientation); - QFETCH(Qt::LayoutDirection, layoutDirection); - QFETCH(int, highlightRangeMode); - QFETCH(QPoint, flickStart); - QFETCH(QPoint, flickEnd); - QFETCH(qreal, snapAlignment); - QFETCH(qreal, endExtent); - QFETCH(qreal, startExtent); - -#ifdef Q_OS_MAC - // This test seems to be unreliable - different test data fails on different runs - QSKIP("QTBUG-24338"); -#endif - - QQuickView *canvas = createView(); - - canvas->setSource(testFileUrl("snapOneItem.qml")); - canvas->show(); - qApp->processEvents(); - - QQuickListView *listview = findItem(canvas->rootObject(), "list"); - QTRY_VERIFY(listview != 0); - - listview->setOrientation(orientation); - listview->setLayoutDirection(layoutDirection); - listview->setHighlightRangeMode(QQuickItemView::HighlightRangeMode(highlightRangeMode)); - QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false); - - QQuickItem *contentItem = listview->contentItem(); - QTRY_VERIFY(contentItem != 0); - - QSignalSpy currentIndexSpy(listview, SIGNAL(currentIndexChanged())); - - // confirm that a flick hits the next item boundary - flick(canvas, flickStart, flickEnd, 180); - QTRY_VERIFY(listview->isMoving() == false); // wait until it stops - if (orientation == QQuickListView::Vertical) - QCOMPARE(listview->contentY(), snapAlignment); - else - QCOMPARE(listview->contentX(), snapAlignment); - - if (QQuickItemView::HighlightRangeMode(highlightRangeMode) == QQuickItemView::StrictlyEnforceRange) { - QCOMPARE(listview->currentIndex(), 1); - QCOMPARE(currentIndexSpy.count(), 1); - } - - // flick to end - do { - flick(canvas, flickStart, flickEnd, 180); - QTRY_VERIFY(listview->isMoving() == false); // wait until it stops - } while (orientation == QQuickListView::Vertical - ? !listview->isAtYEnd() - : layoutDirection == Qt::LeftToRight ? !listview->isAtXEnd() : !listview->isAtXBeginning()); - - if (orientation == QQuickListView::Vertical) - QCOMPARE(listview->contentY(), endExtent); - else - QCOMPARE(listview->contentX(), endExtent); - - if (QQuickItemView::HighlightRangeMode(highlightRangeMode) == QQuickItemView::StrictlyEnforceRange) { - QCOMPARE(listview->currentIndex(), 3); - QCOMPARE(currentIndexSpy.count(), 3); - } - - // flick to start - do { - flick(canvas, flickEnd, flickStart, 180); - QTRY_VERIFY(listview->isMoving() == false); // wait until it stops - } while (orientation == QQuickListView::Vertical - ? !listview->isAtYBeginning() - : layoutDirection == Qt::LeftToRight ? !listview->isAtXBeginning() : !listview->isAtXEnd()); - - if (orientation == QQuickListView::Vertical) - QCOMPARE(listview->contentY(), startExtent); - else - QCOMPARE(listview->contentX(), startExtent); - - if (QQuickItemView::HighlightRangeMode(highlightRangeMode) == QQuickItemView::StrictlyEnforceRange) { - QCOMPARE(listview->currentIndex(), 0); - QCOMPARE(currentIndexSpy.count(), 6); - } - - delete canvas; -} - -void tst_QQuickListView::unrequestedVisibility() -{ - QmlListModel model; - for (int i = 0; i < 30; i++) - model.addItem("Item" + QString::number(i), QString::number(i)); - - QQuickView *canvas = new QQuickView(0); - canvas->setGeometry(0,0,240,320); - - QDeclarativeContext *ctxt = canvas->rootContext(); - ctxt->setContextProperty("testModel", &model); - ctxt->setContextProperty("testWrap", QVariant(false)); - - canvas->setSource(testFileUrl("unrequestedItems.qml")); - canvas->show(); - qApp->processEvents(); - - QQuickListView *leftview = findItem(canvas->rootObject(), "leftList"); - QTRY_VERIFY(leftview != 0); - - QQuickListView *rightview = findItem(canvas->rootObject(), "rightList"); - QTRY_VERIFY(rightview != 0); - - QQuickItem *leftContent = leftview->contentItem(); - QTRY_VERIFY(leftContent != 0); - - QQuickItem *rightContent = rightview->contentItem(); - QTRY_VERIFY(rightContent != 0); - - rightview->setCurrentIndex(20); - - QTRY_COMPARE(leftview->contentY(), 0.0); - QTRY_COMPARE(rightview->contentY(), 100.0); - - QQuickItem *item; - - QVERIFY(item = findItem(leftContent, "wrapper", 1)); - QCOMPARE(item->isVisible(), true); - QVERIFY(item = findItem(rightContent, "wrapper", 1)); - QCOMPARE(item->isVisible(), false); - - QVERIFY(item = findItem(leftContent, "wrapper", 19)); - QCOMPARE(item->isVisible(), false); - QVERIFY(item = findItem(rightContent, "wrapper", 19)); - QCOMPARE(item->isVisible(), true); - - QVERIFY(item = findItem(leftContent, "wrapper", 16)); - QCOMPARE(item->isVisible(), true); - QVERIFY(item = findItem(leftContent, "wrapper", 17)); - QCOMPARE(item->isVisible(), false); - QVERIFY(item = findItem(rightContent, "wrapper", 3)); - QCOMPARE(item->isVisible(), false); - QVERIFY(item = findItem(rightContent, "wrapper", 4)); - QCOMPARE(item->isVisible(), true); - - rightview->setCurrentIndex(0); - - QTRY_COMPARE(leftview->contentY(), 0.0); - QTRY_COMPARE(rightview->contentY(), 0.0); - - QVERIFY(item = findItem(leftContent, "wrapper", 1)); - QCOMPARE(item->isVisible(), true); - QVERIFY(item = findItem(rightContent, "wrapper", 1)); - QTRY_COMPARE(item->isVisible(), true); - - QVERIFY(!findItem(leftContent, "wrapper", 19)); - QVERIFY(!findItem(rightContent, "wrapper", 19)); - - leftview->setCurrentIndex(20); - - QTRY_COMPARE(leftview->contentY(), 100.0); - QTRY_COMPARE(rightview->contentY(), 0.0); - - QVERIFY(item = findItem(leftContent, "wrapper", 1)); - QTRY_COMPARE(item->isVisible(), false); - QVERIFY(item = findItem(rightContent, "wrapper", 1)); - QCOMPARE(item->isVisible(), true); - - QVERIFY(item = findItem(leftContent, "wrapper", 19)); - QCOMPARE(item->isVisible(), true); - QVERIFY(item = findItem(rightContent, "wrapper", 19)); - QCOMPARE(item->isVisible(), false); - - QVERIFY(item = findItem(leftContent, "wrapper", 3)); - QCOMPARE(item->isVisible(), false); - QVERIFY(item = findItem(leftContent, "wrapper", 4)); - QCOMPARE(item->isVisible(), true); - QVERIFY(item = findItem(rightContent, "wrapper", 16)); - QCOMPARE(item->isVisible(), true); - QVERIFY(item = findItem(rightContent, "wrapper", 17)); - QCOMPARE(item->isVisible(), false); - - model.moveItems(19, 1, 1); - QTRY_COMPARE(QQuickItemPrivate::get(leftview)->polishScheduled, false); - - QTRY_VERIFY(item = findItem(leftContent, "wrapper", 1)); - QCOMPARE(item->isVisible(), false); - QVERIFY(item = findItem(rightContent, "wrapper", 1)); - QCOMPARE(item->isVisible(), true); - - QVERIFY(item = findItem(leftContent, "wrapper", 19)); - QCOMPARE(item->isVisible(), true); - QVERIFY(item = findItem(rightContent, "wrapper", 19)); - QCOMPARE(item->isVisible(), false); - - QVERIFY(item = findItem(leftContent, "wrapper", 4)); - QCOMPARE(item->isVisible(), false); - QVERIFY(item = findItem(leftContent, "wrapper", 5)); - QCOMPARE(item->isVisible(), true); - QVERIFY(item = findItem(rightContent, "wrapper", 16)); - QCOMPARE(item->isVisible(), true); - QVERIFY(item = findItem(rightContent, "wrapper", 17)); - QCOMPARE(item->isVisible(), false); - - model.moveItems(3, 4, 1); - QTRY_COMPARE(QQuickItemPrivate::get(leftview)->polishScheduled, false); - - QVERIFY(item = findItem(leftContent, "wrapper", 4)); - QCOMPARE(item->isVisible(), false); - QVERIFY(item = findItem(leftContent, "wrapper", 5)); - QCOMPARE(item->isVisible(), true); - QVERIFY(item = findItem(rightContent, "wrapper", 16)); - QCOMPARE(item->isVisible(), true); - QVERIFY(item = findItem(rightContent, "wrapper", 17)); - QCOMPARE(item->isVisible(), false); - - model.moveItems(4, 3, 1); - QTRY_COMPARE(QQuickItemPrivate::get(leftview)->polishScheduled, false); - - QVERIFY(item = findItem(leftContent, "wrapper", 4)); - QCOMPARE(item->isVisible(), false); - QVERIFY(item = findItem(leftContent, "wrapper", 5)); - QCOMPARE(item->isVisible(), true); - QVERIFY(item = findItem(rightContent, "wrapper", 16)); - QCOMPARE(item->isVisible(), true); - QVERIFY(item = findItem(rightContent, "wrapper", 17)); - QCOMPARE(item->isVisible(), false); - - model.moveItems(16, 17, 1); - QTRY_COMPARE(QQuickItemPrivate::get(leftview)->polishScheduled, false); - - QVERIFY(item = findItem(leftContent, "wrapper", 4)); - QCOMPARE(item->isVisible(), false); - QVERIFY(item = findItem(leftContent, "wrapper", 5)); - QCOMPARE(item->isVisible(), true); - QVERIFY(item = findItem(rightContent, "wrapper", 16)); - QCOMPARE(item->isVisible(), true); - QVERIFY(item = findItem(rightContent, "wrapper", 17)); - QCOMPARE(item->isVisible(), false); - - model.moveItems(17, 16, 1); - QTRY_COMPARE(QQuickItemPrivate::get(leftview)->polishScheduled, false); - - QVERIFY(item = findItem(leftContent, "wrapper", 4)); - QCOMPARE(item->isVisible(), false); - QVERIFY(item = findItem(leftContent, "wrapper", 5)); - QCOMPARE(item->isVisible(), true); - QVERIFY(item = findItem(rightContent, "wrapper", 16)); - QCOMPARE(item->isVisible(), true); - QVERIFY(item = findItem(rightContent, "wrapper", 17)); - QCOMPARE(item->isVisible(), false); - - delete canvas; -} - -void tst_QQuickListView::populateTransitions() -{ - QFETCH(bool, staticallyPopulate); - QFETCH(bool, dynamicallyPopulate); - QFETCH(bool, usePopulateTransition); - - QPointF transitionFrom(-50, -50); - QPointF transitionVia(100, 100); - QaimModel model_transitionFrom; - QaimModel model_transitionVia; - - QaimModel model; - if (staticallyPopulate) { - for (int i = 0; i < 30; i++) - model.addItem("item" + QString::number(i), ""); - } - - QQuickView *canvas = createView(); - canvas->rootContext()->setContextProperty("testModel", &model); - canvas->rootContext()->setContextProperty("testObject", new TestObject(canvas->rootContext())); - canvas->rootContext()->setContextProperty("usePopulateTransition", usePopulateTransition); - canvas->rootContext()->setContextProperty("dynamicallyPopulate", dynamicallyPopulate); - canvas->rootContext()->setContextProperty("transitionFrom", transitionFrom); - canvas->rootContext()->setContextProperty("transitionVia", transitionVia); - canvas->rootContext()->setContextProperty("model_transitionFrom", &model_transitionFrom); - canvas->rootContext()->setContextProperty("model_transitionVia", &model_transitionVia); - canvas->setSource(testFileUrl("populateTransitions.qml")); - canvas->show(); - - QQuickListView *listview = findItem(canvas->rootObject(), "list"); - QVERIFY(listview); - QQuickItem *contentItem = listview->contentItem(); - QVERIFY(contentItem); - - if (staticallyPopulate || dynamicallyPopulate) { - // check the populate transition is run - if (usePopulateTransition) { - QTRY_COMPARE(listview->property("countPopulateTransitions").toInt(), 17); - } else { - QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false); - QTRY_COMPARE(listview->property("countPopulateTransitions").toInt(), 0); - } - QTRY_COMPARE(listview->property("countAddTransitions").toInt(), 0); - } else { - QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false); - } - - int itemCount = findItems(contentItem, "wrapper").count(); - if (usePopulateTransition) - QCOMPARE(itemCount, listview->property("countPopulateTransitions").toInt()); - for (int i=0; i < model.count() && i < itemCount; ++i) { - QQuickItem *item = findItem(contentItem, "wrapper", i); - QVERIFY2(item, QTest::toString(QString("Item %1 not found").arg(i))); - QTRY_COMPARE(item->x(), 0.0); - QTRY_COMPARE(item->y(), i*20.0); - QQuickText *name = findItem(contentItem, "textName", i); - QVERIFY(name != 0); - QTRY_COMPARE(name->text(), model.name(i)); - } - - // add an item and check this is done with add trantion, not populate - model.insertItem(0, "another item", ""); - QTRY_COMPARE(listview->property("countAddTransitions").toInt(), 1); - QTRY_COMPARE(listview->property("countPopulateTransitions").toInt(), - (usePopulateTransition && (staticallyPopulate || dynamicallyPopulate)) ? 17 : 0); - - // clear the model - canvas->rootContext()->setContextProperty("testModel", QVariant()); - QTRY_COMPARE(listview->count(), 0); - QTRY_COMPARE(findItems(contentItem, "wrapper").count(), 0); - listview->setProperty("countPopulateTransitions", 0); - listview->setProperty("countAddTransitions", 0); - - // set to a valid model and check populate transition is run a second time - model.clear(); - for (int i = 0; i < 30; i++) - model.addItem("item" + QString::number(i), ""); - canvas->rootContext()->setContextProperty("testModel", &model); - QTRY_COMPARE(listview->property("countPopulateTransitions").toInt(), usePopulateTransition ? 17 : 0); - QTRY_COMPARE(listview->property("countAddTransitions").toInt(), 0); - - itemCount = findItems(contentItem, "wrapper").count(); - if (usePopulateTransition) - QCOMPARE(itemCount, listview->property("countPopulateTransitions").toInt()); - for (int i=0; i < model.count() && i < itemCount; ++i) { - QQuickItem *item = findItem(contentItem, "wrapper", i); - QVERIFY2(item, QTest::toString(QString("Item %1 not found").arg(i))); - QTRY_COMPARE(item->x(), 0.0); - QTRY_COMPARE(item->y(), i*20.0); - QQuickText *name = findItem(contentItem, "textName", i); - QVERIFY(name != 0); - QTRY_COMPARE(name->text(), model.name(i)); - } - - // reset model and check populate transition is run again - listview->setProperty("countPopulateTransitions", 0); - listview->setProperty("countAddTransitions", 0); - model.reset(); - QTRY_COMPARE(listview->property("countPopulateTransitions").toInt(), usePopulateTransition ? 17 : 0); - QTRY_COMPARE(listview->property("countAddTransitions").toInt(), 0); - - itemCount = findItems(contentItem, "wrapper").count(); - if (usePopulateTransition) - QCOMPARE(itemCount, listview->property("countPopulateTransitions").toInt()); - for (int i=0; i < model.count() && i < itemCount; ++i) { - QQuickItem *item = findItem(contentItem, "wrapper", i); - QVERIFY2(item, QTest::toString(QString("Item %1 not found").arg(i))); - QTRY_COMPARE(item->x(), 0.0); - QTRY_COMPARE(item->y(), i*20.0); - QQuickText *name = findItem(contentItem, "textName", i); - QVERIFY(name != 0); - QTRY_COMPARE(name->text(), model.name(i)); - } - - delete canvas; -} - -void tst_QQuickListView::populateTransitions_data() -{ - QTest::addColumn("staticallyPopulate"); - QTest::addColumn("dynamicallyPopulate"); - QTest::addColumn("usePopulateTransition"); - - QTest::newRow("static") << true << false << true; - QTest::newRow("static, no populate") << true << false << false; - - QTest::newRow("dynamic") << false << true << true; - QTest::newRow("dynamic, no populate") << false << true << false; - - QTest::newRow("empty to start with") << false << false << true; - QTest::newRow("empty to start with, no populate") << false << false << false; -} - -void tst_QQuickListView::addTransitions() -{ - QFETCH(int, initialItemCount); - QFETCH(bool, shouldAnimateTargets); - QFETCH(qreal, contentY); - QFETCH(int, insertionIndex); - QFETCH(int, insertionCount); - QFETCH(ListRange, expectedDisplacedIndexes); - - // added items should start here - QPointF targetItems_transitionFrom(-50, -50); - - // displaced items should pass through this point - QPointF displacedItems_transitionVia(100, 100); - - QaimModel model; - for (int i = 0; i < initialItemCount; i++) - model.addItem("Original item" + QString::number(i), ""); - QaimModel model_targetItems_transitionFrom; - QaimModel model_displacedItems_transitionVia; - - QQuickView *canvas = createView(); - QDeclarativeContext *ctxt = canvas->rootContext(); - TestObject *testObject = new TestObject; - ctxt->setContextProperty("testModel", &model); - ctxt->setContextProperty("model_targetItems_transitionFrom", &model_targetItems_transitionFrom); - ctxt->setContextProperty("model_displacedItems_transitionVia", &model_displacedItems_transitionVia); - ctxt->setContextProperty("targetItems_transitionFrom", targetItems_transitionFrom); - ctxt->setContextProperty("displacedItems_transitionVia", displacedItems_transitionVia); - ctxt->setContextProperty("testObject", testObject); - canvas->setSource(testFileUrl("addTransitions.qml")); - canvas->show(); - - QQuickListView *listview = findItem(canvas->rootObject(), "list"); - QTRY_VERIFY(listview != 0); - QQuickItem *contentItem = listview->contentItem(); - QVERIFY(contentItem != 0); - QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false); - - if (contentY != 0) { - listview->setContentY(contentY); - QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false); - } - - QList > expectedDisplacedValues = expectedDisplacedIndexes.getModelDataValues(model); - - // only target items that will become visible should be animated - QList > newData; - QList > expectedTargetData; - QList targetIndexes; - if (shouldAnimateTargets) { - for (int i=insertionIndex; i= contentY / 20 && i < (contentY + listview->height()) / 20) { // only grab visible items - expectedTargetData << newData.last(); - targetIndexes << i; - } - } - QVERIFY(expectedTargetData.count() > 0); - } - - // start animation - if (!newData.isEmpty()) { - model.insertItems(insertionIndex, newData); - QTRY_COMPARE(model.count(), listview->count()); - } - - QList targetItems = findItems(contentItem, "wrapper", targetIndexes); - - if (shouldAnimateTargets) { - QTRY_COMPARE(listview->property("targetTransitionsDone").toInt(), expectedTargetData.count()); - QTRY_COMPARE(listview->property("displaceTransitionsDone").toInt(), - expectedDisplacedIndexes.isValid() ? expectedDisplacedIndexes.count() : 0); - - // check the target and displaced items were animated - model_targetItems_transitionFrom.matchAgainst(expectedTargetData, "wasn't animated from target 'from' pos", "shouldn't have been animated from target 'from' pos"); - model_displacedItems_transitionVia.matchAgainst(expectedDisplacedValues, "wasn't animated with displaced anim", "shouldn't have been animated with displaced anim"); - - // check attached properties - matchItemsAndIndexes(listview->property("targetTrans_items").toMap(), model, targetIndexes); - matchIndexLists(listview->property("targetTrans_targetIndexes").toList(), targetIndexes); - matchItemLists(listview->property("targetTrans_targetItems").toList(), targetItems); - if (expectedDisplacedIndexes.isValid()) { - // adjust expectedDisplacedIndexes to their final values after the move - QList displacedIndexes = adjustIndexesForAddDisplaced(expectedDisplacedIndexes.indexes, insertionIndex, insertionCount); - matchItemsAndIndexes(listview->property("displacedTrans_items").toMap(), model, displacedIndexes); - matchIndexLists(listview->property("displacedTrans_targetIndexes").toList(), targetIndexes); - matchItemLists(listview->property("displacedTrans_targetItems").toList(), targetItems); - } - - } else { - QTRY_COMPARE(model_targetItems_transitionFrom.count(), 0); - QTRY_COMPARE(model_displacedItems_transitionVia.count(), 0); - } - - QList items = findItems(contentItem, "wrapper"); - int firstVisibleIndex = -1; - int itemCount = items.count(); - for (int i=0; iy() >= contentY) { - QDeclarativeExpression e(qmlContext(items[i]), items[i], "index"); - firstVisibleIndex = e.evaluate().toInt(); - break; - } - } - QVERIFY2(firstVisibleIndex >= 0, QTest::toString(firstVisibleIndex)); - - // verify all items moved to the correct final positions - for (int i=firstVisibleIndex; i < model.count() && i < itemCount; ++i) { - QQuickItem *item = findItem(contentItem, "wrapper", i); - QVERIFY2(item, QTest::toString(QString("Item %1 not found").arg(i))); - QTRY_COMPARE(item->y(), i*20.0); - QQuickText *name = findItem(contentItem, "textName", i); - QVERIFY(name != 0); - QTRY_COMPARE(name->text(), model.name(i)); - } - - delete canvas; - delete testObject; -} - -void tst_QQuickListView::addTransitions_data() -{ - QTest::addColumn("initialItemCount"); - QTest::addColumn("contentY"); - QTest::addColumn("shouldAnimateTargets"); - QTest::addColumn("insertionIndex"); - QTest::addColumn("insertionCount"); - QTest::addColumn("expectedDisplacedIndexes"); - - // if inserting before visible index, items should not appear or animate in, even if there are > 1 new items - QTest::newRow("insert 1, just before start") - << 30 << 20.0 << false - << 0 << 1 << ListRange(); - QTest::newRow("insert 1, way before start") - << 30 << 20.0 << false - << 0 << 1 << ListRange(); - QTest::newRow("insert multiple, just before start") - << 30 << 100.0 << false - << 0 << 3 << ListRange(); - QTest::newRow("insert multiple, way before start") - << 30 << 100.0 << false - << 0 << 3 << ListRange(); - - QTest::newRow("insert 1 at start") - << 30 << 0.0 << true - << 0 << 1 << ListRange(0, 15); - QTest::newRow("insert multiple at start") - << 30 << 0.0 << true - << 0 << 3 << ListRange(0, 15); - QTest::newRow("insert 1 at start, content y not 0") - << 30 << 40.0 << true // first visible is index 2, so translate the displaced indexes by 2 - << 2 << 1 << ListRange(0 + 2, 15 + 2); - QTest::newRow("insert multiple at start, content y not 0") - << 30 << 40.0 << true // first visible is index 2 - << 2 << 3 << ListRange(0 + 2, 15 + 2); - - QTest::newRow("insert 1 at start, to empty list") - << 0 << 0.0 << true - << 0 << 1 << ListRange(); - QTest::newRow("insert multiple at start, to empty list") - << 0 << 0.0 << true - << 0 << 3 << ListRange(); - - QTest::newRow("insert 1 at middle") - << 30 << 0.0 << true - << 5 << 1 << ListRange(5, 15); - QTest::newRow("insert multiple at middle") - << 30 << 0.0 << true - << 5 << 3 << ListRange(5, 15); - - QTest::newRow("insert 1 at bottom") - << 30 << 0.0 << true - << 15 << 1 << ListRange(15, 15); - QTest::newRow("insert multiple at bottom") - << 30 << 0.0 << true - << 15 << 3 << ListRange(15, 15); - QTest::newRow("insert 1 at bottom, content y not 0") - << 30 << 20.0 * 3 << true - << 15 + 3 << 1 << ListRange(15 + 3, 15 + 3); - QTest::newRow("insert multiple at bottom, content y not 0") - << 30 << 20.0 * 3 << true - << 15 + 3 << 3 << ListRange(15 + 3, 15 + 3); - - // items added after the last visible will not be animated in, since they - // do not appear in the final view - QTest::newRow("insert 1 after end") - << 30 << 0.0 << false - << 17 << 1 << ListRange(); - QTest::newRow("insert multiple after end") - << 30 << 0.0 << false - << 17 << 3 << ListRange(); -} - -void tst_QQuickListView::moveTransitions() -{ - QFETCH(int, initialItemCount); - QFETCH(qreal, contentY); - QFETCH(qreal, itemsOffsetAfterMove); - QFETCH(int, moveFrom); - QFETCH(int, moveTo); - QFETCH(int, moveCount); - QFETCH(ListRange, expectedDisplacedIndexes); - - // target and displaced items should pass through these points - QPointF targetItems_transitionVia(-50, 50); - QPointF displacedItems_transitionVia(100, 100); - - QaimModel model; - for (int i = 0; i < initialItemCount; i++) - model.addItem("Original item" + QString::number(i), ""); - QaimModel model_targetItems_transitionVia; - QaimModel model_displacedItems_transitionVia; - - QQuickView *canvas = createView(); - QDeclarativeContext *ctxt = canvas->rootContext(); - TestObject *testObject = new TestObject; - ctxt->setContextProperty("testModel", &model); - ctxt->setContextProperty("model_targetItems_transitionVia", &model_targetItems_transitionVia); - ctxt->setContextProperty("model_displacedItems_transitionVia", &model_displacedItems_transitionVia); - ctxt->setContextProperty("targetItems_transitionVia", targetItems_transitionVia); - ctxt->setContextProperty("displacedItems_transitionVia", displacedItems_transitionVia); - ctxt->setContextProperty("testObject", testObject); - canvas->setSource(testFileUrl("moveTransitions.qml")); - canvas->show(); - - QQuickListView *listview = findItem(canvas->rootObject(), "list"); - QTRY_VERIFY(listview != 0); - QQuickItem *contentItem = listview->contentItem(); - QVERIFY(contentItem != 0); - QQuickText *name; - - if (contentY != 0) { - listview->setContentY(contentY); - QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false); - } - - QList > expectedDisplacedValues = expectedDisplacedIndexes.getModelDataValues(model); - - // Items moving to *or* from visible positions should be animated. - // Otherwise, they should not be animated. - QList > expectedTargetData; - QList targetIndexes; - for (int i=moveFrom; iheight()) / 20 - || toIndex < (contentY + listview->height()) / 20) { - expectedTargetData << qMakePair(model.name(i), model.number(i)); - targetIndexes << i; - } - } - // ViewTransition.index provides the indices that items are moving to, not from - targetIndexes = adjustIndexesForMove(targetIndexes, moveFrom, moveTo, moveCount); - - // start animation - model.moveItems(moveFrom, moveTo, moveCount); - - QTRY_COMPARE(listview->property("targetTransitionsDone").toInt(), expectedTargetData.count()); - QTRY_COMPARE(listview->property("displaceTransitionsDone").toInt(), - expectedDisplacedIndexes.isValid() ? expectedDisplacedIndexes.count() : 0); - - QList targetItems = findItems(contentItem, "wrapper", targetIndexes); - - // check the target and displaced items were animated - model_targetItems_transitionVia.matchAgainst(expectedTargetData, "wasn't animated from target 'from' pos", "shouldn't have been animated from target 'from' pos"); - model_displacedItems_transitionVia.matchAgainst(expectedDisplacedValues, "wasn't animated with displaced anim", "shouldn't have been animated with displaced anim"); - - // check attached properties - matchItemsAndIndexes(listview->property("targetTrans_items").toMap(), model, targetIndexes); - matchIndexLists(listview->property("targetTrans_targetIndexes").toList(), targetIndexes); - matchItemLists(listview->property("targetTrans_targetItems").toList(), targetItems); - if (expectedDisplacedIndexes.isValid()) { - // adjust expectedDisplacedIndexes to their final values after the move - QList displacedIndexes = adjustIndexesForMove(expectedDisplacedIndexes.indexes, moveFrom, moveTo, moveCount); - matchItemsAndIndexes(listview->property("displacedTrans_items").toMap(), model, displacedIndexes); - matchIndexLists(listview->property("displacedTrans_targetIndexes").toList(), targetIndexes); - matchItemLists(listview->property("displacedTrans_targetItems").toList(), targetItems); - } - - QList items = findItems(contentItem, "wrapper"); - int firstVisibleIndex = -1; - for (int i=0; iy() >= contentY) { - QDeclarativeExpression e(qmlContext(items[i]), items[i], "index"); - firstVisibleIndex = e.evaluate().toInt(); - break; - } - } - QVERIFY2(firstVisibleIndex >= 0, QTest::toString(firstVisibleIndex)); - - // verify all items moved to the correct final positions - int itemCount = findItems(contentItem, "wrapper").count(); - for (int i=firstVisibleIndex; i < model.count() && i < itemCount; ++i) { - QQuickItem *item = findItem(contentItem, "wrapper", i); - QVERIFY2(item, QTest::toString(QString("Item %1 not found").arg(i))); - QTRY_COMPARE(item->y(), i*20.0 + itemsOffsetAfterMove); - name = findItem(contentItem, "textName", i); - QVERIFY(name != 0); - QTRY_COMPARE(name->text(), model.name(i)); - } - - delete canvas; - delete testObject; -} - -void tst_QQuickListView::moveTransitions_data() -{ - QTest::addColumn("initialItemCount"); - QTest::addColumn("contentY"); - QTest::addColumn("itemsOffsetAfterMove"); - QTest::addColumn("moveFrom"); - QTest::addColumn("moveTo"); - QTest::addColumn("moveCount"); - QTest::addColumn("expectedDisplacedIndexes"); - - // when removing from above the visible, all items shift down depending on how many - // items have been removed from above the visible - QTest::newRow("move from above view, outside visible items, move 1") << 30 << 4*20.0 << 20.0 - << 1 << 10 << 1 << ListRange(11, 15+4); - QTest::newRow("move from above view, outside visible items, move 1 (first item)") << 30 << 4*20.0 << 20.0 - << 0 << 10 << 1 << ListRange(11, 15+4); - QTest::newRow("move from above view, outside visible items, move multiple") << 30 << 4*20.0 << 2*20.0 - << 1 << 10 << 2 << ListRange(12, 15+4); - QTest::newRow("move from above view, outside visible items, move multiple (first item)") << 30 << 4*20.0 << 3*20.0 - << 0 << 10 << 3 << ListRange(13, 15+4); - QTest::newRow("move from above view, mix of visible/non-visible") << 30 << 4*20.0 << 3*20.0 - << 1 << 10 << 5 << ListRange(6, 14) + ListRange(15, 15+4); - QTest::newRow("move from above view, mix of visible/non-visible (move first)") << 30 << 4*20.0 << 4*20.0 - << 0 << 10 << 5 << ListRange(5, 14) + ListRange(15, 15+4); - - QTest::newRow("move within view, move 1 down") << 30 << 0.0 << 0.0 - << 1 << 10 << 1 << ListRange(2, 10); - QTest::newRow("move within view, move 1 down, move first item") << 30 << 0.0 << 0.0 - << 0 << 10 << 1 << ListRange(1, 10); - QTest::newRow("move within view, move 1 down, move first item, contentY not 0") << 30 << 4*20.0 << 0.0 - << 0+4 << 10+4 << 1 << ListRange(1+4, 10+4); - QTest::newRow("move within view, move 1 down, to last item") << 30 << 0.0 << 0.0 - << 10 << 15 << 1 << ListRange(11, 15); - QTest::newRow("move within view, move first->last") << 30 << 0.0 << 0.0 - << 0 << 15 << 1 << ListRange(1, 15); - - QTest::newRow("move within view, move multiple down") << 30 << 0.0 << 0.0 - << 1 << 10 << 3 << ListRange(4, 12); - QTest::newRow("move within view, move multiple down, move first item") << 30 << 0.0 << 0.0 - << 0 << 10 << 3 << ListRange(3, 12); - QTest::newRow("move within view, move multiple down, move first item, contentY not 0") << 30 << 4*20.0 << 0.0 - << 0+4 << 10+4 << 3 << ListRange(3+4, 12+4); - QTest::newRow("move within view, move multiple down, displace last item") << 30 << 0.0 << 0.0 - << 5 << 13 << 3 << ListRange(8, 15); - QTest::newRow("move within view, move multiple down, move first->last") << 30 << 0.0 << 0.0 - << 0 << 13 << 3 << ListRange(3, 15); - - QTest::newRow("move within view, move 1 up") << 30 << 0.0 << 0.0 - << 10 << 1 << 1 << ListRange(1, 9); - QTest::newRow("move within view, move 1 up, move to first index") << 30 << 0.0 << 0.0 - << 10 << 0 << 1 << ListRange(0, 9); - QTest::newRow("move within view, move 1 up, move to first index, contentY not 0") << 30 << 4*20.0 << 0.0 - << 10+4 << 0+4 << 1 << ListRange(0+4, 9+4); - QTest::newRow("move within view, move 1 up, move to first index, contentY not on item border") << 30 << 4*20.0 - 10 << 0.0 - << 10+4 << 0+4 << 1 << ListRange(0+4, 9+4); - QTest::newRow("move within view, move 1 up, move last item") << 30 << 0.0 << 0.0 - << 15 << 10 << 1 << ListRange(10, 14); - QTest::newRow("move within view, move 1 up, move last->first") << 30 << 0.0 << 0.0 - << 15 << 0 << 1 << ListRange(0, 14); - - QTest::newRow("move within view, move multiple up") << 30 << 0.0 << 0.0 - << 10 << 1 << 3 << ListRange(1, 9); - QTest::newRow("move within view, move multiple up, move to first index") << 30 << 0.0 << 0.0 - << 10 << 0 << 3 << ListRange(0, 9); - QTest::newRow("move within view, move multiple up, move to first index, contentY not 0") << 30 << 4*20.0 << 0.0 - << 10+4 << 0+4 << 3 << ListRange(0+4, 9+4); - QTest::newRow("move within view, move multiple up, move last item") << 30 << 0.0 << 0.0 - << 13 << 5 << 3 << ListRange(5, 12); - QTest::newRow("move within view, move multiple up, move last->first") << 30 << 0.0 << 0.0 - << 13 << 0 << 3 << ListRange(0, 12); - - QTest::newRow("move from below view, move 1 up, move to top") << 30 << 0.0 << 0.0 - << 20 << 0 << 1 << ListRange(0, 15); - QTest::newRow("move from below view, move 1 up, move to top, contentY not 0") << 30 << 4*20.0 << 0.0 - << 25 << 4 << 1 << ListRange(0+4, 15+4); - QTest::newRow("move from below view, move multiple up, move to top") << 30 << 0.0 << 0.0 - << 20 << 0 << 3 << ListRange(0, 15); - QTest::newRow("move from below view, move multiple up, move to top, contentY not 0") << 30 << 4*20.0 << 0.0 - << 25 << 4 << 3 << ListRange(0+4, 15+4); - - QTest::newRow("move from below view, move 1 up, move to bottom") << 30 << 0.0 << 0.0 - << 20 << 15 << 1 << ListRange(15, 15); - QTest::newRow("move from below view, move 1 up, move to bottom, contentY not 0") << 30 << 4*20.0 << 0.0 - << 25 << 15+4 << 1 << ListRange(15+4, 15+4); - QTest::newRow("move from below view, move multiple up, move to to bottom") << 30 << 0.0 << 0.0 - << 20 << 15 << 3 << ListRange(15, 15); - QTest::newRow("move from below view, move multiple up, move to bottom, contentY not 0") << 30 << 4*20.0 << 0.0 - << 25 << 15+4 << 3 << ListRange(15+4, 15+4); -} - -void tst_QQuickListView::removeTransitions() -{ - QFETCH(int, initialItemCount); - QFETCH(bool, shouldAnimateTargets); - QFETCH(qreal, contentY); - QFETCH(int, removalIndex); - QFETCH(int, removalCount); - QFETCH(ListRange, expectedDisplacedIndexes); - - // added items should end here - QPointF targetItems_transitionTo(-50, -50); - - // displaced items should pass through this points - QPointF displacedItems_transitionVia(100, 100); - - QaimModel model; - for (int i = 0; i < initialItemCount; i++) - model.addItem("Original item" + QString::number(i), ""); - QaimModel model_targetItems_transitionTo; - QaimModel model_displacedItems_transitionVia; - - QQuickView *canvas = createView(); - QDeclarativeContext *ctxt = canvas->rootContext(); - TestObject *testObject = new TestObject; - ctxt->setContextProperty("testModel", &model); - ctxt->setContextProperty("model_targetItems_transitionTo", &model_targetItems_transitionTo); - ctxt->setContextProperty("model_displacedItems_transitionVia", &model_displacedItems_transitionVia); - ctxt->setContextProperty("targetItems_transitionTo", targetItems_transitionTo); - ctxt->setContextProperty("displacedItems_transitionVia", displacedItems_transitionVia); - ctxt->setContextProperty("testObject", testObject); - canvas->setSource(testFileUrl("removeTransitions.qml")); - canvas->show(); - - QQuickListView *listview = findItem(canvas->rootObject(), "list"); - QTRY_VERIFY(listview != 0); - QQuickItem *contentItem = listview->contentItem(); - QVERIFY(contentItem != 0); - QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false); - - if (contentY != 0) { - listview->setContentY(contentY); - QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false); - } - - QList > expectedDisplacedValues = expectedDisplacedIndexes.getModelDataValues(model); - - // only target items that are visible should be animated - QList > expectedTargetData; - QList targetIndexes; - if (shouldAnimateTargets) { - for (int i=removalIndex; i= contentY / 20 && i < (contentY + listview->height()) / 20) { - expectedTargetData << qMakePair(model.name(i), model.number(i)); - targetIndexes << i; - } - } - QVERIFY(expectedTargetData.count() > 0); - } - - // calculate targetItems and expectedTargets before model changes - QList targetItems = findItems(contentItem, "wrapper", targetIndexes); - QVariantMap expectedTargets; - for (int i=0; icount()); - - if (shouldAnimateTargets) { - QTRY_COMPARE(listview->property("targetTransitionsDone").toInt(), expectedTargetData.count()); - QTRY_COMPARE(listview->property("displaceTransitionsDone").toInt(), - expectedDisplacedIndexes.isValid() ? expectedDisplacedIndexes.count() : 0); - - // check the target and displaced items were animated - model_targetItems_transitionTo.matchAgainst(expectedTargetData, "wasn't animated to target 'to' pos", "shouldn't have been animated to target 'to' pos"); - model_displacedItems_transitionVia.matchAgainst(expectedDisplacedValues, "wasn't animated with displaced anim", "shouldn't have been animated with displaced anim"); - - // check attached properties - QCOMPARE(listview->property("targetTrans_items").toMap(), expectedTargets); - matchIndexLists(listview->property("targetTrans_targetIndexes").toList(), targetIndexes); - matchItemLists(listview->property("targetTrans_targetItems").toList(), targetItems); - if (expectedDisplacedIndexes.isValid()) { - // adjust expectedDisplacedIndexes to their final values after the move - QList displacedIndexes = adjustIndexesForRemoveDisplaced(expectedDisplacedIndexes.indexes, removalIndex, removalCount); - matchItemsAndIndexes(listview->property("displacedTrans_items").toMap(), model, displacedIndexes); - matchIndexLists(listview->property("displacedTrans_targetIndexes").toList(), targetIndexes); - matchItemLists(listview->property("displacedTrans_targetItems").toList(), targetItems); - } - } else { - QTRY_COMPARE(model_targetItems_transitionTo.count(), 0); - QTRY_COMPARE(model_displacedItems_transitionVia.count(), 0); - } - - QList items = findItems(contentItem, "wrapper"); - int firstVisibleIndex = -1; - int itemCount = items.count(); - - for (int i=0; iy() >= contentY) - firstVisibleIndex = index; - if (index < 0) - itemCount--; // exclude deleted items - } - QVERIFY2(firstVisibleIndex >= 0, QTest::toString(firstVisibleIndex)); - - // verify all items moved to the correct final positions - for (int i=firstVisibleIndex; i < model.count() && i < itemCount; ++i) { - QQuickItem *item = findItem(contentItem, "wrapper", i); - QVERIFY2(item, QTest::toString(QString("Item %1 not found").arg(i))); - QCOMPARE(item->x(), 0.0); - QCOMPARE(item->y(), contentY + (i-firstVisibleIndex) * 20.0); - QQuickText *name = findItem(contentItem, "textName", i); - QVERIFY(name != 0); - QTRY_COMPARE(name->text(), model.name(i)); - } - - delete canvas; - delete testObject; -} - -void tst_QQuickListView::removeTransitions_data() -{ - QTest::addColumn("initialItemCount"); - QTest::addColumn("contentY"); - QTest::addColumn("shouldAnimateTargets"); - QTest::addColumn("removalIndex"); - QTest::addColumn("removalCount"); - QTest::addColumn("expectedDisplacedIndexes"); - - // All items that are visible following the remove operation should be animated. - // Remove targets that are outside of the view should not be animated. - - QTest::newRow("remove 1 before start") - << 30 << 20.0 * 3 << false - << 2 << 1 << ListRange(); - QTest::newRow("remove multiple, all before start") - << 30 << 20.0 * 3 << false - << 0 << 3 << ListRange(); - QTest::newRow("remove mix of before and after start") - << 30 << 20.0 * 3 << true - << 2 << 3 << ListRange(5, 20); // 5-20 are visible after the remove - - QTest::newRow("remove 1 from start") - << 30 << 0.0 << true - << 0 << 1 << ListRange(1, 16); // 1-16 are visible after the remove - QTest::newRow("remove multiple from start") - << 30 << 0.0 << true - << 0 << 3 << ListRange(3, 18); // 3-18 are visible after the remove - QTest::newRow("remove 1 from start, content y not 0") - << 30 << 20.0 * 2 << true // first visible is index 2, so translate the displaced indexes by 2 - << 2 << 1 << ListRange(1 + 2, 16 + 2); - QTest::newRow("remove multiple from start, content y not 0") - << 30 << 20.0 * 2 << true // first visible is index 2 - << 2 << 3 << ListRange(3 + 2, 18 + 2); - - QTest::newRow("remove 1 from middle") - << 30 << 0.0 << true - << 5 << 1 << ListRange(6, 16); - QTest::newRow("remove multiple from middle") - << 30 << 0.0 << true - << 5 << 3 << ListRange(8, 18); - - - QTest::newRow("remove 1 from bottom") - << 30 << 0.0 << true - << 15 << 1 << ListRange(16, 16); - - // remove 15, 16, 17 - // 15 will animate as the target item, 16 & 17 won't be animated since they are outside - // the view, and 18 will be animated as the displaced item to replace the last item - QTest::newRow("remove multiple from bottom") - << 30 << 0.0 << true - << 15 << 3 << ListRange(18, 18); - - QTest::newRow("remove 1 from bottom, content y not 0") - << 30 << 20.0 * 2 << true - << 15 + 2 << 1 << ListRange(16 + 2, 16 + 2); - QTest::newRow("remove multiple from bottom, content y not 0") - << 30 << 20.0 * 2 << true - << 15 + 2 << 3 << ListRange(18 + 2, 18 + 2); - - - QTest::newRow("remove 1 after end") - << 30 << 0.0 << false - << 17 << 1 << ListRange(); - QTest::newRow("remove multiple after end") - << 30 << 0.0 << false - << 17 << 3 << ListRange(); -} - -void tst_QQuickListView::multipleTransitions() -{ - // Tests that if you interrupt a transition in progress with another action that - // cancels the previous transition, the resulting items are still placed correctly. - - QFETCH(int, initialCount); - QFETCH(qreal, contentY); - QFETCH(QList, changes); - - // add transitions on the left, moves on the right - QPointF addTargets_transitionFrom(-50, -50); - QPointF addDisplaced_transitionFrom(-50, 50); - QPointF moveTargets_transitionFrom(50, -50); - QPointF moveDisplaced_transitionFrom(50, 50); - - QmlListModel model; - for (int i = 0; i < initialCount; i++) - model.addItem("Original item" + QString::number(i), ""); - - QQuickView *canvas = createView(); - QDeclarativeContext *ctxt = canvas->rootContext(); - TestObject *testObject = new TestObject; - ctxt->setContextProperty("testModel", &model); - ctxt->setContextProperty("testObject", testObject); - ctxt->setContextProperty("addTargets_transitionFrom", addTargets_transitionFrom); - ctxt->setContextProperty("addDisplaced_transitionFrom", addDisplaced_transitionFrom); - ctxt->setContextProperty("moveTargets_transitionFrom", moveTargets_transitionFrom); - ctxt->setContextProperty("moveDisplaced_transitionFrom", moveDisplaced_transitionFrom); - canvas->setSource(testFileUrl("multipleTransitions.qml")); - canvas->show(); - - QQuickListView *listview = findItem(canvas->rootObject(), "list"); - QTRY_VERIFY(listview != 0); - QQuickItem *contentItem = listview->contentItem(); - QVERIFY(contentItem != 0); - QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false); - - int timeBetweenActions = canvas->rootObject()->property("timeBetweenActions").toInt(); - - QList > targetItems; - for (int i=0; icount()); - QTRY_VERIFY(listview->property("runningAddTargets").toBool()); - QTRY_VERIFY(listview->property("runningAddDisplaced").toBool()); - if (i == changes.count() - 1) { - QTRY_VERIFY(!listview->property("runningAddTargets").toBool()); - QTRY_VERIFY(!listview->property("runningAddDisplaced").toBool()); - } else { - QTest::qWait(timeBetweenActions); - } - break; - } - case ListChange::Removed: - for (int j=changes[i].index; jcount()); - QTRY_VERIFY(listview->property("runningRemoveTargets").toBool()); - QTRY_VERIFY(listview->property("runningRemoveDisplaced").toBool()); - if (i == changes.count() - 1) { - QTRY_VERIFY(!listview->property("runningRemoveTargets").toBool()); - QTRY_VERIFY(!listview->property("runningRemoveDisplaced").toBool()); - } else { - QTest::qWait(timeBetweenActions); - } - break; - case ListChange::Moved: - for (int j=changes[i].index; jproperty("runningMoveTargets").toBool()); - QTRY_VERIFY(listview->property("runningMoveDisplaced").toBool()); - if (i == changes.count() - 1) { - QTRY_VERIFY(!listview->property("runningMoveTargets").toBool()); - QTRY_VERIFY(!listview->property("runningMoveDisplaced").toBool()); - } else { - QTest::qWait(timeBetweenActions); - } - break; - case ListChange::SetCurrent: - listview->setCurrentIndex(changes[i].index); - break; - case ListChange::SetContentY: - listview->setContentY(changes[i].pos); - QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false); - break; - } - } - QCOMPARE(listview->count(), model.count()); - - QList items = findItems(contentItem, "wrapper"); - int firstVisibleIndex = -1; - for (int i=0; iy() >= contentY) { - QDeclarativeExpression e(qmlContext(items[i]), items[i], "index"); - firstVisibleIndex = e.evaluate().toInt(); - break; - } - } - QVERIFY2(firstVisibleIndex >= 0, QTest::toString(firstVisibleIndex)); - - // verify all items moved to the correct final positions - int itemCount = findItems(contentItem, "wrapper").count(); - for (int i=firstVisibleIndex; i < model.count() && i < itemCount; ++i) { - QQuickItem *item = findItem(contentItem, "wrapper", i); - QVERIFY2(item, QTest::toString(QString("Item %1 not found").arg(i))); - QTRY_COMPARE(item->x(), 0.0); - QTRY_COMPARE(item->y(), i*20.0); - QQuickText *name = findItem(contentItem, "textName", i); - QVERIFY(name != 0); - QTRY_COMPARE(name->text(), model.name(i)); - } - - delete canvas; - delete testObject; -} - -void tst_QQuickListView::multipleTransitions_data() -{ - QTest::addColumn("initialCount"); - QTest::addColumn("contentY"); - QTest::addColumn >("changes"); - - // the added item and displaced items should move to final dest correctly - QTest::newRow("add item, then move it immediately") << 10 << 0.0 << (QList() - << ListChange::insert(0, 1) - << ListChange::move(0, 3, 1) - ); - - // items affected by the add should change from move to add transition - QTest::newRow("move, then insert item before the moved item") << 20 << 0.0 << (QList() - << ListChange::move(1, 10, 3) - << ListChange::insert(0, 1) - ); - - // items should be placed correctly if you trigger a transition then refill for that index - QTest::newRow("add at 0, flick down, flick back to top and add at 0 again") << 20 << 0.0 << (QList() - << ListChange::insert(0, 1) - << ListChange::setContentY(80.0) - << ListChange::setContentY(0.0) - << ListChange::insert(0, 1) - ); -} - -QList tst_QQuickListView::toIntList(const QVariantList &list) -{ - QList ret; - bool ok = true; - for (int i=0; i &expectedIndexes) -{ - for (int i=0; i current = indexLists[i].value >().toSet(); - if (current != expectedIndexes.toSet()) - qDebug() << "Cannot match actual targets" << current << "with expected" << expectedIndexes; - QCOMPARE(current, expectedIndexes.toSet()); - } -} - -void tst_QQuickListView::matchItemsAndIndexes(const QVariantMap &items, const QaimModel &model, const QList &expectedIndexes) -{ - for (QVariantMap::const_iterator it = items.begin(); it != items.end(); ++it) { - QVERIFY(it.value().type() == QVariant::Int); - QString name = it.key(); - int itemIndex = it.value().toInt(); - QVERIFY2(expectedIndexes.contains(itemIndex), QTest::toString(QString("Index %1 not found in expectedIndexes").arg(itemIndex))); - if (model.name(itemIndex) != name) - qDebug() << itemIndex; - QCOMPARE(model.name(itemIndex), name); - } - QCOMPARE(items.count(), expectedIndexes.count()); -} - -void tst_QQuickListView::matchItemLists(const QVariantList &itemLists, const QList &expectedItems) -{ - for (int i=0; i(current[j].value()); - QVERIFY2(o, QTest::toString(QString("Invalid actual item at %1").arg(j))); - QVERIFY2(expectedItems.contains(o), QTest::toString(QString("Cannot match item %1").arg(j))); - } - QCOMPARE(current.count(), expectedItems.count()); - } -} - - -QTEST_MAIN(tst_QQuickListView) - -#include "tst_qquicklistview.moc" - diff --git a/tests/auto/qtquick2/qquickloader/data/ActiveComponent.qml b/tests/auto/qtquick2/qquickloader/data/ActiveComponent.qml deleted file mode 100644 index 24c6f7ad91..0000000000 --- a/tests/auto/qtquick2/qquickloader/data/ActiveComponent.qml +++ /dev/null @@ -1,11 +0,0 @@ -import QtQuick 2.0 - -Item { - id: behaviorCounter - property int behaviorCount: 0 - property int canary: 0 - - Behavior on canary { - NumberAnimation { target: behaviorCounter; property: "behaviorCount"; to: (behaviorCounter.behaviorCount + 1); duration: 0 } - } -} diff --git a/tests/auto/qtquick2/qquickloader/data/AnchoredLoader.qml b/tests/auto/qtquick2/qquickloader/data/AnchoredLoader.qml deleted file mode 100644 index 1a2a620d7f..0000000000 --- a/tests/auto/qtquick2/qquickloader/data/AnchoredLoader.qml +++ /dev/null @@ -1,14 +0,0 @@ -import QtQuick 2.0 - -Rectangle { - width: 300 - height: 200 - color: "blue" - Loader { - objectName: "loader" - anchors.fill: parent - sourceComponent: Component { - Rectangle { color: "red"; objectName: "sourceElement" } - } - } -} diff --git a/tests/auto/qtquick2/qquickloader/data/BigComponent.qml b/tests/auto/qtquick2/qquickloader/data/BigComponent.qml deleted file mode 100644 index df92532c43..0000000000 --- a/tests/auto/qtquick2/qquickloader/data/BigComponent.qml +++ /dev/null @@ -1,5015 +0,0 @@ -import QtQuick 2.0 - -Item { - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} -} diff --git a/tests/auto/qtquick2/qquickloader/data/BlueRect.qml b/tests/auto/qtquick2/qquickloader/data/BlueRect.qml deleted file mode 100644 index e96ac00f21..0000000000 --- a/tests/auto/qtquick2/qquickloader/data/BlueRect.qml +++ /dev/null @@ -1,8 +0,0 @@ -import QtQuick 2.0 - -Rectangle { - objectName: "blue" - width: 100 - height: 100 - color: "blue" -} diff --git a/tests/auto/qtquick2/qquickloader/data/CreationContextLoader.qml b/tests/auto/qtquick2/qquickloader/data/CreationContextLoader.qml deleted file mode 100644 index 4dd73e797c..0000000000 --- a/tests/auto/qtquick2/qquickloader/data/CreationContextLoader.qml +++ /dev/null @@ -1,15 +0,0 @@ -import QtQuick 2.0 - -Loader { - id: myLoader - property int testProperty: 1912 - sourceComponent: loaderComponent - Component { - id: loaderComponent - Item { - Component.onCompleted: { - test = (myLoader.testProperty == 1912); - } - } - } -} diff --git a/tests/auto/qtquick2/qquickloader/data/GraphicsWidget250x250.qml b/tests/auto/qtquick2/qquickloader/data/GraphicsWidget250x250.qml deleted file mode 100644 index dae8e3fbbb..0000000000 --- a/tests/auto/qtquick2/qquickloader/data/GraphicsWidget250x250.qml +++ /dev/null @@ -1,5 +0,0 @@ -import QtQuick 2.0 - -QGraphicsWidget { - size: "250x250" -} diff --git a/tests/auto/qtquick2/qquickloader/data/GreenRect.qml b/tests/auto/qtquick2/qquickloader/data/GreenRect.qml deleted file mode 100644 index 99cefaf176..0000000000 --- a/tests/auto/qtquick2/qquickloader/data/GreenRect.qml +++ /dev/null @@ -1,7 +0,0 @@ -import QtQuick 2.0 - -Rectangle { - width: 100; height: 100 - color: "green" - Component.onCompleted: myLoader.source = "BlueRect.qml" -} diff --git a/tests/auto/qtquick2/qquickloader/data/InitialPropertyValuesComponent.qml b/tests/auto/qtquick2/qquickloader/data/InitialPropertyValuesComponent.qml deleted file mode 100644 index 24c6f7ad91..0000000000 --- a/tests/auto/qtquick2/qquickloader/data/InitialPropertyValuesComponent.qml +++ /dev/null @@ -1,11 +0,0 @@ -import QtQuick 2.0 - -Item { - id: behaviorCounter - property int behaviorCount: 0 - property int canary: 0 - - Behavior on canary { - NumberAnimation { target: behaviorCounter; property: "behaviorCount"; to: (behaviorCounter.behaviorCount + 1); duration: 0 } - } -} diff --git a/tests/auto/qtquick2/qquickloader/data/InvalidSourceComponent.qml b/tests/auto/qtquick2/qquickloader/data/InvalidSourceComponent.qml deleted file mode 100644 index 7efa4a5f61..0000000000 --- a/tests/auto/qtquick2/qquickloader/data/InvalidSourceComponent.qml +++ /dev/null @@ -1,5 +0,0 @@ -import QtQuick 2.0 - -Item { - RandomError -} diff --git a/tests/auto/qtquick2/qquickloader/data/NoResize.qml b/tests/auto/qtquick2/qquickloader/data/NoResize.qml deleted file mode 100644 index 9b3ea6410b..0000000000 --- a/tests/auto/qtquick2/qquickloader/data/NoResize.qml +++ /dev/null @@ -1,8 +0,0 @@ -import QtQuick 2.0 - -Item { - width: 200; height: 80 - Loader { - source: "Rect120x60.qml" - } -} diff --git a/tests/auto/qtquick2/qquickloader/data/NoResizeGraphicsWidget.qml b/tests/auto/qtquick2/qquickloader/data/NoResizeGraphicsWidget.qml deleted file mode 100644 index c0f51d8c35..0000000000 --- a/tests/auto/qtquick2/qquickloader/data/NoResizeGraphicsWidget.qml +++ /dev/null @@ -1,9 +0,0 @@ -import QtQuick 2.0 - -Item { - width: 200 - height: 80 - Loader { - source: "GraphicsWidget250x250.qml" - } -} diff --git a/tests/auto/qtquick2/qquickloader/data/QTBUG_16928.qml b/tests/auto/qtquick2/qquickloader/data/QTBUG_16928.qml deleted file mode 100644 index 903d7f0812..0000000000 --- a/tests/auto/qtquick2/qquickloader/data/QTBUG_16928.qml +++ /dev/null @@ -1,23 +0,0 @@ -import QtQuick 2.0 - -Rectangle { - color: "green" - width: loader.implicitWidth+50 - height: loader.implicitHeight+50 - - Loader { - id: loader - sourceComponent: Item { - anchors.centerIn: parent - - implicitWidth: 200 - implicitHeight: 200 - Rectangle { - color: "red" - anchors.fill: parent - } - } - anchors.fill: parent - anchors.margins: 15 - } -} diff --git a/tests/auto/qtquick2/qquickloader/data/QTBUG_17114.qml b/tests/auto/qtquick2/qquickloader/data/QTBUG_17114.qml deleted file mode 100644 index 7402037553..0000000000 --- a/tests/auto/qtquick2/qquickloader/data/QTBUG_17114.qml +++ /dev/null @@ -1,18 +0,0 @@ -import QtQuick 2.0 - -Rectangle { - property real loaderWidth: loader.width - property real loaderHeight: loader.height - width: 200 - height: 200 - - Loader { - id: loader - sourceComponent: Item { - property real iwidth: 32 - property real iheight: 32 - width: iwidth - height: iheight - } - } -} diff --git a/tests/auto/qtquick2/qquickloader/data/Rect120x60.qml b/tests/auto/qtquick2/qquickloader/data/Rect120x60.qml deleted file mode 100644 index fc9e447e69..0000000000 --- a/tests/auto/qtquick2/qquickloader/data/Rect120x60.qml +++ /dev/null @@ -1,6 +0,0 @@ -import QtQuick 2.0 - -Rectangle { - width: 120 - height:60 -} diff --git a/tests/auto/qtquick2/qquickloader/data/SetSourceComponent.qml b/tests/auto/qtquick2/qquickloader/data/SetSourceComponent.qml deleted file mode 100644 index 83cc358f7d..0000000000 --- a/tests/auto/qtquick2/qquickloader/data/SetSourceComponent.qml +++ /dev/null @@ -1,9 +0,0 @@ -import QtQuick 2.0 - -Item { - function clear() { - loader.sourceComponent = undefined - } - Component { id: comp; Rectangle { width: 100; height: 50 } } - Loader { id: loader; sourceComponent: comp } -} diff --git a/tests/auto/qtquick2/qquickloader/data/SizeGraphicsWidgetToLoader.qml b/tests/auto/qtquick2/qquickloader/data/SizeGraphicsWidgetToLoader.qml deleted file mode 100644 index 2a63b4d34f..0000000000 --- a/tests/auto/qtquick2/qquickloader/data/SizeGraphicsWidgetToLoader.qml +++ /dev/null @@ -1,7 +0,0 @@ -import QtQuick 2.0 - -Loader { - width: 200 - height: 80 - source: "GraphicsWidget250x250.qml" -} diff --git a/tests/auto/qtquick2/qquickloader/data/SizeLoaderToGraphicsWidget.qml b/tests/auto/qtquick2/qquickloader/data/SizeLoaderToGraphicsWidget.qml deleted file mode 100644 index a9875d8e21..0000000000 --- a/tests/auto/qtquick2/qquickloader/data/SizeLoaderToGraphicsWidget.qml +++ /dev/null @@ -1,5 +0,0 @@ -import QtQuick 2.0 - -Loader { - source: "GraphicsWidget250x250.qml" -} diff --git a/tests/auto/qtquick2/qquickloader/data/SizeToItem.qml b/tests/auto/qtquick2/qquickloader/data/SizeToItem.qml deleted file mode 100644 index 866365754f..0000000000 --- a/tests/auto/qtquick2/qquickloader/data/SizeToItem.qml +++ /dev/null @@ -1,5 +0,0 @@ -import QtQuick 2.0 - -Loader { - source: "Rect120x60.qml" -} diff --git a/tests/auto/qtquick2/qquickloader/data/SizeToLoader.qml b/tests/auto/qtquick2/qquickloader/data/SizeToLoader.qml deleted file mode 100644 index dad18c6939..0000000000 --- a/tests/auto/qtquick2/qquickloader/data/SizeToLoader.qml +++ /dev/null @@ -1,6 +0,0 @@ -import QtQuick 2.0 - -Loader { - width: 200; height: 80 - source: "Rect120x60.qml" -} diff --git a/tests/auto/qtquick2/qquickloader/data/VmeError.qml b/tests/auto/qtquick2/qquickloader/data/VmeError.qml deleted file mode 100644 index 0443aa9054..0000000000 --- a/tests/auto/qtquick2/qquickloader/data/VmeError.qml +++ /dev/null @@ -1,7 +0,0 @@ -import QtQuick 2.0 - -Rectangle { - width: 100; height: 100; color: "red" - signal somethingHappened - onSomethingHappened: QtObject {} -} diff --git a/tests/auto/qtquick2/qquickloader/data/active.1.qml b/tests/auto/qtquick2/qquickloader/data/active.1.qml deleted file mode 100644 index 2dbd1a0887..0000000000 --- a/tests/auto/qtquick2/qquickloader/data/active.1.qml +++ /dev/null @@ -1,31 +0,0 @@ -import QtQuick 2.0 - -Item { - id: root - - Loader { - id: loader - objectName: "loader" - active: false - } - - Component { - id: inlineTestComponent - Item { - id: inlineTestItem - property int someProperty: 5 - } - } - - function doSetSource() { - loader.source = "ActiveComponent.qml"; - } - - function doSetSourceComponent() { - loader.sourceComponent = inlineTestComponent; - } - - function doSetActive() { - loader.active = true; - } -} diff --git a/tests/auto/qtquick2/qquickloader/data/active.2.qml b/tests/auto/qtquick2/qquickloader/data/active.2.qml deleted file mode 100644 index e561744c63..0000000000 --- a/tests/auto/qtquick2/qquickloader/data/active.2.qml +++ /dev/null @@ -1,18 +0,0 @@ -import QtQuick 2.0 - -Item { - id: root - - Loader { - id: loader - objectName: "loader" - source: "ActiveComponent.qml"; - - property int statusChangedCount: 0 - onStatusChanged: statusChangedCount = statusChangedCount + 1 - } - - function doSetInactive() { - loader.active = false; - } -} diff --git a/tests/auto/qtquick2/qquickloader/data/active.3.qml b/tests/auto/qtquick2/qquickloader/data/active.3.qml deleted file mode 100644 index 0fbba959bb..0000000000 --- a/tests/auto/qtquick2/qquickloader/data/active.3.qml +++ /dev/null @@ -1,18 +0,0 @@ -import QtQuick 2.0 - -Item { - id: root - - Loader { - id: loader - objectName: "loader" - source: "ActiveComponent.qml"; - - property int sourceChangedCount: 0 - onSourceChanged: sourceChangedCount = sourceChangedCount + 1 - } - - function doSetInactive() { - loader.active = false; - } -} diff --git a/tests/auto/qtquick2/qquickloader/data/active.4.qml b/tests/auto/qtquick2/qquickloader/data/active.4.qml deleted file mode 100644 index 63fd46e2da..0000000000 --- a/tests/auto/qtquick2/qquickloader/data/active.4.qml +++ /dev/null @@ -1,26 +0,0 @@ -import QtQuick 2.0 - -Item { - id: root - - Component { - id: inlineTestComponent - Item { - id: inlineTestItem - property int someProperty: 5 - } - } - - Loader { - id: loader - objectName: "loader" - sourceComponent: inlineTestComponent - - property int sourceComponentChangedCount: 0 - onSourceComponentChanged: sourceComponentChangedCount = sourceComponentChangedCount + 1 - } - - function doSetInactive() { - loader.active = false; - } -} diff --git a/tests/auto/qtquick2/qquickloader/data/active.5.qml b/tests/auto/qtquick2/qquickloader/data/active.5.qml deleted file mode 100644 index 903f458a41..0000000000 --- a/tests/auto/qtquick2/qquickloader/data/active.5.qml +++ /dev/null @@ -1,18 +0,0 @@ -import QtQuick 2.0 - -Item { - id: root - - Loader { - id: loader - objectName: "loader" - source: "ActiveComponent.qml"; - - property int itemChangedCount: 0 - onItemChanged: itemChangedCount = itemChangedCount + 1 - } - - function doSetInactive() { - loader.active = false; - } -} diff --git a/tests/auto/qtquick2/qquickloader/data/active.6.qml b/tests/auto/qtquick2/qquickloader/data/active.6.qml deleted file mode 100644 index f769a4e184..0000000000 --- a/tests/auto/qtquick2/qquickloader/data/active.6.qml +++ /dev/null @@ -1,21 +0,0 @@ -import QtQuick 2.0 - -Item { - id: root - - Loader { - id: loader - objectName: "loader" - - property int activeChangedCount: 0 - onActiveChanged: activeChangedCount = activeChangedCount + 1 - } - - function doSetActive() { - loader.active = true; - } - - function doSetInactive() { - loader.active = false; - } -} diff --git a/tests/auto/qtquick2/qquickloader/data/active.7.qml b/tests/auto/qtquick2/qquickloader/data/active.7.qml deleted file mode 100644 index a29e932f5e..0000000000 --- a/tests/auto/qtquick2/qquickloader/data/active.7.qml +++ /dev/null @@ -1,14 +0,0 @@ -import QtQuick 2.0 -Rectangle { - id: root - color: "blue" - width: 100; height: 100 - property bool success: true - - Loader { - active: false - anchors.fill: parent - sourceComponent: Rectangle { color: "red" } - onLoaded: { root.success = false; } // shouldn't be triggered if active is false - } -} diff --git a/tests/auto/qtquick2/qquickloader/data/active.8.qml b/tests/auto/qtquick2/qquickloader/data/active.8.qml deleted file mode 100644 index 3a66d3e99a..0000000000 --- a/tests/auto/qtquick2/qquickloader/data/active.8.qml +++ /dev/null @@ -1,13 +0,0 @@ -import QtQuick 2.0 -Rectangle { - id: root - color: "blue" - width: 100; height: 100 - property bool success: false - - Loader { - anchors.fill: parent - sourceComponent: Rectangle { color: "red" } - onLoaded: { root.success = true; } // should be triggered since active is true by default - } -} diff --git a/tests/auto/qtquick2/qquickloader/data/asynchronous.qml b/tests/auto/qtquick2/qquickloader/data/asynchronous.qml deleted file mode 100644 index 29570525ad..0000000000 --- a/tests/auto/qtquick2/qquickloader/data/asynchronous.qml +++ /dev/null @@ -1,16 +0,0 @@ -import QtQuick 2.0 - -Rectangle { - width: 400; height: 400 - - property string comp - function loadComponent() { - loader.source = comp - } - - Loader { - id: loader - objectName: "loader" - asynchronous: true - } -} diff --git a/tests/auto/qtquick2/qquickloader/data/crash.qml b/tests/auto/qtquick2/qquickloader/data/crash.qml deleted file mode 100644 index e6ddc33a10..0000000000 --- a/tests/auto/qtquick2/qquickloader/data/crash.qml +++ /dev/null @@ -1,14 +0,0 @@ -import QtQuick 2.0 - -Rectangle { - width: 400 - height: 400 - - function setLoaderSource() { - myLoader.source = "GreenRect.qml" - } - - Loader { - id: myLoader - } -} diff --git a/tests/auto/qtquick2/qquickloader/data/creationContext.qml b/tests/auto/qtquick2/qquickloader/data/creationContext.qml deleted file mode 100644 index 17a596cc74..0000000000 --- a/tests/auto/qtquick2/qquickloader/data/creationContext.qml +++ /dev/null @@ -1,8 +0,0 @@ -import QtQuick 2.0 - -Item { - property bool test: false - - CreationContextLoader { - } -} diff --git a/tests/auto/qtquick2/qquickloader/data/differentorigin.qml b/tests/auto/qtquick2/qquickloader/data/differentorigin.qml deleted file mode 100644 index 56a3034fe0..0000000000 --- a/tests/auto/qtquick2/qquickloader/data/differentorigin.qml +++ /dev/null @@ -1,3 +0,0 @@ -import QtQuick 2.0 - -Loader { source: "http://evil.place/evil.qml" } diff --git a/tests/auto/qtquick2/qquickloader/data/implicitSize.qml b/tests/auto/qtquick2/qquickloader/data/implicitSize.qml deleted file mode 100644 index 5c8c8348ed..0000000000 --- a/tests/auto/qtquick2/qquickloader/data/implicitSize.qml +++ /dev/null @@ -1,28 +0,0 @@ -import QtQuick 2.0 - -Rectangle { - property real implWidth: 0 - property real implHeight: 0 - color: "green" - width: loader.implicitWidth+50 - height: loader.implicitHeight+50 - - Loader { - id: loader - sourceComponent: Item { - anchors.centerIn: parent - - implicitWidth: 100 - implicitHeight: 100 - Rectangle { - color: "red" - anchors.fill: parent - } - } - - anchors.fill: parent - anchors.margins: 50 - onImplicitWidthChanged: implWidth = implicitWidth - onImplicitHeightChanged: implHeight = loader.implicitHeight - } -} diff --git a/tests/auto/qtquick2/qquickloader/data/initialPropertyValues.1.qml b/tests/auto/qtquick2/qquickloader/data/initialPropertyValues.1.qml deleted file mode 100644 index ae371797ce..0000000000 --- a/tests/auto/qtquick2/qquickloader/data/initialPropertyValues.1.qml +++ /dev/null @@ -1,22 +0,0 @@ -import QtQuick 2.0 - -Item { - id: root - property int initialValue: 0 - property int behaviorCount: 0 - - Loader { - id: loader - objectName: "loader" - - onLoaded: { - loader.item.canary = 1; // will trigger the behavior, setting behaviorCount -> 1 - } - } - - Component.onCompleted: { - loader.source = "InitialPropertyValuesComponent.qml"; - root.initialValue = loader.item.canary; // should be one, since onLoaded will have triggered by now - root.behaviorCount = loader.item.behaviorCount; // should be one, since onLoaded will have triggered by now - } -} diff --git a/tests/auto/qtquick2/qquickloader/data/initialPropertyValues.2.qml b/tests/auto/qtquick2/qquickloader/data/initialPropertyValues.2.qml deleted file mode 100644 index 76c7bc2fd6..0000000000 --- a/tests/auto/qtquick2/qquickloader/data/initialPropertyValues.2.qml +++ /dev/null @@ -1,20 +0,0 @@ -import QtQuick 2.0 - -Item { - id: root - property int initialValue: 0 - property int behaviorCount: 0 - - Loader { - id: loader - objectName: "loader" - onLoaded: { - root.initialValue = loader.item.canary; // should be two - root.behaviorCount = loader.item.behaviorCount; // should be zero - } - } - - Component.onCompleted: { - loader.setSource("InitialPropertyValuesComponent.qml", {"canary": 2}); - } -} diff --git a/tests/auto/qtquick2/qquickloader/data/initialPropertyValues.3.qml b/tests/auto/qtquick2/qquickloader/data/initialPropertyValues.3.qml deleted file mode 100644 index 3b08e6ee42..0000000000 --- a/tests/auto/qtquick2/qquickloader/data/initialPropertyValues.3.qml +++ /dev/null @@ -1,18 +0,0 @@ -import QtQuick 2.0 - -Item { - id: root - property int initialValue: 0 - property int behaviorCount: 0 - - Loader { - id: loader - objectName: "loader" - active: false - } - - Component.onCompleted: { - loader.setSource("InitialPropertyValuesComponent.qml", {"canary": 3}); - root.initialValue = loader.item.canary; // error - item should not yet exist. - } -} diff --git a/tests/auto/qtquick2/qquickloader/data/initialPropertyValues.4.qml b/tests/auto/qtquick2/qquickloader/data/initialPropertyValues.4.qml deleted file mode 100644 index e8310044e8..0000000000 --- a/tests/auto/qtquick2/qquickloader/data/initialPropertyValues.4.qml +++ /dev/null @@ -1,22 +0,0 @@ -import QtQuick 2.0 - -Item { - id: root - property int initialValue: 0 - property int behaviorCount: 0 - - Loader { - id: loader - objectName: "loader" - active: false - onLoaded: { - root.initialValue = loader.item.canary; // should be four - root.behaviorCount = loader.item.behaviorCount; // should be zero - } - } - - Component.onCompleted: { - loader.setSource("InitialPropertyValuesComponent.qml", {"canary": 4}); - loader.active = true - } -} diff --git a/tests/auto/qtquick2/qquickloader/data/initialPropertyValues.5.qml b/tests/auto/qtquick2/qquickloader/data/initialPropertyValues.5.qml deleted file mode 100644 index 03ee599aba..0000000000 --- a/tests/auto/qtquick2/qquickloader/data/initialPropertyValues.5.qml +++ /dev/null @@ -1,20 +0,0 @@ -import QtQuick 2.0 - -Item { - id: root - property int initialValue: 0 - property int behaviorCount: 0 - - Loader { - id: loader - objectName: "loader" - onLoaded: { - root.initialValue = loader.item.canary; // should be zero, but no error - root.behaviorCount = loader.item.behaviorCount; // should be zero - } - } - - Component.onCompleted: { - loader.setSource("InitialPropertyValuesComponent.qml"); - } -} diff --git a/tests/auto/qtquick2/qquickloader/data/initialPropertyValues.6.qml b/tests/auto/qtquick2/qquickloader/data/initialPropertyValues.6.qml deleted file mode 100644 index 66452b512b..0000000000 --- a/tests/auto/qtquick2/qquickloader/data/initialPropertyValues.6.qml +++ /dev/null @@ -1,25 +0,0 @@ -import QtQuick 2.0 - -Item { - id: root - property int initialValue: 0 - property int behaviorCount: 0 - - Loader { - id: loader - objectName: "loader" - onLoaded: { - root.initialValue = loader.item.canary; // should be six - root.behaviorCount = loader.item.behaviorCount; // should be zero - } - } - - Item { - id: child - property int bindable: 6 - } - - Component.onCompleted: { - loader.setSource("InitialPropertyValuesComponent.qml", {"canary": child.bindable}); - } -} diff --git a/tests/auto/qtquick2/qquickloader/data/initialPropertyValues.7.qml b/tests/auto/qtquick2/qquickloader/data/initialPropertyValues.7.qml deleted file mode 100644 index 02349f7ddf..0000000000 --- a/tests/auto/qtquick2/qquickloader/data/initialPropertyValues.7.qml +++ /dev/null @@ -1,29 +0,0 @@ -import QtQuick 2.0 - -Item { - id: root - property int loaderValue: 0 - property int createObjectValue: 0 - - Loader { - id: loader - objectName: "loader" - onLoaded: { - root.loaderValue = loader.item.canary; // should still be one - } - } - - Item { - id: child - property int bindable: 1; - } - - property InitialPropertyValuesComponent ipvc - Component.onCompleted: { - loader.setSource("InitialPropertyValuesComponent.qml", {"canary": child.bindable}); - var dynComp = Qt.createComponent("InitialPropertyValuesComponent.qml"); - ipvc = dynComp.createObject(root, {"canary": child.bindable}); - child.bindable = 7; // won't cause re-evaluation, since not used in a binding. - root.createObjectValue = ipvc.canary; // should still be one - } -} diff --git a/tests/auto/qtquick2/qquickloader/data/initialPropertyValues.8.qml b/tests/auto/qtquick2/qquickloader/data/initialPropertyValues.8.qml deleted file mode 100644 index 79e9264d4a..0000000000 --- a/tests/auto/qtquick2/qquickloader/data/initialPropertyValues.8.qml +++ /dev/null @@ -1,20 +0,0 @@ -import QtQuick 2.0 - -Item { - id: root - property int initialValue: 0 - - Loader { - id: loader - objectName: "loader" - active: false - onLoaded: { - root.initialValue = loader.item.canary; // should be six - } - } - - Component.onCompleted: { - loader.setSource("http://127.0.0.1:14450/InitialPropertyValuesComponent.qml", {"canary": 6}); - loader.active = true; - } -} diff --git a/tests/auto/qtquick2/qquickloader/data/initialPropertyValues.binding.qml b/tests/auto/qtquick2/qquickloader/data/initialPropertyValues.binding.qml deleted file mode 100644 index e0df50a74a..0000000000 --- a/tests/auto/qtquick2/qquickloader/data/initialPropertyValues.binding.qml +++ /dev/null @@ -1,21 +0,0 @@ -import QtQuick 2.0 - -Item { - id: root - - property InitialPropertyValuesComponent testInstance - testInstance: loader.item - - property int bindable: 1 - property int canaryValue: testInstance.canary - property int behaviorCount: testInstance.behaviorCount - - Loader { - id: loader - objectName: "loader" - } - - Component.onCompleted: { - loader.setSource("InitialPropertyValuesComponent.qml", {"canary": (function() { return root.bindable })}); - } -} diff --git a/tests/auto/qtquick2/qquickloader/data/initialPropertyValues.error.1.qml b/tests/auto/qtquick2/qquickloader/data/initialPropertyValues.error.1.qml deleted file mode 100644 index f324dbddac..0000000000 --- a/tests/auto/qtquick2/qquickloader/data/initialPropertyValues.error.1.qml +++ /dev/null @@ -1,14 +0,0 @@ -import QtQuick 2.0 - -Item { - id: root - - Loader { - id: loader - objectName: "loader" - } - - Component.onCompleted: { - loader.setSource("InitialPropertyValuesComponent.qml", 3); // invalid initial properties object - } -} diff --git a/tests/auto/qtquick2/qquickloader/data/initialPropertyValues.error.2.qml b/tests/auto/qtquick2/qquickloader/data/initialPropertyValues.error.2.qml deleted file mode 100644 index 89aba313c7..0000000000 --- a/tests/auto/qtquick2/qquickloader/data/initialPropertyValues.error.2.qml +++ /dev/null @@ -1,14 +0,0 @@ -import QtQuick 2.0 - -Item { - id: root - - Loader { - id: loader - objectName: "loader" - } - - Component.onCompleted: { - loader.setSource("NonexistentSourceComponent.qml", {"canary":3}); - } -} diff --git a/tests/auto/qtquick2/qquickloader/data/initialPropertyValues.error.3.qml b/tests/auto/qtquick2/qquickloader/data/initialPropertyValues.error.3.qml deleted file mode 100644 index c862007402..0000000000 --- a/tests/auto/qtquick2/qquickloader/data/initialPropertyValues.error.3.qml +++ /dev/null @@ -1,14 +0,0 @@ -import QtQuick 2.0 - -Item { - id: root - - Loader { - id: loader - objectName: "loader" - } - - Component.onCompleted: { - loader.setSource("InvalidSourceComponent.qml", {"canary":3}); - } -} diff --git a/tests/auto/qtquick2/qquickloader/data/initialPropertyValues.error.4.qml b/tests/auto/qtquick2/qquickloader/data/initialPropertyValues.error.4.qml deleted file mode 100644 index 9a80b2156d..0000000000 --- a/tests/auto/qtquick2/qquickloader/data/initialPropertyValues.error.4.qml +++ /dev/null @@ -1,15 +0,0 @@ -import QtQuick 2.0 - -Item { - id: root - property int canary: loader.item.canary - - Loader { - id: loader - objectName: "loader" - } - - Component.onCompleted: { - loader.setSource("InitialPropertyValuesComponent.qml", 3); // invalid initial properties object - } -} diff --git a/tests/auto/qtquick2/qquickloader/data/nonItem.qml b/tests/auto/qtquick2/qquickloader/data/nonItem.qml deleted file mode 100644 index 8cfa0d8efb..0000000000 --- a/tests/auto/qtquick2/qquickloader/data/nonItem.qml +++ /dev/null @@ -1,5 +0,0 @@ -import QtQuick 2.0 - -Loader { - sourceComponent: QtObject {} -} diff --git a/tests/auto/qtquick2/qquickloader/data/parented.qml b/tests/auto/qtquick2/qquickloader/data/parented.qml deleted file mode 100644 index 1c19d4d1a5..0000000000 --- a/tests/auto/qtquick2/qquickloader/data/parented.qml +++ /dev/null @@ -1,21 +0,0 @@ -import QtQuick 2.0 - -Item { - id: root - width: 300; height: 300 - - Component { - id: comp - Rectangle { - objectName: "comp" - parent: root - anchors.fill: parent - color: "blue" - } - } - - Loader { - width: 200; height: 200 - sourceComponent: comp - } -} diff --git a/tests/auto/qtquick2/qquickloader/data/qmldir b/tests/auto/qtquick2/qquickloader/data/qmldir deleted file mode 100644 index bf42b507c0..0000000000 --- a/tests/auto/qtquick2/qquickloader/data/qmldir +++ /dev/null @@ -1 +0,0 @@ -# For tst_QDeclarativeLoader::networkRequestUrl; no types needed though. diff --git a/tests/auto/qtquick2/qquickloader/data/sameorigin-load.qml b/tests/auto/qtquick2/qquickloader/data/sameorigin-load.qml deleted file mode 100644 index 3332500be6..0000000000 --- a/tests/auto/qtquick2/qquickloader/data/sameorigin-load.qml +++ /dev/null @@ -1,3 +0,0 @@ -import QtQuick 2.0 - -Item { } diff --git a/tests/auto/qtquick2/qquickloader/data/sameorigin.qml b/tests/auto/qtquick2/qquickloader/data/sameorigin.qml deleted file mode 100644 index 84846b6aba..0000000000 --- a/tests/auto/qtquick2/qquickloader/data/sameorigin.qml +++ /dev/null @@ -1,3 +0,0 @@ -import QtQuick 2.0 - -Loader { source: "sameorigin-load.qml" } diff --git a/tests/auto/qtquick2/qquickloader/data/sizebound.qml b/tests/auto/qtquick2/qquickloader/data/sizebound.qml deleted file mode 100644 index 09cf32426a..0000000000 --- a/tests/auto/qtquick2/qquickloader/data/sizebound.qml +++ /dev/null @@ -1,30 +0,0 @@ -import QtQuick 2.0 - -Item { - width: 200; height: 200 - - function switchComponent() { - load.sourceComponent = comp2 - } - - Component { - id: comp - Rectangle { - width: 50; height: 60; color: "red" - } - } - - Component { - id: comp2 - Rectangle { - width: 80; height: 90; color: "green" - } - } - - Loader { - id: load - objectName: "loader" - sourceComponent: comp - height: item ? item.height : 0 - } -} diff --git a/tests/auto/qtquick2/qquickloader/data/vmeErrors.qml b/tests/auto/qtquick2/qquickloader/data/vmeErrors.qml deleted file mode 100644 index 8e6c89dc8e..0000000000 --- a/tests/auto/qtquick2/qquickloader/data/vmeErrors.qml +++ /dev/null @@ -1,6 +0,0 @@ -import QtQuick 2.0 - -Loader { - source: "VmeError.qml" -} - diff --git a/tests/auto/qtquick2/qquickloader/qquickloader.pro b/tests/auto/qtquick2/qquickloader/qquickloader.pro deleted file mode 100644 index 33c8c207af..0000000000 --- a/tests/auto/qtquick2/qquickloader/qquickloader.pro +++ /dev/null @@ -1,19 +0,0 @@ -CONFIG += testcase -TARGET = tst_qquickloader -macx:CONFIG -= app_bundle - -INCLUDEPATH += ../../shared/ -HEADERS += ../../shared/testhttpserver.h - -SOURCES += tst_qquickloader.cpp \ - ../../shared/testhttpserver.cpp - -include (../../shared/util.pri) - -testDataFiles.files = data -testDataFiles.path = . -DEPLOYMENT += testDataFiles - -CONFIG += parallel_test - -QT += core-private gui-private declarative-private quick-private network testlib diff --git a/tests/auto/qtquick2/qquickloader/tst_qquickloader.cpp b/tests/auto/qtquick2/qquickloader/tst_qquickloader.cpp deleted file mode 100644 index 33148db7b1..0000000000 --- a/tests/auto/qtquick2/qquickloader/tst_qquickloader.cpp +++ /dev/null @@ -1,987 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include - -#include - -#include -#include -#include -#include -#include "testhttpserver.h" -#include "../../shared/util.h" - -#define SERVER_PORT 14450 - -class PeriodicIncubationController : public QObject, - public QDeclarativeIncubationController -{ -public: - PeriodicIncubationController() { - startTimer(16); - } - -protected: - virtual void timerEvent(QTimerEvent *) { - incubateFor(15); - } -}; - -class tst_QQuickLoader : public QDeclarativeDataTest - -{ - Q_OBJECT -public: - tst_QQuickLoader(); - -private slots: - void sourceOrComponent(); - void sourceOrComponent_data(); - void clear(); - void urlToComponent(); - void componentToUrl(); - void anchoredLoader(); - void sizeLoaderToItem(); - void sizeItemToLoader(); - void noResize(); - void networkRequestUrl(); - void failNetworkRequest(); -// void networkComponent(); - void active(); - void initialPropertyValues_data(); - void initialPropertyValues(); - void initialPropertyValuesBinding(); - void initialPropertyValuesError_data(); - void initialPropertyValuesError(); - - void deleteComponentCrash(); - void nonItem(); - void vmeErrors(); - void creationContext(); - void QTBUG_16928(); - void implicitSize(); - void QTBUG_17114(); - void asynchronous_data(); - void asynchronous(); - void asynchronous_clear(); - - void parented(); - void sizeBound(); - -private: - QDeclarativeEngine engine; -}; - - -tst_QQuickLoader::tst_QQuickLoader() -{ -} - -void tst_QQuickLoader::sourceOrComponent() -{ - QFETCH(QString, sourceOrComponent); - QFETCH(QString, sourceDefinition); - QFETCH(QUrl, sourceUrl); - QFETCH(QString, errorString); - - bool error = !errorString.isEmpty(); - if (error) - QTest::ignoreMessage(QtWarningMsg, errorString.toUtf8().constData()); - - QDeclarativeComponent component(&engine); - component.setData(QByteArray( - "import QtQuick 2.0\n" - "Loader {\n" - " property int onItemChangedCount: 0\n" - " property int onSourceChangedCount: 0\n" - " property int onSourceComponentChangedCount: 0\n" - " property int onStatusChangedCount: 0\n" - " property int onProgressChangedCount: 0\n" - " property int onLoadedCount: 0\n") - + sourceDefinition.toUtf8() - + QByteArray( - " onItemChanged: onItemChangedCount += 1\n" - " onSourceChanged: onSourceChangedCount += 1\n" - " onSourceComponentChanged: onSourceComponentChangedCount += 1\n" - " onStatusChanged: onStatusChangedCount += 1\n" - " onProgressChanged: onProgressChangedCount += 1\n" - " onLoaded: onLoadedCount += 1\n" - "}") - , dataDirectoryUrl()); - - QQuickLoader *loader = qobject_cast(component.create()); - QVERIFY(loader != 0); - QCOMPARE(loader->item() == 0, error); - QCOMPARE(loader->source(), sourceUrl); - QCOMPARE(loader->progress(), 1.0); - - QCOMPARE(loader->status(), error ? QQuickLoader::Error : QQuickLoader::Ready); - QCOMPARE(static_cast(loader)->childItems().count(), error ? 0: 1); - - if (!error) { - bool sourceComponentIsChildOfLoader = false; - for (int ii = 0; ii < loader->children().size(); ++ii) { - QDeclarativeComponent *c = qobject_cast(loader->children().at(ii)); - if (c && c == loader->sourceComponent()) { - sourceComponentIsChildOfLoader = true; - } - } - QVERIFY(sourceComponentIsChildOfLoader); - } - - if (sourceOrComponent == "component") { - QCOMPARE(loader->property("onSourceComponentChangedCount").toInt(), 1); - QCOMPARE(loader->property("onSourceChangedCount").toInt(), 0); - } else { - QCOMPARE(loader->property("onSourceComponentChangedCount").toInt(), 0); - QCOMPARE(loader->property("onSourceChangedCount").toInt(), 1); - } - QCOMPARE(loader->property("onStatusChangedCount").toInt(), 1); - QCOMPARE(loader->property("onProgressChangedCount").toInt(), 1); - - QCOMPARE(loader->property("onItemChangedCount").toInt(), error ? 0 : 1); - QCOMPARE(loader->property("onLoadedCount").toInt(), error ? 0 : 1); - - delete loader; -} - -void tst_QQuickLoader::sourceOrComponent_data() -{ - QTest::addColumn("sourceOrComponent"); - QTest::addColumn("sourceDefinition"); - QTest::addColumn("sourceUrl"); - QTest::addColumn("errorString"); - - QTest::newRow("source") << "source" << "source: 'Rect120x60.qml'\n" << testFileUrl("Rect120x60.qml") << ""; - QTest::newRow("sourceComponent") << "component" << "Component { id: comp; Rectangle { width: 100; height: 50 } }\n sourceComponent: comp\n" << QUrl() << ""; - QTest::newRow("invalid source") << "source" << "source: 'IDontExist.qml'\n" << testFileUrl("IDontExist.qml") - << QString(testFileUrl("IDontExist.qml").toString() + ": File not found"); -} - -void tst_QQuickLoader::clear() -{ - { - QDeclarativeComponent component(&engine); - component.setData(QByteArray( - "import QtQuick 2.0\n" - " Loader { id: loader\n" - " source: 'Rect120x60.qml'\n" - " Timer { interval: 200; running: true; onTriggered: loader.source = '' }\n" - " }") - , dataDirectoryUrl()); - QQuickLoader *loader = qobject_cast(component.create()); - QVERIFY(loader != 0); - QVERIFY(loader->item()); - QCOMPARE(loader->progress(), 1.0); - QCOMPARE(static_cast(loader)->childItems().count(), 1); - - QTRY_VERIFY(loader->item() == 0); - QCOMPARE(loader->progress(), 0.0); - QCOMPARE(loader->status(), QQuickLoader::Null); - QCOMPARE(static_cast(loader)->childItems().count(), 0); - - delete loader; - } - { - QDeclarativeComponent component(&engine, testFileUrl("/SetSourceComponent.qml")); - QQuickItem *item = qobject_cast(component.create()); - QVERIFY(item); - - QQuickLoader *loader = qobject_cast(item->QQuickItem::childItems().at(0)); - QVERIFY(loader); - QVERIFY(loader->item()); - QCOMPARE(loader->progress(), 1.0); - QCOMPARE(static_cast(loader)->childItems().count(), 1); - - loader->setSourceComponent(0); - - QVERIFY(loader->item() == 0); - QCOMPARE(loader->progress(), 0.0); - QCOMPARE(loader->status(), QQuickLoader::Null); - QCOMPARE(static_cast(loader)->childItems().count(), 0); - - delete item; - } - { - QDeclarativeComponent component(&engine, testFileUrl("/SetSourceComponent.qml")); - QQuickItem *item = qobject_cast(component.create()); - QVERIFY(item); - - QQuickLoader *loader = qobject_cast(item->QQuickItem::childItems().at(0)); - QVERIFY(loader); - QVERIFY(loader->item()); - QCOMPARE(loader->progress(), 1.0); - QCOMPARE(static_cast(loader)->childItems().count(), 1); - - QMetaObject::invokeMethod(item, "clear"); - - QVERIFY(loader->item() == 0); - QCOMPARE(loader->progress(), 0.0); - QCOMPARE(loader->status(), QQuickLoader::Null); - QCOMPARE(static_cast(loader)->childItems().count(), 0); - - delete item; - } -} - -void tst_QQuickLoader::urlToComponent() -{ - QDeclarativeComponent component(&engine); - component.setData(QByteArray("import QtQuick 2.0\n" - "Loader {\n" - " id: loader\n" - " Component { id: myComp; Rectangle { width: 10; height: 10 } }\n" - " source: \"Rect120x60.qml\"\n" - " Timer { interval: 100; running: true; onTriggered: loader.sourceComponent = myComp }\n" - "}" ) - , dataDirectoryUrl()); - QQuickLoader *loader = qobject_cast(component.create()); - QTest::qWait(200); - QTRY_VERIFY(loader != 0); - QVERIFY(loader->item()); - QCOMPARE(loader->progress(), 1.0); - QCOMPARE(static_cast(loader)->childItems().count(), 1); - QCOMPARE(loader->width(), 10.0); - QCOMPARE(loader->height(), 10.0); - - delete loader; -} - -void tst_QQuickLoader::componentToUrl() -{ - QDeclarativeComponent component(&engine, testFileUrl("/SetSourceComponent.qml")); - QQuickItem *item = qobject_cast(component.create()); - QVERIFY(item); - - QQuickLoader *loader = qobject_cast(item->QQuickItem::childItems().at(0)); - QVERIFY(loader); - QVERIFY(loader->item()); - QCOMPARE(loader->progress(), 1.0); - QCOMPARE(static_cast(loader)->childItems().count(), 1); - - loader->setSource(testFileUrl("/Rect120x60.qml")); - QVERIFY(loader->item()); - QCOMPARE(loader->progress(), 1.0); - QCOMPARE(static_cast(loader)->childItems().count(), 1); - QCOMPARE(loader->width(), 120.0); - QCOMPARE(loader->height(), 60.0); - - delete item; -} - -void tst_QQuickLoader::anchoredLoader() -{ - QDeclarativeComponent component(&engine, testFileUrl("/AnchoredLoader.qml")); - QQuickItem *rootItem = qobject_cast(component.create()); - QVERIFY(rootItem != 0); - QQuickItem *loader = rootItem->findChild("loader"); - QQuickItem *sourceElement = rootItem->findChild("sourceElement"); - - QVERIFY(loader != 0); - QVERIFY(sourceElement != 0); - - QCOMPARE(rootItem->width(), 300.0); - QCOMPARE(rootItem->height(), 200.0); - - QCOMPARE(loader->width(), 300.0); - QCOMPARE(loader->height(), 200.0); - - QCOMPARE(sourceElement->width(), 300.0); - QCOMPARE(sourceElement->height(), 200.0); -} - -void tst_QQuickLoader::sizeLoaderToItem() -{ - QDeclarativeComponent component(&engine, testFileUrl("/SizeToItem.qml")); - QQuickLoader *loader = qobject_cast(component.create()); - QVERIFY(loader != 0); - QCOMPARE(loader->width(), 120.0); - QCOMPARE(loader->height(), 60.0); - - // Check resize - QQuickItem *rect = qobject_cast(loader->item()); - QVERIFY(rect); - rect->setWidth(150); - rect->setHeight(45); - QCOMPARE(loader->width(), 150.0); - QCOMPARE(loader->height(), 45.0); - - // Check explicit width - loader->setWidth(200.0); - QCOMPARE(loader->width(), 200.0); - QCOMPARE(rect->width(), 200.0); - rect->setWidth(100.0); // when rect changes ... - QCOMPARE(rect->width(), 100.0); // ... it changes - QCOMPARE(loader->width(), 200.0); // ... but loader stays the same - - // Check explicit height - loader->setHeight(200.0); - QCOMPARE(loader->height(), 200.0); - QCOMPARE(rect->height(), 200.0); - rect->setHeight(100.0); // when rect changes ... - QCOMPARE(rect->height(), 100.0); // ... it changes - QCOMPARE(loader->height(), 200.0); // ... but loader stays the same - - // Switch mode - loader->setWidth(180); - loader->setHeight(30); - QCOMPARE(rect->width(), 180.0); - QCOMPARE(rect->height(), 30.0); - - delete loader; -} - -void tst_QQuickLoader::sizeItemToLoader() -{ - QDeclarativeComponent component(&engine, testFileUrl("/SizeToLoader.qml")); - QQuickLoader *loader = qobject_cast(component.create()); - QVERIFY(loader != 0); - QCOMPARE(loader->width(), 200.0); - QCOMPARE(loader->height(), 80.0); - - QQuickItem *rect = qobject_cast(loader->item()); - QVERIFY(rect); - QCOMPARE(rect->width(), 200.0); - QCOMPARE(rect->height(), 80.0); - - // Check resize - loader->setWidth(180); - loader->setHeight(30); - QCOMPARE(rect->width(), 180.0); - QCOMPARE(rect->height(), 30.0); - - // Switch mode - loader->resetWidth(); // reset explicit size - loader->resetHeight(); - rect->setWidth(160); - rect->setHeight(45); - QCOMPARE(loader->width(), 160.0); - QCOMPARE(loader->height(), 45.0); - - delete loader; -} - -void tst_QQuickLoader::noResize() -{ - QDeclarativeComponent component(&engine, testFileUrl("/NoResize.qml")); - QQuickItem* item = qobject_cast(component.create()); - QVERIFY(item != 0); - QCOMPARE(item->width(), 200.0); - QCOMPARE(item->height(), 80.0); - - delete item; -} - -void tst_QQuickLoader::networkRequestUrl() -{ - TestHTTPServer server(SERVER_PORT); - QVERIFY(server.isValid()); - server.serveDirectory(dataDirectory()); - - QDeclarativeComponent component(&engine); - component.setData(QByteArray("import QtQuick 2.0\nLoader { property int signalCount : 0; source: \"http://127.0.0.1:14450/Rect120x60.qml\"; onLoaded: signalCount += 1 }"), testFileUrl("../dummy.qml")); - if (component.isError()) - qDebug() << component.errors(); - QQuickLoader *loader = qobject_cast(component.create()); - QVERIFY(loader != 0); - - QTRY_VERIFY(loader->status() == QQuickLoader::Ready); - - QVERIFY(loader->item()); - QCOMPARE(loader->progress(), 1.0); - QCOMPARE(loader->property("signalCount").toInt(), 1); - QCOMPARE(static_cast(loader)->childItems().count(), 1); - - delete loader; -} - -/* XXX Component waits until all dependencies are loaded. Is this actually possible? -void tst_QQuickLoader::networkComponent() -{ - TestHTTPServer server(SERVER_PORT); - QVERIFY(server.isValid()); - server.serveDirectory("slowdata", TestHTTPServer::Delay); - - QDeclarativeComponent component(&engine); - component.setData(QByteArray( - "import QtQuick 2.0\n" - "import \"http://127.0.0.1:14450/\" as NW\n" - "Item {\n" - " Component { id: comp; NW.SlowRect {} }\n" - " Loader { sourceComponent: comp } }") - , dataDirectoryUrl()); - - QQuickItem *item = qobject_cast(component.create()); - QVERIFY(item); - - QQuickLoader *loader = qobject_cast(item->QQuickItem::children().at(1)); - QVERIFY(loader); - QTRY_VERIFY(loader->status() == QQuickLoader::Ready); - - QVERIFY(loader->item()); - QCOMPARE(loader->progress(), 1.0); - QCOMPARE(loader->status(), QQuickLoader::Ready); - QCOMPARE(static_cast(loader)->children().count(), 1); - - delete loader; -} -*/ - -void tst_QQuickLoader::failNetworkRequest() -{ - TestHTTPServer server(SERVER_PORT); - QVERIFY(server.isValid()); - server.serveDirectory(dataDirectory()); - - QTest::ignoreMessage(QtWarningMsg, "http://127.0.0.1:14450/IDontExist.qml: File not found"); - - QDeclarativeComponent component(&engine); - component.setData(QByteArray("import QtQuick 2.0\nLoader { property int did_load: 123; source: \"http://127.0.0.1:14450/IDontExist.qml\"; onLoaded: did_load=456 }"), QUrl::fromLocalFile("http://127.0.0.1:14450/dummy.qml")); - QQuickLoader *loader = qobject_cast(component.create()); - QVERIFY(loader != 0); - - QTRY_VERIFY(loader->status() == QQuickLoader::Error); - - QVERIFY(loader->item() == 0); - QCOMPARE(loader->progress(), 0.0); - QCOMPARE(loader->property("did_load").toInt(), 123); - QCOMPARE(static_cast(loader)->childItems().count(), 0); - - delete loader; -} - -void tst_QQuickLoader::active() -{ - // check that the item isn't instantiated until active is set to true - { - QDeclarativeComponent component(&engine, testFileUrl("active.1.qml")); - QObject *object = component.create(); - QVERIFY(object != 0); - QQuickLoader *loader = object->findChild("loader"); - - QVERIFY(loader->active() == false); // set manually to false - QVERIFY(loader->item() == 0); - QMetaObject::invokeMethod(object, "doSetSourceComponent"); - QVERIFY(loader->item() == 0); - QMetaObject::invokeMethod(object, "doSetSource"); - QVERIFY(loader->item() == 0); - QMetaObject::invokeMethod(object, "doSetActive"); - QVERIFY(loader->item() != 0); - - delete object; - } - - // check that the status is Null if active is set to false - { - QDeclarativeComponent component(&engine, testFileUrl("active.2.qml")); - QObject *object = component.create(); - QVERIFY(object != 0); - QQuickLoader *loader = object->findChild("loader"); - - QVERIFY(loader->active() == true); // active is true by default - QCOMPARE(loader->status(), QQuickLoader::Ready); - int currStatusChangedCount = loader->property("statusChangedCount").toInt(); - QMetaObject::invokeMethod(object, "doSetInactive"); - QCOMPARE(loader->status(), QQuickLoader::Null); - QCOMPARE(loader->property("statusChangedCount").toInt(), (currStatusChangedCount+1)); - - delete object; - } - - // check that the source is not cleared if active is set to false - { - QDeclarativeComponent component(&engine, testFileUrl("active.3.qml")); - QObject *object = component.create(); - QVERIFY(object != 0); - QQuickLoader *loader = object->findChild("loader"); - - QVERIFY(loader->active() == true); // active is true by default - QVERIFY(!loader->source().isEmpty()); - int currSourceChangedCount = loader->property("sourceChangedCount").toInt(); - QMetaObject::invokeMethod(object, "doSetInactive"); - QVERIFY(!loader->source().isEmpty()); - QCOMPARE(loader->property("sourceChangedCount").toInt(), currSourceChangedCount); - - delete object; - } - - // check that the sourceComponent is not cleared if active is set to false - { - QDeclarativeComponent component(&engine, testFileUrl("active.4.qml")); - QObject *object = component.create(); - QVERIFY(object != 0); - QQuickLoader *loader = object->findChild("loader"); - - QVERIFY(loader->active() == true); // active is true by default - QVERIFY(loader->sourceComponent() != 0); - int currSourceComponentChangedCount = loader->property("sourceComponentChangedCount").toInt(); - QMetaObject::invokeMethod(object, "doSetInactive"); - QVERIFY(loader->sourceComponent() != 0); - QCOMPARE(loader->property("sourceComponentChangedCount").toInt(), currSourceComponentChangedCount); - - delete object; - } - - // check that the item is released if active is set to false - { - QDeclarativeComponent component(&engine, testFileUrl("active.5.qml")); - QObject *object = component.create(); - QVERIFY(object != 0); - QQuickLoader *loader = object->findChild("loader"); - - QVERIFY(loader->active() == true); // active is true by default - QVERIFY(loader->item() != 0); - int currItemChangedCount = loader->property("itemChangedCount").toInt(); - QMetaObject::invokeMethod(object, "doSetInactive"); - QVERIFY(loader->item() == 0); - QCOMPARE(loader->property("itemChangedCount").toInt(), (currItemChangedCount+1)); - - delete object; - } - - // check that the activeChanged signal is emitted correctly - { - QDeclarativeComponent component(&engine, testFileUrl("active.6.qml")); - QObject *object = component.create(); - QVERIFY(object != 0); - QQuickLoader *loader = object->findChild("loader"); - - QVERIFY(loader->active() == true); // active is true by default - loader->setActive(true); // no effect - QCOMPARE(loader->property("activeChangedCount").toInt(), 0); - loader->setActive(false); // change signal should be emitted - QCOMPARE(loader->property("activeChangedCount").toInt(), 1); - loader->setActive(false); // no effect - QCOMPARE(loader->property("activeChangedCount").toInt(), 1); - loader->setActive(true); // change signal should be emitted - QCOMPARE(loader->property("activeChangedCount").toInt(), 2); - loader->setActive(false); // change signal should be emitted - QCOMPARE(loader->property("activeChangedCount").toInt(), 3); - QMetaObject::invokeMethod(object, "doSetActive"); - QCOMPARE(loader->property("activeChangedCount").toInt(), 4); - QMetaObject::invokeMethod(object, "doSetActive"); - QCOMPARE(loader->property("activeChangedCount").toInt(), 4); - QMetaObject::invokeMethod(object, "doSetInactive"); - QCOMPARE(loader->property("activeChangedCount").toInt(), 5); - loader->setActive(true); // change signal should be emitted - QCOMPARE(loader->property("activeChangedCount").toInt(), 6); - - delete object; - } - - // check that the component isn't loaded until active is set to true - { - QDeclarativeComponent component(&engine, testFileUrl("active.7.qml")); - QObject *object = component.create(); - QVERIFY(object != 0); - QCOMPARE(object->property("success").toBool(), true); - delete object; - } - - // check that the component is loaded if active is not set (true by default) - { - QDeclarativeComponent component(&engine, testFileUrl("active.8.qml")); - QObject *object = component.create(); - QVERIFY(object != 0); - QCOMPARE(object->property("success").toBool(), true); - delete object; - } -} - -void tst_QQuickLoader::initialPropertyValues_data() -{ - QTest::addColumn("qmlFile"); - QTest::addColumn("expectedWarnings"); - QTest::addColumn("propertyNames"); - QTest::addColumn("propertyValues"); - - QTest::newRow("source url with value set in onLoaded, initially active = true") << testFileUrl("initialPropertyValues.1.qml") - << QStringList() - << (QStringList() << "initialValue" << "behaviorCount") - << (QVariantList() << 1 << 1); - - QTest::newRow("set source with initial property values specified, active = true") << testFileUrl("initialPropertyValues.2.qml") - << QStringList() - << (QStringList() << "initialValue" << "behaviorCount") - << (QVariantList() << 2 << 0); - - QTest::newRow("set source with initial property values specified, active = false") << testFileUrl("initialPropertyValues.3.qml") - << (QStringList() << QString(QLatin1String("file://") + testFileUrl("initialPropertyValues.3.qml").toLocalFile() + QLatin1String(":16: TypeError: Cannot read property 'canary' of null"))) - << (QStringList()) - << (QVariantList()); - - QTest::newRow("set source with initial property values specified, active = false, with active set true later") << testFileUrl("initialPropertyValues.4.qml") - << QStringList() - << (QStringList() << "initialValue" << "behaviorCount") - << (QVariantList() << 4 << 0); - - QTest::newRow("set source without initial property values specified, active = true") << testFileUrl("initialPropertyValues.5.qml") - << QStringList() - << (QStringList() << "initialValue" << "behaviorCount") - << (QVariantList() << 0 << 0); - - QTest::newRow("set source with initial property values specified with binding, active = true") << testFileUrl("initialPropertyValues.6.qml") - << QStringList() - << (QStringList() << "initialValue" << "behaviorCount") - << (QVariantList() << 6 << 0); - - QTest::newRow("ensure initial property value semantics mimic createObject") << testFileUrl("initialPropertyValues.7.qml") - << QStringList() - << (QStringList() << "loaderValue" << "createObjectValue") - << (QVariantList() << 1 << 1); - - QTest::newRow("ensure initial property values aren't disposed prior to component completion") << testFileUrl("initialPropertyValues.8.qml") - << QStringList() - << (QStringList() << "initialValue") - << (QVariantList() << 6); -} - -void tst_QQuickLoader::initialPropertyValues() -{ - QFETCH(QUrl, qmlFile); - QFETCH(QStringList, expectedWarnings); - QFETCH(QStringList, propertyNames); - QFETCH(QVariantList, propertyValues); - - TestHTTPServer server(SERVER_PORT); - QVERIFY(server.isValid()); - server.serveDirectory(dataDirectory()); - - foreach (const QString &warning, expectedWarnings) - QTest::ignoreMessage(QtWarningMsg, warning.toAscii().constData()); - - QDeclarativeComponent component(&engine, qmlFile); - QObject *object = component.create(); - QVERIFY(object != 0); - qApp->processEvents(); - QTest::qWait(50); - - for (int i = 0; i < propertyNames.size(); ++i) - QCOMPARE(object->property(propertyNames.at(i).toAscii().constData()), propertyValues.at(i)); - - delete object; -} - -void tst_QQuickLoader::initialPropertyValuesBinding() -{ - QDeclarativeComponent component(&engine, testFileUrl("initialPropertyValues.binding.qml")); - QObject *object = component.create(); - QVERIFY(object != 0); - - QVERIFY(object->setProperty("bindable", QVariant(8))); - QCOMPARE(object->property("canaryValue").toInt(), 8); - - delete object; -} - -void tst_QQuickLoader::initialPropertyValuesError_data() -{ - QTest::addColumn("qmlFile"); - QTest::addColumn("expectedWarnings"); - - QTest::newRow("invalid initial property values object") << testFileUrl("initialPropertyValues.error.1.qml") - << (QStringList() << QString(testFileUrl("initialPropertyValues.error.1.qml").toString() + ":6:5: QML Loader: setSource: value is not an object")); - - QTest::newRow("nonexistent source url") << testFileUrl("initialPropertyValues.error.2.qml") - << (QStringList() << QString(testFileUrl("NonexistentSourceComponent.qml").toString() + ": File not found")); - - QTest::newRow("invalid source url") << testFileUrl("initialPropertyValues.error.3.qml") - << (QStringList() << QString(testFileUrl("InvalidSourceComponent.qml").toString() + ":5:1: Syntax error")); - - QTest::newRow("invalid initial property values object with invalid property access") << testFileUrl("initialPropertyValues.error.4.qml") - << (QStringList() << QString(testFileUrl("initialPropertyValues.error.4.qml").toString() + ":7:5: QML Loader: setSource: value is not an object") - << QString(testFileUrl("initialPropertyValues.error.4.qml").toString() + ":5: TypeError: Cannot read property 'canary' of null")); -} - -void tst_QQuickLoader::initialPropertyValuesError() -{ - QFETCH(QUrl, qmlFile); - QFETCH(QStringList, expectedWarnings); - - foreach (const QString &warning, expectedWarnings) - QTest::ignoreMessage(QtWarningMsg, warning.toUtf8().constData()); - - QDeclarativeComponent component(&engine, qmlFile); - QObject *object = component.create(); - QVERIFY(object != 0); - QQuickLoader *loader = object->findChild("loader"); - QVERIFY(loader != 0); - QVERIFY(loader->item() == 0); - delete object; -} - -// QTBUG-9241 -void tst_QQuickLoader::deleteComponentCrash() -{ - QDeclarativeComponent component(&engine, testFileUrl("crash.qml")); - QQuickItem *item = qobject_cast(component.create()); - QVERIFY(item); - - item->metaObject()->invokeMethod(item, "setLoaderSource"); - - QQuickLoader *loader = qobject_cast(item->QQuickItem::childItems().at(0)); - QVERIFY(loader); - QVERIFY(loader->item()); - QCOMPARE(loader->item()->objectName(), QLatin1String("blue")); - QCOMPARE(loader->progress(), 1.0); - QCOMPARE(loader->status(), QQuickLoader::Ready); - QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete); - QCoreApplication::processEvents(); - QTRY_COMPARE(static_cast(loader)->childItems().count(), 1); - QVERIFY(loader->source() == testFileUrl("BlueRect.qml")); - - delete item; -} - -void tst_QQuickLoader::nonItem() -{ - QDeclarativeComponent component(&engine, testFileUrl("nonItem.qml")); - QString err = testFileUrl("nonItem.qml").toString() + ":3:1: QML Loader: Loader does not support loading non-visual elements."; - - QTest::ignoreMessage(QtWarningMsg, err.toLatin1().constData()); - QQuickLoader *loader = qobject_cast(component.create()); - QVERIFY(loader); - QVERIFY(loader->item() == 0); - - delete loader; -} - -void tst_QQuickLoader::vmeErrors() -{ - QDeclarativeComponent component(&engine, testFileUrl("vmeErrors.qml")); - QString err = testFileUrl("VmeError.qml").toString() + ":6: Cannot assign object type QObject with no default method"; - QTest::ignoreMessage(QtWarningMsg, err.toLatin1().constData()); - QQuickLoader *loader = qobject_cast(component.create()); - QVERIFY(loader); - QVERIFY(loader->item() == 0); - - delete loader; -} - -// QTBUG-13481 -void tst_QQuickLoader::creationContext() -{ - QDeclarativeComponent component(&engine, testFileUrl("creationContext.qml")); - - QObject *o = component.create(); - QVERIFY(o != 0); - - QCOMPARE(o->property("test").toBool(), true); - - delete o; -} - -void tst_QQuickLoader::QTBUG_16928() -{ - QDeclarativeComponent component(&engine, testFileUrl("QTBUG_16928.qml")); - QQuickItem *item = qobject_cast(component.create()); - QVERIFY(item); - - QCOMPARE(item->width(), 250.); - QCOMPARE(item->height(), 250.); - - delete item; -} - -void tst_QQuickLoader::implicitSize() -{ - QDeclarativeComponent component(&engine, testFileUrl("implicitSize.qml")); - QQuickItem *item = qobject_cast(component.create()); - QVERIFY(item); - - QCOMPARE(item->width(), 150.); - QCOMPARE(item->height(), 150.); - - QCOMPARE(item->property("implHeight").toReal(), 100.); - QCOMPARE(item->property("implWidth").toReal(), 100.); - - delete item; -} - -void tst_QQuickLoader::QTBUG_17114() -{ - QDeclarativeComponent component(&engine, testFileUrl("QTBUG_17114.qml")); - QQuickItem *item = qobject_cast(component.create()); - QVERIFY(item); - - QCOMPARE(item->property("loaderWidth").toReal(), 32.); - QCOMPARE(item->property("loaderHeight").toReal(), 32.); - - delete item; -} - -void tst_QQuickLoader::asynchronous_data() -{ - QTest::addColumn("qmlFile"); - QTest::addColumn("expectedWarnings"); - - QTest::newRow("Valid component") << testFileUrl("BigComponent.qml") - << QStringList(); - - QTest::newRow("Non-existant component") << testFileUrl("IDoNotExist.qml") - << (QStringList() << QString(testFileUrl("IDoNotExist.qml").toString() + ": File not found")); - - QTest::newRow("Invalid component") << testFileUrl("InvalidSourceComponent.qml") - << (QStringList() << QString(testFileUrl("InvalidSourceComponent.qml").toString() + ":5:1: Syntax error")); -} - -void tst_QQuickLoader::asynchronous() -{ - QFETCH(QUrl, qmlFile); - QFETCH(QStringList, expectedWarnings); - - if (!engine.incubationController()) - engine.setIncubationController(new PeriodicIncubationController); - QDeclarativeComponent component(&engine, testFileUrl("asynchronous.qml")); - QQuickItem *root = qobject_cast(component.create()); - QVERIFY(root); - - QQuickLoader *loader = root->findChild("loader"); - QVERIFY(loader); - - foreach (const QString &warning, expectedWarnings) - QTest::ignoreMessage(QtWarningMsg, warning.toUtf8().constData()); - - QVERIFY(!loader->item()); - root->setProperty("comp", qmlFile.toString()); - QMetaObject::invokeMethod(root, "loadComponent"); - QVERIFY(!loader->item()); - - if (expectedWarnings.isEmpty()) { - QCOMPARE(loader->status(), QQuickLoader::Loading); - QCOMPARE(engine.incubationController()->incubatingObjectCount(), 1); - - QTRY_VERIFY(loader->item()); - QCOMPARE(loader->progress(), 1.0); - QCOMPARE(loader->status(), QQuickLoader::Ready); - } else { - QCOMPARE(loader->progress(), 1.0); - QTRY_COMPARE(loader->status(), QQuickLoader::Error); - } - - delete root; -} - -void tst_QQuickLoader::asynchronous_clear() -{ - if (!engine.incubationController()) - engine.setIncubationController(new PeriodicIncubationController); - QDeclarativeComponent component(&engine, testFileUrl("asynchronous.qml")); - QQuickItem *root = qobject_cast(component.create()); - QVERIFY(root); - - QQuickLoader *loader = root->findChild("loader"); - QVERIFY(loader); - - QVERIFY(!loader->item()); - root->setProperty("comp", "BigComponent.qml"); - QMetaObject::invokeMethod(root, "loadComponent"); - QVERIFY(!loader->item()); - - QCOMPARE(loader->status(), QQuickLoader::Loading); - QCOMPARE(engine.incubationController()->incubatingObjectCount(), 1); - - // clear before component created - root->setProperty("comp", ""); - QMetaObject::invokeMethod(root, "loadComponent"); - QVERIFY(!loader->item()); - QCOMPARE(engine.incubationController()->incubatingObjectCount(), 0); - - QCOMPARE(loader->progress(), 0.0); - QCOMPARE(loader->status(), QQuickLoader::Null); - QCOMPARE(static_cast(loader)->childItems().count(), 0); - - // check loading component - root->setProperty("comp", "Rect120x60.qml"); - QMetaObject::invokeMethod(root, "loadComponent"); - QVERIFY(!loader->item()); - - QCOMPARE(loader->status(), QQuickLoader::Loading); - QCOMPARE(engine.incubationController()->incubatingObjectCount(), 1); - - QTRY_VERIFY(loader->item()); - QCOMPARE(loader->progress(), 1.0); - QCOMPARE(loader->status(), QQuickLoader::Ready); - QCOMPARE(static_cast(loader)->childItems().count(), 1); -} - -void tst_QQuickLoader::parented() -{ - QDeclarativeComponent component(&engine, testFileUrl("parented.qml")); - QQuickItem *root = qobject_cast(component.create()); - QVERIFY(root); - - QQuickItem *item = root->findChild("comp"); - QVERIFY(item); - - QVERIFY(item->parentItem() == root); - - QCOMPARE(item->width(), 300.); - QCOMPARE(item->height(), 300.); - - delete root; -} - -void tst_QQuickLoader::sizeBound() -{ - QDeclarativeComponent component(&engine, testFileUrl("sizebound.qml")); - QQuickItem *root = qobject_cast(component.create()); - QVERIFY(root); - QQuickLoader *loader = root->findChild("loader"); - QVERIFY(loader != 0); - - QVERIFY(loader->item()); - - QCOMPARE(loader->width(), 50.0); - QCOMPARE(loader->height(), 60.0); - - QMetaObject::invokeMethod(root, "switchComponent"); - - QCOMPARE(loader->width(), 80.0); - QCOMPARE(loader->height(), 90.0); - - delete root; -} - - -QTEST_MAIN(tst_QQuickLoader) - -#include "tst_qquickloader.moc" diff --git a/tests/auto/qtquick2/qquickmousearea/data/clickThrough.qml b/tests/auto/qtquick2/qquickmousearea/data/clickThrough.qml deleted file mode 100644 index 3c03161faa..0000000000 --- a/tests/auto/qtquick2/qquickmousearea/data/clickThrough.qml +++ /dev/null @@ -1,25 +0,0 @@ -import QtQuick 2.0 - -Item{ - width: 200 - height: 200 - property int doubleClicks: 0 - property int clicks: 0 - property int pressAndHolds: 0 - property int presses: 0 - MouseArea{ - z: 0 - anchors.fill: parent - propagateComposedEvents: true - onPressed: presses++ - onClicked: clicks++ - onPressAndHold: pressAndHolds++ - onDoubleClicked: doubleClicks++ - } - MouseArea{ - z: 1 - propagateComposedEvents: true - enabled: true - anchors.fill: parent - } -} diff --git a/tests/auto/qtquick2/qquickmousearea/data/clickThrough2.qml b/tests/auto/qtquick2/qquickmousearea/data/clickThrough2.qml deleted file mode 100644 index 2624108225..0000000000 --- a/tests/auto/qtquick2/qquickmousearea/data/clickThrough2.qml +++ /dev/null @@ -1,35 +0,0 @@ -import QtQuick 2.0 - -Item{ - width: 300 - height: 300 - property int doubleClicks: 0 - property int clicks: 0 - property int pressAndHolds: 0 - property int presses: 0 - property bool letThrough: false - property bool noPropagation: false - Rectangle{ - z: 0 - color: "lightsteelblue" - width: 150 - height: 150 - MouseArea{ - anchors.fill: parent - propagateComposedEvents: true - onPressed: presses++ - onClicked: clicks++ - onPressAndHold: pressAndHolds++ - onDoubleClicked: doubleClicks++ - } - } - MouseArea{ - z: 1 - enabled: true - anchors.fill: parent - propagateComposedEvents: !noPropagation - onClicked: mouse.accepted = !letThrough; - onDoubleClicked: mouse.accepted = !letThrough; - onPressAndHold: mouse.accepted = !letThrough; - } -} diff --git a/tests/auto/qtquick2/qquickmousearea/data/clickandhold.qml b/tests/auto/qtquick2/qquickmousearea/data/clickandhold.qml deleted file mode 100644 index 5e4e48f6db..0000000000 --- a/tests/auto/qtquick2/qquickmousearea/data/clickandhold.qml +++ /dev/null @@ -1,13 +0,0 @@ -import QtQuick 2.0 - -Item { - id: root - property bool clicked: false - property bool held: false - - MouseArea { - width: 200; height: 200 - onClicked: { root.clicked = true } - onPressAndHold: { root.held = true } - } -} diff --git a/tests/auto/qtquick2/qquickmousearea/data/clicktwice.qml b/tests/auto/qtquick2/qquickmousearea/data/clicktwice.qml deleted file mode 100644 index 002d1b9047..0000000000 --- a/tests/auto/qtquick2/qquickmousearea/data/clicktwice.qml +++ /dev/null @@ -1,16 +0,0 @@ -import QtQuick 2.0 - -Item { - id: root - property int clicked: 0 - property int pressed: 0 - property int released: 0 - - MouseArea { - width: 200; height: 200 - onPressed: { root.pressed++ } - onClicked: { root.clicked++ } - onReleased: { root.released++ } - } -} - diff --git a/tests/auto/qtquick2/qquickmousearea/data/doubleclick.qml b/tests/auto/qtquick2/qquickmousearea/data/doubleclick.qml deleted file mode 100644 index 1030d0c33e..0000000000 --- a/tests/auto/qtquick2/qquickmousearea/data/doubleclick.qml +++ /dev/null @@ -1,16 +0,0 @@ -import QtQuick 2.0 - -Item { - id: root - property int clicked: 0 - property int doubleClicked: 0 - property int released: 0 - - MouseArea { - width: 200; height: 200 - onClicked: { root.clicked++ } - onDoubleClicked: { root.doubleClicked++ } - onReleased: { root.released++ } - } -} - diff --git a/tests/auto/qtquick2/qquickmousearea/data/dragging.qml b/tests/auto/qtquick2/qquickmousearea/data/dragging.qml deleted file mode 100644 index d9b6ac4083..0000000000 --- a/tests/auto/qtquick2/qquickmousearea/data/dragging.qml +++ /dev/null @@ -1,28 +0,0 @@ -import QtQuick 2.0 -Rectangle { - id: whiteRect - width: 200 - height: 200 - color: "white" - Rectangle { - id: blackRect - objectName: "blackrect" - color: "black" - y: 50 - x: 50 - width: 100 - height: 100 - opacity: (whiteRect.width-blackRect.x+whiteRect.height-blackRect.y-199)/200 - Text { text: blackRect.opacity} - MouseArea { - objectName: "mouseregion" - anchors.fill: parent - drag.target: blackRect - drag.axis: Drag.XandYAxis - drag.minimumX: 0 - drag.maximumX: whiteRect.width-blackRect.width - drag.minimumY: 0 - drag.maximumY: whiteRect.height-blackRect.height - } - } - } diff --git a/tests/auto/qtquick2/qquickmousearea/data/dragproperties.qml b/tests/auto/qtquick2/qquickmousearea/data/dragproperties.qml deleted file mode 100644 index 421dfe26b7..0000000000 --- a/tests/auto/qtquick2/qquickmousearea/data/dragproperties.qml +++ /dev/null @@ -1,28 +0,0 @@ -import QtQuick 2.0 -Rectangle { - id: whiteRect - width: 200 - height: 200 - color: "white" - Rectangle { - id: blackRect - objectName: "blackrect" - color: "black" - y: 50 - x: 50 - width: 100 - height: 100 - opacity: (whiteRect.width-blackRect.x+whiteRect.height-blackRect.y-199)/200 - Text { text: blackRect.opacity} - MouseArea { - objectName: "mouseregion" - anchors.fill: parent - drag.target: blackRect - drag.axis: Drag.XandYAxis - drag.minimumX: 0 - drag.maximumX: whiteRect.width-blackRect.width - drag.minimumY: 0 - drag.maximumY: whiteRect.height-blackRect.height - } - } - } diff --git a/tests/auto/qtquick2/qquickmousearea/data/dragreset.qml b/tests/auto/qtquick2/qquickmousearea/data/dragreset.qml deleted file mode 100644 index d7949f9139..0000000000 --- a/tests/auto/qtquick2/qquickmousearea/data/dragreset.qml +++ /dev/null @@ -1,28 +0,0 @@ -import QtQuick 2.0 -Rectangle { - id: whiteRect - width: 200 - height: 200 - color: "white" - Rectangle { - id: blackRect - objectName: "blackrect" - color: "black" - y: 50 - x: 50 - width: 100 - height: 100 - opacity: (whiteRect.width-blackRect.x+whiteRect.height-blackRect.y-199)/200 - Text { text: blackRect.opacity} - MouseArea { - objectName: "mouseregion" - anchors.fill: parent - drag.target: haveTarget ? blackRect : undefined - drag.axis: Drag.XandYAxis - drag.minimumX: 0 - drag.maximumX: whiteRect.width-blackRect.width - drag.minimumY: 0 - drag.maximumY: whiteRect.height-blackRect.height - } - } - } diff --git a/tests/auto/qtquick2/qquickmousearea/data/hoverPosition.qml b/tests/auto/qtquick2/qquickmousearea/data/hoverPosition.qml deleted file mode 100644 index 834f91ff29..0000000000 --- a/tests/auto/qtquick2/qquickmousearea/data/hoverPosition.qml +++ /dev/null @@ -1,17 +0,0 @@ -import QtQuick 2.0 - -Rectangle { - width: 400; height: 400; - - property real mouseX: mousetracker.mouseX - property real mouseY: mousetracker.mouseY - - Rectangle { - width: 100; height: 100; - MouseArea { - id: mousetracker; - anchors.fill: parent; - hoverEnabled: true - } - } -} diff --git a/tests/auto/qtquick2/qquickmousearea/data/hoverPropagation.qml b/tests/auto/qtquick2/qquickmousearea/data/hoverPropagation.qml deleted file mode 100644 index c47c794132..0000000000 --- a/tests/auto/qtquick2/qquickmousearea/data/hoverPropagation.qml +++ /dev/null @@ -1,54 +0,0 @@ -import QtQuick 2.0 - -Item{ - width: 400 - height: 200 - property bool point1: ma2.containsMouse && !ma1.containsMouse - property bool point2: ma3.containsMouse && ma4.containsMouse - Rectangle{ - width: 200 - height: 200 - color: ma1.containsMouse ? "red" : "white" - MouseArea{ - id: ma1 - hoverEnabled: true - anchors.fill: parent - } - Rectangle{ - width: 100 - height: 100 - color: ma2.containsMouse ? "blue" : "white" - MouseArea{ - id: ma2 - hoverEnabled: true - anchors.fill: parent - } - } - } - - Item{ - x:200 - Rectangle{ - width: 200 - height: 200 - color: ma3.containsMouse ? "yellow" : "white" - Rectangle{ - width: 100 - height: 100 - color: ma4.containsMouse ? "green" : "white" - } - } - MouseArea{ - id: ma3 - hoverEnabled: true - width: 200 - height: 200 - MouseArea{ - id: ma4 - width: 100 - height: 100 - hoverEnabled: true - } - } - } -} diff --git a/tests/auto/qtquick2/qquickmousearea/data/hoverVisible.qml b/tests/auto/qtquick2/qquickmousearea/data/hoverVisible.qml deleted file mode 100644 index 2d65b5573e..0000000000 --- a/tests/auto/qtquick2/qquickmousearea/data/hoverVisible.qml +++ /dev/null @@ -1,15 +0,0 @@ -import QtQuick 2.0 - -Rectangle { - width: 400; height: 400; - - Rectangle { - width: 100; height: 100; - MouseArea { - id: mousetracker; objectName: "mousetracker" - anchors.fill: parent - visible: false - hoverEnabled: true - } - } -} diff --git a/tests/auto/qtquick2/qquickmousearea/data/noclickandhold.qml b/tests/auto/qtquick2/qquickmousearea/data/noclickandhold.qml deleted file mode 100644 index 6647de001d..0000000000 --- a/tests/auto/qtquick2/qquickmousearea/data/noclickandhold.qml +++ /dev/null @@ -1,11 +0,0 @@ -import QtQuick 2.0 - -Item { - id: root - property bool clicked: false - - MouseArea { - width: 200; height: 200 - onClicked: { root.clicked = true } - } -} diff --git a/tests/auto/qtquick2/qquickmousearea/data/pressedCanceled.qml b/tests/auto/qtquick2/qquickmousearea/data/pressedCanceled.qml deleted file mode 100644 index 231436d0f2..0000000000 --- a/tests/auto/qtquick2/qquickmousearea/data/pressedCanceled.qml +++ /dev/null @@ -1,18 +0,0 @@ -import QtQuick 2.0 - -Rectangle { - id: root - color: "#ffffff" - width: 320; height: 240 - property bool pressed:mouse.pressed - property bool canceled: false - property bool released: false - - MouseArea { - id: mouse - anchors.fill: parent - onPressed: { root.canceled = false } - onCanceled: {root.canceled = true} - onReleased: {root.released = true; root.canceled = false} - } -} \ No newline at end of file diff --git a/tests/auto/qtquick2/qquickmousearea/data/pressedOrdering.qml b/tests/auto/qtquick2/qquickmousearea/data/pressedOrdering.qml deleted file mode 100644 index 7aa3098100..0000000000 --- a/tests/auto/qtquick2/qquickmousearea/data/pressedOrdering.qml +++ /dev/null @@ -1,28 +0,0 @@ -import QtQuick 2.0 - -Item { - id: root - property string value: "base" - - MouseArea { - id: mouseArea - width: 200; height: 200 - onClicked: toggleState.state = "toggled" - } - - StateGroup { - states: State { - name: "pressed" - when: mouseArea.pressed - PropertyChanges { target: root; value: "pressed" } - } - } - - StateGroup { - id: toggleState - states: State { - name: "toggled" - PropertyChanges { target: root; value: "toggled" } - } - } -} diff --git a/tests/auto/qtquick2/qquickmousearea/data/preventstealing.qml b/tests/auto/qtquick2/qquickmousearea/data/preventstealing.qml deleted file mode 100644 index fb0d6955c1..0000000000 --- a/tests/auto/qtquick2/qquickmousearea/data/preventstealing.qml +++ /dev/null @@ -1,24 +0,0 @@ -import QtQuick 2.0 - -Flickable { - property bool stealing: true - width: 200 - height: 200 - contentWidth: 400 - contentHeight: 400 - Rectangle { - color: "black" - width: 400 - height: 400 - Rectangle { - x: 50; y: 50 - width: 100; height: 100 - color: "steelblue" - MouseArea { - objectName: "mousearea" - anchors.fill: parent - preventStealing: stealing - } - } - } -} diff --git a/tests/auto/qtquick2/qquickmousearea/data/rejectEvent.qml b/tests/auto/qtquick2/qquickmousearea/data/rejectEvent.qml deleted file mode 100644 index 816fc76fac..0000000000 --- a/tests/auto/qtquick2/qquickmousearea/data/rejectEvent.qml +++ /dev/null @@ -1,28 +0,0 @@ -import QtQuick 2.0 - -Rectangle { - id: root - color: "#ffffff" - width: 320; height: 240 - property bool mr1_pressed: false - property bool mr1_released: false - property bool mr1_canceled: false - property bool mr2_pressed: false - property bool mr2_released: false - property bool mr2_canceled: false - - MouseArea { - id: mouseRegion1 - anchors.fill: parent - onPressed: { root.mr1_pressed = true } - onReleased: { root.mr1_released = true } - onCanceled: { root.mr1_canceled = true } - } - MouseArea { - id: mouseRegion2 - width: 120; height: 120 - onPressed: { root.mr2_pressed = true; mouse.accepted = false } - onReleased: { root.mr2_released = true } - onCanceled: { root.mr2_canceled = true } - } -} diff --git a/tests/auto/qtquick2/qquickmousearea/data/updateMousePosOnClick.qml b/tests/auto/qtquick2/qquickmousearea/data/updateMousePosOnClick.qml deleted file mode 100644 index 7377a2e86c..0000000000 --- a/tests/auto/qtquick2/qquickmousearea/data/updateMousePosOnClick.qml +++ /dev/null @@ -1,20 +0,0 @@ -import QtQuick 2.0 - -Rectangle { - color: "#ffffff" - width: 320; height: 240 - MouseArea { - id: mouseRegion - objectName: "mouseregion" - anchors.fill: parent - Rectangle { - id: ball - objectName: "ball" - width: 20; height: 20 - radius: 10 - color: "#0000ff" - x: { mouseRegion.mouseX } - y: mouseRegion.mouseY - } - } -} diff --git a/tests/auto/qtquick2/qquickmousearea/data/updateMousePosOnResize.qml b/tests/auto/qtquick2/qquickmousearea/data/updateMousePosOnResize.qml deleted file mode 100644 index 55af864060..0000000000 --- a/tests/auto/qtquick2/qquickmousearea/data/updateMousePosOnResize.qml +++ /dev/null @@ -1,43 +0,0 @@ -import QtQuick 2.0 - -Rectangle { - color: "#ffffff" - width: 320; height: 240 - Rectangle { - id: brother - objectName: "brother" - color: "lightgreen" - x: 200; y: 100 - width: 120; height: 120 - } - MouseArea { - id: mouseRegion - objectName: "mouseregion" - - property int x1 - property int y1 - property int x2 - property int y2 - property bool emitPositionChanged: false - property bool mouseMatchesPos: true - - anchors.fill: brother - onPressed: { - if (mouse.x != mouseX || mouse.y != mouseY) - mouseMatchesPos = false - x1 = mouseX; y1 = mouseY - anchors.fill = parent - } - onPositionChanged: { emitPositionChanged = true } - onMouseXChanged: { - if (mouse.x != mouseX || mouse.y != mouseY) - mouseMatchesPos = false - x2 = mouseX; y2 = mouseY - } - onMouseYChanged: { - if (mouse.x != mouseX || mouse.y != mouseY) - mouseMatchesPos = false - x2 = mouseX; y2 = mouseY - } - } -} diff --git a/tests/auto/qtquick2/qquickmousearea/qquickmousearea.pro b/tests/auto/qtquick2/qquickmousearea/qquickmousearea.pro deleted file mode 100644 index 67d77dc05a..0000000000 --- a/tests/auto/qtquick2/qquickmousearea/qquickmousearea.pro +++ /dev/null @@ -1,17 +0,0 @@ -CONFIG += testcase -TARGET = tst_qquickmousearea -macx:CONFIG -= app_bundle - -HEADERS += ../../shared/testhttpserver.h -SOURCES += tst_qquickmousearea.cpp \ - ../../shared/testhttpserver.cpp - -include (../../shared/util.pri) - -testDataFiles.files = data -testDataFiles.path = . -DEPLOYMENT += testDataFiles - -CONFIG += parallel_test - -QT += core-private gui-private declarative-private quick-private network testlib diff --git a/tests/auto/qtquick2/qquickmousearea/tst_qquickmousearea.cpp b/tests/auto/qtquick2/qquickmousearea/tst_qquickmousearea.cpp deleted file mode 100644 index 66f651329a..0000000000 --- a/tests/auto/qtquick2/qquickmousearea/tst_qquickmousearea.cpp +++ /dev/null @@ -1,806 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "../../shared/util.h" - -//#define OLDWAY - -class tst_QQuickMouseArea: public QDeclarativeDataTest -{ - Q_OBJECT -private slots: - void dragProperties(); - void resetDrag(); - void dragging(); - void updateMouseAreaPosOnClick(); - void updateMouseAreaPosOnResize(); - void noOnClickedWithPressAndHold(); - void onMousePressRejected(); - void pressedCanceledOnWindowDeactivate(); - void doubleClick(); - void clickTwice(); - void pressedOrdering(); - void preventStealing(); - void clickThrough(); - void hoverPosition(); - void hoverPropagation(); - void hoverVisible(); - -private: - QQuickView *createView(); -}; - -void tst_QQuickMouseArea::dragProperties() -{ - QQuickView *canvas = createView(); - - canvas->setSource(testFileUrl("dragproperties.qml")); - canvas->show(); - canvas->requestActivateWindow(); - QVERIFY(canvas->rootObject() != 0); - - QQuickMouseArea *mouseRegion = canvas->rootObject()->findChild("mouseregion"); - QQuickDrag *drag = mouseRegion->drag(); - QVERIFY(mouseRegion != 0); - QVERIFY(drag != 0); - - // target - QQuickItem *blackRect = canvas->rootObject()->findChild("blackrect"); - QVERIFY(blackRect != 0); - QVERIFY(blackRect == drag->target()); - QQuickItem *rootItem = qobject_cast(canvas->rootObject()); - QVERIFY(rootItem != 0); - QSignalSpy targetSpy(drag, SIGNAL(targetChanged())); - drag->setTarget(rootItem); - QCOMPARE(targetSpy.count(),1); - drag->setTarget(rootItem); - QCOMPARE(targetSpy.count(),1); - - // axis - QCOMPARE(drag->axis(), QQuickDrag::XandYAxis); - QSignalSpy axisSpy(drag, SIGNAL(axisChanged())); - drag->setAxis(QQuickDrag::XAxis); - QCOMPARE(drag->axis(), QQuickDrag::XAxis); - QCOMPARE(axisSpy.count(),1); - drag->setAxis(QQuickDrag::XAxis); - QCOMPARE(axisSpy.count(),1); - - // minimum and maximum properties - QSignalSpy xminSpy(drag, SIGNAL(minimumXChanged())); - QSignalSpy xmaxSpy(drag, SIGNAL(maximumXChanged())); - QSignalSpy yminSpy(drag, SIGNAL(minimumYChanged())); - QSignalSpy ymaxSpy(drag, SIGNAL(maximumYChanged())); - - QCOMPARE(drag->xmin(), 0.0); - QCOMPARE(drag->xmax(), rootItem->width()-blackRect->width()); - QCOMPARE(drag->ymin(), 0.0); - QCOMPARE(drag->ymax(), rootItem->height()-blackRect->height()); - - drag->setXmin(10); - drag->setXmax(10); - drag->setYmin(10); - drag->setYmax(10); - - QCOMPARE(drag->xmin(), 10.0); - QCOMPARE(drag->xmax(), 10.0); - QCOMPARE(drag->ymin(), 10.0); - QCOMPARE(drag->ymax(), 10.0); - - QCOMPARE(xminSpy.count(),1); - QCOMPARE(xmaxSpy.count(),1); - QCOMPARE(yminSpy.count(),1); - QCOMPARE(ymaxSpy.count(),1); - - drag->setXmin(10); - drag->setXmax(10); - drag->setYmin(10); - drag->setYmax(10); - - QCOMPARE(xminSpy.count(),1); - QCOMPARE(xmaxSpy.count(),1); - QCOMPARE(yminSpy.count(),1); - QCOMPARE(ymaxSpy.count(),1); - - // filterChildren - QSignalSpy filterChildrenSpy(drag, SIGNAL(filterChildrenChanged())); - - drag->setFilterChildren(true); - - QVERIFY(drag->filterChildren()); - QCOMPARE(filterChildrenSpy.count(), 1); - - drag->setFilterChildren(true); - QCOMPARE(filterChildrenSpy.count(), 1); - - delete canvas; -} - -void tst_QQuickMouseArea::resetDrag() -{ - QQuickView *canvas = createView(); - - canvas->rootContext()->setContextProperty("haveTarget", QVariant(true)); - canvas->setSource(testFileUrl("dragreset.qml")); - canvas->show(); - canvas->requestActivateWindow(); - QVERIFY(canvas->rootObject() != 0); - - QQuickMouseArea *mouseRegion = canvas->rootObject()->findChild("mouseregion"); - QQuickDrag *drag = mouseRegion->drag(); - QVERIFY(mouseRegion != 0); - QVERIFY(drag != 0); - - // target - QQuickItem *blackRect = canvas->rootObject()->findChild("blackrect"); - QVERIFY(blackRect != 0); - QVERIFY(blackRect == drag->target()); - QQuickItem *rootItem = qobject_cast(canvas->rootObject()); - QVERIFY(rootItem != 0); - QSignalSpy targetSpy(drag, SIGNAL(targetChanged())); - QVERIFY(drag->target() != 0); - canvas->rootContext()->setContextProperty("haveTarget", QVariant(false)); - QCOMPARE(targetSpy.count(),1); - QVERIFY(drag->target() == 0); - - delete canvas; -} - - -void tst_QQuickMouseArea::dragging() -{ - QQuickView *canvas = createView(); - - canvas->setSource(testFileUrl("dragging.qml")); - canvas->show(); - canvas->requestActivateWindow(); - QTest::qWait(20); - QVERIFY(canvas->rootObject() != 0); - - QQuickMouseArea *mouseRegion = canvas->rootObject()->findChild("mouseregion"); - QQuickDrag *drag = mouseRegion->drag(); - QVERIFY(mouseRegion != 0); - QVERIFY(drag != 0); - - // target - QQuickItem *blackRect = canvas->rootObject()->findChild("blackrect"); - QVERIFY(blackRect != 0); - QVERIFY(blackRect == drag->target()); - - QVERIFY(!drag->active()); - -#ifdef OLDWAY - QMouseEvent pressEvent(QEvent::MouseButtonPress, QPoint(100, 100), Qt::LeftButton, Qt::LeftButton, 0); - QGuiApplication::sendEvent(canvas, &pressEvent); -#else - QTest::mousePress(canvas, Qt::LeftButton, 0, QPoint(100,100)); -#endif - - QVERIFY(!drag->active()); - QCOMPARE(blackRect->x(), 50.0); - QCOMPARE(blackRect->y(), 50.0); - - // First move event triggers drag, second is acted upon. - // This is due to possibility of higher stacked area taking precedence. - - QTest::mouseMove(canvas, QPoint(111,111)); - QTest::qWait(50); - QTest::mouseMove(canvas, QPoint(122,122)); - QTest::qWait(50); - - QVERIFY(drag->active()); - QCOMPARE(blackRect->x(), 72.0); - QCOMPARE(blackRect->y(), 72.0); - -#ifdef OLDWAY - QMouseEvent releaseEvent(QEvent::MouseButtonRelease, QPoint(100, 100), Qt::LeftButton, Qt::LeftButton, 0); - QGuiApplication::sendEvent(canvas, &releaseEvent); -#else - QTest::mouseRelease(canvas, Qt::LeftButton, 0, QPoint(122,122)); - QTest::qWait(50); -#endif - - QVERIFY(!drag->active()); - QCOMPARE(blackRect->x(), 72.0); - QCOMPARE(blackRect->y(), 72.0); - - delete canvas; -} - -QQuickView *tst_QQuickMouseArea::createView() -{ - QQuickView *canvas = new QQuickView(0); - canvas->setBaseSize(QSize(240,320)); - - return canvas; -} - -void tst_QQuickMouseArea::updateMouseAreaPosOnClick() -{ - QQuickView *canvas = createView(); - canvas->setSource(testFileUrl("updateMousePosOnClick.qml")); - canvas->show(); - canvas->requestActivateWindow(); - QVERIFY(canvas->rootObject() != 0); - - QQuickMouseArea *mouseRegion = canvas->rootObject()->findChild("mouseregion"); - QVERIFY(mouseRegion != 0); - - QQuickRectangle *rect = canvas->rootObject()->findChild("ball"); - QVERIFY(rect != 0); - - QCOMPARE(mouseRegion->mouseX(), rect->x()); - QCOMPARE(mouseRegion->mouseY(), rect->y()); - - QMouseEvent event(QEvent::MouseButtonPress, QPoint(100, 100), Qt::LeftButton, Qt::LeftButton, 0); - QGuiApplication::sendEvent(canvas, &event); - - QCOMPARE(mouseRegion->mouseX(), 100.0); - QCOMPARE(mouseRegion->mouseY(), 100.0); - - QCOMPARE(mouseRegion->mouseX(), rect->x()); - QCOMPARE(mouseRegion->mouseY(), rect->y()); - - delete canvas; -} - -void tst_QQuickMouseArea::updateMouseAreaPosOnResize() -{ - QQuickView *canvas = createView(); - canvas->setSource(testFileUrl("updateMousePosOnResize.qml")); - canvas->show(); - canvas->requestActivateWindow(); - QVERIFY(canvas->rootObject() != 0); - - QQuickMouseArea *mouseRegion = canvas->rootObject()->findChild("mouseregion"); - QVERIFY(mouseRegion != 0); - - QQuickRectangle *rect = canvas->rootObject()->findChild("brother"); - QVERIFY(rect != 0); - - QCOMPARE(mouseRegion->mouseX(), 0.0); - QCOMPARE(mouseRegion->mouseY(), 0.0); - - QMouseEvent event(QEvent::MouseButtonPress, rect->pos().toPoint(), Qt::LeftButton, Qt::LeftButton, 0); - QGuiApplication::sendEvent(canvas, &event); - - QVERIFY(!mouseRegion->property("emitPositionChanged").toBool()); - QVERIFY(mouseRegion->property("mouseMatchesPos").toBool()); - - QCOMPARE(mouseRegion->property("x1").toReal(), 0.0); - QCOMPARE(mouseRegion->property("y1").toReal(), 0.0); - - QCOMPARE(mouseRegion->property("x2").toReal(), rect->x()); - QCOMPARE(mouseRegion->property("y2").toReal(), rect->y()); - - QCOMPARE(mouseRegion->mouseX(), rect->x()); - QCOMPARE(mouseRegion->mouseY(), rect->y()); - - delete canvas; -} - -void tst_QQuickMouseArea::noOnClickedWithPressAndHold() -{ - { - // We handle onPressAndHold, therefore no onClicked - QQuickView *canvas = createView(); - canvas->setSource(testFileUrl("clickandhold.qml")); - canvas->show(); - canvas->requestActivateWindow(); - QVERIFY(canvas->rootObject() != 0); - - QMouseEvent pressEvent(QEvent::MouseButtonPress, QPoint(100, 100), Qt::LeftButton, Qt::LeftButton, 0); - QGuiApplication::sendEvent(canvas, &pressEvent); - - QVERIFY(!canvas->rootObject()->property("clicked").toBool()); - QVERIFY(!canvas->rootObject()->property("held").toBool()); - - QTest::qWait(1000); - - QMouseEvent releaseEvent(QEvent::MouseButtonRelease, QPoint(100, 100), Qt::LeftButton, Qt::LeftButton, 0); - QGuiApplication::sendEvent(canvas, &releaseEvent); - - QVERIFY(!canvas->rootObject()->property("clicked").toBool()); - QVERIFY(canvas->rootObject()->property("held").toBool()); - - delete canvas; - } - - { - // We do not handle onPressAndHold, therefore we get onClicked - QQuickView *canvas = createView(); - canvas->setSource(testFileUrl("noclickandhold.qml")); - canvas->show(); - canvas->requestActivateWindow(); - QVERIFY(canvas->rootObject() != 0); - - QMouseEvent pressEvent(QEvent::MouseButtonPress, QPoint(100, 100), Qt::LeftButton, Qt::LeftButton, 0); - QGuiApplication::sendEvent(canvas, &pressEvent); - - QVERIFY(!canvas->rootObject()->property("clicked").toBool()); - - QTest::qWait(1000); - - QMouseEvent releaseEvent(QEvent::MouseButtonRelease, QPoint(100, 100), Qt::LeftButton, Qt::LeftButton, 0); - QGuiApplication::sendEvent(canvas, &releaseEvent); - - QVERIFY(canvas->rootObject()->property("clicked").toBool()); - - delete canvas; - } -} - -void tst_QQuickMouseArea::onMousePressRejected() -{ - QQuickView *canvas = createView(); - canvas->setSource(testFileUrl("rejectEvent.qml")); - canvas->show(); - canvas->requestActivateWindow(); - QVERIFY(canvas->rootObject() != 0); - QVERIFY(canvas->rootObject()->property("enabled").toBool()); - - QVERIFY(!canvas->rootObject()->property("mr1_pressed").toBool()); - QVERIFY(!canvas->rootObject()->property("mr1_released").toBool()); - QVERIFY(!canvas->rootObject()->property("mr1_canceled").toBool()); - QVERIFY(!canvas->rootObject()->property("mr2_pressed").toBool()); - QVERIFY(!canvas->rootObject()->property("mr2_released").toBool()); - QVERIFY(!canvas->rootObject()->property("mr2_canceled").toBool()); - - QMouseEvent pressEvent(QEvent::MouseButtonPress, QPoint(100, 100), Qt::LeftButton, Qt::LeftButton, 0); - QGuiApplication::sendEvent(canvas, &pressEvent); - - QVERIFY(canvas->rootObject()->property("mr1_pressed").toBool()); - QVERIFY(!canvas->rootObject()->property("mr1_released").toBool()); - QVERIFY(!canvas->rootObject()->property("mr1_canceled").toBool()); - QVERIFY(canvas->rootObject()->property("mr2_pressed").toBool()); - QVERIFY(!canvas->rootObject()->property("mr2_released").toBool()); - QVERIFY(canvas->rootObject()->property("mr2_canceled").toBool()); - - QTest::qWait(200); - - QMouseEvent releaseEvent(QEvent::MouseButtonRelease, QPoint(100, 100), Qt::LeftButton, Qt::LeftButton, 0); - QGuiApplication::sendEvent(canvas, &releaseEvent); - - QVERIFY(canvas->rootObject()->property("mr1_released").toBool()); - QVERIFY(!canvas->rootObject()->property("mr1_canceled").toBool()); - QVERIFY(!canvas->rootObject()->property("mr2_released").toBool()); - - delete canvas; -} -void tst_QQuickMouseArea::pressedCanceledOnWindowDeactivate() -{ - QQuickView *canvas = createView(); - canvas->setSource(testFileUrl("pressedCanceled.qml")); - canvas->show(); - canvas->requestActivateWindow(); - QVERIFY(canvas->rootObject() != 0); - QVERIFY(!canvas->rootObject()->property("pressed").toBool()); - QVERIFY(!canvas->rootObject()->property("canceled").toBool()); - QVERIFY(!canvas->rootObject()->property("released").toBool()); - - QMouseEvent pressEvent(QEvent::MouseButtonPress, QPoint(100, 100), Qt::LeftButton, Qt::LeftButton, 0); - QGuiApplication::sendEvent(canvas, &pressEvent); - - QVERIFY(canvas->rootObject()->property("pressed").toBool()); - QVERIFY(!canvas->rootObject()->property("canceled").toBool()); - QVERIFY(!canvas->rootObject()->property("released").toBool()); - - QTest::qWait(200); - - QEvent windowDeactivateEvent(QEvent::WindowDeactivate); - QGuiApplication::sendEvent(canvas, &windowDeactivateEvent); - QVERIFY(!canvas->rootObject()->property("pressed").toBool()); - QVERIFY(canvas->rootObject()->property("canceled").toBool()); - QVERIFY(!canvas->rootObject()->property("released").toBool()); - - QTest::qWait(200); - - //press again - QGuiApplication::sendEvent(canvas, &pressEvent); - QVERIFY(canvas->rootObject()->property("pressed").toBool()); - QVERIFY(!canvas->rootObject()->property("canceled").toBool()); - QVERIFY(!canvas->rootObject()->property("released").toBool()); - - QTest::qWait(200); - - //release - QMouseEvent releaseEvent(QEvent::MouseButtonRelease, QPoint(100, 100), Qt::LeftButton, Qt::LeftButton, 0); - QGuiApplication::sendEvent(canvas, &releaseEvent); - QVERIFY(!canvas->rootObject()->property("pressed").toBool()); - QVERIFY(!canvas->rootObject()->property("canceled").toBool()); - QVERIFY(canvas->rootObject()->property("released").toBool()); - - delete canvas; -} -void tst_QQuickMouseArea::doubleClick() -{ - QQuickView *canvas = createView(); - canvas->setSource(testFileUrl("doubleclick.qml")); - canvas->show(); - canvas->requestActivateWindow(); - QVERIFY(canvas->rootObject() != 0); - - QMouseEvent pressEvent(QEvent::MouseButtonPress, QPoint(100, 100), Qt::LeftButton, Qt::LeftButton, 0); - QGuiApplication::sendEvent(canvas, &pressEvent); - - QMouseEvent releaseEvent(QEvent::MouseButtonRelease, QPoint(100, 100), Qt::LeftButton, Qt::LeftButton, 0); - QGuiApplication::sendEvent(canvas, &releaseEvent); - - QCOMPARE(canvas->rootObject()->property("released").toInt(), 1); - - pressEvent = QMouseEvent(QEvent::MouseButtonDblClick, QPoint(100, 100), Qt::LeftButton, Qt::LeftButton, 0); - QGuiApplication::sendEvent(canvas, &pressEvent); - - QGuiApplication::sendEvent(canvas, &releaseEvent); - - QCOMPARE(canvas->rootObject()->property("clicked").toInt(), 1); - QCOMPARE(canvas->rootObject()->property("doubleClicked").toInt(), 1); - QCOMPARE(canvas->rootObject()->property("released").toInt(), 2); - - delete canvas; -} - -// QTBUG-14832 -void tst_QQuickMouseArea::clickTwice() -{ - QQuickView *canvas = createView(); - canvas->setSource(testFileUrl("clicktwice.qml")); - canvas->show(); - canvas->requestActivateWindow(); - QVERIFY(canvas->rootObject() != 0); - - QMouseEvent pressEvent(QEvent::MouseButtonPress, QPoint(100, 100), Qt::LeftButton, Qt::LeftButton, 0); - QGuiApplication::sendEvent(canvas, &pressEvent); - - QMouseEvent releaseEvent(QEvent::MouseButtonRelease, QPoint(100, 100), Qt::LeftButton, Qt::LeftButton, 0); - QGuiApplication::sendEvent(canvas, &releaseEvent); - - QCOMPARE(canvas->rootObject()->property("pressed").toInt(), 1); - QCOMPARE(canvas->rootObject()->property("released").toInt(), 1); - QCOMPARE(canvas->rootObject()->property("clicked").toInt(), 1); - - pressEvent = QMouseEvent(QEvent::MouseButtonDblClick, QPoint(100, 100), Qt::LeftButton, Qt::LeftButton, 0); - QGuiApplication::sendEvent(canvas, &pressEvent); - - QGuiApplication::sendEvent(canvas, &pressEvent); - QGuiApplication::sendEvent(canvas, &releaseEvent); - - QCOMPARE(canvas->rootObject()->property("pressed").toInt(), 2); - QCOMPARE(canvas->rootObject()->property("released").toInt(), 2); - QCOMPARE(canvas->rootObject()->property("clicked").toInt(), 2); - - delete canvas; -} - -void tst_QQuickMouseArea::pressedOrdering() -{ - QQuickView *canvas = createView(); - canvas->setSource(testFileUrl("pressedOrdering.qml")); - canvas->show(); - canvas->requestActivateWindow(); - QVERIFY(canvas->rootObject() != 0); - - QCOMPARE(canvas->rootObject()->property("value").toString(), QLatin1String("base")); - - QMouseEvent pressEvent(QEvent::MouseButtonPress, QPoint(100, 100), Qt::LeftButton, Qt::LeftButton, 0); - QGuiApplication::sendEvent(canvas, &pressEvent); - - QCOMPARE(canvas->rootObject()->property("value").toString(), QLatin1String("pressed")); - - QMouseEvent releaseEvent(QEvent::MouseButtonRelease, QPoint(100, 100), Qt::LeftButton, Qt::LeftButton, 0); - QGuiApplication::sendEvent(canvas, &releaseEvent); - - QCOMPARE(canvas->rootObject()->property("value").toString(), QLatin1String("toggled")); - - QGuiApplication::sendEvent(canvas, &pressEvent); - - QCOMPARE(canvas->rootObject()->property("value").toString(), QLatin1String("pressed")); - - delete canvas; -} - -void tst_QQuickMouseArea::preventStealing() -{ - QQuickView *canvas = createView(); - - canvas->setSource(testFileUrl("preventstealing.qml")); - canvas->show(); - canvas->requestActivateWindow(); - QVERIFY(canvas->rootObject() != 0); - - QQuickFlickable *flickable = qobject_cast(canvas->rootObject()); - QVERIFY(flickable != 0); - - QQuickMouseArea *mouseArea = canvas->rootObject()->findChild("mousearea"); - QVERIFY(mouseArea != 0); - - QSignalSpy mousePositionSpy(mouseArea, SIGNAL(positionChanged(QQuickMouseEvent*))); - - QTest::mousePress(canvas, Qt::LeftButton, 0, QPoint(80, 80)); - - // Without preventStealing, mouse movement over MouseArea would - // cause the Flickable to steal mouse and trigger content movement. - - QTest::mouseMove(canvas,QPoint(69,69)); - QTest::mouseMove(canvas,QPoint(58,58)); - QTest::mouseMove(canvas,QPoint(47,47)); - - // We should have received all three move events - QCOMPARE(mousePositionSpy.count(), 3); - QVERIFY(mouseArea->pressed()); - - // Flickable content should not have moved. - QCOMPARE(flickable->contentX(), 0.); - QCOMPARE(flickable->contentY(), 0.); - - QTest::mouseRelease(canvas, Qt::LeftButton, 0, QPoint(47, 47)); - - // Now allow stealing and confirm Flickable does its thing. - canvas->rootObject()->setProperty("stealing", false); - - QTest::mousePress(canvas, Qt::LeftButton, 0, QPoint(80, 80)); - - // Without preventStealing, mouse movement over MouseArea would - // cause the Flickable to steal mouse and trigger content movement. - - QTest::mouseMove(canvas,QPoint(69,69)); - QTest::mouseMove(canvas,QPoint(58,58)); - QTest::mouseMove(canvas,QPoint(47,47)); - - // We should only have received the first move event - QCOMPARE(mousePositionSpy.count(), 4); - // Our press should be taken away - QVERIFY(!mouseArea->pressed()); - - // Flickable content should have moved. - - QCOMPARE(flickable->contentX(), 11.); - QCOMPARE(flickable->contentY(), 11.); - - QTest::mouseRelease(canvas, Qt::LeftButton, 0, QPoint(50, 50)); - - delete canvas; -} - -void tst_QQuickMouseArea::clickThrough() -{ - QSKIP("QTBUG-23976 Unstable"); - //With no handlers defined click, doubleClick and PressAndHold should propagate to those with handlers - QQuickView *canvas = createView(); - canvas->setSource(testFileUrl("clickThrough.qml")); - canvas->show(); - canvas->requestActivateWindow(); - QVERIFY(canvas->rootObject() != 0); - - QTest::mousePress(canvas, Qt::LeftButton, 0, QPoint(100,100)); - QTest::mouseRelease(canvas, Qt::LeftButton, 0, QPoint(100,100)); - - QTRY_COMPARE(canvas->rootObject()->property("presses").toInt(), 0); - QTRY_COMPARE(canvas->rootObject()->property("clicks").toInt(), 1); - - QTest::qWait(800); // to avoid generating a double click. - - QTest::mousePress(canvas, Qt::LeftButton, 0, QPoint(100,100)); - QTest::qWait(1000); - QTest::mouseRelease(canvas, Qt::LeftButton, 0, QPoint(100,100)); - - QTRY_COMPARE(canvas->rootObject()->property("presses").toInt(), 0); - QTRY_COMPARE(canvas->rootObject()->property("clicks").toInt(), 1); - QTRY_COMPARE(canvas->rootObject()->property("pressAndHolds").toInt(), 1); - - QTest::mouseDClick(canvas, Qt::LeftButton, 0, QPoint(100,100)); - QTest::qWait(100); - - QCOMPARE(canvas->rootObject()->property("presses").toInt(), 0); - QTRY_COMPARE(canvas->rootObject()->property("clicks").toInt(), 2); - QTRY_COMPARE(canvas->rootObject()->property("doubleClicks").toInt(), 1); - QCOMPARE(canvas->rootObject()->property("pressAndHolds").toInt(), 1); - - delete canvas; - - //With handlers defined click, doubleClick and PressAndHold should propagate only when explicitly ignored - canvas = createView(); - canvas->setSource(testFileUrl("clickThrough2.qml")); - canvas->show(); - canvas->requestActivateWindow(); - QVERIFY(canvas->rootObject() != 0); - - QTest::mousePress(canvas, Qt::LeftButton, 0, QPoint(100,100)); - QTest::mouseRelease(canvas, Qt::LeftButton, 0, QPoint(100,100)); - - QCOMPARE(canvas->rootObject()->property("presses").toInt(), 0); - QCOMPARE(canvas->rootObject()->property("clicks").toInt(), 0); - - QTest::qWait(800); // to avoid generating a double click. - - QTest::mousePress(canvas, Qt::LeftButton, 0, QPoint(100,100)); - QTest::qWait(1000); - QTest::mouseRelease(canvas, Qt::LeftButton, 0, QPoint(100,100)); - QTest::qWait(100); - - QCOMPARE(canvas->rootObject()->property("presses").toInt(), 0); - QCOMPARE(canvas->rootObject()->property("clicks").toInt(), 0); - QCOMPARE(canvas->rootObject()->property("pressAndHolds").toInt(), 0); - - QTest::mouseDClick(canvas, Qt::LeftButton, 0, QPoint(100,100)); - QTest::qWait(100); - - QCOMPARE(canvas->rootObject()->property("presses").toInt(), 0); - QCOMPARE(canvas->rootObject()->property("clicks").toInt(), 0); - QCOMPARE(canvas->rootObject()->property("doubleClicks").toInt(), 0); - QCOMPARE(canvas->rootObject()->property("pressAndHolds").toInt(), 0); - - canvas->rootObject()->setProperty("letThrough", QVariant(true)); - - QTest::qWait(800); // to avoid generating a double click. - QTest::mousePress(canvas, Qt::LeftButton, 0, QPoint(100,100)); - QTest::mouseRelease(canvas, Qt::LeftButton, 0, QPoint(100,100)); - - QCOMPARE(canvas->rootObject()->property("presses").toInt(), 0); - QTRY_COMPARE(canvas->rootObject()->property("clicks").toInt(), 1); - - QTest::qWait(800); // to avoid generating a double click. - QTest::mousePress(canvas, Qt::LeftButton, 0, QPoint(100,100)); - QTest::qWait(1000); - QTest::mouseRelease(canvas, Qt::LeftButton, 0, QPoint(100,100)); - QTest::qWait(100); - - QCOMPARE(canvas->rootObject()->property("presses").toInt(), 0); - QCOMPARE(canvas->rootObject()->property("clicks").toInt(), 1); - QCOMPARE(canvas->rootObject()->property("pressAndHolds").toInt(), 1); - - QTest::mouseDClick(canvas, Qt::LeftButton, 0, QPoint(100,100)); - QTest::qWait(100); - - QCOMPARE(canvas->rootObject()->property("presses").toInt(), 0); - QTRY_COMPARE(canvas->rootObject()->property("clicks").toInt(), 2); - QCOMPARE(canvas->rootObject()->property("doubleClicks").toInt(), 1); - QCOMPARE(canvas->rootObject()->property("pressAndHolds").toInt(), 1); - - canvas->rootObject()->setProperty("noPropagation", QVariant(true)); - - QTest::qWait(800); // to avoid generating a double click. - QTest::mousePress(canvas, Qt::LeftButton, 0, QPoint(100,100)); - QTest::mouseRelease(canvas, Qt::LeftButton, 0, QPoint(100,100)); - - QTest::qWait(800); // to avoid generating a double click. - QTest::mousePress(canvas, Qt::LeftButton, 0, QPoint(100,100)); - QTest::qWait(1000); - QTest::mouseRelease(canvas, Qt::LeftButton, 0, QPoint(100,100)); - QTest::qWait(100); - - QTest::mouseDClick(canvas, Qt::LeftButton, 0, QPoint(100,100)); - QTest::qWait(100); - - QCOMPARE(canvas->rootObject()->property("presses").toInt(), 0); - QTRY_COMPARE(canvas->rootObject()->property("clicks").toInt(), 2); - QCOMPARE(canvas->rootObject()->property("doubleClicks").toInt(), 1); - QCOMPARE(canvas->rootObject()->property("pressAndHolds").toInt(), 1); - - delete canvas; -} - -void tst_QQuickMouseArea::hoverPosition() -{ - QQuickView *canvas = createView(); - canvas->setSource(testFileUrl("hoverPosition.qml")); - - QQuickItem *root = canvas->rootObject(); - QVERIFY(root != 0); - - QCOMPARE(root->property("mouseX").toReal(), qreal(0)); - QCOMPARE(root->property("mouseY").toReal(), qreal(0)); - - QTest::mouseMove(canvas,QPoint(10,32)); - - - QCOMPARE(root->property("mouseX").toReal(), qreal(10)); - QCOMPARE(root->property("mouseY").toReal(), qreal(32)); - - delete canvas; -} - -void tst_QQuickMouseArea::hoverPropagation() -{ - //QTBUG-18175, to behave like GV did. - QQuickView *canvas = createView(); - canvas->setSource(testFileUrl("hoverPropagation.qml")); - - QQuickItem *root = canvas->rootObject(); - QVERIFY(root != 0); - - QCOMPARE(root->property("point1").toBool(), false); - QCOMPARE(root->property("point2").toBool(), false); - - QMouseEvent moveEvent(QEvent::MouseMove, QPoint(32, 32), Qt::NoButton, Qt::NoButton, 0); - QGuiApplication::sendEvent(canvas, &moveEvent); - - QCOMPARE(root->property("point1").toBool(), true); - QCOMPARE(root->property("point2").toBool(), false); - - QMouseEvent moveEvent2(QEvent::MouseMove, QPoint(232, 32), Qt::NoButton, Qt::NoButton, 0); - QGuiApplication::sendEvent(canvas, &moveEvent2); - QCOMPARE(root->property("point1").toBool(), false); - QCOMPARE(root->property("point2").toBool(), true); - - delete canvas; -} - -void tst_QQuickMouseArea::hoverVisible() -{ - QQuickView *canvas = createView(); - canvas->setSource(testFileUrl("hoverVisible.qml")); - - QQuickItem *root = canvas->rootObject(); - QVERIFY(root != 0); - - QQuickMouseArea *mouseTracker = canvas->rootObject()->findChild("mousetracker"); - QVERIFY(mouseTracker != 0); - - QSignalSpy enteredSpy(mouseTracker, SIGNAL(entered())); - - QTest::mouseMove(canvas,QPoint(10,32)); - - QCOMPARE(mouseTracker->hovered(), false); - QCOMPARE(enteredSpy.count(), 0); - - mouseTracker->setVisible(true); - - QCOMPARE(mouseTracker->hovered(), true); - QCOMPARE(enteredSpy.count(), 1); - - QEXPECT_FAIL("", "QTBUG-24282", Continue); - QCOMPARE(QPointF(mouseTracker->mouseX(), mouseTracker->mouseY()), QPointF(10,32)); - - delete canvas; -} - -QTEST_MAIN(tst_QQuickMouseArea) - -#include "tst_qquickmousearea.moc" diff --git a/tests/auto/qtquick2/qquickmultipointtoucharea/data/basic.qml b/tests/auto/qtquick2/qquickmultipointtoucharea/data/basic.qml deleted file mode 100644 index cd6ce8146f..0000000000 --- a/tests/auto/qtquick2/qquickmultipointtoucharea/data/basic.qml +++ /dev/null @@ -1,15 +0,0 @@ -import QtQuick 2.0 - -MultiPointTouchArea { - width: 240 - height: 320 - - minimumTouchPoints: 1 - maximumTouchPoints: 4 - touchPoints: [ - TouchPoint { objectName: "point1" }, - TouchPoint { objectName: "point2" }, - TouchPoint { objectName: "point3" }, - TouchPoint { objectName: "point4" } - ] -} diff --git a/tests/auto/qtquick2/qquickmultipointtoucharea/data/inFlickable.qml b/tests/auto/qtquick2/qquickmultipointtoucharea/data/inFlickable.qml deleted file mode 100644 index 9c9132d0b0..0000000000 --- a/tests/auto/qtquick2/qquickmultipointtoucharea/data/inFlickable.qml +++ /dev/null @@ -1,31 +0,0 @@ -import QtQuick 2.0 - -Flickable { - width: 240 - height: 320 - - contentWidth: width - contentHeight: height * 2 - - property int cancelCount: 0 - property int touchCount: 0 - - MultiPointTouchArea { - anchors.fill: parent - minimumTouchPoints: 2 - maximumTouchPoints: 2 - onGestureStarted: { - if ((Math.abs(point2.x - point2.startX) > gesture.dragThreshold/2) && (Math.abs(point1.x - point1.startX) > gesture.dragThreshold/2)) { - gesture.grab() - } - } - touchPoints: [ - TouchPoint { id: point1; objectName: "point1" }, - TouchPoint { id: point2; objectName: "point2" } - ] - - onCanceled: cancelCount = touchPoints.length - onTouchUpdated: touchCount = touchPoints.length - } -} - diff --git a/tests/auto/qtquick2/qquickmultipointtoucharea/data/nested.qml b/tests/auto/qtquick2/qquickmultipointtoucharea/data/nested.qml deleted file mode 100644 index 37b8820aa0..0000000000 --- a/tests/auto/qtquick2/qquickmultipointtoucharea/data/nested.qml +++ /dev/null @@ -1,27 +0,0 @@ -import QtQuick 2.0 - -MultiPointTouchArea { - width: 240 - height: 320 - - property bool grabInnerArea: true - - minimumTouchPoints: 2 - maximumTouchPoints: 3 - touchPoints: [ - TouchPoint { objectName: "point11" }, - TouchPoint { objectName: "point12" } - ] - - MultiPointTouchArea { - anchors.fill: parent - minimumTouchPoints: 3 - maximumTouchPoints: 3 - onGestureStarted: if (grabInnerArea) gesture.grab() - touchPoints: [ - TouchPoint { objectName: "point21" }, - TouchPoint { objectName: "point22" }, - TouchPoint { objectName: "point23" } - ] - } -} diff --git a/tests/auto/qtquick2/qquickmultipointtoucharea/data/nonOverlapping.qml b/tests/auto/qtquick2/qquickmultipointtoucharea/data/nonOverlapping.qml deleted file mode 100644 index 039607e26c..0000000000 --- a/tests/auto/qtquick2/qquickmultipointtoucharea/data/nonOverlapping.qml +++ /dev/null @@ -1,32 +0,0 @@ -import QtQuick 2.0 - -Rectangle { - width: 240 - height: 320 - - MultiPointTouchArea { - width: parent.width - height: 160 - minimumTouchPoints: 2 - maximumTouchPoints: 2 - onGestureStarted: gesture.grab() - touchPoints: [ - TouchPoint { objectName: "point11" }, - TouchPoint { objectName: "point12" } - ] - } - - MultiPointTouchArea { - width: parent.width - height: 160 - y: 160 - minimumTouchPoints: 3 - maximumTouchPoints: 3 - onGestureStarted: gesture.grab() - touchPoints: [ - TouchPoint { objectName: "point21" }, - TouchPoint { objectName: "point22" }, - TouchPoint { objectName: "point23" } - ] - } -} diff --git a/tests/auto/qtquick2/qquickmultipointtoucharea/data/properties.qml b/tests/auto/qtquick2/qquickmultipointtoucharea/data/properties.qml deleted file mode 100644 index 98ef1a9cbe..0000000000 --- a/tests/auto/qtquick2/qquickmultipointtoucharea/data/properties.qml +++ /dev/null @@ -1,15 +0,0 @@ -import QtQuick 2.0 - -MultiPointTouchArea { - width: 240 - height: 320 - - minimumTouchPoints: 2 - maximumTouchPoints: 4 - touchPoints: [ - TouchPoint {}, - TouchPoint {}, - TouchPoint {}, - TouchPoint {} - ] -} diff --git a/tests/auto/qtquick2/qquickmultipointtoucharea/data/signalTest.qml b/tests/auto/qtquick2/qquickmultipointtoucharea/data/signalTest.qml deleted file mode 100644 index 54b160c182..0000000000 --- a/tests/auto/qtquick2/qquickmultipointtoucharea/data/signalTest.qml +++ /dev/null @@ -1,30 +0,0 @@ -import QtQuick 2.0 - -MultiPointTouchArea { - width: 240 - height: 320 - - function clearCounts() { - touchPointPressCount = 0; - touchPointUpdateCount = 0; - touchPointReleaseCount = 0; - touchCount = 0; - touchUpdatedHandled = false; - } - - property int touchPointPressCount: 0 - property int touchPointUpdateCount: 0 - property int touchPointReleaseCount: 0 - property int touchCount: 0 - property bool touchUpdatedHandled: false - - maximumTouchPoints: 5 - - onPressed: { touchPointPressCount = touchPoints.length } - onUpdated: { touchPointUpdateCount = touchPoints.length } - onReleased: { touchPointReleaseCount = touchPoints.length } - onTouchUpdated: { - touchCount = touchPoints.length - touchUpdatedHandled = true - } -} diff --git a/tests/auto/qtquick2/qquickmultipointtoucharea/qquickmultipointtoucharea.pro b/tests/auto/qtquick2/qquickmultipointtoucharea/qquickmultipointtoucharea.pro deleted file mode 100644 index 38c32099b0..0000000000 --- a/tests/auto/qtquick2/qquickmultipointtoucharea/qquickmultipointtoucharea.pro +++ /dev/null @@ -1,11 +0,0 @@ -TARGET = tst_qquickmultipointtoucharea -CONFIG += testcase -macx:CONFIG -= app_bundle - -SOURCES += tst_qquickmultipointtoucharea.cpp - -importFiles.files = data -importFiles.path = . -DEPLOYMENT += importFiles - -QT += core-private gui-private declarative-private quick-private testlib diff --git a/tests/auto/qtquick2/qquickmultipointtoucharea/tst_qquickmultipointtoucharea.cpp b/tests/auto/qtquick2/qquickmultipointtoucharea/tst_qquickmultipointtoucharea.cpp deleted file mode 100644 index 0a154d0a7b..0000000000 --- a/tests/auto/qtquick2/qquickmultipointtoucharea/tst_qquickmultipointtoucharea.cpp +++ /dev/null @@ -1,727 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include -#include -#include -#include -#include - -class tst_QQuickMultiPointTouchArea: public QObject -{ - Q_OBJECT -public: - tst_QQuickMultiPointTouchArea() : device(0) { } -private slots: - void initTestCase() { - if (!device) { - device = new QTouchDevice; - device->setType(QTouchDevice::TouchScreen); - QWindowSystemInterface::registerTouchDevice(device); - } - } - void cleanupTestCase() {} - - void properties(); - void signalTest(); - void release(); - void reuse(); - void nonOverlapping(); - void nested(); - void inFlickable(); - void invisible(); - -private: - QQuickView *createAndShowView(const QString &file); - QTouchDevice *device; -}; - -void tst_QQuickMultiPointTouchArea::properties() -{ - QQuickView *canvas = createAndShowView("properties.qml"); - QVERIFY(canvas->rootObject() != 0); - - QQuickMultiPointTouchArea *area = qobject_cast(canvas->rootObject()); - QVERIFY(area != 0); - - QCOMPARE(area->minimumTouchPoints(), 2); - QCOMPARE(area->maximumTouchPoints(), 4); - - QDeclarativeListReference ref(area, "touchPoints"); - QCOMPARE(ref.count(), 4); - - delete canvas; -} - -void tst_QQuickMultiPointTouchArea::signalTest() -{ - QQuickView *canvas = createAndShowView("signalTest.qml"); - QVERIFY(canvas->rootObject() != 0); - - QQuickMultiPointTouchArea *area = qobject_cast(canvas->rootObject()); - QVERIFY(area != 0); - - QPoint p1(20,100); - QPoint p2(40,100); - QPoint p3(60,100); - QPoint p4(80,100); - QPoint p5(100,100); - - QTest::QTouchEventSequence sequence = QTest::touchEvent(canvas, device); - - sequence.press(0, p1).press(1, p2).commit(); - - QCOMPARE(area->property("touchPointPressCount").toInt(), 2); - QCOMPARE(area->property("touchPointUpdateCount").toInt(), 0); - QCOMPARE(area->property("touchPointReleaseCount").toInt(), 0); - QCOMPARE(area->property("touchCount").toInt(), 2); - QMetaObject::invokeMethod(area, "clearCounts"); - - sequence.stationary(0).stationary(1).press(2, p3).commit(); - - QCOMPARE(area->property("touchPointPressCount").toInt(), 1); - QCOMPARE(area->property("touchPointUpdateCount").toInt(), 0); - QCOMPARE(area->property("touchPointReleaseCount").toInt(), 0); - QCOMPARE(area->property("touchCount").toInt(), 3); - QMetaObject::invokeMethod(area, "clearCounts"); - - p1 -= QPoint(10,10); - p2 += QPoint(10,10); - sequence.move(0, p1).move(1, p2).stationary(2).commit(); - - QCOMPARE(area->property("touchPointPressCount").toInt(), 0); - QCOMPARE(area->property("touchPointUpdateCount").toInt(), 2); - QCOMPARE(area->property("touchPointReleaseCount").toInt(), 0); - QCOMPARE(area->property("touchCount").toInt(), 3); - QMetaObject::invokeMethod(area, "clearCounts"); - - p3 += QPoint(10,10); - sequence.release(0, p1).release(1, p2) - .move(2, p3).press(3, p4).press(4, p5).commit(); - - QCOMPARE(area->property("touchPointPressCount").toInt(), 2); - QCOMPARE(area->property("touchPointUpdateCount").toInt(), 1); - QCOMPARE(area->property("touchPointReleaseCount").toInt(), 2); - QCOMPARE(area->property("touchCount").toInt(), 3); - QMetaObject::invokeMethod(area, "clearCounts"); - - sequence.release(2, p3).release(3, p4).release(4, p5).commit(); - - QCOMPARE(area->property("touchPointPressCount").toInt(), 0); - QCOMPARE(area->property("touchPointUpdateCount").toInt(), 0); - QCOMPARE(area->property("touchPointReleaseCount").toInt(), 3); - QCOMPARE(area->property("touchCount").toInt(), 0); - QCOMPARE(area->property("touchUpdatedHandled").toBool(), true); - QMetaObject::invokeMethod(area, "clearCounts"); - - delete canvas; -} - -void tst_QQuickMultiPointTouchArea::release() -{ - QQuickView *canvas = createAndShowView("basic.qml"); - QVERIFY(canvas->rootObject() != 0); - - QQuickTouchPoint *point1 = canvas->rootObject()->findChild("point1"); - - QCOMPARE(point1->pressed(), false); - - QPoint p1(20,100); - - QTest::QTouchEventSequence sequence = QTest::touchEvent(canvas, device); - - sequence.press(0, p1).commit(); - - QCOMPARE(point1->pressed(), true); - - p1 += QPoint(0,10); - - sequence.move(0, p1).commit(); - - QCOMPARE(point1->pressed(), true); - QCOMPARE(point1->x(), qreal(20)); QCOMPARE(point1->y(), qreal(110)); - - p1 += QPoint(4,10); - - sequence.release(0, p1).commit(); - - //test that a release without a prior move to the release position successfully updates the point's position - QCOMPARE(point1->pressed(), false); - QCOMPARE(point1->x(), qreal(24)); QCOMPARE(point1->y(), qreal(120)); - - delete canvas; -} - -void tst_QQuickMultiPointTouchArea::reuse() -{ - QQuickView *canvas = createAndShowView("basic.qml"); - QVERIFY(canvas->rootObject() != 0); - - QQuickTouchPoint *point1 = canvas->rootObject()->findChild("point1"); - QQuickTouchPoint *point2 = canvas->rootObject()->findChild("point2"); - QQuickTouchPoint *point3 = canvas->rootObject()->findChild("point3"); - - QCOMPARE(point1->pressed(), false); - QCOMPARE(point2->pressed(), false); - - QPoint p1(20,100); - QPoint p2(40,100); - QPoint p3(60,100); - QPoint p4(80,100); - - QTest::QTouchEventSequence sequence = QTest::touchEvent(canvas, device); - - sequence.press(0, p1).press(1, p2).commit(); - - QCOMPARE(point1->pressed(), true); - QCOMPARE(point2->pressed(), true); - QCOMPARE(point3->pressed(), false); - - sequence.release(0, p1).stationary(1).press(2, p3).commit(); - - //we shouldn't reuse point 1 yet - QCOMPARE(point1->pressed(), false); - QCOMPARE(point2->pressed(), true); - QCOMPARE(point3->pressed(), true); - - //back to base state (no touches) - sequence.release(1, p2).release(2, p3).commit(); - - QCOMPARE(point1->pressed(), false); - QCOMPARE(point2->pressed(), false); - QCOMPARE(point3->pressed(), false); - - sequence.press(0, p1).press(1, p2).commit(); - - QCOMPARE(point1->pressed(), true); - QCOMPARE(point2->pressed(), true); - QCOMPARE(point3->pressed(), false); - - sequence.release(0, p1).stationary(1).commit(); - - QCOMPARE(point1->pressed(), false); - QCOMPARE(point2->pressed(), true); - QCOMPARE(point3->pressed(), false); - - sequence.press(4, p4).stationary(1).commit(); - - //the new touch point should reuse point 1 - QCOMPARE(point1->pressed(), true); - QCOMPARE(point2->pressed(), true); - QCOMPARE(point3->pressed(), false); - - QCOMPARE(point1->x(), qreal(80)); QCOMPARE(point1->y(), qreal(100)); - - delete canvas; -} - -void tst_QQuickMultiPointTouchArea::nonOverlapping() -{ - QQuickView *canvas = createAndShowView("nonOverlapping.qml"); - QVERIFY(canvas->rootObject() != 0); - - QQuickTouchPoint *point11 = canvas->rootObject()->findChild("point11"); - QQuickTouchPoint *point12 = canvas->rootObject()->findChild("point12"); - QQuickTouchPoint *point21 = canvas->rootObject()->findChild("point21"); - QQuickTouchPoint *point22 = canvas->rootObject()->findChild("point22"); - QQuickTouchPoint *point23 = canvas->rootObject()->findChild("point23"); - - QCOMPARE(point11->pressed(), false); - QCOMPARE(point12->pressed(), false); - QCOMPARE(point21->pressed(), false); - QCOMPARE(point22->pressed(), false); - QCOMPARE(point23->pressed(), false); - - QPoint p1(20,100); - QPoint p2(40,100); - QPoint p3(60,180); - QPoint p4(80,180); - QPoint p5(100,180); - - QTest::QTouchEventSequence sequence = QTest::touchEvent(canvas, device); - - sequence.press(0, p1).commit(); - - QCOMPARE(point11->pressed(), false); - QCOMPARE(point12->pressed(), false); - QCOMPARE(point21->pressed(), false); - QCOMPARE(point22->pressed(), false); - QCOMPARE(point23->pressed(), false); - - sequence.stationary(0).press(1, p2).commit(); - - QCOMPARE(point11->pressed(), true); - QCOMPARE(point12->pressed(), true); - QCOMPARE(point21->pressed(), false); - QCOMPARE(point22->pressed(), false); - QCOMPARE(point23->pressed(), false); - - QCOMPARE(point11->x(), qreal(20)); QCOMPARE(point11->y(), qreal(100)); - QCOMPARE(point12->x(), qreal(40)); QCOMPARE(point12->y(), qreal(100)); - - p1 += QPoint(0,10); - p2 += QPoint(5,0); - sequence.move(0, p1).move(1, p2).commit(); - - QCOMPARE(point11->pressed(), true); - QCOMPARE(point12->pressed(), true); - QCOMPARE(point21->pressed(), false); - QCOMPARE(point22->pressed(), false); - QCOMPARE(point23->pressed(), false); - - QCOMPARE(point11->x(), qreal(20)); QCOMPARE(point11->y(), qreal(110)); - QCOMPARE(point12->x(), qreal(45)); QCOMPARE(point12->y(), qreal(100)); - - sequence.stationary(0).stationary(1).press(2, p3).commit(); - - QCOMPARE(point11->pressed(), true); - QCOMPARE(point12->pressed(), true); - QCOMPARE(point21->pressed(), false); - QCOMPARE(point22->pressed(), false); - QCOMPARE(point23->pressed(), false); - - sequence.stationary(0).stationary(1).stationary(2).press(3, p4).press(4, p5).commit(); - - QCOMPARE(point11->pressed(), true); - QCOMPARE(point12->pressed(), true); - QCOMPARE(point21->pressed(), true); - QCOMPARE(point22->pressed(), true); - QCOMPARE(point23->pressed(), true); - - QCOMPARE(point11->x(), qreal(20)); QCOMPARE(point11->y(), qreal(110)); - QCOMPARE(point12->x(), qreal(45)); QCOMPARE(point12->y(), qreal(100)); - QCOMPARE(point21->x(), qreal(60)); QCOMPARE(point21->y(), qreal(20)); - QCOMPARE(point22->x(), qreal(80)); QCOMPARE(point22->y(), qreal(20)); - QCOMPARE(point23->x(), qreal(100)); QCOMPARE(point23->y(), qreal(20)); - - p1 += QPoint(4,10); - p2 += QPoint(17,17); - p3 += QPoint(3,0); - p4 += QPoint(1,-1); - p5 += QPoint(-7,10); - sequence.move(0, p1).move(1, p2).move(2, p3).move(3, p4).move(4, p5).commit(); - - QCOMPARE(point11->pressed(), true); - QCOMPARE(point12->pressed(), true); - QCOMPARE(point21->pressed(), true); - QCOMPARE(point22->pressed(), true); - QCOMPARE(point23->pressed(), true); - - QCOMPARE(point11->x(), qreal(24)); QCOMPARE(point11->y(), qreal(120)); - QCOMPARE(point12->x(), qreal(62)); QCOMPARE(point12->y(), qreal(117)); - QCOMPARE(point21->x(), qreal(63)); QCOMPARE(point21->y(), qreal(20)); - QCOMPARE(point22->x(), qreal(81)); QCOMPARE(point22->y(), qreal(19)); - QCOMPARE(point23->x(), qreal(93)); QCOMPARE(point23->y(), qreal(30)); - - sequence.release(0, p1).release(1, p2).release(2, p3).release(3, p4).release(4, p5).commit(); - - QCOMPARE(point11->pressed(), false); - QCOMPARE(point12->pressed(), false); - QCOMPARE(point21->pressed(), false); - QCOMPARE(point22->pressed(), false); - QCOMPARE(point23->pressed(), false); - - delete canvas; -} - -void tst_QQuickMultiPointTouchArea::nested() -{ - QQuickView *canvas = createAndShowView("nested.qml"); - QVERIFY(canvas->rootObject() != 0); - - QQuickTouchPoint *point11 = canvas->rootObject()->findChild("point11"); - QQuickTouchPoint *point12 = canvas->rootObject()->findChild("point12"); - QQuickTouchPoint *point21 = canvas->rootObject()->findChild("point21"); - QQuickTouchPoint *point22 = canvas->rootObject()->findChild("point22"); - QQuickTouchPoint *point23 = canvas->rootObject()->findChild("point23"); - - QCOMPARE(point11->pressed(), false); - QCOMPARE(point12->pressed(), false); - QCOMPARE(point21->pressed(), false); - QCOMPARE(point22->pressed(), false); - QCOMPARE(point23->pressed(), false); - - QPoint p1(20,100); - QPoint p2(40,100); - QPoint p3(60,180); - - QTest::QTouchEventSequence sequence = QTest::touchEvent(canvas, device); - - sequence.press(0, p1).commit(); - - QCOMPARE(point11->pressed(), false); - QCOMPARE(point12->pressed(), false); - QCOMPARE(point21->pressed(), false); - QCOMPARE(point22->pressed(), false); - QCOMPARE(point23->pressed(), false); - - sequence.stationary(0).press(1, p2).commit(); - - QCOMPARE(point11->pressed(), true); - QCOMPARE(point12->pressed(), true); - QCOMPARE(point21->pressed(), false); - QCOMPARE(point22->pressed(), false); - QCOMPARE(point23->pressed(), false); - - QCOMPARE(point11->x(), qreal(20)); QCOMPARE(point11->y(), qreal(100)); - QCOMPARE(point12->x(), qreal(40)); QCOMPARE(point12->y(), qreal(100)); - - p1 += QPoint(0,10); - p2 += QPoint(5,0); - sequence.move(0, p1).move(1, p2).commit(); - - QCOMPARE(point11->pressed(), true); - QCOMPARE(point12->pressed(), true); - QCOMPARE(point21->pressed(), false); - QCOMPARE(point22->pressed(), false); - QCOMPARE(point23->pressed(), false); - - QCOMPARE(point11->x(), qreal(20)); QCOMPARE(point11->y(), qreal(110)); - QCOMPARE(point12->x(), qreal(45)); QCOMPARE(point12->y(), qreal(100)); - - sequence.stationary(0).stationary(1).press(2, p3).commit(); - - QCOMPARE(point11->pressed(), true); - QCOMPARE(point12->pressed(), true); - QCOMPARE(point21->pressed(), true); - QCOMPARE(point22->pressed(), true); - QCOMPARE(point23->pressed(), true); - - //point11 should be same as point21, point12 same as point22 - QCOMPARE(point11->x(), qreal(20)); QCOMPARE(point11->y(), qreal(110)); - QCOMPARE(point12->x(), qreal(45)); QCOMPARE(point12->y(), qreal(100)); - QCOMPARE(point21->x(), qreal(20)); QCOMPARE(point21->y(), qreal(110)); - QCOMPARE(point22->x(), qreal(45)); QCOMPARE(point22->y(), qreal(100)); - QCOMPARE(point23->x(), qreal(60)); QCOMPARE(point23->y(), qreal(180)); - - sequence.stationary(0).stationary(1).stationary(2).press(3, QPoint(80,180)).press(4, QPoint(100,180)).commit(); - - QCOMPARE(point11->pressed(), true); - QCOMPARE(point12->pressed(), true); - QCOMPARE(point21->pressed(), true); - QCOMPARE(point22->pressed(), true); - QCOMPARE(point23->pressed(), true); - - //new touch points should be ignored (have no impact on our existing touch points) - QCOMPARE(point11->x(), qreal(20)); QCOMPARE(point11->y(), qreal(110)); - QCOMPARE(point12->x(), qreal(45)); QCOMPARE(point12->y(), qreal(100)); - QCOMPARE(point21->x(), qreal(20)); QCOMPARE(point21->y(), qreal(110)); - QCOMPARE(point22->x(), qreal(45)); QCOMPARE(point22->y(), qreal(100)); - QCOMPARE(point23->x(), qreal(60)); QCOMPARE(point23->y(), qreal(180)); - - sequence.stationary(0).stationary(1).stationary(2).release(3, QPoint(80,180)).release(4, QPoint(100,180)).commit(); - - p1 += QPoint(4,10); - p2 += QPoint(17,17); - p3 += QPoint(3,0); - sequence.move(0, p1).move(1, p2).move(2, p3).commit(); - - QCOMPARE(point11->pressed(), true); - QCOMPARE(point12->pressed(), true); - QCOMPARE(point21->pressed(), true); - QCOMPARE(point22->pressed(), true); - QCOMPARE(point23->pressed(), true); - - QCOMPARE(point21->x(), qreal(24)); QCOMPARE(point21->y(), qreal(120)); - QCOMPARE(point22->x(), qreal(62)); QCOMPARE(point22->y(), qreal(117)); - QCOMPARE(point21->x(), qreal(24)); QCOMPARE(point21->y(), qreal(120)); - QCOMPARE(point22->x(), qreal(62)); QCOMPARE(point22->y(), qreal(117)); - QCOMPARE(point23->x(), qreal(63)); QCOMPARE(point23->y(), qreal(180)); - - p1 += QPoint(4,10); - p2 += QPoint(17,17); - p3 += QPoint(3,0); - sequence.move(0, p1).move(1, p2).move(2, p3).commit(); - - QCOMPARE(point11->pressed(), false); - QCOMPARE(point12->pressed(), false); - QCOMPARE(point21->pressed(), true); - QCOMPARE(point22->pressed(), true); - QCOMPARE(point23->pressed(), true); - - //first two remain the same (touches now grabbed by inner touch area) - QCOMPARE(point11->x(), qreal(24)); QCOMPARE(point11->y(), qreal(120)); - QCOMPARE(point12->x(), qreal(62)); QCOMPARE(point12->y(), qreal(117)); - QCOMPARE(point21->x(), qreal(28)); QCOMPARE(point21->y(), qreal(130)); - QCOMPARE(point22->x(), qreal(79)); QCOMPARE(point22->y(), qreal(134)); - QCOMPARE(point23->x(), qreal(66)); QCOMPARE(point23->y(), qreal(180)); - - sequence.release(0, p1).release(1, p2).release(2, p3).commit(); - - sequence.press(0, p1).commit(); - - QCOMPARE(point11->pressed(), false); - QCOMPARE(point12->pressed(), false); - QCOMPARE(point21->pressed(), false); - QCOMPARE(point22->pressed(), false); - QCOMPARE(point23->pressed(), false); - - sequence.release(0, p1).commit(); - - //test with grabbing turned off - canvas->rootObject()->setProperty("grabInnerArea", false); - - sequence.press(0, p1).press(1, p2).press(2, p3).commit(); - - QCOMPARE(point11->pressed(), true); - QCOMPARE(point12->pressed(), true); - QCOMPARE(point21->pressed(), true); - QCOMPARE(point22->pressed(), true); - QCOMPARE(point23->pressed(), true); - - p1 -= QPoint(4,10); - p2 -= QPoint(17,17); - p3 -= QPoint(3,0); - sequence.move(0, p1).move(1, p2).move(2, p3).commit(); - - QCOMPARE(point11->pressed(), true); - QCOMPARE(point12->pressed(), true); - QCOMPARE(point21->pressed(), true); - QCOMPARE(point22->pressed(), true); - QCOMPARE(point23->pressed(), true); - - QCOMPARE(point21->x(), qreal(24)); QCOMPARE(point21->y(), qreal(120)); - QCOMPARE(point22->x(), qreal(62)); QCOMPARE(point22->y(), qreal(117)); - QCOMPARE(point21->x(), qreal(24)); QCOMPARE(point21->y(), qreal(120)); - QCOMPARE(point22->x(), qreal(62)); QCOMPARE(point22->y(), qreal(117)); - QCOMPARE(point23->x(), qreal(63)); QCOMPARE(point23->y(), qreal(180)); - - p1 -= QPoint(4,10); - p2 -= QPoint(17,17); - p3 -= QPoint(3,0); - sequence.move(0, p1).move(1, p2).move(2, p3).commit(); - - QCOMPARE(point11->pressed(), true); - QCOMPARE(point12->pressed(), true); - QCOMPARE(point21->pressed(), true); - QCOMPARE(point22->pressed(), true); - QCOMPARE(point23->pressed(), true); - - //all change (touches not grabbed by inner touch area) - QCOMPARE(point11->x(), qreal(20)); QCOMPARE(point11->y(), qreal(110)); - QCOMPARE(point12->x(), qreal(45)); QCOMPARE(point12->y(), qreal(100)); - QCOMPARE(point21->x(), qreal(20)); QCOMPARE(point21->y(), qreal(110)); - QCOMPARE(point22->x(), qreal(45)); QCOMPARE(point22->y(), qreal(100)); - QCOMPARE(point23->x(), qreal(60)); QCOMPARE(point23->y(), qreal(180)); - - sequence.release(0, p1).release(1, p2).release(2, p3).commit(); - - delete canvas; -} - -void tst_QQuickMultiPointTouchArea::inFlickable() -{ - QQuickView *canvas = createAndShowView("inFlickable.qml"); - QVERIFY(canvas->rootObject() != 0); - - QQuickFlickable *flickable = qobject_cast(canvas->rootObject()); - QVERIFY(flickable != 0); - - QQuickTouchPoint *point11 = canvas->rootObject()->findChild("point1"); - QQuickTouchPoint *point12 = canvas->rootObject()->findChild("point2"); - - QCOMPARE(point11->pressed(), false); - QCOMPARE(point12->pressed(), false); - - QPoint p1(20,100); - QPoint p2(40,100); - - //moving one point vertically - QTest::touchEvent(canvas, device).press(0, p1); - QTest::mousePress(canvas, Qt::LeftButton, 0, p1); - - p1 += QPoint(0,15); - QTest::touchEvent(canvas, device).move(0, p1); - QTest::mouseMove(canvas, p1); - - p1 += QPoint(0,15); - QTest::touchEvent(canvas, device).move(0, p1); - QTest::mouseMove(canvas, p1); - - p1 += QPoint(0,15); - QTest::touchEvent(canvas, device).move(0, p1); - QTest::mouseMove(canvas, p1); - - p1 += QPoint(0,15); - QTest::touchEvent(canvas, device).move(0, p1); - QTest::mouseMove(canvas, p1); - - QVERIFY(flickable->contentY() < 0); - QCOMPARE(point11->pressed(), false); - QCOMPARE(point12->pressed(), false); - - QTest::touchEvent(canvas, device).release(0, p1); - QTest::mouseRelease(canvas,Qt::LeftButton, 0, p1); - QTest::qWait(50); - - QTRY_VERIFY(!flickable->isMoving()); - - //moving two points vertically - p1 = QPoint(20,100); - QTest::touchEvent(canvas, device).press(0, p1).press(1, p2); - QTest::mousePress(canvas, Qt::LeftButton, 0, p1); - - QCOMPARE(point11->pressed(), true); - QCOMPARE(point12->pressed(), true); - QCOMPARE(flickable->property("cancelCount").toInt(), 0); - QCOMPARE(flickable->property("touchCount").toInt(), 2); - - p1 += QPoint(0,15); p2 += QPoint(0,15); - QTest::touchEvent(canvas, device).move(0, p1).move(1, p2); - QTest::mouseMove(canvas, p1); - - p1 += QPoint(0,15); p2 += QPoint(0,15); - QTest::touchEvent(canvas, device).move(0, p1).move(1, p2); - QTest::mouseMove(canvas, p1); - - p1 += QPoint(0,15); p2 += QPoint(0,15); - QTest::touchEvent(canvas, device).move(0, p1).move(1, p2); - QTest::mouseMove(canvas, p1); - - p1 += QPoint(0,15); p2 += QPoint(0,15); - QTest::touchEvent(canvas, device).move(0, p1).move(1, p2); - QTest::mouseMove(canvas, p1); - - QVERIFY(flickable->contentY() < 0); - QCOMPARE(point11->pressed(), false); - QCOMPARE(point12->pressed(), false); - QCOMPARE(flickable->property("cancelCount").toInt(), 2); - QCOMPARE(flickable->property("touchCount").toInt(), 0); - - QTest::touchEvent(canvas, device).release(0, p1).release(1, p2); - QTest::mouseRelease(canvas,Qt::LeftButton, 0, p1); - QTest::qWait(50); - - QTRY_VERIFY(!flickable->isMoving()); - - //moving two points horizontally, then one point vertically - p1 = QPoint(20,100); - p2 = QPoint(40,100); - QTest::touchEvent(canvas, device).press(0, p1).press(1, p2); - QTest::mousePress(canvas, Qt::LeftButton, 0, p1); - - QCOMPARE(point11->pressed(), true); - QCOMPARE(point12->pressed(), true); - - p1 += QPoint(15,0); p2 += QPoint(15,0); - QTest::touchEvent(canvas, device).move(0, p1).move(1, p2); - QTest::mouseMove(canvas, p1); - - p1 += QPoint(15,0); p2 += QPoint(15,0); - QTest::touchEvent(canvas, device).move(0, p1).move(1, p2); - QTest::mouseMove(canvas, p1); - - p1 += QPoint(15,0); p2 += QPoint(15,0); - QTest::touchEvent(canvas, device).move(0, p1).move(1, p2); - QTest::mouseMove(canvas, p1); - - p1 += QPoint(15,0); p2 += QPoint(15,0); - QTest::touchEvent(canvas, device).move(0, p1).move(1, p2); - QTest::mouseMove(canvas, p1); - - p1 += QPoint(0,15); p2 += QPoint(0,15); - QTest::touchEvent(canvas, device).move(0, p1).move(1, p2); - QTest::mouseMove(canvas, p1); - - p1 += QPoint(0,15); p2 += QPoint(0,15); - QTest::touchEvent(canvas, device).move(0, p1).move(1, p2); - QTest::mouseMove(canvas, p1); - - p1 += QPoint(0,15); p2 += QPoint(0,15); - QTest::touchEvent(canvas, device).move(0, p1).move(1, p2); - QTest::mouseMove(canvas, p1); - - p1 += QPoint(0,15); p2 += QPoint(0,15); - QTest::touchEvent(canvas, device).move(0, p1).move(1, p2); - QTest::mouseMove(canvas, p1); - - QVERIFY(flickable->contentY() == 0); - QCOMPARE(point11->pressed(), true); - QCOMPARE(point12->pressed(), true); - - QTest::touchEvent(canvas, device).release(0, p1).release(1, p2); - QTest::mouseRelease(canvas,Qt::LeftButton, 0, p1); - QTest::qWait(50); - - delete canvas; -} - -// QTBUG-23327 -void tst_QQuickMultiPointTouchArea::invisible() -{ - QQuickView *canvas = createAndShowView("signalTest.qml"); - QVERIFY(canvas->rootObject() != 0); - - QQuickMultiPointTouchArea *area = qobject_cast(canvas->rootObject()); - QVERIFY(area != 0); - - area->setVisible(false); - - QPoint p1(20,100); - QPoint p2(40,100); - - QTest::QTouchEventSequence sequence = QTest::touchEvent(canvas, device); - - sequence.press(0, p1).press(1, p2).commit(); - - QCOMPARE(area->property("touchPointPressCount").toInt(), 0); - QCOMPARE(area->property("touchPointUpdateCount").toInt(), 0); - QCOMPARE(area->property("touchPointReleaseCount").toInt(), 0); - QCOMPARE(area->property("touchCount").toInt(), 0); - - delete canvas; -} - - -QQuickView *tst_QQuickMultiPointTouchArea::createAndShowView(const QString &file) -{ - QQuickView *canvas = new QQuickView(0); - canvas->setSource(QUrl::fromLocalFile(QCoreApplication::applicationDirPath() + QLatin1String("/data/") + file)); - canvas->show(); - canvas->requestActivateWindow(); - QTest::qWaitForWindowShown(canvas); - - return canvas; -} - -QTEST_MAIN(tst_QQuickMultiPointTouchArea) - -#include "tst_qquickmultipointtoucharea.moc" diff --git a/tests/auto/qtquick2/qquickpathview/data/ComponentView.qml b/tests/auto/qtquick2/qquickpathview/data/ComponentView.qml deleted file mode 100644 index b61033d375..0000000000 --- a/tests/auto/qtquick2/qquickpathview/data/ComponentView.qml +++ /dev/null @@ -1,17 +0,0 @@ -import QtQuick 2.0 - -PathView { - id: view - - property string title - - width: 100; height: 100; - - model: 1 - delegate: Text { objectName: "listItem"; text: view.title } - - path: Path { - startX: 25; startY: 25; - PathLine { x: 75; y: 75 } - } -} diff --git a/tests/auto/qtquick2/qquickpathview/data/asyncloader.qml b/tests/auto/qtquick2/qquickpathview/data/asyncloader.qml deleted file mode 100644 index 94f560f3e7..0000000000 --- a/tests/auto/qtquick2/qquickpathview/data/asyncloader.qml +++ /dev/null @@ -1,71 +0,0 @@ -import QtQuick 2.0 - -Rectangle { - id: root - property real delegateWidth: 60 - property real delegateHeight: 20 - property real delegateScale: 1.0 - width: 240 - height: 320 - color: "#ffffff" - - Loader { - asynchronous: true - sourceComponent: viewComponent - anchors.fill: parent - } - - Component { - id: adelegate - Rectangle { - objectName: "wrapper" - property bool onPath: PathView.onPath - height: root.delegateHeight - width: root.delegateWidth - scale: root.delegateScale - color: PathView.isCurrentItem ? "lightsteelblue" : "white" - border.color: "black" - Text { - text: index - } - } - } - Component { - id: viewComponent - PathView { - id: view - objectName: "view" - width: 240 - height: 320 - model: 5 - delegate: adelegate - highlight: Rectangle { - width: 60 - height: 20 - color: "yellow" - } - path: Path { - startY: 120 - startX: 160 - PathQuad { - y: 120 - x: 80 - controlY: 330 - controlX: 100 - } - PathLine { - y: 160 - x: 20 - } - PathCubic { - y: 120 - x: 160 - control1Y: 0 - control1X: 100 - control2Y: 0 - control2X: 200 - } - } - } - } -} diff --git a/tests/auto/qtquick2/qquickpathview/data/closedPath.qml b/tests/auto/qtquick2/qquickpathview/data/closedPath.qml deleted file mode 100644 index 3ca34056c8..0000000000 --- a/tests/auto/qtquick2/qquickpathview/data/closedPath.qml +++ /dev/null @@ -1,24 +0,0 @@ -import QtQuick 2.0 - -Path { - startY: 120 - startX: 160 - PathQuad { - y: 120 - x: 80 - controlY: 330 - controlX: 100 - } - PathLine { - y: 160 - x: 20 - } - PathCubic { - y: 120 - x: 160 - control1Y: 0 - control1X: 100 - control2Y: 000 - control2X: 200 - } -} diff --git a/tests/auto/qtquick2/qquickpathview/data/creationContext.qml b/tests/auto/qtquick2/qquickpathview/data/creationContext.qml deleted file mode 100644 index 79a682788b..0000000000 --- a/tests/auto/qtquick2/qquickpathview/data/creationContext.qml +++ /dev/null @@ -1,5 +0,0 @@ -import QtQuick 2.0 - -ComponentView { - title: "Hello!" -} diff --git a/tests/auto/qtquick2/qquickpathview/data/datamodel.qml b/tests/auto/qtquick2/qquickpathview/data/datamodel.qml deleted file mode 100644 index 44f2aecc0a..0000000000 --- a/tests/auto/qtquick2/qquickpathview/data/datamodel.qml +++ /dev/null @@ -1,38 +0,0 @@ -import QtQuick 2.0 - -PathView { - id: pathview - property int viewCount: count - objectName: "pathview" - width: 240; height: 320 - pathItemCount: testObject.pathItemCount - - function checkProperties() { - testObject.error = false; - if (testObject.useModel && pathview.model != testData) { - console.log("model property incorrect"); - testObject.error = true; - } - } - - model: testObject.useModel ? testData : 0 - - delegate: Component { - id: myDelegate - Rectangle { - id: wrapper - objectName: "wrapper" - property bool onPath: PathView.onPath - width: 20; height: 20; color: name - Text { - objectName: "myText" - text: name - } - } - } - - path: Path { - startX: 120; startY: 20; - PathLine { x: 120; y: 300 } - } -} diff --git a/tests/auto/qtquick2/qquickpathview/data/displaypath.qml b/tests/auto/qtquick2/qquickpathview/data/displaypath.qml deleted file mode 100644 index af0f381fc4..0000000000 --- a/tests/auto/qtquick2/qquickpathview/data/displaypath.qml +++ /dev/null @@ -1,59 +0,0 @@ -import QtQuick 2.0 - -Rectangle { - width: 240 - height: 320 - color: "#ffffff" - resources: [ - Component { - id: delegate - Rectangle { - id: wrapper - objectName: "wrapper" - height: 20 - width: 60 - color: "white" - border.color: "black" - Text { - text: index - } - Text { - x: 20 - id: displayText - objectName: "displayText" - text: display - } - } - } - ] - PathView { - id: view - objectName: "view" - width: 240 - height: 320 - model: testModel - delegate: delegate - path: Path { - startY: 120 - startX: 160 - PathQuad { - y: 120 - x: 80 - controlY: 330 - controlX: 100 - } - PathLine { - y: 160 - x: 20 - } - PathCubic { - y: 120 - x: 160 - control1Y: 0 - control1X: 100 - control2Y: 000 - control2X: 200 - } - } - } -} diff --git a/tests/auto/qtquick2/qquickpathview/data/dragpath.qml b/tests/auto/qtquick2/qquickpathview/data/dragpath.qml deleted file mode 100644 index f9c6615b04..0000000000 --- a/tests/auto/qtquick2/qquickpathview/data/dragpath.qml +++ /dev/null @@ -1,19 +0,0 @@ -import QtQuick 2.0 - -PathView { - width: 400 - height: 200 - model: 100 - pathItemCount: 20 - path: Path { - startX: 0; startY: 100 - PathLine { x: 400; y: 100 } - } - delegate: Rectangle { objectName: "wrapper"; height: 100; width: 2; color: PathView.isCurrentItem?"red" : "black" } - dragMargin: 100 - preferredHighlightBegin: 0.5 - preferredHighlightEnd: 0.5 - Text { - text: "current index: " + parent.currentIndex - } -} diff --git a/tests/auto/qtquick2/qquickpathview/data/emptymodel.qml b/tests/auto/qtquick2/qquickpathview/data/emptymodel.qml deleted file mode 100644 index eb4d3006f4..0000000000 --- a/tests/auto/qtquick2/qquickpathview/data/emptymodel.qml +++ /dev/null @@ -1,5 +0,0 @@ -import QtQuick 2.0 - -PathView { - model: emptyModel -} diff --git a/tests/auto/qtquick2/qquickpathview/data/missingPercent.qml b/tests/auto/qtquick2/qquickpathview/data/missingPercent.qml deleted file mode 100644 index 97af8e8982..0000000000 --- a/tests/auto/qtquick2/qquickpathview/data/missingPercent.qml +++ /dev/null @@ -1,9 +0,0 @@ -import QtQuick 2.0 - -Path { - startY: 0 - startX: 0 - PathLine { x: 0; y: 50 } - PathPercent { value: .5 } - PathLine { x: 50; y: 50 } -} diff --git a/tests/auto/qtquick2/qquickpathview/data/openPath.qml b/tests/auto/qtquick2/qquickpathview/data/openPath.qml deleted file mode 100644 index 1bd8375d9e..0000000000 --- a/tests/auto/qtquick2/qquickpathview/data/openPath.qml +++ /dev/null @@ -1,10 +0,0 @@ -import QtQuick 2.0 - -Path { - startY: 120 - startX: 160 - PathLine { - y: 160 - x: 20 - } -} diff --git a/tests/auto/qtquick2/qquickpathview/data/pathUpdate.qml b/tests/auto/qtquick2/qquickpathview/data/pathUpdate.qml deleted file mode 100644 index e729291025..0000000000 --- a/tests/auto/qtquick2/qquickpathview/data/pathUpdate.qml +++ /dev/null @@ -1,18 +0,0 @@ -import QtQuick 2.0 - -Rectangle { - width: 400 - height: 400 - - PathView { - id: view - objectName: "pathView" - anchors.fill: parent - model: 10 - delegate: Rectangle { objectName: "wrapper"; color: "green"; width: 100; height: 100 } - path: Path { - startX: view.width/2; startY: 0 - PathLine { x: view.width/2; y: view.height } - } - } -} diff --git a/tests/auto/qtquick2/qquickpathview/data/pathUpdateOnStartChanged.qml b/tests/auto/qtquick2/qquickpathview/data/pathUpdateOnStartChanged.qml deleted file mode 100644 index 89084b2a37..0000000000 --- a/tests/auto/qtquick2/qquickpathview/data/pathUpdateOnStartChanged.qml +++ /dev/null @@ -1,38 +0,0 @@ -import QtQuick 2.0 - -Rectangle { - width: 800 - height: 480 - color: "black" - resources: [ - ListModel { - id: appModel - ListElement { color: "green" } - }, - Component { - id: appDelegate - Rectangle { - id: wrapper - objectName: "wrapper" - color: "green" - width: 100 - height: 100 - } - } - ] - PathView { - id: pathView - objectName: "pathView" - model: appModel - anchors.fill: parent - - transformOrigin: "Top" - delegate: appDelegate - path: Path { - objectName: "path" - startX: pathView.width / 2 // startX: 400 <- this works as expected - startY: 300 - PathLine { x: 400; y: 120 } - } - } -} diff --git a/tests/auto/qtquick2/qquickpathview/data/pathline.qml b/tests/auto/qtquick2/qquickpathview/data/pathline.qml deleted file mode 100644 index 4c1c785bce..0000000000 --- a/tests/auto/qtquick2/qquickpathview/data/pathline.qml +++ /dev/null @@ -1,48 +0,0 @@ -import QtQuick 2.0 - -Rectangle { - id: app - width: 360 - height: 360 - - PathView { - id: pathView - objectName: "view" - x: (app.width-pathView.width)/2 - y: 100 - width: 240 - height: 100 - - model: testModel - - Rectangle { - anchors.fill: parent - color: "white" - border.color: "black" - } - preferredHighlightBegin: 0.5 - preferredHighlightEnd: 0.5 - - delegate: Rectangle { - objectName: "wrapper" - width: 100 - height: 100 - color: PathView.isCurrentItem ? "red" : "yellow" - Text { - text: index - anchors.centerIn: parent - } - z: (PathView.isCurrentItem?1:0) - } - path: Path { - id: path - startX: -100+pathView.width/2 - startY: pathView.height/2 - PathLine { - id: line - x: 100+pathView.width/2 - y: pathView.height/2 - } - } - } -} diff --git a/tests/auto/qtquick2/qquickpathview/data/pathtest.qml b/tests/auto/qtquick2/qquickpathview/data/pathtest.qml deleted file mode 100644 index 736d58d2a9..0000000000 --- a/tests/auto/qtquick2/qquickpathview/data/pathtest.qml +++ /dev/null @@ -1,14 +0,0 @@ -import QtQuick 2.0 - -Path { - startX: 120; startY: 100 - - PathAttribute { name: "scale"; value: 1.0 } - PathQuad { x: 120; y: 25; controlX: 260; controlY: 75 } - PathPercent { value: 0.3 } - PathLine { x: 120; y: 100 } - PathCubic { - x: 180; y: 0; control1X: -10; control1Y: 90 - control2X: 210; control2Y: 90 - } -} diff --git a/tests/auto/qtquick2/qquickpathview/data/pathview0.qml b/tests/auto/qtquick2/qquickpathview/data/pathview0.qml deleted file mode 100644 index 8b9378163f..0000000000 --- a/tests/auto/qtquick2/qquickpathview/data/pathview0.qml +++ /dev/null @@ -1,85 +0,0 @@ -import QtQuick 2.0 - -Rectangle { - id: root - property int count: view.count - property int currentA: -1 - property int currentB: -1 - property real delegateWidth: 60 - property real delegateHeight: 20 - property real delegateScale: 1.0 - width: 240 - height: 320 - color: "#ffffff" - resources: [ - Component { - id: delegate - Rectangle { - id: wrapper - objectName: "wrapper" - property bool onPath: PathView.onPath - height: root.delegateHeight - width: root.delegateWidth - scale: root.delegateScale - color: PathView.isCurrentItem ? "lightsteelblue" : "white" - border.color: "black" - Text { - text: index - } - Text { - x: 20 - id: textName - objectName: "textName" - text: name - } - Text { - x: 40 - id: textNumber - objectName: "textNumber" - text: number - } - PathView.onCurrentItemChanged: { - if (PathView.isCurrentItem) { - root.currentA = index; - root.currentB = wrapper.PathView.view.currentIndex; - } - } - } - } - ] - PathView { - id: view - objectName: "view" - width: 240 - height: 320 - model: testModel - delegate: delegate - highlight: Rectangle { - width: 60 - height: 20 - color: "yellow" - } - path: Path { - startY: 120 - startX: 160 - PathQuad { - y: 120 - x: 80 - controlY: 330 - controlX: 100 - } - PathLine { - y: 160 - x: 20 - } - PathCubic { - y: 120 - x: 160 - control1Y: 0 - control1X: 100 - control2Y: 000 - control2X: 200 - } - } - } -} diff --git a/tests/auto/qtquick2/qquickpathview/data/pathview1.qml b/tests/auto/qtquick2/qquickpathview/data/pathview1.qml deleted file mode 100644 index 53d375e596..0000000000 --- a/tests/auto/qtquick2/qquickpathview/data/pathview1.qml +++ /dev/null @@ -1,4 +0,0 @@ -import QtQuick 2.0 - -PathView { -} diff --git a/tests/auto/qtquick2/qquickpathview/data/pathview2.qml b/tests/auto/qtquick2/qquickpathview/data/pathview2.qml deleted file mode 100644 index 1d279c42a0..0000000000 --- a/tests/auto/qtquick2/qquickpathview/data/pathview2.qml +++ /dev/null @@ -1,57 +0,0 @@ -import QtQuick 2.0 - -PathView { - id: photoPathView - y: 100; width: 800; height: 330; pathItemCount: 10; z: 1 - - path: Path { - startX: -50; startY: 40; - - PathAttribute { name: "scale"; value: 0.5 } - PathAttribute { name: "angle"; value: -45 } - - PathCubic { - x: 400; y: 220 - control1X: 140; control1Y: 40 - control2X: 210; control2Y: 220 - } - - PathAttribute { name: "scale"; value: 1.2 } - PathAttribute { name: "angle"; value: 0 } - - PathCubic { - x: 850; y: 40 - control2X: 660; control2Y: 40 - control1X: 590; control1Y: 220 - } - - PathAttribute { name: "scale"; value: 0.5 } - PathAttribute { name: "angle"; value: 45 } - } - - model: ListModel { - id: rssModel - ListElement { lColor: "red" } - ListElement { lColor: "green" } - ListElement { lColor: "yellow" } - ListElement { lColor: "blue" } - ListElement { lColor: "purple" } - ListElement { lColor: "gray" } - ListElement { lColor: "brown" } - ListElement { lColor: "thistle" } - } - - delegate: Component { - id: photoDelegate - Rectangle { - id: wrapper - width: 85; height: 85; color: lColor - scale: wrapper.PathView.scale - - transform: Rotation { - id: itemRotation; origin.x: wrapper.width/2; origin.y: wrapper.height/2 - axis.y: 1; axis.z: 0; angle: wrapper.PathView.angle - } - } - } -} diff --git a/tests/auto/qtquick2/qquickpathview/data/pathview3.qml b/tests/auto/qtquick2/qquickpathview/data/pathview3.qml deleted file mode 100644 index ded5a3911c..0000000000 --- a/tests/auto/qtquick2/qquickpathview/data/pathview3.qml +++ /dev/null @@ -1,59 +0,0 @@ -import QtQuick 2.0 - -PathView { - id: photoPathView - y: 100; width: 800; height: 330; pathItemCount: 4; offset: 1 - dragMargin: 24 - preferredHighlightBegin: 0.50 - preferredHighlightEnd: 0.50 - - path: Path { - startX: -50; startY: 40; - - PathAttribute { name: "scale"; value: 0.5 } - PathAttribute { name: "angle"; value: -45 } - - PathCubic { - x: 400; y: 220 - control1X: 140; control1Y: 40 - control2X: 210; control2Y: 220 - } - - PathAttribute { name: "scale"; value: 1.2 } - PathAttribute { name: "angle"; value: 0 } - - PathCubic { - x: 850; y: 40 - control2X: 660; control2Y: 40 - control1X: 590; control1Y: 220 - } - - PathAttribute { name: "scale"; value: 0.5 } - PathAttribute { name: "angle"; value: 45 } - } - - model: ListModel { - id: rssModel - ListElement { lColor: "red" } - ListElement { lColor: "green" } - ListElement { lColor: "yellow" } - ListElement { lColor: "blue" } - ListElement { lColor: "purple" } - ListElement { lColor: "gray" } - ListElement { lColor: "brown" } - ListElement { lColor: "thistle" } - } - - delegate: Component { - id: photoDelegate - Rectangle { - id: wrapper - width: 85; height: 85; color: lColor - - transform: Rotation { - id: itemRotation; origin.x: wrapper.width/2; origin.y: wrapper.height/2 - axis.y: 1; axis.z: 0 - } - } - } -} diff --git a/tests/auto/qtquick2/qquickpathview/data/pathview_package.qml b/tests/auto/qtquick2/qquickpathview/data/pathview_package.qml deleted file mode 100644 index 2af57e6bb1..0000000000 --- a/tests/auto/qtquick2/qquickpathview/data/pathview_package.qml +++ /dev/null @@ -1,88 +0,0 @@ -import QtQuick 2.0 - -Item { - width: 800; height: 600 - Component { - id: photoDelegate - Package { - Item { id: pathItem; objectName: "pathItem"; Package.name: 'path'; width: 85; height: 85; scale: pathItem.PathView.scale } - Item { id: linearItem; Package.name: 'linear'; width: 85; height: 85 } - Rectangle { - id: wrapper - width: 85; height: 85; color: lColor - - transform: Rotation { - id: itemRotation; origin.x: wrapper.width/2; origin.y: wrapper.height/2 - axis.y: 1; axis.z: 0 - } - state: 'path' - states: [ - State { - name: 'path' - ParentChange { target: wrapper; parent: pathItem; x: 0; y: 0 } - PropertyChanges { target: wrapper; opacity: pathItem.PathView.onPath ? 1.0 : 0 } - } - ] - } - } - } - ListModel { - id: rssModel - ListElement { lColor: "red" } - ListElement { lColor: "green" } - ListElement { lColor: "yellow" } - ListElement { lColor: "blue" } - ListElement { lColor: "purple" } - ListElement { lColor: "gray" } - ListElement { lColor: "brown" } - ListElement { lColor: "thistle" } - } - VisualDataModel { id: visualModel; model: rssModel; delegate: photoDelegate } - - PathView { - id: photoPathView - objectName: "photoPathView" - width: 800; height: 330; pathItemCount: 4; offset: 1 - dragMargin: 24 - preferredHighlightBegin: 0.50 - preferredHighlightEnd: 0.50 - - path: Path { - startX: -50; startY: 40; - - PathAttribute { name: "scale"; value: 0.5 } - PathAttribute { name: "angle"; value: -45 } - - PathCubic { - x: 400; y: 220 - control1X: 140; control1Y: 40 - control2X: 210; control2Y: 220 - } - - PathAttribute { name: "scale"; value: 1.2 } - PathAttribute { name: "angle"; value: 0 } - - PathCubic { - x: 850; y: 40 - control2X: 660; control2Y: 40 - control1X: 590; control1Y: 220 - } - - PathAttribute { name: "scale"; value: 0.5 } - PathAttribute { name: "angle"; value: 45 } - } - - model: visualModel.parts.path - } - - PathView { - y: 400; width: 800; height: 330; pathItemCount: 8 - - path: Path { - startX: 0; startY: 40; - PathLine { x: 800; y: 40 } - } - - model: visualModel.parts.linear - } -} diff --git a/tests/auto/qtquick2/qquickpathview/data/propertychanges.qml b/tests/auto/qtquick2/qquickpathview/data/propertychanges.qml deleted file mode 100644 index 09b309f86f..0000000000 --- a/tests/auto/qtquick2/qquickpathview/data/propertychanges.qml +++ /dev/null @@ -1,116 +0,0 @@ -import QtQuick 2.0 - -Rectangle { - width: 350; height: 220; color: "white" - Component { - id: myDelegate - Item { - id: wrapper - width: 180; height: 40; - opacity: PathView.opacity - Column { - x: 5; y: 5 - Text { text: 'Name: ' + name } - Text { text: 'Number: ' + number } - } - } - } - - PathView { - preferredHighlightBegin: 0.1 - preferredHighlightEnd: 0.1 - dragMargin: 5.0 - id: pathView - objectName: "pathView" - anchors.fill: parent - model: listModel - delegate: myDelegate - focus: true - path: Path { - id: myPath - objectName: "path" - startX: 220; startY: 200 - PathAttribute { name: "opacity"; value: 1.0; objectName: "pathAttribute"; } - PathQuad { x: 220; y: 25; controlX: 260; controlY: 75 } - PathAttribute { name: "opacity"; value: 0.3 } - PathQuad { x: 220; y: 200; controlX: -20; controlY: 75 } - } - Timer { - interval: 2000; running: true; repeat: true - onTriggered: { - if (pathView.path == alternatePath) - pathView.path = myPath; - else - pathView.path = alternatePath; - } - } - } - - data:[ - ListModel { - id: listModel - ListElement { - name: "Bill Smith" - number: "555 3264" - } - ListElement { - name: "John Brown" - number: "555 8426" - } - ListElement { - name: "Sam Wise" - number: "555 0473" - } - ListElement { - name: "Bill Smith" - number: "555 3264" - } - ListElement { - name: "John Brown" - number: "555 8426" - } - ListElement { - name: "Sam Wise" - number: "555 0473" - } - ListElement { - name: "Bill Smith" - number: "555 3264" - } - ListElement { - name: "John Brown" - number: "555 8426" - } - ListElement { - name: "Sam Wise" - number: "555 0473" - } - }, - ListModel { - objectName: "alternateModel" - ListElement { - name: "Jack" - number: "555 8426" - } - ListElement { - name: "Mary" - number: "555 3264" - } - }, - Path { - id: alternatePath - objectName: "alternatePath" - startX: 100; startY: 40 - PathAttribute { name: "opacity"; value: 0.0 } - PathLine { x: 100; y: 160 } - PathAttribute { name: "opacity"; value: 0.2 } - PathLine { x: 300; y: 160 } - PathAttribute { name: "opacity"; value: 0.0 } - PathLine { x: 300; y: 40 } - PathAttribute { name: "opacity"; value: 0.2 } - PathLine { x: 100; y: 40 } - } - ] -} - - diff --git a/tests/auto/qtquick2/qquickpathview/data/treemodel.qml b/tests/auto/qtquick2/qquickpathview/data/treemodel.qml deleted file mode 100644 index fcf6922d00..0000000000 --- a/tests/auto/qtquick2/qquickpathview/data/treemodel.qml +++ /dev/null @@ -1,19 +0,0 @@ -import QtQuick 2.0 - -PathView { - width: 320 - height: 240 - function setRoot(index) { - vdm.rootIndex = vdm.modelIndex(index); - } - model: VisualDataModel { - id: vdm - model: myModel - delegate: Text { objectName: "wrapper"; text: display } - } - - path: Path { - startX: 0; startY: 120 - PathLine { x: 320; y: 120 } - } -} diff --git a/tests/auto/qtquick2/qquickpathview/data/undefinedpath.qml b/tests/auto/qtquick2/qquickpathview/data/undefinedpath.qml deleted file mode 100644 index 674e7cca8d..0000000000 --- a/tests/auto/qtquick2/qquickpathview/data/undefinedpath.qml +++ /dev/null @@ -1,17 +0,0 @@ -import QtQuick 2.0 - -PathView { - id: pathView - width: 240; height: 200 - path: Path { - startX: pathView.undef/2.0; startY: 0 - PathLine { x: pathView.undef/2.0; y: 0 } - } - - delegate: Text { text: value } - model: ListModel { - ListElement { value: "one" } - ListElement { value: "two" } - ListElement { value: "three" } - } -} diff --git a/tests/auto/qtquick2/qquickpathview/data/vdm.qml b/tests/auto/qtquick2/qquickpathview/data/vdm.qml deleted file mode 100644 index 839393d9bd..0000000000 --- a/tests/auto/qtquick2/qquickpathview/data/vdm.qml +++ /dev/null @@ -1,28 +0,0 @@ -import QtQuick 2.0 - -PathView { - id: pathView - width: 240; height: 320 - - pathItemCount: 4 - preferredHighlightBegin : 0.5 - preferredHighlightEnd : 0.5 - - path: Path { - startX: 120; startY: 20; - PathLine { x: 120; y: 300 } - } - - ListModel { - id: mo - ListElement { value: "one" } - ListElement { value: "two" } - ListElement { value: "three" } - } - - model: VisualDataModel { - delegate: Text { text: model.value } - model : mo - } -} - diff --git a/tests/auto/qtquick2/qquickpathview/qquickpathview.pro b/tests/auto/qtquick2/qquickpathview/qquickpathview.pro deleted file mode 100644 index 027abb60e6..0000000000 --- a/tests/auto/qtquick2/qquickpathview/qquickpathview.pro +++ /dev/null @@ -1,15 +0,0 @@ -CONFIG += testcase -TARGET = tst_qquickpathview -macx:CONFIG -= app_bundle - -SOURCES += tst_qquickpathview.cpp - -include (../../shared/util.pri) -include (../shared/util.pri) - -testDataFiles.files = data -testDataFiles.path = . -DEPLOYMENT += testDataFiles - -CONFIG += parallel_test -QT += core-private gui-private v8-private declarative-private quick-private widgets testlib diff --git a/tests/auto/qtquick2/qquickpathview/tst_qquickpathview.cpp b/tests/auto/qtquick2/qquickpathview/tst_qquickpathview.cpp deleted file mode 100644 index 8ed2ee75a6..0000000000 --- a/tests/auto/qtquick2/qquickpathview/tst_qquickpathview.cpp +++ /dev/null @@ -1,1458 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "../../shared/util.h" -#include "../shared/viewtestutil.h" -#include "../shared/visualtestutil.h" - -using namespace QQuickViewTestUtil; -using namespace QQuickVisualTestUtil; - - -static void initStandardTreeModel(QStandardItemModel *model) -{ - QStandardItem *item; - item = new QStandardItem(QLatin1String("Row 1 Item")); - model->insertRow(0, item); - - item = new QStandardItem(QLatin1String("Row 2 Item")); - item->setCheckable(true); - model->insertRow(1, item); - - QStandardItem *childItem = new QStandardItem(QLatin1String("Row 2 Child Item")); - item->setChild(0, childItem); - - item = new QStandardItem(QLatin1String("Row 3 Item")); - item->setIcon(QIcon()); - model->insertRow(2, item); -} - - -class tst_QQuickPathView : public QDeclarativeDataTest -{ - Q_OBJECT -public: - tst_QQuickPathView(); - -private slots: - void initValues(); - void items(); - void dataModel(); - void pathview2(); - void pathview3(); - void insertModel_data(); - void insertModel(); - void removeModel_data(); - void removeModel(); - void moveModel_data(); - void moveModel(); - void path(); - void pathMoved(); - void setCurrentIndex(); - void resetModel(); - void propertyChanges(); - void pathChanges(); - void componentChanges(); - void modelChanges(); - void pathUpdateOnStartChanged(); - void package(); - void emptyModel(); - void closed(); - void pathUpdate(); - void visualDataModel(); - void undefinedPath(); - void mouseDrag(); - void treeModel(); - void changePreferredHighlight(); - void missingPercent(); - void creationContext(); - void currentOffsetOnInsertion(); - void asynchronous(); -}; - -class TestObject : public QObject -{ - Q_OBJECT - - Q_PROPERTY(bool error READ error WRITE setError) - Q_PROPERTY(bool useModel READ useModel NOTIFY useModelChanged) - Q_PROPERTY(int pathItemCount READ pathItemCount NOTIFY pathItemCountChanged) - -public: - TestObject() : QObject(), mError(true), mUseModel(true), mPathItemCount(-1) {} - - bool error() const { return mError; } - void setError(bool err) { mError = err; } - - bool useModel() const { return mUseModel; } - void setUseModel(bool use) { mUseModel = use; emit useModelChanged(); } - - int pathItemCount() const { return mPathItemCount; } - void setPathItemCount(int count) { mPathItemCount = count; emit pathItemCountChanged(); } - -signals: - void useModelChanged(); - void pathItemCountChanged(); - -private: - bool mError; - bool mUseModel; - int mPathItemCount; -}; - -tst_QQuickPathView::tst_QQuickPathView() -{ -} - -void tst_QQuickPathView::initValues() -{ - QDeclarativeEngine engine; - QDeclarativeComponent c(&engine, testFileUrl("pathview1.qml")); - QQuickPathView *obj = qobject_cast(c.create()); - - QVERIFY(obj != 0); - QVERIFY(obj->path() == 0); - QVERIFY(obj->delegate() == 0); - QCOMPARE(obj->model(), QVariant()); - QCOMPARE(obj->currentIndex(), 0); - QCOMPARE(obj->offset(), 0.); - QCOMPARE(obj->preferredHighlightBegin(), 0.); - QCOMPARE(obj->dragMargin(), 0.); - QCOMPARE(obj->count(), 0); - QCOMPARE(obj->pathItemCount(), -1); - - delete obj; -} - -void tst_QQuickPathView::items() -{ - QQuickView *canvas = createView(); - - QaimModel model; - model.addItem("Fred", "12345"); - model.addItem("John", "2345"); - model.addItem("Bob", "54321"); - model.addItem("Bill", "4321"); - - QDeclarativeContext *ctxt = canvas->rootContext(); - ctxt->setContextProperty("testModel", &model); - - canvas->setSource(testFileUrl("pathview0.qml")); - qApp->processEvents(); - - QQuickPathView *pathview = findItem(canvas->rootObject(), "view"); - QVERIFY(pathview != 0); - - QCOMPARE(pathview->count(), model.count()); - QCOMPARE(canvas->rootObject()->property("count").toInt(), model.count()); - QCOMPARE(pathview->childItems().count(), model.count()+1); // assumes all are visible, including highlight - - for (int i = 0; i < model.count(); ++i) { - QQuickText *name = findItem(pathview, "textName", i); - QVERIFY(name != 0); - QCOMPARE(name->text(), model.name(i)); - QQuickText *number = findItem(pathview, "textNumber", i); - QVERIFY(number != 0); - QCOMPARE(number->text(), model.number(i)); - } - - QDeclarativePath *path = qobject_cast(pathview->path()); - QVERIFY(path); - - QVERIFY(pathview->highlightItem()); - QPointF start = path->pointAt(0.0); - QPointF offset; - offset.setX(pathview->highlightItem()->width()/2); - offset.setY(pathview->highlightItem()->height()/2); - QCOMPARE(pathview->highlightItem()->pos() + offset, start); - - delete canvas; -} - -void tst_QQuickPathView::pathview2() -{ - QDeclarativeEngine engine; - QDeclarativeComponent c(&engine, testFileUrl("pathview2.qml")); - QQuickPathView *obj = qobject_cast(c.create()); - - QVERIFY(obj != 0); - QVERIFY(obj->path() != 0); - QVERIFY(obj->delegate() != 0); - QVERIFY(obj->model() != QVariant()); - QCOMPARE(obj->currentIndex(), 0); - QCOMPARE(obj->offset(), 0.); - QCOMPARE(obj->preferredHighlightBegin(), 0.); - QCOMPARE(obj->dragMargin(), 0.); - QCOMPARE(obj->count(), 8); - QCOMPARE(obj->pathItemCount(), 10); - - delete obj; -} - -void tst_QQuickPathView::pathview3() -{ - QDeclarativeEngine engine; - QDeclarativeComponent c(&engine, testFileUrl("pathview3.qml")); - QQuickPathView *obj = qobject_cast(c.create()); - - QVERIFY(obj != 0); - QVERIFY(obj->path() != 0); - QVERIFY(obj->delegate() != 0); - QVERIFY(obj->model() != QVariant()); - QCOMPARE(obj->currentIndex(), 0); - QCOMPARE(obj->offset(), 1.0); - QCOMPARE(obj->preferredHighlightBegin(), 0.5); - QCOMPARE(obj->dragMargin(), 24.); - QCOMPARE(obj->count(), 8); - QCOMPARE(obj->pathItemCount(), 4); - - delete obj; -} - -void tst_QQuickPathView::insertModel_data() -{ - QTest::addColumn("mode"); - QTest::addColumn("idx"); - QTest::addColumn("count"); - QTest::addColumn("offset"); - - // We have 8 items, with currentIndex == 4 - QTest::newRow("insert after current") - << int(QQuickPathView::StrictlyEnforceRange) << 6 << 1 << 5.; - QTest::newRow("insert before current") - << int(QQuickPathView::StrictlyEnforceRange) << 2 << 1 << 4.; - QTest::newRow("insert multiple after current") - << int(QQuickPathView::StrictlyEnforceRange) << 5 << 2 << 6.; - QTest::newRow("insert multiple before current") - << int(QQuickPathView::StrictlyEnforceRange) << 1 << 2 << 4.; - QTest::newRow("insert at end") - << int(QQuickPathView::StrictlyEnforceRange) << 8 << 1 << 5.; - QTest::newRow("insert at beginning") - << int(QQuickPathView::StrictlyEnforceRange) << 0 << 1 << 4.; - QTest::newRow("insert at current") - << int(QQuickPathView::StrictlyEnforceRange) << 4 << 1 << 4.; - - QTest::newRow("no range - insert after current") - << int(QQuickPathView::NoHighlightRange) << 6 << 1 << 5.; - QTest::newRow("no range - insert before current") - << int(QQuickPathView::NoHighlightRange) << 2 << 1 << 4.; - QTest::newRow("no range - insert multiple after current") - << int(QQuickPathView::NoHighlightRange) << 5 << 2 << 6.; - QTest::newRow("no range - insert multiple before current") - << int(QQuickPathView::NoHighlightRange) << 1 << 2 << 4.; - QTest::newRow("no range - insert at end") - << int(QQuickPathView::NoHighlightRange) << 8 << 1 << 5.; - QTest::newRow("no range - insert at beginning") - << int(QQuickPathView::NoHighlightRange) << 0 << 1 << 4.; - QTest::newRow("no range - insert at current") - << int(QQuickPathView::NoHighlightRange) << 4 << 1 << 4.; -} - -void tst_QQuickPathView::insertModel() -{ - QFETCH(int, mode); - QFETCH(int, idx); - QFETCH(int, count); - QFETCH(qreal, offset); - - QQuickView *canvas = createView(); - canvas->show(); - - QaimModel model; - model.addItem("Ben", "12345"); - model.addItem("Bohn", "2345"); - model.addItem("Bob", "54321"); - model.addItem("Bill", "4321"); - model.addItem("Jinny", "679"); - model.addItem("Milly", "73378"); - model.addItem("Jimmy", "3535"); - model.addItem("Barb", "9039"); - - QDeclarativeContext *ctxt = canvas->rootContext(); - ctxt->setContextProperty("testModel", &model); - - canvas->setSource(testFileUrl("pathview0.qml")); - qApp->processEvents(); - - QQuickPathView *pathview = findItem(canvas->rootObject(), "view"); - QVERIFY(pathview != 0); - - pathview->setHighlightRangeMode((QQuickPathView::HighlightRangeMode)mode); - - pathview->setCurrentIndex(4); - if (mode == QQuickPathView::StrictlyEnforceRange) - QTRY_COMPARE(pathview->offset(), 4.0); - else - pathview->setOffset(4); - - QList > items; - for (int i = 0; i < count; ++i) - items.append(qMakePair(QString("New"), QString::number(i))); - - model.insertItems(idx, items); - QTRY_COMPARE(pathview->offset(), offset); - - delete canvas; -} - -void tst_QQuickPathView::removeModel_data() -{ - QTest::addColumn("mode"); - QTest::addColumn("idx"); - QTest::addColumn("count"); - QTest::addColumn("offset"); - - // We have 8 items, with currentIndex == 4 - QTest::newRow("remove after current") - << int(QQuickPathView::StrictlyEnforceRange) << 6 << 1 << 3.; - QTest::newRow("remove before current") - << int(QQuickPathView::StrictlyEnforceRange) << 2 << 1 << 4.; - QTest::newRow("remove multiple after current") - << int(QQuickPathView::StrictlyEnforceRange) << 5 << 2 << 2.; - QTest::newRow("remove multiple before current") - << int(QQuickPathView::StrictlyEnforceRange) << 1 << 2 << 4.; - QTest::newRow("remove last") - << int(QQuickPathView::StrictlyEnforceRange) << 7 << 1 << 3.; - QTest::newRow("remove first") - << int(QQuickPathView::StrictlyEnforceRange) << 0 << 1 << 4.; - QTest::newRow("remove current") - << int(QQuickPathView::StrictlyEnforceRange) << 4 << 1 << 3.; - - QTest::newRow("no range - remove after current") - << int(QQuickPathView::NoHighlightRange) << 6 << 1 << 3.; - QTest::newRow("no range - remove before current") - << int(QQuickPathView::NoHighlightRange) << 2 << 1 << 4.; - QTest::newRow("no range - remove multiple after current") - << int(QQuickPathView::NoHighlightRange) << 5 << 2 << 2.; - QTest::newRow("no range - remove multiple before current") - << int(QQuickPathView::NoHighlightRange) << 1 << 2 << 4.; - QTest::newRow("no range - remove last") - << int(QQuickPathView::NoHighlightRange) << 7 << 1 << 3.; - QTest::newRow("no range - remove first") - << int(QQuickPathView::NoHighlightRange) << 0 << 1 << 4.; - QTest::newRow("no range - remove current offset") - << int(QQuickPathView::NoHighlightRange) << 4 << 1 << 4.; -} - -void tst_QQuickPathView::removeModel() -{ - QFETCH(int, mode); - QFETCH(int, idx); - QFETCH(int, count); - QFETCH(qreal, offset); - - QQuickView *canvas = createView(); - canvas->show(); - - QaimModel model; - model.addItem("Ben", "12345"); - model.addItem("Bohn", "2345"); - model.addItem("Bob", "54321"); - model.addItem("Bill", "4321"); - model.addItem("Jinny", "679"); - model.addItem("Milly", "73378"); - model.addItem("Jimmy", "3535"); - model.addItem("Barb", "9039"); - - QDeclarativeContext *ctxt = canvas->rootContext(); - ctxt->setContextProperty("testModel", &model); - - canvas->setSource(testFileUrl("pathview0.qml")); - qApp->processEvents(); - - QQuickPathView *pathview = findItem(canvas->rootObject(), "view"); - QVERIFY(pathview != 0); - - pathview->setHighlightRangeMode((QQuickPathView::HighlightRangeMode)mode); - - pathview->setCurrentIndex(4); - if (mode == QQuickPathView::StrictlyEnforceRange) - QTRY_COMPARE(pathview->offset(), 4.0); - else - pathview->setOffset(4); - - model.removeItems(idx, count); - QTRY_COMPARE(pathview->offset(), offset); - - delete canvas; -} - - -void tst_QQuickPathView::moveModel_data() -{ - QTest::addColumn("mode"); - QTest::addColumn("from"); - QTest::addColumn("to"); - QTest::addColumn("count"); - QTest::addColumn("offset"); - - // We have 8 items, with currentIndex == 4 - QTest::newRow("move after current") - << int(QQuickPathView::StrictlyEnforceRange) << 5 << 6 << 1 << 4.; - QTest::newRow("move before current") - << int(QQuickPathView::StrictlyEnforceRange) << 2 << 3 << 1 << 4.; - QTest::newRow("move before current to after") - << int(QQuickPathView::StrictlyEnforceRange) << 2 << 6 << 1 << 5.; - QTest::newRow("move multiple after current") - << int(QQuickPathView::StrictlyEnforceRange) << 5 << 6 << 2 << 4.; - QTest::newRow("move multiple before current") - << int(QQuickPathView::StrictlyEnforceRange) << 0 << 1 << 2 << 4.; - QTest::newRow("move before current to end") - << int(QQuickPathView::StrictlyEnforceRange) << 2 << 7 << 1 << 5.; - QTest::newRow("move last to beginning") - << int(QQuickPathView::StrictlyEnforceRange) << 7 << 0 << 1 << 3.; - QTest::newRow("move current") - << int(QQuickPathView::StrictlyEnforceRange) << 4 << 6 << 1 << 2.; - - QTest::newRow("no range - move after current") - << int(QQuickPathView::NoHighlightRange) << 5 << 6 << 1 << 4.; - QTest::newRow("no range - move before current") - << int(QQuickPathView::NoHighlightRange) << 2 << 3 << 1 << 4.; - QTest::newRow("no range - move before current to after") - << int(QQuickPathView::NoHighlightRange) << 2 << 6 << 1 << 5.; - QTest::newRow("no range - move multiple after current") - << int(QQuickPathView::NoHighlightRange) << 5 << 6 << 2 << 4.; - QTest::newRow("no range - move multiple before current") - << int(QQuickPathView::NoHighlightRange) << 0 << 1 << 2 << 4.; - QTest::newRow("no range - move before current to end") - << int(QQuickPathView::NoHighlightRange) << 2 << 7 << 1 << 5.; - QTest::newRow("no range - move last to beginning") - << int(QQuickPathView::NoHighlightRange) << 7 << 0 << 1 << 3.; - QTest::newRow("no range - move current") - << int(QQuickPathView::NoHighlightRange) << 4 << 6 << 1 << 4.; - QTest::newRow("no range - move multiple incl. current") - << int(QQuickPathView::NoHighlightRange) << 0 << 1 << 5 << 4.; -} - -void tst_QQuickPathView::moveModel() -{ - QFETCH(int, mode); - QFETCH(int, from); - QFETCH(int, to); - QFETCH(int, count); - QFETCH(qreal, offset); - - QQuickView *canvas = createView(); - canvas->show(); - - QaimModel model; - model.addItem("Ben", "12345"); - model.addItem("Bohn", "2345"); - model.addItem("Bob", "54321"); - model.addItem("Bill", "4321"); - model.addItem("Jinny", "679"); - model.addItem("Milly", "73378"); - model.addItem("Jimmy", "3535"); - model.addItem("Barb", "9039"); - - QDeclarativeContext *ctxt = canvas->rootContext(); - ctxt->setContextProperty("testModel", &model); - - canvas->setSource(testFileUrl("pathview0.qml")); - qApp->processEvents(); - - QQuickPathView *pathview = findItem(canvas->rootObject(), "view"); - QVERIFY(pathview != 0); - - pathview->setHighlightRangeMode((QQuickPathView::HighlightRangeMode)mode); - - pathview->setCurrentIndex(4); - if (mode == QQuickPathView::StrictlyEnforceRange) - QTRY_COMPARE(pathview->offset(), 4.0); - else - pathview->setOffset(4); - - model.moveItems(from, to, count); - QTRY_COMPARE(pathview->offset(), offset); - - delete canvas; -} - -void tst_QQuickPathView::path() -{ - QDeclarativeEngine engine; - QDeclarativeComponent c(&engine, testFileUrl("pathtest.qml")); - QDeclarativePath *obj = qobject_cast(c.create()); - - QVERIFY(obj != 0); - QCOMPARE(obj->startX(), 120.); - QCOMPARE(obj->startY(), 100.); - QVERIFY(obj->path() != QPainterPath()); - - QDeclarativeListReference list(obj, "pathElements"); - QCOMPARE(list.count(), 5); - - QDeclarativePathAttribute* attr = qobject_cast(list.at(0)); - QVERIFY(attr != 0); - QCOMPARE(attr->name(), QString("scale")); - QCOMPARE(attr->value(), 1.0); - - QDeclarativePathQuad* quad = qobject_cast(list.at(1)); - QVERIFY(quad != 0); - QCOMPARE(quad->x(), 120.); - QCOMPARE(quad->y(), 25.); - QCOMPARE(quad->controlX(), 260.); - QCOMPARE(quad->controlY(), 75.); - - QDeclarativePathPercent* perc = qobject_cast(list.at(2)); - QVERIFY(perc != 0); - QCOMPARE(perc->value(), 0.3); - - QDeclarativePathLine* line = qobject_cast(list.at(3)); - QVERIFY(line != 0); - QCOMPARE(line->x(), 120.); - QCOMPARE(line->y(), 100.); - - QDeclarativePathCubic* cubic = qobject_cast(list.at(4)); - QVERIFY(cubic != 0); - QCOMPARE(cubic->x(), 180.); - QCOMPARE(cubic->y(), 0.); - QCOMPARE(cubic->control1X(), -10.); - QCOMPARE(cubic->control1Y(), 90.); - QCOMPARE(cubic->control2X(), 210.); - QCOMPARE(cubic->control2Y(), 90.); - - delete obj; -} - -void tst_QQuickPathView::dataModel() -{ - QQuickView *canvas = createView(); - canvas->show(); - - QDeclarativeContext *ctxt = canvas->rootContext(); - TestObject *testObject = new TestObject; - ctxt->setContextProperty("testObject", testObject); - - QaimModel model; - model.addItem("red", "1"); - model.addItem("green", "2"); - model.addItem("blue", "3"); - model.addItem("purple", "4"); - model.addItem("gray", "5"); - model.addItem("brown", "6"); - model.addItem("yellow", "7"); - model.addItem("thistle", "8"); - model.addItem("cyan", "9"); - model.addItem("peachpuff", "10"); - model.addItem("powderblue", "11"); - model.addItem("gold", "12"); - model.addItem("sandybrown", "13"); - - ctxt->setContextProperty("testData", &model); - - canvas->setSource(testFileUrl("datamodel.qml")); - qApp->processEvents(); - - QQuickPathView *pathview = qobject_cast(canvas->rootObject()); - QVERIFY(pathview != 0); - - QMetaObject::invokeMethod(canvas->rootObject(), "checkProperties"); - QVERIFY(testObject->error() == false); - - QQuickItem *item = findItem(pathview, "wrapper", 0); - QVERIFY(item); - QCOMPARE(item->x(), 110.0); - QCOMPARE(item->y(), 10.0); - - model.insertItem(4, "orange", "10"); - QTest::qWait(100); - - QCOMPARE(canvas->rootObject()->property("viewCount").toInt(), model.count()); - QTRY_COMPARE(findItems(pathview, "wrapper").count(), 14); - - QVERIFY(pathview->currentIndex() == 0); - QCOMPARE(pathview->currentItem(), findItem(pathview, "wrapper", 0)); - - QQuickText *text = findItem(pathview, "myText", 4); - QVERIFY(text); - QCOMPARE(text->text(), model.name(4)); - - model.removeItem(2); - QCOMPARE(canvas->rootObject()->property("viewCount").toInt(), model.count()); - text = findItem(pathview, "myText", 2); - QVERIFY(text); - QCOMPARE(text->text(), model.name(2)); - QCOMPARE(pathview->currentItem(), findItem(pathview, "wrapper", 0)); - - testObject->setPathItemCount(5); - QMetaObject::invokeMethod(canvas->rootObject(), "checkProperties"); - QVERIFY(testObject->error() == false); - - QTRY_COMPARE(findItems(pathview, "wrapper").count(), 5); - - QQuickRectangle *testItem = findItem(pathview, "wrapper", 4); - QVERIFY(testItem != 0); - testItem = findItem(pathview, "wrapper", 5); - QVERIFY(testItem == 0); - - pathview->setCurrentIndex(1); - QCOMPARE(pathview->currentItem(), findItem(pathview, "wrapper", 1)); - QTest::qWait(100); - - model.insertItem(2, "pink", "2"); - QTest::qWait(100); - - QTRY_COMPARE(findItems(pathview, "wrapper").count(), 5); - QVERIFY(pathview->currentIndex() == 1); - QCOMPARE(pathview->currentItem(), findItem(pathview, "wrapper", 1)); - - text = findItem(pathview, "myText", 2); - QVERIFY(text); - QCOMPARE(text->text(), model.name(2)); - - model.removeItem(3); - QTRY_COMPARE(findItems(pathview, "wrapper").count(), 5); - text = findItem(pathview, "myText", 3); - QVERIFY(text); - QCOMPARE(text->text(), model.name(3)); - QCOMPARE(pathview->currentItem(), findItem(pathview, "wrapper", 1)); - - model.moveItem(3, 5); - QTRY_COMPARE(findItems(pathview, "wrapper").count(), 5); - QList items = findItems(pathview, "wrapper"); - foreach (QQuickItem *item, items) { - QVERIFY(item->property("onPath").toBool()); - } - QCOMPARE(pathview->currentItem(), findItem(pathview, "wrapper", 1)); - - // QTBUG-14199 - pathview->setOffset(7); - pathview->setOffset(0); - QCOMPARE(findItems(pathview, "wrapper").count(), 5); - - pathview->setCurrentIndex(model.count()-1); - model.removeItem(model.count()-1); - QCOMPARE(pathview->currentIndex(), model.count()-1); - - delete canvas; - delete testObject; -} - -void tst_QQuickPathView::pathMoved() -{ - QQuickView *canvas = createView(); - canvas->show(); - - QaimModel model; - model.addItem("Ben", "12345"); - model.addItem("Bohn", "2345"); - model.addItem("Bob", "54321"); - model.addItem("Bill", "4321"); - - QDeclarativeContext *ctxt = canvas->rootContext(); - ctxt->setContextProperty("testModel", &model); - - canvas->setSource(testFileUrl("pathview0.qml")); - qApp->processEvents(); - - QQuickPathView *pathview = findItem(canvas->rootObject(), "view"); - QVERIFY(pathview != 0); - - QQuickRectangle *firstItem = findItem(pathview, "wrapper", 0); - QVERIFY(firstItem); - QDeclarativePath *path = qobject_cast(pathview->path()); - QVERIFY(path); - QPointF start = path->pointAt(0.0); - QPointF offset;//Center of item is at point, but pos is from corner - offset.setX(firstItem->width()/2); - offset.setY(firstItem->height()/2); - QTRY_COMPARE(firstItem->pos() + offset, start); - pathview->setOffset(1.0); - - for (int i=0; i(pathview, "wrapper", i); - QPointF itemPos(path->pointAt(0.25 + i*0.25)); - QCOMPARE(curItem->pos() + offset, QPointF(itemPos.x(), itemPos.y())); - } - - pathview->setOffset(0.0); - QCOMPARE(firstItem->pos() + offset, start); - - // Change delegate size - pathview->setOffset(0.1); - pathview->setOffset(0.0); - canvas->rootObject()->setProperty("delegateWidth", 30); - QCOMPARE(firstItem->width(), 30.0); - offset.setX(firstItem->width()/2); - QTRY_COMPARE(firstItem->pos() + offset, start); - - // Change delegate scale - pathview->setOffset(0.1); - pathview->setOffset(0.0); - canvas->rootObject()->setProperty("delegateScale", 1.2); - QTRY_COMPARE(firstItem->pos() + offset, start); - - delete canvas; -} - -void tst_QQuickPathView::setCurrentIndex() -{ - QQuickView *canvas = createView(); - canvas->show(); - - QaimModel model; - model.addItem("Ben", "12345"); - model.addItem("Bohn", "2345"); - model.addItem("Bob", "54321"); - model.addItem("Bill", "4321"); - - QDeclarativeContext *ctxt = canvas->rootContext(); - ctxt->setContextProperty("testModel", &model); - - canvas->setSource(testFileUrl("pathview0.qml")); - qApp->processEvents(); - - QQuickPathView *pathview = findItem(canvas->rootObject(), "view"); - QVERIFY(pathview != 0); - - QQuickRectangle *firstItem = findItem(pathview, "wrapper", 0); - QVERIFY(firstItem); - QDeclarativePath *path = qobject_cast(pathview->path()); - QVERIFY(path); - QPointF start = path->pointAt(0.0); - QPointF offset;//Center of item is at point, but pos is from corner - offset.setX(firstItem->width()/2); - offset.setY(firstItem->height()/2); - QCOMPARE(firstItem->pos() + offset, start); - QCOMPARE(canvas->rootObject()->property("currentA").toInt(), 0); - QCOMPARE(canvas->rootObject()->property("currentB").toInt(), 0); - - pathview->setCurrentIndex(2); - - firstItem = findItem(pathview, "wrapper", 2); - QTRY_COMPARE(firstItem->pos() + offset, start); - QCOMPARE(canvas->rootObject()->property("currentA").toInt(), 2); - QCOMPARE(canvas->rootObject()->property("currentB").toInt(), 2); - QCOMPARE(pathview->currentItem(), firstItem); - QCOMPARE(firstItem->property("onPath"), QVariant(true)); - - pathview->decrementCurrentIndex(); - QTRY_COMPARE(pathview->currentIndex(), 1); - firstItem = findItem(pathview, "wrapper", 1); - QVERIFY(firstItem); - QTRY_COMPARE(firstItem->pos() + offset, start); - QCOMPARE(pathview->currentItem(), firstItem); - QCOMPARE(firstItem->property("onPath"), QVariant(true)); - - pathview->decrementCurrentIndex(); - QTRY_COMPARE(pathview->currentIndex(), 0); - firstItem = findItem(pathview, "wrapper", 0); - QVERIFY(firstItem); - QTRY_COMPARE(firstItem->pos() + offset, start); - QCOMPARE(pathview->currentItem(), firstItem); - QCOMPARE(firstItem->property("onPath"), QVariant(true)); - - pathview->decrementCurrentIndex(); - QTRY_COMPARE(pathview->currentIndex(), 3); - firstItem = findItem(pathview, "wrapper", 3); - QVERIFY(firstItem); - QTRY_COMPARE(firstItem->pos() + offset, start); - QCOMPARE(pathview->currentItem(), firstItem); - QCOMPARE(firstItem->property("onPath"), QVariant(true)); - - pathview->incrementCurrentIndex(); - QTRY_COMPARE(pathview->currentIndex(), 0); - firstItem = findItem(pathview, "wrapper", 0); - QVERIFY(firstItem); - QTRY_COMPARE(firstItem->pos() + offset, start); - QCOMPARE(pathview->currentItem(), firstItem); - QCOMPARE(firstItem->property("onPath"), QVariant(true)); - - // move an item, set move duration to 0, and change currentIndex to moved item. QTBUG-22786 - model.moveItem(0, 3); - pathview->setHighlightMoveDuration(0); - pathview->setCurrentIndex(3); - QCOMPARE(pathview->currentIndex(), 3); - firstItem = findItem(pathview, "wrapper", 3); - QVERIFY(firstItem); - QCOMPARE(pathview->currentItem(), firstItem); - QTRY_COMPARE(firstItem->pos() + offset, start); - model.moveItem(3, 0); - pathview->setCurrentIndex(0); - pathview->setHighlightMoveDuration(300); - - // Check the current item is still created when outside the bounds of pathItemCount. - pathview->setPathItemCount(2); - pathview->setHighlightRangeMode(QQuickPathView::NoHighlightRange); - QVERIFY(findItem(pathview, "wrapper", 0)); - QVERIFY(findItem(pathview, "wrapper", 1)); - QVERIFY(!findItem(pathview, "wrapper", 2)); - QVERIFY(!findItem(pathview, "wrapper", 3)); - - pathview->setCurrentIndex(2); - firstItem = findItem(pathview, "wrapper", 2); - QCOMPARE(pathview->currentItem(), firstItem); - QCOMPARE(firstItem->property("onPath"), QVariant(false)); - - pathview->decrementCurrentIndex(); - QTRY_COMPARE(pathview->currentIndex(), 1); - firstItem = findItem(pathview, "wrapper", 1); - QVERIFY(firstItem); - QCOMPARE(pathview->currentItem(), firstItem); - QCOMPARE(firstItem->property("onPath"), QVariant(true)); - - pathview->decrementCurrentIndex(); - QTRY_COMPARE(pathview->currentIndex(), 0); - firstItem = findItem(pathview, "wrapper", 0); - QVERIFY(firstItem); - QCOMPARE(pathview->currentItem(), firstItem); - QCOMPARE(firstItem->property("onPath"), QVariant(true)); - - pathview->decrementCurrentIndex(); - QTRY_COMPARE(pathview->currentIndex(), 3); - firstItem = findItem(pathview, "wrapper", 3); - QVERIFY(firstItem); - QCOMPARE(pathview->currentItem(), firstItem); - QCOMPARE(firstItem->property("onPath"), QVariant(false)); - - pathview->incrementCurrentIndex(); - QTRY_COMPARE(pathview->currentIndex(), 0); - firstItem = findItem(pathview, "wrapper", 0); - QVERIFY(firstItem); - QCOMPARE(pathview->currentItem(), firstItem); - QCOMPARE(firstItem->property("onPath"), QVariant(true)); - - delete canvas; -} - -void tst_QQuickPathView::resetModel() -{ - QQuickView *canvas = createView(); - - QStringList strings; - strings << "one" << "two" << "three"; - QStringListModel model(strings); - - QDeclarativeContext *ctxt = canvas->rootContext(); - ctxt->setContextProperty("testModel", &model); - - canvas->setSource(testFileUrl("displaypath.qml")); - qApp->processEvents(); - - QQuickPathView *pathview = findItem(canvas->rootObject(), "view"); - QVERIFY(pathview != 0); - - QCOMPARE(pathview->count(), model.rowCount()); - - for (int i = 0; i < model.rowCount(); ++i) { - QQuickText *display = findItem(pathview, "displayText", i); - QVERIFY(display != 0); - QCOMPARE(display->text(), strings.at(i)); - } - - strings.clear(); - strings << "four" << "five" << "six" << "seven"; - model.setStringList(strings); - - QCOMPARE(pathview->count(), model.rowCount()); - - for (int i = 0; i < model.rowCount(); ++i) { - QQuickText *display = findItem(pathview, "displayText", i); - QVERIFY(display != 0); - QCOMPARE(display->text(), strings.at(i)); - } - - delete canvas; -} - -void tst_QQuickPathView::propertyChanges() -{ - QQuickView *canvas = createView(); - QVERIFY(canvas); - canvas->setSource(testFileUrl("propertychanges.qml")); - - QQuickPathView *pathView = canvas->rootObject()->findChild("pathView"); - QVERIFY(pathView); - - QSignalSpy snapPositionSpy(pathView, SIGNAL(preferredHighlightBeginChanged())); - QSignalSpy dragMarginSpy(pathView, SIGNAL(dragMarginChanged())); - - QCOMPARE(pathView->preferredHighlightBegin(), 0.1); - QCOMPARE(pathView->dragMargin(), 5.0); - - pathView->setPreferredHighlightBegin(0.4); - pathView->setPreferredHighlightEnd(0.4); - pathView->setDragMargin(20.0); - - QCOMPARE(pathView->preferredHighlightBegin(), 0.4); - QCOMPARE(pathView->preferredHighlightEnd(), 0.4); - QCOMPARE(pathView->dragMargin(), 20.0); - - QCOMPARE(snapPositionSpy.count(), 1); - QCOMPARE(dragMarginSpy.count(), 1); - - pathView->setPreferredHighlightBegin(0.4); - pathView->setPreferredHighlightEnd(0.4); - pathView->setDragMargin(20.0); - - QCOMPARE(snapPositionSpy.count(), 1); - QCOMPARE(dragMarginSpy.count(), 1); - delete canvas; -} - -void tst_QQuickPathView::pathChanges() -{ - QQuickView *canvas = createView(); - QVERIFY(canvas); - canvas->setSource(testFileUrl("propertychanges.qml")); - - QQuickPathView *pathView = canvas->rootObject()->findChild("pathView"); - QVERIFY(pathView); - - QDeclarativePath *path = canvas->rootObject()->findChild("path"); - QVERIFY(path); - - QSignalSpy startXSpy(path, SIGNAL(startXChanged())); - QSignalSpy startYSpy(path, SIGNAL(startYChanged())); - - QCOMPARE(path->startX(), 220.0); - QCOMPARE(path->startY(), 200.0); - - path->setStartX(240.0); - path->setStartY(220.0); - - QCOMPARE(path->startX(), 240.0); - QCOMPARE(path->startY(), 220.0); - - QCOMPARE(startXSpy.count(),1); - QCOMPARE(startYSpy.count(),1); - - path->setStartX(240); - path->setStartY(220); - - QCOMPARE(startXSpy.count(),1); - QCOMPARE(startYSpy.count(),1); - - QDeclarativePath *alternatePath = canvas->rootObject()->findChild("alternatePath"); - QVERIFY(alternatePath); - - QSignalSpy pathSpy(pathView, SIGNAL(pathChanged())); - - QCOMPARE(pathView->path(), path); - - pathView->setPath(alternatePath); - QCOMPARE(pathView->path(), alternatePath); - QCOMPARE(pathSpy.count(),1); - - pathView->setPath(alternatePath); - QCOMPARE(pathSpy.count(),1); - - QDeclarativePathAttribute *pathAttribute = canvas->rootObject()->findChild("pathAttribute"); - QVERIFY(pathAttribute); - - QSignalSpy nameSpy(pathAttribute, SIGNAL(nameChanged())); - QCOMPARE(pathAttribute->name(), QString("opacity")); - - pathAttribute->setName("scale"); - QCOMPARE(pathAttribute->name(), QString("scale")); - QCOMPARE(nameSpy.count(),1); - - pathAttribute->setName("scale"); - QCOMPARE(nameSpy.count(),1); - delete canvas; -} - -void tst_QQuickPathView::componentChanges() -{ - QQuickView *canvas = createView(); - QVERIFY(canvas); - canvas->setSource(testFileUrl("propertychanges.qml")); - - QQuickPathView *pathView = canvas->rootObject()->findChild("pathView"); - QVERIFY(pathView); - - QDeclarativeComponent delegateComponent(canvas->engine()); - delegateComponent.setData("import QtQuick 2.0; Text { text: 'Name: ' + name }", QUrl::fromLocalFile("")); - - QSignalSpy delegateSpy(pathView, SIGNAL(delegateChanged())); - - pathView->setDelegate(&delegateComponent); - QCOMPARE(pathView->delegate(), &delegateComponent); - QCOMPARE(delegateSpy.count(),1); - - pathView->setDelegate(&delegateComponent); - QCOMPARE(delegateSpy.count(),1); - delete canvas; -} - -void tst_QQuickPathView::modelChanges() -{ - QQuickView *canvas = createView(); - QVERIFY(canvas); - canvas->setSource(testFileUrl("propertychanges.qml")); - - QQuickPathView *pathView = canvas->rootObject()->findChild("pathView"); - QVERIFY(pathView); - - QDeclarativeListModel *alternateModel = canvas->rootObject()->findChild("alternateModel"); - QVERIFY(alternateModel); - QVariant modelVariant = QVariant::fromValue(alternateModel); - QSignalSpy modelSpy(pathView, SIGNAL(modelChanged())); - - pathView->setModel(modelVariant); - QCOMPARE(pathView->model(), modelVariant); - QCOMPARE(modelSpy.count(),1); - - pathView->setModel(modelVariant); - QCOMPARE(modelSpy.count(),1); - - pathView->setModel(QVariant()); - QCOMPARE(modelSpy.count(),2); - - delete canvas; -} - -void tst_QQuickPathView::pathUpdateOnStartChanged() -{ - QQuickView *canvas = createView(); - QVERIFY(canvas); - canvas->setSource(testFileUrl("pathUpdateOnStartChanged.qml")); - - QQuickPathView *pathView = canvas->rootObject()->findChild("pathView"); - QVERIFY(pathView); - - QDeclarativePath *path = canvas->rootObject()->findChild("path"); - QVERIFY(path); - QCOMPARE(path->startX(), 400.0); - QCOMPARE(path->startY(), 300.0); - - QQuickItem *item = findItem(pathView, "wrapper", 0); - QVERIFY(item); - QCOMPARE(item->x(), path->startX() - item->width() / 2.0); - QCOMPARE(item->y(), path->startY() - item->height() / 2.0); - - delete canvas; -} - -void tst_QQuickPathView::package() -{ - QQuickView *canvas = createView(); - QVERIFY(canvas); - canvas->setSource(testFileUrl("pathview_package.qml")); - canvas->show(); - QTest::qWaitForWindowShown(canvas); - - QQuickPathView *pathView = canvas->rootObject()->findChild("photoPathView"); - QVERIFY(pathView); - -#ifdef Q_OS_MAC - QSKIP("QTBUG-21590 view does not reliably receive polish without a running animation"); -#endif - - QQuickItem *item = findItem(pathView, "pathItem"); - QVERIFY(item); - QVERIFY(item->scale() != 1.0); - - delete canvas; -} - -//QTBUG-13017 -void tst_QQuickPathView::emptyModel() -{ - QQuickView *canvas = createView(); - - QStringListModel model; - - QDeclarativeContext *ctxt = canvas->rootContext(); - ctxt->setContextProperty("emptyModel", &model); - - canvas->setSource(testFileUrl("emptymodel.qml")); - qApp->processEvents(); - - QQuickPathView *pathview = qobject_cast(canvas->rootObject()); - QVERIFY(pathview != 0); - - QCOMPARE(pathview->offset(), qreal(0.0)); - - delete canvas; -} - -void tst_QQuickPathView::closed() -{ - QDeclarativeEngine engine; - - { - QDeclarativeComponent c(&engine, testFileUrl("openPath.qml")); - QDeclarativePath *obj = qobject_cast(c.create()); - QVERIFY(obj); - QCOMPARE(obj->isClosed(), false); - delete obj; - } - - { - QDeclarativeComponent c(&engine, testFileUrl("closedPath.qml")); - QDeclarativePath *obj = qobject_cast(c.create()); - QVERIFY(obj); - QCOMPARE(obj->isClosed(), true); - delete obj; - } -} - -// QTBUG-14239 -void tst_QQuickPathView::pathUpdate() -{ - QQuickView *canvas = createView(); - QVERIFY(canvas); - canvas->setSource(testFileUrl("pathUpdate.qml")); - - QQuickPathView *pathView = canvas->rootObject()->findChild("pathView"); - QVERIFY(pathView); - - QQuickItem *item = findItem(pathView, "wrapper", 0); - QVERIFY(item); - QCOMPARE(item->x(), 150.0); - - delete canvas; -} - -void tst_QQuickPathView::visualDataModel() -{ - QDeclarativeEngine engine; - QDeclarativeComponent c(&engine, testFileUrl("vdm.qml")); - - QQuickPathView *obj = qobject_cast(c.create()); - QVERIFY(obj != 0); - - QCOMPARE(obj->count(), 3); - - delete obj; -} - -void tst_QQuickPathView::undefinedPath() -{ - QDeclarativeEngine engine; - - // QPainterPath warnings are only received if QT_NO_DEBUG is not defined - if (QLibraryInfo::isDebugBuild()) { - QString warning1("QPainterPath::moveTo: Adding point where x or y is NaN or Inf, ignoring call"); - QTest::ignoreMessage(QtWarningMsg,qPrintable(warning1)); - - QString warning2("QPainterPath::lineTo: Adding point where x or y is NaN or Inf, ignoring call"); - QTest::ignoreMessage(QtWarningMsg,qPrintable(warning2)); - } - - QDeclarativeComponent c(&engine, testFileUrl("undefinedpath.qml")); - - QQuickPathView *obj = qobject_cast(c.create()); - QVERIFY(obj != 0); - - QCOMPARE(obj->count(), 3); - - delete obj; -} - -void tst_QQuickPathView::mouseDrag() -{ - QQuickView *canvas = createView(); - canvas->setSource(testFileUrl("dragpath.qml")); - canvas->show(); - canvas->requestActivateWindow(); - QTest::qWaitForWindowShown(canvas); - QTRY_COMPARE(canvas, qGuiApp->focusWindow()); - - QQuickPathView *pathview = qobject_cast(canvas->rootObject()); - QVERIFY(pathview != 0); - - int current = pathview->currentIndex(); - - QTest::mousePress(canvas, Qt::LeftButton, 0, QPoint(10,100)); - QTest::qWait(100); - - { - QMouseEvent mv(QEvent::MouseMove, QPoint(30,100), Qt::LeftButton, Qt::LeftButton,Qt::NoModifier); - QGuiApplication::sendEvent(canvas, &mv); - } - { - QMouseEvent mv(QEvent::MouseMove, QPoint(90,100), Qt::LeftButton, Qt::LeftButton,Qt::NoModifier); - QGuiApplication::sendEvent(canvas, &mv); - } - - QVERIFY(pathview->currentIndex() != current); - - QTest::mouseRelease(canvas, Qt::LeftButton, 0, QPoint(40,100)); - - delete canvas; -} - -void tst_QQuickPathView::treeModel() -{ - QQuickView *canvas = createView(); - canvas->show(); - - QStandardItemModel model; - initStandardTreeModel(&model); - canvas->engine()->rootContext()->setContextProperty("myModel", &model); - - canvas->setSource(testFileUrl("treemodel.qml")); - - QQuickPathView *pathview = qobject_cast(canvas->rootObject()); - QVERIFY(pathview != 0); - QCOMPARE(pathview->count(), 3); - - QQuickText *item = findItem(pathview, "wrapper", 0); - QVERIFY(item); - QCOMPARE(item->text(), QLatin1String("Row 1 Item")); - - QVERIFY(QMetaObject::invokeMethod(pathview, "setRoot", Q_ARG(QVariant, 1))); - QCOMPARE(pathview->count(), 1); - - QTRY_VERIFY(item = findItem(pathview, "wrapper", 0)); - QTRY_COMPARE(item->text(), QLatin1String("Row 2 Child Item")); - - delete canvas; -} - -void tst_QQuickPathView::changePreferredHighlight() -{ - QQuickView *canvas = createView(); - canvas->setGeometry(0,0,400,200); - canvas->setSource(testFileUrl("dragpath.qml")); - canvas->show(); - canvas->requestActivateWindow(); - QTest::qWaitForWindowShown(canvas); - QTRY_COMPARE(canvas, qGuiApp->focusWindow()); - - QQuickPathView *pathview = qobject_cast(canvas->rootObject()); - QVERIFY(pathview != 0); - - int current = pathview->currentIndex(); - QCOMPARE(current, 0); - - QQuickRectangle *firstItem = findItem(pathview, "wrapper", 0); - QVERIFY(firstItem); - QDeclarativePath *path = qobject_cast(pathview->path()); - QVERIFY(path); - QPointF start = path->pointAt(0.5); - QPointF offset;//Center of item is at point, but pos is from corner - offset.setX(firstItem->width()/2); - offset.setY(firstItem->height()/2); - QTRY_COMPARE(firstItem->pos() + offset, start); - - pathview->setPreferredHighlightBegin(0.8); - pathview->setPreferredHighlightEnd(0.8); - start = path->pointAt(0.8); - QTRY_COMPARE(firstItem->pos() + offset, start); - QCOMPARE(pathview->currentIndex(), 0); - - delete canvas; -} - -void tst_QQuickPathView::creationContext() -{ - QQuickView canvas; - canvas.setGeometry(0,0,240,320); - canvas.setSource(testFileUrl("creationContext.qml")); - - QQuickItem *rootItem = qobject_cast(canvas.rootObject()); - QVERIFY(rootItem); - QVERIFY(rootItem->property("count").toInt() > 0); - - QQuickItem *item; - QVERIFY(item = findItem(rootItem, "listItem", 0)); - QCOMPARE(item->property("text").toString(), QString("Hello!")); -} - -// QTBUG-21320 -void tst_QQuickPathView::currentOffsetOnInsertion() -{ - QQuickView *canvas = createView(); - canvas->show(); - - QaimModel model; - - QDeclarativeContext *ctxt = canvas->rootContext(); - ctxt->setContextProperty("testModel", &model); - - canvas->setSource(testFileUrl("pathline.qml")); - qApp->processEvents(); - - QQuickPathView *pathview = findItem(canvas->rootObject(), "view"); - QVERIFY(pathview != 0); - - pathview->setPreferredHighlightBegin(0.5); - pathview->setPreferredHighlightEnd(0.5); - - QCOMPARE(pathview->count(), model.count()); - - model.addItem("item0", "0"); - - QCOMPARE(pathview->count(), model.count()); - - QQuickRectangle *item = 0; - QTRY_VERIFY(item = findItem(pathview, "wrapper", 0)); - - QDeclarativePath *path = qobject_cast(pathview->path()); - QVERIFY(path); - - QPointF start = path->pointAt(0.5); - QPointF offset;//Center of item is at point, but pos is from corner - offset.setX(item->width()/2); - offset.setY(item->height()/2); - QCOMPARE(item->pos() + offset, start); - - QSignalSpy currentIndexSpy(pathview, SIGNAL(currentIndexChanged())); - - // insert an item at the beginning - model.insertItem(0, "item1", "1"); - qApp->processEvents(); - - QCOMPARE(currentIndexSpy.count(), 1); - - // currentIndex is now 1 - QVERIFY(item = findItem(pathview, "wrapper", 1)); - - // verify that current item (item 1) is still at offset 0.5 - QCOMPARE(item->pos() + offset, start); - - // insert another item at the beginning - model.insertItem(0, "item2", "2"); - qApp->processEvents(); - - QCOMPARE(currentIndexSpy.count(), 2); - - // currentIndex is now 2 - QVERIFY(item = findItem(pathview, "wrapper", 2)); - - // verify that current item (item 2) is still at offset 0.5 - QCOMPARE(item->pos() + offset, start); - - // verify that remove before current maintains current item - model.removeItem(0); - qApp->processEvents(); - - QCOMPARE(currentIndexSpy.count(), 3); - - // currentIndex is now 1 - QVERIFY(item = findItem(pathview, "wrapper", 1)); - - // verify that current item (item 1) is still at offset 0.5 - QCOMPARE(item->pos() + offset, start); - - delete canvas; -} - -void tst_QQuickPathView::asynchronous() -{ - QQuickView *canvas = createView(); - canvas->show(); - QDeclarativeIncubationController controller; - canvas->engine()->setIncubationController(&controller); - - canvas->setSource(testFileUrl("asyncloader.qml")); - - QQuickItem *rootObject = qobject_cast(canvas->rootObject()); - QVERIFY(rootObject); - - QQuickPathView *pathview = 0; - while (!pathview) { - bool b = false; - controller.incubateWhile(&b); - pathview = rootObject->findChild("view"); - } - - // items will be created one at a time - for (int i = 0; i < 5; ++i) { - QVERIFY(findItem(pathview, "wrapper", i) == 0); - QQuickItem *item = 0; - while (!item) { - bool b = false; - controller.incubateWhile(&b); - item = findItem(pathview, "wrapper", i); - } - } - - { - bool b = true; - controller.incubateWhile(&b); - } - - // verify positioning - QQuickRectangle *firstItem = findItem(pathview, "wrapper", 0); - QVERIFY(firstItem); - QDeclarativePath *path = qobject_cast(pathview->path()); - QVERIFY(path); - QPointF start = path->pointAt(0.0); - QPointF offset;//Center of item is at point, but pos is from corner - offset.setX(firstItem->width()/2); - offset.setY(firstItem->height()/2); - QTRY_COMPARE(firstItem->pos() + offset, start); - pathview->setOffset(1.0); - - for (int i=0; i<5; i++) { - QQuickItem *curItem = findItem(pathview, "wrapper", i); - QPointF itemPos(path->pointAt(0.2 + i*0.2)); - QCOMPARE(curItem->pos() + offset, itemPos); - } - - delete canvas; -} - -void tst_QQuickPathView::missingPercent() -{ - QDeclarativeEngine engine; - QDeclarativeComponent c(&engine, testFileUrl("missingPercent.qml")); - QDeclarativePath *obj = qobject_cast(c.create()); - QVERIFY(obj); - QCOMPARE(obj->attributeAt("_qfx_percent", 1.0), qreal(1.0)); - delete obj; -} - -QTEST_MAIN(tst_QQuickPathView) - -#include "tst_qquickpathview.moc" diff --git a/tests/auto/qtquick2/qquickpincharea/data/pinchproperties.qml b/tests/auto/qtquick2/qquickpincharea/data/pinchproperties.qml deleted file mode 100644 index 44d116184e..0000000000 --- a/tests/auto/qtquick2/qquickpincharea/data/pinchproperties.qml +++ /dev/null @@ -1,50 +0,0 @@ -import QtQuick 2.0 -Rectangle { - id: whiteRect - property variant center - property real scale - property int pointCount: 0 - width: 240; height: 320 - color: "white" - Rectangle { - id: blackRect - objectName: "blackrect" - color: "black" - y: 50 - x: 50 - width: 100 - height: 100 - opacity: (whiteRect.width-blackRect.x+whiteRect.height-blackRect.y-199)/200 - Text { text: blackRect.opacity} - PinchArea { - id: pincharea - objectName: "pincharea" - anchors.fill: parent - pinch.target: blackRect - pinch.dragAxis: Drag.XandYAxis - pinch.minimumX: 0 - pinch.maximumX: whiteRect.width-blackRect.width - pinch.minimumY: 0 - pinch.maximumY: whiteRect.height-blackRect.height - pinch.minimumScale: 1.0 - pinch.maximumScale: 2.0 - pinch.minimumRotation: 0.0 - pinch.maximumRotation: 90.0 - onPinchStarted: { - whiteRect.center = pinch.center - whiteRect.scale = pinch.scale - whiteRect.pointCount = pinch.pointCount; - } - onPinchUpdated: { - whiteRect.center = pinch.center - whiteRect.scale = pinch.scale - whiteRect.pointCount = pinch.pointCount; - } - onPinchFinished: { - whiteRect.center = pinch.center - whiteRect.scale = pinch.scale - whiteRect.pointCount = pinch.pointCount; - } - } - } - } diff --git a/tests/auto/qtquick2/qquickpincharea/qquickpincharea.pro b/tests/auto/qtquick2/qquickpincharea/qquickpincharea.pro deleted file mode 100644 index 3c75079ca5..0000000000 --- a/tests/auto/qtquick2/qquickpincharea/qquickpincharea.pro +++ /dev/null @@ -1,15 +0,0 @@ -CONFIG += testcase -TARGET = tst_qquickpincharea -macx:CONFIG -= app_bundle - -SOURCES += tst_qquickpincharea.cpp - -include (../../shared/util.pri) - -testDataFiles.files = data -testDataFiles.path = . -DEPLOYMENT += testDataFiles - -CONFIG += parallel_test - -QT += core-private gui-private declarative-private quick-private testlib diff --git a/tests/auto/qtquick2/qquickpincharea/tst_qquickpincharea.cpp b/tests/auto/qtquick2/qquickpincharea/tst_qquickpincharea.cpp deleted file mode 100644 index e1eaa7879e..0000000000 --- a/tests/auto/qtquick2/qquickpincharea/tst_qquickpincharea.cpp +++ /dev/null @@ -1,404 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include -#include -#include -#include -#include -#include -#include "../../shared/util.h" - -class tst_QQuickPinchArea: public QDeclarativeDataTest -{ - Q_OBJECT -public: - tst_QQuickPinchArea() : device(0) { } -private slots: - void initTestCase(); - void cleanupTestCase(); - void pinchProperties(); - void scale(); - void pan(); - void retouch(); - -private: - QQuickView *createView(); - QTouchDevice *device; -}; -void tst_QQuickPinchArea::initTestCase() -{ - QDeclarativeDataTest::initTestCase(); - if (!device) { - device = new QTouchDevice; - device->setType(QTouchDevice::TouchScreen); - QWindowSystemInterface::registerTouchDevice(device); - } -} - -void tst_QQuickPinchArea::cleanupTestCase() -{ - -} -void tst_QQuickPinchArea::pinchProperties() -{ - QQuickView *canvas = createView(); - canvas->setSource(testFileUrl("pinchproperties.qml")); - canvas->show(); - canvas->requestActivateWindow(); - QVERIFY(canvas->rootObject() != 0); - - QQuickPinchArea *pinchArea = canvas->rootObject()->findChild("pincharea"); - QQuickPinch *pinch = pinchArea->pinch(); - QVERIFY(pinchArea != 0); - QVERIFY(pinch != 0); - - // target - QQuickItem *blackRect = canvas->rootObject()->findChild("blackrect"); - QVERIFY(blackRect != 0); - QVERIFY(blackRect == pinch->target()); - QQuickItem *rootItem = qobject_cast(canvas->rootObject()); - QVERIFY(rootItem != 0); - QSignalSpy targetSpy(pinch, SIGNAL(targetChanged())); - pinch->setTarget(rootItem); - QCOMPARE(targetSpy.count(),1); - pinch->setTarget(rootItem); - QCOMPARE(targetSpy.count(),1); - - // axis - QCOMPARE(pinch->axis(), QQuickPinch::XandYAxis); - QSignalSpy axisSpy(pinch, SIGNAL(dragAxisChanged())); - pinch->setAxis(QQuickPinch::XAxis); - QCOMPARE(pinch->axis(), QQuickPinch::XAxis); - QCOMPARE(axisSpy.count(),1); - pinch->setAxis(QQuickPinch::XAxis); - QCOMPARE(axisSpy.count(),1); - - // minimum and maximum drag properties - QSignalSpy xminSpy(pinch, SIGNAL(minimumXChanged())); - QSignalSpy xmaxSpy(pinch, SIGNAL(maximumXChanged())); - QSignalSpy yminSpy(pinch, SIGNAL(minimumYChanged())); - QSignalSpy ymaxSpy(pinch, SIGNAL(maximumYChanged())); - - QCOMPARE(pinch->xmin(), 0.0); - QCOMPARE(pinch->xmax(), rootItem->width()-blackRect->width()); - QCOMPARE(pinch->ymin(), 0.0); - QCOMPARE(pinch->ymax(), rootItem->height()-blackRect->height()); - - pinch->setXmin(10); - pinch->setXmax(10); - pinch->setYmin(10); - pinch->setYmax(10); - - QCOMPARE(pinch->xmin(), 10.0); - QCOMPARE(pinch->xmax(), 10.0); - QCOMPARE(pinch->ymin(), 10.0); - QCOMPARE(pinch->ymax(), 10.0); - - QCOMPARE(xminSpy.count(),1); - QCOMPARE(xmaxSpy.count(),1); - QCOMPARE(yminSpy.count(),1); - QCOMPARE(ymaxSpy.count(),1); - - pinch->setXmin(10); - pinch->setXmax(10); - pinch->setYmin(10); - pinch->setYmax(10); - - QCOMPARE(xminSpy.count(),1); - QCOMPARE(xmaxSpy.count(),1); - QCOMPARE(yminSpy.count(),1); - QCOMPARE(ymaxSpy.count(),1); - - // minimum and maximum scale properties - QSignalSpy scaleMinSpy(pinch, SIGNAL(minimumScaleChanged())); - QSignalSpy scaleMaxSpy(pinch, SIGNAL(maximumScaleChanged())); - - QCOMPARE(pinch->minimumScale(), 1.0); - QCOMPARE(pinch->maximumScale(), 2.0); - - pinch->setMinimumScale(0.5); - pinch->setMaximumScale(1.5); - - QCOMPARE(pinch->minimumScale(), 0.5); - QCOMPARE(pinch->maximumScale(), 1.5); - - QCOMPARE(scaleMinSpy.count(),1); - QCOMPARE(scaleMaxSpy.count(),1); - - pinch->setMinimumScale(0.5); - pinch->setMaximumScale(1.5); - - QCOMPARE(scaleMinSpy.count(),1); - QCOMPARE(scaleMaxSpy.count(),1); - - // minimum and maximum rotation properties - QSignalSpy rotMinSpy(pinch, SIGNAL(minimumRotationChanged())); - QSignalSpy rotMaxSpy(pinch, SIGNAL(maximumRotationChanged())); - - QCOMPARE(pinch->minimumRotation(), 0.0); - QCOMPARE(pinch->maximumRotation(), 90.0); - - pinch->setMinimumRotation(-90.0); - pinch->setMaximumRotation(45.0); - - QCOMPARE(pinch->minimumRotation(), -90.0); - QCOMPARE(pinch->maximumRotation(), 45.0); - - QCOMPARE(rotMinSpy.count(),1); - QCOMPARE(rotMaxSpy.count(),1); - - pinch->setMinimumRotation(-90.0); - pinch->setMaximumRotation(45.0); - - QCOMPARE(rotMinSpy.count(),1); - QCOMPARE(rotMaxSpy.count(),1); - - delete canvas; -} - -QTouchEvent::TouchPoint makeTouchPoint(int id, QPoint p, QQuickView *v, QQuickItem *i) -{ - QTouchEvent::TouchPoint touchPoint(id); - touchPoint.setPos(i->mapFromScene(p)); - touchPoint.setScreenPos(v->mapToGlobal(p)); - touchPoint.setScenePos(p); - return touchPoint; -} - -void tst_QQuickPinchArea::scale() -{ - QQuickView *canvas = createView(); - canvas->setSource(testFileUrl("pinchproperties.qml")); - canvas->show(); - canvas->requestActivateWindow(); - QTest::qWaitForWindowShown(canvas); - QVERIFY(canvas->rootObject() != 0); - qApp->processEvents(); - - QQuickPinchArea *pinchArea = canvas->rootObject()->findChild("pincharea"); - QQuickPinch *pinch = pinchArea->pinch(); - QVERIFY(pinchArea != 0); - QVERIFY(pinch != 0); - - QQuickItem *root = qobject_cast(canvas->rootObject()); - QVERIFY(root != 0); - - // target - QQuickItem *blackRect = canvas->rootObject()->findChild("blackrect"); - QVERIFY(blackRect != 0); - - QPoint p1(80, 80); - QPoint p2(100, 100); - - QTest::touchEvent(canvas, device).press(0, p1, canvas); - QTest::touchEvent(canvas, device).stationary(0).press(1, p2, canvas); - p1 -= QPoint(10,10); - p2 += QPoint(10,10); - QTest::touchEvent(canvas, device).move(0, p1,canvas).move(1, p2,canvas); - - QCOMPARE(root->property("scale").toReal(), 1.0); - - p1 -= QPoint(10,10); - p2 += QPoint(10,10); - QTest::touchEvent(canvas, device).move(0, p1,canvas).move(1, p2,canvas); - - QCOMPARE(root->property("scale").toReal(), 1.5); - QCOMPARE(root->property("center").toPointF(), QPointF(40, 40)); // blackrect is at 50,50 - QCOMPARE(blackRect->scale(), 1.5); - - // scale beyond bound - p1 -= QPoint(50,50); - p2 += QPoint(50,50); - QTest::touchEvent(canvas, device).move(0, p1, canvas).move(1, p2, canvas); - - QCOMPARE(blackRect->scale(), 2.0); - - QTest::touchEvent(canvas, device).release(0, p1, canvas).release(1, p2, canvas); - - delete canvas; -} - -void tst_QQuickPinchArea::pan() -{ - QQuickView *canvas = createView(); - canvas->setSource(testFileUrl("pinchproperties.qml")); - canvas->show(); - canvas->requestActivateWindow(); - QTest::qWaitForWindowShown(canvas); - QVERIFY(canvas->rootObject() != 0); - qApp->processEvents(); - - QQuickPinchArea *pinchArea = canvas->rootObject()->findChild("pincharea"); - QQuickPinch *pinch = pinchArea->pinch(); - QVERIFY(pinchArea != 0); - QVERIFY(pinch != 0); - - QQuickItem *root = qobject_cast(canvas->rootObject()); - QVERIFY(root != 0); - - // target - QQuickItem *blackRect = canvas->rootObject()->findChild("blackrect"); - QVERIFY(blackRect != 0); - - QPoint p1(80, 80); - QPoint p2(100, 100); - - QTest::touchEvent(canvas, device).press(0, p1, canvas); - QTest::touchEvent(canvas, device).stationary(0).press(1, p2, canvas); - p1 += QPoint(10,10); - p2 += QPoint(10,10); - QTest::touchEvent(canvas, device).move(0, p1, canvas).move(1, p2, canvas); - - QCOMPARE(root->property("scale").toReal(), 1.0); - - p1 += QPoint(10,10); - p2 += QPoint(10,10); - QTest::touchEvent(canvas, device).move(0, p1, canvas).move(1, p2, canvas); - - QCOMPARE(root->property("center").toPointF(), QPointF(60, 60)); // blackrect is at 50,50 - - QCOMPARE(blackRect->x(), 60.0); - QCOMPARE(blackRect->y(), 60.0); - - // pan x beyond bound - p1 += QPoint(100,100); - p2 += QPoint(100,100); - QTest::touchEvent(canvas, device).move(0, p1, canvas).move(1, p2, canvas); - - QCOMPARE(blackRect->x(), 140.0); - QCOMPARE(blackRect->y(), 160.0); - - QTest::touchEvent(canvas, device).release(0, p1, canvas).release(1, p2, canvas); - - delete canvas; -} - -// test pinch, release one point, touch again to continue pinch -void tst_QQuickPinchArea::retouch() -{ - QQuickView *canvas = createView(); - canvas->setSource(testFileUrl("pinchproperties.qml")); - canvas->show(); - canvas->requestActivateWindow(); - QTest::qWaitForWindowShown(canvas); - QVERIFY(canvas->rootObject() != 0); - qApp->processEvents(); - - QQuickPinchArea *pinchArea = canvas->rootObject()->findChild("pincharea"); - QQuickPinch *pinch = pinchArea->pinch(); - QVERIFY(pinchArea != 0); - QVERIFY(pinch != 0); - - QQuickItem *root = qobject_cast(canvas->rootObject()); - QVERIFY(root != 0); - - QSignalSpy startedSpy(pinchArea, SIGNAL(pinchStarted(QQuickPinchEvent *))); - QSignalSpy finishedSpy(pinchArea, SIGNAL(pinchFinished(QQuickPinchEvent *))); - - // target - QQuickItem *blackRect = canvas->rootObject()->findChild("blackrect"); - QVERIFY(blackRect != 0); - - QPoint p1(80, 80); - QPoint p2(100, 100); - - QTest::touchEvent(canvas, device).press(0, p1, canvas); - QTest::touchEvent(canvas, device).stationary(0).press(1, p2, canvas); - p1 -= QPoint(10,10); - p2 += QPoint(10,10); - QTest::touchEvent(canvas, device).move(0, p1, canvas).move(1, p2, canvas); - - QCOMPARE(root->property("scale").toReal(), 1.0); - - p1 -= QPoint(10,10); - p2 += QPoint(10,10); - QTest::touchEvent(canvas, device).move(0, p1, canvas).move(1, p2, canvas); - - QCOMPARE(startedSpy.count(), 1); - - QCOMPARE(root->property("scale").toReal(), 1.5); - QCOMPARE(root->property("center").toPointF(), QPointF(40, 40)); // blackrect is at 50,50 - QCOMPARE(blackRect->scale(), 1.5); - - QCOMPARE(canvas->rootObject()->property("pointCount").toInt(), 2); - - QCOMPARE(startedSpy.count(), 1); - QCOMPARE(finishedSpy.count(), 0); - - QTest::touchEvent(canvas, device).stationary(0).release(1, p2, canvas); - - QCOMPARE(startedSpy.count(), 1); - QCOMPARE(finishedSpy.count(), 0); - - QCOMPARE(canvas->rootObject()->property("pointCount").toInt(), 1); - - QTest::touchEvent(canvas, device).stationary(0).press(1, p2, canvas); - p1 -= QPoint(10,10); - p2 += QPoint(10,10); - QTest::touchEvent(canvas, device).move(0, p1, canvas).move(1, p2, canvas); - - // Lifting and retouching results in onPinchStarted being called again - QCOMPARE(startedSpy.count(), 2); - QCOMPARE(finishedSpy.count(), 0); - - QCOMPARE(canvas->rootObject()->property("pointCount").toInt(), 2); - - QTest::touchEvent(canvas, device).release(0, p1, canvas).release(1, p2, canvas); - - QCOMPARE(startedSpy.count(), 2); - QCOMPARE(finishedSpy.count(), 1); - - delete canvas; -} - - -QQuickView *tst_QQuickPinchArea::createView() -{ - QQuickView *canvas = new QQuickView(0); - canvas->setGeometry(0,0,240,320); - - return canvas; -} - -QTEST_MAIN(tst_QQuickPinchArea) - -#include "tst_qquickpincharea.moc" diff --git a/tests/auto/qtquick2/qquickpositioners/data/allInvisible.qml b/tests/auto/qtquick2/qquickpositioners/data/allInvisible.qml deleted file mode 100644 index 5894171434..0000000000 --- a/tests/auto/qtquick2/qquickpositioners/data/allInvisible.qml +++ /dev/null @@ -1,44 +0,0 @@ -import QtQuick 2.0 - -Item{ - width: 400 - height: 400 - Column{ - spacing: 20 - objectName: "column" - Item{ - width: 0 - height: 20 - visible: false - } - Item{ - width: 20 - height: 0 - visible: false - } - Item{ - width: 20 - height: 20 - visible: false - } - } - Row{ - spacing: 20 - objectName: "row" - Item{ - width: 0 - height: 20 - visible: false - } - Item{ - width: 20 - height: 0 - visible: false - } - Item{ - width: 20 - height: 20 - visible: false - } - } -} diff --git a/tests/auto/qtquick2/qquickpositioners/data/attachedproperties-column.qml b/tests/auto/qtquick2/qquickpositioners/data/attachedproperties-column.qml deleted file mode 100644 index 4c667aa205..0000000000 --- a/tests/auto/qtquick2/qquickpositioners/data/attachedproperties-column.qml +++ /dev/null @@ -1,50 +0,0 @@ -import QtQuick 2.0 - -Rectangle { - width: 100 - height: 200 - - Column { - - Rectangle { - width: 100 - height: 100 - color: 'red' - visible: false - } - - Rectangle { - objectName: "greenRect" - width: 100 - height: 100 - color: 'green' - property int posIndex: Positioner.index - property bool isFirstItem: Positioner.isFirstItem - property bool isLastItem: Positioner.isLastItem - } - - Rectangle { - width: 100 - height: 100 - color: 'blue' - visible: false - } - - Rectangle { - objectName: "yellowRect" - width: 100 - height: 100 - color: 'yellow' - - property int posIndex: -1 - property bool isFirstItem: false - property bool isLastItem: false - - function onDemandPositioner() { - posIndex = Positioner.index; - isFirstItem = Positioner.isFirstItem - isLastItem = Positioner.isLastItem - } - } - } -} diff --git a/tests/auto/qtquick2/qquickpositioners/data/attachedproperties-dynamic.qml b/tests/auto/qtquick2/qquickpositioners/data/attachedproperties-dynamic.qml deleted file mode 100644 index 894749dc16..0000000000 --- a/tests/auto/qtquick2/qquickpositioners/data/attachedproperties-dynamic.qml +++ /dev/null @@ -1,44 +0,0 @@ -import QtQuick 2.0 - -Rectangle -{ - width: 300 - height: 100 - - Row { - id: pos - objectName: "pos" - anchors.fill: parent - - Rectangle { - objectName: "rect0" - width: 100 - height: 100 - color: 'red' - property int index: Positioner.index - property bool firstItem: Positioner.isFirstItem - property bool lastItem: Positioner.isLastItem - } - - Rectangle { - objectName: "rect1" - width: 100 - height: 100 - color: 'green' - property int index: Positioner.index - property bool firstItem: Positioner.isFirstItem - property bool lastItem: Positioner.isLastItem - } - - property QtObject subRect; - - function createSubRect() { - var component = Qt.createComponent("rectangleComponent.qml"); - subRect = component.createObject(pos, {}); - } - - function destroySubRect() { - subRect.destroy(); - } - } -} diff --git a/tests/auto/qtquick2/qquickpositioners/data/attachedproperties-flow.qml b/tests/auto/qtquick2/qquickpositioners/data/attachedproperties-flow.qml deleted file mode 100644 index e7f9a63e2a..0000000000 --- a/tests/auto/qtquick2/qquickpositioners/data/attachedproperties-flow.qml +++ /dev/null @@ -1,50 +0,0 @@ -import QtQuick 2.0 - -Rectangle { - width: 200 - height: 100 - - Flow { - - Rectangle { - width: 100 - height: 100 - color: 'red' - visible: false - } - - Rectangle { - objectName: "greenRect" - width: 100 - height: 100 - color: 'green' - property int posIndex: Positioner.index - property bool isFirstItem: Positioner.isFirstItem - property bool isLastItem: Positioner.isLastItem - } - - Rectangle { - width: 100 - height: 100 - color: 'blue' - visible: false - } - - Rectangle { - objectName: "yellowRect" - width: 100 - height: 100 - color: 'yellow' - - property int posIndex: -1 - property bool isFirstItem: false - property bool isLastItem: false - - function onDemandPositioner() { - posIndex = Positioner.index; - isFirstItem = Positioner.isFirstItem - isLastItem = Positioner.isLastItem - } - } - } -} diff --git a/tests/auto/qtquick2/qquickpositioners/data/attachedproperties-grid.qml b/tests/auto/qtquick2/qquickpositioners/data/attachedproperties-grid.qml deleted file mode 100644 index 2094309b9f..0000000000 --- a/tests/auto/qtquick2/qquickpositioners/data/attachedproperties-grid.qml +++ /dev/null @@ -1,50 +0,0 @@ -import QtQuick 2.0 - -Rectangle { - width: 200 - height: 100 - - Grid { - - Rectangle { - width: 100 - height: 100 - color: 'red' - visible: false - } - - Rectangle { - objectName: "greenRect" - width: 100 - height: 100 - color: 'green' - property int posIndex: Positioner.index - property bool isFirstItem: Positioner.isFirstItem - property bool isLastItem: Positioner.isLastItem - } - - Rectangle { - width: 100 - height: 100 - color: 'blue' - visible: false - } - - Rectangle { - objectName: "yellowRect" - width: 100 - height: 100 - color: 'yellow' - - property int posIndex: -1 - property bool isFirstItem: false - property bool isLastItem: false - - function onDemandPositioner() { - posIndex = Positioner.index; - isFirstItem = Positioner.isFirstItem - isLastItem = Positioner.isLastItem - } - } - } -} diff --git a/tests/auto/qtquick2/qquickpositioners/data/attachedproperties-row.qml b/tests/auto/qtquick2/qquickpositioners/data/attachedproperties-row.qml deleted file mode 100644 index 212a26b431..0000000000 --- a/tests/auto/qtquick2/qquickpositioners/data/attachedproperties-row.qml +++ /dev/null @@ -1,50 +0,0 @@ -import QtQuick 2.0 - -Rectangle { - width: 200 - height: 100 - - Row { - - Rectangle { - width: 100 - height: 100 - color: 'red' - visible: false - } - - Rectangle { - objectName: "greenRect" - width: 100 - height: 100 - color: 'green' - property int posIndex: Positioner.index - property bool isFirstItem: Positioner.isFirstItem - property bool isLastItem: Positioner.isLastItem - } - - Rectangle { - width: 100 - height: 100 - color: 'blue' - visible: false - } - - Rectangle { - objectName: "yellowRect" - width: 100 - height: 100 - color: 'yellow' - - property int posIndex: -1 - property bool isFirstItem: false - property bool isLastItem: false - - function onDemandPositioner() { - posIndex = Positioner.index; - isFirstItem = Positioner.isFirstItem - isLastItem = Positioner.isLastItem - } - } - } -} diff --git a/tests/auto/qtquick2/qquickpositioners/data/flow-testimplicitsize.qml b/tests/auto/qtquick2/qquickpositioners/data/flow-testimplicitsize.qml deleted file mode 100644 index c32b78676c..0000000000 --- a/tests/auto/qtquick2/qquickpositioners/data/flow-testimplicitsize.qml +++ /dev/null @@ -1,19 +0,0 @@ -import QtQuick 2.0 - -Rectangle { - width: 300; height: 200; - - property int flowLayout: 1 - - Flow { - objectName: "flow" - layoutDirection: (flowLayout == 2) ? Qt.RightToLeft : Qt.LeftToRight - flow: (flowLayout == 1) ? Flow.TopToBottom : Flow.LeftToRight; - - spacing: 20 - anchors.horizontalCenter: parent.horizontalCenter - Rectangle { color: "red"; width: 100; height: 50 } - Rectangle { color: "blue"; width: 100; height: 50 } - } -} - diff --git a/tests/auto/qtquick2/qquickpositioners/data/flowtest-toptobottom.qml b/tests/auto/qtquick2/qquickpositioners/data/flowtest-toptobottom.qml deleted file mode 100644 index a7d3ee13c7..0000000000 --- a/tests/auto/qtquick2/qquickpositioners/data/flowtest-toptobottom.qml +++ /dev/null @@ -1,44 +0,0 @@ -import QtQuick 2.0 - -Item { - height: 90 - width: 480 - property bool testRightToLeft: false - - Flow { - objectName: "flow" - height: parent.height - layoutDirection: testRightToLeft ? Qt.RightToLeft : Qt.LeftToRight - flow: Flow.TopToBottom - Rectangle { - objectName: "one" - color: "red" - width: 50 - height: 50 - } - Rectangle { - objectName: "two" - color: "green" - width: 20 - height: 50 - } - Rectangle { - objectName: "three" - color: "blue" - width: 50 - height: 20 - } - Rectangle { - objectName: "four" - color: "cyan" - width: 50 - height: 50 - } - Rectangle { - objectName: "five" - color: "magenta" - width: 10 - height: 10 - } - } -} diff --git a/tests/auto/qtquick2/qquickpositioners/data/flowtest.qml b/tests/auto/qtquick2/qquickpositioners/data/flowtest.qml deleted file mode 100644 index 40b042dd79..0000000000 --- a/tests/auto/qtquick2/qquickpositioners/data/flowtest.qml +++ /dev/null @@ -1,43 +0,0 @@ -import QtQuick 2.0 - -Item { - width: 90 - height: 480 - property bool testRightToLeft: false - - Flow { - objectName: "flow" - width: parent.width - layoutDirection: testRightToLeft ? Qt.RightToLeft : Qt.LeftToRight - Rectangle { - objectName: "one" - color: "red" - width: 50 - height: 50 - } - Rectangle { - objectName: "two" - color: "green" - width: 20 - height: 50 - } - Rectangle { - objectName: "three" - color: "blue" - width: 50 - height: 20 - } - Rectangle { - objectName: "four" - color: "cyan" - width: 50 - height: 50 - } - Rectangle { - objectName: "five" - color: "magenta" - width: 10 - height: 10 - } - } -} diff --git a/tests/auto/qtquick2/qquickpositioners/data/grid-animated.qml b/tests/auto/qtquick2/qquickpositioners/data/grid-animated.qml deleted file mode 100644 index b8ee8f9a52..0000000000 --- a/tests/auto/qtquick2/qquickpositioners/data/grid-animated.qml +++ /dev/null @@ -1,64 +0,0 @@ -import QtQuick 2.0 - -Item { - width: 640 - height: 480 - property bool testRightToLeft: true - - Grid { - objectName: "grid" - columns: 3 - layoutDirection: testRightToLeft ? Qt.RightToLeft : Qt.LeftToRight - add: Transition { - NumberAnimation { - properties: "x,y"; - } - } - move: Transition { - NumberAnimation { - properties: "x,y"; - } - } - Rectangle { - objectName: "one" - color: "red" - x: -100 - y: -100 - width: 50 - height: 50 - } - Rectangle { - objectName: "two" - x: -100 - y: -100 - visible: false - color: "green" - width: 50 - height: 50 - } - Rectangle { - objectName: "three" - color: "blue" - x: -100 - y: -100 - width: 50 - height: 50 - } - Rectangle { - objectName: "four" - color: "cyan" - x: -100 - y: -100 - width: 50 - height: 50 - } - Rectangle { - objectName: "five" - color: "magenta" - x: -100 - y: -100 - width: 50 - height: 50 - } - } -} diff --git a/tests/auto/qtquick2/qquickpositioners/data/grid-row-column-spacing.qml b/tests/auto/qtquick2/qquickpositioners/data/grid-row-column-spacing.qml deleted file mode 100644 index 49bbd337e7..0000000000 --- a/tests/auto/qtquick2/qquickpositioners/data/grid-row-column-spacing.qml +++ /dev/null @@ -1,43 +0,0 @@ -import QtQuick 2.0 - -Item { - width: 640 - height: 480 - Grid { - objectName: "grid" - columns: 3 - spacing: 4 - rowSpacing: 7 - columnSpacing: 11 - Rectangle { - objectName: "one" - color: "red" - width: 50 - height: 50 - } - Rectangle { - objectName: "two" - color: "green" - width: 20 - height: 50 - } - Rectangle { - objectName: "three" - color: "blue" - width: 50 - height: 20 - } - Rectangle { - objectName: "four" - color: "cyan" - width: 50 - height: 50 - } - Rectangle { - objectName: "five" - color: "magenta" - width: 10 - height: 10 - } - } -} diff --git a/tests/auto/qtquick2/qquickpositioners/data/grid-spacing.qml b/tests/auto/qtquick2/qquickpositioners/data/grid-spacing.qml deleted file mode 100644 index 535a39037f..0000000000 --- a/tests/auto/qtquick2/qquickpositioners/data/grid-spacing.qml +++ /dev/null @@ -1,41 +0,0 @@ -import QtQuick 2.0 - -Item { - width: 640 - height: 480 - Grid { - objectName: "grid" - columns: 3 - spacing: 4 - Rectangle { - objectName: "one" - color: "red" - width: 50 - height: 50 - } - Rectangle { - objectName: "two" - color: "green" - width: 20 - height: 50 - } - Rectangle { - objectName: "three" - color: "blue" - width: 50 - height: 20 - } - Rectangle { - objectName: "four" - color: "cyan" - width: 50 - height: 50 - } - Rectangle { - objectName: "five" - color: "magenta" - width: 10 - height: 10 - } - } -} diff --git a/tests/auto/qtquick2/qquickpositioners/data/grid-toptobottom.qml b/tests/auto/qtquick2/qquickpositioners/data/grid-toptobottom.qml deleted file mode 100644 index 45559aab5d..0000000000 --- a/tests/auto/qtquick2/qquickpositioners/data/grid-toptobottom.qml +++ /dev/null @@ -1,41 +0,0 @@ -import QtQuick 2.0 - -Item { - width: 640 - height: 480 - Grid { - objectName: "grid" - rows: 3 - flow: Grid.TopToBottom - Rectangle { - objectName: "one" - color: "red" - width: 50 - height: 50 - } - Rectangle { - objectName: "two" - color: "green" - width: 20 - height: 50 - } - Rectangle { - objectName: "three" - color: "blue" - width: 50 - height: 20 - } - Rectangle { - objectName: "four" - color: "cyan" - width: 50 - height: 50 - } - Rectangle { - objectName: "five" - color: "magenta" - width: 10 - height: 10 - } - } -} diff --git a/tests/auto/qtquick2/qquickpositioners/data/gridtest.qml b/tests/auto/qtquick2/qquickpositioners/data/gridtest.qml deleted file mode 100644 index 50bec1377b..0000000000 --- a/tests/auto/qtquick2/qquickpositioners/data/gridtest.qml +++ /dev/null @@ -1,42 +0,0 @@ -import QtQuick 2.0 - -Item { - width: 640 - height: 480 - property bool testRightToLeft: false - Grid { - layoutDirection: testRightToLeft ? Qt.RightToLeft : Qt.LeftToRight - objectName: "grid" - columns: 3 - Rectangle { - objectName: "one" - color: "red" - width: 50 - height: 50 - } - Rectangle { - objectName: "two" - color: "green" - width: 20 - height: 50 - } - Rectangle { - objectName: "three" - color: "blue" - width: 30 - height: 20 - } - Rectangle { - objectName: "four" - color: "cyan" - width: 50 - height: 50 - } - Rectangle { - objectName: "five" - color: "magenta" - width: 10 - height: 10 - } - } -} diff --git a/tests/auto/qtquick2/qquickpositioners/data/gridzerocolumns.qml b/tests/auto/qtquick2/qquickpositioners/data/gridzerocolumns.qml deleted file mode 100644 index a252f279c3..0000000000 --- a/tests/auto/qtquick2/qquickpositioners/data/gridzerocolumns.qml +++ /dev/null @@ -1,40 +0,0 @@ -import QtQuick 2.0 - -Item { - width: 640 - height: 480 - Grid { - objectName: "grid" - columns: 0 - Rectangle { - objectName: "one" - color: "red" - width: 50 - height: 50 - } - Rectangle { - objectName: "two" - color: "green" - width: 20 - height: 50 - } - Rectangle { - objectName: "three" - color: "blue" - width: 50 - height: 20 - } - Rectangle { - objectName: "four" - color: "cyan" - width: 50 - height: 50 - } - Rectangle { - objectName: "five" - color: "magenta" - width: 10 - height: 10 - } - } -} diff --git a/tests/auto/qtquick2/qquickpositioners/data/horizontal-animated-disabled.qml b/tests/auto/qtquick2/qquickpositioners/data/horizontal-animated-disabled.qml deleted file mode 100644 index 8723ffc78f..0000000000 --- a/tests/auto/qtquick2/qquickpositioners/data/horizontal-animated-disabled.qml +++ /dev/null @@ -1,40 +0,0 @@ -import QtQuick 2.0 - -Item { - width: 640 - height: 480 - - Row { - objectName: "row" - add: Transition { - enabled: false - NumberAnimation { properties: "x" } - } - move: Transition { - enabled: false - NumberAnimation { properties: "x" } - } - Rectangle { - objectName: "one" - color: "red" - x: -100; - width: 50 - height: 50 - } - Rectangle { - objectName: "two" - color: "blue" - x: -100; - visible: false - width: 50 - height: 50 - } - Rectangle { - objectName: "three" - x: -100; - color: "green" - width: 50 - height: 50 - } - } -} diff --git a/tests/auto/qtquick2/qquickpositioners/data/horizontal-animated.qml b/tests/auto/qtquick2/qquickpositioners/data/horizontal-animated.qml deleted file mode 100644 index a88c26b66c..0000000000 --- a/tests/auto/qtquick2/qquickpositioners/data/horizontal-animated.qml +++ /dev/null @@ -1,47 +0,0 @@ -import QtQuick 2.0 - -Item { - width: 640 - height: 480 - property bool testRightToLeft: false - property bool testEnabled: false - - Row { - objectName: "row" - layoutDirection: testRightToLeft ? Qt.RightToLeft : Qt.LeftToRight - add: Transition { - enabled: testEnabled ? false : true - NumberAnimation { - properties: "x"; - } - } - move: Transition { - enabled: testEnabled ? false : true - NumberAnimation { - properties: "x"; - } - } - Rectangle { - objectName: "one" - color: "red" - x: -100; - width: 50 - height: 50 - } - Rectangle { - objectName: "two" - color: "blue" - x: -100; - visible: false - width: 50 - height: 50 - } - Rectangle { - objectName: "three" - x: -100; - color: "green" - width: 50 - height: 50 - } - } -} diff --git a/tests/auto/qtquick2/qquickpositioners/data/horizontal-spacing.qml b/tests/auto/qtquick2/qquickpositioners/data/horizontal-spacing.qml deleted file mode 100644 index c6ff75ac6b..0000000000 --- a/tests/auto/qtquick2/qquickpositioners/data/horizontal-spacing.qml +++ /dev/null @@ -1,31 +0,0 @@ -import QtQuick 2.0 - -Item { - width: 640 - height: 480 - property bool testRightToLeft: false - - Row { - objectName: "row" - spacing: 10 - layoutDirection: testRightToLeft ? Qt.RightToLeft : Qt.LeftToRight - Rectangle { - objectName: "one" - color: "red" - width: 50 - height: 50 - } - Rectangle { - objectName: "two" - color: "red" - width: 20 - height: 10 - } - Rectangle { - objectName: "three" - color: "red" - width: 40 - height: 20 - } - } -} diff --git a/tests/auto/qtquick2/qquickpositioners/data/horizontal.qml b/tests/auto/qtquick2/qquickpositioners/data/horizontal.qml deleted file mode 100644 index 235ee78c9b..0000000000 --- a/tests/auto/qtquick2/qquickpositioners/data/horizontal.qml +++ /dev/null @@ -1,29 +0,0 @@ -import QtQuick 2.0 - -Item { - width: 640 - height: 480 - property bool testRightToLeft: false - Row { - objectName: "row" - layoutDirection: testRightToLeft ? Qt.RightToLeft : Qt.LeftToRight - Rectangle { - objectName: "one" - color: "red" - width: 50 - height: 50 - } - Rectangle { - objectName: "two" - color: "red" - width: 20 - height: 10 - } - Rectangle { - objectName: "three" - color: "red" - width: 40 - height: 20 - } - } -} diff --git a/tests/auto/qtquick2/qquickpositioners/data/propertychangestest.qml b/tests/auto/qtquick2/qquickpositioners/data/propertychangestest.qml deleted file mode 100644 index c9fd62b012..0000000000 --- a/tests/auto/qtquick2/qquickpositioners/data/propertychangestest.qml +++ /dev/null @@ -1,39 +0,0 @@ -import QtQuick 2.0 - -Grid { - id: myGrid - - width: 270 - height: 270 - x: 3 - y: 3 - columns: 4 - spacing: 3 - - add: columnTransition - move: columnTransition - - Repeater { - model: 20 - Rectangle { color: "black"; width: 50; height: 50 } - } - - data: [ - Transition { - id: rowTransition - objectName: "rowTransition" - NumberAnimation { - properties: "x,y"; - easing.type: "OutInCubic" - } - }, - Transition { - id: columnTransition - objectName: "columnTransition" - NumberAnimation { - properties: "x,y"; - easing.type: "OutInCubic" - } - } - ] -} diff --git a/tests/auto/qtquick2/qquickpositioners/data/rectangleComponent.qml b/tests/auto/qtquick2/qquickpositioners/data/rectangleComponent.qml deleted file mode 100644 index de1bb99593..0000000000 --- a/tests/auto/qtquick2/qquickpositioners/data/rectangleComponent.qml +++ /dev/null @@ -1,11 +0,0 @@ -import QtQuick 2.0; - -Rectangle { - objectName: "rect2" - color: "blue" - width: 100 - height: 100 - property int index: Positioner.index - property bool firstItem: Positioner.isFirstItem - property bool lastItem: Positioner.isLastItem -} diff --git a/tests/auto/qtquick2/qquickpositioners/data/repeatertest.qml b/tests/auto/qtquick2/qquickpositioners/data/repeatertest.qml deleted file mode 100644 index d90e1cf160..0000000000 --- a/tests/auto/qtquick2/qquickpositioners/data/repeatertest.qml +++ /dev/null @@ -1,38 +0,0 @@ -import QtQuick 2.0 - -Item { - width: 640 - height: 480 - Row { - Repeater{ model: 3; - delegate: Component { - Rectangle { - color: "red" - width: 50 - height: 50 - z: {if(index == 0){2;}else if(index == 1){1;} else{3;}} - objectName: {if(index == 0){"one";}else if(index == 1){"two";} else{"three";}} - } - } - } - } - - //This crashed once (QTBUG-16959) because the repeater ended up on the end of the list - //If this grid just instantiates without crashing, then it has not regressed. - Grid { - id: grid - rows: 2 - flow: Grid.TopToBottom - - Repeater { - model: 13 - Rectangle { - color: "goldenrod" - width: 100 - height: 100 - radius: 10 - border.width: 1 - } - } - } -} diff --git a/tests/auto/qtquick2/qquickpositioners/data/vertical-animated.qml b/tests/auto/qtquick2/qquickpositioners/data/vertical-animated.qml deleted file mode 100644 index ecf593cd70..0000000000 --- a/tests/auto/qtquick2/qquickpositioners/data/vertical-animated.qml +++ /dev/null @@ -1,41 +0,0 @@ -import QtQuick 2.0 - -Item { - width: 640 - height: 480 - Column { - objectName: "column" - add: Transition { - NumberAnimation { - properties: "y"; - } - } - move: Transition { - NumberAnimation { - properties: "y"; - } - } - Rectangle { - objectName: "one" - color: "red" - y: -100 - width: 50 - height: 50 - } - Rectangle { - objectName: "two" - color: "blue" - y: -100 - visible: false - width: 50 - height: 50 - } - Rectangle { - objectName: "three" - color: "red" - y: -100 - width: 50 - height: 50 - } - } -} diff --git a/tests/auto/qtquick2/qquickpositioners/data/vertical-spacing.qml b/tests/auto/qtquick2/qquickpositioners/data/vertical-spacing.qml deleted file mode 100644 index 7087961651..0000000000 --- a/tests/auto/qtquick2/qquickpositioners/data/vertical-spacing.qml +++ /dev/null @@ -1,28 +0,0 @@ -import QtQuick 2.0 - -Item { - width: 640 - height: 480 - Column { - objectName: "column" - spacing: 10 - Rectangle { - objectName: "one" - color: "red" - width: 50 - height: 50 - } - Rectangle { - objectName: "two" - color: "red" - width: 20 - height: 10 - } - Rectangle { - objectName: "three" - color: "red" - width: 40 - height: 20 - } - } -} diff --git a/tests/auto/qtquick2/qquickpositioners/data/vertical.qml b/tests/auto/qtquick2/qquickpositioners/data/vertical.qml deleted file mode 100644 index 0c3a81f008..0000000000 --- a/tests/auto/qtquick2/qquickpositioners/data/vertical.qml +++ /dev/null @@ -1,27 +0,0 @@ -import QtQuick 2.0 - -Item { - width: 640 - height: 480 - Column { - objectName: "column" - Rectangle { - objectName: "one" - color: "red" - width: 50 - height: 50 - } - Rectangle { - objectName: "two" - color: "red" - width: 20 - height: 10 - } - Rectangle { - objectName: "three" - color: "red" - width: 40 - height: 20 - } - } -} diff --git a/tests/auto/qtquick2/qquickpositioners/qquickpositioners.pro b/tests/auto/qtquick2/qquickpositioners/qquickpositioners.pro deleted file mode 100644 index ec0056f8e9..0000000000 --- a/tests/auto/qtquick2/qquickpositioners/qquickpositioners.pro +++ /dev/null @@ -1,14 +0,0 @@ -CONFIG += testcase -TARGET = tst_qquickpositioners -SOURCES += tst_qquickpositioners.cpp - -include (../../shared/util.pri) - -macx:CONFIG -= app_bundle - -testDataFiles.files = data -testDataFiles.path = . -DEPLOYMENT += testDataFiles - -CONFIG += parallel_test -QT += core-private gui-private v8-private declarative-private quick-private opengl-private testlib diff --git a/tests/auto/qtquick2/qquickpositioners/tst_qquickpositioners.cpp b/tests/auto/qtquick2/qquickpositioners/tst_qquickpositioners.cpp deleted file mode 100644 index 4c903ab704..0000000000 --- a/tests/auto/qtquick2/qquickpositioners/tst_qquickpositioners.cpp +++ /dev/null @@ -1,1472 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "../../shared/util.h" - -class tst_qquickpositioners : public QDeclarativeDataTest -{ - Q_OBJECT -public: - tst_qquickpositioners(); - -private slots: - void test_horizontal(); - void test_horizontal_rtl(); - void test_horizontal_spacing(); - void test_horizontal_spacing_rightToLeft(); - void test_horizontal_animated(); - void test_horizontal_animated_rightToLeft(); - void test_horizontal_animated_disabled(); - void test_vertical(); - void test_vertical_spacing(); - void test_vertical_animated(); - void test_grid(); - void test_grid_topToBottom(); - void test_grid_rightToLeft(); - void test_grid_spacing(); - void test_grid_row_column_spacing(); - void test_grid_animated(); - void test_grid_animated_rightToLeft(); - void test_grid_zero_columns(); - void test_propertychanges(); - void test_repeater(); - void test_flow(); - void test_flow_rightToLeft(); - void test_flow_topToBottom(); - void test_flow_resize(); - void test_flow_resize_rightToLeft(); - void test_flow_implicit_resize(); - void test_conflictinganchors(); - void test_mirroring(); - void test_allInvisible(); - void test_attachedproperties(); - void test_attachedproperties_data(); - void test_attachedproperties_dynamic(); - -private: - QQuickView *createView(const QString &filename, bool wait=true); -}; - -tst_qquickpositioners::tst_qquickpositioners() -{ -} - -void tst_qquickpositioners::test_horizontal() -{ - QQuickView *canvas = createView(testFile("horizontal.qml")); - - canvas->rootObject()->setProperty("testRightToLeft", false); - - QQuickRectangle *one = canvas->rootObject()->findChild("one"); - QVERIFY(one != 0); - - QQuickRectangle *two = canvas->rootObject()->findChild("two"); - QVERIFY(two != 0); - - QQuickRectangle *three = canvas->rootObject()->findChild("three"); - QVERIFY(three != 0); - - QCOMPARE(one->x(), 0.0); - QCOMPARE(one->y(), 0.0); - QCOMPARE(two->x(), 50.0); - QCOMPARE(two->y(), 0.0); - QCOMPARE(three->x(), 70.0); - QCOMPARE(three->y(), 0.0); - - QQuickItem *row = canvas->rootObject()->findChild("row"); - QCOMPARE(row->width(), 110.0); - QCOMPARE(row->height(), 50.0); - - delete canvas; -} - -void tst_qquickpositioners::test_horizontal_rtl() -{ - QQuickView *canvas = createView(testFile("horizontal.qml")); - - canvas->rootObject()->setProperty("testRightToLeft", true); - - QQuickRectangle *one = canvas->rootObject()->findChild("one"); - QVERIFY(one != 0); - - QQuickRectangle *two = canvas->rootObject()->findChild("two"); - QVERIFY(two != 0); - - QQuickRectangle *three = canvas->rootObject()->findChild("three"); - QVERIFY(three != 0); - - QCOMPARE(one->x(), 60.0); - QCOMPARE(one->y(), 0.0); - QCOMPARE(two->x(), 40.0); - QCOMPARE(two->y(), 0.0); - QCOMPARE(three->x(), 0.0); - QCOMPARE(three->y(), 0.0); - - QQuickItem *row = canvas->rootObject()->findChild("row"); - QCOMPARE(row->width(), 110.0); - QCOMPARE(row->height(), 50.0); - - // Change the width of the row and check that items stay to the right - row->setWidth(200); - QTRY_COMPARE(one->x(), 150.0); - QCOMPARE(one->y(), 0.0); - QCOMPARE(two->x(), 130.0); - QCOMPARE(two->y(), 0.0); - QCOMPARE(three->x(), 90.0); - QCOMPARE(three->y(), 0.0); - - delete canvas; -} - -void tst_qquickpositioners::test_horizontal_spacing() -{ - QQuickView *canvas = createView(testFile("horizontal-spacing.qml")); - - canvas->rootObject()->setProperty("testRightToLeft", false); - - QQuickRectangle *one = canvas->rootObject()->findChild("one"); - QVERIFY(one != 0); - - QQuickRectangle *two = canvas->rootObject()->findChild("two"); - QVERIFY(two != 0); - - QQuickRectangle *three = canvas->rootObject()->findChild("three"); - QVERIFY(three != 0); - - QCOMPARE(one->x(), 0.0); - QCOMPARE(one->y(), 0.0); - QCOMPARE(two->x(), 60.0); - QCOMPARE(two->y(), 0.0); - QCOMPARE(three->x(), 90.0); - QCOMPARE(three->y(), 0.0); - - QQuickItem *row = canvas->rootObject()->findChild("row"); - QCOMPARE(row->width(), 130.0); - QCOMPARE(row->height(), 50.0); - - delete canvas; -} - -void tst_qquickpositioners::test_horizontal_spacing_rightToLeft() -{ - QQuickView *canvas = createView(testFile("horizontal-spacing.qml")); - - canvas->rootObject()->setProperty("testRightToLeft", true); - - QQuickRectangle *one = canvas->rootObject()->findChild("one"); - QVERIFY(one != 0); - - QQuickRectangle *two = canvas->rootObject()->findChild("two"); - QVERIFY(two != 0); - - QQuickRectangle *three = canvas->rootObject()->findChild("three"); - QVERIFY(three != 0); - - QCOMPARE(one->x(), 80.0); - QCOMPARE(one->y(), 0.0); - QCOMPARE(two->x(), 50.0); - QCOMPARE(two->y(), 0.0); - QCOMPARE(three->x(), 00.0); - QCOMPARE(three->y(), 0.0); - - QQuickItem *row = canvas->rootObject()->findChild("row"); - QCOMPARE(row->width(), 130.0); - QCOMPARE(row->height(), 50.0); - - delete canvas; -} - -void tst_qquickpositioners::test_horizontal_animated() -{ - QQuickView *canvas = createView(testFile("horizontal-animated.qml"), false); - - canvas->rootObject()->setProperty("testRightToLeft", false); - - QQuickRectangle *one = canvas->rootObject()->findChild("one"); - QVERIFY(one != 0); - - QQuickRectangle *two = canvas->rootObject()->findChild("two"); - QVERIFY(two != 0); - - QQuickRectangle *three = canvas->rootObject()->findChild("three"); - QVERIFY(three != 0); - - //Note that they animate in - QCOMPARE(one->x(), -100.0); - QCOMPARE(two->x(), -100.0); - QCOMPARE(three->x(), -100.0); - - QTest::qWaitForWindowShown(canvas); //It may not relayout until the next frame, so it needs to be drawn - - QQuickItem *row = canvas->rootObject()->findChild("row"); - QVERIFY(row); - QCOMPARE(row->width(), 100.0); - QCOMPARE(row->height(), 50.0); - - //QTRY_COMPARE used instead of waiting for the expected time of animation completion - //Note that this means the duration of the animation is NOT tested - - QTRY_COMPARE(one->x(), 0.0); - QTRY_COMPARE(one->y(), 0.0); - QTRY_COMPARE(two->isVisible(), false); - QTRY_COMPARE(two->x(), -100.0);//Not 'in' yet - QTRY_COMPARE(two->y(), 0.0); - QTRY_COMPARE(three->x(), 50.0); - QTRY_COMPARE(three->y(), 0.0); - - //Add 'two' - two->setVisible(true); - QTRY_COMPARE(two->isVisible(), true); - QTRY_COMPARE(row->width(), 150.0); - QTRY_COMPARE(row->height(), 50.0); - - QTest::qWait(0);//Let the animation start - QVERIFY(two->x() >= -100.0 && two->x() < 50.0); - QVERIFY(three->x() >= 50.0 && three->x() < 100.0); - - QTRY_COMPARE(two->x(), 50.0); - QTRY_COMPARE(three->x(), 100.0); - - delete canvas; -} - -void tst_qquickpositioners::test_horizontal_animated_rightToLeft() -{ - QQuickView *canvas = createView(testFile("horizontal-animated.qml"), false); - - canvas->rootObject()->setProperty("testRightToLeft", true); - - QQuickRectangle *one = canvas->rootObject()->findChild("one"); - QVERIFY(one != 0); - - QQuickRectangle *two = canvas->rootObject()->findChild("two"); - QVERIFY(two != 0); - - QQuickRectangle *three = canvas->rootObject()->findChild("three"); - QVERIFY(three != 0); - - //Note that they animate in - QCOMPARE(one->x(), -100.0); - QCOMPARE(two->x(), -100.0); - QCOMPARE(three->x(), -100.0); - - QTest::qWaitForWindowShown(canvas); //It may not relayout until the next frame, so it needs to be drawn - - QQuickItem *row = canvas->rootObject()->findChild("row"); - QVERIFY(row); - QCOMPARE(row->width(), 100.0); - QCOMPARE(row->height(), 50.0); - - //QTRY_COMPARE used instead of waiting for the expected time of animation completion - //Note that this means the duration of the animation is NOT tested - - QTRY_COMPARE(one->x(), 50.0); - QTRY_COMPARE(one->y(), 0.0); - QTRY_COMPARE(two->isVisible(), false); - QTRY_COMPARE(two->x(), -100.0);//Not 'in' yet - QTRY_COMPARE(two->y(), 0.0); - QTRY_COMPARE(three->x(), 0.0); - QTRY_COMPARE(three->y(), 0.0); - - //Add 'two' - two->setVisible(true); - QTRY_COMPARE(two->isVisible(), true); - - // New size should propagate after visible change - QTRY_COMPARE(row->width(), 150.0); - QTRY_COMPARE(row->height(), 50.0); - - QTest::qWait(0);//Let the animation start - QVERIFY(one->x() >= 50.0 && one->x() < 100); - QVERIFY(two->x() >= -100.0 && two->x() < 50.0); - - QTRY_COMPARE(one->x(), 100.0); - QTRY_COMPARE(two->x(), 50.0); - - delete canvas; -} - -void tst_qquickpositioners::test_horizontal_animated_disabled() -{ - QQuickView *canvas = createView(testFile("horizontal-animated-disabled.qml")); - - QQuickRectangle *one = canvas->rootObject()->findChild("one"); - QVERIFY(one != 0); - - QQuickRectangle *two = canvas->rootObject()->findChild("two"); - QVERIFY(two != 0); - - QQuickRectangle *three = canvas->rootObject()->findChild("three"); - QVERIFY(three != 0); - - QQuickItem *row = canvas->rootObject()->findChild("row"); - QVERIFY(row); - - qApp->processEvents(); - - QCOMPARE(one->x(), 0.0); - QCOMPARE(one->y(), 0.0); - QCOMPARE(two->isVisible(), false); - QCOMPARE(two->x(), -100.0);//Not 'in' yet - QCOMPARE(two->y(), 0.0); - QCOMPARE(three->x(), 50.0); - QCOMPARE(three->y(), 0.0); - - //Add 'two' - two->setVisible(true); - QCOMPARE(two->isVisible(), true); - QTRY_COMPARE(row->width(), 150.0); - QTRY_COMPARE(row->height(), 50.0); - - QTRY_COMPARE(two->x(), 50.0); - QTRY_COMPARE(three->x(), 100.0); - - delete canvas; -} - -void tst_qquickpositioners::test_vertical() -{ - QQuickView *canvas = createView(testFile("vertical.qml")); - - QQuickRectangle *one = canvas->rootObject()->findChild("one"); - QVERIFY(one != 0); - - QQuickRectangle *two = canvas->rootObject()->findChild("two"); - QVERIFY(two != 0); - - QQuickRectangle *three = canvas->rootObject()->findChild("three"); - QVERIFY(three != 0); - - QCOMPARE(one->x(), 0.0); - QCOMPARE(one->y(), 0.0); - QCOMPARE(two->x(), 0.0); - QCOMPARE(two->y(), 50.0); - QCOMPARE(three->x(), 0.0); - QCOMPARE(three->y(), 60.0); - - QQuickItem *column = canvas->rootObject()->findChild("column"); - QVERIFY(column); - QCOMPARE(column->height(), 80.0); - QCOMPARE(column->width(), 50.0); - - delete canvas; -} - -void tst_qquickpositioners::test_vertical_spacing() -{ - QQuickView *canvas = createView(testFile("vertical-spacing.qml")); - - QQuickRectangle *one = canvas->rootObject()->findChild("one"); - QVERIFY(one != 0); - - QQuickRectangle *two = canvas->rootObject()->findChild("two"); - QVERIFY(two != 0); - - QQuickRectangle *three = canvas->rootObject()->findChild("three"); - QVERIFY(three != 0); - - QCOMPARE(one->x(), 0.0); - QCOMPARE(one->y(), 0.0); - QCOMPARE(two->x(), 0.0); - QCOMPARE(two->y(), 60.0); - QCOMPARE(three->x(), 0.0); - QCOMPARE(three->y(), 80.0); - - QQuickItem *column = canvas->rootObject()->findChild("column"); - QCOMPARE(column->height(), 100.0); - QCOMPARE(column->width(), 50.0); - - delete canvas; -} - -void tst_qquickpositioners::test_vertical_animated() -{ - QQuickView *canvas = createView(testFile("vertical-animated.qml"), false); - - //Note that they animate in - QQuickRectangle *one = canvas->rootObject()->findChild("one"); - QVERIFY(one != 0); - QCOMPARE(one->y(), -100.0); - - QQuickRectangle *two = canvas->rootObject()->findChild("two"); - QVERIFY(two != 0); - QCOMPARE(two->y(), -100.0); - - QQuickRectangle *three = canvas->rootObject()->findChild("three"); - QVERIFY(three != 0); - QCOMPARE(three->y(), -100.0); - - QTest::qWaitForWindowShown(canvas); //It may not relayout until the next frame, so it needs to be drawn - - QQuickItem *column = canvas->rootObject()->findChild("column"); - QVERIFY(column); - QCOMPARE(column->height(), 100.0); - QCOMPARE(column->width(), 50.0); - - //QTRY_COMPARE used instead of waiting for the expected time of animation completion - //Note that this means the duration of the animation is NOT tested - - QTRY_COMPARE(one->y(), 0.0); - QTRY_COMPARE(one->x(), 0.0); - QTRY_COMPARE(two->isVisible(), false); - QTRY_COMPARE(two->y(), -100.0);//Not 'in' yet - QTRY_COMPARE(two->x(), 0.0); - QTRY_COMPARE(three->y(), 50.0); - QTRY_COMPARE(three->x(), 0.0); - - //Add 'two' - two->setVisible(true); - QTRY_COMPARE(two->isVisible(), true); - QTRY_COMPARE(column->height(), 150.0); - QTRY_COMPARE(column->width(), 50.0); - QTest::qWait(0);//Let the animation start - QVERIFY(two->y() >= -100.0 && two->y() < 50.0); - QVERIFY(three->y() >= 50.0 && three->y() < 100.0); - - QTRY_COMPARE(two->y(), 50.0); - QTRY_COMPARE(three->y(), 100.0); - - delete canvas; -} - -void tst_qquickpositioners::test_grid() -{ - QQuickView *canvas = createView(testFile("gridtest.qml")); - - QQuickRectangle *one = canvas->rootObject()->findChild("one"); - QVERIFY(one != 0); - QQuickRectangle *two = canvas->rootObject()->findChild("two"); - QVERIFY(two != 0); - QQuickRectangle *three = canvas->rootObject()->findChild("three"); - QVERIFY(three != 0); - QQuickRectangle *four = canvas->rootObject()->findChild("four"); - QVERIFY(four != 0); - QQuickRectangle *five = canvas->rootObject()->findChild("five"); - QVERIFY(five != 0); - - QCOMPARE(one->x(), 0.0); - QCOMPARE(one->y(), 0.0); - QCOMPARE(two->x(), 50.0); - QCOMPARE(two->y(), 0.0); - QCOMPARE(three->x(), 70.0); - QCOMPARE(three->y(), 0.0); - QCOMPARE(four->x(), 0.0); - QCOMPARE(four->y(), 50.0); - QCOMPARE(five->x(), 50.0); - QCOMPARE(five->y(), 50.0); - - QQuickGrid *grid = canvas->rootObject()->findChild("grid"); - QCOMPARE(grid->flow(), QQuickGrid::LeftToRight); - QCOMPARE(grid->width(), 100.0); - QCOMPARE(grid->height(), 100.0); - - delete canvas; -} - -void tst_qquickpositioners::test_grid_topToBottom() -{ - QQuickView *canvas = createView(testFile("grid-toptobottom.qml")); - - QQuickRectangle *one = canvas->rootObject()->findChild("one"); - QVERIFY(one != 0); - QQuickRectangle *two = canvas->rootObject()->findChild("two"); - QVERIFY(two != 0); - QQuickRectangle *three = canvas->rootObject()->findChild("three"); - QVERIFY(three != 0); - QQuickRectangle *four = canvas->rootObject()->findChild("four"); - QVERIFY(four != 0); - QQuickRectangle *five = canvas->rootObject()->findChild("five"); - QVERIFY(five != 0); - - QCOMPARE(one->x(), 0.0); - QCOMPARE(one->y(), 0.0); - QCOMPARE(two->x(), 0.0); - QCOMPARE(two->y(), 50.0); - QCOMPARE(three->x(), 0.0); - QCOMPARE(three->y(), 100.0); - QCOMPARE(four->x(), 50.0); - QCOMPARE(four->y(), 0.0); - QCOMPARE(five->x(), 50.0); - QCOMPARE(five->y(), 50.0); - - QQuickGrid *grid = canvas->rootObject()->findChild("grid"); - QCOMPARE(grid->flow(), QQuickGrid::TopToBottom); - QCOMPARE(grid->width(), 100.0); - QCOMPARE(grid->height(), 120.0); - - delete canvas; -} - -void tst_qquickpositioners::test_grid_rightToLeft() -{ - QQuickView *canvas = createView(testFile("gridtest.qml")); - - canvas->rootObject()->setProperty("testRightToLeft", true); - - QQuickRectangle *one = canvas->rootObject()->findChild("one"); - QVERIFY(one != 0); - QQuickRectangle *two = canvas->rootObject()->findChild("two"); - QVERIFY(two != 0); - QQuickRectangle *three = canvas->rootObject()->findChild("three"); - QVERIFY(three != 0); - QQuickRectangle *four = canvas->rootObject()->findChild("four"); - QVERIFY(four != 0); - QQuickRectangle *five = canvas->rootObject()->findChild("five"); - QVERIFY(five != 0); - - QCOMPARE(one->x(), 50.0); - QCOMPARE(one->y(), 0.0); - QCOMPARE(two->x(), 30.0); - QCOMPARE(two->y(), 0.0); - QCOMPARE(three->x(), 0.0); - QCOMPARE(three->y(), 0.0); - QCOMPARE(four->x(), 50.0); - QCOMPARE(four->y(), 50.0); - QCOMPARE(five->x(), 40.0); - QCOMPARE(five->y(), 50.0); - - QQuickGrid *grid = canvas->rootObject()->findChild("grid"); - QCOMPARE(grid->layoutDirection(), Qt::RightToLeft); - QCOMPARE(grid->width(), 100.0); - QCOMPARE(grid->height(), 100.0); - - // Change the width of the grid and check that items stay to the right - grid->setWidth(200); - QTRY_COMPARE(one->x(), 150.0); - QCOMPARE(one->y(), 0.0); - QCOMPARE(two->x(), 130.0); - QCOMPARE(two->y(), 0.0); - QCOMPARE(three->x(), 100.0); - QCOMPARE(three->y(), 0.0); - QCOMPARE(four->x(), 150.0); - QCOMPARE(four->y(), 50.0); - QCOMPARE(five->x(), 140.0); - QCOMPARE(five->y(), 50.0); - - delete canvas; -} - -void tst_qquickpositioners::test_grid_spacing() -{ - QQuickView *canvas = createView(testFile("grid-spacing.qml")); - - QQuickRectangle *one = canvas->rootObject()->findChild("one"); - QVERIFY(one != 0); - QQuickRectangle *two = canvas->rootObject()->findChild("two"); - QVERIFY(two != 0); - QQuickRectangle *three = canvas->rootObject()->findChild("three"); - QVERIFY(three != 0); - QQuickRectangle *four = canvas->rootObject()->findChild("four"); - QVERIFY(four != 0); - QQuickRectangle *five = canvas->rootObject()->findChild("five"); - QVERIFY(five != 0); - - QCOMPARE(one->x(), 0.0); - QCOMPARE(one->y(), 0.0); - QCOMPARE(two->x(), 54.0); - QCOMPARE(two->y(), 0.0); - QCOMPARE(three->x(), 78.0); - QCOMPARE(three->y(), 0.0); - QCOMPARE(four->x(), 0.0); - QCOMPARE(four->y(), 54.0); - QCOMPARE(five->x(), 54.0); - QCOMPARE(five->y(), 54.0); - - QQuickItem *grid = canvas->rootObject()->findChild("grid"); - QCOMPARE(grid->width(), 128.0); - QCOMPARE(grid->height(), 104.0); - - delete canvas; -} - -void tst_qquickpositioners::test_grid_row_column_spacing() -{ - QQuickView *canvas = createView(testFile("grid-row-column-spacing.qml")); - - QQuickRectangle *one = canvas->rootObject()->findChild("one"); - QVERIFY(one != 0); - QQuickRectangle *two = canvas->rootObject()->findChild("two"); - QVERIFY(two != 0); - QQuickRectangle *three = canvas->rootObject()->findChild("three"); - QVERIFY(three != 0); - QQuickRectangle *four = canvas->rootObject()->findChild("four"); - QVERIFY(four != 0); - QQuickRectangle *five = canvas->rootObject()->findChild("five"); - QVERIFY(five != 0); - - QCOMPARE(one->x(), 0.0); - QCOMPARE(one->y(), 0.0); - QCOMPARE(two->x(), 61.0); - QCOMPARE(two->y(), 0.0); - QCOMPARE(three->x(), 92.0); - QCOMPARE(three->y(), 0.0); - QCOMPARE(four->x(), 0.0); - QCOMPARE(four->y(), 57.0); - QCOMPARE(five->x(), 61.0); - QCOMPARE(five->y(), 57.0); - - QQuickItem *grid = canvas->rootObject()->findChild("grid"); - QCOMPARE(grid->width(), 142.0); - QCOMPARE(grid->height(), 107.0); - - delete canvas; -} - -void tst_qquickpositioners::test_grid_animated() -{ - QQuickView *canvas = createView(testFile("grid-animated.qml"), false); - - canvas->rootObject()->setProperty("testRightToLeft", false); - - //Note that all animate in - QQuickRectangle *one = canvas->rootObject()->findChild("one"); - QVERIFY(one != 0); - QCOMPARE(one->x(), -100.0); - QCOMPARE(one->y(), -100.0); - - QQuickRectangle *two = canvas->rootObject()->findChild("two"); - QVERIFY(two != 0); - QCOMPARE(two->x(), -100.0); - QCOMPARE(two->y(), -100.0); - - QQuickRectangle *three = canvas->rootObject()->findChild("three"); - QVERIFY(three != 0); - QCOMPARE(three->x(), -100.0); - QCOMPARE(three->y(), -100.0); - - QQuickRectangle *four = canvas->rootObject()->findChild("four"); - QVERIFY(four != 0); - QCOMPARE(four->x(), -100.0); - QCOMPARE(four->y(), -100.0); - - QQuickRectangle *five = canvas->rootObject()->findChild("five"); - QVERIFY(five != 0); - QCOMPARE(five->x(), -100.0); - QCOMPARE(five->y(), -100.0); - - QTest::qWaitForWindowShown(canvas); //It may not relayout until the next frame, so it needs to be drawn - - QQuickItem *grid = canvas->rootObject()->findChild("grid"); - QVERIFY(grid); - QCOMPARE(grid->width(), 150.0); - QCOMPARE(grid->height(), 100.0); - - //QTRY_COMPARE used instead of waiting for the expected time of animation completion - //Note that this means the duration of the animation is NOT tested - - QTRY_COMPARE(one->y(), 0.0); - QTRY_COMPARE(one->x(), 0.0); - QTRY_COMPARE(two->isVisible(), false); - QTRY_COMPARE(two->y(), -100.0); - QTRY_COMPARE(two->x(), -100.0); - QTRY_COMPARE(three->y(), 0.0); - QTRY_COMPARE(three->x(), 50.0); - QTRY_COMPARE(four->y(), 0.0); - QTRY_COMPARE(four->x(), 100.0); - QTRY_COMPARE(five->y(), 50.0); - QTRY_COMPARE(five->x(), 0.0); - - //Add 'two' - two->setVisible(true); - QCOMPARE(two->isVisible(), true); - QCOMPARE(grid->width(), 150.0); - QCOMPARE(grid->height(), 100.0); - QTest::qWait(0);//Let the animation start - QCOMPARE(two->x(), -100.0); - QCOMPARE(two->y(), -100.0); - QCOMPARE(one->x(), 0.0); - QCOMPARE(one->y(), 0.0); - QCOMPARE(three->x(), 50.0); - QCOMPARE(three->y(), 0.0); - QCOMPARE(four->x(), 100.0); - QCOMPARE(four->y(), 0.0); - QCOMPARE(five->x(), 0.0); - QCOMPARE(five->y(), 50.0); - //Let the animation complete - QTRY_COMPARE(two->x(), 50.0); - QTRY_COMPARE(two->y(), 0.0); - QTRY_COMPARE(one->x(), 0.0); - QTRY_COMPARE(one->y(), 0.0); - QTRY_COMPARE(three->x(), 100.0); - QTRY_COMPARE(three->y(), 0.0); - QTRY_COMPARE(four->x(), 0.0); - QTRY_COMPARE(four->y(), 50.0); - QTRY_COMPARE(five->x(), 50.0); - QTRY_COMPARE(five->y(), 50.0); - - delete canvas; -} - -void tst_qquickpositioners::test_grid_animated_rightToLeft() -{ - QQuickView *canvas = createView(testFile("grid-animated.qml"), false); - - canvas->rootObject()->setProperty("testRightToLeft", true); - - //Note that all animate in - QQuickRectangle *one = canvas->rootObject()->findChild("one"); - QVERIFY(one != 0); - QCOMPARE(one->x(), -100.0); - QCOMPARE(one->y(), -100.0); - - QQuickRectangle *two = canvas->rootObject()->findChild("two"); - QVERIFY(two != 0); - QCOMPARE(two->x(), -100.0); - QCOMPARE(two->y(), -100.0); - - QQuickRectangle *three = canvas->rootObject()->findChild("three"); - QVERIFY(three != 0); - QCOMPARE(three->x(), -100.0); - QCOMPARE(three->y(), -100.0); - - QQuickRectangle *four = canvas->rootObject()->findChild("four"); - QVERIFY(four != 0); - QCOMPARE(four->x(), -100.0); - QCOMPARE(four->y(), -100.0); - - QQuickRectangle *five = canvas->rootObject()->findChild("five"); - QVERIFY(five != 0); - QCOMPARE(five->x(), -100.0); - QCOMPARE(five->y(), -100.0); - - QTest::qWaitForWindowShown(canvas); //It may not relayout until the next frame, so it needs to be drawn - - QQuickItem *grid = canvas->rootObject()->findChild("grid"); - QVERIFY(grid); - QCOMPARE(grid->width(), 150.0); - QCOMPARE(grid->height(), 100.0); - - //QTRY_COMPARE used instead of waiting for the expected time of animation completion - //Note that this means the duration of the animation is NOT tested - - QTRY_COMPARE(one->y(), 0.0); - QTRY_COMPARE(one->x(), 100.0); - QTRY_COMPARE(two->isVisible(), false); - QTRY_COMPARE(two->y(), -100.0); - QTRY_COMPARE(two->x(), -100.0); - QTRY_COMPARE(three->y(), 0.0); - QTRY_COMPARE(three->x(), 50.0); - QTRY_COMPARE(four->y(), 0.0); - QTRY_COMPARE(four->x(), 0.0); - QTRY_COMPARE(five->y(), 50.0); - QTRY_COMPARE(five->x(), 100.0); - - //Add 'two' - two->setVisible(true); - QCOMPARE(two->isVisible(), true); - QCOMPARE(grid->width(), 150.0); - QCOMPARE(grid->height(), 100.0); - QTest::qWait(0);//Let the animation start - QCOMPARE(two->x(), -100.0); - QCOMPARE(two->y(), -100.0); - QCOMPARE(one->x(), 100.0); - QCOMPARE(one->y(), 0.0); - QCOMPARE(three->x(), 50.0); - QCOMPARE(three->y(), 0.0); - QCOMPARE(four->x(), 0.0); - QCOMPARE(four->y(), 0.0); - QCOMPARE(five->x(), 100.0); - QCOMPARE(five->y(), 50.0); - //Let the animation complete - QTRY_COMPARE(two->x(), 50.0); - QTRY_COMPARE(two->y(), 0.0); - QTRY_COMPARE(one->x(), 100.0); - QTRY_COMPARE(one->y(), 0.0); - QTRY_COMPARE(three->x(), 0.0); - QTRY_COMPARE(three->y(), 0.0); - QTRY_COMPARE(four->x(), 100.0); - QTRY_COMPARE(four->y(), 50.0); - QTRY_COMPARE(five->x(), 50.0); - QTRY_COMPARE(five->y(), 50.0); - - delete canvas; -} - -void tst_qquickpositioners::test_grid_zero_columns() -{ - QQuickView *canvas = createView(testFile("gridzerocolumns.qml")); - - QQuickRectangle *one = canvas->rootObject()->findChild("one"); - QVERIFY(one != 0); - QQuickRectangle *two = canvas->rootObject()->findChild("two"); - QVERIFY(two != 0); - QQuickRectangle *three = canvas->rootObject()->findChild("three"); - QVERIFY(three != 0); - QQuickRectangle *four = canvas->rootObject()->findChild("four"); - QVERIFY(four != 0); - QQuickRectangle *five = canvas->rootObject()->findChild("five"); - QVERIFY(five != 0); - - QCOMPARE(one->x(), 0.0); - QCOMPARE(one->y(), 0.0); - QCOMPARE(two->x(), 50.0); - QCOMPARE(two->y(), 0.0); - QCOMPARE(three->x(), 70.0); - QCOMPARE(three->y(), 0.0); - QCOMPARE(four->x(), 120.0); - QCOMPARE(four->y(), 0.0); - QCOMPARE(five->x(), 0.0); - QCOMPARE(five->y(), 50.0); - - QQuickItem *grid = canvas->rootObject()->findChild("grid"); - QCOMPARE(grid->width(), 170.0); - QCOMPARE(grid->height(), 60.0); - - delete canvas; -} - -void tst_qquickpositioners::test_propertychanges() -{ - QQuickView *canvas = createView(testFile("propertychangestest.qml")); - - QQuickGrid *grid = qobject_cast(canvas->rootObject()); - QVERIFY(grid != 0); - QDeclarativeTransition *rowTransition = canvas->rootObject()->findChild("rowTransition"); - QDeclarativeTransition *columnTransition = canvas->rootObject()->findChild("columnTransition"); - - QSignalSpy addSpy(grid, SIGNAL(addChanged())); - QSignalSpy moveSpy(grid, SIGNAL(moveChanged())); - QSignalSpy columnsSpy(grid, SIGNAL(columnsChanged())); - QSignalSpy rowsSpy(grid, SIGNAL(rowsChanged())); - - QVERIFY(grid); - QVERIFY(rowTransition); - QVERIFY(columnTransition); - QCOMPARE(grid->add(), columnTransition); - QCOMPARE(grid->move(), columnTransition); - QCOMPARE(grid->columns(), 4); - QCOMPARE(grid->rows(), -1); - - grid->setAdd(rowTransition); - grid->setMove(rowTransition); - QCOMPARE(grid->add(), rowTransition); - QCOMPARE(grid->move(), rowTransition); - QCOMPARE(addSpy.count(),1); - QCOMPARE(moveSpy.count(),1); - - grid->setAdd(rowTransition); - grid->setMove(rowTransition); - QCOMPARE(addSpy.count(),1); - QCOMPARE(moveSpy.count(),1); - - grid->setAdd(0); - grid->setMove(0); - QCOMPARE(addSpy.count(),2); - QCOMPARE(moveSpy.count(),2); - - grid->setColumns(-1); - grid->setRows(3); - QCOMPARE(grid->columns(), -1); - QCOMPARE(grid->rows(), 3); - QCOMPARE(columnsSpy.count(),1); - QCOMPARE(rowsSpy.count(),1); - - grid->setColumns(-1); - grid->setRows(3); - QCOMPARE(columnsSpy.count(),1); - QCOMPARE(rowsSpy.count(),1); - - grid->setColumns(2); - grid->setRows(2); - QCOMPARE(columnsSpy.count(),2); - QCOMPARE(rowsSpy.count(),2); - - delete canvas; -} - -void tst_qquickpositioners::test_repeater() -{ - QQuickView *canvas = createView(testFile("repeatertest.qml")); - - QQuickRectangle *one = canvas->rootObject()->findChild("one"); - QVERIFY(one != 0); - - QQuickRectangle *two = canvas->rootObject()->findChild("two"); - QVERIFY(two != 0); - - QQuickRectangle *three = canvas->rootObject()->findChild("three"); - QVERIFY(three != 0); - - QCOMPARE(one->x(), 0.0); - QCOMPARE(one->y(), 0.0); - QCOMPARE(two->x(), 50.0); - QCOMPARE(two->y(), 0.0); - QCOMPARE(three->x(), 100.0); - QCOMPARE(three->y(), 0.0); - - delete canvas; -} - -void tst_qquickpositioners::test_flow() -{ - QQuickView *canvas = createView(testFile("flowtest.qml")); - - canvas->rootObject()->setProperty("testRightToLeft", false); - - QQuickRectangle *one = canvas->rootObject()->findChild("one"); - QVERIFY(one != 0); - QQuickRectangle *two = canvas->rootObject()->findChild("two"); - QVERIFY(two != 0); - QQuickRectangle *three = canvas->rootObject()->findChild("three"); - QVERIFY(three != 0); - QQuickRectangle *four = canvas->rootObject()->findChild("four"); - QVERIFY(four != 0); - QQuickRectangle *five = canvas->rootObject()->findChild("five"); - QVERIFY(five != 0); - - QCOMPARE(one->x(), 0.0); - QCOMPARE(one->y(), 0.0); - QCOMPARE(two->x(), 50.0); - QCOMPARE(two->y(), 0.0); - QCOMPARE(three->x(), 0.0); - QCOMPARE(three->y(), 50.0); - QCOMPARE(four->x(), 0.0); - QCOMPARE(four->y(), 70.0); - QCOMPARE(five->x(), 50.0); - QCOMPARE(five->y(), 70.0); - - QQuickItem *flow = canvas->rootObject()->findChild("flow"); - QVERIFY(flow); - QCOMPARE(flow->width(), 90.0); - QCOMPARE(flow->height(), 120.0); - - delete canvas; -} - -void tst_qquickpositioners::test_flow_rightToLeft() -{ - QQuickView *canvas = createView(testFile("flowtest.qml")); - - canvas->rootObject()->setProperty("testRightToLeft", true); - - QQuickRectangle *one = canvas->rootObject()->findChild("one"); - QVERIFY(one != 0); - QQuickRectangle *two = canvas->rootObject()->findChild("two"); - QVERIFY(two != 0); - QQuickRectangle *three = canvas->rootObject()->findChild("three"); - QVERIFY(three != 0); - QQuickRectangle *four = canvas->rootObject()->findChild("four"); - QVERIFY(four != 0); - QQuickRectangle *five = canvas->rootObject()->findChild("five"); - QVERIFY(five != 0); - - QCOMPARE(one->x(), 40.0); - QCOMPARE(one->y(), 0.0); - QCOMPARE(two->x(), 20.0); - QCOMPARE(two->y(), 0.0); - QCOMPARE(three->x(), 40.0); - QCOMPARE(three->y(), 50.0); - QCOMPARE(four->x(), 40.0); - QCOMPARE(four->y(), 70.0); - QCOMPARE(five->x(), 30.0); - QCOMPARE(five->y(), 70.0); - - QQuickItem *flow = canvas->rootObject()->findChild("flow"); - QVERIFY(flow); - QCOMPARE(flow->width(), 90.0); - QCOMPARE(flow->height(), 120.0); - - delete canvas; -} - -void tst_qquickpositioners::test_flow_topToBottom() -{ - QQuickView *canvas = createView(testFile("flowtest-toptobottom.qml")); - - canvas->rootObject()->setProperty("testRightToLeft", false); - - QQuickRectangle *one = canvas->rootObject()->findChild("one"); - QVERIFY(one != 0); - QQuickRectangle *two = canvas->rootObject()->findChild("two"); - QVERIFY(two != 0); - QQuickRectangle *three = canvas->rootObject()->findChild("three"); - QVERIFY(three != 0); - QQuickRectangle *four = canvas->rootObject()->findChild("four"); - QVERIFY(four != 0); - QQuickRectangle *five = canvas->rootObject()->findChild("five"); - QVERIFY(five != 0); - - QCOMPARE(one->x(), 0.0); - QCOMPARE(one->y(), 0.0); - QCOMPARE(two->x(), 50.0); - QCOMPARE(two->y(), 0.0); - QCOMPARE(three->x(), 50.0); - QCOMPARE(three->y(), 50.0); - QCOMPARE(four->x(), 100.0); - QCOMPARE(four->y(), 00.0); - QCOMPARE(five->x(), 100.0); - QCOMPARE(five->y(), 50.0); - - QQuickItem *flow = canvas->rootObject()->findChild("flow"); - QVERIFY(flow); - QCOMPARE(flow->height(), 90.0); - QCOMPARE(flow->width(), 150.0); - - canvas->rootObject()->setProperty("testRightToLeft", true); - - QVERIFY(flow); - QCOMPARE(flow->height(), 90.0); - QCOMPARE(flow->width(), 150.0); - - QCOMPARE(one->x(), 100.0); - QCOMPARE(one->y(), 0.0); - QCOMPARE(two->x(), 80.0); - QCOMPARE(two->y(), 0.0); - QCOMPARE(three->x(), 50.0); - QCOMPARE(three->y(), 50.0); - QCOMPARE(four->x(), 0.0); - QCOMPARE(four->y(), 0.0); - QCOMPARE(five->x(), 40.0); - QCOMPARE(five->y(), 50.0); - - delete canvas; -} - -void tst_qquickpositioners::test_flow_resize() -{ - QQuickView *canvas = createView(testFile("flowtest.qml")); - - QQuickItem *root = qobject_cast(canvas->rootObject()); - QVERIFY(root); - root->setWidth(125); - root->setProperty("testRightToLeft", false); - - QQuickRectangle *one = canvas->rootObject()->findChild("one"); - QVERIFY(one != 0); - QQuickRectangle *two = canvas->rootObject()->findChild("two"); - QVERIFY(two != 0); - QQuickRectangle *three = canvas->rootObject()->findChild("three"); - QVERIFY(three != 0); - QQuickRectangle *four = canvas->rootObject()->findChild("four"); - QVERIFY(four != 0); - QQuickRectangle *five = canvas->rootObject()->findChild("five"); - QVERIFY(five != 0); - - QTRY_COMPARE(one->x(), 0.0); - QTRY_COMPARE(one->y(), 0.0); - QTRY_COMPARE(two->x(), 50.0); - QTRY_COMPARE(two->y(), 0.0); - QTRY_COMPARE(three->x(), 70.0); - QTRY_COMPARE(three->y(), 0.0); - QTRY_COMPARE(four->x(), 0.0); - QTRY_COMPARE(four->y(), 50.0); - QTRY_COMPARE(five->x(), 50.0); - QTRY_COMPARE(five->y(), 50.0); - - delete canvas; -} - -void tst_qquickpositioners::test_flow_resize_rightToLeft() -{ - QQuickView *canvas = createView(testFile("flowtest.qml")); - - QQuickItem *root = qobject_cast(canvas->rootObject()); - QVERIFY(root); - root->setWidth(125); - root->setProperty("testRightToLeft", true); - - QQuickRectangle *one = canvas->rootObject()->findChild("one"); - QTRY_VERIFY(one != 0); - QQuickRectangle *two = canvas->rootObject()->findChild("two"); - QVERIFY(two != 0); - QQuickRectangle *three = canvas->rootObject()->findChild("three"); - QVERIFY(three != 0); - QQuickRectangle *four = canvas->rootObject()->findChild("four"); - QVERIFY(four != 0); - QQuickRectangle *five = canvas->rootObject()->findChild("five"); - QVERIFY(five != 0); - - QCOMPARE(one->x(), 75.0); - QCOMPARE(one->y(), 0.0); - QCOMPARE(two->x(), 55.0); - QCOMPARE(two->y(), 0.0); - QCOMPARE(three->x(), 5.0); - QCOMPARE(three->y(), 0.0); - QCOMPARE(four->x(), 75.0); - QCOMPARE(four->y(), 50.0); - QCOMPARE(five->x(), 65.0); - QCOMPARE(five->y(), 50.0); - - delete canvas; -} - -void tst_qquickpositioners::test_flow_implicit_resize() -{ - QQuickView *canvas = createView(testFile("flow-testimplicitsize.qml")); - QVERIFY(canvas->rootObject() != 0); - - QQuickFlow *flow = canvas->rootObject()->findChild("flow"); - QVERIFY(flow != 0); - - QCOMPARE(flow->width(), 100.0); - QCOMPARE(flow->height(), 120.0); - - canvas->rootObject()->setProperty("flowLayout", 0); - QCOMPARE(flow->flow(), QQuickFlow::LeftToRight); - QCOMPARE(flow->width(), 220.0); - QCOMPARE(flow->height(), 50.0); - - canvas->rootObject()->setProperty("flowLayout", 1); - QCOMPARE(flow->flow(), QQuickFlow::TopToBottom); - QCOMPARE(flow->width(), 100.0); - QCOMPARE(flow->height(), 120.0); - - canvas->rootObject()->setProperty("flowLayout", 2); - QCOMPARE(flow->layoutDirection(), Qt::RightToLeft); - QCOMPARE(flow->width(), 220.0); - QCOMPARE(flow->height(), 50.0); - - delete canvas; -} - -QString warningMessage; - -void interceptWarnings(QtMsgType type, const char *msg) -{ - Q_UNUSED( type ); - warningMessage = msg; -} - -void tst_qquickpositioners::test_conflictinganchors() -{ - QtMsgHandler oldMsgHandler = qInstallMsgHandler(interceptWarnings); - QDeclarativeEngine engine; - QDeclarativeComponent component(&engine); - - component.setData("import QtQuick 2.0\nColumn { Item { width: 100; height: 100; } }", QUrl::fromLocalFile("")); - QQuickItem *item = qobject_cast(component.create()); - QVERIFY(item); - QVERIFY(warningMessage.isEmpty()); - delete item; - - component.setData("import QtQuick 2.0\nRow { Item { width: 100; height: 100; } }", QUrl::fromLocalFile("")); - item = qobject_cast(component.create()); - QVERIFY(item); - QVERIFY(warningMessage.isEmpty()); - delete item; - - component.setData("import QtQuick 2.0\nGrid { Item { width: 100; height: 100; } }", QUrl::fromLocalFile("")); - item = qobject_cast(component.create()); - QVERIFY(item); - QVERIFY(warningMessage.isEmpty()); - delete item; - - component.setData("import QtQuick 2.0\nFlow { Item { width: 100; height: 100; } }", QUrl::fromLocalFile("")); - item = qobject_cast(component.create()); - QVERIFY(item); - QVERIFY(warningMessage.isEmpty()); - delete item; - - component.setData("import QtQuick 2.0\nColumn { Item { width: 100; height: 100; anchors.top: parent.top } }", QUrl::fromLocalFile("")); - item = qobject_cast(component.create()); - QVERIFY(item); - QCOMPARE(warningMessage, QString("file::2:1: QML Column: Cannot specify top, bottom, verticalCenter, fill or centerIn anchors for items inside Column. Column will not function.")); - warningMessage.clear(); - delete item; - - component.setData("import QtQuick 2.0\nColumn { Item { width: 100; height: 100; anchors.centerIn: parent } }", QUrl::fromLocalFile("")); - item = qobject_cast(component.create()); - QVERIFY(item); - QCOMPARE(warningMessage, QString("file::2:1: QML Column: Cannot specify top, bottom, verticalCenter, fill or centerIn anchors for items inside Column. Column will not function.")); - warningMessage.clear(); - delete item; - - component.setData("import QtQuick 2.0\nColumn { Item { width: 100; height: 100; anchors.left: parent.left } }", QUrl::fromLocalFile("")); - item = qobject_cast(component.create()); - QVERIFY(item); - QVERIFY(warningMessage.isEmpty()); - warningMessage.clear(); - delete item; - - component.setData("import QtQuick 2.0\nRow { Item { width: 100; height: 100; anchors.left: parent.left } }", QUrl::fromLocalFile("")); - item = qobject_cast(component.create()); - QVERIFY(item); - QCOMPARE(warningMessage, QString("file::2:1: QML Row: Cannot specify left, right, horizontalCenter, fill or centerIn anchors for items inside Row. Row will not function.")); - warningMessage.clear(); - delete item; - - component.setData("import QtQuick 2.0\nRow { width: 100; height: 100; Item { anchors.fill: parent } }", QUrl::fromLocalFile("")); - item = qobject_cast(component.create()); - QVERIFY(item); - QCOMPARE(warningMessage, QString("file::2:1: QML Row: Cannot specify left, right, horizontalCenter, fill or centerIn anchors for items inside Row. Row will not function.")); - warningMessage.clear(); - delete item; - - component.setData("import QtQuick 2.0\nRow { Item { width: 100; height: 100; anchors.top: parent.top } }", QUrl::fromLocalFile("")); - item = qobject_cast(component.create()); - QVERIFY(item); - QVERIFY(warningMessage.isEmpty()); - warningMessage.clear(); - delete item; - - component.setData("import QtQuick 2.0\nGrid { Item { width: 100; height: 100; anchors.horizontalCenter: parent.horizontalCenter } }", QUrl::fromLocalFile("")); - item = qobject_cast(component.create()); - QVERIFY(item); - QCOMPARE(warningMessage, QString("file::2:1: QML Grid: Cannot specify anchors for items inside Grid. Grid will not function.")); - warningMessage.clear(); - delete item; - - component.setData("import QtQuick 2.0\nGrid { Item { width: 100; height: 100; anchors.centerIn: parent } }", QUrl::fromLocalFile("")); - item = qobject_cast(component.create()); - QVERIFY(item); - QCOMPARE(warningMessage, QString("file::2:1: QML Grid: Cannot specify anchors for items inside Grid. Grid will not function.")); - warningMessage.clear(); - delete item; - - component.setData("import QtQuick 2.0\nFlow { Item { width: 100; height: 100; anchors.verticalCenter: parent.verticalCenter } }", QUrl::fromLocalFile("")); - item = qobject_cast(component.create()); - QVERIFY(item); - QCOMPARE(warningMessage, QString("file::2:1: QML Flow: Cannot specify anchors for items inside Flow. Flow will not function.")); - delete item; - - component.setData("import QtQuick 2.0\nFlow { width: 100; height: 100; Item { anchors.fill: parent } }", QUrl::fromLocalFile("")); - item = qobject_cast(component.create()); - QVERIFY(item); - QCOMPARE(warningMessage, QString("file::2:1: QML Flow: Cannot specify anchors for items inside Flow. Flow will not function.")); - qInstallMsgHandler(oldMsgHandler); - delete item; -} - -void tst_qquickpositioners::test_mirroring() -{ - QList qmlFiles; - qmlFiles << "horizontal.qml" << "gridtest.qml" << "flowtest.qml"; - QList objectNames; - objectNames << "one" << "two" << "three" << "four" << "five"; - - foreach (const QString qmlFile, qmlFiles) { - QQuickView *canvasA = createView(testFile(qmlFile)); - QQuickItem *rootA = qobject_cast(canvasA->rootObject()); - - QQuickView *canvasB = createView(testFile(qmlFile)); - QQuickItem *rootB = qobject_cast(canvasB->rootObject()); - - rootA->setProperty("testRightToLeft", true); // layoutDirection: Qt.RightToLeft - - // LTR != RTL - foreach (const QString objectName, objectNames) { - // horizontal.qml only has three items - if (qmlFile == QString("horizontal.qml") && objectName == QString("four")) - break; - QQuickItem *itemA = rootA->findChild(objectName); - QQuickItem *itemB = rootB->findChild(objectName); - QTRY_VERIFY(itemA->x() != itemB->x()); - } - - QDeclarativeProperty enabledProp(rootB, "LayoutMirroring.enabled", qmlContext(rootB)); - enabledProp.write(true); - QDeclarativeProperty inheritProp(rootB, "LayoutMirroring.childrenInherit", qmlContext(rootB)); - inheritProp.write(true); - - // RTL == mirror - foreach (const QString objectName, objectNames) { - // horizontal.qml only has three items - if (qmlFile == QString("horizontal.qml") && objectName == QString("four")) - break; - QQuickItem *itemA = rootA->findChild(objectName); - QQuickItem *itemB = rootB->findChild(objectName); - QTRY_COMPARE(itemA->x(), itemB->x()); - } - - rootA->setProperty("testRightToLeft", false); // layoutDirection: Qt.LeftToRight - rootB->setProperty("testRightToLeft", true); // layoutDirection: Qt.RightToLeft - - // LTR == RTL + mirror - foreach (const QString objectName, objectNames) { - // horizontal.qml only has three items - if (qmlFile == QString("horizontal.qml") && objectName == QString("four")) - break; - QQuickItem *itemA = rootA->findChild(objectName); - QQuickItem *itemB = rootB->findChild(objectName); - QTRY_COMPARE(itemA->x(), itemB->x()); - } - delete canvasA; - delete canvasB; - } -} - -void tst_qquickpositioners::test_allInvisible() -{ - //QTBUG-19361 - QQuickView *canvas = createView(testFile("allInvisible.qml")); - - QQuickItem *root = qobject_cast(canvas->rootObject()); - QVERIFY(root); - - QQuickRow *row = canvas->rootObject()->findChild("row"); - QVERIFY(row != 0); - QVERIFY(row->width() == 0); - QVERIFY(row->height() == 0); - QQuickColumn *column = canvas->rootObject()->findChild("column"); - QVERIFY(column != 0); - QVERIFY(column->width() == 0); - QVERIFY(column->height() == 0); -} - -void tst_qquickpositioners::test_attachedproperties() -{ - QFETCH(QString, filename); - - QQuickView *canvas = createView(filename); - QVERIFY(canvas->rootObject() != 0); - - QQuickRectangle *greenRect = canvas->rootObject()->findChild("greenRect"); - QVERIFY(greenRect != 0); - - int posIndex = greenRect->property("posIndex").toInt(); - QVERIFY(posIndex == 0); - bool isFirst = greenRect->property("isFirstItem").toBool(); - QVERIFY(isFirst == true); - bool isLast = greenRect->property("isLastItem").toBool(); - QVERIFY(isLast == false); - - QQuickRectangle *yellowRect = canvas->rootObject()->findChild("yellowRect"); - QVERIFY(yellowRect != 0); - - posIndex = yellowRect->property("posIndex").toInt(); - QVERIFY(posIndex == -1); - isFirst = yellowRect->property("isFirstItem").toBool(); - QVERIFY(isFirst == false); - isLast = yellowRect->property("isLastItem").toBool(); - QVERIFY(isLast == false); - - yellowRect->metaObject()->invokeMethod(yellowRect, "onDemandPositioner"); - - posIndex = yellowRect->property("posIndex").toInt(); - QVERIFY(posIndex == 1); - isFirst = yellowRect->property("isFirstItem").toBool(); - QVERIFY(isFirst == false); - isLast = yellowRect->property("isLastItem").toBool(); - QVERIFY(isLast == true); - - delete canvas; -} - -void tst_qquickpositioners::test_attachedproperties_data() -{ - QTest::addColumn("filename"); - - QTest::newRow("column") << testFile("attachedproperties-column.qml"); - QTest::newRow("row") << testFile("attachedproperties-row.qml"); - QTest::newRow("grid") << testFile("attachedproperties-grid.qml"); - QTest::newRow("flow") << testFile("attachedproperties-flow.qml"); -} - -void tst_qquickpositioners::test_attachedproperties_dynamic() -{ - QQuickView *canvas = createView(testFile("attachedproperties-dynamic.qml")); - QVERIFY(canvas->rootObject() != 0); - - QQuickRow *row = canvas->rootObject()->findChild("pos"); - QVERIFY(row != 0); - - QQuickRectangle *rect0 = canvas->rootObject()->findChild("rect0"); - QVERIFY(rect0 != 0); - - int posIndex = rect0->property("index").toInt(); - QVERIFY(posIndex == 0); - bool isFirst = rect0->property("firstItem").toBool(); - QVERIFY(isFirst == true); - bool isLast = rect0->property("lastItem").toBool(); - QVERIFY(isLast == false); - - QQuickRectangle *rect1 = canvas->rootObject()->findChild("rect1"); - QVERIFY(rect1 != 0); - - posIndex = rect1->property("index").toInt(); - QVERIFY(posIndex == 1); - isFirst = rect1->property("firstItem").toBool(); - QVERIFY(isFirst == false); - isLast = rect1->property("lastItem").toBool(); - QVERIFY(isLast == true); - - row->metaObject()->invokeMethod(row, "createSubRect"); - - QTRY_VERIFY(rect1->property("index").toInt() == 1); - QTRY_VERIFY(rect1->property("firstItem").toBool() == false); - QTRY_VERIFY(rect1->property("lastItem").toBool() == false); - - QQuickRectangle *rect2 = canvas->rootObject()->findChild("rect2"); - QVERIFY(rect2 != 0); - - posIndex = rect2->property("index").toInt(); - QVERIFY(posIndex == 2); - isFirst = rect2->property("firstItem").toBool(); - QVERIFY(isFirst == false); - isLast = rect2->property("lastItem").toBool(); - QVERIFY(isLast == true); - - row->metaObject()->invokeMethod(row, "destroySubRect"); - - QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete); - QCoreApplication::processEvents(); - - QTRY_VERIFY(rect1->property("index").toInt() == 1); - QTRY_VERIFY(rect1->property("firstItem").toBool() == false); - QTRY_VERIFY(rect1->property("lastItem").toBool() == true); - - delete canvas; -} - -QQuickView *tst_qquickpositioners::createView(const QString &filename, bool wait) -{ - QQuickView *canvas = new QQuickView(0); - - canvas->setSource(QUrl::fromLocalFile(filename)); - canvas->show(); - if (wait) - QTest::qWaitForWindowShown(canvas); //It may not relayout until the next frame, so it needs to be drawn - - return canvas; -} - - -QTEST_MAIN(tst_qquickpositioners) - -#include "tst_qquickpositioners.moc" diff --git a/tests/auto/qtquick2/qquickrepeater/data/asyncloader.qml b/tests/auto/qtquick2/qquickrepeater/data/asyncloader.qml deleted file mode 100644 index 82094e2666..0000000000 --- a/tests/auto/qtquick2/qquickrepeater/data/asyncloader.qml +++ /dev/null @@ -1,32 +0,0 @@ -import QtQuick 2.0 - -Item { - width: 360 - height: 480 - - Loader { - asynchronous: true - sourceComponent: viewComponent - } - - Component { - id: viewComponent - Column { - objectName: "container" - Repeater { - id: repeater - objectName: "repeater" - - model: 10 - - delegate: Rectangle { - objectName: "delegate" + index - color: "red" - width: 360 - height: 50 - Text { text: index } - } - } - } - } -} diff --git a/tests/auto/qtquick2/qquickrepeater/data/initparent.qml b/tests/auto/qtquick2/qquickrepeater/data/initparent.qml deleted file mode 100644 index e6571f09d3..0000000000 --- a/tests/auto/qtquick2/qquickrepeater/data/initparent.qml +++ /dev/null @@ -1,12 +0,0 @@ -import QtQuick 2.0 - -Item { - id: root - property Item parentItem: null - Repeater { - model: 1 - Item { - Component.onCompleted: root.parentItem = parent - } - } -} diff --git a/tests/auto/qtquick2/qquickrepeater/data/intmodel.qml b/tests/auto/qtquick2/qquickrepeater/data/intmodel.qml deleted file mode 100644 index 30a650dd52..0000000000 --- a/tests/auto/qtquick2/qquickrepeater/data/intmodel.qml +++ /dev/null @@ -1,29 +0,0 @@ -import QtQuick 2.0 - -Rectangle { - id: container - objectName: "container" - width: 240 - height: 320 - color: "white" - - function checkProperties() { - testObject.error = false; - if (repeater.delegate != comp) { - console.log("delegate property incorrect"); - testObject.error = true; - } - } - - Component { - id: comp - Item{} - } - - Repeater { - id: repeater - objectName: "repeater" - model: testData - delegate: comp - } -} diff --git a/tests/auto/qtquick2/qquickrepeater/data/itemlist.qml b/tests/auto/qtquick2/qquickrepeater/data/itemlist.qml deleted file mode 100644 index 174bfd4d18..0000000000 --- a/tests/auto/qtquick2/qquickrepeater/data/itemlist.qml +++ /dev/null @@ -1,68 +0,0 @@ -// This example demonstrates placing items in a view using -// a VisualItemModel - -import QtQuick 2.0 - -Rectangle { - id: root - color: "lightgray" - width: 240 - height: 320 - property variant itemModel: itemModel1 - - function checkProperties() { - testObject.error = false; - if (testObject.useModel && view.model != root.itemModel) { - console.log("model property incorrect"); - testObject.error = true; - } - } - - function switchModel() { - root.itemModel = itemModel2 - } - - VisualItemModel { - id: itemModel1 - objectName: "itemModel1" - Rectangle { - objectName: "item1" - height: 50; width: 100; color: "#FFFEF0" - Text { objectName: "text1"; text: "index: " + parent.VisualItemModel.index; font.bold: true; anchors.centerIn: parent } - } - Rectangle { - objectName: "item2" - height: 50; width: 100; color: "#F0FFF7" - Text { objectName: "text2"; text: "index: " + parent.VisualItemModel.index; font.bold: true; anchors.centerIn: parent } - } - Rectangle { - objectName: "item3" - height: 50; width: 100; color: "#F4F0FF" - Text { objectName: "text3"; text: "index: " + parent.VisualItemModel.index; font.bold: true; anchors.centerIn: parent } - } - } - - VisualItemModel { - id: itemModel2 - objectName: "itemModel2" - Rectangle { - objectName: "item4" - height: 50; width: 100; color: "#FFFEF0" - Text { objectName: "text4"; text: "index: " + parent.VisualItemModel.index; font.bold: true; anchors.centerIn: parent } - } - Rectangle { - objectName: "item5" - height: 50; width: 100; color: "#F0FFF7" - Text { objectName: "text5"; text: "index: " + parent.VisualItemModel.index; font.bold: true; anchors.centerIn: parent } - } - } - - Column { - objectName: "container" - Repeater { - id: view - objectName: "repeater" - model: testObject.useModel ? root.itemModel : 0 - } - } -} diff --git a/tests/auto/qtquick2/qquickrepeater/data/modelChanged.qml b/tests/auto/qtquick2/qquickrepeater/data/modelChanged.qml deleted file mode 100644 index 23af127e79..0000000000 --- a/tests/auto/qtquick2/qquickrepeater/data/modelChanged.qml +++ /dev/null @@ -1,26 +0,0 @@ -import QtQuick 2.0 - -Column { - Repeater { - id: repeater - objectName: "repeater" - - property int itemsCount - property variant itemsFound: [] - - delegate: Rectangle { - color: "red" - width: (index+1)*50 - height: 50 - } - - onModelChanged: { - repeater.itemsCount = repeater.count - var items = [] - for (var i=0; i -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "../../shared/util.h" -#include "../shared/viewtestutil.h" -#include "../shared/visualtestutil.h" - -using namespace QQuickViewTestUtil; -using namespace QQuickVisualTestUtil; - - -class tst_QQuickRepeater : public QDeclarativeDataTest -{ - Q_OBJECT -public: - tst_QQuickRepeater(); - -private slots: - void numberModel(); - void objectList(); - void stringList(); - void dataModel_adding(); - void dataModel_removing(); - void dataModel_changes(); - void itemModel(); - void resetModel(); - void modelChanged(); - void properties(); - void asynchronous(); - void initParent(); -}; - -class TestObject : public QObject -{ - Q_OBJECT - - Q_PROPERTY(bool error READ error WRITE setError) - Q_PROPERTY(bool useModel READ useModel NOTIFY useModelChanged) - -public: - TestObject() : QObject(), mError(true), mUseModel(false) {} - - bool error() const { return mError; } - void setError(bool err) { mError = err; } - - bool useModel() const { return mUseModel; } - void setUseModel(bool use) { mUseModel = use; emit useModelChanged(); } - -signals: - void useModelChanged(); - -private: - bool mError; - bool mUseModel; -}; - -tst_QQuickRepeater::tst_QQuickRepeater() -{ -} - -void tst_QQuickRepeater::numberModel() -{ - QQuickView *canvas = createView(); - - QDeclarativeContext *ctxt = canvas->rootContext(); - ctxt->setContextProperty("testData", 5); - TestObject *testObject = new TestObject; - ctxt->setContextProperty("testObject", testObject); - - canvas->setSource(testFileUrl("intmodel.qml")); - qApp->processEvents(); - - QQuickRepeater *repeater = findItem(canvas->rootObject(), "repeater"); - QVERIFY(repeater != 0); - QCOMPARE(repeater->parentItem()->childItems().count(), 5+1); - - QVERIFY(!repeater->itemAt(-1)); - for (int i=0; icount(); i++) - QCOMPARE(repeater->itemAt(i), repeater->parentItem()->childItems().at(i)); - QVERIFY(!repeater->itemAt(repeater->count())); - - QMetaObject::invokeMethod(canvas->rootObject(), "checkProperties"); - QVERIFY(testObject->error() == false); - - delete testObject; - delete canvas; -} - -class MyObject : public QObject -{ - Q_OBJECT - Q_PROPERTY(int idx READ idx CONSTANT) -public: - MyObject(int i) : QObject(), m_idx(i) {} - - int idx() const { return m_idx; } - - int m_idx; -}; - -void tst_QQuickRepeater::objectList() -{ - QQuickView *canvas = createView(); - QObjectList data; - for (int i=0; i<100; i++) - data << new MyObject(i); - - QDeclarativeContext *ctxt = canvas->rootContext(); - ctxt->setContextProperty("testData", QVariant::fromValue(data)); - - canvas->setSource(testFileUrl("objlist.qml")); - qApp->processEvents(); - - QQuickRepeater *repeater = findItem(canvas->rootObject(), "repeater"); - QVERIFY(repeater != 0); - QCOMPARE(repeater->property("errors").toInt(), 0);//If this fails either they are out of order or can't find the object's data - QCOMPARE(repeater->property("instantiated").toInt(), 100); - - QVERIFY(!repeater->itemAt(-1)); - for (int i=0; iitemAt(i), repeater->parentItem()->childItems().at(i)); - QVERIFY(!repeater->itemAt(data.count())); - - QSignalSpy addedSpy(repeater, SIGNAL(itemAdded(int,QQuickItem*))); - QSignalSpy removedSpy(repeater, SIGNAL(itemRemoved(int,QQuickItem*))); - ctxt->setContextProperty("testData", QVariant::fromValue(data)); - QCOMPARE(addedSpy.count(), data.count()); - QCOMPARE(removedSpy.count(), data.count()); - - qDeleteAll(data); - delete canvas; -} - -/* -The Repeater element creates children at its own position in its parent's -stacking order. In this test we insert a repeater between two other Text -elements to test this. -*/ -void tst_QQuickRepeater::stringList() -{ - QQuickView *canvas = createView(); - - QStringList data; - data << "One"; - data << "Two"; - data << "Three"; - data << "Four"; - - QDeclarativeContext *ctxt = canvas->rootContext(); - ctxt->setContextProperty("testData", data); - - canvas->setSource(testFileUrl("repeater1.qml")); - qApp->processEvents(); - - QQuickRepeater *repeater = findItem(canvas->rootObject(), "repeater"); - QVERIFY(repeater != 0); - - QQuickItem *container = findItem(canvas->rootObject(), "container"); - QVERIFY(container != 0); - - QCOMPARE(container->childItems().count(), data.count() + 3); - - bool saw_repeater = false; - for (int i = 0; i < container->childItems().count(); ++i) { - - if (i == 0) { - QQuickText *name = qobject_cast(container->childItems().at(i)); - QVERIFY(name != 0); - QCOMPARE(name->text(), QLatin1String("Zero")); - } else if (i == container->childItems().count() - 2) { - // The repeater itself - QQuickRepeater *rep = qobject_cast(container->childItems().at(i)); - QCOMPARE(rep, repeater); - saw_repeater = true; - continue; - } else if (i == container->childItems().count() - 1) { - QQuickText *name = qobject_cast(container->childItems().at(i)); - QVERIFY(name != 0); - QCOMPARE(name->text(), QLatin1String("Last")); - } else { - QQuickText *name = qobject_cast(container->childItems().at(i)); - QVERIFY(name != 0); - QCOMPARE(name->text(), data.at(i-1)); - } - } - QVERIFY(saw_repeater); - - delete canvas; -} - -void tst_QQuickRepeater::dataModel_adding() -{ - QQuickView *canvas = createView(); - QDeclarativeContext *ctxt = canvas->rootContext(); - TestObject *testObject = new TestObject; - ctxt->setContextProperty("testObject", testObject); - - QaimModel testModel; - ctxt->setContextProperty("testData", &testModel); - canvas->setSource(testFileUrl("repeater2.qml")); - qApp->processEvents(); - - QQuickRepeater *repeater = findItem(canvas->rootObject(), "repeater"); - QVERIFY(repeater != 0); - QQuickItem *container = findItem(canvas->rootObject(), "container"); - QVERIFY(container != 0); - - QVERIFY(!repeater->itemAt(0)); - - QSignalSpy countSpy(repeater, SIGNAL(countChanged())); - QSignalSpy addedSpy(repeater, SIGNAL(itemAdded(int,QQuickItem*))); - - // add to empty model - testModel.addItem("two", "2"); - QCOMPARE(repeater->itemAt(0), container->childItems().at(0)); - QCOMPARE(countSpy.count(), 1); countSpy.clear(); - QCOMPARE(addedSpy.count(), 1); - QCOMPARE(addedSpy.at(0).at(0).toInt(), 0); - QCOMPARE(addedSpy.at(0).at(1).value(), container->childItems().at(0)); - addedSpy.clear(); - - // insert at start - testModel.insertItem(0, "one", "1"); - QCOMPARE(repeater->itemAt(0), container->childItems().at(0)); - QCOMPARE(countSpy.count(), 1); countSpy.clear(); - QCOMPARE(addedSpy.count(), 1); - QCOMPARE(addedSpy.at(0).at(0).toInt(), 0); - QCOMPARE(addedSpy.at(0).at(1).value(), container->childItems().at(0)); - addedSpy.clear(); - - // insert at end - testModel.insertItem(2, "four", "4"); - QCOMPARE(repeater->itemAt(2), container->childItems().at(2)); - QCOMPARE(countSpy.count(), 1); countSpy.clear(); - QCOMPARE(addedSpy.count(), 1); - QCOMPARE(addedSpy.at(0).at(0).toInt(), 2); - QCOMPARE(addedSpy.at(0).at(1).value(), container->childItems().at(2)); - addedSpy.clear(); - - // insert in middle - testModel.insertItem(2, "three", "3"); - QCOMPARE(repeater->itemAt(2), container->childItems().at(2)); - QCOMPARE(countSpy.count(), 1); countSpy.clear(); - QCOMPARE(addedSpy.count(), 1); - QCOMPARE(addedSpy.at(0).at(0).toInt(), 2); - QCOMPARE(addedSpy.at(0).at(1).value(), container->childItems().at(2)); - addedSpy.clear(); - - delete testObject; - addedSpy.clear(); - countSpy.clear(); - delete canvas; -} - -void tst_QQuickRepeater::dataModel_removing() -{ - QQuickView *canvas = createView(); - QDeclarativeContext *ctxt = canvas->rootContext(); - TestObject *testObject = new TestObject; - ctxt->setContextProperty("testObject", testObject); - - QaimModel testModel; - testModel.addItem("one", "1"); - testModel.addItem("two", "2"); - testModel.addItem("three", "3"); - testModel.addItem("four", "4"); - testModel.addItem("five", "5"); - - ctxt->setContextProperty("testData", &testModel); - canvas->setSource(testFileUrl("repeater2.qml")); - qApp->processEvents(); - - QQuickRepeater *repeater = findItem(canvas->rootObject(), "repeater"); - QVERIFY(repeater != 0); - QQuickItem *container = findItem(canvas->rootObject(), "container"); - QVERIFY(container != 0); - QCOMPARE(container->childItems().count(), repeater->count()+1); - - QSignalSpy countSpy(repeater, SIGNAL(countChanged())); - QSignalSpy removedSpy(repeater, SIGNAL(itemRemoved(int,QQuickItem*))); - - // remove at start - QQuickItem *item = repeater->itemAt(0); - QCOMPARE(item, container->childItems().at(0)); - - testModel.removeItem(0); - QVERIFY(repeater->itemAt(0) != item); - QCOMPARE(countSpy.count(), 1); countSpy.clear(); - QCOMPARE(removedSpy.count(), 1); - QCOMPARE(removedSpy.at(0).at(0).toInt(), 0); - QCOMPARE(removedSpy.at(0).at(1).value(), item); - removedSpy.clear(); - - // remove at end - int lastIndex = testModel.count()-1; - item = repeater->itemAt(lastIndex); - QCOMPARE(item, container->childItems().at(lastIndex)); - - testModel.removeItem(lastIndex); - QVERIFY(repeater->itemAt(lastIndex) != item); - QCOMPARE(countSpy.count(), 1); countSpy.clear(); - QCOMPARE(removedSpy.count(), 1); - QCOMPARE(removedSpy.at(0).at(0).toInt(), lastIndex); - QCOMPARE(removedSpy.at(0).at(1).value(), item); - removedSpy.clear(); - - // remove from middle - item = repeater->itemAt(1); - QCOMPARE(item, container->childItems().at(1)); - - testModel.removeItem(1); - QVERIFY(repeater->itemAt(lastIndex) != item); - QCOMPARE(countSpy.count(), 1); countSpy.clear(); - QCOMPARE(removedSpy.count(), 1); - QCOMPARE(removedSpy.at(0).at(0).toInt(), 1); - QCOMPARE(removedSpy.at(0).at(1).value(), item); - removedSpy.clear(); - - delete testObject; - delete canvas; -} - -void tst_QQuickRepeater::dataModel_changes() -{ - QQuickView *canvas = createView(); - QDeclarativeContext *ctxt = canvas->rootContext(); - TestObject *testObject = new TestObject; - ctxt->setContextProperty("testObject", testObject); - - QaimModel testModel; - testModel.addItem("one", "1"); - testModel.addItem("two", "2"); - testModel.addItem("three", "3"); - - ctxt->setContextProperty("testData", &testModel); - canvas->setSource(testFileUrl("repeater2.qml")); - qApp->processEvents(); - - QQuickRepeater *repeater = findItem(canvas->rootObject(), "repeater"); - QVERIFY(repeater != 0); - QQuickItem *container = findItem(canvas->rootObject(), "container"); - QVERIFY(container != 0); - QCOMPARE(container->childItems().count(), repeater->count()+1); - - // Check that model changes are propagated - QQuickText *text = findItem(canvas->rootObject(), "myName", 1); - QVERIFY(text); - QCOMPARE(text->text(), QString("two")); - - testModel.modifyItem(1, "Item two", "_2"); - text = findItem(canvas->rootObject(), "myName", 1); - QVERIFY(text); - QCOMPARE(text->text(), QString("Item two")); - - text = findItem(canvas->rootObject(), "myNumber", 1); - QVERIFY(text); - QCOMPARE(text->text(), QString("_2")); - - delete testObject; - delete canvas; -} - -void tst_QQuickRepeater::itemModel() -{ - QQuickView *canvas = createView(); - QDeclarativeContext *ctxt = canvas->rootContext(); - TestObject *testObject = new TestObject; - ctxt->setContextProperty("testObject", testObject); - - canvas->setSource(testFileUrl("itemlist.qml")); - qApp->processEvents(); - - QQuickRepeater *repeater = findItem(canvas->rootObject(), "repeater"); - QVERIFY(repeater != 0); - - QQuickItem *container = findItem(canvas->rootObject(), "container"); - QVERIFY(container != 0); - - QCOMPARE(container->childItems().count(), 1); - - testObject->setUseModel(true); - QMetaObject::invokeMethod(canvas->rootObject(), "checkProperties"); - QVERIFY(testObject->error() == false); - - QCOMPARE(container->childItems().count(), 4); - QVERIFY(qobject_cast(container->childItems().at(0))->objectName() == "item1"); - QVERIFY(qobject_cast(container->childItems().at(1))->objectName() == "item2"); - QVERIFY(qobject_cast(container->childItems().at(2))->objectName() == "item3"); - QVERIFY(container->childItems().at(3) == repeater); - - QMetaObject::invokeMethod(canvas->rootObject(), "switchModel"); - QCOMPARE(container->childItems().count(), 3); - QVERIFY(qobject_cast(container->childItems().at(0))->objectName() == "item4"); - QVERIFY(qobject_cast(container->childItems().at(1))->objectName() == "item5"); - QVERIFY(container->childItems().at(2) == repeater); - - testObject->setUseModel(false); - QCOMPARE(container->childItems().count(), 1); - - delete testObject; - delete canvas; -} - -void tst_QQuickRepeater::resetModel() -{ - QQuickView *canvas = createView(); - - QStringList dataA; - for (int i=0; i<10; i++) - dataA << QString::number(i); - - QDeclarativeContext *ctxt = canvas->rootContext(); - ctxt->setContextProperty("testData", dataA); - canvas->setSource(testFileUrl("repeater1.qml")); - qApp->processEvents(); - QQuickRepeater *repeater = findItem(canvas->rootObject(), "repeater"); - QVERIFY(repeater != 0); - QQuickItem *container = findItem(canvas->rootObject(), "container"); - QVERIFY(container != 0); - - QCOMPARE(repeater->count(), dataA.count()); - for (int i=0; icount(); i++) - QCOMPARE(repeater->itemAt(i), container->childItems().at(i+1)); // +1 to skip first Text object - - QSignalSpy modelChangedSpy(repeater, SIGNAL(modelChanged())); - QSignalSpy countSpy(repeater, SIGNAL(countChanged())); - QSignalSpy addedSpy(repeater, SIGNAL(itemAdded(int,QQuickItem*))); - QSignalSpy removedSpy(repeater, SIGNAL(itemRemoved(int,QQuickItem*))); - - QStringList dataB; - for (int i=0; i<20; i++) - dataB << QString::number(i); - - // reset context property - ctxt->setContextProperty("testData", dataB); - QCOMPARE(repeater->count(), dataB.count()); - - QCOMPARE(modelChangedSpy.count(), 1); - QCOMPARE(countSpy.count(), 1); - QCOMPARE(removedSpy.count(), dataA.count()); - QCOMPARE(addedSpy.count(), dataB.count()); - for (int i=0; i(), repeater->itemAt(i)); - } - modelChangedSpy.clear(); - countSpy.clear(); - removedSpy.clear(); - addedSpy.clear(); - - // reset via setModel() - repeater->setModel(dataA); - QCOMPARE(repeater->count(), dataA.count()); - - QCOMPARE(modelChangedSpy.count(), 1); - QCOMPARE(countSpy.count(), 1); - QCOMPARE(removedSpy.count(), dataB.count()); - QCOMPARE(addedSpy.count(), dataA.count()); - for (int i=0; i(), repeater->itemAt(i)); - } - - modelChangedSpy.clear(); - countSpy.clear(); - removedSpy.clear(); - addedSpy.clear(); - - delete canvas; -} - -// QTBUG-17156 -void tst_QQuickRepeater::modelChanged() -{ - QDeclarativeEngine engine; - QDeclarativeComponent component(&engine, testFileUrl("modelChanged.qml")); - - QQuickItem *rootObject = qobject_cast(component.create()); - QVERIFY(rootObject); - QQuickRepeater *repeater = findItem(rootObject, "repeater"); - QVERIFY(repeater); - - repeater->setModel(4); - QCOMPARE(repeater->count(), 4); - QCOMPARE(repeater->property("itemsCount").toInt(), 4); - QCOMPARE(repeater->property("itemsFound").toList().count(), 4); - - repeater->setModel(10); - QCOMPARE(repeater->count(), 10); - QCOMPARE(repeater->property("itemsCount").toInt(), 10); - QCOMPARE(repeater->property("itemsFound").toList().count(), 10); - - delete rootObject; -} - -void tst_QQuickRepeater::properties() -{ - QDeclarativeEngine engine; - QDeclarativeComponent component(&engine, testFileUrl("properties.qml")); - - QQuickItem *rootObject = qobject_cast(component.create()); - QVERIFY(rootObject); - - QQuickRepeater *repeater = findItem(rootObject, "repeater"); - QVERIFY(repeater); - - QSignalSpy modelSpy(repeater, SIGNAL(modelChanged())); - repeater->setModel(3); - QCOMPARE(modelSpy.count(),1); - repeater->setModel(3); - QCOMPARE(modelSpy.count(),1); - - QSignalSpy delegateSpy(repeater, SIGNAL(delegateChanged())); - - QDeclarativeComponent rectComponent(&engine); - rectComponent.setData("import QtQuick 2.0; Rectangle {}", QUrl::fromLocalFile("")); - - repeater->setDelegate(&rectComponent); - QCOMPARE(delegateSpy.count(),1); - repeater->setDelegate(&rectComponent); - QCOMPARE(delegateSpy.count(),1); - - delete rootObject; -} - -void tst_QQuickRepeater::asynchronous() -{ - QQuickView *canvas = createView(); - canvas->show(); - QDeclarativeIncubationController controller; - canvas->engine()->setIncubationController(&controller); - - canvas->setSource(testFileUrl("asyncloader.qml")); - - QQuickItem *rootObject = qobject_cast(canvas->rootObject()); - QVERIFY(rootObject); - - QQuickItem *container = findItem(rootObject, "container"); - QVERIFY(!container); - while (!container) { - bool b = false; - controller.incubateWhile(&b); - container = findItem(rootObject, "container"); - } - - QQuickRepeater *repeater = 0; - while (!repeater) { - bool b = false; - controller.incubateWhile(&b); - repeater = findItem(rootObject, "repeater"); - } - - // items will be created one at a time - for (int i = 0; i < 10; ++i) { - QString name("delegate"); - name += QString::number(i); - QVERIFY(findItem(container, name) == 0); - QQuickItem *item = 0; - while (!item) { - bool b = false; - controller.incubateWhile(&b); - item = findItem(container, name); - } - } - - { - bool b = true; - controller.incubateWhile(&b); - } - - // verify positioning - for (int i = 0; i < 10; ++i) { - QString name("delegate"); - name += QString::number(i); - QQuickItem *item = findItem(container, name); - QTRY_COMPARE(item->y(), i * 50.0); - } - - delete canvas; -} - -void tst_QQuickRepeater::initParent() -{ - QDeclarativeEngine engine; - QDeclarativeComponent component(&engine, testFileUrl("initparent.qml")); - - QQuickItem *rootObject = qobject_cast(component.create()); - QVERIFY(rootObject); - - QCOMPARE(qvariant_cast(rootObject->property("parentItem")), rootObject); -} - -QTEST_MAIN(tst_QQuickRepeater) - -#include "tst_qquickrepeater.moc" diff --git a/tests/auto/qtquick2/qquickscreen/data/screen.qml b/tests/auto/qtquick2/qquickscreen/data/screen.qml deleted file mode 100644 index 780b22f23d..0000000000 --- a/tests/auto/qtquick2/qquickscreen/data/screen.qml +++ /dev/null @@ -1,11 +0,0 @@ -import QtQuick 2.0 -import QtQuick.Window 2.0 as Window - -Item { - width: 100 - height: 100 - property int w: Window.Screen.width - property int h: Window.Screen.height - property int curOrientation: Window.Screen.orientation - property int priOrientation: Window.Screen.primaryOrientation -} diff --git a/tests/auto/qtquick2/qquickscreen/qquickscreen.pro b/tests/auto/qtquick2/qquickscreen/qquickscreen.pro deleted file mode 100644 index 6d0a5e1650..0000000000 --- a/tests/auto/qtquick2/qquickscreen/qquickscreen.pro +++ /dev/null @@ -1,10 +0,0 @@ -CONFIG += testcase -TARGET = tst_qquickscreen -SOURCES += tst_qquickscreen.cpp - -include (../../shared/util.pri) - -macx:CONFIG -= app_bundle - -CONFIG += parallel_test -QT += core-private gui-private declarative-private testlib quick-private diff --git a/tests/auto/qtquick2/qquickscreen/tst_qquickscreen.cpp b/tests/auto/qtquick2/qquickscreen/tst_qquickscreen.cpp deleted file mode 100644 index bb687f7596..0000000000 --- a/tests/auto/qtquick2/qquickscreen/tst_qquickscreen.cpp +++ /dev/null @@ -1,77 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include -#include -#include -#include -#include -#include "../../shared/util.h" - -class tst_qquickscreen : public QDeclarativeDataTest -{ - Q_OBJECT -private slots: - void basicProperties(); -}; - -void tst_qquickscreen::basicProperties() -{ - QQuickView view; - view.setSource(testFileUrl("screen.qml")); - view.show(); - QTest::qWaitForWindowShown(&view); - - QQuickItem* root = view.rootObject(); - QVERIFY(root); - - QScreen* screen = view.screen(); - QVERIFY(screen); - - QCOMPARE(screen->size().width(), root->property("w").toInt()); - QCOMPARE(screen->size().height(), root->property("h").toInt()); - QCOMPARE(int(screen->orientation()), root->property("curOrientation").toInt()); - QCOMPARE(int(screen->primaryOrientation()), root->property("priOrientation").toInt()); -} - -QTEST_MAIN(tst_qquickscreen) - -#include "tst_qquickscreen.moc" diff --git a/tests/auto/qtquick2/qquickshadereffect/qquickshadereffect.pro b/tests/auto/qtquick2/qquickshadereffect/qquickshadereffect.pro deleted file mode 100644 index de8b247340..0000000000 --- a/tests/auto/qtquick2/qquickshadereffect/qquickshadereffect.pro +++ /dev/null @@ -1,8 +0,0 @@ -CONFIG += testcase -TARGET = tst_qquickshadereffect -SOURCES += tst_qquickshadereffect.cpp - -macx:CONFIG -= app_bundle - -CONFIG += parallel_test -QT += core-private gui-private declarative-private quick-private widgets testlib diff --git a/tests/auto/qtquick2/qquickshadereffect/tst_qquickshadereffect.cpp b/tests/auto/qtquick2/qquickshadereffect/tst_qquickshadereffect.cpp deleted file mode 100644 index 00ae8fc76d..0000000000 --- a/tests/auto/qtquick2/qquickshadereffect/tst_qquickshadereffect.cpp +++ /dev/null @@ -1,275 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include - -#include -#include -#include - -class TestShaderEffect : public QQuickShaderEffect -{ - Q_OBJECT - Q_PROPERTY(QVariant source READ dummyRead NOTIFY dummyChanged) - Q_PROPERTY(QVariant _0aA9zZ READ dummyRead NOTIFY dummyChanged) - Q_PROPERTY(QVariant x86 READ dummyRead NOTIFY dummyChanged) - Q_PROPERTY(QVariant X READ dummyRead NOTIFY dummyChanged) - -public: - QVariant dummyRead() const { return QVariant(); } - bool isConnected(const char *signal) const { return m_signals.contains(signal); } - -protected: - void connectNotify(const char *signal) { m_signals.append(signal); } - void disconnectNotify(const char *signal) { m_signals.removeOne(signal); } - -signals: - void dummyChanged(); - -private: - QList m_signals; -}; - -class tst_qquickshadereffect : public QObject -{ - Q_OBJECT -public: - tst_qquickshadereffect(); - -private slots: - void initTestCase(); - void cleanupTestCase(); - - void lookThroughShaderCode_data(); - void lookThroughShaderCode(); - -private: - enum PresenceFlags { - VertexPresent = 0x01, - TexCoordPresent = 0x02, - MatrixPresent = 0x04, - OpacityPresent = 0x08, - PropertyPresent = 0x10 - }; -}; - -tst_qquickshadereffect::tst_qquickshadereffect() -{ -} - -void tst_qquickshadereffect::initTestCase() -{ -} - -void tst_qquickshadereffect::cleanupTestCase() -{ -} - -void tst_qquickshadereffect::lookThroughShaderCode_data() -{ - QTest::addColumn("vertexShader"); - QTest::addColumn("fragmentShader"); - QTest::addColumn("presenceFlags"); - - QTest::newRow("default") - << QByteArray("uniform highp mat4 qt_Matrix; \n" - "attribute highp vec4 qt_Vertex; \n" - "attribute highp vec2 qt_MultiTexCoord0; \n" - "varying highp vec2 qt_TexCoord0; \n" - "void main() { \n" - " qt_TexCoord0 = qt_MultiTexCoord0; \n" - " gl_Position = qt_Matrix * qt_Vertex; \n" - "}") - << QByteArray("varying highp vec2 qt_TexCoord0; \n" - "uniform sampler2D source; \n" - "uniform lowp float qt_Opacity; \n" - "void main() { \n" - " gl_FragColor = texture2D(source, qt_TexCoord0) * qt_Opacity; \n" - "}") - << (VertexPresent | TexCoordPresent | MatrixPresent | OpacityPresent | PropertyPresent); - - QTest::newRow("empty") - << QByteArray(" ") // one space -- if completely empty, default will be used instead. - << QByteArray(" ") - << 0; - - - QTest::newRow("inside line comments") - << QByteArray("//uniform highp mat4 qt_Matrix;\n" - "attribute highp vec4 qt_Vertex;\n" - "// attribute highp vec2 qt_MultiTexCoord0;") - << QByteArray("uniform int source; // uniform lowp float qt_Opacity;") - << (VertexPresent | PropertyPresent); - - QTest::newRow("inside block comments") - << QByteArray("/*uniform highp mat4 qt_Matrix;\n" - "*/attribute highp vec4 qt_Vertex;\n" - "/*/attribute highp vec2 qt_MultiTexCoord0;//**/") - << QByteArray("/**/uniform int source; /* uniform lowp float qt_Opacity; */") - << (VertexPresent | PropertyPresent); - - QTest::newRow("inside preprocessor directive") - << QByteArray("#define uniform\nhighp mat4 qt_Matrix;\n" - "attribute highp vec4 qt_Vertex;\n" - "#if\\\nattribute highp vec2 qt_MultiTexCoord0;") - << QByteArray("uniform int source;\n" - " # undef uniform lowp float qt_Opacity;") - << (VertexPresent | PropertyPresent); - - - QTest::newRow("line comments between") - << QByteArray("uniform//foo\nhighp//bar\nmat4//baz\nqt_Matrix;\n" - "attribute//\nhighp//\nvec4//\nqt_Vertex;\n" - " //*/ uniform \n attribute //\\ \n highp //// \n vec2 //* \n qt_MultiTexCoord0;") - << QByteArray("uniform// lowp float qt_Opacity;\nsampler2D source;") - << (VertexPresent | TexCoordPresent | MatrixPresent | PropertyPresent); - - QTest::newRow("block comments between") - << QByteArray("uniform/*foo*/highp/*/bar/*/mat4/**//**/qt_Matrix;\n" - "attribute/**/highp/**/vec4/**/qt_Vertex;\n" - " /* * */ attribute /*///*/ highp /****/ vec2 /**/ qt_MultiTexCoord0;") - << QByteArray("uniform/*/ uniform//lowp/*float qt_Opacity;*/sampler2D source;") - << (VertexPresent | TexCoordPresent | MatrixPresent | PropertyPresent); - - QTest::newRow("preprocessor directive between") - << QByteArray("uniform\n#foo\nhighp\n#bar\nmat4\n#baz\\\nblimey\nqt_Matrix;\n" - "attribute\n#\nhighp\n#\nvec4\n#\nqt_Vertex;\n" - " #uniform \n attribute \n # foo \n highp \n # bar \n vec2 \n#baz \n qt_MultiTexCoord0;") - << QByteArray("uniform\n#if lowp float qt_Opacity;\nsampler2D source;") - << (VertexPresent | TexCoordPresent | MatrixPresent | PropertyPresent); - - QTest::newRow("newline between") - << QByteArray("uniform\nhighp\nmat4\nqt_Matrix\n;\n" - "attribute \t\r\n highp \n vec4 \n\n qt_Vertex ;\n" - " \n attribute \n highp \n vec2 \n qt_Multi\nTexCoord0 \n ;") - << QByteArray("uniform\nsampler2D\nsource;" - "uniform lowp float qt_Opacity;") - << (VertexPresent | MatrixPresent | OpacityPresent | PropertyPresent); - - - QTest::newRow("extra characters #1") - << QByteArray("funiform highp mat4 qt_Matrix;\n" - "attribute highp vec4 qt_Vertex_;\n" - "attribute highp vec2 qqt_MultiTexCoord0;") - << QByteArray("uniformm int source;\n" - "uniform4 lowp float qt_Opacity;") - << 0; - - QTest::newRow("extra characters #2") - << QByteArray("attribute phighp vec4 qt_Vertex;\n" - "attribute highpi vec2 qt_MultiTexCoord0;" - "fattribute highp vec4 qt_Vertex;\n" - "attributed highp vec2 qt_MultiTexCoord0;") - << QByteArray(" ") - << 0; - - QTest::newRow("missing characters #1") - << QByteArray("unifor highp mat4 qt_Matrix;\n" - "attribute highp vec4 qt_Vert;\n" - "attribute highp vec2 MultiTexCoord0;") - << QByteArray("niform int source;\n" - "uniform qt_Opacity;") - << 0; - - QTest::newRow("missing characters #2") - << QByteArray("attribute high vec4 qt_Vertex;\n" - "attribute ighp vec2 qt_MultiTexCoord0;" - "tribute highp vec4 qt_Vertex;\n" - "attrib highp vec2 qt_MultiTexCoord0;") - << QByteArray(" ") - << 0; - - QTest::newRow("precision") - << QByteArray("uniform mat4 qt_Matrix;\n" - "attribute kindofhighp vec4 qt_Vertex;\n" - "attribute highp qt_MultiTexCoord0;\n") - << QByteArray("uniform lowp float qt_Opacity;\n" - "uniform mediump float source;\n") - << (MatrixPresent | OpacityPresent | PropertyPresent); - - - QTest::newRow("property name #1") - << QByteArray("uniform highp vec3 _0aA9zZ;") - << QByteArray(" ") - << int(PropertyPresent); - - QTest::newRow("property name #2") - << QByteArray("uniform mediump vec2 x86;") - << QByteArray(" ") - << int(PropertyPresent); - - QTest::newRow("property name #3") - << QByteArray("uniform lowp float X;") - << QByteArray(" ") - << int(PropertyPresent); -} - -void tst_qquickshadereffect::lookThroughShaderCode() -{ - QFETCH(QByteArray, vertexShader); - QFETCH(QByteArray, fragmentShader); - QFETCH(int, presenceFlags); - - TestShaderEffect item; - QVERIFY(!item.isConnected(SIGNAL(dummyChanged()))); // Nothing connected yet. - - QString expected; - if ((presenceFlags & VertexPresent) == 0) - expected += "Warning: Missing reference to \'qt_Vertex\'.\n"; - if ((presenceFlags & TexCoordPresent) == 0) - expected += "Warning: Missing reference to \'qt_MultiTexCoord0\'.\n"; - if ((presenceFlags & MatrixPresent) == 0) - expected += "Warning: Missing reference to \'qt_Matrix\'.\n"; - if ((presenceFlags & OpacityPresent) == 0) - expected += "Warning: Missing reference to \'qt_Opacity\'.\n"; - - item.setVertexShader(vertexShader); - item.setFragmentShader(fragmentShader); - item.ensureCompleted(); - QCOMPARE(item.parseLog(), expected); - - // If the uniform was successfully parsed, the notify signal has been connected to an update slot. - QCOMPARE(item.isConnected(SIGNAL(dummyChanged())), (presenceFlags & PropertyPresent) != 0); -} - -QTEST_MAIN(tst_qquickshadereffect) - -#include "tst_qquickshadereffect.moc" diff --git a/tests/auto/qtquick2/qquickspriteimage/data/advance.qml b/tests/auto/qtquick2/qquickspriteimage/data/advance.qml deleted file mode 100644 index 46a49ca673..0000000000 --- a/tests/auto/qtquick2/qquickspriteimage/data/advance.qml +++ /dev/null @@ -1,66 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -Rectangle { - color: "black" - width: 320 - height: 320 - - SpriteImage { - objectName: "sprite" - sprites: [Sprite { - name: "firstState" - source: "squarefacesprite.png" - frames: 3 - frameSync: true - to: {"secondState":1} - }, Sprite { - name: "secondState" - source: "squarefacesprite.png" - frames: 6 - frameSync: true - } ] - width: 160 - height: 160 - } -} diff --git a/tests/auto/qtquick2/qquickspriteimage/data/basic.qml b/tests/auto/qtquick2/qquickspriteimage/data/basic.qml deleted file mode 100644 index 2f2b1c96fa..0000000000 --- a/tests/auto/qtquick2/qquickspriteimage/data/basic.qml +++ /dev/null @@ -1,60 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -Rectangle { - color: "black" - width: 320 - height: 320 - - SpriteImage { - objectName: "sprite" - sprites: Sprite { - name: "happy" - source: "squarefacesprite.png" - frames: 6 - frameDuration: 120 - } - width: 160 - height: 160 - } -} diff --git a/tests/auto/qtquick2/qquickspriteimage/data/squarefacesprite.png b/tests/auto/qtquick2/qquickspriteimage/data/squarefacesprite.png deleted file mode 100644 index f9a5d5fcce..0000000000 Binary files a/tests/auto/qtquick2/qquickspriteimage/data/squarefacesprite.png and /dev/null differ diff --git a/tests/auto/qtquick2/qquickspriteimage/qquickspriteimage.pro b/tests/auto/qtquick2/qquickspriteimage/qquickspriteimage.pro deleted file mode 100644 index 0d63007c65..0000000000 --- a/tests/auto/qtquick2/qquickspriteimage/qquickspriteimage.pro +++ /dev/null @@ -1,15 +0,0 @@ -CONFIG += testcase -TARGET = tst_qquickspriteimage -SOURCES += tst_qquickspriteimage.cpp - -include (../../shared/util.pri) - -macx:CONFIG -= app_bundle - -testDataFiles.files = data -testDataFiles.path = . -DEPLOYMENT += testDataFiles - -CONFIG += parallel_test - -QT += core-private gui-private declarative-private quick-private network testlib diff --git a/tests/auto/qtquick2/qquickspriteimage/tst_qquickspriteimage.cpp b/tests/auto/qtquick2/qquickspriteimage/tst_qquickspriteimage.cpp deleted file mode 100644 index 37453521fa..0000000000 --- a/tests/auto/qtquick2/qquickspriteimage/tst_qquickspriteimage.cpp +++ /dev/null @@ -1,98 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include -#include "../../shared/util.h" -#include -#include - -class tst_qquickspriteimage : public QDeclarativeDataTest -{ - Q_OBJECT -public: - tst_qquickspriteimage(){} - -private slots: - void test_properties(); - void test_framerateAdvance();//Separate codepath for QQuickSpriteEngine -}; - -void tst_qquickspriteimage::test_properties() -{ - QQuickView *canvas = new QQuickView(0); - - canvas->setSource(testFileUrl("basic.qml")); - canvas->show(); - QTest::qWaitForWindowShown(canvas); - - QVERIFY(canvas->rootObject()); - QQuickSpriteImage* sprite = canvas->rootObject()->findChild("sprite"); - QVERIFY(sprite); - - QVERIFY(sprite->running()); - QVERIFY(sprite->interpolate()); - - sprite->setRunning(false); - QVERIFY(!sprite->running()); - sprite->setInterpolate(false); - QVERIFY(!sprite->interpolate()); - - delete canvas; -} - -void tst_qquickspriteimage::test_framerateAdvance() -{ - QQuickView *canvas = new QQuickView(0); - - canvas->setSource(testFileUrl("advance.qml")); - canvas->show(); - QTest::qWaitForWindowShown(canvas); - - QVERIFY(canvas->rootObject()); - QQuickSpriteImage* sprite = canvas->rootObject()->findChild("sprite"); - QVERIFY(sprite); - - QTRY_COMPARE(sprite->currentSprite(), QLatin1String("secondState")); - delete canvas; -} - -QTEST_MAIN(tst_qquickspriteimage) - -#include "tst_qquickspriteimage.moc" diff --git a/tests/auto/qtquick2/qquicktext/data/alignments.qml b/tests/auto/qtquick2/qquicktext/data/alignments.qml deleted file mode 100644 index 9798d9c736..0000000000 --- a/tests/auto/qtquick2/qquicktext/data/alignments.qml +++ /dev/null @@ -1,41 +0,0 @@ -import QtQuick 2.0 - -Rectangle { - id: top - width: 70; height: 70; - - property alias horizontalAlignment: t.horizontalAlignment - property alias verticalAlignment: t.verticalAlignment - property alias wrapMode: t.wrapMode - property alias running: timer.running - property string txt: "Test" - - Rectangle { - anchors.centerIn: parent - width: 40 - height: 40 - color: "green" - - Text { - id: t - - anchors.fill: parent - horizontalAlignment: Text.AlignRight - verticalAlignment: Text.AlignBottom - wrapMode: Text.WordWrap - text: top.txt - } - Timer { - id: timer - - interval: 1 - running: true - repeat: true - onTriggered: { - top.txt = top.txt + "
      more " + top.txt.length; - if (top.txt.length > 50) - running = false - } - } - } -} diff --git a/tests/auto/qtquick2/qquicktext/data/alignments_cb.png b/tests/auto/qtquick2/qquicktext/data/alignments_cb.png deleted file mode 100644 index cf6199a418..0000000000 Binary files a/tests/auto/qtquick2/qquicktext/data/alignments_cb.png and /dev/null differ diff --git a/tests/auto/qtquick2/qquicktext/data/alignments_cc.png b/tests/auto/qtquick2/qquicktext/data/alignments_cc.png deleted file mode 100644 index f81ccb4238..0000000000 Binary files a/tests/auto/qtquick2/qquicktext/data/alignments_cc.png and /dev/null differ diff --git a/tests/auto/qtquick2/qquicktext/data/alignments_ct.png b/tests/auto/qtquick2/qquicktext/data/alignments_ct.png deleted file mode 100644 index 9ba64125d5..0000000000 Binary files a/tests/auto/qtquick2/qquicktext/data/alignments_ct.png and /dev/null differ diff --git a/tests/auto/qtquick2/qquicktext/data/alignments_lb.png b/tests/auto/qtquick2/qquicktext/data/alignments_lb.png deleted file mode 100644 index 1b50a81f3d..0000000000 Binary files a/tests/auto/qtquick2/qquicktext/data/alignments_lb.png and /dev/null differ diff --git a/tests/auto/qtquick2/qquicktext/data/alignments_lc.png b/tests/auto/qtquick2/qquicktext/data/alignments_lc.png deleted file mode 100644 index f041b868f8..0000000000 Binary files a/tests/auto/qtquick2/qquicktext/data/alignments_lc.png and /dev/null differ diff --git a/tests/auto/qtquick2/qquicktext/data/alignments_lt.png b/tests/auto/qtquick2/qquicktext/data/alignments_lt.png deleted file mode 100644 index c75e0d158e..0000000000 Binary files a/tests/auto/qtquick2/qquicktext/data/alignments_lt.png and /dev/null differ diff --git a/tests/auto/qtquick2/qquicktext/data/alignments_rb.png b/tests/auto/qtquick2/qquicktext/data/alignments_rb.png deleted file mode 100644 index b06a5da715..0000000000 Binary files a/tests/auto/qtquick2/qquicktext/data/alignments_rb.png and /dev/null differ diff --git a/tests/auto/qtquick2/qquicktext/data/alignments_rc.png b/tests/auto/qtquick2/qquicktext/data/alignments_rc.png deleted file mode 100644 index e468857cd0..0000000000 Binary files a/tests/auto/qtquick2/qquicktext/data/alignments_rc.png and /dev/null differ diff --git a/tests/auto/qtquick2/qquicktext/data/alignments_rt.png b/tests/auto/qtquick2/qquicktext/data/alignments_rt.png deleted file mode 100644 index 576715ffce..0000000000 Binary files a/tests/auto/qtquick2/qquicktext/data/alignments_rt.png and /dev/null differ diff --git a/tests/auto/qtquick2/qquicktext/data/embeddedImagesLocal.qml b/tests/auto/qtquick2/qquicktext/data/embeddedImagesLocal.qml deleted file mode 100644 index 74b2ab817a..0000000000 --- a/tests/auto/qtquick2/qquicktext/data/embeddedImagesLocal.qml +++ /dev/null @@ -1,6 +0,0 @@ -import QtQuick 2.0 - -Text { - textFormat: Text.RichText - text: "" -} diff --git a/tests/auto/qtquick2/qquicktext/data/embeddedImagesLocalError.qml b/tests/auto/qtquick2/qquicktext/data/embeddedImagesLocalError.qml deleted file mode 100644 index a2f7e0c89f..0000000000 --- a/tests/auto/qtquick2/qquicktext/data/embeddedImagesLocalError.qml +++ /dev/null @@ -1,6 +0,0 @@ -import QtQuick 2.0 - -Text { - textFormat: Text.RichText - text: "" -} diff --git a/tests/auto/qtquick2/qquicktext/data/embeddedImagesLocalRelative.qml b/tests/auto/qtquick2/qquicktext/data/embeddedImagesLocalRelative.qml deleted file mode 100644 index 8de7364d08..0000000000 --- a/tests/auto/qtquick2/qquicktext/data/embeddedImagesLocalRelative.qml +++ /dev/null @@ -1,7 +0,0 @@ -import QtQuick 2.0 - -Text { - textFormat: Text.RichText - text: "" - baseUrl: "http/" -} diff --git a/tests/auto/qtquick2/qquicktext/data/embeddedImagesRemote.qml b/tests/auto/qtquick2/qquicktext/data/embeddedImagesRemote.qml deleted file mode 100644 index 702633c538..0000000000 --- a/tests/auto/qtquick2/qquicktext/data/embeddedImagesRemote.qml +++ /dev/null @@ -1,6 +0,0 @@ -import QtQuick 2.0 - -Text { - textFormat: Text.RichText - text: "" -} diff --git a/tests/auto/qtquick2/qquicktext/data/embeddedImagesRemoteError.qml b/tests/auto/qtquick2/qquicktext/data/embeddedImagesRemoteError.qml deleted file mode 100644 index 5762f3e47d..0000000000 --- a/tests/auto/qtquick2/qquicktext/data/embeddedImagesRemoteError.qml +++ /dev/null @@ -1,6 +0,0 @@ -import QtQuick 2.0 - -Text { - textFormat: Text.RichText - text: "" -} diff --git a/tests/auto/qtquick2/qquicktext/data/embeddedImagesRemoteRelative.qml b/tests/auto/qtquick2/qquicktext/data/embeddedImagesRemoteRelative.qml deleted file mode 100644 index cee19740f9..0000000000 --- a/tests/auto/qtquick2/qquicktext/data/embeddedImagesRemoteRelative.qml +++ /dev/null @@ -1,7 +0,0 @@ -import QtQuick 2.0 - -Text { - textFormat: Text.RichText - text: "" - baseUrl: "http://127.0.0.1:14453/text.html" -} diff --git a/tests/auto/qtquick2/qquicktext/data/fontSizeMode.qml b/tests/auto/qtquick2/qquicktext/data/fontSizeMode.qml deleted file mode 100644 index 20f7535365..0000000000 --- a/tests/auto/qtquick2/qquicktext/data/fontSizeMode.qml +++ /dev/null @@ -1,24 +0,0 @@ -import QtQuick 2.0 - -Item { - width: 300 - height: 200 - - Rectangle { - anchors.fill: myText - border.width: 1 - } - - Text { - id: myText - objectName: "myText" - width: 250 - height: 41 - minimumPointSize: 8 - minimumPixelSize: 8 - font.pixelSize: 30 - font.family: "Helvetica" - } - - TextInput { focus: true; objectName: "input" } -} diff --git a/tests/auto/qtquick2/qquicktext/data/horizontalAlignment_RightToLeft.qml b/tests/auto/qtquick2/qquicktext/data/horizontalAlignment_RightToLeft.qml deleted file mode 100644 index 5ba4d35684..0000000000 --- a/tests/auto/qtquick2/qquicktext/data/horizontalAlignment_RightToLeft.qml +++ /dev/null @@ -1,23 +0,0 @@ -import QtQuick 2.0 - -Rectangle { - id: top - width: 200; height: 70; - - property alias horizontalAlignment: text.horizontalAlignment - property string text: "اختبا" - - Rectangle { - anchors.centerIn: parent - width: 180 - height: 20 - color: "green" - - Text { - id: text - objectName: "text" - anchors.fill: parent - text: top.text - } - } -} diff --git a/tests/auto/qtquick2/qquicktext/data/http/exists.png b/tests/auto/qtquick2/qquicktext/data/http/exists.png deleted file mode 100644 index 399bd0b1d9..0000000000 Binary files a/tests/auto/qtquick2/qquicktext/data/http/exists.png and /dev/null differ diff --git a/tests/auto/qtquick2/qquicktext/data/images/face-sad.png b/tests/auto/qtquick2/qquicktext/data/images/face-sad.png deleted file mode 100644 index 24188b7985..0000000000 Binary files a/tests/auto/qtquick2/qquicktext/data/images/face-sad.png and /dev/null differ diff --git a/tests/auto/qtquick2/qquicktext/data/images/heart200.png b/tests/auto/qtquick2/qquicktext/data/images/heart200.png deleted file mode 100644 index cedd3ea608..0000000000 Binary files a/tests/auto/qtquick2/qquicktext/data/images/heart200.png and /dev/null differ diff --git a/tests/auto/qtquick2/qquicktext/data/images/starfish_2.png b/tests/auto/qtquick2/qquicktext/data/images/starfish_2.png deleted file mode 100644 index 132c20ffd0..0000000000 Binary files a/tests/auto/qtquick2/qquicktext/data/images/starfish_2.png and /dev/null differ diff --git a/tests/auto/qtquick2/qquicktext/data/imgTagsElide.qml b/tests/auto/qtquick2/qquicktext/data/imgTagsElide.qml deleted file mode 100644 index fbd64cc5bf..0000000000 --- a/tests/auto/qtquick2/qquicktext/data/imgTagsElide.qml +++ /dev/null @@ -1,24 +0,0 @@ -import QtQuick 2.0 - -Item { - width: 300 - height: 200 - - Text { - id: myText - objectName: "myText" - elide: Text.ElideRight - maximumLineCount: 2 - width: 200 - wrapMode: Text.WordWrap - text: "This is a sad face aligned to the top. Lorem ipsum dolor sit amet. Nulla sed turpis risus. Integer sit amet odio quis mauris varius venenatisLorem ipsum dolor sit amet. Nulla sed turpis risus. Integer sit amet odio quis mauris varius venenatis. Lorem ipsum dolor sit amet. Nulla sed turpis risus.Lorem ipsum dolor sit amet. Nulla sed turpis risus. Lorem ipsum dolor sit amet. Nulla sed turpis risus.Lorem ipsum dolor sit amet. Nulla sed turpis risus." - } - - MouseArea { - anchors.fill: parent - onClicked: myText.width = 400 - - } -} - - diff --git a/tests/auto/qtquick2/qquicktext/data/imgTagsUpdates.qml b/tests/auto/qtquick2/qquicktext/data/imgTagsUpdates.qml deleted file mode 100644 index baf5113e52..0000000000 --- a/tests/auto/qtquick2/qquicktext/data/imgTagsUpdates.qml +++ /dev/null @@ -1,12 +0,0 @@ -import QtQuick 2.0 - -Rectangle { - id: main - width: 300; height: 400 - - Text { - id: myText - objectName: "myText" - text: "" - } -} diff --git a/tests/auto/qtquick2/qquicktext/data/lineCount.qml b/tests/auto/qtquick2/qquicktext/data/lineCount.qml deleted file mode 100644 index b672863684..0000000000 --- a/tests/auto/qtquick2/qquicktext/data/lineCount.qml +++ /dev/null @@ -1,15 +0,0 @@ -import QtQuick 2.0 - -Item { - width: 200 - height: 200 - - Text { - id: myText - objectName: "myText" - width: 200 - wrapMode: Text.WordWrap - maximumLineCount: undefined - text: "Testing that maximumLines, visibleLines, and totalLines works properly in the autotests. The quick brown fox jumped over the lazy anything with the letter 'g'." - } -} diff --git a/tests/auto/qtquick2/qquicktext/data/lineHeight.qml b/tests/auto/qtquick2/qquicktext/data/lineHeight.qml deleted file mode 100644 index c1f337aa05..0000000000 --- a/tests/auto/qtquick2/qquicktext/data/lineHeight.qml +++ /dev/null @@ -1,15 +0,0 @@ -import QtQuick 2.0 - -Item { - width: 200 - height: 200 - - Text { - id: myText - objectName: "myText" - width: 200 - wrapMode: Text.WordWrap - font.pixelSize: 13 - text: "Lorem ipsum sit amet, consectetur adipiscing elit. Integer felis nisl, varius in pretium nec, venenatis non erat. Proin lobortis interdum dictum." - } -} diff --git a/tests/auto/qtquick2/qquicktext/data/lineLayout.qml b/tests/auto/qtquick2/qquicktext/data/lineLayout.qml deleted file mode 100644 index cb2474791e..0000000000 --- a/tests/auto/qtquick2/qquicktext/data/lineLayout.qml +++ /dev/null @@ -1,35 +0,0 @@ -import QtQuick 2.0 - -Rectangle { - id: main - width: 800; height: 600 - - property real off: 0 - - Text { - id: myText - objectName: "myText" - wrapMode: Text.WordWrap - font.pixelSize: 14 - textFormat: Text.StyledText - focus: true - - text: "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer at ante dui. Sed eu egestas est. -

      Maecenas nec libero leo. Sed ac leo eget ipsum ultricies viverra sit amet eu orci. Praesent et tortor risus, viverra accumsan sapien. Sed faucibus eleifend lectus, sed euismod urna porta eu. Aenean ultricies lectus ut orci dictum quis convallis nisi ultrices. Nunc elit mi, iaculis a porttitor rutrum, venenatis malesuada nisi. Suspendisse turpis quam, euismod non imperdiet et, rutrum nec ligula. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam semper tristique metus eu sodales. Integer eget risus ipsum. Quisque ut risus ut nulla tristique volutpat at sit amet nisl. Aliquam pulvinar auctor diam nec bibendum.

      Quisque luctus sapien id arcu volutpat pharetra. Praesent pretium imperdiet euismod. Integer fringilla rhoncus condimentum. Quisque sit amet ornare nulla. Cras sapien augue, sagittis a dictum id, suscipit et nunc. Cras vitae augue in enim elementum venenatis sed nec risus. Sed nisi quam, mollis quis auctor ac, vestibulum in neque. Vivamus eu justo risus. Suspendisse vel mollis est. Vestibulum gravida interdum mi, in molestie neque gravida in. Donec nibh odio, mattis facilisis vulputate et, scelerisque ut felis. Sed ornare eros nec odio aliquam eu varius augue adipiscing. Vivamus sit amet massa dapibus sapien pulvinar consectetur a sit amet felis. Cras non mi id libero dictum iaculis id dignissim eros. Praesent eget enim dui, sed bibendum neque. Ut interdum nisl id leo malesuada ornare. Pellentesque id nisl eu odio volutpat posuere et at massa. Pellentesque nec lorem justo. Integer sem urna, pharetra sed sagittis vitae, condimentum ac felis. Ut vitae sapien ac tortor adipiscing pharetra. Cras tristique urna tempus ante volutpat eleifend non eu ligula. Mauris sodales nisl et lorem tristique sodales. Mauris arcu orci, vehicula semper cursus ac, dapibus ut mi." - - onLineLaidOut: { - line.width = line.number * 15 - if (line.number === 30 || line.number === 60) { - main.off = line.y - } - if (line.number >= 30) { - line.x = line.width + 30 - line.y -= main.off - } - if (line.number >= 60) { - line.x = line.width * 2 + 60 - line.height = 20 - } - } - } -} diff --git a/tests/auto/qtquick2/qquicktext/data/multilengthStrings.qml b/tests/auto/qtquick2/qquicktext/data/multilengthStrings.qml deleted file mode 100644 index d26576eacd..0000000000 --- a/tests/auto/qtquick2/qquicktext/data/multilengthStrings.qml +++ /dev/null @@ -1,14 +0,0 @@ -import QtQuick 2.0 - -Item { - width: 300 - height: 200 - - Text { - id: myText - objectName: "myText" - width: 100 - font.pixelSize: 15 - font.family: "Helvetica" - } -} diff --git a/tests/auto/qtquick2/qquicktext/data/multilengthStringsWrapped.qml b/tests/auto/qtquick2/qquicktext/data/multilengthStringsWrapped.qml deleted file mode 100644 index 0da9bc353a..0000000000 --- a/tests/auto/qtquick2/qquicktext/data/multilengthStringsWrapped.qml +++ /dev/null @@ -1,16 +0,0 @@ -import QtQuick 2.0 - -Item { - width: 300 - height: 200 - - Text { - id: myText - objectName: "myText" - width: 100 - height: 36 - font.pixelSize: 15 - font.family: "Helvetica" - wrapMode: Text.Wrap - } -} diff --git a/tests/auto/qtquick2/qquicktext/data/multilineelide.qml b/tests/auto/qtquick2/qquicktext/data/multilineelide.qml deleted file mode 100644 index f3bb65775b..0000000000 --- a/tests/auto/qtquick2/qquicktext/data/multilineelide.qml +++ /dev/null @@ -1,10 +0,0 @@ -import QtQuick 2.0 - -Text { - width: 200; height: 200 - wrapMode: Text.WordWrap - elide: Text.ElideRight - maximumLineCount: 3 - text: "the quick brown fox jumped over the lazy dog the quick brown fox jumped over the lazy dog the quick brown fox jumped over the lazy dog" -} - diff --git a/tests/auto/qtquick2/qquicktext/data/qtbug_14734.qml b/tests/auto/qtquick2/qquicktext/data/qtbug_14734.qml deleted file mode 100644 index e71a798421..0000000000 --- a/tests/auto/qtquick2/qquicktext/data/qtbug_14734.qml +++ /dev/null @@ -1,10 +0,0 @@ -import QtQuick 2.0 - -Rectangle { - width: 640 - height: 480 - - Text { - text: "í " - } -} diff --git a/tests/auto/qtquick2/qquicktext/data/rotated.qml b/tests/auto/qtquick2/qquicktext/data/rotated.qml deleted file mode 100644 index fecf64b249..0000000000 --- a/tests/auto/qtquick2/qquicktext/data/rotated.qml +++ /dev/null @@ -1,18 +0,0 @@ -import QtQuick 2.0 - -Rectangle { - width : 200 - height : 100 - - Text { - objectName: "text" - x: 20 - y: 20 - height : 20 - width : 80 - text : "Something" - rotation : 30 - transformOrigin : Item.TopLeft - } -} - diff --git a/tests/auto/qtquick2/qquicktext/qquicktext.pro b/tests/auto/qtquick2/qquicktext/qquicktext.pro deleted file mode 100644 index b483bebc61..0000000000 --- a/tests/auto/qtquick2/qquicktext/qquicktext.pro +++ /dev/null @@ -1,19 +0,0 @@ -CONFIG += testcase -TARGET = tst_qquicktext -macx:CONFIG -= app_bundle - -SOURCES += tst_qquicktext.cpp - -INCLUDEPATH += ../../shared/ -HEADERS += ../../shared/testhttpserver.h -SOURCES += ../../shared/testhttpserver.cpp - -include (../../shared/util.pri) - -testDataFiles.files = data -testDataFiles.path = . -DEPLOYMENT += testDataFiles - -CONFIG += parallel_test - -QT += core-private gui-private v8-private declarative-private quick-private widgets-private opengl-private network testlib diff --git a/tests/auto/qtquick2/qquicktext/tst_qquicktext.cpp b/tests/auto/qtquick2/qquicktext/tst_qquicktext.cpp deleted file mode 100644 index d1c0f765d0..0000000000 --- a/tests/auto/qtquick2/qquicktext/tst_qquicktext.cpp +++ /dev/null @@ -1,2432 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "../../shared/util.h" -#include "testhttpserver.h" - -DEFINE_BOOL_CONFIG_OPTION(qmlDisableDistanceField, QML_DISABLE_DISTANCEFIELD) - -class tst_qquicktext : public QDeclarativeDataTest -{ - Q_OBJECT -public: - tst_qquicktext(); - -private slots: - void text(); - void width(); - void wrap(); - void elide(); - void multilineElide(); - void textFormat(); - - void alignments_data(); - void alignments(); - - void baseUrl(); - void embeddedImages_data(); - void embeddedImages(); - - void lineCount(); - void lineHeight(); - - // ### these tests may be trivial - void horizontalAlignment(); - void horizontalAlignment_RightToLeft(); - void verticalAlignment(); - void font(); - void style(); - void color(); - void smooth(); - - // QDeclarativeFontValueType - void weight(); - void underline(); - void overline(); - void strikeout(); - void capitalization(); - void letterSpacing(); - void wordSpacing(); - - void clickLink(); - - void implicitSize_data(); - void implicitSize(); - void contentSize(); - - void lineLaidOut(); - - void imgTagsBaseUrl_data(); - void imgTagsBaseUrl(); - void imgTagsAlign_data(); - void imgTagsAlign(); - void imgTagsMultipleImages(); - void imgTagsElide(); - void imgTagsUpdates(); - void imgTagsError(); - void fontSizeMode_data(); - void fontSizeMode(); - void fontSizeModeMultiline_data(); - void fontSizeModeMultiline(); - void multilengthStrings_data(); - void multilengthStrings(); - -private: - QStringList standard; - QStringList richText; - - QStringList horizontalAlignmentmentStrings; - QStringList verticalAlignmentmentStrings; - - QList verticalAlignmentments; - QList horizontalAlignmentments; - - QStringList styleStrings; - QList styles; - - QStringList colorStrings; - - QDeclarativeEngine engine; - - QQuickView *createView(const QString &filename); -}; - -tst_qquicktext::tst_qquicktext() -{ - standard << "the quick brown fox jumped over the lazy dog" - << "the quick brown fox\n jumped over the lazy dog"; - - richText << "the quick brown fox jumped over the lazy dog" - << "the quick brown fox
      jumped over the lazy dog
      "; - - horizontalAlignmentmentStrings << "AlignLeft" - << "AlignRight" - << "AlignHCenter"; - - verticalAlignmentmentStrings << "AlignTop" - << "AlignBottom" - << "AlignVCenter"; - - horizontalAlignmentments << Qt::AlignLeft - << Qt::AlignRight - << Qt::AlignHCenter; - - verticalAlignmentments << Qt::AlignTop - << Qt::AlignBottom - << Qt::AlignVCenter; - - styleStrings << "Normal" - << "Outline" - << "Raised" - << "Sunken"; - - styles << QQuickText::Normal - << QQuickText::Outline - << QQuickText::Raised - << QQuickText::Sunken; - - colorStrings << "aliceblue" - << "antiquewhite" - << "aqua" - << "darkkhaki" - << "darkolivegreen" - << "dimgray" - << "palevioletred" - << "lightsteelblue" - << "#000000" - << "#AAAAAA" - << "#FFFFFF" - << "#2AC05F"; - // - // need a different test to do alpha channel test - // << "#AA0011DD" - // << "#00F16B11"; - // -} - -QQuickView *tst_qquicktext::createView(const QString &filename) -{ - QQuickView *canvas = new QQuickView(0); - - canvas->setSource(QUrl::fromLocalFile(filename)); - return canvas; -} - -void tst_qquicktext::text() -{ - { - QDeclarativeComponent textComponent(&engine); - textComponent.setData("import QtQuick 2.0\nText { text: \"\" }", QUrl::fromLocalFile("")); - QQuickText *textObject = qobject_cast(textComponent.create()); - - QVERIFY(textObject != 0); - QCOMPARE(textObject->text(), QString("")); - QVERIFY(textObject->width() == 0); - - delete textObject; - } - - for (int i = 0; i < standard.size(); i++) - { - QString componentStr = "import QtQuick 2.0\nText { text: \"" + standard.at(i) + "\" }"; - QDeclarativeComponent textComponent(&engine); - textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); - - QQuickText *textObject = qobject_cast(textComponent.create()); - - QVERIFY(textObject != 0); - QCOMPARE(textObject->text(), standard.at(i)); - QVERIFY(textObject->width() > 0); - - delete textObject; - } - - for (int i = 0; i < richText.size(); i++) - { - QString componentStr = "import QtQuick 2.0\nText { text: \"" + richText.at(i) + "\" }"; - QDeclarativeComponent textComponent(&engine); - textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); - QQuickText *textObject = qobject_cast(textComponent.create()); - - QVERIFY(textObject != 0); - QString expected = richText.at(i); - QCOMPARE(textObject->text(), expected.replace("\\\"", "\"")); - QVERIFY(textObject->width() > 0); - - delete textObject; - } -} - -void tst_qquicktext::width() -{ - // uses Font metrics to find the width for standard and document to find the width for rich - { - QDeclarativeComponent textComponent(&engine); - textComponent.setData("import QtQuick 2.0\nText { text: \"\" }", QUrl::fromLocalFile("")); - QQuickText *textObject = qobject_cast(textComponent.create()); - - QVERIFY(textObject != 0); - QCOMPARE(textObject->width(), 0.); - - delete textObject; - } - - bool requiresUnhintedMetrics = !qmlDisableDistanceField(); - - for (int i = 0; i < standard.size(); i++) - { - QVERIFY(!Qt::mightBeRichText(standard.at(i))); // self-test - - QFont f; - qreal metricWidth = 0.0; - - if (requiresUnhintedMetrics) { - QString s = standard.at(i); - s.replace(QLatin1Char('\n'), QChar::LineSeparator); - - QTextLayout layout(s); - layout.setFlags(Qt::TextExpandTabs | Qt::TextShowMnemonic); - { - QTextOption option; - option.setUseDesignMetrics(true); - layout.setTextOption(option); - } - - layout.beginLayout(); - forever { - QTextLine line = layout.createLine(); - if (!line.isValid()) - break; - } - - layout.endLayout(); - - metricWidth = qCeil(layout.boundingRect().width()); - } else { - QFontMetricsF fm(f); - qreal metricWidth = fm.size(Qt::TextExpandTabs && Qt::TextShowMnemonic, standard.at(i)).width(); - metricWidth = qCeil(metricWidth); - } - - QString componentStr = "import QtQuick 2.0\nText { text: \"" + standard.at(i) + "\" }"; - QDeclarativeComponent textComponent(&engine); - textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); - QQuickText *textObject = qobject_cast(textComponent.create()); - - QVERIFY(textObject != 0); - QVERIFY(textObject->boundingRect().width() > 0); - QCOMPARE(textObject->width(), qreal(metricWidth)); - QVERIFY(textObject->textFormat() == QQuickText::AutoText); // setting text doesn't change format - - delete textObject; - } - - for (int i = 0; i < richText.size(); i++) - { - QVERIFY(Qt::mightBeRichText(richText.at(i))); // self-test - - QString componentStr = "import QtQuick 2.0\nText { text: \"" + richText.at(i) + "\"; textFormat: Text.RichText }"; - QDeclarativeComponent textComponent(&engine); - textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); - QQuickText *textObject = qobject_cast(textComponent.create()); - QVERIFY(textObject != 0); - - QQuickTextPrivate *textPrivate = QQuickTextPrivate::get(textObject); - QVERIFY(textPrivate != 0); - - QTextDocument *doc = textPrivate->textDocument(); - QVERIFY(doc != 0); - - QCOMPARE(int(textObject->width()), int(doc->idealWidth())); - QVERIFY(textObject->textFormat() == QQuickText::RichText); - - delete textObject; - } -} - -void tst_qquicktext::wrap() -{ - int textHeight = 0; - // for specified width and wrap set true - { - QDeclarativeComponent textComponent(&engine); - textComponent.setData("import QtQuick 2.0\nText { text: \"Hello\"; wrapMode: Text.WordWrap; width: 300 }", QUrl::fromLocalFile("")); - QQuickText *textObject = qobject_cast(textComponent.create()); - textHeight = textObject->height(); - - QVERIFY(textObject != 0); - QVERIFY(textObject->wrapMode() == QQuickText::WordWrap); - QCOMPARE(textObject->width(), 300.); - - delete textObject; - } - - for (int i = 0; i < standard.size(); i++) - { - QString componentStr = "import QtQuick 2.0\nText { wrapMode: Text.WordWrap; width: 30; text: \"" + standard.at(i) + "\" }"; - QDeclarativeComponent textComponent(&engine); - textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); - QQuickText *textObject = qobject_cast(textComponent.create()); - - QVERIFY(textObject != 0); - QCOMPARE(textObject->width(), 30.); - QVERIFY(textObject->height() > textHeight); - - int oldHeight = textObject->height(); - textObject->setWidth(100); - QVERIFY(textObject->height() < oldHeight); - - delete textObject; - } - - for (int i = 0; i < richText.size(); i++) - { - QString componentStr = "import QtQuick 2.0\nText { wrapMode: Text.WordWrap; width: 30; text: \"" + richText.at(i) + "\" }"; - QDeclarativeComponent textComponent(&engine); - textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); - QQuickText *textObject = qobject_cast(textComponent.create()); - - QVERIFY(textObject != 0); - QCOMPARE(textObject->width(), 30.); - QVERIFY(textObject->height() > textHeight); - - qreal oldHeight = textObject->height(); - textObject->setWidth(100); - QVERIFY(textObject->height() < oldHeight); - - delete textObject; - } - - // richtext again with a fixed height - for (int i = 0; i < richText.size(); i++) - { - QString componentStr = "import QtQuick 2.0\nText { wrapMode: Text.WordWrap; width: 30; height: 50; text: \"" + richText.at(i) + "\" }"; - QDeclarativeComponent textComponent(&engine); - textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); - QQuickText *textObject = qobject_cast(textComponent.create()); - - QVERIFY(textObject != 0); - QCOMPARE(textObject->width(), 30.); - QVERIFY(textObject->implicitHeight() > textHeight); - - qreal oldHeight = textObject->implicitHeight(); - textObject->setWidth(100); - QVERIFY(textObject->implicitHeight() < oldHeight); - - delete textObject; - } -} - -void tst_qquicktext::elide() -{ - for (QQuickText::TextElideMode m = QQuickText::ElideLeft; m<=QQuickText::ElideNone; m=QQuickText::TextElideMode(int(m)+1)) { - const char* elidename[]={"ElideLeft", "ElideRight", "ElideMiddle", "ElideNone"}; - QString elide = "elide: Text." + QString(elidename[int(m)]) + ";"; - - // XXX Poor coverage. - - { - QDeclarativeComponent textComponent(&engine); - textComponent.setData(("import QtQuick 2.0\nText { text: \"\"; "+elide+" width: 100 }").toLatin1(), QUrl::fromLocalFile("")); - QQuickText *textObject = qobject_cast(textComponent.create()); - - QCOMPARE(textObject->elideMode(), m); - QCOMPARE(textObject->width(), 100.); - - delete textObject; - } - - for (int i = 0; i < standard.size(); i++) - { - QString componentStr = "import QtQuick 2.0\nText { "+elide+" width: 100; text: \"" + standard.at(i) + "\" }"; - QDeclarativeComponent textComponent(&engine); - textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); - QQuickText *textObject = qobject_cast(textComponent.create()); - - QCOMPARE(textObject->elideMode(), m); - QCOMPARE(textObject->width(), 100.); - - delete textObject; - } - - // richtext - does nothing - for (int i = 0; i < richText.size(); i++) - { - QString componentStr = "import QtQuick 2.0\nText { "+elide+" width: 100; text: \"" + richText.at(i) + "\" }"; - QDeclarativeComponent textComponent(&engine); - textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); - QQuickText *textObject = qobject_cast(textComponent.create()); - - QCOMPARE(textObject->elideMode(), m); - QCOMPARE(textObject->width(), 100.); - - delete textObject; - } - } -} - -void tst_qquicktext::multilineElide() -{ - QQuickView *canvas = createView(testFile("multilineelide.qml")); - - QQuickText *myText = qobject_cast(canvas->rootObject()); - QVERIFY(myText != 0); - - QCOMPARE(myText->lineCount(), 3); - QCOMPARE(myText->truncated(), true); - - qreal lineHeight = myText->contentHeight() / 3.; - - // reduce size and ensure fewer lines are drawn - myText->setHeight(lineHeight * 2); - QCOMPARE(myText->lineCount(), 2); - - myText->setHeight(lineHeight); - QCOMPARE(myText->lineCount(), 1); - - myText->setHeight(5); - QCOMPARE(myText->lineCount(), 1); - - myText->setHeight(lineHeight * 3); - QCOMPARE(myText->lineCount(), 3); - - // remove max count and show all lines. - myText->setHeight(1000); - myText->resetMaximumLineCount(); - - QCOMPARE(myText->truncated(), false); - - // reduce size again - myText->setHeight(lineHeight * 2); - QCOMPARE(myText->lineCount(), 2); - QCOMPARE(myText->truncated(), true); - - // change line height - myText->setLineHeight(1.1); - QCOMPARE(myText->lineCount(), 1); - - delete canvas; -} - -void tst_qquicktext::textFormat() -{ - { - QDeclarativeComponent textComponent(&engine); - textComponent.setData("import QtQuick 2.0\nText { text: \"Hello\"; textFormat: Text.RichText }", QUrl::fromLocalFile("")); - QQuickText *textObject = qobject_cast(textComponent.create()); - - QVERIFY(textObject != 0); - QVERIFY(textObject->textFormat() == QQuickText::RichText); - - QQuickTextPrivate *textPrivate = QQuickTextPrivate::get(textObject); - QVERIFY(textPrivate != 0); - QVERIFY(textPrivate->richText == true); - - delete textObject; - } - { - QDeclarativeComponent textComponent(&engine); - textComponent.setData("import QtQuick 2.0\nText { text: \"Hello\" }", QUrl::fromLocalFile("")); - QQuickText *textObject = qobject_cast(textComponent.create()); - - QVERIFY(textObject != 0); - QVERIFY(textObject->textFormat() == QQuickText::AutoText); - - QQuickTextPrivate *textPrivate = QQuickTextPrivate::get(textObject); - QVERIFY(textPrivate != 0); - QVERIFY(textPrivate->styledText == true); - - delete textObject; - } - { - QDeclarativeComponent textComponent(&engine); - textComponent.setData("import QtQuick 2.0\nText { text: \"Hello\"; textFormat: Text.PlainText }", QUrl::fromLocalFile("")); - QQuickText *textObject = qobject_cast(textComponent.create()); - - QVERIFY(textObject != 0); - QVERIFY(textObject->textFormat() == QQuickText::PlainText); - - delete textObject; - } -} - - -void tst_qquicktext::alignments_data() -{ - QTest::addColumn("hAlign"); - QTest::addColumn("vAlign"); - QTest::addColumn("expectfile"); - - QTest::newRow("LT") << int(Qt::AlignLeft) << int(Qt::AlignTop) << testFile("alignments_lt.png"); - QTest::newRow("RT") << int(Qt::AlignRight) << int(Qt::AlignTop) << testFile("alignments_rt.png"); - QTest::newRow("CT") << int(Qt::AlignHCenter) << int(Qt::AlignTop) << testFile("alignments_ct.png"); - - QTest::newRow("LB") << int(Qt::AlignLeft) << int(Qt::AlignBottom) << testFile("alignments_lb.png"); - QTest::newRow("RB") << int(Qt::AlignRight) << int(Qt::AlignBottom) << testFile("alignments_rb.png"); - QTest::newRow("CB") << int(Qt::AlignHCenter) << int(Qt::AlignBottom) << testFile("alignments_cb.png"); - - QTest::newRow("LC") << int(Qt::AlignLeft) << int(Qt::AlignVCenter) << testFile("alignments_lc.png"); - QTest::newRow("RC") << int(Qt::AlignRight) << int(Qt::AlignVCenter) << testFile("alignments_rc.png"); - QTest::newRow("CC") << int(Qt::AlignHCenter) << int(Qt::AlignVCenter) << testFile("alignments_cc.png"); -} - - -void tst_qquicktext::alignments() -{ - QSKIP("Text alignment pixmap comparison tests will not work with scenegraph"); -#if (0)// No widgets in scenegraph - QFETCH(int, hAlign); - QFETCH(int, vAlign); - QFETCH(QString, expectfile); - - QQuickView *canvas = createView(testFile("alignments.qml")); - canvas->show(); - canvas->requestActivateWindow(); - QTest::qWait(50); - QTRY_COMPARE(QGuiApplication::activeWindow(), static_cast(canvas)); - - QObject *ob = canvas->rootObject(); - QVERIFY(ob != 0); - ob->setProperty("horizontalAlignment",hAlign); - ob->setProperty("verticalAlignment",vAlign); - QTRY_COMPARE(ob->property("running").toBool(),false); - QImage actual(canvas->width(), canvas->height(), QImage::Format_RGB32); - actual.fill(qRgb(255,255,255)); - QPainter p(&actual); - canvas->render(&p); - - QImage expect(expectfile); - if (QGuiApplicationPrivate::graphics_system_name == "raster" || QGuiApplicationPrivate::graphics_system_name == "") { - QCOMPARE(actual,expect); - } - delete canvas; -#endif -} - -//the alignment tests may be trivial o.oa -void tst_qquicktext::horizontalAlignment() -{ - //test one align each, and then test if two align fails. - - for (int i = 0; i < standard.size(); i++) - { - for (int j=0; j < horizontalAlignmentmentStrings.size(); j++) - { - QString componentStr = "import QtQuick 2.0\nText { horizontalAlignment: \"" + horizontalAlignmentmentStrings.at(j) + "\"; text: \"" + standard.at(i) + "\" }"; - QDeclarativeComponent textComponent(&engine); - textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); - QQuickText *textObject = qobject_cast(textComponent.create()); - - QCOMPARE((int)textObject->hAlign(), (int)horizontalAlignmentments.at(j)); - - delete textObject; - } - } - - for (int i = 0; i < richText.size(); i++) - { - for (int j=0; j < horizontalAlignmentmentStrings.size(); j++) - { - QString componentStr = "import QtQuick 2.0\nText { horizontalAlignment: \"" + horizontalAlignmentmentStrings.at(j) + "\"; text: \"" + richText.at(i) + "\" }"; - QDeclarativeComponent textComponent(&engine); - textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); - QQuickText *textObject = qobject_cast(textComponent.create()); - - QCOMPARE((int)textObject->hAlign(), (int)horizontalAlignmentments.at(j)); - - delete textObject; - } - } - -} - -void tst_qquicktext::horizontalAlignment_RightToLeft() -{ - QQuickView *canvas = createView(testFile("horizontalAlignment_RightToLeft.qml")); - QQuickText *text = canvas->rootObject()->findChild("text"); - QVERIFY(text != 0); - canvas->show(); - - QQuickTextPrivate *textPrivate = QQuickTextPrivate::get(text); - QVERIFY(textPrivate != 0); - - QTRY_VERIFY(textPrivate->layout.lineCount()); - - // implicit alignment should follow the reading direction of RTL text - QCOMPARE(text->hAlign(), QQuickText::AlignRight); - QCOMPARE(text->effectiveHAlign(), text->hAlign()); - QVERIFY(textPrivate->layout.lineAt(0).naturalTextRect().left() > canvas->width()/2); - - // explicitly left aligned text - text->setHAlign(QQuickText::AlignLeft); - QCOMPARE(text->hAlign(), QQuickText::AlignLeft); - QCOMPARE(text->effectiveHAlign(), text->hAlign()); - QVERIFY(textPrivate->layout.lineAt(0).naturalTextRect().left() < canvas->width()/2); - - // explicitly right aligned text - text->setHAlign(QQuickText::AlignRight); - QCOMPARE(text->hAlign(), QQuickText::AlignRight); - QCOMPARE(text->effectiveHAlign(), text->hAlign()); - QVERIFY(textPrivate->layout.lineAt(0).naturalTextRect().left() > canvas->width()/2); - - // change to rich text - QString textString = text->text(); - text->setText(QString("") + textString + QString("")); - text->setTextFormat(QQuickText::RichText); - text->resetHAlign(); - - // implicitly aligned rich text should follow the reading direction of text - QCOMPARE(text->hAlign(), QQuickText::AlignRight); - QCOMPARE(text->effectiveHAlign(), text->hAlign()); - QVERIFY(textPrivate->textDocument()->defaultTextOption().alignment() & Qt::AlignLeft); - - // explicitly left aligned rich text - text->setHAlign(QQuickText::AlignLeft); - QCOMPARE(text->hAlign(), QQuickText::AlignLeft); - QCOMPARE(text->effectiveHAlign(), text->hAlign()); - QVERIFY(textPrivate->textDocument()->defaultTextOption().alignment() & Qt::AlignRight); - - // explicitly right aligned rich text - text->setHAlign(QQuickText::AlignRight); - QCOMPARE(text->hAlign(), QQuickText::AlignRight); - QCOMPARE(text->effectiveHAlign(), text->hAlign()); - QVERIFY(textPrivate->textDocument()->defaultTextOption().alignment() & Qt::AlignLeft); - - text->setText(textString); - text->setTextFormat(QQuickText::PlainText); - - // explicitly center aligned - text->setHAlign(QQuickText::AlignHCenter); - QCOMPARE(text->hAlign(), QQuickText::AlignHCenter); - QCOMPARE(text->effectiveHAlign(), text->hAlign()); - QVERIFY(textPrivate->layout.lineAt(0).naturalTextRect().left() < canvas->width()/2); - QVERIFY(textPrivate->layout.lineAt(0).naturalTextRect().right() > canvas->width()/2); - - // reseted alignment should go back to following the text reading direction - text->resetHAlign(); - QCOMPARE(text->hAlign(), QQuickText::AlignRight); - QVERIFY(textPrivate->layout.lineAt(0).naturalTextRect().left() > canvas->width()/2); - - // mirror the text item - QQuickItemPrivate::get(text)->setLayoutMirror(true); - - // mirrored implicit alignment should continue to follow the reading direction of the text - QCOMPARE(text->hAlign(), QQuickText::AlignRight); - QCOMPARE(text->effectiveHAlign(), QQuickText::AlignRight); - QVERIFY(textPrivate->layout.lineAt(0).naturalTextRect().left() > canvas->width()/2); - - // mirrored explicitly right aligned behaves as left aligned - text->setHAlign(QQuickText::AlignRight); - QCOMPARE(text->hAlign(), QQuickText::AlignRight); - QCOMPARE(text->effectiveHAlign(), QQuickText::AlignLeft); - QVERIFY(textPrivate->layout.lineAt(0).naturalTextRect().left() < canvas->width()/2); - - // mirrored explicitly left aligned behaves as right aligned - text->setHAlign(QQuickText::AlignLeft); - QCOMPARE(text->hAlign(), QQuickText::AlignLeft); - QCOMPARE(text->effectiveHAlign(), QQuickText::AlignRight); - QVERIFY(textPrivate->layout.lineAt(0).naturalTextRect().left() > canvas->width()/2); - - // disable mirroring - QQuickItemPrivate::get(text)->setLayoutMirror(false); - text->resetHAlign(); - - // English text should be implicitly left aligned - text->setText("Hello world!"); - QCOMPARE(text->hAlign(), QQuickText::AlignLeft); - QVERIFY(textPrivate->layout.lineAt(0).naturalTextRect().left() < canvas->width()/2); - - // empty text with implicit alignment follows the system locale-based - // keyboard input direction from QInputMethod::inputDirection() - text->setText(""); - QCOMPARE(text->hAlign(), qApp->inputMethod()->inputDirection() == Qt::LeftToRight ? - QQuickText::AlignLeft : QQuickText::AlignRight); - text->setHAlign(QQuickText::AlignRight); - QCOMPARE(text->hAlign(), QQuickText::AlignRight); - - delete canvas; - - // alignment of Text with no text set to it - QString componentStr = "import QtQuick 2.0\nText {}"; - QDeclarativeComponent textComponent(&engine); - textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); - QQuickText *textObject = qobject_cast(textComponent.create()); - QCOMPARE(textObject->hAlign(), qApp->inputMethod()->inputDirection() == Qt::LeftToRight ? - QQuickText::AlignLeft : QQuickText::AlignRight); - delete textObject; -} - -void tst_qquicktext::verticalAlignment() -{ - //test one align each, and then test if two align fails. - - for (int i = 0; i < standard.size(); i++) - { - for (int j=0; j < verticalAlignmentmentStrings.size(); j++) - { - QString componentStr = "import QtQuick 2.0\nText { verticalAlignment: \"" + verticalAlignmentmentStrings.at(j) + "\"; text: \"" + standard.at(i) + "\" }"; - QDeclarativeComponent textComponent(&engine); - textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); - QQuickText *textObject = qobject_cast(textComponent.create()); - - QVERIFY(textObject != 0); - QCOMPARE((int)textObject->vAlign(), (int)verticalAlignmentments.at(j)); - - delete textObject; - } - } - - for (int i = 0; i < richText.size(); i++) - { - for (int j=0; j < verticalAlignmentmentStrings.size(); j++) - { - QString componentStr = "import QtQuick 2.0\nText { verticalAlignment: \"" + verticalAlignmentmentStrings.at(j) + "\"; text: \"" + richText.at(i) + "\" }"; - QDeclarativeComponent textComponent(&engine); - textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); - QQuickText *textObject = qobject_cast(textComponent.create()); - - QVERIFY(textObject != 0); - QCOMPARE((int)textObject->vAlign(), (int)verticalAlignmentments.at(j)); - - delete textObject; - } - } - -} - -void tst_qquicktext::font() -{ - //test size, then bold, then italic, then family - { - QString componentStr = "import QtQuick 2.0\nText { font.pointSize: 40; text: \"Hello World\" }"; - QDeclarativeComponent textComponent(&engine); - textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); - QQuickText *textObject = qobject_cast(textComponent.create()); - - QCOMPARE(textObject->font().pointSize(), 40); - QCOMPARE(textObject->font().bold(), false); - QCOMPARE(textObject->font().italic(), false); - - delete textObject; - } - - { - QString componentStr = "import QtQuick 2.0\nText { font.pixelSize: 40; text: \"Hello World\" }"; - QDeclarativeComponent textComponent(&engine); - textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); - QQuickText *textObject = qobject_cast(textComponent.create()); - - QCOMPARE(textObject->font().pixelSize(), 40); - QCOMPARE(textObject->font().bold(), false); - QCOMPARE(textObject->font().italic(), false); - - delete textObject; - } - - { - QString componentStr = "import QtQuick 2.0\nText { font.bold: true; text: \"Hello World\" }"; - QDeclarativeComponent textComponent(&engine); - textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); - QQuickText *textObject = qobject_cast(textComponent.create()); - - QCOMPARE(textObject->font().bold(), true); - QCOMPARE(textObject->font().italic(), false); - - delete textObject; - } - - { - QString componentStr = "import QtQuick 2.0\nText { font.italic: true; text: \"Hello World\" }"; - QDeclarativeComponent textComponent(&engine); - textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); - QQuickText *textObject = qobject_cast(textComponent.create()); - - QCOMPARE(textObject->font().italic(), true); - QCOMPARE(textObject->font().bold(), false); - - delete textObject; - } - - { - QString componentStr = "import QtQuick 2.0\nText { font.family: \"Helvetica\"; text: \"Hello World\" }"; - QDeclarativeComponent textComponent(&engine); - textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); - QQuickText *textObject = qobject_cast(textComponent.create()); - - QCOMPARE(textObject->font().family(), QString("Helvetica")); - QCOMPARE(textObject->font().bold(), false); - QCOMPARE(textObject->font().italic(), false); - - delete textObject; - } - - { - QString componentStr = "import QtQuick 2.0\nText { font.family: \"\"; text: \"Hello World\" }"; - QDeclarativeComponent textComponent(&engine); - textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); - QQuickText *textObject = qobject_cast(textComponent.create()); - - QCOMPARE(textObject->font().family(), QString("")); - - delete textObject; - } -} - -void tst_qquicktext::style() -{ - //test style - for (int i = 0; i < styles.size(); i++) - { - QString componentStr = "import QtQuick 2.0\nText { style: \"" + styleStrings.at(i) + "\"; styleColor: \"white\"; text: \"Hello World\" }"; - QDeclarativeComponent textComponent(&engine); - textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); - QQuickText *textObject = qobject_cast(textComponent.create()); - - QCOMPARE((int)textObject->style(), (int)styles.at(i)); - QCOMPARE(textObject->styleColor(), QColor("white")); - - delete textObject; - } - QString componentStr = "import QtQuick 2.0\nText { text: \"Hello World\" }"; - QDeclarativeComponent textComponent(&engine); - textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); - QQuickText *textObject = qobject_cast(textComponent.create()); - - QRectF brPre = textObject->boundingRect(); - textObject->setStyle(QQuickText::Outline); - QRectF brPost = textObject->boundingRect(); - - QVERIFY(brPre.width() < brPost.width()); - QVERIFY(brPre.height() < brPost.height()); - - delete textObject; -} - -void tst_qquicktext::color() -{ - //test style - for (int i = 0; i < colorStrings.size(); i++) - { - QString componentStr = "import QtQuick 2.0\nText { color: \"" + colorStrings.at(i) + "\"; text: \"Hello World\" }"; - QDeclarativeComponent textComponent(&engine); - textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); - QQuickText *textObject = qobject_cast(textComponent.create()); - - QCOMPARE(textObject->color(), QColor(colorStrings.at(i))); - QCOMPARE(textObject->styleColor(), QColor("black")); - QCOMPARE(textObject->linkColor(), QColor("blue")); - - delete textObject; - } - - for (int i = 0; i < colorStrings.size(); i++) - { - QString componentStr = "import QtQuick 2.0\nText { styleColor: \"" + colorStrings.at(i) + "\"; text: \"Hello World\" }"; - QDeclarativeComponent textComponent(&engine); - textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); - QQuickText *textObject = qobject_cast(textComponent.create()); - - QCOMPARE(textObject->styleColor(), QColor(colorStrings.at(i))); - // default color to black? - QCOMPARE(textObject->color(), QColor("black")); - QCOMPARE(textObject->linkColor(), QColor("blue")); - - delete textObject; - } - - for (int i = 0; i < colorStrings.size(); i++) - { - QString componentStr = "import QtQuick 2.0\nText { linkColor: \"" + colorStrings.at(i) + "\"; text: \"Hello World\" }"; - QDeclarativeComponent textComponent(&engine); - textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); - QQuickText *textObject = qobject_cast(textComponent.create()); - - QCOMPARE(textObject->styleColor(), QColor("black")); - QCOMPARE(textObject->color(), QColor("black")); - QCOMPARE(textObject->linkColor(), QColor(colorStrings.at(i))); - - delete textObject; - } - - for (int i = 0; i < colorStrings.size(); i++) - { - for (int j = 0; j < colorStrings.size(); j++) - { - QString componentStr = "import QtQuick 2.0\nText { " - "color: \"" + colorStrings.at(i) + "\"; " - "styleColor: \"" + colorStrings.at(j) + "\"; " - "linkColor: \"" + colorStrings.at(j) + "\"; " - "text: \"Hello World\" }"; - QDeclarativeComponent textComponent(&engine); - textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); - QQuickText *textObject = qobject_cast(textComponent.create()); - - QCOMPARE(textObject->color(), QColor(colorStrings.at(i))); - QCOMPARE(textObject->styleColor(), QColor(colorStrings.at(j))); - QCOMPARE(textObject->linkColor(), QColor(colorStrings.at(j))); - - delete textObject; - } - } - { - QString colorStr = "#AA001234"; - QColor testColor("#001234"); - testColor.setAlpha(170); - - QString componentStr = "import QtQuick 2.0\nText { color: \"" + colorStr + "\"; text: \"Hello World\" }"; - QDeclarativeComponent textComponent(&engine); - textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); - QQuickText *textObject = qobject_cast(textComponent.create()); - - QCOMPARE(textObject->color(), testColor); - - delete textObject; - } { - QString colorStr = "#001234"; - QColor testColor(colorStr); - - QString componentStr = "import QtQuick 2.0\nText { color: \"" + colorStr + "\"; text: \"Hello World\" }"; - QDeclarativeComponent textComponent(&engine); - textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); - QScopedPointer object(textComponent.create()); - QQuickText *textObject = qobject_cast(object.data()); - - QSignalSpy spy(textObject, SIGNAL(colorChanged())); - - QCOMPARE(textObject->color(), testColor); - textObject->setColor(testColor); - QCOMPARE(textObject->color(), testColor); - QCOMPARE(spy.count(), 0); - - testColor = QColor("black"); - textObject->setColor(testColor); - QCOMPARE(textObject->color(), testColor); - QCOMPARE(spy.count(), 1); - } { - QString colorStr = "#001234"; - QColor testColor(colorStr); - - QString componentStr = "import QtQuick 2.0\nText { styleColor: \"" + colorStr + "\"; text: \"Hello World\" }"; - QDeclarativeComponent textComponent(&engine); - textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); - QScopedPointer object(textComponent.create()); - QQuickText *textObject = qobject_cast(object.data()); - - QSignalSpy spy(textObject, SIGNAL(styleColorChanged())); - - QCOMPARE(textObject->styleColor(), testColor); - textObject->setStyleColor(testColor); - QCOMPARE(textObject->styleColor(), testColor); - QCOMPARE(spy.count(), 0); - - testColor = QColor("black"); - textObject->setStyleColor(testColor); - QCOMPARE(textObject->styleColor(), testColor); - QCOMPARE(spy.count(), 1); - } { - QString colorStr = "#001234"; - QColor testColor(colorStr); - - QString componentStr = "import QtQuick 2.0\nText { linkColor: \"" + colorStr + "\"; text: \"Hello World\" }"; - QDeclarativeComponent textComponent(&engine); - textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); - QScopedPointer object(textComponent.create()); - QQuickText *textObject = qobject_cast(object.data()); - - QSignalSpy spy(textObject, SIGNAL(linkColorChanged())); - - QCOMPARE(textObject->linkColor(), testColor); - textObject->setLinkColor(testColor); - QCOMPARE(textObject->linkColor(), testColor); - QCOMPARE(spy.count(), 0); - - testColor = QColor("black"); - textObject->setLinkColor(testColor); - QCOMPARE(textObject->linkColor(), testColor); - QCOMPARE(spy.count(), 1); - } -} - -void tst_qquicktext::smooth() -{ - for (int i = 0; i < standard.size(); i++) - { - { - QString componentStr = "import QtQuick 2.0\nText { smooth: true; text: \"" + standard.at(i) + "\" }"; - QDeclarativeComponent textComponent(&engine); - textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); - QQuickText *textObject = qobject_cast(textComponent.create()); - QCOMPARE(textObject->smooth(), true); - - delete textObject; - } - { - QString componentStr = "import QtQuick 2.0\nText { text: \"" + standard.at(i) + "\" }"; - QDeclarativeComponent textComponent(&engine); - textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); - QQuickText *textObject = qobject_cast(textComponent.create()); - QCOMPARE(textObject->smooth(), false); - - delete textObject; - } - } - for (int i = 0; i < richText.size(); i++) - { - { - QString componentStr = "import QtQuick 2.0\nText { smooth: true; text: \"" + richText.at(i) + "\" }"; - QDeclarativeComponent textComponent(&engine); - textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); - QQuickText *textObject = qobject_cast(textComponent.create()); - QCOMPARE(textObject->smooth(), true); - - delete textObject; - } - { - QString componentStr = "import QtQuick 2.0\nText { text: \"" + richText.at(i) + "\" }"; - QDeclarativeComponent textComponent(&engine); - textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); - QQuickText *textObject = qobject_cast(textComponent.create()); - QCOMPARE(textObject->smooth(), false); - - delete textObject; - } - } -} - -void tst_qquicktext::weight() -{ - { - QString componentStr = "import QtQuick 2.0\nText { text: \"Hello world!\" }"; - QDeclarativeComponent textComponent(&engine); - textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); - QQuickText *textObject = qobject_cast(textComponent.create()); - - QVERIFY(textObject != 0); - QCOMPARE((int)textObject->font().weight(), (int)QDeclarativeFontValueType::Normal); - - delete textObject; - } - { - QString componentStr = "import QtQuick 2.0\nText { font.weight: \"Bold\"; text: \"Hello world!\" }"; - QDeclarativeComponent textComponent(&engine); - textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); - QQuickText *textObject = qobject_cast(textComponent.create()); - - QVERIFY(textObject != 0); - QCOMPARE((int)textObject->font().weight(), (int)QDeclarativeFontValueType::Bold); - - delete textObject; - } -} - -void tst_qquicktext::underline() -{ - { - QString componentStr = "import QtQuick 2.0\nText { text: \"Hello world!\" }"; - QDeclarativeComponent textComponent(&engine); - textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); - QQuickText *textObject = qobject_cast(textComponent.create()); - - QVERIFY(textObject != 0); - QCOMPARE(textObject->font().underline(), false); - - delete textObject; - } - { - QString componentStr = "import QtQuick 2.0\nText { font.underline: true; text: \"Hello world!\" }"; - QDeclarativeComponent textComponent(&engine); - textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); - QQuickText *textObject = qobject_cast(textComponent.create()); - - QVERIFY(textObject != 0); - QCOMPARE(textObject->font().underline(), true); - - delete textObject; - } -} - -void tst_qquicktext::overline() -{ - { - QString componentStr = "import QtQuick 2.0\nText { text: \"Hello world!\" }"; - QDeclarativeComponent textComponent(&engine); - textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); - QQuickText *textObject = qobject_cast(textComponent.create()); - - QVERIFY(textObject != 0); - QCOMPARE(textObject->font().overline(), false); - - delete textObject; - } - { - QString componentStr = "import QtQuick 2.0\nText { font.overline: true; text: \"Hello world!\" }"; - QDeclarativeComponent textComponent(&engine); - textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); - QQuickText *textObject = qobject_cast(textComponent.create()); - - QVERIFY(textObject != 0); - QCOMPARE(textObject->font().overline(), true); - - delete textObject; - } -} - -void tst_qquicktext::strikeout() -{ - { - QString componentStr = "import QtQuick 2.0\nText { text: \"Hello world!\" }"; - QDeclarativeComponent textComponent(&engine); - textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); - QQuickText *textObject = qobject_cast(textComponent.create()); - - QVERIFY(textObject != 0); - QCOMPARE(textObject->font().strikeOut(), false); - - delete textObject; - } - { - QString componentStr = "import QtQuick 2.0\nText { font.strikeout: true; text: \"Hello world!\" }"; - QDeclarativeComponent textComponent(&engine); - textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); - QQuickText *textObject = qobject_cast(textComponent.create()); - - QVERIFY(textObject != 0); - QCOMPARE(textObject->font().strikeOut(), true); - - delete textObject; - } -} - -void tst_qquicktext::capitalization() -{ - { - QString componentStr = "import QtQuick 2.0\nText { text: \"Hello world!\" }"; - QDeclarativeComponent textComponent(&engine); - textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); - QQuickText *textObject = qobject_cast(textComponent.create()); - - QVERIFY(textObject != 0); - QCOMPARE((int)textObject->font().capitalization(), (int)QDeclarativeFontValueType::MixedCase); - - delete textObject; - } - { - QString componentStr = "import QtQuick 2.0\nText { text: \"Hello world!\"; font.capitalization: \"AllUppercase\" }"; - QDeclarativeComponent textComponent(&engine); - textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); - QQuickText *textObject = qobject_cast(textComponent.create()); - - QVERIFY(textObject != 0); - QCOMPARE((int)textObject->font().capitalization(), (int)QDeclarativeFontValueType::AllUppercase); - - delete textObject; - } - { - QString componentStr = "import QtQuick 2.0\nText { text: \"Hello world!\"; font.capitalization: \"AllLowercase\" }"; - QDeclarativeComponent textComponent(&engine); - textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); - QQuickText *textObject = qobject_cast(textComponent.create()); - - QVERIFY(textObject != 0); - QCOMPARE((int)textObject->font().capitalization(), (int)QDeclarativeFontValueType::AllLowercase); - - delete textObject; - } - { - QString componentStr = "import QtQuick 2.0\nText { text: \"Hello world!\"; font.capitalization: \"SmallCaps\" }"; - QDeclarativeComponent textComponent(&engine); - textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); - QQuickText *textObject = qobject_cast(textComponent.create()); - - QVERIFY(textObject != 0); - QCOMPARE((int)textObject->font().capitalization(), (int)QDeclarativeFontValueType::SmallCaps); - - delete textObject; - } - { - QString componentStr = "import QtQuick 2.0\nText { text: \"Hello world!\"; font.capitalization: \"Capitalize\" }"; - QDeclarativeComponent textComponent(&engine); - textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); - QQuickText *textObject = qobject_cast(textComponent.create()); - - QVERIFY(textObject != 0); - QCOMPARE((int)textObject->font().capitalization(), (int)QDeclarativeFontValueType::Capitalize); - - delete textObject; - } -} - -void tst_qquicktext::letterSpacing() -{ - { - QString componentStr = "import QtQuick 2.0\nText { text: \"Hello world!\" }"; - QDeclarativeComponent textComponent(&engine); - textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); - QQuickText *textObject = qobject_cast(textComponent.create()); - - QVERIFY(textObject != 0); - QCOMPARE(textObject->font().letterSpacing(), 0.0); - - delete textObject; - } - { - QString componentStr = "import QtQuick 2.0\nText { text: \"Hello world!\"; font.letterSpacing: -2 }"; - QDeclarativeComponent textComponent(&engine); - textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); - QQuickText *textObject = qobject_cast(textComponent.create()); - - QVERIFY(textObject != 0); - QCOMPARE(textObject->font().letterSpacing(), -2.); - - delete textObject; - } - { - QString componentStr = "import QtQuick 2.0\nText { text: \"Hello world!\"; font.letterSpacing: 3 }"; - QDeclarativeComponent textComponent(&engine); - textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); - QQuickText *textObject = qobject_cast(textComponent.create()); - - QVERIFY(textObject != 0); - QCOMPARE(textObject->font().letterSpacing(), 3.); - - delete textObject; - } -} - -void tst_qquicktext::wordSpacing() -{ - { - QString componentStr = "import QtQuick 2.0\nText { text: \"Hello world!\" }"; - QDeclarativeComponent textComponent(&engine); - textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); - QQuickText *textObject = qobject_cast(textComponent.create()); - - QVERIFY(textObject != 0); - QCOMPARE(textObject->font().wordSpacing(), 0.0); - - delete textObject; - } - { - QString componentStr = "import QtQuick 2.0\nText { text: \"Hello world!\"; font.wordSpacing: -50 }"; - QDeclarativeComponent textComponent(&engine); - textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); - QQuickText *textObject = qobject_cast(textComponent.create()); - - QVERIFY(textObject != 0); - QCOMPARE(textObject->font().wordSpacing(), -50.); - - delete textObject; - } - { - QString componentStr = "import QtQuick 2.0\nText { text: \"Hello world!\"; font.wordSpacing: 200 }"; - QDeclarativeComponent textComponent(&engine); - textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); - QQuickText *textObject = qobject_cast(textComponent.create()); - - QVERIFY(textObject != 0); - QCOMPARE(textObject->font().wordSpacing(), 200.); - - delete textObject; - } -} - - - - -class EventSender : public QQuickItem -{ -public: - void sendEvent(QMouseEvent *event) { - if (event->type() == QEvent::MouseButtonPress) - mousePressEvent(event); - else if (event->type() == QEvent::MouseButtonRelease) - mouseReleaseEvent(event); - else - qWarning() << "Trying to send unsupported event type"; - } -}; - -class LinkTest : public QObject -{ - Q_OBJECT -public: - LinkTest() {} - - QString link; - -public slots: - void linkClicked(QString l) { link = l; } -}; - -void tst_qquicktext::clickLink() -{ - { - QString componentStr = "import QtQuick 2.0\nText { text: \"Hello world!\" }"; - QDeclarativeComponent textComponent(&engine); - textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); - QQuickText *textObject = qobject_cast(textComponent.create()); - - QVERIFY(textObject != 0); - - LinkTest test; - QObject::connect(textObject, SIGNAL(linkActivated(QString)), &test, SLOT(linkClicked(QString))); - - { - QMouseEvent me(QEvent::MouseButtonPress,QPointF(textObject->x()/2, textObject->y()/2), Qt::LeftButton, Qt::NoButton, Qt::NoModifier); - static_cast(static_cast(textObject))->sendEvent(&me); - - } - - { - QMouseEvent me(QEvent::MouseButtonRelease,QPointF(textObject->x()/2, textObject->y()/2), Qt::LeftButton, Qt::NoButton, Qt::NoModifier); - static_cast(static_cast(textObject))->sendEvent(&me); - - } - - - QCOMPARE(test.link, QLatin1String("http://qt.nokia.com")); - - delete textObject; - } -} - -void tst_qquicktext::baseUrl() -{ - QUrl localUrl("file:///tests/text.qml"); - QUrl remoteUrl("http://qt.nokia.com/test.qml"); - - QDeclarativeComponent textComponent(&engine); - textComponent.setData("import QtQuick 2.0\n Text {}", localUrl); - QQuickText *textObject = qobject_cast(textComponent.create()); - - QCOMPARE(textObject->baseUrl(), localUrl); - - QSignalSpy spy(textObject, SIGNAL(baseUrlChanged())); - - textObject->setBaseUrl(localUrl); - QCOMPARE(textObject->baseUrl(), localUrl); - QCOMPARE(spy.count(), 0); - - textObject->setBaseUrl(remoteUrl); - QCOMPARE(textObject->baseUrl(), remoteUrl); - QCOMPARE(spy.count(), 1); - - textObject->resetBaseUrl(); - QCOMPARE(textObject->baseUrl(), localUrl); - QCOMPARE(spy.count(), 2); -} - -void tst_qquicktext::embeddedImages_data() -{ - QTest::addColumn("qmlfile"); - QTest::addColumn("error"); - QTest::newRow("local") << testFileUrl("embeddedImagesLocal.qml") << ""; - QTest::newRow("local-error") << testFileUrl("embeddedImagesLocalError.qml") - << testFileUrl("embeddedImagesLocalError.qml").toString()+":3:1: QML Text: Cannot open: " + testFileUrl("http/notexists.png").toString(); - QTest::newRow("local") << testFileUrl("embeddedImagesLocalRelative.qml") << ""; - QTest::newRow("remote") << testFileUrl("embeddedImagesRemote.qml") << ""; - QTest::newRow("remote-error") << testFileUrl("embeddedImagesRemoteError.qml") - << testFileUrl("embeddedImagesRemoteError.qml").toString()+":3:1: QML Text: Error downloading http://127.0.0.1:14453/notexists.png - server replied: Not found"; - QTest::newRow("remote") << testFileUrl("embeddedImagesRemoteRelative.qml") << ""; -} - -void tst_qquicktext::embeddedImages() -{ - // Tests QTBUG-9900 - - QFETCH(QUrl, qmlfile); - QFETCH(QString, error); - - TestHTTPServer server(14453); - server.serveDirectory(testFile("http")); - - if (!error.isEmpty()) - QTest::ignoreMessage(QtWarningMsg, error.toLatin1()); - - QDeclarativeComponent textComponent(&engine, qmlfile); - QQuickText *textObject = qobject_cast(textComponent.create()); - - QVERIFY(textObject != 0); - - QTRY_COMPARE(textObject->resourcesLoading(), 0); - - QPixmap pm(testFile("http/exists.png")); - if (error.isEmpty()) { - QCOMPARE(textObject->width(), double(pm.width())); - QCOMPARE(textObject->height(), double(pm.height())); - } else { - QVERIFY(16 != pm.width()); // check test is effective - QCOMPARE(textObject->width(), 16.0); // default size of QTextDocument broken image icon - QCOMPARE(textObject->height(), 16.0); - } - - delete textObject; -} - -void tst_qquicktext::lineCount() -{ - QQuickView *canvas = createView(testFile("lineCount.qml")); - - QQuickText *myText = canvas->rootObject()->findChild("myText"); - QVERIFY(myText != 0); - - QVERIFY(myText->lineCount() > 1); - QVERIFY(!myText->truncated()); - QCOMPARE(myText->maximumLineCount(), INT_MAX); - - myText->setMaximumLineCount(2); - QCOMPARE(myText->lineCount(), 2); - QCOMPARE(myText->truncated(), true); - QCOMPARE(myText->maximumLineCount(), 2); - - myText->resetMaximumLineCount(); - QCOMPARE(myText->maximumLineCount(), INT_MAX); - QCOMPARE(myText->truncated(), false); - - myText->setElideMode(QQuickText::ElideRight); - myText->setMaximumLineCount(2); - QCOMPARE(myText->lineCount(), 2); - QCOMPARE(myText->truncated(), true); - QCOMPARE(myText->maximumLineCount(), 2); - - delete canvas; -} - -void tst_qquicktext::lineHeight() -{ - QQuickView *canvas = createView(testFile("lineHeight.qml")); - - QQuickText *myText = canvas->rootObject()->findChild("myText"); - QVERIFY(myText != 0); - - QVERIFY(myText->lineHeight() == 1); - QVERIFY(myText->lineHeightMode() == QQuickText::ProportionalHeight); - - qreal h = myText->height(); - myText->setLineHeight(1.5); - QCOMPARE(myText->height(), qreal(qCeil(h * 1.5))); - - myText->setLineHeightMode(QQuickText::FixedHeight); - myText->setLineHeight(20); - QCOMPARE(myText->height(), myText->lineCount() * 20.0); - - myText->setText("Lorem ipsum sit amet, consectetur adipiscing elit. Integer felis nisl, varius in pretium nec, venenatis non erat. Proin lobortis interdum dictum."); - myText->setLineHeightMode(QQuickText::ProportionalHeight); - myText->setLineHeight(1.0); - - qreal h2 = myText->height(); - myText->setLineHeight(2.0); - QVERIFY(myText->height() == h2 * 2.0); - - myText->setLineHeightMode(QQuickText::FixedHeight); - myText->setLineHeight(10); - QCOMPARE(myText->height(), myText->lineCount() * 10.0); - - delete canvas; -} - -void tst_qquicktext::implicitSize_data() -{ - QTest::addColumn("text"); - QTest::addColumn("width"); - QTest::addColumn("wrap"); - QTest::addColumn("elide"); - QTest::newRow("plain") << "The quick red fox jumped over the lazy brown dog" << "50" << "Text.NoWrap" << "Text.ElideNone"; - QTest::newRow("richtext") << "The quick red fox jumped over the lazy brown dog" <<" 50" << "Text.NoWrap" << "Text.ElideNone"; - QTest::newRow("plain, 0 width") << "The quick red fox jumped over the lazy brown dog" << "0" << "Text.NoWrap" << "Text.ElideNone"; - QTest::newRow("plain, elide") << "The quick red fox jumped over the lazy brown dog" << "50" << "Text.NoWrap" << "Text.ElideRight"; - QTest::newRow("plain, 0 width, elide") << "The quick red fox jumped over the lazy brown dog" << "0" << "Text.NoWrap" << "Text.ElideRight"; - QTest::newRow("richtext, 0 width") << "The quick red fox jumped over the lazy brown dog" <<" 0" << "Text.NoWrap" << "Text.ElideNone"; - QTest::newRow("plain_wrap") << "The quick red fox jumped over the lazy brown dog" << "50" << "Text.Wrap" << "Text.ElideNone"; - QTest::newRow("richtext_wrap") << "The quick red fox jumped over the lazy brown dog" << "50" << "Text.Wrap" << "Text.ElideNone"; - QTest::newRow("plain_wrap, 0 width") << "The quick red fox jumped over the lazy brown dog" << "0" << "Text.Wrap" << "Text.ElideNone"; - QTest::newRow("plain_wrap, elide") << "The quick red fox jumped over the lazy brown dog" << "50" << "Text.Wrap" << "Text.ElideRight"; - QTest::newRow("plain_wrap, 0 width, elide") << "The quick red fox jumped over the lazy brown dog" << "0" << "Text.Wrap" << "Text.ElideRight"; - QTest::newRow("richtext_wrap, 0 width") << "The quick red fox jumped over the lazy brown dog" << "0" << "Text.Wrap" << "Text.ElideNone"; -} - -void tst_qquicktext::implicitSize() -{ - QFETCH(QString, text); - QFETCH(QString, width); - QFETCH(QString, wrap); - QFETCH(QString, elide); - QString componentStr = "import QtQuick 2.0\nText { " - "text: \"" + text + "\"; " - "width: " + width + "; " - "wrapMode: " + wrap + "; " - "elide: " + elide + "; " - "maximumLineCount: 1 }"; - QDeclarativeComponent textComponent(&engine); - textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); - QQuickText *textObject = qobject_cast(textComponent.create()); - - QVERIFY(textObject->width() < textObject->implicitWidth()); - QVERIFY(textObject->height() == textObject->implicitHeight()); - - textObject->resetWidth(); - QVERIFY(textObject->width() == textObject->implicitWidth()); - QVERIFY(textObject->height() == textObject->implicitHeight()); - - delete textObject; -} - -void tst_qquicktext::contentSize() -{ - QString componentStr = "import QtQuick 2.0\nText { width: 75; height: 16; font.pixelSize: 10 }"; - QDeclarativeComponent textComponent(&engine); - textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); - QScopedPointer object(textComponent.create()); - QQuickText *textObject = qobject_cast(object.data()); - - QSignalSpy spy(textObject, SIGNAL(contentSizeChanged())); - - textObject->setText("The quick red fox jumped over the lazy brown dog"); - - QVERIFY(textObject->contentWidth() > textObject->width()); - QVERIFY(textObject->contentHeight() < textObject->height()); - QCOMPARE(spy.count(), 1); - - textObject->setWrapMode(QQuickText::WordWrap); - QVERIFY(textObject->contentWidth() <= textObject->width()); - QVERIFY(textObject->contentHeight() > textObject->height()); - QCOMPARE(spy.count(), 2); - - textObject->setElideMode(QQuickText::ElideRight); - QVERIFY(textObject->contentWidth() <= textObject->width()); - QVERIFY(textObject->contentHeight() < textObject->height()); - QCOMPARE(spy.count(), 3); - int spyCount = 3; - qreal elidedWidth = textObject->contentWidth(); - - textObject->setText("The quickredfoxjumpedoverthe lazy brown dog"); - QVERIFY(textObject->contentWidth() <= textObject->width()); - QVERIFY(textObject->contentHeight() < textObject->height()); - // this text probably won't have the same elided width, but it's not guaranteed. - if (textObject->contentWidth() != elidedWidth) - QCOMPARE(spy.count(), ++spyCount); - else - QCOMPARE(spy.count(), spyCount); - - textObject->setElideMode(QQuickText::ElideNone); - QVERIFY(textObject->contentWidth() > textObject->width()); - QVERIFY(textObject->contentHeight() > textObject->height()); - QCOMPARE(spy.count(), ++spyCount); -} - -void tst_qquicktext::lineLaidOut() -{ - QQuickView *canvas = createView(testFile("lineLayout.qml")); - - QQuickText *myText = canvas->rootObject()->findChild("myText"); - QVERIFY(myText != 0); - - QQuickTextPrivate *textPrivate = QQuickTextPrivate::get(myText); - QVERIFY(textPrivate != 0); - - QTextDocument *doc = textPrivate->textDocument(); - QVERIFY(doc == 0); - -#if defined(Q_OS_MAC) - QVERIFY(myText->lineCount() == textPrivate->linesRects.count()); -#endif - - for (int i = 0; i < textPrivate->layout.lineCount(); ++i) { - QRectF r = textPrivate->layout.lineAt(i).rect(); - QVERIFY(r.width() == i * 15); - if (i >= 30) - QVERIFY(r.x() == r.width() + 30); - if (i >= 60) { - QVERIFY(r.x() == r.width() * 2 + 60); - QVERIFY(r.height() == 20); - } - } - - delete canvas; -} - -void tst_qquicktext::imgTagsBaseUrl_data() -{ - QTest::addColumn("src"); - QTest::addColumn("baseUrl"); - QTest::addColumn("contextUrl"); - QTest::addColumn("imgHeight"); - - QTest::newRow("absolute local") - << testFileUrl("images/heart200.png") - << QUrl() - << QUrl() - << 181.; - QTest::newRow("relative local context 1") - << QUrl("images/heart200.png") - << QUrl() - << testFileUrl("/app.qml") - << 181.; - QTest::newRow("relative local context 2") - << QUrl("heart200.png") - << QUrl() - << testFileUrl("images/app.qml") - << 181.; - QTest::newRow("relative local base 1") - << QUrl("images/heart200.png") - << testFileUrl("") - << testFileUrl("nonexistant/app.qml") - << 181.; - QTest::newRow("relative local base 2") - << QUrl("heart200.png") - << testFileUrl("images/") - << testFileUrl("nonexistant/app.qml") - << 181.; - QTest::newRow("base relative to local context") - << QUrl("heart200.png") - << testFileUrl("images/") - << testFileUrl("/app.qml") - << 181.; - - QTest::newRow("absolute remote") - << QUrl("http://127.0.0.1:14453/images/heart200.png") - << QUrl() - << QUrl() - << 181.; - QTest::newRow("relative remote base 1") - << QUrl("images/heart200.png") - << QUrl("http://127.0.0.1:14453/") - << testFileUrl("nonexistant/app.qml") - << 181.; - QTest::newRow("relative remote base 2") - << QUrl("heart200.png") - << QUrl("http://127.0.0.1:14453/images/") - << testFileUrl("nonexistant/app.qml") - << 181.; -} - -void tst_qquicktext::imgTagsBaseUrl() -{ - QFETCH(QUrl, src); - QFETCH(QUrl, baseUrl); - QFETCH(QUrl, contextUrl); - QFETCH(qreal, imgHeight); - - TestHTTPServer server(14453); - server.serveDirectory(testFile("")); - - QByteArray baseUrlFragment; - if (!baseUrl.isEmpty()) - baseUrlFragment = "; baseUrl: \"" + baseUrl.toEncoded() + "\""; - QByteArray componentStr = "import QtQuick 2.0\nText { text: \"This is a test \"" + baseUrlFragment + " }"; - - QDeclarativeComponent component(&engine); - component.setData(componentStr, contextUrl); - QScopedPointer object(component.create()); - QQuickText *textObject = qobject_cast(object.data()); - QVERIFY(textObject); - - QCoreApplication::processEvents(); - - QTRY_COMPARE(textObject->height(), imgHeight); -} - -void tst_qquicktext::imgTagsAlign_data() -{ - QTest::addColumn("src"); - QTest::addColumn("imgHeight"); - QTest::addColumn("align"); - QTest::newRow("heart-bottom") << "data/images/heart200.png" << 181 << "bottom"; - QTest::newRow("heart-middle") << "data/images/heart200.png" << 181 << "middle"; - QTest::newRow("heart-top") << "data/images/heart200.png" << 181 << "top"; - QTest::newRow("starfish-bottom") << "data/images/starfish_2.png" << 217 << "bottom"; - QTest::newRow("starfish-middle") << "data/images/starfish_2.png" << 217 << "middle"; - QTest::newRow("starfish-top") << "data/images/starfish_2.png" << 217 << "top"; -} - -void tst_qquicktext::imgTagsAlign() -{ - QFETCH(QString, src); - QFETCH(int, imgHeight); - QFETCH(QString, align); - QString componentStr = "import QtQuick 2.0\nText { text: \"This is a test of image.\" }"; - QDeclarativeComponent textComponent(&engine); - textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); - QQuickText *textObject = qobject_cast(textComponent.create()); - - QVERIFY(textObject != 0); - QVERIFY(textObject->height() == imgHeight); - - QQuickTextPrivate *textPrivate = QQuickTextPrivate::get(textObject); - QVERIFY(textPrivate != 0); - - QRectF br = textPrivate->layout.boundingRect(); - if (align == "bottom") - QVERIFY(br.y() == imgHeight - br.height()); - else if (align == "middle") - QVERIFY(br.y() == imgHeight / 2.0 - br.height() / 2.0); - else if (align == "top") - QVERIFY(br.y() == 0); - - delete textObject; -} - -void tst_qquicktext::imgTagsMultipleImages() -{ - QString componentStr = "import QtQuick 2.0\nText { text: \"This is a starfish and another one.\" }"; - - QDeclarativeComponent textComponent(&engine); - textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); - QQuickText *textObject = qobject_cast(textComponent.create()); - - QVERIFY(textObject != 0); - QVERIFY(textObject->height() == 85); - - QQuickTextPrivate *textPrivate = QQuickTextPrivate::get(textObject); - QVERIFY(textPrivate != 0); - QVERIFY(textPrivate->visibleImgTags.count() == 2); - - delete textObject; -} - -void tst_qquicktext::imgTagsElide() -{ - QQuickView *canvas = createView(testFile("imgTagsElide.qml")); - QQuickText *myText = canvas->rootObject()->findChild("myText"); - QVERIFY(myText != 0); - - QQuickTextPrivate *textPrivate = QQuickTextPrivate::get(myText); - QVERIFY(textPrivate != 0); - QVERIFY(textPrivate->visibleImgTags.count() == 0); - myText->setMaximumLineCount(20); - QTRY_VERIFY(textPrivate->visibleImgTags.count() == 1); - - delete myText; - delete canvas; -} - -void tst_qquicktext::imgTagsUpdates() -{ - QQuickView *canvas = createView(testFile("imgTagsUpdates.qml")); - QQuickText *myText = canvas->rootObject()->findChild("myText"); - QVERIFY(myText != 0); - - QSignalSpy spy(myText, SIGNAL(contentSizeChanged())); - - QQuickTextPrivate *textPrivate = QQuickTextPrivate::get(myText); - QVERIFY(textPrivate != 0); - - myText->setText("This is a heart."); - QVERIFY(textPrivate->visibleImgTags.count() == 1); - QVERIFY(spy.count() == 1); - - myText->setMaximumLineCount(2); - myText->setText("This is another heart."); - QTRY_VERIFY(textPrivate->visibleImgTags.count() == 1); - - // if maximumLineCount is set and the img tag doesn't have an explicit size - // we relayout twice. - QVERIFY(spy.count() == 3); - - delete myText; - delete canvas; -} - -void tst_qquicktext::imgTagsError() -{ - QString componentStr = "import QtQuick 2.0\nText { text: \"This is a starfish.\" }"; - - QDeclarativeComponent textComponent(&engine); - QTest::ignoreMessage(QtWarningMsg, "file::2:1: QML Text: Cannot open: file:data/images/starfish_2.pn"); - textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); - QQuickText *textObject = qobject_cast(textComponent.create()); - - QVERIFY(textObject != 0); - delete textObject; -} - -void tst_qquicktext::fontSizeMode_data() -{ - QTest::addColumn("text"); - QTest::addColumn("canElide"); - QTest::newRow("plain") << "The quick red fox jumped over the lazy brown dog" << true; - QTest::newRow("richtext") << "The quick red fox jumped over the lazy brown dog" << false; -} - -void tst_qquicktext::fontSizeMode() -{ - QFETCH(QString, text); - QFETCH(bool, canElide); - - QQuickView *canvas = createView(testFile("fontSizeMode.qml")); - canvas->show(); - - QQuickText *myText = canvas->rootObject()->findChild("myText"); - QVERIFY(myText != 0); - - myText->setText(text); - QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); - - qreal originalWidth = myText->contentWidth(); - qreal originalHeight = myText->contentHeight(); - - // The original text unwrapped should exceed the width of the item. - QVERIFY(originalWidth > myText->width()); - QVERIFY(originalHeight < myText->height()); - - QFont font = myText->font(); - font.setPixelSize(64); - - myText->setFont(font); - myText->setFontSizeMode(QQuickText::HorizontalFit); - QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); - // Font size reduced to fit within the width of the item. - qreal horizontalFitWidth = myText->contentWidth(); - qreal horizontalFitHeight = myText->contentHeight(); - QVERIFY(horizontalFitWidth <= myText->width() + 2); // rounding - QVERIFY(horizontalFitHeight <= myText->height() + 2); - - if (canElide) { - // Elide won't affect the size with HorizontalFit. - myText->setElideMode(QQuickText::ElideRight); - QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); - QVERIFY(!myText->truncated()); - QCOMPARE(myText->contentWidth(), horizontalFitWidth); - QCOMPARE(myText->contentHeight(), horizontalFitHeight); - - myText->setElideMode(QQuickText::ElideLeft); - QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); - QVERIFY(!myText->truncated()); - QCOMPARE(myText->contentWidth(), horizontalFitWidth); - QCOMPARE(myText->contentHeight(), horizontalFitHeight); - - myText->setElideMode(QQuickText::ElideMiddle); - QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); - QVERIFY(!myText->truncated()); - QCOMPARE(myText->contentWidth(), horizontalFitWidth); - QCOMPARE(myText->contentHeight(), horizontalFitHeight); - - myText->setElideMode(QQuickText::ElideNone); - QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); - } - - myText->setFontSizeMode(QQuickText::VerticalFit); - QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); - // Font size increased to fill the height of the item. - qreal verticalFitHeight = myText->contentHeight(); - QVERIFY(myText->contentWidth() > myText->width()); - QVERIFY(verticalFitHeight <= myText->height() + 2); - QVERIFY(verticalFitHeight > originalHeight); - - if (canElide) { - // Elide won't affect the height of a single line with VerticalFit but will crop the width. - myText->setElideMode(QQuickText::ElideRight); - QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); - QVERIFY(myText->truncated()); - QVERIFY(myText->contentWidth() <= myText->width() + 2); - QCOMPARE(myText->contentHeight(), verticalFitHeight); - - myText->setElideMode(QQuickText::ElideLeft); - QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); - QVERIFY(myText->truncated()); - QVERIFY(myText->contentWidth() <= myText->width() + 2); - QCOMPARE(myText->contentHeight(), verticalFitHeight); - - myText->setElideMode(QQuickText::ElideMiddle); - QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); - QVERIFY(myText->truncated()); - QVERIFY(myText->contentWidth() <= myText->width() + 2); - QCOMPARE(myText->contentHeight(), verticalFitHeight); - - myText->setElideMode(QQuickText::ElideNone); - QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); - } - - myText->setFontSizeMode(QQuickText::Fit); - QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); - // Should be the same as HorizontalFit with no wrapping. - QCOMPARE(myText->contentWidth(), horizontalFitWidth); - QCOMPARE(myText->contentHeight(), horizontalFitHeight); - - if (canElide) { - // Elide won't affect the size with Fit. - myText->setElideMode(QQuickText::ElideRight); - QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); - QVERIFY(!myText->truncated()); - QCOMPARE(myText->contentWidth(), horizontalFitWidth); - QCOMPARE(myText->contentHeight(), horizontalFitHeight); - - myText->setElideMode(QQuickText::ElideLeft); - QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); - QVERIFY(!myText->truncated()); - QCOMPARE(myText->contentWidth(), horizontalFitWidth); - QCOMPARE(myText->contentHeight(), horizontalFitHeight); - - myText->setElideMode(QQuickText::ElideMiddle); - QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); - QVERIFY(!myText->truncated()); - QCOMPARE(myText->contentWidth(), horizontalFitWidth); - QCOMPARE(myText->contentHeight(), horizontalFitHeight); - - myText->setElideMode(QQuickText::ElideNone); - QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); - } - - myText->setFontSizeMode(QQuickText::FixedSize); - myText->setWrapMode(QQuickText::Wrap); - QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); - - originalWidth = myText->contentWidth(); - originalHeight = myText->contentHeight(); - - // The original text wrapped should exceed the height of the item. - QVERIFY(originalWidth <= myText->width() + 2); - QVERIFY(originalHeight > myText->height()); - - myText->setFontSizeMode(QQuickText::HorizontalFit); - QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); - // HorizontalFit should reduce the font size to minimize wrapping, which brings it back to the - // same size as without text wrapping. - QCOMPARE(myText->contentWidth(), horizontalFitWidth); - QCOMPARE(myText->contentHeight(), horizontalFitHeight); - - if (canElide) { - // Elide won't affect the size with HorizontalFit. - myText->setElideMode(QQuickText::ElideRight); - QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); - QVERIFY(!myText->truncated()); - QCOMPARE(myText->contentWidth(), horizontalFitWidth); - QCOMPARE(myText->contentHeight(), horizontalFitHeight); - - myText->setElideMode(QQuickText::ElideNone); - QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); - } - - myText->setFontSizeMode(QQuickText::VerticalFit); - QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); - // VerticalFit should reduce the size to the wrapped text within the vertical height. - verticalFitHeight = myText->contentHeight(); - qreal verticalFitWidth = myText->contentWidth(); - QVERIFY(myText->contentWidth() <= myText->width() + 2); - QVERIFY(verticalFitHeight <= myText->height() + 2); - QVERIFY(verticalFitHeight < originalHeight); - - if (canElide) { - // Elide won't affect the height or width of a wrapped text with VerticalFit. - myText->setElideMode(QQuickText::ElideRight); - QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); - QVERIFY(!myText->truncated()); - QCOMPARE(myText->contentWidth(), verticalFitWidth); - QCOMPARE(myText->contentHeight(), verticalFitHeight); - - myText->setElideMode(QQuickText::ElideNone); - QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); - } - - myText->setFontSizeMode(QQuickText::Fit); - QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); - // Should be the same as VerticalFit with wrapping. - QCOMPARE(myText->contentWidth(), verticalFitWidth); - QCOMPARE(myText->contentHeight(), verticalFitHeight); - - if (canElide) { - // Elide won't affect the size with Fit. - myText->setElideMode(QQuickText::ElideRight); - QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); - QVERIFY(!myText->truncated()); - QCOMPARE(myText->contentWidth(), verticalFitWidth); - QCOMPARE(myText->contentHeight(), verticalFitHeight); - - myText->setElideMode(QQuickText::ElideNone); - QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); - } - - myText->setFontSizeMode(QQuickText::FixedSize); - myText->setMaximumLineCount(2); - QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); - - // The original text wrapped should exceed the height of the item. - QVERIFY(originalWidth <= myText->width() + 2); - QVERIFY(originalHeight > myText->height()); - - myText->setFontSizeMode(QQuickText::HorizontalFit); - QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); - // HorizontalFit should reduce the font size to minimize wrapping, which brings it back to the - // same size as without text wrapping. - QCOMPARE(myText->contentWidth(), horizontalFitWidth); - QCOMPARE(myText->contentHeight(), horizontalFitHeight); - - if (canElide) { - // Elide won't affect the size with HorizontalFit. - myText->setElideMode(QQuickText::ElideRight); - QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); - QVERIFY(!myText->truncated()); - QCOMPARE(myText->contentWidth(), horizontalFitWidth); - QCOMPARE(myText->contentHeight(), horizontalFitHeight); - - myText->setElideMode(QQuickText::ElideNone); - QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); - } - - myText->setFontSizeMode(QQuickText::VerticalFit); - QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); - // VerticalFit should reduce the size to the wrapped text within the vertical height. - verticalFitHeight = myText->contentHeight(); - verticalFitWidth = myText->contentWidth(); - QVERIFY(myText->contentWidth() <= myText->width() + 2); - QVERIFY(verticalFitHeight <= myText->height() + 2); - QVERIFY(verticalFitHeight < originalHeight); - - if (canElide) { - // Elide won't affect the height or width of a wrapped text with VerticalFit. - myText->setElideMode(QQuickText::ElideRight); - QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); - QVERIFY(!myText->truncated()); - QCOMPARE(myText->contentWidth(), verticalFitWidth); - QCOMPARE(myText->contentHeight(), verticalFitHeight); - - myText->setElideMode(QQuickText::ElideNone); - QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); - } - - myText->setFontSizeMode(QQuickText::Fit); - QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); - // Should be the same as VerticalFit with wrapping. - QCOMPARE(myText->contentWidth(), verticalFitWidth); - QCOMPARE(myText->contentHeight(), verticalFitHeight); - - if (canElide) { - // Elide won't affect the size with Fit. - myText->setElideMode(QQuickText::ElideRight); - QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); - QVERIFY(!myText->truncated()); - QCOMPARE(myText->contentWidth(), verticalFitWidth); - QCOMPARE(myText->contentHeight(), verticalFitHeight); - - myText->setElideMode(QQuickText::ElideNone); - QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); - } -} - -void tst_qquicktext::fontSizeModeMultiline_data() -{ - QTest::addColumn("text"); - QTest::addColumn("canElide"); - QTest::newRow("plain") << "The quick red fox jumped\n over the lazy brown dog" << true; - QTest::newRow("richtext") << "The quick red fox jumped
      over the lazy brown dog
      " << false; -} - -void tst_qquicktext::fontSizeModeMultiline() -{ - QFETCH(QString, text); - QFETCH(bool, canElide); - - QQuickView *canvas = createView(testFile("fontSizeMode.qml")); - canvas->show(); - - QQuickText *myText = canvas->rootObject()->findChild("myText"); - QVERIFY(myText != 0); - - myText->setText(text); - QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); - - qreal originalWidth = myText->contentWidth(); - qreal originalHeight = myText->contentHeight(); - QCOMPARE(myText->lineCount(), 2); - - // The original text unwrapped should exceed the width and height of the item. - QVERIFY(originalWidth > myText->width()); - QVERIFY(originalHeight > myText->height()); - - QFont font = myText->font(); - font.setPixelSize(64); - - myText->setFont(font); - myText->setFontSizeMode(QQuickText::HorizontalFit); - QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); - // Font size reduced to fit within the width of the item. - QCOMPARE(myText->lineCount(), 2); - qreal horizontalFitWidth = myText->contentWidth(); - qreal horizontalFitHeight = myText->contentHeight(); - QVERIFY(horizontalFitWidth <= myText->width() + 2); // rounding - QVERIFY(horizontalFitHeight > myText->height()); - - if (canElide) { - // Right eliding will remove the last line - myText->setElideMode(QQuickText::ElideRight); - QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); - QVERIFY(myText->truncated()); - QCOMPARE(myText->lineCount(), 1); - QVERIFY(myText->contentWidth() <= myText->width() + 2); - QVERIFY(myText->contentHeight() <= myText->height() + 2); - - // Left or middle eliding wont have any effect. - myText->setElideMode(QQuickText::ElideLeft); - QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); - QVERIFY(!myText->truncated()); - QCOMPARE(myText->contentWidth(), horizontalFitWidth); - QCOMPARE(myText->contentHeight(), horizontalFitHeight); - - myText->setElideMode(QQuickText::ElideMiddle); - QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); - QVERIFY(!myText->truncated()); - QCOMPARE(myText->contentWidth(), horizontalFitWidth); - QCOMPARE(myText->contentHeight(), horizontalFitHeight); - - myText->setElideMode(QQuickText::ElideNone); - QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); - } - - myText->setFontSizeMode(QQuickText::VerticalFit); - QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); - // Font size reduced to fit within the height of the item. - qreal verticalFitWidth = myText->contentWidth(); - qreal verticalFitHeight = myText->contentHeight(); - QVERIFY(verticalFitWidth <= myText->width() + 2); - QVERIFY(verticalFitHeight <= myText->height() + 2); - - if (canElide) { - // Elide will have no effect. - myText->setElideMode(QQuickText::ElideRight); - QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); - QVERIFY(!myText->truncated()); - QVERIFY(myText->contentWidth() <= myText->width() + 2); - QCOMPARE(myText->contentWidth(), verticalFitWidth); - QCOMPARE(myText->contentHeight(), verticalFitHeight); - - myText->setElideMode(QQuickText::ElideLeft); - QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); - QVERIFY(!myText->truncated()); - QCOMPARE(myText->contentWidth(), verticalFitWidth); - QCOMPARE(myText->contentHeight(), verticalFitHeight); - - myText->setElideMode(QQuickText::ElideMiddle); - QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); - QVERIFY(!myText->truncated()); - QCOMPARE(myText->contentWidth(), verticalFitWidth); - QCOMPARE(myText->contentHeight(), verticalFitHeight); - - myText->setElideMode(QQuickText::ElideNone); - QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); - } - - myText->setFontSizeMode(QQuickText::Fit); - QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); - // Should be the same as VerticalFit with no wrapping. - QCOMPARE(myText->contentWidth(), verticalFitWidth); - QCOMPARE(myText->contentHeight(), verticalFitHeight); - - if (canElide) { - // Elide won't affect the size with Fit. - myText->setElideMode(QQuickText::ElideRight); - QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); - QVERIFY(!myText->truncated()); - QCOMPARE(myText->contentWidth(), verticalFitWidth); - QCOMPARE(myText->contentHeight(), verticalFitHeight); - - myText->setElideMode(QQuickText::ElideLeft); - QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); - QVERIFY(!myText->truncated()); - QCOMPARE(myText->contentWidth(), verticalFitWidth); - QCOMPARE(myText->contentHeight(), verticalFitHeight); - - myText->setElideMode(QQuickText::ElideMiddle); - QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); - QVERIFY(!myText->truncated()); - QCOMPARE(myText->contentWidth(), verticalFitWidth); - QCOMPARE(myText->contentHeight(), verticalFitHeight); - - myText->setElideMode(QQuickText::ElideNone); - QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); - } - - myText->setFontSizeMode(QQuickText::FixedSize); - myText->setWrapMode(QQuickText::Wrap); - QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); - - originalWidth = myText->contentWidth(); - originalHeight = myText->contentHeight(); - - // The original text wrapped should exceed the height of the item. - QVERIFY(originalWidth <= myText->width() + 2); - QVERIFY(originalHeight > myText->height()); - - myText->setFontSizeMode(QQuickText::HorizontalFit); - QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); - // HorizontalFit should reduce the font size to minimize wrapping, which brings it back to the - // same size as without text wrapping. - QCOMPARE(myText->contentWidth(), horizontalFitWidth); - QCOMPARE(myText->contentHeight(), horizontalFitHeight); - - if (canElide) { - // Text will be elided vertically with HorizontalFit - myText->setElideMode(QQuickText::ElideRight); - QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); - QVERIFY(myText->truncated()); - QVERIFY(myText->contentWidth() <= myText->width() + 2); - QVERIFY(myText->contentHeight() <= myText->height() + 2); - - myText->setElideMode(QQuickText::ElideNone); - QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); - } - - myText->setFontSizeMode(QQuickText::VerticalFit); - QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); - // VerticalFit should reduce the size to the wrapped text within the vertical height. - verticalFitHeight = myText->contentHeight(); - verticalFitWidth = myText->contentWidth(); - QVERIFY(myText->contentWidth() <= myText->width() + 2); - QVERIFY(verticalFitHeight <= myText->height() + 2); - QVERIFY(verticalFitHeight < originalHeight); - - if (canElide) { - // Elide won't affect the height or width of a wrapped text with VerticalFit. - myText->setElideMode(QQuickText::ElideRight); - QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); - QVERIFY(!myText->truncated()); - QCOMPARE(myText->contentWidth(), verticalFitWidth); - QCOMPARE(myText->contentHeight(), verticalFitHeight); - - myText->setElideMode(QQuickText::ElideNone); - QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); - } - - myText->setFontSizeMode(QQuickText::Fit); - QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); - // Should be the same as VerticalFit with wrapping. - QCOMPARE(myText->contentWidth(), verticalFitWidth); - QCOMPARE(myText->contentHeight(), verticalFitHeight); - - if (canElide) { - // Elide won't affect the size with Fit. - myText->setElideMode(QQuickText::ElideRight); - QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); - QVERIFY(!myText->truncated()); - QCOMPARE(myText->contentWidth(), verticalFitWidth); - QCOMPARE(myText->contentHeight(), verticalFitHeight); - - myText->setElideMode(QQuickText::ElideNone); - QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); - } - - myText->setFontSizeMode(QQuickText::FixedSize); - myText->setMaximumLineCount(2); - QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); - - // The original text wrapped should exceed the height of the item. - QVERIFY(originalWidth <= myText->width() + 2); - QVERIFY(originalHeight > myText->height()); - - myText->setFontSizeMode(QQuickText::HorizontalFit); - QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); - // HorizontalFit should reduce the font size to minimize wrapping, which brings it back to the - // same size as without text wrapping. - QCOMPARE(myText->contentWidth(), horizontalFitWidth); - QCOMPARE(myText->contentHeight(), horizontalFitHeight); - - if (canElide) { - // Elide won't affect the size with HorizontalFit. - myText->setElideMode(QQuickText::ElideRight); - QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); - QVERIFY(myText->truncated()); - QVERIFY(myText->contentWidth() <= myText->width() + 2); - QVERIFY(myText->contentHeight() <= myText->height() + 2); - - myText->setElideMode(QQuickText::ElideNone); - QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); - } - - myText->setFontSizeMode(QQuickText::VerticalFit); - QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); - // VerticalFit should reduce the size to the wrapped text within the vertical height. - verticalFitHeight = myText->contentHeight(); - verticalFitWidth = myText->contentWidth(); - QVERIFY(myText->contentWidth() <= myText->width() + 2); - QVERIFY(verticalFitHeight <= myText->height() + 2); - QVERIFY(verticalFitHeight < originalHeight); - - if (canElide) { - // Elide won't affect the height or width of a wrapped text with VerticalFit. - myText->setElideMode(QQuickText::ElideRight); - QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); - QVERIFY(!myText->truncated()); - QCOMPARE(myText->contentWidth(), verticalFitWidth); - QCOMPARE(myText->contentHeight(), verticalFitHeight); - - myText->setElideMode(QQuickText::ElideNone); - QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); - } - - myText->setFontSizeMode(QQuickText::Fit); - QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); - // Should be the same as VerticalFit with wrapping. - QCOMPARE(myText->contentWidth(), verticalFitWidth); - QCOMPARE(myText->contentHeight(), verticalFitHeight); - - if (canElide) { - // Elide won't affect the size with Fit. - myText->setElideMode(QQuickText::ElideRight); - QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); - QVERIFY(!myText->truncated()); - QCOMPARE(myText->contentWidth(), verticalFitWidth); - QCOMPARE(myText->contentHeight(), verticalFitHeight); - - myText->setElideMode(QQuickText::ElideNone); - QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); - } -} - -void tst_qquicktext::multilengthStrings_data() -{ - QTest::addColumn("source"); - QTest::newRow("No Wrap") << testFile("multilengthStrings.qml"); - QTest::newRow("Wrap") << testFile("multilengthStringsWrapped.qml"); -} - -void tst_qquicktext::multilengthStrings() -{ - QFETCH(QString, source); - - QScopedPointer canvas(createView(source)); - canvas->show(); - - QQuickText *myText = canvas->rootObject()->findChild("myText"); - QVERIFY(myText != 0); - - const QString longText = "the quick brown fox jumped over the lazy dog"; - const QString mediumText = "the brown fox jumped over the dog"; - const QString shortText = "fox jumped dog"; - - myText->setText(longText); - QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); - const qreal longWidth = myText->contentWidth(); - const qreal longHeight = myText->contentHeight(); - - myText->setText(mediumText); - QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); - const qreal mediumWidth = myText->contentWidth(); - const qreal mediumHeight = myText->contentHeight(); - - myText->setText(shortText); - QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); - const qreal shortWidth = myText->contentWidth(); - const qreal shortHeight = myText->contentHeight(); - - myText->setElideMode(QQuickText::ElideRight); - myText->setText(longText + QLatin1Char('\x9c') + mediumText + QLatin1Char('\x9c') + shortText); - - myText->setSize(QSizeF(longWidth, longHeight)); - QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); - - QCOMPARE(myText->contentWidth(), longWidth); - QCOMPARE(myText->contentHeight(), longHeight); - QCOMPARE(myText->truncated(), false); - - myText->setSize(QSizeF(mediumWidth, mediumHeight)); - QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); - - QCOMPARE(myText->contentWidth(), mediumWidth); - QCOMPARE(myText->contentHeight(), mediumHeight); -#ifdef Q_OS_MAC - QEXPECT_FAIL("Wrap", "QTBUG-24310", Continue); -#endif - QCOMPARE(myText->truncated(), true); - - myText->setSize(QSizeF(shortWidth, shortHeight)); - QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); - - QCOMPARE(myText->contentWidth(), shortWidth); - QCOMPARE(myText->contentHeight(), shortHeight); - QCOMPARE(myText->truncated(), true); -} - -QTEST_MAIN(tst_qquicktext) - -#include "tst_qquicktext.moc" diff --git a/tests/auto/qtquick2/qquicktextedit/data/Cursor.qml b/tests/auto/qtquick2/qquicktextedit/data/Cursor.qml deleted file mode 100644 index e5c1853fc5..0000000000 --- a/tests/auto/qtquick2/qquicktextedit/data/Cursor.qml +++ /dev/null @@ -1,5 +0,0 @@ -import QtQuick 2.0 - -Rectangle { - property string localProperty -} diff --git a/tests/auto/qtquick2/qquicktextedit/data/CursorRect.qml b/tests/auto/qtquick2/qquicktextedit/data/CursorRect.qml deleted file mode 100644 index cae3e63b72..0000000000 --- a/tests/auto/qtquick2/qquicktextedit/data/CursorRect.qml +++ /dev/null @@ -1,8 +0,0 @@ -import QtQuick 2.0 - -TextEdit { - focus: true - objectName: "myEdit" - width: 50 - text: "This is a long piece of text" -} diff --git a/tests/auto/qtquick2/qquicktextedit/data/alignments.qml b/tests/auto/qtquick2/qquicktextedit/data/alignments.qml deleted file mode 100644 index 7d365da8cb..0000000000 --- a/tests/auto/qtquick2/qquicktextedit/data/alignments.qml +++ /dev/null @@ -1,41 +0,0 @@ -import QtQuick 2.0 - -Rectangle { - id: top - width: 70; height: 70; - - property alias horizontalAlignment: t.horizontalAlignment - property alias verticalAlignment: t.verticalAlignment - property alias wrapMode: t.wrapMode - property alias running: timer.running - property string txt: "Test" - - Rectangle { - anchors.centerIn: parent - width: 40 - height: 40 - color: "green" - - TextEdit { - id: t - - anchors.fill: parent - horizontalAlignment: TextEdit.AlignRight - verticalAlignment: TextEdit.AlignBottom - wrapMode: TextEdit.WordWrap - text: top.txt - } - Timer { - id: timer - - interval: 1 - running: true - repeat: true - onTriggered: { - top.txt = top.txt + "
      more " + top.txt.length; - if (top.txt.length > 50) - running = false - } - } - } -} diff --git a/tests/auto/qtquick2/qquicktextedit/data/alignments_cb.png b/tests/auto/qtquick2/qquicktextedit/data/alignments_cb.png deleted file mode 100644 index 99de2192de..0000000000 Binary files a/tests/auto/qtquick2/qquicktextedit/data/alignments_cb.png and /dev/null differ diff --git a/tests/auto/qtquick2/qquicktextedit/data/alignments_cc.png b/tests/auto/qtquick2/qquicktextedit/data/alignments_cc.png deleted file mode 100644 index cb85251180..0000000000 Binary files a/tests/auto/qtquick2/qquicktextedit/data/alignments_cc.png and /dev/null differ diff --git a/tests/auto/qtquick2/qquicktextedit/data/alignments_ct.png b/tests/auto/qtquick2/qquicktextedit/data/alignments_ct.png deleted file mode 100644 index ddca549c82..0000000000 Binary files a/tests/auto/qtquick2/qquicktextedit/data/alignments_ct.png and /dev/null differ diff --git a/tests/auto/qtquick2/qquicktextedit/data/alignments_lb.png b/tests/auto/qtquick2/qquicktextedit/data/alignments_lb.png deleted file mode 100644 index 1b50a81f3d..0000000000 Binary files a/tests/auto/qtquick2/qquicktextedit/data/alignments_lb.png and /dev/null differ diff --git a/tests/auto/qtquick2/qquicktextedit/data/alignments_lc.png b/tests/auto/qtquick2/qquicktextedit/data/alignments_lc.png deleted file mode 100644 index f041b868f8..0000000000 Binary files a/tests/auto/qtquick2/qquicktextedit/data/alignments_lc.png and /dev/null differ diff --git a/tests/auto/qtquick2/qquicktextedit/data/alignments_lt.png b/tests/auto/qtquick2/qquicktextedit/data/alignments_lt.png deleted file mode 100644 index c75e0d158e..0000000000 Binary files a/tests/auto/qtquick2/qquicktextedit/data/alignments_lt.png and /dev/null differ diff --git a/tests/auto/qtquick2/qquicktextedit/data/alignments_rb.png b/tests/auto/qtquick2/qquicktextedit/data/alignments_rb.png deleted file mode 100644 index b06a5da715..0000000000 Binary files a/tests/auto/qtquick2/qquicktextedit/data/alignments_rb.png and /dev/null differ diff --git a/tests/auto/qtquick2/qquicktextedit/data/alignments_rc.png b/tests/auto/qtquick2/qquicktextedit/data/alignments_rc.png deleted file mode 100644 index e468857cd0..0000000000 Binary files a/tests/auto/qtquick2/qquicktextedit/data/alignments_rc.png and /dev/null differ diff --git a/tests/auto/qtquick2/qquicktextedit/data/alignments_rt.png b/tests/auto/qtquick2/qquicktextedit/data/alignments_rt.png deleted file mode 100644 index 576715ffce..0000000000 Binary files a/tests/auto/qtquick2/qquicktextedit/data/alignments_rt.png and /dev/null differ diff --git a/tests/auto/qtquick2/qquicktextedit/data/cursorTest.qml b/tests/auto/qtquick2/qquicktextedit/data/cursorTest.qml deleted file mode 100644 index 7bfc869403..0000000000 --- a/tests/auto/qtquick2/qquicktextedit/data/cursorTest.qml +++ /dev/null @@ -1,9 +0,0 @@ -import QtQuick 2.0 - -Rectangle { width: 300; height: 300; color: "white" - property string contextualProperty: "Hello" - TextEdit { text: "Hello world!"; id: textEditObject; objectName: "textEditObject" - resources: [ Component { id:cursor; Item { id:cursorInstance; objectName: "cursorInstance"; property string localProperty: contextualProperty } } ] - cursorDelegate: cursor - } -} diff --git a/tests/auto/qtquick2/qquicktextedit/data/cursorTestExternal.qml b/tests/auto/qtquick2/qquicktextedit/data/cursorTestExternal.qml deleted file mode 100644 index 7e916ec818..0000000000 --- a/tests/auto/qtquick2/qquicktextedit/data/cursorTestExternal.qml +++ /dev/null @@ -1,15 +0,0 @@ -import QtQuick 2.0 - -Rectangle { width: 300; height: 300; color: "white" - property string contextualProperty: "Hello" - TextEdit { - text: "Hello world!" - id: textEditObject; - objectName: "textEditObject" - cursorDelegate: Cursor { - id:cursorInstance; - objectName: "cursorInstance"; - localProperty: contextualProperty; - } - } -} diff --git a/tests/auto/qtquick2/qquicktextedit/data/cursorTestInline.qml b/tests/auto/qtquick2/qquicktextedit/data/cursorTestInline.qml deleted file mode 100644 index 786f39113c..0000000000 --- a/tests/auto/qtquick2/qquicktextedit/data/cursorTestInline.qml +++ /dev/null @@ -1,15 +0,0 @@ -import QtQuick 2.0 - -Rectangle { width: 300; height: 300; color: "white" - property string contextualProperty: "Hello" - TextEdit { - text: "Hello world!" - id: textEditObject - objectName: "textEditObject" - cursorDelegate: Item { - id:cursorInstance - objectName: "cursorInstance" - property string localProperty: contextualProperty - } - } -} diff --git a/tests/auto/qtquick2/qquicktextedit/data/cursorVisible.qml b/tests/auto/qtquick2/qquicktextedit/data/cursorVisible.qml deleted file mode 100644 index 49e9386947..0000000000 --- a/tests/auto/qtquick2/qquicktextedit/data/cursorVisible.qml +++ /dev/null @@ -1,6 +0,0 @@ -import QtQuick 2.0 - -Item { - width: 100 - height: 20 -} diff --git a/tests/auto/qtquick2/qquicktextedit/data/embeddedImagesLocal.qml b/tests/auto/qtquick2/qquicktextedit/data/embeddedImagesLocal.qml deleted file mode 100644 index 150f7bd898..0000000000 --- a/tests/auto/qtquick2/qquicktextedit/data/embeddedImagesLocal.qml +++ /dev/null @@ -1,6 +0,0 @@ -import QtQuick 2.0 - -TextEdit { - textFormat: TextEdit.RichText - text: "" -} diff --git a/tests/auto/qtquick2/qquicktextedit/data/embeddedImagesLocalError.qml b/tests/auto/qtquick2/qquicktextedit/data/embeddedImagesLocalError.qml deleted file mode 100644 index 067b6d72da..0000000000 --- a/tests/auto/qtquick2/qquicktextedit/data/embeddedImagesLocalError.qml +++ /dev/null @@ -1,6 +0,0 @@ -import QtQuick 2.0 - -TextEdit { - textFormat: TextEdit.RichText - text: "" -} diff --git a/tests/auto/qtquick2/qquicktextedit/data/embeddedImagesLocalRelative.qml b/tests/auto/qtquick2/qquicktextedit/data/embeddedImagesLocalRelative.qml deleted file mode 100644 index 200ded196d..0000000000 --- a/tests/auto/qtquick2/qquicktextedit/data/embeddedImagesLocalRelative.qml +++ /dev/null @@ -1,7 +0,0 @@ -import QtQuick 2.0 - -TextEdit { - textFormat: TextEdit.RichText - text: "" - baseUrl: "http/" -} diff --git a/tests/auto/qtquick2/qquicktextedit/data/embeddedImagesRemote.qml b/tests/auto/qtquick2/qquicktextedit/data/embeddedImagesRemote.qml deleted file mode 100644 index a823882692..0000000000 --- a/tests/auto/qtquick2/qquicktextedit/data/embeddedImagesRemote.qml +++ /dev/null @@ -1,6 +0,0 @@ -import QtQuick 2.0 - -TextEdit { - textFormat: TextEdit.RichText - text: "" -} diff --git a/tests/auto/qtquick2/qquicktextedit/data/embeddedImagesRemoteError.qml b/tests/auto/qtquick2/qquicktextedit/data/embeddedImagesRemoteError.qml deleted file mode 100644 index c6172b68dc..0000000000 --- a/tests/auto/qtquick2/qquicktextedit/data/embeddedImagesRemoteError.qml +++ /dev/null @@ -1,6 +0,0 @@ -import QtQuick 2.0 - -TextEdit { - textFormat: TextEdit.RichText - text: "" -} diff --git a/tests/auto/qtquick2/qquicktextedit/data/embeddedImagesRemoteRelative.qml b/tests/auto/qtquick2/qquicktextedit/data/embeddedImagesRemoteRelative.qml deleted file mode 100644 index ee39e089ea..0000000000 --- a/tests/auto/qtquick2/qquicktextedit/data/embeddedImagesRemoteRelative.qml +++ /dev/null @@ -1,7 +0,0 @@ -import QtQuick 2.0 - -TextEdit { - textFormat: TextEdit.RichText - text: "" - baseUrl: "http://127.0.0.1:42332/text.html" -} diff --git a/tests/auto/qtquick2/qquicktextedit/data/geometrySignals.qml b/tests/auto/qtquick2/qquicktextedit/data/geometrySignals.qml deleted file mode 100644 index 3dbe61c74b..0000000000 --- a/tests/auto/qtquick2/qquicktextedit/data/geometrySignals.qml +++ /dev/null @@ -1,12 +0,0 @@ -import QtQuick 2.0 - -Item { - width: 400; height: 500; - property int bindingWidth: text.width - property int bindingHeight: text.height - - TextInput { - id: text - anchors.fill: parent - } -} diff --git a/tests/auto/qtquick2/qquicktextedit/data/horizontalAlignment_RightToLeft.qml b/tests/auto/qtquick2/qquicktextedit/data/horizontalAlignment_RightToLeft.qml deleted file mode 100644 index 2163838488..0000000000 --- a/tests/auto/qtquick2/qquicktextedit/data/horizontalAlignment_RightToLeft.qml +++ /dev/null @@ -1,25 +0,0 @@ -import QtQuick 2.0 - -Rectangle { - id: top - width: 200; height: 70; - - property alias horizontalAlignment: text.horizontalAlignment - property string text: "اختبا" - - Rectangle { - anchors.centerIn: parent - width: 200 - height: 20 - color: "green" - - TextEdit { - id: text - objectName: "text" - anchors.fill: parent - text: top.text - focus: true - textFormat: TextEdit.AutoText - } - } -} diff --git a/tests/auto/qtquick2/qquicktextedit/data/http/ErrItem.qml b/tests/auto/qtquick2/qquicktextedit/data/http/ErrItem.qml deleted file mode 100644 index 68c0e0c093..0000000000 --- a/tests/auto/qtquick2/qquicktextedit/data/http/ErrItem.qml +++ /dev/null @@ -1,7 +0,0 @@ -import QtQuick 2.0 - -Item{ - Fungus{ - palatable: false; - } -} diff --git a/tests/auto/qtquick2/qquicktextedit/data/http/NormItem.qml b/tests/auto/qtquick2/qquicktextedit/data/http/NormItem.qml deleted file mode 100644 index 2e4c1ed440..0000000000 --- a/tests/auto/qtquick2/qquicktextedit/data/http/NormItem.qml +++ /dev/null @@ -1,6 +0,0 @@ -import QtQuick 2.0 - -Item { - objectName: "delegateOkay" - Rectangle { } -} diff --git a/tests/auto/qtquick2/qquicktextedit/data/http/cursorHttpTest.qml b/tests/auto/qtquick2/qquicktextedit/data/http/cursorHttpTest.qml deleted file mode 100644 index be4526e22b..0000000000 --- a/tests/auto/qtquick2/qquicktextedit/data/http/cursorHttpTest.qml +++ /dev/null @@ -1,22 +0,0 @@ -import QtQuick 2.0 - -Rectangle { width: 300; height: 300; color: "white" - resources: [ - Component { id:cursorFail; FailItem { objectName: "delegateFail" } }, - Component { id:cursorWait; WaitItem { objectName: "delegateSlow" } }, - Component { id:cursorNorm; NormItem { objectName: "delegateOkay" } }, - Component { id:cursorErr; ErrItem { objectName: "delegateErrorA" } } - ] - TextEdit { - cursorDelegate: cursorFail - } - TextEdit { - cursorDelegate: cursorWait - } - TextEdit { - cursorDelegate: cursorNorm - } - TextEdit { - cursorDelegate: cursorErr - } -} diff --git a/tests/auto/qtquick2/qquicktextedit/data/http/cursorHttpTestFail1.qml b/tests/auto/qtquick2/qquicktextedit/data/http/cursorHttpTestFail1.qml deleted file mode 100644 index 1d7763f913..0000000000 --- a/tests/auto/qtquick2/qquicktextedit/data/http/cursorHttpTestFail1.qml +++ /dev/null @@ -1,18 +0,0 @@ -import QtQuick 2.0 - -Rectangle { width: 300; height: 300; color: "white" - resources: [ - Component { id:cursorFail; FailItem { objectName: "delegateFail" } }, - Component { id:cursorWait; WaitItem { objectName: "delegateSlow" } }, - Component { id:cursorNorm; NormItem { objectName: "delegateOkay" } } - ] - TextEdit { - cursorDelegate: cursorFail - } - TextEdit { - cursorDelegate: cursorWait - } - TextEdit { - cursorDelegate: cursorNorm - } -} diff --git a/tests/auto/qtquick2/qquicktextedit/data/http/cursorHttpTestFail2.qml b/tests/auto/qtquick2/qquicktextedit/data/http/cursorHttpTestFail2.qml deleted file mode 100644 index c82ec02e68..0000000000 --- a/tests/auto/qtquick2/qquicktextedit/data/http/cursorHttpTestFail2.qml +++ /dev/null @@ -1,18 +0,0 @@ -import QtQuick 2.0 - -Rectangle { width: 300; height: 300; color: "white" - resources: [ - Component { id:cursorWait; WaitItem { objectName: "delegateSlow" } }, - Component { id:cursorNorm; NormItem { objectName: "delegateOkay" } }, - Component { id:cursorErr; ErrItem { objectName: "delegateErrorA" } } - ] - TextEdit { - cursorDelegate: cursorWait - } - TextEdit { - cursorDelegate: cursorNorm - } - TextEdit { - cursorDelegate: cursorErr - } -} diff --git a/tests/auto/qtquick2/qquicktextedit/data/http/cursorHttpTestPass.qml b/tests/auto/qtquick2/qquicktextedit/data/http/cursorHttpTestPass.qml deleted file mode 100644 index 96d582c95d..0000000000 --- a/tests/auto/qtquick2/qquicktextedit/data/http/cursorHttpTestPass.qml +++ /dev/null @@ -1,18 +0,0 @@ -import QtQuick 2.0 - -Rectangle { width: 300; height: 300; color: "white" - resources: [ - Component { id:cursorWait; WaitItem { objectName: "delegateSlow" } }, - Component { id:cursorNorm; NormItem { objectName: "delegateOkay" } } - ] - TextEdit { - cursorDelegate: cursorWait - text: "Hello" - } - TextEdit { - objectName: "textEditObject" - cursorDelegate: cursorNorm - focus: true; - text: "Hello" - } -} diff --git a/tests/auto/qtquick2/qquicktextedit/data/http/exists.png b/tests/auto/qtquick2/qquicktextedit/data/http/exists.png deleted file mode 100644 index 399bd0b1d9..0000000000 Binary files a/tests/auto/qtquick2/qquicktextedit/data/http/exists.png and /dev/null differ diff --git a/tests/auto/qtquick2/qquicktextedit/data/http/qmldir b/tests/auto/qtquick2/qquicktextedit/data/http/qmldir deleted file mode 100644 index 886e6ffec0..0000000000 --- a/tests/auto/qtquick2/qquicktextedit/data/http/qmldir +++ /dev/null @@ -1,4 +0,0 @@ -ErrItem ErrItem.qml -NormItem NormItem.qml -FailItem FailItem.qml -WaitItem WaitItem.qml diff --git a/tests/auto/qtquick2/qquicktextedit/data/httpfail/FailItem.qml b/tests/auto/qtquick2/qquicktextedit/data/httpfail/FailItem.qml deleted file mode 100644 index 8161843479..0000000000 --- a/tests/auto/qtquick2/qquicktextedit/data/httpfail/FailItem.qml +++ /dev/null @@ -1,5 +0,0 @@ -import QtQuick 2.0 - -Item { - Rectangle { } -} diff --git a/tests/auto/qtquick2/qquicktextedit/data/httpslow/WaitItem.qml b/tests/auto/qtquick2/qquicktextedit/data/httpslow/WaitItem.qml deleted file mode 100644 index 8161843479..0000000000 --- a/tests/auto/qtquick2/qquicktextedit/data/httpslow/WaitItem.qml +++ /dev/null @@ -1,5 +0,0 @@ -import QtQuick 2.0 - -Item { - Rectangle { } -} diff --git a/tests/auto/qtquick2/qquicktextedit/data/inputContext.qml b/tests/auto/qtquick2/qquicktextedit/data/inputContext.qml deleted file mode 100644 index a37c77e3bf..0000000000 --- a/tests/auto/qtquick2/qquicktextedit/data/inputContext.qml +++ /dev/null @@ -1,7 +0,0 @@ -import QtQuick 2.0 - -TextEdit { - width: 200 - text: "supercalifra" - focus: true -} diff --git a/tests/auto/qtquick2/qquicktextedit/data/inputMethodEvent.qml b/tests/auto/qtquick2/qquicktextedit/data/inputMethodEvent.qml deleted file mode 100644 index e3f629ce3e..0000000000 --- a/tests/auto/qtquick2/qquicktextedit/data/inputMethodEvent.qml +++ /dev/null @@ -1,5 +0,0 @@ -import QtQuick 2.0 - -TextEdit { - focus: true -} diff --git a/tests/auto/qtquick2/qquicktextedit/data/inputmethodhints.qml b/tests/auto/qtquick2/qquicktextedit/data/inputmethodhints.qml deleted file mode 100644 index dec3b978e7..0000000000 --- a/tests/auto/qtquick2/qquicktextedit/data/inputmethodhints.qml +++ /dev/null @@ -1,6 +0,0 @@ -import QtQuick 2.0 - -TextEdit { - text: "Hello world!" - inputMethodHints: Qt.ImhNoPredictiveText -} diff --git a/tests/auto/qtquick2/qquicktextedit/data/linkActivated.qml b/tests/auto/qtquick2/qquicktextedit/data/linkActivated.qml deleted file mode 100644 index d3bba82b59..0000000000 --- a/tests/auto/qtquick2/qquicktextedit/data/linkActivated.qml +++ /dev/null @@ -1,6 +0,0 @@ -import QtQuick 2.0 - -TextEdit { - textFormat: TextEdit.RichText - text: "Test link" -} diff --git a/tests/auto/qtquick2/qquicktextedit/data/mouseselection_default.qml b/tests/auto/qtquick2/qquicktextedit/data/mouseselection_default.qml deleted file mode 100644 index ac32f4ced7..0000000000 --- a/tests/auto/qtquick2/qquicktextedit/data/mouseselection_default.qml +++ /dev/null @@ -1,7 +0,0 @@ -import QtQuick 2.0 - -TextEdit { - focus: true - text: "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ" - selectByMouse: false -} diff --git a/tests/auto/qtquick2/qquicktextedit/data/mouseselection_false.qml b/tests/auto/qtquick2/qquicktextedit/data/mouseselection_false.qml deleted file mode 100644 index ac32f4ced7..0000000000 --- a/tests/auto/qtquick2/qquicktextedit/data/mouseselection_false.qml +++ /dev/null @@ -1,7 +0,0 @@ -import QtQuick 2.0 - -TextEdit { - focus: true - text: "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ" - selectByMouse: false -} diff --git a/tests/auto/qtquick2/qquicktextedit/data/mouseselection_false_words.qml b/tests/auto/qtquick2/qquicktextedit/data/mouseselection_false_words.qml deleted file mode 100644 index 86aea46a85..0000000000 --- a/tests/auto/qtquick2/qquicktextedit/data/mouseselection_false_words.qml +++ /dev/null @@ -1,8 +0,0 @@ -import QtQuick 2.0 - -TextEdit { - focus: true - text: "0123456789 ABCDEFGHIJKLMNOPQRSTUVWXYZ" - selectByMouse: false - mouseSelectionMode: TextEdit.SelectWords -} diff --git a/tests/auto/qtquick2/qquicktextedit/data/mouseselection_true.qml b/tests/auto/qtquick2/qquicktextedit/data/mouseselection_true.qml deleted file mode 100644 index 7c7cb0b6fc..0000000000 --- a/tests/auto/qtquick2/qquicktextedit/data/mouseselection_true.qml +++ /dev/null @@ -1,7 +0,0 @@ -import QtQuick 2.0 - -TextEdit { - focus: true - text: "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ" - selectByMouse: true -} diff --git a/tests/auto/qtquick2/qquicktextedit/data/mouseselection_true_words.qml b/tests/auto/qtquick2/qquicktextedit/data/mouseselection_true_words.qml deleted file mode 100644 index c356999220..0000000000 --- a/tests/auto/qtquick2/qquicktextedit/data/mouseselection_true_words.qml +++ /dev/null @@ -1,8 +0,0 @@ -import QtQuick 2.0 - -TextEdit { - focus: true - text: "0123456789 ABCDEFGHIJKLMNOPQRSTUVWXYZ" - selectByMouse: true - mouseSelectionMode: TextEdit.SelectWords -} diff --git a/tests/auto/qtquick2/qquicktextedit/data/mouseselectionmode_characters.qml b/tests/auto/qtquick2/qquicktextedit/data/mouseselectionmode_characters.qml deleted file mode 100644 index c1fe42fd57..0000000000 --- a/tests/auto/qtquick2/qquicktextedit/data/mouseselectionmode_characters.qml +++ /dev/null @@ -1,8 +0,0 @@ -import QtQuick 2.0 - -TextEdit { - focus: true - text: "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ" - selectByMouse: true - mouseSelectionMode: TextEdit.SelectCharacters -} diff --git a/tests/auto/qtquick2/qquicktextedit/data/mouseselectionmode_default.qml b/tests/auto/qtquick2/qquicktextedit/data/mouseselectionmode_default.qml deleted file mode 100644 index 7c7cb0b6fc..0000000000 --- a/tests/auto/qtquick2/qquicktextedit/data/mouseselectionmode_default.qml +++ /dev/null @@ -1,7 +0,0 @@ -import QtQuick 2.0 - -TextEdit { - focus: true - text: "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ" - selectByMouse: true -} diff --git a/tests/auto/qtquick2/qquicktextedit/data/mouseselectionmode_words.qml b/tests/auto/qtquick2/qquicktextedit/data/mouseselectionmode_words.qml deleted file mode 100644 index 0a372bbf83..0000000000 --- a/tests/auto/qtquick2/qquicktextedit/data/mouseselectionmode_words.qml +++ /dev/null @@ -1,8 +0,0 @@ -import QtQuick 2.0 - -TextEdit { - focus: true - text: "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ" - selectByMouse: true - mouseSelectionMode: TextEdit.SelectWords -} diff --git a/tests/auto/qtquick2/qquicktextedit/data/navigation.qml b/tests/auto/qtquick2/qquicktextedit/data/navigation.qml deleted file mode 100644 index 0201c62b3c..0000000000 --- a/tests/auto/qtquick2/qquicktextedit/data/navigation.qml +++ /dev/null @@ -1,24 +0,0 @@ -import QtQuick 2.0 - -Rectangle { - property variant myInput: input - - width: 800; height: 600; color: "blue" - - Item { - id: firstItem; - KeyNavigation.right: input - } - - TextEdit { id: input; focus: true - KeyNavigation.left: firstItem - KeyNavigation.right: lastItem - KeyNavigation.up: firstItem - KeyNavigation.down: lastItem - text: "a" - } - Item { - id: lastItem - KeyNavigation.left: input - } -} diff --git a/tests/auto/qtquick2/qquicktextedit/data/openInputPanel.qml b/tests/auto/qtquick2/qquicktextedit/data/openInputPanel.qml deleted file mode 100644 index d3aecf21be..0000000000 --- a/tests/auto/qtquick2/qquicktextedit/data/openInputPanel.qml +++ /dev/null @@ -1,7 +0,0 @@ -import QtQuick 2.0 - -TextEdit { - width: 100; height: 100 - text: "Hello world" - focus: false -} diff --git a/tests/auto/qtquick2/qquicktextedit/data/persistentSelection.qml b/tests/auto/qtquick2/qquicktextedit/data/persistentSelection.qml deleted file mode 100644 index fb2fe0cd6c..0000000000 --- a/tests/auto/qtquick2/qquicktextedit/data/persistentSelection.qml +++ /dev/null @@ -1,8 +0,0 @@ -import QtQuick 2.0 - -TextEdit { - property string selected: selectedText - - text: "Hello World!" - focus: true -} diff --git a/tests/auto/qtquick2/qquicktextedit/data/positionAt.qml b/tests/auto/qtquick2/qquicktextedit/data/positionAt.qml deleted file mode 100644 index 19093281fe..0000000000 --- a/tests/auto/qtquick2/qquicktextedit/data/positionAt.qml +++ /dev/null @@ -1,9 +0,0 @@ -import QtQuick 2.0 - -TextEdit { - focus: true - objectName: "myInput" - width: 50 - height: 25 - text: "This is\n a long piece of text" -} diff --git a/tests/auto/qtquick2/qquicktextedit/data/qtbug-22058.qml b/tests/auto/qtquick2/qquicktextedit/data/qtbug-22058.qml deleted file mode 100644 index 8ad1514fbf..0000000000 --- a/tests/auto/qtquick2/qquicktextedit/data/qtbug-22058.qml +++ /dev/null @@ -1,39 +0,0 @@ -import QtQuick 2.0 - -Rectangle { - property variant inputField: textedit - height: 200 - width: 200 - - Rectangle { - height: parent.height /2 - width: parent.width - color: "transparent" - border.color: "black" - border.width: 4 - Text { - anchors.centerIn: parent - height: parent.height * .95 - width: parent.width * .95 - text: textedit.text - } - } - - Rectangle { - height: parent.height /2 - width: parent.width - color: "transparent" - border.color: "black" - border.width: 4 - anchors.bottom: parent.bottom - TextEdit { - id: textedit - anchors.centerIn: parent - height: parent.height * .95 - width: parent.width * .95 - focus: true - wrapMode: TextEdit.WordWrap - text: "" - } - } -} diff --git a/tests/auto/qtquick2/qquicktextedit/data/readOnly.qml b/tests/auto/qtquick2/qquicktextedit/data/readOnly.qml deleted file mode 100644 index 085adba5fb..0000000000 --- a/tests/auto/qtquick2/qquicktextedit/data/readOnly.qml +++ /dev/null @@ -1,12 +0,0 @@ -import QtQuick 2.0 - -Rectangle { - property variant myInput: input - - width: 800; height: 600; color: "blue" - - TextEdit { id: input; focus: true - readOnly: true - text: "I am the very model of a modern major general.\n" - } -} diff --git a/tests/auto/qtquick2/qquicktextedit/qquicktextedit.pro b/tests/auto/qtquick2/qquicktextedit/qquicktextedit.pro deleted file mode 100644 index 6f74761b7b..0000000000 --- a/tests/auto/qtquick2/qquicktextedit/qquicktextedit.pro +++ /dev/null @@ -1,16 +0,0 @@ -CONFIG += testcase -TARGET = tst_qquicktextedit -macx:CONFIG -= app_bundle - -SOURCES += tst_qquicktextedit.cpp \ - ../../shared/testhttpserver.cpp - -HEADERS += ../../shared/testhttpserver.h - -include (../../shared/util.pri) - -testDataFiles.files = data -testDataFiles.path = . -DEPLOYMENT += testDataFiles - -QT += core-private gui-private v8-private declarative-private quick-private opengl-private network widgets-private testlib diff --git a/tests/auto/qtquick2/qquicktextedit/tst_qquicktextedit.cpp b/tests/auto/qtquick2/qquicktextedit/tst_qquicktextedit.cpp deleted file mode 100644 index 41c8546688..0000000000 --- a/tests/auto/qtquick2/qquicktextedit/tst_qquicktextedit.cpp +++ /dev/null @@ -1,3884 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include -#include -#include "../../shared/testhttpserver.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "../../shared/util.h" -#include "../../shared/platforminputcontext.h" -#include - -#ifdef Q_OS_MAC -#include -#endif - - -Q_DECLARE_METATYPE(QQuickTextEdit::SelectionMode) -DEFINE_BOOL_CONFIG_OPTION(qmlDisableDistanceField, QML_DISABLE_DISTANCEFIELD) - -QString createExpectedFileIfNotFound(const QString& filebasename, const QImage& actual) -{ - // XXX This will be replaced by some clever persistent platform image store. - QString persistent_dir = QDeclarativeDataTest::instance()->dataDirectory(); - QString arch = "unknown-architecture"; // QTest needs to help with this. - - QString expectfile = persistent_dir + QDir::separator() + filebasename + "-" + arch + ".png"; - - if (!QFile::exists(expectfile)) { - actual.save(expectfile); - qWarning() << "created" << expectfile; - } - - return expectfile; -} - -typedef QPair Key; - -class tst_qquicktextedit : public QDeclarativeDataTest - -{ - Q_OBJECT -public: - tst_qquicktextedit(); - -private slots: - void cleanup(); - void text(); - void width(); - void wrap(); - void textFormat(); - void alignments(); - void alignments_data(); - - // ### these tests may be trivial - void hAlign(); - void hAlign_RightToLeft(); - void vAlign(); - void font(); - void color(); - void textMargin(); - void persistentSelection(); - void focusOnPress(); - void selection(); - void isRightToLeft_data(); - void isRightToLeft(); - void keySelection(); - void moveCursorSelection_data(); - void moveCursorSelection(); - void moveCursorSelectionSequence_data(); - void moveCursorSelectionSequence(); - void mouseSelection_data(); - void mouseSelection(); - void mouseSelectionMode_data(); - void mouseSelectionMode(); - void dragMouseSelection(); - void inputMethodHints(); - - void positionAt(); - - void linkActivated(); - - void cursorDelegate_data(); - void cursorDelegate(); - void cursorVisible(); - void delegateLoading_data(); - void delegateLoading(); - void navigation(); - void readOnly(); - void copyAndPaste(); - void canPaste(); - void canPasteEmpty(); - void textInput(); - void inputMethodUpdate(); - void openInputPanel(); - void geometrySignals(); - void pastingRichText_QTBUG_14003(); - void implicitSize_data(); - void implicitSize(); - void contentSize(); - - void preeditCursorRectangle(); - void inputMethodComposing(); - void cursorRectangleSize(); - - void getText_data(); - void getText(); - void getFormattedText_data(); - void getFormattedText(); - void insert_data(); - void insert(); - void remove_data(); - void remove(); - - void keySequence_data(); - void keySequence(); - - void undo_data(); - void undo(); - void redo_data(); - void redo(); - void undo_keypressevents_data(); - void undo_keypressevents(); - - void baseUrl(); - void embeddedImages(); - void embeddedImages_data(); - - void emptytags_QTBUG_22058(); - -private: - void simulateKeys(QWindow *window, const QList &keys); - void simulateKeys(QWindow *window, const QKeySequence &sequence); - - void simulateKey(QQuickView *, int key, Qt::KeyboardModifiers modifiers = 0); - - QStringList standard; - QStringList richText; - - QStringList hAlignmentStrings; - QStringList vAlignmentStrings; - - QList vAlignments; - QList hAlignments; - - QStringList colorStrings; - - QDeclarativeEngine engine; -}; - -typedef QList IntList; -Q_DECLARE_METATYPE(IntList) - -typedef QList KeyList; -Q_DECLARE_METATYPE(KeyList) - -Q_DECLARE_METATYPE(QQuickTextEdit::TextFormat) - -void tst_qquicktextedit::simulateKeys(QWindow *window, const QList &keys) -{ - for (int i = 0; i < keys.count(); ++i) { - const int key = keys.at(i).first; - const int modifiers = key & Qt::KeyboardModifierMask; - const QString text = !keys.at(i).second.isNull() ? QString(keys.at(i).second) : QString(); - - QKeyEvent press(QEvent::KeyPress, Qt::Key(key), Qt::KeyboardModifiers(modifiers), text); - QKeyEvent release(QEvent::KeyRelease, Qt::Key(key), Qt::KeyboardModifiers(modifiers), text); - - QGuiApplication::sendEvent(window, &press); - QGuiApplication::sendEvent(window, &release); - } -} - -void tst_qquicktextedit::simulateKeys(QWindow *window, const QKeySequence &sequence) -{ - for (int i = 0; i < sequence.count(); ++i) { - const int key = sequence[i]; - const int modifiers = key & Qt::KeyboardModifierMask; - - QTest::keyClick(window, Qt::Key(key & ~modifiers), Qt::KeyboardModifiers(modifiers)); - } -} - -QList &operator <<(QList &keys, const QKeySequence &sequence) -{ - for (int i = 0; i < sequence.count(); ++i) - keys << Key(sequence[i], QChar()); - return keys; -} - -template QList &operator <<(QList &keys, const char (&characters)[N]) -{ - for (int i = 0; i < N - 1; ++i) { - int key = QTest::asciiToKey(characters[i]); - QChar character = QLatin1Char(characters[i]); - keys << Key(key, character); - } - return keys; -} - -QList &operator <<(QList &keys, Qt::Key key) -{ - keys << Key(key, QChar()); - return keys; -} - -tst_qquicktextedit::tst_qquicktextedit() -{ - standard << "the quick brown fox jumped over the lazy dog" - << "the quick brown fox\n jumped over the lazy dog" - << "Hello, world!" - << "!dlrow ,olleH"; - - richText << "the quick brown fox jumped over the lazy dog" - << "the quick brown fox
      jumped over the lazy dog
      "; - - hAlignmentStrings << "AlignLeft" - << "AlignRight" - << "AlignHCenter"; - - vAlignmentStrings << "AlignTop" - << "AlignBottom" - << "AlignVCenter"; - - hAlignments << Qt::AlignLeft - << Qt::AlignRight - << Qt::AlignHCenter; - - vAlignments << Qt::AlignTop - << Qt::AlignBottom - << Qt::AlignVCenter; - - colorStrings << "aliceblue" - << "antiquewhite" - << "aqua" - << "darkkhaki" - << "darkolivegreen" - << "dimgray" - << "palevioletred" - << "lightsteelblue" - << "#000000" - << "#AAAAAA" - << "#FFFFFF" - << "#2AC05F"; - // - // need a different test to do alpha channel test - // << "#AA0011DD" - // << "#00F16B11"; - // -} - -void tst_qquicktextedit::cleanup() -{ - // ensure not even skipped tests with custom input context leave it dangling - QInputMethodPrivate *inputMethodPrivate = QInputMethodPrivate::get(qApp->inputMethod()); - inputMethodPrivate->testContext = 0; -} - -void tst_qquicktextedit::text() -{ - { - QDeclarativeComponent texteditComponent(&engine); - texteditComponent.setData("import QtQuick 2.0\nTextEdit { text: \"\" }", QUrl()); - QQuickTextEdit *textEditObject = qobject_cast(texteditComponent.create()); - - QVERIFY(textEditObject != 0); - QCOMPARE(textEditObject->text(), QString("")); - QCOMPARE(textEditObject->length(), 0); - } - - for (int i = 0; i < standard.size(); i++) - { - QString componentStr = "import QtQuick 2.0\nTextEdit { text: \"" + standard.at(i) + "\" }"; - QDeclarativeComponent texteditComponent(&engine); - texteditComponent.setData(componentStr.toLatin1(), QUrl()); - QQuickTextEdit *textEditObject = qobject_cast(texteditComponent.create()); - - QVERIFY(textEditObject != 0); - QCOMPARE(textEditObject->text(), standard.at(i)); - QCOMPARE(textEditObject->length(), standard.at(i).length()); - } - - for (int i = 0; i < richText.size(); i++) - { - QString componentStr = "import QtQuick 2.0\nTextEdit { text: \"" + richText.at(i) + "\" }"; - QDeclarativeComponent texteditComponent(&engine); - texteditComponent.setData(componentStr.toLatin1(), QUrl()); - - QQuickTextEdit *textEditObject = qobject_cast(texteditComponent.create()); - - QVERIFY(textEditObject != 0); - - QString expected = richText.at(i); - expected.replace(QRegExp("\\\\(.)"),"\\1"); - QCOMPARE(textEditObject->text(), expected); - QCOMPARE(textEditObject->length(), expected.length()); - } - - for (int i = 0; i < standard.size(); i++) - { - QString componentStr = "import QtQuick 2.0\nTextEdit { textFormat: TextEdit.RichText; text: \"" + standard.at(i) + "\" }"; - QDeclarativeComponent texteditComponent(&engine); - texteditComponent.setData(componentStr.toLatin1(), QUrl()); - QQuickTextEdit *textEditObject = qobject_cast(texteditComponent.create()); - - QVERIFY(textEditObject != 0); - - QString actual = textEditObject->text(); - QString expected = standard.at(i); - actual.remove(QRegExp(".*]*>")); - actual.remove(QRegExp("(<[^>]*>)+")); - expected.remove("\n"); - QCOMPARE(actual.simplified(), expected); - QCOMPARE(textEditObject->length(), expected.length()); - } - - for (int i = 0; i < richText.size(); i++) - { - QString componentStr = "import QtQuick 2.0\nTextEdit { textFormat: TextEdit.RichText; text: \"" + richText.at(i) + "\" }"; - QDeclarativeComponent texteditComponent(&engine); - texteditComponent.setData(componentStr.toLatin1(), QUrl()); - QQuickTextEdit *textEditObject = qobject_cast(texteditComponent.create()); - - QVERIFY(textEditObject != 0); - QString actual = textEditObject->text(); - QString expected = richText.at(i); - actual.replace(QRegExp(".*]*>"),""); - actual.replace(QRegExp("(<[^>]*>)+"),"<>"); - expected.replace(QRegExp("(<[^>]*>)+"),"<>"); - QCOMPARE(actual.simplified(),expected.simplified()); - - expected.replace("<>", " "); - QCOMPARE(textEditObject->length(), expected.simplified().length()); - } - - for (int i = 0; i < standard.size(); i++) - { - QString componentStr = "import QtQuick 2.0\nTextEdit { textFormat: TextEdit.AutoText; text: \"" + standard.at(i) + "\" }"; - QDeclarativeComponent texteditComponent(&engine); - texteditComponent.setData(componentStr.toLatin1(), QUrl()); - QQuickTextEdit *textEditObject = qobject_cast(texteditComponent.create()); - - QVERIFY(textEditObject != 0); - QCOMPARE(textEditObject->text(), standard.at(i)); - QCOMPARE(textEditObject->length(), standard.at(i).length()); - } - - for (int i = 0; i < richText.size(); i++) - { - QString componentStr = "import QtQuick 2.0\nTextEdit { textFormat: TextEdit.AutoText; text: \"" + richText.at(i) + "\" }"; - QDeclarativeComponent texteditComponent(&engine); - texteditComponent.setData(componentStr.toLatin1(), QUrl()); - QQuickTextEdit *textEditObject = qobject_cast(texteditComponent.create()); - - QVERIFY(textEditObject != 0); - QString actual = textEditObject->text(); - QString expected = richText.at(i); - actual.replace(QRegExp(".*]*>"),""); - actual.replace(QRegExp("(<[^>]*>)+"),"<>"); - expected.replace(QRegExp("(<[^>]*>)+"),"<>"); - QCOMPARE(actual.simplified(),expected.simplified()); - - expected.replace("<>", " "); - QCOMPARE(textEditObject->length(), expected.simplified().length()); - } -} - -void tst_qquicktextedit::width() -{ - // uses Font metrics to find the width for standard and document to find the width for rich - { - QDeclarativeComponent texteditComponent(&engine); - texteditComponent.setData("import QtQuick 2.0\nTextEdit { text: \"\" }", QUrl()); - QQuickTextEdit *textEditObject = qobject_cast(texteditComponent.create()); - - QVERIFY(textEditObject != 0); - QCOMPARE(textEditObject->width(), 0.0); - } - - bool requiresUnhintedMetrics = !qmlDisableDistanceField(); - - for (int i = 0; i < standard.size(); i++) - { - QString componentStr = "import QtQuick 2.0\nTextEdit { text: \"" + standard.at(i) + "\" }"; - QDeclarativeComponent texteditComponent(&engine); - texteditComponent.setData(componentStr.toLatin1(), QUrl()); - QQuickTextEdit *textEditObject = qobject_cast(texteditComponent.create()); - - QString s = standard.at(i); - s.replace(QLatin1Char('\n'), QChar::LineSeparator); - - QTextLayout layout(s); - layout.setFont(textEditObject->font()); - layout.setFlags(Qt::TextExpandTabs | Qt::TextShowMnemonic); - if (requiresUnhintedMetrics) { - QTextOption option; - option.setUseDesignMetrics(true); - layout.setTextOption(option); - } - - layout.beginLayout(); - forever { - QTextLine line = layout.createLine(); - if (!line.isValid()) - break; - } - - layout.endLayout(); - - qreal metricWidth = ceil(layout.boundingRect().width()); - - QVERIFY(textEditObject != 0); - QCOMPARE(textEditObject->width(), qreal(metricWidth)); - } - - for (int i = 0; i < richText.size(); i++) - { - QTextDocument document; - document.setHtml(richText.at(i)); - document.setDocumentMargin(0); - if (requiresUnhintedMetrics) - document.setUseDesignMetrics(true); - - int documentWidth = ceil(document.idealWidth()); - - QString componentStr = "import QtQuick 2.0\nTextEdit { textFormat: TextEdit.RichText; text: \"" + richText.at(i) + "\" }"; - QDeclarativeComponent texteditComponent(&engine); - texteditComponent.setData(componentStr.toLatin1(), QUrl()); - QQuickTextEdit *textEditObject = qobject_cast(texteditComponent.create()); - - QVERIFY(textEditObject != 0); - QCOMPARE(textEditObject->width(), qreal(documentWidth)); - } -} - -void tst_qquicktextedit::wrap() -{ - // for specified width and wrap set true - { - QDeclarativeComponent texteditComponent(&engine); - texteditComponent.setData("import QtQuick 2.0\nTextEdit { text: \"\"; wrapMode: TextEdit.WordWrap; width: 300 }", QUrl()); - QQuickTextEdit *textEditObject = qobject_cast(texteditComponent.create()); - - QVERIFY(textEditObject != 0); - QCOMPARE(textEditObject->width(), 300.); - } - - for (int i = 0; i < standard.size(); i++) - { - QString componentStr = "import QtQuick 2.0\nTextEdit { wrapMode: TextEdit.WordWrap; width: 300; text: \"" + standard.at(i) + "\" }"; - QDeclarativeComponent texteditComponent(&engine); - texteditComponent.setData(componentStr.toLatin1(), QUrl()); - QQuickTextEdit *textEditObject = qobject_cast(texteditComponent.create()); - - QVERIFY(textEditObject != 0); - QCOMPARE(textEditObject->width(), 300.); - } - - for (int i = 0; i < richText.size(); i++) - { - QString componentStr = "import QtQuick 2.0\nTextEdit { wrapMode: TextEdit.WordWrap; width: 300; text: \"" + richText.at(i) + "\" }"; - QDeclarativeComponent texteditComponent(&engine); - texteditComponent.setData(componentStr.toLatin1(), QUrl()); - QQuickTextEdit *textEditObject = qobject_cast(texteditComponent.create()); - - QVERIFY(textEditObject != 0); - QCOMPARE(textEditObject->width(), 300.); - } - -} - -void tst_qquicktextedit::textFormat() -{ - { - QDeclarativeComponent textComponent(&engine); - textComponent.setData("import QtQuick 2.0\nTextEdit { text: \"Hello\"; textFormat: Text.RichText }", QUrl::fromLocalFile("")); - QQuickTextEdit *textObject = qobject_cast(textComponent.create()); - - QVERIFY(textObject != 0); - QVERIFY(textObject->textFormat() == QQuickTextEdit::RichText); - } - { - QDeclarativeComponent textComponent(&engine); - textComponent.setData("import QtQuick 2.0\nTextEdit { text: \"Hello\"; textFormat: Text.PlainText }", QUrl::fromLocalFile("")); - QQuickTextEdit *textObject = qobject_cast(textComponent.create()); - - QVERIFY(textObject != 0); - QVERIFY(textObject->textFormat() == QQuickTextEdit::PlainText); - } -} - -void tst_qquicktextedit::alignments_data() -{ - QTest::addColumn("hAlign"); - QTest::addColumn("vAlign"); - QTest::addColumn("expectfile"); - - QTest::newRow("LT") << int(Qt::AlignLeft) << int(Qt::AlignTop) << "alignments_lt"; - QTest::newRow("RT") << int(Qt::AlignRight) << int(Qt::AlignTop) << "alignments_rt"; - QTest::newRow("CT") << int(Qt::AlignHCenter) << int(Qt::AlignTop) << "alignments_ct"; - - QTest::newRow("LB") << int(Qt::AlignLeft) << int(Qt::AlignBottom) << "alignments_lb"; - QTest::newRow("RB") << int(Qt::AlignRight) << int(Qt::AlignBottom) << "alignments_rb"; - QTest::newRow("CB") << int(Qt::AlignHCenter) << int(Qt::AlignBottom) << "alignments_cb"; - - QTest::newRow("LC") << int(Qt::AlignLeft) << int(Qt::AlignVCenter) << "alignments_lc"; - QTest::newRow("RC") << int(Qt::AlignRight) << int(Qt::AlignVCenter) << "alignments_rc"; - QTest::newRow("CC") << int(Qt::AlignHCenter) << int(Qt::AlignVCenter) << "alignments_cc"; -} - - -void tst_qquicktextedit::alignments() -{ - QSKIP("Image comparison of text is almost guaranteed to fail during development"); - - QFETCH(int, hAlign); - QFETCH(int, vAlign); - QFETCH(QString, expectfile); - - QQuickView canvas(testFileUrl("alignments.qml")); - - canvas.show(); - canvas.requestActivateWindow(); - QTest::qWaitForWindowShown(&canvas); - QTRY_COMPARE(&canvas, qGuiApp->focusWindow()); - - QObject *ob = canvas.rootObject(); - QVERIFY(ob != 0); - ob->setProperty("horizontalAlignment",hAlign); - ob->setProperty("verticalAlignment",vAlign); - QTRY_COMPARE(ob->property("running").toBool(),false); - QImage actual = canvas.grabFrameBuffer(); - - expectfile = createExpectedFileIfNotFound(expectfile, actual); - - QImage expect(expectfile); - - QCOMPARE(actual,expect); -} - - -//the alignment tests may be trivial o.oa -void tst_qquicktextedit::hAlign() -{ - //test one align each, and then test if two align fails. - - for (int i = 0; i < standard.size(); i++) - { - for (int j=0; j < hAlignmentStrings.size(); j++) - { - QString componentStr = "import QtQuick 2.0\nTextEdit { horizontalAlignment: \"" + hAlignmentStrings.at(j) + "\"; text: \"" + standard.at(i) + "\" }"; - QDeclarativeComponent texteditComponent(&engine); - texteditComponent.setData(componentStr.toLatin1(), QUrl()); - QQuickTextEdit *textEditObject = qobject_cast(texteditComponent.create()); - - QVERIFY(textEditObject != 0); - QCOMPARE((int)textEditObject->hAlign(), (int)hAlignments.at(j)); - } - } - - for (int i = 0; i < richText.size(); i++) - { - for (int j=0; j < hAlignmentStrings.size(); j++) - { - QString componentStr = "import QtQuick 2.0\nTextEdit { horizontalAlignment: \"" + hAlignmentStrings.at(j) + "\"; text: \"" + richText.at(i) + "\" }"; - QDeclarativeComponent texteditComponent(&engine); - texteditComponent.setData(componentStr.toLatin1(), QUrl()); - QQuickTextEdit *textEditObject = qobject_cast(texteditComponent.create()); - - QVERIFY(textEditObject != 0); - QCOMPARE((int)textEditObject->hAlign(), (int)hAlignments.at(j)); - } - } - -} - -void tst_qquicktextedit::hAlign_RightToLeft() -{ - PlatformInputContext platformInputContext; - QInputMethodPrivate *inputMethodPrivate = QInputMethodPrivate::get(qApp->inputMethod()); - inputMethodPrivate->testContext = &platformInputContext; - - QQuickView canvas(testFileUrl("horizontalAlignment_RightToLeft.qml")); - QQuickTextEdit *textEdit = canvas.rootObject()->findChild("text"); - QVERIFY(textEdit != 0); - canvas.show(); - - const QString rtlText = textEdit->text(); - - // implicit alignment should follow the reading direction of text - QCOMPARE(textEdit->hAlign(), QQuickTextEdit::AlignRight); - QVERIFY(textEdit->positionToRectangle(0).x() > canvas.width()/2); - - // explicitly left aligned - textEdit->setHAlign(QQuickTextEdit::AlignLeft); - QCOMPARE(textEdit->hAlign(), QQuickTextEdit::AlignLeft); - QVERIFY(textEdit->positionToRectangle(0).x() < canvas.width()/2); - - // explicitly right aligned - textEdit->setHAlign(QQuickTextEdit::AlignRight); - QCOMPARE(textEdit->hAlign(), QQuickTextEdit::AlignRight); - QVERIFY(textEdit->positionToRectangle(0).x() > canvas.width()/2); - - QString textString = textEdit->text(); - textEdit->setText(QString("") + textString + QString("")); - textEdit->resetHAlign(); - - // implicitly aligned rich text should follow the reading direction of RTL text - QCOMPARE(textEdit->hAlign(), QQuickTextEdit::AlignRight); - QCOMPARE(textEdit->effectiveHAlign(), textEdit->hAlign()); - QVERIFY(textEdit->positionToRectangle(0).x() > canvas.width()/2); - - // explicitly left aligned rich text - textEdit->setHAlign(QQuickTextEdit::AlignLeft); - QCOMPARE(textEdit->hAlign(), QQuickTextEdit::AlignLeft); - QCOMPARE(textEdit->effectiveHAlign(), textEdit->hAlign()); - QVERIFY(textEdit->positionToRectangle(0).x() < canvas.width()/2); - - // explicitly right aligned rich text - textEdit->setHAlign(QQuickTextEdit::AlignRight); - QCOMPARE(textEdit->hAlign(), QQuickTextEdit::AlignRight); - QCOMPARE(textEdit->effectiveHAlign(), textEdit->hAlign()); - QVERIFY(textEdit->positionToRectangle(0).x() > canvas.width()/2); - - textEdit->setText(textString); - - // explicitly center aligned - textEdit->setHAlign(QQuickTextEdit::AlignHCenter); - QCOMPARE(textEdit->hAlign(), QQuickTextEdit::AlignHCenter); - QVERIFY(textEdit->positionToRectangle(0).x() > canvas.width()/2); - - // reseted alignment should go back to following the text reading direction - textEdit->resetHAlign(); - QCOMPARE(textEdit->hAlign(), QQuickTextEdit::AlignRight); - QVERIFY(textEdit->positionToRectangle(0).x() > canvas.width()/2); - - // mirror the text item - QQuickItemPrivate::get(textEdit)->setLayoutMirror(true); - - // mirrored implicit alignment should continue to follow the reading direction of the text - QCOMPARE(textEdit->hAlign(), QQuickTextEdit::AlignRight); - QCOMPARE(textEdit->effectiveHAlign(), QQuickTextEdit::AlignRight); - QVERIFY(textEdit->positionToRectangle(0).x() > canvas.width()/2); - - // mirrored explicitly right aligned behaves as left aligned - textEdit->setHAlign(QQuickTextEdit::AlignRight); - QCOMPARE(textEdit->hAlign(), QQuickTextEdit::AlignRight); - QCOMPARE(textEdit->effectiveHAlign(), QQuickTextEdit::AlignLeft); - QVERIFY(textEdit->positionToRectangle(0).x() < canvas.width()/2); - - // mirrored explicitly left aligned behaves as right aligned - textEdit->setHAlign(QQuickTextEdit::AlignLeft); - QCOMPARE(textEdit->hAlign(), QQuickTextEdit::AlignLeft); - QCOMPARE(textEdit->effectiveHAlign(), QQuickTextEdit::AlignRight); - QVERIFY(textEdit->positionToRectangle(0).x() > canvas.width()/2); - - // disable mirroring - QQuickItemPrivate::get(textEdit)->setLayoutMirror(false); - textEdit->resetHAlign(); - - // English text should be implicitly left aligned - textEdit->setText("Hello world!"); - QCOMPARE(textEdit->hAlign(), QQuickTextEdit::AlignLeft); - QVERIFY(textEdit->positionToRectangle(0).x() < canvas.width()/2); - - canvas.requestActivateWindow(); - QTest::qWaitForWindowShown(&canvas); - QTRY_COMPARE(&canvas, qGuiApp->focusWindow()); - - textEdit->setText(QString()); - { QInputMethodEvent ev(rtlText, QList()); QGuiApplication::sendEvent(qGuiApp->focusObject(), &ev); } - QCOMPARE(textEdit->hAlign(), QQuickTextEdit::AlignRight); - { QInputMethodEvent ev("Hello world!", QList()); QGuiApplication::sendEvent(qGuiApp->focusObject(), &ev); } - QCOMPARE(textEdit->hAlign(), QQuickTextEdit::AlignLeft); - - // Clear pre-edit text. TextEdit should maybe do this itself on setText, but that may be - // redundant as an actual input method may take care of it. - { QInputMethodEvent ev; QGuiApplication::sendEvent(qGuiApp->focusObject(), &ev); } - - // empty text with implicit alignment follows the system locale-based - // keyboard input direction from qApp->inputMethod()->inputDirection - textEdit->setText(""); - platformInputContext.setInputDirection(Qt::LeftToRight); - QVERIFY(qApp->inputMethod()->inputDirection() == Qt::LeftToRight); - QCOMPARE(textEdit->hAlign(), QQuickTextEdit::AlignLeft); - QVERIFY(textEdit->positionToRectangle(0).x() < canvas.width()/2); - - QSignalSpy cursorRectangleSpy(textEdit, SIGNAL(cursorRectangleChanged())); - - platformInputContext.setInputDirection(Qt::RightToLeft); - QCOMPARE(cursorRectangleSpy.count(), 1); - QVERIFY(qApp->inputMethod()->inputDirection() == Qt::RightToLeft); - QCOMPARE(textEdit->hAlign(), QQuickTextEdit::AlignRight); - QVERIFY(textEdit->positionToRectangle(0).x() > canvas.width()/2); - - // set input direction while having content - platformInputContext.setInputDirection(Qt::LeftToRight); - textEdit->setText("a"); - textEdit->setCursorPosition(1); - platformInputContext.setInputDirection(Qt::RightToLeft); - QTest::keyClick(&canvas, Qt::Key_Backspace); - QVERIFY(textEdit->text().isEmpty()); - QCOMPARE(textEdit->hAlign(), QQuickTextEdit::AlignRight); - QVERIFY(textEdit->cursorRectangle().left() > canvas.width()/2); - - // input direction changed while not having focus - platformInputContext.setInputDirection(Qt::LeftToRight); - textEdit->setFocus(false); - platformInputContext.setInputDirection(Qt::RightToLeft); - textEdit->setFocus(true); - QCOMPARE(textEdit->hAlign(), QQuickTextEdit::AlignRight); - QVERIFY(textEdit->cursorRectangle().left() > canvas.width()/2); - - textEdit->setHAlign(QQuickTextEdit::AlignRight); - QCOMPARE(textEdit->hAlign(), QQuickTextEdit::AlignRight); - QVERIFY(textEdit->positionToRectangle(0).x() > canvas.width()/2); -} - -void tst_qquicktextedit::vAlign() -{ - //test one align each, and then test if two align fails. - - for (int i = 0; i < standard.size(); i++) - { - for (int j=0; j < vAlignmentStrings.size(); j++) - { - QString componentStr = "import QtQuick 2.0\nTextEdit { verticalAlignment: \"" + vAlignmentStrings.at(j) + "\"; text: \"" + standard.at(i) + "\" }"; - QDeclarativeComponent texteditComponent(&engine); - texteditComponent.setData(componentStr.toLatin1(), QUrl()); - QQuickTextEdit *textEditObject = qobject_cast(texteditComponent.create()); - - QVERIFY(textEditObject != 0); - QCOMPARE((int)textEditObject->vAlign(), (int)vAlignments.at(j)); - } - } - - for (int i = 0; i < richText.size(); i++) - { - for (int j=0; j < vAlignmentStrings.size(); j++) - { - QString componentStr = "import QtQuick 2.0\nTextEdit { verticalAlignment: \"" + vAlignmentStrings.at(j) + "\"; text: \"" + richText.at(i) + "\" }"; - QDeclarativeComponent texteditComponent(&engine); - texteditComponent.setData(componentStr.toLatin1(), QUrl()); - QQuickTextEdit *textEditObject = qobject_cast(texteditComponent.create()); - - QVERIFY(textEditObject != 0); - QCOMPARE((int)textEditObject->vAlign(), (int)vAlignments.at(j)); - } - } - - QDeclarativeComponent texteditComponent(&engine); - texteditComponent.setData( - "import QtQuick 2.0\n" - "TextEdit { width: 100; height: 100; text: \"Hello World\" }", QUrl()); - QQuickTextEdit *textEditObject = qobject_cast(texteditComponent.create()); - - QVERIFY(textEditObject != 0); - - QCOMPARE(textEditObject->vAlign(), QQuickTextEdit::AlignTop); - QVERIFY(textEditObject->cursorRectangle().bottom() < 50); - QVERIFY(textEditObject->positionToRectangle(0).bottom() < 50); - - // bottom aligned - textEditObject->setVAlign(QQuickTextEdit::AlignBottom); - QCOMPARE(textEditObject->vAlign(), QQuickTextEdit::AlignBottom); - QVERIFY(textEditObject->cursorRectangle().top() > 50); - QVERIFY(textEditObject->positionToRectangle(0).top() > 50); - - // explicitly center aligned - textEditObject->setVAlign(QQuickTextEdit::AlignVCenter); - QCOMPARE(textEditObject->vAlign(), QQuickTextEdit::AlignVCenter); - QVERIFY(textEditObject->cursorRectangle().top() < 50); - QVERIFY(textEditObject->cursorRectangle().bottom() > 50); - QVERIFY(textEditObject->positionToRectangle(0).top() < 50); - QVERIFY(textEditObject->positionToRectangle(0).bottom() > 50); -} - -void tst_qquicktextedit::font() -{ - //test size, then bold, then italic, then family - { - QString componentStr = "import QtQuick 2.0\nTextEdit { font.pointSize: 40; text: \"Hello World\" }"; - QDeclarativeComponent texteditComponent(&engine); - texteditComponent.setData(componentStr.toLatin1(), QUrl()); - QQuickTextEdit *textEditObject = qobject_cast(texteditComponent.create()); - - QVERIFY(textEditObject != 0); - QCOMPARE(textEditObject->font().pointSize(), 40); - QCOMPARE(textEditObject->font().bold(), false); - QCOMPARE(textEditObject->font().italic(), false); - } - - { - QString componentStr = "import QtQuick 2.0\nTextEdit { font.bold: true; text: \"Hello World\" }"; - QDeclarativeComponent texteditComponent(&engine); - texteditComponent.setData(componentStr.toLatin1(), QUrl()); - QQuickTextEdit *textEditObject = qobject_cast(texteditComponent.create()); - - QVERIFY(textEditObject != 0); - QCOMPARE(textEditObject->font().bold(), true); - QCOMPARE(textEditObject->font().italic(), false); - } - - { - QString componentStr = "import QtQuick 2.0\nTextEdit { font.italic: true; text: \"Hello World\" }"; - QDeclarativeComponent texteditComponent(&engine); - texteditComponent.setData(componentStr.toLatin1(), QUrl()); - QQuickTextEdit *textEditObject = qobject_cast(texteditComponent.create()); - - QVERIFY(textEditObject != 0); - QCOMPARE(textEditObject->font().italic(), true); - QCOMPARE(textEditObject->font().bold(), false); - } - - { - QString componentStr = "import QtQuick 2.0\nTextEdit { font.family: \"Helvetica\"; text: \"Hello World\" }"; - QDeclarativeComponent texteditComponent(&engine); - texteditComponent.setData(componentStr.toLatin1(), QUrl()); - QQuickTextEdit *textEditObject = qobject_cast(texteditComponent.create()); - - QVERIFY(textEditObject != 0); - QCOMPARE(textEditObject->font().family(), QString("Helvetica")); - QCOMPARE(textEditObject->font().bold(), false); - QCOMPARE(textEditObject->font().italic(), false); - } - - { - QString componentStr = "import QtQuick 2.0\nTextEdit { font.family: \"\"; text: \"Hello World\" }"; - QDeclarativeComponent texteditComponent(&engine); - texteditComponent.setData(componentStr.toLatin1(), QUrl()); - QQuickTextEdit *textEditObject = qobject_cast(texteditComponent.create()); - - QVERIFY(textEditObject != 0); - QCOMPARE(textEditObject->font().family(), QString("")); - } -} - -void tst_qquicktextedit::color() -{ - //test initial color - { - QString componentStr = "import QtQuick 2.0\nTextEdit { text: \"Hello World\" }"; - QDeclarativeComponent texteditComponent(&engine); - texteditComponent.setData(componentStr.toLatin1(), QUrl()); - QQuickTextEdit *textEditObject = qobject_cast(texteditComponent.create()); - - QQuickTextEditPrivate *textEditPrivate = static_cast(QQuickItemPrivate::get(textEditObject)); - - QVERIFY(textEditObject); - QVERIFY(textEditPrivate); - QVERIFY(textEditPrivate->control); - - QPalette pal = textEditPrivate->control->palette(); - QCOMPARE(textEditPrivate->color, QColor("black")); - QCOMPARE(textEditPrivate->color, pal.color(QPalette::Text)); - } - //test normal - for (int i = 0; i < colorStrings.size(); i++) - { - QString componentStr = "import QtQuick 2.0\nTextEdit { color: \"" + colorStrings.at(i) + "\"; text: \"Hello World\" }"; - QDeclarativeComponent texteditComponent(&engine); - texteditComponent.setData(componentStr.toLatin1(), QUrl()); - QQuickTextEdit *textEditObject = qobject_cast(texteditComponent.create()); - //qDebug() << "textEditObject: " << textEditObject->color() << "vs. " << QColor(colorStrings.at(i)); - QVERIFY(textEditObject != 0); - QCOMPARE(textEditObject->color(), QColor(colorStrings.at(i))); - } - - //test selection - for (int i = 0; i < colorStrings.size(); i++) - { - QString componentStr = "import QtQuick 2.0\nTextEdit { selectionColor: \"" + colorStrings.at(i) + "\"; text: \"Hello World\" }"; - QDeclarativeComponent texteditComponent(&engine); - texteditComponent.setData(componentStr.toLatin1(), QUrl()); - QQuickTextEdit *textEditObject = qobject_cast(texteditComponent.create()); - QVERIFY(textEditObject != 0); - QCOMPARE(textEditObject->selectionColor(), QColor(colorStrings.at(i))); - } - - //test selected text - for (int i = 0; i < colorStrings.size(); i++) - { - QString componentStr = "import QtQuick 2.0\nTextEdit { selectedTextColor: \"" + colorStrings.at(i) + "\"; text: \"Hello World\" }"; - QDeclarativeComponent texteditComponent(&engine); - texteditComponent.setData(componentStr.toLatin1(), QUrl()); - QQuickTextEdit *textEditObject = qobject_cast(texteditComponent.create()); - QVERIFY(textEditObject != 0); - QCOMPARE(textEditObject->selectedTextColor(), QColor(colorStrings.at(i))); - } - - { - QString colorStr = "#AA001234"; - QColor testColor("#001234"); - testColor.setAlpha(170); - - QString componentStr = "import QtQuick 2.0\nTextEdit { color: \"" + colorStr + "\"; text: \"Hello World\" }"; - QDeclarativeComponent texteditComponent(&engine); - texteditComponent.setData(componentStr.toLatin1(), QUrl()); - QQuickTextEdit *textEditObject = qobject_cast(texteditComponent.create()); - - QVERIFY(textEditObject != 0); - QCOMPARE(textEditObject->color(), testColor); - } -} - -void tst_qquicktextedit::textMargin() -{ - for (qreal i=0; i<=10; i+=0.3) { - QString componentStr = "import QtQuick 2.0\nTextEdit { textMargin: " + QString::number(i) + "; text: \"Hello World\" }"; - QDeclarativeComponent texteditComponent(&engine); - texteditComponent.setData(componentStr.toLatin1(), QUrl()); - QQuickTextEdit *textEditObject = qobject_cast(texteditComponent.create()); - QVERIFY(textEditObject != 0); - QCOMPARE(textEditObject->textMargin(), i); - } -} - -void tst_qquicktextedit::persistentSelection() -{ - QQuickView canvas(testFileUrl("persistentSelection.qml")); - canvas.show(); - canvas.requestActivateWindow(); - QTest::qWaitForWindowShown(&canvas); - QTRY_COMPARE(&canvas, qGuiApp->focusWindow()); - canvas.requestActivateWindow(); - - QQuickTextEdit *edit = qobject_cast(canvas.rootObject()); - QVERIFY(edit); - QVERIFY(edit->hasActiveFocus()); - - QSignalSpy spy(edit, SIGNAL(persistentSelectionChanged(bool))); - - QCOMPARE(edit->persistentSelection(), false); - - edit->setPersistentSelection(false); - QCOMPARE(edit->persistentSelection(), false); - QCOMPARE(spy.count(), 0); - - edit->select(1, 4); - QCOMPARE(edit->property("selected").toString(), QLatin1String("ell")); - - edit->setFocus(false); - QCOMPARE(edit->property("selected").toString(), QString()); - - edit->setFocus(true); - QCOMPARE(edit->property("selected").toString(), QString()); - - edit->setPersistentSelection(true); - QCOMPARE(edit->persistentSelection(), true); - QCOMPARE(spy.count(), 1); - - edit->select(1, 4); - QCOMPARE(edit->property("selected").toString(), QLatin1String("ell")); - - edit->setFocus(false); - QCOMPARE(edit->property("selected").toString(), QLatin1String("ell")); - - edit->setFocus(true); - QCOMPARE(edit->property("selected").toString(), QLatin1String("ell")); - -} - -void tst_qquicktextedit::focusOnPress() -{ - { - QString componentStr = "import QtQuick 2.0\nTextEdit { activeFocusOnPress: true; text: \"Hello World\" }"; - QDeclarativeComponent texteditComponent(&engine); - texteditComponent.setData(componentStr.toLatin1(), QUrl()); - QQuickTextEdit *textEditObject = qobject_cast(texteditComponent.create()); - QVERIFY(textEditObject != 0); - QCOMPARE(textEditObject->focusOnPress(), true); - } - - { - QString componentStr = "import QtQuick 2.0\nTextEdit { activeFocusOnPress: false; text: \"Hello World\" }"; - QDeclarativeComponent texteditComponent(&engine); - texteditComponent.setData(componentStr.toLatin1(), QUrl()); - QQuickTextEdit *textEditObject = qobject_cast(texteditComponent.create()); - QVERIFY(textEditObject != 0); - QCOMPARE(textEditObject->focusOnPress(), false); - } -} - -void tst_qquicktextedit::selection() -{ - QString testStr = standard[0];//TODO: What should happen for multiline/rich text? - QString componentStr = "import QtQuick 2.0\nTextEdit { text: \""+ testStr +"\"; }"; - QDeclarativeComponent texteditComponent(&engine); - texteditComponent.setData(componentStr.toLatin1(), QUrl()); - QQuickTextEdit *textEditObject = qobject_cast(texteditComponent.create()); - QVERIFY(textEditObject != 0); - - - //Test selection follows cursor - for (int i=0; i<= testStr.size(); i++) { - textEditObject->setCursorPosition(i); - QCOMPARE(textEditObject->cursorPosition(), i); - QCOMPARE(textEditObject->selectionStart(), i); - QCOMPARE(textEditObject->selectionEnd(), i); - QVERIFY(textEditObject->selectedText().isNull()); - } - - textEditObject->setCursorPosition(0); - QVERIFY(textEditObject->cursorPosition() == 0); - QVERIFY(textEditObject->selectionStart() == 0); - QVERIFY(textEditObject->selectionEnd() == 0); - QVERIFY(textEditObject->selectedText().isNull()); - - // Verify invalid positions are ignored. - textEditObject->setCursorPosition(-1); - QVERIFY(textEditObject->cursorPosition() == 0); - QVERIFY(textEditObject->selectionStart() == 0); - QVERIFY(textEditObject->selectionEnd() == 0); - QVERIFY(textEditObject->selectedText().isNull()); - - textEditObject->setCursorPosition(textEditObject->text().count()+1); - QVERIFY(textEditObject->cursorPosition() == 0); - QVERIFY(textEditObject->selectionStart() == 0); - QVERIFY(textEditObject->selectionEnd() == 0); - QVERIFY(textEditObject->selectedText().isNull()); - - //Test selection - for (int i=0; i<= testStr.size(); i++) { - textEditObject->select(0,i); - QCOMPARE(testStr.mid(0,i), textEditObject->selectedText()); - } - for (int i=0; i<= testStr.size(); i++) { - textEditObject->select(i,testStr.size()); - QCOMPARE(testStr.mid(i,testStr.size()-i), textEditObject->selectedText()); - } - - textEditObject->setCursorPosition(0); - QVERIFY(textEditObject->cursorPosition() == 0); - QVERIFY(textEditObject->selectionStart() == 0); - QVERIFY(textEditObject->selectionEnd() == 0); - QVERIFY(textEditObject->selectedText().isNull()); - - //Test Error Ignoring behaviour - textEditObject->setCursorPosition(0); - QVERIFY(textEditObject->selectedText().isNull()); - textEditObject->select(-10,0); - QVERIFY(textEditObject->selectedText().isNull()); - textEditObject->select(100,101); - QVERIFY(textEditObject->selectedText().isNull()); - textEditObject->select(0,-10); - QVERIFY(textEditObject->selectedText().isNull()); - textEditObject->select(0,100); - QVERIFY(textEditObject->selectedText().isNull()); - textEditObject->select(0,10); - QVERIFY(textEditObject->selectedText().size() == 10); - textEditObject->select(-10,0); - QVERIFY(textEditObject->selectedText().size() == 10); - textEditObject->select(100,101); - QVERIFY(textEditObject->selectedText().size() == 10); - textEditObject->select(0,-10); - QVERIFY(textEditObject->selectedText().size() == 10); - textEditObject->select(0,100); - QVERIFY(textEditObject->selectedText().size() == 10); - - textEditObject->deselect(); - QVERIFY(textEditObject->selectedText().isNull()); - textEditObject->select(0,10); - QVERIFY(textEditObject->selectedText().size() == 10); - textEditObject->deselect(); - QVERIFY(textEditObject->selectedText().isNull()); -} - -void tst_qquicktextedit::isRightToLeft_data() -{ - QTest::addColumn("text"); - QTest::addColumn("emptyString"); - QTest::addColumn("firstCharacter"); - QTest::addColumn("lastCharacter"); - QTest::addColumn("middleCharacter"); - QTest::addColumn("startString"); - QTest::addColumn("midString"); - QTest::addColumn("endString"); - - const quint16 arabic_str[] = { 0x0638, 0x0643, 0x00646, 0x0647, 0x0633, 0x0638, 0x0643, 0x00646, 0x0647, 0x0633, 0x0647}; - QTest::newRow("Empty") << "" << false << false << false << false << false << false << false; - QTest::newRow("Neutral") << "23244242" << false << false << false << false << false << false << false; - QTest::newRow("LTR") << "Hello world" << false << false << false << false << false << false << false; - QTest::newRow("RTL") << QString::fromUtf16(arabic_str, 11) << false << true << true << true << true << true << true; - QTest::newRow("Bidi RTL + LTR + RTL") << QString::fromUtf16(arabic_str, 11) + QString("Hello world") + QString::fromUtf16(arabic_str, 11) << false << true << true << false << true << true << true; - QTest::newRow("Bidi LTR + RTL + LTR") << QString("Hello world") + QString::fromUtf16(arabic_str, 11) + QString("Hello world") << false << false << false << true << false << false << false; -} - -void tst_qquicktextedit::isRightToLeft() -{ - QFETCH(QString, text); - QFETCH(bool, emptyString); - QFETCH(bool, firstCharacter); - QFETCH(bool, lastCharacter); - QFETCH(bool, middleCharacter); - QFETCH(bool, startString); - QFETCH(bool, midString); - QFETCH(bool, endString); - - QQuickTextEdit textEdit; - textEdit.setText(text); - - // first test that the right string is delivered to the QString::isRightToLeft() - QCOMPARE(textEdit.isRightToLeft(0,0), text.mid(0,0).isRightToLeft()); - QCOMPARE(textEdit.isRightToLeft(0,1), text.mid(0,1).isRightToLeft()); - QCOMPARE(textEdit.isRightToLeft(text.count()-2, text.count()-1), text.mid(text.count()-2, text.count()-1).isRightToLeft()); - QCOMPARE(textEdit.isRightToLeft(text.count()/2, text.count()/2 + 1), text.mid(text.count()/2, text.count()/2 + 1).isRightToLeft()); - QCOMPARE(textEdit.isRightToLeft(0,text.count()/4), text.mid(0,text.count()/4).isRightToLeft()); - QCOMPARE(textEdit.isRightToLeft(text.count()/4,3*text.count()/4), text.mid(text.count()/4,3*text.count()/4).isRightToLeft()); - if (text.isEmpty()) - QTest::ignoreMessage(QtWarningMsg, ": QML TextEdit: isRightToLeft(start, end) called with the end property being smaller than the start."); - QCOMPARE(textEdit.isRightToLeft(3*text.count()/4,text.count()-1), text.mid(3*text.count()/4,text.count()-1).isRightToLeft()); - - // then test that the feature actually works - QCOMPARE(textEdit.isRightToLeft(0,0), emptyString); - QCOMPARE(textEdit.isRightToLeft(0,1), firstCharacter); - QCOMPARE(textEdit.isRightToLeft(text.count()-2, text.count()-1), lastCharacter); - QCOMPARE(textEdit.isRightToLeft(text.count()/2, text.count()/2 + 1), middleCharacter); - QCOMPARE(textEdit.isRightToLeft(0,text.count()/4), startString); - QCOMPARE(textEdit.isRightToLeft(text.count()/4,3*text.count()/4), midString); - if (text.isEmpty()) - QTest::ignoreMessage(QtWarningMsg, ": QML TextEdit: isRightToLeft(start, end) called with the end property being smaller than the start."); - QCOMPARE(textEdit.isRightToLeft(3*text.count()/4,text.count()-1), endString); -} - -void tst_qquicktextedit::keySelection() -{ - QQuickView canvas(testFileUrl("navigation.qml")); - canvas.show(); - canvas.requestActivateWindow(); - QTest::qWaitForWindowShown(&canvas); - QTRY_COMPARE(&canvas, qGuiApp->focusWindow()); - canvas.requestActivateWindow(); - - QVERIFY(canvas.rootObject() != 0); - - QQuickTextEdit *input = qobject_cast(qvariant_cast(canvas.rootObject()->property("myInput"))); - - QVERIFY(input != 0); - QTRY_VERIFY(input->hasActiveFocus() == true); - - QSignalSpy spy(input, SIGNAL(selectionChanged())); - - simulateKey(&canvas, Qt::Key_Right, Qt::ShiftModifier); - QVERIFY(input->hasActiveFocus() == true); - QCOMPARE(input->selectedText(), QString("a")); - QCOMPARE(spy.count(), 1); - simulateKey(&canvas, Qt::Key_Right); - QVERIFY(input->hasActiveFocus() == true); - QCOMPARE(input->selectedText(), QString()); - QCOMPARE(spy.count(), 2); - simulateKey(&canvas, Qt::Key_Right); - QVERIFY(input->hasActiveFocus() == false); - QCOMPARE(input->selectedText(), QString()); - QCOMPARE(spy.count(), 2); - - simulateKey(&canvas, Qt::Key_Left); - QVERIFY(input->hasActiveFocus() == true); - QCOMPARE(spy.count(), 2); - simulateKey(&canvas, Qt::Key_Left, Qt::ShiftModifier); - QVERIFY(input->hasActiveFocus() == true); - QCOMPARE(input->selectedText(), QString("a")); - QCOMPARE(spy.count(), 3); - simulateKey(&canvas, Qt::Key_Left); - QVERIFY(input->hasActiveFocus() == true); - QCOMPARE(input->selectedText(), QString()); - QCOMPARE(spy.count(), 4); - simulateKey(&canvas, Qt::Key_Left); - QVERIFY(input->hasActiveFocus() == false); - QCOMPARE(input->selectedText(), QString()); - QCOMPARE(spy.count(), 4); -} - -void tst_qquicktextedit::moveCursorSelection_data() -{ - QTest::addColumn("testStr"); - QTest::addColumn("cursorPosition"); - QTest::addColumn("movePosition"); - QTest::addColumn("mode"); - QTest::addColumn("selectionStart"); - QTest::addColumn("selectionEnd"); - QTest::addColumn("reversible"); - - QTest::newRow("(t)he|characters") - << standard[0] << 0 << 1 << QQuickTextEdit::SelectCharacters << 0 << 1 << true; - QTest::newRow("do(g)|characters") - << standard[0] << 43 << 44 << QQuickTextEdit::SelectCharacters << 43 << 44 << true; - QTest::newRow("jum(p)ed|characters") - << standard[0] << 23 << 24 << QQuickTextEdit::SelectCharacters << 23 << 24 << true; - QTest::newRow("jumped( )over|characters") - << standard[0] << 26 << 27 << QQuickTextEdit::SelectCharacters << 26 << 27 << true; - QTest::newRow("(the )|characters") - << standard[0] << 0 << 4 << QQuickTextEdit::SelectCharacters << 0 << 4 << true; - QTest::newRow("( dog)|characters") - << standard[0] << 40 << 44 << QQuickTextEdit::SelectCharacters << 40 << 44 << true; - QTest::newRow("( jumped )|characters") - << standard[0] << 19 << 27 << QQuickTextEdit::SelectCharacters << 19 << 27 << true; - QTest::newRow("th(e qu)ick|characters") - << standard[0] << 2 << 6 << QQuickTextEdit::SelectCharacters << 2 << 6 << true; - QTest::newRow("la(zy d)og|characters") - << standard[0] << 38 << 42 << QQuickTextEdit::SelectCharacters << 38 << 42 << true; - QTest::newRow("jum(ped ov)er|characters") - << standard[0] << 23 << 29 << QQuickTextEdit::SelectCharacters << 23 << 29 << true; - QTest::newRow("()the|characters") - << standard[0] << 0 << 0 << QQuickTextEdit::SelectCharacters << 0 << 0 << true; - QTest::newRow("dog()|characters") - << standard[0] << 44 << 44 << QQuickTextEdit::SelectCharacters << 44 << 44 << true; - QTest::newRow("jum()ped|characters") - << standard[0] << 23 << 23 << QQuickTextEdit::SelectCharacters << 23 << 23 << true; - - QTest::newRow("<(t)he>|words") - << standard[0] << 0 << 1 << QQuickTextEdit::SelectWords << 0 << 3 << true; - QTest::newRow("|words") - << standard[0] << 43 << 44 << QQuickTextEdit::SelectWords << 41 << 44 << true; - QTest::newRow("|words") - << standard[0] << 23 << 24 << QQuickTextEdit::SelectWords << 20 << 26 << true; - QTest::newRow("over|words") - << standard[0] << 26 << 27 << QQuickTextEdit::SelectWords << 20 << 27 << false; - QTest::newRow("jumped<( )over>|words,reversed") - << standard[0] << 27 << 26 << QQuickTextEdit::SelectWords << 26 << 31 << false; - QTest::newRow("<(the )>quick|words") - << standard[0] << 0 << 4 << QQuickTextEdit::SelectWords << 0 << 4 << false; - QTest::newRow("<(the )quick>|words,reversed") - << standard[0] << 4 << 0 << QQuickTextEdit::SelectWords << 0 << 9 << false; - QTest::newRow("|words") - << standard[0] << 40 << 44 << QQuickTextEdit::SelectWords << 36 << 44 << false; - QTest::newRow("lazy<( dog)>|words,reversed") - << standard[0] << 44 << 40 << QQuickTextEdit::SelectWords << 40 << 44 << false; - QTest::newRow("over|words") - << standard[0] << 19 << 27 << QQuickTextEdit::SelectWords << 16 << 27 << false; - QTest::newRow("fox<( jumped )over>|words,reversed") - << standard[0] << 27 << 19 << QQuickTextEdit::SelectWords << 19 << 31 << false; - QTest::newRow("|words") - << standard[0] << 2 << 6 << QQuickTextEdit::SelectWords << 0 << 9 << true; - QTest::newRow("") - << standard[0] << 38 << 42 << QQuickTextEdit::SelectWords << 36 << 44 << true; - QTest::newRow("|words") - << standard[0] << 23 << 29 << QQuickTextEdit::SelectWords << 20 << 31 << true; - QTest::newRow("<()>the|words") - << standard[0] << 0 << 0 << QQuickTextEdit::SelectWords << 0 << 0 << true; - QTest::newRow("dog<()>|words") - << standard[0] << 44 << 44 << QQuickTextEdit::SelectWords << 44 << 44 << true; - QTest::newRow("jum<()>ped|words") - << standard[0] << 23 << 23 << QQuickTextEdit::SelectWords << 23 << 23 << true; - - QTest::newRow("Hello<(,)> |words") - << standard[2] << 5 << 6 << QQuickTextEdit::SelectWords << 5 << 6 << true; - QTest::newRow("Hello<(, )>world|words") - << standard[2] << 5 << 7 << QQuickTextEdit::SelectWords << 5 << 7 << false; - QTest::newRow("Hello<(, )world>|words,reversed") - << standard[2] << 7 << 5 << QQuickTextEdit::SelectWords << 5 << 12 << false; - QTest::newRow("world|words") - << standard[2] << 3 << 7 << QQuickTextEdit::SelectWords << 0 << 7 << false; - QTest::newRow("|words,reversed") - << standard[2] << 7 << 3 << QQuickTextEdit::SelectWords << 0 << 12 << false; - QTest::newRow(",|words") - << standard[2] << 3 << 5 << QQuickTextEdit::SelectWords << 0 << 5 << true; - QTest::newRow("Hello<()>,|words") - << standard[2] << 5 << 5 << QQuickTextEdit::SelectWords << 5 << 5 << true; - QTest::newRow("Hello,<()>|words") - << standard[2] << 6 << 6 << QQuickTextEdit::SelectWords << 6 << 6 << true; - QTest::newRow("Hello<,( )>world|words") - << standard[2] << 6 << 7 << QQuickTextEdit::SelectWords << 5 << 7 << false; - QTest::newRow("Hello,<( )world>|words,reversed") - << standard[2] << 7 << 6 << QQuickTextEdit::SelectWords << 6 << 12 << false; - QTest::newRow("Hello<,( world)>|words") - << standard[2] << 6 << 12 << QQuickTextEdit::SelectWords << 5 << 12 << false; - QTest::newRow("Hello,<( world)>|words,reversed") - << standard[2] << 12 << 6 << QQuickTextEdit::SelectWords << 6 << 12 << false; - QTest::newRow("Hello<,( world!)>|words") - << standard[2] << 6 << 13 << QQuickTextEdit::SelectWords << 5 << 13 << false; - QTest::newRow("Hello,<( world!)>|words,reversed") - << standard[2] << 13 << 6 << QQuickTextEdit::SelectWords << 6 << 13 << false; - QTest::newRow("Hello<(, world!)>|words") - << standard[2] << 5 << 13 << QQuickTextEdit::SelectWords << 5 << 13 << true; - QTest::newRow("world<(!)>|words") - << standard[2] << 12 << 13 << QQuickTextEdit::SelectWords << 12 << 13 << true; - QTest::newRow("world!<()>)|words") - << standard[2] << 13 << 13 << QQuickTextEdit::SelectWords << 13 << 13 << true; - QTest::newRow("world<()>!)|words") - << standard[2] << 12 << 12 << QQuickTextEdit::SelectWords << 12 << 12 << true; - - QTest::newRow("<(,)>olleH |words") - << standard[3] << 7 << 8 << QQuickTextEdit::SelectWords << 7 << 8 << true; - QTest::newRow("olleH|words") - << standard[3] << 6 << 8 << QQuickTextEdit::SelectWords << 1 << 8 << false; - QTest::newRow("dlrow<( ,)>olleH|words,reversed") - << standard[3] << 8 << 6 << QQuickTextEdit::SelectWords << 6 << 8 << false; - QTest::newRow("|words") - << standard[3] << 6 << 10 << QQuickTextEdit::SelectWords << 1 << 13 << false; - QTest::newRow("dlrow<( ,ol)leH>|words,reversed") - << standard[3] << 10 << 6 << QQuickTextEdit::SelectWords << 6 << 13 << false; - QTest::newRow(",<(ol)leH>,|words") - << standard[3] << 8 << 10 << QQuickTextEdit::SelectWords << 8 << 13 << true; - QTest::newRow(",<()>olleH|words") - << standard[3] << 8 << 8 << QQuickTextEdit::SelectWords << 8 << 8 << true; - QTest::newRow("<()>,olleH|words") - << standard[3] << 7 << 7 << QQuickTextEdit::SelectWords << 7 << 7 << true; - QTest::newRow(",olleH|words") - << standard[3] << 6 << 7 << QQuickTextEdit::SelectWords << 1 << 7 << false; - QTest::newRow("dlrow<( ),>olleH|words,reversed") - << standard[3] << 7 << 6 << QQuickTextEdit::SelectWords << 6 << 8 << false; - QTest::newRow("<(dlrow )>,olleH|words") - << standard[3] << 1 << 7 << QQuickTextEdit::SelectWords << 1 << 7 << false; - QTest::newRow("<(dlrow ),>olleH|words,reversed") - << standard[3] << 7 << 1 << QQuickTextEdit::SelectWords << 1 << 8 << false; - QTest::newRow("<(!dlrow )>,olleH|words") - << standard[3] << 0 << 7 << QQuickTextEdit::SelectWords << 0 << 7 << false; - QTest::newRow("<(!dlrow ),>olleH|words,reversed") - << standard[3] << 7 << 0 << QQuickTextEdit::SelectWords << 0 << 8 << false; - QTest::newRow("(!dlrow ,)olleH|words") - << standard[3] << 0 << 8 << QQuickTextEdit::SelectWords << 0 << 8 << true; - QTest::newRow("<(!)>dlrow|words") - << standard[3] << 0 << 1 << QQuickTextEdit::SelectWords << 0 << 1 << true; - QTest::newRow("<()>!dlrow|words") - << standard[3] << 0 << 0 << QQuickTextEdit::SelectWords << 0 << 0 << true; - QTest::newRow("!<()>dlrow|words") - << standard[3] << 1 << 1 << QQuickTextEdit::SelectWords << 1 << 1 << true; -} - -void tst_qquicktextedit::moveCursorSelection() -{ - QFETCH(QString, testStr); - QFETCH(int, cursorPosition); - QFETCH(int, movePosition); - QFETCH(QQuickTextEdit::SelectionMode, mode); - QFETCH(int, selectionStart); - QFETCH(int, selectionEnd); - QFETCH(bool, reversible); - - QString componentStr = "import QtQuick 2.0\nTextEdit { text: \""+ testStr +"\"; }"; - QDeclarativeComponent textinputComponent(&engine); - textinputComponent.setData(componentStr.toLatin1(), QUrl()); - QQuickTextEdit *texteditObject = qobject_cast(textinputComponent.create()); - QVERIFY(texteditObject != 0); - - texteditObject->setCursorPosition(cursorPosition); - texteditObject->moveCursorSelection(movePosition, mode); - - QCOMPARE(texteditObject->selectedText(), testStr.mid(selectionStart, selectionEnd - selectionStart)); - QCOMPARE(texteditObject->selectionStart(), selectionStart); - QCOMPARE(texteditObject->selectionEnd(), selectionEnd); - - if (reversible) { - texteditObject->setCursorPosition(movePosition); - texteditObject->moveCursorSelection(cursorPosition, mode); - - QCOMPARE(texteditObject->selectedText(), testStr.mid(selectionStart, selectionEnd - selectionStart)); - QCOMPARE(texteditObject->selectionStart(), selectionStart); - QCOMPARE(texteditObject->selectionEnd(), selectionEnd); - } -} - -void tst_qquicktextedit::moveCursorSelectionSequence_data() -{ - QTest::addColumn("testStr"); - QTest::addColumn("cursorPosition"); - QTest::addColumn("movePosition1"); - QTest::addColumn("movePosition2"); - QTest::addColumn("selection1Start"); - QTest::addColumn("selection1End"); - QTest::addColumn("selection2Start"); - QTest::addColumn("selection2End"); - - QTest::newRow("the { f^ox} jumped|ltr") - << standard[0] - << 9 << 13 << 17 - << 4 << 15 - << 4 << 19; - QTest::newRow("the quick<( {bro)wn> f^ox} jumped|rtl") - << standard[0] - << 13 << 9 << 17 - << 9 << 15 - << 10 << 19; - QTest::newRow("the { ^}fox jumped|ltr") - << standard[0] - << 9 << 13 << 16 - << 4 << 15 - << 4 << 16; - QTest::newRow("the quick<( {bro)wn> ^}fox jumped|rtl") - << standard[0] - << 13 << 9 << 16 - << 9 << 15 - << 10 << 16; - QTest::newRow("the {} fox jumped|ltr") - << standard[0] - << 9 << 13 << 15 - << 4 << 15 - << 4 << 15; - QTest::newRow("the quick<( {bro)wn^>} f^ox jumped|rtl") - << standard[0] - << 13 << 9 << 15 - << 9 << 15 - << 10 << 15; - QTest::newRow("the { fox|ltr") - << standard[0] - << 9 << 13 << 10 - << 4 << 15 - << 4 << 10; - QTest::newRow("the quick<(^ {^bro)wn>} fox|rtl") - << standard[0] - << 13 << 9 << 10 - << 9 << 15 - << 10 << 15; - QTest::newRow("the { fox|ltr") - << standard[0] - << 9 << 13 << 9 - << 4 << 15 - << 4 << 9; - QTest::newRow("the quick{<(^ bro)wn>} fox|rtl") - << standard[0] - << 13 << 9 << 9 - << 9 << 15 - << 9 << 15; - QTest::newRow("the { fox|ltr") - << standard[0] - << 9 << 13 << 7 - << 4 << 15 - << 4 << 9; - QTest::newRow("the { fox|rtl") - << standard[0] - << 13 << 9 << 7 - << 9 << 15 - << 4 << 15; - QTest::newRow("the {<^quick}( bro)wn> fox|ltr") - << standard[0] - << 9 << 13 << 4 - << 4 << 15 - << 4 << 9; - QTest::newRow("the {<^quick}( bro)wn> fox|rtl") - << standard[0] - << 13 << 9 << 4 - << 9 << 15 - << 4 << 15; - QTest::newRow("the{^ fox|ltr") - << standard[0] - << 9 << 13 << 3 - << 4 << 15 - << 3 << 9; - QTest::newRow("the{^ fox|rtl") - << standard[0] - << 13 << 9 << 3 - << 9 << 15 - << 3 << 15; - QTest::newRow("{t^he fox|ltr") - << standard[0] - << 9 << 13 << 1 - << 4 << 15 - << 0 << 9; - QTest::newRow("{t^he fox|rtl") - << standard[0] - << 13 << 9 << 1 - << 9 << 15 - << 0 << 15; - - QTest::newRow("{, w^orld}!|ltr") - << standard[2] - << 2 << 4 << 8 - << 0 << 5 - << 0 << 12; - QTest::newRow("{, w^orld}!|rtl") - << standard[2] - << 4 << 2 << 8 - << 0 << 5 - << 0 << 12; - - QTest::newRow("!{dlro^w ,}|ltr") - << standard[3] - << 9 << 11 << 5 - << 8 << 13 - << 1 << 13; - QTest::newRow("!{dlro^w ,}|rtl") - << standard[3] - << 11 << 9 << 5 - << 8 << 13 - << 1 << 13; -} - -void tst_qquicktextedit::moveCursorSelectionSequence() -{ - QFETCH(QString, testStr); - QFETCH(int, cursorPosition); - QFETCH(int, movePosition1); - QFETCH(int, movePosition2); - QFETCH(int, selection1Start); - QFETCH(int, selection1End); - QFETCH(int, selection2Start); - QFETCH(int, selection2End); - - QString componentStr = "import QtQuick 2.0\nTextEdit { text: \""+ testStr +"\"; }"; - QDeclarativeComponent texteditComponent(&engine); - texteditComponent.setData(componentStr.toLatin1(), QUrl()); - QQuickTextEdit *texteditObject = qobject_cast(texteditComponent.create()); - QVERIFY(texteditObject != 0); - - texteditObject->setCursorPosition(cursorPosition); - - texteditObject->moveCursorSelection(movePosition1, QQuickTextEdit::SelectWords); - QCOMPARE(texteditObject->selectedText(), testStr.mid(selection1Start, selection1End - selection1Start)); - QCOMPARE(texteditObject->selectionStart(), selection1Start); - QCOMPARE(texteditObject->selectionEnd(), selection1End); - - texteditObject->moveCursorSelection(movePosition2, QQuickTextEdit::SelectWords); - QCOMPARE(texteditObject->selectedText(), testStr.mid(selection2Start, selection2End - selection2Start)); - QCOMPARE(texteditObject->selectionStart(), selection2Start); - QCOMPARE(texteditObject->selectionEnd(), selection2End); -} - - -void tst_qquicktextedit::mouseSelection_data() -{ - QTest::addColumn("qmlfile"); - QTest::addColumn("from"); - QTest::addColumn("to"); - QTest::addColumn("selectedText"); - - // import installed - QTest::newRow("on") << testFile("mouseselection_true.qml") << 4 << 9 << "45678"; - QTest::newRow("off") << testFile("mouseselection_false.qml") << 4 << 9 << QString(); - QTest::newRow("default") << testFile("mouseselection_default.qml") << 4 << 9 << QString(); - QTest::newRow("off word selection") << testFile("mouseselection_false_words.qml") << 4 << 9 << QString(); - QTest::newRow("on word selection (4,9)") << testFile("mouseselection_true_words.qml") << 4 << 9 << "0123456789"; - QTest::newRow("on word selection (2,13)") << testFile("mouseselection_true_words.qml") << 2 << 13 << "0123456789 ABCDEFGHIJKLMNOPQRSTUVWXYZ"; - QTest::newRow("on word selection (2,30)") << testFile("mouseselection_true_words.qml") << 2 << 30 << "0123456789 ABCDEFGHIJKLMNOPQRSTUVWXYZ"; - QTest::newRow("on word selection (9,13)") << testFile("mouseselection_true_words.qml") << 9 << 13 << "0123456789 ABCDEFGHIJKLMNOPQRSTUVWXYZ"; - QTest::newRow("on word selection (9,30)") << testFile("mouseselection_true_words.qml") << 9 << 30 << "0123456789 ABCDEFGHIJKLMNOPQRSTUVWXYZ"; - QTest::newRow("on word selection (13,2)") << testFile("mouseselection_true_words.qml") << 13 << 2 << "0123456789 ABCDEFGHIJKLMNOPQRSTUVWXYZ"; - QTest::newRow("on word selection (20,2)") << testFile("mouseselection_true_words.qml") << 20 << 2 << "0123456789 ABCDEFGHIJKLMNOPQRSTUVWXYZ"; - QTest::newRow("on word selection (12,9)") << testFile("mouseselection_true_words.qml") << 12 << 9 << "0123456789 ABCDEFGHIJKLMNOPQRSTUVWXYZ"; - QTest::newRow("on word selection (30,9)") << testFile("mouseselection_true_words.qml") << 30 << 9 << "0123456789 ABCDEFGHIJKLMNOPQRSTUVWXYZ"; -} - -void tst_qquicktextedit::mouseSelection() -{ - QFETCH(QString, qmlfile); - QFETCH(int, from); - QFETCH(int, to); - QFETCH(QString, selectedText); - - QQuickView canvas(QUrl::fromLocalFile(qmlfile)); - - canvas.show(); - canvas.requestActivateWindow(); - QTest::qWaitForWindowShown(&canvas); - QTRY_COMPARE(&canvas, qGuiApp->focusWindow()); - - QVERIFY(canvas.rootObject() != 0); - QQuickTextEdit *textEditObject = qobject_cast(canvas.rootObject()); - QVERIFY(textEditObject != 0); - - // press-and-drag-and-release from x1 to x2 - QPoint p1 = textEditObject->positionToRectangle(from).center().toPoint(); - QPoint p2 = textEditObject->positionToRectangle(to).center().toPoint(); - QTest::mousePress(&canvas, Qt::LeftButton, 0, p1); - QTest::mouseMove(&canvas, p2); - QTest::mouseRelease(&canvas, Qt::LeftButton, 0, p2); - QTest::qWait(50); - QTRY_COMPARE(textEditObject->selectedText(), selectedText); - - // Clicking and shift to clicking between the same points should select the same text. - textEditObject->setCursorPosition(0); - QTest::mouseClick(&canvas, Qt::LeftButton, Qt::NoModifier, p1); - QTest::mouseClick(&canvas, Qt::LeftButton, Qt::ShiftModifier, p2); - QTest::qWait(50); - QTRY_COMPARE(textEditObject->selectedText(), selectedText); -} - -void tst_qquicktextedit::dragMouseSelection() -{ - QString qmlfile = testFile("mouseselection_true.qml"); - - QQuickView canvas(QUrl::fromLocalFile(qmlfile)); - - canvas.show(); - canvas.requestActivateWindow(); - QTest::qWaitForWindowShown(&canvas); - QTRY_COMPARE(&canvas, qGuiApp->focusWindow()); - - QVERIFY(canvas.rootObject() != 0); - QQuickTextEdit *textEditObject = qobject_cast(canvas.rootObject()); - QVERIFY(textEditObject != 0); - - // press-and-drag-and-release from x1 to x2 - int x1 = 10; - int x2 = 70; - int y = textEditObject->height()/2; - QTest::mousePress(&canvas, Qt::LeftButton, 0, QPoint(x1,y)); - QTest::mouseMove(&canvas, QPoint(x2, y)); - QTest::mouseRelease(&canvas, Qt::LeftButton, 0, QPoint(x2,y)); - QTest::qWait(300); - QString str1; - QTRY_VERIFY((str1 = textEditObject->selectedText()).length() > 3); - - // press and drag the current selection. - x1 = 40; - x2 = 100; - QTest::mousePress(&canvas, Qt::LeftButton, 0, QPoint(x1,y)); - QTest::mouseMove(&canvas, QPoint(x2, y)); - QTest::mouseRelease(&canvas, Qt::LeftButton, 0, QPoint(x2,y)); - QTest::qWait(300); - QString str2; - QTRY_VERIFY((str2 = textEditObject->selectedText()).length() > 3); - - QVERIFY(str1 != str2); // Verify the second press and drag is a new selection and not the first moved. -} - -void tst_qquicktextedit::mouseSelectionMode_data() -{ - QTest::addColumn("qmlfile"); - QTest::addColumn("selectWords"); - - // import installed - QTest::newRow("SelectWords") << testFile("mouseselectionmode_words.qml") << true; - QTest::newRow("SelectCharacters") << testFile("mouseselectionmode_characters.qml") << false; - QTest::newRow("default") << testFile("mouseselectionmode_default.qml") << false; -} - -void tst_qquicktextedit::mouseSelectionMode() -{ - QFETCH(QString, qmlfile); - QFETCH(bool, selectWords); - - QString text = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"; - - QQuickView canvas(QUrl::fromLocalFile(qmlfile)); - - canvas.show(); - canvas.requestActivateWindow(); - QTest::qWaitForWindowShown(&canvas); - QTRY_COMPARE(&canvas, qGuiApp->focusWindow()); - - QVERIFY(canvas.rootObject() != 0); - QQuickTextEdit *textEditObject = qobject_cast(canvas.rootObject()); - QVERIFY(textEditObject != 0); - - // press-and-drag-and-release from x1 to x2 - int x1 = 10; - int x2 = 70; - int y = textEditObject->height()/2; - QTest::mousePress(&canvas, Qt::LeftButton, 0, QPoint(x1,y)); - QTest::mouseMove(&canvas, QPoint(x2, y)); - //QTest::mouseMove(canvas, QPoint(x2,y)); // doesn't work -// QMouseEvent mv(QEvent::MouseMove, QPoint(x2,y), Qt::LeftButton, Qt::LeftButton,Qt::NoModifier); -// QGuiApplication::sendEvent(&canvas, &mv); - QTest::mouseRelease(&canvas, Qt::LeftButton, 0, QPoint(x2,y)); - QString str = textEditObject->selectedText(); - if (selectWords) { - QTRY_COMPARE(textEditObject->selectedText(), text); - } else { - QTRY_VERIFY(textEditObject->selectedText().length() > 3); - QVERIFY(str != text); - } -} - -void tst_qquicktextedit::inputMethodHints() -{ - QQuickView canvas(testFileUrl("inputmethodhints.qml")); - canvas.show(); - canvas.requestActivateWindow(); - - QVERIFY(canvas.rootObject() != 0); - QQuickTextEdit *textEditObject = qobject_cast(canvas.rootObject()); - QVERIFY(textEditObject != 0); - QVERIFY(textEditObject->inputMethodHints() & Qt::ImhNoPredictiveText); - QSignalSpy inputMethodHintSpy(textEditObject, SIGNAL(inputMethodHintsChanged())); - textEditObject->setInputMethodHints(Qt::ImhUppercaseOnly); - QVERIFY(textEditObject->inputMethodHints() & Qt::ImhUppercaseOnly); - QCOMPARE(inputMethodHintSpy.count(), 1); - textEditObject->setInputMethodHints(Qt::ImhUppercaseOnly); - QCOMPARE(inputMethodHintSpy.count(), 1); - - QQuickTextEdit plainTextEdit; - QCOMPARE(plainTextEdit.inputMethodHints(), Qt::ImhNone); -} - -void tst_qquicktextedit::positionAt() -{ - QQuickView canvas(testFileUrl("positionAt.qml")); - QVERIFY(canvas.rootObject() != 0); - canvas.show(); - canvas.requestActivateWindow(); - canvas.requestActivateWindow(); - QTest::qWaitForWindowShown(&canvas); - - QQuickTextEdit *texteditObject = qobject_cast(canvas.rootObject()); - QVERIFY(texteditObject != 0); - - QTextLayout layout(texteditObject->text()); - layout.setFont(texteditObject->font()); - - if (!qmlDisableDistanceField()) { - QTextOption option; - option.setUseDesignMetrics(true); - layout.setTextOption(option); - } - - layout.beginLayout(); - QTextLine line = layout.createLine(); - layout.endLayout(); - - const int y0 = line.height() / 2; - const int y1 = line.height() * 3 / 2; - - int pos = texteditObject->positionAt(texteditObject->width()/2, y0); - - int widthBegin = floor(line.cursorToX(pos - 1)); - int widthEnd = ceil(line.cursorToX(pos + 1)); - - QVERIFY(widthBegin <= texteditObject->width() / 2); - QVERIFY(widthEnd >= texteditObject->width() / 2); - - const qreal x0 = texteditObject->positionToRectangle(pos).x(); - const qreal x1 = texteditObject->positionToRectangle(pos + 1).x(); - - QString preeditText = texteditObject->text().mid(0, pos); - texteditObject->setText(texteditObject->text().mid(pos)); - texteditObject->setCursorPosition(0); - - QInputMethodEvent inputEvent(preeditText, QList()); - QGuiApplication::sendEvent(qGuiApp->focusObject(), &inputEvent); - - // Check all points within the preedit text return the same position. - QCOMPARE(texteditObject->positionAt(0, y0), 0); - QCOMPARE(texteditObject->positionAt(x0 / 2, y0), 0); - QCOMPARE(texteditObject->positionAt(x0, y0), 0); - - // Verify positioning returns to normal after the preedit text. - QCOMPARE(texteditObject->positionAt(x1, y0), 1); - QCOMPARE(texteditObject->positionToRectangle(1).x(), x1); - - QVERIFY(texteditObject->positionAt(x0 / 2, y1) > 0); -} - -void tst_qquicktextedit::linkActivated() -{ - QQuickView canvas(testFileUrl("linkActivated.qml")); - QVERIFY(canvas.rootObject() != 0); - canvas.show(); - canvas.requestActivateWindow(); - QTest::qWaitForWindowShown(&canvas); - - QQuickTextEdit *texteditObject = qobject_cast(canvas.rootObject()); - QVERIFY(texteditObject != 0); - - QSignalSpy spy(texteditObject, SIGNAL(linkActivated(QString))); - - const QString link("http://example.com/"); - - const QPointF linkPos = texteditObject->positionToRectangle(7).center(); - const QPointF textPos = texteditObject->positionToRectangle(2).center(); - - QTest::mouseClick(&canvas, Qt::LeftButton, 0, linkPos.toPoint()); - QTRY_COMPARE(spy.count(), 1); - QCOMPARE(spy.last()[0].toString(), link); - - QTest::mouseClick(&canvas, Qt::LeftButton, 0, textPos.toPoint()); - QTest::qWait(50); - QCOMPARE(spy.count(), 1); - - texteditObject->setReadOnly(true); - - QTest::mouseClick(&canvas, Qt::LeftButton, 0, linkPos.toPoint()); - QTRY_COMPARE(spy.count(), 2); - QCOMPARE(spy.last()[0].toString(), link); - - QTest::mouseClick(&canvas, Qt::LeftButton, 0, textPos.toPoint()); - QTest::qWait(50); - QCOMPARE(spy.count(), 2); -} - -void tst_qquicktextedit::cursorDelegate_data() -{ - QTest::addColumn("source"); - QTest::newRow("out of line") << testFileUrl("cursorTest.qml"); - QTest::newRow("in line") << testFileUrl("cursorTestInline.qml"); - QTest::newRow("external") << testFileUrl("cursorTestExternal.qml"); -} - -void tst_qquicktextedit::cursorDelegate() -{ - QFETCH(QUrl, source); - QQuickView view(source); - view.show(); - view.requestActivateWindow(); - QQuickTextEdit *textEditObject = view.rootObject()->findChild("textEditObject"); - QVERIFY(textEditObject != 0); - QVERIFY(textEditObject->findChild("cursorInstance")); - //Test Delegate gets created - textEditObject->setFocus(true); - QQuickItem* delegateObject = textEditObject->findChild("cursorInstance"); - QVERIFY(delegateObject); - QCOMPARE(delegateObject->property("localProperty").toString(), QString("Hello")); - //Test Delegate gets moved - for (int i=0; i<= textEditObject->text().length(); i++) { - textEditObject->setCursorPosition(i); - QCOMPARE(textEditObject->cursorRectangle().x(), qRound(delegateObject->x())); - QCOMPARE(textEditObject->cursorRectangle().y(), qRound(delegateObject->y())); - } - // Clear preedit text; - QInputMethodEvent event; - QGuiApplication::sendEvent(&view, &event); - - - // Test delegate gets moved on mouse press. - textEditObject->setSelectByMouse(true); - textEditObject->setCursorPosition(0); - const QPoint point1 = textEditObject->positionToRectangle(5).center().toPoint(); - QTest::mouseClick(&view, Qt::LeftButton, 0, point1); - QTest::qWait(50); - QTRY_VERIFY(textEditObject->cursorPosition() != 0); - QCOMPARE(textEditObject->cursorRectangle().x(), qRound(delegateObject->x())); - QCOMPARE(textEditObject->cursorRectangle().y(), qRound(delegateObject->y())); - - // Test delegate gets moved on mouse drag - textEditObject->setCursorPosition(0); - const QPoint point2 = textEditObject->positionToRectangle(10).center().toPoint(); - QTest::mousePress(&view, Qt::LeftButton, 0, point1); - QMouseEvent mv(QEvent::MouseMove, point2, Qt::LeftButton, Qt::LeftButton,Qt::NoModifier); - QGuiApplication::sendEvent(&view, &mv); - QTest::mouseRelease(&view, Qt::LeftButton, 0, point2); - QTest::qWait(50); - QTRY_COMPARE(textEditObject->cursorRectangle().x(), qRound(delegateObject->x())); - QCOMPARE(textEditObject->cursorRectangle().y(), qRound(delegateObject->y())); - - textEditObject->setReadOnly(true); - textEditObject->setCursorPosition(0); - QTest::mouseClick(&view, Qt::LeftButton, 0, textEditObject->positionToRectangle(5).center().toPoint()); - QTest::qWait(50); - QTRY_VERIFY(textEditObject->cursorPosition() != 0); - QCOMPARE(textEditObject->cursorRectangle().x(), qRound(delegateObject->x())); - QCOMPARE(textEditObject->cursorRectangle().y(), qRound(delegateObject->y())); - - textEditObject->setCursorPosition(0); - QTest::mouseClick(&view, Qt::LeftButton, 0, textEditObject->positionToRectangle(5).center().toPoint()); - QTest::qWait(50); - QTRY_VERIFY(textEditObject->cursorPosition() != 0); - QCOMPARE(textEditObject->cursorRectangle().x(), qRound(delegateObject->x())); - QCOMPARE(textEditObject->cursorRectangle().y(), qRound(delegateObject->y())); - - textEditObject->setCursorPosition(0); - QCOMPARE(textEditObject->cursorRectangle().x(), qRound(delegateObject->x())); - QCOMPARE(textEditObject->cursorRectangle().y(), qRound(delegateObject->y())); - //Test Delegate gets deleted - textEditObject->setCursorDelegate(0); - QVERIFY(!textEditObject->findChild("cursorInstance")); -} - -void tst_qquicktextedit::cursorVisible() -{ - QQuickView view(testFileUrl("cursorVisible.qml")); - view.show(); - view.requestActivateWindow(); - QTest::qWaitForWindowShown(&view); - QTRY_COMPARE(&view, qGuiApp->focusWindow()); - - QQuickTextEdit edit; - QSignalSpy spy(&edit, SIGNAL(cursorVisibleChanged(bool))); - - QCOMPARE(edit.isCursorVisible(), false); - - edit.setCursorVisible(true); - QCOMPARE(edit.isCursorVisible(), true); - QCOMPARE(spy.count(), 1); - - edit.setCursorVisible(false); - QCOMPARE(edit.isCursorVisible(), false); - QCOMPARE(spy.count(), 2); - - edit.setFocus(true); - QCOMPARE(edit.isCursorVisible(), false); - QCOMPARE(spy.count(), 2); - - edit.setParentItem(view.rootObject()); - QCOMPARE(edit.isCursorVisible(), true); - QCOMPARE(spy.count(), 3); - - edit.setFocus(false); - QCOMPARE(edit.isCursorVisible(), false); - QCOMPARE(spy.count(), 4); - - edit.setFocus(true); - QCOMPARE(edit.isCursorVisible(), true); - QCOMPARE(spy.count(), 5); - - QQuickView alternateView; - alternateView.show(); - alternateView.requestActivateWindow(); - QTest::qWaitForWindowShown(&alternateView); - - QCOMPARE(edit.isCursorVisible(), false); - QCOMPARE(spy.count(), 6); - - view.requestActivateWindow(); - QTest::qWaitForWindowShown(&view); - QCOMPARE(edit.isCursorVisible(), true); - QCOMPARE(spy.count(), 7); -} - -void tst_qquicktextedit::delegateLoading_data() -{ - QTest::addColumn("qmlfile"); - QTest::addColumn("error"); - - // import installed - QTest::newRow("pass") << "cursorHttpTestPass.qml" << ""; - QTest::newRow("fail1") << "cursorHttpTestFail1.qml" << "http://localhost:42332/FailItem.qml: Remote host closed the connection "; - QTest::newRow("fail2") << "cursorHttpTestFail2.qml" << "http://localhost:42332/ErrItem.qml:4:5: Fungus is not a type "; -} - -void tst_qquicktextedit::delegateLoading() -{ -#ifdef Q_OS_MAC - QSKIP("Test crashes during canvas tear down. QTBUG-23010"); -#endif - QFETCH(QString, qmlfile); - QFETCH(QString, error); - - TestHTTPServer server(42332); - server.serveDirectory(testFile("httpfail"), TestHTTPServer::Disconnect); - server.serveDirectory(testFile("httpslow"), TestHTTPServer::Delay); - server.serveDirectory(testFile("http")); - - QQuickView view(QUrl(QLatin1String("http://localhost:42332/") + qmlfile)); - view.show(); - view.requestActivateWindow(); - - if (!error.isEmpty()) { - QTest::ignoreMessage(QtWarningMsg, error.toUtf8()); - QTRY_VERIFY(view.status()==QQuickView::Error); - QTRY_VERIFY(!view.rootObject()); // there is fail item inside this test - } else { - QTRY_VERIFY(view.rootObject());//Wait for loading to finish. - QQuickTextEdit *textEditObject = view.rootObject()->findChild("textEditObject"); - // view.rootObject()->dumpObjectTree(); - QVERIFY(textEditObject != 0); - textEditObject->setFocus(true); - QQuickItem *delegate; - delegate = view.rootObject()->findChild("delegateOkay"); - QVERIFY(delegate); - delegate = view.rootObject()->findChild("delegateSlow"); - QVERIFY(delegate); - - delete delegate; - } - - - //A test should be added here with a component which is ready but component.create() returns null - //Not sure how to accomplish this with QQuickTextEdits cursor delegate - //###This was only needed for code coverage, and could be a case of overzealous defensive programming - //delegate = view.rootObject()->findChild("delegateErrorB"); - //QVERIFY(!delegate); -} - -/* -TextEdit element should only handle left/right keys until the cursor reaches -the extent of the text, then they should ignore the keys. -*/ -void tst_qquicktextedit::navigation() -{ - QQuickView canvas(testFileUrl("navigation.qml")); - canvas.show(); - canvas.requestActivateWindow(); - - QVERIFY(canvas.rootObject() != 0); - - QQuickItem *input = qobject_cast(qvariant_cast(canvas.rootObject()->property("myInput"))); - - QVERIFY(input != 0); - QTRY_VERIFY(input->hasActiveFocus() == true); - simulateKey(&canvas, Qt::Key_Left); - QVERIFY(input->hasActiveFocus() == false); - simulateKey(&canvas, Qt::Key_Right); - QVERIFY(input->hasActiveFocus() == true); - simulateKey(&canvas, Qt::Key_Right); - QVERIFY(input->hasActiveFocus() == true); - simulateKey(&canvas, Qt::Key_Right); - QVERIFY(input->hasActiveFocus() == false); - simulateKey(&canvas, Qt::Key_Left); - QVERIFY(input->hasActiveFocus() == true); -} - -void tst_qquicktextedit::copyAndPaste() { -#ifndef QT_NO_CLIPBOARD - -#ifdef Q_OS_MAC - { - PasteboardRef pasteboard; - OSStatus status = PasteboardCreate(0, &pasteboard); - if (status == noErr) - CFRelease(pasteboard); - else - QSKIP("This machine doesn't support the clipboard"); - } -#endif - - QString componentStr = "import QtQuick 2.0\nTextEdit { text: \"Hello world!\" }"; - QDeclarativeComponent textEditComponent(&engine); - textEditComponent.setData(componentStr.toLatin1(), QUrl()); - QQuickTextEdit *textEdit = qobject_cast(textEditComponent.create()); - QVERIFY(textEdit != 0); - - // copy and paste - QCOMPARE(textEdit->text().length(), 12); - textEdit->select(0, textEdit->text().length());; - textEdit->copy(); - QCOMPARE(textEdit->selectedText(), QString("Hello world!")); - QCOMPARE(textEdit->selectedText().length(), 12); - textEdit->setCursorPosition(0); - QVERIFY(textEdit->canPaste()); - textEdit->paste(); - QCOMPARE(textEdit->text(), QString("Hello world!Hello world!")); - QCOMPARE(textEdit->text().length(), 24); - - // canPaste - QVERIFY(textEdit->canPaste()); - textEdit->setReadOnly(true); - QVERIFY(!textEdit->canPaste()); - textEdit->setReadOnly(false); - QVERIFY(textEdit->canPaste()); - - // QTBUG-12339 - // test that document and internal text attribute are in sync - QQuickItemPrivate* pri = QQuickItemPrivate::get(textEdit); - QQuickTextEditPrivate *editPrivate = static_cast(pri); - QCOMPARE(textEdit->text(), editPrivate->text); - - // select word - textEdit->setCursorPosition(0); - textEdit->selectWord(); - QCOMPARE(textEdit->selectedText(), QString("Hello")); - - // select all and cut - textEdit->selectAll(); - textEdit->cut(); - QCOMPARE(textEdit->text().length(), 0); - textEdit->paste(); - QCOMPARE(textEdit->text(), QString("Hello world!Hello world!")); - QCOMPARE(textEdit->text().length(), 24); -#endif -} - -void tst_qquicktextedit::canPaste() { -#ifndef QT_NO_CLIPBOARD - - QGuiApplication::clipboard()->setText("Some text"); - - QString componentStr = "import QtQuick 2.0\nTextEdit { text: \"Hello world!\" }"; - QDeclarativeComponent textEditComponent(&engine); - textEditComponent.setData(componentStr.toLatin1(), QUrl()); - QQuickTextEdit *textEdit = qobject_cast(textEditComponent.create()); - QVERIFY(textEdit != 0); - - // check initial value - QTBUG-17765 - QQuickTextControl tc(0); - QCOMPARE(textEdit->canPaste(), tc.canPaste()); - -#endif -} - -void tst_qquicktextedit::canPasteEmpty() { -#ifndef QT_NO_CLIPBOARD - - QGuiApplication::clipboard()->clear(); - - QString componentStr = "import QtQuick 2.0\nTextEdit { text: \"Hello world!\" }"; - QDeclarativeComponent textEditComponent(&engine); - textEditComponent.setData(componentStr.toLatin1(), QUrl()); - QQuickTextEdit *textEdit = qobject_cast(textEditComponent.create()); - QVERIFY(textEdit != 0); - - // check initial value - QTBUG-17765 - QQuickTextControl tc(0); - QCOMPARE(textEdit->canPaste(), tc.canPaste()); - -#endif -} - -void tst_qquicktextedit::readOnly() -{ - QQuickView canvas(testFileUrl("readOnly.qml")); - canvas.show(); - canvas.requestActivateWindow(); - - QVERIFY(canvas.rootObject() != 0); - - QQuickTextEdit *edit = qobject_cast(qvariant_cast(canvas.rootObject()->property("myInput"))); - - QVERIFY(edit != 0); - QTRY_VERIFY(edit->hasActiveFocus() == true); - QVERIFY(edit->isReadOnly() == true); - QString initial = edit->text(); - for (int k=Qt::Key_0; k<=Qt::Key_Z; k++) - simulateKey(&canvas, k); - simulateKey(&canvas, Qt::Key_Return); - simulateKey(&canvas, Qt::Key_Space); - simulateKey(&canvas, Qt::Key_Escape); - QCOMPARE(edit->text(), initial); - - edit->setCursorPosition(3); - edit->setReadOnly(false); - QCOMPARE(edit->isReadOnly(), false); - QCOMPARE(edit->cursorPosition(), edit->text().length()); -} - -void tst_qquicktextedit::simulateKey(QQuickView *view, int key, Qt::KeyboardModifiers modifiers) -{ - QKeyEvent press(QKeyEvent::KeyPress, key, modifiers); - QKeyEvent release(QKeyEvent::KeyRelease, key, modifiers); - - QGuiApplication::sendEvent(view, &press); - QGuiApplication::sendEvent(view, &release); -} - -void tst_qquicktextedit::textInput() -{ - QQuickView view(testFileUrl("inputMethodEvent.qml")); - view.show(); - view.requestActivateWindow(); - QTest::qWaitForWindowShown(&view); - QTRY_COMPARE(&view, qGuiApp->focusWindow()); - QQuickTextEdit *edit = qobject_cast(view.rootObject()); - QVERIFY(edit); - QVERIFY(edit->hasActiveFocus() == true); - - // test that input method event is committed and change signal is emitted - QSignalSpy spy(edit, SIGNAL(textChanged())); - QInputMethodEvent event; - event.setCommitString( "Hello world!", 0, 0); - QGuiApplication::sendEvent(qGuiApp->focusObject(), &event); - QCOMPARE(edit->text(), QString("Hello world!")); - QCOMPARE(spy.count(), 1); - - // QTBUG-12339 - // test that document and internal text attribute are in sync - QQuickTextEditPrivate *editPrivate = static_cast(QQuickItemPrivate::get(edit)); - QCOMPARE(editPrivate->text, QString("Hello world!")); - - // test that tentative commit is included in text property - edit->setText(""); - spy.clear(); - QList attributes; - QInputMethodEvent event2("preedit", attributes); - event2.setTentativeCommitString("string"); - QGuiApplication::sendEvent(qGuiApp->focusObject(), &event2); - QCOMPARE(spy.count(), 1); - QCOMPARE(edit->text(), QString("string")); - - QInputMethodQueryEvent queryEvent(Qt::ImEnabled); - QGuiApplication::sendEvent(qGuiApp->focusObject(), &queryEvent); - QCOMPARE(queryEvent.value(Qt::ImEnabled).toBool(), true); - - edit->setReadOnly(true); - QGuiApplication::sendEvent(edit, &queryEvent); - QCOMPARE(queryEvent.value(Qt::ImEnabled).toBool(), false); -} - -void tst_qquicktextedit::inputMethodUpdate() -{ - PlatformInputContext platformInputContext; - QInputMethodPrivate *inputMethodPrivate = QInputMethodPrivate::get(qApp->inputMethod()); - inputMethodPrivate->testContext = &platformInputContext; - - QQuickView view(testFileUrl("inputMethodEvent.qml")); - view.show(); - view.requestActivateWindow(); - QTest::qWaitForWindowShown(&view); - QTRY_COMPARE(&view, qGuiApp->focusWindow()); - QQuickTextEdit *edit = qobject_cast(view.rootObject()); - QVERIFY(edit); - QVERIFY(edit->hasActiveFocus() == true); - - // text change even without cursor position change needs to trigger update - edit->setText("test"); - platformInputContext.clear(); - edit->setText("xxxx"); - QVERIFY(platformInputContext.m_updateCallCount > 0); - - // input method event replacing text - platformInputContext.clear(); - { - QInputMethodEvent inputMethodEvent; - inputMethodEvent.setCommitString("y", -1, 1); - QGuiApplication::sendEvent(edit, &inputMethodEvent); - } - QVERIFY(platformInputContext.m_updateCallCount > 0); - - // input method changing selection - platformInputContext.clear(); - { - QList attributes; - attributes << QInputMethodEvent::Attribute(QInputMethodEvent::Selection, 0, 2, QVariant()); - QInputMethodEvent inputMethodEvent("", attributes); - QGuiApplication::sendEvent(edit, &inputMethodEvent); - } - QVERIFY(edit->selectionStart() != edit->selectionEnd()); - QVERIFY(platformInputContext.m_updateCallCount > 0); - - // font changes - platformInputContext.clear(); - QFont font = edit->font(); - font.setBold(!font.bold()); - edit->setFont(font); - QVERIFY(platformInputContext.m_updateCallCount > 0); - - // normal input - platformInputContext.clear(); - { - QInputMethodEvent inputMethodEvent; - inputMethodEvent.setCommitString("y"); - QGuiApplication::sendEvent(edit, &inputMethodEvent); - } - QVERIFY(platformInputContext.m_updateCallCount > 0); - - // changing cursor position - platformInputContext.clear(); - edit->setCursorPosition(0); - QVERIFY(platformInputContext.m_updateCallCount > 0); - - // continuing with selection - platformInputContext.clear(); - edit->moveCursorSelection(1); - QVERIFY(platformInputContext.m_updateCallCount > 0); - - // read only disabled input method - platformInputContext.clear(); - edit->setReadOnly(true); - QVERIFY(platformInputContext.m_updateCallCount > 0); - edit->setReadOnly(false); - - // no updates while no focus - edit->setFocus(false); - platformInputContext.clear(); - edit->setText("Foo"); - QCOMPARE(platformInputContext.m_updateCallCount, 0); - edit->setCursorPosition(1); - QCOMPARE(platformInputContext.m_updateCallCount, 0); - edit->selectAll(); - QCOMPARE(platformInputContext.m_updateCallCount, 0); - edit->setReadOnly(true); - QCOMPARE(platformInputContext.m_updateCallCount, 0); -} - -void tst_qquicktextedit::openInputPanel() -{ - PlatformInputContext platformInputContext; - QInputMethodPrivate *inputMethodPrivate = QInputMethodPrivate::get(qApp->inputMethod()); - inputMethodPrivate->testContext = &platformInputContext; - - QQuickView view(testFileUrl("openInputPanel.qml")); - view.show(); - view.requestActivateWindow(); - QTest::qWaitForWindowShown(&view); - QTRY_COMPARE(&view, qGuiApp->focusWindow()); - - QQuickTextEdit *edit = qobject_cast(view.rootObject()); - QVERIFY(edit); - - // check default values - QVERIFY(edit->focusOnPress()); - QVERIFY(!edit->hasActiveFocus()); - qDebug() << &edit << qApp->focusObject(); - QVERIFY(qApp->focusObject() != edit); - - QCOMPARE(qApp->inputMethod()->visible(), false); - - // input panel should open on focus - QPoint centerPoint(view.width()/2, view.height()/2); - Qt::KeyboardModifiers noModifiers = 0; - QTest::mousePress(&view, Qt::LeftButton, noModifiers, centerPoint); - QGuiApplication::processEvents(); - QVERIFY(edit->hasActiveFocus()); - QCOMPARE(qApp->focusObject(), edit); - QCOMPARE(qApp->inputMethod()->visible(), true); - QTest::mouseRelease(&view, Qt::LeftButton, noModifiers, centerPoint); - - // input panel should be re-opened when pressing already focused TextEdit - qApp->inputMethod()->hide(); - QCOMPARE(qApp->inputMethod()->visible(), false); - QVERIFY(edit->hasActiveFocus()); - QTest::mousePress(&view, Qt::LeftButton, noModifiers, centerPoint); - QGuiApplication::processEvents(); - QCOMPARE(qApp->inputMethod()->visible(), true); - QTest::mouseRelease(&view, Qt::LeftButton, noModifiers, centerPoint); - - // input panel should stay visible if focus is lost to another text editor - QSignalSpy inputPanelVisibilitySpy(qApp->inputMethod(), SIGNAL(visibleChanged())); - QQuickTextEdit anotherEdit; - anotherEdit.setParentItem(view.rootObject()); - anotherEdit.setFocus(true); - QCOMPARE(qApp->inputMethod()->visible(), true); - QCOMPARE(qApp->focusObject(), qobject_cast(&anotherEdit)); - QCOMPARE(inputPanelVisibilitySpy.count(), 0); - - anotherEdit.setFocus(false); - QVERIFY(qApp->focusObject() != &anotherEdit); - QCOMPARE(view.activeFocusItem(), view.rootItem()); - anotherEdit.setFocus(true); - - qApp->inputMethod()->hide(); - - // input panel should not be opened if TextEdit is read only - edit->setReadOnly(true); - edit->setFocus(true); - QCOMPARE(qApp->inputMethod()->visible(), false); - QTest::mousePress(&view, Qt::LeftButton, noModifiers, centerPoint); - QTest::mouseRelease(&view, Qt::LeftButton, noModifiers, centerPoint); - QGuiApplication::processEvents(); - QCOMPARE(qApp->inputMethod()->visible(), false); - - // input panel should not be opened if focusOnPress is set to false - edit->setFocusOnPress(false); - edit->setFocus(false); - edit->setFocus(true); - QCOMPARE(qApp->inputMethod()->visible(), false); - QTest::mousePress(&view, Qt::LeftButton, noModifiers, centerPoint); - QTest::mouseRelease(&view, Qt::LeftButton, noModifiers, centerPoint); - QCOMPARE(qApp->inputMethod()->visible(), false); - - // input panel should open when openSoftwareInputPanel is called - edit->openSoftwareInputPanel(); - QCOMPARE(qApp->inputMethod()->visible(), true); - - // input panel should close when closeSoftwareInputPanel is called - edit->closeSoftwareInputPanel(); - QCOMPARE(qApp->inputMethod()->visible(), false); - - inputMethodPrivate->testContext = 0; -} - -void tst_qquicktextedit::geometrySignals() -{ - QDeclarativeComponent component(&engine, testFileUrl("geometrySignals.qml")); - QObject *o = component.create(); - QVERIFY(o); - QCOMPARE(o->property("bindingWidth").toInt(), 400); - QCOMPARE(o->property("bindingHeight").toInt(), 500); - delete o; -} - -void tst_qquicktextedit::pastingRichText_QTBUG_14003() -{ -#ifndef QT_NO_CLIPBOARD - QString componentStr = "import QtQuick 2.0\nTextEdit { textFormat: TextEdit.PlainText }"; - QDeclarativeComponent component(&engine); - component.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); - QQuickTextEdit *obj = qobject_cast(component.create()); - - QTRY_VERIFY(obj != 0); - QTRY_VERIFY(obj->textFormat() == QQuickTextEdit::PlainText); - - QMimeData *mData = new QMimeData; - mData->setHtml("Hello"); - QGuiApplication::clipboard()->setMimeData(mData); - - obj->paste(); - QTRY_VERIFY(obj->text() == ""); - QTRY_VERIFY(obj->textFormat() == QQuickTextEdit::PlainText); -#endif -} - -void tst_qquicktextedit::implicitSize_data() -{ - QTest::addColumn("text"); - QTest::addColumn("wrap"); - QTest::newRow("plain") << "The quick red fox jumped over the lazy brown dog" << "TextEdit.NoWrap"; - QTest::newRow("richtext") << "The quick red fox jumped over the lazy brown dog" << "TextEdit.NoWrap"; - QTest::newRow("plain_wrap") << "The quick red fox jumped over the lazy brown dog" << "TextEdit.Wrap"; - QTest::newRow("richtext_wrap") << "The quick red fox jumped over the lazy brown dog" << "TextEdit.Wrap"; -} - -void tst_qquicktextedit::implicitSize() -{ - QFETCH(QString, text); - QFETCH(QString, wrap); - QString componentStr = "import QtQuick 2.0\nTextEdit { text: \"" + text + "\"; width: 50; wrapMode: " + wrap + " }"; - QDeclarativeComponent textComponent(&engine); - textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); - QQuickTextEdit *textObject = qobject_cast(textComponent.create()); - - QVERIFY(textObject->width() < textObject->implicitWidth()); - QVERIFY(textObject->height() == textObject->implicitHeight()); - - textObject->resetWidth(); - QVERIFY(textObject->width() == textObject->implicitWidth()); - QVERIFY(textObject->height() == textObject->implicitHeight()); -} - -void tst_qquicktextedit::contentSize() -{ - QString componentStr = "import QtQuick 2.0\nTextEdit { width: 75; height: 16; font.pixelSize: 10 }"; - QDeclarativeComponent textComponent(&engine); - textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); - QScopedPointer object(textComponent.create()); - QQuickTextEdit *textObject = qobject_cast(object.data()); - - QSignalSpy spy(textObject, SIGNAL(contentSizeChanged())); - - textObject->setText("The quick red fox jumped over the lazy brown dog"); - - QVERIFY(textObject->contentWidth() > textObject->width()); - QVERIFY(textObject->contentHeight() < textObject->height()); - QCOMPARE(spy.count(), 1); - - textObject->setWrapMode(QQuickTextEdit::WordWrap); - QVERIFY(textObject->contentWidth() <= textObject->width()); - QVERIFY(textObject->contentHeight() > textObject->height()); - QCOMPARE(spy.count(), 2); - - textObject->setText("The quickredfoxjumpedoverthe lazy brown dog"); - - QVERIFY(textObject->contentWidth() > textObject->width()); - QVERIFY(textObject->contentHeight() > textObject->height()); - QCOMPARE(spy.count(), 3); -} - -void tst_qquicktextedit::preeditCursorRectangle() -{ - QString preeditText = "super"; - - QQuickView view(testFileUrl("inputMethodEvent.qml")); - view.show(); - view.requestActivateWindow(); - QTest::qWaitForWindowShown(&view); - - QTRY_COMPARE(&view, qGuiApp->focusWindow()); - QQuickTextEdit *edit = qobject_cast(view.rootObject()); - QVERIFY(edit); - - QSignalSpy editSpy(edit, SIGNAL(cursorRectangleChanged())); - QSignalSpy panelSpy(qGuiApp->inputMethod(), SIGNAL(cursorRectangleChanged())); - - QRect currentRect; - - QInputMethodQueryEvent query(Qt::ImCursorRectangle); - QCoreApplication::sendEvent(qGuiApp->focusObject(), &query); - QRect previousRect = query.value(Qt::ImCursorRectangle).toRect(); - - // Verify that the micro focus rect is positioned the same for position 0 as - // it would be if there was no preedit text. - QInputMethodEvent imEvent(preeditText, QList() - << QInputMethodEvent::Attribute(QInputMethodEvent::Cursor, 0, preeditText.length(), QVariant())); - QCoreApplication::sendEvent(qGuiApp->focusObject(), &imEvent); - QCoreApplication::sendEvent(qGuiApp->focusObject(), &query); - currentRect = query.value(Qt::ImCursorRectangle).toRect(); - QCOMPARE(currentRect, previousRect); - QCOMPARE(editSpy.count(), 0); - QCOMPARE(panelSpy.count(), 0); - - // Verify that the micro focus rect moves to the left as the cursor position - // is incremented. - for (int i = 1; i <= 5; ++i) { - QInputMethodEvent imEvent(preeditText, QList() - << QInputMethodEvent::Attribute(QInputMethodEvent::Cursor, i, preeditText.length(), QVariant())); - QCoreApplication::sendEvent(qGuiApp->focusObject(), &imEvent); - QCoreApplication::sendEvent(qGuiApp->focusObject(), &query); - currentRect = query.value(Qt::ImCursorRectangle).toRect(); - QVERIFY(previousRect.left() < currentRect.left()); - QVERIFY(editSpy.count() > 0); editSpy.clear(); - QVERIFY(panelSpy.count() > 0); panelSpy.clear(); - previousRect = currentRect; - } - - // Verify that if there is no preedit cursor then the micro focus rect is the - // same as it would be if it were positioned at the end of the preedit text. - QCoreApplication::sendEvent(qGuiApp->focusObject(), &imEvent); - editSpy.clear(); - panelSpy.clear(); - { QInputMethodEvent imEvent(preeditText, QList()); - QCoreApplication::sendEvent(qGuiApp->focusObject(), &imEvent); } - QCoreApplication::sendEvent(qGuiApp->focusObject(), &query); - currentRect = query.value(Qt::ImCursorRectangle).toRect(); - QCOMPARE(currentRect, previousRect); - QVERIFY(editSpy.count() > 0); - QVERIFY(panelSpy.count() > 0); -} - -void tst_qquicktextedit::inputMethodComposing() -{ - QString text = "supercalifragisiticexpialidocious!"; - - QQuickView view(testFileUrl("inputContext.qml")); - view.show(); - view.requestActivateWindow(); - QTest::qWaitForWindowShown(&view); - QTRY_COMPARE(&view, qGuiApp->focusWindow()); - QQuickTextEdit *edit = qobject_cast(view.rootObject()); - QVERIFY(edit); - QSignalSpy spy(edit, SIGNAL(inputMethodComposingChanged())); - edit->setCursorPosition(12); - - QCOMPARE(edit->isInputMethodComposing(), false); - - { - QInputMethodEvent event(text.mid(3), QList()); - QGuiApplication::sendEvent(edit, &event); - } - - QCOMPARE(edit->isInputMethodComposing(), true); - QCOMPARE(spy.count(), 1); - - { - QInputMethodEvent event(text.mid(12), QList()); - QGuiApplication::sendEvent(edit, &event); - } - QCOMPARE(spy.count(), 1); - - { - QInputMethodEvent event; - QGuiApplication::sendEvent(edit, &event); - } - QCOMPARE(edit->isInputMethodComposing(), false); - QCOMPARE(spy.count(), 2); -} - -void tst_qquicktextedit::cursorRectangleSize() -{ - QQuickView *canvas = new QQuickView(testFileUrl("positionAt.qml")); - QVERIFY(canvas->rootObject() != 0); - QQuickTextEdit *textEdit = qobject_cast(canvas->rootObject()); - - // make sure cursor rectangle is not at (0,0) - textEdit->setX(10); - textEdit->setY(10); - textEdit->setCursorPosition(3); - QVERIFY(textEdit != 0); - textEdit->setFocus(true); - canvas->show(); - canvas->requestActivateWindow(); - QTest::qWaitForWindowShown(canvas); - - QInputMethodQueryEvent event(Qt::ImCursorRectangle); - qApp->sendEvent(qApp->focusObject(), &event); - QRectF cursorRectFromQuery = event.value(Qt::ImCursorRectangle).toRectF(); - - QRect cursorRectFromItem = textEdit->cursorRectangle(); - QRectF cursorRectFromPositionToRectangle = textEdit->positionToRectangle(textEdit->cursorPosition()); - - // item and input query cursor rectangles match - QCOMPARE(cursorRectFromItem, cursorRectFromQuery.toRect()); - - // item cursor rectangle and positionToRectangle calculations match - QCOMPARE(cursorRectFromItem, cursorRectFromPositionToRectangle.toRect()); - - // item-canvas transform and input item transform match - QCOMPARE(QQuickItemPrivate::get(textEdit)->itemToCanvasTransform(), qApp->inputMethod()->inputItemTransform()); - - // input panel cursorRectangle property and tranformed item cursor rectangle match - QRectF sceneCursorRect = QQuickItemPrivate::get(textEdit)->itemToCanvasTransform().mapRect(cursorRectFromItem); - QCOMPARE(sceneCursorRect, qApp->inputMethod()->cursorRectangle()); - - delete canvas; -} - -void tst_qquicktextedit::getText_data() -{ - QTest::addColumn("text"); - QTest::addColumn("start"); - QTest::addColumn("end"); - QTest::addColumn("expectedText"); - - const QString richBoldText = QStringLiteral("This is some bold text"); - const QString plainBoldText = QStringLiteral("This is some bold text"); - - QTest::newRow("all plain text") - << standard.at(0) - << 0 << standard.at(0).length() - << standard.at(0); - - QTest::newRow("plain text sub string") - << standard.at(0) - << 0 << 12 - << standard.at(0).mid(0, 12); - - QTest::newRow("plain text sub string reversed") - << standard.at(0) - << 12 << 0 - << standard.at(0).mid(0, 12); - - QTest::newRow("plain text cropped beginning") - << standard.at(0) - << -3 << 4 - << standard.at(0).mid(0, 4); - - QTest::newRow("plain text cropped end") - << standard.at(0) - << 23 << standard.at(0).length() + 8 - << standard.at(0).mid(23); - - QTest::newRow("plain text cropped beginning and end") - << standard.at(0) - << -9 << standard.at(0).length() + 4 - << standard.at(0); - - QTest::newRow("all rich text") - << richBoldText - << 0 << plainBoldText.length() - << plainBoldText; - - QTest::newRow("rich text sub string") - << richBoldText - << 14 << 21 - << plainBoldText.mid(14, 7); -} - -void tst_qquicktextedit::getText() -{ - QFETCH(QString, text); - QFETCH(int, start); - QFETCH(int, end); - QFETCH(QString, expectedText); - - QString componentStr = "import QtQuick 2.0\nTextEdit { textFormat: TextEdit.AutoText; text: \"" + text + "\" }"; - QDeclarativeComponent textEditComponent(&engine); - textEditComponent.setData(componentStr.toLatin1(), QUrl()); - QQuickTextEdit *textEdit = qobject_cast(textEditComponent.create()); - QVERIFY(textEdit != 0); - - QCOMPARE(textEdit->getText(start, end), expectedText); -} - -void tst_qquicktextedit::getFormattedText_data() -{ - QTest::addColumn("text"); - QTest::addColumn("textFormat"); - QTest::addColumn("start"); - QTest::addColumn("end"); - QTest::addColumn("expectedText"); - - const QString richBoldText = QStringLiteral("This is some bold text"); - const QString plainBoldText = QStringLiteral("This is some bold text"); - - QTest::newRow("all plain text") - << standard.at(0) - << QQuickTextEdit::PlainText - << 0 << standard.at(0).length() - << standard.at(0); - - QTest::newRow("plain text sub string") - << standard.at(0) - << QQuickTextEdit::PlainText - << 0 << 12 - << standard.at(0).mid(0, 12); - - QTest::newRow("plain text sub string reversed") - << standard.at(0) - << QQuickTextEdit::PlainText - << 12 << 0 - << standard.at(0).mid(0, 12); - - QTest::newRow("plain text cropped beginning") - << standard.at(0) - << QQuickTextEdit::PlainText - << -3 << 4 - << standard.at(0).mid(0, 4); - - QTest::newRow("plain text cropped end") - << standard.at(0) - << QQuickTextEdit::PlainText - << 23 << standard.at(0).length() + 8 - << standard.at(0).mid(23); - - QTest::newRow("plain text cropped beginning and end") - << standard.at(0) - << QQuickTextEdit::PlainText - << -9 << standard.at(0).length() + 4 - << standard.at(0); - - QTest::newRow("all rich (Auto) text") - << richBoldText - << QQuickTextEdit::AutoText - << 0 << plainBoldText.length() - << QString("This is some \\<.*\\>bold\\ text"); - - QTest::newRow("all rich (Rich) text") - << richBoldText - << QQuickTextEdit::RichText - << 0 << plainBoldText.length() - << QString("This is some \\<.*\\>bold\\ text"); - - QTest::newRow("all rich (Plain) text") - << richBoldText - << QQuickTextEdit::PlainText - << 0 << richBoldText.length() - << richBoldText; - - QTest::newRow("rich (Auto) text sub string") - << richBoldText - << QQuickTextEdit::AutoText - << 14 << 21 - << QString("\\<.*\\>old\\ tex"); - - QTest::newRow("rich (Rich) text sub string") - << richBoldText - << QQuickTextEdit::RichText - << 14 << 21 - << QString("\\<.*\\>old\\ tex"); - - QTest::newRow("rich (Plain) text sub string") - << richBoldText - << QQuickTextEdit::PlainText - << 17 << 27 - << richBoldText.mid(17, 10); -} - -void tst_qquicktextedit::getFormattedText() -{ - QFETCH(QString, text); - QFETCH(QQuickTextEdit::TextFormat, textFormat); - QFETCH(int, start); - QFETCH(int, end); - QFETCH(QString, expectedText); - - QString componentStr = "import QtQuick 2.0\nTextEdit {}"; - QDeclarativeComponent textEditComponent(&engine); - textEditComponent.setData(componentStr.toLatin1(), QUrl()); - QQuickTextEdit *textEdit = qobject_cast(textEditComponent.create()); - QVERIFY(textEdit != 0); - - textEdit->setTextFormat(textFormat); - textEdit->setText(text); - - if (textFormat == QQuickTextEdit::RichText - || (textFormat == QQuickTextEdit::AutoText && Qt::mightBeRichText(text))) { - QVERIFY(textEdit->getFormattedText(start, end).contains(QRegExp(expectedText))); - } else { - QCOMPARE(textEdit->getFormattedText(start, end), expectedText); - } -} - -void tst_qquicktextedit::insert_data() -{ - QTest::addColumn("text"); - QTest::addColumn("textFormat"); - QTest::addColumn("selectionStart"); - QTest::addColumn("selectionEnd"); - QTest::addColumn("insertPosition"); - QTest::addColumn("insertText"); - QTest::addColumn("expectedText"); - QTest::addColumn("expectedSelectionStart"); - QTest::addColumn("expectedSelectionEnd"); - QTest::addColumn("expectedCursorPosition"); - QTest::addColumn("selectionChanged"); - QTest::addColumn("cursorPositionChanged"); - - QTest::newRow("at cursor position (beginning)") - << standard.at(0) << QQuickTextEdit::PlainText - << 0 << 0 << 0 - << QString("Hello") - << QString("Hello") + standard.at(0) - << 5 << 5 << 5 - << false << true; - - QTest::newRow("at cursor position (end)") - << standard.at(0) << QQuickTextEdit::PlainText - << standard.at(0).length() << standard.at(0).length() << standard.at(0).length() - << QString("Hello") - << standard.at(0) + QString("Hello") - << standard.at(0).length() + 5 << standard.at(0).length() + 5 << standard.at(0).length() + 5 - << false << true; - - QTest::newRow("at cursor position (middle)") - << standard.at(0) << QQuickTextEdit::PlainText - << 18 << 18 << 18 - << QString("Hello") - << standard.at(0).mid(0, 18) + QString("Hello") + standard.at(0).mid(18) - << 23 << 23 << 23 - << false << true; - - QTest::newRow("after cursor position (beginning)") - << standard.at(0) << QQuickTextEdit::PlainText - << 0 << 0 << 18 - << QString("Hello") - << standard.at(0).mid(0, 18) + QString("Hello") + standard.at(0).mid(18) - << 0 << 0 << 0 - << false << false; - - QTest::newRow("before cursor position (end)") - << standard.at(0) << QQuickTextEdit::PlainText - << standard.at(0).length() << standard.at(0).length() << 18 - << QString("Hello") - << standard.at(0).mid(0, 18) + QString("Hello") + standard.at(0).mid(18) - << standard.at(0).length() + 5 << standard.at(0).length() + 5 << standard.at(0).length() + 5 - << false << true; - - QTest::newRow("before cursor position (middle)") - << standard.at(0) << QQuickTextEdit::PlainText - << 18 << 18 << 0 - << QString("Hello") - << QString("Hello") + standard.at(0) - << 23 << 23 << 23 - << false << true; - - QTest::newRow("after cursor position (middle)") - << standard.at(0) << QQuickTextEdit::PlainText - << 18 << 18 << standard.at(0).length() - << QString("Hello") - << standard.at(0) + QString("Hello") - << 18 << 18 << 18 - << false << false; - - QTest::newRow("before selection") - << standard.at(0) << QQuickTextEdit::PlainText - << 14 << 19 << 0 - << QString("Hello") - << QString("Hello") + standard.at(0) - << 19 << 24 << 24 - << false << true; - - QTest::newRow("before reversed selection") - << standard.at(0) << QQuickTextEdit::PlainText - << 19 << 14 << 0 - << QString("Hello") - << QString("Hello") + standard.at(0) - << 19 << 24 << 19 - << false << true; - - QTest::newRow("after selection") - << standard.at(0) << QQuickTextEdit::PlainText - << 14 << 19 << standard.at(0).length() - << QString("Hello") - << standard.at(0) + QString("Hello") - << 14 << 19 << 19 - << false << false; - - QTest::newRow("after reversed selection") - << standard.at(0) << QQuickTextEdit::PlainText - << 19 << 14 << standard.at(0).length() - << QString("Hello") - << standard.at(0) + QString("Hello") - << 14 << 19 << 14 - << false << false; - - QTest::newRow("into selection") - << standard.at(0) << QQuickTextEdit::PlainText - << 14 << 19 << 18 - << QString("Hello") - << standard.at(0).mid(0, 18) + QString("Hello") + standard.at(0).mid(18) - << 14 << 24 << 24 - << true << true; - - QTest::newRow("into reversed selection") - << standard.at(0) << QQuickTextEdit::PlainText - << 19 << 14 << 18 - << QString("Hello") - << standard.at(0).mid(0, 18) + QString("Hello") + standard.at(0).mid(18) - << 14 << 24 << 14 - << true << false; - - QTest::newRow("rich text into plain text") - << standard.at(0) << QQuickTextEdit::PlainText - << 0 << 0 << 0 - << QString("Hello") - << QString("Hello") + standard.at(0) - << 12 << 12 << 12 - << false << true; - - QTest::newRow("rich text into rich text") - << standard.at(0) << QQuickTextEdit::RichText - << 0 << 0 << 0 - << QString("Hello") - << QString("Hello") + standard.at(0) - << 5 << 5 << 5 - << false << true; - - QTest::newRow("rich text into auto text") - << standard.at(0) << QQuickTextEdit::AutoText - << 0 << 0 << 0 - << QString("Hello") - << QString("Hello") + standard.at(0) - << 5 << 5 << 5 - << false << true; - - QTest::newRow("before start") - << standard.at(0) << QQuickTextEdit::PlainText - << 0 << 0 << -3 - << QString("Hello") - << standard.at(0) - << 0 << 0 << 0 - << false << false; - - QTest::newRow("past end") - << standard.at(0) << QQuickTextEdit::PlainText - << 0 << 0 << standard.at(0).length() + 3 - << QString("Hello") - << standard.at(0) - << 0 << 0 << 0 - << false << false; -} - -void tst_qquicktextedit::insert() -{ - QFETCH(QString, text); - QFETCH(QQuickTextEdit::TextFormat, textFormat); - QFETCH(int, selectionStart); - QFETCH(int, selectionEnd); - QFETCH(int, insertPosition); - QFETCH(QString, insertText); - QFETCH(QString, expectedText); - QFETCH(int, expectedSelectionStart); - QFETCH(int, expectedSelectionEnd); - QFETCH(int, expectedCursorPosition); - QFETCH(bool, selectionChanged); - QFETCH(bool, cursorPositionChanged); - - QString componentStr = "import QtQuick 2.0\nTextEdit { text: \"" + text + "\" }"; - QDeclarativeComponent textEditComponent(&engine); - textEditComponent.setData(componentStr.toLatin1(), QUrl()); - QQuickTextEdit *textEdit = qobject_cast(textEditComponent.create()); - QVERIFY(textEdit != 0); - - textEdit->setTextFormat(textFormat); - textEdit->select(selectionStart, selectionEnd); - - QSignalSpy selectionSpy(textEdit, SIGNAL(selectionChanged())); - QSignalSpy selectionStartSpy(textEdit, SIGNAL(selectionStartChanged())); - QSignalSpy selectionEndSpy(textEdit, SIGNAL(selectionEndChanged())); - QSignalSpy textSpy(textEdit, SIGNAL(textChanged())); - QSignalSpy cursorPositionSpy(textEdit, SIGNAL(cursorPositionChanged())); - - textEdit->insert(insertPosition, insertText); - - if (textFormat == QQuickTextEdit::RichText || (textFormat == QQuickTextEdit::AutoText && ( - Qt::mightBeRichText(text) || Qt::mightBeRichText(insertText)))) { - QCOMPARE(textEdit->getText(0, expectedText.length()), expectedText); - } else { - QCOMPARE(textEdit->text(), expectedText); - - } - QCOMPARE(textEdit->length(), expectedText.length()); - - QCOMPARE(textEdit->selectionStart(), expectedSelectionStart); - QCOMPARE(textEdit->selectionEnd(), expectedSelectionEnd); - QCOMPARE(textEdit->cursorPosition(), expectedCursorPosition); - - if (selectionStart > selectionEnd) - qSwap(selectionStart, selectionEnd); - - QEXPECT_FAIL("into selection", "selectionChanged signal isn't emitted on edits within selection", Continue); - QEXPECT_FAIL("into reversed selection", "selectionChanged signal isn't emitted on edits within selection", Continue); - QCOMPARE(selectionSpy.count() > 0, selectionChanged); - QCOMPARE(selectionStartSpy.count() > 0, selectionStart != expectedSelectionStart); - QEXPECT_FAIL("into reversed selection", "selectionEndChanged signal not emitted", Continue); - QCOMPARE(selectionEndSpy.count() > 0, selectionEnd != expectedSelectionEnd); - QCOMPARE(textSpy.count() > 0, text != expectedText); - QCOMPARE(cursorPositionSpy.count() > 0, cursorPositionChanged); -} - -void tst_qquicktextedit::remove_data() -{ - QTest::addColumn("text"); - QTest::addColumn("textFormat"); - QTest::addColumn("selectionStart"); - QTest::addColumn("selectionEnd"); - QTest::addColumn("removeStart"); - QTest::addColumn("removeEnd"); - QTest::addColumn("expectedText"); - QTest::addColumn("expectedSelectionStart"); - QTest::addColumn("expectedSelectionEnd"); - QTest::addColumn("expectedCursorPosition"); - QTest::addColumn("selectionChanged"); - QTest::addColumn("cursorPositionChanged"); - - const QString richBoldText = QStringLiteral("This is some bold text"); - const QString plainBoldText = QStringLiteral("This is some bold text"); - - QTest::newRow("from cursor position (beginning)") - << standard.at(0) << QQuickTextEdit::PlainText - << 0 << 0 - << 0 << 5 - << standard.at(0).mid(5) - << 0 << 0 << 0 - << false << false; - - QTest::newRow("to cursor position (beginning)") - << standard.at(0) << QQuickTextEdit::PlainText - << 0 << 0 - << 5 << 0 - << standard.at(0).mid(5) - << 0 << 0 << 0 - << false << false; - - QTest::newRow("to cursor position (end)") - << standard.at(0) << QQuickTextEdit::PlainText - << standard.at(0).length() << standard.at(0).length() - << standard.at(0).length() << standard.at(0).length() - 5 - << standard.at(0).mid(0, standard.at(0).length() - 5) - << standard.at(0).length() - 5 << standard.at(0).length() - 5 << standard.at(0).length() - 5 - << false << true; - - QTest::newRow("to cursor position (end)") - << standard.at(0) << QQuickTextEdit::PlainText - << standard.at(0).length() << standard.at(0).length() - << standard.at(0).length() - 5 << standard.at(0).length() - << standard.at(0).mid(0, standard.at(0).length() - 5) - << standard.at(0).length() - 5 << standard.at(0).length() - 5 << standard.at(0).length() - 5 - << false << true; - - QTest::newRow("from cursor position (middle)") - << standard.at(0) << QQuickTextEdit::PlainText - << 18 << 18 - << 18 << 23 - << standard.at(0).mid(0, 18) + standard.at(0).mid(23) - << 18 << 18 << 18 - << false << false; - - QTest::newRow("to cursor position (middle)") - << standard.at(0) << QQuickTextEdit::PlainText - << 23 << 23 - << 18 << 23 - << standard.at(0).mid(0, 18) + standard.at(0).mid(23) - << 18 << 18 << 18 - << false << true; - - QTest::newRow("after cursor position (beginning)") - << standard.at(0) << QQuickTextEdit::PlainText - << 0 << 0 - << 18 << 23 - << standard.at(0).mid(0, 18) + standard.at(0).mid(23) - << 0 << 0 << 0 - << false << false; - - QTest::newRow("before cursor position (end)") - << standard.at(0) << QQuickTextEdit::PlainText - << standard.at(0).length() << standard.at(0).length() - << 18 << 23 - << standard.at(0).mid(0, 18) + standard.at(0).mid(23) - << standard.at(0).length() - 5 << standard.at(0).length() - 5 << standard.at(0).length() - 5 - << false << true; - - QTest::newRow("before cursor position (middle)") - << standard.at(0) << QQuickTextEdit::PlainText - << 23 << 23 - << 0 << 5 - << standard.at(0).mid(5) - << 18 << 18 << 18 - << false << true; - - QTest::newRow("after cursor position (middle)") - << standard.at(0) << QQuickTextEdit::PlainText - << 18 << 18 - << 18 << 23 - << standard.at(0).mid(0, 18) + standard.at(0).mid(23) - << 18 << 18 << 18 - << false << false; - - QTest::newRow("before selection") - << standard.at(0) << QQuickTextEdit::PlainText - << 14 << 19 - << 0 << 5 - << standard.at(0).mid(5) - << 9 << 14 << 14 - << false << true; - - QTest::newRow("before reversed selection") - << standard.at(0) << QQuickTextEdit::PlainText - << 19 << 14 - << 0 << 5 - << standard.at(0).mid(5) - << 9 << 14 << 9 - << false << true; - - QTest::newRow("after selection") - << standard.at(0) << QQuickTextEdit::PlainText - << 14 << 19 - << standard.at(0).length() - 5 << standard.at(0).length() - << standard.at(0).mid(0, standard.at(0).length() - 5) - << 14 << 19 << 19 - << false << false; - - QTest::newRow("after reversed selection") - << standard.at(0) << QQuickTextEdit::PlainText - << 19 << 14 - << standard.at(0).length() - 5 << standard.at(0).length() - << standard.at(0).mid(0, standard.at(0).length() - 5) - << 14 << 19 << 14 - << false << false; - - QTest::newRow("from selection") - << standard.at(0) << QQuickTextEdit::PlainText - << 14 << 24 - << 18 << 23 - << standard.at(0).mid(0, 18) + standard.at(0).mid(23) - << 14 << 19 << 19 - << true << true; - - QTest::newRow("from reversed selection") - << standard.at(0) << QQuickTextEdit::PlainText - << 24 << 14 - << 18 << 23 - << standard.at(0).mid(0, 18) + standard.at(0).mid(23) - << 14 << 19 << 14 - << true << false; - - QTest::newRow("plain text cropped beginning") - << standard.at(0) << QQuickTextEdit::PlainText - << 0 << 0 - << -3 << 4 - << standard.at(0).mid(4) - << 0 << 0 << 0 - << false << false; - - QTest::newRow("plain text cropped end") - << standard.at(0) << QQuickTextEdit::PlainText - << 0 << 0 - << 23 << standard.at(0).length() + 8 - << standard.at(0).mid(0, 23) - << 0 << 0 << 0 - << false << false; - - QTest::newRow("plain text cropped beginning and end") - << standard.at(0) << QQuickTextEdit::PlainText - << 0 << 0 - << -9 << standard.at(0).length() + 4 - << QString() - << 0 << 0 << 0 - << false << false; - - QTest::newRow("all rich text") - << richBoldText << QQuickTextEdit::RichText - << 0 << 0 - << 0 << plainBoldText.length() - << QString() - << 0 << 0 << 0 - << false << false; - - QTest::newRow("rick text sub string") - << richBoldText << QQuickTextEdit::RichText - << 0 << 0 - << 14 << 21 - << plainBoldText.mid(0, 14) + plainBoldText.mid(21) - << 0 << 0 << 0 - << false << false; -} - -void tst_qquicktextedit::remove() -{ - QFETCH(QString, text); - QFETCH(QQuickTextEdit::TextFormat, textFormat); - QFETCH(int, selectionStart); - QFETCH(int, selectionEnd); - QFETCH(int, removeStart); - QFETCH(int, removeEnd); - QFETCH(QString, expectedText); - QFETCH(int, expectedSelectionStart); - QFETCH(int, expectedSelectionEnd); - QFETCH(int, expectedCursorPosition); - QFETCH(bool, selectionChanged); - QFETCH(bool, cursorPositionChanged); - - QString componentStr = "import QtQuick 2.0\nTextEdit { text: \"" + text + "\" }"; - QDeclarativeComponent textEditComponent(&engine); - textEditComponent.setData(componentStr.toLatin1(), QUrl()); - QQuickTextEdit *textEdit = qobject_cast(textEditComponent.create()); - QVERIFY(textEdit != 0); - - textEdit->setTextFormat(textFormat); - textEdit->select(selectionStart, selectionEnd); - - QSignalSpy selectionSpy(textEdit, SIGNAL(selectionChanged())); - QSignalSpy selectionStartSpy(textEdit, SIGNAL(selectionStartChanged())); - QSignalSpy selectionEndSpy(textEdit, SIGNAL(selectionEndChanged())); - QSignalSpy textSpy(textEdit, SIGNAL(textChanged())); - QSignalSpy cursorPositionSpy(textEdit, SIGNAL(cursorPositionChanged())); - - textEdit->remove(removeStart, removeEnd); - - if (textFormat == QQuickTextEdit::RichText - || (textFormat == QQuickTextEdit::AutoText && Qt::mightBeRichText(text))) { - QCOMPARE(textEdit->getText(0, expectedText.length()), expectedText); - } else { - QCOMPARE(textEdit->text(), expectedText); - } - QCOMPARE(textEdit->length(), expectedText.length()); - - if (selectionStart > selectionEnd) // - qSwap(selectionStart, selectionEnd); - - QCOMPARE(textEdit->selectionStart(), expectedSelectionStart); - QCOMPARE(textEdit->selectionEnd(), expectedSelectionEnd); - QCOMPARE(textEdit->cursorPosition(), expectedCursorPosition); - - QEXPECT_FAIL("from selection", "selectionChanged signal isn't emitted on edits within selection", Continue); - QEXPECT_FAIL("from reversed selection", "selectionChanged signal isn't emitted on edits within selection", Continue); - QCOMPARE(selectionSpy.count() > 0, selectionChanged); - QCOMPARE(selectionStartSpy.count() > 0, selectionStart != expectedSelectionStart); - QEXPECT_FAIL("from reversed selection", "selectionEndChanged signal not emitted", Continue); - QCOMPARE(selectionEndSpy.count() > 0, selectionEnd != expectedSelectionEnd); - QCOMPARE(textSpy.count() > 0, text != expectedText); - - - if (cursorPositionChanged) // - QVERIFY(cursorPositionSpy.count() > 0); -} - - -void tst_qquicktextedit::keySequence_data() -{ - QTest::addColumn("text"); - QTest::addColumn("sequence"); - QTest::addColumn("selectionStart"); - QTest::addColumn("selectionEnd"); - QTest::addColumn("cursorPosition"); - QTest::addColumn("expectedText"); - QTest::addColumn("selectedText"); - - // standard[0] == "the [4]quick [10]brown [16]fox [20]jumped [27]over [32]the [36]lazy [41]dog" - - QTest::newRow("select all") - << standard.at(0) << QKeySequence(QKeySequence::SelectAll) << 0 << 0 - << 44 << standard.at(0) << standard.at(0); - QTest::newRow("select end of line") - << standard.at(0) << QKeySequence(QKeySequence::SelectEndOfLine) << 5 << 5 - << 44 << standard.at(0) << standard.at(0).mid(5); - QTest::newRow("select end of document") - << standard.at(0) << QKeySequence(QKeySequence::SelectEndOfDocument) << 3 << 3 - << 44 << standard.at(0) << standard.at(0).mid(3); - QTest::newRow("select end of block") - << standard.at(0) << QKeySequence(QKeySequence::SelectEndOfBlock) << 18 << 18 - << 44 << standard.at(0) << standard.at(0).mid(18); - QTest::newRow("delete end of line") - << standard.at(0) << QKeySequence(QKeySequence::DeleteEndOfLine) << 24 << 24 - << 24 << standard.at(0).mid(0, 24) << QString(); - QTest::newRow("move to start of line") - << standard.at(0) << QKeySequence(QKeySequence::MoveToStartOfLine) << 31 << 31 - << 0 << standard.at(0) << QString(); - QTest::newRow("move to start of block") - << standard.at(0) << QKeySequence(QKeySequence::MoveToStartOfBlock) << 25 << 25 - << 0 << standard.at(0) << QString(); - QTest::newRow("move to next char") - << standard.at(0) << QKeySequence(QKeySequence::MoveToNextChar) << 12 << 12 - << 13 << standard.at(0) << QString(); - QTest::newRow("move to previous char") - << standard.at(0) << QKeySequence(QKeySequence::MoveToPreviousChar) << 3 << 3 - << 2 << standard.at(0) << QString(); - QTest::newRow("select next char") - << standard.at(0) << QKeySequence(QKeySequence::SelectNextChar) << 23 << 23 - << 24 << standard.at(0) << standard.at(0).mid(23, 1); - QTest::newRow("select previous char") - << standard.at(0) << QKeySequence(QKeySequence::SelectPreviousChar) << 19 << 19 - << 18 << standard.at(0) << standard.at(0).mid(18, 1); - QTest::newRow("move to next word") - << standard.at(0) << QKeySequence(QKeySequence::MoveToNextWord) << 7 << 7 - << 10 << standard.at(0) << QString(); - QTest::newRow("move to previous word") - << standard.at(0) << QKeySequence(QKeySequence::MoveToPreviousWord) << 7 << 7 - << 4 << standard.at(0) << QString(); - QTest::newRow("select previous word") - << standard.at(0) << QKeySequence(QKeySequence::SelectPreviousWord) << 11 << 11 - << 10 << standard.at(0) << standard.at(0).mid(10, 1); - QTest::newRow("delete (selection)") - << standard.at(0) << QKeySequence(QKeySequence::Delete) << 12 << 15 - << 12 << (standard.at(0).mid(0, 12) + standard.at(0).mid(15)) << QString(); - QTest::newRow("delete (no selection)") - << standard.at(0) << QKeySequence(QKeySequence::Delete) << 15 << 15 - << 15 << (standard.at(0).mid(0, 15) + standard.at(0).mid(16)) << QString(); - QTest::newRow("delete end of word") - << standard.at(0) << QKeySequence(QKeySequence::DeleteEndOfWord) << 24 << 24 - << 24 << (standard.at(0).mid(0, 24) + standard.at(0).mid(27)) << QString(); - QTest::newRow("delete start of word") - << standard.at(0) << QKeySequence(QKeySequence::DeleteStartOfWord) << 7 << 7 - << 4 << (standard.at(0).mid(0, 4) + standard.at(0).mid(7)) << QString(); -} - -void tst_qquicktextedit::keySequence() -{ - QFETCH(QString, text); - QFETCH(QKeySequence, sequence); - QFETCH(int, selectionStart); - QFETCH(int, selectionEnd); - QFETCH(int, cursorPosition); - QFETCH(QString, expectedText); - QFETCH(QString, selectedText); - - if (sequence.isEmpty()) { - QSKIP("Key sequence is undefined"); - } - - QString componentStr = "import QtQuick 2.0\nTextEdit { focus: true; text: \"" + text + "\" }"; - QDeclarativeComponent textEditComponent(&engine); - textEditComponent.setData(componentStr.toLatin1(), QUrl()); - QQuickTextEdit *textEdit = qobject_cast(textEditComponent.create()); - QVERIFY(textEdit != 0); - - QQuickCanvas canvas; - textEdit->setParentItem(canvas.rootItem()); - canvas.show(); - canvas.requestActivateWindow(); - QTest::qWaitForWindowShown(&canvas); - QTRY_COMPARE(QGuiApplication::activeWindow(), &canvas); - - textEdit->select(selectionStart, selectionEnd); - - simulateKeys(&canvas, sequence); - - QCOMPARE(textEdit->cursorPosition(), cursorPosition); - QCOMPARE(textEdit->text(), expectedText); - QCOMPARE(textEdit->selectedText(), selectedText); -} - -#define NORMAL 0 -#define REPLACE_UNTIL_END 1 - -void tst_qquicktextedit::undo_data() -{ - QTest::addColumn("insertString"); - QTest::addColumn("insertIndex"); - QTest::addColumn("insertMode"); - QTest::addColumn("expectedString"); - QTest::addColumn("use_keys"); - - for (int i=0; i<2; i++) { - QString keys_str = "keyboard"; - bool use_keys = true; - if (i==0) { - keys_str = "insert"; - use_keys = false; - } - - { - IntList insertIndex; - IntList insertMode; - QStringList insertString; - QStringList expectedString; - - insertIndex << -1; - insertMode << NORMAL; - insertString << "1"; - - insertIndex << -1; - insertMode << NORMAL; - insertString << "5"; - - insertIndex << 1; - insertMode << NORMAL; - insertString << "3"; - - insertIndex << 1; - insertMode << NORMAL; - insertString << "2"; - - insertIndex << 3; - insertMode << NORMAL; - insertString << "4"; - - expectedString << "12345"; - expectedString << "1235"; - expectedString << "135"; - expectedString << "15"; - expectedString << ""; - - QTest::newRow(QString(keys_str + "_numbers").toLatin1()) << - insertString << - insertIndex << - insertMode << - expectedString << - bool(use_keys); - } - { - IntList insertIndex; - IntList insertMode; - QStringList insertString; - QStringList expectedString; - - insertIndex << -1; - insertMode << NORMAL; - insertString << "World"; // World - - insertIndex << 0; - insertMode << NORMAL; - insertString << "Hello"; // HelloWorld - - insertIndex << 0; - insertMode << NORMAL; - insertString << "Well"; // WellHelloWorld - - insertIndex << 9; - insertMode << NORMAL; - insertString << "There"; // WellHelloThereWorld; - - expectedString << "WellHelloThereWorld"; - expectedString << "WellHelloWorld"; - expectedString << "HelloWorld"; - expectedString << "World"; - expectedString << ""; - - QTest::newRow(QString(keys_str + "_helloworld").toLatin1()) << - insertString << - insertIndex << - insertMode << - expectedString << - bool(use_keys); - } - { - IntList insertIndex; - IntList insertMode; - QStringList insertString; - QStringList expectedString; - - insertIndex << -1; - insertMode << NORMAL; - insertString << "Ensuring"; - - insertIndex << -1; - insertMode << NORMAL; - insertString << " instan"; - - insertIndex << 9; - insertMode << NORMAL; - insertString << "an "; - - insertIndex << 10; - insertMode << REPLACE_UNTIL_END; - insertString << " unique instance."; - - expectedString << "Ensuring a unique instance."; - expectedString << "Ensuring a "; // ### Not present in TextInput. - expectedString << "Ensuring an instan"; - expectedString << "Ensuring instan"; - expectedString << ""; - - QTest::newRow(QString(keys_str + "_patterns").toLatin1()) << - insertString << - insertIndex << - insertMode << - expectedString << - bool(use_keys); - } - } -} - -void tst_qquicktextedit::undo() -{ - QFETCH(QStringList, insertString); - QFETCH(IntList, insertIndex); - QFETCH(IntList, insertMode); - QFETCH(QStringList, expectedString); - - QString componentStr = "import QtQuick 2.0\nTextEdit { focus: true }"; - QDeclarativeComponent textEditComponent(&engine); - textEditComponent.setData(componentStr.toLatin1(), QUrl()); - QQuickTextEdit *textEdit = qobject_cast(textEditComponent.create()); - QVERIFY(textEdit != 0); - - QQuickCanvas canvas; - textEdit->setParentItem(canvas.rootItem()); - canvas.show(); - canvas.requestActivateWindow(); - QTest::qWaitForWindowShown(&canvas); - QTRY_COMPARE(QGuiApplication::activeWindow(), &canvas); - - QVERIFY(!textEdit->canUndo()); - - QSignalSpy spy(textEdit, SIGNAL(canUndoChanged())); - - int i; - -// STEP 1: First build up an undo history by inserting or typing some strings... - for (i = 0; i < insertString.size(); ++i) { - if (insertIndex[i] > -1) - textEdit->setCursorPosition(insertIndex[i]); - - // experimental stuff - if (insertMode[i] == REPLACE_UNTIL_END) { - textEdit->select(insertIndex[i], insertIndex[i] + 8); - - // This is what I actually want... - // QTest::keyClick(testWidget, Qt::Key_End, Qt::ShiftModifier); - } - - for (int j = 0; j < insertString.at(i).length(); j++) - QTest::keyClick(&canvas, insertString.at(i).at(j).toLatin1()); - } - - QCOMPARE(spy.count(), 1); - -// STEP 2: Next call undo several times and see if we can restore to the previous state - for (i = 0; i < expectedString.size() - 1; ++i) { - QCOMPARE(textEdit->text(), expectedString[i]); - QVERIFY(textEdit->canUndo()); - textEdit->undo(); - } - -// STEP 3: Verify that we have undone everything - QVERIFY(textEdit->text().isEmpty()); - QVERIFY(!textEdit->canUndo()); - QCOMPARE(spy.count(), 2); -} - -void tst_qquicktextedit::redo_data() -{ - QTest::addColumn("insertString"); - QTest::addColumn("insertIndex"); - QTest::addColumn("expectedString"); - - { - IntList insertIndex; - QStringList insertString; - QStringList expectedString; - - insertIndex << -1; - insertString << "World"; // World - insertIndex << 0; - insertString << "Hello"; // HelloWorld - insertIndex << 0; - insertString << "Well"; // WellHelloWorld - insertIndex << 9; - insertString << "There"; // WellHelloThereWorld; - - expectedString << "World"; - expectedString << "HelloWorld"; - expectedString << "WellHelloWorld"; - expectedString << "WellHelloThereWorld"; - - QTest::newRow("Inserts and setting cursor") << insertString << insertIndex << expectedString; - } -} - -void tst_qquicktextedit::redo() -{ - QFETCH(QStringList, insertString); - QFETCH(IntList, insertIndex); - QFETCH(QStringList, expectedString); - - QString componentStr = "import QtQuick 2.0\nTextEdit { focus: true }"; - QDeclarativeComponent textEditComponent(&engine); - textEditComponent.setData(componentStr.toLatin1(), QUrl()); - QQuickTextEdit *textEdit = qobject_cast(textEditComponent.create()); - QVERIFY(textEdit != 0); - - QQuickCanvas canvas; - textEdit->setParentItem(canvas.rootItem()); - canvas.show(); - canvas.requestActivateWindow(); - QTest::qWaitForWindowShown(&canvas); - QTRY_COMPARE(QGuiApplication::activeWindow(), &canvas); - - QVERIFY(!textEdit->canUndo()); - QVERIFY(!textEdit->canRedo()); - - QSignalSpy spy(textEdit, SIGNAL(canRedoChanged())); - - int i; - // inserts the diff strings at diff positions - for (i = 0; i < insertString.size(); ++i) { - if (insertIndex[i] > -1) - textEdit->setCursorPosition(insertIndex[i]); - for (int j = 0; j < insertString.at(i).length(); j++) - QTest::keyClick(&canvas, insertString.at(i).at(j).toLatin1()); - QVERIFY(textEdit->canUndo()); - QVERIFY(!textEdit->canRedo()); - } - - QCOMPARE(spy.count(), 0); - - // undo everything - while (!textEdit->text().isEmpty()) { - QVERIFY(textEdit->canUndo()); - textEdit->undo(); - QVERIFY(textEdit->canRedo()); - } - - QCOMPARE(spy.count(), 1); - - for (i = 0; i < expectedString.size(); ++i) { - QVERIFY(textEdit->canRedo()); - textEdit->redo(); - QCOMPARE(textEdit->text() , expectedString[i]); - QVERIFY(textEdit->canUndo()); - } - QVERIFY(!textEdit->canRedo()); - QCOMPARE(spy.count(), 2); -} - -void tst_qquicktextedit::undo_keypressevents_data() -{ - QTest::addColumn("keys"); - QTest::addColumn("expectedString"); - - { - KeyList keys; - QStringList expectedString; - - keys << "AFRAID" - << Qt::Key_Home - << "VERY" - << Qt::Key_Left - << Qt::Key_Left - << Qt::Key_Left - << Qt::Key_Left - << "BE" - << Qt::Key_End - << "!"; - - expectedString << "BEVERYAFRAID!"; - expectedString << "BEVERYAFRAID"; - expectedString << "VERYAFRAID"; - expectedString << "AFRAID"; - - QTest::newRow("Inserts and moving cursor") << keys << expectedString; - } { - KeyList keys; - QStringList expectedString; - - // inserting '1234' - keys << "1234" << Qt::Key_Home - // skipping '12' - << Qt::Key_Right << Qt::Key_Right - // selecting '34' - << (Qt::Key_Right | Qt::ShiftModifier) << (Qt::Key_Right | Qt::ShiftModifier) - // deleting '34' - << Qt::Key_Delete; - - expectedString << "12"; - expectedString << "1234"; - - QTest::newRow("Inserts,moving,selection and delete") << keys << expectedString; - } { - KeyList keys; - QStringList expectedString; - - // inserting 'AB12' - keys << "AB12" - << Qt::Key_Home - // selecting 'AB' - << (Qt::Key_Right | Qt::ShiftModifier) << (Qt::Key_Right | Qt::ShiftModifier) - << Qt::Key_Delete - << QKeySequence::Undo - // ### Text is selected in text input -// << Qt::Key_Right - << (Qt::Key_Right | Qt::ShiftModifier) << (Qt::Key_Right | Qt::ShiftModifier) - << Qt::Key_Delete; - - expectedString << "AB"; - expectedString << "AB12"; - - QTest::newRow("Inserts,moving,selection, delete and undo") << keys << expectedString; - } { - KeyList keys; - QStringList expectedString; - - // inserting 'ABCD' - keys << "abcd" - //move left two - << Qt::Key_Left << Qt::Key_Left - // inserting '1234' - << "1234" - // selecting '1234' - << (Qt::Key_Left | Qt::ShiftModifier) << (Qt::Key_Left | Qt::ShiftModifier) << (Qt::Key_Left | Qt::ShiftModifier) << (Qt::Key_Left | Qt::ShiftModifier) - // overwriting '1234' with '5' - << "5" - // undoing deletion of 'AB' - << QKeySequence::Undo - // ### Text is selected in text input - << (Qt::Key_Left | Qt::ShiftModifier) << (Qt::Key_Left | Qt::ShiftModifier) << (Qt::Key_Left | Qt::ShiftModifier) << (Qt::Key_Left | Qt::ShiftModifier) - // overwriting '1234' with '6' - << "6"; - - expectedString << "ab6cd"; - // for versions previous to 3.2 we overwrite needed two undo operations - expectedString << "ab1234cd"; - expectedString << "abcd"; - - QTest::newRow("Inserts,moving,selection and undo, removing selection") << keys << expectedString; - } { - KeyList keys; - QStringList expectedString; - - // inserting 'ABC' - keys << "ABC" - // removes 'C' - << Qt::Key_Backspace; - - expectedString << "AB"; - expectedString << "ABC"; - - QTest::newRow("Inserts,backspace") << keys << expectedString; - } { - KeyList keys; - QStringList expectedString; - - keys << "ABC" - // removes 'C' - << Qt::Key_Backspace - // inserting 'Z' - << "Z"; - - expectedString << "ABZ"; - expectedString << "AB"; - expectedString << "ABC"; - - QTest::newRow("Inserts,backspace,inserts") << keys << expectedString; - } { - KeyList keys; - QStringList expectedString; - - // inserting '123' - keys << "123" << Qt::Key_Home - // selecting '123' - << (Qt::Key_End | Qt::ShiftModifier) - // overwriting '123' with 'ABC' - << "ABC"; - - expectedString << "ABC"; - // ### One operation in TextInput. - expectedString << "A"; - expectedString << "123"; - - QTest::newRow("Inserts,moving,selection and overwriting") << keys << expectedString; - } -} - -void tst_qquicktextedit::undo_keypressevents() -{ - QFETCH(KeyList, keys); - QFETCH(QStringList, expectedString); - - QString componentStr = "import QtQuick 2.0\nTextEdit { focus: true }"; - QDeclarativeComponent textEditComponent(&engine); - textEditComponent.setData(componentStr.toLatin1(), QUrl()); - QQuickTextEdit *textEdit = qobject_cast(textEditComponent.create()); - QVERIFY(textEdit != 0); - - QQuickCanvas canvas; - textEdit->setParentItem(canvas.rootItem()); - canvas.show(); - canvas.requestActivateWindow(); - QTest::qWaitForWindowShown(&canvas); - QTRY_COMPARE(QGuiApplication::activeWindow(), &canvas); - - simulateKeys(&canvas, keys); - - for (int i = 0; i < expectedString.size(); ++i) { - QCOMPARE(textEdit->text() , expectedString[i]); - textEdit->undo(); - } - QVERIFY(textEdit->text().isEmpty()); -} - -void tst_qquicktextedit::baseUrl() -{ - QUrl localUrl("file:///tests/text.qml"); - QUrl remoteUrl("http://qt.nokia.com/test.qml"); - - QDeclarativeComponent textComponent(&engine); - textComponent.setData("import QtQuick 2.0\n TextEdit {}", localUrl); - QQuickTextEdit *textObject = qobject_cast(textComponent.create()); - - QCOMPARE(textObject->baseUrl(), localUrl); - - QSignalSpy spy(textObject, SIGNAL(baseUrlChanged())); - - textObject->setBaseUrl(localUrl); - QCOMPARE(textObject->baseUrl(), localUrl); - QCOMPARE(spy.count(), 0); - - textObject->setBaseUrl(remoteUrl); - QCOMPARE(textObject->baseUrl(), remoteUrl); - QCOMPARE(spy.count(), 1); - - textObject->resetBaseUrl(); - QCOMPARE(textObject->baseUrl(), localUrl); - QCOMPARE(spy.count(), 2); -} - -void tst_qquicktextedit::embeddedImages_data() -{ - QTest::addColumn("qmlfile"); - QTest::addColumn("error"); - QTest::newRow("local") << testFileUrl("embeddedImagesLocal.qml") << ""; - QTest::newRow("local-error") << testFileUrl("embeddedImagesLocalError.qml") - << testFileUrl("embeddedImagesLocalError.qml").toString()+":3:1: QML TextEdit: Cannot open: " + testFileUrl("http/notexists.png").toString(); - QTest::newRow("local") << testFileUrl("embeddedImagesLocalRelative.qml") << ""; - QTest::newRow("remote") << testFileUrl("embeddedImagesRemote.qml") << ""; - QTest::newRow("remote-error") << testFileUrl("embeddedImagesRemoteError.qml") - << testFileUrl("embeddedImagesRemoteError.qml").toString()+":3:1: QML TextEdit: Error downloading http://127.0.0.1:42332/notexists.png - server replied: Not found"; - QTest::newRow("remote") << testFileUrl("embeddedImagesRemoteRelative.qml") << ""; -} - -void tst_qquicktextedit::embeddedImages() -{ - QFETCH(QUrl, qmlfile); - QFETCH(QString, error); - - TestHTTPServer server(42332); - server.serveDirectory(testFile("http")); - - if (!error.isEmpty()) - QTest::ignoreMessage(QtWarningMsg, error.toLatin1()); - - QDeclarativeComponent textComponent(&engine, qmlfile); - QQuickTextEdit *textObject = qobject_cast(textComponent.create()); - - QVERIFY(textObject != 0); - QTRY_COMPARE(QQuickTextEditPrivate::get(textObject)->document->resourcesLoading(), 0); - - QPixmap pm(testFile("http/exists.png")); - if (error.isEmpty()) { - QCOMPARE(textObject->width(), double(pm.width())); - QCOMPARE(textObject->height(), double(pm.height())); - } else { - QVERIFY(16 != pm.width()); // check test is effective - QCOMPARE(textObject->width(), 16.0); // default size of QTextDocument broken image icon - QCOMPARE(textObject->height(), 16.0); - } - - delete textObject; -} - -void tst_qquicktextedit::emptytags_QTBUG_22058() -{ - QQuickView canvas(testFileUrl("qtbug-22058.qml")); - QVERIFY(canvas.rootObject() != 0); - - canvas.show(); - canvas.requestActivateWindow(); - QTest::qWaitForWindowShown(&canvas); - QQuickTextEdit *input = qobject_cast(qvariant_cast(canvas.rootObject()->property("inputField"))); - QVERIFY(input->hasActiveFocus()); - - QInputMethodEvent event("", QList()); - event.setCommitString("Bold<"); - QGuiApplication::sendEvent(input, &event); - QCOMPARE(input->text(), QString("Bold<")); - event.setCommitString(">"); - QGuiApplication::sendEvent(input, &event); - QCOMPARE(input->text(), QString("Bold<>")); -} - -QTEST_MAIN(tst_qquicktextedit) - -#include "tst_qquicktextedit.moc" diff --git a/tests/auto/qtquick2/qquicktextinput/data/Cursor.qml b/tests/auto/qtquick2/qquicktextinput/data/Cursor.qml deleted file mode 100644 index e5c1853fc5..0000000000 --- a/tests/auto/qtquick2/qquicktextinput/data/Cursor.qml +++ /dev/null @@ -1,5 +0,0 @@ -import QtQuick 2.0 - -Rectangle { - property string localProperty -} diff --git a/tests/auto/qtquick2/qquicktextinput/data/cursorTest.qml b/tests/auto/qtquick2/qquicktextinput/data/cursorTest.qml deleted file mode 100644 index 71a420ee7c..0000000000 --- a/tests/auto/qtquick2/qquicktextinput/data/cursorTest.qml +++ /dev/null @@ -1,9 +0,0 @@ -import QtQuick 2.0 - -Rectangle { id:rect; width: 300; height: 300; color: "white" - property string contextualProperty: "Hello" - TextInput { text: "Hello world!"; id: textInputObject; objectName: "textInputObject" - resources: [ Component { id:cursor; Item { id:cursorInstance; objectName: "cursorInstance"; property string localProperty: contextualProperty } } ] - cursorDelegate: cursor - } -} diff --git a/tests/auto/qtquick2/qquicktextinput/data/cursorTestExternal.qml b/tests/auto/qtquick2/qquicktextinput/data/cursorTestExternal.qml deleted file mode 100644 index 9277dcc518..0000000000 --- a/tests/auto/qtquick2/qquicktextinput/data/cursorTestExternal.qml +++ /dev/null @@ -1,15 +0,0 @@ -import QtQuick 2.0 - -Rectangle { width: 300; height: 300; color: "white" - property string contextualProperty: "Hello" - TextInput { - text: "Hello world!" - id: textInputObject; - objectName: "textInputObject" - cursorDelegate: Cursor { - id:cursorInstance; - objectName: "cursorInstance"; - localProperty: contextualProperty; - } - } -} diff --git a/tests/auto/qtquick2/qquicktextinput/data/cursorTestInline.qml b/tests/auto/qtquick2/qquicktextinput/data/cursorTestInline.qml deleted file mode 100644 index efc4b191da..0000000000 --- a/tests/auto/qtquick2/qquicktextinput/data/cursorTestInline.qml +++ /dev/null @@ -1,15 +0,0 @@ -import QtQuick 2.0 - -Rectangle { width: 300; height: 300; color: "white" - property string contextualProperty: "Hello" - TextInput { - text: "Hello world!" - id: textInputObject - objectName: "textInputObject" - cursorDelegate: Item { - id:cursorInstance - objectName: "cursorInstance" - property string localProperty: contextualProperty - } - } -} diff --git a/tests/auto/qtquick2/qquicktextinput/data/cursorVisible.qml b/tests/auto/qtquick2/qquicktextinput/data/cursorVisible.qml deleted file mode 100644 index 49e9386947..0000000000 --- a/tests/auto/qtquick2/qquicktextinput/data/cursorVisible.qml +++ /dev/null @@ -1,6 +0,0 @@ -import QtQuick 2.0 - -Item { - width: 100 - height: 20 -} diff --git a/tests/auto/qtquick2/qquicktextinput/data/echoMode.qml b/tests/auto/qtquick2/qquicktextinput/data/echoMode.qml deleted file mode 100644 index f8a6cf1c89..0000000000 --- a/tests/auto/qtquick2/qquicktextinput/data/echoMode.qml +++ /dev/null @@ -1,11 +0,0 @@ -import QtQuick 2.0 - -Rectangle { - property QtObject myInput: input - - width: 400; height: 200; color: "green" - - TextInput { id: input; focus: true - text: "ABCDefgh" - } -} diff --git a/tests/auto/qtquick2/qquicktextinput/data/geometrySignals.qml b/tests/auto/qtquick2/qquicktextinput/data/geometrySignals.qml deleted file mode 100644 index 90855a61cf..0000000000 --- a/tests/auto/qtquick2/qquicktextinput/data/geometrySignals.qml +++ /dev/null @@ -1,12 +0,0 @@ -import QtQuick 2.0 - -Item { - width: 400; height: 500; - property int bindingWidth: text.width - property int bindingHeight: text.height - - TextEdit { - id: text - anchors.fill: parent - } -} diff --git a/tests/auto/qtquick2/qquicktextinput/data/halign_center.png b/tests/auto/qtquick2/qquicktextinput/data/halign_center.png deleted file mode 100644 index 53e09a8e5b..0000000000 Binary files a/tests/auto/qtquick2/qquicktextinput/data/halign_center.png and /dev/null differ diff --git a/tests/auto/qtquick2/qquicktextinput/data/halign_left.png b/tests/auto/qtquick2/qquicktextinput/data/halign_left.png deleted file mode 100644 index 247acbc9df..0000000000 Binary files a/tests/auto/qtquick2/qquicktextinput/data/halign_left.png and /dev/null differ diff --git a/tests/auto/qtquick2/qquicktextinput/data/halign_right.png b/tests/auto/qtquick2/qquicktextinput/data/halign_right.png deleted file mode 100644 index 691bc75c89..0000000000 Binary files a/tests/auto/qtquick2/qquicktextinput/data/halign_right.png and /dev/null differ diff --git a/tests/auto/qtquick2/qquicktextinput/data/horizontalAlignment.qml b/tests/auto/qtquick2/qquicktextinput/data/horizontalAlignment.qml deleted file mode 100644 index 89934532e3..0000000000 --- a/tests/auto/qtquick2/qquicktextinput/data/horizontalAlignment.qml +++ /dev/null @@ -1,23 +0,0 @@ -import QtQuick 2.0 - -Rectangle { - id: top - width: 70; height: 70; - - property alias horizontalAlignment: text.horizontalAlignment - property string text: "Test" - - Rectangle { - anchors.centerIn: parent - width: 60 - height: 60 - color: "green" - - TextInput { - objectName: "text" - id: text - anchors.fill: parent - text: top.text - } - } -} diff --git a/tests/auto/qtquick2/qquicktextinput/data/horizontalAlignment_RightToLeft.qml b/tests/auto/qtquick2/qquicktextinput/data/horizontalAlignment_RightToLeft.qml deleted file mode 100644 index 5f88025536..0000000000 --- a/tests/auto/qtquick2/qquicktextinput/data/horizontalAlignment_RightToLeft.qml +++ /dev/null @@ -1,24 +0,0 @@ -import QtQuick 2.0 - -Rectangle { - id: top - width: 200; height: 70; - - property alias horizontalAlignment: text.horizontalAlignment - property string text: "اختبا" - - Rectangle { - anchors.centerIn: parent - width: 180 - height: 20 - color: "green" - - TextInput { - id: text - objectName: "text" - anchors.fill: parent - text: top.text - focus: true - } - } -} diff --git a/tests/auto/qtquick2/qquicktextinput/data/inputContext.qml b/tests/auto/qtquick2/qquicktextinput/data/inputContext.qml deleted file mode 100644 index dfc80990c6..0000000000 --- a/tests/auto/qtquick2/qquicktextinput/data/inputContext.qml +++ /dev/null @@ -1,8 +0,0 @@ -import QtQuick 2.0 - -TextInput { - width: 200 - text: "supercalifra" - focus: true - cursorPosition: 12 -} diff --git a/tests/auto/qtquick2/qquicktextinput/data/inputMethodEvent.qml b/tests/auto/qtquick2/qquicktextinput/data/inputMethodEvent.qml deleted file mode 100644 index 7aefdf28f4..0000000000 --- a/tests/auto/qtquick2/qquicktextinput/data/inputMethodEvent.qml +++ /dev/null @@ -1,6 +0,0 @@ -import QtQuick 2.0 - -TextInput { - focus: true - autoScroll: false -} diff --git a/tests/auto/qtquick2/qquicktextinput/data/inputmethods.qml b/tests/auto/qtquick2/qquicktextinput/data/inputmethods.qml deleted file mode 100644 index 711e89144c..0000000000 --- a/tests/auto/qtquick2/qquicktextinput/data/inputmethods.qml +++ /dev/null @@ -1,7 +0,0 @@ -import QtQuick 2.0 - -TextInput { - text: "Hello world!" - inputMethodHints: Qt.ImhNoPredictiveText - Keys.onLeftPressed: {} -} diff --git a/tests/auto/qtquick2/qquicktextinput/data/masks.qml b/tests/auto/qtquick2/qquicktextinput/data/masks.qml deleted file mode 100644 index 589b6a3c15..0000000000 --- a/tests/auto/qtquick2/qquicktextinput/data/masks.qml +++ /dev/null @@ -1,7 +0,0 @@ -import QtQuick 2.0 - -TextInput{ - focus: true - objectName: "myInput" - inputMask: "HHHHhhhh; " -} diff --git a/tests/auto/qtquick2/qquicktextinput/data/maxLength.qml b/tests/auto/qtquick2/qquicktextinput/data/maxLength.qml deleted file mode 100644 index cca537ed6b..0000000000 --- a/tests/auto/qtquick2/qquicktextinput/data/maxLength.qml +++ /dev/null @@ -1,7 +0,0 @@ -import QtQuick 2.0 - -TextInput{ - focus: true - objectName: "myInput" - maximumLength: 10 -} diff --git a/tests/auto/qtquick2/qquicktextinput/data/mouseselection_true.qml b/tests/auto/qtquick2/qquicktextinput/data/mouseselection_true.qml deleted file mode 100644 index 974041b04a..0000000000 --- a/tests/auto/qtquick2/qquicktextinput/data/mouseselection_true.qml +++ /dev/null @@ -1,7 +0,0 @@ -import QtQuick 2.0 - -TextInput { - focus: true - text: "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ" - selectByMouse: true -} diff --git a/tests/auto/qtquick2/qquicktextinput/data/mouseselectionmode_characters.qml b/tests/auto/qtquick2/qquicktextinput/data/mouseselectionmode_characters.qml deleted file mode 100644 index f7c658b618..0000000000 --- a/tests/auto/qtquick2/qquicktextinput/data/mouseselectionmode_characters.qml +++ /dev/null @@ -1,8 +0,0 @@ -import QtQuick 2.0 - -TextInput { - focus: true - text: "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ" - selectByMouse: true - mouseSelectionMode: TextInput.SelectCharacters -} diff --git a/tests/auto/qtquick2/qquicktextinput/data/mouseselectionmode_default.qml b/tests/auto/qtquick2/qquicktextinput/data/mouseselectionmode_default.qml deleted file mode 100644 index 974041b04a..0000000000 --- a/tests/auto/qtquick2/qquicktextinput/data/mouseselectionmode_default.qml +++ /dev/null @@ -1,7 +0,0 @@ -import QtQuick 2.0 - -TextInput { - focus: true - text: "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ" - selectByMouse: true -} diff --git a/tests/auto/qtquick2/qquicktextinput/data/mouseselectionmode_words.qml b/tests/auto/qtquick2/qquicktextinput/data/mouseselectionmode_words.qml deleted file mode 100644 index 20e777e470..0000000000 --- a/tests/auto/qtquick2/qquicktextinput/data/mouseselectionmode_words.qml +++ /dev/null @@ -1,8 +0,0 @@ -import QtQuick 2.0 - -TextInput { - focus: true - text: "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ" - selectByMouse: true - mouseSelectionMode: TextInput.SelectWords -} diff --git a/tests/auto/qtquick2/qquicktextinput/data/navigation.qml b/tests/auto/qtquick2/qquicktextinput/data/navigation.qml deleted file mode 100644 index 3a7d07b3c7..0000000000 --- a/tests/auto/qtquick2/qquicktextinput/data/navigation.qml +++ /dev/null @@ -1,24 +0,0 @@ -import QtQuick 2.0 - -Rectangle { - property variant myInput: input - - width: 800; height: 600; color: "blue" - - Item { - id: firstItem; - KeyNavigation.right: input - } - - TextInput { id: input; focus: true - text: "Needs some text" - KeyNavigation.left: firstItem - KeyNavigation.right: lastItem - KeyNavigation.up: firstItem - KeyNavigation.down: lastItem - } - Item { - id: lastItem - KeyNavigation.left: input - } -} diff --git a/tests/auto/qtquick2/qquicktextinput/data/negativeDimensions.qml b/tests/auto/qtquick2/qquicktextinput/data/negativeDimensions.qml deleted file mode 100644 index 7a58c85b1d..0000000000 --- a/tests/auto/qtquick2/qquicktextinput/data/negativeDimensions.qml +++ /dev/null @@ -1,19 +0,0 @@ -import QtQuick 2.0 - -Item { - TextInput { - objectName: "input" - - focus: true - width: -1 - height: -1 - text: "sushi" - - anchors { - left: parent.left; - leftMargin: 5 - top: parent.top - topMargin: font.pixelSize - } - } -} diff --git a/tests/auto/qtquick2/qquicktextinput/data/openInputPanel.qml b/tests/auto/qtquick2/qquicktextinput/data/openInputPanel.qml deleted file mode 100644 index ca5cb263aa..0000000000 --- a/tests/auto/qtquick2/qquicktextinput/data/openInputPanel.qml +++ /dev/null @@ -1,7 +0,0 @@ -import QtQuick 2.0 - -TextInput { - width: 100; height: 100 - text: "Hello world" - focus: false -} diff --git a/tests/auto/qtquick2/qquicktextinput/data/persistentSelection.qml b/tests/auto/qtquick2/qquicktextinput/data/persistentSelection.qml deleted file mode 100644 index dea6e48b08..0000000000 --- a/tests/auto/qtquick2/qquicktextinput/data/persistentSelection.qml +++ /dev/null @@ -1,8 +0,0 @@ -import QtQuick 2.0 - -TextInput { - property string selected: selectedText - - text: "Hello World!" - focus: true -} diff --git a/tests/auto/qtquick2/qquicktextinput/data/positionAt.qml b/tests/auto/qtquick2/qquicktextinput/data/positionAt.qml deleted file mode 100644 index edb4744107..0000000000 --- a/tests/auto/qtquick2/qquicktextinput/data/positionAt.qml +++ /dev/null @@ -1,9 +0,0 @@ -import QtQuick 2.0 - -TextInput{ - focus: true - objectName: "myInput" - width: 50 - height: 100 - text: "AAAAAAAAAAAAAAAAAAAAAAAAAAAA" -} diff --git a/tests/auto/qtquick2/qquicktextinput/data/preeditAutoScroll.qml b/tests/auto/qtquick2/qquicktextinput/data/preeditAutoScroll.qml deleted file mode 100644 index 9d98a2e220..0000000000 --- a/tests/auto/qtquick2/qquicktextinput/data/preeditAutoScroll.qml +++ /dev/null @@ -1,7 +0,0 @@ -import QtQuick 2.0 - -TextInput { - focus: true - text: "super" - autoScroll: true -} diff --git a/tests/auto/qtquick2/qquicktextinput/data/qtbug-19956double.qml b/tests/auto/qtquick2/qquicktextinput/data/qtbug-19956double.qml deleted file mode 100644 index e9b80fceb2..0000000000 --- a/tests/auto/qtquick2/qquicktextinput/data/qtbug-19956double.qml +++ /dev/null @@ -1,15 +0,0 @@ -import QtQuick 2.0 - -TextInput { - id: textinput - property real topvalue: 30 - property real bottomvalue: 10 - height: 50 - width: 200 - text: "20" - validator: DoubleValidator { - id: doublevalidator - bottom: bottomvalue - top: topvalue - } -} diff --git a/tests/auto/qtquick2/qquicktextinput/data/qtbug-19956int.qml b/tests/auto/qtquick2/qquicktextinput/data/qtbug-19956int.qml deleted file mode 100644 index 0d70eedb80..0000000000 --- a/tests/auto/qtquick2/qquicktextinput/data/qtbug-19956int.qml +++ /dev/null @@ -1,15 +0,0 @@ -import QtQuick 2.0 - -TextInput { - id: textinput - property real topvalue: 30 - property real bottomvalue: 10 - height: 50 - width: 200 - text: "20" - validator: IntValidator { - id: intvalidator - bottom: bottomvalue - top: topvalue - } -} diff --git a/tests/auto/qtquick2/qquicktextinput/data/qtbug-19956regexp.qml b/tests/auto/qtquick2/qquicktextinput/data/qtbug-19956regexp.qml deleted file mode 100644 index b5af13cc4c..0000000000 --- a/tests/auto/qtquick2/qquicktextinput/data/qtbug-19956regexp.qml +++ /dev/null @@ -1,13 +0,0 @@ -import QtQuick 2.0 - -TextInput { - id: textinput - property variant regexvalue - height: 50 - width: 200 - text: "abc" - validator: RegExpValidator { - id: regexpvalidator - regExp: regexvalue - } -} diff --git a/tests/auto/qtquick2/qquicktextinput/data/readOnly.qml b/tests/auto/qtquick2/qquicktextinput/data/readOnly.qml deleted file mode 100644 index 9cda7fbd1d..0000000000 --- a/tests/auto/qtquick2/qquicktextinput/data/readOnly.qml +++ /dev/null @@ -1,12 +0,0 @@ -import QtQuick 2.0 - -Rectangle { - property variant myInput: input - - width: 800; height: 600; color: "blue" - - TextInput { id: input; focus: true - readOnly: true - text: "I am the very model of a modern major general.\n" - } -} diff --git a/tests/auto/qtquick2/qquicktextinput/data/validators.qml b/tests/auto/qtquick2/qquicktextinput/data/validators.qml deleted file mode 100644 index 0ba87e0592..0000000000 --- a/tests/auto/qtquick2/qquicktextinput/data/validators.qml +++ /dev/null @@ -1,29 +0,0 @@ -import QtQuick 2.0 - -Item { - property variant intInput: intInput - property variant dblInput: dblInput - property variant strInput: strInput - property variant unvalidatedInput: unvalidatedInput - - width: 800; height: 600; - - Column{ - TextInput { id: intInput; - property bool acceptable: acceptableInput - validator: IntValidator{top: 11; bottom: 2} - } - TextInput { id: dblInput; - property bool acceptable: acceptableInput - validator: DoubleValidator{top: 12.12; bottom: 2.93; decimals: 2; notation: DoubleValidator.StandardNotation} - } - TextInput { id: strInput; - property bool acceptable: acceptableInput - validator: RegExpValidator { regExp: /[a-zA-z]{2,4}/ } - } - TextInput { id: unvalidatedInput - property bool acceptable: acceptableInput - } - } - -} diff --git a/tests/auto/qtquick2/qquicktextinput/qquicktextinput.pro b/tests/auto/qtquick2/qquicktextinput/qquicktextinput.pro deleted file mode 100644 index 08ce675a03..0000000000 --- a/tests/auto/qtquick2/qquicktextinput/qquicktextinput.pro +++ /dev/null @@ -1,13 +0,0 @@ -CONFIG += testcase -TARGET = tst_qquicktextinput -macx:CONFIG -= app_bundle - -SOURCES += tst_qquicktextinput.cpp - -include (../../shared/util.pri) - -testDataFiles.files = data -testDataFiles.path = . -DEPLOYMENT += testDataFiles - -QT += core-private gui-private v8-private declarative-private quick-private opengl-private testlib diff --git a/tests/auto/qtquick2/qquicktextinput/tst_qquicktextinput.cpp b/tests/auto/qtquick2/qquicktextinput/tst_qquicktextinput.cpp deleted file mode 100644 index c1768bd98a..0000000000 --- a/tests/auto/qtquick2/qquicktextinput/tst_qquicktextinput.cpp +++ /dev/null @@ -1,4706 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include -#include -#include "../../shared/util.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#ifdef Q_OS_MAC -#include -#endif - -#include "qplatformdefs.h" -#include "../../shared/platforminputcontext.h" - -Q_DECLARE_METATYPE(QQuickTextInput::SelectionMode) -DEFINE_BOOL_CONFIG_OPTION(qmlDisableDistanceField, QML_DISABLE_DISTANCEFIELD) - -QString createExpectedFileIfNotFound(const QString& filebasename, const QImage& actual) -{ - // XXX This will be replaced by some clever persistent platform image store. - QString persistent_dir = QDeclarativeDataTest::instance()->dataDirectory(); - QString arch = "unknown-architecture"; // QTest needs to help with this. - - QString expectfile = persistent_dir + QDir::separator() + filebasename + "-" + arch + ".png"; - - if (!QFile::exists(expectfile)) { - actual.save(expectfile); - qWarning() << "created" << expectfile; - } - - return expectfile; -} - -template static T evaluate(QObject *scope, const QString &expression) -{ - QDeclarativeExpression expr(qmlContext(scope), scope, expression); - T result = expr.evaluate().value(); - if (expr.hasError()) - qWarning() << expr.error().toString(); - return result; -} - -typedef QPair Key; - -class tst_qquicktextinput : public QDeclarativeDataTest - -{ - Q_OBJECT -public: - tst_qquicktextinput(); - -private slots: - void cleanup(); - void text(); - void width(); - void font(); - void color(); - void wrap(); - void selection(); - void persistentSelection(); - void isRightToLeft_data(); - void isRightToLeft(); - void moveCursorSelection_data(); - void moveCursorSelection(); - void moveCursorSelectionSequence_data(); - void moveCursorSelectionSequence(); - void dragMouseSelection(); - void mouseSelectionMode_data(); - void mouseSelectionMode(); - void tripleClickSelectsAll(); - - void horizontalAlignment_data(); - void horizontalAlignment(); - void horizontalAlignment_RightToLeft(); - void verticalAlignment(); - - void boundingRect(); - - void positionAt(); - - void maxLength(); - void masks(); - void validators(); - void inputMethods(); - - void passwordCharacter(); - void cursorDelegate_data(); - void cursorDelegate(); - void cursorVisible(); - void cursorRectangle(); - void navigation(); - void navigation_RTL(); - void copyAndPaste(); - void copyAndPasteKeySequence(); - void canPasteEmpty(); - void canPaste(); - void readOnly(); - - void openInputPanel(); - void setHAlignClearCache(); - void focusOutClearSelection(); - - void echoMode(); -#ifdef QT_GUI_PASSWORD_ECHO_DELAY - void passwordEchoDelay(); -#endif - void geometrySignals(); - void contentSize(); - - void preeditAutoScroll(); - void preeditCursorRectangle(); - void inputContextMouseHandler(); - void inputMethodComposing(); - void inputMethodUpdate(); - void cursorRectangleSize(); - - void getText_data(); - void getText(); - void insert_data(); - void insert(); - void remove_data(); - void remove(); - - void keySequence_data(); - void keySequence(); - - void undo_data(); - void undo(); - void redo_data(); - void redo(); - void undo_keypressevents_data(); - void undo_keypressevents(); - - void QTBUG_19956(); - void QTBUG_19956_data(); - void QTBUG_19956_regexp(); - - void negativeDimensions(); - -private: - void simulateKey(QQuickView *, int key); - - void simulateKeys(QWindow *window, const QList &keys); - void simulateKeys(QWindow *window, const QKeySequence &sequence); - - QDeclarativeEngine engine; - QStringList standard; - QStringList colorStrings; -}; - -typedef QList IntList; -Q_DECLARE_METATYPE(IntList) - -typedef QList KeyList; -Q_DECLARE_METATYPE(KeyList) - -void tst_qquicktextinput::simulateKeys(QWindow *window, const QList &keys) -{ - for (int i = 0; i < keys.count(); ++i) { - const int key = keys.at(i).first; - const int modifiers = key & Qt::KeyboardModifierMask; - const QString text = !keys.at(i).second.isNull() ? QString(keys.at(i).second) : QString(); - - QKeyEvent press(QEvent::KeyPress, Qt::Key(key), Qt::KeyboardModifiers(modifiers), text); - QKeyEvent release(QEvent::KeyRelease, Qt::Key(key), Qt::KeyboardModifiers(modifiers), text); - - QGuiApplication::sendEvent(window, &press); - QGuiApplication::sendEvent(window, &release); - } -} - -void tst_qquicktextinput::simulateKeys(QWindow *window, const QKeySequence &sequence) -{ - for (int i = 0; i < sequence.count(); ++i) { - const int key = sequence[i]; - const int modifiers = key & Qt::KeyboardModifierMask; - - QTest::keyClick(window, Qt::Key(key & ~modifiers), Qt::KeyboardModifiers(modifiers)); - } -} - -QList &operator <<(QList &keys, const QKeySequence &sequence) -{ - for (int i = 0; i < sequence.count(); ++i) - keys << Key(sequence[i], QChar()); - return keys; -} - -template QList &operator <<(QList &keys, const char (&characters)[N]) -{ - for (int i = 0; i < N - 1; ++i) { - int key = QTest::asciiToKey(characters[i]); - QChar character = QLatin1Char(characters[i]); - keys << Key(key, character); - } - return keys; -} - -QList &operator <<(QList &keys, Qt::Key key) -{ - keys << Key(key, QChar()); - return keys; -} - -void tst_qquicktextinput::cleanup() -{ - // ensure not even skipped tests with custom input context leave it dangling - QInputMethodPrivate *inputMethodPrivate = QInputMethodPrivate::get(qApp->inputMethod()); - inputMethodPrivate->testContext = 0; -} - -tst_qquicktextinput::tst_qquicktextinput() -{ - standard << "the quick brown fox jumped over the lazy dog" - << "It's supercalifragisiticexpialidocious!" - << "Hello, world!" - << "!dlrow ,olleH" - << " spacey text "; - - colorStrings << "aliceblue" - << "antiquewhite" - << "aqua" - << "darkkhaki" - << "darkolivegreen" - << "dimgray" - << "palevioletred" - << "lightsteelblue" - << "#000000" - << "#AAAAAA" - << "#FFFFFF" - << "#2AC05F"; -} - -void tst_qquicktextinput::text() -{ - { - QDeclarativeComponent textinputComponent(&engine); - textinputComponent.setData("import QtQuick 2.0\nTextInput { text: \"\" }", QUrl()); - QQuickTextInput *textinputObject = qobject_cast(textinputComponent.create()); - - QVERIFY(textinputObject != 0); - QCOMPARE(textinputObject->text(), QString("")); - QCOMPARE(textinputObject->length(), 0); - - delete textinputObject; - } - - for (int i = 0; i < standard.size(); i++) - { - QString componentStr = "import QtQuick 2.0\nTextInput { text: \"" + standard.at(i) + "\" }"; - QDeclarativeComponent textinputComponent(&engine); - textinputComponent.setData(componentStr.toLatin1(), QUrl()); - QQuickTextInput *textinputObject = qobject_cast(textinputComponent.create()); - - QVERIFY(textinputObject != 0); - QCOMPARE(textinputObject->text(), standard.at(i)); - QCOMPARE(textinputObject->length(), standard.at(i).length()); - - delete textinputObject; - } - -} - -void tst_qquicktextinput::width() -{ - // uses Font metrics to find the width for standard - { - QDeclarativeComponent textinputComponent(&engine); - textinputComponent.setData("import QtQuick 2.0\nTextInput { text: \"\" }", QUrl()); - QQuickTextInput *textinputObject = qobject_cast(textinputComponent.create()); - - QVERIFY(textinputObject != 0); - QCOMPARE(textinputObject->width(), 0.0); - - delete textinputObject; - } - - bool requiresUnhintedMetrics = !qmlDisableDistanceField(); - - for (int i = 0; i < standard.size(); i++) - { - QString componentStr = "import QtQuick 2.0\nTextInput { text: \"" + standard.at(i) + "\" }"; - QDeclarativeComponent textinputComponent(&engine); - textinputComponent.setData(componentStr.toLatin1(), QUrl()); - QQuickTextInput *textinputObject = qobject_cast(textinputComponent.create()); - - QString s = standard.at(i); - s.replace(QLatin1Char('\n'), QChar::LineSeparator); - - QTextLayout layout(s); - layout.setFont(textinputObject->font()); - layout.setFlags(Qt::TextExpandTabs | Qt::TextShowMnemonic); - if (requiresUnhintedMetrics) { - QTextOption option; - option.setUseDesignMetrics(true); - layout.setTextOption(option); - } - - layout.beginLayout(); - forever { - QTextLine line = layout.createLine(); - if (!line.isValid()) - break; - } - - layout.endLayout(); - - qreal metricWidth = ceil(layout.boundingRect().width()); - - QVERIFY(textinputObject != 0); - int delta = abs(int(int(textinputObject->width()) - metricWidth)); - QVERIFY(delta <= 3.0); // As best as we can hope for cross-platform. - - delete textinputObject; - } -} - -void tst_qquicktextinput::font() -{ - //test size, then bold, then italic, then family - { - QString componentStr = "import QtQuick 2.0\nTextInput { font.pointSize: 40; text: \"Hello World\" }"; - QDeclarativeComponent textinputComponent(&engine); - textinputComponent.setData(componentStr.toLatin1(), QUrl()); - QQuickTextInput *textinputObject = qobject_cast(textinputComponent.create()); - - QVERIFY(textinputObject != 0); - QCOMPARE(textinputObject->font().pointSize(), 40); - QCOMPARE(textinputObject->font().bold(), false); - QCOMPARE(textinputObject->font().italic(), false); - - delete textinputObject; - } - - { - QString componentStr = "import QtQuick 2.0\nTextInput { font.bold: true; text: \"Hello World\" }"; - QDeclarativeComponent textinputComponent(&engine); - textinputComponent.setData(componentStr.toLatin1(), QUrl()); - QQuickTextInput *textinputObject = qobject_cast(textinputComponent.create()); - - QVERIFY(textinputObject != 0); - QCOMPARE(textinputObject->font().bold(), true); - QCOMPARE(textinputObject->font().italic(), false); - - delete textinputObject; - } - - { - QString componentStr = "import QtQuick 2.0\nTextInput { font.italic: true; text: \"Hello World\" }"; - QDeclarativeComponent textinputComponent(&engine); - textinputComponent.setData(componentStr.toLatin1(), QUrl()); - QQuickTextInput *textinputObject = qobject_cast(textinputComponent.create()); - - QVERIFY(textinputObject != 0); - QCOMPARE(textinputObject->font().italic(), true); - QCOMPARE(textinputObject->font().bold(), false); - - delete textinputObject; - } - - { - QString componentStr = "import QtQuick 2.0\nTextInput { font.family: \"Helvetica\"; text: \"Hello World\" }"; - QDeclarativeComponent textinputComponent(&engine); - textinputComponent.setData(componentStr.toLatin1(), QUrl()); - QQuickTextInput *textinputObject = qobject_cast(textinputComponent.create()); - - QVERIFY(textinputObject != 0); - QCOMPARE(textinputObject->font().family(), QString("Helvetica")); - QCOMPARE(textinputObject->font().bold(), false); - QCOMPARE(textinputObject->font().italic(), false); - - delete textinputObject; - } - - { - QString componentStr = "import QtQuick 2.0\nTextInput { font.family: \"\"; text: \"Hello World\" }"; - QDeclarativeComponent textinputComponent(&engine); - textinputComponent.setData(componentStr.toLatin1(), QUrl()); - QQuickTextInput *textinputObject = qobject_cast(textinputComponent.create()); - - QVERIFY(textinputObject != 0); - QCOMPARE(textinputObject->font().family(), QString("")); - - delete textinputObject; - } -} - -void tst_qquicktextinput::color() -{ - //test color - for (int i = 0; i < colorStrings.size(); i++) - { - QString componentStr = "import QtQuick 2.0\nTextInput { color: \"" + colorStrings.at(i) + "\"; text: \"Hello World\" }"; - QDeclarativeComponent textinputComponent(&engine); - textinputComponent.setData(componentStr.toLatin1(), QUrl()); - QQuickTextInput *textinputObject = qobject_cast(textinputComponent.create()); - QVERIFY(textinputObject != 0); - QCOMPARE(textinputObject->color(), QColor(colorStrings.at(i))); - - delete textinputObject; - } - - //test selection color - for (int i = 0; i < colorStrings.size(); i++) - { - QString componentStr = "import QtQuick 2.0\nTextInput { selectionColor: \"" + colorStrings.at(i) + "\"; text: \"Hello World\" }"; - QDeclarativeComponent textinputComponent(&engine); - textinputComponent.setData(componentStr.toLatin1(), QUrl()); - QQuickTextInput *textinputObject = qobject_cast(textinputComponent.create()); - QVERIFY(textinputObject != 0); - QCOMPARE(textinputObject->selectionColor(), QColor(colorStrings.at(i))); - - delete textinputObject; - } - - //test selected text color - for (int i = 0; i < colorStrings.size(); i++) - { - QString componentStr = "import QtQuick 2.0\nTextInput { selectedTextColor: \"" + colorStrings.at(i) + "\"; text: \"Hello World\" }"; - QDeclarativeComponent textinputComponent(&engine); - textinputComponent.setData(componentStr.toLatin1(), QUrl()); - QQuickTextInput *textinputObject = qobject_cast(textinputComponent.create()); - QVERIFY(textinputObject != 0); - QCOMPARE(textinputObject->selectedTextColor(), QColor(colorStrings.at(i))); - - delete textinputObject; - } - - { - QString colorStr = "#AA001234"; - QColor testColor("#001234"); - testColor.setAlpha(170); - - QString componentStr = "import QtQuick 2.0\nTextInput { color: \"" + colorStr + "\"; text: \"Hello World\" }"; - QDeclarativeComponent textinputComponent(&engine); - textinputComponent.setData(componentStr.toLatin1(), QUrl()); - QQuickTextInput *textinputObject = qobject_cast(textinputComponent.create()); - - QVERIFY(textinputObject != 0); - QCOMPARE(textinputObject->color(), testColor); - - delete textinputObject; - } -} - -void tst_qquicktextinput::wrap() -{ - int textHeight = 0; - // for specified width and wrap set true - { - QDeclarativeComponent textComponent(&engine); - textComponent.setData("import QtQuick 2.0\nTextInput { text: \"Hello\"; wrapMode: Text.WrapAnywhere; width: 300 }", QUrl::fromLocalFile("")); - QQuickTextInput *textObject = qobject_cast(textComponent.create()); - textHeight = textObject->height(); - - QVERIFY(textObject != 0); - QVERIFY(textObject->wrapMode() == QQuickTextInput::WrapAnywhere); - QCOMPARE(textObject->width(), 300.); - - delete textObject; - } - - for (int i = 0; i < standard.count(); i++) { - QString componentStr = "import QtQuick 2.0\nTextInput { wrapMode: Text.WrapAnywhere; width: 30; text: \"" + standard.at(i) + "\" }"; - QDeclarativeComponent textComponent(&engine); - textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); - QQuickTextInput *textObject = qobject_cast(textComponent.create()); - - QVERIFY(textObject != 0); - QCOMPARE(textObject->width(), 30.); - QVERIFY(textObject->height() > textHeight); - - int oldHeight = textObject->height(); - textObject->setWidth(100); - QVERIFY(textObject->height() < oldHeight); - - delete textObject; - } -} - -void tst_qquicktextinput::selection() -{ - QString testStr = standard[0]; - QString componentStr = "import QtQuick 2.0\nTextInput { text: \""+ testStr +"\"; }"; - QDeclarativeComponent textinputComponent(&engine); - textinputComponent.setData(componentStr.toLatin1(), QUrl()); - QQuickTextInput *textinputObject = qobject_cast(textinputComponent.create()); - QVERIFY(textinputObject != 0); - - - //Test selection follows cursor - for (int i=0; i<= testStr.size(); i++) { - textinputObject->setCursorPosition(i); - QCOMPARE(textinputObject->cursorPosition(), i); - QCOMPARE(textinputObject->selectionStart(), i); - QCOMPARE(textinputObject->selectionEnd(), i); - QVERIFY(textinputObject->selectedText().isNull()); - } - - textinputObject->setCursorPosition(0); - QVERIFY(textinputObject->cursorPosition() == 0); - QVERIFY(textinputObject->selectionStart() == 0); - QVERIFY(textinputObject->selectionEnd() == 0); - QVERIFY(textinputObject->selectedText().isNull()); - - // Verify invalid positions are ignored. - textinputObject->setCursorPosition(-1); - QVERIFY(textinputObject->cursorPosition() == 0); - QVERIFY(textinputObject->selectionStart() == 0); - QVERIFY(textinputObject->selectionEnd() == 0); - QVERIFY(textinputObject->selectedText().isNull()); - - textinputObject->setCursorPosition(textinputObject->text().count()+1); - QVERIFY(textinputObject->cursorPosition() == 0); - QVERIFY(textinputObject->selectionStart() == 0); - QVERIFY(textinputObject->selectionEnd() == 0); - QVERIFY(textinputObject->selectedText().isNull()); - - //Test selection - for (int i=0; i<= testStr.size(); i++) { - textinputObject->select(0,i); - QCOMPARE(testStr.mid(0,i), textinputObject->selectedText()); - } - for (int i=0; i<= testStr.size(); i++) { - textinputObject->select(i,testStr.size()); - QCOMPARE(testStr.mid(i,testStr.size()-i), textinputObject->selectedText()); - } - - textinputObject->setCursorPosition(0); - QVERIFY(textinputObject->cursorPosition() == 0); - QVERIFY(textinputObject->selectionStart() == 0); - QVERIFY(textinputObject->selectionEnd() == 0); - QVERIFY(textinputObject->selectedText().isNull()); - - //Test Error Ignoring behaviour - textinputObject->setCursorPosition(0); - QVERIFY(textinputObject->selectedText().isNull()); - textinputObject->select(-10,0); - QVERIFY(textinputObject->selectedText().isNull()); - textinputObject->select(100,110); - QVERIFY(textinputObject->selectedText().isNull()); - textinputObject->select(0,-10); - QVERIFY(textinputObject->selectedText().isNull()); - textinputObject->select(0,100); - QVERIFY(textinputObject->selectedText().isNull()); - textinputObject->select(0,10); - QVERIFY(textinputObject->selectedText().size() == 10); - textinputObject->select(-10,10); - QVERIFY(textinputObject->selectedText().size() == 10); - textinputObject->select(100,101); - QVERIFY(textinputObject->selectedText().size() == 10); - textinputObject->select(0,-10); - QVERIFY(textinputObject->selectedText().size() == 10); - textinputObject->select(0,100); - QVERIFY(textinputObject->selectedText().size() == 10); - - textinputObject->deselect(); - QVERIFY(textinputObject->selectedText().isNull()); - textinputObject->select(0,10); - QVERIFY(textinputObject->selectedText().size() == 10); - textinputObject->deselect(); - QVERIFY(textinputObject->selectedText().isNull()); - - // test input method selection - QSignalSpy selectionSpy(textinputObject, SIGNAL(selectedTextChanged())); - textinputObject->setFocus(true); - { - QList attributes; - attributes << QInputMethodEvent::Attribute(QInputMethodEvent::Selection, 12, 5, QVariant()); - QInputMethodEvent event("", attributes); - QGuiApplication::sendEvent(textinputObject, &event); - } - QCOMPARE(selectionSpy.count(), 1); - QCOMPARE(textinputObject->selectionStart(), 12); - QCOMPARE(textinputObject->selectionEnd(), 17); - - delete textinputObject; -} - -void tst_qquicktextinput::persistentSelection() -{ - QQuickView canvas(testFileUrl("persistentSelection.qml")); - canvas.show(); - canvas.requestActivateWindow(); - QTest::qWaitForWindowShown(&canvas); - QTRY_COMPARE(&canvas, qGuiApp->focusWindow()); - canvas.requestActivateWindow(); - - QQuickTextInput *input = qobject_cast(canvas.rootObject()); - QVERIFY(input); - QVERIFY(input->hasActiveFocus()); - - QSignalSpy spy(input, SIGNAL(persistentSelectionChanged())); - - QCOMPARE(input->persistentSelection(), false); - - input->setPersistentSelection(false); - QCOMPARE(input->persistentSelection(), false); - QCOMPARE(spy.count(), 0); - - input->select(1, 4); - QCOMPARE(input->property("selected").toString(), QLatin1String("ell")); - - input->setFocus(false); - QCOMPARE(input->property("selected").toString(), QString()); - - input->setFocus(true); - QCOMPARE(input->property("selected").toString(), QString()); - - input->setPersistentSelection(true); - QCOMPARE(input->persistentSelection(), true); - QCOMPARE(spy.count(), 1); - - input->select(1, 4); - QCOMPARE(input->property("selected").toString(), QLatin1String("ell")); - - input->setFocus(false); - QCOMPARE(input->property("selected").toString(), QLatin1String("ell")); - - input->setFocus(true); - QCOMPARE(input->property("selected").toString(), QLatin1String("ell")); -} - -void tst_qquicktextinput::isRightToLeft_data() -{ - QTest::addColumn("text"); - QTest::addColumn("emptyString"); - QTest::addColumn("firstCharacter"); - QTest::addColumn("lastCharacter"); - QTest::addColumn("middleCharacter"); - QTest::addColumn("startString"); - QTest::addColumn("midString"); - QTest::addColumn("endString"); - - const quint16 arabic_str[] = { 0x0638, 0x0643, 0x00646, 0x0647, 0x0633, 0x0638, 0x0643, 0x00646, 0x0647, 0x0633, 0x0647}; - QTest::newRow("Empty") << "" << false << false << false << false << false << false << false; - QTest::newRow("Neutral") << "23244242" << false << false << false << false << false << false << false; - QTest::newRow("LTR") << "Hello world" << false << false << false << false << false << false << false; - QTest::newRow("RTL") << QString::fromUtf16(arabic_str, 11) << false << true << true << true << true << true << true; - QTest::newRow("Bidi RTL + LTR + RTL") << QString::fromUtf16(arabic_str, 11) + QString("Hello world") + QString::fromUtf16(arabic_str, 11) << false << true << true << false << true << true << true; - QTest::newRow("Bidi LTR + RTL + LTR") << QString("Hello world") + QString::fromUtf16(arabic_str, 11) + QString("Hello world") << false << false << false << true << false << false << false; -} - -void tst_qquicktextinput::isRightToLeft() -{ - QFETCH(QString, text); - QFETCH(bool, emptyString); - QFETCH(bool, firstCharacter); - QFETCH(bool, lastCharacter); - QFETCH(bool, middleCharacter); - QFETCH(bool, startString); - QFETCH(bool, midString); - QFETCH(bool, endString); - - QQuickTextInput textInput; - textInput.setText(text); - - // first test that the right string is delivered to the QString::isRightToLeft() - QCOMPARE(textInput.isRightToLeft(0,0), text.mid(0,0).isRightToLeft()); - QCOMPARE(textInput.isRightToLeft(0,1), text.mid(0,1).isRightToLeft()); - QCOMPARE(textInput.isRightToLeft(text.count()-2, text.count()-1), text.mid(text.count()-2, text.count()-1).isRightToLeft()); - QCOMPARE(textInput.isRightToLeft(text.count()/2, text.count()/2 + 1), text.mid(text.count()/2, text.count()/2 + 1).isRightToLeft()); - QCOMPARE(textInput.isRightToLeft(0,text.count()/4), text.mid(0,text.count()/4).isRightToLeft()); - QCOMPARE(textInput.isRightToLeft(text.count()/4,3*text.count()/4), text.mid(text.count()/4,3*text.count()/4).isRightToLeft()); - if (text.isEmpty()) - QTest::ignoreMessage(QtWarningMsg, ": QML TextInput: isRightToLeft(start, end) called with the end property being smaller than the start."); - QCOMPARE(textInput.isRightToLeft(3*text.count()/4,text.count()-1), text.mid(3*text.count()/4,text.count()-1).isRightToLeft()); - - // then test that the feature actually works - QCOMPARE(textInput.isRightToLeft(0,0), emptyString); - QCOMPARE(textInput.isRightToLeft(0,1), firstCharacter); - QCOMPARE(textInput.isRightToLeft(text.count()-2, text.count()-1), lastCharacter); - QCOMPARE(textInput.isRightToLeft(text.count()/2, text.count()/2 + 1), middleCharacter); - QCOMPARE(textInput.isRightToLeft(0,text.count()/4), startString); - QCOMPARE(textInput.isRightToLeft(text.count()/4,3*text.count()/4), midString); - if (text.isEmpty()) - QTest::ignoreMessage(QtWarningMsg, ": QML TextInput: isRightToLeft(start, end) called with the end property being smaller than the start."); - QCOMPARE(textInput.isRightToLeft(3*text.count()/4,text.count()-1), endString); -} - -void tst_qquicktextinput::moveCursorSelection_data() -{ - QTest::addColumn("testStr"); - QTest::addColumn("cursorPosition"); - QTest::addColumn("movePosition"); - QTest::addColumn("mode"); - QTest::addColumn("selectionStart"); - QTest::addColumn("selectionEnd"); - QTest::addColumn("reversible"); - - // () contains the text selected by the cursor. - // <> contains the actual selection. - - QTest::newRow("(t)he|characters") - << standard[0] << 0 << 1 << QQuickTextInput::SelectCharacters << 0 << 1 << true; - QTest::newRow("do(g)|characters") - << standard[0] << 43 << 44 << QQuickTextInput::SelectCharacters << 43 << 44 << true; - QTest::newRow("jum(p)ed|characters") - << standard[0] << 23 << 24 << QQuickTextInput::SelectCharacters << 23 << 24 << true; - QTest::newRow("jumped( )over|characters") - << standard[0] << 26 << 27 << QQuickTextInput::SelectCharacters << 26 << 27 << true; - QTest::newRow("(the )|characters") - << standard[0] << 0 << 4 << QQuickTextInput::SelectCharacters << 0 << 4 << true; - QTest::newRow("( dog)|characters") - << standard[0] << 40 << 44 << QQuickTextInput::SelectCharacters << 40 << 44 << true; - QTest::newRow("( jumped )|characters") - << standard[0] << 19 << 27 << QQuickTextInput::SelectCharacters << 19 << 27 << true; - QTest::newRow("th(e qu)ick|characters") - << standard[0] << 2 << 6 << QQuickTextInput::SelectCharacters << 2 << 6 << true; - QTest::newRow("la(zy d)og|characters") - << standard[0] << 38 << 42 << QQuickTextInput::SelectCharacters << 38 << 42 << true; - QTest::newRow("jum(ped ov)er|characters") - << standard[0] << 23 << 29 << QQuickTextInput::SelectCharacters << 23 << 29 << true; - QTest::newRow("()the|characters") - << standard[0] << 0 << 0 << QQuickTextInput::SelectCharacters << 0 << 0 << true; - QTest::newRow("dog()|characters") - << standard[0] << 44 << 44 << QQuickTextInput::SelectCharacters << 44 << 44 << true; - QTest::newRow("jum()ped|characters") - << standard[0] << 23 << 23 << QQuickTextInput::SelectCharacters << 23 << 23 << true; - - QTest::newRow("<(t)he>|words") - << standard[0] << 0 << 1 << QQuickTextInput::SelectWords << 0 << 3 << true; - QTest::newRow("|words") - << standard[0] << 43 << 44 << QQuickTextInput::SelectWords << 41 << 44 << true; - QTest::newRow("|words") - << standard[0] << 23 << 24 << QQuickTextInput::SelectWords << 20 << 26 << true; - QTest::newRow("over|words,ltr") - << standard[0] << 26 << 27 << QQuickTextInput::SelectWords << 20 << 27 << false; - QTest::newRow("jumped<( )over>|words,rtl") - << standard[0] << 27 << 26 << QQuickTextInput::SelectWords << 26 << 31 << false; - QTest::newRow("<(the )>quick|words,ltr") - << standard[0] << 0 << 4 << QQuickTextInput::SelectWords << 0 << 4 << false; - QTest::newRow("<(the )quick>|words,rtl") - << standard[0] << 4 << 0 << QQuickTextInput::SelectWords << 0 << 9 << false; - QTest::newRow("|words,ltr") - << standard[0] << 40 << 44 << QQuickTextInput::SelectWords << 36 << 44 << false; - QTest::newRow("lazy<( dog)>|words,rtl") - << standard[0] << 44 << 40 << QQuickTextInput::SelectWords << 40 << 44 << false; - QTest::newRow("over|words,ltr") - << standard[0] << 19 << 27 << QQuickTextInput::SelectWords << 16 << 27 << false; - QTest::newRow("fox<( jumped )over>|words,rtl") - << standard[0] << 27 << 19 << QQuickTextInput::SelectWords << 19 << 31 << false; - QTest::newRow("|words") - << standard[0] << 2 << 6 << QQuickTextInput::SelectWords << 0 << 9 << true; - QTest::newRow("") - << standard[0] << 38 << 42 << QQuickTextInput::SelectWords << 36 << 44 << true; - QTest::newRow("|words") - << standard[0] << 23 << 29 << QQuickTextInput::SelectWords << 20 << 31 << true; - QTest::newRow("<()>the|words") - << standard[0] << 0 << 0 << QQuickTextInput::SelectWords << 0 << 0 << true; - QTest::newRow("dog<()>|words") - << standard[0] << 44 << 44 << QQuickTextInput::SelectWords << 44 << 44 << true; - QTest::newRow("jum<()>ped|words") - << standard[0] << 23 << 23 << QQuickTextInput::SelectWords << 23 << 23 << true; - - QTest::newRow("Hello<(,)> |words") - << standard[2] << 5 << 6 << QQuickTextInput::SelectWords << 5 << 6 << true; - QTest::newRow("Hello<(, )>world|words,ltr") - << standard[2] << 5 << 7 << QQuickTextInput::SelectWords << 5 << 7 << false; - QTest::newRow("Hello<(, )world>|words,rtl") - << standard[2] << 7 << 5 << QQuickTextInput::SelectWords << 5 << 12 << false; - QTest::newRow("world|words,ltr") - << standard[2] << 3 << 7 << QQuickTextInput::SelectWords << 0 << 7 << false; - QTest::newRow("|words,rtl") - << standard[2] << 7 << 3 << QQuickTextInput::SelectWords << 0 << 12 << false; - QTest::newRow(",|words") - << standard[2] << 3 << 5 << QQuickTextInput::SelectWords << 0 << 5 << true; - QTest::newRow("Hello<()>,|words") - << standard[2] << 5 << 5 << QQuickTextInput::SelectWords << 5 << 5 << true; - QTest::newRow("Hello,<()>|words") - << standard[2] << 6 << 6 << QQuickTextInput::SelectWords << 6 << 6 << true; - QTest::newRow("Hello<,( )>world|words,ltr") - << standard[2] << 6 << 7 << QQuickTextInput::SelectWords << 5 << 7 << false; - QTest::newRow("Hello,<( )world>|words,rtl") - << standard[2] << 7 << 6 << QQuickTextInput::SelectWords << 6 << 12 << false; - QTest::newRow("Hello<,( world)>|words,ltr") - << standard[2] << 6 << 12 << QQuickTextInput::SelectWords << 5 << 12 << false; - QTest::newRow("Hello,<( world)>|words,rtl") - << standard[2] << 12 << 6 << QQuickTextInput::SelectWords << 6 << 12 << false; - QTest::newRow("Hello<,( world!)>|words,ltr") - << standard[2] << 6 << 13 << QQuickTextInput::SelectWords << 5 << 13 << false; - QTest::newRow("Hello,<( world!)>|words,rtl") - << standard[2] << 13 << 6 << QQuickTextInput::SelectWords << 6 << 13 << false; - QTest::newRow("Hello<(, world!)>|words") - << standard[2] << 5 << 13 << QQuickTextInput::SelectWords << 5 << 13 << true; - // Fails due to an issue with QTextBoundaryFinder and punctuation at the end of strings. - // QTBUG-11365 - // QTest::newRow("world<(!)>|words") - // << standard[2] << 12 << 13 << QQuickTextInput::SelectWords << 12 << 13 << true; - QTest::newRow("world!<()>)|words") - << standard[2] << 13 << 13 << QQuickTextInput::SelectWords << 13 << 13 << true; - QTest::newRow("world<()>!)|words") - << standard[2] << 12 << 12 << QQuickTextInput::SelectWords << 12 << 12 << true; - - QTest::newRow("<(,)>olleH |words") - << standard[3] << 7 << 8 << QQuickTextInput::SelectWords << 7 << 8 << true; - QTest::newRow("olleH|words,ltr") - << standard[3] << 6 << 8 << QQuickTextInput::SelectWords << 1 << 8 << false; - QTest::newRow("dlrow<( ,)>olleH|words,rtl") - << standard[3] << 8 << 6 << QQuickTextInput::SelectWords << 6 << 8 << false; - QTest::newRow("|words,ltr") - << standard[3] << 6 << 10 << QQuickTextInput::SelectWords << 1 << 13 << false; - QTest::newRow("dlrow<( ,ol)leH>|words,rtl") - << standard[3] << 10 << 6 << QQuickTextInput::SelectWords << 6 << 13 << false; - QTest::newRow(",<(ol)leH>,|words") - << standard[3] << 8 << 10 << QQuickTextInput::SelectWords << 8 << 13 << true; - QTest::newRow(",<()>olleH|words") - << standard[3] << 8 << 8 << QQuickTextInput::SelectWords << 8 << 8 << true; - QTest::newRow("<()>,olleH|words") - << standard[3] << 7 << 7 << QQuickTextInput::SelectWords << 7 << 7 << true; - QTest::newRow(",olleH|words,ltr") - << standard[3] << 6 << 7 << QQuickTextInput::SelectWords << 1 << 7 << false; - QTest::newRow("dlrow<( ),>olleH|words,rtl") - << standard[3] << 7 << 6 << QQuickTextInput::SelectWords << 6 << 8 << false; - QTest::newRow("<(dlrow )>,olleH|words,ltr") - << standard[3] << 1 << 7 << QQuickTextInput::SelectWords << 1 << 7 << false; - QTest::newRow("<(dlrow ),>olleH|words,rtl") - << standard[3] << 7 << 1 << QQuickTextInput::SelectWords << 1 << 8 << false; - QTest::newRow("<(!dlrow )>,olleH|words,ltr") - << standard[3] << 0 << 7 << QQuickTextInput::SelectWords << 0 << 7 << false; - QTest::newRow("<(!dlrow ),>olleH|words,rtl") - << standard[3] << 7 << 0 << QQuickTextInput::SelectWords << 0 << 8 << false; - QTest::newRow("(!dlrow ,)olleH|words") - << standard[3] << 0 << 8 << QQuickTextInput::SelectWords << 0 << 8 << true; - QTest::newRow("<(!)>dlrow|words") - << standard[3] << 0 << 1 << QQuickTextInput::SelectWords << 0 << 1 << true; - QTest::newRow("<()>!dlrow|words") - << standard[3] << 0 << 0 << QQuickTextInput::SelectWords << 0 << 0 << true; - QTest::newRow("!<()>dlrow|words") - << standard[3] << 1 << 1 << QQuickTextInput::SelectWords << 1 << 1 << true; - - QTest::newRow(" text |words") - << standard[4] << 1 << 4 << QQuickTextInput::SelectWords << 1 << 7 << true; - QTest::newRow(" spacey |words") - << standard[4] << 11 << 13 << QQuickTextInput::SelectWords << 10 << 14 << false; // Should be reversible. QTBUG-11365 - QTest::newRow("<( )>spacey text |words|ltr") - << standard[4] << 0 << 1 << QQuickTextInput::SelectWords << 0 << 1 << false; - QTest::newRow("<( )spacey> text |words|rtl") - << standard[4] << 1 << 0 << QQuickTextInput::SelectWords << 0 << 7 << false; - QTest::newRow("spacey |words|ltr") - << standard[4] << 14 << 15 << QQuickTextInput::SelectWords << 10 << 15 << false; -// QTBUG-11365 -// QTest::newRow("spacey text<( )>|words|rtl") -// << standard[4] << 15 << 14 << QQuickTextInput::SelectWords << 14 << 15 << false; - QTest::newRow("<()> spacey text |words") - << standard[4] << 0 << 0 << QQuickTextInput::SelectWords << 0 << 0 << false; - QTest::newRow(" spacey text <()>|words") - << standard[4] << 15 << 15 << QQuickTextInput::SelectWords << 15 << 15 << false; -} - -void tst_qquicktextinput::moveCursorSelection() -{ - QFETCH(QString, testStr); - QFETCH(int, cursorPosition); - QFETCH(int, movePosition); - QFETCH(QQuickTextInput::SelectionMode, mode); - QFETCH(int, selectionStart); - QFETCH(int, selectionEnd); - QFETCH(bool, reversible); - - QString componentStr = "import QtQuick 2.0\nTextInput { text: \""+ testStr +"\"; }"; - QDeclarativeComponent textinputComponent(&engine); - textinputComponent.setData(componentStr.toLatin1(), QUrl()); - QQuickTextInput *textinputObject = qobject_cast(textinputComponent.create()); - QVERIFY(textinputObject != 0); - - textinputObject->setCursorPosition(cursorPosition); - textinputObject->moveCursorSelection(movePosition, mode); - - QCOMPARE(textinputObject->selectedText(), testStr.mid(selectionStart, selectionEnd - selectionStart)); - QCOMPARE(textinputObject->selectionStart(), selectionStart); - QCOMPARE(textinputObject->selectionEnd(), selectionEnd); - - if (reversible) { - textinputObject->setCursorPosition(movePosition); - textinputObject->moveCursorSelection(cursorPosition, mode); - - QCOMPARE(textinputObject->selectedText(), testStr.mid(selectionStart, selectionEnd - selectionStart)); - QCOMPARE(textinputObject->selectionStart(), selectionStart); - QCOMPARE(textinputObject->selectionEnd(), selectionEnd); - } - - delete textinputObject; -} - -void tst_qquicktextinput::moveCursorSelectionSequence_data() -{ - QTest::addColumn("testStr"); - QTest::addColumn("cursorPosition"); - QTest::addColumn("movePosition1"); - QTest::addColumn("movePosition2"); - QTest::addColumn("selection1Start"); - QTest::addColumn("selection1End"); - QTest::addColumn("selection2Start"); - QTest::addColumn("selection2End"); - - // () contains the text selected by the cursor. - // <> contains the actual selection. - // ^ is the revised cursor position. - // {} contains the revised selection. - - QTest::newRow("the { f^ox} jumped|ltr") - << standard[0] - << 9 << 13 << 17 - << 4 << 15 - << 4 << 19; - QTest::newRow("the quick<( {bro)wn> f^ox} jumped|rtl") - << standard[0] - << 13 << 9 << 17 - << 9 << 15 - << 10 << 19; - QTest::newRow("the { ^}fox jumped|ltr") - << standard[0] - << 9 << 13 << 16 - << 4 << 15 - << 4 << 16; - QTest::newRow("the quick<( {bro)wn> ^}fox jumped|rtl") - << standard[0] - << 13 << 9 << 16 - << 9 << 15 - << 10 << 16; - QTest::newRow("the {} fox jumped|ltr") - << standard[0] - << 9 << 13 << 15 - << 4 << 15 - << 4 << 15; - QTest::newRow("the quick<( {bro)wn^>} f^ox jumped|rtl") - << standard[0] - << 13 << 9 << 15 - << 9 << 15 - << 10 << 15; - QTest::newRow("the { fox|ltr") - << standard[0] - << 9 << 13 << 10 - << 4 << 15 - << 4 << 10; - QTest::newRow("the quick<( {^bro)wn>} fox|rtl") - << standard[0] - << 13 << 9 << 10 - << 9 << 15 - << 10 << 15; - QTest::newRow("the { fox|ltr") - << standard[0] - << 9 << 13 << 9 - << 4 << 15 - << 4 << 9; - QTest::newRow("the quick{<(^ bro)wn>} fox|rtl") - << standard[0] - << 13 << 9 << 9 - << 9 << 15 - << 9 << 15; - QTest::newRow("the { fox|ltr") - << standard[0] - << 9 << 13 << 7 - << 4 << 15 - << 4 << 9; - QTest::newRow("the { fox|rtl") - << standard[0] - << 13 << 9 << 7 - << 9 << 15 - << 4 << 15; - QTest::newRow("the {<^quick}( bro)wn> fox|ltr") - << standard[0] - << 9 << 13 << 4 - << 4 << 15 - << 4 << 9; - QTest::newRow("the {<^quick}( bro)wn> fox|rtl") - << standard[0] - << 13 << 9 << 4 - << 9 << 15 - << 4 << 15; - QTest::newRow("the{^ fox|ltr") - << standard[0] - << 9 << 13 << 3 - << 4 << 15 - << 3 << 9; - QTest::newRow("the{^ fox|rtl") - << standard[0] - << 13 << 9 << 3 - << 9 << 15 - << 3 << 15; - QTest::newRow("{t^he fox|ltr") - << standard[0] - << 9 << 13 << 1 - << 4 << 15 - << 0 << 9; - QTest::newRow("{t^he fox|rtl") - << standard[0] - << 13 << 9 << 1 - << 9 << 15 - << 0 << 15; - - QTest::newRow("{, w^orld}!|ltr") - << standard[2] - << 2 << 4 << 8 - << 0 << 5 - << 0 << 12; - QTest::newRow("{, w^orld}!|rtl") - << standard[2] - << 4 << 2 << 8 - << 0 << 5 - << 0 << 12; - - QTest::newRow("!{dlro^w ,}|ltr") - << standard[3] - << 9 << 11 << 5 - << 8 << 13 - << 1 << 13; - QTest::newRow("!{dlro^w ,}|rtl") - << standard[3] - << 11 << 9 << 5 - << 8 << 13 - << 1 << 13; - - QTest::newRow("{<(^} sp)acey> text |ltr") - << standard[4] - << 0 << 3 << 0 - << 0 << 7 - << 0 << 0; - QTest::newRow("{<( ^}sp)acey> text |ltr") - << standard[4] - << 0 << 3 << 1 - << 0 << 7 - << 0 << 1; - QTest::newRow("<( {s^p)acey>} text |rtl") - << standard[4] - << 3 << 0 << 2 - << 0 << 7 - << 1 << 7; - QTest::newRow("<( {^sp)acey>} text |rtl") - << standard[4] - << 3 << 0 << 1 - << 0 << 7 - << 1 << 7; - - QTest::newRow(" spacey }|rtl") - << standard[4] - << 15 << 12 << 15 - << 10 << 15 - << 15 << 15; -// QTBUG-11365 -// QTest::newRow(" spacey }|rtl") -// << standard[4] -// << 15 << 12 << 14 -// << 10 << 15 -// << 14 << 15; - QTest::newRow(" spacey {|ltr") - << standard[4] - << 12 << 15 << 13 - << 10 << 15 - << 10 << 14; -// QTBUG-11365 -// QTest::newRow(" spacey {|ltr") -// << standard[4] -// << 12 << 15 << 14 -// << 10 << 15 -// << 10 << 14; -} - -void tst_qquicktextinput::moveCursorSelectionSequence() -{ - QFETCH(QString, testStr); - QFETCH(int, cursorPosition); - QFETCH(int, movePosition1); - QFETCH(int, movePosition2); - QFETCH(int, selection1Start); - QFETCH(int, selection1End); - QFETCH(int, selection2Start); - QFETCH(int, selection2End); - - QString componentStr = "import QtQuick 2.0\nTextInput { text: \""+ testStr +"\"; }"; - QDeclarativeComponent textinputComponent(&engine); - textinputComponent.setData(componentStr.toLatin1(), QUrl()); - QQuickTextInput *textinputObject = qobject_cast(textinputComponent.create()); - QVERIFY(textinputObject != 0); - - textinputObject->setCursorPosition(cursorPosition); - - textinputObject->moveCursorSelection(movePosition1, QQuickTextInput::SelectWords); - QCOMPARE(textinputObject->selectedText(), testStr.mid(selection1Start, selection1End - selection1Start)); - QCOMPARE(textinputObject->selectionStart(), selection1Start); - QCOMPARE(textinputObject->selectionEnd(), selection1End); - - textinputObject->moveCursorSelection(movePosition2, QQuickTextInput::SelectWords); - QCOMPARE(textinputObject->selectedText(), testStr.mid(selection2Start, selection2End - selection2Start)); - QCOMPARE(textinputObject->selectionStart(), selection2Start); - QCOMPARE(textinputObject->selectionEnd(), selection2End); - - delete textinputObject; -} - -void tst_qquicktextinput::dragMouseSelection() -{ - QString qmlfile = testFile("mouseselection_true.qml"); - - QQuickView canvas(QUrl::fromLocalFile(qmlfile)); - - canvas.show(); - canvas.requestActivateWindow(); - QTest::qWaitForWindowShown(&canvas); - - QTRY_COMPARE(&canvas, qGuiApp->focusWindow()); - - QVERIFY(canvas.rootObject() != 0); - QQuickTextInput *textInputObject = qobject_cast(canvas.rootObject()); - QVERIFY(textInputObject != 0); - - // press-and-drag-and-release from x1 to x2 - int x1 = 10; - int x2 = 70; - int y = textInputObject->height()/2; - QTest::mousePress(&canvas, Qt::LeftButton, 0, QPoint(x1,y)); - QTest::mouseMove(&canvas, QPoint(x2, y)); - QTest::mouseRelease(&canvas, Qt::LeftButton, 0, QPoint(x2,y)); - QTest::qWait(100); - QString str1; - QVERIFY((str1 = textInputObject->selectedText()).length() > 3); - QVERIFY(str1.length() > 3); - - // press and drag the current selection. - x1 = 40; - x2 = 100; - QTest::mousePress(&canvas, Qt::LeftButton, 0, QPoint(x1,y)); - QTest::mouseMove(&canvas, QPoint(x2, y)); - QTest::mouseRelease(&canvas, Qt::LeftButton, 0, QPoint(x2,y)); - QTest::qWait(300); - QString str2 = textInputObject->selectedText(); - QVERIFY(str2.length() > 3); - - QVERIFY(str1 != str2); -} - -void tst_qquicktextinput::mouseSelectionMode_data() -{ - QTest::addColumn("qmlfile"); - QTest::addColumn("selectWords"); - - // import installed - QTest::newRow("SelectWords") << testFile("mouseselectionmode_words.qml") << true; - QTest::newRow("SelectCharacters") << testFile("mouseselectionmode_characters.qml") << false; - QTest::newRow("default") << testFile("mouseselectionmode_default.qml") << false; -} - -void tst_qquicktextinput::mouseSelectionMode() -{ - QFETCH(QString, qmlfile); - QFETCH(bool, selectWords); - - QString text = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"; - - QQuickView canvas(QUrl::fromLocalFile(qmlfile)); - - canvas.show(); - canvas.requestActivateWindow(); - QTest::qWaitForWindowShown(&canvas); - QTRY_COMPARE(&canvas, qGuiApp->focusWindow()); - - QVERIFY(canvas.rootObject() != 0); - QQuickTextInput *textInputObject = qobject_cast(canvas.rootObject()); - QVERIFY(textInputObject != 0); - - // press-and-drag-and-release from x1 to x2 - int x1 = 10; - int x2 = 70; - int y = textInputObject->height()/2; - QTest::mousePress(&canvas, Qt::LeftButton, 0, QPoint(x1,y)); - QTest::mouseMove(&canvas, QPoint(x2,y)); // doesn't work - QTest::mouseRelease(&canvas, Qt::LeftButton, 0, QPoint(x2,y)); - QTest::qWait(300); - if (selectWords) { - QTRY_COMPARE(textInputObject->selectedText(), text); - } else { - QTRY_VERIFY(textInputObject->selectedText().length() > 3); - QVERIFY(textInputObject->selectedText() != text); - } -} - -void tst_qquicktextinput::horizontalAlignment_data() -{ - QTest::addColumn("hAlign"); - QTest::addColumn("expectfile"); - - QTest::newRow("L") << int(Qt::AlignLeft) << "halign_left"; - QTest::newRow("R") << int(Qt::AlignRight) << "halign_right"; - QTest::newRow("C") << int(Qt::AlignHCenter) << "halign_center"; -} - -void tst_qquicktextinput::horizontalAlignment() -{ - QSKIP("Image comparison of text is almost guaranteed to fail during development"); - - QFETCH(int, hAlign); - QFETCH(QString, expectfile); - - QQuickView canvas(testFileUrl("horizontalAlignment.qml")); - - canvas.show(); - canvas.requestActivateWindow(); - QTest::qWaitForWindowShown(&canvas); - QTRY_COMPARE(&canvas, qGuiApp->focusWindow()); - QObject *ob = canvas.rootObject(); - QVERIFY(ob != 0); - ob->setProperty("horizontalAlignment",hAlign); - QImage actual = canvas.grabFrameBuffer(); - - expectfile = createExpectedFileIfNotFound(expectfile, actual); - - QImage expect(expectfile); - - QCOMPARE(actual,expect); -} - -void tst_qquicktextinput::horizontalAlignment_RightToLeft() -{ - PlatformInputContext platformInputContext; - QInputMethodPrivate *inputMethodPrivate = QInputMethodPrivate::get(qApp->inputMethod()); - inputMethodPrivate->testContext = &platformInputContext; - - QQuickView canvas(testFileUrl("horizontalAlignment_RightToLeft.qml")); - QQuickTextInput *textInput = canvas.rootObject()->findChild("text"); - QVERIFY(textInput != 0); - canvas.show(); - - const QString rtlText = textInput->text(); - - QQuickTextInputPrivate *textInputPrivate = QQuickTextInputPrivate::get(textInput); - QVERIFY(textInputPrivate != 0); - QVERIFY(textInputPrivate->boundingRect.right() - textInputPrivate->hscroll >= textInput->width() - 1); - QVERIFY(textInputPrivate->boundingRect.right() - textInputPrivate->hscroll <= textInput->width() + 1); - - // implicit alignment should follow the reading direction of RTL text - QCOMPARE(textInput->hAlign(), QQuickTextInput::AlignRight); - QCOMPARE(textInput->effectiveHAlign(), textInput->hAlign()); - QVERIFY(textInputPrivate->boundingRect.right() - textInputPrivate->hscroll >= textInput->width() - 1); - QVERIFY(textInputPrivate->boundingRect.right() - textInputPrivate->hscroll <= textInput->width() + 1); - - // explicitly left aligned - textInput->setHAlign(QQuickTextInput::AlignLeft); - QCOMPARE(textInput->hAlign(), QQuickTextInput::AlignLeft); - QCOMPARE(textInput->effectiveHAlign(), textInput->hAlign()); - QCOMPARE(textInputPrivate->boundingRect.left() - textInputPrivate->hscroll, qreal(0)); - - // explicitly right aligned - textInput->setHAlign(QQuickTextInput::AlignRight); - QCOMPARE(textInput->effectiveHAlign(), textInput->hAlign()); - QCOMPARE(textInput->hAlign(), QQuickTextInput::AlignRight); - QVERIFY(textInputPrivate->boundingRect.right() - textInputPrivate->hscroll >= textInput->width() - 1); - QVERIFY(textInputPrivate->boundingRect.right() - textInputPrivate->hscroll <= textInput->width() + 1); - - // explicitly center aligned - textInput->setHAlign(QQuickTextInput::AlignHCenter); - QCOMPARE(textInput->effectiveHAlign(), textInput->hAlign()); - QCOMPARE(textInput->hAlign(), QQuickTextInput::AlignHCenter); - QVERIFY(textInputPrivate->boundingRect.left() - textInputPrivate->hscroll > 0); - QVERIFY(textInputPrivate->boundingRect.right() - textInputPrivate->hscroll < textInput->width()); - - // reseted alignment should go back to following the text reading direction - textInput->resetHAlign(); - QCOMPARE(textInput->hAlign(), QQuickTextInput::AlignRight); - QCOMPARE(textInput->effectiveHAlign(), textInput->hAlign()); - QVERIFY(textInputPrivate->boundingRect.right() - textInputPrivate->hscroll >= textInput->width() - 1); - QVERIFY(textInputPrivate->boundingRect.right() - textInputPrivate->hscroll <= textInput->width() + 1); - - // mirror the text item - QQuickItemPrivate::get(textInput)->setLayoutMirror(true); - - // mirrored implicit alignment should continue to follow the reading direction of the text - QCOMPARE(textInput->hAlign(), QQuickTextInput::AlignRight); - QCOMPARE(textInput->effectiveHAlign(), textInput->hAlign()); - QVERIFY(textInputPrivate->boundingRect.right() - textInputPrivate->hscroll >= textInput->width() - 1); - QVERIFY(textInputPrivate->boundingRect.right() - textInputPrivate->hscroll <= textInput->width() + 1); - - // explicitly right aligned behaves as left aligned - textInput->setHAlign(QQuickTextInput::AlignRight); - QCOMPARE(textInput->hAlign(), QQuickTextInput::AlignRight); - QCOMPARE(textInput->effectiveHAlign(), QQuickTextInput::AlignLeft); - QCOMPARE(textInputPrivate->boundingRect.left() - textInputPrivate->hscroll, qreal(0)); - - // mirrored explicitly left aligned behaves as right aligned - textInput->setHAlign(QQuickTextInput::AlignLeft); - QCOMPARE(textInput->hAlign(), QQuickTextInput::AlignLeft); - QCOMPARE(textInput->effectiveHAlign(), QQuickTextInput::AlignRight); - QVERIFY(textInputPrivate->boundingRect.right() - textInputPrivate->hscroll >= textInput->width() - 1); - QVERIFY(textInputPrivate->boundingRect.right() - textInputPrivate->hscroll <= textInput->width() + 1); - - // disable mirroring - QQuickItemPrivate::get(textInput)->setLayoutMirror(false); - QCOMPARE(textInput->effectiveHAlign(), textInput->hAlign()); - textInput->resetHAlign(); - - // English text should be implicitly left aligned - textInput->setText("Hello world!"); - QCOMPARE(textInput->hAlign(), QQuickTextInput::AlignLeft); - QCOMPARE(textInputPrivate->boundingRect.left() - textInputPrivate->hscroll, qreal(0)); - - canvas.requestActivateWindow(); - QTest::qWaitForWindowShown(&canvas); - QTRY_COMPARE(&canvas, qGuiApp->focusWindow()); - - // If there is no commited text, the preedit text should determine the alignment. - textInput->setText(QString()); - { QInputMethodEvent ev(rtlText, QList()); QGuiApplication::sendEvent(qGuiApp->focusObject(), &ev); } - QCOMPARE(textInput->hAlign(), QQuickTextInput::AlignRight); - { QInputMethodEvent ev("Hello world!", QList()); QGuiApplication::sendEvent(qGuiApp->focusObject(), &ev); } - QCOMPARE(textInput->hAlign(), QQuickTextInput::AlignLeft); - - // Clear pre-edit text. TextInput should maybe do this itself on setText, but that may be - // redundant as an actual input method may take care of it. - { QInputMethodEvent ev; QGuiApplication::sendEvent(qGuiApp->focusObject(), &ev); } - - // empty text with implicit alignment follows the system locale-based - // keyboard input direction from QInputMethod::inputDirection() - textInput->setText(""); - platformInputContext.setInputDirection(Qt::LeftToRight); - QVERIFY(qApp->inputMethod()->inputDirection() == Qt::LeftToRight); - QCOMPARE(textInput->hAlign(), QQuickTextInput::AlignLeft); - QCOMPARE(textInputPrivate->boundingRect.left() - textInputPrivate->hscroll, qreal(0)); - - QSignalSpy cursorRectangleSpy(textInput, SIGNAL(cursorRectangleChanged())); - platformInputContext.setInputDirection(Qt::RightToLeft); - QVERIFY(qApp->inputMethod()->inputDirection() == Qt::RightToLeft); - QCOMPARE(cursorRectangleSpy.count(), 1); - QCOMPARE(textInput->hAlign(), QQuickTextInput::AlignRight); - QVERIFY(textInputPrivate->boundingRect.right() - textInputPrivate->hscroll >= textInput->width() - 1); - QVERIFY(textInputPrivate->boundingRect.right() - textInputPrivate->hscroll <= textInput->width() + 1); - - // set input direction while having content - platformInputContext.setInputDirection(Qt::LeftToRight); - textInput->setText("a"); - platformInputContext.setInputDirection(Qt::RightToLeft); - QTest::keyClick(&canvas, Qt::Key_Backspace); - QVERIFY(textInput->text().isEmpty()); - QCOMPARE(textInput->hAlign(), QQuickTextInput::AlignRight); - QVERIFY(textInputPrivate->boundingRect.right() - textInputPrivate->hscroll >= textInput->width() - 1); - QVERIFY(textInputPrivate->boundingRect.right() - textInputPrivate->hscroll <= textInput->width() + 1); - - // input direction changed while not having focus - platformInputContext.setInputDirection(Qt::LeftToRight); - textInput->setFocus(false); - platformInputContext.setInputDirection(Qt::RightToLeft); - textInput->setFocus(true); - QCOMPARE(textInput->hAlign(), QQuickTextInput::AlignRight); - QVERIFY(textInputPrivate->boundingRect.right() - textInputPrivate->hscroll >= textInput->width() - 1); - QVERIFY(textInputPrivate->boundingRect.right() - textInputPrivate->hscroll <= textInput->width() + 1); - - textInput->setHAlign(QQuickTextInput::AlignRight); - QCOMPARE(textInput->hAlign(), QQuickTextInput::AlignRight); - QVERIFY(textInputPrivate->boundingRect.right() - textInputPrivate->hscroll >= textInput->width() - 1); - QVERIFY(textInputPrivate->boundingRect.right() - textInputPrivate->hscroll <= textInput->width() + 1); -} - -void tst_qquicktextinput::verticalAlignment() -{ - QQuickView canvas(testFileUrl("horizontalAlignment.qml")); - QQuickTextInput *textInput = canvas.rootObject()->findChild("text"); - QVERIFY(textInput != 0); - canvas.show(); - - QQuickTextInputPrivate *textInputPrivate = QQuickTextInputPrivate::get(textInput); - QVERIFY(textInputPrivate != 0); - - QCOMPARE(textInput->vAlign(), QQuickTextInput::AlignTop); - QVERIFY(textInputPrivate->boundingRect.bottom() - textInputPrivate->vscroll < canvas.height() / 2); - QVERIFY(textInput->cursorRectangle().bottom() < canvas.height() / 2); - QVERIFY(textInput->positionToRectangle(0).bottom() < canvas.height() / 2); - - // bottom aligned - textInput->setVAlign(QQuickTextInput::AlignBottom); - QCOMPARE(textInput->vAlign(), QQuickTextInput::AlignBottom); - QVERIFY(textInputPrivate->boundingRect.top() - textInputPrivate->vscroll > canvas.height() / 2); - QVERIFY(textInput->cursorRectangle().top() > canvas.height() / 2); - QVERIFY(textInput->positionToRectangle(0).top() > canvas.height() / 2); - - // explicitly center aligned - textInput->setVAlign(QQuickTextInput::AlignVCenter); - QCOMPARE(textInput->vAlign(), QQuickTextInput::AlignVCenter); - QVERIFY(textInputPrivate->boundingRect.top() - textInputPrivate->vscroll < canvas.height() / 2); - QVERIFY(textInputPrivate->boundingRect.bottom() - textInputPrivate->vscroll > canvas.height() / 2); - QVERIFY(textInput->cursorRectangle().top() < canvas.height() / 2); - QVERIFY(textInput->cursorRectangle().bottom() > canvas.height() / 2); - QVERIFY(textInput->positionToRectangle(0).top() < canvas.height() / 2); - QVERIFY(textInput->positionToRectangle(0).bottom() > canvas.height() / 2); -} - -void tst_qquicktextinput::boundingRect() -{ - QDeclarativeComponent component(&engine); - component.setData("import QtQuick 2.0\n TextInput {}", QUrl()); - QScopedPointer object(component.create()); - QQuickTextInput *input = qobject_cast(object.data()); - QVERIFY(input); - - QCOMPARE(input->width() + input->cursorRectangle().width(), input->boundingRect().width()); - QCOMPARE(input->height(), input->boundingRect().height()); - - input->setText("Hello World"); - QCOMPARE(input->width() + input->cursorRectangle().width(), input->boundingRect().width()); - QCOMPARE(input->height(), input->boundingRect().height()); - - // bounding rect shouldn't exceed the size of the item, expect for the cursor width; - input->setWidth(input->width() / 2); - QCOMPARE(input->width() + input->cursorRectangle().width(), input->boundingRect().width()); - QCOMPARE(input->height(), input->boundingRect().height()); - - input->setHeight(input->height() * 2); - QCOMPARE(input->width() + input->cursorRectangle().width(), input->boundingRect().width()); - QCOMPARE(input->height(), input->boundingRect().height()); - - QDeclarativeComponent cursorComponent(&engine); - cursorComponent.setData("import QtQuick 2.0\nRectangle { height: 20; width: 8 }", QUrl()); - - input->setCursorDelegate(&cursorComponent); - - // If a cursor delegate is used it's size should determine the excess width. - QCOMPARE(input->width() + 8, input->boundingRect().width()); - QCOMPARE(input->height(), input->boundingRect().height()); -} - -void tst_qquicktextinput::positionAt() -{ - QQuickView canvas(testFileUrl("positionAt.qml")); - QVERIFY(canvas.rootObject() != 0); - canvas.show(); - canvas.requestActivateWindow(); - QTest::qWaitForWindowShown(&canvas); - - QQuickTextInput *textinputObject = qobject_cast(canvas.rootObject()); - QVERIFY(textinputObject != 0); - - // Check autoscrolled... - - int pos = evaluate(textinputObject, QString("positionAt(%1)").arg(textinputObject->width()/2)); - - QTextLayout layout(textinputObject->text()); - layout.setFont(textinputObject->font()); - - if (!qmlDisableDistanceField()) { - QTextOption option; - option.setUseDesignMetrics(true); - layout.setTextOption(option); - } - layout.beginLayout(); - QTextLine line = layout.createLine(); - layout.endLayout(); - - int textLeftWidthBegin = floor(line.cursorToX(pos - 1)); - int textLeftWidthEnd = ceil(line.cursorToX(pos + 1)); - int textWidth = floor(line.horizontalAdvance()); - - QVERIFY(textLeftWidthBegin <= textWidth - textinputObject->width() / 2); - QVERIFY(textLeftWidthEnd >= textWidth - textinputObject->width() / 2); - - int x = textinputObject->positionToRectangle(pos + 1).x() - 1; - QCOMPARE(evaluate(textinputObject, QString("positionAt(%1, 0, TextInput.CursorBetweenCharacters)").arg(x)), pos + 1); - QCOMPARE(evaluate(textinputObject, QString("positionAt(%1, 0, TextInput.CursorOnCharacter)").arg(x)), pos); - - // Check without autoscroll... - textinputObject->setAutoScroll(false); - pos = evaluate(textinputObject, QString("positionAt(%1)").arg(textinputObject->width() / 2)); - - textLeftWidthBegin = floor(line.cursorToX(pos - 1)); - textLeftWidthEnd = ceil(line.cursorToX(pos + 1)); - - QVERIFY(textLeftWidthBegin <= textinputObject->width() / 2); - QVERIFY(textLeftWidthEnd >= textinputObject->width() / 2); - - x = textinputObject->positionToRectangle(pos + 1).x() - 1; - QCOMPARE(evaluate(textinputObject, QString("positionAt(%1, 0, TextInput.CursorBetweenCharacters)").arg(x)), pos + 1); - QCOMPARE(evaluate(textinputObject, QString("positionAt(%1, 0, TextInput.CursorOnCharacter)").arg(x)), pos); - - const qreal x0 = textinputObject->positionToRectangle(pos).x(); - const qreal x1 = textinputObject->positionToRectangle(pos + 1).x(); - - QString preeditText = textinputObject->text().mid(0, pos); - textinputObject->setText(textinputObject->text().mid(pos)); - textinputObject->setCursorPosition(0); - - { QInputMethodEvent inputEvent(preeditText, QList()); - QVERIFY(qGuiApp->focusObject()); - QGuiApplication::sendEvent(qGuiApp->focusObject(), &inputEvent); } - - // Check all points within the preedit text return the same position. - QCOMPARE(evaluate(textinputObject, QString("positionAt(%1)").arg(0)), 0); - QCOMPARE(evaluate(textinputObject, QString("positionAt(%1)").arg(x0 / 2)), 0); - QCOMPARE(evaluate(textinputObject, QString("positionAt(%1)").arg(x0)), 0); - - // Verify positioning returns to normal after the preedit text. - QCOMPARE(evaluate(textinputObject, QString("positionAt(%1)").arg(x1)), 1); - QCOMPARE(textinputObject->positionToRectangle(1).x(), x1); - - { QInputMethodEvent inputEvent; - QVERIFY(qGuiApp->focusObject()); - QGuiApplication::sendEvent(qGuiApp->focusObject(), &inputEvent); } - - // With wrapping. - textinputObject->setWrapMode(QQuickTextInput::WrapAnywhere); - - const qreal y0 = line.height() / 2; - const qreal y1 = line.height() * 3 / 2; - - QCOMPARE(evaluate(textinputObject, QString("positionAt(%1, %2)").arg(x0).arg(y0)), pos); - QCOMPARE(evaluate(textinputObject, QString("positionAt(%1, %2)").arg(x1).arg(y0)), pos + 1); - - int newLinePos = evaluate(textinputObject, QString("positionAt(%1, %2)").arg(x0).arg(y1)); - QVERIFY(newLinePos > pos); - QCOMPARE(evaluate(textinputObject, QString("positionAt(%1, %2)").arg(x1).arg(y1)), newLinePos + 1); -} - -void tst_qquicktextinput::maxLength() -{ - QQuickView canvas(testFileUrl("maxLength.qml")); - QVERIFY(canvas.rootObject() != 0); - canvas.show(); - canvas.requestActivateWindow(); - QTest::qWaitForWindowShown(&canvas); - - QQuickTextInput *textinputObject = qobject_cast(canvas.rootObject()); - QVERIFY(textinputObject != 0); - QVERIFY(textinputObject->text().isEmpty()); - QVERIFY(textinputObject->maxLength() == 10); - foreach (const QString &str, standard) { - QVERIFY(textinputObject->text().length() <= 10); - textinputObject->setText(str); - QVERIFY(textinputObject->text().length() <= 10); - } - - textinputObject->setText(""); - QTRY_VERIFY(textinputObject->hasActiveFocus() == true); - for (int i=0; i<20; i++) { - QTRY_COMPARE(textinputObject->text().length(), qMin(i,10)); - //simulateKey(&canvas, Qt::Key_A); - QTest::keyPress(&canvas, Qt::Key_A); - QTest::keyRelease(&canvas, Qt::Key_A, Qt::NoModifier ,10); - QTest::qWait(50); - } -} - -void tst_qquicktextinput::masks() -{ - //Not a comprehensive test of the possible masks, that's done elsewhere (QLineEdit) - //QString componentStr = "import QtQuick 2.0\nTextInput { inputMask: 'HHHHhhhh'; }"; - QQuickView canvas(testFileUrl("masks.qml")); - canvas.show(); - canvas.requestActivateWindow(); - QVERIFY(canvas.rootObject() != 0); - QQuickTextInput *textinputObject = qobject_cast(canvas.rootObject()); - QVERIFY(textinputObject != 0); - QTRY_VERIFY(textinputObject->hasActiveFocus() == true); - QVERIFY(textinputObject->text().length() == 0); - QCOMPARE(textinputObject->inputMask(), QString("HHHHhhhh; ")); - QCOMPARE(textinputObject->length(), 8); - for (int i=0; i<10; i++) { - QTRY_COMPARE(qMin(i,8), textinputObject->text().length()); - QCOMPARE(textinputObject->length(), 8); - QCOMPARE(textinputObject->getText(0, qMin(i, 8)), QString(qMin(i, 8), 'a')); - QCOMPARE(textinputObject->getText(qMin(i, 8), 8), QString(8 - qMin(i, 8), ' ')); - QCOMPARE(i>=4, textinputObject->hasAcceptableInput()); - //simulateKey(&canvas, Qt::Key_A); - QTest::keyPress(&canvas, Qt::Key_A); - QTest::keyRelease(&canvas, Qt::Key_A, Qt::NoModifier ,10); - QTest::qWait(50); - } -} - -void tst_qquicktextinput::validators() -{ - // Note that this test assumes that the validators are working properly - // so you may need to run their tests first. All validators are checked - // here to ensure that their exposure to QML is working. - - QLocale::setDefault(QLocale(QStringLiteral("C"))); - - QQuickView canvas(testFileUrl("validators.qml")); - canvas.show(); - canvas.requestActivateWindow(); - - QVERIFY(canvas.rootObject() != 0); - - QLocale defaultLocale; - QLocale enLocale("en"); - QLocale deLocale("de_DE"); - - QQuickTextInput *intInput = qobject_cast(qvariant_cast(canvas.rootObject()->property("intInput"))); - QVERIFY(intInput); - QSignalSpy intSpy(intInput, SIGNAL(acceptableInputChanged())); - - QQuickIntValidator *intValidator = qobject_cast(intInput->validator()); - QVERIFY(intValidator); - QCOMPARE(intValidator->localeName(), defaultLocale.name()); - QCOMPARE(intInput->validator()->locale(), defaultLocale); - intValidator->setLocaleName(enLocale.name()); - QCOMPARE(intValidator->localeName(), enLocale.name()); - QCOMPARE(intInput->validator()->locale(), enLocale); - intValidator->resetLocaleName(); - QCOMPARE(intValidator->localeName(), defaultLocale.name()); - QCOMPARE(intInput->validator()->locale(), defaultLocale); - - intInput->setFocus(true); - QTRY_VERIFY(intInput->hasActiveFocus()); - QCOMPARE(intInput->hasAcceptableInput(), false); - QCOMPARE(intInput->property("acceptable").toBool(), false); - QTest::keyPress(&canvas, Qt::Key_1); - QTest::keyRelease(&canvas, Qt::Key_1, Qt::NoModifier ,10); - QTest::qWait(50); - QTRY_COMPARE(intInput->text(), QLatin1String("1")); - QCOMPARE(intInput->hasAcceptableInput(), false); - QCOMPARE(intInput->property("acceptable").toBool(), false); - QCOMPARE(intSpy.count(), 0); - QTest::keyPress(&canvas, Qt::Key_2); - QTest::keyRelease(&canvas, Qt::Key_2, Qt::NoModifier ,10); - QTest::qWait(50); - QTRY_COMPARE(intInput->text(), QLatin1String("1")); - QCOMPARE(intInput->hasAcceptableInput(), false); - QCOMPARE(intInput->property("acceptable").toBool(), false); - QCOMPARE(intSpy.count(), 0); - QTest::keyPress(&canvas, Qt::Key_Period); - QTest::keyRelease(&canvas, Qt::Key_Period, Qt::NoModifier ,10); - QTest::qWait(50); - QTRY_COMPARE(intInput->text(), QLatin1String("1")); - QCOMPARE(intInput->hasAcceptableInput(), false); - QTest::keyPress(&canvas, Qt::Key_Comma); - QTest::keyRelease(&canvas, Qt::Key_Comma, Qt::NoModifier ,10); - QTest::qWait(50); - QTRY_COMPARE(intInput->text(), QLatin1String("1,")); - QCOMPARE(intInput->hasAcceptableInput(), false); - QTest::keyPress(&canvas, Qt::Key_Backspace); - QTest::keyRelease(&canvas, Qt::Key_Backspace, Qt::NoModifier ,10); - QTest::qWait(50); - QTRY_COMPARE(intInput->text(), QLatin1String("1")); - QCOMPARE(intInput->hasAcceptableInput(), false); - intValidator->setLocaleName(deLocale.name()); - QTest::keyPress(&canvas, Qt::Key_Period); - QTest::keyRelease(&canvas, Qt::Key_Period, Qt::NoModifier ,10); - QTest::qWait(50); - QTRY_COMPARE(intInput->text(), QLatin1String("1.")); - QCOMPARE(intInput->hasAcceptableInput(), false); - QTest::keyPress(&canvas, Qt::Key_Backspace); - QTest::keyRelease(&canvas, Qt::Key_Backspace, Qt::NoModifier ,10); - QTest::qWait(50); - QTRY_COMPARE(intInput->text(), QLatin1String("1")); - QCOMPARE(intInput->hasAcceptableInput(), false); - intValidator->resetLocaleName(); - QTest::keyPress(&canvas, Qt::Key_1); - QTest::keyRelease(&canvas, Qt::Key_1, Qt::NoModifier ,10); - QTest::qWait(50); - QCOMPARE(intInput->text(), QLatin1String("11")); - QCOMPARE(intInput->hasAcceptableInput(), true); - QCOMPARE(intInput->property("acceptable").toBool(), true); - QCOMPARE(intSpy.count(), 1); - QTest::keyPress(&canvas, Qt::Key_0); - QTest::keyRelease(&canvas, Qt::Key_0, Qt::NoModifier ,10); - QTest::qWait(50); - QCOMPARE(intInput->text(), QLatin1String("11")); - QCOMPARE(intInput->hasAcceptableInput(), true); - QCOMPARE(intInput->property("acceptable").toBool(), true); - QCOMPARE(intSpy.count(), 1); - - QQuickTextInput *dblInput = qobject_cast(qvariant_cast(canvas.rootObject()->property("dblInput"))); - QVERIFY(dblInput); - QSignalSpy dblSpy(dblInput, SIGNAL(acceptableInputChanged())); - - QQuickDoubleValidator *dblValidator = qobject_cast(dblInput->validator()); - QVERIFY(dblValidator); - QCOMPARE(dblValidator->localeName(), defaultLocale.name()); - QCOMPARE(dblInput->validator()->locale(), defaultLocale); - dblValidator->setLocaleName(enLocale.name()); - QCOMPARE(dblValidator->localeName(), enLocale.name()); - QCOMPARE(dblInput->validator()->locale(), enLocale); - dblValidator->resetLocaleName(); - QCOMPARE(dblValidator->localeName(), defaultLocale.name()); - QCOMPARE(dblInput->validator()->locale(), defaultLocale); - - dblInput->setFocus(true); - QVERIFY(dblInput->hasActiveFocus() == true); - QCOMPARE(dblInput->hasAcceptableInput(), false); - QCOMPARE(dblInput->property("acceptable").toBool(), false); - QTest::keyPress(&canvas, Qt::Key_1); - QTest::keyRelease(&canvas, Qt::Key_1, Qt::NoModifier ,10); - QTest::qWait(50); - QTRY_COMPARE(dblInput->text(), QLatin1String("1")); - QCOMPARE(dblInput->hasAcceptableInput(), false); - QCOMPARE(dblInput->property("acceptable").toBool(), false); - QCOMPARE(dblSpy.count(), 0); - QTest::keyPress(&canvas, Qt::Key_2); - QTest::keyRelease(&canvas, Qt::Key_2, Qt::NoModifier ,10); - QTest::qWait(50); - QTRY_COMPARE(dblInput->text(), QLatin1String("12")); - QCOMPARE(dblInput->hasAcceptableInput(), true); - QCOMPARE(dblInput->property("acceptable").toBool(), true); - QCOMPARE(dblSpy.count(), 1); - QTest::keyPress(&canvas, Qt::Key_Comma); - QTest::keyRelease(&canvas, Qt::Key_Comma, Qt::NoModifier ,10); - QTest::qWait(50); - QTRY_COMPARE(dblInput->text(), QLatin1String("12,")); - QCOMPARE(dblInput->hasAcceptableInput(), true); - QTest::keyPress(&canvas, Qt::Key_1); - QTest::keyRelease(&canvas, Qt::Key_1, Qt::NoModifier ,10); - QTest::qWait(50); - QTRY_COMPARE(dblInput->text(), QLatin1String("12,")); - QCOMPARE(dblInput->hasAcceptableInput(), true); - dblValidator->setLocaleName(deLocale.name()); - QCOMPARE(dblInput->hasAcceptableInput(), true); - QTest::keyPress(&canvas, Qt::Key_1); - QTest::keyRelease(&canvas, Qt::Key_1, Qt::NoModifier ,10); - QTest::qWait(50); - QTRY_COMPARE(dblInput->text(), QLatin1String("12,1")); - QCOMPARE(dblInput->hasAcceptableInput(), true); - QTest::keyPress(&canvas, Qt::Key_1); - QTest::keyRelease(&canvas, Qt::Key_1, Qt::NoModifier ,10); - QTest::qWait(50); - QTRY_COMPARE(dblInput->text(), QLatin1String("12,11")); - QCOMPARE(dblInput->hasAcceptableInput(), true); - QTest::keyPress(&canvas, Qt::Key_Backspace); - QTest::keyRelease(&canvas, Qt::Key_Backspace, Qt::NoModifier ,10); - QTest::qWait(50); - QTRY_COMPARE(dblInput->text(), QLatin1String("12,1")); - QCOMPARE(dblInput->hasAcceptableInput(), true); - QTest::keyPress(&canvas, Qt::Key_Backspace); - QTest::keyRelease(&canvas, Qt::Key_Backspace, Qt::NoModifier ,10); - QTest::qWait(50); - QTRY_COMPARE(dblInput->text(), QLatin1String("12,")); - QCOMPARE(dblInput->hasAcceptableInput(), true); - QTest::keyPress(&canvas, Qt::Key_Backspace); - QTest::keyRelease(&canvas, Qt::Key_Backspace, Qt::NoModifier ,10); - QTest::qWait(50); - QTRY_COMPARE(dblInput->text(), QLatin1String("12")); - QCOMPARE(dblInput->hasAcceptableInput(), true); - dblValidator->resetLocaleName(); - QTest::keyPress(&canvas, Qt::Key_Period); - QTest::keyRelease(&canvas, Qt::Key_Period, Qt::NoModifier ,10); - QTest::qWait(50); - QTRY_COMPARE(dblInput->text(), QLatin1String("12.")); - QCOMPARE(dblInput->hasAcceptableInput(), true); - QCOMPARE(dblInput->property("acceptable").toBool(), true); - QCOMPARE(dblSpy.count(), 1); - QTest::keyPress(&canvas, Qt::Key_1); - QTest::keyRelease(&canvas, Qt::Key_1, Qt::NoModifier ,10); - QTest::qWait(50); - QTRY_COMPARE(dblInput->text(), QLatin1String("12.1")); - QCOMPARE(dblInput->hasAcceptableInput(), true); - QCOMPARE(dblInput->property("acceptable").toBool(), true); - QCOMPARE(dblSpy.count(), 1); - QTest::keyPress(&canvas, Qt::Key_1); - QTest::keyRelease(&canvas, Qt::Key_1, Qt::NoModifier ,10); - QTest::qWait(50); - QTRY_COMPARE(dblInput->text(), QLatin1String("12.11")); - QCOMPARE(dblInput->hasAcceptableInput(), true); - QCOMPARE(dblInput->property("acceptable").toBool(), true); - QCOMPARE(dblSpy.count(), 1); - QTest::keyPress(&canvas, Qt::Key_1); - QTest::keyRelease(&canvas, Qt::Key_1, Qt::NoModifier ,10); - QTest::qWait(50); - QTRY_COMPARE(dblInput->text(), QLatin1String("12.11")); - QCOMPARE(dblInput->hasAcceptableInput(), true); - QCOMPARE(dblInput->property("acceptable").toBool(), true); - QCOMPARE(dblSpy.count(), 1); - - // Ensure the validator doesn't prevent characters being removed. - dblInput->setValidator(intInput->validator()); - QCOMPARE(dblInput->text(), QLatin1String("12.11")); - QCOMPARE(dblInput->hasAcceptableInput(), false); - QCOMPARE(dblInput->property("acceptable").toBool(), false); - QCOMPARE(dblSpy.count(), 2); - QTest::keyPress(&canvas, Qt::Key_Backspace); - QTest::keyRelease(&canvas, Qt::Key_Backspace, Qt::NoModifier ,10); - QTest::qWait(50); - QTRY_COMPARE(dblInput->text(), QLatin1String("12.1")); - QCOMPARE(dblInput->hasAcceptableInput(), false); - QCOMPARE(dblInput->property("acceptable").toBool(), false); - QCOMPARE(dblSpy.count(), 2); - // Once unacceptable input is in anything goes until it reaches an acceptable state again. - QTest::keyPress(&canvas, Qt::Key_1); - QTest::keyRelease(&canvas, Qt::Key_1, Qt::NoModifier ,10); - QTest::qWait(50); - QTRY_COMPARE(dblInput->text(), QLatin1String("12.11")); - QCOMPARE(dblInput->hasAcceptableInput(), false); - QCOMPARE(dblSpy.count(), 2); - QTest::keyPress(&canvas, Qt::Key_Backspace); - QTest::keyRelease(&canvas, Qt::Key_Backspace, Qt::NoModifier ,10); - QTest::qWait(50); - QTRY_COMPARE(dblInput->text(), QLatin1String("12.1")); - QCOMPARE(dblInput->hasAcceptableInput(), false); - QCOMPARE(dblInput->property("acceptable").toBool(), false); - QCOMPARE(dblSpy.count(), 2); - QTest::keyPress(&canvas, Qt::Key_Backspace); - QTest::keyRelease(&canvas, Qt::Key_Backspace, Qt::NoModifier ,10); - QTest::qWait(50); - QTRY_COMPARE(dblInput->text(), QLatin1String("12.")); - QCOMPARE(dblInput->hasAcceptableInput(), false); - QCOMPARE(dblInput->property("acceptable").toBool(), false); - QCOMPARE(dblSpy.count(), 2); - QTest::keyPress(&canvas, Qt::Key_Backspace); - QTest::keyRelease(&canvas, Qt::Key_Backspace, Qt::NoModifier ,10); - QTest::qWait(50); - QTRY_COMPARE(dblInput->text(), QLatin1String("12")); - QCOMPARE(dblInput->hasAcceptableInput(), false); - QCOMPARE(dblInput->property("acceptable").toBool(), false); - QCOMPARE(dblSpy.count(), 2); - QTest::keyPress(&canvas, Qt::Key_Backspace); - QTest::keyRelease(&canvas, Qt::Key_Backspace, Qt::NoModifier ,10); - QTest::qWait(50); - QTRY_COMPARE(dblInput->text(), QLatin1String("1")); - QCOMPARE(dblInput->hasAcceptableInput(), false); - QCOMPARE(dblInput->property("acceptable").toBool(), false); - QCOMPARE(dblSpy.count(), 2); - QTest::keyPress(&canvas, Qt::Key_1); - QTest::keyRelease(&canvas, Qt::Key_1, Qt::NoModifier ,10); - QTest::qWait(50); - QCOMPARE(dblInput->text(), QLatin1String("11")); - QCOMPARE(dblInput->property("acceptable").toBool(), true); - QCOMPARE(dblInput->hasAcceptableInput(), true); - QCOMPARE(dblSpy.count(), 3); - - QQuickTextInput *strInput = qobject_cast(qvariant_cast(canvas.rootObject()->property("strInput"))); - QVERIFY(strInput); - QSignalSpy strSpy(strInput, SIGNAL(acceptableInputChanged())); - strInput->setFocus(true); - QVERIFY(strInput->hasActiveFocus() == true); - QCOMPARE(strInput->hasAcceptableInput(), false); - QCOMPARE(strInput->property("acceptable").toBool(), false); - QTest::keyPress(&canvas, Qt::Key_1); - QTest::keyRelease(&canvas, Qt::Key_1, Qt::NoModifier ,10); - QTest::qWait(50); - QTRY_COMPARE(strInput->text(), QLatin1String("")); - QCOMPARE(strInput->hasAcceptableInput(), false); - QCOMPARE(strInput->property("acceptable").toBool(), false); - QCOMPARE(strSpy.count(), 0); - QTest::keyPress(&canvas, Qt::Key_A); - QTest::keyRelease(&canvas, Qt::Key_A, Qt::NoModifier ,10); - QTest::qWait(50); - QTRY_COMPARE(strInput->text(), QLatin1String("a")); - QCOMPARE(strInput->hasAcceptableInput(), false); - QCOMPARE(strInput->property("acceptable").toBool(), false); - QCOMPARE(strSpy.count(), 0); - QTest::keyPress(&canvas, Qt::Key_A); - QTest::keyRelease(&canvas, Qt::Key_A, Qt::NoModifier ,10); - QTest::qWait(50); - QTRY_COMPARE(strInput->text(), QLatin1String("aa")); - QCOMPARE(strInput->hasAcceptableInput(), true); - QCOMPARE(strInput->property("acceptable").toBool(), true); - QCOMPARE(strSpy.count(), 1); - QTest::keyPress(&canvas, Qt::Key_A); - QTest::keyRelease(&canvas, Qt::Key_A, Qt::NoModifier ,10); - QTest::qWait(50); - QTRY_COMPARE(strInput->text(), QLatin1String("aaa")); - QCOMPARE(strInput->hasAcceptableInput(), true); - QCOMPARE(strInput->property("acceptable").toBool(), true); - QCOMPARE(strSpy.count(), 1); - QTest::keyPress(&canvas, Qt::Key_A); - QTest::keyRelease(&canvas, Qt::Key_A, Qt::NoModifier ,10); - QTest::qWait(50); - QTRY_COMPARE(strInput->text(), QLatin1String("aaaa")); - QCOMPARE(strInput->hasAcceptableInput(), true); - QCOMPARE(strInput->property("acceptable").toBool(), true); - QCOMPARE(strSpy.count(), 1); - QTest::keyPress(&canvas, Qt::Key_A); - QTest::keyRelease(&canvas, Qt::Key_A, Qt::NoModifier ,10); - QTest::qWait(50); - QTRY_COMPARE(strInput->text(), QLatin1String("aaaa")); - QCOMPARE(strInput->hasAcceptableInput(), true); - QCOMPARE(strInput->property("acceptable").toBool(), true); - QCOMPARE(strSpy.count(), 1); - - QQuickTextInput *unvalidatedInput = qobject_cast(qvariant_cast(canvas.rootObject()->property("unvalidatedInput"))); - QVERIFY(unvalidatedInput); - QSignalSpy unvalidatedSpy(unvalidatedInput, SIGNAL(acceptableInputChanged())); - unvalidatedInput->setFocus(true); - QVERIFY(unvalidatedInput->hasActiveFocus() == true); - QCOMPARE(unvalidatedInput->hasAcceptableInput(), true); - QCOMPARE(unvalidatedInput->property("acceptable").toBool(), true); - QTest::keyPress(&canvas, Qt::Key_1); - QTest::keyRelease(&canvas, Qt::Key_1, Qt::NoModifier ,10); - QTest::qWait(50); - QTRY_COMPARE(unvalidatedInput->text(), QLatin1String("1")); - QCOMPARE(unvalidatedInput->hasAcceptableInput(), true); - QCOMPARE(unvalidatedInput->property("acceptable").toBool(), true); - QCOMPARE(unvalidatedSpy.count(), 0); - QTest::keyPress(&canvas, Qt::Key_A); - QTest::keyRelease(&canvas, Qt::Key_A, Qt::NoModifier ,10); - QTest::qWait(50); - QTRY_COMPARE(unvalidatedInput->text(), QLatin1String("1a")); - QCOMPARE(unvalidatedInput->hasAcceptableInput(), true); - QCOMPARE(unvalidatedInput->property("acceptable").toBool(), true); - QCOMPARE(unvalidatedSpy.count(), 0); -} - -void tst_qquicktextinput::inputMethods() -{ - QQuickView canvas(testFileUrl("inputmethods.qml")); - canvas.show(); - canvas.requestActivateWindow(); - QTest::qWaitForWindowShown(&canvas); - - // test input method hints - QVERIFY(canvas.rootObject() != 0); - QQuickTextInput *input = qobject_cast(canvas.rootObject()); - QVERIFY(input != 0); - QVERIFY(input->inputMethodHints() & Qt::ImhNoPredictiveText); - QSignalSpy inputMethodHintSpy(input, SIGNAL(inputMethodHintsChanged())); - input->setInputMethodHints(Qt::ImhUppercaseOnly); - QVERIFY(input->inputMethodHints() & Qt::ImhUppercaseOnly); - QCOMPARE(inputMethodHintSpy.count(), 1); - input->setInputMethodHints(Qt::ImhUppercaseOnly); - QCOMPARE(inputMethodHintSpy.count(), 1); - - // default value - QQuickTextInput plainInput; - QCOMPARE(plainInput.inputMethodHints(), Qt::ImhNone); - - input->setFocus(true); - QVERIFY(input->hasActiveFocus() == true); - // test that input method event is committed - QInputMethodEvent event; - event.setCommitString( "My ", -12, 0); - QTRY_COMPARE(qGuiApp->focusObject(), input); - QGuiApplication::sendEvent(qGuiApp->focusObject(), &event); - QCOMPARE(input->text(), QString("My Hello world!")); - - input->setCursorPosition(2); - event.setCommitString("Your", -2, 2); - QGuiApplication::sendEvent(qGuiApp->focusObject(), &event); - QCOMPARE(input->text(), QString("Your Hello world!")); - QCOMPARE(input->cursorPosition(), 4); - - input->setCursorPosition(7); - event.setCommitString("Goodbye", -2, 5); - QGuiApplication::sendEvent(qGuiApp->focusObject(), &event); - QCOMPARE(input->text(), QString("Your Goodbye world!")); - QCOMPARE(input->cursorPosition(), 12); - - input->setCursorPosition(8); - event.setCommitString("Our", -8, 4); - QGuiApplication::sendEvent(qGuiApp->focusObject(), &event); - QCOMPARE(input->text(), QString("Our Goodbye world!")); - QCOMPARE(input->cursorPosition(), 7); - - // test that basic tentative commit gets to text property on preedit state - input->setText(""); - QList attributes; - QInputMethodEvent preeditEvent("test", attributes); - preeditEvent.setTentativeCommitString("test"); - QGuiApplication::sendEvent(input, &preeditEvent); - QCOMPARE(input->text(), QString("test")); - - // tentative commit not allowed present in surrounding text - QInputMethodQueryEvent queryEvent(Qt::ImSurroundingText); - QGuiApplication::sendEvent(input, &queryEvent); - QCOMPARE(queryEvent.value(Qt::ImSurroundingText).toString(), QString("")); - - // if text with tentative commit does not validate, not allowed to be part of text property - input->setText(""); // ensure input state is reset - QValidator *validator = new QIntValidator(0, 100); - input->setValidator(validator); - QGuiApplication::sendEvent(input, &preeditEvent); - QCOMPARE(input->text(), QString("")); - input->setValidator(0); - delete validator; - - // input should reset selection even if replacement parameters are out of bounds - input->setText("text"); - input->setCursorPosition(0); - input->moveCursorSelection(input->text().length()); - event.setCommitString("replacement", -input->text().length(), input->text().length()); - QGuiApplication::sendEvent(qGuiApp->focusObject(), &event); - QCOMPARE(input->selectionStart(), input->selectionEnd()); - - QInputMethodQueryEvent enabledQueryEvent(Qt::ImEnabled); - QGuiApplication::sendEvent(input, &enabledQueryEvent); - QCOMPARE(enabledQueryEvent.value(Qt::ImEnabled).toBool(), true); - - input->setReadOnly(true); - QGuiApplication::sendEvent(input, &enabledQueryEvent); - QCOMPARE(enabledQueryEvent.value(Qt::ImEnabled).toBool(), false); -} - -/* -TextInput element should only handle left/right keys until the cursor reaches -the extent of the text, then they should ignore the keys. - -*/ -void tst_qquicktextinput::navigation() -{ - QQuickView canvas(testFileUrl("navigation.qml")); - canvas.show(); - canvas.requestActivateWindow(); - - QVERIFY(canvas.rootObject() != 0); - - QQuickTextInput *input = qobject_cast(qvariant_cast(canvas.rootObject()->property("myInput"))); - - QVERIFY(input != 0); - input->setCursorPosition(0); - QTRY_VERIFY(input->hasActiveFocus() == true); - simulateKey(&canvas, Qt::Key_Left); - QVERIFY(input->hasActiveFocus() == false); - simulateKey(&canvas, Qt::Key_Right); - QVERIFY(input->hasActiveFocus() == true); - //QT-2944: If text is selected, ensure we deselect upon cursor motion - input->setCursorPosition(input->text().length()); - input->select(0,input->text().length()); - QVERIFY(input->selectionStart() != input->selectionEnd()); - simulateKey(&canvas, Qt::Key_Right); - QVERIFY(input->selectionStart() == input->selectionEnd()); - QVERIFY(input->selectionStart() == input->text().length()); - QVERIFY(input->hasActiveFocus() == true); - simulateKey(&canvas, Qt::Key_Right); - QVERIFY(input->hasActiveFocus() == false); - simulateKey(&canvas, Qt::Key_Left); - QVERIFY(input->hasActiveFocus() == true); - - // Up and Down should NOT do Home/End, even on Mac OS X (QTBUG-10438). - input->setCursorPosition(2); - QCOMPARE(input->cursorPosition(),2); - simulateKey(&canvas, Qt::Key_Up); - QCOMPARE(input->cursorPosition(),2); - simulateKey(&canvas, Qt::Key_Down); - QCOMPARE(input->cursorPosition(),2); -} - -void tst_qquicktextinput::navigation_RTL() -{ - QQuickView canvas(testFileUrl("navigation.qml")); - canvas.show(); - canvas.requestActivateWindow(); - - QVERIFY(canvas.rootObject() != 0); - - QQuickTextInput *input = qobject_cast(qvariant_cast(canvas.rootObject()->property("myInput"))); - - QVERIFY(input != 0); - const quint16 arabic_str[] = { 0x0638, 0x0643, 0x00646, 0x0647, 0x0633, 0x0638, 0x0643, 0x00646, 0x0647, 0x0633, 0x0647}; - input->setText(QString::fromUtf16(arabic_str, 11)); - - input->setCursorPosition(0); - QTRY_VERIFY(input->hasActiveFocus() == true); - - // move off - simulateKey(&canvas, Qt::Key_Right); - QVERIFY(input->hasActiveFocus() == false); - - // move back - simulateKey(&canvas, Qt::Key_Left); - QVERIFY(input->hasActiveFocus() == true); - - input->setCursorPosition(input->text().length()); - QVERIFY(input->hasActiveFocus() == true); - - // move off - simulateKey(&canvas, Qt::Key_Left); - QVERIFY(input->hasActiveFocus() == false); - - // move back - simulateKey(&canvas, Qt::Key_Right); - QVERIFY(input->hasActiveFocus() == true); -} - -void tst_qquicktextinput::copyAndPaste() { -#ifndef QT_NO_CLIPBOARD - -#ifdef Q_OS_MAC - { - PasteboardRef pasteboard; - OSStatus status = PasteboardCreate(0, &pasteboard); - if (status == noErr) - CFRelease(pasteboard); - else - QSKIP("This machine doesn't support the clipboard"); - } -#endif - - QString componentStr = "import QtQuick 2.0\nTextInput { text: \"Hello world!\" }"; - QDeclarativeComponent textInputComponent(&engine); - textInputComponent.setData(componentStr.toLatin1(), QUrl()); - QQuickTextInput *textInput = qobject_cast(textInputComponent.create()); - QVERIFY(textInput != 0); - - // copy and paste - QCOMPARE(textInput->text().length(), 12); - textInput->select(0, textInput->text().length());; - textInput->copy(); - QCOMPARE(textInput->selectedText(), QString("Hello world!")); - QCOMPARE(textInput->selectedText().length(), 12); - textInput->setCursorPosition(0); - QVERIFY(textInput->canPaste()); - textInput->paste(); - QCOMPARE(textInput->text(), QString("Hello world!Hello world!")); - QCOMPARE(textInput->text().length(), 24); - - // can paste - QVERIFY(textInput->canPaste()); - textInput->setReadOnly(true); - QVERIFY(!textInput->canPaste()); - textInput->setReadOnly(false); - QVERIFY(textInput->canPaste()); - - // select word - textInput->setCursorPosition(0); - textInput->selectWord(); - QCOMPARE(textInput->selectedText(), QString("Hello")); - - // select all and cut - textInput->selectAll(); - textInput->cut(); - QCOMPARE(textInput->text().length(), 0); - textInput->paste(); - QCOMPARE(textInput->text(), QString("Hello world!Hello world!")); - QCOMPARE(textInput->text().length(), 24); - - // clear copy buffer - QClipboard *clipboard = QGuiApplication::clipboard(); - QVERIFY(clipboard); - clipboard->clear(); - QVERIFY(!textInput->canPaste()); - - // test that copy functionality is disabled - // when echo mode is set to hide text/password mode - int index = 0; - while (index < 4) { - QQuickTextInput::EchoMode echoMode = QQuickTextInput::EchoMode(index); - textInput->setEchoMode(echoMode); - textInput->setText("My password"); - textInput->select(0, textInput->text().length());; - textInput->copy(); - if (echoMode == QQuickTextInput::Normal) { - QVERIFY(!clipboard->text().isEmpty()); - QCOMPARE(clipboard->text(), QString("My password")); - clipboard->clear(); - } else { - QVERIFY(clipboard->text().isEmpty()); - } - index++; - } - - delete textInput; -#endif -} - -void tst_qquicktextinput::copyAndPasteKeySequence() { -#ifndef QT_NO_CLIPBOARD - -#ifdef Q_OS_MAC - { - PasteboardRef pasteboard; - OSStatus status = PasteboardCreate(0, &pasteboard); - if (status == noErr) - CFRelease(pasteboard); - else - QSKIP("This machine doesn't support the clipboard"); - } -#endif - - QString componentStr = "import QtQuick 2.0\nTextInput { text: \"Hello world!\"; focus: true }"; - QDeclarativeComponent textInputComponent(&engine); - textInputComponent.setData(componentStr.toLatin1(), QUrl()); - QQuickTextInput *textInput = qobject_cast(textInputComponent.create()); - QVERIFY(textInput != 0); - - QQuickCanvas canvas; - textInput->setParentItem(canvas.rootItem()); - canvas.show(); - canvas.requestActivateWindow(); - QTest::qWaitForWindowShown(&canvas); - QTRY_COMPARE(QGuiApplication::activeWindow(), &canvas); - - // copy and paste - QVERIFY(textInput->hasActiveFocus()); - QCOMPARE(textInput->text().length(), 12); - textInput->select(0, textInput->text().length()); - simulateKeys(&canvas, QKeySequence::Copy); - QCOMPARE(textInput->selectedText(), QString("Hello world!")); - QCOMPARE(textInput->selectedText().length(), 12); - textInput->setCursorPosition(0); - QVERIFY(textInput->canPaste()); - simulateKeys(&canvas, QKeySequence::Paste); - QCOMPARE(textInput->text(), QString("Hello world!Hello world!")); - QCOMPARE(textInput->text().length(), 24); - - // select all and cut - simulateKeys(&canvas, QKeySequence::SelectAll); - simulateKeys(&canvas, QKeySequence::Cut); - QCOMPARE(textInput->text().length(), 0); - simulateKeys(&canvas, QKeySequence::Paste); - QCOMPARE(textInput->text(), QString("Hello world!Hello world!")); - QCOMPARE(textInput->text().length(), 24); - - // clear copy buffer - QClipboard *clipboard = QGuiApplication::clipboard(); - QVERIFY(clipboard); - clipboard->clear(); - QVERIFY(!textInput->canPaste()); - - // test that copy functionality is disabled - // when echo mode is set to hide text/password mode - int index = 0; - while (index < 4) { - QQuickTextInput::EchoMode echoMode = QQuickTextInput::EchoMode(index); - textInput->setEchoMode(echoMode); - textInput->setText("My password"); - textInput->select(0, textInput->text().length());; - simulateKeys(&canvas, QKeySequence::Copy); - if (echoMode == QQuickTextInput::Normal) { - QVERIFY(!clipboard->text().isEmpty()); - QCOMPARE(clipboard->text(), QString("My password")); - clipboard->clear(); - } else { - QVERIFY(clipboard->text().isEmpty()); - } - index++; - } - - delete textInput; -#endif -} - -void tst_qquicktextinput::canPasteEmpty() { -#ifndef QT_NO_CLIPBOARD - - QGuiApplication::clipboard()->clear(); - - QString componentStr = "import QtQuick 2.0\nTextInput { text: \"Hello world!\" }"; - QDeclarativeComponent textInputComponent(&engine); - textInputComponent.setData(componentStr.toLatin1(), QUrl()); - QQuickTextInput *textInput = qobject_cast(textInputComponent.create()); - QVERIFY(textInput != 0); - - bool cp = !textInput->isReadOnly() && QGuiApplication::clipboard()->text().length() != 0; - QCOMPARE(textInput->canPaste(), cp); - -#endif -} - -void tst_qquicktextinput::canPaste() { -#ifndef QT_NO_CLIPBOARD - - QGuiApplication::clipboard()->setText("Some text"); - - QString componentStr = "import QtQuick 2.0\nTextInput { text: \"Hello world!\" }"; - QDeclarativeComponent textInputComponent(&engine); - textInputComponent.setData(componentStr.toLatin1(), QUrl()); - QQuickTextInput *textInput = qobject_cast(textInputComponent.create()); - QVERIFY(textInput != 0); - - bool cp = !textInput->isReadOnly() && QGuiApplication::clipboard()->text().length() != 0; - QCOMPARE(textInput->canPaste(), cp); - -#endif -} - -void tst_qquicktextinput::passwordCharacter() -{ - QString componentStr = "import QtQuick 2.0\nTextInput { text: \"Hello world!\"; font.family: \"Helvetica\"; echoMode: TextInput.Password }"; - QDeclarativeComponent textInputComponent(&engine); - textInputComponent.setData(componentStr.toLatin1(), QUrl()); - QQuickTextInput *textInput = qobject_cast(textInputComponent.create()); - QVERIFY(textInput != 0); - - textInput->setPasswordCharacter("X"); - qreal implicitWidth = textInput->implicitWidth(); - textInput->setPasswordCharacter("."); - - // QTBUG-12383 content is updated and redrawn - QVERIFY(textInput->implicitWidth() < implicitWidth); - - delete textInput; -} - -void tst_qquicktextinput::cursorDelegate_data() -{ - QTest::addColumn("source"); - QTest::newRow("out of line") << testFileUrl("cursorTest.qml"); - QTest::newRow("in line") << testFileUrl("cursorTestInline.qml"); - QTest::newRow("external") << testFileUrl("cursorTestExternal.qml"); -} - -void tst_qquicktextinput::cursorDelegate() -{ - QFETCH(QUrl, source); - QQuickView view(source); - view.show(); - view.requestActivateWindow(); - QQuickTextInput *textInputObject = view.rootObject()->findChild("textInputObject"); - QVERIFY(textInputObject != 0); - QVERIFY(textInputObject->findChild("cursorInstance")); - //Test Delegate gets created - textInputObject->setFocus(true); - QQuickItem* delegateObject = textInputObject->findChild("cursorInstance"); - QVERIFY(delegateObject); - QCOMPARE(delegateObject->property("localProperty").toString(), QString("Hello")); - //Test Delegate gets moved - for (int i=0; i<= textInputObject->text().length(); i++) { - textInputObject->setCursorPosition(i); - QCOMPARE(textInputObject->cursorRectangle().x(), qRound(delegateObject->x())); - QCOMPARE(textInputObject->cursorRectangle().y(), qRound(delegateObject->y())); - } - textInputObject->setCursorPosition(0); - QCOMPARE(textInputObject->cursorRectangle().x(), qRound(delegateObject->x())); - QCOMPARE(textInputObject->cursorRectangle().y(), qRound(delegateObject->y())); - //Test Delegate gets deleted - textInputObject->setCursorDelegate(0); - QVERIFY(!textInputObject->findChild("cursorInstance")); -} - -void tst_qquicktextinput::cursorVisible() -{ - QQuickView view(testFileUrl("cursorVisible.qml")); - view.show(); - view.requestActivateWindow(); - QTest::qWaitForWindowShown(&view); - QTRY_COMPARE(&view, qGuiApp->focusWindow()); - - QQuickTextInput input; - input.componentComplete(); - QSignalSpy spy(&input, SIGNAL(cursorVisibleChanged(bool))); - - QCOMPARE(input.isCursorVisible(), false); - - input.setCursorVisible(true); - QCOMPARE(input.isCursorVisible(), true); - QCOMPARE(spy.count(), 1); - - input.setCursorVisible(false); - QCOMPARE(input.isCursorVisible(), false); - QCOMPARE(spy.count(), 2); - - input.setFocus(true); - QCOMPARE(input.isCursorVisible(), false); - QCOMPARE(spy.count(), 2); - - input.setParentItem(view.rootObject()); - QCOMPARE(input.isCursorVisible(), true); - QCOMPARE(spy.count(), 3); - - input.setFocus(false); - QCOMPARE(input.isCursorVisible(), false); - QCOMPARE(spy.count(), 4); - - input.setFocus(true); - QCOMPARE(input.isCursorVisible(), true); - QCOMPARE(spy.count(), 5); - - QQuickView alternateView; - alternateView.show(); - alternateView.requestActivateWindow(); - QTest::qWaitForWindowShown(&alternateView); - - QCOMPARE(input.isCursorVisible(), false); - QCOMPARE(spy.count(), 6); - - view.requestActivateWindow(); - QTest::qWaitForWindowShown(&view); - QCOMPARE(input.isCursorVisible(), true); - QCOMPARE(spy.count(), 7); -} - -static QRect round(const QRectF &r) { - return QRect(qRound(r.left()), qRound(r.top()), qCeil(r.width()), qCeil(r.height())); } - -void tst_qquicktextinput::cursorRectangle() -{ - - QString text = "Hello World!"; - - QQuickTextInput input; - input.setText(text); - input.componentComplete(); - - QTextLayout layout(text); - layout.setFont(input.font()); - if (!qmlDisableDistanceField()) { - QTextOption option; - option.setUseDesignMetrics(true); - layout.setTextOption(option); - } - layout.beginLayout(); - QTextLine line = layout.createLine(); - layout.endLayout(); - - input.setWidth(line.cursorToX(5, QTextLine::Leading)); - input.setHeight(qCeil(line.height() * 3 / 2)); - - QRect r; - - // some tolerance for different fonts. -#ifdef Q_OS_LINUX - const int error = 2; -#else - const int error = 5; -#endif - - for (int i = 0; i <= 5; ++i) { - input.setCursorPosition(i); - r = input.cursorRectangle(); - - QVERIFY(r.left() < qCeil(line.cursorToX(i, QTextLine::Trailing))); - QVERIFY(r.right() >= qFloor(line.cursorToX(i , QTextLine::Leading))); - QCOMPARE(input.inputMethodQuery(Qt::ImCursorRectangle).toRect(), r); - QCOMPARE(round(input.positionToRectangle(i)), r); - } - - // Check the cursor rectangle remains within the input bounding rect when auto scrolling. - QVERIFY(r.left() < input.width()); - QVERIFY(r.right() >= input.width() - error); - - for (int i = 6; i < text.length(); ++i) { - input.setCursorPosition(i); - QCOMPARE(r, input.cursorRectangle()); - QCOMPARE(input.inputMethodQuery(Qt::ImCursorRectangle).toRect(), r); - QCOMPARE(round(input.positionToRectangle(i)), r); - } - - for (int i = text.length() - 2; i >= 0; --i) { - input.setCursorPosition(i); - r = input.cursorRectangle(); - QCOMPARE(r.top(), 0); - QVERIFY(r.right() >= 0); - QCOMPARE(input.inputMethodQuery(Qt::ImCursorRectangle).toRect(), r); - QCOMPARE(round(input.positionToRectangle(i)), r); - } - - // Check position with word wrap. - input.setWrapMode(QQuickTextInput::WordWrap); - input.setAutoScroll(false); - for (int i = 0; i <= 5; ++i) { - input.setCursorPosition(i); - r = input.cursorRectangle(); - - QVERIFY(r.left() < qCeil(line.cursorToX(i, QTextLine::Trailing))); - QVERIFY(r.right() >= qFloor(line.cursorToX(i , QTextLine::Leading))); - QCOMPARE(r.top(), 0); - QCOMPARE(input.inputMethodQuery(Qt::ImCursorRectangle).toRect(), r); - QCOMPARE(round(input.positionToRectangle(i)), r); - } - - input.setCursorPosition(6); - r = input.cursorRectangle(); - QCOMPARE(r.left(), 0); - QVERIFY(r.top() > line.height() - error); - QCOMPARE(input.inputMethodQuery(Qt::ImCursorRectangle).toRect(), r); - QCOMPARE(round(input.positionToRectangle(6)), r); - - for (int i = 7; i < text.length(); ++i) { - input.setCursorPosition(i); - r = input.cursorRectangle(); - QVERIFY(r.top() > line.height() - error); - QCOMPARE(input.inputMethodQuery(Qt::ImCursorRectangle).toRect(), r); - QCOMPARE(round(input.positionToRectangle(i)), r); - } - - // Check vertical scrolling with word wrap. - input.setAutoScroll(true); - for (int i = 0; i <= 5; ++i) { - input.setCursorPosition(i); - r = input.cursorRectangle(); - - QVERIFY(r.left() < qCeil(line.cursorToX(i, QTextLine::Trailing))); - QVERIFY(r.right() >= qFloor(line.cursorToX(i , QTextLine::Leading))); - QCOMPARE(r.top(), 0); - QCOMPARE(input.inputMethodQuery(Qt::ImCursorRectangle).toRect(), r); - QCOMPARE(round(round(input.positionToRectangle(i))), r); - } - - input.setCursorPosition(6); - r = input.cursorRectangle(); - QCOMPARE(r.left(), 0); - QVERIFY(r.bottom() >= input.height() - error); - QCOMPARE(input.inputMethodQuery(Qt::ImCursorRectangle).toRect(), r); - QCOMPARE(round(input.positionToRectangle(6)), r); - - for (int i = 7; i < text.length(); ++i) { - input.setCursorPosition(i); - r = input.cursorRectangle(); - QVERIFY(r.bottom() >= input.height() - error); - QCOMPARE(input.inputMethodQuery(Qt::ImCursorRectangle).toRect(), r); - QCOMPARE(round(input.positionToRectangle(i)), r); - } - - for (int i = text.length() - 2; i >= 6; --i) { - input.setCursorPosition(i); - r = input.cursorRectangle(); - QVERIFY(r.bottom() >= input.height() - error); - QCOMPARE(input.inputMethodQuery(Qt::ImCursorRectangle).toRect(), r); - QCOMPARE(round(input.positionToRectangle(i)), r); - } - - for (int i = 5; i >= 0; --i) { - input.setCursorPosition(i); - r = input.cursorRectangle(); - QCOMPARE(r.top(), 0); - QCOMPARE(input.inputMethodQuery(Qt::ImCursorRectangle).toRect(), r); - QCOMPARE(round(input.positionToRectangle(i)), r); - } - - input.setText("Hi!"); - input.setHAlign(QQuickTextInput::AlignRight); - r = input.cursorRectangle(); - QVERIFY(r.left() < input.width() + error); - QVERIFY(r.right() >= input.width() - error); -} - -void tst_qquicktextinput::readOnly() -{ - QQuickView canvas(testFileUrl("readOnly.qml")); - canvas.show(); - canvas.requestActivateWindow(); - - QVERIFY(canvas.rootObject() != 0); - - QQuickTextInput *input = qobject_cast(qvariant_cast(canvas.rootObject()->property("myInput"))); - - QVERIFY(input != 0); - QTRY_VERIFY(input->hasActiveFocus() == true); - QVERIFY(input->isReadOnly() == true); - QString initial = input->text(); - for (int k=Qt::Key_0; k<=Qt::Key_Z; k++) - simulateKey(&canvas, k); - simulateKey(&canvas, Qt::Key_Return); - simulateKey(&canvas, Qt::Key_Space); - simulateKey(&canvas, Qt::Key_Escape); - QCOMPARE(input->text(), initial); - - input->setCursorPosition(3); - input->setReadOnly(false); - QCOMPARE(input->isReadOnly(), false); - QCOMPARE(input->cursorPosition(), input->text().length()); -} - -void tst_qquicktextinput::echoMode() -{ - QQuickView canvas(testFileUrl("echoMode.qml")); - canvas.show(); - canvas.requestActivateWindow(); - QTest::qWaitForWindowShown(&canvas); - QTRY_COMPARE(&canvas, qGuiApp->focusWindow()); - - QVERIFY(canvas.rootObject() != 0); - - QQuickTextInput *input = qobject_cast(qvariant_cast(canvas.rootObject()->property("myInput"))); - - QVERIFY(input != 0); - QTRY_VERIFY(input->hasActiveFocus() == true); - QString initial = input->text(); - Qt::InputMethodHints ref; - QCOMPARE(initial, QLatin1String("ABCDefgh")); - QCOMPARE(input->echoMode(), QQuickTextInput::Normal); - QCOMPARE(input->displayText(), input->text()); - //Normal - ref &= ~Qt::ImhHiddenText; - ref &= ~(Qt::ImhNoAutoUppercase | Qt::ImhNoPredictiveText | Qt::ImhSensitiveData); - QCOMPARE((Qt::InputMethodHints) input->inputMethodQuery(Qt::ImHints).toInt(), ref); - input->setEchoMode(QQuickTextInput::NoEcho); - QCOMPARE(input->text(), initial); - QCOMPARE(input->displayText(), QLatin1String("")); - QCOMPARE(input->passwordCharacter(), QLatin1String("*")); - //NoEcho - ref |= Qt::ImhHiddenText; - ref |= (Qt::ImhNoAutoUppercase | Qt::ImhNoPredictiveText | Qt::ImhSensitiveData); - QCOMPARE((Qt::InputMethodHints) input->inputMethodQuery(Qt::ImHints).toInt(), ref); - input->setEchoMode(QQuickTextInput::Password); - //Password - ref |= Qt::ImhHiddenText; - ref |= (Qt::ImhNoAutoUppercase | Qt::ImhNoPredictiveText | Qt::ImhSensitiveData); - QCOMPARE(input->text(), initial); - QCOMPARE(input->displayText(), QLatin1String("********")); - QCOMPARE((Qt::InputMethodHints) input->inputMethodQuery(Qt::ImHints).toInt(), ref); - // clearing input hints do not clear bits set by echo mode - input->setInputMethodHints(Qt::ImhNone); - QCOMPARE((Qt::InputMethodHints) input->inputMethodQuery(Qt::ImHints).toInt(), ref); - input->setPasswordCharacter(QChar('Q')); - QCOMPARE(input->passwordCharacter(), QLatin1String("Q")); - QCOMPARE(input->text(), initial); - QCOMPARE(input->displayText(), QLatin1String("QQQQQQQQ")); - input->setEchoMode(QQuickTextInput::PasswordEchoOnEdit); - //PasswordEchoOnEdit - ref &= ~Qt::ImhHiddenText; - ref |= (Qt::ImhNoAutoUppercase | Qt::ImhNoPredictiveText | Qt::ImhSensitiveData); - QCOMPARE((Qt::InputMethodHints) input->inputMethodQuery(Qt::ImHints).toInt(), ref); - QCOMPARE(input->text(), initial); - QCOMPARE(input->displayText(), QLatin1String("QQQQQQQQ")); - QCOMPARE(input->inputMethodQuery(Qt::ImSurroundingText).toString(), QLatin1String("QQQQQQQQ")); - QTest::keyPress(&canvas, Qt::Key_A);//Clearing previous entry is part of PasswordEchoOnEdit - QTest::keyRelease(&canvas, Qt::Key_A, Qt::NoModifier ,10); - QCOMPARE(input->text(), QLatin1String("a")); - QCOMPARE(input->displayText(), QLatin1String("a")); - QCOMPARE(input->inputMethodQuery(Qt::ImSurroundingText).toString(), QLatin1String("a")); - input->setFocus(false); - QVERIFY(input->hasActiveFocus() == false); - QCOMPARE(input->displayText(), QLatin1String("Q")); - QCOMPARE(input->inputMethodQuery(Qt::ImSurroundingText).toString(), QLatin1String("Q")); - input->setFocus(true); - QVERIFY(input->hasActiveFocus()); - QInputMethodEvent inputEvent; - inputEvent.setCommitString(initial); - QGuiApplication::sendEvent(input, &inputEvent); - QCOMPARE(input->text(), initial); - QCOMPARE(input->displayText(), initial); - QCOMPARE(input->inputMethodQuery(Qt::ImSurroundingText).toString(), initial); -} - -#ifdef QT_GUI_PASSWORD_ECHO_DELAY -void tst_qquicktextinput::passwordEchoDelay() -{ - QQuickView canvas(testFileUrl("echoMode.qml")); - canvas.show(); - canvas.requestActivateWindow(); - QTest::qWaitForWindowShown(&canvas); - QTRY_COMPARE(&canvas, qGuiApp->focusWindow()); - - QVERIFY(canvas.rootObject() != 0); - - QQuickTextInput *input = qobject_cast(qvariant_cast(canvas.rootObject()->property("myInput"))); - - QChar fillChar = QLatin1Char('*'); - - input->setEchoMode(QQuickTextInput::Password); - QCOMPARE(input->displayText(), QString(8, fillChar)); - input->setText(QString()); - QCOMPARE(input->displayText(), QString()); - - QTest::keyPress(&canvas, '0'); - QTest::keyPress(&canvas, '1'); - QTest::keyPress(&canvas, '2'); - QCOMPARE(input->displayText(), QString(2, fillChar) + QLatin1Char('2')); - QTest::keyPress(&canvas, '3'); - QTest::keyPress(&canvas, '4'); - QCOMPARE(input->displayText(), QString(4, fillChar) + QLatin1Char('4')); - QTest::keyPress(&canvas, Qt::Key_Backspace); - QCOMPARE(input->displayText(), QString(4, fillChar)); - QTest::keyPress(&canvas, '4'); - QCOMPARE(input->displayText(), QString(4, fillChar) + QLatin1Char('4')); - QTest::qWait(QT_GUI_PASSWORD_ECHO_DELAY); - QTRY_COMPARE(input->displayText(), QString(5, fillChar)); - QTest::keyPress(&canvas, '5'); - QCOMPARE(input->displayText(), QString(5, fillChar) + QLatin1Char('5')); - input->setFocus(false); - QVERIFY(!input->hasFocus()); - QCOMPARE(input->displayText(), QString(6, fillChar)); - input->setFocus(true); - QTRY_VERIFY(input->hasFocus()); - QCOMPARE(input->displayText(), QString(6, fillChar)); - QTest::keyPress(&canvas, '6'); - QCOMPARE(input->displayText(), QString(6, fillChar) + QLatin1Char('6')); - - QInputMethodEvent ev; - ev.setCommitString(QLatin1String("7")); - QGuiApplication::sendEvent(qGuiApp->focusObject(), &ev); - QCOMPARE(input->displayText(), QString(7, fillChar) + QLatin1Char('7')); - - input->setCursorPosition(3); - QCOMPARE(input->displayText(), QString(7, fillChar) + QLatin1Char('7')); - QTest::keyPress(&canvas, 'a'); - QCOMPARE(input->displayText(), QString(3, fillChar) + QLatin1Char('a') + QString(5, fillChar)); - QTest::keyPress(&canvas, Qt::Key_Backspace); - QCOMPARE(input->displayText(), QString(8, fillChar)); -} -#endif - - -void tst_qquicktextinput::simulateKey(QQuickView *view, int key) -{ - QKeyEvent press(QKeyEvent::KeyPress, key, 0); - QKeyEvent release(QKeyEvent::KeyRelease, key, 0); - - QGuiApplication::sendEvent(view, &press); - QGuiApplication::sendEvent(view, &release); -} - - -void tst_qquicktextinput::openInputPanel() -{ - PlatformInputContext platformInputContext; - QInputMethodPrivate *inputMethodPrivate = QInputMethodPrivate::get(qApp->inputMethod()); - inputMethodPrivate->testContext = &platformInputContext; - - QQuickView view(testFileUrl("openInputPanel.qml")); - view.show(); - view.requestActivateWindow(); - QTest::qWaitForWindowShown(&view); - QTRY_COMPARE(&view, qGuiApp->focusWindow()); - - QQuickTextInput *input = qobject_cast(view.rootObject()); - QVERIFY(input); - - // check default values - QVERIFY(input->focusOnPress()); - QVERIFY(!input->hasActiveFocus()); - QVERIFY(qApp->focusObject() != input); - QCOMPARE(qApp->inputMethod()->visible(), false); - - // input panel should open on focus - QPoint centerPoint(view.width()/2, view.height()/2); - Qt::KeyboardModifiers noModifiers = 0; - QTest::mousePress(&view, Qt::LeftButton, noModifiers, centerPoint); - QGuiApplication::processEvents(); - QVERIFY(input->hasActiveFocus()); - QCOMPARE(qApp->focusObject(), input); - QCOMPARE(qApp->inputMethod()->visible(), true); - QTest::mouseRelease(&view, Qt::LeftButton, noModifiers, centerPoint); - - // input panel should be re-opened when pressing already focused TextInput - qApp->inputMethod()->hide(); - QCOMPARE(qApp->inputMethod()->visible(), false); - QVERIFY(input->hasActiveFocus()); - QTest::mousePress(&view, Qt::LeftButton, noModifiers, centerPoint); - QGuiApplication::processEvents(); - QCOMPARE(qApp->inputMethod()->visible(), true); - QTest::mouseRelease(&view, Qt::LeftButton, noModifiers, centerPoint); - - // input panel should stay visible if focus is lost to another text inputor - QSignalSpy inputPanelVisibilitySpy(qApp->inputMethod(), SIGNAL(visibleChanged())); - QQuickTextInput anotherInput; - anotherInput.componentComplete(); - anotherInput.setParentItem(view.rootObject()); - anotherInput.setFocus(true); - QCOMPARE(qApp->inputMethod()->visible(), true); - QCOMPARE(qApp->focusObject(), qobject_cast(&anotherInput)); - QCOMPARE(inputPanelVisibilitySpy.count(), 0); - - anotherInput.setFocus(false); - QVERIFY(qApp->focusObject() != &anotherInput); - QCOMPARE(view.activeFocusItem(), view.rootItem()); - anotherInput.setFocus(true); - - qApp->inputMethod()->hide(); - - // input panel should not be opened if TextInput is read only - input->setReadOnly(true); - input->setFocus(true); - QCOMPARE(qApp->inputMethod()->visible(), false); - QTest::mousePress(&view, Qt::LeftButton, noModifiers, centerPoint); - QTest::mouseRelease(&view, Qt::LeftButton, noModifiers, centerPoint); - QGuiApplication::processEvents(); - QCOMPARE(qApp->inputMethod()->visible(), false); - - // input panel should not be opened if focusOnPress is set to false - input->setFocusOnPress(false); - input->setFocus(false); - input->setFocus(true); - QCOMPARE(qApp->inputMethod()->visible(), false); - QTest::mousePress(&view, Qt::LeftButton, noModifiers, centerPoint); - QTest::mouseRelease(&view, Qt::LeftButton, noModifiers, centerPoint); - QCOMPARE(qApp->inputMethod()->visible(), false); - - // input panel should open when openSoftwareInputPanel is called - input->openSoftwareInputPanel(); - QCOMPARE(qApp->inputMethod()->visible(), true); - - // input panel should close when closeSoftwareInputPanel is called - input->closeSoftwareInputPanel(); - QCOMPARE(qApp->inputMethod()->visible(), false); -} - -class MyTextInput : public QQuickTextInput -{ -public: - MyTextInput(QQuickItem *parent = 0) : QQuickTextInput(parent) - { - nbPaint = 0; - } - virtual QSGNode *updatePaintNode(QSGNode *node, UpdatePaintNodeData *data) - { - nbPaint++; - return QQuickTextInput::updatePaintNode(node, data); - } - int nbPaint; -}; - -void tst_qquicktextinput::setHAlignClearCache() -{ - QQuickView view; - MyTextInput input; - input.setText("Hello world"); - input.setParentItem(view.rootItem()); - view.show(); - view.requestActivateWindow(); - QTest::qWaitForWindowShown(&view); -#ifdef Q_OS_MAC - QEXPECT_FAIL("", "QTBUG-23485", Abort); -#endif - QTRY_COMPARE(input.nbPaint, 1); - input.setHAlign(QQuickTextInput::AlignRight); - //Changing the alignment should trigger a repaint - QTRY_COMPARE(input.nbPaint, 2); -} - -void tst_qquicktextinput::focusOutClearSelection() -{ - QQuickView view; - QQuickTextInput input; - QQuickTextInput input2; - input.setText(QLatin1String("Hello world")); - input.setFocus(true); - input2.setParentItem(view.rootItem()); - input.setParentItem(view.rootItem()); - input.componentComplete(); - input2.componentComplete(); - view.show(); - view.requestActivateWindow(); - QTest::qWaitForWindowShown(&view); - input.select(2,5); - //The selection should work - QTRY_COMPARE(input.selectedText(), QLatin1String("llo")); - input2.setFocus(true); - QGuiApplication::processEvents(); - //The input lost the focus selection should be cleared - QTRY_COMPARE(input.selectedText(), QLatin1String("")); -} - -void tst_qquicktextinput::geometrySignals() -{ - QDeclarativeComponent component(&engine, testFileUrl("geometrySignals.qml")); - QObject *o = component.create(); - QVERIFY(o); - QCOMPARE(o->property("bindingWidth").toInt(), 400); - QCOMPARE(o->property("bindingHeight").toInt(), 500); - delete o; -} - -void tst_qquicktextinput::contentSize() -{ - QString componentStr = "import QtQuick 2.0\nTextInput { width: 75; height: 16; font.pixelSize: 10 }"; - QDeclarativeComponent textComponent(&engine); - textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); - QScopedPointer object(textComponent.create()); - QQuickTextInput *textObject = qobject_cast(object.data()); - - QSignalSpy spy(textObject, SIGNAL(contentSizeChanged())); - - textObject->setText("The quick red fox jumped over the lazy brown dog"); - - QVERIFY(textObject->contentWidth() > textObject->width()); - QVERIFY(textObject->contentHeight() < textObject->height()); - QCOMPARE(spy.count(), 1); - - textObject->setWrapMode(QQuickTextInput::WordWrap); - QVERIFY(textObject->contentWidth() <= textObject->width()); - QVERIFY(textObject->contentHeight() > textObject->height()); - QCOMPARE(spy.count(), 2); - - textObject->setText("The quickredfoxjumpedoverthe lazy brown dog"); - - QVERIFY(textObject->contentWidth() > textObject->width()); - QVERIFY(textObject->contentHeight() > textObject->height()); - QCOMPARE(spy.count(), 3); -} - -static void sendPreeditText(const QString &text, int cursor) -{ - QInputMethodEvent event(text, QList() - << QInputMethodEvent::Attribute(QInputMethodEvent::Cursor, cursor, text.length(), QVariant())); - QCoreApplication::sendEvent(qGuiApp->focusObject(), &event); -} - -void tst_qquicktextinput::preeditAutoScroll() -{ - QString preeditText = "califragisiticexpialidocious!"; - - QQuickView view(testFileUrl("preeditAutoScroll.qml")); - view.show(); - view.requestActivateWindow(); - QTest::qWaitForWindowShown(&view); - QTRY_COMPARE(&view, qGuiApp->focusWindow()); - QQuickTextInput *input = qobject_cast(view.rootObject()); - QVERIFY(input); - QVERIFY(input->hasActiveFocus()); - - input->setWidth(input->implicitWidth()); - - QSignalSpy cursorRectangleSpy(input, SIGNAL(cursorRectangleChanged())); - int cursorRectangleChanges = 0; - - // test the text is scrolled so the preedit is visible. - sendPreeditText(preeditText.mid(0, 3), 1); - QVERIFY(evaluate(input, QString("positionAt(0)")) != 0); - QVERIFY(input->cursorRectangle().left() < input->boundingRect().width()); - QCOMPARE(cursorRectangleSpy.count(), ++cursorRectangleChanges); - - // test the text is scrolled back when the preedit is removed. - QInputMethodEvent imEvent; - QCoreApplication::sendEvent(qGuiApp->focusObject(), &imEvent); - QCOMPARE(evaluate(input, QString("positionAt(%1)").arg(0)), 0); - QCOMPARE(evaluate(input, QString("positionAt(%1)").arg(input->width())), 5); - QCOMPARE(cursorRectangleSpy.count(), ++cursorRectangleChanges); - - QTextLayout layout(preeditText); - layout.setFont(input->font()); - if (!qmlDisableDistanceField()) { - QTextOption option; - option.setUseDesignMetrics(true); - layout.setTextOption(option); - } - layout.beginLayout(); - QTextLine line = layout.createLine(); - layout.endLayout(); - - // test if the preedit is larger than the text input that the - // character preceding the cursor is still visible. - qreal x = input->positionToRectangle(0).x(); - for (int i = 0; i < 3; ++i) { - sendPreeditText(preeditText, i + 1); - int width = ceil(line.cursorToX(i, QTextLine::Trailing)) - floor(line.cursorToX(i)); - QVERIFY(input->cursorRectangle().right() >= width - 3); - QVERIFY(input->positionToRectangle(0).x() < x); - QCOMPARE(cursorRectangleSpy.count(), ++cursorRectangleChanges); - x = input->positionToRectangle(0).x(); - } - for (int i = 1; i >= 0; --i) { - sendPreeditText(preeditText, i + 1); - int width = ceil(line.cursorToX(i, QTextLine::Trailing)) - floor(line.cursorToX(i)); - QVERIFY(input->cursorRectangle().right() >= width - 3); - QVERIFY(input->positionToRectangle(0).x() > x); - QCOMPARE(cursorRectangleSpy.count(), ++cursorRectangleChanges); - x = input->positionToRectangle(0).x(); - } - - // Test incrementing the preedit cursor doesn't cause further - // scrolling when right most text is visible. - sendPreeditText(preeditText, preeditText.length() - 3); - QCOMPARE(cursorRectangleSpy.count(), ++cursorRectangleChanges); - x = input->positionToRectangle(0).x(); - for (int i = 2; i >= 0; --i) { - sendPreeditText(preeditText, preeditText.length() - i); - QCOMPARE(input->positionToRectangle(0).x(), x); - QCOMPARE(cursorRectangleSpy.count(), ++cursorRectangleChanges); - } - for (int i = 1; i < 3; ++i) { - sendPreeditText(preeditText, preeditText.length() - i); - QCOMPARE(input->positionToRectangle(0).x(), x); - QCOMPARE(cursorRectangleSpy.count(), ++cursorRectangleChanges); - } - - // Test disabling auto scroll. - QCoreApplication::sendEvent(qGuiApp->focusObject(), &imEvent); - - input->setAutoScroll(false); - sendPreeditText(preeditText.mid(0, 3), 1); - QCOMPARE(evaluate(input, QString("positionAt(%1)").arg(0)), 0); - QCOMPARE(evaluate(input, QString("positionAt(%1)").arg(input->width())), 5); -} - -void tst_qquicktextinput::preeditCursorRectangle() -{ - QString preeditText = "super"; - - QQuickView view(testFileUrl("inputMethodEvent.qml")); - view.show(); - view.requestActivateWindow(); - QTest::qWaitForWindowShown(&view); - QTRY_COMPARE(&view, qGuiApp->focusWindow()); - QQuickTextInput *input = qobject_cast(view.rootObject()); - QVERIFY(input); - - QRect currentRect; - - QInputMethodQueryEvent query(Qt::ImCursorRectangle); - QCoreApplication::sendEvent(qGuiApp->focusObject(), &query); - QRect previousRect = query.value(Qt::ImCursorRectangle).toRect(); - - // Verify that the micro focus rect is positioned the same for position 0 as - // it would be if there was no preedit text. - sendPreeditText(preeditText, 0); - QCoreApplication::sendEvent(qGuiApp->focusObject(), &query); - currentRect = query.value(Qt::ImCursorRectangle).toRect(); - QCOMPARE(currentRect, previousRect); - - QSignalSpy inputSpy(input, SIGNAL(cursorRectangleChanged())); - QSignalSpy panelSpy(qGuiApp->inputMethod(), SIGNAL(cursorRectangleChanged())); - - // Verify that the micro focus rect moves to the left as the cursor position - // is incremented. - for (int i = 1; i <= 5; ++i) { - sendPreeditText(preeditText, i); - QCoreApplication::sendEvent(qGuiApp->focusObject(), &query); - currentRect = query.value(Qt::ImCursorRectangle).toRect(); - QVERIFY(previousRect.left() < currentRect.left()); - QVERIFY(inputSpy.count() > 0); inputSpy.clear(); - QVERIFY(panelSpy.count() > 0); panelSpy.clear(); - previousRect = currentRect; - } - - // Verify that if there is no preedit cursor then the micro focus rect is the - // same as it would be if it were positioned at the end of the preedit text. - sendPreeditText(preeditText, 0); - QInputMethodEvent imEvent(preeditText, QList()); - QCoreApplication::sendEvent(qGuiApp->focusObject(), &imEvent); - QCoreApplication::sendEvent(qGuiApp->focusObject(), &query); - currentRect = query.value(Qt::ImCursorRectangle).toRect(); - QCOMPARE(currentRect, previousRect); - QVERIFY(inputSpy.count() > 0); - QVERIFY(panelSpy.count() > 0); -} - -void tst_qquicktextinput::inputContextMouseHandler() -{ - PlatformInputContext platformInputContext; - QInputMethodPrivate *inputMethodPrivate = QInputMethodPrivate::get(qApp->inputMethod()); - inputMethodPrivate->testContext = &platformInputContext; - - QString text = "supercalifragisiticexpialidocious!"; - QQuickView view(testFileUrl("inputContext.qml")); - QQuickTextInput *input = qobject_cast(view.rootObject()); - QVERIFY(input); - - input->setFocus(true); - input->setText(""); - - view.show(); - view.requestActivateWindow(); - QTest::qWaitForWindowShown(&view); - QTRY_COMPARE(&view, qGuiApp->focusWindow()); - - QTextLayout layout(text); - layout.setFont(input->font()); - if (!qmlDisableDistanceField()) { - QTextOption option; - option.setUseDesignMetrics(true); - layout.setTextOption(option); - } - layout.beginLayout(); - QTextLine line = layout.createLine(); - layout.endLayout(); - - const qreal x = line.cursorToX(2, QTextLine::Leading); - const qreal y = line.height() / 2; - QPoint position = QPointF(x, y).toPoint(); - - QInputMethodEvent inputEvent(text.mid(0, 5), QList()); - QGuiApplication::sendEvent(input, &inputEvent); - - QTest::mousePress(&view, Qt::LeftButton, Qt::NoModifier, position); - QTest::mouseRelease(&view, Qt::LeftButton, Qt::NoModifier, position); - QGuiApplication::processEvents(); - - QCOMPARE(platformInputContext.m_action, QInputMethod::Click); - QCOMPARE(platformInputContext.m_invokeActionCallCount, 1); - QCOMPARE(platformInputContext.m_cursorPosition, 2); -} - -void tst_qquicktextinput::inputMethodComposing() -{ - QString text = "supercalifragisiticexpialidocious!"; - - QQuickView view(testFileUrl("inputContext.qml")); - view.show(); - view.requestActivateWindow(); - QTest::qWaitForWindowShown(&view); - QTRY_COMPARE(&view, qGuiApp->focusWindow()); - QQuickTextInput *input = qobject_cast(view.rootObject()); - QVERIFY(input); - QSignalSpy spy(input, SIGNAL(inputMethodComposingChanged())); - - QCOMPARE(input->isInputMethodComposing(), false); - { - QInputMethodEvent event(text.mid(3), QList()); - QGuiApplication::sendEvent(input, &event); - } - QCOMPARE(input->isInputMethodComposing(), true); - QCOMPARE(spy.count(), 1); - - { - QInputMethodEvent event(text.mid(12), QList()); - QGuiApplication::sendEvent(input, &event); - } - QCOMPARE(spy.count(), 1); - - { - QInputMethodEvent event; - QGuiApplication::sendEvent(input, &event); - } - QCOMPARE(input->isInputMethodComposing(), false); - QCOMPARE(spy.count(), 2); -} - -void tst_qquicktextinput::inputMethodUpdate() -{ - PlatformInputContext platformInputContext; - QInputMethodPrivate *inputMethodPrivate = QInputMethodPrivate::get(qApp->inputMethod()); - inputMethodPrivate->testContext = &platformInputContext; - - QQuickView view(testFileUrl("inputContext.qml")); - view.show(); - view.requestActivateWindow(); - QTest::qWaitForWindowShown(&view); - QTRY_COMPARE(&view, qGuiApp->focusWindow()); - QQuickTextInput *input = qobject_cast(view.rootObject()); - QVERIFY(input); - - // text change even without cursor position change needs to trigger update - input->setText("test"); - platformInputContext.clear(); - input->setText("xxxx"); - QVERIFY(platformInputContext.m_updateCallCount > 0); - - // input method event replacing text - platformInputContext.clear(); - { - QInputMethodEvent inputMethodEvent; - inputMethodEvent.setCommitString("y", -1, 1); - QGuiApplication::sendEvent(input, &inputMethodEvent); - } - QVERIFY(platformInputContext.m_updateCallCount > 0); - - // input method changing selection - platformInputContext.clear(); - { - QList attributes; - attributes << QInputMethodEvent::Attribute(QInputMethodEvent::Selection, 0, 2, QVariant()); - QInputMethodEvent inputMethodEvent("", attributes); - QGuiApplication::sendEvent(input, &inputMethodEvent); - } - QVERIFY(input->selectionStart() != input->selectionEnd()); - QVERIFY(platformInputContext.m_updateCallCount > 0); - - // programmatical selections trigger update - platformInputContext.clear(); - input->selectAll(); - QVERIFY(platformInputContext.m_updateCallCount > 0); - - // font changes - platformInputContext.clear(); - QFont font = input->font(); - font.setBold(!font.bold()); - input->setFont(font); - QVERIFY(platformInputContext.m_updateCallCount > 0); - - // normal input - platformInputContext.clear(); - { - QInputMethodEvent inputMethodEvent; - inputMethodEvent.setCommitString("y"); - QGuiApplication::sendEvent(input, &inputMethodEvent); - } - QVERIFY(platformInputContext.m_updateCallCount > 0); - - // changing cursor position - platformInputContext.clear(); - input->setCursorPosition(0); - QVERIFY(platformInputContext.m_updateCallCount > 0); - - // read only disabled input method - platformInputContext.clear(); - input->setReadOnly(true); - QVERIFY(platformInputContext.m_updateCallCount > 0); - input->setReadOnly(false); - - // no updates while no focus - input->setFocus(false); - platformInputContext.clear(); - input->setText("Foo"); - QCOMPARE(platformInputContext.m_updateCallCount, 0); - input->setCursorPosition(1); - QCOMPARE(platformInputContext.m_updateCallCount, 0); - input->selectAll(); - QCOMPARE(platformInputContext.m_updateCallCount, 0); - input->setReadOnly(true); - QCOMPARE(platformInputContext.m_updateCallCount, 0); -} - -void tst_qquicktextinput::cursorRectangleSize() -{ - QQuickView *canvas = new QQuickView(testFileUrl("positionAt.qml")); - QVERIFY(canvas->rootObject() != 0); - QQuickTextInput *textInput = qobject_cast(canvas->rootObject()); - - // make sure cursor rectangle is not at (0,0) - textInput->setX(10); - textInput->setY(10); - textInput->setCursorPosition(3); - QVERIFY(textInput != 0); - textInput->setFocus(true); - canvas->show(); - canvas->requestActivateWindow(); - QTest::qWaitForWindowShown(canvas); - QTRY_VERIFY(qApp->focusObject()); - - QInputMethodQueryEvent event(Qt::ImCursorRectangle); - qApp->sendEvent(qApp->focusObject(), &event); - QRectF cursorRectFromQuery = event.value(Qt::ImCursorRectangle).toRectF(); - - QRect cursorRectFromItem = textInput->cursorRectangle(); - QRectF cursorRectFromPositionToRectangle = textInput->positionToRectangle(textInput->cursorPosition()); - - // item and input query cursor rectangles match - QCOMPARE(cursorRectFromItem, cursorRectFromQuery.toRect()); - - // item cursor rectangle and positionToRectangle calculations match - QCOMPARE(cursorRectFromItem, cursorRectFromPositionToRectangle.toRect()); - - // item-canvas transform and input item transform match - QCOMPARE(QQuickItemPrivate::get(textInput)->itemToCanvasTransform(), qApp->inputMethod()->inputItemTransform()); - - // input panel cursorRectangle property and tranformed item cursor rectangle match - QRectF sceneCursorRect = QQuickItemPrivate::get(textInput)->itemToCanvasTransform().mapRect(cursorRectFromItem); - QCOMPARE(sceneCursorRect, qApp->inputMethod()->cursorRectangle()); - - delete canvas; -} - -void tst_qquicktextinput::tripleClickSelectsAll() -{ - QString qmlfile = testFile("positionAt.qml"); - QQuickView view(QUrl::fromLocalFile(qmlfile)); - view.show(); - view.requestActivateWindow(); - QTest::qWaitForWindowShown(&view); - - QTRY_COMPARE(&view, qGuiApp->focusWindow()); - - QQuickTextInput* input = qobject_cast(view.rootObject()); - QVERIFY(input); - - QLatin1String hello("Hello world!"); - input->setSelectByMouse(true); - input->setText(hello); - - // Clicking on the same point inside TextInput three times in a row - // should trigger a triple click, thus selecting all the text. - QPoint pointInside = input->pos().toPoint() + QPoint(2,2); - QTest::mouseDClick(&view, Qt::LeftButton, 0, pointInside); - QTest::mouseClick(&view, Qt::LeftButton, 0, pointInside); - QGuiApplication::processEvents(); - QCOMPARE(input->selectedText(), hello); - - // Now it simulates user moving the mouse between the second and the third click. - // In this situation, we don't expect a triple click. - QPoint pointInsideButFar = QPoint(input->width(),input->height()) - QPoint(2,2); - QTest::mouseDClick(&view, Qt::LeftButton, 0, pointInside); - QTest::mouseClick(&view, Qt::LeftButton, 0, pointInsideButFar); - QGuiApplication::processEvents(); - QVERIFY(input->selectedText().isEmpty()); - - // And now we press the third click too late, so no triple click event is triggered. - QTest::mouseDClick(&view, Qt::LeftButton, 0, pointInside); - QGuiApplication::processEvents(); - QTest::qWait(qApp->styleHints()->mouseDoubleClickInterval() + 1); - QTest::mouseClick(&view, Qt::LeftButton, 0, pointInside); - QGuiApplication::processEvents(); - QVERIFY(input->selectedText().isEmpty()); -} - -void tst_qquicktextinput::QTBUG_19956_data() -{ - QTest::addColumn("url"); - QTest::newRow("intvalidator") << "qtbug-19956int.qml"; - QTest::newRow("doublevalidator") << "qtbug-19956double.qml"; -} - - -void tst_qquicktextinput::getText_data() -{ - QTest::addColumn("text"); - QTest::addColumn("inputMask"); - QTest::addColumn("start"); - QTest::addColumn("end"); - QTest::addColumn("expectedText"); - - QTest::newRow("all plain text") - << standard.at(0) - << QString() - << 0 << standard.at(0).length() - << standard.at(0); - - QTest::newRow("plain text sub string") - << standard.at(0) - << QString() - << 0 << 12 - << standard.at(0).mid(0, 12); - - QTest::newRow("plain text sub string reversed") - << standard.at(0) - << QString() - << 12 << 0 - << standard.at(0).mid(0, 12); - - QTest::newRow("plain text cropped beginning") - << standard.at(0) - << QString() - << -3 << 4 - << standard.at(0).mid(0, 4); - - QTest::newRow("plain text cropped end") - << standard.at(0) - << QString() - << 23 << standard.at(0).length() + 8 - << standard.at(0).mid(23); - - QTest::newRow("plain text cropped beginning and end") - << standard.at(0) - << QString() - << -9 << standard.at(0).length() + 4 - << standard.at(0); -} - -void tst_qquicktextinput::getText() -{ - QFETCH(QString, text); - QFETCH(QString, inputMask); - QFETCH(int, start); - QFETCH(int, end); - QFETCH(QString, expectedText); - - QString componentStr = "import QtQuick 2.0\nTextInput { text: \"" + text + "\"; inputMask: \"" + inputMask + "\" }"; - QDeclarativeComponent textInputComponent(&engine); - textInputComponent.setData(componentStr.toLatin1(), QUrl()); - QQuickTextInput *textInput = qobject_cast(textInputComponent.create()); - QVERIFY(textInput != 0); - - QCOMPARE(textInput->getText(start, end), expectedText); -} - -void tst_qquicktextinput::insert_data() -{ - QTest::addColumn("text"); - QTest::addColumn("inputMask"); - QTest::addColumn("selectionStart"); - QTest::addColumn("selectionEnd"); - QTest::addColumn("insertPosition"); - QTest::addColumn("insertText"); - QTest::addColumn("expectedText"); - QTest::addColumn("expectedSelectionStart"); - QTest::addColumn("expectedSelectionEnd"); - QTest::addColumn("expectedCursorPosition"); - QTest::addColumn("selectionChanged"); - QTest::addColumn("cursorPositionChanged"); - - QTest::newRow("at cursor position (beginning)") - << standard.at(0) - << QString() - << 0 << 0 << 0 - << QString("Hello") - << QString("Hello") + standard.at(0) - << 5 << 5 << 5 - << false << true; - - QTest::newRow("at cursor position (end)") - << standard.at(0) - << QString() - << standard.at(0).length() << standard.at(0).length() << standard.at(0).length() - << QString("Hello") - << standard.at(0) + QString("Hello") - << standard.at(0).length() + 5 << standard.at(0).length() + 5 << standard.at(0).length() + 5 - << false << true; - - QTest::newRow("at cursor position (middle)") - << standard.at(0) - << QString() - << 18 << 18 << 18 - << QString("Hello") - << standard.at(0).mid(0, 18) + QString("Hello") + standard.at(0).mid(18) - << 23 << 23 << 23 - << false << true; - - QTest::newRow("after cursor position (beginning)") - << standard.at(0) - << QString() - << 0 << 0 << 18 - << QString("Hello") - << standard.at(0).mid(0, 18) + QString("Hello") + standard.at(0).mid(18) - << 0 << 0 << 0 - << false << false; - - QTest::newRow("before cursor position (end)") - << standard.at(0) - << QString() - << standard.at(0).length() << standard.at(0).length() << 18 - << QString("Hello") - << standard.at(0).mid(0, 18) + QString("Hello") + standard.at(0).mid(18) - << standard.at(0).length() + 5 << standard.at(0).length() + 5 << standard.at(0).length() + 5 - << false << true; - - QTest::newRow("before cursor position (middle)") - << standard.at(0) - << QString() - << 18 << 18 << 0 - << QString("Hello") - << QString("Hello") + standard.at(0) - << 23 << 23 << 23 - << false << true; - - QTest::newRow("after cursor position (middle)") - << standard.at(0) - << QString() - << 18 << 18 << standard.at(0).length() - << QString("Hello") - << standard.at(0) + QString("Hello") - << 18 << 18 << 18 - << false << false; - - QTest::newRow("before selection") - << standard.at(0) - << QString() - << 14 << 19 << 0 - << QString("Hello") - << QString("Hello") + standard.at(0) - << 19 << 24 << 24 - << false << true; - - QTest::newRow("before reversed selection") - << standard.at(0) - << QString() - << 19 << 14 << 0 - << QString("Hello") - << QString("Hello") + standard.at(0) - << 19 << 24 << 19 - << false << true; - - QTest::newRow("after selection") - << standard.at(0) - << QString() - << 14 << 19 << standard.at(0).length() - << QString("Hello") - << standard.at(0) + QString("Hello") - << 14 << 19 << 19 - << false << false; - - QTest::newRow("after reversed selection") - << standard.at(0) - << QString() - << 19 << 14 << standard.at(0).length() - << QString("Hello") - << standard.at(0) + QString("Hello") - << 14 << 19 << 14 - << false << false; - - QTest::newRow("into selection") - << standard.at(0) - << QString() - << 14 << 19 << 18 - << QString("Hello") - << standard.at(0).mid(0, 18) + QString("Hello") + standard.at(0).mid(18) - << 14 << 24 << 24 - << true << true; - - QTest::newRow("into reversed selection") - << standard.at(0) - << QString() - << 19 << 14 << 18 - << QString("Hello") - << standard.at(0).mid(0, 18) + QString("Hello") + standard.at(0).mid(18) - << 14 << 24 << 14 - << true << false; - - QTest::newRow("rich text into plain text") - << standard.at(0) - << QString() - << 0 << 0 << 0 - << QString("Hello") - << QString("Hello") + standard.at(0) - << 12 << 12 << 12 - << false << true; - - QTest::newRow("before start") - << standard.at(0) - << QString() - << 0 << 0 << -3 - << QString("Hello") - << standard.at(0) - << 0 << 0 << 0 - << false << false; - - QTest::newRow("past end") - << standard.at(0) - << QString() - << 0 << 0 << standard.at(0).length() + 3 - << QString("Hello") - << standard.at(0) - << 0 << 0 << 0 - << false << false; - - const QString inputMask = "009.009.009.009"; - const QString ip = "192.168.2.14"; - - QTest::newRow("mask: at cursor position (beginning)") - << ip - << inputMask - << 0 << 0 << 0 - << QString("125") - << QString("125.168.2.14") - << 0 << 0 << 0 - << false << false; - - QTest::newRow("mask: at cursor position (end)") - << ip - << inputMask - << inputMask.length() << inputMask.length() << inputMask.length() - << QString("8") - << ip - << inputMask.length() << inputMask.length() << inputMask.length() - << false << false; - - QTest::newRow("mask: at cursor position (middle)") - << ip - << inputMask - << 6 << 6 << 6 - << QString("75.2") - << QString("192.167.5.24") - << 6 << 6 << 6 - << false << false; - - QTest::newRow("mask: after cursor position (beginning)") - << ip - << inputMask - << 0 << 0 << 6 - << QString("75.2") - << QString("192.167.5.24") - << 0 << 0 << 0 - << false << false; - - QTest::newRow("mask: before cursor position (end)") - << ip - << inputMask - << inputMask.length() << inputMask.length() << 6 - << QString("75.2") - << QString("192.167.5.24") - << inputMask.length() << inputMask.length() << inputMask.length() - << false << false; - - QTest::newRow("mask: before cursor position (middle)") - << ip - << inputMask - << 6 << 6 << 0 - << QString("125") - << QString("125.168.2.14") - << 6 << 6 << 6 - << false << false; - - QTest::newRow("mask: after cursor position (middle)") - << ip - << inputMask - << 6 << 6 << 13 - << QString("8") - << "192.168.2.18" - << 6 << 6 << 6 - << false << false; - - QTest::newRow("mask: before selection") - << ip - << inputMask - << 6 << 8 << 0 - << QString("125") - << QString("125.168.2.14") - << 6 << 8 << 8 - << false << false; - - QTest::newRow("mask: before reversed selection") - << ip - << inputMask - << 8 << 6 << 0 - << QString("125") - << QString("125.168.2.14") - << 6 << 8 << 6 - << false << false; - - QTest::newRow("mask: after selection") - << ip - << inputMask - << 6 << 8 << 13 - << QString("8") - << "192.168.2.18" - << 6 << 8 << 8 - << false << false; - - QTest::newRow("mask: after reversed selection") - << ip - << inputMask - << 8 << 6 << 13 - << QString("8") - << "192.168.2.18" - << 6 << 8 << 6 - << false << false; - - QTest::newRow("mask: into selection") - << ip - << inputMask - << 5 << 8 << 6 - << QString("75.2") - << QString("192.167.5.24") - << 5 << 8 << 8 - << true << false; - - QTest::newRow("mask: into reversed selection") - << ip - << inputMask - << 8 << 5 << 6 - << QString("75.2") - << QString("192.167.5.24") - << 5 << 8 << 5 - << true << false; - - QTest::newRow("mask: before start") - << ip - << inputMask - << 0 << 0 << -3 - << QString("4") - << ip - << 0 << 0 << 0 - << false << false; - - QTest::newRow("mask: past end") - << ip - << inputMask - << 0 << 0 << ip.length() + 3 - << QString("4") - << ip - << 0 << 0 << 0 - << false << false; - - QTest::newRow("mask: invalid characters") - << ip - << inputMask - << 0 << 0 << 0 - << QString("abc") - << QString("192.168.2.14") - << 0 << 0 << 0 - << false << false; - - QTest::newRow("mask: mixed validity") - << ip - << inputMask - << 0 << 0 << 0 - << QString("a1b2c5") - << QString("125.168.2.14") - << 0 << 0 << 0 - << false << false; -} - -void tst_qquicktextinput::insert() -{ - QFETCH(QString, text); - QFETCH(QString, inputMask); - QFETCH(int, selectionStart); - QFETCH(int, selectionEnd); - QFETCH(int, insertPosition); - QFETCH(QString, insertText); - QFETCH(QString, expectedText); - QFETCH(int, expectedSelectionStart); - QFETCH(int, expectedSelectionEnd); - QFETCH(int, expectedCursorPosition); - QFETCH(bool, selectionChanged); - QFETCH(bool, cursorPositionChanged); - - QString componentStr = "import QtQuick 2.0\nTextInput { text: \"" + text + "\"; inputMask: \"" + inputMask + "\" }"; - QDeclarativeComponent textInputComponent(&engine); - textInputComponent.setData(componentStr.toLatin1(), QUrl()); - QQuickTextInput *textInput = qobject_cast(textInputComponent.create()); - QVERIFY(textInput != 0); - - textInput->select(selectionStart, selectionEnd); - - QSignalSpy selectionSpy(textInput, SIGNAL(selectedTextChanged())); - QSignalSpy selectionStartSpy(textInput, SIGNAL(selectionStartChanged())); - QSignalSpy selectionEndSpy(textInput, SIGNAL(selectionEndChanged())); - QSignalSpy textSpy(textInput, SIGNAL(textChanged())); - QSignalSpy cursorPositionSpy(textInput, SIGNAL(cursorPositionChanged())); - - textInput->insert(insertPosition, insertText); - - QCOMPARE(textInput->text(), expectedText); - QCOMPARE(textInput->length(), inputMask.isEmpty() ? expectedText.length() : inputMask.length()); - - QCOMPARE(textInput->selectionStart(), expectedSelectionStart); - QCOMPARE(textInput->selectionEnd(), expectedSelectionEnd); - QCOMPARE(textInput->cursorPosition(), expectedCursorPosition); - - if (selectionStart > selectionEnd) - qSwap(selectionStart, selectionEnd); - - QCOMPARE(selectionSpy.count() > 0, selectionChanged); - QCOMPARE(selectionStartSpy.count() > 0, selectionStart != expectedSelectionStart); - QCOMPARE(selectionEndSpy.count() > 0, selectionEnd != expectedSelectionEnd); - QCOMPARE(textSpy.count() > 0, text != expectedText); - QCOMPARE(cursorPositionSpy.count() > 0, cursorPositionChanged); -} - -void tst_qquicktextinput::remove_data() -{ - QTest::addColumn("text"); - QTest::addColumn("inputMask"); - QTest::addColumn("selectionStart"); - QTest::addColumn("selectionEnd"); - QTest::addColumn("removeStart"); - QTest::addColumn("removeEnd"); - QTest::addColumn("expectedText"); - QTest::addColumn("expectedSelectionStart"); - QTest::addColumn("expectedSelectionEnd"); - QTest::addColumn("expectedCursorPosition"); - QTest::addColumn("selectionChanged"); - QTest::addColumn("cursorPositionChanged"); - - QTest::newRow("from cursor position (beginning)") - << standard.at(0) - << QString() - << 0 << 0 - << 0 << 5 - << standard.at(0).mid(5) - << 0 << 0 << 0 - << false << false; - - QTest::newRow("to cursor position (beginning)") - << standard.at(0) - << QString() - << 0 << 0 - << 5 << 0 - << standard.at(0).mid(5) - << 0 << 0 << 0 - << false << false; - - QTest::newRow("to cursor position (end)") - << standard.at(0) - << QString() - << standard.at(0).length() << standard.at(0).length() - << standard.at(0).length() << standard.at(0).length() - 5 - << standard.at(0).mid(0, standard.at(0).length() - 5) - << standard.at(0).length() - 5 << standard.at(0).length() - 5 << standard.at(0).length() - 5 - << false << true; - - QTest::newRow("to cursor position (end)") - << standard.at(0) - << QString() - << standard.at(0).length() << standard.at(0).length() - << standard.at(0).length() - 5 << standard.at(0).length() - << standard.at(0).mid(0, standard.at(0).length() - 5) - << standard.at(0).length() - 5 << standard.at(0).length() - 5 << standard.at(0).length() - 5 - << false << true; - - QTest::newRow("from cursor position (middle)") - << standard.at(0) - << QString() - << 18 << 18 - << 18 << 23 - << standard.at(0).mid(0, 18) + standard.at(0).mid(23) - << 18 << 18 << 18 - << false << false; - - QTest::newRow("to cursor position (middle)") - << standard.at(0) - << QString() - << 23 << 23 - << 18 << 23 - << standard.at(0).mid(0, 18) + standard.at(0).mid(23) - << 18 << 18 << 18 - << false << true; - - QTest::newRow("after cursor position (beginning)") - << standard.at(0) - << QString() - << 0 << 0 - << 18 << 23 - << standard.at(0).mid(0, 18) + standard.at(0).mid(23) - << 0 << 0 << 0 - << false << false; - - QTest::newRow("before cursor position (end)") - << standard.at(0) - << QString() - << standard.at(0).length() << standard.at(0).length() - << 18 << 23 - << standard.at(0).mid(0, 18) + standard.at(0).mid(23) - << standard.at(0).length() - 5 << standard.at(0).length() - 5 << standard.at(0).length() - 5 - << false << true; - - QTest::newRow("before cursor position (middle)") - << standard.at(0) - << QString() - << 23 << 23 - << 0 << 5 - << standard.at(0).mid(5) - << 18 << 18 << 18 - << false << true; - - QTest::newRow("after cursor position (middle)") - << standard.at(0) - << QString() - << 18 << 18 - << 18 << 23 - << standard.at(0).mid(0, 18) + standard.at(0).mid(23) - << 18 << 18 << 18 - << false << false; - - QTest::newRow("before selection") - << standard.at(0) - << QString() - << 14 << 19 - << 0 << 5 - << standard.at(0).mid(5) - << 9 << 14 << 14 - << false << true; - - QTest::newRow("before reversed selection") - << standard.at(0) - << QString() - << 19 << 14 - << 0 << 5 - << standard.at(0).mid(5) - << 9 << 14 << 9 - << false << true; - - QTest::newRow("after selection") - << standard.at(0) - << QString() - << 14 << 19 - << standard.at(0).length() - 5 << standard.at(0).length() - << standard.at(0).mid(0, standard.at(0).length() - 5) - << 14 << 19 << 19 - << false << false; - - QTest::newRow("after reversed selection") - << standard.at(0) - << QString() - << 19 << 14 - << standard.at(0).length() - 5 << standard.at(0).length() - << standard.at(0).mid(0, standard.at(0).length() - 5) - << 14 << 19 << 14 - << false << false; - - QTest::newRow("from selection") - << standard.at(0) - << QString() - << 14 << 24 - << 18 << 23 - << standard.at(0).mid(0, 18) + standard.at(0).mid(23) - << 14 << 19 << 19 - << true << true; - - QTest::newRow("from reversed selection") - << standard.at(0) - << QString() - << 24 << 14 - << 18 << 23 - << standard.at(0).mid(0, 18) + standard.at(0).mid(23) - << 14 << 19 << 14 - << true << false; - - QTest::newRow("cropped beginning") - << standard.at(0) - << QString() - << 0 << 0 - << -3 << 4 - << standard.at(0).mid(4) - << 0 << 0 << 0 - << false << false; - - QTest::newRow("cropped end") - << standard.at(0) - << QString() - << 0 << 0 - << 23 << standard.at(0).length() + 8 - << standard.at(0).mid(0, 23) - << 0 << 0 << 0 - << false << false; - - QTest::newRow("cropped beginning and end") - << standard.at(0) - << QString() - << 0 << 0 - << -9 << standard.at(0).length() + 4 - << QString() - << 0 << 0 << 0 - << false << false; - - const QString inputMask = "009.009.009.009"; - const QString ip = "192.168.2.14"; - - QTest::newRow("mask: from cursor position") - << ip - << inputMask - << 6 << 6 - << 6 << 9 - << QString("192.16..14") - << 6 << 6 << 6 - << false << false; - - QTest::newRow("mask: to cursor position") - << ip - << inputMask - << 6 << 6 - << 2 << 6 - << QString("19.8.2.14") - << 6 << 6 << 6 - << false << false; - - QTest::newRow("mask: before cursor position") - << ip - << inputMask - << 6 << 6 - << 0 << 2 - << QString("2.168.2.14") - << 6 << 6 << 6 - << false << false; - - QTest::newRow("mask: after cursor position") - << ip - << inputMask - << 6 << 6 - << 12 << 16 - << QString("192.168.2.") - << 6 << 6 << 6 - << false << false; - - QTest::newRow("mask: before selection") - << ip - << inputMask - << 6 << 8 - << 0 << 2 - << QString("2.168.2.14") - << 6 << 8 << 8 - << false << false; - - QTest::newRow("mask: before reversed selection") - << ip - << inputMask - << 8 << 6 - << 0 << 2 - << QString("2.168.2.14") - << 6 << 8 << 6 - << false << false; - - QTest::newRow("mask: after selection") - << ip - << inputMask - << 6 << 8 - << 12 << 16 - << QString("192.168.2.") - << 6 << 8 << 8 - << false << false; - - QTest::newRow("mask: after reversed selection") - << ip - << inputMask - << 8 << 6 - << 12 << 16 - << QString("192.168.2.") - << 6 << 8 << 6 - << false << false; - - QTest::newRow("mask: from selection") - << ip - << inputMask - << 6 << 13 - << 8 << 10 - << QString("192.168..14") - << 6 << 13 << 13 - << true << false; - - QTest::newRow("mask: from reversed selection") - << ip - << inputMask - << 13 << 6 - << 8 << 10 - << QString("192.168..14") - << 6 << 13 << 6 - << true << false; - - QTest::newRow("mask: cropped beginning") - << ip - << inputMask - << 0 << 0 - << -3 << 4 - << QString(".168.2.14") - << 0 << 0 << 0 - << false << false; - - QTest::newRow("mask: cropped end") - << ip - << inputMask - << 0 << 0 - << 13 << 28 - << QString("192.168.2.1") - << 0 << 0 << 0 - << false << false; - - QTest::newRow("mask: cropped beginning and end") - << ip - << inputMask - << 0 << 0 - << -9 << 28 - << QString("...") - << 0 << 0 << 0 - << false << false; -} - -void tst_qquicktextinput::remove() -{ - QFETCH(QString, text); - QFETCH(QString, inputMask); - QFETCH(int, selectionStart); - QFETCH(int, selectionEnd); - QFETCH(int, removeStart); - QFETCH(int, removeEnd); - QFETCH(QString, expectedText); - QFETCH(int, expectedSelectionStart); - QFETCH(int, expectedSelectionEnd); - QFETCH(int, expectedCursorPosition); - QFETCH(bool, selectionChanged); - QFETCH(bool, cursorPositionChanged); - - QString componentStr = "import QtQuick 2.0\nTextInput { text: \"" + text + "\"; inputMask: \"" + inputMask + "\" }"; - QDeclarativeComponent textInputComponent(&engine); - textInputComponent.setData(componentStr.toLatin1(), QUrl()); - QQuickTextInput *textInput = qobject_cast(textInputComponent.create()); - QVERIFY(textInput != 0); - - textInput->select(selectionStart, selectionEnd); - - QSignalSpy selectionSpy(textInput, SIGNAL(selectedTextChanged())); - QSignalSpy selectionStartSpy(textInput, SIGNAL(selectionStartChanged())); - QSignalSpy selectionEndSpy(textInput, SIGNAL(selectionEndChanged())); - QSignalSpy textSpy(textInput, SIGNAL(textChanged())); - QSignalSpy cursorPositionSpy(textInput, SIGNAL(cursorPositionChanged())); - - textInput->remove(removeStart, removeEnd); - - QCOMPARE(textInput->text(), expectedText); - QCOMPARE(textInput->length(), inputMask.isEmpty() ? expectedText.length() : inputMask.length()); - - if (selectionStart > selectionEnd) // - qSwap(selectionStart, selectionEnd); - - QCOMPARE(textInput->selectionStart(), expectedSelectionStart); - QCOMPARE(textInput->selectionEnd(), expectedSelectionEnd); - QCOMPARE(textInput->cursorPosition(), expectedCursorPosition); - - QCOMPARE(selectionSpy.count() > 0, selectionChanged); - QCOMPARE(selectionStartSpy.count() > 0, selectionStart != expectedSelectionStart); - QCOMPARE(selectionEndSpy.count() > 0, selectionEnd != expectedSelectionEnd); - QCOMPARE(textSpy.count() > 0, text != expectedText); - - if (cursorPositionChanged) // - QVERIFY(cursorPositionSpy.count() > 0); -} - -void tst_qquicktextinput::keySequence_data() -{ - QTest::addColumn("text"); - QTest::addColumn("sequence"); - QTest::addColumn("selectionStart"); - QTest::addColumn("selectionEnd"); - QTest::addColumn("cursorPosition"); - QTest::addColumn("expectedText"); - QTest::addColumn("selectedText"); - - // standard[0] == "the [4]quick [10]brown [16]fox [20]jumped [27]over [32]the [36]lazy [41]dog" - - QTest::newRow("select all") - << standard.at(0) << QKeySequence(QKeySequence::SelectAll) << 0 << 0 - << 44 << standard.at(0) << standard.at(0); - QTest::newRow("select end of line") - << standard.at(0) << QKeySequence(QKeySequence::SelectEndOfLine) << 5 << 5 - << 44 << standard.at(0) << standard.at(0).mid(5); - QTest::newRow("select end of document") // ### Not handled. - << standard.at(0) << QKeySequence(QKeySequence::SelectEndOfDocument) << 3 << 3 - << 3 << standard.at(0) << QString(); - QTest::newRow("select end of block") - << standard.at(0) << QKeySequence(QKeySequence::SelectEndOfBlock) << 18 << 18 - << 44 << standard.at(0) << standard.at(0).mid(18); - QTest::newRow("delete end of line") - << standard.at(0) << QKeySequence(QKeySequence::DeleteEndOfLine) << 24 << 24 - << 24 << standard.at(0).mid(0, 24) << QString(); - QTest::newRow("move to start of line") - << standard.at(0) << QKeySequence(QKeySequence::MoveToStartOfLine) << 31 << 31 - << 0 << standard.at(0) << QString(); - QTest::newRow("move to start of block") - << standard.at(0) << QKeySequence(QKeySequence::MoveToStartOfBlock) << 25 << 25 - << 0 << standard.at(0) << QString(); - QTest::newRow("move to next char") - << standard.at(0) << QKeySequence(QKeySequence::MoveToNextChar) << 12 << 12 - << 13 << standard.at(0) << QString(); - QTest::newRow("move to previous char") - << standard.at(0) << QKeySequence(QKeySequence::MoveToPreviousChar) << 3 << 3 - << 2 << standard.at(0) << QString(); - QTest::newRow("select next char") - << standard.at(0) << QKeySequence(QKeySequence::SelectNextChar) << 23 << 23 - << 24 << standard.at(0) << standard.at(0).mid(23, 1); - QTest::newRow("select previous char") - << standard.at(0) << QKeySequence(QKeySequence::SelectPreviousChar) << 19 << 19 - << 18 << standard.at(0) << standard.at(0).mid(18, 1); - QTest::newRow("move to next word") - << standard.at(0) << QKeySequence(QKeySequence::MoveToNextWord) << 7 << 7 - << 10 << standard.at(0) << QString(); - QTest::newRow("move to previous word") - << standard.at(0) << QKeySequence(QKeySequence::MoveToPreviousWord) << 7 << 7 - << 4 << standard.at(0) << QString(); - QTest::newRow("select previous word") - << standard.at(0) << QKeySequence(QKeySequence::SelectPreviousWord) << 11 << 11 - << 10 << standard.at(0) << standard.at(0).mid(10, 1); - QTest::newRow("delete (selection)") - << standard.at(0) << QKeySequence(QKeySequence::Delete) << 12 << 15 - << 12 << (standard.at(0).mid(0, 12) + standard.at(0).mid(15)) << QString(); - QTest::newRow("delete (no selection)") - << standard.at(0) << QKeySequence(QKeySequence::Delete) << 15 << 15 - << 15 << (standard.at(0).mid(0, 15) + standard.at(0).mid(16)) << QString(); - QTest::newRow("delete end of word") - << standard.at(0) << QKeySequence(QKeySequence::DeleteEndOfWord) << 24 << 24 - << 24 << (standard.at(0).mid(0, 24) + standard.at(0).mid(27)) << QString(); - QTest::newRow("delete start of word") - << standard.at(0) << QKeySequence(QKeySequence::DeleteStartOfWord) << 7 << 7 - << 4 << (standard.at(0).mid(0, 4) + standard.at(0).mid(7)) << QString(); -} - -void tst_qquicktextinput::keySequence() -{ - QFETCH(QString, text); - QFETCH(QKeySequence, sequence); - QFETCH(int, selectionStart); - QFETCH(int, selectionEnd); - QFETCH(int, cursorPosition); - QFETCH(QString, expectedText); - QFETCH(QString, selectedText); - - if (sequence.isEmpty()) { - QSKIP("Key sequence is undefined"); - } - - QString componentStr = "import QtQuick 2.0\nTextInput { focus: true; text: \"" + text + "\" }"; - QDeclarativeComponent textInputComponent(&engine); - textInputComponent.setData(componentStr.toLatin1(), QUrl()); - QQuickTextInput *textInput = qobject_cast(textInputComponent.create()); - QVERIFY(textInput != 0); - - QQuickCanvas canvas; - textInput->setParentItem(canvas.rootItem()); - canvas.show(); - canvas.requestActivateWindow(); - QTest::qWaitForWindowShown(&canvas); - QTRY_COMPARE(QGuiApplication::activeWindow(), &canvas); - - textInput->select(selectionStart, selectionEnd); - - simulateKeys(&canvas, sequence); - - QCOMPARE(textInput->cursorPosition(), cursorPosition); - QCOMPARE(textInput->text(), expectedText); - QCOMPARE(textInput->selectedText(), selectedText); -} - -#define NORMAL 0 -#define REPLACE_UNTIL_END 1 - -void tst_qquicktextinput::undo_data() -{ - QTest::addColumn("insertString"); - QTest::addColumn("insertIndex"); - QTest::addColumn("insertMode"); - QTest::addColumn("expectedString"); - QTest::addColumn("use_keys"); - - for (int i=0; i<2; i++) { - QString keys_str = "keyboard"; - bool use_keys = true; - if (i==0) { - keys_str = "insert"; - use_keys = false; - } - - { - IntList insertIndex; - IntList insertMode; - QStringList insertString; - QStringList expectedString; - - insertIndex << -1; - insertMode << NORMAL; - insertString << "1"; - - insertIndex << -1; - insertMode << NORMAL; - insertString << "5"; - - insertIndex << 1; - insertMode << NORMAL; - insertString << "3"; - - insertIndex << 1; - insertMode << NORMAL; - insertString << "2"; - - insertIndex << 3; - insertMode << NORMAL; - insertString << "4"; - - expectedString << "12345"; - expectedString << "1235"; - expectedString << "135"; - expectedString << "15"; - expectedString << ""; - - QTest::newRow(QString(keys_str + "_numbers").toLatin1()) << - insertString << - insertIndex << - insertMode << - expectedString << - bool(use_keys); - } - { - IntList insertIndex; - IntList insertMode; - QStringList insertString; - QStringList expectedString; - - insertIndex << -1; - insertMode << NORMAL; - insertString << "World"; // World - - insertIndex << 0; - insertMode << NORMAL; - insertString << "Hello"; // HelloWorld - - insertIndex << 0; - insertMode << NORMAL; - insertString << "Well"; // WellHelloWorld - - insertIndex << 9; - insertMode << NORMAL; - insertString << "There"; // WellHelloThereWorld; - - expectedString << "WellHelloThereWorld"; - expectedString << "WellHelloWorld"; - expectedString << "HelloWorld"; - expectedString << "World"; - expectedString << ""; - - QTest::newRow(QString(keys_str + "_helloworld").toLatin1()) << - insertString << - insertIndex << - insertMode << - expectedString << - bool(use_keys); - } - { - IntList insertIndex; - IntList insertMode; - QStringList insertString; - QStringList expectedString; - - insertIndex << -1; - insertMode << NORMAL; - insertString << "Ensuring"; - - insertIndex << -1; - insertMode << NORMAL; - insertString << " instan"; - - insertIndex << 9; - insertMode << NORMAL; - insertString << "an "; - - insertIndex << 10; - insertMode << REPLACE_UNTIL_END; - insertString << " unique instance."; - - expectedString << "Ensuring a unique instance."; - expectedString << "Ensuring an instan"; - expectedString << "Ensuring instan"; - expectedString << ""; - - QTest::newRow(QString(keys_str + "_patterns").toLatin1()) << - insertString << - insertIndex << - insertMode << - expectedString << - bool(use_keys); - } - } -} - -void tst_qquicktextinput::undo() -{ - QFETCH(QStringList, insertString); - QFETCH(IntList, insertIndex); - QFETCH(IntList, insertMode); - QFETCH(QStringList, expectedString); - - QString componentStr = "import QtQuick 2.0\nTextInput { focus: true }"; - QDeclarativeComponent textInputComponent(&engine); - textInputComponent.setData(componentStr.toLatin1(), QUrl()); - QQuickTextInput *textInput = qobject_cast(textInputComponent.create()); - QVERIFY(textInput != 0); - - QQuickCanvas canvas; - textInput->setParentItem(canvas.rootItem()); - canvas.show(); - canvas.requestActivateWindow(); - QTest::qWaitForWindowShown(&canvas); - QTRY_COMPARE(QGuiApplication::activeWindow(), &canvas); - - QVERIFY(!textInput->canUndo()); - - QSignalSpy spy(textInput, SIGNAL(canUndoChanged())); - - int i; - -// STEP 1: First build up an undo history by inserting or typing some strings... - for (i = 0; i < insertString.size(); ++i) { - if (insertIndex[i] > -1) - textInput->setCursorPosition(insertIndex[i]); - - // experimental stuff - if (insertMode[i] == REPLACE_UNTIL_END) { - textInput->select(insertIndex[i], insertIndex[i] + 8); - - // This is what I actually want... - // QTest::keyClick(testWidget, Qt::Key_End, Qt::ShiftModifier); - } - - for (int j = 0; j < insertString.at(i).length(); j++) - QTest::keyClick(&canvas, insertString.at(i).at(j).toLatin1()); - } - - QCOMPARE(spy.count(), 1); - -// STEP 2: Next call undo several times and see if we can restore to the previous state - for (i = 0; i < expectedString.size() - 1; ++i) { - QCOMPARE(textInput->text(), expectedString[i]); - QVERIFY(textInput->canUndo()); - textInput->undo(); - } - -// STEP 3: Verify that we have undone everything - QVERIFY(textInput->text().isEmpty()); - QVERIFY(!textInput->canUndo()); - QCOMPARE(spy.count(), 2); -} - -void tst_qquicktextinput::redo_data() -{ - QTest::addColumn("insertString"); - QTest::addColumn("insertIndex"); - QTest::addColumn("expectedString"); - - { - IntList insertIndex; - QStringList insertString; - QStringList expectedString; - - insertIndex << -1; - insertString << "World"; // World - insertIndex << 0; - insertString << "Hello"; // HelloWorld - insertIndex << 0; - insertString << "Well"; // WellHelloWorld - insertIndex << 9; - insertString << "There"; // WellHelloThereWorld; - - expectedString << "World"; - expectedString << "HelloWorld"; - expectedString << "WellHelloWorld"; - expectedString << "WellHelloThereWorld"; - - QTest::newRow("Inserts and setting cursor") << insertString << insertIndex << expectedString; - } -} - -void tst_qquicktextinput::redo() -{ - QFETCH(QStringList, insertString); - QFETCH(IntList, insertIndex); - QFETCH(QStringList, expectedString); - - QString componentStr = "import QtQuick 2.0\nTextInput { focus: true }"; - QDeclarativeComponent textInputComponent(&engine); - textInputComponent.setData(componentStr.toLatin1(), QUrl()); - QQuickTextInput *textInput = qobject_cast(textInputComponent.create()); - QVERIFY(textInput != 0); - - QQuickCanvas canvas; - textInput->setParentItem(canvas.rootItem()); - canvas.show(); - canvas.requestActivateWindow(); - QTest::qWaitForWindowShown(&canvas); - QTRY_COMPARE(QGuiApplication::activeWindow(), &canvas); - - QVERIFY(!textInput->canUndo()); - QVERIFY(!textInput->canRedo()); - - QSignalSpy spy(textInput, SIGNAL(canRedoChanged())); - - int i; - // inserts the diff strings at diff positions - for (i = 0; i < insertString.size(); ++i) { - if (insertIndex[i] > -1) - textInput->setCursorPosition(insertIndex[i]); - for (int j = 0; j < insertString.at(i).length(); j++) - QTest::keyClick(&canvas, insertString.at(i).at(j).toLatin1()); - QVERIFY(textInput->canUndo()); - QVERIFY(!textInput->canRedo()); - } - - QCOMPARE(spy.count(), 0); - - // undo everything - while (!textInput->text().isEmpty()) { - QVERIFY(textInput->canUndo()); - textInput->undo(); - QVERIFY(textInput->canRedo()); - } - - QCOMPARE(spy.count(), 1); - - for (i = 0; i < expectedString.size(); ++i) { - QVERIFY(textInput->canRedo()); - textInput->redo(); - QCOMPARE(textInput->text() , expectedString[i]); - QVERIFY(textInput->canUndo()); - } - QVERIFY(!textInput->canRedo()); - QCOMPARE(spy.count(), 2); -} - -void tst_qquicktextinput::undo_keypressevents_data() -{ - QTest::addColumn("keys"); - QTest::addColumn("expectedString"); - - { - KeyList keys; - QStringList expectedString; - - keys << "AFRAID" - << QKeySequence::MoveToStartOfLine - << "VERY" - << Qt::Key_Left - << Qt::Key_Left - << Qt::Key_Left - << Qt::Key_Left - << "BE" - << QKeySequence::MoveToEndOfLine - << "!"; - - expectedString << "BEVERYAFRAID!"; - expectedString << "BEVERYAFRAID"; - expectedString << "VERYAFRAID"; - expectedString << "AFRAID"; - - QTest::newRow("Inserts and moving cursor") << keys << expectedString; - } { - KeyList keys; - QStringList expectedString; - - // inserting '1234' - keys << "1234" << QKeySequence::MoveToStartOfLine - // skipping '12' - << Qt::Key_Right << Qt::Key_Right - // selecting '34' - << (Qt::Key_Right | Qt::ShiftModifier) << (Qt::Key_Right | Qt::ShiftModifier) - // deleting '34' - << Qt::Key_Delete; - - expectedString << "12"; - expectedString << "1234"; - - QTest::newRow("Inserts,moving,selection and delete") << keys << expectedString; - } { - KeyList keys; - QStringList expectedString; - - // inserting 'AB12' - keys << "AB12" - << QKeySequence::MoveToStartOfLine - // selecting 'AB' - << (Qt::Key_Right | Qt::ShiftModifier) << (Qt::Key_Right | Qt::ShiftModifier) - << Qt::Key_Delete - << QKeySequence::Undo - << Qt::Key_Right -#ifdef Q_OS_WIN //Mac(?) has a specialcase to handle jumping to the end of a selection - << Qt::Key_Left -#endif - << (Qt::Key_Right | Qt::ShiftModifier) << (Qt::Key_Right | Qt::ShiftModifier) - << Qt::Key_Delete; - - expectedString << "AB"; - expectedString << "AB12"; - - QTest::newRow("Inserts,moving,selection, delete and undo") << keys << expectedString; - } { - KeyList keys; - QStringList expectedString; - - // inserting 'ABCD' - keys << "abcd" - //move left two - << Qt::Key_Left << Qt::Key_Left - // inserting '1234' - << "1234" - // selecting '1234' - << (Qt::Key_Left | Qt::ShiftModifier) << (Qt::Key_Left | Qt::ShiftModifier) << (Qt::Key_Left | Qt::ShiftModifier) << (Qt::Key_Left | Qt::ShiftModifier) - // overwriting '1234' with '5' - << "5" - // undoing deletion of 'AB' - << QKeySequence::Undo - // overwriting '1234' with '6' - << "6"; - - expectedString << "ab6cd"; - // for versions previous to 3.2 we overwrite needed two undo operations - expectedString << "ab1234cd"; - expectedString << "abcd"; - - QTest::newRow("Inserts,moving,selection and undo, removing selection") << keys << expectedString; - } { - KeyList keys; - QStringList expectedString; - - // inserting 'ABC' - keys << "ABC" - // removes 'C' - << Qt::Key_Backspace; - - expectedString << "AB"; - expectedString << "ABC"; - - QTest::newRow("Inserts,backspace") << keys << expectedString; - } { - KeyList keys; - QStringList expectedString; - - keys << "ABC" - // removes 'C' - << Qt::Key_Backspace - // inserting 'Z' - << "Z"; - - expectedString << "ABZ"; - expectedString << "AB"; - expectedString << "ABC"; - - QTest::newRow("Inserts,backspace,inserts") << keys << expectedString; - } { - KeyList keys; - QStringList expectedString; - - // inserting '123' - keys << "123" << QKeySequence::MoveToStartOfLine - // selecting '123' - << QKeySequence::SelectEndOfLine - // overwriting '123' with 'ABC' - << "ABC"; - - expectedString << "ABC"; - // for versions previous to 3.2 we overwrite needed two undo operations - expectedString << "123"; - - QTest::newRow("Inserts,moving,selection and overwriting") << keys << expectedString; - } -} - -void tst_qquicktextinput::undo_keypressevents() -{ - QFETCH(KeyList, keys); - QFETCH(QStringList, expectedString); - - QString componentStr = "import QtQuick 2.0\nTextInput { focus: true }"; - QDeclarativeComponent textInputComponent(&engine); - textInputComponent.setData(componentStr.toLatin1(), QUrl()); - QQuickTextInput *textInput = qobject_cast(textInputComponent.create()); - QVERIFY(textInput != 0); - - QQuickCanvas canvas; - textInput->setParentItem(canvas.rootItem()); - canvas.show(); - canvas.requestActivateWindow(); - QTest::qWaitForWindowShown(&canvas); - QTRY_COMPARE(QGuiApplication::activeWindow(), &canvas); - - simulateKeys(&canvas, keys); - - for (int i = 0; i < expectedString.size(); ++i) { - QCOMPARE(textInput->text() , expectedString[i]); - textInput->undo(); - } - QVERIFY(textInput->text().isEmpty()); -} - -void tst_qquicktextinput::QTBUG_19956() -{ - QFETCH(QString, url); - - QQuickView canvas(testFileUrl(url)); - canvas.show(); - canvas.requestActivateWindow(); - QTest::qWaitForWindowShown(&canvas); - QVERIFY(canvas.rootObject() != 0); - QQuickTextInput *input = qobject_cast(canvas.rootObject()); - QVERIFY(input); - input->setFocus(true); - QVERIFY(input->hasActiveFocus()); - - QCOMPARE(canvas.rootObject()->property("topvalue").toInt(), 30); - QCOMPARE(canvas.rootObject()->property("bottomvalue").toInt(), 10); - QCOMPARE(canvas.rootObject()->property("text").toString(), QString("20")); - QVERIFY(canvas.rootObject()->property("acceptableInput").toBool()); - - canvas.rootObject()->setProperty("topvalue", 15); - QCOMPARE(canvas.rootObject()->property("topvalue").toInt(), 15); - QVERIFY(!canvas.rootObject()->property("acceptableInput").toBool()); - - canvas.rootObject()->setProperty("topvalue", 25); - QCOMPARE(canvas.rootObject()->property("topvalue").toInt(), 25); - QVERIFY(canvas.rootObject()->property("acceptableInput").toBool()); - - canvas.rootObject()->setProperty("bottomvalue", 21); - QCOMPARE(canvas.rootObject()->property("bottomvalue").toInt(), 21); - QVERIFY(!canvas.rootObject()->property("acceptableInput").toBool()); - - canvas.rootObject()->setProperty("bottomvalue", 10); - QCOMPARE(canvas.rootObject()->property("bottomvalue").toInt(), 10); - QVERIFY(canvas.rootObject()->property("acceptableInput").toBool()); -} - -void tst_qquicktextinput::QTBUG_19956_regexp() -{ - QUrl url = testFileUrl("qtbug-19956regexp.qml"); - - QString warning = url.toString() + ":11: Unable to assign [undefined] to QRegExp"; - QTest::ignoreMessage(QtWarningMsg, qPrintable(warning)); - - QQuickView canvas(url); - canvas.show(); - canvas.requestActivateWindow(); - QTest::qWaitForWindowShown(&canvas); - QVERIFY(canvas.rootObject() != 0); - QQuickTextInput *input = qobject_cast(canvas.rootObject()); - QVERIFY(input); - input->setFocus(true); - QVERIFY(input->hasActiveFocus()); - - canvas.rootObject()->setProperty("regexvalue", QRegExp("abc")); - QCOMPARE(canvas.rootObject()->property("regexvalue").toRegExp(), QRegExp("abc")); - QCOMPARE(canvas.rootObject()->property("text").toString(), QString("abc")); - QVERIFY(canvas.rootObject()->property("acceptableInput").toBool()); - - canvas.rootObject()->setProperty("regexvalue", QRegExp("abcd")); - QCOMPARE(canvas.rootObject()->property("regexvalue").toRegExp(), QRegExp("abcd")); - QVERIFY(!canvas.rootObject()->property("acceptableInput").toBool()); - - canvas.rootObject()->setProperty("regexvalue", QRegExp("abc")); - QCOMPARE(canvas.rootObject()->property("regexvalue").toRegExp(), QRegExp("abc")); - QVERIFY(canvas.rootObject()->property("acceptableInput").toBool()); -} - - -void tst_qquicktextinput::negativeDimensions() -{ - // Verify this doesn't assert during initialization. - QDeclarativeComponent component(&engine, testFileUrl("negativeDimensions.qml")); - QScopedPointer o(component.create()); - QVERIFY(o); - QQuickTextInput *input = o->findChild("input"); - QVERIFY(input); - QCOMPARE(input->width(), qreal(-1)); - QCOMPARE(input->height(), qreal(-1)); -} - -QTEST_MAIN(tst_qquicktextinput) - -#include "tst_qquicktextinput.moc" diff --git a/tests/auto/qtquick2/qquickview/data/error1.qml b/tests/auto/qtquick2/qquickview/data/error1.qml deleted file mode 100644 index 09df679555..0000000000 --- a/tests/auto/qtquick2/qquickview/data/error1.qml +++ /dev/null @@ -1,5 +0,0 @@ -import QtQuick 2.0 - -Rectangle { - nonExistentProperty: 5 -} diff --git a/tests/auto/qtquick2/qquickview/data/resizemodeitem.qml b/tests/auto/qtquick2/qquickview/data/resizemodeitem.qml deleted file mode 100644 index ed73009b26..0000000000 --- a/tests/auto/qtquick2/qquickview/data/resizemodeitem.qml +++ /dev/null @@ -1,5 +0,0 @@ -import QtQuick 2.0 -Item { - width: 200 - height: 200 -} diff --git a/tests/auto/qtquick2/qquickview/qquickview.pro b/tests/auto/qtquick2/qquickview/qquickview.pro deleted file mode 100644 index c3bc0ddcaf..0000000000 --- a/tests/auto/qtquick2/qquickview/qquickview.pro +++ /dev/null @@ -1,13 +0,0 @@ -CONFIG += testcase -TARGET = tst_qquickview -macx:CONFIG -= app_bundle - -SOURCES += tst_qquickview.cpp - -include (../../shared/util.pri) - -testDataFiles.files = data -testDataFiles.path = . -DEPLOYMENT += testDataFiles - -QT += core-private gui-private declarative-private quick-private testlib diff --git a/tests/auto/qtquick2/qquickview/tst_qquickview.cpp b/tests/auto/qtquick2/qquickview/tst_qquickview.cpp deleted file mode 100644 index fe290456eb..0000000000 --- a/tests/auto/qtquick2/qquickview/tst_qquickview.cpp +++ /dev/null @@ -1,207 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include -#include -#include -#include -#include -#include -#include "../../shared/util.h" -#include -#include - -class tst_QQuickView : public QDeclarativeDataTest -{ - Q_OBJECT -public: - tst_QQuickView(); - -private slots: - void resizemodeitem(); - void errors(); -}; - - -tst_QQuickView::tst_QQuickView() -{ -} - -void tst_QQuickView::resizemodeitem() -{ - QWindow window; - window.setGeometry(0, 0, 400, 400); - - QQuickView *canvas = new QQuickView(&window); - QVERIFY(canvas); - canvas->setResizeMode(QQuickView::SizeRootObjectToView); - QCOMPARE(QSize(0,0), canvas->initialSize()); - canvas->setSource(testFileUrl("resizemodeitem.qml")); - QQuickItem* item = qobject_cast(canvas->rootObject()); - QVERIFY(item); - window.show(); - - canvas->show(); - - // initial size from root object - QCOMPARE(item->width(), 200.0); - QCOMPARE(item->height(), 200.0); - QCOMPARE(canvas->size(), QSize(200, 200)); - QCOMPARE(canvas->size(), canvas->sizeHint()); - QCOMPARE(canvas->size(), canvas->initialSize()); - - // size update from view - canvas->resize(QSize(80,100)); - - QTRY_COMPARE(item->width(), 80.0); - QCOMPARE(item->height(), 100.0); - QCOMPARE(canvas->size(), QSize(80, 100)); - QCOMPARE(canvas->size(), canvas->sizeHint()); - - canvas->setResizeMode(QQuickView::SizeViewToRootObject); - - // size update from view disabled - canvas->resize(QSize(60,80)); - QCOMPARE(item->width(), 80.0); - QCOMPARE(item->height(), 100.0); - QTest::qWait(50); - QCOMPARE(canvas->size(), QSize(60, 80)); - - // size update from root object - item->setWidth(250); - item->setHeight(350); - QCOMPARE(item->width(), 250.0); - QCOMPARE(item->height(), 350.0); - QTRY_COMPARE(canvas->size(), QSize(250, 350)); - QCOMPARE(canvas->size(), QSize(250, 350)); - QCOMPARE(canvas->size(), canvas->sizeHint()); - - // reset canvas - window.hide(); - delete canvas; - canvas = new QQuickView(&window); - QVERIFY(canvas); - canvas->setResizeMode(QQuickView::SizeViewToRootObject); - canvas->setSource(testFileUrl("resizemodeitem.qml")); - item = qobject_cast(canvas->rootObject()); - QVERIFY(item); - window.show(); - - canvas->show(); - - // initial size for root object - QCOMPARE(item->width(), 200.0); - QCOMPARE(item->height(), 200.0); - QCOMPARE(canvas->size(), canvas->sizeHint()); - QCOMPARE(canvas->size(), canvas->initialSize()); - - // size update from root object - item->setWidth(80); - item->setHeight(100); - QCOMPARE(item->width(), 80.0); - QCOMPARE(item->height(), 100.0); - QTRY_COMPARE(canvas->size(), QSize(80, 100)); - QCOMPARE(canvas->size(), QSize(80, 100)); - QCOMPARE(canvas->size(), canvas->sizeHint()); - - // size update from root object disabled - canvas->setResizeMode(QQuickView::SizeRootObjectToView); - item->setWidth(60); - item->setHeight(80); - QCOMPARE(canvas->width(), 80); - QCOMPARE(canvas->height(), 100); - QCOMPARE(QSize(item->width(), item->height()), canvas->sizeHint()); - - // size update from view - canvas->resize(QSize(200,300)); - QTest::qWait(50); - QCOMPARE(item->width(), 200.0); - QCOMPARE(item->height(), 300.0); - QCOMPARE(canvas->size(), QSize(200, 300)); - QCOMPARE(canvas->size(), canvas->sizeHint()); - - window.hide(); - delete canvas; - - // if we set a specific size for the view then it should keep that size - // for SizeRootObjectToView mode. - canvas = new QQuickView(&window); - canvas->resize(300, 300); - canvas->setResizeMode(QQuickView::SizeRootObjectToView); - QCOMPARE(QSize(0,0), canvas->initialSize()); - canvas->setSource(testFileUrl("resizemodeitem.qml")); - canvas->resize(300, 300); - item = qobject_cast(canvas->rootObject()); - QVERIFY(item); - window.show(); - - canvas->show(); - QTest::qWait(50); - - // initial size from root object - QCOMPARE(item->width(), 300.0); - QCOMPARE(item->height(), 300.0); - QCOMPARE(canvas->size(), QSize(300, 300)); - QCOMPARE(canvas->size(), canvas->sizeHint()); - QCOMPARE(canvas->initialSize(), QSize(200, 200)); // initial object size - - delete canvas; -} - -static void silentErrorsMsgHandler(QtMsgType, const char *) -{ -} - -void tst_QQuickView::errors() -{ - QQuickView *canvas = new QQuickView; - QVERIFY(canvas); - QtMsgHandler old = qInstallMsgHandler(silentErrorsMsgHandler); - canvas->setSource(testFileUrl("error1.qml")); - qInstallMsgHandler(old); - QVERIFY(canvas->status() == QQuickView::Error); - QVERIFY(canvas->errors().count() == 1); - delete canvas; -} - - -QTEST_MAIN(tst_QQuickView) - -#include "tst_qquickview.moc" diff --git a/tests/auto/qtquick2/qquickvisualdatamodel/data/create.qml b/tests/auto/qtquick2/qquickvisualdatamodel/data/create.qml deleted file mode 100644 index 9f4b754552..0000000000 --- a/tests/auto/qtquick2/qquickvisualdatamodel/data/create.qml +++ /dev/null @@ -1,22 +0,0 @@ -import QtQuick 2.0 - -ListView { - width: 200 - height: 200 - - property var persistentHandle - - model: VisualDataModel { - id: visualModel - - persistedItems.includeByDefault: true - - model: myModel - delegate: Item { - id: delegate - objectName: "delegate" - width: 200 - height: 20 - } - } -} diff --git a/tests/auto/qtquick2/qquickvisualdatamodel/data/datalist-package.qml b/tests/auto/qtquick2/qquickvisualdatamodel/data/datalist-package.qml deleted file mode 100644 index ae3bd81d91..0000000000 --- a/tests/auto/qtquick2/qquickvisualdatamodel/data/datalist-package.qml +++ /dev/null @@ -1,20 +0,0 @@ -import QtQuick 2.0 - -ListView { - width: 100 - height: 100 - model: visualModel.parts.package - VisualDataModel { - id: visualModel - objectName: "visualModel" - model: myModel - delegate: Package { - Rectangle { - height: 25 - width: 100 - Package.name: "package" - Text { objectName: "display"; text: display } - } - } - } -} diff --git a/tests/auto/qtquick2/qquickvisualdatamodel/data/datalist.qml b/tests/auto/qtquick2/qquickvisualdatamodel/data/datalist.qml deleted file mode 100644 index 8ce59caddc..0000000000 --- a/tests/auto/qtquick2/qquickvisualdatamodel/data/datalist.qml +++ /dev/null @@ -1,18 +0,0 @@ -import QtQuick 2.0 - -ListView { - width: 100 - height: 100 - model: VisualDataModel { - id: visualModel - objectName: "visualModel" - model: myModel - delegate: Component { - Rectangle { - height: 25 - width: 100 - Text { objectName: "display"; text: display } - } - } - } -} diff --git a/tests/auto/qtquick2/qquickvisualdatamodel/data/groups-invalid.qml b/tests/auto/qtquick2/qquickvisualdatamodel/data/groups-invalid.qml deleted file mode 100644 index 70c6f9f995..0000000000 --- a/tests/auto/qtquick2/qquickvisualdatamodel/data/groups-invalid.qml +++ /dev/null @@ -1,14 +0,0 @@ -import QtQuick 2.0 - -VisualDataModel { - id: visualModel - - objectName: "visualModel" - - groups: [ - VisualDataGroup { id: visibleItems; objectName: "visibleItems"; name: "visible"; includeByDefault: true }, - VisualDataGroup { id: selectedItems; objectName: "selectedItems"; name: "selected" }, - VisualDataGroup { id: unnamed; objectName: "unnamed" }, - VisualDataGroup { id: capitalised; objectName: "capitalised"; name: "Capitalised" } - ] -} diff --git a/tests/auto/qtquick2/qquickvisualdatamodel/data/groups-package.qml b/tests/auto/qtquick2/qquickvisualdatamodel/data/groups-package.qml deleted file mode 100644 index ea5ad5d3bd..0000000000 --- a/tests/auto/qtquick2/qquickvisualdatamodel/data/groups-package.qml +++ /dev/null @@ -1,52 +0,0 @@ -import QtQuick 2.0 - -ListView { - width: 100 - height: 100 - - function contains(array, value) { - for (var i = 0; i < array.length; ++i) - if (array[i] == value) - return true - return false - } - model: visualModel.parts.package - - VisualDataModel { - id: visualModel - - objectName: "visualModel" - - groups: [ - VisualDataGroup { id: visibleItems; objectName: "visibleItems"; name: "visible"; includeByDefault: true }, - VisualDataGroup { id: selectedItems; objectName: "selectedItems"; name: "selected" } - ] - - model: myModel - delegate: Package { - id: delegate - - property variant test1: name - property variant test2: index - property variant test3: VisualDataModel.itemsIndex - property variant test4: VisualDataModel.inItems - property variant test5: VisualDataModel.visibleIndex - property variant test6: VisualDataModel.inVisible - property variant test7: VisualDataModel.selectedIndex - property variant test8: VisualDataModel.inSelected - property variant test9: VisualDataModel.groups - - function hide() { VisualDataModel.inVisible = false } - function select() { VisualDataModel.inSelected = true } - - Item { - Package.name: "package" - - objectName: "delegate" - width: 100 - height: 2 - } - } - } - -} diff --git a/tests/auto/qtquick2/qquickvisualdatamodel/data/groups.qml b/tests/auto/qtquick2/qquickvisualdatamodel/data/groups.qml deleted file mode 100644 index 7502dd2502..0000000000 --- a/tests/auto/qtquick2/qquickvisualdatamodel/data/groups.qml +++ /dev/null @@ -1,46 +0,0 @@ -import QtQuick 2.0 - -ListView { - width: 100 - height: 100 - - function contains(array, value) { - for (var i = 0; i < array.length; ++i) - if (array[i] == value) - return true - return false - } - - model: visualModel - VisualDataModel { - id: visualModel - - objectName: "visualModel" - - groups: [ - VisualDataGroup { id: visibleItems; objectName: "visibleItems"; name: "visible"; includeByDefault: true }, - VisualDataGroup { id: selectedItems; objectName: "selectedItems"; name: "selected" } - ] - - model: myModel - delegate: Item { - id: delegate - - objectName: "delegate" - width: 100 - height: 2 - property variant test1: name - property variant test2: index - property variant test3: VisualDataModel.itemsIndex - property variant test4: VisualDataModel.inItems - property variant test5: VisualDataModel.visibleIndex - property variant test6: VisualDataModel.inVisible - property variant test7: VisualDataModel.selectedIndex - property variant test8: VisualDataModel.inSelected - property variant test9: VisualDataModel.groups - - function hide() { VisualDataModel.inVisible = false } - function select() { VisualDataModel.inSelected = true } - } - } -} diff --git a/tests/auto/qtquick2/qquickvisualdatamodel/data/itemsDestroyed_listView.qml b/tests/auto/qtquick2/qquickvisualdatamodel/data/itemsDestroyed_listView.qml deleted file mode 100644 index 103c4d2eb6..0000000000 --- a/tests/auto/qtquick2/qquickvisualdatamodel/data/itemsDestroyed_listView.qml +++ /dev/null @@ -1,13 +0,0 @@ -import QtQuick 2.0 - -ListView { - width: 100 - height: 100 - - model: myModel - delegate: Item { - objectName: "delegate" - width: 100 - height: 20 - } -} diff --git a/tests/auto/qtquick2/qquickvisualdatamodel/data/itemsDestroyed_package.qml b/tests/auto/qtquick2/qquickvisualdatamodel/data/itemsDestroyed_package.qml deleted file mode 100644 index b47f22dc34..0000000000 --- a/tests/auto/qtquick2/qquickvisualdatamodel/data/itemsDestroyed_package.qml +++ /dev/null @@ -1,42 +0,0 @@ -import QtQuick 2.0 - -Item { - width: 100 - height: 100 - - ListView { - anchors.fill: parent - - model: visualModel.parts.list - } - VisualDataModel { - id: visualModel - - model: myModel - delegate: Package { - Item { - Package.name: "list" - width: 100 - height: 20 - } - - Item { - id: gridItem - Package.name: "grid" - width: 50 - height: 50 - } - Rectangle { - objectName: "delegate" - parent: gridItem - width: 20 - height: 20 - } - } - } - GridView { - anchors.fill: parent - - model: visualModel.parts.grid - } -} diff --git a/tests/auto/qtquick2/qquickvisualdatamodel/data/itemsDestroyed_pathView.qml b/tests/auto/qtquick2/qquickvisualdatamodel/data/itemsDestroyed_pathView.qml deleted file mode 100644 index bc619124fd..0000000000 --- a/tests/auto/qtquick2/qquickvisualdatamodel/data/itemsDestroyed_pathView.qml +++ /dev/null @@ -1,18 +0,0 @@ -import QtQuick 2.0 - -PathView { - width: 100 - height: 100 - - model: myModel - delegate: Item { - objectName: "delegate" - width: 100 - height: 20 - } - - path: Path { - startX: 50; startY: 0 - PathLine { x: 50; y: 100 } - } -} diff --git a/tests/auto/qtquick2/qquickvisualdatamodel/data/itemsDestroyed_repeater.qml b/tests/auto/qtquick2/qquickvisualdatamodel/data/itemsDestroyed_repeater.qml deleted file mode 100644 index e97e0dad2e..0000000000 --- a/tests/auto/qtquick2/qquickvisualdatamodel/data/itemsDestroyed_repeater.qml +++ /dev/null @@ -1,15 +0,0 @@ -import QtQuick 2.0 - -Grid { - Repeater { - width: 100 - height: 100 - - model: myModel - delegate: Item { - objectName: "delegate" - width: 50 - height: 50 - } - } -} diff --git a/tests/auto/qtquick2/qquickvisualdatamodel/data/listmodelproperties-package.qml b/tests/auto/qtquick2/qquickvisualdatamodel/data/listmodelproperties-package.qml deleted file mode 100644 index b6b56727e8..0000000000 --- a/tests/auto/qtquick2/qquickvisualdatamodel/data/listmodelproperties-package.qml +++ /dev/null @@ -1,51 +0,0 @@ -import QtQuick 2.0 - -ListView { - width: 100 - height: 100 - model: visualModel.parts.package - - VisualDataModel { - id: visualModel - objectName: "visualModel" - - groups: [ - VisualDataGroup { id: visibleItems; objectName: "visibleItems"; name: "visible"; includeByDefault: true }, - VisualDataGroup { id: selectedItems; objectName: "selectedItems"; name: "selected" } - ] - - model: ListModel { - id: listModel - - ListElement { number: "one" } - ListElement { number: "two" } - ListElement { number: "three" } - ListElement { number: "four" } - } - - delegate: Package { - id: delegate - - property variant test1: index - property variant test2: model.index - property variant test3: number - property variant test4: model.number - property variant test5: modelData - property variant test6: model.modelData - - function setTest3(arg) { number = arg } - function setTest4(arg) { model.number = arg } - function setTest5(arg) { modelData = arg } - function setTest6(arg) { model.modelData = arg } - - Item { - objectName: "delegate" - - Package.name: "package" - - width: 100 - height: 2 - } - } - } -} diff --git a/tests/auto/qtquick2/qquickvisualdatamodel/data/listmodelproperties.qml b/tests/auto/qtquick2/qquickvisualdatamodel/data/listmodelproperties.qml deleted file mode 100644 index d2dfc37e07..0000000000 --- a/tests/auto/qtquick2/qquickvisualdatamodel/data/listmodelproperties.qml +++ /dev/null @@ -1,45 +0,0 @@ -import QtQuick 2.0 - -ListView { - width: 100 - height: 100 - model: VisualDataModel { - id: visualModel - objectName: "visualModel" - - groups: [ - VisualDataGroup { id: visibleItems; objectName: "visibleItems"; name: "visible"; includeByDefault: true }, - VisualDataGroup { id: selectedItems; objectName: "selectedItems"; name: "selected" } - ] - - model: ListModel { - id: listModel - - ListElement { number: "one" } - ListElement { number: "two" } - ListElement { number: "three" } - ListElement { number: "four" } - } - - delegate: Item { - id: delegate - - objectName: "delegate" - - property variant test1: index - property variant test2: model.index - property variant test3: number - property variant test4: model.number - property variant test5: modelData - property variant test6: model.modelData - - function setTest3(arg) { number = arg } - function setTest4(arg) { model.number = arg } - function setTest5(arg) { modelData = arg } - function setTest6(arg) { model.modelData = arg } - - width: 100 - height: 2 - } - } -} diff --git a/tests/auto/qtquick2/qquickvisualdatamodel/data/modelproperties.qml b/tests/auto/qtquick2/qquickvisualdatamodel/data/modelproperties.qml deleted file mode 100644 index 73b766f1af..0000000000 --- a/tests/auto/qtquick2/qquickvisualdatamodel/data/modelproperties.qml +++ /dev/null @@ -1,21 +0,0 @@ -import QtQuick 2.0 - -ListView { - width: 100 - height: 100 - model: myModel - delegate: Item { - objectName: "delegate" - width: 100 - height: 2 - property variant test1: name - property variant test2: model.name - property variant test3: modelData - property variant test4: model.modelData - property variant test5: modelData.name - property variant test6: model - property variant test7: index - property variant test8: model.index - property variant test9: model.modelData.name - } -} diff --git a/tests/auto/qtquick2/qquickvisualdatamodel/data/modelproperties2.qml b/tests/auto/qtquick2/qquickvisualdatamodel/data/modelproperties2.qml deleted file mode 100644 index ea5c240b29..0000000000 --- a/tests/auto/qtquick2/qquickvisualdatamodel/data/modelproperties2.qml +++ /dev/null @@ -1,21 +0,0 @@ -import QtQuick 2.0 - -ListView { - width: 100 - height: 100 - model: myModel - delegate: Item { - objectName: "delegate" - property variant test1: display - property variant test2: model.display - property variant test3: modelData - property variant test4: model.modelData - property variant test5: modelData.display - property variant test6: model - property variant test7: index - property variant test8: model.index - property variant test9: model.modelData.display - width: 100 - height: 2 - } -} diff --git a/tests/auto/qtquick2/qquickvisualdatamodel/data/multipleroleproperties-package.qml b/tests/auto/qtquick2/qquickvisualdatamodel/data/multipleroleproperties-package.qml deleted file mode 100644 index 964ac426f8..0000000000 --- a/tests/auto/qtquick2/qquickvisualdatamodel/data/multipleroleproperties-package.qml +++ /dev/null @@ -1,46 +0,0 @@ -import QtQuick 2.0 -import tst_qquickvisualdatamodel 1.0 - -ListView { - width: 100 - height: 100 - model: visualModel.parts.package - VisualDataModel { - id: visualModel - objectName: "visualModel" - - groups: [ - VisualDataGroup { id: visibleItems; objectName: "visibleItems"; name: "visible"; includeByDefault: true }, - VisualDataGroup { id: selectedItems; objectName: "selectedItems"; name: "selected" } - ] - - model: StandardItemModel { - StandardItem { text: "Row 1 Item" } - StandardItem { text: "Row 2 Item" } - StandardItem { text: "Row 3 Item" } - StandardItem { text: "Row 4 Item" } - } - - delegate: Package { - id: delegate - - property variant test1: index - property variant test2: model.index - property variant test3: display - property variant test4: model.display - - function setTest3(arg) { display = arg } - function setTest4(arg) { model.display = arg } - - Item { - objectName: "delegate" - - width: 100 - height: 2 - - Package.name: "package" - } - } - } -} - diff --git a/tests/auto/qtquick2/qquickvisualdatamodel/data/multipleroleproperties.qml b/tests/auto/qtquick2/qquickvisualdatamodel/data/multipleroleproperties.qml deleted file mode 100644 index 77e30b69b9..0000000000 --- a/tests/auto/qtquick2/qquickvisualdatamodel/data/multipleroleproperties.qml +++ /dev/null @@ -1,41 +0,0 @@ -import QtQuick 2.0 -import tst_qquickvisualdatamodel 1.0 - -ListView { - width: 100 - height: 100 - model: VisualDataModel { - id: visualModel - objectName: "visualModel" - - groups: [ - VisualDataGroup { id: visibleItems; objectName: "visibleItems"; name: "visible"; includeByDefault: true }, - VisualDataGroup { id: selectedItems; objectName: "selectedItems"; name: "selected" } - ] - - model: StandardItemModel { - StandardItem { text: "Row 1 Item" } - StandardItem { text: "Row 2 Item" } - StandardItem { text: "Row 3 Item" } - StandardItem { text: "Row 4 Item" } - } - - delegate: Item { - id: delegate - - objectName: "delegate" - - property variant test1: index - property variant test2: model.index - property variant test3: display - property variant test4: model.display - - function setTest3(arg) { display = arg } - function setTest4(arg) { model.display = arg } - - width: 100 - height: 2 - } - } -} - diff --git a/tests/auto/qtquick2/qquickvisualdatamodel/data/objectlist.qml b/tests/auto/qtquick2/qquickvisualdatamodel/data/objectlist.qml deleted file mode 100644 index b3952a8a4d..0000000000 --- a/tests/auto/qtquick2/qquickvisualdatamodel/data/objectlist.qml +++ /dev/null @@ -1,19 +0,0 @@ -import QtQuick 2.0 - -ListView { - width: 100 - height: 100 - anchors.fill: parent - model: myModel - delegate: Component { - Rectangle { - height: 25 - width: 100 - color: model.modelData.color - Text { objectName: "name"; text: name; function getText() { return name } } - Text { objectName: "section"; text: parent.ListView.section } - } - } - section.property: "name" - section.criteria: ViewSection.FullString -} diff --git a/tests/auto/qtquick2/qquickvisualdatamodel/data/objectlistproperties-package.qml b/tests/auto/qtquick2/qquickvisualdatamodel/data/objectlistproperties-package.qml deleted file mode 100644 index c69e54c2f8..0000000000 --- a/tests/auto/qtquick2/qquickvisualdatamodel/data/objectlistproperties-package.qml +++ /dev/null @@ -1,48 +0,0 @@ -import QtQuick 2.0 -import tst_qquickvisualdatamodel 1.0 - -ListView { - width: 100 - height: 100 - model: visualModel.parts.package - - VisualDataModel { - id: visualModel - objectName: "visualModel" - - property list objects: [ - DataObject { name: "Item 1"; color: "red" }, - DataObject { name: "Item 2"; color: "green" }, - DataObject { name: "Item 3"; color: "blue"}, - DataObject { name: "Item 4"; color: "yellow" } - ] - - groups: [ - VisualDataGroup { id: visibleItems; objectName: "visibleItems"; name: "visible"; includeByDefault: true }, - VisualDataGroup { id: selectedItems; objectName: "selectedItems"; name: "selected" } - ] - - model: objects - - delegate: Package { - id: delegate - - property variant test1: index - property variant test2: model.index - property variant test3: name - property variant test4: model.name - - function setTest3(arg) { name = arg } - function setTest4(arg) { model.name = arg } - - Item { - objectName: "delegate" - - width: 100 - height: 2 - Package.name: "package" - } - } - } -} - diff --git a/tests/auto/qtquick2/qquickvisualdatamodel/data/objectlistproperties.qml b/tests/auto/qtquick2/qquickvisualdatamodel/data/objectlistproperties.qml deleted file mode 100644 index 0dbe2f5459..0000000000 --- a/tests/auto/qtquick2/qquickvisualdatamodel/data/objectlistproperties.qml +++ /dev/null @@ -1,43 +0,0 @@ -import QtQuick 2.0 -import tst_qquickvisualdatamodel 1.0 - -ListView { - width: 100 - height: 100 - model: VisualDataModel { - id: visualModel - objectName: "visualModel" - - property list objects: [ - DataObject { name: "Item 1"; color: "red" }, - DataObject { name: "Item 2"; color: "green" }, - DataObject { name: "Item 3"; color: "blue"}, - DataObject { name: "Item 4"; color: "yellow" } - ] - - groups: [ - VisualDataGroup { id: visibleItems; objectName: "visibleItems"; name: "visible"; includeByDefault: true }, - VisualDataGroup { id: selectedItems; objectName: "selectedItems"; name: "selected" } - ] - - model: objects - - delegate: Item { - id: delegate - - objectName: "delegate" - - property variant test1: index - property variant test2: model.index - property variant test3: name - property variant test4: model.name - - function setTest3(arg) { name = arg } - function setTest4(arg) { model.name = arg } - - width: 100 - height: 2 - } - } -} - diff --git a/tests/auto/qtquick2/qquickvisualdatamodel/data/onChanged.qml b/tests/auto/qtquick2/qquickvisualdatamodel/data/onChanged.qml deleted file mode 100644 index 71dc7d72d7..0000000000 --- a/tests/auto/qtquick2/qquickvisualdatamodel/data/onChanged.qml +++ /dev/null @@ -1,87 +0,0 @@ -import QtQuick 2.0 - -VisualDataModel { - id: vm - - property var inserted - property var removed - - Component.onCompleted: { - vm.inserted = [] - vm.removed = [] - vi.inserted = [] - vi.removed = [] - si.inserted = [] - si.removed = [] - } - - function verify(changes, indexes, counts, moveIds) { - if (changes.length != indexes.length - || changes.length != counts.length - || changes.length != moveIds.length) { - console.log("invalid length", changes.length, indexes.length, counts.length, moveIds.length) - return false - } - - var valid = true; - for (var i = 0; i < changes.length; ++i) { - if (changes[i].index != indexes[i]) { - console.log(i, "incorrect index. actual:", changes[i].index, "expected:", indexes[i]) - valid = false; - } - if (changes[i].count != counts[i]) { - console.log(i, "incorrect count. actual:", changes[i].count, "expected:", counts[i]) - valid = false; - } - if (changes[i].moveId != moveIds[i]) { - console.log(i, "incorrect moveId. actual:", changes[i].moveId, "expected:", moveIds[i]) - valid = false; - } - } - return valid - } - - groups: [ - VisualDataGroup { - id: vi; - - property var inserted - property var removed - - name: "visible" - includeByDefault: true - - onChanged: { - vi.inserted = inserted - vi.removed = removed - } - }, - VisualDataGroup { - id: si; - - property var inserted - property var removed - - name: "selected" - onChanged: { - si.inserted = inserted - si.removed = removed - } - } - ] - - model: ListModel { - id: listModel - ListElement { number: "one" } - ListElement { number: "two" } - ListElement { number: "three" } - ListElement { number: "four" } - } - - delegate: Item {} - - items.onChanged: { - vm.inserted = inserted - vm.removed = removed - } -} diff --git a/tests/auto/qtquick2/qquickvisualdatamodel/data/packageView.qml b/tests/auto/qtquick2/qquickvisualdatamodel/data/packageView.qml deleted file mode 100644 index 682f3833d1..0000000000 --- a/tests/auto/qtquick2/qquickvisualdatamodel/data/packageView.qml +++ /dev/null @@ -1,63 +0,0 @@ -import QtQuick 2.0 - -Item { - width: 240 - height: 320 - - Component { - id: myDelegate - - Package { - Rectangle { - id: leftWrapper - objectName: "wrapper" - Package.name: "left" - height: 20 - width: 120 - Text { - text: index - } - color: ListView.isCurrentItem ? "lightsteelblue" : "white" - } - Rectangle { - id: rightWrapper - objectName: "wrapper" - Package.name: "right" - height: 20 - width: 120 - Text { - text: index - } - color: ListView.isCurrentItem ? "lightsteelblue" : "white" - } - } - - } - - VisualDataModel { - id: visualModel - - delegate: myDelegate - model: testModel - } - - ListView { - id: leftList - objectName: "leftList" - anchors { - left: parent.left; top: parent.top; - right: parent.horizontalCenter; bottom: parent.bottom - } - model: visualModel.parts.left - } - - ListView { - id: rightList - objectName: "rightList" - anchors { - left: parent.horizontalCenter; top: parent.top; - right: parent.right; bottom: parent.bottom - } - model: visualModel.parts.right - } -} diff --git a/tests/auto/qtquick2/qquickvisualdatamodel/data/singlerole1.qml b/tests/auto/qtquick2/qquickvisualdatamodel/data/singlerole1.qml deleted file mode 100644 index c471893e1d..0000000000 --- a/tests/auto/qtquick2/qquickvisualdatamodel/data/singlerole1.qml +++ /dev/null @@ -1,10 +0,0 @@ -import QtQuick 2.0 - -ListView { - width: 100 - height: 100 - model: myModel - delegate: Component { - Text { objectName: "name"; text: name; function getText() { return name; } } - } -} diff --git a/tests/auto/qtquick2/qquickvisualdatamodel/data/singlerole2.qml b/tests/auto/qtquick2/qquickvisualdatamodel/data/singlerole2.qml deleted file mode 100644 index ab1798999d..0000000000 --- a/tests/auto/qtquick2/qquickvisualdatamodel/data/singlerole2.qml +++ /dev/null @@ -1,10 +0,0 @@ -import QtQuick 2.0 - -ListView { - width: 100 - height: 100 - model: myModel - delegate: Component { - Text { objectName: "name"; text: modelData; function getText() { return modelData } } - } -} diff --git a/tests/auto/qtquick2/qquickvisualdatamodel/data/singleroleproperties-package.qml b/tests/auto/qtquick2/qquickvisualdatamodel/data/singleroleproperties-package.qml deleted file mode 100644 index 910df816f3..0000000000 --- a/tests/auto/qtquick2/qquickvisualdatamodel/data/singleroleproperties-package.qml +++ /dev/null @@ -1,45 +0,0 @@ -import QtQuick 2.0 -import tst_qquickvisualdatamodel 1.0 - -ListView { - width: 100 - height: 100 - model: visualModel.parts.package - - VisualDataModel { - id: visualModel - objectName: "visualModel" - - groups: [ - VisualDataGroup { id: visibleItems; objectName: "visibleItems"; name: "visible"; includeByDefault: true }, - VisualDataGroup { id: selectedItems; objectName: "selectedItems"; name: "selected" } - ] - - model: SingleRoleModel {} - - delegate: Package { - id: delegate - - property variant test1: index - property variant test2: model.index - property variant test3: name - property variant test4: model.name - property variant test5: modelData - property variant test6: model.modelData - - - function setTest3(arg) { name = arg } - function setTest4(arg) { model.name = arg } - function setTest5(arg) { modelData = arg } - function setTest6(arg) { model.modelData = arg } - - Item { - objectName: "delegate" - width: 100 - height: 2 - Package.name: "package" - } - } - - } -} diff --git a/tests/auto/qtquick2/qquickvisualdatamodel/data/singleroleproperties.qml b/tests/auto/qtquick2/qquickvisualdatamodel/data/singleroleproperties.qml deleted file mode 100644 index 6133c61bc5..0000000000 --- a/tests/auto/qtquick2/qquickvisualdatamodel/data/singleroleproperties.qml +++ /dev/null @@ -1,39 +0,0 @@ -import QtQuick 2.0 -import tst_qquickvisualdatamodel 1.0 - -ListView { - width: 100 - height: 100 - model: VisualDataModel { - id: visualModel - objectName: "visualModel" - - groups: [ - VisualDataGroup { id: visibleItems; objectName: "visibleItems"; name: "visible"; includeByDefault: true }, - VisualDataGroup { id: selectedItems; objectName: "selectedItems"; name: "selected" } - ] - - model: SingleRoleModel {} - - delegate: Item { - id: delegate - - objectName: "delegate" - width: 100 - height: 2 - property variant test1: index - property variant test2: model.index - property variant test3: name - property variant test4: model.name - property variant test5: modelData - property variant test6: model.modelData - - - function setTest3(arg) { name = arg } - function setTest4(arg) { model.name = arg } - function setTest5(arg) { modelData = arg } - function setTest6(arg) { model.modelData = arg } - } - - } -} diff --git a/tests/auto/qtquick2/qquickvisualdatamodel/data/stringlistproperties-package.qml b/tests/auto/qtquick2/qquickvisualdatamodel/data/stringlistproperties-package.qml deleted file mode 100644 index d1a4604b77..0000000000 --- a/tests/auto/qtquick2/qquickvisualdatamodel/data/stringlistproperties-package.qml +++ /dev/null @@ -1,45 +0,0 @@ -import QtQuick 2.0 -import tst_qquickvisualdatamodel 1.0 - -ListView { - width: 100 - height: 100 - model: visualModel.parts.package - VisualDataModel { - id: visualModel - objectName: "visualModel" - - groups: [ - VisualDataGroup { id: visibleItems; objectName: "visibleItems"; name: "visible"; includeByDefault: true }, - VisualDataGroup { id: selectedItems; objectName: "selectedItems"; name: "selected" } - ] - - model: [ - "one", - "two", - "three", - "four" - ] - - delegate: Package { - id: delegate - - property variant test1: index - property variant test2: model.index - property variant test3: modelData - property variant test4: model.modelData - - function setTest3(arg) { modelData = arg } - function setTest4(arg) { model.modelData = arg } - - Item { - objectName: "delegate" - - width: 100 - height: 2 - - Package.name: "package" - } - } - } -} diff --git a/tests/auto/qtquick2/qquickvisualdatamodel/data/stringlistproperties.qml b/tests/auto/qtquick2/qquickvisualdatamodel/data/stringlistproperties.qml deleted file mode 100644 index a075ccb4d9..0000000000 --- a/tests/auto/qtquick2/qquickvisualdatamodel/data/stringlistproperties.qml +++ /dev/null @@ -1,40 +0,0 @@ -import QtQuick 2.0 -import tst_qquickvisualdatamodel 1.0 - -ListView { - width: 100 - height: 100 - model: VisualDataModel { - id: visualModel - objectName: "visualModel" - - groups: [ - VisualDataGroup { id: visibleItems; objectName: "visibleItems"; name: "visible"; includeByDefault: true }, - VisualDataGroup { id: selectedItems; objectName: "selectedItems"; name: "selected" } - ] - - model: [ - "one", - "two", - "three", - "four" - ] - - delegate: Item { - id: delegate - - objectName: "delegate" - - property variant test1: index - property variant test2: model.index - property variant test3: modelData - property variant test4: model.modelData - - function setTest3(arg) { modelData = arg } - function setTest4(arg) { model.modelData = arg } - - width: 100 - height: 2 - } - } -} diff --git a/tests/auto/qtquick2/qquickvisualdatamodel/data/visualdatamodel.qml b/tests/auto/qtquick2/qquickvisualdatamodel/data/visualdatamodel.qml deleted file mode 100644 index 0d4d9e2e46..0000000000 --- a/tests/auto/qtquick2/qquickvisualdatamodel/data/visualdatamodel.qml +++ /dev/null @@ -1,12 +0,0 @@ -import QtQuick 2.0 - -VisualDataModel { - function setRoot() { - rootIndex = modelIndex(0); - } - function setRootToParent() { - rootIndex = parentModelIndex(); - } - model: myModel - delegate: Item {} -} diff --git a/tests/auto/qtquick2/qquickvisualdatamodel/qquickvisualdatamodel.pro b/tests/auto/qtquick2/qquickvisualdatamodel/qquickvisualdatamodel.pro deleted file mode 100644 index 6db887d747..0000000000 --- a/tests/auto/qtquick2/qquickvisualdatamodel/qquickvisualdatamodel.pro +++ /dev/null @@ -1,16 +0,0 @@ -CONFIG += testcase -TARGET = tst_qquickvisualdatamodel -macx:CONFIG -= app_bundle - -SOURCES += tst_qquickvisualdatamodel.cpp - -include (../../shared/util.pri) -include (../shared/util.pri) - -testDataFiles.files = data -testDataFiles.path = . -DEPLOYMENT += testDataFiles - -CONFIG += parallel_test - -QT += core-private gui-private v8-private declarative-private quick-private widgets testlib diff --git a/tests/auto/qtquick2/qquickvisualdatamodel/tst_qquickvisualdatamodel.cpp b/tests/auto/qtquick2/qquickvisualdatamodel/tst_qquickvisualdatamodel.cpp deleted file mode 100644 index 1b6a7629d9..0000000000 --- a/tests/auto/qtquick2/qquickvisualdatamodel/tst_qquickvisualdatamodel.cpp +++ /dev/null @@ -1,3446 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include "../../shared/util.h" -#include "../shared/visualtestutil.h" - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -using namespace QQuickVisualTestUtil; - -template int lengthOf(const T (&)[N]) { return N; } - -static void initStandardTreeModel(QStandardItemModel *model) -{ - QStandardItem *item; - item = new QStandardItem(QLatin1String("Row 1 Item")); - model->insertRow(0, item); - - item = new QStandardItem(QLatin1String("Row 2 Item")); - item->setCheckable(true); - model->insertRow(1, item); - - QStandardItem *childItem = new QStandardItem(QLatin1String("Row 2 Child Item")); - item->setChild(0, childItem); - - item = new QStandardItem(QLatin1String("Row 3 Item")); - item->setIcon(QIcon()); - model->insertRow(2, item); -} - -class SingleRoleModel : public QAbstractListModel -{ - Q_OBJECT - Q_PROPERTY(QStringList values WRITE setList) -public: - SingleRoleModel(const QByteArray &role = "name", QObject *parent = 0) - : QAbstractListModel(parent) - { - QHash roles; - roles.insert(Qt::DisplayRole , role); - setRoleNames(roles); - list << "one" << "two" << "three" << "four"; - } - - void emitMove(int sourceFirst, int sourceLast, int destinationChild) { - emit beginMoveRows(QModelIndex(), sourceFirst, sourceLast, QModelIndex(), destinationChild); - emit endMoveRows(); - } - - QStringList list; - - void setList(const QStringList &l) { list = l; } - -public slots: - void set(int idx, QString string) { - list[idx] = string; - emit dataChanged(index(idx,0), index(idx,0)); - } - -protected: - int rowCount(const QModelIndex & /* parent */ = QModelIndex()) const { - return list.count(); - } - QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const { - if (role == Qt::DisplayRole) - return list.at(index.row()); - return QVariant(); - } -}; - -class StandardItem : public QObject, public QStandardItem -{ - Q_OBJECT - Q_PROPERTY(QString text WRITE setText) - -public: - void writeText(const QString &text) { setText(text); } -}; - -class StandardItemModel : public QStandardItemModel -{ - Q_OBJECT - Q_PROPERTY(QDeclarativeListProperty items READ items CONSTANT) - Q_CLASSINFO("DefaultProperty", "items") -public: - QDeclarativeListProperty items() { return QDeclarativeListProperty(this, 0, append); } - - static void append(QDeclarativeListProperty *property, StandardItem *item) - { - static_cast(property->object)->appendRow(item); - } -}; - -class DataObject : public QObject -{ - Q_OBJECT - - Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged) - Q_PROPERTY(QString color READ color WRITE setColor NOTIFY colorChanged) - -public: - DataObject(QObject *parent=0) : QObject(parent) {} - DataObject(const QString &name, const QString &color, QObject *parent=0) - : QObject(parent), m_name(name), m_color(color) { } - - - QString name() const { return m_name; } - void setName(const QString &name) { - if (name != m_name) { - m_name = name; - emit nameChanged(); - } - } - - QString color() const { return m_color; } - void setColor(const QString &color) { - if (color != m_color) { - m_color = color; - emit colorChanged(); - } - } - -signals: - void nameChanged(); - void colorChanged(); - -private: - QString m_name; - QString m_color; -}; - -QML_DECLARE_TYPE(SingleRoleModel) -QML_DECLARE_TYPE(StandardItem) -QML_DECLARE_TYPE(StandardItemModel) -QML_DECLARE_TYPE(DataObject) - -class tst_qquickvisualdatamodel : public QDeclarativeDataTest -{ - Q_OBJECT -public: - tst_qquickvisualdatamodel(); - -private slots: - void initTestCase(); - void cleanupTestCase(); - void rootIndex(); - void updateLayout_data(); - void updateLayout(); - void childChanged_data(); - void childChanged(); - void objectListModel(); - void singleRole(); - void modelProperties(); - void noDelegate_data(); - void noDelegate(); - void itemsDestroyed_data(); - void itemsDestroyed(); - void packagesDestroyed(); - void qaimRowsMoved(); - void qaimRowsMoved_data(); - void remove_data(); - void remove(); - void move_data(); - void move(); - void groups_data(); - void groups(); - void invalidGroups(); - void get(); - void onChanged_data(); - void onChanged(); - void create(); - void incompleteModel(); - void insert_data(); - void insert(); - void resolve_data(); - void resolve(); - void warnings_data(); - void warnings(); - -private: - template void groups_verify( - const SingleRoleModel &model, - QQuickItem *contentItem, - const int (&mIndex)[N], - const int (&iIndex)[N], - const int (&vIndex)[N], - const int (&sIndex)[N], - const bool (&vMember)[N], - const bool (&sMember)[N]); - - template void get_verify( - const SingleRoleModel &model, - QQuickVisualDataModel *visualModel, - QQuickVisualDataGroup *visibleItems, - QQuickVisualDataGroup *selectedItems, - const int (&mIndex)[N], - const int (&iIndex)[N], - const int (&vIndex)[N], - const int (&sIndex)[N], - const bool (&vMember)[N], - const bool (&sMember)[N]); - - bool failed; - QDeclarativeEngine engine; -}; - -Q_DECLARE_METATYPE(QDeclarativeChangeSet) - -template static T evaluate(QObject *scope, const QString &expression) -{ - QDeclarativeExpression expr(qmlContext(scope), scope, expression); - T result = expr.evaluate().value(); - if (expr.hasError()) - qWarning() << expr.error().toString(); - return result; -} - -template <> void evaluate(QObject *scope, const QString &expression) -{ - QDeclarativeExpression expr(qmlContext(scope), scope, expression); - expr.evaluate(); - if (expr.hasError()) - qWarning() << expr.error().toString(); -} - -void tst_qquickvisualdatamodel::initTestCase() -{ - QDeclarativeDataTest::initTestCase(); - qRegisterMetaType(); - - qmlRegisterType("tst_qquickvisualdatamodel", 1, 0, "SingleRoleModel"); - qmlRegisterType("tst_qquickvisualdatamodel", 1, 0, "StandardItem"); - qmlRegisterType("tst_qquickvisualdatamodel", 1, 0, "StandardItemModel"); - qmlRegisterType("tst_qquickvisualdatamodel", 1, 0, "DataObject"); -} - -void tst_qquickvisualdatamodel::cleanupTestCase() -{ - -} - -tst_qquickvisualdatamodel::tst_qquickvisualdatamodel() -{ -} - -void tst_qquickvisualdatamodel::rootIndex() -{ - QDeclarativeEngine engine; - QDeclarativeComponent c(&engine, testFileUrl("visualdatamodel.qml")); - - QStandardItemModel model; - initStandardTreeModel(&model); - - engine.rootContext()->setContextProperty("myModel", &model); - - QQuickVisualDataModel *obj = qobject_cast(c.create()); - QVERIFY(obj != 0); - - QMetaObject::invokeMethod(obj, "setRoot"); - QVERIFY(qvariant_cast(obj->rootIndex()) == model.index(0,0)); - - QMetaObject::invokeMethod(obj, "setRootToParent"); - QVERIFY(qvariant_cast(obj->rootIndex()) == QModelIndex()); - - QMetaObject::invokeMethod(obj, "setRoot"); - QVERIFY(qvariant_cast(obj->rootIndex()) == model.index(0,0)); - model.clear(); // will emit modelReset() - QVERIFY(qvariant_cast(obj->rootIndex()) == QModelIndex()); - - delete obj; -} - -void tst_qquickvisualdatamodel::updateLayout_data() -{ - QTest::addColumn("source"); - - QTest::newRow("item delegate") << testFileUrl("datalist.qml"); - QTest::newRow("package delegate") << testFileUrl("datalist-package.qml"); -} - -void tst_qquickvisualdatamodel::updateLayout() -{ - QFETCH(QUrl, source); - - QQuickView view; - - QStandardItemModel model; - initStandardTreeModel(&model); - - view.rootContext()->setContextProperty("myModel", &model); - - view.setSource(source); - - QQuickListView *listview = qobject_cast(view.rootObject()); - QVERIFY(listview != 0); - - QQuickItem *contentItem = listview->contentItem(); - QVERIFY(contentItem != 0); - - QQuickText *name = findItem(contentItem, "display", 0); - QVERIFY(name); - QCOMPARE(name->text(), QString("Row 1 Item")); - name = findItem(contentItem, "display", 1); - QVERIFY(name); - QCOMPARE(name->text(), QString("Row 2 Item")); - name = findItem(contentItem, "display", 2); - QVERIFY(name); - QCOMPARE(name->text(), QString("Row 3 Item")); - - model.invisibleRootItem()->sortChildren(0, Qt::DescendingOrder); - - name = findItem(contentItem, "display", 0); - QVERIFY(name); - QCOMPARE(name->text(), QString("Row 3 Item")); - name = findItem(contentItem, "display", 1); - QVERIFY(name); - QCOMPARE(name->text(), QString("Row 2 Item")); - name = findItem(contentItem, "display", 2); - QVERIFY(name); - QCOMPARE(name->text(), QString("Row 1 Item")); -} - -void tst_qquickvisualdatamodel::childChanged_data() -{ - QTest::addColumn("source"); - - QTest::newRow("item delegate") << testFileUrl("datalist.qml"); - QTest::newRow("package delegate") << testFileUrl("datalist-package.qml"); -} - -void tst_qquickvisualdatamodel::childChanged() -{ - QFETCH(QUrl, source); - - QQuickView view; - - QStandardItemModel model; - initStandardTreeModel(&model); - - view.rootContext()->setContextProperty("myModel", &model); - - view.setSource(source); - - QQuickListView *listview = qobject_cast(view.rootObject()); - QVERIFY(listview != 0); - - QQuickItem *contentItem = listview->contentItem(); - QVERIFY(contentItem != 0); - - QQuickVisualDataModel *vdm = listview->findChild("visualModel"); - vdm->setRootIndex(QVariant::fromValue(model.indexFromItem(model.item(1,0)))); - QCOMPARE(listview->count(), 1); - - QQuickText *name = findItem(contentItem, "display", 0); - QVERIFY(name); - QCOMPARE(name->text(), QString("Row 2 Child Item")); - - model.item(1,0)->child(0,0)->setText("Row 2 updated child"); - - name = findItem(contentItem, "display", 0); - QVERIFY(name); - QCOMPARE(name->text(), QString("Row 2 updated child")); - - model.item(1,0)->appendRow(new QStandardItem(QLatin1String("Row 2 Child Item 2"))); - QCOMPARE(listview->count(), 2); - - name = findItem(contentItem, "display", 1); - QVERIFY(name != 0); - QCOMPARE(name->text(), QString("Row 2 Child Item 2")); - - model.item(1,0)->takeRow(1); - name = findItem(contentItem, "display", 1); - QVERIFY(name == 0); - - vdm->setRootIndex(QVariant::fromValue(QModelIndex())); - QCOMPARE(listview->count(), 3); - name = findItem(contentItem, "display", 0); - QVERIFY(name); - QCOMPARE(name->text(), QString("Row 1 Item")); - name = findItem(contentItem, "display", 1); - QVERIFY(name); - QCOMPARE(name->text(), QString("Row 2 Item")); - name = findItem(contentItem, "display", 2); - QVERIFY(name); - QCOMPARE(name->text(), QString("Row 3 Item")); -} - -void tst_qquickvisualdatamodel::objectListModel() -{ - QQuickView view; - - QList dataList; - dataList.append(new DataObject("Item 1", "red")); - dataList.append(new DataObject("Item 2", "green")); - dataList.append(new DataObject("Item 3", "blue")); - dataList.append(new DataObject("Item 4", "yellow")); - - QDeclarativeContext *ctxt = view.rootContext(); - ctxt->setContextProperty("myModel", QVariant::fromValue(dataList)); - - view.setSource(testFileUrl("objectlist.qml")); - - QQuickListView *listview = qobject_cast(view.rootObject()); - QVERIFY(listview != 0); - - QQuickItem *contentItem = listview->contentItem(); - QVERIFY(contentItem != 0); - - QQuickText *name = findItem(contentItem, "name", 0); - QCOMPARE(name->text(), QString("Item 1")); - - QQuickText *section = findItem(contentItem, "section", 0); - QCOMPARE(section->text(), QString("Item 1")); - - dataList[0]->setProperty("name", QLatin1String("Changed")); - QCOMPARE(name->text(), QString("Changed")); -} - -void tst_qquickvisualdatamodel::singleRole() -{ - { - QQuickView view; - - SingleRoleModel model; - - QDeclarativeContext *ctxt = view.rootContext(); - ctxt->setContextProperty("myModel", &model); - - view.setSource(testFileUrl("singlerole1.qml")); - - QQuickListView *listview = qobject_cast(view.rootObject()); - QVERIFY(listview != 0); - - QQuickItem *contentItem = listview->contentItem(); - QVERIFY(contentItem != 0); - - QQuickText *name = findItem(contentItem, "name", 1); - QCOMPARE(name->text(), QString("two")); - - model.set(1, "Changed"); - QCOMPARE(name->text(), QString("Changed")); - } - { - QQuickView view; - - SingleRoleModel model; - - QDeclarativeContext *ctxt = view.rootContext(); - ctxt->setContextProperty("myModel", &model); - - view.setSource(testFileUrl("singlerole2.qml")); - - QQuickListView *listview = qobject_cast(view.rootObject()); - QVERIFY(listview != 0); - - QQuickItem *contentItem = listview->contentItem(); - QVERIFY(contentItem != 0); - - QQuickText *name = findItem(contentItem, "name", 1); - QCOMPARE(name->text(), QString("two")); - - model.set(1, "Changed"); - QCOMPARE(name->text(), QString("Changed")); - } - { - QQuickView view; - - SingleRoleModel model("modelData"); - - QDeclarativeContext *ctxt = view.rootContext(); - ctxt->setContextProperty("myModel", &model); - - view.setSource(testFileUrl("singlerole2.qml")); - - QQuickListView *listview = qobject_cast(view.rootObject()); - QVERIFY(listview != 0); - - QQuickItem *contentItem = listview->contentItem(); - QVERIFY(contentItem != 0); - - QQuickText *name = findItem(contentItem, "name", 1); - QCOMPARE(name->text(), QString("two")); - - model.set(1, "Changed"); - QCOMPARE(name->text(), QString("Changed")); - } -} - -void tst_qquickvisualdatamodel::modelProperties() -{ - { - QQuickView view; - - SingleRoleModel model; - - QDeclarativeContext *ctxt = view.rootContext(); - ctxt->setContextProperty("myModel", &model); - - view.setSource(testFileUrl("modelproperties.qml")); - - QQuickListView *listview = qobject_cast(view.rootObject()); - QVERIFY(listview != 0); - - QQuickItem *contentItem = listview->contentItem(); - QVERIFY(contentItem != 0); - - QQuickItem *delegate = findItem(contentItem, "delegate", 1); - QVERIFY(delegate); - QCOMPARE(delegate->property("test1").toString(),QString("two")); - QCOMPARE(delegate->property("test2").toString(),QString("two")); - QCOMPARE(delegate->property("test3").toString(),QString("two")); - QCOMPARE(delegate->property("test4").toString(),QString("two")); - QVERIFY(!delegate->property("test9").isValid()); - QCOMPARE(delegate->property("test5").toString(),QString("")); - QVERIFY(delegate->property("test6").value() != 0); - QCOMPARE(delegate->property("test7").toInt(),1); - QCOMPARE(delegate->property("test8").toInt(),1); - } - - { - QQuickView view; - - QList dataList; - dataList.append(new DataObject("Item 1", "red")); - dataList.append(new DataObject("Item 2", "green")); - dataList.append(new DataObject("Item 3", "blue")); - dataList.append(new DataObject("Item 4", "yellow")); - - QDeclarativeContext *ctxt = view.rootContext(); - ctxt->setContextProperty("myModel", QVariant::fromValue(dataList)); - - view.setSource(testFileUrl("modelproperties.qml")); - - QQuickListView *listview = qobject_cast(view.rootObject()); - QVERIFY(listview != 0); - - QQuickItem *contentItem = listview->contentItem(); - QVERIFY(contentItem != 0); - - QQuickItem *delegate = findItem(contentItem, "delegate", 1); - QVERIFY(delegate); - QCOMPARE(delegate->property("test1").toString(),QString("Item 2")); - QCOMPARE(delegate->property("test2").toString(),QString("Item 2")); - QVERIFY(qobject_cast(delegate->property("test3").value()) != 0); - QVERIFY(qobject_cast(delegate->property("test4").value()) != 0); - QCOMPARE(delegate->property("test5").toString(),QString("Item 2")); - QCOMPARE(delegate->property("test9").toString(),QString("Item 2")); - QVERIFY(delegate->property("test6").value() != 0); - QCOMPARE(delegate->property("test7").toInt(),1); - QCOMPARE(delegate->property("test8").toInt(),1); - } - - { - QQuickView view; - - QStandardItemModel model; - initStandardTreeModel(&model); - - view.rootContext()->setContextProperty("myModel", &model); - - QUrl source(testFileUrl("modelproperties2.qml")); - - //3 items, 3 i each - QTest::ignoreMessage(QtWarningMsg, source.toString().toLatin1() + ":13: ReferenceError: Can't find variable: modelData"); - QTest::ignoreMessage(QtWarningMsg, source.toString().toLatin1() + ":13: ReferenceError: Can't find variable: modelData"); - QTest::ignoreMessage(QtWarningMsg, source.toString().toLatin1() + ":13: ReferenceError: Can't find variable: modelData"); - QTest::ignoreMessage(QtWarningMsg, source.toString().toLatin1() + ":11: ReferenceError: Can't find variable: modelData"); - QTest::ignoreMessage(QtWarningMsg, source.toString().toLatin1() + ":11: ReferenceError: Can't find variable: modelData"); - QTest::ignoreMessage(QtWarningMsg, source.toString().toLatin1() + ":11: ReferenceError: Can't find variable: modelData"); - QTest::ignoreMessage(QtWarningMsg, source.toString().toLatin1() + ":17: TypeError: Cannot read property 'display' of undefined"); - QTest::ignoreMessage(QtWarningMsg, source.toString().toLatin1() + ":17: TypeError: Cannot read property 'display' of undefined"); - QTest::ignoreMessage(QtWarningMsg, source.toString().toLatin1() + ":17: TypeError: Cannot read property 'display' of undefined"); - - view.setSource(source); - - QQuickListView *listview = qobject_cast(view.rootObject()); - QVERIFY(listview != 0); - - QQuickItem *contentItem = listview->contentItem(); - QVERIFY(contentItem != 0); - - QQuickItem *delegate = findItem(contentItem, "delegate", 1); - QVERIFY(delegate); - QCOMPARE(delegate->property("test1").toString(),QString("Row 2 Item")); - QCOMPARE(delegate->property("test2").toString(),QString("Row 2 Item")); - QVERIFY(!delegate->property("test3").isValid()); - QVERIFY(!delegate->property("test4").isValid()); - QVERIFY(!delegate->property("test5").isValid()); - QVERIFY(!delegate->property("test9").isValid()); - QVERIFY(delegate->property("test6").value() != 0); - QCOMPARE(delegate->property("test7").toInt(),1); - QCOMPARE(delegate->property("test8").toInt(),1); - } - - //### should also test QStringList and QVariantList -} - -void tst_qquickvisualdatamodel::noDelegate_data() -{ - QTest::addColumn("source"); - - QTest::newRow("item delegate") << testFileUrl("datalist.qml"); - QTest::newRow("package delegate") << testFileUrl("datalist-package.qml"); -} - -void tst_qquickvisualdatamodel::noDelegate() -{ - QFETCH(QUrl, source); - - QQuickView view; - - QStandardItemModel model; - initStandardTreeModel(&model); - - view.rootContext()->setContextProperty("myModel", &model); - - view.setSource(source); - - QQuickListView *listview = qobject_cast(view.rootObject()); - QVERIFY(listview != 0); - - QQuickVisualDataModel *vdm = listview->findChild("visualModel"); - QVERIFY(vdm != 0); - QCOMPARE(vdm->count(), 3); - - vdm->setDelegate(0); - QCOMPARE(vdm->count(), 0); -} - -void tst_qquickvisualdatamodel::itemsDestroyed_data() -{ - QTest::addColumn("source"); - - QTest::newRow("listView") << testFileUrl("itemsDestroyed_listView.qml"); - QTest::newRow("package") << testFileUrl("itemsDestroyed_package.qml"); - QTest::newRow("pathView") << testFileUrl("itemsDestroyed_pathView.qml"); - QTest::newRow("repeater") << testFileUrl("itemsDestroyed_repeater.qml"); -} - -void tst_qquickvisualdatamodel::itemsDestroyed() -{ - QFETCH(QUrl, source); - - QDeclarativeGuard delegate; - - { - QQuickView view; - QStandardItemModel model; - initStandardTreeModel(&model); - view.rootContext()->setContextProperty("myModel", &model); - view.setSource(source); - - view.show(); - QTest::qWaitForWindowShown(&view); - - QVERIFY(delegate = findItem(view.rootItem(), "delegate", 1)); - } - QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete); - QVERIFY(!delegate); -} - -void tst_qquickvisualdatamodel::packagesDestroyed() -{ - SingleRoleModel model; - model.list.clear(); - for (int i=0; i<30; i++) - model.list << ("item " + i); - - QQuickView view; - view.rootContext()->setContextProperty("testModel", &model); - - QString filename(testFile("packageView.qml")); - view.setSource(QUrl::fromLocalFile(filename)); - - qApp->processEvents(); - - QQuickListView *leftview = findItem(view.rootObject(), "leftList"); - QTRY_VERIFY(leftview != 0); - - QQuickListView *rightview = findItem(view.rootObject(), "rightList"); - QTRY_VERIFY(rightview != 0); - - QQuickItem *leftContent = leftview->contentItem(); - QTRY_VERIFY(leftContent != 0); - - QQuickItem *rightContent = rightview->contentItem(); - QTRY_VERIFY(rightContent != 0); - - QCOMPARE(leftview->currentIndex(), 0); - QCOMPARE(rightview->currentIndex(), 0); - - rightview->setCurrentIndex(20); - QTRY_COMPARE(rightview->contentY(), 100.0); - - QDeclarativeGuard left; - QDeclarativeGuard right; - - QVERIFY(findItem(leftContent, "wrapper", 1)); - QVERIFY(findItem(rightContent, "wrapper", 1)); - - QVERIFY(left = findItem(leftContent, "wrapper", 19)); - QVERIFY(right = findItem(rightContent, "wrapper", 19)); - - rightview->setCurrentIndex(0); - QCOMPARE(rightview->currentIndex(), 0); - - QTRY_COMPARE(rightview->contentY(), 0.0); - QCoreApplication::sendPostedEvents(); - - QVERIFY(!left); - QVERIFY(!right); - - QVERIFY(left = findItem(leftContent, "wrapper", 1)); - QVERIFY(right = findItem(rightContent, "wrapper", 1)); - - rightview->setCurrentIndex(20); - QTRY_COMPARE(rightview->contentY(), 100.0); - - QVERIFY(left); - QVERIFY(right); - - QVERIFY(findItem(leftContent, "wrapper", 19)); - QVERIFY(findItem(rightContent, "wrapper", 19)); - - leftview->setCurrentIndex(20); - QTRY_COMPARE(leftview->contentY(), 100.0); - - QVERIFY(!left); - QVERIFY(!right); -} - -void tst_qquickvisualdatamodel::qaimRowsMoved() -{ - // Test parameters passed in QAIM::rowsMoved() signal are converted correctly - // when translated and emitted as the QListModelInterface::itemsMoved() signal - QFETCH(int, sourceFirst); - QFETCH(int, sourceLast); - QFETCH(int, destinationChild); - QFETCH(int, expectFrom); - QFETCH(int, expectTo); - QFETCH(int, expectCount); - - QDeclarativeEngine engine; - QDeclarativeComponent c(&engine, testFileUrl("visualdatamodel.qml")); - - SingleRoleModel model; - model.list.clear(); - for (int i=0; i<30; i++) - model.list << ("item " + i); - engine.rootContext()->setContextProperty("myModel", &model); - - QQuickVisualDataModel *obj = qobject_cast(c.create()); - QVERIFY(obj != 0); - - QSignalSpy spy(obj, SIGNAL(modelUpdated(QDeclarativeChangeSet,bool))); - model.emitMove(sourceFirst, sourceLast, destinationChild); - QCOMPARE(spy.count(), 1); - - QCOMPARE(spy[0].count(), 2); - QDeclarativeChangeSet changeSet = spy[0][0].value(); - QCOMPARE(changeSet.removes().count(), 1); - QCOMPARE(changeSet.removes().at(0).index, expectFrom); - QCOMPARE(changeSet.removes().at(0).count, expectCount); - QCOMPARE(changeSet.inserts().count(), 1); - QCOMPARE(changeSet.inserts().at(0).index, expectTo); - QCOMPARE(changeSet.inserts().at(0).count, expectCount); - QCOMPARE(changeSet.removes().at(0).moveId, changeSet.inserts().at(0).moveId); - QCOMPARE(spy[0][1].toBool(), false); - - delete obj; -} - -void tst_qquickvisualdatamodel::qaimRowsMoved_data() -{ - QTest::addColumn("sourceFirst"); - QTest::addColumn("sourceLast"); - QTest::addColumn("destinationChild"); - QTest::addColumn("expectFrom"); - QTest::addColumn("expectTo"); - QTest::addColumn("expectCount"); - - QTest::newRow("move 1 forward") - << 1 << 1 << 6 - << 1 << 5 << 1; - - QTest::newRow("move 1 backwards") - << 4 << 4 << 1 - << 4 << 1 << 1; - - QTest::newRow("move multiple forwards") - << 0 << 2 << 13 - << 0 << 10 << 3; - - QTest::newRow("move multiple forwards, with same to") - << 0 << 1 << 3 - << 0 << 1 << 2; - - QTest::newRow("move multiple backwards") - << 10 << 14 << 1 - << 10 << 1 << 5; -} - -void tst_qquickvisualdatamodel::remove_data() -{ - QTest::addColumn("source"); - QTest::addColumn("package delegate"); - - QTest::newRow("item delegate") - << testFileUrl("groups.qml") - << QString(); - QTest::newRow("package") - << testFileUrl("groups-package.qml") - << QString("package."); -} - -void tst_qquickvisualdatamodel::remove() -{ - QQuickView view; - - SingleRoleModel model; - model.list = QStringList() - << "one" - << "two" - << "three" - << "four" - << "five" - << "six" - << "seven" - << "eight" - << "nine" - << "ten" - << "eleven" - << "twelve"; - - QDeclarativeContext *ctxt = view.rootContext(); - ctxt->setContextProperty("myModel", &model); - - view.setSource(testFileUrl("groups.qml")); - - QQuickListView *listview = qobject_cast(view.rootObject()); - QVERIFY(listview != 0); - - QQuickItem *contentItem = listview->contentItem(); - QVERIFY(contentItem != 0); - - QQuickVisualDataModel *visualModel = qobject_cast(qvariant_cast(listview->model())); - QVERIFY(visualModel); - - { - QCOMPARE(listview->count(), 12); - QCOMPARE(visualModel->items()->count(), 12); - static const int mIndex[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11 }; - static const int iIndex[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11 }; - - for (int i = 0; i < lengthOf(mIndex); ++i) { - QQuickItem *delegate = findItem(contentItem, "delegate", mIndex[i]); - QVERIFY(delegate); - QCOMPARE(delegate->property("test1").toString(), model.list.at(mIndex[i])); - QCOMPARE(delegate->property("test2").toInt(), mIndex[i]); - QCOMPARE(delegate->property("test3").toInt(), iIndex[i]); - } - } { - evaluate(visualModel, "items.remove(2)"); - QCOMPARE(listview->count(), 11); - QCOMPARE(visualModel->items()->count(), 11); - static const int mIndex[] = { 0, 1, 3, 4, 5, 6, 7, 8, 9,10,11 }; - static const int iIndex[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10 }; - - for (int i = 0; i < lengthOf(mIndex); ++i) { - QQuickItem *delegate = findItem(contentItem, "delegate", mIndex[i]); - QVERIFY(delegate); - QCOMPARE(delegate->property("test1").toString(), model.list.at(mIndex[i])); - QCOMPARE(delegate->property("test2").toInt(), mIndex[i]); - QCOMPARE(delegate->property("test3").toInt(), iIndex[i]); - } - } { - evaluate(visualModel, "items.remove(1, 4)"); - QCOMPARE(listview->count(), 7); - QCOMPARE(visualModel->items()->count(), 7); - static const int mIndex[] = { 0, 6, 7, 8, 9,10,11 }; - static const int iIndex[] = { 0, 1, 2, 3, 4, 5, 6 }; - - for (int i = 0; i < lengthOf(mIndex); ++i) { - QQuickItem *delegate = findItem(contentItem, "delegate", mIndex[i]); - QVERIFY(delegate); - QCOMPARE(delegate->property("test1").toString(), model.list.at(mIndex[i])); - QCOMPARE(delegate->property("test2").toInt(), mIndex[i]); - QCOMPARE(delegate->property("test3").toInt(), iIndex[i]); - } - } { - QTest::ignoreMessage(QtWarningMsg, ": QML VisualDataGroup: remove: index out of range"); - evaluate(visualModel, "items.remove(-8, 4)"); - QCOMPARE(listview->count(), 7); - QCOMPARE(visualModel->items()->count(), 7); - } { - QTest::ignoreMessage(QtWarningMsg, ": QML VisualDataGroup: remove: index out of range"); - evaluate(visualModel, "items.remove(12, 2)"); - QCOMPARE(listview->count(), 7); - QCOMPARE(visualModel->items()->count(), 7); - } { - QTest::ignoreMessage(QtWarningMsg, ": QML VisualDataGroup: remove: invalid count"); - evaluate(visualModel, "items.remove(5, 3)"); - QCOMPARE(listview->count(), 7); - QCOMPARE(visualModel->items()->count(), 7); - } { - QTest::ignoreMessage(QtWarningMsg, ": QML VisualDataGroup: remove: invalid count"); - evaluate(visualModel, "items.remove(5, -2)"); - QCOMPARE(listview->count(), 7); - QCOMPARE(visualModel->items()->count(), 7); - } -} - -void tst_qquickvisualdatamodel::move_data() -{ - QTest::addColumn("source"); - QTest::addColumn("package delegate"); - - QTest::newRow("item delegate") - << testFileUrl("groups.qml") - << QString(); - QTest::newRow("package") - << testFileUrl("groups-package.qml") - << QString("package."); -} - -void tst_qquickvisualdatamodel::move() -{ - QQuickView view; - - SingleRoleModel model; - model.list = QStringList() - << "one" - << "two" - << "three" - << "four" - << "five" - << "six" - << "seven" - << "eight" - << "nine" - << "ten" - << "eleven" - << "twelve"; - - QDeclarativeContext *ctxt = view.rootContext(); - ctxt->setContextProperty("myModel", &model); - - view.setSource(testFileUrl("groups.qml")); - - QQuickListView *listview = qobject_cast(view.rootObject()); - QVERIFY(listview != 0); - - QQuickItem *contentItem = listview->contentItem(); - QVERIFY(contentItem != 0); - - QQuickVisualDataModel *visualModel = qobject_cast(qvariant_cast(listview->model())); - QVERIFY(visualModel); - - { - QCOMPARE(listview->count(), 12); - QCOMPARE(visualModel->items()->count(), 12); - static const int mIndex[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11 }; - static const int iIndex[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11 }; - - for (int i = 0; i < lengthOf(mIndex); ++i) { - QQuickItem *delegate = findItem(contentItem, "delegate", mIndex[i]); - QVERIFY(delegate); - QCOMPARE(delegate->property("test1").toString(), model.list.at(mIndex[i])); - QCOMPARE(delegate->property("test2").toInt(), mIndex[i]); - QCOMPARE(delegate->property("test3").toInt(), iIndex[i]); - } - } { - evaluate(visualModel, "items.move(2, 4)"); - QCOMPARE(listview->count(), 12); - QCOMPARE(visualModel->items()->count(), 12); - static const int mIndex[] = { 0, 1, 3, 4, 2, 5, 6, 7, 8, 9,10,11 }; - static const int iIndex[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11 }; - - for (int i = 0; i < lengthOf(mIndex); ++i) { - QQuickItem *delegate = findItem(contentItem, "delegate", mIndex[i]); - QVERIFY(delegate); - QCOMPARE(delegate->property("test1").toString(), model.list.at(mIndex[i])); - QCOMPARE(delegate->property("test2").toInt(), mIndex[i]); - QCOMPARE(delegate->property("test3").toInt(), iIndex[i]); - } - } { - evaluate(visualModel, "items.move(4, 2)"); - QCOMPARE(listview->count(), 12); - QCOMPARE(visualModel->items()->count(), 12); - static const int mIndex[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11 }; - static const int iIndex[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11 }; - - for (int i = 0; i < lengthOf(mIndex); ++i) { - QQuickItem *delegate = findItem(contentItem, "delegate", mIndex[i]); - QVERIFY(delegate); - QCOMPARE(delegate->property("test1").toString(), model.list.at(mIndex[i])); - QCOMPARE(delegate->property("test2").toInt(), mIndex[i]); - QCOMPARE(delegate->property("test3").toInt(), iIndex[i]); - } - } { - evaluate(visualModel, "items.move(8, 0, 4)"); - QCOMPARE(listview->count(), 12); - QCOMPARE(visualModel->items()->count(), 12); - static const int mIndex[] = { 8, 9,10,11, 0, 1, 2, 3, 4, 5, 6, 7 }; - static const int iIndex[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11 }; - - for (int i = 0; i < lengthOf(mIndex); ++i) { - QQuickItem *delegate = findItem(contentItem, "delegate", mIndex[i]); - QVERIFY(delegate); - QCOMPARE(delegate->property("test1").toString(), model.list.at(mIndex[i])); - QCOMPARE(delegate->property("test2").toInt(), mIndex[i]); - QCOMPARE(delegate->property("test3").toInt(), iIndex[i]); - } - } { - evaluate(visualModel, "items.move(3, 4, 5)"); - QCOMPARE(listview->count(), 12); - QCOMPARE(visualModel->items()->count(), 12); - static const int mIndex[] = { 8, 9,10,4, 11, 0, 1, 2, 3, 5, 6, 7 }; - static const int iIndex[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11 }; - - for (int i = 0; i < lengthOf(mIndex); ++i) { - QQuickItem *delegate = findItem(contentItem, "delegate", mIndex[i]); - QVERIFY(delegate); - QCOMPARE(delegate->property("test1").toString(), model.list.at(mIndex[i])); - QCOMPARE(delegate->property("test2").toInt(), mIndex[i]); - QCOMPARE(delegate->property("test3").toInt(), iIndex[i]); - } - } { - QTest::ignoreMessage(QtWarningMsg, ": QML VisualDataGroup: move: invalid count"); - evaluate(visualModel, "items.move(5, 2, -2)"); - QCOMPARE(listview->count(), 12); - QCOMPARE(visualModel->items()->count(), 12); - } { - QTest::ignoreMessage(QtWarningMsg, ": QML VisualDataGroup: move: from index out of range"); - evaluate(visualModel, "items.move(-6, 2, 1)"); - QCOMPARE(listview->count(), 12); - QCOMPARE(visualModel->items()->count(), 12); - } { - QTest::ignoreMessage(QtWarningMsg, ": QML VisualDataGroup: move: from index out of range"); - evaluate(visualModel, "items.move(15, 2, 1)"); - QCOMPARE(listview->count(), 12); - QCOMPARE(visualModel->items()->count(), 12); - } { - QTest::ignoreMessage(QtWarningMsg, ": QML VisualDataGroup: move: from index out of range"); - evaluate(visualModel, "items.move(11, 1, 3)"); - QCOMPARE(listview->count(), 12); - QCOMPARE(visualModel->items()->count(), 12); - } { - QTest::ignoreMessage(QtWarningMsg, ": QML VisualDataGroup: move: to index out of range"); - evaluate(visualModel, "items.move(2, -5, 1)"); - QCOMPARE(listview->count(), 12); - QCOMPARE(visualModel->items()->count(), 12); - } { - QTest::ignoreMessage(QtWarningMsg, ": QML VisualDataGroup: move: to index out of range"); - evaluate(visualModel, "items.move(2, 14, 1)"); - QCOMPARE(listview->count(), 12); - QCOMPARE(visualModel->items()->count(), 12); - } { - QTest::ignoreMessage(QtWarningMsg, ": QML VisualDataGroup: move: to index out of range"); - evaluate(visualModel, "items.move(2, 11, 4)"); - QCOMPARE(listview->count(), 12); - QCOMPARE(visualModel->items()->count(), 12); - } -} - -void tst_qquickvisualdatamodel::groups_data() -{ - QTest::addColumn("source"); - QTest::addColumn("part"); - - QTest::newRow("item delegate") - << testFileUrl("groups.qml") - << QString(); - QTest::newRow("package") - << testFileUrl("groups-package.qml") - << QString("visualModel.parts.package."); -} - -template void tst_qquickvisualdatamodel::groups_verify( - const SingleRoleModel &model, - QQuickItem *contentItem, - const int (&mIndex)[N], - const int (&iIndex)[N], - const int (&vIndex)[N], - const int (&sIndex)[N], - const bool (&vMember)[N], - const bool (&sMember)[N]) -{ - failed = true; - for (int i = 0; i < N; ++i) { - QQuickItem *delegate = findItem(contentItem, "delegate", mIndex[i]); - QVERIFY(delegate); - QCOMPARE(evaluate(delegate, "test1"), model.list.at(mIndex[i])); - QCOMPARE(evaluate(delegate, "test2") , mIndex[i]); - QCOMPARE(evaluate(delegate, "test3") , iIndex[i]); - QCOMPARE(evaluate(delegate, "test4"), true); - QCOMPARE(evaluate(delegate, "test5") , vIndex[i]); - QCOMPARE(evaluate(delegate, "test6"), vMember[i]); - QCOMPARE(evaluate(delegate, "test7") , sIndex[i]); - QCOMPARE(evaluate(delegate, "test8"), sMember[i]); - QCOMPARE(evaluate(delegate, "test9").contains("items") , bool(true)); - QCOMPARE(evaluate(delegate, "test9").contains("visible") , bool(vMember[i])); - QCOMPARE(evaluate(delegate, "test9").contains("selected"), bool(sMember[i])); - } - failed = false; -} - -#define VERIFY_GROUPS \ - groups_verify(model, contentItem, mIndex, iIndex, vIndex, sIndex, vMember, sMember); \ - QVERIFY(!failed) - - -void tst_qquickvisualdatamodel::groups() -{ - QFETCH(QUrl, source); - QFETCH(QString, part); - - QQuickView view; - - SingleRoleModel model; - model.list = QStringList() - << "one" - << "two" - << "three" - << "four" - << "five" - << "six" - << "seven" - << "eight" - << "nine" - << "ten" - << "eleven" - << "twelve"; - - QDeclarativeContext *ctxt = view.rootContext(); - ctxt->setContextProperty("myModel", &model); - - view.setSource(source); - - QQuickListView *listview = qobject_cast(view.rootObject()); - QVERIFY(listview != 0); - - QQuickItem *contentItem = listview->contentItem(); - QVERIFY(contentItem != 0); - - QQuickVisualDataModel *visualModel = listview->findChild("visualModel"); - QVERIFY(visualModel); - - QQuickVisualDataGroup *visibleItems = listview->findChild("visibleItems"); - QVERIFY(visibleItems); - - QQuickVisualDataGroup *selectedItems = listview->findChild("selectedItems"); - QVERIFY(selectedItems); - - const bool f = false; - const bool t = true; - - { - QCOMPARE(listview->count(), 12); - QCOMPARE(visualModel->items()->count(), 12); - QCOMPARE(visibleItems->count(), 12); - QCOMPARE(selectedItems->count(), 0); - static const int mIndex [] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11 }; - static const int iIndex [] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11 }; - static const int vIndex [] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11 }; - static const bool vMember[] = { t, t, t, t, t, t, t, t, t, t, t, t }; - static const int sIndex [] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; - static const bool sMember[] = { f, f, f, f, f, f, f, f, f, f, f, f }; - VERIFY_GROUPS; - } { - evaluate(visualModel, "items.addGroups(8, \"selected\")"); - QCOMPARE(listview->count(), 12); - QCOMPARE(visualModel->items()->count(), 12); - QCOMPARE(visibleItems->count(), 12); - QCOMPARE(selectedItems->count(), 1); - static const int mIndex [] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11 }; - static const int iIndex [] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11 }; - static const int vIndex [] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11 }; - static const bool vMember[] = { t, t, t, t, t, t, t, t, t, t, t, t }; - static const int sIndex [] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1 }; - static const bool sMember[] = { f, f, f, f, f, f, f, f, t, f, f, f }; - VERIFY_GROUPS; - } { - evaluate(visualModel, "items.addGroups(6, 4, [\"visible\", \"selected\"])"); - QCOMPARE(listview->count(), 12); - QCOMPARE(visualModel->items()->count(), 12); - QCOMPARE(visibleItems->count(), 12); - QCOMPARE(selectedItems->count(), 4); - static const int mIndex [] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11 }; - static const int iIndex [] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11 }; - static const int vIndex [] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11 }; - static const bool vMember[] = { t, t, t, t, t, t, t, t, t, t, t, t }; - static const int sIndex [] = { 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 4, 4 }; - static const bool sMember[] = { f, f, f, f, f, f, t, t, t, t, f, f }; - VERIFY_GROUPS; - } { - evaluate(visualModel, "items.setGroups(2, [\"items\", \"selected\"])"); - QCOMPARE(listview->count(), 12); - QCOMPARE(visualModel->items()->count(), 12); - QCOMPARE(visibleItems->count(), 11); - QCOMPARE(selectedItems->count(), 5); - static const int mIndex [] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11 }; - static const int iIndex [] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11 }; - static const int vIndex [] = { 0, 1, 2, 2, 3, 4, 5, 6, 7, 8, 9,10 }; - static const bool vMember[] = { t, t, f, t, t, t, t, t, t, t, t, t }; - static const int sIndex [] = { 0, 0, 0, 1, 1, 1, 1, 2, 3, 4, 5, 5 }; - static const bool sMember[] = { f, f, t, f, f, f, t, t, t, t, f, f }; - VERIFY_GROUPS; - } { - evaluate(selectedItems, "setGroups(0, 3, \"items\")"); - QCOMPARE(listview->count(), 12); - QCOMPARE(visualModel->items()->count(), 12); - QCOMPARE(visibleItems->count(), 9); - QCOMPARE(selectedItems->count(), 2); - static const int mIndex [] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11 }; - static const int iIndex [] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11 }; - static const int vIndex [] = { 0, 1, 2, 2, 3, 4, 5, 5, 5, 6, 7, 8 }; - static const bool vMember[] = { t, t, f, t, t, t, f, f, t, t, t, t }; - static const int sIndex [] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 2 }; - static const bool sMember[] = { f, f, f, f, f, f, f, f, t, t, f, f }; - VERIFY_GROUPS; - } { - QTest::ignoreMessage(QtWarningMsg, ": QML VisualDataGroup: addGroups: invalid count"); - evaluate(visualModel, "items.addGroups(11, -4, \"items\")"); - QCOMPARE(listview->count(), 12); - QCOMPARE(visualModel->items()->count(), 12); - QCOMPARE(visibleItems->count(), 9); - QCOMPARE(selectedItems->count(), 2); - } { - QTest::ignoreMessage(QtWarningMsg, ": QML VisualDataGroup: addGroups: index out of range"); - evaluate(visualModel, "items.addGroups(-1, 3, \"items\")"); - QCOMPARE(listview->count(), 12); - QCOMPARE(visualModel->items()->count(), 12); - QCOMPARE(visibleItems->count(), 9); - QCOMPARE(selectedItems->count(), 2); - } { - QTest::ignoreMessage(QtWarningMsg, ": QML VisualDataGroup: addGroups: index out of range"); - evaluate(visualModel, "items.addGroups(14, 3, \"items\")"); - QCOMPARE(listview->count(), 12); - QCOMPARE(visualModel->items()->count(), 12); - QCOMPARE(visibleItems->count(), 9); - QCOMPARE(selectedItems->count(), 2); - } { - QTest::ignoreMessage(QtWarningMsg, ": QML VisualDataGroup: addGroups: invalid count"); - evaluate(visualModel, "items.addGroups(11, 5, \"items\")"); - QCOMPARE(listview->count(), 12); - QCOMPARE(visualModel->items()->count(), 12); - QCOMPARE(visibleItems->count(), 9); - QCOMPARE(selectedItems->count(), 2); - } { - QTest::ignoreMessage(QtWarningMsg, ": QML VisualDataGroup: setGroups: invalid count"); - evaluate(visualModel, "items.setGroups(11, -4, \"items\")"); - QCOMPARE(listview->count(), 12); - QCOMPARE(visualModel->items()->count(), 12); - QCOMPARE(visibleItems->count(), 9); - QCOMPARE(selectedItems->count(), 2); - } { - QTest::ignoreMessage(QtWarningMsg, ": QML VisualDataGroup: setGroups: index out of range"); - evaluate(visualModel, "items.setGroups(-1, 3, \"items\")"); - QCOMPARE(listview->count(), 12); - QCOMPARE(visualModel->items()->count(), 12); - QCOMPARE(visibleItems->count(), 9); - QCOMPARE(selectedItems->count(), 2); - } { - QTest::ignoreMessage(QtWarningMsg, ": QML VisualDataGroup: setGroups: index out of range"); - evaluate(visualModel, "items.setGroups(14, 3, \"items\")"); - QCOMPARE(listview->count(), 12); - QCOMPARE(visualModel->items()->count(), 12); - QCOMPARE(visibleItems->count(), 9); - QCOMPARE(selectedItems->count(), 2); - } { - QTest::ignoreMessage(QtWarningMsg, ": QML VisualDataGroup: setGroups: invalid count"); - evaluate(visualModel, "items.setGroups(11, 5, \"items\")"); - QCOMPARE(listview->count(), 12); - QCOMPARE(visualModel->items()->count(), 12); - QCOMPARE(visibleItems->count(), 9); - QCOMPARE(selectedItems->count(), 2); - } { - QTest::ignoreMessage(QtWarningMsg, ": QML VisualDataGroup: removeGroups: invalid count"); - evaluate(visualModel, "items.removeGroups(11, -4, \"items\")"); - QCOMPARE(listview->count(), 12); - QCOMPARE(visualModel->items()->count(), 12); - } { - QTest::ignoreMessage(QtWarningMsg, ": QML VisualDataGroup: removeGroups: index out of range"); - evaluate(visualModel, "items.removeGroups(-1, 3, \"items\")"); - QCOMPARE(listview->count(), 12); - QCOMPARE(visualModel->items()->count(), 12); - QCOMPARE(visibleItems->count(), 9); - QCOMPARE(selectedItems->count(), 2); - } { - QTest::ignoreMessage(QtWarningMsg, ": QML VisualDataGroup: removeGroups: index out of range"); - evaluate(visualModel, "items.removeGroups(14, 3, \"items\")"); - QCOMPARE(listview->count(), 12); - QCOMPARE(visualModel->items()->count(), 12); - QCOMPARE(visibleItems->count(), 9); - QCOMPARE(selectedItems->count(), 2); - } { - QTest::ignoreMessage(QtWarningMsg, ": QML VisualDataGroup: removeGroups: invalid count"); - evaluate(visualModel, "items.removeGroups(11, 5, \"items\")"); - QCOMPARE(listview->count(), 12); - QCOMPARE(visualModel->items()->count(), 12); - QCOMPARE(visibleItems->count(), 9); - QCOMPARE(selectedItems->count(), 2); - } { - evaluate(visualModel, part + "filterOnGroup = \"visible\""); - QCOMPARE(listview->count(), 9); - QCOMPARE(visualModel->items()->count(), 12); - QCOMPARE(visibleItems->count(), 9); - QCOMPARE(selectedItems->count(), 2); - QCOMPARE(evaluate(visualModel, part + "filterOnGroup"), QString("visible")); - } { - evaluate(visualModel, part + "filterOnGroup = \"selected\""); - QCOMPARE(listview->count(), 2); - QCOMPARE(visualModel->items()->count(), 12); - QCOMPARE(visibleItems->count(), 9); - QCOMPARE(selectedItems->count(), 2); - QCOMPARE(evaluate(visualModel, part + "filterOnGroup"), QString("selected")); - } { - evaluate(visualModel, part + "filterOnGroup = undefined"); - QCOMPARE(listview->count(), 12); - QCOMPARE(visualModel->items()->count(), 12); - QCOMPARE(visibleItems->count(), 9); - QCOMPARE(selectedItems->count(), 2); - QCOMPARE(evaluate(visualModel, part + "filterOnGroup"), QString("items")); - } { - QQuickItem *delegate = findItem(contentItem, "delegate", 5); - QVERIFY(delegate); - - evaluate(delegate, "hide()"); - QCOMPARE(listview->count(), 12); - QCOMPARE(visualModel->items()->count(), 12); - QCOMPARE(visibleItems->count(), 8); - QCOMPARE(selectedItems->count(), 2); - static const int mIndex [] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11 }; - static const int iIndex [] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11 }; - static const int vIndex [] = { 0, 1, 2, 2, 3, 4, 4, 4, 4, 5, 6, 7 }; - static const bool vMember[] = { t, t, f, t, t, f, f, f, t, t, t, t }; - static const int sIndex [] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 2 }; - static const bool sMember[] = { f, f, f, f, f, f, f, f, t, t, f, f }; - VERIFY_GROUPS; - } { - QQuickItem *delegate = findItem(contentItem, "delegate", 5); - QVERIFY(delegate); - - evaluate(delegate, "select()"); - QCOMPARE(listview->count(), 12); - QCOMPARE(visualModel->items()->count(), 12); - QCOMPARE(visibleItems->count(), 8); - QCOMPARE(selectedItems->count(), 3); - static const int mIndex [] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11 }; - static const int iIndex [] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11 }; - static const int vIndex [] = { 0, 1, 2, 2, 3, 4, 4, 4, 4, 5, 6, 7 }; - static const bool vMember[] = { t, t, f, t, t, f, f, f, t, t, t, t }; - static const int sIndex [] = { 0, 0, 0, 0, 0, 0, 1, 1, 1, 2, 3, 3 }; - static const bool sMember[] = { f, f, f, f, f, t, f, f, t, t, f, f }; - VERIFY_GROUPS; - } { - evaluate(visualModel, "items.move(2, 6, 3)"); - QCOMPARE(listview->count(), 12); - QCOMPARE(visualModel->items()->count(), 12); - QCOMPARE(visibleItems->count(), 8); - QCOMPARE(selectedItems->count(), 3); - static const int mIndex [] = { 0, 1, 5, 6, 7, 8, 2, 3, 4, 9,10,11 }; - static const int iIndex [] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11 }; - static const int vIndex [] = { 0, 1, 2, 2, 2, 2, 3, 3, 4, 5, 6, 7 }; - static const bool vMember[] = { t, t, f, f, f, t, f, t, t, t, t, t }; - static const int sIndex [] = { 0, 0, 0, 1, 1, 1, 2, 2, 2, 2, 3, 3 }; - static const bool sMember[] = { f, f, t, f, f, t, f, f, f, t, f, f }; - VERIFY_GROUPS; - } -} - -template void tst_qquickvisualdatamodel::get_verify( - const SingleRoleModel &model, - QQuickVisualDataModel *visualModel, - QQuickVisualDataGroup *visibleItems, - QQuickVisualDataGroup *selectedItems, - const int (&mIndex)[N], - const int (&iIndex)[N], - const int (&vIndex)[N], - const int (&sIndex)[N], - const bool (&vMember)[N], - const bool (&sMember)[N]) -{ - failed = true; - for (int i = 0; i < N; ++i) { - QCOMPARE(evaluate(visualModel, QString("items.get(%1).model.name").arg(i)), model.list.at(mIndex[i])); - QCOMPARE(evaluate(visualModel, QString("items.get(%1).model.modelData").arg(i)), model.list.at(mIndex[i])); - QCOMPARE(evaluate(visualModel, QString("items.get(%1).model.index").arg(i)), mIndex[i]); - QCOMPARE(evaluate(visualModel, QString("items.get(%1).itemsIndex").arg(i)), iIndex[i]); - QCOMPARE(evaluate(visualModel, QString("items.get(%1).inItems").arg(i)), true); - QCOMPARE(evaluate(visualModel, QString("items.get(%1).visibleIndex").arg(i)), vIndex[i]); - QCOMPARE(evaluate(visualModel, QString("items.get(%1).inVisible").arg(i)), vMember[i]); - QCOMPARE(evaluate(visualModel, QString("items.get(%1).selectedIndex").arg(i)), sIndex[i]); - QCOMPARE(evaluate(visualModel, QString("items.get(%1).inSelected").arg(i)), sMember[i]); - QCOMPARE(evaluate(visualModel, QString("contains(items.get(%1).groups, \"items\")").arg(i)), true); - QCOMPARE(evaluate(visualModel, QString("contains(items.get(%1).groups, \"visible\")").arg(i)), vMember[i]); - QCOMPARE(evaluate(visualModel, QString("contains(items.get(%1).groups, \"selected\")").arg(i)), sMember[i]); - - if (vMember[i]) { - QCOMPARE(evaluate(visibleItems, QString("get(%1).model.name").arg(vIndex[i])), model.list.at(mIndex[i])); - QCOMPARE(evaluate(visibleItems, QString("get(%1).model.modelData").arg(vIndex[i])), model.list.at(mIndex[i])); - QCOMPARE(evaluate(visibleItems, QString("get(%1).model.index").arg(vIndex[i])), mIndex[i]); - QCOMPARE(evaluate(visibleItems, QString("get(%1).itemsIndex").arg(vIndex[i])), iIndex[i]); - QCOMPARE(evaluate(visibleItems, QString("get(%1).inItems").arg(vIndex[i])), true); - QCOMPARE(evaluate(visibleItems, QString("get(%1).visibleIndex").arg(vIndex[i])), vIndex[i]); - QCOMPARE(evaluate(visibleItems, QString("get(%1).inVisible").arg(vIndex[i])), vMember[i]); - QCOMPARE(evaluate(visibleItems, QString("get(%1).selectedIndex").arg(vIndex[i])), sIndex[i]); - QCOMPARE(evaluate(visibleItems, QString("get(%1).inSelected").arg(vIndex[i])), sMember[i]); - - QCOMPARE(evaluate(visibleItems, QString("contains(get(%1).groups, \"items\")").arg(vIndex[i])), true); - QCOMPARE(evaluate(visibleItems, QString("contains(get(%1).groups, \"visible\")").arg(vIndex[i])), vMember[i]); - QCOMPARE(evaluate(visibleItems, QString("contains(get(%1).groups, \"selected\")").arg(vIndex[i])), sMember[i]); - } - if (sMember[i]) { - QCOMPARE(evaluate(selectedItems, QString("get(%1).model.name").arg(sIndex[i])), model.list.at(mIndex[i])); - QCOMPARE(evaluate(selectedItems, QString("get(%1).model.modelData").arg(sIndex[i])), model.list.at(mIndex[i])); - QCOMPARE(evaluate(selectedItems, QString("get(%1).model.index").arg(sIndex[i])), mIndex[i]); - QCOMPARE(evaluate(selectedItems, QString("get(%1).itemsIndex").arg(sIndex[i])), iIndex[i]); - QCOMPARE(evaluate(selectedItems, QString("get(%1).inItems").arg(sIndex[i])), true); - QCOMPARE(evaluate(selectedItems, QString("get(%1).visibleIndex").arg(sIndex[i])), vIndex[i]); - QCOMPARE(evaluate(selectedItems, QString("get(%1).inVisible").arg(sIndex[i])), vMember[i]); - QCOMPARE(evaluate(selectedItems, QString("get(%1).selectedIndex").arg(sIndex[i])), sIndex[i]); - QCOMPARE(evaluate(selectedItems, QString("get(%1).inSelected").arg(sIndex[i])), sMember[i]); - QCOMPARE(evaluate(selectedItems, QString("contains(get(%1).groups, \"items\")").arg(sIndex[i])), true); - QCOMPARE(evaluate(selectedItems, QString("contains(get(%1).groups, \"visible\")").arg(sIndex[i])), vMember[i]); - QCOMPARE(evaluate(selectedItems, QString("contains(get(%1).groups, \"selected\")").arg(sIndex[i])), sMember[i]); - } - } - failed = false; -} - -#define VERIFY_GET \ - get_verify(model, visualModel, visibleItems, selectedItems, mIndex, iIndex, vIndex, sIndex, vMember, sMember); \ - QVERIFY(!failed) - -void tst_qquickvisualdatamodel::get() -{ - QQuickView view; - - SingleRoleModel model; - model.list = QStringList() - << "one" - << "two" - << "three" - << "four" - << "five" - << "six" - << "seven" - << "eight" - << "nine" - << "ten" - << "eleven" - << "twelve"; - - QDeclarativeContext *ctxt = view.rootContext(); - ctxt->setContextProperty("myModel", &model); - - view.setSource(testFileUrl("groups.qml")); - - QQuickListView *listview = qobject_cast(view.rootObject()); - QVERIFY(listview != 0); - - QQuickItem *contentItem = listview->contentItem(); - QVERIFY(contentItem != 0); - - QQuickVisualDataModel *visualModel = qobject_cast(qvariant_cast(listview->model())); - QVERIFY(visualModel); - - QQuickVisualDataGroup *visibleItems = visualModel->findChild("visibleItems"); - QVERIFY(visibleItems); - - QQuickVisualDataGroup *selectedItems = visualModel->findChild("selectedItems"); - QVERIFY(selectedItems); - - QV8Engine *v8Engine = QDeclarativeEnginePrivate::getV8Engine(ctxt->engine()); - QVERIFY(v8Engine); - - const bool f = false; - const bool t = true; - - { - QCOMPARE(listview->count(), 12); - QCOMPARE(visualModel->items()->count(), 12); - QCOMPARE(visibleItems->count(), 12); - QCOMPARE(selectedItems->count(), 0); - static const int mIndex [] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11 }; - static const int iIndex [] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11 }; - static const int vIndex [] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11 }; - static const bool vMember[] = { t, t, t, t, t, t, t, t, t, t, t, t }; - static const int sIndex [] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; - static const bool sMember[] = { f, f, f, f, f, f, f, f, f, f, f, f }; - VERIFY_GET; - } { - evaluate(visualModel, "items.addGroups(8, \"selected\")"); - QCOMPARE(listview->count(), 12); - QCOMPARE(visualModel->items()->count(), 12); - QCOMPARE(visibleItems->count(), 12); - QCOMPARE(selectedItems->count(), 1); - static const int mIndex [] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11 }; - static const int iIndex [] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11 }; - static const int vIndex [] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11 }; - static const bool vMember[] = { t, t, t, t, t, t, t, t, t, t, t, t }; - static const int sIndex [] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1 }; - static const bool sMember[] = { f, f, f, f, f, f, f, f, t, f, f, f }; - VERIFY_GET; - } { - evaluate(visualModel, "items.addGroups(6, 4, [\"visible\", \"selected\"])"); - QCOMPARE(listview->count(), 12); - QCOMPARE(visualModel->items()->count(), 12); - QCOMPARE(visibleItems->count(), 12); - QCOMPARE(selectedItems->count(), 4); - static const int mIndex [] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11 }; - static const int iIndex [] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11 }; - static const int vIndex [] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11 }; - static const bool vMember[] = { t, t, t, t, t, t, t, t, t, t, t, t }; - static const int sIndex [] = { 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 4, 4 }; - static const bool sMember[] = { f, f, f, f, f, f, t, t, t, t, f, f }; - VERIFY_GET; - } { - evaluate(visualModel, "items.setGroups(2, [\"items\", \"selected\"])"); - QCOMPARE(listview->count(), 12); - QCOMPARE(visualModel->items()->count(), 12); - QCOMPARE(visibleItems->count(), 11); - QCOMPARE(selectedItems->count(), 5); - static const int mIndex [] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11 }; - static const int iIndex [] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11 }; - static const int vIndex [] = { 0, 1, 2, 2, 3, 4, 5, 6, 7, 8, 9,10 }; - static const bool vMember[] = { t, t, f, t, t, t, t, t, t, t, t, t }; - static const int sIndex [] = { 0, 0, 0, 1, 1, 1, 1, 2, 3, 4, 5, 5 }; - static const bool sMember[] = { f, f, t, f, f, f, t, t, t, t, f, f }; - VERIFY_GET; - } { - evaluate(selectedItems, "setGroups(0, 3, \"items\")"); - QCOMPARE(listview->count(), 12); - QCOMPARE(visualModel->items()->count(), 12); - QCOMPARE(visibleItems->count(), 9); - QCOMPARE(selectedItems->count(), 2); - static const int mIndex [] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11 }; - static const int iIndex [] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11 }; - static const int vIndex [] = { 0, 1, 2, 2, 3, 4, 5, 5, 5, 6, 7, 8 }; - static const bool vMember[] = { t, t, f, t, t, t, f, f, t, t, t, t }; - static const int sIndex [] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 2 }; - static const bool sMember[] = { f, f, f, f, f, f, f, f, t, t, f, f }; - VERIFY_GET; - } { - evaluate(visualModel, "items.get(5).inVisible = false"); - QCOMPARE(listview->count(), 12); - QCOMPARE(visualModel->items()->count(), 12); - QCOMPARE(visibleItems->count(), 8); - QCOMPARE(selectedItems->count(), 2); - static const int mIndex [] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11 }; - static const int iIndex [] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11 }; - static const int vIndex [] = { 0, 1, 2, 2, 3, 4, 4, 4, 4, 5, 6, 7 }; - static const bool vMember[] = { t, t, f, t, t, f, f, f, t, t, t, t }; - static const int sIndex [] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 2 }; - static const bool sMember[] = { f, f, f, f, f, f, f, f, t, t, f, f }; - VERIFY_GET; - } { - evaluate(visualModel, "items.get(5).inSelected = true"); - QCOMPARE(listview->count(), 12); - QCOMPARE(visualModel->items()->count(), 12); - QCOMPARE(visibleItems->count(), 8); - QCOMPARE(selectedItems->count(), 3); - static const int mIndex [] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11 }; - static const int iIndex [] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11 }; - static const int vIndex [] = { 0, 1, 2, 2, 3, 4, 4, 4, 4, 5, 6, 7 }; - static const bool vMember[] = { t, t, f, t, t, f, f, f, t, t, t, t }; - static const int sIndex [] = { 0, 0, 0, 0, 0, 0, 1, 1, 1, 2, 3, 3 }; - static const bool sMember[] = { f, f, f, f, f, t, f, f, t, t, f, f }; - VERIFY_GET; - } { - evaluate(visualModel, "items.get(5).groups = [\"visible\", \"items\"]"); - QCOMPARE(listview->count(), 12); - QCOMPARE(visualModel->items()->count(), 12); - QCOMPARE(visibleItems->count(), 9); - QCOMPARE(selectedItems->count(), 2); - static const int mIndex [] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11 }; - static const int iIndex [] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11 }; - static const int vIndex [] = { 0, 1, 2, 2, 3, 4, 5, 5, 5, 6, 7, 8 }; - static const bool vMember[] = { t, t, f, t, t, t, f, f, t, t, t, t }; - static const int sIndex [] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 2 }; - static const bool sMember[] = { f, f, f, f, f, f, f, f, t, t, f, f }; - VERIFY_GET; - } -} - -void tst_qquickvisualdatamodel::invalidGroups() -{ - QUrl source = testFileUrl("groups-invalid.qml"); - QTest::ignoreMessage(QtWarningMsg, (source.toString() + ":12:9: QML VisualDataGroup: " + QQuickVisualDataGroup::tr("Group names must start with a lower case letter")).toUtf8()); - - QDeclarativeComponent component(&engine, source); - QScopedPointer object(component.create()); - QVERIFY(object); - - QCOMPARE(evaluate(object.data(), "groups.length"), 4); - QCOMPARE(evaluate(object.data(), "groups[0].name"), QString("items")); - QCOMPARE(evaluate(object.data(), "groups[1].name"), QString("persistedItems")); - QCOMPARE(evaluate(object.data(), "groups[2].name"), QString("visible")); - QCOMPARE(evaluate(object.data(), "groups[3].name"), QString("selected")); -} - -void tst_qquickvisualdatamodel::onChanged_data() -{ - QTest::addColumn("expression"); - QTest::addColumn("tests"); - - QTest::newRow("item appended") - << QString("listModel.append({\"number\": \"five\"})") - << (QStringList() - << "verify(vm.removed, [], [], [])" - << "verify(vm.inserted, [4], [1], [undefined])" - << "verify(vi.removed, [], [], [])" - << "verify(vi.inserted, [4], [1], [undefined])" - << "verify(si.removed, [], [], [])" - << "verify(si.inserted, [], [], [])"); - QTest::newRow("item prepended") - << QString("listModel.insert(0, {\"number\": \"five\"})") - << (QStringList() - << "verify(vm.removed, [], [], [])" - << "verify(vm.inserted, [0], [1], [undefined])" - << "verify(vi.removed, [], [], [])" - << "verify(vi.inserted, [0], [1], [undefined])" - << "verify(si.removed, [], [], [])" - << "verify(si.inserted, [], [], [])"); - QTest::newRow("item inserted") - << QString("listModel.insert(2, {\"number\": \"five\"})") - << (QStringList() - << "verify(vm.removed, [], [], [])" - << "verify(vm.inserted, [2], [1], [undefined])" - << "verify(vi.removed, [], [], [])" - << "verify(vi.inserted, [2], [1], [undefined])" - << "verify(si.removed, [], [], [])" - << "verify(si.inserted, [], [], [])"); - - QTest::newRow("item removed tail") - << QString("listModel.remove(3)") - << (QStringList() - << "verify(vm.removed, [3], [1], [undefined])" - << "verify(vm.inserted, [], [], [])" - << "verify(vi.removed, [3], [1], [undefined])" - << "verify(vi.inserted, [], [], [])" - << "verify(si.removed, [], [], [])" - << "verify(si.inserted, [], [], [])"); - QTest::newRow("item removed head") - << QString("listModel.remove(0)") - << (QStringList() - << "verify(vm.removed, [0], [1], [undefined])" - << "verify(vm.inserted, [], [], [])" - << "verify(vi.removed, [0], [1], [undefined])" - << "verify(vi.inserted, [], [], [])" - << "verify(si.removed, [], [], [])" - << "verify(si.inserted, [], [], [])"); - QTest::newRow("item removed middle") - << QString("listModel.remove(1)") - << (QStringList() - << "verify(vm.removed, [1], [1], [undefined])" - << "verify(vm.inserted, [], [], [])" - << "verify(vi.removed, [1], [1], [undefined])" - << "verify(vi.inserted, [], [], [])" - << "verify(si.removed, [], [], [])" - << "verify(si.inserted, [], [], [])"); - - - QTest::newRow("item moved from tail") - << QString("listModel.move(3, 0, 1)") - << (QStringList() - << "verify(vm.removed, [3], [1], [vm.inserted[0].moveId])" - << "verify(vm.inserted, [0], [1], [vm.removed[0].moveId])" - << "verify(vi.removed, [3], [1], [vi.inserted[0].moveId])" - << "verify(vi.inserted, [0], [1], [vi.removed[0].moveId])" - << "verify(si.removed, [], [], [])" - << "verify(si.inserted, [], [], [])"); - QTest::newRow("item moved from head") - << QString("listModel.move(0, 2, 2)") - << (QStringList() - << "verify(vm.removed, [0], [2], [vm.inserted[0].moveId])" - << "verify(vm.inserted, [2], [2], [vm.removed[0].moveId])" - << "verify(vi.removed, [0], [2], [vi.inserted[0].moveId])" - << "verify(vi.inserted, [2], [2], [vi.removed[0].moveId])" - << "verify(si.removed, [], [], [])" - << "verify(si.inserted, [], [], [])"); - - QTest::newRow("groups changed") - << QString("items.setGroups(1, 2, [\"items\", \"selected\"])") - << (QStringList() - << "verify(vm.inserted, [], [], [])" - << "verify(vm.removed, [], [], [])" - << "verify(vi.removed, [1], [2], [undefined])" - << "verify(vi.inserted, [], [], [])" - << "verify(si.removed, [], [], [])" - << "verify(si.inserted, [0], [2], [undefined])"); - - QTest::newRow("multiple removes") - << QString("{ vi.remove(1, 1); " - "vi.removeGroups(0, 2, \"items\") }") - << (QStringList() - << "verify(vm.removed, [0, 1], [1, 1], [undefined, undefined])" - << "verify(vm.inserted, [], [], [])" - << "verify(vi.removed, [1], [1], [undefined])" - << "verify(vi.inserted, [], [], [])" - << "verify(si.removed, [], [], [])" - << "verify(si.inserted, [], [], [])"); -} - -void tst_qquickvisualdatamodel::onChanged() -{ - QFETCH(QString, expression); - QFETCH(QStringList, tests); - - QDeclarativeComponent component(&engine, testFileUrl("onChanged.qml")); - QScopedPointer object(component.create()); - QVERIFY(object); - - evaluate(object.data(), expression); - - foreach (const QString &test, tests) { - bool passed = evaluate(object.data(), test); - if (!passed) - qWarning() << test; - QVERIFY(passed); - } -} - -void tst_qquickvisualdatamodel::create() -{ - QQuickView view; - - SingleRoleModel model; - model.list = QStringList() - << "one" - << "two" - << "three" - << "four" - << "five" - << "six" - << "seven" - << "eight" - << "nine" - << "ten" - << "eleven" - << "twelve" - << "thirteen" - << "fourteen" - << "fifteen" - << "sixteen" - << "seventeen" - << "eighteen" - << "nineteen" - << "twenty"; - - QDeclarativeContext *ctxt = view.rootContext(); - ctxt->setContextProperty("myModel", &model); - - view.setSource(testFileUrl("create.qml")); - - QQuickListView *listview = qobject_cast(view.rootObject()); - QVERIFY(listview != 0); - - QQuickItem *contentItem = listview->contentItem(); - QVERIFY(contentItem != 0); - - QQuickVisualDataModel *visualModel = qobject_cast(qvariant_cast(listview->model())); - QVERIFY(visualModel); - - QCOMPARE(listview->count(), 20); - - QDeclarativeGuard delegate; - - // persistedItems.includeByDefault is true, so all items belong to persistedItems initially. - QVERIFY(delegate = findItem(contentItem, "delegate", 1)); - QCOMPARE(evaluate(delegate, "VisualDataModel.inPersistedItems"), true); - - // changing include by default doesn't remove persistance. - evaluate(visualModel, "persistedItems.includeByDefault = false"); - QCOMPARE(evaluate(delegate, "VisualDataModel.inPersistedItems"), true); - - // removing from persistedItems does. - evaluate(visualModel, "persistedItems.remove(0, 20)"); - QCOMPARE(listview->count(), 20); - QCOMPARE(evaluate(delegate, "VisualDataModel.inPersistedItems"), false); - - // Request an item instantiated by the view. - QVERIFY(delegate = qobject_cast(evaluate(visualModel, "items.create(1)"))); - QCOMPARE(delegate.data(), findItem(contentItem, "delegate", 1)); - QCOMPARE(evaluate(delegate, "VisualDataModel.inPersistedItems"), true); - QCOMPARE(evaluate(visualModel, "persistedItems.count"), 1); - - evaluate(delegate, "VisualDataModel.inPersistedItems = false"); - QCOMPARE(listview->count(), 20); - QCoreApplication::sendPostedEvents(delegate, QEvent::DeferredDelete); - QVERIFY(delegate); - QCOMPARE(evaluate(delegate, "VisualDataModel.inPersistedItems"), false); - QCOMPARE(evaluate(visualModel, "persistedItems.count"), 0); - - // Request an item not instantiated by the view. - QVERIFY(!findItem(contentItem, "delegate", 15)); - QVERIFY(delegate = qobject_cast(evaluate(visualModel, "items.create(15)"))); - QCOMPARE(delegate.data(), findItem(contentItem, "delegate", 15)); - QCOMPARE(evaluate(delegate, "VisualDataModel.inPersistedItems"), true); - QCOMPARE(evaluate(visualModel, "persistedItems.count"), 1); - - evaluate(visualModel, "persistedItems.remove(0)"); - QCoreApplication::sendPostedEvents(delegate, QEvent::DeferredDelete); - QVERIFY(!delegate); - QCOMPARE(evaluate(visualModel, "persistedItems.count"), 0); - - // Request an item not instantiated by the view, then scroll the view so it will request it. - QVERIFY(!findItem(contentItem, "delegate", 16)); - QVERIFY(delegate = qobject_cast(evaluate(visualModel, "items.create(16)"))); - QCOMPARE(delegate.data(), findItem(contentItem, "delegate", 16)); - QCOMPARE(evaluate(delegate, "VisualDataModel.inPersistedItems"), true); - QCOMPARE(evaluate(visualModel, "persistedItems.count"), 1); - - evaluate(listview, "positionViewAtIndex(19, ListView.End)"); - QCOMPARE(listview->count(), 20); - evaluate(delegate, "VisualDataModel.groups = [\"items\"]"); - QCoreApplication::sendPostedEvents(delegate, QEvent::DeferredDelete); - QVERIFY(delegate); - QCOMPARE(evaluate(delegate, "VisualDataModel.inPersistedItems"), false); - QCOMPARE(evaluate(visualModel, "persistedItems.count"), 0); - - // Request and release an item instantiated by the view, then scroll the view so it releases it. - QVERIFY(findItem(contentItem, "delegate", 17)); - QVERIFY(delegate = qobject_cast(evaluate(visualModel, "items.create(17)"))); - QCOMPARE(delegate.data(), findItem(contentItem, "delegate", 17)); - QCOMPARE(evaluate(delegate, "VisualDataModel.inPersistedItems"), true); - QCOMPARE(evaluate(visualModel, "persistedItems.count"), 1); - - evaluate(visualModel, "items.removeGroups(17, \"persistedItems\")"); - QCoreApplication::sendPostedEvents(delegate, QEvent::DeferredDelete); - QVERIFY(delegate); - QCOMPARE(evaluate(delegate, "VisualDataModel.inPersistedItems"), false); - QCOMPARE(evaluate(visualModel, "persistedItems.count"), 0); - evaluate(listview, "positionViewAtIndex(1, ListView.Beginning)"); - QCOMPARE(listview->count(), 20); - QCoreApplication::sendPostedEvents(delegate, QEvent::DeferredDelete); - QVERIFY(!delegate); - - // Adding an item to the persistedItems group won't instantiate it, but if later requested by - // the view it will be persisted. - evaluate(visualModel, "items.addGroups(18, \"persistedItems\")"); - QCOMPARE(evaluate(visualModel, "persistedItems.count"), 1); - QVERIFY(!findItem(contentItem, "delegate", 18)); - evaluate(listview, "positionViewAtIndex(19, ListView.End)"); - QCOMPARE(listview->count(), 20); - QVERIFY(delegate = findItem(contentItem, "delegate", 18)); - QCOMPARE(evaluate(delegate, "VisualDataModel.inPersistedItems"), true); - QCoreApplication::sendPostedEvents(delegate, QEvent::DeferredDelete); - QVERIFY(delegate); - evaluate(listview, "positionViewAtIndex(1, ListView.Beginning)"); - QCOMPARE(listview->count(), 20); - QCoreApplication::sendPostedEvents(delegate, QEvent::DeferredDelete); - QVERIFY(delegate); - - // Remove an uninstantiated but cached item from the persistedItems group. - evaluate(visualModel, "items.addGroups(19, \"persistedItems\")"); - QCOMPARE(evaluate(visualModel, "persistedItems.count"), 2); - QVERIFY(!findItem(contentItem, "delegate", 19)); - // Store a reference to the item so it is retained in the cache. - evaluate(visualModel, "persistentHandle = items.get(19)"); - QCOMPARE(evaluate(visualModel, "persistentHandle.inPersistedItems"), true); - evaluate(visualModel, "items.removeGroups(19, \"persistedItems\")"); - QCOMPARE(evaluate(visualModel, "persistentHandle.inPersistedItems"), false); -} - -void tst_qquickvisualdatamodel::incompleteModel() -{ - // VisualDataModel is first populated in componentComplete. Verify various functions are - // harmlessly ignored until then. - - QDeclarativeComponent component(&engine); - component.setData("import QtQuick 2.0\n VisualDataModel {}", testFileUrl("")); - - QScopedPointer object(component.beginCreate(engine.rootContext())); - - QQuickVisualDataModel *model = qobject_cast(object.data()); - QVERIFY(model); - - QSignalSpy itemsSpy(model->items(), SIGNAL(countChanged())); - QSignalSpy persistedItemsSpy(model->items(), SIGNAL(countChanged())); - - evaluate(model, "items.removeGroups(0, items.count, \"items\")"); - QCOMPARE(itemsSpy.count(), 0); - QCOMPARE(persistedItemsSpy.count(), 0); - - evaluate(model, "items.setGroups(0, items.count, \"persistedItems\")"); - QCOMPARE(itemsSpy.count(), 0); - QCOMPARE(persistedItemsSpy.count(), 0); - - evaluate(model, "items.addGroups(0, items.count, \"persistedItems\")"); - QCOMPARE(itemsSpy.count(), 0); - QCOMPARE(persistedItemsSpy.count(), 0); - - evaluate(model, "items.remove(0, items.count)"); - QCOMPARE(itemsSpy.count(), 0); - QCOMPARE(persistedItemsSpy.count(), 0); - - evaluate(model, "items.insert([ \"color\": \"blue\" ])"); - QCOMPARE(itemsSpy.count(), 0); - QCOMPARE(persistedItemsSpy.count(), 0); - - QTest::ignoreMessage(QtWarningMsg, ": QML VisualDataGroup: get: index out of range"); - QVERIFY(evaluate(model, "items.get(0) === undefined")); - - component.completeCreate(); -} - -void tst_qquickvisualdatamodel::insert_data() -{ - QTest::addColumn("source"); - QTest::addColumn("expression"); - QTest::addColumn("modelCount"); - QTest::addColumn("visualCount"); - QTest::addColumn("index"); - QTest::addColumn("inItems"); - QTest::addColumn("persisted"); - QTest::addColumn("visible"); - QTest::addColumn("selected"); - QTest::addColumn("modelData"); - QTest::addColumn("property"); - QTest::addColumn("propertyData"); - - const QUrl listModelSource[] = { - testFileUrl("listmodelproperties.qml"), - testFileUrl("listmodelproperties-package.qml") }; - const QUrl singleRoleSource[] = { - testFileUrl("singleroleproperties.qml"), - testFileUrl("singleroleproperties-package.qml") }; - const QUrl multipleRoleSource[] = { - testFileUrl("multipleroleproperties.qml"), - testFileUrl("multipleroleproperties-package.qml") }; - const QUrl stringListSource[] = { - testFileUrl("stringlistproperties.qml"), - testFileUrl("stringlistproperties-package.qml") }; - const QUrl objectListSource[] = { - testFileUrl("objectlistproperties.qml"), - testFileUrl("objectlistproperties-package.qml") }; - - for (int i = 0; i < 2; ++i) { - // List Model. - QTest::newRow("ListModel.items prepend") - << listModelSource[i] - << QString("items.insert(0, {\"number\": \"eight\"})") - << 4 << 5 << 0 << true << false << false << false << true - << QString("number") - << (QStringList() << "eight" << "one" << "two" << "three" << "four"); - - QTest::newRow("ListModel.items append") - << listModelSource[i] - << QString("items.insert({\"number\": \"eight\"})") - << 4 << 5 << 4 << true << false << false << false << true - << QString("number") - << (QStringList() << "one" << "two" << "three" << "four" << "eight"); - - QTest::newRow("ListModel.items insert at 2") - << listModelSource[i] - << QString("items.insert(2, {\"number\": \"eight\"})") - << 4 << 5 << 2 << true << false << false << false << true - << QString("number") - << (QStringList() << "one" << "two" << "eight" << "three" << "four"); - - QTest::newRow("ListModel.items insert at items.get(2)") - << listModelSource[i] - << QString("items.insert(items.get(2), {\"number\": \"eight\"})") - << 4 << 5 << 2 << true << false << false << false << true - << QString("number") - << (QStringList() << "one" << "two" << "eight" << "three" << "four"); - - QTest::newRow("ListModel.items insert at visibleItems.get(2)") - << listModelSource[i] - << QString("items.insert(visibleItems.get(2), {\"number\": \"eight\"})") - << 4 << 5 << 2 << true << false << false << false << true - << QString("number") - << (QStringList() << "one" << "two" << "eight" << "three" << "four"); - - QTest::newRow("ListModel.selectedItems insert at items.get(2)") - << listModelSource[i] - << QString("selectedItems.insert(items.get(2), {\"number\": \"eight\"})") - << 4 << 5 << 2 << false << false << false << true << true - << QString("number") - << (QStringList() << "one" << "two" << "eight" << "three" << "four"); - - QTest::newRow("ListModel.selectedItems insert at visibleItems.get(2)") - << listModelSource[i] - << QString("selectedItems.insert(visibleItems.get(2), {\"number\": \"eight\"})") - << 4 << 5 << 2 << false << false << false << true << true - << QString("number") - << (QStringList() << "one" << "two" << "eight" << "three" << "four"); - - QTest::newRow("ListModel.items prepend modelData") - << listModelSource[i] - << QString("items.insert(0, {\"modelData\": \"eight\"})") - << 4 << 5 << 0 << true << false << false << false << true - << QString("number") - << (QStringList() << "eight" << "one" << "two" << "three" << "four"); - - QTest::newRow("ListModel.items prepend, edit number") - << listModelSource[i] - << QString("{ " - "items.insert(0, {\"number\": \"eight\"}); " - "items.get(0).model.number = \"seven\"; }") - << 4 << 5 << 0 << true << false << false << false << true - << QString("number") - << (QStringList() << "seven" << "one" << "two" << "three" << "four"); - - QTest::newRow("ListModel.items prepend, edit modelData") - << listModelSource[i] - << QString("{ " - "items.insert(0, {\"number\": \"eight\"}); " - "items.get(0).model.modelData = \"seven\"; }") - << 4 << 5 << 0 << true << false << false << false << true - << QString("number") - << (QStringList() << "seven" << "one" << "two" << "three" << "four"); - - QTest::newRow("ListModel.items prepend, edit resolved") - << listModelSource[i] - << QString("{ " - "items.insert(0, {\"number\": \"eight\"}); " - "items.get(2).model.number = \"seven\"; }") - << 4 << 5 << 0 << true << false << false << false << true - << QString("number") - << (QStringList() << "eight" << "one" << "two" << "three" << "four"); - - QTest::newRow("ListModel.items prepend with groups") - << listModelSource[i] - << QString("items.insert(0, {\"number\": \"eight\"}, [\"visible\", \"truncheon\"])") - << 4 << 5 << 0 << true << false << true << false << true - << QString("number") - << (QStringList() << "eight" << "one" << "two" << "three" << "four"); - - QTest::newRow("ListModel.items append with groups") - << listModelSource[i] - << QString("items.insert({\"number\": \"eight\"}, [\"visible\", \"selected\"])") - << 4 << 5 << 4 << true << false << true << true << true - << QString("number") - << (QStringList() << "one" << "two" << "three" << "four" << "eight"); - - QTest::newRow("ListModel.items insert at 2 with groups") - << listModelSource[i] - << QString("items.insert(2, {\"number\": \"eight\"}, \"visible\")") - << 4 << 5 << 2 << true << false << true << false << true - << QString("number") - << (QStringList() << "one" << "two" << "eight" << "three" << "four"); - - // create ListModel - QTest::newRow("ListModel.items prepend") - << listModelSource[i] - << QString("items.create(0, {\"number\": \"eight\"})") - << 4 << 5 << 0 << true << true << false << false << true - << QString("number") - << (QStringList() << "eight" << "one" << "two" << "three" << "four"); - - QTest::newRow("ListModel.items append") - << listModelSource[i] - << QString("items.create({\"number\": \"eight\"})") - << 4 << 5 << 4 << true << true << false << false << true - << QString("number") - << (QStringList() << "one" << "two" << "three" << "four" << "eight"); - - QTest::newRow("ListModel.items create at 2") - << listModelSource[i] - << QString("items.create(2, {\"number\": \"eight\"})") - << 4 << 5 << 2 << true << true << false << false << true - << QString("number") - << (QStringList() << "one" << "two" << "eight" << "three" << "four"); - - QTest::newRow("ListModel.items create at items.get(2)") - << listModelSource[i] - << QString("items.create(items.get(2), {\"number\": \"eight\"})") - << 4 << 5 << 2 << true << true << false << false << true - << QString("number") - << (QStringList() << "one" << "two" << "eight" << "three" << "four"); - - QTest::newRow("ListModel.items create at visibleItems.get(2)") - << listModelSource[i] - << QString("items.create(visibleItems.get(2), {\"number\": \"eight\"})") - << 4 << 5 << 2 << true << true << false << false << true - << QString("number") - << (QStringList() << "one" << "two" << "eight" << "three" << "four"); - - QTest::newRow("ListModel.selectedItems create at items.get(2)") - << listModelSource[i] - << QString("selectedItems.create(items.get(2), {\"number\": \"eight\"})") - << 4 << 5 << 2 << false << true << false << true << true - << QString("number") - << (QStringList() << "one" << "two" << "eight" << "three" << "four"); - - QTest::newRow("ListModel.selectedItems create at visibleItems.get(2)") - << listModelSource[i] - << QString("selectedItems.create(visibleItems.get(2), {\"number\": \"eight\"})") - << 4 << 5 << 2 << false << true << false << true << true - << QString("number") - << (QStringList() << "one" << "two" << "eight" << "three" << "four"); - - QTest::newRow("ListModel.items create prepended") - << listModelSource[i] - << QString("items.create(0, {\"number\": \"eight\"})") - << 4 << 5 << 0 << true << true << false << false << true - << QString("number") - << (QStringList() << "eight" << "one" << "two" << "three" << "four"); - - QTest::newRow("ListModel.items create appended") - << listModelSource[i] - << QString("items.create({\"number\": \"eight\"})") - << 4 << 5 << 4 << true << true << false << false << true - << QString("number") - << (QStringList() << "one" << "two" << "three" << "four" << "eight"); - - QTest::newRow("ListModel.items create at 2") - << listModelSource[i] - << QString("items.create(2, {\"number\": \"eight\"})") - << 4 << 5 << 2 << true << true << false << false << true - << QString("number") - << (QStringList() << "one" << "two" << "eight" << "three" << "four"); - - QTest::newRow("ListModel.items create at items.get(2)") - << listModelSource[i] - << QString("items.create(items.get(2), {\"number\": \"eight\"})") - << 4 << 5 << 2 << true << true << false << false << true - << QString("number") - << (QStringList() << "one" << "two" << "eight" << "three" << "four"); - - QTest::newRow("ListModel.items create at visibleItems.get(2)") - << listModelSource[i] - << QString("items.create(visibleItems.get(2), {\"number\": \"eight\"})") - << 4 << 5 << 2 << true << true << false << false << true - << QString("number") - << (QStringList() << "one" << "two" << "eight" << "three" << "four"); - - QTest::newRow("ListModel.create prepend modelData") - << listModelSource[i] - << QString("items.create(0, {\"modelData\": \"eight\"})") - << 4 << 5 << 0 << true << true << false << false << true - << QString("number") - << (QStringList() << "eight" << "one" << "two" << "three" << "four"); - - QTest::newRow("ListModel.items create prepended, edit number") - << listModelSource[i] - << QString("{ " - "var item = items.create(0, {\"number\": \"eight\"}); " - "item.setTest3(\"seven\"); }") - << 4 << 5 << 0 << true << true << false << false << true - << QString("number") - << (QStringList() << "seven" << "one" << "two" << "three" << "four"); - - QTest::newRow("ListModel.items create prepended, edit model.number") - << listModelSource[i] - << QString("{ " - "var item = items.create(0, {\"number\": \"eight\"}); " - "item.setTest4(\"seven\"); }") - << 4 << 5 << 0 << true << true << false << false << true - << QString("number") - << (QStringList() << "seven" << "one" << "two" << "three" << "four"); - - QTest::newRow("ListModel.items create prepended, edit modelData") - << listModelSource[i] - << QString("{ " - "var item = items.create(0, {\"number\": \"eight\"}); " - "item.setTest5(\"seven\"); }") - << 4 << 5 << 0 << true << true << false << false << true - << QString("number") - << (QStringList() << "seven" << "one" << "two" << "three" << "four"); - - QTest::newRow("ListModel.items create prepended, edit model.modelData") - << listModelSource[i] - << QString("{ " - "var item = items.create(0, {\"number\": \"eight\"}); " - "item.setTest6(\"seven\"); }") - << 4 << 5 << 0 << true << true << false << false << true - << QString("number") - << (QStringList() << "seven" << "one" << "two" << "three" << "four"); - - QTest::newRow("ListModel.items create prepended with groups") - << listModelSource[i] - << QString("items.create(0, {\"number\": \"eight\"}, [\"visible\", \"truncheon\"])") - << 4 << 5 << 0 << true << true << true << false << true - << QString("number") - << (QStringList() << "eight" << "one" << "two" << "three" << "four"); - - QTest::newRow("ListModel.items create appended with groups") - << listModelSource[i] - << QString("items.create({\"number\": \"eight\"}, [\"visible\", \"selected\"])") - << 4 << 5 << 4 << true << true << true << true << true - << QString("number") - << (QStringList() << "one" << "two" << "three" << "four" << "eight"); - - QTest::newRow("ListModel.items create inserted with groups") - << listModelSource[i] - << QString("items.create(2, {\"number\": \"eight\"}, \"visible\")") - << 4 << 5 << 2 << true << true << true << false << true - << QString("number") - << (QStringList() << "one" << "two" << "eight" << "three" << "four"); - - QTest::newRow("ListModel.items create prepended clear persistence") - << listModelSource[i] - << QString("{ items.create(0, {\"number\": \"eight\"}); " - "items.get(0).inPersistedItems = false }") - << 4 << 5 << 0 << true << false << false << false << true - << QString("number") - << (QStringList() << "eight" << "one" << "two" << "three" << "four"); - - QTest::newRow("ListModel.items create appended clear persistence") - << listModelSource[i] - << QString("{ items.create({\"number\": \"eight\"}); " - "items.get(4).inPersistedItems = false }") - << 4 << 5 << 4 << true << false << false << false << true - << QString("number") - << (QStringList() << "one" << "two" << "three" << "four" << "eight"); - - QTest::newRow("ListModel.items create inserted clear persistence") - << listModelSource[i] - << QString("{ items.create(2, {\"number\": \"eight\"}); " - "items.get(2).inPersistedItems = false }") - << 4 << 5 << 2 << true << false << false << false << true - << QString("number") - << (QStringList() << "one" << "two" << "eight" << "three" << "four"); - - // AbstractItemModel (Single Role). - QTest::newRow("AbstractItemModel.items prepend") - << singleRoleSource[i] - << QString("items.insert(0, {\"name\": \"eight\"})") - << 4 << 5 << 0 << true << false << false << false << true - << QString("name") - << (QStringList() << "eight" << "one" << "two" << "three" << "four"); - - QTest::newRow("AbstractItemModel.items append") - << singleRoleSource[i] - << QString("items.insert({\"name\": \"eight\"})") - << 4 << 5 << 4 << true << false << false << false << true - << QString("name") - << (QStringList() << "one" << "two" << "three" << "four" << "eight"); - - QTest::newRow("AbstractItemModel.items insert at 2") - << singleRoleSource[i] - << QString("items.insert(2, {\"name\": \"eight\"})") - << 4 << 5 << 2 << true << false << false << false << true - << QString("name") - << (QStringList() << "one" << "two" << "eight" << "three" << "four"); - - QTest::newRow("AbstractItemModel.items prepend modelData") - << singleRoleSource[i] - << QString("items.insert(0, {\"modelData\": \"eight\"})") - << 4 << 5 << 0 << true << false << false << false << true - << QString("name") - << (QStringList() << "eight" << "one" << "two" << "three" << "four"); - - QTest::newRow("AbstractItemModel.items prepend, edit name") - << singleRoleSource[i] - << QString("{ " - "items.insert(0, {\"name\": \"eight\"}); " - "items.get(0).model.name = \"seven\"; }") - << 4 << 5 << 0 << true << false << false << false << true - << QString("name") - << (QStringList() << "seven" << "one" << "two" << "three" << "four"); - - QTest::newRow("AbstractItemModel.items prepend, edit modelData") - << singleRoleSource[i] - << QString("{ " - "items.insert(0, {\"name\": \"eight\"}); " - "items.get(0).model.modelData = \"seven\"; }") - << 4 << 5 << 0 << true << false << false << false << true - << QString("name") - << (QStringList() << "seven" << "one" << "two" << "three" << "four"); - - QTest::newRow("AbstractItemModel.items prepend, edit resolved") - << singleRoleSource[i] - << QString("{ " - "items.insert(0, {\"name\": \"eight\"}); " - "items.get(2).model.name = \"seven\"; }") - << 4 << 5 << 0 << true << false << false << false << true - << QString("name") - << (QStringList() << "eight" << "one" << "two" << "three" << "four"); - - QTest::newRow("AbstractItemModel.create prepend modelData") - << singleRoleSource[i] - << QString("items.create(0, {\"modelData\": \"eight\"})") - << 4 << 5 << 0 << true << true << false << false << true - << QString("name") - << (QStringList() << "eight" << "one" << "two" << "three" << "four"); - - QTest::newRow("AbstractItemModel.items create prepended, edit name") - << singleRoleSource[i] - << QString("{ " - "var item = items.create(0, {\"name\": \"eight\"}); " - "item.setTest3(\"seven\"); }") - << 4 << 5 << 0 << true << true << false << false << true - << QString("name") - << (QStringList() << "seven" << "one" << "two" << "three" << "four"); - - QTest::newRow("AbstractItemModel.items create prepended, edit model.name") - << singleRoleSource[i] - << QString("{ " - "var item = items.create(0, {\"name\": \"eight\"}); " - "item.setTest4(\"seven\"); }") - << 4 << 5 << 0 << true << true << false << false << true - << QString("name") - << (QStringList() << "seven" << "one" << "two" << "three" << "four"); - - QTest::newRow("AbstractItemModel.items create prepended, edit modelData") - << singleRoleSource[i] - << QString("{ " - "var item = items.create(0, {\"name\": \"eight\"}); " - "item.setTest5(\"seven\"); }") - << 4 << 5 << 0 << true << true << false << false << true - << QString("name") - << (QStringList() << "seven" << "one" << "two" << "three" << "four"); - - QTest::newRow("AbstractItemModel.items create prepended, edit model.modelData") - << singleRoleSource[i] - << QString("{ " - "var item = items.create(0, {\"name\": \"eight\"}); " - "item.setTest6(\"seven\"); }") - << 4 << 5 << 0 << true << true << false << false << true - << QString("name") - << (QStringList() << "seven" << "one" << "two" << "three" << "four"); - - // AbstractItemModel (Multiple Roles). - QTest::newRow("StandardItemModel.items prepend") - << multipleRoleSource[i] - << QString("items.insert(0, {\"display\": \"Row 8 Item\"})") - << 4 << 5 << 0 << true << false << false << false << false - << QString("display") - << (QStringList() << "Row 8 Item" << "Row 1 Item" << "Row 2 Item" << "Row 3 Item" << "Row 4 Item"); - - QTest::newRow("StandardItemModel.items append") - << multipleRoleSource[i] - << QString("items.insert({\"display\": \"Row 8 Item\"})") - << 4 << 5 << 4 << true << false << false << false << false - << QString("display") - << (QStringList() << "Row 1 Item" << "Row 2 Item" << "Row 3 Item" << "Row 4 Item" << "Row 8 Item"); - - QTest::newRow("StandardItemModel.items insert at 2") - << multipleRoleSource[i] - << QString("items.insert(2, {\"display\": \"Row 8 Item\"})") - << 4 << 5 << 2 << true << false << false << false << false - << QString("display") - << (QStringList() << "Row 1 Item" << "Row 2 Item" << "Row 8 Item" << "Row 3 Item" << "Row 4 Item"); - - QTest::newRow("StandardItemModel.items prepend modelData") - << multipleRoleSource[i] - << QString("items.insert(0, {\"modelData\": \"Row 8 Item\"})") - << 4 << 5 << 0 << true << false << false << false << false - << QString("display") - << (QStringList() << QString() << "Row 1 Item" << "Row 2 Item" << "Row 3 Item" << "Row 4 Item"); - - QTest::newRow("StandardItemModel.items prepend, edit display") - << multipleRoleSource[i] - << QString("{ " - "items.insert(0, {\"display\": \"Row 8 Item\"}); " - "items.get(0).model.display = \"Row 7 Item\"; }") - << 4 << 5 << 0 << true << false << false << false << false - << QString("display") - << (QStringList() << "Row 7 Item" << "Row 1 Item" << "Row 2 Item" << "Row 3 Item" << "Row 4 Item"); - - QTest::newRow("StandardItemModel.items prepend, edit modelData") - << multipleRoleSource[i] - << QString("{ " - "items.insert(0, {\"display\": \"Row 8 Item\"}); " - "items.get(0).model.modelData = \"Row 7 Item\"; }") - << 4 << 5 << 0 << true << false << false << false << false - << QString("display") - << (QStringList() << "Row 8 Item" << "Row 1 Item" << "Row 2 Item" << "Row 3 Item" << "Row 4 Item"); - - QTest::newRow("StandardItemModel.items prepend, edit resolved") - << multipleRoleSource[i] - << QString("{ " - "items.insert(0, {\"display\": \"Row 8 Item\"}); " - "items.get(2).model.display = \"Row 7 Item\"; }") - << 4 << 5 << 0 << true << false << false << false << false - << QString("display") - << (QStringList() << "Row 8 Item" << "Row 1 Item" << "Row 2 Item" << "Row 3 Item" << "Row 4 Item"); - - QTest::newRow("StandardItemModel.create prepend modelData") - << multipleRoleSource[i] - << QString("items.create(0, {\"modelData\": \"Row 8 Item\"})") - << 4 << 5 << 0 << true << true << false << false << false - << QString("display") - << (QStringList() << QString() << "Row 1 Item" << "Row 2 Item" << "Row 3 Item" << "Row 4 Item"); - - QTest::newRow("StandardItemModel.items create prepended, edit display") - << multipleRoleSource[i] - << QString("{ " - "var item = items.create(0, {\"display\": \"Row 8 Item\"}); " - "item.setTest3(\"Row 7 Item\"); }") - << 4 << 5 << 0 << true << true << false << false << false - << QString("display") - << (QStringList() << "Row 7 Item" << "Row 1 Item" << "Row 2 Item" << "Row 3 Item" << "Row 4 Item"); - - QTest::newRow("StandardItemModel.items create prepended, edit model.display") - << multipleRoleSource[i] - << QString("{ " - "var item = items.create(0, {\"display\": \"Row 8 Item\"}); " - "item.setTest4(\"Row 7 Item\"); }") - << 4 << 5 << 0 << true << true << false << false << false - << QString("display") - << (QStringList() << "Row 7 Item" << "Row 1 Item" << "Row 2 Item" << "Row 3 Item" << "Row 4 Item"); - - // StringList. - QTest::newRow("StringList.items prepend") - << stringListSource[i] - << QString("items.insert(0, {\"modelData\": \"eight\"})") - << 4 << 5 << 0 << true << false << false << false << false - << QString("modelData") - << (QStringList() << "eight" << "one" << "two" << "three" << "four"); - - QTest::newRow("StringList.items append") - << stringListSource[i] - << QString("items.insert({\"modelData\": \"eight\"})") - << 4 << 5 << 4 << true << false << false << false << false - << QString("modelData") - << (QStringList() << "one" << "two" << "three" << "four" << "eight"); - - QTest::newRow("StringList.items insert at 2") - << stringListSource[i] - << QString("items.insert(2, {\"modelData\": \"eight\"})") - << 4 << 5 << 2 << true << false << false << false << false - << QString("modelData") - << (QStringList() << "one" << "two" << "eight" << "three" << "four"); - - QTest::newRow("StringList.items prepend, edit modelData") - << stringListSource[i] - << QString("{ " - "items.insert(0, {\"modelData\": \"eight\"}); " - "items.get(0).model.modelData = \"seven\"; }") - << 4 << 5 << 0 << true << false << false << false << false - << QString("modelData") - << (QStringList() << "seven" << "one" << "two" << "three" << "four"); - - QTest::newRow("StringList.items prepend, edit resolved") - << stringListSource[i] - << QString("{ " - "items.insert(0, {\"modelData\": \"eight\"}); " - "items.get(2).model.modelData = \"seven\"; }") - << 4 << 5 << 0 << true << false << false << false << false - << QString("modelData") - << (QStringList() << "eight" << "one" << "two" << "three" << "four"); - - QTest::newRow("StringList.create prepend modelData") - << stringListSource[i] - << QString("items.create(0, {\"modelData\": \"eight\"})") - << 4 << 5 << 0 << true << true << false << false << false - << QString("modelData") - << (QStringList() << "eight" << "one" << "two" << "three" << "four"); - - QTest::newRow("StringList.items create prepended, edit modelData") - << stringListSource[i] - << QString("{ " - "var item = items.create(0, {\"modelData\": \"eight\"}); " - "item.setTest3(\"seven\"); }") - << 4 << 5 << 0 << true << true << false << false << false - << QString("modelData") - << (QStringList() << "seven" << "one" << "two" << "three" << "four"); - - QTest::newRow("StringList.items create prepended, edit model.modelData") - << stringListSource[i] - << QString("{ " - "var item = items.create(0, {\"modelData\": \"eight\"}); " - "item.setTest4(\"seven\"); }") - << 4 << 5 << 0 << true << true << false << false << false - << QString("modelData") - << (QStringList() << "seven" << "one" << "two" << "three" << "four"); - - // ObjectList - QTest::newRow("ObjectList.items prepend") - << objectListSource[i] - << QString("items.insert(0, {\"name\": \"Item 8\"})") - << 4 << 4 << 4 << false << false << false << false << false - << QString("name") - << (QStringList() << "Item 1" << "Item 2" << "Item 3" << "Item 4"); - - QTest::newRow("ObjectList.items append") - << objectListSource[i] - << QString("items.insert({\"name\": \"Item 8\"})") - << 4 << 4 << 4 << false << false << false << false << false - << QString("name") - << (QStringList() << "Item 1" << "Item 2" << "Item 3" << "Item 4"); - - QTest::newRow("ObjectList.items insert at 2") - << objectListSource[i] - << QString("items.insert(2, {\"name\": \"Item 8\"})") - << 4 << 4 << 4 << false << false << false << false << false - << QString("name") - << (QStringList() << "Item 1" << "Item 2" << "Item 3" << "Item 4"); - } -} - -void tst_qquickvisualdatamodel::insert() -{ - QFETCH(QUrl, source); - QFETCH(QString, expression); - QFETCH(int, modelCount); - QFETCH(int, visualCount); - QFETCH(int, index); - QFETCH(bool, inItems); - QFETCH(bool, persisted); - QFETCH(bool, visible); - QFETCH(bool, selected); - QFETCH(bool, modelData); - QFETCH(QString, property); - QFETCH(QStringList, propertyData); - - QQuickCanvas canvas; - - QDeclarativeComponent component(&engine); - component.loadUrl(source); - QScopedPointer object(component.create()); - QQuickListView *listView = qobject_cast(object.data()); - QVERIFY(listView); - listView->setParentItem(canvas.rootItem()); - - QQuickItem *contentItem = listView->contentItem(); - QVERIFY(contentItem); - - QObject *visualModel = listView->findChild("visualModel"); - QVERIFY(visualModel); - - evaluate(visualModel, expression); - - QCOMPARE(evaluate(listView, "count"), inItems ? visualCount : modelCount); - QCOMPARE(evaluate(visualModel, "count"), inItems ? visualCount : modelCount); - QCOMPARE(evaluate(visualModel, "items.count"), inItems ? visualCount : modelCount); - QCOMPARE(evaluate(visualModel, "persistedItems.count"), persisted ? 1 : 0); - QCOMPARE(evaluate(visualModel, "visibleItems.count"), visible ? visualCount : modelCount); - QCOMPARE(evaluate(visualModel, "selectedItems.count"), selected ? 1 : 0); - - QCOMPARE(propertyData.count(), visualCount); - for (int i = 0; i < visualCount; ++i) { - int modelIndex = i; - if (modelIndex > index) - modelIndex -= 1; - else if (modelIndex == index) - modelIndex = -1; - - const int itemsIndex = inItems || i <= index ? i : i - 1; - QString get; - - if (i != index) { - get = QString("items.get(%1)").arg(itemsIndex); - - QQuickItem *item = findItem(contentItem, "delegate", modelIndex); - QVERIFY(item); - - QCOMPARE(evaluate(item, "test1"), modelIndex); - QCOMPARE(evaluate(item, "test2"), modelIndex); - QCOMPARE(evaluate(item, "test3"), propertyData.at(i)); - QCOMPARE(evaluate(item, "test4"), propertyData.at(i)); - - if (modelData) { - QCOMPARE(evaluate(item, "test5"), propertyData.at(i)); - QCOMPARE(evaluate(item, "test6"), propertyData.at(i)); - } - - QCOMPARE(evaluate(item, "delegate.VisualDataModel.inItems"), true); - QCOMPARE(evaluate(item, "delegate.VisualDataModel.inPersistedItems"), false); - QCOMPARE(evaluate(item, "delegate.VisualDataModel.inVisible"), true); - QCOMPARE(evaluate(item, "delegate.VisualDataModel.inSelected"), false); - QCOMPARE(evaluate(item, "delegate.VisualDataModel.isUnresolved"), false); - - QCOMPARE(evaluate(item, "delegate.VisualDataModel.itemsIndex"), itemsIndex); - QCOMPARE(evaluate(item, "delegate.VisualDataModel.persistedItemsIndex"), persisted && i > index ? 1 : 0); - QCOMPARE(evaluate(item, "delegate.VisualDataModel.visibleIndex"), visible || i <= index ? i : i - 1); - QCOMPARE(evaluate(item, "delegate.VisualDataModel.selectedIndex"), selected && i > index ? 1 : 0); - } else if (inItems) { - get = QString("items.get(%1)").arg(index); - } else if (persisted) { - get = "persistedItems.get(0)"; - } else if (visible) { - get = QString("visibleItems.get(%1)").arg(index); - } else if (selected) { - get = "selectedItems.get(0)"; - } else { - continue; - } - - QCOMPARE(evaluate(visualModel, get + ".model.index"), modelIndex); - - QCOMPARE(evaluate(visualModel, get + ".model." + property), propertyData.at(i)); - - QCOMPARE(evaluate(visualModel, get + ".inItems"), inItems || i != index); - QCOMPARE(evaluate(visualModel, get + ".inPersistedItems"), persisted && i == index); - QCOMPARE(evaluate(visualModel, get + ".inVisible"), visible || i != index); - QCOMPARE(evaluate(visualModel, get + ".inSelected"), selected && i == index); - QCOMPARE(evaluate(visualModel, get + ".isUnresolved"), i == index); - - QCOMPARE(evaluate(visualModel, get + ".itemsIndex"), inItems || i <= index ? i : i - 1); - QCOMPARE(evaluate(visualModel, get + ".persistedItemsIndex"), persisted && i > index ? 1 : 0); - QCOMPARE(evaluate(visualModel, get + ".visibleIndex"), visible || i <= index ? i : i - 1); - QCOMPARE(evaluate(visualModel, get + ".selectedIndex"), selected && i > index ? 1 : 0); - } - - QObject *item = 0; - - if (inItems) - item = evaluate(visualModel, QString("items.create(%1)").arg(index)); - else if (persisted) - item = evaluate(visualModel, QString("persistedItems.create(%1)").arg(0)); - else if (visible) - item = evaluate(visualModel, QString("visibleItems.create(%1)").arg(index)); - else if (selected) - item = evaluate(visualModel, QString("selectedItems.create(%1)").arg(0)); - else - return; - - QVERIFY(item); - - QCOMPARE(evaluate(item, "test1"), -1); - QCOMPARE(evaluate(item, "test2"), -1); - QCOMPARE(evaluate(item, "test3"), propertyData.at(index)); - QCOMPARE(evaluate(item, "test4"), propertyData.at(index)); - - if (modelData) { - QCOMPARE(evaluate(item, "test5"), propertyData.at(index)); - QCOMPARE(evaluate(item, "test6"), propertyData.at(index)); - } - - QCOMPARE(evaluate(item, "delegate.VisualDataModel.inItems"), inItems); - QCOMPARE(evaluate(item, "delegate.VisualDataModel.inPersistedItems"), true); - QCOMPARE(evaluate(item, "delegate.VisualDataModel.inVisible"), visible); - QCOMPARE(evaluate(item, "delegate.VisualDataModel.inSelected"), selected); - QCOMPARE(evaluate(item, "delegate.VisualDataModel.isUnresolved"), true); - - QCOMPARE(evaluate(item, "delegate.VisualDataModel.itemsIndex"), index); - QCOMPARE(evaluate(item, "delegate.VisualDataModel.persistedItemsIndex"), 0); - QCOMPARE(evaluate(item, "delegate.VisualDataModel.visibleIndex"), index); - QCOMPARE(evaluate(item, "delegate.VisualDataModel.selectedIndex"), 0); -} - -void tst_qquickvisualdatamodel::resolve_data() -{ - QTest::addColumn("source"); - QTest::addColumn("setupExpression"); - QTest::addColumn("resolveExpression"); - QTest::addColumn("unresolvedCount"); - QTest::addColumn("modelCount"); - QTest::addColumn("visualCount"); - QTest::addColumn("index"); - QTest::addColumn("inItems"); - QTest::addColumn("persisted"); - QTest::addColumn("visible"); - QTest::addColumn("selected"); - QTest::addColumn("modelData"); - QTest::addColumn("property"); - QTest::addColumn("propertyData"); - - const QUrl listModelSource[] = { - testFileUrl("listmodelproperties.qml"), - testFileUrl("listmodelproperties-package.qml") }; - const QUrl singleRoleSource[] = { - testFileUrl("singleroleproperties.qml"), - testFileUrl("singleroleproperties-package.qml") }; - const QUrl multipleRoleSource[] = { - testFileUrl("multipleroleproperties.qml"), - testFileUrl("multipleroleproperties-package.qml") }; - const QUrl stringListSource[] = { - testFileUrl("stringlistproperties.qml"), - testFileUrl("stringlistproperties-package.qml") }; - const QUrl objectListSource[] = { - testFileUrl("objectlistproperties.qml"), - testFileUrl("objectlistproperties-package.qml") }; - - for (int i = 0; i < 2; ++i) { - // List Model. - QTest::newRow("ListModel.items prepend, resolve prepended") - << listModelSource[i] - << QString("items.insert(0, {\"number\": \"eight\"})") - << QString("{ listModel.insert(0, {\"number\": \"seven\"}); items.resolve(0, 1) }") - << 5 << 5 << 5 << 0 << true << false << true << false << true - << QString("number") - << (QStringList() << "seven" << "one" << "two" << "three" << "four"); - - QTest::newRow("ListModel.items prepend, resolve appended") - << listModelSource[i] - << QString("items.insert(0, {\"number\": \"eight\"})") - << QString("{ listModel.append({\"number\": \"seven\"}); items.resolve(0, 5) }") - << 5 << 5 << 5 << 4 << true << false << true << false << true - << QString("number") - << (QStringList() << "one" << "two" << "three" << "four" << "seven"); - - QTest::newRow("ListModel.items prepend, resolve inserted") - << listModelSource[i] - << QString("items.insert(0, {\"number\": \"eight\"})") - << QString("{ listModel.insert(2, {\"number\": \"seven\"}); items.resolve(0, 3) }") - << 5 << 5 << 5 << 2 << true << false << true << false << true - << QString("number") - << (QStringList() << "one" << "two" << "seven" << "three" << "four"); - - QTest::newRow("ListModel.items append, resolve prepended") - << listModelSource[i] - << QString("items.insert({\"number\": \"eight\"})") - << QString("{ listModel.insert(0, {\"number\": \"seven\"}); items.resolve(5, 0) }") - << 5 << 5 << 5 << 0 << true << false << true << false << true - << QString("number") - << (QStringList() << "seven" << "one" << "two" << "three" << "four"); - - QTest::newRow("ListModel.items append, resolve appended") - << listModelSource[i] - << QString("items.insert({\"number\": \"eight\"})") - << QString("{ listModel.append({\"number\": \"seven\"}); items.resolve(5, 4) }") - << 5 << 5 << 5 << 4 << true << false << true << false << true - << QString("number") - << (QStringList() << "one" << "two" << "three" << "four" << "seven"); - - QTest::newRow("ListModel.items append, resolve inserted") - << listModelSource[i] - << QString("items.insert({\"number\": \"eight\"})") - << QString("{ listModel.insert(2, {\"number\": \"seven\"}); items.resolve(5, 2) }") - << 5 << 5 << 5 << 2 << true << false << true << false << true - << QString("number") - << (QStringList() << "one" << "two" << "seven" << "three" << "four"); - - QTest::newRow("ListModel.items insert, resolve prepended") - << listModelSource[i] - << QString("items.insert(2, {\"number\": \"eight\"})") - << QString("{ listModel.insert(0, {\"number\": \"seven\"}); items.resolve(3, 0) }") - << 5 << 5 << 5 << 0 << true << false << true << false << true - << QString("number") - << (QStringList() << "seven" << "one" << "two" << "three" << "four"); - - QTest::newRow("ListModel.items insert, resolve appended") - << listModelSource[i] - << QString("items.insert(2, {\"number\": \"eight\"})") - << QString("{ listModel.append({\"number\": \"seven\"}); items.resolve(2, 5) }") - << 5 << 5 << 5 << 4 << true << false << true << false << true - << QString("number") - << (QStringList() << "one" << "two" << "three" << "four" << "seven"); - - QTest::newRow("ListModel.items insert, resolve inserted") - << listModelSource[i] - << QString("items.insert(2, {\"number\": \"eight\"})") - << QString("{ listModel.insert(2, {\"number\": \"seven\"}); items.resolve(2, 3) }") - << 5 << 5 << 5 << 2 << true << false << true << false << true - << QString("number") - << (QStringList() << "one" << "two" << "seven" << "three" << "four"); - - QTest::newRow("ListModel.items prepend, move resolved") - << listModelSource[i] - << QString("items.insert(0, {\"number\": \"eight\"})") - << QString("{ listModel.insert(0, {\"number\": \"seven\"}); " - "items.resolve(0, 1); " - "listModel.move(0, 2, 1) }") - << 5 << 5 << 5 << 2 << true << false << true << false << true - << QString("number") - << (QStringList() << "one" << "two" << "seven" << "three" << "four"); - - QTest::newRow("ListModel.items append, move resolved") - << listModelSource[i] - << QString("items.insert({\"number\": \"eight\"})") - << QString("{ listModel.append({\"number\": \"seven\"}); " - "items.resolve(5, 4); " - "listModel.move(4, 2, 1) }") - << 5 << 5 << 5 << 2 << true << false << true << false << true - << QString("number") - << (QStringList() << "one" << "two" << "seven" << "three" << "four"); - - QTest::newRow("ListModel.items insert, move resolved") - << listModelSource[i] - << QString("items.insert(2, {\"number\": \"eight\"})") - << QString("{ listModel.insert(2, {\"number\": \"seven\"}); " - "items.resolve(2, 3);" - "listModel.move(2, 0, 1) }") - << 5 << 5 << 5 << 0 << true << false << true << false << true - << QString("number") - << (QStringList() << "seven" << "one" << "two" << "three" << "four"); - - QTest::newRow("ListModel.items prepend, remove resolved") - << listModelSource[i] - << QString("items.insert(0, {\"number\": \"eight\"})") - << QString("{ listModel.insert(0, {\"number\": \"seven\"}); " - "items.resolve(0, 1); " - "listModel.remove(0, 1) }") - << 5 << 4 << 4 << 4 << false << false << false << false << true - << QString("number") - << (QStringList() << "one" << "two" << "three" << "four"); - - QTest::newRow("ListModel.items append, remove resolved") - << listModelSource[i] - << QString("items.insert({\"number\": \"eight\"})") - << QString("{ listModel.append({\"number\": \"seven\"}); " - "items.resolve(5, 4); " - "listModel.remove(4, 1) }") - << 5 << 4 << 4 << 4 << false << false << false << false << true - << QString("number") - << (QStringList() << "one" << "two" << "three" << "four"); - - QTest::newRow("ListModel.items insert, remove resolved") - << listModelSource[i] - << QString("items.insert(2, {\"number\": \"eight\"})") - << QString("{ listModel.insert(2, {\"number\": \"seven\"}); " - "items.resolve(2, 3);" - "listModel.remove(2, 1) }") - << 5 << 4 << 4 << 4 << false << false << false << false << true - << QString("number") - << (QStringList() << "one" << "two" << "three" << "four"); - - QTest::newRow("ListModel.selectedItems prepend, resolve prepended") - << listModelSource[i] - << QString("selectedItems.insert(0, {\"number\": \"eight\"})") - << QString("{ listModel.insert(0, {\"number\": \"seven\"}); " - "selectedItems.resolve(selectedItems.get(0), items.get(0)) }") - << 4 << 5 << 5 << 0 << true << false << true << true << true - << QString("number") - << (QStringList() << "seven" << "one" << "two" << "three" << "four"); - - QTest::newRow("ListModel.selectedItems prepend, resolve appended") - << listModelSource[i] - << QString("selectedItems.insert(0, {\"number\": \"eight\"})") - << QString("{ listModel.append({\"number\": \"seven\"}); " - "selectedItems.resolve(selectedItems.get(0), items.get(4)) }") - << 4 << 5 << 5 << 4 << true << false << true << true << true - << QString("number") - << (QStringList() << "one" << "two" << "three" << "four" << "seven"); - - QTest::newRow("ListModel.selectedItems prepend, resolve inserted") - << listModelSource[i] - << QString("selectedItems.insert(0, {\"number\": \"eight\"})") - << QString("{ listModel.insert(2, {\"number\": \"seven\"}); " - "selectedItems.resolve(selectedItems.get(0), items.get(2)) }") - << 4 << 5 << 5 << 2 << true << false << true << true << true - << QString("number") - << (QStringList() << "one" << "two" << "seven" << "three" << "four"); - - QTest::newRow("ListModel.selectedItems append, resolve prepended") - << listModelSource[i] - << QString("selectedItems.insert({\"number\": \"eight\"})") - << QString("{ listModel.insert(0, {\"number\": \"seven\"}); " - "selectedItems.resolve(selectedItems.get(0), items.get(0)) }") - << 4 << 5 << 5 << 0 << true << false << true << true << true - << QString("number") - << (QStringList() << "seven" << "one" << "two" << "three" << "four"); - - QTest::newRow("ListModel.selectedItems append, resolve appended") - << listModelSource[i] - << QString("selectedItems.insert({\"number\": \"eight\"})") - << QString("{ listModel.append({\"number\": \"seven\"}); " - "selectedItems.resolve(selectedItems.get(0), items.get(4)) }") - << 4 << 5 << 5 << 4 << true << false << true << true << true - << QString("number") - << (QStringList() << "one" << "two" << "three" << "four" << "seven"); - - QTest::newRow("ListModel.selectedItems append, resolve inserted") - << listModelSource[i] - << QString("selectedItems.insert({\"number\": \"eight\"})") - << QString("{ listModel.insert(2, {\"number\": \"seven\"}); " - "selectedItems.resolve(selectedItems.get(0), items.get(2)) }") - << 4 << 5 << 5 << 2 << true << false << true << true << true - << QString("number") - << (QStringList() << "one" << "two" << "seven" << "three" << "four"); - - // AbstractItemModel (Single Role) - QTest::newRow("ListModel.items prepend, resolve prepended") - << singleRoleSource[i] - << QString("items.insert(0, {\"name\": \"eight\"})") - << QString("{ items.resolve(0, 1) }") - << 5 << 4 << 4 << 0 << true << false << true << false << true - << QString("name") - << (QStringList() << "one" << "two" << "three" << "four"); - - - QTest::newRow("ListModel.items append, resolve appended") - << singleRoleSource[i] - << QString("items.insert({\"name\": \"eight\"})") - << QString("{ items.resolve(4, 3) }") - << 5 << 4 << 4 << 3 << true << false << true << false << true - << QString("name") - << (QStringList() << "one" << "two" << "three" << "four"); - - QTest::newRow("ListModel.items insert, resolve inserted") - << singleRoleSource[i] - << QString("items.insert(2, {\"name\": \"eight\"})") - << QString("{ items.resolve(2, 3) }") - << 5 << 4 << 4 << 2 << true << false << true << false << true - << QString("name") - << (QStringList() << "one" << "two" << "three" << "four"); - - // AbstractItemModel (Single Role) - QTest::newRow("AbstractItemModel.items prepend, resolve prepended") - << singleRoleSource[i] - << QString("items.insert(0, {\"name\": \"eight\"})") - << QString("{ items.resolve(0, 1) }") - << 5 << 4 << 4 << 0 << true << false << true << false << true - << QString("name") - << (QStringList() << "one" << "two" << "three" << "four"); - - QTest::newRow("AbstractItemModel.items append, resolve appended") - << singleRoleSource[i] - << QString("items.insert({\"name\": \"eight\"})") - << QString("{ items.resolve(4, 3) }") - << 5 << 4 << 4 << 3 << true << false << true << false << true - << QString("name") - << (QStringList() << "one" << "two" << "three" << "four"); - - QTest::newRow("AbstractItemModel.items insert, resolve inserted") - << singleRoleSource[i] - << QString("items.insert(2, {\"name\": \"eight\"})") - << QString("{ items.resolve(2, 3) }") - << 5 << 4 << 4 << 2 << true << false << true << false << true - << QString("name") - << (QStringList() << "one" << "two" << "three" << "four"); - - // AbstractItemModel (Multiple Roles) - QTest::newRow("StandardItemModel.items prepend, resolve prepended") - << multipleRoleSource[i] - << QString("items.insert(0, {\"display\": \"Row 8 Item\"})") - << QString("{ items.resolve(0, 1) }") - << 5 << 4 << 4 << 0 << true << false << true << false << false - << QString("display") - << (QStringList() << "Row 1 Item" << "Row 2 Item" << "Row 3 Item" << "Row 4 Item"); - - QTest::newRow("StandardItemModel.items append, resolve appended") - << multipleRoleSource[i] - << QString("items.insert({\"display\": \"Row 8 Item\"})") - << QString("{ items.resolve(4, 3) }") - << 5 << 4 << 4 << 3 << true << false << true << false << false - << QString("display") - << (QStringList() << "Row 1 Item" << "Row 2 Item" << "Row 3 Item" << "Row 4 Item"); - - QTest::newRow("StandardItemModel.items insert, resolve inserted") - << multipleRoleSource[i] - << QString("items.insert(2, {\"display\": \"Row 8 Item\"})") - << QString("{ items.resolve(2, 3) }") - << 5 << 4 << 4 << 2 << true << false << true << false << false - << QString("display") - << (QStringList() << "Row 1 Item" << "Row 2 Item" << "Row 3 Item" << "Row 4 Item"); - - // StringList - QTest::newRow("StringList.items prepend, resolve prepended") - << stringListSource[i] - << QString("items.insert(0, {\"modelData\": \"eight\"})") - << QString("{ items.resolve(0, 1) }") - << 5 << 4 << 4 << 0 << true << false << true << false << false - << QString("modelData") - << (QStringList() << "one" << "two" << "three" << "four"); - - QTest::newRow("StringList.items append, resolve appended") - << stringListSource[i] - << QString("items.insert({\"modelData\": \"eight\"})") - << QString("{ items.resolve(4, 3) }") - << 5 << 4 << 4 << 3 << true << false << true << false << false - << QString("modelData") - << (QStringList() << "one" << "two" << "three" << "four"); - - QTest::newRow("StringList.items insert, resolve inserted") - << stringListSource[i] - << QString("items.insert(2, {\"modelData\": \"eight\"})") - << QString("{ items.resolve(2, 3) }") - << 5 << 4 << 4 << 2 << true << false << true << false << false - << QString("modelData") - << (QStringList() << "one" << "two" << "three" << "four"); - } -} - -void tst_qquickvisualdatamodel::resolve() -{ - QFETCH(QUrl, source); - QFETCH(QString, setupExpression); - QFETCH(QString, resolveExpression); - QFETCH(int, unresolvedCount); - QFETCH(int, modelCount); - QFETCH(int, visualCount); - QFETCH(int, index); - QFETCH(bool, inItems); - QFETCH(bool, persisted); - QFETCH(bool, visible); - QFETCH(bool, selected); - QFETCH(bool, modelData); - QFETCH(QString, property); - QFETCH(QStringList, propertyData); - - QQuickCanvas canvas; - - QDeclarativeComponent component(&engine); - component.loadUrl(source); - QScopedPointer object(component.create()); - QQuickListView *listView = qobject_cast(object.data()); - QVERIFY(listView); - listView->setParentItem(canvas.rootItem()); - - QQuickItem *contentItem = listView->contentItem(); - QVERIFY(contentItem); - - QObject *visualModel = listView->findChild("visualModel"); - QVERIFY(visualModel); - - evaluate(visualModel, setupExpression); - QCOMPARE(evaluate(listView, "count"), unresolvedCount); - - evaluate(visualModel, resolveExpression); - - QCOMPARE(evaluate(listView, "count"), inItems ? visualCount : modelCount); - QCOMPARE(evaluate(visualModel, "count"), inItems ? visualCount : modelCount); - QCOMPARE(evaluate(visualModel, "items.count"), inItems ? visualCount : modelCount); - QCOMPARE(evaluate(visualModel, "persistedItems.count"), persisted ? 1 : 0); - QCOMPARE(evaluate(visualModel, "visibleItems.count"), visible ? visualCount : modelCount); - QCOMPARE(evaluate(visualModel, "selectedItems.count"), selected ? 1 : 0); - - QCOMPARE(propertyData.count(), visualCount); - for (int i = 0; i < visualCount; ++i) { - int modelIndex = i; - - const int itemsIndex = inItems || i <= index ? i : i - 1; - QString get; - - if (i != index) { - get = QString("items.get(%1)").arg(itemsIndex); - - QQuickItem *item = findItem(contentItem, "delegate", modelIndex); - QVERIFY(item); - - QCOMPARE(evaluate(item, "test1"), modelIndex); - QCOMPARE(evaluate(item, "test2"), modelIndex); - QCOMPARE(evaluate(item, "test3"), propertyData.at(i)); - QCOMPARE(evaluate(item, "test4"), propertyData.at(i)); - - if (modelData) { - QCOMPARE(evaluate(item, "test5"), propertyData.at(i)); - QCOMPARE(evaluate(item, "test6"), propertyData.at(i)); - } - - QCOMPARE(evaluate(item, "delegate.VisualDataModel.inItems"), true); - QCOMPARE(evaluate(item, "delegate.VisualDataModel.inPersistedItems"), false); - QCOMPARE(evaluate(item, "delegate.VisualDataModel.inVisible"), true); - QCOMPARE(evaluate(item, "delegate.VisualDataModel.inSelected"), false); - QCOMPARE(evaluate(item, "delegate.VisualDataModel.isUnresolved"), false); - - QCOMPARE(evaluate(item, "delegate.VisualDataModel.itemsIndex"), itemsIndex); - QCOMPARE(evaluate(item, "delegate.VisualDataModel.persistedItemsIndex"), persisted && i > index ? 1 : 0); - QCOMPARE(evaluate(item, "delegate.VisualDataModel.visibleIndex"), visible || i <= index ? i : i - 1); - QCOMPARE(evaluate(item, "delegate.VisualDataModel.selectedIndex"), selected && i > index ? 1 : 0); - } else if (inItems) { - get = QString("items.get(%1)").arg(index); - } else if (persisted) { - get = "persistedItems.get(0)"; - } else if (visible) { - get = QString("visibleItems.get(%1)").arg(index); - } else if (selected) { - get = "selectedItems.get(0)"; - } else { - continue; - } - - QCOMPARE(evaluate(visualModel, get + ".model.index"), modelIndex); - - QCOMPARE(evaluate(visualModel, get + ".model." + property), propertyData.at(i)); - - QCOMPARE(evaluate(visualModel, get + ".inItems"), inItems || i != index); - QCOMPARE(evaluate(visualModel, get + ".inPersistedItems"), persisted && i == index); - QCOMPARE(evaluate(visualModel, get + ".inVisible"), visible || i != index); - QCOMPARE(evaluate(visualModel, get + ".inSelected"), selected && i == index); - QCOMPARE(evaluate(visualModel, get + ".isUnresolved"), false); - - QCOMPARE(evaluate(visualModel, get + ".itemsIndex"), inItems || i <= index ? i : i - 1); - QCOMPARE(evaluate(visualModel, get + ".persistedItemsIndex"), persisted && i > index ? 1 : 0); - QCOMPARE(evaluate(visualModel, get + ".visibleIndex"), visible || i <= index ? i : i - 1); - QCOMPARE(evaluate(visualModel, get + ".selectedIndex"), selected && i > index ? 1 : 0); - } - - QObject *item = 0; - - if (inItems) - item = evaluate(visualModel, QString("items.create(%1)").arg(index)); - else if (persisted) - item = evaluate(visualModel, QString("persistedItems.create(%1)").arg(0)); - else if (visible) - item = evaluate(visualModel, QString("visibleItems.create(%1)").arg(index)); - else if (selected) - item = evaluate(visualModel, QString("selectedItems.create(%1)").arg(0)); - else - return; - - QVERIFY(item); - - QCOMPARE(evaluate(item, "test1"), index); - QCOMPARE(evaluate(item, "test2"), index); - QCOMPARE(evaluate(item, "test3"), propertyData.at(index)); - QCOMPARE(evaluate(item, "test4"), propertyData.at(index)); - - if (modelData) { - QCOMPARE(evaluate(item, "test5"), propertyData.at(index)); - QCOMPARE(evaluate(item, "test6"), propertyData.at(index)); - } - - QCOMPARE(evaluate(item, "delegate.VisualDataModel.inItems"), inItems); - QCOMPARE(evaluate(item, "delegate.VisualDataModel.inPersistedItems"), true); - QCOMPARE(evaluate(item, "delegate.VisualDataModel.inVisible"), visible); - QCOMPARE(evaluate(item, "delegate.VisualDataModel.inSelected"), selected); - QCOMPARE(evaluate(item, "delegate.VisualDataModel.isUnresolved"), false); - - QCOMPARE(evaluate(item, "delegate.VisualDataModel.itemsIndex"), index); - QCOMPARE(evaluate(item, "delegate.VisualDataModel.persistedItemsIndex"), 0); - QCOMPARE(evaluate(item, "delegate.VisualDataModel.visibleIndex"), index); - QCOMPARE(evaluate(item, "delegate.VisualDataModel.selectedIndex"), 0); -} - -void tst_qquickvisualdatamodel::warnings_data() -{ - QTest::addColumn("source"); - QTest::addColumn("expression"); - QTest::addColumn("warning"); - QTest::addColumn("count"); - - QTest::newRow("insert < 0") - << testFileUrl("listmodelproperties.qml") - << QString("items.insert(-2, {\"number\": \"eight\"})") - << (": QML VisualDataGroup: " + QQuickVisualDataGroup::tr("insert: index out of range")) - << 4; - - QTest::newRow("insert > length") - << testFileUrl("listmodelproperties.qml") - << QString("items.insert(8, {\"number\": \"eight\"})") - << (": QML VisualDataGroup: " + QQuickVisualDataGroup::tr("insert: index out of range")) - << 4; - - QTest::newRow("create < 0") - << testFileUrl("listmodelproperties.qml") - << QString("items.create(-2, {\"number\": \"eight\"})") - << (": QML VisualDataGroup: " + QQuickVisualDataGroup::tr("create: index out of range")) - << 4; - - QTest::newRow("create > length") - << testFileUrl("listmodelproperties.qml") - << QString("items.create(8, {\"number\": \"eight\"})") - << (": QML VisualDataGroup: " + QQuickVisualDataGroup::tr("create: index out of range")) - << 4; - - QTest::newRow("resolve from < 0") - << testFileUrl("listmodelproperties.qml") - << QString("items.resolve(-2, 3)") - << (": QML VisualDataGroup: " + QQuickVisualDataGroup::tr("resolve: from index out of range")) - << 4; - - QTest::newRow("resolve from > length") - << testFileUrl("listmodelproperties.qml") - << QString("items.resolve(8, 3)") - << (": QML VisualDataGroup: " + QQuickVisualDataGroup::tr("resolve: from index out of range")) - << 4; - - QTest::newRow("resolve to < 0") - << testFileUrl("listmodelproperties.qml") - << QString("items.resolve(3, -2)") - << (": QML VisualDataGroup: " + QQuickVisualDataGroup::tr("resolve: to index out of range")) - << 4; - - QTest::newRow("resolve to > length") - << testFileUrl("listmodelproperties.qml") - << QString("items.resolve(3, 8)") - << (": QML VisualDataGroup: " + QQuickVisualDataGroup::tr("resolve: to index out of range")) - << 4; - - QTest::newRow("resolve from invalid index") - << testFileUrl("listmodelproperties.qml") - << QString("items.resolve(\"two\", 3)") - << (": QML VisualDataGroup: " + QQuickVisualDataGroup::tr("resolve: from index invalid")) - << 4; - - QTest::newRow("resolve to invalid index") - << testFileUrl("listmodelproperties.qml") - << QString("items.resolve(3, \"two\")") - << (": QML VisualDataGroup: " + QQuickVisualDataGroup::tr("resolve: to index invalid")) - << 4; - - QTest::newRow("resolve already resolved item") - << testFileUrl("listmodelproperties.qml") - << QString("items.resolve(3, 2)") - << (": QML VisualDataGroup: " + QQuickVisualDataGroup::tr("resolve: from is not an unresolved item")) - << 4; - - QTest::newRow("resolve already resolved item") - << testFileUrl("listmodelproperties.qml") - << QString("{ items.insert(0, {\"number\": \"eight\"});" - "items.insert(1, {\"number\": \"seven\"});" - "items.resolve(0, 1)}") - << (": QML VisualDataGroup: " + QQuickVisualDataGroup::tr("resolve: to is not a model item")) - << 6; - - QTest::newRow("remove index < 0") - << testFileUrl("listmodelproperties.qml") - << QString("items.remove(-2, 1)") - << (": QML VisualDataGroup: " + QQuickVisualDataGroup::tr("remove: index out of range")) - << 4; - - QTest::newRow("remove index == length") - << testFileUrl("listmodelproperties.qml") - << QString("items.remove(4, 1)") - << (": QML VisualDataGroup: " + QQuickVisualDataGroup::tr("remove: index out of range")) - << 4; - - QTest::newRow("remove index > length") - << testFileUrl("listmodelproperties.qml") - << QString("items.remove(9, 1)") - << (": QML VisualDataGroup: " + QQuickVisualDataGroup::tr("remove: index out of range")) - << 4; - - QTest::newRow("remove invalid index") - << testFileUrl("listmodelproperties.qml") - << QString("items.remove(\"nine\", 1)") - << (": QML VisualDataGroup: " + QQuickVisualDataGroup::tr("remove: invalid index")) - << 4; - - QTest::newRow("remove count < 0") - << testFileUrl("listmodelproperties.qml") - << QString("items.remove(1, -2)") - << (": QML VisualDataGroup: " + QQuickVisualDataGroup::tr("remove: invalid count")) - << 4; - - QTest::newRow("remove index + count > length") - << testFileUrl("listmodelproperties.qml") - << QString("items.remove(2, 4, \"selected\")") - << (": QML VisualDataGroup: " + QQuickVisualDataGroup::tr("remove: invalid count")) - << 4; - - QTest::newRow("addGroups index < 0") - << testFileUrl("listmodelproperties.qml") - << QString("items.addGroups(-2, 1, \"selected\")") - << (": QML VisualDataGroup: " + QQuickVisualDataGroup::tr("addGroups: index out of range")) - << 4; - - QTest::newRow("addGroups index == length") - << testFileUrl("listmodelproperties.qml") - << QString("items.addGroups(4, 1, \"selected\")") - << (": QML VisualDataGroup: " + QQuickVisualDataGroup::tr("addGroups: index out of range")) - << 4; - - QTest::newRow("addGroups index > length") - << testFileUrl("listmodelproperties.qml") - << QString("items.addGroups(9, 1, \"selected\")") - << (": QML VisualDataGroup: " + QQuickVisualDataGroup::tr("addGroups: index out of range")) - << 4; - - QTest::newRow("addGroups count < 0") - << testFileUrl("listmodelproperties.qml") - << QString("items.addGroups(1, -2, \"selected\")") - << (": QML VisualDataGroup: " + QQuickVisualDataGroup::tr("addGroups: invalid count")) - << 4; - - QTest::newRow("addGroups index + count > length") - << testFileUrl("listmodelproperties.qml") - << QString("items.addGroups(2, 4, \"selected\")") - << (": QML VisualDataGroup: " + QQuickVisualDataGroup::tr("addGroups: invalid count")) - << 4; - - QTest::newRow("removeGroups index < 0") - << testFileUrl("listmodelproperties.qml") - << QString("items.removeGroups(-2, 1, \"selected\")") - << (": QML VisualDataGroup: " + QQuickVisualDataGroup::tr("removeGroups: index out of range")) - << 4; - - QTest::newRow("removeGroups index == length") - << testFileUrl("listmodelproperties.qml") - << QString("items.removeGroups(4, 1, \"selected\")") - << (": QML VisualDataGroup: " + QQuickVisualDataGroup::tr("removeGroups: index out of range")) - << 4; - - QTest::newRow("removeGroups index > length") - << testFileUrl("listmodelproperties.qml") - << QString("items.removeGroups(9, 1, \"selected\")") - << (": QML VisualDataGroup: " + QQuickVisualDataGroup::tr("removeGroups: index out of range")) - << 4; - - QTest::newRow("removeGroups count < 0") - << testFileUrl("listmodelproperties.qml") - << QString("items.removeGroups(1, -2, \"selected\")") - << (": QML VisualDataGroup: " + QQuickVisualDataGroup::tr("removeGroups: invalid count")) - << 4; - - QTest::newRow("removeGroups index + count > length") - << testFileUrl("listmodelproperties.qml") - << QString("items.removeGroups(2, 4, \"selected\")") - << (": QML VisualDataGroup: " + QQuickVisualDataGroup::tr("removeGroups: invalid count")) - << 4; - - QTest::newRow("setGroups index < 0") - << testFileUrl("listmodelproperties.qml") - << QString("items.setGroups(-2, 1, \"selected\")") - << (": QML VisualDataGroup: " + QQuickVisualDataGroup::tr("setGroups: index out of range")) - << 4; - - QTest::newRow("setGroups index == length") - << testFileUrl("listmodelproperties.qml") - << QString("items.setGroups(4, 1, \"selected\")") - << (": QML VisualDataGroup: " + QQuickVisualDataGroup::tr("setGroups: index out of range")) - << 4; - - QTest::newRow("setGroups index > length") - << testFileUrl("listmodelproperties.qml") - << QString("items.setGroups(9, 1, \"selected\")") - << (": QML VisualDataGroup: " + QQuickVisualDataGroup::tr("setGroups: index out of range")) - << 4; - - QTest::newRow("setGroups count < 0") - << testFileUrl("listmodelproperties.qml") - << QString("items.setGroups(1, -2, \"selected\")") - << (": QML VisualDataGroup: " + QQuickVisualDataGroup::tr("setGroups: invalid count")) - << 4; - - QTest::newRow("setGroups index + count > length") - << testFileUrl("listmodelproperties.qml") - << QString("items.setGroups(2, 4, \"selected\")") - << (": QML VisualDataGroup: " + QQuickVisualDataGroup::tr("setGroups: invalid count")) - << 4; - - QTest::newRow("move from < 0") - << testFileUrl("listmodelproperties.qml") - << QString("items.move(-2, 1, 1)") - << (": QML VisualDataGroup: " + QQuickVisualDataGroup::tr("move: from index out of range")) - << 4; - - QTest::newRow("move from == length") - << testFileUrl("listmodelproperties.qml") - << QString("items.move(4, 1, 1)") - << (": QML VisualDataGroup: " + QQuickVisualDataGroup::tr("move: from index out of range")) - << 4; - - QTest::newRow("move from > length") - << testFileUrl("listmodelproperties.qml") - << QString("items.move(9, 1, 1)") - << (": QML VisualDataGroup: " + QQuickVisualDataGroup::tr("move: from index out of range")) - << 4; - - QTest::newRow("move invalid from") - << testFileUrl("listmodelproperties.qml") - << QString("items.move(\"nine\", 1, 1)") - << (": QML VisualDataGroup: " + QQuickVisualDataGroup::tr("move: invalid from index")) - << 4; - - QTest::newRow("move to < 0") - << testFileUrl("listmodelproperties.qml") - << QString("items.move(1, -2, 1)") - << (": QML VisualDataGroup: " + QQuickVisualDataGroup::tr("move: to index out of range")) - << 4; - - QTest::newRow("move to == length") - << testFileUrl("listmodelproperties.qml") - << QString("items.move(1, 4, 1)") - << (": QML VisualDataGroup: " + QQuickVisualDataGroup::tr("move: to index out of range")) - << 4; - - QTest::newRow("move to > length") - << testFileUrl("listmodelproperties.qml") - << QString("items.move(1, 9, 1)") - << (": QML VisualDataGroup: " + QQuickVisualDataGroup::tr("move: to index out of range")) - << 4; - - QTest::newRow("move invalid to") - << testFileUrl("listmodelproperties.qml") - << QString("items.move(1, \"nine\", 1)") - << (": QML VisualDataGroup: " + QQuickVisualDataGroup::tr("move: invalid to index")) - << 4; - - QTest::newRow("move count < 0") - << testFileUrl("listmodelproperties.qml") - << QString("items.move(1, 1, -2)") - << (": QML VisualDataGroup: " + QQuickVisualDataGroup::tr("move: invalid count")) - << 4; - - QTest::newRow("move from + count > length") - << testFileUrl("listmodelproperties.qml") - << QString("items.move(2, 1, 4)") - << (": QML VisualDataGroup: " + QQuickVisualDataGroup::tr("move: from index out of range")) - << 4; -} - -void tst_qquickvisualdatamodel::warnings() -{ - QFETCH(QUrl, source); - QFETCH(QString, expression); - QFETCH(QString, warning); - QFETCH(int, count); - - QQuickCanvas canvas; - - QDeclarativeComponent component(&engine); - component.loadUrl(source); - QScopedPointer object(component.create()); - QQuickListView *listView = qobject_cast(object.data()); - QVERIFY(listView); - listView->setParentItem(canvas.rootItem()); - - QQuickItem *contentItem = listView->contentItem(); - QVERIFY(contentItem); - - QObject *visualModel = evaluate(listView, "model"); - QVERIFY(visualModel); - - QTest::ignoreMessage(QtWarningMsg, warning.toUtf8()); - - evaluate(visualModel, expression); - QCOMPARE(evaluate(listView, "count"), count); -} - - -QTEST_MAIN(tst_qquickvisualdatamodel) - -#include "tst_qquickvisualdatamodel.moc" diff --git a/tests/auto/qtquick2/qtquick2.pro b/tests/auto/qtquick2/qtquick2.pro deleted file mode 100644 index 7acd75f69e..0000000000 --- a/tests/auto/qtquick2/qtquick2.pro +++ /dev/null @@ -1,70 +0,0 @@ -TEMPLATE = subdirs - -PUBLICTESTS += \ - examples \ - geometry \ - nodes \ - rendernode \ - qdeclarativepixmapcache - -# This test requires the qtconcurrent module -!contains(QT_CONFIG, concurrent):PUBLICTESTS -= qdeclarativepixmapcache - -PRIVATETESTS += \ - qdeclarativeanimations \ - qdeclarativeapplication \ - qdeclarativebehaviors \ - qdeclarativefontloader \ - qdeclarativepath \ - qdeclarativesmoothedanimation \ - qdeclarativespringanimation \ - qdeclarativestyledtext \ - qdeclarativestates \ - qdeclarativesystempalette \ - qdeclarativetimer \ - qdeclarativexmllistmodel - -# This test requires the xmlpatterns module -!contains(QT_CONFIG,xmlpatterns):PRIVATETESTS -= qdeclarativexmllistmodel - -QUICKTESTS = \ - qquickaccessible \ - qquickanchors \ - qquickanimatedimage \ - qquickborderimage \ - qquickcanvas \ - qquickdrag \ - qquickdroparea \ - qquickflickable \ - qquickflipable \ - qquickfocusscope \ - qquickgridview \ - qquickimage \ - qquickitem \ - qquickitem2 \ - qquickitemlayer \ - qquicklistview \ - qquickloader \ - qquickmousearea \ - qquickmultipointtoucharea \ - qquickpathview \ - qquickpincharea \ - qquickpositioners \ - qquickrepeater \ - qquickshadereffect \ - qquickspriteimage \ - qquicktext \ - qquicktextedit \ - qquicktextinput \ - qquickvisualdatamodel \ - qquickview \ - qquickcanvasitem \ - qquickscreen \ - - -SUBDIRS += $$PUBLICTESTS - -contains(QT_CONFIG, private_tests) { - SUBDIRS += $$PRIVATETESTS - SUBDIRS += $$QUICKTESTS -} diff --git a/tests/auto/qtquick2/rendernode/data/MessUpState.qml b/tests/auto/qtquick2/rendernode/data/MessUpState.qml deleted file mode 100644 index 58f6e80a2c..0000000000 --- a/tests/auto/qtquick2/rendernode/data/MessUpState.qml +++ /dev/null @@ -1,32 +0,0 @@ -import QtQuick 2.0 -import Test 1.0 - -Rectangle { - width: 200 - height: 200 - color: "black" - Rectangle { - width: 200 - height: 100 - anchors.centerIn: parent - clip: true - color: "white" - Rectangle { - width: 100 - height: 100 - anchors.centerIn: parent - rotation: 45 - color: "blue" - clip: true - MessUpItem { - anchors.fill: parent - } - Rectangle { - anchors.fill: parent - anchors.margins: -50 - color: "red" - opacity: 0.5 - } - } - } -} diff --git a/tests/auto/qtquick2/rendernode/data/RenderOrder.qml b/tests/auto/qtquick2/rendernode/data/RenderOrder.qml deleted file mode 100644 index 3342756e06..0000000000 --- a/tests/auto/qtquick2/rendernode/data/RenderOrder.qml +++ /dev/null @@ -1,53 +0,0 @@ -import QtQuick 2.0 -import Test 1.0 - -Rectangle { - id: root - - width: 200 - height: 200 - color: "black" - - Rectangle { - width: 100 - height: 100 - anchors.top: parent.top - anchors.left: parent.left - color: "red" - opacity: 0.5 - } - - Rectangle { - width: 100 - height: 100 - anchors.bottom: parent.bottom - anchors.left: parent.left - color: "red" - } - - ClearItem { - width: 100 - height: 100 - anchors.centerIn: parent - color: "white" - clip: true - } - - Rectangle { - width: 100 - height: 100 - anchors.top: parent.top - anchors.right: parent.right - color: "blue" - } - - Rectangle { - width: 100 - height: 100 - anchors.bottom: parent.bottom - anchors.right: parent.right - color: "blue" - opacity: 0.5 - } - -} diff --git a/tests/auto/qtquick2/rendernode/rendernode.pro b/tests/auto/qtquick2/rendernode/rendernode.pro deleted file mode 100644 index f915a58900..0000000000 --- a/tests/auto/qtquick2/rendernode/rendernode.pro +++ /dev/null @@ -1,18 +0,0 @@ -CONFIG += testcase -TARGET = tst_rendernode -SOURCES += tst_rendernode.cpp - -macx:CONFIG -= app_bundle - -testDataFiles.files = data -testDataFiles.path = . -DEPLOYMENT += testDataFiles - -include(../../shared/util.pri) - -CONFIG += parallel_test -QT += core-private gui-private v8-private declarative-private quick-private testlib - -OTHER_FILES += \ - data/RenderOrder.qml \ - data/MessUpState.qml \ diff --git a/tests/auto/qtquick2/rendernode/tst_rendernode.cpp b/tests/auto/qtquick2/rendernode/tst_rendernode.cpp deleted file mode 100644 index f0e385152e..0000000000 --- a/tests/auto/qtquick2/rendernode/tst_rendernode.cpp +++ /dev/null @@ -1,242 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include - -#include -#include -#include -#include - -#include "../../shared/util.h" - -class tst_rendernode: public QDeclarativeDataTest -{ - Q_OBJECT -public: - tst_rendernode(); - - QImage runTest(const QString &url) - { - QQuickView view; - view.setSource(QUrl(url)); - - view.show(); - QTest::qWaitForWindowShown(&view); - - return view.grabFrameBuffer(); - } - -private slots: - void renderOrder(); - void messUpState(); -}; - -class ClearNode : public QSGRenderNode -{ -public: - virtual StateFlags changedStates() - { - return ColorState; - } - - virtual void render(const RenderState &) - { - // If clip has been set, scissoring will make sure the right area is cleared. - glClearColor(color.redF(), color.greenF(), color.blueF(), 1.0f); - glClear(GL_COLOR_BUFFER_BIT); - } - - QColor color; -}; - -class ClearItem : public QQuickItem -{ - Q_OBJECT - Q_PROPERTY(QColor color READ color WRITE setColor NOTIFY colorChanged) -public: - ClearItem() : m_color(Qt::black) - { - setFlag(ItemHasContents, true); - } - - QColor color() const { return m_color; } - void setColor(const QColor &color) - { - if (color == m_color) - return; - m_color = color; - emit colorChanged(); - } - -protected: - virtual QSGNode *updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *) - { - ClearNode *node = static_cast(oldNode); - if (!node) - node = new ClearNode; - node->color = m_color; - return node; - } - -Q_SIGNALS: - void colorChanged(); - -private: - QColor m_color; -}; - -class MessUpNode : public QSGRenderNode -{ -public: - virtual StateFlags changedStates() - { - return StateFlags(DepthState) | StencilState | ScissorState | ColorState | BlendState - | CullState | ViewportState; - } - - virtual void render(const RenderState &) - { - // Don't draw anything, just mess up the state - glViewport(10, 10, 10, 10); - glDisable(GL_SCISSOR_TEST); - glDepthMask(true); - glEnable(GL_DEPTH_TEST); - glDepthFunc(GL_EQUAL); -#if defined(QT_OPENGL_ES) - glClearDepthf(1); -#else - glClearDepth(1); -#endif - glClearStencil(42); - glClearColor(1.0f, 0.5f, 1.0f, 0.0f); - glClear(GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); - glEnable(GL_SCISSOR_TEST); - glScissor(190, 190, 10, 10); - glStencilFunc(GL_EQUAL, 28, 0xff); - glBlendFunc(GL_ZERO, GL_ZERO); - GLint frontFace; - glGetIntegerv(GL_FRONT_FACE, &frontFace); - glFrontFace(frontFace == GL_CW ? GL_CCW : GL_CW); - glEnable(GL_CULL_FACE); - } -}; - -class MessUpItem : public QQuickItem -{ - Q_OBJECT -public: - MessUpItem() - { - setFlag(ItemHasContents, true); - } - -protected: - virtual QSGNode *updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *) - { - MessUpNode *node = static_cast(oldNode); - if (!node) - node = new MessUpNode; - return node; - } -}; - -tst_rendernode::tst_rendernode() -{ - qmlRegisterType("Test", 1, 0, "ClearItem"); - qmlRegisterType("Test", 1, 0, "MessUpItem"); -} - -static void fuzzyCompareColor(QRgb x, QRgb y) -{ - QVERIFY(qAbs(qRed(x) - qRed(y)) < 4); - QVERIFY(qAbs(qGreen(x) - qGreen(y)) < 4); - QVERIFY(qAbs(qBlue(x) - qBlue(y)) < 4); -} - -void tst_rendernode::renderOrder() -{ - QImage fb = runTest(testFile("RenderOrder.qml")); - int x1 = fb.width() / 8; - int x2 = fb.width() * 3 / 8; - int x3 = fb.width() * 5 / 8; - int x4 = fb.width() * 7 / 8; - int y1 = fb.height() / 8; - int y2 = fb.height() * 3 / 8; - int y3 = fb.height() * 5 / 8; - int y4 = fb.height() * 7 / 8; - - fuzzyCompareColor(fb.pixel(x1, y1), qRgb(0x7f, 0x00, 0x00)); - QCOMPARE(fb.pixel(x2, y2), qRgb(0xff, 0xff, 0xff)); - QCOMPARE(fb.pixel(x3, y2), qRgb(0x00, 0x00, 0xff)); - QCOMPARE(fb.pixel(x4, y1), qRgb(0x00, 0x00, 0xff)); - QCOMPARE(fb.pixel(x1, y4), qRgb(0xff, 0x00, 0x00)); - QCOMPARE(fb.pixel(x2, y3), qRgb(0xff, 0xff, 0xff)); - fuzzyCompareColor(fb.pixel(x3, y3), qRgb(0x7f, 0x7f, 0xff)); - fuzzyCompareColor(fb.pixel(x4, y4), qRgb(0x00, 0x00, 0x7f)); -} - -void tst_rendernode::messUpState() -{ - QImage fb = runTest(testFile("MessUpState.qml")); - int x1 = 0; - int x2 = fb.width() / 2; - int x3 = fb.width() - 1; - int y1 = 0; - int y2 = fb.height() * 3 / 16; - int y3 = fb.height() / 2; - int y4 = fb.height() * 13 / 16; - int y5 = fb.height() - 1; - - QCOMPARE(fb.pixel(x1, y3), qRgb(0xff, 0xff, 0xff)); - QCOMPARE(fb.pixel(x3, y3), qRgb(0xff, 0xff, 0xff)); - - QCOMPARE(fb.pixel(x2, y1), qRgb(0x00, 0x00, 0x00)); - QCOMPARE(fb.pixel(x2, y2), qRgb(0x00, 0x00, 0x00)); - fuzzyCompareColor(fb.pixel(x2, y3), qRgb(0x7f, 0x00, 0x7f)); - QCOMPARE(fb.pixel(x2, y4), qRgb(0x00, 0x00, 0x00)); - QCOMPARE(fb.pixel(x2, y5), qRgb(0x00, 0x00, 0x00)); -} - - -QTEST_MAIN(tst_rendernode) - -#include "tst_rendernode.moc" diff --git a/tests/auto/qtquick2/shared/util.pri b/tests/auto/qtquick2/shared/util.pri deleted file mode 100644 index eddbe4b6aa..0000000000 --- a/tests/auto/qtquick2/shared/util.pri +++ /dev/null @@ -1,7 +0,0 @@ - -HEADERS += $$PWD/visualtestutil.h \ - $$PWD/viewtestutil.h -SOURCES += $$PWD/visualtestutil.cpp \ - $$PWD/viewtestutil.cpp - -DEFINES += QT_DECLARATIVETEST_DATADIR=\\\"$${_PRO_FILE_PWD_}/data\\\" diff --git a/tests/auto/qtquick2/shared/viewtestutil.cpp b/tests/auto/qtquick2/shared/viewtestutil.cpp deleted file mode 100644 index eeef23001e..0000000000 --- a/tests/auto/qtquick2/shared/viewtestutil.cpp +++ /dev/null @@ -1,493 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "viewtestutil.h" - -#include - -#include - -template -static void qdeclarativemodelviewstestutil_move(int from, int to, int n, T *items) -{ - if (from > to) { - // Only move forwards - flip if backwards moving - int tfrom = from; - int tto = to; - from = tto; - to = tto+n; - n = tfrom-tto; - } - - T replaced; - int i=0; - typename T::ConstIterator it=items->begin(); it += from+n; - for (; ibegin(); it += from; - for (; ibegin(); t += from; - for (; f != replaced.end(); ++f, ++t) - *t = *f; -} - -QQuickView *QQuickViewTestUtil::createView() -{ - QQuickView *canvas = new QQuickView(0); - canvas->setGeometry(0,0,240,320); - - return canvas; -} - -void QQuickViewTestUtil::flick(QQuickView *canvas, const QPoint &from, const QPoint &to, int duration) -{ - const int pointCount = 5; - QPoint diff = to - from; - - // send press, five equally spaced moves, and release. - QTest::mousePress(canvas, Qt::LeftButton, 0, from); - - for (int i = 0; i < pointCount; ++i) { - QMouseEvent mv(QEvent::MouseMove, from + (i+1)*diff/pointCount, Qt::LeftButton, Qt::LeftButton,Qt::NoModifier); - QGuiApplication::sendEvent(canvas, &mv); - QTest::qWait(duration/pointCount); - QCoreApplication::processEvents(); - } - - QTest::mouseRelease(canvas, Qt::LeftButton, 0, to); - QTest::qWait(50); -} - -QList QQuickViewTestUtil::adjustIndexesForAddDisplaced(const QList &indexes, int index, int count) -{ - QList result; - for (int i=0; i= index) { - num += count; - } - result << num; - } - return result; -} - -QList QQuickViewTestUtil::adjustIndexesForMove(const QList &indexes, int from, int to, int count) -{ - QList result; - for (int i=0; i= from && num < from + count) - num += (to - from); // target - else if (num >= from && num < to + count) - num -= count; // displaced - } else if (from > to) { - if (num >= from && num < from + count) - num -= (from - to); // target - else if (num >= to && num < from + count) - num += count; // displaced - } - result << num; - } - return result; -} - -QList QQuickViewTestUtil::adjustIndexesForRemoveDisplaced(const QList &indexes, int index, int count) -{ - QList result; - for (int i=0; i= index) - num -= count; - result << num; - } - return result; -} - - -QQuickViewTestUtil::QmlListModel::QmlListModel(QObject *parent) - : QListModelInterface(parent) -{ -} - -QQuickViewTestUtil::QmlListModel::~QmlListModel() -{ -} - -QString QQuickViewTestUtil::QmlListModel::name(int index) const -{ - return list.at(index).first; -} - -QString QQuickViewTestUtil::QmlListModel::number(int index) const -{ - return list.at(index).second; -} - -int QQuickViewTestUtil::QmlListModel::count() const -{ - return list.count(); -} - -QList QQuickViewTestUtil::QmlListModel::roles() const -{ - return QList() << Name << Number; -} - -QString QQuickViewTestUtil::QmlListModel::toString(int role) const -{ - switch (role) { - case Name: - return "name"; - case Number: - return "number"; - default: - return ""; - } -} - -QVariant QQuickViewTestUtil::QmlListModel::data(int index, int role) const -{ - if (role==0) - return list.at(index).first; - if (role==1) - return list.at(index).second; - return QVariant(); -} - -QHash QQuickViewTestUtil::QmlListModel::data(int index, const QList &roles) const -{ - QHash returnHash; - - for (int i = 0; i < roles.size(); ++i) { - int role = roles.at(i); - QVariant info; - switch (role) { - case Name: - info = list.at(index).first; - break; - case Number: - info = list.at(index).second; - break; - default: - break; - } - returnHash.insert(role, info); - } - return returnHash; -} - -void QQuickViewTestUtil::QmlListModel::addItem(const QString &name, const QString &number) -{ - list.append(QPair(name, number)); - emit itemsInserted(list.count()-1, 1); -} - -void QQuickViewTestUtil::QmlListModel::insertItem(int index, const QString &name, const QString &number) -{ - list.insert(index, QPair(name, number)); - emit itemsInserted(index, 1); -} - -void QQuickViewTestUtil::QmlListModel::insertItems(int index, const QList > &items) -{ - for (int i=0; i(items[i].first, items[i].second)); - emit itemsInserted(index, items.count()); -} - -void QQuickViewTestUtil::QmlListModel::removeItem(int index) -{ - list.removeAt(index); - emit itemsRemoved(index, 1); -} - -void QQuickViewTestUtil::QmlListModel::removeItems(int index, int count) -{ - int c = count; - while (c--) - list.removeAt(index); - emit itemsRemoved(index, count); -} - -void QQuickViewTestUtil::QmlListModel::moveItem(int from, int to) -{ - list.move(from, to); - emit itemsMoved(from, to, 1); -} - -void QQuickViewTestUtil::QmlListModel::moveItems(int from, int to, int count) -{ - qdeclarativemodelviewstestutil_move(from, to, count, &list); - emit itemsMoved(from, to, count); -} - -void QQuickViewTestUtil::QmlListModel::modifyItem(int index, const QString &name, const QString &number) -{ - list[index] = QPair(name, number); - emit itemsChanged(index, 1, roles()); -} - -void QQuickViewTestUtil::QmlListModel::clear() { - int count = list.count(); - list.clear(); - emit itemsRemoved(0, count); -} - -void QQuickViewTestUtil::QmlListModel::matchAgainst(const QList > &other, const QString &error1, const QString &error2) { - for (int i=0; i roles; - roles[Name] = "name"; - roles[Number] = "number"; - setRoleNames(roles); -} - -int QQuickViewTestUtil::QaimModel::rowCount(const QModelIndex &parent) const -{ - Q_UNUSED(parent); - return list.count(); -} - -QVariant QQuickViewTestUtil::QaimModel::data(const QModelIndex &index, int role) const -{ - QVariant rv; - if (role == Name) - rv = list.at(index.row()).first; - else if (role == Number) - rv = list.at(index.row()).second; - - return rv; -} - -int QQuickViewTestUtil::QaimModel::count() const -{ - return rowCount(); -} - -QString QQuickViewTestUtil::QaimModel::name(int index) const -{ - return list.at(index).first; -} - -QString QQuickViewTestUtil::QaimModel::number(int index) const -{ - return list.at(index).second; -} - -void QQuickViewTestUtil::QaimModel::addItem(const QString &name, const QString &number) -{ - emit beginInsertRows(QModelIndex(), list.count(), list.count()); - list.append(QPair(name, number)); - emit endInsertRows(); -} - -void QQuickViewTestUtil::QaimModel::addItems(const QList > &items) -{ - emit beginInsertRows(QModelIndex(), list.count(), list.count()+items.count()-1); - for (int i=0; i(items[i].first, items[i].second)); - emit endInsertRows(); -} - -void QQuickViewTestUtil::QaimModel::insertItem(int index, const QString &name, const QString &number) -{ - emit beginInsertRows(QModelIndex(), index, index); - list.insert(index, QPair(name, number)); - emit endInsertRows(); -} - -void QQuickViewTestUtil::QaimModel::insertItems(int index, const QList > &items) -{ - emit beginInsertRows(QModelIndex(), index, index+items.count()-1); - for (int i=0; i(items[i].first, items[i].second)); - emit endInsertRows(); -} - -void QQuickViewTestUtil::QaimModel::removeItem(int index) -{ - emit beginRemoveRows(QModelIndex(), index, index); - list.removeAt(index); - emit endRemoveRows(); -} - -void QQuickViewTestUtil::QaimModel::removeItems(int index, int count) -{ - emit beginRemoveRows(QModelIndex(), index, index+count-1); - while (count--) - list.removeAt(index); - emit endRemoveRows(); -} - -void QQuickViewTestUtil::QaimModel::moveItem(int from, int to) -{ - emit beginMoveRows(QModelIndex(), from, from, QModelIndex(), to); - list.move(from, to); - emit endMoveRows(); -} - -void QQuickViewTestUtil::QaimModel::moveItems(int from, int to, int count) -{ - emit beginMoveRows(QModelIndex(), from, from+count-1, QModelIndex(), to > from ? to+count : to); - qdeclarativemodelviewstestutil_move(from, to, count, &list); - emit endMoveRows(); -} - -void QQuickViewTestUtil::QaimModel::modifyItem(int idx, const QString &name, const QString &number) -{ - list[idx] = QPair(name, number); - emit dataChanged(index(idx,0), index(idx,0)); -} - -void QQuickViewTestUtil::QaimModel::clear() -{ - int count = list.count(); - emit beginRemoveRows(QModelIndex(), 0, count-1); - list.clear(); - emit endRemoveRows(); -} - -void QQuickViewTestUtil::QaimModel::reset() -{ - emit beginResetModel(); - emit endResetModel(); -} - -void QQuickViewTestUtil::QaimModel::matchAgainst(const QList > &other, const QString &error1, const QString &error2) { - for (int i=0; i > QQuickViewTestUtil::ListRange::getModelDataValues(const QmlListModel &model) -{ - QList > data; - if (!valid) - return data; - for (int i=0; i > QQuickViewTestUtil::ListRange::getModelDataValues(const QaimModel &model) -{ - QList > data; - if (!valid) - return data; - for (int i=0; i -#include -#include -#include - -QT_FORWARD_DECLARE_CLASS(QQuickView) - -namespace QQuickViewTestUtil -{ - QQuickView *createView(); - - void flick(QQuickView *canvas, const QPoint &from, const QPoint &to, int duration); - - QList adjustIndexesForAddDisplaced(const QList &indexes, int index, int count); - QList adjustIndexesForMove(const QList &indexes, int from, int to, int count); - QList adjustIndexesForRemoveDisplaced(const QList &indexes, int index, int count); - - struct ListChange { - enum { Inserted, Removed, Moved, SetCurrent, SetContentY } type; - int index; - int count; - int to; // Move - qreal pos; // setContentY - - static ListChange insert(int index, int count = 1) { ListChange c = { Inserted, index, count, -1, 0.0 }; return c; } - static ListChange remove(int index, int count = 1) { ListChange c = { Removed, index, count, -1, 0.0 }; return c; } - static ListChange move(int index, int to, int count) { ListChange c = { Moved, index, count, to, 0.0 }; return c; } - static ListChange setCurrent(int index) { ListChange c = { SetCurrent, index, -1, -1, 0.0 }; return c; } - static ListChange setContentY(qreal pos) { ListChange c = { SetContentY, -1, -1, -1, pos }; return c; } - }; - - class QmlListModel : public QListModelInterface - { - Q_OBJECT - public: - QmlListModel(QObject *parent = 0); - ~QmlListModel(); - - enum Roles { Name, Number }; - - QString name(int index) const; - QString number(int index) const; - - int count() const; - - QList roles() const; - QString toString(int role) const; - - QVariant data(int index, int role) const; - QHash data(int index, const QList &roles) const; - - Q_INVOKABLE void addItem(const QString &name, const QString &number); - void insertItem(int index, const QString &name, const QString &number); - void insertItems(int index, const QList > &items); - - void removeItem(int index); - void removeItems(int index, int count); - - void moveItem(int from, int to); - void moveItems(int from, int to, int count); - - void modifyItem(int index, const QString &name, const QString &number); - - void clear(); - - void matchAgainst(const QList > &other, const QString &error1, const QString &error2); - - private: - QList > list; - }; - - class QaimModel : public QAbstractListModel - { - Q_OBJECT - public: - enum Roles { Name = Qt::UserRole+1, Number = Qt::UserRole+2 }; - - QaimModel(QObject *parent=0); - - int rowCount(const QModelIndex &parent=QModelIndex()) const; - QVariant data(const QModelIndex &index, int role=Qt::DisplayRole) const; - - int count() const; - QString name(int index) const; - QString number(int index) const; - - Q_INVOKABLE void addItem(const QString &name, const QString &number); - void addItems(const QList > &items); - void insertItem(int index, const QString &name, const QString &number); - void insertItems(int index, const QList > &items); - - void removeItem(int index); - void removeItems(int index, int count); - - void moveItem(int from, int to); - void moveItems(int from, int to, int count); - - void modifyItem(int idx, const QString &name, const QString &number); - - void clear(); - void reset(); - - void matchAgainst(const QList > &other, const QString &error1, const QString &error2); - - private: - QList > list; - }; - - class ListRange - { - public: - ListRange(); - ListRange(const ListRange &other); - ListRange(int start, int end); - - ~ListRange(); - - ListRange operator+(const ListRange &other) const; - bool operator==(const ListRange &other) const; - bool operator!=(const ListRange &other) const; - - bool isValid() const; - int count() const; - - QList > getModelDataValues(const QmlListModel &model); - QList > getModelDataValues(const QaimModel &model); - - QList indexes; - bool valid; - }; -} - -Q_DECLARE_METATYPE(QList) -Q_DECLARE_METATYPE(QQuickViewTestUtil::ListRange) - -#endif // QQUICKVIEWTESTUTIL_H diff --git a/tests/auto/qtquick2/shared/visualtestutil.cpp b/tests/auto/qtquick2/shared/visualtestutil.cpp deleted file mode 100644 index 8680df10e9..0000000000 --- a/tests/auto/qtquick2/shared/visualtestutil.cpp +++ /dev/null @@ -1,71 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "visualtestutil.h" - -#include -#include - -QQuickItem *QQuickVisualTestUtil::findVisibleChild(QQuickItem *parent, const QString &objectName) -{ - QQuickItem *item = 0; - QList items = parent->findChildren(objectName); - for (int i = 0; i < items.count(); ++i) { - if (items.at(i)->isVisible()) { - item = items.at(i); - break; - } - } - return item; -} - -void QQuickVisualTestUtil::dumpTree(QQuickItem *parent, int depth) -{ - static QString padding(" "); - for (int i = 0; i < parent->childItems().count(); ++i) { - QQuickItem *item = qobject_cast(parent->childItems().at(i)); - if (!item) - continue; - qDebug() << padding.left(depth*2) << item; - dumpTree(item, depth+1); - } -} - diff --git a/tests/auto/qtquick2/shared/visualtestutil.h b/tests/auto/qtquick2/shared/visualtestutil.h deleted file mode 100644 index 09bb03c002..0000000000 --- a/tests/auto/qtquick2/shared/visualtestutil.h +++ /dev/null @@ -1,112 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QQUICKVISUALTESTUTIL_H -#define QQUICKVISUALTESTUTIL_H - -#include -#include - -namespace QQuickVisualTestUtil -{ - QQuickItem *findVisibleChild(QQuickItem *parent, const QString &objectName); - - void dumpTree(QQuickItem *parent, int depth = 0); - - - /* - Find an item with the specified objectName. If index is supplied then the - item must also evaluate the {index} expression equal to index - */ - template - T *findItem(QQuickItem *parent, const QString &objectName, int index = -1) - { - const QMetaObject &mo = T::staticMetaObject; - for (int i = 0; i < parent->childItems().count(); ++i) { - QQuickItem *item = qobject_cast(parent->childItems().at(i)); - if (!item) - continue; - if (mo.cast(item) && (objectName.isEmpty() || item->objectName() == objectName)) { - if (index != -1) { - QDeclarativeExpression e(qmlContext(item), item, "index"); - if (e.evaluate().toInt() == index) - return static_cast(item); - } else { - return static_cast(item); - } - } - item = findItem(item, objectName, index); - if (item) - return static_cast(item); - } - - return 0; - } - - template - QList findItems(QQuickItem *parent, const QString &objectName, bool visibleOnly = true) - { - QList items; - const QMetaObject &mo = T::staticMetaObject; - for (int i = 0; i < parent->childItems().count(); ++i) { - QQuickItem *item = qobject_cast(parent->childItems().at(i)); - if (!item || (visibleOnly && !item->isVisible())) - continue; - if (mo.cast(item) && (objectName.isEmpty() || item->objectName() == objectName)) - items.append(static_cast(item)); - items += findItems(item, objectName); - } - - return items; - } - - template - QList findItems(QQuickItem *parent, const QString &objectName, const QList &indexes) - { - QList items; - for (int i=0; i(findItem(parent, objectName, indexes[i])); - return items; - } - -} - -#endif // QQUICKVISUALTESTUTIL_H diff --git a/tests/auto/quick/examples/data/dummytest.qml b/tests/auto/quick/examples/data/dummytest.qml new file mode 100644 index 0000000000..b20e907f27 --- /dev/null +++ b/tests/auto/quick/examples/data/dummytest.qml @@ -0,0 +1,6 @@ +import Qt.VisualTest 4.6 + +VisualTest { + Frame { msec: 0 } + Frame { msec: 10 } +} diff --git a/tests/auto/quick/examples/data/webbrowser/webbrowser.qml b/tests/auto/quick/examples/data/webbrowser/webbrowser.qml new file mode 100644 index 0000000000..d31787b939 --- /dev/null +++ b/tests/auto/quick/examples/data/webbrowser/webbrowser.qml @@ -0,0 +1,6 @@ +import Qt.VisualTest 4.6 + +VisualTest { + Frame { msec: 0 } + Frame { msec: 2000 } +} diff --git a/tests/auto/quick/examples/examples.pro b/tests/auto/quick/examples/examples.pro new file mode 100644 index 0000000000..e67120d7c2 --- /dev/null +++ b/tests/auto/quick/examples/examples.pro @@ -0,0 +1,10 @@ +CONFIG += testcase +TARGET = tst_examples +macx:CONFIG -= app_bundle + +SOURCES += tst_examples.cpp +DEFINES += SRCDIR=\\\"$$PWD\\\" + +CONFIG += parallel_test +#temporary +QT += core-private gui-private qml-private quick-private widgets-private v8-private testlib diff --git a/tests/auto/quick/examples/tst_examples.cpp b/tests/auto/quick/examples/tst_examples.cpp new file mode 100644 index 0000000000..24a60cb08a --- /dev/null +++ b/tests/auto/quick/examples/tst_examples.cpp @@ -0,0 +1,307 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +static QtMsgHandler testlibMsgHandler = 0; +void msgHandlerFilter(QtMsgType type, const char *msg) +{ + if (type == QtCriticalMsg || type == QtFatalMsg) + (*testlibMsgHandler)(type, msg); +} + +class tst_examples : public QObject +{ + Q_OBJECT +public: + tst_examples(); + +private slots: + void init(); + void cleanup(); + + void sgexamples_data(); + void sgexamples(); + void sgsnippets_data(); + void sgsnippets(); + + void namingConvention(); +private: + QStringList excludedDirs; + QStringList excludedFiles; + + void namingConvention(const QDir &); + QStringList findQmlFiles(const QDir &); + + QQmlEngine engine; +}; + +tst_examples::tst_examples() +{ + // Add files to exclude here + excludedFiles << "doc/src/snippets/qml/listmodel.qml"; //Just a ListModel, no root QQuickItem + + // Add directories you want excluded here + excludedDirs << "examples/qml/text/fonts"; // QTBUG-21415 + excludedDirs << "doc/src/snippets/qml/path"; //No root QQuickItem + + // Not run in QQuickView + excludedDirs << "examples/qml/qtquick1"; + + // These snippets are not expected to run on their own. + excludedDirs << "doc/src/snippets/qml/visualdatamodel_rootindex"; + excludedDirs << "doc/src/snippets/qml/qtbinding"; + excludedDirs << "doc/src/snippets/qml/imports"; + excludedDirs << "doc/src/snippets/qtquick1/visualdatamodel_rootindex"; + excludedDirs << "doc/src/snippets/qtquick1/qtbinding"; + excludedDirs << "doc/src/snippets/qtquick1/imports"; + +#ifdef QT_NO_WEBKIT + excludedDirs << "examples/qml/modelviews/webview"; + excludedDirs << "examples/qml/webbrowser"; + excludedDirs << "doc/src/snippets/qml/webview"; + excludedDirs << "doc/src/snippets/qtquick1/webview"; +#endif + +#ifdef QT_NO_XMLPATTERNS + excludedDirs << "examples/qml/xml/xmldata"; + excludedDirs << "examples/qml/twitter"; + excludedDirs << "examples/qml/flickr"; + excludedDirs << "examples/qml/photoviewer"; +#endif +} + +void tst_examples::init() +{ + if (!qstrcmp(QTest::currentTestFunction(), "sgsnippets")) + testlibMsgHandler = qInstallMsgHandler(msgHandlerFilter); +} + +void tst_examples::cleanup() +{ + if (!qstrcmp(QTest::currentTestFunction(), "sgsnippets")) + qInstallMsgHandler(testlibMsgHandler); +} + +/* +This tests that the examples follow the naming convention required +to have them tested by the examples() test. +*/ +void tst_examples::namingConvention(const QDir &d) +{ + for (int ii = 0; ii < excludedDirs.count(); ++ii) { + QString s = excludedDirs.at(ii); + if (d.absolutePath().endsWith(s)) + return; + } + + QStringList files = d.entryList(QStringList() << QLatin1String("*.qml"), + QDir::Files); + + bool seenQml = !files.isEmpty(); + bool seenLowercase = false; + + foreach (const QString &file, files) { + if (file.at(0).isLower()) + seenLowercase = true; + } + + if (!seenQml) { + QStringList dirs = d.entryList(QDir::Dirs | QDir::NoDotAndDotDot | + QDir::NoSymLinks); + foreach (const QString &dir, dirs) { + QDir sub = d; + sub.cd(dir); + namingConvention(sub); + } + } else if(!seenLowercase) { + QFAIL(qPrintable(QString( + "Directory %1 violates naming convention; expected at least one qml file " + "starting with lower case, got: %2" + ).arg(d.absolutePath()).arg(files.join(",")))); + } +} + +void tst_examples::namingConvention() +{ + QString examples = QLibraryInfo::location(QLibraryInfo::ExamplesPath); + + namingConvention(QDir(examples)); +} + +QStringList tst_examples::findQmlFiles(const QDir &d) +{ + for (int ii = 0; ii < excludedDirs.count(); ++ii) { + QString s = excludedDirs.at(ii); + if (d.absolutePath().endsWith(s)) + return QStringList(); + } + + QStringList rv; + + QStringList cppfiles = d.entryList(QStringList() << QLatin1String("*.cpp"), QDir::Files); + if (cppfiles.isEmpty()) { + QStringList files = d.entryList(QStringList() << QLatin1String("*.qml"), + QDir::Files); + foreach (const QString &file, files) { + if (file.at(0).isLower()) { + bool superContinue = false; + for (int ii = 0; ii < excludedFiles.count(); ++ii) { + QString e = excludedFiles.at(ii); + if (d.absoluteFilePath(file).endsWith(e)) { + superContinue = true; + break; + } + } + if (superContinue) + continue; + rv << d.absoluteFilePath(file); + } + } + } + + + QStringList dirs = d.entryList(QDir::Dirs | QDir::NoDotAndDotDot | + QDir::NoSymLinks); + foreach (const QString &dir, dirs) { + QDir sub = d; + sub.cd(dir); + rv << findQmlFiles(sub); + } + + return rv; +} + +/* +This test runs all the examples in the QtQml UI source tree and ensures +that they start and exit cleanly. + +Examples are any .qml files under the examples/ directory that start +with a lower case letter. +*/ +void tst_examples::sgexamples_data() +{ + QTest::addColumn("file"); + + QString examples = QLatin1String(SRCDIR) + "/../../../../examples/qml/"; + QString tutorials = QLatin1String(SRCDIR) + "/../../../../examples/tutorials/"; //Only qml tutorials since modularization + + QStringList files; + files << findQmlFiles(QDir(examples)); + files << findQmlFiles(QDir(tutorials)); + + foreach (const QString &file, files) + QTest::newRow(qPrintable(file)) << file; +} + +void tst_examples::sgexamples() +{ + QFETCH(QString, file); + + QQmlComponent component(&engine, QUrl::fromLocalFile(file)); + if (component.status() == QQmlComponent::Error) + qWarning() << component.errors(); + QCOMPARE(component.status(), QQmlComponent::Ready); + + QScopedPointer object(component.beginCreate(engine.rootContext())); + QQuickItem *root = qobject_cast(object.data()); + if (!root) + component.completeCreate(); + QVERIFY(root); + + QQuickCanvas canvas; + root->setParentItem(canvas.rootItem()); + component.completeCreate(); + canvas.show(); + + QTest::qWaitForWindowShown(&canvas); + +} + +void tst_examples::sgsnippets_data() +{ + QTest::addColumn("file"); + + QString snippets = QLatin1String(SRCDIR) + "/../../../../doc/src/snippets/qml"; + + QStringList files; + files << findQmlFiles(QDir(snippets)); + + foreach (const QString &file, files) + QTest::newRow(qPrintable(file)) << file; +} + +void tst_examples::sgsnippets() +{ + QFETCH(QString, file); + + QQmlComponent component(&engine, QUrl::fromLocalFile(file)); + if (component.status() == QQmlComponent::Error) + qWarning() << component.errors(); + QCOMPARE(component.status(), QQmlComponent::Ready); + + QScopedPointer object(component.beginCreate(engine.rootContext())); + QQuickItem *root = qobject_cast(object.data()); + if (!root) + component.completeCreate(); + QVERIFY(root); + + QQuickCanvas canvas; + root->setParentItem(canvas.rootItem()); + component.completeCreate(); + canvas.show(); + + QTest::qWaitForWindowShown(&canvas); + +} + +QTEST_MAIN(tst_examples) + +#include "tst_examples.moc" diff --git a/tests/auto/quick/geometry/geometry.pro b/tests/auto/quick/geometry/geometry.pro new file mode 100644 index 0000000000..41fcab7c8f --- /dev/null +++ b/tests/auto/quick/geometry/geometry.pro @@ -0,0 +1,9 @@ +CONFIG += testcase +TARGET = tst_geometry +macx:CONFIG -= app_bundle + +SOURCES += tst_geometry.cpp + +CONFIG+=parallel_test + +QT += core-private gui-private qml-private quick-private opengl testlib diff --git a/tests/auto/quick/geometry/tst_geometry.cpp b/tests/auto/quick/geometry/tst_geometry.cpp new file mode 100644 index 0000000000..8d8f45b8cb --- /dev/null +++ b/tests/auto/quick/geometry/tst_geometry.cpp @@ -0,0 +1,181 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the Qt scene graph research project. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include + +#include + +class GeometryTest : public QObject +{ + Q_OBJECT + +public: + +private Q_SLOTS: + void testPoint2D(); + void testTexturedPoint2D(); + void testCustomGeometry(); + +private: +}; + +void GeometryTest::testPoint2D() +{ + QSGGeometry geometry(QSGGeometry::defaultAttributes_Point2D(), 4, 0); + + QCOMPARE(geometry.attributeCount(), 1); + QCOMPARE(geometry.sizeOfVertex(), (int) sizeof(float) * 2); + QCOMPARE(geometry.vertexCount(), 4); + QCOMPARE(geometry.indexCount(), 0); + QVERIFY(geometry.indexData() == 0); + + QSGGeometry::updateRectGeometry(&geometry, QRectF(1, 2, 3, 4)); + + QSGGeometry::Point2D *pts = geometry.vertexDataAsPoint2D(); + QVERIFY(pts != 0); + + QCOMPARE(pts[0].x, (float) 1); + QCOMPARE(pts[0].y, (float) 2); + QCOMPARE(pts[3].x, (float) 4); + QCOMPARE(pts[3].y, (float) 6); + + // Verify that resize gives me enough allocated data without crashing... + geometry.allocate(100, 100); + pts = geometry.vertexDataAsPoint2D(); + quint16 *is = geometry.indexDataAsUShort(); + for (int i=0; i<100; ++i) { + pts[i].x = i; + pts[i].y = i + 100; + is[i] = i; + } + QVERIFY(true); +} + + +void GeometryTest::testTexturedPoint2D() +{ + QSGGeometry geometry(QSGGeometry::defaultAttributes_TexturedPoint2D(), 4, 0); + + QCOMPARE(geometry.attributeCount(), 2); + QCOMPARE(geometry.sizeOfVertex(), (int) sizeof(float) * 4); + QCOMPARE(geometry.vertexCount(), 4); + QCOMPARE(geometry.indexCount(), 0); + QVERIFY(geometry.indexData() == 0); + + QSGGeometry::updateTexturedRectGeometry(&geometry, QRectF(1, 2, 3, 4), QRectF(5, 6, 7, 8)); + + QSGGeometry::TexturedPoint2D *pts = geometry.vertexDataAsTexturedPoint2D(); + QVERIFY(pts != 0); + + QCOMPARE(pts[0].x, (float) 1); + QCOMPARE(pts[0].y, (float) 2); + QCOMPARE(pts[0].tx, (float) 5); + QCOMPARE(pts[0].ty, (float) 6); + + QCOMPARE(pts[3].x, (float) 4); + QCOMPARE(pts[3].y, (float) 6); + QCOMPARE(pts[3].tx, (float) 12); + QCOMPARE(pts[3].ty, (float) 14); + + // Verify that resize gives me enough allocated data without crashing... + geometry.allocate(100, 100); + pts = geometry.vertexDataAsTexturedPoint2D(); + quint16 *is = geometry.indexDataAsUShort(); + for (int i=0; i<100; ++i) { + pts[i].x = i; + pts[i].y = i + 100; + pts[i].tx = i + 200; + pts[i].ty = i + 300; + is[i] = i; + } + QVERIFY(true); +} + +void GeometryTest::testCustomGeometry() +{ + struct V { + float x, y; + unsigned char r, g, b, a; + float v1, v2, v3, v4; + }; + + static QSGGeometry::Attribute attributes[] = { + { 0, 2, GL_FLOAT }, + { 1, 4, GL_UNSIGNED_BYTE }, + { 2, 4, GL_FLOAT }, + }; + static QSGGeometry::AttributeSet set = { 4, 6 * sizeof(float) + 4 * sizeof(unsigned char), attributes }; + + QSGGeometry geometry(set, 1000, 4000); + + // Verify that space has been allocated. + quint16 *ii = geometry.indexDataAsUShort(); + for (int i=0; i +#include + +#include +#include +#include + +#include +#include +class NodesTest : public QObject +{ + Q_OBJECT + +public: + NodesTest(); + +private Q_SLOTS: + void initTestCase(); + void cleanupTestCase() { + delete widget; + } + + // Root nodes + void propegate(); + void propegateWithMultipleRoots(); + void simulatedEffect_data(); + void simulatedEffect(); + + // Opacity nodes + void basicOpacityNode(); + void opacityPropegation(); + + // QSGNodeUpdater + void isBlockedCheck(); + +private: + QGLWidget *widget; + + QSGNodeUpdater updater; +}; + +void NodesTest::initTestCase() +{ + widget = new QGLWidget(); + widget->resize(100, 30); + widget->show(); +} + +class DummyRenderer : public QSGRenderer +{ +public: + DummyRenderer(QSGRootNode *root) + : QSGRenderer(QSGContext::createDefaultContext()) + , changedNode(0) + , changedState(0) + , renderCount(0) + { + setRootNode(root); + } + + void render() { + ++renderCount; + renderingOrder = ++globalRendereringOrder; + } + + void nodeChanged(QSGNode *node, QSGNode::DirtyState state) { + changedNode = node; + changedState = state; + QSGRenderer::nodeChanged(node, state); + } + + QSGNode *changedNode; + QSGNode::DirtyState changedState; + + int renderCount; + int renderingOrder; + static int globalRendereringOrder; +}; + +int DummyRenderer::globalRendereringOrder; + +NodesTest::NodesTest() +{ +} + + +void NodesTest::propegate() +{ + QSGRootNode root; + QSGNode child; child.setFlag(QSGNode::OwnedByParent, false); + root.appendChildNode(&child); + + DummyRenderer renderer(&root); + + child.markDirty(QSGNode::DirtyGeometry); + + QCOMPARE(&child, renderer.changedNode); + QCOMPARE((int) renderer.changedState, (int) QSGNode::DirtyGeometry); +} + + +void NodesTest::propegateWithMultipleRoots() +{ + QSGRootNode root1; + QSGNode child2; child2.setFlag(QSGNode::OwnedByParent, false); + QSGRootNode root3; root3.setFlag(QSGNode::OwnedByParent, false); + QSGNode child4; child4.setFlag(QSGNode::OwnedByParent, false); + + root1.appendChildNode(&child2); + child2.appendChildNode(&root3); + root3.appendChildNode(&child4); + + DummyRenderer ren1(&root1); + DummyRenderer ren2(&root3); + + child4.markDirty(QSGNode::DirtyGeometry); + + QCOMPARE(ren1.changedNode, &child4); + QCOMPARE(ren2.changedNode, &child4); + + QCOMPARE((int) ren1.changedState, (int) QSGNode::DirtyGeometry); + QCOMPARE((int) ren2.changedState, (int) QSGNode::DirtyGeometry); +} + + + +class SimulatedEffectRenderer : public DummyRenderer +{ +public: + SimulatedEffectRenderer(QSGRootNode *root, QSGBasicGeometryNode *c) + : DummyRenderer(root) + { + child = c; + } + + void render() { + matrix = child->matrix() ? *child->matrix() : QMatrix4x4(); + DummyRenderer::render(); + } + + QSGBasicGeometryNode *child; + QMatrix4x4 matrix; +}; + + +class PseudoEffectNode : public QSGNode { +public: + PseudoEffectNode(QSGRenderer *r) + : renderer(r) + { + setFlag(UsePreprocess); + } + + void preprocess() { + + if (renderer->rootNode()->parent()) { + // Mark the root dirty to build a clean state from the root and down + renderer->rootNode()->markDirty(QSGNode::DirtyForceUpdate); + } + + renderer->renderScene(); + + if (renderer->rootNode()->parent()) { + // Mark the parent of the root dirty to force the root and down to be updated. + renderer->rootNode()->parent()->markDirty(QSGNode::DirtyForceUpdate); + } + } + + QSGRenderer *renderer; +}; + +void NodesTest::simulatedEffect_data() +{ + QTest::addColumn("connected"); + + QTest::newRow("connected") << true; + QTest::newRow("disconnected") << false; +} + +void NodesTest::simulatedEffect() +{ + QFETCH(bool, connected); + + QSGRootNode root; + QSGRootNode source; + QSGTransformNode xform; + QSGSimpleRectNode geometry; + geometry.setRect(QRectF(0, 0, 1, 1)); + geometry.setColor(Qt::red); + + root.setFlag(QSGNode::OwnedByParent, false); + source.setFlag(QSGNode::OwnedByParent, false); + xform.setFlag(QSGNode::OwnedByParent, false); + geometry.setFlag(QSGNode::OwnedByParent, false); + + SimulatedEffectRenderer rootRenderer(&root, &geometry); + SimulatedEffectRenderer sourceRenderer(&source, &geometry); + + PseudoEffectNode effect(&sourceRenderer); + + /* + root Source is redirected into effect using the SimulatedEffectRenderer + / \ + xform effect + | + source + | + geometry + */ + + root.appendChildNode(&xform); + root.appendChildNode(&effect); + if (connected) + xform.appendChildNode(&source); + source.appendChildNode(&geometry); + QMatrix4x4 m; m.translate(1, 2, 3); + xform.setMatrix(m); + + // Clear all dirty states... + updater.updateStates(&root); + + rootRenderer.renderScene(); + + // compare that we got one render call to each + QCOMPARE(rootRenderer.renderCount, 1); + QCOMPARE(sourceRenderer.renderCount, 1); + QVERIFY(sourceRenderer.renderingOrder < rootRenderer.renderingOrder); + if (connected) // geometry is not rendered in this case, so skip it... + QCOMPARE(rootRenderer.matrix, xform.matrix()); + QCOMPARE(sourceRenderer.matrix, QMatrix4x4()); +} + +void NodesTest::basicOpacityNode() +{ + QSGOpacityNode n; + QCOMPARE(n.opacity(), 1.); + + n.setOpacity(0.5); + QCOMPARE(n.opacity(), 0.5); + + n.setOpacity(-1); + QCOMPARE(n.opacity(), 0.); + + n.setOpacity(2); + QCOMPARE(n.opacity(), 1.); +} + +void NodesTest::opacityPropegation() +{ + QSGRootNode root; + QSGOpacityNode *a = new QSGOpacityNode; + QSGOpacityNode *b = new QSGOpacityNode; + QSGOpacityNode *c = new QSGOpacityNode; + + QSGSimpleRectNode *geometry = new QSGSimpleRectNode; + geometry->setRect(0, 0, 100, 100); + + root.appendChildNode(a); + a->appendChildNode(b); + b->appendChildNode(c); + c->appendChildNode(geometry); + + a->setOpacity(0.9); + b->setOpacity(0.8); + c->setOpacity(0.7); + + updater.updateStates(&root); + + QCOMPARE(a->combinedOpacity(), 0.9); + QCOMPARE(b->combinedOpacity(), 0.9 * 0.8); + QCOMPARE(c->combinedOpacity(), 0.9 * 0.8 * 0.7); + QCOMPARE(geometry->inheritedOpacity(), 0.9 * 0.8 * 0.7); + + b->setOpacity(0.1); + updater.updateStates(&root); + + QCOMPARE(a->combinedOpacity(), 0.9); + QCOMPARE(b->combinedOpacity(), 0.9 * 0.1); + QCOMPARE(c->combinedOpacity(), 0.9 * 0.1 * 0.7); + QCOMPARE(geometry->inheritedOpacity(), 0.9 * 0.1 * 0.7); + + b->setOpacity(0); + updater.updateStates(&root); + + QVERIFY(b->isSubtreeBlocked()); + + // Verify that geometry did not get updated as it is in a blocked + // subtree + QCOMPARE(c->combinedOpacity(), 0.9 * 0.1 * 0.7); + QCOMPARE(geometry->inheritedOpacity(), 0.9 * 0.1 * 0.7); +} + +void NodesTest::isBlockedCheck() +{ + QSGRootNode root; + QSGOpacityNode *opacity = new QSGOpacityNode(); + QSGNode *node = new QSGNode(); + + root.appendChildNode(opacity); + opacity->appendChildNode(node); + + QSGNodeUpdater updater; + + opacity->setOpacity(0); + QVERIFY(updater.isNodeBlocked(node, &root)); + + opacity->setOpacity(1); + QVERIFY(!updater.isNodeBlocked(node, &root)); +} + +QTEST_MAIN(NodesTest); + +#include "tst_nodestest.moc" diff --git a/tests/auto/quick/qquickaccessible/data/checkbuttons.qml b/tests/auto/quick/qquickaccessible/data/checkbuttons.qml new file mode 100644 index 0000000000..22cdad1377 --- /dev/null +++ b/tests/auto/quick/qquickaccessible/data/checkbuttons.qml @@ -0,0 +1,47 @@ +import QtQuick 2.0 + +Item { + width: 400 + height: 400 + + // button, not checkable + Rectangle { + y: 20 + width: 100; height: 20 + Accessible.role : Accessible.Button + } + + // button, checkable, not checked + Rectangle { + y: 40 + width: 100; height: 20 + Accessible.role : Accessible.Button + property bool checkable: true + property bool checked: false + } + + // button, checkable, checked + Rectangle { + y: 60 + width: 100; height: 20 + Accessible.role : Accessible.Button + property bool checkable: true + property bool checked: true + } + + // check box, checked + Rectangle { + y: 80 + width: 100; height: 20 + Accessible.role : Accessible.CheckBox + property bool checked: true + } + // check box, not checked + Rectangle { + y: 100 + width: 100; height: 20 + Accessible.role : Accessible.CheckBox + property bool checked: false + } +} + diff --git a/tests/auto/quick/qquickaccessible/data/hittest.qml b/tests/auto/quick/qquickaccessible/data/hittest.qml new file mode 100644 index 0000000000..e8003e648a --- /dev/null +++ b/tests/auto/quick/qquickaccessible/data/hittest.qml @@ -0,0 +1,176 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtQml module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + + +import QtQuick 2.0 +import "widgets" + +Rectangle { + id: page + width: 640 + height: 480 + color: "white" + Rectangle { + id: header + color: "#c0c0c0" + height: usage.height + chkClip.height + anchors.left: parent.left + anchors.right: parent.right + Text { + id: usage + text: "Use an a11y inspect tool to see if all visible rectangles can be found with hit testing." + } + Rectangle { + id: chkClip + property bool checked: true + + color: (checked ? "#f0f0f0" : "#c0c0c0") + height: label.height + width: label.width + anchors.left: parent.left + anchors.bottom: parent.bottom + + MouseArea { + anchors.fill: parent + onClicked: chkClip.checked = !chkClip.checked + } + Text { + id: label + text: "Click here to toggle clipping" + } + } + } + TextRect { + clip: chkClip.checked + z: 2 + id: rect1 + text: "rect1" + width: 100 + height: 100 + color: "#ffc0c0" + anchors.top: header.bottom + TextRect { + id: rect10 + text: "rect10" + width: 100 + height: 100 + x: 50 + y: 50 + color: "#ffa0a0" + TextRect { + id: rect100 + text: "rect100" + width: 100 + height: 100 + x: 80 + y: 80 + color: "#ff8080" + } + TextRect { + id: rect101 + text: "rect101" + x: 100 + y: 70 + z: 3 + width: 100 + height: 100 + color: "#e06060" + } + TextRect { + id: rect102 + text: "rect102" + width: 100 + height: 100 + x: 150 + y: 60 + color: "#c04040" + } + } + } + + TextRect { + x: 0 + y: 50 + id: rect2 + text: "rect2" + width: 100 + height: 100 + color: "#c0c0ff" + TextRect { + id: rect20 + text: "rect20" + width: 100 + height: 100 + x: 50 + y: 50 + color: "#a0a0ff" + TextRect { + id: rect200 + text: "rect200" + width: 100 + height: 100 + x: 80 + y: 80 + color: "#8080ff" + } + TextRect { + id: rect201 + text: "rect201" + x: 100 + y: 70 + z: 100 + width: 100 + height: 100 + color: "#6060e0" + } + TextRect { + id: rect202 + text: "rect202" + width: 100 + height: 100 + x: 150 + y: 60 + color: "#4040c0" + } + } + } + +} diff --git a/tests/auto/quick/qquickaccessible/data/pushbutton.qml b/tests/auto/quick/qquickaccessible/data/pushbutton.qml new file mode 100644 index 0000000000..df19231703 --- /dev/null +++ b/tests/auto/quick/qquickaccessible/data/pushbutton.qml @@ -0,0 +1,15 @@ +import QtQuick 2.0 + +Rectangle { + Accessible.role : Accessible.Button + property string text : "test" + + Text { + anchors.fill : parent + text : parent.text + } + + MouseArea { + anchors.fill : parent + } +} diff --git a/tests/auto/quick/qquickaccessible/data/statictext.qml b/tests/auto/quick/qquickaccessible/data/statictext.qml new file mode 100644 index 0000000000..a0821cfc4d --- /dev/null +++ b/tests/auto/quick/qquickaccessible/data/statictext.qml @@ -0,0 +1,25 @@ +import QtQuick 2.0 + +Item { + width: 400 + height: 400 + + Text { + x: 100 + y: 20 + width: 200 + height: 50 + text : "Hello Accessibility" + } + + Text { + x: 100 + y: 40 + width: 100 + height: 40 + text : "Hello 2" + Accessible.role: Accessible.StaticText + Accessible.name: "The Hello 2 accessible text" + Accessible.description: "A text description" + } +} diff --git a/tests/auto/quick/qquickaccessible/data/widgets/TextRect.qml b/tests/auto/quick/qquickaccessible/data/widgets/TextRect.qml new file mode 100644 index 0000000000..937686974b --- /dev/null +++ b/tests/auto/quick/qquickaccessible/data/widgets/TextRect.qml @@ -0,0 +1,26 @@ +import QtQuick 2.0 + +Rectangle { + id: button + + property alias text : buttonText.text + Accessible.name: text + Accessible.description: "This button does " + text + Accessible.role: Accessible.Client + + signal clicked + + width: 40 + height: 40 + border.width: 2 + border.color: "black"; + + Text { + id: buttonText + text: "TextRect" + anchors.centerIn: parent + font.pixelSize: parent.height * .1 + style: Text.Sunken; color: "white"; styleColor: "black"; smooth: true + } + +} diff --git a/tests/auto/quick/qquickaccessible/qquickaccessible.pro b/tests/auto/quick/qquickaccessible/qquickaccessible.pro new file mode 100644 index 0000000000..ca50f5d8af --- /dev/null +++ b/tests/auto/quick/qquickaccessible/qquickaccessible.pro @@ -0,0 +1,25 @@ +CONFIG += testcase + +TARGET = tst_qquickaccessible +QT += qml-private network quick-private testlib +macx:CONFIG -= app_bundle + +SOURCES += tst_qquickaccessible.cpp + +include (../../shared/util.pri) + +OTHER_FILES += data/checkbuttons.qml +OTHER_FILES += data/hittest.qml +OTHER_FILES += data/pushbutton.qml +OTHER_FILES += data/statictext.qml + +DEFINES += SRCDIR=\\\"$$PWD\\\" + +CONFIG += parallel_test + +wince*: { + accessneeded.files = $$QT_BUILD_TREE\\plugins\\accessible\\*.dll + accessneeded.path = accessible + DEPLOYMENT += accessneeded +} + diff --git a/tests/auto/quick/qquickaccessible/tst_qquickaccessible.cpp b/tests/auto/quick/qquickaccessible/tst_qquickaccessible.cpp new file mode 100644 index 0000000000..d65666162d --- /dev/null +++ b/tests/auto/quick/qquickaccessible/tst_qquickaccessible.cpp @@ -0,0 +1,410 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtQml module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + + +#include +#include "QtTest/qtestaccessible.h" + +#include + +#include +#include + +#include +#include +#include + +#include "../../shared/util.h" + + +typedef QSharedPointer QAI; + +#define EXPECT(cond) \ + do { \ + if (!errorAt && !(cond)) { \ + errorAt = __LINE__; \ + qWarning("level: %d, middle: %d, role: %d (%s)", treelevel, middle, iface->role(), #cond); \ + } \ + } while (0) + +static int verifyHierarchy(QAccessibleInterface *iface) +{ + int errorAt = 0; + static int treelevel = 0; // for error diagnostics + QAccessibleInterface *middleChild, *if2; + middleChild = 0; + ++treelevel; + int middle = iface->childCount()/2 + 1; + if (iface->childCount() >= 2) { + middleChild = iface->child(middle - 1); + } + for (int i = 0; i < iface->childCount() && !errorAt; ++i) { + if2 = iface->child(i); + EXPECT(if2 != 0); + // navigate Ancestor... + QAccessibleInterface *parent = if2->parent(); + EXPECT(iface->object() == parent->object()); + delete parent; + + // verify children... + if (!errorAt) + errorAt = verifyHierarchy(if2); + delete if2; + } + delete middleChild; + + --treelevel; + return errorAt; +} + + +//TESTED_FILES= + +class tst_QQuickAccessible : public QQmlDataTest +{ + Q_OBJECT +public: + tst_QQuickAccessible(); + virtual ~tst_QQuickAccessible(); + +private slots: + void commonTests_data(); + void commonTests(); + + void quickAttachedProperties(); + void basicPropertiesTest(); + void hitTest(); + void checkableTest(); +}; + +tst_QQuickAccessible::tst_QQuickAccessible() +{ + +} + +tst_QQuickAccessible::~tst_QQuickAccessible() +{ + +} + +void tst_QQuickAccessible::commonTests_data() +{ + QTest::addColumn("accessibleRoleFileName"); + + QTest::newRow("StaticText") << SRCDIR "/data/statictext.qml"; + QTest::newRow("PushButton") << SRCDIR "/data/pushbutton.qml"; +} + +void tst_QQuickAccessible::commonTests() +{ + QFETCH(QString, accessibleRoleFileName); + + qDebug() << "testing" << accessibleRoleFileName; + + QQuickView *view = new QQuickView(); +// view->setFixedSize(240,320); + view->setSource(QUrl::fromLocalFile(accessibleRoleFileName)); + view->show(); +// view->setFocus(); + QVERIFY(view->rootObject() != 0); + + QAccessibleInterface *iface = QAccessible::queryAccessibleInterface(view); + QVERIFY(iface); + + delete iface; + delete view; +} + + + +QString eventName(const int ev) +{ + switch (ev) { + case 0x0001: return "SoundPlayed"; + case 0x0002: return "Alert"; + case 0x0003: return "ForegroundChanged"; + case 0x0004: return "MenuStart"; + case 0x0005: return "MenuEnd"; + case 0x0006: return "PopupMenuStart"; + case 0x0007: return "PopupMenuEnd"; + case 0x000C: return "ContextHelpStart"; + case 0x000D: return "ContextHelpEnd"; + case 0x000E: return "DragDropStart"; + case 0x000F: return "DragDropEnd"; + case 0x0010: return "DialogStart"; + case 0x0011: return "DialogEnd"; + case 0x0012: return "ScrollingStart"; + case 0x0013: return "ScrollingEnd"; + case 0x0018: return "MenuCommand"; + case 0x8000: return "ObjectCreated"; + case 0x8001: return "ObjectDestroyed"; + case 0x8002: return "ObjectShow"; + case 0x8003: return "ObjectHide"; + case 0x8004: return "ObjectReorder"; + case 0x8005: return "Focus"; + case 0x8006: return "Selection"; + case 0x8007: return "SelectionAdd"; + case 0x8008: return "SelectionRemove"; + case 0x8009: return "SelectionWithin"; + case 0x800A: return "StateChanged"; + case 0x800B: return "LocationChanged"; + case 0x800C: return "NameChanged"; + case 0x800D: return "DescriptionChanged"; + case 0x800E: return "ValueChanged"; + case 0x800F: return "ParentChanged"; + case 0x80A0: return "HelpChanged"; + case 0x80B0: return "DefaultActionChanged"; + case 0x80C0: return "AcceleratorChanged"; + default: return "Unknown Event"; + } +} + +void tst_QQuickAccessible::quickAttachedProperties() +{ + { + QQmlEngine engine; + QQmlComponent component(&engine); + component.setData("import QtQuick 2.0\nItem {\n" + "}", QUrl()); + QObject *object = component.create(); + QVERIFY(object != 0); + + QObject *attachedObject = QQuickAccessibleAttached::attachedProperties(object); + QCOMPARE(attachedObject, static_cast(0)); + delete object; + } + + // Attached property + { + QObject parent; + QQuickAccessibleAttached *attachedObj = new QQuickAccessibleAttached(&parent); + + attachedObj->name(); + + QVariant pp = attachedObj->property("name"); + QQmlEngine engine; + QQmlComponent component(&engine); + component.setData("import QtQuick 2.0\nItem {\n" + "Accessible.role: Accessible.Button\n" + "}", QUrl()); + QObject *object = component.create(); + QVERIFY(object != 0); + + QObject *attachedObject = QQuickAccessibleAttached::attachedProperties(object); + QVERIFY(attachedObject); + if (attachedObject) { + QVariant p = attachedObject->property("role"); + QCOMPARE(p.isNull(), false); + QCOMPARE(p.toInt(), int(QAccessible::PushButton)); + p = attachedObject->property("name"); + QCOMPARE(p.isNull(), true); + p = attachedObject->property("description"); + QCOMPARE(p.isNull(), true); + } + delete object; + } + + // Attached property + { + QQmlEngine engine; + QQmlComponent component(&engine); + component.setData("import QtQuick 2.0\nItem {\n" + "Accessible.role: Accessible.Button\n" + "Accessible.name: \"Donald\"\n" + "Accessible.description: \"Duck\"\n" + "}", QUrl()); + QObject *object = component.create(); + QVERIFY(object != 0); + + QObject *attachedObject = QQuickAccessibleAttached::attachedProperties(object); + QVERIFY(attachedObject); + if (attachedObject) { + QVariant p = attachedObject->property("role"); + QCOMPARE(p.isNull(), false); + QCOMPARE(p.toInt(), int(QAccessible::PushButton)); + p = attachedObject->property("name"); + QCOMPARE(p.isNull(), false); + QCOMPARE(p.toString(), QLatin1String("Donald")); + p = attachedObject->property("description"); + QCOMPARE(p.isNull(), false); + QCOMPARE(p.toString(), QLatin1String("Duck")); + } + delete object; + } +} + + +void tst_QQuickAccessible::basicPropertiesTest() +{ + QAI app = QAI(QAccessible::queryAccessibleInterface(qApp)); + QCOMPARE(app->childCount(), 0); + + QQuickView *canvas = new QQuickView(); + canvas->setSource(testFileUrl("statictext.qml")); + canvas->show(); + QCOMPARE(app->childCount(), 1); + + QAI iface = QAI(QAccessible::queryAccessibleInterface(canvas)); + QVERIFY(iface.data()); + QCOMPARE(iface->childCount(), 1); + + QAI item = QAI(iface->child(0)); + QVERIFY(item.data()); + QCOMPARE(item->childCount(), 2); + QCOMPARE(item->rect().size(), QSize(400, 400)); + QCOMPARE(item->role(), QAccessible::Pane); + QCOMPARE(iface->indexOfChild(item.data()), 0); + + QAI text = QAI(item->child(0)); + QVERIFY(text.data()); + QCOMPARE(text->childCount(), 0); + + QCOMPARE(text->text(QAccessible::Name), QLatin1String("Hello Accessibility")); + QCOMPARE(text->rect().size(), QSize(200, 50)); + QCOMPARE(text->rect().x(), item->rect().x() + 100); + QCOMPARE(text->rect().y(), item->rect().y() + 20); + QCOMPARE(text->role(), QAccessible::StaticText); + QCOMPARE(item->indexOfChild(text.data()), 0); + + QAI text2 = QAI(item->child(1)); + QVERIFY(text2.data()); + QCOMPARE(text2->childCount(), 0); + + QCOMPARE(text2->text(QAccessible::Name), QLatin1String("The Hello 2 accessible text")); + QCOMPARE(text2->rect().size(), QSize(100, 40)); + QCOMPARE(text2->rect().x(), item->rect().x() + 100); + QCOMPARE(text2->rect().y(), item->rect().y() + 40); + QCOMPARE(text2->role(), QAccessible::StaticText); + QCOMPARE(item->indexOfChild(text2.data()), 1); + + QCOMPARE(iface->indexOfChild(text2.data()), -1); + QCOMPARE(text2->indexOfChild(item.data()), -1); + + delete canvas; +} + +QAI topLevelChildAt(QAccessibleInterface *iface, int x, int y) +{ + QAI child = QAI(iface->childAt(x, y)); + if (!child) + return QAI(); + + QAI childOfChild; + while (childOfChild = QAI(child->childAt(x, y))) { + child = childOfChild; + } + return child; +} + +void tst_QQuickAccessible::hitTest() +{ + QQuickView *canvas = new QQuickView; + canvas->setSource(testFileUrl("hittest.qml")); + canvas->show(); + + QAI iface = QAI(QAccessible::queryAccessibleInterface(canvas)); + QVERIFY(iface.data()); + QAI rootItem = QAI(iface->child(0)); + QRect rootRect = rootItem->rect(); + + // hit the root item + QAI itemHit(iface->childAt(rootRect.x() + 200, rootRect.y() + 50)); + QVERIFY(itemHit); + QCOMPARE(rootRect, itemHit->rect()); + + // hit rect1 + QAI rect1(rootItem->child(1)); + QRect rect1Rect = rect1->rect(); + itemHit = QAI(rootItem->childAt(rect1Rect.x() + 10, rect1Rect.y() + 10)); + QVERIFY(itemHit); + QCOMPARE(rect1Rect, itemHit->rect()); + QCOMPARE(itemHit->text(QAccessible::Name), QLatin1String("rect1")); + + // should also work from top level (app) + QAI app(QAccessible::queryAccessibleInterface(qApp)); + QAI itemHit2(topLevelChildAt(app.data(), rect1Rect.x() + 10, rect1Rect.y() + 10)); + QVERIFY(itemHit2); + QCOMPARE(itemHit2->rect(), rect1Rect); + QCOMPARE(itemHit2->text(QAccessible::Name), QLatin1String("rect1")); + + // hit rect201 + QAI rect2(rootItem->child(2)); + QAI rect20(rect2->child(1)); + QAI rect201(rect20->child(2)); + QVERIFY(rect201); + + QRect rect201Rect = rect201->rect(); + itemHit = QAI(iface->childAt(rect201Rect.x() + 20, rect201Rect.y() + 20)); + QVERIFY(itemHit); + QCOMPARE(itemHit->rect(), rect201Rect); + QCOMPARE(itemHit->text(QAccessible::Name), QLatin1String("rect201")); + + delete canvas; +} + +void tst_QQuickAccessible::checkableTest() +{ + QQuickView *canvas = new QQuickView(); + canvas->setSource(testFileUrl("checkbuttons.qml")); + canvas->show(); + + QAI iface = QAI(QAccessible::queryAccessibleInterface(canvas)); + QVERIFY(iface.data()); + QAI root = QAI(iface->child(0)); + + QAI button1 = QAI(root->child(0)); + QCOMPARE(button1->role(), QAccessible::Button); + QVERIFY(!(button1->state().checked)); + QAI button2 = QAI(root->child(1)); + QVERIFY(!(button2->state().checked)); + QAI button3 = QAI(root->child(2)); + QVERIFY(button3->state().checked); + + QAI checkBox1 = QAI(root->child(3)); + QCOMPARE(checkBox1->role(), QAccessible::CheckBox); + QVERIFY((checkBox1->state().checked)); + QAI checkBox2 = QAI(root->child(4)); + QVERIFY(!(checkBox2->state().checked)); +} + +QTEST_MAIN(tst_QQuickAccessible) + +#include "tst_qquickaccessible.moc" diff --git a/tests/auto/quick/qquickanchors/data/anchors.qml b/tests/auto/quick/qquickanchors/data/anchors.qml new file mode 100644 index 0000000000..4be49a3468 --- /dev/null +++ b/tests/auto/quick/qquickanchors/data/anchors.qml @@ -0,0 +1,162 @@ +import QtQuick 2.0 + +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/quick/qquickanchors/data/centerin.qml b/tests/auto/quick/qquickanchors/data/centerin.qml new file mode 100644 index 0000000000..e6c9179116 --- /dev/null +++ b/tests/auto/quick/qquickanchors/data/centerin.qml @@ -0,0 +1,18 @@ +import QtQuick 2.0 + +Rectangle { + width: 200; height: 200 + Rectangle { + objectName: "centered" + width: 50; height: 50; color: "blue" + anchors.centerIn: parent; + anchors.verticalCenterOffset: 30 + anchors.horizontalCenterOffset: 10 + } + + Rectangle { + objectName: "centered2" + width: 11; height: 11; color: "green" + anchors.centerIn: parent; + } +} diff --git a/tests/auto/quick/qquickanchors/data/centerinRotation.qml b/tests/auto/quick/qquickanchors/data/centerinRotation.qml new file mode 100644 index 0000000000..933a25c100 --- /dev/null +++ b/tests/auto/quick/qquickanchors/data/centerinRotation.qml @@ -0,0 +1,17 @@ +import QtQuick 2.0 + +Rectangle { + width: 200; height: 200 + Rectangle { + objectName: "outer" + rotation: 90 + width: 101; height: 101; color: "blue" + anchors.centerIn: parent; + + Rectangle { + objectName: "inner" + width: 50; height: 50; color: "blue" + anchors.centerIn: parent; + } + } +} diff --git a/tests/auto/quick/qquickanchors/data/crash1.qml b/tests/auto/quick/qquickanchors/data/crash1.qml new file mode 100644 index 0000000000..98dd6cfa41 --- /dev/null +++ b/tests/auto/quick/qquickanchors/data/crash1.qml @@ -0,0 +1,11 @@ +import QtQuick 2.0 + +Column { + Text { + text: "foo" + anchors.fill: parent + } + Text { + text: "bar" + } +} diff --git a/tests/auto/quick/qquickanchors/data/fill.qml b/tests/auto/quick/qquickanchors/data/fill.qml new file mode 100644 index 0000000000..08db199d7b --- /dev/null +++ b/tests/auto/quick/qquickanchors/data/fill.qml @@ -0,0 +1,14 @@ +import QtQuick 2.0 + +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/quick/qquickanchors/data/hvCenter.qml b/tests/auto/quick/qquickanchors/data/hvCenter.qml new file mode 100644 index 0000000000..6763f8eb75 --- /dev/null +++ b/tests/auto/quick/qquickanchors/data/hvCenter.qml @@ -0,0 +1,11 @@ +import QtQuick 2.0 + +Rectangle { + width: 77; height: 95 + Rectangle { + objectName: "centered" + width: 57; height: 57; color: "blue" + anchors.verticalCenter: parent.verticalCenter + anchors.horizontalCenter: parent.horizontalCenter + } +} diff --git a/tests/auto/quick/qquickanchors/data/loop1.qml b/tests/auto/quick/qquickanchors/data/loop1.qml new file mode 100644 index 0000000000..342b2af052 --- /dev/null +++ b/tests/auto/quick/qquickanchors/data/loop1.qml @@ -0,0 +1,8 @@ +import QtQuick 2.0 + +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/quick/qquickanchors/data/loop2.qml b/tests/auto/quick/qquickanchors/data/loop2.qml new file mode 100644 index 0000000000..044152989e --- /dev/null +++ b/tests/auto/quick/qquickanchors/data/loop2.qml @@ -0,0 +1,20 @@ +import QtQuick 2.0 + +Rectangle { + id: container; + width: 600; + height: 600; + + Image { + id: image1 + source: "http://labs.qt.nokia.com/blogs/wp-content/uploads/2009/03/3311388091_ac2a257feb.jpg" + anchors.right: image2.left + } + + Image { + id: image2 + source: "http://labs.qt.nokia.com/blogs/wp-content/uploads/2009/03/oslo_groupphoto.jpg" + anchors.left: image1.right + anchors.leftMargin: 20 + } +} diff --git a/tests/auto/quick/qquickanchors/data/margins.qml b/tests/auto/quick/qquickanchors/data/margins.qml new file mode 100644 index 0000000000..9403f65a61 --- /dev/null +++ b/tests/auto/quick/qquickanchors/data/margins.qml @@ -0,0 +1,13 @@ +import QtQuick 2.0 + +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/quick/qquickanchors/qquickanchors.pro b/tests/auto/quick/qquickanchors/qquickanchors.pro new file mode 100644 index 0000000000..30e6e6dcf8 --- /dev/null +++ b/tests/auto/quick/qquickanchors/qquickanchors.pro @@ -0,0 +1,16 @@ +TARGET = tst_qquickanchors +CONFIG += testcase +SOURCES += tst_qquickanchors.cpp + +include (../../shared/util.pri) +include (../shared/util.pri) + +macx:CONFIG -= app_bundle + +testDataFiles.files = data +testDataFiles.path = . +DEPLOYMENT += testDataFiles + +CONFIG += parallel_test + +QT += core-private gui-private qml-private quick-private v8-private testlib diff --git a/tests/auto/quick/qquickanchors/tst_qquickanchors.cpp b/tests/auto/quick/qquickanchors/tst_qquickanchors.cpp new file mode 100644 index 0000000000..749b11f919 --- /dev/null +++ b/tests/auto/quick/qquickanchors/tst_qquickanchors.cpp @@ -0,0 +1,669 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "../../shared/util.h" +#include "../shared/visualtestutil.h" + +Q_DECLARE_METATYPE(QQuickAnchors::Anchor) +Q_DECLARE_METATYPE(QQuickAnchorLine::AnchorLine) + +using namespace QQuickVisualTestUtil; + +class tst_qquickanchors : public QQmlDataTest +{ + Q_OBJECT +public: + tst_qquickanchors() {} + +private slots: + void basicAnchors(); + void basicAnchorsRTL(); + void loops(); + void illegalSets(); + void illegalSets_data(); + void reset(); + void reset_data(); + void resetConvenience(); + void nullItem(); + void nullItem_data(); + void crash1(); + void centerIn(); + void centerInRTL(); + void centerInRotation(); + void hvCenter(); + void hvCenterRTL(); + void fill(); + void fillRTL(); + void margins(); + void marginsRTL(); +}; + +void tst_qquickanchors::basicAnchors() +{ + QQuickView *view = new QQuickView; + view->setSource(testFileUrl("anchors.qml")); + + qApp->processEvents(); + + //sibling horizontal + QCOMPARE(findItem(view->rootObject(), QLatin1String("rect1"))->x(), 26.0); + QCOMPARE(findItem(view->rootObject(), QLatin1String("rect2"))->x(), 122.0); + QCOMPARE(findItem(view->rootObject(), QLatin1String("rect3"))->x(), 74.0); + QCOMPARE(findItem(view->rootObject(), QLatin1String("rect4"))->x(), 16.0); + QCOMPARE(findItem(view->rootObject(), QLatin1String("rect5"))->x(), 112.0); + QCOMPARE(findItem(view->rootObject(), QLatin1String("rect6"))->x(), 64.0); + + //parent horizontal + QCOMPARE(findItem(view->rootObject(), QLatin1String("rect7"))->x(), 0.0); + QCOMPARE(findItem(view->rootObject(), QLatin1String("rect8"))->x(), 240.0); + QCOMPARE(findItem(view->rootObject(), QLatin1String("rect9"))->x(), 120.0); + QCOMPARE(findItem(view->rootObject(), QLatin1String("rect10"))->x(), -10.0); + QCOMPARE(findItem(view->rootObject(), QLatin1String("rect11"))->x(), 230.0); + QCOMPARE(findItem(view->rootObject(), QLatin1String("rect12"))->x(), 110.0); + + //vertical + QCOMPARE(findItem(view->rootObject(), QLatin1String("rect13"))->y(), 20.0); + QCOMPARE(findItem(view->rootObject(), QLatin1String("rect14"))->y(), 155.0); + + //stretch + QCOMPARE(findItem(view->rootObject(), QLatin1String("rect15"))->x(), 26.0); + QCOMPARE(findItem(view->rootObject(), QLatin1String("rect15"))->width(), 96.0); + QCOMPARE(findItem(view->rootObject(), QLatin1String("rect16"))->x(), 26.0); + QCOMPARE(findItem(view->rootObject(), QLatin1String("rect16"))->width(), 192.0); + QCOMPARE(findItem(view->rootObject(), QLatin1String("rect17"))->x(), -70.0); + QCOMPARE(findItem(view->rootObject(), QLatin1String("rect17"))->width(), 192.0); + + //vertical stretch + QCOMPARE(findItem(view->rootObject(), QLatin1String("rect18"))->y(), 20.0); + QCOMPARE(findItem(view->rootObject(), QLatin1String("rect18"))->height(), 40.0); + + //more parent horizontal + QCOMPARE(findItem(view->rootObject(), QLatin1String("rect19"))->x(), 115.0); + QCOMPARE(findItem(view->rootObject(), QLatin1String("rect20"))->x(), 235.0); + QCOMPARE(findItem(view->rootObject(), QLatin1String("rect21"))->x(), -5.0); + + //centerIn + QCOMPARE(findItem(view->rootObject(), QLatin1String("rect22"))->x(), 69.0); + QCOMPARE(findItem(view->rootObject(), QLatin1String("rect22"))->y(), 5.0); + + //margins + QCOMPARE(findItem(view->rootObject(), QLatin1String("rect23"))->x(), 31.0); + QCOMPARE(findItem(view->rootObject(), QLatin1String("rect23"))->y(), 5.0); + QCOMPARE(findItem(view->rootObject(), QLatin1String("rect23"))->width(), 86.0); + QCOMPARE(findItem(view->rootObject(), QLatin1String("rect23"))->height(), 10.0); + + // offsets + QCOMPARE(findItem(view->rootObject(), QLatin1String("rect24"))->x(), 26.0); + QCOMPARE(findItem(view->rootObject(), QLatin1String("rect25"))->y(), 60.0); + QCOMPARE(findItem(view->rootObject(), QLatin1String("rect26"))->y(), 5.0); + + //baseline + QQuickText *text1 = findItem(view->rootObject(), QLatin1String("text1")); + QQuickText *text2 = findItem(view->rootObject(), QLatin1String("text2")); + QCOMPARE(text1->y(), text2->y()); + + delete view; +} + +QQuickItem* childItem(QQuickItem *parentItem, const char * itemString) { + return findItem(parentItem, QLatin1String(itemString)); +} + +qreal offsetMasterRTL(QQuickItem *rootItem, const char * itemString) { + QQuickItem* masterItem = findItem(rootItem, QLatin1String("masterRect")); + return masterItem->width()+2*masterItem->x()-findItem(rootItem, QLatin1String(itemString))->width(); +} + +qreal offsetParentRTL(QQuickItem *rootItem, const char * itemString) { + return rootItem->width()+2*rootItem->x()-findItem(rootItem, QLatin1String(itemString))->width(); +} + +void mirrorAnchors(QQuickItem *item) { + QQuickItemPrivate *itemPrivate = QQuickItemPrivate::get(item); + itemPrivate->setLayoutMirror(true); +} + +void tst_qquickanchors::basicAnchorsRTL() +{ + QQuickView *view = new QQuickView; + view->setSource(testFileUrl("anchors.qml")); + + qApp->processEvents(); + + QQuickItem* rootItem = qobject_cast(view->rootObject()); + foreach (QObject *child, rootItem->children()) { + bool mirrored = QQuickItemPrivate::get(qobject_cast(child))->anchors()->property("mirrored").toBool(); + QCOMPARE(mirrored, false); + } + + foreach (QObject *child, rootItem->children()) + mirrorAnchors(qobject_cast(child)); + + foreach (QObject *child, rootItem->children()) { + bool mirrored = QQuickItemPrivate::get(qobject_cast(child))->anchors()->property("mirrored").toBool(); + QCOMPARE(mirrored, true); + } + + //sibling horizontal + QCOMPARE(childItem(rootItem, "rect1")->x(), offsetMasterRTL(rootItem, "rect1")-26.0); + QCOMPARE(childItem(rootItem, "rect2")->x(), offsetMasterRTL(rootItem, "rect2")-122.0); + QCOMPARE(childItem(rootItem, "rect3")->x(), offsetMasterRTL(rootItem, "rect3")-74.0); + QCOMPARE(childItem(rootItem, "rect4")->x(), offsetMasterRTL(rootItem, "rect4")-16.0); + QCOMPARE(childItem(rootItem, "rect5")->x(), offsetMasterRTL(rootItem, "rect5")-112.0); + QCOMPARE(childItem(rootItem, "rect6")->x(), offsetMasterRTL(rootItem, "rect6")-64.0); + + //parent horizontal + QCOMPARE(childItem(rootItem, "rect7")->x(), offsetParentRTL(rootItem, "rect7")-0.0); + QCOMPARE(childItem(rootItem, "rect8")->x(), offsetParentRTL(rootItem, "rect8")-240.0); + QCOMPARE(childItem(rootItem, "rect9")->x(), offsetParentRTL(rootItem, "rect9")-120.0); + QCOMPARE(childItem(rootItem, "rect10")->x(), offsetParentRTL(rootItem, "rect10")+10.0); + QCOMPARE(childItem(rootItem, "rect11")->x(), offsetParentRTL(rootItem, "rect11")-230.0); + QCOMPARE(childItem(rootItem, "rect12")->x(), offsetParentRTL(rootItem, "rect12")-110.0); + + //vertical + QCOMPARE(childItem(rootItem, "rect13")->y(), 20.0); + QCOMPARE(childItem(rootItem, "rect14")->y(), 155.0); + + //stretch + QCOMPARE(childItem(rootItem, "rect15")->x(), offsetMasterRTL(rootItem, "rect15")-26.0); + QCOMPARE(childItem(rootItem, "rect15")->width(), 96.0); + QCOMPARE(childItem(rootItem, "rect16")->x(), offsetMasterRTL(rootItem, "rect16")-26.0); + QCOMPARE(childItem(rootItem, "rect16")->width(), 192.0); + QCOMPARE(childItem(rootItem, "rect17")->x(), offsetMasterRTL(rootItem, "rect17")+70.0); + QCOMPARE(childItem(rootItem, "rect17")->width(), 192.0); + + //vertical stretch + QCOMPARE(childItem(rootItem, "rect18")->y(), 20.0); + QCOMPARE(childItem(rootItem, "rect18")->height(), 40.0); + + //more parent horizontal + QCOMPARE(childItem(rootItem, "rect19")->x(), offsetParentRTL(rootItem, "rect19")-115.0); + QCOMPARE(childItem(rootItem, "rect20")->x(), offsetParentRTL(rootItem, "rect20")-235.0); + QCOMPARE(childItem(rootItem, "rect21")->x(), offsetParentRTL(rootItem, "rect21")+5.0); + + //centerIn + QCOMPARE(childItem(rootItem, "rect22")->x(), offsetMasterRTL(rootItem, "rect22")-69.0); + QCOMPARE(childItem(rootItem, "rect22")->y(), 5.0); + + //margins + QCOMPARE(childItem(rootItem, "rect23")->x(), offsetMasterRTL(rootItem, "rect23")-31.0); + QCOMPARE(childItem(rootItem, "rect23")->y(), 5.0); + QCOMPARE(childItem(rootItem, "rect23")->width(), 86.0); + QCOMPARE(childItem(rootItem, "rect23")->height(), 10.0); + + // offsets + QCOMPARE(childItem(rootItem, "rect24")->x(), offsetMasterRTL(rootItem, "rect24")-26.0); + QCOMPARE(childItem(rootItem, "rect25")->y(), 60.0); + QCOMPARE(childItem(rootItem, "rect26")->y(), 5.0); + + //baseline + QQuickText *text1 = findItem(rootItem, QLatin1String("text1")); + QQuickText *text2 = findItem(rootItem, QLatin1String("text2")); + QCOMPARE(text1->y(), text2->y()); + + delete view; +} + +// mostly testing that we don't crash +void tst_qquickanchors::loops() +{ + { + QUrl source(testFileUrl("loop1.qml")); + + QString expect = source.toString() + ":6:5: QML Text: Possible anchor loop detected on horizontal anchor."; + QTest::ignoreMessage(QtWarningMsg, expect.toLatin1()); + QTest::ignoreMessage(QtWarningMsg, expect.toLatin1()); + + QQuickView *view = new QQuickView; + view->setSource(source); + qApp->processEvents(); + + delete view; + } + + { + QUrl source(testFileUrl("loop2.qml")); + + QString expect = source.toString() + ":8:3: QML Image: Possible anchor loop detected on horizontal anchor."; + QTest::ignoreMessage(QtWarningMsg, expect.toLatin1()); + + QQuickView *view = new QQuickView; + view->setSource(source); + qApp->processEvents(); + + delete view; + } +} + +void tst_qquickanchors::illegalSets() +{ + QFETCH(QString, qml); + QFETCH(QString, warning); + + QTest::ignoreMessage(QtWarningMsg, warning.toLatin1()); + + QQmlEngine engine; + QQmlComponent component(&engine); + component.setData(QByteArray("import QtQuick 2.0\n" + qml.toUtf8()), QUrl::fromLocalFile("")); + if (!component.isReady()) + qWarning() << "Test errors:" << component.errors(); + QVERIFY(component.isReady()); + QObject *o = component.create(); + delete o; +} + +void tst_qquickanchors::illegalSets_data() +{ + QTest::addColumn("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 } }" + << "file::2:23: QML Rectangle: Cannot specify left, right, and hcenter anchors."; + + foreach (const QString &side, QStringList() << "left" << "right") { + QTest::newRow("H - anchor to V") + << QString("Rectangle { Rectangle { anchors.%1: parent.top } }").arg(side) + << "file::2:13: QML Rectangle: Cannot anchor a horizontal edge to a vertical edge."; + + QTest::newRow("H - anchor to non parent/sibling") + << QString("Rectangle { Item { Rectangle { id: rect } } Rectangle { anchors.%1: rect.%1 } }").arg(side) + << "file::2:45: QML Rectangle: Cannot anchor to an item that isn't a parent or sibling."; + + QTest::newRow("H - anchor to self") + << QString("Rectangle { id: rect; anchors.%1: rect.%1 }").arg(side) + << "file::2:1: QML Rectangle: Cannot anchor item to self."; + } + + + QTest::newRow("V - too many anchors") + << "Rectangle { id: rect; Rectangle { anchors.top: rect.top; anchors.bottom: rect.bottom; anchors.verticalCenter: rect.verticalCenter } }" + << "file::2:23: QML Rectangle: Cannot specify top, bottom, and vcenter anchors."; + + QTest::newRow("V - too many anchors with baseline") + << "Rectangle { Text { id: text1; text: \"Hello\" } Text { anchors.baseline: text1.baseline; anchors.top: text1.top; } }" + << "file::2:47: QML Text: Baseline anchor cannot be used in conjunction with top, bottom, or vcenter anchors."; + + foreach (const QString &side, QStringList() << "top" << "bottom" << "baseline") { + + QTest::newRow("V - anchor to H") + << QString("Rectangle { Rectangle { anchors.%1: parent.left } }").arg(side) + << "file::2:13: QML Rectangle: Cannot anchor a vertical edge to a horizontal edge."; + + QTest::newRow("V - anchor to non parent/sibling") + << QString("Rectangle { Item { Rectangle { id: rect } } Rectangle { anchors.%1: rect.%1 } }").arg(side) + << "file::2:45: QML Rectangle: Cannot anchor to an item that isn't a parent or sibling."; + + QTest::newRow("V - anchor to self") + << QString("Rectangle { id: rect; anchors.%1: rect.%1 }").arg(side) + << "file::2:1: QML Rectangle: Cannot anchor item to self."; + } + + + QTest::newRow("centerIn - anchor to non parent/sibling") + << "Rectangle { Item { Rectangle { id: rect } } Rectangle { anchors.centerIn: rect} }" + << "file::2:45: QML Rectangle: Cannot anchor to an item that isn't a parent or sibling."; + + + QTest::newRow("fill - anchor to non parent/sibling") + << "Rectangle { Item { Rectangle { id: rect } } Rectangle { anchors.fill: rect} }" + << "file::2:45: QML Rectangle: Cannot anchor to an item that isn't a parent or sibling."; +} + +void tst_qquickanchors::reset() +{ + QFETCH(QString, side); + QFETCH(QQuickAnchorLine::AnchorLine, anchorLine); + QFETCH(QQuickAnchors::Anchor, usedAnchor); + + QQuickItem *baseItem = new QQuickItem; + + QQuickAnchorLine anchor; + anchor.item = baseItem; + anchor.anchorLine = anchorLine; + + QQuickItem *item = new QQuickItem; + QQuickItemPrivate *itemPrivate = QQuickItemPrivate::get(item); + + const QMetaObject *meta = itemPrivate->anchors()->metaObject(); + QMetaProperty p = meta->property(meta->indexOfProperty(side.toUtf8().constData())); + + QVERIFY(p.write(itemPrivate->anchors(), qVariantFromValue(anchor))); + QCOMPARE(itemPrivate->anchors()->usedAnchors().testFlag(usedAnchor), true); + + QVERIFY(p.reset(itemPrivate->anchors())); + QCOMPARE(itemPrivate->anchors()->usedAnchors().testFlag(usedAnchor), false); + + delete item; + delete baseItem; +} + +void tst_qquickanchors::reset_data() +{ + QTest::addColumn("side"); + QTest::addColumn("anchorLine"); + QTest::addColumn("usedAnchor"); + + QTest::newRow("left") << "left" << QQuickAnchorLine::Left << QQuickAnchors::LeftAnchor; + QTest::newRow("top") << "top" << QQuickAnchorLine::Top << QQuickAnchors::TopAnchor; + QTest::newRow("right") << "right" << QQuickAnchorLine::Right << QQuickAnchors::RightAnchor; + QTest::newRow("bottom") << "bottom" << QQuickAnchorLine::Bottom << QQuickAnchors::BottomAnchor; + + QTest::newRow("hcenter") << "horizontalCenter" << QQuickAnchorLine::HCenter << QQuickAnchors::HCenterAnchor; + QTest::newRow("vcenter") << "verticalCenter" << QQuickAnchorLine::VCenter << QQuickAnchors::VCenterAnchor; + QTest::newRow("baseline") << "baseline" << QQuickAnchorLine::Baseline << QQuickAnchors::BaselineAnchor; +} + +void tst_qquickanchors::resetConvenience() +{ + QQuickItem *baseItem = new QQuickItem; + QQuickItem *item = new QQuickItem; + QQuickItemPrivate *itemPrivate = QQuickItemPrivate::get(item); + + //fill + itemPrivate->anchors()->setFill(baseItem); + QVERIFY(itemPrivate->anchors()->fill() == baseItem); + itemPrivate->anchors()->resetFill(); + QVERIFY(itemPrivate->anchors()->fill() == 0); + + //centerIn + itemPrivate->anchors()->setCenterIn(baseItem); + QVERIFY(itemPrivate->anchors()->centerIn() == baseItem); + itemPrivate->anchors()->resetCenterIn(); + QVERIFY(itemPrivate->anchors()->centerIn() == 0); + + delete item; + delete baseItem; +} + +void tst_qquickanchors::nullItem() +{ + QFETCH(QString, side); + + QQuickAnchorLine anchor; + QQuickItem *item = new QQuickItem; + QQuickItemPrivate *itemPrivate = QQuickItemPrivate::get(item); + + const QMetaObject *meta = itemPrivate->anchors()->metaObject(); + QMetaProperty p = meta->property(meta->indexOfProperty(side.toUtf8().constData())); + + QTest::ignoreMessage(QtWarningMsg, ": QML Item: Cannot anchor to a null item."); + QVERIFY(p.write(itemPrivate->anchors(), qVariantFromValue(anchor))); + + delete item; +} + +void tst_qquickanchors::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"; +} + +//QTBUG-5428 +void tst_qquickanchors::crash1() +{ + QUrl source(testFileUrl("crash1.qml")); + + QQuickView *view = new QQuickView(source); + qApp->processEvents(); + + delete view; +} + +void tst_qquickanchors::fill() +{ + QQuickView *view = new QQuickView(testFileUrl("fill.qml")); + + qApp->processEvents(); + QQuickRectangle* rect = findItem(view->rootObject(), QLatin1String("filler")); + QQuickItemPrivate *rectPrivate = QQuickItemPrivate::get(rect); + QCOMPARE(rect->x(), 0.0 + 10.0); + QCOMPARE(rect->y(), 0.0 + 30.0); + QCOMPARE(rect->width(), 200.0 - 10.0 - 20.0); + QCOMPARE(rect->height(), 200.0 - 30.0 - 40.0); + //Alter Offsets (tests QTBUG-6631) + rectPrivate->anchors()->setLeftMargin(20.0); + rectPrivate->anchors()->setRightMargin(0.0); + rectPrivate->anchors()->setBottomMargin(0.0); + rectPrivate->anchors()->setTopMargin(10.0); + QCOMPARE(rect->x(), 0.0 + 20.0); + QCOMPARE(rect->y(), 0.0 + 10.0); + QCOMPARE(rect->width(), 200.0 - 20.0); + QCOMPARE(rect->height(), 200.0 - 10.0); + + delete view; +} + +void tst_qquickanchors::fillRTL() +{ + QQuickView *view = new QQuickView(testFileUrl("fill.qml")); + + qApp->processEvents(); + QQuickRectangle* rect = findItem(view->rootObject(), QLatin1String("filler")); + QQuickItemPrivate *rectPrivate = QQuickItemPrivate::get(rect); + mirrorAnchors(rect); + + QCOMPARE(rect->x(), 0.0 + 20.0); + QCOMPARE(rect->y(), 0.0 + 30.0); + QCOMPARE(rect->width(), 200.0 - 10.0 - 20.0); + QCOMPARE(rect->height(), 200.0 - 30.0 - 40.0); + //Alter Offsets (tests QTBUG-6631) + rectPrivate->anchors()->setLeftMargin(20.0); + rectPrivate->anchors()->setRightMargin(0.0); + rectPrivate->anchors()->setBottomMargin(0.0); + rectPrivate->anchors()->setTopMargin(10.0); + QCOMPARE(rect->x(), 0.0 + 0.0); + QCOMPARE(rect->y(), 0.0 + 10.0); + QCOMPARE(rect->width(), 200.0 - 20.0); + QCOMPARE(rect->height(), 200.0 - 10.0); + + delete view; +} + +void tst_qquickanchors::centerIn() +{ + QQuickView *view = new QQuickView(testFileUrl("centerin.qml")); + + qApp->processEvents(); + QQuickRectangle* rect = findItem(view->rootObject(), QLatin1String("centered")); + QQuickItemPrivate *rectPrivate = QQuickItemPrivate::get(rect); + + QCOMPARE(rect->x(), 75.0 + 10); + QCOMPARE(rect->y(), 75.0 + 30); + //Alter Offsets (tests QTBUG-6631) + rectPrivate->anchors()->setHorizontalCenterOffset(-20.0); + rectPrivate->anchors()->setVerticalCenterOffset(-10.0); + QCOMPARE(rect->x(), 75.0 - 20.0); + QCOMPARE(rect->y(), 75.0 - 10.0); + + //QTBUG-21730 (use actual center to prevent animation jitter) + QQuickRectangle* rect2 = findItem(view->rootObject(), QLatin1String("centered2")); + QCOMPARE(rect2->x(), 94.5); + QCOMPARE(rect2->y(), 94.5); + + delete view; +} + +void tst_qquickanchors::centerInRTL() +{ + QQuickView *view = new QQuickView(testFileUrl("centerin.qml")); + + qApp->processEvents(); + QQuickRectangle* rect = findItem(view->rootObject(), QLatin1String("centered")); + QQuickItemPrivate *rectPrivate = QQuickItemPrivate::get(rect); + mirrorAnchors(rect); + + QCOMPARE(rect->x(), 75.0 - 10); + QCOMPARE(rect->y(), 75.0 + 30); + //Alter Offsets (tests QTBUG-6631) + rectPrivate->anchors()->setHorizontalCenterOffset(-20.0); + rectPrivate->anchors()->setVerticalCenterOffset(-10.0); + QCOMPARE(rect->x(), 75.0 + 20.0); + QCOMPARE(rect->y(), 75.0 - 10.0); + + delete view; +} + +//QTBUG-12441 +void tst_qquickanchors::centerInRotation() +{ + QQuickView *view = new QQuickView(testFileUrl("centerinRotation.qml")); + + qApp->processEvents(); + QQuickRectangle* outer = findItem(view->rootObject(), QLatin1String("outer")); + QQuickRectangle* inner = findItem(view->rootObject(), QLatin1String("inner")); + + QCOMPARE(outer->x(), qreal(49.5)); + QCOMPARE(outer->y(), qreal(49.5)); + QCOMPARE(inner->x(), qreal(25.5)); + QCOMPARE(inner->y(), qreal(25.5)); + + delete view; +} + +void tst_qquickanchors::hvCenter() +{ + QQuickView *view = new QQuickView(testFileUrl("hvCenter.qml")); + + qApp->processEvents(); + QQuickRectangle* rect = findItem(view->rootObject(), QLatin1String("centered")); + QQuickItemPrivate *rectPrivate = QQuickItemPrivate::get(rect); + + // test QTBUG-10999 + QCOMPARE(rect->x(), 10.0); + QCOMPARE(rect->y(), 19.0); + + rectPrivate->anchors()->setHorizontalCenterOffset(-5.0); + rectPrivate->anchors()->setVerticalCenterOffset(5.0); + QCOMPARE(rect->x(), 10.0 - 5.0); + QCOMPARE(rect->y(), 19.0 + 5.0); + + delete view; +} + +void tst_qquickanchors::hvCenterRTL() +{ + QQuickView *view = new QQuickView(testFileUrl("hvCenter.qml")); + + qApp->processEvents(); + QQuickRectangle* rect = findItem(view->rootObject(), QLatin1String("centered")); + QQuickItemPrivate *rectPrivate = QQuickItemPrivate::get(rect); + mirrorAnchors(rect); + + // test QTBUG-10999 + QCOMPARE(rect->x(), 10.0); + QCOMPARE(rect->y(), 19.0); + + rectPrivate->anchors()->setHorizontalCenterOffset(-5.0); + rectPrivate->anchors()->setVerticalCenterOffset(5.0); + QCOMPARE(rect->x(), 10.0 + 5.0); + QCOMPARE(rect->y(), 19.0 + 5.0); + + delete view; +} +void tst_qquickanchors::margins() +{ + QQuickView *view = new QQuickView(testFileUrl("margins.qml")); + + qApp->processEvents(); + QQuickRectangle* rect = findItem(view->rootObject(), QLatin1String("filler")); + QQuickItemPrivate *rectPrivate = QQuickItemPrivate::get(rect); + QCOMPARE(rect->x(), 5.0); + QCOMPARE(rect->y(), 6.0); + QCOMPARE(rect->width(), 200.0 - 5.0 - 10.0); + QCOMPARE(rect->height(), 200.0 - 6.0 - 10.0); + + rectPrivate->anchors()->setTopMargin(0.0); + rectPrivate->anchors()->setMargins(20.0); + + QCOMPARE(rect->x(), 5.0); + QCOMPARE(rect->y(), 20.0); + QCOMPARE(rect->width(), 200.0 - 5.0 - 20.0); + QCOMPARE(rect->height(), 200.0 - 20.0 - 20.0); + + delete view; +} + +void tst_qquickanchors::marginsRTL() +{ + QQuickView *view = new QQuickView(testFileUrl("margins.qml")); + + QQuickRectangle* rect = findItem(view->rootObject(), QLatin1String("filler")); + QQuickItemPrivate *rectPrivate = QQuickItemPrivate::get(rect); + mirrorAnchors(rect); + + QCOMPARE(rect->x(), 10.0); + QCOMPARE(rect->y(), 6.0); + QCOMPARE(rect->width(), 200.0 - 5.0 - 10.0); + QCOMPARE(rect->height(), 200.0 - 6.0 - 10.0); + + rectPrivate->anchors()->setTopMargin(0.0); + rectPrivate->anchors()->setMargins(20.0); + + QCOMPARE(rect->x(), 20.0); + QCOMPARE(rect->y(), 20.0); + QCOMPARE(rect->width(), 200.0 - 5.0 - 20.0); + QCOMPARE(rect->height(), 200.0 - 20.0 - 20.0); + + delete view; +} + + +QTEST_MAIN(tst_qquickanchors) + +#include "tst_qquickanchors.moc" diff --git a/tests/auto/quick/qquickanimatedimage/data/colors.gif b/tests/auto/quick/qquickanimatedimage/data/colors.gif new file mode 100644 index 0000000000..1270bfaa79 Binary files /dev/null and b/tests/auto/quick/qquickanimatedimage/data/colors.gif differ diff --git a/tests/auto/quick/qquickanimatedimage/data/colors.qml b/tests/auto/quick/qquickanimatedimage/data/colors.qml new file mode 100644 index 0000000000..5ccc0148dd --- /dev/null +++ b/tests/auto/quick/qquickanimatedimage/data/colors.qml @@ -0,0 +1,5 @@ +import QtQuick 2.0 + +AnimatedImage { + source: "colors.gif" +} diff --git a/tests/auto/quick/qquickanimatedimage/data/hearts.gif b/tests/auto/quick/qquickanimatedimage/data/hearts.gif new file mode 100644 index 0000000000..cfb55f27f5 Binary files /dev/null and b/tests/auto/quick/qquickanimatedimage/data/hearts.gif differ diff --git a/tests/auto/quick/qquickanimatedimage/data/hearts.qml b/tests/auto/quick/qquickanimatedimage/data/hearts.qml new file mode 100644 index 0000000000..717bab430b --- /dev/null +++ b/tests/auto/quick/qquickanimatedimage/data/hearts.qml @@ -0,0 +1,6 @@ +import QtQuick 2.0 + +AnimatedImage { + source: "hearts.gif" + playing: false +} diff --git a/tests/auto/quick/qquickanimatedimage/data/qmldir b/tests/auto/quick/qquickanimatedimage/data/qmldir new file mode 100644 index 0000000000..ef7c1f44f3 --- /dev/null +++ b/tests/auto/quick/qquickanimatedimage/data/qmldir @@ -0,0 +1 @@ +# No local types diff --git a/tests/auto/quick/qquickanimatedimage/data/qtbug-16520.qml b/tests/auto/quick/qquickanimatedimage/data/qtbug-16520.qml new file mode 100644 index 0000000000..da77a4063b --- /dev/null +++ b/tests/auto/quick/qquickanimatedimage/data/qtbug-16520.qml @@ -0,0 +1,17 @@ +import QtQuick 2.0 + +Rectangle { + width: 500 + height: 500 + + AnimatedImage { + objectName: "anim" + anchors.centerIn: parent + asynchronous: true + opacity: status == AnimatedImage.Ready ? 1 : 0 + + Behavior on opacity { + NumberAnimation { duration: 1000 } + } + } +} diff --git a/tests/auto/quick/qquickanimatedimage/data/stickman.gif b/tests/auto/quick/qquickanimatedimage/data/stickman.gif new file mode 100644 index 0000000000..7c4cd18687 Binary files /dev/null and b/tests/auto/quick/qquickanimatedimage/data/stickman.gif differ diff --git a/tests/auto/quick/qquickanimatedimage/data/stickman.qml b/tests/auto/quick/qquickanimatedimage/data/stickman.qml new file mode 100644 index 0000000000..a47924de21 --- /dev/null +++ b/tests/auto/quick/qquickanimatedimage/data/stickman.qml @@ -0,0 +1,5 @@ +import QtQuick 2.0 + +AnimatedImage { + source: "stickman.gif" +} diff --git a/tests/auto/quick/qquickanimatedimage/data/stickmanerror1.qml b/tests/auto/quick/qquickanimatedimage/data/stickmanerror1.qml new file mode 100644 index 0000000000..4f823b3d70 --- /dev/null +++ b/tests/auto/quick/qquickanimatedimage/data/stickmanerror1.qml @@ -0,0 +1,6 @@ +import QtQuick 2.0 + +AnimatedImage { + sourceSize: "240x180" + source: "stickman.gif" +} diff --git a/tests/auto/quick/qquickanimatedimage/data/stickmanpause.qml b/tests/auto/quick/qquickanimatedimage/data/stickmanpause.qml new file mode 100644 index 0000000000..ef771ed56f --- /dev/null +++ b/tests/auto/quick/qquickanimatedimage/data/stickmanpause.qml @@ -0,0 +1,7 @@ +import QtQuick 2.0 + +AnimatedImage { + source: "stickman.gif" + paused: true + currentFrame: 2 +} diff --git a/tests/auto/quick/qquickanimatedimage/data/stickmanscaled.qml b/tests/auto/quick/qquickanimatedimage/data/stickmanscaled.qml new file mode 100644 index 0000000000..1ef1f95165 --- /dev/null +++ b/tests/auto/quick/qquickanimatedimage/data/stickmanscaled.qml @@ -0,0 +1,7 @@ +import QtQuick 2.0 + +AnimatedImage { + width: 240 + height: 180 + source: "stickman.gif" +} diff --git a/tests/auto/quick/qquickanimatedimage/data/stickmanstopped.qml b/tests/auto/quick/qquickanimatedimage/data/stickmanstopped.qml new file mode 100644 index 0000000000..0bf80b8972 --- /dev/null +++ b/tests/auto/quick/qquickanimatedimage/data/stickmanstopped.qml @@ -0,0 +1,6 @@ +import QtQuick 2.0 + +AnimatedImage { + source: "stickman.gif" + playing: false +} diff --git a/tests/auto/quick/qquickanimatedimage/qquickanimatedimage.pro b/tests/auto/quick/qquickanimatedimage/qquickanimatedimage.pro new file mode 100644 index 0000000000..468a3253f8 --- /dev/null +++ b/tests/auto/quick/qquickanimatedimage/qquickanimatedimage.pro @@ -0,0 +1,17 @@ +CONFIG += testcase +TARGET = tst_qquickanimatedimage +HEADERS += ../../shared/testhttpserver.h +SOURCES += tst_qquickanimatedimage.cpp \ + ../../shared/testhttpserver.cpp + +include (../../shared/util.pri) + +macx:CONFIG -= app_bundle + +testDataFiles.files = data +testDataFiles.path = . +DEPLOYMENT += testDataFiles + +CONFIG += parallel_test + +QT += core-private gui-private qml-private quick-private network testlib diff --git a/tests/auto/quick/qquickanimatedimage/tst_qquickanimatedimage.cpp b/tests/auto/quick/qquickanimatedimage/tst_qquickanimatedimage.cpp new file mode 100644 index 0000000000..7775e395cb --- /dev/null +++ b/tests/auto/quick/qquickanimatedimage/tst_qquickanimatedimage.cpp @@ -0,0 +1,374 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "../../shared/testhttpserver.h" +#include "../../shared/util.h" + +Q_DECLARE_METATYPE(QQuickImageBase::Status) + +class tst_qquickanimatedimage : public QQmlDataTest +{ + Q_OBJECT +public: + tst_qquickanimatedimage() {} + +private slots: + void play(); + void pause(); + void stopped(); + void setFrame(); + void frameCount(); + void mirror_running(); + void mirror_notRunning(); + void mirror_notRunning_data(); + void remote(); + void remote_data(); + void sourceSize(); + void sourceSizeReadOnly(); + void invalidSource(); + void qtbug_16520(); + void progressAndStatusChanges(); + +}; + +void tst_qquickanimatedimage::play() +{ + QQmlEngine engine; + QQmlComponent component(&engine, testFileUrl("stickman.qml")); + QQuickAnimatedImage *anim = qobject_cast(component.create()); + QVERIFY(anim); + QVERIFY(anim->isPlaying()); + + delete anim; +} + +void tst_qquickanimatedimage::pause() +{ + QQmlEngine engine; + QQmlComponent component(&engine, testFileUrl("stickmanpause.qml")); + QQuickAnimatedImage *anim = qobject_cast(component.create()); + QVERIFY(anim); + QVERIFY(anim->isPlaying()); + QVERIFY(anim->isPaused()); + + delete anim; +} + +void tst_qquickanimatedimage::stopped() +{ + QQmlEngine engine; + QQmlComponent component(&engine, testFileUrl("stickmanstopped.qml")); + QQuickAnimatedImage *anim = qobject_cast(component.create()); + QVERIFY(anim); + QVERIFY(!anim->isPlaying()); + QCOMPARE(anim->currentFrame(), 0); + + delete anim; +} + +void tst_qquickanimatedimage::setFrame() +{ + QQmlEngine engine; + QQmlComponent component(&engine, testFileUrl("stickmanpause.qml")); + QQuickAnimatedImage *anim = qobject_cast(component.create()); + QVERIFY(anim); + QVERIFY(anim->isPlaying()); + QCOMPARE(anim->currentFrame(), 2); + + delete anim; +} + +void tst_qquickanimatedimage::frameCount() +{ + QQmlEngine engine; + QQmlComponent component(&engine, testFileUrl("colors.qml")); + QQuickAnimatedImage *anim = qobject_cast(component.create()); + QVERIFY(anim); + QVERIFY(anim->isPlaying()); + QCOMPARE(anim->frameCount(), 3); + + delete anim; +} + +void tst_qquickanimatedimage::mirror_running() +{ + // test where mirror is set to true after animation has started + + QQuickView canvas; + canvas.show(); + + canvas.setSource(testFileUrl("hearts.qml")); + QQuickAnimatedImage *anim = qobject_cast(canvas.rootObject()); + QVERIFY(anim); + + int width = anim->property("width").toInt(); + + QCOMPARE(anim->currentFrame(), 0); + QPixmap frame0 = QPixmap::fromImage(canvas.grabFrameBuffer()); + + anim->setCurrentFrame(1); + QPixmap frame1 = QPixmap::fromImage(canvas.grabFrameBuffer()); + + anim->setCurrentFrame(0); + + QSignalSpy spy(anim, SIGNAL(frameChanged())); + anim->setPlaying(true); + + QTRY_VERIFY(spy.count() == 1); spy.clear(); + anim->setProperty("mirror", true); + + QCOMPARE(anim->currentFrame(), 1); + QPixmap frame1_flipped = QPixmap::fromImage(canvas.grabFrameBuffer()); + + QTRY_VERIFY(spy.count() == 1); spy.clear(); + QCOMPARE(anim->currentFrame(), 0); // animation only has 2 frames, should cycle back to first + QPixmap frame0_flipped = QPixmap::fromImage(canvas.grabFrameBuffer()); + + QSKIP("Skip while QTBUG-19351 and QTBUG-19252 are not resolved"); + + QTransform transform; + transform.translate(width, 0).scale(-1, 1.0); + QPixmap frame0_expected = frame0.transformed(transform); + QPixmap frame1_expected = frame1.transformed(transform); + + QCOMPARE(frame0_flipped, frame0_expected); + QCOMPARE(frame1_flipped, frame1_expected); +} + +void tst_qquickanimatedimage::mirror_notRunning() +{ + QFETCH(QUrl, fileUrl); + + QQuickView canvas; + canvas.show(); + + canvas.setSource(fileUrl); + QQuickAnimatedImage *anim = qobject_cast(canvas.rootObject()); + QVERIFY(anim); + + int width = anim->property("width").toInt(); + QPixmap screenshot = QPixmap::fromImage(canvas.grabFrameBuffer()); + + QTransform transform; + transform.translate(width, 0).scale(-1, 1.0); + QPixmap expected = screenshot.transformed(transform); + + int frame = anim->currentFrame(); + bool playing = anim->isPlaying(); + bool paused = anim->isPlaying(); + + anim->setProperty("mirror", true); + screenshot = QPixmap::fromImage(canvas.grabFrameBuffer()); + + QSKIP("Skip while QTBUG-19351 and QTBUG-19252 are not resolved"); + QCOMPARE(screenshot, expected); + + // mirroring should not change the current frame or playing status + QCOMPARE(anim->currentFrame(), frame); + QCOMPARE(anim->isPlaying(), playing); + QCOMPARE(anim->isPaused(), paused); +} + +void tst_qquickanimatedimage::mirror_notRunning_data() +{ + QTest::addColumn("fileUrl"); + + QTest::newRow("paused") << testFileUrl("stickmanpause.qml"); + QTest::newRow("stopped") << testFileUrl("stickmanstopped.qml"); +} + +void tst_qquickanimatedimage::remote() +{ + QFETCH(QString, fileName); + QFETCH(bool, paused); + + TestHTTPServer server(14449); + QVERIFY(server.isValid()); + server.serveDirectory(dataDirectory()); + + QQmlEngine engine; + QQmlComponent component(&engine, QUrl("http://127.0.0.1:14449/" + fileName)); + QTRY_VERIFY(component.isReady()); + + QQuickAnimatedImage *anim = qobject_cast(component.create()); + QVERIFY(anim); + + QTRY_VERIFY(anim->isPlaying()); + if (paused) { + QTRY_VERIFY(anim->isPaused()); + QCOMPARE(anim->currentFrame(), 2); + } + QVERIFY(anim->status() != QQuickAnimatedImage::Error); + + delete anim; +} + +void tst_qquickanimatedimage::sourceSize() +{ + QQmlEngine engine; + QQmlComponent component(&engine, testFileUrl("stickmanscaled.qml")); + QQuickAnimatedImage *anim = qobject_cast(component.create()); + QVERIFY(anim); + QCOMPARE(anim->width(),240.0); + QCOMPARE(anim->height(),180.0); + QCOMPARE(anim->sourceSize(),QSize(160,120)); + + delete anim; +} + +void tst_qquickanimatedimage::sourceSizeReadOnly() +{ + QQmlEngine engine; + QQmlComponent component(&engine, testFileUrl("stickmanerror1.qml")); + QVERIFY(component.isError()); + QCOMPARE(component.errors().at(0).description(), QString("Invalid property assignment: \"sourceSize\" is a read-only property")); +} + +void tst_qquickanimatedimage::remote_data() +{ + QTest::addColumn("fileName"); + QTest::addColumn("paused"); + + QTest::newRow("playing") << "stickman.qml" << false; + QTest::newRow("paused") << "stickmanpause.qml" << true; +} + +void tst_qquickanimatedimage::invalidSource() +{ + QQmlEngine engine; + QQmlComponent component(&engine); + component.setData("import QtQuick 2.0\n AnimatedImage { source: \"no-such-file.gif\" }", QUrl::fromLocalFile("")); + QVERIFY(component.isReady()); + + QTest::ignoreMessage(QtWarningMsg, "file::2:2: QML AnimatedImage: Error Reading Animated Image File file:no-such-file.gif"); + + QQuickAnimatedImage *anim = qobject_cast(component.create()); + QVERIFY(anim); + + QVERIFY(!anim->isPlaying()); + QVERIFY(!anim->isPaused()); + QCOMPARE(anim->currentFrame(), 0); + QCOMPARE(anim->frameCount(), 0); + QTRY_VERIFY(anim->status() == 3); +} + +void tst_qquickanimatedimage::qtbug_16520() +{ + TestHTTPServer server(14449); + QVERIFY(server.isValid()); + server.serveDirectory(dataDirectory()); + + QQmlEngine engine; + QQmlComponent component(&engine, testFileUrl("qtbug-16520.qml")); + QTRY_VERIFY(component.isReady()); + + QQuickRectangle *root = qobject_cast(component.create()); + QVERIFY(root); + QQuickAnimatedImage *anim = root->findChild("anim"); + + anim->setProperty("source", "http://127.0.0.1:14449/stickman.gif"); + + QTRY_VERIFY(anim->opacity() == 0); + QTRY_VERIFY(anim->opacity() == 1); + + delete anim; +} + +void tst_qquickanimatedimage::progressAndStatusChanges() +{ + TestHTTPServer server(14449); + QVERIFY(server.isValid()); + server.serveDirectory(dataDirectory()); + + QQmlEngine engine; + QString componentStr = "import QtQuick 2.0\nAnimatedImage { source: srcImage }"; + QQmlContext *ctxt = engine.rootContext(); + ctxt->setContextProperty("srcImage", testFileUrl("stickman.gif")); + QQmlComponent component(&engine); + component.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); + QQuickImage *obj = qobject_cast(component.create()); + QVERIFY(obj != 0); + QVERIFY(obj->status() == QQuickImage::Ready); + QTRY_VERIFY(obj->progress() == 1.0); + + qRegisterMetaType(); + QSignalSpy sourceSpy(obj, SIGNAL(sourceChanged(const QUrl &))); + QSignalSpy progressSpy(obj, SIGNAL(progressChanged(qreal))); + QSignalSpy statusSpy(obj, SIGNAL(statusChanged(QQuickImageBase::Status))); + + // Loading local file + ctxt->setContextProperty("srcImage", testFileUrl("colors.gif")); + QTRY_VERIFY(obj->status() == QQuickImage::Ready); + QTRY_VERIFY(obj->progress() == 1.0); + QTRY_COMPARE(sourceSpy.count(), 1); + QTRY_COMPARE(progressSpy.count(), 0); + QTRY_COMPARE(statusSpy.count(), 0); + + // Loading remote file + ctxt->setContextProperty("srcImage", "http://127.0.0.1:14449/stickman.gif"); + QTRY_VERIFY(obj->status() == QQuickImage::Loading); + QTRY_VERIFY(obj->progress() == 0.0); + QTRY_VERIFY(obj->status() == QQuickImage::Ready); + QTRY_VERIFY(obj->progress() == 1.0); + QTRY_COMPARE(sourceSpy.count(), 2); + QTRY_VERIFY(progressSpy.count() > 1); + QTRY_COMPARE(statusSpy.count(), 2); + + ctxt->setContextProperty("srcImage", ""); + QTRY_VERIFY(obj->status() == QQuickImage::Null); + QTRY_VERIFY(obj->progress() == 0.0); + QTRY_COMPARE(sourceSpy.count(), 3); + QTRY_VERIFY(progressSpy.count() > 2); + QTRY_COMPARE(statusSpy.count(), 3); +} + +QTEST_MAIN(tst_qquickanimatedimage) + +#include "tst_qquickanimatedimage.moc" diff --git a/tests/auto/quick/qquickanimationcontroller/data/tst_numberanimation.qml b/tests/auto/quick/qquickanimationcontroller/data/tst_numberanimation.qml new file mode 100644 index 0000000000..7c4496b206 --- /dev/null +++ b/tests/auto/quick/qquickanimationcontroller/data/tst_numberanimation.qml @@ -0,0 +1,38 @@ +import QtQuick 2.0 +import QtTest 1.0 + +Rectangle { + id:container + width:50 + height:50 + + Rectangle {id:rect; x:0; y:0; color:"red"; width:10; height:10} + AnimationController { + id:numberAnimationcontroller + progress:1 + animation: NumberAnimation {target: rect; property: "x"; from:0; to:40; duration: 1000} + } + + TestCase { + name:"AnimationController" + when:windowShown + function test_numberAnimation() { + numberAnimationcontroller.progress = 0; + compare(rect.x, 0); + numberAnimationcontroller.progress = 0.5; + compare(rect.x, 20); + + // <=0 -> 0 + numberAnimationcontroller.progress = -1; + compare(rect.x, 0); + + //>=1 -> 1 + numberAnimationcontroller.progress = 1.1; + compare(rect.x, 40); + + //make sure the progress can be set backward + numberAnimationcontroller.progress = 0.5; + compare(rect.x, 20); + } + } +} \ No newline at end of file diff --git a/tests/auto/quick/qquickanimationcontroller/qquickanimationcontroller.pro b/tests/auto/quick/qquickanimationcontroller/qquickanimationcontroller.pro new file mode 100644 index 0000000000..72a09fcb9c --- /dev/null +++ b/tests/auto/quick/qquickanimationcontroller/qquickanimationcontroller.pro @@ -0,0 +1,10 @@ +QT += core-private gui-private qml-private +TEMPLATE=app +TARGET=tst_qquickanimationcontroller + +CONFIG += warn_on qmltestcase +SOURCES += tst_qquickanimationcontroller.cpp + +importFiles.files = data +importFiles.path = . +DEPLOYMENT += importFiles diff --git a/tests/auto/quick/qquickanimationcontroller/tst_qquickanimationcontroller.cpp b/tests/auto/quick/qquickanimationcontroller/tst_qquickanimationcontroller.cpp new file mode 100644 index 0000000000..8c851bcf65 --- /dev/null +++ b/tests/auto/quick/qquickanimationcontroller/tst_qquickanimationcontroller.cpp @@ -0,0 +1,42 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include +QUICK_TEST_MAIN(qquickanimationcontroller) diff --git a/tests/auto/quick/qquickanimations/data/Double.qml b/tests/auto/quick/qquickanimations/data/Double.qml new file mode 100644 index 0000000000..99ffca1d62 --- /dev/null +++ b/tests/auto/quick/qquickanimations/data/Double.qml @@ -0,0 +1,14 @@ +import QtQuick 2.0 + +Rectangle { + id: container + property bool on: false + border.color: "#ffffff" + color: "green" + width: 50 + height: 50 + NumberAnimation on x { + objectName: "animation" + running: container.on; from: 0; to: 600; loops: Animation.Infinite; duration: 2000 + } +} diff --git a/tests/auto/quick/qquickanimations/data/attached.qml b/tests/auto/quick/qquickanimations/data/attached.qml new file mode 100644 index 0000000000..9dcfcd8752 --- /dev/null +++ b/tests/auto/quick/qquickanimations/data/attached.qml @@ -0,0 +1,34 @@ +import QtQuick 2.0 + +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(wrapper.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/quick/qquickanimations/data/badproperty1.qml b/tests/auto/quick/qquickanimations/data/badproperty1.qml new file mode 100644 index 0000000000..9634c2c169 --- /dev/null +++ b/tests/auto/quick/qquickanimations/data/badproperty1.qml @@ -0,0 +1,21 @@ +import QtQuick 2.0 + +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/quick/qquickanimations/data/badproperty2.qml b/tests/auto/quick/qquickanimations/data/badproperty2.qml new file mode 100644 index 0000000000..c121172a99 --- /dev/null +++ b/tests/auto/quick/qquickanimations/data/badproperty2.qml @@ -0,0 +1,21 @@ +import QtQuick 2.0 + +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/quick/qquickanimations/data/badtype1.qml b/tests/auto/quick/qquickanimations/data/badtype1.qml new file mode 100644 index 0000000000..43e1ec8572 --- /dev/null +++ b/tests/auto/quick/qquickanimations/data/badtype1.qml @@ -0,0 +1,12 @@ +import QtQuick 2.0 + +Rectangle { + width: 240 + height: 320 + Rectangle { + color: "red" + width: 50; height: 50 + x: 100; y: 100 + PropertyAnimation on x { from: "blue"; to: "green"; } + } +} diff --git a/tests/auto/quick/qquickanimations/data/badtype2.qml b/tests/auto/quick/qquickanimations/data/badtype2.qml new file mode 100644 index 0000000000..5341cb3d1c --- /dev/null +++ b/tests/auto/quick/qquickanimations/data/badtype2.qml @@ -0,0 +1,12 @@ +import QtQuick 2.0 + +Rectangle { + width: 240 + height: 320 + Rectangle { + color: "red" + width: 50; height: 50 + x: 100; y: 100 + NumberAnimation on x { from: "blue"; to: "green"; } + } +} diff --git a/tests/auto/quick/qquickanimations/data/badtype3.qml b/tests/auto/quick/qquickanimations/data/badtype3.qml new file mode 100644 index 0000000000..182efa0840 --- /dev/null +++ b/tests/auto/quick/qquickanimations/data/badtype3.qml @@ -0,0 +1,12 @@ +import QtQuick 2.0 + +Rectangle { + width: 240 + height: 320 + Rectangle { + color: "red" + ColorAnimation on color { from: 10; to: 15; } + width: 50; height: 50 + x: 100; y: 100 + } +} diff --git a/tests/auto/quick/qquickanimations/data/badtype4.qml b/tests/auto/quick/qquickanimations/data/badtype4.qml new file mode 100644 index 0000000000..f091e2430f --- /dev/null +++ b/tests/auto/quick/qquickanimations/data/badtype4.qml @@ -0,0 +1,27 @@ +import QtQuick 2.0 + +Rectangle { + id: wrapper + width: 240 + height: 320 + Rectangle { + id: myRect + objectName: "MyRect" + color: "red" + width: 50; height: 50 + x: 100; y: 100 + MouseArea { + 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 { properties: "x,color"; duration: 1000 } //x is real, color is color + NumberAnimation { properties: "x,color"; duration: 1000 } //x is real, color is color + } +} diff --git a/tests/auto/quick/qquickanimations/data/disabledTransition.qml b/tests/auto/quick/qquickanimations/data/disabledTransition.qml new file mode 100644 index 0000000000..0fbafead8b --- /dev/null +++ b/tests/auto/quick/qquickanimations/data/disabledTransition.qml @@ -0,0 +1,30 @@ +import QtQuick 2.0 + +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 { + enabled: false + NumberAnimation { targets: theRect; properties: "x" } + } + + MouseArea { + anchors.fill: parent + onClicked: parent.state = "moved" + } +} diff --git a/tests/auto/quick/qquickanimations/data/dontAutoStart.qml b/tests/auto/quick/qquickanimations/data/dontAutoStart.qml new file mode 100644 index 0000000000..c0c0c65e3f --- /dev/null +++ b/tests/auto/quick/qquickanimations/data/dontAutoStart.qml @@ -0,0 +1,18 @@ +import QtQuick 2.0 + +Rectangle { + id: wrapper + width: 600 + height: 400 + + Rectangle { + id: redRect + width: 100; height: 100 + color: Qt.rgba(1,0,0) + Behavior on x { + NumberAnimation { id: myAnim; objectName: "MyAnim"; target: redRect; property: "y"; to: 300; loops: Animation.Infinite} + } + + } + +} diff --git a/tests/auto/quick/qquickanimations/data/dontStart.qml b/tests/auto/quick/qquickanimations/data/dontStart.qml new file mode 100644 index 0000000000..3eee0cfd35 --- /dev/null +++ b/tests/auto/quick/qquickanimations/data/dontStart.qml @@ -0,0 +1,19 @@ +import QtQuick 2.0 + +Rectangle { + id: wrapper + width: 600 + height: 400 + + Rectangle { + id: redRect + width: 100; height: 100 + color: Qt.rgba(1,0,0) + SequentialAnimation on x { + running: false + NumberAnimation { objectName: "MyAnim"; running: true } + } + + } + +} diff --git a/tests/auto/quick/qquickanimations/data/dontStart2.qml b/tests/auto/quick/qquickanimations/data/dontStart2.qml new file mode 100644 index 0000000000..e7b4164e4e --- /dev/null +++ b/tests/auto/quick/qquickanimations/data/dontStart2.qml @@ -0,0 +1,19 @@ +import QtQuick 2.0 + +Rectangle { + id: wrapper + width: 600 + height: 400 + + Rectangle { + id: redRect + width: 100; height: 100 + color: Qt.rgba(1,0,0) + + transitions: Transition { + SequentialAnimation { + NumberAnimation { id: myAnim; objectName: "MyAnim"; running: true } + } + } + } +} diff --git a/tests/auto/quick/qquickanimations/data/dotproperty.qml b/tests/auto/quick/qquickanimations/data/dotproperty.qml new file mode 100644 index 0000000000..e0e46dcef5 --- /dev/null +++ b/tests/auto/quick/qquickanimations/data/dotproperty.qml @@ -0,0 +1,24 @@ +import QtQuick 2.0 + +Rectangle { + id: wrapper + width: 240 + height: 320 + Rectangle { + id: myRect + color: "red" + width: 50; height: 50 + x: 100; y: 100 + MouseArea { + 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 { properties: "border.color"; duration: 1000 } + } +} diff --git a/tests/auto/quick/qquickanimations/data/doubleRegistrationBug.qml b/tests/auto/quick/qquickanimations/data/doubleRegistrationBug.qml new file mode 100644 index 0000000000..9ef3da20c0 --- /dev/null +++ b/tests/auto/quick/qquickanimations/data/doubleRegistrationBug.qml @@ -0,0 +1,8 @@ +import QtQuick 2.0 + +Rectangle { + width: 400; height: 400 + + Double { id: dub; on: parent.width < 800 } + Component.onCompleted: dub.on = false +} diff --git a/tests/auto/quick/qquickanimations/data/looping.qml b/tests/auto/quick/qquickanimations/data/looping.qml new file mode 100644 index 0000000000..a3d40ae837 --- /dev/null +++ b/tests/auto/quick/qquickanimations/data/looping.qml @@ -0,0 +1,16 @@ +import QtQuick 2.0 + +Item { + width: 200; height: 200 + + Rectangle { + x: 50; y: 50; width: 50; height: 50; color: "red" + + SequentialAnimation on rotation { + NumberAnimation { + from: 0; to: 90; duration: 100 + loops: 3 + } + } + } +} diff --git a/tests/auto/quick/qquickanimations/data/mixedtype1.qml b/tests/auto/quick/qquickanimations/data/mixedtype1.qml new file mode 100644 index 0000000000..76129dd15e --- /dev/null +++ b/tests/auto/quick/qquickanimations/data/mixedtype1.qml @@ -0,0 +1,25 @@ +import QtQuick 2.0 + +Rectangle { + id: wrapper + width: 240 + height: 320 + Rectangle { + id: myRect + objectName: "MyRect" + color: "red" + width: 50; height: 50 + x: 100; y: 100 + MouseArea { + 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 { properties: "x,border.width"; duration: 1000 } //x is real, border.width is int + } +} diff --git a/tests/auto/quick/qquickanimations/data/mixedtype2.qml b/tests/auto/quick/qquickanimations/data/mixedtype2.qml new file mode 100644 index 0000000000..1a7166e3f3 --- /dev/null +++ b/tests/auto/quick/qquickanimations/data/mixedtype2.qml @@ -0,0 +1,25 @@ +import QtQuick 2.0 + +Rectangle { + id: wrapper + width: 240 + height: 320 + Rectangle { + id: myRect + objectName: "MyRect" + color: "red" + width: 50; height: 50 + x: 100; y: 100 + MouseArea { + 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 { properties: "x,color"; duration: 1000 } //x is real, color is color + } +} diff --git a/tests/auto/quick/qquickanimations/data/nonTransitionBug.qml b/tests/auto/quick/qquickanimations/data/nonTransitionBug.qml new file mode 100644 index 0000000000..909c533e7b --- /dev/null +++ b/tests/auto/quick/qquickanimations/data/nonTransitionBug.qml @@ -0,0 +1,30 @@ +import QtQuick 2.0 + +Rectangle { + id: root + width: 200 + height: 200 + + Rectangle { + id: mover + objectName: "mover" + } + + states: [ + State { + name: "free" + }, + State { + name: "left" + PropertyChanges { + restoreEntryValues: false + target: mover + x: 0 + } + } + ] + + transitions: Transition { + PropertyAnimation { properties: "x"; duration: 50 } + } +} diff --git a/tests/auto/quick/qquickanimations/data/pathAnimation.qml b/tests/auto/quick/qquickanimations/data/pathAnimation.qml new file mode 100644 index 0000000000..d2006a1c6a --- /dev/null +++ b/tests/auto/quick/qquickanimations/data/pathAnimation.qml @@ -0,0 +1,27 @@ +import QtQuick 2.0 + +Rectangle { + width: 400 + height: 400 + + Rectangle { + id: redRect + color: "red" + width: 100; height: 100 + x: 50; y: 50 + } + + PathAnimation { + target: redRect + duration: 100; + path: Path { + startX: 50; startY: 50 + PathCubic { + x: 300; y: 300 + + control1X: 300; control1Y: 50 + control2X: 50; control2Y: 300 + } + } + } +} diff --git a/tests/auto/quick/qquickanimations/data/pathAnimation2.qml b/tests/auto/quick/qquickanimations/data/pathAnimation2.qml new file mode 100644 index 0000000000..2f64dac2cc --- /dev/null +++ b/tests/auto/quick/qquickanimations/data/pathAnimation2.qml @@ -0,0 +1,26 @@ +import QtQuick 2.0 + +Rectangle { + width: 400 + height: 400 + + Rectangle { + id: redRect + color: "red" + width: 100; height: 100 + x: 50; y: 50 + } + + PathAnimation { + target: redRect + duration: 100; + endRotation: 0 + orientationEntryDuration: 10 + orientationExitDuration: 10 + orientation: PathAnimation.RightFirst + path: Path { + startX: 50; startY: 50 + PathLine { x: 300; y: 300 } + } + } +} diff --git a/tests/auto/quick/qquickanimations/data/pathAnimationNoStart.qml b/tests/auto/quick/qquickanimations/data/pathAnimationNoStart.qml new file mode 100644 index 0000000000..be3501fabb --- /dev/null +++ b/tests/auto/quick/qquickanimations/data/pathAnimationNoStart.qml @@ -0,0 +1,27 @@ +import QtQuick 2.0 + +Rectangle { + width: 400 + height: 400 + + Rectangle { + id: redRect + color: "red" + width: 100; height: 100 + x: 50; y: 50 + } + + PathAnimation { + target: redRect + duration: 100; + path: Path { + //no startX/Y defined (should automatically start from redRects pos) + PathCubic { + x: 300; y: 300 + + control1X: 300; control1Y: 50 + control2X: 50; control2Y: 300 + } + } + } +} diff --git a/tests/auto/quick/qquickanimations/data/pathInterpolator.qml b/tests/auto/quick/qquickanimations/data/pathInterpolator.qml new file mode 100644 index 0000000000..0104412d7c --- /dev/null +++ b/tests/auto/quick/qquickanimations/data/pathInterpolator.qml @@ -0,0 +1,13 @@ +import QtQuick 2.0 + +PathInterpolator { + path: Path { + startX: 50; startY: 50 + PathCubic { + x: 300; y: 300 + + control1X: 300; control1Y: 50 + control2X: 50; control2Y: 300 + } + } +} diff --git a/tests/auto/quick/qquickanimations/data/pathInterpolatorBack.qml b/tests/auto/quick/qquickanimations/data/pathInterpolatorBack.qml new file mode 100644 index 0000000000..41366ef798 --- /dev/null +++ b/tests/auto/quick/qquickanimations/data/pathInterpolatorBack.qml @@ -0,0 +1,11 @@ +import QtQuick 2.0 + +PathInterpolator { + path: Path { + startX: 50; startY: 50 + PathLine { x: 50; y: 100 } + PathLine { x: 100; y: 100 } + PathLine { x: 100; y: 50 } + PathLine { x: 200; y: 50 } + } +} diff --git a/tests/auto/quick/qquickanimations/data/pathInterpolatorBack2.qml b/tests/auto/quick/qquickanimations/data/pathInterpolatorBack2.qml new file mode 100644 index 0000000000..eb3d4c3f86 --- /dev/null +++ b/tests/auto/quick/qquickanimations/data/pathInterpolatorBack2.qml @@ -0,0 +1,10 @@ +import QtQuick 2.0 + +PathInterpolator { + path: Path { + startX: 200; startY: 280 + PathCurve { x: 150; y: 280 } + PathCurve { x: 150; y: 80 } + PathCurve { x: 0; y: 80 } + } +} diff --git a/tests/auto/quick/qquickanimations/data/pathTransition.qml b/tests/auto/quick/qquickanimations/data/pathTransition.qml new file mode 100644 index 0000000000..55ffc33f95 --- /dev/null +++ b/tests/auto/quick/qquickanimations/data/pathTransition.qml @@ -0,0 +1,41 @@ +import QtQuick 2.0 + +Rectangle { + width: 800 + height: 800 + + Rectangle { + id: redRect; objectName: "redRect" + color: "red" + width: 50; height: 50 + x: 500; y: 50 + } + + states: State { + name: "moved" + PropertyChanges { + target: redRect + x: 100; y: 700 + } + } + + transitions: Transition { + to: "moved"; reversible: true + PathAnimation { + id: pathAnim + target: redRect + duration: 300 + path: Path { + PathCurve { x: 100; y: 100 } + PathCurve { x: 200; y: 350 } + PathCurve { x: 600; y: 500 } + PathCurve {} + } + } + } + + MouseArea { + anchors.fill: parent + onClicked: parent.state = parent.state == "moved" ? "" : "moved" + } +} diff --git a/tests/auto/quick/qquickanimations/data/pauseBindingBug.qml b/tests/auto/quick/qquickanimations/data/pauseBindingBug.qml new file mode 100644 index 0000000000..359cda166f --- /dev/null +++ b/tests/auto/quick/qquickanimations/data/pauseBindingBug.qml @@ -0,0 +1,17 @@ +import QtQuick 2.0 + +Rectangle { + id: rect + width: 200 + height: 200 + + property bool animating: false + property int value: 0 + + NumberAnimation on value { + objectName: "animation" + paused: !rect.animating + to: 100 + duration: 50 + } +} diff --git a/tests/auto/quick/qquickanimations/data/pauseBug.qml b/tests/auto/quick/qquickanimations/data/pauseBug.qml new file mode 100644 index 0000000000..fa2c4be4ba --- /dev/null +++ b/tests/auto/quick/qquickanimations/data/pauseBug.qml @@ -0,0 +1,7 @@ +import QtQuick 2.0 + +SequentialAnimation { + id: animation + running: true + ScriptAction { script: animation.paused = true } +} diff --git a/tests/auto/quick/qquickanimations/data/properties.qml b/tests/auto/quick/qquickanimations/data/properties.qml new file mode 100644 index 0000000000..f0f730967c --- /dev/null +++ b/tests/auto/quick/qquickanimations/data/properties.qml @@ -0,0 +1,14 @@ +import QtQuick 2.0 + +Rectangle { + width: 400 + height: 400 + Rectangle { + id: theRect + objectName: "TheRect" + color: "red" + width: 50; height: 50 + x: 100; y: 100 + NumberAnimation on x { to: 200 } + } +} diff --git a/tests/auto/quick/qquickanimations/data/properties2.qml b/tests/auto/quick/qquickanimations/data/properties2.qml new file mode 100644 index 0000000000..6b7f026e0b --- /dev/null +++ b/tests/auto/quick/qquickanimations/data/properties2.qml @@ -0,0 +1,14 @@ +import QtQuick 2.0 + +Rectangle { + width: 400 + height: 400 + Rectangle { + id: theRect + objectName: "TheRect" + color: "red" + width: 50; height: 50 + x: 100; y: 100 + NumberAnimation on x { targets: theRect; properties: "x"; to: 200; } + } +} diff --git a/tests/auto/quick/qquickanimations/data/properties3.qml b/tests/auto/quick/qquickanimations/data/properties3.qml new file mode 100644 index 0000000000..5eb65496d4 --- /dev/null +++ b/tests/auto/quick/qquickanimations/data/properties3.qml @@ -0,0 +1,14 @@ +import QtQuick 2.0 + +Rectangle { + width: 400 + height: 400 + Rectangle { + id: theRect + objectName: "TheRect" + color: "red" + width: 50; height: 50 + x: 100; y: 100 + NumberAnimation on x { target: theRect; property: "x"; to: 300; } + } +} diff --git a/tests/auto/quick/qquickanimations/data/properties4.qml b/tests/auto/quick/qquickanimations/data/properties4.qml new file mode 100644 index 0000000000..dfe8ad17e7 --- /dev/null +++ b/tests/auto/quick/qquickanimations/data/properties4.qml @@ -0,0 +1,14 @@ +import QtQuick 2.0 + +Rectangle { + width: 400 + height: 400 + Rectangle { + id: theRect + objectName: "TheRect" + color: "red" + width: 50; height: 50 + x: 100; y: 100 + NumberAnimation on x { target: theRect; property: "y"; to: 200; } + } +} diff --git a/tests/auto/quick/qquickanimations/data/properties5.qml b/tests/auto/quick/qquickanimations/data/properties5.qml new file mode 100644 index 0000000000..075fc9bc5a --- /dev/null +++ b/tests/auto/quick/qquickanimations/data/properties5.qml @@ -0,0 +1,14 @@ +import QtQuick 2.0 + +Rectangle { + width: 400 + height: 400 + Rectangle { + id: theRect + objectName: "TheRect" + color: "red" + width: 50; height: 50 + x: 100; y: 100 + NumberAnimation on x { targets: theRect; properties: "y"; to: 200; } + } +} diff --git a/tests/auto/quick/qquickanimations/data/propertiesTransition.qml b/tests/auto/quick/qquickanimations/data/propertiesTransition.qml new file mode 100644 index 0000000000..968c5f6285 --- /dev/null +++ b/tests/auto/quick/qquickanimations/data/propertiesTransition.qml @@ -0,0 +1,29 @@ +import QtQuick 2.0 + +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 { targets: theRect; properties: "x" } + } + + MouseArea { + anchors.fill: parent + onClicked: parent.state = "moved" + } +} diff --git a/tests/auto/quick/qquickanimations/data/propertiesTransition2.qml b/tests/auto/quick/qquickanimations/data/propertiesTransition2.qml new file mode 100644 index 0000000000..f06165604a --- /dev/null +++ b/tests/auto/quick/qquickanimations/data/propertiesTransition2.qml @@ -0,0 +1,29 @@ +import QtQuick 2.0 + +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 } + } + + MouseArea { + anchors.fill: parent + onClicked: parent.state = "moved" + } +} diff --git a/tests/auto/quick/qquickanimations/data/propertiesTransition3.qml b/tests/auto/quick/qquickanimations/data/propertiesTransition3.qml new file mode 100644 index 0000000000..7d3b3b9c6d --- /dev/null +++ b/tests/auto/quick/qquickanimations/data/propertiesTransition3.qml @@ -0,0 +1,29 @@ +import QtQuick 2.0 + +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 { targets: theRect; properties: "y" } + } + + MouseArea { + anchors.fill: parent + onClicked: parent.state = "moved" + } +} diff --git a/tests/auto/quick/qquickanimations/data/propertiesTransition4.qml b/tests/auto/quick/qquickanimations/data/propertiesTransition4.qml new file mode 100644 index 0000000000..1c31a79634 --- /dev/null +++ b/tests/auto/quick/qquickanimations/data/propertiesTransition4.qml @@ -0,0 +1,29 @@ +import QtQuick 2.0 + +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; properties: "x" } + } + + MouseArea { + anchors.fill: parent + onClicked: parent.state = "moved" + } +} diff --git a/tests/auto/quick/qquickanimations/data/propertiesTransition5.qml b/tests/auto/quick/qquickanimations/data/propertiesTransition5.qml new file mode 100644 index 0000000000..a2ff746900 --- /dev/null +++ b/tests/auto/quick/qquickanimations/data/propertiesTransition5.qml @@ -0,0 +1,29 @@ +import QtQuick 2.0 + +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 { targets: theRect; property: "x" } + } + + MouseArea { + anchors.fill: parent + onClicked: parent.state = "moved" + } +} diff --git a/tests/auto/quick/qquickanimations/data/propertiesTransition6.qml b/tests/auto/quick/qquickanimations/data/propertiesTransition6.qml new file mode 100644 index 0000000000..d3db01efb0 --- /dev/null +++ b/tests/auto/quick/qquickanimations/data/propertiesTransition6.qml @@ -0,0 +1,29 @@ +import QtQuick 2.0 + +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 { targets: theItem; properties: "x" } + } + + MouseArea { + anchors.fill: parent + onClicked: parent.state = "moved" + } +} diff --git a/tests/auto/quick/qquickanimations/data/propertiesTransition7.qml b/tests/auto/quick/qquickanimations/data/propertiesTransition7.qml new file mode 100644 index 0000000000..98898de8ef --- /dev/null +++ b/tests/auto/quick/qquickanimations/data/propertiesTransition7.qml @@ -0,0 +1,29 @@ +import QtQuick 2.0 + +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 { + SpringAnimation { targets: theRect; properties: "x"; velocity: 10000 } + } + + MouseArea { + anchors.fill: parent + onClicked: parent.state = "moved" + } +} diff --git a/tests/auto/quick/qquickanimations/data/reanchor.qml b/tests/auto/quick/qquickanimations/data/reanchor.qml new file mode 100644 index 0000000000..241cc81a96 --- /dev/null +++ b/tests/auto/quick/qquickanimations/data/reanchor.qml @@ -0,0 +1,46 @@ +import QtQuick 2.0 + +Rectangle { + id: container + width: 200; height: 200 + Rectangle { + id: myRect + color: "green"; + anchors.left: parent.left + anchors.right: rightGuideline.left + anchors.top: topGuideline.top + anchors.bottom: container.bottom + } + Item { id: leftGuideline; x: 10 } + Item { id: rightGuideline; x: 150 } + Item { id: topGuideline; y: 10 } + Item { id: bottomGuideline; y: 150 } + Item { id: topGuideline2; y: 50 } + Item { id: bottomGuideline2; y: 175 } + + states: [ State { + name: "reanchored" + AnchorChanges { + target: myRect; + anchors.left: leftGuideline.left + anchors.right: container.right + anchors.top: container.top + anchors.bottom: bottomGuideline.bottom + } + }, State { + name: "reanchored2" + AnchorChanges { + target: myRect; + anchors.left: undefined + anchors.right: undefined + anchors.top: topGuideline2.top + anchors.bottom: bottomGuideline2.bottom + } + }] + + transitions: Transition { + AnchorAnimation { } + } + + state: "reanchored" +} diff --git a/tests/auto/quick/qquickanimations/data/registrationBug.qml b/tests/auto/quick/qquickanimations/data/registrationBug.qml new file mode 100644 index 0000000000..633da4e17f --- /dev/null +++ b/tests/auto/quick/qquickanimations/data/registrationBug.qml @@ -0,0 +1,18 @@ +import QtQuick 2.0 + +Rectangle { + id: rect + width: 200 + height: 200 + + property bool animating: true + property int value: 0 + + NumberAnimation { + target: rect + property: "value" + running: rect.animating + to: 100 + duration: 50 + } +} diff --git a/tests/auto/quick/qquickanimations/data/reparent.qml b/tests/auto/quick/qquickanimations/data/reparent.qml new file mode 100644 index 0000000000..39f1e7a6d2 --- /dev/null +++ b/tests/auto/quick/qquickanimations/data/reparent.qml @@ -0,0 +1,56 @@ +import QtQuick 2.0 + +Rectangle { + width: 400; + height: 240; + color: "black"; + + Rectangle { + id: gr + objectName: "target" + color: "green" + width: 50; height: 50 + } + + Rectangle { + id: np + objectName: "newParent" + x: 150 + width: 150; height: 150 + color: "yellow" + clip: true + Rectangle { + color: "red" + x: 50; y: 50; height: 50; width: 50 + } + + } + + Rectangle { + id: vp + objectName: "viaParent" + x: 100; y: 100 + width: 50; height: 50 + color: "blue" + rotation: 45 + scale: 2 + } + + states: State { + name: "state1" + ParentChange { + target: gr + parent: np + x: 50; y: 50; width: 100; + } + } + + transitions: Transition { + reversible: true + to: "state1" + ParentAnimation { + target: gr; via: vp; + NumberAnimation { properties: "x,y,rotation,scale,width" } + } + } +} diff --git a/tests/auto/quick/qquickanimations/data/rotation.qml b/tests/auto/quick/qquickanimations/data/rotation.qml new file mode 100644 index 0000000000..4dc42a1bd2 --- /dev/null +++ b/tests/auto/quick/qquickanimations/data/rotation.qml @@ -0,0 +1,48 @@ +import QtQuick 2.0 + +Rectangle { + width: 600; height: 200 + + Row { + spacing: 5 + Rectangle { + id: rr + objectName: "rr" + color: "red" + width: 100; height: 100 + } + Rectangle { + id: rr2 + objectName: "rr2" + color: "red" + width: 100; height: 100 + } + Rectangle { + id: rr3 + objectName: "rr3" + color: "red" + width: 100; height: 100 + } + Rectangle { + id: rr4 + objectName: "rr4" + color: "red" + width: 100; height: 100 + } + } + + states: State { + name: "state1" + PropertyChanges { target: rr; rotation: 370 } + PropertyChanges { target: rr2; rotation: 370 } + PropertyChanges { target: rr3; rotation: 370 } + PropertyChanges { target: rr4; rotation: 370 } + } + + transitions: Transition { + RotationAnimation { target: rr; direction: RotationAnimation.Numerical; duration: 1000 } + RotationAnimation { target: rr2; direction: RotationAnimation.Clockwise; duration: 1000 } + RotationAnimation { target: rr3; direction: RotationAnimation.Counterclockwise; duration: 1000 } + RotationAnimation { target: rr4; direction: RotationAnimation.Shortest; duration: 1000 } + } +} diff --git a/tests/auto/quick/qquickanimations/data/runningTrueBug.qml b/tests/auto/quick/qquickanimations/data/runningTrueBug.qml new file mode 100644 index 0000000000..bec6fab368 --- /dev/null +++ b/tests/auto/quick/qquickanimations/data/runningTrueBug.qml @@ -0,0 +1,30 @@ +import QtQuick 2.0 +Rectangle { + color: "skyblue" + width: 500 + height: 200 + Rectangle { + objectName: "cloud" + color: "white" + y: 50 + width: 100 + height: 100 + + SequentialAnimation on x { + loops: Animation.Infinite + running: true + NumberAnimation { + id: firstAnimation + from: 0 + to: 500 + duration: 5000 + } + NumberAnimation { + id: secondAnimation + from: -100 + to: 0 + duration: 1000 + } + } + } +} diff --git a/tests/auto/quick/qquickanimations/data/transitionAssignmentBug.qml b/tests/auto/quick/qquickanimations/data/transitionAssignmentBug.qml new file mode 100644 index 0000000000..508693e0fc --- /dev/null +++ b/tests/auto/quick/qquickanimations/data/transitionAssignmentBug.qml @@ -0,0 +1,12 @@ +import QtQuick 2.0 + +Rectangle { + width: 400 + height: 400 + + property bool nullObject + Component.onCompleted: nullObject = transitions.length > 0 && transitions[0] === null + + property list myTransitions: [Transition {}, Transition {}] + transitions: myTransitions +} diff --git a/tests/auto/quick/qquickanimations/data/valuesource.qml b/tests/auto/quick/qquickanimations/data/valuesource.qml new file mode 100644 index 0000000000..7a636b4003 --- /dev/null +++ b/tests/auto/quick/qquickanimations/data/valuesource.qml @@ -0,0 +1,14 @@ +import QtQuick 2.0 + +Rectangle { + width: 400 + height: 400 + Rectangle { + id: rect + objectName: "MyRect" + color: "red" + width: 50; height: 50 + x: 100; y: 100 + NumberAnimation on x { id: anim; objectName: "MyAnim"; to: 200 } + } +} diff --git a/tests/auto/quick/qquickanimations/data/valuesource2.qml b/tests/auto/quick/qquickanimations/data/valuesource2.qml new file mode 100644 index 0000000000..9788761ee8 --- /dev/null +++ b/tests/auto/quick/qquickanimations/data/valuesource2.qml @@ -0,0 +1,14 @@ +import QtQuick 2.0 + +Rectangle { + width: 400 + height: 400 + Rectangle { + id: rect + objectName: "MyRect" + color: "red" + width: 50; height: 50 + x: 100; y: 100 + NumberAnimation on x { id: anim; objectName: "MyAnim"; running: false; to: 200 } + } +} diff --git a/tests/auto/quick/qquickanimations/qquickanimations.pro b/tests/auto/quick/qquickanimations/qquickanimations.pro new file mode 100644 index 0000000000..0e432ab9f1 --- /dev/null +++ b/tests/auto/quick/qquickanimations/qquickanimations.pro @@ -0,0 +1,18 @@ +CONFIG += testcase +TARGET = tst_qquickanimations +SOURCES += tst_qquickanimations.cpp + +include (../../shared/util.pri) + +macx:CONFIG -= app_bundle + +testDataFiles.files = data +testDataFiles.path = . +DEPLOYMENT += testDataFiles + +CONFIG += parallel_test + +QT += core-private gui-private v8-private qml-private quick-private opengl-private testlib + +# QTBUG-23385 - color mixing tests failing on Ubuntu 11.10 x64 +linux-*:system(". /etc/lsb-release && [ $DISTRIB_CODENAME = oneiric ]"):DEFINES+=UBUNTU_ONEIRIC diff --git a/tests/auto/quick/qquickanimations/tst_qquickanimations.cpp b/tests/auto/quick/qquickanimations/tst_qquickanimations.cpp new file mode 100644 index 0000000000..108bce64f9 --- /dev/null +++ b/tests/auto/quick/qquickanimations/tst_qquickanimations.cpp @@ -0,0 +1,1319 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#include "../../shared/util.h" + +class tst_qquickanimations : public QQmlDataTest +{ + Q_OBJECT +public: + tst_qquickanimations() {} + +private slots: + void initTestCase() + { + QQmlEngine engine; // ensure types are registered + QQmlDataTest::initTestCase(); + } + + void simpleProperty(); + void simpleNumber(); + void simpleColor(); + void simpleRotation(); + void simplePath(); + void simpleAnchor(); + void reparent(); + void pathInterpolator(); + void pathInterpolatorBackwardJump(); + void pathWithNoStart(); + void alwaysRunToEnd(); + void complete(); + void resume(); + void dotProperty(); + void badTypes(); + void badProperties(); + void mixedTypes(); + void properties(); + void propertiesTransition(); + void pathTransition(); + void disabledTransition(); + void invalidDuration(); + void attached(); + void propertyValueSourceDefaultStart(); + void dontStart(); + void easingProperties(); + void rotation(); + void runningTrueBug(); + void nonTransitionBug(); + void registrationBug(); + void doubleRegistrationBug(); + void alwaysRunToEndRestartBug(); + void transitionAssignmentBug(); + void pauseBindingBug(); + void pauseBug(); + void loopingBug(); +}; + +#define QTIMED_COMPARE(lhs, rhs) do { \ + for (int ii = 0; ii < 5; ++ii) { \ + if (lhs == rhs) \ + break; \ + QTest::qWait(50); \ + } \ + QCOMPARE(lhs, rhs); \ +} while (false) + +void tst_qquickanimations::simpleProperty() +{ + QQuickRectangle rect; + QQuickPropertyAnimation animation; + animation.setTargetObject(&rect); + animation.setProperty("x"); + animation.setTo(200); + QVERIFY(animation.target() == &rect); + QVERIFY(animation.property() == "x"); + QVERIFY(animation.to().toReal() == 200.0); + animation.start(); + QVERIFY(animation.isRunning()); + QTest::qWait(animation.duration()); + QTIMED_COMPARE(rect.x(), 200.0); + + rect.setPos(QPointF(0,0)); + animation.start(); + QVERIFY(animation.isRunning()); + animation.pause(); + QVERIFY(animation.isPaused()); + animation.setCurrentTime(125); + QVERIFY(animation.currentTime() == 125); + QCOMPARE(rect.x(),100.0); +} + +void tst_qquickanimations::simpleNumber() +{ + QQuickRectangle rect; + QQuickNumberAnimation animation; + animation.setTargetObject(&rect); + animation.setProperty("x"); + animation.setTo(200); + QVERIFY(animation.target() == &rect); + QVERIFY(animation.property() == "x"); + QVERIFY(animation.to() == 200); + animation.start(); + QVERIFY(animation.isRunning()); + QTest::qWait(animation.duration()); + QTIMED_COMPARE(rect.x(), qreal(200)); + + rect.setX(0); + animation.start(); + animation.pause(); + QVERIFY(animation.isRunning()); + QVERIFY(animation.isPaused()); + animation.setCurrentTime(125); + QVERIFY(animation.currentTime() == 125); + QCOMPARE(rect.x(), qreal(100)); +} + +void tst_qquickanimations::simpleColor() +{ + QQuickRectangle rect; + QQuickColorAnimation animation; + animation.setTargetObject(&rect); + animation.setProperty("color"); + animation.setTo(QColor("red")); + QVERIFY(animation.target() == &rect); + QVERIFY(animation.property() == "color"); + QVERIFY(animation.to() == QColor("red")); + animation.start(); + QVERIFY(animation.isRunning()); + QTest::qWait(animation.duration()); + QTIMED_COMPARE(rect.color(), QColor("red")); + + rect.setColor(QColor("blue")); + animation.start(); + animation.pause(); + QVERIFY(animation.isRunning()); + QVERIFY(animation.isPaused()); + animation.setCurrentTime(125); + QVERIFY(animation.currentTime() == 125); +#if defined(UBUNTU_ONEIRIC) && defined(__x86_64__) + QEXPECT_FAIL("", "Fails on this platform - QTBUG-23385", Abort); +#endif + QCOMPARE(rect.color(), QColor::fromRgbF(0.498039, 0, 0.498039, 1)); + + rect.setColor(QColor("green")); + animation.setFrom(QColor("blue")); + QVERIFY(animation.from() == QColor("blue")); + animation.restart(); + QCOMPARE(rect.color(), QColor("blue")); + QVERIFY(animation.isRunning()); + animation.setCurrentTime(125); + QCOMPARE(rect.color(), QColor::fromRgbF(0.498039, 0, 0.498039, 1)); +} + +void tst_qquickanimations::simpleRotation() +{ + QQuickRectangle rect; + QQuickRotationAnimation animation; + animation.setTargetObject(&rect); + animation.setProperty("rotation"); + animation.setTo(270); + QVERIFY(animation.target() == &rect); + QVERIFY(animation.property() == "rotation"); + QVERIFY(animation.to() == 270); + QVERIFY(animation.direction() == QQuickRotationAnimation::Numerical); + animation.start(); + QVERIFY(animation.isRunning()); + QTest::qWait(animation.duration()); + QTIMED_COMPARE(rect.rotation(), qreal(270)); + + rect.setRotation(0); + animation.start(); + animation.pause(); + QVERIFY(animation.isRunning()); + QVERIFY(animation.isPaused()); + animation.setCurrentTime(125); + QVERIFY(animation.currentTime() == 125); + QCOMPARE(rect.rotation(), qreal(135)); +} + +void tst_qquickanimations::simplePath() +{ + { + QQmlEngine engine; + QQmlComponent c(&engine, testFileUrl("pathAnimation.qml")); + QQuickRectangle *rect = qobject_cast(c.create()); + QVERIFY(rect); + + QQuickRectangle *redRect = rect->findChild(); + QVERIFY(redRect); + QQuickPathAnimation *pathAnim = rect->findChild(); + QVERIFY(pathAnim); + + QCOMPARE(pathAnim->duration(), 100); + QCOMPARE(pathAnim->target(), redRect); + + pathAnim->start(); + pathAnim->pause(); + + pathAnim->setCurrentTime(30); + QCOMPARE(redRect->x(), qreal(167)); + QCOMPARE(redRect->y(), qreal(104)); + + pathAnim->setCurrentTime(100); + QCOMPARE(redRect->x(), qreal(300)); + QCOMPARE(redRect->y(), qreal(300)); + + //verify animation runs to end + pathAnim->start(); + QCOMPARE(redRect->x(), qreal(50)); + QCOMPARE(redRect->y(), qreal(50)); + QTRY_COMPARE(redRect->x(), qreal(300)); + QCOMPARE(redRect->y(), qreal(300)); + + pathAnim->setOrientation(QQuickPathAnimation::RightFirst); + QCOMPARE(pathAnim->orientation(), QQuickPathAnimation::RightFirst); + pathAnim->start(); + QTRY_VERIFY(redRect->rotation() != 0); + pathAnim->stop(); + + delete rect; + } + + { + QQmlEngine engine; + QQmlComponent c(&engine, testFileUrl("pathAnimation2.qml")); + QQuickRectangle *rect = qobject_cast(c.create()); + QVERIFY(rect); + + QQuickRectangle *redRect = rect->findChild(); + QVERIFY(redRect); + QQuickPathAnimation *pathAnim = rect->findChild(); + QVERIFY(pathAnim); + + QCOMPARE(pathAnim->orientation(), QQuickPathAnimation::RightFirst); + QCOMPARE(pathAnim->endRotation(), qreal(0)); + QCOMPARE(pathAnim->orientationEntryDuration(), 10); + QCOMPARE(pathAnim->orientationExitDuration(), 10); + + pathAnim->start(); + pathAnim->pause(); + QCOMPARE(redRect->x(), qreal(50)); + QCOMPARE(redRect->y(), qreal(50)); + QCOMPARE(redRect->rotation(), qreal(-360)); + + pathAnim->setCurrentTime(50); + QCOMPARE(redRect->x(), qreal(175)); + QCOMPARE(redRect->y(), qreal(175)); + QCOMPARE(redRect->rotation(), qreal(-315)); + + pathAnim->setCurrentTime(100); + QCOMPARE(redRect->x(), qreal(300)); + QCOMPARE(redRect->y(), qreal(300)); + QCOMPARE(redRect->rotation(), qreal(0)); + + delete rect; + } +} + +void tst_qquickanimations::simpleAnchor() +{ + QQmlEngine engine; + QQmlComponent c(&engine, testFileUrl("reanchor.qml")); + QQuickRectangle *rect = qobject_cast(c.create()); + QVERIFY(rect); + + QQuickRectangle *greenRect = rect->findChild(); + QVERIFY(greenRect); + + QCOMPARE(rect->state(), QLatin1String("reanchored")); + QCOMPARE(greenRect->x(), qreal(10)); + QCOMPARE(greenRect->y(), qreal(0)); + QCOMPARE(greenRect->width(), qreal(190)); + QCOMPARE(greenRect->height(), qreal(150)); + + rect->setState(""); + + //verify animation in progress + QTRY_VERIFY(greenRect->x() < 10 && greenRect->x() > 0); + QVERIFY(greenRect->y() > 0 && greenRect->y() < 10); + QVERIFY(greenRect->width() < 190 && greenRect->width() > 150); + QVERIFY(greenRect->height() > 150 && greenRect->height() < 190); + + //verify end state ("") + QTRY_COMPARE(greenRect->x(), qreal(0)); + QCOMPARE(greenRect->y(), qreal(10)); + QCOMPARE(greenRect->width(), qreal(150)); + QCOMPARE(greenRect->height(), qreal(190)); + + rect->setState("reanchored2"); + + //verify animation in progress + QTRY_VERIFY(greenRect->y() > 10 && greenRect->y() < 50); + QVERIFY(greenRect->height() > 125 && greenRect->height() < 190); + //NOTE: setting left/right anchors to undefined removes the anchors, but does not resize. + QCOMPARE(greenRect->x(), qreal(0)); + QCOMPARE(greenRect->width(), qreal(150)); + + //verify end state ("reanchored2") + QTRY_COMPARE(greenRect->y(), qreal(50)); + QCOMPARE(greenRect->height(), qreal(125)); + QCOMPARE(greenRect->x(), qreal(0)); + QCOMPARE(greenRect->width(), qreal(150)); + + rect->setState("reanchored"); + + //verify animation in progress + QTRY_VERIFY(greenRect->x() < 10 && greenRect->x() > 0); + QVERIFY(greenRect->y() > 0 && greenRect->y() < 50); + QVERIFY(greenRect->width() < 190 && greenRect->width() > 150); + QVERIFY(greenRect->height() > 125 && greenRect->height() < 150); + + //verify end state ("reanchored") + QTRY_COMPARE(greenRect->x(), qreal(10)); + QCOMPARE(greenRect->y(), qreal(0)); + QCOMPARE(greenRect->width(), qreal(190)); + QCOMPARE(greenRect->height(), qreal(150)); + + rect->setState("reanchored2"); + + //verify animation in progress + QTRY_VERIFY(greenRect->x() < 10 && greenRect->x() > 0); + QVERIFY(greenRect->y() > 0 && greenRect->y() < 50); + QVERIFY(greenRect->width() < 190 && greenRect->width() > 150); + QVERIFY(greenRect->height() > 125 && greenRect->height() < 150); + + //verify end state ("reanchored2") + QTRY_COMPARE(greenRect->x(), qreal(0)); + QCOMPARE(greenRect->y(), qreal(50)); + QCOMPARE(greenRect->width(), qreal(150)); + QCOMPARE(greenRect->height(), qreal(125)); + + delete rect; +} + +void tst_qquickanimations::reparent() +{ + QQmlEngine engine; + QQmlComponent c(&engine, testFileUrl("reparent.qml")); + QQuickRectangle *rect = qobject_cast(c.create()); + QVERIFY(rect); + + QQuickRectangle *target = rect->findChild("target"); + QVERIFY(target); + + QCOMPARE(target->parentItem(), rect); + QCOMPARE(target->x(), qreal(0)); + QCOMPARE(target->y(), qreal(0)); + QCOMPARE(target->width(), qreal(50)); + QCOMPARE(target->height(), qreal(50)); + QCOMPARE(target->rotation(), qreal(0)); + QCOMPARE(target->scale(), qreal(1)); + + rect->setState("state1"); + + QQuickRectangle *viaParent = rect->findChild("viaParent"); + QVERIFY(viaParent); + + QQuickRectangle *newParent = rect->findChild("newParent"); + QVERIFY(newParent); + + QTest::qWait(100); + + //animation in progress + QTRY_COMPARE(target->parentItem(), viaParent); + QVERIFY(target->x() > -100 && target->x() < 50); + QVERIFY(target->y() > -100 && target->y() < 50); + QVERIFY(target->width() > 50 && target->width() < 100); + QCOMPARE(target->height(), qreal(50)); + QCOMPARE(target->rotation(), qreal(-45)); + QCOMPARE(target->scale(), qreal(.5)); + + //end state + QTRY_COMPARE(target->parentItem(), newParent); + QCOMPARE(target->x(), qreal(50)); + QCOMPARE(target->y(), qreal(50)); + QCOMPARE(target->width(), qreal(100)); + QCOMPARE(target->height(), qreal(50)); + QCOMPARE(target->rotation(), qreal(0)); + QCOMPARE(target->scale(), qreal(1)); + + delete rect; +} + +void tst_qquickanimations::pathInterpolator() +{ + QQmlEngine engine; + QQmlComponent c(&engine, testFileUrl("pathInterpolator.qml")); + QQuickPathInterpolator *interpolator = qobject_cast(c.create()); + QVERIFY(interpolator); + + QCOMPARE(interpolator->progress(), qreal(0)); + QCOMPARE(interpolator->x(), qreal(50)); + QCOMPARE(interpolator->y(), qreal(50)); + QCOMPARE(interpolator->angle(), qreal(0)); + + interpolator->setProgress(.5); + QCOMPARE(interpolator->progress(), qreal(.5)); + QCOMPARE(interpolator->x(), qreal(175)); + QCOMPARE(interpolator->y(), qreal(175)); + QCOMPARE(interpolator->angle(), qreal(90)); + + interpolator->setProgress(1); + QCOMPARE(interpolator->progress(), qreal(1)); + QCOMPARE(interpolator->x(), qreal(300)); + QCOMPARE(interpolator->y(), qreal(300)); + QCOMPARE(interpolator->angle(), qreal(0)); +} + +void tst_qquickanimations::pathInterpolatorBackwardJump() +{ + { + QQmlEngine engine; + QQmlComponent c(&engine, testFileUrl("pathInterpolatorBack.qml")); + QQuickPathInterpolator *interpolator = qobject_cast(c.create()); + QVERIFY(interpolator); + + QCOMPARE(interpolator->progress(), qreal(0)); + QCOMPARE(interpolator->x(), qreal(50)); + QCOMPARE(interpolator->y(), qreal(50)); + QCOMPARE(interpolator->angle(), qreal(90)); + + interpolator->setProgress(.5); + QCOMPARE(interpolator->progress(), qreal(.5)); + QCOMPARE(interpolator->x(), qreal(100)); + QCOMPARE(interpolator->y(), qreal(75)); + QCOMPARE(interpolator->angle(), qreal(270)); + + interpolator->setProgress(1); + QCOMPARE(interpolator->progress(), qreal(1)); + QCOMPARE(interpolator->x(), qreal(200)); + QCOMPARE(interpolator->y(), qreal(50)); + QCOMPARE(interpolator->angle(), qreal(0)); + + //make sure we don't get caught in infinite loop here + interpolator->setProgress(0); + QCOMPARE(interpolator->progress(), qreal(0)); + QCOMPARE(interpolator->x(), qreal(50)); + QCOMPARE(interpolator->y(), qreal(50)); + QCOMPARE(interpolator->angle(), qreal(90)); + } + + { + QQmlEngine engine; + QQmlComponent c(&engine, testFileUrl("pathInterpolatorBack2.qml")); + QQuickPathInterpolator *interpolator = qobject_cast(c.create()); + QVERIFY(interpolator); + + QCOMPARE(interpolator->progress(), qreal(0)); + QCOMPARE(interpolator->x(), qreal(200)); + QCOMPARE(interpolator->y(), qreal(280)); + QCOMPARE(interpolator->angle(), qreal(180)); + + interpolator->setProgress(1); + QCOMPARE(interpolator->progress(), qreal(1)); + QCOMPARE(interpolator->x(), qreal(0)); + QCOMPARE(interpolator->y(), qreal(80)); + QCOMPARE(interpolator->angle(), qreal(180)); + + //make sure we don't get caught in infinite loop here + interpolator->setProgress(0); + QCOMPARE(interpolator->progress(), qreal(0)); + QCOMPARE(interpolator->x(), qreal(200)); + QCOMPARE(interpolator->y(), qreal(280)); + QCOMPARE(interpolator->angle(), qreal(180)); + } +} + +void tst_qquickanimations::pathWithNoStart() +{ + QQmlEngine engine; + QQmlComponent c(&engine, testFileUrl("pathAnimationNoStart.qml")); + QQuickRectangle *rect = qobject_cast(c.create()); + QVERIFY(rect); + + QQuickRectangle *redRect = rect->findChild(); + QVERIFY(redRect); + QQuickPathAnimation *pathAnim = rect->findChild(); + QVERIFY(pathAnim); + + pathAnim->start(); + pathAnim->pause(); + QCOMPARE(redRect->x(), qreal(50)); + QCOMPARE(redRect->y(), qreal(50)); + + pathAnim->setCurrentTime(50); + QCOMPARE(redRect->x(), qreal(175)); + QCOMPARE(redRect->y(), qreal(175)); + + pathAnim->setCurrentTime(100); + QCOMPARE(redRect->x(), qreal(300)); + QCOMPARE(redRect->y(), qreal(300)); + + redRect->setX(100); + redRect->setY(100); + pathAnim->start(); + QCOMPARE(redRect->x(), qreal(100)); + QCOMPARE(redRect->y(), qreal(100)); + QTRY_COMPARE(redRect->x(), qreal(300)); + QCOMPARE(redRect->y(), qreal(300)); +} + +void tst_qquickanimations::alwaysRunToEnd() +{ + QQuickRectangle rect; + QQuickPropertyAnimation animation; + animation.setTargetObject(&rect); + animation.setProperty("x"); + animation.setTo(200); + animation.setDuration(1000); + animation.setLoops(-1); + animation.setAlwaysRunToEnd(true); + QVERIFY(animation.loops() == -1); + QVERIFY(animation.alwaysRunToEnd() == true); + animation.start(); + QTest::qWait(1500); + animation.stop(); + QVERIFY(rect.x() != qreal(200)); + QTest::qWait(500); + QTIMED_COMPARE(rect.x(), qreal(200)); +} + +void tst_qquickanimations::complete() +{ + QQuickRectangle rect; + QQuickPropertyAnimation animation; + animation.setTargetObject(&rect); + animation.setProperty("x"); + animation.setFrom(1); + animation.setTo(200); + animation.setDuration(500); + QVERIFY(animation.from() == 1); + animation.start(); + QTest::qWait(50); + animation.stop(); + QVERIFY(rect.x() != qreal(200)); + animation.start(); + QTest::qWait(50); + QVERIFY(animation.isRunning()); + animation.complete(); + QCOMPARE(rect.x(), qreal(200)); +} + +void tst_qquickanimations::resume() +{ + QQuickRectangle rect; + QQuickPropertyAnimation animation; + animation.setTargetObject(&rect); + animation.setProperty("x"); + animation.setFrom(10); + animation.setTo(200); + animation.setDuration(1000); + QVERIFY(animation.from() == 10); + + animation.start(); + QTest::qWait(400); + animation.pause(); + qreal x = rect.x(); + QVERIFY(x != qreal(200) && x != qreal(10)); + QVERIFY(animation.isRunning()); + QVERIFY(animation.isPaused()); + + animation.resume(); + QVERIFY(animation.isRunning()); + QVERIFY(!animation.isPaused()); + QTest::qWait(400); + animation.stop(); + QVERIFY(rect.x() > x); +} + +void tst_qquickanimations::dotProperty() +{ + QQuickRectangle rect; + QQuickNumberAnimation animation; + animation.setTargetObject(&rect); + animation.setProperty("border.width"); + animation.setTo(10); + animation.start(); + QTest::qWait(animation.duration()+50); + QTIMED_COMPARE(rect.border()->width(), 10.0); + + rect.border()->setWidth(0); + animation.start(); + animation.pause(); + animation.setCurrentTime(125); + QVERIFY(animation.currentTime() == 125); + QCOMPARE(rect.border()->width(), 5.0); +} + +void tst_qquickanimations::badTypes() +{ + //don't crash + { + QQuickView *view = new QQuickView; + view->setSource(testFileUrl("badtype1.qml")); + + qApp->processEvents(); + + delete view; + } + + //make sure we get a compiler error + { + QQmlEngine engine; + QQmlComponent c(&engine, testFileUrl("badtype2.qml")); + QTest::ignoreMessage(QtWarningMsg, "QQmlComponent: Component is not ready"); + c.create(); + + QVERIFY(c.errors().count() == 1); + QCOMPARE(c.errors().at(0).description(), QLatin1String("Invalid property assignment: number expected")); + } + + //make sure we get a compiler error + { + QQmlEngine engine; + QQmlComponent c(&engine, testFileUrl("badtype3.qml")); + QTest::ignoreMessage(QtWarningMsg, "QQmlComponent: Component is not ready"); + c.create(); + + QVERIFY(c.errors().count() == 1); + QCOMPARE(c.errors().at(0).description(), QLatin1String("Invalid property assignment: color expected")); + } + + //don't crash + { + QQmlEngine engine; + QQmlComponent c(&engine, testFileUrl("badtype4.qml")); + QQuickRectangle *rect = qobject_cast(c.create()); + QVERIFY(rect); + + QQuickItemPrivate::get(rect)->setState("state1"); + QTest::qWait(1000 + 50); + QQuickRectangle *myRect = rect->findChild("MyRect"); + QVERIFY(myRect); + QCOMPARE(myRect->x(),qreal(200)); + } +} + +void tst_qquickanimations::badProperties() +{ + //make sure we get a runtime error + { + QQmlEngine engine; + + QQmlComponent c1(&engine, testFileUrl("badproperty1.qml")); + QByteArray message = testFileUrl("badproperty1.qml").toString().toUtf8() + ":18:9: QML ColorAnimation: Cannot animate non-existent property \"border.colr\""; + QTest::ignoreMessage(QtWarningMsg, message); + QQuickRectangle *rect = qobject_cast(c1.create()); + QVERIFY(rect); + + QQmlComponent c2(&engine, testFileUrl("badproperty2.qml")); + message = testFileUrl("badproperty2.qml").toString().toUtf8() + ":18:9: QML ColorAnimation: Cannot animate read-only property \"border\""; + QTest::ignoreMessage(QtWarningMsg, message); + rect = qobject_cast(c2.create()); + QVERIFY(rect); + + //### should we warn here are well? + //rect->setState("state1"); + } +} + +//test animating mixed types with property animation in a transition +//for example, int + real; color + real; etc +void tst_qquickanimations::mixedTypes() +{ + //assumes border.width stays a real -- not real robust + { + QQmlEngine engine; + QQmlComponent c(&engine, testFileUrl("mixedtype1.qml")); + QQuickRectangle *rect = qobject_cast(c.create()); + QVERIFY(rect); + + QQuickItemPrivate::get(rect)->setState("state1"); + QTest::qWait(500); + QQuickRectangle *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); + } + + { + QQmlEngine engine; + QQmlComponent c(&engine, testFileUrl("mixedtype2.qml")); + QQuickRectangle *rect = qobject_cast(c.create()); + QVERIFY(rect); + + QQuickItemPrivate::get(rect)->setState("state1"); + QTest::qWait(500); + QQuickRectangle *myRect = rect->findChild("MyRect"); + QVERIFY(myRect); + + //rather inexact -- is there a better way? + QVERIFY(myRect->x() > 100 && myRect->x() < 200); +#if defined(UBUNTU_ONEIRIC) && defined(__x86_64__) + QEXPECT_FAIL("", "Fails on this platform - QTBUG-23385", Continue); +#endif + QVERIFY(myRect->color() != QColor("red") && myRect->color() != QColor("blue")); + } +} + +void tst_qquickanimations::properties() +{ + const int waitDuration = 300; + { + QQmlEngine engine; + QQmlComponent c(&engine, testFileUrl("properties.qml")); + QQuickRectangle *rect = qobject_cast(c.create()); + QVERIFY(rect); + + QQuickRectangle *myRect = rect->findChild("TheRect"); + QVERIFY(myRect); + QTest::qWait(waitDuration); + QTIMED_COMPARE(myRect->x(),qreal(200)); + } + + { + QQmlEngine engine; + QQmlComponent c(&engine, testFileUrl("properties2.qml")); + QQuickRectangle *rect = qobject_cast(c.create()); + QVERIFY(rect); + + QQuickRectangle *myRect = rect->findChild("TheRect"); + QVERIFY(myRect); + QTest::qWait(waitDuration); + QTIMED_COMPARE(myRect->x(),qreal(200)); + } + + { + QQmlEngine engine; + QQmlComponent c(&engine, testFileUrl("properties3.qml")); + QQuickRectangle *rect = qobject_cast(c.create()); + QVERIFY(rect); + + QQuickRectangle *myRect = rect->findChild("TheRect"); + QVERIFY(myRect); + QTest::qWait(waitDuration); + QTIMED_COMPARE(myRect->x(),qreal(300)); + } + + { + QQmlEngine engine; + QQmlComponent c(&engine, testFileUrl("properties4.qml")); + QQuickRectangle *rect = qobject_cast(c.create()); + QVERIFY(rect); + + QQuickRectangle *myRect = rect->findChild("TheRect"); + QVERIFY(myRect); + QTest::qWait(waitDuration); + QTIMED_COMPARE(myRect->y(),qreal(200)); + QTIMED_COMPARE(myRect->x(),qreal(100)); + } + + { + QQmlEngine engine; + QQmlComponent c(&engine, testFileUrl("properties5.qml")); + QQuickRectangle *rect = qobject_cast(c.create()); + QVERIFY(rect); + + QQuickRectangle *myRect = rect->findChild("TheRect"); + QVERIFY(myRect); + QTest::qWait(waitDuration); + QTIMED_COMPARE(myRect->x(),qreal(100)); + QTIMED_COMPARE(myRect->y(),qreal(200)); + } +} + +void tst_qquickanimations::propertiesTransition() +{ + const int waitDuration = 300; + { + QQmlEngine engine; + QQmlComponent c(&engine, testFileUrl("propertiesTransition.qml")); + QQuickRectangle *rect = qobject_cast(c.create()); + QVERIFY(rect); + + QQuickItemPrivate::get(rect)->setState("moved"); + QQuickRectangle *myRect = rect->findChild("TheRect"); + QVERIFY(myRect); + QTest::qWait(waitDuration); + QTIMED_COMPARE(myRect->x(),qreal(200)); + } + + { + QQmlEngine engine; + QQmlComponent c(&engine, testFileUrl("propertiesTransition2.qml")); + QQuickRectangle *rect = qobject_cast(c.create()); + QVERIFY(rect); + + QQuickRectangle *myRect = rect->findChild("TheRect"); + QVERIFY(myRect); + QQuickItemPrivate::get(rect)->setState("moved"); + QCOMPARE(myRect->x(),qreal(200)); + QCOMPARE(myRect->y(),qreal(100)); + QTest::qWait(waitDuration); + QTIMED_COMPARE(myRect->y(),qreal(200)); + } + + { + QQmlEngine engine; + QQmlComponent c(&engine, testFileUrl("propertiesTransition3.qml")); + QQuickRectangle *rect = qobject_cast(c.create()); + QVERIFY(rect); + + QQuickRectangle *myRect = rect->findChild("TheRect"); + QVERIFY(myRect); + QQuickItemPrivate::get(rect)->setState("moved"); + QCOMPARE(myRect->x(),qreal(200)); + QCOMPARE(myRect->y(),qreal(100)); + } + + { + QQmlEngine engine; + QQmlComponent c(&engine, testFileUrl("propertiesTransition4.qml")); + QQuickRectangle *rect = qobject_cast(c.create()); + QVERIFY(rect); + + QQuickRectangle *myRect = rect->findChild("TheRect"); + QVERIFY(myRect); + QQuickItemPrivate::get(rect)->setState("moved"); + QCOMPARE(myRect->x(),qreal(100)); + QTest::qWait(waitDuration); + QTIMED_COMPARE(myRect->x(),qreal(200)); + } + + { + QQmlEngine engine; + QQmlComponent c(&engine, testFileUrl("propertiesTransition5.qml")); + QQuickRectangle *rect = qobject_cast(c.create()); + QVERIFY(rect); + + QQuickRectangle *myRect = rect->findChild("TheRect"); + QVERIFY(myRect); + QQuickItemPrivate::get(rect)->setState("moved"); + QCOMPARE(myRect->x(),qreal(100)); + QTest::qWait(waitDuration); + QTIMED_COMPARE(myRect->x(),qreal(200)); + } + + /*{ + QQmlEngine engine; + QQmlComponent c(&engine, testFileUrl("propertiesTransition6.qml")); + QQuickRectangle *rect = qobject_cast(c.create()); + QVERIFY(rect); + + QQuickRectangle *myRect = rect->findChild("TheRect"); + QVERIFY(myRect); + QQuickItemPrivate::get(rect)->setState("moved"); + QCOMPARE(myRect->x(),qreal(100)); + QTest::qWait(waitDuration); + QTIMED_COMPARE(myRect->x(),qreal(100)); + }*/ + + { + QQmlEngine engine; + QQmlComponent c(&engine, testFileUrl("propertiesTransition7.qml")); + QQuickRectangle *rect = qobject_cast(c.create()); + QVERIFY(rect); + + QQuickItemPrivate::get(rect)->setState("moved"); + QQuickRectangle *myRect = rect->findChild("TheRect"); + QVERIFY(myRect); + QTest::qWait(waitDuration); + QTIMED_COMPARE(myRect->x(),qreal(200)); + } + +} + +void tst_qquickanimations::pathTransition() +{ + QQmlEngine engine; + QQmlComponent c(&engine, testFileUrl("pathTransition.qml")); + QQuickRectangle *rect = qobject_cast(c.create()); + QVERIFY(rect); + + QQuickRectangle *myRect = rect->findChild("redRect"); + QVERIFY(myRect); + + QQuickItemPrivate::get(rect)->setState("moved"); + QTRY_VERIFY(myRect->x() < 500 && myRect->x() > 100 && myRect->y() > 50 && myRect->y() < 700 ); //animation started + QTRY_VERIFY(qFuzzyCompare(myRect->x(), qreal(100)) && qFuzzyCompare(myRect->y(), qreal(700))); + QTest::qWait(100); + + QQuickItemPrivate::get(rect)->setState(""); + QTRY_VERIFY(myRect->x() < 500 && myRect->x() > 100 && myRect->y() > 50 && myRect->y() < 700 ); //animation started + QTRY_VERIFY(qFuzzyCompare(myRect->x(), qreal(500)) && qFuzzyCompare(myRect->y(), qreal(50))); +} + +void tst_qquickanimations::disabledTransition() +{ + QQmlEngine engine; + QQmlComponent c(&engine, testFileUrl("disabledTransition.qml")); + QQuickRectangle *rect = qobject_cast(c.create()); + QVERIFY(rect); + + QQuickRectangle *myRect = rect->findChild("TheRect"); + QVERIFY(myRect); + + QQuickTransition *trans = rect->findChild(); + QVERIFY(trans); + + QCOMPARE(trans->enabled(), false); + + QQuickItemPrivate::get(rect)->setState("moved"); + QCOMPARE(myRect->x(),qreal(200)); + + trans->setEnabled(true); + + QQuickItemPrivate::get(rect)->setState(""); + QCOMPARE(myRect->x(),qreal(200)); + QTest::qWait(300); + QTIMED_COMPARE(myRect->x(),qreal(100)); +} + +void tst_qquickanimations::invalidDuration() +{ + QQuickPropertyAnimation *animation = new QQuickPropertyAnimation; + QTest::ignoreMessage(QtWarningMsg, ": QML PropertyAnimation: Cannot set a duration of < 0"); + animation->setDuration(-1); + QCOMPARE(animation->duration(), 250); + + QQuickPauseAnimation *pauseAnimation = new QQuickPauseAnimation; + QTest::ignoreMessage(QtWarningMsg, ": QML PauseAnimation: Cannot set a duration of < 0"); + pauseAnimation->setDuration(-1); + QCOMPARE(pauseAnimation->duration(), 250); +} + +void tst_qquickanimations::attached() +{ + QQmlEngine engine; + + QQmlComponent c(&engine, testFileUrl("attached.qml")); + QTest::ignoreMessage(QtDebugMsg, "off"); + QTest::ignoreMessage(QtDebugMsg, "on"); + QQuickRectangle *rect = qobject_cast(c.create()); + QVERIFY(rect); +} + +void tst_qquickanimations::propertyValueSourceDefaultStart() +{ + { + QQmlEngine engine; + + QQmlComponent c(&engine, testFileUrl("valuesource.qml")); + + QQuickRectangle *rect = qobject_cast(c.create()); + QVERIFY(rect); + + QQuickAbstractAnimation *myAnim = rect->findChild("MyAnim"); + QVERIFY(myAnim); + QVERIFY(myAnim->isRunning()); + } + + { + QQmlEngine engine; + + QQmlComponent c(&engine, testFileUrl("valuesource2.qml")); + + QQuickRectangle *rect = qobject_cast(c.create()); + QVERIFY(rect); + + QQuickAbstractAnimation *myAnim = rect->findChild("MyAnim"); + QVERIFY(myAnim); + QVERIFY(myAnim->isRunning() == false); + } + + { + QQmlEngine engine; + + QQmlComponent c(&engine, testFileUrl("dontAutoStart.qml")); + + QQuickRectangle *rect = qobject_cast(c.create()); + QVERIFY(rect); + + QQuickAbstractAnimation *myAnim = rect->findChild("MyAnim"); + QVERIFY(myAnim && !myAnim->qtAnimation()); + //QVERIFY(myAnim->qtAnimation()->state() == QAbstractAnimationJob::Stopped); + } +} + + +void tst_qquickanimations::dontStart() +{ + { + QQmlEngine engine; + + QQmlComponent c(&engine, testFileUrl("dontStart.qml")); + + QString warning = c.url().toString() + ":14:13: QML NumberAnimation: setRunning() cannot be used on non-root animation nodes."; + QTest::ignoreMessage(QtWarningMsg, qPrintable(warning)); + QQuickRectangle *rect = qobject_cast(c.create()); + QVERIFY(rect); + + QQuickAbstractAnimation *myAnim = rect->findChild("MyAnim"); + QVERIFY(myAnim && !myAnim->qtAnimation()); + //QVERIFY(myAnim->qtAnimation()->state() == QAbstractAnimationJob::Stopped); + } + + { + QQmlEngine engine; + + QQmlComponent c(&engine, testFileUrl("dontStart2.qml")); + + QString warning = c.url().toString() + ":15:17: QML NumberAnimation: setRunning() cannot be used on non-root animation nodes."; + QTest::ignoreMessage(QtWarningMsg, qPrintable(warning)); + QQuickRectangle *rect = qobject_cast(c.create()); + QVERIFY(rect); + + QQuickAbstractAnimation *myAnim = rect->findChild("MyAnim"); + QVERIFY(myAnim && !myAnim->qtAnimation()); + //QVERIFY(myAnim->qtAnimation()->state() == QAbstractAnimationJob::Stopped); + } +} + +void tst_qquickanimations::easingProperties() +{ + { + QQmlEngine engine; + QString componentStr = "import QtQuick 2.0\nNumberAnimation { easing.type: \"InOutQuad\" }"; + QQmlComponent animationComponent(&engine); + animationComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); + QQuickPropertyAnimation *animObject = qobject_cast(animationComponent.create()); + + QVERIFY(animObject != 0); + QCOMPARE(animObject->easing().type(), QEasingCurve::InOutQuad); + } + + { + QQmlEngine engine; + QString componentStr = "import QtQuick 2.0\nPropertyAnimation { easing.type: \"OutBounce\"; easing.amplitude: 5.0 }"; + QQmlComponent animationComponent(&engine); + animationComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); + QQuickPropertyAnimation *animObject = qobject_cast(animationComponent.create()); + + QVERIFY(animObject != 0); + QCOMPARE(animObject->easing().type(), QEasingCurve::OutBounce); + QCOMPARE(animObject->easing().amplitude(), 5.0); + } + + { + QQmlEngine engine; + QString componentStr = "import QtQuick 2.0\nPropertyAnimation { easing.type: \"OutElastic\"; easing.amplitude: 5.0; easing.period: 3.0}"; + QQmlComponent animationComponent(&engine); + animationComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); + QQuickPropertyAnimation *animObject = qobject_cast(animationComponent.create()); + + QVERIFY(animObject != 0); + QCOMPARE(animObject->easing().type(), QEasingCurve::OutElastic); + QCOMPARE(animObject->easing().amplitude(), 5.0); + QCOMPARE(animObject->easing().period(), 3.0); + } + + { + QQmlEngine engine; + QString componentStr = "import QtQuick 2.0\nPropertyAnimation { easing.type: \"InOutBack\"; easing.overshoot: 2 }"; + QQmlComponent animationComponent(&engine); + animationComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); + QQuickPropertyAnimation *animObject = qobject_cast(animationComponent.create()); + + QVERIFY(animObject != 0); + QCOMPARE(animObject->easing().type(), QEasingCurve::InOutBack); + QCOMPARE(animObject->easing().overshoot(), 2.0); + } + + { + QQmlEngine engine; + QString componentStr = "import QtQuick 2.0\nPropertyAnimation { easing.type: \"Bezier\"; easing.bezierCurve: [0.5, 0.2, 0.13, 0.65, 1.0, 1.0] }"; + QQmlComponent animationComponent(&engine); + animationComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); + QQuickPropertyAnimation *animObject = qobject_cast(animationComponent.create()); + + QVERIFY(animObject != 0); + QCOMPARE(animObject->easing().type(), QEasingCurve::BezierSpline); + QList points = animObject->easing().cubicBezierSpline(); + QCOMPARE(points.count(), 3); + QCOMPARE(points.at(0), QPointF(0.5, 0.2)); + QCOMPARE(points.at(1), QPointF(0.13, 0.65)); + QCOMPARE(points.at(2), QPointF(1.0, 1.0)); + } +} + +void tst_qquickanimations::rotation() +{ + QQmlEngine engine; + QQmlComponent c(&engine, testFileUrl("rotation.qml")); + QQuickRectangle *rect = qobject_cast(c.create()); + QVERIFY(rect); + + QQuickRectangle *rr = rect->findChild("rr"); + QQuickRectangle *rr2 = rect->findChild("rr2"); + QQuickRectangle *rr3 = rect->findChild("rr3"); + QQuickRectangle *rr4 = rect->findChild("rr4"); + + QQuickItemPrivate::get(rect)->setState("state1"); + QTest::qWait(800); + qreal r1 = rr->rotation(); + qreal r2 = rr2->rotation(); + qreal r3 = rr3->rotation(); + qreal r4 = rr4->rotation(); + + QVERIFY(r1 > qreal(0) && r1 < qreal(370)); + QVERIFY(r2 > qreal(0) && r2 < qreal(370)); + QVERIFY(r3 < qreal(0) && r3 > qreal(-350)); + QVERIFY(r4 > qreal(0) && r4 < qreal(10)); + QCOMPARE(r1,r2); + QVERIFY(r4 < r2); + + QTest::qWait(800); + QTIMED_COMPARE(rr->rotation() + rr2->rotation() + rr3->rotation() + rr4->rotation(), qreal(370*4)); +} + +void tst_qquickanimations::runningTrueBug() +{ + //ensure we start correctly when "running: true" is explicitly set + QQmlEngine engine; + QQmlComponent c(&engine, testFileUrl("runningTrueBug.qml")); + QQuickRectangle *rect = qobject_cast(c.create()); + QVERIFY(rect); + + QQuickRectangle *cloud = rect->findChild("cloud"); + QVERIFY(cloud); + QTest::qWait(1000); + QVERIFY(cloud->x() > qreal(0)); +} + +//QTBUG-12805 +void tst_qquickanimations::nonTransitionBug() +{ + //tests that the animation values from the previous transition are properly cleared + //in the case where an animation in the transition doesn't match anything (but previously did) + QQmlEngine engine; + + QQmlComponent c(&engine, testFileUrl("nonTransitionBug.qml")); + QQuickRectangle *rect = qobject_cast(c.create()); + QVERIFY(rect != 0); + QQuickItemPrivate *rectPrivate = QQuickItemPrivate::get(rect); + QQuickRectangle *mover = rect->findChild("mover"); + + mover->setX(100); + QCOMPARE(mover->x(), qreal(100)); + + rectPrivate->setState("left"); + QTRY_COMPARE(mover->x(), qreal(0)); + + mover->setX(100); + QCOMPARE(mover->x(), qreal(100)); + + //make sure we don't try to animate back to 0 + rectPrivate->setState("free"); + QTest::qWait(300); + QCOMPARE(mover->x(), qreal(100)); +} + +//QTBUG-14042 +void tst_qquickanimations::registrationBug() +{ + QQmlEngine engine; + + QQmlComponent c(&engine, testFileUrl("registrationBug.qml")); + QQuickRectangle *rect = qobject_cast(c.create()); + QVERIFY(rect != 0); + QTRY_COMPARE(rect->property("value"), QVariant(int(100))); +} + +void tst_qquickanimations::doubleRegistrationBug() +{ + QQmlEngine engine; + + QQmlComponent c(&engine, testFileUrl("doubleRegistrationBug.qml")); + QQuickRectangle *rect = qobject_cast(c.create()); + QVERIFY(rect != 0); + + QQuickAbstractAnimation *anim = rect->findChild("animation"); + QVERIFY(anim != 0); + QTRY_COMPARE(anim->qtAnimation()->state(), QAbstractAnimationJob::Stopped); +} + +//QTBUG-16736 +void tst_qquickanimations::alwaysRunToEndRestartBug() +{ + QQuickRectangle rect; + QQuickPropertyAnimation animation; + animation.setTargetObject(&rect); + animation.setProperty("x"); + animation.setTo(200); + animation.setDuration(1000); + animation.setLoops(-1); + animation.setAlwaysRunToEnd(true); + QVERIFY(animation.loops() == -1); + QVERIFY(animation.alwaysRunToEnd() == true); + animation.start(); + animation.stop(); + animation.start(); + animation.stop(); + QTest::qWait(500); + QVERIFY(rect.x() != qreal(200)); + QTest::qWait(800); + QTIMED_COMPARE(rect.x(), qreal(200)); + QCOMPARE(static_cast(&animation)->qtAnimation()->state(), QAbstractAnimationJob::Stopped); +} + +//QTBUG-20227 +void tst_qquickanimations::transitionAssignmentBug() +{ + QQmlEngine engine; + + QQmlComponent c(&engine, testFileUrl("transitionAssignmentBug.qml")); + QQuickRectangle *rect = qobject_cast(c.create()); + QVERIFY(rect != 0); + + QCOMPARE(rect->property("nullObject").toBool(), false); +} + +//QTBUG-19080 +void tst_qquickanimations::pauseBindingBug() +{ + QQmlEngine engine; + + QQmlComponent c(&engine, testFileUrl("pauseBindingBug.qml")); + QQuickRectangle *rect = qobject_cast(c.create()); + QVERIFY(rect != 0); + QQuickAbstractAnimation *anim = rect->findChild("animation"); + QVERIFY(anim->qtAnimation()->state() == QAbstractAnimationJob::Paused); + + delete rect; +} + +//QTBUG-13598 +void tst_qquickanimations::pauseBug() +{ + QQmlEngine engine; + + QQmlComponent c(&engine, testFileUrl("pauseBug.qml")); + QQuickAbstractAnimation *anim = qobject_cast(c.create()); + QVERIFY(anim != 0); + QCOMPARE(anim->qtAnimation()->state(), QAbstractAnimationJob::Paused); + QCOMPARE(anim->isPaused(), true); + QCOMPARE(anim->isRunning(), true); + + delete anim; +} + +//QTBUG-23092 +void tst_qquickanimations::loopingBug() +{ + QQmlEngine engine; + + QQmlComponent c(&engine, testFileUrl("looping.qml")); + QObject *obj = c.create(); + + QQuickAbstractAnimation *anim = obj->findChild(); + QVERIFY(anim != 0); + QCOMPARE(anim->qtAnimation()->totalDuration(), 300); + QCOMPARE(anim->isRunning(), true); + QTRY_COMPARE(static_cast(anim->qtAnimation())->firstChild()->currentLoop(), 2); + QTRY_COMPARE(anim->isRunning(), false); + + QQuickRectangle *rect = obj->findChild(); + QVERIFY(rect != 0); + QCOMPARE(rect->rotation(), qreal(90)); + + delete obj; +} + +QTEST_MAIN(tst_qquickanimations) + +#include "tst_qquickanimations.moc" diff --git a/tests/auto/quick/qquickapplication/qquickapplication.pro b/tests/auto/quick/qquickapplication/qquickapplication.pro new file mode 100644 index 0000000000..96cfe82a82 --- /dev/null +++ b/tests/auto/quick/qquickapplication/qquickapplication.pro @@ -0,0 +1,7 @@ +CONFIG += testcase +TARGET = tst_qquickapplication +macx:CONFIG -= app_bundle + +SOURCES += tst_qquickapplication.cpp +QT += core-private gui-private qml-private quick-private testlib + diff --git a/tests/auto/quick/qquickapplication/tst_qquickapplication.cpp b/tests/auto/quick/qquickapplication/tst_qquickapplication.cpp new file mode 100644 index 0000000000..61675d980d --- /dev/null +++ b/tests/auto/quick/qquickapplication/tst_qquickapplication.cpp @@ -0,0 +1,159 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include +#include +#include +#include +#include + +class tst_qquickapplication : public QObject +{ + Q_OBJECT +public: + tst_qquickapplication(); + +private slots: + void active(); + void layoutDirection(); + void inputPanel(); + void inputMethod(); + +private: + QQmlEngine engine; +}; + +tst_qquickapplication::tst_qquickapplication() +{ +} + +void tst_qquickapplication::active() +{ + QQmlComponent component(&engine); + component.setData("import QtQuick 2.0; Item { property bool active: Qt.application.active }", QUrl::fromLocalFile("")); + QQuickItem *item = qobject_cast(component.create()); + QVERIFY(item); + QQuickView view; + item->setParentItem(view.rootObject()); + + // not active + QVERIFY(!item->property("active").toBool()); + QCOMPARE(item->property("active").toBool(), QGuiApplication::activeWindow() != 0); + + // active + view.show(); + view.requestActivateWindow(); + QTest::qWait(50); + QEXPECT_FAIL("", "QTBUG-21573", Abort); + QTRY_COMPARE(view.status(), QQuickView::Ready); + QCOMPARE(item->property("active").toBool(), QGuiApplication::activeWindow() != 0); + +#if 0 + // QGuiApplication has no equivalent of setActiveWindow(0). QTBUG-21573 + // Is this different to clearing the active state of the window or can it be removed? + // On Mac, setActiveWindow(0) on mac does not deactivate the current application, + // must switch to a different app or hide the current app to trigger this + // on mac, setActiveWindow(0) on mac does not deactivate the current application + // (you have to switch to a different app or hide the current app to trigger this) + + // not active again + QGuiApplication::setActiveWindow(0); + QVERIFY(!item->property("active").toBool()); + QCOMPARE(item->property("active").toBool(), QGuiApplication::activeWindow() != 0); +#endif + +} + +void tst_qquickapplication::layoutDirection() +{ + + QQmlComponent component(&engine); + component.setData("import QtQuick 2.0; Item { property bool layoutDirection: Qt.application.layoutDirection }", QUrl::fromLocalFile("")); + QQuickItem *item = qobject_cast(component.create()); + QVERIFY(item); + QQuickView view; + item->setParentItem(view.rootObject()); + + // not mirrored + QCOMPARE(Qt::LayoutDirection(item->property("layoutDirection").toInt()), Qt::LeftToRight); + + // mirrored + QGuiApplication::setLayoutDirection(Qt::RightToLeft); + QEXPECT_FAIL("", "QTBUG-21573", Abort); + QCOMPARE(Qt::LayoutDirection(item->property("layoutDirection").toInt()), Qt::RightToLeft); + + // not mirrored again + QGuiApplication::setLayoutDirection(Qt::LeftToRight); + QCOMPARE(Qt::LayoutDirection(item->property("layoutDirection").toInt()), Qt::LeftToRight); +} + +void tst_qquickapplication::inputPanel() +{ + QQmlComponent component(&engine); + component.setData("import QtQuick 2.0; Item { property variant inputPanel: Qt.application.inputPanel }", QUrl::fromLocalFile("")); + QQuickItem *item = qobject_cast(component.create()); + QVERIFY(item); + QQuickView view; + item->setParentItem(view.rootObject()); + + // check that the inputPanel property maches with application's input panel + QCOMPARE(qvariant_cast(item->property("inputPanel")), qApp->inputMethod()); +} + +void tst_qquickapplication::inputMethod() +{ + // technically not in QQuickApplication, but testing anyway here + QQmlComponent component(&engine); + component.setData("import QtQuick 2.0; Item { property variant inputMethod: Qt.inputMethod }", QUrl::fromLocalFile("")); + QQuickItem *item = qobject_cast(component.create()); + QVERIFY(item); + QQuickView view; + item->setParentItem(view.rootObject()); + + // check that the inputMethod property maches with application's input method + QCOMPARE(qvariant_cast(item->property("inputMethod")), qApp->inputMethod()); +} + + +QTEST_MAIN(tst_qquickapplication) + +#include "tst_qquickapplication.moc" diff --git a/tests/auto/quick/qquickbehaviors/data/binding.qml b/tests/auto/quick/qquickbehaviors/data/binding.qml new file mode 100644 index 0000000000..5aceefa743 --- /dev/null +++ b/tests/auto/quick/qquickbehaviors/data/binding.qml @@ -0,0 +1,26 @@ +import QtQuick 2.0 +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 + Behavior on x { NumberAnimation { duration: 800; } } + } + MouseArea { + id: clicker + anchors.fill: parent + } + states: State { + name: "moved" + when: clicker.pressed + PropertyChanges { + target: rect + x: movedx + } + } +} diff --git a/tests/auto/quick/qquickbehaviors/data/color.qml b/tests/auto/quick/qquickbehaviors/data/color.qml new file mode 100644 index 0000000000..a318578a9b --- /dev/null +++ b/tests/auto/quick/qquickbehaviors/data/color.qml @@ -0,0 +1,24 @@ +import QtQuick 2.0 +Rectangle { + width: 400 + height: 400 + Rectangle { + id: rect + objectName: "MyRect" + width: 100; height: 100; + color: "green" + Behavior on color { ColorAnimation { duration: 500; } } + } + MouseArea { + id: clicker + anchors.fill: parent + } + states: State { + name: "red" + when: clicker.pressed + PropertyChanges { + target: rect + color: "red" + } + } +} diff --git a/tests/auto/quick/qquickbehaviors/data/cpptrigger.qml b/tests/auto/quick/qquickbehaviors/data/cpptrigger.qml new file mode 100644 index 0000000000..f033ec5aeb --- /dev/null +++ b/tests/auto/quick/qquickbehaviors/data/cpptrigger.qml @@ -0,0 +1,11 @@ +import QtQuick 2.0 +Rectangle { + width: 400 + height: 400 + Rectangle { + id: rect + objectName: "MyRect" + width: 100; height: 100; color: "green" + Behavior on x { NumberAnimation { duration: 500; } } + } +} diff --git a/tests/auto/quick/qquickbehaviors/data/delayedRegistration.qml b/tests/auto/quick/qquickbehaviors/data/delayedRegistration.qml new file mode 100644 index 0000000000..ed35a308f7 --- /dev/null +++ b/tests/auto/quick/qquickbehaviors/data/delayedRegistration.qml @@ -0,0 +1,25 @@ +import QtQuick 2.0 + +Rectangle { + id: container + + width: 400; height: 400; + property Item myItem + + function doCreate() { + myItem = myComponent.createObject(container) + myItem.x = 100 + } + + Component { + id: myComponent + Rectangle { + width: 100 + height: 100 + color: "green" + Behavior on x { NumberAnimation { duration: 500 } } + } + } + + Component.onCompleted: doCreate() +} diff --git a/tests/auto/quick/qquickbehaviors/data/disabled.qml b/tests/auto/quick/qquickbehaviors/data/disabled.qml new file mode 100644 index 0000000000..20860d8dde --- /dev/null +++ b/tests/auto/quick/qquickbehaviors/data/disabled.qml @@ -0,0 +1,27 @@ +import QtQuick 2.0 +Rectangle { + width: 400 + height: 400 + Rectangle { + id: rect + objectName: "MyRect" + width: 100; height: 100; color: "green" + Behavior on x { + objectName: "MyBehavior"; + enabled: false + NumberAnimation { duration: 200; } + } + } + MouseArea { + id: clicker + anchors.fill: parent + } + states: State { + name: "moved" + when: clicker.pressed + PropertyChanges { + target: rect + x: 200 + } + } +} diff --git a/tests/auto/quick/qquickbehaviors/data/dontStart.qml b/tests/auto/quick/qquickbehaviors/data/dontStart.qml new file mode 100644 index 0000000000..38e1ea9d9e --- /dev/null +++ b/tests/auto/quick/qquickbehaviors/data/dontStart.qml @@ -0,0 +1,18 @@ +import QtQuick 2.0 + +Rectangle { + id: wrapper + width: 600 + height: 400 + + Rectangle { + id: redRect + width: 100; height: 100 + color: Qt.rgba(1,0,0) + Behavior on x { + NumberAnimation {id: myAnim; objectName: "MyAnim"; running: true } + } + + } + +} diff --git a/tests/auto/quick/qquickbehaviors/data/empty.qml b/tests/auto/quick/qquickbehaviors/data/empty.qml new file mode 100644 index 0000000000..d8f115390a --- /dev/null +++ b/tests/auto/quick/qquickbehaviors/data/empty.qml @@ -0,0 +1,23 @@ +import QtQuick 2.0 +Rectangle { + width: 400 + height: 400 + Rectangle { + id: rect + objectName: "MyRect" + width: 100; height: 100; color: "green" + Behavior on x {} + } + MouseArea { + id: clicker + anchors.fill: parent + } + states: State { + name: "moved" + when: clicker.pressed + PropertyChanges { + target: rect + x: 200 + } + } +} diff --git a/tests/auto/quick/qquickbehaviors/data/explicit.qml b/tests/auto/quick/qquickbehaviors/data/explicit.qml new file mode 100644 index 0000000000..20875c30e3 --- /dev/null +++ b/tests/auto/quick/qquickbehaviors/data/explicit.qml @@ -0,0 +1,26 @@ +import QtQuick 2.0 +Rectangle { + width: 400 + height: 400 + Rectangle { + id: rect + objectName: "MyRect" + width: 100; height: 100; color: "green" + Behavior on x { + objectName: "MyBehavior"; + NumberAnimation { target: rect; property: "x"; duration: 500; } + } + } + MouseArea { + id: clicker + anchors.fill: parent + } + states: State { + name: "moved" + when: clicker.pressed + PropertyChanges { + target: rect + x: 200 + } + } +} diff --git a/tests/auto/quick/qquickbehaviors/data/groupProperty.qml b/tests/auto/quick/qquickbehaviors/data/groupProperty.qml new file mode 100644 index 0000000000..a05ab7d54b --- /dev/null +++ b/tests/auto/quick/qquickbehaviors/data/groupProperty.qml @@ -0,0 +1,23 @@ +import QtQuick 2.0 +Rectangle { + width: 400 + height: 400 + Rectangle { + id: rect + objectName: "MyRect" + width: 100; height: 100; color: "green" + Behavior on pos { PropertyAnimation { duration: 500; } } + } + MouseArea { + 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/quick/qquickbehaviors/data/groupProperty2.qml b/tests/auto/quick/qquickbehaviors/data/groupProperty2.qml new file mode 100644 index 0000000000..2f3de5131c --- /dev/null +++ b/tests/auto/quick/qquickbehaviors/data/groupProperty2.qml @@ -0,0 +1,23 @@ +import QtQuick 2.0 +Rectangle { + width: 400 + height: 400 + Rectangle { + id: rect + objectName: "MyRect" + width: 100; height: 100; color: "green" + Behavior on border.width { NumberAnimation { duration: 500; } } + } + MouseArea { + id: clicker + anchors.fill: parent + } + states: State { + name: "moved" + when: clicker.pressed + PropertyChanges { + target: rect + border.width: 4; + } + } +} diff --git a/tests/auto/quick/qquickbehaviors/data/groupedPropertyCrash.qml b/tests/auto/quick/qquickbehaviors/data/groupedPropertyCrash.qml new file mode 100644 index 0000000000..6835902bc5 --- /dev/null +++ b/tests/auto/quick/qquickbehaviors/data/groupedPropertyCrash.qml @@ -0,0 +1,10 @@ +import QtQuick 2.0 + +Rectangle { + width: 200 + height: 200 + Text { + Behavior on anchors.verticalCenterOffset { NumberAnimation { duration: 300; } } + text: "Hello World" + } +} diff --git a/tests/auto/quick/qquickbehaviors/data/loop.qml b/tests/auto/quick/qquickbehaviors/data/loop.qml new file mode 100644 index 0000000000..3e8d88734d --- /dev/null +++ b/tests/auto/quick/qquickbehaviors/data/loop.qml @@ -0,0 +1,19 @@ +import QtQuick 2.0 +Rectangle { + width: 400 + height: 400 + Rectangle { + id: rect + objectName: "MyRect" + width: 100; height: 100; color: "green" + Behavior on x { NumberAnimation { duration: 200; } } + onXChanged: x = 100; + } + states: State { + name: "moved" + PropertyChanges { + target: rect + x: 200 + } + } +} diff --git a/tests/auto/quick/qquickbehaviors/data/nonSelecting2.qml b/tests/auto/quick/qquickbehaviors/data/nonSelecting2.qml new file mode 100644 index 0000000000..6357094cfe --- /dev/null +++ b/tests/auto/quick/qquickbehaviors/data/nonSelecting2.qml @@ -0,0 +1,26 @@ +import QtQuick 2.0 +Rectangle { + width: 400 + height: 400 + Rectangle { + id: rect + objectName: "MyRect" + width: 100; height: 100; color: "green" + Behavior on x { + objectName: "MyBehavior"; + NumberAnimation { targets: rect; properties: "y"; duration: 200; } + } + } + MouseArea { + id: clicker + anchors.fill: parent + } + states: State { + name: "moved" + when: clicker.pressed + PropertyChanges { + target: rect + x: 200 + } + } +} diff --git a/tests/auto/quick/qquickbehaviors/data/parent.qml b/tests/auto/quick/qquickbehaviors/data/parent.qml new file mode 100644 index 0000000000..f8c2731d86 --- /dev/null +++ b/tests/auto/quick/qquickbehaviors/data/parent.qml @@ -0,0 +1,28 @@ +import QtQuick 2.0 +Rectangle { + width: 400 + height: 400 + Rectangle { + id: rect + objectName: "MyRect" + width: 100; height: 100; color: "green" + Behavior on parent { + SequentialAnimation { + PauseAnimation { duration: 500 } + PropertyAction {} + } + } + } + Item { + id: newParent + objectName: "NewParent" + x: 100 + } + states: State { + name: "reparented" + PropertyChanges { + target: rect + parent: newParent + } + } +} diff --git a/tests/auto/quick/qquickbehaviors/data/qtbug12295.qml b/tests/auto/quick/qquickbehaviors/data/qtbug12295.qml new file mode 100644 index 0000000000..c6bef581a4 --- /dev/null +++ b/tests/auto/quick/qquickbehaviors/data/qtbug12295.qml @@ -0,0 +1,17 @@ +import QtQuick 2.0 + +Rectangle { + width: 200 + height: 200 + color: "blue" + + Rectangle { + id: myRect + objectName: "myRect" + width: 100 + height: 100 + Behavior on x { + NumberAnimation { duration: 500 } + } + } +} diff --git a/tests/auto/quick/qquickbehaviors/data/reassignedAnimation.qml b/tests/auto/quick/qquickbehaviors/data/reassignedAnimation.qml new file mode 100644 index 0000000000..5731cb3efd --- /dev/null +++ b/tests/auto/quick/qquickbehaviors/data/reassignedAnimation.qml @@ -0,0 +1,32 @@ +import QtQuick 2.0 +Rectangle { + width: 400 + height: 400 + Rectangle { + id: rect + objectName: "MyRect" + width: 100; height: 100; color: "green" + Behavior on x { + id: myBehavior + objectName: "MyBehavior" + NumberAnimation {id: na1; duration: 200 } + } + } + MouseArea { + id: clicker + anchors.fill: parent + } + states: State { + name: "moved" + when: clicker.pressed + PropertyChanges { + target: rect + x: 200 + } + } + + NumberAnimation {id: na2; duration: 1000 } + Component.onCompleted: { + myBehavior.animation = na2; + } +} diff --git a/tests/auto/quick/qquickbehaviors/data/runningTrue.qml b/tests/auto/quick/qquickbehaviors/data/runningTrue.qml new file mode 100644 index 0000000000..4fd1136f3a --- /dev/null +++ b/tests/auto/quick/qquickbehaviors/data/runningTrue.qml @@ -0,0 +1,20 @@ +import QtQuick 2.0 + +Rectangle { + id: root + width:200; height:200 + + property real myValue: 0 + + Rectangle { + anchors.centerIn: parent + width: 100 + height: 100 + color: "green" + smooth: true + rotation: myValue + Behavior on rotation { + RotationAnimation { id: rotAnim; objectName: "rotAnim"; direction: RotationAnimation.Shortest } + } + } +} diff --git a/tests/auto/quick/qquickbehaviors/data/scripttrigger.qml b/tests/auto/quick/qquickbehaviors/data/scripttrigger.qml new file mode 100644 index 0000000000..ff71f2b1b0 --- /dev/null +++ b/tests/auto/quick/qquickbehaviors/data/scripttrigger.qml @@ -0,0 +1,16 @@ +import QtQuick 2.0 +Rectangle { + width: 400 + height: 400 + + onColorChanged: { + rect.x = 200 + } + + Rectangle { + id: rect + objectName: "MyRect" + width: 100; height: 100; color: "green" + Behavior on x { NumberAnimation { duration: 800; } } + } +} diff --git a/tests/auto/quick/qquickbehaviors/data/simple.qml b/tests/auto/quick/qquickbehaviors/data/simple.qml new file mode 100644 index 0000000000..c64a6e1928 --- /dev/null +++ b/tests/auto/quick/qquickbehaviors/data/simple.qml @@ -0,0 +1,26 @@ +import QtQuick 2.0 +Rectangle { + width: 400 + height: 400 + Rectangle { + id: rect + objectName: "MyRect" + width: 100; height: 100; color: "green" + Behavior on x { + objectName: "MyBehavior"; + NumberAnimation {id: na; duration: 500; } + } + } + MouseArea { + id: clicker + anchors.fill: parent + } + states: State { + name: "moved" + when: clicker.pressed + PropertyChanges { + target: rect + x: 200 + } + } +} diff --git a/tests/auto/quick/qquickbehaviors/data/startOnCompleted.qml b/tests/auto/quick/qquickbehaviors/data/startOnCompleted.qml new file mode 100644 index 0000000000..fdc3779a5c --- /dev/null +++ b/tests/auto/quick/qquickbehaviors/data/startOnCompleted.qml @@ -0,0 +1,15 @@ +import QtQuick 2.0 + +Rectangle { + width: 400 + height: 400 + + Rectangle { + id: innerRect + width: 100; height: 100 + color: "green" + Behavior on x { NumberAnimation {} } + } + + Component.onCompleted: innerRect.x = 100 +} diff --git a/tests/auto/quick/qquickbehaviors/data/startup.qml b/tests/auto/quick/qquickbehaviors/data/startup.qml new file mode 100644 index 0000000000..9fa74ca39e --- /dev/null +++ b/tests/auto/quick/qquickbehaviors/data/startup.qml @@ -0,0 +1,17 @@ +import QtQuick 2.0 + +Rectangle { + width: 400 + height: 400 + + Rectangle { + objectName: "innerRect" + height: 100; width: 100; color: "green" + property real targetX: 100 + + x: targetX + Behavior on x { + NumberAnimation {} + } + } +} diff --git a/tests/auto/quick/qquickbehaviors/data/startup2.qml b/tests/auto/quick/qquickbehaviors/data/startup2.qml new file mode 100644 index 0000000000..0654ef3644 --- /dev/null +++ b/tests/auto/quick/qquickbehaviors/data/startup2.qml @@ -0,0 +1,16 @@ +import QtQuick 2.0 + +Rectangle { + width: 800; + height: 480; + + Text { id:theText; text: "hello world" } + + Rectangle { + objectName: "innerRect" + color: "red" + x: theText.width + Behavior on x { NumberAnimation {} } + width: 100; height: 100 + } +} diff --git a/tests/auto/quick/qquickbehaviors/data/valueType.qml b/tests/auto/quick/qquickbehaviors/data/valueType.qml new file mode 100644 index 0000000000..7bc8297dc7 --- /dev/null +++ b/tests/auto/quick/qquickbehaviors/data/valueType.qml @@ -0,0 +1,13 @@ +import QtQuick 2.0 +Rectangle { + width: 400 + height: 400 + + color.r: 1 + color.g: 0 + color.b: 1 + + Behavior on color.r { NumberAnimation { duration: 500; } } + + function changeR() { color.r = 0 } +} diff --git a/tests/auto/quick/qquickbehaviors/qquickbehaviors.pro b/tests/auto/quick/qquickbehaviors/qquickbehaviors.pro new file mode 100644 index 0000000000..fc103ed4c2 --- /dev/null +++ b/tests/auto/quick/qquickbehaviors/qquickbehaviors.pro @@ -0,0 +1,15 @@ +CONFIG += testcase +TARGET = tst_qquickbehaviors +SOURCES += tst_qquickbehaviors.cpp + +include (../../shared/util.pri) + +macx:CONFIG -= app_bundle + +testDataFiles.files = data +testDataFiles.path = . +DEPLOYMENT += testDataFiles + +CONFIG += parallel_test + +QT += core-private gui-private v8-private qml-private quick-private opengl-private testlib diff --git a/tests/auto/quick/qquickbehaviors/tst_qquickbehaviors.cpp b/tests/auto/quick/qquickbehaviors/tst_qquickbehaviors.cpp new file mode 100644 index 0000000000..bd17bf4143 --- /dev/null +++ b/tests/auto/quick/qquickbehaviors/tst_qquickbehaviors.cpp @@ -0,0 +1,473 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "../../shared/util.h" + +class tst_qquickbehaviors : public QQmlDataTest +{ + Q_OBJECT +public: + tst_qquickbehaviors() {} + +private slots: + void init() { qApp->processEvents(); } //work around animation timer bug (QTBUG-22865) + void simpleBehavior(); + void scriptTriggered(); + void cppTriggered(); + void loop(); + void colorBehavior(); + void parentBehavior(); + void replaceBinding(); + //void transitionOverrides(); + void group(); + void valueType(); + void emptyBehavior(); + void explicitSelection(); + void nonSelectingBehavior(); + void reassignedAnimation(); + void disabled(); + void dontStart(); + void startup(); + void groupedPropertyCrash(); + void runningTrue(); + void sameValue(); + void delayedRegistration(); + void startOnCompleted(); +}; + +void tst_qquickbehaviors::simpleBehavior() +{ + QQmlEngine engine; + QQmlComponent c(&engine, testFileUrl("simple.qml")); + QQuickRectangle *rect = qobject_cast(c.create()); + QTRY_VERIFY(rect); + QTRY_VERIFY(qobject_cast(rect->findChild("MyBehavior"))->animation()); + + QQuickItemPrivate::get(rect)->setState("moved"); + QTRY_VERIFY(qobject_cast(rect->findChild("MyRect"))->x() > 0); + QTRY_VERIFY(qobject_cast(rect->findChild("MyRect"))->x() < 200); + //i.e. the behavior has been triggered + + delete rect; +} + +void tst_qquickbehaviors::scriptTriggered() +{ + QQmlEngine engine; + QQmlComponent c(&engine, testFileUrl("scripttrigger.qml")); + QQuickRectangle *rect = qobject_cast(c.create()); + QTRY_VERIFY(rect); + + rect->setColor(QColor("red")); + QTRY_VERIFY(qobject_cast(rect->findChild("MyRect"))->x() > 0); + QTRY_VERIFY(qobject_cast(rect->findChild("MyRect"))->x() < 200); + //i.e. the behavior has been triggered + + delete rect; +} + +void tst_qquickbehaviors::cppTriggered() +{ + QQmlEngine engine; + QQmlComponent c(&engine, testFileUrl("cpptrigger.qml")); + QQuickRectangle *rect = qobject_cast(c.create()); + QTRY_VERIFY(rect); + + QQuickRectangle *innerRect = qobject_cast(rect->findChild("MyRect")); + QTRY_VERIFY(innerRect); + + innerRect->setProperty("x", 200); + QTRY_VERIFY(innerRect->x() > 0); + QTRY_VERIFY(innerRect->x() < 200); //i.e. the behavior has been triggered + + delete rect; +} + +void tst_qquickbehaviors::loop() +{ + QQmlEngine engine; + QQmlComponent c(&engine, testFileUrl("loop.qml")); + QQuickRectangle *rect = qobject_cast(c.create()); + QTRY_VERIFY(rect); + + //don't crash + QQuickItemPrivate::get(rect)->setState("moved"); + + delete rect; +} + +void tst_qquickbehaviors::colorBehavior() +{ + QQmlEngine engine; + QQmlComponent c(&engine, testFileUrl("color.qml")); + QQuickRectangle *rect = qobject_cast(c.create()); + QTRY_VERIFY(rect); + + QQuickItemPrivate::get(rect)->setState("red"); + QTRY_VERIFY(qobject_cast(rect->findChild("MyRect"))->color() != QColor("red")); + QTRY_VERIFY(qobject_cast(rect->findChild("MyRect"))->color() != QColor("green")); + //i.e. the behavior has been triggered + + delete rect; +} + +void tst_qquickbehaviors::parentBehavior() +{ + QQmlEngine engine; + QQmlComponent c(&engine, testFileUrl("parent.qml")); + QQuickRectangle *rect = qobject_cast(c.create()); + QTRY_VERIFY(rect); + + QQuickItemPrivate::get(rect)->setState("reparented"); + QTRY_VERIFY(rect->findChild("MyRect")->parentItem() != rect->findChild("NewParent")); + QTRY_VERIFY(rect->findChild("MyRect")->parentItem() == rect->findChild("NewParent")); + + delete rect; +} + +void tst_qquickbehaviors::replaceBinding() +{ + QQmlEngine engine; + QQmlComponent c(&engine, testFileUrl("binding.qml")); + QQuickRectangle *rect = qobject_cast(c.create()); + QTRY_VERIFY(rect); + + QQuickItemPrivate::get(rect)->setState("moved"); + QQuickRectangle *innerRect = qobject_cast(rect->findChild("MyRect")); + QTRY_VERIFY(innerRect); + QTRY_VERIFY(innerRect->x() > 0); + QTRY_VERIFY(innerRect->x() < 200); + //i.e. the behavior has been triggered + QTRY_COMPARE(innerRect->x(), (qreal)200); + rect->setProperty("basex", 10); + QTRY_COMPARE(innerRect->x(), (qreal)200); + rect->setProperty("movedx", 210); + QTRY_COMPARE(innerRect->x(), (qreal)210); + + QQuickItemPrivate::get(rect)->setState(""); + QTRY_VERIFY(innerRect->x() > 10); + QTRY_VERIFY(innerRect->x() < 210); //i.e. the behavior has been triggered + QTRY_COMPARE(innerRect->x(), (qreal)10); + rect->setProperty("movedx", 200); + QTRY_COMPARE(innerRect->x(), (qreal)10); + rect->setProperty("basex", 20); + QTRY_COMPARE(innerRect->x(), (qreal)20); + + delete rect; +} + +void tst_qquickbehaviors::group() +{ + /* XXX TODO Create a test element for this case. + { + QQmlEngine engine; + QQmlComponent c(&engine, testFileUrl("groupProperty.qml"))); + QQuickRectangle *rect = qobject_cast(c.create()); + qDebug() << c.errorString(); + QTRY_VERIFY(rect); + + QQuickItemPrivate::get(rect)->setState("moved"); + //QTest::qWait(200); + QTRY_VERIFY(qobject_cast(rect->findChild("MyRect"))->x() > 0); + QTRY_VERIFY(qobject_cast(rect->findChild("MyRect"))->x() < 200); + //i.e. the behavior has been triggered + + delete rect; + } + */ + + { + QQmlEngine engine; + QQmlComponent c(&engine, testFileUrl("groupProperty2.qml")); + QQuickRectangle *rect = qobject_cast(c.create()); + QTRY_VERIFY(rect); + + QQuickItemPrivate::get(rect)->setState("moved"); + QTRY_VERIFY(qobject_cast(rect->findChild("MyRect"))->border()->width() > 0); + QTRY_VERIFY(qobject_cast(rect->findChild("MyRect"))->border()->width() < 4); + //i.e. the behavior has been triggered + + delete rect; + } +} + +void tst_qquickbehaviors::valueType() +{ + QQmlEngine engine; + QQmlComponent c(&engine, testFileUrl("valueType.qml")); + QQuickRectangle *rect = qobject_cast(c.create()); + QVERIFY(rect); + + //QTBUG-20827 + QCOMPARE(rect->color(), QColor::fromRgb(255,0,255)); + + delete rect; +} + +void tst_qquickbehaviors::emptyBehavior() +{ + QQmlEngine engine; + QQmlComponent c(&engine, testFileUrl("empty.qml")); + QQuickRectangle *rect = qobject_cast(c.create()); + QVERIFY(rect); + + QQuickItemPrivate::get(rect)->setState("moved"); + qreal x = qobject_cast(rect->findChild("MyRect"))->x(); + QCOMPARE(x, qreal(200)); //should change immediately + + delete rect; +} + +void tst_qquickbehaviors::explicitSelection() +{ + QQmlEngine engine; + QQmlComponent c(&engine, testFileUrl("explicit.qml")); + QQuickRectangle *rect = qobject_cast(c.create()); + QVERIFY(rect); + + QQuickItemPrivate::get(rect)->setState("moved"); + QTRY_VERIFY(qobject_cast(rect->findChild("MyRect"))->x() > 0); + QTRY_VERIFY(qobject_cast(rect->findChild("MyRect"))->x() < 200); + //i.e. the behavior has been triggered + + delete rect; +} + +void tst_qquickbehaviors::nonSelectingBehavior() +{ + QQmlEngine engine; + QQmlComponent c(&engine, testFileUrl("nonSelecting2.qml")); + QQuickRectangle *rect = qobject_cast(c.create()); + QVERIFY(rect); + + QQuickItemPrivate::get(rect)->setState("moved"); + qreal x = qobject_cast(rect->findChild("MyRect"))->x(); + QCOMPARE(x, qreal(200)); //should change immediately + + delete rect; +} + +void tst_qquickbehaviors::reassignedAnimation() +{ + QQmlEngine engine; + QQmlComponent c(&engine, testFileUrl("reassignedAnimation.qml")); + QString warning = testFileUrl("reassignedAnimation.qml").toString() + ":9:9: QML Behavior: Cannot change the animation assigned to a Behavior."; + QTest::ignoreMessage(QtWarningMsg, qPrintable(warning)); + QQuickRectangle *rect = qobject_cast(c.create()); + QVERIFY(rect); + QCOMPARE(qobject_cast( + rect->findChild("MyBehavior")->animation())->duration(), 200); + + delete rect; +} + +void tst_qquickbehaviors::disabled() +{ + QQmlEngine engine; + QQmlComponent c(&engine, testFileUrl("disabled.qml")); + QQuickRectangle *rect = qobject_cast(c.create()); + QVERIFY(rect); + QCOMPARE(rect->findChild("MyBehavior")->enabled(), false); + + QQuickItemPrivate::get(rect)->setState("moved"); + qreal x = qobject_cast(rect->findChild("MyRect"))->x(); + QCOMPARE(x, qreal(200)); //should change immediately + + delete rect; +} + +void tst_qquickbehaviors::dontStart() +{ + QQmlEngine engine; + + QQmlComponent c(&engine, testFileUrl("dontStart.qml")); + + QString warning = c.url().toString() + ":13:13: QML NumberAnimation: setRunning() cannot be used on non-root animation nodes."; + QTest::ignoreMessage(QtWarningMsg, qPrintable(warning)); + QQuickRectangle *rect = qobject_cast(c.create()); + QVERIFY(rect); + + QQuickAbstractAnimation *myAnim = rect->findChild("MyAnim"); + QVERIFY(myAnim && !myAnim->qtAnimation()); + + delete rect; +} + +void tst_qquickbehaviors::startup() +{ + { + QQmlEngine engine; + QQmlComponent c(&engine, testFileUrl("startup.qml")); + QQuickRectangle *rect = qobject_cast(c.create()); + QVERIFY(rect); + + QQuickRectangle *innerRect = rect->findChild("innerRect"); + QVERIFY(innerRect); + + QCOMPARE(innerRect->x(), qreal(100)); //should be set immediately + + delete rect; + } + + { + QQmlEngine engine; + QQmlComponent c(&engine, testFileUrl("startup2.qml")); + QQuickRectangle *rect = qobject_cast(c.create()); + QVERIFY(rect); + + QQuickRectangle *innerRect = rect->findChild("innerRect"); + QVERIFY(innerRect); + + QQuickText *text = rect->findChild(); + QVERIFY(text); + + QCOMPARE(innerRect->x(), text->width()); //should be set immediately + + delete rect; + } +} + +//QTBUG-10799 +void tst_qquickbehaviors::groupedPropertyCrash() +{ + QQmlEngine engine; + QQmlComponent c(&engine, testFileUrl("groupedPropertyCrash.qml")); + QQuickRectangle *rect = qobject_cast(c.create()); + QVERIFY(rect); //don't crash + + delete rect; +} + +//QTBUG-5491 +void tst_qquickbehaviors::runningTrue() +{ + QQmlEngine engine; + QQmlComponent c(&engine, testFileUrl("runningTrue.qml")); + QQuickRectangle *rect = qobject_cast(c.create()); + QVERIFY(rect); + + QQuickAbstractAnimation *animation = rect->findChild("rotAnim"); + QVERIFY(animation); + + QSignalSpy runningSpy(animation, SIGNAL(runningChanged(bool))); + rect->setProperty("myValue", 180); + QTRY_VERIFY(runningSpy.count() > 0); + + delete rect; +} + +//QTBUG-12295 +void tst_qquickbehaviors::sameValue() +{ + QQmlEngine engine; + QQmlComponent c(&engine, testFileUrl("qtbug12295.qml")); + QQuickRectangle *rect = qobject_cast(c.create()); + QVERIFY(rect); + + QQuickRectangle *target = rect->findChild("myRect"); + QVERIFY(target); + + target->setX(100); + QCOMPARE(target->x(), qreal(100)); + + target->setProperty("x", 0); + QTRY_VERIFY(target->x() != qreal(0) && target->x() != qreal(100)); + QTRY_VERIFY(target->x() == qreal(0)); //make sure Behavior has finished. + + target->setX(100); + QCOMPARE(target->x(), qreal(100)); + + //this is the main point of the test -- the behavior needs to be triggered again + //even though we set 0 twice in a row. + target->setProperty("x", 0); + QTRY_VERIFY(target->x() != qreal(0) && target->x() != qreal(100)); + + delete rect; +} + +//QTBUG-18362 +void tst_qquickbehaviors::delayedRegistration() +{ + QQmlEngine engine; + + QQmlComponent c(&engine, testFileUrl("delayedRegistration.qml")); + QQuickRectangle *rect = qobject_cast(c.create()); + QVERIFY(rect != 0); + + QQuickItem *innerRect = rect->property("myItem").value(); + QVERIFY(innerRect != 0); + + QCOMPARE(innerRect->property("x").toInt(), int(0)); + + QTRY_COMPARE(innerRect->property("x").toInt(), int(100)); +} + +//QTBUG-22555 +void tst_qquickbehaviors::startOnCompleted() +{ + QQmlEngine engine; + + QQmlComponent c(&engine, testFileUrl("startOnCompleted.qml")); + QQuickRectangle *rect = qobject_cast(c.create()); + QVERIFY(rect != 0); + + QQuickItem *innerRect = rect->findChild(); + QVERIFY(innerRect != 0); + + QCOMPARE(innerRect->property("x").toInt(), int(0)); + + QTRY_COMPARE(innerRect->property("x").toInt(), int(100)); + + delete rect; +} + +QTEST_MAIN(tst_qquickbehaviors) + +#include "tst_qquickbehaviors.moc" diff --git a/tests/auto/quick/qquickborderimage/data/colors-mirror.png b/tests/auto/quick/qquickborderimage/data/colors-mirror.png new file mode 100644 index 0000000000..e30870dd1e Binary files /dev/null and b/tests/auto/quick/qquickborderimage/data/colors-mirror.png differ diff --git a/tests/auto/quick/qquickborderimage/data/colors-round-quotes.sci b/tests/auto/quick/qquickborderimage/data/colors-round-quotes.sci new file mode 100644 index 0000000000..294f3cfe48 --- /dev/null +++ b/tests/auto/quick/qquickborderimage/data/colors-round-quotes.sci @@ -0,0 +1,7 @@ +border.left:10 +border.top:20 +border.right:30 +border.bottom:40 +horizontalTileRule:Round +verticalTileRule:Repeat +source:"colors.png" diff --git a/tests/auto/quick/qquickborderimage/data/colors-round-remote.sci b/tests/auto/quick/qquickborderimage/data/colors-round-remote.sci new file mode 100644 index 0000000000..c673bed598 --- /dev/null +++ b/tests/auto/quick/qquickborderimage/data/colors-round-remote.sci @@ -0,0 +1,7 @@ +border.left:10 +border.top:20 +border.right:30 +border.bottom:40 +horizontalTileRule:Round +verticalTileRule:Repeat +source:http://127.0.0.1:14446/colors.png diff --git a/tests/auto/quick/qquickborderimage/data/colors-round.sci b/tests/auto/quick/qquickborderimage/data/colors-round.sci new file mode 100644 index 0000000000..5d2f49f0e1 --- /dev/null +++ b/tests/auto/quick/qquickborderimage/data/colors-round.sci @@ -0,0 +1,7 @@ +border.left:10 +border.top:20 +border.right:30 +border.bottom:40 +horizontalTileRule:Round +verticalTileRule:Repeat +source:colors.png diff --git a/tests/auto/quick/qquickborderimage/data/colors.png b/tests/auto/quick/qquickborderimage/data/colors.png new file mode 100644 index 0000000000..dfb62f3d64 Binary files /dev/null and b/tests/auto/quick/qquickborderimage/data/colors.png differ diff --git a/tests/auto/quick/qquickborderimage/data/heart200.png b/tests/auto/quick/qquickborderimage/data/heart200.png new file mode 100644 index 0000000000..5a31ae8f4d Binary files /dev/null and b/tests/auto/quick/qquickborderimage/data/heart200.png differ diff --git a/tests/auto/quick/qquickborderimage/data/invalid.sci b/tests/auto/quick/qquickborderimage/data/invalid.sci new file mode 100644 index 0000000000..98c72c9bf1 --- /dev/null +++ b/tests/auto/quick/qquickborderimage/data/invalid.sci @@ -0,0 +1,7 @@ +border.left:10 +border.top:20 +border.down:30 +border.up:40 +horizontalTileRule:Roun +verticalTileRule:Repea +source:colors.png diff --git a/tests/auto/quick/qquickborderimage/data/mirror.qml b/tests/auto/quick/qquickborderimage/data/mirror.qml new file mode 100644 index 0000000000..abab076e08 --- /dev/null +++ b/tests/auto/quick/qquickborderimage/data/mirror.qml @@ -0,0 +1,7 @@ +import QtQuick 2.0 + +BorderImage { + source: "colors-mirror.png" + width: 300; height: 300 + border { top: 30; right: 30; bottom: 30; left: 30 } +} diff --git a/tests/auto/quick/qquickborderimage/qquickborderimage.pro b/tests/auto/quick/qquickborderimage/qquickborderimage.pro new file mode 100644 index 0000000000..f50149aead --- /dev/null +++ b/tests/auto/quick/qquickborderimage/qquickborderimage.pro @@ -0,0 +1,17 @@ +CONFIG += testcase +TARGET = tst_qquickborderimage +macx:CONFIG -= app_bundle + +HEADERS += ../../shared/testhttpserver.h +SOURCES += tst_qquickborderimage.cpp \ + ../../shared/testhttpserver.cpp + +include (../../shared/util.pri) + +testDataFiles.files = data +testDataFiles.path = . +DEPLOYMENT += testDataFiles + +CONFIG += parallel_test + +QT += core-private gui-private qml-private quick-private network widgets testlib diff --git a/tests/auto/quick/qquickborderimage/tst_qquickborderimage.cpp b/tests/auto/quick/qquickborderimage/tst_qquickborderimage.cpp new file mode 100644 index 0000000000..13b12f6020 --- /dev/null +++ b/tests/auto/quick/qquickborderimage/tst_qquickborderimage.cpp @@ -0,0 +1,373 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +#include "../../shared/testhttpserver.h" +#include "../../shared/util.h" + +#define SERVER_PORT 14446 +#define SERVER_ADDR "http://127.0.0.1:14446" + +class tst_qquickborderimage : public QQmlDataTest + +{ + Q_OBJECT +public: + tst_qquickborderimage(); + +private slots: + void noSource(); + void imageSource(); + void imageSource_data(); + void clearSource(); + void resized(); + void smooth(); + void mirror(); + void tileModes(); + void sciSource(); + void sciSource_data(); + void invalidSciFile(); + void pendingRemoteRequest(); + void pendingRemoteRequest_data(); + +private: + QQmlEngine engine; +}; + +tst_qquickborderimage::tst_qquickborderimage() +{ +} + +void tst_qquickborderimage::noSource() +{ + QString componentStr = "import QtQuick 2.0\nBorderImage { source: \"\" }"; + QQmlComponent component(&engine); + component.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); + QQuickBorderImage *obj = qobject_cast(component.create()); + QVERIFY(obj != 0); + QCOMPARE(obj->source(), QUrl()); + QCOMPARE(obj->width(), 0.); + QCOMPARE(obj->height(), 0.); + QCOMPARE(obj->horizontalTileMode(), QQuickBorderImage::Stretch); + QCOMPARE(obj->verticalTileMode(), QQuickBorderImage::Stretch); + + delete obj; +} + +void tst_qquickborderimage::imageSource_data() +{ + QTest::addColumn("source"); + QTest::addColumn("remote"); + QTest::addColumn("error"); + + QTest::newRow("local") << testFileUrl("colors.png").toString() << false << ""; + QTest::newRow("local not found") << testFileUrl("no-such-file.png").toString() << false + << "file::2:1: QML BorderImage: Cannot open: " + testFileUrl("no-such-file.png").toString(); + QTest::newRow("remote") << SERVER_ADDR "/colors.png" << true << ""; + QTest::newRow("remote not found") << SERVER_ADDR "/no-such-file.png" << true + << "file::2:1: QML BorderImage: Error downloading " SERVER_ADDR "/no-such-file.png - server replied: Not found"; +} + +void tst_qquickborderimage::imageSource() +{ + QFETCH(QString, source); + QFETCH(bool, remote); + QFETCH(QString, error); + + TestHTTPServer *server = 0; + if (remote) { + server = new TestHTTPServer(SERVER_PORT); + QVERIFY(server->isValid()); + server->serveDirectory(dataDirectory()); + } + + if (!error.isEmpty()) + QTest::ignoreMessage(QtWarningMsg, error.toUtf8()); + + QString componentStr = "import QtQuick 2.0\nBorderImage { source: \"" + source + "\" }"; + QQmlComponent component(&engine); + component.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); + QQuickBorderImage *obj = qobject_cast(component.create()); + QVERIFY(obj != 0); + + if (remote) + QTRY_VERIFY(obj->status() == QQuickBorderImage::Loading); + + QCOMPARE(obj->source(), remote ? source : QUrl(source)); + + if (error.isEmpty()) { + QTRY_VERIFY(obj->status() == QQuickBorderImage::Ready); + QCOMPARE(obj->width(), 120.); + QCOMPARE(obj->height(), 120.); + QCOMPARE(obj->sourceSize().width(), 120); + QCOMPARE(obj->sourceSize().height(), 120); + QCOMPARE(obj->horizontalTileMode(), QQuickBorderImage::Stretch); + QCOMPARE(obj->verticalTileMode(), QQuickBorderImage::Stretch); + } else { + QTRY_VERIFY(obj->status() == QQuickBorderImage::Error); + } + + delete obj; + delete server; +} + +void tst_qquickborderimage::clearSource() +{ + QString componentStr = "import QtQuick 2.0\nBorderImage { source: srcImage }"; + QQmlContext *ctxt = engine.rootContext(); + ctxt->setContextProperty("srcImage", testFileUrl("colors.png")); + QQmlComponent component(&engine); + component.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); + QQuickBorderImage *obj = qobject_cast(component.create()); + QVERIFY(obj != 0); + QVERIFY(obj->status() == QQuickBorderImage::Ready); + QCOMPARE(obj->width(), 120.); + QCOMPARE(obj->height(), 120.); + + ctxt->setContextProperty("srcImage", ""); + QVERIFY(obj->source().isEmpty()); + QVERIFY(obj->status() == QQuickBorderImage::Null); + QCOMPARE(obj->width(), 0.); + QCOMPARE(obj->height(), 0.); +} + +void tst_qquickborderimage::resized() +{ + QString componentStr = "import QtQuick 2.0\nBorderImage { source: \"" + testFileUrl("colors.png").toString() + "\"; width: 300; height: 300 }"; + QQmlComponent component(&engine); + component.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); + QQuickBorderImage *obj = qobject_cast(component.create()); + QVERIFY(obj != 0); + QCOMPARE(obj->width(), 300.); + QCOMPARE(obj->height(), 300.); + QCOMPARE(obj->sourceSize().width(), 120); + QCOMPARE(obj->sourceSize().height(), 120); + QCOMPARE(obj->horizontalTileMode(), QQuickBorderImage::Stretch); + QCOMPARE(obj->verticalTileMode(), QQuickBorderImage::Stretch); + + delete obj; +} + +void tst_qquickborderimage::smooth() +{ + QString componentStr = "import QtQuick 2.0\nBorderImage { source: \"" + testFile("colors.png") + "\"; smooth: true; width: 300; height: 300 }"; + QQmlComponent component(&engine); + component.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); + QQuickBorderImage *obj = qobject_cast(component.create()); + QVERIFY(obj != 0); + QCOMPARE(obj->width(), 300.); + QCOMPARE(obj->height(), 300.); + QCOMPARE(obj->smooth(), true); + QCOMPARE(obj->horizontalTileMode(), QQuickBorderImage::Stretch); + QCOMPARE(obj->verticalTileMode(), QQuickBorderImage::Stretch); + + delete obj; +} + +void tst_qquickborderimage::mirror() +{ + QQuickView *canvas = new QQuickView; + canvas->setSource(testFileUrl("mirror.qml")); + QQuickBorderImage *image = qobject_cast(canvas->rootObject()); + QVERIFY(image != 0); + + QImage screenshot = canvas->grabFrameBuffer(); + + QImage srcPixmap(screenshot); + QTransform transform; + transform.translate(image->width(), 0).scale(-1, 1.0); + srcPixmap = srcPixmap.transformed(transform); + + image->setProperty("mirror", true); + screenshot = canvas->grabFrameBuffer(); + QCOMPARE(screenshot, srcPixmap); + + delete canvas; +} + +void tst_qquickborderimage::tileModes() +{ + { + QString componentStr = "import QtQuick 2.0\nBorderImage { source: \"" + testFile("colors.png") + "\"; width: 100; height: 300; horizontalTileMode: BorderImage.Repeat; verticalTileMode: BorderImage.Repeat }"; + QQmlComponent component(&engine); + component.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); + QQuickBorderImage *obj = qobject_cast(component.create()); + QVERIFY(obj != 0); + QCOMPARE(obj->width(), 100.); + QCOMPARE(obj->height(), 300.); + QCOMPARE(obj->horizontalTileMode(), QQuickBorderImage::Repeat); + QCOMPARE(obj->verticalTileMode(), QQuickBorderImage::Repeat); + + delete obj; + } + { + QString componentStr = "import QtQuick 2.0\nBorderImage { source: \"" + testFile("colors.png") + "\"; width: 300; height: 150; horizontalTileMode: BorderImage.Round; verticalTileMode: BorderImage.Round }"; + QQmlComponent component(&engine); + component.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); + QQuickBorderImage *obj = qobject_cast(component.create()); + QVERIFY(obj != 0); + QCOMPARE(obj->width(), 300.); + QCOMPARE(obj->height(), 150.); + QCOMPARE(obj->horizontalTileMode(), QQuickBorderImage::Round); + QCOMPARE(obj->verticalTileMode(), QQuickBorderImage::Round); + + delete obj; + } +} + +void tst_qquickborderimage::sciSource() +{ + QFETCH(QString, source); + QFETCH(bool, valid); + + bool remote = source.startsWith("http"); + TestHTTPServer *server = 0; + if (remote) { + server = new TestHTTPServer(SERVER_PORT); + QVERIFY(server->isValid()); + server->serveDirectory(dataDirectory()); + } + + QString componentStr = "import QtQuick 2.0\nBorderImage { source: \"" + source + "\"; width: 300; height: 300 }"; + QQmlComponent component(&engine); + component.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); + QQuickBorderImage *obj = qobject_cast(component.create()); + QVERIFY(obj != 0); + + if (remote) + QTRY_VERIFY(obj->status() == QQuickBorderImage::Loading); + + QCOMPARE(obj->source(), remote ? source : QUrl(source)); + QCOMPARE(obj->width(), 300.); + QCOMPARE(obj->height(), 300.); + + if (valid) { + QTRY_VERIFY(obj->status() == QQuickBorderImage::Ready); + QCOMPARE(obj->border()->left(), 10); + QCOMPARE(obj->border()->top(), 20); + QCOMPARE(obj->border()->right(), 30); + QCOMPARE(obj->border()->bottom(), 40); + QCOMPARE(obj->horizontalTileMode(), QQuickBorderImage::Round); + QCOMPARE(obj->verticalTileMode(), QQuickBorderImage::Repeat); + } else { + QTRY_VERIFY(obj->status() == QQuickBorderImage::Error); + } + + delete obj; + delete server; +} + +void tst_qquickborderimage::sciSource_data() +{ + QTest::addColumn("source"); + QTest::addColumn("valid"); + + QTest::newRow("local") << testFileUrl("colors-round.sci").toString() << true; + QTest::newRow("local quoted filename") << testFileUrl("colors-round-quotes.sci").toString() << true; + QTest::newRow("local not found") << testFileUrl("no-such-file.sci").toString() << false; + QTest::newRow("remote") << SERVER_ADDR "/colors-round.sci" << true; + QTest::newRow("remote filename quoted") << SERVER_ADDR "/colors-round-quotes.sci" << true; + QTest::newRow("remote image") << SERVER_ADDR "/colors-round-remote.sci" << true; + QTest::newRow("remote not found") << SERVER_ADDR "/no-such-file.sci" << false; +} + +void tst_qquickborderimage::invalidSciFile() +{ + QTest::ignoreMessage(QtWarningMsg, "QQuickGridScaledImage: Invalid tile rule specified. Using Stretch."); // for "Roun" + QTest::ignoreMessage(QtWarningMsg, "QQuickGridScaledImage: Invalid tile rule specified. Using Stretch."); // for "Repea" + + QString componentStr = "import QtQuick 2.0\nBorderImage { source: \"" + testFileUrl("invalid.sci").toString() +"\"; width: 300; height: 300 }"; + QQmlComponent component(&engine); + component.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); + QQuickBorderImage *obj = qobject_cast(component.create()); + QVERIFY(obj != 0); + QCOMPARE(obj->width(), 300.); + QCOMPARE(obj->height(), 300.); + QCOMPARE(obj->status(), QQuickImageBase::Error); + QCOMPARE(obj->horizontalTileMode(), QQuickBorderImage::Stretch); + QCOMPARE(obj->verticalTileMode(), QQuickBorderImage::Stretch); + + delete obj; +} + +void tst_qquickborderimage::pendingRemoteRequest() +{ + QFETCH(QString, source); + + QString componentStr = "import QtQuick 2.0\nBorderImage { source: \"" + source + "\" }"; + QQmlComponent component(&engine); + component.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); + QQuickBorderImage *obj = qobject_cast(component.create()); + QVERIFY(obj != 0); + QCOMPARE(obj->status(), QQuickBorderImage::Loading); + + // verify no crash + // This will cause a delayed "QThread: Destroyed while thread is still running" warning + delete obj; + QTest::qWait(50); +} + +void tst_qquickborderimage::pendingRemoteRequest_data() +{ + QTest::addColumn("source"); + + QTest::newRow("png file") << "http://localhost/none.png"; + QTest::newRow("sci file") << "http://localhost/none.sci"; +} + +QTEST_MAIN(tst_qquickborderimage) + +#include "tst_qquickborderimage.moc" diff --git a/tests/auto/quick/qquickcanvas/data/AnimationsWhileHidden.qml b/tests/auto/quick/qquickcanvas/data/AnimationsWhileHidden.qml new file mode 100644 index 0000000000..e95b029210 --- /dev/null +++ b/tests/auto/quick/qquickcanvas/data/AnimationsWhileHidden.qml @@ -0,0 +1,17 @@ +import QtQuick 2.0 +import QtQuick.Window 2.0 as Window + +Window.Window +{ + id: win + visible: true + width: 250 + height: 250 + + SequentialAnimation { + PauseAnimation { duration: 500 } + PropertyAction { target: win; property: "visible"; value: true } + loops: Animation.Infinite + running: true + } +} diff --git a/tests/auto/quick/qquickcanvas/data/Headless.qml b/tests/auto/quick/qquickcanvas/data/Headless.qml new file mode 100644 index 0000000000..2e09cb1f24 --- /dev/null +++ b/tests/auto/quick/qquickcanvas/data/Headless.qml @@ -0,0 +1,33 @@ +import QtQuick 2.0 +import QtQuick.Window 2.0 as Window + +Window.Window { + + width: 300 + height: 200 + visible: true + + Text { + anchors.left: parent.left + anchors.top: parent.top + text: "Testing headless mode" + } + + Rectangle { + anchors.centerIn: parent + width: 100 + height: 50 + rotation: -30 + gradient: Gradient { + GradientStop { position: 0; color: "lightsteelblue" } + GradientStop { position: 1; color: "black" } + } + } + + Image { + source: "colors.png" + anchors.bottom: parent.bottom + anchors.right: parent.right + } + +} diff --git a/tests/auto/quick/qquickcanvas/data/colors.png b/tests/auto/quick/qquickcanvas/data/colors.png new file mode 100644 index 0000000000..dfb62f3d64 Binary files /dev/null and b/tests/auto/quick/qquickcanvas/data/colors.png differ diff --git a/tests/auto/quick/qquickcanvas/data/focus.qml b/tests/auto/quick/qquickcanvas/data/focus.qml new file mode 100644 index 0000000000..901f2fcf2e --- /dev/null +++ b/tests/auto/quick/qquickcanvas/data/focus.qml @@ -0,0 +1,11 @@ +import QtQuick 2.0 +import QtQuick.Window 2.0 as Window + +Window.Window { + Item { + objectName: "item1" + } + Item { + objectName: "item2" + } +} diff --git a/tests/auto/quick/qquickcanvas/data/window.qml b/tests/auto/quick/qquickcanvas/data/window.qml new file mode 100644 index 0000000000..d79d5161b5 --- /dev/null +++ b/tests/auto/quick/qquickcanvas/data/window.qml @@ -0,0 +1,9 @@ +import QtQuick 2.0 +import QtQuick.Window 2.0 as Window + +Window.Window { + color: "#00FF00" + Item { + objectName: "item" + } +} diff --git a/tests/auto/quick/qquickcanvas/qquickcanvas.pro b/tests/auto/quick/qquickcanvas/qquickcanvas.pro new file mode 100644 index 0000000000..7f27a05243 --- /dev/null +++ b/tests/auto/quick/qquickcanvas/qquickcanvas.pro @@ -0,0 +1,20 @@ +CONFIG += testcase +TARGET = tst_qquickcanvas +SOURCES += tst_qquickcanvas.cpp + +include (../../shared/util.pri) + +macx:CONFIG -= app_bundle + +CONFIG += parallel_test +QT += core-private gui-private qml-private quick-private testlib + +testData.files = data +testData.path = . +DEPLOYMENT += testData + +OTHER_FILES += \ + data/AnimationsWhileHidden.qml \ + data/Headless.qml + + diff --git a/tests/auto/quick/qquickcanvas/tst_qquickcanvas.cpp b/tests/auto/quick/qquickcanvas/tst_qquickcanvas.cpp new file mode 100644 index 0000000000..3a27d179c5 --- /dev/null +++ b/tests/auto/quick/qquickcanvas/tst_qquickcanvas.cpp @@ -0,0 +1,775 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "../../shared/util.h" +#include + +struct TouchEventData { + QEvent::Type type; + QWidget *widget; + QWindow *window; + Qt::TouchPointStates states; + QList touchPoints; +}; + +static QTouchEvent::TouchPoint makeTouchPoint(QQuickItem *item, const QPointF &p, const QPointF &lastPoint = QPointF()) +{ + QPointF last = lastPoint.isNull() ? p : lastPoint; + + QTouchEvent::TouchPoint tp; + + tp.setPos(p); + tp.setLastPos(last); + tp.setScenePos(item->mapToScene(p)); + tp.setLastScenePos(item->mapToScene(last)); + tp.setScreenPos(item->canvas()->mapToGlobal(tp.scenePos().toPoint())); + tp.setLastScreenPos(item->canvas()->mapToGlobal(tp.lastScenePos().toPoint())); + return tp; +} + +static TouchEventData makeTouchData(QEvent::Type type, QWindow *w, Qt::TouchPointStates states = 0, + const QList& touchPoints = QList()) +{ + TouchEventData d = { type, 0, w, states, touchPoints }; + return d; +} +static TouchEventData makeTouchData(QEvent::Type type, QWindow *w, Qt::TouchPointStates states, const QTouchEvent::TouchPoint &touchPoint) +{ + QList points; + points << touchPoint; + return makeTouchData(type, w, states, points); +} + +#define COMPARE_TOUCH_POINTS(tp1, tp2) \ +{ \ + QCOMPARE(tp1.pos(), tp2.pos()); \ + QCOMPARE(tp1.lastPos(), tp2.lastPos()); \ + QCOMPARE(tp1.scenePos(), tp2.scenePos()); \ + QCOMPARE(tp1.lastScenePos(), tp2.lastScenePos()); \ + QCOMPARE(tp1.screenPos(), tp2.screenPos()); \ + QCOMPARE(tp1.lastScreenPos(), tp2.lastScreenPos()); \ +} + +#define COMPARE_TOUCH_DATA(d1, d2) \ +{ \ + QCOMPARE((int)d1.type, (int)d2.type); \ + QCOMPARE(d1.widget, d2.widget); \ + QCOMPARE((int)d1.states, (int)d2.states); \ + QCOMPARE(d1.touchPoints.count(), d2.touchPoints.count()); \ + for (int i=0; isetWidth(1); + setAcceptedMouseButtons(Qt::LeftButton); + setFiltersChildMouseEvents(true); + } + + void reset() { + acceptEvents = true; + setEnabled(true); + setOpacity(1.0); + + lastEvent = makeTouchData(QEvent::None, canvas(), 0, QList());//CHECK_VALID + } + + static void clearMousePressCounter() + { + mousePressNum = 0; + } + + bool acceptEvents; + TouchEventData lastEvent; + int mousePressId; +protected: + virtual void touchEvent(QTouchEvent *event) { + if (!acceptEvents) { + event->ignore(); + return; + } + lastEvent = makeTouchData(event->type(), event->window(), event->touchPointStates(), event->touchPoints()); + event->accept(); + } + + virtual void mousePressEvent(QMouseEvent *) { + mousePressId = ++mousePressNum; + } + + bool childMouseEventFilter(QQuickItem *, QEvent *event) { + if (event->type() == QEvent::MouseButtonPress) + mousePressId = ++mousePressNum; + return false; + } + + static int mousePressNum; +}; + +int TestTouchItem::mousePressNum = 0; + +class ConstantUpdateItem : public QQuickItem +{ +Q_OBJECT +public: + ConstantUpdateItem(QQuickItem *parent = 0) : QQuickItem(parent), iterations(0) {setFlag(ItemHasContents);} + + int iterations; +protected: + QSGNode* updatePaintNode(QSGNode *, UpdatePaintNodeData *){ + iterations++; + update(); + return 0; + } +}; + +class tst_qquickcanvas : public QQmlDataTest +{ + Q_OBJECT +public: + +private slots: + void initTestCase() + { + QQmlDataTest::initTestCase(); + touchDevice = new QTouchDevice(); + touchDevice->setType(QTouchDevice::TouchScreen); + QWindowSystemInterface::registerTouchDevice(touchDevice); + } + + + void constantUpdates(); + void mouseFiltering(); + void headless(); + + void touchEvent_basic(); + void touchEvent_propagation(); + void touchEvent_propagation_data(); + void touchEvent_cancel(); + + void clearCanvas(); + + void qmlCreation(); + void clearColor(); + + void grab(); + void multipleWindows(); + + void animationsWhileHidden(); + + void focusObject(); + + void ignoreUnhandledMouseEvents(); + +private: + QTouchDevice *touchDevice; +}; + +//If the item calls update inside updatePaintNode, it should schedule another update +void tst_qquickcanvas::constantUpdates() +{ + QQuickCanvas canvas; + canvas.resize(250, 250); + ConstantUpdateItem item(canvas.rootItem()); + canvas.show(); + QTRY_VERIFY(item.iterations > 60); +} + +void tst_qquickcanvas::touchEvent_basic() +{ + TestTouchItem::clearMousePressCounter(); + + QQuickCanvas *canvas = new QQuickCanvas; + canvas->resize(250, 250); + canvas->move(100, 100); + canvas->show(); + + TestTouchItem *bottomItem = new TestTouchItem(canvas->rootItem()); + bottomItem->setObjectName("Bottom Item"); + bottomItem->setSize(QSizeF(150, 150)); + + TestTouchItem *middleItem = new TestTouchItem(bottomItem); + middleItem->setObjectName("Middle Item"); + middleItem->setPos(QPointF(50, 50)); + middleItem->setSize(QSizeF(150, 150)); + + TestTouchItem *topItem = new TestTouchItem(middleItem); + topItem->setObjectName("Top Item"); + topItem->setPos(QPointF(50, 50)); + topItem->setSize(QSizeF(150, 150)); + + QPointF pos(10, 10); + + // press single point + QTest::touchEvent(canvas, touchDevice).press(0, topItem->mapToScene(pos).toPoint(),canvas); + QTest::qWait(50); + + QCOMPARE(topItem->lastEvent.touchPoints.count(), 1); + + QVERIFY(middleItem->lastEvent.touchPoints.isEmpty()); + QVERIFY(bottomItem->lastEvent.touchPoints.isEmpty()); + TouchEventData d = makeTouchData(QEvent::TouchBegin, canvas, Qt::TouchPointPressed, makeTouchPoint(topItem,pos)); + COMPARE_TOUCH_DATA(topItem->lastEvent, makeTouchData(QEvent::TouchBegin, canvas, Qt::TouchPointPressed, makeTouchPoint(topItem, pos))); + topItem->reset(); + + // press multiple points + QTest::touchEvent(canvas, touchDevice).press(0, topItem->mapToScene(pos).toPoint(),canvas) + .press(1, bottomItem->mapToScene(pos).toPoint(), canvas); + QTest::qWait(50); + QCOMPARE(topItem->lastEvent.touchPoints.count(), 1); + QVERIFY(middleItem->lastEvent.touchPoints.isEmpty()); + QCOMPARE(bottomItem->lastEvent.touchPoints.count(), 1); + COMPARE_TOUCH_DATA(topItem->lastEvent, makeTouchData(QEvent::TouchBegin, canvas, Qt::TouchPointPressed, makeTouchPoint(topItem, pos))); + COMPARE_TOUCH_DATA(bottomItem->lastEvent, makeTouchData(QEvent::TouchBegin, canvas, Qt::TouchPointPressed, makeTouchPoint(bottomItem, pos))); + topItem->reset(); + bottomItem->reset(); + + // touch point on top item moves to bottom item, but top item should still receive the event + QTest::touchEvent(canvas, touchDevice).press(0, topItem->mapToScene(pos).toPoint(), canvas); + QTest::qWait(50); + QTest::touchEvent(canvas, touchDevice).move(0, bottomItem->mapToScene(pos).toPoint(), canvas); + QTest::qWait(50); + QCOMPARE(topItem->lastEvent.touchPoints.count(), 1); + COMPARE_TOUCH_DATA(topItem->lastEvent, makeTouchData(QEvent::TouchUpdate, canvas, Qt::TouchPointMoved, + makeTouchPoint(topItem, topItem->mapFromItem(bottomItem, pos), pos))); + topItem->reset(); + + // touch point on bottom item moves to top item, but bottom item should still receive the event + QTest::touchEvent(canvas, touchDevice).press(0, bottomItem->mapToScene(pos).toPoint(), canvas); + QTest::qWait(50); + QTest::touchEvent(canvas, touchDevice).move(0, topItem->mapToScene(pos).toPoint(), canvas); + QTest::qWait(50); + QCOMPARE(bottomItem->lastEvent.touchPoints.count(), 1); + COMPARE_TOUCH_DATA(bottomItem->lastEvent, makeTouchData(QEvent::TouchUpdate, canvas, Qt::TouchPointMoved, + makeTouchPoint(bottomItem, bottomItem->mapFromItem(topItem, pos), pos))); + bottomItem->reset(); + + // a single stationary press on an item shouldn't cause an event + QTest::touchEvent(canvas, touchDevice).press(0, topItem->mapToScene(pos).toPoint(), canvas); + QTest::qWait(50); + QTest::touchEvent(canvas, touchDevice).stationary(0) + .press(1, bottomItem->mapToScene(pos).toPoint(), canvas); + QTest::qWait(50); + QCOMPARE(topItem->lastEvent.touchPoints.count(), 1); // received press only, not stationary + QVERIFY(middleItem->lastEvent.touchPoints.isEmpty()); + QCOMPARE(bottomItem->lastEvent.touchPoints.count(), 1); + COMPARE_TOUCH_DATA(topItem->lastEvent, makeTouchData(QEvent::TouchBegin, canvas, Qt::TouchPointPressed, makeTouchPoint(topItem, pos))); + COMPARE_TOUCH_DATA(bottomItem->lastEvent, makeTouchData(QEvent::TouchBegin, canvas, Qt::TouchPointPressed, makeTouchPoint(bottomItem, pos))); + topItem->reset(); + bottomItem->reset(); + + // move touch point from top item to bottom, and release + QTest::touchEvent(canvas, touchDevice).press(0, topItem->mapToScene(pos).toPoint(),canvas); + QTest::qWait(50); + QTest::touchEvent(canvas, touchDevice).release(0, bottomItem->mapToScene(pos).toPoint(),canvas); + QTest::qWait(50); + QCOMPARE(topItem->lastEvent.touchPoints.count(), 1); + COMPARE_TOUCH_DATA(topItem->lastEvent, makeTouchData(QEvent::TouchEnd, canvas, Qt::TouchPointReleased, + makeTouchPoint(topItem, topItem->mapFromItem(bottomItem, pos), pos))); + topItem->reset(); + + // release while another point is pressed + QTest::touchEvent(canvas, touchDevice).press(0, topItem->mapToScene(pos).toPoint(),canvas) + .press(1, bottomItem->mapToScene(pos).toPoint(), canvas); + QTest::qWait(50); + QTest::touchEvent(canvas, touchDevice).move(0, bottomItem->mapToScene(pos).toPoint(), canvas); + QTest::qWait(50); + QTest::touchEvent(canvas, touchDevice).release(0, bottomItem->mapToScene(pos).toPoint(), canvas) + .stationary(1); + QTest::qWait(50); + QCOMPARE(topItem->lastEvent.touchPoints.count(), 1); + QVERIFY(middleItem->lastEvent.touchPoints.isEmpty()); + QCOMPARE(bottomItem->lastEvent.touchPoints.count(), 1); + COMPARE_TOUCH_DATA(topItem->lastEvent, makeTouchData(QEvent::TouchEnd, canvas, Qt::TouchPointReleased, + makeTouchPoint(topItem, topItem->mapFromItem(bottomItem, pos)))); + COMPARE_TOUCH_DATA(bottomItem->lastEvent, makeTouchData(QEvent::TouchBegin, canvas, Qt::TouchPointPressed, makeTouchPoint(bottomItem, pos))); + topItem->reset(); + bottomItem->reset(); + + delete topItem; + delete middleItem; + delete bottomItem; + delete canvas; +} + +void tst_qquickcanvas::touchEvent_propagation() +{ + TestTouchItem::clearMousePressCounter(); + + QFETCH(bool, acceptEvents); + QFETCH(bool, enableItem); + QFETCH(qreal, itemOpacity); + + QQuickCanvas *canvas = new QQuickCanvas; + canvas->resize(250, 250); + canvas->move(100, 100); + canvas->show(); + + TestTouchItem *bottomItem = new TestTouchItem(canvas->rootItem()); + bottomItem->setObjectName("Bottom Item"); + bottomItem->setSize(QSizeF(150, 150)); + + TestTouchItem *middleItem = new TestTouchItem(bottomItem); + middleItem->setObjectName("Middle Item"); + middleItem->setPos(QPointF(50, 50)); + middleItem->setSize(QSizeF(150, 150)); + + TestTouchItem *topItem = new TestTouchItem(middleItem); + topItem->setObjectName("Top Item"); + topItem->setPos(QPointF(50, 50)); + topItem->setSize(QSizeF(150, 150)); + + QPointF pos(10, 10); + QPoint pointInBottomItem = bottomItem->mapToScene(pos).toPoint(); // (10, 10) + QPoint pointInMiddleItem = middleItem->mapToScene(pos).toPoint(); // (60, 60) overlaps with bottomItem + QPoint pointInTopItem = topItem->mapToScene(pos).toPoint(); // (110, 110) overlaps with bottom & top items + + // disable topItem + topItem->acceptEvents = acceptEvents; + topItem->setEnabled(enableItem); + topItem->setOpacity(itemOpacity); + + // single touch to top item, should be received by middle item + QTest::touchEvent(canvas, touchDevice).press(0, pointInTopItem, canvas); + QTest::qWait(50); + QVERIFY(topItem->lastEvent.touchPoints.isEmpty()); + QCOMPARE(middleItem->lastEvent.touchPoints.count(), 1); + QVERIFY(bottomItem->lastEvent.touchPoints.isEmpty()); + COMPARE_TOUCH_DATA(middleItem->lastEvent, makeTouchData(QEvent::TouchBegin, canvas, Qt::TouchPointPressed, + makeTouchPoint(middleItem, middleItem->mapFromItem(topItem, pos)))); + + // touch top and middle items, middle item should get both events + QTest::touchEvent(canvas, touchDevice).press(0, pointInTopItem, canvas) + .press(1, pointInMiddleItem, canvas); + QTest::qWait(50); + QVERIFY(topItem->lastEvent.touchPoints.isEmpty()); + QCOMPARE(middleItem->lastEvent.touchPoints.count(), 2); + QVERIFY(bottomItem->lastEvent.touchPoints.isEmpty()); + COMPARE_TOUCH_DATA(middleItem->lastEvent, makeTouchData(QEvent::TouchBegin, canvas, Qt::TouchPointPressed, + (QList() << makeTouchPoint(middleItem, middleItem->mapFromItem(topItem, pos)) + << makeTouchPoint(middleItem, pos) ))); + middleItem->reset(); + + // disable middleItem as well + middleItem->acceptEvents = acceptEvents; + middleItem->setEnabled(enableItem); + middleItem->setOpacity(itemOpacity); + + // touch top and middle items, bottom item should get all events + QTest::touchEvent(canvas, touchDevice).press(0, pointInTopItem, canvas) + .press(1, pointInMiddleItem, canvas); + QTest::qWait(50); + QVERIFY(topItem->lastEvent.touchPoints.isEmpty()); + QVERIFY(middleItem->lastEvent.touchPoints.isEmpty()); + QCOMPARE(bottomItem->lastEvent.touchPoints.count(), 2); + COMPARE_TOUCH_DATA(bottomItem->lastEvent, makeTouchData(QEvent::TouchBegin, canvas, Qt::TouchPointPressed, + (QList() << makeTouchPoint(bottomItem, bottomItem->mapFromItem(topItem, pos)) + << makeTouchPoint(bottomItem, bottomItem->mapFromItem(middleItem, pos)) ))); + bottomItem->reset(); + + // disable bottom item as well + bottomItem->acceptEvents = acceptEvents; + bottomItem->setEnabled(enableItem); + bottomItem->setOpacity(itemOpacity); + + // no events should be received + QTest::touchEvent(canvas, touchDevice).press(0, pointInTopItem, canvas) + .press(1, pointInMiddleItem, canvas) + .press(2, pointInBottomItem, canvas); + QTest::qWait(50); + QVERIFY(topItem->lastEvent.touchPoints.isEmpty()); + QVERIFY(middleItem->lastEvent.touchPoints.isEmpty()); + QVERIFY(bottomItem->lastEvent.touchPoints.isEmpty()); + + topItem->reset(); + middleItem->reset(); + bottomItem->reset(); + + // disable middle item, touch on top item + middleItem->acceptEvents = acceptEvents; + middleItem->setEnabled(enableItem); + middleItem->setOpacity(itemOpacity); + QTest::touchEvent(canvas, touchDevice).press(0, pointInTopItem, canvas); + QTest::qWait(50); + if (!enableItem || itemOpacity == 0) { + // middle item is disabled or has 0 opacity, bottom item receives the event + QVERIFY(topItem->lastEvent.touchPoints.isEmpty()); + QVERIFY(middleItem->lastEvent.touchPoints.isEmpty()); + QCOMPARE(bottomItem->lastEvent.touchPoints.count(), 1); + COMPARE_TOUCH_DATA(bottomItem->lastEvent, makeTouchData(QEvent::TouchBegin, canvas, Qt::TouchPointPressed, + makeTouchPoint(bottomItem, bottomItem->mapFromItem(topItem, pos)))); + } else { + // middle item ignores event, sends it to the top item (top-most child) + QCOMPARE(topItem->lastEvent.touchPoints.count(), 1); + QVERIFY(middleItem->lastEvent.touchPoints.isEmpty()); + QVERIFY(bottomItem->lastEvent.touchPoints.isEmpty()); + COMPARE_TOUCH_DATA(topItem->lastEvent, makeTouchData(QEvent::TouchBegin, canvas, Qt::TouchPointPressed, + makeTouchPoint(topItem, pos))); + } + + delete topItem; + delete middleItem; + delete bottomItem; + delete canvas; +} + +void tst_qquickcanvas::touchEvent_propagation_data() +{ + QTest::addColumn("acceptEvents"); + QTest::addColumn("enableItem"); + QTest::addColumn("itemOpacity"); + + QTest::newRow("disable events") << false << true << 1.0; + QTest::newRow("disable item") << true << false << 1.0; + QTest::newRow("opacity of 0") << true << true << 0.0; +} + +void tst_qquickcanvas::touchEvent_cancel() +{ + TestTouchItem::clearMousePressCounter(); + + QQuickCanvas *canvas = new QQuickCanvas; + canvas->resize(250, 250); + canvas->move(100, 100); + canvas->show(); + + TestTouchItem *item = new TestTouchItem(canvas->rootItem()); + item->setPos(QPointF(50, 50)); + item->setSize(QSizeF(150, 150)); + + QPointF pos(10, 10); + QTest::touchEvent(canvas, touchDevice).press(0, item->mapToScene(pos).toPoint(),canvas); + QCoreApplication::processEvents(); + + QTRY_COMPARE(item->lastEvent.touchPoints.count(), 1); + TouchEventData d = makeTouchData(QEvent::TouchBegin, canvas, Qt::TouchPointPressed, makeTouchPoint(item,pos)); + COMPARE_TOUCH_DATA(item->lastEvent, d); + item->reset(); + + QWindowSystemInterface::handleTouchCancelEvent(0, touchDevice); + QCoreApplication::processEvents(); + d = makeTouchData(QEvent::TouchCancel, canvas); + COMPARE_TOUCH_DATA(item->lastEvent, d); + + delete item; + delete canvas; +} + +void tst_qquickcanvas::clearCanvas() +{ + QQuickCanvas *canvas = new QQuickCanvas; + QQuickItem *item = new QQuickItem; + item->setParentItem(canvas->rootItem()); + + QVERIFY(item->canvas() == canvas); + + delete canvas; + + QVERIFY(item->canvas() == 0); + + delete item; +} + +void tst_qquickcanvas::mouseFiltering() +{ + TestTouchItem::clearMousePressCounter(); + + QQuickCanvas *canvas = new QQuickCanvas; + canvas->resize(250, 250); + canvas->move(100, 100); + canvas->show(); + + TestTouchItem *bottomItem = new TestTouchItem(canvas->rootItem()); + bottomItem->setObjectName("Bottom Item"); + bottomItem->setSize(QSizeF(150, 150)); + + TestTouchItem *middleItem = new TestTouchItem(bottomItem); + middleItem->setObjectName("Middle Item"); + middleItem->setPos(QPointF(50, 50)); + middleItem->setSize(QSizeF(150, 150)); + + TestTouchItem *topItem = new TestTouchItem(middleItem); + topItem->setObjectName("Top Item"); + topItem->setPos(QPointF(50, 50)); + topItem->setSize(QSizeF(150, 150)); + + QPoint pos(100, 100); + + QTest::mousePress(canvas, Qt::LeftButton, 0, pos); + + // Mouse filtering propagates down the stack, so the + // correct order is + // 1. middleItem filters event + // 2. bottomItem filters event + // 3. topItem receives event + QTRY_COMPARE(middleItem->mousePressId, 1); + QTRY_COMPARE(bottomItem->mousePressId, 2); + QTRY_COMPARE(topItem->mousePressId, 3); + + delete canvas; +} + +void tst_qquickcanvas::qmlCreation() +{ + QQmlEngine engine; + QQmlComponent component(&engine); + component.loadUrl(testFileUrl("window.qml")); + QObject* created = component.create(); + QVERIFY(created); + + QQuickCanvas* canvas = qobject_cast(created); + QVERIFY(canvas); + QCOMPARE(canvas->clearColor(), QColor(Qt::green)); + + QQuickItem* item = canvas->findChild("item"); + QVERIFY(item); + QCOMPARE(item->canvas(), canvas); + + delete canvas; +} + +void tst_qquickcanvas::clearColor() +{ + //### Can we examine rendering to make sure it is really blue? + QQuickCanvas *canvas = new QQuickCanvas; + canvas->resize(250, 250); + canvas->move(100, 100); + canvas->setClearColor(Qt::blue); + canvas->show(); + QTest::qWaitForWindowShown(canvas); + QCOMPARE(canvas->clearColor(), QColor(Qt::blue)); + delete canvas; +} + +void tst_qquickcanvas::grab() +{ + QQuickCanvas canvas; + canvas.setClearColor(Qt::red); + + canvas.resize(250, 250); + canvas.show(); + + QTest::qWaitForWindowShown(&canvas); + + QImage content = canvas.grabFrameBuffer(); + QCOMPARE(content.width(), canvas.width()); + QCOMPARE(content.height(), canvas.height()); + QCOMPARE((uint) content.convertToFormat(QImage::Format_RGB32).pixel(0, 0), (uint) 0xffff0000); +} + +void tst_qquickcanvas::multipleWindows() +{ + QList windows; + for (int i=0; i<6; ++i) { + QQuickCanvas *c = new QQuickCanvas(); + c->setClearColor(Qt::GlobalColor(Qt::red + i)); + c->resize(300, 200); + c->setPos(100 + i * 30, 100 + i * 20); + c->show(); + windows << c; + QVERIFY(c->visible()); + } + + // move them + for (int i=0; isetPos(c->x() - 10, c->y() - 10); + } + + // resize them + for (int i=0; iresize(200, 150); + } + + qDeleteAll(windows); +} + +void tst_qquickcanvas::animationsWhileHidden() +{ + QQmlEngine engine; + QQmlComponent component(&engine); + component.loadUrl(testFileUrl("AnimationsWhileHidden.qml")); + QObject* created = component.create(); + + QQuickCanvas* canvas = qobject_cast(created); + QVERIFY(canvas); + QVERIFY(canvas->visible()); + + // Now hide the window and verify that it went off screen + canvas->hide(); + QTest::qWait(10); + QVERIFY(!canvas->visible()); + + // Running animaiton should cause it to become visible again shortly. + QTRY_VERIFY(canvas->visible()); + + delete canvas; +} + + +void tst_qquickcanvas::headless() +{ + QQmlEngine engine; + QQmlComponent component(&engine); + component.loadUrl(testFileUrl("Headless.qml")); + QObject* created = component.create(); + + QQuickCanvas* canvas = qobject_cast(created); + QVERIFY(canvas); + + QTest::qWaitForWindowShown(canvas); + QVERIFY(canvas->visible()); + + QSignalSpy initialized(canvas, SIGNAL(sceneGraphInitialized())); + QSignalSpy invalidated(canvas, SIGNAL(sceneGraphInvalidated())); + + // Verify that the canvas is alive and kicking + QVERIFY(canvas->openglContext() != 0); + + // Store the visual result + QImage originalContent = canvas->grabFrameBuffer(); + + // Hide the canvas and verify signal emittion and GL context deletion + canvas->hide(); + canvas->releaseResources(); + + QTRY_COMPARE(invalidated.size(), 1); + QVERIFY(canvas->openglContext() == 0); + + // Destroy the native windowing system buffers + canvas->destroy(); + QVERIFY(canvas->handle() == 0); + + // Show and verify that we are back and running + canvas->show(); + QTest::qWaitForWindowShown(canvas); + + QCOMPARE(initialized.size(), 1); + QVERIFY(canvas->openglContext() != 0); + + // Verify that the visual output is the same + QImage newContent = canvas->grabFrameBuffer(); + + QCOMPARE(originalContent, newContent); + + delete canvas; +} + +void tst_qquickcanvas::focusObject() +{ + QQmlEngine engine; + QQmlComponent component(&engine); + component.loadUrl(testFileUrl("focus.qml")); + QObject *created = component.create(); + QVERIFY(created); + + QQuickCanvas *canvas = qobject_cast(created); + QVERIFY(canvas); + + QQuickItem *item1 = canvas->findChild("item1"); + QVERIFY(item1); + item1->setFocus(true); + QCOMPARE(item1, canvas->focusObject()); + + QQuickItem *item2 = canvas->findChild("item2"); + QVERIFY(item2); + item2->setFocus(true); + QCOMPARE(item2, canvas->focusObject()); + + delete canvas; +} + +void tst_qquickcanvas::ignoreUnhandledMouseEvents() +{ + QQuickCanvas* canvas = new QQuickCanvas; + canvas->resize(100, 100); + canvas->show(); + + QQuickItem* item = new QQuickItem; + item->setSize(QSizeF(100, 100)); + item->setParentItem(canvas->rootItem()); + + { + QMouseEvent me(QEvent::MouseButtonPress, QPointF(50, 50), Qt::LeftButton, Qt::LeftButton, + Qt::NoModifier); + me.setAccepted(true); + QVERIFY(QCoreApplication::sendEvent(canvas, &me)); + QVERIFY(!me.isAccepted()); + } + + { + QMouseEvent me(QEvent::MouseMove, QPointF(51, 51), Qt::LeftButton, Qt::LeftButton, + Qt::NoModifier); + me.setAccepted(true); + QVERIFY(QCoreApplication::sendEvent(canvas, &me)); + QVERIFY(!me.isAccepted()); + } + + { + QMouseEvent me(QEvent::MouseButtonRelease, QPointF(51, 51), Qt::LeftButton, Qt::LeftButton, + Qt::NoModifier); + me.setAccepted(true); + QVERIFY(QCoreApplication::sendEvent(canvas, &me)); + QVERIFY(!me.isAccepted()); + } + + delete canvas; +} + +QTEST_MAIN(tst_qquickcanvas) + +#include "tst_qquickcanvas.moc" diff --git a/tests/auto/quick/qquickcanvasitem/data/anim-gr.gif b/tests/auto/quick/qquickcanvasitem/data/anim-gr.gif new file mode 100644 index 0000000000..45263e0afb Binary files /dev/null and b/tests/auto/quick/qquickcanvasitem/data/anim-gr.gif differ diff --git a/tests/auto/quick/qquickcanvasitem/data/anim-gr.png b/tests/auto/quick/qquickcanvasitem/data/anim-gr.png new file mode 100644 index 0000000000..925e2efc9a Binary files /dev/null and b/tests/auto/quick/qquickcanvasitem/data/anim-gr.png differ diff --git a/tests/auto/quick/qquickcanvasitem/data/anim-poster-gr.png b/tests/auto/quick/qquickcanvasitem/data/anim-poster-gr.png new file mode 100644 index 0000000000..6941207373 Binary files /dev/null and b/tests/auto/quick/qquickcanvasitem/data/anim-poster-gr.png differ diff --git a/tests/auto/quick/qquickcanvasitem/data/background.png b/tests/auto/quick/qquickcanvasitem/data/background.png new file mode 100644 index 0000000000..6db6c6b1b9 Binary files /dev/null and b/tests/auto/quick/qquickcanvasitem/data/background.png differ diff --git a/tests/auto/quick/qquickcanvasitem/data/broken.png b/tests/auto/quick/qquickcanvasitem/data/broken.png new file mode 100644 index 0000000000..f2581017b4 Binary files /dev/null and b/tests/auto/quick/qquickcanvasitem/data/broken.png differ diff --git a/tests/auto/quick/qquickcanvasitem/data/ggrr-256x256.png b/tests/auto/quick/qquickcanvasitem/data/ggrr-256x256.png new file mode 100644 index 0000000000..0342e4a384 Binary files /dev/null and b/tests/auto/quick/qquickcanvasitem/data/ggrr-256x256.png differ diff --git a/tests/auto/quick/qquickcanvasitem/data/green-16x16.png b/tests/auto/quick/qquickcanvasitem/data/green-16x16.png new file mode 100644 index 0000000000..e19a3ffddd Binary files /dev/null and b/tests/auto/quick/qquickcanvasitem/data/green-16x16.png differ diff --git a/tests/auto/quick/qquickcanvasitem/data/green-1x1.png b/tests/auto/quick/qquickcanvasitem/data/green-1x1.png new file mode 100644 index 0000000000..862d1dd10c Binary files /dev/null and b/tests/auto/quick/qquickcanvasitem/data/green-1x1.png differ diff --git a/tests/auto/quick/qquickcanvasitem/data/green-256x256.png b/tests/auto/quick/qquickcanvasitem/data/green-256x256.png new file mode 100644 index 0000000000..b06945c310 Binary files /dev/null and b/tests/auto/quick/qquickcanvasitem/data/green-256x256.png differ diff --git a/tests/auto/quick/qquickcanvasitem/data/green-2x2.png b/tests/auto/quick/qquickcanvasitem/data/green-2x2.png new file mode 100644 index 0000000000..adc059449c Binary files /dev/null and b/tests/auto/quick/qquickcanvasitem/data/green-2x2.png differ diff --git a/tests/auto/quick/qquickcanvasitem/data/green.png b/tests/auto/quick/qquickcanvasitem/data/green.png new file mode 100644 index 0000000000..28a1faab37 Binary files /dev/null and b/tests/auto/quick/qquickcanvasitem/data/green.png differ diff --git a/tests/auto/quick/qquickcanvasitem/data/grgr-256x256.png b/tests/auto/quick/qquickcanvasitem/data/grgr-256x256.png new file mode 100644 index 0000000000..b8c7189d62 Binary files /dev/null and b/tests/auto/quick/qquickcanvasitem/data/grgr-256x256.png differ diff --git a/tests/auto/quick/qquickcanvasitem/data/red-16x16.png b/tests/auto/quick/qquickcanvasitem/data/red-16x16.png new file mode 100644 index 0000000000..9038fef784 Binary files /dev/null and b/tests/auto/quick/qquickcanvasitem/data/red-16x16.png differ diff --git a/tests/auto/quick/qquickcanvasitem/data/red.png b/tests/auto/quick/qquickcanvasitem/data/red.png new file mode 100644 index 0000000000..a6e195d59c Binary files /dev/null and b/tests/auto/quick/qquickcanvasitem/data/red.png differ diff --git a/tests/auto/quick/qquickcanvasitem/data/redtransparent.png b/tests/auto/quick/qquickcanvasitem/data/redtransparent.png new file mode 100644 index 0000000000..75da08c3d6 Binary files /dev/null and b/tests/auto/quick/qquickcanvasitem/data/redtransparent.png differ diff --git a/tests/auto/quick/qquickcanvasitem/data/rgrg-256x256.png b/tests/auto/quick/qquickcanvasitem/data/rgrg-256x256.png new file mode 100644 index 0000000000..e6fba3daa5 Binary files /dev/null and b/tests/auto/quick/qquickcanvasitem/data/rgrg-256x256.png differ diff --git a/tests/auto/quick/qquickcanvasitem/data/rrgg-256x256.png b/tests/auto/quick/qquickcanvasitem/data/rrgg-256x256.png new file mode 100644 index 0000000000..7f63515654 Binary files /dev/null and b/tests/auto/quick/qquickcanvasitem/data/rrgg-256x256.png differ diff --git a/tests/auto/quick/qquickcanvasitem/data/testhelper.js b/tests/auto/quick/qquickcanvasitem/data/testhelper.js new file mode 100644 index 0000000000..bac0210e16 --- /dev/null +++ b/tests/auto/quick/qquickcanvasitem/data/testhelper.js @@ -0,0 +1,18 @@ +function comparePixel(ctx,x,y,r,g,b,a, d) +{ + var c = ctx.getImageData(x,y,1,1).data; + if (d === undefined) + d = 0; + r = Math.round(r); + g = Math.round(g); + b = Math.round(b); + a = Math.round(a); + + if (Math.abs(c[0]-r)>d || Math.abs(c[1]-g)>d || Math.abs(c[2]-b)>d || Math.abs(c[3]-a)>d) { + console.log('Pixel compare fail:\nactual :[' + c[0]+','+c[1]+','+c[2]+','+c[3] + ']\nexpected:['+r+','+g+','+b+','+a+'] +/- '+d); + return false; + } + return true; +} + + diff --git a/tests/auto/quick/qquickcanvasitem/data/transparent.png b/tests/auto/quick/qquickcanvasitem/data/transparent.png new file mode 100644 index 0000000000..2b498699a8 Binary files /dev/null and b/tests/auto/quick/qquickcanvasitem/data/transparent.png differ diff --git a/tests/auto/quick/qquickcanvasitem/data/transparent50.png b/tests/auto/quick/qquickcanvasitem/data/transparent50.png new file mode 100644 index 0000000000..55f8e69325 Binary files /dev/null and b/tests/auto/quick/qquickcanvasitem/data/transparent50.png differ diff --git a/tests/auto/quick/qquickcanvasitem/data/tst_arc.qml b/tests/auto/quick/qquickcanvasitem/data/tst_arc.qml new file mode 100644 index 0000000000..6006a5a4c0 --- /dev/null +++ b/tests/auto/quick/qquickcanvasitem/data/tst_arc.qml @@ -0,0 +1,487 @@ +import QtQuick 2.0 +import QtTest 1.0 +import "testhelper.js" as Helper + +Canvas { + id:canvas; width:100;height:50; renderTarget: Canvas.Image + TestCase { + name: "arc"; when: windowShown + function test_angle_1() { + var ctx = canvas.getContext('2d'); + ctx.reset(); + + ctx.fillStyle = '#0f0'; + ctx.fillRect(0, 0, 100, 50); + ctx.fillStyle = '#f00'; + ctx.beginPath(); + ctx.moveTo(100, 0); + ctx.arc(100, 0, 150, Math.PI/2, -Math.PI, true); + ctx.fill(); + verify(Helper.comparePixel(ctx,50,25, 0,255,0,255)); + } + function test_angle_2() { + var ctx = canvas.getContext('2d'); + ctx.reset(); + + ctx.fillStyle = '#0f0'; + ctx.fillRect(0, 0, 100, 50); + ctx.fillStyle = '#f00'; + ctx.beginPath(); + ctx.moveTo(100, 0); + ctx.arc(100, 0, 150, -3*Math.PI/2, -Math.PI, true); + ctx.fill(); + verify(Helper.comparePixel(ctx,50,25, 0,255,0,255)); + } + function test_angle_3() { + var ctx = canvas.getContext('2d'); + ctx.reset(); + ctx.fillStyle = '#0f0'; + ctx.fillRect(0, 0, 100, 50); + ctx.fillStyle = '#f00'; + ctx.beginPath(); + ctx.moveTo(100, 0); + ctx.arc(100, 0, 150, (512+1/2)*Math.PI, (1024-1)*Math.PI, true); + ctx.fill(); + //verify(Helper.comparePixel(ctx,50,25, 0,255,0,255)); + } + function test_angle_4() { + var ctx = canvas.getContext('2d'); + ctx.reset(); + + ctx.fillStyle = '#f00'; + ctx.fillRect(0, 0, 100, 50); + ctx.fillStyle = '#0f0'; + ctx.beginPath(); + ctx.moveTo(50, 25); + ctx.arc(50, 25, 60, (512+1/2)*Math.PI, (1024-1)*Math.PI, false); + ctx.fill(); + verify(Helper.comparePixel(ctx,1,1, 0,255,0,255)); + verify(Helper.comparePixel(ctx,98,1, 0,255,0,255)); + verify(Helper.comparePixel(ctx,1,48, 0,255,0,255)); + verify(Helper.comparePixel(ctx,98,48, 0,255,0,255)); + } + function test_angle_5() { + var ctx = canvas.getContext('2d'); + ctx.reset(); + + ctx.fillStyle = '#0f0'; + ctx.fillRect(0, 0, 100, 50); + ctx.fillStyle = '#f00'; + ctx.beginPath(); + ctx.moveTo(100, 0); + ctx.arc(100, 0, 150, (1024-1)*Math.PI, (512+1/2)*Math.PI, false); + ctx.fill(); + /*FIXME: + actual :[255,0,0,255] + expected:[0,255,0,255] +/- 0 + */ + //verify(Helper.comparePixel(ctx,50,25, 0,255,0,255)); + } + + function test_angle_6() { + var ctx = canvas.getContext('2d'); + ctx.reset(); + + ctx.fillStyle = '#f00'; + ctx.fillRect(0, 0, 100, 50); + ctx.fillStyle = '#0f0'; + ctx.beginPath(); + ctx.moveTo(50, 25); + ctx.arc(50, 25, 60, (1024-1)*Math.PI, (512+1/2)*Math.PI, true); + ctx.fill(); + + verify(Helper.comparePixel(ctx,1,1, 0,255,0,255)); + verify(Helper.comparePixel(ctx,98,1, 0,255,0,255)); + verify(Helper.comparePixel(ctx,1,48, 0,255,0,255)); + verify(Helper.comparePixel(ctx,98,48, 0,255,0,255)); + } + + function test_empty() { + var ctx = canvas.getContext('2d'); + ctx.reset(); + + ctx.fillStyle = '#0f0'; + ctx.fillRect(0, 0, 100, 50); + ctx.lineWidth = 50; + ctx.strokeStyle = '#f00'; + ctx.beginPath(); + ctx.arc(200, 25, 5, 0, 2*Math.PI, true); + ctx.stroke(); + /*FIXME: + actual :[255,0,0,255] + expected:[0,255,0,255] +/- 0 + */ + //verify(Helper.comparePixel(ctx,50,25, 0,255,0,255)); + } + function test_nonempty() { + var ctx = canvas.getContext('2d'); + ctx.reset(); + + ctx.fillStyle = '#f00'; + ctx.fillRect(0, 0, 100, 50); + ctx.lineWidth = 50; + ctx.strokeStyle = '#0f0'; + ctx.beginPath(); + ctx.moveTo(0, 25); + ctx.arc(200, 25, 5, 0, 2*Math.PI, true); + ctx.stroke(); + verify(Helper.comparePixel(ctx,50,25, 0,255,0,255)); + } + function test_nonfinite() { + skip("FIXME"); + var ctx = canvas.getContext('2d'); + ctx.reset(); + + ctx.fillStyle = '#f00'; + ctx.fillRect(0, 0, 100, 50); + ctx.moveTo(0, 0); + ctx.lineTo(100, 0); + ctx.arc(Infinity, 0, 50, 0, 2*Math.PI, true); + ctx.arc(-Infinity, 0, 50, 0, 2*Math.PI, true); + ctx.arc(NaN, 0, 50, 0, 2*Math.PI, true); + ctx.arc(0, Infinity, 50, 0, 2*Math.PI, true); + ctx.arc(0, -Infinity, 50, 0, 2*Math.PI, true); + ctx.arc(0, NaN, 50, 0, 2*Math.PI, true); + ctx.arc(0, 0, Infinity, 0, 2*Math.PI, true); + ctx.arc(0, 0, -Infinity, 0, 2*Math.PI, true); + ctx.arc(0, 0, NaN, 0, 2*Math.PI, true); + ctx.arc(0, 0, 50, Infinity, 2*Math.PI, true); + ctx.arc(0, 0, 50, -Infinity, 2*Math.PI, true); + ctx.arc(0, 0, 50, NaN, 2*Math.PI, true); + ctx.arc(0, 0, 50, 0, Infinity, true); + ctx.arc(0, 0, 50, 0, -Infinity, true); + ctx.arc(0, 0, 50, 0, NaN, true); + ctx.arc(Infinity, Infinity, 50, 0, 2*Math.PI, true); + ctx.arc(Infinity, Infinity, Infinity, 0, 2*Math.PI, true); + ctx.arc(Infinity, Infinity, Infinity, Infinity, 2*Math.PI, true); + ctx.arc(Infinity, Infinity, Infinity, Infinity, Infinity, true); + ctx.arc(Infinity, Infinity, Infinity, 0, Infinity, true); + ctx.arc(Infinity, Infinity, 50, Infinity, 2*Math.PI, true); + ctx.arc(Infinity, Infinity, 50, Infinity, Infinity, true); + ctx.arc(Infinity, Infinity, 50, 0, Infinity, true); + ctx.arc(Infinity, 0, Infinity, 0, 2*Math.PI, true); + ctx.arc(Infinity, 0, Infinity, Infinity, 2*Math.PI, true); + ctx.arc(Infinity, 0, Infinity, Infinity, Infinity, true); + ctx.arc(Infinity, 0, Infinity, 0, Infinity, true); + ctx.arc(Infinity, 0, 50, Infinity, 2*Math.PI, true); + ctx.arc(Infinity, 0, 50, Infinity, Infinity, true); + ctx.arc(Infinity, 0, 50, 0, Infinity, true); + ctx.arc(0, Infinity, Infinity, 0, 2*Math.PI, true); + ctx.arc(0, Infinity, Infinity, Infinity, 2*Math.PI, true); + ctx.arc(0, Infinity, Infinity, Infinity, Infinity, true); + ctx.arc(0, Infinity, Infinity, 0, Infinity, true); + ctx.arc(0, Infinity, 50, Infinity, 2*Math.PI, true); + ctx.arc(0, Infinity, 50, Infinity, Infinity, true); + ctx.arc(0, Infinity, 50, 0, Infinity, true); + ctx.arc(0, 0, Infinity, Infinity, 2*Math.PI, true); + ctx.arc(0, 0, Infinity, Infinity, Infinity, true); + ctx.arc(0, 0, Infinity, 0, Infinity, true); + ctx.arc(0, 0, 50, Infinity, Infinity, true); + ctx.lineTo(100, 50); + ctx.lineTo(0, 50); + ctx.fillStyle = '#0f0'; + ctx.fill(); + verify(Helper.comparePixel(ctx,50,25, 0,255,0,255)); + verify(Helper.comparePixel(ctx,90,45, 0,255,0,255)); + } + function test_end() { + var ctx = canvas.getContext('2d'); + ctx.reset(); + + ctx.fillStyle = '#f00'; + ctx.fillRect(0, 0, 100, 50); + ctx.lineWidth = 50; + ctx.strokeStyle = '#0f0'; + ctx.beginPath(); + ctx.moveTo(-100, 0); + ctx.arc(-100, 0, 25, -Math.PI/2, Math.PI/2, true); + ctx.lineTo(100, 25); + ctx.stroke(); + verify(Helper.comparePixel(ctx,50,25, 0,255,0,255)); + } + function test_negative() { + var ctx = canvas.getContext('2d'); + ctx.reset(); + + try { var err = false; + ctx.arc(0, 0, -1, 0, 0, true); + } catch (e) { + if (e.code != DOMException.INDEX_SIZE_ERR) + fail("expected exception of type INDEX_SIZE_ERR, got: "+e.message); + err = true; + } finally { + verify(err, "should throw exception of type INDEX_SIZE_ERR: ctx.arc(0, 0, -1, 0, 0, true)"); + } + + } + + function test_scale_1() { + var ctx = canvas.getContext('2d'); + ctx.reset(); + + ctx.fillStyle = '#f00'; + ctx.fillRect(0, 0, 100, 50); + ctx.scale(2, 0.5); + ctx.fillStyle = '#0f0'; + ctx.beginPath(); + ctx.arc(25, 50, 56, 0, 2*Math.PI, false); + ctx.fill(); + ctx.fillStyle = '#f00'; + ctx.beginPath(); + ctx.moveTo(-25, 50); + ctx.arc(-25, 50, 24, 0, 2*Math.PI, false); + ctx.moveTo(75, 50); + ctx.arc(75, 50, 24, 0, 2*Math.PI, false); + ctx.moveTo(25, -25); + ctx.arc(25, -25, 24, 0, 2*Math.PI, false); + ctx.moveTo(25, 125); + ctx.arc(25, 125, 24, 0, 2*Math.PI, false); + ctx.fill(); + + verify(Helper.comparePixel(ctx, 0,0, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 50,0, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 99,0, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 0,25, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 99,25, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 0,49, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 50,49, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 99,49, 0,255,0,255)); + } + + function test_scale_2() { + var ctx = canvas.getContext('2d'); + ctx.reset(); + + ctx.fillStyle = '#f00'; + ctx.fillRect(0, 0, 100, 50); + ctx.scale(100, 100); + ctx.strokeStyle = '#0f0'; + ctx.lineWidth = 1.2; + ctx.beginPath(); + ctx.arc(0, 0, 0.6, 0, Math.PI/2, false); + ctx.stroke(); + + verify(Helper.comparePixel(ctx, 1,1, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 50,1, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 98,1, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 1,25, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 98,25, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 1,48, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 50,48, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 98,48, 0,255,0,255)); + } + + function test_selfintersect_1() { + var ctx = canvas.getContext('2d'); + ctx.reset(); + + ctx.fillStyle = '#0f0'; + ctx.fillRect(0, 0, 100, 50); + ctx.lineWidth = 200; + ctx.strokeStyle = '#f00'; + ctx.beginPath(); + ctx.arc(100, 50, 25, 0, -Math.PI/2, true); + ctx.stroke(); + ctx.beginPath(); + ctx.arc(0, 0, 25, 0, -Math.PI/2, true); + ctx.stroke(); + //verify(Helper.comparePixel(ctx, 1,1, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); + } + + function test_selfintersect_2() { + var ctx = canvas.getContext('2d'); + ctx.reset(); + + ctx.fillStyle = '#f00'; + ctx.fillRect(0, 0, 100, 50); + ctx.lineWidth = 180; + ctx.strokeStyle = '#0f0'; + ctx.beginPath(); + ctx.arc(-50, 50, 25, 0, -Math.PI/2, true); + ctx.stroke(); + ctx.beginPath(); + ctx.arc(100, 0, 25, 0, -Math.PI/2, true); + ctx.stroke(); + verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 90,10, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 97,1, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 97,2, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 97,3, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 2,48, 0,255,0,255)); + } + + function test_shape_1() { + var ctx = canvas.getContext('2d'); + ctx.reset(); + + ctx.fillStyle = '#0f0'; + ctx.fillRect(0, 0, 100, 50); + ctx.lineWidth = 50; + ctx.strokeStyle = '#f00'; + ctx.beginPath(); + ctx.arc(50, 50, 50, 0, Math.PI, false); + ctx.stroke(); + //verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 1,1, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 98,1, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 1,48, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 20,48, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 98,48, 0,255,0,255)); + } + + function test_shape_2() { + var ctx = canvas.getContext('2d'); + ctx.reset(); + + ctx.fillStyle = '#f00'; + ctx.fillRect(0, 0, 100, 50); + ctx.lineWidth = 100; + ctx.strokeStyle = '#0f0'; + ctx.beginPath(); + ctx.arc(50, 50, 50, 0, Math.PI, true); + ctx.stroke(); + verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 1,1, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 98,1, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 1,48, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 20,48, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 98,48, 0,255,0,255)); + } + function test_shape_3() { + var ctx = canvas.getContext('2d'); + ctx.reset(); + + ctx.fillStyle = '#0f0'; + ctx.fillRect(0, 0, 100, 50); + ctx.lineWidth = 100; + ctx.strokeStyle = '#f00'; + ctx.beginPath(); + ctx.arc(0, 50, 50, 0, -Math.PI/2, false); + ctx.stroke(); + //verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 1,1, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 98,1, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 1,48, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 98,48, 0,255,0,255)); + } + + function test_shape_4() { + var ctx = canvas.getContext('2d'); + ctx.reset(); + + ctx.fillStyle = '#f00'; + ctx.fillRect(0, 0, 100, 50); + ctx.lineWidth = 150; + ctx.strokeStyle = '#0f0'; + ctx.beginPath(); + ctx.arc(-50, 50, 100, 0, -Math.PI/2, true); + ctx.stroke(); + verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 1,1, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 98,1, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 1,48, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 98,48, 0,255,0,255)); + } + + function test_shape_5() { + var ctx = canvas.getContext('2d'); + ctx.reset(); + + ctx.fillStyle = '#0f0'; + ctx.fillRect(0, 0, 100, 50); + ctx.lineWidth = 200; + ctx.strokeStyle = '#f00'; + ctx.beginPath(); + ctx.arc(300, 0, 100, 0, 5*Math.PI, false); + ctx.stroke(); + //verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 1,1, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 98,1, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 1,48, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 98,48, 0,255,0,255)); + } + + function test_twopie() { + var ctx = canvas.getContext('2d'); + ctx.reset(); + + ctx.fillStyle = '#0f0'; + ctx.fillRect(0, 0, 100, 50); + ctx.strokeStyle = '#f00'; + ctx.lineWidth = 100; + ctx.beginPath(); + ctx.arc(50, 25, 50, 0, 2*Math.PI - 1e-4, true); + ctx.stroke(); + //verify(Helper.comparePixel(ctx, 50,20, 0,255,0,255)); + ctx.reset(); + + ctx.fillStyle = '#f00'; + ctx.fillRect(0, 0, 100, 50); + ctx.strokeStyle = '#0f0'; + ctx.lineWidth = 100; + ctx.beginPath(); + ctx.arc(50, 25, 50, 0, 2*Math.PI - 1e-4, false); + ctx.stroke(); + verify(Helper.comparePixel(ctx, 50,20, 0,255,0,255)); + ctx.reset(); + + ctx.fillStyle = '#f00'; + ctx.fillRect(0, 0, 100, 50); + ctx.strokeStyle = '#0f0'; + ctx.lineWidth = 100; + ctx.beginPath(); + ctx.arc(50, 25, 50, 0, 2*Math.PI + 1e-4, true); + ctx.stroke(); + verify(Helper.comparePixel(ctx, 50,20, 0,255,0,255)); + ctx.reset(); + + ctx.fillStyle = '#f00'; + ctx.fillRect(0, 0, 100, 50); + ctx.strokeStyle = '#0f0'; + ctx.lineWidth = 100; + ctx.beginPath(); + ctx.arc(50, 25, 50, 0, 2*Math.PI + 1e-4, false); + ctx.stroke(); + verify(Helper.comparePixel(ctx, 50,20, 0,255,0,255)); + } + + function test_zero() { + var ctx = canvas.getContext('2d'); + ctx.reset(); + + ctx.fillStyle = '#0f0'; + ctx.fillRect(0, 0, 100, 50); + ctx.strokeStyle = '#f00'; + ctx.lineWidth = 100; + ctx.beginPath(); + ctx.arc(50, 25, 50, 0, 0, true); + ctx.stroke(); + //verify(Helper.comparePixel(ctx, 50,20, 0,255,0,255)); + ctx.reset(); + + ctx.fillStyle = '#0f0'; + ctx.fillRect(0, 0, 100, 50); + ctx.strokeStyle = '#f00'; + ctx.lineWidth = 100; + ctx.beginPath(); + ctx.arc(50, 25, 50, 0, 0, false); + ctx.stroke(); + //verify(Helper.comparePixel(ctx, 50,20, 0,255,0,255)); + ctx.reset(); + + ctx.fillStyle = '#f00' + ctx.fillRect(0, 0, 100, 50); + ctx.lineWidth = 50; + ctx.strokeStyle = '#0f0'; + ctx.beginPath(); + ctx.moveTo(0, 25); + ctx.arc(200, 25, 0, 0, Math.PI, true); + ctx.stroke(); + verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); + + } + } +} diff --git a/tests/auto/quick/qquickcanvasitem/data/tst_arcto.qml b/tests/auto/quick/qquickcanvasitem/data/tst_arcto.qml new file mode 100644 index 0000000000..cc1d88672b --- /dev/null +++ b/tests/auto/quick/qquickcanvasitem/data/tst_arcto.qml @@ -0,0 +1,410 @@ +import QtQuick 2.0 +import QtTest 1.0 +import "testhelper.js" as Helper + +Canvas { + id:canvas; width:100;height:50; renderTarget: Canvas.Image + TestCase { + name: "arcTo"; when: windowShown + function test_coincide() { + var ctx = canvas.getContext('2d'); + ctx.reset(); + ctx.fillStyle = '#f00'; + ctx.fillRect(0, 0, 100, 50); + ctx.lineWidth = 50; + + ctx.strokeStyle = '#0f0'; + ctx.beginPath(); + ctx.moveTo(0, 25); + ctx.arcTo(0, 25, 50, 1000, 1); + ctx.lineTo(100, 25); + ctx.stroke(); + + ctx.strokeStyle = '#f00'; + ctx.beginPath(); + ctx.moveTo(50, 25); + ctx.arcTo(50, 25, 100, 25, 1); + ctx.stroke(); + + verify(Helper.comparePixel(ctx, 50,1, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 50,48, 0,255,0,255)); + ctx.reset(); + + ctx.fillStyle = '#f00'; + ctx.fillRect(0, 0, 100, 50); + ctx.lineWidth = 50; + ctx.strokeStyle = '#0f0'; + ctx.beginPath(); + ctx.moveTo(0, 25); + ctx.arcTo(100, 25, 100, 25, 1); + ctx.stroke(); + + verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); + } + function test_collinear() { + var ctx = canvas.getContext('2d'); + ctx.reset(); + + ctx.fillStyle = '#f00'; + ctx.fillRect(0, 0, 100, 50); + ctx.lineWidth = 50; + + ctx.strokeStyle = '#0f0'; + ctx.beginPath(); + ctx.moveTo(0, 25); + ctx.arcTo(100, 25, 200, 25, 1); + ctx.stroke(); + + ctx.strokeStyle = '#f00'; + ctx.beginPath(); + ctx.moveTo(-100, 25); + ctx.arcTo(0, 25, 100, 25, 1); + ctx.stroke(); + + verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); + ctx.reset(); + + ctx.fillStyle = '#f00'; + ctx.fillRect(0, 0, 100, 50); + ctx.lineWidth = 50; + + ctx.strokeStyle = '#0f0'; + ctx.beginPath(); + ctx.moveTo(0, 25); + ctx.arcTo(100, 25, 10, 25, 1); + ctx.stroke(); + + ctx.strokeStyle = '#f00'; + ctx.beginPath(); + ctx.moveTo(100, 25); + ctx.arcTo(200, 25, 110, 25, 1); + ctx.stroke(); + verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); + ctx.reset(); + + ctx.fillStyle = '#f00'; + ctx.fillRect(0, 0, 100, 50); + ctx.lineWidth = 50; + + ctx.strokeStyle = '#0f0'; + ctx.beginPath(); + ctx.moveTo(0, 25); + ctx.arcTo(100, 25, -100, 25, 1); + ctx.stroke(); + + ctx.strokeStyle = '#f00'; + ctx.beginPath(); + ctx.moveTo(100, 25); + ctx.arcTo(200, 25, 0, 25, 1); + ctx.stroke(); + + ctx.beginPath(); + ctx.moveTo(-100, 25); + ctx.arcTo(0, 25, -200, 25, 1); + ctx.stroke(); + + verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); + } + function test_subpath() { + var ctx = canvas.getContext('2d'); + ctx.reset(); + + ctx.fillStyle = '#0f0'; + ctx.fillRect(0, 0, 100, 50); + ctx.lineWidth = 50; + ctx.strokeStyle = '#f00'; + ctx.beginPath(); + ctx.arcTo(100, 50, 200, 50, 0.1); + ctx.stroke(); + //verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); + ctx.reset(); + + ctx.fillStyle = '#f00'; + ctx.fillRect(0, 0, 100, 50); + ctx.lineWidth = 50; + ctx.strokeStyle = '#0f0'; + ctx.beginPath(); + ctx.arcTo(0, 25, 50, 250, 0.1); + ctx.lineTo(100, 25); + ctx.stroke(); + verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); + } + + function test_negative() { + var ctx = canvas.getContext('2d'); + ctx.reset(); + + try { var err = false; + ctx.arcTo(0, 0, 0, 0, -1); + } catch (e) { + if (e.code != DOMException.INDEX_SIZE_ERR) + fail("expectes INDEX_SIZE_ERR, got: "+e.message); + err = true; + } + finally { + verify(err, "should throw INDEX_SIZE_ERR: ctx.arcTo(0, 0, 0, 0, -1)"); + } + } + + function test_nonfinite() { + var ctx = canvas.getContext('2d'); + ctx.reset(); + + skip("FIXME"); + + ctx.moveTo(0, 0); + ctx.lineTo(100, 0); + ctx.arcTo(Infinity, 50, 0, 50, 0); + ctx.arcTo(-Infinity, 50, 0, 50, 0); + ctx.arcTo(NaN, 50, 0, 50, 0); + ctx.arcTo(0, Infinity, 0, 50, 0); + ctx.arcTo(0, -Infinity, 0, 50, 0); + ctx.arcTo(0, NaN, 0, 50, 0); + ctx.arcTo(0, 50, Infinity, 50, 0); + ctx.arcTo(0, 50, -Infinity, 50, 0); + ctx.arcTo(0, 50, NaN, 50, 0); + ctx.arcTo(0, 50, 0, Infinity, 0); + ctx.arcTo(0, 50, 0, -Infinity, 0); + ctx.arcTo(0, 50, 0, NaN, 0); + ctx.arcTo(0, 50, 0, 50, Infinity); + ctx.arcTo(0, 50, 0, 50, -Infinity); + ctx.arcTo(0, 50, 0, 50, NaN); + ctx.arcTo(Infinity, Infinity, 0, 50, 0); + ctx.arcTo(Infinity, Infinity, Infinity, 50, 0); + ctx.arcTo(Infinity, Infinity, Infinity, Infinity, 0); + ctx.arcTo(Infinity, Infinity, Infinity, Infinity, Infinity); + ctx.arcTo(Infinity, Infinity, Infinity, 50, Infinity); + ctx.arcTo(Infinity, Infinity, 0, Infinity, 0); + ctx.arcTo(Infinity, Infinity, 0, Infinity, Infinity); + ctx.arcTo(Infinity, Infinity, 0, 50, Infinity); + ctx.arcTo(Infinity, 50, Infinity, 50, 0); + ctx.arcTo(Infinity, 50, Infinity, Infinity, 0); + ctx.arcTo(Infinity, 50, Infinity, Infinity, Infinity); + ctx.arcTo(Infinity, 50, Infinity, 50, Infinity); + ctx.arcTo(Infinity, 50, 0, Infinity, 0); + ctx.arcTo(Infinity, 50, 0, Infinity, Infinity); + ctx.arcTo(Infinity, 50, 0, 50, Infinity); + ctx.arcTo(0, Infinity, Infinity, 50, 0); + ctx.arcTo(0, Infinity, Infinity, Infinity, 0); + ctx.arcTo(0, Infinity, Infinity, Infinity, Infinity); + ctx.arcTo(0, Infinity, Infinity, 50, Infinity); + ctx.arcTo(0, Infinity, 0, Infinity, 0); + ctx.arcTo(0, Infinity, 0, Infinity, Infinity); + ctx.arcTo(0, Infinity, 0, 50, Infinity); + ctx.arcTo(0, 50, Infinity, Infinity, 0); + ctx.arcTo(0, 50, Infinity, Infinity, Infinity); + ctx.arcTo(0, 50, Infinity, 50, Infinity); + ctx.arcTo(0, 50, 0, Infinity, Infinity); + ctx.lineTo(100, 50); + ctx.lineTo(0, 50); + ctx.fillStyle = '#0f0'; + ctx.fill(); + verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 90,45, 0,255,0,255)); + + } + function test_scale() { + var ctx = canvas.getContext('2d'); + ctx.reset(); + + ctx.fillStyle = '#f00'; + ctx.fillRect(0, 0, 100, 50); + + ctx.fillStyle = '#0f0'; + ctx.beginPath(); + ctx.moveTo(0, 50); + ctx.translate(100, 0); + ctx.scale(0.1, 1); + ctx.arcTo(50, 50, 50, 0, 50); + ctx.lineTo(-1000, 0); + ctx.fill(); + + skip("FIXME"); + //verify(Helper.comparePixel(ctx, 0,0, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 50,0, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 99,0, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 0,25, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 99,25, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 0,49, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 50,49, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 99,49, 0,255,0,255)); + } + + function test_shape() { + var ctx = canvas.getContext('2d'); + ctx.reset(); + + var tol = 1.5; // tolerance to avoid antialiasing artifacts + + ctx.fillStyle = '#0f0'; + ctx.fillRect(0, 0, 100, 50); + + ctx.strokeStyle = '#f00'; + ctx.lineWidth = 10; + ctx.beginPath(); + ctx.moveTo(10, 25); + ctx.arcTo(75, 25, 75, 60, 20); + ctx.stroke(); + + ctx.fillStyle = '#0f0'; + ctx.beginPath(); + ctx.rect(10, 20, 45, 10); + ctx.moveTo(80, 45); + ctx.arc(55, 45, 25+tol, 0, -Math.PI/2, true); + ctx.arc(55, 45, 15-tol, -Math.PI/2, 0, false); + ctx.fill(); + + verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 55,19, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 55,20, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 55,21, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 64,22, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 65,21, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 72,28, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 73,27, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 78,36, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 79,35, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 80,44, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 80,45, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 80,46, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 65,45, 0,255,0,255)); + ctx.reset(); + + ctx.fillStyle = '#0f0'; + ctx.fillRect(0, 0, 100, 50); + + ctx.fillStyle = '#f00'; + ctx.beginPath(); + ctx.rect(10, 20, 45, 10); + ctx.moveTo(80, 45); + ctx.arc(55, 45, 25-tol, 0, -Math.PI/2, true); + ctx.arc(55, 45, 15+tol, -Math.PI/2, 0, false); + ctx.fill(); + + ctx.strokeStyle = '#0f0'; + ctx.lineWidth = 10; + ctx.beginPath(); + ctx.moveTo(10, 25); + ctx.arcTo(75, 25, 75, 60, 20); + ctx.stroke(); + + //verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 55,19, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 55,20, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 55,21, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 64,22, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 65,21, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 72,28, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 73,27, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 78,36, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 79,35, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 80,44, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 80,45, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 80,46, 0,255,0,255)); + ctx.reset(); + + + ctx.fillStyle = '#0f0'; + ctx.fillRect(0, 0, 100, 50); + ctx.strokeStyle = '#f00'; + ctx.lineWidth = 50; + ctx.beginPath(); + ctx.moveTo(-100, -100); + ctx.arcTo(-100, 25, 200, 25, 10); + ctx.stroke(); + + verify(Helper.comparePixel(ctx, 1,1, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 1,48, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 98,1, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 98,48, 0,255,0,255)); + ctx.reset(); + + ctx.fillStyle = '#f00'; + ctx.fillRect(0, 0, 100, 50); + ctx.strokeStyle = '#0f0'; + ctx.lineWidth = 50; + ctx.beginPath(); + ctx.moveTo(0, 25); + ctx.arcTo(200, 25, 200, 50, 10); + ctx.stroke(); + + //verify(Helper.comparePixel(ctx, 1,1, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 1,48, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 98,1, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 98,48, 0,255,0,255)); + } + + function test_transform() { + var ctx = canvas.getContext('2d'); + ctx.reset(); + + ctx.fillStyle = '#f00'; + ctx.fillRect(0, 0, 100, 50); + + ctx.fillStyle = '#0f0'; + ctx.beginPath(); + ctx.moveTo(0, 50); + ctx.translate(100, 0); + ctx.arcTo(50, 50, 50, 0, 50); + ctx.lineTo(-100, 0); + ctx.fill(); + + skip("FIXME"); + //verify(Helper.comparePixel(ctx, 0,0, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 50,0, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 99,0, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 0,25, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 99,25, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 0,49, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 50,49, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 99,49, 0,255,0,255)); + } + function test_zero() { + var ctx = canvas.getContext('2d'); + ctx.reset(); + + ctx.fillStyle = '#f00'; + ctx.fillRect(0, 0, 100, 50); + ctx.lineWidth = 50; + + ctx.strokeStyle = '#0f0'; + ctx.beginPath(); + ctx.moveTo(0, 25); + ctx.arcTo(100, 25, 100, 100, 0); + ctx.stroke(); + + ctx.strokeStyle = '#f00'; + ctx.beginPath(); + ctx.moveTo(0, -25); + ctx.arcTo(50, -25, 50, 50, 0); + ctx.stroke(); + + verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); + ctx.reset(); + + ctx.fillStyle = '#f00'; + ctx.fillRect(0, 0, 100, 50); + ctx.lineWidth = 50; + + ctx.strokeStyle = '#0f0'; + ctx.beginPath(); + ctx.moveTo(0, 25); + ctx.arcTo(100, 25, -100, 25, 0); + ctx.stroke(); + + ctx.strokeStyle = '#f00'; + ctx.beginPath(); + ctx.moveTo(100, 25); + ctx.arcTo(200, 25, 50, 25, 0); + ctx.stroke(); + + verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); + + } + } +} diff --git a/tests/auto/quick/qquickcanvasitem/data/tst_canvas.qml b/tests/auto/quick/qquickcanvasitem/data/tst_canvas.qml new file mode 100644 index 0000000000..a00ccc3c3f --- /dev/null +++ b/tests/auto/quick/qquickcanvasitem/data/tst_canvas.qml @@ -0,0 +1,278 @@ +import QtQuick 2.0 +import QtTest 1.0 + +Rectangle { + id:container + width:100 + height:100 + Component { + id:canvas + Canvas { + id:c + width:100;height:100 + onPaint: { + var context = getContext("2d"); + context.fillStyle = "red"; + context.fillRect(0, 0, 100, 100); + } + property int paintCount:spyPaint.count + property int paintedCount:spyPainted.count + property int canvasSizeChangedCount:spyCanvasSizeChanged.count + property int tileSizeChangedCount:spyTileSizeChanged.count + property int renderStrategyChangedCount:spyRenderStrategyChanged.count + property int canvasWindowChangedCount:spyCanvasWindowChanged.count + property int renderTargetChangedCount:spyRenderTargetChanged.count + property int imageLoadedCount:spyImageLoaded.count + property int availableChangedCount:spyAvailableChanged.count + + SignalSpy {id: spyPaint;target:c;signalName: "paint"} + SignalSpy {id: spyPainted;target:c;signalName: "painted"} + SignalSpy {id: spyCanvasSizeChanged;target:c;signalName: "canvasSizeChanged"} + SignalSpy {id: spyTileSizeChanged;target:c;signalName: "tileSizeChanged"} + SignalSpy {id: spyRenderStrategyChanged;target:c;signalName: "renderStrategyChanged"} + SignalSpy {id: spyCanvasWindowChanged;target:c;signalName: "canvasWindowChanged"} + SignalSpy {id: spyRenderTargetChanged;target:c;signalName: "renderTargetChanged"} + SignalSpy {id: spyImageLoaded;target:c;signalName: "imageLoaded"} + SignalSpy {id: spyAvailableChanged;target:c;signalName: "availableChanged"} + } + } + + TestCase { + name: "Canvas"; when: windowShown + function test_canvasSize() { + var c = canvas.createObject(container); + verify(c); + wait(100); + verify(c.availableChangedCount, 1); + + //by default canvasSize is same with canvas' actual size + // when canvas size changes, canvasSize should be changed as well. + compare(c.canvasSize.width, c.width); + compare(c.canvasSize.height, c.height); + c.width = 20; + compare(c.canvasSize.width, 20); + compare(c.canvasSizeChangedCount, 1); + c.height = 5; + compare(c.canvasSizeChangedCount, 2); + compare(c.canvasSize.height, 5); + + //change canvasSize manually, then canvasSize detaches from canvas + //actual size. + c.canvasSize.width = 100; + compare(c.canvasSizeChangedCount, 3); + compare(c.canvasSize.width, 100); + compare(c.width, 20); + c.canvasSize.height = 50; + compare(c.canvasSizeChangedCount, 4); + compare(c.canvasSize.height, 50); + compare(c.height, 5); + + c.width = 10; + compare(c.canvasSizeChangedCount, 4); + compare(c.canvasSize.width, 100); + compare(c.canvasSize.height, 50); + + c.height = 10; + compare(c.canvasSizeChangedCount, 4); + compare(c.canvasSize.width, 100); + compare(c.canvasSize.height, 50); + c.destroy(); + } + function test_tileSize() { + var c = canvas.createObject(container); + verify(c); + wait(100); + verify(c.availableChangedCount, 1); + + compare(c.tileSize.width, c.width); + compare(c.tileSize.height, c.height); + c.width = 20; + compare(c.tileSize.width, 20); + compare(c.tileSizeChangedCount, 1); + c.height = 5; + compare(c.tileSizeChangedCount, 2); + compare(c.tileSize.height, 5); + + c.tileSize.width = 100; + compare(c.tileSizeChangedCount, 3); + compare(c.tileSize.width, 100); + compare(c.width, 20); + c.tileSize.height = 50; + compare(c.tileSizeChangedCount, 4); + compare(c.tileSize.height, 50); + compare(c.height, 5); + + c.width = 10; + compare(c.tileSizeChangedCount, 4); + compare(c.tileSize.width, 100); + compare(c.tileSize.height, 50); + + c.height = 10; + compare(c.tileSizeChangedCount, 4); + compare(c.tileSize.width, 100); + compare(c.tileSize.height, 50); + c.destroy(); + + } + + function test_canvasWindow() { + var c = canvas.createObject(container); + verify(c); + wait(100); + verify(c.availableChangedCount, 1); + compare(c.canvasWindow.x, 0); + compare(c.canvasWindow.y, 0); + compare(c.canvasWindow.width, c.width); + compare(c.canvasWindow.height, c.height); + + c.width = 20; + compare(c.canvasWindow.width, 20); + compare(c.canvasWindowChangedCount, 1); + c.height = 5; + compare(c.canvasWindowChangedCount, 2); + compare(c.canvasWindow.height, 5); + + c.canvasWindow.x = 5; + c.canvasWindow.y = 6; + c.canvasWindow.width = 10; + c.canvasWindow.height =20; + compare(c.canvasWindowChangedCount, 6); + compare(c.canvasWindow.width, 10); + compare(c.canvasWindow.height, 20); + compare(c.canvasWindow.x, 5); + compare(c.canvasWindow.y, 6); + c.destroy(); + + } + function test_renderTargetAndStrategy() { + var c = canvas.createObject(container); + verify(c); + wait(100); + verify(c.availableChangedCount, 1); + + compare(c.renderTarget, Canvas.Image); + compare(c.renderStrategy, Canvas.Threaded); + c.destroy(); + + } + function test_save() { + var c = canvas.createObject(container); + verify(c); + wait(100); + verify(c.availableChangedCount, 1); + + c.renderTarget = Canvas.Image; + c.requestPaint(); + wait(100); + verify(c.save("c.png")); + c.loadImage("c.png"); + wait(200); + compare(c.imageLoadedCount, 1); + verify(c.isImageLoaded("c.png")); + verify(!c.isImageLoading("c.png")); + verify(!c.isImageError("c.png")); + c.destroy(); + + } + function test_toDataURL_data() { + return [{mimeType:"image/png"}, + {mimeType:"image/bmp"}, + {mimeType:"image/jpeg"}, + {mimeType:"image/x-portable-pixmap"}, + //{mimeType:"image/tiff"}, QTBUG-23980 + {mimeType:"image/xpm"}, + ]; + } + + function test_toDataURL(data) { + var c = canvas.createObject(container); + verify(c); + wait(100); + verify(c.availableChangedCount, 1); + + var ctx = c.getContext("2d"); + ctx.fillStyle = "red"; + ctx.fillRect(0, 0, c.width, c.height); + wait(100); + + var dataUrl = c.toDataURL(); + verify(dataUrl != "data:,"); + dataUrl = c.toDataURL("image/invalid"); + verify(dataUrl == "data:,"); + + dataUrl = c.toDataURL(data.mimeType); + verify(dataUrl != "data:,"); + + ctx.save(); + ctx.fillStyle = "blue"; + ctx.fillRect(0, 0, c.width, c.height); + ctx.restore(); + wait(100); + + var dataUrl2 = c.toDataURL(data.mimeType); + verify (dataUrl2 != "data:,"); + verify (dataUrl2 != dataUrl); + c.destroy(); + + } + function test_paint() { + var c = canvas.createObject(container); + verify(c); + wait(100); + verify(c.availableChangedCount, 1); + + c.renderTarget = Canvas.Image; + c.renderStrategy = Canvas.Immediate; + var ctx = c.getContext("2d"); + ctx.fillRect(0, 0, c.width, c.height); + c.toDataURL(); + wait(100); + + compare(c.paintedCount, 1); + compare(c.paintCount, 1); + c.destroy(); + + } + function test_loadImage() { + var c = canvas.createObject(container); + verify(c); + wait(100); + verify(c.availableChangedCount, 1); + + c.loadImage("red.png"); + wait(200); + compare(c.imageLoadedCount, 1); + verify(c.isImageLoaded("red.png")); + verify(!c.isImageLoading("red.png")); + verify(!c.isImageError("red.png")); + + c.unloadImage("red.png"); + verify(!c.isImageLoaded("red.png")); + verify(!c.isImageLoading("red.png")); + verify(!c.isImageError("red.png")); + c.destroy(); + + } + + function test_getContext() { + var c = canvas.createObject(container); + verify(c); + wait(100); + verify(c.availableChangedCount, 1); + + var ctx = c.getContext("2d"); + verify(ctx); + compare(ctx.canvas, c); + ctx = c.getContext('2d'); + verify(ctx); + compare(ctx.canvas, c); + ctx = c.getContext('2D'); + verify(ctx); + compare(ctx.canvas, c); + ctx = c.getContext('invalid'); + verify(!ctx); + c.destroy(); + + } + } +} diff --git a/tests/auto/quick/qquickcanvasitem/data/tst_composite.qml b/tests/auto/quick/qquickcanvasitem/data/tst_composite.qml new file mode 100644 index 0000000000..11e1dce902 --- /dev/null +++ b/tests/auto/quick/qquickcanvasitem/data/tst_composite.qml @@ -0,0 +1,380 @@ +import QtQuick 2.0 +import QtTest 1.0 +import "testhelper.js" as Helper +Canvas { + id:canvas; width:100;height:50; renderTarget:Canvas.Image + TestCase { + name: "composite"; when: windowShown + function test_clearRect() { + var ctx = canvas.getContext('2d'); + ctx.reset(); + ctx.fillStyle = '#f00'; + ctx.fillRect(0, 0, 100, 50); + ctx.globalCompositeOperation = 'destination-atop'; + ctx.clearRect(0, 0, 100, 50); + verify(Helper.comparePixel(ctx, 50,25, 0,0,0,0)); + } + + function test_clip_data() { + return [ {compsite:"copy"}, + {compsite:"destination-atop"}, + {compsite:"destination-in"}, + {compsite:"destination-out"}, + {compsite:"destination-over"}, + {compsite:"lighter"}, + {compsite:"source-atop"}, + {compsite:"source-in"}, + {compsite:"source-out"}, + {compsite:"source-over"}, + {compsite:"xor"} + ]; + } + + function test_clip(data) { + var ctx = canvas.getContext('2d'); + ctx.reset(); + ctx.fillStyle = '#0f0'; + ctx.fillRect(0, 0, 100, 50); + ctx.globalCompositeOperation = data.compsite; + ctx.rect(-20, -20, 10, 10); + ctx.clip(); + ctx.fillStyle = '#f00'; + ctx.fillRect(0, 0, 50, 50); + verify(Helper.comparePixel(ctx, 25,25, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 75,25, 0,255,0,255)); + } + + function test_globalAlpha() { + var ctx = canvas.getContext('2d'); + ctx.reset(); + compare(ctx.globalAlpha, 1.0); + + ctx.fillStyle = '#0f0'; + ctx.fillRect(0, 0, 100, 50); + ctx.globalAlpha = 0.01; // avoid any potential alpha=0 optimisations + ctx.fillStyle = '#f00'; + ctx.fillRect(0, 0, 100, 50); + //verify(Helper.comparePixel(ctx, 50,25, 2,253,0,255, 2)); + + ctx.reset(); + ctx.globalAlpha = 0.5; + var a = ctx.globalAlpha; // might not be exactly 0.5, if it is rounded/quantised, so remember for future comparisons + ctx.globalAlpha = Infinity; + compare(ctx.globalAlpha, a); + ctx.globalAlpha = -Infinity; + compare(ctx.globalAlpha, a); + ctx.globalAlpha = NaN; + compare(ctx.globalAlpha, a); + + ctx.globalAlpha = 0.5; + a = ctx.globalAlpha; // might not be exactly 0.5, if it is rounded/quantised, so remember for future comparisons + ctx.globalAlpha = 1.1; + compare(ctx.globalAlpha, a); + ctx.globalAlpha = -0.1; + compare(ctx.globalAlpha, a); + ctx.globalAlpha = 0; + compare(ctx.globalAlpha, 0); + ctx.globalAlpha = 1; + compare(ctx.globalAlpha, 1); + + } + + function test_operation() { + var ctx = canvas.getContext('2d'); + ctx.reset(); + ctx.globalCompositeOperation = 'xor'; + ctx.globalCompositeOperation = 'Source-over'; + compare(ctx.globalCompositeOperation, 'xor'); + + ctx.reset(); + ctx.globalCompositeOperation = 'xor'; + ctx.globalCompositeOperation = 'clear'; + compare(ctx.globalCompositeOperation, 'xor'); + + ctx.reset(); + ctx.globalCompositeOperation = 'xor'; + ctx.globalCompositeOperation = 'darker'; + compare(ctx.globalCompositeOperation, 'xor'); + + ctx.reset(); + compare(ctx.globalCompositeOperation, 'source-over'); + + + ctx.reset(); + var modes = ['source-atop', 'source-in', 'source-out', 'source-over', + 'destination-atop', 'destination-in', 'destination-out', 'destination-over', + 'lighter', 'copy', 'xor']; + for (var i = 0; i < modes.length; ++i) + { + ctx.globalCompositeOperation = modes[i]; + compare(ctx.globalCompositeOperation, modes[i]); + } + + ctx.reset(); + ctx.globalCompositeOperation = 'xor'; + ctx.globalCompositeOperation = 'highlight'; + compare(ctx.globalCompositeOperation, 'xor'); + + ctx.reset(); + ctx.globalCompositeOperation = 'xor'; + ctx.globalCompositeOperation = 'source-over\\0'; + compare(ctx.globalCompositeOperation, 'xor'); + + ctx.reset(); + ctx.globalCompositeOperation = 'xor'; + ctx.globalCompositeOperation = 'over'; + compare(ctx.globalCompositeOperation, 'xor'); + + + ctx.reset(); + ctx.globalCompositeOperation = 'xor'; + ctx.globalCompositeOperation = 'nonexistent'; + compare(ctx.globalCompositeOperation, 'xor'); + } + + function test_solid() { + skip("FIXME"); + var ctx = canvas.getContext('2d'); + ctx.reset(); + ctx.fillStyle = Qt.rgba(0, 1, 1, 1.0); + ctx.fillRect(0, 0, 100, 50); + ctx.globalCompositeOperation = 'copy'; + ctx.fillStyle = Qt.rgba(1, 1, 0, 1.0); + ctx.fillRect(0, 0, 100, 50); + //verify(Helper.comparePixel(ctx, 50,25, 255,255,0, 5)); + + ctx.reset(); + ctx.fillStyle = 'rgba(0, 255, 255, 1.0)'; + ctx.fillRect(0, 0, 100, 50); + ctx.globalCompositeOperation = 'destination-atop'; + ctx.fillStyle = 'rgba(255, 255, 0, 1.0)'; + ctx.fillRect(0, 0, 100, 50); + //verify(Helper.comparePixel(ctx, 50,25, 0,255,255,255, 5)); + + ctx.reset(); + ctx.fillStyle = 'rgba(0, 255, 255, 1.0)'; + ctx.fillRect(0, 0, 100, 50); + ctx.globalCompositeOperation = 'destination-in'; + ctx.fillStyle = 'rgba(255, 255, 0, 1.0)'; + ctx.fillRect(0, 0, 100, 50); + //verify(Helper.comparePixel(ctx, 50,25, 0,255,255,255, 5)); + + ctx.reset(); + ctx.fillStyle = 'rgba(0, 255, 255, 1.0)'; + ctx.fillRect(0, 0, 100, 50); + ctx.globalCompositeOperation = 'destination-out'; + ctx.fillStyle = 'rgba(255, 255, 0, 1.0)'; + ctx.fillRect(0, 0, 100, 50); + verify(Helper.comparePixel(ctx, 50,25, 0,0,0,0, 5)); + + + ctx.reset(); + ctx.fillStyle = 'rgba(0, 255, 255, 1.0)'; + ctx.fillRect(0, 0, 100, 50); + ctx.globalCompositeOperation = 'destination-over'; + ctx.fillStyle = 'rgba(255, 255, 0, 1.0)'; + ctx.fillRect(0, 0, 100, 50); + //verify(Helper.comparePixel(ctx, 50,25, 0,255,255,255, 5)); + + ctx.reset(); + ctx.fillStyle = 'rgba(0, 255, 255, 1.0)'; + ctx.fillRect(0, 0, 100, 50); + ctx.globalCompositeOperation = 'lighter'; + ctx.fillStyle = 'rgba(255, 255, 0, 1.0)'; + ctx.fillRect(0, 0, 100, 50); + //verify(Helper.comparePixel(ctx, 50,25, 255,255,255,255, 5)); + + + ctx.reset(); + ctx.fillStyle = 'rgba(0, 255, 255, 1.0)'; + ctx.fillRect(0, 0, 100, 50); + ctx.globalCompositeOperation = 'source-atop'; + ctx.fillStyle = 'rgba(255, 255, 0, 1.0)'; + ctx.fillRect(0, 0, 100, 50); + //verify(Helper.comparePixel(ctx, 50,25, 255,255,0, 5)); + + + ctx.reset(); + ctx.fillStyle = 'rgba(0, 255, 255, 1.0)'; + ctx.fillRect(0, 0, 100, 50); + ctx.globalCompositeOperation = 'source-in'; + ctx.fillStyle = 'rgba(255, 255, 0, 1.0)'; + ctx.fillRect(0, 0, 100, 50); + //verify(Helper.comparePixel(ctx, 50,25, 255,255,0, 5)); + + + ctx.reset(); + ctx.fillStyle = 'rgba(0, 255, 255, 1.0)'; + ctx.fillRect(0, 0, 100, 50); + ctx.globalCompositeOperation = 'source-out'; + ctx.fillStyle = 'rgba(255, 255, 0, 1.0)'; + ctx.fillRect(0, 0, 100, 50); + // verify(Helper.comparePixel(ctx, 50,25, 0,0,0,0, 5)); + + + ctx.reset(); + ctx.fillStyle = 'rgba(0, 255, 255, 1.0)'; + ctx.fillRect(0, 0, 100, 50); + ctx.globalCompositeOperation = 'source-over'; + ctx.fillStyle = 'rgba(255, 255, 0, 1.0)'; + ctx.fillRect(0, 0, 100, 50); + //verify(Helper.comparePixel(ctx, 50,25, 255,255,0, 5)); + + ctx.reset(); + ctx.fillStyle = 'rgba(0, 255, 255, 1.0)'; + ctx.fillRect(0, 0, 100, 50); + ctx.globalCompositeOperation = 'xor'; + ctx.fillStyle = 'rgba(255, 255, 0, 1.0)'; + ctx.fillRect(0, 0, 100, 50); + //verify(Helper.comparePixel(ctx, 50,25, 0,0,0,0, 5)); + } + function test_transparent() { + + skip("FIXME"); + var ctx = canvas.getContext('2d'); + ctx.reset(); + ctx.fillStyle = 'rgba(0, 255, 0, 0.5)'; + ctx.fillRect(0, 0, 100, 50); + ctx.globalCompositeOperation = 'copy'; + ctx.fillStyle = 'rgba(0, 0, 255, 0.75)'; + ctx.fillRect(0, 0, 100, 50); + verify(Helper.comparePixel(ctx, 50,25, 0,0,255,191, 5)); + + ctx.reset(); + ctx.fillStyle = 'rgba(0, 255, 0, 0.5)'; + ctx.fillRect(0, 0, 100, 50); + ctx.globalCompositeOperation = 'copy'; + ctx.fillStyle = 'rgba(0, 0, 255, 0.75)'; + ctx.fillRect(0, 0, 100, 50); + verify(Helper.comparePixel(ctx, 50,25, 0,0,255,191, 5)); + + ctx.reset(); + ctx.fillStyle = 'rgba(0, 255, 0, 0.5)'; + ctx.fillRect(0, 0, 100, 50); + ctx.globalCompositeOperation = 'destination-in'; + ctx.fillStyle = 'rgba(0, 0, 255, 0.75)'; + ctx.fillRect(0, 0, 100, 50); + verify(Helper.comparePixel(ctx, 50,25, 0,255,0,95, 5)); + + ctx.reset(); + ctx.fillStyle = 'rgba(0, 255, 0, 0.5)'; + ctx.fillRect(0, 0, 100, 50); + ctx.globalCompositeOperation = 'destination-out'; + ctx.fillStyle = 'rgba(0, 0, 255, 0.75)'; + ctx.fillRect(0, 0, 100, 50); + verify(Helper.comparePixel(ctx, 50,25, 0,255,0,31, 5)); + + ctx.reset(); + ctx.fillStyle = 'rgba(0, 255, 0, 0.5)'; + ctx.fillRect(0, 0, 100, 50); + ctx.globalCompositeOperation = 'destination-over'; + ctx.fillStyle = 'rgba(0, 0, 255, 0.75)'; + ctx.fillRect(0, 0, 100, 50); + verify(Helper.comparePixel(ctx, 50,25, 0,145,109,223, 5)); + + + ctx.reset(); + ctx.fillStyle = 'rgba(0, 255, 0, 0.5)'; + ctx.fillRect(0, 0, 100, 50); + ctx.globalCompositeOperation = 'lighter'; + ctx.fillStyle = 'rgba(0, 0, 255, 0.75)'; + ctx.fillRect(0, 0, 100, 50); + verify(Helper.comparePixel(ctx, 50,25, 0,127,191,255, 5)); + + ctx.reset(); + ctx.fillStyle = 'rgba(0, 255, 0, 0.5)'; + ctx.fillRect(0, 0, 100, 50); + ctx.globalCompositeOperation = 'source-atop'; + ctx.fillStyle = 'rgba(0, 0, 255, 0.75)'; + ctx.fillRect(0, 0, 100, 50); + verify(Helper.comparePixel(ctx, 50,25, 0,63,191,127, 5)); + + ctx.reset(); + ctx.fillStyle = 'rgba(0, 255, 0, 0.5)'; + ctx.fillRect(0, 0, 100, 50); + ctx.globalCompositeOperation = 'source-in'; + ctx.fillStyle = 'rgba(0, 0, 255, 0.75)'; + ctx.fillRect(0, 0, 100, 50); + verify(Helper.comparePixel(ctx, 50,25, 0,0,255,95, 5)); + + ctx.reset(); + ctx.fillStyle = 'rgba(0, 255, 0, 0.5)'; + ctx.fillRect(0, 0, 100, 50); + ctx.globalCompositeOperation = 'source-out'; + ctx.fillStyle = 'rgba(0, 0, 255, 0.75)'; + ctx.fillRect(0, 0, 100, 50); + verify(Helper.comparePixel(ctx, 50,25, 0,0,255,95, 5)); + + + ctx.reset(); + ctx.fillStyle = 'rgba(0, 255, 0, 0.5)'; + ctx.fillRect(0, 0, 100, 50); + ctx.globalCompositeOperation = 'source-over'; + ctx.fillStyle = 'rgba(0, 0, 255, 0.75)'; + ctx.fillRect(0, 0, 100, 50); + verify(Helper.comparePixel(ctx, 50,25, 0,36,218,223, 5)); + + ctx.reset(); + ctx.fillStyle = 'rgba(0, 255, 0, 0.5)'; + ctx.fillRect(0, 0, 100, 50); + ctx.globalCompositeOperation = 'xor'; + ctx.fillStyle = 'rgba(0, 0, 255, 0.75)'; + ctx.fillRect(0, 0, 100, 50); + verify(Helper.comparePixel(ctx, 50,25, 0,63,191,127, 5)); + + } + + function test_uncovered() { + skip("FIXME"); + var ctx = canvas.getContext('2d'); + ctx.reset(); + ctx.fillStyle = 'rgba(0, 255, 0, 0.5)'; + ctx.fillRect(0, 0, 100, 50); + ctx.globalCompositeOperation = 'copy'; + ctx.fillStyle = 'rgba(0, 0, 255, 0.75)'; + ctx.translate(0, 25); + ctx.fillRect(0, 50, 100, 50); + verify(Helper.comparePixel(ctx, 50,25, 0,0,0,0, 5)); + + ctx.reset(); + ctx.fillStyle = 'rgba(0, 255, 0, 0.5)'; + ctx.fillRect(0, 0, 100, 50); + ctx.globalCompositeOperation = 'destination-atop'; + ctx.fillStyle = 'rgba(0, 0, 255, 0.75)'; + ctx.translate(0, 25); + ctx.fillRect(0, 50, 100, 50); + verify(Helper.comparePixel(ctx, 50,25, 0,0,0,0, 5)); + + + + ctx.reset(); + ctx.fillStyle = 'rgba(0, 255, 0, 0.5)'; + ctx.fillRect(0, 0, 100, 50); + ctx.globalCompositeOperation = 'destination-in'; + ctx.fillStyle = 'rgba(0, 0, 255, 0.75)'; + ctx.translate(0, 25); + ctx.fillRect(0, 50, 100, 50); + verify(Helper.comparePixel(ctx, 50,25, 0,0,0,0, 5)); + + ctx.reset(); + ctx.fillStyle = 'rgba(0, 255, 0, 0.5)'; + ctx.fillRect(0, 0, 100, 50); + ctx.globalCompositeOperation = 'source-in'; + ctx.fillStyle = 'rgba(0, 0, 255, 0.75)'; + ctx.translate(0, 25); + ctx.fillRect(0, 50, 100, 50); + verify(Helper.comparePixel(ctx, 50,25, 0,0,0,0, 5)); + + ctx.reset(); + ctx.fillStyle = 'rgba(0, 255, 0, 0.5)'; + ctx.fillRect(0, 0, 100, 50); + ctx.globalCompositeOperation = 'source-out'; + ctx.fillStyle = 'rgba(0, 0, 255, 0.75)'; + ctx.translate(0, 25); + ctx.fillRect(0, 50, 100, 50); + verify(Helper.comparePixel(ctx, 50,25, 0,0,0,0, 5)); + + } + + } +} \ No newline at end of file diff --git a/tests/auto/quick/qquickcanvasitem/data/tst_context.qml b/tests/auto/quick/qquickcanvasitem/data/tst_context.qml new file mode 100644 index 0000000000..b72e755ed9 --- /dev/null +++ b/tests/auto/quick/qquickcanvasitem/data/tst_context.qml @@ -0,0 +1,73 @@ + +import QtQuick 2.0 +import QtTest 1.0 + +Canvas { + id: canvas + width: 1 + height: 1 + contextType: "2d" + + property var contextInPaint + + SignalSpy { + id: paintedSpy + target: canvas + signalName: "paint" + } + + SignalSpy { + id: contextSpy + target: canvas + signalName: "contextChanged" + } + + onPaint: { + contextInPaint = context; + } + + TestCase { + name: "ContextTypeStored" + when: windowShown + + function test_contextType() { + compare(canvas.contextType, "2d"); + } + } + + TestCase { + name: "ContextValidWhenTypePredefined" + when: canvas.available + + function test_context() { + // Wait for the context to become active + wait(100); + compare(contextSpy.count, 1); + + // Context is available + verify(canvas.context) + } + + function test_contextIsConsistent() { + // Wait for the context to become active + wait(100); + compare(contextSpy.count, 1); + + // getContext("2d") is the same as the context property + compare(canvas.getContext("2d"), canvas.context); + } + + function test_paintHadContext() { + // Make there was a paint signal + wait(100); + verify(paintedSpy.count, 1) + + // Paint was called with a valid context when contextType is + // specified + verify(canvas.contextInPaint) + + // paints context was the correct one + compare(canvas.contextInPaint, canvas.getContext("2d")); + } + } +} diff --git a/tests/auto/quick/qquickcanvasitem/data/tst_drawimage.qml b/tests/auto/quick/qquickcanvasitem/data/tst_drawimage.qml new file mode 100644 index 0000000000..102217dc0c --- /dev/null +++ b/tests/auto/quick/qquickcanvasitem/data/tst_drawimage.qml @@ -0,0 +1,667 @@ +import QtQuick 2.0 +import QtTest 1.0 +import "testhelper.js" as Helper +Canvas { + id:canvas; width:100;height:50; renderTarget: Canvas.Image + Component.onCompleted: { + canvas.loadImage('green.png'); + canvas.loadImage('red.png'); + canvas.loadImage('rgrg-256x256.png'); + canvas.loadImage('ggrr-256x256.png'); + canvas.loadImage('broken.png'); + } + + TestCase { + //TODO + name: "image"; when: windowShown + function test_3args() { + //make sure all images are loaded + wait(200); + var ctx = canvas.getContext('2d'); + ctx.reset(); + ctx.drawImage('green.png', 0, 0); + ctx.drawImage('red.png', -100, 0); + ctx.drawImage('red.png', 100, 0); + ctx.drawImage('red.png', 0, -50); + ctx.drawImage('red.png', 0, 50); + + verify(Helper.comparePixel(ctx, 0,0, 0,255,0,255,2)); + verify(Helper.comparePixel(ctx, 99,0, 0,255,0,255,2)); + verify(Helper.comparePixel(ctx, 0,49, 0,255,0,255,2)); + verify(Helper.comparePixel(ctx, 99,49, 0,255,0,255,2)); + + } + function test_5args() { + var ctx = canvas.getContext('2d'); + ctx.reset(); + ctx.fillStyle = '#f00'; + ctx.fillRect(0, 0, 100, 50); + ctx.drawImage('green.png', 50, 0, 50, 50); + ctx.drawImage('red.png', 0, 0, 50, 50); + ctx.fillStyle = '#0f0'; + ctx.fillRect(0, 0, 50, 50); + + verify(Helper.comparePixel(ctx, 0,0, 0,255,0,255,2)); + verify(Helper.comparePixel(ctx, 99,0, 0,255,0,255,2)); + verify(Helper.comparePixel(ctx, 0,49, 0,255,0,255,2)); + verify(Helper.comparePixel(ctx, 99,49, 0,255,0,255,2)); + + } + function test_9args() { + var ctx = canvas.getContext('2d'); + ctx.reset(); + ctx.fillStyle = '#f00'; + ctx.fillRect(0, 0, 100, 50); + ctx.drawImage('green.png', 0, 0, 100, 50, 0, 0, 100, 50); + verify(Helper.comparePixel(ctx, 0,0, 0,255,0,255,2)); + verify(Helper.comparePixel(ctx, 99,0, 0,255,0,255,2)); + verify(Helper.comparePixel(ctx, 0,49, 0,255,0,255,2)); + verify(Helper.comparePixel(ctx, 99,49, 0,255,0,255,2)); + + ctx.reset(); + + ctx.fillStyle = '#f00'; + ctx.fillRect(0, 0, 100, 50); + ctx.drawImage('green.png', 0, 0, 100, 50, 0, 0, 100, 50); + ctx.drawImage('red.png', 0, 0, 100, 50, -100, 0, 100, 50); + ctx.drawImage('red.png', 0, 0, 100, 50, 100, 0, 100, 50); + ctx.drawImage('red.png', 0, 0, 100, 50, 0, -50, 100, 50); + ctx.drawImage('red.png', 0, 0, 100, 50, 0, 50, 100, 50); + verify(Helper.comparePixel(ctx, 0,0, 0,255,0,255,2)); + verify(Helper.comparePixel(ctx, 99,0, 0,255,0,255,2)); + verify(Helper.comparePixel(ctx, 0,49, 0,255,0,255,2)); + verify(Helper.comparePixel(ctx, 99,49, 0,255,0,255,2)); + + + ctx.fillStyle = '#f00'; + ctx.fillRect(0, 0, 100, 50); + ctx.drawImage('green.png', 1, 1, 1, 1, 0, 0, 100, 50); + ctx.drawImage('red.png', 0, 0, 100, 50, -50, 0, 50, 50); + ctx.drawImage('red.png', 0, 0, 100, 50, 100, 0, 50, 50); + ctx.drawImage('red.png', 0, 0, 100, 50, 0, -25, 100, 25); + ctx.drawImage('red.png', 0, 0, 100, 50, 0, 50, 100, 25); + verify(Helper.comparePixel(ctx, 0,0, 0,255,0,255,2)); + verify(Helper.comparePixel(ctx, 99,0, 0,255,0,255,2)); + verify(Helper.comparePixel(ctx, 0,49, 0,255,0,255,2)); + verify(Helper.comparePixel(ctx, 99,49, 0,255,0,255,2)); + + ctx.fillStyle = '#f00'; + ctx.fillRect(0, 0, 100, 50); + ctx.drawImage('rgrg-256x256.png', 140, 20, 100, 50, 0, 0, 100, 50); + verify(Helper.comparePixel(ctx, 0,0, 0,255,0,255,2)); + verify(Helper.comparePixel(ctx, 99,0, 0,255,0,255,2)); + verify(Helper.comparePixel(ctx, 0,49, 0,255,0,255,2)); + verify(Helper.comparePixel(ctx, 99,49, 0,255,0,255,2)); + + ctx.fillStyle = '#f00'; + ctx.fillRect(0, 0, 100, 50); + ctx.drawImage('rgrg-256x256.png', 0, 0, 256, 256, 0, 0, 100, 50); + ctx.fillStyle = '#0f0'; + ctx.fillRect(0, 0, 51, 26); + ctx.fillRect(49, 24, 51, 26); + verify(Helper.comparePixel(ctx, 0,0, 0,255,0,255,2)); + verify(Helper.comparePixel(ctx, 99,0, 0,255,0,255,2)); + verify(Helper.comparePixel(ctx, 0,49, 0,255,0,255,2)); + verify(Helper.comparePixel(ctx, 99,49, 0,255,0,255,2)); + verify(Helper.comparePixel(ctx, 20,20, 0,255,0,255,2)); + verify(Helper.comparePixel(ctx, 80,20, 0,255,0,255,2)); + verify(Helper.comparePixel(ctx, 20,30, 0,255,0,255,2)); + verify(Helper.comparePixel(ctx, 80,30, 0,255,0,255,2)); + + } + function test_animated() { + var ctx = canvas.getContext('2d'); + ctx.reset(); + //should animated image be supported at all? + } + function test_clip() { + var ctx = canvas.getContext('2d'); + ctx.reset(); + ctx.fillStyle = '#0f0'; + ctx.fillRect(0, 0, 100, 50); + ctx.rect(-10, -10, 1, 1); + ctx.clip(); + ctx.drawImage('red.png', 0, 0); + verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255,2)); + + + } + function test_self() { + var ctx = canvas.getContext('2d'); + ctx.reset(); + ignoreWarning("QImage::scaled: Image is a null image"); + ignoreWarning("QImage::scaled: Image is a null image"); + + ctx.fillStyle = '#0f0'; + ctx.fillRect(0, 0, 50, 50); + ctx.fillStyle = '#f00'; + ctx.fillRect(50, 0, 50, 50); + ctx.drawImage(canvas, 50, 0); + + verify(Helper.comparePixel(ctx, 0,0, 0,255,0,255,2)); + verify(Helper.comparePixel(ctx, 99,0, 0,255,0,255,2)); + verify(Helper.comparePixel(ctx, 0,49, 0,255,0,255,2)); + verify(Helper.comparePixel(ctx, 99,49, 0,255,0,255,2)); + + ctx.reset(); + ctx.fillStyle = '#0f0'; + ctx.fillRect(0, 1, 100, 49); + ctx.fillStyle = '#f00'; + ctx.fillRect(0, 0, 100, 1); + ctx.drawImage(canvas, 0, 1); + ctx.fillStyle = '#0f0'; + ctx.fillRect(0, 0, 100, 2); + + verify(Helper.comparePixel(ctx, 0,0, 0,255,0,255,2)); + verify(Helper.comparePixel(ctx, 99,0, 0,255,0,255,2)); + verify(Helper.comparePixel(ctx, 0,49, 0,255,0,255,2)); + verify(Helper.comparePixel(ctx, 99,49, 0,255,0,255,2)); + + + } + + function test_outsidesource() { + var ctx = canvas.getContext('2d'); + ctx.reset(); + + ctx.drawImage('green.png', 10.5, 10.5, 89.5, 39.5, 0, 0, 100, 50); + ctx.drawImage('green.png', 5.5, 5.5, -5.5, -5.5, 0, 0, 100, 50); + ctx.drawImage('green.png', 100, 50, -5, -5, 0, 0, 100, 50); + try { var err = false; + ctx.drawImage('red.png', -0.001, 0, 100, 50, 0, 0, 100, 50); + } catch (e) { if (e.code != DOMException.INDEX_SIZE_ERR) fail("Failed assertion: expected exception of type INDEX_SIZE_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type INDEX_SIZE_ERR: ctx.drawImage('red.png', -0.001, 0, 100, 50, 0, 0, 100, 50)"); } + try { var err = false; + ctx.drawImage('red.png', 0, -0.001, 100, 50, 0, 0, 100, 50); + } catch (e) { if (e.code != DOMException.INDEX_SIZE_ERR) fail("Failed assertion: expected exception of type INDEX_SIZE_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type INDEX_SIZE_ERR: ctx.drawImage('red.png', 0, -0.001, 100, 50, 0, 0, 100, 50)"); } + try { var err = false; + ctx.drawImage('red.png', 0, 0, 100.001, 50, 0, 0, 100, 50); + } catch (e) { if (e.code != DOMException.INDEX_SIZE_ERR) fail("Failed assertion: expected exception of type INDEX_SIZE_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type INDEX_SIZE_ERR: ctx.drawImage('red.png', 0, 0, 100.001, 50, 0, 0, 100, 50)"); } + try { var err = false; + ctx.drawImage('red.png', 0, 0, 100, 50.001, 0, 0, 100, 50); + } catch (e) { if (e.code != DOMException.INDEX_SIZE_ERR) fail("Failed assertion: expected exception of type INDEX_SIZE_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type INDEX_SIZE_ERR: ctx.drawImage('red.png', 0, 0, 100, 50.001, 0, 0, 100, 50)"); } + try { var err = false; + ctx.drawImage('red.png', 50, 0, 50.001, 50, 0, 0, 100, 50); + } catch (e) { if (e.code != DOMException.INDEX_SIZE_ERR) fail("Failed assertion: expected exception of type INDEX_SIZE_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type INDEX_SIZE_ERR: ctx.drawImage('red.png', 50, 0, 50.001, 50, 0, 0, 100, 50)"); } + try { var err = false; + ctx.drawImage('red.png', 0, 0, -5, 5, 0, 0, 100, 50); + } catch (e) { if (e.code != DOMException.INDEX_SIZE_ERR) fail("Failed assertion: expected exception of type INDEX_SIZE_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type INDEX_SIZE_ERR: ctx.drawImage('red.png', 0, 0, -5, 5, 0, 0, 100, 50)"); } + try { var err = false; + ctx.drawImage('red.png', 0, 0, 5, -5, 0, 0, 100, 50); + } catch (e) { if (e.code != DOMException.INDEX_SIZE_ERR) fail("Failed assertion: expected exception of type INDEX_SIZE_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type INDEX_SIZE_ERR: ctx.drawImage('red.png', 0, 0, 5, -5, 0, 0, 100, 50)"); } +// try { var err = false; +// ctx.drawImage('red.png', 110, 60, -20, -20, 0, 0, 100, 50); +// } catch (e) { if (e.code != DOMException.INDEX_SIZE_ERR) fail("Failed assertion: expected exception of type INDEX_SIZE_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type INDEX_SIZE_ERR: ctx.drawImage('red.png', 110, 60, -20, -20, 0, 0, 100, 50)"); } +// verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255,2)); + + } + + function test_null() { + var ctx = canvas.getContext('2d'); + ctx.reset(); + + try { var err = false; + ctx.drawImage(null, 0, 0); + } catch (e) { if (e.code != DOMException.TYPE_MISMATCH_ERR) fail("Failed assertion: expected exception of type TYPE_MISMATCH_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type TYPE_MISMATCH_ERR: ctx.drawImage(null, 0, 0)"); } + + } + + function test_composite() { + var ctx = canvas.getContext('2d'); + ctx.reset(); + ctx.fillStyle = '#0f0'; + ctx.fillRect(0, 0, 100, 50); + ctx.globalCompositeOperation = 'destination-over'; + ctx.drawImage('red.png', 0, 0); + verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255,2)); + + } + function test_path() { + var ctx = canvas.getContext('2d'); + ctx.reset(); + } + function test_transform() { + var ctx = canvas.getContext('2d'); + ctx.reset(); + ctx.fillStyle = '#0f0'; + ctx.fillRect(0, 0, 100, 50); + ctx.translate(100, 0); + ctx.drawImage('red.png', 0, 0); + verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255,2)); + + } + + function test_imageitem() { + var ctx = canvas.getContext('2d'); + ctx.reset(); + //TODO + } + + function test_imageData() { + var ctx = canvas.getContext('2d'); + ctx.reset(); + //TODO + } + + function test_wrongtype() { + var ctx = canvas.getContext('2d'); + ctx.reset(); + + try { var err = false; + ctx.drawImage(undefined, 0, 0); + } catch (e) { if (e.code != DOMException.TYPE_MISMATCH_ERR) fail("Failed assertion: expected exception of type TYPE_MISMATCH_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type TYPE_MISMATCH_ERR: ctx.drawImage(undefined, 0, 0)"); } + try { var err = false; + ctx.drawImage(0, 0, 0); + } catch (e) { if (e.code != DOMException.TYPE_MISMATCH_ERR) fail("Failed assertion: expected exception of type TYPE_MISMATCH_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type TYPE_MISMATCH_ERR: ctx.drawImage(0, 0, 0)"); } + try { var err = false; + ctx.drawImage("", 0, 0); + } catch (e) { if (e.code != DOMException.TYPE_MISMATCH_ERR) fail("Failed assertion: expected exception of type TYPE_MISMATCH_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type TYPE_MISMATCH_ERR: ctx.drawImage(\"\", 0, 0)"); } + } + + function test_nonfinite() { + var ctx = canvas.getContext('2d'); + ctx.reset(); + ignoreWarning("QImage::scaled: Image is a null image"); + ignoreWarning("QImage::scaled: Image is a null image"); + ignoreWarning("QImage::scaled: Image is a null image"); + ignoreWarning("QImage::scaled: Image is a null image"); + ctx.fillStyle = '#0f0'; + ctx.fillRect(0, 0, 100, 50); + var red = 'red.png'; + ctx.drawImage(red, Infinity, 0); + ctx.drawImage(red, -Infinity, 0); + ctx.drawImage(red, NaN, 0); + ctx.drawImage(red, 0, Infinity); + ctx.drawImage(red, 0, -Infinity); + ctx.drawImage(red, 0, NaN); + ctx.drawImage(red, Infinity, Infinity); + ctx.drawImage(red, Infinity, 0, 100, 50); + ctx.drawImage(red, -Infinity, 0, 100, 50); + ctx.drawImage(red, NaN, 0, 100, 50); + ctx.drawImage(red, 0, Infinity, 100, 50); + ctx.drawImage(red, 0, -Infinity, 100, 50); + ctx.drawImage(red, 0, NaN, 100, 50); + ctx.drawImage(red, 0, 0, Infinity, 50); + ctx.drawImage(red, 0, 0, -Infinity, 50); + ctx.drawImage(red, 0, 0, NaN, 50); + ctx.drawImage(red, 0, 0, 100, Infinity); + ctx.drawImage(red, 0, 0, 100, -Infinity); + ctx.drawImage(red, 0, 0, 100, NaN); + ctx.drawImage(red, Infinity, Infinity, 100, 50); + ctx.drawImage(red, Infinity, Infinity, Infinity, 50); + ctx.drawImage(red, Infinity, Infinity, Infinity, Infinity); + ctx.drawImage(red, Infinity, Infinity, 100, Infinity); + ctx.drawImage(red, Infinity, 0, Infinity, 50); + ctx.drawImage(red, Infinity, 0, Infinity, Infinity); + ctx.drawImage(red, Infinity, 0, 100, Infinity); + ctx.drawImage(red, 0, Infinity, Infinity, 50); + ctx.drawImage(red, 0, Infinity, Infinity, Infinity); + ctx.drawImage(red, 0, Infinity, 100, Infinity); + ctx.drawImage(red, 0, 0, Infinity, Infinity); + ctx.drawImage(red, Infinity, 0, 100, 50, 0, 0, 100, 50); + ctx.drawImage(red, -Infinity, 0, 100, 50, 0, 0, 100, 50); + ctx.drawImage(red, NaN, 0, 100, 50, 0, 0, 100, 50); + ctx.drawImage(red, 0, Infinity, 100, 50, 0, 0, 100, 50); + ctx.drawImage(red, 0, -Infinity, 100, 50, 0, 0, 100, 50); + ctx.drawImage(red, 0, NaN, 100, 50, 0, 0, 100, 50); + ctx.drawImage(red, 0, 0, Infinity, 50, 0, 0, 100, 50); + ctx.drawImage(red, 0, 0, -Infinity, 50, 0, 0, 100, 50); + ctx.drawImage(red, 0, 0, NaN, 50, 0, 0, 100, 50); + ctx.drawImage(red, 0, 0, 100, Infinity, 0, 0, 100, 50); + ctx.drawImage(red, 0, 0, 100, -Infinity, 0, 0, 100, 50); + ctx.drawImage(red, 0, 0, 100, NaN, 0, 0, 100, 50); + ctx.drawImage(red, 0, 0, 100, 50, Infinity, 0, 100, 50); + ctx.drawImage(red, 0, 0, 100, 50, -Infinity, 0, 100, 50); + ctx.drawImage(red, 0, 0, 100, 50, NaN, 0, 100, 50); + ctx.drawImage(red, 0, 0, 100, 50, 0, Infinity, 100, 50); + ctx.drawImage(red, 0, 0, 100, 50, 0, -Infinity, 100, 50); + ctx.drawImage(red, 0, 0, 100, 50, 0, NaN, 100, 50); + ctx.drawImage(red, 0, 0, 100, 50, 0, 0, Infinity, 50); + ctx.drawImage(red, 0, 0, 100, 50, 0, 0, -Infinity, 50); + ctx.drawImage(red, 0, 0, 100, 50, 0, 0, NaN, 50); + ctx.drawImage(red, 0, 0, 100, 50, 0, 0, 100, Infinity); + ctx.drawImage(red, 0, 0, 100, 50, 0, 0, 100, -Infinity); + ctx.drawImage(red, 0, 0, 100, 50, 0, 0, 100, NaN); + ctx.drawImage(red, Infinity, Infinity, 100, 50, 0, 0, 100, 50); + ctx.drawImage(red, Infinity, Infinity, Infinity, 50, 0, 0, 100, 50); + ctx.drawImage(red, Infinity, Infinity, Infinity, Infinity, 0, 0, 100, 50); + ctx.drawImage(red, Infinity, Infinity, Infinity, Infinity, Infinity, 0, 100, 50); + ctx.drawImage(red, Infinity, Infinity, Infinity, Infinity, Infinity, Infinity, 100, 50); + ctx.drawImage(red, Infinity, Infinity, Infinity, Infinity, Infinity, Infinity, Infinity, 50); + ctx.drawImage(red, Infinity, Infinity, Infinity, Infinity, Infinity, Infinity, Infinity, Infinity); + ctx.drawImage(red, Infinity, Infinity, Infinity, Infinity, Infinity, Infinity, 100, Infinity); + ctx.drawImage(red, Infinity, Infinity, Infinity, Infinity, Infinity, 0, Infinity, 50); + ctx.drawImage(red, Infinity, Infinity, Infinity, Infinity, Infinity, 0, Infinity, Infinity); + ctx.drawImage(red, Infinity, Infinity, Infinity, Infinity, Infinity, 0, 100, Infinity); + ctx.drawImage(red, Infinity, Infinity, Infinity, Infinity, 0, Infinity, 100, 50); + ctx.drawImage(red, Infinity, Infinity, Infinity, Infinity, 0, Infinity, Infinity, 50); + ctx.drawImage(red, Infinity, Infinity, Infinity, Infinity, 0, Infinity, Infinity, Infinity); + ctx.drawImage(red, Infinity, Infinity, Infinity, Infinity, 0, Infinity, 100, Infinity); + ctx.drawImage(red, Infinity, Infinity, Infinity, Infinity, 0, 0, Infinity, 50); + ctx.drawImage(red, Infinity, Infinity, Infinity, Infinity, 0, 0, Infinity, Infinity); + ctx.drawImage(red, Infinity, Infinity, Infinity, Infinity, 0, 0, 100, Infinity); + ctx.drawImage(red, Infinity, Infinity, Infinity, 50, Infinity, 0, 100, 50); + ctx.drawImage(red, Infinity, Infinity, Infinity, 50, Infinity, Infinity, 100, 50); + ctx.drawImage(red, Infinity, Infinity, Infinity, 50, Infinity, Infinity, Infinity, 50); + ctx.drawImage(red, Infinity, Infinity, Infinity, 50, Infinity, Infinity, Infinity, Infinity); + ctx.drawImage(red, Infinity, Infinity, Infinity, 50, Infinity, Infinity, 100, Infinity); + ctx.drawImage(red, Infinity, Infinity, Infinity, 50, Infinity, 0, Infinity, 50); + ctx.drawImage(red, Infinity, Infinity, Infinity, 50, Infinity, 0, Infinity, Infinity); + ctx.drawImage(red, Infinity, Infinity, Infinity, 50, Infinity, 0, 100, Infinity); + ctx.drawImage(red, Infinity, Infinity, Infinity, 50, 0, Infinity, 100, 50); + ctx.drawImage(red, Infinity, Infinity, Infinity, 50, 0, Infinity, Infinity, 50); + ctx.drawImage(red, Infinity, Infinity, Infinity, 50, 0, Infinity, Infinity, Infinity); + ctx.drawImage(red, Infinity, Infinity, Infinity, 50, 0, Infinity, 100, Infinity); + ctx.drawImage(red, Infinity, Infinity, Infinity, 50, 0, 0, Infinity, 50); + ctx.drawImage(red, Infinity, Infinity, Infinity, 50, 0, 0, Infinity, Infinity); + ctx.drawImage(red, Infinity, Infinity, Infinity, 50, 0, 0, 100, Infinity); + ctx.drawImage(red, Infinity, Infinity, 100, Infinity, 0, 0, 100, 50); + ctx.drawImage(red, Infinity, Infinity, 100, Infinity, Infinity, 0, 100, 50); + ctx.drawImage(red, Infinity, Infinity, 100, Infinity, Infinity, Infinity, 100, 50); + ctx.drawImage(red, Infinity, Infinity, 100, Infinity, Infinity, Infinity, Infinity, 50); + ctx.drawImage(red, Infinity, Infinity, 100, Infinity, Infinity, Infinity, Infinity, Infinity); + ctx.drawImage(red, Infinity, Infinity, 100, Infinity, Infinity, Infinity, 100, Infinity); + ctx.drawImage(red, Infinity, Infinity, 100, Infinity, Infinity, 0, Infinity, 50); + ctx.drawImage(red, Infinity, Infinity, 100, Infinity, Infinity, 0, Infinity, Infinity); + ctx.drawImage(red, Infinity, Infinity, 100, Infinity, Infinity, 0, 100, Infinity); + ctx.drawImage(red, Infinity, Infinity, 100, Infinity, 0, Infinity, 100, 50); + ctx.drawImage(red, Infinity, Infinity, 100, Infinity, 0, Infinity, Infinity, 50); + ctx.drawImage(red, Infinity, Infinity, 100, Infinity, 0, Infinity, Infinity, Infinity); + ctx.drawImage(red, Infinity, Infinity, 100, Infinity, 0, Infinity, 100, Infinity); + ctx.drawImage(red, Infinity, Infinity, 100, Infinity, 0, 0, Infinity, 50); + ctx.drawImage(red, Infinity, Infinity, 100, Infinity, 0, 0, Infinity, Infinity); + ctx.drawImage(red, Infinity, Infinity, 100, Infinity, 0, 0, 100, Infinity); + ctx.drawImage(red, Infinity, Infinity, 100, 50, Infinity, 0, 100, 50); + ctx.drawImage(red, Infinity, Infinity, 100, 50, Infinity, Infinity, 100, 50); + ctx.drawImage(red, Infinity, Infinity, 100, 50, Infinity, Infinity, Infinity, 50); + ctx.drawImage(red, Infinity, Infinity, 100, 50, Infinity, Infinity, Infinity, Infinity); + ctx.drawImage(red, Infinity, Infinity, 100, 50, Infinity, Infinity, 100, Infinity); + ctx.drawImage(red, Infinity, Infinity, 100, 50, Infinity, 0, Infinity, 50); + ctx.drawImage(red, Infinity, Infinity, 100, 50, Infinity, 0, Infinity, Infinity); + ctx.drawImage(red, Infinity, Infinity, 100, 50, Infinity, 0, 100, Infinity); + ctx.drawImage(red, Infinity, Infinity, 100, 50, 0, Infinity, 100, 50); + ctx.drawImage(red, Infinity, Infinity, 100, 50, 0, Infinity, Infinity, 50); + ctx.drawImage(red, Infinity, Infinity, 100, 50, 0, Infinity, Infinity, Infinity); + ctx.drawImage(red, Infinity, Infinity, 100, 50, 0, Infinity, 100, Infinity); + ctx.drawImage(red, Infinity, Infinity, 100, 50, 0, 0, Infinity, 50); + ctx.drawImage(red, Infinity, Infinity, 100, 50, 0, 0, Infinity, Infinity); + ctx.drawImage(red, Infinity, Infinity, 100, 50, 0, 0, 100, Infinity); + ctx.drawImage(red, Infinity, 0, Infinity, 50, 0, 0, 100, 50); + ctx.drawImage(red, Infinity, 0, Infinity, Infinity, 0, 0, 100, 50); + ctx.drawImage(red, Infinity, 0, Infinity, Infinity, Infinity, 0, 100, 50); + ctx.drawImage(red, Infinity, 0, Infinity, Infinity, Infinity, Infinity, 100, 50); + ctx.drawImage(red, Infinity, 0, Infinity, Infinity, Infinity, Infinity, Infinity, 50); + ctx.drawImage(red, Infinity, 0, Infinity, Infinity, Infinity, Infinity, Infinity, Infinity); + ctx.drawImage(red, Infinity, 0, Infinity, Infinity, Infinity, Infinity, 100, Infinity); + ctx.drawImage(red, Infinity, 0, Infinity, Infinity, Infinity, 0, Infinity, 50); + ctx.drawImage(red, Infinity, 0, Infinity, Infinity, Infinity, 0, Infinity, Infinity); + ctx.drawImage(red, Infinity, 0, Infinity, Infinity, Infinity, 0, 100, Infinity); + ctx.drawImage(red, Infinity, 0, Infinity, Infinity, 0, Infinity, 100, 50); + ctx.drawImage(red, Infinity, 0, Infinity, Infinity, 0, Infinity, Infinity, 50); + ctx.drawImage(red, Infinity, 0, Infinity, Infinity, 0, Infinity, Infinity, Infinity); + ctx.drawImage(red, Infinity, 0, Infinity, Infinity, 0, Infinity, 100, Infinity); + ctx.drawImage(red, Infinity, 0, Infinity, Infinity, 0, 0, Infinity, 50); + ctx.drawImage(red, Infinity, 0, Infinity, Infinity, 0, 0, Infinity, Infinity); + ctx.drawImage(red, Infinity, 0, Infinity, Infinity, 0, 0, 100, Infinity); + ctx.drawImage(red, Infinity, 0, Infinity, 50, Infinity, 0, 100, 50); + ctx.drawImage(red, Infinity, 0, Infinity, 50, Infinity, Infinity, 100, 50); + ctx.drawImage(red, Infinity, 0, Infinity, 50, Infinity, Infinity, Infinity, 50); + ctx.drawImage(red, Infinity, 0, Infinity, 50, Infinity, Infinity, Infinity, Infinity); + ctx.drawImage(red, Infinity, 0, Infinity, 50, Infinity, Infinity, 100, Infinity); + ctx.drawImage(red, Infinity, 0, Infinity, 50, Infinity, 0, Infinity, 50); + ctx.drawImage(red, Infinity, 0, Infinity, 50, Infinity, 0, Infinity, Infinity); + ctx.drawImage(red, Infinity, 0, Infinity, 50, Infinity, 0, 100, Infinity); + ctx.drawImage(red, Infinity, 0, Infinity, 50, 0, Infinity, 100, 50); + ctx.drawImage(red, Infinity, 0, Infinity, 50, 0, Infinity, Infinity, 50); + ctx.drawImage(red, Infinity, 0, Infinity, 50, 0, Infinity, Infinity, Infinity); + ctx.drawImage(red, Infinity, 0, Infinity, 50, 0, Infinity, 100, Infinity); + ctx.drawImage(red, Infinity, 0, Infinity, 50, 0, 0, Infinity, 50); + ctx.drawImage(red, Infinity, 0, Infinity, 50, 0, 0, Infinity, Infinity); + ctx.drawImage(red, Infinity, 0, Infinity, 50, 0, 0, 100, Infinity); + ctx.drawImage(red, Infinity, 0, 100, Infinity, 0, 0, 100, 50); + ctx.drawImage(red, Infinity, 0, 100, Infinity, Infinity, 0, 100, 50); + ctx.drawImage(red, Infinity, 0, 100, Infinity, Infinity, Infinity, 100, 50); + ctx.drawImage(red, Infinity, 0, 100, Infinity, Infinity, Infinity, Infinity, 50); + ctx.drawImage(red, Infinity, 0, 100, Infinity, Infinity, Infinity, Infinity, Infinity); + ctx.drawImage(red, Infinity, 0, 100, Infinity, Infinity, Infinity, 100, Infinity); + ctx.drawImage(red, Infinity, 0, 100, Infinity, Infinity, 0, Infinity, 50); + ctx.drawImage(red, Infinity, 0, 100, Infinity, Infinity, 0, Infinity, Infinity); + ctx.drawImage(red, Infinity, 0, 100, Infinity, Infinity, 0, 100, Infinity); + ctx.drawImage(red, Infinity, 0, 100, Infinity, 0, Infinity, 100, 50); + ctx.drawImage(red, Infinity, 0, 100, Infinity, 0, Infinity, Infinity, 50); + ctx.drawImage(red, Infinity, 0, 100, Infinity, 0, Infinity, Infinity, Infinity); + ctx.drawImage(red, Infinity, 0, 100, Infinity, 0, Infinity, 100, Infinity); + ctx.drawImage(red, Infinity, 0, 100, Infinity, 0, 0, Infinity, 50); + ctx.drawImage(red, Infinity, 0, 100, Infinity, 0, 0, Infinity, Infinity); + ctx.drawImage(red, Infinity, 0, 100, Infinity, 0, 0, 100, Infinity); + ctx.drawImage(red, Infinity, 0, 100, 50, Infinity, 0, 100, 50); + ctx.drawImage(red, Infinity, 0, 100, 50, Infinity, Infinity, 100, 50); + ctx.drawImage(red, Infinity, 0, 100, 50, Infinity, Infinity, Infinity, 50); + ctx.drawImage(red, Infinity, 0, 100, 50, Infinity, Infinity, Infinity, Infinity); + ctx.drawImage(red, Infinity, 0, 100, 50, Infinity, Infinity, 100, Infinity); + ctx.drawImage(red, Infinity, 0, 100, 50, Infinity, 0, Infinity, 50); + ctx.drawImage(red, Infinity, 0, 100, 50, Infinity, 0, Infinity, Infinity); + ctx.drawImage(red, Infinity, 0, 100, 50, Infinity, 0, 100, Infinity); + ctx.drawImage(red, Infinity, 0, 100, 50, 0, Infinity, 100, 50); + ctx.drawImage(red, Infinity, 0, 100, 50, 0, Infinity, Infinity, 50); + ctx.drawImage(red, Infinity, 0, 100, 50, 0, Infinity, Infinity, Infinity); + ctx.drawImage(red, Infinity, 0, 100, 50, 0, Infinity, 100, Infinity); + ctx.drawImage(red, Infinity, 0, 100, 50, 0, 0, Infinity, 50); + ctx.drawImage(red, Infinity, 0, 100, 50, 0, 0, Infinity, Infinity); + ctx.drawImage(red, Infinity, 0, 100, 50, 0, 0, 100, Infinity); + ctx.drawImage(red, 0, Infinity, Infinity, 50, 0, 0, 100, 50); + ctx.drawImage(red, 0, Infinity, Infinity, Infinity, 0, 0, 100, 50); + ctx.drawImage(red, 0, Infinity, Infinity, Infinity, Infinity, 0, 100, 50); + ctx.drawImage(red, 0, Infinity, Infinity, Infinity, Infinity, Infinity, 100, 50); + ctx.drawImage(red, 0, Infinity, Infinity, Infinity, Infinity, Infinity, Infinity, 50); + ctx.drawImage(red, 0, Infinity, Infinity, Infinity, Infinity, Infinity, Infinity, Infinity); + ctx.drawImage(red, 0, Infinity, Infinity, Infinity, Infinity, Infinity, 100, Infinity); + ctx.drawImage(red, 0, Infinity, Infinity, Infinity, Infinity, 0, Infinity, 50); + ctx.drawImage(red, 0, Infinity, Infinity, Infinity, Infinity, 0, Infinity, Infinity); + ctx.drawImage(red, 0, Infinity, Infinity, Infinity, Infinity, 0, 100, Infinity); + ctx.drawImage(red, 0, Infinity, Infinity, Infinity, 0, Infinity, 100, 50); + ctx.drawImage(red, 0, Infinity, Infinity, Infinity, 0, Infinity, Infinity, 50); + ctx.drawImage(red, 0, Infinity, Infinity, Infinity, 0, Infinity, Infinity, Infinity); + ctx.drawImage(red, 0, Infinity, Infinity, Infinity, 0, Infinity, 100, Infinity); + ctx.drawImage(red, 0, Infinity, Infinity, Infinity, 0, 0, Infinity, 50); + ctx.drawImage(red, 0, Infinity, Infinity, Infinity, 0, 0, Infinity, Infinity); + ctx.drawImage(red, 0, Infinity, Infinity, Infinity, 0, 0, 100, Infinity); + ctx.drawImage(red, 0, Infinity, Infinity, 50, Infinity, 0, 100, 50); + ctx.drawImage(red, 0, Infinity, Infinity, 50, Infinity, Infinity, 100, 50); + ctx.drawImage(red, 0, Infinity, Infinity, 50, Infinity, Infinity, Infinity, 50); + ctx.drawImage(red, 0, Infinity, Infinity, 50, Infinity, Infinity, Infinity, Infinity); + ctx.drawImage(red, 0, Infinity, Infinity, 50, Infinity, Infinity, 100, Infinity); + ctx.drawImage(red, 0, Infinity, Infinity, 50, Infinity, 0, Infinity, 50); + ctx.drawImage(red, 0, Infinity, Infinity, 50, Infinity, 0, Infinity, Infinity); + ctx.drawImage(red, 0, Infinity, Infinity, 50, Infinity, 0, 100, Infinity); + ctx.drawImage(red, 0, Infinity, Infinity, 50, 0, Infinity, 100, 50); + ctx.drawImage(red, 0, Infinity, Infinity, 50, 0, Infinity, Infinity, 50); + ctx.drawImage(red, 0, Infinity, Infinity, 50, 0, Infinity, Infinity, Infinity); + ctx.drawImage(red, 0, Infinity, Infinity, 50, 0, Infinity, 100, Infinity); + ctx.drawImage(red, 0, Infinity, Infinity, 50, 0, 0, Infinity, 50); + ctx.drawImage(red, 0, Infinity, Infinity, 50, 0, 0, Infinity, Infinity); + ctx.drawImage(red, 0, Infinity, Infinity, 50, 0, 0, 100, Infinity); + ctx.drawImage(red, 0, Infinity, 100, Infinity, 0, 0, 100, 50); + ctx.drawImage(red, 0, Infinity, 100, Infinity, Infinity, 0, 100, 50); + ctx.drawImage(red, 0, Infinity, 100, Infinity, Infinity, Infinity, 100, 50); + ctx.drawImage(red, 0, Infinity, 100, Infinity, Infinity, Infinity, Infinity, 50); + ctx.drawImage(red, 0, Infinity, 100, Infinity, Infinity, Infinity, Infinity, Infinity); + ctx.drawImage(red, 0, Infinity, 100, Infinity, Infinity, Infinity, 100, Infinity); + ctx.drawImage(red, 0, Infinity, 100, Infinity, Infinity, 0, Infinity, 50); + ctx.drawImage(red, 0, Infinity, 100, Infinity, Infinity, 0, Infinity, Infinity); + ctx.drawImage(red, 0, Infinity, 100, Infinity, Infinity, 0, 100, Infinity); + ctx.drawImage(red, 0, Infinity, 100, Infinity, 0, Infinity, 100, 50); + ctx.drawImage(red, 0, Infinity, 100, Infinity, 0, Infinity, Infinity, 50); + ctx.drawImage(red, 0, Infinity, 100, Infinity, 0, Infinity, Infinity, Infinity); + ctx.drawImage(red, 0, Infinity, 100, Infinity, 0, Infinity, 100, Infinity); + ctx.drawImage(red, 0, Infinity, 100, Infinity, 0, 0, Infinity, 50); + ctx.drawImage(red, 0, Infinity, 100, Infinity, 0, 0, Infinity, Infinity); + ctx.drawImage(red, 0, Infinity, 100, Infinity, 0, 0, 100, Infinity); + ctx.drawImage(red, 0, Infinity, 100, 50, Infinity, 0, 100, 50); + ctx.drawImage(red, 0, Infinity, 100, 50, Infinity, Infinity, 100, 50); + ctx.drawImage(red, 0, Infinity, 100, 50, Infinity, Infinity, Infinity, 50); + ctx.drawImage(red, 0, Infinity, 100, 50, Infinity, Infinity, Infinity, Infinity); + ctx.drawImage(red, 0, Infinity, 100, 50, Infinity, Infinity, 100, Infinity); + ctx.drawImage(red, 0, Infinity, 100, 50, Infinity, 0, Infinity, 50); + ctx.drawImage(red, 0, Infinity, 100, 50, Infinity, 0, Infinity, Infinity); + ctx.drawImage(red, 0, Infinity, 100, 50, Infinity, 0, 100, Infinity); + ctx.drawImage(red, 0, Infinity, 100, 50, 0, Infinity, 100, 50); + ctx.drawImage(red, 0, Infinity, 100, 50, 0, Infinity, Infinity, 50); + ctx.drawImage(red, 0, Infinity, 100, 50, 0, Infinity, Infinity, Infinity); + ctx.drawImage(red, 0, Infinity, 100, 50, 0, Infinity, 100, Infinity); + ctx.drawImage(red, 0, Infinity, 100, 50, 0, 0, Infinity, 50); + ctx.drawImage(red, 0, Infinity, 100, 50, 0, 0, Infinity, Infinity); + ctx.drawImage(red, 0, Infinity, 100, 50, 0, 0, 100, Infinity); + ctx.drawImage(red, 0, 0, Infinity, Infinity, 0, 0, 100, 50); + ctx.drawImage(red, 0, 0, Infinity, Infinity, Infinity, 0, 100, 50); + ctx.drawImage(red, 0, 0, Infinity, Infinity, Infinity, Infinity, 100, 50); + ctx.drawImage(red, 0, 0, Infinity, Infinity, Infinity, Infinity, Infinity, 50); + ctx.drawImage(red, 0, 0, Infinity, Infinity, Infinity, Infinity, Infinity, Infinity); + ctx.drawImage(red, 0, 0, Infinity, Infinity, Infinity, Infinity, 100, Infinity); + ctx.drawImage(red, 0, 0, Infinity, Infinity, Infinity, 0, Infinity, 50); + ctx.drawImage(red, 0, 0, Infinity, Infinity, Infinity, 0, Infinity, Infinity); + ctx.drawImage(red, 0, 0, Infinity, Infinity, Infinity, 0, 100, Infinity); + ctx.drawImage(red, 0, 0, Infinity, Infinity, 0, Infinity, 100, 50); + ctx.drawImage(red, 0, 0, Infinity, Infinity, 0, Infinity, Infinity, 50); + ctx.drawImage(red, 0, 0, Infinity, Infinity, 0, Infinity, Infinity, Infinity); + ctx.drawImage(red, 0, 0, Infinity, Infinity, 0, Infinity, 100, Infinity); + ctx.drawImage(red, 0, 0, Infinity, Infinity, 0, 0, Infinity, 50); + ctx.drawImage(red, 0, 0, Infinity, Infinity, 0, 0, Infinity, Infinity); + ctx.drawImage(red, 0, 0, Infinity, Infinity, 0, 0, 100, Infinity); + ctx.drawImage(red, 0, 0, Infinity, 50, Infinity, 0, 100, 50); + ctx.drawImage(red, 0, 0, Infinity, 50, Infinity, Infinity, 100, 50); + ctx.drawImage(red, 0, 0, Infinity, 50, Infinity, Infinity, Infinity, 50); + ctx.drawImage(red, 0, 0, Infinity, 50, Infinity, Infinity, Infinity, Infinity); + ctx.drawImage(red, 0, 0, Infinity, 50, Infinity, Infinity, 100, Infinity); + ctx.drawImage(red, 0, 0, Infinity, 50, Infinity, 0, Infinity, 50); + ctx.drawImage(red, 0, 0, Infinity, 50, Infinity, 0, Infinity, Infinity); + ctx.drawImage(red, 0, 0, Infinity, 50, Infinity, 0, 100, Infinity); + ctx.drawImage(red, 0, 0, Infinity, 50, 0, Infinity, 100, 50); + ctx.drawImage(red, 0, 0, Infinity, 50, 0, Infinity, Infinity, 50); + ctx.drawImage(red, 0, 0, Infinity, 50, 0, Infinity, Infinity, Infinity); + ctx.drawImage(red, 0, 0, Infinity, 50, 0, Infinity, 100, Infinity); + ctx.drawImage(red, 0, 0, Infinity, 50, 0, 0, Infinity, 50); + ctx.drawImage(red, 0, 0, Infinity, 50, 0, 0, Infinity, Infinity); + ctx.drawImage(red, 0, 0, Infinity, 50, 0, 0, 100, Infinity); + ctx.drawImage(red, 0, 0, 100, Infinity, Infinity, 0, 100, 50); + ctx.drawImage(red, 0, 0, 100, Infinity, Infinity, Infinity, 100, 50); + ctx.drawImage(red, 0, 0, 100, Infinity, Infinity, Infinity, Infinity, 50); + ctx.drawImage(red, 0, 0, 100, Infinity, Infinity, Infinity, Infinity, Infinity); + ctx.drawImage(red, 0, 0, 100, Infinity, Infinity, Infinity, 100, Infinity); + ctx.drawImage(red, 0, 0, 100, Infinity, Infinity, 0, Infinity, 50); + ctx.drawImage(red, 0, 0, 100, Infinity, Infinity, 0, Infinity, Infinity); + ctx.drawImage(red, 0, 0, 100, Infinity, Infinity, 0, 100, Infinity); + ctx.drawImage(red, 0, 0, 100, Infinity, 0, Infinity, 100, 50); + ctx.drawImage(red, 0, 0, 100, Infinity, 0, Infinity, Infinity, 50); + ctx.drawImage(red, 0, 0, 100, Infinity, 0, Infinity, Infinity, Infinity); + ctx.drawImage(red, 0, 0, 100, Infinity, 0, Infinity, 100, Infinity); + ctx.drawImage(red, 0, 0, 100, Infinity, 0, 0, Infinity, 50); + ctx.drawImage(red, 0, 0, 100, Infinity, 0, 0, Infinity, Infinity); + ctx.drawImage(red, 0, 0, 100, Infinity, 0, 0, 100, Infinity); + ctx.drawImage(red, 0, 0, 100, 50, Infinity, Infinity, 100, 50); + ctx.drawImage(red, 0, 0, 100, 50, Infinity, Infinity, Infinity, 50); + ctx.drawImage(red, 0, 0, 100, 50, Infinity, Infinity, Infinity, Infinity); + ctx.drawImage(red, 0, 0, 100, 50, Infinity, Infinity, 100, Infinity); + ctx.drawImage(red, 0, 0, 100, 50, Infinity, 0, Infinity, 50); + ctx.drawImage(red, 0, 0, 100, 50, Infinity, 0, Infinity, Infinity); + ctx.drawImage(red, 0, 0, 100, 50, Infinity, 0, 100, Infinity); + ctx.drawImage(red, 0, 0, 100, 50, 0, Infinity, Infinity, 50); + ctx.drawImage(red, 0, 0, 100, 50, 0, Infinity, Infinity, Infinity); + ctx.drawImage(red, 0, 0, 100, 50, 0, Infinity, 100, Infinity); + ctx.drawImage(red, 0, 0, 100, 50, 0, 0, Infinity, Infinity); + verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); + + } + + function test_negative() { + var ctx = canvas.getContext('2d'); + ctx.reset(); + + ctx.fillStyle = '#f00'; + ctx.fillRect(0, 0, 100, 50); + ctx.drawImage('ggrr-256x256.png', 100, 78, 50, 50, 0, 50, 50, -50); + ctx.drawImage('ggrr-256x256.png', 100, 128, 50, -50, 100, 50, -50, -50); +// verify(Helper.comparePixel(ctx, 1,1, 0,255,0,255,2)); +// verify(Helper.comparePixel(ctx, 1,48, 0,255,0,255,2)); +// verify(Helper.comparePixel(ctx, 98,1, 0,255,0,255,2)); +// verify(Helper.comparePixel(ctx, 98,48, 0,255,0,255,2)); +// verify(Helper.comparePixel(ctx, 48,1, 0,255,0,255,2)); +// verify(Helper.comparePixel(ctx, 48,48, 0,255,0,255,2)); +// verify(Helper.comparePixel(ctx, 51,1, 0,255,0,255,2)); +// verify(Helper.comparePixel(ctx, 51,48, 0,255,0,255,2)); +// verify(Helper.comparePixel(ctx, 25,25, 0,255,0,255,2)); +// verify(Helper.comparePixel(ctx, 75,25, 0,255,0,255,2)); + + ctx.reset(); + ctx.fillStyle = '#f00'; + ctx.fillRect(0, 0, 100, 50); + ctx.drawImage('ggrr-256x256.png', 0, 178, 50, -100, 0, 0, 50, 100); + ctx.drawImage('ggrr-256x256.png', 0, 78, 50, 100, 50, 100, 50, -100); +// verify(Helper.comparePixel(ctx, 1,1, 0,255,0,255,2)); +// verify(Helper.comparePixel(ctx, 1,48, 0,255,0,255,2)); +// verify(Helper.comparePixel(ctx, 98,1, 0,255,0,255,2)); +// verify(Helper.comparePixel(ctx, 98,48, 0,255,0,255,2)); +// verify(Helper.comparePixel(ctx, 48,1, 0,255,0,255,2)); +// verify(Helper.comparePixel(ctx, 48,48, 0,255,0,255,2)); +// verify(Helper.comparePixel(ctx, 51,1, 0,255,0,255,2)); +// verify(Helper.comparePixel(ctx, 51,48, 0,255,0,255,2)); +// verify(Helper.comparePixel(ctx, 25,25, 0,255,0,255,2)); +// verify(Helper.comparePixel(ctx, 75,25, 0,255,0,255,2)); + + ctx.reset(); + ctx.fillStyle = '#f00'; + ctx.fillRect(0, 0, 100, 50); + ctx.drawImage('ggrr-256x256.png', 100, 78, -100, 50, 0, 0, 50, 50); + ctx.drawImage('ggrr-256x256.png', 100, 128, -100, -50, 50, 0, 50, 50); +// verify(Helper.comparePixel(ctx, 1,1, 0,255,0,255,2)); +// verify(Helper.comparePixel(ctx, 1,48, 0,255,0,255,2)); +// verify(Helper.comparePixel(ctx, 98,1, 0,255,0,255,2)); +// verify(Helper.comparePixel(ctx, 98,48, 0,255,0,255,2)); +// verify(Helper.comparePixel(ctx, 48,1, 0,255,0,255,2)); +// verify(Helper.comparePixel(ctx, 48,48, 0,255,0,255,2)); +// verify(Helper.comparePixel(ctx, 51,1, 0,255,0,255,2)); +// verify(Helper.comparePixel(ctx, 51,48, 0,255,0,255,2)); +// verify(Helper.comparePixel(ctx, 25,25, 0,255,0,255,2)); +// verify(Helper.comparePixel(ctx, 75,25, 0,255,0,255,2)); + + } + + function test_canvas() { + var ctx = canvas.getContext('2d'); + ctx.reset(); + var canvas2 = Qt.createQmlObject("import QtQuick 2.0; Canvas{renderTarget:Canvas.Image}", canvas); + canvas2.width = 100; + canvas2.height = 50; + var ctx2 = canvas2.getContext('2d'); + ctx2.fillStyle = '#0f0'; + ctx2.fillRect(0, 0, 100, 50); + + ctx.fillStyle = '#f00'; + ctx.drawImage(canvas2, 0, 0); + + //verify(Helper.comparePixel(ctx, 0,0, 0,255,0,255,2)); + //verify(Helper.comparePixel(ctx, 99,0, 0,255,0,255,2)); + //verify(Helper.comparePixel(ctx, 0,49, 0,255,0,255,2)); + //verify(Helper.comparePixel(ctx, 99,49, 0,255,0,255,2)); + + } + + function test_broken() { + var ctx = canvas.getContext('2d'); + ctx.reset(); + var img = 'broken.png'; + verify(!img.complete); + ctx.drawImage(img, 0, 0); + } + + function test_alpha() { + var ctx=canvas.getContext('2d'); + ctx.reset(); + ctx.fillStyle = '#0f0'; + ctx.fillRect(0, 0, 100, 50); + ctx.globalAlpha = 0; + ctx.drawImage('red.png', 0, 0); + verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255, 2)); + + } + } +} diff --git a/tests/auto/quick/qquickcanvasitem/data/tst_fillStyle.qml b/tests/auto/quick/qquickcanvasitem/data/tst_fillStyle.qml new file mode 100644 index 0000000000..8f5a78cec0 --- /dev/null +++ b/tests/auto/quick/qquickcanvasitem/data/tst_fillStyle.qml @@ -0,0 +1,113 @@ +import QtQuick 2.0 +import QtTest 1.0 +import "testhelper.js" as Helper + +Canvas { + id:canvas; width:1;height:1;renderTarget:Canvas.Image + TestCase { + name: "fillStyle"; when: windowShown + function test_default() { + var ctx = canvas.getContext('2d'); + ctx.reset(); + verify(ctx.fillStyle, "#000000"); + ctx.clearRect(0, 0, 1, 1); + compare(ctx.fillStyle, "#000000"); + } + function test_get() { + var ctx = canvas.getContext('2d'); + ctx.reset(); + ctx.fillStyle = '#fa0'; + compare(ctx.fillStyle, '#ffaa00'); + ctx.fillStyle = Qt.rgba(0,0,0,0); + compare(ctx.fillStyle, 'rgba(0, 0, 0, 0.0)'); + } + function test_hex() { + var ctx = canvas.getContext('2d'); + ctx.reset(); + ctx.fillStyle = '#f00'; + compare(ctx.fillStyle, '#ff0000'); + ctx.fillStyle = "#0f0"; + compare(ctx.fillStyle, '#00ff00'); + ctx.fillStyle = "#0fF"; + compare(ctx.fillStyle, '#00ffff'); + ctx.fillStyle = "#0aCCfb"; + compare(ctx.fillStyle, '#0accfb'); + + } + function test_invalid() { + var ctx = canvas.getContext('2d'); + ctx.reset(); + ctx.fillStyle = '#fa0'; + compare(ctx.fillStyle, '#ffaa00'); + ctx.fillStyle = "invalid"; + compare(ctx.fillStyle, '#ffaa00'); + ctx.fillStyle = "rgb (1, 2, 3)"; + compare(ctx.fillStyle, '#ffaa00'); + ctx.fillStyle = '#fa0'; + + ctx.fillStyle = "rgba(3, 1, 2)"; + compare(ctx.fillStyle, '#ffaa00'); + ctx.fillStyle = "rgb((3,4,1)"; + compare(ctx.fillStyle, '#ffaa00'); + ctx.fillStyle = "rgb(1, 3, 4, 0.5)"; + compare(ctx.fillStyle, '#ffaa00'); + ctx.fillStyle = "hsl(2, 3, 4, 0.8)"; + compare(ctx.fillStyle, '#ffaa00'); + ctx.fillStyle = "hsl(2, 3, 4"; + compare(ctx.fillStyle, '#ffaa00'); + } + function test_saverestore() { + var ctx = canvas.getContext('2d'); + var old = ctx.fillStyle; + ctx.save(); + ctx.fillStyle = "#ffaaff"; + ctx.restore(); + compare(ctx.fillStyle, old); + + ctx.fillStyle = "#ffcc88"; + old = ctx.fillStyle; + ctx.save(); + compare(ctx.fillStyle, old); + ctx.restore(); + } + function test_namedColor() { + var ctx = canvas.getContext('2d'); + ctx.reset(); + ctx.fillStyle = "red"; + ctx.fillRect(0,0,1,1); + verify(Helper.comparePixel(ctx,0,0,255,0,0,255)); + + ctx.fillStyle = "black"; + ctx.fillRect(0,0,1,1); + verify(Helper.comparePixel(ctx,0,0,0,0,0,255)); + + ctx.fillStyle = "white"; + ctx.fillRect(0,0,1,1); + verify(Helper.comparePixel(ctx,0,0,255,255,255,255)); + } + function test_rgba() { + var ctx = canvas.getContext('2d'); + ctx.reset(); + ctx.fillStyle = "rgb(-100, 300, 255)"; + compare(ctx.fillStyle, "#00ffff"); + ctx.fillStyle = "rgba(-100, 300, 255, 0.0)"; + compare(ctx.fillStyle, "rgba(0, 255, 255, 0.0)"); + ctx.fillStyle = "rgb(-10%, 110%, 50%)"; + compare(ctx.fillStyle, "#00ff80"); + + ctx.clearRect(0, 0, 1, 1); + ctx.fillStyle = 'rgba(0%, 100%, 0%, 0.499)'; + ctx.fillRect(0, 0, 1, 1); + verify(Helper.comparePixel(ctx, 0,0, 0,255,0,127)); + } + + function test_hsla() { + var ctx = canvas.getContext('2d'); + ctx.reset(); + ctx.fillStyle = "hsla(120, 100%, 50%, 0.499)"; + ctx.fillRect(0, 0, 1, 1); + verify(Helper.comparePixel(ctx,0,0,0,255,0,127)); + } + + } +} diff --git a/tests/auto/quick/qquickcanvasitem/data/tst_fillrect.qml b/tests/auto/quick/qquickcanvasitem/data/tst_fillrect.qml new file mode 100644 index 0000000000..08197816e9 --- /dev/null +++ b/tests/auto/quick/qquickcanvasitem/data/tst_fillrect.qml @@ -0,0 +1,26 @@ +import QtQuick 2.0 +import QtTest 1.0 + +Canvas { + id:canvas; width:1;height:1; + renderTarget:Canvas.Image + renderStrategy: Canvas.Immediate + + TestCase { + name: "FillRect"; when: canvas.available + + function test_fillRect() { + var ctx = canvas.getContext('2d'); + ctx.fillStyle = "red"; + ctx.fillRect(0, 0, canvas.width, canvas.height); + + var imageData = ctx.getImageData(0, 0, 1, 1); + var d = imageData.data; + verify(d.length == 4); + verify(d[0] == 255); + verify(d[1] == 0); + verify(d[2] == 0); + verify(d[3] == 255); + } + } +} diff --git a/tests/auto/quick/qquickcanvasitem/data/tst_gradient.qml b/tests/auto/quick/qquickcanvasitem/data/tst_gradient.qml new file mode 100644 index 0000000000..d454c2efe1 --- /dev/null +++ b/tests/auto/quick/qquickcanvasitem/data/tst_gradient.qml @@ -0,0 +1,981 @@ +import QtQuick 2.0 +import QtTest 1.0 +import "testhelper.js" as Helper +Canvas { + id:canvas; width:100;height:50; renderTarget: Canvas.Image + TestCase { + name: "gradient"; when: windowShown + function test_basic() { + var ctx = canvas.getContext('2d'); + ctx.reset(); + ctx.fillStyle = '#0f0'; + ctx.fillRect(0, 0, 100, 50); + var g = ctx.createLinearGradient(0, 0, 0, 50); + ctx.fillStyle = g; + ctx.fillRect(0, 0, 100, 50); + //verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255,2)); + + } + + function test_interpolate() { + var ctx = canvas.getContext('2d'); + ctx.reset(); + + ctx.fillStyle = '#ff0'; + ctx.fillRect(0, 0, 100, 50); + var g = ctx.createLinearGradient(0, 0, 100, 0); + g.addColorStop(0, 'rgba(0,0,255, 0)'); + g.addColorStop(1, 'rgba(0,0,255, 1)'); + ctx.fillStyle = g; + ctx.fillRect(0, 0, 100, 50); + //verify(Helper.comparePixel(ctx, 25,25, 191,191,63,255,3)); + //verify(Helper.comparePixel(ctx, 50,25, 127,127,127,255,3)); + //verify(Helper.comparePixel(ctx, 75,25, 63,63,191,255,3)); + + ctx.reset(); + var g = ctx.createLinearGradient(0, 0, 100, 0); + g.addColorStop(0, '#ff0'); + g.addColorStop(1, '#00f'); + ctx.fillStyle = g; + ctx.fillRect(0, 0, 100, 50); + //verify(Helper.comparePixel(ctx, 25,25, 191,191,63,255,3)); + //verify(Helper.comparePixel(ctx, 50,25, 127,127,127,255,3)); + //verify(Helper.comparePixel(ctx, 75,25, 63,63,191,255,3)); + + + ctx.reset(); + var g = ctx.createLinearGradient(0, 0, 100, 0); + g.addColorStop(0, 'rgba(255,255,0, 0)'); + g.addColorStop(1, 'rgba(0,0,255, 1)'); + ctx.fillStyle = g; + ctx.fillRect(0, 0, 100, 50); + //verify(Helper.comparePixel(ctx, 25,25, 191,191,63,63,3)); + //verify(Helper.comparePixel(ctx, 50,25, 127,127,127,127,3)); + //verify(Helper.comparePixel(ctx, 75,25, 63,63,191,191,3)); + + ctx.reset(); + canvas.width = 200; + var g = ctx.createLinearGradient(0, 0, 200, 0); + g.addColorStop(0, '#ff0'); + g.addColorStop(0.5, '#0ff'); + g.addColorStop(1, '#f0f'); + ctx.fillStyle = g; + ctx.fillRect(0, 0, 200, 50); + //verify(Helper.comparePixel(ctx, 50,25, 127,255,127,255,3)); + //verify(Helper.comparePixel(ctx, 100,25, 0,255,255,255,3)); + //verify(Helper.comparePixel(ctx, 150,25, 127,127,255,255,3)); + + ctx.reset(); + ctx.fillStyle = '#f00'; + ctx.fillRect(0, 0, 100, 50); + + var g = ctx.createLinearGradient(25, 0, 75, 0); + g.addColorStop(0.4, '#0f0'); + g.addColorStop(0.6, '#0f0'); + + ctx.fillStyle = g; + ctx.fillRect(0, 0, 100, 50); + //verify(Helper.comparePixel(ctx, 20,25, 0,255,0,255,2)); + //verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255,2)); + //verify(Helper.comparePixel(ctx, 80,25, 0,255,0,255,2)); + + + ctx.reset(); + ctx.canvas.width = 200; + var g = ctx.createLinearGradient(0, 0, 200, 0); + g.addColorStop(0, '#f00'); + g.addColorStop(0, '#ff0'); + g.addColorStop(0.25, '#00f'); + g.addColorStop(0.25, '#0f0'); + g.addColorStop(0.25, '#0f0'); + g.addColorStop(0.25, '#0f0'); + g.addColorStop(0.25, '#ff0'); + g.addColorStop(0.5, '#00f'); + g.addColorStop(0.5, '#0f0'); + g.addColorStop(0.75, '#00f'); + g.addColorStop(0.75, '#f00'); + g.addColorStop(0.75, '#ff0'); + g.addColorStop(0.5, '#0f0'); + g.addColorStop(0.5, '#0f0'); + g.addColorStop(0.5, '#ff0'); + g.addColorStop(1, '#00f'); + ctx.fillStyle = g; + ctx.fillRect(0, 0, 200, 50); + //verify(Helper.comparePixel(ctx, 49,25, 0,0,255,255,16)); + //verify(Helper.comparePixel(ctx, 51,25, 255,255,0,255,16)); + //verify(Helper.comparePixel(ctx, 99,25, 0,0,255,255,16)); + //verify(Helper.comparePixel(ctx, 101,25, 255,255,0,255,16)); + //verify(Helper.comparePixel(ctx, 149,25, 0,0,255,255,16)); + //verify(Helper.comparePixel(ctx, 151,25, 255,255,0,255,16)); + ctx.canvas.width = 100; + + ctx.reset(); + var g = ctx.createLinearGradient(0, 0, 100, 0); + var ps = [ 0, 1/10, 1/4, 1/3, 1/2, 3/4, 1 ]; + for (var p = 0; p < ps.length; ++p) + { + g.addColorStop(ps[p], '#0f0'); + for (var i = 0; i < 15; ++i) + g.addColorStop(ps[p], '#f00'); + g.addColorStop(ps[p], '#0f0'); + } + ctx.fillStyle = g; + ctx.fillRect(0, 0, 100, 50); + //verify(Helper.comparePixel(ctx, 1,25, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 30,25, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 40,25, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 60,25, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 80,25, 0,255,0,255)); + + + ctx.reset(); + var g = ctx.createLinearGradient(0, 0, 100, 0); + g.addColorStop(0, '#0f0'); + g.addColorStop(1, '#0f0'); + ctx.fillStyle = g; + ctx.fillRect(0, 0, 100, 50); + //verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); + + + + ctx.reset(); + var g = ctx.createLinearGradient(0, 0, 0, 50); + g.addColorStop(0, '#ff0'); + g.addColorStop(1, '#00f'); + ctx.fillStyle = g; + ctx.fillRect(0, 0, 100, 50); + //verify(Helper.comparePixel(ctx, 50,12, 191,191,63,255,10)); + //verify(Helper.comparePixel(ctx, 50,25, 127,127,127,255,5)); + //verify(Helper.comparePixel(ctx, 50,37, 63,63,191,255,10)); + + + ctx.reset(); + + ctx.fillStyle = '#0f0'; + ctx.fillRect(0, 0, 100, 50); + + var g = ctx.createLinearGradient(50, 25, 50, 25); // zero-length line (undefined direction) + g.addColorStop(0, '#f00'); + g.addColorStop(1, '#f00'); + ctx.fillStyle = g; + ctx.fillRect(0, 0, 100, 50); + //verify(Helper.comparePixel(ctx, 40,20, 0,255,0,255,2)); + + + + } + function test_radial() { + var ctx = canvas.getContext('2d'); + ctx.reset(); + ctx.fillStyle = '#0f0'; + ctx.fillRect(0, 0, 100, 50); + + var g = ctx.createRadialGradient(0, 100, 40, 100, 100, 50); + g.addColorStop(0, '#f00'); + g.addColorStop(1, '#f00'); + ctx.fillStyle = g; + ctx.fillRect(0, 0, 100, 50); + + //verify(Helper.comparePixel(ctx, 1,1, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 50,1, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 98,1, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 1,25, 0,255,0,255,16)); + //verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 98,25, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 1,48, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 50,48, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 98,48, 0,255,0,255)); + + ctx.reset(); + ctx.fillStyle = '#f00'; + ctx.fillRect(0, 0, 100, 50); + + g = ctx.createRadialGradient(210, 25, 100, 230, 25, 101); + g.addColorStop(0, '#0f0'); + g.addColorStop(1, '#f00'); + ctx.fillStyle = g; + ctx.fillRect(0, 0, 100, 50); + + //verify(Helper.comparePixel(ctx, 1,1, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 50,1, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 98,1, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 1,25, 0,255,0,255,16)); + //verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 98,25, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 1,48, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 50,48, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 98,48, 0,255,0,255)); + + + ctx.reset(); + ctx.fillStyle = '#f00'; + ctx.fillRect(0, 0, 100, 50); + + g = ctx.createRadialGradient(210, 25, 100, 230, 25, 100); + g.addColorStop(0, '#0f0'); + g.addColorStop(1, '#f00'); + ctx.fillStyle = g; + ctx.fillRect(0, 0, 100, 50); + + //verify(Helper.comparePixel(ctx, 1,1, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 50,1, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 98,1, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 1,25, 0,255,0,255,16)); + //verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 98,25, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 1,48, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 50,48, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 98,48, 0,255,0,255)); + + ctx.reset(); + ctx.fillStyle = '#f00'; + ctx.fillRect(0, 0, 100, 50); + + g = ctx.createRadialGradient(311, 25, 10, 210, 25, 100); + g.addColorStop(0, '#f00'); + g.addColorStop(1, '#0f0'); + ctx.fillStyle = g; + ctx.fillRect(0, 0, 100, 50); + + //verify(Helper.comparePixel(ctx, 1,1, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 50,1, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 98,1, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 1,25, 0,255,0,255,16)); + //verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 98,25, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 1,48, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 50,48, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 98,48, 0,255,0,255)); + + ctx.reset(); + var tol = 1; // tolerance to avoid antialiasing artifacts + + ctx.fillStyle = '#0f0'; + ctx.fillRect(0, 0, 100, 50); + + ctx.fillStyle = '#f00'; + ctx.beginPath(); + ctx.moveTo(30+tol, 40); + ctx.lineTo(110, -20+tol); + ctx.lineTo(110, 100-tol); + ctx.fill(); + + g = ctx.createRadialGradient(30+10*5/2, 40, 10*3/2, 30+10*15/4, 40, 10*9/4); + g.addColorStop(0, '#0f0'); + g.addColorStop(1, '#0f0'); + ctx.fillStyle = g; + ctx.fillRect(0, 0, 100, 50); + + //verify(Helper.comparePixel(ctx, 1,1, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 50,1, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 98,1, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 1,25, 0,255,0,255,16)); + //verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 98,25, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 1,48, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 50,48, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 98,48, 0,255,0,255)); + + ctx.reset(); + var tol = 1; // tolerance to avoid antialiasing artifacts + + ctx.fillStyle = '#0f0'; + ctx.fillRect(0, 0, 100, 50); + + g = ctx.createRadialGradient(30+10*5/2, 40, 10*3/2, 30+10*15/4, 40, 10*9/4); + g.addColorStop(0, '#f00'); + g.addColorStop(1, '#f00'); + ctx.fillStyle = g; + ctx.fillRect(0, 0, 100, 50); + + ctx.fillStyle = '#0f0'; + ctx.beginPath(); + ctx.moveTo(30-tol, 40); + ctx.lineTo(110, -20-tol); + ctx.lineTo(110, 100+tol); + ctx.fill(); + + //verify(Helper.comparePixel(ctx, 1,1, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 50,1, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 98,1, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 1,25, 0,255,0,255,16)); + //verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 98,25, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 1,48, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 50,48, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 98,48, 0,255,0,255)); + + ctx.reset(); + ctx.fillStyle = '#f00'; + ctx.fillRect(0, 0, 100, 50); + + g = ctx.createRadialGradient(230, 25, 100, 100, 25, 101); + g.addColorStop(0, '#f00'); + g.addColorStop(1, '#0f0'); + ctx.fillStyle = g; + ctx.fillRect(0, 0, 100, 50); + + //verify(Helper.comparePixel(ctx, 1,1, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 50,1, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 98,1, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 1,25, 0,255,0,255,16)); + //verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 98,25, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 1,48, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 50,48, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 98,48, 0,255,0,255)); + + ctx.reset(); + ctx.fillStyle = '#0f0'; + ctx.fillRect(0, 0, 100, 50); + + g = ctx.createRadialGradient(50, 25, 20, 50, 25, 20); + g.addColorStop(0, '#f00'); + g.addColorStop(1, '#f00'); + ctx.fillStyle = g; + ctx.fillRect(0, 0, 100, 50); + + //verify(Helper.comparePixel(ctx, 1,1, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 50,1, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 98,1, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 1,25, 0,255,0,255,16)); + //verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 98,25, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 1,48, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 50,48, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 98,48, 0,255,0,255)); + + ctx.reset(); + ctx.fillStyle = '#f00'; + ctx.fillRect(0, 0, 100, 50); + + g = ctx.createRadialGradient(50, 25, 100, 50, 25, 200); + g.addColorStop(0, '#0f0'); + g.addColorStop(1, '#f00'); + ctx.fillStyle = g; + ctx.fillRect(0, 0, 100, 50); + + //verify(Helper.comparePixel(ctx, 1,1, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 50,1, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 98,1, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 1,25, 0,255,0,255,16)); + //verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 98,25, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 1,48, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 50,48, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 98,48, 0,255,0,255)); + + ctx.reset(); + ctx.fillStyle = '#f00'; + ctx.fillRect(0, 0, 100, 50); + + g = ctx.createRadialGradient(50, 25, 200, 50, 25, 100); + g.addColorStop(0, '#f00'); + g.addColorStop(1, '#0f0'); + ctx.fillStyle = g; + ctx.fillRect(0, 0, 100, 50); + + //verify(Helper.comparePixel(ctx, 1,1, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 50,1, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 98,1, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 1,25, 0,255,0,255,16)); + //verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 98,25, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 1,48, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 50,48, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 98,48, 0,255,0,255)); + + ctx.reset(); + ctx.fillStyle = '#f00'; + ctx.fillRect(0, 0, 100, 50); + + g = ctx.createRadialGradient(50, 25, 200, 50, 25, 100); + g.addColorStop(0, '#f00'); + g.addColorStop(0.993, '#f00'); + g.addColorStop(1, '#0f0'); + ctx.fillStyle = g; + ctx.fillRect(0, 0, 100, 50); + + //verify(Helper.comparePixel(ctx, 1,1, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 50,1, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 98,1, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 1,25, 0,255,0,255,16)); + //verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 98,25, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 1,48, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 50,48, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 98,48, 0,255,0,255)); + + ctx.reset(); + try { var err = false; + ctx.createRadialGradient(0, 0, -0.1, 0, 0, 1); + } catch (e) { if (e.code != DOMException.INDEX_SIZE_ERR) fail("Failed assertion: expected exception of type INDEX_SIZE_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type INDEX_SIZE_ERR: ctx.createRadialGradient(0, 0, -0.1, 0, 0, 1)"); } + try { var err = false; + ctx.createRadialGradient(0, 0, 1, 0, 0, -0.1); + } catch (e) { if (e.code != DOMException.INDEX_SIZE_ERR) fail("Failed assertion: expected exception of type INDEX_SIZE_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type INDEX_SIZE_ERR: ctx.createRadialGradient(0, 0, 1, 0, 0, -0.1)"); } + try { var err = false; + ctx.createRadialGradient(0, 0, -0.1, 0, 0, -0.1); + } catch (e) { if (e.code != DOMException.INDEX_SIZE_ERR) fail("Failed assertion: expected exception of type INDEX_SIZE_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type INDEX_SIZE_ERR: ctx.createRadialGradient(0, 0, -0.1, 0, 0, -0.1)"); } + + + ctx.reset(); + + + try { var err = false; + ctx.createRadialGradient(Infinity, 0, 1, 0, 0, 1); + } catch (e) { if (e.code != DOMException.NOT_SUPPORTED_ERR) fail("Failed assertion: expected exception of type NOT_SUPPORTED_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type NOT_SUPPORTED_ERR: ctx.createRadialGradient(Infinity, 0, 1, 0, 0, 1)"); } + try { var err = false; + ctx.createRadialGradient(-Infinity, 0, 1, 0, 0, 1); + } catch (e) { if (e.code != DOMException.NOT_SUPPORTED_ERR) fail("Failed assertion: expected exception of type NOT_SUPPORTED_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type NOT_SUPPORTED_ERR: ctx.createRadialGradient(-Infinity, 0, 1, 0, 0, 1)"); } + try { var err = false; + ctx.createRadialGradient(NaN, 0, 1, 0, 0, 1); + } catch (e) { if (e.code != DOMException.NOT_SUPPORTED_ERR) fail("Failed assertion: expected exception of type NOT_SUPPORTED_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type NOT_SUPPORTED_ERR: ctx.createRadialGradient(NaN, 0, 1, 0, 0, 1)"); } + try { var err = false; + ctx.createRadialGradient(0, Infinity, 1, 0, 0, 1); + } catch (e) { if (e.code != DOMException.NOT_SUPPORTED_ERR) fail("Failed assertion: expected exception of type NOT_SUPPORTED_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type NOT_SUPPORTED_ERR: ctx.createRadialGradient(0, Infinity, 1, 0, 0, 1)"); } + try { var err = false; + ctx.createRadialGradient(0, -Infinity, 1, 0, 0, 1); + } catch (e) { if (e.code != DOMException.NOT_SUPPORTED_ERR) fail("Failed assertion: expected exception of type NOT_SUPPORTED_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type NOT_SUPPORTED_ERR: ctx.createRadialGradient(0, -Infinity, 1, 0, 0, 1)"); } + try { var err = false; + ctx.createRadialGradient(0, NaN, 1, 0, 0, 1); + } catch (e) { if (e.code != DOMException.NOT_SUPPORTED_ERR) fail("Failed assertion: expected exception of type NOT_SUPPORTED_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type NOT_SUPPORTED_ERR: ctx.createRadialGradient(0, NaN, 1, 0, 0, 1)"); } + try { var err = false; + ctx.createRadialGradient(0, 0, Infinity, 0, 0, 1); + } catch (e) { if (e.code != DOMException.NOT_SUPPORTED_ERR) fail("Failed assertion: expected exception of type NOT_SUPPORTED_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type NOT_SUPPORTED_ERR: ctx.createRadialGradient(0, 0, Infinity, 0, 0, 1)"); } + try { var err = false; + ctx.createRadialGradient(0, 0, -Infinity, 0, 0, 1); + } catch (e) { if (e.code != DOMException.NOT_SUPPORTED_ERR) fail("Failed assertion: expected exception of type NOT_SUPPORTED_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type NOT_SUPPORTED_ERR: ctx.createRadialGradient(0, 0, -Infinity, 0, 0, 1)"); } + try { var err = false; + ctx.createRadialGradient(0, 0, NaN, 0, 0, 1); + } catch (e) { if (e.code != DOMException.NOT_SUPPORTED_ERR) fail("Failed assertion: expected exception of type NOT_SUPPORTED_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type NOT_SUPPORTED_ERR: ctx.createRadialGradient(0, 0, NaN, 0, 0, 1)"); } + try { var err = false; + ctx.createRadialGradient(0, 0, 1, Infinity, 0, 1); + } catch (e) { if (e.code != DOMException.NOT_SUPPORTED_ERR) fail("Failed assertion: expected exception of type NOT_SUPPORTED_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type NOT_SUPPORTED_ERR: ctx.createRadialGradient(0, 0, 1, Infinity, 0, 1)"); } + try { var err = false; + ctx.createRadialGradient(0, 0, 1, -Infinity, 0, 1); + } catch (e) { if (e.code != DOMException.NOT_SUPPORTED_ERR) fail("Failed assertion: expected exception of type NOT_SUPPORTED_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type NOT_SUPPORTED_ERR: ctx.createRadialGradient(0, 0, 1, -Infinity, 0, 1)"); } + try { var err = false; + ctx.createRadialGradient(0, 0, 1, NaN, 0, 1); + } catch (e) { if (e.code != DOMException.NOT_SUPPORTED_ERR) fail("Failed assertion: expected exception of type NOT_SUPPORTED_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type NOT_SUPPORTED_ERR: ctx.createRadialGradient(0, 0, 1, NaN, 0, 1)"); } + try { var err = false; + ctx.createRadialGradient(0, 0, 1, 0, Infinity, 1); + } catch (e) { if (e.code != DOMException.NOT_SUPPORTED_ERR) fail("Failed assertion: expected exception of type NOT_SUPPORTED_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type NOT_SUPPORTED_ERR: ctx.createRadialGradient(0, 0, 1, 0, Infinity, 1)"); } + try { var err = false; + ctx.createRadialGradient(0, 0, 1, 0, -Infinity, 1); + } catch (e) { if (e.code != DOMException.NOT_SUPPORTED_ERR) fail("Failed assertion: expected exception of type NOT_SUPPORTED_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type NOT_SUPPORTED_ERR: ctx.createRadialGradient(0, 0, 1, 0, -Infinity, 1)"); } + try { var err = false; + ctx.createRadialGradient(0, 0, 1, 0, NaN, 1); + } catch (e) { if (e.code != DOMException.NOT_SUPPORTED_ERR) fail("Failed assertion: expected exception of type NOT_SUPPORTED_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type NOT_SUPPORTED_ERR: ctx.createRadialGradient(0, 0, 1, 0, NaN, 1)"); } + try { var err = false; + ctx.createRadialGradient(0, 0, 1, 0, 0, Infinity); + } catch (e) { if (e.code != DOMException.NOT_SUPPORTED_ERR) fail("Failed assertion: expected exception of type NOT_SUPPORTED_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type NOT_SUPPORTED_ERR: ctx.createRadialGradient(0, 0, 1, 0, 0, Infinity)"); } + try { var err = false; + ctx.createRadialGradient(0, 0, 1, 0, 0, -Infinity); + } catch (e) { if (e.code != DOMException.NOT_SUPPORTED_ERR) fail("Failed assertion: expected exception of type NOT_SUPPORTED_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type NOT_SUPPORTED_ERR: ctx.createRadialGradient(0, 0, 1, 0, 0, -Infinity)"); } + try { var err = false; + ctx.createRadialGradient(0, 0, 1, 0, 0, NaN); + } catch (e) { if (e.code != DOMException.NOT_SUPPORTED_ERR) fail("Failed assertion: expected exception of type NOT_SUPPORTED_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type NOT_SUPPORTED_ERR: ctx.createRadialGradient(0, 0, 1, 0, 0, NaN)"); } + try { var err = false; + ctx.createRadialGradient(Infinity, Infinity, 1, 0, 0, 1); + } catch (e) { if (e.code != DOMException.NOT_SUPPORTED_ERR) fail("Failed assertion: expected exception of type NOT_SUPPORTED_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type NOT_SUPPORTED_ERR: ctx.createRadialGradient(Infinity, Infinity, 1, 0, 0, 1)"); } + try { var err = false; + ctx.createRadialGradient(Infinity, Infinity, Infinity, 0, 0, 1); + } catch (e) { if (e.code != DOMException.NOT_SUPPORTED_ERR) fail("Failed assertion: expected exception of type NOT_SUPPORTED_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type NOT_SUPPORTED_ERR: ctx.createRadialGradient(Infinity, Infinity, Infinity, 0, 0, 1)"); } + try { var err = false; + ctx.createRadialGradient(Infinity, Infinity, Infinity, Infinity, 0, 1); + } catch (e) { if (e.code != DOMException.NOT_SUPPORTED_ERR) fail("Failed assertion: expected exception of type NOT_SUPPORTED_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type NOT_SUPPORTED_ERR: ctx.createRadialGradient(Infinity, Infinity, Infinity, Infinity, 0, 1)"); } + try { var err = false; + ctx.createRadialGradient(Infinity, Infinity, Infinity, Infinity, Infinity, 1); + } catch (e) { if (e.code != DOMException.NOT_SUPPORTED_ERR) fail("Failed assertion: expected exception of type NOT_SUPPORTED_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type NOT_SUPPORTED_ERR: ctx.createRadialGradient(Infinity, Infinity, Infinity, Infinity, Infinity, 1)"); } + try { var err = false; + ctx.createRadialGradient(Infinity, Infinity, Infinity, Infinity, Infinity, Infinity); + } catch (e) { if (e.code != DOMException.NOT_SUPPORTED_ERR) fail("Failed assertion: expected exception of type NOT_SUPPORTED_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type NOT_SUPPORTED_ERR: ctx.createRadialGradient(Infinity, Infinity, Infinity, Infinity, Infinity, Infinity)"); } + try { var err = false; + ctx.createRadialGradient(Infinity, Infinity, Infinity, Infinity, 0, Infinity); + } catch (e) { if (e.code != DOMException.NOT_SUPPORTED_ERR) fail("Failed assertion: expected exception of type NOT_SUPPORTED_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type NOT_SUPPORTED_ERR: ctx.createRadialGradient(Infinity, Infinity, Infinity, Infinity, 0, Infinity)"); } + try { var err = false; + ctx.createRadialGradient(Infinity, Infinity, Infinity, 0, Infinity, 1); + } catch (e) { if (e.code != DOMException.NOT_SUPPORTED_ERR) fail("Failed assertion: expected exception of type NOT_SUPPORTED_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type NOT_SUPPORTED_ERR: ctx.createRadialGradient(Infinity, Infinity, Infinity, 0, Infinity, 1)"); } + try { var err = false; + ctx.createRadialGradient(Infinity, Infinity, Infinity, 0, Infinity, Infinity); + } catch (e) { if (e.code != DOMException.NOT_SUPPORTED_ERR) fail("Failed assertion: expected exception of type NOT_SUPPORTED_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type NOT_SUPPORTED_ERR: ctx.createRadialGradient(Infinity, Infinity, Infinity, 0, Infinity, Infinity)"); } + try { var err = false; + ctx.createRadialGradient(Infinity, Infinity, Infinity, 0, 0, Infinity); + } catch (e) { if (e.code != DOMException.NOT_SUPPORTED_ERR) fail("Failed assertion: expected exception of type NOT_SUPPORTED_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type NOT_SUPPORTED_ERR: ctx.createRadialGradient(Infinity, Infinity, Infinity, 0, 0, Infinity)"); } + try { var err = false; + ctx.createRadialGradient(Infinity, Infinity, 1, Infinity, 0, 1); + } catch (e) { if (e.code != DOMException.NOT_SUPPORTED_ERR) fail("Failed assertion: expected exception of type NOT_SUPPORTED_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type NOT_SUPPORTED_ERR: ctx.createRadialGradient(Infinity, Infinity, 1, Infinity, 0, 1)"); } + try { var err = false; + ctx.createRadialGradient(Infinity, Infinity, 1, Infinity, Infinity, 1); + } catch (e) { if (e.code != DOMException.NOT_SUPPORTED_ERR) fail("Failed assertion: expected exception of type NOT_SUPPORTED_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type NOT_SUPPORTED_ERR: ctx.createRadialGradient(Infinity, Infinity, 1, Infinity, Infinity, 1)"); } + try { var err = false; + ctx.createRadialGradient(Infinity, Infinity, 1, Infinity, Infinity, Infinity); + } catch (e) { if (e.code != DOMException.NOT_SUPPORTED_ERR) fail("Failed assertion: expected exception of type NOT_SUPPORTED_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type NOT_SUPPORTED_ERR: ctx.createRadialGradient(Infinity, Infinity, 1, Infinity, Infinity, Infinity)"); } + try { var err = false; + ctx.createRadialGradient(Infinity, Infinity, 1, Infinity, 0, Infinity); + } catch (e) { if (e.code != DOMException.NOT_SUPPORTED_ERR) fail("Failed assertion: expected exception of type NOT_SUPPORTED_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type NOT_SUPPORTED_ERR: ctx.createRadialGradient(Infinity, Infinity, 1, Infinity, 0, Infinity)"); } + try { var err = false; + ctx.createRadialGradient(Infinity, Infinity, 1, 0, Infinity, 1); + } catch (e) { if (e.code != DOMException.NOT_SUPPORTED_ERR) fail("Failed assertion: expected exception of type NOT_SUPPORTED_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type NOT_SUPPORTED_ERR: ctx.createRadialGradient(Infinity, Infinity, 1, 0, Infinity, 1)"); } + try { var err = false; + ctx.createRadialGradient(Infinity, Infinity, 1, 0, Infinity, Infinity); + } catch (e) { if (e.code != DOMException.NOT_SUPPORTED_ERR) fail("Failed assertion: expected exception of type NOT_SUPPORTED_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type NOT_SUPPORTED_ERR: ctx.createRadialGradient(Infinity, Infinity, 1, 0, Infinity, Infinity)"); } + try { var err = false; + ctx.createRadialGradient(Infinity, Infinity, 1, 0, 0, Infinity); + } catch (e) { if (e.code != DOMException.NOT_SUPPORTED_ERR) fail("Failed assertion: expected exception of type NOT_SUPPORTED_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type NOT_SUPPORTED_ERR: ctx.createRadialGradient(Infinity, Infinity, 1, 0, 0, Infinity)"); } + try { var err = false; + ctx.createRadialGradient(Infinity, 0, Infinity, 0, 0, 1); + } catch (e) { if (e.code != DOMException.NOT_SUPPORTED_ERR) fail("Failed assertion: expected exception of type NOT_SUPPORTED_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type NOT_SUPPORTED_ERR: ctx.createRadialGradient(Infinity, 0, Infinity, 0, 0, 1)"); } + try { var err = false; + ctx.createRadialGradient(Infinity, 0, Infinity, Infinity, 0, 1); + } catch (e) { if (e.code != DOMException.NOT_SUPPORTED_ERR) fail("Failed assertion: expected exception of type NOT_SUPPORTED_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type NOT_SUPPORTED_ERR: ctx.createRadialGradient(Infinity, 0, Infinity, Infinity, 0, 1)"); } + try { var err = false; + ctx.createRadialGradient(Infinity, 0, Infinity, Infinity, Infinity, 1); + } catch (e) { if (e.code != DOMException.NOT_SUPPORTED_ERR) fail("Failed assertion: expected exception of type NOT_SUPPORTED_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type NOT_SUPPORTED_ERR: ctx.createRadialGradient(Infinity, 0, Infinity, Infinity, Infinity, 1)"); } + try { var err = false; + ctx.createRadialGradient(Infinity, 0, Infinity, Infinity, Infinity, Infinity); + } catch (e) { if (e.code != DOMException.NOT_SUPPORTED_ERR) fail("Failed assertion: expected exception of type NOT_SUPPORTED_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type NOT_SUPPORTED_ERR: ctx.createRadialGradient(Infinity, 0, Infinity, Infinity, Infinity, Infinity)"); } + try { var err = false; + ctx.createRadialGradient(Infinity, 0, Infinity, Infinity, 0, Infinity); + } catch (e) { if (e.code != DOMException.NOT_SUPPORTED_ERR) fail("Failed assertion: expected exception of type NOT_SUPPORTED_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type NOT_SUPPORTED_ERR: ctx.createRadialGradient(Infinity, 0, Infinity, Infinity, 0, Infinity)"); } + try { var err = false; + ctx.createRadialGradient(Infinity, 0, Infinity, 0, Infinity, 1); + } catch (e) { if (e.code != DOMException.NOT_SUPPORTED_ERR) fail("Failed assertion: expected exception of type NOT_SUPPORTED_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type NOT_SUPPORTED_ERR: ctx.createRadialGradient(Infinity, 0, Infinity, 0, Infinity, 1)"); } + try { var err = false; + ctx.createRadialGradient(Infinity, 0, Infinity, 0, Infinity, Infinity); + } catch (e) { if (e.code != DOMException.NOT_SUPPORTED_ERR) fail("Failed assertion: expected exception of type NOT_SUPPORTED_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type NOT_SUPPORTED_ERR: ctx.createRadialGradient(Infinity, 0, Infinity, 0, Infinity, Infinity)"); } + try { var err = false; + ctx.createRadialGradient(Infinity, 0, Infinity, 0, 0, Infinity); + } catch (e) { if (e.code != DOMException.NOT_SUPPORTED_ERR) fail("Failed assertion: expected exception of type NOT_SUPPORTED_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type NOT_SUPPORTED_ERR: ctx.createRadialGradient(Infinity, 0, Infinity, 0, 0, Infinity)"); } + try { var err = false; + ctx.createRadialGradient(Infinity, 0, 1, Infinity, 0, 1); + } catch (e) { if (e.code != DOMException.NOT_SUPPORTED_ERR) fail("Failed assertion: expected exception of type NOT_SUPPORTED_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type NOT_SUPPORTED_ERR: ctx.createRadialGradient(Infinity, 0, 1, Infinity, 0, 1)"); } + try { var err = false; + ctx.createRadialGradient(Infinity, 0, 1, Infinity, Infinity, 1); + } catch (e) { if (e.code != DOMException.NOT_SUPPORTED_ERR) fail("Failed assertion: expected exception of type NOT_SUPPORTED_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type NOT_SUPPORTED_ERR: ctx.createRadialGradient(Infinity, 0, 1, Infinity, Infinity, 1)"); } + try { var err = false; + ctx.createRadialGradient(Infinity, 0, 1, Infinity, Infinity, Infinity); + } catch (e) { if (e.code != DOMException.NOT_SUPPORTED_ERR) fail("Failed assertion: expected exception of type NOT_SUPPORTED_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type NOT_SUPPORTED_ERR: ctx.createRadialGradient(Infinity, 0, 1, Infinity, Infinity, Infinity)"); } + try { var err = false; + ctx.createRadialGradient(Infinity, 0, 1, Infinity, 0, Infinity); + } catch (e) { if (e.code != DOMException.NOT_SUPPORTED_ERR) fail("Failed assertion: expected exception of type NOT_SUPPORTED_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type NOT_SUPPORTED_ERR: ctx.createRadialGradient(Infinity, 0, 1, Infinity, 0, Infinity)"); } + try { var err = false; + ctx.createRadialGradient(Infinity, 0, 1, 0, Infinity, 1); + } catch (e) { if (e.code != DOMException.NOT_SUPPORTED_ERR) fail("Failed assertion: expected exception of type NOT_SUPPORTED_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type NOT_SUPPORTED_ERR: ctx.createRadialGradient(Infinity, 0, 1, 0, Infinity, 1)"); } + try { var err = false; + ctx.createRadialGradient(Infinity, 0, 1, 0, Infinity, Infinity); + } catch (e) { if (e.code != DOMException.NOT_SUPPORTED_ERR) fail("Failed assertion: expected exception of type NOT_SUPPORTED_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type NOT_SUPPORTED_ERR: ctx.createRadialGradient(Infinity, 0, 1, 0, Infinity, Infinity)"); } + try { var err = false; + ctx.createRadialGradient(Infinity, 0, 1, 0, 0, Infinity); + } catch (e) { if (e.code != DOMException.NOT_SUPPORTED_ERR) fail("Failed assertion: expected exception of type NOT_SUPPORTED_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type NOT_SUPPORTED_ERR: ctx.createRadialGradient(Infinity, 0, 1, 0, 0, Infinity)"); } + try { var err = false; + ctx.createRadialGradient(0, Infinity, Infinity, 0, 0, 1); + } catch (e) { if (e.code != DOMException.NOT_SUPPORTED_ERR) fail("Failed assertion: expected exception of type NOT_SUPPORTED_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type NOT_SUPPORTED_ERR: ctx.createRadialGradient(0, Infinity, Infinity, 0, 0, 1)"); } + try { var err = false; + ctx.createRadialGradient(0, Infinity, Infinity, Infinity, 0, 1); + } catch (e) { if (e.code != DOMException.NOT_SUPPORTED_ERR) fail("Failed assertion: expected exception of type NOT_SUPPORTED_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type NOT_SUPPORTED_ERR: ctx.createRadialGradient(0, Infinity, Infinity, Infinity, 0, 1)"); } + try { var err = false; + ctx.createRadialGradient(0, Infinity, Infinity, Infinity, Infinity, 1); + } catch (e) { if (e.code != DOMException.NOT_SUPPORTED_ERR) fail("Failed assertion: expected exception of type NOT_SUPPORTED_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type NOT_SUPPORTED_ERR: ctx.createRadialGradient(0, Infinity, Infinity, Infinity, Infinity, 1)"); } + try { var err = false; + ctx.createRadialGradient(0, Infinity, Infinity, Infinity, Infinity, Infinity); + } catch (e) { if (e.code != DOMException.NOT_SUPPORTED_ERR) fail("Failed assertion: expected exception of type NOT_SUPPORTED_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type NOT_SUPPORTED_ERR: ctx.createRadialGradient(0, Infinity, Infinity, Infinity, Infinity, Infinity)"); } + try { var err = false; + ctx.createRadialGradient(0, Infinity, Infinity, Infinity, 0, Infinity); + } catch (e) { if (e.code != DOMException.NOT_SUPPORTED_ERR) fail("Failed assertion: expected exception of type NOT_SUPPORTED_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type NOT_SUPPORTED_ERR: ctx.createRadialGradient(0, Infinity, Infinity, Infinity, 0, Infinity)"); } + try { var err = false; + ctx.createRadialGradient(0, Infinity, Infinity, 0, Infinity, 1); + } catch (e) { if (e.code != DOMException.NOT_SUPPORTED_ERR) fail("Failed assertion: expected exception of type NOT_SUPPORTED_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type NOT_SUPPORTED_ERR: ctx.createRadialGradient(0, Infinity, Infinity, 0, Infinity, 1)"); } + try { var err = false; + ctx.createRadialGradient(0, Infinity, Infinity, 0, Infinity, Infinity); + } catch (e) { if (e.code != DOMException.NOT_SUPPORTED_ERR) fail("Failed assertion: expected exception of type NOT_SUPPORTED_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type NOT_SUPPORTED_ERR: ctx.createRadialGradient(0, Infinity, Infinity, 0, Infinity, Infinity)"); } + try { var err = false; + ctx.createRadialGradient(0, Infinity, Infinity, 0, 0, Infinity); + } catch (e) { if (e.code != DOMException.NOT_SUPPORTED_ERR) fail("Failed assertion: expected exception of type NOT_SUPPORTED_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type NOT_SUPPORTED_ERR: ctx.createRadialGradient(0, Infinity, Infinity, 0, 0, Infinity)"); } + try { var err = false; + ctx.createRadialGradient(0, Infinity, 1, Infinity, 0, 1); + } catch (e) { if (e.code != DOMException.NOT_SUPPORTED_ERR) fail("Failed assertion: expected exception of type NOT_SUPPORTED_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type NOT_SUPPORTED_ERR: ctx.createRadialGradient(0, Infinity, 1, Infinity, 0, 1)"); } + try { var err = false; + ctx.createRadialGradient(0, Infinity, 1, Infinity, Infinity, 1); + } catch (e) { if (e.code != DOMException.NOT_SUPPORTED_ERR) fail("Failed assertion: expected exception of type NOT_SUPPORTED_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type NOT_SUPPORTED_ERR: ctx.createRadialGradient(0, Infinity, 1, Infinity, Infinity, 1)"); } + try { var err = false; + ctx.createRadialGradient(0, Infinity, 1, Infinity, Infinity, Infinity); + } catch (e) { if (e.code != DOMException.NOT_SUPPORTED_ERR) fail("Failed assertion: expected exception of type NOT_SUPPORTED_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type NOT_SUPPORTED_ERR: ctx.createRadialGradient(0, Infinity, 1, Infinity, Infinity, Infinity)"); } + try { var err = false; + ctx.createRadialGradient(0, Infinity, 1, Infinity, 0, Infinity); + } catch (e) { if (e.code != DOMException.NOT_SUPPORTED_ERR) fail("Failed assertion: expected exception of type NOT_SUPPORTED_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type NOT_SUPPORTED_ERR: ctx.createRadialGradient(0, Infinity, 1, Infinity, 0, Infinity)"); } + try { var err = false; + ctx.createRadialGradient(0, Infinity, 1, 0, Infinity, 1); + } catch (e) { if (e.code != DOMException.NOT_SUPPORTED_ERR) fail("Failed assertion: expected exception of type NOT_SUPPORTED_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type NOT_SUPPORTED_ERR: ctx.createRadialGradient(0, Infinity, 1, 0, Infinity, 1)"); } + try { var err = false; + ctx.createRadialGradient(0, Infinity, 1, 0, Infinity, Infinity); + } catch (e) { if (e.code != DOMException.NOT_SUPPORTED_ERR) fail("Failed assertion: expected exception of type NOT_SUPPORTED_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type NOT_SUPPORTED_ERR: ctx.createRadialGradient(0, Infinity, 1, 0, Infinity, Infinity)"); } + try { var err = false; + ctx.createRadialGradient(0, Infinity, 1, 0, 0, Infinity); + } catch (e) { if (e.code != DOMException.NOT_SUPPORTED_ERR) fail("Failed assertion: expected exception of type NOT_SUPPORTED_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type NOT_SUPPORTED_ERR: ctx.createRadialGradient(0, Infinity, 1, 0, 0, Infinity)"); } + try { var err = false; + ctx.createRadialGradient(0, 0, Infinity, Infinity, 0, 1); + } catch (e) { if (e.code != DOMException.NOT_SUPPORTED_ERR) fail("Failed assertion: expected exception of type NOT_SUPPORTED_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type NOT_SUPPORTED_ERR: ctx.createRadialGradient(0, 0, Infinity, Infinity, 0, 1)"); } + try { var err = false; + ctx.createRadialGradient(0, 0, Infinity, Infinity, Infinity, 1); + } catch (e) { if (e.code != DOMException.NOT_SUPPORTED_ERR) fail("Failed assertion: expected exception of type NOT_SUPPORTED_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type NOT_SUPPORTED_ERR: ctx.createRadialGradient(0, 0, Infinity, Infinity, Infinity, 1)"); } + try { var err = false; + ctx.createRadialGradient(0, 0, Infinity, Infinity, Infinity, Infinity); + } catch (e) { if (e.code != DOMException.NOT_SUPPORTED_ERR) fail("Failed assertion: expected exception of type NOT_SUPPORTED_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type NOT_SUPPORTED_ERR: ctx.createRadialGradient(0, 0, Infinity, Infinity, Infinity, Infinity)"); } + try { var err = false; + ctx.createRadialGradient(0, 0, Infinity, Infinity, 0, Infinity); + } catch (e) { if (e.code != DOMException.NOT_SUPPORTED_ERR) fail("Failed assertion: expected exception of type NOT_SUPPORTED_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type NOT_SUPPORTED_ERR: ctx.createRadialGradient(0, 0, Infinity, Infinity, 0, Infinity)"); } + try { var err = false; + ctx.createRadialGradient(0, 0, Infinity, 0, Infinity, 1); + } catch (e) { if (e.code != DOMException.NOT_SUPPORTED_ERR) fail("Failed assertion: expected exception of type NOT_SUPPORTED_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type NOT_SUPPORTED_ERR: ctx.createRadialGradient(0, 0, Infinity, 0, Infinity, 1)"); } + try { var err = false; + ctx.createRadialGradient(0, 0, Infinity, 0, Infinity, Infinity); + } catch (e) { if (e.code != DOMException.NOT_SUPPORTED_ERR) fail("Failed assertion: expected exception of type NOT_SUPPORTED_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type NOT_SUPPORTED_ERR: ctx.createRadialGradient(0, 0, Infinity, 0, Infinity, Infinity)"); } + try { var err = false; + ctx.createRadialGradient(0, 0, Infinity, 0, 0, Infinity); + } catch (e) { if (e.code != DOMException.NOT_SUPPORTED_ERR) fail("Failed assertion: expected exception of type NOT_SUPPORTED_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type NOT_SUPPORTED_ERR: ctx.createRadialGradient(0, 0, Infinity, 0, 0, Infinity)"); } + try { var err = false; + ctx.createRadialGradient(0, 0, 1, Infinity, Infinity, 1); + } catch (e) { if (e.code != DOMException.NOT_SUPPORTED_ERR) fail("Failed assertion: expected exception of type NOT_SUPPORTED_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type NOT_SUPPORTED_ERR: ctx.createRadialGradient(0, 0, 1, Infinity, Infinity, 1)"); } + try { var err = false; + ctx.createRadialGradient(0, 0, 1, Infinity, Infinity, Infinity); + } catch (e) { if (e.code != DOMException.NOT_SUPPORTED_ERR) fail("Failed assertion: expected exception of type NOT_SUPPORTED_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type NOT_SUPPORTED_ERR: ctx.createRadialGradient(0, 0, 1, Infinity, Infinity, Infinity)"); } + try { var err = false; + ctx.createRadialGradient(0, 0, 1, Infinity, 0, Infinity); + } catch (e) { if (e.code != DOMException.NOT_SUPPORTED_ERR) fail("Failed assertion: expected exception of type NOT_SUPPORTED_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type NOT_SUPPORTED_ERR: ctx.createRadialGradient(0, 0, 1, Infinity, 0, Infinity)"); } + try { var err = false; + ctx.createRadialGradient(0, 0, 1, 0, Infinity, Infinity); + } catch (e) { if (e.code != DOMException.NOT_SUPPORTED_ERR) fail("Failed assertion: expected exception of type NOT_SUPPORTED_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type NOT_SUPPORTED_ERR: ctx.createRadialGradient(0, 0, 1, 0, Infinity, Infinity)"); } + + + ctx.reset(); + ctx.fillStyle = '#f00'; + ctx.fillRect(0, 0, 100, 50); + g = ctx.createRadialGradient(200, 25, 10, 200, 25, 20); + g.addColorStop(0, '#f00'); + g.addColorStop(1, '#0f0'); + ctx.fillStyle = g;ctx.fillRect(0, 0, 100, 50); + + //verify(Helper.comparePixel(ctx, 1,1, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 50,1, 0,255,0,255));//verify(Helper.comparePixel(ctx, 98,1, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 1,25, 0,255,0,255,16)); + //verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 98,25, 0,255,0,255));//verify(Helper.comparePixel(ctx, 1,48, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 50,48, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 98,48, 0,255,0,255)); + + ctx.reset(); + ctx.fillStyle = '#f00'; + ctx.fillRect(0, 0, 100, 50); + g = ctx.createRadialGradient(200, 25, 20, 200, 25, 10); + g.addColorStop(0, '#0f0'); + g.addColorStop(1, '#f00'); + ctx.fillStyle = g;ctx.fillRect(0, 0, 100, 50); + + //verify(Helper.comparePixel(ctx, 1,1, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 50,1, 0,255,0,255));//verify(Helper.comparePixel(ctx, 98,1, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 1,25, 0,255,0,255,16)); + //verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 98,25, 0,255,0,255));//verify(Helper.comparePixel(ctx, 1,48, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 50,48, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 98,48, 0,255,0,255)); + + ctx.reset(); + ctx.fillStyle = '#f00'; + ctx.fillRect(0, 0, 100, 50); + g = ctx.createRadialGradient(200, 25, 20, 200, 25, 10); + g.addColorStop(0, '#0f0'); + g.addColorStop(0.001, '#f00'); + g.addColorStop(1, '#f00');ctx.fillStyle = g; + ctx.fillRect(0, 0, 100, 50); + + //verify(Helper.comparePixel(ctx, 1,1, 0,255,0,255));//verify(Helper.comparePixel(ctx, 50,1, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 98,1, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 1,25, 0,255,0,255,16)); + //verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255));//verify(Helper.comparePixel(ctx, 98,25, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 1,48, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 50,48, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 98,48, 0,255,0,255)); + + ctx.reset(); + ctx.fillStyle = '#0f0'; + ctx.fillRect(0, 0, 100, 50); + g = ctx.createRadialGradient(150, 25, 50, 200, 25, 100); + g.addColorStop(0, '#f00'); + g.addColorStop(1, '#f00'); + ctx.fillStyle = g;ctx.fillRect(0, 0, 100, 50); + + //verify(Helper.comparePixel(ctx, 1,1, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 50,1, 0,255,0,255));//verify(Helper.comparePixel(ctx, 98,1, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 1,25, 0,255,0,255,16)); + //verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 98,25, 0,255,0,255));//verify(Helper.comparePixel(ctx, 1,48, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 50,48, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 98,48, 0,255,0,255)); + + ctx.reset(); + + ctx.fillStyle = '#f00'; + ctx.fillRect(0, 0, 100, 50); + g = ctx.createRadialGradient(-80, 25, 70, 0, 25, 150); + g.addColorStop(0, '#f00'); + g.addColorStop(0.01, '#0f0'); + g.addColorStop(0.99, '#0f0');g.addColorStop(1, '#f00'); + ctx.fillStyle = g; + ctx.fillRect(0, 0, 100, 50); + //verify(Helper.comparePixel(ctx, 1,1, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 50,1, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 98,1, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 1,25, 0,255,0,255,16));//verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 98,25, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 1,48, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 50,48, 0,255,0,255));//verify(Helper.comparePixel(ctx, 98,48, 0,255,0,255)); + + ctx.reset(); + ctx.fillStyle = '#0f0'; + ctx.fillRect(0, 0, 100, 50); + g = ctx.createRadialGradient(120, -15, 25, 140, -30, 50); + g.addColorStop(0, '#f00'); + g.addColorStop(1, '#f00'); + ctx.fillStyle = g;ctx.fillRect(0, 0, 100, 50); + + //verify(Helper.comparePixel(ctx, 1,1, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 50,1, 0,255,0,255));//verify(Helper.comparePixel(ctx, 98,1, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 1,25, 0,255,0,255,16)); + //verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 98,25, 0,255,0,255));//verify(Helper.comparePixel(ctx, 1,48, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 50,48, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 98,48, 0,255,0,255)); + + ctx.reset(); + g = ctx.createRadialGradient(0, 0, 0, 0, 0, 11.2); + g.addColorStop(0, '#0f0'); + g.addColorStop(0.5, '#0f0');g.addColorStop(0.51, '#f00'); + g.addColorStop(1, '#f00'); + ctx.fillStyle = g; + ctx.translate(50, 25);ctx.scale(10, 10); + ctx.fillRect(-5, -2.5, 10, 5); + //verify(Helper.comparePixel(ctx, 25,25, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255));//verify(Helper.comparePixel(ctx, 75,25, 0,255,0,255)); + + ctx.reset(); + ctx.translate(100, 0); + g = ctx.createRadialGradient(0, 0, 0, 0, 0, 11.2); + g.addColorStop(0, '#0f0');g.addColorStop(0.5, '#0f0'); + g.addColorStop(0.51, '#f00'); + g.addColorStop(1, '#f00'); + ctx.fillStyle = g;ctx.translate(-50, 25); + ctx.scale(10, 10); + ctx.fillRect(-5, -2.5, 10, 5); + //verify(Helper.comparePixel(ctx, 25,25, 0,255,0,255));//verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 75,25, 0,255,0,255)); + + + ctx.reset(); + g = ctx.createRadialGradient(0, 0, 0, 0, 0, 11.2); + g.addColorStop(0, '#0f0'); + g.addColorStop(0.5, '#0f0');g.addColorStop(0.51, '#f00'); + g.addColorStop(1, '#f00'); + ctx.fillStyle = g; + ctx.fillRect(0, 0, 100, 50);ctx.translate(50, 25); + ctx.scale(10, 10); + ctx.fillRect(-5, -2.5, 10, 5); + //verify(Helper.comparePixel(ctx, 25,25, 0,255,0,255));//verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 75,25, 0,255,0,255)); + + + } + function test_linear() { + var ctx = canvas.getContext('2d'); + ctx.reset(); + try { var err = false; + ctx.createLinearGradient(Infinity, 0, 1, 0); + } catch (e) { if (e.code != DOMException.NOT_SUPPORTED_ERR) fail("Failed assertion: expected exception of type NOT_SUPPORTED_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type NOT_SUPPORTED_ERR: ctx.createLinearGradient(Infinity, 0, 1, 0)"); } + try { var err = false; + ctx.createLinearGradient(-Infinity, 0, 1, 0); + } catch (e) { if (e.code != DOMException.NOT_SUPPORTED_ERR) fail("Failed assertion: expected exception of type NOT_SUPPORTED_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type NOT_SUPPORTED_ERR: ctx.createLinearGradient(-Infinity, 0, 1, 0)"); } + try { var err = false; + ctx.createLinearGradient(NaN, 0, 1, 0); + } catch (e) { if (e.code != DOMException.NOT_SUPPORTED_ERR) fail("Failed assertion: expected exception of type NOT_SUPPORTED_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type NOT_SUPPORTED_ERR: ctx.createLinearGradient(NaN, 0, 1, 0)"); } + try { var err = false; + ctx.createLinearGradient(0, Infinity, 1, 0); + } catch (e) { if (e.code != DOMException.NOT_SUPPORTED_ERR) fail("Failed assertion: expected exception of type NOT_SUPPORTED_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type NOT_SUPPORTED_ERR: ctx.createLinearGradient(0, Infinity, 1, 0)"); } + try { var err = false; + ctx.createLinearGradient(0, -Infinity, 1, 0); + } catch (e) { if (e.code != DOMException.NOT_SUPPORTED_ERR) fail("Failed assertion: expected exception of type NOT_SUPPORTED_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type NOT_SUPPORTED_ERR: ctx.createLinearGradient(0, -Infinity, 1, 0)"); } + try { var err = false; + ctx.createLinearGradient(0, NaN, 1, 0); + } catch (e) { if (e.code != DOMException.NOT_SUPPORTED_ERR) fail("Failed assertion: expected exception of type NOT_SUPPORTED_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type NOT_SUPPORTED_ERR: ctx.createLinearGradient(0, NaN, 1, 0)"); } + try { var err = false; + ctx.createLinearGradient(0, 0, Infinity, 0); + } catch (e) { if (e.code != DOMException.NOT_SUPPORTED_ERR) fail("Failed assertion: expected exception of type NOT_SUPPORTED_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type NOT_SUPPORTED_ERR: ctx.createLinearGradient(0, 0, Infinity, 0)"); } + try { var err = false; + ctx.createLinearGradient(0, 0, -Infinity, 0); + } catch (e) { if (e.code != DOMException.NOT_SUPPORTED_ERR) fail("Failed assertion: expected exception of type NOT_SUPPORTED_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type NOT_SUPPORTED_ERR: ctx.createLinearGradient(0, 0, -Infinity, 0)"); } + try { var err = false; + ctx.createLinearGradient(0, 0, NaN, 0); + } catch (e) { if (e.code != DOMException.NOT_SUPPORTED_ERR) fail("Failed assertion: expected exception of type NOT_SUPPORTED_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type NOT_SUPPORTED_ERR: ctx.createLinearGradient(0, 0, NaN, 0)"); } + try { var err = false; + ctx.createLinearGradient(0, 0, 1, Infinity); + } catch (e) { if (e.code != DOMException.NOT_SUPPORTED_ERR) fail("Failed assertion: expected exception of type NOT_SUPPORTED_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type NOT_SUPPORTED_ERR: ctx.createLinearGradient(0, 0, 1, Infinity)"); } + try { var err = false; + ctx.createLinearGradient(0, 0, 1, -Infinity); + } catch (e) { if (e.code != DOMException.NOT_SUPPORTED_ERR) fail("Failed assertion: expected exception of type NOT_SUPPORTED_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type NOT_SUPPORTED_ERR: ctx.createLinearGradient(0, 0, 1, -Infinity)"); } + try { var err = false; + ctx.createLinearGradient(0, 0, 1, NaN); + } catch (e) { if (e.code != DOMException.NOT_SUPPORTED_ERR) fail("Failed assertion: expected exception of type NOT_SUPPORTED_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type NOT_SUPPORTED_ERR: ctx.createLinearGradient(0, 0, 1, NaN)"); } + try { var err = false; + ctx.createLinearGradient(Infinity, Infinity, 1, 0); + } catch (e) { if (e.code != DOMException.NOT_SUPPORTED_ERR) fail("Failed assertion: expected exception of type NOT_SUPPORTED_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type NOT_SUPPORTED_ERR: ctx.createLinearGradient(Infinity, Infinity, 1, 0)"); } + try { var err = false; + ctx.createLinearGradient(Infinity, Infinity, Infinity, 0); + } catch (e) { if (e.code != DOMException.NOT_SUPPORTED_ERR) fail("Failed assertion: expected exception of type NOT_SUPPORTED_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type NOT_SUPPORTED_ERR: ctx.createLinearGradient(Infinity, Infinity, Infinity, 0)"); } + try { var err = false; + ctx.createLinearGradient(Infinity, Infinity, Infinity, Infinity); + } catch (e) { if (e.code != DOMException.NOT_SUPPORTED_ERR) fail("Failed assertion: expected exception of type NOT_SUPPORTED_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type NOT_SUPPORTED_ERR: ctx.createLinearGradient(Infinity, Infinity, Infinity, Infinity)"); } + try { var err = false; + ctx.createLinearGradient(Infinity, Infinity, 1, Infinity); + } catch (e) { if (e.code != DOMException.NOT_SUPPORTED_ERR) fail("Failed assertion: expected exception of type NOT_SUPPORTED_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type NOT_SUPPORTED_ERR: ctx.createLinearGradient(Infinity, Infinity, 1, Infinity)"); } + try { var err = false; + ctx.createLinearGradient(Infinity, 0, Infinity, 0); + } catch (e) { if (e.code != DOMException.NOT_SUPPORTED_ERR) fail("Failed assertion: expected exception of type NOT_SUPPORTED_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type NOT_SUPPORTED_ERR: ctx.createLinearGradient(Infinity, 0, Infinity, 0)"); } + try { var err = false; + ctx.createLinearGradient(Infinity, 0, Infinity, Infinity); + } catch (e) { if (e.code != DOMException.NOT_SUPPORTED_ERR) fail("Failed assertion: expected exception of type NOT_SUPPORTED_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type NOT_SUPPORTED_ERR: ctx.createLinearGradient(Infinity, 0, Infinity, Infinity)"); } + try { var err = false; + ctx.createLinearGradient(Infinity, 0, 1, Infinity); + } catch (e) { if (e.code != DOMException.NOT_SUPPORTED_ERR) fail("Failed assertion: expected exception of type NOT_SUPPORTED_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type NOT_SUPPORTED_ERR: ctx.createLinearGradient(Infinity, 0, 1, Infinity)"); } + try { var err = false; + ctx.createLinearGradient(0, Infinity, Infinity, 0); + } catch (e) { if (e.code != DOMException.NOT_SUPPORTED_ERR) fail("Failed assertion: expected exception of type NOT_SUPPORTED_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type NOT_SUPPORTED_ERR: ctx.createLinearGradient(0, Infinity, Infinity, 0)"); } + try { var err = false; + ctx.createLinearGradient(0, Infinity, Infinity, Infinity); + } catch (e) { if (e.code != DOMException.NOT_SUPPORTED_ERR) fail("Failed assertion: expected exception of type NOT_SUPPORTED_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type NOT_SUPPORTED_ERR: ctx.createLinearGradient(0, Infinity, Infinity, Infinity)"); } + try { var err = false; + ctx.createLinearGradient(0, Infinity, 1, Infinity); + } catch (e) { if (e.code != DOMException.NOT_SUPPORTED_ERR) fail("Failed assertion: expected exception of type NOT_SUPPORTED_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type NOT_SUPPORTED_ERR: ctx.createLinearGradient(0, Infinity, 1, Infinity)"); } + try { var err = false; + ctx.createLinearGradient(0, 0, Infinity, Infinity); + } catch (e) { if (e.code != DOMException.NOT_SUPPORTED_ERR) fail("Failed assertion: expected exception of type NOT_SUPPORTED_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type NOT_SUPPORTED_ERR: ctx.createLinearGradient(0, 0, Infinity, Infinity)"); } + + ctx.reset(); + var g = ctx.createLinearGradient(0, 0, 200, 0); + g.addColorStop(0, '#f00'); + g.addColorStop(0.25, '#0f0'); + g.addColorStop(0.75, '#0f0'); + g.addColorStop(1, '#f00'); + ctx.fillStyle = g; + ctx.translate(-50, 0); + ctx.fillRect(50, 0, 100, 50); + verify(Helper.comparePixel(ctx, 25,25, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 75,25, 0,255,0,255)); + + ctx.reset(); + ctx.translate(100, 0); + g = ctx.createLinearGradient(0, 0, 200, 0); + g.addColorStop(0, '#f00'); + g.addColorStop(0.25, '#0f0'); + g.addColorStop(0.75, '#0f0'); + g.addColorStop(1, '#f00'); + ctx.fillStyle = g; + ctx.translate(-150, 0); + ctx.fillRect(50, 0, 100, 50); + verify(Helper.comparePixel(ctx, 25,25, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 75,25, 0,255,0,255)); + + + ctx.reset(); + g = ctx.createLinearGradient(0, 0, 200, 0); + g.addColorStop(0, '#f00'); + g.addColorStop(0.25, '#0f0'); + g.addColorStop(0.75, '#0f0'); + g.addColorStop(1, '#f00'); + ctx.fillStyle = g; + ctx.fillRect(0, 0, 100, 50); + ctx.translate(-50, 0); + ctx.fillRect(50, 0, 100, 50); + verify(Helper.comparePixel(ctx, 25,25, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 75,25, 0,255,0,255)); + + } + function test_object() { + var ctx = canvas.getContext('2d'); + ctx.reset(); + var g1 = ctx.createLinearGradient(0, 0, 100, 0); + var g2 = ctx.createLinearGradient(0, 0, 100, 0); + ctx.fillStyle = g1; + + + ctx.reset(); + var g = ctx.createLinearGradient(0, 0, 100, 0); + try { var err = false; + g.addColorStop(0, ""); + } catch (e) { if (e.code != DOMException.SYNTAX_ERR) fail("Failed assertion: expected exception of type SYNTAX_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type SYNTAX_ERR: g.addColorStop(0, \"\")"); } + try { var err = false; + g.addColorStop(0, 'undefined'); + } catch (e) { if (e.code != DOMException.SYNTAX_ERR) fail("Failed assertion: expected exception of type SYNTAX_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type SYNTAX_ERR: g.addColorStop(0, 'undefined')"); } + + + ctx.reset(); + g = ctx.createLinearGradient(0, 0, 100, 0); + try { var err = false; + g.addColorStop(-1, '#000'); + } catch (e) { if (e.code != DOMException.INDEX_SIZE_ERR) fail("Failed assertion: expected exception of type INDEX_SIZE_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type INDEX_SIZE_ERR: g.addColorStop(-1, '#000')"); } + try { var err = false; + g.addColorStop(2, '#000'); + } catch (e) { if (e.code != DOMException.INDEX_SIZE_ERR) fail("Failed assertion: expected exception of type INDEX_SIZE_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type INDEX_SIZE_ERR: g.addColorStop(2, '#000')"); } + try { var err = false; + g.addColorStop(Infinity, '#000'); + } catch (e) { if (e.code != DOMException.INDEX_SIZE_ERR) fail("Failed assertion: expected exception of type INDEX_SIZE_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type INDEX_SIZE_ERR: g.addColorStop(Infinity, '#000')"); } + try { var err = false; + g.addColorStop(-Infinity, '#000'); + } catch (e) { if (e.code != DOMException.INDEX_SIZE_ERR) fail("Failed assertion: expected exception of type INDEX_SIZE_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type INDEX_SIZE_ERR: g.addColorStop(-Infinity, '#000')"); } + try { var err = false; + g.addColorStop(NaN, '#000'); + } catch (e) { if (e.code != DOMException.INDEX_SIZE_ERR) fail("Failed assertion: expected exception of type INDEX_SIZE_ERR, got: "+e.message); err = true; } finally { verify(err, "should throw exception of type INDEX_SIZE_ERR: g.addColorStop(NaN, '#000')"); } + + + ctx.reset(); + g = ctx.createLinearGradient(-100, 0, 200, 0); + g.addColorStop(0, '#f00'); + g.addColorStop(1, '#f00'); + ctx.fillStyle = g; + g.addColorStop(0.1, '#0f0'); + g.addColorStop(0.9, '#0f0'); + ctx.fillRect(0, 0, 100, 50); + //verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255,2)); + + ctx.reset(); + ctx.fillStyle = '#0f0'; + ctx.fillRect(0, 0, 100, 50); + + g = ctx.createRadialGradient(120, 25, 10, 211, 25, 100); + g.addColorStop(0, '#f00'); + g.addColorStop(1, '#f00'); + ctx.fillStyle = g; + ctx.fillRect(0, 0, 100, 50); + + //verify(Helper.comparePixel(ctx, 1,1, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 50,1, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 98,1, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 1,25, 0,255,0,255,16)); + //verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 98,25, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 1,48, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 50,48, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 98,48, 0,255,0,255)); + + + } + + function test_conical() { + var ctx = canvas.getContext('2d'); + ctx.reset(); + var g = ctx.createConicalGradient(10, 10, 50); + //TODO + } + } +} diff --git a/tests/auto/quick/qquickcanvasitem/data/tst_line.qml b/tests/auto/quick/qquickcanvasitem/data/tst_line.qml new file mode 100644 index 0000000000..baf9987ce3 --- /dev/null +++ b/tests/auto/quick/qquickcanvasitem/data/tst_line.qml @@ -0,0 +1,831 @@ +import QtQuick 2.0 +import QtTest 1.0 +import"testhelper.js" as Helper +Canvas { + id:canvas; width:100;height:50;renderTarget: Canvas.Image + TestCase { + name: "line"; when: windowShown + function test_default() { + var ctx = canvas.getContext('2d'); + ctx.reset(); + compare(ctx.lineWidth, 1); + compare(ctx.lineCap, 'butt'); + compare(ctx.lineJoin, 'miter'); + compare(ctx.miterLimit, 10); + } + + function test_cross() { + var ctx = canvas.getContext('2d'); + ctx.reset(); + ctx.fillStyle = '#0f0'; + ctx.fillRect(0, 0, 100, 50); + + ctx.lineWidth = 200; + ctx.lineJoin = 'bevel'; + + ctx.strokeStyle = '#f00'; + ctx.beginPath(); + ctx.moveTo(110, 50); + ctx.lineTo(110, 60); + ctx.lineTo(100, 60); + ctx.stroke(); + + verify(Helper.comparePixel(ctx, 1,1, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 48,1, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 48,48, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 1,48, 0,255,0,255)); + + } + + function test_join() { + var ctx = canvas.getContext('2d'); + ctx.reset(); + + ctx.fillStyle = '#0f0'; + ctx.fillRect(0, 0, 100, 50); + + var tol = 1; // tolerance to avoid antialiasing artifacts + + ctx.lineJoin = 'bevel'; + ctx.lineWidth = 20; + + ctx.fillStyle = '#f00'; + ctx.strokeStyle = '#0f0'; + + ctx.fillRect(10, 10, 20, 20); + ctx.fillRect(20, 20, 20, 20); + ctx.beginPath(); + ctx.moveTo(30, 20); + ctx.lineTo(40-tol, 20); + ctx.lineTo(30, 10+tol); + ctx.fill(); + + ctx.beginPath(); + ctx.moveTo(10, 20); + ctx.lineTo(30, 20); + ctx.lineTo(30, 40); + ctx.stroke(); + + + ctx.fillStyle = '#0f0'; + ctx.strokeStyle = '#f00'; + + ctx.beginPath(); + ctx.moveTo(60, 20); + ctx.lineTo(80, 20); + ctx.lineTo(80, 40); + ctx.stroke(); + + ctx.fillRect(60, 10, 20, 20); + ctx.fillRect(70, 20, 20, 20); + ctx.beginPath(); + ctx.moveTo(80, 20); + ctx.lineTo(90+tol, 20); + ctx.lineTo(80, 10-tol); + ctx.fill(); + + verify(Helper.comparePixel(ctx, 34,16, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 34,15, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 35,15, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 36,15, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 36,14, 0,255,0,255)); + + verify(Helper.comparePixel(ctx, 84,16, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 84,15, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 85,15, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 86,15, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 86,14, 0,255,0,255)); + + + ctx.reset(); + ctx.fillStyle = '#f00'; + ctx.strokeStyle = '#0f0'; + ctx.fillRect(0, 0, 100, 50); + + ctx.lineJoin = 'miter'; + ctx.lineWidth = 200; + + ctx.beginPath(); + ctx.moveTo(100, 50); + ctx.lineTo(100, 1000); + ctx.lineTo(1000, 1000); + ctx.lineTo(1000, 50); + ctx.closePath(); + ctx.stroke(); + + verify(Helper.comparePixel(ctx, 1,1, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 48,1, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 48,48, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 1,48, 0,255,0,255)); + + + ctx.reset(); + ctx.lineJoin = 'bevel' + compare(ctx.lineJoin, 'bevel'); + + ctx.lineJoin = 'bevel'; + ctx.lineJoin = 'invalid'; + compare(ctx.lineJoin, 'bevel'); + + ctx.lineJoin = 'bevel'; + ctx.lineJoin = 'ROUND'; + compare(ctx.lineJoin, 'bevel'); + + ctx.lineJoin = 'bevel'; + ctx.lineJoin = 'round\\0'; + compare(ctx.lineJoin, 'bevel'); + + ctx.lineJoin = 'bevel'; + ctx.lineJoin = 'round '; + compare(ctx.lineJoin, 'bevel'); + + ctx.lineJoin = 'bevel'; + ctx.lineJoin = ""; + compare(ctx.lineJoin, 'bevel'); + + ctx.lineJoin = 'bevel'; + ctx.lineJoin = 'butt'; + compare(ctx.lineJoin, 'bevel'); + + ctx.reset(); + ctx.fillStyle = '#0f0'; + ctx.fillRect(0, 0, 100, 50); + + ctx.lineJoin = 'miter'; + ctx.lineWidth = 20; + + ctx.fillStyle = '#f00'; + ctx.strokeStyle = '#0f0'; + + ctx.fillStyle = '#f00'; + ctx.strokeStyle = '#0f0'; + + ctx.fillRect(10, 10, 30, 20); + ctx.fillRect(20, 10, 20, 30); + + ctx.beginPath(); + ctx.moveTo(10, 20); + ctx.lineTo(30, 20); + ctx.lineTo(30, 40); + ctx.stroke(); + + + ctx.fillStyle = '#0f0'; + ctx.strokeStyle = '#f00'; + + ctx.beginPath(); + ctx.moveTo(60, 20); + ctx.lineTo(80, 20); + ctx.lineTo(80, 40); + ctx.stroke(); + + ctx.fillRect(60, 10, 30, 20); + ctx.fillRect(70, 10, 20, 30); + + verify(Helper.comparePixel(ctx, 38,12, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 39,11, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 40,10, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 41,9, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 42,8, 0,255,0,255)); + + verify(Helper.comparePixel(ctx, 88,12, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 89,11, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 90,10, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 91,9, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 92,8, 0,255,0,255)); + + ctx.reset(); + ctx.fillStyle = '#0f0'; + ctx.strokeStyle = '#f00'; + ctx.fillRect(0, 0, 100, 50); + + ctx.lineJoin = 'miter'; + ctx.lineWidth = 200; + + ctx.beginPath(); + ctx.moveTo(100, 50); + ctx.lineTo(100, 1000); + ctx.lineTo(1000, 1000); + ctx.lineTo(1000, 50); + ctx.lineTo(100, 50); + ctx.stroke(); + + //verify(Helper.comparePixel(ctx, 1,1, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 48,1, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 48,48, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 1,48, 0,255,0,255)); + + ctx.reset(); + ctx.fillStyle = '#f00'; + ctx.fillRect(0, 0, 100, 50); + + ctx.strokeStyle = '#0f0'; + ctx.lineWidth = 300; + ctx.lineJoin = 'round'; + ctx.beginPath(); + ctx.moveTo(-100, 25); + ctx.lineTo(0, 25); + ctx.lineTo(-100, 25); + ctx.stroke(); + + verify(Helper.comparePixel(ctx, 1,1, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 48,1, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 48,48, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 1,48, 0,255,0,255)); + + ctx.reset(); + + ctx.fillStyle = '#0f0'; + ctx.fillRect(0, 0, 100, 50); + + var tol = 1; // tolerance to avoid antialiasing artifacts + + ctx.lineJoin = 'round'; + ctx.lineWidth = 20; + + ctx.fillStyle = '#f00'; + ctx.strokeStyle = '#0f0'; + + ctx.fillRect(10, 10, 20, 20); + ctx.fillRect(20, 20, 20, 20); + ctx.beginPath(); + ctx.moveTo(30, 20); + ctx.arc(30, 20, 10-tol, 0, 2*Math.PI, true); + ctx.fill(); + + ctx.beginPath(); + ctx.moveTo(10, 20); + ctx.lineTo(30, 20); + ctx.lineTo(30, 40); + ctx.stroke(); + + + ctx.fillStyle = '#0f0'; + ctx.strokeStyle = '#f00'; + + ctx.beginPath(); + ctx.moveTo(60, 20); + ctx.lineTo(80, 20); + ctx.lineTo(80, 40); + ctx.stroke(); + + ctx.fillRect(60, 10, 20, 20); + ctx.fillRect(70, 20, 20, 20); + ctx.beginPath(); + ctx.moveTo(80, 20); + ctx.arc(80, 20, 10+tol, 0, 2*Math.PI, true); + ctx.fill(); + + verify(Helper.comparePixel(ctx, 36,14, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 36,13, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 37,13, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 38,13, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 38,12, 0,255,0,255)); + + verify(Helper.comparePixel(ctx, 86,14, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 86,13, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 87,13, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 88,13, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 88,12, 0,255,0,255)); + + ctx.reset(); + ctx.lineJoin = 'bevel' + compare(ctx.lineJoin, 'bevel'); + + ctx.lineJoin = 'round'; + compare(ctx.lineJoin, 'round'); + + ctx.lineJoin = 'miter'; + compare(ctx.lineJoin, 'miter'); + + } + function test_miter() { + var ctx = canvas.getContext('2d'); + ctx.reset(); + ctx.fillStyle = '#f00'; + ctx.fillRect(0, 0, 100, 50); + + ctx.lineWidth = 200; + ctx.lineJoin = 'miter'; + + ctx.strokeStyle = '#0f0'; + ctx.miterLimit = 2.614; + ctx.beginPath(); + ctx.moveTo(100, 1000); + ctx.lineTo(100, 100); + ctx.lineTo(1000, 1000); + ctx.stroke(); + + ctx.strokeStyle = '#f00'; + ctx.miterLimit = 2.613; + ctx.beginPath(); + ctx.moveTo(100, 1000); + ctx.lineTo(100, 100); + ctx.lineTo(1000, 1000); + ctx.stroke(); + + //verify(Helper.comparePixel(ctx, 1,1, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 48,1, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 48,48, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 1,48, 0,255,0,255)); + + ctx.reset(); + ctx.fillStyle = '#0f0'; + ctx.fillRect(0, 0, 100, 50); + + ctx.lineWidth = 400; + ctx.lineJoin = 'miter'; + + ctx.strokeStyle = '#f00'; + ctx.miterLimit = 1.414; + ctx.beginPath(); + ctx.moveTo(200, 1000); + ctx.lineTo(200, 200); + ctx.lineTo(1000, 201); // slightly non-right-angle to avoid being a special case + ctx.stroke(); + + //verify(Helper.comparePixel(ctx, 1,1, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 48,1, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 48,48, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 1,48, 0,255,0,255)); + + ctx.reset(); + ctx.miterLimit = 1.5; + compare(ctx.miterLimit, 1.5); + + ctx.miterLimit = 1.5; + ctx.miterLimit = 0; + compare(ctx.miterLimit, 1.5); + + ctx.miterLimit = 1.5; + ctx.miterLimit = -1; + compare(ctx.miterLimit, 1.5); + + ctx.miterLimit = 1.5; + ctx.miterLimit = Infinity; + compare(ctx.miterLimit, 1.5); + + ctx.miterLimit = 1.5; + ctx.miterLimit = -Infinity; + compare(ctx.miterLimit, 1.5); + + ctx.miterLimit = 1.5; + ctx.miterLimit = NaN; + compare(ctx.miterLimit, 1.5); + + ctx.reset(); + ctx.fillStyle = '#0f0'; + ctx.fillRect(0, 0, 100, 50); + + ctx.lineWidth = 200; + ctx.lineJoin = 'miter'; + + ctx.strokeStyle = '#f00'; + ctx.miterLimit = 1.414; + ctx.beginPath(); + ctx.strokeRect(100, 25, 200, 0); + + //verify(Helper.comparePixel(ctx, 1,1, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 48,1, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 48,48, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 1,48, 0,255,0,255)); + + ctx.reset(); + ctx.fillStyle = '#f00'; + ctx.fillRect(0, 0, 100, 50); + + ctx.lineWidth = 1600; + ctx.lineJoin = 'miter'; + + ctx.strokeStyle = '#0f0'; + ctx.miterLimit = 1.083; + ctx.beginPath(); + ctx.moveTo(800, 10000); + ctx.lineTo(800, 300); + ctx.lineTo(10000, -8900); + ctx.stroke(); + + ctx.strokeStyle = '#f00'; + ctx.miterLimit = 1.082; + ctx.beginPath(); + ctx.moveTo(800, 10000); + ctx.lineTo(800, 300); + ctx.lineTo(10000, -8900); + ctx.stroke(); + + //verify(Helper.comparePixel(ctx, 1,1, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 48,1, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 48,48, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 1,48, 0,255,0,255)); + + ctx.reset(); + ctx.fillStyle = '#0f0'; + ctx.fillRect(0, 0, 100, 50); + + ctx.lineWidth = 400; + ctx.lineJoin = 'miter'; + + ctx.strokeStyle = '#f00'; + ctx.miterLimit = 1.414; + ctx.beginPath(); + ctx.moveTo(200, 1000); + ctx.lineTo(200, 200); + ctx.lineTo(1000, 200); + ctx.stroke(); + + //verify(Helper.comparePixel(ctx, 1,1, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 48,1, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 48,48, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 1,48, 0,255,0,255)); + + ctx.reset(); + ctx.miterLimit = 1.5; + compare(ctx.miterLimit, 1.5); + + ctx.miterLimit = "1e1"; + compare(ctx.miterLimit, 10); + + ctx.miterLimit = 1/1024; + compare(ctx.miterLimit, 1/1024); + + ctx.miterLimit = 1000; + compare(ctx.miterLimit, 1000); + + ctx.reset(); + ctx.fillStyle = '#f00'; + ctx.fillRect(0, 0, 100, 50); + + ctx.lineWidth = 400; + ctx.lineJoin = 'miter'; + + ctx.strokeStyle = '#0f0'; + ctx.miterLimit = 1.416; + ctx.beginPath(); + ctx.moveTo(200, 1000); + ctx.lineTo(200, 200); + ctx.lineTo(1000, 201); + ctx.stroke(); + + verify(Helper.comparePixel(ctx, 1,1, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 48,1, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 48,48, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 1,48, 0,255,0,255)); + + + } + function test_width() { + var ctx = canvas.getContext('2d'); + ctx.reset(); + ctx.fillStyle = '#0f0'; + ctx.fillRect(0, 0, 100, 50); + + ctx.lineWidth = 20; + // Draw a green line over a red box, to check the line is not too small + ctx.fillStyle = '#f00'; + ctx.strokeStyle = '#0f0'; + ctx.fillRect(15, 15, 20, 20); + ctx.beginPath(); + ctx.moveTo(25, 15); + ctx.lineTo(25, 35); + ctx.stroke(); + + // Draw a green box over a red line, to check the line is not too large + ctx.fillStyle = '#0f0'; + ctx.strokeStyle = '#f00'; + ctx.beginPath(); + ctx.moveTo(75, 15); + ctx.lineTo(75, 35); + ctx.stroke(); + ctx.fillRect(65, 15, 20, 20); + + verify(Helper.comparePixel(ctx, 14,25, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 15,25, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 16,25, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 25,25, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 34,25, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 35,25, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 36,25, 0,255,0,255)); + + verify(Helper.comparePixel(ctx, 64,25, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 65,25, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 66,25, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 75,25, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 84,25, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 85,25, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 86,25, 0,255,0,255)); + + ctx.reset(); + ctx.lineWidth = 1.5; + compare(ctx.lineWidth, 1.5); + + ctx.lineWidth = 1.5; + ctx.lineWidth = 0; + compare(ctx.lineWidth, 1.5); + + ctx.lineWidth = 1.5; + ctx.lineWidth = -1; + compare(ctx.lineWidth, 1.5); + + ctx.lineWidth = 1.5; + ctx.lineWidth = Infinity; + compare(ctx.lineWidth, 1.5); + + ctx.lineWidth = 1.5; + ctx.lineWidth = -Infinity; + compare(ctx.lineWidth, 1.5); + + ctx.lineWidth = 1.5; + ctx.lineWidth = NaN; + compare(ctx.lineWidth, 1.5); + + ctx.reset(); + ctx.fillStyle = '#f00'; + ctx.fillRect(0, 0, 100, 50); + + ctx.scale(50, 50); + ctx.strokeStyle = '#0f0'; + ctx.moveTo(0, 0.5); + ctx.lineTo(2, 0.5); + ctx.stroke(); + + //verify(Helper.comparePixel(ctx, 25,25, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 75,25, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 50,5, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 50,45, 0,255,0,255)); + + ctx.reset(); + ctx.fillStyle = '#0f0'; + ctx.fillRect(0, 0, 100, 50); + + ctx.lineWidth = 4; + // Draw a green line over a red box, to check the line is not too small + ctx.fillStyle = '#f00'; + ctx.strokeStyle = '#0f0'; + ctx.fillRect(15, 15, 20, 20); + ctx.save(); + ctx.scale(5, 1); + ctx.beginPath(); + ctx.moveTo(5, 15); + ctx.lineTo(5, 35); + ctx.stroke(); + ctx.restore(); + + // Draw a green box over a red line, to check the line is not too large + ctx.fillStyle = '#0f0'; + ctx.strokeStyle = '#f00'; + ctx.save(); + ctx.scale(-5, 1); + ctx.beginPath(); + ctx.moveTo(-15, 15); + ctx.lineTo(-15, 35); + ctx.stroke(); + ctx.restore(); + ctx.fillRect(65, 15, 20, 20); + + verify(Helper.comparePixel(ctx, 14,25, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 15,25, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 16,25, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 25,25, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 34,25, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 35,25, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 36,25, 0,255,0,255)); + + //verify(Helper.comparePixel(ctx, 64,25, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 65,25, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 66,25, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 75,25, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 84,25, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 85,25, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 86,25, 0,255,0,255)); + + ctx.reset(); + ctx.lineWidth = 1.5; + compare(ctx.lineWidth, 1.5); + + ctx.lineWidth = "1e1"; + compare(ctx.lineWidth, 10); + + ctx.lineWidth = 1/1024; + compare(ctx.lineWidth, 1/1024); + + ctx.lineWidth = 1000; + compare(ctx.lineWidth, 1000); + + } + function test_cap() { + var ctx = canvas.getContext('2d'); + ctx.reset(); + + ctx.fillStyle = '#0f0'; + ctx.fillRect(0, 0, 100, 50); + + ctx.lineCap = 'butt'; + ctx.lineWidth = 20; + + ctx.fillStyle = '#f00'; + ctx.strokeStyle = '#0f0'; + ctx.fillRect(15, 15, 20, 20); + ctx.beginPath(); + ctx.moveTo(25, 15); + ctx.lineTo(25, 35); + ctx.stroke(); + + ctx.fillStyle = '#0f0'; + ctx.strokeStyle = '#f00'; + ctx.beginPath(); + ctx.moveTo(75, 15); + ctx.lineTo(75, 35); + ctx.stroke(); + ctx.fillRect(65, 15, 20, 20); + + verify(Helper.comparePixel(ctx, 25,14, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 25,15, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 25,16, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 25,34, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 25,35, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 25,36, 0,255,0,255)); + + verify(Helper.comparePixel(ctx, 75,14, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 75,15, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 75,16, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 75,34, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 75,35, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 75,36, 0,255,0,255)); + + ctx.reset(); + + ctx.fillStyle = '#0f0'; + ctx.strokeStyle = '#f00'; + ctx.fillRect(0, 0, 100, 50); + + ctx.lineJoin = 'bevel'; + ctx.lineCap = 'square'; + ctx.lineWidth = 400; + + ctx.beginPath(); + ctx.moveTo(200, 200); + ctx.lineTo(200, 1000); + ctx.lineTo(1000, 1000); + ctx.lineTo(1000, 200); + ctx.closePath(); + ctx.stroke(); + + verify(Helper.comparePixel(ctx, 1,1, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 48,1, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 48,48, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 1,48, 0,255,0,255)); + ctx.reset(); + + ctx.lineCap = 'butt' + compare(ctx.lineCap, 'butt'); + + ctx.lineCap = 'butt'; + ctx.lineCap = 'invalid'; + compare(ctx.lineCap, 'butt'); + + ctx.lineCap = 'butt'; + ctx.lineCap = 'ROUND'; + compare(ctx.lineCap, 'butt'); + + ctx.lineCap = 'butt'; + ctx.lineCap = 'round\\0'; + compare(ctx.lineCap, 'butt'); + + ctx.lineCap = 'butt'; + ctx.lineCap = 'round '; + compare(ctx.lineCap, 'butt'); + + ctx.lineCap = 'butt'; + ctx.lineCap = ""; + compare(ctx.lineCap, 'butt'); + + ctx.lineCap = 'butt'; + ctx.lineCap = 'bevel'; + compare(ctx.lineCap, 'butt'); + + ctx.fillStyle = '#f00'; + ctx.strokeStyle = '#0f0'; + ctx.fillRect(0, 0, 100, 50); + + ctx.lineJoin = 'bevel'; + ctx.lineCap = 'square'; + ctx.lineWidth = 400; + + ctx.beginPath(); + ctx.moveTo(200, 200); + ctx.lineTo(200, 1000); + ctx.lineTo(1000, 1000); + ctx.lineTo(1000, 200); + ctx.lineTo(200, 200); + ctx.stroke(); + + //FIXME:!!! + //verify(Helper.comparePixel(ctx, 1,1, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 48,1, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 48,48, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 1,48, 0,255,0,255)); + ctx.reset(); + + ctx.fillStyle = '#0f0'; + ctx.fillRect(0, 0, 100, 50); + + var tol = 1; // tolerance to avoid antialiasing artifacts + + ctx.lineCap = 'round'; + ctx.lineWidth = 20; + + + ctx.fillStyle = '#f00'; + ctx.strokeStyle = '#0f0'; + + ctx.beginPath(); + ctx.moveTo(35-tol, 15); + ctx.arc(25, 15, 10-tol, 0, Math.PI, true); + ctx.arc(25, 35, 10-tol, Math.PI, 0, true); + ctx.fill(); + + ctx.beginPath(); + ctx.moveTo(25, 15); + ctx.lineTo(25, 35); + ctx.stroke(); + + + ctx.fillStyle = '#0f0'; + ctx.strokeStyle = '#f00'; + + ctx.beginPath(); + ctx.moveTo(75, 15); + ctx.lineTo(75, 35); + ctx.stroke(); + + ctx.beginPath(); + ctx.moveTo(85+tol, 15); + ctx.arc(75, 15, 10+tol, 0, Math.PI, true); + ctx.arc(75, 35, 10+tol, Math.PI, 0, true); + ctx.fill(); + + verify(Helper.comparePixel(ctx, 17,6, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 25,6, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 32,6, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 17,43, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 25,43, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 32,43, 0,255,0,255)); + + verify(Helper.comparePixel(ctx, 67,6, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 75,6, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 82,6, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 67,43, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 75,43, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 82,43, 0,255,0,255)); + ctx.reset(); + + ctx.fillStyle = '#0f0'; + ctx.fillRect(0, 0, 100, 50); + + ctx.lineCap = 'square'; + ctx.lineWidth = 20; + + ctx.fillStyle = '#f00'; + ctx.strokeStyle = '#0f0'; + ctx.fillRect(15, 5, 20, 40); + ctx.beginPath(); + ctx.moveTo(25, 15); + ctx.lineTo(25, 35); + ctx.stroke(); + + ctx.fillStyle = '#0f0'; + ctx.strokeStyle = '#f00'; + ctx.beginPath(); + ctx.moveTo(75, 15); + ctx.lineTo(75, 35); + ctx.stroke(); + ctx.fillRect(65, 5, 20, 40); + + verify(Helper.comparePixel(ctx, 25,4, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 25,5, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 25,6, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 25,44, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 25,45, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 25,46, 0,255,0,255)); + + verify(Helper.comparePixel(ctx, 75,4, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 75,5, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 75,6, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 75,44, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 75,45, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 75,46, 0,255,0,255)); + + ctx.reset(); + ctx.lineCap = 'butt' + compare(ctx.lineCap, 'butt'); + + ctx.lineCap = 'round'; + compare(ctx.lineCap, 'round'); + + ctx.lineCap = 'square'; + compare(ctx.lineCap, 'square'); + + } + } +} \ No newline at end of file diff --git a/tests/auto/quick/qquickcanvasitem/data/tst_path.qml b/tests/auto/quick/qquickcanvasitem/data/tst_path.qml new file mode 100644 index 0000000000..b04ccf5458 --- /dev/null +++ b/tests/auto/quick/qquickcanvasitem/data/tst_path.qml @@ -0,0 +1,1443 @@ +import QtQuick 2.0 +import QtTest 1.0 +import "testhelper.js" as Helper + +Canvas { + id:canvas; width:100;height:50; renderTarget: Canvas.Image + TestCase { + name: "path"; when: windowShown + + function test_basic() { + var ctx = canvas.getContext('2d'); + ctx.reset(); + ctx.fillStyle = '#0f0'; + ctx.fillRect(0, 0, 100, 50); + ctx.closePath(); + ctx.fillStyle = '#f00'; + ctx.fill(); + verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); + + ctx.reset(); + ctx.fillStyle = '#f00'; + ctx.fillRect(0, 0, 100, 50); + ctx.save(); + ctx.rect(0, 0, 100, 50); + ctx.restore(); + ctx.fillStyle = '#0f0'; + ctx.fill(); + verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); + + + canvas.width = 100; + ctx.rect(0, 0, 100, 50); + canvas.width = 100; + ctx.fillStyle = '#f00'; + ctx.fill(); + //verify(Helper.comparePixel(ctx, 20,20, 0,0,0,0)); + } + function test_beginPath() { + var ctx = canvas.getContext('2d'); + ctx.fillStyle = '#0f0'; + ctx.fillRect(0, 0, 100, 50); + ctx.rect(0, 0, 100, 50); + ctx.beginPath(); + ctx.fillStyle = '#f00'; + ctx.fill(); + verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); + } + function test_closePath() { + var ctx = canvas.getContext('2d'); + ctx.reset(); + ctx.fillStyle = '#0f0'; + ctx.fillRect(0, 0, 100, 50); + ctx.closePath(); + ctx.fillStyle = '#f00'; + ctx.fill(); + verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); + + ctx.reset(); + ctx.fillStyle = '#f00'; + ctx.fillRect(0, 0, 100, 50); + ctx.strokeStyle = '#0f0'; + ctx.lineWidth = 50; + ctx.moveTo(-100, 25); + ctx.lineTo(-100, -100); + ctx.lineTo(200, -100); + ctx.lineTo(200, 25); + ctx.closePath(); + ctx.stroke(); + verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); + + ctx.reset(); + ctx.fillStyle = '#f00'; + ctx.fillRect(0, 0, 100, 50); + ctx.strokeStyle = '#0f0'; + ctx.lineWidth = 50; + ctx.moveTo(-100, 25); + ctx.lineTo(-100, -1000); + ctx.closePath(); + ctx.lineTo(1000, 25); + ctx.stroke(); + verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); + } + + function test_isPointInPath() { + var ctx = canvas.getContext('2d'); + ctx.reset(); + ctx.arc(50, 25, 10, 0, Math.PI, false); + verify(!ctx.isPointInPath(50, 10)); + verify(!ctx.isPointInPath(50, 20)); + //verify(!ctx.isPointInPath(50, 30)); + verify(!ctx.isPointInPath(50, 40)); + verify(!ctx.isPointInPath(30, 20)); + verify(!ctx.isPointInPath(70, 20)); + verify(!ctx.isPointInPath(30, 30)); + verify(!ctx.isPointInPath(70, 30)); + + ctx.reset(); + ctx.rect(0, 0, 20, 20); + verify(ctx.isPointInPath(10, 10)); + verify(!ctx.isPointInPath(30, 10)); + + ctx.reset(); + ctx.rect(20, 0, 20, 20); + //verify(ctx.isPointInPath(10, 10)); + verify(ctx.isPointInPath(30, 10)); + + ctx.reset(); + ctx.bezierCurveTo(50, -50, 50, 100, 75, 25); + verify(!ctx.isPointInPath(25, 20)); + verify(!ctx.isPointInPath(25, 30)); + //verify(ctx.isPointInPath(30, 20)); + verify(!ctx.isPointInPath(30, 30)); + //verify(!ctx.isPointInPath(40, 2)); + //verify(ctx.isPointInPath(40, 20)); + verify(!ctx.isPointInPath(40, 30)); + verify(!ctx.isPointInPath(40, 47)); + //verify(ctx.isPointInPath(45, 20)); + //verify(!ctx.isPointInPath(45, 30)); + //verify(!ctx.isPointInPath(55, 20)); + //verify(ctx.isPointInPath(55, 30)); + verify(!ctx.isPointInPath(60, 2)); + //verify(!ctx.isPointInPath(60, 20)); + verify(ctx.isPointInPath(60, 30)); + verify(!ctx.isPointInPath(60, 47)); + verify(!ctx.isPointInPath(70, 20)); + verify(ctx.isPointInPath(70, 30)); + verify(!ctx.isPointInPath(75, 20)); + verify(!ctx.isPointInPath(75, 30)); + + ctx.reset(); + ctx.arc(50, 25, 10, 0, 7, false); + verify(!ctx.isPointInPath(50, 10)); + //verify(ctx.isPointInPath(50, 20)); + //verify(ctx.isPointInPath(50, 30)); + verify(!ctx.isPointInPath(50, 40)); + verify(!ctx.isPointInPath(30, 20)); + verify(!ctx.isPointInPath(70, 20)); + verify(!ctx.isPointInPath(30, 30)); + //verify(!ctx.isPointInPath(70, 30)); + + ctx.reset(); + ctx.rect(0, 0, 20, 20); + verify(ctx.isPointInPath(0, 0)); + verify(ctx.isPointInPath(10, 0)); + //verify(ctx.isPointInPath(20, 0)); + //verify(ctx.isPointInPath(20, 10)); + //verify(ctx.isPointInPath(20, 20)); + //verify(ctx.isPointInPath(10, 20)); + //verify(ctx.isPointInPath(0, 20)); + verify(ctx.isPointInPath(0, 10)); + verify(!ctx.isPointInPath(10, -0.01)); + verify(!ctx.isPointInPath(10, 20.01)); + verify(!ctx.isPointInPath(-0.01, 10)); + //verify(!ctx.isPointInPath(20.01, 10)); + + ctx.reset(); + verify(!ctx.isPointInPath(0, 0)); + + + ctx.reset(); + ctx.rect(-100, -50, 200, 100); + //verify(ctx.isPointInPath(Infinity, 0)); + //verify(ctx.isPointInPath(-Infinity, 0)); + //verify(ctx.isPointInPath(NaN, 0)); + //verify(ctx.isPointInPath(0, Infinity)); + //verify(ctx.isPointInPath(0, -Infinity)); + //verify(ctx.isPointInPath(0, NaN)); + //verify(ctx.isPointInPath(NaN, NaN)); + + ctx.reset(); + ctx.rect(0, -100, 20, 20); + ctx.rect(20, -10, 20, 20); + verify(!ctx.isPointInPath(10, -110)); + verify(ctx.isPointInPath(10, -90)); + verify(!ctx.isPointInPath(10, -70)); + //verify(!ctx.isPointInPath(30, -20)); + //verify(ctx.isPointInPath(30, 0)); + //verify(!ctx.isPointInPath(30, 20)); + + ctx.reset(); + ctx.rect(0, 0, 20, 20); + ctx.beginPath(); + ctx.rect(20, 0, 20, 20); + ctx.closePath(); + ctx.rect(40, 0, 20, 20); + verify(!ctx.isPointInPath(10, 10)); + verify(ctx.isPointInPath(30, 10)); + verify(ctx.isPointInPath(50, 10)); + + ctx.reset(); + ctx.translate(50, 0); + ctx.rect(0, 0, 20, 20); + verify(!ctx.isPointInPath(-40, 10)); + verify(!ctx.isPointInPath(10, 10)); + //verify(!ctx.isPointInPath(49, 10)); + verify(ctx.isPointInPath(51, 10)); + verify(ctx.isPointInPath(69, 10)); + verify(!ctx.isPointInPath(71, 10)); + + ctx.reset(); + ctx.rect(50, 0, 20, 20); + ctx.translate(50, 0); + verify(!ctx.isPointInPath(-40, 10)); + verify(!ctx.isPointInPath(10, 10)); + //verify(!ctx.isPointInPath(49, 10)); + verify(ctx.isPointInPath(51, 10)); + verify(ctx.isPointInPath(69, 10)); + verify(!ctx.isPointInPath(71, 10)); + + ctx.reset(); + ctx.scale(-1, 1); + ctx.rect(-70, 0, 20, 20); + verify(!ctx.isPointInPath(-40, 10)); + verify(!ctx.isPointInPath(10, 10)); + //verify(!ctx.isPointInPath(49, 10)); + verify(ctx.isPointInPath(51, 10)); + verify(ctx.isPointInPath(69, 10)); + verify(!ctx.isPointInPath(71, 10)); + + ctx.reset(); + ctx.moveTo(0, 0); + ctx.lineTo(20, 0); + ctx.lineTo(20, 20); + ctx.lineTo(0, 20); + verify(ctx.isPointInPath(10, 10)); + //verify(!ctx.isPointInPath(30, 10)); + + ctx.reset(); + ctx.moveTo(0, 0); + ctx.lineTo(50, 0); + ctx.lineTo(50, 50); + ctx.lineTo(0, 50); + ctx.lineTo(0, 0); + ctx.lineTo(10, 10); + ctx.lineTo(10, 40); + ctx.lineTo(40, 40); + ctx.lineTo(40, 10); + ctx.lineTo(10, 10); + + verify(ctx.isPointInPath(5, 5)); + verify(ctx.isPointInPath(25, 5)); + verify(ctx.isPointInPath(45, 5)); + verify(ctx.isPointInPath(5, 25)); + verify(!ctx.isPointInPath(25, 25)); + verify(ctx.isPointInPath(45, 25)); + verify(ctx.isPointInPath(5, 45)); + verify(ctx.isPointInPath(25, 45)); + verify(ctx.isPointInPath(45, 45)); + } + + + function test_fill() { + var ctx = canvas.getContext('2d'); + ctx.reset(); + ctx.fillStyle = '#f00'; + ctx.fillRect(0, 0, 100, 50); + + ctx.fillStyle = '#0f0'; + ctx.moveTo(0, 0); + ctx.lineTo(100, 0); + ctx.lineTo(100, 50); + ctx.lineTo(0, 50); + ctx.fill(); + + verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); + + + ctx.reset(); + ctx.fillStyle = '#00f'; + ctx.fillRect(0, 0, 100, 50); + + ctx.moveTo(0, 0); + ctx.lineTo(100, 0); + ctx.lineTo(100, 50); + ctx.fillStyle = '#f00'; + ctx.fill(); + ctx.lineTo(0, 50); + ctx.fillStyle = '#0f0'; + ctx.fill(); + + //verify(Helper.comparePixel(ctx, 90,10, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 10,40, 0,255,0,255)); + + ctx.reset(); + ctx.fillStyle = '#000'; + ctx.fillRect(0, 0, 100, 50); + + ctx.fillStyle = 'rgba(0, 255, 0, 0.5)'; + ctx.rect(0, 0, 100, 50); + ctx.closePath(); + ctx.rect(10, 10, 80, 30); + ctx.fill(); + + //verify(Helper.comparePixel(ctx, 50,25, 0,127,0,255, 1)); + + ctx.reset(); + ctx.fillStyle = '#f00'; + ctx.fillRect(0, 0, 100, 50); + + ctx.fillStyle = '#0f0'; + ctx.moveTo(-10, -10); + ctx.lineTo(110, -10); + ctx.lineTo(110, 60); + ctx.lineTo(-10, 60); + ctx.lineTo(-10, -10); + ctx.lineTo(0, 0); + ctx.lineTo(100, 0); + ctx.lineTo(100, 50); + ctx.lineTo(0, 50); + ctx.fill(); + + //verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); + + ctx.reset(); + ctx.fillStyle = '#0f0'; + ctx.fillRect(0, 0, 100, 50); + + ctx.fillStyle = '#f00'; + ctx.moveTo(-10, -10); + ctx.lineTo(110, -10); + ctx.lineTo(110, 60); + ctx.lineTo(-10, 60); + ctx.lineTo(-10, -10); + ctx.lineTo(0, 0); + ctx.lineTo(0, 50); + ctx.lineTo(100, 50); + ctx.lineTo(100, 0); + ctx.fill(); + + verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); + + ctx.reset(); + ctx.fillStyle = '#0f0'; + ctx.fillRect(0, 0, 100, 50); + + ctx.fillStyle = '#f00'; + ctx.moveTo(-10, -10); + ctx.lineTo(110, -10); + ctx.lineTo(110, 60); + ctx.lineTo(-10, 60); + ctx.moveTo(0, 0); + ctx.lineTo(0, 50); + ctx.lineTo(100, 50); + ctx.lineTo(100, 0); + ctx.fill(); + + verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); + + ctx.reset(); + ctx.fillStyle = '#f00'; + ctx.fillRect(0, 0, 100, 50); + + ctx.fillStyle = '#0f0'; + ctx.moveTo(-10, -10); + ctx.lineTo(110, -10); + ctx.lineTo(110, 60); + ctx.lineTo(-10, 60); + ctx.lineTo(-10, -10); + ctx.lineTo(-20, -20); + ctx.lineTo(120, -20); + ctx.lineTo(120, 70); + ctx.lineTo(-20, 70); + ctx.lineTo(-20, -20); + ctx.lineTo(0, 0); + ctx.lineTo(0, 50); + ctx.lineTo(100, 50); + ctx.lineTo(100, 0); + ctx.fill(); + + verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); + + } + function test_stroke() { + var ctx = canvas.getContext('2d'); + ctx.reset(); + ctx.fillStyle = '#0f0'; + ctx.fillRect(0, 0, 100, 50); + + ctx.strokeStyle = '#f00'; + ctx.lineWidth = 100; + ctx.lineCap = 'round'; + ctx.lineJoin = 'round'; + + ctx.beginPath(); + ctx.moveTo(40, 25); + ctx.moveTo(60, 25); + ctx.stroke(); + + verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); + + ctx.reset(); + ctx.fillStyle = '#000'; + ctx.fillRect(0, 0, 100, 50); + + ctx.strokeStyle = 'rgba(0, 255, 0, 0.5)'; + ctx.lineWidth = 50; + ctx.moveTo(0, 20); + ctx.lineTo(100, 20); + ctx.moveTo(0, 30); + ctx.lineTo(100, 30); + ctx.stroke(); + + //verify(Helper.comparePixel(ctx, 50,25, 0,127,0,255)); + + ctx.reset(); + ctx.fillStyle = '#0f0'; + ctx.fillRect(0, 0, 100, 50); + + ctx.strokeStyle = '#f00'; + ctx.lineWidth = 100; + ctx.lineCap = 'round'; + ctx.lineJoin = 'round'; + + ctx.beginPath(); + ctx.moveTo(50, 25); + ctx.arcTo(50, 25, 150, 25, 10); + ctx.stroke(); + + ctx.beginPath(); + ctx.moveTo(50, 25); + ctx.arc(50, 25, 10, 0, 0, false); + ctx.stroke(); + + // verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); + ctx.reset(); + ctx.fillStyle = '#0f0'; + ctx.fillRect(0, 0, 100, 50); + + ctx.strokeStyle = '#f00'; + ctx.lineWidth = 100; + ctx.lineCap = 'round'; + ctx.lineJoin = 'round'; + + ctx.beginPath(); + ctx.moveTo(50, 25); + ctx.lineTo(50, 25); + ctx.closePath(); + ctx.stroke(); + + verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); + ctx.reset(); + + ctx.fillStyle = '#0f0'; + ctx.fillRect(0, 0, 100, 50); + + ctx.strokeStyle = '#f00'; + ctx.lineWidth = 400; + ctx.lineJoin = 'miter'; + ctx.miterLimit = 1.4; + + ctx.beginPath(); + ctx.moveTo(-1000, 200, 0, 0); + ctx.lineTo(-100, 200); + ctx.lineTo(-100, 200); + ctx.lineTo(-100, 200); + ctx.lineTo(-100, 1000); + ctx.stroke(); + + verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); + + ctx.reset(); + ctx.fillStyle = '#0f0'; + ctx.fillRect(0, 0, 100, 50); + + ctx.strokeStyle = '#f00'; + ctx.lineWidth = 100; + ctx.lineCap = 'round'; + ctx.lineJoin = 'round'; + + ctx.beginPath(); + ctx.moveTo(50, 25); + ctx.quadraticCurveTo(50, 25, 50, 25); + ctx.stroke(); + + ctx.beginPath(); + ctx.moveTo(50, 25); + ctx.bezierCurveTo(50, 25, 50, 25, 50, 25); + ctx.stroke(); + + verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); + + ctx.fillStyle = '#0f0'; + ctx.fillRect(0, 0, 100, 50); + + ctx.strokeStyle = '#f00'; + ctx.lineWidth = 100; + ctx.lineCap = 'round'; + ctx.lineJoin = 'round'; + + ctx.beginPath(); + ctx.moveTo(50, 25); + ctx.lineTo(50, 25); + ctx.stroke(); + + verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); + + ctx.reset(); + ctx.fillStyle = '#0f0'; + ctx.fillRect(0, 0, 100, 50); + + ctx.strokeStyle = '#f00'; + ctx.lineWidth = 100; + ctx.lineCap = 'round'; + ctx.lineJoin = 'round'; + + ctx.beginPath(); + ctx.rect(50, 25, 0, 0); + ctx.stroke(); + + ctx.strokeRect(50, 25, 0, 0); + + verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); + + + ctx.fillStyle = '#f00'; + ctx.fillRect(0, 0, 100, 50); + + ctx.beginPath(); + ctx.rect(25, 12.5, 50, 25); + ctx.save(); + ctx.scale(50, 25); + ctx.strokeStyle = '#0f0'; + ctx.stroke(); + ctx.restore(); + + ctx.beginPath(); + ctx.rect(-25, -12.5, 150, 75); + ctx.save(); + ctx.scale(50, 25); + ctx.strokeStyle = '#f00'; + ctx.stroke(); + ctx.restore(); + + //verify(Helper.comparePixel(ctx, 0,0, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 50,0, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 99,0, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 0,25, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 99,25, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 0,49, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 50,49, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 99,49, 0,255,0,255)); + + ctx.reset(); + ctx.fillStyle = '#f00'; + ctx.fillRect(0, 0, 100, 50); + + ctx.beginPath(); + ctx.rect(25, 12.5, 50, 25); + ctx.save(); + ctx.rotate(Math.PI/2); + ctx.scale(25, 50); + ctx.strokeStyle = '#0f0'; + ctx.stroke(); + ctx.restore(); + + ctx.beginPath(); + ctx.rect(-25, -12.5, 150, 75); + ctx.save(); + ctx.rotate(Math.PI/2); + ctx.scale(25, 50); + ctx.strokeStyle = '#f00'; + ctx.stroke(); + ctx.restore(); + + //verify(Helper.comparePixel(ctx, 0,0, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 50,0, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 99,0, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 0,25, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 99,25, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 0,49, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 50,49, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 99,49, 0,255,0,255)); + + ctx.reset(); + ctx.fillStyle = '#f00'; + ctx.fillRect(0, 0, 100, 50); + + ctx.save(); + ctx.beginPath(); + ctx.moveTo(49, -50); + ctx.lineTo(201, -50); + ctx.rotate(Math.PI/4); + ctx.scale(1, 283); + ctx.strokeStyle = '#0f0'; + ctx.stroke(); + ctx.restore(); + + ctx.save(); + ctx.beginPath(); + ctx.translate(-150, 0); + ctx.moveTo(49, -50); + ctx.lineTo(199, -50); + ctx.rotate(Math.PI/4); + ctx.scale(1, 142); + ctx.strokeStyle = '#f00'; + ctx.stroke(); + ctx.restore(); + + ctx.save(); + ctx.beginPath(); + ctx.translate(-150, 0); + ctx.moveTo(49, -50); + ctx.lineTo(199, -50); + ctx.rotate(Math.PI/4); + ctx.scale(1, 142); + ctx.strokeStyle = '#f00'; + ctx.stroke(); + ctx.restore(); + + //verify(Helper.comparePixel(ctx, 0,0, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 50,0, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 99,0, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 0,25, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 99,25, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 0,49, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 50,49, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 99,49, 0,255,0,255)); + + ctx.reset(); + ctx.fillStyle = '#f00'; + ctx.fillRect(0, 0, 100, 50); + + ctx.lineWidth = 50; + ctx.moveTo(-100, 25); + ctx.lineTo(-100, -100); + ctx.lineTo(200, -100); + ctx.lineTo(200, 25); + ctx.strokeStyle = '#f00'; + ctx.stroke(); + + ctx.closePath(); + ctx.strokeStyle = '#0f0'; + ctx.stroke(); + + verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); + + ctx.reset(); + ctx.fillStyle = '#f00'; + ctx.fillRect(0, 0, 100, 50); + + ctx.strokeStyle = '#0f0'; + ctx.lineWidth = 40; + ctx.moveTo(0, 10); + ctx.lineTo(100, 10); + ctx.moveTo(100, 40); + ctx.lineTo(0, 40); + ctx.stroke(); + + verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); + + } + function test_clip() { + var ctx = canvas.getContext('2d'); + ctx.reset(); + ctx.fillStyle = '#f00'; + ctx.fillRect(0, 0, 100, 50); + + ctx.beginPath(); + ctx.rect(0, 0, 100, 50); + ctx.clip(); + + ctx.fillStyle = '#0f0'; + ctx.fillRect(0, 0, 100, 50); + + verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); + + ctx.reset(); + ctx.fillStyle = '#0f0'; + ctx.fillRect(0, 0, 100, 50); + + ctx.beginPath(); + ctx.rect(-100, 0, 100, 50); + ctx.clip(); + + ctx.fillStyle = '#f00'; + ctx.fillRect(0, 0, 100, 50); + + verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); + ctx.reset(); + ctx.fillStyle = '#0f0'; + ctx.fillRect(0, 0, 100, 50); + + ctx.beginPath(); + ctx.clip(); + + ctx.fillStyle = '#f00'; + ctx.fillRect(0, 0, 100, 50); + + verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); + + ctx.fillStyle = '#0f0'; + ctx.fillRect(0, 0, 100, 50); + + ctx.beginPath(); + ctx.rect(0, 0, 50, 50); + ctx.clip(); + ctx.beginPath(); + ctx.rect(50, 0, 50, 50) + ctx.clip(); + + ctx.fillStyle = '#f00'; + ctx.fillRect(0, 0, 100, 50); + + verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); + + ctx.reset(); + ctx.fillStyle = '#f00'; + ctx.fillRect(0, 0, 100, 50); + + ctx.fillStyle = '#0f0'; + + ctx.beginPath(); + ctx.moveTo(0, 0); + ctx.lineTo(0, 50); + ctx.lineTo(100, 50); + ctx.lineTo(100, 0); + ctx.clip(); + + ctx.lineTo(0, 0); + ctx.fill(); + + verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); + + + ctx.reset(); + ctx.fillStyle = '#0f0'; + ctx.fillRect(0, 0, 100, 50); + + ctx.beginPath(); + ctx.moveTo(-10, -10); + ctx.lineTo(110, -10); + ctx.lineTo(110, 60); + ctx.lineTo(-10, 60); + ctx.lineTo(-10, -10); + ctx.lineTo(0, 0); + ctx.lineTo(0, 50); + ctx.lineTo(100, 50); + ctx.lineTo(100, 0); + ctx.clip(); + + ctx.fillStyle = '#f00'; + ctx.fillRect(0, 0, 100, 50); + + verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); + + ctx.reset(); + ctx.fillStyle = '#f00'; + ctx.fillRect(0, 0, 100, 50); + + ctx.beginPath(); + ctx.moveTo(-10, -10); + ctx.lineTo(110, -10); + ctx.lineTo(110, 60); + ctx.lineTo(-10, 60); + ctx.lineTo(-10, -10); + ctx.clip(); + + ctx.beginPath(); + ctx.moveTo(0, 0); + ctx.lineTo(0, 50); + ctx.lineTo(100, 50); + ctx.lineTo(100, 0); + ctx.lineTo(0, 0); + ctx.clip(); + + ctx.fillStyle = '#0f0'; + ctx.fillRect(0, 0, 100, 50); + + verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); + } + + function test_moveTo() { + var ctx = canvas.getContext('2d'); + ctx.reset(); + ctx.fillStyle = '#f00'; + ctx.fillRect(0, 0, 100, 50); + ctx.rect(0, 0, 10, 50); + ctx.moveTo(100, 0); + ctx.lineTo(10, 0); + ctx.lineTo(10, 50); + ctx.lineTo(100, 50); + ctx.fillStyle = '#0f0'; + ctx.fill(); + verify(Helper.comparePixel(ctx, 90,25, 0,255,0,255)); + ctx.reset(); + ctx.fillStyle = '#f00'; + ctx.fillRect(0, 0, 100, 50); + ctx.moveTo(0, 25); + ctx.moveTo(100, 25); + ctx.moveTo(0, 25); + ctx.lineTo(100, 25); + ctx.strokeStyle = '#0f0'; + ctx.lineWidth = 50; + ctx.stroke(); + verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); + + ctx.reset(); + ctx.fillStyle = '#0f0'; + ctx.fillRect(0, 0, 100, 50); + ctx.beginPath(); + ctx.moveTo(0, 0); + ctx.moveTo(100, 0); + ctx.moveTo(100, 50); + ctx.moveTo(0, 50); + ctx.fillStyle = '#f00'; + ctx.fill(); + verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); + + ctx.reset(); + ctx.moveTo(0, 0); + ctx.lineTo(100, 0); + ctx.moveTo(Infinity, 50); + ctx.moveTo(-Infinity, 50); + ctx.moveTo(NaN, 50); + ctx.moveTo(0, Infinity); + ctx.moveTo(0, -Infinity); + ctx.moveTo(0, NaN); + ctx.moveTo(Infinity, Infinity); + ctx.lineTo(100, 50); + ctx.lineTo(0, 50); + ctx.fillStyle = '#0f0'; + ctx.fill(); + verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); + } + function test_lineTo() { + var ctx = canvas.getContext('2d'); + ctx.reset(); + ctx.fillStyle = '#f00'; + ctx.fillRect(0, 0, 100, 50); + ctx.strokeStyle = '#0f0'; + ctx.lineWidth = 50; + ctx.beginPath(); + ctx.moveTo(0, 25); + ctx.lineTo(100, 25); + ctx.stroke(); + verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); + + ctx.reset(); + ctx.fillStyle = '#0f0'; + ctx.fillRect(0, 0, 100, 50); + ctx.strokeStyle = '#f00'; + ctx.lineWidth = 50; + ctx.beginPath(); + ctx.lineTo(100, 50); + ctx.stroke(); + // verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); + + ctx.reset(); + ctx.fillStyle = '#f00'; + ctx.fillRect(0, 0, 100, 50); + ctx.strokeStyle = '#0f0'; + ctx.lineWidth = 50; + ctx.beginPath(); + ctx.lineTo(0, 25); + ctx.lineTo(100, 25); + ctx.stroke(); + verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); + + ctx.reset(); + ctx.fillStyle = '#f00'; + ctx.fillRect(0, 0, 100, 50); + ctx.strokeStyle = '#0f0'; + ctx.lineWidth = 50; + ctx.beginPath(); + ctx.moveTo(-100, -100); + ctx.lineTo(0, 25); + ctx.lineTo(100, 25); + ctx.stroke(); + verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); + + ctx.reset(); + ctx.moveTo(0, 0); + ctx.lineTo(100, 0); + ctx.lineTo(Infinity, 50); + ctx.lineTo(-Infinity, 50); + ctx.lineTo(NaN, 50); + ctx.lineTo(0, Infinity); + ctx.lineTo(0, -Infinity); + ctx.lineTo(0, NaN); + ctx.lineTo(Infinity, Infinity); + ctx.lineTo(100, 50); + ctx.lineTo(0, 50); + ctx.fillStyle = '#0f0'; + ctx.fill(); + verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 90,45, 0,255,0,255)); + + } + function test_bezierCurveTo() { + var ctx = canvas.getContext('2d'); + ctx.reset(); + ctx.fillStyle = '#f00'; + ctx.fillRect(0, 0, 100, 50); + ctx.strokeStyle = '#0f0'; + ctx.lineWidth = 50; + ctx.beginPath(); + ctx.moveTo(0, 25); + ctx.bezierCurveTo(100, 25, 100, 25, 100, 25); + ctx.stroke(); + verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); + + ctx.reset(); + ctx.fillStyle = '#0f0'; + ctx.fillRect(0, 0, 100, 50); + ctx.strokeStyle = '#f00'; + ctx.lineWidth = 50; + ctx.beginPath(); + ctx.bezierCurveTo(100, 50, 200, 50, 200, 50); + ctx.stroke(); + //verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 95,45, 0,255,0,255)); + + ctx.reset(); + ctx.fillStyle = '#f00'; + ctx.fillRect(0, 0, 100, 50); + ctx.strokeStyle = '#0f0'; + ctx.lineWidth = 50; + ctx.beginPath(); + ctx.bezierCurveTo(0, 25, 100, 25, 100, 25); + ctx.stroke(); + verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 5,45, 0,255,0,255)); + + ctx.reset(); + ctx.moveTo(0, 0); + ctx.lineTo(100, 0); + ctx.bezierCurveTo(Infinity, 50, 0, 50, 0, 50); + ctx.bezierCurveTo(-Infinity, 50, 0, 50, 0, 50); + ctx.bezierCurveTo(NaN, 50, 0, 50, 0, 50); + ctx.bezierCurveTo(0, Infinity, 0, 50, 0, 50); + ctx.bezierCurveTo(0, -Infinity, 0, 50, 0, 50); + ctx.bezierCurveTo(0, NaN, 0, 50, 0, 50); + ctx.bezierCurveTo(0, 50, Infinity, 50, 0, 50); + ctx.bezierCurveTo(0, 50, -Infinity, 50, 0, 50); + ctx.bezierCurveTo(0, 50, NaN, 50, 0, 50); + ctx.bezierCurveTo(0, 50, 0, Infinity, 0, 50); + ctx.bezierCurveTo(0, 50, 0, -Infinity, 0, 50); + ctx.bezierCurveTo(0, 50, 0, NaN, 0, 50); + ctx.bezierCurveTo(0, 50, 0, 50, Infinity, 50); + ctx.bezierCurveTo(0, 50, 0, 50, -Infinity, 50); + ctx.bezierCurveTo(0, 50, 0, 50, NaN, 50); + ctx.bezierCurveTo(0, 50, 0, 50, 0, Infinity); + ctx.bezierCurveTo(0, 50, 0, 50, 0, -Infinity); + ctx.bezierCurveTo(0, 50, 0, 50, 0, NaN); + ctx.bezierCurveTo(Infinity, Infinity, 0, 50, 0, 50); + ctx.bezierCurveTo(Infinity, Infinity, Infinity, 50, 0, 50); + ctx.bezierCurveTo(Infinity, Infinity, Infinity, Infinity, 0, 50); + ctx.bezierCurveTo(Infinity, Infinity, Infinity, Infinity, Infinity, 50); + ctx.bezierCurveTo(Infinity, Infinity, Infinity, Infinity, Infinity, Infinity); + ctx.bezierCurveTo(Infinity, Infinity, Infinity, Infinity, 0, Infinity); + ctx.bezierCurveTo(Infinity, Infinity, Infinity, 50, Infinity, 50); + ctx.bezierCurveTo(Infinity, Infinity, Infinity, 50, Infinity, Infinity); + ctx.bezierCurveTo(Infinity, Infinity, Infinity, 50, 0, Infinity); + ctx.bezierCurveTo(Infinity, Infinity, 0, Infinity, 0, 50); + ctx.bezierCurveTo(Infinity, Infinity, 0, Infinity, Infinity, 50); + ctx.bezierCurveTo(Infinity, Infinity, 0, Infinity, Infinity, Infinity); + ctx.bezierCurveTo(Infinity, Infinity, 0, Infinity, 0, Infinity); + ctx.bezierCurveTo(Infinity, Infinity, 0, 50, Infinity, 50); + ctx.bezierCurveTo(Infinity, Infinity, 0, 50, Infinity, Infinity); + ctx.bezierCurveTo(Infinity, Infinity, 0, 50, 0, Infinity); + ctx.bezierCurveTo(Infinity, 50, Infinity, 50, 0, 50); + ctx.bezierCurveTo(Infinity, 50, Infinity, Infinity, 0, 50); + ctx.bezierCurveTo(Infinity, 50, Infinity, Infinity, Infinity, 50); + ctx.bezierCurveTo(Infinity, 50, Infinity, Infinity, Infinity, Infinity); + ctx.bezierCurveTo(Infinity, 50, Infinity, Infinity, 0, Infinity); + ctx.bezierCurveTo(Infinity, 50, Infinity, 50, Infinity, 50); + ctx.bezierCurveTo(Infinity, 50, Infinity, 50, Infinity, Infinity); + ctx.bezierCurveTo(Infinity, 50, Infinity, 50, 0, Infinity); + ctx.bezierCurveTo(Infinity, 50, 0, Infinity, 0, 50); + ctx.bezierCurveTo(Infinity, 50, 0, Infinity, Infinity, 50); + ctx.bezierCurveTo(Infinity, 50, 0, Infinity, Infinity, Infinity); + ctx.bezierCurveTo(Infinity, 50, 0, Infinity, 0, Infinity); + ctx.bezierCurveTo(Infinity, 50, 0, 50, Infinity, 50); + ctx.bezierCurveTo(Infinity, 50, 0, 50, Infinity, Infinity); + ctx.bezierCurveTo(Infinity, 50, 0, 50, 0, Infinity); + ctx.bezierCurveTo(Infinity, 50, Infinity, 50, 0, 50); + ctx.bezierCurveTo(Infinity, 50, Infinity, Infinity, 0, 50); + ctx.bezierCurveTo(Infinity, 50, Infinity, Infinity, Infinity, 50); + ctx.bezierCurveTo(Infinity, 50, Infinity, Infinity, Infinity, Infinity); + ctx.bezierCurveTo(Infinity, 50, Infinity, Infinity, 0, Infinity); + ctx.bezierCurveTo(Infinity, 50, Infinity, 50, Infinity, 50); + ctx.bezierCurveTo(Infinity, 50, Infinity, 50, Infinity, Infinity); + ctx.bezierCurveTo(Infinity, 50, Infinity, 50, 0, Infinity); + ctx.bezierCurveTo(Infinity, 50, 0, Infinity, 0, 50); + ctx.bezierCurveTo(Infinity, 50, 0, Infinity, Infinity, 50); + ctx.bezierCurveTo(Infinity, 50, 0, Infinity, Infinity, Infinity); + ctx.bezierCurveTo(Infinity, 50, 0, Infinity, 0, Infinity); + ctx.bezierCurveTo(Infinity, 50, 0, 50, Infinity, 50); + ctx.bezierCurveTo(Infinity, 50, 0, 50, Infinity, Infinity); + ctx.bezierCurveTo(Infinity, 50, 0, 50, 0, Infinity); + ctx.bezierCurveTo(0, Infinity, Infinity, 50, 0, 50); + ctx.bezierCurveTo(0, Infinity, Infinity, Infinity, 0, 50); + ctx.bezierCurveTo(0, Infinity, Infinity, Infinity, Infinity, 50); + ctx.bezierCurveTo(0, Infinity, Infinity, Infinity, Infinity, Infinity); + ctx.bezierCurveTo(0, Infinity, Infinity, Infinity, 0, Infinity); + ctx.bezierCurveTo(0, Infinity, Infinity, 50, Infinity, 50); + ctx.bezierCurveTo(0, Infinity, Infinity, 50, Infinity, Infinity); + ctx.bezierCurveTo(0, Infinity, Infinity, 50, 0, Infinity); + ctx.bezierCurveTo(0, Infinity, 0, Infinity, 0, 50); + ctx.bezierCurveTo(0, Infinity, 0, Infinity, Infinity, 50); + ctx.bezierCurveTo(0, Infinity, 0, Infinity, Infinity, Infinity); + ctx.bezierCurveTo(0, Infinity, 0, Infinity, 0, Infinity); + ctx.bezierCurveTo(0, Infinity, 0, 50, Infinity, 50); + ctx.bezierCurveTo(0, Infinity, 0, 50, Infinity, Infinity); + ctx.bezierCurveTo(0, Infinity, 0, 50, 0, Infinity); + ctx.bezierCurveTo(0, 50, Infinity, Infinity, 0, 50); + ctx.bezierCurveTo(0, 50, Infinity, Infinity, Infinity, 50); + ctx.bezierCurveTo(0, 50, Infinity, Infinity, Infinity, Infinity); + ctx.bezierCurveTo(0, 50, Infinity, Infinity, 0, Infinity); + ctx.bezierCurveTo(0, 50, Infinity, 50, Infinity, 50); + ctx.bezierCurveTo(0, 50, Infinity, 50, Infinity, Infinity); + ctx.bezierCurveTo(0, 50, Infinity, 50, 0, Infinity); + ctx.bezierCurveTo(0, 50, 0, Infinity, Infinity, 50); + ctx.bezierCurveTo(0, 50, 0, Infinity, Infinity, Infinity); + ctx.bezierCurveTo(0, 50, 0, Infinity, 0, Infinity); + ctx.bezierCurveTo(0, 50, 0, 50, Infinity, Infinity); + ctx.lineTo(100, 50); + ctx.lineTo(0, 50); + ctx.fillStyle = '#0f0'; + ctx.fill(); + verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 90,45, 0,255,0,255)); + + ctx.reset(); + ctx.fillStyle = '#f00'; + ctx.fillRect(0, 0, 100, 50); + ctx.scale(1000, 1000); + ctx.strokeStyle = '#0f0'; + ctx.lineWidth = 0.055; + ctx.beginPath(); + ctx.moveTo(-2, 3.1); + ctx.bezierCurveTo(-2, -1, 2.1, -1, 2.1, 3.1); + ctx.stroke(); + //verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 1,1, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 98,1, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 1,48, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 98,48, 0,255,0,255)); + + ctx.reset(); + ctx.fillStyle = '#f00'; + ctx.fillRect(0, 0, 100, 50); + ctx.strokeStyle = '#0f0'; + ctx.lineWidth = 55; + ctx.beginPath(); + ctx.moveTo(-2000, 3100); + ctx.bezierCurveTo(-2000, -1000, 2100, -1000, 2100, 3100); + ctx.stroke(); + verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 1,1, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 98,1, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 1,48, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 98,48, 0,255,0,255)); + + } + function test_quadraticCurveTo() { + var ctx = canvas.getContext('2d'); + ctx.reset(); + ctx.fillStyle = '#f00'; + ctx.fillRect(0, 0, 100, 50); + ctx.strokeStyle = '#0f0'; + ctx.lineWidth = 50; + ctx.beginPath(); + ctx.moveTo(0, 25); + ctx.quadraticCurveTo(100, 25, 100, 25); + ctx.stroke(); + verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); + + ctx.reset(); + ctx.fillStyle = '#0f0'; + ctx.fillRect(0, 0, 100, 50); + ctx.strokeStyle = '#f00'; + ctx.lineWidth = 50; + ctx.beginPath(); + ctx.quadraticCurveTo(100, 50, 200, 50); + ctx.stroke(); + //verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 95,45, 0,255,0,255)); + + ctx.reset(); + ctx.fillStyle = '#f00'; + ctx.fillRect(0, 0, 100, 50); + ctx.strokeStyle = '#0f0'; + ctx.lineWidth = 50; + ctx.beginPath(); + ctx.quadraticCurveTo(0, 25, 100, 25); + ctx.stroke(); + verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 5,45, 0,255,0,255)); + + ctx.reset(); + ctx.moveTo(0, 0); + ctx.lineTo(100, 0); + ctx.quadraticCurveTo(Infinity, 50, 0, 50); + ctx.quadraticCurveTo(-Infinity, 50, 0, 50); + ctx.quadraticCurveTo(NaN, 50, 0, 50); + ctx.quadraticCurveTo(0, Infinity, 0, 50); + ctx.quadraticCurveTo(0, -Infinity, 0, 50); + ctx.quadraticCurveTo(0, NaN, 0, 50); + ctx.quadraticCurveTo(0, 50, Infinity, 50); + ctx.quadraticCurveTo(0, 50, -Infinity, 50); + ctx.quadraticCurveTo(0, 50, NaN, 50); + ctx.quadraticCurveTo(0, 50, 0, Infinity); + ctx.quadraticCurveTo(0, 50, 0, -Infinity); + ctx.quadraticCurveTo(0, 50, 0, NaN); + ctx.quadraticCurveTo(Infinity, Infinity, 0, 50); + ctx.quadraticCurveTo(Infinity, Infinity, Infinity, 50); + ctx.quadraticCurveTo(Infinity, Infinity, Infinity, Infinity); + ctx.quadraticCurveTo(Infinity, Infinity, 0, Infinity); + ctx.quadraticCurveTo(Infinity, 50, Infinity, 50); + ctx.quadraticCurveTo(Infinity, 50, Infinity, Infinity); + ctx.quadraticCurveTo(Infinity, 50, 0, Infinity); + ctx.quadraticCurveTo(0, Infinity, Infinity, 50); + ctx.quadraticCurveTo(0, Infinity, Infinity, Infinity); + ctx.quadraticCurveTo(0, Infinity, 0, Infinity); + ctx.quadraticCurveTo(0, 50, Infinity, Infinity); + ctx.lineTo(100, 50); + ctx.lineTo(0, 50); + ctx.fillStyle = '#0f0'; + ctx.fill(); + verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 90,45, 0,255,0,255)); + + ctx.reset(); + ctx.fillStyle = '#f00'; + ctx.fillRect(0, 0, 100, 50); + ctx.scale(1000, 1000); + ctx.strokeStyle = '#0f0'; + ctx.lineWidth = 0.055; + ctx.beginPath(); + ctx.moveTo(-1, 1.05); + ctx.quadraticCurveTo(0, -1, 1.2, 1.05); + ctx.stroke(); + //verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 1,1, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 98,1, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 1,48, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 98,48, 0,255,0,255)); + + ctx.reset(); + ctx.fillStyle = '#f00'; + ctx.fillRect(0, 0, 100, 50); + ctx.strokeStyle = '#0f0'; + ctx.lineWidth = 55; + ctx.beginPath(); + ctx.moveTo(-1000, 1050); + ctx.quadraticCurveTo(0, -1000, 1200, 1050); + ctx.stroke(); + verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 1,1, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 98,1, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 1,48, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 98,48, 0,255,0,255)); + } + function test_rect() { + var ctx = canvas.getContext('2d'); + ctx.reset(); + + ctx.fillStyle = '#f00'; + ctx.fillRect(0, 0, 100, 50); + ctx.fillStyle = '#0f0'; + ctx.rect(0, 0, 100, 50); + ctx.fill(); + verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); + + ctx.reset(); + ctx.fillStyle = '#f00'; + ctx.fillRect(0, 0, 100, 50); + ctx.strokeStyle = '#0f0'; + ctx.lineWidth = 200; + ctx.lineJoin = 'miter'; + ctx.rect(100, 50, 100, 100); + ctx.stroke(); + verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); + + ctx.reset(); + ctx.fillStyle = '#f00'; + ctx.fillRect(0, 0, 100, 50); + ctx.strokeStyle = '#0f0'; + ctx.lineWidth = 100; + ctx.rect(200, 100, 400, 1000); + ctx.lineTo(-2000, -1000); + ctx.stroke(); + verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); + + ctx.reset(); + ctx.fillStyle = '#f00'; + ctx.fillRect(0, 0, 100, 50); + ctx.strokeStyle = '#0f0'; + ctx.lineWidth = 450; + ctx.lineCap = 'round'; + ctx.lineJoin = 'bevel'; + ctx.rect(150, 150, 2000, 2000); + ctx.lineTo(160, 160); + ctx.stroke(); + verify(Helper.comparePixel(ctx, 1,1, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 98,1, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 1,48, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 98,48, 0,255,0,255)); + + ctx.reset(); + ctx.fillStyle = '#f00'; + ctx.fillRect(0, 0, 100, 50); + ctx.beginPath(); + ctx.fillStyle = '#0f0'; + ctx.rect(0, 0, 50, 25); + ctx.rect(100, 0, -50, 25); + ctx.rect(0, 50, 50, -25); + ctx.rect(100, 50, -50, -25); + ctx.fill(); + verify(Helper.comparePixel(ctx, 25,12, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 75,12, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 25,37, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 75,37, 0,255,0,255)); + + ctx.reset(); + ctx.fillStyle = '#0f0'; + ctx.fillRect(0, 0, 100, 50); + ctx.beginPath(); + ctx.strokeStyle = '#f00'; + ctx.lineWidth = 50; + ctx.moveTo(-100, 25); + ctx.lineTo(-50, 25); + ctx.rect(200, 25, 1, 1); + ctx.stroke(); + verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); + + + ctx.reset(); + ctx.moveTo(0, 0); + ctx.lineTo(100, 0); + ctx.rect(Infinity, 50, 1, 1); + ctx.rect(-Infinity, 50, 1, 1); + ctx.rect(NaN, 50, 1, 1); + ctx.rect(0, Infinity, 1, 1); + ctx.rect(0, -Infinity, 1, 1); + ctx.rect(0, NaN, 1, 1); + ctx.rect(0, 50, Infinity, 1); + ctx.rect(0, 50, -Infinity, 1); + ctx.rect(0, 50, NaN, 1); + ctx.rect(0, 50, 1, Infinity); + ctx.rect(0, 50, 1, -Infinity); + ctx.rect(0, 50, 1, NaN); + ctx.rect(Infinity, Infinity, 1, 1); + ctx.rect(Infinity, Infinity, Infinity, 1); + ctx.rect(Infinity, Infinity, Infinity, Infinity); + ctx.rect(Infinity, Infinity, 1, Infinity); + ctx.rect(Infinity, 50, Infinity, 1); + ctx.rect(Infinity, 50, Infinity, Infinity); + ctx.rect(Infinity, 50, 1, Infinity); + ctx.rect(0, Infinity, Infinity, 1); + ctx.rect(0, Infinity, Infinity, Infinity); + ctx.rect(0, Infinity, 1, Infinity); + ctx.rect(0, 50, Infinity, Infinity); + ctx.lineTo(100, 50); + ctx.lineTo(0, 50); + ctx.fillStyle = '#0f0'; + ctx.fill(); + //verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); + //verify(Helper.comparePixel(ctx, 90,45, 0,255,0,255)); + + + ctx.reset(); + ctx.fillStyle = '#f00'; + ctx.fillRect(0, 0, 100, 50); + ctx.strokeStyle = '#0f0'; + ctx.lineWidth = 90; + ctx.beginPath(); + ctx.rect(45, 20, 10, 10); + ctx.stroke(); + verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); + + ctx.reset(); + ctx.fillStyle = '#0f0'; + ctx.fillRect(0, 0, 100, 50); + ctx.beginPath(); + ctx.fillStyle = '#f00'; + ctx.rect(0, 0, 50, 50); + ctx.rect(100, 50, -50, -50); + ctx.rect(0, 25, 100, -25); + ctx.rect(100, 25, -100, 25); + ctx.fill(); + verify(Helper.comparePixel(ctx, 25,12, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 75,12, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 25,37, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 75,37, 0,255,0,255)); + + ctx.reset(); + ctx.fillStyle = '#f00'; + ctx.fillRect(0, 0, 100, 50); + ctx.strokeStyle = '#0f0'; + ctx.lineWidth = 100; + ctx.beginPath(); + ctx.rect(0, 50, 100, 0); + ctx.stroke(); + verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); + + ctx.reset(); + ctx.fillStyle = '#f00'; + ctx.fillRect(0, 0, 100, 50); + ctx.strokeStyle = '#0f0'; + ctx.lineWidth = 100; + ctx.beginPath(); + ctx.rect(50, -100, 0, 250); + ctx.stroke(); + verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); + + ctx.reset(); + ctx.fillStyle = '#0f0'; + ctx.fillRect(0, 0, 100, 50); + ctx.strokeStyle = '#f00'; + ctx.lineWidth = 100; + ctx.beginPath(); + ctx.rect(50, 25, 0, 0); + ctx.stroke(); + verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); + + ctx.reset(); + ctx.fillStyle = '#f00'; + ctx.fillRect(0, 0, 100, 50); + ctx.strokeStyle = '#0f0'; + ctx.lineWidth = 50; + ctx.rect(100, 25, 0, 0); + ctx.lineTo(0, 25); + ctx.stroke(); + verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); + + ctx.reset(); + ctx.fillStyle = '#0f0'; + ctx.fillRect(0, 0, 100, 50); + ctx.strokeStyle = '#f00'; + ctx.lineWidth = 50; + ctx.moveTo(0, 0); + ctx.rect(100, 25, 0, 0); + ctx.stroke(); + verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); + + ctx.reset(); + ctx.fillStyle = '#0f0'; + ctx.fillRect(0, 0, 100, 50); + ctx.strokeStyle = '#f00'; + ctx.lineJoin = 'miter'; + ctx.miterLimit = 1.5; + ctx.lineWidth = 200; + ctx.beginPath(); + ctx.rect(100, 25, 1000, 0); + ctx.stroke(); + //verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); + } + + function test_clearRect() { + var ctx = canvas.getContext('2d'); + ctx.reset(); + ctx.fillStyle = '#0f0'; + ctx.beginPath(); + ctx.rect(0, 0, 100, 50); + ctx.clearRect(0, 0, 16, 16); + ctx.fill(); + verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); + } + function test_fillRect() { + var ctx = canvas.getContext('2d'); + ctx.reset(); + ctx.beginPath(); + ctx.rect(0, 0, 100, 50); + ctx.fillStyle = '#f00'; + ctx.fillRect(0, 0, 16, 16); + ctx.fillStyle = '#0f0'; + ctx.fill(); + verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); + } + + function test_strokeRect() { + var ctx = canvas.getContext('2d'); + ctx.reset(); + ctx.beginPath(); + ctx.rect(0, 0, 100, 50); + ctx.strokeStyle = '#f00'; + ctx.lineWidth = 5; + ctx.strokeRect(0, 0, 16, 16); + ctx.fillStyle = '#0f0'; + ctx.fill(); + + verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); + } + function test_transform() { + var ctx = canvas.getContext('2d'); + ctx.reset(); + ctx.fillStyle = '#f00'; + ctx.fillRect(0, 0, 100, 50); + + ctx.translate(-100, 0); + ctx.rect(100, 0, 100, 50); + ctx.translate(0, -100); + ctx.fillStyle = '#0f0'; + ctx.fill(); + + //verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); + + ctx.reset(); + ctx.fillStyle = '#f00'; + ctx.fillRect(0, 0, 100, 50); + ctx.fillStyle = '#0f0'; + ctx.moveTo(0, 0); + ctx.translate(100, 0); + ctx.lineTo(0, 0); + ctx.translate(0, 50); + ctx.lineTo(0, 0); + ctx.translate(-100, 0); + ctx.lineTo(0, 0); + ctx.translate(1000, 1000); + ctx.rotate(Math.PI/2); + ctx.scale(0.1, 0.1); + ctx.fill(); + //verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); + + ctx.reset(); + ctx.fillStyle = '#0f0'; + ctx.fillRect(0, 0, 100, 50); + + ctx.fillStyle = '#f00'; + ctx.translate(-100, 0); + ctx.rect(0, 0, 100, 50); + ctx.fill(); + ctx.translate(100, 0); + ctx.fill(); + + ctx.beginPath(); + ctx.strokeStyle = '#f00'; + ctx.lineWidth = 50; + ctx.translate(0, -50); + ctx.moveTo(0, 25); + ctx.lineTo(100, 25); + ctx.stroke(); + ctx.translate(0, 50); + ctx.stroke(); + verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); + } + } +} diff --git a/tests/auto/quick/qquickcanvasitem/data/tst_pattern.qml b/tests/auto/quick/qquickcanvasitem/data/tst_pattern.qml new file mode 100644 index 0000000000..dd5b6628e8 --- /dev/null +++ b/tests/auto/quick/qquickcanvasitem/data/tst_pattern.qml @@ -0,0 +1,34 @@ +import QtQuick 2.0 +import QtTest 1.0 +import "testhelper.js" as Helper +Canvas { + id:canvas; width:100;height:50; renderTarget: Canvas.Image + TestCase { + //TODO + name: "pattern"; when: windowShown + function test_basic() { + var ctx = canvas.getContext('2d'); + ctx.reset(); + } + function test_animated() { + var ctx = canvas.getContext('2d'); + ctx.reset(); + } + function test_image() { + var ctx = canvas.getContext('2d'); + ctx.reset(); + } + function test_modified() { + var ctx = canvas.getContext('2d'); + ctx.reset(); + } + function test_paint() { + var ctx = canvas.getContext('2d'); + ctx.reset(); + } + function test_repeat() { + var ctx = canvas.getContext('2d'); + ctx.reset(); + } + } +} diff --git a/tests/auto/quick/qquickcanvasitem/data/tst_pixel.qml b/tests/auto/quick/qquickcanvasitem/data/tst_pixel.qml new file mode 100644 index 0000000000..1a3793d7a3 --- /dev/null +++ b/tests/auto/quick/qquickcanvasitem/data/tst_pixel.qml @@ -0,0 +1,30 @@ +import QtQuick 2.0 +import QtTest 1.0 +import "testhelper.js" as Helper +Canvas { + id:canvas; width:100;height:50; renderTarget: Canvas.Image + TestCase { + //TODO + name: "pixel"; when: windowShown + function test_createImageData() { + var ctx = canvas.getContext('2d'); + ctx.reset(); + } + function test_getImageData() { + var ctx = canvas.getContext('2d'); + ctx.reset(); + } + function test_object() { + var ctx = canvas.getContext('2d'); + ctx.reset(); + } + function test_putImageData() { + var ctx = canvas.getContext('2d'); + ctx.reset(); + } + function test_filters() { + var ctx = canvas.getContext('2d'); + ctx.reset(); + } + } +} diff --git a/tests/auto/quick/qquickcanvasitem/data/tst_shadow.qml b/tests/auto/quick/qquickcanvasitem/data/tst_shadow.qml new file mode 100644 index 0000000000..4405ca6c0e --- /dev/null +++ b/tests/auto/quick/qquickcanvasitem/data/tst_shadow.qml @@ -0,0 +1,59 @@ +import QtQuick 2.0 +import QtTest 1.0 +import "testhelper.js" as Helper +Canvas { + id:canvas; width:100;height:50; renderTarget: Canvas.Image + TestCase { + //TODO + + name: "shadow"; when: windowShown + function test_basic() { + var ctx = canvas.getContext('2d'); + ctx.reset(); + } + function test_blur() { + var ctx = canvas.getContext('2d'); + ctx.reset(); + } + + function test_clip() { + var ctx = canvas.getContext('2d'); + ctx.reset(); + } + + function test_composite() { + var ctx = canvas.getContext('2d'); + ctx.reset(); + } + + function test_enable() { + var ctx = canvas.getContext('2d'); + ctx.reset(); + } + + function test_gradient() { + var ctx = canvas.getContext('2d'); + ctx.reset(); + } + function test_image() { + var ctx = canvas.getContext('2d'); + ctx.reset(); + } + function test_offset() { + var ctx = canvas.getContext('2d'); + ctx.reset(); + } + function test_pattern() { + var ctx = canvas.getContext('2d'); + ctx.reset(); + } + function test_stroke() { + var ctx = canvas.getContext('2d'); + ctx.reset(); + } + function test_tranform() { + var ctx = canvas.getContext('2d'); + ctx.reset(); + } + } +} diff --git a/tests/auto/quick/qquickcanvasitem/data/tst_state.qml b/tests/auto/quick/qquickcanvasitem/data/tst_state.qml new file mode 100644 index 0000000000..8042cf6a1d --- /dev/null +++ b/tests/auto/quick/qquickcanvasitem/data/tst_state.qml @@ -0,0 +1,390 @@ +import QtQuick 2.0 +import QtTest 1.0 +import "testhelper.js" as Helper +Canvas { + id:canvas; width:100;height:50; renderTarget: Canvas.Image + TestCase { + id:testCase + name: "state"; when: windowShown + function test_bitmap() { + var ctx = canvas.getContext('2d'); + ctx.reset(); + ctx.fillStyle = '#f00'; + ctx.fillRect(0, 0, 100, 50); + ctx.save(); + ctx.fillStyle = '#0f0'; + ctx.fillRect(0, 0, 100, 50); + ctx.restore(); + verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); + } + function test_clip() { + var ctx = canvas.getContext('2d'); + ctx.reset(); + + ctx.fillStyle = '#f00'; + ctx.fillRect(0, 0, 100, 50); + ctx.save(); + ctx.rect(0, 0, 1, 1); + ctx.clip(); + ctx.restore(); + ctx.fillStyle = '#0f0'; + ctx.fillRect(0, 0, 100, 50); + //verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); + + } + function test_fillStyle() { + var ctx = canvas.getContext('2d'); + ctx.reset(); + // Test that restore() undoes any modifications + var old = ctx.fillStyle; + ctx.save(); + ctx.fillStyle = "#ff0000"; + ctx.restore(); + compare(ctx.fillStyle, old); + + // Also test that save() doesn't modify the values + ctx.fillStyle = "#ff0000"; + old = ctx.fillStyle; + // we're not interested in failures caused by get(set(x)) != x (e.g. + // from rounding), so compare against 'old' instead of against "#ff0000" + ctx.save(); + compare(ctx.fillStyle, old); + ctx.restore(); + } + function test_font() { + var ctx = canvas.getContext('2d'); + ctx.reset(); + + // Test that restore() undoes any modifications + var old = ctx.font; + ctx.save(); + ctx.font = "25px serif"; + ctx.restore(); + compare(ctx.font, old); + + // Also test that save() doesn't modify the values + ctx.font = "25px serif"; + old = ctx.font; + // we're not interested in failures caused by get(set(x)) != x (e.g. + // from rounding), so compare against 'old' instead of against "25px serif" + ctx.save(); + compare(ctx.font, old); + ctx.restore(); + } + function test_globalAlpha() { + var ctx = canvas.getContext('2d'); + ctx.reset(); + + // Test that restore() undoes any modifications + var old = ctx.globalAlpha; + ctx.save(); + ctx.globalAlpha = 0.5; + ctx.restore(); + compare(ctx.globalAlpha, old); + + // Also test that save() doesn't modify the values + ctx.globalAlpha = 0.5; + old = ctx.globalAlpha; + // we're not interested in failures caused by get(set(x)) != x (e.g. + // from rounding), so compare against 'old' instead of against 0.5 + ctx.save(); + compare(ctx.globalAlpha, old); + ctx.restore(); + } + function test_globalCompositeOperation() { + var ctx = canvas.getContext('2d'); + ctx.reset(); + + // Test that restore() undoes any modifications + var old = ctx.globalCompositeOperation; + ctx.save(); + ctx.globalCompositeOperation = "copy"; + ctx.restore(); + compare(ctx.globalCompositeOperation, old); + + // Also test that save() doesn't modify the values + ctx.globalCompositeOperation = "copy"; + old = ctx.globalCompositeOperation; + // we're not interested in failures caused by get(set(x)) != x (e.g. + // from rounding), so compare against 'old' instead of against "copy" + ctx.save(); + compare(ctx.globalCompositeOperation, old); + ctx.restore(); + } + function test_lineCap() { + var ctx = canvas.getContext('2d'); + ctx.reset(); + + // Test that restore() undoes any modifications + var old = ctx.lineCap; + ctx.save(); + ctx.lineCap = "round"; + ctx.restore(); + compare(ctx.lineCap, old); + + // Also test that save() doesn't modify the values + ctx.lineCap = "round"; + old = ctx.lineCap; + // we're not interested in failures caused by get(set(x)) != x (e.g. + // from rounding), so compare against 'old' instead of against "round" + ctx.save(); + compare(ctx.lineCap, old); + ctx.restore(); + } + function test_lineJoin() { + var ctx = canvas.getContext('2d'); + ctx.reset(); + + // Test that restore() undoes any modifications + var old = ctx.lineJoin; + ctx.save(); + ctx.lineJoin = "round"; + ctx.restore(); + compare(ctx.lineJoin, old); + + // Also test that save() doesn't modify the values + ctx.lineJoin = "round"; + old = ctx.lineJoin; + // we're not interested in failures caused by get(set(x)) != x (e.g. + // from rounding), so compare against 'old' instead of against "round" + ctx.save(); + compare(ctx.lineJoin, old); + ctx.restore(); + } + function test_lineWidth() { + var ctx = canvas.getContext('2d'); + ctx.reset(); + + // Test that restore() undoes any modifications + var old = ctx.lineJoin; + ctx.save(); + ctx.lineJoin = "round"; + ctx.restore(); + compare(ctx.lineJoin, old, "ctx.lineJoin", "old"); + + // Also test that save() doesn't modify the values + ctx.lineJoin = "round"; + old = ctx.lineJoin; + // we're not interested in failures caused by get(set(x)) != x (e.g. + // from rounding), so compare against 'old' instead of against "round" + ctx.save(); + compare(ctx.lineJoin, old); + ctx.restore(); + } + function test_miterLimit() { + var ctx = canvas.getContext('2d'); + ctx.reset(); + + // Test that restore() undoes any modifications + var old = ctx.miterLimit; + ctx.save(); + ctx.miterLimit = 0.5; + ctx.restore(); + compare(ctx.miterLimit, old); + + // Also test that save() doesn't modify the values + ctx.miterLimit = 0.5; + old = ctx.miterLimit; + // we're not interested in failures caused by get(set(x)) != x (e.g. + // from rounding), so compare against 'old' instead of against 0.5 + ctx.save(); + compare(ctx.miterLimit, old); + ctx.restore(); + } + function test_path() { + var ctx = canvas.getContext('2d'); + ctx.reset(); + + ctx.fillStyle = '#f00'; + ctx.fillRect(0, 0, 100, 50); + ctx.save(); + ctx.rect(0, 0, 100, 50); + ctx.restore(); + ctx.fillStyle = '#0f0'; + ctx.fill(); + verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); + } + function test_shadow() { + var ctx = canvas.getContext('2d'); + ctx.reset(); + + // Test that restore() undoes any modifications + var old = ctx.shadowBlur; + ctx.save(); + ctx.shadowBlur = 5; + ctx.restore(); + compare(ctx.shadowBlur, old); + + // Also test that save() doesn't modify the values + ctx.shadowBlur = 5; + old = ctx.shadowBlur; + // we're not interested in failures caused by get(set(x)) != x (e.g. + // from rounding), so compare against 'old' instead of against 5 + ctx.save(); + compare(ctx.shadowBlur, old); + ctx.restore(); + + // Test that restore() undoes any modifications + var old = ctx.shadowColor; + ctx.save(); + ctx.shadowColor = "#ff0000"; + ctx.restore(); + compare(ctx.shadowColor, old); + + // Also test that save() doesn't modify the values + ctx.shadowColor = "#ff0000"; + old = ctx.shadowColor; + // we're not interested in failures caused by get(set(x)) != x (e.g. + // from rounding), so compare against 'old' instead of against "#ff0000" + ctx.save(); + compare(ctx.shadowColor, old); + ctx.restore(); + + // Test that restore() undoes any modifications + var old = ctx.shadowOffsetX; + ctx.save(); + ctx.shadowOffsetX = 5; + ctx.restore(); + compare(ctx.shadowOffsetX, old); + + // Also test that save() doesn't modify the values + ctx.shadowOffsetX = 5; + old = ctx.shadowOffsetX; + // we're not interested in failures caused by get(set(x)) != x (e.g. + // from rounding), so compare against 'old' instead of against 5 + ctx.save(); + compare(ctx.shadowOffsetX, old); + ctx.restore(); + + // Test that restore() undoes any modifications + var old = ctx.shadowOffsetY; + ctx.save(); + ctx.shadowOffsetY = 5; + ctx.restore(); + compare(ctx.shadowOffsetY, old); + + // Also test that save() doesn't modify the values + ctx.shadowOffsetY = 5; + old = ctx.shadowOffsetY; + // we're not interested in failures caused by get(set(x)) != x (e.g. + // from rounding), so compare against 'old' instead of against 5 + ctx.save(); + compare(ctx.shadowOffsetY, old); + ctx.restore(); + + } + function test_stack() { + var ctx = canvas.getContext('2d'); + ctx.reset(); + + ctx.lineWidth = 1; + ctx.save(); + ctx.lineWidth = 2; + ctx.save(); + ctx.lineWidth = 3; + compare(ctx.lineWidth, 3); + ctx.restore(); + compare(ctx.lineWidth, 2); + ctx.restore(); + compare(ctx.lineWidth, 1); + + var limit = 512; + for (var i = 1; i < limit; ++i) + { + ctx.save(); + ctx.lineWidth = i; + } + for (var i = limit-1; i > 0; --i) + { + testCase.compare(ctx.lineWidth, i); //strange javascript error here + ctx.restore(); + } + + for (var i = 0; i < 16; ++i) + ctx.restore(); + ctx.lineWidth = 0.5; + ctx.restore(); + compare(ctx.lineWidth, 0.5); + + } + function test_strokeStyle() { + var ctx = canvas.getContext('2d'); + ctx.reset(); + + // Test that restore() undoes any modifications + var old = ctx.strokeStyle; + ctx.save(); + ctx.strokeStyle = "#ff0000"; + ctx.restore(); + compare(ctx.strokeStyle, old); + + // Also test that save() doesn't modify the values + ctx.strokeStyle = "#ff0000"; + old = ctx.strokeStyle; + // we're not interested in failures caused by get(set(x)) != x (e.g. + // from rounding), so compare against 'old' instead of against "#ff0000" + ctx.save(); + compare(ctx.strokeStyle, old); + ctx.restore(); + + + } + + function test_text() { + var ctx = canvas.getContext('2d'); + ctx.reset(); + + // Test that restore() undoes any modifications + var old = ctx.textAlign; + ctx.save(); + ctx.textAlign = "center"; + ctx.restore(); + compare(ctx.textAlign, old); + + // Also test that save() doesn't modify the values + ctx.textAlign = "center"; + old = ctx.textAlign; + // we're not interested in failures caused by get(set(x)) != x (e.g. + // from rounding), so compare against 'old' instead of against "center" + ctx.save(); + compare(ctx.textAlign, old); + ctx.restore(); + + // Test that restore() undoes any modifications + var old = ctx.textBaseline; + ctx.save(); + ctx.textBaseline = "bottom"; + ctx.restore(); + compare(ctx.textBaseline, old); + + // Also test that save() doesn't modify the values + ctx.textBaseline = "bottom"; + old = ctx.textBaseline; + // we're not interested in failures caused by get(set(x)) != x (e.g. + // from rounding), so compare against 'old' instead of against "bottom" + ctx.save(); + compare(ctx.textBaseline, old); + ctx.restore(); + + + } + + function test_transform() { + var ctx = canvas.getContext('2d'); + ctx.reset(); + + ctx.fillStyle = '#0f0'; + ctx.fillRect(0, 0, 100, 50); + ctx.save(); + ctx.translate(200, 0); + ctx.restore(); + ctx.fillStyle = '#f00'; + ctx.fillRect(-200, 0, 100, 50); + verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); + + + } + + + } +} diff --git a/tests/auto/quick/qquickcanvasitem/data/tst_strokeStyle.qml b/tests/auto/quick/qquickcanvasitem/data/tst_strokeStyle.qml new file mode 100644 index 0000000000..6b42f8a770 --- /dev/null +++ b/tests/auto/quick/qquickcanvasitem/data/tst_strokeStyle.qml @@ -0,0 +1,48 @@ +import QtQuick 2.0 +import QtTest 1.0 +import "testhelper.js" as Helper + +Canvas { + id:canvas; width:100;height:50; renderTarget:Canvas.Image + TestCase { + name: "strokeStyle"; when: windowShown + function test_default() { + var ctx = canvas.getContext('2d'); + ctx.reset(); + compare(ctx.strokeStyle, "#000000") + ctx.clearRect(0, 0, 1, 1); + compare(ctx.strokeStyle, "#000000") + } + function test_saverestore() { + var ctx = canvas.getContext('2d'); + var old = ctx.strokeStyle; + ctx.save(); + ctx.strokeStyle = "#ffaaff"; + ctx.restore(); + compare(ctx.strokeStyle, old); + + ctx.strokeStyle = "#ffcc88"; + old = ctx.strokeStyle; + ctx.save(); + compare(ctx.strokeStyle, old); + ctx.restore(); + } + function test_namedColor() { + var ctx = canvas.getContext('2d'); + ctx.reset(); + ctx.strokeStyle = "red"; + ctx.strokeRect(0,0,1,1); + verify(Helper.comparePixel(ctx,0,0,255,0,0,255)); + + ctx.strokeStyle = "black"; + ctx.strokeRect(0,0,1,1); + verify(Helper.comparePixel(ctx,0,0,0,0,0,255)); + + ctx.strokeStyle = "white"; + ctx.strokeRect(0,0,1,1); + verify(Helper.comparePixel(ctx,0,0,255,255,255,255)); + } + + + } +} diff --git a/tests/auto/quick/qquickcanvasitem/data/tst_text.qml b/tests/auto/quick/qquickcanvasitem/data/tst_text.qml new file mode 100644 index 0000000000..baeb17c9fb --- /dev/null +++ b/tests/auto/quick/qquickcanvasitem/data/tst_text.qml @@ -0,0 +1,34 @@ +import QtQuick 2.0 +import QtTest 1.0 +import "testhelper.js" as Helper +Canvas { + id:canvas; width:100;height:50; renderTarget: Canvas.Image + TestCase { + //TODO + name: "text"; when: windowShown + function test_baseLine() { + var ctx = canvas.getContext('2d'); + ctx.reset(); + } + function test_align() { + var ctx = canvas.getContext('2d'); + ctx.reset(); + } + function test_stroke() { + var ctx = canvas.getContext('2d'); + ctx.reset(); + } + function test_fill() { + var ctx = canvas.getContext('2d'); + ctx.reset(); + } + function test_font() { + var ctx = canvas.getContext('2d'); + ctx.reset(); + } + function test_measure() { + var ctx = canvas.getContext('2d'); + ctx.reset(); + } + } +} diff --git a/tests/auto/quick/qquickcanvasitem/data/tst_transform.qml b/tests/auto/quick/qquickcanvasitem/data/tst_transform.qml new file mode 100644 index 0000000000..834a22f549 --- /dev/null +++ b/tests/auto/quick/qquickcanvasitem/data/tst_transform.qml @@ -0,0 +1,487 @@ +import QtQuick 2.0 +import QtTest 1.0 +import "testhelper.js" as Helper +Canvas { + id:canvas; width:100;height:50; renderTarget: Canvas.Image + TestCase { + name: "transform"; when: windowShown + function test_order() { + var ctx = canvas.getContext('2d'); + ctx.reset(); + ctx.fillStyle = '#f00'; + ctx.fillRect(0, 0, 100, 50); + + ctx.scale(2, 1); + ctx.rotate(Math.PI / 2); + ctx.fillStyle = '#0f0'; + ctx.fillRect(0, -50, 50, 50); + verify(Helper.comparePixel(ctx, 75,25, 0,255,0,255)); + } + function test_rotate() { + var ctx = canvas.getContext('2d'); + ctx.reset(); + ctx.fillStyle = '#f00'; + ctx.fillRect(0, 0, 100, 50); + + ctx.rotate(Math.PI / 2); + ctx.fillStyle = '#0f0'; + ctx.fillRect(0, -100, 50, 100); + verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); + ctx.reset(); + + ctx.fillStyle = '#f00'; + ctx.fillRect(0, 0, 100, 50); + + ctx.translate(100, 10); + ctx.rotate(Infinity); + ctx.rotate(-Infinity); + ctx.rotate(NaN); + + ctx.fillStyle = '#0f0'; + ctx.fillRect(-100, -10, 100, 50); + + verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); + ctx.reset(); + + ctx.fillStyle = '#f00'; + ctx.fillRect(0, 0, 100, 50); + + ctx.rotate(Math.PI); // should fail obviously if this is 3.1 degrees + ctx.fillStyle = '#0f0'; + ctx.fillRect(-100, -50, 100, 50); + verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); + ctx.reset(); + + ctx.fillStyle = '#f00'; + ctx.fillRect(0, 0, 100, 50); + + ctx.rotate(Math.PI * (1 + 4096)); // == pi (mod 2*pi) + // We need about pi +/- 0.001 in order to get correct-looking results + // 32-bit floats can store pi*4097 with precision 2^-10, so that should + // be safe enough on reasonable implementations + ctx.fillStyle = '#0f0'; + ctx.fillRect(-100, -50, 100, 50); + verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 98,2, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 98,47, 0,255,0,255)); + ctx.reset(); + + ctx.fillStyle = '#f00'; + ctx.fillRect(0, 0, 100, 50); + + ctx.rotate(-Math.PI * (1 + 4096)); + ctx.fillStyle = '#0f0'; + ctx.fillRect(-100, -50, 100, 50); + verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 98,2, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 98,47, 0,255,0,255)); + ctx.reset(); + + ctx.fillStyle = '#f00'; + ctx.fillRect(0, 0, 100, 50); + + ctx.rotate(0); + ctx.fillStyle = '#0f0'; + ctx.fillRect(0, 0, 100, 50); + verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); + + + } + function test_scale() { + var ctx = canvas.getContext('2d'); + ctx.reset(); + + ctx.fillStyle = '#f00'; + ctx.fillRect(0, 0, 100, 50); + + ctx.scale(2, 4); + ctx.fillStyle = '#0f0'; + ctx.fillRect(0, 0, 50, 12.5); + verify(Helper.comparePixel(ctx, 90,40, 0,255,0,255)); + ctx.reset(); + + ctx.fillStyle = '#f00'; + ctx.fillRect(0, 0, 100, 50); + + ctx.scale(1e5, 1e5); + ctx.fillStyle = '#0f0'; + ctx.fillRect(0, 0, 1, 1); + verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); + ctx.reset(); + + ctx.fillStyle = '#f00'; + ctx.fillRect(0, 0, 100, 50); + + ctx.scale(Math.sqrt(2), Math.sqrt(2)); + ctx.scale(Math.sqrt(2), Math.sqrt(2)); + ctx.fillStyle = '#0f0'; + ctx.fillRect(0, 0, 50, 25); + verify(Helper.comparePixel(ctx, 90,40, 0,255,0,255)); + ctx.reset(); + + ctx.fillStyle = '#f00'; + ctx.fillRect(0, 0, 100, 50); + + ctx.save(); + ctx.scale(-1, 1); + ctx.fillStyle = '#0f0'; + ctx.fillRect(-50, 0, 50, 50); + ctx.restore(); + + ctx.save(); + ctx.scale(1, -1); + ctx.fillStyle = '#0f0'; + ctx.fillRect(50, -50, 50, 50); + ctx.restore(); + verify(Helper.comparePixel(ctx, 25,25, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 75,25, 0,255,0,255)); + ctx.reset(); + + ctx.fillStyle = '#f00'; + ctx.fillRect(0, 0, 100, 50); + + ctx.translate(100, 10); + ctx.scale(Infinity, 0.1); + ctx.scale(-Infinity, 0.1); + ctx.scale(NaN, 0.1); + ctx.scale(0.1, Infinity); + ctx.scale(0.1, -Infinity); + ctx.scale(0.1, NaN); + ctx.scale(Infinity, Infinity); + + ctx.fillStyle = '#0f0'; + ctx.fillRect(-100, -10, 100, 50); + + verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); + ctx.reset(); + + ctx.fillStyle = '#0f0'; + ctx.fillRect(0, 0, 100, 50); + + ctx.save(); + ctx.translate(50, 0); + ctx.scale(0, 1); + ctx.fillStyle = '#f00'; + ctx.fillRect(0, 0, 100, 50); + ctx.restore(); + + ctx.save(); + ctx.translate(0, 25); + ctx.scale(1, 0); + ctx.fillStyle = '#f00'; + ctx.fillRect(0, 0, 100, 50); + ctx.restore(); + + // Firefox has a bug where it renders the canvas as empty and toDataURL throws an exception + canvas.toDataURL(); + + verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); + } + function test_setTransform() { + var ctx = canvas.getContext('2d'); + ctx.reset(); + ctx.fillStyle = '#f00'; + ctx.fillRect(0, 0, 100, 50); + + ctx.setTransform(1/2,0, 0,1/2, 0,0); + ctx.setTransform(2,0, 0,2, 0,0); + ctx.fillStyle = '#0f0'; + ctx.fillRect(0, 0, 50, 25); + verify(Helper.comparePixel(ctx, 75,35, 0,255,0,255)); + ctx.reset(); + + ctx.fillStyle = '#f00'; + ctx.fillRect(0, 0, 100, 50); + + ctx.translate(100, 10); + ctx.setTransform(Infinity, 0, 0, 0, 0, 0); + ctx.setTransform(-Infinity, 0, 0, 0, 0, 0); + ctx.setTransform(NaN, 0, 0, 0, 0, 0); + ctx.setTransform(0, Infinity, 0, 0, 0, 0); + ctx.setTransform(0, -Infinity, 0, 0, 0, 0); + ctx.setTransform(0, NaN, 0, 0, 0, 0); + ctx.setTransform(0, 0, Infinity, 0, 0, 0); + ctx.setTransform(0, 0, -Infinity, 0, 0, 0); + ctx.setTransform(0, 0, NaN, 0, 0, 0); + ctx.setTransform(0, 0, 0, Infinity, 0, 0); + ctx.setTransform(0, 0, 0, -Infinity, 0, 0); + ctx.setTransform(0, 0, 0, NaN, 0, 0); + ctx.setTransform(0, 0, 0, 0, Infinity, 0); + ctx.setTransform(0, 0, 0, 0, -Infinity, 0); + ctx.setTransform(0, 0, 0, 0, NaN, 0); + ctx.setTransform(0, 0, 0, 0, 0, Infinity); + ctx.setTransform(0, 0, 0, 0, 0, -Infinity); + ctx.setTransform(0, 0, 0, 0, 0, NaN); + ctx.setTransform(Infinity, Infinity, 0, 0, 0, 0); + ctx.setTransform(Infinity, Infinity, Infinity, 0, 0, 0); + ctx.setTransform(Infinity, Infinity, Infinity, Infinity, 0, 0); + ctx.setTransform(Infinity, Infinity, Infinity, Infinity, Infinity, 0); + ctx.setTransform(Infinity, Infinity, Infinity, Infinity, Infinity, Infinity); + ctx.setTransform(Infinity, Infinity, Infinity, Infinity, 0, Infinity); + ctx.setTransform(Infinity, Infinity, Infinity, 0, Infinity, 0); + ctx.setTransform(Infinity, Infinity, Infinity, 0, Infinity, Infinity); + ctx.setTransform(Infinity, Infinity, Infinity, 0, 0, Infinity); + ctx.setTransform(Infinity, Infinity, 0, Infinity, 0, 0); + ctx.setTransform(Infinity, Infinity, 0, Infinity, Infinity, 0); + ctx.setTransform(Infinity, Infinity, 0, Infinity, Infinity, Infinity); + ctx.setTransform(Infinity, Infinity, 0, Infinity, 0, Infinity); + ctx.setTransform(Infinity, Infinity, 0, 0, Infinity, 0); + ctx.setTransform(Infinity, Infinity, 0, 0, Infinity, Infinity); + ctx.setTransform(Infinity, Infinity, 0, 0, 0, Infinity); + ctx.setTransform(Infinity, 0, Infinity, 0, 0, 0); + ctx.setTransform(Infinity, 0, Infinity, Infinity, 0, 0); + ctx.setTransform(Infinity, 0, Infinity, Infinity, Infinity, 0); + ctx.setTransform(Infinity, 0, Infinity, Infinity, Infinity, Infinity); + ctx.setTransform(Infinity, 0, Infinity, Infinity, 0, Infinity); + ctx.setTransform(Infinity, 0, Infinity, 0, Infinity, 0); + ctx.setTransform(Infinity, 0, Infinity, 0, Infinity, Infinity); + ctx.setTransform(Infinity, 0, Infinity, 0, 0, Infinity); + ctx.setTransform(Infinity, 0, 0, Infinity, 0, 0); + ctx.setTransform(Infinity, 0, 0, Infinity, Infinity, 0); + ctx.setTransform(Infinity, 0, 0, Infinity, Infinity, Infinity); + ctx.setTransform(Infinity, 0, 0, Infinity, 0, Infinity); + ctx.setTransform(Infinity, 0, 0, 0, Infinity, 0); + ctx.setTransform(Infinity, 0, 0, 0, Infinity, Infinity); + ctx.setTransform(Infinity, 0, 0, 0, 0, Infinity); + ctx.setTransform(0, Infinity, Infinity, 0, 0, 0); + ctx.setTransform(0, Infinity, Infinity, Infinity, 0, 0); + ctx.setTransform(0, Infinity, Infinity, Infinity, Infinity, 0); + ctx.setTransform(0, Infinity, Infinity, Infinity, Infinity, Infinity); + ctx.setTransform(0, Infinity, Infinity, Infinity, 0, Infinity); + ctx.setTransform(0, Infinity, Infinity, 0, Infinity, 0); + ctx.setTransform(0, Infinity, Infinity, 0, Infinity, Infinity); + ctx.setTransform(0, Infinity, Infinity, 0, 0, Infinity); + ctx.setTransform(0, Infinity, 0, Infinity, 0, 0); + ctx.setTransform(0, Infinity, 0, Infinity, Infinity, 0); + ctx.setTransform(0, Infinity, 0, Infinity, Infinity, Infinity); + ctx.setTransform(0, Infinity, 0, Infinity, 0, Infinity); + ctx.setTransform(0, Infinity, 0, 0, Infinity, 0); + ctx.setTransform(0, Infinity, 0, 0, Infinity, Infinity); + ctx.setTransform(0, Infinity, 0, 0, 0, Infinity); + ctx.setTransform(0, 0, Infinity, Infinity, 0, 0); + ctx.setTransform(0, 0, Infinity, Infinity, Infinity, 0); + ctx.setTransform(0, 0, Infinity, Infinity, Infinity, Infinity); + ctx.setTransform(0, 0, Infinity, Infinity, 0, Infinity); + ctx.setTransform(0, 0, Infinity, 0, Infinity, 0); + ctx.setTransform(0, 0, Infinity, 0, Infinity, Infinity); + ctx.setTransform(0, 0, Infinity, 0, 0, Infinity); + ctx.setTransform(0, 0, 0, Infinity, Infinity, 0); + ctx.setTransform(0, 0, 0, Infinity, Infinity, Infinity); + ctx.setTransform(0, 0, 0, Infinity, 0, Infinity); + ctx.setTransform(0, 0, 0, 0, Infinity, Infinity); + + ctx.fillStyle = '#0f0'; + ctx.fillRect(-100, -10, 100, 50); + + verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); + ctx.reset(); + + // Create green with a red square ring inside it + ctx.fillStyle = '#0f0'; + ctx.fillRect(0, 0, 100, 50); + ctx.fillStyle = '#f00'; + ctx.fillRect(20, 10, 60, 30); + ctx.fillStyle = '#0f0'; + ctx.fillRect(40, 20, 20, 10); + + // Draw a skewed shape to fill that gap, to make sure it is aligned correctly + ctx.setTransform(1,4, 2,3, 5,6); + // Post-transform coordinates: + // [[20,10],[80,10],[80,40],[20,40],[20,10],[40,20],[40,30],[60,30],[60,20],[40,20],[20,10]]; + // Hence pre-transform coordinates: + var pts=[[-7.4,11.2],[-43.4,59.2],[-31.4,53.2],[4.6,5.2],[-7.4,11.2], + [-15.4,25.2],[-11.4,23.2],[-23.4,39.2],[-27.4,41.2],[-15.4,25.2], + [-7.4,11.2]]; + ctx.beginPath(); + ctx.moveTo(pts[0][0], pts[0][1]); + for (var i = 0; i < pts.length; ++i) + ctx.lineTo(pts[i][0], pts[i][1]); + ctx.fill(); + /* + //FIXME: + verify(Helper.comparePixel(ctx, 21,11, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 79,11, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 21,39, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 79,39, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 39,19, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 61,19, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 39,31, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 61,31, 0,255,0,255)); + */ + ctx.reset(); + + ctx.fillStyle = '#f00'; + ctx.fillRect(0, 0, 100, 50); + + ctx.transform(1,0, 0,1, 0,0); + ctx.fillStyle = '#0f0'; + ctx.fillRect(0, 0, 100, 50); + verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); + + } + function test_transform() { + var ctx = canvas.getContext('2d'); + ctx.reset(); + ctx.fillStyle = '#f00'; + ctx.fillRect(0, 0, 100, 50); + + ctx.transform(1,2, 3,4, 5,6); + ctx.transform(-2,1, 3/2,-1/2, 1,-2); + ctx.fillStyle = '#0f0'; + ctx.fillRect(0, 0, 100, 50); + verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); + ctx.reset(); + + ctx.fillStyle = '#f00'; + ctx.fillRect(0, 0, 100, 50); + + ctx.translate(100, 10); + ctx.transform(Infinity, 0, 0, 0, 0, 0); + ctx.transform(-Infinity, 0, 0, 0, 0, 0); + ctx.transform(NaN, 0, 0, 0, 0, 0); + ctx.transform(0, Infinity, 0, 0, 0, 0); + ctx.transform(0, -Infinity, 0, 0, 0, 0); + ctx.transform(0, NaN, 0, 0, 0, 0); + ctx.transform(0, 0, Infinity, 0, 0, 0); + ctx.transform(0, 0, -Infinity, 0, 0, 0); + ctx.transform(0, 0, NaN, 0, 0, 0); + ctx.transform(0, 0, 0, Infinity, 0, 0); + ctx.transform(0, 0, 0, -Infinity, 0, 0); + ctx.transform(0, 0, 0, NaN, 0, 0); + ctx.transform(0, 0, 0, 0, Infinity, 0); + ctx.transform(0, 0, 0, 0, -Infinity, 0); + ctx.transform(0, 0, 0, 0, NaN, 0); + ctx.transform(0, 0, 0, 0, 0, Infinity); + ctx.transform(0, 0, 0, 0, 0, -Infinity); + ctx.transform(0, 0, 0, 0, 0, NaN); + ctx.transform(Infinity, Infinity, 0, 0, 0, 0); + ctx.transform(Infinity, Infinity, Infinity, 0, 0, 0); + ctx.transform(Infinity, Infinity, Infinity, Infinity, 0, 0); + ctx.transform(Infinity, Infinity, Infinity, Infinity, Infinity, 0); + ctx.transform(Infinity, Infinity, Infinity, Infinity, Infinity, Infinity); + ctx.transform(Infinity, Infinity, Infinity, Infinity, 0, Infinity); + ctx.transform(Infinity, Infinity, Infinity, 0, Infinity, 0); + ctx.transform(Infinity, Infinity, Infinity, 0, Infinity, Infinity); + ctx.transform(Infinity, Infinity, Infinity, 0, 0, Infinity); + ctx.transform(Infinity, Infinity, 0, Infinity, 0, 0); + ctx.transform(Infinity, Infinity, 0, Infinity, Infinity, 0); + ctx.transform(Infinity, Infinity, 0, Infinity, Infinity, Infinity); + ctx.transform(Infinity, Infinity, 0, Infinity, 0, Infinity); + ctx.transform(Infinity, Infinity, 0, 0, Infinity, 0); + ctx.transform(Infinity, Infinity, 0, 0, Infinity, Infinity); + ctx.transform(Infinity, Infinity, 0, 0, 0, Infinity); + ctx.transform(Infinity, 0, Infinity, 0, 0, 0); + ctx.transform(Infinity, 0, Infinity, Infinity, 0, 0); + ctx.transform(Infinity, 0, Infinity, Infinity, Infinity, 0); + ctx.transform(Infinity, 0, Infinity, Infinity, Infinity, Infinity); + ctx.transform(Infinity, 0, Infinity, Infinity, 0, Infinity); + ctx.transform(Infinity, 0, Infinity, 0, Infinity, 0); + ctx.transform(Infinity, 0, Infinity, 0, Infinity, 0); + ctx.transform(Infinity, 0, Infinity, 0, Infinity, Infinity); + ctx.transform(Infinity, 0, Infinity, 0, 0, Infinity); + ctx.transform(Infinity, 0, 0, Infinity, 0, 0); + ctx.transform(Infinity, 0, 0, Infinity, Infinity, 0); + ctx.transform(Infinity, 0, 0, Infinity, Infinity, Infinity); + ctx.transform(Infinity, 0, 0, Infinity, 0, Infinity); + ctx.transform(Infinity, 0, 0, 0, Infinity, 0); + ctx.transform(Infinity, 0, 0, 0, Infinity, Infinity); + ctx.transform(Infinity, 0, 0, 0, 0, Infinity); + ctx.transform(0, Infinity, Infinity, 0, 0, 0); + ctx.transform(0, Infinity, Infinity, Infinity, 0, 0); + ctx.transform(0, Infinity, Infinity, Infinity, Infinity, 0); + ctx.transform(0, Infinity, Infinity, Infinity, Infinity, Infinity); + ctx.transform(0, Infinity, Infinity, Infinity, 0, Infinity); + ctx.transform(0, Infinity, Infinity, 0, Infinity, 0); + ctx.transform(0, Infinity, Infinity, 0, Infinity, Infinity); + ctx.transform(0, Infinity, Infinity, 0, 0, Infinity); + ctx.transform(0, Infinity, 0, Infinity, 0, 0); + ctx.transform(0, Infinity, 0, Infinity, Infinity, 0); + ctx.transform(0, Infinity, 0, Infinity, Infinity, Infinity); + ctx.transform(0, Infinity, 0, Infinity, 0, Infinity); + ctx.transform(0, Infinity, 0, 0, Infinity, 0); + ctx.transform(0, Infinity, 0, 0, Infinity, Infinity); + ctx.transform(0, Infinity, 0, 0, 0, Infinity); + ctx.transform(0, 0, Infinity, Infinity, 0, 0); + ctx.transform(0, 0, Infinity, Infinity, Infinity, 0); + ctx.transform(0, 0, Infinity, Infinity, Infinity, Infinity); + ctx.transform(0, 0, Infinity, Infinity, 0, Infinity); + ctx.transform(0, 0, Infinity, 0, Infinity, 0); + ctx.transform(0, 0, Infinity, 0, Infinity, Infinity); + ctx.transform(0, 0, Infinity, 0, 0, Infinity); + ctx.transform(0, 0, 0, Infinity, Infinity, 0); + ctx.transform(0, 0, 0, Infinity, Infinity, Infinity); + ctx.transform(0, 0, 0, Infinity, 0, Infinity); + ctx.transform(0, 0, 0, 0, Infinity, Infinity); + + ctx.fillStyle = '#0f0'; + ctx.fillRect(-100, -10, 100, 50); + + verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); + ctx.reset(); + + // Create green with a red square ring inside it + ctx.fillStyle = '#0f0'; + ctx.fillRect(0, 0, 100, 50); + ctx.fillStyle = '#f00'; + ctx.fillRect(20, 10, 60, 30); + ctx.fillStyle = '#0f0'; + ctx.fillRect(40, 20, 20, 10); + + // Draw a skewed shape to fill that gap, to make sure it is aligned correctly + ctx.transform(1,4, 2,3, 5,6); + // Post-transform coordinates: + // [[20,10],[80,10],[80,40],[20,40],[20,10],[40,20],[40,30],[60,30],[60,20],[40,20],[20,10]]; + // Hence pre-transform coordinates: + var pts=[[-7.4,11.2],[-43.4,59.2],[-31.4,53.2],[4.6,5.2],[-7.4,11.2], + [-15.4,25.2],[-11.4,23.2],[-23.4,39.2],[-27.4,41.2],[-15.4,25.2], + [-7.4,11.2]]; + ctx.beginPath(); + ctx.moveTo(pts[0][0], pts[0][1]); + for (var i = 0; i < pts.length; ++i) + ctx.lineTo(pts[i][0], pts[i][1]); + ctx.fill(); + /* + //FIXME: + verify(Helper.comparePixel(ctx, 21,11, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 79,11, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 21,39, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 79,39, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 39,19, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 61,19, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 39,31, 0,255,0,255)); + verify(Helper.comparePixel(ctx, 61,31, 0,255,0,255)); + */ + } + function test_translate() { + var ctx = canvas.getContext('2d'); + ctx.reset(); + ctx.fillStyle = '#f00'; + ctx.fillRect(0, 0, 100, 50); + + ctx.translate(100, 50); + ctx.fillStyle = '#0f0'; + ctx.fillRect(-100, -50, 100, 50); + verify(Helper.comparePixel(ctx, 90,40, 0,255,0,255)); + ctx.reset(); + + ctx.fillStyle = '#f00'; + ctx.fillRect(0, 0, 100, 50); + + ctx.translate(100, 10); + ctx.translate(Infinity, 0.1); + ctx.translate(-Infinity, 0.1); + ctx.translate(NaN, 0.1); + ctx.translate(0.1, Infinity); + ctx.translate(0.1, -Infinity); + ctx.translate(0.1, NaN); + ctx.translate(Infinity, Infinity); + + ctx.fillStyle = '#0f0'; + ctx.fillRect(-100, -10, 100, 50); + + verify(Helper.comparePixel(ctx, 50,25, 0,255,0,255)); + + + } + } +} diff --git a/tests/auto/quick/qquickcanvasitem/data/yellow.png b/tests/auto/quick/qquickcanvasitem/data/yellow.png new file mode 100644 index 0000000000..51e8aaf38c Binary files /dev/null and b/tests/auto/quick/qquickcanvasitem/data/yellow.png differ diff --git a/tests/auto/quick/qquickcanvasitem/data/yellow75.png b/tests/auto/quick/qquickcanvasitem/data/yellow75.png new file mode 100644 index 0000000000..2bb82c9834 Binary files /dev/null and b/tests/auto/quick/qquickcanvasitem/data/yellow75.png differ diff --git a/tests/auto/quick/qquickcanvasitem/qquickcanvasitem.pro b/tests/auto/quick/qquickcanvasitem/qquickcanvasitem.pro new file mode 100644 index 0000000000..ccf894715f --- /dev/null +++ b/tests/auto/quick/qquickcanvasitem/qquickcanvasitem.pro @@ -0,0 +1,34 @@ +QT += core-private gui-private qml-private widgets +TEMPLATE=app +TARGET=tst_qquickcanvasitem + +CONFIG += warn_on qmltestcase +SOURCES += tst_qquickcanvasitem.cpp + +importFiles.files = data +importFiles.path = . +DEPLOYMENT += importFiles + +OTHER_FILES += \ + data/testhelper.js \ + data/tst_transform.qml \ + data/tst_text.qml \ + data/tst_strokeStyle.qml \ + data/tst_state.qml \ + data/tst_shadow.qml \ + data/tst_pattern.qml \ + data/tst_path.qml \ + data/tst_line.qml \ + data/tst_fillStyle.qml \ + data/tst_fillrect.qml \ + data/tst_drawimage.qml \ + data/tst_composite.qml \ + data/tst_canvas.qml \ + data/tst_pixel.qml \ + data/tst_gradient.qml \ + data/tst_arcto.qml \ + data/tst_arc.qml \ + data/tst_context.qml + + + diff --git a/tests/auto/quick/qquickcanvasitem/tst_qquickcanvasitem.cpp b/tests/auto/quick/qquickcanvasitem/tst_qquickcanvasitem.cpp new file mode 100644 index 0000000000..468c7cb9db --- /dev/null +++ b/tests/auto/quick/qquickcanvasitem/tst_qquickcanvasitem.cpp @@ -0,0 +1,42 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include +QUICK_TEST_MAIN(qquickcanvasitem) diff --git a/tests/auto/quick/qquickdrag/qquickdrag.pro b/tests/auto/quick/qquickdrag/qquickdrag.pro new file mode 100644 index 0000000000..820661ac23 --- /dev/null +++ b/tests/auto/quick/qquickdrag/qquickdrag.pro @@ -0,0 +1,9 @@ +TARGET = tst_qquickdrag +CONFIG += testcase +macx:CONFIG -= app_bundle + +SOURCES += tst_qquickdrag.cpp + +CONFIG += parallel_test + +QT += core-private gui-private qml-private quick-private network testlib diff --git a/tests/auto/quick/qquickdrag/tst_qquickdrag.cpp b/tests/auto/quick/qquickdrag/tst_qquickdrag.cpp new file mode 100644 index 0000000000..37fb6d2d1f --- /dev/null +++ b/tests/auto/quick/qquickdrag/tst_qquickdrag.cpp @@ -0,0 +1,1034 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include +#include +#include +#include +#include +#include + +template static T evaluate(QObject *scope, const QString &expression) +{ + QQmlExpression expr(qmlContext(scope), scope, expression); + QVariant result = expr.evaluate(); + if (expr.hasError()) + qWarning() << expr.error().toString(); + return result.value(); +} + +template <> void evaluate(QObject *scope, const QString &expression) +{ + QQmlExpression expr(qmlContext(scope), scope, expression); + expr.evaluate(); + if (expr.hasError()) + qWarning() << expr.error().toString(); +} + +Q_DECLARE_METATYPE(Qt::DropActions) + +class TestDropTarget : public QQuickItem +{ + Q_OBJECT +public: + TestDropTarget(QQuickItem *parent = 0) + : QQuickItem(parent) + , enterEvents(0) + , moveEvents(0) + , leaveEvents(0) + , dropEvents(0) + , acceptAction(Qt::MoveAction) + , defaultAction(Qt::IgnoreAction) + , proposedAction(Qt::IgnoreAction) + , accept(true) + { + setFlags(ItemAcceptsDrops); + } + + void reset() + { + enterEvents = 0; + moveEvents = 0; + leaveEvents = 0; + dropEvents = 0; + defaultAction = Qt::IgnoreAction; + proposedAction = Qt::IgnoreAction; + supportedActions = Qt::IgnoreAction; + } + + void dragEnterEvent(QDragEnterEvent *event) + { + ++enterEvents; + position = event->pos(); + defaultAction = event->dropAction(); + proposedAction = event->proposedAction(); + supportedActions = event->possibleActions(); + event->setAccepted(accept); + } + + void dragMoveEvent(QDragMoveEvent *event) + { + ++moveEvents; + position = event->pos(); + defaultAction = event->dropAction(); + proposedAction = event->proposedAction(); + supportedActions = event->possibleActions(); + event->setAccepted(accept); + } + + void dragLeaveEvent(QDragLeaveEvent *event) + { + ++leaveEvents; + event->setAccepted(accept); + } + + void dropEvent(QDropEvent *event) + { + ++dropEvents; + position = event->pos(); + defaultAction = event->dropAction(); + proposedAction = event->proposedAction(); + supportedActions = event->possibleActions(); + event->setDropAction(acceptAction); + event->setAccepted(accept); + } + + int enterEvents; + int moveEvents; + int leaveEvents; + int dropEvents; + Qt::DropAction acceptAction; + Qt::DropAction defaultAction; + Qt::DropAction proposedAction; + Qt::DropActions supportedActions; + QPointF position; + bool accept; +}; + +class tst_QQuickDrag: public QObject +{ + Q_OBJECT +private slots: + void initTestCase(); + void cleanupTestCase(); + + void active(); + void drop(); + void move(); + void hotSpot(); + void supportedActions(); + void proposedAction(); + void keys(); + void source(); + void recursion_data(); + void recursion(); + +private: + QQmlEngine engine; +}; + +void tst_QQuickDrag::initTestCase() +{ + +} + +void tst_QQuickDrag::cleanupTestCase() +{ + +} + +void tst_QQuickDrag::active() +{ + QQuickCanvas canvas; + TestDropTarget dropTarget(canvas.rootItem()); + dropTarget.setSize(QSizeF(100, 100)); + QQmlComponent component(&engine); + component.setData( + "import QtQuick 2.0\n" + "Item {\n" + "property bool dragActive: Drag.active\n" + "property Item dragTarget: Drag.target\n" + "x: 50; y: 50\n" + "width: 10; height: 10\n" + "}", QUrl()); + QScopedPointer object(component.create()); + QQuickItem *item = qobject_cast(object.data()); + QVERIFY(item); + item->setParentItem(&dropTarget); + + QCOMPARE(evaluate(item, "Drag.active"), false); + QCOMPARE(evaluate(item, "dragActive"), false); + + evaluate(item, "Drag.active = true"); + QCOMPARE(evaluate(item, "Drag.active"), true); + QCOMPARE(evaluate(item, "dragActive"), true); + QCOMPARE(evaluate(item, "Drag.target"), static_cast(&dropTarget)); + QCOMPARE(evaluate(item, "dragTarget"), static_cast(&dropTarget)); + QCOMPARE(dropTarget.enterEvents, 1); QCOMPARE(dropTarget.leaveEvents, 0); + + dropTarget.reset(); + evaluate(item, "Drag.active = false"); + QCOMPARE(evaluate(item, "Drag.active"), false); + QCOMPARE(evaluate(item, "dragActive"), false); + QCOMPARE(evaluate(item, "Drag.target"), static_cast(0)); + QCOMPARE(evaluate(item, "dragTarget"), static_cast(0)); + QCOMPARE(dropTarget.enterEvents, 0); QCOMPARE(dropTarget.leaveEvents, 1); + + dropTarget.reset(); + evaluate(item, "Drag.cancel()"); + QCOMPARE(evaluate(item, "Drag.active"), false); + QCOMPARE(evaluate(item, "dragActive"), false); + QCOMPARE(evaluate(item, "Drag.target"), static_cast(0)); + QCOMPARE(evaluate(item, "dragTarget"), static_cast(0)); + QCOMPARE(dropTarget.enterEvents, 0); QCOMPARE(dropTarget.leaveEvents, 0); + + dropTarget.reset(); + evaluate(item, "Drag.start()"); + QCOMPARE(evaluate(item, "Drag.active"), true); + QCOMPARE(evaluate(item, "dragActive"), true); + QCOMPARE(evaluate(item, "Drag.target"), static_cast(&dropTarget)); + QCOMPARE(evaluate(item, "dragTarget"), static_cast(&dropTarget)); + QCOMPARE(dropTarget.enterEvents, 1); QCOMPARE(dropTarget.leaveEvents, 0); + + // Start while a drag is active, cancels the previous drag and starts a new one. + dropTarget.reset(); + evaluate(item, "Drag.start()"); + QCOMPARE(evaluate(item, "Drag.active"), true); + QCOMPARE(evaluate(item, "dragActive"), true); + QCOMPARE(evaluate(item, "Drag.target"), static_cast(&dropTarget)); + QCOMPARE(evaluate(item, "dragTarget"), static_cast(&dropTarget)); + QCOMPARE(dropTarget.enterEvents, 1); QCOMPARE(dropTarget.leaveEvents, 1); + + dropTarget.reset(); + evaluate(item, "Drag.cancel()"); + QCOMPARE(evaluate(item, "Drag.active"), false); + QCOMPARE(evaluate(item, "dragActive"), false); + QCOMPARE(evaluate(item, "Drag.target"), static_cast(0)); + QCOMPARE(evaluate(item, "dragTarget"), static_cast(0)); + QCOMPARE(dropTarget.enterEvents, 0); QCOMPARE(dropTarget.leaveEvents, 1); + + // Enter events aren't sent to items without the QQuickItem::ItemAcceptsDrops flag. + dropTarget.setFlags(QQuickItem::Flags()); + + dropTarget.reset(); + evaluate(item, "Drag.active = true"); + QCOMPARE(evaluate(item, "Drag.active"), true); + QCOMPARE(evaluate(item, "dragActive"), true); + QCOMPARE(evaluate(item, "Drag.target"), static_cast(0)); + QCOMPARE(evaluate(item, "dragTarget"), static_cast(0)); + QCOMPARE(dropTarget.enterEvents, 0); QCOMPARE(dropTarget.leaveEvents, 0); + + dropTarget.reset(); + evaluate(item, "Drag.active = false"); + QCOMPARE(evaluate(item, "Drag.active"), false); + QCOMPARE(evaluate(item, "dragActive"), false); + QCOMPARE(evaluate(item, "Drag.target"), static_cast(0)); + QCOMPARE(evaluate(item, "dragTarget"), static_cast(0)); + QCOMPARE(dropTarget.enterEvents, 0); QCOMPARE(dropTarget.leaveEvents, 0); + + dropTarget.setFlags(QQuickItem::ItemAcceptsDrops); + + dropTarget.reset(); + evaluate(item, "Drag.active = true"); + QCOMPARE(evaluate(item, "Drag.active"), true); + QCOMPARE(evaluate(item, "dragActive"), true); + QCOMPARE(evaluate(item, "Drag.target"), static_cast(&dropTarget)); + QCOMPARE(evaluate(item, "dragTarget"), static_cast(&dropTarget)); + QCOMPARE(dropTarget.enterEvents, 1); QCOMPARE(dropTarget.leaveEvents, 0); + + dropTarget.setFlags(QQuickItem::Flags()); + + dropTarget.reset(); + evaluate(item, "Drag.active = false"); + QCOMPARE(evaluate(item, "Drag.active"), false); + QCOMPARE(evaluate(item, "dragActive"), false); + QCOMPARE(evaluate(item, "Drag.target"), static_cast(0)); + QCOMPARE(evaluate(item, "dragTarget"), static_cast(0)); + QCOMPARE(dropTarget.enterEvents, 0); QCOMPARE(dropTarget.leaveEvents, 1); + + // Follow up events aren't sent to items if the enter event isn't accepted. + dropTarget.setFlags(QQuickItem::ItemAcceptsDrops); + dropTarget.accept = false; + + dropTarget.reset(); + evaluate(item, "Drag.active = true"); + QCOMPARE(evaluate(item, "Drag.active"), true); + QCOMPARE(evaluate(item, "dragActive"), true); + QCOMPARE(evaluate(item, "Drag.target"), static_cast(0)); + QCOMPARE(evaluate(item, "dragTarget"), static_cast(0)); + QCOMPARE(dropTarget.enterEvents, 1); QCOMPARE(dropTarget.leaveEvents, 0); + + dropTarget.reset(); + evaluate(item, "Drag.active = false"); + QCOMPARE(evaluate(item, "Drag.active"), false); + QCOMPARE(evaluate(item, "dragActive"), false); + QCOMPARE(evaluate(item, "Drag.target"), static_cast(0)); + QCOMPARE(evaluate(item, "dragTarget"), static_cast(0)); + QCOMPARE(dropTarget.enterEvents, 0); QCOMPARE(dropTarget.leaveEvents, 0); + + dropTarget.accept = true; + + dropTarget.reset(); + evaluate(item, "Drag.active = true"); + QCOMPARE(evaluate(item, "Drag.active"), true); + QCOMPARE(evaluate(item, "dragActive"), true); + QCOMPARE(evaluate(item, "Drag.target"), static_cast(&dropTarget)); + QCOMPARE(evaluate(item, "dragTarget"), static_cast(&dropTarget)); + QCOMPARE(dropTarget.enterEvents, 1); QCOMPARE(dropTarget.leaveEvents, 0); + + dropTarget.accept = false; + + dropTarget.reset(); + evaluate(item, "Drag.active = false"); + QCOMPARE(evaluate(item, "Drag.active"), false); + QCOMPARE(evaluate(item, "dragActive"), false); + QCOMPARE(evaluate(item, "Drag.target"), static_cast(0)); + QCOMPARE(evaluate(item, "dragTarget"), static_cast(0)); + QCOMPARE(dropTarget.enterEvents, 0); QCOMPARE(dropTarget.leaveEvents, 1); + + // Events are sent to hidden or disabled items. + dropTarget.accept = true; + dropTarget.setVisible(false); + dropTarget.reset(); + evaluate(item, "Drag.active = true"); + QCOMPARE(evaluate(item, "Drag.active"), true); + QCOMPARE(evaluate(item, "dragActive"), true); + QCOMPARE(evaluate(item, "Drag.target"), static_cast(0)); + QCOMPARE(evaluate(item, "dragTarget"), static_cast(0)); + QCOMPARE(dropTarget.enterEvents, 0); QCOMPARE(dropTarget.leaveEvents, 0); + + evaluate(item, "Drag.active = false"); + dropTarget.setVisible(true); + + dropTarget.setOpacity(0.0); + dropTarget.reset(); + evaluate(item, "Drag.active = true"); + QCOMPARE(evaluate(item, "Drag.active"), true); + QCOMPARE(evaluate(item, "dragActive"), true); + QCOMPARE(evaluate(item, "Drag.target"), static_cast(0)); + QCOMPARE(evaluate(item, "dragTarget"), static_cast(0)); + QCOMPARE(dropTarget.enterEvents, 0); QCOMPARE(dropTarget.leaveEvents, 0); + + evaluate(item, "Drag.active = false"); + dropTarget.setOpacity(1.0); + + dropTarget.setEnabled(false); + dropTarget.reset(); + evaluate(item, "Drag.active = true"); + QCOMPARE(evaluate(item, "Drag.active"), true); + QCOMPARE(evaluate(item, "dragActive"), true); + QCOMPARE(evaluate(item, "Drag.target"), static_cast(0)); + QCOMPARE(evaluate(item, "dragTarget"), static_cast(0)); + QCOMPARE(dropTarget.enterEvents, 0); QCOMPARE(dropTarget.leaveEvents, 0); +} + +void tst_QQuickDrag::drop() +{ + QQuickCanvas canvas; + TestDropTarget outerTarget(canvas.rootItem()); + outerTarget.setSize(QSizeF(100, 100)); + outerTarget.acceptAction = Qt::CopyAction; + TestDropTarget innerTarget(&outerTarget); + innerTarget.setSize(QSizeF(100, 100)); + innerTarget.acceptAction = Qt::MoveAction; + QQmlComponent component(&engine); + component.setData( + "import QtQuick 2.0\n" + "Item {\n" + "property bool dragActive: Drag.active\n" + "property Item dragTarget: Drag.target\n" + "x: 50; y: 50\n" + "width: 10; height: 10\n" + "}", QUrl()); + QScopedPointer object(component.create()); + QQuickItem *item = qobject_cast(object.data()); + QVERIFY(item); + item->setParentItem(&outerTarget); + + innerTarget.reset(); outerTarget.reset(); + evaluate(item, "Drag.active = true"); + QCOMPARE(evaluate(item, "Drag.active"), true); + QCOMPARE(evaluate(item, "dragActive"), true); + QCOMPARE(evaluate(item, "Drag.target"), static_cast(&innerTarget)); + QCOMPARE(evaluate(item, "dragTarget"), static_cast(&innerTarget)); + QCOMPARE(outerTarget.enterEvents, 1); QCOMPARE(outerTarget.leaveEvents, 0); QCOMPARE(outerTarget.dropEvents, 0); + QCOMPARE(innerTarget.enterEvents, 1); QCOMPARE(innerTarget.leaveEvents, 0); QCOMPARE(innerTarget.dropEvents, 0); + + innerTarget.reset(); outerTarget.reset(); + QCOMPARE(evaluate(item, "Drag.drop() == Qt.MoveAction"), true); + QCOMPARE(evaluate(item, "Drag.active"), false); + QCOMPARE(evaluate(item, "dragActive"), false); + QCOMPARE(evaluate(item, "Drag.target"), static_cast(&innerTarget)); + QCOMPARE(evaluate(item, "dragTarget"), static_cast(&innerTarget)); + QCOMPARE(outerTarget.enterEvents, 0); QCOMPARE(outerTarget.leaveEvents, 1); QCOMPARE(outerTarget.dropEvents, 0); + QCOMPARE(innerTarget.enterEvents, 0); QCOMPARE(innerTarget.leaveEvents, 0); QCOMPARE(innerTarget.dropEvents, 1); + + innerTarget.reset(); outerTarget.reset(); + evaluate(item, "Drag.active = true"); + QCOMPARE(evaluate(item, "Drag.active"), true); + QCOMPARE(evaluate(item, "dragActive"), true); + QCOMPARE(evaluate(item, "Drag.target"), static_cast(&innerTarget)); + QCOMPARE(evaluate(item, "dragTarget"), static_cast(&innerTarget)); + QCOMPARE(outerTarget.enterEvents, 1); QCOMPARE(outerTarget.leaveEvents, 0); QCOMPARE(outerTarget.dropEvents, 0); + QCOMPARE(innerTarget.enterEvents, 1); QCOMPARE(innerTarget.leaveEvents, 0); QCOMPARE(innerTarget.dropEvents, 0); + + // Inner target declines the drop so it is propagated to the outer target. + innerTarget.accept = false; + + innerTarget.reset(); outerTarget.reset(); + QCOMPARE(evaluate(item, "Drag.drop() == Qt.CopyAction"), true); + QCOMPARE(evaluate(item, "Drag.active"), false); + QCOMPARE(evaluate(item, "dragActive"), false); + QCOMPARE(evaluate(item, "Drag.target"), static_cast(&outerTarget)); + QCOMPARE(evaluate(item, "dragTarget"), static_cast(&outerTarget)); + QCOMPARE(outerTarget.enterEvents, 0); QCOMPARE(outerTarget.leaveEvents, 0); QCOMPARE(outerTarget.dropEvents, 1); + QCOMPARE(innerTarget.enterEvents, 0); QCOMPARE(innerTarget.leaveEvents, 0); QCOMPARE(innerTarget.dropEvents, 1); + + + // Inner target doesn't accept enter so drop goes directly to outer. + innerTarget.accept = true; + innerTarget.setFlags(QQuickItem::Flags()); + + innerTarget.reset(); outerTarget.reset(); + evaluate(item, "Drag.active = true"); + QCOMPARE(evaluate(item, "Drag.active"), true); + QCOMPARE(evaluate(item, "dragActive"), true); + QCOMPARE(evaluate(item, "Drag.target"), static_cast(&outerTarget)); + QCOMPARE(evaluate(item, "dragTarget"), static_cast(&outerTarget)); + QCOMPARE(outerTarget.enterEvents, 1); QCOMPARE(outerTarget.leaveEvents, 0); QCOMPARE(outerTarget.dropEvents, 0); + QCOMPARE(innerTarget.enterEvents, 0); QCOMPARE(innerTarget.leaveEvents, 0); QCOMPARE(innerTarget.dropEvents, 0); + + innerTarget.reset(); outerTarget.reset(); + QCOMPARE(evaluate(item, "Drag.drop() == Qt.CopyAction"), true); + QCOMPARE(evaluate(item, "Drag.active"), false); + QCOMPARE(evaluate(item, "dragActive"), false); + QCOMPARE(evaluate(item, "Drag.target"), static_cast(&outerTarget)); + QCOMPARE(evaluate(item, "dragTarget"), static_cast(&outerTarget)); + QCOMPARE(outerTarget.enterEvents, 0); QCOMPARE(outerTarget.leaveEvents, 0); QCOMPARE(outerTarget.dropEvents, 1); + QCOMPARE(innerTarget.enterEvents, 0); QCOMPARE(innerTarget.leaveEvents, 0); QCOMPARE(innerTarget.dropEvents, 0); + + // Neither target accepts drop so Qt::IgnoreAction is returned. + innerTarget.reset(); outerTarget.reset(); + evaluate(item, "Drag.active = true"); + QCOMPARE(evaluate(item, "Drag.active"), true); + QCOMPARE(evaluate(item, "dragActive"), true); + QCOMPARE(evaluate(item, "Drag.target"), static_cast(&outerTarget)); + QCOMPARE(evaluate(item, "dragTarget"), static_cast(&outerTarget)); + QCOMPARE(outerTarget.enterEvents, 1); QCOMPARE(outerTarget.leaveEvents, 0); QCOMPARE(outerTarget.dropEvents, 0); + QCOMPARE(innerTarget.enterEvents, 0); QCOMPARE(innerTarget.leaveEvents, 0); QCOMPARE(innerTarget.dropEvents, 0); + + outerTarget.accept = false; + + innerTarget.reset(); outerTarget.reset(); + QCOMPARE(evaluate(item, "Drag.drop() == Qt.IgnoreAction"), true); + QCOMPARE(evaluate(item, "Drag.active"), false); + QCOMPARE(evaluate(item, "dragActive"), false); + QCOMPARE(evaluate(item, "Drag.target"), static_cast(0)); + QCOMPARE(evaluate(item, "dragTarget"), static_cast(0)); + QCOMPARE(outerTarget.enterEvents, 0); QCOMPARE(outerTarget.leaveEvents, 0); QCOMPARE(outerTarget.dropEvents, 1); + QCOMPARE(innerTarget.enterEvents, 0); QCOMPARE(innerTarget.leaveEvents, 0); QCOMPARE(innerTarget.dropEvents, 0); + + // drop doesn't send an event and returns Qt.IgnoreAction if not active. + innerTarget.accept = true; + outerTarget.accept = true; + innerTarget.reset(); outerTarget.reset(); + QCOMPARE(evaluate(item, "Drag.drop() == Qt.IgnoreAction"), true); + QCOMPARE(evaluate(item, "Drag.active"), false); + QCOMPARE(evaluate(item, "dragActive"), false); + QCOMPARE(evaluate(item, "Drag.target"), static_cast(0)); + QCOMPARE(evaluate(item, "dragTarget"), static_cast(0)); + QCOMPARE(outerTarget.enterEvents, 0); QCOMPARE(outerTarget.leaveEvents, 0); QCOMPARE(outerTarget.dropEvents, 0); + QCOMPARE(innerTarget.enterEvents, 0); QCOMPARE(innerTarget.leaveEvents, 0); QCOMPARE(innerTarget.dropEvents, 0); +} + +void tst_QQuickDrag::move() +{ + QQuickCanvas canvas; + TestDropTarget outerTarget(canvas.rootItem()); + outerTarget.setSize(QSizeF(100, 100)); + TestDropTarget leftTarget(&outerTarget); + leftTarget.setPos(QPointF(0, 35)); + leftTarget.setSize(QSizeF(30, 30)); + TestDropTarget rightTarget(&outerTarget); + rightTarget.setPos(QPointF(70, 35)); + rightTarget.setSize(QSizeF(30, 30)); + QQmlComponent component(&engine); + component.setData( + "import QtQuick 2.0\n" + "Item {\n" + "property bool dragActive: Drag.active\n" + "property Item dragTarget: Drag.target\n" + "x: 50; y: 50\n" + "width: 10; height: 10\n" + "}", QUrl()); + QScopedPointer object(component.create()); + QQuickItem *item = qobject_cast(object.data()); + QVERIFY(item); + item->setParentItem(&outerTarget); + + evaluate(item, "Drag.active = true"); + QCOMPARE(evaluate(item, "Drag.active"), true); + QCOMPARE(evaluate(item, "dragActive"), true); + QCOMPARE(evaluate(item, "Drag.target"), static_cast(&outerTarget)); + QCOMPARE(evaluate(item, "dragTarget"), static_cast(&outerTarget)); + QCOMPARE(outerTarget.enterEvents, 1); QCOMPARE(outerTarget.leaveEvents, 0); QCOMPARE(outerTarget.moveEvents, 0); + QCOMPARE(leftTarget .enterEvents, 0); QCOMPARE(leftTarget .leaveEvents, 0); QCOMPARE(leftTarget .moveEvents, 0); + QCOMPARE(rightTarget.enterEvents, 0); QCOMPARE(rightTarget.leaveEvents, 0); QCOMPARE(rightTarget.moveEvents, 0); + QCOMPARE(outerTarget.position.x(), qreal(50)); QCOMPARE(outerTarget.position.y(), qreal(50)); + + // Move within the outer target. + outerTarget.reset(); leftTarget.reset(); rightTarget.reset(); + item->setPos(QPointF(60, 50)); + QCOMPARE(evaluate(item, "Drag.target"), static_cast(&outerTarget)); + QCOMPARE(evaluate(item, "dragTarget"), static_cast(&outerTarget)); + QCOMPARE(outerTarget.enterEvents, 0); QCOMPARE(outerTarget.leaveEvents, 0); QCOMPARE(outerTarget.moveEvents, 1); + QCOMPARE(leftTarget .enterEvents, 0); QCOMPARE(leftTarget .leaveEvents, 0); QCOMPARE(leftTarget .moveEvents, 0); + QCOMPARE(rightTarget.enterEvents, 0); QCOMPARE(rightTarget.leaveEvents, 0); QCOMPARE(rightTarget.moveEvents, 0); + QCOMPARE(outerTarget.position.x(), qreal(60)); QCOMPARE(outerTarget.position.y(), qreal(50)); + + // Move into the right target. + outerTarget.reset(); leftTarget.reset(); rightTarget.reset(); + item->setPos(QPointF(75, 50)); + QCOMPARE(evaluate(item, "Drag.target"), static_cast(&rightTarget)); + QCOMPARE(evaluate(item, "dragTarget"), static_cast(&rightTarget)); + QCOMPARE(outerTarget.enterEvents, 0); QCOMPARE(outerTarget.leaveEvents, 0); QCOMPARE(outerTarget.moveEvents, 1); + QCOMPARE(leftTarget .enterEvents, 0); QCOMPARE(leftTarget .leaveEvents, 0); QCOMPARE(leftTarget .moveEvents, 0); + QCOMPARE(rightTarget.enterEvents, 1); QCOMPARE(rightTarget.leaveEvents, 0); QCOMPARE(rightTarget.moveEvents, 0); + QCOMPARE(outerTarget.position.x(), qreal(75)); QCOMPARE(outerTarget.position.y(), qreal(50)); + QCOMPARE(rightTarget.position.x(), qreal(5)); QCOMPARE(rightTarget.position.y(), qreal(15)); + + // Move into the left target. + outerTarget.reset(); leftTarget.reset(); rightTarget.reset(); + item->setPos(QPointF(25, 50)); + QCOMPARE(evaluate(item, "Drag.target"), static_cast(&leftTarget)); + QCOMPARE(evaluate(item, "dragTarget"), static_cast(&leftTarget)); + QCOMPARE(outerTarget.enterEvents, 0); QCOMPARE(outerTarget.leaveEvents, 0); QCOMPARE(outerTarget.moveEvents, 1); + QCOMPARE(leftTarget .enterEvents, 1); QCOMPARE(leftTarget .leaveEvents, 0); QCOMPARE(leftTarget .moveEvents, 0); + QCOMPARE(rightTarget.enterEvents, 0); QCOMPARE(rightTarget.leaveEvents, 1); QCOMPARE(rightTarget.moveEvents, 0); + QCOMPARE(outerTarget.position.x(), qreal(25)); QCOMPARE(outerTarget.position.y(), qreal(50)); + QCOMPARE(leftTarget.position.x(), qreal(25)); QCOMPARE(leftTarget.position.y(), qreal(15)); + + // Move within the left target. + outerTarget.reset(); leftTarget.reset(); rightTarget.reset(); + item->setPos(QPointF(25, 40)); + QCOMPARE(evaluate(item, "Drag.target"), static_cast(&leftTarget)); + QCOMPARE(evaluate(item, "dragTarget"), static_cast(&leftTarget)); + QCOMPARE(outerTarget.enterEvents, 0); QCOMPARE(outerTarget.leaveEvents, 0); QCOMPARE(outerTarget.moveEvents, 1); + QCOMPARE(leftTarget .enterEvents, 0); QCOMPARE(leftTarget .leaveEvents, 0); QCOMPARE(leftTarget .moveEvents, 1); + QCOMPARE(rightTarget.enterEvents, 0); QCOMPARE(rightTarget.leaveEvents, 0); QCOMPARE(rightTarget.moveEvents, 0); + QCOMPARE(outerTarget.position.x(), qreal(25)); QCOMPARE(outerTarget.position.y(), qreal(40)); + QCOMPARE(leftTarget.position.x(), qreal(25)); QCOMPARE(leftTarget.position.y(), qreal(5)); + + // Move out of all targets. + outerTarget.reset(); leftTarget.reset(); rightTarget.reset(); + item->setPos(QPointF(110, 50)); + QCOMPARE(evaluate(item, "Drag.target"), static_cast(0)); + QCOMPARE(evaluate(item, "dragTarget"), static_cast(0)); + QCOMPARE(outerTarget.enterEvents, 0); QCOMPARE(outerTarget.leaveEvents, 1); QCOMPARE(outerTarget.moveEvents, 0); + QCOMPARE(leftTarget .enterEvents, 0); QCOMPARE(leftTarget .leaveEvents, 1); QCOMPARE(leftTarget .moveEvents, 0); + QCOMPARE(rightTarget.enterEvents, 0); QCOMPARE(rightTarget.leaveEvents, 0); QCOMPARE(rightTarget.moveEvents, 0); + + // Stop the right target accepting drag events and move into it. + rightTarget.accept = false; + + outerTarget.reset(); leftTarget.reset(); rightTarget.reset(); + item->setPos(QPointF(80, 50)); + QCOMPARE(evaluate(item, "Drag.target"), static_cast(&outerTarget)); + QCOMPARE(evaluate(item, "dragTarget"), static_cast(&outerTarget)); + QCOMPARE(outerTarget.enterEvents, 1); QCOMPARE(outerTarget.leaveEvents, 0); QCOMPARE(outerTarget.moveEvents, 0); + QCOMPARE(leftTarget .enterEvents, 0); QCOMPARE(leftTarget .leaveEvents, 0); QCOMPARE(leftTarget .moveEvents, 0); + QCOMPARE(rightTarget.enterEvents, 1); QCOMPARE(rightTarget.leaveEvents, 0); QCOMPARE(rightTarget.moveEvents, 0); + QCOMPARE(outerTarget.position.x(), qreal(80)); QCOMPARE(outerTarget.position.y(), qreal(50)); + + // Stop the outer target accepting drag events after it has accepted an enter event. + outerTarget.accept = false; + + outerTarget.reset(); leftTarget.reset(); rightTarget.reset(); + item->setPos(QPointF(60, 50)); + QCOMPARE(evaluate(item, "Drag.target"), static_cast(&outerTarget)); + QCOMPARE(evaluate(item, "dragTarget"), static_cast(&outerTarget)); + QCOMPARE(outerTarget.enterEvents, 0); QCOMPARE(outerTarget.leaveEvents, 0); QCOMPARE(outerTarget.moveEvents, 1); + QCOMPARE(leftTarget .enterEvents, 0); QCOMPARE(leftTarget .leaveEvents, 0); QCOMPARE(leftTarget .moveEvents, 0); + QCOMPARE(rightTarget.enterEvents, 0); QCOMPARE(rightTarget.leaveEvents, 0); QCOMPARE(rightTarget.moveEvents, 0); + QCOMPARE(outerTarget.position.x(), qreal(60)); QCOMPARE(outerTarget.position.y(), qreal(50)); + + // Clear the QQuickItem::ItemAcceptsDrops flag from the outer target after it accepted an enter event. + outerTarget.setFlags(QQuickItem::Flags()); + + outerTarget.reset(); leftTarget.reset(); rightTarget.reset(); + item->setPos(QPointF(40, 50)); + QCOMPARE(evaluate(item, "Drag.target"), static_cast(&outerTarget)); + QCOMPARE(evaluate(item, "dragTarget"), static_cast(&outerTarget)); + QCOMPARE(outerTarget.enterEvents, 0); QCOMPARE(outerTarget.leaveEvents, 0); QCOMPARE(outerTarget.moveEvents, 1); + QCOMPARE(leftTarget .enterEvents, 0); QCOMPARE(leftTarget .leaveEvents, 0); QCOMPARE(leftTarget .moveEvents, 0); + QCOMPARE(rightTarget.enterEvents, 0); QCOMPARE(rightTarget.leaveEvents, 0); QCOMPARE(rightTarget.moveEvents, 0); + QCOMPARE(outerTarget.position.x(), qreal(40)); QCOMPARE(outerTarget.position.y(), qreal(50)); + + // Clear the QQuickItem::ItemAcceptsDrops flag from the left target before it accepts an enter event. + leftTarget.setFlags(QQuickItem::Flags()); + + outerTarget.reset(); leftTarget.reset(); rightTarget.reset(); + item->setPos(QPointF(25, 50)); + QCOMPARE(evaluate(item, "Drag.target"), static_cast(&outerTarget)); + QCOMPARE(evaluate(item, "dragTarget"), static_cast(&outerTarget)); + QCOMPARE(outerTarget.enterEvents, 0); QCOMPARE(outerTarget.leaveEvents, 0); QCOMPARE(outerTarget.moveEvents, 1); + QCOMPARE(leftTarget .enterEvents, 0); QCOMPARE(leftTarget .leaveEvents, 0); QCOMPARE(leftTarget .moveEvents, 0); + QCOMPARE(rightTarget.enterEvents, 0); QCOMPARE(rightTarget.leaveEvents, 0); QCOMPARE(rightTarget.moveEvents, 0); + QCOMPARE(outerTarget.position.x(), qreal(25)); QCOMPARE(outerTarget.position.y(), qreal(50)); +} + + +void tst_QQuickDrag::hotSpot() +{ + QQuickCanvas canvas; + TestDropTarget dropTarget(canvas.rootItem()); + dropTarget.setSize(QSizeF(100, 100)); + QQmlComponent component(&engine); + component.setData( + "import QtQuick 2.0\n" + "Item {\n" + "property real hotSpotX: Drag.hotSpot.x\n" + "property real hotSpotY: Drag.hotSpot.y\n" + "x: 50; y: 50\n" + "width: 10; height: 10\n" + "}", QUrl()); + QScopedPointer object(component.create()); + QQuickItem *item = qobject_cast(object.data()); + QVERIFY(item); + item->setParentItem(&dropTarget); + + QCOMPARE(evaluate(item, "Drag.hotSpot.x"), qreal(0)); + QCOMPARE(evaluate(item, "Drag.hotSpot.y"), qreal(0)); + QCOMPARE(evaluate(item, "hotSpotX"), qreal(0)); + QCOMPARE(evaluate(item, "hotSpotY"), qreal(0)); + + evaluate(item, "{ Drag.start(); Drag.cancel() }"); + QCOMPARE(dropTarget.position.x(), qreal(50)); + QCOMPARE(dropTarget.position.y(), qreal(50)); + + evaluate(item, "{ Drag.hotSpot.x = 5, Drag.hotSpot.y = 5 }"); + QCOMPARE(evaluate(item, "Drag.hotSpot.x"), qreal(5)); + QCOMPARE(evaluate(item, "Drag.hotSpot.y"), qreal(5)); + QCOMPARE(evaluate(item, "hotSpotX"), qreal(5)); + QCOMPARE(evaluate(item, "hotSpotY"), qreal(5)); + + evaluate(item, "Drag.start()"); + QCOMPARE(dropTarget.position.x(), qreal(55)); + QCOMPARE(dropTarget.position.y(), qreal(55)); + + item->setPos(QPointF(30, 20)); + QCOMPARE(dropTarget.position.x(), qreal(35)); + QCOMPARE(dropTarget.position.y(), qreal(25)); + + evaluate(item, "{ Drag.hotSpot.x = 10; Drag.hotSpot.y = 10 }"); + QCOMPARE(evaluate(item, "Drag.hotSpot.x"), qreal(10)); + QCOMPARE(evaluate(item, "Drag.hotSpot.y"), qreal(10)); + QCOMPARE(evaluate(item, "hotSpotX"), qreal(10)); + QCOMPARE(evaluate(item, "hotSpotY"), qreal(10)); + // Changing the hotSpot won't generate a move event so the position is unchanged. Should it? + QCOMPARE(dropTarget.position.x(), qreal(35)); + QCOMPARE(dropTarget.position.y(), qreal(25)); + + item->setPos(QPointF(10, 20)); + QCOMPARE(dropTarget.position.x(), qreal(20)); + QCOMPARE(dropTarget.position.y(), qreal(30)); +} + +void tst_QQuickDrag::supportedActions() +{ + QQuickCanvas canvas; + TestDropTarget dropTarget(canvas.rootItem()); + dropTarget.setSize(QSizeF(100, 100)); + QQmlComponent component(&engine); + component.setData( + "import QtQuick 2.0\n" + "Item {\n" + "property int supportedActions: Drag.supportedActions\n" + "x: 50; y: 50\n" + "width: 10; height: 10\n" + "}", QUrl()); + QScopedPointer object(component.create()); + QQuickItem *item = qobject_cast(object.data()); + QVERIFY(item); + item->setParentItem(&dropTarget); + + QCOMPARE(evaluate(item, "Drag.supportedActions == Qt.CopyAction | Qt.MoveAction | Qt.LinkAction"), true); + QCOMPARE(evaluate(item, "supportedActions == Qt.CopyAction | Qt.MoveAction | Qt.LinkAction"), true); + evaluate(item, "{ Drag.start(); Drag.cancel() }"); + QCOMPARE(dropTarget.supportedActions, Qt::CopyAction | Qt::MoveAction | Qt::LinkAction); + + evaluate(item, "Drag.supportedActions = Qt.CopyAction | Qt.MoveAction"); + QCOMPARE(evaluate(item, "Drag.supportedActions == Qt.CopyAction | Qt.MoveAction"), true); + QCOMPARE(evaluate(item, "supportedActions == Qt.CopyAction | Qt.MoveAction"), true); + evaluate(item, "Drag.start()"); + QCOMPARE(dropTarget.supportedActions, Qt::CopyAction | Qt::MoveAction); + + // Once a drag is started the proposed actions are locked in for future events. + evaluate(item, "Drag.supportedActions = Qt.MoveAction"); + QCOMPARE(evaluate(item, "Drag.supportedActions == Qt.MoveAction"), true); + QCOMPARE(evaluate(item, "supportedActions == Qt.MoveAction"), true); + item->setPos(QPointF(60, 60)); + QCOMPARE(dropTarget.supportedActions, Qt::CopyAction | Qt::MoveAction); + + // Calling start with proposed actions will override the current actions for the next sequence. + evaluate(item, "Drag.start(Qt.CopyAction)"); + QCOMPARE(evaluate(item, "Drag.supportedActions == Qt.MoveAction"), true); + QCOMPARE(evaluate(item, "supportedActions == Qt.MoveAction"), true); + QCOMPARE(dropTarget.supportedActions, Qt::CopyAction); + + evaluate(item, "Drag.start()"); + QCOMPARE(evaluate(item, "Drag.supportedActions == Qt.MoveAction"), true); + QCOMPARE(evaluate(item, "supportedActions == Qt.MoveAction"), true); + QCOMPARE(dropTarget.supportedActions, Qt::MoveAction); +} + +void tst_QQuickDrag::proposedAction() +{ + QQuickCanvas canvas; + TestDropTarget dropTarget(canvas.rootItem()); + dropTarget.setSize(QSizeF(100, 100)); + QQmlComponent component(&engine); + component.setData( + "import QtQuick 2.0\n" + "Item {\n" + "property int proposedAction: Drag.proposedAction\n" + "x: 50; y: 50\n" + "width: 10; height: 10\n" + "}", QUrl()); + QScopedPointer object(component.create()); + QQuickItem *item = qobject_cast(object.data()); + QVERIFY(item); + item->setParentItem(&dropTarget); + + + QCOMPARE(evaluate(item, "Drag.proposedAction == Qt.MoveAction"), true); + QCOMPARE(evaluate(item, "proposedAction == Qt.MoveAction"), true); + evaluate(item, "{ Drag.start(); Drag.cancel() }"); + QCOMPARE(dropTarget.defaultAction, Qt::MoveAction); + QCOMPARE(dropTarget.proposedAction, Qt::MoveAction); + + evaluate(item, "Drag.proposedAction = Qt.CopyAction"); + QCOMPARE(evaluate(item, "Drag.proposedAction == Qt.CopyAction"), true); + QCOMPARE(evaluate(item, "proposedAction == Qt.CopyAction"), true); + evaluate(item, "Drag.start()"); + QCOMPARE(dropTarget.defaultAction, Qt::CopyAction); + QCOMPARE(dropTarget.proposedAction, Qt::CopyAction); + + // The proposed action can change during a drag. + evaluate(item, "Drag.proposedAction = Qt.MoveAction"); + QCOMPARE(evaluate(item, "Drag.proposedAction == Qt.MoveAction"), true); + QCOMPARE(evaluate(item, "proposedAction == Qt.MoveAction"), true); + item->setPos(QPointF(60, 60)); + QCOMPARE(dropTarget.defaultAction, Qt::MoveAction); + QCOMPARE(dropTarget.proposedAction, Qt::MoveAction); + + evaluate(item, "Drag.proposedAction = Qt.LinkAction"); + QCOMPARE(evaluate(item, "Drag.proposedAction == Qt.LinkAction"), true); + QCOMPARE(evaluate(item, "proposedAction == Qt.LinkAction"), true); + evaluate(item, "Drag.drop()"); + QCOMPARE(dropTarget.defaultAction, Qt::LinkAction); + QCOMPARE(dropTarget.proposedAction, Qt::LinkAction); +} + +void tst_QQuickDrag::keys() +{ + QQmlComponent component(&engine); + component.setData( + "import QtQuick 2.0\n" + "Item {\n" + "property variant keys: Drag.keys\n" + "x: 50; y: 50\n" + "width: 10; height: 10\n" + "}", QUrl()); + QScopedPointer object(component.create()); + QQuickItem *item = qobject_cast(object.data()); + QVERIFY(item); + +// QCOMPARE(evaluate(item, "Drag.keys"), QStringList()); +// QCOMPARE(evaluate(item, "keys"), QStringList()); + QCOMPARE(item->property("keys").toStringList(), QStringList()); + + evaluate(item, "Drag.keys = [\"red\", \"blue\"]"); +// QCOMPARE(evaluate(item, "Drag.keys"), QStringList() << "red" << "blue"); +// QCOMPARE(evaluate(item, "keys"), QStringList() << "red" << "blue"); + QCOMPARE(item->property("keys").toStringList(), QStringList() << "red" << "blue"); +} + +void tst_QQuickDrag::source() +{ + + QQmlComponent component(&engine); + component.setData( + "import QtQuick 2.0\n" + "Item {\n" + "property Item source: Drag.source\n" + "x: 50; y: 50\n" + "width: 10; height: 10\n" + "Item { id: proxySource; objectName: \"proxySource\" }\n" + "}", QUrl()); + QScopedPointer object(component.create()); + QQuickItem *item = qobject_cast(object.data()); + QVERIFY(item); + + QCOMPARE(evaluate(item, "Drag.source"), static_cast(item)); + QCOMPARE(evaluate(item, "source"), static_cast(item)); + + QQuickItem *proxySource = item->findChild("proxySource"); + QVERIFY(proxySource); + + evaluate(item, "Drag.source = proxySource"); + QCOMPARE(evaluate(item, "Drag.source"), static_cast(proxySource)); + QCOMPARE(evaluate(item, "source"), static_cast(proxySource)); + + evaluate(item, "Drag.source = undefined"); + QCOMPARE(evaluate(item, "Drag.source"), static_cast(item)); + QCOMPARE(evaluate(item, "source"), static_cast(item)); +} + +class RecursingDropTarget : public TestDropTarget +{ +public: + RecursingDropTarget(const QString &script, int type, QQuickItem *parent) + : TestDropTarget(parent), script(script), type(type), item(0) {} + + void setItem(QQuickItem *i) { item = i; } + +protected: + void dragEnterEvent(QDragEnterEvent *event) + { + TestDropTarget::dragEnterEvent(event); + if (type == QEvent::DragEnter && enterEvents < 2) + evaluate(item, script); + } + + void dragMoveEvent(QDragMoveEvent *event) + { + TestDropTarget::dragMoveEvent(event); + if (type == QEvent::DragMove && moveEvents < 2) + evaluate(item, script); + } + + void dragLeaveEvent(QDragLeaveEvent *event) + { + TestDropTarget::dragLeaveEvent(event); + if (type == QEvent::DragLeave && leaveEvents < 2) + evaluate(item, script); + } + + void dropEvent(QDropEvent *event) + { + TestDropTarget::dropEvent(event); + if (type == QEvent::Drop && dropEvents < 2) + evaluate(item, script); + } + +private: + QString script; + int type; + QQuickItem *item; + +}; + +void tst_QQuickDrag::recursion_data() +{ + QTest::addColumn("script"); + QTest::addColumn("type"); + QTest::addColumn("warning"); + + QTest::newRow("Drag.start() in Enter") + << QString("Drag.start()") + << int(QEvent::DragEnter) + << QByteArray(": QML QQuickDragAttached: start() cannot be called from within a drag event handler"); + QTest::newRow("Drag.cancel() in Enter") + << QString("Drag.cancel()") + << int(QEvent::DragEnter) + << QByteArray(": QML QQuickDragAttached: cancel() cannot be called from within a drag event handler"); + QTest::newRow("Drag.drop() in Enter") + << QString("Drag.drop()") + << int(QEvent::DragEnter) + << QByteArray(": QML QQuickDragAttached: drop() cannot be called from within a drag event handler"); + QTest::newRow("Drag.active = true in Enter") + << QString("Drag.active = true") + << int(QEvent::DragEnter) + << QByteArray(); + QTest::newRow("Drag.active = false in Enter") + << QString("Drag.active = false") + << int(QEvent::DragEnter) + << QByteArray(": QML QQuickDragAttached: active cannot be changed from within a drag event handler"); + QTest::newRow("move in Enter") + << QString("x = 23") + << int(QEvent::DragEnter) + << QByteArray(); + + QTest::newRow("Drag.start() in Move") + << QString("Drag.start()") + << int(QEvent::DragMove) + << QByteArray(": QML QQuickDragAttached: start() cannot be called from within a drag event handler"); + QTest::newRow("Drag.cancel() in Move") + << QString("Drag.cancel()") + << int(QEvent::DragMove) + << QByteArray(": QML QQuickDragAttached: cancel() cannot be called from within a drag event handler"); + QTest::newRow("Drag.drop() in Move") + << QString("Drag.drop()") + << int(QEvent::DragMove) + << QByteArray(": QML QQuickDragAttached: drop() cannot be called from within a drag event handler"); + QTest::newRow("Drag.active = true in Move") + << QString("Drag.active = true") + << int(QEvent::DragMove) + << QByteArray(); + QTest::newRow("Drag.active = false in Move") + << QString("Drag.active = false") + << int(QEvent::DragMove) + << QByteArray(": QML QQuickDragAttached: active cannot be changed from within a drag event handler"); + QTest::newRow("move in Move") + << QString("x = 23") + << int(QEvent::DragMove) + << QByteArray(); + + QTest::newRow("Drag.start() in Leave") + << QString("Drag.start()") + << int(QEvent::DragLeave) + << QByteArray(": QML QQuickDragAttached: start() cannot be called from within a drag event handler"); + QTest::newRow("Drag.cancel() in Leave") + << QString("Drag.cancel()") + << int(QEvent::DragLeave) + << QByteArray(": QML QQuickDragAttached: cancel() cannot be called from within a drag event handler"); + QTest::newRow("Drag.drop() in Leave") + << QString("Drag.drop()") + << int(QEvent::DragLeave) + << QByteArray(": QML QQuickDragAttached: drop() cannot be called from within a drag event handler"); + QTest::newRow("Drag.active = true in Leave") + << QString("Drag.active = true") + << int(QEvent::DragLeave) + << QByteArray(": QML QQuickDragAttached: active cannot be changed from within a drag event handler"); + QTest::newRow("Drag.active = false in Leave") + << QString("Drag.active = false") + << int(QEvent::DragLeave) + << QByteArray(); + QTest::newRow("move in Leave") + << QString("x = 23") + << int(QEvent::DragLeave) + << QByteArray(); + + QTest::newRow("Drag.start() in Drop") + << QString("Drag.start()") + << int(QEvent::Drop) + << QByteArray(": QML QQuickDragAttached: start() cannot be called from within a drag event handler"); + QTest::newRow("Drag.cancel() in Drop") + << QString("Drag.cancel()") + << int(QEvent::Drop) + << QByteArray(": QML QQuickDragAttached: cancel() cannot be called from within a drag event handler"); + QTest::newRow("Drag.drop() in Drop") + << QString("Drag.drop()") + << int(QEvent::Drop) + << QByteArray(": QML QQuickDragAttached: drop() cannot be called from within a drag event handler"); + QTest::newRow("Drag.active = true in Drop") + << QString("Drag.active = true") + << int(QEvent::Drop) + << QByteArray(": QML QQuickDragAttached: active cannot be changed from within a drag event handler"); + QTest::newRow("Drag.active = false in Drop") + << QString("Drag.active = false") + << int(QEvent::Drop) + << QByteArray(); + QTest::newRow("move in Drop") + << QString("x = 23") + << int(QEvent::Drop) + << QByteArray(); +} + +void tst_QQuickDrag::recursion() +{ + QFETCH(QString, script); + QFETCH(int, type); + QFETCH(QByteArray, warning); + + if (!warning.isEmpty()) + QTest::ignoreMessage(QtWarningMsg, warning.constData()); + + QQuickCanvas canvas; + RecursingDropTarget dropTarget(script, type, canvas.rootItem()); + dropTarget.setSize(QSizeF(100, 100)); + QQmlComponent component(&engine); + component.setData( + "import QtQuick 2.0\n" + "Item {\n" + "x: 50; y: 50\n" + "width: 10; height: 10\n" + "}", QUrl()); + QScopedPointer object(component.create()); + QQuickItem *item = qobject_cast(object.data()); + QVERIFY(item); + item->setParentItem(canvas.rootItem()); + + dropTarget.setItem(item); + + evaluate(item, "Drag.start()"); + QCOMPARE(dropTarget.enterEvents, 1); + QCOMPARE(dropTarget.moveEvents, 0); + QCOMPARE(dropTarget.dropEvents, 0); + QCOMPARE(dropTarget.leaveEvents, 0); + + evaluate(item, "y = 15"); + QCOMPARE(dropTarget.enterEvents, 1); + QCOMPARE(dropTarget.moveEvents, 1); + QCOMPARE(dropTarget.dropEvents, 0); + QCOMPARE(dropTarget.leaveEvents, 0); + + if (type == QEvent::Drop) { + QCOMPARE(evaluate(item, "Drag.drop() == Qt.MoveAction"), true); + QCOMPARE(dropTarget.enterEvents, 1); + QCOMPARE(dropTarget.moveEvents, 1); + QCOMPARE(dropTarget.dropEvents, 1); + QCOMPARE(dropTarget.leaveEvents, 0); + } else { + evaluate(item, "Drag.cancel()"); + QCOMPARE(dropTarget.enterEvents, 1); + QCOMPARE(dropTarget.moveEvents, 1); + QCOMPARE(dropTarget.dropEvents, 0); + QCOMPARE(dropTarget.leaveEvents, 1); + } +} + + +QTEST_MAIN(tst_QQuickDrag) + +#include "tst_qquickdrag.moc" diff --git a/tests/auto/quick/qquickdroparea/qquickdroparea.pro b/tests/auto/quick/qquickdroparea/qquickdroparea.pro new file mode 100644 index 0000000000..5ae8d222c4 --- /dev/null +++ b/tests/auto/quick/qquickdroparea/qquickdroparea.pro @@ -0,0 +1,9 @@ +TARGET = tst_qquickdroparea +CONFIG += testcase +macx:CONFIG -= app_bundle + +SOURCES += tst_qquickdroparea.cpp + +CONFIG += parallel_test + +QT += core-private gui-private qml-private quick-private network testlib diff --git a/tests/auto/quick/qquickdroparea/tst_qquickdroparea.cpp b/tests/auto/quick/qquickdroparea/tst_qquickdroparea.cpp new file mode 100644 index 0000000000..ed7a0aa0fa --- /dev/null +++ b/tests/auto/quick/qquickdroparea/tst_qquickdroparea.cpp @@ -0,0 +1,1117 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include +#include +#include +#include +#include +#include + +#include + +template static T evaluate(QObject *scope, const QString &expression) +{ + QQmlExpression expr(qmlContext(scope), scope, expression); + QVariant result = expr.evaluate(); + if (expr.hasError()) + qWarning() << expr.error().toString(); + return result.value(); +} + +template <> void evaluate(QObject *scope, const QString &expression) +{ + QQmlExpression expr(qmlContext(scope), scope, expression); + expr.evaluate(); + if (expr.hasError()) + qWarning() << expr.error().toString(); +} + +class tst_QQuickDropArea: public QObject +{ + Q_OBJECT +private slots: + void initTestCase(); + void cleanupTestCase(); + + void containsDrag_internal(); + void containsDrag_external(); + void keys_internal(); + void keys_external(); + void source_internal(); +// void source_external(); + void position_internal(); + void position_external(); + void drop_internal(); +// void drop_external(); + void simultaneousDrags(); + +private: + QQmlEngine engine; +}; + +void tst_QQuickDropArea::initTestCase() +{ + +} + +void tst_QQuickDropArea::cleanupTestCase() +{ + +} + +void tst_QQuickDropArea::containsDrag_internal() +{ + QQuickCanvas canvas; + QQmlComponent component(&engine); + component.setData( + "import QtQuick 2.0\n" + "DropArea {\n" + "property bool hasDrag: containsDrag\n" + "property int enterEvents: 0\n" + "property int exitEvents: 0\n" + "width: 100; height: 100\n" + "onEntered: {++enterEvents}\n" + "onExited: {++exitEvents}\n" + "Item {\n" + "objectName: \"dragItem\"\n" + "x: 50; y: 50\n" + "width: 10; height: 10\n" + "}\n" + "}", QUrl()); + QScopedPointer object(component.create()); + QQuickItem *dropArea = qobject_cast(object.data()); + QVERIFY(dropArea); + dropArea->setParentItem(canvas.rootItem()); + + QQuickItem *dragItem = dropArea->findChild("dragItem"); + QVERIFY(dragItem); + + QCOMPARE(evaluate(dropArea, "containsDrag"), false); + QCOMPARE(evaluate(dropArea, "hasDrag"), false); + + evaluate(dragItem, "Drag.active = true"); + QCOMPARE(evaluate(dropArea, "containsDrag"), true); + QCOMPARE(evaluate(dropArea, "hasDrag"), true); + QCOMPARE(evaluate(dropArea, "enterEvents"), 1); + QCOMPARE(evaluate(dropArea, "exitEvents"), 0); + + evaluate(dropArea, "{ enterEvents = 0; exitEvents = 0 }"); + evaluate(dragItem, "Drag.active = false"); + QCOMPARE(evaluate(dropArea, "containsDrag"), false); + QCOMPARE(evaluate(dropArea, "hasDrag"), false); + QCOMPARE(evaluate(dropArea, "enterEvents"), 0); + QCOMPARE(evaluate(dropArea, "exitEvents"), 1); + + evaluate(dropArea, "{ enterEvents = 0; exitEvents = 0 }"); + + dragItem->setPos(QPointF(150, 50)); + evaluate(dragItem, "Drag.active = true"); + QCOMPARE(evaluate(dropArea, "containsDrag"), false); + QCOMPARE(evaluate(dropArea, "hasDrag"), false); + QCOMPARE(evaluate(dropArea, "enterEvents"), 0); + QCOMPARE(evaluate(dropArea, "exitEvents"), 0); + + dragItem->setPos(QPointF(50, 50)); + QCOMPARE(evaluate(dropArea, "containsDrag"), true); + QCOMPARE(evaluate(dropArea, "hasDrag"), true); + QCOMPARE(evaluate(dropArea, "enterEvents"), 1); + QCOMPARE(evaluate(dropArea, "exitEvents"), 0); + + evaluate(dropArea, "{ enterEvents = 0; exitEvents = 0 }"); + dragItem->setPos(QPointF(150, 50)); + + QCOMPARE(evaluate(dropArea, "containsDrag"), false); + QCOMPARE(evaluate(dropArea, "hasDrag"), false); + QCOMPARE(evaluate(dropArea, "enterEvents"), 0); + QCOMPARE(evaluate(dropArea, "exitEvents"), 1); + + evaluate(dragItem, "Drag.active = false"); +} + +void tst_QQuickDropArea::containsDrag_external() +{ + QQuickCanvas canvas; + QQmlComponent component(&engine); + component.setData( + "import QtQuick 2.0\n" + "DropArea {\n" + "property bool hasDrag: containsDrag\n" + "property int enterEvents: 0\n" + "property int exitEvents: 0\n" + "width: 100; height: 100\n" + "onEntered: {++enterEvents}\n" + "onExited: {++exitEvents}\n" + "}", QUrl()); + QScopedPointer object(component.create()); + QQuickItem *dropArea = qobject_cast(object.data()); + QVERIFY(dropArea); + dropArea->setParentItem(canvas.rootItem()); + + QMimeData data; + QQuickCanvas alternateCanvas; + + QCOMPARE(evaluate(dropArea, "containsDrag"), false); + QCOMPARE(evaluate(dropArea, "hasDrag"), false); + + QWindowSystemInterface::handleDrag(&canvas, &data, QPoint(50, 50)); + QCOMPARE(evaluate(dropArea, "containsDrag"), true); + QCOMPARE(evaluate(dropArea, "hasDrag"), true); + QCOMPARE(evaluate(dropArea, "enterEvents"), 1); + QCOMPARE(evaluate(dropArea, "exitEvents"), 0); + + evaluate(dropArea, "{ enterEvents = 0; exitEvents = 0 }"); + QWindowSystemInterface::handleDrag(&alternateCanvas, &data, QPoint(50, 50)); + QCOMPARE(evaluate(dropArea, "containsDrag"), false); + QCOMPARE(evaluate(dropArea, "hasDrag"), false); + QCOMPARE(evaluate(dropArea, "enterEvents"), 0); + QCOMPARE(evaluate(dropArea, "exitEvents"), 1); + + evaluate(dropArea, "{ enterEvents = 0; exitEvents = 0 }"); + + QWindowSystemInterface::handleDrag(&canvas, &data, QPoint(150, 50)); + QCOMPARE(evaluate(dropArea, "containsDrag"), false); + QCOMPARE(evaluate(dropArea, "hasDrag"), false); + QCOMPARE(evaluate(dropArea, "enterEvents"), 0); + QCOMPARE(evaluate(dropArea, "exitEvents"), 0); + + QWindowSystemInterface::handleDrag(&canvas, &data, QPoint(50, 50)); + QCOMPARE(evaluate(dropArea, "containsDrag"), true); + QCOMPARE(evaluate(dropArea, "hasDrag"), true); + QCOMPARE(evaluate(dropArea, "enterEvents"), 1); + QCOMPARE(evaluate(dropArea, "exitEvents"), 0); + + evaluate(dropArea, "{ enterEvents = 0; exitEvents = 0 }"); + + QWindowSystemInterface::handleDrag(&canvas, &data, QPoint(150, 50)); + QCOMPARE(evaluate(dropArea, "containsDrag"), false); + QCOMPARE(evaluate(dropArea, "hasDrag"), false); + QCOMPARE(evaluate(dropArea, "enterEvents"), 0); + QCOMPARE(evaluate(dropArea, "exitEvents"), 1); + + QWindowSystemInterface::handleDrop(&canvas, &data, QPoint(150, 50)); +} + +void tst_QQuickDropArea::keys_internal() +{ + QQuickCanvas canvas; + QQmlComponent component(&engine); + component.setData( + "import QtQuick 2.0\n" + "DropArea {\n" + "property variant dragKeys\n" + "property variant dropKeys: keys\n" + "property int enterEvents: 0\n" + "width: 100; height: 100\n" + "onEntered: {++enterEvents; dragKeys = drag.keys }\n" + "Item {\n" + "objectName: \"dragItem\"\n" + "x: 50; y: 50\n" + "width: 10; height: 10\n" + "Drag.keys: [\"red\", \"blue\"]\n" + "}\n" + "}", QUrl()); + QScopedPointer object(component.create()); + QQuickItem *dropArea = qobject_cast(object.data()); + QVERIFY(dropArea); + dropArea->setParentItem(canvas.rootItem()); + + QQuickItem *dragItem = dropArea->findChild("dragItem"); + QVERIFY(dragItem); + + QCOMPARE(evaluate(dropArea, "containsDrag"), false); + + evaluate(dragItem, "Drag.active = true"); + QCOMPARE(evaluate(dropArea, "containsDrag"), true); + QCOMPARE(evaluate(dropArea, "enterEvents"), 1); + QCOMPARE(dropArea->property("dragKeys").toStringList(), QStringList() << "red" << "blue"); + + evaluate(dragItem, "Drag.active = false"); + evaluate(dropArea, "keys = \"blue\""); + QCOMPARE(dropArea->property("keys").toStringList(), QStringList() << "blue"); + QCOMPARE(dropArea->property("dropKeys").toStringList(), QStringList() << "blue"); + evaluate(dropArea, "{ enterEvents = 0; dragKeys = undefined }"); + evaluate(dragItem, "Drag.active = true"); + QCOMPARE(evaluate(dropArea, "containsDrag"), true); + QCOMPARE(evaluate(dropArea, "enterEvents"), 1); + QCOMPARE(dropArea->property("dragKeys").toStringList(), QStringList() << "red" << "blue"); + + evaluate(dragItem, "Drag.active = false"); + evaluate(dropArea, "keys = \"red\""); + QCOMPARE(dropArea->property("keys").toStringList(), QStringList() << "red"); + QCOMPARE(dropArea->property("dropKeys").toStringList(), QStringList() << "red"); + evaluate(dropArea, "{ enterEvents = 0; dragKeys = undefined }"); + evaluate(dragItem, "Drag.active = true"); + QCOMPARE(evaluate(dropArea, "containsDrag"), true); + QCOMPARE(evaluate(dropArea, "enterEvents"), 1); + QCOMPARE(dropArea->property("dragKeys").toStringList(), QStringList() << "red" << "blue"); + + evaluate(dragItem, "Drag.active = false"); + evaluate(dropArea, "keys = \"green\""); + QCOMPARE(dropArea->property("keys").toStringList(), QStringList() << "green"); + QCOMPARE(dropArea->property("dropKeys").toStringList(), QStringList() << "green"); + evaluate(dropArea, "{ enterEvents = 0; dragKeys = undefined }"); + evaluate(dragItem, "Drag.active = true"); + QCOMPARE(evaluate(dropArea, "containsDrag"), false); + QCOMPARE(evaluate(dropArea, "enterEvents"), 0); + + evaluate(dragItem, "Drag.active = false"); + evaluate(dropArea, "keys = [\"red\", \"green\"]"); + QCOMPARE(dropArea->property("keys").toStringList(), QStringList() << "red" << "green"); + QCOMPARE(dropArea->property("dropKeys").toStringList(), QStringList() << "red" << "green"); + evaluate(dropArea, "{ enterEvents = 0; dragKeys = undefined }"); + evaluate(dragItem, "Drag.active = true"); + QCOMPARE(evaluate(dropArea, "containsDrag"), true); + QCOMPARE(evaluate(dropArea, "enterEvents"), 1); + QCOMPARE(dropArea->property("dragKeys").toStringList(), QStringList() << "red" << "blue"); + + evaluate(dragItem, "Drag.active = false"); + evaluate(dragItem, "Drag.keys = []"); + evaluate(dropArea, "{ enterEvents = 0; dragKeys = undefined }"); + evaluate(dragItem, "Drag.active = true"); + QCOMPARE(evaluate(dropArea, "containsDrag"), false); + QCOMPARE(evaluate(dropArea, "enterEvents"), 0); + + evaluate(dragItem, "Drag.active = false"); + evaluate(dropArea, "keys = []"); + QCOMPARE(dropArea->property("keys").toStringList(), QStringList()); + QCOMPARE(dropArea->property("dropKeys").toStringList(), QStringList()); + evaluate(dropArea, "{ enterEvents = 0; dragKeys = undefined }"); + evaluate(dragItem, "Drag.active = true"); + QCOMPARE(evaluate(dropArea, "containsDrag"), true); + QCOMPARE(evaluate(dropArea, "enterEvents"), 1); + QCOMPARE(dropArea->property("dragKeys").toStringList(), QStringList()); + + evaluate(dragItem, "Drag.active = false"); + evaluate(dropArea, "keys = []"); + evaluate(dropArea, "{ enterEvents = 0; dragKeys = undefined }"); + evaluate(dragItem, "Drag.active = true"); + QCOMPARE(evaluate(dropArea, "containsDrag"), true); + QCOMPARE(evaluate(dropArea, "enterEvents"), 1); + QCOMPARE(dropArea->property("dragKeys").toStringList(), QStringList()); + + evaluate(dragItem, "Drag.active = false"); + evaluate(dragItem, "Drag.keys = [\"red\", \"blue\"]"); + evaluate(dropArea, "{ enterEvents = 0; dragKeys = undefined }"); + evaluate(dragItem, "Drag.active = true"); + QCOMPARE(evaluate(dropArea, "containsDrag"), true); + QCOMPARE(evaluate(dropArea, "enterEvents"), 1); + QCOMPARE(dropArea->property("dragKeys").toStringList(), QStringList() << "red" << "blue"); +} + +void tst_QQuickDropArea::keys_external() +{ + QQuickCanvas canvas; + QQmlComponent component(&engine); + component.setData( + "import QtQuick 2.0\n" + "DropArea {\n" + "property variant dragKeys\n" + "property variant dropKeys: keys\n" + "property int enterEvents: 0\n" + "width: 100; height: 100\n" + "onEntered: {++enterEvents; dragKeys = drag.keys }\n" + "}", QUrl()); + QScopedPointer object(component.create()); + QQuickItem *dropArea = qobject_cast(object.data()); + dropArea->setParentItem(canvas.rootItem()); + + QMimeData data; + QQuickCanvas alternateCanvas; + + data.setData("text/x-red", "red"); + data.setData("text/x-blue", "blue"); + + QCOMPARE(evaluate(dropArea, "containsDrag"), false); + + QWindowSystemInterface::handleDrag(&canvas, &data, QPoint(50, 50)); + QCOMPARE(evaluate(dropArea, "containsDrag"), true); + QCOMPARE(evaluate(dropArea, "enterEvents"), 1); + QCOMPARE(dropArea->property("dragKeys").toStringList(), QStringList() << "text/x-red" << "text/x-blue"); + + QWindowSystemInterface::handleDrag(&alternateCanvas, &data, QPoint(50, 50)); + evaluate(dropArea, "keys = \"text/x-blue\""); + QCOMPARE(dropArea->property("keys").toStringList(), QStringList() << "text/x-blue"); + QCOMPARE(dropArea->property("dropKeys").toStringList(), QStringList() << "text/x-blue"); + evaluate(dropArea, "{ enterEvents = 0; dragKeys = undefined }"); + QWindowSystemInterface::handleDrag(&canvas, &data, QPoint(50, 50)); + QCOMPARE(evaluate(dropArea, "containsDrag"), true); + QCOMPARE(evaluate(dropArea, "enterEvents"), 1); + QCOMPARE(dropArea->property("dragKeys").toStringList(), QStringList() << "text/x-red" << "text/x-blue"); + + QWindowSystemInterface::handleDrag(&alternateCanvas, &data, QPoint(50, 50)); + evaluate(dropArea, "keys = \"text/x-red\""); + QCOMPARE(dropArea->property("keys").toStringList(), QStringList() << "text/x-red"); + QCOMPARE(dropArea->property("dropKeys").toStringList(), QStringList() << "text/x-red"); + evaluate(dropArea, "{ enterEvents = 0; dragKeys = undefined }"); + QWindowSystemInterface::handleDrag(&canvas, &data, QPoint(50, 50)); + QCOMPARE(evaluate(dropArea, "containsDrag"), true); + QCOMPARE(evaluate(dropArea, "enterEvents"), 1); + QCOMPARE(dropArea->property("dragKeys").toStringList(), QStringList() << "text/x-red" << "text/x-blue"); + + QWindowSystemInterface::handleDrag(&alternateCanvas, &data, QPoint(50, 50)); + evaluate(dropArea, "keys = \"text/x-green\""); + QCOMPARE(dropArea->property("keys").toStringList(), QStringList() << "text/x-green"); + QCOMPARE(dropArea->property("dropKeys").toStringList(), QStringList() << "text/x-green"); + evaluate(dropArea, "{ enterEvents = 0; dragKeys = undefined }"); + QWindowSystemInterface::handleDrag(&canvas, &data, QPoint(50, 50)); + QCOMPARE(evaluate(dropArea, "containsDrag"), false); + QCOMPARE(evaluate(dropArea, "enterEvents"), 0); + + QWindowSystemInterface::handleDrag(&alternateCanvas, &data, QPoint(50, 50)); + evaluate(dropArea, "keys = [\"text/x-red\", \"text/x-green\"]"); + QCOMPARE(dropArea->property("keys").toStringList(), QStringList() << "text/x-red" << "text/x-green"); + QCOMPARE(dropArea->property("dropKeys").toStringList(), QStringList() << "text/x-red" << "text/x-green"); + evaluate(dropArea, "{ enterEvents = 0; dragKeys = undefined }"); + QWindowSystemInterface::handleDrag(&canvas, &data, QPoint(50, 50)); + QCOMPARE(evaluate(dropArea, "containsDrag"), true); + QCOMPARE(evaluate(dropArea, "enterEvents"), 1); + QCOMPARE(dropArea->property("dragKeys").toStringList(), QStringList() << "text/x-red" << "text/x-blue"); + + QWindowSystemInterface::handleDrag(&alternateCanvas, &data, QPoint(50, 50)); + data.removeFormat("text/x-red"); + data.removeFormat("text/x-blue"); + evaluate(dropArea, "{ enterEvents = 0; dragKeys = undefined }"); + QWindowSystemInterface::handleDrag(&canvas, &data, QPoint(50, 50)); + QCOMPARE(evaluate(dropArea, "containsDrag"), false); + QCOMPARE(evaluate(dropArea, "enterEvents"), 0); + + QWindowSystemInterface::handleDrag(&alternateCanvas, &data, QPoint(50, 50)); + evaluate(dropArea, "keys = []"); + QCOMPARE(dropArea->property("keys").toStringList(), QStringList()); + QCOMPARE(dropArea->property("dropKeys").toStringList(), QStringList()); + evaluate(dropArea, "{ enterEvents = 0; dragKeys = undefined }"); + QWindowSystemInterface::handleDrag(&canvas, &data, QPoint(50, 50)); + QCOMPARE(evaluate(dropArea, "containsDrag"), true); + QCOMPARE(evaluate(dropArea, "enterEvents"), 1); + QCOMPARE(dropArea->property("dragKeys").toStringList(), QStringList()); + + QWindowSystemInterface::handleDrag(&alternateCanvas, &data, QPoint(50, 50)); + data.setData("text/x-red", "red"); + data.setData("text/x-blue", "blue"); + QCOMPARE(dropArea->property("keys").toStringList(), QStringList()); + QCOMPARE(dropArea->property("dropKeys").toStringList(), QStringList()); + evaluate(dropArea, "{ enterEvents = 0; dragKeys = undefined }"); + QWindowSystemInterface::handleDrag(&canvas, &data, QPoint(50, 50)); + QCOMPARE(evaluate(dropArea, "containsDrag"), true); + QCOMPARE(evaluate(dropArea, "enterEvents"), 1); + QCOMPARE(dropArea->property("dragKeys").toStringList(), QStringList() << "text/x-red" << "text/x-blue"); + + QWindowSystemInterface::handleDrop(&canvas, &data, QPoint(50, 50)); +} + +void tst_QQuickDropArea::source_internal() +{ + QQuickCanvas canvas; + QQmlComponent component(&engine); + component.setData( + "import QtQuick 2.0\n" + "DropArea {\n" + "property Item source: drag.source\n" + "property Item eventSource\n" + "width: 100; height: 100\n" + "onEntered: {eventSource = drag.source}\n" + "Item {\n" + "objectName: \"dragItem\"\n" + "x: 50; y: 50\n" + "width: 10; height: 10\n" + "}\n" + "Item { id: dragSource; objectName: \"dragSource\" }\n" + "}", QUrl()); + QScopedPointer object(component.create()); + QQuickItem *dropArea = qobject_cast(object.data()); + QVERIFY(dropArea); + dropArea->setParentItem(canvas.rootItem()); + + QQuickItem *dragItem = dropArea->findChild("dragItem"); + QVERIFY(dragItem); + + QQuickItem *dragSource = dropArea->findChild("dragSource"); + QVERIFY(dragSource); + + QCOMPARE(evaluate(dropArea, "source"), static_cast(0)); + QCOMPARE(evaluate(dropArea, "drag.source"), static_cast(0)); + + evaluate(dragItem, "Drag.active = true"); + QCOMPARE(evaluate(dropArea, "source"), static_cast(dragItem)); + QCOMPARE(evaluate(dropArea, "drag.source"), static_cast(dragItem)); + QCOMPARE(evaluate(dropArea, "eventSource"), static_cast(dragItem)); + + evaluate(dragItem, "Drag.active = false"); + QCOMPARE(evaluate(dropArea, "source"), static_cast(0)); + QCOMPARE(evaluate(dropArea, "drag.source"), static_cast(0)); + + + evaluate(dropArea, "{ eventSource = null }"); + evaluate(dragItem, "Drag.source = dragSource"); + + evaluate(dragItem, "Drag.active = true"); + QCOMPARE(evaluate(dropArea, "source"), static_cast(dragSource)); + QCOMPARE(evaluate(dropArea, "drag.source"), static_cast(dragSource)); + QCOMPARE(evaluate(dropArea, "eventSource"), static_cast(dragSource)); + + evaluate(dragItem, "Drag.active = false"); + QCOMPARE(evaluate(dropArea, "source"), static_cast(0)); + QCOMPARE(evaluate(dropArea, "drag.source"), static_cast(0)); +} + +// Setting a source can't be emulated using the QWindowSystemInterface API. + +//void tst_QQuickDropArea::source_external() +//{ +//} + +void tst_QQuickDropArea::position_internal() +{ + QQuickCanvas canvas; + QQmlComponent component(&engine); + component.setData( + "import QtQuick 2.0\n" + "DropArea {\n" + "property real dragX: drag.x\n" + "property real dragY: drag.y\n" + "property real eventX\n" + "property real eventY\n" + "property int enterEvents: 0\n" + "property int moveEvents: 0\n" + "width: 100; height: 100\n" + "onEntered: {++enterEvents; eventX = drag.x; eventY = drag.y}\n" + "onPositionChanged: {++moveEvents; eventX = drag.x; eventY = drag.y}\n" + "Item {\n" + "objectName: \"dragItem\"\n" + "x: 50; y: 50\n" + "width: 10; height: 10\n" + "}\n" + "}", QUrl()); + QScopedPointer object(component.create()); + QQuickItem *dropArea = qobject_cast(object.data()); + QVERIFY(dropArea); + dropArea->setParentItem(canvas.rootItem()); + + QQuickItem *dragItem = dropArea->findChild("dragItem"); + QVERIFY(dragItem); + + evaluate(dragItem, "Drag.active = true"); + QCOMPARE(evaluate(dropArea, "enterEvents"), 1); + QCOMPARE(evaluate(dropArea, "moveEvents"), 0); + QCOMPARE(evaluate(dropArea, "drag.x"), qreal(50)); + QCOMPARE(evaluate(dropArea, "drag.y"), qreal(50)); + QCOMPARE(evaluate(dropArea, "dragX"), qreal(50)); + QCOMPARE(evaluate(dropArea, "dragY"), qreal(50)); + QCOMPARE(evaluate(dropArea, "eventX"), qreal(50)); + QCOMPARE(evaluate(dropArea, "eventY"), qreal(50)); + + evaluate(dropArea, "{ enterEvents = 0; moveEvents = 0; eventX = -1; eventY = -1 }"); + dragItem->setPos(QPointF(40, 50)); + QCOMPARE(evaluate(dropArea, "enterEvents"), 0); + QCOMPARE(evaluate(dropArea, "moveEvents"), 1); + QCOMPARE(evaluate(dropArea, "drag.x"), qreal(40)); + QCOMPARE(evaluate(dropArea, "drag.y"), qreal(50)); + QCOMPARE(evaluate(dropArea, "dragX"), qreal(40)); + QCOMPARE(evaluate(dropArea, "dragY"), qreal(50)); + QCOMPARE(evaluate(dropArea, "eventX"), qreal(40)); + QCOMPARE(evaluate(dropArea, "eventY"), qreal(50)); + + evaluate(dropArea, "{ enterEvents = 0; moveEvents = 0; eventX = -1; eventY = -1 }"); + dragItem->setPos(QPointF(75, 25)); + QCOMPARE(evaluate(dropArea, "enterEvents"), 0); + QCOMPARE(evaluate(dropArea, "moveEvents"), 1); + QCOMPARE(evaluate(dropArea, "drag.x"), qreal(75)); + QCOMPARE(evaluate(dropArea, "drag.y"), qreal(25)); + QCOMPARE(evaluate(dropArea, "dragX"), qreal(75)); + QCOMPARE(evaluate(dropArea, "dragY"), qreal(25)); + QCOMPARE(evaluate(dropArea, "eventX"), qreal(75)); + QCOMPARE(evaluate(dropArea, "eventY"), qreal(25)); + + evaluate(dragItem, "Drag.active = false"); +} + +void tst_QQuickDropArea::position_external() +{ + QQuickCanvas canvas; + QQmlComponent component(&engine); + component.setData( + "import QtQuick 2.0\n" + "DropArea {\n" + "property real dragX: drag.x\n" + "property real dragY: drag.y\n" + "property real eventX\n" + "property real eventY\n" + "property int enterEvents: 0\n" + "property int moveEvents: 0\n" + "width: 100; height: 100\n" + "onEntered: {++enterEvents; eventX = drag.x; eventY = drag.y}\n" + "onPositionChanged: {++moveEvents; eventX = drag.x; eventY = drag.y}\n" + "}", QUrl()); + QScopedPointer object(component.create()); + QQuickItem *dropArea = qobject_cast(object.data()); + QVERIFY(dropArea); + dropArea->setParentItem(canvas.rootItem()); + + QMimeData data; + + QWindowSystemInterface::handleDrag(&canvas, &data, QPoint(50, 50)); + QCOMPARE(evaluate(dropArea, "enterEvents"), 1); + QCOMPARE(evaluate(dropArea, "moveEvents"), 1); + QCOMPARE(evaluate(dropArea, "drag.x"), qreal(50)); + QCOMPARE(evaluate(dropArea, "drag.y"), qreal(50)); + QCOMPARE(evaluate(dropArea, "dragX"), qreal(50)); + QCOMPARE(evaluate(dropArea, "dragY"), qreal(50)); + QCOMPARE(evaluate(dropArea, "eventX"), qreal(50)); + QCOMPARE(evaluate(dropArea, "eventY"), qreal(50)); + + evaluate(dropArea, "{ enterEvents = 0; moveEvents = 0; eventX = -1; eventY = -1 }"); + QWindowSystemInterface::handleDrag(&canvas, &data, QPoint(40, 50)); + QCOMPARE(evaluate(dropArea, "enterEvents"), 0); + QCOMPARE(evaluate(dropArea, "moveEvents"), 1); + QCOMPARE(evaluate(dropArea, "drag.x"), qreal(40)); + QCOMPARE(evaluate(dropArea, "drag.y"), qreal(50)); + QCOMPARE(evaluate(dropArea, "dragX"), qreal(40)); + QCOMPARE(evaluate(dropArea, "dragY"), qreal(50)); + QCOMPARE(evaluate(dropArea, "eventX"), qreal(40)); + QCOMPARE(evaluate(dropArea, "eventY"), qreal(50)); + + evaluate(dropArea, "{ enterEvents = 0; moveEvents = 0; eventX = -1; eventY = -1 }"); + QWindowSystemInterface::handleDrag(&canvas, &data, QPoint(75, 25)); + QCOMPARE(evaluate(dropArea, "enterEvents"), 0); + QCOMPARE(evaluate(dropArea, "moveEvents"), 1); + QCOMPARE(evaluate(dropArea, "drag.x"), qreal(75)); + QCOMPARE(evaluate(dropArea, "drag.y"), qreal(25)); + QCOMPARE(evaluate(dropArea, "dragX"), qreal(75)); + QCOMPARE(evaluate(dropArea, "dragY"), qreal(25)); + QCOMPARE(evaluate(dropArea, "eventX"), qreal(75)); + QCOMPARE(evaluate(dropArea, "eventY"), qreal(25)); + + QWindowSystemInterface::handleDrop(&canvas, &data, QPoint(75, 25)); +} + +void tst_QQuickDropArea::drop_internal() +{ + QQuickCanvas canvas; + QQmlComponent component(&engine); + component.setData( + "import QtQuick 2.0\n" + "DropArea {\n" + "property bool accept: false\n" + "property bool setAccepted: false\n" + "property bool acceptDropAction: false\n" + "property bool setDropAction: false\n" + "property int dropAction: Qt.IgnoreAction\n" + "property int proposedAction: Qt.IgnoreAction\n" + "property int supportedActions: Qt.IgnoreAction\n" + "property int dropEvents: 0\n" + "width: 100; height: 100\n" + "onDropped: {\n" + "++dropEvents\n" + "supportedActions = drop.supportedActions\n" + "proposedAction = drop.action\n" + "if (setDropAction)\n" + "drop.action = dropAction\n" + "if (acceptDropAction)\n" + "drop.accept(dropAction)\n" + "else if (setAccepted)\n" + "drop.accepted = accept\n" + "else if (accept)\n" + "drop.accept()\n" + "}\n" + "Item {\n" + "objectName: \"dragItem\"\n" + "x: 50; y: 50\n" + "width: 10; height: 10\n" + "}\n" + "}", QUrl()); + QScopedPointer object(component.create()); + QQuickItem *dropArea = qobject_cast(object.data()); + QVERIFY(dropArea); + dropArea->setParentItem(canvas.rootItem()); + + QQuickItem *dragItem = dropArea->findChild("dragItem"); + QVERIFY(dragItem); + + evaluate(dragItem, "Drag.active = true"); + QCOMPARE(evaluate(dragItem, "Drag.drop()"), int(Qt::IgnoreAction)); + QCOMPARE(evaluate(dropArea, "dropEvents"), 1); + QCOMPARE(evaluate(dropArea, "supportedActions"), int(Qt::CopyAction | Qt::MoveAction | Qt::LinkAction)); + QCOMPARE(evaluate(dropArea, "proposedAction"), int(Qt::MoveAction)); + + evaluate(dropArea, "{ dropEvents = 0; proposedAction = Qt.IgnoreAction; supportedActions = Qt.IgnoreAction }"); + evaluate(dropArea, "{ accept = true; setDropAction = true; dropAction = Qt.LinkAction }"); + evaluate(dragItem, "Drag.active = true"); + QCOMPARE(evaluate(dragItem, "Drag.drop()"), int(Qt::LinkAction)); + QCOMPARE(evaluate(dropArea, "dropEvents"), 1); + QCOMPARE(evaluate(dropArea, "supportedActions"), int(Qt::CopyAction | Qt::MoveAction | Qt::LinkAction)); + QCOMPARE(evaluate(dropArea, "proposedAction"), int(Qt::MoveAction)); + + evaluate(dropArea, "{ dropEvents = 0; proposedAction = Qt.IgnoreAction; supportedActions = Qt.IgnoreAction }"); + evaluate(dropArea, "{ setAccepted = true; }"); + evaluate(dragItem, "Drag.active = true"); + QCOMPARE(evaluate(dragItem, "Drag.drop()"), int(Qt::LinkAction)); + QCOMPARE(evaluate(dropArea, "dropEvents"), 1); + QCOMPARE(evaluate(dropArea, "supportedActions"), int(Qt::CopyAction | Qt::MoveAction | Qt::LinkAction)); + QCOMPARE(evaluate(dropArea, "proposedAction"), int(Qt::MoveAction)); + + evaluate(dropArea, "{ dropEvents = 0; proposedAction = Qt.IgnoreAction; supportedActions = Qt.IgnoreAction }"); + evaluate(dropArea, "{ accept = false; setAccepted = true; }"); + evaluate(dragItem, "Drag.active = true"); + QCOMPARE(evaluate(dragItem, "Drag.drop()"), int(Qt::IgnoreAction)); + QCOMPARE(evaluate(dropArea, "dropEvents"), 1); + QCOMPARE(evaluate(dropArea, "supportedActions"), int(Qt::CopyAction | Qt::MoveAction | Qt::LinkAction)); + QCOMPARE(evaluate(dropArea, "proposedAction"), int(Qt::MoveAction)); + + evaluate(dropArea, "{ dropEvents = 0; proposedAction = Qt.IgnoreAction; supportedActions = Qt.IgnoreAction }"); + evaluate(dropArea, "{ setAccepted = false; setDropAction = false; acceptDropAction = true; }"); + evaluate(dragItem, "Drag.active = true"); + QCOMPARE(evaluate(dragItem, "Drag.drop()"), int(Qt::LinkAction)); + QCOMPARE(evaluate(dropArea, "dropEvents"), 1); + QCOMPARE(evaluate(dropArea, "supportedActions"), int(Qt::CopyAction | Qt::MoveAction | Qt::LinkAction)); + QCOMPARE(evaluate(dropArea, "proposedAction"), int(Qt::MoveAction)); + + evaluate(dropArea, "{ dropEvents = 0; proposedAction = Qt.IgnoreAction; supportedActions = Qt.IgnoreAction }"); + evaluate(dropArea, "{ acceptDropAction = false; dropAction = Qt.IgnoreAction; accept = true }"); + evaluate(dragItem, "Drag.active = true"); + QCOMPARE(evaluate(dragItem, "Drag.drop()"), int(Qt::MoveAction)); + QCOMPARE(evaluate(dropArea, "dropEvents"), 1); + QCOMPARE(evaluate(dropArea, "supportedActions"), int(Qt::CopyAction | Qt::MoveAction | Qt::LinkAction)); + QCOMPARE(evaluate(dropArea, "proposedAction"), int(Qt::MoveAction)); + + evaluate(dropArea, "{ dropEvents = 0; proposedAction = Qt.IgnoreAction; supportedActions = Qt.IgnoreAction }"); + evaluate(dropArea, "{ setAccepted = true }"); + evaluate(dragItem, "Drag.active = true"); + QCOMPARE(evaluate(dragItem, "Drag.drop()"), int(Qt::MoveAction)); + QCOMPARE(evaluate(dropArea, "dropEvents"), 1); + QCOMPARE(evaluate(dropArea, "supportedActions"), int(Qt::CopyAction | Qt::MoveAction | Qt::LinkAction)); + QCOMPARE(evaluate(dropArea, "proposedAction"), int(Qt::MoveAction)); + + evaluate(dropArea, "{ dropEvents = 0; proposedAction = Qt.IgnoreAction; supportedActions = Qt.IgnoreAction }"); + evaluate(dropArea, "{ setAccepted = false }"); + evaluate(dragItem, "Drag.supportedActions = Qt.LinkAction"); + evaluate(dragItem, "Drag.active = true"); + QCOMPARE(evaluate(dragItem, "Drag.drop()"), int(Qt::MoveAction)); + QCOMPARE(evaluate(dropArea, "dropEvents"), 1); + QCOMPARE(evaluate(dropArea, "supportedActions"), int(Qt::LinkAction)); + QCOMPARE(evaluate(dropArea, "proposedAction"), int(Qt::MoveAction)); + + evaluate(dropArea, "{ dropEvents = 0; proposedAction = Qt.IgnoreAction; supportedActions = Qt.IgnoreAction }"); + evaluate(dropArea, "{ setAccepted = true }"); + evaluate(dragItem, "Drag.active = true"); + QCOMPARE(evaluate(dragItem, "Drag.drop()"), int(Qt::MoveAction)); + QCOMPARE(evaluate(dropArea, "dropEvents"), 1); + QCOMPARE(evaluate(dropArea, "supportedActions"), int(Qt::LinkAction)); + QCOMPARE(evaluate(dropArea, "proposedAction"), int(Qt::MoveAction)); + + evaluate(dropArea, "{ dropEvents = 0; proposedAction = Qt.IgnoreAction; supportedActions = Qt.IgnoreAction }"); + evaluate(dropArea, "{ setAccepted = false }"); + evaluate(dragItem, "Drag.proposedAction = Qt.LinkAction"); + evaluate(dragItem, "Drag.active = true"); + QCOMPARE(evaluate(dragItem, "Drag.drop()"), int(Qt::LinkAction)); + QCOMPARE(evaluate(dropArea, "dropEvents"), 1); + QCOMPARE(evaluate(dropArea, "supportedActions"), int(Qt::LinkAction)); + QCOMPARE(evaluate(dropArea, "proposedAction"), int(Qt::LinkAction)); + + evaluate(dropArea, "{ dropEvents = 0; proposedAction = Qt.IgnoreAction; supportedActions = Qt.IgnoreAction }"); + evaluate(dropArea, "{ setAccepted = true }"); + evaluate(dragItem, "Drag.active = true"); + QCOMPARE(evaluate(dragItem, "Drag.drop()"), int(Qt::LinkAction)); + QCOMPARE(evaluate(dropArea, "dropEvents"), 1); + QCOMPARE(evaluate(dropArea, "supportedActions"), int(Qt::LinkAction)); + QCOMPARE(evaluate(dropArea, "proposedAction"), int(Qt::LinkAction)); +} + +// Setting the supportedActions can't be emulated using the QWindowSystemInterface API. + +//void tst_QQuickDropArea::drop_external() +//{ +//} + +void tst_QQuickDropArea::simultaneousDrags() +{ + QQuickCanvas canvas; + QQmlComponent component(&engine); + component.setData( + "import QtQuick 2.0\n" + "DropArea {\n" + "property int enterEvents: 0\n" + "property int exitEvents: 0\n" + "width: 100; height: 100\n" + "keys: [\"red\", \"text/x-red\"]\n" + "onEntered: {++enterEvents}\n" + "onExited: {++exitEvents}\n" + "DropArea {\n" + "objectName: \"dropArea2\"\n" + "property int enterEvents: 0\n" + "property int exitEvents: 0\n" + "width: 100; height: 100\n" + "keys: [\"blue\", \"text/x-blue\"]\n" + "onEntered: {++enterEvents}\n" + "onExited: {++exitEvents}\n" + "}\n" + "Item {\n" + "objectName: \"dragItem1\"\n" + "x: 50; y: 50\n" + "width: 10; height: 10\n" + "Drag.keys: [\"red\", \"blue\"]" + "}\n" + "Item {\n" + "objectName: \"dragItem2\"\n" + "x: 50; y: 50\n" + "width: 10; height: 10\n" + "Drag.keys: [\"red\", \"blue\"]" + "}\n" + "}", QUrl()); + + QScopedPointer object(component.create()); + QQuickItem *dropArea1 = qobject_cast(object.data()); + QVERIFY(dropArea1); + dropArea1->setParentItem(canvas.rootItem()); + + QQuickItem *dropArea2 = dropArea1->findChild("dropArea2"); + QVERIFY(dropArea2); + + QQuickItem *dragItem1 = dropArea1->findChild("dragItem1"); + QVERIFY(dragItem1); + + QQuickItem *dragItem2 = dropArea1->findChild("dragItem2"); + QVERIFY(dragItem2); + + QMimeData data; + data.setData("text/x-red", "red"); + data.setData("text/x-blue", "blue"); + + QQuickCanvas alternateCanvas; + + // Mixed internal drags. + evaluate(dropArea1, "{ enterEvents = 0; exitEvents = 0 }"); + evaluate(dropArea2, "{ enterEvents = 0; exitEvents = 0 }"); + evaluate(dragItem1, "Drag.active = true"); + QCOMPARE(evaluate(dropArea1, "containsDrag"), true); + QCOMPARE(evaluate(dropArea1, "enterEvents"), 1); + QCOMPARE(evaluate(dropArea1, "exitEvents"), 0); + QCOMPARE(evaluate(dropArea2, "containsDrag"), true); + QCOMPARE(evaluate(dropArea2, "enterEvents"), 1); + QCOMPARE(evaluate(dropArea2, "exitEvents"), 0); + + evaluate(dropArea1, "{ enterEvents = 0; exitEvents = 0 }"); + evaluate(dropArea2, "{ enterEvents = 0; exitEvents = 0 }"); + evaluate(dragItem2, "Drag.active = true"); + QCOMPARE(evaluate(dropArea1, "containsDrag"), true); + QCOMPARE(evaluate(dropArea1, "enterEvents"), 0); + QCOMPARE(evaluate(dropArea1, "exitEvents"), 0); + QCOMPARE(evaluate(dropArea2, "containsDrag"), true); + QCOMPARE(evaluate(dropArea2, "enterEvents"), 0); + QCOMPARE(evaluate(dropArea2, "exitEvents"), 0); + + evaluate(dragItem2, "Drag.active = false"); + QCOMPARE(evaluate(dropArea1, "containsDrag"), true); + QCOMPARE(evaluate(dropArea1, "enterEvents"), 0); + QCOMPARE(evaluate(dropArea1, "exitEvents"), 0); + QCOMPARE(evaluate(dropArea2, "containsDrag"), true); + QCOMPARE(evaluate(dropArea2, "enterEvents"), 0); + QCOMPARE(evaluate(dropArea2, "exitEvents"), 0); + + evaluate(dragItem2, "Drag.active = true"); + QCOMPARE(evaluate(dropArea1, "containsDrag"), true); + QCOMPARE(evaluate(dropArea1, "enterEvents"), 0); + QCOMPARE(evaluate(dropArea1, "exitEvents"), 0); + QCOMPARE(evaluate(dropArea2, "containsDrag"), true); + QCOMPARE(evaluate(dropArea2, "enterEvents"), 0); + QCOMPARE(evaluate(dropArea2, "exitEvents"), 0); + + evaluate(dragItem1, "Drag.active = false"); + QCOMPARE(evaluate(dropArea1, "containsDrag"), false); + QCOMPARE(evaluate(dropArea1, "enterEvents"), 0); + QCOMPARE(evaluate(dropArea1, "exitEvents"), 1); + QCOMPARE(evaluate(dropArea2, "containsDrag"), false); + QCOMPARE(evaluate(dropArea2, "enterEvents"), 0); + QCOMPARE(evaluate(dropArea2, "exitEvents"), 1); + + evaluate(dropArea1, "{ enterEvents = 0; exitEvents = 0 }"); + evaluate(dropArea2, "{ enterEvents = 0; exitEvents = 0 }"); + evaluate(dragItem2, "Drag.active = false"); + QCOMPARE(evaluate(dropArea1, "containsDrag"), false); + QCOMPARE(evaluate(dropArea1, "enterEvents"), 0); + QCOMPARE(evaluate(dropArea1, "exitEvents"), 0); + QCOMPARE(evaluate(dropArea2, "containsDrag"), false); + QCOMPARE(evaluate(dropArea2, "enterEvents"), 0); + QCOMPARE(evaluate(dropArea2, "exitEvents"), 0); + + // internal then external. + evaluate(dropArea1, "{ enterEvents = 0; exitEvents = 0 }"); + evaluate(dropArea2, "{ enterEvents = 0; exitEvents = 0 }"); + evaluate(dragItem1, "Drag.active = true"); + QCOMPARE(evaluate(dropArea1, "containsDrag"), true); + QCOMPARE(evaluate(dropArea1, "enterEvents"), 1); + QCOMPARE(evaluate(dropArea1, "exitEvents"), 0); + QCOMPARE(evaluate(dropArea2, "containsDrag"), true); + QCOMPARE(evaluate(dropArea2, "enterEvents"), 1); + QCOMPARE(evaluate(dropArea2, "exitEvents"), 0); + + evaluate(dropArea1, "{ enterEvents = 0; exitEvents = 0 }"); + evaluate(dropArea2, "{ enterEvents = 0; exitEvents = 0 }"); + QWindowSystemInterface::handleDrag(&canvas, &data, QPoint(50, 50)); + QCOMPARE(evaluate(dropArea1, "containsDrag"), true); + QCOMPARE(evaluate(dropArea1, "enterEvents"), 0); + QCOMPARE(evaluate(dropArea1, "exitEvents"), 0); + QCOMPARE(evaluate(dropArea2, "containsDrag"), true); + QCOMPARE(evaluate(dropArea2, "enterEvents"), 0); + QCOMPARE(evaluate(dropArea2, "exitEvents"), 0); + + QWindowSystemInterface::handleDrag(&alternateCanvas, &data, QPoint(50, 50)); + QCOMPARE(evaluate(dropArea1, "containsDrag"), true); + QCOMPARE(evaluate(dropArea1, "enterEvents"), 0); + QCOMPARE(evaluate(dropArea1, "exitEvents"), 0); + QCOMPARE(evaluate(dropArea2, "containsDrag"), true); + QCOMPARE(evaluate(dropArea2, "enterEvents"), 0); + QCOMPARE(evaluate(dropArea2, "exitEvents"), 0); + + QWindowSystemInterface::handleDrag(&canvas, &data, QPoint(50, 50)); + QCOMPARE(evaluate(dropArea1, "containsDrag"), true); + QCOMPARE(evaluate(dropArea1, "enterEvents"), 0); + QCOMPARE(evaluate(dropArea1, "exitEvents"), 0); + QCOMPARE(evaluate(dropArea2, "containsDrag"), true); + QCOMPARE(evaluate(dropArea2, "enterEvents"), 0); + QCOMPARE(evaluate(dropArea2, "exitEvents"), 0); + + evaluate(dragItem1, "Drag.active = false"); + QCOMPARE(evaluate(dropArea1, "containsDrag"), false); + QCOMPARE(evaluate(dropArea1, "enterEvents"), 0); + QCOMPARE(evaluate(dropArea1, "exitEvents"), 1); + QCOMPARE(evaluate(dropArea2, "containsDrag"), false); + QCOMPARE(evaluate(dropArea2, "enterEvents"), 0); + QCOMPARE(evaluate(dropArea2, "exitEvents"), 1); + + evaluate(dropArea1, "{ enterEvents = 0; exitEvents = 0 }"); + evaluate(dropArea2, "{ enterEvents = 0; exitEvents = 0 }"); + QWindowSystemInterface::handleDrag(&alternateCanvas, &data, QPoint(50, 50)); + QCOMPARE(evaluate(dropArea1, "containsDrag"), false); + QCOMPARE(evaluate(dropArea1, "enterEvents"), 0); + QCOMPARE(evaluate(dropArea1, "exitEvents"), 0); + QCOMPARE(evaluate(dropArea2, "containsDrag"), false); + QCOMPARE(evaluate(dropArea2, "enterEvents"), 0); + QCOMPARE(evaluate(dropArea2, "exitEvents"), 0); + + // external then internal. + evaluate(dropArea1, "{ enterEvents = 0; exitEvents = 0 }"); + evaluate(dropArea2, "{ enterEvents = 0; exitEvents = 0 }"); + QWindowSystemInterface::handleDrag(&canvas, &data, QPoint(50, 50)); + QCOMPARE(evaluate(dropArea1, "containsDrag"), true); + QCOMPARE(evaluate(dropArea1, "enterEvents"), 1); + QCOMPARE(evaluate(dropArea1, "exitEvents"), 0); + QCOMPARE(evaluate(dropArea2, "containsDrag"), true); + QCOMPARE(evaluate(dropArea2, "enterEvents"), 1); + QCOMPARE(evaluate(dropArea2, "exitEvents"), 0); + + evaluate(dropArea1, "{ enterEvents = 0; exitEvents = 0 }"); + evaluate(dropArea2, "{ enterEvents = 0; exitEvents = 0 }"); + evaluate(dragItem2, "Drag.active = true"); + QCOMPARE(evaluate(dropArea1, "containsDrag"), true); + QCOMPARE(evaluate(dropArea1, "enterEvents"), 0); + QCOMPARE(evaluate(dropArea1, "exitEvents"), 0); + QCOMPARE(evaluate(dropArea2, "containsDrag"), true); + QCOMPARE(evaluate(dropArea2, "enterEvents"), 0); + QCOMPARE(evaluate(dropArea2, "exitEvents"), 0); + + evaluate(dragItem2, "Drag.active = false"); + QCOMPARE(evaluate(dropArea1, "containsDrag"), true); + QCOMPARE(evaluate(dropArea1, "enterEvents"), 0); + QCOMPARE(evaluate(dropArea1, "exitEvents"), 0); + QCOMPARE(evaluate(dropArea2, "containsDrag"), true); + QCOMPARE(evaluate(dropArea2, "enterEvents"), 0); + QCOMPARE(evaluate(dropArea2, "exitEvents"), 0); + + evaluate(dragItem2, "Drag.active = true"); + QCOMPARE(evaluate(dropArea1, "containsDrag"), true); + QCOMPARE(evaluate(dropArea1, "enterEvents"), 0); + QCOMPARE(evaluate(dropArea1, "exitEvents"), 0); + QCOMPARE(evaluate(dropArea2, "containsDrag"), true); + QCOMPARE(evaluate(dropArea2, "enterEvents"), 0); + QCOMPARE(evaluate(dropArea2, "exitEvents"), 0); + + QWindowSystemInterface::handleDrag(&alternateCanvas, &data, QPoint(50, 50)); + QCOMPARE(evaluate(dropArea1, "containsDrag"), false); + QCOMPARE(evaluate(dropArea1, "enterEvents"), 0); + QCOMPARE(evaluate(dropArea1, "exitEvents"), 1); + QCOMPARE(evaluate(dropArea2, "containsDrag"), false); + QCOMPARE(evaluate(dropArea2, "enterEvents"), 0); + QCOMPARE(evaluate(dropArea2, "exitEvents"), 1); + + evaluate(dropArea1, "{ enterEvents = 0; exitEvents = 0 }"); + evaluate(dropArea2, "{ enterEvents = 0; exitEvents = 0 }"); + evaluate(dragItem2, "Drag.active = false"); + QCOMPARE(evaluate(dropArea1, "containsDrag"), false); + QCOMPARE(evaluate(dropArea1, "enterEvents"), 0); + QCOMPARE(evaluate(dropArea1, "exitEvents"), 0); + QCOMPARE(evaluate(dropArea2, "containsDrag"), false); + QCOMPARE(evaluate(dropArea2, "enterEvents"), 0); + QCOMPARE(evaluate(dropArea2, "exitEvents"), 0); + + // Different acceptance + evaluate(dragItem1, "Drag.keys = \"red\""); + evaluate(dragItem2, "Drag.keys = \"blue\""); + data.removeFormat("text/x-red"); + + evaluate(dropArea1, "{ enterEvents = 0; exitEvents = 0 }"); + evaluate(dropArea2, "{ enterEvents = 0; exitEvents = 0 }"); + evaluate(dragItem1, "Drag.active = true"); + QCOMPARE(evaluate(dropArea1, "containsDrag"), true); + QCOMPARE(evaluate(dropArea1, "enterEvents"), 1); + QCOMPARE(evaluate(dropArea1, "exitEvents"), 0); + QCOMPARE(evaluate(dropArea2, "containsDrag"), false); + QCOMPARE(evaluate(dropArea2, "enterEvents"), 0); + QCOMPARE(evaluate(dropArea2, "exitEvents"), 0); + + evaluate(dropArea1, "{ enterEvents = 0; exitEvents = 0 }"); + evaluate(dropArea2, "{ enterEvents = 0; exitEvents = 0 }"); + evaluate(dragItem2, "Drag.active = true"); + QCOMPARE(evaluate(dropArea1, "containsDrag"), true); + QCOMPARE(evaluate(dropArea1, "enterEvents"), 0); + QCOMPARE(evaluate(dropArea1, "exitEvents"), 0); + QCOMPARE(evaluate(dropArea2, "containsDrag"), true); + QCOMPARE(evaluate(dropArea2, "enterEvents"), 1); + QCOMPARE(evaluate(dropArea2, "exitEvents"), 0); + + evaluate(dropArea1, "{ enterEvents = 0; exitEvents = 0 }"); + evaluate(dropArea2, "{ enterEvents = 0; exitEvents = 0 }"); + evaluate(dragItem2, "Drag.active = false"); + QCOMPARE(evaluate(dropArea1, "containsDrag"), true); + QCOMPARE(evaluate(dropArea1, "enterEvents"), 0); + QCOMPARE(evaluate(dropArea1, "exitEvents"), 0); + QCOMPARE(evaluate(dropArea2, "containsDrag"), false); + QCOMPARE(evaluate(dropArea2, "enterEvents"), 0); + QCOMPARE(evaluate(dropArea2, "exitEvents"), 1); + + evaluate(dropArea1, "{ enterEvents = 0; exitEvents = 0 }"); + evaluate(dropArea2, "{ enterEvents = 0; exitEvents = 0 }"); + evaluate(dragItem2, "Drag.active = true"); + QCOMPARE(evaluate(dropArea1, "containsDrag"), true); + QCOMPARE(evaluate(dropArea1, "enterEvents"), 0); + QCOMPARE(evaluate(dropArea1, "exitEvents"), 0); + QCOMPARE(evaluate(dropArea2, "containsDrag"), true); + QCOMPARE(evaluate(dropArea2, "enterEvents"), 1); + QCOMPARE(evaluate(dropArea2, "exitEvents"), 0); + + evaluate(dropArea1, "{ enterEvents = 0; exitEvents = 0 }"); + evaluate(dropArea2, "{ enterEvents = 0; exitEvents = 0 }"); + evaluate(dragItem1, "Drag.active = false"); + QCOMPARE(evaluate(dropArea1, "containsDrag"), false); + QCOMPARE(evaluate(dropArea1, "enterEvents"), 0); + QCOMPARE(evaluate(dropArea1, "exitEvents"), 1); + QCOMPARE(evaluate(dropArea2, "containsDrag"), true); + QCOMPARE(evaluate(dropArea2, "enterEvents"), 0); + QCOMPARE(evaluate(dropArea2, "exitEvents"), 0); + + evaluate(dropArea1, "{ enterEvents = 0; exitEvents = 0 }"); + evaluate(dropArea2, "{ enterEvents = 0; exitEvents = 0 }"); + evaluate(dragItem2, "Drag.active = false"); + QCOMPARE(evaluate(dropArea1, "containsDrag"), false); + QCOMPARE(evaluate(dropArea1, "enterEvents"), 0); + QCOMPARE(evaluate(dropArea1, "exitEvents"), 0); + QCOMPARE(evaluate(dropArea2, "containsDrag"), false); + QCOMPARE(evaluate(dropArea2, "enterEvents"), 0); + QCOMPARE(evaluate(dropArea2, "exitEvents"), 1); + + // internal then external + evaluate(dropArea1, "{ enterEvents = 0; exitEvents = 0 }"); + evaluate(dropArea2, "{ enterEvents = 0; exitEvents = 0 }"); + evaluate(dragItem1, "Drag.active = true"); + QCOMPARE(evaluate(dropArea1, "containsDrag"), true); + QCOMPARE(evaluate(dropArea1, "enterEvents"), 1); + QCOMPARE(evaluate(dropArea1, "exitEvents"), 0); + QCOMPARE(evaluate(dropArea2, "containsDrag"), false); + QCOMPARE(evaluate(dropArea2, "enterEvents"), 0); + QCOMPARE(evaluate(dropArea2, "exitEvents"), 0); + + evaluate(dropArea1, "{ enterEvents = 0; exitEvents = 0 }"); + evaluate(dropArea2, "{ enterEvents = 0; exitEvents = 0 }"); + QWindowSystemInterface::handleDrag(&canvas, &data, QPoint(50, 50)); + QCOMPARE(evaluate(dropArea1, "containsDrag"), true); + QCOMPARE(evaluate(dropArea1, "enterEvents"), 0); + QCOMPARE(evaluate(dropArea1, "exitEvents"), 0); + QCOMPARE(evaluate(dropArea2, "containsDrag"), true); + QCOMPARE(evaluate(dropArea2, "enterEvents"), 1); + QCOMPARE(evaluate(dropArea2, "exitEvents"), 0); + + evaluate(dropArea1, "{ enterEvents = 0; exitEvents = 0 }"); + evaluate(dropArea2, "{ enterEvents = 0; exitEvents = 0 }"); + QWindowSystemInterface::handleDrag(&alternateCanvas, &data, QPoint(50, 50)); + QCOMPARE(evaluate(dropArea1, "containsDrag"), true); + QCOMPARE(evaluate(dropArea1, "enterEvents"), 0); + QCOMPARE(evaluate(dropArea1, "exitEvents"), 0); + QCOMPARE(evaluate(dropArea2, "containsDrag"), false); + QCOMPARE(evaluate(dropArea2, "enterEvents"), 0); + QCOMPARE(evaluate(dropArea2, "exitEvents"), 1); + + evaluate(dropArea1, "{ enterEvents = 0; exitEvents = 0 }"); + evaluate(dropArea2, "{ enterEvents = 0; exitEvents = 0 }"); + QWindowSystemInterface::handleDrag(&canvas, &data, QPoint(50, 50)); + QCOMPARE(evaluate(dropArea1, "containsDrag"), true); + QCOMPARE(evaluate(dropArea1, "enterEvents"), 0); + QCOMPARE(evaluate(dropArea1, "exitEvents"), 0); + QCOMPARE(evaluate(dropArea2, "containsDrag"), true); + QCOMPARE(evaluate(dropArea2, "enterEvents"), 1); + QCOMPARE(evaluate(dropArea2, "exitEvents"), 0); + + evaluate(dropArea1, "{ enterEvents = 0; exitEvents = 0 }"); + evaluate(dropArea2, "{ enterEvents = 0; exitEvents = 0 }"); + evaluate(dragItem1, "Drag.active = false"); + QCOMPARE(evaluate(dropArea1, "containsDrag"), false); + QCOMPARE(evaluate(dropArea1, "enterEvents"), 0); + QCOMPARE(evaluate(dropArea1, "exitEvents"), 1); + QCOMPARE(evaluate(dropArea2, "containsDrag"), true); + QCOMPARE(evaluate(dropArea2, "enterEvents"), 0); + QCOMPARE(evaluate(dropArea2, "exitEvents"), 0); + + evaluate(dropArea1, "{ enterEvents = 0; exitEvents = 0 }"); + evaluate(dropArea2, "{ enterEvents = 0; exitEvents = 0 }"); + QWindowSystemInterface::handleDrag(&alternateCanvas, &data, QPoint(50, 50)); + QCOMPARE(evaluate(dropArea1, "containsDrag"), false); + QCOMPARE(evaluate(dropArea1, "enterEvents"), 0); + QCOMPARE(evaluate(dropArea1, "exitEvents"), 0); + QCOMPARE(evaluate(dropArea2, "containsDrag"), false); + QCOMPARE(evaluate(dropArea2, "enterEvents"), 0); + QCOMPARE(evaluate(dropArea2, "exitEvents"), 1); + + QWindowSystemInterface::handleDrop(&alternateCanvas, &data, QPoint(50, 50)); +} + +QTEST_MAIN(tst_QQuickDropArea) + +#include "tst_qquickdroparea.moc" diff --git a/tests/auto/quick/qquickflickable/data/disabled.qml b/tests/auto/quick/qquickflickable/data/disabled.qml new file mode 100644 index 0000000000..9b679827c7 --- /dev/null +++ b/tests/auto/quick/qquickflickable/data/disabled.qml @@ -0,0 +1,30 @@ +import QtQuick 2.0 + +Rectangle { + id: root + width: 100; height: 100 + property bool clicked: false + + Flickable { + objectName: "flickable" + width: 100; height: 100 + contentWidth: column.width; contentHeight: column.height + enabled: false + + Column { + id: column + Repeater { + model: 4 + Rectangle { + width: 200; height: 300; color: "blue" + MouseArea { anchors.fill: parent; onClicked: { } } + } + } + } + } + + MouseArea { + width: 100; height: 30 + onClicked: root.clicked = true + } +} diff --git a/tests/auto/quick/qquickflickable/data/flickable01.qml b/tests/auto/quick/qquickflickable/data/flickable01.qml new file mode 100644 index 0000000000..cbec44bb4f --- /dev/null +++ b/tests/auto/quick/qquickflickable/data/flickable01.qml @@ -0,0 +1,4 @@ +import QtQuick 2.0 + +Flickable { +} diff --git a/tests/auto/quick/qquickflickable/data/flickable02.qml b/tests/auto/quick/qquickflickable/data/flickable02.qml new file mode 100644 index 0000000000..80caa32da5 --- /dev/null +++ b/tests/auto/quick/qquickflickable/data/flickable02.qml @@ -0,0 +1,14 @@ +import QtQuick 2.0 + +Flickable { + width: 100; height: 100 + contentWidth: row.width; contentHeight: row.height + + Row { + id: row + Repeater { + model: 4 + Rectangle { width: 200; height: 300; color: "blue" } + } + } +} diff --git a/tests/auto/quick/qquickflickable/data/flickable03.qml b/tests/auto/quick/qquickflickable/data/flickable03.qml new file mode 100644 index 0000000000..719c682ee6 --- /dev/null +++ b/tests/auto/quick/qquickflickable/data/flickable03.qml @@ -0,0 +1,14 @@ +import QtQuick 2.0 + +Flickable { + width: 100; height: 400 + contentWidth: column.width; contentHeight: column.height + + Column { + id: column + Repeater { + model: 20 + Rectangle { width: 200; height: 300; color: "blue" } + } + } +} diff --git a/tests/auto/quick/qquickflickable/data/flickable04.qml b/tests/auto/quick/qquickflickable/data/flickable04.qml new file mode 100644 index 0000000000..b2f30b84ec --- /dev/null +++ b/tests/auto/quick/qquickflickable/data/flickable04.qml @@ -0,0 +1,22 @@ +import QtQuick 2.0 + +Flickable { + property bool ok: false + function check() { + if (column.parent == contentItem) + ok = true; + } + + width: 100; height: 100 + contentWidth: column.width; contentHeight: column.height + pressDelay: 200; boundsBehavior: Flickable.StopAtBounds; interactive: false + maximumFlickVelocity: 2000 + + Column { + id: column + Repeater { + model: 4 + Rectangle { width: 200; height: 300; color: "blue" } + } + } +} diff --git a/tests/auto/quick/qquickflickable/data/flickableqgraphicswidget.qml b/tests/auto/quick/qquickflickable/data/flickableqgraphicswidget.qml new file mode 100644 index 0000000000..bb8f1eefc6 --- /dev/null +++ b/tests/auto/quick/qquickflickable/data/flickableqgraphicswidget.qml @@ -0,0 +1,7 @@ +import QtQuick 2.0 + +Flickable { + width: 100; height: 100 + + QGraphicsWidget { objectName: "widget1"; width: 200; height: 300 } +} diff --git a/tests/auto/quick/qquickflickable/data/margins.qml b/tests/auto/quick/qquickflickable/data/margins.qml new file mode 100644 index 0000000000..4866bd8301 --- /dev/null +++ b/tests/auto/quick/qquickflickable/data/margins.qml @@ -0,0 +1,19 @@ +import QtQuick 2.0 + +Flickable { + width: 200; height: 200 + contentWidth: row.width; contentHeight: row.height + + topMargin: 20 + bottomMargin: 30 + leftMargin: 40 + rightMargin: 50 + + Row { + id: row + Repeater { + model: 4 + Rectangle { width: 400; height: 600; color: "blue" } + } + } +} diff --git a/tests/auto/quick/qquickflickable/data/nestedPressDelay.qml b/tests/auto/quick/qquickflickable/data/nestedPressDelay.qml new file mode 100644 index 0000000000..60dadcc73c --- /dev/null +++ b/tests/auto/quick/qquickflickable/data/nestedPressDelay.qml @@ -0,0 +1,33 @@ +import QtQuick 2.0 + +Flickable { + property bool pressed: ma.pressed + width: 240 + height: 320 + contentWidth: 480 + contentHeight: 320 + flickableDirection: Flickable.HorizontalFlick + pressDelay: 50 + Flickable { + objectName: "innerFlickable" + flickableDirection: Flickable.VerticalFlick + width: 480 + height: 320 + contentWidth: 480 + contentHeight: 400 + pressDelay: 10000 + Rectangle { + y: 100 + anchors.horizontalCenter: parent.horizontalCenter + width: 240 + height: 100 + color: ma.pressed ? 'blue' : 'green' + MouseArea { + id: ma + objectName: "mouseArea" + anchors.fill: parent + } + } + } +} + diff --git a/tests/auto/quick/qquickflickable/data/resize.qml b/tests/auto/quick/qquickflickable/data/resize.qml new file mode 100644 index 0000000000..1a9ef54107 --- /dev/null +++ b/tests/auto/quick/qquickflickable/data/resize.qml @@ -0,0 +1,27 @@ +import QtQuick 2.0 + +Rectangle { + function resizeContent() { + flick.resizeContent(600, 600, Qt.point(100, 100)) + } + function returnToBounds() { + flick.returnToBounds() + } + width: 400 + height: 360 + color: "gray" + + Flickable { + id: flick + objectName: "flick" + anchors.fill: parent + contentWidth: 300 + contentHeight: 300 + + Rectangle { + width: flick.contentWidth + height: flick.contentHeight + color: "red" + } + } +} diff --git a/tests/auto/quick/qquickflickable/data/wheel.qml b/tests/auto/quick/qquickflickable/data/wheel.qml new file mode 100644 index 0000000000..2928bbcd72 --- /dev/null +++ b/tests/auto/quick/qquickflickable/data/wheel.qml @@ -0,0 +1,25 @@ +import QtQuick 2.0 + +Rectangle { + width: 400 + height: 400 + color: "gray" + + Flickable { + id: flick + objectName: "flick" + anchors.fill: parent + contentWidth: 800 + contentHeight: 800 + + Rectangle { + width: flick.contentWidth + height: flick.contentHeight + color: "red" + Rectangle { + width: 50; height: 50; color: "blue" + anchors.centerIn: parent + } + } + } +} diff --git a/tests/auto/quick/qquickflickable/qquickflickable.pro b/tests/auto/quick/qquickflickable/qquickflickable.pro new file mode 100644 index 0000000000..0ca03b2497 --- /dev/null +++ b/tests/auto/quick/qquickflickable/qquickflickable.pro @@ -0,0 +1,15 @@ +CONFIG += testcase +TARGET = tst_qquickflickable +macx:CONFIG -= app_bundle + +SOURCES += tst_qquickflickable.cpp + +include (../../shared/util.pri) +include (../shared/util.pri) + +testDataFiles.files = data +testDataFiles.path = . +DEPLOYMENT += testDataFiles + +CONFIG += parallel_test +QT += core-private gui-private v8-private qml-private quick-private testlib diff --git a/tests/auto/quick/qquickflickable/tst_qquickflickable.cpp b/tests/auto/quick/qquickflickable/tst_qquickflickable.cpp new file mode 100644 index 0000000000..e46659e6d0 --- /dev/null +++ b/tests/auto/quick/qquickflickable/tst_qquickflickable.cpp @@ -0,0 +1,663 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "../../shared/util.h" +#include "../shared/viewtestutil.h" +#include "../shared/visualtestutil.h" +#include + +using namespace QQuickViewTestUtil; +using namespace QQuickVisualTestUtil; + +class tst_qquickflickable : public QQmlDataTest +{ + Q_OBJECT +public: + +private slots: + void create(); + void horizontalViewportSize(); + void verticalViewportSize(); + void properties(); + void boundsBehavior(); + void maximumFlickVelocity(); + void flickDeceleration(); + void pressDelay(); + void nestedPressDelay(); + void flickableDirection(); + void resizeContent(); + void returnToBounds(); + void wheel(); + void movingAndDragging(); + void disabled(); + void flickVelocity(); + void margins(); + +private: + QQmlEngine engine; +}; + +void tst_qquickflickable::create() +{ + QQmlEngine engine; + QQmlComponent c(&engine, testFileUrl("flickable01.qml")); + QQuickFlickable *obj = qobject_cast(c.create()); + + QVERIFY(obj != 0); + QCOMPARE(obj->isAtXBeginning(), true); + QCOMPARE(obj->isAtXEnd(), false); + QCOMPARE(obj->isAtYBeginning(), true); + QCOMPARE(obj->isAtYEnd(), false); + QCOMPARE(obj->contentX(), 0.); + QCOMPARE(obj->contentY(), 0.); + + QCOMPARE(obj->horizontalVelocity(), 0.); + QCOMPARE(obj->verticalVelocity(), 0.); + + QCOMPARE(obj->isInteractive(), true); + QCOMPARE(obj->boundsBehavior(), QQuickFlickable::DragAndOvershootBounds); + QCOMPARE(obj->pressDelay(), 0); + QCOMPARE(obj->maximumFlickVelocity(), 2500.); + + delete obj; +} + +void tst_qquickflickable::horizontalViewportSize() +{ + QQmlEngine engine; + QQmlComponent c(&engine, testFileUrl("flickable02.qml")); + QQuickFlickable *obj = qobject_cast(c.create()); + + QVERIFY(obj != 0); + QCOMPARE(obj->contentWidth(), 800.); + QCOMPARE(obj->contentHeight(), 300.); + QCOMPARE(obj->isAtXBeginning(), true); + QCOMPARE(obj->isAtXEnd(), false); + QCOMPARE(obj->isAtYBeginning(), true); + QCOMPARE(obj->isAtYEnd(), false); + + delete obj; +} + +void tst_qquickflickable::verticalViewportSize() +{ + QQmlEngine engine; + QQmlComponent c(&engine, testFileUrl("flickable03.qml")); + QQuickFlickable *obj = qobject_cast(c.create()); + + QVERIFY(obj != 0); + QCOMPARE(obj->contentWidth(), 200.); + QCOMPARE(obj->contentHeight(), 6000.); + QCOMPARE(obj->isAtXBeginning(), true); + QCOMPARE(obj->isAtXEnd(), false); + QCOMPARE(obj->isAtYBeginning(), true); + QCOMPARE(obj->isAtYEnd(), false); + + delete obj; +} + +void tst_qquickflickable::properties() +{ + QQmlEngine engine; + QQmlComponent c(&engine, testFileUrl("flickable04.qml")); + QQuickFlickable *obj = qobject_cast(c.create()); + + QVERIFY(obj != 0); + QCOMPARE(obj->isInteractive(), false); + QCOMPARE(obj->boundsBehavior(), QQuickFlickable::StopAtBounds); + QCOMPARE(obj->pressDelay(), 200); + QCOMPARE(obj->maximumFlickVelocity(), 2000.); + + QVERIFY(obj->property("ok").toBool() == false); + QMetaObject::invokeMethod(obj, "check"); + QVERIFY(obj->property("ok").toBool() == true); + + delete obj; +} + +void tst_qquickflickable::boundsBehavior() +{ + QQmlComponent component(&engine); + component.setData("import QtQuick 2.0; Flickable { boundsBehavior: Flickable.StopAtBounds }", QUrl::fromLocalFile("")); + QQuickFlickable *flickable = qobject_cast(component.create()); + QSignalSpy spy(flickable, SIGNAL(boundsBehaviorChanged())); + + QVERIFY(flickable); + QVERIFY(flickable->boundsBehavior() == QQuickFlickable::StopAtBounds); + + flickable->setBoundsBehavior(QQuickFlickable::DragAndOvershootBounds); + QVERIFY(flickable->boundsBehavior() == QQuickFlickable::DragAndOvershootBounds); + QCOMPARE(spy.count(),1); + flickable->setBoundsBehavior(QQuickFlickable::DragAndOvershootBounds); + QCOMPARE(spy.count(),1); + + flickable->setBoundsBehavior(QQuickFlickable::DragOverBounds); + QVERIFY(flickable->boundsBehavior() == QQuickFlickable::DragOverBounds); + QCOMPARE(spy.count(),2); + flickable->setBoundsBehavior(QQuickFlickable::DragOverBounds); + QCOMPARE(spy.count(),2); + + flickable->setBoundsBehavior(QQuickFlickable::StopAtBounds); + QVERIFY(flickable->boundsBehavior() == QQuickFlickable::StopAtBounds); + QCOMPARE(spy.count(),3); + flickable->setBoundsBehavior(QQuickFlickable::StopAtBounds); + QCOMPARE(spy.count(),3); +} + +void tst_qquickflickable::maximumFlickVelocity() +{ + QQmlComponent component(&engine); + component.setData("import QtQuick 2.0; Flickable { maximumFlickVelocity: 1.0; }", QUrl::fromLocalFile("")); + QQuickFlickable *flickable = qobject_cast(component.create()); + QSignalSpy spy(flickable, SIGNAL(maximumFlickVelocityChanged())); + + QVERIFY(flickable); + QCOMPARE(flickable->maximumFlickVelocity(), 1.0); + + flickable->setMaximumFlickVelocity(2.0); + QCOMPARE(flickable->maximumFlickVelocity(), 2.0); + QCOMPARE(spy.count(),1); + flickable->setMaximumFlickVelocity(2.0); + QCOMPARE(spy.count(),1); +} + +void tst_qquickflickable::flickDeceleration() +{ + QQmlComponent component(&engine); + component.setData("import QtQuick 2.0; Flickable { flickDeceleration: 1.0; }", QUrl::fromLocalFile("")); + QQuickFlickable *flickable = qobject_cast(component.create()); + QSignalSpy spy(flickable, SIGNAL(flickDecelerationChanged())); + + QVERIFY(flickable); + QCOMPARE(flickable->flickDeceleration(), 1.0); + + flickable->setFlickDeceleration(2.0); + QCOMPARE(flickable->flickDeceleration(), 2.0); + QCOMPARE(spy.count(),1); + flickable->setFlickDeceleration(2.0); + QCOMPARE(spy.count(),1); +} + +void tst_qquickflickable::pressDelay() +{ + QQmlComponent component(&engine); + component.setData("import QtQuick 2.0; Flickable { pressDelay: 100; }", QUrl::fromLocalFile("")); + QQuickFlickable *flickable = qobject_cast(component.create()); + QSignalSpy spy(flickable, SIGNAL(pressDelayChanged())); + + QVERIFY(flickable); + QCOMPARE(flickable->pressDelay(), 100); + + flickable->setPressDelay(200); + QCOMPARE(flickable->pressDelay(), 200); + QCOMPARE(spy.count(),1); + flickable->setPressDelay(200); + QCOMPARE(spy.count(),1); +} + +// QTBUG-17361 +void tst_qquickflickable::nestedPressDelay() +{ + QQuickView *canvas = new QQuickView; + canvas->setSource(testFileUrl("nestedPressDelay.qml")); + canvas->show(); + canvas->requestActivateWindow(); + QVERIFY(canvas->rootObject() != 0); + + QQuickFlickable *outer = qobject_cast(canvas->rootObject()); + QVERIFY(outer != 0); + + QQuickFlickable *inner = canvas->rootObject()->findChild("innerFlickable"); + QVERIFY(inner != 0); + + QTest::mousePress(canvas, Qt::LeftButton, 0, QPoint(150, 150)); + // the MouseArea is not pressed immediately + QVERIFY(outer->property("pressed").toBool() == false); + + // The outer pressDelay will prevail (50ms, vs. 10sec) + // QTRY_VERIFY() has 5sec timeout, so will timeout well within 10sec. + QTRY_VERIFY(outer->property("pressed").toBool() == true); + + QTest::mouseRelease(canvas, Qt::LeftButton, 0, QPoint(150, 150)); + + delete canvas; +} + +void tst_qquickflickable::flickableDirection() +{ + QQmlComponent component(&engine); + component.setData("import QtQuick 2.0; Flickable { flickableDirection: Flickable.VerticalFlick; }", QUrl::fromLocalFile("")); + QQuickFlickable *flickable = qobject_cast(component.create()); + QSignalSpy spy(flickable, SIGNAL(flickableDirectionChanged())); + + QVERIFY(flickable); + QCOMPARE(flickable->flickableDirection(), QQuickFlickable::VerticalFlick); + + flickable->setFlickableDirection(QQuickFlickable::HorizontalAndVerticalFlick); + QCOMPARE(flickable->flickableDirection(), QQuickFlickable::HorizontalAndVerticalFlick); + QCOMPARE(spy.count(),1); + + flickable->setFlickableDirection(QQuickFlickable::AutoFlickDirection); + QCOMPARE(flickable->flickableDirection(), QQuickFlickable::AutoFlickDirection); + QCOMPARE(spy.count(),2); + + flickable->setFlickableDirection(QQuickFlickable::HorizontalFlick); + QCOMPARE(flickable->flickableDirection(), QQuickFlickable::HorizontalFlick); + QCOMPARE(spy.count(),3); + + flickable->setFlickableDirection(QQuickFlickable::HorizontalFlick); + QCOMPARE(flickable->flickableDirection(), QQuickFlickable::HorizontalFlick); + QCOMPARE(spy.count(),3); +} + +// QtQuick 1.1 +void tst_qquickflickable::resizeContent() +{ + QQmlEngine engine; + QQmlComponent c(&engine, testFileUrl("resize.qml")); + QQuickItem *root = qobject_cast(c.create()); + QQuickFlickable *obj = findItem(root, "flick"); + + QVERIFY(obj != 0); + QCOMPARE(obj->contentX(), 0.); + QCOMPARE(obj->contentY(), 0.); + QCOMPARE(obj->contentWidth(), 300.); + QCOMPARE(obj->contentHeight(), 300.); + + QMetaObject::invokeMethod(root, "resizeContent"); + + QCOMPARE(obj->contentX(), 100.); + QCOMPARE(obj->contentY(), 100.); + QCOMPARE(obj->contentWidth(), 600.); + QCOMPARE(obj->contentHeight(), 600.); + + delete root; +} + +// QtQuick 1.1 +void tst_qquickflickable::returnToBounds() +{ + QQmlEngine engine; + QQmlComponent c(&engine, testFileUrl("resize.qml")); + QQuickItem *root = qobject_cast(c.create()); + QQuickFlickable *obj = findItem(root, "flick"); + + QVERIFY(obj != 0); + QCOMPARE(obj->contentX(), 0.); + QCOMPARE(obj->contentY(), 0.); + QCOMPARE(obj->contentWidth(), 300.); + QCOMPARE(obj->contentHeight(), 300.); + + obj->setContentX(100); + obj->setContentY(400); + QTRY_COMPARE(obj->contentX(), 100.); + QTRY_COMPARE(obj->contentY(), 400.); + + QMetaObject::invokeMethod(root, "returnToBounds"); + + QTRY_COMPARE(obj->contentX(), 0.); + QTRY_COMPARE(obj->contentY(), 0.); + + delete root; +} + +void tst_qquickflickable::wheel() +{ + QQuickView *canvas = new QQuickView; + canvas->setSource(testFileUrl("wheel.qml")); + canvas->show(); + canvas->requestActivateWindow(); + QVERIFY(canvas->rootObject() != 0); + + QQuickFlickable *flick = canvas->rootObject()->findChild("flick"); + QVERIFY(flick != 0); + + { + QWheelEvent event(QPoint(200, 200), -120, Qt::NoButton, Qt::NoModifier, Qt::Vertical); + event.setAccepted(false); + QGuiApplication::sendEvent(canvas, &event); + } + + QTRY_VERIFY(flick->contentY() > 0); + QVERIFY(flick->contentX() == 0); + + flick->setContentY(0); + QVERIFY(flick->contentY() == 0); + + { + QWheelEvent event(QPoint(200, 200), -120, Qt::NoButton, Qt::NoModifier, Qt::Horizontal); + event.setAccepted(false); + QGuiApplication::sendEvent(canvas, &event); + } + + QTRY_VERIFY(flick->contentX() > 0); + QVERIFY(flick->contentY() == 0); + + delete canvas; +} + +void tst_qquickflickable::movingAndDragging() +{ + QQuickView *canvas = new QQuickView; + canvas->setSource(testFileUrl("flickable03.qml")); + canvas->show(); + canvas->requestActivateWindow(); + QTest::qWaitForWindowShown(canvas); + QVERIFY(canvas->rootObject() != 0); + + QQuickFlickable *flickable = qobject_cast(canvas->rootObject()); + QVERIFY(flickable != 0); + + QSignalSpy vDragSpy(flickable, SIGNAL(draggingVerticallyChanged())); + QSignalSpy hDragSpy(flickable, SIGNAL(draggingHorizontallyChanged())); + QSignalSpy dragSpy(flickable, SIGNAL(draggingChanged())); + QSignalSpy vMoveSpy(flickable, SIGNAL(movingVerticallyChanged())); + QSignalSpy hMoveSpy(flickable, SIGNAL(movingHorizontallyChanged())); + QSignalSpy moveSpy(flickable, SIGNAL(movingChanged())); + QSignalSpy dragStartSpy(flickable, SIGNAL(dragStarted())); + QSignalSpy dragEndSpy(flickable, SIGNAL(dragEnded())); + + //Vertical + QTest::mousePress(canvas, Qt::LeftButton, 0, QPoint(50, 90)); + + QTest::mouseMove(canvas, QPoint(50, 80)); + QTest::mouseMove(canvas, QPoint(50, 70)); + QTest::mouseMove(canvas, QPoint(50, 60)); + + QMouseEvent moveEvent(QEvent::MouseMove, QPoint(50, 80), Qt::LeftButton, Qt::LeftButton, 0); + + QVERIFY(!flickable->isDraggingHorizontally()); + QVERIFY(flickable->isDraggingVertically()); + QVERIFY(flickable->isDragging()); + QCOMPARE(vDragSpy.count(), 1); + QCOMPARE(dragSpy.count(), 1); + QCOMPARE(hDragSpy.count(), 0); + QCOMPARE(dragStartSpy.count(), 1); + QCOMPARE(dragEndSpy.count(), 0); + + QVERIFY(!flickable->isMovingHorizontally()); + QVERIFY(flickable->isMovingVertically()); + QVERIFY(flickable->isMoving()); + QCOMPARE(vMoveSpy.count(), 1); + QCOMPARE(moveSpy.count(), 1); + QCOMPARE(hMoveSpy.count(), 0); + + QTest::mouseRelease(canvas, Qt::LeftButton, 0, QPoint(50, 60)); + + QTRY_VERIFY(!flickable->isDraggingVertically()); + QVERIFY(!flickable->isDragging()); + QCOMPARE(vDragSpy.count(), 2); + QCOMPARE(dragSpy.count(), 2); + QCOMPARE(hDragSpy.count(), 0); + QCOMPARE(dragStartSpy.count(), 1); + QCOMPARE(dragEndSpy.count(), 1); + + // wait for any motion to end + QTRY_VERIFY(flickable->isMoving() == false); + + //Horizontal + vDragSpy.clear(); + hDragSpy.clear(); + dragSpy.clear(); + vMoveSpy.clear(); + hMoveSpy.clear(); + moveSpy.clear(); + dragStartSpy.clear(); + dragEndSpy.clear(); + + QTest::mousePress(canvas, Qt::LeftButton, 0, QPoint(90, 50)); + + QTest::mouseMove(canvas, QPoint(80, 50)); + QTest::mouseMove(canvas, QPoint(70, 50)); + QTest::mouseMove(canvas, QPoint(60, 50)); + + QVERIFY(!flickable->isDraggingVertically()); + QVERIFY(flickable->isDraggingHorizontally()); + QVERIFY(flickable->isDragging()); + QCOMPARE(vDragSpy.count(), 0); + QCOMPARE(dragSpy.count(), 1); + QCOMPARE(hDragSpy.count(), 1); + QCOMPARE(dragStartSpy.count(), 1); + QCOMPARE(dragEndSpy.count(), 0); + + QVERIFY(!flickable->isMovingVertically()); + QVERIFY(flickable->isMovingHorizontally()); + QVERIFY(flickable->isMoving()); + QCOMPARE(vMoveSpy.count(), 0); + QCOMPARE(moveSpy.count(), 1); + QCOMPARE(hMoveSpy.count(), 1); + + QTest::mouseRelease(canvas, Qt::LeftButton, 0, QPoint(60, 50)); + + QTRY_VERIFY(!flickable->isDraggingHorizontally()); + QVERIFY(!flickable->isDragging()); + QCOMPARE(vDragSpy.count(), 0); + QCOMPARE(dragSpy.count(), 2); + QCOMPARE(hDragSpy.count(), 2); + QCOMPARE(dragStartSpy.count(), 1); + QCOMPARE(dragEndSpy.count(), 1); + // Don't test moving because a flick could occur + +#ifdef Q_OS_MAC + QSKIP("Producing flicks on Mac CI impossible due to timing problems"); +#endif + + QTRY_VERIFY(!flickable->isMoving()); + + vMoveSpy.clear(); + hMoveSpy.clear(); + moveSpy.clear(); + QSignalSpy vFlickSpy(flickable, SIGNAL(flickingVerticallyChanged())); + QSignalSpy hFlickSpy(flickable, SIGNAL(flickingHorizontallyChanged())); + QSignalSpy flickSpy(flickable, SIGNAL(flickingChanged())); + + // flick then press while it is still moving + // flicking == false, moving == true; + flick(canvas, QPoint(20,190), QPoint(20, 50), 200); + QVERIFY(flickable->verticalVelocity() > 0.0); + QVERIFY(flickable->isFlicking()); + QVERIFY(flickable->isFlickingVertically()); + QVERIFY(!flickable->isFlickingHorizontally()); + QVERIFY(flickable->isMoving()); + QVERIFY(flickable->isMovingVertically()); + QVERIFY(!flickable->isMovingHorizontally()); + QCOMPARE(vMoveSpy.count(), 1); + QCOMPARE(hMoveSpy.count(), 0); + QCOMPARE(moveSpy.count(), 1); + QCOMPARE(vFlickSpy.count(), 1); + QCOMPARE(hFlickSpy.count(), 0); + QCOMPARE(flickSpy.count(), 1); + + QTest::mousePress(canvas, Qt::LeftButton, 0, QPoint(20, 50)); + QTRY_VERIFY(!flickable->isFlicking()); + QVERIFY(!flickable->isFlickingVertically()); + QVERIFY(flickable->isMoving()); + QVERIFY(flickable->isMovingVertically()); + + QTest::mouseRelease(canvas, Qt::LeftButton, 0, QPoint(20,50)); + QVERIFY(!flickable->isFlicking()); + QVERIFY(!flickable->isFlickingVertically()); + QTRY_VERIFY(!flickable->isMoving()); + QVERIFY(!flickable->isMovingVertically()); + + delete canvas; +} + +void tst_qquickflickable::disabled() +{ + QQuickView *canvas = new QQuickView; + canvas->setSource(testFileUrl("disabled.qml")); + canvas->show(); + canvas->requestActivateWindow(); + QVERIFY(canvas->rootObject() != 0); + + QQuickFlickable *flick = canvas->rootObject()->findChild("flickable"); + QVERIFY(flick != 0); + + QTest::mousePress(canvas, Qt::LeftButton, 0, QPoint(50, 90)); + + QTest::mouseMove(canvas, QPoint(50, 80)); + QTest::mouseMove(canvas, QPoint(50, 70)); + QTest::mouseMove(canvas, QPoint(50, 60)); + + QVERIFY(flick->isMoving() == false); + + QTest::mouseRelease(canvas, Qt::LeftButton, 0, QPoint(50, 60)); + + // verify that mouse clicks on other elements still work (QTBUG-20584) + QTest::mousePress(canvas, Qt::LeftButton, 0, QPoint(50, 10)); + QTest::mouseRelease(canvas, Qt::LeftButton, 0, QPoint(50, 10)); + + QTRY_VERIFY(canvas->rootObject()->property("clicked").toBool() == true); +} + +void tst_qquickflickable::flickVelocity() +{ +#ifdef Q_OS_MAC + QSKIP("Producing flicks on Mac CI impossible due to timing problems"); +#endif + + QQuickView *canvas = new QQuickView; + canvas->setSource(testFileUrl("flickable03.qml")); + canvas->show(); + canvas->requestActivateWindow(); + QVERIFY(canvas->rootObject() != 0); + + QQuickFlickable *flickable = qobject_cast(canvas->rootObject()); + QVERIFY(flickable != 0); + + // flick up + flick(canvas, QPoint(20,190), QPoint(20, 50), 200); + QVERIFY(flickable->verticalVelocity() > 0.0); + QTRY_VERIFY(flickable->verticalVelocity() == 0.0); + + // flick down + flick(canvas, QPoint(20,10), QPoint(20, 140), 200); + QVERIFY(flickable->verticalVelocity() < 0.0); + QTRY_VERIFY(flickable->verticalVelocity() == 0.0); + + // Flick multiple times and verify that flick acceleration is applied. + QQuickFlickablePrivate *fp = QQuickFlickablePrivate::get(flickable); + bool boosted = false; + for (int i = 0; i < 6; ++i) { + flick(canvas, QPoint(20,390), QPoint(20, 50), 200); + boosted |= fp->flickBoost > 1.0; + } + QVERIFY(boosted); + + // Flick in opposite direction -> boost cancelled. + flick(canvas, QPoint(20,10), QPoint(20, 340), 200); + QTRY_VERIFY(flickable->verticalVelocity() < 0.0); + QVERIFY(fp->flickBoost == 1.0); + + delete canvas; +} + +void tst_qquickflickable::margins() +{ + QQmlEngine engine; + QQmlComponent c(&engine, testFileUrl("margins.qml")); + QQuickItem *root = qobject_cast(c.create()); + QQuickFlickable *obj = qobject_cast(root); + QVERIFY(obj != 0); + + // starting state + QCOMPARE(obj->contentX(), -40.); + QCOMPARE(obj->contentY(), -20.); + QCOMPARE(obj->contentWidth(), 1600.); + QCOMPARE(obj->contentHeight(), 600.); + QCOMPARE(obj->xOrigin(), 0.); + QCOMPARE(obj->yOrigin(), 0.); + + // Reduce left margin + obj->setLeftMargin(30); + QTRY_COMPARE(obj->contentX(), -30.); + + // Reduce top margin + obj->setTopMargin(20); + QTRY_COMPARE(obj->contentY(), -20.); + + // position to the far right, including margin + obj->setContentX(1600 + 50 - obj->width()); + obj->returnToBounds(); + QTest::qWait(200); + QCOMPARE(obj->contentX(), 1600. + 50. - obj->width()); + + // position beyond the far right, including margin + obj->setContentX(1600 + 50 - obj->width() + 1.); + obj->returnToBounds(); + QTRY_COMPARE(obj->contentX(), 1600. + 50. - obj->width()); + + // Reduce right margin + obj->setRightMargin(40); + QTRY_COMPARE(obj->contentX(), 1600. + 40. - obj->width()); + QCOMPARE(obj->contentWidth(), 1600.); + + // position to the far bottom, including margin + obj->setContentY(600 + 30 - obj->height()); + obj->returnToBounds(); + QTest::qWait(200); + QCOMPARE(obj->contentY(), 600. + 30. - obj->height()); + + // position beyond the far bottom, including margin + obj->setContentY(600 + 30 - obj->height() + 1.); + obj->returnToBounds(); + QTRY_COMPARE(obj->contentY(), 600. + 30. - obj->height()); + + // Reduce bottom margin + obj->setBottomMargin(20); + QTRY_COMPARE(obj->contentY(), 600. + 20. - obj->height()); + QCOMPARE(obj->contentHeight(), 600.); + + delete root; +} + +QTEST_MAIN(tst_qquickflickable) + +#include "tst_qquickflickable.moc" diff --git a/tests/auto/quick/qquickflipable/data/crash.qml b/tests/auto/quick/qquickflipable/data/crash.qml new file mode 100644 index 0000000000..a0327918cb --- /dev/null +++ b/tests/auto/quick/qquickflipable/data/crash.qml @@ -0,0 +1,9 @@ +import QtQuick 2.0 + +Flipable { + transform: Rotation { + axis.y: 1 + axis.z: 0 + angle: 180 + } +} diff --git a/tests/auto/quick/qquickflipable/data/flipable-abort.qml b/tests/auto/quick/qquickflipable/data/flipable-abort.qml new file mode 100644 index 0000000000..90fc03a5f9 --- /dev/null +++ b/tests/auto/quick/qquickflipable/data/flipable-abort.qml @@ -0,0 +1,10 @@ +import QtQuick 2.0 + +Rectangle { + Flipable { + id: flipable + } + Rectangle { + visible: flipable.side == Flipable.Front + } +} diff --git a/tests/auto/quick/qquickflipable/data/test-flipable.qml b/tests/auto/quick/qquickflipable/data/test-flipable.qml new file mode 100644 index 0000000000..dff6d3fe39 --- /dev/null +++ b/tests/auto/quick/qquickflipable/data/test-flipable.qml @@ -0,0 +1,9 @@ +import QtQuick 2.0 + +Flipable { + id: flipable + width: 640; height: 480 + + front: Rectangle { anchors.fill: flipable } + back: Rectangle { anchors.fill: flipable } +} diff --git a/tests/auto/quick/qquickflipable/qquickflipable.pro b/tests/auto/quick/qquickflipable/qquickflipable.pro new file mode 100644 index 0000000000..ca98cbe279 --- /dev/null +++ b/tests/auto/quick/qquickflipable/qquickflipable.pro @@ -0,0 +1,15 @@ +CONFIG += testcase +TARGET = tst_qquickflipable +macx:CONFIG -= app_bundle + +SOURCES += tst_qquickflipable.cpp + +include (../../shared/util.pri) + +testDataFiles.files = data +testDataFiles.path = . +DEPLOYMENT += testDataFiles + +CONFIG += parallel_test + +QT += core-private gui-private v8-private qml-private quick-private testlib diff --git a/tests/auto/quick/qquickflipable/tst_qquickflipable.cpp b/tests/auto/quick/qquickflipable/tst_qquickflipable.cpp new file mode 100644 index 0000000000..2f399359ef --- /dev/null +++ b/tests/auto/quick/qquickflipable/tst_qquickflipable.cpp @@ -0,0 +1,135 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "../../shared/util.h" + +class tst_qquickflipable : public QQmlDataTest +{ + Q_OBJECT +public: + +private slots: + void create(); + void checkFrontAndBack(); + void setFrontAndBack(); + + // below here task issues + void QTBUG_9161_crash(); + void QTBUG_8474_qgv_abort(); + +private: + QQmlEngine engine; +}; + +void tst_qquickflipable::create() +{ + QQmlEngine engine; + QQmlComponent c(&engine, testFileUrl("test-flipable.qml")); + QQuickFlipable *obj = qobject_cast(c.create()); + + QVERIFY(obj != 0); + delete obj; +} + +void tst_qquickflipable::checkFrontAndBack() +{ + QQmlEngine engine; + QQmlComponent c(&engine, testFileUrl("test-flipable.qml")); + QQuickFlipable *obj = qobject_cast(c.create()); + + QVERIFY(obj != 0); + QVERIFY(obj->front() != 0); + QVERIFY(obj->back() != 0); + delete obj; +} + +void tst_qquickflipable::setFrontAndBack() +{ + QQmlEngine engine; + QQmlComponent c(&engine, testFileUrl("test-flipable.qml")); + QQuickFlipable *obj = qobject_cast(c.create()); + + QVERIFY(obj != 0); + QVERIFY(obj->front() != 0); + QVERIFY(obj->back() != 0); + + QString message = c.url().toString() + ":3:1: QML Flipable: front is a write-once property"; + QTest::ignoreMessage(QtWarningMsg, qPrintable(message)); + obj->setFront(new QQuickRectangle()); + + message = c.url().toString() + ":3:1: QML Flipable: back is a write-once property"; + QTest::ignoreMessage(QtWarningMsg, qPrintable(message)); + obj->setBack(new QQuickRectangle()); + delete obj; +} + +void tst_qquickflipable::QTBUG_9161_crash() +{ + QQuickView *canvas = new QQuickView; + canvas->setSource(testFileUrl("crash.qml")); + QQuickItem *root = canvas->rootObject(); + QVERIFY(root != 0); + canvas->show(); + delete canvas; +} + +void tst_qquickflipable::QTBUG_8474_qgv_abort() +{ + QQuickView *canvas = new QQuickView; + canvas->setSource(testFileUrl("flipable-abort.qml")); + QQuickItem *root = canvas->rootObject(); + QVERIFY(root != 0); + canvas->show(); + delete canvas; +} + +QTEST_MAIN(tst_qquickflipable) + +#include "tst_qquickflipable.moc" diff --git a/tests/auto/quick/qquickfocusscope/data/canvasFocus.qml b/tests/auto/quick/qquickfocusscope/data/canvasFocus.qml new file mode 100644 index 0000000000..7d8dac5a22 --- /dev/null +++ b/tests/auto/quick/qquickfocusscope/data/canvasFocus.qml @@ -0,0 +1,22 @@ +import QtQuick 2.0 + +Column { + FocusScope { + objectName: "scope1" + width: 20 ;height: 20 + focus: true + Rectangle { + objectName: "item1" + anchors.fill: parent + focus: true + } + } + FocusScope { + objectName: "scope2" + width: 20 ;height: 20 + Rectangle { + objectName: "item2" + anchors.fill: parent + } + } +} diff --git a/tests/auto/quick/qquickfocusscope/data/chain.qml b/tests/auto/quick/qquickfocusscope/data/chain.qml new file mode 100644 index 0000000000..4b96662318 --- /dev/null +++ b/tests/auto/quick/qquickfocusscope/data/chain.qml @@ -0,0 +1,28 @@ +import QtQuick 2.0 + +Rectangle { + id: root + width:300; height:400 + + property bool focus1: root.activeFocus + property bool focus2: item1.activeFocus + property bool focus3: fs1.activeFocus + property bool focus4: fs2.activeFocus + property bool focus5: theItem.activeFocus + + Item { + id: item1 + FocusScope { + id: fs1 + focus: true + FocusScope { + id: fs2 + focus: true + Item { + id: theItem + focus: true + } + } + } + } +} diff --git a/tests/auto/quick/qquickfocusscope/data/forceActiveFocus.qml b/tests/auto/quick/qquickfocusscope/data/forceActiveFocus.qml new file mode 100644 index 0000000000..74d2106888 --- /dev/null +++ b/tests/auto/quick/qquickfocusscope/data/forceActiveFocus.qml @@ -0,0 +1,26 @@ +import QtQuick 2.0 + +Rectangle { + objectName: "root" + FocusScope { + objectName: "scope" + Item { + objectName: "item-a1" + FocusScope { + objectName: "scope-a" + Item { + objectName: "item-a2" + } + } + } + Item { + objectName: "item-b1" + FocusScope { + objectName: "scope-b" + Item { + objectName: "item-b2" + } + } + } + } +} diff --git a/tests/auto/quick/qquickfocusscope/data/forcefocus.qml b/tests/auto/quick/qquickfocusscope/data/forcefocus.qml new file mode 100644 index 0000000000..f41582a951 --- /dev/null +++ b/tests/auto/quick/qquickfocusscope/data/forcefocus.qml @@ -0,0 +1,81 @@ +import QtQuick 2.0 + +Rectangle { + width: 800; height: 600 + + FocusScope { + focus: true + + FocusScope { + id: firstScope + objectName: "item0" + focus: true + + Rectangle { + height: 120; width: 420 + + color: "transparent" + border.width: 5; border.color: firstScope.activeFocus?"blue":"black" + + Rectangle { + id: item1; objectName: "item1" + x: 10; y: 10; width: 100; height: 100; color: "green" + border.width: 5; border.color: activeFocus?"blue":"black" + focus: true + + Rectangle { + width: 50; height: 50; anchors.centerIn: parent + color: parent.activeFocus?"red":"transparent" + } + } + + Rectangle { + id: item2; objectName: "item2" + x: 310; y: 10; width: 100; height: 100; color: "green" + border.width: 5; border.color: activeFocus?"blue":"black" + + Rectangle { + width: 50; height: 50; anchors.centerIn: parent + color: parent.activeFocus?"red":"transparent" + } + } + } + } + + FocusScope { + id: secondScope + objectName: "item3" + + Rectangle { + y: 160; height: 120; width: 420 + + color: "transparent" + border.width: 5; border.color: secondScope.activeFocus?"blue":"black" + + Rectangle { + id: item4; objectName: "item4" + x: 10; y: 10; width: 100; height: 100; color: "green" + border.width: 5; border.color: activeFocus?"blue":"black" + + Rectangle { + width: 50; height: 50; anchors.centerIn: parent + color: parent.activeFocus?"red":"transparent" + } + } + + Rectangle { + id: item5; objectName: "item5" + x: 310; y: 10; width: 100; height: 100; color: "green" + border.width: 5; border.color: activeFocus?"blue":"black" + + Rectangle { + width: 50; height: 50; anchors.centerIn: parent + color: parent.activeFocus?"red":"transparent" + } + } + } + } + } + Keys.onDigit4Pressed: item4.focus = true + Keys.onDigit5Pressed: item5.forceActiveFocus() +} diff --git a/tests/auto/quick/qquickfocusscope/data/qtBug13380.qml b/tests/auto/quick/qquickfocusscope/data/qtBug13380.qml new file mode 100644 index 0000000000..29de046b38 --- /dev/null +++ b/tests/auto/quick/qquickfocusscope/data/qtBug13380.qml @@ -0,0 +1,24 @@ +import QtQuick 2.0 + +Rectangle { + width: 400; height: 400 + + property bool showRect: false + onShowRectChanged: if (showRect) rect.visible = true + property bool noFocus: !fs2.activeFocus + + FocusScope { + id: fs1 + focus: true + } + Rectangle { + id: rect + visible: false + FocusScope { + id: fs2 + Rectangle { + focus: true + } + } + } +} diff --git a/tests/auto/quick/qquickfocusscope/data/signalEmission.qml b/tests/auto/quick/qquickfocusscope/data/signalEmission.qml new file mode 100644 index 0000000000..999a40c5ad --- /dev/null +++ b/tests/auto/quick/qquickfocusscope/data/signalEmission.qml @@ -0,0 +1,33 @@ +import QtQuick 2.0 + +Rectangle { + width: 200 + height: 200 + + FocusScope { + focus: true + Rectangle { + objectName: "item1" + color: "blue" + onFocusChanged: focus ? color = "red" : color = "blue" + } + Rectangle { + objectName: "item2" + color: "blue" + onFocusChanged: focus ? color = "red" : color = "blue" + } + } + + FocusScope { + Rectangle { + objectName: "item3" + color: "blue" + onFocusChanged: focus ? color = "red" : color = "blue" + } + Rectangle { + objectName: "item4" + color: "blue" + onFocusChanged: focus ? color = "red" : color = "blue" + } + } +} diff --git a/tests/auto/quick/qquickfocusscope/data/test.qml b/tests/auto/quick/qquickfocusscope/data/test.qml new file mode 100644 index 0000000000..67be29c3fb --- /dev/null +++ b/tests/auto/quick/qquickfocusscope/data/test.qml @@ -0,0 +1,77 @@ +import QtQuick 2.0 + +Rectangle { + color: "white" + width: 800 + height: 600 + + Keys.onDigit9Pressed: console.log("Error - Root") + + FocusScope { + id: myScope + objectName: "item0" + focus: true + + Keys.onDigit9Pressed: console.log("Error - FocusScope") + + Rectangle { + height: 120 + width: 420 + + color: "transparent" + border.width: 5 + border.color: myScope.activeFocus?"blue":"black" + + Rectangle { + id: item1; objectName: "item1" + x: 10; y: 10 + width: 100; height: 100; color: "green" + border.width: 5 + border.color: activeFocus?"blue":"black" + Keys.onDigit9Pressed: console.debug("Top Left"); + KeyNavigation.right: item2 + focus: true + + Rectangle { + width: 50; height: 50; anchors.centerIn: parent + color: parent.activeFocus?"red":"transparent" + } + } + + Rectangle { + id: item2; objectName: "item2" + x: 310; y: 10 + width: 100; height: 100; color: "green" + border.width: 5 + border.color: activeFocus?"blue":"black" + KeyNavigation.left: item1 + Keys.onDigit9Pressed: console.log("Top Right"); + + Rectangle { + width: 50; height: 50; anchors.centerIn: parent + color: parent.activeFocus?"red":"transparent" + } + } + } + KeyNavigation.down: item3 + } + + Text { x:100; y:170; text: "Blue border indicates scoped focus\nBlack border indicates NOT scoped focus\nRed box indicates active focus\nUse arrow keys to navigate\nPress \"9\" to print currently focused item" } + + Rectangle { + id: item3; objectName: "item3" + x: 10; y: 300 + width: 100; height: 100; color: "green" + border.width: 5 + border.color: activeFocus?"blue":"black" + + Keys.onDigit9Pressed: console.log("Bottom Left"); + KeyNavigation.up: myScope + + Rectangle { + width: 50; height: 50; anchors.centerIn: parent + color: parent.activeFocus?"red":"transparent" + } + } + +} diff --git a/tests/auto/quick/qquickfocusscope/data/test2.qml b/tests/auto/quick/qquickfocusscope/data/test2.qml new file mode 100644 index 0000000000..ad74f3e9f4 --- /dev/null +++ b/tests/auto/quick/qquickfocusscope/data/test2.qml @@ -0,0 +1,39 @@ +import QtQuick 2.0 + +Rectangle { + color: "white" + width: 800 + height: 600 + + Text { text: "All five rectangles should be red" } + + FocusScope { + y: 100 + focus: true; objectName: "item1" + Rectangle { width: 50; height: 50; color: parent.activeFocus?"red":"blue" } + + FocusScope { + y: 100 + focus: true; objectName: "item2" + Rectangle { width: 50; height: 50; color: parent.activeFocus?"red":"blue" } + + FocusScope { + y: 100 + focus: true; objectName: "item3" + Rectangle { width: 50; height: 50; color: parent.activeFocus?"red":"blue" } + + FocusScope { + y: 100 + focus: true; objectName: "item4" + Rectangle { width: 50; height: 50; color: parent.activeFocus?"red":"blue" } + + FocusScope { + y: 100 + focus: true; objectName: "item5" + Rectangle { width: 50; height: 50; color: parent.activeFocus?"red":"blue" } + } + } + } + } + } +} diff --git a/tests/auto/quick/qquickfocusscope/data/test3.qml b/tests/auto/quick/qquickfocusscope/data/test3.qml new file mode 100644 index 0000000000..537c30816e --- /dev/null +++ b/tests/auto/quick/qquickfocusscope/data/test3.qml @@ -0,0 +1,52 @@ +import QtQuick 2.0 + +Rectangle { + color: "white" + width: 800 + height: 600 + + ListModel { + id: model + ListElement { name: "1" } + ListElement { name: "2" } + ListElement { name: "3" } + ListElement { name: "4" } + ListElement { name: "5" } + ListElement { name: "6" } + ListElement { name: "7" } + ListElement { name: "8" } + ListElement { name: "9" } + } + + Component { + id: verticalDelegate + FocusScope { + id: root + width: 50; height: 50; + Keys.onDigit9Pressed: console.log("Error - " + name) + Rectangle { + focus: true + Keys.onDigit9Pressed: console.log(name) + width: 50; height: 50; + color: root.ListView.isCurrentItem?"red":"green" + Text { text: name; anchors.centerIn: parent } + } + } + } + + ListView { + width: 800; height: 50; orientation: "Horizontal" + focus: true + model: model + delegate: verticalDelegate + preferredHighlightBegin: 100 + preferredHighlightEnd: 100 + highlightRangeMode: "StrictlyEnforceRange" + } + + + Text { + y: 100; x: 50 + text: "Currently selected element should be red\nPressing \"9\" should print the number of the currently selected item\nBe sure to scroll all the way to the right, pause, and then all the way to the left." + } +} diff --git a/tests/auto/quick/qquickfocusscope/data/test4.qml b/tests/auto/quick/qquickfocusscope/data/test4.qml new file mode 100644 index 0000000000..0eea649f5d --- /dev/null +++ b/tests/auto/quick/qquickfocusscope/data/test4.qml @@ -0,0 +1,76 @@ +import QtQuick 2.0 + +Rectangle { + color: "white" + width: 800 + height: 600 + + Keys.onDigit9Pressed: console.log("Error - Root") + + FocusScope { + id: myScope + + Keys.onDigit9Pressed: console.log("Error - FocusScope") + + Rectangle { + objectName: "item0" + height: 120 + width: 420 + + color: "transparent" + border.width: 5 + border.color: myScope.activeFocus?"blue":"black" + + Rectangle { + id: item1; objectName: "item1" + x: 10; y: 10 + width: 100; height: 100; color: "green" + border.width: 5 + border.color: activeFocus?"blue":"black" + Keys.onDigit9Pressed: console.log("Error - Top Left"); + KeyNavigation.right: item2 + focus: true + + Rectangle { + width: 50; height: 50; anchors.centerIn: parent + color: parent.activeFocus?"red":"transparent" + } + } + + Rectangle { + id: item2; objectName: "item2" + x: 310; y: 10 + width: 100; height: 100; color: "green" + border.width: 5 + border.color: activeFocus?"blue":"black" + KeyNavigation.left: item1 + Keys.onDigit9Pressed: console.log("Error - Top Right"); + + Rectangle { + width: 50; height: 50; anchors.centerIn: parent + color: parent.activeFocus?"red":"transparent" + } + } + } + KeyNavigation.down: item3 + } + + Text { x:100; y:170; text: "There should be no blue borders, or red squares.\nPressing \"9\" should do nothing.\nArrow keys should have no effect." } + + Rectangle { + id: item3; objectName: "item3" + x: 10; y: 300 + width: 100; height: 100; color: "green" + border.width: 5 + border.color: activeFocus?"blue":"black" + + Keys.onDigit9Pressed: console.log("Error - Bottom Left"); + KeyNavigation.up: myScope + + Rectangle { + width: 50; height: 50; anchors.centerIn: parent + color: parent.activeFocus?"red":"transparent" + } + } + +} diff --git a/tests/auto/quick/qquickfocusscope/data/test5.qml b/tests/auto/quick/qquickfocusscope/data/test5.qml new file mode 100644 index 0000000000..9c37cd1303 --- /dev/null +++ b/tests/auto/quick/qquickfocusscope/data/test5.qml @@ -0,0 +1,84 @@ +import QtQuick 2.0 + +Rectangle { + color: "white" + width: 800 + height: 600 + + Keys.onReturnPressed: console.log("Error - Root") + + FocusScope { + id: myScope + objectName: "item0" + focus: true + + Keys.onReturnPressed: console.log("Error - FocusScope") + + Rectangle { + height: 120 + width: 420 + + color: "transparent" + border.width: 5 + border.color: myScope.activeFocus?"blue":"black" + + Rectangle { + x: 10; y: 10 + width: 100; height: 100; color: "green" + border.width: 5 + border.color: item1.activeFocus?"blue":"black" + } + + TextEdit { + id: item1; objectName: "item1" + x: 20; y: 20 + width: 90; height: 90 + color: "white" + font.pixelSize: 20 + Keys.onReturnPressed: console.log("Top Left"); + KeyNavigation.right: item2 + focus: true + wrapMode: TextEdit.WordWrap + text: "Box 1" + } + + Rectangle { + id: item2; objectName: "item2" + x: 310; y: 10 + width: 100; height: 100; color: "green" + border.width: 5 + border.color: activeFocus?"blue":"black" + KeyNavigation.left: item1 + Keys.onReturnPressed: console.log("Top Right"); + + Rectangle { + width: 50; height: 50; anchors.centerIn: parent + color: parent.activeFocus?"red":"transparent" + } + } + } + KeyNavigation.down: item3 + } + + Text { x:100; y:170; text: "Blue border indicates scoped focus\nBlack border indicates NOT scoped focus\nRed box or flashing cursor indicates active focus\nUse arrow keys to navigate\nPress Ctrl-Return to print currently focused item" } + + Rectangle { + x: 10; y: 300 + width: 100; height: 100; color: "green" + border.width: 5 + border.color: item3.activeFocus?"blue":"black" + } + + TextEdit { + id: item3; objectName: "item3" + x: 20; y: 310 + width: 90; height: 90 + color: "white" + font.pixelSize: 20 + text: "Box 3" + + Keys.onReturnPressed: console.log("Bottom Left"); + KeyNavigation.up: myScope + wrapMode: TextEdit.WordWrap + } +} diff --git a/tests/auto/quick/qquickfocusscope/qquickfocusscope.pro b/tests/auto/quick/qquickfocusscope/qquickfocusscope.pro new file mode 100644 index 0000000000..34de32b173 --- /dev/null +++ b/tests/auto/quick/qquickfocusscope/qquickfocusscope.pro @@ -0,0 +1,14 @@ +CONFIG += testcase +TARGET = tst_qquickfocusscope +SOURCES += tst_qquickfocusscope.cpp + +include (../../shared/util.pri) +include (../shared/util.pri) + +macx:CONFIG -= app_bundle + +testDataFiles.files = data +testDataFiles.path = . +DEPLOYMENT += testDataFiles + +QT += core-private gui-private qml-private quick-private testlib diff --git a/tests/auto/quick/qquickfocusscope/tst_qquickfocusscope.cpp b/tests/auto/quick/qquickfocusscope/tst_qquickfocusscope.cpp new file mode 100644 index 0000000000..3571392b17 --- /dev/null +++ b/tests/auto/quick/qquickfocusscope/tst_qquickfocusscope.cpp @@ -0,0 +1,636 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "../../shared/util.h" +#include "../shared/visualtestutil.h" + +using namespace QQuickVisualTestUtil; + +class tst_qquickfocusscope : public QQmlDataTest +{ + Q_OBJECT +public: + tst_qquickfocusscope() {} + +private slots: + void basic(); + void nested(); + void noFocus(); + void textEdit(); + void forceFocus(); + void noParentFocus(); + void signalEmission(); + void qtBug13380(); + void forceActiveFocus(); + void canvasFocus(); +}; + +void tst_qquickfocusscope::basic() +{ + QQuickView *view = new QQuickView; + view->setSource(testFileUrl("test.qml")); + + QQuickFocusScope *item0 = findItem(view->rootObject(), QLatin1String("item0")); + QQuickRectangle *item1 = findItem(view->rootObject(), QLatin1String("item1")); + QQuickRectangle *item2 = findItem(view->rootObject(), QLatin1String("item2")); + QQuickRectangle *item3 = findItem(view->rootObject(), QLatin1String("item3")); + QVERIFY(item0 != 0); + QVERIFY(item1 != 0); + QVERIFY(item2 != 0); + QVERIFY(item3 != 0); + + view->show(); + view->requestActivateWindow(); + + QTest::qWaitForWindowShown(view); + QTRY_VERIFY(view == qGuiApp->focusWindow()); + + QVERIFY(view->isTopLevel()); + QVERIFY(item0->hasActiveFocus() == true); + QVERIFY(item1->hasActiveFocus() == true); + QVERIFY(item2->hasActiveFocus() == false); + QVERIFY(item3->hasActiveFocus() == false); + + QTest::keyClick(view, Qt::Key_Right); + QTest::qWait(50); + QVERIFY(item0->hasActiveFocus() == true); + QVERIFY(item1->hasActiveFocus() == false); + QVERIFY(item2->hasActiveFocus() == true); + QVERIFY(item3->hasActiveFocus() == false); + + QTest::keyClick(view, Qt::Key_Down); + QTest::qWait(50); + QVERIFY(item0->hasActiveFocus() == false); + QVERIFY(item1->hasActiveFocus() == false); + QVERIFY(item2->hasActiveFocus() == false); + QVERIFY(item3->hasActiveFocus() == true); + + delete view; +} + +void tst_qquickfocusscope::nested() +{ + QQuickView *view = new QQuickView; + view->setSource(testFileUrl("test2.qml")); + + QQuickFocusScope *item1 = findItem(view->rootObject(), QLatin1String("item1")); + QQuickFocusScope *item2 = findItem(view->rootObject(), QLatin1String("item2")); + QQuickFocusScope *item3 = findItem(view->rootObject(), QLatin1String("item3")); + QQuickFocusScope *item4 = findItem(view->rootObject(), QLatin1String("item4")); + QQuickFocusScope *item5 = findItem(view->rootObject(), QLatin1String("item5")); + QVERIFY(item1 != 0); + QVERIFY(item2 != 0); + QVERIFY(item3 != 0); + QVERIFY(item4 != 0); + QVERIFY(item5 != 0); + + view->show(); + view->requestActivateWindow(); + + QTest::qWaitForWindowShown(view); + QTRY_VERIFY(view == qGuiApp->focusWindow()); + + QVERIFY(item1->hasActiveFocus() == true); + QVERIFY(item2->hasActiveFocus() == true); + QVERIFY(item3->hasActiveFocus() == true); + QVERIFY(item4->hasActiveFocus() == true); + QVERIFY(item5->hasActiveFocus() == true); + delete view; +} + +void tst_qquickfocusscope::noFocus() +{ + QQuickView *view = new QQuickView; + view->setSource(testFileUrl("test4.qml")); + + QQuickRectangle *item0 = findItem(view->rootObject(), QLatin1String("item0")); + QQuickRectangle *item1 = findItem(view->rootObject(), QLatin1String("item1")); + QQuickRectangle *item2 = findItem(view->rootObject(), QLatin1String("item2")); + QQuickRectangle *item3 = findItem(view->rootObject(), QLatin1String("item3")); + QVERIFY(item0 != 0); + QVERIFY(item1 != 0); + QVERIFY(item2 != 0); + QVERIFY(item3 != 0); + + view->show(); + view->requestActivateWindow(); + QTest::qWaitForWindowShown(view); + QTRY_VERIFY(view == qGuiApp->focusWindow()); + + QVERIFY(item0->hasActiveFocus() == false); + QVERIFY(item1->hasActiveFocus() == false); + QVERIFY(item2->hasActiveFocus() == false); + QVERIFY(item3->hasActiveFocus() == false); + + QTest::keyClick(view, Qt::Key_Right); + QVERIFY(item0->hasActiveFocus() == false); + QVERIFY(item1->hasActiveFocus() == false); + QVERIFY(item2->hasActiveFocus() == false); + QVERIFY(item3->hasActiveFocus() == false); + + QTest::keyClick(view, Qt::Key_Down); + QVERIFY(item0->hasActiveFocus() == false); + QVERIFY(item1->hasActiveFocus() == false); + QVERIFY(item2->hasActiveFocus() == false); + QVERIFY(item3->hasActiveFocus() == false); + + delete view; +} + +void tst_qquickfocusscope::textEdit() +{ + QQuickView *view = new QQuickView; + view->setSource(testFileUrl("test5.qml")); + + QQuickFocusScope *item0 = findItem(view->rootObject(), QLatin1String("item0")); + QQuickTextEdit *item1 = findItem(view->rootObject(), QLatin1String("item1")); + QQuickRectangle *item2 = findItem(view->rootObject(), QLatin1String("item2")); + QQuickTextEdit *item3 = findItem(view->rootObject(), QLatin1String("item3")); + QVERIFY(item0 != 0); + QVERIFY(item1 != 0); + QVERIFY(item2 != 0); + QVERIFY(item3 != 0); + + view->show(); + view->requestActivateWindow(); + + QTest::qWaitForWindowShown(view); + + QTRY_VERIFY(view == qGuiApp->focusWindow()); + QVERIFY(item0->hasActiveFocus() == true); + QVERIFY(item1->hasActiveFocus() == true); + QVERIFY(item2->hasActiveFocus() == false); + QVERIFY(item3->hasActiveFocus() == false); + + QTest::keyClick(view, Qt::Key_Right); + QVERIFY(item0->hasActiveFocus() == true); + QVERIFY(item1->hasActiveFocus() == true); + QVERIFY(item2->hasActiveFocus() == false); + QVERIFY(item3->hasActiveFocus() == false); + + QTest::keyClick(view, Qt::Key_Right); + QTest::keyClick(view, Qt::Key_Right); + QTest::keyClick(view, Qt::Key_Right); + QTest::keyClick(view, Qt::Key_Right); + QTest::keyClick(view, Qt::Key_Right); + QVERIFY(item0->hasActiveFocus() == true); + QVERIFY(item1->hasActiveFocus() == false); + QVERIFY(item2->hasActiveFocus() == true); + QVERIFY(item3->hasActiveFocus() == false); + + QTest::keyClick(view, Qt::Key_Down); + QVERIFY(item0->hasActiveFocus() == false); + QVERIFY(item1->hasActiveFocus() == false); + QVERIFY(item2->hasActiveFocus() == false); + QVERIFY(item3->hasActiveFocus() == true); + + delete view; +} + +void tst_qquickfocusscope::forceFocus() +{ + QQuickView *view = new QQuickView; + view->setSource(testFileUrl("forcefocus.qml")); + + QQuickFocusScope *item0 = findItem(view->rootObject(), QLatin1String("item0")); + QQuickRectangle *item1 = findItem(view->rootObject(), QLatin1String("item1")); + QQuickRectangle *item2 = findItem(view->rootObject(), QLatin1String("item2")); + QQuickFocusScope *item3 = findItem(view->rootObject(), QLatin1String("item3")); + QQuickRectangle *item4 = findItem(view->rootObject(), QLatin1String("item4")); + QQuickRectangle *item5 = findItem(view->rootObject(), QLatin1String("item5")); + QVERIFY(item0 != 0); + QVERIFY(item1 != 0); + QVERIFY(item2 != 0); + QVERIFY(item3 != 0); + QVERIFY(item4 != 0); + QVERIFY(item5 != 0); + + view->show(); + view->requestActivateWindow(); + QTest::qWaitForWindowShown(view); + QTRY_VERIFY(view == qGuiApp->focusWindow()); + + QVERIFY(item0->hasActiveFocus() == true); + QVERIFY(item1->hasActiveFocus() == true); + QVERIFY(item2->hasActiveFocus() == false); + QVERIFY(item3->hasActiveFocus() == false); + QVERIFY(item4->hasActiveFocus() == false); + QVERIFY(item5->hasActiveFocus() == false); + + QTest::keyClick(view, Qt::Key_4); + QVERIFY(item0->hasActiveFocus() == true); + QVERIFY(item1->hasActiveFocus() == true); + QVERIFY(item2->hasActiveFocus() == false); + QVERIFY(item3->hasActiveFocus() == false); + QVERIFY(item4->hasActiveFocus() == false); + QVERIFY(item5->hasActiveFocus() == false); + + QTest::keyClick(view, Qt::Key_5); + QVERIFY(item0->hasActiveFocus() == false); + QVERIFY(item1->hasActiveFocus() == false); + QVERIFY(item2->hasActiveFocus() == false); + QVERIFY(item3->hasActiveFocus() == true); + QVERIFY(item4->hasActiveFocus() == false); + QVERIFY(item5->hasActiveFocus() == true); + + delete view; +} + +void tst_qquickfocusscope::noParentFocus() +{ + QQuickView *view = new QQuickView; + view->setSource(testFileUrl("chain.qml")); + QVERIFY(view->rootObject()); + + view->show(); + view->requestActivateWindow(); + QTest::qWaitForWindowShown(view); + QTRY_VERIFY(view == qGuiApp->focusWindow()); + + QVERIFY(view->rootObject()->property("focus1") == false); + QVERIFY(view->rootObject()->property("focus2") == false); + QVERIFY(view->rootObject()->property("focus3") == true); + QVERIFY(view->rootObject()->property("focus4") == true); + QVERIFY(view->rootObject()->property("focus5") == true); + + delete view; +} + +void tst_qquickfocusscope::signalEmission() +{ + QQuickView *view = new QQuickView; + view->setSource(testFileUrl("signalEmission.qml")); + + QQuickRectangle *item1 = findItem(view->rootObject(), QLatin1String("item1")); + QQuickRectangle *item2 = findItem(view->rootObject(), QLatin1String("item2")); + QQuickRectangle *item3 = findItem(view->rootObject(), QLatin1String("item3")); + QQuickRectangle *item4 = findItem(view->rootObject(), QLatin1String("item4")); + QVERIFY(item1 != 0); + QVERIFY(item2 != 0); + QVERIFY(item3 != 0); + QVERIFY(item4 != 0); + + view->show(); + view->requestActivateWindow(); + + QTest::qWaitForWindowShown(view); + QTRY_VERIFY(view == qGuiApp->focusWindow()); + + QVariant blue(QColor("blue")); + QVariant red(QColor("red")); + + item1->setFocus(true); + QCOMPARE(item1->property("color"), red); + QCOMPARE(item2->property("color"), blue); + QCOMPARE(item3->property("color"), blue); + QCOMPARE(item4->property("color"), blue); + + item2->setFocus(true); + QCOMPARE(item1->property("color"), blue); + QCOMPARE(item2->property("color"), red); + QCOMPARE(item3->property("color"), blue); + QCOMPARE(item4->property("color"), blue); + + item3->setFocus(true); + QCOMPARE(item1->property("color"), blue); + QCOMPARE(item2->property("color"), red); + QCOMPARE(item3->property("color"), red); + QCOMPARE(item4->property("color"), blue); + + item4->setFocus(true); + QCOMPARE(item1->property("color"), blue); + QCOMPARE(item2->property("color"), red); + QCOMPARE(item3->property("color"), blue); + QCOMPARE(item4->property("color"), red); + + item4->setFocus(false); + QCOMPARE(item1->property("color"), blue); + QCOMPARE(item2->property("color"), red); + QCOMPARE(item3->property("color"), blue); + QCOMPARE(item4->property("color"), blue); + + delete view; +} + +void tst_qquickfocusscope::qtBug13380() +{ + QQuickView *view = new QQuickView; + view->setSource(testFileUrl("qtBug13380.qml")); + + view->show(); + QVERIFY(view->rootObject()); + view->requestActivateWindow(); + qApp->processEvents(); + + QTest::qWaitForWindowShown(view); + + QTRY_VERIFY(view == qGuiApp->focusWindow()); + QVERIFY(view->rootObject()->property("noFocus").toBool()); + + view->rootObject()->setProperty("showRect", true); + QVERIFY(view->rootObject()->property("noFocus").toBool()); + + delete view; +} + +void tst_qquickfocusscope::forceActiveFocus() +{ + QQuickView *view = new QQuickView; + view->setSource(testFileUrl("forceActiveFocus.qml")); + + view->show(); + view->requestActivateWindow(); + QTest::qWaitForWindowShown(view); + QTRY_VERIFY(view == qGuiApp->focusWindow()); + + QQuickItem *rootObject = view->rootObject(); + QVERIFY(rootObject); + + QQuickItem *scope = findItem(rootObject, QLatin1String("scope")); + QQuickItem *itemA1 = findItem(rootObject, QLatin1String("item-a1")); + QQuickItem *scopeA = findItem(rootObject, QLatin1String("scope-a")); + QQuickItem *itemA2 = findItem(rootObject, QLatin1String("item-a2")); + QQuickItem *itemB1 = findItem(rootObject, QLatin1String("item-b1")); + QQuickItem *scopeB = findItem(rootObject, QLatin1String("scope-b")); + QQuickItem *itemB2 = findItem(rootObject, QLatin1String("item-b2")); + + QVERIFY(scope); + QVERIFY(itemA1); + QVERIFY(scopeA); + QVERIFY(itemA2); + QVERIFY(itemB1); + QVERIFY(scopeB); + QVERIFY(itemB2); + + QSignalSpy rootSpy(rootObject, SIGNAL(activeFocusChanged(bool))); + QSignalSpy scopeSpy(scope, SIGNAL(activeFocusChanged(bool))); + QSignalSpy scopeASpy(scopeA, SIGNAL(activeFocusChanged(bool))); + QSignalSpy scopeBSpy(scopeB, SIGNAL(activeFocusChanged(bool))); + + // First, walk the focus from item-a1 down to item-a2 and back again + itemA1->forceActiveFocus(); + QVERIFY(itemA1->hasActiveFocus()); + QVERIFY(!rootObject->hasActiveFocus()); + QCOMPARE(rootSpy.count(), 0); + QCOMPARE(scopeSpy.count(), 1); + + scopeA->forceActiveFocus(); + QVERIFY(!itemA1->hasActiveFocus()); + QVERIFY(scopeA->hasActiveFocus()); + QCOMPARE(scopeASpy.count(), 1); + QCOMPARE(rootSpy.count(), 0); + QCOMPARE(scopeSpy.count(), 1); + + itemA2->forceActiveFocus(); + QVERIFY(!itemA1->hasActiveFocus()); + QVERIFY(itemA2->hasActiveFocus()); + QVERIFY(scopeA->hasActiveFocus()); + QCOMPARE(scopeASpy.count(), 1); + QCOMPARE(rootSpy.count(), 0); + QCOMPARE(scopeSpy.count(), 1); + + scopeA->forceActiveFocus(); + QVERIFY(!itemA1->hasActiveFocus()); + QVERIFY(itemA2->hasActiveFocus()); + QVERIFY(scopeA->hasActiveFocus()); + QCOMPARE(scopeASpy.count(), 1); + QCOMPARE(rootSpy.count(), 0); + QCOMPARE(scopeSpy.count(), 1); + + itemA1->forceActiveFocus(); + QVERIFY(itemA1->hasActiveFocus()); + QVERIFY(!scopeA->hasActiveFocus()); + QVERIFY(!itemA2->hasActiveFocus()); + QCOMPARE(scopeASpy.count(), 2); + QCOMPARE(rootSpy.count(), 0); + QCOMPARE(scopeSpy.count(), 1); + + // Then jump back and forth between branch 'a' and 'b' + itemB1->forceActiveFocus(); + QVERIFY(itemB1->hasActiveFocus()); + QCOMPARE(rootSpy.count(), 0); + QCOMPARE(scopeSpy.count(), 1); + + scopeA->forceActiveFocus(); + QVERIFY(!itemA1->hasActiveFocus()); + QVERIFY(!itemB1->hasActiveFocus()); + QVERIFY(scopeA->hasActiveFocus()); + QCOMPARE(scopeASpy.count(), 3); + QCOMPARE(rootSpy.count(), 0); + QCOMPARE(scopeSpy.count(), 1); + + scopeB->forceActiveFocus(); + QVERIFY(!scopeA->hasActiveFocus()); + QVERIFY(!itemB1->hasActiveFocus()); + QVERIFY(scopeB->hasActiveFocus()); + QCOMPARE(scopeASpy.count(), 4); + QCOMPARE(scopeBSpy.count(), 1); + QCOMPARE(rootSpy.count(), 0); + QCOMPARE(scopeSpy.count(), 1); + + itemA2->forceActiveFocus(); + QVERIFY(!scopeB->hasActiveFocus()); + QVERIFY(itemA2->hasActiveFocus()); + QCOMPARE(scopeASpy.count(), 5); + QCOMPARE(scopeBSpy.count(), 2); + QCOMPARE(rootSpy.count(), 0); + QCOMPARE(scopeSpy.count(), 1); + + itemB2->forceActiveFocus(); + QVERIFY(!itemA2->hasActiveFocus()); + QVERIFY(itemB2->hasActiveFocus()); + QCOMPARE(scopeASpy.count(), 6); + QCOMPARE(scopeBSpy.count(), 3); + QCOMPARE(rootSpy.count(), 0); + QCOMPARE(scopeSpy.count(), 1); + + delete view; +} + +void tst_qquickfocusscope::canvasFocus() +{ + QQuickView *view = new QQuickView; + view->setSource(testFileUrl("canvasFocus.qml")); + + QQuickView alternateView; + + QQuickItem *rootObject = view->rootObject(); + QVERIFY(rootObject); + + QQuickItem *rootItem = view->rootItem(); + QQuickItem *scope1 = findItem(rootObject, QLatin1String("scope1")); + QQuickItem *item1 = findItem(rootObject, QLatin1String("item1")); + QQuickItem *scope2 = findItem(rootObject, QLatin1String("scope2")); + QQuickItem *item2 = findItem(rootObject, QLatin1String("item2")); + + QVERIFY(scope1); + QVERIFY(item1); + QVERIFY(scope2); + QVERIFY(item2); + + QSignalSpy rootFocusSpy(rootItem, SIGNAL(focusChanged(bool))); + QSignalSpy scope1FocusSpy(scope1, SIGNAL(focusChanged(bool))); + QSignalSpy item1FocusSpy(item1, SIGNAL(focusChanged(bool))); + QSignalSpy scope2FocusSpy(scope2, SIGNAL(focusChanged(bool))); + QSignalSpy item2FocusSpy(item2, SIGNAL(focusChanged(bool))); + QSignalSpy rootActiveFocusSpy(rootItem, SIGNAL(activeFocusChanged(bool))); + QSignalSpy scope1ActiveFocusSpy(scope1, SIGNAL(activeFocusChanged(bool))); + QSignalSpy item1ActiveFocusSpy(item1, SIGNAL(activeFocusChanged(bool))); + QSignalSpy scope2ActiveFocusSpy(scope2, SIGNAL(activeFocusChanged(bool))); + QSignalSpy item2ActiveFocusSpy(item2, SIGNAL(activeFocusChanged(bool))); + + QEXPECT_FAIL("", "QTBUG-22415", Abort); + QCOMPARE(rootItem->hasFocus(), false); + QCOMPARE(rootItem->hasActiveFocus(), false); + QCOMPARE(scope1->hasFocus(), true); + QCOMPARE(scope1->hasActiveFocus(), false); + QCOMPARE(item1->hasFocus(), true); + QCOMPARE(item1->hasActiveFocus(), false); + QCOMPARE(scope2->hasFocus(), false); + QCOMPARE(scope2->hasActiveFocus(), false); + QCOMPARE(item2->hasFocus(), false); + QCOMPARE(item2->hasActiveFocus(), false); + + view->show(); + view->requestActivateWindow(); + + QTest::qWaitForWindowShown(view); + QTRY_VERIFY(view == qGuiApp->focusWindow()); + + // Now the canvas has focus, active focus given to item1 + QCOMPARE(rootItem->hasFocus(), true); + QCOMPARE(rootItem->hasActiveFocus(), true); + QCOMPARE(scope1->hasFocus(), true); + QCOMPARE(scope1->hasActiveFocus(), true); + QCOMPARE(item1->hasFocus(), true); + QCOMPARE(item1->hasActiveFocus(), true); + QCOMPARE(scope2->hasFocus(), false); + QCOMPARE(scope2->hasActiveFocus(), false); + QCOMPARE(item2->hasFocus(), false); + QCOMPARE(item2->hasActiveFocus(), false); + + QCOMPARE(rootFocusSpy.count(), 1); + QCOMPARE(rootActiveFocusSpy.count(), 1); + QCOMPARE(scope1FocusSpy.count(), 0); + QCOMPARE(scope1ActiveFocusSpy.count(), 1); + QCOMPARE(item1FocusSpy.count(), 0); + QCOMPARE(item1ActiveFocusSpy.count(), 1); + + + // view->hide(); // seemingly doesn't remove focus, so have an another view steal it. + alternateView.show(); + alternateView.requestActivateWindow(); + QTest::qWaitForWindowShown(&alternateView); + QTRY_VERIFY(QGuiApplication::focusWindow() == &alternateView); + + QCOMPARE(rootItem->hasFocus(), false); + QCOMPARE(rootItem->hasActiveFocus(), false); + QCOMPARE(scope1->hasFocus(), true); + QCOMPARE(scope1->hasActiveFocus(), false); + QCOMPARE(item1->hasFocus(), true); + QCOMPARE(item1->hasActiveFocus(), false); + + QCOMPARE(rootFocusSpy.count(), 2); + QCOMPARE(rootActiveFocusSpy.count(), 2); + QCOMPARE(scope1FocusSpy.count(), 0); + QCOMPARE(scope1ActiveFocusSpy.count(), 2); + QCOMPARE(item1FocusSpy.count(), 0); + QCOMPARE(item1ActiveFocusSpy.count(), 2); + + + // canvas does not have focus, so item2 will not get active focus + item2->forceActiveFocus(); + + QCOMPARE(rootItem->hasFocus(), false); + QCOMPARE(rootItem->hasActiveFocus(), false); + QCOMPARE(scope1->hasFocus(), false); + QCOMPARE(scope1->hasActiveFocus(), false); + QCOMPARE(item1->hasFocus(), true); + QCOMPARE(item1->hasActiveFocus(), false); + QCOMPARE(scope2->hasFocus(), true); + QCOMPARE(scope2->hasActiveFocus(), false); + QCOMPARE(item2->hasFocus(), true); + QCOMPARE(item2->hasActiveFocus(), false); + + QCOMPARE(rootFocusSpy.count(), 2); + QCOMPARE(rootActiveFocusSpy.count(), 2); + QCOMPARE(scope1FocusSpy.count(), 1); + QCOMPARE(scope1ActiveFocusSpy.count(), 2); + QCOMPARE(item1FocusSpy.count(), 0); + QCOMPARE(item1ActiveFocusSpy.count(), 2); + QCOMPARE(scope2FocusSpy.count(), 1); + QCOMPARE(scope2ActiveFocusSpy.count(), 0); + QCOMPARE(item2FocusSpy.count(), 1); + QCOMPARE(item2ActiveFocusSpy.count(), 0); + + // give the canvas focus, and item2 will get active focus + view->show(); + view->requestActivateWindow(); + QTest::qWaitForWindowShown(view); + QTRY_VERIFY(QGuiApplication::focusWindow() == view); + + QCOMPARE(rootItem->hasFocus(), true); + QCOMPARE(rootItem->hasActiveFocus(), true); + QCOMPARE(scope2->hasFocus(), true); + QCOMPARE(scope2->hasActiveFocus(), true); + QCOMPARE(item2->hasFocus(), true); + QCOMPARE(item2->hasActiveFocus(), true); + QCOMPARE(rootFocusSpy.count(), 3); + QCOMPARE(rootActiveFocusSpy.count(), 3); + QCOMPARE(scope2FocusSpy.count(), 1); + QCOMPARE(scope2ActiveFocusSpy.count(), 1); + QCOMPARE(item2FocusSpy.count(), 1); + QCOMPARE(item2ActiveFocusSpy.count(), 1); + + delete view; +} + +QTEST_MAIN(tst_qquickfocusscope) + +#include "tst_qquickfocusscope.moc" diff --git a/tests/auto/quick/qquickfontloader/data/daniel.ttf b/tests/auto/quick/qquickfontloader/data/daniel.ttf new file mode 100644 index 0000000000..aae50d5035 Binary files /dev/null and b/tests/auto/quick/qquickfontloader/data/daniel.ttf differ diff --git a/tests/auto/quick/qquickfontloader/data/dummy.ttf b/tests/auto/quick/qquickfontloader/data/dummy.ttf new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/auto/quick/qquickfontloader/data/qtbug-20268.qml b/tests/auto/quick/qquickfontloader/data/qtbug-20268.qml new file mode 100644 index 0000000000..0eafdfa17b --- /dev/null +++ b/tests/auto/quick/qquickfontloader/data/qtbug-20268.qml @@ -0,0 +1,27 @@ +import QtQuick 2.0 + +Rectangle { + id: test + property variant fontloader: fontloaderelement + height: 100; width: 100 + property bool usename: false + property int statenum: 1 + property alias name: fontloaderelement.name + property alias source: fontloaderelement.source + property alias status: fontloaderelement.status + + FontLoader { + id: fontloaderelement + } + + states: [ + State { name: "start"; when: !usename + PropertyChanges { target: fontloaderelement; source: "tarzeau_ocr_a.ttf" } + }, + State { name: "changefont"; when: usename + PropertyChanges { target: fontloaderelement; name: "Tahoma" } + } + ] + + Text { id: textelement; text: fontloaderelement.name; color: "black" } +} diff --git a/tests/auto/quick/qquickfontloader/data/tarzeau_ocr_a.ttf b/tests/auto/quick/qquickfontloader/data/tarzeau_ocr_a.ttf new file mode 100644 index 0000000000..cf93f9651f Binary files /dev/null and b/tests/auto/quick/qquickfontloader/data/tarzeau_ocr_a.ttf differ diff --git a/tests/auto/quick/qquickfontloader/qquickfontloader.pro b/tests/auto/quick/qquickfontloader/qquickfontloader.pro new file mode 100644 index 0000000000..7c34c43d04 --- /dev/null +++ b/tests/auto/quick/qquickfontloader/qquickfontloader.pro @@ -0,0 +1,17 @@ +CONFIG += testcase +TARGET = tst_qquickfontloader +macx:CONFIG -= app_bundle + +HEADERS += ../../shared/testhttpserver.h +SOURCES += tst_qquickfontloader.cpp \ + ../../shared/testhttpserver.cpp + +include (../../shared/util.pri) + +testDataFiles.files = data +testDataFiles.path = . +DEPLOYMENT += testDataFiles + +CONFIG += parallel_test + +QT += core-private gui-private qml-private quick-private network testlib diff --git a/tests/auto/quick/qquickfontloader/tst_qquickfontloader.cpp b/tests/auto/quick/qquickfontloader/tst_qquickfontloader.cpp new file mode 100644 index 0000000000..d8f368cf3e --- /dev/null +++ b/tests/auto/quick/qquickfontloader/tst_qquickfontloader.cpp @@ -0,0 +1,255 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include +#include +#include +#include +#include +#include +#include "../../shared/util.h" +#include "../../shared/testhttpserver.h" +#include +#include + +#define SERVER_PORT 14448 + +class tst_qquickfontloader : public QQmlDataTest +{ + Q_OBJECT +public: + tst_qquickfontloader(); + +private slots: + void initTestCase(); + void noFont(); + void namedFont(); + void localFont(); + void failLocalFont(); + void webFont(); + void redirWebFont(); + void failWebFont(); + void changeFont(); + void changeFontSourceViaState(); + +private: + QQmlEngine engine; + TestHTTPServer server; +}; + +tst_qquickfontloader::tst_qquickfontloader() : + server(SERVER_PORT) +{ +} + +void tst_qquickfontloader::initTestCase() +{ + QQmlDataTest::initTestCase(); + server.serveDirectory(dataDirectory()); + QVERIFY(server.isValid()); +} + +void tst_qquickfontloader::noFont() +{ + QString componentStr = "import QtQuick 2.0\nFontLoader { }"; + QQmlComponent component(&engine); + component.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); + QQuickFontLoader *fontObject = qobject_cast(component.create()); + + QVERIFY(fontObject != 0); + QCOMPARE(fontObject->name(), QString("")); + QCOMPARE(fontObject->source(), QUrl("")); + QTRY_VERIFY(fontObject->status() == QQuickFontLoader::Null); + + delete fontObject; +} + +void tst_qquickfontloader::namedFont() +{ + QString componentStr = "import QtQuick 2.0\nFontLoader { name: \"Helvetica\" }"; + QQmlComponent component(&engine); + component.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); + QQuickFontLoader *fontObject = qobject_cast(component.create()); + + QVERIFY(fontObject != 0); + QCOMPARE(fontObject->source(), QUrl("")); + QCOMPARE(fontObject->name(), QString("Helvetica")); + QTRY_VERIFY(fontObject->status() == QQuickFontLoader::Ready); +} + +void tst_qquickfontloader::localFont() +{ + QString componentStr = "import QtQuick 2.0\nFontLoader { source: \"" + testFile("tarzeau_ocr_a.ttf") + "\" }"; + QQmlComponent component(&engine); + component.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); + QQuickFontLoader *fontObject = qobject_cast(component.create()); + + QVERIFY(fontObject != 0); + QVERIFY(fontObject->source() != QUrl("")); + QTRY_COMPARE(fontObject->name(), QString("OCRA")); + QTRY_VERIFY(fontObject->status() == QQuickFontLoader::Ready); +} + +void tst_qquickfontloader::failLocalFont() +{ + QString componentStr = "import QtQuick 2.0\nFontLoader { source: \"" + testFileUrl("dummy.ttf").toString() + "\" }"; + QTest::ignoreMessage(QtWarningMsg, QString("file::2:1: QML FontLoader: Cannot load font: \"" + testFileUrl("dummy.ttf").toString() + "\"").toUtf8().constData()); + QQmlComponent component(&engine); + component.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); + QQuickFontLoader *fontObject = qobject_cast(component.create()); + + QVERIFY(fontObject != 0); + QVERIFY(fontObject->source() != QUrl("")); + QTRY_COMPARE(fontObject->name(), QString("")); + QTRY_VERIFY(fontObject->status() == QQuickFontLoader::Error); +} + +void tst_qquickfontloader::webFont() +{ + QString componentStr = "import QtQuick 2.0\nFontLoader { source: \"http://localhost:14448/tarzeau_ocr_a.ttf\" }"; + QQmlComponent component(&engine); + + component.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); + QQuickFontLoader *fontObject = qobject_cast(component.create()); + + QVERIFY(fontObject != 0); + QVERIFY(fontObject->source() != QUrl("")); + QTRY_COMPARE(fontObject->name(), QString("OCRA")); + QTRY_VERIFY(fontObject->status() == QQuickFontLoader::Ready); +} + +void tst_qquickfontloader::redirWebFont() +{ + server.addRedirect("olddir/oldname.ttf","../tarzeau_ocr_a.ttf"); + + QString componentStr = "import QtQuick 2.0\nFontLoader { source: \"http://localhost:14448/olddir/oldname.ttf\" }"; + QQmlComponent component(&engine); + + component.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); + QQuickFontLoader *fontObject = qobject_cast(component.create()); + + QVERIFY(fontObject != 0); + QVERIFY(fontObject->source() != QUrl("")); + QTRY_COMPARE(fontObject->name(), QString("OCRA")); + QTRY_VERIFY(fontObject->status() == QQuickFontLoader::Ready); +} + +void tst_qquickfontloader::failWebFont() +{ + QString componentStr = "import QtQuick 2.0\nFontLoader { source: \"http://localhost:14448/nonexist.ttf\" }"; + QTest::ignoreMessage(QtWarningMsg, "file::2:1: QML FontLoader: Cannot load font: \"http://localhost:14448/nonexist.ttf\""); + QQmlComponent component(&engine); + component.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); + QQuickFontLoader *fontObject = qobject_cast(component.create()); + + QVERIFY(fontObject != 0); + QVERIFY(fontObject->source() != QUrl("")); + QTRY_COMPARE(fontObject->name(), QString("")); + QTRY_VERIFY(fontObject->status() == QQuickFontLoader::Error); +} + +void tst_qquickfontloader::changeFont() +{ + QString componentStr = "import QtQuick 2.0\nFontLoader { source: font }"; + QQmlContext *ctxt = engine.rootContext(); + ctxt->setContextProperty("font", testFileUrl("tarzeau_ocr_a.ttf")); + QQmlComponent component(&engine); + component.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); + QQuickFontLoader *fontObject = qobject_cast(component.create()); + + QVERIFY(fontObject != 0); + + QSignalSpy nameSpy(fontObject, SIGNAL(nameChanged())); + QSignalSpy statusSpy(fontObject, SIGNAL(statusChanged())); + + QTRY_VERIFY(fontObject->status() == QQuickFontLoader::Ready); + QCOMPARE(nameSpy.count(), 0); + QCOMPARE(statusSpy.count(), 0); + QTRY_COMPARE(fontObject->name(), QString("OCRA")); + + ctxt->setContextProperty("font", "http://localhost:14448/daniel.ttf"); + QTRY_VERIFY(fontObject->status() == QQuickFontLoader::Loading); + QTRY_VERIFY(fontObject->status() == QQuickFontLoader::Ready); + QCOMPARE(nameSpy.count(), 1); + QCOMPARE(statusSpy.count(), 2); + QTRY_COMPARE(fontObject->name(), QString("Daniel")); + + ctxt->setContextProperty("font", testFileUrl("tarzeau_ocr_a.ttf")); + QTRY_VERIFY(fontObject->status() == QQuickFontLoader::Ready); + QCOMPARE(nameSpy.count(), 2); + QCOMPARE(statusSpy.count(), 2); + QTRY_COMPARE(fontObject->name(), QString("OCRA")); + + ctxt->setContextProperty("font", "http://localhost:14448/daniel.ttf"); + QTRY_VERIFY(fontObject->status() == QQuickFontLoader::Ready); + QCOMPARE(nameSpy.count(), 3); + QCOMPARE(statusSpy.count(), 2); + QTRY_COMPARE(fontObject->name(), QString("Daniel")); +} + +void tst_qquickfontloader::changeFontSourceViaState() +{ + QQuickView canvas(testFileUrl("qtbug-20268.qml")); + canvas.show(); + canvas.requestActivateWindow(); + QTest::qWaitForWindowShown(&canvas); + QTRY_COMPARE(&canvas, qGuiApp->focusWindow()); + + QQuickFontLoader *fontObject = qobject_cast(qvariant_cast(canvas.rootObject()->property("fontloader"))); + QVERIFY(fontObject != 0); + QTRY_VERIFY(fontObject->status() == QQuickFontLoader::Ready); + QVERIFY(fontObject->source() != QUrl("")); + QTRY_COMPARE(fontObject->name(), QString("OCRA")); + + canvas.rootObject()->setProperty("usename", true); + + // This warning should probably not be printed once QTBUG-20268 is fixed + QString warning = QString(testFileUrl("qtbug-20268.qml").toString()) + + QLatin1String(":13:5: QML FontLoader: Cannot load font: \"\""); + QTest::ignoreMessage(QtWarningMsg, qPrintable(warning)); + + QEXPECT_FAIL("", "QTBUG-20268", Abort); + QTRY_VERIFY(fontObject->status() == QQuickFontLoader::Ready); + QCOMPARE(canvas.rootObject()->property("name").toString(), QString("Tahoma")); +} + +QTEST_MAIN(tst_qquickfontloader) + +#include "tst_qquickfontloader.moc" diff --git a/tests/auto/quick/qquickgridview/data/ComponentView.qml b/tests/auto/quick/qquickgridview/data/ComponentView.qml new file mode 100644 index 0000000000..12ab6c92d1 --- /dev/null +++ b/tests/auto/quick/qquickgridview/data/ComponentView.qml @@ -0,0 +1,14 @@ +import QtQuick 2.0 + +GridView { + id: view + + property string title + + width: 100; height: 100; + + model: 1 + delegate: Text { objectName: "listItem"; text: view.title } + header: Text { objectName: "header"; text: view.title } + footer: Text { objectName: "footer"; text: view.title } +} diff --git a/tests/auto/quick/qquickgridview/data/addTransitions.qml b/tests/auto/quick/qquickgridview/data/addTransitions.qml new file mode 100644 index 0000000000..3f47cbd7b7 --- /dev/null +++ b/tests/auto/quick/qquickgridview/data/addTransitions.qml @@ -0,0 +1,129 @@ +import QtQuick 2.0 + +Rectangle { + id: root + width: 550 + height: 600 + + property int duration: 10 + property int count: grid.count + + Component { + id: myDelegate + + Rectangle { + id: wrapper + + property string nameData: name + + objectName: "wrapper" + width: 80 + height: 60 + border.width: 1 + Column { + Text { text: index } + Text { + text: wrapper.x + ", " + wrapper.y + } + Text { + id: textName + objectName: "textName" + text: name + } + } + color: GridView.isCurrentItem ? "lightsteelblue" : "white" + + onXChanged: checkPos() + onYChanged: checkPos() + + function checkPos() { + if (Qt.point(x, y) == targetItems_transitionFrom) + model_targetItems_transitionFrom.addItem(name, "") + if (Qt.point(x, y) == displacedItems_transitionVia) + model_displacedItems_transitionVia.addItem(name, "") + } + } + } + + GridView { + id: grid + + property int targetTransitionsDone + property int displaceTransitionsDone + + property var targetTrans_items: new Object() + property var targetTrans_targetIndexes: new Array() + property var targetTrans_targetItems: new Array() + + property var displacedTrans_items: new Object() + property var displacedTrans_targetIndexes: new Array() + property var displacedTrans_targetItems: new Array() + + objectName: "grid" + width: 240 + height: 320 + cellWidth: 80 + cellHeight: 60 + anchors.centerIn: parent + model: testModel + delegate: myDelegate + + // for QQmlListProperty types + function copyList(propList) { + var temp = new Array() + for (var i=0; iName: ' + name } + Text { text: 'Number: ' + number } + } + } + } + Component { + id: highlightRed + Rectangle { + color: "red" + radius: 10 + opacity: 0.5 + } + } + GridView { + cellWidth:180 + cellHeight:40 + objectName: "gridView" + anchors.fill: parent + model: listModel + delegate: delegate + highlight: highlightRed + focus: true + keyNavigationWraps: true + cacheBuffer: 10 + flow: GridView.LeftToRight + } + + data:[ + ListModel { + id: listModel + ListElement { + name: "Bill Smith" + number: "555 3264" + } + ListElement { + name: "John Brown" + number: "555 8426" + } + ListElement { + name: "Sam Wise" + number: "555 0473" + } + }, + ListModel { + objectName: "alternateModel" + ListElement { + name: "Jack" + number: "555 8426" + } + ListElement { + name: "Mary" + number: "555 3264" + } + } + ] +} + + diff --git a/tests/auto/quick/qquickgridview/data/removeTransitions.qml b/tests/auto/quick/qquickgridview/data/removeTransitions.qml new file mode 100644 index 0000000000..3e82cf7f96 --- /dev/null +++ b/tests/auto/quick/qquickgridview/data/removeTransitions.qml @@ -0,0 +1,146 @@ +import QtQuick 2.0 + +Rectangle { + id: root + width: 500 + height: 600 + + property int duration: 10 + property int count: grid.count + + Component { + id: myDelegate + Rectangle { + id: wrapper + + property string nameData: name + + objectName: "wrapper" + width: 80 + height: 60 + border.width: 1 + Column { + Text { text: index } + Text { + text: wrapper.x + ", " + wrapper.y + } + Text { + id: textName + objectName: "textName" + text: name + } + } + color: GridView.isCurrentItem ? "lightsteelblue" : "white" + + onXChanged: checkPos() + onYChanged: checkPos() + + function checkPos() { + if (Qt.point(x, y) == targetItems_transitionTo) { + model_targetItems_transitionTo.addItem(nameData, "") // name is invalid once model removes the item + } + if (Qt.point(x, y) == displacedItems_transitionVia) { + model_displacedItems_transitionVia.addItem(name, "") + } + } + } + } + + GridView { + id: grid + + property int targetTransitionsDone + property int displaceTransitionsDone + + property var targetTrans_items: new Object() + property var targetTrans_targetIndexes: new Array() + property var targetTrans_targetItems: new Array() + + property var displacedTrans_items: new Object() + property var displacedTrans_targetIndexes: new Array() + property var displacedTrans_targetItems: new Array() + + objectName: "grid" + width: 240 + height: 320 + cellWidth: 80 + cellHeight: 60 + anchors.centerIn: parent + model: testModel + delegate: myDelegate + + // for QQmlListProperty types + function copyList(propList) { + var temp = new Array() + for (var i=0; i +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "../../shared/util.h" +#include "../shared/viewtestutil.h" +#include "../shared/visualtestutil.h" +#include + +Q_DECLARE_METATYPE(Qt::LayoutDirection) +Q_DECLARE_METATYPE(QQuickGridView::Flow) + +using namespace QQuickViewTestUtil; +using namespace QQuickVisualTestUtil; + +class tst_QQuickGridView : public QQmlDataTest +{ + Q_OBJECT +public: + tst_QQuickGridView(); + +private slots: + void items(); + void changed(); + void inserted(); + void inserted_more(); + void inserted_more_data(); + void insertBeforeVisible(); + void insertBeforeVisible_data(); + void removed(); + void removed_more(); + void removed_more_data(); + void addOrRemoveBeforeVisible(); + void addOrRemoveBeforeVisible_data(); + void clear(); + void moved(); + void moved_data(); + void multipleChanges(); + void multipleChanges_data(); + void swapWithFirstItem(); + void changeFlow(); + void currentIndex(); + void noCurrentIndex(); + void defaultValues(); + void properties(); + void propertyChanges(); + void componentChanges(); + void modelChanges(); + void positionViewAtIndex(); + void positionViewAtIndex_rightToLeft(); + void mirroring(); + void snapping(); + void resetModel(); + void enforceRange(); + void enforceRange_rightToLeft(); + void QTBUG_8456(); + void manualHighlight(); + void footer(); + void footer_data(); + void header(); + void header_data(); + void resizeViewAndRepaint(); + void changeColumnCount(); + void indexAt_itemAt_data(); + void indexAt_itemAt(); + void onAdd(); + void onAdd_data(); + void onRemove(); + void onRemove_data(); + void columnCount(); + void margins(); + void creationContext(); + void snapToRow_data(); + void snapToRow(); + void snapOneRow_data(); + void snapOneRow(); + void unaligned(); + void cacheBuffer(); + void asynchronous(); + void unrequestedVisibility(); + + void populateTransitions(); + void populateTransitions_data(); + void addTransitions(); + void addTransitions_data(); + void moveTransitions(); + void moveTransitions_data(); + void removeTransitions(); + void removeTransitions_data(); + void multipleTransitions(); + void multipleTransitions_data(); + +private: + QList toIntList(const QVariantList &list); + void matchIndexLists(const QVariantList &indexLists, const QList &expectedIndexes); + void matchItemsAndIndexes(const QVariantMap &items, const QaimModel &model, const QList &expectedIndexes); + void matchItemLists(const QVariantList &itemLists, const QList &expectedItems); +}; + +tst_QQuickGridView::tst_QQuickGridView() +{ +} + +void tst_QQuickGridView::items() +{ + QQuickView *canvas = createView(); + + QaimModel model; + model.addItem("Fred", "12345"); + model.addItem("John", "2345"); + model.addItem("Bob", "54321"); + model.addItem("Billy", "22345"); + model.addItem("Sam", "2945"); + model.addItem("Ben", "04321"); + model.addItem("Jim", "0780"); + + QQmlContext *ctxt = canvas->rootContext(); + ctxt->setContextProperty("testModel", &model); + ctxt->setContextProperty("testRightToLeft", QVariant(false)); + ctxt->setContextProperty("testTopToBottom", QVariant(false)); + + canvas->setSource(testFileUrl("gridview1.qml")); + qApp->processEvents(); + + QQuickGridView *gridview = findItem(canvas->rootObject(), "grid"); + QTRY_VERIFY(gridview != 0); + + QQuickItem *contentItem = gridview->contentItem(); + QTRY_VERIFY(contentItem != 0); + + QTRY_COMPARE(gridview->count(), model.count()); + QTRY_COMPARE(canvas->rootObject()->property("count").toInt(), model.count()); + QTRY_COMPARE(contentItem->childItems().count(), model.count()+1); // assumes all are visible, +1 for the (default) highlight item + + for (int i = 0; i < model.count(); ++i) { + QQuickText *name = findItem(contentItem, "textName", i); + QTRY_VERIFY(name != 0); + QTRY_COMPARE(name->text(), model.name(i)); + QQuickText *number = findItem(contentItem, "textNumber", i); + QTRY_VERIFY(number != 0); + QTRY_COMPARE(number->text(), model.number(i)); + } + + // set an empty model and confirm that items are destroyed + QaimModel model2; + ctxt->setContextProperty("testModel", &model2); + + int itemCount = findItems(contentItem, "wrapper").count(); + QTRY_VERIFY(itemCount == 0); + + delete canvas; +} + +void tst_QQuickGridView::changed() +{ + QQuickView *canvas = createView(); + + QaimModel model; + model.addItem("Fred", "12345"); + model.addItem("John", "2345"); + model.addItem("Bob", "54321"); + model.addItem("Billy", "22345"); + model.addItem("Sam", "2945"); + model.addItem("Ben", "04321"); + model.addItem("Jim", "0780"); + + QQmlContext *ctxt = canvas->rootContext(); + ctxt->setContextProperty("testModel", &model); + ctxt->setContextProperty("testRightToLeft", QVariant(false)); + ctxt->setContextProperty("testTopToBottom", QVariant(false)); + + canvas->setSource(testFileUrl("gridview1.qml")); + qApp->processEvents(); + + QQuickFlickable *gridview = findItem(canvas->rootObject(), "grid"); + QTRY_VERIFY(gridview != 0); + + QQuickItem *contentItem = gridview->contentItem(); + QTRY_VERIFY(contentItem != 0); + + model.modifyItem(1, "Will", "9876"); + QQuickText *name = findItem(contentItem, "textName", 1); + QTRY_VERIFY(name != 0); + QTRY_COMPARE(name->text(), model.name(1)); + QQuickText *number = findItem(contentItem, "textNumber", 1); + QTRY_VERIFY(number != 0); + QTRY_COMPARE(number->text(), model.number(1)); + + delete canvas; +} + +void tst_QQuickGridView::inserted() +{ + QQuickView *canvas = createView(); + canvas->show(); + + QaimModel model; + model.addItem("Fred", "12345"); + model.addItem("John", "2345"); + model.addItem("Bob", "54321"); + + QQmlContext *ctxt = canvas->rootContext(); + ctxt->setContextProperty("testModel", &model); + ctxt->setContextProperty("testRightToLeft", QVariant(false)); + ctxt->setContextProperty("testTopToBottom", QVariant(false)); + + canvas->setSource(testFileUrl("gridview1.qml")); + qApp->processEvents(); + + QQuickGridView *gridview = findItem(canvas->rootObject(), "grid"); + QTRY_VERIFY(gridview != 0); + + QQuickItem *contentItem = gridview->contentItem(); + QTRY_VERIFY(contentItem != 0); + + model.insertItem(1, "Will", "9876"); + + QTRY_COMPARE(canvas->rootObject()->property("count").toInt(), model.count()); + QTRY_COMPARE(contentItem->childItems().count(), model.count()+1); // assumes all are visible, +1 for the (default) highlight item + + QQuickText *name = findItem(contentItem, "textName", 1); + QTRY_VERIFY(name != 0); + QTRY_COMPARE(name->text(), model.name(1)); + QQuickText *number = findItem(contentItem, "textNumber", 1); + QTRY_VERIFY(number != 0); + QTRY_COMPARE(number->text(), model.number(1)); + + // Checks that onAdd is called + int added = canvas->rootObject()->property("added").toInt(); + QTRY_COMPARE(added, 1); + + // Confirm items positioned correctly + for (int i = 0; i < model.count(); ++i) { + QQuickItem *item = findItem(contentItem, "wrapper", i); + QTRY_COMPARE(item->x(), (i%3)*80.0); + QTRY_COMPARE(item->y(), (i/3)*60.0); + } + + model.insertItem(0, "Foo", "1111"); // zero index, and current item + + QTRY_COMPARE(contentItem->childItems().count(), model.count()+1); // assumes all are visible, +1 for the (default) highlight item + + name = findItem(contentItem, "textName", 0); + QTRY_VERIFY(name != 0); + QTRY_COMPARE(name->text(), model.name(0)); + number = findItem(contentItem, "textNumber", 0); + QTRY_VERIFY(number != 0); + QTRY_COMPARE(number->text(), model.number(0)); + + QTRY_COMPARE(gridview->currentIndex(), 1); + + // Confirm items positioned correctly + for (int i = 0; i < model.count(); ++i) { + QQuickItem *item = findItem(contentItem, "wrapper", i); + QTRY_VERIFY(item->x() == (i%3)*80); + QTRY_VERIFY(item->y() == (i/3)*60); + } + + for (int i = model.count(); i < 30; ++i) + model.insertItem(i, "Hello", QString::number(i)); + + gridview->setContentY(120); + + // Insert item outside visible area + model.insertItem(1, "Hello", "1324"); + + QTRY_VERIFY(gridview->contentY() == 120); + + delete canvas; +} + +void tst_QQuickGridView::inserted_more() +{ + QFETCH(qreal, contentY); + QFETCH(int, insertIndex); + QFETCH(int, insertCount); + QFETCH(qreal, itemsOffsetAfterMove); + + QaimModel model; + for (int i = 0; i < 30; i++) + model.addItem("Item" + QString::number(i), ""); + + QQuickView *canvas = createView(); + QQmlContext *ctxt = canvas->rootContext(); + ctxt->setContextProperty("testModel", &model); + ctxt->setContextProperty("testRightToLeft", QVariant(false)); + ctxt->setContextProperty("testTopToBottom", QVariant(false)); + + canvas->setSource(testFileUrl("gridview1.qml")); + canvas->show(); + qApp->processEvents(); + + QQuickGridView *gridview = findItem(canvas->rootObject(), "grid"); + QTRY_VERIFY(gridview != 0); + QQuickItem *contentItem = gridview->contentItem(); + QTRY_VERIFY(contentItem != 0); + + gridview->setContentY(contentY); + QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false); + + QList > newData; + for (int i=0; iproperty("count").toInt(), model.count()); + + // check visibleItems.first() is in correct position + QQuickItem *item0 = findItem(contentItem, "wrapper", 0); + QVERIFY(item0); + QCOMPARE(item0->y(), 0.0); + + QList items = findItems(contentItem, "wrapper"); + int firstVisibleIndex = -1; + for (int i=0; iy() >= contentY) { + QQmlExpression e(qmlContext(items[i]), items[i], "index"); + firstVisibleIndex = e.evaluate().toInt(); + break; + } + } + QVERIFY2(firstVisibleIndex >= 0, QTest::toString(firstVisibleIndex)); + + // Confirm items positioned correctly and indexes correct + int itemCount = findItems(contentItem, "wrapper").count(); + QQuickText *name; + QQuickText *number; + for (int i = firstVisibleIndex; i < model.count() && i < itemCount; ++i) { + QQuickItem *item = findItem(contentItem, "wrapper", i); + QVERIFY2(item, QTest::toString(QString("Item %1 not found").arg(i))); + + QCOMPARE(item->x(), (i%3)*80.0); + QCOMPARE(item->y(), (i/3)*60.0 + itemsOffsetAfterMove); + + name = findItem(contentItem, "textName", i); + QVERIFY(name != 0); + QCOMPARE(name->text(), model.name(i)); + number = findItem(contentItem, "textNumber", i); + QVERIFY(number != 0); + QCOMPARE(number->text(), model.number(i)); + } + + delete canvas; +} + +void tst_QQuickGridView::inserted_more_data() +{ + QTest::addColumn("contentY"); + QTest::addColumn("insertIndex"); + QTest::addColumn("insertCount"); + QTest::addColumn("itemsOffsetAfterMove"); + + QTest::newRow("add 1, before visible items") + << 120.0 // show 6-23 + << 5 << 1 + << 0.0; // insert 1 above first visible, grid is rearranged; first visible moves forward within its row + // new 1st visible item is at 0 + + QTest::newRow("add 2, before visible items") + << 120.0 // show 6-23 + << 5 << 2 + << 0.0; // insert 2 above first visible, grid is rearranged; first visible moves forward within its row + + QTest::newRow("add 3, before visible items") + << 120.0 // show 6-23 + << 5 << 3 + << -60.0; // insert 3 (1 row) above first visible in negative pos, first visible does not move + + QTest::newRow("add 5, before visible items") + << 120.0 // show 6-23 + << 5 << 5 + << -60.0; // insert 1 row + 2 items above first visible, 1 row added at negative pos, + // grid is rearranged and first visible moves forward within its row + + QTest::newRow("add 6, before visible items") + << 120.0 // show 6-23 + << 5 << 6 + << -60.0 * 2; // insert 2 rows above first visible in negative pos, first visible does not move + + + + QTest::newRow("add 1, at start of visible, content at start") + << 0.0 + << 0 << 1 + << 0.0; + + QTest::newRow("add multiple, at start of visible, content at start") + << 0.0 + << 0 << 3 + << 0.0; + + QTest::newRow("add 1, at start of visible, content not at start") + << 120.0 // show 6-23 + << 6 << 1 + << 0.0; + + QTest::newRow("add multiple, at start of visible, content not at start") + << 120.0 // show 6-23 + << 6 << 3 + << 0.0; + + + QTest::newRow("add 1, at end of visible, content at start") + << 0.0 + << 17 << 1 + << 0.0; + + QTest::newRow("add 1, at end of visible, content at start") + << 0.0 + << 17 << 3 + << 0.0; + + QTest::newRow("add 1, at end of visible, content not at start") + << 120.0 // show 6-23 + << 23 << 1 + << 0.0; + + QTest::newRow("add multiple, at end of visible, content not at start") + << 120.0 // show 6-23 + << 23 << 3 + << 0.0; + + + QTest::newRow("add 1, after visible, content at start") + << 0.0 + << 20 << 1 + << 0.0; + + QTest::newRow("add 1, after visible, content at start") + << 0.0 + << 20 << 3 + << 0.0; + + QTest::newRow("add 1, after visible, content not at start") + << 120.0 // show 6-23 + << 24 << 1 + << 0.0; + + QTest::newRow("add multiple, after visible, content not at start") + << 120.0 // show 6-23 + << 24 << 3 + << 0.0; +} + +void tst_QQuickGridView::insertBeforeVisible() +{ + QFETCH(int, insertIndex); + QFETCH(int, insertCount); + QFETCH(int, cacheBuffer); + + QQuickText *name; + QQuickView *canvas = createView(); + + QaimModel model; + for (int i = 0; i < 30; i++) + model.addItem("Item" + QString::number(i), ""); + + QQmlContext *ctxt = canvas->rootContext(); + ctxt->setContextProperty("testModel", &model); + ctxt->setContextProperty("testRightToLeft", QVariant(false)); + ctxt->setContextProperty("testTopToBottom", QVariant(false)); + canvas->setSource(testFileUrl("gridview1.qml")); + canvas->show(); + qApp->processEvents(); + + QQuickGridView *gridview = findItem(canvas->rootObject(), "grid"); + QTRY_VERIFY(gridview != 0); + QQuickItem *contentItem = gridview->contentItem(); + QTRY_VERIFY(contentItem != 0); + + gridview->setCacheBuffer(cacheBuffer); + QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false); + + // trigger a refill (not just setting contentY) so that the visibleItems grid is updated + int firstVisibleIndex = 12; // move to an index where the top item is not visible + gridview->setContentY(firstVisibleIndex/3 * 60.0); + gridview->setCurrentIndex(firstVisibleIndex); + QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false); + + QTRY_COMPARE(gridview->currentIndex(), firstVisibleIndex); + QQuickItem *item = findItem(contentItem, "wrapper", firstVisibleIndex); + QVERIFY(item); + QCOMPARE(item->y(), gridview->contentY()); + + QList > newData; + for (int i=0; iproperty("count").toInt(), model.count()); + + // now, moving to the top of the view should position the inserted items correctly + int itemsOffsetAfterMove = (insertCount / 3) * -60.0; + gridview->setCurrentIndex(0); + QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false); + QTRY_COMPARE(gridview->currentIndex(), 0); + QTRY_COMPARE(gridview->contentY(), 0.0 + itemsOffsetAfterMove); + + // Confirm items positioned correctly and indexes correct + int itemCount = findItems(contentItem, "wrapper").count(); + for (int i = 0; i < model.count() && i < itemCount; ++i) { + item = findItem(contentItem, "wrapper", i); + QVERIFY2(item, QTest::toString(QString("Item %1 not found").arg(i))); + QCOMPARE(item->x(), (i%3)*80.0); + QCOMPARE(item->y(), (i/3)*60.0 + itemsOffsetAfterMove); + name = findItem(contentItem, "textName", i); + QVERIFY(name != 0); + QTRY_COMPARE(name->text(), model.name(i)); + } + + delete canvas; +} + +void tst_QQuickGridView::insertBeforeVisible_data() +{ + QTest::addColumn("insertIndex"); + QTest::addColumn("insertCount"); + QTest::addColumn("cacheBuffer"); + + QTest::newRow("insert 1 at 0, 0 buffer") << 0 << 1 << 0; + QTest::newRow("insert 1 at 0, 100 buffer") << 0 << 1 << 100; + QTest::newRow("insert 1 at 0, 500 buffer") << 0 << 1 << 500; + + QTest::newRow("insert 1 at 1, 0 buffer") << 1 << 1 << 0; + QTest::newRow("insert 1 at 1, 100 buffer") << 1 << 1 << 100; + QTest::newRow("insert 1 at 1, 500 buffer") << 1 << 1 << 500; + + QTest::newRow("insert multiple at 0, 0 buffer") << 0 << 6 << 0; + QTest::newRow("insert multiple at 0, 100 buffer") << 0 << 6 << 100; + QTest::newRow("insert multiple at 0, 500 buffer") << 0 << 6 << 500; + + QTest::newRow("insert multiple at 1, 0 buffer") << 1 << 6 << 0; + QTest::newRow("insert multiple at 1, 100 buffer") << 1 << 6 << 100; + QTest::newRow("insert multiple at 1, 500 buffer") << 1 << 6 << 500; +} + +void tst_QQuickGridView::removed() +{ + QQuickView *canvas = createView(); + canvas->show(); + + QaimModel model; + for (int i = 0; i < 40; i++) + model.addItem("Item" + QString::number(i), ""); + + QQmlContext *ctxt = canvas->rootContext(); + ctxt->setContextProperty("testModel", &model); + ctxt->setContextProperty("testRightToLeft", QVariant(false)); + ctxt->setContextProperty("testTopToBottom", QVariant(false)); + + canvas->setSource(testFileUrl("gridview1.qml")); + qApp->processEvents(); + + QQuickGridView *gridview = findItem(canvas->rootObject(), "grid"); + QTRY_VERIFY(gridview != 0); + QQuickItem *contentItem = gridview->contentItem(); + QTRY_VERIFY(contentItem != 0); + QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false); + + model.removeItem(1); + QTRY_COMPARE(canvas->rootObject()->property("count").toInt(), model.count()); + + QQuickText *name = findItem(contentItem, "textName", 1); + QTRY_VERIFY(name != 0); + QTRY_COMPARE(name->text(), model.name(1)); + QQuickText *number = findItem(contentItem, "textNumber", 1); + QTRY_VERIFY(number != 0); + QTRY_COMPARE(number->text(), model.number(1)); + + + // Checks that onRemove is called + QString removed = canvas->rootObject()->property("removed").toString(); + QTRY_COMPARE(removed, QString("Item1")); + + // Confirm items positioned correctly + int itemCount = findItems(contentItem, "wrapper").count(); + for (int i = 0; i < model.count() && i < itemCount; ++i) { + QQuickItem *item = findItem(contentItem, "wrapper", i); + if (!item) qWarning() << "Item" << i << "not found"; + QTRY_VERIFY(item->x() == (i%3)*80); + QTRY_VERIFY(item->y() == (i/3)*60); + } + + // Remove first item (which is the current item); + model.removeItem(0); + QTRY_COMPARE(canvas->rootObject()->property("count").toInt(), model.count()); + + name = findItem(contentItem, "textName", 0); + QTRY_VERIFY(name != 0); + QTRY_COMPARE(name->text(), model.name(0)); + number = findItem(contentItem, "textNumber", 0); + QTRY_VERIFY(number != 0); + QTRY_COMPARE(number->text(), model.number(0)); + + + // Confirm items positioned correctly + itemCount = findItems(contentItem, "wrapper").count(); + for (int i = 0; i < model.count() && i < itemCount; ++i) { + QQuickItem *item = findItem(contentItem, "wrapper", i); + if (!item) qWarning() << "Item" << i << "not found"; + QTRY_VERIFY(item->x() == (i%3)*80); + QTRY_VERIFY(item->y() == (i/3)*60); + } + + // Remove items not visible + model.removeItem(25); + QTRY_COMPARE(canvas->rootObject()->property("count").toInt(), model.count()); + + // Confirm items positioned correctly + itemCount = findItems(contentItem, "wrapper").count(); + for (int i = 0; i < model.count() && i < itemCount; ++i) { + QQuickItem *item = findItem(contentItem, "wrapper", i); + if (!item) qWarning() << "Item" << i << "not found"; + QTRY_VERIFY(item->x() == (i%3)*80); + QTRY_VERIFY(item->y() == (i/3)*60); + } + + // Remove items before visible + gridview->setContentY(120); + gridview->setCurrentIndex(10); + + // Setting currentIndex above shouldn't cause view to scroll + QTRY_COMPARE(gridview->contentY(), 120.0); + + model.removeItem(1); + QTRY_COMPARE(canvas->rootObject()->property("count").toInt(), model.count()); + + // Confirm items positioned correctly + for (int i = 6; i < 18; ++i) { + QQuickItem *item = findItem(contentItem, "wrapper", i); + if (!item) qWarning() << "Item" << i << "not found"; + QTRY_VERIFY(item->x() == (i%3)*80); + QTRY_VERIFY(item->y() == (i/3)*60); + } + + // Remove currentIndex + QQuickItem *oldCurrent = gridview->currentItem(); + model.removeItem(9); + QTRY_COMPARE(canvas->rootObject()->property("count").toInt(), model.count()); + + QTRY_COMPARE(gridview->currentIndex(), 9); + QTRY_VERIFY(gridview->currentItem() != oldCurrent); + + gridview->setContentY(0); + // let transitions settle. + QTest::qWait(300); + + // Confirm items positioned correctly + itemCount = findItems(contentItem, "wrapper").count(); + for (int i = 0; i < model.count() && i < itemCount; ++i) { + QQuickItem *item = findItem(contentItem, "wrapper", i); + QTRY_VERIFY(item->x() == (i%3)*80); + QTRY_VERIFY(item->y() == (i/3)*60); + } + + // remove item outside current view. + gridview->setCurrentIndex(32); + gridview->setContentY(240); + + model.removeItem(30); + QTRY_VERIFY(gridview->currentIndex() == 31); + + // remove current item beyond visible items. + gridview->setCurrentIndex(20); + gridview->setContentY(0); + model.removeItem(20); + + QTRY_COMPARE(gridview->currentIndex(), 20); + QTRY_VERIFY(gridview->currentItem() != 0); + + // remove item before current, but visible + gridview->setCurrentIndex(8); + gridview->setContentY(240); + oldCurrent = gridview->currentItem(); + model.removeItem(6); + + QTRY_COMPARE(gridview->currentIndex(), 7); + QTRY_VERIFY(gridview->currentItem() == oldCurrent); + + delete canvas; +} + +void tst_QQuickGridView::removed_more() +{ + QFETCH(qreal, contentY); + QFETCH(int, removeIndex); + QFETCH(int, removeCount); + QFETCH(qreal, itemsOffsetAfterMove); + QFETCH(QString, firstVisible); + + QQuickText *name; + QQuickText *number; + QQuickView *canvas = createView(); + + QaimModel model; + for (int i = 0; i < 30; i++) + model.addItem("Item" + QString::number(i), ""); + + QQmlContext *ctxt = canvas->rootContext(); + ctxt->setContextProperty("testModel", &model); + ctxt->setContextProperty("testRightToLeft", QVariant(false)); + ctxt->setContextProperty("testTopToBottom", QVariant(false)); + canvas->setSource(testFileUrl("gridview1.qml")); + canvas->show(); + qApp->processEvents(); + + QQuickGridView *gridview = findItem(canvas->rootObject(), "grid"); + QTRY_VERIFY(gridview != 0); + QQuickItem *contentItem = gridview->contentItem(); + QTRY_VERIFY(contentItem != 0); + + gridview->setContentY(contentY); + QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false); + + model.removeItems(removeIndex, removeCount); + QTRY_COMPARE(gridview->property("count").toInt(), model.count()); + + QString firstName; + int firstVisibleIndex = -1; + QList items = findItems(contentItem, "wrapper"); + for (int i=0; iy() >= contentY) { + QQmlExpression e(qmlContext(items[i]), items[i], "index"); + firstVisibleIndex = e.evaluate().toInt(); + QQmlExpression en(qmlContext(items[i]), items[i], "name"); + firstName = en.evaluate().toString(); + break; + } + } + QVERIFY2(firstVisibleIndex >= 0, QTest::toString(firstVisibleIndex)); + QCOMPARE(firstName, firstVisible); + + // Confirm items positioned correctly and indexes correct + int itemCount = findItems(contentItem, "wrapper").count(); + for (int i = firstVisibleIndex; i < model.count() && i < itemCount; ++i) { + QQuickItem *item = findItem(contentItem, "wrapper", i); + QVERIFY2(item, QTest::toString(QString("Item %1 not found").arg(i))); + + QTRY_COMPARE(item->x(), (i%3)*80.0); + QTRY_COMPARE(item->y(), (i/3)*60.0 + itemsOffsetAfterMove); + + name = findItem(contentItem, "textName", i); + QVERIFY(name != 0); + QTRY_COMPARE(name->text(), model.name(i)); + number = findItem(contentItem, "textNumber", i); + QVERIFY(number != 0); + QTRY_COMPARE(number->text(), model.number(i)); + } + + delete canvas; +} + +void tst_QQuickGridView::removed_more_data() +{ + QTest::addColumn("contentY"); + QTest::addColumn("removeIndex"); + QTest::addColumn("removeCount"); + QTest::addColumn("itemsOffsetAfterMove"); + QTest::addColumn("firstVisible"); + + QTest::newRow("remove 1, before visible items") + << 120.0 // show 6-23 + << 2 << 1 + << 0.0 << "Item7"; + + QTest::newRow("remove 1, before visible position") + << 120.0 // show 6-23 + << 3 << 1 + << 0.0 << "Item7"; + + QTest::newRow("remove multiple, all before visible items") + << 120.0 + << 1 << 3 + << 60.0 << "Item6"; // removed top row, slide down by 1 row + + QTest::newRow("remove multiple, all before visible items, remove item 0") + << 120.0 + << 0 << 4 + << 60.0 << "Item7"; // removed top row, slide down by 1 row + + QTest::newRow("remove multiple rows, all before visible items") + << 240.0 // show 12-29 + << 1 << 7 + << 120.0 << "Item13"; + + QTest::newRow("remove one row before visible, content y not on item border") + << 100.0 + << 0 << 3 + << 60.0 << "Item6"; // 1 row removed + + QTest::newRow("remove mix of visible/non-visible") + << 120.0 // show 6-23 + << 2 << 3 + << 60.0 << "Item6"; // 1 row removed + + + // remove 3,4,5 before the visible pos, first row moves down to just before the visible pos, + // items 6,7 are removed from view, item 8 slides up to original pos of item 6 (120px) + QTest::newRow("remove multiple, mix of items from before and within visible items") + << 120.0 + << 3 << 5 + << 60.0 << "Item8"; // adjust for the 1 row removed before the visible + + QTest::newRow("remove multiple, mix of items from before and within visible items, remove item 0") + << 120.0 + << 0 << 8 + << 60.0 * 2 << "Item8"; // adjust for the 2 rows removed before the visible + + + QTest::newRow("remove 1, from start of visible, content at start") + << 0.0 + << 0 << 1 + << 0.0 << "Item1"; + + QTest::newRow("remove multiple, from start of visible, content at start") + << 0.0 + << 0 << 3 + << 0.0 << "Item3"; + + QTest::newRow("remove 1, from start of visible, content not at start") + << 120.0 // show 6-23 + << 4 << 1 + << 0.0 << "Item7"; + + QTest::newRow("remove multiple, from start of visible, content not at start") + << 120.0 // show 6-23 + << 4 << 3 + << 0.0 << "Item9"; + + + QTest::newRow("remove 1, from middle of visible, content at start") + << 0.0 + << 10 << 1 + << 0.0 << "Item0"; + + QTest::newRow("remove multiple, from middle of visible, content at start") + << 0.0 + << 10 << 5 + << 0.0 << "Item0"; + + QTest::newRow("remove 1, from middle of visible, content not at start") + << 120.0 // show 6-23 + << 10 << 1 + << 0.0 << "Item6"; + + QTest::newRow("remove multiple, from middle of visible, content not at start") + << 120.0 // show 6-23 + << 10 << 5 + << 0.0 << "Item6"; + + + QTest::newRow("remove 1, after visible, content at start") + << 0.0 + << 16 << 1 + << 0.0 << "Item0"; + + QTest::newRow("remove multiple, after visible, content at start") + << 0.0 + << 16 << 5 + << 0.0 << "Item0"; + + QTest::newRow("remove 1, after visible, content not at start") + << 120.0 // show 6-23 + << 16+4 << 1 + << 0.0 << "Item6"; + + QTest::newRow("remove multiple, after visible, content not at start") + << 120.0 // show 6-23 + << 16+4 << 5 + << 0.0 << "Item6"; + + QTest::newRow("remove multiple, mix of items from within and after visible items") + << 120.0 // show 6-23 + << 20 << 5 + << 0.0 << "Item6"; +} + +void tst_QQuickGridView::addOrRemoveBeforeVisible() +{ + // QTBUG-21588: ensure re-layout is done on grid after adding or removing + // items from before the visible area + + QFETCH(bool, doAdd); + QFETCH(qreal, newTopContentY); + + QQuickView *canvas = createView(); + canvas->show(); + + QaimModel model; + for (int i = 0; i < 30; i++) + model.addItem("Item" + QString::number(i), ""); + + QQmlContext *ctxt = canvas->rootContext(); + ctxt->setContextProperty("testModel", &model); + ctxt->setContextProperty("testRightToLeft", QVariant(false)); + ctxt->setContextProperty("testTopToBottom", QVariant(false)); + canvas->setSource(testFileUrl("gridview1.qml")); + + QQuickGridView *gridview = findItem(canvas->rootObject(), "grid"); + QTRY_VERIFY(gridview != 0); + QQuickItem *contentItem = gridview->contentItem(); + QTRY_VERIFY(contentItem != 0); + + QQuickText *name = findItem(contentItem, "textName", 0); + QTRY_COMPARE(name->text(), QString("Item0")); + + gridview->setCurrentIndex(0); + qApp->processEvents(); + QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false); + + // scroll down until item 0 is no longer drawn + // (bug not triggered if we just move using content y, since that doesn't + // refill and change the visible items) + gridview->setCurrentIndex(24); + qApp->processEvents(); + + QTRY_COMPARE(gridview->currentIndex(), 24); + QTRY_COMPARE(gridview->contentY(), 220.0); + + QTest::qWait(100); // wait for refill to complete + QTRY_VERIFY(!findItem(contentItem, "wrapper", 0)); // 0 shouldn't be visible + + if (doAdd) { + model.insertItem(0, "New Item", "New Item number"); + QTRY_COMPARE(gridview->count(), 31); + } else { + model.removeItem(0); + QTRY_COMPARE(gridview->count(), 29); + } + + // scroll back up and item 0 should be gone + gridview->setCurrentIndex(0); + qApp->processEvents(); + QTRY_COMPARE(gridview->currentIndex(), 0); + QTRY_COMPARE(gridview->contentY(), newTopContentY); + + name = findItem(contentItem, "textName", 0); + if (doAdd) + QCOMPARE(name->text(), QString("New Item")); + else + QCOMPARE(name->text(), QString("Item1")); + + // Confirm items positioned correctly + int itemCount = findItems(contentItem, "wrapper").count(); + for (int i = 0; i < model.count() && i < itemCount; ++i) { + QTRY_VERIFY(findItem(contentItem, "wrapper", i)); + QQuickItem *item = findItem(contentItem, "wrapper", i); + QTRY_VERIFY(item->x() == (i%3)*80); + QTRY_VERIFY(item->y() == (i/3)*60 + newTopContentY); + } + + delete canvas; +} + +void tst_QQuickGridView::addOrRemoveBeforeVisible_data() +{ + QTest::addColumn("doAdd"); + QTest::addColumn("newTopContentY"); + + QTest::newRow("add") << true << -60.0; + QTest::newRow("remove") << false << -60.0; +} + +void tst_QQuickGridView::clear() +{ + QQuickView *canvas = createView(); + + QaimModel model; + for (int i = 0; i < 30; i++) + model.addItem("Item" + QString::number(i), ""); + + QQmlContext *ctxt = canvas->rootContext(); + ctxt->setContextProperty("testModel", &model); + ctxt->setContextProperty("testRightToLeft", QVariant(false)); + ctxt->setContextProperty("testTopToBottom", QVariant(false)); + + canvas->setSource(testFileUrl("gridview1.qml")); + canvas->show(); + qApp->processEvents(); + + QQuickGridView *gridview = findItem(canvas->rootObject(), "grid"); + QVERIFY(gridview != 0); + QQuickItem *contentItem = gridview->contentItem(); + QVERIFY(contentItem != 0); + QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false); + + model.clear(); + + QVERIFY(gridview->count() == 0); + QVERIFY(gridview->currentItem() == 0); + QVERIFY(gridview->contentY() == 0); + QVERIFY(gridview->currentIndex() == -1); + + // confirm sanity when adding an item to cleared list + model.addItem("New", "1"); + QTRY_COMPARE(gridview->count(), 1); + QVERIFY(gridview->currentItem() != 0); + QVERIFY(gridview->currentIndex() == 0); + + delete canvas; +} + +void tst_QQuickGridView::moved() +{ + QFETCH(qreal, contentY); + QFETCH(int, from); + QFETCH(int, to); + QFETCH(int, count); + QFETCH(qreal, itemsOffsetAfterMove); + + QQuickText *name; + QQuickText *number; + QScopedPointer canvas(createView()); + + QaimModel model; + for (int i = 0; i < 30; i++) + model.addItem("Item" + QString::number(i), ""); + + QQmlContext *ctxt = canvas->rootContext(); + ctxt->setContextProperty("testModel", &model); + ctxt->setContextProperty("testRightToLeft", QVariant(false)); + ctxt->setContextProperty("testTopToBottom", QVariant(false)); + + canvas->setSource(testFileUrl("gridview1.qml")); + canvas->show(); + qApp->processEvents(); + + QQuickGridView *gridview = findItem(canvas->rootObject(), "grid"); + QTRY_VERIFY(gridview != 0); + QQuickItem *contentItem = gridview->contentItem(); + QTRY_VERIFY(contentItem != 0); + QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false); + + QQuickItem *currentItem = gridview->currentItem(); + QTRY_VERIFY(currentItem != 0); + + if (contentY != 0) { + gridview->setContentY(contentY); + QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false); + } + + model.moveItems(from, to, count); + QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false); + + // Confirm items positioned correctly and indexes correct + int firstVisibleIndex = qCeil(contentY / 60.0) * 3; + int itemCount = findItems(contentItem, "wrapper").count(); + for (int i = firstVisibleIndex; i < model.count() && i < itemCount; ++i) { + if (i >= firstVisibleIndex + 18) // index has moved out of view + continue; + QQuickItem *item = findItem(contentItem, "wrapper", i); + QVERIFY2(item, QTest::toString(QString("Item %1 not found").arg(i))); + + QTRY_COMPARE(item->x(), (i%3)*80.0); + QTRY_COMPARE(item->y(), (i/3)*60.0 + itemsOffsetAfterMove); + + name = findItem(contentItem, "textName", i); + QVERIFY(name != 0); + QTRY_COMPARE(name->text(), model.name(i)); + number = findItem(contentItem, "textNumber", i); + QVERIFY(number != 0); + QTRY_COMPARE(number->text(), model.number(i)); + + // current index should have been updated + if (item == currentItem) + QTRY_COMPARE(gridview->currentIndex(), i); + } +} + +void tst_QQuickGridView::moved_data() +{ + QTest::addColumn("contentY"); + QTest::addColumn("from"); + QTest::addColumn("to"); + QTest::addColumn("count"); + QTest::addColumn("itemsOffsetAfterMove"); + + // model starts with 30 items, each 80x60, in area 240x320 + // 18 items should be visible at a time + + // The first visible item should not move upwards and out of the view + // if items are moved/removed before it. + + + QTest::newRow("move 1 forwards, within visible items") + << 0.0 + << 1 << 8 << 1 + << 0.0; + + QTest::newRow("move 1 forwards, from non-visible -> visible") + << 120.0 // show 6-23 + << 1 << 23 << 1 + << 0.0; + + QTest::newRow("move 1 forwards, from non-visible -> visible (move first item)") + << 120.0 // // show 6-23 + << 0 << 6 << 1 + << 0.0; + + QTest::newRow("move 1 forwards, from visible -> non-visible") + << 0.0 + << 1 << 20 << 1 + << 0.0; + + QTest::newRow("move 1 forwards, from visible -> non-visible (move first item)") + << 0.0 + << 0 << 20 << 1 + << 0.0; + + + QTest::newRow("move 1 backwards, within visible items") + << 0.0 + << 10 << 5 << 1 + << 0.0; + + QTest::newRow("move 1 backwards, within visible items (to first index)") + << 0.0 + << 10 << 0 << 1 + << 0.0; + + QTest::newRow("move 1 backwards, from non-visible -> visible") + << 0.0 + << 28 << 8 << 1 + << 0.0; + + QTest::newRow("move 1 backwards, from non-visible -> visible (move last item)") + << 0.0 + << 29 << 14 << 1 + << 0.0; + + QTest::newRow("move 1 backwards, from visible -> non-visible") + << 120.0 // show 6-23 + << 7 << 1 << 1 + << 0.0; // only 1 item moved back, so items shift accordingly and first row doesn't move + + QTest::newRow("move 1 backwards, from visible -> non-visible (move first item)") + << 120.0 // show 6-23 + << 7 << 0 << 1 + << 0.0; // only 1 item moved back, so items shift accordingly and first row doesn't move + + + QTest::newRow("move multiple forwards, within visible items") + << 0.0 + << 0 << 5 << 3 + << 0.0; + + QTest::newRow("move multiple backwards, within visible items (move first item)") + << 0.0 + << 10 << 0 << 3 + << 0.0; + + QTest::newRow("move multiple forwards, before visible items") + << 120.0 // show 6-23 + << 3 << 4 << 3 // 3, 4, 5 move to after 6 + << 60.0; // row of 3,4,5 has moved down + + QTest::newRow("move multiple forwards, from non-visible -> visible") + << 120.0 // show 6-23 + << 1 << 6 << 3 + << 60.0; // 1st row (it's above visible area) disappears, 0 drops down 1 row, first visible item (6) stays where it is + + QTest::newRow("move multiple forwards, from non-visible -> visible (move first item)") + << 120.0 // show 6-23 + << 0 << 6 << 3 + << 60.0; // top row moved and shifted to below 3rd row, all items should shift down by 1 row + + QTest::newRow("move multiple forwards, mix of non-visible/visible") + << 120.0 + << 3 << 16 << 6 + << 60.0; // top two rows removed, third row is now the first visible + + QTest::newRow("move multiple forwards, to bottom of view") + << 0.0 + << 5 << 13 << 5 + << 0.0; + + QTest::newRow("move multiple forwards, to bottom of view, first row -> last") + << 0.0 + << 0 << 15 << 3 + << 0.0; + + QTest::newRow("move multiple forwards, to bottom of view, content y not 0") + << 120.0 + << 5+4 << 13+4 << 5 + << 0.0; + + QTest::newRow("move multiple forwards, from visible -> non-visible") + << 0.0 + << 1 << 16 << 3 + << 0.0; + + QTest::newRow("move multiple forwards, from visible -> non-visible (move first item)") + << 0.0 + << 0 << 16 << 3 + << 0.0; + + + QTest::newRow("move multiple backwards, within visible items") + << 0.0 + << 4 << 1 << 3 + << 0.0; + + QTest::newRow("move multiple backwards, from non-visible -> visible") + << 0.0 + << 20 << 4 << 3 + << 0.0; + + QTest::newRow("move multiple backwards, from non-visible -> visible (move last item)") + << 0.0 + << 27 << 10 << 3 + << 0.0; + + QTest::newRow("move multiple backwards, from visible -> non-visible") + << 120.0 // show 6-23 + << 16 << 1 << 3 + << -60.0; // to minimize movement, items are added above visible area, all items move up by 1 row + + QTest::newRow("move multiple backwards, from visible -> non-visible (move first item)") + << 120.0 // show 6-23 + << 16 << 0 << 3 + << -60.0; // 16,17,18 move to above item 0, all items move up by 1 row +} + +void tst_QQuickGridView::multipleChanges() +{ + QFETCH(int, startCount); + QFETCH(QList, changes); + QFETCH(int, newCount); + QFETCH(int, newCurrentIndex); + + QQuickView *canvas = createView(); + + QaimModel model; + for (int i = 0; i < startCount; i++) + model.addItem("Item" + QString::number(i), ""); + + QQmlContext *ctxt = canvas->rootContext(); + ctxt->setContextProperty("testModel", &model); + ctxt->setContextProperty("testRightToLeft", QVariant(false)); + ctxt->setContextProperty("testTopToBottom", QVariant(false)); + + canvas->setSource(testFileUrl("gridview1.qml")); + canvas->show(); + qApp->processEvents(); + + QQuickGridView *gridview = findItem(canvas->rootObject(), "grid"); + QTRY_VERIFY(gridview != 0); + QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false); + + for (int i=0; i > items; + for (int j=changes[i].index; jpolishScheduled, false); + break; + case ListChange::Moved: + model.moveItems(changes[i].index, changes[i].to, changes[i].count); + QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false); + break; + case ListChange::SetCurrent: + gridview->setCurrentIndex(changes[i].index); + QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false); + break; + case ListChange::SetContentY: + gridview->setContentY(changes[i].pos); + QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false); + break; + } + } + + QTRY_COMPARE(gridview->count(), newCount); + QCOMPARE(gridview->count(), model.count()); + QTRY_COMPARE(gridview->currentIndex(), newCurrentIndex); + + QQuickText *name; + QQuickText *number; + QQuickItem *contentItem = gridview->contentItem(); + QTRY_VERIFY(contentItem != 0); + int itemCount = findItems(contentItem, "wrapper").count(); + for (int i=0; i < model.count() && i < itemCount; ++i) { + QQuickItem *item = findItem(contentItem, "wrapper", i); + QVERIFY2(item, QTest::toString(QString("Item %1 not found").arg(i))); + name = findItem(contentItem, "textName", i); + QVERIFY(name != 0); + QTRY_COMPARE(name->text(), model.name(i)); + number = findItem(contentItem, "textNumber", i); + QVERIFY(number != 0); + QTRY_COMPARE(number->text(), model.number(i)); + } + + delete canvas; +} + +void tst_QQuickGridView::multipleChanges_data() +{ + QTest::addColumn("startCount"); + QTest::addColumn >("changes"); + QTest::addColumn("newCount"); + QTest::addColumn("newCurrentIndex"); + + QList changes; + + for (int i=1; i<30; i++) + changes << ListChange::remove(0); + QTest::newRow("remove all but 1, first->last") << 30 << changes << 1 << 0; + + changes << ListChange::remove(0); + QTest::newRow("remove all") << 30 << changes << 0 << -1; + + changes.clear(); + changes << ListChange::setCurrent(29); + for (int i=29; i>0; i--) + changes << ListChange::remove(i); + QTest::newRow("remove last (current) -> first") << 30 << changes << 1 << 0; + + QTest::newRow("remove then insert at 0") << 10 << (QList() + << ListChange::remove(0, 1) + << ListChange::insert(0, 1) + ) << 10 << 1; + + QTest::newRow("remove then insert at non-zero index") << 10 << (QList() + << ListChange::setCurrent(2) + << ListChange::remove(2, 1) + << ListChange::insert(2, 1) + ) << 10 << 3; + + QTest::newRow("remove current then insert below it") << 10 << (QList() + << ListChange::setCurrent(1) + << ListChange::remove(1, 3) + << ListChange::insert(2, 2) + ) << 9 << 1; + + QTest::newRow("remove current index then move it down") << 10 << (QList() + << ListChange::setCurrent(2) + << ListChange::remove(1, 3) + << ListChange::move(1, 5, 1) + ) << 7 << 5; + + QTest::newRow("remove current index then move it up") << 10 << (QList() + << ListChange::setCurrent(5) + << ListChange::remove(4, 3) + << ListChange::move(4, 1, 1) + ) << 7 << 1; + + + QTest::newRow("insert multiple times") << 0 << (QList() + << ListChange::insert(0, 2) + << ListChange::insert(0, 4) + << ListChange::insert(0, 6) + ) << 12 << 10; + + QTest::newRow("insert multiple times with current index changes") << 0 << (QList() + << ListChange::insert(0, 2) + << ListChange::insert(0, 4) + << ListChange::insert(0, 6) + << ListChange::setCurrent(3) + << ListChange::insert(3, 2) + ) << 14 << 5; + + QTest::newRow("insert and remove all") << 0 << (QList() + << ListChange::insert(0, 30) + << ListChange::remove(0, 30) + ) << 0 << -1; + + QTest::newRow("insert and remove current") << 30 << (QList() + << ListChange::insert(1) + << ListChange::setCurrent(1) + << ListChange::remove(1) + ) << 30 << 1; + + QTest::newRow("insert before 0, then remove cross section of new and old items") << 10 << (QList() + << ListChange::insert(0, 10) + << ListChange::remove(5, 10) + ) << 10 << 5; + + QTest::newRow("insert multiple, then move new items to end") << 10 << (QList() + << ListChange::insert(0, 3) + << ListChange::move(0, 10, 3) + ) << 13 << 0; + + QTest::newRow("insert multiple, then move new and some old items to end") << 10 << (QList() + << ListChange::insert(0, 3) + << ListChange::move(0, 8, 5) + ) << 13 << 11; + + QTest::newRow("insert multiple at end, then move new and some old items to start") << 10 << (QList() + << ListChange::setCurrent(9) + << ListChange::insert(10, 3) + << ListChange::move(8, 0, 5) + ) << 13 << 1; + + + QTest::newRow("move back and forth to same index") << 10 << (QList() + << ListChange::setCurrent(1) + << ListChange::move(1, 2, 2) + << ListChange::move(2, 1, 2) + ) << 10 << 1; + + QTest::newRow("move forwards then back") << 10 << (QList() + << ListChange::setCurrent(2) + << ListChange::move(1, 2, 3) + << ListChange::move(3, 0, 5) + ) << 10 << 0; + + QTest::newRow("move current, then remove it") << 10 << (QList() + << ListChange::setCurrent(5) + << ListChange::move(5, 0, 1) + << ListChange::remove(0) + ) << 9 << 0; + + QTest::newRow("move current, then insert before it") << 10 << (QList() + << ListChange::setCurrent(5) + << ListChange::move(5, 0, 1) + << ListChange::insert(0) + ) << 11 << 1; + + QTest::newRow("move multiple, then remove them") << 10 << (QList() + << ListChange::setCurrent(1) + << ListChange::move(5, 1, 3) + << ListChange::remove(1, 3) + ) << 7 << 1; + + QTest::newRow("move multiple, then insert before them") << 10 << (QList() + << ListChange::setCurrent(5) + << ListChange::move(5, 1, 3) + << ListChange::insert(1, 5) + ) << 15 << 6; + + QTest::newRow("move multiple, then insert after them") << 10 << (QList() + << ListChange::setCurrent(3) + << ListChange::move(0, 1, 2) + << ListChange::insert(3, 5) + ) << 15 << 8; + + + QTest::newRow("clear current") << 0 << (QList() + << ListChange::insert(0, 5) + << ListChange::setCurrent(-1) + << ListChange::remove(0, 5) + << ListChange::insert(0, 5) + ) << 5 << -1; +} + + +void tst_QQuickGridView::swapWithFirstItem() +{ + // QTBUG_9697 + QQuickView *canvas = createView(); + + QaimModel model; + for (int i = 0; i < 30; i++) + model.addItem("Item" + QString::number(i), ""); + + QQmlContext *ctxt = canvas->rootContext(); + ctxt->setContextProperty("testModel", &model); + ctxt->setContextProperty("testRightToLeft", QVariant(false)); + ctxt->setContextProperty("testTopToBottom", QVariant(false)); + + canvas->setSource(testFileUrl("gridview1.qml")); + canvas->show(); + qApp->processEvents(); + + QQuickGridView *gridview = findItem(canvas->rootObject(), "grid"); + QTRY_VERIFY(gridview != 0); + + // ensure content position is stable + gridview->setContentY(0); + model.moveItem(10, 0); + QTRY_VERIFY(gridview->contentY() == 0); + + delete canvas; +} + +void tst_QQuickGridView::currentIndex() +{ + QaimModel model; + for (int i = 0; i < 60; i++) + model.addItem("Item" + QString::number(i), QString::number(i)); + + QQuickView *canvas = new QQuickView(0); + canvas->setGeometry(0,0,240,320); + canvas->show(); + + QQmlContext *ctxt = canvas->rootContext(); + ctxt->setContextProperty("testModel", &model); + + QString filename(testFile("gridview-initCurrent.qml")); + canvas->setSource(QUrl::fromLocalFile(filename)); + + qApp->processEvents(); + + QQuickGridView *gridview = findItem(canvas->rootObject(), "grid"); + QVERIFY(gridview != 0); + QTRY_VERIFY(!QQuickItemPrivate::get(gridview)->polishScheduled); + + QQuickItem *contentItem = gridview->contentItem(); + QVERIFY(contentItem != 0); + + // current item should be third item + QCOMPARE(gridview->currentIndex(), 35); + QCOMPARE(gridview->currentItem(), findItem(contentItem, "wrapper", 35)); + QCOMPARE(gridview->currentItem()->y(), gridview->highlightItem()->y()); + QCOMPARE(gridview->contentY(), 400.0); + + gridview->moveCurrentIndexRight(); + QCOMPARE(gridview->currentIndex(), 36); + gridview->moveCurrentIndexDown(); + QCOMPARE(gridview->currentIndex(), 39); + gridview->moveCurrentIndexUp(); + QCOMPARE(gridview->currentIndex(), 36); + gridview->moveCurrentIndexLeft(); + QCOMPARE(gridview->currentIndex(), 35); + + // wait until motion stops + QTRY_VERIFY(gridview->verticalVelocity() == 0.0); + + // no wrap + gridview->setCurrentIndex(0); + QCOMPARE(gridview->currentIndex(), 0); + // confirm that the velocity is updated + QTRY_VERIFY(gridview->verticalVelocity() != 0.0); + + gridview->moveCurrentIndexUp(); + QCOMPARE(gridview->currentIndex(), 0); + + gridview->moveCurrentIndexLeft(); + QCOMPARE(gridview->currentIndex(), 0); + + gridview->setCurrentIndex(model.count()-1); + QCOMPARE(gridview->currentIndex(), model.count()-1); + + gridview->moveCurrentIndexRight(); + QCOMPARE(gridview->currentIndex(), model.count()-1); + + gridview->moveCurrentIndexDown(); + QCOMPARE(gridview->currentIndex(), model.count()-1); + + // with wrap + gridview->setWrapEnabled(true); + + gridview->setCurrentIndex(0); + QCOMPARE(gridview->currentIndex(), 0); + + gridview->moveCurrentIndexLeft(); + QCOMPARE(gridview->currentIndex(), model.count()-1); + + qApp->processEvents(); + QTRY_COMPARE(gridview->contentY(), 880.0); + + gridview->moveCurrentIndexRight(); + QCOMPARE(gridview->currentIndex(), 0); + + QTRY_COMPARE(gridview->contentY(), 0.0); + + + // footer should become visible if it is out of view, and then current index moves to the first row + canvas->rootObject()->setProperty("showFooter", true); + QTRY_VERIFY(gridview->footerItem()); + gridview->setCurrentIndex(model.count()-3); + QTRY_VERIFY(gridview->footerItem()->y() > gridview->contentY() + gridview->height()); + gridview->setCurrentIndex(model.count()-2); + QTRY_COMPARE(gridview->contentY() + gridview->height(), (60.0 * model.count()/3) + gridview->footerItem()->height()); + canvas->rootObject()->setProperty("showFooter", false); + + // header should become visible if it is out of view, and then current index moves to the last row + canvas->rootObject()->setProperty("showHeader", true); + QTRY_VERIFY(gridview->headerItem()); + gridview->setCurrentIndex(3); + QTRY_VERIFY(gridview->headerItem()->y() + gridview->headerItem()->height() < gridview->contentY()); + gridview->setCurrentIndex(1); + QTRY_COMPARE(gridview->contentY(), -gridview->headerItem()->height()); + canvas->rootObject()->setProperty("showHeader", false); + + + // Test keys + canvas->requestActivateWindow(); + QTest::qWaitForWindowShown(canvas); + QTRY_VERIFY(qGuiApp->focusWindow() == canvas); + + gridview->setCurrentIndex(0); + + QTest::keyClick(canvas, Qt::Key_Down); + QCOMPARE(gridview->currentIndex(), 3); + + QTest::keyClick(canvas, Qt::Key_Up); + QCOMPARE(gridview->currentIndex(), 0); + + // hold down Key_Down + for (int i=0; i<(model.count() / 3) - 1; i++) { + QTest::simulateEvent(canvas, true, Qt::Key_Down, Qt::NoModifier, "", true); + QTRY_COMPARE(gridview->currentIndex(), i*3 + 3); + } + QTest::keyRelease(canvas, Qt::Key_Down); + QTRY_COMPARE(gridview->currentIndex(), 57); + QTRY_COMPARE(gridview->contentY(), 880.0); + + // hold down Key_Up + for (int i=(model.count() / 3) - 1; i > 0; i--) { + QTest::simulateEvent(canvas, true, Qt::Key_Up, Qt::NoModifier, "", true); + QTRY_COMPARE(gridview->currentIndex(), i*3 - 3); + } + QTest::keyRelease(canvas, Qt::Key_Up); + QTRY_COMPARE(gridview->currentIndex(), 0); + QTRY_COMPARE(gridview->contentY(), 0.0); + + + gridview->setFlow(QQuickGridView::TopToBottom); + + canvas->requestActivateWindow(); + QTest::qWaitForWindowShown(canvas); + QVERIFY(qGuiApp->focusWindow() == canvas); + qApp->processEvents(); + + QTest::keyClick(canvas, Qt::Key_Right); + QCOMPARE(gridview->currentIndex(), 5); + + QTest::keyClick(canvas, Qt::Key_Left); + QCOMPARE(gridview->currentIndex(), 0); + + QTest::keyClick(canvas, Qt::Key_Down); + QCOMPARE(gridview->currentIndex(), 1); + + QTest::keyClick(canvas, Qt::Key_Up); + QCOMPARE(gridview->currentIndex(), 0); + + // hold down Key_Right + for (int i=0; i<(model.count() / 5) - 1; i++) { + QTest::simulateEvent(canvas, true, Qt::Key_Right, Qt::NoModifier, "", true); + QTRY_COMPARE(gridview->currentIndex(), i*5 + 5); + } + + QTest::keyRelease(canvas, Qt::Key_Right); + QTRY_COMPARE(gridview->currentIndex(), 55); + QTRY_COMPARE(gridview->contentX(), 720.0); + + // hold down Key_Left + for (int i=(model.count() / 5) - 1; i > 0; i--) { + QTest::simulateEvent(canvas, true, Qt::Key_Left, Qt::NoModifier, "", true); + QTRY_COMPARE(gridview->currentIndex(), i*5 - 5); + } + QTest::keyRelease(canvas, Qt::Key_Left); + QTRY_COMPARE(gridview->currentIndex(), 0); + QTRY_COMPARE(gridview->contentX(), 0.0); + + + // turn off auto highlight + gridview->setHighlightFollowsCurrentItem(false); + QVERIFY(gridview->highlightFollowsCurrentItem() == false); + QVERIFY(gridview->highlightItem()); + qreal hlPosX = gridview->highlightItem()->x(); + qreal hlPosY = gridview->highlightItem()->y(); + + gridview->setCurrentIndex(5); + QTRY_COMPARE(gridview->highlightItem()->x(), hlPosX); + QTRY_COMPARE(gridview->highlightItem()->y(), hlPosY); + + // insert item before currentIndex + gridview->setCurrentIndex(28); + model.insertItem(0, "Foo", "1111"); + QTRY_COMPARE(canvas->rootObject()->property("current").toInt(), 29); + + // check removing highlight by setting currentIndex to -1; + gridview->setCurrentIndex(-1); + + QCOMPARE(gridview->currentIndex(), -1); + QVERIFY(!gridview->highlightItem()); + QVERIFY(!gridview->currentItem()); + + gridview->setHighlightFollowsCurrentItem(true); + + gridview->setFlow(QQuickGridView::LeftToRight); + gridview->setLayoutDirection(Qt::RightToLeft); + + canvas->requestActivateWindow(); + QTest::qWaitForWindowShown(canvas); + QTRY_VERIFY(qGuiApp->focusWindow() == canvas); + qApp->processEvents(); + + gridview->setCurrentIndex(35); + + QTest::keyClick(canvas, Qt::Key_Right); + QCOMPARE(gridview->currentIndex(), 34); + + QTest::keyClick(canvas, Qt::Key_Down); + QCOMPARE(gridview->currentIndex(), 37); + + QTest::keyClick(canvas, Qt::Key_Up); + QCOMPARE(gridview->currentIndex(), 34); + + QTest::keyClick(canvas, Qt::Key_Left); + QCOMPARE(gridview->currentIndex(), 35); + + + // turn off auto highlight + gridview->setHighlightFollowsCurrentItem(false); + QVERIFY(gridview->highlightFollowsCurrentItem() == false); + QVERIFY(gridview->highlightItem()); + hlPosX = gridview->highlightItem()->x(); + hlPosY = gridview->highlightItem()->y(); + + gridview->setCurrentIndex(5); + QTRY_COMPARE(gridview->highlightItem()->x(), hlPosX); + QTRY_COMPARE(gridview->highlightItem()->y(), hlPosY); + + // insert item before currentIndex + gridview->setCurrentIndex(28); + model.insertItem(0, "Foo", "1111"); + QTRY_COMPARE(canvas->rootObject()->property("current").toInt(), 29); + + // check removing highlight by setting currentIndex to -1; + gridview->setCurrentIndex(-1); + + QCOMPARE(gridview->currentIndex(), -1); + QVERIFY(!gridview->highlightItem()); + QVERIFY(!gridview->currentItem()); + + delete canvas; +} + +void tst_QQuickGridView::noCurrentIndex() +{ + QaimModel model; + for (int i = 0; i < 60; i++) + model.addItem("Item" + QString::number(i), QString::number(i)); + + QQuickView *canvas = new QQuickView(0); + canvas->setGeometry(0,0,240,320); + + QQmlContext *ctxt = canvas->rootContext(); + ctxt->setContextProperty("testModel", &model); + + QString filename(testFile("gridview-noCurrent.qml")); + canvas->setSource(QUrl::fromLocalFile(filename)); + canvas->show(); + qApp->processEvents(); + + QQuickGridView *gridview = findItem(canvas->rootObject(), "grid"); + QVERIFY(gridview != 0); + QQuickItem *contentItem = gridview->contentItem(); + QVERIFY(contentItem != 0); + QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false); + + // current index should be -1 + QCOMPARE(gridview->currentIndex(), -1); + QVERIFY(!gridview->currentItem()); + QVERIFY(!gridview->highlightItem()); + QCOMPARE(gridview->contentY(), 0.0); + + gridview->setCurrentIndex(5); + QCOMPARE(gridview->currentIndex(), 5); + QVERIFY(gridview->currentItem()); + QVERIFY(gridview->highlightItem()); + + delete canvas; +} + +void tst_QQuickGridView::changeFlow() +{ + QQuickView *canvas = createView(); + + QaimModel model; + for (int i = 0; i < 30; i++) + model.addItem("Item" + QString::number(i), QString::number(i)); + + QQmlContext *ctxt = canvas->rootContext(); + ctxt->setContextProperty("testModel", &model); + ctxt->setContextProperty("testRightToLeft", QVariant(false)); + ctxt->setContextProperty("testTopToBottom", QVariant(false)); + + canvas->setSource(testFileUrl("gridview1.qml")); + qApp->processEvents(); + + QQuickGridView *gridview = findItem(canvas->rootObject(), "grid"); + QTRY_VERIFY(gridview != 0); + + QQuickItem *contentItem = gridview->contentItem(); + QTRY_VERIFY(contentItem != 0); + + // Confirm items positioned correctly and indexes correct + int itemCount = findItems(contentItem, "wrapper").count(); + for (int i = 0; i < model.count() && i < itemCount; ++i) { + QQuickItem *item = findItem(contentItem, "wrapper", i); + if (!item) qWarning() << "Item" << i << "not found"; + QTRY_VERIFY(item); + QTRY_COMPARE(item->x(), qreal((i%3)*80)); + QTRY_COMPARE(item->y(), qreal((i/3)*60)); + QQuickText *name = findItem(contentItem, "textName", i); + QTRY_VERIFY(name != 0); + QTRY_COMPARE(name->text(), model.name(i)); + QQuickText *number = findItem(contentItem, "textNumber", i); + QTRY_VERIFY(number != 0); + QTRY_COMPARE(number->text(), model.number(i)); + } + + ctxt->setContextProperty("testTopToBottom", QVariant(true)); + + // Confirm items positioned correctly and indexes correct + itemCount = findItems(contentItem, "wrapper").count(); + for (int i = 0; i < model.count() && i < itemCount; ++i) { + QQuickItem *item = findItem(contentItem, "wrapper", i); + if (!item) qWarning() << "Item" << i << "not found"; + QTRY_VERIFY(item); + QTRY_COMPARE(item->x(), qreal((i/5)*80)); + QTRY_COMPARE(item->y(), qreal((i%5)*60)); + QQuickText *name = findItem(contentItem, "textName", i); + QTRY_VERIFY(name != 0); + QTRY_COMPARE(name->text(), model.name(i)); + QQuickText *number = findItem(contentItem, "textNumber", i); + QTRY_VERIFY(number != 0); + QTRY_COMPARE(number->text(), model.number(i)); + } + + ctxt->setContextProperty("testRightToLeft", QVariant(true)); + + // Confirm items positioned correctly and indexes correct + itemCount = findItems(contentItem, "wrapper").count(); + for (int i = 0; i < model.count() && i < itemCount; ++i) { + QQuickItem *item = findItem(contentItem, "wrapper", i); + if (!item) qWarning() << "Item" << i << "not found"; + QTRY_VERIFY(item); + QTRY_COMPARE(item->x(), qreal(-(i/5)*80 - item->width())); + QTRY_COMPARE(item->y(), qreal((i%5)*60)); + QQuickText *name = findItem(contentItem, "textName", i); + QTRY_VERIFY(name != 0); + QTRY_COMPARE(name->text(), model.name(i)); + QQuickText *number = findItem(contentItem, "textNumber", i); + QTRY_VERIFY(number != 0); + QTRY_COMPARE(number->text(), model.number(i)); + } + gridview->setContentX(100); + QTRY_COMPARE(gridview->contentX(), 100.); + ctxt->setContextProperty("testTopToBottom", QVariant(false)); + QTRY_COMPARE(gridview->contentX(), 0.); + + // Confirm items positioned correctly and indexes correct + itemCount = findItems(contentItem, "wrapper").count(); + for (int i = 0; i < model.count() && i < itemCount; ++i) { + QQuickItem *item = findItem(contentItem, "wrapper", i); + if (!item) qWarning() << "Item" << i << "not found"; + QTRY_VERIFY(item); + QTRY_COMPARE(item->x(), qreal(240 - (i%3+1)*80)); + QTRY_COMPARE(item->y(), qreal((i/3)*60)); + QQuickText *name = findItem(contentItem, "textName", i); + QTRY_VERIFY(name != 0); + QTRY_COMPARE(name->text(), model.name(i)); + QQuickText *number = findItem(contentItem, "textNumber", i); + QTRY_VERIFY(number != 0); + QTRY_COMPARE(number->text(), model.number(i)); + } + + delete canvas; +} + +void tst_QQuickGridView::defaultValues() +{ + QQmlEngine engine; + QQmlComponent c(&engine, testFileUrl("gridview3.qml")); + QQuickGridView *obj = qobject_cast(c.create()); + + QTRY_VERIFY(obj != 0); + QTRY_VERIFY(obj->model() == QVariant()); + QTRY_VERIFY(obj->delegate() == 0); + QTRY_COMPARE(obj->currentIndex(), -1); + QTRY_VERIFY(obj->currentItem() == 0); + QTRY_COMPARE(obj->count(), 0); + QTRY_VERIFY(obj->highlight() == 0); + QTRY_VERIFY(obj->highlightItem() == 0); + QTRY_COMPARE(obj->highlightFollowsCurrentItem(), true); + QTRY_VERIFY(obj->flow() == 0); + QTRY_COMPARE(obj->isWrapEnabled(), false); + QTRY_COMPARE(obj->cacheBuffer(), 0); + QTRY_COMPARE(obj->cellWidth(), qreal(100)); //### Should 100 be the default? + QTRY_COMPARE(obj->cellHeight(), qreal(100)); + delete obj; +} + +void tst_QQuickGridView::properties() +{ + QQmlEngine engine; + QQmlComponent c(&engine, testFileUrl("gridview2.qml")); + QQuickGridView *obj = qobject_cast(c.create()); + + QTRY_VERIFY(obj != 0); + QTRY_VERIFY(obj->model() != QVariant()); + QTRY_VERIFY(obj->delegate() != 0); + QTRY_COMPARE(obj->currentIndex(), 0); + QTRY_VERIFY(obj->currentItem() != 0); + QTRY_COMPARE(obj->count(), 4); + QTRY_VERIFY(obj->highlight() != 0); + QTRY_VERIFY(obj->highlightItem() != 0); + QTRY_COMPARE(obj->highlightFollowsCurrentItem(), false); + QTRY_VERIFY(obj->flow() == 0); + QTRY_COMPARE(obj->isWrapEnabled(), true); + QTRY_COMPARE(obj->cacheBuffer(), 200); + QTRY_COMPARE(obj->cellWidth(), qreal(100)); + QTRY_COMPARE(obj->cellHeight(), qreal(100)); + delete obj; +} + +void tst_QQuickGridView::propertyChanges() +{ + QQuickView *canvas = createView(); + QTRY_VERIFY(canvas); + canvas->setSource(testFileUrl("propertychangestest.qml")); + + QQuickGridView *gridView = canvas->rootObject()->findChild("gridView"); + QTRY_VERIFY(gridView); + + QSignalSpy keyNavigationWrapsSpy(gridView, SIGNAL(keyNavigationWrapsChanged())); + QSignalSpy cacheBufferSpy(gridView, SIGNAL(cacheBufferChanged())); + QSignalSpy layoutSpy(gridView, SIGNAL(layoutDirectionChanged())); + QSignalSpy flowSpy(gridView, SIGNAL(flowChanged())); + + QTRY_COMPARE(gridView->isWrapEnabled(), true); + QTRY_COMPARE(gridView->cacheBuffer(), 10); + QTRY_COMPARE(gridView->flow(), QQuickGridView::LeftToRight); + + gridView->setWrapEnabled(false); + gridView->setCacheBuffer(3); + gridView->setFlow(QQuickGridView::TopToBottom); + + QTRY_COMPARE(gridView->isWrapEnabled(), false); + QTRY_COMPARE(gridView->cacheBuffer(), 3); + QTRY_COMPARE(gridView->flow(), QQuickGridView::TopToBottom); + + QTRY_COMPARE(keyNavigationWrapsSpy.count(),1); + QTRY_COMPARE(cacheBufferSpy.count(),1); + QTRY_COMPARE(flowSpy.count(),1); + + gridView->setWrapEnabled(false); + gridView->setCacheBuffer(3); + gridView->setFlow(QQuickGridView::TopToBottom); + + QTRY_COMPARE(keyNavigationWrapsSpy.count(),1); + QTRY_COMPARE(cacheBufferSpy.count(),1); + QTRY_COMPARE(flowSpy.count(),1); + + gridView->setFlow(QQuickGridView::LeftToRight); + QTRY_COMPARE(gridView->flow(), QQuickGridView::LeftToRight); + + gridView->setWrapEnabled(true); + gridView->setCacheBuffer(5); + gridView->setLayoutDirection(Qt::RightToLeft); + + QTRY_COMPARE(gridView->isWrapEnabled(), true); + QTRY_COMPARE(gridView->cacheBuffer(), 5); + QTRY_COMPARE(gridView->layoutDirection(), Qt::RightToLeft); + + QTRY_COMPARE(keyNavigationWrapsSpy.count(),2); + QTRY_COMPARE(cacheBufferSpy.count(),2); + QTRY_COMPARE(layoutSpy.count(),1); + QTRY_COMPARE(flowSpy.count(),2); + + gridView->setWrapEnabled(true); + gridView->setCacheBuffer(5); + gridView->setLayoutDirection(Qt::RightToLeft); + + QTRY_COMPARE(keyNavigationWrapsSpy.count(),2); + QTRY_COMPARE(cacheBufferSpy.count(),2); + QTRY_COMPARE(layoutSpy.count(),1); + QTRY_COMPARE(flowSpy.count(),2); + + gridView->setFlow(QQuickGridView::TopToBottom); + QTRY_COMPARE(gridView->flow(), QQuickGridView::TopToBottom); + QTRY_COMPARE(flowSpy.count(),3); + + gridView->setFlow(QQuickGridView::TopToBottom); + QTRY_COMPARE(flowSpy.count(),3); + + delete canvas; +} + +void tst_QQuickGridView::componentChanges() +{ + QQuickView *canvas = createView(); + QTRY_VERIFY(canvas); + canvas->setSource(testFileUrl("propertychangestest.qml")); + + QQuickGridView *gridView = canvas->rootObject()->findChild("gridView"); + QTRY_VERIFY(gridView); + + QQmlComponent component(canvas->engine()); + component.setData("import QtQuick 2.0; Rectangle { color: \"blue\"; }", QUrl::fromLocalFile("")); + + QQmlComponent delegateComponent(canvas->engine()); + delegateComponent.setData("import QtQuick 2.0; Text { text: 'Name: ' + name }", QUrl::fromLocalFile("")); + + QSignalSpy highlightSpy(gridView, SIGNAL(highlightChanged())); + QSignalSpy delegateSpy(gridView, SIGNAL(delegateChanged())); + QSignalSpy headerSpy(gridView, SIGNAL(headerChanged())); + QSignalSpy footerSpy(gridView, SIGNAL(footerChanged())); + + gridView->setHighlight(&component); + gridView->setDelegate(&delegateComponent); + gridView->setHeader(&component); + gridView->setFooter(&component); + + QTRY_COMPARE(gridView->highlight(), &component); + QTRY_COMPARE(gridView->delegate(), &delegateComponent); + QTRY_COMPARE(gridView->header(), &component); + QTRY_COMPARE(gridView->footer(), &component); + + QTRY_COMPARE(highlightSpy.count(),1); + QTRY_COMPARE(delegateSpy.count(),1); + QTRY_COMPARE(headerSpy.count(),1); + QTRY_COMPARE(footerSpy.count(),1); + + gridView->setHighlight(&component); + gridView->setDelegate(&delegateComponent); + gridView->setHeader(&component); + gridView->setFooter(&component); + + QTRY_COMPARE(highlightSpy.count(),1); + QTRY_COMPARE(delegateSpy.count(),1); + QTRY_COMPARE(headerSpy.count(),1); + QTRY_COMPARE(footerSpy.count(),1); + + delete canvas; +} + +void tst_QQuickGridView::modelChanges() +{ + QQuickView *canvas = createView(); + QTRY_VERIFY(canvas); + canvas->setSource(testFileUrl("propertychangestest.qml")); + + QQuickGridView *gridView = canvas->rootObject()->findChild("gridView"); + QTRY_VERIFY(gridView); + + QQuickListModel *alternateModel = canvas->rootObject()->findChild("alternateModel"); + QTRY_VERIFY(alternateModel); + QVariant modelVariant = QVariant::fromValue(alternateModel); + QSignalSpy modelSpy(gridView, SIGNAL(modelChanged())); + + gridView->setModel(modelVariant); + QTRY_COMPARE(gridView->model(), modelVariant); + QTRY_COMPARE(modelSpy.count(),1); + + gridView->setModel(modelVariant); + QTRY_COMPARE(modelSpy.count(),1); + + gridView->setModel(QVariant()); + QTRY_COMPARE(modelSpy.count(),2); + delete canvas; +} + +void tst_QQuickGridView::positionViewAtIndex() +{ + QQuickView *canvas = createView(); + + QaimModel model; + for (int i = 0; i < 40; i++) + model.addItem("Item" + QString::number(i), ""); + + QQmlContext *ctxt = canvas->rootContext(); + ctxt->setContextProperty("testModel", &model); + ctxt->setContextProperty("testRightToLeft", QVariant(false)); + ctxt->setContextProperty("testTopToBottom", QVariant(false)); + + canvas->setSource(testFileUrl("gridview1.qml")); + canvas->show(); + qApp->processEvents(); + + QQuickGridView *gridview = findItem(canvas->rootObject(), "grid"); + QTRY_VERIFY(gridview != 0); + QQuickItem *contentItem = gridview->contentItem(); + QTRY_VERIFY(contentItem != 0); + QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false); + + // Confirm items positioned correctly + int itemCount = findItems(contentItem, "wrapper").count(); + for (int i = 0; i < model.count() && i < itemCount-1; ++i) { + QQuickItem *item = findItem(contentItem, "wrapper", i); + if (!item) qWarning() << "Item" << i << "not found"; + QTRY_VERIFY(item); + QTRY_COMPARE(item->x(), (i%3)*80.); + QTRY_COMPARE(item->y(), (i/3)*60.); + } + + // Position on a currently visible item + gridview->positionViewAtIndex(4, QQuickGridView::Beginning); + QTRY_COMPARE(gridview->indexAt(120, 90), 4); + QTRY_COMPARE(gridview->contentY(), 60.); + + // Confirm items positioned correctly + itemCount = findItems(contentItem, "wrapper").count(); + for (int i = 3; i < model.count() && i < itemCount-3-1; ++i) { + QQuickItem *item = findItem(contentItem, "wrapper", i); + if (!item) qWarning() << "Item" << i << "not found"; + QTRY_VERIFY(item); + QTRY_COMPARE(item->x(), (i%3)*80.); + QTRY_COMPARE(item->y(), (i/3)*60.); + } + + // Position on an item beyond the visible items + gridview->positionViewAtIndex(21, QQuickGridView::Beginning); + QTRY_COMPARE(gridview->indexAt(40, 450), 21); + QTRY_COMPARE(gridview->contentY(), 420.); + + // Confirm items positioned correctly + itemCount = findItems(contentItem, "wrapper").count(); + for (int i = 22; i < model.count() && i < itemCount-22-1; ++i) { + QQuickItem *item = findItem(contentItem, "wrapper", i); + if (!item) qWarning() << "Item" << i << "not found"; + QTRY_VERIFY(item); + QTRY_COMPARE(item->x(), (i%3)*80.); + QTRY_COMPARE(item->y(), (i/3)*60.); + } + + // Position on an item that would leave empty space if positioned at the top + gridview->positionViewAtIndex(31, QQuickGridView::Beginning); + QTRY_COMPARE(gridview->indexAt(120, 630), 31); + QTRY_COMPARE(gridview->contentY(), 520.); + + // Confirm items positioned correctly + itemCount = findItems(contentItem, "wrapper").count(); + for (int i = 24; i < model.count() && i < itemCount-24-1; ++i) { + QQuickItem *item = findItem(contentItem, "wrapper", i); + if (!item) qWarning() << "Item" << i << "not found"; + QTRY_VERIFY(item); + QTRY_COMPARE(item->x(), (i%3)*80.); + QTRY_COMPARE(item->y(), (i/3)*60.); + } + + // Position at the beginning again + gridview->positionViewAtIndex(0, QQuickGridView::Beginning); + QTRY_COMPARE(gridview->indexAt(0, 0), 0); + QTRY_COMPARE(gridview->indexAt(40, 30), 0); + QTRY_COMPARE(gridview->indexAt(80, 60), 4); + QTRY_COMPARE(gridview->contentY(), 0.); + + // Confirm items positioned correctly + itemCount = findItems(contentItem, "wrapper").count(); + for (int i = 0; i < model.count() && i < itemCount-1; ++i) { + QQuickItem *item = findItem(contentItem, "wrapper", i); + if (!item) qWarning() << "Item" << i << "not found"; + QTRY_VERIFY(item); + QTRY_COMPARE(item->x(), (i%3)*80.); + QTRY_COMPARE(item->y(), (i/3)*60.); + } + + // Position at End + gridview->positionViewAtIndex(30, QQuickGridView::End); + QTRY_COMPARE(gridview->contentY(), 340.); + + // Position in Center + gridview->positionViewAtIndex(15, QQuickGridView::Center); + QTRY_COMPARE(gridview->contentY(), 170.); + + // Ensure at least partially visible + gridview->positionViewAtIndex(15, QQuickGridView::Visible); + QTRY_COMPARE(gridview->contentY(), 170.); + + gridview->setContentY(302); + gridview->positionViewAtIndex(15, QQuickGridView::Visible); + QTRY_COMPARE(gridview->contentY(), 302.); + + gridview->setContentY(360); + gridview->positionViewAtIndex(15, QQuickGridView::Visible); + QTRY_COMPARE(gridview->contentY(), 300.); + + gridview->setContentY(60); + gridview->positionViewAtIndex(20, QQuickGridView::Visible); + QTRY_COMPARE(gridview->contentY(), 60.); + + gridview->setContentY(20); + gridview->positionViewAtIndex(20, QQuickGridView::Visible); + QTRY_COMPARE(gridview->contentY(), 100.); + + // Ensure completely visible + gridview->setContentY(120); + gridview->positionViewAtIndex(20, QQuickGridView::Contain); + QTRY_COMPARE(gridview->contentY(), 120.); + + gridview->setContentY(302); + gridview->positionViewAtIndex(15, QQuickGridView::Contain); + QTRY_COMPARE(gridview->contentY(), 300.); + + gridview->setContentY(60); + gridview->positionViewAtIndex(20, QQuickGridView::Contain); + QTRY_COMPARE(gridview->contentY(), 100.); + + // Test for Top To Bottom layout + ctxt->setContextProperty("testTopToBottom", QVariant(true)); + + // Confirm items positioned correctly + itemCount = findItems(contentItem, "wrapper").count(); + for (int i = 0; i < model.count() && i < itemCount-1; ++i) { + QQuickItem *item = findItem(contentItem, "wrapper", i); + if (!item) qWarning() << "Item" << i << "not found"; + QTRY_VERIFY(item); + QTRY_COMPARE(item->x(), (i/5)*80.); + QTRY_COMPARE(item->y(), (i%5)*60.); + } + + // Position at End + gridview->positionViewAtIndex(30, QQuickGridView::End); + QTRY_COMPARE(gridview->contentX(), 320.); + QTRY_COMPARE(gridview->contentY(), 0.); + + // Position in Center + gridview->positionViewAtIndex(15, QQuickGridView::Center); + QTRY_COMPARE(gridview->contentX(), 160.); + + // Ensure at least partially visible + gridview->positionViewAtIndex(15, QQuickGridView::Visible); + QTRY_COMPARE(gridview->contentX(), 160.); + + gridview->setContentX(170); + gridview->positionViewAtIndex(25, QQuickGridView::Visible); + QTRY_COMPARE(gridview->contentX(), 170.); + + gridview->positionViewAtIndex(30, QQuickGridView::Visible); + QTRY_COMPARE(gridview->contentX(), 320.); + + gridview->setContentX(170); + gridview->positionViewAtIndex(25, QQuickGridView::Contain); + QTRY_COMPARE(gridview->contentX(), 240.); + + // positionViewAtBeginning + gridview->positionViewAtBeginning(); + QTRY_COMPARE(gridview->contentX(), 0.); + + gridview->setContentX(80); + canvas->rootObject()->setProperty("showHeader", true); + gridview->positionViewAtBeginning(); + QTRY_COMPARE(gridview->contentX(), -30.); + + // positionViewAtEnd + gridview->positionViewAtEnd(); + QTRY_COMPARE(gridview->contentX(), 400.); // 8*80 - 240 (8 columns) + + gridview->setContentX(80); + canvas->rootObject()->setProperty("showFooter", true); + gridview->positionViewAtEnd(); + QTRY_COMPARE(gridview->contentX(), 430.); + + // set current item to outside visible view, position at beginning + // and ensure highlight moves to current item + gridview->setCurrentIndex(6); + gridview->positionViewAtBeginning(); + QTRY_COMPARE(gridview->contentX(), -30.); + QVERIFY(gridview->highlightItem()); + QCOMPARE(gridview->highlightItem()->x(), 80.); + + delete canvas; +} + +void tst_QQuickGridView::snapping() +{ + QQuickView *canvas = createView(); + + QaimModel model; + for (int i = 0; i < 40; i++) + model.addItem("Item" + QString::number(i), ""); + + QQmlContext *ctxt = canvas->rootContext(); + ctxt->setContextProperty("testModel", &model); + ctxt->setContextProperty("testTopToBottom", QVariant(false)); + ctxt->setContextProperty("testRightToLeft", QVariant(false)); + + canvas->setSource(testFileUrl("gridview1.qml")); + qApp->processEvents(); + + QQuickGridView *gridview = findItem(canvas->rootObject(), "grid"); + QTRY_VERIFY(gridview != 0); + + gridview->setHeight(220); + QCOMPARE(gridview->height(), 220.); + + gridview->positionViewAtIndex(12, QQuickGridView::Visible); + QCOMPARE(gridview->contentY(), 80.); + + gridview->setContentY(0); + QCOMPARE(gridview->contentY(), 0.); + + gridview->setSnapMode(QQuickGridView::SnapToRow); + QCOMPARE(gridview->snapMode(), QQuickGridView::SnapToRow); + + gridview->positionViewAtIndex(12, QQuickGridView::Visible); + QCOMPARE(gridview->contentY(), 60.); + + gridview->positionViewAtIndex(15, QQuickGridView::End); + QCOMPARE(gridview->contentY(), 120.); + + delete canvas; + +} + +void tst_QQuickGridView::mirroring() +{ + QQuickView *canvasA = createView(); + canvasA->setSource(testFileUrl("mirroring.qml")); + QQuickGridView *gridviewA = findItem(canvasA->rootObject(), "view"); + QTRY_VERIFY(gridviewA != 0); + + QQuickView *canvasB = createView(); + canvasB->setSource(testFileUrl("mirroring.qml")); + QQuickGridView *gridviewB = findItem(canvasB->rootObject(), "view"); + QTRY_VERIFY(gridviewA != 0); + qApp->processEvents(); + + QList objectNames; + objectNames << "item1" << "item2"; // << "item3" + + gridviewA->setProperty("layoutDirection", Qt::LeftToRight); + gridviewB->setProperty("layoutDirection", Qt::RightToLeft); + QCOMPARE(gridviewA->layoutDirection(), gridviewA->effectiveLayoutDirection()); + + // LTR != RTL + foreach (const QString objectName, objectNames) + QVERIFY(findItem(gridviewA, objectName)->x() != findItem(gridviewB, objectName)->x()); + + gridviewA->setProperty("layoutDirection", Qt::LeftToRight); + gridviewB->setProperty("layoutDirection", Qt::LeftToRight); + + // LTR == LTR + foreach (const QString objectName, objectNames) + QCOMPARE(findItem(gridviewA, objectName)->x(), findItem(gridviewB, objectName)->x()); + + QVERIFY(gridviewB->layoutDirection() == gridviewB->effectiveLayoutDirection()); + QQuickItemPrivate::get(gridviewB)->setLayoutMirror(true); + QVERIFY(gridviewB->layoutDirection() != gridviewB->effectiveLayoutDirection()); + + // LTR != LTR+mirror + foreach (const QString objectName, objectNames) + QVERIFY(findItem(gridviewA, objectName)->x() != findItem(gridviewB, objectName)->x()); + + gridviewA->setProperty("layoutDirection", Qt::RightToLeft); + + // RTL == LTR+mirror + foreach (const QString objectName, objectNames) + QCOMPARE(findItem(gridviewA, objectName)->x(), findItem(gridviewB, objectName)->x()); + + gridviewB->setProperty("layoutDirection", Qt::RightToLeft); + + // RTL != RTL+mirror + foreach (const QString objectName, objectNames) + QVERIFY(findItem(gridviewA, objectName)->x() != findItem(gridviewB, objectName)->x()); + + gridviewA->setProperty("layoutDirection", Qt::LeftToRight); + + // LTR == RTL+mirror + foreach (const QString objectName, objectNames) + QCOMPARE(findItem(gridviewA, objectName)->x(), findItem(gridviewB, objectName)->x()); + + delete canvasA; + delete canvasB; +} + +void tst_QQuickGridView::positionViewAtIndex_rightToLeft() +{ + QQuickView *canvas = createView(); + + QaimModel model; + for (int i = 0; i < 40; i++) + model.addItem("Item" + QString::number(i), ""); + + QQmlContext *ctxt = canvas->rootContext(); + ctxt->setContextProperty("testModel", &model); + ctxt->setContextProperty("testTopToBottom", QVariant(true)); + ctxt->setContextProperty("testRightToLeft", QVariant(true)); + + canvas->setSource(testFileUrl("gridview1.qml")); + qApp->processEvents(); + + QQuickGridView *gridview = findItem(canvas->rootObject(), "grid"); + QTRY_VERIFY(gridview != 0); + + QQuickItem *contentItem = gridview->contentItem(); + QTRY_VERIFY(contentItem != 0); + + // Confirm items positioned correctly + int itemCount = findItems(contentItem, "wrapper").count(); + for (int i = 0; i < model.count() && i < itemCount-1; ++i) { + QQuickItem *item = findItem(contentItem, "wrapper", i); + if (!item) qWarning() << "Item" << i << "not found"; + QTRY_VERIFY(item); + QTRY_COMPARE(item->x(), qreal(-(i/5)*80-item->width())); + QTRY_COMPARE(item->y(), qreal((i%5)*60)); + } + + // Position on a currently visible item + gridview->positionViewAtIndex(6, QQuickGridView::Beginning); + QTRY_COMPARE(gridview->contentX(), -320.); + + // Confirm items positioned correctly + itemCount = findItems(contentItem, "wrapper").count(); + for (int i = 3; i < model.count() && i < itemCount-3-1; ++i) { + QQuickItem *item = findItem(contentItem, "wrapper", i); + if (!item) qWarning() << "Item" << i << "not found"; + QTRY_VERIFY(item); + QTRY_COMPARE(item->x(), qreal(-(i/5)*80-item->width())); + QTRY_COMPARE(item->y(), qreal((i%5)*60)); + } + + // Position on an item beyond the visible items + gridview->positionViewAtIndex(21, QQuickGridView::Beginning); + QTRY_COMPARE(gridview->contentX(), -560.); + + // Confirm items positioned correctly + itemCount = findItems(contentItem, "wrapper").count(); + for (int i = 22; i < model.count() && i < itemCount-22-1; ++i) { + QQuickItem *item = findItem(contentItem, "wrapper", i); + if (!item) qWarning() << "Item" << i << "not found"; + QTRY_VERIFY(item); + QTRY_COMPARE(item->x(), qreal(-(i/5)*80-item->width())); + QTRY_COMPARE(item->y(), qreal((i%5)*60)); + } + + // Position on an item that would leave empty space if positioned at the top + gridview->positionViewAtIndex(31, QQuickGridView::Beginning); + QTRY_COMPARE(gridview->contentX(), -640.); + + // Confirm items positioned correctly + itemCount = findItems(contentItem, "wrapper").count(); + for (int i = 24; i < model.count() && i < itemCount-24-1; ++i) { + QQuickItem *item = findItem(contentItem, "wrapper", i); + if (!item) qWarning() << "Item" << i << "not found"; + QTRY_VERIFY(item); + QTRY_COMPARE(item->x(), qreal(-(i/5)*80-item->width())); + QTRY_COMPARE(item->y(), qreal((i%5)*60)); + } + + // Position at the beginning again + gridview->positionViewAtIndex(0, QQuickGridView::Beginning); + QTRY_COMPARE(gridview->contentX(), -240.); + + // Confirm items positioned correctly + itemCount = findItems(contentItem, "wrapper").count(); + for (int i = 0; i < model.count() && i < itemCount-1; ++i) { + QQuickItem *item = findItem(contentItem, "wrapper", i); + if (!item) qWarning() << "Item" << i << "not found"; + QTRY_VERIFY(item); + QTRY_COMPARE(item->x(), qreal(-(i/5)*80-item->width())); + QTRY_COMPARE(item->y(), qreal((i%5)*60)); + } + + // Position at End + gridview->positionViewAtIndex(30, QQuickGridView::End); + QTRY_COMPARE(gridview->contentX(), -560.); + + // Position in Center + gridview->positionViewAtIndex(15, QQuickGridView::Center); + QTRY_COMPARE(gridview->contentX(), -400.); + + // Ensure at least partially visible + gridview->positionViewAtIndex(15, QQuickGridView::Visible); + QTRY_COMPARE(gridview->contentX(), -400.); + + gridview->setContentX(-555.); + gridview->positionViewAtIndex(15, QQuickGridView::Visible); + QTRY_COMPARE(gridview->contentX(), -555.); + + gridview->setContentX(-239); + gridview->positionViewAtIndex(15, QQuickGridView::Visible); + QTRY_COMPARE(gridview->contentX(), -320.); + + gridview->setContentX(-239); + gridview->positionViewAtIndex(20, QQuickGridView::Visible); + QTRY_COMPARE(gridview->contentX(), -400.); + + gridview->setContentX(-640); + gridview->positionViewAtIndex(20, QQuickGridView::Visible); + QTRY_COMPARE(gridview->contentX(), -560.); + + // Ensure completely visible + gridview->setContentX(-400); + gridview->positionViewAtIndex(20, QQuickGridView::Contain); + QTRY_COMPARE(gridview->contentX(), -400.); + + gridview->setContentX(-315); + gridview->positionViewAtIndex(15, QQuickGridView::Contain); + QTRY_COMPARE(gridview->contentX(), -320.); + + gridview->setContentX(-640); + gridview->positionViewAtIndex(20, QQuickGridView::Contain); + QTRY_COMPARE(gridview->contentX(), -560.); + + delete canvas; +} + +void tst_QQuickGridView::resetModel() +{ + QQuickView *canvas = createView(); + + QStringList strings; + strings << "one" << "two" << "three"; + QStringListModel model(strings); + + QQmlContext *ctxt = canvas->rootContext(); + ctxt->setContextProperty("testModel", &model); + + canvas->setSource(testFileUrl("displaygrid.qml")); + canvas->show(); + qApp->processEvents(); + + QQuickGridView *gridview = findItem(canvas->rootObject(), "grid"); + QTRY_VERIFY(gridview != 0); + QQuickItem *contentItem = gridview->contentItem(); + QTRY_VERIFY(contentItem != 0); + QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false); + + QTRY_COMPARE(gridview->count(), model.rowCount()); + + for (int i = 0; i < model.rowCount(); ++i) { + QQuickText *display = findItem(contentItem, "displayText", i); + QTRY_VERIFY(display != 0); + QTRY_COMPARE(display->text(), strings.at(i)); + } + + strings.clear(); + strings << "four" << "five" << "six" << "seven"; + model.setStringList(strings); + + QTRY_COMPARE(gridview->count(), model.rowCount()); + + for (int i = 0; i < model.rowCount(); ++i) { + QQuickText *display = findItem(contentItem, "displayText", i); + QTRY_VERIFY(display != 0); + QTRY_COMPARE(display->text(), strings.at(i)); + } + + delete canvas; +} + +void tst_QQuickGridView::enforceRange() +{ + QQuickView *canvas = createView(); + + QaimModel model; + for (int i = 0; i < 30; i++) + model.addItem("Item" + QString::number(i), ""); + + QQmlContext *ctxt = canvas->rootContext(); + ctxt->setContextProperty("testModel", &model); + ctxt->setContextProperty("testRightToLeft", QVariant(false)); + ctxt->setContextProperty("testTopToBottom", QVariant(false)); + + canvas->setSource(testFileUrl("gridview-enforcerange.qml")); + canvas->show(); + qApp->processEvents(); + QVERIFY(canvas->rootObject() != 0); + + QQuickGridView *gridview = findItem(canvas->rootObject(), "grid"); + QTRY_VERIFY(gridview != 0); + + QTRY_COMPARE(gridview->preferredHighlightBegin(), 100.0); + QTRY_COMPARE(gridview->preferredHighlightEnd(), 100.0); + QTRY_COMPARE(gridview->highlightRangeMode(), QQuickGridView::StrictlyEnforceRange); + QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false); + + QQuickItem *contentItem = gridview->contentItem(); + QTRY_VERIFY(contentItem != 0); + + // view should be positioned at the top of the range. + QQuickItem *item = findItem(contentItem, "wrapper", 0); + QTRY_VERIFY(item); + QTRY_COMPARE(gridview->contentY(), -100.0); + + QQuickText *name = findItem(contentItem, "textName", 0); + QTRY_VERIFY(name != 0); + QTRY_COMPARE(name->text(), model.name(0)); + QQuickText *number = findItem(contentItem, "textNumber", 0); + QTRY_VERIFY(number != 0); + QTRY_COMPARE(number->text(), model.number(0)); + + // Check currentIndex is updated when contentItem moves + gridview->setContentY(0); + QTRY_COMPARE(gridview->currentIndex(), 2); + + gridview->setCurrentIndex(5); + QTRY_COMPARE(gridview->contentY(), 100.); + + QaimModel model2; + for (int i = 0; i < 5; i++) + model2.addItem("Item" + QString::number(i), ""); + + ctxt->setContextProperty("testModel", &model2); + QCOMPARE(gridview->count(), 5); + + delete canvas; +} + +void tst_QQuickGridView::enforceRange_rightToLeft() +{ + QQuickView *canvas = createView(); + + QaimModel model; + for (int i = 0; i < 30; i++) + model.addItem("Item" + QString::number(i), ""); + + QQmlContext *ctxt = canvas->rootContext(); + ctxt->setContextProperty("testModel", &model); + ctxt->setContextProperty("testRightToLeft", QVariant(true)); + ctxt->setContextProperty("testTopToBottom", QVariant(true)); + + canvas->setSource(testFileUrl("gridview-enforcerange.qml")); + qApp->processEvents(); + QVERIFY(canvas->rootObject() != 0); + + QQuickGridView *gridview = findItem(canvas->rootObject(), "grid"); + QTRY_VERIFY(gridview != 0); + + QCOMPARE(gridview->preferredHighlightBegin(), 100.0); + QCOMPARE(gridview->preferredHighlightEnd(), 100.0); + QCOMPARE(gridview->highlightRangeMode(), QQuickGridView::StrictlyEnforceRange); + + QQuickItem *contentItem = gridview->contentItem(); + QVERIFY(contentItem != 0); + + // view should be positioned at the top of the range. + QQuickItem *item = findItem(contentItem, "wrapper", 0); + QVERIFY(item); + QTRY_COMPARE(gridview->contentX(), -140.); + QTRY_COMPARE(gridview->contentY(), 0.0); + + QQuickText *name = findItem(contentItem, "textName", 0); + QTRY_VERIFY(name != 0); + QTRY_COMPARE(name->text(), model.name(0)); + QQuickText *number = findItem(contentItem, "textNumber", 0); + QTRY_VERIFY(number != 0); + QTRY_COMPARE(number->text(), model.number(0)); + + // Check currentIndex is updated when contentItem moves + gridview->setContentX(-240); + QTRY_COMPARE(gridview->currentIndex(), 3); + + gridview->setCurrentIndex(7); + QTRY_COMPARE(gridview->contentX(), -340.); + QTRY_COMPARE(gridview->contentY(), 0.0); + + QaimModel model2; + for (int i = 0; i < 5; i++) + model2.addItem("Item" + QString::number(i), ""); + + ctxt->setContextProperty("testModel", &model2); + QCOMPARE(gridview->count(), 5); + + delete canvas; +} + +void tst_QQuickGridView::QTBUG_8456() +{ + QQuickView *canvas = createView(); + + canvas->setSource(testFileUrl("setindex.qml")); + qApp->processEvents(); + + QQuickGridView *gridview = findItem(canvas->rootObject(), "grid"); + QTRY_VERIFY(gridview != 0); + + QTRY_COMPARE(gridview->currentIndex(), 0); + + delete canvas; +} + +void tst_QQuickGridView::manualHighlight() +{ + QQuickView *canvas = createView(); + + QString filename(testFile("manual-highlight.qml")); + canvas->setSource(QUrl::fromLocalFile(filename)); + + qApp->processEvents(); + + QQuickGridView *gridview = findItem(canvas->rootObject(), "grid"); + QTRY_VERIFY(gridview != 0); + + QQuickItem *contentItem = gridview->contentItem(); + QTRY_VERIFY(contentItem != 0); + + QTRY_COMPARE(gridview->currentIndex(), 0); + QTRY_COMPARE(gridview->currentItem(), findItem(contentItem, "wrapper", 0)); + QTRY_COMPARE(gridview->highlightItem()->y() - 5, gridview->currentItem()->y()); + QTRY_COMPARE(gridview->highlightItem()->x() - 5, gridview->currentItem()->x()); + + gridview->setCurrentIndex(2); + + QTRY_COMPARE(gridview->currentIndex(), 2); + QTRY_COMPARE(gridview->currentItem(), findItem(contentItem, "wrapper", 2)); + QTRY_COMPARE(gridview->highlightItem()->y() - 5, gridview->currentItem()->y()); + QTRY_COMPARE(gridview->highlightItem()->x() - 5, gridview->currentItem()->x()); + + gridview->positionViewAtIndex(8, QQuickGridView::Contain); + + QTRY_COMPARE(gridview->currentIndex(), 2); + QTRY_COMPARE(gridview->currentItem(), findItem(contentItem, "wrapper", 2)); + QTRY_COMPARE(gridview->highlightItem()->y() - 5, gridview->currentItem()->y()); + QTRY_COMPARE(gridview->highlightItem()->x() - 5, gridview->currentItem()->x()); + + gridview->setFlow(QQuickGridView::TopToBottom); + QTRY_COMPARE(gridview->flow(), QQuickGridView::TopToBottom); + + gridview->setCurrentIndex(0); + QTRY_COMPARE(gridview->currentIndex(), 0); + QTRY_COMPARE(gridview->currentItem(), findItem(contentItem, "wrapper", 0)); + QTRY_COMPARE(gridview->highlightItem()->y() - 5, gridview->currentItem()->y()); + QTRY_COMPARE(gridview->highlightItem()->x() - 5, gridview->currentItem()->x()); + + delete canvas; +} + + +void tst_QQuickGridView::footer() +{ + QFETCH(QQuickGridView::Flow, flow); + QFETCH(Qt::LayoutDirection, layoutDirection); + QFETCH(QPointF, initialFooterPos); + QFETCH(QPointF, changedFooterPos); + QFETCH(QPointF, initialContentPos); + QFETCH(QPointF, changedContentPos); + QFETCH(QPointF, firstDelegatePos); + QFETCH(QPointF, resizeContentPos); + + QQuickView *canvas = createView(); + canvas->show(); + + QaimModel model; + for (int i = 0; i < 7; i++) + model.addItem("Item" + QString::number(i), ""); + + QQmlContext *ctxt = canvas->rootContext(); + ctxt->setContextProperty("testModel", &model); + + canvas->setSource(testFileUrl("footer.qml")); + qApp->processEvents(); + + QQuickGridView *gridview = findItem(canvas->rootObject(), "grid"); + QTRY_VERIFY(gridview != 0); + gridview->setFlow(flow); + gridview->setLayoutDirection(layoutDirection); + + QQuickItem *contentItem = gridview->contentItem(); + QTRY_VERIFY(contentItem != 0); + + QQuickText *footer = findItem(contentItem, "footer"); + QVERIFY(footer); + + QVERIFY(footer == gridview->footerItem()); + + QCOMPARE(footer->pos(), initialFooterPos); + QCOMPARE(footer->width(), 100.); + QCOMPARE(footer->height(), 30.); + QCOMPARE(QPointF(gridview->contentX(), gridview->contentY()), initialContentPos); + + QQuickItem *item = findItem(contentItem, "wrapper", 0); + QVERIFY(item); + QCOMPARE(item->pos(), firstDelegatePos); + + if (flow == QQuickGridView::LeftToRight) { + // shrink by one row + model.removeItem(2); + QTRY_COMPARE(footer->y(), initialFooterPos.y() - gridview->cellHeight()); + } else { + // shrink by one column + model.removeItem(2); + model.removeItem(3); + if (layoutDirection == Qt::LeftToRight) + QTRY_COMPARE(footer->x(), initialFooterPos.x() - gridview->cellWidth()); + else + QTRY_COMPARE(footer->x(), initialFooterPos.x() + gridview->cellWidth()); + } + + // remove all items + model.clear(); + + QPointF posWhenNoItems(0, 0); + if (layoutDirection == Qt::RightToLeft) + posWhenNoItems.setX(flow == QQuickGridView::LeftToRight ? gridview->width() - footer->width() : -footer->width()); + QTRY_COMPARE(footer->pos(), posWhenNoItems); + + // if header is present, it's at a negative pos, so the footer should not move + canvas->rootObject()->setProperty("showHeader", true); + QVERIFY(findItem(contentItem, "header") != 0); + QTRY_COMPARE(footer->pos(), posWhenNoItems); + canvas->rootObject()->setProperty("showHeader", false); + + // add 30 items + for (int i = 0; i < 30; i++) + model.addItem("Item" + QString::number(i), ""); + + QSignalSpy footerItemSpy(gridview, SIGNAL(footerItemChanged())); + QMetaObject::invokeMethod(canvas->rootObject(), "changeFooter"); + + QCOMPARE(footerItemSpy.count(), 1); + + footer = findItem(contentItem, "footer"); + QVERIFY(!footer); + footer = findItem(contentItem, "footer2"); + QVERIFY(footer); + + QVERIFY(footer == gridview->footerItem()); + + QCOMPARE(footer->pos(), changedFooterPos); + QCOMPARE(footer->width(), 50.); + QCOMPARE(footer->height(), 20.); + QTRY_COMPARE(QPointF(gridview->contentX(), gridview->contentY()), changedContentPos); + + item = findItem(contentItem, "wrapper", 0); + QVERIFY(item); + QCOMPARE(item->pos(), firstDelegatePos); + + gridview->positionViewAtEnd(); + footer->setHeight(10); + footer->setWidth(40); + QTRY_COMPARE(QPointF(gridview->contentX(), gridview->contentY()), resizeContentPos); + + delete canvas; +} + +void tst_QQuickGridView::footer_data() +{ + QTest::addColumn("flow"); + QTest::addColumn("layoutDirection"); + QTest::addColumn("initialFooterPos"); + QTest::addColumn("changedFooterPos"); + QTest::addColumn("initialContentPos"); + QTest::addColumn("changedContentPos"); + QTest::addColumn("firstDelegatePos"); + QTest::addColumn("resizeContentPos"); + + // footer1 = 100 x 30 + // footer2 = 50 x 20 + // cells = 80 * 60 + // view width = 240 + // view height = 320 + + // footer below items, bottom left + QTest::newRow("flow left to right") << QQuickGridView::LeftToRight << Qt::LeftToRight + << QPointF(0, 3 * 60) // 180 = height of 3 rows (cell height is 60) + << QPointF(0, 10 * 60) // 30 items = 10 rows + << QPointF(0, 0) + << QPointF(0, 0) + << QPointF(0, 0) + << QPointF(0, 10 * 60 - 320 + 10); + + // footer below items, bottom right + QTest::newRow("flow left to right, layout right to left") << QQuickGridView::LeftToRight << Qt::RightToLeft + << QPointF(240 - 100, 3 * 60) + << QPointF((240 - 100) + 50, 10 * 60) // 50 = width diff between old and new footers + << QPointF(0, 0) + << QPointF(0, 0) + << QPointF(240 - 80, 0) + << QPointF(0, 10 * 60 - 320 + 10); + + // footer to right of items + QTest::newRow("flow top to bottom, layout left to right") << QQuickGridView::TopToBottom << Qt::LeftToRight + << QPointF(2 * 80, 0) // 2 columns, cell width 80 + << QPointF(6 * 80, 0) // 30 items = 6 columns + << QPointF(0, 0) + << QPointF(0, 0) + << QPointF(0, 0) + << QPointF(6 * 80 - 240 + 40, 0); + + // footer to left of items + QTest::newRow("flow top to bottom, layout right to left") << QQuickGridView::TopToBottom << Qt::RightToLeft + << QPointF(-(2 * 80) - 100, 0) + << QPointF(-(6 * 80) - 50, 0) // 50 = new footer width + << QPointF(-240, 0) + << QPointF(-240, 0) // unchanged, footer change doesn't change content pos + << QPointF(-80, 0) + << QPointF(-(6 * 80) - 40, 0); +} + +void tst_QQuickGridView::header() +{ + QFETCH(QQuickGridView::Flow, flow); + QFETCH(Qt::LayoutDirection, layoutDirection); + QFETCH(QPointF, initialHeaderPos); + QFETCH(QPointF, changedHeaderPos); + QFETCH(QPointF, initialContentPos); + QFETCH(QPointF, changedContentPos); + QFETCH(QPointF, firstDelegatePos); + QFETCH(QPointF, resizeContentPos); + + QaimModel model; + for (int i = 0; i < 30; i++) + model.addItem("Item" + QString::number(i), ""); + + QQuickView *canvas = createView(); + canvas->rootContext()->setContextProperty("testModel", &model); + canvas->rootContext()->setContextProperty("initialViewWidth", 240); + canvas->rootContext()->setContextProperty("initialViewHeight", 320); + canvas->setSource(testFileUrl("header.qml")); + canvas->show(); + qApp->processEvents(); + + QQuickGridView *gridview = findItem(canvas->rootObject(), "grid"); + QTRY_VERIFY(gridview != 0); + gridview->setFlow(flow); + gridview->setLayoutDirection(layoutDirection); + QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false); + + QQuickItem *contentItem = gridview->contentItem(); + QTRY_VERIFY(contentItem != 0); + + QQuickText *header = findItem(contentItem, "header"); + QVERIFY(header); + + QVERIFY(header == gridview->headerItem()); + + QCOMPARE(header->pos(), initialHeaderPos); + QCOMPARE(header->width(), 100.); + QCOMPARE(header->height(), 30.); + QCOMPARE(QPointF(gridview->contentX(), gridview->contentY()), initialContentPos); + + QQuickItem *item = findItem(contentItem, "wrapper", 0); + QVERIFY(item); + QCOMPARE(item->pos(), firstDelegatePos); + + model.clear(); + QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false); + QCOMPARE(header->pos(), initialHeaderPos); // header should stay where it is + + for (int i = 0; i < 30; i++) + model.addItem("Item" + QString::number(i), ""); + + QSignalSpy headerItemSpy(gridview, SIGNAL(headerItemChanged())); + QMetaObject::invokeMethod(canvas->rootObject(), "changeHeader"); + + QCOMPARE(headerItemSpy.count(), 1); + + header = findItem(contentItem, "header"); + QVERIFY(!header); + header = findItem(contentItem, "header2"); + QVERIFY(header); + + QVERIFY(header == gridview->headerItem()); + + QCOMPARE(header->pos(), changedHeaderPos); + QCOMPARE(header->width(), 50.); + QCOMPARE(header->height(), 20.); + QTRY_COMPARE(QPointF(gridview->contentX(), gridview->contentY()), changedContentPos); + + item = findItem(contentItem, "wrapper", 0); + QVERIFY(item); + QCOMPARE(item->pos(), firstDelegatePos); + + header->setHeight(10); + header->setWidth(40); + QTRY_COMPARE(QPointF(gridview->contentX(), gridview->contentY()), resizeContentPos); + + delete canvas; + + + // QTBUG-21207 header should become visible if view resizes from initial empty size + + canvas = createView(); + canvas->rootContext()->setContextProperty("testModel", &model); + canvas->rootContext()->setContextProperty("initialViewWidth", 240); + canvas->rootContext()->setContextProperty("initialViewHeight", 320); + canvas->setSource(testFileUrl("header.qml")); + canvas->show(); + qApp->processEvents(); + + gridview = findItem(canvas->rootObject(), "grid"); + QTRY_VERIFY(gridview != 0); + gridview->setFlow(flow); + gridview->setLayoutDirection(layoutDirection); + QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false); + + gridview->setWidth(240); + gridview->setHeight(320); + QTRY_COMPARE(gridview->headerItem()->pos(), initialHeaderPos); + QCOMPARE(QPointF(gridview->contentX(), gridview->contentY()), initialContentPos); + + delete canvas; +} + +void tst_QQuickGridView::header_data() +{ + QTest::addColumn("flow"); + QTest::addColumn("layoutDirection"); + QTest::addColumn("initialHeaderPos"); + QTest::addColumn("changedHeaderPos"); + QTest::addColumn("initialContentPos"); + QTest::addColumn("changedContentPos"); + QTest::addColumn("firstDelegatePos"); + QTest::addColumn("resizeContentPos"); + + // header1 = 100 x 30 + // header2 = 50 x 20 + // cells = 80 x 60 + // view width = 240 + + // header above items, top left + QTest::newRow("flow left to right") << QQuickGridView::LeftToRight << Qt::LeftToRight + << QPointF(0, -30) + << QPointF(0, -20) + << QPointF(0, -30) + << QPointF(0, -20) + << QPointF(0, 0) + << QPointF(0, -10); + + // header above items, top right + QTest::newRow("flow left to right, layout right to left") << QQuickGridView::LeftToRight << Qt::RightToLeft + << QPointF(240 - 100, -30) + << QPointF((240 - 100) + 50, -20) // 50 = width diff between old and new headers + << QPointF(0, -30) + << QPointF(0, -20) + << QPointF(160, 0) + << QPointF(0, -10); + + // header to left of items + QTest::newRow("flow top to bottom, layout left to right") << QQuickGridView::TopToBottom << Qt::LeftToRight + << QPointF(-100, 0) + << QPointF(-50, 0) + << QPointF(-100, 0) + << QPointF(-50, 0) + << QPointF(0, 0) + << QPointF(-40, 0); + + // header to right of items + QTest::newRow("flow top to bottom, layout right to left") << QQuickGridView::TopToBottom << Qt::RightToLeft + << QPointF(0, 0) + << QPointF(0, 0) + << QPointF(-(240 - 100), 0) + << QPointF(-(240 - 50), 0) + << QPointF(-80, 0) + << QPointF(-(240 - 40), 0); +} + +void tst_QQuickGridView::resizeViewAndRepaint() +{ + QQuickView *canvas = createView(); + canvas->show(); + + QaimModel model; + for (int i = 0; i < 40; i++) + model.addItem("Item" + QString::number(i), ""); + + QQmlContext *ctxt = canvas->rootContext(); + ctxt->setContextProperty("testModel", &model); + ctxt->setContextProperty("initialWidth", 240); + ctxt->setContextProperty("initialHeight", 100); + + canvas->setSource(testFileUrl("resizeview.qml")); + canvas->show(); + qApp->processEvents(); + + QQuickGridView *gridview = findItem(canvas->rootObject(), "grid"); + QTRY_VERIFY(gridview != 0); + QQuickItem *contentItem = gridview->contentItem(); + QTRY_VERIFY(contentItem != 0); + QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false); + + // item at index 10 should not be currently visible + QVERIFY(!findItem(contentItem, "wrapper", 10)); + + gridview->setHeight(320); + QTRY_VERIFY(findItem(contentItem, "wrapper", 10)); + + gridview->setHeight(100); + QTRY_VERIFY(!findItem(contentItem, "wrapper", 10)); + + // Ensure we handle -ve sizes + gridview->setHeight(-100); + QTRY_COMPARE(findItems(contentItem, "wrapper", false).count(), 3); + + gridview->setCacheBuffer(120); + QTRY_COMPARE(findItems(contentItem, "wrapper", false).count(), 9); + + // ensure items in cache become visible + gridview->setHeight(120); + QTRY_COMPARE(findItems(contentItem, "wrapper", false).count(), 15); + + int itemCount = findItems(contentItem, "wrapper").count(); + for (int i = 0; i < model.count() && i < itemCount; ++i) { + QQuickItem *item = findItem(contentItem, "wrapper", i); + if (!item) qWarning() << "Item" << i << "not found"; + QTRY_VERIFY(item); + QTRY_COMPARE(item->x(), qreal((i%3)*80)); + QTRY_COMPARE(item->y(), qreal((i/3)*60)); + QCOMPARE(item->isVisible(), i < 9); // inside view visible, outside not visible + } + + // ensure items outside view become invisible + gridview->setHeight(60); + QTRY_COMPARE(findItems(contentItem, "wrapper", false).count(), 12); + + itemCount = findItems(contentItem, "wrapper", false).count(); + for (int i = 0; i < model.count() && i < itemCount; ++i) { + QQuickItem *item = findItem(contentItem, "wrapper", i); + if (!item) qWarning() << "Item" << i << "not found"; + QTRY_VERIFY(item); + QTRY_COMPARE(item->x(), qreal((i%3)*80)); + QTRY_COMPARE(item->y(), qreal((i/3)*60)); + QCOMPARE(item->isVisible(), i < 6); // inside view visible, outside not visible + } + + delete canvas; +} + +void tst_QQuickGridView::changeColumnCount() +{ + QmlListModel model; + for (int i = 0; i < 40; i++) + model.addItem("Item" + QString::number(i), ""); + + QQuickView *canvas = createView(); + QQmlContext *ctxt = canvas->rootContext(); + ctxt->setContextProperty("testModel", &model); + ctxt->setContextProperty("initialWidth", 100); + ctxt->setContextProperty("initialHeight", 320); + canvas->setSource(testFileUrl("resizeview.qml")); + canvas->show(); + qApp->processEvents(); + + QQuickGridView *gridview = findItem(canvas->rootObject(), "grid"); + QTRY_VERIFY(gridview != 0); + QQuickItem *contentItem = gridview->contentItem(); + QTRY_VERIFY(contentItem != 0); + QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false); + + // a single column of 6 items are visible + int itemCount = findItems(contentItem, "wrapper").count(); + QCOMPARE(itemCount, 6); + for (int i = 0; i < model.count() && i < itemCount; ++i) { + QQuickItem *item = findItem(contentItem, "wrapper", i); + QVERIFY2(item, QTest::toString(QString("Item %1 not found").arg(i))); + QCOMPARE(item->x(), 0.0); + QCOMPARE(item->y(), qreal(i*60)); + } + + // now 6x3 grid is visible, plus 1 extra below for refill + gridview->setWidth(240); + QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false); + itemCount = findItems(contentItem, "wrapper").count(); + QCOMPARE(itemCount, 6*3 + 1); + for (int i = 0; i < model.count() && i < itemCount; ++i) { + QQuickItem *item = findItem(contentItem, "wrapper", i); + QVERIFY2(item, QTest::toString(QString("Item %1 not found").arg(i))); + QCOMPARE(item->x(), qreal((i%3)*80)); + QCOMPARE(item->y(), qreal((i/3)*60)); + } + + // back to single column + gridview->setWidth(100); + QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false); + itemCount = findItems(contentItem, "wrapper").count(); + QCOMPARE(itemCount, 6); + for (int i = 0; i < model.count() && i < itemCount; ++i) { + QQuickItem *item = findItem(contentItem, "wrapper", i); + QVERIFY2(item, QTest::toString(QString("Item %1 not found").arg(i))); + QCOMPARE(item->x(), 0.0); + QCOMPARE(item->y(), qreal(i*60)); + } + + delete canvas; +} + +void tst_QQuickGridView::indexAt_itemAt_data() +{ + QTest::addColumn("x"); + QTest::addColumn("y"); + QTest::addColumn("index"); + + QTest::newRow("Item 0 - 0, 0") << 0. << 0. << 0; + QTest::newRow("Item 0 - 79, 59") << 79. << 59. << 0; + QTest::newRow("Item 1 - 80, 0") << 80. << 0. << 1; + QTest::newRow("Item 3 - 0, 60") << 0. << 60. << 3; + QTest::newRow("No Item - 240, 0") << 240. << 0. << -1; +} + +void tst_QQuickGridView::indexAt_itemAt() +{ + QFETCH(qreal, x); + QFETCH(qreal, y); + QFETCH(int, index); + + QQuickView *canvas = createView(); + + QaimModel model; + model.addItem("Fred", "12345"); + model.addItem("John", "2345"); + model.addItem("Bob", "54321"); + model.addItem("Billy", "22345"); + model.addItem("Sam", "2945"); + model.addItem("Ben", "04321"); + model.addItem("Jim", "0780"); + + QQmlContext *ctxt = canvas->rootContext(); + ctxt->setContextProperty("testModel", &model); + ctxt->setContextProperty("testRightToLeft", QVariant(false)); + ctxt->setContextProperty("testTopToBottom", QVariant(false)); + + canvas->setSource(testFileUrl("gridview1.qml")); + qApp->processEvents(); + + QQuickGridView *gridview = findItem(canvas->rootObject(), "grid"); + QTRY_VERIFY(gridview != 0); + + QQuickItem *contentItem = gridview->contentItem(); + QTRY_VERIFY(contentItem != 0); + + QTRY_COMPARE(gridview->count(), model.count()); + + QQuickItem *item = 0; + if (index >= 0) { + item = findItem(contentItem, "wrapper", index); + QVERIFY(item); + } + QCOMPARE(gridview->indexAt(x, y), index); + QVERIFY(gridview->itemAt(x, y) == item); + + delete canvas; +} + +void tst_QQuickGridView::onAdd() +{ + QFETCH(int, initialItemCount); + QFETCH(int, itemsToAdd); + + const int delegateWidth = 50; + const int delegateHeight = 100; + QaimModel model; + QQuickView *canvas = createView(); + canvas->setGeometry(0,0,5 * delegateWidth, 5 * delegateHeight); // just ensure all items fit + + // these initial items should not trigger GridView.onAdd + for (int i=0; irootContext(); + ctxt->setContextProperty("testModel", &model); + ctxt->setContextProperty("delegateWidth", delegateWidth); + ctxt->setContextProperty("delegateHeight", delegateHeight); + canvas->setSource(testFileUrl("attachedSignals.qml")); + + QObject *object = canvas->rootObject(); + object->setProperty("width", canvas->width()); + object->setProperty("height", canvas->height()); + qApp->processEvents(); + + QList > items; + for (int i=0; i(canvas->rootObject())->count()); + qApp->processEvents(); + + QVariantList result = object->property("addedDelegates").toList(); + QTRY_COMPARE(result.count(), items.count()); + for (int i=0; i("initialItemCount"); + QTest::addColumn("itemsToAdd"); + + QTest::newRow("0, add 1") << 0 << 1; + QTest::newRow("0, add 2") << 0 << 2; + QTest::newRow("0, add 10") << 0 << 10; + + QTest::newRow("1, add 1") << 1 << 1; + QTest::newRow("1, add 2") << 1 << 2; + QTest::newRow("1, add 10") << 1 << 10; + + QTest::newRow("5, add 1") << 5 << 1; + QTest::newRow("5, add 2") << 5 << 2; + QTest::newRow("5, add 10") << 5 << 10; +} + +void tst_QQuickGridView::onRemove() +{ + QFETCH(int, initialItemCount); + QFETCH(int, indexToRemove); + QFETCH(int, removeCount); + + const int delegateWidth = 50; + const int delegateHeight = 100; + QaimModel model; + for (int i=0; irootContext(); + ctxt->setContextProperty("testModel", &model); + ctxt->setContextProperty("delegateWidth", delegateWidth); + ctxt->setContextProperty("delegateHeight", delegateHeight); + canvas->setSource(testFileUrl("attachedSignals.qml")); + QObject *object = canvas->rootObject(); + + model.removeItems(indexToRemove, removeCount); + QTRY_COMPARE(model.count(), qobject_cast(canvas->rootObject())->count()); + QCOMPARE(object->property("removedDelegateCount"), QVariant(removeCount)); + + delete canvas; +} + +void tst_QQuickGridView::onRemove_data() +{ + QTest::addColumn("initialItemCount"); + QTest::addColumn("indexToRemove"); + QTest::addColumn("removeCount"); + + QTest::newRow("remove first") << 1 << 0 << 1; + QTest::newRow("two items, remove first") << 2 << 0 << 1; + QTest::newRow("two items, remove last") << 2 << 1 << 1; + QTest::newRow("two items, remove all") << 2 << 0 << 2; + + QTest::newRow("four items, remove first") << 4 << 0 << 1; + QTest::newRow("four items, remove 0-2") << 4 << 0 << 2; + QTest::newRow("four items, remove 1-3") << 4 << 1 << 2; + QTest::newRow("four items, remove 2-4") << 4 << 2 << 2; + QTest::newRow("four items, remove last") << 4 << 3 << 1; + QTest::newRow("four items, remove all") << 4 << 0 << 4; + + QTest::newRow("ten items, remove 1-8") << 10 << 0 << 8; + QTest::newRow("ten items, remove 2-7") << 10 << 2 << 5; + QTest::newRow("ten items, remove 4-10") << 10 << 4 << 6; +} + +void tst_QQuickGridView::columnCount() +{ + QQuickView canvas; + canvas.setSource(testFileUrl("gridview4.qml")); + canvas.show(); + canvas.requestActivateWindow(); + QTest::qWaitForWindowShown(&canvas); + + QQuickGridView *view = qobject_cast(canvas.rootObject()); + + QCOMPARE(view->cellWidth(), qreal(405)/qreal(9)); + QCOMPARE(view->cellHeight(), qreal(100)); + + QList items = findItems(view, "delegate"); + QCOMPARE(items.size(), 18); + QCOMPARE(items.at(8)->y(), qreal(0)); + QCOMPARE(items.at(9)->y(), qreal(100)); +} + +void tst_QQuickGridView::margins() +{ + { + QQuickView *canvas = createView(); + + QaimModel model; + for (int i = 0; i < 40; i++) + model.addItem("Item" + QString::number(i), ""); + + QQmlContext *ctxt = canvas->rootContext(); + ctxt->setContextProperty("testModel", &model); + ctxt->setContextProperty("testRightToLeft", QVariant(false)); + + canvas->setSource(testFileUrl("margins.qml")); + canvas->show(); + qApp->processEvents(); + + QQuickGridView *gridview = findItem(canvas->rootObject(), "grid"); + QTRY_VERIFY(gridview != 0); + QQuickItem *contentItem = gridview->contentItem(); + QTRY_VERIFY(contentItem != 0); + QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false); + + QCOMPARE(gridview->contentX(), -30.); + QCOMPARE(gridview->xOrigin(), 0.); + + // check end bound + gridview->positionViewAtEnd(); + qreal pos = gridview->contentX(); + gridview->setContentX(pos + 80); + gridview->returnToBounds(); + QTRY_COMPARE(gridview->contentX(), pos + 50); + + // remove item before visible and check that left margin is maintained + // and xOrigin is updated + gridview->setContentX(200); + model.removeItems(0, 4); + QTest::qWait(100); + gridview->setContentX(-50); + gridview->returnToBounds(); + QCOMPARE(gridview->xOrigin(), 100.); + QTRY_COMPARE(gridview->contentX(), 70.); + + // reduce left margin + gridview->setLeftMargin(20); + QCOMPARE(gridview->xOrigin(), 100.); + QTRY_COMPARE(gridview->contentX(), 80.); + + // check end bound + gridview->positionViewAtEnd(); + QCOMPARE(gridview->xOrigin(), 0.); // positionViewAtEnd() resets origin + pos = gridview->contentX(); + gridview->setContentX(pos + 80); + gridview->returnToBounds(); + QTRY_COMPARE(gridview->contentX(), pos + 50); + + // reduce right margin + pos = gridview->contentX(); + gridview->setRightMargin(40); + QCOMPARE(gridview->xOrigin(), 0.); + QTRY_COMPARE(gridview->contentX(), pos-10); + + delete canvas; + } + { + //RTL + QQuickView *canvas = createView(); + canvas->show(); + + QaimModel model; + for (int i = 0; i < 40; i++) + model.addItem("Item" + QString::number(i), ""); + + QQmlContext *ctxt = canvas->rootContext(); + ctxt->setContextProperty("testModel", &model); + ctxt->setContextProperty("testRightToLeft", QVariant(true)); + + canvas->setSource(testFileUrl("margins.qml")); + qApp->processEvents(); + + QQuickGridView *gridview = findItem(canvas->rootObject(), "grid"); + QTRY_VERIFY(gridview != 0); + + QQuickItem *contentItem = gridview->contentItem(); + QTRY_VERIFY(contentItem != 0); + + QCOMPARE(gridview->contentX(), -240+30.); + QCOMPARE(gridview->xOrigin(), 0.); + + // check end bound + gridview->positionViewAtEnd(); + qreal pos = gridview->contentX(); + gridview->setContentX(pos - 80); + gridview->returnToBounds(); + QTRY_COMPARE(gridview->contentX(), pos - 50); + + // remove item before visible and check that left margin is maintained + // and xOrigin is updated + gridview->setContentX(-400); + model.removeItems(0, 4); + QTest::qWait(100); + gridview->setContentX(-240+50); + gridview->returnToBounds(); + QCOMPARE(gridview->xOrigin(), -100.); + QTRY_COMPARE(gridview->contentX(), -240-70.); + + // reduce left margin (i.e. right side due to RTL) + pos = gridview->contentX(); + gridview->setLeftMargin(20); + QCOMPARE(gridview->xOrigin(), -100.); + QTRY_COMPARE(gridview->contentX(), -240-80.); + + // check end bound + gridview->positionViewAtEnd(); + QCOMPARE(gridview->xOrigin(), 0.); // positionViewAtEnd() resets origin + pos = gridview->contentX(); + gridview->setContentX(pos - 80); + gridview->returnToBounds(); + QTRY_COMPARE(gridview->contentX(), pos - 50); + + // reduce right margin (i.e. left side due to RTL) + pos = gridview->contentX(); + gridview->setRightMargin(40); + QCOMPARE(gridview->xOrigin(), 0.); + QTRY_COMPARE(gridview->contentX(), pos+10); + + delete canvas; + } +} + +void tst_QQuickGridView::creationContext() +{ + QQuickView canvas; + canvas.setGeometry(0,0,240,320); + canvas.setSource(testFileUrl("creationContext.qml")); + qApp->processEvents(); + + QQuickItem *rootItem = qobject_cast(canvas.rootObject()); + QVERIFY(rootItem); + QVERIFY(rootItem->property("count").toInt() > 0); + + QQuickItem *item; + QVERIFY(item = rootItem->findChild("listItem")); + QCOMPARE(item->property("text").toString(), QString("Hello!")); + QVERIFY(item = rootItem->findChild("header")); + QCOMPARE(item->property("text").toString(), QString("Hello!")); + QVERIFY(item = rootItem->findChild("footer")); + QCOMPARE(item->property("text").toString(), QString("Hello!")); +} + +void tst_QQuickGridView::snapToRow_data() +{ + QTest::addColumn("flow"); + QTest::addColumn("layoutDirection"); + QTest::addColumn("highlightRangeMode"); + QTest::addColumn("flickStart"); + QTest::addColumn("flickEnd"); + QTest::addColumn("snapAlignment"); + QTest::addColumn("endExtent"); + QTest::addColumn("startExtent"); + + QTest::newRow("vertical, left to right") << QQuickGridView::LeftToRight << Qt::LeftToRight << int(QQuickItemView::NoHighlightRange) + << QPoint(20, 200) << QPoint(20, 20) << 60.0 << 1200.0 << 0.0; + + QTest::newRow("horizontal, left to right") << QQuickGridView::TopToBottom << Qt::LeftToRight << int(QQuickItemView::NoHighlightRange) + << QPoint(200, 20) << QPoint(20, 20) << 60.0 << 1200.0 << 0.0; + + QTest::newRow("horizontal, right to left") << QQuickGridView::TopToBottom << Qt::RightToLeft << int(QQuickItemView::NoHighlightRange) + << QPoint(20, 20) << QPoint(200, 20) << -60.0 << -1200.0 - 240.0 << -240.0; + + QTest::newRow("vertical, left to right, enforce range") << QQuickGridView::LeftToRight << Qt::LeftToRight << int(QQuickItemView::StrictlyEnforceRange) + << QPoint(20, 200) << QPoint(20, 20) << 60.0 << 1340.0 << -20.0; + + QTest::newRow("horizontal, left to right, enforce range") << QQuickGridView::TopToBottom << Qt::LeftToRight << int(QQuickItemView::StrictlyEnforceRange) + << QPoint(200, 20) << QPoint(20, 20) << 60.0 << 1340.0 << -20.0; + + QTest::newRow("horizontal, right to left, enforce range") << QQuickGridView::TopToBottom << Qt::RightToLeft << int(QQuickItemView::StrictlyEnforceRange) + << QPoint(20, 20) << QPoint(200, 20) << -60.0 << -1200.0 - 240.0 - 140.0 << -220.0; +} + +void tst_QQuickGridView::snapToRow() +{ + QFETCH(QQuickGridView::Flow, flow); + QFETCH(Qt::LayoutDirection, layoutDirection); + QFETCH(int, highlightRangeMode); + QFETCH(QPoint, flickStart); + QFETCH(QPoint, flickEnd); + QFETCH(qreal, snapAlignment); + QFETCH(qreal, endExtent); + QFETCH(qreal, startExtent); + + QQuickView *canvas = createView(); + + canvas->setSource(testFileUrl("snapToRow.qml")); + canvas->show(); + qApp->processEvents(); + + QQuickGridView *gridview = findItem(canvas->rootObject(), "grid"); + QTRY_VERIFY(gridview != 0); + + gridview->setFlow(flow); + gridview->setLayoutDirection(layoutDirection); + gridview->setHighlightRangeMode(QQuickItemView::HighlightRangeMode(highlightRangeMode)); + QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false); + + QQuickItem *contentItem = gridview->contentItem(); + QTRY_VERIFY(contentItem != 0); + + // confirm that a flick hits an item boundary + flick(canvas, flickStart, flickEnd, 180); + QTRY_VERIFY(gridview->isMoving() == false); // wait until it stops + if (flow == QQuickGridView::LeftToRight) + QCOMPARE(qreal(fmod(gridview->contentY(),80.0)), snapAlignment); + else + QCOMPARE(qreal(fmod(gridview->contentX(),80.0)), snapAlignment); + + // flick to end + do { + flick(canvas, flickStart, flickEnd, 180); + QTRY_VERIFY(gridview->isMoving() == false); // wait until it stops + } while (flow == QQuickGridView::LeftToRight + ? !gridview->isAtYEnd() + : layoutDirection == Qt::LeftToRight ? !gridview->isAtXEnd() : !gridview->isAtXBeginning()); + + if (flow == QQuickGridView::LeftToRight) + QCOMPARE(gridview->contentY(), endExtent); + else + QCOMPARE(gridview->contentX(), endExtent); + + // flick to start + do { + flick(canvas, flickEnd, flickStart, 180); + QTRY_VERIFY(gridview->isMoving() == false); // wait until it stops + } while (flow == QQuickGridView::LeftToRight + ? !gridview->isAtYBeginning() + : layoutDirection == Qt::LeftToRight ? !gridview->isAtXBeginning() : !gridview->isAtXEnd()); + + if (flow == QQuickGridView::LeftToRight) + QCOMPARE(gridview->contentY(), startExtent); + else + QCOMPARE(gridview->contentX(), startExtent); + + delete canvas; +} + +void tst_QQuickGridView::snapOneRow_data() +{ + QTest::addColumn("flow"); + QTest::addColumn("layoutDirection"); + QTest::addColumn("highlightRangeMode"); + QTest::addColumn("flickStart"); + QTest::addColumn("flickEnd"); + QTest::addColumn("snapAlignment"); + QTest::addColumn("endExtent"); + QTest::addColumn("startExtent"); + + QTest::newRow("vertical, left to right") << QQuickGridView::LeftToRight << Qt::LeftToRight << int(QQuickItemView::NoHighlightRange) + << QPoint(20, 200) << QPoint(20, 20) << 100.0 << 360.0 << 0.0; + + QTest::newRow("horizontal, left to right") << QQuickGridView::TopToBottom << Qt::LeftToRight << int(QQuickItemView::NoHighlightRange) + << QPoint(200, 20) << QPoint(20, 20) << 100.0 << 360.0 << 0.0; + + QTest::newRow("horizontal, right to left") << QQuickGridView::TopToBottom << Qt::RightToLeft << int(QQuickItemView::NoHighlightRange) + << QPoint(20, 20) << QPoint(200, 20) << -340.0 << -360.0 - 240.0 << -240.0; + + QTest::newRow("vertical, left to right, enforce range") << QQuickGridView::LeftToRight << Qt::LeftToRight << int(QQuickItemView::StrictlyEnforceRange) + << QPoint(20, 200) << QPoint(20, 20) << 100.0 << 460.0 << -20.0; + + QTest::newRow("horizontal, left to right, enforce range") << QQuickGridView::TopToBottom << Qt::LeftToRight << int(QQuickItemView::StrictlyEnforceRange) + << QPoint(200, 20) << QPoint(20, 20) << 100.0 << 460.0 << -20.0; + + QTest::newRow("horizontal, right to left, enforce range") << QQuickGridView::TopToBottom << Qt::RightToLeft << int(QQuickItemView::StrictlyEnforceRange) + << QPoint(20, 20) << QPoint(200, 20) << -340.0 << -360.0 - 240.0 - 100.0 << -220.0; +} + +void tst_QQuickGridView::snapOneRow() +{ + QFETCH(QQuickGridView::Flow, flow); + QFETCH(Qt::LayoutDirection, layoutDirection); + QFETCH(int, highlightRangeMode); + QFETCH(QPoint, flickStart); + QFETCH(QPoint, flickEnd); + QFETCH(qreal, snapAlignment); + QFETCH(qreal, endExtent); + QFETCH(qreal, startExtent); + + QQuickView *canvas = createView(); + + canvas->setSource(testFileUrl("snapOneRow.qml")); + canvas->show(); + qApp->processEvents(); + + QQuickGridView *gridview = findItem(canvas->rootObject(), "grid"); + QTRY_VERIFY(gridview != 0); + + gridview->setFlow(flow); + gridview->setLayoutDirection(layoutDirection); + gridview->setHighlightRangeMode(QQuickItemView::HighlightRangeMode(highlightRangeMode)); + QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false); + + QQuickItem *contentItem = gridview->contentItem(); + QTRY_VERIFY(contentItem != 0); + + QSignalSpy currentIndexSpy(gridview, SIGNAL(currentIndexChanged())); + + // confirm that a flick hits next row boundary + flick(canvas, flickStart, flickEnd, 180); + QTRY_VERIFY(gridview->isMoving() == false); // wait until it stops + if (flow == QQuickGridView::LeftToRight) + QCOMPARE(gridview->contentY(), snapAlignment); + else + QCOMPARE(gridview->contentX(), snapAlignment); + + if (QQuickItemView::HighlightRangeMode(highlightRangeMode) == QQuickItemView::StrictlyEnforceRange) { + QCOMPARE(gridview->currentIndex(), 2); + QCOMPARE(currentIndexSpy.count(), 1); + } + + // flick to end + do { + flick(canvas, flickStart, flickEnd, 180); + QTRY_VERIFY(gridview->isMoving() == false); // wait until it stops + } while (flow == QQuickGridView::LeftToRight + ? !gridview->isAtYEnd() + : layoutDirection == Qt::LeftToRight ? !gridview->isAtXEnd() : !gridview->isAtXBeginning()); + + if (QQuickItemView::HighlightRangeMode(highlightRangeMode) == QQuickItemView::StrictlyEnforceRange) { + QCOMPARE(gridview->currentIndex(), 8); + QCOMPARE(currentIndexSpy.count(), 4); + } + + if (flow == QQuickGridView::LeftToRight) + QCOMPARE(gridview->contentY(), endExtent); + else + QCOMPARE(gridview->contentX(), endExtent); + + // flick to start + do { + flick(canvas, flickEnd, flickStart, 180); + QTRY_VERIFY(gridview->isMoving() == false); // wait until it stops + } while (flow == QQuickGridView::LeftToRight + ? !gridview->isAtYBeginning() + : layoutDirection == Qt::LeftToRight ? !gridview->isAtXBeginning() : !gridview->isAtXEnd()); + + if (flow == QQuickGridView::LeftToRight) + QCOMPARE(gridview->contentY(), startExtent); + else + QCOMPARE(gridview->contentX(), startExtent); + + if (QQuickItemView::HighlightRangeMode(highlightRangeMode) == QQuickItemView::StrictlyEnforceRange) { + QCOMPARE(gridview->currentIndex(), 0); + QCOMPARE(currentIndexSpy.count(), 8); + } + + delete canvas; +} + + +void tst_QQuickGridView::unaligned() +{ + QQuickView *canvas = createView(); + canvas->show(); + + QaimModel model; + for (int i = 0; i < 10; i++) + model.addItem("Item" + QString::number(i), ""); + + QQmlContext *ctxt = canvas->rootContext(); + ctxt->setContextProperty("testModel", &model); + + canvas->setSource(testFileUrl("unaligned.qml")); + qApp->processEvents(); + + QQuickGridView *gridview = qobject_cast(canvas->rootObject()); + QVERIFY(gridview != 0); + + QQuickItem *contentItem = gridview->contentItem(); + QVERIFY(contentItem != 0); + + for (int i = 0; i < 10; ++i) { + QQuickItem *item = findItem(contentItem, "wrapper", i); + if (!item) qWarning() << "Item" << i << "not found"; + QVERIFY(item); + QCOMPARE(item->x(), qreal((i%9)*gridview->cellWidth())); + QCOMPARE(item->y(), qreal((i/9)*gridview->cellHeight())); + } + + // appending + for (int i = 10; i < 18; ++i) { + model.addItem("Item" + QString::number(i), ""); + QQuickItem *item = 0; + QTRY_VERIFY(item = findItem(contentItem, "wrapper", i)); + QCOMPARE(item->x(), qreal((i%9)*gridview->cellWidth())); + QCOMPARE(item->y(), qreal((i/9)*gridview->cellHeight())); + } + + // inserting + for (int i = 0; i < 10; ++i) { + model.insertItem(i, "Item" + QString::number(i), ""); + QQuickItem *item = 0; + QTRY_VERIFY(item = findItem(contentItem, "wrapper", i)); + QCOMPARE(item->x(), qreal((i%9)*gridview->cellWidth())); + QCOMPARE(item->y(), qreal((i/9)*gridview->cellHeight())); + } + + // removing + model.removeItems(7, 10); + QTRY_COMPARE(model.count(), gridview->count()); + for (int i = 0; i < 18; ++i) { + QQuickItem *item = 0; + QTRY_VERIFY(item = findItem(contentItem, "wrapper", i)); + QCOMPARE(item->x(), qreal(i%9)*gridview->cellWidth()); + QCOMPARE(item->y(), qreal(i/9)*gridview->cellHeight()); + } + + delete canvas; +} + +void tst_QQuickGridView::populateTransitions() +{ + QFETCH(bool, staticallyPopulate); + QFETCH(bool, dynamicallyPopulate); + QFETCH(bool, usePopulateTransition); + + QPointF transitionFrom(-50, -50); + QPointF transitionVia(100, 100); + QaimModel model_transitionFrom; + QaimModel model_transitionVia; + + QaimModel model; + if (staticallyPopulate) { + for (int i = 0; i < 30; i++) + model.addItem("item" + QString::number(i), ""); + } + + QQuickView *canvas = createView(); + canvas->rootContext()->setContextProperty("testModel", &model); + canvas->rootContext()->setContextProperty("usePopulateTransition", usePopulateTransition); + canvas->rootContext()->setContextProperty("dynamicallyPopulate", dynamicallyPopulate); + canvas->rootContext()->setContextProperty("transitionFrom", transitionFrom); + canvas->rootContext()->setContextProperty("transitionVia", transitionVia); + canvas->rootContext()->setContextProperty("model_transitionFrom", &model_transitionFrom); + canvas->rootContext()->setContextProperty("model_transitionVia", &model_transitionVia); + canvas->setSource(testFileUrl("populateTransitions.qml")); + canvas->show(); + + QQuickGridView *gridview = findItem(canvas->rootObject(), "grid"); + QVERIFY(gridview); + QQuickItem *contentItem = gridview->contentItem(); + QVERIFY(contentItem); + + if (staticallyPopulate || dynamicallyPopulate) { + // check the populate transition is run + if (usePopulateTransition) { + QTRY_COMPARE(gridview->property("countPopulateTransitions").toInt(), 19); + } else { + QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false); + QTRY_COMPARE(gridview->property("countPopulateTransitions").toInt(), 0); + } + QTRY_COMPARE(gridview->property("countAddTransitions").toInt(), 0); + } else { + QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false); + } + + int itemCount = findItems(contentItem, "wrapper").count(); + if (usePopulateTransition) + QCOMPARE(itemCount, gridview->property("countPopulateTransitions").toInt()); + for (int i=0; i < model.count() && i < itemCount; ++i) { + QQuickItem *item = findItem(contentItem, "wrapper", i); + QVERIFY2(item, QTest::toString(QString("Item %1 not found").arg(i))); + QCOMPARE(item->x(), (i%3)*80.0); + QCOMPARE(item->y(), (i/3)*60.0); + QQuickText *name = findItem(contentItem, "textName", i); + QVERIFY(name != 0); + QTRY_COMPARE(name->text(), model.name(i)); + } + + // add an item and check this is done with add transition, not populate + model.insertItem(0, "another item", ""); + QTRY_COMPARE(gridview->property("countAddTransitions").toInt(), 1); + QTRY_COMPARE(gridview->property("countPopulateTransitions").toInt(), + (usePopulateTransition && (staticallyPopulate || dynamicallyPopulate)) ? 19 : 0); + + // clear the model + canvas->rootContext()->setContextProperty("testModel", QVariant()); + QTRY_COMPARE(gridview->count(), 0); + QTRY_COMPARE(findItems(contentItem, "wrapper").count(), 0); + gridview->setProperty("countPopulateTransitions", 0); + gridview->setProperty("countAddTransitions", 0); + + // set to a valid model and check populate transition is run a second time + model.clear(); + for (int i = 0; i < 30; i++) + model.addItem("item" + QString::number(i), ""); + canvas->rootContext()->setContextProperty("testModel", &model); + QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false); + + QTRY_COMPARE(gridview->property("countPopulateTransitions").toInt(), usePopulateTransition ? 19 : 0); + QTRY_COMPARE(gridview->property("countAddTransitions").toInt(), 0); + + itemCount = findItems(contentItem, "wrapper").count(); + if (usePopulateTransition) + QCOMPARE(itemCount, gridview->property("countPopulateTransitions").toInt()); + for (int i=0; i < model.count() && i < itemCount; ++i) { + QQuickItem *item = findItem(contentItem, "wrapper", i); + QVERIFY2(item, QTest::toString(QString("Item %1 not found").arg(i))); + QCOMPARE(item->x(), (i%3)*80.0); + QCOMPARE(item->y(), (i/3)*60.0); + QQuickText *name = findItem(contentItem, "textName", i); + QVERIFY(name != 0); + QTRY_COMPARE(name->text(), model.name(i)); + } + + // reset model and check populate transition is run again + gridview->setProperty("countPopulateTransitions", 0); + gridview->setProperty("countAddTransitions", 0); + model.reset(); + QTRY_COMPARE(gridview->property("countPopulateTransitions").toInt(), usePopulateTransition ? 19 : 0); + QTRY_COMPARE(gridview->property("countAddTransitions").toInt(), 0); + + itemCount = findItems(contentItem, "wrapper").count(); + if (usePopulateTransition) + QCOMPARE(itemCount, gridview->property("countPopulateTransitions").toInt()); + for (int i=0; i < model.count() && i < itemCount; ++i) { + QQuickItem *item = findItem(contentItem, "wrapper", i); + QVERIFY2(item, QTest::toString(QString("Item %1 not found").arg(i))); + QCOMPARE(item->x(), (i%3)*80.0); + QCOMPARE(item->y(), (i/3)*60.0); + QQuickText *name = findItem(contentItem, "textName", i); + QVERIFY(name != 0); + QTRY_COMPARE(name->text(), model.name(i)); + } + + delete canvas; +} + +void tst_QQuickGridView::populateTransitions_data() +{ + QTest::addColumn("staticallyPopulate"); + QTest::addColumn("dynamicallyPopulate"); + QTest::addColumn("usePopulateTransition"); + + QTest::newRow("static") << true << false << true; + QTest::newRow("static, no populate") << true << false << false; + + QTest::newRow("dynamic") << false << true << true; + QTest::newRow("dynamic, no populate") << false << true << false; + + QTest::newRow("empty to start with") << false << false << true; + QTest::newRow("empty to start with, no populate") << false << false << false; +} + +void tst_QQuickGridView::addTransitions() +{ + QFETCH(int, initialItemCount); + QFETCH(bool, shouldAnimateTargets); + QFETCH(qreal, contentY); + QFETCH(int, insertionIndex); + QFETCH(int, insertionCount); + QFETCH(ListRange, expectedDisplacedIndexes); + + // added items should start here + QPointF targetItems_transitionFrom(-50, -50); + + // displaced items should pass through this point + QPointF displacedItems_transitionVia(100, 100); + + QaimModel model; + for (int i = 0; i < initialItemCount; i++) + model.addItem("Original item" + QString::number(i), ""); + QaimModel model_targetItems_transitionFrom; + QaimModel model_displacedItems_transitionVia; + + QQuickView *canvas = createView(); + QQmlContext *ctxt = canvas->rootContext(); + ctxt->setContextProperty("testModel", &model); + ctxt->setContextProperty("model_targetItems_transitionFrom", &model_targetItems_transitionFrom); + ctxt->setContextProperty("model_displacedItems_transitionVia", &model_displacedItems_transitionVia); + ctxt->setContextProperty("targetItems_transitionFrom", targetItems_transitionFrom); + ctxt->setContextProperty("displacedItems_transitionVia", displacedItems_transitionVia); + canvas->setSource(testFileUrl("addTransitions.qml")); + canvas->show(); + + QQuickGridView *gridview = findItem(canvas->rootObject(), "grid"); + QTRY_VERIFY(gridview != 0); + QQuickItem *contentItem = gridview->contentItem(); + QVERIFY(contentItem != 0); + QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false); + + if (contentY != 0) { + gridview->setContentY(contentY); + QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false); + } + + QList > expectedDisplacedValues = expectedDisplacedIndexes.getModelDataValues(model); + + // only target items that will become visible should be animated + QList > newData; + QList > expectedTargetData; + QList targetIndexes; + if (shouldAnimateTargets) { + for (int i=insertionIndex; i= (contentY / 60)*3 && i < qCeil((contentY + gridview->height()) / 60.0)*3) { + expectedTargetData << newData.last(); + targetIndexes << i; + } + } + QVERIFY(expectedTargetData.count() > 0); + } + + // start animation + if (!newData.isEmpty()) { + model.insertItems(insertionIndex, newData); + QTRY_COMPARE(model.count(), gridview->count()); + } + + QList targetItems = findItems(contentItem, "wrapper", targetIndexes); + + if (shouldAnimateTargets) { + QTRY_COMPARE(gridview->property("targetTransitionsDone").toInt(), expectedTargetData.count()); + QTRY_COMPARE(gridview->property("displaceTransitionsDone").toInt(), + expectedDisplacedIndexes.isValid() ? expectedDisplacedIndexes.count() : 0); + + // check the target and displaced items were animated + model_targetItems_transitionFrom.matchAgainst(expectedTargetData, "wasn't animated from target 'from' pos", "shouldn't have been animated from target 'from' pos"); + model_displacedItems_transitionVia.matchAgainst(expectedDisplacedValues, "wasn't animated with displaced anim", "shouldn't have been animated with displaced anim"); + + // check attached properties + matchItemsAndIndexes(gridview->property("targetTrans_items").toMap(), model, targetIndexes); + matchIndexLists(gridview->property("targetTrans_targetIndexes").toList(), targetIndexes); + matchItemLists(gridview->property("targetTrans_targetItems").toList(), targetItems); + if (expectedDisplacedIndexes.isValid()) { + // adjust expectedDisplacedIndexes to their final values after the move + QList displacedIndexes = adjustIndexesForAddDisplaced(expectedDisplacedIndexes.indexes, insertionIndex, insertionCount); + matchItemsAndIndexes(gridview->property("displacedTrans_items").toMap(), model, displacedIndexes); + matchIndexLists(gridview->property("displacedTrans_targetIndexes").toList(), targetIndexes); + matchItemLists(gridview->property("displacedTrans_targetItems").toList(), targetItems); + } + } else { + QTRY_COMPARE(model_targetItems_transitionFrom.count(), 0); + QTRY_COMPARE(model_displacedItems_transitionVia.count(), 0); + } + + QList items = findItems(contentItem, "wrapper"); + int firstVisibleIndex = -1; + for (int i=0; iy() >= contentY) { + QQmlExpression e(qmlContext(items[i]), items[i], "index"); + firstVisibleIndex = e.evaluate().toInt(); + break; + } + } + QVERIFY2(firstVisibleIndex >= 0, QTest::toString(firstVisibleIndex)); + + // verify all items moved to the correct final positions + int itemCount = findItems(contentItem, "wrapper").count(); + for (int i = firstVisibleIndex; i < model.count() && i < itemCount; ++i) { + QQuickItem *item = findItem(contentItem, "wrapper", i); + QVERIFY2(item, QTest::toString(QString("Item %1 not found").arg(i))); + QCOMPARE(item->x(), (i%3)*80.0); + QCOMPARE(item->y(), (i/3)*60.0); + QQuickText *name = findItem(contentItem, "textName", i); + QVERIFY(name != 0); + QCOMPARE(name->text(), model.name(i)); + } + + delete canvas; +} + +void tst_QQuickGridView::addTransitions_data() +{ + QTest::addColumn("initialItemCount"); + QTest::addColumn("contentY"); + QTest::addColumn("shouldAnimateTargets"); + QTest::addColumn("insertionIndex"); + QTest::addColumn("insertionCount"); + QTest::addColumn("expectedDisplacedIndexes"); + + // if inserting a full row before visible index, items don't appear or animate in, even if there are > 1 new items + QTest::newRow("insert 1, just before start") + << 30 << 20.0 << false + << 0 << 1 << ListRange(); + QTest::newRow("insert 1, way before start") + << 30 << 20.0 << false + << 0 << 1 << ListRange(); + QTest::newRow("insert multiple, just before start") + << 30 << 100.0 << false + << 0 << 3 << ListRange(); + QTest::newRow("insert multiple (< 1 row), just before start") + << 30 << 100.0 << false + << 0 << 2 << ListRange(); + QTest::newRow("insert multiple, way before start") + << 30 << 100.0 << false + << 0 << 3 << ListRange(); + + QTest::newRow("insert 1 at start") + << 30 << 0.0 << true + << 0 << 1 << ListRange(0, 17); + QTest::newRow("insert multiple at start") + << 30 << 0.0 << true + << 0 << 3 << ListRange(0, 17); + QTest::newRow("insert multiple (> 1 row) at start") + << 30 << 0.0 << true + << 0 << 5 << ListRange(0, 17); + QTest::newRow("insert 1 at start, content y not 0") + << 30 << 60.0 << true // first visible is index 3 + << 3 << 1 << ListRange(0 + 3, 17 + 3); + QTest::newRow("insert multiple at start, content y not 0") + << 30 << 60.0 << true // first visible is index 3 + << 3 << 3 << ListRange(0 + 3, 17 + 3); + QTest::newRow("insert multiple (> 1 row) at start, content y not 0") + << 30 << 60.0 << true // first visible is index 3 + << 3 << 5 << ListRange(0 + 3, 17 + 3); + + QTest::newRow("insert 1 at start, to empty grid") + << 0 << 0.0 << true + << 0 << 1 << ListRange(); + QTest::newRow("insert multiple at start, to empty grid") + << 0 << 0.0 << true + << 0 << 3 << ListRange(); + + QTest::newRow("insert 1 at middle") + << 30 << 0.0 << true + << 7 << 1 << ListRange(7, 17); + QTest::newRow("insert multiple at middle") + << 30 << 0.0 << true + << 7 << 3 << ListRange(7, 17); + QTest::newRow("insert multiple (> 1 row) at middle") + << 30 << 0.0 << true + << 7 << 5 << ListRange(7, 17); + + QTest::newRow("insert 1 at bottom") + << 30 << 0.0 << true + << 17 << 1 << ListRange(17, 17); + QTest::newRow("insert multiple at bottom") + << 30 << 0.0 << true + << 17 << 3 << ListRange(17, 17); + QTest::newRow("insert 1 at bottom, content y not 0") + << 30 << 20.0 * 3 << true + << 17 + 3 << 1 << ListRange(17 + 3, 17 + 3); + QTest::newRow("insert multiple at bottom, content y not 0") + << 30 << 20.0 * 3 << true + << 17 + 3 << 3 << ListRange(17 + 3, 17 + 3); + + + // items added after the last visible will not be animated in, since they + // do not appear in the final view + QTest::newRow("insert 1 after end") + << 30 << 0.0 << false + << 18 << 1 << ListRange(); + QTest::newRow("insert multiple after end") + << 30 << 0.0 << false + << 18 << 3 << ListRange(); +} + +void tst_QQuickGridView::moveTransitions() +{ + QFETCH(int, initialItemCount); + QFETCH(qreal, contentY); + QFETCH(qreal, itemsOffsetAfterMove); + QFETCH(int, moveFrom); + QFETCH(int, moveTo); + QFETCH(int, moveCount); + QFETCH(ListRange, expectedDisplacedIndexes); + + // target and displaced items should pass through these points + QPointF targetItems_transitionVia(-50, 50); + QPointF displacedItems_transitionVia(100, 100); + + QaimModel model; + for (int i = 0; i < initialItemCount; i++) + model.addItem("Original item" + QString::number(i), ""); + QaimModel model_targetItems_transitionVia; + QaimModel model_displacedItems_transitionVia; + + QQuickView *canvas = createView(); + QQmlContext *ctxt = canvas->rootContext(); + ctxt->setContextProperty("testModel", &model); + ctxt->setContextProperty("model_targetItems_transitionVia", &model_targetItems_transitionVia); + ctxt->setContextProperty("model_displacedItems_transitionVia", &model_displacedItems_transitionVia); + ctxt->setContextProperty("targetItems_transitionVia", targetItems_transitionVia); + ctxt->setContextProperty("displacedItems_transitionVia", displacedItems_transitionVia); + canvas->setSource(testFileUrl("moveTransitions.qml")); + canvas->show(); + + QQuickGridView *gridview = findItem(canvas->rootObject(), "grid"); + QTRY_VERIFY(gridview != 0); + QQuickItem *contentItem = gridview->contentItem(); + QVERIFY(contentItem != 0); + QQuickText *name; + + if (contentY != 0) { + gridview->setContentY(contentY); + QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false); + } + + QList > expectedDisplacedValues = expectedDisplacedIndexes.getModelDataValues(model); + + // Items moving to *or* from visible positions should be animated. + // Otherwise, they should not be animated. + QList > expectedTargetData; + QList targetIndexes; + for (int i=moveFrom; iheight()) / 60.0)*3) - 1; + if ((i >= firstVisibleIndex && i <= lastVisibleIndex) + || (toIndex >= firstVisibleIndex && toIndex <= lastVisibleIndex)) { + expectedTargetData << qMakePair(model.name(i), model.number(i)); + targetIndexes << i; + } + } + // ViewTransition.index provides the indices that items are moving to, not from + targetIndexes = adjustIndexesForMove(targetIndexes, moveFrom, moveTo, moveCount); + + // start animation + model.moveItems(moveFrom, moveTo, moveCount); + + QTRY_COMPARE(gridview->property("targetTransitionsDone").toInt(), expectedTargetData.count()); + QTRY_COMPARE(gridview->property("displaceTransitionsDone").toInt(), + expectedDisplacedIndexes.isValid() ? expectedDisplacedIndexes.count() : 0); + + QList targetItems = findItems(contentItem, "wrapper", targetIndexes); + + // check the target and displaced items were animated + model_targetItems_transitionVia.matchAgainst(expectedTargetData, "wasn't animated from target 'from' pos", "shouldn't have been animated from target 'from' pos"); + model_displacedItems_transitionVia.matchAgainst(expectedDisplacedValues, "wasn't animated with displaced anim", "shouldn't have been animated with displaced anim"); + + // check attached properties + matchItemsAndIndexes(gridview->property("targetTrans_items").toMap(), model, targetIndexes); + matchIndexLists(gridview->property("targetTrans_targetIndexes").toList(), targetIndexes); + matchItemLists(gridview->property("targetTrans_targetItems").toList(), targetItems); + if (expectedDisplacedIndexes.isValid()) { + // adjust expectedDisplacedIndexes to their final values after the move + QList displacedIndexes = adjustIndexesForMove(expectedDisplacedIndexes.indexes, moveFrom, moveTo, moveCount); + matchItemsAndIndexes(gridview->property("displacedTrans_items").toMap(), model, displacedIndexes); + matchIndexLists(gridview->property("displacedTrans_targetIndexes").toList(), targetIndexes); + matchItemLists(gridview->property("displacedTrans_targetItems").toList(), targetItems); + } + + QList items = findItems(contentItem, "wrapper"); + int firstVisibleIndex = -1; + for (int i=0; iy() >= contentY) { + QQmlExpression e(qmlContext(items[i]), items[i], "index"); + firstVisibleIndex = e.evaluate().toInt(); + break; + } + } + QVERIFY2(firstVisibleIndex >= 0, QTest::toString(firstVisibleIndex)); + + // verify all items moved to the correct final positions + int itemCount = findItems(contentItem, "wrapper").count(); + for (int i=firstVisibleIndex; i < model.count() && i < itemCount; ++i) { + QQuickItem *item = findItem(contentItem, "wrapper", i); + QVERIFY2(item, QTest::toString(QString("Item %1 not found").arg(i))); + QCOMPARE(item->x(), (i%3)*80.0); + QCOMPARE(item->y(), (i/3)*60.0 + itemsOffsetAfterMove); + name = findItem(contentItem, "textName", i); + QVERIFY(name != 0); + QTRY_COMPARE(name->text(), model.name(i)); + } + + delete canvas; +} + +void tst_QQuickGridView::moveTransitions_data() +{ + QTest::addColumn("initialItemCount"); + QTest::addColumn("contentY"); + QTest::addColumn("itemsOffsetAfterMove"); + QTest::addColumn("moveFrom"); + QTest::addColumn("moveTo"); + QTest::addColumn("moveCount"); + QTest::addColumn("expectedDisplacedIndexes"); + + QTest::newRow("move from above view, outside visible items, move 1") << 30 << 120.0 << 0.0 + << 1 << 10 << 1 << ListRange(6, 10); + QTest::newRow("move from above view, outside visible items, move 1 (first item)") << 30 << 120.0 << 0.0 + << 0 << 10 << 1 << ListRange(6, 10); + QTest::newRow("move from above view, outside visible items, move multiple") << 30 << 120.0 << 60.0 + << 1 << 10 << 3 << ListRange(13, 23); + QTest::newRow("move from above view, mix of visible/non-visible") << 30 << 120.0 << 60.0 + << 1 << 10 << 6 << (ListRange(7, 15) + ListRange(16, 23)); + QTest::newRow("move from above view, mix of visible/non-visible (move first)") << 30 << 120.0 << 120.0 + << 0 << 10 << 6 << ListRange(16, 23); + + QTest::newRow("move within view, move 1 down") << 30 << 0.0 << 0.0 + << 1 << 10 << 1 << ListRange(2, 10); + QTest::newRow("move within view, move 1 down, move first item") << 30 << 0.0 << 0.0 + << 0 << 10 << 1 << ListRange(1, 10); + QTest::newRow("move within view, move 1 down, move first item, contentY not 0") << 30 << 120.0 << 0.0 + << 0+6 << 10+6 << 1 << ListRange(1+6, 10+6); + QTest::newRow("move within view, move 1 down, to last item") << 30 << 0.0 << 0.0 + << 10 << 17 << 1 << ListRange(11, 17); + QTest::newRow("move within view, move first->last") << 30 << 0.0 << 0.0 + << 0 << 17 << 1 << ListRange(1, 17); + + QTest::newRow("move within view, move multiple down") << 30 << 0.0 << 0.0 + << 1 << 10 << 3 << ListRange(4, 12); + QTest::newRow("move within view, move multiple down, move first item") << 30 << 0.0 << 0.0 + << 0 << 10 << 3 << ListRange(3, 12); + QTest::newRow("move within view, move multiple down, move first item, contentY not 0") << 30 << 60.0 << 0.0 + << 0+3 << 10+3 << 3 << ListRange(3+3, 12+3); + QTest::newRow("move within view, move multiple down, displace last item") << 30 << 0.0 << 0.0 + << 5 << 15 << 3 << ListRange(8, 17); + QTest::newRow("move within view, move multiple down, move first->last") << 30 << 0.0 << 0.0 + << 0 << 15 << 3 << ListRange(3, 17); + + QTest::newRow("move within view, move 1 up") << 30 << 0.0 << 0.0 + << 10 << 1 << 1 << ListRange(1, 9); + QTest::newRow("move within view, move 1 up, move to first index") << 30 << 0.0 << 0.0 + << 10 << 0 << 1 << ListRange(0, 9); + QTest::newRow("move within view, move 1 up, move to first index, contentY not 0") << 30 << 120.0 << 0.0 + << 10+6 << 0+6 << 1 << ListRange(0+6, 9+6); + QTest::newRow("move within view, move 1 up, move to first index, contentY not on item border") << 30 << 80.0 << 0.0 + << 10+3 << 0+3 << 1 << ListRange(0+3, 9+3); + QTest::newRow("move within view, move 1 up, move last item") << 30 << 0.0 << 0.0 + << 17 << 10 << 1 << ListRange(10, 16); + QTest::newRow("move within view, move 1 up, move last->first") << 30 << 0.0 << 0.0 + << 17 << 0 << 1 << ListRange(0, 16); + + QTest::newRow("move within view, move multiple up") << 30 << 0.0 << 0.0 + << 10 << 1 << 3 << ListRange(1, 9); + QTest::newRow("move within view, move multiple (> 1 row) up") << 30 << 0.0 << 0.0 + << 10 << 1 << 5 << ListRange(1, 9); + QTest::newRow("move within view, move multiple up, move to first index") << 30 << 0.0 << 0.0 + << 10 << 0 << 3 << ListRange(0, 9); + QTest::newRow("move within view, move multiple up, move to first index, contentY not 0") << 30 << 60.0 << 0.0 + << 10+3 << 0+3 << 3 << ListRange(0+3, 9+3); + QTest::newRow("move within view, move multiple up (> 1 row), move to first index, contentY not on border") << 30 << 80.0 << 0.0 + << 10+3 << 0+3 << 5 << ListRange(0+3, 9+3); + QTest::newRow("move within view, move multiple up, move last item") << 30 << 0.0 << 0.0 + << 15 << 5 << 3 << ListRange(5, 14); + QTest::newRow("move within view, move multiple up, move last->first") << 30 << 0.0 << 0.0 + << 15 << 0 << 3 << ListRange(0, 14); + + QTest::newRow("move from below view, move 1 up") << 30 << 0.0 << 0.0 + << 20 << 5 << 1 << ListRange(5, 17); + QTest::newRow("move from below view, move 1 up, move to top") << 30 << 0.0 << 0.0 + << 20 << 0 << 1 << ListRange(0, 17); + QTest::newRow("move from below view, move 1 up, move to top, contentY not 0") << 30 << 60.0 << 0.0 + << 25 << 3 << 1 << ListRange(0+3, 17+3); + QTest::newRow("move from below view, move multiple (> 1 row) up") << 30 << 0.0 << 0.0 + << 20 << 5 << 5 << ListRange(5, 17); + QTest::newRow("move from below view, move multiple up, move to top") << 30 << 0.0 << 0.0 + << 20 << 0 << 3 << ListRange(0, 17); + QTest::newRow("move from below view, move multiple up, move to top, contentY not 0") << 30 << 60.0 << 0.0 + << 25 << 3 << 3 << ListRange(0+3, 17+3); + + QTest::newRow("move from below view, move 1 up, move to bottom") << 30 << 0.0 << 0.0 + << 20 << 17 << 1 << ListRange(17, 17); + QTest::newRow("move from below view, move 1 up, move to bottom, contentY not 0") << 30 << 60.0 << 0.0 + << 25 << 17+3 << 1 << ListRange(17+3, 17+3); + QTest::newRow("move from below view, move multiple up, move to to bottom") << 30 << 0.0 << 0.0 + << 20 << 17 << 3 << ListRange(17, 17); + QTest::newRow("move from below view, move multiple up, move to bottom, contentY not 0") << 30 << 60.0 << 0.0 + << 25 << 17+3 << 3 << ListRange(17+3, 17+3); +} + +void tst_QQuickGridView::removeTransitions() +{ + QFETCH(int, initialItemCount); + QFETCH(bool, shouldAnimateTargets); + QFETCH(qreal, contentY); + QFETCH(int, removalIndex); + QFETCH(int, removalCount); + QFETCH(ListRange, expectedDisplacedIndexes); + + // added items should end here + QPointF targetItems_transitionTo(-50, -50); + + // displaced items should pass through this points + QPointF displacedItems_transitionVia(100, 100); + + QaimModel model; + for (int i = 0; i < initialItemCount; i++) + model.addItem("Original item" + QString::number(i), ""); + QaimModel model_targetItems_transitionTo; + QaimModel model_displacedItems_transitionVia; + + QQuickView *canvas = createView(); + QQmlContext *ctxt = canvas->rootContext(); + ctxt->setContextProperty("testModel", &model); + ctxt->setContextProperty("model_targetItems_transitionTo", &model_targetItems_transitionTo); + ctxt->setContextProperty("model_displacedItems_transitionVia", &model_displacedItems_transitionVia); + ctxt->setContextProperty("targetItems_transitionTo", targetItems_transitionTo); + ctxt->setContextProperty("displacedItems_transitionVia", displacedItems_transitionVia); + canvas->setSource(testFileUrl("removeTransitions.qml")); + canvas->show(); + + QQuickGridView *gridview = findItem(canvas->rootObject(), "grid"); + QTRY_VERIFY(gridview != 0); + QQuickItem *contentItem = gridview->contentItem(); + QVERIFY(contentItem != 0); + QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false); + + if (contentY != 0) { + gridview->setContentY(contentY); + QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false); + } + + QList > expectedDisplacedValues = expectedDisplacedIndexes.getModelDataValues(model); + + // only target items that are visible should be animated + QList > expectedTargetData; + QList targetIndexes; + if (shouldAnimateTargets) { + for (int i=removalIndex; iheight()) / 60.0)*3) - 1; + if (i >= firstVisibleIndex && i <= lastVisibleIndex) { + expectedTargetData << qMakePair(model.name(i), model.number(i)); + targetIndexes << i; + } + } + QVERIFY(expectedTargetData.count() > 0); + } + + // calculate targetItems and expectedTargets before model changes + QList targetItems = findItems(contentItem, "wrapper", targetIndexes); + QVariantMap expectedTargets; + for (int i=0; icount()); + + if (shouldAnimateTargets || expectedDisplacedIndexes.isValid()) { + QTRY_COMPARE(gridview->property("targetTransitionsDone").toInt(), expectedTargetData.count()); + QTRY_COMPARE(gridview->property("displaceTransitionsDone").toInt(), + expectedDisplacedIndexes.isValid() ? expectedDisplacedIndexes.count() : 0); + + // check the target and displaced items were animated + model_targetItems_transitionTo.matchAgainst(expectedTargetData, "wasn't animated to target 'to' pos", "shouldn't have been animated to target 'to' pos"); + model_displacedItems_transitionVia.matchAgainst(expectedDisplacedValues, "wasn't animated with displaced anim", "shouldn't have been animated with displaced anim"); + + // check attached properties + QCOMPARE(gridview->property("targetTrans_items").toMap(), expectedTargets); + matchIndexLists(gridview->property("targetTrans_targetIndexes").toList(), targetIndexes); + matchItemLists(gridview->property("targetTrans_targetItems").toList(), targetItems); + if (expectedDisplacedIndexes.isValid()) { + // adjust expectedDisplacedIndexes to their final values after the move + QList displacedIndexes = adjustIndexesForRemoveDisplaced(expectedDisplacedIndexes.indexes, removalIndex, removalCount); + matchItemsAndIndexes(gridview->property("displacedTrans_items").toMap(), model, displacedIndexes); + matchIndexLists(gridview->property("displacedTrans_targetIndexes").toList(), targetIndexes); + matchItemLists(gridview->property("displacedTrans_targetItems").toList(), targetItems); + } + } else { + QTRY_COMPARE(model_targetItems_transitionTo.count(), 0); + QTRY_COMPARE(model_displacedItems_transitionVia.count(), 0); + } + + QList items = findItems(contentItem, "wrapper"); + int itemCount = items.count(); + int firstVisibleIndex = -1; + for (int i=0; iy() >= contentY) + firstVisibleIndex = index; + else if (index < 0) + itemCount--; // exclude deleted items + } + QVERIFY2(firstVisibleIndex >= 0, QTest::toString(firstVisibleIndex)); + + // verify all items moved to the correct final positions + for (int i=firstVisibleIndex; i < model.count() && i < itemCount; ++i) { + QQuickItem *item = findItem(contentItem, "wrapper", i); + QVERIFY2(item, QTest::toString(QString("Item %1 not found").arg(i))); + QCOMPARE(item->x(), (i%3)*80.0); + QCOMPARE(item->y(), contentY + ((i-firstVisibleIndex)/3) * 60.0); + QQuickText *name = findItem(contentItem, "textName", i); + QVERIFY(name != 0); + QTRY_COMPARE(name->text(), model.name(i)); + } + + delete canvas; +} + +void tst_QQuickGridView::removeTransitions_data() +{ + QTest::addColumn("initialItemCount"); + QTest::addColumn("contentY"); + QTest::addColumn("shouldAnimateTargets"); + QTest::addColumn("removalIndex"); + QTest::addColumn("removalCount"); + QTest::addColumn("expectedDisplacedIndexes"); + + // All items that are visible following the remove operation should be animated. + // Remove targets that are outside of the view should not be animated. + + // For a GridView, removing any number of items other than a full row before the start + // should displace all items in the view + QTest::newRow("remove 1 before start") + << 30 << 120.0 << false + << 2 << 1 << ListRange(6, 24); // 6-24 are displaced + QTest::newRow("remove 1 row, before start") + << 30 << 120.0 << false + << 3 << 3 << ListRange(); + QTest::newRow("remove between 1-2 rows, before start") + << 30 << 120.0 << false + << 0 << 5 << ListRange(6, 25); + QTest::newRow("remove 2 rows, before start") + << 30 << 120.0 << false + << 0 << 6 << ListRange(); + QTest::newRow("remove mix of before and after start") + << 30 << 60.0 << true + << 2 << 3 << ListRange(5, 23); // 5-23 are displaced into view + + + QTest::newRow("remove 1 from start") + << 30 << 0.0 << true + << 0 << 1 << ListRange(1, 18); // 1-18 are displaced into view + QTest::newRow("remove multiple from start") + << 30 << 0.0 << true + << 0 << 3 << ListRange(3, 20); // 3-18 are displaced into view + QTest::newRow("remove 1 from start, content y not 0") + << 30 << 60.0 << true + << 3 << 1 << ListRange(1 + 3, 18 + 3); + QTest::newRow("remove multiple from start, content y not 0") + << 30 << 60.0 << true + << 3 << 3 << ListRange(3 + 3, 20 + 3); + + + QTest::newRow("remove 1 from middle") + << 30 << 0.0 << true + << 5 << 1 << ListRange(6, 18); + QTest::newRow("remove multiple from middle") + << 30 << 0.0 << true + << 5 << 3 << ListRange(8, 20); + + + QTest::newRow("remove 1 from bottom") + << 30 << 0.0 << true + << 17 << 1 << ListRange(18, 18); + QTest::newRow("remove multiple (1 row) from bottom") + << 30 << 0.0 << true + << 15 << 3 << ListRange(18, 20); + QTest::newRow("remove multiple (> 1 row) from bottom") + << 30 << 0.0 << true + << 15 << 5 << ListRange(20, 22); + QTest::newRow("remove 1 from bottom, content y not 0") + << 30 << 60.0 << true + << 17 + 3 << 1 << ListRange(18 + 3, 18 + 3); + QTest::newRow("remove multiple (1 row) from bottom, content y not 0") + << 30 << 60.0 << true + << 15 + 3 << 3 << ListRange(18 + 3, 20 + 3); + + + QTest::newRow("remove 1 after end") + << 30 << 0.0 << false + << 18 << 1 << ListRange(); + QTest::newRow("remove multiple after end") + << 30 << 0.0 << false + << 18 << 3 << ListRange(); +} + +void tst_QQuickGridView::multipleTransitions() +{ + // Tests that if you interrupt a transition in progress with another action that + // cancels the previous transition, the resulting items are still placed correctly. + + QFETCH(int, initialCount); + QFETCH(qreal, contentY); + QFETCH(QList, changes); + + // add transitions on the left, moves on the right + QPointF addTargets_transitionFrom(-50, -50); + QPointF addDisplaced_transitionFrom(-50, 50); + QPointF moveTargets_transitionFrom(50, -50); + QPointF moveDisplaced_transitionFrom(50, 50); + + QmlListModel model; + for (int i = 0; i < initialCount; i++) + model.addItem("Original item" + QString::number(i), ""); + + QQuickView *canvas = createView(); + QQmlContext *ctxt = canvas->rootContext(); + ctxt->setContextProperty("testModel", &model); + ctxt->setContextProperty("addTargets_transitionFrom", addTargets_transitionFrom); + ctxt->setContextProperty("addDisplaced_transitionFrom", addDisplaced_transitionFrom); + ctxt->setContextProperty("moveTargets_transitionFrom", moveTargets_transitionFrom); + ctxt->setContextProperty("moveDisplaced_transitionFrom", moveDisplaced_transitionFrom); + canvas->setSource(testFileUrl("multipleTransitions.qml")); + canvas->show(); + + QQuickGridView *gridview = findItem(canvas->rootObject(), "grid"); + QTRY_VERIFY(gridview != 0); + QQuickItem *contentItem = gridview->contentItem(); + QVERIFY(contentItem != 0); + QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false); + + int timeBetweenActions = canvas->rootObject()->property("timeBetweenActions").toInt(); + + QList > targetItems; + for (int i=0; icount()); + QTRY_VERIFY(gridview->property("runningAddTargets").toBool()); + QTRY_VERIFY(gridview->property("runningAddDisplaced").toBool()); + if (i == changes.count() - 1) { + QTRY_VERIFY(!gridview->property("runningAddTargets").toBool()); + QTRY_VERIFY(!gridview->property("runningAddDisplaced").toBool()); + } else { + QTest::qWait(timeBetweenActions); + } + break; + } + case ListChange::Removed: + for (int j=changes[i].index; jcount()); + QTRY_VERIFY(gridview->property("runningRemoveTargets").toBool()); + QTRY_VERIFY(gridview->property("runningRemoveDisplaced").toBool()); + if (i == changes.count() - 1) { + QTRY_VERIFY(!gridview->property("runningRemoveTargets").toBool()); + QTRY_VERIFY(!gridview->property("runningRemoveDisplaced").toBool()); + } else { + QTest::qWait(timeBetweenActions); + } + break; + case ListChange::Moved: + for (int j=changes[i].index; jproperty("runningMoveTargets").toBool()); + QTRY_VERIFY(gridview->property("runningMoveDisplaced").toBool()); + if (i == changes.count() - 1) { + QTRY_VERIFY(!gridview->property("runningMoveTargets").toBool()); + QTRY_VERIFY(!gridview->property("runningMoveDisplaced").toBool()); + } else { + QTest::qWait(timeBetweenActions); + } + break; + case ListChange::SetCurrent: + gridview->setCurrentIndex(changes[i].index); + QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false); + break; + case ListChange::SetContentY: + gridview->setContentY(changes[i].pos); + QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false); + break; + } + } + QCOMPARE(gridview->count(), model.count()); + + QList items = findItems(contentItem, "wrapper"); + int firstVisibleIndex = -1; + for (int i=0; iy() >= contentY) { + QQmlExpression e(qmlContext(items[i]), items[i], "index"); + firstVisibleIndex = e.evaluate().toInt(); + break; + } + } + QVERIFY2(firstVisibleIndex >= 0, QTest::toString(firstVisibleIndex)); + + // verify all items moved to the correct final positions + int itemCount = findItems(contentItem, "wrapper").count(); + for (int i=firstVisibleIndex; i < model.count() && i < itemCount; ++i) { + QQuickItem *item = findItem(contentItem, "wrapper", i); + QVERIFY2(item, QTest::toString(QString("Item %1 not found").arg(i))); + QCOMPARE(item->x(), (i%3)*80.0); + QCOMPARE(item->y(), (i/3)*60.0); + QQuickText *name = findItem(contentItem, "textName", i); + QVERIFY(name != 0); + QTRY_COMPARE(name->text(), model.name(i)); + } + + delete canvas; +} + +void tst_QQuickGridView::multipleTransitions_data() +{ + QTest::addColumn("initialCount"); + QTest::addColumn("contentY"); + QTest::addColumn >("changes"); + + // the added item and displaced items should move to final dest correctly + QTest::newRow("add item, then move it immediately") << 10 << 0.0 << (QList() + << ListChange::insert(0, 1) + << ListChange::move(0, 3, 1) + ); + + // items affected by the add should change from move to add transition + QTest::newRow("move, then insert item before the moved item") << 20 << 0.0 << (QList() + << ListChange::move(1, 10, 3) + << ListChange::insert(0, 1) + ); + + // items should be placed correctly if you trigger a transition then refill for that index + QTest::newRow("add at 0, flick down, flick back to top and add at 0 again") << 20 << 0.0 << (QList() + << ListChange::insert(0, 1) + << ListChange::setContentY(160.0) + << ListChange::setContentY(0.0) + << ListChange::insert(0, 1) + ); +} + +void tst_QQuickGridView::cacheBuffer() +{ + QQuickView *canvas = createView(); + + QaimModel model; + for (int i = 0; i < 90; i++) + model.addItem("Item" + QString::number(i), ""); + + QQmlContext *ctxt = canvas->rootContext(); + ctxt->setContextProperty("testModel", &model); + ctxt->setContextProperty("testRightToLeft", QVariant(false)); + ctxt->setContextProperty("testTopToBottom", QVariant(false)); + + canvas->setSource(testFileUrl("gridview1.qml")); + canvas->show(); + qApp->processEvents(); + + QQuickGridView *gridview = findItem(canvas->rootObject(), "grid"); + QVERIFY(gridview != 0); + + QQuickItem *contentItem = gridview->contentItem(); + QVERIFY(contentItem != 0); + QVERIFY(gridview->delegate() != 0); + QVERIFY(gridview->model() != 0); + + // Confirm items positioned correctly + int itemCount = findItems(contentItem, "wrapper", false).count(); + for (int i = 0; i < model.count() && i < itemCount; ++i) { + QQuickItem *item = findItem(contentItem, "wrapper", i); + QTRY_COMPARE(item->x(), (i%3)*80.0); + QTRY_COMPARE(item->y(), (i/3)*60.0); + } + + QQmlIncubationController controller; + canvas->engine()->setIncubationController(&controller); + + canvas->rootObject()->setProperty("cacheBuffer", 200); + QTRY_VERIFY(gridview->cacheBuffer() == 200); + + // items will be created one at a time + for (int i = itemCount; i < qMin(itemCount+9,model.count()); ++i) { + QVERIFY(findItem(gridview, "wrapper", i) == 0); + QQuickItem *item = 0; + while (!item) { + bool b = false; + controller.incubateWhile(&b); + item = findItem(gridview, "wrapper", i); + } + } + + { + bool b = true; + controller.incubateWhile(&b); + } + + int newItemCount = 0; + newItemCount = findItems(contentItem, "wrapper", false).count(); + + // Confirm items positioned correctly + for (int i = 0; i < model.count() && i < newItemCount; ++i) { + QQuickItem *item = findItem(contentItem, "wrapper", i); + QVERIFY(item); + QTRY_COMPARE(item->x(), (i%3)*80.0); + QTRY_COMPARE(item->y(), (i/3)*60.0); + } + + // move view and confirm items in view are visible immediately and outside are created async + gridview->setContentY(300); + + for (int i = 15; i < 34; ++i) { // 34 due to staggered item creation + QQuickItem *item = findItem(contentItem, "wrapper", i); + QVERIFY(item); + QTRY_COMPARE(item->x(), (i%3)*80.0); + QTRY_COMPARE(item->y(), (i/3)*60.0); + } + + QVERIFY(findItem(gridview, "wrapper", 34) == 0); + + // ensure buffered items are created + for (int i = 34; i < qMin(44,model.count()); ++i) { + QQuickItem *item = 0; + while (!item) { + qGuiApp->processEvents(); // allow refill to happen + bool b = false; + controller.incubateWhile(&b); + item = findItem(gridview, "wrapper", i); + } + } + + { + bool b = true; + controller.incubateWhile(&b); + } + + delete canvas; +} + +void tst_QQuickGridView::asynchronous() +{ + QQuickView *canvas = createView(); + canvas->show(); + QQmlIncubationController controller; + canvas->engine()->setIncubationController(&controller); + + canvas->setSource(testFile("asyncloader.qml")); + + QQuickItem *rootObject = qobject_cast(canvas->rootObject()); + QVERIFY(rootObject); + + QQuickGridView *gridview = 0; + while (!gridview) { + bool b = false; + controller.incubateWhile(&b); + gridview = rootObject->findChild("view"); + } + + // items will be created one at a time + for (int i = 0; i < 12; ++i) { + QVERIFY(findItem(gridview, "wrapper", i) == 0); + QQuickItem *item = 0; + while (!item) { + bool b = false; + controller.incubateWhile(&b); + item = findItem(gridview, "wrapper", i); + } + } + + { + bool b = true; + controller.incubateWhile(&b); + } + + // verify positioning + QQuickItem *contentItem = gridview->contentItem(); + for (int i = 0; i < 12; ++i) { + QQuickItem *item = findItem(contentItem, "wrapper", i); + if (!item) qWarning() << "Item" << i << "not found"; + QVERIFY(item->x() == (i%3)*100); + QVERIFY(item->y() == (i/3)*100); + } + + delete canvas; +} + +void tst_QQuickGridView::unrequestedVisibility() +{ + QaimModel model; + for (int i = 0; i < 30; i++) + model.addItem("Item" + QString::number(i), QString::number(i)); + + QQuickView *canvas = new QQuickView(0); + canvas->setGeometry(0,0,240,320); + + QQmlContext *ctxt = canvas->rootContext(); + ctxt->setContextProperty("testModel", &model); + ctxt->setContextProperty("testWrap", QVariant(false)); + + canvas->setSource(testFileUrl("unrequestedItems.qml")); + + canvas->show(); + + qApp->processEvents(); + + QQuickGridView *leftview = findItem(canvas->rootObject(), "leftGrid"); + QTRY_VERIFY(leftview != 0); + + QQuickGridView *rightview = findItem(canvas->rootObject(), "rightGrid"); + QTRY_VERIFY(rightview != 0); + + QQuickItem *leftContent = leftview->contentItem(); + QTRY_VERIFY(leftContent != 0); + + QQuickItem *rightContent = rightview->contentItem(); + QTRY_VERIFY(rightContent != 0); + + rightview->setCurrentIndex(12); + + QTRY_COMPARE(leftview->contentY(), 0.0); + QTRY_COMPARE(rightview->contentY(), 240.0); + + QQuickItem *item; + + QVERIFY(item = findItem(leftContent, "wrapper", 1)); + QCOMPARE(item->isVisible(), true); + QVERIFY(item = findItem(rightContent, "wrapper", 1)); + QCOMPARE(item->isVisible(), false); + + QVERIFY(item = findItem(leftContent, "wrapper", 11)); + QCOMPARE(item->isVisible(), false); + QVERIFY(item = findItem(rightContent, "wrapper", 11)); + QCOMPARE(item->isVisible(), true); + + QVERIFY(item = findItem(leftContent, "wrapper", 9)); + QCOMPARE(item->isVisible(), true); + QVERIFY(item = findItem(leftContent, "wrapper", 10)); + QCOMPARE(item->isVisible(), false); + QVERIFY(item = findItem(rightContent, "wrapper", 3)); + QCOMPARE(item->isVisible(), false); + QVERIFY(item = findItem(rightContent, "wrapper", 4)); + QCOMPARE(item->isVisible(), true); + + rightview->setCurrentIndex(0); + + QTRY_COMPARE(leftview->contentY(), 0.0); + QTRY_COMPARE(rightview->contentY(), 0.0); + + QVERIFY(item = findItem(leftContent, "wrapper", 1)); + QCOMPARE(item->isVisible(), true); + QVERIFY(item = findItem(rightContent, "wrapper", 1)); + QTRY_COMPARE(item->isVisible(), true); + + QVERIFY(!findItem(leftContent, "wrapper", 11)); + QVERIFY(!findItem(rightContent, "wrapper", 11)); + + leftview->setCurrentIndex(12); + + QTRY_COMPARE(leftview->contentY(), 240.0); + QTRY_COMPARE(rightview->contentY(), 0.0); + + QVERIFY(item = findItem(leftContent, "wrapper", 1)); + QTRY_COMPARE(item->isVisible(), false); + QVERIFY(item = findItem(rightContent, "wrapper", 1)); + QCOMPARE(item->isVisible(), true); + + QVERIFY(item = findItem(leftContent, "wrapper", 11)); + QCOMPARE(item->isVisible(), true); + QVERIFY(item = findItem(rightContent, "wrapper", 11)); + QCOMPARE(item->isVisible(), false); + + QVERIFY(item = findItem(leftContent, "wrapper", 3)); + QCOMPARE(item->isVisible(), false); + QVERIFY(item = findItem(leftContent, "wrapper", 5)); + QCOMPARE(item->isVisible(), true); + QVERIFY(item = findItem(rightContent, "wrapper", 9)); + QCOMPARE(item->isVisible(), true); + QVERIFY(item = findItem(rightContent, "wrapper", 10)); + QCOMPARE(item->isVisible(), false); + + // move a non-visible item into view + model.moveItems(10, 9, 1); + QTRY_COMPARE(QQuickItemPrivate::get(leftview)->polishScheduled, false); + + QTRY_VERIFY(item = findItem(leftContent, "wrapper", 1)); + QCOMPARE(item->isVisible(), false); + QVERIFY(item = findItem(rightContent, "wrapper", 1)); + QCOMPARE(item->isVisible(), true); + + QVERIFY(item = findItem(leftContent, "wrapper", 11)); + QCOMPARE(item->isVisible(), true); + QVERIFY(item = findItem(rightContent, "wrapper", 11)); + QCOMPARE(item->isVisible(), false); + + QVERIFY(item = findItem(leftContent, "wrapper", 3)); + QCOMPARE(item->isVisible(), false); + QVERIFY(item = findItem(leftContent, "wrapper", 5)); + QCOMPARE(item->isVisible(), true); + QVERIFY(item = findItem(rightContent, "wrapper", 9)); + QCOMPARE(item->isVisible(), true); + QVERIFY(item = findItem(rightContent, "wrapper", 10)); + QCOMPARE(item->isVisible(), false); + + // move a visible item out of view + model.moveItems(5, 3, 1); + QTRY_COMPARE(QQuickItemPrivate::get(leftview)->polishScheduled, false); + + QVERIFY(item = findItem(leftContent, "wrapper", 3)); + QCOMPARE(item->isVisible(), false); + QVERIFY(item = findItem(leftContent, "wrapper", 5)); + QCOMPARE(item->isVisible(), true); + QVERIFY(item = findItem(rightContent, "wrapper", 9)); + QCOMPARE(item->isVisible(), true); + QVERIFY(item = findItem(rightContent, "wrapper", 10)); + QCOMPARE(item->isVisible(), false); + + // move a non-visible item into view + model.moveItems(3, 5, 1); + QTRY_COMPARE(QQuickItemPrivate::get(leftview)->polishScheduled, false); + + QVERIFY(item = findItem(leftContent, "wrapper", 3)); + QCOMPARE(item->isVisible(), false); + QVERIFY(item = findItem(leftContent, "wrapper", 5)); + QCOMPARE(item->isVisible(), true); + QVERIFY(item = findItem(rightContent, "wrapper", 9)); + QCOMPARE(item->isVisible(), true); + QVERIFY(item = findItem(rightContent, "wrapper", 10)); + QCOMPARE(item->isVisible(), false); + + // move a visible item out of view + model.moveItems(9, 10, 1); + QTRY_COMPARE(QQuickItemPrivate::get(leftview)->polishScheduled, false); + + QVERIFY(item = findItem(leftContent, "wrapper", 3)); + QCOMPARE(item->isVisible(), false); + QVERIFY(item = findItem(leftContent, "wrapper", 5)); + QCOMPARE(item->isVisible(), true); + QVERIFY(item = findItem(rightContent, "wrapper", 9)); + QCOMPARE(item->isVisible(), true); + QVERIFY(item = findItem(rightContent, "wrapper", 10)); + QCOMPARE(item->isVisible(), false); + + // move a non-visible item into view + model.moveItems(10, 9, 1); + QTRY_COMPARE(QQuickItemPrivate::get(leftview)->polishScheduled, false); + + QVERIFY(item = findItem(leftContent, "wrapper", 3)); + QCOMPARE(item->isVisible(), false); + QVERIFY(item = findItem(leftContent, "wrapper", 5)); + QCOMPARE(item->isVisible(), true); + QVERIFY(item = findItem(rightContent, "wrapper", 9)); + QCOMPARE(item->isVisible(), true); + QVERIFY(item = findItem(rightContent, "wrapper", 10)); + QCOMPARE(item->isVisible(), false); + + delete canvas; +} + +QList tst_QQuickGridView::toIntList(const QVariantList &list) +{ + QList ret; + bool ok = true; + for (int i=0; i &expectedIndexes) +{ + for (int i=0; i current = indexLists[i].value >().toSet(); + if (current != expectedIndexes.toSet()) + qDebug() << "Cannot match actual targets" << current << "with expected" << expectedIndexes; + QCOMPARE(current, expectedIndexes.toSet()); + } +} + +void tst_QQuickGridView::matchItemsAndIndexes(const QVariantMap &items, const QaimModel &model, const QList &expectedIndexes) +{ + for (QVariantMap::const_iterator it = items.begin(); it != items.end(); ++it) { + QVERIFY(it.value().type() == QVariant::Int); + QString name = it.key(); + int itemIndex = it.value().toInt(); + QVERIFY2(expectedIndexes.contains(itemIndex), QTest::toString(QString("Index %1 not found in expectedIndexes").arg(itemIndex))); + if (model.name(itemIndex) != name) + qDebug() << itemIndex; + QCOMPARE(model.name(itemIndex), name); + } + QCOMPARE(items.count(), expectedIndexes.count()); +} + +void tst_QQuickGridView::matchItemLists(const QVariantList &itemLists, const QList &expectedItems) +{ + for (int i=0; i(current[j].value()); + QVERIFY2(o, QTest::toString(QString("Invalid actual item at %1").arg(j))); + QVERIFY2(expectedItems.contains(o), QTest::toString(QString("Cannot match item %1").arg(j))); + } + QCOMPARE(current.count(), expectedItems.count()); + } +} + +QTEST_MAIN(tst_QQuickGridView) + +#include "tst_qquickgridview.moc" + diff --git a/tests/auto/quick/qquickimage/data/aspectratio.qml b/tests/auto/quick/qquickimage/data/aspectratio.qml new file mode 100644 index 0000000000..b26f0e1f04 --- /dev/null +++ b/tests/auto/quick/qquickimage/data/aspectratio.qml @@ -0,0 +1,6 @@ +import QtQuick 2.0 + +Image { + source: "heart.png" + fillMode: Image.PreserveAspectFit; +} diff --git a/tests/auto/quick/qquickimage/data/big.jpeg b/tests/auto/quick/qquickimage/data/big.jpeg new file mode 100644 index 0000000000..bed7bd65c3 Binary files /dev/null and b/tests/auto/quick/qquickimage/data/big.jpeg differ diff --git a/tests/auto/quick/qquickimage/data/big256.png b/tests/auto/quick/qquickimage/data/big256.png new file mode 100644 index 0000000000..1dc1596d03 Binary files /dev/null and b/tests/auto/quick/qquickimage/data/big256.png differ diff --git a/tests/auto/quick/qquickimage/data/colors.png b/tests/auto/quick/qquickimage/data/colors.png new file mode 100644 index 0000000000..dfb62f3d64 Binary files /dev/null and b/tests/auto/quick/qquickimage/data/colors.png differ diff --git a/tests/auto/quick/qquickimage/data/colors1.png b/tests/auto/quick/qquickimage/data/colors1.png new file mode 100644 index 0000000000..dfb62f3d64 Binary files /dev/null and b/tests/auto/quick/qquickimage/data/colors1.png differ diff --git a/tests/auto/quick/qquickimage/data/green.png b/tests/auto/quick/qquickimage/data/green.png new file mode 100644 index 0000000000..0a2e153ba1 Binary files /dev/null and b/tests/auto/quick/qquickimage/data/green.png differ diff --git a/tests/auto/quick/qquickimage/data/heart-win32.png b/tests/auto/quick/qquickimage/data/heart-win32.png new file mode 100644 index 0000000000..351da13772 Binary files /dev/null and b/tests/auto/quick/qquickimage/data/heart-win32.png differ diff --git a/tests/auto/quick/qquickimage/data/heart.png b/tests/auto/quick/qquickimage/data/heart.png new file mode 100644 index 0000000000..abe97fee4b Binary files /dev/null and b/tests/auto/quick/qquickimage/data/heart.png differ diff --git a/tests/auto/quick/qquickimage/data/heart.svg b/tests/auto/quick/qquickimage/data/heart.svg new file mode 100644 index 0000000000..8c982cd93c --- /dev/null +++ b/tests/auto/quick/qquickimage/data/heart.svg @@ -0,0 +1,55 @@ + + + + + +Heart Left-Highlight +This is a normal valentines day heart. + + +holiday +valentines + +valentine +hash(0x8a091c0) +hash(0x8a0916c) +signs_and_symbols +hash(0x8a091f0) +day + + + + +Jon Phillips + + + + +Jon Phillips + + + + +Jon Phillips + + + +image/svg+xml + + +en + + + + + + + + + + + + + + + diff --git a/tests/auto/quick/qquickimage/data/heart200-win32.png b/tests/auto/quick/qquickimage/data/heart200-win32.png new file mode 100644 index 0000000000..4976ff98ba Binary files /dev/null and b/tests/auto/quick/qquickimage/data/heart200-win32.png differ diff --git a/tests/auto/quick/qquickimage/data/heart200.png b/tests/auto/quick/qquickimage/data/heart200.png new file mode 100644 index 0000000000..7fbb13c5bb Binary files /dev/null and b/tests/auto/quick/qquickimage/data/heart200.png differ diff --git a/tests/auto/quick/qquickimage/data/htiling.qml b/tests/auto/quick/qquickimage/data/htiling.qml new file mode 100644 index 0000000000..f192f931c9 --- /dev/null +++ b/tests/auto/quick/qquickimage/data/htiling.qml @@ -0,0 +1,11 @@ +import QtQuick 2.0 + +Rectangle { + width: 200; height: 550 + + Image { + objectName: "tiling"; anchors.fill: parent + source: "green.png"; fillMode: Image.TileHorizontally + } +} + diff --git a/tests/auto/quick/qquickimage/data/mirror.qml b/tests/auto/quick/qquickimage/data/mirror.qml new file mode 100644 index 0000000000..98fddf083e --- /dev/null +++ b/tests/auto/quick/qquickimage/data/mirror.qml @@ -0,0 +1,11 @@ +import QtQuick 2.0 + +Rectangle { + width: 300 + height: 250 + Image { + objectName: "image" + anchors.fill: parent + source: "pattern.png" + } +} diff --git a/tests/auto/quick/qquickimage/data/nullpixmap.qml b/tests/auto/quick/qquickimage/data/nullpixmap.qml new file mode 100644 index 0000000000..d52f41f164 --- /dev/null +++ b/tests/auto/quick/qquickimage/data/nullpixmap.qml @@ -0,0 +1,6 @@ +import QtQuick 2.0 + +Image { + width: 10; height:10; fillMode: Image.PreserveAspectFit + source: "" +} diff --git a/tests/auto/quick/qquickimage/data/pattern.png b/tests/auto/quick/qquickimage/data/pattern.png new file mode 100644 index 0000000000..d3d5e1e007 Binary files /dev/null and b/tests/auto/quick/qquickimage/data/pattern.png differ diff --git a/tests/auto/quick/qquickimage/data/qtbug_16389.qml b/tests/auto/quick/qquickimage/data/qtbug_16389.qml new file mode 100644 index 0000000000..7b8adecb11 --- /dev/null +++ b/tests/auto/quick/qquickimage/data/qtbug_16389.qml @@ -0,0 +1,30 @@ +import QtQuick 2.0 +Rectangle { + width: 400 + height: 400 + + Item { + anchors.top: parent.top + anchors.left: parent.left + anchors.bottom: blueHandle.top + anchors.right: blueHandle.left + + Image { + id: iconImage + objectName: "iconImage" + anchors.top: parent.top + anchors.bottom: parent.bottom + source: "heart200.png" + fillMode: Image.PreserveAspectFit + smooth: true + } + } + + Rectangle { + id: blueHandle + objectName: "blueHandle" + color: "blue" + width: 25 + height: 25 + } +} diff --git a/tests/auto/quick/qquickimage/data/qtbug_22125.qml b/tests/auto/quick/qquickimage/data/qtbug_22125.qml new file mode 100644 index 0000000000..9b68c0a125 --- /dev/null +++ b/tests/auto/quick/qquickimage/data/qtbug_22125.qml @@ -0,0 +1,44 @@ +import QtQuick 2.0 + +Item { + id: root + width: 800 + height: 800 + + GridView { + anchors.fill: parent + delegate: Image { + source: imagePath; + asynchronous: true + smooth: true + width: 200 + height: 200 + } + model: ListModel { + ListElement { + imagePath: "http://127.0.0.1:14451/big256.png" + } + ListElement { + imagePath: "http://127.0.0.1:14451/big256.png" + } + ListElement { + imagePath: "http://127.0.0.1:14451/big256.png" + } + ListElement { + imagePath: "http://127.0.0.1:14451/colors.png" + } + ListElement { + imagePath: "http://127.0.0.1:14451/colors1.png" + } + ListElement { + imagePath: "http://127.0.0.1:14451/big.jpeg" + } + ListElement { + imagePath: "http://127.0.0.1:14451/heart.png" + } + ListElement { + imagePath: "http://127.0.0.1:14451/green.png" + } + } + } +} diff --git a/tests/auto/quick/qquickimage/data/rect.png b/tests/auto/quick/qquickimage/data/rect.png new file mode 100644 index 0000000000..d564a2d5a5 Binary files /dev/null and b/tests/auto/quick/qquickimage/data/rect.png differ diff --git a/tests/auto/quick/qquickimage/data/sourceSize.qml b/tests/auto/quick/qquickimage/data/sourceSize.qml new file mode 100644 index 0000000000..8e25c254d3 --- /dev/null +++ b/tests/auto/quick/qquickimage/data/sourceSize.qml @@ -0,0 +1,7 @@ +import QtQuick 2.0 + +Image { + source: "heart.png" + sourceSize.width: srcWidth + sourceSize.height: srcHeight +} diff --git a/tests/auto/quick/qquickimage/data/vtiling.qml b/tests/auto/quick/qquickimage/data/vtiling.qml new file mode 100644 index 0000000000..f730f6e050 --- /dev/null +++ b/tests/auto/quick/qquickimage/data/vtiling.qml @@ -0,0 +1,11 @@ +import QtQuick 2.0 + +Rectangle { + width: 550; height: 200 + + Image { + objectName: "tiling"; anchors.fill: parent + source: "green.png"; fillMode: Image.TileVertically + } +} + diff --git a/tests/auto/quick/qquickimage/qquickimage.pro b/tests/auto/quick/qquickimage/qquickimage.pro new file mode 100644 index 0000000000..a68a7870d8 --- /dev/null +++ b/tests/auto/quick/qquickimage/qquickimage.pro @@ -0,0 +1,17 @@ +CONFIG += testcase +TARGET = tst_qquickimage +macx:CONFIG -= app_bundle + +HEADERS += ../../shared/testhttpserver.h +SOURCES += tst_qquickimage.cpp \ + ../../shared/testhttpserver.cpp + +include (../../shared/util.pri) +include (../shared/util.pri) + +testDataFiles.files = data +testDataFiles.path = . +DEPLOYMENT += testDataFiles + +CONFIG += parallel_test +QT += core-private gui-private qml-private quick-private network testlib diff --git a/tests/auto/quick/qquickimage/tst_qquickimage.cpp b/tests/auto/quick/qquickimage/tst_qquickimage.cpp new file mode 100644 index 0000000000..eda56fa789 --- /dev/null +++ b/tests/auto/quick/qquickimage/tst_qquickimage.cpp @@ -0,0 +1,749 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "../../shared/util.h" +#include "../../shared/testhttpserver.h" +#include "../shared/visualtestutil.h" + +#define SERVER_PORT 14451 +#define SERVER_ADDR "http://127.0.0.1:14451" + + +using namespace QQuickVisualTestUtil; + +Q_DECLARE_METATYPE(QQuickImageBase::Status) + +class tst_qquickimage : public QQmlDataTest +{ + Q_OBJECT +public: + tst_qquickimage(); + +private slots: + void noSource(); + void imageSource(); + void imageSource_data(); + void clearSource(); + void resized(); + void preserveAspectRatio(); + void smooth(); + void mirror(); + void svg(); + void geometry(); + void geometry_data(); + void big(); + void tiling_QTBUG_6716(); + void tiling_QTBUG_6716_data(); + void noLoading(); + void paintedWidthHeight(); + void sourceSize_QTBUG_14303(); + void sourceSize_QTBUG_16389(); + void nullPixmapPaint(); + void imageCrash_QTBUG_22125(); + void sourceSize_data(); + void sourceSize(); + +private: + QQmlEngine engine; +}; + +tst_qquickimage::tst_qquickimage() +{ +} + +void tst_qquickimage::noSource() +{ + QString componentStr = "import QtQuick 2.0\nImage { source: \"\" }"; + QQmlComponent component(&engine); + component.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); + QQuickImage *obj = qobject_cast(component.create()); + QVERIFY(obj != 0); + QCOMPARE(obj->source(), QUrl()); + QVERIFY(obj->status() == QQuickImage::Null); + QCOMPARE(obj->width(), 0.); + QCOMPARE(obj->height(), 0.); + QCOMPARE(obj->fillMode(), QQuickImage::Stretch); + QCOMPARE(obj->progress(), 0.0); + + delete obj; +} + +void tst_qquickimage::imageSource_data() +{ + QTest::addColumn("source"); + QTest::addColumn("width"); + QTest::addColumn("height"); + QTest::addColumn("remote"); + QTest::addColumn("async"); + QTest::addColumn("cache"); + QTest::addColumn("error"); + + QTest::newRow("local") << testFileUrl("colors.png").toString() << 120.0 << 120.0 << false << false << true << ""; + QTest::newRow("local no cache") << testFileUrl("colors.png").toString() << 120.0 << 120.0 << false << false << false << ""; + QTest::newRow("local async") << testFileUrl("colors1.png").toString() << 120.0 << 120.0 << false << true << true << ""; + QTest::newRow("local not found") << testFileUrl("no-such-file.png").toString() << 0.0 << 0.0 << false + << false << true << "file::2:1: QML Image: Cannot open: " + testFileUrl("no-such-file.png").toString(); + QTest::newRow("local async not found") << testFileUrl("no-such-file-1.png").toString() << 0.0 << 0.0 << false + << true << true << "file::2:1: QML Image: Cannot open: " + testFileUrl("no-such-file-1.png").toString(); + QTest::newRow("remote") << SERVER_ADDR "/colors.png" << 120.0 << 120.0 << true << false << true << ""; + QTest::newRow("remote redirected") << SERVER_ADDR "/oldcolors.png" << 120.0 << 120.0 << true << false << false << ""; + if (QImageReader::supportedImageFormats().contains("svg")) + QTest::newRow("remote svg") << SERVER_ADDR "/heart.svg" << 550.0 << 500.0 << true << false << false << ""; + + QTest::newRow("remote not found") << SERVER_ADDR "/no-such-file.png" << 0.0 << 0.0 << true + << false << true << "file::2:1: QML Image: Error downloading " SERVER_ADDR "/no-such-file.png - server replied: Not found"; + +} + +void tst_qquickimage::imageSource() +{ + QFETCH(QString, source); + QFETCH(double, width); + QFETCH(double, height); + QFETCH(bool, remote); + QFETCH(bool, async); + QFETCH(bool, cache); + QFETCH(QString, error); + + TestHTTPServer server(SERVER_PORT); + if (remote) { + QVERIFY(server.isValid()); + server.serveDirectory(dataDirectory()); + server.addRedirect("oldcolors.png", SERVER_ADDR "/colors.png"); + } + + if (!error.isEmpty()) + QTest::ignoreMessage(QtWarningMsg, error.toUtf8()); + + QString componentStr = "import QtQuick 2.0\nImage { source: \"" + source + "\"; asynchronous: " + + (async ? QLatin1String("true") : QLatin1String("false")) + "; cache: " + + (cache ? QLatin1String("true") : QLatin1String("false")) + " }"; + QQmlComponent component(&engine); + component.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); + QQuickImage *obj = qobject_cast(component.create()); + QVERIFY(obj != 0); + + if (async) + QVERIFY(obj->asynchronous() == true); + else + QVERIFY(obj->asynchronous() == false); + + if (cache) + QVERIFY(obj->cache() == true); + else + QVERIFY(obj->cache() == false); + + if (remote || async) + QTRY_VERIFY(obj->status() == QQuickImage::Loading); + + QCOMPARE(obj->source(), remote ? source : QUrl(source)); + + if (error.isEmpty()) { + QTRY_VERIFY(obj->status() == QQuickImage::Ready); + QCOMPARE(obj->width(), qreal(width)); + QCOMPARE(obj->height(), qreal(height)); + QCOMPARE(obj->fillMode(), QQuickImage::Stretch); + QCOMPARE(obj->progress(), 1.0); + } else { + QTRY_VERIFY(obj->status() == QQuickImage::Error); + } + + delete obj; +} + +void tst_qquickimage::clearSource() +{ + QString componentStr = "import QtQuick 2.0\nImage { source: srcImage }"; + QQmlContext *ctxt = engine.rootContext(); + ctxt->setContextProperty("srcImage", testFileUrl("colors.png")); + QQmlComponent component(&engine); + component.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); + QQuickImage *obj = qobject_cast(component.create()); + QVERIFY(obj != 0); + QVERIFY(obj->status() == QQuickImage::Ready); + QCOMPARE(obj->width(), 120.); + QCOMPARE(obj->height(), 120.); + QCOMPARE(obj->progress(), 1.0); + + ctxt->setContextProperty("srcImage", ""); + QVERIFY(obj->source().isEmpty()); + QVERIFY(obj->status() == QQuickImage::Null); + QCOMPARE(obj->width(), 0.); + QCOMPARE(obj->height(), 0.); + QCOMPARE(obj->progress(), 0.0); + + delete obj; +} + +void tst_qquickimage::resized() +{ + QString componentStr = "import QtQuick 2.0\nImage { source: \"" + testFile("colors.png") + "\"; width: 300; height: 300 }"; + QQmlComponent component(&engine); + component.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); + QQuickImage *obj = qobject_cast(component.create()); + QVERIFY(obj != 0); + QCOMPARE(obj->width(), 300.); + QCOMPARE(obj->height(), 300.); + QCOMPARE(obj->fillMode(), QQuickImage::Stretch); + delete obj; +} + + +void tst_qquickimage::preserveAspectRatio() +{ + QQuickView *canvas = new QQuickView(0); + canvas->show(); + + canvas->setSource(testFileUrl("aspectratio.qml")); + QQuickImage *image = qobject_cast(canvas->rootObject()); + QVERIFY(image != 0); + image->setWidth(80.0); + QCOMPARE(image->width(), 80.); + QCOMPARE(image->height(), 80.); + + canvas->setSource(testFileUrl("aspectratio.qml")); + image = qobject_cast(canvas->rootObject()); + image->setHeight(60.0); + QVERIFY(image != 0); + QCOMPARE(image->height(), 60.); + QCOMPARE(image->width(), 60.); + delete canvas; +} + +void tst_qquickimage::smooth() +{ + QString componentStr = "import QtQuick 2.0\nImage { source: \"" + testFile("colors.png") + "\"; smooth: true; width: 300; height: 300 }"; + QQmlComponent component(&engine); + component.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); + QQuickImage *obj = qobject_cast(component.create()); + QVERIFY(obj != 0); + QCOMPARE(obj->width(), 300.); + QCOMPARE(obj->height(), 300.); + QCOMPARE(obj->smooth(), true); + QCOMPARE(obj->fillMode(), QQuickImage::Stretch); + + delete obj; +} + +void tst_qquickimage::mirror() +{ + QSKIP("Test is broken on multiple levels, will need incremental fixes"); + + QMap screenshots; + QList fillModes; + fillModes << QQuickImage::Stretch << QQuickImage::PreserveAspectFit << QQuickImage::PreserveAspectCrop + << QQuickImage::Tile << QQuickImage::TileVertically << QQuickImage::TileHorizontally; + + qreal width = 300; + qreal height = 250; + + foreach (QQuickImage::FillMode fillMode, fillModes) { + QQuickView *canvas = new QQuickView; + canvas->setSource(testFileUrl("mirror.qml")); + + QQuickImage *obj = canvas->rootObject()->findChild("image"); + QVERIFY(obj != 0); + + obj->setFillMode(fillMode); + obj->setProperty("mirror", true); + canvas->show(); + + QImage screenshot = canvas->grabFrameBuffer(); + screenshots[fillMode] = screenshot; + delete canvas; + } + + foreach (QQuickImage::FillMode fillMode, fillModes) { + QPixmap srcPixmap; + QVERIFY(srcPixmap.load(testFile("pattern.png"))); + + QPixmap expected(width, height); + expected.fill(); + QPainter p_e(&expected); + QTransform transform; + transform.translate(width, 0).scale(-1, 1.0); + p_e.setTransform(transform); + + switch (fillMode) { + case QQuickImage::Stretch: + p_e.drawPixmap(QRect(0, 0, width, height), srcPixmap, QRect(0, 0, srcPixmap.width(), srcPixmap.height())); + break; + case QQuickImage::PreserveAspectFit: + p_e.drawPixmap(QRect(25, 0, height, height), srcPixmap, QRect(0, 0, srcPixmap.width(), srcPixmap.height())); + break; + case QQuickImage::PreserveAspectCrop: + { + qreal ratio = width/srcPixmap.width(); // width is the longer side + QRect rect(0, 0, srcPixmap.width()*ratio, srcPixmap.height()*ratio); + rect.moveCenter(QRect(0, 0, width, height).center()); + p_e.drawPixmap(rect, srcPixmap, QRect(0, 0, srcPixmap.width(), srcPixmap.height())); + break; + } + case QQuickImage::Tile: + p_e.drawTiledPixmap(QRect(0, 0, width, height), srcPixmap); + break; + case QQuickImage::TileVertically: + transform.scale(width / srcPixmap.width(), 1.0); + p_e.setTransform(transform); + p_e.drawTiledPixmap(QRect(0, 0, width, height), srcPixmap); + break; + case QQuickImage::TileHorizontally: + transform.scale(1.0, height / srcPixmap.height()); + p_e.setTransform(transform); + p_e.drawTiledPixmap(QRect(0, 0, width, height), srcPixmap); + break; + case QQuickImage::Pad: + break; + } + + QImage img = expected.toImage(); + QEXPECT_FAIL("", "QTBUG-21005 fails", Continue); + QCOMPARE(screenshots[fillMode], img); + } +} + +void tst_qquickimage::svg() +{ + if (!QImageReader::supportedImageFormats().contains("svg")) + QSKIP("svg support not available"); + + QString src = testFileUrl("heart.svg").toString(); + QString componentStr = "import QtQuick 2.0\nImage { source: \"" + src + "\"; sourceSize.width: 300; sourceSize.height: 300 }"; + QQmlComponent component(&engine); + component.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); + QQuickImage *obj = qobject_cast(component.create()); + QVERIFY(obj != 0); + QCOMPARE(obj->width(), 300.0); + QCOMPARE(obj->height(), 300.0); + obj->setSourceSize(QSize(200,200)); + + QCOMPARE(obj->width(), 200.0); + QCOMPARE(obj->height(), 200.0); + delete obj; +} + +void tst_qquickimage::geometry_data() +{ + QTest::addColumn("fillMode"); + QTest::addColumn("explicitWidth"); + QTest::addColumn("explicitHeight"); + QTest::addColumn("itemWidth"); + QTest::addColumn("paintedWidth"); + QTest::addColumn("boundingWidth"); + QTest::addColumn("itemHeight"); + QTest::addColumn("paintedHeight"); + QTest::addColumn("boundingHeight"); + + // tested image has width 200, height 100 + + // bounding rect and item rect are equal with fillMode PreserveAspectFit, painted rect may be smaller if the aspect ratio doesn't match + QTest::newRow("PreserveAspectFit") << "PreserveAspectFit" << false << false << 200.0 << 200.0 << 200.0 << 100.0 << 100.0 << 100.0; + QTest::newRow("PreserveAspectFit explicit width 300") << "PreserveAspectFit" << true << false << 300.0 << 200.0 << 300.0 << 100.0 << 100.0 << 100.0; + QTest::newRow("PreserveAspectFit explicit height 400") << "PreserveAspectFit" << false << true << 200.0 << 200.0 << 200.0 << 400.0 << 100.0 << 400.0; + QTest::newRow("PreserveAspectFit explicit width 300, height 400") << "PreserveAspectFit" << true << true << 300.0 << 300.0 << 300.0 << 400.0 << 150.0 << 400.0; + + // bounding rect and painted rect are equal with fillMode PreserveAspectCrop, item rect may be smaller if the aspect ratio doesn't match + QTest::newRow("PreserveAspectCrop") << "PreserveAspectCrop" << false << false << 200.0 << 200.0 << 200.0 << 100.0 << 100.0 << 100.0; + QTest::newRow("PreserveAspectCrop explicit width 300") << "PreserveAspectCrop" << true << false << 300.0 << 300.0 << 300.0 << 100.0 << 150.0 << 150.0; + QTest::newRow("PreserveAspectCrop explicit height 400") << "PreserveAspectCrop" << false << true << 200.0 << 800.0 << 800.0 << 400.0 << 400.0 << 400.0; + QTest::newRow("PreserveAspectCrop explicit width 300, height 400") << "PreserveAspectCrop" << true << true << 300.0 << 800.0 << 800.0 << 400.0 << 400.0 << 400.0; + + // bounding rect, painted rect and item rect are equal in stretching and tiling images + QStringList fillModes; + fillModes << "Stretch" << "Tile" << "TileVertically" << "TileHorizontally"; + foreach (QString fillMode, fillModes) { + QTest::newRow(fillMode.toLatin1()) << fillMode << false << false << 200.0 << 200.0 << 200.0 << 100.0 << 100.0 << 100.0; + QTest::newRow(QString(fillMode + " explicit width 300").toLatin1()) << fillMode << true << false << 300.0 << 300.0 << 300.0 << 100.0 << 100.0 << 100.0; + QTest::newRow(QString(fillMode + " explicit height 400").toLatin1()) << fillMode << false << true << 200.0 << 200.0 << 200.0 << 400.0 << 400.0 << 400.0; + QTest::newRow(QString(fillMode + " explicit width 300, height 400").toLatin1()) << fillMode << true << true << 300.0 << 300.0 << 300.0 << 400.0 << 400.0 << 400.0; + } +} + +void tst_qquickimage::geometry() +{ + QFETCH(QString, fillMode); + QFETCH(bool, explicitWidth); + QFETCH(bool, explicitHeight); + QFETCH(double, itemWidth); + QFETCH(double, itemHeight); + QFETCH(double, paintedWidth); + QFETCH(double, paintedHeight); + QFETCH(double, boundingWidth); + QFETCH(double, boundingHeight); + + QString src = testFileUrl("rect.png").toString(); + QString componentStr = "import QtQuick 2.0\nImage { source: \"" + src + "\"; fillMode: Image." + fillMode + "; "; + + if (explicitWidth) + componentStr.append("width: 300; "); + if (explicitHeight) + componentStr.append("height: 400; "); + componentStr.append("}"); + QQmlComponent component(&engine); + component.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); + QQuickImage *obj = qobject_cast(component.create()); + QVERIFY(obj != 0); + + QCOMPARE(obj->width(), itemWidth); + QCOMPARE(obj->paintedWidth(), paintedWidth); + QCOMPARE(obj->boundingRect().width(), boundingWidth); + + QCOMPARE(obj->height(), itemHeight); + QCOMPARE(obj->paintedHeight(), paintedHeight); + QCOMPARE(obj->boundingRect().height(), boundingHeight); + delete obj; +} + +void tst_qquickimage::big() +{ + // If the JPEG loader does not implement scaling efficiently, it would + // have to build a 400 MB image. That would be a bug in the JPEG loader. + + QString src = testFileUrl("big.jpeg").toString(); + QString componentStr = "import QtQuick 2.0\nImage { source: \"" + src + "\"; width: 100; sourceSize.height: 256 }"; + + QQmlComponent component(&engine); + component.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); + QQuickImage *obj = qobject_cast(component.create()); + QVERIFY(obj != 0); + QCOMPARE(obj->width(), 100.0); + QCOMPARE(obj->height(), 256.0); + + delete obj; +} + +// As tiling_QTBUG_6716 doesn't complete, it doesn't delete the +// canvas which causes leak warnings. Use this delete on stack +// destruction pattern to work around this. +template +struct AutoDelete { + AutoDelete(T *t) : t(t) {} + ~AutoDelete() { delete t; } +private: + T *t; +}; + +void tst_qquickimage::tiling_QTBUG_6716() +{ + QSKIP("Test is broken on multiple levels, will need incremental fixes"); + + QFETCH(QString, source); + + QQuickView *canvas = new QQuickView(0); + AutoDelete del(canvas); + + canvas->setSource(testFileUrl(source)); + canvas->show(); + qApp->processEvents(); + + QQuickImage *tiling = findItem(canvas->rootObject(), "tiling"); + + QVERIFY(tiling != 0); + QImage img = canvas->grabFrameBuffer(); + for (int x = 0; x < tiling->width(); ++x) { + for (int y = 0; y < tiling->height(); ++y) { + QVERIFY(img.pixel(x, y) == qRgb(0, 255, 0)); + } + } + + delete canvas; +} + +void tst_qquickimage::tiling_QTBUG_6716_data() +{ + QTest::addColumn("source"); + QTest::newRow("vertical_tiling") << "vtiling.qml"; + QTest::newRow("horizontal_tiling") << "htiling.qml"; +} + +void tst_qquickimage::noLoading() +{ + qRegisterMetaType(); + + TestHTTPServer server(SERVER_PORT); + QVERIFY(server.isValid()); + server.serveDirectory(dataDirectory()); + server.addRedirect("oldcolors.png", SERVER_ADDR "/colors.png"); + + QString componentStr = "import QtQuick 2.0\nImage { source: srcImage; cache: true }"; + QQmlContext *ctxt = engine.rootContext(); + ctxt->setContextProperty("srcImage", testFileUrl("heart.png")); + QQmlComponent component(&engine); + component.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); + QQuickImage *obj = qobject_cast(component.create()); + QVERIFY(obj != 0); + QVERIFY(obj->status() == QQuickImage::Ready); + + QSignalSpy sourceSpy(obj, SIGNAL(sourceChanged(const QUrl &))); + QSignalSpy progressSpy(obj, SIGNAL(progressChanged(qreal))); + QSignalSpy statusSpy(obj, SIGNAL(statusChanged(QQuickImageBase::Status))); + + // Loading local file + ctxt->setContextProperty("srcImage", testFileUrl("green.png")); + QTRY_VERIFY(obj->status() == QQuickImage::Ready); + QTRY_VERIFY(obj->progress() == 1.0); + QTRY_COMPARE(sourceSpy.count(), 1); + QTRY_COMPARE(progressSpy.count(), 0); + QTRY_COMPARE(statusSpy.count(), 0); + + // Loading remote file + ctxt->setContextProperty("srcImage", QString(SERVER_ADDR) + "/rect.png"); + QTRY_VERIFY(obj->status() == QQuickImage::Loading); + QTRY_VERIFY(obj->progress() == 0.0); + QTRY_VERIFY(obj->status() == QQuickImage::Ready); + QTRY_VERIFY(obj->progress() == 1.0); + QTRY_COMPARE(sourceSpy.count(), 2); + QTRY_COMPARE(progressSpy.count(), 2); + QTRY_COMPARE(statusSpy.count(), 2); + + // Loading remote file again - should not go through 'Loading' state. + ctxt->setContextProperty("srcImage", testFileUrl("green.png")); + ctxt->setContextProperty("srcImage", QString(SERVER_ADDR) + "/rect.png"); + QTRY_VERIFY(obj->status() == QQuickImage::Ready); + QTRY_VERIFY(obj->progress() == 1.0); + QTRY_COMPARE(sourceSpy.count(), 4); + QTRY_COMPARE(progressSpy.count(), 2); + QTRY_COMPARE(statusSpy.count(), 2); + + delete obj; +} + +void tst_qquickimage::paintedWidthHeight() +{ + { + QString src = testFileUrl("heart.png").toString(); + QString componentStr = "import QtQuick 2.0\nImage { source: \"" + src + "\"; width: 200; height: 25; fillMode: Image.PreserveAspectFit }"; + + QQmlComponent component(&engine); + component.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); + QQuickImage *obj = qobject_cast(component.create()); + QVERIFY(obj != 0); + QCOMPARE(obj->width(), 200.0); + QCOMPARE(obj->height(), 25.0); + QCOMPARE(obj->paintedWidth(), 25.0); + QCOMPARE(obj->paintedHeight(), 25.0); + + delete obj; + } + + { + QString src = testFileUrl("heart.png").toString(); + QString componentStr = "import QtQuick 2.0\nImage { source: \"" + src + "\"; width: 26; height: 175; fillMode: Image.PreserveAspectFit }"; + QQmlComponent component(&engine); + component.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); + QQuickImage *obj = qobject_cast(component.create()); + QVERIFY(obj != 0); + QCOMPARE(obj->width(), 26.0); + QCOMPARE(obj->height(), 175.0); + QCOMPARE(obj->paintedWidth(), 26.0); + QCOMPARE(obj->paintedHeight(), 26.0); + + delete obj; + } +} + +void tst_qquickimage::sourceSize_QTBUG_14303() +{ + QString componentStr = "import QtQuick 2.0\nImage { source: srcImage }"; + QQmlContext *ctxt = engine.rootContext(); + ctxt->setContextProperty("srcImage", testFileUrl("heart200.png")); + QQmlComponent component(&engine); + component.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); + QQuickImage *obj = qobject_cast(component.create()); + + QSignalSpy sourceSizeSpy(obj, SIGNAL(sourceSizeChanged())); + + QTRY_VERIFY(obj != 0); + QTRY_VERIFY(obj->status() == QQuickImage::Ready); + + QTRY_COMPARE(obj->sourceSize().width(), 200); + QTRY_COMPARE(obj->sourceSize().height(), 200); + QTRY_COMPARE(sourceSizeSpy.count(), 0); + + ctxt->setContextProperty("srcImage", testFileUrl("colors.png")); + QTRY_COMPARE(obj->sourceSize().width(), 120); + QTRY_COMPARE(obj->sourceSize().height(), 120); + QTRY_COMPARE(sourceSizeSpy.count(), 1); + + ctxt->setContextProperty("srcImage", testFileUrl("heart200.png")); + QTRY_COMPARE(obj->sourceSize().width(), 200); + QTRY_COMPARE(obj->sourceSize().height(), 200); + QTRY_COMPARE(sourceSizeSpy.count(), 2); + + delete obj; +} + +void tst_qquickimage::sourceSize_QTBUG_16389() +{ + QQuickView *canvas = new QQuickView(0); + canvas->setSource(testFileUrl("qtbug_16389.qml")); + canvas->show(); + qApp->processEvents(); + + QQuickImage *image = findItem(canvas->rootObject(), "iconImage"); + QQuickItem *handle = findItem(canvas->rootObject(), "blueHandle"); + + QCOMPARE(image->sourceSize().width(), 200); + QCOMPARE(image->sourceSize().height(), 200); + QCOMPARE(image->paintedWidth(), 0.0); + QCOMPARE(image->paintedHeight(), 0.0); + + handle->setY(20); + + QCOMPARE(image->sourceSize().width(), 200); + QCOMPARE(image->sourceSize().height(), 200); + QCOMPARE(image->paintedWidth(), 20.0); + QCOMPARE(image->paintedHeight(), 20.0); + + delete canvas; +} + +static int numberOfWarnings = 0; +static void checkWarnings(QtMsgType, const char *msg) +{ + if (!QString(msg).contains("QGLContext::makeCurrent(): Failed.")) + numberOfWarnings++; +} + +// QTBUG-15690 +void tst_qquickimage::nullPixmapPaint() +{ + QQuickView *canvas = new QQuickView(0); + canvas->setSource(testFileUrl("nullpixmap.qml")); + canvas->show(); + + QQuickImage *image = qobject_cast(canvas->rootObject()); + QTRY_VERIFY(image != 0); + image->setSource(SERVER_ADDR + QString("/no-such-file.png")); + + QtMsgHandler previousMsgHandler = qInstallMsgHandler(checkWarnings); + + // used to print "QTransform::translate with NaN called" + QPixmap pm = QPixmap::fromImage(canvas->grabFrameBuffer()); + qInstallMsgHandler(previousMsgHandler); + QVERIFY(numberOfWarnings == 0); + delete image; + + delete canvas; +} + +void tst_qquickimage::imageCrash_QTBUG_22125() +{ + TestHTTPServer server(SERVER_PORT); + QVERIFY(server.isValid()); + server.serveDirectory(dataDirectory(), TestHTTPServer::Delay); + + { + QQuickView view(testFileUrl("qtbug_22125.qml")); + view.show(); + qApp->processEvents(); + qApp->processEvents(); + // shouldn't crash when the view drops out of scope due to + // QQuickPixmapData attempting to dereference a pointer to + // the destroyed reader. + } + + // shouldn't crash when deleting cancelled QQmlPixmapReplys. + QTest::qWait(520); // Delay mode delays for 500 ms. + QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete); + QCoreApplication::processEvents(); +} + +void tst_qquickimage::sourceSize_data() +{ + QTest::addColumn("sourceWidth"); + QTest::addColumn("sourceHeight"); + QTest::addColumn("implicitWidth"); + QTest::addColumn("implicitHeight"); + + QTest::newRow("unscaled") << 0 << 0 << 300.0 << 300.0; + QTest::newRow("scale width") << 100 << 0 << 100.0 << 100.0; + QTest::newRow("scale height") << 0 << 150 << 150.0 << 150.0; + QTest::newRow("larger sourceSize") << 400 << 400 << 300.0 << 300.0; +} + +void tst_qquickimage::sourceSize() +{ + QFETCH(int, sourceWidth); + QFETCH(int, sourceHeight); + QFETCH(qreal, implicitWidth); + QFETCH(qreal, implicitHeight); + + QQuickView *canvas = new QQuickView(0); + QQmlContext *ctxt = canvas->rootContext(); + ctxt->setContextProperty("srcWidth", sourceWidth); + ctxt->setContextProperty("srcHeight", sourceHeight); + + canvas->setSource(testFileUrl("sourceSize.qml")); + canvas->show(); + qApp->processEvents(); + + QQuickImage *image = qobject_cast(canvas->rootObject()); + QVERIFY(image); + + QCOMPARE(image->sourceSize().width(), sourceWidth); + QCOMPARE(image->sourceSize().height(), sourceHeight); + QCOMPARE(image->implicitWidth(), implicitWidth); + QCOMPARE(image->implicitHeight(), implicitHeight); + + delete canvas; +} + +QTEST_MAIN(tst_qquickimage) + +#include "tst_qquickimage.moc" diff --git a/tests/auto/quick/qquickitem/data/order.1.qml b/tests/auto/quick/qquickitem/data/order.1.qml new file mode 100644 index 0000000000..963288b257 --- /dev/null +++ b/tests/auto/quick/qquickitem/data/order.1.qml @@ -0,0 +1,7 @@ +import QtQuick 2.0 + +Item { + Item { objectName: "1" } + Item { objectName: "2" } + Item { objectName: "3" } +} diff --git a/tests/auto/quick/qquickitem/data/order.2.qml b/tests/auto/quick/qquickitem/data/order.2.qml new file mode 100644 index 0000000000..5609c77e28 --- /dev/null +++ b/tests/auto/quick/qquickitem/data/order.2.qml @@ -0,0 +1,7 @@ +import QtQuick 2.0 + +Item { + Item { objectName: "1" } + Item { objectName: "2"; z: 1.0 } + Item { objectName: "3" } +} diff --git a/tests/auto/quick/qquickitem/data/polishOnCompleted.qml b/tests/auto/quick/qquickitem/data/polishOnCompleted.qml new file mode 100644 index 0000000000..7008cdc67e --- /dev/null +++ b/tests/auto/quick/qquickitem/data/polishOnCompleted.qml @@ -0,0 +1,11 @@ +import Qt.test 1.0 +import QtQuick 2.0 + +TestPolishItem { + width: 200 + height: 200 + + Component.onCompleted: { + doPolish() + } +} diff --git a/tests/auto/quick/qquickitem/qquickitem.pro b/tests/auto/quick/qquickitem/qquickitem.pro new file mode 100644 index 0000000000..cf24e63d05 --- /dev/null +++ b/tests/auto/quick/qquickitem/qquickitem.pro @@ -0,0 +1,14 @@ +CONFIG += testcase +TARGET = tst_qquickitem +SOURCES += tst_qquickitem.cpp + +include (../../shared/util.pri) + +macx:CONFIG -= app_bundle + +testDataFiles.files = data +testDataFiles.path = . +DEPLOYMENT += testDataFiles + +CONFIG += parallel_test +QT += core-private gui-private v8-private qml-private quick-private widgets testlib diff --git a/tests/auto/quick/qquickitem/tst_qquickitem.cpp b/tests/auto/quick/qquickitem/tst_qquickitem.cpp new file mode 100644 index 0000000000..7a589a48cd --- /dev/null +++ b/tests/auto/quick/qquickitem/tst_qquickitem.cpp @@ -0,0 +1,1468 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include + +#include +#include +#include +#include +#include "private/qquickfocusscope_p.h" +#include "private/qquickitem_p.h" +#include +#include +#include "../../shared/util.h" + +class TestItem : public QQuickItem +{ +Q_OBJECT +public: + TestItem(QQuickItem *parent = 0) + : QQuickItem(parent), focused(false), pressCount(0), releaseCount(0) + , wheelCount(0), acceptIncomingTouchEvents(true) + , touchEventReached(false) {} + + bool focused; + int pressCount; + int releaseCount; + int wheelCount; + bool acceptIncomingTouchEvents; + bool touchEventReached; +protected: + virtual void focusInEvent(QFocusEvent *) { Q_ASSERT(!focused); focused = true; } + virtual void focusOutEvent(QFocusEvent *) { Q_ASSERT(focused); focused = false; } + virtual void mousePressEvent(QMouseEvent *event) { event->accept(); ++pressCount; } + virtual void mouseReleaseEvent(QMouseEvent *event) { event->accept(); ++releaseCount; } + virtual void touchEvent(QTouchEvent *event) { + touchEventReached = true; + event->setAccepted(acceptIncomingTouchEvents); + } + virtual void wheelEvent(QWheelEvent *event) { event->accept(); ++wheelCount; } +}; + +class TestCanvas: public QQuickCanvas +{ +public: + TestCanvas() + : QQuickCanvas() + {} + + virtual bool event(QEvent *event) + { + return QQuickCanvas::event(event); + } +}; + +class TestPolishItem : public QQuickItem +{ +Q_OBJECT +public: + TestPolishItem(QQuickItem *parent = 0) + : QQuickItem(parent), wasPolished(false) { + + } + + bool wasPolished; + +protected: + virtual void updatePolish() { + wasPolished = true; + } + +public slots: + void doPolish() { + polish(); + } +}; + +class TestFocusScope : public QQuickFocusScope +{ +Q_OBJECT +public: + TestFocusScope(QQuickItem *parent = 0) : QQuickFocusScope(parent), focused(false) {} + + bool focused; +protected: + virtual void focusInEvent(QFocusEvent *) { Q_ASSERT(!focused); focused = true; } + virtual void focusOutEvent(QFocusEvent *) { Q_ASSERT(focused); focused = false; } +}; + +class tst_qquickitem : public QQmlDataTest +{ + Q_OBJECT +public: + +private slots: + void initTestCase(); + + void noCanvas(); + void simpleFocus(); + void scopedFocus(); + void addedToCanvas(); + void changeParent(); + + void constructor(); + void setParentItem(); + + void visible(); + void enabled(); + void enabledFocus(); + + void mouseGrab(); + void touchEventAcceptIgnore_data(); + void touchEventAcceptIgnore(); + void polishOutsideAnimation(); + void polishOnCompleted(); + + void wheelEvent_data(); + void wheelEvent(); + void hoverEvent_data(); + void hoverEvent(); + void hoverEventInParent(); + + void paintOrder_data(); + void paintOrder(); + +private: + + enum PaintOrderOp { + NoOp, Append, Remove, StackBefore, StackAfter, SetZ + }; + + void ensureFocus(QWindow *w) { + w->show(); + w->requestActivateWindow(); + qApp->processEvents(); + } +}; + +void tst_qquickitem::initTestCase() +{ + QQmlDataTest::initTestCase(); + qmlRegisterType("Qt.test", 1, 0, "TestPolishItem"); +} + +// Focus has no effect when outside a canvas +void tst_qquickitem::noCanvas() +{ + QQuickItem *root = new TestItem; + QQuickItem *child = new TestItem(root); + QQuickItem *scope = new TestItem(root); + QQuickFocusScope *scopedChild = new TestFocusScope(scope); + QQuickFocusScope *scopedChild2 = new TestFocusScope(scope); + + QCOMPARE(root->hasFocus(), false); + QCOMPARE(child->hasFocus(), false); + QCOMPARE(scope->hasFocus(), false); + QCOMPARE(scopedChild->hasFocus(), false); + QCOMPARE(scopedChild2->hasFocus(), false); + + root->setFocus(true); + scope->setFocus(true); + scopedChild2->setFocus(true); + QCOMPARE(root->hasFocus(), true); + QCOMPARE(child->hasFocus(), false); + QCOMPARE(scope->hasFocus(), true); + QCOMPARE(scopedChild->hasFocus(), false); + QCOMPARE(scopedChild2->hasFocus(), true); + + root->setFocus(false); + child->setFocus(true); + scopedChild->setFocus(true); + scope->setFocus(false); + QCOMPARE(root->hasFocus(), false); + QCOMPARE(child->hasFocus(), true); + QCOMPARE(scope->hasFocus(), false); + QCOMPARE(scopedChild->hasFocus(), true); + QCOMPARE(scopedChild2->hasFocus(), true); + + delete root; +} + +struct FocusData { + FocusData() : focus(false), activeFocus(false) {} + + void set(bool f, bool af) { focus = f; activeFocus = af; } + bool focus; + bool activeFocus; +}; +struct FocusState : public QHash +{ + FocusState() : activeFocusItem(0) {} + FocusState &operator<<(QQuickItem *item) { + insert(item, FocusData()); + return *this; + } + + void active(QQuickItem *i) { + activeFocusItem = i; + } + QQuickItem *activeFocusItem; +}; + +#define FVERIFY() \ + do { \ + if (focusState.activeFocusItem) { \ + QCOMPARE(canvas.activeFocusItem(), focusState.activeFocusItem); \ + if (qobject_cast(canvas.activeFocusItem())) \ + QCOMPARE(qobject_cast(canvas.activeFocusItem())->focused, true); \ + else if (qobject_cast(canvas.activeFocusItem())) \ + QCOMPARE(qobject_cast(canvas.activeFocusItem())->focused, true); \ + } else { \ + QCOMPARE(canvas.activeFocusItem(), canvas.rootItem()); \ + } \ + for (QHash::Iterator iter = focusState.begin(); \ + iter != focusState.end(); \ + iter++) { \ + QCOMPARE(iter.key()->hasFocus(), iter.value().focus); \ + QCOMPARE(iter.key()->hasActiveFocus(), iter.value().activeFocus); \ + } \ + } while (false) + +// Tests a simple set of top-level scoped items +void tst_qquickitem::simpleFocus() +{ + QQuickCanvas canvas; + ensureFocus(&canvas); + +#ifdef Q_OS_MAC + QSKIP("QTBUG-24094: fails on Mac OS X 10.7"); +#endif + + QTRY_VERIFY(QGuiApplication::focusWindow() == &canvas); + + QQuickItem *l1c1 = new TestItem(canvas.rootItem()); + QQuickItem *l1c2 = new TestItem(canvas.rootItem()); + QQuickItem *l1c3 = new TestItem(canvas.rootItem()); + + QQuickItem *l2c1 = new TestItem(l1c1); + QQuickItem *l2c2 = new TestItem(l1c1); + QQuickItem *l2c3 = new TestItem(l1c3); + + FocusState focusState; + focusState << l1c1 << l1c2 << l1c3 + << l2c1 << l2c2 << l2c3; + FVERIFY(); + + l1c1->setFocus(true); + focusState[l1c1].set(true, true); + focusState.active(l1c1); + FVERIFY(); + + l2c3->setFocus(true); + focusState[l1c1].set(false, false); + focusState[l2c3].set(true, true); + focusState.active(l2c3); + FVERIFY(); + + l1c3->setFocus(true); + focusState[l2c3].set(false, false); + focusState[l1c3].set(true, true); + focusState.active(l1c3); + FVERIFY(); + + l1c2->setFocus(false); + FVERIFY(); + + l1c3->setFocus(false); + focusState[l1c3].set(false, false); + focusState.active(0); + FVERIFY(); + + l2c1->setFocus(true); + focusState[l2c1].set(true, true); + focusState.active(l2c1); + FVERIFY(); +} + +// Items with a focus scope +void tst_qquickitem::scopedFocus() +{ + QQuickCanvas canvas; + ensureFocus(&canvas); + QTRY_VERIFY(QGuiApplication::focusWindow() == &canvas); + + QQuickItem *l1c1 = new TestItem(canvas.rootItem()); + QQuickItem *l1c2 = new TestItem(canvas.rootItem()); + QQuickItem *l1c3 = new TestItem(canvas.rootItem()); + + QQuickItem *l2c1 = new TestItem(l1c1); + QQuickItem *l2c2 = new TestItem(l1c1); + QQuickItem *l2c3 = new TestFocusScope(l1c3); + + QQuickItem *l3c1 = new TestItem(l2c3); + QQuickItem *l3c2 = new TestFocusScope(l2c3); + + QQuickItem *l4c1 = new TestItem(l3c2); + QQuickItem *l4c2 = new TestItem(l3c2); + + FocusState focusState; + focusState << l1c1 << l1c2 << l1c3 + << l2c1 << l2c2 << l2c3 + << l3c1 << l3c2 + << l4c1 << l4c2; + FVERIFY(); + + l4c2->setFocus(true); + focusState[l4c2].set(true, false); + FVERIFY(); + + l4c1->setFocus(true); + focusState[l4c2].set(false, false); + focusState[l4c1].set(true, false); + FVERIFY(); + + l1c1->setFocus(true); + focusState[l1c1].set(true, true); + focusState.active(l1c1); + FVERIFY(); + + l3c2->setFocus(true); + focusState[l3c2].set(true, false); + FVERIFY(); + + l2c3->setFocus(true); + focusState[l1c1].set(false, false); + focusState[l2c3].set(true, true); + focusState[l3c2].set(true, true); + focusState[l4c1].set(true, true); + focusState.active(l4c1); + FVERIFY(); + + l3c2->setFocus(false); + focusState[l3c2].set(false, false); + focusState[l4c1].set(true, false); + focusState.active(l2c3); + FVERIFY(); + + l3c2->setFocus(true); + focusState[l3c2].set(true, true); + focusState[l4c1].set(true, true); + focusState.active(l4c1); + FVERIFY(); + + l4c1->setFocus(false); + focusState[l4c1].set(false, false); + focusState.active(l3c2); + FVERIFY(); + + l1c3->setFocus(true); + focusState[l1c3].set(true, true); + focusState[l2c3].set(false, false); + focusState[l3c2].set(true, false); + focusState.active(l1c3); + FVERIFY(); +} + +// Tests focus corrects itself when a tree is added to a canvas for the first time +void tst_qquickitem::addedToCanvas() +{ + { + QQuickCanvas canvas; + ensureFocus(&canvas); + QTRY_VERIFY(QGuiApplication::focusWindow() == &canvas); + + QQuickItem *item = new TestItem; + + FocusState focusState; + focusState << item; + + item->setFocus(true); + focusState[item].set(true, false); + FVERIFY(); + + item->setParentItem(canvas.rootItem()); + focusState[item].set(true, true); + focusState.active(item); + FVERIFY(); + } + + { + QQuickCanvas canvas; + ensureFocus(&canvas); + QTRY_VERIFY(QGuiApplication::focusWindow() == &canvas); + + QQuickItem *item = new TestItem(canvas.rootItem()); + + QQuickItem *tree = new TestItem; + QQuickItem *c1 = new TestItem(tree); + QQuickItem *c2 = new TestItem(tree); + + FocusState focusState; + focusState << item << tree << c1 << c2; + + item->setFocus(true); + c1->setFocus(true); + c2->setFocus(true); + focusState[item].set(true, true); + focusState[c1].set(true, false); + focusState[c2].set(true, false); + focusState.active(item); + FVERIFY(); + + tree->setParentItem(item); + focusState[c1].set(false, false); + focusState[c2].set(false, false); + FVERIFY(); + } + + { + QQuickCanvas canvas; + ensureFocus(&canvas); + QTRY_VERIFY(QGuiApplication::focusWindow() == &canvas); + + QQuickItem *tree = new TestItem; + QQuickItem *c1 = new TestItem(tree); + QQuickItem *c2 = new TestItem(tree); + + FocusState focusState; + focusState << tree << c1 << c2; + c1->setFocus(true); + c2->setFocus(true); + focusState[c1].set(true, false); + focusState[c2].set(true, false); + FVERIFY(); + + tree->setParentItem(canvas.rootItem()); + focusState[c1].set(true, true); + focusState[c2].set(false, false); + focusState.active(c1); + FVERIFY(); + } + + { + QQuickCanvas canvas; + ensureFocus(&canvas); + QTRY_VERIFY(QGuiApplication::focusWindow() == &canvas); + QQuickItem *tree = new TestFocusScope; + QQuickItem *c1 = new TestItem(tree); + QQuickItem *c2 = new TestItem(tree); + + FocusState focusState; + focusState << tree << c1 << c2; + c1->setFocus(true); + c2->setFocus(true); + focusState[c1].set(true, false); + focusState[c2].set(true, false); + FVERIFY(); + + tree->setParentItem(canvas.rootItem()); + focusState[c1].set(true, false); + focusState[c2].set(false, false); + FVERIFY(); + + tree->setFocus(true); + focusState[tree].set(true, true); + focusState[c1].set(true, true); + focusState.active(c1); + FVERIFY(); + } + + { + QQuickCanvas canvas; + ensureFocus(&canvas); + QTRY_VERIFY(QGuiApplication::focusWindow() == &canvas); + QQuickItem *tree = new TestFocusScope; + QQuickItem *c1 = new TestItem(tree); + QQuickItem *c2 = new TestItem(tree); + + FocusState focusState; + focusState << tree << c1 << c2; + tree->setFocus(true); + c1->setFocus(true); + c2->setFocus(true); + focusState[tree].set(true, false); + focusState[c1].set(true, false); + focusState[c2].set(true, false); + FVERIFY(); + + tree->setParentItem(canvas.rootItem()); + focusState[tree].set(true, true); + focusState[c1].set(true, true); + focusState[c2].set(false, false); + focusState.active(c1); + FVERIFY(); + } + + { + QQuickCanvas canvas; + ensureFocus(&canvas); + QTRY_VERIFY(QGuiApplication::focusWindow() == &canvas); + QQuickItem *child = new TestItem(canvas.rootItem()); + QQuickItem *tree = new TestFocusScope; + QQuickItem *c1 = new TestItem(tree); + QQuickItem *c2 = new TestItem(tree); + + FocusState focusState; + focusState << child << tree << c1 << c2; + child->setFocus(true); + tree->setFocus(true); + c1->setFocus(true); + c2->setFocus(true); + focusState[child].set(true, true); + focusState[tree].set(true, false); + focusState[c1].set(true, false); + focusState[c2].set(true, false); + focusState.active(child); + FVERIFY(); + + tree->setParentItem(canvas.rootItem()); + focusState[tree].set(false, false); + focusState[c1].set(true, false); + focusState[c2].set(false, false); + FVERIFY(); + + tree->setFocus(true); + focusState[child].set(false, false); + focusState[tree].set(true, true); + focusState[c1].set(true, true); + focusState.active(c1); + FVERIFY(); + } +} + +void tst_qquickitem::changeParent() +{ + // Parent to no parent + { + QQuickCanvas canvas; + ensureFocus(&canvas); + QTRY_VERIFY(QGuiApplication::focusWindow() == &canvas); + QQuickItem *child = new TestItem(canvas.rootItem()); + + FocusState focusState; + focusState << child; + FVERIFY(); + + child->setFocus(true); + focusState[child].set(true, true); + focusState.active(child); + FVERIFY(); + + child->setParentItem(0); + focusState[child].set(true, false); + focusState.active(0); + FVERIFY(); + } + + // Different parent, same focus scope + { + QQuickCanvas canvas; + ensureFocus(&canvas); + QTRY_VERIFY(QGuiApplication::focusWindow() == &canvas); + QQuickItem *child = new TestItem(canvas.rootItem()); + QQuickItem *child2 = new TestItem(canvas.rootItem()); + + FocusState focusState; + focusState << child << child2; + FVERIFY(); + + child->setFocus(true); + focusState[child].set(true, true); + focusState.active(child); + FVERIFY(); + + child->setParentItem(child2); + FVERIFY(); + } + + // Different parent, different focus scope + { + QQuickCanvas canvas; + ensureFocus(&canvas); + QTRY_VERIFY(QGuiApplication::focusWindow() == &canvas); + QQuickItem *child = new TestItem(canvas.rootItem()); + QQuickItem *child2 = new TestFocusScope(canvas.rootItem()); + QQuickItem *item = new TestItem(child); + + FocusState focusState; + focusState << child << child2 << item; + FVERIFY(); + + item->setFocus(true); + focusState[item].set(true, true); + focusState.active(item); + FVERIFY(); + + item->setParentItem(child2); + focusState[item].set(true, false); + focusState.active(0); + FVERIFY(); + } + { + QQuickCanvas canvas; + ensureFocus(&canvas); + QTRY_VERIFY(QGuiApplication::focusWindow() == &canvas); + QQuickItem *child = new TestItem(canvas.rootItem()); + QQuickItem *child2 = new TestFocusScope(canvas.rootItem()); + QQuickItem *item = new TestItem(child2); + + FocusState focusState; + focusState << child << child2 << item; + FVERIFY(); + + item->setFocus(true); + focusState[item].set(true, false); + focusState.active(0); + FVERIFY(); + + item->setParentItem(child); + focusState[item].set(true, true); + focusState.active(item); + FVERIFY(); + } + { + QQuickCanvas canvas; + ensureFocus(&canvas); + QTRY_VERIFY(QGuiApplication::focusWindow() == &canvas); + QQuickItem *child = new TestItem(canvas.rootItem()); + QQuickItem *child2 = new TestFocusScope(canvas.rootItem()); + QQuickItem *item = new TestItem(child2); + + FocusState focusState; + focusState << child << child2 << item; + FVERIFY(); + + child->setFocus(true); + item->setFocus(true); + focusState[child].set(true, true); + focusState[item].set(true, false); + focusState.active(child); + FVERIFY(); + + item->setParentItem(child); + focusState[item].set(false, false); + FVERIFY(); + } + +} + +void tst_qquickitem::constructor() +{ + QQuickItem *root = new QQuickItem; + QVERIFY(root->parent() == 0); + QVERIFY(root->parentItem() == 0); + + QQuickItem *child1 = new QQuickItem(root); + QVERIFY(child1->parent() == root); + QVERIFY(child1->parentItem() == root); + QCOMPARE(root->childItems().count(), 1); + QCOMPARE(root->childItems().at(0), child1); + + QQuickItem *child2 = new QQuickItem(root); + QVERIFY(child2->parent() == root); + QVERIFY(child2->parentItem() == root); + QCOMPARE(root->childItems().count(), 2); + QCOMPARE(root->childItems().at(0), child1); + QCOMPARE(root->childItems().at(1), child2); + + delete root; +} + +void tst_qquickitem::setParentItem() +{ + QQuickItem *root = new QQuickItem; + QVERIFY(root->parent() == 0); + QVERIFY(root->parentItem() == 0); + + QQuickItem *child1 = new QQuickItem; + QVERIFY(child1->parent() == 0); + QVERIFY(child1->parentItem() == 0); + + child1->setParentItem(root); + QVERIFY(child1->parent() == 0); + QVERIFY(child1->parentItem() == root); + QCOMPARE(root->childItems().count(), 1); + QCOMPARE(root->childItems().at(0), child1); + + QQuickItem *child2 = new QQuickItem; + QVERIFY(child2->parent() == 0); + QVERIFY(child2->parentItem() == 0); + child2->setParentItem(root); + QVERIFY(child2->parent() == 0); + QVERIFY(child2->parentItem() == root); + QCOMPARE(root->childItems().count(), 2); + QCOMPARE(root->childItems().at(0), child1); + QCOMPARE(root->childItems().at(1), child2); + + child1->setParentItem(0); + QVERIFY(child1->parent() == 0); + QVERIFY(child1->parentItem() == 0); + QCOMPARE(root->childItems().count(), 1); + QCOMPARE(root->childItems().at(0), child2); + + delete root; + + QVERIFY(child1->parent() == 0); + QVERIFY(child1->parentItem() == 0); + QVERIFY(child2->parent() == 0); + QVERIFY(child2->parentItem() == 0); + + delete child1; + delete child2; +} + +void tst_qquickitem::visible() +{ + QQuickItem *root = new QQuickItem; + + QQuickItem *child1 = new QQuickItem; + child1->setParentItem(root); + + QQuickItem *child2 = new QQuickItem; + child2->setParentItem(root); + + QVERIFY(child1->isVisible()); + QVERIFY(child2->isVisible()); + + root->setVisible(false); + QVERIFY(!child1->isVisible()); + QVERIFY(!child2->isVisible()); + + root->setVisible(true); + QVERIFY(child1->isVisible()); + QVERIFY(child2->isVisible()); + + child1->setVisible(false); + QVERIFY(!child1->isVisible()); + QVERIFY(child2->isVisible()); + + child2->setParentItem(child1); + QVERIFY(!child1->isVisible()); + QVERIFY(!child2->isVisible()); + + child2->setParentItem(root); + QVERIFY(!child1->isVisible()); + QVERIFY(child2->isVisible()); + + delete root; + delete child1; + delete child2; +} + +void tst_qquickitem::enabled() +{ + QQuickItem *root = new QQuickItem; + + QQuickItem *child1 = new QQuickItem; + child1->setParentItem(root); + + QQuickItem *child2 = new QQuickItem; + child2->setParentItem(root); + + QVERIFY(child1->isEnabled()); + QVERIFY(child2->isEnabled()); + + root->setEnabled(false); + QVERIFY(!child1->isEnabled()); + QVERIFY(!child2->isEnabled()); + + root->setEnabled(true); + QVERIFY(child1->isEnabled()); + QVERIFY(child2->isEnabled()); + + child1->setEnabled(false); + QVERIFY(!child1->isEnabled()); + QVERIFY(child2->isEnabled()); + + child2->setParentItem(child1); + QVERIFY(!child1->isEnabled()); + QVERIFY(!child2->isEnabled()); + + child2->setParentItem(root); + QVERIFY(!child1->isEnabled()); + QVERIFY(child2->isEnabled()); + + delete root; + delete child1; + delete child2; +} + +void tst_qquickitem::enabledFocus() +{ + QQuickCanvas canvas; + ensureFocus(&canvas); + + QQuickFocusScope root; + + root.setFocus(true); + root.setEnabled(false); + + QCOMPARE(root.isEnabled(), false); + QCOMPARE(root.hasFocus(), true); + QCOMPARE(root.hasActiveFocus(), false); + + root.setParentItem(canvas.rootItem()); + + QCOMPARE(root.isEnabled(), false); + QCOMPARE(root.hasFocus(), true); + QCOMPARE(root.hasActiveFocus(), false); + QCOMPARE(canvas.activeFocusItem(), canvas.rootItem()); + + root.setEnabled(true); + QCOMPARE(root.isEnabled(), true); + QCOMPARE(root.hasFocus(), true); + QCOMPARE(root.hasActiveFocus(), true); + QCOMPARE(canvas.activeFocusItem(), static_cast(&root)); + + QQuickItem child1; + child1.setParentItem(&root); + + QCOMPARE(child1.isEnabled(), true); + QCOMPARE(child1.hasFocus(), false); + QCOMPARE(child1.hasActiveFocus(), false); + QCOMPARE(canvas.activeFocusItem(), static_cast(&root)); + + QQuickItem child2; + child2.setFocus(true); + child2.setParentItem(&root); + + QCOMPARE(root.isEnabled(), true); + QCOMPARE(root.hasFocus(), true); + QCOMPARE(root.hasActiveFocus(), true); + QCOMPARE(child2.isEnabled(), true); + QCOMPARE(child2.hasFocus(), true); + QCOMPARE(child2.hasActiveFocus(), true); + QCOMPARE(canvas.activeFocusItem(), &child2); + + child2.setEnabled(false); + + QCOMPARE(root.isEnabled(), true); + QCOMPARE(root.hasFocus(), true); + QCOMPARE(root.hasActiveFocus(), true); + QCOMPARE(child1.isEnabled(), true); + QCOMPARE(child1.hasFocus(), false); + QCOMPARE(child1.hasActiveFocus(), false); + QCOMPARE(child2.isEnabled(), false); + QCOMPARE(child2.hasFocus(), true); + QCOMPARE(child2.hasActiveFocus(), false); + QCOMPARE(canvas.activeFocusItem(), static_cast(&root)); + + child1.setEnabled(false); + QCOMPARE(child1.isEnabled(), false); + QCOMPARE(child1.hasFocus(), false); + QCOMPARE(child1.hasActiveFocus(), false); + + child1.setFocus(true); + QCOMPARE(child1.isEnabled(), false); + QCOMPARE(child1.hasFocus(), true); + QCOMPARE(child1.hasActiveFocus(), false); + QCOMPARE(child2.isEnabled(), false); + QCOMPARE(child2.hasFocus(), false); + QCOMPARE(child2.hasActiveFocus(), false); + QCOMPARE(canvas.activeFocusItem(), static_cast(&root)); + + child1.setEnabled(true); + QCOMPARE(child1.isEnabled(), true); + QCOMPARE(child1.hasFocus(), true); + QCOMPARE(child1.hasActiveFocus(), true); + QCOMPARE(canvas.activeFocusItem(), static_cast(&child1)); + + root.setFocus(false); + QCOMPARE(root.isEnabled(), true); + QCOMPARE(root.hasFocus(), false); + QCOMPARE(root.hasActiveFocus(), false); + QCOMPARE(child1.isEnabled(), true); + QCOMPARE(child1.hasFocus(), true); + QCOMPARE(child1.hasActiveFocus(), false); + QCOMPARE(canvas.activeFocusItem(), canvas.rootItem()); + + child2.forceActiveFocus(); + QCOMPARE(root.isEnabled(), true); + QCOMPARE(root.hasFocus(), true); + QCOMPARE(root.hasActiveFocus(), true); + QCOMPARE(child1.isEnabled(), true); + QCOMPARE(child1.hasFocus(), false); + QCOMPARE(child1.hasActiveFocus(), false); + QCOMPARE(child2.isEnabled(), false); + QCOMPARE(child2.hasFocus(), true); + QCOMPARE(child2.hasActiveFocus(), false); + QCOMPARE(canvas.activeFocusItem(), static_cast(&root)); + + root.setEnabled(false); + QCOMPARE(root.isEnabled(), false); + QCOMPARE(root.hasFocus(), true); + QCOMPARE(root.hasActiveFocus(), false); + QCOMPARE(child1.isEnabled(), false); + QCOMPARE(child1.hasFocus(), false); + QCOMPARE(child1.hasActiveFocus(), false); + QCOMPARE(child2.isEnabled(), false); + QCOMPARE(child2.hasFocus(), true); + QCOMPARE(child2.hasActiveFocus(), false); + QCOMPARE(canvas.activeFocusItem(), canvas.rootItem()); + + child1.forceActiveFocus(); + QCOMPARE(root.isEnabled(), false); + QCOMPARE(root.hasFocus(), true); + QCOMPARE(root.hasActiveFocus(), false); + QCOMPARE(child1.isEnabled(), false); + QCOMPARE(child1.hasFocus(), true); + QCOMPARE(child1.hasActiveFocus(), false); + QCOMPARE(child2.isEnabled(), false); + QCOMPARE(child2.hasFocus(), false); + QCOMPARE(child2.hasActiveFocus(), false); + QCOMPARE(canvas.activeFocusItem(), canvas.rootItem()); + + root.setEnabled(true); + QCOMPARE(root.isEnabled(), true); + QCOMPARE(root.hasFocus(), true); + QCOMPARE(root.hasActiveFocus(), true); + QCOMPARE(child1.isEnabled(), true); + QCOMPARE(child1.hasFocus(), true); + QCOMPARE(child1.hasActiveFocus(), true); + QCOMPARE(child2.isEnabled(), false); + QCOMPARE(child2.hasFocus(), false); + QCOMPARE(child2.hasActiveFocus(), false); + QCOMPARE(canvas.activeFocusItem(), static_cast(&child1)); +} + +void tst_qquickitem::mouseGrab() +{ + QQuickCanvas *canvas = new QQuickCanvas; + canvas->resize(200, 200); + canvas->show(); + + TestItem *child1 = new TestItem; + child1->setAcceptedMouseButtons(Qt::LeftButton); + child1->setSize(QSizeF(200, 100)); + child1->setParentItem(canvas->rootItem()); + + TestItem *child2 = new TestItem; + child2->setAcceptedMouseButtons(Qt::LeftButton); + child2->setY(51); + child2->setSize(QSizeF(200, 100)); + child2->setParentItem(canvas->rootItem()); + + QTest::mousePress(canvas, Qt::LeftButton, 0, QPoint(50,50)); + QTest::qWait(100); + QVERIFY(canvas->mouseGrabberItem() == child1); + QTest::qWait(100); + + QCOMPARE(child1->pressCount, 1); + QTest::mouseRelease(canvas, Qt::LeftButton, 0, QPoint(50,50)); + QTest::qWait(50); + QVERIFY(canvas->mouseGrabberItem() == 0); + QCOMPARE(child1->releaseCount, 1); + + QTest::mousePress(canvas, Qt::LeftButton, 0, QPoint(50,50)); + QTest::qWait(50); + QVERIFY(canvas->mouseGrabberItem() == child1); + QCOMPARE(child1->pressCount, 2); + child1->setEnabled(false); + QVERIFY(canvas->mouseGrabberItem() == 0); + QTest::mouseRelease(canvas, Qt::LeftButton, 0, QPoint(50,50)); + QTest::qWait(50); + QCOMPARE(child1->releaseCount, 1); + child1->setEnabled(true); + + QTest::mousePress(canvas, Qt::LeftButton, 0, QPoint(50,50)); + QTest::qWait(50); + QVERIFY(canvas->mouseGrabberItem() == child1); + QCOMPARE(child1->pressCount, 3); + child1->setVisible(false); + QVERIFY(canvas->mouseGrabberItem() == 0); + QTest::mouseRelease(canvas, Qt::LeftButton, 0, QPoint(50,50)); + QCOMPARE(child1->releaseCount, 1); + child1->setVisible(true); + + QTest::mousePress(canvas, Qt::LeftButton, 0, QPoint(50,50)); + QTest::qWait(50); + QVERIFY(canvas->mouseGrabberItem() == child1); + QCOMPARE(child1->pressCount, 4); + child2->grabMouse(); + QVERIFY(canvas->mouseGrabberItem() == child2); + QTest::mouseRelease(canvas, Qt::LeftButton, 0, QPoint(50,50)); + QTest::qWait(50); + QCOMPARE(child1->releaseCount, 1); + QCOMPARE(child2->releaseCount, 1); + + child2->grabMouse(); + QVERIFY(canvas->mouseGrabberItem() == child2); + QTest::mousePress(canvas, Qt::LeftButton, 0, QPoint(50,50)); + QTest::qWait(50); + QCOMPARE(child1->pressCount, 4); + QCOMPARE(child2->pressCount, 1); + QTest::mouseRelease(canvas, Qt::LeftButton, 0, QPoint(50,50)); + QTest::qWait(50); + QCOMPARE(child1->releaseCount, 1); + QCOMPARE(child2->releaseCount, 2); + + delete child1; + delete child2; + delete canvas; +} + +void tst_qquickitem::touchEventAcceptIgnore_data() +{ + QTest::addColumn("itemSupportsTouch"); + + QTest::newRow("with touch") << true; + QTest::newRow("without touch") << false; +} + +void tst_qquickitem::touchEventAcceptIgnore() +{ + QFETCH(bool, itemSupportsTouch); + + TestCanvas *canvas = new TestCanvas; + canvas->resize(100, 100); + canvas->show(); + + TestItem *item = new TestItem; + item->setSize(QSizeF(100, 100)); + item->setParentItem(canvas->rootItem()); + item->acceptIncomingTouchEvents = itemSupportsTouch; + + static QTouchDevice* device = 0; + if (!device) { + device =new QTouchDevice; + device->setType(QTouchDevice::TouchScreen); + QWindowSystemInterface::registerTouchDevice(device); + } + + // Send Begin, Update & End touch sequence + { + QTouchEvent::TouchPoint point; + point.setId(1); + point.setPos(QPointF(50, 50)); + point.setScreenPos(point.pos()); + point.setState(Qt::TouchPointPressed); + + QTouchEvent event(QEvent::TouchBegin, device, + Qt::NoModifier, + Qt::TouchPointPressed, + QList() << point); + event.setAccepted(true); + + item->touchEventReached = false; + + bool accepted = canvas->event(&event); + + QVERIFY(item->touchEventReached); + QCOMPARE(accepted && event.isAccepted(), itemSupportsTouch); + } + { + QTouchEvent::TouchPoint point; + point.setId(1); + point.setPos(QPointF(60, 60)); + point.setScreenPos(point.pos()); + point.setState(Qt::TouchPointMoved); + + QTouchEvent event(QEvent::TouchUpdate, device, + Qt::NoModifier, + Qt::TouchPointMoved, + QList() << point); + event.setAccepted(true); + + item->touchEventReached = false; + + bool accepted = canvas->event(&event); + + QCOMPARE(item->touchEventReached, itemSupportsTouch); + QCOMPARE(accepted && event.isAccepted(), itemSupportsTouch); + } + { + QTouchEvent::TouchPoint point; + point.setId(1); + point.setPos(QPointF(60, 60)); + point.setScreenPos(point.pos()); + point.setState(Qt::TouchPointReleased); + + QTouchEvent event(QEvent::TouchEnd, device, + Qt::NoModifier, + Qt::TouchPointReleased, + QList() << point); + event.setAccepted(true); + + item->touchEventReached = false; + + bool accepted = canvas->event(&event); + + QCOMPARE(item->touchEventReached, itemSupportsTouch); + QCOMPARE(accepted && event.isAccepted(), itemSupportsTouch); + } + + delete item; + delete canvas; +} + +void tst_qquickitem::polishOutsideAnimation() +{ + QQuickCanvas *canvas = new QQuickCanvas; + canvas->resize(200, 200); + canvas->show(); + + TestPolishItem *item = new TestPolishItem(canvas->rootItem()); + item->setSize(QSizeF(200, 100)); + QTest::qWait(50); + + QTimer::singleShot(10, item, SLOT(doPolish())); + QTRY_VERIFY(item->wasPolished); + + delete item; + delete canvas; +} + +void tst_qquickitem::polishOnCompleted() +{ + QQuickView *view = new QQuickView; + view->setSource(testFileUrl("polishOnCompleted.qml")); + view->show(); + + TestPolishItem *item = qobject_cast(view->rootObject()); + QVERIFY(item); + +#ifdef Q_OS_MAC + QSKIP("QTBUG-21590 view does not reliably receive polish without a running animation"); +#endif + + QTRY_VERIFY(item->wasPolished); + + delete view; +} + +void tst_qquickitem::wheelEvent_data() +{ + QTest::addColumn("visible"); + QTest::addColumn("enabled"); + + QTest::newRow("visible and enabled") << true << true; + QTest::newRow("visible and disabled") << true << false; + QTest::newRow("invisible and enabled") << false << true; + QTest::newRow("invisible and disabled") << false << false; +} + +void tst_qquickitem::wheelEvent() +{ + QFETCH(bool, visible); + QFETCH(bool, enabled); + + const bool shouldReceiveWheelEvents = visible && enabled; + + QQuickCanvas *canvas = new QQuickCanvas; + canvas->resize(200, 200); + canvas->show(); + + TestItem *item = new TestItem; + item->setSize(QSizeF(200, 100)); + item->setParentItem(canvas->rootItem()); + + item->setEnabled(enabled); + item->setVisible(visible); + + QWheelEvent event(QPoint(100, 50), -120, Qt::NoButton, Qt::NoModifier, Qt::Vertical); + event.setAccepted(false); + QGuiApplication::sendEvent(canvas, &event); + + if (shouldReceiveWheelEvents) { + QVERIFY(event.isAccepted()); + QCOMPARE(item->wheelCount, 1); + } else { + QVERIFY(!event.isAccepted()); + QCOMPARE(item->wheelCount, 0); + } + + delete canvas; +} + +class HoverItem : public QQuickItem +{ +Q_OBJECT +public: + HoverItem(QQuickItem *parent = 0) + : QQuickItem(parent), hoverEnterCount(0), hoverMoveCount(0), hoverLeaveCount(0) + { } + void resetCounters() { + hoverEnterCount = 0; + hoverMoveCount = 0; + hoverLeaveCount = 0; + } + int hoverEnterCount; + int hoverMoveCount; + int hoverLeaveCount; +protected: + virtual void hoverEnterEvent(QHoverEvent *event) { + event->accept(); + ++hoverEnterCount; + } + virtual void hoverMoveEvent(QHoverEvent *event) { + event->accept(); + ++hoverMoveCount; + } + virtual void hoverLeaveEvent(QHoverEvent *event) { + event->accept(); + ++hoverLeaveCount; + } +}; + +void tst_qquickitem::hoverEvent_data() +{ + QTest::addColumn("visible"); + QTest::addColumn("enabled"); + QTest::addColumn("acceptHoverEvents"); + + QTest::newRow("visible, enabled, accept hover") << true << true << true; + QTest::newRow("visible, disabled, accept hover") << true << false << true; + QTest::newRow("invisible, enabled, accept hover") << false << true << true; + QTest::newRow("invisible, disabled, accept hover") << false << false << true; + + QTest::newRow("visible, enabled, not accept hover") << true << true << false; + QTest::newRow("visible, disabled, not accept hover") << true << false << false; + QTest::newRow("invisible, enabled, not accept hover") << false << true << false; + QTest::newRow("invisible, disabled, not accept hover") << false << false << false; +} + +// ### For some unknown reason QTest::mouseMove() isn't working correctly. +static void sendMouseMove(QObject *object, const QPoint &position) +{ + QMouseEvent moveEvent(QEvent::MouseMove, position, Qt::NoButton, Qt::NoButton, 0); + QGuiApplication::sendEvent(object, &moveEvent); +} + +void tst_qquickitem::hoverEvent() +{ + QFETCH(bool, visible); + QFETCH(bool, enabled); + QFETCH(bool, acceptHoverEvents); + + QQuickCanvas *canvas = new QQuickCanvas(); + canvas->resize(200, 200); + canvas->show(); + + HoverItem *item = new HoverItem; + item->setSize(QSizeF(100, 100)); + item->setParentItem(canvas->rootItem()); + + item->setEnabled(enabled); + item->setVisible(visible); + item->setAcceptHoverEvents(acceptHoverEvents); + + const QPoint outside(150, 150); + const QPoint inside(50, 50); + const QPoint anotherInside(51, 51); + + sendMouseMove(canvas, outside); + item->resetCounters(); + + // Enter, then move twice inside, then leave. + sendMouseMove(canvas, inside); + sendMouseMove(canvas, anotherInside); + sendMouseMove(canvas, inside); + sendMouseMove(canvas, outside); + + const bool shouldReceiveHoverEvents = visible && enabled && acceptHoverEvents; + if (shouldReceiveHoverEvents) { + QCOMPARE(item->hoverEnterCount, 1); + QCOMPARE(item->hoverMoveCount, 2); + QCOMPARE(item->hoverLeaveCount, 1); + } else { + QCOMPARE(item->hoverEnterCount, 0); + QCOMPARE(item->hoverMoveCount, 0); + QCOMPARE(item->hoverLeaveCount, 0); + } + + delete canvas; +} + +void tst_qquickitem::hoverEventInParent() +{ + QQuickCanvas *canvas = new QQuickCanvas(); + canvas->resize(200, 200); + canvas->show(); + + HoverItem *parentItem = new HoverItem(canvas->rootItem()); + parentItem->setSize(QSizeF(200, 200)); + parentItem->setAcceptHoverEvents(true); + + HoverItem *leftItem = new HoverItem(parentItem); + leftItem->setSize(QSizeF(100, 200)); + leftItem->setAcceptHoverEvents(true); + + HoverItem *rightItem = new HoverItem(parentItem); + rightItem->setSize(QSizeF(100, 200)); + rightItem->setPos(QPointF(100, 0)); + rightItem->setAcceptHoverEvents(true); + + const QPoint insideLeft(50, 100); + const QPoint insideRight(150, 100); + + sendMouseMove(canvas, insideLeft); + parentItem->resetCounters(); + leftItem->resetCounters(); + rightItem->resetCounters(); + + sendMouseMove(canvas, insideRight); + QCOMPARE(parentItem->hoverEnterCount, 0); + QCOMPARE(parentItem->hoverLeaveCount, 0); + QCOMPARE(leftItem->hoverEnterCount, 0); + QCOMPARE(leftItem->hoverLeaveCount, 1); + QCOMPARE(rightItem->hoverEnterCount, 1); + QCOMPARE(rightItem->hoverLeaveCount, 0); + + sendMouseMove(canvas, insideLeft); + QCOMPARE(parentItem->hoverEnterCount, 0); + QCOMPARE(parentItem->hoverLeaveCount, 0); + QCOMPARE(leftItem->hoverEnterCount, 1); + QCOMPARE(leftItem->hoverLeaveCount, 1); + QCOMPARE(rightItem->hoverEnterCount, 1); + QCOMPARE(rightItem->hoverLeaveCount, 1); + + delete canvas; +} + +void tst_qquickitem::paintOrder_data() +{ + const QUrl order1Url = testFileUrl("order.1.qml"); + const QUrl order2Url = testFileUrl("order.2.qml"); + + QTest::addColumn("source"); + QTest::addColumn("op"); + QTest::addColumn("param1"); + QTest::addColumn("param2"); + QTest::addColumn("expected"); + + QTest::newRow("test 1 noop") << order1Url + << int(NoOp) << QVariant() << QVariant() + << (QStringList() << "1" << "2" << "3"); + QTest::newRow("test 1 add") << order1Url + << int(Append) << QVariant("new") << QVariant() + << (QStringList() << "1" << "2" << "3" << "new"); + QTest::newRow("test 1 remove") << order1Url + << int(Remove) << QVariant(1) << QVariant() + << (QStringList() << "1" << "3"); + QTest::newRow("test 1 stack before") << order1Url + << int(StackBefore) << QVariant(2) << QVariant(1) + << (QStringList() << "1" << "3" << "2"); + QTest::newRow("test 1 stack after") << order1Url + << int(StackAfter) << QVariant(0) << QVariant(1) + << (QStringList() << "2" << "1" << "3"); + QTest::newRow("test 1 set z") << order1Url + << int(SetZ) << QVariant(1) << QVariant(qreal(1.)) + << (QStringList() << "1" << "3" << "2"); + + QTest::newRow("test 2 noop") << order2Url + << int(NoOp) << QVariant() << QVariant() + << (QStringList() << "1" << "3" << "2"); + QTest::newRow("test 2 add") << order2Url + << int(Append) << QVariant("new") << QVariant() + << (QStringList() << "1" << "3" << "new" << "2"); + QTest::newRow("test 2 remove 1") << order2Url + << int(Remove) << QVariant(1) << QVariant() + << (QStringList() << "1" << "3"); + QTest::newRow("test 2 remove 2") << order2Url + << int(Remove) << QVariant(2) << QVariant() + << (QStringList() << "1" << "2"); + QTest::newRow("test 2 stack before 1") << order2Url + << int(StackBefore) << QVariant(1) << QVariant(0) + << (QStringList() << "1" << "3" << "2"); + QTest::newRow("test 2 stack before 2") << order2Url + << int(StackBefore) << QVariant(2) << QVariant(0) + << (QStringList() << "3" << "1" << "2"); + QTest::newRow("test 2 stack after 1") << order2Url + << int(StackAfter) << QVariant(0) << QVariant(1) + << (QStringList() << "1" << "3" << "2"); + QTest::newRow("test 2 stack after 2") << order2Url + << int(StackAfter) << QVariant(0) << QVariant(2) + << (QStringList() << "3" << "1" << "2"); + QTest::newRow("test 1 set z") << order1Url + << int(SetZ) << QVariant(2) << QVariant(qreal(2.)) + << (QStringList() << "1" << "2" << "3"); +} + +void tst_qquickitem::paintOrder() +{ + QFETCH(QUrl, source); + QFETCH(int, op); + QFETCH(QVariant, param1); + QFETCH(QVariant, param2); + QFETCH(QStringList, expected); + + QQuickView view; + view.setSource(source); + + QQuickItem *root = qobject_cast(view.rootObject()); + QVERIFY(root); + + switch (op) { + case Append: { + QQuickItem *item = new QQuickItem(root); + item->setObjectName(param1.toString()); + } + break; + case Remove: { + QQuickItem *item = root->childItems().at(param1.toInt()); + delete item; + } + break; + case StackBefore: { + QQuickItem *item1 = root->childItems().at(param1.toInt()); + QQuickItem *item2 = root->childItems().at(param2.toInt()); + item1->stackBefore(item2); + } + break; + case StackAfter: { + QQuickItem *item1 = root->childItems().at(param1.toInt()); + QQuickItem *item2 = root->childItems().at(param2.toInt()); + item1->stackAfter(item2); + } + break; + case SetZ: { + QQuickItem *item = root->childItems().at(param1.toInt()); + item->setZ(param2.toReal()); + } + break; + default: + break; + } + + QList list = QQuickItemPrivate::get(root)->paintOrderChildItems(); + + QStringList items; + for (int i = 0; i < list.count(); ++i) + items << list.at(i)->objectName(); + + QCOMPARE(items, expected); +} + + +QTEST_MAIN(tst_qquickitem) + +#include "tst_qquickitem.moc" diff --git a/tests/auto/quick/qquickitem2/data/childrenProperty.qml b/tests/auto/quick/qquickitem2/data/childrenProperty.qml new file mode 100644 index 0000000000..85ddbc1446 --- /dev/null +++ b/tests/auto/quick/qquickitem2/data/childrenProperty.qml @@ -0,0 +1,14 @@ +import QtQuick 2.0 + +Item { + id: root + + property bool test1: root.children.length == 3 + property bool test2: root.children[0] == item1 + property bool test3: root.children[1] == item2 + property bool test4: root.children[2] == item3 + property bool test5: root.children[3] == null + + children: [ Item { id: item1 }, Item { id: item2 }, Item { id: item3 } ] +} + diff --git a/tests/auto/quick/qquickitem2/data/childrenRect.qml b/tests/auto/quick/qquickitem2/data/childrenRect.qml new file mode 100644 index 0000000000..ebc57aefbe --- /dev/null +++ b/tests/auto/quick/qquickitem2/data/childrenRect.qml @@ -0,0 +1,27 @@ +import QtQuick 2.0 + +Rectangle { + width: 400 + height: 400 + + property int childCount: 0; + + Item { + objectName: "testItem" + width: childrenRect.width + height: childrenRect.height + + Repeater { + id: repeater + model: childCount + delegate: Rectangle { + x: index*10 + y: index*20 + width: 10 + height: 20 + + color: "red" + } + } + } +} diff --git a/tests/auto/quick/qquickitem2/data/childrenRectBug.qml b/tests/auto/quick/qquickitem2/data/childrenRectBug.qml new file mode 100644 index 0000000000..86a4f19c5c --- /dev/null +++ b/tests/auto/quick/qquickitem2/data/childrenRectBug.qml @@ -0,0 +1,23 @@ +import QtQuick 2.0 + +Rectangle { + width: 400 + height: 200 + + Item { + objectName: "theItem" + anchors.centerIn: parent + width: childrenRect.width + height: childrenRect.height + Rectangle { + id: text1 + anchors.verticalCenter: parent.verticalCenter + width: 100; height: 100; color: "green" + } + Rectangle { + anchors.left: text1.right + anchors.verticalCenter: parent.verticalCenter + width: 100; height: 100; color: "green" + } + } +} diff --git a/tests/auto/quick/qquickitem2/data/childrenRectBug2.qml b/tests/auto/quick/qquickitem2/data/childrenRectBug2.qml new file mode 100644 index 0000000000..6e80ed28af --- /dev/null +++ b/tests/auto/quick/qquickitem2/data/childrenRectBug2.qml @@ -0,0 +1,53 @@ +import QtQuick 2.0 + +Rectangle { + width:360; + height: 200 + + Item { + objectName: "theItem" + anchors.centerIn: parent + width: childrenRect.width + height: childrenRect.height + Rectangle { + id: header1 + anchors.horizontalCenter: parent.horizontalCenter + anchors.top: parent.top + width: 100; height: 50 + color: "green" + } + Rectangle { + id: text1 + anchors.top: header1.bottom + anchors.topMargin: 10 + anchors.horizontalCenter: parent.horizontalCenter + width: 100; height: 50 + color: "blue" + } + } + + states: [ + State { + name: "row" + AnchorChanges { + target: header1 + anchors.horizontalCenter: undefined + anchors.verticalCenter: parent.verticalCenter + anchors.left: parent.left + anchors.top: undefined + } + AnchorChanges { + target: text1 + anchors.horizontalCenter: undefined + anchors.verticalCenter: parent.verticalCenter + anchors.top: undefined + anchors.left: header1.right + } + PropertyChanges { + target: text1 + anchors.leftMargin: 10 + anchors.topMargin: 0 + } + } + ] +} diff --git a/tests/auto/quick/qquickitem2/data/childrenRectBug3.qml b/tests/auto/quick/qquickitem2/data/childrenRectBug3.qml new file mode 100644 index 0000000000..518e76509e --- /dev/null +++ b/tests/auto/quick/qquickitem2/data/childrenRectBug3.qml @@ -0,0 +1,15 @@ +import QtQuick 2.0 + +Rectangle { + width: 300 + height: 300 + + Rectangle { + height: childrenRect.height + + Repeater { + model: 1 + Rectangle { } + } + } +} diff --git a/tests/auto/quick/qquickitem2/data/implicitsize.qml b/tests/auto/quick/qquickitem2/data/implicitsize.qml new file mode 100644 index 0000000000..cc6aaf7d60 --- /dev/null +++ b/tests/auto/quick/qquickitem2/data/implicitsize.qml @@ -0,0 +1,19 @@ +import QtQuick 2.0 + +Item { + implicitWidth: 200 + implicitHeight: 100 + + width: 80 + height: 60 + + function resetSize() { + width = undefined + height = undefined + } + + function changeImplicit() { + implicitWidth = 150 + implicitHeight = 80 + } +} diff --git a/tests/auto/quick/qquickitem2/data/keynavigationtest.qml b/tests/auto/quick/qquickitem2/data/keynavigationtest.qml new file mode 100644 index 0000000000..aacb621fb0 --- /dev/null +++ b/tests/auto/quick/qquickitem2/data/keynavigationtest.qml @@ -0,0 +1,87 @@ +import QtQuick 2.0 + +Grid { + columns: 2 + width: 100; height: 100 + function verify() { + if (item1.KeyNavigation.right != item2) + return false; + if (item1.KeyNavigation.down != item3) + return false; + if (item1.KeyNavigation.tab != item2) + return false; + if (item1.KeyNavigation.backtab != item4) + return false; + + if (item2.KeyNavigation.left != item1) + return false; + if (item2.KeyNavigation.down != item4) + return false; + if (item2.KeyNavigation.tab != item3) + return false; + if (item2.KeyNavigation.backtab != item1) + return false; + + if (item3.KeyNavigation.right != item4) + return false; + if (item3.KeyNavigation.up != item1) + return false; + if (item3.KeyNavigation.tab != item4) + return false; + if (item3.KeyNavigation.backtab != item2) + return false; + + if (item4.KeyNavigation.left != item3) + return false; + if (item4.KeyNavigation.up != item2) + return false; + if (item4.KeyNavigation.tab != item1) + return false; + if (item4.KeyNavigation.backtab != item3) + return false; + + return true; + } + + Rectangle { + id: item1 + objectName: "item1" + focus: true + width: 50; height: 50 + color: focus ? "red" : "lightgray" + KeyNavigation.right: item2 + KeyNavigation.down: item3 + KeyNavigation.tab: item2 + KeyNavigation.backtab: item4 + } + Rectangle { + id: item2 + objectName: "item2" + width: 50; height: 50 + color: focus ? "red" : "lightgray" + KeyNavigation.left: item1 + KeyNavigation.down: item4 + KeyNavigation.tab: item3 + KeyNavigation.backtab: item1 + } + Rectangle { + id: item3 + objectName: "item3" + width: 50; height: 50 + color: focus ? "red" : "lightgray" + KeyNavigation.right: item4 + KeyNavigation.up: item1 + KeyNavigation.tab: item4 + KeyNavigation.backtab: item2 + } + Rectangle { + id: item4 + objectName: "item4" + width: 50; height: 50 + color: focus ? "red" : "lightgray" + KeyNavigation.left: item3 + KeyNavigation.up: item2 + KeyNavigation.tab: item1 + KeyNavigation.backtab: item3 + } +} diff --git a/tests/auto/quick/qquickitem2/data/keynavigationtest_implicit.qml b/tests/auto/quick/qquickitem2/data/keynavigationtest_implicit.qml new file mode 100644 index 0000000000..92d4ae23de --- /dev/null +++ b/tests/auto/quick/qquickitem2/data/keynavigationtest_implicit.qml @@ -0,0 +1,68 @@ +import QtQuick 2.0 + +Grid { + columns: 2 + width: 100; height: 100 + function verify() { + if (item1.KeyNavigation.tab != item2) + return false; + if (item1.KeyNavigation.backtab != item4) + return false; + + if (item2.KeyNavigation.left != item1) + return false; + if (item2.KeyNavigation.down != item4) + return false; + if (item2.KeyNavigation.tab != item3) + return false; + if (item2.KeyNavigation.backtab != item1) + return false; + + if (item3.KeyNavigation.right != item4) + return false; + if (item3.KeyNavigation.up != item1) + return false; + if (item3.KeyNavigation.tab != item4) + return false; + if (item3.KeyNavigation.backtab != item2) + return false; + + return true; + } + + Rectangle { + id: item1 + objectName: "item1" + focus: true + width: 50; height: 50 + color: focus ? "red" : "lightgray" + KeyNavigation.tab: item2 + KeyNavigation.backtab: item4 + } + Rectangle { + id: item2 + objectName: "item2" + width: 50; height: 50 + color: focus ? "red" : "lightgray" + KeyNavigation.left: item1 + KeyNavigation.down: item4 + KeyNavigation.tab: item3 + KeyNavigation.backtab: item1 + } + Rectangle { + id: item3 + objectName: "item3" + width: 50; height: 50 + color: focus ? "red" : "lightgray" + KeyNavigation.right: item4 + KeyNavigation.up: item1 + KeyNavigation.tab: item4 + KeyNavigation.backtab: item2 + } + Rectangle { + id: item4 + objectName: "item4" + width: 50; height: 50 + color: focus ? "red" : "lightgray" + } +} diff --git a/tests/auto/quick/qquickitem2/data/keysim.qml b/tests/auto/quick/qquickitem2/data/keysim.qml new file mode 100644 index 0000000000..7da8a47681 --- /dev/null +++ b/tests/auto/quick/qquickitem2/data/keysim.qml @@ -0,0 +1,11 @@ +import QtQuick 2.0 + +Item { + focus: true + + Keys.forwardTo: [ item2 ] + + TextInput { + id: item2 + } +} diff --git a/tests/auto/quick/qquickitem2/data/keyspriority.qml b/tests/auto/quick/qquickitem2/data/keyspriority.qml new file mode 100644 index 0000000000..ae51aae776 --- /dev/null +++ b/tests/auto/quick/qquickitem2/data/keyspriority.qml @@ -0,0 +1,11 @@ +import QtQuick 2.0 +import Test 1.0 + +KeyTestItem { + focus: true + Keys.onPressed: keysTestObject.keyPress(event.key, event.text, event.modifiers) + Keys.onReleased: { keysTestObject.keyRelease(event.key, event.text, event.modifiers); event.accepted = true; } + Keys.priority: keysTestObject.processLast ? Keys.AfterItem : Keys.BeforeItem + + property int priorityTest: Keys.priority +} diff --git a/tests/auto/quick/qquickitem2/data/keystest.qml b/tests/auto/quick/qquickitem2/data/keystest.qml new file mode 100644 index 0000000000..c70e0061f5 --- /dev/null +++ b/tests/auto/quick/qquickitem2/data/keystest.qml @@ -0,0 +1,24 @@ +import QtQuick 2.0 + +Item { + focus: true + + property bool isEnabled: Keys.enabled + + Keys.onPressed: keysTestObject.keyPress(event.key, event.text, event.modifiers) + Keys.onReleased: { keysTestObject.keyRelease(event.key, event.text, event.modifiers); event.accepted = true; } + Keys.onReturnPressed: keysTestObject.keyPress(event.key, "Return", event.modifiers) + Keys.onDigit0Pressed: keysTestObject.keyPress(event.key, event.text, event.modifiers) + Keys.onDigit9Pressed: { event.accepted = false; keysTestObject.keyPress(event.key, event.text, event.modifiers) } + Keys.onTabPressed: keysTestObject.keyPress(event.key, "Tab", event.modifiers) + Keys.onBacktabPressed: keysTestObject.keyPress(event.key, "Backtab", event.modifiers) + Keys.forwardTo: [ item2 ] + Keys.enabled: enableKeyHanding + + Item { + id: item2 + visible: forwardeeVisible + Keys.onPressed: keysTestObject.forwardedKey(event.key) + Keys.onReleased: keysTestObject.forwardedKey(event.key) + } +} diff --git a/tests/auto/quick/qquickitem2/data/layoutmirroring.qml b/tests/auto/quick/qquickitem2/data/layoutmirroring.qml new file mode 100644 index 0000000000..036819740c --- /dev/null +++ b/tests/auto/quick/qquickitem2/data/layoutmirroring.qml @@ -0,0 +1,54 @@ +import QtQuick 2.0 + +Item { + property bool childrenInherit: true + Item { + objectName: "mirrored1" + LayoutMirroring.enabled: true + LayoutMirroring.childrenInherit: parent.childrenInherit + Item { + Item { + objectName: "notMirrored1" + LayoutMirroring.enabled: false + Item { + objectName: "inheritedMirror1" + } + } + Item { + objectName: "inheritedMirror2" + } + } + } + Item { + objectName: "mirrored2" + LayoutMirroring.enabled: true + LayoutMirroring.childrenInherit: false + Item { + objectName: "notMirrored2" + } + } + Item { + LayoutMirroring.enabled: true + LayoutMirroring.childrenInherit: true + Loader { + id: loader + } + } + states: State { + name: "newContent" + PropertyChanges { + target: loader + sourceComponent: component + } + } + Component { + id: component + Item { + objectName: "notMirrored3" + LayoutMirroring.enabled: false + Item { + objectName: "inheritedMirror3" + } + } + } +} diff --git a/tests/auto/quick/qquickitem2/data/mapCoordinates.qml b/tests/auto/quick/qquickitem2/data/mapCoordinates.qml new file mode 100644 index 0000000000..7b979a54b3 --- /dev/null +++ b/tests/auto/quick/qquickitem2/data/mapCoordinates.qml @@ -0,0 +1,84 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Item { + id: root; objectName: "root" + width: 200; height: 200 + + Item { id: itemA; objectName: "itemA"; x: 50; y: 50 } + + Item { + x: 50; y: 50 + Item { id: itemB; objectName: "itemB"; x: 100; y: 100 } + } + + function mapAToB(x, y) { + var pos = itemA.mapToItem(itemB, x, y) + return Qt.point(pos.x, pos.y) + } + + function mapAFromB(x, y) { + var pos = itemA.mapFromItem(itemB, x, y) + return Qt.point(pos.x, pos.y) + } + + function mapAToNull(x, y) { + var pos = itemA.mapToItem(null, x, y) + return Qt.point(pos.x, pos.y) + } + + function mapAFromNull(x, y) { + var pos = itemA.mapFromItem(null, x, y) + return Qt.point(pos.x, pos.y) + } + + function checkMapAToInvalid(x, y) { + var pos = itemA.mapToItem(1122, x, y) + return pos == undefined; + } + + function checkMapAFromInvalid(x, y) { + var pos = itemA.mapFromItem(1122, x, y) + return pos == undefined; + } +} diff --git a/tests/auto/quick/qquickitem2/data/parentLoop.qml b/tests/auto/quick/qquickitem2/data/parentLoop.qml new file mode 100644 index 0000000000..7b6560fbf7 --- /dev/null +++ b/tests/auto/quick/qquickitem2/data/parentLoop.qml @@ -0,0 +1,14 @@ +import QtQuick 2.0 + +Item { + Item { + id: item1 + objectName: "item1" + + Item { + id: item2 + objectName: "item2" + } + } + Component.onCompleted: item1.parent = item2 +} diff --git a/tests/auto/quick/qquickitem2/data/propertychanges.qml b/tests/auto/quick/qquickitem2/data/propertychanges.qml new file mode 100644 index 0000000000..3fa5ea9c23 --- /dev/null +++ b/tests/auto/quick/qquickitem2/data/propertychanges.qml @@ -0,0 +1,10 @@ +import QtQuick 2.0 + +Item { + Item { + objectName: "item" + } + Item { + objectName: "parentItem" + } +} diff --git a/tests/auto/quick/qquickitem2/data/qtbug_16871.qml b/tests/auto/quick/qquickitem2/data/qtbug_16871.qml new file mode 100644 index 0000000000..f1e7377730 --- /dev/null +++ b/tests/auto/quick/qquickitem2/data/qtbug_16871.qml @@ -0,0 +1,5 @@ +import QtQuick 2.0 + +Item { + children: [ 10 ] +} diff --git a/tests/auto/quick/qquickitem2/data/resourcesProperty.qml b/tests/auto/quick/qquickitem2/data/resourcesProperty.qml new file mode 100644 index 0000000000..b8f18bb375 --- /dev/null +++ b/tests/auto/quick/qquickitem2/data/resourcesProperty.qml @@ -0,0 +1,21 @@ +import QtQuick 2.0 + +Item { + id: root + + property bool test1 + property bool test2 + property bool test3 + property bool test4 + property bool test5 + + Component.onCompleted: { + test1 = (root.resources.length >= 3) + test2 = root.resources[0] == item1 + test3 = root.resources[1] == item2 + test4 = root.resources[2] == item3 + test5 = root.resources[10] == null + } + + resources: [ Item { id: item1 }, Item { id: item2 }, Item { id: item3 } ] +} diff --git a/tests/auto/quick/qquickitem2/data/transformCrash.qml b/tests/auto/quick/qquickitem2/data/transformCrash.qml new file mode 100644 index 0000000000..284e85f0e0 --- /dev/null +++ b/tests/auto/quick/qquickitem2/data/transformCrash.qml @@ -0,0 +1,13 @@ +import QtQuick 2.0 + +Item { + id: wrapper + width: 200 + height: 200 + + QtObject { + id: object + } + + Component.onCompleted: wrapper.transform = object +} diff --git a/tests/auto/quick/qquickitem2/data/visiblechildren.qml b/tests/auto/quick/qquickitem2/data/visiblechildren.qml new file mode 100644 index 0000000000..e51eb3551b --- /dev/null +++ b/tests/auto/quick/qquickitem2/data/visiblechildren.qml @@ -0,0 +1,143 @@ +import QtQuick 2.0 + +Item { + id: root + width: 400 + height: 300 + + Row { + id: row + Item { id: item1 + Item { id: item1_1; visible: true } + Item { id: item1_2; visible: true } + } + Item { id: item2 } + Item { id: item3 + Item { id: item3_1; visible: false } + Item { id: item3_2; visible: false } + } + Item { id: item4; visible: false + Item { id: item4_1 // implicitly invisible + Item { id: item4_1_1 } // implicitly invisible + Item { id: item4_1_2 } // implicitly invisible + } + } + } + + property int row_changeEventCalls: 0 + property int item1_changeEventCalls: 0 + property int item2_changeEventCalls: 0 + property int item3_changeEventCalls: 0 + property int item4_1_changeEventCalls: 0 + property int item4_1_1_changeEventCalls: 0 + Connections { target: row; onVisibleChildrenChanged: row_changeEventCalls++ } + Connections { target: item1; onVisibleChildrenChanged: item1_changeEventCalls++ } + Connections { target: item2; onVisibleChildrenChanged: item2_changeEventCalls++ } + Connections { target: item3; onVisibleChildrenChanged: item3_changeEventCalls++ } + Connections { target: item4_1; onVisibleChildrenChanged: item4_1_changeEventCalls++ } + Connections { target: item4_1_1; onVisibleChildrenChanged: item4_1_1_changeEventCalls++ } + + // Make sure there are three visible children and no signals fired yet + property bool test1_1: row.visibleChildren.length == 3 + property bool test1_2: row.visibleChildren[0] == item1 && row.visibleChildren[1] == item2 && row.visibleChildren[2] == item3 + property bool test1_3: row_changeEventCalls == 0 + property bool test1_4: item1_changeEventCalls == 0 && item2_changeEventCalls == 0 && item3_changeEventCalls == 0 + + // Next test + function hideFirstAndLastRowChild() { + item1.visible = false; + item3.visible = false; + } + + // Make sure row is signaled twice and item1 only once, and item3 not at all, and that item2 is the visible child + property bool test2_1: row.visibleChildren.length == 1 + property bool test2_2: row.visibleChildren[0] == item2 + property bool test2_3: row_changeEventCalls == 2 + property bool test2_4: item1_changeEventCalls == 1 && item2_changeEventCalls == 0 && item3_changeEventCalls == 0 + + // Next test + function showLastRowChildsLastChild() { + item3_2.visible = true; + } + + // Make sure item3_changeEventCalls is not signaled + property bool test3_1: row.visibleChildren.length == 1 + property bool test3_2: row.visibleChildren[0] == item2 + property bool test3_3: row_changeEventCalls == 2 + property bool test3_4: item1_changeEventCalls == 1 && item2_changeEventCalls == 0 && item3_changeEventCalls == 0 + + // Next test + function showLastRowChild() { + item3.visible = true; + } + + // Make sure row and item3 are signaled + property bool test4_1: row.visibleChildren.length == 2 + property bool test4_2: row.visibleChildren[0] == item2 && row.visibleChildren[1] == item3 + property bool test4_3: row_changeEventCalls == 3 + property bool test4_4: item1_changeEventCalls == 1 && item2_changeEventCalls == 0 && item3_changeEventCalls == 1 + + // Next test + function tryWriteToReadonlyVisibleChildren() { + var foo = fooComponent.createObject(root); + if (Qt.isQtObject(foo) && foo.children.length == 3 && foo.visibleChildren.length == 3) { + test5_1 = true; + } + + foo.visibleChildren.length = 10; // make sure this has no effect + test5_1 = (foo.visibleChildren.length == 3); + delete foo; + } + + Component { + id: fooComponent + Item { + children: [ Item {},Item {},Item {} ] + visibleChildren: [ Item {} ] + } + } + + // Make sure visibleChildren.length is 3 and stays that way + property bool test5_1: false + + // Next test + function reparentVisibleItem3() { + item3.parent = hiddenItem; // item3 has one visible children + } + + Item { id: hiddenItem; visible: false } + + property bool test6_1: row.visibleChildren.length == 1 && row_changeEventCalls == 4 + property bool test6_2: item3_changeEventCalls == 2 + property bool test6_3: item3.visible == false + + // Next test + + property bool test6_4: item4_1.visible == false && item4_1_changeEventCalls == 0 + + function reparentImlicitlyInvisibleItem4_1() { + item4_1.parent = visibleItem; + } + + Item { id: visibleItem; visible: true } + property int visibleItem_changeEventCalls: 0 + Connections { target: visibleItem; onVisibleChildrenChanged: visibleItem_changeEventCalls++ } + + + // Make sure that an item with implictly invisible children will be signaled when reparented to a visible parent + property bool test7_1: row.visibleChildren.length == 1 && row_changeEventCalls == 4 + property bool test7_2: item4_1.visible == true + property bool test7_3: item4_1_changeEventCalls == 1 + property bool test7_4: visibleItem_changeEventCalls == 1 + + + + // FINALLY make sure nothing has changes while we weren't paying attention + + property bool test8_1: row.visibleChildren.length == 1 && row.visibleChildren[0] == item2 && row_changeEventCalls == 4 + property bool test8_2: item1_changeEventCalls == 1 && item1.visible == false + property bool test8_3: item2_changeEventCalls == 0 && item2.visible == true + property bool test8_4: item3_changeEventCalls == 2 && item3.visible == false + property bool test8_5: item4_1_1_changeEventCalls == 0 && item4_1_1.visible == true + +} diff --git a/tests/auto/quick/qquickitem2/qquickitem2.pro b/tests/auto/quick/qquickitem2/qquickitem2.pro new file mode 100644 index 0000000000..29897ba3c1 --- /dev/null +++ b/tests/auto/quick/qquickitem2/qquickitem2.pro @@ -0,0 +1,15 @@ +CONFIG += testcase +TARGET = tst_qquickitem2 +macx:CONFIG -= app_bundle + +SOURCES += tst_qquickitem.cpp + +include (../../shared/util.pri) + +testDataFiles.files = data +testDataFiles.path = . +DEPLOYMENT += testDataFiles + +CONFIG += parallel_test + +QT += core-private gui-private v8-private qml-private quick-private opengl-private testlib diff --git a/tests/auto/quick/qquickitem2/tst_qquickitem.cpp b/tests/auto/quick/qquickitem2/tst_qquickitem.cpp new file mode 100644 index 0000000000..c2390c4525 --- /dev/null +++ b/tests/auto/quick/qquickitem2/tst_qquickitem.cpp @@ -0,0 +1,1380 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "../../shared/util.h" +#include "../shared/visualtestutil.h" +#include "../../shared/platforminputcontext.h" + +using namespace QQuickVisualTestUtil; + +class tst_QQuickItem : public QQmlDataTest +{ + Q_OBJECT +public: + tst_QQuickItem(); + +private slots: + void initTestCase(); + void cleanup(); + + void keys(); + void keysProcessingOrder(); + void keysim(); + void keyNavigation(); + void keyNavigation_RightToLeft(); + void keyNavigation_skipNotVisible(); + void keyNavigation_implicitSetting(); + void layoutMirroring(); + void layoutMirroringIllegalParent(); + void smooth(); + void clip(); + void mapCoordinates(); + void mapCoordinates_data(); + void propertyChanges(); + void transforms(); + void transforms_data(); + void childrenRect(); + void childrenRectBug(); + void childrenRectBug2(); + void childrenRectBug3(); + + void childrenProperty(); + void resourcesProperty(); + + void transformCrash(); + void implicitSize(); + void qtbug_16871(); + void visibleChildren(); + void parentLoop(); +private: + QQmlEngine engine; +}; + +class KeysTestObject : public QObject +{ + Q_OBJECT + + Q_PROPERTY(bool processLast READ processLast NOTIFY processLastChanged) + +public: + KeysTestObject() : mKey(0), mModifiers(0), mForwardedKey(0), mLast(false) {} + + void reset() { + mKey = 0; + mText = QString(); + mModifiers = 0; + mForwardedKey = 0; + } + + bool processLast() const { return mLast; } + void setProcessLast(bool b) { + if (b != mLast) { + mLast = b; + emit processLastChanged(); + } + } + +public slots: + void keyPress(int key, QString text, int modifiers) { + mKey = key; + mText = text; + mModifiers = modifiers; + } + void keyRelease(int key, QString text, int modifiers) { + mKey = key; + mText = text; + mModifiers = modifiers; + } + void forwardedKey(int key) { + mForwardedKey = key; + } + +signals: + void processLastChanged(); + +public: + int mKey; + QString mText; + int mModifiers; + int mForwardedKey; + bool mLast; + +private: +}; + +class KeyTestItem : public QQuickItem +{ + Q_OBJECT +public: + KeyTestItem(QQuickItem *parent=0) : QQuickItem(parent), mKey(0) {} + +protected: + void keyPressEvent(QKeyEvent *e) { + mKey = e->key(); + + if (e->key() == Qt::Key_A) + e->accept(); + else + e->ignore(); + } + + void keyReleaseEvent(QKeyEvent *e) { + if (e->key() == Qt::Key_B) + e->accept(); + else + e->ignore(); + } + +public: + int mKey; +}; + +QML_DECLARE_TYPE(KeyTestItem); + + +tst_QQuickItem::tst_QQuickItem() +{ +} + +void tst_QQuickItem::initTestCase() +{ + QQmlDataTest::initTestCase(); + qmlRegisterType("Test",1,0,"KeyTestItem"); +} + +void tst_QQuickItem::cleanup() +{ + QInputMethodPrivate *inputMethodPrivate = QInputMethodPrivate::get(qApp->inputMethod()); + inputMethodPrivate->testContext = 0; +} + +void tst_QQuickItem::keys() +{ + QQuickView *canvas = new QQuickView(0); + canvas->setBaseSize(QSize(240,320)); + + KeysTestObject *testObject = new KeysTestObject; + canvas->rootContext()->setContextProperty("keysTestObject", testObject); + + canvas->rootContext()->setContextProperty("enableKeyHanding", QVariant(true)); + canvas->rootContext()->setContextProperty("forwardeeVisible", QVariant(true)); + + canvas->setSource(testFileUrl("keystest.qml")); + canvas->show(); + canvas->requestActivateWindow(); + QTest::qWaitForWindowShown(canvas); + QTRY_VERIFY(QGuiApplication::focusWindow() == canvas); + + QVERIFY(canvas->rootObject()); + QCOMPARE(canvas->rootObject()->property("isEnabled").toBool(), true); + + QKeyEvent key(QEvent::KeyPress, Qt::Key_A, Qt::NoModifier, "A", false, 1); + QGuiApplication::sendEvent(canvas, &key); + QCOMPARE(testObject->mKey, int(Qt::Key_A)); + QCOMPARE(testObject->mForwardedKey, int(Qt::Key_A)); + QCOMPARE(testObject->mText, QLatin1String("A")); + QVERIFY(testObject->mModifiers == Qt::NoModifier); + QVERIFY(!key.isAccepted()); + + testObject->reset(); + + key = QKeyEvent(QEvent::KeyRelease, Qt::Key_A, Qt::ShiftModifier, "A", false, 1); + QGuiApplication::sendEvent(canvas, &key); + QCOMPARE(testObject->mKey, int(Qt::Key_A)); + QCOMPARE(testObject->mForwardedKey, int(Qt::Key_A)); + QCOMPARE(testObject->mText, QLatin1String("A")); + QVERIFY(testObject->mModifiers == Qt::ShiftModifier); + QVERIFY(key.isAccepted()); + + testObject->reset(); + + key = QKeyEvent(QEvent::KeyPress, Qt::Key_Return, Qt::NoModifier, "", false, 1); + QGuiApplication::sendEvent(canvas, &key); + QCOMPARE(testObject->mKey, int(Qt::Key_Return)); + QCOMPARE(testObject->mForwardedKey, int(Qt::Key_Return)); + QCOMPARE(testObject->mText, QLatin1String("Return")); + QVERIFY(testObject->mModifiers == Qt::NoModifier); + QVERIFY(key.isAccepted()); + + testObject->reset(); + + key = QKeyEvent(QEvent::KeyPress, Qt::Key_0, Qt::NoModifier, "0", false, 1); + QGuiApplication::sendEvent(canvas, &key); + QCOMPARE(testObject->mKey, int(Qt::Key_0)); + QCOMPARE(testObject->mForwardedKey, int(Qt::Key_0)); + QCOMPARE(testObject->mText, QLatin1String("0")); + QVERIFY(testObject->mModifiers == Qt::NoModifier); + QVERIFY(key.isAccepted()); + + testObject->reset(); + + key = QKeyEvent(QEvent::KeyPress, Qt::Key_9, Qt::NoModifier, "9", false, 1); + QGuiApplication::sendEvent(canvas, &key); + QCOMPARE(testObject->mKey, int(Qt::Key_9)); + QCOMPARE(testObject->mForwardedKey, int(Qt::Key_9)); + QCOMPARE(testObject->mText, QLatin1String("9")); + QVERIFY(testObject->mModifiers == Qt::NoModifier); + QVERIFY(!key.isAccepted()); + + testObject->reset(); + + key = QKeyEvent(QEvent::KeyPress, Qt::Key_Tab, Qt::NoModifier, "", false, 1); + QGuiApplication::sendEvent(canvas, &key); + QCOMPARE(testObject->mKey, int(Qt::Key_Tab)); + QCOMPARE(testObject->mForwardedKey, int(Qt::Key_Tab)); + QCOMPARE(testObject->mText, QLatin1String("Tab")); + QVERIFY(testObject->mModifiers == Qt::NoModifier); + QVERIFY(key.isAccepted()); + + testObject->reset(); + + key = QKeyEvent(QEvent::KeyPress, Qt::Key_Backtab, Qt::NoModifier, "", false, 1); + QGuiApplication::sendEvent(canvas, &key); + QCOMPARE(testObject->mKey, int(Qt::Key_Backtab)); + QCOMPARE(testObject->mForwardedKey, int(Qt::Key_Backtab)); + QCOMPARE(testObject->mText, QLatin1String("Backtab")); + QVERIFY(testObject->mModifiers == Qt::NoModifier); + QVERIFY(key.isAccepted()); + + testObject->reset(); + + canvas->rootContext()->setContextProperty("forwardeeVisible", QVariant(false)); + key = QKeyEvent(QEvent::KeyPress, Qt::Key_A, Qt::NoModifier, "A", false, 1); + QGuiApplication::sendEvent(canvas, &key); + QCOMPARE(testObject->mKey, int(Qt::Key_A)); + QCOMPARE(testObject->mForwardedKey, 0); + QCOMPARE(testObject->mText, QLatin1String("A")); + QVERIFY(testObject->mModifiers == Qt::NoModifier); + QVERIFY(!key.isAccepted()); + + testObject->reset(); + + canvas->rootContext()->setContextProperty("enableKeyHanding", QVariant(false)); + QCOMPARE(canvas->rootObject()->property("isEnabled").toBool(), false); + + key = QKeyEvent(QEvent::KeyPress, Qt::Key_Return, Qt::NoModifier, "", false, 1); + QGuiApplication::sendEvent(canvas, &key); + QCOMPARE(testObject->mKey, 0); + QVERIFY(!key.isAccepted()); + + canvas->rootContext()->setContextProperty("enableKeyHanding", QVariant(true)); + QCOMPARE(canvas->rootObject()->property("isEnabled").toBool(), true); + + key = QKeyEvent(QEvent::KeyPress, Qt::Key_Return, Qt::NoModifier, "", false, 1); + QGuiApplication::sendEvent(canvas, &key); + QCOMPARE(testObject->mKey, int(Qt::Key_Return)); + QVERIFY(key.isAccepted()); + + delete canvas; + delete testObject; +} + +void tst_QQuickItem::keysProcessingOrder() +{ + QQuickView *canvas = new QQuickView(0); + canvas->setBaseSize(QSize(240,320)); + + KeysTestObject *testObject = new KeysTestObject; + canvas->rootContext()->setContextProperty("keysTestObject", testObject); + + canvas->setSource(testFileUrl("keyspriority.qml")); + canvas->show(); + canvas->requestActivateWindow(); + QTest::qWaitForWindowShown(canvas); + QTRY_VERIFY(QGuiApplication::focusWindow() == canvas); + + KeyTestItem *testItem = qobject_cast(canvas->rootObject()); + QVERIFY(testItem); + + QCOMPARE(testItem->property("priorityTest").toInt(), 0); + + QKeyEvent key(QEvent::KeyPress, Qt::Key_A, Qt::NoModifier, "A", false, 1); + QGuiApplication::sendEvent(canvas, &key); + QCOMPARE(testObject->mKey, int(Qt::Key_A)); + QCOMPARE(testObject->mText, QLatin1String("A")); + QVERIFY(testObject->mModifiers == Qt::NoModifier); + QVERIFY(key.isAccepted()); + + testObject->reset(); + + testObject->setProcessLast(true); + + QCOMPARE(testItem->property("priorityTest").toInt(), 1); + + key = QKeyEvent(QEvent::KeyPress, Qt::Key_A, Qt::NoModifier, "A", false, 1); + QGuiApplication::sendEvent(canvas, &key); + QCOMPARE(testObject->mKey, 0); + QVERIFY(key.isAccepted()); + + testObject->reset(); + + key = QKeyEvent(QEvent::KeyPress, Qt::Key_B, Qt::NoModifier, "B", false, 1); + QGuiApplication::sendEvent(canvas, &key); + QCOMPARE(testObject->mKey, int(Qt::Key_B)); + QCOMPARE(testObject->mText, QLatin1String("B")); + QVERIFY(testObject->mModifiers == Qt::NoModifier); + QVERIFY(!key.isAccepted()); + + testObject->reset(); + + key = QKeyEvent(QEvent::KeyRelease, Qt::Key_B, Qt::NoModifier, "B", false, 1); + QGuiApplication::sendEvent(canvas, &key); + QCOMPARE(testObject->mKey, 0); + QVERIFY(key.isAccepted()); + + delete canvas; + delete testObject; +} + +void tst_QQuickItem::keysim() +{ + PlatformInputContext platformInputContext; + QInputMethodPrivate *inputMethodPrivate = QInputMethodPrivate::get(qApp->inputMethod()); + inputMethodPrivate->testContext = &platformInputContext; + + QQuickView *canvas = new QQuickView(0); + canvas->setBaseSize(QSize(240,320)); + + canvas->setSource(testFileUrl("keysim.qml")); + canvas->show(); + canvas->requestActivateWindow(); + QTest::qWaitForWindowShown(canvas); + QTRY_VERIFY(QGuiApplication::focusWindow() == canvas); + + QVERIFY(canvas->rootObject()); + QVERIFY(canvas->rootObject()->hasFocus() && canvas->rootObject()->hasActiveFocus()); + + QQuickTextInput *input = canvas->rootObject()->findChild(); + QVERIFY(input); + + QInputMethodEvent ev("Hello world!", QList()); + QGuiApplication::sendEvent(qGuiApp->focusObject(), &ev); + + QEXPECT_FAIL("", "QTBUG-24280", Continue); + QCOMPARE(input->text(), QLatin1String("Hello world!")); + + delete canvas; +} + +QQuickItemPrivate *childPrivate(QQuickItem *rootItem, const char * itemString) +{ + QQuickItem *item = findItem(rootItem, QString(QLatin1String(itemString))); + QQuickItemPrivate* itemPrivate = QQuickItemPrivate::get(item); + return itemPrivate; +} + +QVariant childProperty(QQuickItem *rootItem, const char * itemString, const char * property) +{ + QQuickItem *item = findItem(rootItem, QString(QLatin1String(itemString))); + return item->property(property); +} + +bool anchorsMirrored(QQuickItem *rootItem, const char * itemString) +{ + QQuickItem *item = findItem(rootItem, QString(QLatin1String(itemString))); + QQuickItemPrivate* itemPrivate = QQuickItemPrivate::get(item); + return itemPrivate->anchors()->mirrored(); +} + +void tst_QQuickItem::layoutMirroring() +{ + QQuickView *canvas = new QQuickView(0); + canvas->setSource(testFileUrl("layoutmirroring.qml")); + canvas->show(); + + QQuickItem *rootItem = qobject_cast(canvas->rootObject()); + QVERIFY(rootItem); + QQuickItemPrivate *rootPrivate = QQuickItemPrivate::get(rootItem); + QVERIFY(rootPrivate); + + QCOMPARE(childPrivate(rootItem, "mirrored1")->effectiveLayoutMirror, true); + QCOMPARE(childPrivate(rootItem, "mirrored2")->effectiveLayoutMirror, true); + QCOMPARE(childPrivate(rootItem, "notMirrored1")->effectiveLayoutMirror, false); + QCOMPARE(childPrivate(rootItem, "notMirrored2")->effectiveLayoutMirror, false); + QCOMPARE(childPrivate(rootItem, "inheritedMirror1")->effectiveLayoutMirror, true); + QCOMPARE(childPrivate(rootItem, "inheritedMirror2")->effectiveLayoutMirror, true); + + QCOMPARE(anchorsMirrored(rootItem, "mirrored1"), true); + QCOMPARE(anchorsMirrored(rootItem, "mirrored2"), true); + QCOMPARE(anchorsMirrored(rootItem, "notMirrored1"), false); + QCOMPARE(anchorsMirrored(rootItem, "notMirrored2"), false); + QCOMPARE(anchorsMirrored(rootItem, "inheritedMirror1"), true); + QCOMPARE(anchorsMirrored(rootItem, "inheritedMirror2"), true); + + QCOMPARE(childPrivate(rootItem, "mirrored1")->inheritedLayoutMirror, true); + QCOMPARE(childPrivate(rootItem, "mirrored2")->inheritedLayoutMirror, false); + QCOMPARE(childPrivate(rootItem, "notMirrored1")->inheritedLayoutMirror, true); + QCOMPARE(childPrivate(rootItem, "notMirrored2")->inheritedLayoutMirror, false); + QCOMPARE(childPrivate(rootItem, "inheritedMirror1")->inheritedLayoutMirror, true); + QCOMPARE(childPrivate(rootItem, "inheritedMirror2")->inheritedLayoutMirror, true); + + QCOMPARE(childPrivate(rootItem, "mirrored1")->isMirrorImplicit, false); + QCOMPARE(childPrivate(rootItem, "mirrored2")->isMirrorImplicit, false); + QCOMPARE(childPrivate(rootItem, "notMirrored1")->isMirrorImplicit, false); + QCOMPARE(childPrivate(rootItem, "notMirrored2")->isMirrorImplicit, true); + QCOMPARE(childPrivate(rootItem, "inheritedMirror1")->isMirrorImplicit, true); + QCOMPARE(childPrivate(rootItem, "inheritedMirror2")->isMirrorImplicit, true); + + QCOMPARE(childPrivate(rootItem, "mirrored1")->inheritMirrorFromParent, true); + QCOMPARE(childPrivate(rootItem, "mirrored2")->inheritMirrorFromParent, false); + QCOMPARE(childPrivate(rootItem, "notMirrored1")->inheritMirrorFromParent, true); + QCOMPARE(childPrivate(rootItem, "notMirrored2")->inheritMirrorFromParent, false); + QCOMPARE(childPrivate(rootItem, "inheritedMirror1")->inheritMirrorFromParent, true); + QCOMPARE(childPrivate(rootItem, "inheritedMirror2")->inheritMirrorFromParent, true); + + QCOMPARE(childPrivate(rootItem, "mirrored1")->inheritMirrorFromItem, true); + QCOMPARE(childPrivate(rootItem, "mirrored2")->inheritMirrorFromItem, false); + QCOMPARE(childPrivate(rootItem, "notMirrored1")->inheritMirrorFromItem, false); + QCOMPARE(childPrivate(rootItem, "notMirrored2")->inheritMirrorFromItem, false); + QCOMPARE(childPrivate(rootItem, "inheritedMirror1")->inheritMirrorFromItem, false); + QCOMPARE(childPrivate(rootItem, "inheritedMirror2")->inheritMirrorFromItem, false); + + // load dynamic content using Loader that needs to inherit mirroring + rootItem->setProperty("state", "newContent"); + QCOMPARE(childPrivate(rootItem, "notMirrored3")->effectiveLayoutMirror, false); + QCOMPARE(childPrivate(rootItem, "inheritedMirror3")->effectiveLayoutMirror, true); + + QCOMPARE(childPrivate(rootItem, "notMirrored3")->inheritedLayoutMirror, true); + QCOMPARE(childPrivate(rootItem, "inheritedMirror3")->inheritedLayoutMirror, true); + + QCOMPARE(childPrivate(rootItem, "notMirrored3")->isMirrorImplicit, false); + QCOMPARE(childPrivate(rootItem, "inheritedMirror3")->isMirrorImplicit, true); + + QCOMPARE(childPrivate(rootItem, "notMirrored3")->inheritMirrorFromParent, true); + QCOMPARE(childPrivate(rootItem, "inheritedMirror3")->inheritMirrorFromParent, true); + + QCOMPARE(childPrivate(rootItem, "notMirrored3")->inheritMirrorFromItem, false); + QCOMPARE(childPrivate(rootItem, "notMirrored3")->inheritMirrorFromItem, false); + + // disable inheritance + rootItem->setProperty("childrenInherit", false); + + QCOMPARE(childPrivate(rootItem, "inheritedMirror1")->effectiveLayoutMirror, false); + QCOMPARE(childPrivate(rootItem, "inheritedMirror2")->effectiveLayoutMirror, false); + QCOMPARE(childPrivate(rootItem, "mirrored1")->effectiveLayoutMirror, true); + QCOMPARE(childPrivate(rootItem, "notMirrored1")->effectiveLayoutMirror, false); + + QCOMPARE(childPrivate(rootItem, "inheritedMirror1")->inheritedLayoutMirror, false); + QCOMPARE(childPrivate(rootItem, "inheritedMirror2")->inheritedLayoutMirror, false); + QCOMPARE(childPrivate(rootItem, "mirrored1")->inheritedLayoutMirror, false); + QCOMPARE(childPrivate(rootItem, "notMirrored1")->inheritedLayoutMirror, false); + + // re-enable inheritance + rootItem->setProperty("childrenInherit", true); + + QCOMPARE(childPrivate(rootItem, "inheritedMirror1")->effectiveLayoutMirror, true); + QCOMPARE(childPrivate(rootItem, "inheritedMirror2")->effectiveLayoutMirror, true); + QCOMPARE(childPrivate(rootItem, "mirrored1")->effectiveLayoutMirror, true); + QCOMPARE(childPrivate(rootItem, "notMirrored1")->effectiveLayoutMirror, false); + + QCOMPARE(childPrivate(rootItem, "inheritedMirror1")->inheritedLayoutMirror, true); + QCOMPARE(childPrivate(rootItem, "inheritedMirror2")->inheritedLayoutMirror, true); + QCOMPARE(childPrivate(rootItem, "mirrored1")->inheritedLayoutMirror, true); + QCOMPARE(childPrivate(rootItem, "notMirrored1")->inheritedLayoutMirror, true); + + // + // dynamic parenting + // + QQuickItem *parentItem1 = new QQuickItem(); + QQuickItemPrivate::get(parentItem1)->effectiveLayoutMirror = true; // LayoutMirroring.enabled: true + QQuickItemPrivate::get(parentItem1)->isMirrorImplicit = false; + QQuickItemPrivate::get(parentItem1)->inheritMirrorFromItem = true; // LayoutMirroring.childrenInherit: true + QQuickItemPrivate::get(parentItem1)->resolveLayoutMirror(); + + // inherit in constructor + QQuickItem *childItem1 = new QQuickItem(parentItem1); + QCOMPARE(QQuickItemPrivate::get(childItem1)->effectiveLayoutMirror, true); + QCOMPARE(QQuickItemPrivate::get(childItem1)->inheritMirrorFromParent, true); + + // inherit through a parent change + QQuickItem *childItem2 = new QQuickItem(); + QCOMPARE(QQuickItemPrivate::get(childItem2)->effectiveLayoutMirror, false); + QCOMPARE(QQuickItemPrivate::get(childItem2)->inheritMirrorFromParent, false); + childItem2->setParentItem(parentItem1); + QCOMPARE(QQuickItemPrivate::get(childItem2)->effectiveLayoutMirror, true); + QCOMPARE(QQuickItemPrivate::get(childItem2)->inheritMirrorFromParent, true); + + // stop inherting through a parent change + QQuickItem *parentItem2 = new QQuickItem(); + QQuickItemPrivate::get(parentItem2)->effectiveLayoutMirror = true; // LayoutMirroring.enabled: true + QQuickItemPrivate::get(parentItem2)->resolveLayoutMirror(); + childItem2->setParentItem(parentItem2); + QCOMPARE(QQuickItemPrivate::get(childItem2)->effectiveLayoutMirror, false); + QCOMPARE(QQuickItemPrivate::get(childItem2)->inheritMirrorFromParent, false); + + delete parentItem1; + delete parentItem2; +} + +void tst_QQuickItem::layoutMirroringIllegalParent() +{ + QQmlComponent component(&engine); + component.setData("import QtQuick 2.0; QtObject { LayoutMirroring.enabled: true; LayoutMirroring.childrenInherit: true }", QUrl::fromLocalFile("")); + QTest::ignoreMessage(QtWarningMsg, "file::1:21: QML QtObject: LayoutDirection attached property only works with Items"); + QObject *object = component.create(); + QVERIFY(object != 0); +} + +void tst_QQuickItem::keyNavigation() +{ + QQuickView *canvas = new QQuickView(0); + canvas->setBaseSize(QSize(240,320)); + + canvas->setSource(testFileUrl("keynavigationtest.qml")); + canvas->show(); + canvas->requestActivateWindow(); + QTest::qWaitForWindowShown(canvas); + QTRY_VERIFY(QGuiApplication::focusWindow() == canvas); + + QQuickItem *item = findItem(canvas->rootObject(), "item1"); + QVERIFY(item); + QVERIFY(item->hasActiveFocus()); + + QVariant result; + QVERIFY(QMetaObject::invokeMethod(canvas->rootObject(), "verify", + Q_RETURN_ARG(QVariant, result))); + QVERIFY(result.toBool()); + + // right + QKeyEvent key(QEvent::KeyPress, Qt::Key_Right, Qt::NoModifier, "", false, 1); + QGuiApplication::sendEvent(canvas, &key); + QVERIFY(key.isAccepted()); + + item = findItem(canvas->rootObject(), "item2"); + QVERIFY(item); + QVERIFY(item->hasActiveFocus()); + + // down + key = QKeyEvent(QEvent::KeyPress, Qt::Key_Down, Qt::NoModifier, "", false, 1); + QGuiApplication::sendEvent(canvas, &key); + QVERIFY(key.isAccepted()); + + item = findItem(canvas->rootObject(), "item4"); + QVERIFY(item); + QVERIFY(item->hasActiveFocus()); + + // left + key = QKeyEvent(QEvent::KeyPress, Qt::Key_Left, Qt::NoModifier, "", false, 1); + QGuiApplication::sendEvent(canvas, &key); + QVERIFY(key.isAccepted()); + + item = findItem(canvas->rootObject(), "item3"); + QVERIFY(item); + QVERIFY(item->hasActiveFocus()); + + // up + key = QKeyEvent(QEvent::KeyPress, Qt::Key_Up, Qt::NoModifier, "", false, 1); + QGuiApplication::sendEvent(canvas, &key); + QVERIFY(key.isAccepted()); + + item = findItem(canvas->rootObject(), "item1"); + QVERIFY(item); + QVERIFY(item->hasActiveFocus()); + + // tab + key = QKeyEvent(QEvent::KeyPress, Qt::Key_Tab, Qt::NoModifier, "", false, 1); + QGuiApplication::sendEvent(canvas, &key); + QVERIFY(key.isAccepted()); + + item = findItem(canvas->rootObject(), "item2"); + QVERIFY(item); + QVERIFY(item->hasActiveFocus()); + + // backtab + key = QKeyEvent(QEvent::KeyPress, Qt::Key_Backtab, Qt::NoModifier, "", false, 1); + QGuiApplication::sendEvent(canvas, &key); + QVERIFY(key.isAccepted()); + + item = findItem(canvas->rootObject(), "item1"); + QVERIFY(item); + QVERIFY(item->hasActiveFocus()); + + delete canvas; +} + +void tst_QQuickItem::keyNavigation_RightToLeft() +{ + QQuickView *canvas = new QQuickView(0); + canvas->setBaseSize(QSize(240,320)); + + canvas->setSource(testFileUrl("keynavigationtest.qml")); + canvas->show(); + canvas->requestActivateWindow(); + QTest::qWaitForWindowShown(canvas); + QTRY_VERIFY(QGuiApplication::focusWindow() == canvas); + + QQuickItem *rootItem = qobject_cast(canvas->rootObject()); + QVERIFY(rootItem); + QQuickItemPrivate* rootItemPrivate = QQuickItemPrivate::get(rootItem); + + rootItemPrivate->effectiveLayoutMirror = true; // LayoutMirroring.mirror: true + rootItemPrivate->isMirrorImplicit = false; + rootItemPrivate->inheritMirrorFromItem = true; // LayoutMirroring.inherit: true + rootItemPrivate->resolveLayoutMirror(); + + QEvent wa(QEvent::WindowActivate); + QGuiApplication::sendEvent(canvas, &wa); + QFocusEvent fe(QEvent::FocusIn); + QGuiApplication::sendEvent(canvas, &fe); + + QQuickItem *item = findItem(canvas->rootObject(), "item1"); + QVERIFY(item); + QVERIFY(item->hasActiveFocus()); + + QVariant result; + QVERIFY(QMetaObject::invokeMethod(canvas->rootObject(), "verify", + Q_RETURN_ARG(QVariant, result))); + QVERIFY(result.toBool()); + + // right + QKeyEvent key(QEvent::KeyPress, Qt::Key_Left, Qt::NoModifier, "", false, 1); + QGuiApplication::sendEvent(canvas, &key); + QVERIFY(key.isAccepted()); + + item = findItem(canvas->rootObject(), "item2"); + QVERIFY(item); + QVERIFY(item->hasActiveFocus()); + + // left + key = QKeyEvent(QEvent::KeyPress, Qt::Key_Right, Qt::NoModifier, "", false, 1); + QGuiApplication::sendEvent(canvas, &key); + QVERIFY(key.isAccepted()); + + item = findItem(canvas->rootObject(), "item1"); + QVERIFY(item); + QVERIFY(item->hasActiveFocus()); + + delete canvas; +} + +void tst_QQuickItem::keyNavigation_skipNotVisible() +{ + QQuickView *canvas = new QQuickView(0); + canvas->setBaseSize(QSize(240,320)); + + canvas->setSource(testFileUrl("keynavigationtest.qml")); + canvas->show(); + canvas->requestActivateWindow(); + QTest::qWaitForWindowShown(canvas); + QTRY_VERIFY(QGuiApplication::focusWindow() == canvas); + + QQuickItem *item = findItem(canvas->rootObject(), "item1"); + QVERIFY(item); + QVERIFY(item->hasActiveFocus()); + + // Set item 2 to not visible + item = findItem(canvas->rootObject(), "item2"); + QVERIFY(item); + item->setVisible(false); + QVERIFY(!item->isVisible()); + + // right + QKeyEvent key(QEvent::KeyPress, Qt::Key_Right, Qt::NoModifier, "", false, 1); + QGuiApplication::sendEvent(canvas, &key); + QVERIFY(key.isAccepted()); + + item = findItem(canvas->rootObject(), "item1"); + QVERIFY(item); + QVERIFY(item->hasActiveFocus()); + + // tab + key = QKeyEvent(QEvent::KeyPress, Qt::Key_Tab, Qt::NoModifier, "", false, 1); + QGuiApplication::sendEvent(canvas, &key); + QVERIFY(key.isAccepted()); + + item = findItem(canvas->rootObject(), "item3"); + QVERIFY(item); + QVERIFY(item->hasActiveFocus()); + + // backtab + key = QKeyEvent(QEvent::KeyPress, Qt::Key_Backtab, Qt::NoModifier, "", false, 1); + QGuiApplication::sendEvent(canvas, &key); + QVERIFY(key.isAccepted()); + + item = findItem(canvas->rootObject(), "item1"); + QVERIFY(item); + QVERIFY(item->hasActiveFocus()); + + //Set item 3 to not visible + item = findItem(canvas->rootObject(), "item3"); + QVERIFY(item); + item->setVisible(false); + QVERIFY(!item->isVisible()); + + // tab + key = QKeyEvent(QEvent::KeyPress, Qt::Key_Tab, Qt::NoModifier, "", false, 1); + QGuiApplication::sendEvent(canvas, &key); + QVERIFY(key.isAccepted()); + + item = findItem(canvas->rootObject(), "item4"); + QVERIFY(item); + QVERIFY(item->hasActiveFocus()); + + // backtab + key = QKeyEvent(QEvent::KeyPress, Qt::Key_Backtab, Qt::NoModifier, "", false, 1); + QGuiApplication::sendEvent(canvas, &key); + QVERIFY(key.isAccepted()); + + item = findItem(canvas->rootObject(), "item1"); + QVERIFY(item); + QVERIFY(item->hasActiveFocus()); + + delete canvas; +} + +void tst_QQuickItem::keyNavigation_implicitSetting() +{ + QQuickView *canvas = new QQuickView(0); + canvas->setBaseSize(QSize(240,320)); + + canvas->setSource(testFileUrl("keynavigationtest_implicit.qml")); + canvas->show(); + canvas->requestActivateWindow(); + QTest::qWaitForWindowShown(canvas); + QTRY_VERIFY(QGuiApplication::focusWindow() == canvas); + + QEvent wa(QEvent::WindowActivate); + QGuiApplication::sendEvent(canvas, &wa); + QFocusEvent fe(QEvent::FocusIn); + QGuiApplication::sendEvent(canvas, &fe); + + QQuickItem *item = findItem(canvas->rootObject(), "item1"); + QVERIFY(item); + QVERIFY(item->hasActiveFocus()); + + QVariant result; + QVERIFY(QMetaObject::invokeMethod(canvas->rootObject(), "verify", + Q_RETURN_ARG(QVariant, result))); + QVERIFY(result.toBool()); + + // right + QKeyEvent key(QEvent::KeyPress, Qt::Key_Right, Qt::NoModifier, "", false, 1); + QGuiApplication::sendEvent(canvas, &key); + QVERIFY(key.isAccepted()); + + item = findItem(canvas->rootObject(), "item2"); + QVERIFY(item); + QVERIFY(item->hasActiveFocus()); + + // back to item1 + key = QKeyEvent(QEvent::KeyPress, Qt::Key_Left, Qt::NoModifier, "", false, 1); + QGuiApplication::sendEvent(canvas, &key); + QVERIFY(key.isAccepted()); + + item = findItem(canvas->rootObject(), "item1"); + QVERIFY(item); + QVERIFY(item->hasActiveFocus()); + + // down + key = QKeyEvent(QEvent::KeyPress, Qt::Key_Down, Qt::NoModifier, "", false, 1); + QGuiApplication::sendEvent(canvas, &key); + QVERIFY(key.isAccepted()); + + item = findItem(canvas->rootObject(), "item3"); + QVERIFY(item); + QVERIFY(item->hasActiveFocus()); + + // move to item4 + key = QKeyEvent(QEvent::KeyPress, Qt::Key_Right, Qt::NoModifier, "", false, 1); + QGuiApplication::sendEvent(canvas, &key); + QVERIFY(key.isAccepted()); + + item = findItem(canvas->rootObject(), "item4"); + QVERIFY(item); + QVERIFY(item->hasActiveFocus()); + + // left + key = QKeyEvent(QEvent::KeyPress, Qt::Key_Left, Qt::NoModifier, "", false, 1); + QGuiApplication::sendEvent(canvas, &key); + QVERIFY(key.isAccepted()); + + item = findItem(canvas->rootObject(), "item3"); + QVERIFY(item); + QVERIFY(item->hasActiveFocus()); + + // back to item4 + key = QKeyEvent(QEvent::KeyPress, Qt::Key_Right, Qt::NoModifier, "", false, 1); + QGuiApplication::sendEvent(canvas, &key); + QVERIFY(key.isAccepted()); + + item = findItem(canvas->rootObject(), "item4"); + QVERIFY(item); + QVERIFY(item->hasActiveFocus()); + + // up + key = QKeyEvent(QEvent::KeyPress, Qt::Key_Up, Qt::NoModifier, "", false, 1); + QGuiApplication::sendEvent(canvas, &key); + QVERIFY(key.isAccepted()); + + item = findItem(canvas->rootObject(), "item2"); + QVERIFY(item); + QVERIFY(item->hasActiveFocus()); + + // back to item4 + key = QKeyEvent(QEvent::KeyPress, Qt::Key_Down, Qt::NoModifier, "", false, 1); + QGuiApplication::sendEvent(canvas, &key); + QVERIFY(key.isAccepted()); + + item = findItem(canvas->rootObject(), "item4"); + QVERIFY(item); + QVERIFY(item->hasActiveFocus()); + + // tab + key = QKeyEvent(QEvent::KeyPress, Qt::Key_Tab, Qt::NoModifier, "", false, 1); + QGuiApplication::sendEvent(canvas, &key); + QVERIFY(key.isAccepted()); + + item = findItem(canvas->rootObject(), "item1"); + QVERIFY(item); + QVERIFY(item->hasActiveFocus()); + + // back to item4 + key = QKeyEvent(QEvent::KeyPress, Qt::Key_Backtab, Qt::NoModifier, "", false, 1); + QGuiApplication::sendEvent(canvas, &key); + QVERIFY(key.isAccepted()); + + item = findItem(canvas->rootObject(), "item4"); + QVERIFY(item); + QVERIFY(item->hasActiveFocus()); + + // backtab + key = QKeyEvent(QEvent::KeyPress, Qt::Key_Backtab, Qt::NoModifier, "", false, 1); + QGuiApplication::sendEvent(canvas, &key); + QVERIFY(key.isAccepted()); + + item = findItem(canvas->rootObject(), "item3"); + QVERIFY(item); + QVERIFY(item->hasActiveFocus()); + + delete canvas; +} + +void tst_QQuickItem::smooth() +{ + QQmlComponent component(&engine); + component.setData("import QtQuick 2.0; Item { smooth: false; }", QUrl::fromLocalFile("")); + QQuickItem *item = qobject_cast(component.create()); + QSignalSpy spy(item, SIGNAL(smoothChanged(bool))); + + QVERIFY(item); + QVERIFY(!item->smooth()); + + item->setSmooth(true); + QVERIFY(item->smooth()); + QCOMPARE(spy.count(),1); + QList arguments = spy.first(); + QVERIFY(arguments.count() == 1); + QVERIFY(arguments.at(0).toBool() == true); + + item->setSmooth(true); + QCOMPARE(spy.count(),1); + + item->setSmooth(false); + QVERIFY(!item->smooth()); + QCOMPARE(spy.count(),2); + item->setSmooth(false); + QCOMPARE(spy.count(),2); + + delete item; +} + +void tst_QQuickItem::clip() +{ + QQmlComponent component(&engine); + component.setData("import QtQuick 2.0\nItem { clip: false\n }", QUrl::fromLocalFile("")); + QQuickItem *item = qobject_cast(component.create()); + QSignalSpy spy(item, SIGNAL(clipChanged(bool))); + + QVERIFY(item); + QVERIFY(!item->clip()); + + item->setClip(true); + QVERIFY(item->clip()); + + QList arguments = spy.first(); + QVERIFY(arguments.count() == 1); + QVERIFY(arguments.at(0).toBool() == true); + + QCOMPARE(spy.count(),1); + item->setClip(true); + QCOMPARE(spy.count(),1); + + item->setClip(false); + QVERIFY(!item->clip()); + QCOMPARE(spy.count(),2); + item->setClip(false); + QCOMPARE(spy.count(),2); + + delete item; +} + +void tst_QQuickItem::mapCoordinates() +{ + QFETCH(int, x); + QFETCH(int, y); + + QQuickView *canvas = new QQuickView(0); + canvas->setBaseSize(QSize(300, 300)); + canvas->setSource(testFileUrl("mapCoordinates.qml")); + canvas->show(); + qApp->processEvents(); + + QQuickItem *root = qobject_cast(canvas->rootObject()); + QVERIFY(root != 0); + QQuickItem *a = findItem(canvas->rootObject(), "itemA"); + QVERIFY(a != 0); + QQuickItem *b = findItem(canvas->rootObject(), "itemB"); + QVERIFY(b != 0); + + QVariant result; + + QVERIFY(QMetaObject::invokeMethod(root, "mapAToB", + Q_RETURN_ARG(QVariant, result), Q_ARG(QVariant, x), Q_ARG(QVariant, y))); + QCOMPARE(result.value(), qobject_cast(a)->mapToItem(b, QPointF(x, y))); + + QVERIFY(QMetaObject::invokeMethod(root, "mapAFromB", + Q_RETURN_ARG(QVariant, result), Q_ARG(QVariant, x), Q_ARG(QVariant, y))); + QCOMPARE(result.value(), qobject_cast(a)->mapFromItem(b, QPointF(x, y))); + + QVERIFY(QMetaObject::invokeMethod(root, "mapAToNull", + Q_RETURN_ARG(QVariant, result), Q_ARG(QVariant, x), Q_ARG(QVariant, y))); + QCOMPARE(result.value(), qobject_cast(a)->mapToScene(QPointF(x, y))); + + QVERIFY(QMetaObject::invokeMethod(root, "mapAFromNull", + Q_RETURN_ARG(QVariant, result), Q_ARG(QVariant, x), Q_ARG(QVariant, y))); + QCOMPARE(result.value(), qobject_cast(a)->mapFromScene(QPointF(x, y))); + + QString warning1 = testFileUrl("mapCoordinates.qml").toString() + ":48:5: QML Item: mapToItem() given argument \"1122\" which is neither null nor an Item"; + QString warning2 = testFileUrl("mapCoordinates.qml").toString() + ":48:5: QML Item: mapFromItem() given argument \"1122\" which is neither null nor an Item"; + + QTest::ignoreMessage(QtWarningMsg, qPrintable(warning1)); + QVERIFY(QMetaObject::invokeMethod(root, "checkMapAToInvalid", + Q_RETURN_ARG(QVariant, result), Q_ARG(QVariant, x), Q_ARG(QVariant, y))); + QVERIFY(result.toBool()); + + QTest::ignoreMessage(QtWarningMsg, qPrintable(warning2)); + QVERIFY(QMetaObject::invokeMethod(root, "checkMapAFromInvalid", + Q_RETURN_ARG(QVariant, result), Q_ARG(QVariant, x), Q_ARG(QVariant, y))); + QVERIFY(result.toBool()); + + delete canvas; +} + +void tst_QQuickItem::mapCoordinates_data() +{ + QTest::addColumn("x"); + QTest::addColumn("y"); + + for (int i=-20; i<=20; i+=10) + QTest::newRow(QTest::toString(i)) << i << i; +} + +void tst_QQuickItem::transforms_data() +{ + QTest::addColumn("qml"); + QTest::addColumn("transform"); + QTest::newRow("translate") << QByteArray("Translate { x: 10; y: 20 }") + << QTransform(1,0,0,0,1,0,10,20,1); + QTest::newRow("rotation") << QByteArray("Rotation { angle: 90 }") + << QTransform(0,1,0,-1,0,0,0,0,1); + QTest::newRow("scale") << QByteArray("Scale { xScale: 1.5; yScale: -2 }") + << QTransform(1.5,0,0,0,-2,0,0,0,1); + QTest::newRow("sequence") << QByteArray("[ Translate { x: 10; y: 20 }, Scale { xScale: 1.5; yScale: -2 } ]") + << QTransform(1,0,0,0,1,0,10,20,1) * QTransform(1.5,0,0,0,-2,0,0,0,1); +} + +void tst_QQuickItem::transforms() +{ + QFETCH(QByteArray, qml); + QFETCH(QTransform, transform); + QQmlComponent component(&engine); + component.setData("import QtQuick 2.0\nItem { transform: "+qml+"}", QUrl::fromLocalFile("")); + QQuickItem *item = qobject_cast(component.create()); + QVERIFY(item); + QCOMPARE(item->itemTransform(0,0), transform); +} + +void tst_QQuickItem::childrenProperty() +{ + QQmlComponent component(&engine, testFileUrl("childrenProperty.qml")); + + QObject *o = component.create(); + QVERIFY(o != 0); + + QCOMPARE(o->property("test1").toBool(), true); + QCOMPARE(o->property("test2").toBool(), true); + QCOMPARE(o->property("test3").toBool(), true); + QCOMPARE(o->property("test4").toBool(), true); + QCOMPARE(o->property("test5").toBool(), true); + delete o; +} + +void tst_QQuickItem::resourcesProperty() +{ + QQmlComponent component(&engine, testFileUrl("resourcesProperty.qml")); + + QObject *o = component.create(); + QVERIFY(o != 0); + + QCOMPARE(o->property("test1").toBool(), true); + QCOMPARE(o->property("test2").toBool(), true); + QCOMPARE(o->property("test3").toBool(), true); + QCOMPARE(o->property("test4").toBool(), true); + QCOMPARE(o->property("test5").toBool(), true); + delete o; +} + +void tst_QQuickItem::propertyChanges() +{ + QQuickView *canvas = new QQuickView(0); + canvas->setBaseSize(QSize(300, 300)); + canvas->setSource(testFileUrl("propertychanges.qml")); + canvas->show(); + canvas->requestActivateWindow(); + QTest::qWaitForWindowShown(canvas); + QTRY_VERIFY(QGuiApplication::focusWindow() == canvas); + + QQuickItem *item = findItem(canvas->rootObject(), "item"); + QQuickItem *parentItem = findItem(canvas->rootObject(), "parentItem"); + + QVERIFY(item); + QVERIFY(parentItem); + + QSignalSpy parentSpy(item, SIGNAL(parentChanged(QQuickItem *))); + QSignalSpy widthSpy(item, SIGNAL(widthChanged())); + QSignalSpy heightSpy(item, SIGNAL(heightChanged())); + QSignalSpy baselineOffsetSpy(item, SIGNAL(baselineOffsetChanged(qreal))); + QSignalSpy childrenRectSpy(parentItem, SIGNAL(childrenRectChanged(QRectF))); + QSignalSpy focusSpy(item, SIGNAL(focusChanged(bool))); + QSignalSpy wantsFocusSpy(parentItem, SIGNAL(activeFocusChanged(bool))); + QSignalSpy childrenChangedSpy(parentItem, SIGNAL(childrenChanged())); + QSignalSpy xSpy(item, SIGNAL(xChanged())); + QSignalSpy ySpy(item, SIGNAL(yChanged())); + + item->setParentItem(parentItem); + item->setWidth(100.0); + item->setHeight(200.0); + item->setFocus(true); + item->setBaselineOffset(10.0); + + QCOMPARE(item->parentItem(), parentItem); + QCOMPARE(parentSpy.count(),1); + QList parentArguments = parentSpy.first(); + QVERIFY(parentArguments.count() == 1); + QCOMPARE(item->parentItem(), qvariant_cast(parentArguments.at(0))); + QCOMPARE(childrenChangedSpy.count(),1); + + item->setParentItem(parentItem); + QCOMPARE(childrenChangedSpy.count(),1); + + QCOMPARE(item->width(), 100.0); + QCOMPARE(widthSpy.count(),1); + + QCOMPARE(item->height(), 200.0); + QCOMPARE(heightSpy.count(),1); + + QCOMPARE(item->baselineOffset(), 10.0); + QCOMPARE(baselineOffsetSpy.count(),1); + QList baselineOffsetArguments = baselineOffsetSpy.first(); + QVERIFY(baselineOffsetArguments.count() == 1); + QCOMPARE(item->baselineOffset(), baselineOffsetArguments.at(0).toReal()); + + QCOMPARE(parentItem->childrenRect(), QRectF(0.0,0.0,100.0,200.0)); + QCOMPARE(childrenRectSpy.count(),1); + QList childrenRectArguments = childrenRectSpy.at(0); + QVERIFY(childrenRectArguments.count() == 1); + QCOMPARE(parentItem->childrenRect(), childrenRectArguments.at(0).toRectF()); + + QCOMPARE(item->hasActiveFocus(), true); + QCOMPARE(focusSpy.count(),1); + QList focusArguments = focusSpy.first(); + QVERIFY(focusArguments.count() == 1); + QCOMPARE(focusArguments.at(0).toBool(), true); + + QCOMPARE(parentItem->hasActiveFocus(), false); + QCOMPARE(parentItem->hasFocus(), false); + QCOMPARE(wantsFocusSpy.count(),0); + + item->setX(10.0); + QCOMPARE(item->x(), 10.0); + QCOMPARE(xSpy.count(), 1); + + item->setY(10.0); + QCOMPARE(item->y(), 10.0); + QCOMPARE(ySpy.count(), 1); + + delete canvas; +} + +void tst_QQuickItem::childrenRect() +{ + QQuickView *canvas = new QQuickView(0); + canvas->setSource(testFileUrl("childrenRect.qml")); + canvas->setBaseSize(QSize(240,320)); + canvas->show(); + + QQuickItem *o = canvas->rootObject(); + QQuickItem *item = o->findChild("testItem"); + QCOMPARE(item->width(), qreal(0)); + QCOMPARE(item->height(), qreal(0)); + + o->setProperty("childCount", 1); + QCOMPARE(item->width(), qreal(10)); + QCOMPARE(item->height(), qreal(20)); + + o->setProperty("childCount", 5); + QCOMPARE(item->width(), qreal(50)); + QCOMPARE(item->height(), qreal(100)); + + o->setProperty("childCount", 0); + QCOMPARE(item->width(), qreal(0)); + QCOMPARE(item->height(), qreal(0)); + + delete o; + delete canvas; +} + +// QTBUG-11383 +void tst_QQuickItem::childrenRectBug() +{ + QQuickView *canvas = new QQuickView(0); + + QString warning = testFileUrl("childrenRectBug.qml").toString() + ":7:5: QML Item: Binding loop detected for property \"height\""; + QTest::ignoreMessage(QtWarningMsg, qPrintable(warning)); + QTest::ignoreMessage(QtWarningMsg, qPrintable(warning)); + + canvas->setSource(testFileUrl("childrenRectBug.qml")); + canvas->show(); + + QQuickItem *o = canvas->rootObject(); + QQuickItem *item = o->findChild("theItem"); + QCOMPARE(item->width(), qreal(200)); + QCOMPARE(item->height(), qreal(100)); + QCOMPARE(item->x(), qreal(100)); + + delete canvas; +} + +// QTBUG-11465 +void tst_QQuickItem::childrenRectBug2() +{ + QQuickView *canvas = new QQuickView(0); + + QString warning1 = testFileUrl("childrenRectBug2.qml").toString() + ":7:5: QML Item: Binding loop detected for property \"width\""; + QTest::ignoreMessage(QtWarningMsg, qPrintable(warning1)); + QTest::ignoreMessage(QtWarningMsg, qPrintable(warning1)); + + QString warning2 = testFileUrl("childrenRectBug2.qml").toString() + ":7:5: QML Item: Binding loop detected for property \"height\""; + QTest::ignoreMessage(QtWarningMsg, qPrintable(warning2)); + QTest::ignoreMessage(QtWarningMsg, qPrintable(warning2)); + QTest::ignoreMessage(QtWarningMsg, qPrintable(warning2)); + QTest::ignoreMessage(QtWarningMsg, qPrintable(warning2)); + + canvas->setSource(testFileUrl("childrenRectBug2.qml")); + canvas->show(); + + QQuickRectangle *rect = qobject_cast(canvas->rootObject()); + QVERIFY(rect); + QQuickItem *item = rect->findChild("theItem"); + QCOMPARE(item->width(), qreal(100)); + QCOMPARE(item->height(), qreal(110)); + QCOMPARE(item->x(), qreal(130)); + + QQuickItemPrivate *rectPrivate = QQuickItemPrivate::get(rect); + rectPrivate->setState("row"); + QCOMPARE(item->width(), qreal(210)); + QCOMPARE(item->height(), qreal(50)); + QCOMPARE(item->x(), qreal(75)); + + delete canvas; +} + +// QTBUG-12722 +void tst_QQuickItem::childrenRectBug3() +{ + QQuickView *canvas = new QQuickView(0); + canvas->setSource(testFileUrl("childrenRectBug3.qml")); + canvas->show(); + + //don't crash on delete + delete canvas; +} + +// QTBUG-13893 +void tst_QQuickItem::transformCrash() +{ + QQuickView *canvas = new QQuickView(0); + canvas->setSource(testFileUrl("transformCrash.qml")); + canvas->show(); + + delete canvas; +} + +void tst_QQuickItem::implicitSize() +{ + QQuickView *canvas = new QQuickView(0); + canvas->setSource(testFileUrl("implicitsize.qml")); + canvas->show(); + + QQuickItem *item = qobject_cast(canvas->rootObject()); + QVERIFY(item); + QCOMPARE(item->width(), qreal(80)); + QCOMPARE(item->height(), qreal(60)); + + QCOMPARE(item->implicitWidth(), qreal(200)); + QCOMPARE(item->implicitHeight(), qreal(100)); + + QMetaObject::invokeMethod(item, "resetSize"); + + QCOMPARE(item->width(), qreal(200)); + QCOMPARE(item->height(), qreal(100)); + + QMetaObject::invokeMethod(item, "changeImplicit"); + + QCOMPARE(item->implicitWidth(), qreal(150)); + QCOMPARE(item->implicitHeight(), qreal(80)); + QCOMPARE(item->width(), qreal(150)); + QCOMPARE(item->height(), qreal(80)); + + delete canvas; +} + +void tst_QQuickItem::qtbug_16871() +{ + QQmlComponent component(&engine, testFileUrl("qtbug_16871.qml")); + QObject *o = component.create(); + QVERIFY(o != 0); + delete o; +} + + +void tst_QQuickItem::visibleChildren() +{ + QQuickView *canvas = new QQuickView(0); + canvas->setSource(testFileUrl("visiblechildren.qml")); + canvas->show(); + + QQuickItem *root = qobject_cast(canvas->rootObject()); + QVERIFY(root); + + QCOMPARE(root->property("test1_1").toBool(), true); + QCOMPARE(root->property("test1_2").toBool(), true); + QCOMPARE(root->property("test1_3").toBool(), true); + QCOMPARE(root->property("test1_4").toBool(), true); + + QMetaObject::invokeMethod(root, "hideFirstAndLastRowChild"); + QCOMPARE(root->property("test2_1").toBool(), true); + QCOMPARE(root->property("test2_2").toBool(), true); + QCOMPARE(root->property("test2_3").toBool(), true); + QCOMPARE(root->property("test2_4").toBool(), true); + + QMetaObject::invokeMethod(root, "showLastRowChildsLastChild"); + QCOMPARE(root->property("test3_1").toBool(), true); + QCOMPARE(root->property("test3_2").toBool(), true); + QCOMPARE(root->property("test3_3").toBool(), true); + QCOMPARE(root->property("test3_4").toBool(), true); + + QMetaObject::invokeMethod(root, "showLastRowChild"); + QCOMPARE(root->property("test4_1").toBool(), true); + QCOMPARE(root->property("test4_2").toBool(), true); + QCOMPARE(root->property("test4_3").toBool(), true); + QCOMPARE(root->property("test4_4").toBool(), true); + + QString warning1 = testFileUrl("visiblechildren.qml").toString() + ":96:32: QML Item: QQuickItem: visibleChildren property is readonly and cannot be assigned to."; + QTest::ignoreMessage(QtWarningMsg, qPrintable(warning1)); + QMetaObject::invokeMethod(root, "tryWriteToReadonlyVisibleChildren"); + QCOMPARE(root->property("test5_1").toBool(), true); + + QMetaObject::invokeMethod(root, "reparentVisibleItem3"); + QCOMPARE(root->property("test6_1").toBool(), true); + QCOMPARE(root->property("test6_2").toBool(), true); + QCOMPARE(root->property("test6_3").toBool(), true); + QCOMPARE(root->property("test6_4").toBool(), true); + + QMetaObject::invokeMethod(root, "reparentImlicitlyInvisibleItem4_1"); + QCOMPARE(root->property("test7_1").toBool(), true); + QCOMPARE(root->property("test7_2").toBool(), true); + QCOMPARE(root->property("test7_3").toBool(), true); + QCOMPARE(root->property("test7_4").toBool(), true); + + // FINALLY TEST THAT EVERYTHING IS AS EXPECTED + QCOMPARE(root->property("test8_1").toBool(), true); + QCOMPARE(root->property("test8_2").toBool(), true); + QCOMPARE(root->property("test8_3").toBool(), true); + QCOMPARE(root->property("test8_4").toBool(), true); + QCOMPARE(root->property("test8_5").toBool(), true); + + delete canvas; +} + +void tst_QQuickItem::parentLoop() +{ + QQuickView *canvas = new QQuickView(0); + + QTest::ignoreMessage(QtWarningMsg, "QQuickItem::setParentItem: Parent is already part of this items subtree."); + canvas->setSource(testFileUrl("parentLoop.qml")); + + QQuickItem *root = qobject_cast(canvas->rootObject()); + QVERIFY(root); + + QQuickItem *item1 = root->findChild("item1"); + QVERIFY(item1); + QCOMPARE(item1->parentItem(), root); + + QQuickItem *item2 = root->findChild("item2"); + QVERIFY(item2); + QCOMPARE(item2->parentItem(), item1); + + delete canvas; +} + +QTEST_MAIN(tst_QQuickItem) + +#include "tst_qquickitem.moc" diff --git a/tests/auto/quick/qquickitemlayer/data/DisableLayer.qml b/tests/auto/quick/qquickitemlayer/data/DisableLayer.qml new file mode 100644 index 0000000000..70fc05e937 --- /dev/null +++ b/tests/auto/quick/qquickitemlayer/data/DisableLayer.qml @@ -0,0 +1,18 @@ +import QtQuick 2.0 + +Item { + width: 200 + height: 200 + Rectangle { + width: 100 + height: 100 + color: "red" + layer.enabled: true + Component.onCompleted: { + layer.enabled = false + visible = false + width = 120 + x = 10 + } + } +} diff --git a/tests/auto/quick/qquickitemlayer/data/Effect.qml b/tests/auto/quick/qquickitemlayer/data/Effect.qml new file mode 100644 index 0000000000..630c8f90ed --- /dev/null +++ b/tests/auto/quick/qquickitemlayer/data/Effect.qml @@ -0,0 +1,34 @@ +import QtQuick 2.0 + +Item +{ + width: 100 + height: 100 + + Rectangle { + id: box + width: 100 + height: 100 + + color: "#0000ff" + + Rectangle { + x: 50 + width: 50 + height: 100 + color: "#00ff00" + } + + layer.enabled: true + layer.effect: ShaderEffect { + fragmentShader: " + uniform lowp sampler2D source; + uniform lowp float qt_Opacity; + varying highp vec2 qt_TexCoord0; + void main() { + gl_FragColor = texture2D(source, qt_TexCoord0).bgra * qt_Opacity; + }" + } + + } +} diff --git a/tests/auto/quick/qquickitemlayer/data/Enabled.qml b/tests/auto/quick/qquickitemlayer/data/Enabled.qml new file mode 100644 index 0000000000..0e7d4f56b8 --- /dev/null +++ b/tests/auto/quick/qquickitemlayer/data/Enabled.qml @@ -0,0 +1,25 @@ +import QtQuick 2.0 + +Item +{ + width: 200 + height: 200 + + Item { + width: 20 + height: 20 + scale: 10 + + layer.enabled: true + anchors.centerIn: parent + + Rectangle { + width: 20 + height: 20 + gradient: Gradient { + GradientStop { position: 0; color: "white" } + GradientStop { position: 1; color: "black" } + } + } + } +} diff --git a/tests/auto/quick/qquickitemlayer/data/ItemEffect.qml b/tests/auto/quick/qquickitemlayer/data/ItemEffect.qml new file mode 100644 index 0000000000..2f17d78efd --- /dev/null +++ b/tests/auto/quick/qquickitemlayer/data/ItemEffect.qml @@ -0,0 +1,23 @@ +import QtQuick 2.0 + +Item { + width: 200 + height: 200 + Rectangle { + anchors.fill: parent + anchors.margins: 99 + gradient: Gradient { + GradientStop { position: 0.3; color: "red" } + GradientStop { position: 0.7; color: "blue" } + } + layer.enabled: true + layer.effect: Item { + property variant source + ShaderEffect { + anchors.fill: parent + anchors.margins: -99 + property variant source: parent.source + } + } + } +} diff --git a/tests/auto/quick/qquickitemlayer/data/Mipmap.qml b/tests/auto/quick/qquickitemlayer/data/Mipmap.qml new file mode 100644 index 0000000000..8de41076e9 --- /dev/null +++ b/tests/auto/quick/qquickitemlayer/data/Mipmap.qml @@ -0,0 +1,30 @@ +import QtQuick 2.0 + +Item +{ + width: 100 + height: 100 + + Rectangle { + id: box + width: 600 + height: 600 + + scale: 1 / 6. + + color: "black" + + layer.enabled: true + layer.mipmap: true + layer.smooth: true + + anchors.centerIn: parent + + Rectangle { + x: 1 + width: 1 + height: parent.height + color: "white" + } + } +} diff --git a/tests/auto/quick/qquickitemlayer/data/RectangleEffect.qml b/tests/auto/quick/qquickitemlayer/data/RectangleEffect.qml new file mode 100644 index 0000000000..94c43f2caf --- /dev/null +++ b/tests/auto/quick/qquickitemlayer/data/RectangleEffect.qml @@ -0,0 +1,22 @@ +import QtQuick 2.0 + +Item { + width: 200 + height: 200 + Rectangle { + width: 100 + height: 100 + x: 50 + y: 50 + scale: 1.5 + z: 1 + rotation: 45 + color: "#ff0000" + layer.enabled: true + layer.effect: Rectangle { color: "#0000ff" } + } + Rectangle { + anchors.fill: parent + color: "#00ff00" + } +} diff --git a/tests/auto/quick/qquickitemlayer/data/SamplerNameChange.qml b/tests/auto/quick/qquickitemlayer/data/SamplerNameChange.qml new file mode 100644 index 0000000000..a4c2ebff6b --- /dev/null +++ b/tests/auto/quick/qquickitemlayer/data/SamplerNameChange.qml @@ -0,0 +1,18 @@ +import QtQuick 2.0 + +Rectangle { + width: 200 + height: 200 + color: "blue" + layer.enabled: true + layer.effect: ShaderEffect { + fragmentShader: " + uniform sampler2D foo; + uniform lowp float qt_Opacity; + varying highp vec2 qt_TexCoord0; + void main() { + gl_FragColor = texture2D(foo, qt_TexCoord0) * qt_Opacity; + }" + } + Component.onCompleted: layer.samplerName = "foo" +} diff --git a/tests/auto/quick/qquickitemlayer/data/Smooth.qml b/tests/auto/quick/qquickitemlayer/data/Smooth.qml new file mode 100644 index 0000000000..3f9575bb0b --- /dev/null +++ b/tests/auto/quick/qquickitemlayer/data/Smooth.qml @@ -0,0 +1,23 @@ +import QtQuick 2.0 + + +Item { + width: 200 + height: 100 + + Row { + id: layerRoot + + width: 20 + height: 10 + + Rectangle { width: 10; height: 10; color: "red" } + Rectangle { width: 10; height: 10; color: "blue" } + + layer.enabled: true + layer.smooth: true + + anchors.centerIn: parent + scale: 10 + } +} diff --git a/tests/auto/quick/qquickitemlayer/data/SourceRect.qml b/tests/auto/quick/qquickitemlayer/data/SourceRect.qml new file mode 100644 index 0000000000..7cc7e8b21e --- /dev/null +++ b/tests/auto/quick/qquickitemlayer/data/SourceRect.qml @@ -0,0 +1,33 @@ +import QtQuick 2.0 + +Item +{ + width: 100 + height: 100 + + Rectangle { + id: box + width: 100 + height: 100 + + color: "#ff0000" + + layer.enabled: true + layer.sourceRect: Qt.rect(-10, -10, box.width + 20, box.height + 20); + + // A shader that pads the transparent pixels with blue. + layer.effect: ShaderEffect { + fragmentShader: " + uniform lowp sampler2D source; + uniform lowp float qt_Opacity; + varying highp vec2 qt_TexCoord0; + void main() { + vec4 c = texture2D(source, qt_TexCoord0); + if (c.a == 0.) + c = vec4(0, 0, 1, 1); + gl_FragColor = c * qt_Opacity; + } + " + } + } +} diff --git a/tests/auto/quick/qquickitemlayer/data/TextureProvider.qml b/tests/auto/quick/qquickitemlayer/data/TextureProvider.qml new file mode 100644 index 0000000000..ccd515652a --- /dev/null +++ b/tests/auto/quick/qquickitemlayer/data/TextureProvider.qml @@ -0,0 +1,40 @@ +import QtQuick 2.0 + +Item +{ + width: 100 + height: 100 + + Rectangle { + id: box + width: 100 + height: 100 + + color: "#0000ff" + + Rectangle { + x: 50 + width: 50 + height: 100 + color: "#00ff00" + } + + visible: false + + layer.enabled: true + } + + ShaderEffect { + anchors.fill: parent + property variant source: box + + fragmentShader: " + uniform lowp sampler2D source; + uniform lowp float qt_Opacity; + varying highp vec2 qt_TexCoord0; + void main() { + gl_FragColor = texture2D(source, qt_TexCoord0).bgra * qt_Opacity; + }" + } + +} diff --git a/tests/auto/quick/qquickitemlayer/data/ToggleLayerAndEffect.qml b/tests/auto/quick/qquickitemlayer/data/ToggleLayerAndEffect.qml new file mode 100644 index 0000000000..174b669b6c --- /dev/null +++ b/tests/auto/quick/qquickitemlayer/data/ToggleLayerAndEffect.qml @@ -0,0 +1,23 @@ +import QtQuick 2.0 + +Item { + width: 200 + height: 200 + Rectangle { + width: 100 + height: 100 + color: "red" + Component.onCompleted: { + layer.enabled = true + layer.effect = effectComponent + layer.enabled = false + visible = false + width = 120 + x = 10 + } + } + Component { + id: effectComponent + ShaderEffect { } + } +} diff --git a/tests/auto/quick/qquickitemlayer/data/Visible.qml b/tests/auto/quick/qquickitemlayer/data/Visible.qml new file mode 100644 index 0000000000..8267f18250 --- /dev/null +++ b/tests/auto/quick/qquickitemlayer/data/Visible.qml @@ -0,0 +1,56 @@ +import QtQuick 2.0 + +Item +{ + id: root + + width: 100 + height: 100 + + property bool layerEffect: false; + onLayerEffectChanged: root.maybeUse(); + Component.onCompleted: root.maybeUse(); + + property real layerOpacity: 1; + property bool layerVisible: true; + + function maybeUse() { + if (root.layerEffect) + box.layer.effect = shaderEffect + } + + Component { + id: shaderEffect + ShaderEffect { + fragmentShader: " + uniform lowp sampler2D source; + uniform lowp float qt_Opacity; + varying highp vec2 qt_TexCoord0; + void main() { + gl_FragColor = texture2D(source, qt_TexCoord0).bgra * qt_Opacity; + } + " + } + + } + + Rectangle { + id: box + width: 100 + height: 100 + + color: "#0000ff" + visible: parent.layerVisible; + opacity: parent.layerOpacity; + + Rectangle { + x: 50 + width: 50 + height: 100 + color: "#00ff00" + } + + layer.enabled: true + + } +} diff --git a/tests/auto/quick/qquickitemlayer/data/ZOrder.qml b/tests/auto/quick/qquickitemlayer/data/ZOrder.qml new file mode 100644 index 0000000000..59ccb32224 --- /dev/null +++ b/tests/auto/quick/qquickitemlayer/data/ZOrder.qml @@ -0,0 +1,52 @@ +import QtQuick 2.0 + +Item +{ + id: root + + width: 200 + height: 200 + + Component { + id: shaderEffect + ShaderEffect { } + } + + property bool layerEffect: false; + onLayerEffectChanged: root.maybeUse(); + Component.onCompleted: root.maybeUse(); + + function maybeUse() { + if (root.layerEffect) + box.layer.effect = shaderEffect + } + + + Rectangle { + color: "red" + anchors.left: parent.left + anchors.top: parent.top + width: 100 + height: 100 + z: 1 + } + + Rectangle { + color: "#00ff00" + anchors.bottom: parent.bottom + anchors.right: parent.right + width: 100 + height: 100 + z: 3 + } + + Rectangle { + id: box + color: "blue" + anchors.fill: parent + anchors.margins: 10 + layer.enabled: true + z: 2 + } + +} diff --git a/tests/auto/quick/qquickitemlayer/data/ZOrderChange.qml b/tests/auto/quick/qquickitemlayer/data/ZOrderChange.qml new file mode 100644 index 0000000000..ebbd3b7e15 --- /dev/null +++ b/tests/auto/quick/qquickitemlayer/data/ZOrderChange.qml @@ -0,0 +1,50 @@ +import QtQuick 2.0 + +Item { + width: 200 + height: 200 + property bool layerEffect: false + property bool layerEnabled: false + property real layerZ: 0 + Rectangle { + anchors.fill: parent + color: "#00ffff" + } + Rectangle { + id: foo + anchors.fill: parent + color: "#ffff00" + Rectangle { + width: 100 + height: 100 + color: "#00ffff" + } + layer.enabled: parent.layerEnabled + layer.effect: parent.layerEffect ? effectComponent : null + opacity: 0.5 + z: layerZ + } + Rectangle { + width: 100 + height: 100 + x: 100 + color: "#ff0000" + } + Rectangle { + width: 100 + height: 100 + y: 100 + color: "#0000ff" + z: 1 + } + Component { + id: effectComponent + ShaderEffect { + fragmentShader: " + uniform sampler2D source; + uniform lowp float qt_Opacity; + varying highp vec2 qt_TexCoord0; + void main() { gl_FragColor = texture2D(source, qt_TexCoord0).xzyw * qt_Opacity; }" + } + } +} diff --git a/tests/auto/quick/qquickitemlayer/qquickitemlayer.pro b/tests/auto/quick/qquickitemlayer/qquickitemlayer.pro new file mode 100644 index 0000000000..a2d5f401ff --- /dev/null +++ b/tests/auto/quick/qquickitemlayer/qquickitemlayer.pro @@ -0,0 +1,38 @@ +CONFIG += testcase +TARGET = tst_qquickitemlayer +SOURCES += tst_qquickitemlayer.cpp + +macx:CONFIG -= app_bundle + +testDataFiles.files = data +testDataFiles.path = . +DEPLOYMENT += testDataFiles + +include(../../shared/util.pri) + +CONFIG += parallel_test +QT += core-private gui-private v8-private qml-private quick-private testlib + +OTHER_FILES += \ + data/Smooth.qml \ + data/Enabled.qml \ + data/Mipmap.qml \ + data/Effect.qml \ + data/SourceRect.qml \ + data/TextureProvider.qml \ + data/Visible.qml \ + data/ZOrder.qml \ + data/ZOrderChange.qml \ + data/ToggleLayerAndEffect.qml \ + data/DisableLayer.qml \ + data/SamplerNameChange.qml \ + data/ItemEffect.qml \ + data/RectangleEffect.qml + + + + + + + + diff --git a/tests/auto/quick/qquickitemlayer/tst_qquickitemlayer.cpp b/tests/auto/quick/qquickitemlayer/tst_qquickitemlayer.cpp new file mode 100644 index 0000000000..44d0d6d09c --- /dev/null +++ b/tests/auto/quick/qquickitemlayer/tst_qquickitemlayer.cpp @@ -0,0 +1,436 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include + +#include +#include +#include + +#include "../../shared/util.h" + +class tst_QQuickItemLayer: public QQmlDataTest +{ + Q_OBJECT +public: + tst_QQuickItemLayer(); + + QImage runTest(const QString &url) + { + QQuickView view; + view.setSource(QUrl(url)); + + view.show(); + QTest::qWaitForWindowShown(&view); + + return view.grabFrameBuffer(); + } + +private slots: + void layerEnabled(); + void layerSmooth(); + void layerMipmap(); + void layerEffect(); + + void layerVisibility_data(); + void layerVisibility(); + + void layerSourceRect(); + + void layerZOrder_data(); + void layerZOrder(); + + void layerIsTextureProvider(); + + void changeZOrder_data(); + void changeZOrder(); + + void toggleLayerAndEffect(); + void disableLayer(); + void changeSamplerName(); + void itemEffect(); + void rectangleEffect(); + +private: + bool m_isMesaSoftwareRasterizer; + int m_mesaVersion; +}; + +tst_QQuickItemLayer::tst_QQuickItemLayer() + : m_mesaVersion(0) +{ + QWindow window; + QOpenGLContext context; + window.setSurfaceType(QWindow::OpenGLSurface); + window.create(); + context.create(); + context.makeCurrent(&window); + const char *vendor = (const char *)glGetString(GL_VENDOR); + const char *renderer = (const char *)glGetString(GL_RENDERER); + m_isMesaSoftwareRasterizer = strcmp(vendor, "Mesa Project") == 0 + && strcmp(renderer, "Software Rasterizer") == 0; + if (m_isMesaSoftwareRasterizer) { + // Expects format: Mesa [-devel] [...] + const char *version = (const char *)glGetString(GL_VERSION); + QList list = QByteArray(version).split(' '); + if (list.size() >= 3) { + list = list.at(2).split('-').at(0).split('.'); + int major = 0; + int minor = 0; + int patch = 0; + if (list.size() >= 1) + major = list.at(0).toInt(); + if (list.size() >= 2) + minor = list.at(1).toInt(); + if (list.size() >= 3) + patch = list.at(2).toInt(); + m_mesaVersion = QT_VERSION_CHECK(major, minor, patch); + } + } +} + +// The test draws a red and a blue box next to each other and tests that the +// output is still red and blue on the left and right and a combination of +// the two in the middle. + +void tst_QQuickItemLayer::layerSmooth() +{ + if (m_isMesaSoftwareRasterizer && m_mesaVersion < QT_VERSION_CHECK(7, 11, 0)) + QSKIP("Mesa Software Rasterizer below version 7.11 does not render this test correctly."); + QImage fb = runTest(testFile("Smooth.qml")); + QCOMPARE(fb.pixel(0, 0), qRgb(0xff, 0, 0)); + QCOMPARE(fb.pixel(fb.width() - 1, 0), qRgb(0, 0, 0xff)); + + uint pixel = fb.pixel(fb.width() / 2, 0); + QVERIFY(qRed(pixel) > 0); + QVERIFY(qBlue(pixel) > 0); +} + + + +// The test draws a gradient at a small size into a layer and scales the +// layer. If the layer is enabled there should be very visible bands in +// the gradient. + +void tst_QQuickItemLayer::layerEnabled() +{ + if (m_isMesaSoftwareRasterizer && m_mesaVersion < QT_VERSION_CHECK(7, 11, 0)) + QSKIP("Mesa Software Rasterizer below version 7.11 does not render this test correctly."); + QImage fb = runTest(testFile("Enabled.qml")); + // Verify the banding + QCOMPARE(fb.pixel(0, 0), fb.pixel(0, 1)); + // Verify the gradient + QVERIFY(fb.pixel(0, 0) != fb.pixel(0, fb.height() - 1)); +} + + + +// The test draws a one pixel wide line and scales it down by more than a a factor 2 +// If mipmpping works, the pixels should be gray, not white or black + +void tst_QQuickItemLayer::layerMipmap() +{ + if (m_isMesaSoftwareRasterizer) + QSKIP("Mipmapping does not work with the Mesa Software Rasterizer."); + QImage fb = runTest(testFile("Mipmap.qml")); + QVERIFY(fb.pixel(0, 0) != 0xff000000); + QVERIFY(fb.pixel(0, 0) != 0xffffffff); +} + + + +// The test implements an rgb swapping effect sourced from a blue rectangle. The +// resulting pixel should be red + +void tst_QQuickItemLayer::layerEffect() +{ + if (m_isMesaSoftwareRasterizer && m_mesaVersion < QT_VERSION_CHECK(7, 11, 0)) + QSKIP("Mesa Software Rasterizer below version 7.11 does not render this test correctly."); + QImage fb = runTest(testFile("Effect.qml")); + QCOMPARE(fb.pixel(0, 0), qRgb(0xff, 0, 0)); + QCOMPARE(fb.pixel(fb.width() - 1, 0), qRgb(0, 0xff, 0)); +} + + + +// The test draws a rectangle and verifies that there is padding on each side +// as the source rect spans outside the item. The padding is verified using +// a shader that pads transparent to blue. Everything else is red. +void tst_QQuickItemLayer::layerSourceRect() +{ + if (m_isMesaSoftwareRasterizer && m_mesaVersion < QT_VERSION_CHECK(7, 11, 0)) + QSKIP("Mesa Software Rasterizer below version 7.11 does not render this test correctly."); + + QImage fb = runTest(testFile("SourceRect.qml")); + + // Check that the edges are converted to blue + QCOMPARE(fb.pixel(0, 0), qRgb(0, 0, 0xff)); + QCOMPARE(fb.pixel(fb.width() - 1, 0), qRgb(0, 0, 0xff)); + QCOMPARE(fb.pixel(0, fb.height() - 1), qRgb(0, 0, 0xff)); + QCOMPARE(fb.pixel(fb.width() - 1, fb.height() - 1), qRgb(0, 0, 0xff)); + + // The center pixel should be red + QCOMPARE(fb.pixel(fb.width() / 2, fb.height() / 2), qRgb(0xff, 0, 0)); +} + + + +// Same as the effect test up above, but this time use the item +// directly in a stand alone ShaderEffect +void tst_QQuickItemLayer::layerIsTextureProvider() +{ + if (m_isMesaSoftwareRasterizer && m_mesaVersion < QT_VERSION_CHECK(7, 11, 0)) + QSKIP("Mesa Software Rasterizer below version 7.11 does not render this test correctly."); + QImage fb = runTest(testFile("TextureProvider.qml")); + QCOMPARE(fb.pixel(0, 0), qRgb(0xff, 0, 0)); + QCOMPARE(fb.pixel(fb.width() - 1, 0), qRgb(0, 0xff, 0)); +} + + +void tst_QQuickItemLayer::layerVisibility_data() +{ + QTest::addColumn("visible"); + QTest::addColumn("effect"); + QTest::addColumn("opacity"); + + QTest::newRow("!effect, !visible, a=1") << false << false << 1.; + QTest::newRow("!effect, visible, a=1") << false << true << 1.; + QTest::newRow("effect, !visible, a=1") << true << false << 1.; + QTest::newRow("effect, visible, a=1") << true << true << 1.; + + QTest::newRow("!effect, !visible, a=.5") << false << false << .5; + QTest::newRow("!effect, visible, a=.5") << false << true << .5; + QTest::newRow("effect, !visible, a=.5") << true << false << .5; + QTest::newRow("effect, visible, a=.5") << true << true << .5; + + QTest::newRow("!effect, !visible, a=0") << false << false << 0.; + QTest::newRow("!effect, visible, a=0") << false << true << 0.; + QTest::newRow("effect, !visible, a=0") << true << false << 0.; + QTest::newRow("effect, visible, a=0") << true << true << 0.; +} + +void tst_QQuickItemLayer::layerVisibility() +{ + if (m_isMesaSoftwareRasterizer && m_mesaVersion < QT_VERSION_CHECK(7, 11, 0)) + QSKIP("Mesa Software Rasterizer below version 7.11 does not render this test correctly."); + + QFETCH(bool, visible); + QFETCH(bool, effect); + QFETCH(qreal, opacity); + + QQuickView view; + view.setSource(testFile("Visible.qml")); + + QQuickItem *child = view.rootItem()->childItems().at(0); + child->setProperty("layerVisible", visible); + child->setProperty("layerEffect", effect); + child->setProperty("layerOpacity", opacity); + + view.show(); + + QTest::qWaitForWindowShown(&view); + + QImage fb = view.grabFrameBuffer(); + uint pixel = fb.pixel(0, 0); + + if (!visible || opacity == 0) { + QCOMPARE(pixel, qRgb(0xff, 0xff, 0xff)); + } else if (effect) { + QCOMPARE(qRed(pixel), 0xff); + QVERIFY(qGreen(pixel) < 0xff); + QVERIFY(qBlue(pixel) < 0xff); + } else { // no effect + QCOMPARE(qBlue(pixel), 0xff); + QVERIFY(qGreen(pixel) < 0xff); + QVERIFY(qRed(pixel) < 0xff); + } +} + + + + +void tst_QQuickItemLayer::layerZOrder_data() +{ + QTest::addColumn("effect"); + + QTest::newRow("!effect") << false; + QTest::newRow("effect") << true; +} + +void tst_QQuickItemLayer::layerZOrder() +{ + if (m_isMesaSoftwareRasterizer && m_mesaVersion < QT_VERSION_CHECK(7, 11, 0)) + QSKIP("Mesa Software Rasterizer below version 7.11 does not render this test correctly."); + + QFETCH(bool, effect); + + QQuickView view; + view.setSource(testFile("ZOrder.qml")); + + QQuickItem *child = view.rootItem()->childItems().at(0); + child->setProperty("layerEffect", effect); + + view.show(); + + QTest::qWaitForWindowShown(&view); + + QImage fb = view.grabFrameBuffer(); + + QCOMPARE(fb.pixel(50, 50), qRgb(0, 0, 0xff)); + QCOMPARE(fb.pixel(150, 150), qRgb(0, 0xff, 00)); + +} + +void tst_QQuickItemLayer::changeZOrder_data() +{ + QTest::addColumn("layered"); + QTest::addColumn("effect"); + + QTest::newRow("layered, effect") << true << true; + QTest::newRow("layered, !effect") << true << false; + QTest::newRow("!layered") << false << false; +} + +void tst_QQuickItemLayer::changeZOrder() +{ + if (m_isMesaSoftwareRasterizer && m_mesaVersion < QT_VERSION_CHECK(7, 11, 0)) + QSKIP("Mesa Software Rasterizer below version 7.11 does not render this test correctly."); + + QFETCH(bool, layered); + QFETCH(bool, effect); + + QQuickView view; + view.setSource(testFile("ZOrderChange.qml")); + + QQuickItem *child = view.rootItem()->childItems().at(0); + child->setProperty("layerEnabled", layered); + child->setProperty("layerEffect", effect); + child->setProperty("layerZ", 1); + + view.show(); + + QTest::qWaitForWindowShown(&view); + + QImage fb = view.grabFrameBuffer(); + + QRgb topLeft = fb.pixel(50, 50); + QRgb topRight = fb.pixel(150, 50); + QRgb bottomLeft = fb.pixel(50, 150); + QRgb bottomRight = fb.pixel(150, 150); + + QCOMPARE(bottomLeft, qRgb(0, 0, 0xff)); + + if (layered) { + QCOMPARE(topLeft, qRgb(0, 0xff, 0xff)); + } else { + QCOMPARE(qGreen(topLeft), 0xff); + QVERIFY(qAbs(qRed(topLeft) - 0x3f) < 4); + QVERIFY(qAbs(qBlue(topLeft) - 0xbf) < 4); + } + + if (layered && effect) { + QCOMPARE(qRed(topRight), 0xff); + QCOMPARE(qGreen(topRight), 0x00); + QVERIFY(qAbs(qBlue(topRight) - 0x7f) < 4); + + QVERIFY(qAbs(qRed(bottomRight) - 0x7f) < 4); + QCOMPARE(qBlue(bottomRight), 0xff); + QVERIFY(qAbs(qGreen(bottomRight) - 0x7f) < 4); + } else { + QCOMPARE(qRed(topRight), 0xff); + QCOMPARE(qBlue(topRight), 0x00); + QVERIFY(qAbs(qGreen(topRight) - 0x7f) < 4); + + QVERIFY(qAbs(qRed(bottomRight) - 0x7f) < 4); + QCOMPARE(qGreen(bottomRight), 0xff); + QVERIFY(qAbs(qBlue(bottomRight) - 0x7f) < 4); + } +} + +void tst_QQuickItemLayer::toggleLayerAndEffect() +{ + // This test passes if it doesn't crash. + runTest(testFile("ToggleLayerAndEffect.qml")); +} + +void tst_QQuickItemLayer::disableLayer() +{ + // This test passes if it doesn't crash. + runTest(testFile("DisableLayer.qml")); +} + +void tst_QQuickItemLayer::changeSamplerName() +{ + if (m_isMesaSoftwareRasterizer && m_mesaVersion < QT_VERSION_CHECK(7, 11, 0)) + QSKIP("Mesa Software Rasterizer below version 7.11 does not render this test correctly."); + QImage fb = runTest(testFile("SamplerNameChange.qml")); + QCOMPARE(fb.pixel(0, 0), qRgb(0, 0, 0xff)); +} + +void tst_QQuickItemLayer::itemEffect() +{ + if (m_isMesaSoftwareRasterizer && m_mesaVersion < QT_VERSION_CHECK(7, 11, 0)) + QSKIP("Mesa Software Rasterizer below version 7.11 does not render this test correctly."); + QImage fb = runTest(testFile("ItemEffect.qml")); + QCOMPARE(fb.pixel(0, 0), qRgb(0xff, 0, 0)); + QCOMPARE(fb.pixel(199, 0), qRgb(0xff, 0, 0)); + QCOMPARE(fb.pixel(0, 199), qRgb(0, 0, 0xff)); + QCOMPARE(fb.pixel(199, 199), qRgb(0, 0, 0xff)); +} + +void tst_QQuickItemLayer::rectangleEffect() +{ + QImage fb = runTest(testFile("RectangleEffect.qml")); + QCOMPARE(fb.pixel(0, 0), qRgb(0, 0xff, 0)); + QCOMPARE(fb.pixel(199, 0), qRgb(0, 0xff, 0)); + QCOMPARE(fb.pixel(0, 199), qRgb(0, 0xff, 0)); + QCOMPARE(fb.pixel(199, 199), qRgb(0, 0xff, 0)); + + QCOMPARE(fb.pixel(100, 0), qRgb(0, 0, 0xff)); + QCOMPARE(fb.pixel(199, 100), qRgb(0, 0, 0xff)); + QCOMPARE(fb.pixel(100, 199), qRgb(0, 0, 0xff)); + QCOMPARE(fb.pixel(0, 100), qRgb(0, 0, 0xff)); +} + + +QTEST_MAIN(tst_QQuickItemLayer) + +#include "tst_qquickitemlayer.moc" diff --git a/tests/auto/quick/qquicklistview/data/ComponentView.qml b/tests/auto/quick/qquicklistview/data/ComponentView.qml new file mode 100644 index 0000000000..3e87be8799 --- /dev/null +++ b/tests/auto/quick/qquicklistview/data/ComponentView.qml @@ -0,0 +1,16 @@ +import QtQuick 2.0 + +ListView { + id: view + + property string title + + width: 100; height: 100; + + model: 1 + delegate: Text { objectName: "listItem"; text: view.title } + header: Text { objectName: "header"; text: view.title } + footer: Text { objectName: "footer"; text: view.title } + section.delegate: Text { objectName: "section"; text: view.title } + section.property: "modelData" +} diff --git a/tests/auto/quick/qquicklistview/data/Page.qml b/tests/auto/quick/qquicklistview/data/Page.qml new file mode 100644 index 0000000000..abe4364315 --- /dev/null +++ b/tests/auto/quick/qquicklistview/data/Page.qml @@ -0,0 +1,10 @@ +import QtQuick 2.0 + +Item { + anchors.fill: parent + default property alias contentArea: contentItem.data + Item { + id: contentItem + anchors.fill: parent + } +} diff --git a/tests/auto/quick/qquicklistview/data/addTransitions.qml b/tests/auto/quick/qquicklistview/data/addTransitions.qml new file mode 100644 index 0000000000..6a7c3234f6 --- /dev/null +++ b/tests/auto/quick/qquicklistview/data/addTransitions.qml @@ -0,0 +1,134 @@ +import QtQuick 2.0 + +Rectangle { + id: root + width: 500 + height: 600 + + property int duration: 10 + property int count: list.count + + Component { + id: myDelegate + Rectangle { + id: wrapper + + property string nameData: name + + objectName: "wrapper" + height: 20 + width: 240 + Text { text: index } + Text { + x: 30 + id: textName + objectName: "textName" + text: name + } + Text { + x: 200 + text: wrapper.y + } + color: ListView.isCurrentItem ? "lightsteelblue" : "white" + + onXChanged: checkPos() + onYChanged: checkPos() + + function checkPos() { + if (Qt.point(x, y) == targetItems_transitionFrom) + model_targetItems_transitionFrom.addItem(name, "") + if (Qt.point(x, y) == displacedItems_transitionVia) + model_displacedItems_transitionVia.addItem(name, "") + } + } + } + + ListView { + id: list + + property int targetTransitionsDone + property int displaceTransitionsDone + + property var targetTrans_items: new Object() + property var targetTrans_targetIndexes: new Array() + property var targetTrans_targetItems: new Array() + + property var displacedTrans_items: new Object() + property var displacedTrans_targetIndexes: new Array() + property var displacedTrans_targetItems: new Array() + + objectName: "list" + focus: true + anchors.centerIn: parent + width: 240 + height: 320 + model: testModel + delegate: myDelegate + + // for QQmlListProperty types + function copyList(propList) { + var temp = new Array() + for (var i=0; iName: ' + name } + Text { text: 'Number: ' + number } + } + } + } + Component { + id: highlightRed + Rectangle { + color: "red" + radius: 10 + opacity: 0.5 + } + } + ListView { + objectName: "listView" + anchors.fill: parent + model: listModel + delegate: delegate + highlight: highlightRed + focus: true + highlightFollowsCurrentItem: true + preferredHighlightBegin: 0.0 + preferredHighlightEnd: 0.0 + highlightRangeMode: ListView.ApplyRange + keyNavigationWraps: true + cacheBuffer: 10 + snapMode: ListView.SnapToItem + } + + data:[ + ListModel { + id: listModel + ListElement { + name: "Bill Smith" + number: "555 3264" + } + ListElement { + name: "John Brown" + number: "555 8426" + } + ListElement { + name: "Sam Wise" + number: "555 0473" + } + }, + ListModel { + objectName: "alternateModel" + ListElement { + name: "Jack" + number: "555 8426" + } + ListElement { + name: "Mary" + number: "555 3264" + } + } + ] +} + + diff --git a/tests/auto/quick/qquicklistview/data/qtbug-21742.qml b/tests/auto/quick/qquicklistview/data/qtbug-21742.qml new file mode 100644 index 0000000000..774f9041fb --- /dev/null +++ b/tests/auto/quick/qquicklistview/data/qtbug-21742.qml @@ -0,0 +1,36 @@ +import QtQuick 2.0 + +Rectangle { + height: 200 + width: 200 + property int count: menuView.count + + Component.onCompleted: { setModel(); } + + function setModel() + { + menuModel.append({"enabledItem" : true}); + menuView.currentIndex = 0; + } + + ListModel { + id: menuModel + } + + ListView { + id: menuView + anchors.fill: parent + model: menuModel + delegate: mything + } + + Component { + id: mything + Rectangle { + height: 50 + width: 200 + color: index == menuView.currentIndex ? "green" : "blue" + } + } + +} \ No newline at end of file diff --git a/tests/auto/quick/qquicklistview/data/qtbug14821.qml b/tests/auto/quick/qquicklistview/data/qtbug14821.qml new file mode 100644 index 0000000000..0a5e0acbb4 --- /dev/null +++ b/tests/auto/quick/qquicklistview/data/qtbug14821.qml @@ -0,0 +1,31 @@ +import QtQuick 2.0 + +ListView { + id: view + width: 300; height: 200 + focus: true + keyNavigationWraps: true + + model: 100 + + preferredHighlightBegin: 90 + preferredHighlightEnd: 110 + + highlightRangeMode: ListView.StrictlyEnforceRange + highlight: Component { + Rectangle { + border.color: "blue" + border.width: 3 + color: "transparent" + width: 300; height: 15 + } + } + + delegate: Component { + Item { + height: 15 + (view.currentIndex == index ? 20 : 0) + width: 200 + Text { text: 'Index: ' + index; anchors.verticalCenter: parent.verticalCenter } + } + } +} diff --git a/tests/auto/quick/qquicklistview/data/qtbug16037.qml b/tests/auto/quick/qquicklistview/data/qtbug16037.qml new file mode 100644 index 0000000000..21faeb3f32 --- /dev/null +++ b/tests/auto/quick/qquicklistview/data/qtbug16037.qml @@ -0,0 +1,37 @@ +import QtQuick 2.0 + +Item { + width: 640 + height: 480 + + function setModel() { + listView.model = listModel1 + } + + ListModel { + id: listModel1 + ListElement { text: "Apple" } + ListElement { text: "Banana" } + ListElement { text: "Orange" } + ListElement { text: "Coconut" } + } + + Rectangle { + width: 200 + height: listView.contentHeight + color: "yellow" + anchors.centerIn: parent + + ListView { + id: listView + objectName: "listview" + anchors.fill: parent + + delegate: Item { + width: 200 + height: 20 + Text { text: model.text; anchors.centerIn: parent } + } + } + } +} diff --git a/tests/auto/quick/qquicklistview/data/removeTransitions.qml b/tests/auto/quick/qquicklistview/data/removeTransitions.qml new file mode 100644 index 0000000000..a85b217138 --- /dev/null +++ b/tests/auto/quick/qquicklistview/data/removeTransitions.qml @@ -0,0 +1,144 @@ +import QtQuick 2.0 + +Rectangle { + id: root + width: 500 + height: 600 + + property int duration: 10 + property int count: list.count + + Component { + id: myDelegate + Rectangle { + id: wrapper + + property string nameData: name + + objectName: "wrapper" + height: 20 + width: 240 + Text { text: index } + Text { + x: 30 + id: textName + objectName: "textName" + text: name + } + Text { + x: 200 + text: wrapper.y + } + color: ListView.isCurrentItem ? "lightsteelblue" : "white" + + onXChanged: checkPos() + onYChanged: checkPos() + + function checkPos() { + if (Qt.point(x, y) == targetItems_transitionTo) { + model_targetItems_transitionTo.addItem(nameData, "") // name is invalid once model removes the item + } + if (Qt.point(x, y) == displacedItems_transitionVia) { + model_displacedItems_transitionVia.addItem(name, "") + } + } + } + } + + ListView { + id: list + + property int targetTransitionsDone + property int displaceTransitionsDone + + property var targetTrans_items: new Object() + property var targetTrans_targetIndexes: new Array() + property var targetTrans_targetItems: new Array() + + property var displacedTrans_items: new Object() + property var displacedTrans_targetIndexes: new Array() + property var displacedTrans_targetItems: new Array() + + objectName: "list" + focus: true + anchors.centerIn: parent + width: 240 + height: 320 + model: testModel + delegate: myDelegate + + // for QQmlListProperty types + function copyList(propList) { + var temp = new Array() + for (var i=0; i +#include + +IncrementalModel::IncrementalModel(QObject *parent) + : QAbstractListModel(parent), count(0) +{ + for (int i = 0; i < 100; ++i) + list.append("Item " + QString::number(i)); +} + +int IncrementalModel::rowCount(const QModelIndex & /* parent */) const +{ + return count; +} + +QVariant IncrementalModel::data(const QModelIndex &index, int role) const +{ + if (!index.isValid()) + return QVariant(); + + if (index.row() >= list.size() || index.row() < 0) + return QVariant(); + + if (role == Qt::DisplayRole) + return list.at(index.row()); + return QVariant(); +} + +bool IncrementalModel::canFetchMore(const QModelIndex & /* index */) const +{ + if (count < list.size()) + return true; + else + return false; +} + +void IncrementalModel::fetchMore(const QModelIndex & /* index */) +{ + int remainder = list.size() - count; + int itemsToFetch = qMin(5, remainder); + + beginInsertRows(QModelIndex(), count, count+itemsToFetch-1); + + count += itemsToFetch; + + endInsertRows(); +} diff --git a/tests/auto/quick/qquicklistview/incrementalmodel.h b/tests/auto/quick/qquicklistview/incrementalmodel.h new file mode 100644 index 0000000000..bf524d16e6 --- /dev/null +++ b/tests/auto/quick/qquicklistview/incrementalmodel.h @@ -0,0 +1,68 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef IncrementalModel_H +#define IncrementalModel_H + +#include +#include +#include + +class IncrementalModel : public QAbstractListModel +{ + Q_OBJECT + +public: + IncrementalModel(QObject *parent = 0); + + int rowCount(const QModelIndex &parent = QModelIndex()) const; + QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const; + +protected: + bool canFetchMore(const QModelIndex &parent) const; + void fetchMore(const QModelIndex &parent); + +private: + QStringList list; + int count; +}; + +#endif diff --git a/tests/auto/quick/qquicklistview/qquicklistview.pro b/tests/auto/quick/qquicklistview/qquicklistview.pro new file mode 100644 index 0000000000..4cac8e7665 --- /dev/null +++ b/tests/auto/quick/qquicklistview/qquicklistview.pro @@ -0,0 +1,16 @@ +CONFIG += testcase +TARGET = tst_qquicklistview +macx:CONFIG -= app_bundle + +HEADERS += incrementalmodel.h +SOURCES += tst_qquicklistview.cpp \ + incrementalmodel.cpp + +include (../../shared/util.pri) +include (../shared/util.pri) + +testDataFiles.files = data +testDataFiles.path = . +DEPLOYMENT += testDataFiles + +QT += core-private gui-private qml-private quick-private widgets widgets-private v8-private opengl-private testlib diff --git a/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp b/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp new file mode 100644 index 0000000000..bcac5917d6 --- /dev/null +++ b/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp @@ -0,0 +1,5716 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "../../shared/util.h" +#include "../shared/viewtestutil.h" +#include "../shared/visualtestutil.h" +#include "incrementalmodel.h" +#include + +Q_DECLARE_METATYPE(Qt::LayoutDirection) +Q_DECLARE_METATYPE(QQuickListView::Orientation) + +using namespace QQuickViewTestUtil; +using namespace QQuickVisualTestUtil; + +class tst_QQuickListView : public QQmlDataTest +{ + Q_OBJECT +public: + tst_QQuickListView(); + +private slots: + // Test both QListModelInterface and QAbstractItemModel model types + void qListModelInterface_items(); + void qListModelInterface_package_items(); + void qAbstractItemModel_items(); + + void qListModelInterface_changed(); + void qListModelInterface_package_changed(); + void qAbstractItemModel_changed(); + + void qListModelInterface_inserted(); + void qListModelInterface_inserted_more(); + void qListModelInterface_inserted_more_data(); + void qListModelInterface_package_inserted(); + void qAbstractItemModel_inserted(); + void qAbstractItemModel_inserted_more(); + void qAbstractItemModel_inserted_more_data(); + + void qListModelInterface_removed(); + void qListModelInterface_removed_more(); + void qListModelInterface_removed_more_data(); + void qListModelInterface_package_removed(); + void qAbstractItemModel_removed(); + void qAbstractItemModel_removed_more(); + void qAbstractItemModel_removed_more_data(); + + void qListModelInterface_moved(); + void qListModelInterface_moved_data(); + void qListModelInterface_package_moved(); + void qListModelInterface_package_moved_data(); + void qAbstractItemModel_moved(); + void qAbstractItemModel_moved_data(); + + void multipleChanges(); + void multipleChanges_data(); + + void qListModelInterface_clear(); + void qListModelInterface_package_clear(); + void qAbstractItemModel_clear(); + + void insertBeforeVisible(); + void insertBeforeVisible_data(); + void swapWithFirstItem(); + void itemList(); + void currentIndex_delayedItemCreation(); + void currentIndex_delayedItemCreation_data(); + void currentIndex(); + void noCurrentIndex(); + void enforceRange(); + void enforceRange_withoutHighlight(); + void spacing(); + void qListModelInterface_sections(); + void qListModelInterface_package_sections(); + void qAbstractItemModel_sections(); + void sectionsPositioning(); + void sectionsDelegate(); + void cacheBuffer(); + void positionViewAtIndex(); + void resetModel(); + void propertyChanges(); + void componentChanges(); + void modelChanges(); + void manualHighlight(); + void header(); + void header_data(); + void header_delayItemCreation(); + void footer(); + void footer_data(); + void headerFooter(); + void resizeView(); + void resizeViewAndRepaint(); + void sizeLessThan1(); + void QTBUG_14821(); + void resizeDelegate(); + void resizeFirstDelegate(); + void QTBUG_16037(); + void indexAt_itemAt_data(); + void indexAt_itemAt(); + void incrementalModel(); + void onAdd(); + void onAdd_data(); + void onRemove(); + void onRemove_data(); + void rightToLeft(); + void test_mirroring(); + void margins(); + void marginsResize(); + void marginsResize_data(); + void creationContext(); + void snapToItem_data(); + void snapToItem(); + void snapOneItem_data(); + void snapOneItem(); + + void QTBUG_9791(); + void QTBUG_11105(); + void QTBUG_21742(); + + void asynchronous(); + void unrequestedVisibility(); + + void populateTransitions(); + void populateTransitions_data(); + void addTransitions(); + void addTransitions_data(); + void moveTransitions(); + void moveTransitions_data(); + void removeTransitions(); + void removeTransitions_data(); + void multipleTransitions(); + void multipleTransitions_data(); + +private: + template void items(const QUrl &source, bool forceLayout); + template void changed(const QUrl &source, bool forceLayout); + template void inserted(const QUrl &source); + template void inserted_more(); + template void removed(const QUrl &source, bool animated); + template void removed_more(const QUrl &source); + template void moved(const QUrl &source); + template void clear(const QUrl &source); + template void sections(const QUrl &source); + + QList toIntList(const QVariantList &list); + void matchIndexLists(const QVariantList &indexLists, const QList &expectedIndexes); + void matchItemsAndIndexes(const QVariantMap &items, const QaimModel &model, const QList &expectedIndexes); + void matchItemLists(const QVariantList &itemLists, const QList &expectedItems); + + void inserted_more_data(); + void removed_more_data(); + void moved_data(); +}; + +class TestObject : public QObject +{ + Q_OBJECT + + Q_PROPERTY(bool error READ error WRITE setError NOTIFY changedError) + Q_PROPERTY(bool animate READ animate NOTIFY changedAnim) + Q_PROPERTY(bool invalidHighlight READ invalidHighlight NOTIFY changedHl) + Q_PROPERTY(int cacheBuffer READ cacheBuffer NOTIFY changedCacheBuffer) + +public: + TestObject(QObject *parent = 0) + : QObject(parent), mError(true), mAnimate(false), mInvalidHighlight(false) + , mCacheBuffer(0) {} + + bool error() const { return mError; } + void setError(bool err) { mError = err; emit changedError(); } + + bool animate() const { return mAnimate; } + void setAnimate(bool anim) { mAnimate = anim; emit changedAnim(); } + + bool invalidHighlight() const { return mInvalidHighlight; } + void setInvalidHighlight(bool invalid) { mInvalidHighlight = invalid; emit changedHl(); } + + int cacheBuffer() const { return mCacheBuffer; } + void setCacheBuffer(int buffer) { mCacheBuffer = buffer; emit changedCacheBuffer(); } + +signals: + void changedError(); + void changedAnim(); + void changedHl(); + void changedCacheBuffer(); + +public: + bool mError; + bool mAnimate; + bool mInvalidHighlight; + int mCacheBuffer; +}; + +tst_QQuickListView::tst_QQuickListView() +{ +} + +template +void tst_QQuickListView::items(const QUrl &source, bool forceLayout) +{ + QQuickView *canvas = createView(); + + T model; + model.addItem("Fred", "12345"); + model.addItem("John", "2345"); + model.addItem("Bob", "54321"); + + QQmlContext *ctxt = canvas->rootContext(); + ctxt->setContextProperty("testModel", &model); + + TestObject *testObject = new TestObject; + ctxt->setContextProperty("testObject", testObject); + + canvas->setSource(source); + qApp->processEvents(); + + QQuickListView *listview = findItem(canvas->rootObject(), "list"); + QTRY_VERIFY(listview != 0); + + QQuickItem *contentItem = listview->contentItem(); + QTRY_VERIFY(contentItem != 0); + + QMetaObject::invokeMethod(canvas->rootObject(), "checkProperties"); + QTRY_VERIFY(testObject->error() == false); + + QTRY_VERIFY(listview->highlightItem() != 0); + QTRY_COMPARE(listview->count(), model.count()); + QTRY_COMPARE(canvas->rootObject()->property("count").toInt(), model.count()); + QTRY_COMPARE(contentItem->childItems().count(), model.count()+1); // assumes all are visible, +1 for the (default) highlight item + + // current item should be first item + QTRY_COMPARE(listview->currentItem(), findItem(contentItem, "wrapper", 0)); + + for (int i = 0; i < model.count(); ++i) { + QQuickText *name = findItem(contentItem, "textName", i); + QTRY_VERIFY(name != 0); + QTRY_COMPARE(name->text(), model.name(i)); + QQuickText *number = findItem(contentItem, "textNumber", i); + QTRY_VERIFY(number != 0); + QTRY_COMPARE(number->text(), model.number(i)); + } + + // switch to other delegate + testObject->setAnimate(true); + QMetaObject::invokeMethod(canvas->rootObject(), "checkProperties"); + QTRY_VERIFY(testObject->error() == false); + QTRY_VERIFY(listview->currentItem()); + + // set invalid highlight + testObject->setInvalidHighlight(true); + QMetaObject::invokeMethod(canvas->rootObject(), "checkProperties"); + QTRY_VERIFY(testObject->error() == false); + QTRY_VERIFY(listview->currentItem()); + QTRY_VERIFY(listview->highlightItem() == 0); + + // back to normal highlight + testObject->setInvalidHighlight(false); + QMetaObject::invokeMethod(canvas->rootObject(), "checkProperties"); + QTRY_VERIFY(testObject->error() == false); + QTRY_VERIFY(listview->currentItem()); + QTRY_VERIFY(listview->highlightItem() != 0); + + // set an empty model and confirm that items are destroyed + T model2; + ctxt->setContextProperty("testModel", &model2); + + // Force a layout, necessary if ListView is completed before VisualDataModel. + if (forceLayout) + QCOMPARE(listview->property("count").toInt(), 0); + + int itemCount = findItems(contentItem, "wrapper").count(); + QTRY_VERIFY(itemCount == 0); + + QTRY_COMPARE(listview->highlightResizeSpeed(), 1000.0); + QTRY_COMPARE(listview->highlightMoveSpeed(), 1000.0); + + delete canvas; + delete testObject; +} + + +template +void tst_QQuickListView::changed(const QUrl &source, bool forceLayout) +{ + QQuickView *canvas = createView(); + + T model; + model.addItem("Fred", "12345"); + model.addItem("John", "2345"); + model.addItem("Bob", "54321"); + + QQmlContext *ctxt = canvas->rootContext(); + ctxt->setContextProperty("testModel", &model); + + TestObject *testObject = new TestObject; + ctxt->setContextProperty("testObject", testObject); + + canvas->setSource(source); + qApp->processEvents(); + + QQuickFlickable *listview = findItem(canvas->rootObject(), "list"); + QTRY_VERIFY(listview != 0); + + QQuickItem *contentItem = listview->contentItem(); + QTRY_VERIFY(contentItem != 0); + + // Force a layout, necessary if ListView is completed before VisualDataModel. + if (forceLayout) + QCOMPARE(listview->property("count").toInt(), model.count()); + + model.modifyItem(1, "Will", "9876"); + QQuickText *name = findItem(contentItem, "textName", 1); + QTRY_VERIFY(name != 0); + QTRY_COMPARE(name->text(), model.name(1)); + QQuickText *number = findItem(contentItem, "textNumber", 1); + QTRY_VERIFY(number != 0); + QTRY_COMPARE(number->text(), model.number(1)); + + delete canvas; + delete testObject; +} + +template +void tst_QQuickListView::inserted(const QUrl &source) +{ + QQuickView *canvas = createView(); + canvas->show(); + + T model; + model.addItem("Fred", "12345"); + model.addItem("John", "2345"); + model.addItem("Bob", "54321"); + + QQmlContext *ctxt = canvas->rootContext(); + ctxt->setContextProperty("testModel", &model); + + TestObject *testObject = new TestObject; + ctxt->setContextProperty("testObject", testObject); + + canvas->setSource(source); + qApp->processEvents(); + + QQuickListView *listview = findItem(canvas->rootObject(), "list"); + QTRY_VERIFY(listview != 0); + + QQuickItem *contentItem = listview->contentItem(); + QTRY_VERIFY(contentItem != 0); + + model.insertItem(1, "Will", "9876"); + + QTRY_COMPARE(canvas->rootObject()->property("count").toInt(), model.count()); + QTRY_COMPARE(contentItem->childItems().count(), model.count()+1); // assumes all are visible, +1 for the (default) highlight item + + QQuickText *name = findItem(contentItem, "textName", 1); + QTRY_VERIFY(name != 0); + QTRY_COMPARE(name->text(), model.name(1)); + QQuickText *number = findItem(contentItem, "textNumber", 1); + QTRY_VERIFY(number != 0); + QTRY_COMPARE(number->text(), model.number(1)); + + // Confirm items positioned correctly + for (int i = 0; i < model.count(); ++i) { + QQuickItem *item = findItem(contentItem, "wrapper", i); + QTRY_COMPARE(item->y(), i*20.0); + } + + model.insertItem(0, "Foo", "1111"); // zero index, and current item + + QTRY_COMPARE(canvas->rootObject()->property("count").toInt(), model.count()); + QTRY_COMPARE(contentItem->childItems().count(), model.count()+1); // assumes all are visible, +1 for the (default) highlight item + + name = findItem(contentItem, "textName", 0); + QTRY_VERIFY(name != 0); + QTRY_COMPARE(name->text(), model.name(0)); + number = findItem(contentItem, "textNumber", 0); + QTRY_VERIFY(number != 0); + QTRY_COMPARE(number->text(), model.number(0)); + + QTRY_COMPARE(listview->currentIndex(), 1); + + // Confirm items positioned correctly + for (int i = 0; i < model.count(); ++i) { + QQuickItem *item = findItem(contentItem, "wrapper", i); + QTRY_COMPARE(item->y(), i*20.0); + } + + for (int i = model.count(); i < 30; ++i) + model.insertItem(i, "Hello", QString::number(i)); + + listview->setContentY(80); + + // Insert item outside visible area + model.insertItem(1, "Hello", "1324"); + + QTRY_VERIFY(listview->contentY() == 80); + + // Confirm items positioned correctly + for (int i = 5; i < 5+15; ++i) { + QQuickItem *item = findItem(contentItem, "wrapper", i); + if (!item) qWarning() << "Item" << i << "not found"; + QTRY_VERIFY(item); + QTRY_COMPARE(item->y(), i*20.0 - 20.0); + } + +// QTRY_COMPARE(listview->contentItemHeight(), model.count() * 20.0); + + // QTBUG-19675 + model.clear(); + model.insertItem(0, "Hello", "1234"); + QTRY_COMPARE(canvas->rootObject()->property("count").toInt(), model.count()); + + QQuickItem *item = findItem(contentItem, "wrapper", 0); + QVERIFY(item); + QCOMPARE(item->y(), 0.); + QTRY_VERIFY(listview->contentY() == 0); + + delete canvas; + delete testObject; +} + +template +void tst_QQuickListView::inserted_more() +{ + QFETCH(qreal, contentY); + QFETCH(int, insertIndex); + QFETCH(int, insertCount); + QFETCH(qreal, itemsOffsetAfterMove); + + T model; + for (int i = 0; i < 30; i++) + model.addItem("Item" + QString::number(i), ""); + + QQuickView *canvas = createView(); + QQmlContext *ctxt = canvas->rootContext(); + ctxt->setContextProperty("testModel", &model); + + TestObject *testObject = new TestObject; + ctxt->setContextProperty("testObject", testObject); + + canvas->setSource(testFileUrl("listviewtest.qml")); + canvas->show(); + qApp->processEvents(); + + QQuickListView *listview = findItem(canvas->rootObject(), "list"); + QTRY_VERIFY(listview != 0); + QQuickItem *contentItem = listview->contentItem(); + QTRY_VERIFY(contentItem != 0); + + listview->setContentY(contentY); + QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false); + + QList > newData; + for (int i=0; iproperty("count").toInt(), model.count()); + + // check visibleItems.first() is in correct position + QQuickItem *item0 = findItem(contentItem, "wrapper", 0); + QVERIFY(item0); + QCOMPARE(item0->y(), itemsOffsetAfterMove); + + QList items = findItems(contentItem, "wrapper"); + int firstVisibleIndex = -1; + for (int i=0; iy() >= contentY) { + QQmlExpression e(qmlContext(items[i]), items[i], "index"); + firstVisibleIndex = e.evaluate().toInt(); + break; + } + } + QVERIFY2(firstVisibleIndex >= 0, QTest::toString(firstVisibleIndex)); + + // Confirm items positioned correctly and indexes correct + int itemCount = findItems(contentItem, "wrapper").count(); + QQuickText *name; + QQuickText *number; + for (int i = firstVisibleIndex; i < model.count() && i < itemCount; ++i) { + QQuickItem *item = findItem(contentItem, "wrapper", i); + QVERIFY2(item, QTest::toString(QString("Item %1 not found").arg(i))); + QTRY_COMPARE(item->y(), i*20.0 + itemsOffsetAfterMove); + name = findItem(contentItem, "textName", i); + QVERIFY(name != 0); + QTRY_COMPARE(name->text(), model.name(i)); + number = findItem(contentItem, "textNumber", i); + QVERIFY(number != 0); + QTRY_COMPARE(number->text(), model.number(i)); + } + + delete canvas; + delete testObject; +} + +void tst_QQuickListView::inserted_more_data() +{ + QTest::addColumn("contentY"); + QTest::addColumn("insertIndex"); + QTest::addColumn("insertCount"); + QTest::addColumn("itemsOffsetAfterMove"); + + QTest::newRow("add 1, before visible items") + << 80.0 // show 4-19 + << 3 << 1 + << -20.0; // insert above first visible i.e. 0 is at -20, first visible should not move + + QTest::newRow("add multiple, before visible") + << 80.0 // show 4-19 + << 3 << 3 + << -20.0 * 3; // again first visible should not move + + QTest::newRow("add 1, at start of visible, content at start") + << 0.0 + << 0 << 1 + << 0.0; + + QTest::newRow("add multiple, start of visible, content at start") + << 0.0 + << 0 << 3 + << 0.0; + + QTest::newRow("add 1, at start of visible, content not at start") + << 80.0 // show 4-19 + << 4 << 1 + << 0.0; + + QTest::newRow("add multiple, at start of visible, content not at start") + << 80.0 // show 4-19 + << 4 << 3 + << 0.0; + + + QTest::newRow("add 1, at end of visible, content at start") + << 0.0 + << 15 << 1 + << 0.0; + + QTest::newRow("add 1, at end of visible, content at start") + << 0.0 + << 15 << 3 + << 0.0; + + QTest::newRow("add 1, at end of visible, content not at start") + << 80.0 // show 4-19 + << 19 << 1 + << 0.0; + + QTest::newRow("add multiple, at end of visible, content not at start") + << 80.0 // show 4-19 + << 19 << 3 + << 0.0; + + + QTest::newRow("add 1, after visible, content at start") + << 0.0 + << 16 << 1 + << 0.0; + + QTest::newRow("add 1, after visible, content at start") + << 0.0 + << 16 << 3 + << 0.0; + + QTest::newRow("add 1, after visible, content not at start") + << 80.0 // show 4-19 + << 20 << 1 + << 0.0; + + QTest::newRow("add multiple, after visible, content not at start") + << 80.0 // show 4-19 + << 20 << 3 + << 0.0; +} + +void tst_QQuickListView::insertBeforeVisible() +{ + QFETCH(int, insertIndex); + QFETCH(int, insertCount); + QFETCH(int, cacheBuffer); + + QQuickText *name; + QQuickView *canvas = createView(); + + QmlListModel model; + for (int i = 0; i < 30; i++) + model.addItem("Item" + QString::number(i), ""); + + QQmlContext *ctxt = canvas->rootContext(); + ctxt->setContextProperty("testModel", &model); + + TestObject *testObject = new TestObject; + ctxt->setContextProperty("testObject", testObject); + + canvas->setSource(testFileUrl("listviewtest.qml")); + canvas->show(); + qApp->processEvents(); + + QQuickListView *listview = findItem(canvas->rootObject(), "list"); + QTRY_VERIFY(listview != 0); + QQuickItem *contentItem = listview->contentItem(); + QTRY_VERIFY(contentItem != 0); + + listview->setCacheBuffer(cacheBuffer); + QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false); + + // trigger a refill (not just setting contentY) so that the visibleItems grid is updated + int firstVisibleIndex = 20; // move to an index where the top item is not visible + listview->setContentY(firstVisibleIndex * 20.0); + listview->setCurrentIndex(firstVisibleIndex); + + qApp->processEvents(); + QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false); + QTRY_COMPARE(listview->currentIndex(), firstVisibleIndex); + QQuickItem *item = findItem(contentItem, "wrapper", firstVisibleIndex); + QVERIFY(item); + QCOMPARE(item->y(), listview->contentY()); + + QList > newData; + for (int i=0; iproperty("count").toInt(), model.count()); + + // now, moving to the top of the view should position the inserted items correctly + int itemsOffsetAfterMove = -(insertCount * 20); + listview->setCurrentIndex(0); + QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false); + QTRY_COMPARE(listview->currentIndex(), 0); + QTRY_COMPARE(listview->contentY(), 0.0 + itemsOffsetAfterMove); + + // Confirm items positioned correctly and indexes correct + int itemCount = findItems(contentItem, "wrapper").count(); + for (int i = 0; i < model.count() && i < itemCount; ++i) { + item = findItem(contentItem, "wrapper", i); + QVERIFY2(item, QTest::toString(QString("Item %1 not found").arg(i))); + QTRY_COMPARE(item->y(), i*20.0 + itemsOffsetAfterMove); + name = findItem(contentItem, "textName", i); + QVERIFY(name != 0); + QTRY_COMPARE(name->text(), model.name(i)); + } + + delete canvas; + delete testObject; +} + +void tst_QQuickListView::insertBeforeVisible_data() +{ + QTest::addColumn("insertIndex"); + QTest::addColumn("insertCount"); + QTest::addColumn("cacheBuffer"); + + QTest::newRow("insert 1 at 0, 0 buffer") << 0 << 1 << 0; + QTest::newRow("insert 1 at 0, 100 buffer") << 0 << 1 << 100; + QTest::newRow("insert 1 at 0, 500 buffer") << 0 << 1 << 500; + + QTest::newRow("insert 1 at 1, 0 buffer") << 1 << 1 << 0; + QTest::newRow("insert 1 at 1, 100 buffer") << 1 << 1 << 100; + QTest::newRow("insert 1 at 1, 500 buffer") << 1 << 1 << 500; + + QTest::newRow("insert multiple at 0, 0 buffer") << 0 << 3 << 0; + QTest::newRow("insert multiple at 0, 100 buffer") << 0 << 3 << 100; + QTest::newRow("insert multiple at 0, 500 buffer") << 0 << 3 << 500; + + QTest::newRow("insert multiple at 1, 0 buffer") << 1 << 3 << 0; + QTest::newRow("insert multiple at 1, 100 buffer") << 1 << 3 << 100; + QTest::newRow("insert multiple at 1, 500 buffer") << 1 << 3 << 500; +} + +template +void tst_QQuickListView::removed(const QUrl &source, bool /* animated */) +{ + QQuickView *canvas = createView(); + + T model; + for (int i = 0; i < 50; i++) + model.addItem("Item" + QString::number(i), ""); + + QQmlContext *ctxt = canvas->rootContext(); + ctxt->setContextProperty("testModel", &model); + + TestObject *testObject = new TestObject; + ctxt->setContextProperty("testObject", testObject); + + canvas->setSource(source); + canvas->show(); + qApp->processEvents(); + + QQuickListView *listview = findItem(canvas->rootObject(), "list"); + QTRY_VERIFY(listview != 0); + QQuickItem *contentItem = listview->contentItem(); + QTRY_VERIFY(contentItem != 0); + QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false); + + model.removeItem(1); + QTRY_COMPARE(canvas->rootObject()->property("count").toInt(), model.count()); + + QQuickText *name = findItem(contentItem, "textName", 1); + QTRY_VERIFY(name != 0); + QTRY_COMPARE(name->text(), model.name(1)); + QQuickText *number = findItem(contentItem, "textNumber", 1); + QTRY_VERIFY(number != 0); + QTRY_COMPARE(number->text(), model.number(1)); + + // Confirm items positioned correctly + int itemCount = findItems(contentItem, "wrapper").count(); + for (int i = 0; i < model.count() && i < itemCount; ++i) { + QQuickItem *item = findItem(contentItem, "wrapper", i); + if (!item) qWarning() << "Item" << i << "not found"; + QTRY_VERIFY(item); + QTRY_VERIFY(item->y() == i*20); + } + + // Remove first item (which is the current item); + model.removeItem(0); + QTRY_COMPARE(canvas->rootObject()->property("count").toInt(), model.count()); + + name = findItem(contentItem, "textName", 0); + QTRY_VERIFY(name != 0); + QTRY_COMPARE(name->text(), model.name(0)); + number = findItem(contentItem, "textNumber", 0); + QTRY_VERIFY(number != 0); + QTRY_COMPARE(number->text(), model.number(0)); + + // Confirm items positioned correctly + itemCount = findItems(contentItem, "wrapper").count(); + for (int i = 0; i < model.count() && i < itemCount; ++i) { + QQuickItem *item = findItem(contentItem, "wrapper", i); + if (!item) qWarning() << "Item" << i << "not found"; + QTRY_VERIFY(item); + QTRY_COMPARE(item->y(),i*20.0); + } + + // Remove items not visible + model.removeItem(18); + QTRY_COMPARE(canvas->rootObject()->property("count").toInt(), model.count()); + + // Confirm items positioned correctly + itemCount = findItems(contentItem, "wrapper").count(); + for (int i = 0; i < model.count() && i < itemCount; ++i) { + QQuickItem *item = findItem(contentItem, "wrapper", i); + if (!item) qWarning() << "Item" << i << "not found"; + QTRY_VERIFY(item); + QTRY_COMPARE(item->y(),i*20.0); + } + + // Remove items before visible + listview->setContentY(80); + listview->setCurrentIndex(10); + + model.removeItem(1); // post: top item will be at 20 + QTRY_COMPARE(canvas->rootObject()->property("count").toInt(), model.count()); + + // Confirm items positioned correctly + for (int i = 2; i < 18; ++i) { + QQuickItem *item = findItem(contentItem, "wrapper", i); + if (!item) qWarning() << "Item" << i << "not found"; + QTRY_VERIFY(item); + QTRY_COMPARE(item->y(),20+i*20.0); + } + + // Remove current index + QTRY_VERIFY(listview->currentIndex() == 9); + QQuickItem *oldCurrent = listview->currentItem(); + model.removeItem(9); + + QTRY_COMPARE(listview->currentIndex(), 9); + QTRY_VERIFY(listview->currentItem() != oldCurrent); + + listview->setContentY(20); // That's the top now + // let transitions settle. + QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false); + QTest::qWait(300); + + // Confirm items positioned correctly + itemCount = findItems(contentItem, "wrapper").count(); + for (int i = 0; i < model.count() && i < itemCount; ++i) { + QQuickItem *item = findItem(contentItem, "wrapper", i); + if (!item) qWarning() << "Item" << i << "not found"; + QTRY_VERIFY(item); + QTRY_COMPARE(item->y(),20+i*20.0); + } + + // remove current item beyond visible items. + listview->setCurrentIndex(20); + listview->setContentY(40); + QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false); + + model.removeItem(20); + QTRY_COMPARE(listview->currentIndex(), 20); + QTRY_VERIFY(listview->currentItem() != 0); + + // remove item before current, but visible + listview->setCurrentIndex(8); + QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false); + oldCurrent = listview->currentItem(); + model.removeItem(6); + + QTRY_COMPARE(listview->currentIndex(), 7); + QTRY_VERIFY(listview->currentItem() == oldCurrent); + + listview->setContentY(80); + QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false); + QTest::qWait(300); + + // remove all visible items + model.removeItems(1, 18); + QTRY_COMPARE(listview->count() , model.count()); + + // Confirm items positioned correctly + itemCount = findItems(contentItem, "wrapper").count(); + for (int i = 0; i < model.count() && i < itemCount-1; ++i) { + QQuickItem *item = findItem(contentItem, "wrapper", i+1); + if (!item) qWarning() << "Item" << i+1 << "not found"; + QTRY_VERIFY(item); + QTRY_COMPARE(item->y(),80+i*20.0); + } + + model.removeItems(1, 17); + QTRY_COMPARE(listview->count() , model.count()); + + model.removeItems(2, 1); + QTRY_COMPARE(listview->count() , model.count()); + + model.addItem("New", "1"); + QTRY_COMPARE(listview->count() , model.count()); + + QTRY_VERIFY(name = findItem(contentItem, "textName", model.count()-1)); + QCOMPARE(name->text(), QString("New")); + + // Add some more items so that we don't run out + model.clear(); + for (int i = 0; i < 50; i++) + model.addItem("Item" + QString::number(i), ""); + + // QTBUG-QTBUG-20575 + listview->setCurrentIndex(0); + listview->setContentY(30); + model.removeItem(0); + QTRY_VERIFY(name = findItem(contentItem, "textName", 0)); + + // QTBUG-19198 move to end and remove all visible items one at a time. + listview->positionViewAtEnd(); + for (int i = 0; i < 18; ++i) + model.removeItems(model.count() - 1, 1); + QTRY_VERIFY(findItems(contentItem, "wrapper").count() > 16); + + delete canvas; + delete testObject; +} + +template +void tst_QQuickListView::removed_more(const QUrl &source) +{ + QFETCH(qreal, contentY); + QFETCH(int, removeIndex); + QFETCH(int, removeCount); + QFETCH(qreal, itemsOffsetAfterMove); + + QQuickText *name; + QQuickText *number; + QQuickView *canvas = createView(); + + T model; + for (int i = 0; i < 30; i++) + model.addItem("Item" + QString::number(i), ""); + + QQmlContext *ctxt = canvas->rootContext(); + ctxt->setContextProperty("testModel", &model); + + TestObject *testObject = new TestObject; + ctxt->setContextProperty("testObject", testObject); + + canvas->setSource(source); + canvas->show(); + qApp->processEvents(); + + QQuickListView *listview = findItem(canvas->rootObject(), "list"); + QTRY_VERIFY(listview != 0); + QQuickItem *contentItem = listview->contentItem(); + QTRY_VERIFY(contentItem != 0); + + listview->setContentY(contentY); + QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false); + + // wait for refill (after refill, items above the firstVisibleIndex-1 should not be rendered) + int firstVisibleIndex = contentY / 20; + if (firstVisibleIndex - 2 >= 0) + QTRY_VERIFY(!findItem(contentItem, "textName", firstVisibleIndex - 2)); + + model.removeItems(removeIndex, removeCount); + QTRY_COMPARE(listview->property("count").toInt(), model.count()); + + // check visibleItems.first() is in correct position + QQuickItem *item0 = findItem(contentItem, "wrapper", 0); + QVERIFY(item0); + QCOMPARE(item0->y(), itemsOffsetAfterMove); + + QList items = findItems(contentItem, "wrapper"); + for (int i=0; iy() >= contentY) { + QQmlExpression e(qmlContext(items[i]), items[i], "index"); + firstVisibleIndex = e.evaluate().toInt(); + break; + } + } + QVERIFY2(firstVisibleIndex >= 0, QTest::toString(firstVisibleIndex)); + + // Confirm items positioned correctly and indexes correct + int itemCount = findItems(contentItem, "wrapper").count(); + for (int i = firstVisibleIndex; i < model.count() && i < itemCount; ++i) { + QQuickItem *item = findItem(contentItem, "wrapper", i); + QVERIFY2(item, QTest::toString(QString("Item %1 not found").arg(i))); + QTRY_COMPARE(item->y(), i*20.0 + itemsOffsetAfterMove); + name = findItem(contentItem, "textName", i); + QVERIFY(name != 0); + QTRY_COMPARE(name->text(), model.name(i)); + number = findItem(contentItem, "textNumber", i); + QVERIFY(number != 0); + QTRY_COMPARE(number->text(), model.number(i)); + } + + delete canvas; + delete testObject; +} + +void tst_QQuickListView::removed_more_data() +{ + QTest::addColumn("contentY"); + QTest::addColumn("removeIndex"); + QTest::addColumn("removeCount"); + QTest::addColumn("itemsOffsetAfterMove"); + + QTest::newRow("remove 1, before visible items") + << 80.0 // show 4-19 + << 3 << 1 + << 20.0; // visible items slide down by 1 item so that first visible does not move + + QTest::newRow("remove multiple, all before visible items") + << 80.0 + << 1 << 3 + << 20.0 * 3; + + QTest::newRow("remove multiple, all before visible items, remove item 0") + << 80.0 + << 0 << 4 + << 20.0 * 4; + + // remove 1,2,3 before the visible pos, 0 moves down to just before the visible pos, + // items 4,5 are removed from view, item 6 slides up to original pos of item 4 (80px) + QTest::newRow("remove multiple, mix of items from before and within visible items") + << 80.0 + << 1 << 5 + << 20.0 * 3; // adjust for the 3 items removed before the visible + + QTest::newRow("remove multiple, mix of items from before and within visible items, remove item 0") + << 80.0 + << 0 << 6 + << 20.0 * 4; // adjust for the 3 items removed before the visible + + + QTest::newRow("remove 1, from start of visible, content at start") + << 0.0 + << 0 << 1 + << 0.0; + + QTest::newRow("remove multiple, from start of visible, content at start") + << 0.0 + << 0 << 3 + << 0.0; + + QTest::newRow("remove 1, from start of visible, content not at start") + << 80.0 // show 4-19 + << 4 << 1 + << 0.0; + + QTest::newRow("remove multiple, from start of visible, content not at start") + << 80.0 // show 4-19 + << 4 << 3 + << 0.0; + + + QTest::newRow("remove 1, from middle of visible, content at start") + << 0.0 + << 10 << 1 + << 0.0; + + QTest::newRow("remove multiple, from middle of visible, content at start") + << 0.0 + << 10 << 5 + << 0.0; + + QTest::newRow("remove 1, from middle of visible, content not at start") + << 80.0 // show 4-19 + << 10 << 1 + << 0.0; + + QTest::newRow("remove multiple, from middle of visible, content not at start") + << 80.0 // show 4-19 + << 10 << 5 + << 0.0; + + + QTest::newRow("remove 1, after visible, content at start") + << 0.0 + << 16 << 1 + << 0.0; + + QTest::newRow("remove multiple, after visible, content at start") + << 0.0 + << 16 << 5 + << 0.0; + + QTest::newRow("remove 1, after visible, content not at middle") + << 80.0 // show 4-19 + << 16+4 << 1 + << 0.0; + + QTest::newRow("remove multiple, after visible, content not at start") + << 80.0 // show 4-19 + << 16+4 << 5 + << 0.0; + + QTest::newRow("remove multiple, mix of items from within and after visible items") + << 80.0 + << 18 << 5 + << 0.0; +} + +template +void tst_QQuickListView::clear(const QUrl &source) +{ + QQuickView *canvas = createView(); + + T model; + for (int i = 0; i < 30; i++) + model.addItem("Item" + QString::number(i), ""); + + QQmlContext *ctxt = canvas->rootContext(); + ctxt->setContextProperty("testModel", &model); + + TestObject *testObject = new TestObject; + ctxt->setContextProperty("testObject", testObject); + + canvas->setSource(source); + canvas->show(); + qApp->processEvents(); + + QQuickListView *listview = findItem(canvas->rootObject(), "list"); + QTRY_VERIFY(listview != 0); + QQuickItem *contentItem = listview->contentItem(); + QTRY_VERIFY(contentItem != 0); + QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false); + + model.clear(); + + QTRY_VERIFY(listview->count() == 0); + QTRY_VERIFY(listview->currentItem() == 0); + QTRY_VERIFY(listview->contentY() == 0); + QVERIFY(listview->currentIndex() == -1); + + // confirm sanity when adding an item to cleared list + model.addItem("New", "1"); + QTRY_VERIFY(listview->count() == 1); + QVERIFY(listview->currentItem() != 0); + QVERIFY(listview->currentIndex() == 0); + + delete canvas; + delete testObject; +} + +template +void tst_QQuickListView::moved(const QUrl &source) +{ + QFETCH(qreal, contentY); + QFETCH(int, from); + QFETCH(int, to); + QFETCH(int, count); + QFETCH(qreal, itemsOffsetAfterMove); + + QQuickText *name; + QQuickText *number; + QQuickView *canvas = createView(); + + T model; + for (int i = 0; i < 30; i++) + model.addItem("Item" + QString::number(i), ""); + + QQmlContext *ctxt = canvas->rootContext(); + ctxt->setContextProperty("testModel", &model); + + TestObject *testObject = new TestObject; + ctxt->setContextProperty("testObject", testObject); + + canvas->setSource(source); + canvas->show(); + qApp->processEvents(); + + QQuickListView *listview = findItem(canvas->rootObject(), "list"); + QTRY_VERIFY(listview != 0); + QQuickItem *contentItem = listview->contentItem(); + QTRY_VERIFY(contentItem != 0); + QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false); + + QQuickItem *currentItem = listview->currentItem(); + QTRY_VERIFY(currentItem != 0); + + if (contentY != 0) { + listview->setContentY(contentY); + QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false); + } + + model.moveItems(from, to, count); + QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false); + + QList items = findItems(contentItem, "wrapper"); + int firstVisibleIndex = -1; + for (int i=0; iy() >= contentY) { + QQmlExpression e(qmlContext(items[i]), items[i], "index"); + firstVisibleIndex = e.evaluate().toInt(); + break; + } + } + QVERIFY2(firstVisibleIndex >= 0, QTest::toString(firstVisibleIndex)); + + // Confirm items positioned correctly and indexes correct + int itemCount = findItems(contentItem, "wrapper").count(); + for (int i = firstVisibleIndex; i < model.count() && i < itemCount; ++i) { + if (i >= firstVisibleIndex + 16) // index has moved out of view + continue; + QQuickItem *item = findItem(contentItem, "wrapper", i); + QVERIFY2(item, QTest::toString(QString("Item %1 not found").arg(i))); + QTRY_COMPARE(item->y(), i*20.0 + itemsOffsetAfterMove); + name = findItem(contentItem, "textName", i); + QVERIFY(name != 0); + QTRY_COMPARE(name->text(), model.name(i)); + number = findItem(contentItem, "textNumber", i); + QVERIFY(number != 0); + QTRY_COMPARE(number->text(), model.number(i)); + + // current index should have been updated + if (item == currentItem) + QTRY_COMPARE(listview->currentIndex(), i); + } + + delete canvas; + delete testObject; +} + +void tst_QQuickListView::moved_data() +{ + QTest::addColumn("contentY"); + QTest::addColumn("from"); + QTest::addColumn("to"); + QTest::addColumn("count"); + QTest::addColumn("itemsOffsetAfterMove"); + + // model starts with 30 items, each 20px high, in area 320px high + // 16 items should be visible at a time + // itemsOffsetAfterMove should be > 0 whenever items above the visible pos have moved + + QTest::newRow("move 1 forwards, within visible items") + << 0.0 + << 1 << 4 << 1 + << 0.0; + + QTest::newRow("move 1 forwards, from non-visible -> visible") + << 80.0 // show 4-19 + << 1 << 18 << 1 + << 20.0; // removed 1 item above the first visible, so item 0 should drop down by 1 to minimize movement + + QTest::newRow("move 1 forwards, from non-visible -> visible (move first item)") + << 80.0 // show 4-19 + << 0 << 4 << 1 + << 20.0; // first item has moved to below item4, everything drops down by size of 1 item + + QTest::newRow("move 1 forwards, from visible -> non-visible") + << 0.0 + << 1 << 16 << 1 + << 0.0; + + QTest::newRow("move 1 forwards, from visible -> non-visible (move first item)") + << 0.0 + << 0 << 16 << 1 + << 0.0; + + + QTest::newRow("move 1 backwards, within visible items") + << 0.0 + << 4 << 1 << 1 + << 0.0; + + QTest::newRow("move 1 backwards, within visible items (to first index)") + << 0.0 + << 4 << 0 << 1 + << 0.0; + + QTest::newRow("move 1 backwards, from non-visible -> visible") + << 0.0 + << 20 << 4 << 1 + << 0.0; + + QTest::newRow("move 1 backwards, from non-visible -> visible (move last item)") + << 0.0 + << 29 << 15 << 1 + << 0.0; + + QTest::newRow("move 1 backwards, from visible -> non-visible") + << 80.0 // show 4-19 + << 16 << 1 << 1 + << -20.0; // to minimize movement, item 0 moves to -20, and other items do not move + + QTest::newRow("move 1 backwards, from visible -> non-visible (move first item)") + << 80.0 // show 4-19 + << 16 << 0 << 1 + << -20.0; // to minimize movement, item 16 (now at 0) moves to -20, and other items do not move + + + QTest::newRow("move multiple forwards, within visible items") + << 0.0 + << 0 << 5 << 3 + << 0.0; + + QTest::newRow("move multiple forwards, before visible items") + << 140.0 // show 7-22 + << 4 << 5 << 3 // 4,5,6 move to below 7 + << 20.0 * 3; // 4,5,6 moved down + + QTest::newRow("move multiple forwards, from non-visible -> visible") + << 80.0 // show 4-19 + << 1 << 5 << 3 + << 20.0 * 3; // moving 3 from above the content y should adjust y positions accordingly + + QTest::newRow("move multiple forwards, from non-visible -> visible (move first item)") + << 80.0 // show 4-19 + << 0 << 5 << 3 + << 20.0 * 3; // moving 3 from above the content y should adjust y positions accordingly + + QTest::newRow("move multiple forwards, mix of non-visible/visible") + << 40.0 + << 1 << 16 << 2 + << 20.0; // item 1,2 are removed, item 3 is now first visible + + QTest::newRow("move multiple forwards, to bottom of view") + << 0.0 + << 5 << 13 << 3 + << 0.0; + + QTest::newRow("move multiple forwards, to bottom of view, first->last") + << 0.0 + << 0 << 13 << 3 + << 0.0; + + QTest::newRow("move multiple forwards, to bottom of view, content y not 0") + << 80.0 + << 5+4 << 13+4 << 3 + << 0.0; + + QTest::newRow("move multiple forwards, from visible -> non-visible") + << 0.0 + << 1 << 16 << 3 + << 0.0; + + QTest::newRow("move multiple forwards, from visible -> non-visible (move first item)") + << 0.0 + << 0 << 16 << 3 + << 0.0; + + + QTest::newRow("move multiple backwards, within visible items") + << 0.0 + << 4 << 1 << 3 + << 0.0; + + QTest::newRow("move multiple backwards, within visible items (move first item)") + << 0.0 + << 10 << 0 << 3 + << 0.0; + + QTest::newRow("move multiple backwards, from non-visible -> visible") + << 0.0 + << 20 << 4 << 3 + << 0.0; + + QTest::newRow("move multiple backwards, from non-visible -> visible (move last item)") + << 0.0 + << 27 << 10 << 3 + << 0.0; + + QTest::newRow("move multiple backwards, from visible -> non-visible") + << 80.0 // show 4-19 + << 16 << 1 << 3 + << -20.0 * 3; // to minimize movement, 0 moves by -60, and other items do not move + + QTest::newRow("move multiple backwards, from visible -> non-visible (move first item)") + << 80.0 // show 4-19 + << 16 << 0 << 3 + << -20.0 * 3; // to minimize movement, 16,17,18 move to above item 0, and other items do not move +} + +void tst_QQuickListView::multipleChanges() +{ + QFETCH(int, startCount); + QFETCH(QList, changes); + QFETCH(int, newCount); + QFETCH(int, newCurrentIndex); + + QQuickView *canvas = createView(); + + QmlListModel model; + for (int i = 0; i < startCount; i++) + model.addItem("Item" + QString::number(i), ""); + + QQmlContext *ctxt = canvas->rootContext(); + ctxt->setContextProperty("testModel", &model); + + TestObject *testObject = new TestObject; + ctxt->setContextProperty("testObject", testObject); + + canvas->setSource(testFileUrl("listviewtest.qml")); + canvas->show(); + qApp->processEvents(); + + QQuickListView *listview = findItem(canvas->rootObject(), "list"); + QTRY_VERIFY(listview != 0); + QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false); + + for (int i=0; i > items; + for (int j=changes[i].index; jpolishScheduled, false); + break; + } + case ListChange::Removed: + model.removeItems(changes[i].index, changes[i].count); + QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false); + break; + case ListChange::Moved: + model.moveItems(changes[i].index, changes[i].to, changes[i].count); + QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false); + break; + case ListChange::SetCurrent: + listview->setCurrentIndex(changes[i].index); + QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false); + break; + case ListChange::SetContentY: + listview->setContentY(changes[i].pos); + QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false); + break; + } + } + + QTRY_COMPARE(listview->count(), newCount); + QCOMPARE(listview->count(), model.count()); + QTRY_COMPARE(listview->currentIndex(), newCurrentIndex); + + QQuickText *name; + QQuickText *number; + QQuickItem *contentItem = listview->contentItem(); + QTRY_VERIFY(contentItem != 0); + int itemCount = findItems(contentItem, "wrapper").count(); + for (int i=0; i < model.count() && i < itemCount; ++i) { + QQuickItem *item = findItem(contentItem, "wrapper", i); + QVERIFY2(item, QTest::toString(QString("Item %1 not found").arg(i))); + name = findItem(contentItem, "textName", i); + QVERIFY(name != 0); + QTRY_COMPARE(name->text(), model.name(i)); + number = findItem(contentItem, "textNumber", i); + QVERIFY(number != 0); + QTRY_COMPARE(number->text(), model.number(i)); + } + + delete testObject; + delete canvas; +} + +void tst_QQuickListView::multipleChanges_data() +{ + QTest::addColumn("startCount"); + QTest::addColumn >("changes"); + QTest::addColumn("newCount"); + QTest::addColumn("newCurrentIndex"); + + QList changes; + + for (int i=1; i<30; i++) + changes << ListChange::remove(0); + QTest::newRow("remove all but 1, first->last") << 30 << changes << 1 << 0; + + changes << ListChange::remove(0); + QTest::newRow("remove all") << 30 << changes << 0 << -1; + + changes.clear(); + changes << ListChange::setCurrent(29); + for (int i=29; i>0; i--) + changes << ListChange::remove(i); + QTest::newRow("remove last (current) -> first") << 30 << changes << 1 << 0; + + QTest::newRow("remove then insert at 0") << 10 << (QList() + << ListChange::remove(0, 1) + << ListChange::insert(0, 1) + ) << 10 << 1; + + QTest::newRow("remove then insert at non-zero index") << 10 << (QList() + << ListChange::setCurrent(2) + << ListChange::remove(2, 1) + << ListChange::insert(2, 1) + ) << 10 << 3; + + QTest::newRow("remove current then insert below it") << 10 << (QList() + << ListChange::setCurrent(1) + << ListChange::remove(1, 3) + << ListChange::insert(2, 2) + ) << 9 << 1; + + QTest::newRow("remove current index then move it down") << 10 << (QList() + << ListChange::setCurrent(2) + << ListChange::remove(1, 3) + << ListChange::move(1, 5, 1) + ) << 7 << 5; + + QTest::newRow("remove current index then move it up") << 10 << (QList() + << ListChange::setCurrent(5) + << ListChange::remove(4, 3) + << ListChange::move(4, 1, 1) + ) << 7 << 1; + + + QTest::newRow("insert multiple times") << 0 << (QList() + << ListChange::insert(0, 2) + << ListChange::insert(0, 4) + << ListChange::insert(0, 6) + ) << 12 << 10; + + QTest::newRow("insert multiple times with current index changes") << 0 << (QList() + << ListChange::insert(0, 2) + << ListChange::insert(0, 4) + << ListChange::insert(0, 6) + << ListChange::setCurrent(3) + << ListChange::insert(3, 2) + ) << 14 << 5; + + QTest::newRow("insert and remove all") << 0 << (QList() + << ListChange::insert(0, 30) + << ListChange::remove(0, 30) + ) << 0 << -1; + + QTest::newRow("insert and remove current") << 30 << (QList() + << ListChange::insert(1) + << ListChange::setCurrent(1) + << ListChange::remove(1) + ) << 30 << 1; + + QTest::newRow("insert before 0, then remove cross section of new and old items") << 10 << (QList() + << ListChange::insert(0, 10) + << ListChange::remove(5, 10) + ) << 10 << 5; + + QTest::newRow("insert multiple, then move new items to end") << 10 << (QList() + << ListChange::insert(0, 3) + << ListChange::move(0, 10, 3) + ) << 13 << 0; + + QTest::newRow("insert multiple, then move new and some old items to end") << 10 << (QList() + << ListChange::insert(0, 3) + << ListChange::move(0, 8, 5) + ) << 13 << 11; + + QTest::newRow("insert multiple at end, then move new and some old items to start") << 10 << (QList() + << ListChange::setCurrent(9) + << ListChange::insert(10, 3) + << ListChange::move(8, 0, 5) + ) << 13 << 1; + + + QTest::newRow("move back and forth to same index") << 10 << (QList() + << ListChange::setCurrent(1) + << ListChange::move(1, 2, 2) + << ListChange::move(2, 1, 2) + ) << 10 << 1; + + QTest::newRow("move forwards then back") << 10 << (QList() + << ListChange::setCurrent(2) + << ListChange::move(1, 2, 3) + << ListChange::move(3, 0, 5) + ) << 10 << 0; + + QTest::newRow("move current, then remove it") << 10 << (QList() + << ListChange::setCurrent(5) + << ListChange::move(5, 0, 1) + << ListChange::remove(0) + ) << 9 << 0; + + QTest::newRow("move current, then insert before it") << 10 << (QList() + << ListChange::setCurrent(5) + << ListChange::move(5, 0, 1) + << ListChange::insert(0) + ) << 11 << 1; + + QTest::newRow("move multiple, then remove them") << 10 << (QList() + << ListChange::setCurrent(1) + << ListChange::move(5, 1, 3) + << ListChange::remove(1, 3) + ) << 7 << 1; + + QTest::newRow("move multiple, then insert before them") << 10 << (QList() + << ListChange::setCurrent(5) + << ListChange::move(5, 1, 3) + << ListChange::insert(1, 5) + ) << 15 << 6; + + QTest::newRow("move multiple, then insert after them") << 10 << (QList() + << ListChange::setCurrent(3) + << ListChange::move(0, 1, 2) + << ListChange::insert(3, 5) + ) << 15 << 8; + + + QTest::newRow("clear current") << 0 << (QList() + << ListChange::insert(0, 5) + << ListChange::setCurrent(-1) + << ListChange::remove(0, 5) + << ListChange::insert(0, 5) + ) << 5 << -1; +} + +void tst_QQuickListView::swapWithFirstItem() +{ + QQuickView *canvas = createView(); + + QmlListModel model; + for (int i = 0; i < 30; i++) + model.addItem("Item" + QString::number(i), ""); + + QQmlContext *ctxt = canvas->rootContext(); + ctxt->setContextProperty("testModel", &model); + + TestObject *testObject = new TestObject; + ctxt->setContextProperty("testObject", testObject); + + canvas->setSource(testFileUrl("listviewtest.qml")); + canvas->show(); + qApp->processEvents(); + + QQuickListView *listview = findItem(canvas->rootObject(), "list"); + QTRY_VERIFY(listview != 0); + QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false); + + // ensure content position is stable + listview->setContentY(0); + model.moveItem(1, 0); + QTRY_VERIFY(listview->contentY() == 0); + + delete testObject; + delete canvas; +} + +void tst_QQuickListView::enforceRange() +{ + QQuickView *canvas = createView(); + + QmlListModel model; + for (int i = 0; i < 30; i++) + model.addItem("Item" + QString::number(i), ""); + + QQmlContext *ctxt = canvas->rootContext(); + ctxt->setContextProperty("testModel", &model); + + canvas->setSource(testFileUrl("listview-enforcerange.qml")); + canvas->show(); + qApp->processEvents(); + + QQuickListView *listview = findItem(canvas->rootObject(), "list"); + QTRY_VERIFY(listview != 0); + + QTRY_COMPARE(listview->preferredHighlightBegin(), 100.0); + QTRY_COMPARE(listview->preferredHighlightEnd(), 100.0); + QTRY_COMPARE(listview->highlightRangeMode(), QQuickListView::StrictlyEnforceRange); + QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false); + + QQuickItem *contentItem = listview->contentItem(); + QTRY_VERIFY(contentItem != 0); + + // view should be positioned at the top of the range. + QQuickItem *item = findItem(contentItem, "wrapper", 0); + QTRY_VERIFY(item); + QTRY_COMPARE(listview->contentY(), -100.0); + + QQuickText *name = findItem(contentItem, "textName", 0); + QTRY_VERIFY(name != 0); + QTRY_COMPARE(name->text(), model.name(0)); + QQuickText *number = findItem(contentItem, "textNumber", 0); + QTRY_VERIFY(number != 0); + QTRY_COMPARE(number->text(), model.number(0)); + + // Check currentIndex is updated when contentItem moves + listview->setContentY(20); + + QTRY_COMPARE(listview->currentIndex(), 6); + + // change model + QmlListModel model2; + for (int i = 0; i < 5; i++) + model2.addItem("Item" + QString::number(i), ""); + + ctxt->setContextProperty("testModel", &model2); + QCOMPARE(listview->count(), 5); + + delete canvas; +} + +void tst_QQuickListView::enforceRange_withoutHighlight() +{ + // QTBUG-20287 + // If no highlight is set but StrictlyEnforceRange is used, the content should still move + // to the correct position (i.e. to the next/previous item, not next/previous section) + // when moving up/down via incrementCurrentIndex() and decrementCurrentIndex() + + QQuickView *canvas = createView(); + + QmlListModel model; + model.addItem("Item 0", "a"); + model.addItem("Item 1", "b"); + model.addItem("Item 2", "b"); + model.addItem("Item 3", "c"); + + QQmlContext *ctxt = canvas->rootContext(); + ctxt->setContextProperty("testModel", &model); + + canvas->setSource(testFileUrl("listview-enforcerange-nohighlight.qml")); + canvas->show(); + qApp->processEvents(); + + QQuickListView *listview = findItem(canvas->rootObject(), "list"); + QTRY_VERIFY(listview != 0); + QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false); + + qreal expectedPos = -100.0; + + expectedPos += 10.0; // scroll past 1st section's delegate (10px height) + QTRY_COMPARE(listview->contentY(), expectedPos); + + expectedPos += 20 + 10; // scroll past 1st section and section delegate of 2nd section + QTest::keyClick(canvas, Qt::Key_Down); + + QTRY_COMPARE(listview->contentY(), expectedPos); + + expectedPos += 20; // scroll past 1st item of 2nd section + QTest::keyClick(canvas, Qt::Key_Down); + QTRY_COMPARE(listview->contentY(), expectedPos); + + expectedPos += 20 + 10; // scroll past 2nd item of 2nd section and section delegate of 3rd section + QTest::keyClick(canvas, Qt::Key_Down); + QTRY_COMPARE(listview->contentY(), expectedPos); + + delete canvas; +} + +void tst_QQuickListView::spacing() +{ + QQuickView *canvas = createView(); + + QmlListModel model; + for (int i = 0; i < 30; i++) + model.addItem("Item" + QString::number(i), ""); + + QQmlContext *ctxt = canvas->rootContext(); + ctxt->setContextProperty("testModel", &model); + + TestObject *testObject = new TestObject; + ctxt->setContextProperty("testObject", testObject); + + canvas->setSource(testFileUrl("listviewtest.qml")); + canvas->show(); + qApp->processEvents(); + + QQuickListView *listview = findItem(canvas->rootObject(), "list"); + QTRY_VERIFY(listview != 0); + + QQuickItem *contentItem = listview->contentItem(); + QTRY_VERIFY(contentItem != 0); + QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false); + + // Confirm items positioned correctly + int itemCount = findItems(contentItem, "wrapper").count(); + for (int i = 0; i < model.count() && i < itemCount; ++i) { + QQuickItem *item = findItem(contentItem, "wrapper", i); + if (!item) qWarning() << "Item" << i << "not found"; + QTRY_VERIFY(item); + QTRY_VERIFY(item->y() == i*20); + } + + listview->setSpacing(10); + QTRY_VERIFY(listview->spacing() == 10); + + // Confirm items positioned correctly + QTRY_VERIFY(findItems(contentItem, "wrapper").count() == 11); + for (int i = 0; i < 11; ++i) { + QQuickItem *item = findItem(contentItem, "wrapper", i); + if (!item) qWarning() << "Item" << i << "not found"; + QTRY_VERIFY(item); + QTRY_VERIFY(item->y() == i*30); + } + + listview->setSpacing(0); + + // Confirm items positioned correctly + QTRY_VERIFY(findItems(contentItem, "wrapper").count() >= 16); + for (int i = 0; i < 16; ++i) { + QQuickItem *item = findItem(contentItem, "wrapper", i); + if (!item) qWarning() << "Item" << i << "not found"; + QTRY_VERIFY(item); + QTRY_COMPARE(item->y(), i*20.0); + } + + delete canvas; + delete testObject; +} + +template +void tst_QQuickListView::sections(const QUrl &source) +{ + QQuickView *canvas = createView(); + + T model; + for (int i = 0; i < 30; i++) + model.addItem("Item" + QString::number(i), QString::number(i/5)); + + QQmlContext *ctxt = canvas->rootContext(); + ctxt->setContextProperty("testModel", &model); + + canvas->setSource(source); + canvas->show(); + qApp->processEvents(); + + QQuickListView *listview = findItem(canvas->rootObject(), "list"); + QTRY_VERIFY(listview != 0); + + QQuickItem *contentItem = listview->contentItem(); + QTRY_VERIFY(contentItem != 0); + + QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false); + + // Confirm items positioned correctly + int itemCount = findItems(contentItem, "wrapper").count(); + for (int i = 0; i < model.count() && i < itemCount; ++i) { + QQuickItem *item = findItem(contentItem, "wrapper", i); + QTRY_VERIFY(item); + QTRY_COMPARE(item->y(), qreal(i*20 + ((i+4)/5) * 20)); + QQuickText *next = findItem(item, "nextSection"); + QCOMPARE(next->text().toInt(), (i+1)/5); + } + + QSignalSpy currentSectionChangedSpy(listview, SIGNAL(currentSectionChanged())); + + // Remove section boundary + model.removeItem(5); + QTRY_COMPARE(listview->count(), model.count()); + + // New section header created + QQuickItem *item = findItem(contentItem, "wrapper", 5); + QTRY_VERIFY(item); + QTRY_COMPARE(item->height(), 40.0); + + model.insertItem(3, "New Item", "0"); + QTRY_COMPARE(listview->count(), model.count()); + + // Section header moved + item = findItem(contentItem, "wrapper", 5); + QTRY_VERIFY(item); + QTRY_COMPARE(item->height(), 20.0); + + item = findItem(contentItem, "wrapper", 6); + QTRY_VERIFY(item); + QTRY_COMPARE(item->height(), 40.0); + + // insert item which will become a section header + model.insertItem(6, "Replace header", "1"); + QTRY_COMPARE(listview->count(), model.count()); + + item = findItem(contentItem, "wrapper", 6); + QTRY_VERIFY(item); + QTRY_COMPARE(item->height(), 40.0); + + item = findItem(contentItem, "wrapper", 7); + QTRY_VERIFY(item); + QTRY_COMPARE(item->height(), 20.0); + + QTRY_COMPARE(listview->currentSection(), QString("0")); + + listview->setContentY(140); + QTRY_COMPARE(listview->currentSection(), QString("1")); + + QTRY_COMPARE(currentSectionChangedSpy.count(), 1); + + listview->setContentY(20); + QTRY_COMPARE(listview->currentSection(), QString("0")); + + QTRY_COMPARE(currentSectionChangedSpy.count(), 2); + + item = findItem(contentItem, "wrapper", 1); + QTRY_VERIFY(item); + QTRY_COMPARE(item->height(), 20.0); + + // check that headers change when item changes + listview->setContentY(0); + QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false); + model.modifyItem(0, "changed", "2"); + QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false); + + item = findItem(contentItem, "wrapper", 1); + QTRY_VERIFY(item); + QTRY_COMPARE(item->height(), 40.0); + + delete canvas; +} + +void tst_QQuickListView::sectionsDelegate() +{ + QSKIP("QTBUG-24395"); + + QQuickView *canvas = createView(); + + QmlListModel model; + for (int i = 0; i < 30; i++) + model.addItem("Item" + QString::number(i), QString::number(i/5)); + + QQmlContext *ctxt = canvas->rootContext(); + ctxt->setContextProperty("testModel", &model); + + canvas->setSource(testFileUrl("listview-sections_delegate.qml")); + canvas->show(); + qApp->processEvents(); + + QQuickListView *listview = findItem(canvas->rootObject(), "list"); + QTRY_VERIFY(listview != 0); + + QQuickItem *contentItem = listview->contentItem(); + QTRY_VERIFY(contentItem != 0); + + QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false); + + // Confirm items positioned correctly + int itemCount = findItems(contentItem, "wrapper").count(); + for (int i = 0; i < model.count() && i < itemCount; ++i) { + QQuickItem *item = findItem(contentItem, "wrapper", i); + QTRY_VERIFY(item); + QTRY_COMPARE(item->y(), qreal(i*20 + ((i+5)/5) * 20)); + QQuickText *next = findItem(item, "nextSection"); + QCOMPARE(next->text().toInt(), (i+1)/5); + } + + for (int i = 0; i < 3; ++i) { + QQuickItem *item = findItem(contentItem, "sect_" + QString::number(i)); + QVERIFY(item); + QTRY_COMPARE(item->y(), qreal(i*20*6)); + } + + // ensure section header is maintained in view + listview->setCurrentIndex(20); + QTRY_VERIFY(listview->contentY() >= 200.0); + listview->setCurrentIndex(0); + QTRY_COMPARE(listview->contentY(), 0.0); + + // change section + model.modifyItem(0, "One", "aaa"); + model.modifyItem(1, "Two", "aaa"); + model.modifyItem(2, "Three", "aaa"); + model.modifyItem(3, "Four", "aaa"); + model.modifyItem(4, "Five", "aaa"); + QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false); + + for (int i = 0; i < 3; ++i) { + QQuickItem *item = findItem(contentItem, + "sect_" + (i == 0 ? QString("aaa") : QString::number(i))); + QVERIFY(item); + QTRY_COMPARE(item->y(), qreal(i*20*6)); + } + + // remove section boundary + model.removeItem(5); + QTRY_COMPARE(listview->count(), model.count()); + for (int i = 0; i < 3; ++i) { + QQuickItem *item = findItem(contentItem, + "sect_" + (i == 0 ? QString("aaa") : QString::number(i))); + QVERIFY(item); + } + + // QTBUG-17606 + QList items = findItems(contentItem, "sect_1"); + QCOMPARE(items.count(), 1); + + // QTBUG-17759 + model.modifyItem(0, "One", "aaa"); + model.modifyItem(1, "One", "aaa"); + model.modifyItem(2, "One", "aaa"); + model.modifyItem(3, "Four", "aaa"); + model.modifyItem(4, "Four", "aaa"); + model.modifyItem(5, "Four", "aaa"); + model.modifyItem(6, "Five", "aaa"); + model.modifyItem(7, "Five", "aaa"); + model.modifyItem(8, "Five", "aaa"); + model.modifyItem(9, "Two", "aaa"); + model.modifyItem(10, "Two", "aaa"); + model.modifyItem(11, "Two", "aaa"); + QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false); + QTRY_COMPARE(findItems(contentItem, "sect_aaa").count(), 1); + canvas->rootObject()->setProperty("sectionProperty", "name"); + // ensure view has settled. + QTRY_COMPARE(findItems(contentItem, "sect_Four").count(), 1); + for (int i = 0; i < 4; ++i) { + QQuickItem *item = findItem(contentItem, + "sect_" + model.name(i*3)); + QVERIFY(item); + QTRY_COMPARE(item->y(), qreal(i*20*4)); + } + + // QTBUG-17769 + model.removeItems(10, 20); + // ensure view has settled. + QTRY_COMPARE(findItems(contentItem, "wrapper").count(), 10); + // Drag view up beyond bounds + QTest::mousePress(canvas, Qt::LeftButton, 0, QPoint(20,20)); + { + QMouseEvent mv(QEvent::MouseMove, QPoint(20,0), Qt::LeftButton, Qt::LeftButton,Qt::NoModifier); + QGuiApplication::sendEvent(canvas, &mv); + } + { + QMouseEvent mv(QEvent::MouseMove, QPoint(20,-50), Qt::LeftButton, Qt::LeftButton,Qt::NoModifier); + QGuiApplication::sendEvent(canvas, &mv); + } + { + QMouseEvent mv(QEvent::MouseMove, QPoint(20,-200), Qt::LeftButton, Qt::LeftButton,Qt::NoModifier); + QGuiApplication::sendEvent(canvas, &mv); + } + QTest::mouseRelease(canvas, Qt::LeftButton, 0, QPoint(20,-200)); + // view should settle back at 0 + QTRY_COMPARE(listview->contentY(), 0.0); + + delete canvas; +} + +void tst_QQuickListView::sectionsPositioning() +{ + QQuickView *canvas = createView(); + + QmlListModel model; + for (int i = 0; i < 30; i++) + model.addItem("Item" + QString::number(i), QString::number(i/5)); + + QQmlContext *ctxt = canvas->rootContext(); + ctxt->setContextProperty("testModel", &model); + + canvas->setSource(testFileUrl("listview-sections_delegate.qml")); + canvas->show(); + qApp->processEvents(); + canvas->rootObject()->setProperty("sectionPositioning", QVariant(int(QQuickViewSection::InlineLabels | QQuickViewSection::CurrentLabelAtStart | QQuickViewSection::NextLabelAtEnd))); + + QQuickListView *listview = findItem(canvas->rootObject(), "list"); + QTRY_VERIFY(listview != 0); + QQuickItem *contentItem = listview->contentItem(); + QTRY_VERIFY(contentItem != 0); + QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false); + + for (int i = 0; i < 3; ++i) { + QQuickItem *item = findItem(contentItem, "sect_" + QString::number(i)); + QVERIFY(item); + QTRY_COMPARE(item->y(), qreal(i*20*6)); + } + + QQuickItem *topItem = findVisibleChild(contentItem, "sect_0"); // section header + QVERIFY(topItem); + QCOMPARE(topItem->y(), 0.); + + QQuickItem *bottomItem = findVisibleChild(contentItem, "sect_3"); // section footer + QVERIFY(bottomItem); + QCOMPARE(bottomItem->y(), 300.); + + // move down a little and check that section header is at top + listview->setContentY(10); + QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false); + QCOMPARE(topItem->y(), 0.); + + // push the top header up + listview->setContentY(110); + QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false); + topItem = findVisibleChild(contentItem, "sect_0"); // section header + QVERIFY(topItem); + QCOMPARE(topItem->y(), 100.); + + QQuickItem *item = findVisibleChild(contentItem, "sect_1"); + QVERIFY(item); + QCOMPARE(item->y(), 120.); + + bottomItem = findVisibleChild(contentItem, "sect_4"); // section footer + QVERIFY(bottomItem); + QCOMPARE(bottomItem->y(), 410.); + + // Move past section 0 + listview->setContentY(120); + QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false); + topItem = findVisibleChild(contentItem, "sect_0"); // section header + QVERIFY(!topItem); + + // Push section footer down + listview->setContentY(70); + QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false); + bottomItem = findVisibleChild(contentItem, "sect_4"); // section footer + QVERIFY(bottomItem); + QCOMPARE(bottomItem->y(), 380.); + + // Change current section + listview->setContentY(10); + model.modifyItem(0, "One", "aaa"); + model.modifyItem(1, "Two", "aaa"); + model.modifyItem(2, "Three", "aaa"); + model.modifyItem(3, "Four", "aaa"); + model.modifyItem(4, "Five", "aaa"); + QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false); + + QTRY_COMPARE(listview->currentSection(), QString("aaa")); + + for (int i = 0; i < 3; ++i) { + QQuickItem *item = findItem(contentItem, + "sect_" + (i == 0 ? QString("aaa") : QString::number(i))); + QVERIFY(item); + QTRY_COMPARE(item->y(), qreal(i*20*6)); + } + + QTRY_VERIFY(topItem = findVisibleChild(contentItem, "sect_aaa")); // section header + QCOMPARE(topItem->y(), 10.); + + // remove section boundary + listview->setContentY(120); + QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false); + model.removeItem(5); + QTRY_COMPARE(listview->count(), model.count()); + for (int i = 0; i < 3; ++i) { + QQuickItem *item = findItem(contentItem, + "sect_" + (i == 0 ? QString("aaa") : QString::number(i))); + QVERIFY(item); + QTRY_COMPARE(item->y(), qreal(i*20*6)); + } + + QVERIFY(topItem = findVisibleChild(contentItem, "sect_1")); + QTRY_COMPARE(topItem->y(), 120.); + + // Change the next section + listview->setContentY(0); + QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false); + bottomItem = findVisibleChild(contentItem, "sect_3"); // section footer + QVERIFY(bottomItem); + QTRY_COMPARE(bottomItem->y(), 300.); + + model.modifyItem(14, "New", "new"); + QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false); + + QTRY_VERIFY(bottomItem = findVisibleChild(contentItem, "sect_new")); // section footer + QTRY_COMPARE(bottomItem->y(), 300.); + + // Turn sticky footer off + listview->setContentY(20); + QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false); + canvas->rootObject()->setProperty("sectionPositioning", QVariant(int(QQuickViewSection::InlineLabels | QQuickViewSection::CurrentLabelAtStart))); + QTRY_VERIFY(item = findVisibleChild(contentItem, "sect_new")); // inline label restored + QCOMPARE(item->y(), 340.); + + // Turn sticky header off + listview->setContentY(30); + QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false); + canvas->rootObject()->setProperty("sectionPositioning", QVariant(int(QQuickViewSection::InlineLabels))); + QTRY_VERIFY(item = findVisibleChild(contentItem, "sect_aaa")); // inline label restored + QCOMPARE(item->y(), 0.); + + delete canvas; +} + +void tst_QQuickListView::currentIndex_delayedItemCreation() +{ + QFETCH(bool, setCurrentToZero); + + QQuickView *canvas = createView(); + + // test currentIndexChanged() is emitted even if currentIndex = 0 on start up + // (since the currentItem will have changed and that shares the same index) + canvas->rootContext()->setContextProperty("setCurrentToZero", setCurrentToZero); + + canvas->setSource(testFileUrl("fillModelOnComponentCompleted.qml")); + qApp->processEvents(); + + QQuickListView *listview = findItem(canvas->rootObject(), "list"); + QTRY_VERIFY(listview != 0); + QQuickItem *contentItem = listview->contentItem(); + QTRY_VERIFY(contentItem != 0); + + QSignalSpy spy(listview, SIGNAL(currentItemChanged())); + QCOMPARE(listview->currentIndex(), 0); + QTRY_COMPARE(spy.count(), 1); + + delete canvas; +} + +void tst_QQuickListView::currentIndex_delayedItemCreation_data() +{ + QTest::addColumn("setCurrentToZero"); + + QTest::newRow("set to 0") << true; + QTest::newRow("don't set to 0") << false; +} + +void tst_QQuickListView::currentIndex() +{ + QmlListModel model; + for (int i = 0; i < 30; i++) + model.addItem("Item" + QString::number(i), QString::number(i)); + + QQuickView *canvas = new QQuickView(0); + canvas->setGeometry(0,0,240,320); + + QQmlContext *ctxt = canvas->rootContext(); + ctxt->setContextProperty("testModel", &model); + ctxt->setContextProperty("testWrap", QVariant(false)); + + QString filename(testFile("listview-initCurrent.qml")); + canvas->setSource(QUrl::fromLocalFile(filename)); + canvas->show(); + qApp->processEvents(); + + QQuickListView *listview = findItem(canvas->rootObject(), "list"); + QTRY_VERIFY(listview != 0); + QQuickItem *contentItem = listview->contentItem(); + QTRY_VERIFY(contentItem != 0); + QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false); + + // current item should be 20th item at startup + // and current item should be in view + QCOMPARE(listview->currentIndex(), 20); + QCOMPARE(listview->contentY(), 100.0); + QCOMPARE(listview->currentItem(), findItem(contentItem, "wrapper", 20)); + QCOMPARE(listview->highlightItem()->y(), listview->currentItem()->y()); + + // no wrap + listview->setCurrentIndex(0); + QCOMPARE(listview->currentIndex(), 0); + // confirm that the velocity is updated + QTRY_VERIFY(listview->verticalVelocity() != 0.0); + + listview->incrementCurrentIndex(); + QCOMPARE(listview->currentIndex(), 1); + listview->decrementCurrentIndex(); + QCOMPARE(listview->currentIndex(), 0); + + listview->decrementCurrentIndex(); + QCOMPARE(listview->currentIndex(), 0); + + // with wrap + ctxt->setContextProperty("testWrap", QVariant(true)); + QVERIFY(listview->isWrapEnabled()); + + listview->decrementCurrentIndex(); + QCOMPARE(listview->currentIndex(), model.count()-1); + + QTRY_COMPARE(listview->contentY(), 280.0); + + listview->incrementCurrentIndex(); + QCOMPARE(listview->currentIndex(), 0); + + QTRY_COMPARE(listview->contentY(), 0.0); + + + // footer should become visible if it is out of view, and then current index is set to count-1 + canvas->rootObject()->setProperty("showFooter", true); + QTRY_VERIFY(listview->footerItem()); + listview->setCurrentIndex(model.count()-2); + QTRY_VERIFY(listview->footerItem()->y() > listview->contentY() + listview->height()); + listview->setCurrentIndex(model.count()-1); + QTRY_COMPARE(listview->contentY() + listview->height(), (20.0 * model.count()) + listview->footerItem()->height()); + canvas->rootObject()->setProperty("showFooter", false); + + // header should become visible if it is out of view, and then current index is set to 0 + canvas->rootObject()->setProperty("showHeader", true); + QTRY_VERIFY(listview->headerItem()); + listview->setCurrentIndex(1); + QTRY_VERIFY(listview->headerItem()->y() + listview->headerItem()->height() < listview->contentY()); + listview->setCurrentIndex(0); + QTRY_COMPARE(listview->contentY(), -listview->headerItem()->height()); + canvas->rootObject()->setProperty("showHeader", false); + + + // Test keys + canvas->show(); + canvas->requestActivateWindow(); + QTest::qWaitForWindowShown(canvas); + QTRY_VERIFY(qGuiApp->focusWindow() == canvas); + + listview->setCurrentIndex(0); + + QTest::keyClick(canvas, Qt::Key_Down); + QCOMPARE(listview->currentIndex(), 1); + + QTest::keyClick(canvas, Qt::Key_Up); + QCOMPARE(listview->currentIndex(), 0); + + // hold down Key_Down + for (int i=0; icurrentIndex(), i+1); + } + QTest::keyRelease(canvas, Qt::Key_Down); + QTRY_COMPARE(listview->currentIndex(), model.count()-1); + QTRY_COMPARE(listview->contentY(), 280.0); + + // hold down Key_Up + for (int i=model.count()-1; i > 0; i--) { + QTest::simulateEvent(canvas, true, Qt::Key_Up, Qt::NoModifier, "", true); + QTRY_COMPARE(listview->currentIndex(), i-1); + } + QTest::keyRelease(canvas, Qt::Key_Up); + QTRY_COMPARE(listview->currentIndex(), 0); + QTRY_COMPARE(listview->contentY(), 0.0); + + + // turn off auto highlight + listview->setHighlightFollowsCurrentItem(false); + QVERIFY(listview->highlightFollowsCurrentItem() == false); + + QVERIFY(listview->highlightItem()); + qreal hlPos = listview->highlightItem()->y(); + + listview->setCurrentIndex(4); + QTRY_COMPARE(listview->highlightItem()->y(), hlPos); + + // insert item before currentIndex + listview->setCurrentIndex(28); + model.insertItem(0, "Foo", "1111"); + QTRY_COMPARE(canvas->rootObject()->property("current").toInt(), 29); + + // check removing highlight by setting currentIndex to -1; + listview->setCurrentIndex(-1); + + QCOMPARE(listview->currentIndex(), -1); + QVERIFY(!listview->highlightItem()); + QVERIFY(!listview->currentItem()); + + delete canvas; +} + +void tst_QQuickListView::noCurrentIndex() +{ + QmlListModel model; + for (int i = 0; i < 30; i++) + model.addItem("Item" + QString::number(i), QString::number(i)); + + QQuickView *canvas = new QQuickView(0); + canvas->setGeometry(0,0,240,320); + + QQmlContext *ctxt = canvas->rootContext(); + ctxt->setContextProperty("testModel", &model); + + QString filename(testFile("listview-noCurrent.qml")); + canvas->setSource(QUrl::fromLocalFile(filename)); + canvas->show(); + qApp->processEvents(); + + QQuickListView *listview = findItem(canvas->rootObject(), "list"); + QTRY_VERIFY(listview != 0); + QQuickItem *contentItem = listview->contentItem(); + QTRY_VERIFY(contentItem != 0); + QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false); + + // current index should be -1 at startup + // and we should not have a currentItem or highlightItem + QCOMPARE(listview->currentIndex(), -1); + QCOMPARE(listview->contentY(), 0.0); + QVERIFY(!listview->highlightItem()); + QVERIFY(!listview->currentItem()); + + listview->setCurrentIndex(2); + QCOMPARE(listview->currentIndex(), 2); + QVERIFY(listview->highlightItem()); + QVERIFY(listview->currentItem()); + + delete canvas; +} + +void tst_QQuickListView::itemList() +{ + QQuickView *canvas = createView(); + canvas->setSource(testFileUrl("itemlist.qml")); + canvas->show(); + qApp->processEvents(); + + QQuickListView *listview = findItem(canvas->rootObject(), "view"); + QTRY_VERIFY(listview != 0); + + QQuickItem *contentItem = listview->contentItem(); + QTRY_VERIFY(contentItem != 0); + + QQuickVisualItemModel *model = canvas->rootObject()->findChild("itemModel"); + QTRY_VERIFY(model != 0); + + QTRY_VERIFY(model->count() == 3); + QTRY_COMPARE(listview->currentIndex(), 0); + + QQuickItem *item = findItem(contentItem, "item1"); + QTRY_VERIFY(item); + QTRY_COMPARE(item->x(), 0.0); + QCOMPARE(item->height(), listview->height()); + + QQuickText *text = findItem(contentItem, "text1"); + QTRY_VERIFY(text); + QTRY_COMPARE(text->text(), QLatin1String("index: 0")); + + listview->setCurrentIndex(2); + + item = findItem(contentItem, "item3"); + QTRY_VERIFY(item); + QTRY_COMPARE(item->x(), 480.0); + + text = findItem(contentItem, "text3"); + QTRY_VERIFY(text); + QTRY_COMPARE(text->text(), QLatin1String("index: 2")); + + delete canvas; +} + +void tst_QQuickListView::cacheBuffer() +{ + QQuickView *canvas = createView(); + + QmlListModel model; + for (int i = 0; i < 90; i++) + model.addItem("Item" + QString::number(i), ""); + + QQmlContext *ctxt = canvas->rootContext(); + ctxt->setContextProperty("testModel", &model); + + TestObject *testObject = new TestObject; + ctxt->setContextProperty("testObject", testObject); + + canvas->setSource(testFileUrl("listviewtest.qml")); + canvas->show(); + qApp->processEvents(); + + QQuickListView *listview = findItem(canvas->rootObject(), "list"); + QTRY_VERIFY(listview != 0); + + QQuickItem *contentItem = listview->contentItem(); + QTRY_VERIFY(contentItem != 0); + QTRY_VERIFY(listview->delegate() != 0); + QTRY_VERIFY(listview->model() != 0); + QTRY_VERIFY(listview->highlight() != 0); + + // Confirm items positioned correctly + int itemCount = findItems(contentItem, "wrapper").count(); + for (int i = 0; i < model.count() && i < itemCount; ++i) { + QQuickItem *item = findItem(contentItem, "wrapper", i); + if (!item) qWarning() << "Item" << i << "not found"; + QTRY_VERIFY(item); + QTRY_VERIFY(item->y() == i*20); + } + + QQmlIncubationController controller; + canvas->engine()->setIncubationController(&controller); + + testObject->setCacheBuffer(200); + QTRY_VERIFY(listview->cacheBuffer() == 200); + + // items will be created one at a time + for (int i = itemCount; i < qMin(itemCount+10,model.count()); ++i) { + QVERIFY(findItem(listview, "wrapper", i) == 0); + QQuickItem *item = 0; + while (!item) { + bool b = false; + controller.incubateWhile(&b); + item = findItem(listview, "wrapper", i); + } + } + + { + bool b = true; + controller.incubateWhile(&b); + } + + int newItemCount = 0; + newItemCount = findItems(contentItem, "wrapper").count(); + + // Confirm items positioned correctly + for (int i = 0; i < model.count() && i < newItemCount; ++i) { + QQuickItem *item = findItem(contentItem, "wrapper", i); + if (!item) qWarning() << "Item" << i << "not found"; + QTRY_VERIFY(item); + QTRY_VERIFY(item->y() == i*20); + } + + // move view and confirm items in view are visible immediately and outside are created async + listview->setContentY(300); + + for (int i = 15; i < 32; ++i) { + QQuickItem *item = findItem(contentItem, "wrapper", i); + if (!item) qWarning() << "Item" << i << "not found"; + QVERIFY(item); + QVERIFY(item->y() == i*20); + } + + QVERIFY(findItem(listview, "wrapper", 32) == 0); + + // ensure buffered items are created + for (int i = 32; i < qMin(41,model.count()); ++i) { + QQuickItem *item = 0; + while (!item) { + qGuiApp->processEvents(); // allow refill to happen + bool b = false; + controller.incubateWhile(&b); + item = findItem(listview, "wrapper", i); + } + } + + { + bool b = true; + controller.incubateWhile(&b); + } + + delete canvas; + delete testObject; +} + +void tst_QQuickListView::positionViewAtIndex() +{ + QQuickView *canvas = createView(); + + QmlListModel model; + for (int i = 0; i < 40; i++) + model.addItem("Item" + QString::number(i), ""); + + QQmlContext *ctxt = canvas->rootContext(); + ctxt->setContextProperty("testModel", &model); + + TestObject *testObject = new TestObject; + ctxt->setContextProperty("testObject", testObject); + canvas->show(); + canvas->setSource(testFileUrl("listviewtest.qml")); + qApp->processEvents(); + + QQuickListView *listview = findItem(canvas->rootObject(), "list"); + QTRY_VERIFY(listview != 0); + QQuickItem *contentItem = listview->contentItem(); + QTRY_VERIFY(contentItem != 0); + QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false); + + // Confirm items positioned correctly + int itemCount = findItems(contentItem, "wrapper").count(); + for (int i = 0; i < model.count() && i < itemCount; ++i) { + QQuickItem *item = findItem(contentItem, "wrapper", i); + if (!item) qWarning() << "Item" << i << "not found"; + QTRY_VERIFY(item); + QTRY_COMPARE(item->y(), i*20.); + } + + // Position on a currently visible item + listview->positionViewAtIndex(3, QQuickListView::Beginning); + QTRY_COMPARE(listview->contentY(), 60.); + + // Confirm items positioned correctly + itemCount = findItems(contentItem, "wrapper").count(); + for (int i = 3; i < model.count() && i < itemCount-3-1; ++i) { + QQuickItem *item = findItem(contentItem, "wrapper", i); + if (!item) qWarning() << "Item" << i << "not found"; + QTRY_VERIFY(item); + QTRY_COMPARE(item->y(), i*20.); + } + + // Position on an item beyond the visible items + listview->positionViewAtIndex(22, QQuickListView::Beginning); + QTRY_COMPARE(listview->contentY(), 440.); + + // Confirm items positioned correctly + itemCount = findItems(contentItem, "wrapper").count(); + for (int i = 22; i < model.count() && i < itemCount-22-1; ++i) { + QQuickItem *item = findItem(contentItem, "wrapper", i); + if (!item) qWarning() << "Item" << i << "not found"; + QTRY_VERIFY(item); + QTRY_COMPARE(item->y(), i*20.); + } + + // Position on an item that would leave empty space if positioned at the top + listview->positionViewAtIndex(28, QQuickListView::Beginning); + QTRY_COMPARE(listview->contentY(), 480.); + + // Confirm items positioned correctly + itemCount = findItems(contentItem, "wrapper").count(); + for (int i = 24; i < model.count() && i < itemCount-24-1; ++i) { + QQuickItem *item = findItem(contentItem, "wrapper", i); + if (!item) qWarning() << "Item" << i << "not found"; + QTRY_VERIFY(item); + QTRY_COMPARE(item->y(), i*20.); + } + + // Position at the beginning again + listview->positionViewAtIndex(0, QQuickListView::Beginning); + QTRY_COMPARE(listview->contentY(), 0.); + + // Confirm items positioned correctly + itemCount = findItems(contentItem, "wrapper").count(); + for (int i = 0; i < model.count() && i < itemCount-1; ++i) { + QQuickItem *item = findItem(contentItem, "wrapper", i); + if (!item) qWarning() << "Item" << i << "not found"; + QTRY_VERIFY(item); + QTRY_COMPARE(item->y(), i*20.); + } + + // Position at End using last index + listview->positionViewAtIndex(model.count()-1, QQuickListView::End); + QTRY_COMPARE(listview->contentY(), 480.); + + // Confirm items positioned correctly + itemCount = findItems(contentItem, "wrapper").count(); + for (int i = 24; i < model.count(); ++i) { + QQuickItem *item = findItem(contentItem, "wrapper", i); + if (!item) qWarning() << "Item" << i << "not found"; + QTRY_VERIFY(item); + QTRY_COMPARE(item->y(), i*20.); + } + + // Position at End + listview->positionViewAtIndex(20, QQuickListView::End); + QTRY_COMPARE(listview->contentY(), 100.); + + // Position in Center + listview->positionViewAtIndex(15, QQuickListView::Center); + QTRY_COMPARE(listview->contentY(), 150.); + + // Ensure at least partially visible + listview->positionViewAtIndex(15, QQuickListView::Visible); + QTRY_COMPARE(listview->contentY(), 150.); + + listview->setContentY(302); + listview->positionViewAtIndex(15, QQuickListView::Visible); + QTRY_COMPARE(listview->contentY(), 302.); + + listview->setContentY(320); + listview->positionViewAtIndex(15, QQuickListView::Visible); + QTRY_COMPARE(listview->contentY(), 300.); + + listview->setContentY(85); + listview->positionViewAtIndex(20, QQuickListView::Visible); + QTRY_COMPARE(listview->contentY(), 85.); + + listview->setContentY(75); + listview->positionViewAtIndex(20, QQuickListView::Visible); + QTRY_COMPARE(listview->contentY(), 100.); + + // Ensure completely visible + listview->setContentY(120); + listview->positionViewAtIndex(20, QQuickListView::Contain); + QTRY_COMPARE(listview->contentY(), 120.); + + listview->setContentY(302); + listview->positionViewAtIndex(15, QQuickListView::Contain); + QTRY_COMPARE(listview->contentY(), 300.); + + listview->setContentY(85); + listview->positionViewAtIndex(20, QQuickListView::Contain); + QTRY_COMPARE(listview->contentY(), 100.); + + // positionAtBeginnging + listview->positionViewAtBeginning(); + QTRY_COMPARE(listview->contentY(), 0.); + + listview->setContentY(80); + canvas->rootObject()->setProperty("showHeader", true); + listview->positionViewAtBeginning(); + QTRY_COMPARE(listview->contentY(), -30.); + + // positionAtEnd + listview->positionViewAtEnd(); + QTRY_COMPARE(listview->contentY(), 480.); // 40*20 - 320 + + listview->setContentY(80); + canvas->rootObject()->setProperty("showFooter", true); + listview->positionViewAtEnd(); + QTRY_COMPARE(listview->contentY(), 510.); + + // set current item to outside visible view, position at beginning + // and ensure highlight moves to current item + listview->setCurrentIndex(1); + listview->positionViewAtBeginning(); + QTRY_COMPARE(listview->contentY(), -30.); + QVERIFY(listview->highlightItem()); + QCOMPARE(listview->highlightItem()->y(), 20.); + + delete canvas; + delete testObject; +} + +void tst_QQuickListView::resetModel() +{ + QQuickView *canvas = createView(); + + QStringList strings; + strings << "one" << "two" << "three"; + QStringListModel model(strings); + + QQmlContext *ctxt = canvas->rootContext(); + ctxt->setContextProperty("testModel", &model); + + canvas->setSource(testFileUrl("displaylist.qml")); + canvas->show(); + qApp->processEvents(); + + QQuickListView *listview = findItem(canvas->rootObject(), "list"); + QTRY_VERIFY(listview != 0); + QQuickItem *contentItem = listview->contentItem(); + QTRY_VERIFY(contentItem != 0); + QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false); + + QTRY_COMPARE(listview->count(), model.rowCount()); + + for (int i = 0; i < model.rowCount(); ++i) { + QQuickText *display = findItem(contentItem, "displayText", i); + QTRY_VERIFY(display != 0); + QTRY_COMPARE(display->text(), strings.at(i)); + } + + strings.clear(); + strings << "four" << "five" << "six" << "seven"; + model.setStringList(strings); + + QTRY_COMPARE(listview->count(), model.rowCount()); + + for (int i = 0; i < model.rowCount(); ++i) { + QQuickText *display = findItem(contentItem, "displayText", i); + QTRY_VERIFY(display != 0); + QTRY_COMPARE(display->text(), strings.at(i)); + } + + delete canvas; +} + +void tst_QQuickListView::propertyChanges() +{ + QQuickView *canvas = createView(); + QTRY_VERIFY(canvas); + canvas->setSource(testFileUrl("propertychangestest.qml")); + + QQuickListView *listView = canvas->rootObject()->findChild("listView"); + QTRY_VERIFY(listView); + + QSignalSpy highlightFollowsCurrentItemSpy(listView, SIGNAL(highlightFollowsCurrentItemChanged())); + QSignalSpy preferredHighlightBeginSpy(listView, SIGNAL(preferredHighlightBeginChanged())); + QSignalSpy preferredHighlightEndSpy(listView, SIGNAL(preferredHighlightEndChanged())); + QSignalSpy highlightRangeModeSpy(listView, SIGNAL(highlightRangeModeChanged())); + QSignalSpy keyNavigationWrapsSpy(listView, SIGNAL(keyNavigationWrapsChanged())); + QSignalSpy cacheBufferSpy(listView, SIGNAL(cacheBufferChanged())); + QSignalSpy snapModeSpy(listView, SIGNAL(snapModeChanged())); + + QTRY_COMPARE(listView->highlightFollowsCurrentItem(), true); + QTRY_COMPARE(listView->preferredHighlightBegin(), 0.0); + QTRY_COMPARE(listView->preferredHighlightEnd(), 0.0); + QTRY_COMPARE(listView->highlightRangeMode(), QQuickListView::ApplyRange); + QTRY_COMPARE(listView->isWrapEnabled(), true); + QTRY_COMPARE(listView->cacheBuffer(), 10); + QTRY_COMPARE(listView->snapMode(), QQuickListView::SnapToItem); + + listView->setHighlightFollowsCurrentItem(false); + listView->setPreferredHighlightBegin(1.0); + listView->setPreferredHighlightEnd(1.0); + listView->setHighlightRangeMode(QQuickListView::StrictlyEnforceRange); + listView->setWrapEnabled(false); + listView->setCacheBuffer(3); + listView->setSnapMode(QQuickListView::SnapOneItem); + + QTRY_COMPARE(listView->highlightFollowsCurrentItem(), false); + QTRY_COMPARE(listView->preferredHighlightBegin(), 1.0); + QTRY_COMPARE(listView->preferredHighlightEnd(), 1.0); + QTRY_COMPARE(listView->highlightRangeMode(), QQuickListView::StrictlyEnforceRange); + QTRY_COMPARE(listView->isWrapEnabled(), false); + QTRY_COMPARE(listView->cacheBuffer(), 3); + QTRY_COMPARE(listView->snapMode(), QQuickListView::SnapOneItem); + + QTRY_COMPARE(highlightFollowsCurrentItemSpy.count(),1); + QTRY_COMPARE(preferredHighlightBeginSpy.count(),1); + QTRY_COMPARE(preferredHighlightEndSpy.count(),1); + QTRY_COMPARE(highlightRangeModeSpy.count(),1); + QTRY_COMPARE(keyNavigationWrapsSpy.count(),1); + QTRY_COMPARE(cacheBufferSpy.count(),1); + QTRY_COMPARE(snapModeSpy.count(),1); + + listView->setHighlightFollowsCurrentItem(false); + listView->setPreferredHighlightBegin(1.0); + listView->setPreferredHighlightEnd(1.0); + listView->setHighlightRangeMode(QQuickListView::StrictlyEnforceRange); + listView->setWrapEnabled(false); + listView->setCacheBuffer(3); + listView->setSnapMode(QQuickListView::SnapOneItem); + + QTRY_COMPARE(highlightFollowsCurrentItemSpy.count(),1); + QTRY_COMPARE(preferredHighlightBeginSpy.count(),1); + QTRY_COMPARE(preferredHighlightEndSpy.count(),1); + QTRY_COMPARE(highlightRangeModeSpy.count(),1); + QTRY_COMPARE(keyNavigationWrapsSpy.count(),1); + QTRY_COMPARE(cacheBufferSpy.count(),1); + QTRY_COMPARE(snapModeSpy.count(),1); + + delete canvas; +} + +void tst_QQuickListView::componentChanges() +{ + QQuickView *canvas = createView(); + QTRY_VERIFY(canvas); + canvas->setSource(testFileUrl("propertychangestest.qml")); + + QQuickListView *listView = canvas->rootObject()->findChild("listView"); + QTRY_VERIFY(listView); + + QQmlComponent component(canvas->engine()); + component.setData("import QtQuick 2.0; Rectangle { color: \"blue\"; }", QUrl::fromLocalFile("")); + + QQmlComponent delegateComponent(canvas->engine()); + delegateComponent.setData("import QtQuick 2.0; Text { text: 'Name: ' + name }", QUrl::fromLocalFile("")); + + QSignalSpy highlightSpy(listView, SIGNAL(highlightChanged())); + QSignalSpy delegateSpy(listView, SIGNAL(delegateChanged())); + QSignalSpy headerSpy(listView, SIGNAL(headerChanged())); + QSignalSpy footerSpy(listView, SIGNAL(footerChanged())); + + listView->setHighlight(&component); + listView->setHeader(&component); + listView->setFooter(&component); + listView->setDelegate(&delegateComponent); + + QTRY_COMPARE(listView->highlight(), &component); + QTRY_COMPARE(listView->header(), &component); + QTRY_COMPARE(listView->footer(), &component); + QTRY_COMPARE(listView->delegate(), &delegateComponent); + + QTRY_COMPARE(highlightSpy.count(),1); + QTRY_COMPARE(delegateSpy.count(),1); + QTRY_COMPARE(headerSpy.count(),1); + QTRY_COMPARE(footerSpy.count(),1); + + listView->setHighlight(&component); + listView->setHeader(&component); + listView->setFooter(&component); + listView->setDelegate(&delegateComponent); + + QTRY_COMPARE(highlightSpy.count(),1); + QTRY_COMPARE(delegateSpy.count(),1); + QTRY_COMPARE(headerSpy.count(),1); + QTRY_COMPARE(footerSpy.count(),1); + + delete canvas; +} + +void tst_QQuickListView::modelChanges() +{ + QQuickView *canvas = createView(); + QTRY_VERIFY(canvas); + canvas->setSource(testFileUrl("propertychangestest.qml")); + + QQuickListView *listView = canvas->rootObject()->findChild("listView"); + QTRY_VERIFY(listView); + + QQuickListModel *alternateModel = canvas->rootObject()->findChild("alternateModel"); + QTRY_VERIFY(alternateModel); + QVariant modelVariant = QVariant::fromValue(alternateModel); + QSignalSpy modelSpy(listView, SIGNAL(modelChanged())); + + listView->setModel(modelVariant); + QTRY_COMPARE(listView->model(), modelVariant); + QTRY_COMPARE(modelSpy.count(),1); + + listView->setModel(modelVariant); + QTRY_COMPARE(modelSpy.count(),1); + + listView->setModel(QVariant()); + QTRY_COMPARE(modelSpy.count(),2); + + delete canvas; +} + +void tst_QQuickListView::QTBUG_9791() +{ + QQuickView *canvas = createView(); + + canvas->setSource(testFileUrl("strictlyenforcerange.qml")); + qApp->processEvents(); + + QQuickListView *listview = qobject_cast(canvas->rootObject()); + QTRY_VERIFY(listview != 0); + + QQuickItem *contentItem = listview->contentItem(); + QTRY_VERIFY(contentItem != 0); + QTRY_VERIFY(listview->delegate() != 0); + QTRY_VERIFY(listview->model() != 0); + + QMetaObject::invokeMethod(listview, "fillModel"); + qApp->processEvents(); + + // Confirm items positioned correctly + int itemCount = findItems(contentItem, "wrapper", false).count(); + QCOMPARE(itemCount, 3); + + for (int i = 0; i < itemCount; ++i) { + QQuickItem *item = findItem(contentItem, "wrapper", i); + if (!item) qWarning() << "Item" << i << "not found"; + QTRY_VERIFY(item); + QTRY_COMPARE(item->x(), i*300.0); + } + + // check that view is positioned correctly + QTRY_COMPARE(listview->contentX(), 590.0); + + delete canvas; +} + +void tst_QQuickListView::manualHighlight() +{ + QQuickView *canvas = new QQuickView(0); + canvas->setGeometry(0,0,240,320); + + QString filename(testFile("manual-highlight.qml")); + canvas->setSource(QUrl::fromLocalFile(filename)); + + qApp->processEvents(); + + QQuickListView *listview = findItem(canvas->rootObject(), "list"); + QTRY_VERIFY(listview != 0); + + QQuickItem *contentItem = listview->contentItem(); + QTRY_VERIFY(contentItem != 0); + + QTRY_COMPARE(listview->currentIndex(), 0); + QTRY_COMPARE(listview->currentItem(), findItem(contentItem, "wrapper", 0)); + QTRY_COMPARE(listview->highlightItem()->y() - 5, listview->currentItem()->y()); + + listview->setCurrentIndex(2); + + QTRY_COMPARE(listview->currentIndex(), 2); + QTRY_COMPARE(listview->currentItem(), findItem(contentItem, "wrapper", 2)); + QTRY_COMPARE(listview->highlightItem()->y() - 5, listview->currentItem()->y()); + + // QTBUG-15972 + listview->positionViewAtIndex(3, QQuickListView::Contain); + + QTRY_COMPARE(listview->currentIndex(), 2); + QTRY_COMPARE(listview->currentItem(), findItem(contentItem, "wrapper", 2)); + QTRY_COMPARE(listview->highlightItem()->y() - 5, listview->currentItem()->y()); + + delete canvas; +} + +void tst_QQuickListView::QTBUG_11105() +{ + QQuickView *canvas = createView(); + + QmlListModel model; + for (int i = 0; i < 30; i++) + model.addItem("Item" + QString::number(i), ""); + + QQmlContext *ctxt = canvas->rootContext(); + ctxt->setContextProperty("testModel", &model); + + TestObject *testObject = new TestObject; + ctxt->setContextProperty("testObject", testObject); + + canvas->setSource(testFileUrl("listviewtest.qml")); + canvas->show(); + qApp->processEvents(); + + QQuickListView *listview = findItem(canvas->rootObject(), "list"); + QTRY_VERIFY(listview != 0); + QQuickItem *contentItem = listview->contentItem(); + QTRY_VERIFY(contentItem != 0); + QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false); + + // Confirm items positioned correctly + int itemCount = findItems(contentItem, "wrapper").count(); + for (int i = 0; i < model.count() && i < itemCount; ++i) { + QQuickItem *item = findItem(contentItem, "wrapper", i); + if (!item) qWarning() << "Item" << i << "not found"; + QTRY_VERIFY(item); + QTRY_VERIFY(item->y() == i*20); + } + + listview->positionViewAtIndex(20, QQuickListView::Beginning); + QCOMPARE(listview->contentY(), 280.); + + QmlListModel model2; + for (int i = 0; i < 5; i++) + model2.addItem("Item" + QString::number(i), ""); + + ctxt->setContextProperty("testModel", &model2); + + itemCount = findItems(contentItem, "wrapper").count(); + QCOMPARE(itemCount, 5); + + delete canvas; + delete testObject; +} + +void tst_QQuickListView::header() +{ + QFETCH(QQuickListView::Orientation, orientation); + QFETCH(Qt::LayoutDirection, layoutDirection); + QFETCH(QPointF, initialHeaderPos); + QFETCH(QPointF, firstDelegatePos); + QFETCH(QPointF, initialContentPos); + QFETCH(QPointF, changedHeaderPos); + QFETCH(QPointF, changedContentPos); + QFETCH(QPointF, resizeContentPos); + + QmlListModel model; + for (int i = 0; i < 30; i++) + model.addItem("Item" + QString::number(i), ""); + + QQuickView *canvas = createView(); + canvas->rootContext()->setContextProperty("testModel", &model); + canvas->rootContext()->setContextProperty("initialViewWidth", 240); + canvas->rootContext()->setContextProperty("initialViewHeight", 320); + canvas->setSource(testFileUrl("header.qml")); + canvas->show(); + qApp->processEvents(); + + QQuickListView *listview = findItem(canvas->rootObject(), "list"); + QTRY_VERIFY(listview != 0); + listview->setOrientation(orientation); + listview->setLayoutDirection(layoutDirection); + + QQuickItem *contentItem = listview->contentItem(); + QTRY_VERIFY(contentItem != 0); + + QQuickText *header = 0; + QTRY_VERIFY(header = findItem(contentItem, "header")); + QVERIFY(header == listview->headerItem()); + + QCOMPARE(header->width(), 100.); + QCOMPARE(header->height(), 30.); + QCOMPARE(header->pos(), initialHeaderPos); + QCOMPARE(QPointF(listview->contentX(), listview->contentY()), initialContentPos); + + QQuickItem *item = findItem(contentItem, "wrapper", 0); + QVERIFY(item); + QCOMPARE(item->pos(), firstDelegatePos); + + model.clear(); + QTRY_COMPARE(listview->count(), model.count()); + QCOMPARE(header->pos(), initialHeaderPos); // header should stay where it is + + for (int i = 0; i < 30; i++) + model.addItem("Item" + QString::number(i), ""); + + QSignalSpy headerItemSpy(listview, SIGNAL(headerItemChanged())); + QMetaObject::invokeMethod(canvas->rootObject(), "changeHeader"); + + QCOMPARE(headerItemSpy.count(), 1); + + header = findItem(contentItem, "header"); + QVERIFY(!header); + header = findItem(contentItem, "header2"); + QVERIFY(header); + + QVERIFY(header == listview->headerItem()); + + QCOMPARE(header->pos(), changedHeaderPos); + QCOMPARE(header->width(), 50.); + QCOMPARE(header->height(), 20.); + QTRY_COMPARE(QPointF(listview->contentX(), listview->contentY()), changedContentPos); + + item = findItem(contentItem, "wrapper", 0); + QVERIFY(item); + QCOMPARE(item->pos(), firstDelegatePos); + + delete canvas; + + + // QTBUG-21207 header should become visible if view resizes from initial empty size + + canvas = createView(); + canvas->rootContext()->setContextProperty("testModel", &model); + canvas->rootContext()->setContextProperty("initialViewWidth", 0.0); + canvas->rootContext()->setContextProperty("initialViewHeight", 0.0); + canvas->setSource(testFileUrl("header.qml")); + canvas->show(); + qApp->processEvents(); + + listview = findItem(canvas->rootObject(), "list"); + QTRY_VERIFY(listview != 0); + listview->setOrientation(orientation); + listview->setLayoutDirection(layoutDirection); + QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false); + + listview->setWidth(240); + listview->setHeight(320); + QTRY_COMPARE(listview->headerItem()->pos(), initialHeaderPos); + QCOMPARE(QPointF(listview->contentX(), listview->contentY()), initialContentPos); + + + delete canvas; +} + +void tst_QQuickListView::header_data() +{ + QTest::addColumn("orientation"); + QTest::addColumn("layoutDirection"); + QTest::addColumn("initialHeaderPos"); + QTest::addColumn("changedHeaderPos"); + QTest::addColumn("initialContentPos"); + QTest::addColumn("changedContentPos"); + QTest::addColumn("firstDelegatePos"); + QTest::addColumn("resizeContentPos"); + + // header1 = 100 x 30 + // header2 = 50 x 20 + // delegates = 240 x 20 + // view width = 240 + + // header above items, top left + QTest::newRow("vertical, left to right") << QQuickListView::Vertical << Qt::LeftToRight + << QPointF(0, -30) + << QPointF(0, -20) + << QPointF(0, -30) + << QPointF(0, -20) + << QPointF(0, 0) + << QPointF(0, -10); + + // header above items, top right + QTest::newRow("vertical, layout right to left") << QQuickListView::Vertical << Qt::RightToLeft + << QPointF(0, -30) + << QPointF(0, -20) + << QPointF(0, -30) + << QPointF(0, -20) + << QPointF(0, 0) + << QPointF(0, -10); + + // header to left of items + QTest::newRow("horizontal, layout left to right") << QQuickListView::Horizontal << Qt::LeftToRight + << QPointF(-100, 0) + << QPointF(-50, 0) + << QPointF(-100, 0) + << QPointF(-50, 0) + << QPointF(0, 0) + << QPointF(-40, 0); + + // header to right of items + QTest::newRow("horizontal, layout right to left") << QQuickListView::Horizontal << Qt::RightToLeft + << QPointF(0, 0) + << QPointF(0, 0) + << QPointF(-240 + 100, 0) + << QPointF(-240 + 50, 0) + << QPointF(-240, 0) + << QPointF(-240 + 40, 0); +} + +void tst_QQuickListView::header_delayItemCreation() +{ + QQuickView *canvas = createView(); + + QmlListModel model; + + canvas->rootContext()->setContextProperty("setCurrentToZero", QVariant(false)); + canvas->setSource(testFileUrl("fillModelOnComponentCompleted.qml")); + qApp->processEvents(); + + QQuickListView *listview = findItem(canvas->rootObject(), "list"); + QTRY_VERIFY(listview != 0); + + QQuickItem *contentItem = listview->contentItem(); + QTRY_VERIFY(contentItem != 0); + + QQuickText *header = findItem(contentItem, "header"); + QVERIFY(header); + QCOMPARE(header->y(), -header->height()); + + QCOMPARE(listview->contentY(), -header->height()); + + model.clear(); + QTRY_COMPARE(header->y(), -header->height()); + + delete canvas; +} + +void tst_QQuickListView::footer() +{ + QFETCH(QQuickListView::Orientation, orientation); + QFETCH(Qt::LayoutDirection, layoutDirection); + QFETCH(QPointF, initialFooterPos); + QFETCH(QPointF, firstDelegatePos); + QFETCH(QPointF, initialContentPos); + QFETCH(QPointF, changedFooterPos); + QFETCH(QPointF, changedContentPos); + QFETCH(QPointF, resizeContentPos); + + QQuickView *canvas = createView(); + + QmlListModel model; + for (int i = 0; i < 3; i++) + model.addItem("Item" + QString::number(i), ""); + + QQmlContext *ctxt = canvas->rootContext(); + ctxt->setContextProperty("testModel", &model); + + canvas->setSource(testFileUrl("footer.qml")); + canvas->show(); + qApp->processEvents(); + + QQuickListView *listview = findItem(canvas->rootObject(), "list"); + QTRY_VERIFY(listview != 0); + listview->setOrientation(orientation); + listview->setLayoutDirection(layoutDirection); + QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false); + + QQuickItem *contentItem = listview->contentItem(); + QTRY_VERIFY(contentItem != 0); + + QQuickText *footer = findItem(contentItem, "footer"); + QVERIFY(footer); + + QVERIFY(footer == listview->footerItem()); + + QCOMPARE(footer->pos(), initialFooterPos); + QCOMPARE(footer->width(), 100.); + QCOMPARE(footer->height(), 30.); + QCOMPARE(QPointF(listview->contentX(), listview->contentY()), initialContentPos); + + QQuickItem *item = findItem(contentItem, "wrapper", 0); + QVERIFY(item); + QCOMPARE(item->pos(), firstDelegatePos); + + // remove one item + model.removeItem(1); + + if (orientation == QQuickListView::Vertical) { + QTRY_COMPARE(footer->y(), initialFooterPos.y() - 20); // delegate height = 20 + } else { + QTRY_COMPARE(footer->x(), layoutDirection == Qt::LeftToRight ? + initialFooterPos.x() - 40 : initialFooterPos.x() + 40); // delegate width = 40 + } + + // remove all items + model.clear(); + + QPointF posWhenNoItems(0, 0); + if (orientation == QQuickListView::Horizontal && layoutDirection == Qt::RightToLeft) + posWhenNoItems.setX(-100); + QTRY_COMPARE(footer->pos(), posWhenNoItems); + + // if header is present, it's at a negative pos, so the footer should not move + canvas->rootObject()->setProperty("showHeader", true); + QTRY_COMPARE(footer->pos(), posWhenNoItems); + canvas->rootObject()->setProperty("showHeader", false); + + // add 30 items + for (int i = 0; i < 30; i++) + model.addItem("Item" + QString::number(i), ""); + + QSignalSpy footerItemSpy(listview, SIGNAL(footerItemChanged())); + QMetaObject::invokeMethod(canvas->rootObject(), "changeFooter"); + + QCOMPARE(footerItemSpy.count(), 1); + + footer = findItem(contentItem, "footer"); + QVERIFY(!footer); + footer = findItem(contentItem, "footer2"); + QVERIFY(footer); + + QVERIFY(footer == listview->footerItem()); + + QCOMPARE(footer->pos(), changedFooterPos); + QCOMPARE(footer->width(), 50.); + QCOMPARE(footer->height(), 20.); + QTRY_COMPARE(QPointF(listview->contentX(), listview->contentY()), changedContentPos); + + item = findItem(contentItem, "wrapper", 0); + QVERIFY(item); + QCOMPARE(item->pos(), firstDelegatePos); + + listview->positionViewAtEnd(); + footer->setHeight(10); + footer->setWidth(40); + QTRY_COMPARE(QPointF(listview->contentX(), listview->contentY()), resizeContentPos); + + delete canvas; +} + +void tst_QQuickListView::footer_data() +{ + QTest::addColumn("orientation"); + QTest::addColumn("layoutDirection"); + QTest::addColumn("initialFooterPos"); + QTest::addColumn("changedFooterPos"); + QTest::addColumn("initialContentPos"); + QTest::addColumn("changedContentPos"); + QTest::addColumn("firstDelegatePos"); + QTest::addColumn("resizeContentPos"); + + // footer1 = 100 x 30 + // footer2 = 50 x 20 + // delegates = 40 x 20 + // view width = 240 + // view height = 320 + + // footer below items, bottom left + QTest::newRow("vertical, layout left to right") << QQuickListView::Vertical << Qt::LeftToRight + << QPointF(0, 3 * 20) + << QPointF(0, 30 * 20) // added 30 items + << QPointF(0, 0) + << QPointF(0, 0) + << QPointF(0, 0) + << QPointF(0, 30 * 20 - 320 + 10); + + // footer below items, bottom right + QTest::newRow("vertical, layout right to left") << QQuickListView::Vertical << Qt::RightToLeft + << QPointF(0, 3 * 20) + << QPointF(0, 30 * 20) + << QPointF(0, 0) + << QPointF(0, 0) + << QPointF(0, 0) + << QPointF(0, 30 * 20 - 320 + 10); + + // footer to right of items + QTest::newRow("horizontal, layout left to right") << QQuickListView::Horizontal << Qt::LeftToRight + << QPointF(40 * 3, 0) + << QPointF(40 * 30, 0) + << QPointF(0, 0) + << QPointF(0, 0) + << QPointF(0, 0) + << QPointF(40 * 30 - 240 + 40, 0); + + // footer to left of items + QTest::newRow("horizontal, layout right to left") << QQuickListView::Horizontal << Qt::RightToLeft + << QPointF(-(40 * 3) - 100, 0) + << QPointF(-(40 * 30) - 50, 0) // 50 = new footer width + << QPointF(-240, 0) + << QPointF(-240, 0) + << QPointF(-40, 0) + << QPointF(-(40 * 30) - 40, 0); +} + +class LVAccessor : public QQuickListView +{ +public: + qreal minY() const { return minYExtent(); } + qreal maxY() const { return maxYExtent(); } + qreal minX() const { return minXExtent(); } + qreal maxX() const { return maxXExtent(); } +}; + +void tst_QQuickListView::headerFooter() +{ + { + // Vertical + QQuickView *canvas = createView(); + + QmlListModel model; + QQmlContext *ctxt = canvas->rootContext(); + ctxt->setContextProperty("testModel", &model); + + canvas->setSource(testFileUrl("headerfooter.qml")); + qApp->processEvents(); + + QQuickListView *listview = qobject_cast(canvas->rootObject()); + QTRY_VERIFY(listview != 0); + + QQuickItem *contentItem = listview->contentItem(); + QTRY_VERIFY(contentItem != 0); + + QQuickItem *header = findItem(contentItem, "header"); + QVERIFY(header); + QCOMPARE(header->y(), -header->height()); + + QQuickItem *footer = findItem(contentItem, "footer"); + QVERIFY(footer); + QCOMPARE(footer->y(), 0.); + + QCOMPARE(static_cast(listview)->minY(), header->height()); + QCOMPARE(static_cast(listview)->maxY(), header->height()); + + delete canvas; + } + { + // Horizontal + QQuickView *canvas = createView(); + + QmlListModel model; + QQmlContext *ctxt = canvas->rootContext(); + ctxt->setContextProperty("testModel", &model); + + canvas->setSource(testFileUrl("headerfooter.qml")); + canvas->rootObject()->setProperty("horizontal", true); + qApp->processEvents(); + + QQuickListView *listview = qobject_cast(canvas->rootObject()); + QTRY_VERIFY(listview != 0); + + QQuickItem *contentItem = listview->contentItem(); + QTRY_VERIFY(contentItem != 0); + + QQuickItem *header = findItem(contentItem, "header"); + QVERIFY(header); + QCOMPARE(header->x(), -header->width()); + + QQuickItem *footer = findItem(contentItem, "footer"); + QVERIFY(footer); + QCOMPARE(footer->x(), 0.); + + QCOMPARE(static_cast(listview)->minX(), header->width()); + QCOMPARE(static_cast(listview)->maxX(), header->width()); + + delete canvas; + } + { + // Horizontal RTL + QQuickView *canvas = createView(); + + QmlListModel model; + QQmlContext *ctxt = canvas->rootContext(); + ctxt->setContextProperty("testModel", &model); + + canvas->setSource(testFileUrl("headerfooter.qml")); + canvas->rootObject()->setProperty("horizontal", true); + canvas->rootObject()->setProperty("rtl", true); + qApp->processEvents(); + + QQuickListView *listview = qobject_cast(canvas->rootObject()); + QTRY_VERIFY(listview != 0); + + QQuickItem *contentItem = listview->contentItem(); + QTRY_VERIFY(contentItem != 0); + + QQuickItem *header = findItem(contentItem, "header"); + QVERIFY(header); + QCOMPARE(header->x(), 0.); + + QQuickItem *footer = findItem(contentItem, "footer"); + QVERIFY(footer); + QCOMPARE(footer->x(), -footer->width()); + + QCOMPARE(static_cast(listview)->minX(), 240. - header->width()); + QCOMPARE(static_cast(listview)->maxX(), 240. - header->width()); + + delete canvas; + } +} + +void tst_QQuickListView::resizeView() +{ + QQuickView *canvas = createView(); + + QmlListModel model; + for (int i = 0; i < 40; i++) + model.addItem("Item" + QString::number(i), ""); + + QQmlContext *ctxt = canvas->rootContext(); + ctxt->setContextProperty("testModel", &model); + + TestObject *testObject = new TestObject; + ctxt->setContextProperty("testObject", testObject); + + canvas->setSource(testFileUrl("listviewtest.qml")); + canvas->show(); + qApp->processEvents(); + + QQuickListView *listview = findItem(canvas->rootObject(), "list"); + QTRY_VERIFY(listview != 0); + QQuickItem *contentItem = listview->contentItem(); + QTRY_VERIFY(contentItem != 0); + QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false); + + // Confirm items positioned correctly + int itemCount = findItems(contentItem, "wrapper").count(); + for (int i = 0; i < model.count() && i < itemCount; ++i) { + QQuickItem *item = findItem(contentItem, "wrapper", i); + if (!item) qWarning() << "Item" << i << "not found"; + QTRY_VERIFY(item); + QTRY_COMPARE(item->y(), i*20.); + } + + QVariant heightRatio; + QMetaObject::invokeMethod(canvas->rootObject(), "heightRatio", Q_RETURN_ARG(QVariant, heightRatio)); + QCOMPARE(heightRatio.toReal(), 0.4); + + listview->setHeight(200); + QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false); + + QMetaObject::invokeMethod(canvas->rootObject(), "heightRatio", Q_RETURN_ARG(QVariant, heightRatio)); + QCOMPARE(heightRatio.toReal(), 0.25); + + // Ensure we handle -ve sizes + listview->setHeight(-100); + QTRY_COMPARE(findItems(contentItem, "wrapper", false).count(), 1); + + listview->setCacheBuffer(200); + QTRY_COMPARE(findItems(contentItem, "wrapper", false).count(), 11); + + // ensure items in cache become visible + listview->setHeight(200); + QTRY_COMPARE(findItems(contentItem, "wrapper", false).count(), 21); + + itemCount = findItems(contentItem, "wrapper", false).count(); + for (int i = 0; i < model.count() && i < itemCount; ++i) { + QQuickItem *item = findItem(contentItem, "wrapper", i); + if (!item) qWarning() << "Item" << i << "not found"; + QTRY_VERIFY(item); + QTRY_COMPARE(item->y(), i*20.); + QCOMPARE(item->isVisible(), i < 11); // inside view visible, outside not visible + } + + // ensure items outside view become invisible + listview->setHeight(100); + QTRY_COMPARE(findItems(contentItem, "wrapper", false).count(), 16); + + itemCount = findItems(contentItem, "wrapper", false).count(); + for (int i = 0; i < model.count() && i < itemCount; ++i) { + QQuickItem *item = findItem(contentItem, "wrapper", i); + if (!item) qWarning() << "Item" << i << "not found"; + QTRY_VERIFY(item); + QTRY_COMPARE(item->y(), i*20.); + QCOMPARE(item->isVisible(), i < 6); // inside view visible, outside not visible + } + + delete canvas; + delete testObject; +} + +void tst_QQuickListView::resizeViewAndRepaint() +{ + QQuickView *canvas = createView(); + + QmlListModel model; + for (int i = 0; i < 40; i++) + model.addItem("Item" + QString::number(i), ""); + + QQmlContext *ctxt = canvas->rootContext(); + ctxt->setContextProperty("testModel", &model); + ctxt->setContextProperty("initialHeight", 100); + + canvas->setSource(testFileUrl("resizeview.qml")); + canvas->show(); + qApp->processEvents(); + + QQuickListView *listview = findItem(canvas->rootObject(), "list"); + QTRY_VERIFY(listview != 0); + QQuickItem *contentItem = listview->contentItem(); + QTRY_VERIFY(contentItem != 0); + QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false); + + // item at index 10 should not be currently visible + QVERIFY(!findItem(contentItem, "wrapper", 10)); + + listview->setHeight(320); + + QTRY_VERIFY(findItem(contentItem, "wrapper", 10)); + + listview->setHeight(100); + QTRY_VERIFY(!findItem(contentItem, "wrapper", 10)); + + delete canvas; +} + +void tst_QQuickListView::sizeLessThan1() +{ + QQuickView *canvas = createView(); + + QmlListModel model; + for (int i = 0; i < 30; i++) + model.addItem("Item" + QString::number(i), ""); + + QQmlContext *ctxt = canvas->rootContext(); + ctxt->setContextProperty("testModel", &model); + + TestObject *testObject = new TestObject; + ctxt->setContextProperty("testObject", testObject); + + canvas->setSource(testFileUrl("sizelessthan1.qml")); + canvas->show(); + qApp->processEvents(); + + QQuickListView *listview = findItem(canvas->rootObject(), "list"); + QTRY_VERIFY(listview != 0); + QQuickItem *contentItem = listview->contentItem(); + QTRY_VERIFY(contentItem != 0); + QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false); + + // Confirm items positioned correctly + int itemCount = findItems(contentItem, "wrapper").count(); + for (int i = 0; i < model.count() && i < itemCount; ++i) { + QQuickItem *item = findItem(contentItem, "wrapper", i); + if (!item) qWarning() << "Item" << i << "not found"; + QTRY_VERIFY(item); + QTRY_COMPARE(item->y(), i*0.5); + } + + delete canvas; + delete testObject; +} + +void tst_QQuickListView::QTBUG_14821() +{ + QQuickView *canvas = createView(); + + canvas->setSource(testFileUrl("qtbug14821.qml")); + qApp->processEvents(); + + QQuickListView *listview = qobject_cast(canvas->rootObject()); + QVERIFY(listview != 0); + + QQuickItem *contentItem = listview->contentItem(); + QVERIFY(contentItem != 0); + + listview->decrementCurrentIndex(); + QCOMPARE(listview->currentIndex(), 99); + + listview->incrementCurrentIndex(); + QCOMPARE(listview->currentIndex(), 0); + + delete canvas; +} + +void tst_QQuickListView::resizeDelegate() +{ + QQuickView *canvas = createView(); + + QStringList strings; + for (int i = 0; i < 30; ++i) + strings << QString::number(i); + QStringListModel model(strings); + + QQmlContext *ctxt = canvas->rootContext(); + ctxt->setContextProperty("testModel", &model); + + canvas->setSource(testFileUrl("displaylist.qml")); + canvas->show(); + qApp->processEvents(); + + QQuickListView *listview = findItem(canvas->rootObject(), "list"); + QVERIFY(listview != 0); + QQuickItem *contentItem = listview->contentItem(); + QVERIFY(contentItem != 0); + QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false); + + QCOMPARE(listview->count(), model.rowCount()); + + listview->setCurrentIndex(25); + listview->setContentY(0); + QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false); + + for (int i = 0; i < 16; ++i) { + QQuickItem *item = findItem(contentItem, "wrapper", i); + QVERIFY(item != 0); + QCOMPARE(item->y(), i*20.0); + } + + QCOMPARE(listview->currentItem()->y(), 500.0); + QTRY_COMPARE(listview->highlightItem()->y(), 500.0); + + canvas->rootObject()->setProperty("delegateHeight", 30); + QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false); + + for (int i = 0; i < 11; ++i) { + QQuickItem *item = findItem(contentItem, "wrapper", i); + QVERIFY(item != 0); + QTRY_COMPARE(item->y(), i*30.0); + } + + QTRY_COMPARE(listview->currentItem()->y(), 750.0); + QTRY_COMPARE(listview->highlightItem()->y(), 750.0); + + listview->setCurrentIndex(1); + listview->positionViewAtIndex(25, QQuickListView::Beginning); + listview->positionViewAtIndex(5, QQuickListView::Beginning); + QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false); + + for (int i = 5; i < 16; ++i) { + QQuickItem *item = findItem(contentItem, "wrapper", i); + QVERIFY(item != 0); + QCOMPARE(item->y(), i*30.0); + } + + QTRY_COMPARE(listview->currentItem()->y(), 30.0); + QTRY_COMPARE(listview->highlightItem()->y(), 30.0); + + canvas->rootObject()->setProperty("delegateHeight", 20); + QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false); + + for (int i = 5; i < 11; ++i) { + QQuickItem *item = findItem(contentItem, "wrapper", i); + QVERIFY(item != 0); + QTRY_COMPARE(item->y(), 150 + (i-5)*20.0); + } + + QTRY_COMPARE(listview->currentItem()->y(), 70.0); + QTRY_COMPARE(listview->highlightItem()->y(), 70.0); + + delete canvas; +} + +void tst_QQuickListView::resizeFirstDelegate() +{ + // QTBUG-20712: Content Y jumps constantly if first delegate height == 0 + // and other delegates have height > 0 + + QQuickView *canvas = createView(); + + // bug only occurs when all items in the model are visible + QmlListModel model; + for (int i = 0; i < 10; i++) + model.addItem("Item" + QString::number(i), ""); + + QQmlContext *ctxt = canvas->rootContext(); + ctxt->setContextProperty("testModel", &model); + + TestObject *testObject = new TestObject; + ctxt->setContextProperty("testObject", testObject); + + canvas->setSource(testFileUrl("listviewtest.qml")); + canvas->show(); + qApp->processEvents(); + + QQuickListView *listview = findItem(canvas->rootObject(), "list"); + QVERIFY(listview != 0); + QQuickItem *contentItem = listview->contentItem(); + QVERIFY(contentItem != 0); + QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false); + + QQuickItem *item = 0; + for (int i = 0; i < model.count(); ++i) { + item = findItem(contentItem, "wrapper", i); + QVERIFY(item != 0); + QCOMPARE(item->y(), i*20.0); + } + + item = findItem(contentItem, "wrapper", 0); + item->setHeight(0); + + // check the content y has not jumped up and down + QCOMPARE(listview->contentY(), 0.0); + QSignalSpy spy(listview, SIGNAL(contentYChanged())); + QTest::qWait(100); + QCOMPARE(spy.count(), 0); + + for (int i = 1; i < model.count(); ++i) { + item = findItem(contentItem, "wrapper", i); + QVERIFY(item != 0); + QTRY_COMPARE(item->y(), (i-1)*20.0); + } + + + // QTBUG-22014: refill doesn't clear items scrolling off the top of the + // list if they follow a zero-sized delegate + + for (int i = 0; i < 10; i++) + model.addItem("Item" + QString::number(i), ""); + QTRY_COMPARE(listview->count(), model.count()); + + item = findItem(contentItem, "wrapper", 1); + QVERIFY(item); + item->setHeight(0); + + listview->setCurrentIndex(19); + qApp->processEvents(); + QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false); + + // items 0-2 should have been deleted + for (int i=0; i<3; i++) { + QTRY_VERIFY(!findItem(contentItem, "wrapper", i)); + } + + delete testObject; + delete canvas; +} + +void tst_QQuickListView::QTBUG_16037() +{ + QQuickView *canvas = createView(); + canvas->show(); + + canvas->setSource(testFileUrl("qtbug16037.qml")); + qApp->processEvents(); + + QQuickListView *listview = findItem(canvas->rootObject(), "listview"); + QTRY_VERIFY(listview != 0); + + QVERIFY(listview->contentHeight() <= 0.0); + + QMetaObject::invokeMethod(canvas->rootObject(), "setModel"); + + QTRY_COMPARE(listview->contentHeight(), 80.0); + + delete canvas; +} + +void tst_QQuickListView::indexAt_itemAt_data() +{ + QTest::addColumn("x"); + QTest::addColumn("y"); + QTest::addColumn("index"); + + QTest::newRow("Item 0 - 0, 0") << 0. << 0. << 0; + QTest::newRow("Item 0 - 0, 19") << 0. << 19. << 0; + QTest::newRow("Item 0 - 239, 19") << 239. << 19. << 0; + QTest::newRow("Item 1 - 0, 20") << 0. << 20. << 1; + QTest::newRow("No Item - 240, 20") << 240. << 20. << -1; +} + +void tst_QQuickListView::indexAt_itemAt() +{ + QFETCH(qreal, x); + QFETCH(qreal, y); + QFETCH(int, index); + + QQuickView *canvas = createView(); + + QmlListModel model; + for (int i = 0; i < 30; i++) + model.addItem("Item" + QString::number(i), ""); + + QQmlContext *ctxt = canvas->rootContext(); + ctxt->setContextProperty("testModel", &model); + + TestObject *testObject = new TestObject; + ctxt->setContextProperty("testObject", testObject); + + canvas->setSource(testFileUrl("listviewtest.qml")); + canvas->show(); + qApp->processEvents(); + + QQuickListView *listview = findItem(canvas->rootObject(), "list"); + QTRY_VERIFY(listview != 0); + + QQuickItem *contentItem = listview->contentItem(); + QTRY_VERIFY(contentItem != 0); + QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false); + + QQuickItem *item = 0; + if (index >= 0) { + item = findItem(contentItem, "wrapper", index); + QVERIFY(item); + } + QCOMPARE(listview->indexAt(x,y), index); + QVERIFY(listview->itemAt(x,y) == item); + + delete canvas; + delete testObject; +} + +void tst_QQuickListView::incrementalModel() +{ + QQuickView *canvas = createView(); + + IncrementalModel model; + QQmlContext *ctxt = canvas->rootContext(); + ctxt->setContextProperty("testModel", &model); + + canvas->setSource(testFileUrl("displaylist.qml")); + qApp->processEvents(); + + QQuickListView *listview = findItem(canvas->rootObject(), "list"); + QTRY_VERIFY(listview != 0); + + QQuickItem *contentItem = listview->contentItem(); + QTRY_VERIFY(contentItem != 0); + + QTRY_COMPARE(listview->count(), 20); + + listview->positionViewAtIndex(10, QQuickListView::Beginning); + + QTRY_COMPARE(listview->count(), 25); + + delete canvas; +} + +void tst_QQuickListView::onAdd() +{ + QFETCH(int, initialItemCount); + QFETCH(int, itemsToAdd); + + const int delegateHeight = 10; + QaimModel model; + + // these initial items should not trigger ListView.onAdd + for (int i=0; isetGeometry(0,0,200, delegateHeight * (initialItemCount + itemsToAdd)); + QQmlContext *ctxt = canvas->rootContext(); + ctxt->setContextProperty("testModel", &model); + ctxt->setContextProperty("delegateHeight", delegateHeight); + canvas->setSource(testFileUrl("attachedSignals.qml")); + + QObject *object = canvas->rootObject(); + object->setProperty("width", canvas->width()); + object->setProperty("height", canvas->height()); + qApp->processEvents(); + + QList > items; + for (int i=0; irootObject()->property("count").toInt(), model.count()); + + QVariantList result = object->property("addedDelegates").toList(); + QCOMPARE(result.count(), items.count()); + for (int i=0; i("initialItemCount"); + QTest::addColumn("itemsToAdd"); + + QTest::newRow("0, add 1") << 0 << 1; + QTest::newRow("0, add 2") << 0 << 2; + QTest::newRow("0, add 10") << 0 << 10; + + QTest::newRow("1, add 1") << 1 << 1; + QTest::newRow("1, add 2") << 1 << 2; + QTest::newRow("1, add 10") << 1 << 10; + + QTest::newRow("5, add 1") << 5 << 1; + QTest::newRow("5, add 2") << 5 << 2; + QTest::newRow("5, add 10") << 5 << 10; +} + +void tst_QQuickListView::onRemove() +{ + QFETCH(int, initialItemCount); + QFETCH(int, indexToRemove); + QFETCH(int, removeCount); + + const int delegateHeight = 10; + QaimModel model; + for (int i=0; irootContext(); + ctxt->setContextProperty("testModel", &model); + ctxt->setContextProperty("delegateHeight", delegateHeight); + canvas->setSource(testFileUrl("attachedSignals.qml")); + + QObject *object = canvas->rootObject(); + + model.removeItems(indexToRemove, removeCount); + QTRY_COMPARE(canvas->rootObject()->property("count").toInt(), model.count()); + + QCOMPARE(object->property("removedDelegateCount"), QVariant(removeCount)); + + delete canvas; +} + +void tst_QQuickListView::onRemove_data() +{ + QTest::addColumn("initialItemCount"); + QTest::addColumn("indexToRemove"); + QTest::addColumn("removeCount"); + + QTest::newRow("remove first") << 1 << 0 << 1; + QTest::newRow("two items, remove first") << 2 << 0 << 1; + QTest::newRow("two items, remove last") << 2 << 1 << 1; + QTest::newRow("two items, remove all") << 2 << 0 << 2; + + QTest::newRow("four items, remove first") << 4 << 0 << 1; + QTest::newRow("four items, remove 0-2") << 4 << 0 << 2; + QTest::newRow("four items, remove 1-3") << 4 << 1 << 2; + QTest::newRow("four items, remove 2-4") << 4 << 2 << 2; + QTest::newRow("four items, remove last") << 4 << 3 << 1; + QTest::newRow("four items, remove all") << 4 << 0 << 4; + + QTest::newRow("ten items, remove 1-8") << 10 << 0 << 8; + QTest::newRow("ten items, remove 2-7") << 10 << 2 << 5; + QTest::newRow("ten items, remove 4-10") << 10 << 4 << 6; +} + +void tst_QQuickListView::rightToLeft() +{ + QQuickView *canvas = createView(); + canvas->setGeometry(0,0,640,320); + canvas->setSource(testFileUrl("rightToLeft.qml")); + canvas->show(); + qApp->processEvents(); + + QVERIFY(canvas->rootObject() != 0); + QQuickListView *listview = findItem(canvas->rootObject(), "view"); + QTRY_VERIFY(listview != 0); + + QQuickItem *contentItem = listview->contentItem(); + QTRY_VERIFY(contentItem != 0); + + QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false); + + QQuickVisualItemModel *model = canvas->rootObject()->findChild("itemModel"); + QTRY_VERIFY(model != 0); + + QTRY_VERIFY(model->count() == 3); + QTRY_COMPARE(listview->currentIndex(), 0); + + // initial position at first item, right edge aligned + QCOMPARE(listview->contentX(), -640.); + + QQuickItem *item = findItem(contentItem, "item1"); + QTRY_VERIFY(item); + QTRY_COMPARE(item->x(), -100.0); + QCOMPARE(item->height(), listview->height()); + + QQuickText *text = findItem(contentItem, "text1"); + QTRY_VERIFY(text); + QTRY_COMPARE(text->text(), QLatin1String("index: 0")); + + listview->setCurrentIndex(2); + + item = findItem(contentItem, "item3"); + QTRY_VERIFY(item); + QTRY_COMPARE(item->x(), -540.0); + + text = findItem(contentItem, "text3"); + QTRY_VERIFY(text); + QTRY_COMPARE(text->text(), QLatin1String("index: 2")); + + QCOMPARE(listview->contentX(), -640.); + + // Ensure resizing maintains position relative to right edge + qobject_cast(canvas->rootObject())->setWidth(600); + QTRY_COMPARE(listview->contentX(), -600.); + + delete canvas; +} + +void tst_QQuickListView::test_mirroring() +{ + QQuickView *canvasA = createView(); + canvasA->setSource(testFileUrl("rightToLeft.qml")); + QQuickListView *listviewA = findItem(canvasA->rootObject(), "view"); + QTRY_VERIFY(listviewA != 0); + + QQuickView *canvasB = createView(); + canvasB->setSource(testFileUrl("rightToLeft.qml")); + QQuickListView *listviewB = findItem(canvasB->rootObject(), "view"); + QTRY_VERIFY(listviewA != 0); + qApp->processEvents(); + + QList objectNames; + objectNames << "item1" << "item2"; // << "item3" + + listviewA->setProperty("layoutDirection", Qt::LeftToRight); + listviewB->setProperty("layoutDirection", Qt::RightToLeft); + QCOMPARE(listviewA->layoutDirection(), listviewA->effectiveLayoutDirection()); + + // LTR != RTL + foreach (const QString objectName, objectNames) + QVERIFY(findItem(listviewA, objectName)->x() != findItem(listviewB, objectName)->x()); + + listviewA->setProperty("layoutDirection", Qt::LeftToRight); + listviewB->setProperty("layoutDirection", Qt::LeftToRight); + + // LTR == LTR + foreach (const QString objectName, objectNames) + QCOMPARE(findItem(listviewA, objectName)->x(), findItem(listviewB, objectName)->x()); + + QVERIFY(listviewB->layoutDirection() == listviewB->effectiveLayoutDirection()); + QQuickItemPrivate::get(listviewB)->setLayoutMirror(true); + QVERIFY(listviewB->layoutDirection() != listviewB->effectiveLayoutDirection()); + + // LTR != LTR+mirror + foreach (const QString objectName, objectNames) + QVERIFY(findItem(listviewA, objectName)->x() != findItem(listviewB, objectName)->x()); + + listviewA->setProperty("layoutDirection", Qt::RightToLeft); + + // RTL == LTR+mirror + foreach (const QString objectName, objectNames) + QCOMPARE(findItem(listviewA, objectName)->x(), findItem(listviewB, objectName)->x()); + + listviewB->setProperty("layoutDirection", Qt::RightToLeft); + + // RTL != RTL+mirror + foreach (const QString objectName, objectNames) + QVERIFY(findItem(listviewA, objectName)->x() != findItem(listviewB, objectName)->x()); + + listviewA->setProperty("layoutDirection", Qt::LeftToRight); + + // LTR == RTL+mirror + foreach (const QString objectName, objectNames) + QCOMPARE(findItem(listviewA, objectName)->x(), findItem(listviewB, objectName)->x()); + + delete canvasA; + delete canvasB; +} + +void tst_QQuickListView::margins() +{ + QQuickView *canvas = createView(); + + QaimModel model; + for (int i = 0; i < 50; i++) + model.addItem("Item" + QString::number(i), ""); + + QQmlContext *ctxt = canvas->rootContext(); + ctxt->setContextProperty("testModel", &model); + + canvas->setSource(testFileUrl("margins.qml")); + canvas->show(); + qApp->processEvents(); + + QQuickListView *listview = findItem(canvas->rootObject(), "list"); + QTRY_VERIFY(listview != 0); + QQuickItem *contentItem = listview->contentItem(); + QTRY_VERIFY(contentItem != 0); + QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false); + + QCOMPARE(listview->contentY(), -30.); + QCOMPARE(listview->yOrigin(), 0.); + + // check end bound + listview->positionViewAtEnd(); + qreal pos = listview->contentY(); + listview->setContentY(pos + 80); + QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false); + listview->returnToBounds(); + QTRY_COMPARE(listview->contentY(), pos + 50); + + // remove item before visible and check that top margin is maintained + // and yOrigin is updated + listview->setContentY(100); + model.removeItem(1); + QTRY_COMPARE(listview->count(), model.count()); + listview->setContentY(-50); + QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false); + listview->returnToBounds(); + QCOMPARE(listview->yOrigin(), 20.); + QTRY_COMPARE(listview->contentY(), -10.); + + // reduce top margin + listview->setTopMargin(20); + QCOMPARE(listview->yOrigin(), 20.); + QTRY_COMPARE(listview->contentY(), 0.); + + // check end bound + listview->positionViewAtEnd(); + pos = listview->contentY(); + listview->setContentY(pos + 80); + listview->returnToBounds(); + QTRY_COMPARE(listview->contentY(), pos + 50); + + // reduce bottom margin + pos = listview->contentY(); + listview->setBottomMargin(40); + QCOMPARE(listview->yOrigin(), 20.); + QTRY_COMPARE(listview->contentY(), pos-10); + + delete canvas; +} + +// QTBUG-24028 +void tst_QQuickListView::marginsResize() +{ + QFETCH(QQuickListView::Orientation, orientation); + QFETCH(Qt::LayoutDirection, layoutDirection); + QFETCH(qreal, start); + QFETCH(qreal, end); + + QQuickView *canvas = createView(); + + canvas->setSource(testFileUrl("margins2.qml")); + canvas->show(); + qApp->processEvents(); + + QQuickListView *listview = findItem(canvas->rootObject(), "listview"); + QTRY_VERIFY(listview != 0); + + listview->setOrientation(orientation); + listview->setLayoutDirection(layoutDirection); + QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false); + + // view is resized after componentCompleted - top margin should still be visible + if (orientation == QQuickListView::Vertical) + QCOMPARE(listview->contentY(), start); + else + QCOMPARE(listview->contentX(), start); + + // move to last index and ensure bottom margin is visible. + listview->setCurrentIndex(19); + if (orientation == QQuickListView::Vertical) + QTRY_COMPARE(listview->contentY(), end); + else + QTRY_COMPARE(listview->contentX(), end); + + // back to top - top margin should be visible. + listview->setCurrentIndex(0); + if (orientation == QQuickListView::Vertical) + QTRY_COMPARE(listview->contentY(), start); + else + QTRY_COMPARE(listview->contentX(), start); + + delete canvas; +} + +void tst_QQuickListView::marginsResize_data() +{ + QTest::addColumn("orientation"); + QTest::addColumn("layoutDirection"); + QTest::addColumn("start"); + QTest::addColumn("end"); + + QTest::newRow("vertical") << QQuickListView::Vertical << Qt::LeftToRight << -20.0 << 1020.0; + QTest::newRow("horizontal") << QQuickListView::Horizontal << Qt::LeftToRight << -20.0 << 1020.0; + QTest::newRow("horizontal, rtl") << QQuickListView::Horizontal << Qt::RightToLeft << -180.0 << -1220.0; +} + +void tst_QQuickListView::snapToItem_data() +{ + QTest::addColumn("orientation"); + QTest::addColumn("layoutDirection"); + QTest::addColumn("highlightRangeMode"); + QTest::addColumn("flickStart"); + QTest::addColumn("flickEnd"); + QTest::addColumn("snapAlignment"); + QTest::addColumn("endExtent"); + QTest::addColumn("startExtent"); + + QTest::newRow("vertical, left to right") << QQuickListView::Vertical << Qt::LeftToRight << int(QQuickItemView::NoHighlightRange) + << QPoint(20, 200) << QPoint(20, 20) << 60.0 << 1200.0 << 0.0; + + QTest::newRow("horizontal, left to right") << QQuickListView::Horizontal << Qt::LeftToRight << int(QQuickItemView::NoHighlightRange) + << QPoint(200, 20) << QPoint(20, 20) << 60.0 << 1200.0 << 0.0; + + QTest::newRow("horizontal, right to left") << QQuickListView::Horizontal << Qt::RightToLeft << int(QQuickItemView::NoHighlightRange) + << QPoint(20, 20) << QPoint(200, 20) << -60.0 << -1200.0 - 240.0 << -240.0; + + QTest::newRow("vertical, left to right, enforce range") << QQuickListView::Vertical << Qt::LeftToRight << int(QQuickItemView::StrictlyEnforceRange) + << QPoint(20, 200) << QPoint(20, 20) << 60.0 << 1340.0 << -20.0; + + QTest::newRow("horizontal, left to right, enforce range") << QQuickListView::Horizontal << Qt::LeftToRight << int(QQuickItemView::StrictlyEnforceRange) + << QPoint(200, 20) << QPoint(20, 20) << 60.0 << 1340.0 << -20.0; + + QTest::newRow("horizontal, right to left, enforce range") << QQuickListView::Horizontal << Qt::RightToLeft << int(QQuickItemView::StrictlyEnforceRange) + << QPoint(20, 20) << QPoint(200, 20) << -60.0 << -1200.0 - 240.0 - 140.0 << -220.0; +} + +void tst_QQuickListView::snapToItem() +{ + QFETCH(QQuickListView::Orientation, orientation); + QFETCH(Qt::LayoutDirection, layoutDirection); + QFETCH(int, highlightRangeMode); + QFETCH(QPoint, flickStart); + QFETCH(QPoint, flickEnd); + QFETCH(qreal, snapAlignment); + QFETCH(qreal, endExtent); + QFETCH(qreal, startExtent); + + QQuickView *canvas = createView(); + + canvas->setSource(testFileUrl("snapToItem.qml")); + canvas->show(); + qApp->processEvents(); + + QQuickListView *listview = findItem(canvas->rootObject(), "list"); + QTRY_VERIFY(listview != 0); + + listview->setOrientation(orientation); + listview->setLayoutDirection(layoutDirection); + listview->setHighlightRangeMode(QQuickItemView::HighlightRangeMode(highlightRangeMode)); + QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false); + + QQuickItem *contentItem = listview->contentItem(); + QTRY_VERIFY(contentItem != 0); + + // confirm that a flick hits an item boundary + flick(canvas, flickStart, flickEnd, 180); + QTRY_VERIFY(listview->isMoving() == false); // wait until it stops + if (orientation == QQuickListView::Vertical) + QCOMPARE(qreal(fmod(listview->contentY(),80.0)), snapAlignment); + else + QCOMPARE(qreal(fmod(listview->contentX(),80.0)), snapAlignment); + + // flick to end + do { + flick(canvas, flickStart, flickEnd, 180); + QTRY_VERIFY(listview->isMoving() == false); // wait until it stops + } while (orientation == QQuickListView::Vertical + ? !listview->isAtYEnd() + : layoutDirection == Qt::LeftToRight ? !listview->isAtXEnd() : !listview->isAtXBeginning()); + + if (orientation == QQuickListView::Vertical) + QCOMPARE(listview->contentY(), endExtent); + else + QCOMPARE(listview->contentX(), endExtent); + + // flick to start + do { + flick(canvas, flickEnd, flickStart, 180); + QTRY_VERIFY(listview->isMoving() == false); // wait until it stops + } while (orientation == QQuickListView::Vertical + ? !listview->isAtYBeginning() + : layoutDirection == Qt::LeftToRight ? !listview->isAtXBeginning() : !listview->isAtXEnd()); + + if (orientation == QQuickListView::Vertical) + QCOMPARE(listview->contentY(), startExtent); + else + QCOMPARE(listview->contentX(), startExtent); + + delete canvas; +} + +void tst_QQuickListView::qListModelInterface_items() +{ + items(testFileUrl("listviewtest.qml"), false); +} + +void tst_QQuickListView::qListModelInterface_package_items() +{ + items(testFileUrl("listviewtest-package.qml"), true); +} + +void tst_QQuickListView::qAbstractItemModel_items() +{ + items(testFileUrl("listviewtest.qml"), false); +} + +void tst_QQuickListView::qListModelInterface_changed() +{ + changed(testFileUrl("listviewtest.qml"), false); +} + +void tst_QQuickListView::qListModelInterface_package_changed() +{ + changed(testFileUrl("listviewtest-package.qml"), true); +} + +void tst_QQuickListView::qAbstractItemModel_changed() +{ + changed(testFileUrl("listviewtest.qml"), false); +} + +void tst_QQuickListView::qListModelInterface_inserted() +{ + inserted(testFileUrl("listviewtest.qml")); +} + +void tst_QQuickListView::qListModelInterface_package_inserted() +{ + inserted(testFileUrl("listviewtest-package.qml")); +} + +void tst_QQuickListView::qListModelInterface_inserted_more() +{ + inserted_more(); +} + +void tst_QQuickListView::qListModelInterface_inserted_more_data() +{ + inserted_more_data(); +} + +void tst_QQuickListView::qAbstractItemModel_inserted() +{ + inserted(testFileUrl("listviewtest.qml")); +} + +void tst_QQuickListView::qAbstractItemModel_inserted_more() +{ + inserted_more(); +} + +void tst_QQuickListView::qAbstractItemModel_inserted_more_data() +{ + inserted_more_data(); +} + +void tst_QQuickListView::qListModelInterface_removed() +{ + removed(testFileUrl("listviewtest.qml"), false); + removed(testFileUrl("listviewtest.qml"), true); +} + +void tst_QQuickListView::qListModelInterface_removed_more() +{ + removed_more(testFileUrl("listviewtest.qml")); +} + +void tst_QQuickListView::qListModelInterface_removed_more_data() +{ + removed_more_data(); +} + +void tst_QQuickListView::qListModelInterface_package_removed() +{ + removed(testFileUrl("listviewtest-package.qml"), false); + removed(testFileUrl("listviewtest-package.qml"), true); +} + +void tst_QQuickListView::qAbstractItemModel_removed() +{ + removed(testFileUrl("listviewtest.qml"), false); + removed(testFileUrl("listviewtest.qml"), true); +} + +void tst_QQuickListView::qAbstractItemModel_removed_more() +{ + removed_more(testFileUrl("listviewtest.qml")); +} + +void tst_QQuickListView::qAbstractItemModel_removed_more_data() +{ + removed_more_data(); +} + +void tst_QQuickListView::qListModelInterface_moved() +{ + moved(testFileUrl("listviewtest.qml")); +} + +void tst_QQuickListView::qListModelInterface_moved_data() +{ + moved_data(); +} + +void tst_QQuickListView::qListModelInterface_package_moved() +{ + moved(testFileUrl("listviewtest-package.qml")); +} + +void tst_QQuickListView::qListModelInterface_package_moved_data() +{ + moved_data(); +} + +void tst_QQuickListView::qAbstractItemModel_moved() +{ + moved(testFileUrl("listviewtest.qml")); +} + +void tst_QQuickListView::qAbstractItemModel_moved_data() +{ + moved_data(); +} + +void tst_QQuickListView::qListModelInterface_clear() +{ + clear(testFileUrl("listviewtest.qml")); +} + +void tst_QQuickListView::qListModelInterface_package_clear() +{ + clear(testFileUrl("listviewtest-package.qml")); +} + +void tst_QQuickListView::qAbstractItemModel_clear() +{ + clear(testFileUrl("listviewtest.qml")); +} + +void tst_QQuickListView::qListModelInterface_sections() +{ + sections(testFileUrl("listview-sections.qml")); +} + +void tst_QQuickListView::qListModelInterface_package_sections() +{ + sections(testFileUrl("listview-sections-package.qml")); +} + +void tst_QQuickListView::qAbstractItemModel_sections() +{ + sections(testFileUrl("listview-sections.qml")); +} + +void tst_QQuickListView::creationContext() +{ + QQuickView canvas; + canvas.setGeometry(0,0,240,320); + canvas.setSource(testFileUrl("creationContext.qml")); + qApp->processEvents(); + + QQuickItem *rootItem = qobject_cast(canvas.rootObject()); + QVERIFY(rootItem); + QVERIFY(rootItem->property("count").toInt() > 0); + + QQuickItem *item; + QVERIFY(item = rootItem->findChild("listItem")); + QCOMPARE(item->property("text").toString(), QString("Hello!")); + QVERIFY(item = rootItem->findChild("header")); + QCOMPARE(item->property("text").toString(), QString("Hello!")); + QVERIFY(item = rootItem->findChild("footer")); + QCOMPARE(item->property("text").toString(), QString("Hello!")); + QVERIFY(item = rootItem->findChild("section")); + QCOMPARE(item->property("text").toString(), QString("Hello!")); +} + +void tst_QQuickListView::QTBUG_21742() +{ + QQuickView canvas; + canvas.setGeometry(0,0,200,200); + canvas.setSource(testFileUrl("qtbug-21742.qml")); + qApp->processEvents(); + + QQuickItem *rootItem = qobject_cast(canvas.rootObject()); + QVERIFY(rootItem); + QCOMPARE(rootItem->property("count").toInt(), 1); +} + +void tst_QQuickListView::asynchronous() +{ + QQuickView *canvas = createView(); + canvas->show(); + QQmlIncubationController controller; + canvas->engine()->setIncubationController(&controller); + + canvas->setSource(testFileUrl("asyncloader.qml")); + + QQuickItem *rootObject = qobject_cast(canvas->rootObject()); + QVERIFY(rootObject); + + QQuickListView *listview = 0; + while (!listview) { + bool b = false; + controller.incubateWhile(&b); + listview = rootObject->findChild("view"); + } + + // items will be created one at a time + for (int i = 0; i < 8; ++i) { + QVERIFY(findItem(listview, "wrapper", i) == 0); + QQuickItem *item = 0; + while (!item) { + bool b = false; + controller.incubateWhile(&b); + item = findItem(listview, "wrapper", i); + } + } + + { + bool b = true; + controller.incubateWhile(&b); + } + + // verify positioning + QQuickItem *contentItem = listview->contentItem(); + for (int i = 0; i < 8; ++i) { + QQuickItem *item = findItem(contentItem, "wrapper", i); + QTRY_COMPARE(item->y(), i*50.0); + } + + delete canvas; +} + +void tst_QQuickListView::snapOneItem_data() +{ + QTest::addColumn("orientation"); + QTest::addColumn("layoutDirection"); + QTest::addColumn("highlightRangeMode"); + QTest::addColumn("flickStart"); + QTest::addColumn("flickEnd"); + QTest::addColumn("snapAlignment"); + QTest::addColumn("endExtent"); + QTest::addColumn("startExtent"); + + QTest::newRow("vertical, left to right") << QQuickListView::Vertical << Qt::LeftToRight << int(QQuickItemView::NoHighlightRange) + << QPoint(20, 200) << QPoint(20, 20) << 180.0 << 560.0 << 0.0; + + QTest::newRow("horizontal, left to right") << QQuickListView::Horizontal << Qt::LeftToRight << int(QQuickItemView::NoHighlightRange) + << QPoint(200, 20) << QPoint(20, 20) << 180.0 << 560.0 << 0.0; + + QTest::newRow("horizontal, right to left") << QQuickListView::Horizontal << Qt::RightToLeft << int(QQuickItemView::NoHighlightRange) + << QPoint(20, 20) << QPoint(200, 20) << -420.0 << -560.0 - 240.0 << -240.0; + + QTest::newRow("vertical, left to right, enforce range") << QQuickListView::Vertical << Qt::LeftToRight << int(QQuickItemView::StrictlyEnforceRange) + << QPoint(20, 200) << QPoint(20, 20) << 180.0 << 580.0 << -20.0; + + QTest::newRow("horizontal, left to right, enforce range") << QQuickListView::Horizontal << Qt::LeftToRight << int(QQuickItemView::StrictlyEnforceRange) + << QPoint(200, 20) << QPoint(20, 20) << 180.0 << 580.0 << -20.0; + + QTest::newRow("horizontal, right to left, enforce range") << QQuickListView::Horizontal << Qt::RightToLeft << int(QQuickItemView::StrictlyEnforceRange) + << QPoint(20, 20) << QPoint(200, 20) << -420.0 << -580.0 - 240.0 << -220.0; +} + +void tst_QQuickListView::snapOneItem() +{ + QFETCH(QQuickListView::Orientation, orientation); + QFETCH(Qt::LayoutDirection, layoutDirection); + QFETCH(int, highlightRangeMode); + QFETCH(QPoint, flickStart); + QFETCH(QPoint, flickEnd); + QFETCH(qreal, snapAlignment); + QFETCH(qreal, endExtent); + QFETCH(qreal, startExtent); + +#ifdef Q_OS_MAC + // This test seems to be unreliable - different test data fails on different runs + QSKIP("QTBUG-24338"); +#endif + + QQuickView *canvas = createView(); + + canvas->setSource(testFileUrl("snapOneItem.qml")); + canvas->show(); + qApp->processEvents(); + + QQuickListView *listview = findItem(canvas->rootObject(), "list"); + QTRY_VERIFY(listview != 0); + + listview->setOrientation(orientation); + listview->setLayoutDirection(layoutDirection); + listview->setHighlightRangeMode(QQuickItemView::HighlightRangeMode(highlightRangeMode)); + QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false); + + QQuickItem *contentItem = listview->contentItem(); + QTRY_VERIFY(contentItem != 0); + + QSignalSpy currentIndexSpy(listview, SIGNAL(currentIndexChanged())); + + // confirm that a flick hits the next item boundary + flick(canvas, flickStart, flickEnd, 180); + QTRY_VERIFY(listview->isMoving() == false); // wait until it stops + if (orientation == QQuickListView::Vertical) + QCOMPARE(listview->contentY(), snapAlignment); + else + QCOMPARE(listview->contentX(), snapAlignment); + + if (QQuickItemView::HighlightRangeMode(highlightRangeMode) == QQuickItemView::StrictlyEnforceRange) { + QCOMPARE(listview->currentIndex(), 1); + QCOMPARE(currentIndexSpy.count(), 1); + } + + // flick to end + do { + flick(canvas, flickStart, flickEnd, 180); + QTRY_VERIFY(listview->isMoving() == false); // wait until it stops + } while (orientation == QQuickListView::Vertical + ? !listview->isAtYEnd() + : layoutDirection == Qt::LeftToRight ? !listview->isAtXEnd() : !listview->isAtXBeginning()); + + if (orientation == QQuickListView::Vertical) + QCOMPARE(listview->contentY(), endExtent); + else + QCOMPARE(listview->contentX(), endExtent); + + if (QQuickItemView::HighlightRangeMode(highlightRangeMode) == QQuickItemView::StrictlyEnforceRange) { + QCOMPARE(listview->currentIndex(), 3); + QCOMPARE(currentIndexSpy.count(), 3); + } + + // flick to start + do { + flick(canvas, flickEnd, flickStart, 180); + QTRY_VERIFY(listview->isMoving() == false); // wait until it stops + } while (orientation == QQuickListView::Vertical + ? !listview->isAtYBeginning() + : layoutDirection == Qt::LeftToRight ? !listview->isAtXBeginning() : !listview->isAtXEnd()); + + if (orientation == QQuickListView::Vertical) + QCOMPARE(listview->contentY(), startExtent); + else + QCOMPARE(listview->contentX(), startExtent); + + if (QQuickItemView::HighlightRangeMode(highlightRangeMode) == QQuickItemView::StrictlyEnforceRange) { + QCOMPARE(listview->currentIndex(), 0); + QCOMPARE(currentIndexSpy.count(), 6); + } + + delete canvas; +} + +void tst_QQuickListView::unrequestedVisibility() +{ + QmlListModel model; + for (int i = 0; i < 30; i++) + model.addItem("Item" + QString::number(i), QString::number(i)); + + QQuickView *canvas = new QQuickView(0); + canvas->setGeometry(0,0,240,320); + + QQmlContext *ctxt = canvas->rootContext(); + ctxt->setContextProperty("testModel", &model); + ctxt->setContextProperty("testWrap", QVariant(false)); + + canvas->setSource(testFileUrl("unrequestedItems.qml")); + canvas->show(); + qApp->processEvents(); + + QQuickListView *leftview = findItem(canvas->rootObject(), "leftList"); + QTRY_VERIFY(leftview != 0); + + QQuickListView *rightview = findItem(canvas->rootObject(), "rightList"); + QTRY_VERIFY(rightview != 0); + + QQuickItem *leftContent = leftview->contentItem(); + QTRY_VERIFY(leftContent != 0); + + QQuickItem *rightContent = rightview->contentItem(); + QTRY_VERIFY(rightContent != 0); + + rightview->setCurrentIndex(20); + + QTRY_COMPARE(leftview->contentY(), 0.0); + QTRY_COMPARE(rightview->contentY(), 100.0); + + QQuickItem *item; + + QVERIFY(item = findItem(leftContent, "wrapper", 1)); + QCOMPARE(item->isVisible(), true); + QVERIFY(item = findItem(rightContent, "wrapper", 1)); + QCOMPARE(item->isVisible(), false); + + QVERIFY(item = findItem(leftContent, "wrapper", 19)); + QCOMPARE(item->isVisible(), false); + QVERIFY(item = findItem(rightContent, "wrapper", 19)); + QCOMPARE(item->isVisible(), true); + + QVERIFY(item = findItem(leftContent, "wrapper", 16)); + QCOMPARE(item->isVisible(), true); + QVERIFY(item = findItem(leftContent, "wrapper", 17)); + QCOMPARE(item->isVisible(), false); + QVERIFY(item = findItem(rightContent, "wrapper", 3)); + QCOMPARE(item->isVisible(), false); + QVERIFY(item = findItem(rightContent, "wrapper", 4)); + QCOMPARE(item->isVisible(), true); + + rightview->setCurrentIndex(0); + + QTRY_COMPARE(leftview->contentY(), 0.0); + QTRY_COMPARE(rightview->contentY(), 0.0); + + QVERIFY(item = findItem(leftContent, "wrapper", 1)); + QCOMPARE(item->isVisible(), true); + QVERIFY(item = findItem(rightContent, "wrapper", 1)); + QTRY_COMPARE(item->isVisible(), true); + + QVERIFY(!findItem(leftContent, "wrapper", 19)); + QVERIFY(!findItem(rightContent, "wrapper", 19)); + + leftview->setCurrentIndex(20); + + QTRY_COMPARE(leftview->contentY(), 100.0); + QTRY_COMPARE(rightview->contentY(), 0.0); + + QVERIFY(item = findItem(leftContent, "wrapper", 1)); + QTRY_COMPARE(item->isVisible(), false); + QVERIFY(item = findItem(rightContent, "wrapper", 1)); + QCOMPARE(item->isVisible(), true); + + QVERIFY(item = findItem(leftContent, "wrapper", 19)); + QCOMPARE(item->isVisible(), true); + QVERIFY(item = findItem(rightContent, "wrapper", 19)); + QCOMPARE(item->isVisible(), false); + + QVERIFY(item = findItem(leftContent, "wrapper", 3)); + QCOMPARE(item->isVisible(), false); + QVERIFY(item = findItem(leftContent, "wrapper", 4)); + QCOMPARE(item->isVisible(), true); + QVERIFY(item = findItem(rightContent, "wrapper", 16)); + QCOMPARE(item->isVisible(), true); + QVERIFY(item = findItem(rightContent, "wrapper", 17)); + QCOMPARE(item->isVisible(), false); + + model.moveItems(19, 1, 1); + QTRY_COMPARE(QQuickItemPrivate::get(leftview)->polishScheduled, false); + + QTRY_VERIFY(item = findItem(leftContent, "wrapper", 1)); + QCOMPARE(item->isVisible(), false); + QVERIFY(item = findItem(rightContent, "wrapper", 1)); + QCOMPARE(item->isVisible(), true); + + QVERIFY(item = findItem(leftContent, "wrapper", 19)); + QCOMPARE(item->isVisible(), true); + QVERIFY(item = findItem(rightContent, "wrapper", 19)); + QCOMPARE(item->isVisible(), false); + + QVERIFY(item = findItem(leftContent, "wrapper", 4)); + QCOMPARE(item->isVisible(), false); + QVERIFY(item = findItem(leftContent, "wrapper", 5)); + QCOMPARE(item->isVisible(), true); + QVERIFY(item = findItem(rightContent, "wrapper", 16)); + QCOMPARE(item->isVisible(), true); + QVERIFY(item = findItem(rightContent, "wrapper", 17)); + QCOMPARE(item->isVisible(), false); + + model.moveItems(3, 4, 1); + QTRY_COMPARE(QQuickItemPrivate::get(leftview)->polishScheduled, false); + + QVERIFY(item = findItem(leftContent, "wrapper", 4)); + QCOMPARE(item->isVisible(), false); + QVERIFY(item = findItem(leftContent, "wrapper", 5)); + QCOMPARE(item->isVisible(), true); + QVERIFY(item = findItem(rightContent, "wrapper", 16)); + QCOMPARE(item->isVisible(), true); + QVERIFY(item = findItem(rightContent, "wrapper", 17)); + QCOMPARE(item->isVisible(), false); + + model.moveItems(4, 3, 1); + QTRY_COMPARE(QQuickItemPrivate::get(leftview)->polishScheduled, false); + + QVERIFY(item = findItem(leftContent, "wrapper", 4)); + QCOMPARE(item->isVisible(), false); + QVERIFY(item = findItem(leftContent, "wrapper", 5)); + QCOMPARE(item->isVisible(), true); + QVERIFY(item = findItem(rightContent, "wrapper", 16)); + QCOMPARE(item->isVisible(), true); + QVERIFY(item = findItem(rightContent, "wrapper", 17)); + QCOMPARE(item->isVisible(), false); + + model.moveItems(16, 17, 1); + QTRY_COMPARE(QQuickItemPrivate::get(leftview)->polishScheduled, false); + + QVERIFY(item = findItem(leftContent, "wrapper", 4)); + QCOMPARE(item->isVisible(), false); + QVERIFY(item = findItem(leftContent, "wrapper", 5)); + QCOMPARE(item->isVisible(), true); + QVERIFY(item = findItem(rightContent, "wrapper", 16)); + QCOMPARE(item->isVisible(), true); + QVERIFY(item = findItem(rightContent, "wrapper", 17)); + QCOMPARE(item->isVisible(), false); + + model.moveItems(17, 16, 1); + QTRY_COMPARE(QQuickItemPrivate::get(leftview)->polishScheduled, false); + + QVERIFY(item = findItem(leftContent, "wrapper", 4)); + QCOMPARE(item->isVisible(), false); + QVERIFY(item = findItem(leftContent, "wrapper", 5)); + QCOMPARE(item->isVisible(), true); + QVERIFY(item = findItem(rightContent, "wrapper", 16)); + QCOMPARE(item->isVisible(), true); + QVERIFY(item = findItem(rightContent, "wrapper", 17)); + QCOMPARE(item->isVisible(), false); + + delete canvas; +} + +void tst_QQuickListView::populateTransitions() +{ + QFETCH(bool, staticallyPopulate); + QFETCH(bool, dynamicallyPopulate); + QFETCH(bool, usePopulateTransition); + + QPointF transitionFrom(-50, -50); + QPointF transitionVia(100, 100); + QaimModel model_transitionFrom; + QaimModel model_transitionVia; + + QaimModel model; + if (staticallyPopulate) { + for (int i = 0; i < 30; i++) + model.addItem("item" + QString::number(i), ""); + } + + QQuickView *canvas = createView(); + canvas->rootContext()->setContextProperty("testModel", &model); + canvas->rootContext()->setContextProperty("testObject", new TestObject(canvas->rootContext())); + canvas->rootContext()->setContextProperty("usePopulateTransition", usePopulateTransition); + canvas->rootContext()->setContextProperty("dynamicallyPopulate", dynamicallyPopulate); + canvas->rootContext()->setContextProperty("transitionFrom", transitionFrom); + canvas->rootContext()->setContextProperty("transitionVia", transitionVia); + canvas->rootContext()->setContextProperty("model_transitionFrom", &model_transitionFrom); + canvas->rootContext()->setContextProperty("model_transitionVia", &model_transitionVia); + canvas->setSource(testFileUrl("populateTransitions.qml")); + canvas->show(); + + QQuickListView *listview = findItem(canvas->rootObject(), "list"); + QVERIFY(listview); + QQuickItem *contentItem = listview->contentItem(); + QVERIFY(contentItem); + + if (staticallyPopulate || dynamicallyPopulate) { + // check the populate transition is run + if (usePopulateTransition) { + QTRY_COMPARE(listview->property("countPopulateTransitions").toInt(), 17); + } else { + QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false); + QTRY_COMPARE(listview->property("countPopulateTransitions").toInt(), 0); + } + QTRY_COMPARE(listview->property("countAddTransitions").toInt(), 0); + } else { + QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false); + } + + int itemCount = findItems(contentItem, "wrapper").count(); + if (usePopulateTransition) + QCOMPARE(itemCount, listview->property("countPopulateTransitions").toInt()); + for (int i=0; i < model.count() && i < itemCount; ++i) { + QQuickItem *item = findItem(contentItem, "wrapper", i); + QVERIFY2(item, QTest::toString(QString("Item %1 not found").arg(i))); + QTRY_COMPARE(item->x(), 0.0); + QTRY_COMPARE(item->y(), i*20.0); + QQuickText *name = findItem(contentItem, "textName", i); + QVERIFY(name != 0); + QTRY_COMPARE(name->text(), model.name(i)); + } + + // add an item and check this is done with add trantion, not populate + model.insertItem(0, "another item", ""); + QTRY_COMPARE(listview->property("countAddTransitions").toInt(), 1); + QTRY_COMPARE(listview->property("countPopulateTransitions").toInt(), + (usePopulateTransition && (staticallyPopulate || dynamicallyPopulate)) ? 17 : 0); + + // clear the model + canvas->rootContext()->setContextProperty("testModel", QVariant()); + QTRY_COMPARE(listview->count(), 0); + QTRY_COMPARE(findItems(contentItem, "wrapper").count(), 0); + listview->setProperty("countPopulateTransitions", 0); + listview->setProperty("countAddTransitions", 0); + + // set to a valid model and check populate transition is run a second time + model.clear(); + for (int i = 0; i < 30; i++) + model.addItem("item" + QString::number(i), ""); + canvas->rootContext()->setContextProperty("testModel", &model); + QTRY_COMPARE(listview->property("countPopulateTransitions").toInt(), usePopulateTransition ? 17 : 0); + QTRY_COMPARE(listview->property("countAddTransitions").toInt(), 0); + + itemCount = findItems(contentItem, "wrapper").count(); + if (usePopulateTransition) + QCOMPARE(itemCount, listview->property("countPopulateTransitions").toInt()); + for (int i=0; i < model.count() && i < itemCount; ++i) { + QQuickItem *item = findItem(contentItem, "wrapper", i); + QVERIFY2(item, QTest::toString(QString("Item %1 not found").arg(i))); + QTRY_COMPARE(item->x(), 0.0); + QTRY_COMPARE(item->y(), i*20.0); + QQuickText *name = findItem(contentItem, "textName", i); + QVERIFY(name != 0); + QTRY_COMPARE(name->text(), model.name(i)); + } + + // reset model and check populate transition is run again + listview->setProperty("countPopulateTransitions", 0); + listview->setProperty("countAddTransitions", 0); + model.reset(); + QTRY_COMPARE(listview->property("countPopulateTransitions").toInt(), usePopulateTransition ? 17 : 0); + QTRY_COMPARE(listview->property("countAddTransitions").toInt(), 0); + + itemCount = findItems(contentItem, "wrapper").count(); + if (usePopulateTransition) + QCOMPARE(itemCount, listview->property("countPopulateTransitions").toInt()); + for (int i=0; i < model.count() && i < itemCount; ++i) { + QQuickItem *item = findItem(contentItem, "wrapper", i); + QVERIFY2(item, QTest::toString(QString("Item %1 not found").arg(i))); + QTRY_COMPARE(item->x(), 0.0); + QTRY_COMPARE(item->y(), i*20.0); + QQuickText *name = findItem(contentItem, "textName", i); + QVERIFY(name != 0); + QTRY_COMPARE(name->text(), model.name(i)); + } + + delete canvas; +} + +void tst_QQuickListView::populateTransitions_data() +{ + QTest::addColumn("staticallyPopulate"); + QTest::addColumn("dynamicallyPopulate"); + QTest::addColumn("usePopulateTransition"); + + QTest::newRow("static") << true << false << true; + QTest::newRow("static, no populate") << true << false << false; + + QTest::newRow("dynamic") << false << true << true; + QTest::newRow("dynamic, no populate") << false << true << false; + + QTest::newRow("empty to start with") << false << false << true; + QTest::newRow("empty to start with, no populate") << false << false << false; +} + +void tst_QQuickListView::addTransitions() +{ + QFETCH(int, initialItemCount); + QFETCH(bool, shouldAnimateTargets); + QFETCH(qreal, contentY); + QFETCH(int, insertionIndex); + QFETCH(int, insertionCount); + QFETCH(ListRange, expectedDisplacedIndexes); + + // added items should start here + QPointF targetItems_transitionFrom(-50, -50); + + // displaced items should pass through this point + QPointF displacedItems_transitionVia(100, 100); + + QaimModel model; + for (int i = 0; i < initialItemCount; i++) + model.addItem("Original item" + QString::number(i), ""); + QaimModel model_targetItems_transitionFrom; + QaimModel model_displacedItems_transitionVia; + + QQuickView *canvas = createView(); + QQmlContext *ctxt = canvas->rootContext(); + TestObject *testObject = new TestObject; + ctxt->setContextProperty("testModel", &model); + ctxt->setContextProperty("model_targetItems_transitionFrom", &model_targetItems_transitionFrom); + ctxt->setContextProperty("model_displacedItems_transitionVia", &model_displacedItems_transitionVia); + ctxt->setContextProperty("targetItems_transitionFrom", targetItems_transitionFrom); + ctxt->setContextProperty("displacedItems_transitionVia", displacedItems_transitionVia); + ctxt->setContextProperty("testObject", testObject); + canvas->setSource(testFileUrl("addTransitions.qml")); + canvas->show(); + + QQuickListView *listview = findItem(canvas->rootObject(), "list"); + QTRY_VERIFY(listview != 0); + QQuickItem *contentItem = listview->contentItem(); + QVERIFY(contentItem != 0); + QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false); + + if (contentY != 0) { + listview->setContentY(contentY); + QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false); + } + + QList > expectedDisplacedValues = expectedDisplacedIndexes.getModelDataValues(model); + + // only target items that will become visible should be animated + QList > newData; + QList > expectedTargetData; + QList targetIndexes; + if (shouldAnimateTargets) { + for (int i=insertionIndex; i= contentY / 20 && i < (contentY + listview->height()) / 20) { // only grab visible items + expectedTargetData << newData.last(); + targetIndexes << i; + } + } + QVERIFY(expectedTargetData.count() > 0); + } + + // start animation + if (!newData.isEmpty()) { + model.insertItems(insertionIndex, newData); + QTRY_COMPARE(model.count(), listview->count()); + } + + QList targetItems = findItems(contentItem, "wrapper", targetIndexes); + + if (shouldAnimateTargets) { + QTRY_COMPARE(listview->property("targetTransitionsDone").toInt(), expectedTargetData.count()); + QTRY_COMPARE(listview->property("displaceTransitionsDone").toInt(), + expectedDisplacedIndexes.isValid() ? expectedDisplacedIndexes.count() : 0); + + // check the target and displaced items were animated + model_targetItems_transitionFrom.matchAgainst(expectedTargetData, "wasn't animated from target 'from' pos", "shouldn't have been animated from target 'from' pos"); + model_displacedItems_transitionVia.matchAgainst(expectedDisplacedValues, "wasn't animated with displaced anim", "shouldn't have been animated with displaced anim"); + + // check attached properties + matchItemsAndIndexes(listview->property("targetTrans_items").toMap(), model, targetIndexes); + matchIndexLists(listview->property("targetTrans_targetIndexes").toList(), targetIndexes); + matchItemLists(listview->property("targetTrans_targetItems").toList(), targetItems); + if (expectedDisplacedIndexes.isValid()) { + // adjust expectedDisplacedIndexes to their final values after the move + QList displacedIndexes = adjustIndexesForAddDisplaced(expectedDisplacedIndexes.indexes, insertionIndex, insertionCount); + matchItemsAndIndexes(listview->property("displacedTrans_items").toMap(), model, displacedIndexes); + matchIndexLists(listview->property("displacedTrans_targetIndexes").toList(), targetIndexes); + matchItemLists(listview->property("displacedTrans_targetItems").toList(), targetItems); + } + + } else { + QTRY_COMPARE(model_targetItems_transitionFrom.count(), 0); + QTRY_COMPARE(model_displacedItems_transitionVia.count(), 0); + } + + QList items = findItems(contentItem, "wrapper"); + int firstVisibleIndex = -1; + int itemCount = items.count(); + for (int i=0; iy() >= contentY) { + QQmlExpression e(qmlContext(items[i]), items[i], "index"); + firstVisibleIndex = e.evaluate().toInt(); + break; + } + } + QVERIFY2(firstVisibleIndex >= 0, QTest::toString(firstVisibleIndex)); + + // verify all items moved to the correct final positions + for (int i=firstVisibleIndex; i < model.count() && i < itemCount; ++i) { + QQuickItem *item = findItem(contentItem, "wrapper", i); + QVERIFY2(item, QTest::toString(QString("Item %1 not found").arg(i))); + QTRY_COMPARE(item->y(), i*20.0); + QQuickText *name = findItem(contentItem, "textName", i); + QVERIFY(name != 0); + QTRY_COMPARE(name->text(), model.name(i)); + } + + delete canvas; + delete testObject; +} + +void tst_QQuickListView::addTransitions_data() +{ + QTest::addColumn("initialItemCount"); + QTest::addColumn("contentY"); + QTest::addColumn("shouldAnimateTargets"); + QTest::addColumn("insertionIndex"); + QTest::addColumn("insertionCount"); + QTest::addColumn("expectedDisplacedIndexes"); + + // if inserting before visible index, items should not appear or animate in, even if there are > 1 new items + QTest::newRow("insert 1, just before start") + << 30 << 20.0 << false + << 0 << 1 << ListRange(); + QTest::newRow("insert 1, way before start") + << 30 << 20.0 << false + << 0 << 1 << ListRange(); + QTest::newRow("insert multiple, just before start") + << 30 << 100.0 << false + << 0 << 3 << ListRange(); + QTest::newRow("insert multiple, way before start") + << 30 << 100.0 << false + << 0 << 3 << ListRange(); + + QTest::newRow("insert 1 at start") + << 30 << 0.0 << true + << 0 << 1 << ListRange(0, 15); + QTest::newRow("insert multiple at start") + << 30 << 0.0 << true + << 0 << 3 << ListRange(0, 15); + QTest::newRow("insert 1 at start, content y not 0") + << 30 << 40.0 << true // first visible is index 2, so translate the displaced indexes by 2 + << 2 << 1 << ListRange(0 + 2, 15 + 2); + QTest::newRow("insert multiple at start, content y not 0") + << 30 << 40.0 << true // first visible is index 2 + << 2 << 3 << ListRange(0 + 2, 15 + 2); + + QTest::newRow("insert 1 at start, to empty list") + << 0 << 0.0 << true + << 0 << 1 << ListRange(); + QTest::newRow("insert multiple at start, to empty list") + << 0 << 0.0 << true + << 0 << 3 << ListRange(); + + QTest::newRow("insert 1 at middle") + << 30 << 0.0 << true + << 5 << 1 << ListRange(5, 15); + QTest::newRow("insert multiple at middle") + << 30 << 0.0 << true + << 5 << 3 << ListRange(5, 15); + + QTest::newRow("insert 1 at bottom") + << 30 << 0.0 << true + << 15 << 1 << ListRange(15, 15); + QTest::newRow("insert multiple at bottom") + << 30 << 0.0 << true + << 15 << 3 << ListRange(15, 15); + QTest::newRow("insert 1 at bottom, content y not 0") + << 30 << 20.0 * 3 << true + << 15 + 3 << 1 << ListRange(15 + 3, 15 + 3); + QTest::newRow("insert multiple at bottom, content y not 0") + << 30 << 20.0 * 3 << true + << 15 + 3 << 3 << ListRange(15 + 3, 15 + 3); + + // items added after the last visible will not be animated in, since they + // do not appear in the final view + QTest::newRow("insert 1 after end") + << 30 << 0.0 << false + << 17 << 1 << ListRange(); + QTest::newRow("insert multiple after end") + << 30 << 0.0 << false + << 17 << 3 << ListRange(); +} + +void tst_QQuickListView::moveTransitions() +{ + QFETCH(int, initialItemCount); + QFETCH(qreal, contentY); + QFETCH(qreal, itemsOffsetAfterMove); + QFETCH(int, moveFrom); + QFETCH(int, moveTo); + QFETCH(int, moveCount); + QFETCH(ListRange, expectedDisplacedIndexes); + + // target and displaced items should pass through these points + QPointF targetItems_transitionVia(-50, 50); + QPointF displacedItems_transitionVia(100, 100); + + QaimModel model; + for (int i = 0; i < initialItemCount; i++) + model.addItem("Original item" + QString::number(i), ""); + QaimModel model_targetItems_transitionVia; + QaimModel model_displacedItems_transitionVia; + + QQuickView *canvas = createView(); + QQmlContext *ctxt = canvas->rootContext(); + TestObject *testObject = new TestObject; + ctxt->setContextProperty("testModel", &model); + ctxt->setContextProperty("model_targetItems_transitionVia", &model_targetItems_transitionVia); + ctxt->setContextProperty("model_displacedItems_transitionVia", &model_displacedItems_transitionVia); + ctxt->setContextProperty("targetItems_transitionVia", targetItems_transitionVia); + ctxt->setContextProperty("displacedItems_transitionVia", displacedItems_transitionVia); + ctxt->setContextProperty("testObject", testObject); + canvas->setSource(testFileUrl("moveTransitions.qml")); + canvas->show(); + + QQuickListView *listview = findItem(canvas->rootObject(), "list"); + QTRY_VERIFY(listview != 0); + QQuickItem *contentItem = listview->contentItem(); + QVERIFY(contentItem != 0); + QQuickText *name; + + if (contentY != 0) { + listview->setContentY(contentY); + QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false); + } + + QList > expectedDisplacedValues = expectedDisplacedIndexes.getModelDataValues(model); + + // Items moving to *or* from visible positions should be animated. + // Otherwise, they should not be animated. + QList > expectedTargetData; + QList targetIndexes; + for (int i=moveFrom; iheight()) / 20 + || toIndex < (contentY + listview->height()) / 20) { + expectedTargetData << qMakePair(model.name(i), model.number(i)); + targetIndexes << i; + } + } + // ViewTransition.index provides the indices that items are moving to, not from + targetIndexes = adjustIndexesForMove(targetIndexes, moveFrom, moveTo, moveCount); + + // start animation + model.moveItems(moveFrom, moveTo, moveCount); + + QTRY_COMPARE(listview->property("targetTransitionsDone").toInt(), expectedTargetData.count()); + QTRY_COMPARE(listview->property("displaceTransitionsDone").toInt(), + expectedDisplacedIndexes.isValid() ? expectedDisplacedIndexes.count() : 0); + + QList targetItems = findItems(contentItem, "wrapper", targetIndexes); + + // check the target and displaced items were animated + model_targetItems_transitionVia.matchAgainst(expectedTargetData, "wasn't animated from target 'from' pos", "shouldn't have been animated from target 'from' pos"); + model_displacedItems_transitionVia.matchAgainst(expectedDisplacedValues, "wasn't animated with displaced anim", "shouldn't have been animated with displaced anim"); + + // check attached properties + matchItemsAndIndexes(listview->property("targetTrans_items").toMap(), model, targetIndexes); + matchIndexLists(listview->property("targetTrans_targetIndexes").toList(), targetIndexes); + matchItemLists(listview->property("targetTrans_targetItems").toList(), targetItems); + if (expectedDisplacedIndexes.isValid()) { + // adjust expectedDisplacedIndexes to their final values after the move + QList displacedIndexes = adjustIndexesForMove(expectedDisplacedIndexes.indexes, moveFrom, moveTo, moveCount); + matchItemsAndIndexes(listview->property("displacedTrans_items").toMap(), model, displacedIndexes); + matchIndexLists(listview->property("displacedTrans_targetIndexes").toList(), targetIndexes); + matchItemLists(listview->property("displacedTrans_targetItems").toList(), targetItems); + } + + QList items = findItems(contentItem, "wrapper"); + int firstVisibleIndex = -1; + for (int i=0; iy() >= contentY) { + QQmlExpression e(qmlContext(items[i]), items[i], "index"); + firstVisibleIndex = e.evaluate().toInt(); + break; + } + } + QVERIFY2(firstVisibleIndex >= 0, QTest::toString(firstVisibleIndex)); + + // verify all items moved to the correct final positions + int itemCount = findItems(contentItem, "wrapper").count(); + for (int i=firstVisibleIndex; i < model.count() && i < itemCount; ++i) { + QQuickItem *item = findItem(contentItem, "wrapper", i); + QVERIFY2(item, QTest::toString(QString("Item %1 not found").arg(i))); + QTRY_COMPARE(item->y(), i*20.0 + itemsOffsetAfterMove); + name = findItem(contentItem, "textName", i); + QVERIFY(name != 0); + QTRY_COMPARE(name->text(), model.name(i)); + } + + delete canvas; + delete testObject; +} + +void tst_QQuickListView::moveTransitions_data() +{ + QTest::addColumn("initialItemCount"); + QTest::addColumn("contentY"); + QTest::addColumn("itemsOffsetAfterMove"); + QTest::addColumn("moveFrom"); + QTest::addColumn("moveTo"); + QTest::addColumn("moveCount"); + QTest::addColumn("expectedDisplacedIndexes"); + + // when removing from above the visible, all items shift down depending on how many + // items have been removed from above the visible + QTest::newRow("move from above view, outside visible items, move 1") << 30 << 4*20.0 << 20.0 + << 1 << 10 << 1 << ListRange(11, 15+4); + QTest::newRow("move from above view, outside visible items, move 1 (first item)") << 30 << 4*20.0 << 20.0 + << 0 << 10 << 1 << ListRange(11, 15+4); + QTest::newRow("move from above view, outside visible items, move multiple") << 30 << 4*20.0 << 2*20.0 + << 1 << 10 << 2 << ListRange(12, 15+4); + QTest::newRow("move from above view, outside visible items, move multiple (first item)") << 30 << 4*20.0 << 3*20.0 + << 0 << 10 << 3 << ListRange(13, 15+4); + QTest::newRow("move from above view, mix of visible/non-visible") << 30 << 4*20.0 << 3*20.0 + << 1 << 10 << 5 << ListRange(6, 14) + ListRange(15, 15+4); + QTest::newRow("move from above view, mix of visible/non-visible (move first)") << 30 << 4*20.0 << 4*20.0 + << 0 << 10 << 5 << ListRange(5, 14) + ListRange(15, 15+4); + + QTest::newRow("move within view, move 1 down") << 30 << 0.0 << 0.0 + << 1 << 10 << 1 << ListRange(2, 10); + QTest::newRow("move within view, move 1 down, move first item") << 30 << 0.0 << 0.0 + << 0 << 10 << 1 << ListRange(1, 10); + QTest::newRow("move within view, move 1 down, move first item, contentY not 0") << 30 << 4*20.0 << 0.0 + << 0+4 << 10+4 << 1 << ListRange(1+4, 10+4); + QTest::newRow("move within view, move 1 down, to last item") << 30 << 0.0 << 0.0 + << 10 << 15 << 1 << ListRange(11, 15); + QTest::newRow("move within view, move first->last") << 30 << 0.0 << 0.0 + << 0 << 15 << 1 << ListRange(1, 15); + + QTest::newRow("move within view, move multiple down") << 30 << 0.0 << 0.0 + << 1 << 10 << 3 << ListRange(4, 12); + QTest::newRow("move within view, move multiple down, move first item") << 30 << 0.0 << 0.0 + << 0 << 10 << 3 << ListRange(3, 12); + QTest::newRow("move within view, move multiple down, move first item, contentY not 0") << 30 << 4*20.0 << 0.0 + << 0+4 << 10+4 << 3 << ListRange(3+4, 12+4); + QTest::newRow("move within view, move multiple down, displace last item") << 30 << 0.0 << 0.0 + << 5 << 13 << 3 << ListRange(8, 15); + QTest::newRow("move within view, move multiple down, move first->last") << 30 << 0.0 << 0.0 + << 0 << 13 << 3 << ListRange(3, 15); + + QTest::newRow("move within view, move 1 up") << 30 << 0.0 << 0.0 + << 10 << 1 << 1 << ListRange(1, 9); + QTest::newRow("move within view, move 1 up, move to first index") << 30 << 0.0 << 0.0 + << 10 << 0 << 1 << ListRange(0, 9); + QTest::newRow("move within view, move 1 up, move to first index, contentY not 0") << 30 << 4*20.0 << 0.0 + << 10+4 << 0+4 << 1 << ListRange(0+4, 9+4); + QTest::newRow("move within view, move 1 up, move to first index, contentY not on item border") << 30 << 4*20.0 - 10 << 0.0 + << 10+4 << 0+4 << 1 << ListRange(0+4, 9+4); + QTest::newRow("move within view, move 1 up, move last item") << 30 << 0.0 << 0.0 + << 15 << 10 << 1 << ListRange(10, 14); + QTest::newRow("move within view, move 1 up, move last->first") << 30 << 0.0 << 0.0 + << 15 << 0 << 1 << ListRange(0, 14); + + QTest::newRow("move within view, move multiple up") << 30 << 0.0 << 0.0 + << 10 << 1 << 3 << ListRange(1, 9); + QTest::newRow("move within view, move multiple up, move to first index") << 30 << 0.0 << 0.0 + << 10 << 0 << 3 << ListRange(0, 9); + QTest::newRow("move within view, move multiple up, move to first index, contentY not 0") << 30 << 4*20.0 << 0.0 + << 10+4 << 0+4 << 3 << ListRange(0+4, 9+4); + QTest::newRow("move within view, move multiple up, move last item") << 30 << 0.0 << 0.0 + << 13 << 5 << 3 << ListRange(5, 12); + QTest::newRow("move within view, move multiple up, move last->first") << 30 << 0.0 << 0.0 + << 13 << 0 << 3 << ListRange(0, 12); + + QTest::newRow("move from below view, move 1 up, move to top") << 30 << 0.0 << 0.0 + << 20 << 0 << 1 << ListRange(0, 15); + QTest::newRow("move from below view, move 1 up, move to top, contentY not 0") << 30 << 4*20.0 << 0.0 + << 25 << 4 << 1 << ListRange(0+4, 15+4); + QTest::newRow("move from below view, move multiple up, move to top") << 30 << 0.0 << 0.0 + << 20 << 0 << 3 << ListRange(0, 15); + QTest::newRow("move from below view, move multiple up, move to top, contentY not 0") << 30 << 4*20.0 << 0.0 + << 25 << 4 << 3 << ListRange(0+4, 15+4); + + QTest::newRow("move from below view, move 1 up, move to bottom") << 30 << 0.0 << 0.0 + << 20 << 15 << 1 << ListRange(15, 15); + QTest::newRow("move from below view, move 1 up, move to bottom, contentY not 0") << 30 << 4*20.0 << 0.0 + << 25 << 15+4 << 1 << ListRange(15+4, 15+4); + QTest::newRow("move from below view, move multiple up, move to to bottom") << 30 << 0.0 << 0.0 + << 20 << 15 << 3 << ListRange(15, 15); + QTest::newRow("move from below view, move multiple up, move to bottom, contentY not 0") << 30 << 4*20.0 << 0.0 + << 25 << 15+4 << 3 << ListRange(15+4, 15+4); +} + +void tst_QQuickListView::removeTransitions() +{ + QFETCH(int, initialItemCount); + QFETCH(bool, shouldAnimateTargets); + QFETCH(qreal, contentY); + QFETCH(int, removalIndex); + QFETCH(int, removalCount); + QFETCH(ListRange, expectedDisplacedIndexes); + + // added items should end here + QPointF targetItems_transitionTo(-50, -50); + + // displaced items should pass through this points + QPointF displacedItems_transitionVia(100, 100); + + QaimModel model; + for (int i = 0; i < initialItemCount; i++) + model.addItem("Original item" + QString::number(i), ""); + QaimModel model_targetItems_transitionTo; + QaimModel model_displacedItems_transitionVia; + + QQuickView *canvas = createView(); + QQmlContext *ctxt = canvas->rootContext(); + TestObject *testObject = new TestObject; + ctxt->setContextProperty("testModel", &model); + ctxt->setContextProperty("model_targetItems_transitionTo", &model_targetItems_transitionTo); + ctxt->setContextProperty("model_displacedItems_transitionVia", &model_displacedItems_transitionVia); + ctxt->setContextProperty("targetItems_transitionTo", targetItems_transitionTo); + ctxt->setContextProperty("displacedItems_transitionVia", displacedItems_transitionVia); + ctxt->setContextProperty("testObject", testObject); + canvas->setSource(testFileUrl("removeTransitions.qml")); + canvas->show(); + + QQuickListView *listview = findItem(canvas->rootObject(), "list"); + QTRY_VERIFY(listview != 0); + QQuickItem *contentItem = listview->contentItem(); + QVERIFY(contentItem != 0); + QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false); + + if (contentY != 0) { + listview->setContentY(contentY); + QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false); + } + + QList > expectedDisplacedValues = expectedDisplacedIndexes.getModelDataValues(model); + + // only target items that are visible should be animated + QList > expectedTargetData; + QList targetIndexes; + if (shouldAnimateTargets) { + for (int i=removalIndex; i= contentY / 20 && i < (contentY + listview->height()) / 20) { + expectedTargetData << qMakePair(model.name(i), model.number(i)); + targetIndexes << i; + } + } + QVERIFY(expectedTargetData.count() > 0); + } + + // calculate targetItems and expectedTargets before model changes + QList targetItems = findItems(contentItem, "wrapper", targetIndexes); + QVariantMap expectedTargets; + for (int i=0; icount()); + + if (shouldAnimateTargets) { + QTRY_COMPARE(listview->property("targetTransitionsDone").toInt(), expectedTargetData.count()); + QTRY_COMPARE(listview->property("displaceTransitionsDone").toInt(), + expectedDisplacedIndexes.isValid() ? expectedDisplacedIndexes.count() : 0); + + // check the target and displaced items were animated + model_targetItems_transitionTo.matchAgainst(expectedTargetData, "wasn't animated to target 'to' pos", "shouldn't have been animated to target 'to' pos"); + model_displacedItems_transitionVia.matchAgainst(expectedDisplacedValues, "wasn't animated with displaced anim", "shouldn't have been animated with displaced anim"); + + // check attached properties + QCOMPARE(listview->property("targetTrans_items").toMap(), expectedTargets); + matchIndexLists(listview->property("targetTrans_targetIndexes").toList(), targetIndexes); + matchItemLists(listview->property("targetTrans_targetItems").toList(), targetItems); + if (expectedDisplacedIndexes.isValid()) { + // adjust expectedDisplacedIndexes to their final values after the move + QList displacedIndexes = adjustIndexesForRemoveDisplaced(expectedDisplacedIndexes.indexes, removalIndex, removalCount); + matchItemsAndIndexes(listview->property("displacedTrans_items").toMap(), model, displacedIndexes); + matchIndexLists(listview->property("displacedTrans_targetIndexes").toList(), targetIndexes); + matchItemLists(listview->property("displacedTrans_targetItems").toList(), targetItems); + } + } else { + QTRY_COMPARE(model_targetItems_transitionTo.count(), 0); + QTRY_COMPARE(model_displacedItems_transitionVia.count(), 0); + } + + QList items = findItems(contentItem, "wrapper"); + int firstVisibleIndex = -1; + int itemCount = items.count(); + + for (int i=0; iy() >= contentY) + firstVisibleIndex = index; + if (index < 0) + itemCount--; // exclude deleted items + } + QVERIFY2(firstVisibleIndex >= 0, QTest::toString(firstVisibleIndex)); + + // verify all items moved to the correct final positions + for (int i=firstVisibleIndex; i < model.count() && i < itemCount; ++i) { + QQuickItem *item = findItem(contentItem, "wrapper", i); + QVERIFY2(item, QTest::toString(QString("Item %1 not found").arg(i))); + QCOMPARE(item->x(), 0.0); + QCOMPARE(item->y(), contentY + (i-firstVisibleIndex) * 20.0); + QQuickText *name = findItem(contentItem, "textName", i); + QVERIFY(name != 0); + QTRY_COMPARE(name->text(), model.name(i)); + } + + delete canvas; + delete testObject; +} + +void tst_QQuickListView::removeTransitions_data() +{ + QTest::addColumn("initialItemCount"); + QTest::addColumn("contentY"); + QTest::addColumn("shouldAnimateTargets"); + QTest::addColumn("removalIndex"); + QTest::addColumn("removalCount"); + QTest::addColumn("expectedDisplacedIndexes"); + + // All items that are visible following the remove operation should be animated. + // Remove targets that are outside of the view should not be animated. + + QTest::newRow("remove 1 before start") + << 30 << 20.0 * 3 << false + << 2 << 1 << ListRange(); + QTest::newRow("remove multiple, all before start") + << 30 << 20.0 * 3 << false + << 0 << 3 << ListRange(); + QTest::newRow("remove mix of before and after start") + << 30 << 20.0 * 3 << true + << 2 << 3 << ListRange(5, 20); // 5-20 are visible after the remove + + QTest::newRow("remove 1 from start") + << 30 << 0.0 << true + << 0 << 1 << ListRange(1, 16); // 1-16 are visible after the remove + QTest::newRow("remove multiple from start") + << 30 << 0.0 << true + << 0 << 3 << ListRange(3, 18); // 3-18 are visible after the remove + QTest::newRow("remove 1 from start, content y not 0") + << 30 << 20.0 * 2 << true // first visible is index 2, so translate the displaced indexes by 2 + << 2 << 1 << ListRange(1 + 2, 16 + 2); + QTest::newRow("remove multiple from start, content y not 0") + << 30 << 20.0 * 2 << true // first visible is index 2 + << 2 << 3 << ListRange(3 + 2, 18 + 2); + + QTest::newRow("remove 1 from middle") + << 30 << 0.0 << true + << 5 << 1 << ListRange(6, 16); + QTest::newRow("remove multiple from middle") + << 30 << 0.0 << true + << 5 << 3 << ListRange(8, 18); + + + QTest::newRow("remove 1 from bottom") + << 30 << 0.0 << true + << 15 << 1 << ListRange(16, 16); + + // remove 15, 16, 17 + // 15 will animate as the target item, 16 & 17 won't be animated since they are outside + // the view, and 18 will be animated as the displaced item to replace the last item + QTest::newRow("remove multiple from bottom") + << 30 << 0.0 << true + << 15 << 3 << ListRange(18, 18); + + QTest::newRow("remove 1 from bottom, content y not 0") + << 30 << 20.0 * 2 << true + << 15 + 2 << 1 << ListRange(16 + 2, 16 + 2); + QTest::newRow("remove multiple from bottom, content y not 0") + << 30 << 20.0 * 2 << true + << 15 + 2 << 3 << ListRange(18 + 2, 18 + 2); + + + QTest::newRow("remove 1 after end") + << 30 << 0.0 << false + << 17 << 1 << ListRange(); + QTest::newRow("remove multiple after end") + << 30 << 0.0 << false + << 17 << 3 << ListRange(); +} + +void tst_QQuickListView::multipleTransitions() +{ + // Tests that if you interrupt a transition in progress with another action that + // cancels the previous transition, the resulting items are still placed correctly. + + QFETCH(int, initialCount); + QFETCH(qreal, contentY); + QFETCH(QList, changes); + + // add transitions on the left, moves on the right + QPointF addTargets_transitionFrom(-50, -50); + QPointF addDisplaced_transitionFrom(-50, 50); + QPointF moveTargets_transitionFrom(50, -50); + QPointF moveDisplaced_transitionFrom(50, 50); + + QmlListModel model; + for (int i = 0; i < initialCount; i++) + model.addItem("Original item" + QString::number(i), ""); + + QQuickView *canvas = createView(); + QQmlContext *ctxt = canvas->rootContext(); + TestObject *testObject = new TestObject; + ctxt->setContextProperty("testModel", &model); + ctxt->setContextProperty("testObject", testObject); + ctxt->setContextProperty("addTargets_transitionFrom", addTargets_transitionFrom); + ctxt->setContextProperty("addDisplaced_transitionFrom", addDisplaced_transitionFrom); + ctxt->setContextProperty("moveTargets_transitionFrom", moveTargets_transitionFrom); + ctxt->setContextProperty("moveDisplaced_transitionFrom", moveDisplaced_transitionFrom); + canvas->setSource(testFileUrl("multipleTransitions.qml")); + canvas->show(); + + QQuickListView *listview = findItem(canvas->rootObject(), "list"); + QTRY_VERIFY(listview != 0); + QQuickItem *contentItem = listview->contentItem(); + QVERIFY(contentItem != 0); + QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false); + + int timeBetweenActions = canvas->rootObject()->property("timeBetweenActions").toInt(); + + QList > targetItems; + for (int i=0; icount()); + QTRY_VERIFY(listview->property("runningAddTargets").toBool()); + QTRY_VERIFY(listview->property("runningAddDisplaced").toBool()); + if (i == changes.count() - 1) { + QTRY_VERIFY(!listview->property("runningAddTargets").toBool()); + QTRY_VERIFY(!listview->property("runningAddDisplaced").toBool()); + } else { + QTest::qWait(timeBetweenActions); + } + break; + } + case ListChange::Removed: + for (int j=changes[i].index; jcount()); + QTRY_VERIFY(listview->property("runningRemoveTargets").toBool()); + QTRY_VERIFY(listview->property("runningRemoveDisplaced").toBool()); + if (i == changes.count() - 1) { + QTRY_VERIFY(!listview->property("runningRemoveTargets").toBool()); + QTRY_VERIFY(!listview->property("runningRemoveDisplaced").toBool()); + } else { + QTest::qWait(timeBetweenActions); + } + break; + case ListChange::Moved: + for (int j=changes[i].index; jproperty("runningMoveTargets").toBool()); + QTRY_VERIFY(listview->property("runningMoveDisplaced").toBool()); + if (i == changes.count() - 1) { + QTRY_VERIFY(!listview->property("runningMoveTargets").toBool()); + QTRY_VERIFY(!listview->property("runningMoveDisplaced").toBool()); + } else { + QTest::qWait(timeBetweenActions); + } + break; + case ListChange::SetCurrent: + listview->setCurrentIndex(changes[i].index); + break; + case ListChange::SetContentY: + listview->setContentY(changes[i].pos); + QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false); + break; + } + } + QCOMPARE(listview->count(), model.count()); + + QList items = findItems(contentItem, "wrapper"); + int firstVisibleIndex = -1; + for (int i=0; iy() >= contentY) { + QQmlExpression e(qmlContext(items[i]), items[i], "index"); + firstVisibleIndex = e.evaluate().toInt(); + break; + } + } + QVERIFY2(firstVisibleIndex >= 0, QTest::toString(firstVisibleIndex)); + + // verify all items moved to the correct final positions + int itemCount = findItems(contentItem, "wrapper").count(); + for (int i=firstVisibleIndex; i < model.count() && i < itemCount; ++i) { + QQuickItem *item = findItem(contentItem, "wrapper", i); + QVERIFY2(item, QTest::toString(QString("Item %1 not found").arg(i))); + QTRY_COMPARE(item->x(), 0.0); + QTRY_COMPARE(item->y(), i*20.0); + QQuickText *name = findItem(contentItem, "textName", i); + QVERIFY(name != 0); + QTRY_COMPARE(name->text(), model.name(i)); + } + + delete canvas; + delete testObject; +} + +void tst_QQuickListView::multipleTransitions_data() +{ + QTest::addColumn("initialCount"); + QTest::addColumn("contentY"); + QTest::addColumn >("changes"); + + // the added item and displaced items should move to final dest correctly + QTest::newRow("add item, then move it immediately") << 10 << 0.0 << (QList() + << ListChange::insert(0, 1) + << ListChange::move(0, 3, 1) + ); + + // items affected by the add should change from move to add transition + QTest::newRow("move, then insert item before the moved item") << 20 << 0.0 << (QList() + << ListChange::move(1, 10, 3) + << ListChange::insert(0, 1) + ); + + // items should be placed correctly if you trigger a transition then refill for that index + QTest::newRow("add at 0, flick down, flick back to top and add at 0 again") << 20 << 0.0 << (QList() + << ListChange::insert(0, 1) + << ListChange::setContentY(80.0) + << ListChange::setContentY(0.0) + << ListChange::insert(0, 1) + ); +} + +QList tst_QQuickListView::toIntList(const QVariantList &list) +{ + QList ret; + bool ok = true; + for (int i=0; i &expectedIndexes) +{ + for (int i=0; i current = indexLists[i].value >().toSet(); + if (current != expectedIndexes.toSet()) + qDebug() << "Cannot match actual targets" << current << "with expected" << expectedIndexes; + QCOMPARE(current, expectedIndexes.toSet()); + } +} + +void tst_QQuickListView::matchItemsAndIndexes(const QVariantMap &items, const QaimModel &model, const QList &expectedIndexes) +{ + for (QVariantMap::const_iterator it = items.begin(); it != items.end(); ++it) { + QVERIFY(it.value().type() == QVariant::Int); + QString name = it.key(); + int itemIndex = it.value().toInt(); + QVERIFY2(expectedIndexes.contains(itemIndex), QTest::toString(QString("Index %1 not found in expectedIndexes").arg(itemIndex))); + if (model.name(itemIndex) != name) + qDebug() << itemIndex; + QCOMPARE(model.name(itemIndex), name); + } + QCOMPARE(items.count(), expectedIndexes.count()); +} + +void tst_QQuickListView::matchItemLists(const QVariantList &itemLists, const QList &expectedItems) +{ + for (int i=0; i(current[j].value()); + QVERIFY2(o, QTest::toString(QString("Invalid actual item at %1").arg(j))); + QVERIFY2(expectedItems.contains(o), QTest::toString(QString("Cannot match item %1").arg(j))); + } + QCOMPARE(current.count(), expectedItems.count()); + } +} + + +QTEST_MAIN(tst_QQuickListView) + +#include "tst_qquicklistview.moc" + diff --git a/tests/auto/quick/qquickloader/data/ActiveComponent.qml b/tests/auto/quick/qquickloader/data/ActiveComponent.qml new file mode 100644 index 0000000000..24c6f7ad91 --- /dev/null +++ b/tests/auto/quick/qquickloader/data/ActiveComponent.qml @@ -0,0 +1,11 @@ +import QtQuick 2.0 + +Item { + id: behaviorCounter + property int behaviorCount: 0 + property int canary: 0 + + Behavior on canary { + NumberAnimation { target: behaviorCounter; property: "behaviorCount"; to: (behaviorCounter.behaviorCount + 1); duration: 0 } + } +} diff --git a/tests/auto/quick/qquickloader/data/AnchoredLoader.qml b/tests/auto/quick/qquickloader/data/AnchoredLoader.qml new file mode 100644 index 0000000000..1a2a620d7f --- /dev/null +++ b/tests/auto/quick/qquickloader/data/AnchoredLoader.qml @@ -0,0 +1,14 @@ +import QtQuick 2.0 + +Rectangle { + width: 300 + height: 200 + color: "blue" + Loader { + objectName: "loader" + anchors.fill: parent + sourceComponent: Component { + Rectangle { color: "red"; objectName: "sourceElement" } + } + } +} diff --git a/tests/auto/quick/qquickloader/data/BigComponent.qml b/tests/auto/quick/qquickloader/data/BigComponent.qml new file mode 100644 index 0000000000..df92532c43 --- /dev/null +++ b/tests/auto/quick/qquickloader/data/BigComponent.qml @@ -0,0 +1,5015 @@ +import QtQuick 2.0 + +Item { + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} +} diff --git a/tests/auto/quick/qquickloader/data/BlueRect.qml b/tests/auto/quick/qquickloader/data/BlueRect.qml new file mode 100644 index 0000000000..e96ac00f21 --- /dev/null +++ b/tests/auto/quick/qquickloader/data/BlueRect.qml @@ -0,0 +1,8 @@ +import QtQuick 2.0 + +Rectangle { + objectName: "blue" + width: 100 + height: 100 + color: "blue" +} diff --git a/tests/auto/quick/qquickloader/data/CreationContextLoader.qml b/tests/auto/quick/qquickloader/data/CreationContextLoader.qml new file mode 100644 index 0000000000..4dd73e797c --- /dev/null +++ b/tests/auto/quick/qquickloader/data/CreationContextLoader.qml @@ -0,0 +1,15 @@ +import QtQuick 2.0 + +Loader { + id: myLoader + property int testProperty: 1912 + sourceComponent: loaderComponent + Component { + id: loaderComponent + Item { + Component.onCompleted: { + test = (myLoader.testProperty == 1912); + } + } + } +} diff --git a/tests/auto/quick/qquickloader/data/GraphicsWidget250x250.qml b/tests/auto/quick/qquickloader/data/GraphicsWidget250x250.qml new file mode 100644 index 0000000000..dae8e3fbbb --- /dev/null +++ b/tests/auto/quick/qquickloader/data/GraphicsWidget250x250.qml @@ -0,0 +1,5 @@ +import QtQuick 2.0 + +QGraphicsWidget { + size: "250x250" +} diff --git a/tests/auto/quick/qquickloader/data/GreenRect.qml b/tests/auto/quick/qquickloader/data/GreenRect.qml new file mode 100644 index 0000000000..99cefaf176 --- /dev/null +++ b/tests/auto/quick/qquickloader/data/GreenRect.qml @@ -0,0 +1,7 @@ +import QtQuick 2.0 + +Rectangle { + width: 100; height: 100 + color: "green" + Component.onCompleted: myLoader.source = "BlueRect.qml" +} diff --git a/tests/auto/quick/qquickloader/data/InitialPropertyValuesComponent.qml b/tests/auto/quick/qquickloader/data/InitialPropertyValuesComponent.qml new file mode 100644 index 0000000000..24c6f7ad91 --- /dev/null +++ b/tests/auto/quick/qquickloader/data/InitialPropertyValuesComponent.qml @@ -0,0 +1,11 @@ +import QtQuick 2.0 + +Item { + id: behaviorCounter + property int behaviorCount: 0 + property int canary: 0 + + Behavior on canary { + NumberAnimation { target: behaviorCounter; property: "behaviorCount"; to: (behaviorCounter.behaviorCount + 1); duration: 0 } + } +} diff --git a/tests/auto/quick/qquickloader/data/InvalidSourceComponent.qml b/tests/auto/quick/qquickloader/data/InvalidSourceComponent.qml new file mode 100644 index 0000000000..7efa4a5f61 --- /dev/null +++ b/tests/auto/quick/qquickloader/data/InvalidSourceComponent.qml @@ -0,0 +1,5 @@ +import QtQuick 2.0 + +Item { + RandomError +} diff --git a/tests/auto/quick/qquickloader/data/NoResize.qml b/tests/auto/quick/qquickloader/data/NoResize.qml new file mode 100644 index 0000000000..9b3ea6410b --- /dev/null +++ b/tests/auto/quick/qquickloader/data/NoResize.qml @@ -0,0 +1,8 @@ +import QtQuick 2.0 + +Item { + width: 200; height: 80 + Loader { + source: "Rect120x60.qml" + } +} diff --git a/tests/auto/quick/qquickloader/data/NoResizeGraphicsWidget.qml b/tests/auto/quick/qquickloader/data/NoResizeGraphicsWidget.qml new file mode 100644 index 0000000000..c0f51d8c35 --- /dev/null +++ b/tests/auto/quick/qquickloader/data/NoResizeGraphicsWidget.qml @@ -0,0 +1,9 @@ +import QtQuick 2.0 + +Item { + width: 200 + height: 80 + Loader { + source: "GraphicsWidget250x250.qml" + } +} diff --git a/tests/auto/quick/qquickloader/data/QTBUG_16928.qml b/tests/auto/quick/qquickloader/data/QTBUG_16928.qml new file mode 100644 index 0000000000..903d7f0812 --- /dev/null +++ b/tests/auto/quick/qquickloader/data/QTBUG_16928.qml @@ -0,0 +1,23 @@ +import QtQuick 2.0 + +Rectangle { + color: "green" + width: loader.implicitWidth+50 + height: loader.implicitHeight+50 + + Loader { + id: loader + sourceComponent: Item { + anchors.centerIn: parent + + implicitWidth: 200 + implicitHeight: 200 + Rectangle { + color: "red" + anchors.fill: parent + } + } + anchors.fill: parent + anchors.margins: 15 + } +} diff --git a/tests/auto/quick/qquickloader/data/QTBUG_17114.qml b/tests/auto/quick/qquickloader/data/QTBUG_17114.qml new file mode 100644 index 0000000000..7402037553 --- /dev/null +++ b/tests/auto/quick/qquickloader/data/QTBUG_17114.qml @@ -0,0 +1,18 @@ +import QtQuick 2.0 + +Rectangle { + property real loaderWidth: loader.width + property real loaderHeight: loader.height + width: 200 + height: 200 + + Loader { + id: loader + sourceComponent: Item { + property real iwidth: 32 + property real iheight: 32 + width: iwidth + height: iheight + } + } +} diff --git a/tests/auto/quick/qquickloader/data/Rect120x60.qml b/tests/auto/quick/qquickloader/data/Rect120x60.qml new file mode 100644 index 0000000000..fc9e447e69 --- /dev/null +++ b/tests/auto/quick/qquickloader/data/Rect120x60.qml @@ -0,0 +1,6 @@ +import QtQuick 2.0 + +Rectangle { + width: 120 + height:60 +} diff --git a/tests/auto/quick/qquickloader/data/SetSourceComponent.qml b/tests/auto/quick/qquickloader/data/SetSourceComponent.qml new file mode 100644 index 0000000000..83cc358f7d --- /dev/null +++ b/tests/auto/quick/qquickloader/data/SetSourceComponent.qml @@ -0,0 +1,9 @@ +import QtQuick 2.0 + +Item { + function clear() { + loader.sourceComponent = undefined + } + Component { id: comp; Rectangle { width: 100; height: 50 } } + Loader { id: loader; sourceComponent: comp } +} diff --git a/tests/auto/quick/qquickloader/data/SizeGraphicsWidgetToLoader.qml b/tests/auto/quick/qquickloader/data/SizeGraphicsWidgetToLoader.qml new file mode 100644 index 0000000000..2a63b4d34f --- /dev/null +++ b/tests/auto/quick/qquickloader/data/SizeGraphicsWidgetToLoader.qml @@ -0,0 +1,7 @@ +import QtQuick 2.0 + +Loader { + width: 200 + height: 80 + source: "GraphicsWidget250x250.qml" +} diff --git a/tests/auto/quick/qquickloader/data/SizeLoaderToGraphicsWidget.qml b/tests/auto/quick/qquickloader/data/SizeLoaderToGraphicsWidget.qml new file mode 100644 index 0000000000..a9875d8e21 --- /dev/null +++ b/tests/auto/quick/qquickloader/data/SizeLoaderToGraphicsWidget.qml @@ -0,0 +1,5 @@ +import QtQuick 2.0 + +Loader { + source: "GraphicsWidget250x250.qml" +} diff --git a/tests/auto/quick/qquickloader/data/SizeToItem.qml b/tests/auto/quick/qquickloader/data/SizeToItem.qml new file mode 100644 index 0000000000..866365754f --- /dev/null +++ b/tests/auto/quick/qquickloader/data/SizeToItem.qml @@ -0,0 +1,5 @@ +import QtQuick 2.0 + +Loader { + source: "Rect120x60.qml" +} diff --git a/tests/auto/quick/qquickloader/data/SizeToLoader.qml b/tests/auto/quick/qquickloader/data/SizeToLoader.qml new file mode 100644 index 0000000000..dad18c6939 --- /dev/null +++ b/tests/auto/quick/qquickloader/data/SizeToLoader.qml @@ -0,0 +1,6 @@ +import QtQuick 2.0 + +Loader { + width: 200; height: 80 + source: "Rect120x60.qml" +} diff --git a/tests/auto/quick/qquickloader/data/VmeError.qml b/tests/auto/quick/qquickloader/data/VmeError.qml new file mode 100644 index 0000000000..0443aa9054 --- /dev/null +++ b/tests/auto/quick/qquickloader/data/VmeError.qml @@ -0,0 +1,7 @@ +import QtQuick 2.0 + +Rectangle { + width: 100; height: 100; color: "red" + signal somethingHappened + onSomethingHappened: QtObject {} +} diff --git a/tests/auto/quick/qquickloader/data/active.1.qml b/tests/auto/quick/qquickloader/data/active.1.qml new file mode 100644 index 0000000000..2dbd1a0887 --- /dev/null +++ b/tests/auto/quick/qquickloader/data/active.1.qml @@ -0,0 +1,31 @@ +import QtQuick 2.0 + +Item { + id: root + + Loader { + id: loader + objectName: "loader" + active: false + } + + Component { + id: inlineTestComponent + Item { + id: inlineTestItem + property int someProperty: 5 + } + } + + function doSetSource() { + loader.source = "ActiveComponent.qml"; + } + + function doSetSourceComponent() { + loader.sourceComponent = inlineTestComponent; + } + + function doSetActive() { + loader.active = true; + } +} diff --git a/tests/auto/quick/qquickloader/data/active.2.qml b/tests/auto/quick/qquickloader/data/active.2.qml new file mode 100644 index 0000000000..e561744c63 --- /dev/null +++ b/tests/auto/quick/qquickloader/data/active.2.qml @@ -0,0 +1,18 @@ +import QtQuick 2.0 + +Item { + id: root + + Loader { + id: loader + objectName: "loader" + source: "ActiveComponent.qml"; + + property int statusChangedCount: 0 + onStatusChanged: statusChangedCount = statusChangedCount + 1 + } + + function doSetInactive() { + loader.active = false; + } +} diff --git a/tests/auto/quick/qquickloader/data/active.3.qml b/tests/auto/quick/qquickloader/data/active.3.qml new file mode 100644 index 0000000000..0fbba959bb --- /dev/null +++ b/tests/auto/quick/qquickloader/data/active.3.qml @@ -0,0 +1,18 @@ +import QtQuick 2.0 + +Item { + id: root + + Loader { + id: loader + objectName: "loader" + source: "ActiveComponent.qml"; + + property int sourceChangedCount: 0 + onSourceChanged: sourceChangedCount = sourceChangedCount + 1 + } + + function doSetInactive() { + loader.active = false; + } +} diff --git a/tests/auto/quick/qquickloader/data/active.4.qml b/tests/auto/quick/qquickloader/data/active.4.qml new file mode 100644 index 0000000000..63fd46e2da --- /dev/null +++ b/tests/auto/quick/qquickloader/data/active.4.qml @@ -0,0 +1,26 @@ +import QtQuick 2.0 + +Item { + id: root + + Component { + id: inlineTestComponent + Item { + id: inlineTestItem + property int someProperty: 5 + } + } + + Loader { + id: loader + objectName: "loader" + sourceComponent: inlineTestComponent + + property int sourceComponentChangedCount: 0 + onSourceComponentChanged: sourceComponentChangedCount = sourceComponentChangedCount + 1 + } + + function doSetInactive() { + loader.active = false; + } +} diff --git a/tests/auto/quick/qquickloader/data/active.5.qml b/tests/auto/quick/qquickloader/data/active.5.qml new file mode 100644 index 0000000000..903f458a41 --- /dev/null +++ b/tests/auto/quick/qquickloader/data/active.5.qml @@ -0,0 +1,18 @@ +import QtQuick 2.0 + +Item { + id: root + + Loader { + id: loader + objectName: "loader" + source: "ActiveComponent.qml"; + + property int itemChangedCount: 0 + onItemChanged: itemChangedCount = itemChangedCount + 1 + } + + function doSetInactive() { + loader.active = false; + } +} diff --git a/tests/auto/quick/qquickloader/data/active.6.qml b/tests/auto/quick/qquickloader/data/active.6.qml new file mode 100644 index 0000000000..f769a4e184 --- /dev/null +++ b/tests/auto/quick/qquickloader/data/active.6.qml @@ -0,0 +1,21 @@ +import QtQuick 2.0 + +Item { + id: root + + Loader { + id: loader + objectName: "loader" + + property int activeChangedCount: 0 + onActiveChanged: activeChangedCount = activeChangedCount + 1 + } + + function doSetActive() { + loader.active = true; + } + + function doSetInactive() { + loader.active = false; + } +} diff --git a/tests/auto/quick/qquickloader/data/active.7.qml b/tests/auto/quick/qquickloader/data/active.7.qml new file mode 100644 index 0000000000..a29e932f5e --- /dev/null +++ b/tests/auto/quick/qquickloader/data/active.7.qml @@ -0,0 +1,14 @@ +import QtQuick 2.0 +Rectangle { + id: root + color: "blue" + width: 100; height: 100 + property bool success: true + + Loader { + active: false + anchors.fill: parent + sourceComponent: Rectangle { color: "red" } + onLoaded: { root.success = false; } // shouldn't be triggered if active is false + } +} diff --git a/tests/auto/quick/qquickloader/data/active.8.qml b/tests/auto/quick/qquickloader/data/active.8.qml new file mode 100644 index 0000000000..3a66d3e99a --- /dev/null +++ b/tests/auto/quick/qquickloader/data/active.8.qml @@ -0,0 +1,13 @@ +import QtQuick 2.0 +Rectangle { + id: root + color: "blue" + width: 100; height: 100 + property bool success: false + + Loader { + anchors.fill: parent + sourceComponent: Rectangle { color: "red" } + onLoaded: { root.success = true; } // should be triggered since active is true by default + } +} diff --git a/tests/auto/quick/qquickloader/data/asynchronous.qml b/tests/auto/quick/qquickloader/data/asynchronous.qml new file mode 100644 index 0000000000..29570525ad --- /dev/null +++ b/tests/auto/quick/qquickloader/data/asynchronous.qml @@ -0,0 +1,16 @@ +import QtQuick 2.0 + +Rectangle { + width: 400; height: 400 + + property string comp + function loadComponent() { + loader.source = comp + } + + Loader { + id: loader + objectName: "loader" + asynchronous: true + } +} diff --git a/tests/auto/quick/qquickloader/data/crash.qml b/tests/auto/quick/qquickloader/data/crash.qml new file mode 100644 index 0000000000..e6ddc33a10 --- /dev/null +++ b/tests/auto/quick/qquickloader/data/crash.qml @@ -0,0 +1,14 @@ +import QtQuick 2.0 + +Rectangle { + width: 400 + height: 400 + + function setLoaderSource() { + myLoader.source = "GreenRect.qml" + } + + Loader { + id: myLoader + } +} diff --git a/tests/auto/quick/qquickloader/data/creationContext.qml b/tests/auto/quick/qquickloader/data/creationContext.qml new file mode 100644 index 0000000000..17a596cc74 --- /dev/null +++ b/tests/auto/quick/qquickloader/data/creationContext.qml @@ -0,0 +1,8 @@ +import QtQuick 2.0 + +Item { + property bool test: false + + CreationContextLoader { + } +} diff --git a/tests/auto/quick/qquickloader/data/differentorigin.qml b/tests/auto/quick/qquickloader/data/differentorigin.qml new file mode 100644 index 0000000000..56a3034fe0 --- /dev/null +++ b/tests/auto/quick/qquickloader/data/differentorigin.qml @@ -0,0 +1,3 @@ +import QtQuick 2.0 + +Loader { source: "http://evil.place/evil.qml" } diff --git a/tests/auto/quick/qquickloader/data/implicitSize.qml b/tests/auto/quick/qquickloader/data/implicitSize.qml new file mode 100644 index 0000000000..5c8c8348ed --- /dev/null +++ b/tests/auto/quick/qquickloader/data/implicitSize.qml @@ -0,0 +1,28 @@ +import QtQuick 2.0 + +Rectangle { + property real implWidth: 0 + property real implHeight: 0 + color: "green" + width: loader.implicitWidth+50 + height: loader.implicitHeight+50 + + Loader { + id: loader + sourceComponent: Item { + anchors.centerIn: parent + + implicitWidth: 100 + implicitHeight: 100 + Rectangle { + color: "red" + anchors.fill: parent + } + } + + anchors.fill: parent + anchors.margins: 50 + onImplicitWidthChanged: implWidth = implicitWidth + onImplicitHeightChanged: implHeight = loader.implicitHeight + } +} diff --git a/tests/auto/quick/qquickloader/data/initialPropertyValues.1.qml b/tests/auto/quick/qquickloader/data/initialPropertyValues.1.qml new file mode 100644 index 0000000000..ae371797ce --- /dev/null +++ b/tests/auto/quick/qquickloader/data/initialPropertyValues.1.qml @@ -0,0 +1,22 @@ +import QtQuick 2.0 + +Item { + id: root + property int initialValue: 0 + property int behaviorCount: 0 + + Loader { + id: loader + objectName: "loader" + + onLoaded: { + loader.item.canary = 1; // will trigger the behavior, setting behaviorCount -> 1 + } + } + + Component.onCompleted: { + loader.source = "InitialPropertyValuesComponent.qml"; + root.initialValue = loader.item.canary; // should be one, since onLoaded will have triggered by now + root.behaviorCount = loader.item.behaviorCount; // should be one, since onLoaded will have triggered by now + } +} diff --git a/tests/auto/quick/qquickloader/data/initialPropertyValues.2.qml b/tests/auto/quick/qquickloader/data/initialPropertyValues.2.qml new file mode 100644 index 0000000000..76c7bc2fd6 --- /dev/null +++ b/tests/auto/quick/qquickloader/data/initialPropertyValues.2.qml @@ -0,0 +1,20 @@ +import QtQuick 2.0 + +Item { + id: root + property int initialValue: 0 + property int behaviorCount: 0 + + Loader { + id: loader + objectName: "loader" + onLoaded: { + root.initialValue = loader.item.canary; // should be two + root.behaviorCount = loader.item.behaviorCount; // should be zero + } + } + + Component.onCompleted: { + loader.setSource("InitialPropertyValuesComponent.qml", {"canary": 2}); + } +} diff --git a/tests/auto/quick/qquickloader/data/initialPropertyValues.3.qml b/tests/auto/quick/qquickloader/data/initialPropertyValues.3.qml new file mode 100644 index 0000000000..3b08e6ee42 --- /dev/null +++ b/tests/auto/quick/qquickloader/data/initialPropertyValues.3.qml @@ -0,0 +1,18 @@ +import QtQuick 2.0 + +Item { + id: root + property int initialValue: 0 + property int behaviorCount: 0 + + Loader { + id: loader + objectName: "loader" + active: false + } + + Component.onCompleted: { + loader.setSource("InitialPropertyValuesComponent.qml", {"canary": 3}); + root.initialValue = loader.item.canary; // error - item should not yet exist. + } +} diff --git a/tests/auto/quick/qquickloader/data/initialPropertyValues.4.qml b/tests/auto/quick/qquickloader/data/initialPropertyValues.4.qml new file mode 100644 index 0000000000..e8310044e8 --- /dev/null +++ b/tests/auto/quick/qquickloader/data/initialPropertyValues.4.qml @@ -0,0 +1,22 @@ +import QtQuick 2.0 + +Item { + id: root + property int initialValue: 0 + property int behaviorCount: 0 + + Loader { + id: loader + objectName: "loader" + active: false + onLoaded: { + root.initialValue = loader.item.canary; // should be four + root.behaviorCount = loader.item.behaviorCount; // should be zero + } + } + + Component.onCompleted: { + loader.setSource("InitialPropertyValuesComponent.qml", {"canary": 4}); + loader.active = true + } +} diff --git a/tests/auto/quick/qquickloader/data/initialPropertyValues.5.qml b/tests/auto/quick/qquickloader/data/initialPropertyValues.5.qml new file mode 100644 index 0000000000..03ee599aba --- /dev/null +++ b/tests/auto/quick/qquickloader/data/initialPropertyValues.5.qml @@ -0,0 +1,20 @@ +import QtQuick 2.0 + +Item { + id: root + property int initialValue: 0 + property int behaviorCount: 0 + + Loader { + id: loader + objectName: "loader" + onLoaded: { + root.initialValue = loader.item.canary; // should be zero, but no error + root.behaviorCount = loader.item.behaviorCount; // should be zero + } + } + + Component.onCompleted: { + loader.setSource("InitialPropertyValuesComponent.qml"); + } +} diff --git a/tests/auto/quick/qquickloader/data/initialPropertyValues.6.qml b/tests/auto/quick/qquickloader/data/initialPropertyValues.6.qml new file mode 100644 index 0000000000..66452b512b --- /dev/null +++ b/tests/auto/quick/qquickloader/data/initialPropertyValues.6.qml @@ -0,0 +1,25 @@ +import QtQuick 2.0 + +Item { + id: root + property int initialValue: 0 + property int behaviorCount: 0 + + Loader { + id: loader + objectName: "loader" + onLoaded: { + root.initialValue = loader.item.canary; // should be six + root.behaviorCount = loader.item.behaviorCount; // should be zero + } + } + + Item { + id: child + property int bindable: 6 + } + + Component.onCompleted: { + loader.setSource("InitialPropertyValuesComponent.qml", {"canary": child.bindable}); + } +} diff --git a/tests/auto/quick/qquickloader/data/initialPropertyValues.7.qml b/tests/auto/quick/qquickloader/data/initialPropertyValues.7.qml new file mode 100644 index 0000000000..02349f7ddf --- /dev/null +++ b/tests/auto/quick/qquickloader/data/initialPropertyValues.7.qml @@ -0,0 +1,29 @@ +import QtQuick 2.0 + +Item { + id: root + property int loaderValue: 0 + property int createObjectValue: 0 + + Loader { + id: loader + objectName: "loader" + onLoaded: { + root.loaderValue = loader.item.canary; // should still be one + } + } + + Item { + id: child + property int bindable: 1; + } + + property InitialPropertyValuesComponent ipvc + Component.onCompleted: { + loader.setSource("InitialPropertyValuesComponent.qml", {"canary": child.bindable}); + var dynComp = Qt.createComponent("InitialPropertyValuesComponent.qml"); + ipvc = dynComp.createObject(root, {"canary": child.bindable}); + child.bindable = 7; // won't cause re-evaluation, since not used in a binding. + root.createObjectValue = ipvc.canary; // should still be one + } +} diff --git a/tests/auto/quick/qquickloader/data/initialPropertyValues.8.qml b/tests/auto/quick/qquickloader/data/initialPropertyValues.8.qml new file mode 100644 index 0000000000..79e9264d4a --- /dev/null +++ b/tests/auto/quick/qquickloader/data/initialPropertyValues.8.qml @@ -0,0 +1,20 @@ +import QtQuick 2.0 + +Item { + id: root + property int initialValue: 0 + + Loader { + id: loader + objectName: "loader" + active: false + onLoaded: { + root.initialValue = loader.item.canary; // should be six + } + } + + Component.onCompleted: { + loader.setSource("http://127.0.0.1:14450/InitialPropertyValuesComponent.qml", {"canary": 6}); + loader.active = true; + } +} diff --git a/tests/auto/quick/qquickloader/data/initialPropertyValues.binding.qml b/tests/auto/quick/qquickloader/data/initialPropertyValues.binding.qml new file mode 100644 index 0000000000..e0df50a74a --- /dev/null +++ b/tests/auto/quick/qquickloader/data/initialPropertyValues.binding.qml @@ -0,0 +1,21 @@ +import QtQuick 2.0 + +Item { + id: root + + property InitialPropertyValuesComponent testInstance + testInstance: loader.item + + property int bindable: 1 + property int canaryValue: testInstance.canary + property int behaviorCount: testInstance.behaviorCount + + Loader { + id: loader + objectName: "loader" + } + + Component.onCompleted: { + loader.setSource("InitialPropertyValuesComponent.qml", {"canary": (function() { return root.bindable })}); + } +} diff --git a/tests/auto/quick/qquickloader/data/initialPropertyValues.error.1.qml b/tests/auto/quick/qquickloader/data/initialPropertyValues.error.1.qml new file mode 100644 index 0000000000..f324dbddac --- /dev/null +++ b/tests/auto/quick/qquickloader/data/initialPropertyValues.error.1.qml @@ -0,0 +1,14 @@ +import QtQuick 2.0 + +Item { + id: root + + Loader { + id: loader + objectName: "loader" + } + + Component.onCompleted: { + loader.setSource("InitialPropertyValuesComponent.qml", 3); // invalid initial properties object + } +} diff --git a/tests/auto/quick/qquickloader/data/initialPropertyValues.error.2.qml b/tests/auto/quick/qquickloader/data/initialPropertyValues.error.2.qml new file mode 100644 index 0000000000..89aba313c7 --- /dev/null +++ b/tests/auto/quick/qquickloader/data/initialPropertyValues.error.2.qml @@ -0,0 +1,14 @@ +import QtQuick 2.0 + +Item { + id: root + + Loader { + id: loader + objectName: "loader" + } + + Component.onCompleted: { + loader.setSource("NonexistentSourceComponent.qml", {"canary":3}); + } +} diff --git a/tests/auto/quick/qquickloader/data/initialPropertyValues.error.3.qml b/tests/auto/quick/qquickloader/data/initialPropertyValues.error.3.qml new file mode 100644 index 0000000000..c862007402 --- /dev/null +++ b/tests/auto/quick/qquickloader/data/initialPropertyValues.error.3.qml @@ -0,0 +1,14 @@ +import QtQuick 2.0 + +Item { + id: root + + Loader { + id: loader + objectName: "loader" + } + + Component.onCompleted: { + loader.setSource("InvalidSourceComponent.qml", {"canary":3}); + } +} diff --git a/tests/auto/quick/qquickloader/data/initialPropertyValues.error.4.qml b/tests/auto/quick/qquickloader/data/initialPropertyValues.error.4.qml new file mode 100644 index 0000000000..9a80b2156d --- /dev/null +++ b/tests/auto/quick/qquickloader/data/initialPropertyValues.error.4.qml @@ -0,0 +1,15 @@ +import QtQuick 2.0 + +Item { + id: root + property int canary: loader.item.canary + + Loader { + id: loader + objectName: "loader" + } + + Component.onCompleted: { + loader.setSource("InitialPropertyValuesComponent.qml", 3); // invalid initial properties object + } +} diff --git a/tests/auto/quick/qquickloader/data/nonItem.qml b/tests/auto/quick/qquickloader/data/nonItem.qml new file mode 100644 index 0000000000..8cfa0d8efb --- /dev/null +++ b/tests/auto/quick/qquickloader/data/nonItem.qml @@ -0,0 +1,5 @@ +import QtQuick 2.0 + +Loader { + sourceComponent: QtObject {} +} diff --git a/tests/auto/quick/qquickloader/data/parented.qml b/tests/auto/quick/qquickloader/data/parented.qml new file mode 100644 index 0000000000..1c19d4d1a5 --- /dev/null +++ b/tests/auto/quick/qquickloader/data/parented.qml @@ -0,0 +1,21 @@ +import QtQuick 2.0 + +Item { + id: root + width: 300; height: 300 + + Component { + id: comp + Rectangle { + objectName: "comp" + parent: root + anchors.fill: parent + color: "blue" + } + } + + Loader { + width: 200; height: 200 + sourceComponent: comp + } +} diff --git a/tests/auto/quick/qquickloader/data/qmldir b/tests/auto/quick/qquickloader/data/qmldir new file mode 100644 index 0000000000..bf42b507c0 --- /dev/null +++ b/tests/auto/quick/qquickloader/data/qmldir @@ -0,0 +1 @@ +# For tst_QDeclarativeLoader::networkRequestUrl; no types needed though. diff --git a/tests/auto/quick/qquickloader/data/sameorigin-load.qml b/tests/auto/quick/qquickloader/data/sameorigin-load.qml new file mode 100644 index 0000000000..3332500be6 --- /dev/null +++ b/tests/auto/quick/qquickloader/data/sameorigin-load.qml @@ -0,0 +1,3 @@ +import QtQuick 2.0 + +Item { } diff --git a/tests/auto/quick/qquickloader/data/sameorigin.qml b/tests/auto/quick/qquickloader/data/sameorigin.qml new file mode 100644 index 0000000000..84846b6aba --- /dev/null +++ b/tests/auto/quick/qquickloader/data/sameorigin.qml @@ -0,0 +1,3 @@ +import QtQuick 2.0 + +Loader { source: "sameorigin-load.qml" } diff --git a/tests/auto/quick/qquickloader/data/sizebound.qml b/tests/auto/quick/qquickloader/data/sizebound.qml new file mode 100644 index 0000000000..09cf32426a --- /dev/null +++ b/tests/auto/quick/qquickloader/data/sizebound.qml @@ -0,0 +1,30 @@ +import QtQuick 2.0 + +Item { + width: 200; height: 200 + + function switchComponent() { + load.sourceComponent = comp2 + } + + Component { + id: comp + Rectangle { + width: 50; height: 60; color: "red" + } + } + + Component { + id: comp2 + Rectangle { + width: 80; height: 90; color: "green" + } + } + + Loader { + id: load + objectName: "loader" + sourceComponent: comp + height: item ? item.height : 0 + } +} diff --git a/tests/auto/quick/qquickloader/data/vmeErrors.qml b/tests/auto/quick/qquickloader/data/vmeErrors.qml new file mode 100644 index 0000000000..8e6c89dc8e --- /dev/null +++ b/tests/auto/quick/qquickloader/data/vmeErrors.qml @@ -0,0 +1,6 @@ +import QtQuick 2.0 + +Loader { + source: "VmeError.qml" +} + diff --git a/tests/auto/quick/qquickloader/qquickloader.pro b/tests/auto/quick/qquickloader/qquickloader.pro new file mode 100644 index 0000000000..fd525351ab --- /dev/null +++ b/tests/auto/quick/qquickloader/qquickloader.pro @@ -0,0 +1,19 @@ +CONFIG += testcase +TARGET = tst_qquickloader +macx:CONFIG -= app_bundle + +INCLUDEPATH += ../../shared/ +HEADERS += ../../shared/testhttpserver.h + +SOURCES += tst_qquickloader.cpp \ + ../../shared/testhttpserver.cpp + +include (../../shared/util.pri) + +testDataFiles.files = data +testDataFiles.path = . +DEPLOYMENT += testDataFiles + +CONFIG += parallel_test + +QT += core-private gui-private qml-private quick-private network testlib diff --git a/tests/auto/quick/qquickloader/tst_qquickloader.cpp b/tests/auto/quick/qquickloader/tst_qquickloader.cpp new file mode 100644 index 0000000000..77d0c29220 --- /dev/null +++ b/tests/auto/quick/qquickloader/tst_qquickloader.cpp @@ -0,0 +1,987 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include + +#include + +#include +#include +#include +#include +#include "testhttpserver.h" +#include "../../shared/util.h" + +#define SERVER_PORT 14450 + +class PeriodicIncubationController : public QObject, + public QQmlIncubationController +{ +public: + PeriodicIncubationController() { + startTimer(16); + } + +protected: + virtual void timerEvent(QTimerEvent *) { + incubateFor(15); + } +}; + +class tst_QQuickLoader : public QQmlDataTest + +{ + Q_OBJECT +public: + tst_QQuickLoader(); + +private slots: + void sourceOrComponent(); + void sourceOrComponent_data(); + void clear(); + void urlToComponent(); + void componentToUrl(); + void anchoredLoader(); + void sizeLoaderToItem(); + void sizeItemToLoader(); + void noResize(); + void networkRequestUrl(); + void failNetworkRequest(); +// void networkComponent(); + void active(); + void initialPropertyValues_data(); + void initialPropertyValues(); + void initialPropertyValuesBinding(); + void initialPropertyValuesError_data(); + void initialPropertyValuesError(); + + void deleteComponentCrash(); + void nonItem(); + void vmeErrors(); + void creationContext(); + void QTBUG_16928(); + void implicitSize(); + void QTBUG_17114(); + void asynchronous_data(); + void asynchronous(); + void asynchronous_clear(); + + void parented(); + void sizeBound(); + +private: + QQmlEngine engine; +}; + + +tst_QQuickLoader::tst_QQuickLoader() +{ +} + +void tst_QQuickLoader::sourceOrComponent() +{ + QFETCH(QString, sourceOrComponent); + QFETCH(QString, sourceDefinition); + QFETCH(QUrl, sourceUrl); + QFETCH(QString, errorString); + + bool error = !errorString.isEmpty(); + if (error) + QTest::ignoreMessage(QtWarningMsg, errorString.toUtf8().constData()); + + QQmlComponent component(&engine); + component.setData(QByteArray( + "import QtQuick 2.0\n" + "Loader {\n" + " property int onItemChangedCount: 0\n" + " property int onSourceChangedCount: 0\n" + " property int onSourceComponentChangedCount: 0\n" + " property int onStatusChangedCount: 0\n" + " property int onProgressChangedCount: 0\n" + " property int onLoadedCount: 0\n") + + sourceDefinition.toUtf8() + + QByteArray( + " onItemChanged: onItemChangedCount += 1\n" + " onSourceChanged: onSourceChangedCount += 1\n" + " onSourceComponentChanged: onSourceComponentChangedCount += 1\n" + " onStatusChanged: onStatusChangedCount += 1\n" + " onProgressChanged: onProgressChangedCount += 1\n" + " onLoaded: onLoadedCount += 1\n" + "}") + , dataDirectoryUrl()); + + QQuickLoader *loader = qobject_cast(component.create()); + QVERIFY(loader != 0); + QCOMPARE(loader->item() == 0, error); + QCOMPARE(loader->source(), sourceUrl); + QCOMPARE(loader->progress(), 1.0); + + QCOMPARE(loader->status(), error ? QQuickLoader::Error : QQuickLoader::Ready); + QCOMPARE(static_cast(loader)->childItems().count(), error ? 0: 1); + + if (!error) { + bool sourceComponentIsChildOfLoader = false; + for (int ii = 0; ii < loader->children().size(); ++ii) { + QQmlComponent *c = qobject_cast(loader->children().at(ii)); + if (c && c == loader->sourceComponent()) { + sourceComponentIsChildOfLoader = true; + } + } + QVERIFY(sourceComponentIsChildOfLoader); + } + + if (sourceOrComponent == "component") { + QCOMPARE(loader->property("onSourceComponentChangedCount").toInt(), 1); + QCOMPARE(loader->property("onSourceChangedCount").toInt(), 0); + } else { + QCOMPARE(loader->property("onSourceComponentChangedCount").toInt(), 0); + QCOMPARE(loader->property("onSourceChangedCount").toInt(), 1); + } + QCOMPARE(loader->property("onStatusChangedCount").toInt(), 1); + QCOMPARE(loader->property("onProgressChangedCount").toInt(), 1); + + QCOMPARE(loader->property("onItemChangedCount").toInt(), error ? 0 : 1); + QCOMPARE(loader->property("onLoadedCount").toInt(), error ? 0 : 1); + + delete loader; +} + +void tst_QQuickLoader::sourceOrComponent_data() +{ + QTest::addColumn("sourceOrComponent"); + QTest::addColumn("sourceDefinition"); + QTest::addColumn("sourceUrl"); + QTest::addColumn("errorString"); + + QTest::newRow("source") << "source" << "source: 'Rect120x60.qml'\n" << testFileUrl("Rect120x60.qml") << ""; + QTest::newRow("sourceComponent") << "component" << "Component { id: comp; Rectangle { width: 100; height: 50 } }\n sourceComponent: comp\n" << QUrl() << ""; + QTest::newRow("invalid source") << "source" << "source: 'IDontExist.qml'\n" << testFileUrl("IDontExist.qml") + << QString(testFileUrl("IDontExist.qml").toString() + ": File not found"); +} + +void tst_QQuickLoader::clear() +{ + { + QQmlComponent component(&engine); + component.setData(QByteArray( + "import QtQuick 2.0\n" + " Loader { id: loader\n" + " source: 'Rect120x60.qml'\n" + " Timer { interval: 200; running: true; onTriggered: loader.source = '' }\n" + " }") + , dataDirectoryUrl()); + QQuickLoader *loader = qobject_cast(component.create()); + QVERIFY(loader != 0); + QVERIFY(loader->item()); + QCOMPARE(loader->progress(), 1.0); + QCOMPARE(static_cast(loader)->childItems().count(), 1); + + QTRY_VERIFY(loader->item() == 0); + QCOMPARE(loader->progress(), 0.0); + QCOMPARE(loader->status(), QQuickLoader::Null); + QCOMPARE(static_cast(loader)->childItems().count(), 0); + + delete loader; + } + { + QQmlComponent component(&engine, testFileUrl("/SetSourceComponent.qml")); + QQuickItem *item = qobject_cast(component.create()); + QVERIFY(item); + + QQuickLoader *loader = qobject_cast(item->QQuickItem::childItems().at(0)); + QVERIFY(loader); + QVERIFY(loader->item()); + QCOMPARE(loader->progress(), 1.0); + QCOMPARE(static_cast(loader)->childItems().count(), 1); + + loader->setSourceComponent(0); + + QVERIFY(loader->item() == 0); + QCOMPARE(loader->progress(), 0.0); + QCOMPARE(loader->status(), QQuickLoader::Null); + QCOMPARE(static_cast(loader)->childItems().count(), 0); + + delete item; + } + { + QQmlComponent component(&engine, testFileUrl("/SetSourceComponent.qml")); + QQuickItem *item = qobject_cast(component.create()); + QVERIFY(item); + + QQuickLoader *loader = qobject_cast(item->QQuickItem::childItems().at(0)); + QVERIFY(loader); + QVERIFY(loader->item()); + QCOMPARE(loader->progress(), 1.0); + QCOMPARE(static_cast(loader)->childItems().count(), 1); + + QMetaObject::invokeMethod(item, "clear"); + + QVERIFY(loader->item() == 0); + QCOMPARE(loader->progress(), 0.0); + QCOMPARE(loader->status(), QQuickLoader::Null); + QCOMPARE(static_cast(loader)->childItems().count(), 0); + + delete item; + } +} + +void tst_QQuickLoader::urlToComponent() +{ + QQmlComponent component(&engine); + component.setData(QByteArray("import QtQuick 2.0\n" + "Loader {\n" + " id: loader\n" + " Component { id: myComp; Rectangle { width: 10; height: 10 } }\n" + " source: \"Rect120x60.qml\"\n" + " Timer { interval: 100; running: true; onTriggered: loader.sourceComponent = myComp }\n" + "}" ) + , dataDirectoryUrl()); + QQuickLoader *loader = qobject_cast(component.create()); + QTest::qWait(200); + QTRY_VERIFY(loader != 0); + QVERIFY(loader->item()); + QCOMPARE(loader->progress(), 1.0); + QCOMPARE(static_cast(loader)->childItems().count(), 1); + QCOMPARE(loader->width(), 10.0); + QCOMPARE(loader->height(), 10.0); + + delete loader; +} + +void tst_QQuickLoader::componentToUrl() +{ + QQmlComponent component(&engine, testFileUrl("/SetSourceComponent.qml")); + QQuickItem *item = qobject_cast(component.create()); + QVERIFY(item); + + QQuickLoader *loader = qobject_cast(item->QQuickItem::childItems().at(0)); + QVERIFY(loader); + QVERIFY(loader->item()); + QCOMPARE(loader->progress(), 1.0); + QCOMPARE(static_cast(loader)->childItems().count(), 1); + + loader->setSource(testFileUrl("/Rect120x60.qml")); + QVERIFY(loader->item()); + QCOMPARE(loader->progress(), 1.0); + QCOMPARE(static_cast(loader)->childItems().count(), 1); + QCOMPARE(loader->width(), 120.0); + QCOMPARE(loader->height(), 60.0); + + delete item; +} + +void tst_QQuickLoader::anchoredLoader() +{ + QQmlComponent component(&engine, testFileUrl("/AnchoredLoader.qml")); + QQuickItem *rootItem = qobject_cast(component.create()); + QVERIFY(rootItem != 0); + QQuickItem *loader = rootItem->findChild("loader"); + QQuickItem *sourceElement = rootItem->findChild("sourceElement"); + + QVERIFY(loader != 0); + QVERIFY(sourceElement != 0); + + QCOMPARE(rootItem->width(), 300.0); + QCOMPARE(rootItem->height(), 200.0); + + QCOMPARE(loader->width(), 300.0); + QCOMPARE(loader->height(), 200.0); + + QCOMPARE(sourceElement->width(), 300.0); + QCOMPARE(sourceElement->height(), 200.0); +} + +void tst_QQuickLoader::sizeLoaderToItem() +{ + QQmlComponent component(&engine, testFileUrl("/SizeToItem.qml")); + QQuickLoader *loader = qobject_cast(component.create()); + QVERIFY(loader != 0); + QCOMPARE(loader->width(), 120.0); + QCOMPARE(loader->height(), 60.0); + + // Check resize + QQuickItem *rect = qobject_cast(loader->item()); + QVERIFY(rect); + rect->setWidth(150); + rect->setHeight(45); + QCOMPARE(loader->width(), 150.0); + QCOMPARE(loader->height(), 45.0); + + // Check explicit width + loader->setWidth(200.0); + QCOMPARE(loader->width(), 200.0); + QCOMPARE(rect->width(), 200.0); + rect->setWidth(100.0); // when rect changes ... + QCOMPARE(rect->width(), 100.0); // ... it changes + QCOMPARE(loader->width(), 200.0); // ... but loader stays the same + + // Check explicit height + loader->setHeight(200.0); + QCOMPARE(loader->height(), 200.0); + QCOMPARE(rect->height(), 200.0); + rect->setHeight(100.0); // when rect changes ... + QCOMPARE(rect->height(), 100.0); // ... it changes + QCOMPARE(loader->height(), 200.0); // ... but loader stays the same + + // Switch mode + loader->setWidth(180); + loader->setHeight(30); + QCOMPARE(rect->width(), 180.0); + QCOMPARE(rect->height(), 30.0); + + delete loader; +} + +void tst_QQuickLoader::sizeItemToLoader() +{ + QQmlComponent component(&engine, testFileUrl("/SizeToLoader.qml")); + QQuickLoader *loader = qobject_cast(component.create()); + QVERIFY(loader != 0); + QCOMPARE(loader->width(), 200.0); + QCOMPARE(loader->height(), 80.0); + + QQuickItem *rect = qobject_cast(loader->item()); + QVERIFY(rect); + QCOMPARE(rect->width(), 200.0); + QCOMPARE(rect->height(), 80.0); + + // Check resize + loader->setWidth(180); + loader->setHeight(30); + QCOMPARE(rect->width(), 180.0); + QCOMPARE(rect->height(), 30.0); + + // Switch mode + loader->resetWidth(); // reset explicit size + loader->resetHeight(); + rect->setWidth(160); + rect->setHeight(45); + QCOMPARE(loader->width(), 160.0); + QCOMPARE(loader->height(), 45.0); + + delete loader; +} + +void tst_QQuickLoader::noResize() +{ + QQmlComponent component(&engine, testFileUrl("/NoResize.qml")); + QQuickItem* item = qobject_cast(component.create()); + QVERIFY(item != 0); + QCOMPARE(item->width(), 200.0); + QCOMPARE(item->height(), 80.0); + + delete item; +} + +void tst_QQuickLoader::networkRequestUrl() +{ + TestHTTPServer server(SERVER_PORT); + QVERIFY(server.isValid()); + server.serveDirectory(dataDirectory()); + + QQmlComponent component(&engine); + component.setData(QByteArray("import QtQuick 2.0\nLoader { property int signalCount : 0; source: \"http://127.0.0.1:14450/Rect120x60.qml\"; onLoaded: signalCount += 1 }"), testFileUrl("../dummy.qml")); + if (component.isError()) + qDebug() << component.errors(); + QQuickLoader *loader = qobject_cast(component.create()); + QVERIFY(loader != 0); + + QTRY_VERIFY(loader->status() == QQuickLoader::Ready); + + QVERIFY(loader->item()); + QCOMPARE(loader->progress(), 1.0); + QCOMPARE(loader->property("signalCount").toInt(), 1); + QCOMPARE(static_cast(loader)->childItems().count(), 1); + + delete loader; +} + +/* XXX Component waits until all dependencies are loaded. Is this actually possible? +void tst_QQuickLoader::networkComponent() +{ + TestHTTPServer server(SERVER_PORT); + QVERIFY(server.isValid()); + server.serveDirectory("slowdata", TestHTTPServer::Delay); + + QQmlComponent component(&engine); + component.setData(QByteArray( + "import QtQuick 2.0\n" + "import \"http://127.0.0.1:14450/\" as NW\n" + "Item {\n" + " Component { id: comp; NW.SlowRect {} }\n" + " Loader { sourceComponent: comp } }") + , dataDirectoryUrl()); + + QQuickItem *item = qobject_cast(component.create()); + QVERIFY(item); + + QQuickLoader *loader = qobject_cast(item->QQuickItem::children().at(1)); + QVERIFY(loader); + QTRY_VERIFY(loader->status() == QQuickLoader::Ready); + + QVERIFY(loader->item()); + QCOMPARE(loader->progress(), 1.0); + QCOMPARE(loader->status(), QQuickLoader::Ready); + QCOMPARE(static_cast(loader)->children().count(), 1); + + delete loader; +} +*/ + +void tst_QQuickLoader::failNetworkRequest() +{ + TestHTTPServer server(SERVER_PORT); + QVERIFY(server.isValid()); + server.serveDirectory(dataDirectory()); + + QTest::ignoreMessage(QtWarningMsg, "http://127.0.0.1:14450/IDontExist.qml: File not found"); + + QQmlComponent component(&engine); + component.setData(QByteArray("import QtQuick 2.0\nLoader { property int did_load: 123; source: \"http://127.0.0.1:14450/IDontExist.qml\"; onLoaded: did_load=456 }"), QUrl::fromLocalFile("http://127.0.0.1:14450/dummy.qml")); + QQuickLoader *loader = qobject_cast(component.create()); + QVERIFY(loader != 0); + + QTRY_VERIFY(loader->status() == QQuickLoader::Error); + + QVERIFY(loader->item() == 0); + QCOMPARE(loader->progress(), 0.0); + QCOMPARE(loader->property("did_load").toInt(), 123); + QCOMPARE(static_cast(loader)->childItems().count(), 0); + + delete loader; +} + +void tst_QQuickLoader::active() +{ + // check that the item isn't instantiated until active is set to true + { + QQmlComponent component(&engine, testFileUrl("active.1.qml")); + QObject *object = component.create(); + QVERIFY(object != 0); + QQuickLoader *loader = object->findChild("loader"); + + QVERIFY(loader->active() == false); // set manually to false + QVERIFY(loader->item() == 0); + QMetaObject::invokeMethod(object, "doSetSourceComponent"); + QVERIFY(loader->item() == 0); + QMetaObject::invokeMethod(object, "doSetSource"); + QVERIFY(loader->item() == 0); + QMetaObject::invokeMethod(object, "doSetActive"); + QVERIFY(loader->item() != 0); + + delete object; + } + + // check that the status is Null if active is set to false + { + QQmlComponent component(&engine, testFileUrl("active.2.qml")); + QObject *object = component.create(); + QVERIFY(object != 0); + QQuickLoader *loader = object->findChild("loader"); + + QVERIFY(loader->active() == true); // active is true by default + QCOMPARE(loader->status(), QQuickLoader::Ready); + int currStatusChangedCount = loader->property("statusChangedCount").toInt(); + QMetaObject::invokeMethod(object, "doSetInactive"); + QCOMPARE(loader->status(), QQuickLoader::Null); + QCOMPARE(loader->property("statusChangedCount").toInt(), (currStatusChangedCount+1)); + + delete object; + } + + // check that the source is not cleared if active is set to false + { + QQmlComponent component(&engine, testFileUrl("active.3.qml")); + QObject *object = component.create(); + QVERIFY(object != 0); + QQuickLoader *loader = object->findChild("loader"); + + QVERIFY(loader->active() == true); // active is true by default + QVERIFY(!loader->source().isEmpty()); + int currSourceChangedCount = loader->property("sourceChangedCount").toInt(); + QMetaObject::invokeMethod(object, "doSetInactive"); + QVERIFY(!loader->source().isEmpty()); + QCOMPARE(loader->property("sourceChangedCount").toInt(), currSourceChangedCount); + + delete object; + } + + // check that the sourceComponent is not cleared if active is set to false + { + QQmlComponent component(&engine, testFileUrl("active.4.qml")); + QObject *object = component.create(); + QVERIFY(object != 0); + QQuickLoader *loader = object->findChild("loader"); + + QVERIFY(loader->active() == true); // active is true by default + QVERIFY(loader->sourceComponent() != 0); + int currSourceComponentChangedCount = loader->property("sourceComponentChangedCount").toInt(); + QMetaObject::invokeMethod(object, "doSetInactive"); + QVERIFY(loader->sourceComponent() != 0); + QCOMPARE(loader->property("sourceComponentChangedCount").toInt(), currSourceComponentChangedCount); + + delete object; + } + + // check that the item is released if active is set to false + { + QQmlComponent component(&engine, testFileUrl("active.5.qml")); + QObject *object = component.create(); + QVERIFY(object != 0); + QQuickLoader *loader = object->findChild("loader"); + + QVERIFY(loader->active() == true); // active is true by default + QVERIFY(loader->item() != 0); + int currItemChangedCount = loader->property("itemChangedCount").toInt(); + QMetaObject::invokeMethod(object, "doSetInactive"); + QVERIFY(loader->item() == 0); + QCOMPARE(loader->property("itemChangedCount").toInt(), (currItemChangedCount+1)); + + delete object; + } + + // check that the activeChanged signal is emitted correctly + { + QQmlComponent component(&engine, testFileUrl("active.6.qml")); + QObject *object = component.create(); + QVERIFY(object != 0); + QQuickLoader *loader = object->findChild("loader"); + + QVERIFY(loader->active() == true); // active is true by default + loader->setActive(true); // no effect + QCOMPARE(loader->property("activeChangedCount").toInt(), 0); + loader->setActive(false); // change signal should be emitted + QCOMPARE(loader->property("activeChangedCount").toInt(), 1); + loader->setActive(false); // no effect + QCOMPARE(loader->property("activeChangedCount").toInt(), 1); + loader->setActive(true); // change signal should be emitted + QCOMPARE(loader->property("activeChangedCount").toInt(), 2); + loader->setActive(false); // change signal should be emitted + QCOMPARE(loader->property("activeChangedCount").toInt(), 3); + QMetaObject::invokeMethod(object, "doSetActive"); + QCOMPARE(loader->property("activeChangedCount").toInt(), 4); + QMetaObject::invokeMethod(object, "doSetActive"); + QCOMPARE(loader->property("activeChangedCount").toInt(), 4); + QMetaObject::invokeMethod(object, "doSetInactive"); + QCOMPARE(loader->property("activeChangedCount").toInt(), 5); + loader->setActive(true); // change signal should be emitted + QCOMPARE(loader->property("activeChangedCount").toInt(), 6); + + delete object; + } + + // check that the component isn't loaded until active is set to true + { + QQmlComponent component(&engine, testFileUrl("active.7.qml")); + QObject *object = component.create(); + QVERIFY(object != 0); + QCOMPARE(object->property("success").toBool(), true); + delete object; + } + + // check that the component is loaded if active is not set (true by default) + { + QQmlComponent component(&engine, testFileUrl("active.8.qml")); + QObject *object = component.create(); + QVERIFY(object != 0); + QCOMPARE(object->property("success").toBool(), true); + delete object; + } +} + +void tst_QQuickLoader::initialPropertyValues_data() +{ + QTest::addColumn("qmlFile"); + QTest::addColumn("expectedWarnings"); + QTest::addColumn("propertyNames"); + QTest::addColumn("propertyValues"); + + QTest::newRow("source url with value set in onLoaded, initially active = true") << testFileUrl("initialPropertyValues.1.qml") + << QStringList() + << (QStringList() << "initialValue" << "behaviorCount") + << (QVariantList() << 1 << 1); + + QTest::newRow("set source with initial property values specified, active = true") << testFileUrl("initialPropertyValues.2.qml") + << QStringList() + << (QStringList() << "initialValue" << "behaviorCount") + << (QVariantList() << 2 << 0); + + QTest::newRow("set source with initial property values specified, active = false") << testFileUrl("initialPropertyValues.3.qml") + << (QStringList() << QString(QLatin1String("file://") + testFileUrl("initialPropertyValues.3.qml").toLocalFile() + QLatin1String(":16: TypeError: Cannot read property 'canary' of null"))) + << (QStringList()) + << (QVariantList()); + + QTest::newRow("set source with initial property values specified, active = false, with active set true later") << testFileUrl("initialPropertyValues.4.qml") + << QStringList() + << (QStringList() << "initialValue" << "behaviorCount") + << (QVariantList() << 4 << 0); + + QTest::newRow("set source without initial property values specified, active = true") << testFileUrl("initialPropertyValues.5.qml") + << QStringList() + << (QStringList() << "initialValue" << "behaviorCount") + << (QVariantList() << 0 << 0); + + QTest::newRow("set source with initial property values specified with binding, active = true") << testFileUrl("initialPropertyValues.6.qml") + << QStringList() + << (QStringList() << "initialValue" << "behaviorCount") + << (QVariantList() << 6 << 0); + + QTest::newRow("ensure initial property value semantics mimic createObject") << testFileUrl("initialPropertyValues.7.qml") + << QStringList() + << (QStringList() << "loaderValue" << "createObjectValue") + << (QVariantList() << 1 << 1); + + QTest::newRow("ensure initial property values aren't disposed prior to component completion") << testFileUrl("initialPropertyValues.8.qml") + << QStringList() + << (QStringList() << "initialValue") + << (QVariantList() << 6); +} + +void tst_QQuickLoader::initialPropertyValues() +{ + QFETCH(QUrl, qmlFile); + QFETCH(QStringList, expectedWarnings); + QFETCH(QStringList, propertyNames); + QFETCH(QVariantList, propertyValues); + + TestHTTPServer server(SERVER_PORT); + QVERIFY(server.isValid()); + server.serveDirectory(dataDirectory()); + + foreach (const QString &warning, expectedWarnings) + QTest::ignoreMessage(QtWarningMsg, warning.toAscii().constData()); + + QQmlComponent component(&engine, qmlFile); + QObject *object = component.create(); + QVERIFY(object != 0); + qApp->processEvents(); + QTest::qWait(50); + + for (int i = 0; i < propertyNames.size(); ++i) + QCOMPARE(object->property(propertyNames.at(i).toAscii().constData()), propertyValues.at(i)); + + delete object; +} + +void tst_QQuickLoader::initialPropertyValuesBinding() +{ + QQmlComponent component(&engine, testFileUrl("initialPropertyValues.binding.qml")); + QObject *object = component.create(); + QVERIFY(object != 0); + + QVERIFY(object->setProperty("bindable", QVariant(8))); + QCOMPARE(object->property("canaryValue").toInt(), 8); + + delete object; +} + +void tst_QQuickLoader::initialPropertyValuesError_data() +{ + QTest::addColumn("qmlFile"); + QTest::addColumn("expectedWarnings"); + + QTest::newRow("invalid initial property values object") << testFileUrl("initialPropertyValues.error.1.qml") + << (QStringList() << QString(testFileUrl("initialPropertyValues.error.1.qml").toString() + ":6:5: QML Loader: setSource: value is not an object")); + + QTest::newRow("nonexistent source url") << testFileUrl("initialPropertyValues.error.2.qml") + << (QStringList() << QString(testFileUrl("NonexistentSourceComponent.qml").toString() + ": File not found")); + + QTest::newRow("invalid source url") << testFileUrl("initialPropertyValues.error.3.qml") + << (QStringList() << QString(testFileUrl("InvalidSourceComponent.qml").toString() + ":5:1: Syntax error")); + + QTest::newRow("invalid initial property values object with invalid property access") << testFileUrl("initialPropertyValues.error.4.qml") + << (QStringList() << QString(testFileUrl("initialPropertyValues.error.4.qml").toString() + ":7:5: QML Loader: setSource: value is not an object") + << QString(testFileUrl("initialPropertyValues.error.4.qml").toString() + ":5: TypeError: Cannot read property 'canary' of null")); +} + +void tst_QQuickLoader::initialPropertyValuesError() +{ + QFETCH(QUrl, qmlFile); + QFETCH(QStringList, expectedWarnings); + + foreach (const QString &warning, expectedWarnings) + QTest::ignoreMessage(QtWarningMsg, warning.toUtf8().constData()); + + QQmlComponent component(&engine, qmlFile); + QObject *object = component.create(); + QVERIFY(object != 0); + QQuickLoader *loader = object->findChild("loader"); + QVERIFY(loader != 0); + QVERIFY(loader->item() == 0); + delete object; +} + +// QTBUG-9241 +void tst_QQuickLoader::deleteComponentCrash() +{ + QQmlComponent component(&engine, testFileUrl("crash.qml")); + QQuickItem *item = qobject_cast(component.create()); + QVERIFY(item); + + item->metaObject()->invokeMethod(item, "setLoaderSource"); + + QQuickLoader *loader = qobject_cast(item->QQuickItem::childItems().at(0)); + QVERIFY(loader); + QVERIFY(loader->item()); + QCOMPARE(loader->item()->objectName(), QLatin1String("blue")); + QCOMPARE(loader->progress(), 1.0); + QCOMPARE(loader->status(), QQuickLoader::Ready); + QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete); + QCoreApplication::processEvents(); + QTRY_COMPARE(static_cast(loader)->childItems().count(), 1); + QVERIFY(loader->source() == testFileUrl("BlueRect.qml")); + + delete item; +} + +void tst_QQuickLoader::nonItem() +{ + QQmlComponent component(&engine, testFileUrl("nonItem.qml")); + QString err = testFileUrl("nonItem.qml").toString() + ":3:1: QML Loader: Loader does not support loading non-visual elements."; + + QTest::ignoreMessage(QtWarningMsg, err.toLatin1().constData()); + QQuickLoader *loader = qobject_cast(component.create()); + QVERIFY(loader); + QVERIFY(loader->item() == 0); + + delete loader; +} + +void tst_QQuickLoader::vmeErrors() +{ + QQmlComponent component(&engine, testFileUrl("vmeErrors.qml")); + QString err = testFileUrl("VmeError.qml").toString() + ":6: Cannot assign object type QObject with no default method"; + QTest::ignoreMessage(QtWarningMsg, err.toLatin1().constData()); + QQuickLoader *loader = qobject_cast(component.create()); + QVERIFY(loader); + QVERIFY(loader->item() == 0); + + delete loader; +} + +// QTBUG-13481 +void tst_QQuickLoader::creationContext() +{ + QQmlComponent component(&engine, testFileUrl("creationContext.qml")); + + QObject *o = component.create(); + QVERIFY(o != 0); + + QCOMPARE(o->property("test").toBool(), true); + + delete o; +} + +void tst_QQuickLoader::QTBUG_16928() +{ + QQmlComponent component(&engine, testFileUrl("QTBUG_16928.qml")); + QQuickItem *item = qobject_cast(component.create()); + QVERIFY(item); + + QCOMPARE(item->width(), 250.); + QCOMPARE(item->height(), 250.); + + delete item; +} + +void tst_QQuickLoader::implicitSize() +{ + QQmlComponent component(&engine, testFileUrl("implicitSize.qml")); + QQuickItem *item = qobject_cast(component.create()); + QVERIFY(item); + + QCOMPARE(item->width(), 150.); + QCOMPARE(item->height(), 150.); + + QCOMPARE(item->property("implHeight").toReal(), 100.); + QCOMPARE(item->property("implWidth").toReal(), 100.); + + delete item; +} + +void tst_QQuickLoader::QTBUG_17114() +{ + QQmlComponent component(&engine, testFileUrl("QTBUG_17114.qml")); + QQuickItem *item = qobject_cast(component.create()); + QVERIFY(item); + + QCOMPARE(item->property("loaderWidth").toReal(), 32.); + QCOMPARE(item->property("loaderHeight").toReal(), 32.); + + delete item; +} + +void tst_QQuickLoader::asynchronous_data() +{ + QTest::addColumn("qmlFile"); + QTest::addColumn("expectedWarnings"); + + QTest::newRow("Valid component") << testFileUrl("BigComponent.qml") + << QStringList(); + + QTest::newRow("Non-existant component") << testFileUrl("IDoNotExist.qml") + << (QStringList() << QString(testFileUrl("IDoNotExist.qml").toString() + ": File not found")); + + QTest::newRow("Invalid component") << testFileUrl("InvalidSourceComponent.qml") + << (QStringList() << QString(testFileUrl("InvalidSourceComponent.qml").toString() + ":5:1: Syntax error")); +} + +void tst_QQuickLoader::asynchronous() +{ + QFETCH(QUrl, qmlFile); + QFETCH(QStringList, expectedWarnings); + + if (!engine.incubationController()) + engine.setIncubationController(new PeriodicIncubationController); + QQmlComponent component(&engine, testFileUrl("asynchronous.qml")); + QQuickItem *root = qobject_cast(component.create()); + QVERIFY(root); + + QQuickLoader *loader = root->findChild("loader"); + QVERIFY(loader); + + foreach (const QString &warning, expectedWarnings) + QTest::ignoreMessage(QtWarningMsg, warning.toUtf8().constData()); + + QVERIFY(!loader->item()); + root->setProperty("comp", qmlFile.toString()); + QMetaObject::invokeMethod(root, "loadComponent"); + QVERIFY(!loader->item()); + + if (expectedWarnings.isEmpty()) { + QCOMPARE(loader->status(), QQuickLoader::Loading); + QCOMPARE(engine.incubationController()->incubatingObjectCount(), 1); + + QTRY_VERIFY(loader->item()); + QCOMPARE(loader->progress(), 1.0); + QCOMPARE(loader->status(), QQuickLoader::Ready); + } else { + QCOMPARE(loader->progress(), 1.0); + QTRY_COMPARE(loader->status(), QQuickLoader::Error); + } + + delete root; +} + +void tst_QQuickLoader::asynchronous_clear() +{ + if (!engine.incubationController()) + engine.setIncubationController(new PeriodicIncubationController); + QQmlComponent component(&engine, testFileUrl("asynchronous.qml")); + QQuickItem *root = qobject_cast(component.create()); + QVERIFY(root); + + QQuickLoader *loader = root->findChild("loader"); + QVERIFY(loader); + + QVERIFY(!loader->item()); + root->setProperty("comp", "BigComponent.qml"); + QMetaObject::invokeMethod(root, "loadComponent"); + QVERIFY(!loader->item()); + + QCOMPARE(loader->status(), QQuickLoader::Loading); + QCOMPARE(engine.incubationController()->incubatingObjectCount(), 1); + + // clear before component created + root->setProperty("comp", ""); + QMetaObject::invokeMethod(root, "loadComponent"); + QVERIFY(!loader->item()); + QCOMPARE(engine.incubationController()->incubatingObjectCount(), 0); + + QCOMPARE(loader->progress(), 0.0); + QCOMPARE(loader->status(), QQuickLoader::Null); + QCOMPARE(static_cast(loader)->childItems().count(), 0); + + // check loading component + root->setProperty("comp", "Rect120x60.qml"); + QMetaObject::invokeMethod(root, "loadComponent"); + QVERIFY(!loader->item()); + + QCOMPARE(loader->status(), QQuickLoader::Loading); + QCOMPARE(engine.incubationController()->incubatingObjectCount(), 1); + + QTRY_VERIFY(loader->item()); + QCOMPARE(loader->progress(), 1.0); + QCOMPARE(loader->status(), QQuickLoader::Ready); + QCOMPARE(static_cast(loader)->childItems().count(), 1); +} + +void tst_QQuickLoader::parented() +{ + QQmlComponent component(&engine, testFileUrl("parented.qml")); + QQuickItem *root = qobject_cast(component.create()); + QVERIFY(root); + + QQuickItem *item = root->findChild("comp"); + QVERIFY(item); + + QVERIFY(item->parentItem() == root); + + QCOMPARE(item->width(), 300.); + QCOMPARE(item->height(), 300.); + + delete root; +} + +void tst_QQuickLoader::sizeBound() +{ + QQmlComponent component(&engine, testFileUrl("sizebound.qml")); + QQuickItem *root = qobject_cast(component.create()); + QVERIFY(root); + QQuickLoader *loader = root->findChild("loader"); + QVERIFY(loader != 0); + + QVERIFY(loader->item()); + + QCOMPARE(loader->width(), 50.0); + QCOMPARE(loader->height(), 60.0); + + QMetaObject::invokeMethod(root, "switchComponent"); + + QCOMPARE(loader->width(), 80.0); + QCOMPARE(loader->height(), 90.0); + + delete root; +} + + +QTEST_MAIN(tst_QQuickLoader) + +#include "tst_qquickloader.moc" diff --git a/tests/auto/quick/qquickmousearea/data/clickThrough.qml b/tests/auto/quick/qquickmousearea/data/clickThrough.qml new file mode 100644 index 0000000000..3c03161faa --- /dev/null +++ b/tests/auto/quick/qquickmousearea/data/clickThrough.qml @@ -0,0 +1,25 @@ +import QtQuick 2.0 + +Item{ + width: 200 + height: 200 + property int doubleClicks: 0 + property int clicks: 0 + property int pressAndHolds: 0 + property int presses: 0 + MouseArea{ + z: 0 + anchors.fill: parent + propagateComposedEvents: true + onPressed: presses++ + onClicked: clicks++ + onPressAndHold: pressAndHolds++ + onDoubleClicked: doubleClicks++ + } + MouseArea{ + z: 1 + propagateComposedEvents: true + enabled: true + anchors.fill: parent + } +} diff --git a/tests/auto/quick/qquickmousearea/data/clickThrough2.qml b/tests/auto/quick/qquickmousearea/data/clickThrough2.qml new file mode 100644 index 0000000000..2624108225 --- /dev/null +++ b/tests/auto/quick/qquickmousearea/data/clickThrough2.qml @@ -0,0 +1,35 @@ +import QtQuick 2.0 + +Item{ + width: 300 + height: 300 + property int doubleClicks: 0 + property int clicks: 0 + property int pressAndHolds: 0 + property int presses: 0 + property bool letThrough: false + property bool noPropagation: false + Rectangle{ + z: 0 + color: "lightsteelblue" + width: 150 + height: 150 + MouseArea{ + anchors.fill: parent + propagateComposedEvents: true + onPressed: presses++ + onClicked: clicks++ + onPressAndHold: pressAndHolds++ + onDoubleClicked: doubleClicks++ + } + } + MouseArea{ + z: 1 + enabled: true + anchors.fill: parent + propagateComposedEvents: !noPropagation + onClicked: mouse.accepted = !letThrough; + onDoubleClicked: mouse.accepted = !letThrough; + onPressAndHold: mouse.accepted = !letThrough; + } +} diff --git a/tests/auto/quick/qquickmousearea/data/clickandhold.qml b/tests/auto/quick/qquickmousearea/data/clickandhold.qml new file mode 100644 index 0000000000..5e4e48f6db --- /dev/null +++ b/tests/auto/quick/qquickmousearea/data/clickandhold.qml @@ -0,0 +1,13 @@ +import QtQuick 2.0 + +Item { + id: root + property bool clicked: false + property bool held: false + + MouseArea { + width: 200; height: 200 + onClicked: { root.clicked = true } + onPressAndHold: { root.held = true } + } +} diff --git a/tests/auto/quick/qquickmousearea/data/clicktwice.qml b/tests/auto/quick/qquickmousearea/data/clicktwice.qml new file mode 100644 index 0000000000..002d1b9047 --- /dev/null +++ b/tests/auto/quick/qquickmousearea/data/clicktwice.qml @@ -0,0 +1,16 @@ +import QtQuick 2.0 + +Item { + id: root + property int clicked: 0 + property int pressed: 0 + property int released: 0 + + MouseArea { + width: 200; height: 200 + onPressed: { root.pressed++ } + onClicked: { root.clicked++ } + onReleased: { root.released++ } + } +} + diff --git a/tests/auto/quick/qquickmousearea/data/doubleclick.qml b/tests/auto/quick/qquickmousearea/data/doubleclick.qml new file mode 100644 index 0000000000..1030d0c33e --- /dev/null +++ b/tests/auto/quick/qquickmousearea/data/doubleclick.qml @@ -0,0 +1,16 @@ +import QtQuick 2.0 + +Item { + id: root + property int clicked: 0 + property int doubleClicked: 0 + property int released: 0 + + MouseArea { + width: 200; height: 200 + onClicked: { root.clicked++ } + onDoubleClicked: { root.doubleClicked++ } + onReleased: { root.released++ } + } +} + diff --git a/tests/auto/quick/qquickmousearea/data/dragging.qml b/tests/auto/quick/qquickmousearea/data/dragging.qml new file mode 100644 index 0000000000..d9b6ac4083 --- /dev/null +++ b/tests/auto/quick/qquickmousearea/data/dragging.qml @@ -0,0 +1,28 @@ +import QtQuick 2.0 +Rectangle { + id: whiteRect + width: 200 + height: 200 + color: "white" + Rectangle { + id: blackRect + objectName: "blackrect" + color: "black" + y: 50 + x: 50 + width: 100 + height: 100 + opacity: (whiteRect.width-blackRect.x+whiteRect.height-blackRect.y-199)/200 + Text { text: blackRect.opacity} + MouseArea { + objectName: "mouseregion" + anchors.fill: parent + drag.target: blackRect + drag.axis: Drag.XandYAxis + drag.minimumX: 0 + drag.maximumX: whiteRect.width-blackRect.width + drag.minimumY: 0 + drag.maximumY: whiteRect.height-blackRect.height + } + } + } diff --git a/tests/auto/quick/qquickmousearea/data/dragproperties.qml b/tests/auto/quick/qquickmousearea/data/dragproperties.qml new file mode 100644 index 0000000000..421dfe26b7 --- /dev/null +++ b/tests/auto/quick/qquickmousearea/data/dragproperties.qml @@ -0,0 +1,28 @@ +import QtQuick 2.0 +Rectangle { + id: whiteRect + width: 200 + height: 200 + color: "white" + Rectangle { + id: blackRect + objectName: "blackrect" + color: "black" + y: 50 + x: 50 + width: 100 + height: 100 + opacity: (whiteRect.width-blackRect.x+whiteRect.height-blackRect.y-199)/200 + Text { text: blackRect.opacity} + MouseArea { + objectName: "mouseregion" + anchors.fill: parent + drag.target: blackRect + drag.axis: Drag.XandYAxis + drag.minimumX: 0 + drag.maximumX: whiteRect.width-blackRect.width + drag.minimumY: 0 + drag.maximumY: whiteRect.height-blackRect.height + } + } + } diff --git a/tests/auto/quick/qquickmousearea/data/dragreset.qml b/tests/auto/quick/qquickmousearea/data/dragreset.qml new file mode 100644 index 0000000000..d7949f9139 --- /dev/null +++ b/tests/auto/quick/qquickmousearea/data/dragreset.qml @@ -0,0 +1,28 @@ +import QtQuick 2.0 +Rectangle { + id: whiteRect + width: 200 + height: 200 + color: "white" + Rectangle { + id: blackRect + objectName: "blackrect" + color: "black" + y: 50 + x: 50 + width: 100 + height: 100 + opacity: (whiteRect.width-blackRect.x+whiteRect.height-blackRect.y-199)/200 + Text { text: blackRect.opacity} + MouseArea { + objectName: "mouseregion" + anchors.fill: parent + drag.target: haveTarget ? blackRect : undefined + drag.axis: Drag.XandYAxis + drag.minimumX: 0 + drag.maximumX: whiteRect.width-blackRect.width + drag.minimumY: 0 + drag.maximumY: whiteRect.height-blackRect.height + } + } + } diff --git a/tests/auto/quick/qquickmousearea/data/hoverPosition.qml b/tests/auto/quick/qquickmousearea/data/hoverPosition.qml new file mode 100644 index 0000000000..834f91ff29 --- /dev/null +++ b/tests/auto/quick/qquickmousearea/data/hoverPosition.qml @@ -0,0 +1,17 @@ +import QtQuick 2.0 + +Rectangle { + width: 400; height: 400; + + property real mouseX: mousetracker.mouseX + property real mouseY: mousetracker.mouseY + + Rectangle { + width: 100; height: 100; + MouseArea { + id: mousetracker; + anchors.fill: parent; + hoverEnabled: true + } + } +} diff --git a/tests/auto/quick/qquickmousearea/data/hoverPropagation.qml b/tests/auto/quick/qquickmousearea/data/hoverPropagation.qml new file mode 100644 index 0000000000..c47c794132 --- /dev/null +++ b/tests/auto/quick/qquickmousearea/data/hoverPropagation.qml @@ -0,0 +1,54 @@ +import QtQuick 2.0 + +Item{ + width: 400 + height: 200 + property bool point1: ma2.containsMouse && !ma1.containsMouse + property bool point2: ma3.containsMouse && ma4.containsMouse + Rectangle{ + width: 200 + height: 200 + color: ma1.containsMouse ? "red" : "white" + MouseArea{ + id: ma1 + hoverEnabled: true + anchors.fill: parent + } + Rectangle{ + width: 100 + height: 100 + color: ma2.containsMouse ? "blue" : "white" + MouseArea{ + id: ma2 + hoverEnabled: true + anchors.fill: parent + } + } + } + + Item{ + x:200 + Rectangle{ + width: 200 + height: 200 + color: ma3.containsMouse ? "yellow" : "white" + Rectangle{ + width: 100 + height: 100 + color: ma4.containsMouse ? "green" : "white" + } + } + MouseArea{ + id: ma3 + hoverEnabled: true + width: 200 + height: 200 + MouseArea{ + id: ma4 + width: 100 + height: 100 + hoverEnabled: true + } + } + } +} diff --git a/tests/auto/quick/qquickmousearea/data/hoverVisible.qml b/tests/auto/quick/qquickmousearea/data/hoverVisible.qml new file mode 100644 index 0000000000..2d65b5573e --- /dev/null +++ b/tests/auto/quick/qquickmousearea/data/hoverVisible.qml @@ -0,0 +1,15 @@ +import QtQuick 2.0 + +Rectangle { + width: 400; height: 400; + + Rectangle { + width: 100; height: 100; + MouseArea { + id: mousetracker; objectName: "mousetracker" + anchors.fill: parent + visible: false + hoverEnabled: true + } + } +} diff --git a/tests/auto/quick/qquickmousearea/data/noclickandhold.qml b/tests/auto/quick/qquickmousearea/data/noclickandhold.qml new file mode 100644 index 0000000000..6647de001d --- /dev/null +++ b/tests/auto/quick/qquickmousearea/data/noclickandhold.qml @@ -0,0 +1,11 @@ +import QtQuick 2.0 + +Item { + id: root + property bool clicked: false + + MouseArea { + width: 200; height: 200 + onClicked: { root.clicked = true } + } +} diff --git a/tests/auto/quick/qquickmousearea/data/pressedCanceled.qml b/tests/auto/quick/qquickmousearea/data/pressedCanceled.qml new file mode 100644 index 0000000000..231436d0f2 --- /dev/null +++ b/tests/auto/quick/qquickmousearea/data/pressedCanceled.qml @@ -0,0 +1,18 @@ +import QtQuick 2.0 + +Rectangle { + id: root + color: "#ffffff" + width: 320; height: 240 + property bool pressed:mouse.pressed + property bool canceled: false + property bool released: false + + MouseArea { + id: mouse + anchors.fill: parent + onPressed: { root.canceled = false } + onCanceled: {root.canceled = true} + onReleased: {root.released = true; root.canceled = false} + } +} \ No newline at end of file diff --git a/tests/auto/quick/qquickmousearea/data/pressedOrdering.qml b/tests/auto/quick/qquickmousearea/data/pressedOrdering.qml new file mode 100644 index 0000000000..7aa3098100 --- /dev/null +++ b/tests/auto/quick/qquickmousearea/data/pressedOrdering.qml @@ -0,0 +1,28 @@ +import QtQuick 2.0 + +Item { + id: root + property string value: "base" + + MouseArea { + id: mouseArea + width: 200; height: 200 + onClicked: toggleState.state = "toggled" + } + + StateGroup { + states: State { + name: "pressed" + when: mouseArea.pressed + PropertyChanges { target: root; value: "pressed" } + } + } + + StateGroup { + id: toggleState + states: State { + name: "toggled" + PropertyChanges { target: root; value: "toggled" } + } + } +} diff --git a/tests/auto/quick/qquickmousearea/data/preventstealing.qml b/tests/auto/quick/qquickmousearea/data/preventstealing.qml new file mode 100644 index 0000000000..fb0d6955c1 --- /dev/null +++ b/tests/auto/quick/qquickmousearea/data/preventstealing.qml @@ -0,0 +1,24 @@ +import QtQuick 2.0 + +Flickable { + property bool stealing: true + width: 200 + height: 200 + contentWidth: 400 + contentHeight: 400 + Rectangle { + color: "black" + width: 400 + height: 400 + Rectangle { + x: 50; y: 50 + width: 100; height: 100 + color: "steelblue" + MouseArea { + objectName: "mousearea" + anchors.fill: parent + preventStealing: stealing + } + } + } +} diff --git a/tests/auto/quick/qquickmousearea/data/rejectEvent.qml b/tests/auto/quick/qquickmousearea/data/rejectEvent.qml new file mode 100644 index 0000000000..816fc76fac --- /dev/null +++ b/tests/auto/quick/qquickmousearea/data/rejectEvent.qml @@ -0,0 +1,28 @@ +import QtQuick 2.0 + +Rectangle { + id: root + color: "#ffffff" + width: 320; height: 240 + property bool mr1_pressed: false + property bool mr1_released: false + property bool mr1_canceled: false + property bool mr2_pressed: false + property bool mr2_released: false + property bool mr2_canceled: false + + MouseArea { + id: mouseRegion1 + anchors.fill: parent + onPressed: { root.mr1_pressed = true } + onReleased: { root.mr1_released = true } + onCanceled: { root.mr1_canceled = true } + } + MouseArea { + id: mouseRegion2 + width: 120; height: 120 + onPressed: { root.mr2_pressed = true; mouse.accepted = false } + onReleased: { root.mr2_released = true } + onCanceled: { root.mr2_canceled = true } + } +} diff --git a/tests/auto/quick/qquickmousearea/data/updateMousePosOnClick.qml b/tests/auto/quick/qquickmousearea/data/updateMousePosOnClick.qml new file mode 100644 index 0000000000..7377a2e86c --- /dev/null +++ b/tests/auto/quick/qquickmousearea/data/updateMousePosOnClick.qml @@ -0,0 +1,20 @@ +import QtQuick 2.0 + +Rectangle { + color: "#ffffff" + width: 320; height: 240 + MouseArea { + id: mouseRegion + objectName: "mouseregion" + anchors.fill: parent + Rectangle { + id: ball + objectName: "ball" + width: 20; height: 20 + radius: 10 + color: "#0000ff" + x: { mouseRegion.mouseX } + y: mouseRegion.mouseY + } + } +} diff --git a/tests/auto/quick/qquickmousearea/data/updateMousePosOnResize.qml b/tests/auto/quick/qquickmousearea/data/updateMousePosOnResize.qml new file mode 100644 index 0000000000..55af864060 --- /dev/null +++ b/tests/auto/quick/qquickmousearea/data/updateMousePosOnResize.qml @@ -0,0 +1,43 @@ +import QtQuick 2.0 + +Rectangle { + color: "#ffffff" + width: 320; height: 240 + Rectangle { + id: brother + objectName: "brother" + color: "lightgreen" + x: 200; y: 100 + width: 120; height: 120 + } + MouseArea { + id: mouseRegion + objectName: "mouseregion" + + property int x1 + property int y1 + property int x2 + property int y2 + property bool emitPositionChanged: false + property bool mouseMatchesPos: true + + anchors.fill: brother + onPressed: { + if (mouse.x != mouseX || mouse.y != mouseY) + mouseMatchesPos = false + x1 = mouseX; y1 = mouseY + anchors.fill = parent + } + onPositionChanged: { emitPositionChanged = true } + onMouseXChanged: { + if (mouse.x != mouseX || mouse.y != mouseY) + mouseMatchesPos = false + x2 = mouseX; y2 = mouseY + } + onMouseYChanged: { + if (mouse.x != mouseX || mouse.y != mouseY) + mouseMatchesPos = false + x2 = mouseX; y2 = mouseY + } + } +} diff --git a/tests/auto/quick/qquickmousearea/qquickmousearea.pro b/tests/auto/quick/qquickmousearea/qquickmousearea.pro new file mode 100644 index 0000000000..c75db5ea55 --- /dev/null +++ b/tests/auto/quick/qquickmousearea/qquickmousearea.pro @@ -0,0 +1,17 @@ +CONFIG += testcase +TARGET = tst_qquickmousearea +macx:CONFIG -= app_bundle + +HEADERS += ../../shared/testhttpserver.h +SOURCES += tst_qquickmousearea.cpp \ + ../../shared/testhttpserver.cpp + +include (../../shared/util.pri) + +testDataFiles.files = data +testDataFiles.path = . +DEPLOYMENT += testDataFiles + +CONFIG += parallel_test + +QT += core-private gui-private qml-private quick-private network testlib diff --git a/tests/auto/quick/qquickmousearea/tst_qquickmousearea.cpp b/tests/auto/quick/qquickmousearea/tst_qquickmousearea.cpp new file mode 100644 index 0000000000..0fb82a66bc --- /dev/null +++ b/tests/auto/quick/qquickmousearea/tst_qquickmousearea.cpp @@ -0,0 +1,806 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "../../shared/util.h" + +//#define OLDWAY + +class tst_QQuickMouseArea: public QQmlDataTest +{ + Q_OBJECT +private slots: + void dragProperties(); + void resetDrag(); + void dragging(); + void updateMouseAreaPosOnClick(); + void updateMouseAreaPosOnResize(); + void noOnClickedWithPressAndHold(); + void onMousePressRejected(); + void pressedCanceledOnWindowDeactivate(); + void doubleClick(); + void clickTwice(); + void pressedOrdering(); + void preventStealing(); + void clickThrough(); + void hoverPosition(); + void hoverPropagation(); + void hoverVisible(); + +private: + QQuickView *createView(); +}; + +void tst_QQuickMouseArea::dragProperties() +{ + QQuickView *canvas = createView(); + + canvas->setSource(testFileUrl("dragproperties.qml")); + canvas->show(); + canvas->requestActivateWindow(); + QVERIFY(canvas->rootObject() != 0); + + QQuickMouseArea *mouseRegion = canvas->rootObject()->findChild("mouseregion"); + QQuickDrag *drag = mouseRegion->drag(); + QVERIFY(mouseRegion != 0); + QVERIFY(drag != 0); + + // target + QQuickItem *blackRect = canvas->rootObject()->findChild("blackrect"); + QVERIFY(blackRect != 0); + QVERIFY(blackRect == drag->target()); + QQuickItem *rootItem = qobject_cast(canvas->rootObject()); + QVERIFY(rootItem != 0); + QSignalSpy targetSpy(drag, SIGNAL(targetChanged())); + drag->setTarget(rootItem); + QCOMPARE(targetSpy.count(),1); + drag->setTarget(rootItem); + QCOMPARE(targetSpy.count(),1); + + // axis + QCOMPARE(drag->axis(), QQuickDrag::XandYAxis); + QSignalSpy axisSpy(drag, SIGNAL(axisChanged())); + drag->setAxis(QQuickDrag::XAxis); + QCOMPARE(drag->axis(), QQuickDrag::XAxis); + QCOMPARE(axisSpy.count(),1); + drag->setAxis(QQuickDrag::XAxis); + QCOMPARE(axisSpy.count(),1); + + // minimum and maximum properties + QSignalSpy xminSpy(drag, SIGNAL(minimumXChanged())); + QSignalSpy xmaxSpy(drag, SIGNAL(maximumXChanged())); + QSignalSpy yminSpy(drag, SIGNAL(minimumYChanged())); + QSignalSpy ymaxSpy(drag, SIGNAL(maximumYChanged())); + + QCOMPARE(drag->xmin(), 0.0); + QCOMPARE(drag->xmax(), rootItem->width()-blackRect->width()); + QCOMPARE(drag->ymin(), 0.0); + QCOMPARE(drag->ymax(), rootItem->height()-blackRect->height()); + + drag->setXmin(10); + drag->setXmax(10); + drag->setYmin(10); + drag->setYmax(10); + + QCOMPARE(drag->xmin(), 10.0); + QCOMPARE(drag->xmax(), 10.0); + QCOMPARE(drag->ymin(), 10.0); + QCOMPARE(drag->ymax(), 10.0); + + QCOMPARE(xminSpy.count(),1); + QCOMPARE(xmaxSpy.count(),1); + QCOMPARE(yminSpy.count(),1); + QCOMPARE(ymaxSpy.count(),1); + + drag->setXmin(10); + drag->setXmax(10); + drag->setYmin(10); + drag->setYmax(10); + + QCOMPARE(xminSpy.count(),1); + QCOMPARE(xmaxSpy.count(),1); + QCOMPARE(yminSpy.count(),1); + QCOMPARE(ymaxSpy.count(),1); + + // filterChildren + QSignalSpy filterChildrenSpy(drag, SIGNAL(filterChildrenChanged())); + + drag->setFilterChildren(true); + + QVERIFY(drag->filterChildren()); + QCOMPARE(filterChildrenSpy.count(), 1); + + drag->setFilterChildren(true); + QCOMPARE(filterChildrenSpy.count(), 1); + + delete canvas; +} + +void tst_QQuickMouseArea::resetDrag() +{ + QQuickView *canvas = createView(); + + canvas->rootContext()->setContextProperty("haveTarget", QVariant(true)); + canvas->setSource(testFileUrl("dragreset.qml")); + canvas->show(); + canvas->requestActivateWindow(); + QVERIFY(canvas->rootObject() != 0); + + QQuickMouseArea *mouseRegion = canvas->rootObject()->findChild("mouseregion"); + QQuickDrag *drag = mouseRegion->drag(); + QVERIFY(mouseRegion != 0); + QVERIFY(drag != 0); + + // target + QQuickItem *blackRect = canvas->rootObject()->findChild("blackrect"); + QVERIFY(blackRect != 0); + QVERIFY(blackRect == drag->target()); + QQuickItem *rootItem = qobject_cast(canvas->rootObject()); + QVERIFY(rootItem != 0); + QSignalSpy targetSpy(drag, SIGNAL(targetChanged())); + QVERIFY(drag->target() != 0); + canvas->rootContext()->setContextProperty("haveTarget", QVariant(false)); + QCOMPARE(targetSpy.count(),1); + QVERIFY(drag->target() == 0); + + delete canvas; +} + + +void tst_QQuickMouseArea::dragging() +{ + QQuickView *canvas = createView(); + + canvas->setSource(testFileUrl("dragging.qml")); + canvas->show(); + canvas->requestActivateWindow(); + QTest::qWait(20); + QVERIFY(canvas->rootObject() != 0); + + QQuickMouseArea *mouseRegion = canvas->rootObject()->findChild("mouseregion"); + QQuickDrag *drag = mouseRegion->drag(); + QVERIFY(mouseRegion != 0); + QVERIFY(drag != 0); + + // target + QQuickItem *blackRect = canvas->rootObject()->findChild("blackrect"); + QVERIFY(blackRect != 0); + QVERIFY(blackRect == drag->target()); + + QVERIFY(!drag->active()); + +#ifdef OLDWAY + QMouseEvent pressEvent(QEvent::MouseButtonPress, QPoint(100, 100), Qt::LeftButton, Qt::LeftButton, 0); + QGuiApplication::sendEvent(canvas, &pressEvent); +#else + QTest::mousePress(canvas, Qt::LeftButton, 0, QPoint(100,100)); +#endif + + QVERIFY(!drag->active()); + QCOMPARE(blackRect->x(), 50.0); + QCOMPARE(blackRect->y(), 50.0); + + // First move event triggers drag, second is acted upon. + // This is due to possibility of higher stacked area taking precedence. + + QTest::mouseMove(canvas, QPoint(111,111)); + QTest::qWait(50); + QTest::mouseMove(canvas, QPoint(122,122)); + QTest::qWait(50); + + QVERIFY(drag->active()); + QCOMPARE(blackRect->x(), 72.0); + QCOMPARE(blackRect->y(), 72.0); + +#ifdef OLDWAY + QMouseEvent releaseEvent(QEvent::MouseButtonRelease, QPoint(100, 100), Qt::LeftButton, Qt::LeftButton, 0); + QGuiApplication::sendEvent(canvas, &releaseEvent); +#else + QTest::mouseRelease(canvas, Qt::LeftButton, 0, QPoint(122,122)); + QTest::qWait(50); +#endif + + QVERIFY(!drag->active()); + QCOMPARE(blackRect->x(), 72.0); + QCOMPARE(blackRect->y(), 72.0); + + delete canvas; +} + +QQuickView *tst_QQuickMouseArea::createView() +{ + QQuickView *canvas = new QQuickView(0); + canvas->setBaseSize(QSize(240,320)); + + return canvas; +} + +void tst_QQuickMouseArea::updateMouseAreaPosOnClick() +{ + QQuickView *canvas = createView(); + canvas->setSource(testFileUrl("updateMousePosOnClick.qml")); + canvas->show(); + canvas->requestActivateWindow(); + QVERIFY(canvas->rootObject() != 0); + + QQuickMouseArea *mouseRegion = canvas->rootObject()->findChild("mouseregion"); + QVERIFY(mouseRegion != 0); + + QQuickRectangle *rect = canvas->rootObject()->findChild("ball"); + QVERIFY(rect != 0); + + QCOMPARE(mouseRegion->mouseX(), rect->x()); + QCOMPARE(mouseRegion->mouseY(), rect->y()); + + QMouseEvent event(QEvent::MouseButtonPress, QPoint(100, 100), Qt::LeftButton, Qt::LeftButton, 0); + QGuiApplication::sendEvent(canvas, &event); + + QCOMPARE(mouseRegion->mouseX(), 100.0); + QCOMPARE(mouseRegion->mouseY(), 100.0); + + QCOMPARE(mouseRegion->mouseX(), rect->x()); + QCOMPARE(mouseRegion->mouseY(), rect->y()); + + delete canvas; +} + +void tst_QQuickMouseArea::updateMouseAreaPosOnResize() +{ + QQuickView *canvas = createView(); + canvas->setSource(testFileUrl("updateMousePosOnResize.qml")); + canvas->show(); + canvas->requestActivateWindow(); + QVERIFY(canvas->rootObject() != 0); + + QQuickMouseArea *mouseRegion = canvas->rootObject()->findChild("mouseregion"); + QVERIFY(mouseRegion != 0); + + QQuickRectangle *rect = canvas->rootObject()->findChild("brother"); + QVERIFY(rect != 0); + + QCOMPARE(mouseRegion->mouseX(), 0.0); + QCOMPARE(mouseRegion->mouseY(), 0.0); + + QMouseEvent event(QEvent::MouseButtonPress, rect->pos().toPoint(), Qt::LeftButton, Qt::LeftButton, 0); + QGuiApplication::sendEvent(canvas, &event); + + QVERIFY(!mouseRegion->property("emitPositionChanged").toBool()); + QVERIFY(mouseRegion->property("mouseMatchesPos").toBool()); + + QCOMPARE(mouseRegion->property("x1").toReal(), 0.0); + QCOMPARE(mouseRegion->property("y1").toReal(), 0.0); + + QCOMPARE(mouseRegion->property("x2").toReal(), rect->x()); + QCOMPARE(mouseRegion->property("y2").toReal(), rect->y()); + + QCOMPARE(mouseRegion->mouseX(), rect->x()); + QCOMPARE(mouseRegion->mouseY(), rect->y()); + + delete canvas; +} + +void tst_QQuickMouseArea::noOnClickedWithPressAndHold() +{ + { + // We handle onPressAndHold, therefore no onClicked + QQuickView *canvas = createView(); + canvas->setSource(testFileUrl("clickandhold.qml")); + canvas->show(); + canvas->requestActivateWindow(); + QVERIFY(canvas->rootObject() != 0); + + QMouseEvent pressEvent(QEvent::MouseButtonPress, QPoint(100, 100), Qt::LeftButton, Qt::LeftButton, 0); + QGuiApplication::sendEvent(canvas, &pressEvent); + + QVERIFY(!canvas->rootObject()->property("clicked").toBool()); + QVERIFY(!canvas->rootObject()->property("held").toBool()); + + QTest::qWait(1000); + + QMouseEvent releaseEvent(QEvent::MouseButtonRelease, QPoint(100, 100), Qt::LeftButton, Qt::LeftButton, 0); + QGuiApplication::sendEvent(canvas, &releaseEvent); + + QVERIFY(!canvas->rootObject()->property("clicked").toBool()); + QVERIFY(canvas->rootObject()->property("held").toBool()); + + delete canvas; + } + + { + // We do not handle onPressAndHold, therefore we get onClicked + QQuickView *canvas = createView(); + canvas->setSource(testFileUrl("noclickandhold.qml")); + canvas->show(); + canvas->requestActivateWindow(); + QVERIFY(canvas->rootObject() != 0); + + QMouseEvent pressEvent(QEvent::MouseButtonPress, QPoint(100, 100), Qt::LeftButton, Qt::LeftButton, 0); + QGuiApplication::sendEvent(canvas, &pressEvent); + + QVERIFY(!canvas->rootObject()->property("clicked").toBool()); + + QTest::qWait(1000); + + QMouseEvent releaseEvent(QEvent::MouseButtonRelease, QPoint(100, 100), Qt::LeftButton, Qt::LeftButton, 0); + QGuiApplication::sendEvent(canvas, &releaseEvent); + + QVERIFY(canvas->rootObject()->property("clicked").toBool()); + + delete canvas; + } +} + +void tst_QQuickMouseArea::onMousePressRejected() +{ + QQuickView *canvas = createView(); + canvas->setSource(testFileUrl("rejectEvent.qml")); + canvas->show(); + canvas->requestActivateWindow(); + QVERIFY(canvas->rootObject() != 0); + QVERIFY(canvas->rootObject()->property("enabled").toBool()); + + QVERIFY(!canvas->rootObject()->property("mr1_pressed").toBool()); + QVERIFY(!canvas->rootObject()->property("mr1_released").toBool()); + QVERIFY(!canvas->rootObject()->property("mr1_canceled").toBool()); + QVERIFY(!canvas->rootObject()->property("mr2_pressed").toBool()); + QVERIFY(!canvas->rootObject()->property("mr2_released").toBool()); + QVERIFY(!canvas->rootObject()->property("mr2_canceled").toBool()); + + QMouseEvent pressEvent(QEvent::MouseButtonPress, QPoint(100, 100), Qt::LeftButton, Qt::LeftButton, 0); + QGuiApplication::sendEvent(canvas, &pressEvent); + + QVERIFY(canvas->rootObject()->property("mr1_pressed").toBool()); + QVERIFY(!canvas->rootObject()->property("mr1_released").toBool()); + QVERIFY(!canvas->rootObject()->property("mr1_canceled").toBool()); + QVERIFY(canvas->rootObject()->property("mr2_pressed").toBool()); + QVERIFY(!canvas->rootObject()->property("mr2_released").toBool()); + QVERIFY(canvas->rootObject()->property("mr2_canceled").toBool()); + + QTest::qWait(200); + + QMouseEvent releaseEvent(QEvent::MouseButtonRelease, QPoint(100, 100), Qt::LeftButton, Qt::LeftButton, 0); + QGuiApplication::sendEvent(canvas, &releaseEvent); + + QVERIFY(canvas->rootObject()->property("mr1_released").toBool()); + QVERIFY(!canvas->rootObject()->property("mr1_canceled").toBool()); + QVERIFY(!canvas->rootObject()->property("mr2_released").toBool()); + + delete canvas; +} +void tst_QQuickMouseArea::pressedCanceledOnWindowDeactivate() +{ + QQuickView *canvas = createView(); + canvas->setSource(testFileUrl("pressedCanceled.qml")); + canvas->show(); + canvas->requestActivateWindow(); + QVERIFY(canvas->rootObject() != 0); + QVERIFY(!canvas->rootObject()->property("pressed").toBool()); + QVERIFY(!canvas->rootObject()->property("canceled").toBool()); + QVERIFY(!canvas->rootObject()->property("released").toBool()); + + QMouseEvent pressEvent(QEvent::MouseButtonPress, QPoint(100, 100), Qt::LeftButton, Qt::LeftButton, 0); + QGuiApplication::sendEvent(canvas, &pressEvent); + + QVERIFY(canvas->rootObject()->property("pressed").toBool()); + QVERIFY(!canvas->rootObject()->property("canceled").toBool()); + QVERIFY(!canvas->rootObject()->property("released").toBool()); + + QTest::qWait(200); + + QEvent windowDeactivateEvent(QEvent::WindowDeactivate); + QGuiApplication::sendEvent(canvas, &windowDeactivateEvent); + QVERIFY(!canvas->rootObject()->property("pressed").toBool()); + QVERIFY(canvas->rootObject()->property("canceled").toBool()); + QVERIFY(!canvas->rootObject()->property("released").toBool()); + + QTest::qWait(200); + + //press again + QGuiApplication::sendEvent(canvas, &pressEvent); + QVERIFY(canvas->rootObject()->property("pressed").toBool()); + QVERIFY(!canvas->rootObject()->property("canceled").toBool()); + QVERIFY(!canvas->rootObject()->property("released").toBool()); + + QTest::qWait(200); + + //release + QMouseEvent releaseEvent(QEvent::MouseButtonRelease, QPoint(100, 100), Qt::LeftButton, Qt::LeftButton, 0); + QGuiApplication::sendEvent(canvas, &releaseEvent); + QVERIFY(!canvas->rootObject()->property("pressed").toBool()); + QVERIFY(!canvas->rootObject()->property("canceled").toBool()); + QVERIFY(canvas->rootObject()->property("released").toBool()); + + delete canvas; +} +void tst_QQuickMouseArea::doubleClick() +{ + QQuickView *canvas = createView(); + canvas->setSource(testFileUrl("doubleclick.qml")); + canvas->show(); + canvas->requestActivateWindow(); + QVERIFY(canvas->rootObject() != 0); + + QMouseEvent pressEvent(QEvent::MouseButtonPress, QPoint(100, 100), Qt::LeftButton, Qt::LeftButton, 0); + QGuiApplication::sendEvent(canvas, &pressEvent); + + QMouseEvent releaseEvent(QEvent::MouseButtonRelease, QPoint(100, 100), Qt::LeftButton, Qt::LeftButton, 0); + QGuiApplication::sendEvent(canvas, &releaseEvent); + + QCOMPARE(canvas->rootObject()->property("released").toInt(), 1); + + pressEvent = QMouseEvent(QEvent::MouseButtonDblClick, QPoint(100, 100), Qt::LeftButton, Qt::LeftButton, 0); + QGuiApplication::sendEvent(canvas, &pressEvent); + + QGuiApplication::sendEvent(canvas, &releaseEvent); + + QCOMPARE(canvas->rootObject()->property("clicked").toInt(), 1); + QCOMPARE(canvas->rootObject()->property("doubleClicked").toInt(), 1); + QCOMPARE(canvas->rootObject()->property("released").toInt(), 2); + + delete canvas; +} + +// QTBUG-14832 +void tst_QQuickMouseArea::clickTwice() +{ + QQuickView *canvas = createView(); + canvas->setSource(testFileUrl("clicktwice.qml")); + canvas->show(); + canvas->requestActivateWindow(); + QVERIFY(canvas->rootObject() != 0); + + QMouseEvent pressEvent(QEvent::MouseButtonPress, QPoint(100, 100), Qt::LeftButton, Qt::LeftButton, 0); + QGuiApplication::sendEvent(canvas, &pressEvent); + + QMouseEvent releaseEvent(QEvent::MouseButtonRelease, QPoint(100, 100), Qt::LeftButton, Qt::LeftButton, 0); + QGuiApplication::sendEvent(canvas, &releaseEvent); + + QCOMPARE(canvas->rootObject()->property("pressed").toInt(), 1); + QCOMPARE(canvas->rootObject()->property("released").toInt(), 1); + QCOMPARE(canvas->rootObject()->property("clicked").toInt(), 1); + + pressEvent = QMouseEvent(QEvent::MouseButtonDblClick, QPoint(100, 100), Qt::LeftButton, Qt::LeftButton, 0); + QGuiApplication::sendEvent(canvas, &pressEvent); + + QGuiApplication::sendEvent(canvas, &pressEvent); + QGuiApplication::sendEvent(canvas, &releaseEvent); + + QCOMPARE(canvas->rootObject()->property("pressed").toInt(), 2); + QCOMPARE(canvas->rootObject()->property("released").toInt(), 2); + QCOMPARE(canvas->rootObject()->property("clicked").toInt(), 2); + + delete canvas; +} + +void tst_QQuickMouseArea::pressedOrdering() +{ + QQuickView *canvas = createView(); + canvas->setSource(testFileUrl("pressedOrdering.qml")); + canvas->show(); + canvas->requestActivateWindow(); + QVERIFY(canvas->rootObject() != 0); + + QCOMPARE(canvas->rootObject()->property("value").toString(), QLatin1String("base")); + + QMouseEvent pressEvent(QEvent::MouseButtonPress, QPoint(100, 100), Qt::LeftButton, Qt::LeftButton, 0); + QGuiApplication::sendEvent(canvas, &pressEvent); + + QCOMPARE(canvas->rootObject()->property("value").toString(), QLatin1String("pressed")); + + QMouseEvent releaseEvent(QEvent::MouseButtonRelease, QPoint(100, 100), Qt::LeftButton, Qt::LeftButton, 0); + QGuiApplication::sendEvent(canvas, &releaseEvent); + + QCOMPARE(canvas->rootObject()->property("value").toString(), QLatin1String("toggled")); + + QGuiApplication::sendEvent(canvas, &pressEvent); + + QCOMPARE(canvas->rootObject()->property("value").toString(), QLatin1String("pressed")); + + delete canvas; +} + +void tst_QQuickMouseArea::preventStealing() +{ + QQuickView *canvas = createView(); + + canvas->setSource(testFileUrl("preventstealing.qml")); + canvas->show(); + canvas->requestActivateWindow(); + QVERIFY(canvas->rootObject() != 0); + + QQuickFlickable *flickable = qobject_cast(canvas->rootObject()); + QVERIFY(flickable != 0); + + QQuickMouseArea *mouseArea = canvas->rootObject()->findChild("mousearea"); + QVERIFY(mouseArea != 0); + + QSignalSpy mousePositionSpy(mouseArea, SIGNAL(positionChanged(QQuickMouseEvent*))); + + QTest::mousePress(canvas, Qt::LeftButton, 0, QPoint(80, 80)); + + // Without preventStealing, mouse movement over MouseArea would + // cause the Flickable to steal mouse and trigger content movement. + + QTest::mouseMove(canvas,QPoint(69,69)); + QTest::mouseMove(canvas,QPoint(58,58)); + QTest::mouseMove(canvas,QPoint(47,47)); + + // We should have received all three move events + QCOMPARE(mousePositionSpy.count(), 3); + QVERIFY(mouseArea->pressed()); + + // Flickable content should not have moved. + QCOMPARE(flickable->contentX(), 0.); + QCOMPARE(flickable->contentY(), 0.); + + QTest::mouseRelease(canvas, Qt::LeftButton, 0, QPoint(47, 47)); + + // Now allow stealing and confirm Flickable does its thing. + canvas->rootObject()->setProperty("stealing", false); + + QTest::mousePress(canvas, Qt::LeftButton, 0, QPoint(80, 80)); + + // Without preventStealing, mouse movement over MouseArea would + // cause the Flickable to steal mouse and trigger content movement. + + QTest::mouseMove(canvas,QPoint(69,69)); + QTest::mouseMove(canvas,QPoint(58,58)); + QTest::mouseMove(canvas,QPoint(47,47)); + + // We should only have received the first move event + QCOMPARE(mousePositionSpy.count(), 4); + // Our press should be taken away + QVERIFY(!mouseArea->pressed()); + + // Flickable content should have moved. + + QCOMPARE(flickable->contentX(), 11.); + QCOMPARE(flickable->contentY(), 11.); + + QTest::mouseRelease(canvas, Qt::LeftButton, 0, QPoint(50, 50)); + + delete canvas; +} + +void tst_QQuickMouseArea::clickThrough() +{ + QSKIP("QTBUG-23976 Unstable"); + //With no handlers defined click, doubleClick and PressAndHold should propagate to those with handlers + QQuickView *canvas = createView(); + canvas->setSource(testFileUrl("clickThrough.qml")); + canvas->show(); + canvas->requestActivateWindow(); + QVERIFY(canvas->rootObject() != 0); + + QTest::mousePress(canvas, Qt::LeftButton, 0, QPoint(100,100)); + QTest::mouseRelease(canvas, Qt::LeftButton, 0, QPoint(100,100)); + + QTRY_COMPARE(canvas->rootObject()->property("presses").toInt(), 0); + QTRY_COMPARE(canvas->rootObject()->property("clicks").toInt(), 1); + + QTest::qWait(800); // to avoid generating a double click. + + QTest::mousePress(canvas, Qt::LeftButton, 0, QPoint(100,100)); + QTest::qWait(1000); + QTest::mouseRelease(canvas, Qt::LeftButton, 0, QPoint(100,100)); + + QTRY_COMPARE(canvas->rootObject()->property("presses").toInt(), 0); + QTRY_COMPARE(canvas->rootObject()->property("clicks").toInt(), 1); + QTRY_COMPARE(canvas->rootObject()->property("pressAndHolds").toInt(), 1); + + QTest::mouseDClick(canvas, Qt::LeftButton, 0, QPoint(100,100)); + QTest::qWait(100); + + QCOMPARE(canvas->rootObject()->property("presses").toInt(), 0); + QTRY_COMPARE(canvas->rootObject()->property("clicks").toInt(), 2); + QTRY_COMPARE(canvas->rootObject()->property("doubleClicks").toInt(), 1); + QCOMPARE(canvas->rootObject()->property("pressAndHolds").toInt(), 1); + + delete canvas; + + //With handlers defined click, doubleClick and PressAndHold should propagate only when explicitly ignored + canvas = createView(); + canvas->setSource(testFileUrl("clickThrough2.qml")); + canvas->show(); + canvas->requestActivateWindow(); + QVERIFY(canvas->rootObject() != 0); + + QTest::mousePress(canvas, Qt::LeftButton, 0, QPoint(100,100)); + QTest::mouseRelease(canvas, Qt::LeftButton, 0, QPoint(100,100)); + + QCOMPARE(canvas->rootObject()->property("presses").toInt(), 0); + QCOMPARE(canvas->rootObject()->property("clicks").toInt(), 0); + + QTest::qWait(800); // to avoid generating a double click. + + QTest::mousePress(canvas, Qt::LeftButton, 0, QPoint(100,100)); + QTest::qWait(1000); + QTest::mouseRelease(canvas, Qt::LeftButton, 0, QPoint(100,100)); + QTest::qWait(100); + + QCOMPARE(canvas->rootObject()->property("presses").toInt(), 0); + QCOMPARE(canvas->rootObject()->property("clicks").toInt(), 0); + QCOMPARE(canvas->rootObject()->property("pressAndHolds").toInt(), 0); + + QTest::mouseDClick(canvas, Qt::LeftButton, 0, QPoint(100,100)); + QTest::qWait(100); + + QCOMPARE(canvas->rootObject()->property("presses").toInt(), 0); + QCOMPARE(canvas->rootObject()->property("clicks").toInt(), 0); + QCOMPARE(canvas->rootObject()->property("doubleClicks").toInt(), 0); + QCOMPARE(canvas->rootObject()->property("pressAndHolds").toInt(), 0); + + canvas->rootObject()->setProperty("letThrough", QVariant(true)); + + QTest::qWait(800); // to avoid generating a double click. + QTest::mousePress(canvas, Qt::LeftButton, 0, QPoint(100,100)); + QTest::mouseRelease(canvas, Qt::LeftButton, 0, QPoint(100,100)); + + QCOMPARE(canvas->rootObject()->property("presses").toInt(), 0); + QTRY_COMPARE(canvas->rootObject()->property("clicks").toInt(), 1); + + QTest::qWait(800); // to avoid generating a double click. + QTest::mousePress(canvas, Qt::LeftButton, 0, QPoint(100,100)); + QTest::qWait(1000); + QTest::mouseRelease(canvas, Qt::LeftButton, 0, QPoint(100,100)); + QTest::qWait(100); + + QCOMPARE(canvas->rootObject()->property("presses").toInt(), 0); + QCOMPARE(canvas->rootObject()->property("clicks").toInt(), 1); + QCOMPARE(canvas->rootObject()->property("pressAndHolds").toInt(), 1); + + QTest::mouseDClick(canvas, Qt::LeftButton, 0, QPoint(100,100)); + QTest::qWait(100); + + QCOMPARE(canvas->rootObject()->property("presses").toInt(), 0); + QTRY_COMPARE(canvas->rootObject()->property("clicks").toInt(), 2); + QCOMPARE(canvas->rootObject()->property("doubleClicks").toInt(), 1); + QCOMPARE(canvas->rootObject()->property("pressAndHolds").toInt(), 1); + + canvas->rootObject()->setProperty("noPropagation", QVariant(true)); + + QTest::qWait(800); // to avoid generating a double click. + QTest::mousePress(canvas, Qt::LeftButton, 0, QPoint(100,100)); + QTest::mouseRelease(canvas, Qt::LeftButton, 0, QPoint(100,100)); + + QTest::qWait(800); // to avoid generating a double click. + QTest::mousePress(canvas, Qt::LeftButton, 0, QPoint(100,100)); + QTest::qWait(1000); + QTest::mouseRelease(canvas, Qt::LeftButton, 0, QPoint(100,100)); + QTest::qWait(100); + + QTest::mouseDClick(canvas, Qt::LeftButton, 0, QPoint(100,100)); + QTest::qWait(100); + + QCOMPARE(canvas->rootObject()->property("presses").toInt(), 0); + QTRY_COMPARE(canvas->rootObject()->property("clicks").toInt(), 2); + QCOMPARE(canvas->rootObject()->property("doubleClicks").toInt(), 1); + QCOMPARE(canvas->rootObject()->property("pressAndHolds").toInt(), 1); + + delete canvas; +} + +void tst_QQuickMouseArea::hoverPosition() +{ + QQuickView *canvas = createView(); + canvas->setSource(testFileUrl("hoverPosition.qml")); + + QQuickItem *root = canvas->rootObject(); + QVERIFY(root != 0); + + QCOMPARE(root->property("mouseX").toReal(), qreal(0)); + QCOMPARE(root->property("mouseY").toReal(), qreal(0)); + + QTest::mouseMove(canvas,QPoint(10,32)); + + + QCOMPARE(root->property("mouseX").toReal(), qreal(10)); + QCOMPARE(root->property("mouseY").toReal(), qreal(32)); + + delete canvas; +} + +void tst_QQuickMouseArea::hoverPropagation() +{ + //QTBUG-18175, to behave like GV did. + QQuickView *canvas = createView(); + canvas->setSource(testFileUrl("hoverPropagation.qml")); + + QQuickItem *root = canvas->rootObject(); + QVERIFY(root != 0); + + QCOMPARE(root->property("point1").toBool(), false); + QCOMPARE(root->property("point2").toBool(), false); + + QMouseEvent moveEvent(QEvent::MouseMove, QPoint(32, 32), Qt::NoButton, Qt::NoButton, 0); + QGuiApplication::sendEvent(canvas, &moveEvent); + + QCOMPARE(root->property("point1").toBool(), true); + QCOMPARE(root->property("point2").toBool(), false); + + QMouseEvent moveEvent2(QEvent::MouseMove, QPoint(232, 32), Qt::NoButton, Qt::NoButton, 0); + QGuiApplication::sendEvent(canvas, &moveEvent2); + QCOMPARE(root->property("point1").toBool(), false); + QCOMPARE(root->property("point2").toBool(), true); + + delete canvas; +} + +void tst_QQuickMouseArea::hoverVisible() +{ + QQuickView *canvas = createView(); + canvas->setSource(testFileUrl("hoverVisible.qml")); + + QQuickItem *root = canvas->rootObject(); + QVERIFY(root != 0); + + QQuickMouseArea *mouseTracker = canvas->rootObject()->findChild("mousetracker"); + QVERIFY(mouseTracker != 0); + + QSignalSpy enteredSpy(mouseTracker, SIGNAL(entered())); + + QTest::mouseMove(canvas,QPoint(10,32)); + + QCOMPARE(mouseTracker->hovered(), false); + QCOMPARE(enteredSpy.count(), 0); + + mouseTracker->setVisible(true); + + QCOMPARE(mouseTracker->hovered(), true); + QCOMPARE(enteredSpy.count(), 1); + + QEXPECT_FAIL("", "QTBUG-24282", Continue); + QCOMPARE(QPointF(mouseTracker->mouseX(), mouseTracker->mouseY()), QPointF(10,32)); + + delete canvas; +} + +QTEST_MAIN(tst_QQuickMouseArea) + +#include "tst_qquickmousearea.moc" diff --git a/tests/auto/quick/qquickmultipointtoucharea/data/basic.qml b/tests/auto/quick/qquickmultipointtoucharea/data/basic.qml new file mode 100644 index 0000000000..cd6ce8146f --- /dev/null +++ b/tests/auto/quick/qquickmultipointtoucharea/data/basic.qml @@ -0,0 +1,15 @@ +import QtQuick 2.0 + +MultiPointTouchArea { + width: 240 + height: 320 + + minimumTouchPoints: 1 + maximumTouchPoints: 4 + touchPoints: [ + TouchPoint { objectName: "point1" }, + TouchPoint { objectName: "point2" }, + TouchPoint { objectName: "point3" }, + TouchPoint { objectName: "point4" } + ] +} diff --git a/tests/auto/quick/qquickmultipointtoucharea/data/inFlickable.qml b/tests/auto/quick/qquickmultipointtoucharea/data/inFlickable.qml new file mode 100644 index 0000000000..9c9132d0b0 --- /dev/null +++ b/tests/auto/quick/qquickmultipointtoucharea/data/inFlickable.qml @@ -0,0 +1,31 @@ +import QtQuick 2.0 + +Flickable { + width: 240 + height: 320 + + contentWidth: width + contentHeight: height * 2 + + property int cancelCount: 0 + property int touchCount: 0 + + MultiPointTouchArea { + anchors.fill: parent + minimumTouchPoints: 2 + maximumTouchPoints: 2 + onGestureStarted: { + if ((Math.abs(point2.x - point2.startX) > gesture.dragThreshold/2) && (Math.abs(point1.x - point1.startX) > gesture.dragThreshold/2)) { + gesture.grab() + } + } + touchPoints: [ + TouchPoint { id: point1; objectName: "point1" }, + TouchPoint { id: point2; objectName: "point2" } + ] + + onCanceled: cancelCount = touchPoints.length + onTouchUpdated: touchCount = touchPoints.length + } +} + diff --git a/tests/auto/quick/qquickmultipointtoucharea/data/nested.qml b/tests/auto/quick/qquickmultipointtoucharea/data/nested.qml new file mode 100644 index 0000000000..37b8820aa0 --- /dev/null +++ b/tests/auto/quick/qquickmultipointtoucharea/data/nested.qml @@ -0,0 +1,27 @@ +import QtQuick 2.0 + +MultiPointTouchArea { + width: 240 + height: 320 + + property bool grabInnerArea: true + + minimumTouchPoints: 2 + maximumTouchPoints: 3 + touchPoints: [ + TouchPoint { objectName: "point11" }, + TouchPoint { objectName: "point12" } + ] + + MultiPointTouchArea { + anchors.fill: parent + minimumTouchPoints: 3 + maximumTouchPoints: 3 + onGestureStarted: if (grabInnerArea) gesture.grab() + touchPoints: [ + TouchPoint { objectName: "point21" }, + TouchPoint { objectName: "point22" }, + TouchPoint { objectName: "point23" } + ] + } +} diff --git a/tests/auto/quick/qquickmultipointtoucharea/data/nonOverlapping.qml b/tests/auto/quick/qquickmultipointtoucharea/data/nonOverlapping.qml new file mode 100644 index 0000000000..039607e26c --- /dev/null +++ b/tests/auto/quick/qquickmultipointtoucharea/data/nonOverlapping.qml @@ -0,0 +1,32 @@ +import QtQuick 2.0 + +Rectangle { + width: 240 + height: 320 + + MultiPointTouchArea { + width: parent.width + height: 160 + minimumTouchPoints: 2 + maximumTouchPoints: 2 + onGestureStarted: gesture.grab() + touchPoints: [ + TouchPoint { objectName: "point11" }, + TouchPoint { objectName: "point12" } + ] + } + + MultiPointTouchArea { + width: parent.width + height: 160 + y: 160 + minimumTouchPoints: 3 + maximumTouchPoints: 3 + onGestureStarted: gesture.grab() + touchPoints: [ + TouchPoint { objectName: "point21" }, + TouchPoint { objectName: "point22" }, + TouchPoint { objectName: "point23" } + ] + } +} diff --git a/tests/auto/quick/qquickmultipointtoucharea/data/properties.qml b/tests/auto/quick/qquickmultipointtoucharea/data/properties.qml new file mode 100644 index 0000000000..98ef1a9cbe --- /dev/null +++ b/tests/auto/quick/qquickmultipointtoucharea/data/properties.qml @@ -0,0 +1,15 @@ +import QtQuick 2.0 + +MultiPointTouchArea { + width: 240 + height: 320 + + minimumTouchPoints: 2 + maximumTouchPoints: 4 + touchPoints: [ + TouchPoint {}, + TouchPoint {}, + TouchPoint {}, + TouchPoint {} + ] +} diff --git a/tests/auto/quick/qquickmultipointtoucharea/data/signalTest.qml b/tests/auto/quick/qquickmultipointtoucharea/data/signalTest.qml new file mode 100644 index 0000000000..54b160c182 --- /dev/null +++ b/tests/auto/quick/qquickmultipointtoucharea/data/signalTest.qml @@ -0,0 +1,30 @@ +import QtQuick 2.0 + +MultiPointTouchArea { + width: 240 + height: 320 + + function clearCounts() { + touchPointPressCount = 0; + touchPointUpdateCount = 0; + touchPointReleaseCount = 0; + touchCount = 0; + touchUpdatedHandled = false; + } + + property int touchPointPressCount: 0 + property int touchPointUpdateCount: 0 + property int touchPointReleaseCount: 0 + property int touchCount: 0 + property bool touchUpdatedHandled: false + + maximumTouchPoints: 5 + + onPressed: { touchPointPressCount = touchPoints.length } + onUpdated: { touchPointUpdateCount = touchPoints.length } + onReleased: { touchPointReleaseCount = touchPoints.length } + onTouchUpdated: { + touchCount = touchPoints.length + touchUpdatedHandled = true + } +} diff --git a/tests/auto/quick/qquickmultipointtoucharea/qquickmultipointtoucharea.pro b/tests/auto/quick/qquickmultipointtoucharea/qquickmultipointtoucharea.pro new file mode 100644 index 0000000000..3c6f304284 --- /dev/null +++ b/tests/auto/quick/qquickmultipointtoucharea/qquickmultipointtoucharea.pro @@ -0,0 +1,11 @@ +TARGET = tst_qquickmultipointtoucharea +CONFIG += testcase +macx:CONFIG -= app_bundle + +SOURCES += tst_qquickmultipointtoucharea.cpp + +importFiles.files = data +importFiles.path = . +DEPLOYMENT += importFiles + +QT += core-private gui-private qml-private quick-private testlib diff --git a/tests/auto/quick/qquickmultipointtoucharea/tst_qquickmultipointtoucharea.cpp b/tests/auto/quick/qquickmultipointtoucharea/tst_qquickmultipointtoucharea.cpp new file mode 100644 index 0000000000..507612f8ce --- /dev/null +++ b/tests/auto/quick/qquickmultipointtoucharea/tst_qquickmultipointtoucharea.cpp @@ -0,0 +1,727 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include +#include +#include +#include + +class tst_QQuickMultiPointTouchArea: public QObject +{ + Q_OBJECT +public: + tst_QQuickMultiPointTouchArea() : device(0) { } +private slots: + void initTestCase() { + if (!device) { + device = new QTouchDevice; + device->setType(QTouchDevice::TouchScreen); + QWindowSystemInterface::registerTouchDevice(device); + } + } + void cleanupTestCase() {} + + void properties(); + void signalTest(); + void release(); + void reuse(); + void nonOverlapping(); + void nested(); + void inFlickable(); + void invisible(); + +private: + QQuickView *createAndShowView(const QString &file); + QTouchDevice *device; +}; + +void tst_QQuickMultiPointTouchArea::properties() +{ + QQuickView *canvas = createAndShowView("properties.qml"); + QVERIFY(canvas->rootObject() != 0); + + QQuickMultiPointTouchArea *area = qobject_cast(canvas->rootObject()); + QVERIFY(area != 0); + + QCOMPARE(area->minimumTouchPoints(), 2); + QCOMPARE(area->maximumTouchPoints(), 4); + + QQmlListReference ref(area, "touchPoints"); + QCOMPARE(ref.count(), 4); + + delete canvas; +} + +void tst_QQuickMultiPointTouchArea::signalTest() +{ + QQuickView *canvas = createAndShowView("signalTest.qml"); + QVERIFY(canvas->rootObject() != 0); + + QQuickMultiPointTouchArea *area = qobject_cast(canvas->rootObject()); + QVERIFY(area != 0); + + QPoint p1(20,100); + QPoint p2(40,100); + QPoint p3(60,100); + QPoint p4(80,100); + QPoint p5(100,100); + + QTest::QTouchEventSequence sequence = QTest::touchEvent(canvas, device); + + sequence.press(0, p1).press(1, p2).commit(); + + QCOMPARE(area->property("touchPointPressCount").toInt(), 2); + QCOMPARE(area->property("touchPointUpdateCount").toInt(), 0); + QCOMPARE(area->property("touchPointReleaseCount").toInt(), 0); + QCOMPARE(area->property("touchCount").toInt(), 2); + QMetaObject::invokeMethod(area, "clearCounts"); + + sequence.stationary(0).stationary(1).press(2, p3).commit(); + + QCOMPARE(area->property("touchPointPressCount").toInt(), 1); + QCOMPARE(area->property("touchPointUpdateCount").toInt(), 0); + QCOMPARE(area->property("touchPointReleaseCount").toInt(), 0); + QCOMPARE(area->property("touchCount").toInt(), 3); + QMetaObject::invokeMethod(area, "clearCounts"); + + p1 -= QPoint(10,10); + p2 += QPoint(10,10); + sequence.move(0, p1).move(1, p2).stationary(2).commit(); + + QCOMPARE(area->property("touchPointPressCount").toInt(), 0); + QCOMPARE(area->property("touchPointUpdateCount").toInt(), 2); + QCOMPARE(area->property("touchPointReleaseCount").toInt(), 0); + QCOMPARE(area->property("touchCount").toInt(), 3); + QMetaObject::invokeMethod(area, "clearCounts"); + + p3 += QPoint(10,10); + sequence.release(0, p1).release(1, p2) + .move(2, p3).press(3, p4).press(4, p5).commit(); + + QCOMPARE(area->property("touchPointPressCount").toInt(), 2); + QCOMPARE(area->property("touchPointUpdateCount").toInt(), 1); + QCOMPARE(area->property("touchPointReleaseCount").toInt(), 2); + QCOMPARE(area->property("touchCount").toInt(), 3); + QMetaObject::invokeMethod(area, "clearCounts"); + + sequence.release(2, p3).release(3, p4).release(4, p5).commit(); + + QCOMPARE(area->property("touchPointPressCount").toInt(), 0); + QCOMPARE(area->property("touchPointUpdateCount").toInt(), 0); + QCOMPARE(area->property("touchPointReleaseCount").toInt(), 3); + QCOMPARE(area->property("touchCount").toInt(), 0); + QCOMPARE(area->property("touchUpdatedHandled").toBool(), true); + QMetaObject::invokeMethod(area, "clearCounts"); + + delete canvas; +} + +void tst_QQuickMultiPointTouchArea::release() +{ + QQuickView *canvas = createAndShowView("basic.qml"); + QVERIFY(canvas->rootObject() != 0); + + QQuickTouchPoint *point1 = canvas->rootObject()->findChild("point1"); + + QCOMPARE(point1->pressed(), false); + + QPoint p1(20,100); + + QTest::QTouchEventSequence sequence = QTest::touchEvent(canvas, device); + + sequence.press(0, p1).commit(); + + QCOMPARE(point1->pressed(), true); + + p1 += QPoint(0,10); + + sequence.move(0, p1).commit(); + + QCOMPARE(point1->pressed(), true); + QCOMPARE(point1->x(), qreal(20)); QCOMPARE(point1->y(), qreal(110)); + + p1 += QPoint(4,10); + + sequence.release(0, p1).commit(); + + //test that a release without a prior move to the release position successfully updates the point's position + QCOMPARE(point1->pressed(), false); + QCOMPARE(point1->x(), qreal(24)); QCOMPARE(point1->y(), qreal(120)); + + delete canvas; +} + +void tst_QQuickMultiPointTouchArea::reuse() +{ + QQuickView *canvas = createAndShowView("basic.qml"); + QVERIFY(canvas->rootObject() != 0); + + QQuickTouchPoint *point1 = canvas->rootObject()->findChild("point1"); + QQuickTouchPoint *point2 = canvas->rootObject()->findChild("point2"); + QQuickTouchPoint *point3 = canvas->rootObject()->findChild("point3"); + + QCOMPARE(point1->pressed(), false); + QCOMPARE(point2->pressed(), false); + + QPoint p1(20,100); + QPoint p2(40,100); + QPoint p3(60,100); + QPoint p4(80,100); + + QTest::QTouchEventSequence sequence = QTest::touchEvent(canvas, device); + + sequence.press(0, p1).press(1, p2).commit(); + + QCOMPARE(point1->pressed(), true); + QCOMPARE(point2->pressed(), true); + QCOMPARE(point3->pressed(), false); + + sequence.release(0, p1).stationary(1).press(2, p3).commit(); + + //we shouldn't reuse point 1 yet + QCOMPARE(point1->pressed(), false); + QCOMPARE(point2->pressed(), true); + QCOMPARE(point3->pressed(), true); + + //back to base state (no touches) + sequence.release(1, p2).release(2, p3).commit(); + + QCOMPARE(point1->pressed(), false); + QCOMPARE(point2->pressed(), false); + QCOMPARE(point3->pressed(), false); + + sequence.press(0, p1).press(1, p2).commit(); + + QCOMPARE(point1->pressed(), true); + QCOMPARE(point2->pressed(), true); + QCOMPARE(point3->pressed(), false); + + sequence.release(0, p1).stationary(1).commit(); + + QCOMPARE(point1->pressed(), false); + QCOMPARE(point2->pressed(), true); + QCOMPARE(point3->pressed(), false); + + sequence.press(4, p4).stationary(1).commit(); + + //the new touch point should reuse point 1 + QCOMPARE(point1->pressed(), true); + QCOMPARE(point2->pressed(), true); + QCOMPARE(point3->pressed(), false); + + QCOMPARE(point1->x(), qreal(80)); QCOMPARE(point1->y(), qreal(100)); + + delete canvas; +} + +void tst_QQuickMultiPointTouchArea::nonOverlapping() +{ + QQuickView *canvas = createAndShowView("nonOverlapping.qml"); + QVERIFY(canvas->rootObject() != 0); + + QQuickTouchPoint *point11 = canvas->rootObject()->findChild("point11"); + QQuickTouchPoint *point12 = canvas->rootObject()->findChild("point12"); + QQuickTouchPoint *point21 = canvas->rootObject()->findChild("point21"); + QQuickTouchPoint *point22 = canvas->rootObject()->findChild("point22"); + QQuickTouchPoint *point23 = canvas->rootObject()->findChild("point23"); + + QCOMPARE(point11->pressed(), false); + QCOMPARE(point12->pressed(), false); + QCOMPARE(point21->pressed(), false); + QCOMPARE(point22->pressed(), false); + QCOMPARE(point23->pressed(), false); + + QPoint p1(20,100); + QPoint p2(40,100); + QPoint p3(60,180); + QPoint p4(80,180); + QPoint p5(100,180); + + QTest::QTouchEventSequence sequence = QTest::touchEvent(canvas, device); + + sequence.press(0, p1).commit(); + + QCOMPARE(point11->pressed(), false); + QCOMPARE(point12->pressed(), false); + QCOMPARE(point21->pressed(), false); + QCOMPARE(point22->pressed(), false); + QCOMPARE(point23->pressed(), false); + + sequence.stationary(0).press(1, p2).commit(); + + QCOMPARE(point11->pressed(), true); + QCOMPARE(point12->pressed(), true); + QCOMPARE(point21->pressed(), false); + QCOMPARE(point22->pressed(), false); + QCOMPARE(point23->pressed(), false); + + QCOMPARE(point11->x(), qreal(20)); QCOMPARE(point11->y(), qreal(100)); + QCOMPARE(point12->x(), qreal(40)); QCOMPARE(point12->y(), qreal(100)); + + p1 += QPoint(0,10); + p2 += QPoint(5,0); + sequence.move(0, p1).move(1, p2).commit(); + + QCOMPARE(point11->pressed(), true); + QCOMPARE(point12->pressed(), true); + QCOMPARE(point21->pressed(), false); + QCOMPARE(point22->pressed(), false); + QCOMPARE(point23->pressed(), false); + + QCOMPARE(point11->x(), qreal(20)); QCOMPARE(point11->y(), qreal(110)); + QCOMPARE(point12->x(), qreal(45)); QCOMPARE(point12->y(), qreal(100)); + + sequence.stationary(0).stationary(1).press(2, p3).commit(); + + QCOMPARE(point11->pressed(), true); + QCOMPARE(point12->pressed(), true); + QCOMPARE(point21->pressed(), false); + QCOMPARE(point22->pressed(), false); + QCOMPARE(point23->pressed(), false); + + sequence.stationary(0).stationary(1).stationary(2).press(3, p4).press(4, p5).commit(); + + QCOMPARE(point11->pressed(), true); + QCOMPARE(point12->pressed(), true); + QCOMPARE(point21->pressed(), true); + QCOMPARE(point22->pressed(), true); + QCOMPARE(point23->pressed(), true); + + QCOMPARE(point11->x(), qreal(20)); QCOMPARE(point11->y(), qreal(110)); + QCOMPARE(point12->x(), qreal(45)); QCOMPARE(point12->y(), qreal(100)); + QCOMPARE(point21->x(), qreal(60)); QCOMPARE(point21->y(), qreal(20)); + QCOMPARE(point22->x(), qreal(80)); QCOMPARE(point22->y(), qreal(20)); + QCOMPARE(point23->x(), qreal(100)); QCOMPARE(point23->y(), qreal(20)); + + p1 += QPoint(4,10); + p2 += QPoint(17,17); + p3 += QPoint(3,0); + p4 += QPoint(1,-1); + p5 += QPoint(-7,10); + sequence.move(0, p1).move(1, p2).move(2, p3).move(3, p4).move(4, p5).commit(); + + QCOMPARE(point11->pressed(), true); + QCOMPARE(point12->pressed(), true); + QCOMPARE(point21->pressed(), true); + QCOMPARE(point22->pressed(), true); + QCOMPARE(point23->pressed(), true); + + QCOMPARE(point11->x(), qreal(24)); QCOMPARE(point11->y(), qreal(120)); + QCOMPARE(point12->x(), qreal(62)); QCOMPARE(point12->y(), qreal(117)); + QCOMPARE(point21->x(), qreal(63)); QCOMPARE(point21->y(), qreal(20)); + QCOMPARE(point22->x(), qreal(81)); QCOMPARE(point22->y(), qreal(19)); + QCOMPARE(point23->x(), qreal(93)); QCOMPARE(point23->y(), qreal(30)); + + sequence.release(0, p1).release(1, p2).release(2, p3).release(3, p4).release(4, p5).commit(); + + QCOMPARE(point11->pressed(), false); + QCOMPARE(point12->pressed(), false); + QCOMPARE(point21->pressed(), false); + QCOMPARE(point22->pressed(), false); + QCOMPARE(point23->pressed(), false); + + delete canvas; +} + +void tst_QQuickMultiPointTouchArea::nested() +{ + QQuickView *canvas = createAndShowView("nested.qml"); + QVERIFY(canvas->rootObject() != 0); + + QQuickTouchPoint *point11 = canvas->rootObject()->findChild("point11"); + QQuickTouchPoint *point12 = canvas->rootObject()->findChild("point12"); + QQuickTouchPoint *point21 = canvas->rootObject()->findChild("point21"); + QQuickTouchPoint *point22 = canvas->rootObject()->findChild("point22"); + QQuickTouchPoint *point23 = canvas->rootObject()->findChild("point23"); + + QCOMPARE(point11->pressed(), false); + QCOMPARE(point12->pressed(), false); + QCOMPARE(point21->pressed(), false); + QCOMPARE(point22->pressed(), false); + QCOMPARE(point23->pressed(), false); + + QPoint p1(20,100); + QPoint p2(40,100); + QPoint p3(60,180); + + QTest::QTouchEventSequence sequence = QTest::touchEvent(canvas, device); + + sequence.press(0, p1).commit(); + + QCOMPARE(point11->pressed(), false); + QCOMPARE(point12->pressed(), false); + QCOMPARE(point21->pressed(), false); + QCOMPARE(point22->pressed(), false); + QCOMPARE(point23->pressed(), false); + + sequence.stationary(0).press(1, p2).commit(); + + QCOMPARE(point11->pressed(), true); + QCOMPARE(point12->pressed(), true); + QCOMPARE(point21->pressed(), false); + QCOMPARE(point22->pressed(), false); + QCOMPARE(point23->pressed(), false); + + QCOMPARE(point11->x(), qreal(20)); QCOMPARE(point11->y(), qreal(100)); + QCOMPARE(point12->x(), qreal(40)); QCOMPARE(point12->y(), qreal(100)); + + p1 += QPoint(0,10); + p2 += QPoint(5,0); + sequence.move(0, p1).move(1, p2).commit(); + + QCOMPARE(point11->pressed(), true); + QCOMPARE(point12->pressed(), true); + QCOMPARE(point21->pressed(), false); + QCOMPARE(point22->pressed(), false); + QCOMPARE(point23->pressed(), false); + + QCOMPARE(point11->x(), qreal(20)); QCOMPARE(point11->y(), qreal(110)); + QCOMPARE(point12->x(), qreal(45)); QCOMPARE(point12->y(), qreal(100)); + + sequence.stationary(0).stationary(1).press(2, p3).commit(); + + QCOMPARE(point11->pressed(), true); + QCOMPARE(point12->pressed(), true); + QCOMPARE(point21->pressed(), true); + QCOMPARE(point22->pressed(), true); + QCOMPARE(point23->pressed(), true); + + //point11 should be same as point21, point12 same as point22 + QCOMPARE(point11->x(), qreal(20)); QCOMPARE(point11->y(), qreal(110)); + QCOMPARE(point12->x(), qreal(45)); QCOMPARE(point12->y(), qreal(100)); + QCOMPARE(point21->x(), qreal(20)); QCOMPARE(point21->y(), qreal(110)); + QCOMPARE(point22->x(), qreal(45)); QCOMPARE(point22->y(), qreal(100)); + QCOMPARE(point23->x(), qreal(60)); QCOMPARE(point23->y(), qreal(180)); + + sequence.stationary(0).stationary(1).stationary(2).press(3, QPoint(80,180)).press(4, QPoint(100,180)).commit(); + + QCOMPARE(point11->pressed(), true); + QCOMPARE(point12->pressed(), true); + QCOMPARE(point21->pressed(), true); + QCOMPARE(point22->pressed(), true); + QCOMPARE(point23->pressed(), true); + + //new touch points should be ignored (have no impact on our existing touch points) + QCOMPARE(point11->x(), qreal(20)); QCOMPARE(point11->y(), qreal(110)); + QCOMPARE(point12->x(), qreal(45)); QCOMPARE(point12->y(), qreal(100)); + QCOMPARE(point21->x(), qreal(20)); QCOMPARE(point21->y(), qreal(110)); + QCOMPARE(point22->x(), qreal(45)); QCOMPARE(point22->y(), qreal(100)); + QCOMPARE(point23->x(), qreal(60)); QCOMPARE(point23->y(), qreal(180)); + + sequence.stationary(0).stationary(1).stationary(2).release(3, QPoint(80,180)).release(4, QPoint(100,180)).commit(); + + p1 += QPoint(4,10); + p2 += QPoint(17,17); + p3 += QPoint(3,0); + sequence.move(0, p1).move(1, p2).move(2, p3).commit(); + + QCOMPARE(point11->pressed(), true); + QCOMPARE(point12->pressed(), true); + QCOMPARE(point21->pressed(), true); + QCOMPARE(point22->pressed(), true); + QCOMPARE(point23->pressed(), true); + + QCOMPARE(point21->x(), qreal(24)); QCOMPARE(point21->y(), qreal(120)); + QCOMPARE(point22->x(), qreal(62)); QCOMPARE(point22->y(), qreal(117)); + QCOMPARE(point21->x(), qreal(24)); QCOMPARE(point21->y(), qreal(120)); + QCOMPARE(point22->x(), qreal(62)); QCOMPARE(point22->y(), qreal(117)); + QCOMPARE(point23->x(), qreal(63)); QCOMPARE(point23->y(), qreal(180)); + + p1 += QPoint(4,10); + p2 += QPoint(17,17); + p3 += QPoint(3,0); + sequence.move(0, p1).move(1, p2).move(2, p3).commit(); + + QCOMPARE(point11->pressed(), false); + QCOMPARE(point12->pressed(), false); + QCOMPARE(point21->pressed(), true); + QCOMPARE(point22->pressed(), true); + QCOMPARE(point23->pressed(), true); + + //first two remain the same (touches now grabbed by inner touch area) + QCOMPARE(point11->x(), qreal(24)); QCOMPARE(point11->y(), qreal(120)); + QCOMPARE(point12->x(), qreal(62)); QCOMPARE(point12->y(), qreal(117)); + QCOMPARE(point21->x(), qreal(28)); QCOMPARE(point21->y(), qreal(130)); + QCOMPARE(point22->x(), qreal(79)); QCOMPARE(point22->y(), qreal(134)); + QCOMPARE(point23->x(), qreal(66)); QCOMPARE(point23->y(), qreal(180)); + + sequence.release(0, p1).release(1, p2).release(2, p3).commit(); + + sequence.press(0, p1).commit(); + + QCOMPARE(point11->pressed(), false); + QCOMPARE(point12->pressed(), false); + QCOMPARE(point21->pressed(), false); + QCOMPARE(point22->pressed(), false); + QCOMPARE(point23->pressed(), false); + + sequence.release(0, p1).commit(); + + //test with grabbing turned off + canvas->rootObject()->setProperty("grabInnerArea", false); + + sequence.press(0, p1).press(1, p2).press(2, p3).commit(); + + QCOMPARE(point11->pressed(), true); + QCOMPARE(point12->pressed(), true); + QCOMPARE(point21->pressed(), true); + QCOMPARE(point22->pressed(), true); + QCOMPARE(point23->pressed(), true); + + p1 -= QPoint(4,10); + p2 -= QPoint(17,17); + p3 -= QPoint(3,0); + sequence.move(0, p1).move(1, p2).move(2, p3).commit(); + + QCOMPARE(point11->pressed(), true); + QCOMPARE(point12->pressed(), true); + QCOMPARE(point21->pressed(), true); + QCOMPARE(point22->pressed(), true); + QCOMPARE(point23->pressed(), true); + + QCOMPARE(point21->x(), qreal(24)); QCOMPARE(point21->y(), qreal(120)); + QCOMPARE(point22->x(), qreal(62)); QCOMPARE(point22->y(), qreal(117)); + QCOMPARE(point21->x(), qreal(24)); QCOMPARE(point21->y(), qreal(120)); + QCOMPARE(point22->x(), qreal(62)); QCOMPARE(point22->y(), qreal(117)); + QCOMPARE(point23->x(), qreal(63)); QCOMPARE(point23->y(), qreal(180)); + + p1 -= QPoint(4,10); + p2 -= QPoint(17,17); + p3 -= QPoint(3,0); + sequence.move(0, p1).move(1, p2).move(2, p3).commit(); + + QCOMPARE(point11->pressed(), true); + QCOMPARE(point12->pressed(), true); + QCOMPARE(point21->pressed(), true); + QCOMPARE(point22->pressed(), true); + QCOMPARE(point23->pressed(), true); + + //all change (touches not grabbed by inner touch area) + QCOMPARE(point11->x(), qreal(20)); QCOMPARE(point11->y(), qreal(110)); + QCOMPARE(point12->x(), qreal(45)); QCOMPARE(point12->y(), qreal(100)); + QCOMPARE(point21->x(), qreal(20)); QCOMPARE(point21->y(), qreal(110)); + QCOMPARE(point22->x(), qreal(45)); QCOMPARE(point22->y(), qreal(100)); + QCOMPARE(point23->x(), qreal(60)); QCOMPARE(point23->y(), qreal(180)); + + sequence.release(0, p1).release(1, p2).release(2, p3).commit(); + + delete canvas; +} + +void tst_QQuickMultiPointTouchArea::inFlickable() +{ + QQuickView *canvas = createAndShowView("inFlickable.qml"); + QVERIFY(canvas->rootObject() != 0); + + QQuickFlickable *flickable = qobject_cast(canvas->rootObject()); + QVERIFY(flickable != 0); + + QQuickTouchPoint *point11 = canvas->rootObject()->findChild("point1"); + QQuickTouchPoint *point12 = canvas->rootObject()->findChild("point2"); + + QCOMPARE(point11->pressed(), false); + QCOMPARE(point12->pressed(), false); + + QPoint p1(20,100); + QPoint p2(40,100); + + //moving one point vertically + QTest::touchEvent(canvas, device).press(0, p1); + QTest::mousePress(canvas, Qt::LeftButton, 0, p1); + + p1 += QPoint(0,15); + QTest::touchEvent(canvas, device).move(0, p1); + QTest::mouseMove(canvas, p1); + + p1 += QPoint(0,15); + QTest::touchEvent(canvas, device).move(0, p1); + QTest::mouseMove(canvas, p1); + + p1 += QPoint(0,15); + QTest::touchEvent(canvas, device).move(0, p1); + QTest::mouseMove(canvas, p1); + + p1 += QPoint(0,15); + QTest::touchEvent(canvas, device).move(0, p1); + QTest::mouseMove(canvas, p1); + + QVERIFY(flickable->contentY() < 0); + QCOMPARE(point11->pressed(), false); + QCOMPARE(point12->pressed(), false); + + QTest::touchEvent(canvas, device).release(0, p1); + QTest::mouseRelease(canvas,Qt::LeftButton, 0, p1); + QTest::qWait(50); + + QTRY_VERIFY(!flickable->isMoving()); + + //moving two points vertically + p1 = QPoint(20,100); + QTest::touchEvent(canvas, device).press(0, p1).press(1, p2); + QTest::mousePress(canvas, Qt::LeftButton, 0, p1); + + QCOMPARE(point11->pressed(), true); + QCOMPARE(point12->pressed(), true); + QCOMPARE(flickable->property("cancelCount").toInt(), 0); + QCOMPARE(flickable->property("touchCount").toInt(), 2); + + p1 += QPoint(0,15); p2 += QPoint(0,15); + QTest::touchEvent(canvas, device).move(0, p1).move(1, p2); + QTest::mouseMove(canvas, p1); + + p1 += QPoint(0,15); p2 += QPoint(0,15); + QTest::touchEvent(canvas, device).move(0, p1).move(1, p2); + QTest::mouseMove(canvas, p1); + + p1 += QPoint(0,15); p2 += QPoint(0,15); + QTest::touchEvent(canvas, device).move(0, p1).move(1, p2); + QTest::mouseMove(canvas, p1); + + p1 += QPoint(0,15); p2 += QPoint(0,15); + QTest::touchEvent(canvas, device).move(0, p1).move(1, p2); + QTest::mouseMove(canvas, p1); + + QVERIFY(flickable->contentY() < 0); + QCOMPARE(point11->pressed(), false); + QCOMPARE(point12->pressed(), false); + QCOMPARE(flickable->property("cancelCount").toInt(), 2); + QCOMPARE(flickable->property("touchCount").toInt(), 0); + + QTest::touchEvent(canvas, device).release(0, p1).release(1, p2); + QTest::mouseRelease(canvas,Qt::LeftButton, 0, p1); + QTest::qWait(50); + + QTRY_VERIFY(!flickable->isMoving()); + + //moving two points horizontally, then one point vertically + p1 = QPoint(20,100); + p2 = QPoint(40,100); + QTest::touchEvent(canvas, device).press(0, p1).press(1, p2); + QTest::mousePress(canvas, Qt::LeftButton, 0, p1); + + QCOMPARE(point11->pressed(), true); + QCOMPARE(point12->pressed(), true); + + p1 += QPoint(15,0); p2 += QPoint(15,0); + QTest::touchEvent(canvas, device).move(0, p1).move(1, p2); + QTest::mouseMove(canvas, p1); + + p1 += QPoint(15,0); p2 += QPoint(15,0); + QTest::touchEvent(canvas, device).move(0, p1).move(1, p2); + QTest::mouseMove(canvas, p1); + + p1 += QPoint(15,0); p2 += QPoint(15,0); + QTest::touchEvent(canvas, device).move(0, p1).move(1, p2); + QTest::mouseMove(canvas, p1); + + p1 += QPoint(15,0); p2 += QPoint(15,0); + QTest::touchEvent(canvas, device).move(0, p1).move(1, p2); + QTest::mouseMove(canvas, p1); + + p1 += QPoint(0,15); p2 += QPoint(0,15); + QTest::touchEvent(canvas, device).move(0, p1).move(1, p2); + QTest::mouseMove(canvas, p1); + + p1 += QPoint(0,15); p2 += QPoint(0,15); + QTest::touchEvent(canvas, device).move(0, p1).move(1, p2); + QTest::mouseMove(canvas, p1); + + p1 += QPoint(0,15); p2 += QPoint(0,15); + QTest::touchEvent(canvas, device).move(0, p1).move(1, p2); + QTest::mouseMove(canvas, p1); + + p1 += QPoint(0,15); p2 += QPoint(0,15); + QTest::touchEvent(canvas, device).move(0, p1).move(1, p2); + QTest::mouseMove(canvas, p1); + + QVERIFY(flickable->contentY() == 0); + QCOMPARE(point11->pressed(), true); + QCOMPARE(point12->pressed(), true); + + QTest::touchEvent(canvas, device).release(0, p1).release(1, p2); + QTest::mouseRelease(canvas,Qt::LeftButton, 0, p1); + QTest::qWait(50); + + delete canvas; +} + +// QTBUG-23327 +void tst_QQuickMultiPointTouchArea::invisible() +{ + QQuickView *canvas = createAndShowView("signalTest.qml"); + QVERIFY(canvas->rootObject() != 0); + + QQuickMultiPointTouchArea *area = qobject_cast(canvas->rootObject()); + QVERIFY(area != 0); + + area->setVisible(false); + + QPoint p1(20,100); + QPoint p2(40,100); + + QTest::QTouchEventSequence sequence = QTest::touchEvent(canvas, device); + + sequence.press(0, p1).press(1, p2).commit(); + + QCOMPARE(area->property("touchPointPressCount").toInt(), 0); + QCOMPARE(area->property("touchPointUpdateCount").toInt(), 0); + QCOMPARE(area->property("touchPointReleaseCount").toInt(), 0); + QCOMPARE(area->property("touchCount").toInt(), 0); + + delete canvas; +} + + +QQuickView *tst_QQuickMultiPointTouchArea::createAndShowView(const QString &file) +{ + QQuickView *canvas = new QQuickView(0); + canvas->setSource(QUrl::fromLocalFile(QCoreApplication::applicationDirPath() + QLatin1String("/data/") + file)); + canvas->show(); + canvas->requestActivateWindow(); + QTest::qWaitForWindowShown(canvas); + + return canvas; +} + +QTEST_MAIN(tst_QQuickMultiPointTouchArea) + +#include "tst_qquickmultipointtoucharea.moc" diff --git a/tests/auto/quick/qquickpath/data/arc.qml b/tests/auto/quick/qquickpath/data/arc.qml new file mode 100644 index 0000000000..000221c784 --- /dev/null +++ b/tests/auto/quick/qquickpath/data/arc.qml @@ -0,0 +1,11 @@ +import QtQuick 2.0 + +Path { + startX: 0; startY: 0 + + PathArc { + x: 100; y: 100 + radiusX: 100; radiusY: 100 + direction: PathArc.Clockwise + } +} diff --git a/tests/auto/quick/qquickpath/data/closedcurve.qml b/tests/auto/quick/qquickpath/data/closedcurve.qml new file mode 100644 index 0000000000..bb4a715e28 --- /dev/null +++ b/tests/auto/quick/qquickpath/data/closedcurve.qml @@ -0,0 +1,9 @@ +import QtQuick 2.0 + +Path { + startX: 50; startY: 50 + + PathCurve { x: 100; y: 100 } + PathCurve { x: 50; y: 150 } + PathCurve { x: 50; y: 50 } +} diff --git a/tests/auto/quick/qquickpath/data/curve.qml b/tests/auto/quick/qquickpath/data/curve.qml new file mode 100644 index 0000000000..c571186496 --- /dev/null +++ b/tests/auto/quick/qquickpath/data/curve.qml @@ -0,0 +1,9 @@ +import QtQuick 2.0 + +Path { + startX: 0; startY: 0 + + PathCurve { x: 100; y: 50 } + PathCurve { x: 50; y: 100 } + PathCurve { x: 100; y: 150 } +} diff --git a/tests/auto/quick/qquickpath/data/svg.qml b/tests/auto/quick/qquickpath/data/svg.qml new file mode 100644 index 0000000000..cec0f75061 --- /dev/null +++ b/tests/auto/quick/qquickpath/data/svg.qml @@ -0,0 +1,5 @@ +import QtQuick 2.0 + +Path { + PathSvg { path: "M200,300 Q400,50 600,300 T1000,300" } +} diff --git a/tests/auto/quick/qquickpath/qquickpath.pro b/tests/auto/quick/qquickpath/qquickpath.pro new file mode 100644 index 0000000000..e1f0f7b278 --- /dev/null +++ b/tests/auto/quick/qquickpath/qquickpath.pro @@ -0,0 +1,15 @@ +CONFIG += testcase +TARGET = tst_qquickpath +macx:CONFIG -= app_bundle + +SOURCES += tst_qquickpath.cpp + +include (../../shared/util.pri) + +testDataFiles.files = data +testDataFiles.path = . +DEPLOYMENT += testDataFiles + +CONFIG += parallel_test + +QT += core-private gui-private v8-private qml-private quick-private testlib diff --git a/tests/auto/quick/qquickpath/tst_qquickpath.cpp b/tests/auto/quick/qquickpath/tst_qquickpath.cpp new file mode 100644 index 0000000000..73e7e6ea38 --- /dev/null +++ b/tests/auto/quick/qquickpath/tst_qquickpath.cpp @@ -0,0 +1,199 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include +#include +#include + +#include "../../shared/util.h" + +class tst_QuickPath : public QQmlDataTest +{ + Q_OBJECT +public: + tst_QuickPath() {} + +private slots: + void arc(); + void catmullromCurve(); + void closedCatmullromCurve(); + void svg(); +}; + +void tst_QuickPath::arc() +{ + QQmlEngine engine; + QQmlComponent c(&engine, testFileUrl("arc.qml")); + QQuickPath *obj = qobject_cast(c.create()); + QVERIFY(obj != 0); + + QCOMPARE(obj->startX(), 0.); + QCOMPARE(obj->startY(), 0.); + + QQmlListReference list(obj, "pathElements"); + QCOMPARE(list.count(), 1); + + QQuickPathArc* arc = qobject_cast(list.at(0)); + QVERIFY(arc != 0); + QCOMPARE(arc->x(), 100.); + QCOMPARE(arc->y(), 100.); + QCOMPARE(arc->radiusX(), 100.); + QCOMPARE(arc->radiusY(), 100.); + QCOMPARE(arc->useLargeArc(), false); + QCOMPARE(arc->direction(), QQuickPathArc::Clockwise); + + QPainterPath path = obj->path(); + QVERIFY(path != QPainterPath()); + + QPointF pos = obj->pointAt(0); + QCOMPARE(pos, QPointF(0,0)); + pos = obj->pointAt(.25); + QCOMPARE(pos.toPoint(), QPoint(39,8)); //fuzzy compare + pos = obj->pointAt(.75); + QCOMPARE(pos.toPoint(), QPoint(92,61)); //fuzzy compare + pos = obj->pointAt(1); + QCOMPARE(pos, QPointF(100,100)); +} + +void tst_QuickPath::catmullromCurve() +{ + QQmlEngine engine; + QQmlComponent c(&engine, testFileUrl("curve.qml")); + QQuickPath *obj = qobject_cast(c.create()); + QVERIFY(obj != 0); + + QCOMPARE(obj->startX(), 0.); + QCOMPARE(obj->startY(), 0.); + + QQmlListReference list(obj, "pathElements"); + QCOMPARE(list.count(), 3); + + QQuickPathCatmullRomCurve* curve = qobject_cast(list.at(0)); + QVERIFY(curve != 0); + QCOMPARE(curve->x(), 100.); + QCOMPARE(curve->y(), 50.); + + curve = qobject_cast(list.at(2)); + QVERIFY(curve != 0); + QCOMPARE(curve->x(), 100.); + QCOMPARE(curve->y(), 150.); + + QPainterPath path = obj->path(); + QVERIFY(path != QPainterPath()); + + QPointF pos = obj->pointAt(0); + QCOMPARE(pos, QPointF(0,0)); + pos = obj->pointAt(.25); + QCOMPARE(pos.toPoint(), QPoint(63,26)); //fuzzy compare + pos = obj->pointAt(.75); + QCOMPARE(pos.toPoint(), QPoint(51,105)); //fuzzy compare + pos = obj->pointAt(1); + QCOMPARE(pos, QPointF(100,150)); +} + +void tst_QuickPath::closedCatmullromCurve() +{ + QQmlEngine engine; + QQmlComponent c(&engine, testFileUrl("closedcurve.qml")); + QQuickPath *obj = qobject_cast(c.create()); + QVERIFY(obj != 0); + + QCOMPARE(obj->startX(), 50.); + QCOMPARE(obj->startY(), 50.); + + QQmlListReference list(obj, "pathElements"); + QCOMPARE(list.count(), 3); + + QQuickPathCatmullRomCurve* curve = qobject_cast(list.at(2)); + QVERIFY(curve != 0); + QCOMPARE(curve->x(), 50.); + QCOMPARE(curve->y(), 50.); + + QVERIFY(obj->isClosed()); + + QPainterPath path = obj->path(); + QVERIFY(path != QPainterPath()); + + QPointF pos = obj->pointAt(0); + QCOMPARE(pos, QPointF(50,50)); + pos = obj->pointAt(.1); + QCOMPARE(pos.toPoint(), QPoint(67,56)); //fuzzy compare + pos = obj->pointAt(.75); + QCOMPARE(pos.toPoint(), QPoint(44,116)); //fuzzy compare + pos = obj->pointAt(1); + QCOMPARE(pos, QPointF(50,50)); +} + +void tst_QuickPath::svg() +{ + QQmlEngine engine; + QQmlComponent c(&engine, testFileUrl("svg.qml")); + QQuickPath *obj = qobject_cast(c.create()); + QVERIFY(obj != 0); + + QCOMPARE(obj->startX(), 0.); + QCOMPARE(obj->startY(), 0.); + + QQmlListReference list(obj, "pathElements"); + QCOMPARE(list.count(), 1); + + QQuickPathSvg* svg = qobject_cast(list.at(0)); + QVERIFY(svg != 0); + QCOMPARE(svg->path(), QLatin1String("M200,300 Q400,50 600,300 T1000,300")); + + QPainterPath path = obj->path(); + QVERIFY(path != QPainterPath()); + + QPointF pos = obj->pointAt(0); + QCOMPARE(pos, QPointF(200,300)); + pos = obj->pointAt(.25); + QCOMPARE(pos.toPoint(), QPoint(400,175)); //fuzzy compare + pos = obj->pointAt(.75); + QCOMPARE(pos.toPoint(), QPoint(800,425)); //fuzzy compare + pos = obj->pointAt(1); + QCOMPARE(pos, QPointF(1000,300)); +} + + +QTEST_MAIN(tst_QuickPath) + +#include "tst_qquickpath.moc" diff --git a/tests/auto/quick/qquickpathview/data/ComponentView.qml b/tests/auto/quick/qquickpathview/data/ComponentView.qml new file mode 100644 index 0000000000..b61033d375 --- /dev/null +++ b/tests/auto/quick/qquickpathview/data/ComponentView.qml @@ -0,0 +1,17 @@ +import QtQuick 2.0 + +PathView { + id: view + + property string title + + width: 100; height: 100; + + model: 1 + delegate: Text { objectName: "listItem"; text: view.title } + + path: Path { + startX: 25; startY: 25; + PathLine { x: 75; y: 75 } + } +} diff --git a/tests/auto/quick/qquickpathview/data/asyncloader.qml b/tests/auto/quick/qquickpathview/data/asyncloader.qml new file mode 100644 index 0000000000..94f560f3e7 --- /dev/null +++ b/tests/auto/quick/qquickpathview/data/asyncloader.qml @@ -0,0 +1,71 @@ +import QtQuick 2.0 + +Rectangle { + id: root + property real delegateWidth: 60 + property real delegateHeight: 20 + property real delegateScale: 1.0 + width: 240 + height: 320 + color: "#ffffff" + + Loader { + asynchronous: true + sourceComponent: viewComponent + anchors.fill: parent + } + + Component { + id: adelegate + Rectangle { + objectName: "wrapper" + property bool onPath: PathView.onPath + height: root.delegateHeight + width: root.delegateWidth + scale: root.delegateScale + color: PathView.isCurrentItem ? "lightsteelblue" : "white" + border.color: "black" + Text { + text: index + } + } + } + Component { + id: viewComponent + PathView { + id: view + objectName: "view" + width: 240 + height: 320 + model: 5 + delegate: adelegate + highlight: Rectangle { + width: 60 + height: 20 + color: "yellow" + } + path: Path { + startY: 120 + startX: 160 + PathQuad { + y: 120 + x: 80 + controlY: 330 + controlX: 100 + } + PathLine { + y: 160 + x: 20 + } + PathCubic { + y: 120 + x: 160 + control1Y: 0 + control1X: 100 + control2Y: 0 + control2X: 200 + } + } + } + } +} diff --git a/tests/auto/quick/qquickpathview/data/closedPath.qml b/tests/auto/quick/qquickpathview/data/closedPath.qml new file mode 100644 index 0000000000..3ca34056c8 --- /dev/null +++ b/tests/auto/quick/qquickpathview/data/closedPath.qml @@ -0,0 +1,24 @@ +import QtQuick 2.0 + +Path { + startY: 120 + startX: 160 + PathQuad { + y: 120 + x: 80 + controlY: 330 + controlX: 100 + } + PathLine { + y: 160 + x: 20 + } + PathCubic { + y: 120 + x: 160 + control1Y: 0 + control1X: 100 + control2Y: 000 + control2X: 200 + } +} diff --git a/tests/auto/quick/qquickpathview/data/creationContext.qml b/tests/auto/quick/qquickpathview/data/creationContext.qml new file mode 100644 index 0000000000..79a682788b --- /dev/null +++ b/tests/auto/quick/qquickpathview/data/creationContext.qml @@ -0,0 +1,5 @@ +import QtQuick 2.0 + +ComponentView { + title: "Hello!" +} diff --git a/tests/auto/quick/qquickpathview/data/datamodel.qml b/tests/auto/quick/qquickpathview/data/datamodel.qml new file mode 100644 index 0000000000..44f2aecc0a --- /dev/null +++ b/tests/auto/quick/qquickpathview/data/datamodel.qml @@ -0,0 +1,38 @@ +import QtQuick 2.0 + +PathView { + id: pathview + property int viewCount: count + objectName: "pathview" + width: 240; height: 320 + pathItemCount: testObject.pathItemCount + + function checkProperties() { + testObject.error = false; + if (testObject.useModel && pathview.model != testData) { + console.log("model property incorrect"); + testObject.error = true; + } + } + + model: testObject.useModel ? testData : 0 + + delegate: Component { + id: myDelegate + Rectangle { + id: wrapper + objectName: "wrapper" + property bool onPath: PathView.onPath + width: 20; height: 20; color: name + Text { + objectName: "myText" + text: name + } + } + } + + path: Path { + startX: 120; startY: 20; + PathLine { x: 120; y: 300 } + } +} diff --git a/tests/auto/quick/qquickpathview/data/displaypath.qml b/tests/auto/quick/qquickpathview/data/displaypath.qml new file mode 100644 index 0000000000..af0f381fc4 --- /dev/null +++ b/tests/auto/quick/qquickpathview/data/displaypath.qml @@ -0,0 +1,59 @@ +import QtQuick 2.0 + +Rectangle { + width: 240 + height: 320 + color: "#ffffff" + resources: [ + Component { + id: delegate + Rectangle { + id: wrapper + objectName: "wrapper" + height: 20 + width: 60 + color: "white" + border.color: "black" + Text { + text: index + } + Text { + x: 20 + id: displayText + objectName: "displayText" + text: display + } + } + } + ] + PathView { + id: view + objectName: "view" + width: 240 + height: 320 + model: testModel + delegate: delegate + path: Path { + startY: 120 + startX: 160 + PathQuad { + y: 120 + x: 80 + controlY: 330 + controlX: 100 + } + PathLine { + y: 160 + x: 20 + } + PathCubic { + y: 120 + x: 160 + control1Y: 0 + control1X: 100 + control2Y: 000 + control2X: 200 + } + } + } +} diff --git a/tests/auto/quick/qquickpathview/data/dragpath.qml b/tests/auto/quick/qquickpathview/data/dragpath.qml new file mode 100644 index 0000000000..f9c6615b04 --- /dev/null +++ b/tests/auto/quick/qquickpathview/data/dragpath.qml @@ -0,0 +1,19 @@ +import QtQuick 2.0 + +PathView { + width: 400 + height: 200 + model: 100 + pathItemCount: 20 + path: Path { + startX: 0; startY: 100 + PathLine { x: 400; y: 100 } + } + delegate: Rectangle { objectName: "wrapper"; height: 100; width: 2; color: PathView.isCurrentItem?"red" : "black" } + dragMargin: 100 + preferredHighlightBegin: 0.5 + preferredHighlightEnd: 0.5 + Text { + text: "current index: " + parent.currentIndex + } +} diff --git a/tests/auto/quick/qquickpathview/data/emptymodel.qml b/tests/auto/quick/qquickpathview/data/emptymodel.qml new file mode 100644 index 0000000000..eb4d3006f4 --- /dev/null +++ b/tests/auto/quick/qquickpathview/data/emptymodel.qml @@ -0,0 +1,5 @@ +import QtQuick 2.0 + +PathView { + model: emptyModel +} diff --git a/tests/auto/quick/qquickpathview/data/missingPercent.qml b/tests/auto/quick/qquickpathview/data/missingPercent.qml new file mode 100644 index 0000000000..97af8e8982 --- /dev/null +++ b/tests/auto/quick/qquickpathview/data/missingPercent.qml @@ -0,0 +1,9 @@ +import QtQuick 2.0 + +Path { + startY: 0 + startX: 0 + PathLine { x: 0; y: 50 } + PathPercent { value: .5 } + PathLine { x: 50; y: 50 } +} diff --git a/tests/auto/quick/qquickpathview/data/openPath.qml b/tests/auto/quick/qquickpathview/data/openPath.qml new file mode 100644 index 0000000000..1bd8375d9e --- /dev/null +++ b/tests/auto/quick/qquickpathview/data/openPath.qml @@ -0,0 +1,10 @@ +import QtQuick 2.0 + +Path { + startY: 120 + startX: 160 + PathLine { + y: 160 + x: 20 + } +} diff --git a/tests/auto/quick/qquickpathview/data/pathUpdate.qml b/tests/auto/quick/qquickpathview/data/pathUpdate.qml new file mode 100644 index 0000000000..e729291025 --- /dev/null +++ b/tests/auto/quick/qquickpathview/data/pathUpdate.qml @@ -0,0 +1,18 @@ +import QtQuick 2.0 + +Rectangle { + width: 400 + height: 400 + + PathView { + id: view + objectName: "pathView" + anchors.fill: parent + model: 10 + delegate: Rectangle { objectName: "wrapper"; color: "green"; width: 100; height: 100 } + path: Path { + startX: view.width/2; startY: 0 + PathLine { x: view.width/2; y: view.height } + } + } +} diff --git a/tests/auto/quick/qquickpathview/data/pathUpdateOnStartChanged.qml b/tests/auto/quick/qquickpathview/data/pathUpdateOnStartChanged.qml new file mode 100644 index 0000000000..89084b2a37 --- /dev/null +++ b/tests/auto/quick/qquickpathview/data/pathUpdateOnStartChanged.qml @@ -0,0 +1,38 @@ +import QtQuick 2.0 + +Rectangle { + width: 800 + height: 480 + color: "black" + resources: [ + ListModel { + id: appModel + ListElement { color: "green" } + }, + Component { + id: appDelegate + Rectangle { + id: wrapper + objectName: "wrapper" + color: "green" + width: 100 + height: 100 + } + } + ] + PathView { + id: pathView + objectName: "pathView" + model: appModel + anchors.fill: parent + + transformOrigin: "Top" + delegate: appDelegate + path: Path { + objectName: "path" + startX: pathView.width / 2 // startX: 400 <- this works as expected + startY: 300 + PathLine { x: 400; y: 120 } + } + } +} diff --git a/tests/auto/quick/qquickpathview/data/pathline.qml b/tests/auto/quick/qquickpathview/data/pathline.qml new file mode 100644 index 0000000000..4c1c785bce --- /dev/null +++ b/tests/auto/quick/qquickpathview/data/pathline.qml @@ -0,0 +1,48 @@ +import QtQuick 2.0 + +Rectangle { + id: app + width: 360 + height: 360 + + PathView { + id: pathView + objectName: "view" + x: (app.width-pathView.width)/2 + y: 100 + width: 240 + height: 100 + + model: testModel + + Rectangle { + anchors.fill: parent + color: "white" + border.color: "black" + } + preferredHighlightBegin: 0.5 + preferredHighlightEnd: 0.5 + + delegate: Rectangle { + objectName: "wrapper" + width: 100 + height: 100 + color: PathView.isCurrentItem ? "red" : "yellow" + Text { + text: index + anchors.centerIn: parent + } + z: (PathView.isCurrentItem?1:0) + } + path: Path { + id: path + startX: -100+pathView.width/2 + startY: pathView.height/2 + PathLine { + id: line + x: 100+pathView.width/2 + y: pathView.height/2 + } + } + } +} diff --git a/tests/auto/quick/qquickpathview/data/pathtest.qml b/tests/auto/quick/qquickpathview/data/pathtest.qml new file mode 100644 index 0000000000..736d58d2a9 --- /dev/null +++ b/tests/auto/quick/qquickpathview/data/pathtest.qml @@ -0,0 +1,14 @@ +import QtQuick 2.0 + +Path { + startX: 120; startY: 100 + + PathAttribute { name: "scale"; value: 1.0 } + PathQuad { x: 120; y: 25; controlX: 260; controlY: 75 } + PathPercent { value: 0.3 } + PathLine { x: 120; y: 100 } + PathCubic { + x: 180; y: 0; control1X: -10; control1Y: 90 + control2X: 210; control2Y: 90 + } +} diff --git a/tests/auto/quick/qquickpathview/data/pathview0.qml b/tests/auto/quick/qquickpathview/data/pathview0.qml new file mode 100644 index 0000000000..8b9378163f --- /dev/null +++ b/tests/auto/quick/qquickpathview/data/pathview0.qml @@ -0,0 +1,85 @@ +import QtQuick 2.0 + +Rectangle { + id: root + property int count: view.count + property int currentA: -1 + property int currentB: -1 + property real delegateWidth: 60 + property real delegateHeight: 20 + property real delegateScale: 1.0 + width: 240 + height: 320 + color: "#ffffff" + resources: [ + Component { + id: delegate + Rectangle { + id: wrapper + objectName: "wrapper" + property bool onPath: PathView.onPath + height: root.delegateHeight + width: root.delegateWidth + scale: root.delegateScale + color: PathView.isCurrentItem ? "lightsteelblue" : "white" + border.color: "black" + Text { + text: index + } + Text { + x: 20 + id: textName + objectName: "textName" + text: name + } + Text { + x: 40 + id: textNumber + objectName: "textNumber" + text: number + } + PathView.onCurrentItemChanged: { + if (PathView.isCurrentItem) { + root.currentA = index; + root.currentB = wrapper.PathView.view.currentIndex; + } + } + } + } + ] + PathView { + id: view + objectName: "view" + width: 240 + height: 320 + model: testModel + delegate: delegate + highlight: Rectangle { + width: 60 + height: 20 + color: "yellow" + } + path: Path { + startY: 120 + startX: 160 + PathQuad { + y: 120 + x: 80 + controlY: 330 + controlX: 100 + } + PathLine { + y: 160 + x: 20 + } + PathCubic { + y: 120 + x: 160 + control1Y: 0 + control1X: 100 + control2Y: 000 + control2X: 200 + } + } + } +} diff --git a/tests/auto/quick/qquickpathview/data/pathview1.qml b/tests/auto/quick/qquickpathview/data/pathview1.qml new file mode 100644 index 0000000000..53d375e596 --- /dev/null +++ b/tests/auto/quick/qquickpathview/data/pathview1.qml @@ -0,0 +1,4 @@ +import QtQuick 2.0 + +PathView { +} diff --git a/tests/auto/quick/qquickpathview/data/pathview2.qml b/tests/auto/quick/qquickpathview/data/pathview2.qml new file mode 100644 index 0000000000..1d279c42a0 --- /dev/null +++ b/tests/auto/quick/qquickpathview/data/pathview2.qml @@ -0,0 +1,57 @@ +import QtQuick 2.0 + +PathView { + id: photoPathView + y: 100; width: 800; height: 330; pathItemCount: 10; z: 1 + + path: Path { + startX: -50; startY: 40; + + PathAttribute { name: "scale"; value: 0.5 } + PathAttribute { name: "angle"; value: -45 } + + PathCubic { + x: 400; y: 220 + control1X: 140; control1Y: 40 + control2X: 210; control2Y: 220 + } + + PathAttribute { name: "scale"; value: 1.2 } + PathAttribute { name: "angle"; value: 0 } + + PathCubic { + x: 850; y: 40 + control2X: 660; control2Y: 40 + control1X: 590; control1Y: 220 + } + + PathAttribute { name: "scale"; value: 0.5 } + PathAttribute { name: "angle"; value: 45 } + } + + model: ListModel { + id: rssModel + ListElement { lColor: "red" } + ListElement { lColor: "green" } + ListElement { lColor: "yellow" } + ListElement { lColor: "blue" } + ListElement { lColor: "purple" } + ListElement { lColor: "gray" } + ListElement { lColor: "brown" } + ListElement { lColor: "thistle" } + } + + delegate: Component { + id: photoDelegate + Rectangle { + id: wrapper + width: 85; height: 85; color: lColor + scale: wrapper.PathView.scale + + transform: Rotation { + id: itemRotation; origin.x: wrapper.width/2; origin.y: wrapper.height/2 + axis.y: 1; axis.z: 0; angle: wrapper.PathView.angle + } + } + } +} diff --git a/tests/auto/quick/qquickpathview/data/pathview3.qml b/tests/auto/quick/qquickpathview/data/pathview3.qml new file mode 100644 index 0000000000..ded5a3911c --- /dev/null +++ b/tests/auto/quick/qquickpathview/data/pathview3.qml @@ -0,0 +1,59 @@ +import QtQuick 2.0 + +PathView { + id: photoPathView + y: 100; width: 800; height: 330; pathItemCount: 4; offset: 1 + dragMargin: 24 + preferredHighlightBegin: 0.50 + preferredHighlightEnd: 0.50 + + path: Path { + startX: -50; startY: 40; + + PathAttribute { name: "scale"; value: 0.5 } + PathAttribute { name: "angle"; value: -45 } + + PathCubic { + x: 400; y: 220 + control1X: 140; control1Y: 40 + control2X: 210; control2Y: 220 + } + + PathAttribute { name: "scale"; value: 1.2 } + PathAttribute { name: "angle"; value: 0 } + + PathCubic { + x: 850; y: 40 + control2X: 660; control2Y: 40 + control1X: 590; control1Y: 220 + } + + PathAttribute { name: "scale"; value: 0.5 } + PathAttribute { name: "angle"; value: 45 } + } + + model: ListModel { + id: rssModel + ListElement { lColor: "red" } + ListElement { lColor: "green" } + ListElement { lColor: "yellow" } + ListElement { lColor: "blue" } + ListElement { lColor: "purple" } + ListElement { lColor: "gray" } + ListElement { lColor: "brown" } + ListElement { lColor: "thistle" } + } + + delegate: Component { + id: photoDelegate + Rectangle { + id: wrapper + width: 85; height: 85; color: lColor + + transform: Rotation { + id: itemRotation; origin.x: wrapper.width/2; origin.y: wrapper.height/2 + axis.y: 1; axis.z: 0 + } + } + } +} diff --git a/tests/auto/quick/qquickpathview/data/pathview_package.qml b/tests/auto/quick/qquickpathview/data/pathview_package.qml new file mode 100644 index 0000000000..2af57e6bb1 --- /dev/null +++ b/tests/auto/quick/qquickpathview/data/pathview_package.qml @@ -0,0 +1,88 @@ +import QtQuick 2.0 + +Item { + width: 800; height: 600 + Component { + id: photoDelegate + Package { + Item { id: pathItem; objectName: "pathItem"; Package.name: 'path'; width: 85; height: 85; scale: pathItem.PathView.scale } + Item { id: linearItem; Package.name: 'linear'; width: 85; height: 85 } + Rectangle { + id: wrapper + width: 85; height: 85; color: lColor + + transform: Rotation { + id: itemRotation; origin.x: wrapper.width/2; origin.y: wrapper.height/2 + axis.y: 1; axis.z: 0 + } + state: 'path' + states: [ + State { + name: 'path' + ParentChange { target: wrapper; parent: pathItem; x: 0; y: 0 } + PropertyChanges { target: wrapper; opacity: pathItem.PathView.onPath ? 1.0 : 0 } + } + ] + } + } + } + ListModel { + id: rssModel + ListElement { lColor: "red" } + ListElement { lColor: "green" } + ListElement { lColor: "yellow" } + ListElement { lColor: "blue" } + ListElement { lColor: "purple" } + ListElement { lColor: "gray" } + ListElement { lColor: "brown" } + ListElement { lColor: "thistle" } + } + VisualDataModel { id: visualModel; model: rssModel; delegate: photoDelegate } + + PathView { + id: photoPathView + objectName: "photoPathView" + width: 800; height: 330; pathItemCount: 4; offset: 1 + dragMargin: 24 + preferredHighlightBegin: 0.50 + preferredHighlightEnd: 0.50 + + path: Path { + startX: -50; startY: 40; + + PathAttribute { name: "scale"; value: 0.5 } + PathAttribute { name: "angle"; value: -45 } + + PathCubic { + x: 400; y: 220 + control1X: 140; control1Y: 40 + control2X: 210; control2Y: 220 + } + + PathAttribute { name: "scale"; value: 1.2 } + PathAttribute { name: "angle"; value: 0 } + + PathCubic { + x: 850; y: 40 + control2X: 660; control2Y: 40 + control1X: 590; control1Y: 220 + } + + PathAttribute { name: "scale"; value: 0.5 } + PathAttribute { name: "angle"; value: 45 } + } + + model: visualModel.parts.path + } + + PathView { + y: 400; width: 800; height: 330; pathItemCount: 8 + + path: Path { + startX: 0; startY: 40; + PathLine { x: 800; y: 40 } + } + + model: visualModel.parts.linear + } +} diff --git a/tests/auto/quick/qquickpathview/data/propertychanges.qml b/tests/auto/quick/qquickpathview/data/propertychanges.qml new file mode 100644 index 0000000000..09b309f86f --- /dev/null +++ b/tests/auto/quick/qquickpathview/data/propertychanges.qml @@ -0,0 +1,116 @@ +import QtQuick 2.0 + +Rectangle { + width: 350; height: 220; color: "white" + Component { + id: myDelegate + Item { + id: wrapper + width: 180; height: 40; + opacity: PathView.opacity + Column { + x: 5; y: 5 + Text { text: 'Name: ' + name } + Text { text: 'Number: ' + number } + } + } + } + + PathView { + preferredHighlightBegin: 0.1 + preferredHighlightEnd: 0.1 + dragMargin: 5.0 + id: pathView + objectName: "pathView" + anchors.fill: parent + model: listModel + delegate: myDelegate + focus: true + path: Path { + id: myPath + objectName: "path" + startX: 220; startY: 200 + PathAttribute { name: "opacity"; value: 1.0; objectName: "pathAttribute"; } + PathQuad { x: 220; y: 25; controlX: 260; controlY: 75 } + PathAttribute { name: "opacity"; value: 0.3 } + PathQuad { x: 220; y: 200; controlX: -20; controlY: 75 } + } + Timer { + interval: 2000; running: true; repeat: true + onTriggered: { + if (pathView.path == alternatePath) + pathView.path = myPath; + else + pathView.path = alternatePath; + } + } + } + + data:[ + ListModel { + id: listModel + ListElement { + name: "Bill Smith" + number: "555 3264" + } + ListElement { + name: "John Brown" + number: "555 8426" + } + ListElement { + name: "Sam Wise" + number: "555 0473" + } + ListElement { + name: "Bill Smith" + number: "555 3264" + } + ListElement { + name: "John Brown" + number: "555 8426" + } + ListElement { + name: "Sam Wise" + number: "555 0473" + } + ListElement { + name: "Bill Smith" + number: "555 3264" + } + ListElement { + name: "John Brown" + number: "555 8426" + } + ListElement { + name: "Sam Wise" + number: "555 0473" + } + }, + ListModel { + objectName: "alternateModel" + ListElement { + name: "Jack" + number: "555 8426" + } + ListElement { + name: "Mary" + number: "555 3264" + } + }, + Path { + id: alternatePath + objectName: "alternatePath" + startX: 100; startY: 40 + PathAttribute { name: "opacity"; value: 0.0 } + PathLine { x: 100; y: 160 } + PathAttribute { name: "opacity"; value: 0.2 } + PathLine { x: 300; y: 160 } + PathAttribute { name: "opacity"; value: 0.0 } + PathLine { x: 300; y: 40 } + PathAttribute { name: "opacity"; value: 0.2 } + PathLine { x: 100; y: 40 } + } + ] +} + + diff --git a/tests/auto/quick/qquickpathview/data/treemodel.qml b/tests/auto/quick/qquickpathview/data/treemodel.qml new file mode 100644 index 0000000000..fcf6922d00 --- /dev/null +++ b/tests/auto/quick/qquickpathview/data/treemodel.qml @@ -0,0 +1,19 @@ +import QtQuick 2.0 + +PathView { + width: 320 + height: 240 + function setRoot(index) { + vdm.rootIndex = vdm.modelIndex(index); + } + model: VisualDataModel { + id: vdm + model: myModel + delegate: Text { objectName: "wrapper"; text: display } + } + + path: Path { + startX: 0; startY: 120 + PathLine { x: 320; y: 120 } + } +} diff --git a/tests/auto/quick/qquickpathview/data/undefinedpath.qml b/tests/auto/quick/qquickpathview/data/undefinedpath.qml new file mode 100644 index 0000000000..674e7cca8d --- /dev/null +++ b/tests/auto/quick/qquickpathview/data/undefinedpath.qml @@ -0,0 +1,17 @@ +import QtQuick 2.0 + +PathView { + id: pathView + width: 240; height: 200 + path: Path { + startX: pathView.undef/2.0; startY: 0 + PathLine { x: pathView.undef/2.0; y: 0 } + } + + delegate: Text { text: value } + model: ListModel { + ListElement { value: "one" } + ListElement { value: "two" } + ListElement { value: "three" } + } +} diff --git a/tests/auto/quick/qquickpathview/data/vdm.qml b/tests/auto/quick/qquickpathview/data/vdm.qml new file mode 100644 index 0000000000..839393d9bd --- /dev/null +++ b/tests/auto/quick/qquickpathview/data/vdm.qml @@ -0,0 +1,28 @@ +import QtQuick 2.0 + +PathView { + id: pathView + width: 240; height: 320 + + pathItemCount: 4 + preferredHighlightBegin : 0.5 + preferredHighlightEnd : 0.5 + + path: Path { + startX: 120; startY: 20; + PathLine { x: 120; y: 300 } + } + + ListModel { + id: mo + ListElement { value: "one" } + ListElement { value: "two" } + ListElement { value: "three" } + } + + model: VisualDataModel { + delegate: Text { text: model.value } + model : mo + } +} + diff --git a/tests/auto/quick/qquickpathview/qquickpathview.pro b/tests/auto/quick/qquickpathview/qquickpathview.pro new file mode 100644 index 0000000000..52f00ce3f8 --- /dev/null +++ b/tests/auto/quick/qquickpathview/qquickpathview.pro @@ -0,0 +1,15 @@ +CONFIG += testcase +TARGET = tst_qquickpathview +macx:CONFIG -= app_bundle + +SOURCES += tst_qquickpathview.cpp + +include (../../shared/util.pri) +include (../shared/util.pri) + +testDataFiles.files = data +testDataFiles.path = . +DEPLOYMENT += testDataFiles + +CONFIG += parallel_test +QT += core-private gui-private v8-private qml-private quick-private widgets testlib diff --git a/tests/auto/quick/qquickpathview/tst_qquickpathview.cpp b/tests/auto/quick/qquickpathview/tst_qquickpathview.cpp new file mode 100644 index 0000000000..8866cafd80 --- /dev/null +++ b/tests/auto/quick/qquickpathview/tst_qquickpathview.cpp @@ -0,0 +1,1458 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "../../shared/util.h" +#include "../shared/viewtestutil.h" +#include "../shared/visualtestutil.h" + +using namespace QQuickViewTestUtil; +using namespace QQuickVisualTestUtil; + + +static void initStandardTreeModel(QStandardItemModel *model) +{ + QStandardItem *item; + item = new QStandardItem(QLatin1String("Row 1 Item")); + model->insertRow(0, item); + + item = new QStandardItem(QLatin1String("Row 2 Item")); + item->setCheckable(true); + model->insertRow(1, item); + + QStandardItem *childItem = new QStandardItem(QLatin1String("Row 2 Child Item")); + item->setChild(0, childItem); + + item = new QStandardItem(QLatin1String("Row 3 Item")); + item->setIcon(QIcon()); + model->insertRow(2, item); +} + + +class tst_QQuickPathView : public QQmlDataTest +{ + Q_OBJECT +public: + tst_QQuickPathView(); + +private slots: + void initValues(); + void items(); + void dataModel(); + void pathview2(); + void pathview3(); + void insertModel_data(); + void insertModel(); + void removeModel_data(); + void removeModel(); + void moveModel_data(); + void moveModel(); + void path(); + void pathMoved(); + void setCurrentIndex(); + void resetModel(); + void propertyChanges(); + void pathChanges(); + void componentChanges(); + void modelChanges(); + void pathUpdateOnStartChanged(); + void package(); + void emptyModel(); + void closed(); + void pathUpdate(); + void visualDataModel(); + void undefinedPath(); + void mouseDrag(); + void treeModel(); + void changePreferredHighlight(); + void missingPercent(); + void creationContext(); + void currentOffsetOnInsertion(); + void asynchronous(); +}; + +class TestObject : public QObject +{ + Q_OBJECT + + Q_PROPERTY(bool error READ error WRITE setError) + Q_PROPERTY(bool useModel READ useModel NOTIFY useModelChanged) + Q_PROPERTY(int pathItemCount READ pathItemCount NOTIFY pathItemCountChanged) + +public: + TestObject() : QObject(), mError(true), mUseModel(true), mPathItemCount(-1) {} + + bool error() const { return mError; } + void setError(bool err) { mError = err; } + + bool useModel() const { return mUseModel; } + void setUseModel(bool use) { mUseModel = use; emit useModelChanged(); } + + int pathItemCount() const { return mPathItemCount; } + void setPathItemCount(int count) { mPathItemCount = count; emit pathItemCountChanged(); } + +signals: + void useModelChanged(); + void pathItemCountChanged(); + +private: + bool mError; + bool mUseModel; + int mPathItemCount; +}; + +tst_QQuickPathView::tst_QQuickPathView() +{ +} + +void tst_QQuickPathView::initValues() +{ + QQmlEngine engine; + QQmlComponent c(&engine, testFileUrl("pathview1.qml")); + QQuickPathView *obj = qobject_cast(c.create()); + + QVERIFY(obj != 0); + QVERIFY(obj->path() == 0); + QVERIFY(obj->delegate() == 0); + QCOMPARE(obj->model(), QVariant()); + QCOMPARE(obj->currentIndex(), 0); + QCOMPARE(obj->offset(), 0.); + QCOMPARE(obj->preferredHighlightBegin(), 0.); + QCOMPARE(obj->dragMargin(), 0.); + QCOMPARE(obj->count(), 0); + QCOMPARE(obj->pathItemCount(), -1); + + delete obj; +} + +void tst_QQuickPathView::items() +{ + QQuickView *canvas = createView(); + + QaimModel model; + model.addItem("Fred", "12345"); + model.addItem("John", "2345"); + model.addItem("Bob", "54321"); + model.addItem("Bill", "4321"); + + QQmlContext *ctxt = canvas->rootContext(); + ctxt->setContextProperty("testModel", &model); + + canvas->setSource(testFileUrl("pathview0.qml")); + qApp->processEvents(); + + QQuickPathView *pathview = findItem(canvas->rootObject(), "view"); + QVERIFY(pathview != 0); + + QCOMPARE(pathview->count(), model.count()); + QCOMPARE(canvas->rootObject()->property("count").toInt(), model.count()); + QCOMPARE(pathview->childItems().count(), model.count()+1); // assumes all are visible, including highlight + + for (int i = 0; i < model.count(); ++i) { + QQuickText *name = findItem(pathview, "textName", i); + QVERIFY(name != 0); + QCOMPARE(name->text(), model.name(i)); + QQuickText *number = findItem(pathview, "textNumber", i); + QVERIFY(number != 0); + QCOMPARE(number->text(), model.number(i)); + } + + QQuickPath *path = qobject_cast(pathview->path()); + QVERIFY(path); + + QVERIFY(pathview->highlightItem()); + QPointF start = path->pointAt(0.0); + QPointF offset; + offset.setX(pathview->highlightItem()->width()/2); + offset.setY(pathview->highlightItem()->height()/2); + QCOMPARE(pathview->highlightItem()->pos() + offset, start); + + delete canvas; +} + +void tst_QQuickPathView::pathview2() +{ + QQmlEngine engine; + QQmlComponent c(&engine, testFileUrl("pathview2.qml")); + QQuickPathView *obj = qobject_cast(c.create()); + + QVERIFY(obj != 0); + QVERIFY(obj->path() != 0); + QVERIFY(obj->delegate() != 0); + QVERIFY(obj->model() != QVariant()); + QCOMPARE(obj->currentIndex(), 0); + QCOMPARE(obj->offset(), 0.); + QCOMPARE(obj->preferredHighlightBegin(), 0.); + QCOMPARE(obj->dragMargin(), 0.); + QCOMPARE(obj->count(), 8); + QCOMPARE(obj->pathItemCount(), 10); + + delete obj; +} + +void tst_QQuickPathView::pathview3() +{ + QQmlEngine engine; + QQmlComponent c(&engine, testFileUrl("pathview3.qml")); + QQuickPathView *obj = qobject_cast(c.create()); + + QVERIFY(obj != 0); + QVERIFY(obj->path() != 0); + QVERIFY(obj->delegate() != 0); + QVERIFY(obj->model() != QVariant()); + QCOMPARE(obj->currentIndex(), 0); + QCOMPARE(obj->offset(), 1.0); + QCOMPARE(obj->preferredHighlightBegin(), 0.5); + QCOMPARE(obj->dragMargin(), 24.); + QCOMPARE(obj->count(), 8); + QCOMPARE(obj->pathItemCount(), 4); + + delete obj; +} + +void tst_QQuickPathView::insertModel_data() +{ + QTest::addColumn("mode"); + QTest::addColumn("idx"); + QTest::addColumn("count"); + QTest::addColumn("offset"); + + // We have 8 items, with currentIndex == 4 + QTest::newRow("insert after current") + << int(QQuickPathView::StrictlyEnforceRange) << 6 << 1 << 5.; + QTest::newRow("insert before current") + << int(QQuickPathView::StrictlyEnforceRange) << 2 << 1 << 4.; + QTest::newRow("insert multiple after current") + << int(QQuickPathView::StrictlyEnforceRange) << 5 << 2 << 6.; + QTest::newRow("insert multiple before current") + << int(QQuickPathView::StrictlyEnforceRange) << 1 << 2 << 4.; + QTest::newRow("insert at end") + << int(QQuickPathView::StrictlyEnforceRange) << 8 << 1 << 5.; + QTest::newRow("insert at beginning") + << int(QQuickPathView::StrictlyEnforceRange) << 0 << 1 << 4.; + QTest::newRow("insert at current") + << int(QQuickPathView::StrictlyEnforceRange) << 4 << 1 << 4.; + + QTest::newRow("no range - insert after current") + << int(QQuickPathView::NoHighlightRange) << 6 << 1 << 5.; + QTest::newRow("no range - insert before current") + << int(QQuickPathView::NoHighlightRange) << 2 << 1 << 4.; + QTest::newRow("no range - insert multiple after current") + << int(QQuickPathView::NoHighlightRange) << 5 << 2 << 6.; + QTest::newRow("no range - insert multiple before current") + << int(QQuickPathView::NoHighlightRange) << 1 << 2 << 4.; + QTest::newRow("no range - insert at end") + << int(QQuickPathView::NoHighlightRange) << 8 << 1 << 5.; + QTest::newRow("no range - insert at beginning") + << int(QQuickPathView::NoHighlightRange) << 0 << 1 << 4.; + QTest::newRow("no range - insert at current") + << int(QQuickPathView::NoHighlightRange) << 4 << 1 << 4.; +} + +void tst_QQuickPathView::insertModel() +{ + QFETCH(int, mode); + QFETCH(int, idx); + QFETCH(int, count); + QFETCH(qreal, offset); + + QQuickView *canvas = createView(); + canvas->show(); + + QaimModel model; + model.addItem("Ben", "12345"); + model.addItem("Bohn", "2345"); + model.addItem("Bob", "54321"); + model.addItem("Bill", "4321"); + model.addItem("Jinny", "679"); + model.addItem("Milly", "73378"); + model.addItem("Jimmy", "3535"); + model.addItem("Barb", "9039"); + + QQmlContext *ctxt = canvas->rootContext(); + ctxt->setContextProperty("testModel", &model); + + canvas->setSource(testFileUrl("pathview0.qml")); + qApp->processEvents(); + + QQuickPathView *pathview = findItem(canvas->rootObject(), "view"); + QVERIFY(pathview != 0); + + pathview->setHighlightRangeMode((QQuickPathView::HighlightRangeMode)mode); + + pathview->setCurrentIndex(4); + if (mode == QQuickPathView::StrictlyEnforceRange) + QTRY_COMPARE(pathview->offset(), 4.0); + else + pathview->setOffset(4); + + QList > items; + for (int i = 0; i < count; ++i) + items.append(qMakePair(QString("New"), QString::number(i))); + + model.insertItems(idx, items); + QTRY_COMPARE(pathview->offset(), offset); + + delete canvas; +} + +void tst_QQuickPathView::removeModel_data() +{ + QTest::addColumn("mode"); + QTest::addColumn("idx"); + QTest::addColumn("count"); + QTest::addColumn("offset"); + + // We have 8 items, with currentIndex == 4 + QTest::newRow("remove after current") + << int(QQuickPathView::StrictlyEnforceRange) << 6 << 1 << 3.; + QTest::newRow("remove before current") + << int(QQuickPathView::StrictlyEnforceRange) << 2 << 1 << 4.; + QTest::newRow("remove multiple after current") + << int(QQuickPathView::StrictlyEnforceRange) << 5 << 2 << 2.; + QTest::newRow("remove multiple before current") + << int(QQuickPathView::StrictlyEnforceRange) << 1 << 2 << 4.; + QTest::newRow("remove last") + << int(QQuickPathView::StrictlyEnforceRange) << 7 << 1 << 3.; + QTest::newRow("remove first") + << int(QQuickPathView::StrictlyEnforceRange) << 0 << 1 << 4.; + QTest::newRow("remove current") + << int(QQuickPathView::StrictlyEnforceRange) << 4 << 1 << 3.; + + QTest::newRow("no range - remove after current") + << int(QQuickPathView::NoHighlightRange) << 6 << 1 << 3.; + QTest::newRow("no range - remove before current") + << int(QQuickPathView::NoHighlightRange) << 2 << 1 << 4.; + QTest::newRow("no range - remove multiple after current") + << int(QQuickPathView::NoHighlightRange) << 5 << 2 << 2.; + QTest::newRow("no range - remove multiple before current") + << int(QQuickPathView::NoHighlightRange) << 1 << 2 << 4.; + QTest::newRow("no range - remove last") + << int(QQuickPathView::NoHighlightRange) << 7 << 1 << 3.; + QTest::newRow("no range - remove first") + << int(QQuickPathView::NoHighlightRange) << 0 << 1 << 4.; + QTest::newRow("no range - remove current offset") + << int(QQuickPathView::NoHighlightRange) << 4 << 1 << 4.; +} + +void tst_QQuickPathView::removeModel() +{ + QFETCH(int, mode); + QFETCH(int, idx); + QFETCH(int, count); + QFETCH(qreal, offset); + + QQuickView *canvas = createView(); + canvas->show(); + + QaimModel model; + model.addItem("Ben", "12345"); + model.addItem("Bohn", "2345"); + model.addItem("Bob", "54321"); + model.addItem("Bill", "4321"); + model.addItem("Jinny", "679"); + model.addItem("Milly", "73378"); + model.addItem("Jimmy", "3535"); + model.addItem("Barb", "9039"); + + QQmlContext *ctxt = canvas->rootContext(); + ctxt->setContextProperty("testModel", &model); + + canvas->setSource(testFileUrl("pathview0.qml")); + qApp->processEvents(); + + QQuickPathView *pathview = findItem(canvas->rootObject(), "view"); + QVERIFY(pathview != 0); + + pathview->setHighlightRangeMode((QQuickPathView::HighlightRangeMode)mode); + + pathview->setCurrentIndex(4); + if (mode == QQuickPathView::StrictlyEnforceRange) + QTRY_COMPARE(pathview->offset(), 4.0); + else + pathview->setOffset(4); + + model.removeItems(idx, count); + QTRY_COMPARE(pathview->offset(), offset); + + delete canvas; +} + + +void tst_QQuickPathView::moveModel_data() +{ + QTest::addColumn("mode"); + QTest::addColumn("from"); + QTest::addColumn("to"); + QTest::addColumn("count"); + QTest::addColumn("offset"); + + // We have 8 items, with currentIndex == 4 + QTest::newRow("move after current") + << int(QQuickPathView::StrictlyEnforceRange) << 5 << 6 << 1 << 4.; + QTest::newRow("move before current") + << int(QQuickPathView::StrictlyEnforceRange) << 2 << 3 << 1 << 4.; + QTest::newRow("move before current to after") + << int(QQuickPathView::StrictlyEnforceRange) << 2 << 6 << 1 << 5.; + QTest::newRow("move multiple after current") + << int(QQuickPathView::StrictlyEnforceRange) << 5 << 6 << 2 << 4.; + QTest::newRow("move multiple before current") + << int(QQuickPathView::StrictlyEnforceRange) << 0 << 1 << 2 << 4.; + QTest::newRow("move before current to end") + << int(QQuickPathView::StrictlyEnforceRange) << 2 << 7 << 1 << 5.; + QTest::newRow("move last to beginning") + << int(QQuickPathView::StrictlyEnforceRange) << 7 << 0 << 1 << 3.; + QTest::newRow("move current") + << int(QQuickPathView::StrictlyEnforceRange) << 4 << 6 << 1 << 2.; + + QTest::newRow("no range - move after current") + << int(QQuickPathView::NoHighlightRange) << 5 << 6 << 1 << 4.; + QTest::newRow("no range - move before current") + << int(QQuickPathView::NoHighlightRange) << 2 << 3 << 1 << 4.; + QTest::newRow("no range - move before current to after") + << int(QQuickPathView::NoHighlightRange) << 2 << 6 << 1 << 5.; + QTest::newRow("no range - move multiple after current") + << int(QQuickPathView::NoHighlightRange) << 5 << 6 << 2 << 4.; + QTest::newRow("no range - move multiple before current") + << int(QQuickPathView::NoHighlightRange) << 0 << 1 << 2 << 4.; + QTest::newRow("no range - move before current to end") + << int(QQuickPathView::NoHighlightRange) << 2 << 7 << 1 << 5.; + QTest::newRow("no range - move last to beginning") + << int(QQuickPathView::NoHighlightRange) << 7 << 0 << 1 << 3.; + QTest::newRow("no range - move current") + << int(QQuickPathView::NoHighlightRange) << 4 << 6 << 1 << 4.; + QTest::newRow("no range - move multiple incl. current") + << int(QQuickPathView::NoHighlightRange) << 0 << 1 << 5 << 4.; +} + +void tst_QQuickPathView::moveModel() +{ + QFETCH(int, mode); + QFETCH(int, from); + QFETCH(int, to); + QFETCH(int, count); + QFETCH(qreal, offset); + + QQuickView *canvas = createView(); + canvas->show(); + + QaimModel model; + model.addItem("Ben", "12345"); + model.addItem("Bohn", "2345"); + model.addItem("Bob", "54321"); + model.addItem("Bill", "4321"); + model.addItem("Jinny", "679"); + model.addItem("Milly", "73378"); + model.addItem("Jimmy", "3535"); + model.addItem("Barb", "9039"); + + QQmlContext *ctxt = canvas->rootContext(); + ctxt->setContextProperty("testModel", &model); + + canvas->setSource(testFileUrl("pathview0.qml")); + qApp->processEvents(); + + QQuickPathView *pathview = findItem(canvas->rootObject(), "view"); + QVERIFY(pathview != 0); + + pathview->setHighlightRangeMode((QQuickPathView::HighlightRangeMode)mode); + + pathview->setCurrentIndex(4); + if (mode == QQuickPathView::StrictlyEnforceRange) + QTRY_COMPARE(pathview->offset(), 4.0); + else + pathview->setOffset(4); + + model.moveItems(from, to, count); + QTRY_COMPARE(pathview->offset(), offset); + + delete canvas; +} + +void tst_QQuickPathView::path() +{ + QQmlEngine engine; + QQmlComponent c(&engine, testFileUrl("pathtest.qml")); + QQuickPath *obj = qobject_cast(c.create()); + + QVERIFY(obj != 0); + QCOMPARE(obj->startX(), 120.); + QCOMPARE(obj->startY(), 100.); + QVERIFY(obj->path() != QPainterPath()); + + QQmlListReference list(obj, "pathElements"); + QCOMPARE(list.count(), 5); + + QQuickPathAttribute* attr = qobject_cast(list.at(0)); + QVERIFY(attr != 0); + QCOMPARE(attr->name(), QString("scale")); + QCOMPARE(attr->value(), 1.0); + + QQuickPathQuad* quad = qobject_cast(list.at(1)); + QVERIFY(quad != 0); + QCOMPARE(quad->x(), 120.); + QCOMPARE(quad->y(), 25.); + QCOMPARE(quad->controlX(), 260.); + QCOMPARE(quad->controlY(), 75.); + + QQuickPathPercent* perc = qobject_cast(list.at(2)); + QVERIFY(perc != 0); + QCOMPARE(perc->value(), 0.3); + + QQuickPathLine* line = qobject_cast(list.at(3)); + QVERIFY(line != 0); + QCOMPARE(line->x(), 120.); + QCOMPARE(line->y(), 100.); + + QQuickPathCubic* cubic = qobject_cast(list.at(4)); + QVERIFY(cubic != 0); + QCOMPARE(cubic->x(), 180.); + QCOMPARE(cubic->y(), 0.); + QCOMPARE(cubic->control1X(), -10.); + QCOMPARE(cubic->control1Y(), 90.); + QCOMPARE(cubic->control2X(), 210.); + QCOMPARE(cubic->control2Y(), 90.); + + delete obj; +} + +void tst_QQuickPathView::dataModel() +{ + QQuickView *canvas = createView(); + canvas->show(); + + QQmlContext *ctxt = canvas->rootContext(); + TestObject *testObject = new TestObject; + ctxt->setContextProperty("testObject", testObject); + + QaimModel model; + model.addItem("red", "1"); + model.addItem("green", "2"); + model.addItem("blue", "3"); + model.addItem("purple", "4"); + model.addItem("gray", "5"); + model.addItem("brown", "6"); + model.addItem("yellow", "7"); + model.addItem("thistle", "8"); + model.addItem("cyan", "9"); + model.addItem("peachpuff", "10"); + model.addItem("powderblue", "11"); + model.addItem("gold", "12"); + model.addItem("sandybrown", "13"); + + ctxt->setContextProperty("testData", &model); + + canvas->setSource(testFileUrl("datamodel.qml")); + qApp->processEvents(); + + QQuickPathView *pathview = qobject_cast(canvas->rootObject()); + QVERIFY(pathview != 0); + + QMetaObject::invokeMethod(canvas->rootObject(), "checkProperties"); + QVERIFY(testObject->error() == false); + + QQuickItem *item = findItem(pathview, "wrapper", 0); + QVERIFY(item); + QCOMPARE(item->x(), 110.0); + QCOMPARE(item->y(), 10.0); + + model.insertItem(4, "orange", "10"); + QTest::qWait(100); + + QCOMPARE(canvas->rootObject()->property("viewCount").toInt(), model.count()); + QTRY_COMPARE(findItems(pathview, "wrapper").count(), 14); + + QVERIFY(pathview->currentIndex() == 0); + QCOMPARE(pathview->currentItem(), findItem(pathview, "wrapper", 0)); + + QQuickText *text = findItem(pathview, "myText", 4); + QVERIFY(text); + QCOMPARE(text->text(), model.name(4)); + + model.removeItem(2); + QCOMPARE(canvas->rootObject()->property("viewCount").toInt(), model.count()); + text = findItem(pathview, "myText", 2); + QVERIFY(text); + QCOMPARE(text->text(), model.name(2)); + QCOMPARE(pathview->currentItem(), findItem(pathview, "wrapper", 0)); + + testObject->setPathItemCount(5); + QMetaObject::invokeMethod(canvas->rootObject(), "checkProperties"); + QVERIFY(testObject->error() == false); + + QTRY_COMPARE(findItems(pathview, "wrapper").count(), 5); + + QQuickRectangle *testItem = findItem(pathview, "wrapper", 4); + QVERIFY(testItem != 0); + testItem = findItem(pathview, "wrapper", 5); + QVERIFY(testItem == 0); + + pathview->setCurrentIndex(1); + QCOMPARE(pathview->currentItem(), findItem(pathview, "wrapper", 1)); + QTest::qWait(100); + + model.insertItem(2, "pink", "2"); + QTest::qWait(100); + + QTRY_COMPARE(findItems(pathview, "wrapper").count(), 5); + QVERIFY(pathview->currentIndex() == 1); + QCOMPARE(pathview->currentItem(), findItem(pathview, "wrapper", 1)); + + text = findItem(pathview, "myText", 2); + QVERIFY(text); + QCOMPARE(text->text(), model.name(2)); + + model.removeItem(3); + QTRY_COMPARE(findItems(pathview, "wrapper").count(), 5); + text = findItem(pathview, "myText", 3); + QVERIFY(text); + QCOMPARE(text->text(), model.name(3)); + QCOMPARE(pathview->currentItem(), findItem(pathview, "wrapper", 1)); + + model.moveItem(3, 5); + QTRY_COMPARE(findItems(pathview, "wrapper").count(), 5); + QList items = findItems(pathview, "wrapper"); + foreach (QQuickItem *item, items) { + QVERIFY(item->property("onPath").toBool()); + } + QCOMPARE(pathview->currentItem(), findItem(pathview, "wrapper", 1)); + + // QTBUG-14199 + pathview->setOffset(7); + pathview->setOffset(0); + QCOMPARE(findItems(pathview, "wrapper").count(), 5); + + pathview->setCurrentIndex(model.count()-1); + model.removeItem(model.count()-1); + QCOMPARE(pathview->currentIndex(), model.count()-1); + + delete canvas; + delete testObject; +} + +void tst_QQuickPathView::pathMoved() +{ + QQuickView *canvas = createView(); + canvas->show(); + + QaimModel model; + model.addItem("Ben", "12345"); + model.addItem("Bohn", "2345"); + model.addItem("Bob", "54321"); + model.addItem("Bill", "4321"); + + QQmlContext *ctxt = canvas->rootContext(); + ctxt->setContextProperty("testModel", &model); + + canvas->setSource(testFileUrl("pathview0.qml")); + qApp->processEvents(); + + QQuickPathView *pathview = findItem(canvas->rootObject(), "view"); + QVERIFY(pathview != 0); + + QQuickRectangle *firstItem = findItem(pathview, "wrapper", 0); + QVERIFY(firstItem); + QQuickPath *path = qobject_cast(pathview->path()); + QVERIFY(path); + QPointF start = path->pointAt(0.0); + QPointF offset;//Center of item is at point, but pos is from corner + offset.setX(firstItem->width()/2); + offset.setY(firstItem->height()/2); + QTRY_COMPARE(firstItem->pos() + offset, start); + pathview->setOffset(1.0); + + for (int i=0; i(pathview, "wrapper", i); + QPointF itemPos(path->pointAt(0.25 + i*0.25)); + QCOMPARE(curItem->pos() + offset, QPointF(itemPos.x(), itemPos.y())); + } + + pathview->setOffset(0.0); + QCOMPARE(firstItem->pos() + offset, start); + + // Change delegate size + pathview->setOffset(0.1); + pathview->setOffset(0.0); + canvas->rootObject()->setProperty("delegateWidth", 30); + QCOMPARE(firstItem->width(), 30.0); + offset.setX(firstItem->width()/2); + QTRY_COMPARE(firstItem->pos() + offset, start); + + // Change delegate scale + pathview->setOffset(0.1); + pathview->setOffset(0.0); + canvas->rootObject()->setProperty("delegateScale", 1.2); + QTRY_COMPARE(firstItem->pos() + offset, start); + + delete canvas; +} + +void tst_QQuickPathView::setCurrentIndex() +{ + QQuickView *canvas = createView(); + canvas->show(); + + QaimModel model; + model.addItem("Ben", "12345"); + model.addItem("Bohn", "2345"); + model.addItem("Bob", "54321"); + model.addItem("Bill", "4321"); + + QQmlContext *ctxt = canvas->rootContext(); + ctxt->setContextProperty("testModel", &model); + + canvas->setSource(testFileUrl("pathview0.qml")); + qApp->processEvents(); + + QQuickPathView *pathview = findItem(canvas->rootObject(), "view"); + QVERIFY(pathview != 0); + + QQuickRectangle *firstItem = findItem(pathview, "wrapper", 0); + QVERIFY(firstItem); + QQuickPath *path = qobject_cast(pathview->path()); + QVERIFY(path); + QPointF start = path->pointAt(0.0); + QPointF offset;//Center of item is at point, but pos is from corner + offset.setX(firstItem->width()/2); + offset.setY(firstItem->height()/2); + QCOMPARE(firstItem->pos() + offset, start); + QCOMPARE(canvas->rootObject()->property("currentA").toInt(), 0); + QCOMPARE(canvas->rootObject()->property("currentB").toInt(), 0); + + pathview->setCurrentIndex(2); + + firstItem = findItem(pathview, "wrapper", 2); + QTRY_COMPARE(firstItem->pos() + offset, start); + QCOMPARE(canvas->rootObject()->property("currentA").toInt(), 2); + QCOMPARE(canvas->rootObject()->property("currentB").toInt(), 2); + QCOMPARE(pathview->currentItem(), firstItem); + QCOMPARE(firstItem->property("onPath"), QVariant(true)); + + pathview->decrementCurrentIndex(); + QTRY_COMPARE(pathview->currentIndex(), 1); + firstItem = findItem(pathview, "wrapper", 1); + QVERIFY(firstItem); + QTRY_COMPARE(firstItem->pos() + offset, start); + QCOMPARE(pathview->currentItem(), firstItem); + QCOMPARE(firstItem->property("onPath"), QVariant(true)); + + pathview->decrementCurrentIndex(); + QTRY_COMPARE(pathview->currentIndex(), 0); + firstItem = findItem(pathview, "wrapper", 0); + QVERIFY(firstItem); + QTRY_COMPARE(firstItem->pos() + offset, start); + QCOMPARE(pathview->currentItem(), firstItem); + QCOMPARE(firstItem->property("onPath"), QVariant(true)); + + pathview->decrementCurrentIndex(); + QTRY_COMPARE(pathview->currentIndex(), 3); + firstItem = findItem(pathview, "wrapper", 3); + QVERIFY(firstItem); + QTRY_COMPARE(firstItem->pos() + offset, start); + QCOMPARE(pathview->currentItem(), firstItem); + QCOMPARE(firstItem->property("onPath"), QVariant(true)); + + pathview->incrementCurrentIndex(); + QTRY_COMPARE(pathview->currentIndex(), 0); + firstItem = findItem(pathview, "wrapper", 0); + QVERIFY(firstItem); + QTRY_COMPARE(firstItem->pos() + offset, start); + QCOMPARE(pathview->currentItem(), firstItem); + QCOMPARE(firstItem->property("onPath"), QVariant(true)); + + // move an item, set move duration to 0, and change currentIndex to moved item. QTBUG-22786 + model.moveItem(0, 3); + pathview->setHighlightMoveDuration(0); + pathview->setCurrentIndex(3); + QCOMPARE(pathview->currentIndex(), 3); + firstItem = findItem(pathview, "wrapper", 3); + QVERIFY(firstItem); + QCOMPARE(pathview->currentItem(), firstItem); + QTRY_COMPARE(firstItem->pos() + offset, start); + model.moveItem(3, 0); + pathview->setCurrentIndex(0); + pathview->setHighlightMoveDuration(300); + + // Check the current item is still created when outside the bounds of pathItemCount. + pathview->setPathItemCount(2); + pathview->setHighlightRangeMode(QQuickPathView::NoHighlightRange); + QVERIFY(findItem(pathview, "wrapper", 0)); + QVERIFY(findItem(pathview, "wrapper", 1)); + QVERIFY(!findItem(pathview, "wrapper", 2)); + QVERIFY(!findItem(pathview, "wrapper", 3)); + + pathview->setCurrentIndex(2); + firstItem = findItem(pathview, "wrapper", 2); + QCOMPARE(pathview->currentItem(), firstItem); + QCOMPARE(firstItem->property("onPath"), QVariant(false)); + + pathview->decrementCurrentIndex(); + QTRY_COMPARE(pathview->currentIndex(), 1); + firstItem = findItem(pathview, "wrapper", 1); + QVERIFY(firstItem); + QCOMPARE(pathview->currentItem(), firstItem); + QCOMPARE(firstItem->property("onPath"), QVariant(true)); + + pathview->decrementCurrentIndex(); + QTRY_COMPARE(pathview->currentIndex(), 0); + firstItem = findItem(pathview, "wrapper", 0); + QVERIFY(firstItem); + QCOMPARE(pathview->currentItem(), firstItem); + QCOMPARE(firstItem->property("onPath"), QVariant(true)); + + pathview->decrementCurrentIndex(); + QTRY_COMPARE(pathview->currentIndex(), 3); + firstItem = findItem(pathview, "wrapper", 3); + QVERIFY(firstItem); + QCOMPARE(pathview->currentItem(), firstItem); + QCOMPARE(firstItem->property("onPath"), QVariant(false)); + + pathview->incrementCurrentIndex(); + QTRY_COMPARE(pathview->currentIndex(), 0); + firstItem = findItem(pathview, "wrapper", 0); + QVERIFY(firstItem); + QCOMPARE(pathview->currentItem(), firstItem); + QCOMPARE(firstItem->property("onPath"), QVariant(true)); + + delete canvas; +} + +void tst_QQuickPathView::resetModel() +{ + QQuickView *canvas = createView(); + + QStringList strings; + strings << "one" << "two" << "three"; + QStringListModel model(strings); + + QQmlContext *ctxt = canvas->rootContext(); + ctxt->setContextProperty("testModel", &model); + + canvas->setSource(testFileUrl("displaypath.qml")); + qApp->processEvents(); + + QQuickPathView *pathview = findItem(canvas->rootObject(), "view"); + QVERIFY(pathview != 0); + + QCOMPARE(pathview->count(), model.rowCount()); + + for (int i = 0; i < model.rowCount(); ++i) { + QQuickText *display = findItem(pathview, "displayText", i); + QVERIFY(display != 0); + QCOMPARE(display->text(), strings.at(i)); + } + + strings.clear(); + strings << "four" << "five" << "six" << "seven"; + model.setStringList(strings); + + QCOMPARE(pathview->count(), model.rowCount()); + + for (int i = 0; i < model.rowCount(); ++i) { + QQuickText *display = findItem(pathview, "displayText", i); + QVERIFY(display != 0); + QCOMPARE(display->text(), strings.at(i)); + } + + delete canvas; +} + +void tst_QQuickPathView::propertyChanges() +{ + QQuickView *canvas = createView(); + QVERIFY(canvas); + canvas->setSource(testFileUrl("propertychanges.qml")); + + QQuickPathView *pathView = canvas->rootObject()->findChild("pathView"); + QVERIFY(pathView); + + QSignalSpy snapPositionSpy(pathView, SIGNAL(preferredHighlightBeginChanged())); + QSignalSpy dragMarginSpy(pathView, SIGNAL(dragMarginChanged())); + + QCOMPARE(pathView->preferredHighlightBegin(), 0.1); + QCOMPARE(pathView->dragMargin(), 5.0); + + pathView->setPreferredHighlightBegin(0.4); + pathView->setPreferredHighlightEnd(0.4); + pathView->setDragMargin(20.0); + + QCOMPARE(pathView->preferredHighlightBegin(), 0.4); + QCOMPARE(pathView->preferredHighlightEnd(), 0.4); + QCOMPARE(pathView->dragMargin(), 20.0); + + QCOMPARE(snapPositionSpy.count(), 1); + QCOMPARE(dragMarginSpy.count(), 1); + + pathView->setPreferredHighlightBegin(0.4); + pathView->setPreferredHighlightEnd(0.4); + pathView->setDragMargin(20.0); + + QCOMPARE(snapPositionSpy.count(), 1); + QCOMPARE(dragMarginSpy.count(), 1); + delete canvas; +} + +void tst_QQuickPathView::pathChanges() +{ + QQuickView *canvas = createView(); + QVERIFY(canvas); + canvas->setSource(testFileUrl("propertychanges.qml")); + + QQuickPathView *pathView = canvas->rootObject()->findChild("pathView"); + QVERIFY(pathView); + + QQuickPath *path = canvas->rootObject()->findChild("path"); + QVERIFY(path); + + QSignalSpy startXSpy(path, SIGNAL(startXChanged())); + QSignalSpy startYSpy(path, SIGNAL(startYChanged())); + + QCOMPARE(path->startX(), 220.0); + QCOMPARE(path->startY(), 200.0); + + path->setStartX(240.0); + path->setStartY(220.0); + + QCOMPARE(path->startX(), 240.0); + QCOMPARE(path->startY(), 220.0); + + QCOMPARE(startXSpy.count(),1); + QCOMPARE(startYSpy.count(),1); + + path->setStartX(240); + path->setStartY(220); + + QCOMPARE(startXSpy.count(),1); + QCOMPARE(startYSpy.count(),1); + + QQuickPath *alternatePath = canvas->rootObject()->findChild("alternatePath"); + QVERIFY(alternatePath); + + QSignalSpy pathSpy(pathView, SIGNAL(pathChanged())); + + QCOMPARE(pathView->path(), path); + + pathView->setPath(alternatePath); + QCOMPARE(pathView->path(), alternatePath); + QCOMPARE(pathSpy.count(),1); + + pathView->setPath(alternatePath); + QCOMPARE(pathSpy.count(),1); + + QQuickPathAttribute *pathAttribute = canvas->rootObject()->findChild("pathAttribute"); + QVERIFY(pathAttribute); + + QSignalSpy nameSpy(pathAttribute, SIGNAL(nameChanged())); + QCOMPARE(pathAttribute->name(), QString("opacity")); + + pathAttribute->setName("scale"); + QCOMPARE(pathAttribute->name(), QString("scale")); + QCOMPARE(nameSpy.count(),1); + + pathAttribute->setName("scale"); + QCOMPARE(nameSpy.count(),1); + delete canvas; +} + +void tst_QQuickPathView::componentChanges() +{ + QQuickView *canvas = createView(); + QVERIFY(canvas); + canvas->setSource(testFileUrl("propertychanges.qml")); + + QQuickPathView *pathView = canvas->rootObject()->findChild("pathView"); + QVERIFY(pathView); + + QQmlComponent delegateComponent(canvas->engine()); + delegateComponent.setData("import QtQuick 2.0; Text { text: 'Name: ' + name }", QUrl::fromLocalFile("")); + + QSignalSpy delegateSpy(pathView, SIGNAL(delegateChanged())); + + pathView->setDelegate(&delegateComponent); + QCOMPARE(pathView->delegate(), &delegateComponent); + QCOMPARE(delegateSpy.count(),1); + + pathView->setDelegate(&delegateComponent); + QCOMPARE(delegateSpy.count(),1); + delete canvas; +} + +void tst_QQuickPathView::modelChanges() +{ + QQuickView *canvas = createView(); + QVERIFY(canvas); + canvas->setSource(testFileUrl("propertychanges.qml")); + + QQuickPathView *pathView = canvas->rootObject()->findChild("pathView"); + QVERIFY(pathView); + + QQuickListModel *alternateModel = canvas->rootObject()->findChild("alternateModel"); + QVERIFY(alternateModel); + QVariant modelVariant = QVariant::fromValue(alternateModel); + QSignalSpy modelSpy(pathView, SIGNAL(modelChanged())); + + pathView->setModel(modelVariant); + QCOMPARE(pathView->model(), modelVariant); + QCOMPARE(modelSpy.count(),1); + + pathView->setModel(modelVariant); + QCOMPARE(modelSpy.count(),1); + + pathView->setModel(QVariant()); + QCOMPARE(modelSpy.count(),2); + + delete canvas; +} + +void tst_QQuickPathView::pathUpdateOnStartChanged() +{ + QQuickView *canvas = createView(); + QVERIFY(canvas); + canvas->setSource(testFileUrl("pathUpdateOnStartChanged.qml")); + + QQuickPathView *pathView = canvas->rootObject()->findChild("pathView"); + QVERIFY(pathView); + + QQuickPath *path = canvas->rootObject()->findChild("path"); + QVERIFY(path); + QCOMPARE(path->startX(), 400.0); + QCOMPARE(path->startY(), 300.0); + + QQuickItem *item = findItem(pathView, "wrapper", 0); + QVERIFY(item); + QCOMPARE(item->x(), path->startX() - item->width() / 2.0); + QCOMPARE(item->y(), path->startY() - item->height() / 2.0); + + delete canvas; +} + +void tst_QQuickPathView::package() +{ + QQuickView *canvas = createView(); + QVERIFY(canvas); + canvas->setSource(testFileUrl("pathview_package.qml")); + canvas->show(); + QTest::qWaitForWindowShown(canvas); + + QQuickPathView *pathView = canvas->rootObject()->findChild("photoPathView"); + QVERIFY(pathView); + +#ifdef Q_OS_MAC + QSKIP("QTBUG-21590 view does not reliably receive polish without a running animation"); +#endif + + QQuickItem *item = findItem(pathView, "pathItem"); + QVERIFY(item); + QVERIFY(item->scale() != 1.0); + + delete canvas; +} + +//QTBUG-13017 +void tst_QQuickPathView::emptyModel() +{ + QQuickView *canvas = createView(); + + QStringListModel model; + + QQmlContext *ctxt = canvas->rootContext(); + ctxt->setContextProperty("emptyModel", &model); + + canvas->setSource(testFileUrl("emptymodel.qml")); + qApp->processEvents(); + + QQuickPathView *pathview = qobject_cast(canvas->rootObject()); + QVERIFY(pathview != 0); + + QCOMPARE(pathview->offset(), qreal(0.0)); + + delete canvas; +} + +void tst_QQuickPathView::closed() +{ + QQmlEngine engine; + + { + QQmlComponent c(&engine, testFileUrl("openPath.qml")); + QQuickPath *obj = qobject_cast(c.create()); + QVERIFY(obj); + QCOMPARE(obj->isClosed(), false); + delete obj; + } + + { + QQmlComponent c(&engine, testFileUrl("closedPath.qml")); + QQuickPath *obj = qobject_cast(c.create()); + QVERIFY(obj); + QCOMPARE(obj->isClosed(), true); + delete obj; + } +} + +// QTBUG-14239 +void tst_QQuickPathView::pathUpdate() +{ + QQuickView *canvas = createView(); + QVERIFY(canvas); + canvas->setSource(testFileUrl("pathUpdate.qml")); + + QQuickPathView *pathView = canvas->rootObject()->findChild("pathView"); + QVERIFY(pathView); + + QQuickItem *item = findItem(pathView, "wrapper", 0); + QVERIFY(item); + QCOMPARE(item->x(), 150.0); + + delete canvas; +} + +void tst_QQuickPathView::visualDataModel() +{ + QQmlEngine engine; + QQmlComponent c(&engine, testFileUrl("vdm.qml")); + + QQuickPathView *obj = qobject_cast(c.create()); + QVERIFY(obj != 0); + + QCOMPARE(obj->count(), 3); + + delete obj; +} + +void tst_QQuickPathView::undefinedPath() +{ + QQmlEngine engine; + + // QPainterPath warnings are only received if QT_NO_DEBUG is not defined + if (QLibraryInfo::isDebugBuild()) { + QString warning1("QPainterPath::moveTo: Adding point where x or y is NaN or Inf, ignoring call"); + QTest::ignoreMessage(QtWarningMsg,qPrintable(warning1)); + + QString warning2("QPainterPath::lineTo: Adding point where x or y is NaN or Inf, ignoring call"); + QTest::ignoreMessage(QtWarningMsg,qPrintable(warning2)); + } + + QQmlComponent c(&engine, testFileUrl("undefinedpath.qml")); + + QQuickPathView *obj = qobject_cast(c.create()); + QVERIFY(obj != 0); + + QCOMPARE(obj->count(), 3); + + delete obj; +} + +void tst_QQuickPathView::mouseDrag() +{ + QQuickView *canvas = createView(); + canvas->setSource(testFileUrl("dragpath.qml")); + canvas->show(); + canvas->requestActivateWindow(); + QTest::qWaitForWindowShown(canvas); + QTRY_COMPARE(canvas, qGuiApp->focusWindow()); + + QQuickPathView *pathview = qobject_cast(canvas->rootObject()); + QVERIFY(pathview != 0); + + int current = pathview->currentIndex(); + + QTest::mousePress(canvas, Qt::LeftButton, 0, QPoint(10,100)); + QTest::qWait(100); + + { + QMouseEvent mv(QEvent::MouseMove, QPoint(30,100), Qt::LeftButton, Qt::LeftButton,Qt::NoModifier); + QGuiApplication::sendEvent(canvas, &mv); + } + { + QMouseEvent mv(QEvent::MouseMove, QPoint(90,100), Qt::LeftButton, Qt::LeftButton,Qt::NoModifier); + QGuiApplication::sendEvent(canvas, &mv); + } + + QVERIFY(pathview->currentIndex() != current); + + QTest::mouseRelease(canvas, Qt::LeftButton, 0, QPoint(40,100)); + + delete canvas; +} + +void tst_QQuickPathView::treeModel() +{ + QQuickView *canvas = createView(); + canvas->show(); + + QStandardItemModel model; + initStandardTreeModel(&model); + canvas->engine()->rootContext()->setContextProperty("myModel", &model); + + canvas->setSource(testFileUrl("treemodel.qml")); + + QQuickPathView *pathview = qobject_cast(canvas->rootObject()); + QVERIFY(pathview != 0); + QCOMPARE(pathview->count(), 3); + + QQuickText *item = findItem(pathview, "wrapper", 0); + QVERIFY(item); + QCOMPARE(item->text(), QLatin1String("Row 1 Item")); + + QVERIFY(QMetaObject::invokeMethod(pathview, "setRoot", Q_ARG(QVariant, 1))); + QCOMPARE(pathview->count(), 1); + + QTRY_VERIFY(item = findItem(pathview, "wrapper", 0)); + QTRY_COMPARE(item->text(), QLatin1String("Row 2 Child Item")); + + delete canvas; +} + +void tst_QQuickPathView::changePreferredHighlight() +{ + QQuickView *canvas = createView(); + canvas->setGeometry(0,0,400,200); + canvas->setSource(testFileUrl("dragpath.qml")); + canvas->show(); + canvas->requestActivateWindow(); + QTest::qWaitForWindowShown(canvas); + QTRY_COMPARE(canvas, qGuiApp->focusWindow()); + + QQuickPathView *pathview = qobject_cast(canvas->rootObject()); + QVERIFY(pathview != 0); + + int current = pathview->currentIndex(); + QCOMPARE(current, 0); + + QQuickRectangle *firstItem = findItem(pathview, "wrapper", 0); + QVERIFY(firstItem); + QQuickPath *path = qobject_cast(pathview->path()); + QVERIFY(path); + QPointF start = path->pointAt(0.5); + QPointF offset;//Center of item is at point, but pos is from corner + offset.setX(firstItem->width()/2); + offset.setY(firstItem->height()/2); + QTRY_COMPARE(firstItem->pos() + offset, start); + + pathview->setPreferredHighlightBegin(0.8); + pathview->setPreferredHighlightEnd(0.8); + start = path->pointAt(0.8); + QTRY_COMPARE(firstItem->pos() + offset, start); + QCOMPARE(pathview->currentIndex(), 0); + + delete canvas; +} + +void tst_QQuickPathView::creationContext() +{ + QQuickView canvas; + canvas.setGeometry(0,0,240,320); + canvas.setSource(testFileUrl("creationContext.qml")); + + QQuickItem *rootItem = qobject_cast(canvas.rootObject()); + QVERIFY(rootItem); + QVERIFY(rootItem->property("count").toInt() > 0); + + QQuickItem *item; + QVERIFY(item = findItem(rootItem, "listItem", 0)); + QCOMPARE(item->property("text").toString(), QString("Hello!")); +} + +// QTBUG-21320 +void tst_QQuickPathView::currentOffsetOnInsertion() +{ + QQuickView *canvas = createView(); + canvas->show(); + + QaimModel model; + + QQmlContext *ctxt = canvas->rootContext(); + ctxt->setContextProperty("testModel", &model); + + canvas->setSource(testFileUrl("pathline.qml")); + qApp->processEvents(); + + QQuickPathView *pathview = findItem(canvas->rootObject(), "view"); + QVERIFY(pathview != 0); + + pathview->setPreferredHighlightBegin(0.5); + pathview->setPreferredHighlightEnd(0.5); + + QCOMPARE(pathview->count(), model.count()); + + model.addItem("item0", "0"); + + QCOMPARE(pathview->count(), model.count()); + + QQuickRectangle *item = 0; + QTRY_VERIFY(item = findItem(pathview, "wrapper", 0)); + + QQuickPath *path = qobject_cast(pathview->path()); + QVERIFY(path); + + QPointF start = path->pointAt(0.5); + QPointF offset;//Center of item is at point, but pos is from corner + offset.setX(item->width()/2); + offset.setY(item->height()/2); + QCOMPARE(item->pos() + offset, start); + + QSignalSpy currentIndexSpy(pathview, SIGNAL(currentIndexChanged())); + + // insert an item at the beginning + model.insertItem(0, "item1", "1"); + qApp->processEvents(); + + QCOMPARE(currentIndexSpy.count(), 1); + + // currentIndex is now 1 + QVERIFY(item = findItem(pathview, "wrapper", 1)); + + // verify that current item (item 1) is still at offset 0.5 + QCOMPARE(item->pos() + offset, start); + + // insert another item at the beginning + model.insertItem(0, "item2", "2"); + qApp->processEvents(); + + QCOMPARE(currentIndexSpy.count(), 2); + + // currentIndex is now 2 + QVERIFY(item = findItem(pathview, "wrapper", 2)); + + // verify that current item (item 2) is still at offset 0.5 + QCOMPARE(item->pos() + offset, start); + + // verify that remove before current maintains current item + model.removeItem(0); + qApp->processEvents(); + + QCOMPARE(currentIndexSpy.count(), 3); + + // currentIndex is now 1 + QVERIFY(item = findItem(pathview, "wrapper", 1)); + + // verify that current item (item 1) is still at offset 0.5 + QCOMPARE(item->pos() + offset, start); + + delete canvas; +} + +void tst_QQuickPathView::asynchronous() +{ + QQuickView *canvas = createView(); + canvas->show(); + QQmlIncubationController controller; + canvas->engine()->setIncubationController(&controller); + + canvas->setSource(testFileUrl("asyncloader.qml")); + + QQuickItem *rootObject = qobject_cast(canvas->rootObject()); + QVERIFY(rootObject); + + QQuickPathView *pathview = 0; + while (!pathview) { + bool b = false; + controller.incubateWhile(&b); + pathview = rootObject->findChild("view"); + } + + // items will be created one at a time + for (int i = 0; i < 5; ++i) { + QVERIFY(findItem(pathview, "wrapper", i) == 0); + QQuickItem *item = 0; + while (!item) { + bool b = false; + controller.incubateWhile(&b); + item = findItem(pathview, "wrapper", i); + } + } + + { + bool b = true; + controller.incubateWhile(&b); + } + + // verify positioning + QQuickRectangle *firstItem = findItem(pathview, "wrapper", 0); + QVERIFY(firstItem); + QQuickPath *path = qobject_cast(pathview->path()); + QVERIFY(path); + QPointF start = path->pointAt(0.0); + QPointF offset;//Center of item is at point, but pos is from corner + offset.setX(firstItem->width()/2); + offset.setY(firstItem->height()/2); + QTRY_COMPARE(firstItem->pos() + offset, start); + pathview->setOffset(1.0); + + for (int i=0; i<5; i++) { + QQuickItem *curItem = findItem(pathview, "wrapper", i); + QPointF itemPos(path->pointAt(0.2 + i*0.2)); + QCOMPARE(curItem->pos() + offset, itemPos); + } + + delete canvas; +} + +void tst_QQuickPathView::missingPercent() +{ + QQmlEngine engine; + QQmlComponent c(&engine, testFileUrl("missingPercent.qml")); + QQuickPath *obj = qobject_cast(c.create()); + QVERIFY(obj); + QCOMPARE(obj->attributeAt("_qfx_percent", 1.0), qreal(1.0)); + delete obj; +} + +QTEST_MAIN(tst_QQuickPathView) + +#include "tst_qquickpathview.moc" diff --git a/tests/auto/quick/qquickpincharea/data/pinchproperties.qml b/tests/auto/quick/qquickpincharea/data/pinchproperties.qml new file mode 100644 index 0000000000..44d116184e --- /dev/null +++ b/tests/auto/quick/qquickpincharea/data/pinchproperties.qml @@ -0,0 +1,50 @@ +import QtQuick 2.0 +Rectangle { + id: whiteRect + property variant center + property real scale + property int pointCount: 0 + width: 240; height: 320 + color: "white" + Rectangle { + id: blackRect + objectName: "blackrect" + color: "black" + y: 50 + x: 50 + width: 100 + height: 100 + opacity: (whiteRect.width-blackRect.x+whiteRect.height-blackRect.y-199)/200 + Text { text: blackRect.opacity} + PinchArea { + id: pincharea + objectName: "pincharea" + anchors.fill: parent + pinch.target: blackRect + pinch.dragAxis: Drag.XandYAxis + pinch.minimumX: 0 + pinch.maximumX: whiteRect.width-blackRect.width + pinch.minimumY: 0 + pinch.maximumY: whiteRect.height-blackRect.height + pinch.minimumScale: 1.0 + pinch.maximumScale: 2.0 + pinch.minimumRotation: 0.0 + pinch.maximumRotation: 90.0 + onPinchStarted: { + whiteRect.center = pinch.center + whiteRect.scale = pinch.scale + whiteRect.pointCount = pinch.pointCount; + } + onPinchUpdated: { + whiteRect.center = pinch.center + whiteRect.scale = pinch.scale + whiteRect.pointCount = pinch.pointCount; + } + onPinchFinished: { + whiteRect.center = pinch.center + whiteRect.scale = pinch.scale + whiteRect.pointCount = pinch.pointCount; + } + } + } + } diff --git a/tests/auto/quick/qquickpincharea/qquickpincharea.pro b/tests/auto/quick/qquickpincharea/qquickpincharea.pro new file mode 100644 index 0000000000..514dd25a5a --- /dev/null +++ b/tests/auto/quick/qquickpincharea/qquickpincharea.pro @@ -0,0 +1,15 @@ +CONFIG += testcase +TARGET = tst_qquickpincharea +macx:CONFIG -= app_bundle + +SOURCES += tst_qquickpincharea.cpp + +include (../../shared/util.pri) + +testDataFiles.files = data +testDataFiles.path = . +DEPLOYMENT += testDataFiles + +CONFIG += parallel_test + +QT += core-private gui-private qml-private quick-private testlib diff --git a/tests/auto/quick/qquickpincharea/tst_qquickpincharea.cpp b/tests/auto/quick/qquickpincharea/tst_qquickpincharea.cpp new file mode 100644 index 0000000000..6e83d41c4e --- /dev/null +++ b/tests/auto/quick/qquickpincharea/tst_qquickpincharea.cpp @@ -0,0 +1,404 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include +#include +#include +#include +#include +#include "../../shared/util.h" + +class tst_QQuickPinchArea: public QQmlDataTest +{ + Q_OBJECT +public: + tst_QQuickPinchArea() : device(0) { } +private slots: + void initTestCase(); + void cleanupTestCase(); + void pinchProperties(); + void scale(); + void pan(); + void retouch(); + +private: + QQuickView *createView(); + QTouchDevice *device; +}; +void tst_QQuickPinchArea::initTestCase() +{ + QQmlDataTest::initTestCase(); + if (!device) { + device = new QTouchDevice; + device->setType(QTouchDevice::TouchScreen); + QWindowSystemInterface::registerTouchDevice(device); + } +} + +void tst_QQuickPinchArea::cleanupTestCase() +{ + +} +void tst_QQuickPinchArea::pinchProperties() +{ + QQuickView *canvas = createView(); + canvas->setSource(testFileUrl("pinchproperties.qml")); + canvas->show(); + canvas->requestActivateWindow(); + QVERIFY(canvas->rootObject() != 0); + + QQuickPinchArea *pinchArea = canvas->rootObject()->findChild("pincharea"); + QQuickPinch *pinch = pinchArea->pinch(); + QVERIFY(pinchArea != 0); + QVERIFY(pinch != 0); + + // target + QQuickItem *blackRect = canvas->rootObject()->findChild("blackrect"); + QVERIFY(blackRect != 0); + QVERIFY(blackRect == pinch->target()); + QQuickItem *rootItem = qobject_cast(canvas->rootObject()); + QVERIFY(rootItem != 0); + QSignalSpy targetSpy(pinch, SIGNAL(targetChanged())); + pinch->setTarget(rootItem); + QCOMPARE(targetSpy.count(),1); + pinch->setTarget(rootItem); + QCOMPARE(targetSpy.count(),1); + + // axis + QCOMPARE(pinch->axis(), QQuickPinch::XandYAxis); + QSignalSpy axisSpy(pinch, SIGNAL(dragAxisChanged())); + pinch->setAxis(QQuickPinch::XAxis); + QCOMPARE(pinch->axis(), QQuickPinch::XAxis); + QCOMPARE(axisSpy.count(),1); + pinch->setAxis(QQuickPinch::XAxis); + QCOMPARE(axisSpy.count(),1); + + // minimum and maximum drag properties + QSignalSpy xminSpy(pinch, SIGNAL(minimumXChanged())); + QSignalSpy xmaxSpy(pinch, SIGNAL(maximumXChanged())); + QSignalSpy yminSpy(pinch, SIGNAL(minimumYChanged())); + QSignalSpy ymaxSpy(pinch, SIGNAL(maximumYChanged())); + + QCOMPARE(pinch->xmin(), 0.0); + QCOMPARE(pinch->xmax(), rootItem->width()-blackRect->width()); + QCOMPARE(pinch->ymin(), 0.0); + QCOMPARE(pinch->ymax(), rootItem->height()-blackRect->height()); + + pinch->setXmin(10); + pinch->setXmax(10); + pinch->setYmin(10); + pinch->setYmax(10); + + QCOMPARE(pinch->xmin(), 10.0); + QCOMPARE(pinch->xmax(), 10.0); + QCOMPARE(pinch->ymin(), 10.0); + QCOMPARE(pinch->ymax(), 10.0); + + QCOMPARE(xminSpy.count(),1); + QCOMPARE(xmaxSpy.count(),1); + QCOMPARE(yminSpy.count(),1); + QCOMPARE(ymaxSpy.count(),1); + + pinch->setXmin(10); + pinch->setXmax(10); + pinch->setYmin(10); + pinch->setYmax(10); + + QCOMPARE(xminSpy.count(),1); + QCOMPARE(xmaxSpy.count(),1); + QCOMPARE(yminSpy.count(),1); + QCOMPARE(ymaxSpy.count(),1); + + // minimum and maximum scale properties + QSignalSpy scaleMinSpy(pinch, SIGNAL(minimumScaleChanged())); + QSignalSpy scaleMaxSpy(pinch, SIGNAL(maximumScaleChanged())); + + QCOMPARE(pinch->minimumScale(), 1.0); + QCOMPARE(pinch->maximumScale(), 2.0); + + pinch->setMinimumScale(0.5); + pinch->setMaximumScale(1.5); + + QCOMPARE(pinch->minimumScale(), 0.5); + QCOMPARE(pinch->maximumScale(), 1.5); + + QCOMPARE(scaleMinSpy.count(),1); + QCOMPARE(scaleMaxSpy.count(),1); + + pinch->setMinimumScale(0.5); + pinch->setMaximumScale(1.5); + + QCOMPARE(scaleMinSpy.count(),1); + QCOMPARE(scaleMaxSpy.count(),1); + + // minimum and maximum rotation properties + QSignalSpy rotMinSpy(pinch, SIGNAL(minimumRotationChanged())); + QSignalSpy rotMaxSpy(pinch, SIGNAL(maximumRotationChanged())); + + QCOMPARE(pinch->minimumRotation(), 0.0); + QCOMPARE(pinch->maximumRotation(), 90.0); + + pinch->setMinimumRotation(-90.0); + pinch->setMaximumRotation(45.0); + + QCOMPARE(pinch->minimumRotation(), -90.0); + QCOMPARE(pinch->maximumRotation(), 45.0); + + QCOMPARE(rotMinSpy.count(),1); + QCOMPARE(rotMaxSpy.count(),1); + + pinch->setMinimumRotation(-90.0); + pinch->setMaximumRotation(45.0); + + QCOMPARE(rotMinSpy.count(),1); + QCOMPARE(rotMaxSpy.count(),1); + + delete canvas; +} + +QTouchEvent::TouchPoint makeTouchPoint(int id, QPoint p, QQuickView *v, QQuickItem *i) +{ + QTouchEvent::TouchPoint touchPoint(id); + touchPoint.setPos(i->mapFromScene(p)); + touchPoint.setScreenPos(v->mapToGlobal(p)); + touchPoint.setScenePos(p); + return touchPoint; +} + +void tst_QQuickPinchArea::scale() +{ + QQuickView *canvas = createView(); + canvas->setSource(testFileUrl("pinchproperties.qml")); + canvas->show(); + canvas->requestActivateWindow(); + QTest::qWaitForWindowShown(canvas); + QVERIFY(canvas->rootObject() != 0); + qApp->processEvents(); + + QQuickPinchArea *pinchArea = canvas->rootObject()->findChild("pincharea"); + QQuickPinch *pinch = pinchArea->pinch(); + QVERIFY(pinchArea != 0); + QVERIFY(pinch != 0); + + QQuickItem *root = qobject_cast(canvas->rootObject()); + QVERIFY(root != 0); + + // target + QQuickItem *blackRect = canvas->rootObject()->findChild("blackrect"); + QVERIFY(blackRect != 0); + + QPoint p1(80, 80); + QPoint p2(100, 100); + + QTest::touchEvent(canvas, device).press(0, p1, canvas); + QTest::touchEvent(canvas, device).stationary(0).press(1, p2, canvas); + p1 -= QPoint(10,10); + p2 += QPoint(10,10); + QTest::touchEvent(canvas, device).move(0, p1,canvas).move(1, p2,canvas); + + QCOMPARE(root->property("scale").toReal(), 1.0); + + p1 -= QPoint(10,10); + p2 += QPoint(10,10); + QTest::touchEvent(canvas, device).move(0, p1,canvas).move(1, p2,canvas); + + QCOMPARE(root->property("scale").toReal(), 1.5); + QCOMPARE(root->property("center").toPointF(), QPointF(40, 40)); // blackrect is at 50,50 + QCOMPARE(blackRect->scale(), 1.5); + + // scale beyond bound + p1 -= QPoint(50,50); + p2 += QPoint(50,50); + QTest::touchEvent(canvas, device).move(0, p1, canvas).move(1, p2, canvas); + + QCOMPARE(blackRect->scale(), 2.0); + + QTest::touchEvent(canvas, device).release(0, p1, canvas).release(1, p2, canvas); + + delete canvas; +} + +void tst_QQuickPinchArea::pan() +{ + QQuickView *canvas = createView(); + canvas->setSource(testFileUrl("pinchproperties.qml")); + canvas->show(); + canvas->requestActivateWindow(); + QTest::qWaitForWindowShown(canvas); + QVERIFY(canvas->rootObject() != 0); + qApp->processEvents(); + + QQuickPinchArea *pinchArea = canvas->rootObject()->findChild("pincharea"); + QQuickPinch *pinch = pinchArea->pinch(); + QVERIFY(pinchArea != 0); + QVERIFY(pinch != 0); + + QQuickItem *root = qobject_cast(canvas->rootObject()); + QVERIFY(root != 0); + + // target + QQuickItem *blackRect = canvas->rootObject()->findChild("blackrect"); + QVERIFY(blackRect != 0); + + QPoint p1(80, 80); + QPoint p2(100, 100); + + QTest::touchEvent(canvas, device).press(0, p1, canvas); + QTest::touchEvent(canvas, device).stationary(0).press(1, p2, canvas); + p1 += QPoint(10,10); + p2 += QPoint(10,10); + QTest::touchEvent(canvas, device).move(0, p1, canvas).move(1, p2, canvas); + + QCOMPARE(root->property("scale").toReal(), 1.0); + + p1 += QPoint(10,10); + p2 += QPoint(10,10); + QTest::touchEvent(canvas, device).move(0, p1, canvas).move(1, p2, canvas); + + QCOMPARE(root->property("center").toPointF(), QPointF(60, 60)); // blackrect is at 50,50 + + QCOMPARE(blackRect->x(), 60.0); + QCOMPARE(blackRect->y(), 60.0); + + // pan x beyond bound + p1 += QPoint(100,100); + p2 += QPoint(100,100); + QTest::touchEvent(canvas, device).move(0, p1, canvas).move(1, p2, canvas); + + QCOMPARE(blackRect->x(), 140.0); + QCOMPARE(blackRect->y(), 160.0); + + QTest::touchEvent(canvas, device).release(0, p1, canvas).release(1, p2, canvas); + + delete canvas; +} + +// test pinch, release one point, touch again to continue pinch +void tst_QQuickPinchArea::retouch() +{ + QQuickView *canvas = createView(); + canvas->setSource(testFileUrl("pinchproperties.qml")); + canvas->show(); + canvas->requestActivateWindow(); + QTest::qWaitForWindowShown(canvas); + QVERIFY(canvas->rootObject() != 0); + qApp->processEvents(); + + QQuickPinchArea *pinchArea = canvas->rootObject()->findChild("pincharea"); + QQuickPinch *pinch = pinchArea->pinch(); + QVERIFY(pinchArea != 0); + QVERIFY(pinch != 0); + + QQuickItem *root = qobject_cast(canvas->rootObject()); + QVERIFY(root != 0); + + QSignalSpy startedSpy(pinchArea, SIGNAL(pinchStarted(QQuickPinchEvent *))); + QSignalSpy finishedSpy(pinchArea, SIGNAL(pinchFinished(QQuickPinchEvent *))); + + // target + QQuickItem *blackRect = canvas->rootObject()->findChild("blackrect"); + QVERIFY(blackRect != 0); + + QPoint p1(80, 80); + QPoint p2(100, 100); + + QTest::touchEvent(canvas, device).press(0, p1, canvas); + QTest::touchEvent(canvas, device).stationary(0).press(1, p2, canvas); + p1 -= QPoint(10,10); + p2 += QPoint(10,10); + QTest::touchEvent(canvas, device).move(0, p1, canvas).move(1, p2, canvas); + + QCOMPARE(root->property("scale").toReal(), 1.0); + + p1 -= QPoint(10,10); + p2 += QPoint(10,10); + QTest::touchEvent(canvas, device).move(0, p1, canvas).move(1, p2, canvas); + + QCOMPARE(startedSpy.count(), 1); + + QCOMPARE(root->property("scale").toReal(), 1.5); + QCOMPARE(root->property("center").toPointF(), QPointF(40, 40)); // blackrect is at 50,50 + QCOMPARE(blackRect->scale(), 1.5); + + QCOMPARE(canvas->rootObject()->property("pointCount").toInt(), 2); + + QCOMPARE(startedSpy.count(), 1); + QCOMPARE(finishedSpy.count(), 0); + + QTest::touchEvent(canvas, device).stationary(0).release(1, p2, canvas); + + QCOMPARE(startedSpy.count(), 1); + QCOMPARE(finishedSpy.count(), 0); + + QCOMPARE(canvas->rootObject()->property("pointCount").toInt(), 1); + + QTest::touchEvent(canvas, device).stationary(0).press(1, p2, canvas); + p1 -= QPoint(10,10); + p2 += QPoint(10,10); + QTest::touchEvent(canvas, device).move(0, p1, canvas).move(1, p2, canvas); + + // Lifting and retouching results in onPinchStarted being called again + QCOMPARE(startedSpy.count(), 2); + QCOMPARE(finishedSpy.count(), 0); + + QCOMPARE(canvas->rootObject()->property("pointCount").toInt(), 2); + + QTest::touchEvent(canvas, device).release(0, p1, canvas).release(1, p2, canvas); + + QCOMPARE(startedSpy.count(), 2); + QCOMPARE(finishedSpy.count(), 1); + + delete canvas; +} + + +QQuickView *tst_QQuickPinchArea::createView() +{ + QQuickView *canvas = new QQuickView(0); + canvas->setGeometry(0,0,240,320); + + return canvas; +} + +QTEST_MAIN(tst_QQuickPinchArea) + +#include "tst_qquickpincharea.moc" diff --git a/tests/auto/quick/qquickpixmapcache/data/exists.png b/tests/auto/quick/qquickpixmapcache/data/exists.png new file mode 100644 index 0000000000..399bd0b1d9 Binary files /dev/null and b/tests/auto/quick/qquickpixmapcache/data/exists.png differ diff --git a/tests/auto/quick/qquickpixmapcache/data/exists1.png b/tests/auto/quick/qquickpixmapcache/data/exists1.png new file mode 100644 index 0000000000..399bd0b1d9 Binary files /dev/null and b/tests/auto/quick/qquickpixmapcache/data/exists1.png differ diff --git a/tests/auto/quick/qquickpixmapcache/data/exists2.png b/tests/auto/quick/qquickpixmapcache/data/exists2.png new file mode 100644 index 0000000000..399bd0b1d9 Binary files /dev/null and b/tests/auto/quick/qquickpixmapcache/data/exists2.png differ diff --git a/tests/auto/quick/qquickpixmapcache/data/http/exists.png b/tests/auto/quick/qquickpixmapcache/data/http/exists.png new file mode 100644 index 0000000000..399bd0b1d9 Binary files /dev/null and b/tests/auto/quick/qquickpixmapcache/data/http/exists.png differ diff --git a/tests/auto/quick/qquickpixmapcache/data/http/exists1.png b/tests/auto/quick/qquickpixmapcache/data/http/exists1.png new file mode 100644 index 0000000000..399bd0b1d9 Binary files /dev/null and b/tests/auto/quick/qquickpixmapcache/data/http/exists1.png differ diff --git a/tests/auto/quick/qquickpixmapcache/data/http/exists2.png b/tests/auto/quick/qquickpixmapcache/data/http/exists2.png new file mode 100644 index 0000000000..399bd0b1d9 Binary files /dev/null and b/tests/auto/quick/qquickpixmapcache/data/http/exists2.png differ diff --git a/tests/auto/quick/qquickpixmapcache/data/http/exists3.png b/tests/auto/quick/qquickpixmapcache/data/http/exists3.png new file mode 100644 index 0000000000..399bd0b1d9 Binary files /dev/null and b/tests/auto/quick/qquickpixmapcache/data/http/exists3.png differ diff --git a/tests/auto/quick/qquickpixmapcache/data/http/exists4.png b/tests/auto/quick/qquickpixmapcache/data/http/exists4.png new file mode 100644 index 0000000000..399bd0b1d9 Binary files /dev/null and b/tests/auto/quick/qquickpixmapcache/data/http/exists4.png differ diff --git a/tests/auto/quick/qquickpixmapcache/data/http/exists5.png b/tests/auto/quick/qquickpixmapcache/data/http/exists5.png new file mode 100644 index 0000000000..399bd0b1d9 Binary files /dev/null and b/tests/auto/quick/qquickpixmapcache/data/http/exists5.png differ diff --git a/tests/auto/quick/qquickpixmapcache/data/http/exists6.png b/tests/auto/quick/qquickpixmapcache/data/http/exists6.png new file mode 100644 index 0000000000..399bd0b1d9 Binary files /dev/null and b/tests/auto/quick/qquickpixmapcache/data/http/exists6.png differ diff --git a/tests/auto/quick/qquickpixmapcache/data/http/exists7.png b/tests/auto/quick/qquickpixmapcache/data/http/exists7.png new file mode 100644 index 0000000000..399bd0b1d9 Binary files /dev/null and b/tests/auto/quick/qquickpixmapcache/data/http/exists7.png differ diff --git a/tests/auto/quick/qquickpixmapcache/data/http/exists8.png b/tests/auto/quick/qquickpixmapcache/data/http/exists8.png new file mode 100644 index 0000000000..399bd0b1d9 Binary files /dev/null and b/tests/auto/quick/qquickpixmapcache/data/http/exists8.png differ diff --git a/tests/auto/quick/qquickpixmapcache/data/massive.png b/tests/auto/quick/qquickpixmapcache/data/massive.png new file mode 100644 index 0000000000..bc6cc9e6ca Binary files /dev/null and b/tests/auto/quick/qquickpixmapcache/data/massive.png differ diff --git a/tests/auto/quick/qquickpixmapcache/qquickpixmapcache.pro b/tests/auto/quick/qquickpixmapcache/qquickpixmapcache.pro new file mode 100644 index 0000000000..7611e37b49 --- /dev/null +++ b/tests/auto/quick/qquickpixmapcache/qquickpixmapcache.pro @@ -0,0 +1,21 @@ +CONFIG += testcase +TARGET = tst_qquickpixmapcache +macx:CONFIG -= app_bundle + +SOURCES += tst_qquickpixmapcache.cpp \ + ../../shared/testhttpserver.cpp +HEADERS += ../../shared/testhttpserver.h +INCLUDEPATH += ../../shared/ + +include (../../shared/util.pri) + +importFiles.files = data +importFiles.path = . +DEPLOYMENT += importFiles + +# QMAKE_CXXFLAGS = -fprofile-arcs -ftest-coverage +# LIBS += -lgcov + +CONFIG += parallel_test + +QT += core-private gui-private qml-private quick-private network testlib concurrent diff --git a/tests/auto/quick/qquickpixmapcache/tst_qquickpixmapcache.cpp b/tests/auto/quick/qquickpixmapcache/tst_qquickpixmapcache.cpp new file mode 100644 index 0000000000..855322e376 --- /dev/null +++ b/tests/auto/quick/qquickpixmapcache/tst_qquickpixmapcache.cpp @@ -0,0 +1,467 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include +#include +#include +#include +#include +#include +#include "../../shared/util.h" +#include "testhttpserver.h" + +#ifndef QT_NO_CONCURRENT +#include +#include +#endif + +#define PIXMAP_DATA_LEAK_TEST 0 + +class tst_qquickpixmapcache : public QQmlDataTest +{ + Q_OBJECT +public: + tst_qquickpixmapcache() : server(14452) {} + +private slots: + void initTestCase(); + void single(); + void single_data(); + void parallel(); + void parallel_data(); + void massive(); + void cancelcrash(); + void shrinkcache(); +#ifndef QT_NO_CONCURRENT + void networkCrash(); +#endif + void lockingCrash(); +#if PIXMAP_DATA_LEAK_TEST + void dataLeak(); +#endif +private: + QQmlEngine engine; + TestHTTPServer server; +}; + +static int slotters=0; + +class Slotter : public QObject +{ + Q_OBJECT +public: + Slotter() + { + gotslot = false; + slotters++; + } + bool gotslot; + +public slots: + void got() + { + gotslot = true; + --slotters; + if (slotters==0) + QTestEventLoop::instance().exitLoop(); + } +}; + +#ifndef QT_NO_LOCALFILE_OPTIMIZED_QML +static const bool localfile_optimized = true; +#else +static const bool localfile_optimized = false; +#endif + + +void tst_qquickpixmapcache::initTestCase() +{ + QQmlDataTest::initTestCase(); + server.serveDirectory(testFile("http")); +} + +void tst_qquickpixmapcache::single_data() +{ + // Note, since QQuickPixmapCache is shared, tests affect each other! + // so use different files fore all test functions. + + QTest::addColumn("target"); + QTest::addColumn("incache"); + QTest::addColumn("exists"); + QTest::addColumn("neterror"); + + // File URLs are optimized + QTest::newRow("local") << testFileUrl("exists.png") << localfile_optimized << true << false; + QTest::newRow("local") << testFileUrl("notexists.png") << localfile_optimized << false << false; + QTest::newRow("remote") << QUrl("http://127.0.0.1:14452/exists.png") << false << true << false; + QTest::newRow("remote") << QUrl("http://127.0.0.1:14452/notexists.png") << false << false << true; +} + +void tst_qquickpixmapcache::single() +{ + QFETCH(QUrl, target); + QFETCH(bool, incache); + QFETCH(bool, exists); + QFETCH(bool, neterror); + + QString expectedError; + if (neterror) { + expectedError = "Error downloading " + target.toString() + " - server replied: Not found"; + } else if (!exists) { + expectedError = "Cannot open: " + target.toString(); + } + + QQuickPixmap pixmap; + QVERIFY(pixmap.width() <= 0); // Check Qt assumption + + pixmap.load(&engine, target); + + if (incache) { + QCOMPARE(pixmap.error(), expectedError); + if (exists) { + QVERIFY(pixmap.status() == QQuickPixmap::Ready); + QVERIFY(pixmap.width() > 0); + } else { + QVERIFY(pixmap.status() == QQuickPixmap::Error); + QVERIFY(pixmap.width() <= 0); + } + } else { + QVERIFY(pixmap.width() <= 0); + + Slotter getter; + pixmap.connectFinished(&getter, SLOT(got())); + QTestEventLoop::instance().enterLoop(10); + QVERIFY(!QTestEventLoop::instance().timeout()); + QVERIFY(getter.gotslot); + if (exists) { + QVERIFY(pixmap.status() == QQuickPixmap::Ready); + QVERIFY(pixmap.width() > 0); + } else { + QVERIFY(pixmap.status() == QQuickPixmap::Error); + QVERIFY(pixmap.width() <= 0); + } + QCOMPARE(pixmap.error(), expectedError); + } +} + +void tst_qquickpixmapcache::parallel_data() +{ + // Note, since QQuickPixmapCache is shared, tests affect each other! + // so use different files fore all test functions. + + QTest::addColumn("target1"); + QTest::addColumn("target2"); + QTest::addColumn("incache"); + QTest::addColumn("cancel"); // which one to cancel + + QTest::newRow("local") + << testFileUrl("exists1.png") + << testFileUrl("exists2.png") + << (localfile_optimized ? 2 : 0) + << -1; + + QTest::newRow("remote") + << QUrl("http://127.0.0.1:14452/exists2.png") + << QUrl("http://127.0.0.1:14452/exists3.png") + << 0 + << -1; + + QTest::newRow("remoteagain") + << QUrl("http://127.0.0.1:14452/exists2.png") + << QUrl("http://127.0.0.1:14452/exists3.png") + << 2 + << -1; + + QTest::newRow("remotecopy") + << QUrl("http://127.0.0.1:14452/exists4.png") + << QUrl("http://127.0.0.1:14452/exists4.png") + << 0 + << -1; + + QTest::newRow("remotecopycancel") + << QUrl("http://127.0.0.1:14452/exists5.png") + << QUrl("http://127.0.0.1:14452/exists5.png") + << 0 + << 0; +} + +void tst_qquickpixmapcache::parallel() +{ + QFETCH(QUrl, target1); + QFETCH(QUrl, target2); + QFETCH(int, incache); + QFETCH(int, cancel); + + QList targets; + targets << target1 << target2; + + QList pixmaps; + QList pending; + QList getters; + + for (int i=0; iload(&engine, target); + + QVERIFY(pixmap->status() != QQuickPixmap::Error); + pixmaps.append(pixmap); + if (pixmap->isReady()) { + QVERIFY(pixmap->width() > 0); + getters.append(0); + pending.append(false); + } else { + QVERIFY(pixmap->width() <= 0); + getters.append(new Slotter); + pixmap->connectFinished(getters[i], SLOT(got())); + pending.append(true); + } + } + + QCOMPARE(incache+slotters, targets.count()); + + if (cancel >= 0) { + pixmaps.at(cancel)->clear(getters[cancel]); + slotters--; + } + + if (slotters) { + QTestEventLoop::instance().enterLoop(10); + QVERIFY(!QTestEventLoop::instance().timeout()); + } + + for (int i=0; igotslot); + } else { + if (pending[i]) + QVERIFY(getters[i]->gotslot); + + QVERIFY(pixmap->isReady()); + QVERIFY(pixmap->width() > 0); + delete getters[i]; + } + } + + qDeleteAll(pixmaps); +} + +void tst_qquickpixmapcache::massive() +{ + QQmlEngine engine; + QUrl url = testFileUrl("massive.png"); + + // Confirm that massive images remain in the cache while they are + // in use by the application. + { + qint64 cachekey = 0; + QQuickPixmap p(&engine, url); + QVERIFY(p.isReady()); + QVERIFY(p.image().size() == QSize(10000, 1000)); + cachekey = p.image().cacheKey(); + + QQuickPixmap p2(&engine, url); + QVERIFY(p2.isReady()); + QVERIFY(p2.image().size() == QSize(10000, 1000)); + + QVERIFY(p2.image().cacheKey() == cachekey); + } + + // Confirm that massive images are removed from the cache when + // they become unused + { + qint64 cachekey = 0; + { + QQuickPixmap p(&engine, url); + QVERIFY(p.isReady()); + QVERIFY(p.image().size() == QSize(10000, 1000)); + cachekey = p.image().cacheKey(); + } + + QQuickPixmap p2(&engine, url); + QVERIFY(p2.isReady()); + QVERIFY(p2.image().size() == QSize(10000, 1000)); + + QVERIFY(p2.image().cacheKey() != cachekey); + } +} + +// QTBUG-12729 +void tst_qquickpixmapcache::cancelcrash() +{ + QUrl url("http://127.0.0.1:14452/cancelcrash_notexist.png"); + for (int ii = 0; ii < 1000; ++ii) { + QQuickPixmap pix(&engine, url); + } +} + +class MyPixmapProvider : public QQmlImageProvider +{ +public: + MyPixmapProvider() + : QQmlImageProvider(Pixmap) {} + + virtual QPixmap requestPixmap(const QString &d, QSize *, const QSize &) { + Q_UNUSED(d) + QPixmap pix(800, 600); + pix.fill(Qt::red); + return pix; + } +}; + +// QTBUG-13345 +void tst_qquickpixmapcache::shrinkcache() +{ + QQmlEngine engine; + engine.addImageProvider(QLatin1String("mypixmaps"), new MyPixmapProvider); + + for (int ii = 0; ii < 4000; ++ii) { + QUrl url("image://mypixmaps/" + QString::number(ii)); + QQuickPixmap p(&engine, url); + } +} + +#ifndef QT_NO_CONCURRENT + +void createNetworkServer() +{ + QEventLoop eventLoop; + TestHTTPServer server(14453); + server.serveDirectory(QQmlDataTest::instance()->testFile("http")); + QTimer::singleShot(100, &eventLoop, SLOT(quit())); + eventLoop.exec(); +} + +#ifndef QT_NO_CONCURRENT +// QT-3957 +void tst_qquickpixmapcache::networkCrash() +{ + QFuture future = QtConcurrent::run(createNetworkServer); + QQmlEngine engine; + for (int ii = 0; ii < 100 ; ++ii) { + QQuickPixmap* pixmap = new QQuickPixmap; + pixmap->load(&engine, QUrl(QString("http://127.0.0.1:14453/exists.png"))); + QTest::qSleep(1); + pixmap->clear(); + delete pixmap; + } + future.cancel(); +} +#endif + +#endif + +// QTBUG-22125 +void tst_qquickpixmapcache::lockingCrash() +{ + TestHTTPServer server(14453); + server.serveDirectory(testFile("http"), TestHTTPServer::Delay); + + { + QQuickPixmap* p = new QQuickPixmap; + { + QQmlEngine e; + p->load(&e, QUrl(QString("http://127.0.0.1:14453/exists6.png"))); + } + p->clear(); + QVERIFY(p->isNull()); + delete p; + } +} + + +#if PIXMAP_DATA_LEAK_TEST +// This test should not be enabled by default as it +// produces spurious output in the expected case. +#include +class DataLeakView : public QQuickView +{ + Q_OBJECT + +public: + explicit DataLeakView() : QQuickView() + { + setSource(testFileUrl("dataLeak.qml")); + } + + void showFor2Seconds() + { + showFullScreen(); + QTimer::singleShot(2000, this, SIGNAL(ready())); + } + +signals: + void ready(); +}; + +// QTBUG-22742 +Q_GLOBAL_STATIC(QQuickPixmap, dataLeakPixmap) +void tst_qquickpixmapcache::dataLeak() +{ + // Should not leak cached QQuickPixmapData. + // Unfortunately, since the QQuickPixmapStore + // is a global static, and it releases the cache + // entries on dtor (application exit), we must use + // valgrind to determine whether it leaks or not. + QQuickPixmap *p1 = new QQuickPixmap; + QQuickPixmap *p2 = new QQuickPixmap; + { + QScopedPointer test(new DataLeakView); + test->showFor2Seconds(); + dataLeakPixmap()->load(test->engine(), testFileUrl("exists.png")); + p1->load(test->engine(), testFileUrl("exists.png")); + p2->load(test->engine(), testFileUrl("exists2.png")); + QTest::qWait(2005); // 2 seconds + a few more millis. + } + + // When the (global static) dataLeakPixmap is deleted, it + // shouldn't attempt to dereference a QQuickPixmapData + // which has been deleted by the QQuickPixmapStore + // destructor. +} +#endif +#undef PIXMAP_DATA_LEAK_TEST + +QTEST_MAIN(tst_qquickpixmapcache) + +#include "tst_qquickpixmapcache.moc" diff --git a/tests/auto/quick/qquickpositioners/data/allInvisible.qml b/tests/auto/quick/qquickpositioners/data/allInvisible.qml new file mode 100644 index 0000000000..5894171434 --- /dev/null +++ b/tests/auto/quick/qquickpositioners/data/allInvisible.qml @@ -0,0 +1,44 @@ +import QtQuick 2.0 + +Item{ + width: 400 + height: 400 + Column{ + spacing: 20 + objectName: "column" + Item{ + width: 0 + height: 20 + visible: false + } + Item{ + width: 20 + height: 0 + visible: false + } + Item{ + width: 20 + height: 20 + visible: false + } + } + Row{ + spacing: 20 + objectName: "row" + Item{ + width: 0 + height: 20 + visible: false + } + Item{ + width: 20 + height: 0 + visible: false + } + Item{ + width: 20 + height: 20 + visible: false + } + } +} diff --git a/tests/auto/quick/qquickpositioners/data/attachedproperties-column.qml b/tests/auto/quick/qquickpositioners/data/attachedproperties-column.qml new file mode 100644 index 0000000000..4c667aa205 --- /dev/null +++ b/tests/auto/quick/qquickpositioners/data/attachedproperties-column.qml @@ -0,0 +1,50 @@ +import QtQuick 2.0 + +Rectangle { + width: 100 + height: 200 + + Column { + + Rectangle { + width: 100 + height: 100 + color: 'red' + visible: false + } + + Rectangle { + objectName: "greenRect" + width: 100 + height: 100 + color: 'green' + property int posIndex: Positioner.index + property bool isFirstItem: Positioner.isFirstItem + property bool isLastItem: Positioner.isLastItem + } + + Rectangle { + width: 100 + height: 100 + color: 'blue' + visible: false + } + + Rectangle { + objectName: "yellowRect" + width: 100 + height: 100 + color: 'yellow' + + property int posIndex: -1 + property bool isFirstItem: false + property bool isLastItem: false + + function onDemandPositioner() { + posIndex = Positioner.index; + isFirstItem = Positioner.isFirstItem + isLastItem = Positioner.isLastItem + } + } + } +} diff --git a/tests/auto/quick/qquickpositioners/data/attachedproperties-dynamic.qml b/tests/auto/quick/qquickpositioners/data/attachedproperties-dynamic.qml new file mode 100644 index 0000000000..894749dc16 --- /dev/null +++ b/tests/auto/quick/qquickpositioners/data/attachedproperties-dynamic.qml @@ -0,0 +1,44 @@ +import QtQuick 2.0 + +Rectangle +{ + width: 300 + height: 100 + + Row { + id: pos + objectName: "pos" + anchors.fill: parent + + Rectangle { + objectName: "rect0" + width: 100 + height: 100 + color: 'red' + property int index: Positioner.index + property bool firstItem: Positioner.isFirstItem + property bool lastItem: Positioner.isLastItem + } + + Rectangle { + objectName: "rect1" + width: 100 + height: 100 + color: 'green' + property int index: Positioner.index + property bool firstItem: Positioner.isFirstItem + property bool lastItem: Positioner.isLastItem + } + + property QtObject subRect; + + function createSubRect() { + var component = Qt.createComponent("rectangleComponent.qml"); + subRect = component.createObject(pos, {}); + } + + function destroySubRect() { + subRect.destroy(); + } + } +} diff --git a/tests/auto/quick/qquickpositioners/data/attachedproperties-flow.qml b/tests/auto/quick/qquickpositioners/data/attachedproperties-flow.qml new file mode 100644 index 0000000000..e7f9a63e2a --- /dev/null +++ b/tests/auto/quick/qquickpositioners/data/attachedproperties-flow.qml @@ -0,0 +1,50 @@ +import QtQuick 2.0 + +Rectangle { + width: 200 + height: 100 + + Flow { + + Rectangle { + width: 100 + height: 100 + color: 'red' + visible: false + } + + Rectangle { + objectName: "greenRect" + width: 100 + height: 100 + color: 'green' + property int posIndex: Positioner.index + property bool isFirstItem: Positioner.isFirstItem + property bool isLastItem: Positioner.isLastItem + } + + Rectangle { + width: 100 + height: 100 + color: 'blue' + visible: false + } + + Rectangle { + objectName: "yellowRect" + width: 100 + height: 100 + color: 'yellow' + + property int posIndex: -1 + property bool isFirstItem: false + property bool isLastItem: false + + function onDemandPositioner() { + posIndex = Positioner.index; + isFirstItem = Positioner.isFirstItem + isLastItem = Positioner.isLastItem + } + } + } +} diff --git a/tests/auto/quick/qquickpositioners/data/attachedproperties-grid.qml b/tests/auto/quick/qquickpositioners/data/attachedproperties-grid.qml new file mode 100644 index 0000000000..2094309b9f --- /dev/null +++ b/tests/auto/quick/qquickpositioners/data/attachedproperties-grid.qml @@ -0,0 +1,50 @@ +import QtQuick 2.0 + +Rectangle { + width: 200 + height: 100 + + Grid { + + Rectangle { + width: 100 + height: 100 + color: 'red' + visible: false + } + + Rectangle { + objectName: "greenRect" + width: 100 + height: 100 + color: 'green' + property int posIndex: Positioner.index + property bool isFirstItem: Positioner.isFirstItem + property bool isLastItem: Positioner.isLastItem + } + + Rectangle { + width: 100 + height: 100 + color: 'blue' + visible: false + } + + Rectangle { + objectName: "yellowRect" + width: 100 + height: 100 + color: 'yellow' + + property int posIndex: -1 + property bool isFirstItem: false + property bool isLastItem: false + + function onDemandPositioner() { + posIndex = Positioner.index; + isFirstItem = Positioner.isFirstItem + isLastItem = Positioner.isLastItem + } + } + } +} diff --git a/tests/auto/quick/qquickpositioners/data/attachedproperties-row.qml b/tests/auto/quick/qquickpositioners/data/attachedproperties-row.qml new file mode 100644 index 0000000000..212a26b431 --- /dev/null +++ b/tests/auto/quick/qquickpositioners/data/attachedproperties-row.qml @@ -0,0 +1,50 @@ +import QtQuick 2.0 + +Rectangle { + width: 200 + height: 100 + + Row { + + Rectangle { + width: 100 + height: 100 + color: 'red' + visible: false + } + + Rectangle { + objectName: "greenRect" + width: 100 + height: 100 + color: 'green' + property int posIndex: Positioner.index + property bool isFirstItem: Positioner.isFirstItem + property bool isLastItem: Positioner.isLastItem + } + + Rectangle { + width: 100 + height: 100 + color: 'blue' + visible: false + } + + Rectangle { + objectName: "yellowRect" + width: 100 + height: 100 + color: 'yellow' + + property int posIndex: -1 + property bool isFirstItem: false + property bool isLastItem: false + + function onDemandPositioner() { + posIndex = Positioner.index; + isFirstItem = Positioner.isFirstItem + isLastItem = Positioner.isLastItem + } + } + } +} diff --git a/tests/auto/quick/qquickpositioners/data/flow-testimplicitsize.qml b/tests/auto/quick/qquickpositioners/data/flow-testimplicitsize.qml new file mode 100644 index 0000000000..c32b78676c --- /dev/null +++ b/tests/auto/quick/qquickpositioners/data/flow-testimplicitsize.qml @@ -0,0 +1,19 @@ +import QtQuick 2.0 + +Rectangle { + width: 300; height: 200; + + property int flowLayout: 1 + + Flow { + objectName: "flow" + layoutDirection: (flowLayout == 2) ? Qt.RightToLeft : Qt.LeftToRight + flow: (flowLayout == 1) ? Flow.TopToBottom : Flow.LeftToRight; + + spacing: 20 + anchors.horizontalCenter: parent.horizontalCenter + Rectangle { color: "red"; width: 100; height: 50 } + Rectangle { color: "blue"; width: 100; height: 50 } + } +} + diff --git a/tests/auto/quick/qquickpositioners/data/flowtest-toptobottom.qml b/tests/auto/quick/qquickpositioners/data/flowtest-toptobottom.qml new file mode 100644 index 0000000000..a7d3ee13c7 --- /dev/null +++ b/tests/auto/quick/qquickpositioners/data/flowtest-toptobottom.qml @@ -0,0 +1,44 @@ +import QtQuick 2.0 + +Item { + height: 90 + width: 480 + property bool testRightToLeft: false + + Flow { + objectName: "flow" + height: parent.height + layoutDirection: testRightToLeft ? Qt.RightToLeft : Qt.LeftToRight + flow: Flow.TopToBottom + Rectangle { + objectName: "one" + color: "red" + width: 50 + height: 50 + } + Rectangle { + objectName: "two" + color: "green" + width: 20 + height: 50 + } + Rectangle { + objectName: "three" + color: "blue" + width: 50 + height: 20 + } + Rectangle { + objectName: "four" + color: "cyan" + width: 50 + height: 50 + } + Rectangle { + objectName: "five" + color: "magenta" + width: 10 + height: 10 + } + } +} diff --git a/tests/auto/quick/qquickpositioners/data/flowtest.qml b/tests/auto/quick/qquickpositioners/data/flowtest.qml new file mode 100644 index 0000000000..40b042dd79 --- /dev/null +++ b/tests/auto/quick/qquickpositioners/data/flowtest.qml @@ -0,0 +1,43 @@ +import QtQuick 2.0 + +Item { + width: 90 + height: 480 + property bool testRightToLeft: false + + Flow { + objectName: "flow" + width: parent.width + layoutDirection: testRightToLeft ? Qt.RightToLeft : Qt.LeftToRight + Rectangle { + objectName: "one" + color: "red" + width: 50 + height: 50 + } + Rectangle { + objectName: "two" + color: "green" + width: 20 + height: 50 + } + Rectangle { + objectName: "three" + color: "blue" + width: 50 + height: 20 + } + Rectangle { + objectName: "four" + color: "cyan" + width: 50 + height: 50 + } + Rectangle { + objectName: "five" + color: "magenta" + width: 10 + height: 10 + } + } +} diff --git a/tests/auto/quick/qquickpositioners/data/grid-animated.qml b/tests/auto/quick/qquickpositioners/data/grid-animated.qml new file mode 100644 index 0000000000..b8ee8f9a52 --- /dev/null +++ b/tests/auto/quick/qquickpositioners/data/grid-animated.qml @@ -0,0 +1,64 @@ +import QtQuick 2.0 + +Item { + width: 640 + height: 480 + property bool testRightToLeft: true + + Grid { + objectName: "grid" + columns: 3 + layoutDirection: testRightToLeft ? Qt.RightToLeft : Qt.LeftToRight + add: Transition { + NumberAnimation { + properties: "x,y"; + } + } + move: Transition { + NumberAnimation { + properties: "x,y"; + } + } + Rectangle { + objectName: "one" + color: "red" + x: -100 + y: -100 + width: 50 + height: 50 + } + Rectangle { + objectName: "two" + x: -100 + y: -100 + visible: false + color: "green" + width: 50 + height: 50 + } + Rectangle { + objectName: "three" + color: "blue" + x: -100 + y: -100 + width: 50 + height: 50 + } + Rectangle { + objectName: "four" + color: "cyan" + x: -100 + y: -100 + width: 50 + height: 50 + } + Rectangle { + objectName: "five" + color: "magenta" + x: -100 + y: -100 + width: 50 + height: 50 + } + } +} diff --git a/tests/auto/quick/qquickpositioners/data/grid-row-column-spacing.qml b/tests/auto/quick/qquickpositioners/data/grid-row-column-spacing.qml new file mode 100644 index 0000000000..49bbd337e7 --- /dev/null +++ b/tests/auto/quick/qquickpositioners/data/grid-row-column-spacing.qml @@ -0,0 +1,43 @@ +import QtQuick 2.0 + +Item { + width: 640 + height: 480 + Grid { + objectName: "grid" + columns: 3 + spacing: 4 + rowSpacing: 7 + columnSpacing: 11 + Rectangle { + objectName: "one" + color: "red" + width: 50 + height: 50 + } + Rectangle { + objectName: "two" + color: "green" + width: 20 + height: 50 + } + Rectangle { + objectName: "three" + color: "blue" + width: 50 + height: 20 + } + Rectangle { + objectName: "four" + color: "cyan" + width: 50 + height: 50 + } + Rectangle { + objectName: "five" + color: "magenta" + width: 10 + height: 10 + } + } +} diff --git a/tests/auto/quick/qquickpositioners/data/grid-spacing.qml b/tests/auto/quick/qquickpositioners/data/grid-spacing.qml new file mode 100644 index 0000000000..535a39037f --- /dev/null +++ b/tests/auto/quick/qquickpositioners/data/grid-spacing.qml @@ -0,0 +1,41 @@ +import QtQuick 2.0 + +Item { + width: 640 + height: 480 + Grid { + objectName: "grid" + columns: 3 + spacing: 4 + Rectangle { + objectName: "one" + color: "red" + width: 50 + height: 50 + } + Rectangle { + objectName: "two" + color: "green" + width: 20 + height: 50 + } + Rectangle { + objectName: "three" + color: "blue" + width: 50 + height: 20 + } + Rectangle { + objectName: "four" + color: "cyan" + width: 50 + height: 50 + } + Rectangle { + objectName: "five" + color: "magenta" + width: 10 + height: 10 + } + } +} diff --git a/tests/auto/quick/qquickpositioners/data/grid-toptobottom.qml b/tests/auto/quick/qquickpositioners/data/grid-toptobottom.qml new file mode 100644 index 0000000000..45559aab5d --- /dev/null +++ b/tests/auto/quick/qquickpositioners/data/grid-toptobottom.qml @@ -0,0 +1,41 @@ +import QtQuick 2.0 + +Item { + width: 640 + height: 480 + Grid { + objectName: "grid" + rows: 3 + flow: Grid.TopToBottom + Rectangle { + objectName: "one" + color: "red" + width: 50 + height: 50 + } + Rectangle { + objectName: "two" + color: "green" + width: 20 + height: 50 + } + Rectangle { + objectName: "three" + color: "blue" + width: 50 + height: 20 + } + Rectangle { + objectName: "four" + color: "cyan" + width: 50 + height: 50 + } + Rectangle { + objectName: "five" + color: "magenta" + width: 10 + height: 10 + } + } +} diff --git a/tests/auto/quick/qquickpositioners/data/gridtest.qml b/tests/auto/quick/qquickpositioners/data/gridtest.qml new file mode 100644 index 0000000000..50bec1377b --- /dev/null +++ b/tests/auto/quick/qquickpositioners/data/gridtest.qml @@ -0,0 +1,42 @@ +import QtQuick 2.0 + +Item { + width: 640 + height: 480 + property bool testRightToLeft: false + Grid { + layoutDirection: testRightToLeft ? Qt.RightToLeft : Qt.LeftToRight + objectName: "grid" + columns: 3 + Rectangle { + objectName: "one" + color: "red" + width: 50 + height: 50 + } + Rectangle { + objectName: "two" + color: "green" + width: 20 + height: 50 + } + Rectangle { + objectName: "three" + color: "blue" + width: 30 + height: 20 + } + Rectangle { + objectName: "four" + color: "cyan" + width: 50 + height: 50 + } + Rectangle { + objectName: "five" + color: "magenta" + width: 10 + height: 10 + } + } +} diff --git a/tests/auto/quick/qquickpositioners/data/gridzerocolumns.qml b/tests/auto/quick/qquickpositioners/data/gridzerocolumns.qml new file mode 100644 index 0000000000..a252f279c3 --- /dev/null +++ b/tests/auto/quick/qquickpositioners/data/gridzerocolumns.qml @@ -0,0 +1,40 @@ +import QtQuick 2.0 + +Item { + width: 640 + height: 480 + Grid { + objectName: "grid" + columns: 0 + Rectangle { + objectName: "one" + color: "red" + width: 50 + height: 50 + } + Rectangle { + objectName: "two" + color: "green" + width: 20 + height: 50 + } + Rectangle { + objectName: "three" + color: "blue" + width: 50 + height: 20 + } + Rectangle { + objectName: "four" + color: "cyan" + width: 50 + height: 50 + } + Rectangle { + objectName: "five" + color: "magenta" + width: 10 + height: 10 + } + } +} diff --git a/tests/auto/quick/qquickpositioners/data/horizontal-animated-disabled.qml b/tests/auto/quick/qquickpositioners/data/horizontal-animated-disabled.qml new file mode 100644 index 0000000000..8723ffc78f --- /dev/null +++ b/tests/auto/quick/qquickpositioners/data/horizontal-animated-disabled.qml @@ -0,0 +1,40 @@ +import QtQuick 2.0 + +Item { + width: 640 + height: 480 + + Row { + objectName: "row" + add: Transition { + enabled: false + NumberAnimation { properties: "x" } + } + move: Transition { + enabled: false + NumberAnimation { properties: "x" } + } + Rectangle { + objectName: "one" + color: "red" + x: -100; + width: 50 + height: 50 + } + Rectangle { + objectName: "two" + color: "blue" + x: -100; + visible: false + width: 50 + height: 50 + } + Rectangle { + objectName: "three" + x: -100; + color: "green" + width: 50 + height: 50 + } + } +} diff --git a/tests/auto/quick/qquickpositioners/data/horizontal-animated.qml b/tests/auto/quick/qquickpositioners/data/horizontal-animated.qml new file mode 100644 index 0000000000..a88c26b66c --- /dev/null +++ b/tests/auto/quick/qquickpositioners/data/horizontal-animated.qml @@ -0,0 +1,47 @@ +import QtQuick 2.0 + +Item { + width: 640 + height: 480 + property bool testRightToLeft: false + property bool testEnabled: false + + Row { + objectName: "row" + layoutDirection: testRightToLeft ? Qt.RightToLeft : Qt.LeftToRight + add: Transition { + enabled: testEnabled ? false : true + NumberAnimation { + properties: "x"; + } + } + move: Transition { + enabled: testEnabled ? false : true + NumberAnimation { + properties: "x"; + } + } + Rectangle { + objectName: "one" + color: "red" + x: -100; + width: 50 + height: 50 + } + Rectangle { + objectName: "two" + color: "blue" + x: -100; + visible: false + width: 50 + height: 50 + } + Rectangle { + objectName: "three" + x: -100; + color: "green" + width: 50 + height: 50 + } + } +} diff --git a/tests/auto/quick/qquickpositioners/data/horizontal-spacing.qml b/tests/auto/quick/qquickpositioners/data/horizontal-spacing.qml new file mode 100644 index 0000000000..c6ff75ac6b --- /dev/null +++ b/tests/auto/quick/qquickpositioners/data/horizontal-spacing.qml @@ -0,0 +1,31 @@ +import QtQuick 2.0 + +Item { + width: 640 + height: 480 + property bool testRightToLeft: false + + Row { + objectName: "row" + spacing: 10 + layoutDirection: testRightToLeft ? Qt.RightToLeft : Qt.LeftToRight + Rectangle { + objectName: "one" + color: "red" + width: 50 + height: 50 + } + Rectangle { + objectName: "two" + color: "red" + width: 20 + height: 10 + } + Rectangle { + objectName: "three" + color: "red" + width: 40 + height: 20 + } + } +} diff --git a/tests/auto/quick/qquickpositioners/data/horizontal.qml b/tests/auto/quick/qquickpositioners/data/horizontal.qml new file mode 100644 index 0000000000..235ee78c9b --- /dev/null +++ b/tests/auto/quick/qquickpositioners/data/horizontal.qml @@ -0,0 +1,29 @@ +import QtQuick 2.0 + +Item { + width: 640 + height: 480 + property bool testRightToLeft: false + Row { + objectName: "row" + layoutDirection: testRightToLeft ? Qt.RightToLeft : Qt.LeftToRight + Rectangle { + objectName: "one" + color: "red" + width: 50 + height: 50 + } + Rectangle { + objectName: "two" + color: "red" + width: 20 + height: 10 + } + Rectangle { + objectName: "three" + color: "red" + width: 40 + height: 20 + } + } +} diff --git a/tests/auto/quick/qquickpositioners/data/propertychangestest.qml b/tests/auto/quick/qquickpositioners/data/propertychangestest.qml new file mode 100644 index 0000000000..c9fd62b012 --- /dev/null +++ b/tests/auto/quick/qquickpositioners/data/propertychangestest.qml @@ -0,0 +1,39 @@ +import QtQuick 2.0 + +Grid { + id: myGrid + + width: 270 + height: 270 + x: 3 + y: 3 + columns: 4 + spacing: 3 + + add: columnTransition + move: columnTransition + + Repeater { + model: 20 + Rectangle { color: "black"; width: 50; height: 50 } + } + + data: [ + Transition { + id: rowTransition + objectName: "rowTransition" + NumberAnimation { + properties: "x,y"; + easing.type: "OutInCubic" + } + }, + Transition { + id: columnTransition + objectName: "columnTransition" + NumberAnimation { + properties: "x,y"; + easing.type: "OutInCubic" + } + } + ] +} diff --git a/tests/auto/quick/qquickpositioners/data/rectangleComponent.qml b/tests/auto/quick/qquickpositioners/data/rectangleComponent.qml new file mode 100644 index 0000000000..de1bb99593 --- /dev/null +++ b/tests/auto/quick/qquickpositioners/data/rectangleComponent.qml @@ -0,0 +1,11 @@ +import QtQuick 2.0; + +Rectangle { + objectName: "rect2" + color: "blue" + width: 100 + height: 100 + property int index: Positioner.index + property bool firstItem: Positioner.isFirstItem + property bool lastItem: Positioner.isLastItem +} diff --git a/tests/auto/quick/qquickpositioners/data/repeatertest.qml b/tests/auto/quick/qquickpositioners/data/repeatertest.qml new file mode 100644 index 0000000000..d90e1cf160 --- /dev/null +++ b/tests/auto/quick/qquickpositioners/data/repeatertest.qml @@ -0,0 +1,38 @@ +import QtQuick 2.0 + +Item { + width: 640 + height: 480 + Row { + Repeater{ model: 3; + delegate: Component { + Rectangle { + color: "red" + width: 50 + height: 50 + z: {if(index == 0){2;}else if(index == 1){1;} else{3;}} + objectName: {if(index == 0){"one";}else if(index == 1){"two";} else{"three";}} + } + } + } + } + + //This crashed once (QTBUG-16959) because the repeater ended up on the end of the list + //If this grid just instantiates without crashing, then it has not regressed. + Grid { + id: grid + rows: 2 + flow: Grid.TopToBottom + + Repeater { + model: 13 + Rectangle { + color: "goldenrod" + width: 100 + height: 100 + radius: 10 + border.width: 1 + } + } + } +} diff --git a/tests/auto/quick/qquickpositioners/data/vertical-animated.qml b/tests/auto/quick/qquickpositioners/data/vertical-animated.qml new file mode 100644 index 0000000000..ecf593cd70 --- /dev/null +++ b/tests/auto/quick/qquickpositioners/data/vertical-animated.qml @@ -0,0 +1,41 @@ +import QtQuick 2.0 + +Item { + width: 640 + height: 480 + Column { + objectName: "column" + add: Transition { + NumberAnimation { + properties: "y"; + } + } + move: Transition { + NumberAnimation { + properties: "y"; + } + } + Rectangle { + objectName: "one" + color: "red" + y: -100 + width: 50 + height: 50 + } + Rectangle { + objectName: "two" + color: "blue" + y: -100 + visible: false + width: 50 + height: 50 + } + Rectangle { + objectName: "three" + color: "red" + y: -100 + width: 50 + height: 50 + } + } +} diff --git a/tests/auto/quick/qquickpositioners/data/vertical-spacing.qml b/tests/auto/quick/qquickpositioners/data/vertical-spacing.qml new file mode 100644 index 0000000000..7087961651 --- /dev/null +++ b/tests/auto/quick/qquickpositioners/data/vertical-spacing.qml @@ -0,0 +1,28 @@ +import QtQuick 2.0 + +Item { + width: 640 + height: 480 + Column { + objectName: "column" + spacing: 10 + Rectangle { + objectName: "one" + color: "red" + width: 50 + height: 50 + } + Rectangle { + objectName: "two" + color: "red" + width: 20 + height: 10 + } + Rectangle { + objectName: "three" + color: "red" + width: 40 + height: 20 + } + } +} diff --git a/tests/auto/quick/qquickpositioners/data/vertical.qml b/tests/auto/quick/qquickpositioners/data/vertical.qml new file mode 100644 index 0000000000..0c3a81f008 --- /dev/null +++ b/tests/auto/quick/qquickpositioners/data/vertical.qml @@ -0,0 +1,27 @@ +import QtQuick 2.0 + +Item { + width: 640 + height: 480 + Column { + objectName: "column" + Rectangle { + objectName: "one" + color: "red" + width: 50 + height: 50 + } + Rectangle { + objectName: "two" + color: "red" + width: 20 + height: 10 + } + Rectangle { + objectName: "three" + color: "red" + width: 40 + height: 20 + } + } +} diff --git a/tests/auto/quick/qquickpositioners/qquickpositioners.pro b/tests/auto/quick/qquickpositioners/qquickpositioners.pro new file mode 100644 index 0000000000..56fe465901 --- /dev/null +++ b/tests/auto/quick/qquickpositioners/qquickpositioners.pro @@ -0,0 +1,14 @@ +CONFIG += testcase +TARGET = tst_qquickpositioners +SOURCES += tst_qquickpositioners.cpp + +include (../../shared/util.pri) + +macx:CONFIG -= app_bundle + +testDataFiles.files = data +testDataFiles.path = . +DEPLOYMENT += testDataFiles + +CONFIG += parallel_test +QT += core-private gui-private v8-private qml-private quick-private opengl-private testlib diff --git a/tests/auto/quick/qquickpositioners/tst_qquickpositioners.cpp b/tests/auto/quick/qquickpositioners/tst_qquickpositioners.cpp new file mode 100644 index 0000000000..ecc4c80b2a --- /dev/null +++ b/tests/auto/quick/qquickpositioners/tst_qquickpositioners.cpp @@ -0,0 +1,1472 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "../../shared/util.h" + +class tst_qquickpositioners : public QQmlDataTest +{ + Q_OBJECT +public: + tst_qquickpositioners(); + +private slots: + void test_horizontal(); + void test_horizontal_rtl(); + void test_horizontal_spacing(); + void test_horizontal_spacing_rightToLeft(); + void test_horizontal_animated(); + void test_horizontal_animated_rightToLeft(); + void test_horizontal_animated_disabled(); + void test_vertical(); + void test_vertical_spacing(); + void test_vertical_animated(); + void test_grid(); + void test_grid_topToBottom(); + void test_grid_rightToLeft(); + void test_grid_spacing(); + void test_grid_row_column_spacing(); + void test_grid_animated(); + void test_grid_animated_rightToLeft(); + void test_grid_zero_columns(); + void test_propertychanges(); + void test_repeater(); + void test_flow(); + void test_flow_rightToLeft(); + void test_flow_topToBottom(); + void test_flow_resize(); + void test_flow_resize_rightToLeft(); + void test_flow_implicit_resize(); + void test_conflictinganchors(); + void test_mirroring(); + void test_allInvisible(); + void test_attachedproperties(); + void test_attachedproperties_data(); + void test_attachedproperties_dynamic(); + +private: + QQuickView *createView(const QString &filename, bool wait=true); +}; + +tst_qquickpositioners::tst_qquickpositioners() +{ +} + +void tst_qquickpositioners::test_horizontal() +{ + QQuickView *canvas = createView(testFile("horizontal.qml")); + + canvas->rootObject()->setProperty("testRightToLeft", false); + + QQuickRectangle *one = canvas->rootObject()->findChild("one"); + QVERIFY(one != 0); + + QQuickRectangle *two = canvas->rootObject()->findChild("two"); + QVERIFY(two != 0); + + QQuickRectangle *three = canvas->rootObject()->findChild("three"); + QVERIFY(three != 0); + + QCOMPARE(one->x(), 0.0); + QCOMPARE(one->y(), 0.0); + QCOMPARE(two->x(), 50.0); + QCOMPARE(two->y(), 0.0); + QCOMPARE(three->x(), 70.0); + QCOMPARE(three->y(), 0.0); + + QQuickItem *row = canvas->rootObject()->findChild("row"); + QCOMPARE(row->width(), 110.0); + QCOMPARE(row->height(), 50.0); + + delete canvas; +} + +void tst_qquickpositioners::test_horizontal_rtl() +{ + QQuickView *canvas = createView(testFile("horizontal.qml")); + + canvas->rootObject()->setProperty("testRightToLeft", true); + + QQuickRectangle *one = canvas->rootObject()->findChild("one"); + QVERIFY(one != 0); + + QQuickRectangle *two = canvas->rootObject()->findChild("two"); + QVERIFY(two != 0); + + QQuickRectangle *three = canvas->rootObject()->findChild("three"); + QVERIFY(three != 0); + + QCOMPARE(one->x(), 60.0); + QCOMPARE(one->y(), 0.0); + QCOMPARE(two->x(), 40.0); + QCOMPARE(two->y(), 0.0); + QCOMPARE(three->x(), 0.0); + QCOMPARE(three->y(), 0.0); + + QQuickItem *row = canvas->rootObject()->findChild("row"); + QCOMPARE(row->width(), 110.0); + QCOMPARE(row->height(), 50.0); + + // Change the width of the row and check that items stay to the right + row->setWidth(200); + QTRY_COMPARE(one->x(), 150.0); + QCOMPARE(one->y(), 0.0); + QCOMPARE(two->x(), 130.0); + QCOMPARE(two->y(), 0.0); + QCOMPARE(three->x(), 90.0); + QCOMPARE(three->y(), 0.0); + + delete canvas; +} + +void tst_qquickpositioners::test_horizontal_spacing() +{ + QQuickView *canvas = createView(testFile("horizontal-spacing.qml")); + + canvas->rootObject()->setProperty("testRightToLeft", false); + + QQuickRectangle *one = canvas->rootObject()->findChild("one"); + QVERIFY(one != 0); + + QQuickRectangle *two = canvas->rootObject()->findChild("two"); + QVERIFY(two != 0); + + QQuickRectangle *three = canvas->rootObject()->findChild("three"); + QVERIFY(three != 0); + + QCOMPARE(one->x(), 0.0); + QCOMPARE(one->y(), 0.0); + QCOMPARE(two->x(), 60.0); + QCOMPARE(two->y(), 0.0); + QCOMPARE(three->x(), 90.0); + QCOMPARE(three->y(), 0.0); + + QQuickItem *row = canvas->rootObject()->findChild("row"); + QCOMPARE(row->width(), 130.0); + QCOMPARE(row->height(), 50.0); + + delete canvas; +} + +void tst_qquickpositioners::test_horizontal_spacing_rightToLeft() +{ + QQuickView *canvas = createView(testFile("horizontal-spacing.qml")); + + canvas->rootObject()->setProperty("testRightToLeft", true); + + QQuickRectangle *one = canvas->rootObject()->findChild("one"); + QVERIFY(one != 0); + + QQuickRectangle *two = canvas->rootObject()->findChild("two"); + QVERIFY(two != 0); + + QQuickRectangle *three = canvas->rootObject()->findChild("three"); + QVERIFY(three != 0); + + QCOMPARE(one->x(), 80.0); + QCOMPARE(one->y(), 0.0); + QCOMPARE(two->x(), 50.0); + QCOMPARE(two->y(), 0.0); + QCOMPARE(three->x(), 00.0); + QCOMPARE(three->y(), 0.0); + + QQuickItem *row = canvas->rootObject()->findChild("row"); + QCOMPARE(row->width(), 130.0); + QCOMPARE(row->height(), 50.0); + + delete canvas; +} + +void tst_qquickpositioners::test_horizontal_animated() +{ + QQuickView *canvas = createView(testFile("horizontal-animated.qml"), false); + + canvas->rootObject()->setProperty("testRightToLeft", false); + + QQuickRectangle *one = canvas->rootObject()->findChild("one"); + QVERIFY(one != 0); + + QQuickRectangle *two = canvas->rootObject()->findChild("two"); + QVERIFY(two != 0); + + QQuickRectangle *three = canvas->rootObject()->findChild("three"); + QVERIFY(three != 0); + + //Note that they animate in + QCOMPARE(one->x(), -100.0); + QCOMPARE(two->x(), -100.0); + QCOMPARE(three->x(), -100.0); + + QTest::qWaitForWindowShown(canvas); //It may not relayout until the next frame, so it needs to be drawn + + QQuickItem *row = canvas->rootObject()->findChild("row"); + QVERIFY(row); + QCOMPARE(row->width(), 100.0); + QCOMPARE(row->height(), 50.0); + + //QTRY_COMPARE used instead of waiting for the expected time of animation completion + //Note that this means the duration of the animation is NOT tested + + QTRY_COMPARE(one->x(), 0.0); + QTRY_COMPARE(one->y(), 0.0); + QTRY_COMPARE(two->isVisible(), false); + QTRY_COMPARE(two->x(), -100.0);//Not 'in' yet + QTRY_COMPARE(two->y(), 0.0); + QTRY_COMPARE(three->x(), 50.0); + QTRY_COMPARE(three->y(), 0.0); + + //Add 'two' + two->setVisible(true); + QTRY_COMPARE(two->isVisible(), true); + QTRY_COMPARE(row->width(), 150.0); + QTRY_COMPARE(row->height(), 50.0); + + QTest::qWait(0);//Let the animation start + QVERIFY(two->x() >= -100.0 && two->x() < 50.0); + QVERIFY(three->x() >= 50.0 && three->x() < 100.0); + + QTRY_COMPARE(two->x(), 50.0); + QTRY_COMPARE(three->x(), 100.0); + + delete canvas; +} + +void tst_qquickpositioners::test_horizontal_animated_rightToLeft() +{ + QQuickView *canvas = createView(testFile("horizontal-animated.qml"), false); + + canvas->rootObject()->setProperty("testRightToLeft", true); + + QQuickRectangle *one = canvas->rootObject()->findChild("one"); + QVERIFY(one != 0); + + QQuickRectangle *two = canvas->rootObject()->findChild("two"); + QVERIFY(two != 0); + + QQuickRectangle *three = canvas->rootObject()->findChild("three"); + QVERIFY(three != 0); + + //Note that they animate in + QCOMPARE(one->x(), -100.0); + QCOMPARE(two->x(), -100.0); + QCOMPARE(three->x(), -100.0); + + QTest::qWaitForWindowShown(canvas); //It may not relayout until the next frame, so it needs to be drawn + + QQuickItem *row = canvas->rootObject()->findChild("row"); + QVERIFY(row); + QCOMPARE(row->width(), 100.0); + QCOMPARE(row->height(), 50.0); + + //QTRY_COMPARE used instead of waiting for the expected time of animation completion + //Note that this means the duration of the animation is NOT tested + + QTRY_COMPARE(one->x(), 50.0); + QTRY_COMPARE(one->y(), 0.0); + QTRY_COMPARE(two->isVisible(), false); + QTRY_COMPARE(two->x(), -100.0);//Not 'in' yet + QTRY_COMPARE(two->y(), 0.0); + QTRY_COMPARE(three->x(), 0.0); + QTRY_COMPARE(three->y(), 0.0); + + //Add 'two' + two->setVisible(true); + QTRY_COMPARE(two->isVisible(), true); + + // New size should propagate after visible change + QTRY_COMPARE(row->width(), 150.0); + QTRY_COMPARE(row->height(), 50.0); + + QTest::qWait(0);//Let the animation start + QVERIFY(one->x() >= 50.0 && one->x() < 100); + QVERIFY(two->x() >= -100.0 && two->x() < 50.0); + + QTRY_COMPARE(one->x(), 100.0); + QTRY_COMPARE(two->x(), 50.0); + + delete canvas; +} + +void tst_qquickpositioners::test_horizontal_animated_disabled() +{ + QQuickView *canvas = createView(testFile("horizontal-animated-disabled.qml")); + + QQuickRectangle *one = canvas->rootObject()->findChild("one"); + QVERIFY(one != 0); + + QQuickRectangle *two = canvas->rootObject()->findChild("two"); + QVERIFY(two != 0); + + QQuickRectangle *three = canvas->rootObject()->findChild("three"); + QVERIFY(three != 0); + + QQuickItem *row = canvas->rootObject()->findChild("row"); + QVERIFY(row); + + qApp->processEvents(); + + QCOMPARE(one->x(), 0.0); + QCOMPARE(one->y(), 0.0); + QCOMPARE(two->isVisible(), false); + QCOMPARE(two->x(), -100.0);//Not 'in' yet + QCOMPARE(two->y(), 0.0); + QCOMPARE(three->x(), 50.0); + QCOMPARE(three->y(), 0.0); + + //Add 'two' + two->setVisible(true); + QCOMPARE(two->isVisible(), true); + QTRY_COMPARE(row->width(), 150.0); + QTRY_COMPARE(row->height(), 50.0); + + QTRY_COMPARE(two->x(), 50.0); + QTRY_COMPARE(three->x(), 100.0); + + delete canvas; +} + +void tst_qquickpositioners::test_vertical() +{ + QQuickView *canvas = createView(testFile("vertical.qml")); + + QQuickRectangle *one = canvas->rootObject()->findChild("one"); + QVERIFY(one != 0); + + QQuickRectangle *two = canvas->rootObject()->findChild("two"); + QVERIFY(two != 0); + + QQuickRectangle *three = canvas->rootObject()->findChild("three"); + QVERIFY(three != 0); + + QCOMPARE(one->x(), 0.0); + QCOMPARE(one->y(), 0.0); + QCOMPARE(two->x(), 0.0); + QCOMPARE(two->y(), 50.0); + QCOMPARE(three->x(), 0.0); + QCOMPARE(three->y(), 60.0); + + QQuickItem *column = canvas->rootObject()->findChild("column"); + QVERIFY(column); + QCOMPARE(column->height(), 80.0); + QCOMPARE(column->width(), 50.0); + + delete canvas; +} + +void tst_qquickpositioners::test_vertical_spacing() +{ + QQuickView *canvas = createView(testFile("vertical-spacing.qml")); + + QQuickRectangle *one = canvas->rootObject()->findChild("one"); + QVERIFY(one != 0); + + QQuickRectangle *two = canvas->rootObject()->findChild("two"); + QVERIFY(two != 0); + + QQuickRectangle *three = canvas->rootObject()->findChild("three"); + QVERIFY(three != 0); + + QCOMPARE(one->x(), 0.0); + QCOMPARE(one->y(), 0.0); + QCOMPARE(two->x(), 0.0); + QCOMPARE(two->y(), 60.0); + QCOMPARE(three->x(), 0.0); + QCOMPARE(three->y(), 80.0); + + QQuickItem *column = canvas->rootObject()->findChild("column"); + QCOMPARE(column->height(), 100.0); + QCOMPARE(column->width(), 50.0); + + delete canvas; +} + +void tst_qquickpositioners::test_vertical_animated() +{ + QQuickView *canvas = createView(testFile("vertical-animated.qml"), false); + + //Note that they animate in + QQuickRectangle *one = canvas->rootObject()->findChild("one"); + QVERIFY(one != 0); + QCOMPARE(one->y(), -100.0); + + QQuickRectangle *two = canvas->rootObject()->findChild("two"); + QVERIFY(two != 0); + QCOMPARE(two->y(), -100.0); + + QQuickRectangle *three = canvas->rootObject()->findChild("three"); + QVERIFY(three != 0); + QCOMPARE(three->y(), -100.0); + + QTest::qWaitForWindowShown(canvas); //It may not relayout until the next frame, so it needs to be drawn + + QQuickItem *column = canvas->rootObject()->findChild("column"); + QVERIFY(column); + QCOMPARE(column->height(), 100.0); + QCOMPARE(column->width(), 50.0); + + //QTRY_COMPARE used instead of waiting for the expected time of animation completion + //Note that this means the duration of the animation is NOT tested + + QTRY_COMPARE(one->y(), 0.0); + QTRY_COMPARE(one->x(), 0.0); + QTRY_COMPARE(two->isVisible(), false); + QTRY_COMPARE(two->y(), -100.0);//Not 'in' yet + QTRY_COMPARE(two->x(), 0.0); + QTRY_COMPARE(three->y(), 50.0); + QTRY_COMPARE(three->x(), 0.0); + + //Add 'two' + two->setVisible(true); + QTRY_COMPARE(two->isVisible(), true); + QTRY_COMPARE(column->height(), 150.0); + QTRY_COMPARE(column->width(), 50.0); + QTest::qWait(0);//Let the animation start + QVERIFY(two->y() >= -100.0 && two->y() < 50.0); + QVERIFY(three->y() >= 50.0 && three->y() < 100.0); + + QTRY_COMPARE(two->y(), 50.0); + QTRY_COMPARE(three->y(), 100.0); + + delete canvas; +} + +void tst_qquickpositioners::test_grid() +{ + QQuickView *canvas = createView(testFile("gridtest.qml")); + + QQuickRectangle *one = canvas->rootObject()->findChild("one"); + QVERIFY(one != 0); + QQuickRectangle *two = canvas->rootObject()->findChild("two"); + QVERIFY(two != 0); + QQuickRectangle *three = canvas->rootObject()->findChild("three"); + QVERIFY(three != 0); + QQuickRectangle *four = canvas->rootObject()->findChild("four"); + QVERIFY(four != 0); + QQuickRectangle *five = canvas->rootObject()->findChild("five"); + QVERIFY(five != 0); + + QCOMPARE(one->x(), 0.0); + QCOMPARE(one->y(), 0.0); + QCOMPARE(two->x(), 50.0); + QCOMPARE(two->y(), 0.0); + QCOMPARE(three->x(), 70.0); + QCOMPARE(three->y(), 0.0); + QCOMPARE(four->x(), 0.0); + QCOMPARE(four->y(), 50.0); + QCOMPARE(five->x(), 50.0); + QCOMPARE(five->y(), 50.0); + + QQuickGrid *grid = canvas->rootObject()->findChild("grid"); + QCOMPARE(grid->flow(), QQuickGrid::LeftToRight); + QCOMPARE(grid->width(), 100.0); + QCOMPARE(grid->height(), 100.0); + + delete canvas; +} + +void tst_qquickpositioners::test_grid_topToBottom() +{ + QQuickView *canvas = createView(testFile("grid-toptobottom.qml")); + + QQuickRectangle *one = canvas->rootObject()->findChild("one"); + QVERIFY(one != 0); + QQuickRectangle *two = canvas->rootObject()->findChild("two"); + QVERIFY(two != 0); + QQuickRectangle *three = canvas->rootObject()->findChild("three"); + QVERIFY(three != 0); + QQuickRectangle *four = canvas->rootObject()->findChild("four"); + QVERIFY(four != 0); + QQuickRectangle *five = canvas->rootObject()->findChild("five"); + QVERIFY(five != 0); + + QCOMPARE(one->x(), 0.0); + QCOMPARE(one->y(), 0.0); + QCOMPARE(two->x(), 0.0); + QCOMPARE(two->y(), 50.0); + QCOMPARE(three->x(), 0.0); + QCOMPARE(three->y(), 100.0); + QCOMPARE(four->x(), 50.0); + QCOMPARE(four->y(), 0.0); + QCOMPARE(five->x(), 50.0); + QCOMPARE(five->y(), 50.0); + + QQuickGrid *grid = canvas->rootObject()->findChild("grid"); + QCOMPARE(grid->flow(), QQuickGrid::TopToBottom); + QCOMPARE(grid->width(), 100.0); + QCOMPARE(grid->height(), 120.0); + + delete canvas; +} + +void tst_qquickpositioners::test_grid_rightToLeft() +{ + QQuickView *canvas = createView(testFile("gridtest.qml")); + + canvas->rootObject()->setProperty("testRightToLeft", true); + + QQuickRectangle *one = canvas->rootObject()->findChild("one"); + QVERIFY(one != 0); + QQuickRectangle *two = canvas->rootObject()->findChild("two"); + QVERIFY(two != 0); + QQuickRectangle *three = canvas->rootObject()->findChild("three"); + QVERIFY(three != 0); + QQuickRectangle *four = canvas->rootObject()->findChild("four"); + QVERIFY(four != 0); + QQuickRectangle *five = canvas->rootObject()->findChild("five"); + QVERIFY(five != 0); + + QCOMPARE(one->x(), 50.0); + QCOMPARE(one->y(), 0.0); + QCOMPARE(two->x(), 30.0); + QCOMPARE(two->y(), 0.0); + QCOMPARE(three->x(), 0.0); + QCOMPARE(three->y(), 0.0); + QCOMPARE(four->x(), 50.0); + QCOMPARE(four->y(), 50.0); + QCOMPARE(five->x(), 40.0); + QCOMPARE(five->y(), 50.0); + + QQuickGrid *grid = canvas->rootObject()->findChild("grid"); + QCOMPARE(grid->layoutDirection(), Qt::RightToLeft); + QCOMPARE(grid->width(), 100.0); + QCOMPARE(grid->height(), 100.0); + + // Change the width of the grid and check that items stay to the right + grid->setWidth(200); + QTRY_COMPARE(one->x(), 150.0); + QCOMPARE(one->y(), 0.0); + QCOMPARE(two->x(), 130.0); + QCOMPARE(two->y(), 0.0); + QCOMPARE(three->x(), 100.0); + QCOMPARE(three->y(), 0.0); + QCOMPARE(four->x(), 150.0); + QCOMPARE(four->y(), 50.0); + QCOMPARE(five->x(), 140.0); + QCOMPARE(five->y(), 50.0); + + delete canvas; +} + +void tst_qquickpositioners::test_grid_spacing() +{ + QQuickView *canvas = createView(testFile("grid-spacing.qml")); + + QQuickRectangle *one = canvas->rootObject()->findChild("one"); + QVERIFY(one != 0); + QQuickRectangle *two = canvas->rootObject()->findChild("two"); + QVERIFY(two != 0); + QQuickRectangle *three = canvas->rootObject()->findChild("three"); + QVERIFY(three != 0); + QQuickRectangle *four = canvas->rootObject()->findChild("four"); + QVERIFY(four != 0); + QQuickRectangle *five = canvas->rootObject()->findChild("five"); + QVERIFY(five != 0); + + QCOMPARE(one->x(), 0.0); + QCOMPARE(one->y(), 0.0); + QCOMPARE(two->x(), 54.0); + QCOMPARE(two->y(), 0.0); + QCOMPARE(three->x(), 78.0); + QCOMPARE(three->y(), 0.0); + QCOMPARE(four->x(), 0.0); + QCOMPARE(four->y(), 54.0); + QCOMPARE(five->x(), 54.0); + QCOMPARE(five->y(), 54.0); + + QQuickItem *grid = canvas->rootObject()->findChild("grid"); + QCOMPARE(grid->width(), 128.0); + QCOMPARE(grid->height(), 104.0); + + delete canvas; +} + +void tst_qquickpositioners::test_grid_row_column_spacing() +{ + QQuickView *canvas = createView(testFile("grid-row-column-spacing.qml")); + + QQuickRectangle *one = canvas->rootObject()->findChild("one"); + QVERIFY(one != 0); + QQuickRectangle *two = canvas->rootObject()->findChild("two"); + QVERIFY(two != 0); + QQuickRectangle *three = canvas->rootObject()->findChild("three"); + QVERIFY(three != 0); + QQuickRectangle *four = canvas->rootObject()->findChild("four"); + QVERIFY(four != 0); + QQuickRectangle *five = canvas->rootObject()->findChild("five"); + QVERIFY(five != 0); + + QCOMPARE(one->x(), 0.0); + QCOMPARE(one->y(), 0.0); + QCOMPARE(two->x(), 61.0); + QCOMPARE(two->y(), 0.0); + QCOMPARE(three->x(), 92.0); + QCOMPARE(three->y(), 0.0); + QCOMPARE(four->x(), 0.0); + QCOMPARE(four->y(), 57.0); + QCOMPARE(five->x(), 61.0); + QCOMPARE(five->y(), 57.0); + + QQuickItem *grid = canvas->rootObject()->findChild("grid"); + QCOMPARE(grid->width(), 142.0); + QCOMPARE(grid->height(), 107.0); + + delete canvas; +} + +void tst_qquickpositioners::test_grid_animated() +{ + QQuickView *canvas = createView(testFile("grid-animated.qml"), false); + + canvas->rootObject()->setProperty("testRightToLeft", false); + + //Note that all animate in + QQuickRectangle *one = canvas->rootObject()->findChild("one"); + QVERIFY(one != 0); + QCOMPARE(one->x(), -100.0); + QCOMPARE(one->y(), -100.0); + + QQuickRectangle *two = canvas->rootObject()->findChild("two"); + QVERIFY(two != 0); + QCOMPARE(two->x(), -100.0); + QCOMPARE(two->y(), -100.0); + + QQuickRectangle *three = canvas->rootObject()->findChild("three"); + QVERIFY(three != 0); + QCOMPARE(three->x(), -100.0); + QCOMPARE(three->y(), -100.0); + + QQuickRectangle *four = canvas->rootObject()->findChild("four"); + QVERIFY(four != 0); + QCOMPARE(four->x(), -100.0); + QCOMPARE(four->y(), -100.0); + + QQuickRectangle *five = canvas->rootObject()->findChild("five"); + QVERIFY(five != 0); + QCOMPARE(five->x(), -100.0); + QCOMPARE(five->y(), -100.0); + + QTest::qWaitForWindowShown(canvas); //It may not relayout until the next frame, so it needs to be drawn + + QQuickItem *grid = canvas->rootObject()->findChild("grid"); + QVERIFY(grid); + QCOMPARE(grid->width(), 150.0); + QCOMPARE(grid->height(), 100.0); + + //QTRY_COMPARE used instead of waiting for the expected time of animation completion + //Note that this means the duration of the animation is NOT tested + + QTRY_COMPARE(one->y(), 0.0); + QTRY_COMPARE(one->x(), 0.0); + QTRY_COMPARE(two->isVisible(), false); + QTRY_COMPARE(two->y(), -100.0); + QTRY_COMPARE(two->x(), -100.0); + QTRY_COMPARE(three->y(), 0.0); + QTRY_COMPARE(three->x(), 50.0); + QTRY_COMPARE(four->y(), 0.0); + QTRY_COMPARE(four->x(), 100.0); + QTRY_COMPARE(five->y(), 50.0); + QTRY_COMPARE(five->x(), 0.0); + + //Add 'two' + two->setVisible(true); + QCOMPARE(two->isVisible(), true); + QCOMPARE(grid->width(), 150.0); + QCOMPARE(grid->height(), 100.0); + QTest::qWait(0);//Let the animation start + QCOMPARE(two->x(), -100.0); + QCOMPARE(two->y(), -100.0); + QCOMPARE(one->x(), 0.0); + QCOMPARE(one->y(), 0.0); + QCOMPARE(three->x(), 50.0); + QCOMPARE(three->y(), 0.0); + QCOMPARE(four->x(), 100.0); + QCOMPARE(four->y(), 0.0); + QCOMPARE(five->x(), 0.0); + QCOMPARE(five->y(), 50.0); + //Let the animation complete + QTRY_COMPARE(two->x(), 50.0); + QTRY_COMPARE(two->y(), 0.0); + QTRY_COMPARE(one->x(), 0.0); + QTRY_COMPARE(one->y(), 0.0); + QTRY_COMPARE(three->x(), 100.0); + QTRY_COMPARE(three->y(), 0.0); + QTRY_COMPARE(four->x(), 0.0); + QTRY_COMPARE(four->y(), 50.0); + QTRY_COMPARE(five->x(), 50.0); + QTRY_COMPARE(five->y(), 50.0); + + delete canvas; +} + +void tst_qquickpositioners::test_grid_animated_rightToLeft() +{ + QQuickView *canvas = createView(testFile("grid-animated.qml"), false); + + canvas->rootObject()->setProperty("testRightToLeft", true); + + //Note that all animate in + QQuickRectangle *one = canvas->rootObject()->findChild("one"); + QVERIFY(one != 0); + QCOMPARE(one->x(), -100.0); + QCOMPARE(one->y(), -100.0); + + QQuickRectangle *two = canvas->rootObject()->findChild("two"); + QVERIFY(two != 0); + QCOMPARE(two->x(), -100.0); + QCOMPARE(two->y(), -100.0); + + QQuickRectangle *three = canvas->rootObject()->findChild("three"); + QVERIFY(three != 0); + QCOMPARE(three->x(), -100.0); + QCOMPARE(three->y(), -100.0); + + QQuickRectangle *four = canvas->rootObject()->findChild("four"); + QVERIFY(four != 0); + QCOMPARE(four->x(), -100.0); + QCOMPARE(four->y(), -100.0); + + QQuickRectangle *five = canvas->rootObject()->findChild("five"); + QVERIFY(five != 0); + QCOMPARE(five->x(), -100.0); + QCOMPARE(five->y(), -100.0); + + QTest::qWaitForWindowShown(canvas); //It may not relayout until the next frame, so it needs to be drawn + + QQuickItem *grid = canvas->rootObject()->findChild("grid"); + QVERIFY(grid); + QCOMPARE(grid->width(), 150.0); + QCOMPARE(grid->height(), 100.0); + + //QTRY_COMPARE used instead of waiting for the expected time of animation completion + //Note that this means the duration of the animation is NOT tested + + QTRY_COMPARE(one->y(), 0.0); + QTRY_COMPARE(one->x(), 100.0); + QTRY_COMPARE(two->isVisible(), false); + QTRY_COMPARE(two->y(), -100.0); + QTRY_COMPARE(two->x(), -100.0); + QTRY_COMPARE(three->y(), 0.0); + QTRY_COMPARE(three->x(), 50.0); + QTRY_COMPARE(four->y(), 0.0); + QTRY_COMPARE(four->x(), 0.0); + QTRY_COMPARE(five->y(), 50.0); + QTRY_COMPARE(five->x(), 100.0); + + //Add 'two' + two->setVisible(true); + QCOMPARE(two->isVisible(), true); + QCOMPARE(grid->width(), 150.0); + QCOMPARE(grid->height(), 100.0); + QTest::qWait(0);//Let the animation start + QCOMPARE(two->x(), -100.0); + QCOMPARE(two->y(), -100.0); + QCOMPARE(one->x(), 100.0); + QCOMPARE(one->y(), 0.0); + QCOMPARE(three->x(), 50.0); + QCOMPARE(three->y(), 0.0); + QCOMPARE(four->x(), 0.0); + QCOMPARE(four->y(), 0.0); + QCOMPARE(five->x(), 100.0); + QCOMPARE(five->y(), 50.0); + //Let the animation complete + QTRY_COMPARE(two->x(), 50.0); + QTRY_COMPARE(two->y(), 0.0); + QTRY_COMPARE(one->x(), 100.0); + QTRY_COMPARE(one->y(), 0.0); + QTRY_COMPARE(three->x(), 0.0); + QTRY_COMPARE(three->y(), 0.0); + QTRY_COMPARE(four->x(), 100.0); + QTRY_COMPARE(four->y(), 50.0); + QTRY_COMPARE(five->x(), 50.0); + QTRY_COMPARE(five->y(), 50.0); + + delete canvas; +} + +void tst_qquickpositioners::test_grid_zero_columns() +{ + QQuickView *canvas = createView(testFile("gridzerocolumns.qml")); + + QQuickRectangle *one = canvas->rootObject()->findChild("one"); + QVERIFY(one != 0); + QQuickRectangle *two = canvas->rootObject()->findChild("two"); + QVERIFY(two != 0); + QQuickRectangle *three = canvas->rootObject()->findChild("three"); + QVERIFY(three != 0); + QQuickRectangle *four = canvas->rootObject()->findChild("four"); + QVERIFY(four != 0); + QQuickRectangle *five = canvas->rootObject()->findChild("five"); + QVERIFY(five != 0); + + QCOMPARE(one->x(), 0.0); + QCOMPARE(one->y(), 0.0); + QCOMPARE(two->x(), 50.0); + QCOMPARE(two->y(), 0.0); + QCOMPARE(three->x(), 70.0); + QCOMPARE(three->y(), 0.0); + QCOMPARE(four->x(), 120.0); + QCOMPARE(four->y(), 0.0); + QCOMPARE(five->x(), 0.0); + QCOMPARE(five->y(), 50.0); + + QQuickItem *grid = canvas->rootObject()->findChild("grid"); + QCOMPARE(grid->width(), 170.0); + QCOMPARE(grid->height(), 60.0); + + delete canvas; +} + +void tst_qquickpositioners::test_propertychanges() +{ + QQuickView *canvas = createView(testFile("propertychangestest.qml")); + + QQuickGrid *grid = qobject_cast(canvas->rootObject()); + QVERIFY(grid != 0); + QQuickTransition *rowTransition = canvas->rootObject()->findChild("rowTransition"); + QQuickTransition *columnTransition = canvas->rootObject()->findChild("columnTransition"); + + QSignalSpy addSpy(grid, SIGNAL(addChanged())); + QSignalSpy moveSpy(grid, SIGNAL(moveChanged())); + QSignalSpy columnsSpy(grid, SIGNAL(columnsChanged())); + QSignalSpy rowsSpy(grid, SIGNAL(rowsChanged())); + + QVERIFY(grid); + QVERIFY(rowTransition); + QVERIFY(columnTransition); + QCOMPARE(grid->add(), columnTransition); + QCOMPARE(grid->move(), columnTransition); + QCOMPARE(grid->columns(), 4); + QCOMPARE(grid->rows(), -1); + + grid->setAdd(rowTransition); + grid->setMove(rowTransition); + QCOMPARE(grid->add(), rowTransition); + QCOMPARE(grid->move(), rowTransition); + QCOMPARE(addSpy.count(),1); + QCOMPARE(moveSpy.count(),1); + + grid->setAdd(rowTransition); + grid->setMove(rowTransition); + QCOMPARE(addSpy.count(),1); + QCOMPARE(moveSpy.count(),1); + + grid->setAdd(0); + grid->setMove(0); + QCOMPARE(addSpy.count(),2); + QCOMPARE(moveSpy.count(),2); + + grid->setColumns(-1); + grid->setRows(3); + QCOMPARE(grid->columns(), -1); + QCOMPARE(grid->rows(), 3); + QCOMPARE(columnsSpy.count(),1); + QCOMPARE(rowsSpy.count(),1); + + grid->setColumns(-1); + grid->setRows(3); + QCOMPARE(columnsSpy.count(),1); + QCOMPARE(rowsSpy.count(),1); + + grid->setColumns(2); + grid->setRows(2); + QCOMPARE(columnsSpy.count(),2); + QCOMPARE(rowsSpy.count(),2); + + delete canvas; +} + +void tst_qquickpositioners::test_repeater() +{ + QQuickView *canvas = createView(testFile("repeatertest.qml")); + + QQuickRectangle *one = canvas->rootObject()->findChild("one"); + QVERIFY(one != 0); + + QQuickRectangle *two = canvas->rootObject()->findChild("two"); + QVERIFY(two != 0); + + QQuickRectangle *three = canvas->rootObject()->findChild("three"); + QVERIFY(three != 0); + + QCOMPARE(one->x(), 0.0); + QCOMPARE(one->y(), 0.0); + QCOMPARE(two->x(), 50.0); + QCOMPARE(two->y(), 0.0); + QCOMPARE(three->x(), 100.0); + QCOMPARE(three->y(), 0.0); + + delete canvas; +} + +void tst_qquickpositioners::test_flow() +{ + QQuickView *canvas = createView(testFile("flowtest.qml")); + + canvas->rootObject()->setProperty("testRightToLeft", false); + + QQuickRectangle *one = canvas->rootObject()->findChild("one"); + QVERIFY(one != 0); + QQuickRectangle *two = canvas->rootObject()->findChild("two"); + QVERIFY(two != 0); + QQuickRectangle *three = canvas->rootObject()->findChild("three"); + QVERIFY(three != 0); + QQuickRectangle *four = canvas->rootObject()->findChild("four"); + QVERIFY(four != 0); + QQuickRectangle *five = canvas->rootObject()->findChild("five"); + QVERIFY(five != 0); + + QCOMPARE(one->x(), 0.0); + QCOMPARE(one->y(), 0.0); + QCOMPARE(two->x(), 50.0); + QCOMPARE(two->y(), 0.0); + QCOMPARE(three->x(), 0.0); + QCOMPARE(three->y(), 50.0); + QCOMPARE(four->x(), 0.0); + QCOMPARE(four->y(), 70.0); + QCOMPARE(five->x(), 50.0); + QCOMPARE(five->y(), 70.0); + + QQuickItem *flow = canvas->rootObject()->findChild("flow"); + QVERIFY(flow); + QCOMPARE(flow->width(), 90.0); + QCOMPARE(flow->height(), 120.0); + + delete canvas; +} + +void tst_qquickpositioners::test_flow_rightToLeft() +{ + QQuickView *canvas = createView(testFile("flowtest.qml")); + + canvas->rootObject()->setProperty("testRightToLeft", true); + + QQuickRectangle *one = canvas->rootObject()->findChild("one"); + QVERIFY(one != 0); + QQuickRectangle *two = canvas->rootObject()->findChild("two"); + QVERIFY(two != 0); + QQuickRectangle *three = canvas->rootObject()->findChild("three"); + QVERIFY(three != 0); + QQuickRectangle *four = canvas->rootObject()->findChild("four"); + QVERIFY(four != 0); + QQuickRectangle *five = canvas->rootObject()->findChild("five"); + QVERIFY(five != 0); + + QCOMPARE(one->x(), 40.0); + QCOMPARE(one->y(), 0.0); + QCOMPARE(two->x(), 20.0); + QCOMPARE(two->y(), 0.0); + QCOMPARE(three->x(), 40.0); + QCOMPARE(three->y(), 50.0); + QCOMPARE(four->x(), 40.0); + QCOMPARE(four->y(), 70.0); + QCOMPARE(five->x(), 30.0); + QCOMPARE(five->y(), 70.0); + + QQuickItem *flow = canvas->rootObject()->findChild("flow"); + QVERIFY(flow); + QCOMPARE(flow->width(), 90.0); + QCOMPARE(flow->height(), 120.0); + + delete canvas; +} + +void tst_qquickpositioners::test_flow_topToBottom() +{ + QQuickView *canvas = createView(testFile("flowtest-toptobottom.qml")); + + canvas->rootObject()->setProperty("testRightToLeft", false); + + QQuickRectangle *one = canvas->rootObject()->findChild("one"); + QVERIFY(one != 0); + QQuickRectangle *two = canvas->rootObject()->findChild("two"); + QVERIFY(two != 0); + QQuickRectangle *three = canvas->rootObject()->findChild("three"); + QVERIFY(three != 0); + QQuickRectangle *four = canvas->rootObject()->findChild("four"); + QVERIFY(four != 0); + QQuickRectangle *five = canvas->rootObject()->findChild("five"); + QVERIFY(five != 0); + + QCOMPARE(one->x(), 0.0); + QCOMPARE(one->y(), 0.0); + QCOMPARE(two->x(), 50.0); + QCOMPARE(two->y(), 0.0); + QCOMPARE(three->x(), 50.0); + QCOMPARE(three->y(), 50.0); + QCOMPARE(four->x(), 100.0); + QCOMPARE(four->y(), 00.0); + QCOMPARE(five->x(), 100.0); + QCOMPARE(five->y(), 50.0); + + QQuickItem *flow = canvas->rootObject()->findChild("flow"); + QVERIFY(flow); + QCOMPARE(flow->height(), 90.0); + QCOMPARE(flow->width(), 150.0); + + canvas->rootObject()->setProperty("testRightToLeft", true); + + QVERIFY(flow); + QCOMPARE(flow->height(), 90.0); + QCOMPARE(flow->width(), 150.0); + + QCOMPARE(one->x(), 100.0); + QCOMPARE(one->y(), 0.0); + QCOMPARE(two->x(), 80.0); + QCOMPARE(two->y(), 0.0); + QCOMPARE(three->x(), 50.0); + QCOMPARE(three->y(), 50.0); + QCOMPARE(four->x(), 0.0); + QCOMPARE(four->y(), 0.0); + QCOMPARE(five->x(), 40.0); + QCOMPARE(five->y(), 50.0); + + delete canvas; +} + +void tst_qquickpositioners::test_flow_resize() +{ + QQuickView *canvas = createView(testFile("flowtest.qml")); + + QQuickItem *root = qobject_cast(canvas->rootObject()); + QVERIFY(root); + root->setWidth(125); + root->setProperty("testRightToLeft", false); + + QQuickRectangle *one = canvas->rootObject()->findChild("one"); + QVERIFY(one != 0); + QQuickRectangle *two = canvas->rootObject()->findChild("two"); + QVERIFY(two != 0); + QQuickRectangle *three = canvas->rootObject()->findChild("three"); + QVERIFY(three != 0); + QQuickRectangle *four = canvas->rootObject()->findChild("four"); + QVERIFY(four != 0); + QQuickRectangle *five = canvas->rootObject()->findChild("five"); + QVERIFY(five != 0); + + QTRY_COMPARE(one->x(), 0.0); + QTRY_COMPARE(one->y(), 0.0); + QTRY_COMPARE(two->x(), 50.0); + QTRY_COMPARE(two->y(), 0.0); + QTRY_COMPARE(three->x(), 70.0); + QTRY_COMPARE(three->y(), 0.0); + QTRY_COMPARE(four->x(), 0.0); + QTRY_COMPARE(four->y(), 50.0); + QTRY_COMPARE(five->x(), 50.0); + QTRY_COMPARE(five->y(), 50.0); + + delete canvas; +} + +void tst_qquickpositioners::test_flow_resize_rightToLeft() +{ + QQuickView *canvas = createView(testFile("flowtest.qml")); + + QQuickItem *root = qobject_cast(canvas->rootObject()); + QVERIFY(root); + root->setWidth(125); + root->setProperty("testRightToLeft", true); + + QQuickRectangle *one = canvas->rootObject()->findChild("one"); + QTRY_VERIFY(one != 0); + QQuickRectangle *two = canvas->rootObject()->findChild("two"); + QVERIFY(two != 0); + QQuickRectangle *three = canvas->rootObject()->findChild("three"); + QVERIFY(three != 0); + QQuickRectangle *four = canvas->rootObject()->findChild("four"); + QVERIFY(four != 0); + QQuickRectangle *five = canvas->rootObject()->findChild("five"); + QVERIFY(five != 0); + + QCOMPARE(one->x(), 75.0); + QCOMPARE(one->y(), 0.0); + QCOMPARE(two->x(), 55.0); + QCOMPARE(two->y(), 0.0); + QCOMPARE(three->x(), 5.0); + QCOMPARE(three->y(), 0.0); + QCOMPARE(four->x(), 75.0); + QCOMPARE(four->y(), 50.0); + QCOMPARE(five->x(), 65.0); + QCOMPARE(five->y(), 50.0); + + delete canvas; +} + +void tst_qquickpositioners::test_flow_implicit_resize() +{ + QQuickView *canvas = createView(testFile("flow-testimplicitsize.qml")); + QVERIFY(canvas->rootObject() != 0); + + QQuickFlow *flow = canvas->rootObject()->findChild("flow"); + QVERIFY(flow != 0); + + QCOMPARE(flow->width(), 100.0); + QCOMPARE(flow->height(), 120.0); + + canvas->rootObject()->setProperty("flowLayout", 0); + QCOMPARE(flow->flow(), QQuickFlow::LeftToRight); + QCOMPARE(flow->width(), 220.0); + QCOMPARE(flow->height(), 50.0); + + canvas->rootObject()->setProperty("flowLayout", 1); + QCOMPARE(flow->flow(), QQuickFlow::TopToBottom); + QCOMPARE(flow->width(), 100.0); + QCOMPARE(flow->height(), 120.0); + + canvas->rootObject()->setProperty("flowLayout", 2); + QCOMPARE(flow->layoutDirection(), Qt::RightToLeft); + QCOMPARE(flow->width(), 220.0); + QCOMPARE(flow->height(), 50.0); + + delete canvas; +} + +QString warningMessage; + +void interceptWarnings(QtMsgType type, const char *msg) +{ + Q_UNUSED( type ); + warningMessage = msg; +} + +void tst_qquickpositioners::test_conflictinganchors() +{ + QtMsgHandler oldMsgHandler = qInstallMsgHandler(interceptWarnings); + QQmlEngine engine; + QQmlComponent component(&engine); + + component.setData("import QtQuick 2.0\nColumn { Item { width: 100; height: 100; } }", QUrl::fromLocalFile("")); + QQuickItem *item = qobject_cast(component.create()); + QVERIFY(item); + QVERIFY(warningMessage.isEmpty()); + delete item; + + component.setData("import QtQuick 2.0\nRow { Item { width: 100; height: 100; } }", QUrl::fromLocalFile("")); + item = qobject_cast(component.create()); + QVERIFY(item); + QVERIFY(warningMessage.isEmpty()); + delete item; + + component.setData("import QtQuick 2.0\nGrid { Item { width: 100; height: 100; } }", QUrl::fromLocalFile("")); + item = qobject_cast(component.create()); + QVERIFY(item); + QVERIFY(warningMessage.isEmpty()); + delete item; + + component.setData("import QtQuick 2.0\nFlow { Item { width: 100; height: 100; } }", QUrl::fromLocalFile("")); + item = qobject_cast(component.create()); + QVERIFY(item); + QVERIFY(warningMessage.isEmpty()); + delete item; + + component.setData("import QtQuick 2.0\nColumn { Item { width: 100; height: 100; anchors.top: parent.top } }", QUrl::fromLocalFile("")); + item = qobject_cast(component.create()); + QVERIFY(item); + QCOMPARE(warningMessage, QString("file::2:1: QML Column: Cannot specify top, bottom, verticalCenter, fill or centerIn anchors for items inside Column. Column will not function.")); + warningMessage.clear(); + delete item; + + component.setData("import QtQuick 2.0\nColumn { Item { width: 100; height: 100; anchors.centerIn: parent } }", QUrl::fromLocalFile("")); + item = qobject_cast(component.create()); + QVERIFY(item); + QCOMPARE(warningMessage, QString("file::2:1: QML Column: Cannot specify top, bottom, verticalCenter, fill or centerIn anchors for items inside Column. Column will not function.")); + warningMessage.clear(); + delete item; + + component.setData("import QtQuick 2.0\nColumn { Item { width: 100; height: 100; anchors.left: parent.left } }", QUrl::fromLocalFile("")); + item = qobject_cast(component.create()); + QVERIFY(item); + QVERIFY(warningMessage.isEmpty()); + warningMessage.clear(); + delete item; + + component.setData("import QtQuick 2.0\nRow { Item { width: 100; height: 100; anchors.left: parent.left } }", QUrl::fromLocalFile("")); + item = qobject_cast(component.create()); + QVERIFY(item); + QCOMPARE(warningMessage, QString("file::2:1: QML Row: Cannot specify left, right, horizontalCenter, fill or centerIn anchors for items inside Row. Row will not function.")); + warningMessage.clear(); + delete item; + + component.setData("import QtQuick 2.0\nRow { width: 100; height: 100; Item { anchors.fill: parent } }", QUrl::fromLocalFile("")); + item = qobject_cast(component.create()); + QVERIFY(item); + QCOMPARE(warningMessage, QString("file::2:1: QML Row: Cannot specify left, right, horizontalCenter, fill or centerIn anchors for items inside Row. Row will not function.")); + warningMessage.clear(); + delete item; + + component.setData("import QtQuick 2.0\nRow { Item { width: 100; height: 100; anchors.top: parent.top } }", QUrl::fromLocalFile("")); + item = qobject_cast(component.create()); + QVERIFY(item); + QVERIFY(warningMessage.isEmpty()); + warningMessage.clear(); + delete item; + + component.setData("import QtQuick 2.0\nGrid { Item { width: 100; height: 100; anchors.horizontalCenter: parent.horizontalCenter } }", QUrl::fromLocalFile("")); + item = qobject_cast(component.create()); + QVERIFY(item); + QCOMPARE(warningMessage, QString("file::2:1: QML Grid: Cannot specify anchors for items inside Grid. Grid will not function.")); + warningMessage.clear(); + delete item; + + component.setData("import QtQuick 2.0\nGrid { Item { width: 100; height: 100; anchors.centerIn: parent } }", QUrl::fromLocalFile("")); + item = qobject_cast(component.create()); + QVERIFY(item); + QCOMPARE(warningMessage, QString("file::2:1: QML Grid: Cannot specify anchors for items inside Grid. Grid will not function.")); + warningMessage.clear(); + delete item; + + component.setData("import QtQuick 2.0\nFlow { Item { width: 100; height: 100; anchors.verticalCenter: parent.verticalCenter } }", QUrl::fromLocalFile("")); + item = qobject_cast(component.create()); + QVERIFY(item); + QCOMPARE(warningMessage, QString("file::2:1: QML Flow: Cannot specify anchors for items inside Flow. Flow will not function.")); + delete item; + + component.setData("import QtQuick 2.0\nFlow { width: 100; height: 100; Item { anchors.fill: parent } }", QUrl::fromLocalFile("")); + item = qobject_cast(component.create()); + QVERIFY(item); + QCOMPARE(warningMessage, QString("file::2:1: QML Flow: Cannot specify anchors for items inside Flow. Flow will not function.")); + qInstallMsgHandler(oldMsgHandler); + delete item; +} + +void tst_qquickpositioners::test_mirroring() +{ + QList qmlFiles; + qmlFiles << "horizontal.qml" << "gridtest.qml" << "flowtest.qml"; + QList objectNames; + objectNames << "one" << "two" << "three" << "four" << "five"; + + foreach (const QString qmlFile, qmlFiles) { + QQuickView *canvasA = createView(testFile(qmlFile)); + QQuickItem *rootA = qobject_cast(canvasA->rootObject()); + + QQuickView *canvasB = createView(testFile(qmlFile)); + QQuickItem *rootB = qobject_cast(canvasB->rootObject()); + + rootA->setProperty("testRightToLeft", true); // layoutDirection: Qt.RightToLeft + + // LTR != RTL + foreach (const QString objectName, objectNames) { + // horizontal.qml only has three items + if (qmlFile == QString("horizontal.qml") && objectName == QString("four")) + break; + QQuickItem *itemA = rootA->findChild(objectName); + QQuickItem *itemB = rootB->findChild(objectName); + QTRY_VERIFY(itemA->x() != itemB->x()); + } + + QQmlProperty enabledProp(rootB, "LayoutMirroring.enabled", qmlContext(rootB)); + enabledProp.write(true); + QQmlProperty inheritProp(rootB, "LayoutMirroring.childrenInherit", qmlContext(rootB)); + inheritProp.write(true); + + // RTL == mirror + foreach (const QString objectName, objectNames) { + // horizontal.qml only has three items + if (qmlFile == QString("horizontal.qml") && objectName == QString("four")) + break; + QQuickItem *itemA = rootA->findChild(objectName); + QQuickItem *itemB = rootB->findChild(objectName); + QTRY_COMPARE(itemA->x(), itemB->x()); + } + + rootA->setProperty("testRightToLeft", false); // layoutDirection: Qt.LeftToRight + rootB->setProperty("testRightToLeft", true); // layoutDirection: Qt.RightToLeft + + // LTR == RTL + mirror + foreach (const QString objectName, objectNames) { + // horizontal.qml only has three items + if (qmlFile == QString("horizontal.qml") && objectName == QString("four")) + break; + QQuickItem *itemA = rootA->findChild(objectName); + QQuickItem *itemB = rootB->findChild(objectName); + QTRY_COMPARE(itemA->x(), itemB->x()); + } + delete canvasA; + delete canvasB; + } +} + +void tst_qquickpositioners::test_allInvisible() +{ + //QTBUG-19361 + QQuickView *canvas = createView(testFile("allInvisible.qml")); + + QQuickItem *root = qobject_cast(canvas->rootObject()); + QVERIFY(root); + + QQuickRow *row = canvas->rootObject()->findChild("row"); + QVERIFY(row != 0); + QVERIFY(row->width() == 0); + QVERIFY(row->height() == 0); + QQuickColumn *column = canvas->rootObject()->findChild("column"); + QVERIFY(column != 0); + QVERIFY(column->width() == 0); + QVERIFY(column->height() == 0); +} + +void tst_qquickpositioners::test_attachedproperties() +{ + QFETCH(QString, filename); + + QQuickView *canvas = createView(filename); + QVERIFY(canvas->rootObject() != 0); + + QQuickRectangle *greenRect = canvas->rootObject()->findChild("greenRect"); + QVERIFY(greenRect != 0); + + int posIndex = greenRect->property("posIndex").toInt(); + QVERIFY(posIndex == 0); + bool isFirst = greenRect->property("isFirstItem").toBool(); + QVERIFY(isFirst == true); + bool isLast = greenRect->property("isLastItem").toBool(); + QVERIFY(isLast == false); + + QQuickRectangle *yellowRect = canvas->rootObject()->findChild("yellowRect"); + QVERIFY(yellowRect != 0); + + posIndex = yellowRect->property("posIndex").toInt(); + QVERIFY(posIndex == -1); + isFirst = yellowRect->property("isFirstItem").toBool(); + QVERIFY(isFirst == false); + isLast = yellowRect->property("isLastItem").toBool(); + QVERIFY(isLast == false); + + yellowRect->metaObject()->invokeMethod(yellowRect, "onDemandPositioner"); + + posIndex = yellowRect->property("posIndex").toInt(); + QVERIFY(posIndex == 1); + isFirst = yellowRect->property("isFirstItem").toBool(); + QVERIFY(isFirst == false); + isLast = yellowRect->property("isLastItem").toBool(); + QVERIFY(isLast == true); + + delete canvas; +} + +void tst_qquickpositioners::test_attachedproperties_data() +{ + QTest::addColumn("filename"); + + QTest::newRow("column") << testFile("attachedproperties-column.qml"); + QTest::newRow("row") << testFile("attachedproperties-row.qml"); + QTest::newRow("grid") << testFile("attachedproperties-grid.qml"); + QTest::newRow("flow") << testFile("attachedproperties-flow.qml"); +} + +void tst_qquickpositioners::test_attachedproperties_dynamic() +{ + QQuickView *canvas = createView(testFile("attachedproperties-dynamic.qml")); + QVERIFY(canvas->rootObject() != 0); + + QQuickRow *row = canvas->rootObject()->findChild("pos"); + QVERIFY(row != 0); + + QQuickRectangle *rect0 = canvas->rootObject()->findChild("rect0"); + QVERIFY(rect0 != 0); + + int posIndex = rect0->property("index").toInt(); + QVERIFY(posIndex == 0); + bool isFirst = rect0->property("firstItem").toBool(); + QVERIFY(isFirst == true); + bool isLast = rect0->property("lastItem").toBool(); + QVERIFY(isLast == false); + + QQuickRectangle *rect1 = canvas->rootObject()->findChild("rect1"); + QVERIFY(rect1 != 0); + + posIndex = rect1->property("index").toInt(); + QVERIFY(posIndex == 1); + isFirst = rect1->property("firstItem").toBool(); + QVERIFY(isFirst == false); + isLast = rect1->property("lastItem").toBool(); + QVERIFY(isLast == true); + + row->metaObject()->invokeMethod(row, "createSubRect"); + + QTRY_VERIFY(rect1->property("index").toInt() == 1); + QTRY_VERIFY(rect1->property("firstItem").toBool() == false); + QTRY_VERIFY(rect1->property("lastItem").toBool() == false); + + QQuickRectangle *rect2 = canvas->rootObject()->findChild("rect2"); + QVERIFY(rect2 != 0); + + posIndex = rect2->property("index").toInt(); + QVERIFY(posIndex == 2); + isFirst = rect2->property("firstItem").toBool(); + QVERIFY(isFirst == false); + isLast = rect2->property("lastItem").toBool(); + QVERIFY(isLast == true); + + row->metaObject()->invokeMethod(row, "destroySubRect"); + + QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete); + QCoreApplication::processEvents(); + + QTRY_VERIFY(rect1->property("index").toInt() == 1); + QTRY_VERIFY(rect1->property("firstItem").toBool() == false); + QTRY_VERIFY(rect1->property("lastItem").toBool() == true); + + delete canvas; +} + +QQuickView *tst_qquickpositioners::createView(const QString &filename, bool wait) +{ + QQuickView *canvas = new QQuickView(0); + + canvas->setSource(QUrl::fromLocalFile(filename)); + canvas->show(); + if (wait) + QTest::qWaitForWindowShown(canvas); //It may not relayout until the next frame, so it needs to be drawn + + return canvas; +} + + +QTEST_MAIN(tst_qquickpositioners) + +#include "tst_qquickpositioners.moc" diff --git a/tests/auto/quick/qquickrepeater/data/asyncloader.qml b/tests/auto/quick/qquickrepeater/data/asyncloader.qml new file mode 100644 index 0000000000..82094e2666 --- /dev/null +++ b/tests/auto/quick/qquickrepeater/data/asyncloader.qml @@ -0,0 +1,32 @@ +import QtQuick 2.0 + +Item { + width: 360 + height: 480 + + Loader { + asynchronous: true + sourceComponent: viewComponent + } + + Component { + id: viewComponent + Column { + objectName: "container" + Repeater { + id: repeater + objectName: "repeater" + + model: 10 + + delegate: Rectangle { + objectName: "delegate" + index + color: "red" + width: 360 + height: 50 + Text { text: index } + } + } + } + } +} diff --git a/tests/auto/quick/qquickrepeater/data/initparent.qml b/tests/auto/quick/qquickrepeater/data/initparent.qml new file mode 100644 index 0000000000..e6571f09d3 --- /dev/null +++ b/tests/auto/quick/qquickrepeater/data/initparent.qml @@ -0,0 +1,12 @@ +import QtQuick 2.0 + +Item { + id: root + property Item parentItem: null + Repeater { + model: 1 + Item { + Component.onCompleted: root.parentItem = parent + } + } +} diff --git a/tests/auto/quick/qquickrepeater/data/intmodel.qml b/tests/auto/quick/qquickrepeater/data/intmodel.qml new file mode 100644 index 0000000000..30a650dd52 --- /dev/null +++ b/tests/auto/quick/qquickrepeater/data/intmodel.qml @@ -0,0 +1,29 @@ +import QtQuick 2.0 + +Rectangle { + id: container + objectName: "container" + width: 240 + height: 320 + color: "white" + + function checkProperties() { + testObject.error = false; + if (repeater.delegate != comp) { + console.log("delegate property incorrect"); + testObject.error = true; + } + } + + Component { + id: comp + Item{} + } + + Repeater { + id: repeater + objectName: "repeater" + model: testData + delegate: comp + } +} diff --git a/tests/auto/quick/qquickrepeater/data/itemlist.qml b/tests/auto/quick/qquickrepeater/data/itemlist.qml new file mode 100644 index 0000000000..174bfd4d18 --- /dev/null +++ b/tests/auto/quick/qquickrepeater/data/itemlist.qml @@ -0,0 +1,68 @@ +// This example demonstrates placing items in a view using +// a VisualItemModel + +import QtQuick 2.0 + +Rectangle { + id: root + color: "lightgray" + width: 240 + height: 320 + property variant itemModel: itemModel1 + + function checkProperties() { + testObject.error = false; + if (testObject.useModel && view.model != root.itemModel) { + console.log("model property incorrect"); + testObject.error = true; + } + } + + function switchModel() { + root.itemModel = itemModel2 + } + + VisualItemModel { + id: itemModel1 + objectName: "itemModel1" + Rectangle { + objectName: "item1" + height: 50; width: 100; color: "#FFFEF0" + Text { objectName: "text1"; text: "index: " + parent.VisualItemModel.index; font.bold: true; anchors.centerIn: parent } + } + Rectangle { + objectName: "item2" + height: 50; width: 100; color: "#F0FFF7" + Text { objectName: "text2"; text: "index: " + parent.VisualItemModel.index; font.bold: true; anchors.centerIn: parent } + } + Rectangle { + objectName: "item3" + height: 50; width: 100; color: "#F4F0FF" + Text { objectName: "text3"; text: "index: " + parent.VisualItemModel.index; font.bold: true; anchors.centerIn: parent } + } + } + + VisualItemModel { + id: itemModel2 + objectName: "itemModel2" + Rectangle { + objectName: "item4" + height: 50; width: 100; color: "#FFFEF0" + Text { objectName: "text4"; text: "index: " + parent.VisualItemModel.index; font.bold: true; anchors.centerIn: parent } + } + Rectangle { + objectName: "item5" + height: 50; width: 100; color: "#F0FFF7" + Text { objectName: "text5"; text: "index: " + parent.VisualItemModel.index; font.bold: true; anchors.centerIn: parent } + } + } + + Column { + objectName: "container" + Repeater { + id: view + objectName: "repeater" + model: testObject.useModel ? root.itemModel : 0 + } + } +} diff --git a/tests/auto/quick/qquickrepeater/data/modelChanged.qml b/tests/auto/quick/qquickrepeater/data/modelChanged.qml new file mode 100644 index 0000000000..23af127e79 --- /dev/null +++ b/tests/auto/quick/qquickrepeater/data/modelChanged.qml @@ -0,0 +1,26 @@ +import QtQuick 2.0 + +Column { + Repeater { + id: repeater + objectName: "repeater" + + property int itemsCount + property variant itemsFound: [] + + delegate: Rectangle { + color: "red" + width: (index+1)*50 + height: 50 + } + + onModelChanged: { + repeater.itemsCount = repeater.count + var items = [] + for (var i=0; i +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "../../shared/util.h" +#include "../shared/viewtestutil.h" +#include "../shared/visualtestutil.h" + +using namespace QQuickViewTestUtil; +using namespace QQuickVisualTestUtil; + + +class tst_QQuickRepeater : public QQmlDataTest +{ + Q_OBJECT +public: + tst_QQuickRepeater(); + +private slots: + void numberModel(); + void objectList(); + void stringList(); + void dataModel_adding(); + void dataModel_removing(); + void dataModel_changes(); + void itemModel(); + void resetModel(); + void modelChanged(); + void properties(); + void asynchronous(); + void initParent(); +}; + +class TestObject : public QObject +{ + Q_OBJECT + + Q_PROPERTY(bool error READ error WRITE setError) + Q_PROPERTY(bool useModel READ useModel NOTIFY useModelChanged) + +public: + TestObject() : QObject(), mError(true), mUseModel(false) {} + + bool error() const { return mError; } + void setError(bool err) { mError = err; } + + bool useModel() const { return mUseModel; } + void setUseModel(bool use) { mUseModel = use; emit useModelChanged(); } + +signals: + void useModelChanged(); + +private: + bool mError; + bool mUseModel; +}; + +tst_QQuickRepeater::tst_QQuickRepeater() +{ +} + +void tst_QQuickRepeater::numberModel() +{ + QQuickView *canvas = createView(); + + QQmlContext *ctxt = canvas->rootContext(); + ctxt->setContextProperty("testData", 5); + TestObject *testObject = new TestObject; + ctxt->setContextProperty("testObject", testObject); + + canvas->setSource(testFileUrl("intmodel.qml")); + qApp->processEvents(); + + QQuickRepeater *repeater = findItem(canvas->rootObject(), "repeater"); + QVERIFY(repeater != 0); + QCOMPARE(repeater->parentItem()->childItems().count(), 5+1); + + QVERIFY(!repeater->itemAt(-1)); + for (int i=0; icount(); i++) + QCOMPARE(repeater->itemAt(i), repeater->parentItem()->childItems().at(i)); + QVERIFY(!repeater->itemAt(repeater->count())); + + QMetaObject::invokeMethod(canvas->rootObject(), "checkProperties"); + QVERIFY(testObject->error() == false); + + delete testObject; + delete canvas; +} + +class MyObject : public QObject +{ + Q_OBJECT + Q_PROPERTY(int idx READ idx CONSTANT) +public: + MyObject(int i) : QObject(), m_idx(i) {} + + int idx() const { return m_idx; } + + int m_idx; +}; + +void tst_QQuickRepeater::objectList() +{ + QQuickView *canvas = createView(); + QObjectList data; + for (int i=0; i<100; i++) + data << new MyObject(i); + + QQmlContext *ctxt = canvas->rootContext(); + ctxt->setContextProperty("testData", QVariant::fromValue(data)); + + canvas->setSource(testFileUrl("objlist.qml")); + qApp->processEvents(); + + QQuickRepeater *repeater = findItem(canvas->rootObject(), "repeater"); + QVERIFY(repeater != 0); + QCOMPARE(repeater->property("errors").toInt(), 0);//If this fails either they are out of order or can't find the object's data + QCOMPARE(repeater->property("instantiated").toInt(), 100); + + QVERIFY(!repeater->itemAt(-1)); + for (int i=0; iitemAt(i), repeater->parentItem()->childItems().at(i)); + QVERIFY(!repeater->itemAt(data.count())); + + QSignalSpy addedSpy(repeater, SIGNAL(itemAdded(int,QQuickItem*))); + QSignalSpy removedSpy(repeater, SIGNAL(itemRemoved(int,QQuickItem*))); + ctxt->setContextProperty("testData", QVariant::fromValue(data)); + QCOMPARE(addedSpy.count(), data.count()); + QCOMPARE(removedSpy.count(), data.count()); + + qDeleteAll(data); + delete canvas; +} + +/* +The Repeater element creates children at its own position in its parent's +stacking order. In this test we insert a repeater between two other Text +elements to test this. +*/ +void tst_QQuickRepeater::stringList() +{ + QQuickView *canvas = createView(); + + QStringList data; + data << "One"; + data << "Two"; + data << "Three"; + data << "Four"; + + QQmlContext *ctxt = canvas->rootContext(); + ctxt->setContextProperty("testData", data); + + canvas->setSource(testFileUrl("repeater1.qml")); + qApp->processEvents(); + + QQuickRepeater *repeater = findItem(canvas->rootObject(), "repeater"); + QVERIFY(repeater != 0); + + QQuickItem *container = findItem(canvas->rootObject(), "container"); + QVERIFY(container != 0); + + QCOMPARE(container->childItems().count(), data.count() + 3); + + bool saw_repeater = false; + for (int i = 0; i < container->childItems().count(); ++i) { + + if (i == 0) { + QQuickText *name = qobject_cast(container->childItems().at(i)); + QVERIFY(name != 0); + QCOMPARE(name->text(), QLatin1String("Zero")); + } else if (i == container->childItems().count() - 2) { + // The repeater itself + QQuickRepeater *rep = qobject_cast(container->childItems().at(i)); + QCOMPARE(rep, repeater); + saw_repeater = true; + continue; + } else if (i == container->childItems().count() - 1) { + QQuickText *name = qobject_cast(container->childItems().at(i)); + QVERIFY(name != 0); + QCOMPARE(name->text(), QLatin1String("Last")); + } else { + QQuickText *name = qobject_cast(container->childItems().at(i)); + QVERIFY(name != 0); + QCOMPARE(name->text(), data.at(i-1)); + } + } + QVERIFY(saw_repeater); + + delete canvas; +} + +void tst_QQuickRepeater::dataModel_adding() +{ + QQuickView *canvas = createView(); + QQmlContext *ctxt = canvas->rootContext(); + TestObject *testObject = new TestObject; + ctxt->setContextProperty("testObject", testObject); + + QaimModel testModel; + ctxt->setContextProperty("testData", &testModel); + canvas->setSource(testFileUrl("repeater2.qml")); + qApp->processEvents(); + + QQuickRepeater *repeater = findItem(canvas->rootObject(), "repeater"); + QVERIFY(repeater != 0); + QQuickItem *container = findItem(canvas->rootObject(), "container"); + QVERIFY(container != 0); + + QVERIFY(!repeater->itemAt(0)); + + QSignalSpy countSpy(repeater, SIGNAL(countChanged())); + QSignalSpy addedSpy(repeater, SIGNAL(itemAdded(int,QQuickItem*))); + + // add to empty model + testModel.addItem("two", "2"); + QCOMPARE(repeater->itemAt(0), container->childItems().at(0)); + QCOMPARE(countSpy.count(), 1); countSpy.clear(); + QCOMPARE(addedSpy.count(), 1); + QCOMPARE(addedSpy.at(0).at(0).toInt(), 0); + QCOMPARE(addedSpy.at(0).at(1).value(), container->childItems().at(0)); + addedSpy.clear(); + + // insert at start + testModel.insertItem(0, "one", "1"); + QCOMPARE(repeater->itemAt(0), container->childItems().at(0)); + QCOMPARE(countSpy.count(), 1); countSpy.clear(); + QCOMPARE(addedSpy.count(), 1); + QCOMPARE(addedSpy.at(0).at(0).toInt(), 0); + QCOMPARE(addedSpy.at(0).at(1).value(), container->childItems().at(0)); + addedSpy.clear(); + + // insert at end + testModel.insertItem(2, "four", "4"); + QCOMPARE(repeater->itemAt(2), container->childItems().at(2)); + QCOMPARE(countSpy.count(), 1); countSpy.clear(); + QCOMPARE(addedSpy.count(), 1); + QCOMPARE(addedSpy.at(0).at(0).toInt(), 2); + QCOMPARE(addedSpy.at(0).at(1).value(), container->childItems().at(2)); + addedSpy.clear(); + + // insert in middle + testModel.insertItem(2, "three", "3"); + QCOMPARE(repeater->itemAt(2), container->childItems().at(2)); + QCOMPARE(countSpy.count(), 1); countSpy.clear(); + QCOMPARE(addedSpy.count(), 1); + QCOMPARE(addedSpy.at(0).at(0).toInt(), 2); + QCOMPARE(addedSpy.at(0).at(1).value(), container->childItems().at(2)); + addedSpy.clear(); + + delete testObject; + addedSpy.clear(); + countSpy.clear(); + delete canvas; +} + +void tst_QQuickRepeater::dataModel_removing() +{ + QQuickView *canvas = createView(); + QQmlContext *ctxt = canvas->rootContext(); + TestObject *testObject = new TestObject; + ctxt->setContextProperty("testObject", testObject); + + QaimModel testModel; + testModel.addItem("one", "1"); + testModel.addItem("two", "2"); + testModel.addItem("three", "3"); + testModel.addItem("four", "4"); + testModel.addItem("five", "5"); + + ctxt->setContextProperty("testData", &testModel); + canvas->setSource(testFileUrl("repeater2.qml")); + qApp->processEvents(); + + QQuickRepeater *repeater = findItem(canvas->rootObject(), "repeater"); + QVERIFY(repeater != 0); + QQuickItem *container = findItem(canvas->rootObject(), "container"); + QVERIFY(container != 0); + QCOMPARE(container->childItems().count(), repeater->count()+1); + + QSignalSpy countSpy(repeater, SIGNAL(countChanged())); + QSignalSpy removedSpy(repeater, SIGNAL(itemRemoved(int,QQuickItem*))); + + // remove at start + QQuickItem *item = repeater->itemAt(0); + QCOMPARE(item, container->childItems().at(0)); + + testModel.removeItem(0); + QVERIFY(repeater->itemAt(0) != item); + QCOMPARE(countSpy.count(), 1); countSpy.clear(); + QCOMPARE(removedSpy.count(), 1); + QCOMPARE(removedSpy.at(0).at(0).toInt(), 0); + QCOMPARE(removedSpy.at(0).at(1).value(), item); + removedSpy.clear(); + + // remove at end + int lastIndex = testModel.count()-1; + item = repeater->itemAt(lastIndex); + QCOMPARE(item, container->childItems().at(lastIndex)); + + testModel.removeItem(lastIndex); + QVERIFY(repeater->itemAt(lastIndex) != item); + QCOMPARE(countSpy.count(), 1); countSpy.clear(); + QCOMPARE(removedSpy.count(), 1); + QCOMPARE(removedSpy.at(0).at(0).toInt(), lastIndex); + QCOMPARE(removedSpy.at(0).at(1).value(), item); + removedSpy.clear(); + + // remove from middle + item = repeater->itemAt(1); + QCOMPARE(item, container->childItems().at(1)); + + testModel.removeItem(1); + QVERIFY(repeater->itemAt(lastIndex) != item); + QCOMPARE(countSpy.count(), 1); countSpy.clear(); + QCOMPARE(removedSpy.count(), 1); + QCOMPARE(removedSpy.at(0).at(0).toInt(), 1); + QCOMPARE(removedSpy.at(0).at(1).value(), item); + removedSpy.clear(); + + delete testObject; + delete canvas; +} + +void tst_QQuickRepeater::dataModel_changes() +{ + QQuickView *canvas = createView(); + QQmlContext *ctxt = canvas->rootContext(); + TestObject *testObject = new TestObject; + ctxt->setContextProperty("testObject", testObject); + + QaimModel testModel; + testModel.addItem("one", "1"); + testModel.addItem("two", "2"); + testModel.addItem("three", "3"); + + ctxt->setContextProperty("testData", &testModel); + canvas->setSource(testFileUrl("repeater2.qml")); + qApp->processEvents(); + + QQuickRepeater *repeater = findItem(canvas->rootObject(), "repeater"); + QVERIFY(repeater != 0); + QQuickItem *container = findItem(canvas->rootObject(), "container"); + QVERIFY(container != 0); + QCOMPARE(container->childItems().count(), repeater->count()+1); + + // Check that model changes are propagated + QQuickText *text = findItem(canvas->rootObject(), "myName", 1); + QVERIFY(text); + QCOMPARE(text->text(), QString("two")); + + testModel.modifyItem(1, "Item two", "_2"); + text = findItem(canvas->rootObject(), "myName", 1); + QVERIFY(text); + QCOMPARE(text->text(), QString("Item two")); + + text = findItem(canvas->rootObject(), "myNumber", 1); + QVERIFY(text); + QCOMPARE(text->text(), QString("_2")); + + delete testObject; + delete canvas; +} + +void tst_QQuickRepeater::itemModel() +{ + QQuickView *canvas = createView(); + QQmlContext *ctxt = canvas->rootContext(); + TestObject *testObject = new TestObject; + ctxt->setContextProperty("testObject", testObject); + + canvas->setSource(testFileUrl("itemlist.qml")); + qApp->processEvents(); + + QQuickRepeater *repeater = findItem(canvas->rootObject(), "repeater"); + QVERIFY(repeater != 0); + + QQuickItem *container = findItem(canvas->rootObject(), "container"); + QVERIFY(container != 0); + + QCOMPARE(container->childItems().count(), 1); + + testObject->setUseModel(true); + QMetaObject::invokeMethod(canvas->rootObject(), "checkProperties"); + QVERIFY(testObject->error() == false); + + QCOMPARE(container->childItems().count(), 4); + QVERIFY(qobject_cast(container->childItems().at(0))->objectName() == "item1"); + QVERIFY(qobject_cast(container->childItems().at(1))->objectName() == "item2"); + QVERIFY(qobject_cast(container->childItems().at(2))->objectName() == "item3"); + QVERIFY(container->childItems().at(3) == repeater); + + QMetaObject::invokeMethod(canvas->rootObject(), "switchModel"); + QCOMPARE(container->childItems().count(), 3); + QVERIFY(qobject_cast(container->childItems().at(0))->objectName() == "item4"); + QVERIFY(qobject_cast(container->childItems().at(1))->objectName() == "item5"); + QVERIFY(container->childItems().at(2) == repeater); + + testObject->setUseModel(false); + QCOMPARE(container->childItems().count(), 1); + + delete testObject; + delete canvas; +} + +void tst_QQuickRepeater::resetModel() +{ + QQuickView *canvas = createView(); + + QStringList dataA; + for (int i=0; i<10; i++) + dataA << QString::number(i); + + QQmlContext *ctxt = canvas->rootContext(); + ctxt->setContextProperty("testData", dataA); + canvas->setSource(testFileUrl("repeater1.qml")); + qApp->processEvents(); + QQuickRepeater *repeater = findItem(canvas->rootObject(), "repeater"); + QVERIFY(repeater != 0); + QQuickItem *container = findItem(canvas->rootObject(), "container"); + QVERIFY(container != 0); + + QCOMPARE(repeater->count(), dataA.count()); + for (int i=0; icount(); i++) + QCOMPARE(repeater->itemAt(i), container->childItems().at(i+1)); // +1 to skip first Text object + + QSignalSpy modelChangedSpy(repeater, SIGNAL(modelChanged())); + QSignalSpy countSpy(repeater, SIGNAL(countChanged())); + QSignalSpy addedSpy(repeater, SIGNAL(itemAdded(int,QQuickItem*))); + QSignalSpy removedSpy(repeater, SIGNAL(itemRemoved(int,QQuickItem*))); + + QStringList dataB; + for (int i=0; i<20; i++) + dataB << QString::number(i); + + // reset context property + ctxt->setContextProperty("testData", dataB); + QCOMPARE(repeater->count(), dataB.count()); + + QCOMPARE(modelChangedSpy.count(), 1); + QCOMPARE(countSpy.count(), 1); + QCOMPARE(removedSpy.count(), dataA.count()); + QCOMPARE(addedSpy.count(), dataB.count()); + for (int i=0; i(), repeater->itemAt(i)); + } + modelChangedSpy.clear(); + countSpy.clear(); + removedSpy.clear(); + addedSpy.clear(); + + // reset via setModel() + repeater->setModel(dataA); + QCOMPARE(repeater->count(), dataA.count()); + + QCOMPARE(modelChangedSpy.count(), 1); + QCOMPARE(countSpy.count(), 1); + QCOMPARE(removedSpy.count(), dataB.count()); + QCOMPARE(addedSpy.count(), dataA.count()); + for (int i=0; i(), repeater->itemAt(i)); + } + + modelChangedSpy.clear(); + countSpy.clear(); + removedSpy.clear(); + addedSpy.clear(); + + delete canvas; +} + +// QTBUG-17156 +void tst_QQuickRepeater::modelChanged() +{ + QQmlEngine engine; + QQmlComponent component(&engine, testFileUrl("modelChanged.qml")); + + QQuickItem *rootObject = qobject_cast(component.create()); + QVERIFY(rootObject); + QQuickRepeater *repeater = findItem(rootObject, "repeater"); + QVERIFY(repeater); + + repeater->setModel(4); + QCOMPARE(repeater->count(), 4); + QCOMPARE(repeater->property("itemsCount").toInt(), 4); + QCOMPARE(repeater->property("itemsFound").toList().count(), 4); + + repeater->setModel(10); + QCOMPARE(repeater->count(), 10); + QCOMPARE(repeater->property("itemsCount").toInt(), 10); + QCOMPARE(repeater->property("itemsFound").toList().count(), 10); + + delete rootObject; +} + +void tst_QQuickRepeater::properties() +{ + QQmlEngine engine; + QQmlComponent component(&engine, testFileUrl("properties.qml")); + + QQuickItem *rootObject = qobject_cast(component.create()); + QVERIFY(rootObject); + + QQuickRepeater *repeater = findItem(rootObject, "repeater"); + QVERIFY(repeater); + + QSignalSpy modelSpy(repeater, SIGNAL(modelChanged())); + repeater->setModel(3); + QCOMPARE(modelSpy.count(),1); + repeater->setModel(3); + QCOMPARE(modelSpy.count(),1); + + QSignalSpy delegateSpy(repeater, SIGNAL(delegateChanged())); + + QQmlComponent rectComponent(&engine); + rectComponent.setData("import QtQuick 2.0; Rectangle {}", QUrl::fromLocalFile("")); + + repeater->setDelegate(&rectComponent); + QCOMPARE(delegateSpy.count(),1); + repeater->setDelegate(&rectComponent); + QCOMPARE(delegateSpy.count(),1); + + delete rootObject; +} + +void tst_QQuickRepeater::asynchronous() +{ + QQuickView *canvas = createView(); + canvas->show(); + QQmlIncubationController controller; + canvas->engine()->setIncubationController(&controller); + + canvas->setSource(testFileUrl("asyncloader.qml")); + + QQuickItem *rootObject = qobject_cast(canvas->rootObject()); + QVERIFY(rootObject); + + QQuickItem *container = findItem(rootObject, "container"); + QVERIFY(!container); + while (!container) { + bool b = false; + controller.incubateWhile(&b); + container = findItem(rootObject, "container"); + } + + QQuickRepeater *repeater = 0; + while (!repeater) { + bool b = false; + controller.incubateWhile(&b); + repeater = findItem(rootObject, "repeater"); + } + + // items will be created one at a time + for (int i = 0; i < 10; ++i) { + QString name("delegate"); + name += QString::number(i); + QVERIFY(findItem(container, name) == 0); + QQuickItem *item = 0; + while (!item) { + bool b = false; + controller.incubateWhile(&b); + item = findItem(container, name); + } + } + + { + bool b = true; + controller.incubateWhile(&b); + } + + // verify positioning + for (int i = 0; i < 10; ++i) { + QString name("delegate"); + name += QString::number(i); + QQuickItem *item = findItem(container, name); + QTRY_COMPARE(item->y(), i * 50.0); + } + + delete canvas; +} + +void tst_QQuickRepeater::initParent() +{ + QQmlEngine engine; + QQmlComponent component(&engine, testFileUrl("initparent.qml")); + + QQuickItem *rootObject = qobject_cast(component.create()); + QVERIFY(rootObject); + + QCOMPARE(qvariant_cast(rootObject->property("parentItem")), rootObject); +} + +QTEST_MAIN(tst_QQuickRepeater) + +#include "tst_qquickrepeater.moc" diff --git a/tests/auto/quick/qquickscreen/data/screen.qml b/tests/auto/quick/qquickscreen/data/screen.qml new file mode 100644 index 0000000000..780b22f23d --- /dev/null +++ b/tests/auto/quick/qquickscreen/data/screen.qml @@ -0,0 +1,11 @@ +import QtQuick 2.0 +import QtQuick.Window 2.0 as Window + +Item { + width: 100 + height: 100 + property int w: Window.Screen.width + property int h: Window.Screen.height + property int curOrientation: Window.Screen.orientation + property int priOrientation: Window.Screen.primaryOrientation +} diff --git a/tests/auto/quick/qquickscreen/qquickscreen.pro b/tests/auto/quick/qquickscreen/qquickscreen.pro new file mode 100644 index 0000000000..00ec51ef33 --- /dev/null +++ b/tests/auto/quick/qquickscreen/qquickscreen.pro @@ -0,0 +1,10 @@ +CONFIG += testcase +TARGET = tst_qquickscreen +SOURCES += tst_qquickscreen.cpp + +include (../../shared/util.pri) + +macx:CONFIG -= app_bundle + +CONFIG += parallel_test +QT += core-private gui-private qml-private testlib quick-private diff --git a/tests/auto/quick/qquickscreen/tst_qquickscreen.cpp b/tests/auto/quick/qquickscreen/tst_qquickscreen.cpp new file mode 100644 index 0000000000..cbf9438f24 --- /dev/null +++ b/tests/auto/quick/qquickscreen/tst_qquickscreen.cpp @@ -0,0 +1,77 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include +#include +#include +#include +#include "../../shared/util.h" + +class tst_qquickscreen : public QQmlDataTest +{ + Q_OBJECT +private slots: + void basicProperties(); +}; + +void tst_qquickscreen::basicProperties() +{ + QQuickView view; + view.setSource(testFileUrl("screen.qml")); + view.show(); + QTest::qWaitForWindowShown(&view); + + QQuickItem* root = view.rootObject(); + QVERIFY(root); + + QScreen* screen = view.screen(); + QVERIFY(screen); + + QCOMPARE(screen->size().width(), root->property("w").toInt()); + QCOMPARE(screen->size().height(), root->property("h").toInt()); + QCOMPARE(int(screen->orientation()), root->property("curOrientation").toInt()); + QCOMPARE(int(screen->primaryOrientation()), root->property("priOrientation").toInt()); +} + +QTEST_MAIN(tst_qquickscreen) + +#include "tst_qquickscreen.moc" diff --git a/tests/auto/quick/qquickshadereffect/qquickshadereffect.pro b/tests/auto/quick/qquickshadereffect/qquickshadereffect.pro new file mode 100644 index 0000000000..6ff50a0553 --- /dev/null +++ b/tests/auto/quick/qquickshadereffect/qquickshadereffect.pro @@ -0,0 +1,8 @@ +CONFIG += testcase +TARGET = tst_qquickshadereffect +SOURCES += tst_qquickshadereffect.cpp + +macx:CONFIG -= app_bundle + +CONFIG += parallel_test +QT += core-private gui-private qml-private quick-private widgets testlib diff --git a/tests/auto/quick/qquickshadereffect/tst_qquickshadereffect.cpp b/tests/auto/quick/qquickshadereffect/tst_qquickshadereffect.cpp new file mode 100644 index 0000000000..00ae8fc76d --- /dev/null +++ b/tests/auto/quick/qquickshadereffect/tst_qquickshadereffect.cpp @@ -0,0 +1,275 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include + +#include +#include +#include + +class TestShaderEffect : public QQuickShaderEffect +{ + Q_OBJECT + Q_PROPERTY(QVariant source READ dummyRead NOTIFY dummyChanged) + Q_PROPERTY(QVariant _0aA9zZ READ dummyRead NOTIFY dummyChanged) + Q_PROPERTY(QVariant x86 READ dummyRead NOTIFY dummyChanged) + Q_PROPERTY(QVariant X READ dummyRead NOTIFY dummyChanged) + +public: + QVariant dummyRead() const { return QVariant(); } + bool isConnected(const char *signal) const { return m_signals.contains(signal); } + +protected: + void connectNotify(const char *signal) { m_signals.append(signal); } + void disconnectNotify(const char *signal) { m_signals.removeOne(signal); } + +signals: + void dummyChanged(); + +private: + QList m_signals; +}; + +class tst_qquickshadereffect : public QObject +{ + Q_OBJECT +public: + tst_qquickshadereffect(); + +private slots: + void initTestCase(); + void cleanupTestCase(); + + void lookThroughShaderCode_data(); + void lookThroughShaderCode(); + +private: + enum PresenceFlags { + VertexPresent = 0x01, + TexCoordPresent = 0x02, + MatrixPresent = 0x04, + OpacityPresent = 0x08, + PropertyPresent = 0x10 + }; +}; + +tst_qquickshadereffect::tst_qquickshadereffect() +{ +} + +void tst_qquickshadereffect::initTestCase() +{ +} + +void tst_qquickshadereffect::cleanupTestCase() +{ +} + +void tst_qquickshadereffect::lookThroughShaderCode_data() +{ + QTest::addColumn("vertexShader"); + QTest::addColumn("fragmentShader"); + QTest::addColumn("presenceFlags"); + + QTest::newRow("default") + << QByteArray("uniform highp mat4 qt_Matrix; \n" + "attribute highp vec4 qt_Vertex; \n" + "attribute highp vec2 qt_MultiTexCoord0; \n" + "varying highp vec2 qt_TexCoord0; \n" + "void main() { \n" + " qt_TexCoord0 = qt_MultiTexCoord0; \n" + " gl_Position = qt_Matrix * qt_Vertex; \n" + "}") + << QByteArray("varying highp vec2 qt_TexCoord0; \n" + "uniform sampler2D source; \n" + "uniform lowp float qt_Opacity; \n" + "void main() { \n" + " gl_FragColor = texture2D(source, qt_TexCoord0) * qt_Opacity; \n" + "}") + << (VertexPresent | TexCoordPresent | MatrixPresent | OpacityPresent | PropertyPresent); + + QTest::newRow("empty") + << QByteArray(" ") // one space -- if completely empty, default will be used instead. + << QByteArray(" ") + << 0; + + + QTest::newRow("inside line comments") + << QByteArray("//uniform highp mat4 qt_Matrix;\n" + "attribute highp vec4 qt_Vertex;\n" + "// attribute highp vec2 qt_MultiTexCoord0;") + << QByteArray("uniform int source; // uniform lowp float qt_Opacity;") + << (VertexPresent | PropertyPresent); + + QTest::newRow("inside block comments") + << QByteArray("/*uniform highp mat4 qt_Matrix;\n" + "*/attribute highp vec4 qt_Vertex;\n" + "/*/attribute highp vec2 qt_MultiTexCoord0;//**/") + << QByteArray("/**/uniform int source; /* uniform lowp float qt_Opacity; */") + << (VertexPresent | PropertyPresent); + + QTest::newRow("inside preprocessor directive") + << QByteArray("#define uniform\nhighp mat4 qt_Matrix;\n" + "attribute highp vec4 qt_Vertex;\n" + "#if\\\nattribute highp vec2 qt_MultiTexCoord0;") + << QByteArray("uniform int source;\n" + " # undef uniform lowp float qt_Opacity;") + << (VertexPresent | PropertyPresent); + + + QTest::newRow("line comments between") + << QByteArray("uniform//foo\nhighp//bar\nmat4//baz\nqt_Matrix;\n" + "attribute//\nhighp//\nvec4//\nqt_Vertex;\n" + " //*/ uniform \n attribute //\\ \n highp //// \n vec2 //* \n qt_MultiTexCoord0;") + << QByteArray("uniform// lowp float qt_Opacity;\nsampler2D source;") + << (VertexPresent | TexCoordPresent | MatrixPresent | PropertyPresent); + + QTest::newRow("block comments between") + << QByteArray("uniform/*foo*/highp/*/bar/*/mat4/**//**/qt_Matrix;\n" + "attribute/**/highp/**/vec4/**/qt_Vertex;\n" + " /* * */ attribute /*///*/ highp /****/ vec2 /**/ qt_MultiTexCoord0;") + << QByteArray("uniform/*/ uniform//lowp/*float qt_Opacity;*/sampler2D source;") + << (VertexPresent | TexCoordPresent | MatrixPresent | PropertyPresent); + + QTest::newRow("preprocessor directive between") + << QByteArray("uniform\n#foo\nhighp\n#bar\nmat4\n#baz\\\nblimey\nqt_Matrix;\n" + "attribute\n#\nhighp\n#\nvec4\n#\nqt_Vertex;\n" + " #uniform \n attribute \n # foo \n highp \n # bar \n vec2 \n#baz \n qt_MultiTexCoord0;") + << QByteArray("uniform\n#if lowp float qt_Opacity;\nsampler2D source;") + << (VertexPresent | TexCoordPresent | MatrixPresent | PropertyPresent); + + QTest::newRow("newline between") + << QByteArray("uniform\nhighp\nmat4\nqt_Matrix\n;\n" + "attribute \t\r\n highp \n vec4 \n\n qt_Vertex ;\n" + " \n attribute \n highp \n vec2 \n qt_Multi\nTexCoord0 \n ;") + << QByteArray("uniform\nsampler2D\nsource;" + "uniform lowp float qt_Opacity;") + << (VertexPresent | MatrixPresent | OpacityPresent | PropertyPresent); + + + QTest::newRow("extra characters #1") + << QByteArray("funiform highp mat4 qt_Matrix;\n" + "attribute highp vec4 qt_Vertex_;\n" + "attribute highp vec2 qqt_MultiTexCoord0;") + << QByteArray("uniformm int source;\n" + "uniform4 lowp float qt_Opacity;") + << 0; + + QTest::newRow("extra characters #2") + << QByteArray("attribute phighp vec4 qt_Vertex;\n" + "attribute highpi vec2 qt_MultiTexCoord0;" + "fattribute highp vec4 qt_Vertex;\n" + "attributed highp vec2 qt_MultiTexCoord0;") + << QByteArray(" ") + << 0; + + QTest::newRow("missing characters #1") + << QByteArray("unifor highp mat4 qt_Matrix;\n" + "attribute highp vec4 qt_Vert;\n" + "attribute highp vec2 MultiTexCoord0;") + << QByteArray("niform int source;\n" + "uniform qt_Opacity;") + << 0; + + QTest::newRow("missing characters #2") + << QByteArray("attribute high vec4 qt_Vertex;\n" + "attribute ighp vec2 qt_MultiTexCoord0;" + "tribute highp vec4 qt_Vertex;\n" + "attrib highp vec2 qt_MultiTexCoord0;") + << QByteArray(" ") + << 0; + + QTest::newRow("precision") + << QByteArray("uniform mat4 qt_Matrix;\n" + "attribute kindofhighp vec4 qt_Vertex;\n" + "attribute highp qt_MultiTexCoord0;\n") + << QByteArray("uniform lowp float qt_Opacity;\n" + "uniform mediump float source;\n") + << (MatrixPresent | OpacityPresent | PropertyPresent); + + + QTest::newRow("property name #1") + << QByteArray("uniform highp vec3 _0aA9zZ;") + << QByteArray(" ") + << int(PropertyPresent); + + QTest::newRow("property name #2") + << QByteArray("uniform mediump vec2 x86;") + << QByteArray(" ") + << int(PropertyPresent); + + QTest::newRow("property name #3") + << QByteArray("uniform lowp float X;") + << QByteArray(" ") + << int(PropertyPresent); +} + +void tst_qquickshadereffect::lookThroughShaderCode() +{ + QFETCH(QByteArray, vertexShader); + QFETCH(QByteArray, fragmentShader); + QFETCH(int, presenceFlags); + + TestShaderEffect item; + QVERIFY(!item.isConnected(SIGNAL(dummyChanged()))); // Nothing connected yet. + + QString expected; + if ((presenceFlags & VertexPresent) == 0) + expected += "Warning: Missing reference to \'qt_Vertex\'.\n"; + if ((presenceFlags & TexCoordPresent) == 0) + expected += "Warning: Missing reference to \'qt_MultiTexCoord0\'.\n"; + if ((presenceFlags & MatrixPresent) == 0) + expected += "Warning: Missing reference to \'qt_Matrix\'.\n"; + if ((presenceFlags & OpacityPresent) == 0) + expected += "Warning: Missing reference to \'qt_Opacity\'.\n"; + + item.setVertexShader(vertexShader); + item.setFragmentShader(fragmentShader); + item.ensureCompleted(); + QCOMPARE(item.parseLog(), expected); + + // If the uniform was successfully parsed, the notify signal has been connected to an update slot. + QCOMPARE(item.isConnected(SIGNAL(dummyChanged())), (presenceFlags & PropertyPresent) != 0); +} + +QTEST_MAIN(tst_qquickshadereffect) + +#include "tst_qquickshadereffect.moc" diff --git a/tests/auto/quick/qquicksmoothedanimation/data/deleteOnUpdate.qml b/tests/auto/quick/qquicksmoothedanimation/data/deleteOnUpdate.qml new file mode 100644 index 0000000000..ff8dfaa846 --- /dev/null +++ b/tests/auto/quick/qquicksmoothedanimation/data/deleteOnUpdate.qml @@ -0,0 +1,27 @@ +import QtQuick 2.0 + +Rectangle { + width: 300; height: 300; + + Rectangle { + color: "red" + width: 60; height: 60; + x: 100; y: 100; + + property real prevX: 100 + onXChanged: { + if (x - prevX > 10) { + anim.to += 5 + anim.restart(); //this can cause deletion of backend animation classes + prevX = x; + } + } + + SmoothedAnimation on x { + id: anim + objectName: "anim" + velocity: 100 + to: 150 + } + } +} diff --git a/tests/auto/quick/qquicksmoothedanimation/data/simpleanimation.qml b/tests/auto/quick/qquicksmoothedanimation/data/simpleanimation.qml new file mode 100644 index 0000000000..b2be63ec94 --- /dev/null +++ b/tests/auto/quick/qquicksmoothedanimation/data/simpleanimation.qml @@ -0,0 +1,12 @@ +import QtQuick 2.0 + +Rectangle { + width: 300; height: 300; + Rectangle { + objectName: "rect" + color: "red" + width: 60; height: 60; + x: 100; y: 100; + } + SmoothedAnimation { objectName: "anim"} +} \ No newline at end of file diff --git a/tests/auto/quick/qquicksmoothedanimation/data/smoothedanimation1.qml b/tests/auto/quick/qquicksmoothedanimation/data/smoothedanimation1.qml new file mode 100644 index 0000000000..3631f971f0 --- /dev/null +++ b/tests/auto/quick/qquicksmoothedanimation/data/smoothedanimation1.qml @@ -0,0 +1,3 @@ +import QtQuick 2.0 + +SmoothedAnimation {} diff --git a/tests/auto/quick/qquicksmoothedanimation/data/smoothedanimation2.qml b/tests/auto/quick/qquicksmoothedanimation/data/smoothedanimation2.qml new file mode 100644 index 0000000000..b07120234a --- /dev/null +++ b/tests/auto/quick/qquicksmoothedanimation/data/smoothedanimation2.qml @@ -0,0 +1,5 @@ +import QtQuick 2.0 + +SmoothedAnimation { + to: 10; duration: 300; reversingMode: SmoothedAnimation.Immediate +} diff --git a/tests/auto/quick/qquicksmoothedanimation/data/smoothedanimation3.qml b/tests/auto/quick/qquicksmoothedanimation/data/smoothedanimation3.qml new file mode 100644 index 0000000000..8d5dc4a92b --- /dev/null +++ b/tests/auto/quick/qquicksmoothedanimation/data/smoothedanimation3.qml @@ -0,0 +1,6 @@ +import QtQuick 2.0 + +SmoothedAnimation { + to: 10; velocity: 250; reversingMode: SmoothedAnimation.Sync + maximumEasingTime: 150 +} diff --git a/tests/auto/quick/qquicksmoothedanimation/data/smoothedanimationBehavior.qml b/tests/auto/quick/qquicksmoothedanimation/data/smoothedanimationBehavior.qml new file mode 100644 index 0000000000..81d36bf015 --- /dev/null +++ b/tests/auto/quick/qquicksmoothedanimation/data/smoothedanimationBehavior.qml @@ -0,0 +1,24 @@ +import QtQuick 2.0 + +Rectangle { + width: 400; height: 400; color: "blue" + + Rectangle { + id: rect1 + color: "red" + width: 60; height: 60; + x: 100; y: 100; + SmoothedAnimation on x { to: 200; velocity: 500 } + SmoothedAnimation on y { to: 200; velocity: 500 } + } + + Rectangle { + objectName: "theRect" + color: "green" + width: 60; height: 60; + x: rect1.x; y: rect1.y; + // id are needed for SmoothedAnimation in order to avoid deferred creation + Behavior on x { SmoothedAnimation { id: anim1; objectName: "easeX"; velocity: 400 } } + Behavior on y { SmoothedAnimation { id: anim2; objectName: "easeY"; velocity: 400 } } + } + } diff --git a/tests/auto/quick/qquicksmoothedanimation/data/smoothedanimationValueSource.qml b/tests/auto/quick/qquicksmoothedanimation/data/smoothedanimationValueSource.qml new file mode 100644 index 0000000000..e136df84f6 --- /dev/null +++ b/tests/auto/quick/qquicksmoothedanimation/data/smoothedanimationValueSource.qml @@ -0,0 +1,13 @@ +import QtQuick 2.0 + +Rectangle { + width: 300; height: 300; + Rectangle { + objectName: "theRect" + color: "red" + width: 60; height: 60; + x: 100; y: 100; + SmoothedAnimation on x { objectName: "easeX"; to: 200; velocity: 500 } + SmoothedAnimation on y { objectName: "easeY"; to: 200; duration: 250; velocity: 500 } + } +} diff --git a/tests/auto/quick/qquicksmoothedanimation/qquicksmoothedanimation.pro b/tests/auto/quick/qquicksmoothedanimation/qquicksmoothedanimation.pro new file mode 100644 index 0000000000..0d5567da8d --- /dev/null +++ b/tests/auto/quick/qquicksmoothedanimation/qquicksmoothedanimation.pro @@ -0,0 +1,15 @@ +CONFIG += testcase +TARGET = tst_qquicksmoothedanimation +macx:CONFIG -= app_bundle + +SOURCES += tst_qquicksmoothedanimation.cpp + +include (../../shared/util.pri) + +testDataFiles.files = data +testDataFiles.path = . +DEPLOYMENT += testDataFiles + +CONFIG += parallel_test + +QT += core-private gui-private v8-private qml-private quick-private testlib diff --git a/tests/auto/quick/qquicksmoothedanimation/tst_qquicksmoothedanimation.cpp b/tests/auto/quick/qquicksmoothedanimation/tst_qquicksmoothedanimation.cpp new file mode 100644 index 0000000000..a3e0e46f97 --- /dev/null +++ b/tests/auto/quick/qquicksmoothedanimation/tst_qquicksmoothedanimation.cpp @@ -0,0 +1,242 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include +#include +#include +#include +#include +#include +#include "../../shared/util.h" + +class tst_qquicksmoothedanimation : public QQmlDataTest +{ + Q_OBJECT +public: + tst_qquicksmoothedanimation(); + +private slots: + void defaultValues(); + void values(); + void disabled(); + void simpleAnimation(); + void valueSource(); + void behavior(); + void deleteOnUpdate(); + +private: + QQmlEngine engine; +}; + +tst_qquicksmoothedanimation::tst_qquicksmoothedanimation() +{ +} + +void tst_qquicksmoothedanimation::defaultValues() +{ + QQmlEngine engine; + QQmlComponent c(&engine, testFileUrl("smoothedanimation1.qml")); + QQuickSmoothedAnimation *obj = qobject_cast(c.create()); + + QVERIFY(obj != 0); + + QCOMPARE(obj->to(), 0.); + QCOMPARE(obj->velocity(), 200.); + QCOMPARE(obj->duration(), -1); + QCOMPARE(obj->maximumEasingTime(), -1); + QCOMPARE(obj->reversingMode(), QQuickSmoothedAnimation::Eased); + + delete obj; +} + +void tst_qquicksmoothedanimation::values() +{ + QQmlEngine engine; + QQmlComponent c(&engine, testFileUrl("smoothedanimation2.qml")); + QQuickSmoothedAnimation *obj = qobject_cast(c.create()); + + QVERIFY(obj != 0); + + QCOMPARE(obj->to(), 10.); + QCOMPARE(obj->velocity(), 200.); + QCOMPARE(obj->duration(), 300); + QCOMPARE(obj->maximumEasingTime(), -1); + QCOMPARE(obj->reversingMode(), QQuickSmoothedAnimation::Immediate); + + delete obj; +} + +void tst_qquicksmoothedanimation::disabled() +{ + QQmlEngine engine; + QQmlComponent c(&engine, testFileUrl("smoothedanimation3.qml")); + QQuickSmoothedAnimation *obj = qobject_cast(c.create()); + + QVERIFY(obj != 0); + + QCOMPARE(obj->to(), 10.); + QCOMPARE(obj->velocity(), 250.); + QCOMPARE(obj->maximumEasingTime(), 150); + QCOMPARE(obj->reversingMode(), QQuickSmoothedAnimation::Sync); + + delete obj; +} + +void tst_qquicksmoothedanimation::simpleAnimation() +{ + QQmlEngine engine; + QQmlComponent c(&engine, testFileUrl("simpleanimation.qml")); + QObject *obj = c.create(); + QVERIFY(obj); + + QQuickRectangle *rect = obj->findChild("rect"); + QVERIFY(rect); + + QQuickSmoothedAnimation *animation = obj->findChild("anim"); + QVERIFY(animation); + + animation->setTargetObject(rect); + animation->setProperty("x"); + animation->setTo(200); + animation->setDuration(250); + QVERIFY(animation->target() == rect); + QVERIFY(animation->property() == "x"); + QVERIFY(animation->to() == 200); + animation->start(); + QVERIFY(animation->isRunning()); + QTest::qWait(animation->duration()); + QTRY_COMPARE(rect->x(), qreal(200)); + QTest::qWait(100); //smoothed animation doesn't report stopped until delayed timer fires + + QVERIFY(!animation->isRunning()); + rect->setX(0); + animation->start(); + QVERIFY(animation->isRunning()); + animation->pause(); + QVERIFY(animation->isRunning()); + QVERIFY(animation->isPaused()); + animation->setCurrentTime(125); + QVERIFY(animation->currentTime() == 125); + QCOMPARE(rect->x(), qreal(100)); +} + +void tst_qquicksmoothedanimation::valueSource() +{ + QQmlEngine engine; + + QQmlComponent c(&engine, testFileUrl("smoothedanimationValueSource.qml")); + + QQuickRectangle *rect = qobject_cast(c.create()); + QVERIFY(rect); + + QQuickRectangle *theRect = rect->findChild("theRect"); + QVERIFY(theRect); + + QQuickSmoothedAnimation *easeX = rect->findChild("easeX"); + QVERIFY(easeX); + QVERIFY(easeX->isRunning()); + + QQuickSmoothedAnimation *easeY = rect->findChild("easeY"); + QVERIFY(easeY); + QVERIFY(easeY->isRunning()); + + // XXX get the proper duration + QTest::qWait(100); + + QTRY_VERIFY(!easeX->isRunning()); + QTRY_VERIFY(!easeY->isRunning()); + + QTRY_COMPARE(theRect->x(), qreal(200)); + QTRY_COMPARE(theRect->y(), qreal(200)); + + delete rect; +} + +void tst_qquicksmoothedanimation::behavior() +{ + QQmlEngine engine; + + QQmlComponent c(&engine, testFileUrl("smoothedanimationBehavior.qml")); + + QQuickRectangle *rect = qobject_cast(c.create()); + QVERIFY(rect); + + QQuickRectangle *theRect = rect->findChild("theRect"); + QVERIFY(theRect); + + QQuickSmoothedAnimation *easeX = rect->findChild("easeX"); + QVERIFY(easeX); + + QQuickSmoothedAnimation *easeY = rect->findChild("easeY"); + QVERIFY(easeY); + + // XXX get the proper duration + QTest::qWait(400); + + QTRY_VERIFY(!easeX->isRunning()); + QTRY_VERIFY(!easeY->isRunning()); + + QTRY_COMPARE(theRect->x(), qreal(200)); + QTRY_COMPARE(theRect->y(), qreal(200)); + + delete rect; +} + +void tst_qquicksmoothedanimation::deleteOnUpdate() +{ + QQmlEngine engine; + + QQmlComponent c(&engine, testFileUrl("deleteOnUpdate.qml")); + + QQuickRectangle *rect = qobject_cast(c.create()); + QVERIFY(rect); + + QQuickSmoothedAnimation *anim = rect->findChild("anim"); + QVERIFY(anim); + + //don't crash + QTest::qWait(500); + + delete rect; +} + +QTEST_MAIN(tst_qquicksmoothedanimation) + +#include "tst_qquicksmoothedanimation.moc" diff --git a/tests/auto/quick/qquickspringanimation/data/springanimation1.qml b/tests/auto/quick/qquickspringanimation/data/springanimation1.qml new file mode 100644 index 0000000000..9f52aa56c1 --- /dev/null +++ b/tests/auto/quick/qquickspringanimation/data/springanimation1.qml @@ -0,0 +1,4 @@ +import QtQuick 2.0 + +SpringAnimation { +} diff --git a/tests/auto/quick/qquickspringanimation/data/springanimation2.qml b/tests/auto/quick/qquickspringanimation/data/springanimation2.qml new file mode 100644 index 0000000000..9f72e51533 --- /dev/null +++ b/tests/auto/quick/qquickspringanimation/data/springanimation2.qml @@ -0,0 +1,16 @@ +import QtQuick 2.0 + +Item { + Item { + id: item + } + + SpringAnimation { + target: item; property: "x" + to: 1.44; velocity: 0.9 + spring: 1.0; damping: 0.5 + epsilon: 0.25; modulus: 360.0 + mass: 2.0; + running: true; + } +} diff --git a/tests/auto/quick/qquickspringanimation/data/springanimation3.qml b/tests/auto/quick/qquickspringanimation/data/springanimation3.qml new file mode 100644 index 0000000000..f4dc121eb8 --- /dev/null +++ b/tests/auto/quick/qquickspringanimation/data/springanimation3.qml @@ -0,0 +1,8 @@ +import QtQuick 2.0 + +SpringAnimation { + to: 1.44; velocity: 0.9 + spring: 1.0; damping: 0.5 + epsilon: 0.25; modulus: 360.0 + mass: 2.0; running: false +} diff --git a/tests/auto/quick/qquickspringanimation/qquickspringanimation.pro b/tests/auto/quick/qquickspringanimation/qquickspringanimation.pro new file mode 100644 index 0000000000..8ad472f8cc --- /dev/null +++ b/tests/auto/quick/qquickspringanimation/qquickspringanimation.pro @@ -0,0 +1,15 @@ +CONFIG += testcase +TARGET = tst_qquickspringanimation +macx:CONFIG -= app_bundle + +SOURCES += tst_qquickspringanimation.cpp + +include (../../shared/util.pri) + +testDataFiles.files = data +testDataFiles.path = . +DEPLOYMENT += testDataFiles + +CONFIG += parallel_test + +QT += core-private gui-private v8-private qml-private quick-private testlib diff --git a/tests/auto/quick/qquickspringanimation/tst_qquickspringanimation.cpp b/tests/auto/quick/qquickspringanimation/tst_qquickspringanimation.cpp new file mode 100644 index 0000000000..4fa512d9b6 --- /dev/null +++ b/tests/auto/quick/qquickspringanimation/tst_qquickspringanimation.cpp @@ -0,0 +1,133 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include +#include +#include +#include +#include +#include "../../shared/util.h" + +class tst_qquickspringanimation : public QQmlDataTest +{ + Q_OBJECT +public: + tst_qquickspringanimation(); + +private slots: + void defaultValues(); + void values(); + void disabled(); + +private: + QQmlEngine engine; +}; + +tst_qquickspringanimation::tst_qquickspringanimation() +{ +} + +void tst_qquickspringanimation::defaultValues() +{ + QQmlEngine engine; + QQmlComponent c(&engine, testFileUrl("springanimation1.qml")); + QQuickSpringAnimation *obj = qobject_cast(c.create()); + + QVERIFY(obj != 0); + + QCOMPARE(obj->to(), 0.); + QCOMPARE(obj->velocity(), 0.); + QCOMPARE(obj->spring(), 0.); + QCOMPARE(obj->damping(), 0.); + QCOMPARE(obj->epsilon(), 0.01); + QCOMPARE(obj->modulus(), 0.); + QCOMPARE(obj->mass(), 1.); + QCOMPARE(obj->isRunning(), false); + + delete obj; +} + +void tst_qquickspringanimation::values() +{ + QQmlEngine engine; + QQmlComponent c(&engine, testFileUrl("springanimation2.qml")); + QObject *root = c.create(); + + QQuickSpringAnimation *obj = root->findChild(); + + QVERIFY(obj != 0); + + QCOMPARE(obj->to(), 1.44); + QCOMPARE(obj->velocity(), 0.9); + QCOMPARE(obj->spring(), 1.0); + QCOMPARE(obj->damping(), 0.5); + QCOMPARE(obj->epsilon(), 0.25); + QCOMPARE(obj->modulus(), 360.0); + QCOMPARE(obj->mass(), 2.0); + QCOMPARE(obj->isRunning(), true); + + QTRY_COMPARE(obj->isRunning(), false); + + delete obj; +} + +void tst_qquickspringanimation::disabled() +{ + QQmlEngine engine; + QQmlComponent c(&engine, testFileUrl("springanimation3.qml")); + QQuickSpringAnimation *obj = qobject_cast(c.create()); + + QVERIFY(obj != 0); + + QCOMPARE(obj->to(), 1.44); + QCOMPARE(obj->velocity(), 0.9); + QCOMPARE(obj->spring(), 1.0); + QCOMPARE(obj->damping(), 0.5); + QCOMPARE(obj->epsilon(), 0.25); + QCOMPARE(obj->modulus(), 360.0); + QCOMPARE(obj->mass(), 2.0); + QCOMPARE(obj->isRunning(), false); + + delete obj; +} + +QTEST_MAIN(tst_qquickspringanimation) + +#include "tst_qquickspringanimation.moc" diff --git a/tests/auto/quick/qquickspriteimage/data/advance.qml b/tests/auto/quick/qquickspriteimage/data/advance.qml new file mode 100644 index 0000000000..46a49ca673 --- /dev/null +++ b/tests/auto/quick/qquickspriteimage/data/advance.qml @@ -0,0 +1,66 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Rectangle { + color: "black" + width: 320 + height: 320 + + SpriteImage { + objectName: "sprite" + sprites: [Sprite { + name: "firstState" + source: "squarefacesprite.png" + frames: 3 + frameSync: true + to: {"secondState":1} + }, Sprite { + name: "secondState" + source: "squarefacesprite.png" + frames: 6 + frameSync: true + } ] + width: 160 + height: 160 + } +} diff --git a/tests/auto/quick/qquickspriteimage/data/basic.qml b/tests/auto/quick/qquickspriteimage/data/basic.qml new file mode 100644 index 0000000000..2f2b1c96fa --- /dev/null +++ b/tests/auto/quick/qquickspriteimage/data/basic.qml @@ -0,0 +1,60 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Rectangle { + color: "black" + width: 320 + height: 320 + + SpriteImage { + objectName: "sprite" + sprites: Sprite { + name: "happy" + source: "squarefacesprite.png" + frames: 6 + frameDuration: 120 + } + width: 160 + height: 160 + } +} diff --git a/tests/auto/quick/qquickspriteimage/data/squarefacesprite.png b/tests/auto/quick/qquickspriteimage/data/squarefacesprite.png new file mode 100644 index 0000000000..f9a5d5fcce Binary files /dev/null and b/tests/auto/quick/qquickspriteimage/data/squarefacesprite.png differ diff --git a/tests/auto/quick/qquickspriteimage/qquickspriteimage.pro b/tests/auto/quick/qquickspriteimage/qquickspriteimage.pro new file mode 100644 index 0000000000..50613792de --- /dev/null +++ b/tests/auto/quick/qquickspriteimage/qquickspriteimage.pro @@ -0,0 +1,15 @@ +CONFIG += testcase +TARGET = tst_qquickspriteimage +SOURCES += tst_qquickspriteimage.cpp + +include (../../shared/util.pri) + +macx:CONFIG -= app_bundle + +testDataFiles.files = data +testDataFiles.path = . +DEPLOYMENT += testDataFiles + +CONFIG += parallel_test + +QT += core-private gui-private qml-private quick-private network testlib diff --git a/tests/auto/quick/qquickspriteimage/tst_qquickspriteimage.cpp b/tests/auto/quick/qquickspriteimage/tst_qquickspriteimage.cpp new file mode 100644 index 0000000000..7aff77334d --- /dev/null +++ b/tests/auto/quick/qquickspriteimage/tst_qquickspriteimage.cpp @@ -0,0 +1,98 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include +#include "../../shared/util.h" +#include +#include + +class tst_qquickspriteimage : public QQmlDataTest +{ + Q_OBJECT +public: + tst_qquickspriteimage(){} + +private slots: + void test_properties(); + void test_framerateAdvance();//Separate codepath for QQuickSpriteEngine +}; + +void tst_qquickspriteimage::test_properties() +{ + QQuickView *canvas = new QQuickView(0); + + canvas->setSource(testFileUrl("basic.qml")); + canvas->show(); + QTest::qWaitForWindowShown(canvas); + + QVERIFY(canvas->rootObject()); + QQuickSpriteImage* sprite = canvas->rootObject()->findChild("sprite"); + QVERIFY(sprite); + + QVERIFY(sprite->running()); + QVERIFY(sprite->interpolate()); + + sprite->setRunning(false); + QVERIFY(!sprite->running()); + sprite->setInterpolate(false); + QVERIFY(!sprite->interpolate()); + + delete canvas; +} + +void tst_qquickspriteimage::test_framerateAdvance() +{ + QQuickView *canvas = new QQuickView(0); + + canvas->setSource(testFileUrl("advance.qml")); + canvas->show(); + QTest::qWaitForWindowShown(canvas); + + QVERIFY(canvas->rootObject()); + QQuickSpriteImage* sprite = canvas->rootObject()->findChild("sprite"); + QVERIFY(sprite); + + QTRY_COMPARE(sprite->currentSprite(), QLatin1String("secondState")); + delete canvas; +} + +QTEST_MAIN(tst_qquickspriteimage) + +#include "tst_qquickspriteimage.moc" diff --git a/tests/auto/quick/qquickstates/data/ExtendedRectangle.qml b/tests/auto/quick/qquickstates/data/ExtendedRectangle.qml new file mode 100644 index 0000000000..1ea346b841 --- /dev/null +++ b/tests/auto/quick/qquickstates/data/ExtendedRectangle.qml @@ -0,0 +1,19 @@ +import QtQuick 2.0 +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/quick/qquickstates/data/Implementation/MyType.qml b/tests/auto/quick/qquickstates/data/Implementation/MyType.qml new file mode 100644 index 0000000000..01eb32cd4d --- /dev/null +++ b/tests/auto/quick/qquickstates/data/Implementation/MyType.qml @@ -0,0 +1,32 @@ +import QtQuick 2.0 + +Item { + Column { + anchors.centerIn: parent + Image { id: image1; objectName: "image1" } + Image { id: image2; objectName: "image2" } + Image { id: image3; objectName: "image3" } + } + + states: State { + name: "SetImageState" + PropertyChanges { + target: image1 + source: "images/qt-logo.png" + } + PropertyChanges { + target: image2 + source: "images/" + "qt-logo.png" + } + PropertyChanges { + target: image3 + source: "images/" + (true ? "qt-logo.png" : "") + } + } + + MouseArea { + anchors.fill: parent + onClicked: parent.state = "SetImageState" + } + +} diff --git a/tests/auto/quick/qquickstates/data/Implementation/images/qt-logo.png b/tests/auto/quick/qquickstates/data/Implementation/images/qt-logo.png new file mode 100644 index 0000000000..14ddf2a028 Binary files /dev/null and b/tests/auto/quick/qquickstates/data/Implementation/images/qt-logo.png differ diff --git a/tests/auto/quick/qquickstates/data/QTBUG-14830.qml b/tests/auto/quick/qquickstates/data/QTBUG-14830.qml new file mode 100644 index 0000000000..5ba7c3ad6f --- /dev/null +++ b/tests/auto/quick/qquickstates/data/QTBUG-14830.qml @@ -0,0 +1,29 @@ +import QtQuick 2.0 + +Rectangle { + width: 1024 + height: 768 + + Item { + id: area + objectName: "area" + property int numx: 6 + property int cellwidth: 1024/numx + + onWidthChanged: { + width = width>1024?1024:width; + } + + state: 'minimal' + states: [ + State { + name: 'minimal' + PropertyChanges { + target: area + width: cellwidth + } + } + ] + + } +} diff --git a/tests/auto/quick/qquickstates/data/anchorChanges1.qml b/tests/auto/quick/qquickstates/data/anchorChanges1.qml new file mode 100644 index 0000000000..378f5390f9 --- /dev/null +++ b/tests/auto/quick/qquickstates/data/anchorChanges1.qml @@ -0,0 +1,23 @@ +import QtQuick 2.0 + +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; + anchors.left: undefined + anchors.right: container.right + } + } +} diff --git a/tests/auto/quick/qquickstates/data/anchorChanges2.qml b/tests/auto/quick/qquickstates/data/anchorChanges2.qml new file mode 100644 index 0000000000..dc7f8ef0d1 --- /dev/null +++ b/tests/auto/quick/qquickstates/data/anchorChanges2.qml @@ -0,0 +1,21 @@ +import QtQuick 2.0 + +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; + anchors.left: undefined + anchors.right: parent.right + } + } +} diff --git a/tests/auto/quick/qquickstates/data/anchorChanges3.qml b/tests/auto/quick/qquickstates/data/anchorChanges3.qml new file mode 100644 index 0000000000..af49575854 --- /dev/null +++ b/tests/auto/quick/qquickstates/data/anchorChanges3.qml @@ -0,0 +1,29 @@ +import QtQuick 2.0 + +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; + anchors.left: leftGuideline.left + anchors.right: container.right + anchors.top: container.top + anchors.bottom: bottomGuideline.bottom + } + } +} diff --git a/tests/auto/quick/qquickstates/data/anchorChanges4.qml b/tests/auto/quick/qquickstates/data/anchorChanges4.qml new file mode 100644 index 0000000000..28b55818bd --- /dev/null +++ b/tests/auto/quick/qquickstates/data/anchorChanges4.qml @@ -0,0 +1,22 @@ +import QtQuick 2.0 + +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; + anchors.horizontalCenter: bottomGuideline.horizontalCenter + anchors.verticalCenter: leftGuideline.verticalCenter + } + } +} diff --git a/tests/auto/quick/qquickstates/data/anchorChanges5.qml b/tests/auto/quick/qquickstates/data/anchorChanges5.qml new file mode 100644 index 0000000000..b1ca968fb9 --- /dev/null +++ b/tests/auto/quick/qquickstates/data/anchorChanges5.qml @@ -0,0 +1,22 @@ +import QtQuick 2.0 + +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; + anchors.horizontalCenter: bottomGuideline.horizontalCenter + anchors.baseline: leftGuideline.baseline + } + } +} diff --git a/tests/auto/quick/qquickstates/data/anchorChangesCrash.qml b/tests/auto/quick/qquickstates/data/anchorChangesCrash.qml new file mode 100644 index 0000000000..9af0e4645a --- /dev/null +++ b/tests/auto/quick/qquickstates/data/anchorChangesCrash.qml @@ -0,0 +1,14 @@ +import QtQuick 2.0 + +Rectangle { + id: container + width: 400 + height: 400 + + states: State { + name: "reanchored" + AnchorChanges { + anchors.top: container.top + } + } +} diff --git a/tests/auto/quick/qquickstates/data/anchorRewindBug.qml b/tests/auto/quick/qquickstates/data/anchorRewindBug.qml new file mode 100644 index 0000000000..60c537b1ed --- /dev/null +++ b/tests/auto/quick/qquickstates/data/anchorRewindBug.qml @@ -0,0 +1,37 @@ +import QtQuick 2.0 +Rectangle { + id: container + color: "red" + height: 200 + width: 200 + Column { + id: column + objectName: "column" + anchors.left: container.right + anchors.bottom: container.bottom + + Rectangle { + id: rectangle + color: "blue" + height: 100 + width: 200 + } + Rectangle { + color: "blue" + height: 100 + width: 200 + } + } + states: State { + name: "reanchored" + AnchorChanges { + target: column + anchors.left: undefined + anchors.right: container.right + } + PropertyChanges { + target: rectangle + visible: false + } + } +} diff --git a/tests/auto/quick/qquickstates/data/anchorRewindBug2.qml b/tests/auto/quick/qquickstates/data/anchorRewindBug2.qml new file mode 100644 index 0000000000..574ef473ce --- /dev/null +++ b/tests/auto/quick/qquickstates/data/anchorRewindBug2.qml @@ -0,0 +1,25 @@ +import QtQuick 2.0 + +Rectangle { + id: root + width:200; height:300 + + Rectangle { + id: rectangle + objectName: "mover" + color: "green" + width:50; height:50 + } + + states: [ + State { + name: "anchored" + AnchorChanges { + target: rectangle + anchors.left: root.left + anchors.right: root.right + anchors.bottom: root.bottom + } + } + ] +} diff --git a/tests/auto/quick/qquickstates/data/attachedPropertyChanges.qml b/tests/auto/quick/qquickstates/data/attachedPropertyChanges.qml new file mode 100644 index 0000000000..413af2ee42 --- /dev/null +++ b/tests/auto/quick/qquickstates/data/attachedPropertyChanges.qml @@ -0,0 +1,20 @@ +import Qt.test 1.0 +import QtQuick 2.0 + +Item { + id: item + width: 100; height: 100 + MyRectangle.foo: 0 + + states: State { + name: "foo1" + PropertyChanges { + target: item + MyRectangle.foo: 1 + width: 50 + } + } + + Component.onCompleted: item.state = "foo1" +} + diff --git a/tests/auto/quick/qquickstates/data/autoStateAtStartupRestoreBug.qml b/tests/auto/quick/qquickstates/data/autoStateAtStartupRestoreBug.qml new file mode 100644 index 0000000000..6cbf524ec2 --- /dev/null +++ b/tests/auto/quick/qquickstates/data/autoStateAtStartupRestoreBug.qml @@ -0,0 +1,18 @@ +import QtQuick 2.0 + +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/quick/qquickstates/data/avoidFastForward.qml b/tests/auto/quick/qquickstates/data/avoidFastForward.qml new file mode 100644 index 0000000000..519befc31e --- /dev/null +++ b/tests/auto/quick/qquickstates/data/avoidFastForward.qml @@ -0,0 +1,17 @@ +import QtQuick 2.0 + +Rectangle { + id: rect + width: 200 + height: 200 + + property int updateCount: 0 + onColorChanged: updateCount++ + + property color aColor: "green" + + states: State { + name: "a" + PropertyChanges { target: rect; color: aColor } + } +} diff --git a/tests/auto/quick/qquickstates/data/basicBinding.qml b/tests/auto/quick/qquickstates/data/basicBinding.qml new file mode 100644 index 0000000000..59b67d0863 --- /dev/null +++ b/tests/auto/quick/qquickstates/data/basicBinding.qml @@ -0,0 +1,12 @@ +import QtQuick 2.0 +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/quick/qquickstates/data/basicBinding2.qml b/tests/auto/quick/qquickstates/data/basicBinding2.qml new file mode 100644 index 0000000000..55f88120aa --- /dev/null +++ b/tests/auto/quick/qquickstates/data/basicBinding2.qml @@ -0,0 +1,12 @@ +import QtQuick 2.0 +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/quick/qquickstates/data/basicBinding3.qml b/tests/auto/quick/qquickstates/data/basicBinding3.qml new file mode 100644 index 0000000000..361ab0b091 --- /dev/null +++ b/tests/auto/quick/qquickstates/data/basicBinding3.qml @@ -0,0 +1,13 @@ +import QtQuick 2.0 +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/quick/qquickstates/data/basicBinding4.qml b/tests/auto/quick/qquickstates/data/basicBinding4.qml new file mode 100644 index 0000000000..b29f0fcf22 --- /dev/null +++ b/tests/auto/quick/qquickstates/data/basicBinding4.qml @@ -0,0 +1,17 @@ +import QtQuick 2.0 +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/quick/qquickstates/data/basicChanges.qml b/tests/auto/quick/qquickstates/data/basicChanges.qml new file mode 100644 index 0000000000..3e2b73acde --- /dev/null +++ b/tests/auto/quick/qquickstates/data/basicChanges.qml @@ -0,0 +1,10 @@ +import QtQuick 2.0 +Rectangle { + id: myRectangle + width: 100; height: 100 + color: "red" + states: State { + name: "blue" + PropertyChanges { target: myRectangle; color: "blue" } + } +} diff --git a/tests/auto/quick/qquickstates/data/basicChanges2.qml b/tests/auto/quick/qquickstates/data/basicChanges2.qml new file mode 100644 index 0000000000..5ff46cc60c --- /dev/null +++ b/tests/auto/quick/qquickstates/data/basicChanges2.qml @@ -0,0 +1,15 @@ +import QtQuick 2.0 +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/quick/qquickstates/data/basicChanges3.qml b/tests/auto/quick/qquickstates/data/basicChanges3.qml new file mode 100644 index 0000000000..e46e98f75e --- /dev/null +++ b/tests/auto/quick/qquickstates/data/basicChanges3.qml @@ -0,0 +1,15 @@ +import QtQuick 2.0 +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/quick/qquickstates/data/basicChanges4.qml b/tests/auto/quick/qquickstates/data/basicChanges4.qml new file mode 100644 index 0000000000..7da1e0fb2e --- /dev/null +++ b/tests/auto/quick/qquickstates/data/basicChanges4.qml @@ -0,0 +1,19 @@ +import Qt.test 1.0 +import QtQuick 2.0 + +MyRectangle { + id: rect + width: 100; height: 100 + color: "red" + + states: State { + name: "aBlueDay" + PropertyChanges { + target: rect + onPropertyWithNotifyChanged: { rect.color = "blue"; } + } + } + + Component.onCompleted: rect.state = "aBlueDay" +} + diff --git a/tests/auto/quick/qquickstates/data/basicExtension.qml b/tests/auto/quick/qquickstates/data/basicExtension.qml new file mode 100644 index 0000000000..00f5fee287 --- /dev/null +++ b/tests/auto/quick/qquickstates/data/basicExtension.qml @@ -0,0 +1,16 @@ +import QtQuick 2.0 +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/quick/qquickstates/data/deleting.qml b/tests/auto/quick/qquickstates/data/deleting.qml new file mode 100644 index 0000000000..b8e8d33c17 --- /dev/null +++ b/tests/auto/quick/qquickstates/data/deleting.qml @@ -0,0 +1,11 @@ +import QtQuick 2.0 +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/quick/qquickstates/data/deletingState.qml b/tests/auto/quick/qquickstates/data/deletingState.qml new file mode 100644 index 0000000000..68a9c2a24d --- /dev/null +++ b/tests/auto/quick/qquickstates/data/deletingState.qml @@ -0,0 +1,13 @@ +import QtQuick 2.0 +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/quick/qquickstates/data/editProperties.qml b/tests/auto/quick/qquickstates/data/editProperties.qml new file mode 100644 index 0000000000..9bff3657ba --- /dev/null +++ b/tests/auto/quick/qquickstates/data/editProperties.qml @@ -0,0 +1,34 @@ +import QtQuick 2.0 +Rectangle { + id: myRectangle + + property color sourceColor: "blue" + width: 400; height: 400 + color: "red" + + Rectangle { + id: rect2 + objectName: "rect2" + width: parent.width + 2 + height: 200 + color: "yellow" + } + + states: [ + State { + name: "blue" + PropertyChanges { + target: rect2 + width:50 + height: 40 + } + }, + State { + name: "green" + PropertyChanges { + target: rect2 + width: myRectangle.width / 2 + height: myRectangle.width / 4 + } + }] +} diff --git a/tests/auto/quick/qquickstates/data/explicit.qml b/tests/auto/quick/qquickstates/data/explicit.qml new file mode 100644 index 0000000000..d09893a1db --- /dev/null +++ b/tests/auto/quick/qquickstates/data/explicit.qml @@ -0,0 +1,15 @@ +import QtQuick 2.0 +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/quick/qquickstates/data/extendsBug.qml b/tests/auto/quick/qquickstates/data/extendsBug.qml new file mode 100644 index 0000000000..573341520d --- /dev/null +++ b/tests/auto/quick/qquickstates/data/extendsBug.qml @@ -0,0 +1,26 @@ +import QtQuick 2.0 + +Rectangle { + width: 200 + height: 200 + + Rectangle { + id: rect + objectName: "greenRect" + width: 100 + height: 100 + color: "green" + } + + states:[ + State { + name: "a" + PropertyChanges { target: rect; x: 100 } + }, + State { + name: "b" + extend:"a" + PropertyChanges { target: rect; y: 100 } + } + ] +} diff --git a/tests/auto/quick/qquickstates/data/fakeExtension.qml b/tests/auto/quick/qquickstates/data/fakeExtension.qml new file mode 100644 index 0000000000..6a5c7003f6 --- /dev/null +++ b/tests/auto/quick/qquickstates/data/fakeExtension.qml @@ -0,0 +1,16 @@ +import QtQuick 2.0 +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/quick/qquickstates/data/illegalObj.qml b/tests/auto/quick/qquickstates/data/illegalObj.qml new file mode 100644 index 0000000000..a2bbd5d32b --- /dev/null +++ b/tests/auto/quick/qquickstates/data/illegalObj.qml @@ -0,0 +1,12 @@ +import QtQuick 2.0 + +Rectangle { + id: myItem + + states : State { + PropertyChanges { + target: myItem + children: Item { id: newItem } + } + } +} diff --git a/tests/auto/quick/qquickstates/data/illegalTempState.qml b/tests/auto/quick/qquickstates/data/illegalTempState.qml new file mode 100644 index 0000000000..9cb39c0728 --- /dev/null +++ b/tests/auto/quick/qquickstates/data/illegalTempState.qml @@ -0,0 +1,21 @@ +import QtQuick 2.0 + +Rectangle { + id: card + width: 100; height: 100 + + states: [ + State { + name: "placed" + PropertyChanges { target: card; state: "idle" } + }, + State { + name: "idle" + } + ] + + MouseArea { + anchors.fill: parent + onClicked: card.state = "placed" + } +} diff --git a/tests/auto/quick/qquickstates/data/image.png b/tests/auto/quick/qquickstates/data/image.png new file mode 100644 index 0000000000..ed1833c95b Binary files /dev/null and b/tests/auto/quick/qquickstates/data/image.png differ diff --git a/tests/auto/quick/qquickstates/data/legalTempState.qml b/tests/auto/quick/qquickstates/data/legalTempState.qml new file mode 100644 index 0000000000..a93860f5cc --- /dev/null +++ b/tests/auto/quick/qquickstates/data/legalTempState.qml @@ -0,0 +1,23 @@ +import QtQuick 2.0 + +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") } + } + ] + + MouseArea { + anchors.fill: parent + onClicked: card.state = "placed" + } +} diff --git a/tests/auto/quick/qquickstates/data/nonExistantProp.qml b/tests/auto/quick/qquickstates/data/nonExistantProp.qml new file mode 100644 index 0000000000..ce502699bb --- /dev/null +++ b/tests/auto/quick/qquickstates/data/nonExistantProp.qml @@ -0,0 +1,11 @@ +import QtQuick 2.0 +Rectangle { + id: myRectangle + + width: 100; height: 100 + color: "red" + states: State { + name: "blue" + PropertyChanges { target: myRectangle; colr: "blue" } + } +} diff --git a/tests/auto/quick/qquickstates/data/parentChange1.qml b/tests/auto/quick/qquickstates/data/parentChange1.qml new file mode 100644 index 0000000000..663ad1a264 --- /dev/null +++ b/tests/auto/quick/qquickstates/data/parentChange1.qml @@ -0,0 +1,37 @@ +import QtQuick 2.0 + +Rectangle { + width: 400; height: 400 + Item { + x: 10; y: 10 + Rectangle { + id: myRect + objectName: "MyRect" + x: 5 + width: 100; height: 100 + color: "red" + } + } + MouseArea { + 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/quick/qquickstates/data/parentChange2.qml b/tests/auto/quick/qquickstates/data/parentChange2.qml new file mode 100644 index 0000000000..ae290e961e --- /dev/null +++ b/tests/auto/quick/qquickstates/data/parentChange2.qml @@ -0,0 +1,31 @@ +import QtQuick 2.0 + +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" + } + } + MouseArea { + id: clickable + anchors.fill: parent + } + + states: State { + name: "reparented" + when: clickable.pressed + ParentChange { + target: myRect + parent: newParent + } + } +} diff --git a/tests/auto/quick/qquickstates/data/parentChange3.qml b/tests/auto/quick/qquickstates/data/parentChange3.qml new file mode 100644 index 0000000000..46665cb4c8 --- /dev/null +++ b/tests/auto/quick/qquickstates/data/parentChange3.qml @@ -0,0 +1,42 @@ +import QtQuick 2.0 + +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" + } + } + MouseArea { + 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/quick/qquickstates/data/parentChange4.qml b/tests/auto/quick/qquickstates/data/parentChange4.qml new file mode 100644 index 0000000000..22de72f8c9 --- /dev/null +++ b/tests/auto/quick/qquickstates/data/parentChange4.qml @@ -0,0 +1,30 @@ +import QtQuick 2.0 + +Rectangle { + width: 400; height: 400 + Rectangle { + id: myRect + objectName: "MyRect" + x: 5; y: 5 + width: 100; height: 100 + color: "red" + } + MouseArea { + id: clickable + anchors.fill: parent + } + + Item { + id: newParent + transform: Scale { xScale: .5; yScale: .7} + } + + states: State { + name: "reparented" + when: clickable.pressed + ParentChange { + target: myRect + parent: newParent + } + } +} diff --git a/tests/auto/quick/qquickstates/data/parentChange5.qml b/tests/auto/quick/qquickstates/data/parentChange5.qml new file mode 100644 index 0000000000..c353d2637f --- /dev/null +++ b/tests/auto/quick/qquickstates/data/parentChange5.qml @@ -0,0 +1,30 @@ +import QtQuick 2.0 + +Rectangle { + width: 400; height: 400 + Rectangle { + id: myRect + objectName: "MyRect" + x: 5; y: 5 + width: 100; height: 100 + color: "red" + } + MouseArea { + id: clickable + anchors.fill: parent + } + + Item { + id: newParent + 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/quick/qquickstates/data/parentChange6.qml b/tests/auto/quick/qquickstates/data/parentChange6.qml new file mode 100644 index 0000000000..b373dbba20 --- /dev/null +++ b/tests/auto/quick/qquickstates/data/parentChange6.qml @@ -0,0 +1,30 @@ +import QtQuick 2.0 + +Rectangle { + width: 400; height: 400 + Rectangle { + id: myRect + objectName: "MyRect" + x: 5; y: 5 + width: 100; height: 100 + color: "red" + } + MouseArea { + id: clickable + anchors.fill: parent + } + + Item { + id: newParent + rotation: 180 + } + + states: State { + name: "reparented" + when: clickable.pressed + ParentChange { + target: myRect + parent: newParent + } + } +} diff --git a/tests/auto/quick/qquickstates/data/propertyErrors.qml b/tests/auto/quick/qquickstates/data/propertyErrors.qml new file mode 100644 index 0000000000..ddd636493d --- /dev/null +++ b/tests/auto/quick/qquickstates/data/propertyErrors.qml @@ -0,0 +1,10 @@ +import QtQuick 2.0 +Rectangle { + id: myRectangle + width: 100; height: 100 + color: "red" + states: State { + name: "blue" + PropertyChanges { target: myRectangle; colr: "blue"; activeFocus: true } + } +} diff --git a/tests/auto/quick/qquickstates/data/reset.qml b/tests/auto/quick/qquickstates/data/reset.qml new file mode 100644 index 0000000000..f0ecab0950 --- /dev/null +++ b/tests/auto/quick/qquickstates/data/reset.qml @@ -0,0 +1,19 @@ +import QtQuick 2.0 + +Rectangle { + width: 640 + height: 480 + Image { + id: image + width: 40 + source: "image.png" + } + + states: State { + name: "state1" + PropertyChanges { + target: image + width: undefined + } + } +} diff --git a/tests/auto/quick/qquickstates/data/restoreEntryValues.qml b/tests/auto/quick/qquickstates/data/restoreEntryValues.qml new file mode 100644 index 0000000000..950a522841 --- /dev/null +++ b/tests/auto/quick/qquickstates/data/restoreEntryValues.qml @@ -0,0 +1,14 @@ +import QtQuick 2.0 +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/quick/qquickstates/data/returnToBase.qml b/tests/auto/quick/qquickstates/data/returnToBase.qml new file mode 100644 index 0000000000..9a0ee82397 --- /dev/null +++ b/tests/auto/quick/qquickstates/data/returnToBase.qml @@ -0,0 +1,21 @@ +import QtQuick 2.0 + +Rectangle { + id: theRect + property bool triggerState: false + property string stateString: "" + states: [ State { + when: triggerState + PropertyChanges { + target: theRect + stateString: "inState" + } + }, + State { + name: "" + PropertyChanges { + target: theRect + stateString: "originalState" + } + }] +} diff --git a/tests/auto/quick/qquickstates/data/revertListBug.qml b/tests/auto/quick/qquickstates/data/revertListBug.qml new file mode 100644 index 0000000000..fbc4bc5ecc --- /dev/null +++ b/tests/auto/quick/qquickstates/data/revertListBug.qml @@ -0,0 +1,47 @@ +import QtQuick 2.0 + +Rectangle { + width: 400; height: 400 + + property Item targetItem: rect1 + + function switchTargetItem() { + if (targetItem === rect1) + targetItem = rect2; + else + targetItem = rect1; + } + + states: State { + name: "reparented" + ParentChange { + target: targetItem + parent: newParent + x: 0; y: 0 + } + } + + Item { + objectName: "originalParent1" + Rectangle { + id: rect1; objectName: "rect1" + width: 50; height: 50 + color: "green" + } + } + + Item { + objectName: "originalParent2" + Rectangle { + id: rect2; objectName: "rect2" + x: 50; y: 50 + width: 50; height: 50 + color: "green" + } + } + + Item { + id: newParent; objectName: "newParent" + x: 200; y: 100 + } +} diff --git a/tests/auto/quick/qquickstates/data/script.qml b/tests/auto/quick/qquickstates/data/script.qml new file mode 100644 index 0000000000..218f0fae74 --- /dev/null +++ b/tests/auto/quick/qquickstates/data/script.qml @@ -0,0 +1,10 @@ +import QtQuick 2.0 +Rectangle { + id: myRectangle + width: 100; height: 100 + color: "red" + states: State { + name: "blue" + StateChangeScript { script: myRectangle.color = "blue"; } + } +} diff --git a/tests/auto/quick/qquickstates/data/signalOverride.qml b/tests/auto/quick/qquickstates/data/signalOverride.qml new file mode 100644 index 0000000000..9ab8037e51 --- /dev/null +++ b/tests/auto/quick/qquickstates/data/signalOverride.qml @@ -0,0 +1,18 @@ +import QtQuick 2.0 +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/quick/qquickstates/data/signalOverride2.qml b/tests/auto/quick/qquickstates/data/signalOverride2.qml new file mode 100644 index 0000000000..4e5e335b8b --- /dev/null +++ b/tests/auto/quick/qquickstates/data/signalOverride2.qml @@ -0,0 +1,9 @@ +import QtQuick 2.0 +import Qt.test 1.0 + +MyRectangle { + id: rect + onDidSomething: color = "blue" + width: 100; height: 100 + ExtendedRectangle {} +} diff --git a/tests/auto/quick/qquickstates/data/signalOverrideCrash.qml b/tests/auto/quick/qquickstates/data/signalOverrideCrash.qml new file mode 100644 index 0000000000..3e2ae1e93d --- /dev/null +++ b/tests/auto/quick/qquickstates/data/signalOverrideCrash.qml @@ -0,0 +1,15 @@ +import QtQuick 2.0 +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/quick/qquickstates/data/signalOverrideCrash2.qml b/tests/auto/quick/qquickstates/data/signalOverrideCrash2.qml new file mode 100644 index 0000000000..3937874aa2 --- /dev/null +++ b/tests/auto/quick/qquickstates/data/signalOverrideCrash2.qml @@ -0,0 +1,24 @@ +import QtQuick 2.0 + +Rectangle { + id: myRect + width: 400 + height: 400 + + states: [ + State { + name: "state1" + PropertyChanges { + target: myRect + onHeightChanged: console.log("Hello World") + color: "green" + } + }, + State { + name: "state2"; extend: "state1" + PropertyChanges { + target: myRect + color: "red" + } + }] +} diff --git a/tests/auto/quick/qquickstates/data/signalOverrideCrash3.qml b/tests/auto/quick/qquickstates/data/signalOverrideCrash3.qml new file mode 100644 index 0000000000..98d4c57219 --- /dev/null +++ b/tests/auto/quick/qquickstates/data/signalOverrideCrash3.qml @@ -0,0 +1,27 @@ +import QtQuick 2.0 + +Rectangle { + id: myRect + width: 400 + height: 400 + + onHeightChanged: console.log("base state") + + states: [ + State { + name: "state1" + PropertyChanges { + target: myRect + onHeightChanged: console.log("state1") + color: "green" + } + }, + State { + name: "state2"; + PropertyChanges { + target: myRect + onHeightChanged: console.log("state2") + color: "red" + } + }] +} diff --git a/tests/auto/quick/qquickstates/data/unnamedWhen.qml b/tests/auto/quick/qquickstates/data/unnamedWhen.qml new file mode 100644 index 0000000000..35eacff07b --- /dev/null +++ b/tests/auto/quick/qquickstates/data/unnamedWhen.qml @@ -0,0 +1,14 @@ +import QtQuick 2.0 + +Rectangle { + id: theRect + property bool triggerState: false + property string stateString: "" + states: State { + when: triggerState + PropertyChanges { + target: theRect + stateString: "inState" + } + } +} diff --git a/tests/auto/quick/qquickstates/data/urlResolution.qml b/tests/auto/quick/qquickstates/data/urlResolution.qml new file mode 100644 index 0000000000..516ac034d6 --- /dev/null +++ b/tests/auto/quick/qquickstates/data/urlResolution.qml @@ -0,0 +1,12 @@ +import QtQuick 2.0 +import "Implementation" + +Rectangle { + width: 100 + height: 200 + + MyType { + objectName: "MyType" + anchors.fill: parent + } +} diff --git a/tests/auto/quick/qquickstates/data/whenOrdering.qml b/tests/auto/quick/qquickstates/data/whenOrdering.qml new file mode 100644 index 0000000000..92025a2054 --- /dev/null +++ b/tests/auto/quick/qquickstates/data/whenOrdering.qml @@ -0,0 +1,11 @@ +import QtQuick 2.0 + +Rectangle { + property bool condition1: false + property bool condition2: false + + states: [ + State { name: "state1"; when: condition1 }, + State { name: "state2"; when: condition2 } + ] +} diff --git a/tests/auto/quick/qquickstates/qquickstates.pro b/tests/auto/quick/qquickstates/qquickstates.pro new file mode 100644 index 0000000000..ec881680ea --- /dev/null +++ b/tests/auto/quick/qquickstates/qquickstates.pro @@ -0,0 +1,14 @@ +CONFIG += testcase +TARGET = tst_qquickstates +macx:CONFIG -= app_bundle + +SOURCES += tst_qquickstates.cpp + +include (../../shared/util.pri) + +testDataFiles.files = data +testDataFiles.path = . +DEPLOYMENT += testDataFiles + +CONFIG += parallel_test +QT += core-private gui-private v8-private qml-private quick-private opengl-private testlib diff --git a/tests/auto/quick/qquickstates/tst_qquickstates.cpp b/tests/auto/quick/qquickstates/tst_qquickstates.cpp new file mode 100644 index 0000000000..fc8194f6ca --- /dev/null +++ b/tests/auto/quick/qquickstates/tst_qquickstates.cpp @@ -0,0 +1,1608 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "../../shared/util.h" + +class MyAttached : public QObject +{ + Q_OBJECT + Q_PROPERTY(int foo READ foo WRITE setFoo) +public: + MyAttached(QObject *parent) : QObject(parent), m_foo(13) {} + + int foo() const { return m_foo; } + void setFoo(int f) { m_foo = f; } + +private: + int m_foo; +}; + +class MyRect : public QQuickRectangle +{ + Q_OBJECT + Q_PROPERTY(int propertyWithNotify READ propertyWithNotify WRITE setPropertyWithNotify NOTIFY oddlyNamedNotifySignal) +public: + MyRect() {} + + void doSomething() { emit didSomething(); } + + int propertyWithNotify() const { return m_prop; } + void setPropertyWithNotify(int i) { m_prop = i; emit oddlyNamedNotifySignal(); } + + static MyAttached *qmlAttachedProperties(QObject *o) { + return new MyAttached(o); + } +Q_SIGNALS: + void didSomething(); + void oddlyNamedNotifySignal(); + +private: + int m_prop; +}; + +QML_DECLARE_TYPE(MyRect) +QML_DECLARE_TYPEINFO(MyRect, QML_HAS_ATTACHED_PROPERTIES) + +class tst_qquickstates : public QQmlDataTest +{ + Q_OBJECT +public: + tst_qquickstates() {} + +private: + QByteArray fullDataPath(const QString &path) const; + +private slots: + void initTestCase(); + + void basicChanges(); + void attachedPropertyChanges(); + void basicExtension(); + void basicBinding(); + void signalOverride(); + void signalOverrideCrash(); + void signalOverrideCrash2(); + void signalOverrideCrash3(); + void parentChange(); + void parentChangeErrors(); + void anchorChanges(); + void anchorChanges2(); + void anchorChanges3(); + void anchorChanges4(); + void anchorChanges5(); + void anchorChangesRTL(); + void anchorChangesRTL2(); + void anchorChangesRTL3(); + void anchorChangesCrash(); + void anchorRewindBug(); + void anchorRewindBug2(); + void script(); + void restoreEntryValues(); + void explicitChanges(); + void propertyErrors(); + void incorrectRestoreBug(); + void autoStateAtStartupRestoreBug(); + void deletingChange(); + void deletingState(); + void tempState(); + void illegalTempState(); + void nonExistantProperty(); + void reset(); + void illegalObjectCreation(); + void whenOrdering(); + void urlResolution(); + void unnamedWhen(); + void returnToBase(); + void extendsBug(); + void editProperties(); + void QTBUG_14830(); + void avoidFastForward(); + void revertListBug(); +}; + +void tst_qquickstates::initTestCase() +{ + QQmlDataTest::initTestCase(); + qmlRegisterType("Qt.test", 1, 0, "MyRectangle"); +} + +QByteArray tst_qquickstates::fullDataPath(const QString &path) const +{ + return testFileUrl(path).toString().toUtf8(); +} + +void tst_qquickstates::basicChanges() +{ + QQmlEngine engine; + + { + QQmlComponent rectComponent(&engine, testFileUrl("basicChanges.qml")); + QQuickRectangle *rect = qobject_cast(rectComponent.create()); + QQuickItemPrivate *rectPrivate = QQuickItemPrivate::get(rect); + QVERIFY(rect != 0); + + QCOMPARE(rect->color(),QColor("red")); + + rectPrivate->setState("blue"); + QCOMPARE(rect->color(),QColor("blue")); + + rectPrivate->setState(""); + QCOMPARE(rect->color(),QColor("red")); + } + + { + QQmlComponent rectComponent(&engine, testFileUrl("basicChanges2.qml")); + QQuickRectangle *rect = qobject_cast(rectComponent.create()); + QQuickItemPrivate *rectPrivate = QQuickItemPrivate::get(rect); + QVERIFY(rect != 0); + + QCOMPARE(rect->color(),QColor("red")); + + rectPrivate->setState("blue"); + QCOMPARE(rect->color(),QColor("blue")); + + rectPrivate->setState("green"); + QCOMPARE(rect->color(),QColor("green")); + + rectPrivate->setState(""); + QCOMPARE(rect->color(),QColor("red")); + + rectPrivate->setState("green"); + QCOMPARE(rect->color(),QColor("green")); + } + + { + QQmlComponent rectComponent(&engine, testFileUrl("basicChanges3.qml")); + QQuickRectangle *rect = qobject_cast(rectComponent.create()); + QQuickItemPrivate *rectPrivate = QQuickItemPrivate::get(rect); + QVERIFY(rect != 0); + + QCOMPARE(rect->color(),QColor("red")); + QCOMPARE(rect->border()->width(),1.0); + + rectPrivate->setState("blue"); + QCOMPARE(rect->color(),QColor("blue")); + QCOMPARE(rect->border()->width(),1.0); + + rectPrivate->setState("bordered"); + QCOMPARE(rect->color(),QColor("red")); + QCOMPARE(rect->border()->width(),2.0); + + rectPrivate->setState(""); + QCOMPARE(rect->color(),QColor("red")); + QCOMPARE(rect->border()->width(),1.0); + //### we should be checking that this is an implicit rather than explicit 1 (which currently fails) + + rectPrivate->setState("bordered"); + QCOMPARE(rect->color(),QColor("red")); + QCOMPARE(rect->border()->width(),2.0); + + rectPrivate->setState("blue"); + QCOMPARE(rect->color(),QColor("blue")); + QCOMPARE(rect->border()->width(),1.0); + + } + + { + // Test basicChanges4.qml can magically connect to propertyWithNotify's notify + // signal using 'onPropertyWithNotifyChanged' even though the signal name is + // actually 'oddlyNamedNotifySignal' + + QQmlComponent component(&engine, testFileUrl("basicChanges4.qml")); + QVERIFY(component.isReady()); + + MyRect *rect = qobject_cast(component.create()); + QVERIFY(rect != 0); + + QMetaProperty prop = rect->metaObject()->property(rect->metaObject()->indexOfProperty("propertyWithNotify")); + QVERIFY(prop.hasNotifySignal()); + QString notifySignal = QByteArray(prop.notifySignal().signature()); + QVERIFY(!notifySignal.startsWith("propertyWithNotifyChanged(")); + + QCOMPARE(rect->color(), QColor(Qt::red)); + + rect->setPropertyWithNotify(100); + QCOMPARE(rect->color(), QColor(Qt::blue)); + } +} + +void tst_qquickstates::attachedPropertyChanges() +{ + QQmlEngine engine; + + QQmlComponent component(&engine, testFileUrl("attachedPropertyChanges.qml")); + QVERIFY(component.isReady()); + + QQuickItem *item = qobject_cast(component.create()); + QVERIFY(item != 0); + QCOMPARE(item->width(), 50.0); + + // Ensure attached property has been changed + QObject *attObj = qmlAttachedPropertiesObject(item, false); + QVERIFY(attObj); + + MyAttached *att = qobject_cast(attObj); + QVERIFY(att); + + QCOMPARE(att->foo(), 1); +} + +void tst_qquickstates::basicExtension() +{ + QQmlEngine engine; + + { + QQmlComponent rectComponent(&engine, testFileUrl("basicExtension.qml")); + QQuickRectangle *rect = qobject_cast(rectComponent.create()); + QQuickItemPrivate *rectPrivate = QQuickItemPrivate::get(rect); + QVERIFY(rect != 0); + + QCOMPARE(rect->color(),QColor("red")); + QCOMPARE(rect->border()->width(),1.0); + + rectPrivate->setState("blue"); + QCOMPARE(rect->color(),QColor("blue")); + QCOMPARE(rect->border()->width(),1.0); + + rectPrivate->setState("bordered"); + QCOMPARE(rect->color(),QColor("blue")); + QCOMPARE(rect->border()->width(),2.0); + + rectPrivate->setState("blue"); + QCOMPARE(rect->color(),QColor("blue")); + QCOMPARE(rect->border()->width(),1.0); + + rectPrivate->setState(""); + QCOMPARE(rect->color(),QColor("red")); + QCOMPARE(rect->border()->width(),1.0); + + rectPrivate->setState("bordered"); + QCOMPARE(rect->color(),QColor("blue")); + QCOMPARE(rect->border()->width(),2.0); + + rectPrivate->setState(""); + QCOMPARE(rect->color(),QColor("red")); + QCOMPARE(rect->border()->width(),1.0); + } + + { + QQmlComponent rectComponent(&engine, testFileUrl("fakeExtension.qml")); + QQuickRectangle *rect = qobject_cast(rectComponent.create()); + QQuickItemPrivate *rectPrivate = QQuickItemPrivate::get(rect); + QVERIFY(rect != 0); + + QCOMPARE(rect->color(),QColor("red")); + + rectPrivate->setState("blue"); + QCOMPARE(rect->color(),QColor("blue")); + + rectPrivate->setState("green"); + QCOMPARE(rect->color(),QColor("green")); + + rectPrivate->setState("blue"); + QCOMPARE(rect->color(),QColor("blue")); + + rectPrivate->setState("green"); + QCOMPARE(rect->color(),QColor("green")); + + rectPrivate->setState(""); + QCOMPARE(rect->color(),QColor("red")); + + rectPrivate->setState("green"); + QCOMPARE(rect->color(),QColor("green")); + } +} + +void tst_qquickstates::basicBinding() +{ + QQmlEngine engine; + + { + QQmlComponent rectComponent(&engine, testFileUrl("basicBinding.qml")); + QQuickRectangle *rect = qobject_cast(rectComponent.create()); + QQuickItemPrivate *rectPrivate = QQuickItemPrivate::get(rect); + QVERIFY(rect != 0); + + QCOMPARE(rect->color(),QColor("red")); + + rectPrivate->setState("blue"); + QCOMPARE(rect->color(),QColor("blue")); + + rectPrivate->setState(""); + QCOMPARE(rect->color(),QColor("red")); + + rectPrivate->setState("blue"); + QCOMPARE(rect->color(),QColor("blue")); + rect->setProperty("sourceColor", QColor("green")); + QCOMPARE(rect->color(),QColor("green")); + + rectPrivate->setState(""); + QCOMPARE(rect->color(),QColor("red")); + rect->setProperty("sourceColor", QColor("yellow")); + QCOMPARE(rect->color(),QColor("red")); + + rectPrivate->setState("blue"); + QCOMPARE(rect->color(),QColor("yellow")); + } + + { + QQmlComponent rectComponent(&engine, testFileUrl("basicBinding2.qml")); + QQuickRectangle *rect = qobject_cast(rectComponent.create()); + QQuickItemPrivate *rectPrivate = QQuickItemPrivate::get(rect); + QVERIFY(rect != 0); + + QCOMPARE(rect->color(),QColor("red")); + + rectPrivate->setState("blue"); + QCOMPARE(rect->color(),QColor("blue")); + + rectPrivate->setState(""); + QCOMPARE(rect->color(),QColor("red")); + + rectPrivate->setState("blue"); + QCOMPARE(rect->color(),QColor("blue")); + rect->setProperty("sourceColor", QColor("green")); + QCOMPARE(rect->color(),QColor("blue")); + + rectPrivate->setState(""); + QCOMPARE(rect->color(),QColor("green")); + rect->setProperty("sourceColor", QColor("yellow")); + QCOMPARE(rect->color(),QColor("yellow")); + + rectPrivate->setState("blue"); + QCOMPARE(rect->color(),QColor("blue")); + + rectPrivate->setState(""); + QCOMPARE(rect->color(),QColor("yellow")); + } + + { + QQmlComponent rectComponent(&engine, testFileUrl("basicBinding3.qml")); + QQuickRectangle *rect = qobject_cast(rectComponent.create()); + QQuickItemPrivate *rectPrivate = QQuickItemPrivate::get(rect); + QVERIFY(rect != 0); + + QCOMPARE(rect->color(),QColor("red")); + rect->setProperty("sourceColor", QColor("green")); + QCOMPARE(rect->color(),QColor("green")); + + rectPrivate->setState("blue"); + QCOMPARE(rect->color(),QColor("blue")); + rect->setProperty("sourceColor", QColor("red")); + QCOMPARE(rect->color(),QColor("blue")); + rect->setProperty("sourceColor2", QColor("yellow")); + QCOMPARE(rect->color(),QColor("yellow")); + + rectPrivate->setState(""); + QCOMPARE(rect->color(),QColor("red")); + rect->setProperty("sourceColor2", QColor("green")); + QCOMPARE(rect->color(),QColor("red")); + rect->setProperty("sourceColor", QColor("yellow")); + QCOMPARE(rect->color(),QColor("yellow")); + } + + { + QQmlComponent rectComponent(&engine, testFileUrl("basicBinding4.qml")); + QQuickRectangle *rect = qobject_cast(rectComponent.create()); + QQuickItemPrivate *rectPrivate = QQuickItemPrivate::get(rect); + QVERIFY(rect != 0); + + QCOMPARE(rect->color(),QColor("red")); + + rectPrivate->setState("blue"); + QCOMPARE(rect->color(),QColor("blue")); + rect->setProperty("sourceColor", QColor("yellow")); + QCOMPARE(rect->color(),QColor("yellow")); + + rectPrivate->setState("green"); + QCOMPARE(rect->color(),QColor("green")); + rect->setProperty("sourceColor", QColor("purple")); + QCOMPARE(rect->color(),QColor("green")); + + rectPrivate->setState("blue"); + QCOMPARE(rect->color(),QColor("purple")); + + rectPrivate->setState("green"); + QCOMPARE(rect->color(),QColor("green")); + + rectPrivate->setState(""); + QCOMPARE(rect->color(),QColor("red")); + } +} + +void tst_qquickstates::signalOverride() +{ + QQmlEngine engine; + + { + QQmlComponent rectComponent(&engine, testFileUrl("signalOverride.qml")); + MyRect *rect = qobject_cast(rectComponent.create()); + QVERIFY(rect != 0); + + QCOMPARE(rect->color(),QColor("red")); + rect->doSomething(); + QCOMPARE(rect->color(),QColor("blue")); + + QQuickItemPrivate::get(rect)->setState("green"); + rect->doSomething(); + QCOMPARE(rect->color(),QColor("green")); + } + + { + QQmlComponent rectComponent(&engine, testFileUrl("signalOverride2.qml")); + MyRect *rect = qobject_cast(rectComponent.create()); + QVERIFY(rect != 0); + + QCOMPARE(rect->color(),QColor("white")); + rect->doSomething(); + QCOMPARE(rect->color(),QColor("blue")); + + QQuickRectangle *innerRect = qobject_cast(rect->findChild("extendedRect")); + QQuickItemPrivate::get(innerRect)->setState("green"); + rect->doSomething(); + QCOMPARE(rect->color(),QColor("blue")); + QCOMPARE(innerRect->color(),QColor("green")); + QCOMPARE(innerRect->property("extendedColor").value(),QColor("green")); + } +} + +void tst_qquickstates::signalOverrideCrash() +{ + QQmlEngine engine; + + QQmlComponent rectComponent(&engine, testFileUrl("signalOverrideCrash.qml")); + MyRect *rect = qobject_cast(rectComponent.create()); + QVERIFY(rect != 0); + + QQuickItemPrivate::get(rect)->setState("overridden"); + rect->doSomething(); +} + +void tst_qquickstates::signalOverrideCrash2() +{ + QQmlEngine engine; + + QQmlComponent rectComponent(&engine, testFileUrl("signalOverrideCrash2.qml")); + QQuickRectangle *rect = qobject_cast(rectComponent.create()); + QVERIFY(rect != 0); + + QQuickItemPrivate::get(rect)->setState("state1"); + QQuickItemPrivate::get(rect)->setState("state2"); + QQuickItemPrivate::get(rect)->setState("state1"); + + delete rect; +} + +void tst_qquickstates::signalOverrideCrash3() +{ + QQmlEngine engine; + + QQmlComponent rectComponent(&engine, testFileUrl("signalOverrideCrash3.qml")); + QQuickRectangle *rect = qobject_cast(rectComponent.create()); + QVERIFY(rect != 0); + + QQuickItemPrivate::get(rect)->setState("state1"); + QQuickItemPrivate::get(rect)->setState(""); + QQuickItemPrivate::get(rect)->setState("state2"); + QQuickItemPrivate::get(rect)->setState(""); + + delete rect; +} + +void tst_qquickstates::parentChange() +{ + QQmlEngine engine; + + { + QQmlComponent rectComponent(&engine, testFileUrl("parentChange1.qml")); + QQuickRectangle *rect = qobject_cast(rectComponent.create()); + QVERIFY(rect != 0); + + QQuickRectangle *innerRect = qobject_cast(rect->findChild("MyRect")); + QVERIFY(innerRect != 0); + + QQmlListReference list(rect, "states"); + QQuickState *state = qobject_cast(list.at(0)); + QVERIFY(state != 0); + + qmlExecuteDeferred(state); + QQuickParentChange *pChange = qobject_cast(state->operationAt(0)); + QVERIFY(pChange != 0); + QQuickItem *nParent = qobject_cast(rect->findChild("NewParent")); + QVERIFY(nParent != 0); + + QCOMPARE(pChange->parent(), nParent); + + QQuickItemPrivate::get(rect)->setState("reparented"); + QCOMPARE(innerRect->rotation(), qreal(0)); + QCOMPARE(innerRect->scale(), qreal(1)); + QCOMPARE(innerRect->x(), qreal(-133)); + QCOMPARE(innerRect->y(), qreal(-300)); + } + + { + QQmlComponent rectComponent(&engine, testFileUrl("parentChange2.qml")); + QQuickRectangle *rect = qobject_cast(rectComponent.create()); + QVERIFY(rect != 0); + QQuickItemPrivate *rectPrivate = QQuickItemPrivate::get(rect); + QQuickRectangle *innerRect = qobject_cast(rect->findChild("MyRect")); + QVERIFY(innerRect != 0); + + rectPrivate->setState("reparented"); + QCOMPARE(innerRect->rotation(), qreal(15)); + QCOMPARE(innerRect->scale(), qreal(.5)); + QCOMPARE(QString("%1").arg(innerRect->x()), QString("%1").arg(-19.9075)); + QCOMPARE(QString("%1").arg(innerRect->y()), QString("%1").arg(-8.73433)); + } + + { + QQmlComponent rectComponent(&engine, testFileUrl("parentChange3.qml")); + QQuickRectangle *rect = qobject_cast(rectComponent.create()); + QVERIFY(rect != 0); + QQuickItemPrivate *rectPrivate = QQuickItemPrivate::get(rect); + QQuickRectangle *innerRect = qobject_cast(rect->findChild("MyRect")); + QVERIFY(innerRect != 0); + + rectPrivate->setState("reparented"); + QCOMPARE(innerRect->rotation(), qreal(-37)); + QCOMPARE(innerRect->scale(), qreal(.25)); + QCOMPARE(QString("%1").arg(innerRect->x()), QString("%1").arg(-217.305)); + QCOMPARE(QString("%1").arg(innerRect->y()), QString("%1").arg(-164.413)); + + rectPrivate->setState(""); + QCOMPARE(innerRect->rotation(), qreal(0)); + QCOMPARE(innerRect->scale(), qreal(1)); + QCOMPARE(innerRect->x(), qreal(5)); + //do a non-qFuzzyCompare fuzzy compare + QVERIFY(innerRect->y() < qreal(0.00001) && innerRect->y() > qreal(-0.00001)); + } + + { + QQmlComponent rectComponent(&engine, testFileUrl("parentChange6.qml")); + QQuickRectangle *rect = qobject_cast(rectComponent.create()); + QVERIFY(rect != 0); + + QQuickRectangle *innerRect = qobject_cast(rect->findChild("MyRect")); + QVERIFY(innerRect != 0); + + QQuickItemPrivate::get(rect)->setState("reparented"); + QCOMPARE(innerRect->rotation(), qreal(180)); + QCOMPARE(innerRect->scale(), qreal(1)); + QCOMPARE(innerRect->x(), qreal(-105)); + QCOMPARE(innerRect->y(), qreal(-105)); + } +} + +void tst_qquickstates::parentChangeErrors() +{ + QQmlEngine engine; + + { + QQmlComponent rectComponent(&engine, testFileUrl("parentChange4.qml")); + QQuickRectangle *rect = qobject_cast(rectComponent.create()); + QVERIFY(rect != 0); + + QQuickRectangle *innerRect = qobject_cast(rect->findChild("MyRect")); + QVERIFY(innerRect != 0); + + QTest::ignoreMessage(QtWarningMsg, fullDataPath("parentChange4.qml") + ":25:9: QML ParentChange: Unable to preserve appearance under non-uniform scale"); + QQuickItemPrivate::get(rect)->setState("reparented"); + QCOMPARE(innerRect->rotation(), qreal(0)); + QCOMPARE(innerRect->scale(), qreal(1)); + QCOMPARE(innerRect->x(), qreal(5)); + QCOMPARE(innerRect->y(), qreal(5)); + } + + { + QQmlComponent rectComponent(&engine, testFileUrl("parentChange5.qml")); + QQuickRectangle *rect = qobject_cast(rectComponent.create()); + QVERIFY(rect != 0); + + QQuickRectangle *innerRect = qobject_cast(rect->findChild("MyRect")); + QVERIFY(innerRect != 0); + + QTest::ignoreMessage(QtWarningMsg, fullDataPath("parentChange5.qml") + ":25:9: QML ParentChange: Unable to preserve appearance under complex transform"); + QQuickItemPrivate::get(rect)->setState("reparented"); + QCOMPARE(innerRect->rotation(), qreal(0)); + QCOMPARE(innerRect->scale(), qreal(1)); + QCOMPARE(innerRect->x(), qreal(5)); + QCOMPARE(innerRect->y(), qreal(5)); + } +} + +void tst_qquickstates::anchorChanges() +{ + QQmlEngine engine; + + QQmlComponent rectComponent(&engine, testFileUrl("anchorChanges1.qml")); + QQuickRectangle *rect = qobject_cast(rectComponent.create()); + QVERIFY(rect != 0); + QQuickItemPrivate *rectPrivate = QQuickItemPrivate::get(rect); + + QQuickRectangle *innerRect = qobject_cast(rect->findChild("MyRect")); + QVERIFY(innerRect != 0); + + QQmlListReference list(rect, "states"); + QQuickState *state = qobject_cast(list.at(0)); + QVERIFY(state != 0); + + qmlExecuteDeferred(state); + QQuickAnchorChanges *aChanges = qobject_cast(state->operationAt(0)); + QVERIFY(aChanges != 0); + + QCOMPARE(aChanges->anchors()->left().script(), QLatin1String("undefined")); + QCOMPARE(aChanges->anchors()->right().script(), QLatin1String("container.right")); + + rectPrivate->setState("right"); + QCOMPARE(innerRect->x(), qreal(150)); + QCOMPARE(aChanges->object(), qobject_cast(innerRect)); + QCOMPARE(QQuickItemPrivate::get(aChanges->object())->anchors()->left().anchorLine, QQuickAnchorLine::Invalid); //### was reset (how do we distinguish from not set at all) + QCOMPARE(QQuickItemPrivate::get(aChanges->object())->anchors()->right().item, rectPrivate->right().item); + QCOMPARE(QQuickItemPrivate::get(aChanges->object())->anchors()->right().anchorLine, rectPrivate->right().anchorLine); + + rectPrivate->setState(""); + QCOMPARE(innerRect->x(), qreal(5)); + + delete rect; +} + +void tst_qquickstates::anchorChanges2() +{ + QQmlEngine engine; + + QQmlComponent rectComponent(&engine, testFileUrl("anchorChanges2.qml")); + QQuickRectangle *rect = qobject_cast(rectComponent.create()); + QVERIFY(rect != 0); + QQuickItemPrivate *rectPrivate = QQuickItemPrivate::get(rect); + + QQuickRectangle *innerRect = qobject_cast(rect->findChild("MyRect")); + QVERIFY(innerRect != 0); + + rectPrivate->setState("right"); + QCOMPARE(innerRect->x(), qreal(150)); + + rectPrivate->setState(""); + QCOMPARE(innerRect->x(), qreal(5)); + + delete rect; +} + +void tst_qquickstates::anchorChanges3() +{ + QQmlEngine engine; + + QQmlComponent rectComponent(&engine, testFileUrl("anchorChanges3.qml")); + QQuickRectangle *rect = qobject_cast(rectComponent.create()); + QVERIFY(rect != 0); + QQuickItemPrivate *rectPrivate = QQuickItemPrivate::get(rect); + + QQuickRectangle *innerRect = qobject_cast(rect->findChild("MyRect")); + QVERIFY(innerRect != 0); + + QQuickItem *leftGuideline = qobject_cast(rect->findChild("LeftGuideline")); + QVERIFY(leftGuideline != 0); + + QQuickItem *bottomGuideline = qobject_cast(rect->findChild("BottomGuideline")); + QVERIFY(bottomGuideline != 0); + + QQmlListReference list(rect, "states"); + QQuickState *state = qobject_cast(list.at(0)); + QVERIFY(state != 0); + + qmlExecuteDeferred(state); + QQuickAnchorChanges *aChanges = qobject_cast(state->operationAt(0)); + QVERIFY(aChanges != 0); + + QCOMPARE(aChanges->anchors()->top().script(), QLatin1String("container.top")); + QCOMPARE(aChanges->anchors()->bottom().script(), QLatin1String("bottomGuideline.bottom")); + + rectPrivate->setState("reanchored"); + QCOMPARE(aChanges->object(), qobject_cast(innerRect)); + QCOMPARE(QQuickItemPrivate::get(aChanges->object())->anchors()->left().item, QQuickItemPrivate::get(leftGuideline)->left().item); + QCOMPARE(QQuickItemPrivate::get(aChanges->object())->anchors()->left().anchorLine, QQuickItemPrivate::get(leftGuideline)->left().anchorLine); + QCOMPARE(QQuickItemPrivate::get(aChanges->object())->anchors()->right().item, rectPrivate->right().item); + QCOMPARE(QQuickItemPrivate::get(aChanges->object())->anchors()->right().anchorLine, rectPrivate->right().anchorLine); + QCOMPARE(QQuickItemPrivate::get(aChanges->object())->anchors()->top().item, rectPrivate->top().item); + QCOMPARE(QQuickItemPrivate::get(aChanges->object())->anchors()->top().anchorLine, rectPrivate->top().anchorLine); + QCOMPARE(QQuickItemPrivate::get(aChanges->object())->anchors()->bottom().item, QQuickItemPrivate::get(bottomGuideline)->bottom().item); + QCOMPARE(QQuickItemPrivate::get(aChanges->object())->anchors()->bottom().anchorLine, QQuickItemPrivate::get(bottomGuideline)->bottom().anchorLine); + + QCOMPARE(innerRect->x(), qreal(10)); + QCOMPARE(innerRect->y(), qreal(0)); + QCOMPARE(innerRect->width(), qreal(190)); + QCOMPARE(innerRect->height(), qreal(150)); + + rectPrivate->setState(""); + QCOMPARE(innerRect->x(), qreal(0)); + QCOMPARE(innerRect->y(), qreal(10)); + QCOMPARE(innerRect->width(), qreal(150)); + QCOMPARE(innerRect->height(), qreal(190)); + + delete rect; +} + +void tst_qquickstates::anchorChanges4() +{ + QQmlEngine engine; + + QQmlComponent rectComponent(&engine, testFileUrl("anchorChanges4.qml")); + QQuickRectangle *rect = qobject_cast(rectComponent.create()); + QVERIFY(rect != 0); + + QQuickRectangle *innerRect = qobject_cast(rect->findChild("MyRect")); + QVERIFY(innerRect != 0); + + QQuickItem *leftGuideline = qobject_cast(rect->findChild("LeftGuideline")); + QVERIFY(leftGuideline != 0); + + QQuickItem *bottomGuideline = qobject_cast(rect->findChild("BottomGuideline")); + QVERIFY(bottomGuideline != 0); + + QQmlListReference list(rect, "states"); + QQuickState *state = qobject_cast(list.at(0)); + QVERIFY(state != 0); + + qmlExecuteDeferred(state); + QQuickAnchorChanges *aChanges = qobject_cast(state->operationAt(0)); + QVERIFY(aChanges != 0); + + QCOMPARE(aChanges->anchors()->horizontalCenter().script(), QLatin1String("bottomGuideline.horizontalCenter")); + QCOMPARE(aChanges->anchors()->verticalCenter().script(), QLatin1String("leftGuideline.verticalCenter")); + + QQuickItemPrivate::get(rect)->setState("reanchored"); + QCOMPARE(aChanges->object(), qobject_cast(innerRect)); + QCOMPARE(QQuickItemPrivate::get(aChanges->object())->anchors()->horizontalCenter().item, QQuickItemPrivate::get(bottomGuideline)->horizontalCenter().item); + QCOMPARE(QQuickItemPrivate::get(aChanges->object())->anchors()->horizontalCenter().anchorLine, QQuickItemPrivate::get(bottomGuideline)->horizontalCenter().anchorLine); + QCOMPARE(QQuickItemPrivate::get(aChanges->object())->anchors()->verticalCenter().item, QQuickItemPrivate::get(leftGuideline)->verticalCenter().item); + QCOMPARE(QQuickItemPrivate::get(aChanges->object())->anchors()->verticalCenter().anchorLine, QQuickItemPrivate::get(leftGuideline)->verticalCenter().anchorLine); + + delete rect; +} + +void tst_qquickstates::anchorChanges5() +{ + QQmlEngine engine; + + QQmlComponent rectComponent(&engine, testFileUrl("anchorChanges5.qml")); + QQuickRectangle *rect = qobject_cast(rectComponent.create()); + QVERIFY(rect != 0); + + QQuickRectangle *innerRect = qobject_cast(rect->findChild("MyRect")); + QVERIFY(innerRect != 0); + + QQuickItem *leftGuideline = qobject_cast(rect->findChild("LeftGuideline")); + QVERIFY(leftGuideline != 0); + + QQuickItem *bottomGuideline = qobject_cast(rect->findChild("BottomGuideline")); + QVERIFY(bottomGuideline != 0); + + QQmlListReference list(rect, "states"); + QQuickState *state = qobject_cast(list.at(0)); + QVERIFY(state != 0); + + qmlExecuteDeferred(state); + QQuickAnchorChanges *aChanges = qobject_cast(state->operationAt(0)); + QVERIFY(aChanges != 0); + + QCOMPARE(aChanges->anchors()->baseline().script(), QLatin1String("leftGuideline.baseline")); + + QQuickItemPrivate::get(rect)->setState("reanchored"); + QCOMPARE(aChanges->object(), qobject_cast(innerRect)); + QCOMPARE(QQuickItemPrivate::get(aChanges->object())->anchors()->horizontalCenter().item, QQuickItemPrivate::get(bottomGuideline)->horizontalCenter().item); + QCOMPARE(QQuickItemPrivate::get(aChanges->object())->anchors()->horizontalCenter().anchorLine, QQuickItemPrivate::get(bottomGuideline)->horizontalCenter().anchorLine); + QCOMPARE(QQuickItemPrivate::get(aChanges->object())->anchors()->baseline().item, QQuickItemPrivate::get(leftGuideline)->baseline().item); + QCOMPARE(QQuickItemPrivate::get(aChanges->object())->anchors()->baseline().anchorLine, QQuickItemPrivate::get(leftGuideline)->baseline().anchorLine); + + delete rect; +} + +void mirrorAnchors(QQuickItem *item) { + QQuickItemPrivate *itemPrivate = QQuickItemPrivate::get(item); + itemPrivate->setLayoutMirror(true); +} + +qreal offsetRTL(QQuickItem *anchorItem, QQuickItem *item) { + return anchorItem->width()+2*anchorItem->x()-item->width(); +} + +void tst_qquickstates::anchorChangesRTL() +{ + QQmlEngine engine; + + QQmlComponent rectComponent(&engine, testFileUrl("anchorChanges1.qml")); + QQuickRectangle *rect = qobject_cast(rectComponent.create()); + QVERIFY(rect != 0); + QQuickItemPrivate *rectPrivate = QQuickItemPrivate::get(rect); + + QQuickRectangle *innerRect = qobject_cast(rect->findChild("MyRect")); + QVERIFY(innerRect != 0); + mirrorAnchors(innerRect); + + QQmlListReference list(rect, "states"); + QQuickState *state = qobject_cast(list.at(0)); + QVERIFY(state != 0); + + qmlExecuteDeferred(state); + QQuickAnchorChanges *aChanges = qobject_cast(state->operationAt(0)); + QVERIFY(aChanges != 0); + + rectPrivate->setState("right"); + QCOMPARE(innerRect->x(), offsetRTL(rect, innerRect) - qreal(150)); + QCOMPARE(aChanges->object(), qobject_cast(innerRect)); + QCOMPARE(QQuickItemPrivate::get(aChanges->object())->anchors()->left().anchorLine, QQuickAnchorLine::Invalid); //### was reset (how do we distinguish from not set at all) + QCOMPARE(QQuickItemPrivate::get(aChanges->object())->anchors()->right().item, rectPrivate->right().item); + QCOMPARE(QQuickItemPrivate::get(aChanges->object())->anchors()->right().anchorLine, rectPrivate->right().anchorLine); + + rectPrivate->setState(""); + QCOMPARE(innerRect->x(), offsetRTL(rect, innerRect) -qreal(5)); + + delete rect; +} + +void tst_qquickstates::anchorChangesRTL2() +{ + QQmlEngine engine; + + QQmlComponent rectComponent(&engine, testFileUrl("anchorChanges2.qml")); + QQuickRectangle *rect = qobject_cast(rectComponent.create()); + QVERIFY(rect != 0); + QQuickItemPrivate *rectPrivate = QQuickItemPrivate::get(rect); + + QQuickRectangle *innerRect = qobject_cast(rect->findChild("MyRect")); + QVERIFY(innerRect != 0); + mirrorAnchors(innerRect); + + rectPrivate->setState("right"); + QCOMPARE(innerRect->x(), offsetRTL(rect, innerRect) - qreal(150)); + + rectPrivate->setState(""); + QCOMPARE(innerRect->x(), offsetRTL(rect, innerRect) - qreal(5)); + + delete rect; +} + +void tst_qquickstates::anchorChangesRTL3() +{ + QQmlEngine engine; + + QQmlComponent rectComponent(&engine, testFileUrl("anchorChanges3.qml")); + QQuickRectangle *rect = qobject_cast(rectComponent.create()); + QVERIFY(rect != 0); + QQuickItemPrivate *rectPrivate = QQuickItemPrivate::get(rect); + + QQuickRectangle *innerRect = qobject_cast(rect->findChild("MyRect")); + QVERIFY(innerRect != 0); + mirrorAnchors(innerRect); + + QQuickItem *leftGuideline = qobject_cast(rect->findChild("LeftGuideline")); + QVERIFY(leftGuideline != 0); + + QQuickItem *bottomGuideline = qobject_cast(rect->findChild("BottomGuideline")); + QVERIFY(bottomGuideline != 0); + + QQmlListReference list(rect, "states"); + QQuickState *state = qobject_cast(list.at(0)); + QVERIFY(state != 0); + + qmlExecuteDeferred(state); + QQuickAnchorChanges *aChanges = qobject_cast(state->operationAt(0)); + QVERIFY(aChanges != 0); + + rectPrivate->setState("reanchored"); + QCOMPARE(aChanges->object(), qobject_cast(innerRect)); + QCOMPARE(QQuickItemPrivate::get(aChanges->object())->anchors()->left().item, QQuickItemPrivate::get(leftGuideline)->left().item); + QCOMPARE(QQuickItemPrivate::get(aChanges->object())->anchors()->left().anchorLine, QQuickItemPrivate::get(leftGuideline)->left().anchorLine); + QCOMPARE(QQuickItemPrivate::get(aChanges->object())->anchors()->right().item, rectPrivate->right().item); + QCOMPARE(QQuickItemPrivate::get(aChanges->object())->anchors()->right().anchorLine, rectPrivate->right().anchorLine); + QCOMPARE(QQuickItemPrivate::get(aChanges->object())->anchors()->top().item, rectPrivate->top().item); + QCOMPARE(QQuickItemPrivate::get(aChanges->object())->anchors()->top().anchorLine, rectPrivate->top().anchorLine); + QCOMPARE(QQuickItemPrivate::get(aChanges->object())->anchors()->bottom().item, QQuickItemPrivate::get(bottomGuideline)->bottom().item); + QCOMPARE(QQuickItemPrivate::get(aChanges->object())->anchors()->bottom().anchorLine, QQuickItemPrivate::get(bottomGuideline)->bottom().anchorLine); + + QCOMPARE(innerRect->x(), offsetRTL(leftGuideline, innerRect) - qreal(10)); + QCOMPARE(innerRect->y(), qreal(0)); + // between left side of parent and leftGuideline.x: 10, which has width 0 + QCOMPARE(innerRect->width(), qreal(10)); + QCOMPARE(innerRect->height(), qreal(150)); + + rectPrivate->setState(""); + QCOMPARE(innerRect->x(), offsetRTL(rect, innerRect) - qreal(0)); + QCOMPARE(innerRect->y(), qreal(10)); + // between right side of parent and left side of rightGuideline.x: 150, which has width 0 + QCOMPARE(innerRect->width(), qreal(50)); + QCOMPARE(innerRect->height(), qreal(190)); + + delete rect; +} + +//QTBUG-9609 +void tst_qquickstates::anchorChangesCrash() +{ + QQmlEngine engine; + + QQmlComponent rectComponent(&engine, testFileUrl("anchorChangesCrash.qml")); + QQuickRectangle *rect = qobject_cast(rectComponent.create()); + QVERIFY(rect != 0); + + QQuickItemPrivate::get(rect)->setState("reanchored"); + + delete rect; +} + +// QTBUG-12273 +void tst_qquickstates::anchorRewindBug() +{ + QQuickView *view = new QQuickView; + view->setSource(testFileUrl("anchorRewindBug.qml")); + + view->show(); + view->requestActivateWindow(); + + QTest::qWaitForWindowShown(view); + + QQuickRectangle *rect = qobject_cast(view->rootObject()); + QVERIFY(rect != 0); + + QQuickItem * column = rect->findChild("column"); + + QVERIFY(column != 0); + QVERIFY(!QQuickItemPrivate::get(column)->heightValid); + QVERIFY(!QQuickItemPrivate::get(column)->widthValid); + QCOMPARE(column->height(), 200.0); + QQuickItemPrivate::get(rect)->setState("reanchored"); + + // column height and width should stay implicit + // and column's implicit resizing should still work + QVERIFY(!QQuickItemPrivate::get(column)->heightValid); + QVERIFY(!QQuickItemPrivate::get(column)->widthValid); + QTRY_COMPARE(column->height(), 100.0); + + QQuickItemPrivate::get(rect)->setState(""); + + // column height and width should stay implicit + // and column's implicit resizing should still work + QVERIFY(!QQuickItemPrivate::get(column)->heightValid); + QVERIFY(!QQuickItemPrivate::get(column)->widthValid); + QTRY_COMPARE(column->height(), 200.0); + + delete view; +} + +// QTBUG-11834 +void tst_qquickstates::anchorRewindBug2() +{ + QQmlEngine engine; + + QQmlComponent rectComponent(&engine, testFileUrl("anchorRewindBug2.qml")); + QQuickRectangle *rect = qobject_cast(rectComponent.create()); + QVERIFY(rect != 0); + + QQuickRectangle *mover = rect->findChild("mover"); + + QVERIFY(mover != 0); + QCOMPARE(mover->y(), qreal(0.0)); + QCOMPARE(mover->width(), qreal(50.0)); + + QQuickItemPrivate::get(rect)->setState("anchored"); + QCOMPARE(mover->y(), qreal(250.0)); + QCOMPARE(mover->width(), qreal(200.0)); + + QQuickItemPrivate::get(rect)->setState(""); + QCOMPARE(mover->y(), qreal(0.0)); + QCOMPARE(mover->width(), qreal(50.0)); + + delete rect; +} + +void tst_qquickstates::script() +{ + QQmlEngine engine; + + { + QQmlComponent rectComponent(&engine, testFileUrl("script.qml")); + QQuickRectangle *rect = qobject_cast(rectComponent.create()); + QVERIFY(rect != 0); + QQuickItemPrivate *rectPrivate = QQuickItemPrivate::get(rect); + QCOMPARE(rect->color(),QColor("red")); + + rectPrivate->setState("blue"); + QCOMPARE(rect->color(),QColor("blue")); + + rectPrivate->setState(""); + QCOMPARE(rect->color(),QColor("blue")); // a script isn't reverted + } +} + +void tst_qquickstates::restoreEntryValues() +{ + QQmlEngine engine; + + QQmlComponent rectComponent(&engine, testFileUrl("restoreEntryValues.qml")); + QQuickRectangle *rect = qobject_cast(rectComponent.create()); + QVERIFY(rect != 0); + QQuickItemPrivate *rectPrivate = QQuickItemPrivate::get(rect); + QCOMPARE(rect->color(),QColor("red")); + + rectPrivate->setState("blue"); + QCOMPARE(rect->color(),QColor("blue")); + + rectPrivate->setState(""); + QCOMPARE(rect->color(),QColor("blue")); +} + +void tst_qquickstates::explicitChanges() +{ + QQmlEngine engine; + + QQmlComponent rectComponent(&engine, testFileUrl("explicit.qml")); + QQuickRectangle *rect = qobject_cast(rectComponent.create()); + QVERIFY(rect != 0); + QQuickItemPrivate *rectPrivate = QQuickItemPrivate::get(rect); + QQmlListReference list(rect, "states"); + QQuickState *state = qobject_cast(list.at(0)); + QVERIFY(state != 0); + + qmlExecuteDeferred(state); + QQuickPropertyChanges *changes = qobject_cast(rect->findChild("changes")); + QVERIFY(changes != 0); + QVERIFY(changes->isExplicit()); + + QCOMPARE(rect->color(),QColor("red")); + + rectPrivate->setState("blue"); + QCOMPARE(rect->color(),QColor("blue")); + + rect->setProperty("sourceColor", QColor("green")); + QCOMPARE(rect->color(),QColor("blue")); + + rectPrivate->setState(""); + QCOMPARE(rect->color(),QColor("red")); + rect->setProperty("sourceColor", QColor("yellow")); + QCOMPARE(rect->color(),QColor("red")); + + rectPrivate->setState("blue"); + QCOMPARE(rect->color(),QColor("yellow")); +} + +void tst_qquickstates::propertyErrors() +{ + QQmlEngine engine; + QQmlComponent rectComponent(&engine, testFileUrl("propertyErrors.qml")); + QQuickRectangle *rect = qobject_cast(rectComponent.create()); + QVERIFY(rect != 0); + + QCOMPARE(rect->color(),QColor("red")); + + QTest::ignoreMessage(QtWarningMsg, fullDataPath("propertyErrors.qml") + ":8:9: QML PropertyChanges: Cannot assign to non-existent property \"colr\""); + QTest::ignoreMessage(QtWarningMsg, fullDataPath("propertyErrors.qml") + ":8:9: QML PropertyChanges: Cannot assign to read-only property \"activeFocus\""); + QQuickItemPrivate::get(rect)->setState("blue"); +} + +void tst_qquickstates::incorrectRestoreBug() +{ + QQmlEngine engine; + + QQmlComponent rectComponent(&engine, testFileUrl("basicChanges.qml")); + QQuickRectangle *rect = qobject_cast(rectComponent.create()); + QVERIFY(rect != 0); + QQuickItemPrivate *rectPrivate = QQuickItemPrivate::get(rect); + QCOMPARE(rect->color(),QColor("red")); + + rectPrivate->setState("blue"); + QCOMPARE(rect->color(),QColor("blue")); + + rectPrivate->setState(""); + QCOMPARE(rect->color(),QColor("red")); + + // make sure if we change the base state value, we then restore to it correctly + rect->setColor(QColor("green")); + + rectPrivate->setState("blue"); + QCOMPARE(rect->color(),QColor("blue")); + + rectPrivate->setState(""); + QCOMPARE(rect->color(),QColor("green")); +} + +void tst_qquickstates::autoStateAtStartupRestoreBug() +{ + QQmlEngine engine; + + QQmlComponent component(&engine, testFileUrl("autoStateAtStartupRestoreBug.qml")); + QObject *obj = component.create(); + + QVERIFY(obj != 0); + QCOMPARE(obj->property("test").toInt(), 3); + + obj->setProperty("input", 2); + + QCOMPARE(obj->property("test").toInt(), 9); + + delete obj; +} + +void tst_qquickstates::deletingChange() +{ + QQmlEngine engine; + + QQmlComponent rectComponent(&engine, testFileUrl("deleting.qml")); + QQuickRectangle *rect = qobject_cast(rectComponent.create()); + QVERIFY(rect != 0); + QQuickItemPrivate *rectPrivate = QQuickItemPrivate::get(rect); + rectPrivate->setState("blue"); + QCOMPARE(rect->color(),QColor("blue")); + QCOMPARE(rect->radius(),qreal(5)); + + rectPrivate->setState(""); + QCOMPARE(rect->color(),QColor("red")); + QCOMPARE(rect->radius(),qreal(0)); + + QQuickPropertyChanges *pc = rect->findChild("pc1"); + QVERIFY(pc != 0); + delete pc; + + QQuickState *state = rect->findChild(); + QVERIFY(state != 0); + qmlExecuteDeferred(state); + QCOMPARE(state->operationCount(), 1); + + rectPrivate->setState("blue"); + QCOMPARE(rect->color(),QColor("red")); + QCOMPARE(rect->radius(),qreal(5)); + + delete rect; +} + +void tst_qquickstates::deletingState() +{ + QQmlEngine engine; + + QQmlComponent rectComponent(&engine, testFileUrl("deletingState.qml")); + QQuickRectangle *rect = qobject_cast(rectComponent.create()); + QVERIFY(rect != 0); + + QQuickStateGroup *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")); + + QQuickState *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_qquickstates::tempState() +{ + QQmlEngine engine; + + QQmlComponent rectComponent(&engine, testFileUrl("legalTempState.qml")); + QQuickRectangle *rect = qobject_cast(rectComponent.create()); + QVERIFY(rect != 0); + QQuickItemPrivate *rectPrivate = QQuickItemPrivate::get(rect); + QTest::ignoreMessage(QtDebugMsg, "entering placed"); + QTest::ignoreMessage(QtDebugMsg, "entering idle"); + rectPrivate->setState("placed"); + QCOMPARE(rectPrivate->state(), QLatin1String("idle")); +} + +void tst_qquickstates::illegalTempState() +{ + QQmlEngine engine; + + QQmlComponent rectComponent(&engine, testFileUrl("illegalTempState.qml")); + QQuickRectangle *rect = qobject_cast(rectComponent.create()); + QVERIFY(rect != 0); + QQuickItemPrivate *rectPrivate = QQuickItemPrivate::get(rect); + QTest::ignoreMessage(QtWarningMsg, ": QML StateGroup: Can't apply a state change as part of a state definition."); + rectPrivate->setState("placed"); + QCOMPARE(rectPrivate->state(), QLatin1String("placed")); +} + +void tst_qquickstates::nonExistantProperty() +{ + QQmlEngine engine; + + QQmlComponent rectComponent(&engine, testFileUrl("nonExistantProp.qml")); + QQuickRectangle *rect = qobject_cast(rectComponent.create()); + QVERIFY(rect != 0); + QQuickItemPrivate *rectPrivate = QQuickItemPrivate::get(rect); + QTest::ignoreMessage(QtWarningMsg, fullDataPath("nonExistantProp.qml") + ":9:9: QML PropertyChanges: Cannot assign to non-existent property \"colr\""); + rectPrivate->setState("blue"); + QCOMPARE(rectPrivate->state(), QLatin1String("blue")); +} + +void tst_qquickstates::reset() +{ + QQmlEngine engine; + + QQmlComponent c(&engine, testFileUrl("reset.qml")); + QQuickRectangle *rect = qobject_cast(c.create()); + QVERIFY(rect != 0); + + QQuickImage *image = rect->findChild(); + QVERIFY(image != 0); + QCOMPARE(image->width(), qreal(40.)); + QCOMPARE(image->height(), qreal(20.)); + + QQuickItemPrivate::get(rect)->setState("state1"); + + QCOMPARE(image->width(), 20.0); + QCOMPARE(image->height(), qreal(20.)); + + delete rect; +} + +void tst_qquickstates::illegalObjectCreation() +{ + QQmlEngine engine; + + QQmlComponent component(&engine, testFileUrl("illegalObj.qml")); + QList errors = component.errors(); + QVERIFY(errors.count() == 1); + const QQmlError &error = errors.at(0); + QCOMPARE(error.line(), 9); + QCOMPARE(error.column(), 23); + QCOMPARE(error.description().toUtf8().constData(), "PropertyChanges does not support creating state-specific objects."); +} + +void tst_qquickstates::whenOrdering() +{ + QQmlEngine engine; + + QQmlComponent c(&engine, testFileUrl("whenOrdering.qml")); + QQuickRectangle *rect = qobject_cast(c.create()); + QVERIFY(rect != 0); + QQuickItemPrivate *rectPrivate = QQuickItemPrivate::get(rect); + + QCOMPARE(rectPrivate->state(), QLatin1String("")); + rect->setProperty("condition2", true); + QCOMPARE(rectPrivate->state(), QLatin1String("state2")); + rect->setProperty("condition1", true); + QCOMPARE(rectPrivate->state(), QLatin1String("state1")); + rect->setProperty("condition2", false); + QCOMPARE(rectPrivate->state(), QLatin1String("state1")); + rect->setProperty("condition2", true); + QCOMPARE(rectPrivate->state(), QLatin1String("state1")); + rect->setProperty("condition1", false); + rect->setProperty("condition2", false); + QCOMPARE(rectPrivate->state(), QLatin1String("")); +} + +void tst_qquickstates::urlResolution() +{ + QQmlEngine engine; + + QQmlComponent c(&engine, testFileUrl("urlResolution.qml")); + QQuickRectangle *rect = qobject_cast(c.create()); + QVERIFY(rect != 0); + + QQuickItem *myType = rect->findChild("MyType"); + QQuickImage *image1 = rect->findChild("image1"); + QQuickImage *image2 = rect->findChild("image2"); + QQuickImage *image3 = rect->findChild("image3"); + QVERIFY(myType != 0 && image1 != 0 && image2 != 0 && image3 != 0); + + QQuickItemPrivate::get(myType)->setState("SetImageState"); + QUrl resolved = testFileUrl("Implementation/images/qt-logo.png"); + QCOMPARE(image1->source(), resolved); + QCOMPARE(image2->source(), resolved); + QCOMPARE(image3->source(), resolved); + + delete rect; +} + +void tst_qquickstates::unnamedWhen() +{ + QQmlEngine engine; + + QQmlComponent c(&engine, testFileUrl("unnamedWhen.qml")); + QQuickRectangle *rect = qobject_cast(c.create()); + QVERIFY(rect != 0); + QQuickItemPrivate *rectPrivate = QQuickItemPrivate::get(rect); + + QCOMPARE(rectPrivate->state(), QLatin1String("")); + QCOMPARE(rect->property("stateString").toString(), QLatin1String("")); + rect->setProperty("triggerState", true); + QCOMPARE(rectPrivate->state(), QLatin1String("anonymousState1")); + QCOMPARE(rect->property("stateString").toString(), QLatin1String("inState")); + rect->setProperty("triggerState", false); + QCOMPARE(rectPrivate->state(), QLatin1String("")); + QCOMPARE(rect->property("stateString").toString(), QLatin1String("")); +} + +void tst_qquickstates::returnToBase() +{ + QQmlEngine engine; + + QQmlComponent c(&engine, testFileUrl("returnToBase.qml")); + QQuickRectangle *rect = qobject_cast(c.create()); + QVERIFY(rect != 0); + QQuickItemPrivate *rectPrivate = QQuickItemPrivate::get(rect); + + QCOMPARE(rectPrivate->state(), QLatin1String("")); + QCOMPARE(rect->property("stateString").toString(), QLatin1String("")); + rect->setProperty("triggerState", true); + QCOMPARE(rectPrivate->state(), QLatin1String("anonymousState1")); + QCOMPARE(rect->property("stateString").toString(), QLatin1String("inState")); + rect->setProperty("triggerState", false); + QCOMPARE(rectPrivate->state(), QLatin1String("")); + QCOMPARE(rect->property("stateString").toString(), QLatin1String("originalState")); +} + +//QTBUG-12559 +void tst_qquickstates::extendsBug() +{ + QQmlEngine engine; + + QQmlComponent c(&engine, testFileUrl("extendsBug.qml")); + QQuickRectangle *rect = qobject_cast(c.create()); + QVERIFY(rect != 0); + QQuickItemPrivate *rectPrivate = QQuickItemPrivate::get(rect); + QQuickRectangle *greenRect = rect->findChild("greenRect"); + + rectPrivate->setState("b"); + QCOMPARE(greenRect->x(), qreal(100)); + QCOMPARE(greenRect->y(), qreal(100)); +} + +void tst_qquickstates::editProperties() +{ + QQmlEngine engine; + + QQmlComponent c(&engine, testFileUrl("editProperties.qml")); + QQuickRectangle *rect = qobject_cast(c.create()); + QVERIFY(rect != 0); + + QQuickItemPrivate *rectPrivate = QQuickItemPrivate::get(rect); + + QQuickStateGroup *stateGroup = rectPrivate->_states(); + QVERIFY(stateGroup != 0); + qmlExecuteDeferred(stateGroup); + + QQuickState *blueState = stateGroup->findState("blue"); + QVERIFY(blueState != 0); + qmlExecuteDeferred(blueState); + + QQuickPropertyChanges *propertyChangesBlue = qobject_cast(blueState->operationAt(0)); + QVERIFY(propertyChangesBlue != 0); + + QQuickState *greenState = stateGroup->findState("green"); + QVERIFY(greenState != 0); + qmlExecuteDeferred(greenState); + + QQuickPropertyChanges *propertyChangesGreen = qobject_cast(greenState->operationAt(0)); + QVERIFY(propertyChangesGreen != 0); + + QQuickRectangle *childRect = rect->findChild("rect2"); + QVERIFY(childRect != 0); + QCOMPARE(childRect->width(), qreal(402)); + QVERIFY(QQmlPropertyPrivate::binding(QQmlProperty(childRect, "width"))); + QCOMPARE(childRect->height(), qreal(200)); + + rectPrivate->setState("blue"); + QCOMPARE(childRect->width(), qreal(50)); + QCOMPARE(childRect->height(), qreal(40)); + QVERIFY(!QQmlPropertyPrivate::binding(QQmlProperty(childRect, "width"))); + QVERIFY(blueState->bindingInRevertList(childRect, "width")); + + + rectPrivate->setState("green"); + QCOMPARE(childRect->width(), qreal(200)); + QCOMPARE(childRect->height(), qreal(100)); + QVERIFY(greenState->bindingInRevertList(childRect, "width")); + + + rectPrivate->setState(""); + + + QCOMPARE(propertyChangesBlue->actions().length(), 2); + QVERIFY(propertyChangesBlue->containsValue("width")); + QVERIFY(!propertyChangesBlue->containsProperty("x")); + QCOMPARE(propertyChangesBlue->value("width").toInt(), 50); + QVERIFY(!propertyChangesBlue->value("x").isValid()); + + propertyChangesBlue->changeValue("width", 60); + QCOMPARE(propertyChangesBlue->value("width").toInt(), 60); + QCOMPARE(propertyChangesBlue->actions().length(), 2); + + + propertyChangesBlue->changeExpression("width", "myRectangle.width / 2"); + QVERIFY(!propertyChangesBlue->containsValue("width")); + QVERIFY(propertyChangesBlue->containsExpression("width")); + QCOMPARE(propertyChangesBlue->value("width").toInt(), 0); + QCOMPARE(propertyChangesBlue->actions().length(), 2); + + propertyChangesBlue->changeValue("width", 50); + QVERIFY(propertyChangesBlue->containsValue("width")); + QVERIFY(!propertyChangesBlue->containsExpression("width")); + QCOMPARE(propertyChangesBlue->value("width").toInt(), 50); + QCOMPARE(propertyChangesBlue->actions().length(), 2); + + QVERIFY(QQmlPropertyPrivate::binding(QQmlProperty(childRect, "width"))); + rectPrivate->setState("blue"); + QCOMPARE(childRect->width(), qreal(50)); + QCOMPARE(childRect->height(), qreal(40)); + + propertyChangesBlue->changeValue("width", 60); + QCOMPARE(propertyChangesBlue->value("width").toInt(), 60); + QCOMPARE(propertyChangesBlue->actions().length(), 2); + QCOMPARE(childRect->width(), qreal(60)); + QVERIFY(!QQmlPropertyPrivate::binding(QQmlProperty(childRect, "width"))); + + propertyChangesBlue->changeExpression("width", "myRectangle.width / 2"); + QVERIFY(!propertyChangesBlue->containsValue("width")); + QVERIFY(propertyChangesBlue->containsExpression("width")); + QCOMPARE(propertyChangesBlue->value("width").toInt(), 0); + QCOMPARE(propertyChangesBlue->actions().length(), 2); + QVERIFY(QQmlPropertyPrivate::binding(QQmlProperty(childRect, "width"))); + QCOMPARE(childRect->width(), qreal(200)); + + propertyChangesBlue->changeValue("width", 50); + QCOMPARE(childRect->width(), qreal(50)); + + rectPrivate->setState(""); + QCOMPARE(childRect->width(), qreal(402)); + QVERIFY(QQmlPropertyPrivate::binding(QQmlProperty(childRect, "width"))); + + QCOMPARE(propertyChangesGreen->actions().length(), 2); + rectPrivate->setState("green"); + QCOMPARE(childRect->width(), qreal(200)); + QCOMPARE(childRect->height(), qreal(100)); + QVERIFY(QQmlPropertyPrivate::binding(QQmlProperty(childRect, "width"))); + QVERIFY(greenState->bindingInRevertList(childRect, "width")); + QCOMPARE(propertyChangesGreen->actions().length(), 2); + + + propertyChangesGreen->removeProperty("height"); + QVERIFY(!QQmlPropertyPrivate::binding(QQmlProperty(childRect, "height"))); + QCOMPARE(childRect->height(), qreal(200)); + + QVERIFY(greenState->bindingInRevertList(childRect, "width")); + QVERIFY(greenState->containsPropertyInRevertList(childRect, "width")); + propertyChangesGreen->removeProperty("width"); + QVERIFY(QQmlPropertyPrivate::binding(QQmlProperty(childRect, "width"))); + QCOMPARE(childRect->width(), qreal(402)); + QVERIFY(!greenState->bindingInRevertList(childRect, "width")); + QVERIFY(!greenState->containsPropertyInRevertList(childRect, "width")); + + propertyChangesBlue->removeProperty("width"); + QCOMPARE(childRect->width(), qreal(402)); + + rectPrivate->setState("blue"); + QCOMPARE(childRect->width(), qreal(402)); + QCOMPARE(childRect->height(), qreal(40)); +} + +void tst_qquickstates::QTBUG_14830() +{ + QQmlEngine engine; + + QQmlComponent c(&engine, testFileUrl("QTBUG-14830.qml")); + QQuickRectangle *rect = qobject_cast(c.create()); + QVERIFY(rect != 0); + QQuickItem *item = rect->findChild("area"); + + QCOMPARE(item->width(), qreal(171)); +} + +void tst_qquickstates::avoidFastForward() +{ + QQmlEngine engine; + + //shouldn't fast forward if there isn't a transition + QQmlComponent c(&engine, testFileUrl("avoidFastForward.qml")); + QQuickRectangle *rect = qobject_cast(c.create()); + QVERIFY(rect != 0); + + QQuickItemPrivate *rectPrivate = QQuickItemPrivate::get(rect); + rectPrivate->setState("a"); + QCOMPARE(rect->property("updateCount").toInt(), 1); +} + +//QTBUG-22583 +void tst_qquickstates::revertListBug() +{ + QQmlEngine engine; + + QQmlComponent c(&engine, testFileUrl("revertListBug.qml")); + QQuickRectangle *rect = qobject_cast(c.create()); + QVERIFY(rect != 0); + + QQuickRectangle *rect1 = rect->findChild("rect1"); + QQuickRectangle *rect2 = rect->findChild("rect2"); + QQuickItem *origParent1 = rect->findChild("originalParent1"); + QQuickItem *origParent2 = rect->findChild("originalParent2"); + QQuickItem *newParent = rect->findChild("newParent"); + + QCOMPARE(rect1->parentItem(), origParent1); + QCOMPARE(rect2->parentItem(), origParent2); + + QQuickItemPrivate *rectPrivate = QQuickItemPrivate::get(rect); + rectPrivate->setState("reparented"); + + QCOMPARE(rect1->parentItem(), newParent); + QCOMPARE(rect2->parentItem(), origParent2); + + rectPrivate->setState(""); + + QCOMPARE(rect1->parentItem(), origParent1); + QCOMPARE(rect2->parentItem(), origParent2); + + QMetaObject::invokeMethod(rect, "switchTargetItem"); + + rectPrivate->setState("reparented"); + + QCOMPARE(rect1->parentItem(), origParent1); + QCOMPARE(rect2->parentItem(), newParent); + + rectPrivate->setState(""); + + QCOMPARE(rect1->parentItem(), origParent1); + QCOMPARE(rect2->parentItem(), origParent2); //QTBUG-22583 causes rect2's parent item to be origParent1 +} + +QTEST_MAIN(tst_qquickstates) + +#include "tst_qquickstates.moc" diff --git a/tests/auto/quick/qquickstyledtext/qquickstyledtext.pro b/tests/auto/quick/qquickstyledtext/qquickstyledtext.pro new file mode 100644 index 0000000000..bd367d5ce2 --- /dev/null +++ b/tests/auto/quick/qquickstyledtext/qquickstyledtext.pro @@ -0,0 +1,8 @@ +CONFIG += testcase +TARGET = tst_qquickstyledtext +macx:CONFIG -= app_bundle + +SOURCES += tst_qquickstyledtext.cpp + +CONFIG += parallel_test +QT += core-private gui-private qml-private quick-private network testlib diff --git a/tests/auto/quick/qquickstyledtext/tst_qquickstyledtext.cpp b/tests/auto/quick/qquickstyledtext/tst_qquickstyledtext.cpp new file mode 100644 index 0000000000..86874b84fd --- /dev/null +++ b/tests/auto/quick/qquickstyledtext/tst_qquickstyledtext.cpp @@ -0,0 +1,185 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include +#include +#include +#include +#include + +class tst_qquickstyledtext : public QObject +{ + Q_OBJECT +public: + tst_qquickstyledtext() + { + } + + struct Format { + enum Type { + Bold = 0x01, + Underline = 0x02, + Italic = 0x04 + }; + Format(int t, int s, int l) + : type(t), start(s), length(l) {} + int type; + int start; + int length; + }; + typedef QList FormatList; + + static const QChar bullet; + static const QChar disc; + static const QChar square; + +private slots: + void textOutput(); + void textOutput_data(); +}; + +Q_DECLARE_METATYPE(tst_qquickstyledtext::FormatList); + +const QChar tst_qquickstyledtext::bullet(0x2022); +const QChar tst_qquickstyledtext::disc(0x25e6); +const QChar tst_qquickstyledtext::square(0x25a1); + +// For malformed input all we test is that we get the expected text and format out. +// +void tst_qquickstyledtext::textOutput_data() +{ + QTest::addColumn("input"); + QTest::addColumn("output"); + QTest::addColumn("formats"); + + QTest::newRow("bold") << "bold" << "bold" << (FormatList() << Format(Format::Bold, 0, 4)); + QTest::newRow("italic") << "italic" << "italic" << (FormatList() << Format(Format::Italic, 0, 6)); + QTest::newRow("underline") << "underline" << "underline" << (FormatList() << Format(Format::Underline, 0, 9)); + QTest::newRow("strong") << "strong" << "strong" << (FormatList() << Format(Format::Bold, 0, 6)); + QTest::newRow("underline") << "underline" << "underline" << (FormatList() << Format(Format::Underline, 0, 9)); + QTest::newRow("missing >") << "text") << "text") << "text<" << "text" << (FormatList() << Format(Format::Bold, 0, 4)); + QTest::newRow("missing ") << "text" << "text" << (FormatList() << Format(Format::Bold, 0, 4)); + QTest::newRow("nested") << "text italic bold" << "text italic bold" << (FormatList() << Format(Format::Bold, 0, 5) << Format(Format::Bold | Format::Italic, 5, 6) << Format(Format::Bold, 11, 5)); + QTest::newRow("bad nest") << "text italic" << "text italic" << (FormatList() << Format(Format::Bold, 0, 5) << Format(Format::Bold | Format::Italic, 5, 6)); + QTest::newRow("font color") << "red text" << "red text" << (FormatList() << Format(0, 0, 8)); + QTest::newRow("font color: single quote") << "red text" << "red text" << (FormatList() << Format(0, 0, 8)); + QTest::newRow("font size") << "text" << "text" << (FormatList() << Format(0, 0, 4)); + QTest::newRow("font empty") << "text" << "text" << FormatList(); + QTest::newRow("font bad 1") << "text" << "text" << FormatList(); + QTest::newRow("font bad 2") << "text" << "" << FormatList(); + QTest::newRow("extra close") << "text" << "text" << (FormatList() << Format(Format::Bold, 0, 4)); + QTest::newRow("extra space") << "text" << "text" << (FormatList() << Format(Format::Bold, 0, 4)); + QTest::newRow("entities") << "<b>this & that</b>" << "this & that" << FormatList(); + QTest::newRow("newline") << "text
      more text" << QLatin1String("text") + QChar(QChar::LineSeparator) + QLatin1String("more text") << FormatList(); + QTest::newRow("paragraph") << "text

      more text" << QLatin1String("text") + QChar(QChar::LineSeparator) + QLatin1String("more text") << FormatList(); + QTest::newRow("paragraph closed") << "text

      more text

      more text" << QLatin1String("text") + QChar(QChar::LineSeparator) + QLatin1String("more text") + QChar(QChar::LineSeparator) + QLatin1String("more text") << FormatList(); + QTest::newRow("paragraph closed bold") << "text

      more text

      more text
      " << QLatin1String("text") + QChar(QChar::LineSeparator) + QLatin1String("more text") + QChar(QChar::LineSeparator) + QLatin1String("more text") << (FormatList() << Format(Format::Bold, 0, 24)); + QTest::newRow("self-closing newline") << "text
      more text" << QLatin1String("text") + QChar(QChar::LineSeparator) + QLatin1String("more text") << FormatList(); + QTest::newRow("empty") << "" << "" << FormatList(); + QTest::newRow("unknown tag") << "underline not" << "underline not" << (FormatList() << Format(Format::Underline, 0, 9)); + QTest::newRow("ordered list") << "
      1. one
      2. two" << QChar(QChar::LineSeparator) + QString(6, QChar::Nbsp) + QLatin1String("1.") + QString(2, QChar::Nbsp) + QLatin1String("one") + QChar(QChar::LineSeparator) + QString(6, QChar::Nbsp) + QLatin1String("2.") + QString(2, QChar::Nbsp) + QLatin1String("two") << FormatList(); + QTest::newRow("ordered list closed") << "
        1. one
        2. two
        " << QChar(QChar::LineSeparator) + QString(6, QChar::Nbsp) + QLatin1String("1.") + QString(2, QChar::Nbsp) + QLatin1String("one") + QChar(QChar::LineSeparator) + QString(6, QChar::Nbsp) + QLatin1String("2.") + QString(2, QChar::Nbsp) + QLatin1String("two") + QChar(QChar::LineSeparator) << FormatList(); + QTest::newRow("ordered list alpha") << "
        1. one
        2. two
        " << QChar(QChar::LineSeparator) + QString(6, QChar::Nbsp) + QLatin1String("a.") + QString(2, QChar::Nbsp) + QLatin1String("one") + QChar(QChar::LineSeparator) + QString(6, QChar::Nbsp) + QLatin1String("b.") + QString(2, QChar::Nbsp) + QLatin1String("two") + QChar(QChar::LineSeparator) << FormatList(); + QTest::newRow("ordered list upper alpha") << "
        1. one
        2. two
        " << QChar(QChar::LineSeparator) + QString(6, QChar::Nbsp) + QLatin1String("A.") + QString(2, QChar::Nbsp) + QLatin1String("one") + QChar(QChar::LineSeparator) + QString(6, QChar::Nbsp) + QLatin1String("B.") + QString(2, QChar::Nbsp) + QLatin1String("two") + QChar(QChar::LineSeparator) << FormatList(); + QTest::newRow("ordered list roman") << "
        1. one
        2. two
        " << QChar(QChar::LineSeparator) + QString(6, QChar::Nbsp) + QLatin1String("i.") + QString(2, QChar::Nbsp) + QLatin1String("one") + QChar(QChar::LineSeparator) + QString(6, QChar::Nbsp) + QLatin1String("ii.") + QString(2, QChar::Nbsp) + QLatin1String("two") + QChar(QChar::LineSeparator) << FormatList(); + QTest::newRow("ordered list upper roman") << "
        1. one
        2. two
        " << QChar(QChar::LineSeparator) + QString(6, QChar::Nbsp) + QLatin1String("I.") + QString(2, QChar::Nbsp) + QLatin1String("one") + QChar(QChar::LineSeparator) + QString(6, QChar::Nbsp) + QLatin1String("II.") + QString(2, QChar::Nbsp) + QLatin1String("two") + QChar(QChar::LineSeparator) << FormatList(); + QTest::newRow("ordered list bad") << "
        1. one
        2. two
        " << QChar(QChar::LineSeparator) + QString(6, QChar::Nbsp) + QLatin1String("1.") + QString(2, QChar::Nbsp) + QLatin1String("one") + QChar(QChar::LineSeparator) + QString(6, QChar::Nbsp) + QLatin1String("2.") + QString(2, QChar::Nbsp) + QLatin1String("two") + QChar(QChar::LineSeparator) << FormatList(); + QTest::newRow("unordered list") << "
        • one
        • two" << QChar(QChar::LineSeparator) + QString(6, QChar::Nbsp) + bullet + QString(2, QChar::Nbsp) + QLatin1String("one") + QChar(QChar::LineSeparator) + QString(6, QChar::Nbsp) + bullet + QString(2, QChar::Nbsp) + QLatin1String("two") << FormatList(); + QTest::newRow("unordered list closed") << "
          • one
          • two
          " << QChar(QChar::LineSeparator) + QString(6, QChar::Nbsp) + bullet + QString(2, QChar::Nbsp) + QLatin1String("one") + QChar(QChar::LineSeparator) + QString(6, QChar::Nbsp) + bullet + QString(2, QChar::Nbsp) + QLatin1String("two") + QChar(QChar::LineSeparator) << FormatList(); + QTest::newRow("unordered list disc") << "
          • one
          • two
          " << QChar(QChar::LineSeparator) + QString(6, QChar::Nbsp) + disc + QString(2, QChar::Nbsp) + QLatin1String("one") + QChar(QChar::LineSeparator) + QString(6, QChar::Nbsp) + disc + QString(2, QChar::Nbsp) + QLatin1String("two") + QChar(QChar::LineSeparator) << FormatList(); + QTest::newRow("unordered list square") << "
          • one
          • two
          " << QChar(QChar::LineSeparator) + QString(6, QChar::Nbsp) + square + QString(2, QChar::Nbsp) + QLatin1String("one") + QChar(QChar::LineSeparator) + QString(6, QChar::Nbsp) + square + QString(2, QChar::Nbsp) + QLatin1String("two") + QChar(QChar::LineSeparator) << FormatList(); + QTest::newRow("unordered list bad") << "
          • one
          • two
          " << QChar(QChar::LineSeparator) + QString(6, QChar::Nbsp) + bullet + QString(2, QChar::Nbsp) + QLatin1String("one") + QChar(QChar::LineSeparator) + QString(6, QChar::Nbsp) + bullet + QString(2, QChar::Nbsp) + QLatin1String("two") + QChar(QChar::LineSeparator) << FormatList(); + QTest::newRow("header close") << "

          head

          more" << QChar(QChar::LineSeparator) + QLatin1String("head") + QChar(QChar::LineSeparator) + QLatin1String("more") << (FormatList() << Format(Format::Bold, 0, 5)); + QTest::newRow("h0") << "head" << "head" << FormatList(); + QTest::newRow("h1") << "

          head" << QChar(QChar::LineSeparator) + QLatin1String("head") << (FormatList() << Format(Format::Bold, 0, 5)); + QTest::newRow("h2") << "

          head" << QChar(QChar::LineSeparator) + QLatin1String("head") << (FormatList() << Format(Format::Bold, 0, 5)); + QTest::newRow("h3") << "

          head" << QChar(QChar::LineSeparator) + QLatin1String("head") << (FormatList() << Format(Format::Bold, 0, 5)); + QTest::newRow("h4") << "

          head" << QChar(QChar::LineSeparator) + QLatin1String("head") << (FormatList() << Format(Format::Bold, 0, 5)); + QTest::newRow("h5") << "

          head" << QChar(QChar::LineSeparator) + QLatin1String("head") << (FormatList() << Format(Format::Bold, 0, 5)); + QTest::newRow("h6") << "
          head" << QChar(QChar::LineSeparator) + QLatin1String("head") << (FormatList() << Format(Format::Bold, 0, 5)); + QTest::newRow("h7") << "head" << "head" << FormatList(); + QTest::newRow("pre") << "normal
          pre text
          normal" << QLatin1String("normal") + QChar(QChar::LineSeparator) + QLatin1String("pre") + QChar(QChar::Nbsp) + QLatin1String("text") + QChar(QChar::LineSeparator) + QLatin1String("normal") << (FormatList() << Format(0, 6, 9)); + QTest::newRow("pre lb") << "normal
          pre\n text
          normal" << QLatin1String("normal") + QChar(QChar::LineSeparator) + QLatin1String("pre") + QChar(QChar::LineSeparator) + QChar(QChar::Nbsp) + QLatin1String("text") + QChar(QChar::LineSeparator) + QLatin1String("normal") << (FormatList() << Format(0, 6, 10)); + QTest::newRow("line feed") << "line\nfeed" << "line feed" << FormatList(); + QTest::newRow("leading whitespace") << " leading whitespace" << "leading whitespace" << FormatList(); + QTest::newRow("trailing whitespace") << "trailing whitespace " << "trailing whitespace" << FormatList(); + QTest::newRow("consecutive whitespace") << " consecutive \t \n whitespace" << "consecutive whitespace" << FormatList(); + QTest::newRow("space after newline") << "text
          more text" << QLatin1String("text") + QChar(QChar::LineSeparator) + QLatin1String("more text") << FormatList(); + QTest::newRow("space after paragraph") << "text

          more text

          more text" << QLatin1String("text") + QChar(QChar::LineSeparator) + QLatin1String("more text") + QChar(QChar::LineSeparator) + QLatin1String("more text") << FormatList(); + QTest::newRow("space in header") << "

          head

          " << QChar(QChar::LineSeparator) + QLatin1String("head") + QChar(QChar::LineSeparator) << (FormatList() << Format(Format::Bold, 0, 5)); + QTest::newRow("space before bold") << "this is bold" << "this is bold" << (FormatList() << Format(Format::Bold, 8, 4)); + QTest::newRow("space leading bold") << "this is bold" << "this is bold" << (FormatList() << Format(Format::Bold, 7, 5)); + QTest::newRow("space trailing bold") << "this is bold " << "this is bold " << (FormatList() << Format(Format::Bold, 8, 5)); + QTest::newRow("img") << "ab" << "a b" << FormatList(); +} + +void tst_qquickstyledtext::textOutput() +{ + QFETCH(QString, input); + QFETCH(QString, output); + QFETCH(FormatList, formats); + + QTextLayout layout; + QList imgTags; + QQuickStyledText::parse(input, layout, imgTags, QUrl(), 0, false); + + QCOMPARE(layout.text(), output); + + QList layoutFormats = layout.additionalFormats(); + + QCOMPARE(layoutFormats.count(), formats.count()); + for (int i = 0; i < formats.count(); ++i) { + QCOMPARE(layoutFormats.at(i).start, formats.at(i).start); + QCOMPARE(layoutFormats.at(i).length, formats.at(i).length); + if (formats.at(i).type & Format::Bold) + QVERIFY(layoutFormats.at(i).format.fontWeight() == QFont::Bold); + else + QVERIFY(layoutFormats.at(i).format.fontWeight() == QFont::Normal); + QVERIFY(layoutFormats.at(i).format.fontItalic() == bool(formats.at(i).type & Format::Italic)); + QVERIFY(layoutFormats.at(i).format.fontUnderline() == bool(formats.at(i).type & Format::Underline)); + } +} + + +QTEST_MAIN(tst_qquickstyledtext) + +#include "tst_qquickstyledtext.moc" diff --git a/tests/auto/quick/qquicksystempalette/qquicksystempalette.pro b/tests/auto/quick/qquicksystempalette/qquicksystempalette.pro new file mode 100644 index 0000000000..c8825c07fb --- /dev/null +++ b/tests/auto/quick/qquicksystempalette/qquicksystempalette.pro @@ -0,0 +1,8 @@ +CONFIG += testcase +TARGET = tst_qquicksystempalette +macx:CONFIG -= app_bundle + +SOURCES += tst_qquicksystempalette.cpp + +CONFIG += parallel_test +QT += core-private gui-private qml-private quick-private widgets testlib diff --git a/tests/auto/quick/qquicksystempalette/tst_qquicksystempalette.cpp b/tests/auto/quick/qquicksystempalette/tst_qquicksystempalette.cpp new file mode 100644 index 0000000000..3b74dfd0ed --- /dev/null +++ b/tests/auto/quick/qquicksystempalette/tst_qquicksystempalette.cpp @@ -0,0 +1,185 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include +#include +#include +#include +#include + +class tst_qquicksystempalette : public QObject +{ + Q_OBJECT +public: + tst_qquicksystempalette(); + +private slots: + void activePalette(); + void inactivePalette(); + void disabledPalette(); + void paletteChanged(); + +private: + QQmlEngine engine; +}; + +tst_qquicksystempalette::tst_qquicksystempalette() +{ +} + +void tst_qquicksystempalette::activePalette() +{ + QString componentStr = "import QtQuick 2.0\nSystemPalette { }"; + QQmlComponent component(&engine); + component.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); + QQuickSystemPalette *object = qobject_cast(component.create()); + + QVERIFY(object != 0); + + QPalette palette; + palette.setCurrentColorGroup(QPalette::Active); + QCOMPARE(palette.window().color(), object->window()); + QCOMPARE(palette.windowText().color(), object->windowText()); + QCOMPARE(palette.base().color(), object->base()); + QCOMPARE(palette.text().color(), object->text()); + QCOMPARE(palette.alternateBase().color(), object->alternateBase()); + QCOMPARE(palette.button().color(), object->button()); + QCOMPARE(palette.buttonText().color(), object->buttonText()); + QCOMPARE(palette.light().color(), object->light()); + QCOMPARE(palette.midlight().color(), object->midlight()); + QCOMPARE(palette.dark().color(), object->dark()); + QCOMPARE(palette.mid().color(), object->mid()); + QCOMPARE(palette.shadow().color(), object->shadow()); + QCOMPARE(palette.highlight().color(), object->highlight()); + QCOMPARE(palette.highlightedText().color(), object->highlightedText()); + + delete object; +} + +void tst_qquicksystempalette::inactivePalette() +{ + QString componentStr = "import QtQuick 2.0\nSystemPalette { colorGroup: SystemPalette.Inactive }"; + QQmlComponent component(&engine); + component.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); + QQuickSystemPalette *object = qobject_cast(component.create()); + + QVERIFY(object != 0); + QVERIFY(object->colorGroup() == QQuickSystemPalette::Inactive); + + QPalette palette; + palette.setCurrentColorGroup(QPalette::Inactive); + QCOMPARE(palette.window().color(), object->window()); + QCOMPARE(palette.windowText().color(), object->windowText()); + QCOMPARE(palette.base().color(), object->base()); + QCOMPARE(palette.text().color(), object->text()); + QCOMPARE(palette.alternateBase().color(), object->alternateBase()); + QCOMPARE(palette.button().color(), object->button()); + QCOMPARE(palette.buttonText().color(), object->buttonText()); + QCOMPARE(palette.light().color(), object->light()); + QCOMPARE(palette.midlight().color(), object->midlight()); + QCOMPARE(palette.dark().color(), object->dark()); + QCOMPARE(palette.mid().color(), object->mid()); + QCOMPARE(palette.shadow().color(), object->shadow()); + QCOMPARE(palette.highlight().color(), object->highlight()); + QCOMPARE(palette.highlightedText().color(), object->highlightedText()); + + delete object; +} + +void tst_qquicksystempalette::disabledPalette() +{ + QString componentStr = "import QtQuick 2.0\nSystemPalette { colorGroup: SystemPalette.Disabled }"; + QQmlComponent component(&engine); + component.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); + QQuickSystemPalette *object = qobject_cast(component.create()); + + QVERIFY(object != 0); + QVERIFY(object->colorGroup() == QQuickSystemPalette::Disabled); + + QPalette palette; + palette.setCurrentColorGroup(QPalette::Disabled); + QCOMPARE(palette.window().color(), object->window()); + QCOMPARE(palette.windowText().color(), object->windowText()); + QCOMPARE(palette.base().color(), object->base()); + QCOMPARE(palette.text().color(), object->text()); + QCOMPARE(palette.alternateBase().color(), object->alternateBase()); + QCOMPARE(palette.button().color(), object->button()); + QCOMPARE(palette.buttonText().color(), object->buttonText()); + QCOMPARE(palette.light().color(), object->light()); + QCOMPARE(palette.midlight().color(), object->midlight()); + QCOMPARE(palette.dark().color(), object->dark()); + QCOMPARE(palette.mid().color(), object->mid()); + QCOMPARE(palette.shadow().color(), object->shadow()); + QCOMPARE(palette.highlight().color(), object->highlight()); + QCOMPARE(palette.highlightedText().color(), object->highlightedText()); + + delete object; +} + +void tst_qquicksystempalette::paletteChanged() +{ + QString componentStr = "import QtQuick 2.0\nSystemPalette { }"; + QQmlComponent component(&engine); + component.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); + QQuickSystemPalette *object = qobject_cast(component.create()); + + QVERIFY(object != 0); + + QPalette p; + p.setCurrentColorGroup(QPalette::Active); + p.setColor(QPalette::Active, QPalette::Text, QColor("red")); + p.setColor(QPalette::Active, QPalette::ButtonText, QColor("green")); + p.setColor(QPalette::Active, QPalette::WindowText, QColor("blue")); + + qApp->setPalette(p); + + object->setColorGroup(QQuickSystemPalette::Active); + QTRY_COMPARE(QColor("red"), object->text()); + QTRY_COMPARE(QColor("green"), object->buttonText()); + QTRY_COMPARE(QColor("blue"), object->windowText()); + + delete object; +} + +QTEST_MAIN(tst_qquicksystempalette) + +#include "tst_qquicksystempalette.moc" diff --git a/tests/auto/quick/qquicktext/data/alignments.qml b/tests/auto/quick/qquicktext/data/alignments.qml new file mode 100644 index 0000000000..9798d9c736 --- /dev/null +++ b/tests/auto/quick/qquicktext/data/alignments.qml @@ -0,0 +1,41 @@ +import QtQuick 2.0 + +Rectangle { + id: top + width: 70; height: 70; + + property alias horizontalAlignment: t.horizontalAlignment + property alias verticalAlignment: t.verticalAlignment + property alias wrapMode: t.wrapMode + property alias running: timer.running + property string txt: "Test" + + Rectangle { + anchors.centerIn: parent + width: 40 + height: 40 + color: "green" + + Text { + id: t + + anchors.fill: parent + horizontalAlignment: Text.AlignRight + verticalAlignment: Text.AlignBottom + wrapMode: Text.WordWrap + text: top.txt + } + Timer { + id: timer + + interval: 1 + running: true + repeat: true + onTriggered: { + top.txt = top.txt + "
          more " + top.txt.length; + if (top.txt.length > 50) + running = false + } + } + } +} diff --git a/tests/auto/quick/qquicktext/data/alignments_cb.png b/tests/auto/quick/qquicktext/data/alignments_cb.png new file mode 100644 index 0000000000..cf6199a418 Binary files /dev/null and b/tests/auto/quick/qquicktext/data/alignments_cb.png differ diff --git a/tests/auto/quick/qquicktext/data/alignments_cc.png b/tests/auto/quick/qquicktext/data/alignments_cc.png new file mode 100644 index 0000000000..f81ccb4238 Binary files /dev/null and b/tests/auto/quick/qquicktext/data/alignments_cc.png differ diff --git a/tests/auto/quick/qquicktext/data/alignments_ct.png b/tests/auto/quick/qquicktext/data/alignments_ct.png new file mode 100644 index 0000000000..9ba64125d5 Binary files /dev/null and b/tests/auto/quick/qquicktext/data/alignments_ct.png differ diff --git a/tests/auto/quick/qquicktext/data/alignments_lb.png b/tests/auto/quick/qquicktext/data/alignments_lb.png new file mode 100644 index 0000000000..1b50a81f3d Binary files /dev/null and b/tests/auto/quick/qquicktext/data/alignments_lb.png differ diff --git a/tests/auto/quick/qquicktext/data/alignments_lc.png b/tests/auto/quick/qquicktext/data/alignments_lc.png new file mode 100644 index 0000000000..f041b868f8 Binary files /dev/null and b/tests/auto/quick/qquicktext/data/alignments_lc.png differ diff --git a/tests/auto/quick/qquicktext/data/alignments_lt.png b/tests/auto/quick/qquicktext/data/alignments_lt.png new file mode 100644 index 0000000000..c75e0d158e Binary files /dev/null and b/tests/auto/quick/qquicktext/data/alignments_lt.png differ diff --git a/tests/auto/quick/qquicktext/data/alignments_rb.png b/tests/auto/quick/qquicktext/data/alignments_rb.png new file mode 100644 index 0000000000..b06a5da715 Binary files /dev/null and b/tests/auto/quick/qquicktext/data/alignments_rb.png differ diff --git a/tests/auto/quick/qquicktext/data/alignments_rc.png b/tests/auto/quick/qquicktext/data/alignments_rc.png new file mode 100644 index 0000000000..e468857cd0 Binary files /dev/null and b/tests/auto/quick/qquicktext/data/alignments_rc.png differ diff --git a/tests/auto/quick/qquicktext/data/alignments_rt.png b/tests/auto/quick/qquicktext/data/alignments_rt.png new file mode 100644 index 0000000000..576715ffce Binary files /dev/null and b/tests/auto/quick/qquicktext/data/alignments_rt.png differ diff --git a/tests/auto/quick/qquicktext/data/embeddedImagesLocal.qml b/tests/auto/quick/qquicktext/data/embeddedImagesLocal.qml new file mode 100644 index 0000000000..74b2ab817a --- /dev/null +++ b/tests/auto/quick/qquicktext/data/embeddedImagesLocal.qml @@ -0,0 +1,6 @@ +import QtQuick 2.0 + +Text { + textFormat: Text.RichText + text: "" +} diff --git a/tests/auto/quick/qquicktext/data/embeddedImagesLocalError.qml b/tests/auto/quick/qquicktext/data/embeddedImagesLocalError.qml new file mode 100644 index 0000000000..a2f7e0c89f --- /dev/null +++ b/tests/auto/quick/qquicktext/data/embeddedImagesLocalError.qml @@ -0,0 +1,6 @@ +import QtQuick 2.0 + +Text { + textFormat: Text.RichText + text: "" +} diff --git a/tests/auto/quick/qquicktext/data/embeddedImagesLocalRelative.qml b/tests/auto/quick/qquicktext/data/embeddedImagesLocalRelative.qml new file mode 100644 index 0000000000..8de7364d08 --- /dev/null +++ b/tests/auto/quick/qquicktext/data/embeddedImagesLocalRelative.qml @@ -0,0 +1,7 @@ +import QtQuick 2.0 + +Text { + textFormat: Text.RichText + text: "" + baseUrl: "http/" +} diff --git a/tests/auto/quick/qquicktext/data/embeddedImagesRemote.qml b/tests/auto/quick/qquicktext/data/embeddedImagesRemote.qml new file mode 100644 index 0000000000..702633c538 --- /dev/null +++ b/tests/auto/quick/qquicktext/data/embeddedImagesRemote.qml @@ -0,0 +1,6 @@ +import QtQuick 2.0 + +Text { + textFormat: Text.RichText + text: "" +} diff --git a/tests/auto/quick/qquicktext/data/embeddedImagesRemoteError.qml b/tests/auto/quick/qquicktext/data/embeddedImagesRemoteError.qml new file mode 100644 index 0000000000..5762f3e47d --- /dev/null +++ b/tests/auto/quick/qquicktext/data/embeddedImagesRemoteError.qml @@ -0,0 +1,6 @@ +import QtQuick 2.0 + +Text { + textFormat: Text.RichText + text: "" +} diff --git a/tests/auto/quick/qquicktext/data/embeddedImagesRemoteRelative.qml b/tests/auto/quick/qquicktext/data/embeddedImagesRemoteRelative.qml new file mode 100644 index 0000000000..cee19740f9 --- /dev/null +++ b/tests/auto/quick/qquicktext/data/embeddedImagesRemoteRelative.qml @@ -0,0 +1,7 @@ +import QtQuick 2.0 + +Text { + textFormat: Text.RichText + text: "" + baseUrl: "http://127.0.0.1:14453/text.html" +} diff --git a/tests/auto/quick/qquicktext/data/fontSizeMode.qml b/tests/auto/quick/qquicktext/data/fontSizeMode.qml new file mode 100644 index 0000000000..20f7535365 --- /dev/null +++ b/tests/auto/quick/qquicktext/data/fontSizeMode.qml @@ -0,0 +1,24 @@ +import QtQuick 2.0 + +Item { + width: 300 + height: 200 + + Rectangle { + anchors.fill: myText + border.width: 1 + } + + Text { + id: myText + objectName: "myText" + width: 250 + height: 41 + minimumPointSize: 8 + minimumPixelSize: 8 + font.pixelSize: 30 + font.family: "Helvetica" + } + + TextInput { focus: true; objectName: "input" } +} diff --git a/tests/auto/quick/qquicktext/data/horizontalAlignment_RightToLeft.qml b/tests/auto/quick/qquicktext/data/horizontalAlignment_RightToLeft.qml new file mode 100644 index 0000000000..5ba4d35684 --- /dev/null +++ b/tests/auto/quick/qquicktext/data/horizontalAlignment_RightToLeft.qml @@ -0,0 +1,23 @@ +import QtQuick 2.0 + +Rectangle { + id: top + width: 200; height: 70; + + property alias horizontalAlignment: text.horizontalAlignment + property string text: "اختبا" + + Rectangle { + anchors.centerIn: parent + width: 180 + height: 20 + color: "green" + + Text { + id: text + objectName: "text" + anchors.fill: parent + text: top.text + } + } +} diff --git a/tests/auto/quick/qquicktext/data/http/exists.png b/tests/auto/quick/qquicktext/data/http/exists.png new file mode 100644 index 0000000000..399bd0b1d9 Binary files /dev/null and b/tests/auto/quick/qquicktext/data/http/exists.png differ diff --git a/tests/auto/quick/qquicktext/data/images/face-sad.png b/tests/auto/quick/qquicktext/data/images/face-sad.png new file mode 100644 index 0000000000..24188b7985 Binary files /dev/null and b/tests/auto/quick/qquicktext/data/images/face-sad.png differ diff --git a/tests/auto/quick/qquicktext/data/images/heart200.png b/tests/auto/quick/qquicktext/data/images/heart200.png new file mode 100644 index 0000000000..cedd3ea608 Binary files /dev/null and b/tests/auto/quick/qquicktext/data/images/heart200.png differ diff --git a/tests/auto/quick/qquicktext/data/images/starfish_2.png b/tests/auto/quick/qquicktext/data/images/starfish_2.png new file mode 100644 index 0000000000..132c20ffd0 Binary files /dev/null and b/tests/auto/quick/qquicktext/data/images/starfish_2.png differ diff --git a/tests/auto/quick/qquicktext/data/imgTagsElide.qml b/tests/auto/quick/qquicktext/data/imgTagsElide.qml new file mode 100644 index 0000000000..fbd64cc5bf --- /dev/null +++ b/tests/auto/quick/qquicktext/data/imgTagsElide.qml @@ -0,0 +1,24 @@ +import QtQuick 2.0 + +Item { + width: 300 + height: 200 + + Text { + id: myText + objectName: "myText" + elide: Text.ElideRight + maximumLineCount: 2 + width: 200 + wrapMode: Text.WordWrap + text: "This is a sad face aligned to the top. Lorem ipsum dolor sit amet. Nulla sed turpis risus. Integer sit amet odio quis mauris varius venenatisLorem ipsum dolor sit amet. Nulla sed turpis risus. Integer sit amet odio quis mauris varius venenatis. Lorem ipsum dolor sit amet. Nulla sed turpis risus.Lorem ipsum dolor sit amet. Nulla sed turpis risus. Lorem ipsum dolor sit amet. Nulla sed turpis risus.Lorem ipsum dolor sit amet. Nulla sed turpis risus." + } + + MouseArea { + anchors.fill: parent + onClicked: myText.width = 400 + + } +} + + diff --git a/tests/auto/quick/qquicktext/data/imgTagsUpdates.qml b/tests/auto/quick/qquicktext/data/imgTagsUpdates.qml new file mode 100644 index 0000000000..baf5113e52 --- /dev/null +++ b/tests/auto/quick/qquicktext/data/imgTagsUpdates.qml @@ -0,0 +1,12 @@ +import QtQuick 2.0 + +Rectangle { + id: main + width: 300; height: 400 + + Text { + id: myText + objectName: "myText" + text: "" + } +} diff --git a/tests/auto/quick/qquicktext/data/lineCount.qml b/tests/auto/quick/qquicktext/data/lineCount.qml new file mode 100644 index 0000000000..b672863684 --- /dev/null +++ b/tests/auto/quick/qquicktext/data/lineCount.qml @@ -0,0 +1,15 @@ +import QtQuick 2.0 + +Item { + width: 200 + height: 200 + + Text { + id: myText + objectName: "myText" + width: 200 + wrapMode: Text.WordWrap + maximumLineCount: undefined + text: "Testing that maximumLines, visibleLines, and totalLines works properly in the autotests. The quick brown fox jumped over the lazy anything with the letter 'g'." + } +} diff --git a/tests/auto/quick/qquicktext/data/lineHeight.qml b/tests/auto/quick/qquicktext/data/lineHeight.qml new file mode 100644 index 0000000000..c1f337aa05 --- /dev/null +++ b/tests/auto/quick/qquicktext/data/lineHeight.qml @@ -0,0 +1,15 @@ +import QtQuick 2.0 + +Item { + width: 200 + height: 200 + + Text { + id: myText + objectName: "myText" + width: 200 + wrapMode: Text.WordWrap + font.pixelSize: 13 + text: "Lorem ipsum sit amet, consectetur adipiscing elit. Integer felis nisl, varius in pretium nec, venenatis non erat. Proin lobortis interdum dictum." + } +} diff --git a/tests/auto/quick/qquicktext/data/lineLayout.qml b/tests/auto/quick/qquicktext/data/lineLayout.qml new file mode 100644 index 0000000000..cb2474791e --- /dev/null +++ b/tests/auto/quick/qquicktext/data/lineLayout.qml @@ -0,0 +1,35 @@ +import QtQuick 2.0 + +Rectangle { + id: main + width: 800; height: 600 + + property real off: 0 + + Text { + id: myText + objectName: "myText" + wrapMode: Text.WordWrap + font.pixelSize: 14 + textFormat: Text.StyledText + focus: true + + text: "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer at ante dui. Sed eu egestas est. +

          Maecenas nec libero leo. Sed ac leo eget ipsum ultricies viverra sit amet eu orci. Praesent et tortor risus, viverra accumsan sapien. Sed faucibus eleifend lectus, sed euismod urna porta eu. Aenean ultricies lectus ut orci dictum quis convallis nisi ultrices. Nunc elit mi, iaculis a porttitor rutrum, venenatis malesuada nisi. Suspendisse turpis quam, euismod non imperdiet et, rutrum nec ligula. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam semper tristique metus eu sodales. Integer eget risus ipsum. Quisque ut risus ut nulla tristique volutpat at sit amet nisl. Aliquam pulvinar auctor diam nec bibendum.

          Quisque luctus sapien id arcu volutpat pharetra. Praesent pretium imperdiet euismod. Integer fringilla rhoncus condimentum. Quisque sit amet ornare nulla. Cras sapien augue, sagittis a dictum id, suscipit et nunc. Cras vitae augue in enim elementum venenatis sed nec risus. Sed nisi quam, mollis quis auctor ac, vestibulum in neque. Vivamus eu justo risus. Suspendisse vel mollis est. Vestibulum gravida interdum mi, in molestie neque gravida in. Donec nibh odio, mattis facilisis vulputate et, scelerisque ut felis. Sed ornare eros nec odio aliquam eu varius augue adipiscing. Vivamus sit amet massa dapibus sapien pulvinar consectetur a sit amet felis. Cras non mi id libero dictum iaculis id dignissim eros. Praesent eget enim dui, sed bibendum neque. Ut interdum nisl id leo malesuada ornare. Pellentesque id nisl eu odio volutpat posuere et at massa. Pellentesque nec lorem justo. Integer sem urna, pharetra sed sagittis vitae, condimentum ac felis. Ut vitae sapien ac tortor adipiscing pharetra. Cras tristique urna tempus ante volutpat eleifend non eu ligula. Mauris sodales nisl et lorem tristique sodales. Mauris arcu orci, vehicula semper cursus ac, dapibus ut mi." + + onLineLaidOut: { + line.width = line.number * 15 + if (line.number === 30 || line.number === 60) { + main.off = line.y + } + if (line.number >= 30) { + line.x = line.width + 30 + line.y -= main.off + } + if (line.number >= 60) { + line.x = line.width * 2 + 60 + line.height = 20 + } + } + } +} diff --git a/tests/auto/quick/qquicktext/data/multilengthStrings.qml b/tests/auto/quick/qquicktext/data/multilengthStrings.qml new file mode 100644 index 0000000000..d26576eacd --- /dev/null +++ b/tests/auto/quick/qquicktext/data/multilengthStrings.qml @@ -0,0 +1,14 @@ +import QtQuick 2.0 + +Item { + width: 300 + height: 200 + + Text { + id: myText + objectName: "myText" + width: 100 + font.pixelSize: 15 + font.family: "Helvetica" + } +} diff --git a/tests/auto/quick/qquicktext/data/multilengthStringsWrapped.qml b/tests/auto/quick/qquicktext/data/multilengthStringsWrapped.qml new file mode 100644 index 0000000000..0da9bc353a --- /dev/null +++ b/tests/auto/quick/qquicktext/data/multilengthStringsWrapped.qml @@ -0,0 +1,16 @@ +import QtQuick 2.0 + +Item { + width: 300 + height: 200 + + Text { + id: myText + objectName: "myText" + width: 100 + height: 36 + font.pixelSize: 15 + font.family: "Helvetica" + wrapMode: Text.Wrap + } +} diff --git a/tests/auto/quick/qquicktext/data/multilineelide.qml b/tests/auto/quick/qquicktext/data/multilineelide.qml new file mode 100644 index 0000000000..f3bb65775b --- /dev/null +++ b/tests/auto/quick/qquicktext/data/multilineelide.qml @@ -0,0 +1,10 @@ +import QtQuick 2.0 + +Text { + width: 200; height: 200 + wrapMode: Text.WordWrap + elide: Text.ElideRight + maximumLineCount: 3 + text: "the quick brown fox jumped over the lazy dog the quick brown fox jumped over the lazy dog the quick brown fox jumped over the lazy dog" +} + diff --git a/tests/auto/quick/qquicktext/data/qtbug_14734.qml b/tests/auto/quick/qquicktext/data/qtbug_14734.qml new file mode 100644 index 0000000000..e71a798421 --- /dev/null +++ b/tests/auto/quick/qquicktext/data/qtbug_14734.qml @@ -0,0 +1,10 @@ +import QtQuick 2.0 + +Rectangle { + width: 640 + height: 480 + + Text { + text: "í " + } +} diff --git a/tests/auto/quick/qquicktext/data/rotated.qml b/tests/auto/quick/qquicktext/data/rotated.qml new file mode 100644 index 0000000000..fecf64b249 --- /dev/null +++ b/tests/auto/quick/qquicktext/data/rotated.qml @@ -0,0 +1,18 @@ +import QtQuick 2.0 + +Rectangle { + width : 200 + height : 100 + + Text { + objectName: "text" + x: 20 + y: 20 + height : 20 + width : 80 + text : "Something" + rotation : 30 + transformOrigin : Item.TopLeft + } +} + diff --git a/tests/auto/quick/qquicktext/qquicktext.pro b/tests/auto/quick/qquicktext/qquicktext.pro new file mode 100644 index 0000000000..67e0b9fb90 --- /dev/null +++ b/tests/auto/quick/qquicktext/qquicktext.pro @@ -0,0 +1,19 @@ +CONFIG += testcase +TARGET = tst_qquicktext +macx:CONFIG -= app_bundle + +SOURCES += tst_qquicktext.cpp + +INCLUDEPATH += ../../shared/ +HEADERS += ../../shared/testhttpserver.h +SOURCES += ../../shared/testhttpserver.cpp + +include (../../shared/util.pri) + +testDataFiles.files = data +testDataFiles.path = . +DEPLOYMENT += testDataFiles + +CONFIG += parallel_test + +QT += core-private gui-private v8-private qml-private quick-private widgets-private opengl-private network testlib diff --git a/tests/auto/quick/qquicktext/tst_qquicktext.cpp b/tests/auto/quick/qquicktext/tst_qquicktext.cpp new file mode 100644 index 0000000000..754395dba1 --- /dev/null +++ b/tests/auto/quick/qquicktext/tst_qquicktext.cpp @@ -0,0 +1,2432 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "../../shared/util.h" +#include "testhttpserver.h" + +DEFINE_BOOL_CONFIG_OPTION(qmlDisableDistanceField, QML_DISABLE_DISTANCEFIELD) + +class tst_qquicktext : public QQmlDataTest +{ + Q_OBJECT +public: + tst_qquicktext(); + +private slots: + void text(); + void width(); + void wrap(); + void elide(); + void multilineElide(); + void textFormat(); + + void alignments_data(); + void alignments(); + + void baseUrl(); + void embeddedImages_data(); + void embeddedImages(); + + void lineCount(); + void lineHeight(); + + // ### these tests may be trivial + void horizontalAlignment(); + void horizontalAlignment_RightToLeft(); + void verticalAlignment(); + void font(); + void style(); + void color(); + void smooth(); + + // QQmlFontValueType + void weight(); + void underline(); + void overline(); + void strikeout(); + void capitalization(); + void letterSpacing(); + void wordSpacing(); + + void clickLink(); + + void implicitSize_data(); + void implicitSize(); + void contentSize(); + + void lineLaidOut(); + + void imgTagsBaseUrl_data(); + void imgTagsBaseUrl(); + void imgTagsAlign_data(); + void imgTagsAlign(); + void imgTagsMultipleImages(); + void imgTagsElide(); + void imgTagsUpdates(); + void imgTagsError(); + void fontSizeMode_data(); + void fontSizeMode(); + void fontSizeModeMultiline_data(); + void fontSizeModeMultiline(); + void multilengthStrings_data(); + void multilengthStrings(); + +private: + QStringList standard; + QStringList richText; + + QStringList horizontalAlignmentmentStrings; + QStringList verticalAlignmentmentStrings; + + QList verticalAlignmentments; + QList horizontalAlignmentments; + + QStringList styleStrings; + QList styles; + + QStringList colorStrings; + + QQmlEngine engine; + + QQuickView *createView(const QString &filename); +}; + +tst_qquicktext::tst_qquicktext() +{ + standard << "the quick brown fox jumped over the lazy dog" + << "the quick brown fox\n jumped over the lazy dog"; + + richText << "the quick brown fox jumped over the lazy dog" + << "the quick brown fox
          jumped over the lazy dog
          "; + + horizontalAlignmentmentStrings << "AlignLeft" + << "AlignRight" + << "AlignHCenter"; + + verticalAlignmentmentStrings << "AlignTop" + << "AlignBottom" + << "AlignVCenter"; + + horizontalAlignmentments << Qt::AlignLeft + << Qt::AlignRight + << Qt::AlignHCenter; + + verticalAlignmentments << Qt::AlignTop + << Qt::AlignBottom + << Qt::AlignVCenter; + + styleStrings << "Normal" + << "Outline" + << "Raised" + << "Sunken"; + + styles << QQuickText::Normal + << QQuickText::Outline + << QQuickText::Raised + << QQuickText::Sunken; + + colorStrings << "aliceblue" + << "antiquewhite" + << "aqua" + << "darkkhaki" + << "darkolivegreen" + << "dimgray" + << "palevioletred" + << "lightsteelblue" + << "#000000" + << "#AAAAAA" + << "#FFFFFF" + << "#2AC05F"; + // + // need a different test to do alpha channel test + // << "#AA0011DD" + // << "#00F16B11"; + // +} + +QQuickView *tst_qquicktext::createView(const QString &filename) +{ + QQuickView *canvas = new QQuickView(0); + + canvas->setSource(QUrl::fromLocalFile(filename)); + return canvas; +} + +void tst_qquicktext::text() +{ + { + QQmlComponent textComponent(&engine); + textComponent.setData("import QtQuick 2.0\nText { text: \"\" }", QUrl::fromLocalFile("")); + QQuickText *textObject = qobject_cast(textComponent.create()); + + QVERIFY(textObject != 0); + QCOMPARE(textObject->text(), QString("")); + QVERIFY(textObject->width() == 0); + + delete textObject; + } + + for (int i = 0; i < standard.size(); i++) + { + QString componentStr = "import QtQuick 2.0\nText { text: \"" + standard.at(i) + "\" }"; + QQmlComponent textComponent(&engine); + textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); + + QQuickText *textObject = qobject_cast(textComponent.create()); + + QVERIFY(textObject != 0); + QCOMPARE(textObject->text(), standard.at(i)); + QVERIFY(textObject->width() > 0); + + delete textObject; + } + + for (int i = 0; i < richText.size(); i++) + { + QString componentStr = "import QtQuick 2.0\nText { text: \"" + richText.at(i) + "\" }"; + QQmlComponent textComponent(&engine); + textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); + QQuickText *textObject = qobject_cast(textComponent.create()); + + QVERIFY(textObject != 0); + QString expected = richText.at(i); + QCOMPARE(textObject->text(), expected.replace("\\\"", "\"")); + QVERIFY(textObject->width() > 0); + + delete textObject; + } +} + +void tst_qquicktext::width() +{ + // uses Font metrics to find the width for standard and document to find the width for rich + { + QQmlComponent textComponent(&engine); + textComponent.setData("import QtQuick 2.0\nText { text: \"\" }", QUrl::fromLocalFile("")); + QQuickText *textObject = qobject_cast(textComponent.create()); + + QVERIFY(textObject != 0); + QCOMPARE(textObject->width(), 0.); + + delete textObject; + } + + bool requiresUnhintedMetrics = !qmlDisableDistanceField(); + + for (int i = 0; i < standard.size(); i++) + { + QVERIFY(!Qt::mightBeRichText(standard.at(i))); // self-test + + QFont f; + qreal metricWidth = 0.0; + + if (requiresUnhintedMetrics) { + QString s = standard.at(i); + s.replace(QLatin1Char('\n'), QChar::LineSeparator); + + QTextLayout layout(s); + layout.setFlags(Qt::TextExpandTabs | Qt::TextShowMnemonic); + { + QTextOption option; + option.setUseDesignMetrics(true); + layout.setTextOption(option); + } + + layout.beginLayout(); + forever { + QTextLine line = layout.createLine(); + if (!line.isValid()) + break; + } + + layout.endLayout(); + + metricWidth = qCeil(layout.boundingRect().width()); + } else { + QFontMetricsF fm(f); + qreal metricWidth = fm.size(Qt::TextExpandTabs && Qt::TextShowMnemonic, standard.at(i)).width(); + metricWidth = qCeil(metricWidth); + } + + QString componentStr = "import QtQuick 2.0\nText { text: \"" + standard.at(i) + "\" }"; + QQmlComponent textComponent(&engine); + textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); + QQuickText *textObject = qobject_cast(textComponent.create()); + + QVERIFY(textObject != 0); + QVERIFY(textObject->boundingRect().width() > 0); + QCOMPARE(textObject->width(), qreal(metricWidth)); + QVERIFY(textObject->textFormat() == QQuickText::AutoText); // setting text doesn't change format + + delete textObject; + } + + for (int i = 0; i < richText.size(); i++) + { + QVERIFY(Qt::mightBeRichText(richText.at(i))); // self-test + + QString componentStr = "import QtQuick 2.0\nText { text: \"" + richText.at(i) + "\"; textFormat: Text.RichText }"; + QQmlComponent textComponent(&engine); + textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); + QQuickText *textObject = qobject_cast(textComponent.create()); + QVERIFY(textObject != 0); + + QQuickTextPrivate *textPrivate = QQuickTextPrivate::get(textObject); + QVERIFY(textPrivate != 0); + + QTextDocument *doc = textPrivate->textDocument(); + QVERIFY(doc != 0); + + QCOMPARE(int(textObject->width()), int(doc->idealWidth())); + QVERIFY(textObject->textFormat() == QQuickText::RichText); + + delete textObject; + } +} + +void tst_qquicktext::wrap() +{ + int textHeight = 0; + // for specified width and wrap set true + { + QQmlComponent textComponent(&engine); + textComponent.setData("import QtQuick 2.0\nText { text: \"Hello\"; wrapMode: Text.WordWrap; width: 300 }", QUrl::fromLocalFile("")); + QQuickText *textObject = qobject_cast(textComponent.create()); + textHeight = textObject->height(); + + QVERIFY(textObject != 0); + QVERIFY(textObject->wrapMode() == QQuickText::WordWrap); + QCOMPARE(textObject->width(), 300.); + + delete textObject; + } + + for (int i = 0; i < standard.size(); i++) + { + QString componentStr = "import QtQuick 2.0\nText { wrapMode: Text.WordWrap; width: 30; text: \"" + standard.at(i) + "\" }"; + QQmlComponent textComponent(&engine); + textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); + QQuickText *textObject = qobject_cast(textComponent.create()); + + QVERIFY(textObject != 0); + QCOMPARE(textObject->width(), 30.); + QVERIFY(textObject->height() > textHeight); + + int oldHeight = textObject->height(); + textObject->setWidth(100); + QVERIFY(textObject->height() < oldHeight); + + delete textObject; + } + + for (int i = 0; i < richText.size(); i++) + { + QString componentStr = "import QtQuick 2.0\nText { wrapMode: Text.WordWrap; width: 30; text: \"" + richText.at(i) + "\" }"; + QQmlComponent textComponent(&engine); + textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); + QQuickText *textObject = qobject_cast(textComponent.create()); + + QVERIFY(textObject != 0); + QCOMPARE(textObject->width(), 30.); + QVERIFY(textObject->height() > textHeight); + + qreal oldHeight = textObject->height(); + textObject->setWidth(100); + QVERIFY(textObject->height() < oldHeight); + + delete textObject; + } + + // richtext again with a fixed height + for (int i = 0; i < richText.size(); i++) + { + QString componentStr = "import QtQuick 2.0\nText { wrapMode: Text.WordWrap; width: 30; height: 50; text: \"" + richText.at(i) + "\" }"; + QQmlComponent textComponent(&engine); + textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); + QQuickText *textObject = qobject_cast(textComponent.create()); + + QVERIFY(textObject != 0); + QCOMPARE(textObject->width(), 30.); + QVERIFY(textObject->implicitHeight() > textHeight); + + qreal oldHeight = textObject->implicitHeight(); + textObject->setWidth(100); + QVERIFY(textObject->implicitHeight() < oldHeight); + + delete textObject; + } +} + +void tst_qquicktext::elide() +{ + for (QQuickText::TextElideMode m = QQuickText::ElideLeft; m<=QQuickText::ElideNone; m=QQuickText::TextElideMode(int(m)+1)) { + const char* elidename[]={"ElideLeft", "ElideRight", "ElideMiddle", "ElideNone"}; + QString elide = "elide: Text." + QString(elidename[int(m)]) + ";"; + + // XXX Poor coverage. + + { + QQmlComponent textComponent(&engine); + textComponent.setData(("import QtQuick 2.0\nText { text: \"\"; "+elide+" width: 100 }").toLatin1(), QUrl::fromLocalFile("")); + QQuickText *textObject = qobject_cast(textComponent.create()); + + QCOMPARE(textObject->elideMode(), m); + QCOMPARE(textObject->width(), 100.); + + delete textObject; + } + + for (int i = 0; i < standard.size(); i++) + { + QString componentStr = "import QtQuick 2.0\nText { "+elide+" width: 100; text: \"" + standard.at(i) + "\" }"; + QQmlComponent textComponent(&engine); + textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); + QQuickText *textObject = qobject_cast(textComponent.create()); + + QCOMPARE(textObject->elideMode(), m); + QCOMPARE(textObject->width(), 100.); + + delete textObject; + } + + // richtext - does nothing + for (int i = 0; i < richText.size(); i++) + { + QString componentStr = "import QtQuick 2.0\nText { "+elide+" width: 100; text: \"" + richText.at(i) + "\" }"; + QQmlComponent textComponent(&engine); + textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); + QQuickText *textObject = qobject_cast(textComponent.create()); + + QCOMPARE(textObject->elideMode(), m); + QCOMPARE(textObject->width(), 100.); + + delete textObject; + } + } +} + +void tst_qquicktext::multilineElide() +{ + QQuickView *canvas = createView(testFile("multilineelide.qml")); + + QQuickText *myText = qobject_cast(canvas->rootObject()); + QVERIFY(myText != 0); + + QCOMPARE(myText->lineCount(), 3); + QCOMPARE(myText->truncated(), true); + + qreal lineHeight = myText->contentHeight() / 3.; + + // reduce size and ensure fewer lines are drawn + myText->setHeight(lineHeight * 2); + QCOMPARE(myText->lineCount(), 2); + + myText->setHeight(lineHeight); + QCOMPARE(myText->lineCount(), 1); + + myText->setHeight(5); + QCOMPARE(myText->lineCount(), 1); + + myText->setHeight(lineHeight * 3); + QCOMPARE(myText->lineCount(), 3); + + // remove max count and show all lines. + myText->setHeight(1000); + myText->resetMaximumLineCount(); + + QCOMPARE(myText->truncated(), false); + + // reduce size again + myText->setHeight(lineHeight * 2); + QCOMPARE(myText->lineCount(), 2); + QCOMPARE(myText->truncated(), true); + + // change line height + myText->setLineHeight(1.1); + QCOMPARE(myText->lineCount(), 1); + + delete canvas; +} + +void tst_qquicktext::textFormat() +{ + { + QQmlComponent textComponent(&engine); + textComponent.setData("import QtQuick 2.0\nText { text: \"Hello\"; textFormat: Text.RichText }", QUrl::fromLocalFile("")); + QQuickText *textObject = qobject_cast(textComponent.create()); + + QVERIFY(textObject != 0); + QVERIFY(textObject->textFormat() == QQuickText::RichText); + + QQuickTextPrivate *textPrivate = QQuickTextPrivate::get(textObject); + QVERIFY(textPrivate != 0); + QVERIFY(textPrivate->richText == true); + + delete textObject; + } + { + QQmlComponent textComponent(&engine); + textComponent.setData("import QtQuick 2.0\nText { text: \"Hello\" }", QUrl::fromLocalFile("")); + QQuickText *textObject = qobject_cast(textComponent.create()); + + QVERIFY(textObject != 0); + QVERIFY(textObject->textFormat() == QQuickText::AutoText); + + QQuickTextPrivate *textPrivate = QQuickTextPrivate::get(textObject); + QVERIFY(textPrivate != 0); + QVERIFY(textPrivate->styledText == true); + + delete textObject; + } + { + QQmlComponent textComponent(&engine); + textComponent.setData("import QtQuick 2.0\nText { text: \"Hello\"; textFormat: Text.PlainText }", QUrl::fromLocalFile("")); + QQuickText *textObject = qobject_cast(textComponent.create()); + + QVERIFY(textObject != 0); + QVERIFY(textObject->textFormat() == QQuickText::PlainText); + + delete textObject; + } +} + + +void tst_qquicktext::alignments_data() +{ + QTest::addColumn("hAlign"); + QTest::addColumn("vAlign"); + QTest::addColumn("expectfile"); + + QTest::newRow("LT") << int(Qt::AlignLeft) << int(Qt::AlignTop) << testFile("alignments_lt.png"); + QTest::newRow("RT") << int(Qt::AlignRight) << int(Qt::AlignTop) << testFile("alignments_rt.png"); + QTest::newRow("CT") << int(Qt::AlignHCenter) << int(Qt::AlignTop) << testFile("alignments_ct.png"); + + QTest::newRow("LB") << int(Qt::AlignLeft) << int(Qt::AlignBottom) << testFile("alignments_lb.png"); + QTest::newRow("RB") << int(Qt::AlignRight) << int(Qt::AlignBottom) << testFile("alignments_rb.png"); + QTest::newRow("CB") << int(Qt::AlignHCenter) << int(Qt::AlignBottom) << testFile("alignments_cb.png"); + + QTest::newRow("LC") << int(Qt::AlignLeft) << int(Qt::AlignVCenter) << testFile("alignments_lc.png"); + QTest::newRow("RC") << int(Qt::AlignRight) << int(Qt::AlignVCenter) << testFile("alignments_rc.png"); + QTest::newRow("CC") << int(Qt::AlignHCenter) << int(Qt::AlignVCenter) << testFile("alignments_cc.png"); +} + + +void tst_qquicktext::alignments() +{ + QSKIP("Text alignment pixmap comparison tests will not work with scenegraph"); +#if (0)// No widgets in scenegraph + QFETCH(int, hAlign); + QFETCH(int, vAlign); + QFETCH(QString, expectfile); + + QQuickView *canvas = createView(testFile("alignments.qml")); + canvas->show(); + canvas->requestActivateWindow(); + QTest::qWait(50); + QTRY_COMPARE(QGuiApplication::activeWindow(), static_cast(canvas)); + + QObject *ob = canvas->rootObject(); + QVERIFY(ob != 0); + ob->setProperty("horizontalAlignment",hAlign); + ob->setProperty("verticalAlignment",vAlign); + QTRY_COMPARE(ob->property("running").toBool(),false); + QImage actual(canvas->width(), canvas->height(), QImage::Format_RGB32); + actual.fill(qRgb(255,255,255)); + QPainter p(&actual); + canvas->render(&p); + + QImage expect(expectfile); + if (QGuiApplicationPrivate::graphics_system_name == "raster" || QGuiApplicationPrivate::graphics_system_name == "") { + QCOMPARE(actual,expect); + } + delete canvas; +#endif +} + +//the alignment tests may be trivial o.oa +void tst_qquicktext::horizontalAlignment() +{ + //test one align each, and then test if two align fails. + + for (int i = 0; i < standard.size(); i++) + { + for (int j=0; j < horizontalAlignmentmentStrings.size(); j++) + { + QString componentStr = "import QtQuick 2.0\nText { horizontalAlignment: \"" + horizontalAlignmentmentStrings.at(j) + "\"; text: \"" + standard.at(i) + "\" }"; + QQmlComponent textComponent(&engine); + textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); + QQuickText *textObject = qobject_cast(textComponent.create()); + + QCOMPARE((int)textObject->hAlign(), (int)horizontalAlignmentments.at(j)); + + delete textObject; + } + } + + for (int i = 0; i < richText.size(); i++) + { + for (int j=0; j < horizontalAlignmentmentStrings.size(); j++) + { + QString componentStr = "import QtQuick 2.0\nText { horizontalAlignment: \"" + horizontalAlignmentmentStrings.at(j) + "\"; text: \"" + richText.at(i) + "\" }"; + QQmlComponent textComponent(&engine); + textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); + QQuickText *textObject = qobject_cast(textComponent.create()); + + QCOMPARE((int)textObject->hAlign(), (int)horizontalAlignmentments.at(j)); + + delete textObject; + } + } + +} + +void tst_qquicktext::horizontalAlignment_RightToLeft() +{ + QQuickView *canvas = createView(testFile("horizontalAlignment_RightToLeft.qml")); + QQuickText *text = canvas->rootObject()->findChild("text"); + QVERIFY(text != 0); + canvas->show(); + + QQuickTextPrivate *textPrivate = QQuickTextPrivate::get(text); + QVERIFY(textPrivate != 0); + + QTRY_VERIFY(textPrivate->layout.lineCount()); + + // implicit alignment should follow the reading direction of RTL text + QCOMPARE(text->hAlign(), QQuickText::AlignRight); + QCOMPARE(text->effectiveHAlign(), text->hAlign()); + QVERIFY(textPrivate->layout.lineAt(0).naturalTextRect().left() > canvas->width()/2); + + // explicitly left aligned text + text->setHAlign(QQuickText::AlignLeft); + QCOMPARE(text->hAlign(), QQuickText::AlignLeft); + QCOMPARE(text->effectiveHAlign(), text->hAlign()); + QVERIFY(textPrivate->layout.lineAt(0).naturalTextRect().left() < canvas->width()/2); + + // explicitly right aligned text + text->setHAlign(QQuickText::AlignRight); + QCOMPARE(text->hAlign(), QQuickText::AlignRight); + QCOMPARE(text->effectiveHAlign(), text->hAlign()); + QVERIFY(textPrivate->layout.lineAt(0).naturalTextRect().left() > canvas->width()/2); + + // change to rich text + QString textString = text->text(); + text->setText(QString("") + textString + QString("")); + text->setTextFormat(QQuickText::RichText); + text->resetHAlign(); + + // implicitly aligned rich text should follow the reading direction of text + QCOMPARE(text->hAlign(), QQuickText::AlignRight); + QCOMPARE(text->effectiveHAlign(), text->hAlign()); + QVERIFY(textPrivate->textDocument()->defaultTextOption().alignment() & Qt::AlignLeft); + + // explicitly left aligned rich text + text->setHAlign(QQuickText::AlignLeft); + QCOMPARE(text->hAlign(), QQuickText::AlignLeft); + QCOMPARE(text->effectiveHAlign(), text->hAlign()); + QVERIFY(textPrivate->textDocument()->defaultTextOption().alignment() & Qt::AlignRight); + + // explicitly right aligned rich text + text->setHAlign(QQuickText::AlignRight); + QCOMPARE(text->hAlign(), QQuickText::AlignRight); + QCOMPARE(text->effectiveHAlign(), text->hAlign()); + QVERIFY(textPrivate->textDocument()->defaultTextOption().alignment() & Qt::AlignLeft); + + text->setText(textString); + text->setTextFormat(QQuickText::PlainText); + + // explicitly center aligned + text->setHAlign(QQuickText::AlignHCenter); + QCOMPARE(text->hAlign(), QQuickText::AlignHCenter); + QCOMPARE(text->effectiveHAlign(), text->hAlign()); + QVERIFY(textPrivate->layout.lineAt(0).naturalTextRect().left() < canvas->width()/2); + QVERIFY(textPrivate->layout.lineAt(0).naturalTextRect().right() > canvas->width()/2); + + // reseted alignment should go back to following the text reading direction + text->resetHAlign(); + QCOMPARE(text->hAlign(), QQuickText::AlignRight); + QVERIFY(textPrivate->layout.lineAt(0).naturalTextRect().left() > canvas->width()/2); + + // mirror the text item + QQuickItemPrivate::get(text)->setLayoutMirror(true); + + // mirrored implicit alignment should continue to follow the reading direction of the text + QCOMPARE(text->hAlign(), QQuickText::AlignRight); + QCOMPARE(text->effectiveHAlign(), QQuickText::AlignRight); + QVERIFY(textPrivate->layout.lineAt(0).naturalTextRect().left() > canvas->width()/2); + + // mirrored explicitly right aligned behaves as left aligned + text->setHAlign(QQuickText::AlignRight); + QCOMPARE(text->hAlign(), QQuickText::AlignRight); + QCOMPARE(text->effectiveHAlign(), QQuickText::AlignLeft); + QVERIFY(textPrivate->layout.lineAt(0).naturalTextRect().left() < canvas->width()/2); + + // mirrored explicitly left aligned behaves as right aligned + text->setHAlign(QQuickText::AlignLeft); + QCOMPARE(text->hAlign(), QQuickText::AlignLeft); + QCOMPARE(text->effectiveHAlign(), QQuickText::AlignRight); + QVERIFY(textPrivate->layout.lineAt(0).naturalTextRect().left() > canvas->width()/2); + + // disable mirroring + QQuickItemPrivate::get(text)->setLayoutMirror(false); + text->resetHAlign(); + + // English text should be implicitly left aligned + text->setText("Hello world!"); + QCOMPARE(text->hAlign(), QQuickText::AlignLeft); + QVERIFY(textPrivate->layout.lineAt(0).naturalTextRect().left() < canvas->width()/2); + + // empty text with implicit alignment follows the system locale-based + // keyboard input direction from QInputMethod::inputDirection() + text->setText(""); + QCOMPARE(text->hAlign(), qApp->inputMethod()->inputDirection() == Qt::LeftToRight ? + QQuickText::AlignLeft : QQuickText::AlignRight); + text->setHAlign(QQuickText::AlignRight); + QCOMPARE(text->hAlign(), QQuickText::AlignRight); + + delete canvas; + + // alignment of Text with no text set to it + QString componentStr = "import QtQuick 2.0\nText {}"; + QQmlComponent textComponent(&engine); + textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); + QQuickText *textObject = qobject_cast(textComponent.create()); + QCOMPARE(textObject->hAlign(), qApp->inputMethod()->inputDirection() == Qt::LeftToRight ? + QQuickText::AlignLeft : QQuickText::AlignRight); + delete textObject; +} + +void tst_qquicktext::verticalAlignment() +{ + //test one align each, and then test if two align fails. + + for (int i = 0; i < standard.size(); i++) + { + for (int j=0; j < verticalAlignmentmentStrings.size(); j++) + { + QString componentStr = "import QtQuick 2.0\nText { verticalAlignment: \"" + verticalAlignmentmentStrings.at(j) + "\"; text: \"" + standard.at(i) + "\" }"; + QQmlComponent textComponent(&engine); + textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); + QQuickText *textObject = qobject_cast(textComponent.create()); + + QVERIFY(textObject != 0); + QCOMPARE((int)textObject->vAlign(), (int)verticalAlignmentments.at(j)); + + delete textObject; + } + } + + for (int i = 0; i < richText.size(); i++) + { + for (int j=0; j < verticalAlignmentmentStrings.size(); j++) + { + QString componentStr = "import QtQuick 2.0\nText { verticalAlignment: \"" + verticalAlignmentmentStrings.at(j) + "\"; text: \"" + richText.at(i) + "\" }"; + QQmlComponent textComponent(&engine); + textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); + QQuickText *textObject = qobject_cast(textComponent.create()); + + QVERIFY(textObject != 0); + QCOMPARE((int)textObject->vAlign(), (int)verticalAlignmentments.at(j)); + + delete textObject; + } + } + +} + +void tst_qquicktext::font() +{ + //test size, then bold, then italic, then family + { + QString componentStr = "import QtQuick 2.0\nText { font.pointSize: 40; text: \"Hello World\" }"; + QQmlComponent textComponent(&engine); + textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); + QQuickText *textObject = qobject_cast(textComponent.create()); + + QCOMPARE(textObject->font().pointSize(), 40); + QCOMPARE(textObject->font().bold(), false); + QCOMPARE(textObject->font().italic(), false); + + delete textObject; + } + + { + QString componentStr = "import QtQuick 2.0\nText { font.pixelSize: 40; text: \"Hello World\" }"; + QQmlComponent textComponent(&engine); + textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); + QQuickText *textObject = qobject_cast(textComponent.create()); + + QCOMPARE(textObject->font().pixelSize(), 40); + QCOMPARE(textObject->font().bold(), false); + QCOMPARE(textObject->font().italic(), false); + + delete textObject; + } + + { + QString componentStr = "import QtQuick 2.0\nText { font.bold: true; text: \"Hello World\" }"; + QQmlComponent textComponent(&engine); + textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); + QQuickText *textObject = qobject_cast(textComponent.create()); + + QCOMPARE(textObject->font().bold(), true); + QCOMPARE(textObject->font().italic(), false); + + delete textObject; + } + + { + QString componentStr = "import QtQuick 2.0\nText { font.italic: true; text: \"Hello World\" }"; + QQmlComponent textComponent(&engine); + textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); + QQuickText *textObject = qobject_cast(textComponent.create()); + + QCOMPARE(textObject->font().italic(), true); + QCOMPARE(textObject->font().bold(), false); + + delete textObject; + } + + { + QString componentStr = "import QtQuick 2.0\nText { font.family: \"Helvetica\"; text: \"Hello World\" }"; + QQmlComponent textComponent(&engine); + textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); + QQuickText *textObject = qobject_cast(textComponent.create()); + + QCOMPARE(textObject->font().family(), QString("Helvetica")); + QCOMPARE(textObject->font().bold(), false); + QCOMPARE(textObject->font().italic(), false); + + delete textObject; + } + + { + QString componentStr = "import QtQuick 2.0\nText { font.family: \"\"; text: \"Hello World\" }"; + QQmlComponent textComponent(&engine); + textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); + QQuickText *textObject = qobject_cast(textComponent.create()); + + QCOMPARE(textObject->font().family(), QString("")); + + delete textObject; + } +} + +void tst_qquicktext::style() +{ + //test style + for (int i = 0; i < styles.size(); i++) + { + QString componentStr = "import QtQuick 2.0\nText { style: \"" + styleStrings.at(i) + "\"; styleColor: \"white\"; text: \"Hello World\" }"; + QQmlComponent textComponent(&engine); + textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); + QQuickText *textObject = qobject_cast(textComponent.create()); + + QCOMPARE((int)textObject->style(), (int)styles.at(i)); + QCOMPARE(textObject->styleColor(), QColor("white")); + + delete textObject; + } + QString componentStr = "import QtQuick 2.0\nText { text: \"Hello World\" }"; + QQmlComponent textComponent(&engine); + textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); + QQuickText *textObject = qobject_cast(textComponent.create()); + + QRectF brPre = textObject->boundingRect(); + textObject->setStyle(QQuickText::Outline); + QRectF brPost = textObject->boundingRect(); + + QVERIFY(brPre.width() < brPost.width()); + QVERIFY(brPre.height() < brPost.height()); + + delete textObject; +} + +void tst_qquicktext::color() +{ + //test style + for (int i = 0; i < colorStrings.size(); i++) + { + QString componentStr = "import QtQuick 2.0\nText { color: \"" + colorStrings.at(i) + "\"; text: \"Hello World\" }"; + QQmlComponent textComponent(&engine); + textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); + QQuickText *textObject = qobject_cast(textComponent.create()); + + QCOMPARE(textObject->color(), QColor(colorStrings.at(i))); + QCOMPARE(textObject->styleColor(), QColor("black")); + QCOMPARE(textObject->linkColor(), QColor("blue")); + + delete textObject; + } + + for (int i = 0; i < colorStrings.size(); i++) + { + QString componentStr = "import QtQuick 2.0\nText { styleColor: \"" + colorStrings.at(i) + "\"; text: \"Hello World\" }"; + QQmlComponent textComponent(&engine); + textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); + QQuickText *textObject = qobject_cast(textComponent.create()); + + QCOMPARE(textObject->styleColor(), QColor(colorStrings.at(i))); + // default color to black? + QCOMPARE(textObject->color(), QColor("black")); + QCOMPARE(textObject->linkColor(), QColor("blue")); + + delete textObject; + } + + for (int i = 0; i < colorStrings.size(); i++) + { + QString componentStr = "import QtQuick 2.0\nText { linkColor: \"" + colorStrings.at(i) + "\"; text: \"Hello World\" }"; + QQmlComponent textComponent(&engine); + textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); + QQuickText *textObject = qobject_cast(textComponent.create()); + + QCOMPARE(textObject->styleColor(), QColor("black")); + QCOMPARE(textObject->color(), QColor("black")); + QCOMPARE(textObject->linkColor(), QColor(colorStrings.at(i))); + + delete textObject; + } + + for (int i = 0; i < colorStrings.size(); i++) + { + for (int j = 0; j < colorStrings.size(); j++) + { + QString componentStr = "import QtQuick 2.0\nText { " + "color: \"" + colorStrings.at(i) + "\"; " + "styleColor: \"" + colorStrings.at(j) + "\"; " + "linkColor: \"" + colorStrings.at(j) + "\"; " + "text: \"Hello World\" }"; + QQmlComponent textComponent(&engine); + textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); + QQuickText *textObject = qobject_cast(textComponent.create()); + + QCOMPARE(textObject->color(), QColor(colorStrings.at(i))); + QCOMPARE(textObject->styleColor(), QColor(colorStrings.at(j))); + QCOMPARE(textObject->linkColor(), QColor(colorStrings.at(j))); + + delete textObject; + } + } + { + QString colorStr = "#AA001234"; + QColor testColor("#001234"); + testColor.setAlpha(170); + + QString componentStr = "import QtQuick 2.0\nText { color: \"" + colorStr + "\"; text: \"Hello World\" }"; + QQmlComponent textComponent(&engine); + textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); + QQuickText *textObject = qobject_cast(textComponent.create()); + + QCOMPARE(textObject->color(), testColor); + + delete textObject; + } { + QString colorStr = "#001234"; + QColor testColor(colorStr); + + QString componentStr = "import QtQuick 2.0\nText { color: \"" + colorStr + "\"; text: \"Hello World\" }"; + QQmlComponent textComponent(&engine); + textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); + QScopedPointer object(textComponent.create()); + QQuickText *textObject = qobject_cast(object.data()); + + QSignalSpy spy(textObject, SIGNAL(colorChanged())); + + QCOMPARE(textObject->color(), testColor); + textObject->setColor(testColor); + QCOMPARE(textObject->color(), testColor); + QCOMPARE(spy.count(), 0); + + testColor = QColor("black"); + textObject->setColor(testColor); + QCOMPARE(textObject->color(), testColor); + QCOMPARE(spy.count(), 1); + } { + QString colorStr = "#001234"; + QColor testColor(colorStr); + + QString componentStr = "import QtQuick 2.0\nText { styleColor: \"" + colorStr + "\"; text: \"Hello World\" }"; + QQmlComponent textComponent(&engine); + textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); + QScopedPointer object(textComponent.create()); + QQuickText *textObject = qobject_cast(object.data()); + + QSignalSpy spy(textObject, SIGNAL(styleColorChanged())); + + QCOMPARE(textObject->styleColor(), testColor); + textObject->setStyleColor(testColor); + QCOMPARE(textObject->styleColor(), testColor); + QCOMPARE(spy.count(), 0); + + testColor = QColor("black"); + textObject->setStyleColor(testColor); + QCOMPARE(textObject->styleColor(), testColor); + QCOMPARE(spy.count(), 1); + } { + QString colorStr = "#001234"; + QColor testColor(colorStr); + + QString componentStr = "import QtQuick 2.0\nText { linkColor: \"" + colorStr + "\"; text: \"Hello World\" }"; + QQmlComponent textComponent(&engine); + textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); + QScopedPointer object(textComponent.create()); + QQuickText *textObject = qobject_cast(object.data()); + + QSignalSpy spy(textObject, SIGNAL(linkColorChanged())); + + QCOMPARE(textObject->linkColor(), testColor); + textObject->setLinkColor(testColor); + QCOMPARE(textObject->linkColor(), testColor); + QCOMPARE(spy.count(), 0); + + testColor = QColor("black"); + textObject->setLinkColor(testColor); + QCOMPARE(textObject->linkColor(), testColor); + QCOMPARE(spy.count(), 1); + } +} + +void tst_qquicktext::smooth() +{ + for (int i = 0; i < standard.size(); i++) + { + { + QString componentStr = "import QtQuick 2.0\nText { smooth: true; text: \"" + standard.at(i) + "\" }"; + QQmlComponent textComponent(&engine); + textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); + QQuickText *textObject = qobject_cast(textComponent.create()); + QCOMPARE(textObject->smooth(), true); + + delete textObject; + } + { + QString componentStr = "import QtQuick 2.0\nText { text: \"" + standard.at(i) + "\" }"; + QQmlComponent textComponent(&engine); + textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); + QQuickText *textObject = qobject_cast(textComponent.create()); + QCOMPARE(textObject->smooth(), false); + + delete textObject; + } + } + for (int i = 0; i < richText.size(); i++) + { + { + QString componentStr = "import QtQuick 2.0\nText { smooth: true; text: \"" + richText.at(i) + "\" }"; + QQmlComponent textComponent(&engine); + textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); + QQuickText *textObject = qobject_cast(textComponent.create()); + QCOMPARE(textObject->smooth(), true); + + delete textObject; + } + { + QString componentStr = "import QtQuick 2.0\nText { text: \"" + richText.at(i) + "\" }"; + QQmlComponent textComponent(&engine); + textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); + QQuickText *textObject = qobject_cast(textComponent.create()); + QCOMPARE(textObject->smooth(), false); + + delete textObject; + } + } +} + +void tst_qquicktext::weight() +{ + { + QString componentStr = "import QtQuick 2.0\nText { text: \"Hello world!\" }"; + QQmlComponent textComponent(&engine); + textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); + QQuickText *textObject = qobject_cast(textComponent.create()); + + QVERIFY(textObject != 0); + QCOMPARE((int)textObject->font().weight(), (int)QQmlFontValueType::Normal); + + delete textObject; + } + { + QString componentStr = "import QtQuick 2.0\nText { font.weight: \"Bold\"; text: \"Hello world!\" }"; + QQmlComponent textComponent(&engine); + textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); + QQuickText *textObject = qobject_cast(textComponent.create()); + + QVERIFY(textObject != 0); + QCOMPARE((int)textObject->font().weight(), (int)QQmlFontValueType::Bold); + + delete textObject; + } +} + +void tst_qquicktext::underline() +{ + { + QString componentStr = "import QtQuick 2.0\nText { text: \"Hello world!\" }"; + QQmlComponent textComponent(&engine); + textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); + QQuickText *textObject = qobject_cast(textComponent.create()); + + QVERIFY(textObject != 0); + QCOMPARE(textObject->font().underline(), false); + + delete textObject; + } + { + QString componentStr = "import QtQuick 2.0\nText { font.underline: true; text: \"Hello world!\" }"; + QQmlComponent textComponent(&engine); + textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); + QQuickText *textObject = qobject_cast(textComponent.create()); + + QVERIFY(textObject != 0); + QCOMPARE(textObject->font().underline(), true); + + delete textObject; + } +} + +void tst_qquicktext::overline() +{ + { + QString componentStr = "import QtQuick 2.0\nText { text: \"Hello world!\" }"; + QQmlComponent textComponent(&engine); + textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); + QQuickText *textObject = qobject_cast(textComponent.create()); + + QVERIFY(textObject != 0); + QCOMPARE(textObject->font().overline(), false); + + delete textObject; + } + { + QString componentStr = "import QtQuick 2.0\nText { font.overline: true; text: \"Hello world!\" }"; + QQmlComponent textComponent(&engine); + textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); + QQuickText *textObject = qobject_cast(textComponent.create()); + + QVERIFY(textObject != 0); + QCOMPARE(textObject->font().overline(), true); + + delete textObject; + } +} + +void tst_qquicktext::strikeout() +{ + { + QString componentStr = "import QtQuick 2.0\nText { text: \"Hello world!\" }"; + QQmlComponent textComponent(&engine); + textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); + QQuickText *textObject = qobject_cast(textComponent.create()); + + QVERIFY(textObject != 0); + QCOMPARE(textObject->font().strikeOut(), false); + + delete textObject; + } + { + QString componentStr = "import QtQuick 2.0\nText { font.strikeout: true; text: \"Hello world!\" }"; + QQmlComponent textComponent(&engine); + textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); + QQuickText *textObject = qobject_cast(textComponent.create()); + + QVERIFY(textObject != 0); + QCOMPARE(textObject->font().strikeOut(), true); + + delete textObject; + } +} + +void tst_qquicktext::capitalization() +{ + { + QString componentStr = "import QtQuick 2.0\nText { text: \"Hello world!\" }"; + QQmlComponent textComponent(&engine); + textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); + QQuickText *textObject = qobject_cast(textComponent.create()); + + QVERIFY(textObject != 0); + QCOMPARE((int)textObject->font().capitalization(), (int)QQmlFontValueType::MixedCase); + + delete textObject; + } + { + QString componentStr = "import QtQuick 2.0\nText { text: \"Hello world!\"; font.capitalization: \"AllUppercase\" }"; + QQmlComponent textComponent(&engine); + textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); + QQuickText *textObject = qobject_cast(textComponent.create()); + + QVERIFY(textObject != 0); + QCOMPARE((int)textObject->font().capitalization(), (int)QQmlFontValueType::AllUppercase); + + delete textObject; + } + { + QString componentStr = "import QtQuick 2.0\nText { text: \"Hello world!\"; font.capitalization: \"AllLowercase\" }"; + QQmlComponent textComponent(&engine); + textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); + QQuickText *textObject = qobject_cast(textComponent.create()); + + QVERIFY(textObject != 0); + QCOMPARE((int)textObject->font().capitalization(), (int)QQmlFontValueType::AllLowercase); + + delete textObject; + } + { + QString componentStr = "import QtQuick 2.0\nText { text: \"Hello world!\"; font.capitalization: \"SmallCaps\" }"; + QQmlComponent textComponent(&engine); + textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); + QQuickText *textObject = qobject_cast(textComponent.create()); + + QVERIFY(textObject != 0); + QCOMPARE((int)textObject->font().capitalization(), (int)QQmlFontValueType::SmallCaps); + + delete textObject; + } + { + QString componentStr = "import QtQuick 2.0\nText { text: \"Hello world!\"; font.capitalization: \"Capitalize\" }"; + QQmlComponent textComponent(&engine); + textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); + QQuickText *textObject = qobject_cast(textComponent.create()); + + QVERIFY(textObject != 0); + QCOMPARE((int)textObject->font().capitalization(), (int)QQmlFontValueType::Capitalize); + + delete textObject; + } +} + +void tst_qquicktext::letterSpacing() +{ + { + QString componentStr = "import QtQuick 2.0\nText { text: \"Hello world!\" }"; + QQmlComponent textComponent(&engine); + textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); + QQuickText *textObject = qobject_cast(textComponent.create()); + + QVERIFY(textObject != 0); + QCOMPARE(textObject->font().letterSpacing(), 0.0); + + delete textObject; + } + { + QString componentStr = "import QtQuick 2.0\nText { text: \"Hello world!\"; font.letterSpacing: -2 }"; + QQmlComponent textComponent(&engine); + textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); + QQuickText *textObject = qobject_cast(textComponent.create()); + + QVERIFY(textObject != 0); + QCOMPARE(textObject->font().letterSpacing(), -2.); + + delete textObject; + } + { + QString componentStr = "import QtQuick 2.0\nText { text: \"Hello world!\"; font.letterSpacing: 3 }"; + QQmlComponent textComponent(&engine); + textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); + QQuickText *textObject = qobject_cast(textComponent.create()); + + QVERIFY(textObject != 0); + QCOMPARE(textObject->font().letterSpacing(), 3.); + + delete textObject; + } +} + +void tst_qquicktext::wordSpacing() +{ + { + QString componentStr = "import QtQuick 2.0\nText { text: \"Hello world!\" }"; + QQmlComponent textComponent(&engine); + textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); + QQuickText *textObject = qobject_cast(textComponent.create()); + + QVERIFY(textObject != 0); + QCOMPARE(textObject->font().wordSpacing(), 0.0); + + delete textObject; + } + { + QString componentStr = "import QtQuick 2.0\nText { text: \"Hello world!\"; font.wordSpacing: -50 }"; + QQmlComponent textComponent(&engine); + textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); + QQuickText *textObject = qobject_cast(textComponent.create()); + + QVERIFY(textObject != 0); + QCOMPARE(textObject->font().wordSpacing(), -50.); + + delete textObject; + } + { + QString componentStr = "import QtQuick 2.0\nText { text: \"Hello world!\"; font.wordSpacing: 200 }"; + QQmlComponent textComponent(&engine); + textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); + QQuickText *textObject = qobject_cast(textComponent.create()); + + QVERIFY(textObject != 0); + QCOMPARE(textObject->font().wordSpacing(), 200.); + + delete textObject; + } +} + + + + +class EventSender : public QQuickItem +{ +public: + void sendEvent(QMouseEvent *event) { + if (event->type() == QEvent::MouseButtonPress) + mousePressEvent(event); + else if (event->type() == QEvent::MouseButtonRelease) + mouseReleaseEvent(event); + else + qWarning() << "Trying to send unsupported event type"; + } +}; + +class LinkTest : public QObject +{ + Q_OBJECT +public: + LinkTest() {} + + QString link; + +public slots: + void linkClicked(QString l) { link = l; } +}; + +void tst_qquicktext::clickLink() +{ + { + QString componentStr = "import QtQuick 2.0\nText { text: \"Hello world!\" }"; + QQmlComponent textComponent(&engine); + textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); + QQuickText *textObject = qobject_cast(textComponent.create()); + + QVERIFY(textObject != 0); + + LinkTest test; + QObject::connect(textObject, SIGNAL(linkActivated(QString)), &test, SLOT(linkClicked(QString))); + + { + QMouseEvent me(QEvent::MouseButtonPress,QPointF(textObject->x()/2, textObject->y()/2), Qt::LeftButton, Qt::NoButton, Qt::NoModifier); + static_cast(static_cast(textObject))->sendEvent(&me); + + } + + { + QMouseEvent me(QEvent::MouseButtonRelease,QPointF(textObject->x()/2, textObject->y()/2), Qt::LeftButton, Qt::NoButton, Qt::NoModifier); + static_cast(static_cast(textObject))->sendEvent(&me); + + } + + + QCOMPARE(test.link, QLatin1String("http://qt.nokia.com")); + + delete textObject; + } +} + +void tst_qquicktext::baseUrl() +{ + QUrl localUrl("file:///tests/text.qml"); + QUrl remoteUrl("http://qt.nokia.com/test.qml"); + + QQmlComponent textComponent(&engine); + textComponent.setData("import QtQuick 2.0\n Text {}", localUrl); + QQuickText *textObject = qobject_cast(textComponent.create()); + + QCOMPARE(textObject->baseUrl(), localUrl); + + QSignalSpy spy(textObject, SIGNAL(baseUrlChanged())); + + textObject->setBaseUrl(localUrl); + QCOMPARE(textObject->baseUrl(), localUrl); + QCOMPARE(spy.count(), 0); + + textObject->setBaseUrl(remoteUrl); + QCOMPARE(textObject->baseUrl(), remoteUrl); + QCOMPARE(spy.count(), 1); + + textObject->resetBaseUrl(); + QCOMPARE(textObject->baseUrl(), localUrl); + QCOMPARE(spy.count(), 2); +} + +void tst_qquicktext::embeddedImages_data() +{ + QTest::addColumn("qmlfile"); + QTest::addColumn("error"); + QTest::newRow("local") << testFileUrl("embeddedImagesLocal.qml") << ""; + QTest::newRow("local-error") << testFileUrl("embeddedImagesLocalError.qml") + << testFileUrl("embeddedImagesLocalError.qml").toString()+":3:1: QML Text: Cannot open: " + testFileUrl("http/notexists.png").toString(); + QTest::newRow("local") << testFileUrl("embeddedImagesLocalRelative.qml") << ""; + QTest::newRow("remote") << testFileUrl("embeddedImagesRemote.qml") << ""; + QTest::newRow("remote-error") << testFileUrl("embeddedImagesRemoteError.qml") + << testFileUrl("embeddedImagesRemoteError.qml").toString()+":3:1: QML Text: Error downloading http://127.0.0.1:14453/notexists.png - server replied: Not found"; + QTest::newRow("remote") << testFileUrl("embeddedImagesRemoteRelative.qml") << ""; +} + +void tst_qquicktext::embeddedImages() +{ + // Tests QTBUG-9900 + + QFETCH(QUrl, qmlfile); + QFETCH(QString, error); + + TestHTTPServer server(14453); + server.serveDirectory(testFile("http")); + + if (!error.isEmpty()) + QTest::ignoreMessage(QtWarningMsg, error.toLatin1()); + + QQmlComponent textComponent(&engine, qmlfile); + QQuickText *textObject = qobject_cast(textComponent.create()); + + QVERIFY(textObject != 0); + + QTRY_COMPARE(textObject->resourcesLoading(), 0); + + QPixmap pm(testFile("http/exists.png")); + if (error.isEmpty()) { + QCOMPARE(textObject->width(), double(pm.width())); + QCOMPARE(textObject->height(), double(pm.height())); + } else { + QVERIFY(16 != pm.width()); // check test is effective + QCOMPARE(textObject->width(), 16.0); // default size of QTextDocument broken image icon + QCOMPARE(textObject->height(), 16.0); + } + + delete textObject; +} + +void tst_qquicktext::lineCount() +{ + QQuickView *canvas = createView(testFile("lineCount.qml")); + + QQuickText *myText = canvas->rootObject()->findChild("myText"); + QVERIFY(myText != 0); + + QVERIFY(myText->lineCount() > 1); + QVERIFY(!myText->truncated()); + QCOMPARE(myText->maximumLineCount(), INT_MAX); + + myText->setMaximumLineCount(2); + QCOMPARE(myText->lineCount(), 2); + QCOMPARE(myText->truncated(), true); + QCOMPARE(myText->maximumLineCount(), 2); + + myText->resetMaximumLineCount(); + QCOMPARE(myText->maximumLineCount(), INT_MAX); + QCOMPARE(myText->truncated(), false); + + myText->setElideMode(QQuickText::ElideRight); + myText->setMaximumLineCount(2); + QCOMPARE(myText->lineCount(), 2); + QCOMPARE(myText->truncated(), true); + QCOMPARE(myText->maximumLineCount(), 2); + + delete canvas; +} + +void tst_qquicktext::lineHeight() +{ + QQuickView *canvas = createView(testFile("lineHeight.qml")); + + QQuickText *myText = canvas->rootObject()->findChild("myText"); + QVERIFY(myText != 0); + + QVERIFY(myText->lineHeight() == 1); + QVERIFY(myText->lineHeightMode() == QQuickText::ProportionalHeight); + + qreal h = myText->height(); + myText->setLineHeight(1.5); + QCOMPARE(myText->height(), qreal(qCeil(h * 1.5))); + + myText->setLineHeightMode(QQuickText::FixedHeight); + myText->setLineHeight(20); + QCOMPARE(myText->height(), myText->lineCount() * 20.0); + + myText->setText("Lorem ipsum sit amet, consectetur adipiscing elit. Integer felis nisl, varius in pretium nec, venenatis non erat. Proin lobortis interdum dictum."); + myText->setLineHeightMode(QQuickText::ProportionalHeight); + myText->setLineHeight(1.0); + + qreal h2 = myText->height(); + myText->setLineHeight(2.0); + QVERIFY(myText->height() == h2 * 2.0); + + myText->setLineHeightMode(QQuickText::FixedHeight); + myText->setLineHeight(10); + QCOMPARE(myText->height(), myText->lineCount() * 10.0); + + delete canvas; +} + +void tst_qquicktext::implicitSize_data() +{ + QTest::addColumn("text"); + QTest::addColumn("width"); + QTest::addColumn("wrap"); + QTest::addColumn("elide"); + QTest::newRow("plain") << "The quick red fox jumped over the lazy brown dog" << "50" << "Text.NoWrap" << "Text.ElideNone"; + QTest::newRow("richtext") << "The quick red fox jumped over the lazy brown dog" <<" 50" << "Text.NoWrap" << "Text.ElideNone"; + QTest::newRow("plain, 0 width") << "The quick red fox jumped over the lazy brown dog" << "0" << "Text.NoWrap" << "Text.ElideNone"; + QTest::newRow("plain, elide") << "The quick red fox jumped over the lazy brown dog" << "50" << "Text.NoWrap" << "Text.ElideRight"; + QTest::newRow("plain, 0 width, elide") << "The quick red fox jumped over the lazy brown dog" << "0" << "Text.NoWrap" << "Text.ElideRight"; + QTest::newRow("richtext, 0 width") << "The quick red fox jumped over the lazy brown dog" <<" 0" << "Text.NoWrap" << "Text.ElideNone"; + QTest::newRow("plain_wrap") << "The quick red fox jumped over the lazy brown dog" << "50" << "Text.Wrap" << "Text.ElideNone"; + QTest::newRow("richtext_wrap") << "The quick red fox jumped over the lazy brown dog" << "50" << "Text.Wrap" << "Text.ElideNone"; + QTest::newRow("plain_wrap, 0 width") << "The quick red fox jumped over the lazy brown dog" << "0" << "Text.Wrap" << "Text.ElideNone"; + QTest::newRow("plain_wrap, elide") << "The quick red fox jumped over the lazy brown dog" << "50" << "Text.Wrap" << "Text.ElideRight"; + QTest::newRow("plain_wrap, 0 width, elide") << "The quick red fox jumped over the lazy brown dog" << "0" << "Text.Wrap" << "Text.ElideRight"; + QTest::newRow("richtext_wrap, 0 width") << "The quick red fox jumped over the lazy brown dog" << "0" << "Text.Wrap" << "Text.ElideNone"; +} + +void tst_qquicktext::implicitSize() +{ + QFETCH(QString, text); + QFETCH(QString, width); + QFETCH(QString, wrap); + QFETCH(QString, elide); + QString componentStr = "import QtQuick 2.0\nText { " + "text: \"" + text + "\"; " + "width: " + width + "; " + "wrapMode: " + wrap + "; " + "elide: " + elide + "; " + "maximumLineCount: 1 }"; + QQmlComponent textComponent(&engine); + textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); + QQuickText *textObject = qobject_cast(textComponent.create()); + + QVERIFY(textObject->width() < textObject->implicitWidth()); + QVERIFY(textObject->height() == textObject->implicitHeight()); + + textObject->resetWidth(); + QVERIFY(textObject->width() == textObject->implicitWidth()); + QVERIFY(textObject->height() == textObject->implicitHeight()); + + delete textObject; +} + +void tst_qquicktext::contentSize() +{ + QString componentStr = "import QtQuick 2.0\nText { width: 75; height: 16; font.pixelSize: 10 }"; + QQmlComponent textComponent(&engine); + textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); + QScopedPointer object(textComponent.create()); + QQuickText *textObject = qobject_cast(object.data()); + + QSignalSpy spy(textObject, SIGNAL(contentSizeChanged())); + + textObject->setText("The quick red fox jumped over the lazy brown dog"); + + QVERIFY(textObject->contentWidth() > textObject->width()); + QVERIFY(textObject->contentHeight() < textObject->height()); + QCOMPARE(spy.count(), 1); + + textObject->setWrapMode(QQuickText::WordWrap); + QVERIFY(textObject->contentWidth() <= textObject->width()); + QVERIFY(textObject->contentHeight() > textObject->height()); + QCOMPARE(spy.count(), 2); + + textObject->setElideMode(QQuickText::ElideRight); + QVERIFY(textObject->contentWidth() <= textObject->width()); + QVERIFY(textObject->contentHeight() < textObject->height()); + QCOMPARE(spy.count(), 3); + int spyCount = 3; + qreal elidedWidth = textObject->contentWidth(); + + textObject->setText("The quickredfoxjumpedoverthe lazy brown dog"); + QVERIFY(textObject->contentWidth() <= textObject->width()); + QVERIFY(textObject->contentHeight() < textObject->height()); + // this text probably won't have the same elided width, but it's not guaranteed. + if (textObject->contentWidth() != elidedWidth) + QCOMPARE(spy.count(), ++spyCount); + else + QCOMPARE(spy.count(), spyCount); + + textObject->setElideMode(QQuickText::ElideNone); + QVERIFY(textObject->contentWidth() > textObject->width()); + QVERIFY(textObject->contentHeight() > textObject->height()); + QCOMPARE(spy.count(), ++spyCount); +} + +void tst_qquicktext::lineLaidOut() +{ + QQuickView *canvas = createView(testFile("lineLayout.qml")); + + QQuickText *myText = canvas->rootObject()->findChild("myText"); + QVERIFY(myText != 0); + + QQuickTextPrivate *textPrivate = QQuickTextPrivate::get(myText); + QVERIFY(textPrivate != 0); + + QTextDocument *doc = textPrivate->textDocument(); + QVERIFY(doc == 0); + +#if defined(Q_OS_MAC) + QVERIFY(myText->lineCount() == textPrivate->linesRects.count()); +#endif + + for (int i = 0; i < textPrivate->layout.lineCount(); ++i) { + QRectF r = textPrivate->layout.lineAt(i).rect(); + QVERIFY(r.width() == i * 15); + if (i >= 30) + QVERIFY(r.x() == r.width() + 30); + if (i >= 60) { + QVERIFY(r.x() == r.width() * 2 + 60); + QVERIFY(r.height() == 20); + } + } + + delete canvas; +} + +void tst_qquicktext::imgTagsBaseUrl_data() +{ + QTest::addColumn("src"); + QTest::addColumn("baseUrl"); + QTest::addColumn("contextUrl"); + QTest::addColumn("imgHeight"); + + QTest::newRow("absolute local") + << testFileUrl("images/heart200.png") + << QUrl() + << QUrl() + << 181.; + QTest::newRow("relative local context 1") + << QUrl("images/heart200.png") + << QUrl() + << testFileUrl("/app.qml") + << 181.; + QTest::newRow("relative local context 2") + << QUrl("heart200.png") + << QUrl() + << testFileUrl("images/app.qml") + << 181.; + QTest::newRow("relative local base 1") + << QUrl("images/heart200.png") + << testFileUrl("") + << testFileUrl("nonexistant/app.qml") + << 181.; + QTest::newRow("relative local base 2") + << QUrl("heart200.png") + << testFileUrl("images/") + << testFileUrl("nonexistant/app.qml") + << 181.; + QTest::newRow("base relative to local context") + << QUrl("heart200.png") + << testFileUrl("images/") + << testFileUrl("/app.qml") + << 181.; + + QTest::newRow("absolute remote") + << QUrl("http://127.0.0.1:14453/images/heart200.png") + << QUrl() + << QUrl() + << 181.; + QTest::newRow("relative remote base 1") + << QUrl("images/heart200.png") + << QUrl("http://127.0.0.1:14453/") + << testFileUrl("nonexistant/app.qml") + << 181.; + QTest::newRow("relative remote base 2") + << QUrl("heart200.png") + << QUrl("http://127.0.0.1:14453/images/") + << testFileUrl("nonexistant/app.qml") + << 181.; +} + +void tst_qquicktext::imgTagsBaseUrl() +{ + QFETCH(QUrl, src); + QFETCH(QUrl, baseUrl); + QFETCH(QUrl, contextUrl); + QFETCH(qreal, imgHeight); + + TestHTTPServer server(14453); + server.serveDirectory(testFile("")); + + QByteArray baseUrlFragment; + if (!baseUrl.isEmpty()) + baseUrlFragment = "; baseUrl: \"" + baseUrl.toEncoded() + "\""; + QByteArray componentStr = "import QtQuick 2.0\nText { text: \"This is a test \"" + baseUrlFragment + " }"; + + QQmlComponent component(&engine); + component.setData(componentStr, contextUrl); + QScopedPointer object(component.create()); + QQuickText *textObject = qobject_cast(object.data()); + QVERIFY(textObject); + + QCoreApplication::processEvents(); + + QTRY_COMPARE(textObject->height(), imgHeight); +} + +void tst_qquicktext::imgTagsAlign_data() +{ + QTest::addColumn("src"); + QTest::addColumn("imgHeight"); + QTest::addColumn("align"); + QTest::newRow("heart-bottom") << "data/images/heart200.png" << 181 << "bottom"; + QTest::newRow("heart-middle") << "data/images/heart200.png" << 181 << "middle"; + QTest::newRow("heart-top") << "data/images/heart200.png" << 181 << "top"; + QTest::newRow("starfish-bottom") << "data/images/starfish_2.png" << 217 << "bottom"; + QTest::newRow("starfish-middle") << "data/images/starfish_2.png" << 217 << "middle"; + QTest::newRow("starfish-top") << "data/images/starfish_2.png" << 217 << "top"; +} + +void tst_qquicktext::imgTagsAlign() +{ + QFETCH(QString, src); + QFETCH(int, imgHeight); + QFETCH(QString, align); + QString componentStr = "import QtQuick 2.0\nText { text: \"This is a test of image.\" }"; + QQmlComponent textComponent(&engine); + textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); + QQuickText *textObject = qobject_cast(textComponent.create()); + + QVERIFY(textObject != 0); + QVERIFY(textObject->height() == imgHeight); + + QQuickTextPrivate *textPrivate = QQuickTextPrivate::get(textObject); + QVERIFY(textPrivate != 0); + + QRectF br = textPrivate->layout.boundingRect(); + if (align == "bottom") + QVERIFY(br.y() == imgHeight - br.height()); + else if (align == "middle") + QVERIFY(br.y() == imgHeight / 2.0 - br.height() / 2.0); + else if (align == "top") + QVERIFY(br.y() == 0); + + delete textObject; +} + +void tst_qquicktext::imgTagsMultipleImages() +{ + QString componentStr = "import QtQuick 2.0\nText { text: \"This is a starfish and another one.\" }"; + + QQmlComponent textComponent(&engine); + textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); + QQuickText *textObject = qobject_cast(textComponent.create()); + + QVERIFY(textObject != 0); + QVERIFY(textObject->height() == 85); + + QQuickTextPrivate *textPrivate = QQuickTextPrivate::get(textObject); + QVERIFY(textPrivate != 0); + QVERIFY(textPrivate->visibleImgTags.count() == 2); + + delete textObject; +} + +void tst_qquicktext::imgTagsElide() +{ + QQuickView *canvas = createView(testFile("imgTagsElide.qml")); + QQuickText *myText = canvas->rootObject()->findChild("myText"); + QVERIFY(myText != 0); + + QQuickTextPrivate *textPrivate = QQuickTextPrivate::get(myText); + QVERIFY(textPrivate != 0); + QVERIFY(textPrivate->visibleImgTags.count() == 0); + myText->setMaximumLineCount(20); + QTRY_VERIFY(textPrivate->visibleImgTags.count() == 1); + + delete myText; + delete canvas; +} + +void tst_qquicktext::imgTagsUpdates() +{ + QQuickView *canvas = createView(testFile("imgTagsUpdates.qml")); + QQuickText *myText = canvas->rootObject()->findChild("myText"); + QVERIFY(myText != 0); + + QSignalSpy spy(myText, SIGNAL(contentSizeChanged())); + + QQuickTextPrivate *textPrivate = QQuickTextPrivate::get(myText); + QVERIFY(textPrivate != 0); + + myText->setText("This is a heart."); + QVERIFY(textPrivate->visibleImgTags.count() == 1); + QVERIFY(spy.count() == 1); + + myText->setMaximumLineCount(2); + myText->setText("This is another heart."); + QTRY_VERIFY(textPrivate->visibleImgTags.count() == 1); + + // if maximumLineCount is set and the img tag doesn't have an explicit size + // we relayout twice. + QVERIFY(spy.count() == 3); + + delete myText; + delete canvas; +} + +void tst_qquicktext::imgTagsError() +{ + QString componentStr = "import QtQuick 2.0\nText { text: \"This is a starfish.\" }"; + + QQmlComponent textComponent(&engine); + QTest::ignoreMessage(QtWarningMsg, "file::2:1: QML Text: Cannot open: file:data/images/starfish_2.pn"); + textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); + QQuickText *textObject = qobject_cast(textComponent.create()); + + QVERIFY(textObject != 0); + delete textObject; +} + +void tst_qquicktext::fontSizeMode_data() +{ + QTest::addColumn("text"); + QTest::addColumn("canElide"); + QTest::newRow("plain") << "The quick red fox jumped over the lazy brown dog" << true; + QTest::newRow("richtext") << "The quick red fox jumped over the lazy brown dog" << false; +} + +void tst_qquicktext::fontSizeMode() +{ + QFETCH(QString, text); + QFETCH(bool, canElide); + + QQuickView *canvas = createView(testFile("fontSizeMode.qml")); + canvas->show(); + + QQuickText *myText = canvas->rootObject()->findChild("myText"); + QVERIFY(myText != 0); + + myText->setText(text); + QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); + + qreal originalWidth = myText->contentWidth(); + qreal originalHeight = myText->contentHeight(); + + // The original text unwrapped should exceed the width of the item. + QVERIFY(originalWidth > myText->width()); + QVERIFY(originalHeight < myText->height()); + + QFont font = myText->font(); + font.setPixelSize(64); + + myText->setFont(font); + myText->setFontSizeMode(QQuickText::HorizontalFit); + QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); + // Font size reduced to fit within the width of the item. + qreal horizontalFitWidth = myText->contentWidth(); + qreal horizontalFitHeight = myText->contentHeight(); + QVERIFY(horizontalFitWidth <= myText->width() + 2); // rounding + QVERIFY(horizontalFitHeight <= myText->height() + 2); + + if (canElide) { + // Elide won't affect the size with HorizontalFit. + myText->setElideMode(QQuickText::ElideRight); + QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); + QVERIFY(!myText->truncated()); + QCOMPARE(myText->contentWidth(), horizontalFitWidth); + QCOMPARE(myText->contentHeight(), horizontalFitHeight); + + myText->setElideMode(QQuickText::ElideLeft); + QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); + QVERIFY(!myText->truncated()); + QCOMPARE(myText->contentWidth(), horizontalFitWidth); + QCOMPARE(myText->contentHeight(), horizontalFitHeight); + + myText->setElideMode(QQuickText::ElideMiddle); + QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); + QVERIFY(!myText->truncated()); + QCOMPARE(myText->contentWidth(), horizontalFitWidth); + QCOMPARE(myText->contentHeight(), horizontalFitHeight); + + myText->setElideMode(QQuickText::ElideNone); + QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); + } + + myText->setFontSizeMode(QQuickText::VerticalFit); + QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); + // Font size increased to fill the height of the item. + qreal verticalFitHeight = myText->contentHeight(); + QVERIFY(myText->contentWidth() > myText->width()); + QVERIFY(verticalFitHeight <= myText->height() + 2); + QVERIFY(verticalFitHeight > originalHeight); + + if (canElide) { + // Elide won't affect the height of a single line with VerticalFit but will crop the width. + myText->setElideMode(QQuickText::ElideRight); + QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); + QVERIFY(myText->truncated()); + QVERIFY(myText->contentWidth() <= myText->width() + 2); + QCOMPARE(myText->contentHeight(), verticalFitHeight); + + myText->setElideMode(QQuickText::ElideLeft); + QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); + QVERIFY(myText->truncated()); + QVERIFY(myText->contentWidth() <= myText->width() + 2); + QCOMPARE(myText->contentHeight(), verticalFitHeight); + + myText->setElideMode(QQuickText::ElideMiddle); + QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); + QVERIFY(myText->truncated()); + QVERIFY(myText->contentWidth() <= myText->width() + 2); + QCOMPARE(myText->contentHeight(), verticalFitHeight); + + myText->setElideMode(QQuickText::ElideNone); + QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); + } + + myText->setFontSizeMode(QQuickText::Fit); + QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); + // Should be the same as HorizontalFit with no wrapping. + QCOMPARE(myText->contentWidth(), horizontalFitWidth); + QCOMPARE(myText->contentHeight(), horizontalFitHeight); + + if (canElide) { + // Elide won't affect the size with Fit. + myText->setElideMode(QQuickText::ElideRight); + QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); + QVERIFY(!myText->truncated()); + QCOMPARE(myText->contentWidth(), horizontalFitWidth); + QCOMPARE(myText->contentHeight(), horizontalFitHeight); + + myText->setElideMode(QQuickText::ElideLeft); + QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); + QVERIFY(!myText->truncated()); + QCOMPARE(myText->contentWidth(), horizontalFitWidth); + QCOMPARE(myText->contentHeight(), horizontalFitHeight); + + myText->setElideMode(QQuickText::ElideMiddle); + QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); + QVERIFY(!myText->truncated()); + QCOMPARE(myText->contentWidth(), horizontalFitWidth); + QCOMPARE(myText->contentHeight(), horizontalFitHeight); + + myText->setElideMode(QQuickText::ElideNone); + QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); + } + + myText->setFontSizeMode(QQuickText::FixedSize); + myText->setWrapMode(QQuickText::Wrap); + QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); + + originalWidth = myText->contentWidth(); + originalHeight = myText->contentHeight(); + + // The original text wrapped should exceed the height of the item. + QVERIFY(originalWidth <= myText->width() + 2); + QVERIFY(originalHeight > myText->height()); + + myText->setFontSizeMode(QQuickText::HorizontalFit); + QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); + // HorizontalFit should reduce the font size to minimize wrapping, which brings it back to the + // same size as without text wrapping. + QCOMPARE(myText->contentWidth(), horizontalFitWidth); + QCOMPARE(myText->contentHeight(), horizontalFitHeight); + + if (canElide) { + // Elide won't affect the size with HorizontalFit. + myText->setElideMode(QQuickText::ElideRight); + QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); + QVERIFY(!myText->truncated()); + QCOMPARE(myText->contentWidth(), horizontalFitWidth); + QCOMPARE(myText->contentHeight(), horizontalFitHeight); + + myText->setElideMode(QQuickText::ElideNone); + QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); + } + + myText->setFontSizeMode(QQuickText::VerticalFit); + QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); + // VerticalFit should reduce the size to the wrapped text within the vertical height. + verticalFitHeight = myText->contentHeight(); + qreal verticalFitWidth = myText->contentWidth(); + QVERIFY(myText->contentWidth() <= myText->width() + 2); + QVERIFY(verticalFitHeight <= myText->height() + 2); + QVERIFY(verticalFitHeight < originalHeight); + + if (canElide) { + // Elide won't affect the height or width of a wrapped text with VerticalFit. + myText->setElideMode(QQuickText::ElideRight); + QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); + QVERIFY(!myText->truncated()); + QCOMPARE(myText->contentWidth(), verticalFitWidth); + QCOMPARE(myText->contentHeight(), verticalFitHeight); + + myText->setElideMode(QQuickText::ElideNone); + QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); + } + + myText->setFontSizeMode(QQuickText::Fit); + QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); + // Should be the same as VerticalFit with wrapping. + QCOMPARE(myText->contentWidth(), verticalFitWidth); + QCOMPARE(myText->contentHeight(), verticalFitHeight); + + if (canElide) { + // Elide won't affect the size with Fit. + myText->setElideMode(QQuickText::ElideRight); + QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); + QVERIFY(!myText->truncated()); + QCOMPARE(myText->contentWidth(), verticalFitWidth); + QCOMPARE(myText->contentHeight(), verticalFitHeight); + + myText->setElideMode(QQuickText::ElideNone); + QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); + } + + myText->setFontSizeMode(QQuickText::FixedSize); + myText->setMaximumLineCount(2); + QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); + + // The original text wrapped should exceed the height of the item. + QVERIFY(originalWidth <= myText->width() + 2); + QVERIFY(originalHeight > myText->height()); + + myText->setFontSizeMode(QQuickText::HorizontalFit); + QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); + // HorizontalFit should reduce the font size to minimize wrapping, which brings it back to the + // same size as without text wrapping. + QCOMPARE(myText->contentWidth(), horizontalFitWidth); + QCOMPARE(myText->contentHeight(), horizontalFitHeight); + + if (canElide) { + // Elide won't affect the size with HorizontalFit. + myText->setElideMode(QQuickText::ElideRight); + QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); + QVERIFY(!myText->truncated()); + QCOMPARE(myText->contentWidth(), horizontalFitWidth); + QCOMPARE(myText->contentHeight(), horizontalFitHeight); + + myText->setElideMode(QQuickText::ElideNone); + QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); + } + + myText->setFontSizeMode(QQuickText::VerticalFit); + QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); + // VerticalFit should reduce the size to the wrapped text within the vertical height. + verticalFitHeight = myText->contentHeight(); + verticalFitWidth = myText->contentWidth(); + QVERIFY(myText->contentWidth() <= myText->width() + 2); + QVERIFY(verticalFitHeight <= myText->height() + 2); + QVERIFY(verticalFitHeight < originalHeight); + + if (canElide) { + // Elide won't affect the height or width of a wrapped text with VerticalFit. + myText->setElideMode(QQuickText::ElideRight); + QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); + QVERIFY(!myText->truncated()); + QCOMPARE(myText->contentWidth(), verticalFitWidth); + QCOMPARE(myText->contentHeight(), verticalFitHeight); + + myText->setElideMode(QQuickText::ElideNone); + QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); + } + + myText->setFontSizeMode(QQuickText::Fit); + QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); + // Should be the same as VerticalFit with wrapping. + QCOMPARE(myText->contentWidth(), verticalFitWidth); + QCOMPARE(myText->contentHeight(), verticalFitHeight); + + if (canElide) { + // Elide won't affect the size with Fit. + myText->setElideMode(QQuickText::ElideRight); + QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); + QVERIFY(!myText->truncated()); + QCOMPARE(myText->contentWidth(), verticalFitWidth); + QCOMPARE(myText->contentHeight(), verticalFitHeight); + + myText->setElideMode(QQuickText::ElideNone); + QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); + } +} + +void tst_qquicktext::fontSizeModeMultiline_data() +{ + QTest::addColumn("text"); + QTest::addColumn("canElide"); + QTest::newRow("plain") << "The quick red fox jumped\n over the lazy brown dog" << true; + QTest::newRow("richtext") << "The quick red fox jumped
          over the lazy brown dog
          " << false; +} + +void tst_qquicktext::fontSizeModeMultiline() +{ + QFETCH(QString, text); + QFETCH(bool, canElide); + + QQuickView *canvas = createView(testFile("fontSizeMode.qml")); + canvas->show(); + + QQuickText *myText = canvas->rootObject()->findChild("myText"); + QVERIFY(myText != 0); + + myText->setText(text); + QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); + + qreal originalWidth = myText->contentWidth(); + qreal originalHeight = myText->contentHeight(); + QCOMPARE(myText->lineCount(), 2); + + // The original text unwrapped should exceed the width and height of the item. + QVERIFY(originalWidth > myText->width()); + QVERIFY(originalHeight > myText->height()); + + QFont font = myText->font(); + font.setPixelSize(64); + + myText->setFont(font); + myText->setFontSizeMode(QQuickText::HorizontalFit); + QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); + // Font size reduced to fit within the width of the item. + QCOMPARE(myText->lineCount(), 2); + qreal horizontalFitWidth = myText->contentWidth(); + qreal horizontalFitHeight = myText->contentHeight(); + QVERIFY(horizontalFitWidth <= myText->width() + 2); // rounding + QVERIFY(horizontalFitHeight > myText->height()); + + if (canElide) { + // Right eliding will remove the last line + myText->setElideMode(QQuickText::ElideRight); + QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); + QVERIFY(myText->truncated()); + QCOMPARE(myText->lineCount(), 1); + QVERIFY(myText->contentWidth() <= myText->width() + 2); + QVERIFY(myText->contentHeight() <= myText->height() + 2); + + // Left or middle eliding wont have any effect. + myText->setElideMode(QQuickText::ElideLeft); + QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); + QVERIFY(!myText->truncated()); + QCOMPARE(myText->contentWidth(), horizontalFitWidth); + QCOMPARE(myText->contentHeight(), horizontalFitHeight); + + myText->setElideMode(QQuickText::ElideMiddle); + QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); + QVERIFY(!myText->truncated()); + QCOMPARE(myText->contentWidth(), horizontalFitWidth); + QCOMPARE(myText->contentHeight(), horizontalFitHeight); + + myText->setElideMode(QQuickText::ElideNone); + QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); + } + + myText->setFontSizeMode(QQuickText::VerticalFit); + QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); + // Font size reduced to fit within the height of the item. + qreal verticalFitWidth = myText->contentWidth(); + qreal verticalFitHeight = myText->contentHeight(); + QVERIFY(verticalFitWidth <= myText->width() + 2); + QVERIFY(verticalFitHeight <= myText->height() + 2); + + if (canElide) { + // Elide will have no effect. + myText->setElideMode(QQuickText::ElideRight); + QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); + QVERIFY(!myText->truncated()); + QVERIFY(myText->contentWidth() <= myText->width() + 2); + QCOMPARE(myText->contentWidth(), verticalFitWidth); + QCOMPARE(myText->contentHeight(), verticalFitHeight); + + myText->setElideMode(QQuickText::ElideLeft); + QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); + QVERIFY(!myText->truncated()); + QCOMPARE(myText->contentWidth(), verticalFitWidth); + QCOMPARE(myText->contentHeight(), verticalFitHeight); + + myText->setElideMode(QQuickText::ElideMiddle); + QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); + QVERIFY(!myText->truncated()); + QCOMPARE(myText->contentWidth(), verticalFitWidth); + QCOMPARE(myText->contentHeight(), verticalFitHeight); + + myText->setElideMode(QQuickText::ElideNone); + QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); + } + + myText->setFontSizeMode(QQuickText::Fit); + QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); + // Should be the same as VerticalFit with no wrapping. + QCOMPARE(myText->contentWidth(), verticalFitWidth); + QCOMPARE(myText->contentHeight(), verticalFitHeight); + + if (canElide) { + // Elide won't affect the size with Fit. + myText->setElideMode(QQuickText::ElideRight); + QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); + QVERIFY(!myText->truncated()); + QCOMPARE(myText->contentWidth(), verticalFitWidth); + QCOMPARE(myText->contentHeight(), verticalFitHeight); + + myText->setElideMode(QQuickText::ElideLeft); + QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); + QVERIFY(!myText->truncated()); + QCOMPARE(myText->contentWidth(), verticalFitWidth); + QCOMPARE(myText->contentHeight(), verticalFitHeight); + + myText->setElideMode(QQuickText::ElideMiddle); + QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); + QVERIFY(!myText->truncated()); + QCOMPARE(myText->contentWidth(), verticalFitWidth); + QCOMPARE(myText->contentHeight(), verticalFitHeight); + + myText->setElideMode(QQuickText::ElideNone); + QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); + } + + myText->setFontSizeMode(QQuickText::FixedSize); + myText->setWrapMode(QQuickText::Wrap); + QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); + + originalWidth = myText->contentWidth(); + originalHeight = myText->contentHeight(); + + // The original text wrapped should exceed the height of the item. + QVERIFY(originalWidth <= myText->width() + 2); + QVERIFY(originalHeight > myText->height()); + + myText->setFontSizeMode(QQuickText::HorizontalFit); + QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); + // HorizontalFit should reduce the font size to minimize wrapping, which brings it back to the + // same size as without text wrapping. + QCOMPARE(myText->contentWidth(), horizontalFitWidth); + QCOMPARE(myText->contentHeight(), horizontalFitHeight); + + if (canElide) { + // Text will be elided vertically with HorizontalFit + myText->setElideMode(QQuickText::ElideRight); + QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); + QVERIFY(myText->truncated()); + QVERIFY(myText->contentWidth() <= myText->width() + 2); + QVERIFY(myText->contentHeight() <= myText->height() + 2); + + myText->setElideMode(QQuickText::ElideNone); + QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); + } + + myText->setFontSizeMode(QQuickText::VerticalFit); + QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); + // VerticalFit should reduce the size to the wrapped text within the vertical height. + verticalFitHeight = myText->contentHeight(); + verticalFitWidth = myText->contentWidth(); + QVERIFY(myText->contentWidth() <= myText->width() + 2); + QVERIFY(verticalFitHeight <= myText->height() + 2); + QVERIFY(verticalFitHeight < originalHeight); + + if (canElide) { + // Elide won't affect the height or width of a wrapped text with VerticalFit. + myText->setElideMode(QQuickText::ElideRight); + QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); + QVERIFY(!myText->truncated()); + QCOMPARE(myText->contentWidth(), verticalFitWidth); + QCOMPARE(myText->contentHeight(), verticalFitHeight); + + myText->setElideMode(QQuickText::ElideNone); + QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); + } + + myText->setFontSizeMode(QQuickText::Fit); + QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); + // Should be the same as VerticalFit with wrapping. + QCOMPARE(myText->contentWidth(), verticalFitWidth); + QCOMPARE(myText->contentHeight(), verticalFitHeight); + + if (canElide) { + // Elide won't affect the size with Fit. + myText->setElideMode(QQuickText::ElideRight); + QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); + QVERIFY(!myText->truncated()); + QCOMPARE(myText->contentWidth(), verticalFitWidth); + QCOMPARE(myText->contentHeight(), verticalFitHeight); + + myText->setElideMode(QQuickText::ElideNone); + QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); + } + + myText->setFontSizeMode(QQuickText::FixedSize); + myText->setMaximumLineCount(2); + QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); + + // The original text wrapped should exceed the height of the item. + QVERIFY(originalWidth <= myText->width() + 2); + QVERIFY(originalHeight > myText->height()); + + myText->setFontSizeMode(QQuickText::HorizontalFit); + QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); + // HorizontalFit should reduce the font size to minimize wrapping, which brings it back to the + // same size as without text wrapping. + QCOMPARE(myText->contentWidth(), horizontalFitWidth); + QCOMPARE(myText->contentHeight(), horizontalFitHeight); + + if (canElide) { + // Elide won't affect the size with HorizontalFit. + myText->setElideMode(QQuickText::ElideRight); + QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); + QVERIFY(myText->truncated()); + QVERIFY(myText->contentWidth() <= myText->width() + 2); + QVERIFY(myText->contentHeight() <= myText->height() + 2); + + myText->setElideMode(QQuickText::ElideNone); + QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); + } + + myText->setFontSizeMode(QQuickText::VerticalFit); + QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); + // VerticalFit should reduce the size to the wrapped text within the vertical height. + verticalFitHeight = myText->contentHeight(); + verticalFitWidth = myText->contentWidth(); + QVERIFY(myText->contentWidth() <= myText->width() + 2); + QVERIFY(verticalFitHeight <= myText->height() + 2); + QVERIFY(verticalFitHeight < originalHeight); + + if (canElide) { + // Elide won't affect the height or width of a wrapped text with VerticalFit. + myText->setElideMode(QQuickText::ElideRight); + QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); + QVERIFY(!myText->truncated()); + QCOMPARE(myText->contentWidth(), verticalFitWidth); + QCOMPARE(myText->contentHeight(), verticalFitHeight); + + myText->setElideMode(QQuickText::ElideNone); + QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); + } + + myText->setFontSizeMode(QQuickText::Fit); + QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); + // Should be the same as VerticalFit with wrapping. + QCOMPARE(myText->contentWidth(), verticalFitWidth); + QCOMPARE(myText->contentHeight(), verticalFitHeight); + + if (canElide) { + // Elide won't affect the size with Fit. + myText->setElideMode(QQuickText::ElideRight); + QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); + QVERIFY(!myText->truncated()); + QCOMPARE(myText->contentWidth(), verticalFitWidth); + QCOMPARE(myText->contentHeight(), verticalFitHeight); + + myText->setElideMode(QQuickText::ElideNone); + QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); + } +} + +void tst_qquicktext::multilengthStrings_data() +{ + QTest::addColumn("source"); + QTest::newRow("No Wrap") << testFile("multilengthStrings.qml"); + QTest::newRow("Wrap") << testFile("multilengthStringsWrapped.qml"); +} + +void tst_qquicktext::multilengthStrings() +{ + QFETCH(QString, source); + + QScopedPointer canvas(createView(source)); + canvas->show(); + + QQuickText *myText = canvas->rootObject()->findChild("myText"); + QVERIFY(myText != 0); + + const QString longText = "the quick brown fox jumped over the lazy dog"; + const QString mediumText = "the brown fox jumped over the dog"; + const QString shortText = "fox jumped dog"; + + myText->setText(longText); + QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); + const qreal longWidth = myText->contentWidth(); + const qreal longHeight = myText->contentHeight(); + + myText->setText(mediumText); + QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); + const qreal mediumWidth = myText->contentWidth(); + const qreal mediumHeight = myText->contentHeight(); + + myText->setText(shortText); + QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); + const qreal shortWidth = myText->contentWidth(); + const qreal shortHeight = myText->contentHeight(); + + myText->setElideMode(QQuickText::ElideRight); + myText->setText(longText + QLatin1Char('\x9c') + mediumText + QLatin1Char('\x9c') + shortText); + + myText->setSize(QSizeF(longWidth, longHeight)); + QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); + + QCOMPARE(myText->contentWidth(), longWidth); + QCOMPARE(myText->contentHeight(), longHeight); + QCOMPARE(myText->truncated(), false); + + myText->setSize(QSizeF(mediumWidth, mediumHeight)); + QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); + + QCOMPARE(myText->contentWidth(), mediumWidth); + QCOMPARE(myText->contentHeight(), mediumHeight); +#ifdef Q_OS_MAC + QEXPECT_FAIL("Wrap", "QTBUG-24310", Continue); +#endif + QCOMPARE(myText->truncated(), true); + + myText->setSize(QSizeF(shortWidth, shortHeight)); + QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); + + QCOMPARE(myText->contentWidth(), shortWidth); + QCOMPARE(myText->contentHeight(), shortHeight); + QCOMPARE(myText->truncated(), true); +} + +QTEST_MAIN(tst_qquicktext) + +#include "tst_qquicktext.moc" diff --git a/tests/auto/quick/qquicktextedit/data/Cursor.qml b/tests/auto/quick/qquicktextedit/data/Cursor.qml new file mode 100644 index 0000000000..e5c1853fc5 --- /dev/null +++ b/tests/auto/quick/qquicktextedit/data/Cursor.qml @@ -0,0 +1,5 @@ +import QtQuick 2.0 + +Rectangle { + property string localProperty +} diff --git a/tests/auto/quick/qquicktextedit/data/CursorRect.qml b/tests/auto/quick/qquicktextedit/data/CursorRect.qml new file mode 100644 index 0000000000..cae3e63b72 --- /dev/null +++ b/tests/auto/quick/qquicktextedit/data/CursorRect.qml @@ -0,0 +1,8 @@ +import QtQuick 2.0 + +TextEdit { + focus: true + objectName: "myEdit" + width: 50 + text: "This is a long piece of text" +} diff --git a/tests/auto/quick/qquicktextedit/data/alignments.qml b/tests/auto/quick/qquicktextedit/data/alignments.qml new file mode 100644 index 0000000000..7d365da8cb --- /dev/null +++ b/tests/auto/quick/qquicktextedit/data/alignments.qml @@ -0,0 +1,41 @@ +import QtQuick 2.0 + +Rectangle { + id: top + width: 70; height: 70; + + property alias horizontalAlignment: t.horizontalAlignment + property alias verticalAlignment: t.verticalAlignment + property alias wrapMode: t.wrapMode + property alias running: timer.running + property string txt: "Test" + + Rectangle { + anchors.centerIn: parent + width: 40 + height: 40 + color: "green" + + TextEdit { + id: t + + anchors.fill: parent + horizontalAlignment: TextEdit.AlignRight + verticalAlignment: TextEdit.AlignBottom + wrapMode: TextEdit.WordWrap + text: top.txt + } + Timer { + id: timer + + interval: 1 + running: true + repeat: true + onTriggered: { + top.txt = top.txt + "
          more " + top.txt.length; + if (top.txt.length > 50) + running = false + } + } + } +} diff --git a/tests/auto/quick/qquicktextedit/data/alignments_cb.png b/tests/auto/quick/qquicktextedit/data/alignments_cb.png new file mode 100644 index 0000000000..99de2192de Binary files /dev/null and b/tests/auto/quick/qquicktextedit/data/alignments_cb.png differ diff --git a/tests/auto/quick/qquicktextedit/data/alignments_cc.png b/tests/auto/quick/qquicktextedit/data/alignments_cc.png new file mode 100644 index 0000000000..cb85251180 Binary files /dev/null and b/tests/auto/quick/qquicktextedit/data/alignments_cc.png differ diff --git a/tests/auto/quick/qquicktextedit/data/alignments_ct.png b/tests/auto/quick/qquicktextedit/data/alignments_ct.png new file mode 100644 index 0000000000..ddca549c82 Binary files /dev/null and b/tests/auto/quick/qquicktextedit/data/alignments_ct.png differ diff --git a/tests/auto/quick/qquicktextedit/data/alignments_lb.png b/tests/auto/quick/qquicktextedit/data/alignments_lb.png new file mode 100644 index 0000000000..1b50a81f3d Binary files /dev/null and b/tests/auto/quick/qquicktextedit/data/alignments_lb.png differ diff --git a/tests/auto/quick/qquicktextedit/data/alignments_lc.png b/tests/auto/quick/qquicktextedit/data/alignments_lc.png new file mode 100644 index 0000000000..f041b868f8 Binary files /dev/null and b/tests/auto/quick/qquicktextedit/data/alignments_lc.png differ diff --git a/tests/auto/quick/qquicktextedit/data/alignments_lt.png b/tests/auto/quick/qquicktextedit/data/alignments_lt.png new file mode 100644 index 0000000000..c75e0d158e Binary files /dev/null and b/tests/auto/quick/qquicktextedit/data/alignments_lt.png differ diff --git a/tests/auto/quick/qquicktextedit/data/alignments_rb.png b/tests/auto/quick/qquicktextedit/data/alignments_rb.png new file mode 100644 index 0000000000..b06a5da715 Binary files /dev/null and b/tests/auto/quick/qquicktextedit/data/alignments_rb.png differ diff --git a/tests/auto/quick/qquicktextedit/data/alignments_rc.png b/tests/auto/quick/qquicktextedit/data/alignments_rc.png new file mode 100644 index 0000000000..e468857cd0 Binary files /dev/null and b/tests/auto/quick/qquicktextedit/data/alignments_rc.png differ diff --git a/tests/auto/quick/qquicktextedit/data/alignments_rt.png b/tests/auto/quick/qquicktextedit/data/alignments_rt.png new file mode 100644 index 0000000000..576715ffce Binary files /dev/null and b/tests/auto/quick/qquicktextedit/data/alignments_rt.png differ diff --git a/tests/auto/quick/qquicktextedit/data/cursorTest.qml b/tests/auto/quick/qquicktextedit/data/cursorTest.qml new file mode 100644 index 0000000000..7bfc869403 --- /dev/null +++ b/tests/auto/quick/qquicktextedit/data/cursorTest.qml @@ -0,0 +1,9 @@ +import QtQuick 2.0 + +Rectangle { width: 300; height: 300; color: "white" + property string contextualProperty: "Hello" + TextEdit { text: "Hello world!"; id: textEditObject; objectName: "textEditObject" + resources: [ Component { id:cursor; Item { id:cursorInstance; objectName: "cursorInstance"; property string localProperty: contextualProperty } } ] + cursorDelegate: cursor + } +} diff --git a/tests/auto/quick/qquicktextedit/data/cursorTestExternal.qml b/tests/auto/quick/qquicktextedit/data/cursorTestExternal.qml new file mode 100644 index 0000000000..7e916ec818 --- /dev/null +++ b/tests/auto/quick/qquicktextedit/data/cursorTestExternal.qml @@ -0,0 +1,15 @@ +import QtQuick 2.0 + +Rectangle { width: 300; height: 300; color: "white" + property string contextualProperty: "Hello" + TextEdit { + text: "Hello world!" + id: textEditObject; + objectName: "textEditObject" + cursorDelegate: Cursor { + id:cursorInstance; + objectName: "cursorInstance"; + localProperty: contextualProperty; + } + } +} diff --git a/tests/auto/quick/qquicktextedit/data/cursorTestInline.qml b/tests/auto/quick/qquicktextedit/data/cursorTestInline.qml new file mode 100644 index 0000000000..786f39113c --- /dev/null +++ b/tests/auto/quick/qquicktextedit/data/cursorTestInline.qml @@ -0,0 +1,15 @@ +import QtQuick 2.0 + +Rectangle { width: 300; height: 300; color: "white" + property string contextualProperty: "Hello" + TextEdit { + text: "Hello world!" + id: textEditObject + objectName: "textEditObject" + cursorDelegate: Item { + id:cursorInstance + objectName: "cursorInstance" + property string localProperty: contextualProperty + } + } +} diff --git a/tests/auto/quick/qquicktextedit/data/cursorVisible.qml b/tests/auto/quick/qquicktextedit/data/cursorVisible.qml new file mode 100644 index 0000000000..49e9386947 --- /dev/null +++ b/tests/auto/quick/qquicktextedit/data/cursorVisible.qml @@ -0,0 +1,6 @@ +import QtQuick 2.0 + +Item { + width: 100 + height: 20 +} diff --git a/tests/auto/quick/qquicktextedit/data/embeddedImagesLocal.qml b/tests/auto/quick/qquicktextedit/data/embeddedImagesLocal.qml new file mode 100644 index 0000000000..150f7bd898 --- /dev/null +++ b/tests/auto/quick/qquicktextedit/data/embeddedImagesLocal.qml @@ -0,0 +1,6 @@ +import QtQuick 2.0 + +TextEdit { + textFormat: TextEdit.RichText + text: "" +} diff --git a/tests/auto/quick/qquicktextedit/data/embeddedImagesLocalError.qml b/tests/auto/quick/qquicktextedit/data/embeddedImagesLocalError.qml new file mode 100644 index 0000000000..067b6d72da --- /dev/null +++ b/tests/auto/quick/qquicktextedit/data/embeddedImagesLocalError.qml @@ -0,0 +1,6 @@ +import QtQuick 2.0 + +TextEdit { + textFormat: TextEdit.RichText + text: "" +} diff --git a/tests/auto/quick/qquicktextedit/data/embeddedImagesLocalRelative.qml b/tests/auto/quick/qquicktextedit/data/embeddedImagesLocalRelative.qml new file mode 100644 index 0000000000..200ded196d --- /dev/null +++ b/tests/auto/quick/qquicktextedit/data/embeddedImagesLocalRelative.qml @@ -0,0 +1,7 @@ +import QtQuick 2.0 + +TextEdit { + textFormat: TextEdit.RichText + text: "" + baseUrl: "http/" +} diff --git a/tests/auto/quick/qquicktextedit/data/embeddedImagesRemote.qml b/tests/auto/quick/qquicktextedit/data/embeddedImagesRemote.qml new file mode 100644 index 0000000000..a823882692 --- /dev/null +++ b/tests/auto/quick/qquicktextedit/data/embeddedImagesRemote.qml @@ -0,0 +1,6 @@ +import QtQuick 2.0 + +TextEdit { + textFormat: TextEdit.RichText + text: "" +} diff --git a/tests/auto/quick/qquicktextedit/data/embeddedImagesRemoteError.qml b/tests/auto/quick/qquicktextedit/data/embeddedImagesRemoteError.qml new file mode 100644 index 0000000000..c6172b68dc --- /dev/null +++ b/tests/auto/quick/qquicktextedit/data/embeddedImagesRemoteError.qml @@ -0,0 +1,6 @@ +import QtQuick 2.0 + +TextEdit { + textFormat: TextEdit.RichText + text: "" +} diff --git a/tests/auto/quick/qquicktextedit/data/embeddedImagesRemoteRelative.qml b/tests/auto/quick/qquicktextedit/data/embeddedImagesRemoteRelative.qml new file mode 100644 index 0000000000..ee39e089ea --- /dev/null +++ b/tests/auto/quick/qquicktextedit/data/embeddedImagesRemoteRelative.qml @@ -0,0 +1,7 @@ +import QtQuick 2.0 + +TextEdit { + textFormat: TextEdit.RichText + text: "" + baseUrl: "http://127.0.0.1:42332/text.html" +} diff --git a/tests/auto/quick/qquicktextedit/data/geometrySignals.qml b/tests/auto/quick/qquicktextedit/data/geometrySignals.qml new file mode 100644 index 0000000000..3dbe61c74b --- /dev/null +++ b/tests/auto/quick/qquicktextedit/data/geometrySignals.qml @@ -0,0 +1,12 @@ +import QtQuick 2.0 + +Item { + width: 400; height: 500; + property int bindingWidth: text.width + property int bindingHeight: text.height + + TextInput { + id: text + anchors.fill: parent + } +} diff --git a/tests/auto/quick/qquicktextedit/data/horizontalAlignment_RightToLeft.qml b/tests/auto/quick/qquicktextedit/data/horizontalAlignment_RightToLeft.qml new file mode 100644 index 0000000000..2163838488 --- /dev/null +++ b/tests/auto/quick/qquicktextedit/data/horizontalAlignment_RightToLeft.qml @@ -0,0 +1,25 @@ +import QtQuick 2.0 + +Rectangle { + id: top + width: 200; height: 70; + + property alias horizontalAlignment: text.horizontalAlignment + property string text: "اختبا" + + Rectangle { + anchors.centerIn: parent + width: 200 + height: 20 + color: "green" + + TextEdit { + id: text + objectName: "text" + anchors.fill: parent + text: top.text + focus: true + textFormat: TextEdit.AutoText + } + } +} diff --git a/tests/auto/quick/qquicktextedit/data/http/ErrItem.qml b/tests/auto/quick/qquicktextedit/data/http/ErrItem.qml new file mode 100644 index 0000000000..68c0e0c093 --- /dev/null +++ b/tests/auto/quick/qquicktextedit/data/http/ErrItem.qml @@ -0,0 +1,7 @@ +import QtQuick 2.0 + +Item{ + Fungus{ + palatable: false; + } +} diff --git a/tests/auto/quick/qquicktextedit/data/http/NormItem.qml b/tests/auto/quick/qquicktextedit/data/http/NormItem.qml new file mode 100644 index 0000000000..2e4c1ed440 --- /dev/null +++ b/tests/auto/quick/qquicktextedit/data/http/NormItem.qml @@ -0,0 +1,6 @@ +import QtQuick 2.0 + +Item { + objectName: "delegateOkay" + Rectangle { } +} diff --git a/tests/auto/quick/qquicktextedit/data/http/cursorHttpTest.qml b/tests/auto/quick/qquicktextedit/data/http/cursorHttpTest.qml new file mode 100644 index 0000000000..be4526e22b --- /dev/null +++ b/tests/auto/quick/qquicktextedit/data/http/cursorHttpTest.qml @@ -0,0 +1,22 @@ +import QtQuick 2.0 + +Rectangle { width: 300; height: 300; color: "white" + resources: [ + Component { id:cursorFail; FailItem { objectName: "delegateFail" } }, + Component { id:cursorWait; WaitItem { objectName: "delegateSlow" } }, + Component { id:cursorNorm; NormItem { objectName: "delegateOkay" } }, + Component { id:cursorErr; ErrItem { objectName: "delegateErrorA" } } + ] + TextEdit { + cursorDelegate: cursorFail + } + TextEdit { + cursorDelegate: cursorWait + } + TextEdit { + cursorDelegate: cursorNorm + } + TextEdit { + cursorDelegate: cursorErr + } +} diff --git a/tests/auto/quick/qquicktextedit/data/http/cursorHttpTestFail1.qml b/tests/auto/quick/qquicktextedit/data/http/cursorHttpTestFail1.qml new file mode 100644 index 0000000000..1d7763f913 --- /dev/null +++ b/tests/auto/quick/qquicktextedit/data/http/cursorHttpTestFail1.qml @@ -0,0 +1,18 @@ +import QtQuick 2.0 + +Rectangle { width: 300; height: 300; color: "white" + resources: [ + Component { id:cursorFail; FailItem { objectName: "delegateFail" } }, + Component { id:cursorWait; WaitItem { objectName: "delegateSlow" } }, + Component { id:cursorNorm; NormItem { objectName: "delegateOkay" } } + ] + TextEdit { + cursorDelegate: cursorFail + } + TextEdit { + cursorDelegate: cursorWait + } + TextEdit { + cursorDelegate: cursorNorm + } +} diff --git a/tests/auto/quick/qquicktextedit/data/http/cursorHttpTestFail2.qml b/tests/auto/quick/qquicktextedit/data/http/cursorHttpTestFail2.qml new file mode 100644 index 0000000000..c82ec02e68 --- /dev/null +++ b/tests/auto/quick/qquicktextedit/data/http/cursorHttpTestFail2.qml @@ -0,0 +1,18 @@ +import QtQuick 2.0 + +Rectangle { width: 300; height: 300; color: "white" + resources: [ + Component { id:cursorWait; WaitItem { objectName: "delegateSlow" } }, + Component { id:cursorNorm; NormItem { objectName: "delegateOkay" } }, + Component { id:cursorErr; ErrItem { objectName: "delegateErrorA" } } + ] + TextEdit { + cursorDelegate: cursorWait + } + TextEdit { + cursorDelegate: cursorNorm + } + TextEdit { + cursorDelegate: cursorErr + } +} diff --git a/tests/auto/quick/qquicktextedit/data/http/cursorHttpTestPass.qml b/tests/auto/quick/qquicktextedit/data/http/cursorHttpTestPass.qml new file mode 100644 index 0000000000..96d582c95d --- /dev/null +++ b/tests/auto/quick/qquicktextedit/data/http/cursorHttpTestPass.qml @@ -0,0 +1,18 @@ +import QtQuick 2.0 + +Rectangle { width: 300; height: 300; color: "white" + resources: [ + Component { id:cursorWait; WaitItem { objectName: "delegateSlow" } }, + Component { id:cursorNorm; NormItem { objectName: "delegateOkay" } } + ] + TextEdit { + cursorDelegate: cursorWait + text: "Hello" + } + TextEdit { + objectName: "textEditObject" + cursorDelegate: cursorNorm + focus: true; + text: "Hello" + } +} diff --git a/tests/auto/quick/qquicktextedit/data/http/exists.png b/tests/auto/quick/qquicktextedit/data/http/exists.png new file mode 100644 index 0000000000..399bd0b1d9 Binary files /dev/null and b/tests/auto/quick/qquicktextedit/data/http/exists.png differ diff --git a/tests/auto/quick/qquicktextedit/data/http/qmldir b/tests/auto/quick/qquicktextedit/data/http/qmldir new file mode 100644 index 0000000000..886e6ffec0 --- /dev/null +++ b/tests/auto/quick/qquicktextedit/data/http/qmldir @@ -0,0 +1,4 @@ +ErrItem ErrItem.qml +NormItem NormItem.qml +FailItem FailItem.qml +WaitItem WaitItem.qml diff --git a/tests/auto/quick/qquicktextedit/data/httpfail/FailItem.qml b/tests/auto/quick/qquicktextedit/data/httpfail/FailItem.qml new file mode 100644 index 0000000000..8161843479 --- /dev/null +++ b/tests/auto/quick/qquicktextedit/data/httpfail/FailItem.qml @@ -0,0 +1,5 @@ +import QtQuick 2.0 + +Item { + Rectangle { } +} diff --git a/tests/auto/quick/qquicktextedit/data/httpslow/WaitItem.qml b/tests/auto/quick/qquicktextedit/data/httpslow/WaitItem.qml new file mode 100644 index 0000000000..8161843479 --- /dev/null +++ b/tests/auto/quick/qquicktextedit/data/httpslow/WaitItem.qml @@ -0,0 +1,5 @@ +import QtQuick 2.0 + +Item { + Rectangle { } +} diff --git a/tests/auto/quick/qquicktextedit/data/inputContext.qml b/tests/auto/quick/qquicktextedit/data/inputContext.qml new file mode 100644 index 0000000000..a37c77e3bf --- /dev/null +++ b/tests/auto/quick/qquicktextedit/data/inputContext.qml @@ -0,0 +1,7 @@ +import QtQuick 2.0 + +TextEdit { + width: 200 + text: "supercalifra" + focus: true +} diff --git a/tests/auto/quick/qquicktextedit/data/inputMethodEvent.qml b/tests/auto/quick/qquicktextedit/data/inputMethodEvent.qml new file mode 100644 index 0000000000..e3f629ce3e --- /dev/null +++ b/tests/auto/quick/qquicktextedit/data/inputMethodEvent.qml @@ -0,0 +1,5 @@ +import QtQuick 2.0 + +TextEdit { + focus: true +} diff --git a/tests/auto/quick/qquicktextedit/data/inputmethodhints.qml b/tests/auto/quick/qquicktextedit/data/inputmethodhints.qml new file mode 100644 index 0000000000..dec3b978e7 --- /dev/null +++ b/tests/auto/quick/qquicktextedit/data/inputmethodhints.qml @@ -0,0 +1,6 @@ +import QtQuick 2.0 + +TextEdit { + text: "Hello world!" + inputMethodHints: Qt.ImhNoPredictiveText +} diff --git a/tests/auto/quick/qquicktextedit/data/linkActivated.qml b/tests/auto/quick/qquicktextedit/data/linkActivated.qml new file mode 100644 index 0000000000..d3bba82b59 --- /dev/null +++ b/tests/auto/quick/qquicktextedit/data/linkActivated.qml @@ -0,0 +1,6 @@ +import QtQuick 2.0 + +TextEdit { + textFormat: TextEdit.RichText + text: "Test link" +} diff --git a/tests/auto/quick/qquicktextedit/data/mouseselection_default.qml b/tests/auto/quick/qquicktextedit/data/mouseselection_default.qml new file mode 100644 index 0000000000..ac32f4ced7 --- /dev/null +++ b/tests/auto/quick/qquicktextedit/data/mouseselection_default.qml @@ -0,0 +1,7 @@ +import QtQuick 2.0 + +TextEdit { + focus: true + text: "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ" + selectByMouse: false +} diff --git a/tests/auto/quick/qquicktextedit/data/mouseselection_false.qml b/tests/auto/quick/qquicktextedit/data/mouseselection_false.qml new file mode 100644 index 0000000000..ac32f4ced7 --- /dev/null +++ b/tests/auto/quick/qquicktextedit/data/mouseselection_false.qml @@ -0,0 +1,7 @@ +import QtQuick 2.0 + +TextEdit { + focus: true + text: "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ" + selectByMouse: false +} diff --git a/tests/auto/quick/qquicktextedit/data/mouseselection_false_words.qml b/tests/auto/quick/qquicktextedit/data/mouseselection_false_words.qml new file mode 100644 index 0000000000..86aea46a85 --- /dev/null +++ b/tests/auto/quick/qquicktextedit/data/mouseselection_false_words.qml @@ -0,0 +1,8 @@ +import QtQuick 2.0 + +TextEdit { + focus: true + text: "0123456789 ABCDEFGHIJKLMNOPQRSTUVWXYZ" + selectByMouse: false + mouseSelectionMode: TextEdit.SelectWords +} diff --git a/tests/auto/quick/qquicktextedit/data/mouseselection_true.qml b/tests/auto/quick/qquicktextedit/data/mouseselection_true.qml new file mode 100644 index 0000000000..7c7cb0b6fc --- /dev/null +++ b/tests/auto/quick/qquicktextedit/data/mouseselection_true.qml @@ -0,0 +1,7 @@ +import QtQuick 2.0 + +TextEdit { + focus: true + text: "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ" + selectByMouse: true +} diff --git a/tests/auto/quick/qquicktextedit/data/mouseselection_true_words.qml b/tests/auto/quick/qquicktextedit/data/mouseselection_true_words.qml new file mode 100644 index 0000000000..c356999220 --- /dev/null +++ b/tests/auto/quick/qquicktextedit/data/mouseselection_true_words.qml @@ -0,0 +1,8 @@ +import QtQuick 2.0 + +TextEdit { + focus: true + text: "0123456789 ABCDEFGHIJKLMNOPQRSTUVWXYZ" + selectByMouse: true + mouseSelectionMode: TextEdit.SelectWords +} diff --git a/tests/auto/quick/qquicktextedit/data/mouseselectionmode_characters.qml b/tests/auto/quick/qquicktextedit/data/mouseselectionmode_characters.qml new file mode 100644 index 0000000000..c1fe42fd57 --- /dev/null +++ b/tests/auto/quick/qquicktextedit/data/mouseselectionmode_characters.qml @@ -0,0 +1,8 @@ +import QtQuick 2.0 + +TextEdit { + focus: true + text: "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ" + selectByMouse: true + mouseSelectionMode: TextEdit.SelectCharacters +} diff --git a/tests/auto/quick/qquicktextedit/data/mouseselectionmode_default.qml b/tests/auto/quick/qquicktextedit/data/mouseselectionmode_default.qml new file mode 100644 index 0000000000..7c7cb0b6fc --- /dev/null +++ b/tests/auto/quick/qquicktextedit/data/mouseselectionmode_default.qml @@ -0,0 +1,7 @@ +import QtQuick 2.0 + +TextEdit { + focus: true + text: "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ" + selectByMouse: true +} diff --git a/tests/auto/quick/qquicktextedit/data/mouseselectionmode_words.qml b/tests/auto/quick/qquicktextedit/data/mouseselectionmode_words.qml new file mode 100644 index 0000000000..0a372bbf83 --- /dev/null +++ b/tests/auto/quick/qquicktextedit/data/mouseselectionmode_words.qml @@ -0,0 +1,8 @@ +import QtQuick 2.0 + +TextEdit { + focus: true + text: "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ" + selectByMouse: true + mouseSelectionMode: TextEdit.SelectWords +} diff --git a/tests/auto/quick/qquicktextedit/data/navigation.qml b/tests/auto/quick/qquicktextedit/data/navigation.qml new file mode 100644 index 0000000000..0201c62b3c --- /dev/null +++ b/tests/auto/quick/qquicktextedit/data/navigation.qml @@ -0,0 +1,24 @@ +import QtQuick 2.0 + +Rectangle { + property variant myInput: input + + width: 800; height: 600; color: "blue" + + Item { + id: firstItem; + KeyNavigation.right: input + } + + TextEdit { id: input; focus: true + KeyNavigation.left: firstItem + KeyNavigation.right: lastItem + KeyNavigation.up: firstItem + KeyNavigation.down: lastItem + text: "a" + } + Item { + id: lastItem + KeyNavigation.left: input + } +} diff --git a/tests/auto/quick/qquicktextedit/data/openInputPanel.qml b/tests/auto/quick/qquicktextedit/data/openInputPanel.qml new file mode 100644 index 0000000000..d3aecf21be --- /dev/null +++ b/tests/auto/quick/qquicktextedit/data/openInputPanel.qml @@ -0,0 +1,7 @@ +import QtQuick 2.0 + +TextEdit { + width: 100; height: 100 + text: "Hello world" + focus: false +} diff --git a/tests/auto/quick/qquicktextedit/data/persistentSelection.qml b/tests/auto/quick/qquicktextedit/data/persistentSelection.qml new file mode 100644 index 0000000000..fb2fe0cd6c --- /dev/null +++ b/tests/auto/quick/qquicktextedit/data/persistentSelection.qml @@ -0,0 +1,8 @@ +import QtQuick 2.0 + +TextEdit { + property string selected: selectedText + + text: "Hello World!" + focus: true +} diff --git a/tests/auto/quick/qquicktextedit/data/positionAt.qml b/tests/auto/quick/qquicktextedit/data/positionAt.qml new file mode 100644 index 0000000000..19093281fe --- /dev/null +++ b/tests/auto/quick/qquicktextedit/data/positionAt.qml @@ -0,0 +1,9 @@ +import QtQuick 2.0 + +TextEdit { + focus: true + objectName: "myInput" + width: 50 + height: 25 + text: "This is\n a long piece of text" +} diff --git a/tests/auto/quick/qquicktextedit/data/qtbug-22058.qml b/tests/auto/quick/qquicktextedit/data/qtbug-22058.qml new file mode 100644 index 0000000000..8ad1514fbf --- /dev/null +++ b/tests/auto/quick/qquicktextedit/data/qtbug-22058.qml @@ -0,0 +1,39 @@ +import QtQuick 2.0 + +Rectangle { + property variant inputField: textedit + height: 200 + width: 200 + + Rectangle { + height: parent.height /2 + width: parent.width + color: "transparent" + border.color: "black" + border.width: 4 + Text { + anchors.centerIn: parent + height: parent.height * .95 + width: parent.width * .95 + text: textedit.text + } + } + + Rectangle { + height: parent.height /2 + width: parent.width + color: "transparent" + border.color: "black" + border.width: 4 + anchors.bottom: parent.bottom + TextEdit { + id: textedit + anchors.centerIn: parent + height: parent.height * .95 + width: parent.width * .95 + focus: true + wrapMode: TextEdit.WordWrap + text: "" + } + } +} diff --git a/tests/auto/quick/qquicktextedit/data/readOnly.qml b/tests/auto/quick/qquicktextedit/data/readOnly.qml new file mode 100644 index 0000000000..085adba5fb --- /dev/null +++ b/tests/auto/quick/qquicktextedit/data/readOnly.qml @@ -0,0 +1,12 @@ +import QtQuick 2.0 + +Rectangle { + property variant myInput: input + + width: 800; height: 600; color: "blue" + + TextEdit { id: input; focus: true + readOnly: true + text: "I am the very model of a modern major general.\n" + } +} diff --git a/tests/auto/quick/qquicktextedit/qquicktextedit.pro b/tests/auto/quick/qquicktextedit/qquicktextedit.pro new file mode 100644 index 0000000000..39a5178c7d --- /dev/null +++ b/tests/auto/quick/qquicktextedit/qquicktextedit.pro @@ -0,0 +1,16 @@ +CONFIG += testcase +TARGET = tst_qquicktextedit +macx:CONFIG -= app_bundle + +SOURCES += tst_qquicktextedit.cpp \ + ../../shared/testhttpserver.cpp + +HEADERS += ../../shared/testhttpserver.h + +include (../../shared/util.pri) + +testDataFiles.files = data +testDataFiles.path = . +DEPLOYMENT += testDataFiles + +QT += core-private gui-private v8-private qml-private quick-private opengl-private network widgets-private testlib diff --git a/tests/auto/quick/qquicktextedit/tst_qquicktextedit.cpp b/tests/auto/quick/qquicktextedit/tst_qquicktextedit.cpp new file mode 100644 index 0000000000..314a523602 --- /dev/null +++ b/tests/auto/quick/qquicktextedit/tst_qquicktextedit.cpp @@ -0,0 +1,3884 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include +#include +#include "../../shared/testhttpserver.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "../../shared/util.h" +#include "../../shared/platforminputcontext.h" +#include + +#ifdef Q_OS_MAC +#include +#endif + + +Q_DECLARE_METATYPE(QQuickTextEdit::SelectionMode) +DEFINE_BOOL_CONFIG_OPTION(qmlDisableDistanceField, QML_DISABLE_DISTANCEFIELD) + +QString createExpectedFileIfNotFound(const QString& filebasename, const QImage& actual) +{ + // XXX This will be replaced by some clever persistent platform image store. + QString persistent_dir = QQmlDataTest::instance()->dataDirectory(); + QString arch = "unknown-architecture"; // QTest needs to help with this. + + QString expectfile = persistent_dir + QDir::separator() + filebasename + "-" + arch + ".png"; + + if (!QFile::exists(expectfile)) { + actual.save(expectfile); + qWarning() << "created" << expectfile; + } + + return expectfile; +} + +typedef QPair Key; + +class tst_qquicktextedit : public QQmlDataTest + +{ + Q_OBJECT +public: + tst_qquicktextedit(); + +private slots: + void cleanup(); + void text(); + void width(); + void wrap(); + void textFormat(); + void alignments(); + void alignments_data(); + + // ### these tests may be trivial + void hAlign(); + void hAlign_RightToLeft(); + void vAlign(); + void font(); + void color(); + void textMargin(); + void persistentSelection(); + void focusOnPress(); + void selection(); + void isRightToLeft_data(); + void isRightToLeft(); + void keySelection(); + void moveCursorSelection_data(); + void moveCursorSelection(); + void moveCursorSelectionSequence_data(); + void moveCursorSelectionSequence(); + void mouseSelection_data(); + void mouseSelection(); + void mouseSelectionMode_data(); + void mouseSelectionMode(); + void dragMouseSelection(); + void inputMethodHints(); + + void positionAt(); + + void linkActivated(); + + void cursorDelegate_data(); + void cursorDelegate(); + void cursorVisible(); + void delegateLoading_data(); + void delegateLoading(); + void navigation(); + void readOnly(); + void copyAndPaste(); + void canPaste(); + void canPasteEmpty(); + void textInput(); + void inputMethodUpdate(); + void openInputPanel(); + void geometrySignals(); + void pastingRichText_QTBUG_14003(); + void implicitSize_data(); + void implicitSize(); + void contentSize(); + + void preeditCursorRectangle(); + void inputMethodComposing(); + void cursorRectangleSize(); + + void getText_data(); + void getText(); + void getFormattedText_data(); + void getFormattedText(); + void insert_data(); + void insert(); + void remove_data(); + void remove(); + + void keySequence_data(); + void keySequence(); + + void undo_data(); + void undo(); + void redo_data(); + void redo(); + void undo_keypressevents_data(); + void undo_keypressevents(); + + void baseUrl(); + void embeddedImages(); + void embeddedImages_data(); + + void emptytags_QTBUG_22058(); + +private: + void simulateKeys(QWindow *window, const QList &keys); + void simulateKeys(QWindow *window, const QKeySequence &sequence); + + void simulateKey(QQuickView *, int key, Qt::KeyboardModifiers modifiers = 0); + + QStringList standard; + QStringList richText; + + QStringList hAlignmentStrings; + QStringList vAlignmentStrings; + + QList vAlignments; + QList hAlignments; + + QStringList colorStrings; + + QQmlEngine engine; +}; + +typedef QList IntList; +Q_DECLARE_METATYPE(IntList) + +typedef QList KeyList; +Q_DECLARE_METATYPE(KeyList) + +Q_DECLARE_METATYPE(QQuickTextEdit::TextFormat) + +void tst_qquicktextedit::simulateKeys(QWindow *window, const QList &keys) +{ + for (int i = 0; i < keys.count(); ++i) { + const int key = keys.at(i).first; + const int modifiers = key & Qt::KeyboardModifierMask; + const QString text = !keys.at(i).second.isNull() ? QString(keys.at(i).second) : QString(); + + QKeyEvent press(QEvent::KeyPress, Qt::Key(key), Qt::KeyboardModifiers(modifiers), text); + QKeyEvent release(QEvent::KeyRelease, Qt::Key(key), Qt::KeyboardModifiers(modifiers), text); + + QGuiApplication::sendEvent(window, &press); + QGuiApplication::sendEvent(window, &release); + } +} + +void tst_qquicktextedit::simulateKeys(QWindow *window, const QKeySequence &sequence) +{ + for (int i = 0; i < sequence.count(); ++i) { + const int key = sequence[i]; + const int modifiers = key & Qt::KeyboardModifierMask; + + QTest::keyClick(window, Qt::Key(key & ~modifiers), Qt::KeyboardModifiers(modifiers)); + } +} + +QList &operator <<(QList &keys, const QKeySequence &sequence) +{ + for (int i = 0; i < sequence.count(); ++i) + keys << Key(sequence[i], QChar()); + return keys; +} + +template QList &operator <<(QList &keys, const char (&characters)[N]) +{ + for (int i = 0; i < N - 1; ++i) { + int key = QTest::asciiToKey(characters[i]); + QChar character = QLatin1Char(characters[i]); + keys << Key(key, character); + } + return keys; +} + +QList &operator <<(QList &keys, Qt::Key key) +{ + keys << Key(key, QChar()); + return keys; +} + +tst_qquicktextedit::tst_qquicktextedit() +{ + standard << "the quick brown fox jumped over the lazy dog" + << "the quick brown fox\n jumped over the lazy dog" + << "Hello, world!" + << "!dlrow ,olleH"; + + richText << "the quick brown fox jumped over the lazy dog" + << "the quick brown fox
          jumped over the lazy dog
          "; + + hAlignmentStrings << "AlignLeft" + << "AlignRight" + << "AlignHCenter"; + + vAlignmentStrings << "AlignTop" + << "AlignBottom" + << "AlignVCenter"; + + hAlignments << Qt::AlignLeft + << Qt::AlignRight + << Qt::AlignHCenter; + + vAlignments << Qt::AlignTop + << Qt::AlignBottom + << Qt::AlignVCenter; + + colorStrings << "aliceblue" + << "antiquewhite" + << "aqua" + << "darkkhaki" + << "darkolivegreen" + << "dimgray" + << "palevioletred" + << "lightsteelblue" + << "#000000" + << "#AAAAAA" + << "#FFFFFF" + << "#2AC05F"; + // + // need a different test to do alpha channel test + // << "#AA0011DD" + // << "#00F16B11"; + // +} + +void tst_qquicktextedit::cleanup() +{ + // ensure not even skipped tests with custom input context leave it dangling + QInputMethodPrivate *inputMethodPrivate = QInputMethodPrivate::get(qApp->inputMethod()); + inputMethodPrivate->testContext = 0; +} + +void tst_qquicktextedit::text() +{ + { + QQmlComponent texteditComponent(&engine); + texteditComponent.setData("import QtQuick 2.0\nTextEdit { text: \"\" }", QUrl()); + QQuickTextEdit *textEditObject = qobject_cast(texteditComponent.create()); + + QVERIFY(textEditObject != 0); + QCOMPARE(textEditObject->text(), QString("")); + QCOMPARE(textEditObject->length(), 0); + } + + for (int i = 0; i < standard.size(); i++) + { + QString componentStr = "import QtQuick 2.0\nTextEdit { text: \"" + standard.at(i) + "\" }"; + QQmlComponent texteditComponent(&engine); + texteditComponent.setData(componentStr.toLatin1(), QUrl()); + QQuickTextEdit *textEditObject = qobject_cast(texteditComponent.create()); + + QVERIFY(textEditObject != 0); + QCOMPARE(textEditObject->text(), standard.at(i)); + QCOMPARE(textEditObject->length(), standard.at(i).length()); + } + + for (int i = 0; i < richText.size(); i++) + { + QString componentStr = "import QtQuick 2.0\nTextEdit { text: \"" + richText.at(i) + "\" }"; + QQmlComponent texteditComponent(&engine); + texteditComponent.setData(componentStr.toLatin1(), QUrl()); + + QQuickTextEdit *textEditObject = qobject_cast(texteditComponent.create()); + + QVERIFY(textEditObject != 0); + + QString expected = richText.at(i); + expected.replace(QRegExp("\\\\(.)"),"\\1"); + QCOMPARE(textEditObject->text(), expected); + QCOMPARE(textEditObject->length(), expected.length()); + } + + for (int i = 0; i < standard.size(); i++) + { + QString componentStr = "import QtQuick 2.0\nTextEdit { textFormat: TextEdit.RichText; text: \"" + standard.at(i) + "\" }"; + QQmlComponent texteditComponent(&engine); + texteditComponent.setData(componentStr.toLatin1(), QUrl()); + QQuickTextEdit *textEditObject = qobject_cast(texteditComponent.create()); + + QVERIFY(textEditObject != 0); + + QString actual = textEditObject->text(); + QString expected = standard.at(i); + actual.remove(QRegExp(".*]*>")); + actual.remove(QRegExp("(<[^>]*>)+")); + expected.remove("\n"); + QCOMPARE(actual.simplified(), expected); + QCOMPARE(textEditObject->length(), expected.length()); + } + + for (int i = 0; i < richText.size(); i++) + { + QString componentStr = "import QtQuick 2.0\nTextEdit { textFormat: TextEdit.RichText; text: \"" + richText.at(i) + "\" }"; + QQmlComponent texteditComponent(&engine); + texteditComponent.setData(componentStr.toLatin1(), QUrl()); + QQuickTextEdit *textEditObject = qobject_cast(texteditComponent.create()); + + QVERIFY(textEditObject != 0); + QString actual = textEditObject->text(); + QString expected = richText.at(i); + actual.replace(QRegExp(".*]*>"),""); + actual.replace(QRegExp("(<[^>]*>)+"),"<>"); + expected.replace(QRegExp("(<[^>]*>)+"),"<>"); + QCOMPARE(actual.simplified(),expected.simplified()); + + expected.replace("<>", " "); + QCOMPARE(textEditObject->length(), expected.simplified().length()); + } + + for (int i = 0; i < standard.size(); i++) + { + QString componentStr = "import QtQuick 2.0\nTextEdit { textFormat: TextEdit.AutoText; text: \"" + standard.at(i) + "\" }"; + QQmlComponent texteditComponent(&engine); + texteditComponent.setData(componentStr.toLatin1(), QUrl()); + QQuickTextEdit *textEditObject = qobject_cast(texteditComponent.create()); + + QVERIFY(textEditObject != 0); + QCOMPARE(textEditObject->text(), standard.at(i)); + QCOMPARE(textEditObject->length(), standard.at(i).length()); + } + + for (int i = 0; i < richText.size(); i++) + { + QString componentStr = "import QtQuick 2.0\nTextEdit { textFormat: TextEdit.AutoText; text: \"" + richText.at(i) + "\" }"; + QQmlComponent texteditComponent(&engine); + texteditComponent.setData(componentStr.toLatin1(), QUrl()); + QQuickTextEdit *textEditObject = qobject_cast(texteditComponent.create()); + + QVERIFY(textEditObject != 0); + QString actual = textEditObject->text(); + QString expected = richText.at(i); + actual.replace(QRegExp(".*]*>"),""); + actual.replace(QRegExp("(<[^>]*>)+"),"<>"); + expected.replace(QRegExp("(<[^>]*>)+"),"<>"); + QCOMPARE(actual.simplified(),expected.simplified()); + + expected.replace("<>", " "); + QCOMPARE(textEditObject->length(), expected.simplified().length()); + } +} + +void tst_qquicktextedit::width() +{ + // uses Font metrics to find the width for standard and document to find the width for rich + { + QQmlComponent texteditComponent(&engine); + texteditComponent.setData("import QtQuick 2.0\nTextEdit { text: \"\" }", QUrl()); + QQuickTextEdit *textEditObject = qobject_cast(texteditComponent.create()); + + QVERIFY(textEditObject != 0); + QCOMPARE(textEditObject->width(), 0.0); + } + + bool requiresUnhintedMetrics = !qmlDisableDistanceField(); + + for (int i = 0; i < standard.size(); i++) + { + QString componentStr = "import QtQuick 2.0\nTextEdit { text: \"" + standard.at(i) + "\" }"; + QQmlComponent texteditComponent(&engine); + texteditComponent.setData(componentStr.toLatin1(), QUrl()); + QQuickTextEdit *textEditObject = qobject_cast(texteditComponent.create()); + + QString s = standard.at(i); + s.replace(QLatin1Char('\n'), QChar::LineSeparator); + + QTextLayout layout(s); + layout.setFont(textEditObject->font()); + layout.setFlags(Qt::TextExpandTabs | Qt::TextShowMnemonic); + if (requiresUnhintedMetrics) { + QTextOption option; + option.setUseDesignMetrics(true); + layout.setTextOption(option); + } + + layout.beginLayout(); + forever { + QTextLine line = layout.createLine(); + if (!line.isValid()) + break; + } + + layout.endLayout(); + + qreal metricWidth = ceil(layout.boundingRect().width()); + + QVERIFY(textEditObject != 0); + QCOMPARE(textEditObject->width(), qreal(metricWidth)); + } + + for (int i = 0; i < richText.size(); i++) + { + QTextDocument document; + document.setHtml(richText.at(i)); + document.setDocumentMargin(0); + if (requiresUnhintedMetrics) + document.setUseDesignMetrics(true); + + int documentWidth = ceil(document.idealWidth()); + + QString componentStr = "import QtQuick 2.0\nTextEdit { textFormat: TextEdit.RichText; text: \"" + richText.at(i) + "\" }"; + QQmlComponent texteditComponent(&engine); + texteditComponent.setData(componentStr.toLatin1(), QUrl()); + QQuickTextEdit *textEditObject = qobject_cast(texteditComponent.create()); + + QVERIFY(textEditObject != 0); + QCOMPARE(textEditObject->width(), qreal(documentWidth)); + } +} + +void tst_qquicktextedit::wrap() +{ + // for specified width and wrap set true + { + QQmlComponent texteditComponent(&engine); + texteditComponent.setData("import QtQuick 2.0\nTextEdit { text: \"\"; wrapMode: TextEdit.WordWrap; width: 300 }", QUrl()); + QQuickTextEdit *textEditObject = qobject_cast(texteditComponent.create()); + + QVERIFY(textEditObject != 0); + QCOMPARE(textEditObject->width(), 300.); + } + + for (int i = 0; i < standard.size(); i++) + { + QString componentStr = "import QtQuick 2.0\nTextEdit { wrapMode: TextEdit.WordWrap; width: 300; text: \"" + standard.at(i) + "\" }"; + QQmlComponent texteditComponent(&engine); + texteditComponent.setData(componentStr.toLatin1(), QUrl()); + QQuickTextEdit *textEditObject = qobject_cast(texteditComponent.create()); + + QVERIFY(textEditObject != 0); + QCOMPARE(textEditObject->width(), 300.); + } + + for (int i = 0; i < richText.size(); i++) + { + QString componentStr = "import QtQuick 2.0\nTextEdit { wrapMode: TextEdit.WordWrap; width: 300; text: \"" + richText.at(i) + "\" }"; + QQmlComponent texteditComponent(&engine); + texteditComponent.setData(componentStr.toLatin1(), QUrl()); + QQuickTextEdit *textEditObject = qobject_cast(texteditComponent.create()); + + QVERIFY(textEditObject != 0); + QCOMPARE(textEditObject->width(), 300.); + } + +} + +void tst_qquicktextedit::textFormat() +{ + { + QQmlComponent textComponent(&engine); + textComponent.setData("import QtQuick 2.0\nTextEdit { text: \"Hello\"; textFormat: Text.RichText }", QUrl::fromLocalFile("")); + QQuickTextEdit *textObject = qobject_cast(textComponent.create()); + + QVERIFY(textObject != 0); + QVERIFY(textObject->textFormat() == QQuickTextEdit::RichText); + } + { + QQmlComponent textComponent(&engine); + textComponent.setData("import QtQuick 2.0\nTextEdit { text: \"Hello\"; textFormat: Text.PlainText }", QUrl::fromLocalFile("")); + QQuickTextEdit *textObject = qobject_cast(textComponent.create()); + + QVERIFY(textObject != 0); + QVERIFY(textObject->textFormat() == QQuickTextEdit::PlainText); + } +} + +void tst_qquicktextedit::alignments_data() +{ + QTest::addColumn("hAlign"); + QTest::addColumn("vAlign"); + QTest::addColumn("expectfile"); + + QTest::newRow("LT") << int(Qt::AlignLeft) << int(Qt::AlignTop) << "alignments_lt"; + QTest::newRow("RT") << int(Qt::AlignRight) << int(Qt::AlignTop) << "alignments_rt"; + QTest::newRow("CT") << int(Qt::AlignHCenter) << int(Qt::AlignTop) << "alignments_ct"; + + QTest::newRow("LB") << int(Qt::AlignLeft) << int(Qt::AlignBottom) << "alignments_lb"; + QTest::newRow("RB") << int(Qt::AlignRight) << int(Qt::AlignBottom) << "alignments_rb"; + QTest::newRow("CB") << int(Qt::AlignHCenter) << int(Qt::AlignBottom) << "alignments_cb"; + + QTest::newRow("LC") << int(Qt::AlignLeft) << int(Qt::AlignVCenter) << "alignments_lc"; + QTest::newRow("RC") << int(Qt::AlignRight) << int(Qt::AlignVCenter) << "alignments_rc"; + QTest::newRow("CC") << int(Qt::AlignHCenter) << int(Qt::AlignVCenter) << "alignments_cc"; +} + + +void tst_qquicktextedit::alignments() +{ + QSKIP("Image comparison of text is almost guaranteed to fail during development"); + + QFETCH(int, hAlign); + QFETCH(int, vAlign); + QFETCH(QString, expectfile); + + QQuickView canvas(testFileUrl("alignments.qml")); + + canvas.show(); + canvas.requestActivateWindow(); + QTest::qWaitForWindowShown(&canvas); + QTRY_COMPARE(&canvas, qGuiApp->focusWindow()); + + QObject *ob = canvas.rootObject(); + QVERIFY(ob != 0); + ob->setProperty("horizontalAlignment",hAlign); + ob->setProperty("verticalAlignment",vAlign); + QTRY_COMPARE(ob->property("running").toBool(),false); + QImage actual = canvas.grabFrameBuffer(); + + expectfile = createExpectedFileIfNotFound(expectfile, actual); + + QImage expect(expectfile); + + QCOMPARE(actual,expect); +} + + +//the alignment tests may be trivial o.oa +void tst_qquicktextedit::hAlign() +{ + //test one align each, and then test if two align fails. + + for (int i = 0; i < standard.size(); i++) + { + for (int j=0; j < hAlignmentStrings.size(); j++) + { + QString componentStr = "import QtQuick 2.0\nTextEdit { horizontalAlignment: \"" + hAlignmentStrings.at(j) + "\"; text: \"" + standard.at(i) + "\" }"; + QQmlComponent texteditComponent(&engine); + texteditComponent.setData(componentStr.toLatin1(), QUrl()); + QQuickTextEdit *textEditObject = qobject_cast(texteditComponent.create()); + + QVERIFY(textEditObject != 0); + QCOMPARE((int)textEditObject->hAlign(), (int)hAlignments.at(j)); + } + } + + for (int i = 0; i < richText.size(); i++) + { + for (int j=0; j < hAlignmentStrings.size(); j++) + { + QString componentStr = "import QtQuick 2.0\nTextEdit { horizontalAlignment: \"" + hAlignmentStrings.at(j) + "\"; text: \"" + richText.at(i) + "\" }"; + QQmlComponent texteditComponent(&engine); + texteditComponent.setData(componentStr.toLatin1(), QUrl()); + QQuickTextEdit *textEditObject = qobject_cast(texteditComponent.create()); + + QVERIFY(textEditObject != 0); + QCOMPARE((int)textEditObject->hAlign(), (int)hAlignments.at(j)); + } + } + +} + +void tst_qquicktextedit::hAlign_RightToLeft() +{ + PlatformInputContext platformInputContext; + QInputMethodPrivate *inputMethodPrivate = QInputMethodPrivate::get(qApp->inputMethod()); + inputMethodPrivate->testContext = &platformInputContext; + + QQuickView canvas(testFileUrl("horizontalAlignment_RightToLeft.qml")); + QQuickTextEdit *textEdit = canvas.rootObject()->findChild("text"); + QVERIFY(textEdit != 0); + canvas.show(); + + const QString rtlText = textEdit->text(); + + // implicit alignment should follow the reading direction of text + QCOMPARE(textEdit->hAlign(), QQuickTextEdit::AlignRight); + QVERIFY(textEdit->positionToRectangle(0).x() > canvas.width()/2); + + // explicitly left aligned + textEdit->setHAlign(QQuickTextEdit::AlignLeft); + QCOMPARE(textEdit->hAlign(), QQuickTextEdit::AlignLeft); + QVERIFY(textEdit->positionToRectangle(0).x() < canvas.width()/2); + + // explicitly right aligned + textEdit->setHAlign(QQuickTextEdit::AlignRight); + QCOMPARE(textEdit->hAlign(), QQuickTextEdit::AlignRight); + QVERIFY(textEdit->positionToRectangle(0).x() > canvas.width()/2); + + QString textString = textEdit->text(); + textEdit->setText(QString("") + textString + QString("")); + textEdit->resetHAlign(); + + // implicitly aligned rich text should follow the reading direction of RTL text + QCOMPARE(textEdit->hAlign(), QQuickTextEdit::AlignRight); + QCOMPARE(textEdit->effectiveHAlign(), textEdit->hAlign()); + QVERIFY(textEdit->positionToRectangle(0).x() > canvas.width()/2); + + // explicitly left aligned rich text + textEdit->setHAlign(QQuickTextEdit::AlignLeft); + QCOMPARE(textEdit->hAlign(), QQuickTextEdit::AlignLeft); + QCOMPARE(textEdit->effectiveHAlign(), textEdit->hAlign()); + QVERIFY(textEdit->positionToRectangle(0).x() < canvas.width()/2); + + // explicitly right aligned rich text + textEdit->setHAlign(QQuickTextEdit::AlignRight); + QCOMPARE(textEdit->hAlign(), QQuickTextEdit::AlignRight); + QCOMPARE(textEdit->effectiveHAlign(), textEdit->hAlign()); + QVERIFY(textEdit->positionToRectangle(0).x() > canvas.width()/2); + + textEdit->setText(textString); + + // explicitly center aligned + textEdit->setHAlign(QQuickTextEdit::AlignHCenter); + QCOMPARE(textEdit->hAlign(), QQuickTextEdit::AlignHCenter); + QVERIFY(textEdit->positionToRectangle(0).x() > canvas.width()/2); + + // reseted alignment should go back to following the text reading direction + textEdit->resetHAlign(); + QCOMPARE(textEdit->hAlign(), QQuickTextEdit::AlignRight); + QVERIFY(textEdit->positionToRectangle(0).x() > canvas.width()/2); + + // mirror the text item + QQuickItemPrivate::get(textEdit)->setLayoutMirror(true); + + // mirrored implicit alignment should continue to follow the reading direction of the text + QCOMPARE(textEdit->hAlign(), QQuickTextEdit::AlignRight); + QCOMPARE(textEdit->effectiveHAlign(), QQuickTextEdit::AlignRight); + QVERIFY(textEdit->positionToRectangle(0).x() > canvas.width()/2); + + // mirrored explicitly right aligned behaves as left aligned + textEdit->setHAlign(QQuickTextEdit::AlignRight); + QCOMPARE(textEdit->hAlign(), QQuickTextEdit::AlignRight); + QCOMPARE(textEdit->effectiveHAlign(), QQuickTextEdit::AlignLeft); + QVERIFY(textEdit->positionToRectangle(0).x() < canvas.width()/2); + + // mirrored explicitly left aligned behaves as right aligned + textEdit->setHAlign(QQuickTextEdit::AlignLeft); + QCOMPARE(textEdit->hAlign(), QQuickTextEdit::AlignLeft); + QCOMPARE(textEdit->effectiveHAlign(), QQuickTextEdit::AlignRight); + QVERIFY(textEdit->positionToRectangle(0).x() > canvas.width()/2); + + // disable mirroring + QQuickItemPrivate::get(textEdit)->setLayoutMirror(false); + textEdit->resetHAlign(); + + // English text should be implicitly left aligned + textEdit->setText("Hello world!"); + QCOMPARE(textEdit->hAlign(), QQuickTextEdit::AlignLeft); + QVERIFY(textEdit->positionToRectangle(0).x() < canvas.width()/2); + + canvas.requestActivateWindow(); + QTest::qWaitForWindowShown(&canvas); + QTRY_COMPARE(&canvas, qGuiApp->focusWindow()); + + textEdit->setText(QString()); + { QInputMethodEvent ev(rtlText, QList()); QGuiApplication::sendEvent(qGuiApp->focusObject(), &ev); } + QCOMPARE(textEdit->hAlign(), QQuickTextEdit::AlignRight); + { QInputMethodEvent ev("Hello world!", QList()); QGuiApplication::sendEvent(qGuiApp->focusObject(), &ev); } + QCOMPARE(textEdit->hAlign(), QQuickTextEdit::AlignLeft); + + // Clear pre-edit text. TextEdit should maybe do this itself on setText, but that may be + // redundant as an actual input method may take care of it. + { QInputMethodEvent ev; QGuiApplication::sendEvent(qGuiApp->focusObject(), &ev); } + + // empty text with implicit alignment follows the system locale-based + // keyboard input direction from qApp->inputMethod()->inputDirection + textEdit->setText(""); + platformInputContext.setInputDirection(Qt::LeftToRight); + QVERIFY(qApp->inputMethod()->inputDirection() == Qt::LeftToRight); + QCOMPARE(textEdit->hAlign(), QQuickTextEdit::AlignLeft); + QVERIFY(textEdit->positionToRectangle(0).x() < canvas.width()/2); + + QSignalSpy cursorRectangleSpy(textEdit, SIGNAL(cursorRectangleChanged())); + + platformInputContext.setInputDirection(Qt::RightToLeft); + QCOMPARE(cursorRectangleSpy.count(), 1); + QVERIFY(qApp->inputMethod()->inputDirection() == Qt::RightToLeft); + QCOMPARE(textEdit->hAlign(), QQuickTextEdit::AlignRight); + QVERIFY(textEdit->positionToRectangle(0).x() > canvas.width()/2); + + // set input direction while having content + platformInputContext.setInputDirection(Qt::LeftToRight); + textEdit->setText("a"); + textEdit->setCursorPosition(1); + platformInputContext.setInputDirection(Qt::RightToLeft); + QTest::keyClick(&canvas, Qt::Key_Backspace); + QVERIFY(textEdit->text().isEmpty()); + QCOMPARE(textEdit->hAlign(), QQuickTextEdit::AlignRight); + QVERIFY(textEdit->cursorRectangle().left() > canvas.width()/2); + + // input direction changed while not having focus + platformInputContext.setInputDirection(Qt::LeftToRight); + textEdit->setFocus(false); + platformInputContext.setInputDirection(Qt::RightToLeft); + textEdit->setFocus(true); + QCOMPARE(textEdit->hAlign(), QQuickTextEdit::AlignRight); + QVERIFY(textEdit->cursorRectangle().left() > canvas.width()/2); + + textEdit->setHAlign(QQuickTextEdit::AlignRight); + QCOMPARE(textEdit->hAlign(), QQuickTextEdit::AlignRight); + QVERIFY(textEdit->positionToRectangle(0).x() > canvas.width()/2); +} + +void tst_qquicktextedit::vAlign() +{ + //test one align each, and then test if two align fails. + + for (int i = 0; i < standard.size(); i++) + { + for (int j=0; j < vAlignmentStrings.size(); j++) + { + QString componentStr = "import QtQuick 2.0\nTextEdit { verticalAlignment: \"" + vAlignmentStrings.at(j) + "\"; text: \"" + standard.at(i) + "\" }"; + QQmlComponent texteditComponent(&engine); + texteditComponent.setData(componentStr.toLatin1(), QUrl()); + QQuickTextEdit *textEditObject = qobject_cast(texteditComponent.create()); + + QVERIFY(textEditObject != 0); + QCOMPARE((int)textEditObject->vAlign(), (int)vAlignments.at(j)); + } + } + + for (int i = 0; i < richText.size(); i++) + { + for (int j=0; j < vAlignmentStrings.size(); j++) + { + QString componentStr = "import QtQuick 2.0\nTextEdit { verticalAlignment: \"" + vAlignmentStrings.at(j) + "\"; text: \"" + richText.at(i) + "\" }"; + QQmlComponent texteditComponent(&engine); + texteditComponent.setData(componentStr.toLatin1(), QUrl()); + QQuickTextEdit *textEditObject = qobject_cast(texteditComponent.create()); + + QVERIFY(textEditObject != 0); + QCOMPARE((int)textEditObject->vAlign(), (int)vAlignments.at(j)); + } + } + + QQmlComponent texteditComponent(&engine); + texteditComponent.setData( + "import QtQuick 2.0\n" + "TextEdit { width: 100; height: 100; text: \"Hello World\" }", QUrl()); + QQuickTextEdit *textEditObject = qobject_cast(texteditComponent.create()); + + QVERIFY(textEditObject != 0); + + QCOMPARE(textEditObject->vAlign(), QQuickTextEdit::AlignTop); + QVERIFY(textEditObject->cursorRectangle().bottom() < 50); + QVERIFY(textEditObject->positionToRectangle(0).bottom() < 50); + + // bottom aligned + textEditObject->setVAlign(QQuickTextEdit::AlignBottom); + QCOMPARE(textEditObject->vAlign(), QQuickTextEdit::AlignBottom); + QVERIFY(textEditObject->cursorRectangle().top() > 50); + QVERIFY(textEditObject->positionToRectangle(0).top() > 50); + + // explicitly center aligned + textEditObject->setVAlign(QQuickTextEdit::AlignVCenter); + QCOMPARE(textEditObject->vAlign(), QQuickTextEdit::AlignVCenter); + QVERIFY(textEditObject->cursorRectangle().top() < 50); + QVERIFY(textEditObject->cursorRectangle().bottom() > 50); + QVERIFY(textEditObject->positionToRectangle(0).top() < 50); + QVERIFY(textEditObject->positionToRectangle(0).bottom() > 50); +} + +void tst_qquicktextedit::font() +{ + //test size, then bold, then italic, then family + { + QString componentStr = "import QtQuick 2.0\nTextEdit { font.pointSize: 40; text: \"Hello World\" }"; + QQmlComponent texteditComponent(&engine); + texteditComponent.setData(componentStr.toLatin1(), QUrl()); + QQuickTextEdit *textEditObject = qobject_cast(texteditComponent.create()); + + QVERIFY(textEditObject != 0); + QCOMPARE(textEditObject->font().pointSize(), 40); + QCOMPARE(textEditObject->font().bold(), false); + QCOMPARE(textEditObject->font().italic(), false); + } + + { + QString componentStr = "import QtQuick 2.0\nTextEdit { font.bold: true; text: \"Hello World\" }"; + QQmlComponent texteditComponent(&engine); + texteditComponent.setData(componentStr.toLatin1(), QUrl()); + QQuickTextEdit *textEditObject = qobject_cast(texteditComponent.create()); + + QVERIFY(textEditObject != 0); + QCOMPARE(textEditObject->font().bold(), true); + QCOMPARE(textEditObject->font().italic(), false); + } + + { + QString componentStr = "import QtQuick 2.0\nTextEdit { font.italic: true; text: \"Hello World\" }"; + QQmlComponent texteditComponent(&engine); + texteditComponent.setData(componentStr.toLatin1(), QUrl()); + QQuickTextEdit *textEditObject = qobject_cast(texteditComponent.create()); + + QVERIFY(textEditObject != 0); + QCOMPARE(textEditObject->font().italic(), true); + QCOMPARE(textEditObject->font().bold(), false); + } + + { + QString componentStr = "import QtQuick 2.0\nTextEdit { font.family: \"Helvetica\"; text: \"Hello World\" }"; + QQmlComponent texteditComponent(&engine); + texteditComponent.setData(componentStr.toLatin1(), QUrl()); + QQuickTextEdit *textEditObject = qobject_cast(texteditComponent.create()); + + QVERIFY(textEditObject != 0); + QCOMPARE(textEditObject->font().family(), QString("Helvetica")); + QCOMPARE(textEditObject->font().bold(), false); + QCOMPARE(textEditObject->font().italic(), false); + } + + { + QString componentStr = "import QtQuick 2.0\nTextEdit { font.family: \"\"; text: \"Hello World\" }"; + QQmlComponent texteditComponent(&engine); + texteditComponent.setData(componentStr.toLatin1(), QUrl()); + QQuickTextEdit *textEditObject = qobject_cast(texteditComponent.create()); + + QVERIFY(textEditObject != 0); + QCOMPARE(textEditObject->font().family(), QString("")); + } +} + +void tst_qquicktextedit::color() +{ + //test initial color + { + QString componentStr = "import QtQuick 2.0\nTextEdit { text: \"Hello World\" }"; + QQmlComponent texteditComponent(&engine); + texteditComponent.setData(componentStr.toLatin1(), QUrl()); + QQuickTextEdit *textEditObject = qobject_cast(texteditComponent.create()); + + QQuickTextEditPrivate *textEditPrivate = static_cast(QQuickItemPrivate::get(textEditObject)); + + QVERIFY(textEditObject); + QVERIFY(textEditPrivate); + QVERIFY(textEditPrivate->control); + + QPalette pal = textEditPrivate->control->palette(); + QCOMPARE(textEditPrivate->color, QColor("black")); + QCOMPARE(textEditPrivate->color, pal.color(QPalette::Text)); + } + //test normal + for (int i = 0; i < colorStrings.size(); i++) + { + QString componentStr = "import QtQuick 2.0\nTextEdit { color: \"" + colorStrings.at(i) + "\"; text: \"Hello World\" }"; + QQmlComponent texteditComponent(&engine); + texteditComponent.setData(componentStr.toLatin1(), QUrl()); + QQuickTextEdit *textEditObject = qobject_cast(texteditComponent.create()); + //qDebug() << "textEditObject: " << textEditObject->color() << "vs. " << QColor(colorStrings.at(i)); + QVERIFY(textEditObject != 0); + QCOMPARE(textEditObject->color(), QColor(colorStrings.at(i))); + } + + //test selection + for (int i = 0; i < colorStrings.size(); i++) + { + QString componentStr = "import QtQuick 2.0\nTextEdit { selectionColor: \"" + colorStrings.at(i) + "\"; text: \"Hello World\" }"; + QQmlComponent texteditComponent(&engine); + texteditComponent.setData(componentStr.toLatin1(), QUrl()); + QQuickTextEdit *textEditObject = qobject_cast(texteditComponent.create()); + QVERIFY(textEditObject != 0); + QCOMPARE(textEditObject->selectionColor(), QColor(colorStrings.at(i))); + } + + //test selected text + for (int i = 0; i < colorStrings.size(); i++) + { + QString componentStr = "import QtQuick 2.0\nTextEdit { selectedTextColor: \"" + colorStrings.at(i) + "\"; text: \"Hello World\" }"; + QQmlComponent texteditComponent(&engine); + texteditComponent.setData(componentStr.toLatin1(), QUrl()); + QQuickTextEdit *textEditObject = qobject_cast(texteditComponent.create()); + QVERIFY(textEditObject != 0); + QCOMPARE(textEditObject->selectedTextColor(), QColor(colorStrings.at(i))); + } + + { + QString colorStr = "#AA001234"; + QColor testColor("#001234"); + testColor.setAlpha(170); + + QString componentStr = "import QtQuick 2.0\nTextEdit { color: \"" + colorStr + "\"; text: \"Hello World\" }"; + QQmlComponent texteditComponent(&engine); + texteditComponent.setData(componentStr.toLatin1(), QUrl()); + QQuickTextEdit *textEditObject = qobject_cast(texteditComponent.create()); + + QVERIFY(textEditObject != 0); + QCOMPARE(textEditObject->color(), testColor); + } +} + +void tst_qquicktextedit::textMargin() +{ + for (qreal i=0; i<=10; i+=0.3) { + QString componentStr = "import QtQuick 2.0\nTextEdit { textMargin: " + QString::number(i) + "; text: \"Hello World\" }"; + QQmlComponent texteditComponent(&engine); + texteditComponent.setData(componentStr.toLatin1(), QUrl()); + QQuickTextEdit *textEditObject = qobject_cast(texteditComponent.create()); + QVERIFY(textEditObject != 0); + QCOMPARE(textEditObject->textMargin(), i); + } +} + +void tst_qquicktextedit::persistentSelection() +{ + QQuickView canvas(testFileUrl("persistentSelection.qml")); + canvas.show(); + canvas.requestActivateWindow(); + QTest::qWaitForWindowShown(&canvas); + QTRY_COMPARE(&canvas, qGuiApp->focusWindow()); + canvas.requestActivateWindow(); + + QQuickTextEdit *edit = qobject_cast(canvas.rootObject()); + QVERIFY(edit); + QVERIFY(edit->hasActiveFocus()); + + QSignalSpy spy(edit, SIGNAL(persistentSelectionChanged(bool))); + + QCOMPARE(edit->persistentSelection(), false); + + edit->setPersistentSelection(false); + QCOMPARE(edit->persistentSelection(), false); + QCOMPARE(spy.count(), 0); + + edit->select(1, 4); + QCOMPARE(edit->property("selected").toString(), QLatin1String("ell")); + + edit->setFocus(false); + QCOMPARE(edit->property("selected").toString(), QString()); + + edit->setFocus(true); + QCOMPARE(edit->property("selected").toString(), QString()); + + edit->setPersistentSelection(true); + QCOMPARE(edit->persistentSelection(), true); + QCOMPARE(spy.count(), 1); + + edit->select(1, 4); + QCOMPARE(edit->property("selected").toString(), QLatin1String("ell")); + + edit->setFocus(false); + QCOMPARE(edit->property("selected").toString(), QLatin1String("ell")); + + edit->setFocus(true); + QCOMPARE(edit->property("selected").toString(), QLatin1String("ell")); + +} + +void tst_qquicktextedit::focusOnPress() +{ + { + QString componentStr = "import QtQuick 2.0\nTextEdit { activeFocusOnPress: true; text: \"Hello World\" }"; + QQmlComponent texteditComponent(&engine); + texteditComponent.setData(componentStr.toLatin1(), QUrl()); + QQuickTextEdit *textEditObject = qobject_cast(texteditComponent.create()); + QVERIFY(textEditObject != 0); + QCOMPARE(textEditObject->focusOnPress(), true); + } + + { + QString componentStr = "import QtQuick 2.0\nTextEdit { activeFocusOnPress: false; text: \"Hello World\" }"; + QQmlComponent texteditComponent(&engine); + texteditComponent.setData(componentStr.toLatin1(), QUrl()); + QQuickTextEdit *textEditObject = qobject_cast(texteditComponent.create()); + QVERIFY(textEditObject != 0); + QCOMPARE(textEditObject->focusOnPress(), false); + } +} + +void tst_qquicktextedit::selection() +{ + QString testStr = standard[0];//TODO: What should happen for multiline/rich text? + QString componentStr = "import QtQuick 2.0\nTextEdit { text: \""+ testStr +"\"; }"; + QQmlComponent texteditComponent(&engine); + texteditComponent.setData(componentStr.toLatin1(), QUrl()); + QQuickTextEdit *textEditObject = qobject_cast(texteditComponent.create()); + QVERIFY(textEditObject != 0); + + + //Test selection follows cursor + for (int i=0; i<= testStr.size(); i++) { + textEditObject->setCursorPosition(i); + QCOMPARE(textEditObject->cursorPosition(), i); + QCOMPARE(textEditObject->selectionStart(), i); + QCOMPARE(textEditObject->selectionEnd(), i); + QVERIFY(textEditObject->selectedText().isNull()); + } + + textEditObject->setCursorPosition(0); + QVERIFY(textEditObject->cursorPosition() == 0); + QVERIFY(textEditObject->selectionStart() == 0); + QVERIFY(textEditObject->selectionEnd() == 0); + QVERIFY(textEditObject->selectedText().isNull()); + + // Verify invalid positions are ignored. + textEditObject->setCursorPosition(-1); + QVERIFY(textEditObject->cursorPosition() == 0); + QVERIFY(textEditObject->selectionStart() == 0); + QVERIFY(textEditObject->selectionEnd() == 0); + QVERIFY(textEditObject->selectedText().isNull()); + + textEditObject->setCursorPosition(textEditObject->text().count()+1); + QVERIFY(textEditObject->cursorPosition() == 0); + QVERIFY(textEditObject->selectionStart() == 0); + QVERIFY(textEditObject->selectionEnd() == 0); + QVERIFY(textEditObject->selectedText().isNull()); + + //Test selection + for (int i=0; i<= testStr.size(); i++) { + textEditObject->select(0,i); + QCOMPARE(testStr.mid(0,i), textEditObject->selectedText()); + } + for (int i=0; i<= testStr.size(); i++) { + textEditObject->select(i,testStr.size()); + QCOMPARE(testStr.mid(i,testStr.size()-i), textEditObject->selectedText()); + } + + textEditObject->setCursorPosition(0); + QVERIFY(textEditObject->cursorPosition() == 0); + QVERIFY(textEditObject->selectionStart() == 0); + QVERIFY(textEditObject->selectionEnd() == 0); + QVERIFY(textEditObject->selectedText().isNull()); + + //Test Error Ignoring behaviour + textEditObject->setCursorPosition(0); + QVERIFY(textEditObject->selectedText().isNull()); + textEditObject->select(-10,0); + QVERIFY(textEditObject->selectedText().isNull()); + textEditObject->select(100,101); + QVERIFY(textEditObject->selectedText().isNull()); + textEditObject->select(0,-10); + QVERIFY(textEditObject->selectedText().isNull()); + textEditObject->select(0,100); + QVERIFY(textEditObject->selectedText().isNull()); + textEditObject->select(0,10); + QVERIFY(textEditObject->selectedText().size() == 10); + textEditObject->select(-10,0); + QVERIFY(textEditObject->selectedText().size() == 10); + textEditObject->select(100,101); + QVERIFY(textEditObject->selectedText().size() == 10); + textEditObject->select(0,-10); + QVERIFY(textEditObject->selectedText().size() == 10); + textEditObject->select(0,100); + QVERIFY(textEditObject->selectedText().size() == 10); + + textEditObject->deselect(); + QVERIFY(textEditObject->selectedText().isNull()); + textEditObject->select(0,10); + QVERIFY(textEditObject->selectedText().size() == 10); + textEditObject->deselect(); + QVERIFY(textEditObject->selectedText().isNull()); +} + +void tst_qquicktextedit::isRightToLeft_data() +{ + QTest::addColumn("text"); + QTest::addColumn("emptyString"); + QTest::addColumn("firstCharacter"); + QTest::addColumn("lastCharacter"); + QTest::addColumn("middleCharacter"); + QTest::addColumn("startString"); + QTest::addColumn("midString"); + QTest::addColumn("endString"); + + const quint16 arabic_str[] = { 0x0638, 0x0643, 0x00646, 0x0647, 0x0633, 0x0638, 0x0643, 0x00646, 0x0647, 0x0633, 0x0647}; + QTest::newRow("Empty") << "" << false << false << false << false << false << false << false; + QTest::newRow("Neutral") << "23244242" << false << false << false << false << false << false << false; + QTest::newRow("LTR") << "Hello world" << false << false << false << false << false << false << false; + QTest::newRow("RTL") << QString::fromUtf16(arabic_str, 11) << false << true << true << true << true << true << true; + QTest::newRow("Bidi RTL + LTR + RTL") << QString::fromUtf16(arabic_str, 11) + QString("Hello world") + QString::fromUtf16(arabic_str, 11) << false << true << true << false << true << true << true; + QTest::newRow("Bidi LTR + RTL + LTR") << QString("Hello world") + QString::fromUtf16(arabic_str, 11) + QString("Hello world") << false << false << false << true << false << false << false; +} + +void tst_qquicktextedit::isRightToLeft() +{ + QFETCH(QString, text); + QFETCH(bool, emptyString); + QFETCH(bool, firstCharacter); + QFETCH(bool, lastCharacter); + QFETCH(bool, middleCharacter); + QFETCH(bool, startString); + QFETCH(bool, midString); + QFETCH(bool, endString); + + QQuickTextEdit textEdit; + textEdit.setText(text); + + // first test that the right string is delivered to the QString::isRightToLeft() + QCOMPARE(textEdit.isRightToLeft(0,0), text.mid(0,0).isRightToLeft()); + QCOMPARE(textEdit.isRightToLeft(0,1), text.mid(0,1).isRightToLeft()); + QCOMPARE(textEdit.isRightToLeft(text.count()-2, text.count()-1), text.mid(text.count()-2, text.count()-1).isRightToLeft()); + QCOMPARE(textEdit.isRightToLeft(text.count()/2, text.count()/2 + 1), text.mid(text.count()/2, text.count()/2 + 1).isRightToLeft()); + QCOMPARE(textEdit.isRightToLeft(0,text.count()/4), text.mid(0,text.count()/4).isRightToLeft()); + QCOMPARE(textEdit.isRightToLeft(text.count()/4,3*text.count()/4), text.mid(text.count()/4,3*text.count()/4).isRightToLeft()); + if (text.isEmpty()) + QTest::ignoreMessage(QtWarningMsg, ": QML TextEdit: isRightToLeft(start, end) called with the end property being smaller than the start."); + QCOMPARE(textEdit.isRightToLeft(3*text.count()/4,text.count()-1), text.mid(3*text.count()/4,text.count()-1).isRightToLeft()); + + // then test that the feature actually works + QCOMPARE(textEdit.isRightToLeft(0,0), emptyString); + QCOMPARE(textEdit.isRightToLeft(0,1), firstCharacter); + QCOMPARE(textEdit.isRightToLeft(text.count()-2, text.count()-1), lastCharacter); + QCOMPARE(textEdit.isRightToLeft(text.count()/2, text.count()/2 + 1), middleCharacter); + QCOMPARE(textEdit.isRightToLeft(0,text.count()/4), startString); + QCOMPARE(textEdit.isRightToLeft(text.count()/4,3*text.count()/4), midString); + if (text.isEmpty()) + QTest::ignoreMessage(QtWarningMsg, ": QML TextEdit: isRightToLeft(start, end) called with the end property being smaller than the start."); + QCOMPARE(textEdit.isRightToLeft(3*text.count()/4,text.count()-1), endString); +} + +void tst_qquicktextedit::keySelection() +{ + QQuickView canvas(testFileUrl("navigation.qml")); + canvas.show(); + canvas.requestActivateWindow(); + QTest::qWaitForWindowShown(&canvas); + QTRY_COMPARE(&canvas, qGuiApp->focusWindow()); + canvas.requestActivateWindow(); + + QVERIFY(canvas.rootObject() != 0); + + QQuickTextEdit *input = qobject_cast(qvariant_cast(canvas.rootObject()->property("myInput"))); + + QVERIFY(input != 0); + QTRY_VERIFY(input->hasActiveFocus() == true); + + QSignalSpy spy(input, SIGNAL(selectionChanged())); + + simulateKey(&canvas, Qt::Key_Right, Qt::ShiftModifier); + QVERIFY(input->hasActiveFocus() == true); + QCOMPARE(input->selectedText(), QString("a")); + QCOMPARE(spy.count(), 1); + simulateKey(&canvas, Qt::Key_Right); + QVERIFY(input->hasActiveFocus() == true); + QCOMPARE(input->selectedText(), QString()); + QCOMPARE(spy.count(), 2); + simulateKey(&canvas, Qt::Key_Right); + QVERIFY(input->hasActiveFocus() == false); + QCOMPARE(input->selectedText(), QString()); + QCOMPARE(spy.count(), 2); + + simulateKey(&canvas, Qt::Key_Left); + QVERIFY(input->hasActiveFocus() == true); + QCOMPARE(spy.count(), 2); + simulateKey(&canvas, Qt::Key_Left, Qt::ShiftModifier); + QVERIFY(input->hasActiveFocus() == true); + QCOMPARE(input->selectedText(), QString("a")); + QCOMPARE(spy.count(), 3); + simulateKey(&canvas, Qt::Key_Left); + QVERIFY(input->hasActiveFocus() == true); + QCOMPARE(input->selectedText(), QString()); + QCOMPARE(spy.count(), 4); + simulateKey(&canvas, Qt::Key_Left); + QVERIFY(input->hasActiveFocus() == false); + QCOMPARE(input->selectedText(), QString()); + QCOMPARE(spy.count(), 4); +} + +void tst_qquicktextedit::moveCursorSelection_data() +{ + QTest::addColumn("testStr"); + QTest::addColumn("cursorPosition"); + QTest::addColumn("movePosition"); + QTest::addColumn("mode"); + QTest::addColumn("selectionStart"); + QTest::addColumn("selectionEnd"); + QTest::addColumn("reversible"); + + QTest::newRow("(t)he|characters") + << standard[0] << 0 << 1 << QQuickTextEdit::SelectCharacters << 0 << 1 << true; + QTest::newRow("do(g)|characters") + << standard[0] << 43 << 44 << QQuickTextEdit::SelectCharacters << 43 << 44 << true; + QTest::newRow("jum(p)ed|characters") + << standard[0] << 23 << 24 << QQuickTextEdit::SelectCharacters << 23 << 24 << true; + QTest::newRow("jumped( )over|characters") + << standard[0] << 26 << 27 << QQuickTextEdit::SelectCharacters << 26 << 27 << true; + QTest::newRow("(the )|characters") + << standard[0] << 0 << 4 << QQuickTextEdit::SelectCharacters << 0 << 4 << true; + QTest::newRow("( dog)|characters") + << standard[0] << 40 << 44 << QQuickTextEdit::SelectCharacters << 40 << 44 << true; + QTest::newRow("( jumped )|characters") + << standard[0] << 19 << 27 << QQuickTextEdit::SelectCharacters << 19 << 27 << true; + QTest::newRow("th(e qu)ick|characters") + << standard[0] << 2 << 6 << QQuickTextEdit::SelectCharacters << 2 << 6 << true; + QTest::newRow("la(zy d)og|characters") + << standard[0] << 38 << 42 << QQuickTextEdit::SelectCharacters << 38 << 42 << true; + QTest::newRow("jum(ped ov)er|characters") + << standard[0] << 23 << 29 << QQuickTextEdit::SelectCharacters << 23 << 29 << true; + QTest::newRow("()the|characters") + << standard[0] << 0 << 0 << QQuickTextEdit::SelectCharacters << 0 << 0 << true; + QTest::newRow("dog()|characters") + << standard[0] << 44 << 44 << QQuickTextEdit::SelectCharacters << 44 << 44 << true; + QTest::newRow("jum()ped|characters") + << standard[0] << 23 << 23 << QQuickTextEdit::SelectCharacters << 23 << 23 << true; + + QTest::newRow("<(t)he>|words") + << standard[0] << 0 << 1 << QQuickTextEdit::SelectWords << 0 << 3 << true; + QTest::newRow("|words") + << standard[0] << 43 << 44 << QQuickTextEdit::SelectWords << 41 << 44 << true; + QTest::newRow("|words") + << standard[0] << 23 << 24 << QQuickTextEdit::SelectWords << 20 << 26 << true; + QTest::newRow("over|words") + << standard[0] << 26 << 27 << QQuickTextEdit::SelectWords << 20 << 27 << false; + QTest::newRow("jumped<( )over>|words,reversed") + << standard[0] << 27 << 26 << QQuickTextEdit::SelectWords << 26 << 31 << false; + QTest::newRow("<(the )>quick|words") + << standard[0] << 0 << 4 << QQuickTextEdit::SelectWords << 0 << 4 << false; + QTest::newRow("<(the )quick>|words,reversed") + << standard[0] << 4 << 0 << QQuickTextEdit::SelectWords << 0 << 9 << false; + QTest::newRow("|words") + << standard[0] << 40 << 44 << QQuickTextEdit::SelectWords << 36 << 44 << false; + QTest::newRow("lazy<( dog)>|words,reversed") + << standard[0] << 44 << 40 << QQuickTextEdit::SelectWords << 40 << 44 << false; + QTest::newRow("over|words") + << standard[0] << 19 << 27 << QQuickTextEdit::SelectWords << 16 << 27 << false; + QTest::newRow("fox<( jumped )over>|words,reversed") + << standard[0] << 27 << 19 << QQuickTextEdit::SelectWords << 19 << 31 << false; + QTest::newRow("|words") + << standard[0] << 2 << 6 << QQuickTextEdit::SelectWords << 0 << 9 << true; + QTest::newRow("") + << standard[0] << 38 << 42 << QQuickTextEdit::SelectWords << 36 << 44 << true; + QTest::newRow("|words") + << standard[0] << 23 << 29 << QQuickTextEdit::SelectWords << 20 << 31 << true; + QTest::newRow("<()>the|words") + << standard[0] << 0 << 0 << QQuickTextEdit::SelectWords << 0 << 0 << true; + QTest::newRow("dog<()>|words") + << standard[0] << 44 << 44 << QQuickTextEdit::SelectWords << 44 << 44 << true; + QTest::newRow("jum<()>ped|words") + << standard[0] << 23 << 23 << QQuickTextEdit::SelectWords << 23 << 23 << true; + + QTest::newRow("Hello<(,)> |words") + << standard[2] << 5 << 6 << QQuickTextEdit::SelectWords << 5 << 6 << true; + QTest::newRow("Hello<(, )>world|words") + << standard[2] << 5 << 7 << QQuickTextEdit::SelectWords << 5 << 7 << false; + QTest::newRow("Hello<(, )world>|words,reversed") + << standard[2] << 7 << 5 << QQuickTextEdit::SelectWords << 5 << 12 << false; + QTest::newRow("world|words") + << standard[2] << 3 << 7 << QQuickTextEdit::SelectWords << 0 << 7 << false; + QTest::newRow("|words,reversed") + << standard[2] << 7 << 3 << QQuickTextEdit::SelectWords << 0 << 12 << false; + QTest::newRow(",|words") + << standard[2] << 3 << 5 << QQuickTextEdit::SelectWords << 0 << 5 << true; + QTest::newRow("Hello<()>,|words") + << standard[2] << 5 << 5 << QQuickTextEdit::SelectWords << 5 << 5 << true; + QTest::newRow("Hello,<()>|words") + << standard[2] << 6 << 6 << QQuickTextEdit::SelectWords << 6 << 6 << true; + QTest::newRow("Hello<,( )>world|words") + << standard[2] << 6 << 7 << QQuickTextEdit::SelectWords << 5 << 7 << false; + QTest::newRow("Hello,<( )world>|words,reversed") + << standard[2] << 7 << 6 << QQuickTextEdit::SelectWords << 6 << 12 << false; + QTest::newRow("Hello<,( world)>|words") + << standard[2] << 6 << 12 << QQuickTextEdit::SelectWords << 5 << 12 << false; + QTest::newRow("Hello,<( world)>|words,reversed") + << standard[2] << 12 << 6 << QQuickTextEdit::SelectWords << 6 << 12 << false; + QTest::newRow("Hello<,( world!)>|words") + << standard[2] << 6 << 13 << QQuickTextEdit::SelectWords << 5 << 13 << false; + QTest::newRow("Hello,<( world!)>|words,reversed") + << standard[2] << 13 << 6 << QQuickTextEdit::SelectWords << 6 << 13 << false; + QTest::newRow("Hello<(, world!)>|words") + << standard[2] << 5 << 13 << QQuickTextEdit::SelectWords << 5 << 13 << true; + QTest::newRow("world<(!)>|words") + << standard[2] << 12 << 13 << QQuickTextEdit::SelectWords << 12 << 13 << true; + QTest::newRow("world!<()>)|words") + << standard[2] << 13 << 13 << QQuickTextEdit::SelectWords << 13 << 13 << true; + QTest::newRow("world<()>!)|words") + << standard[2] << 12 << 12 << QQuickTextEdit::SelectWords << 12 << 12 << true; + + QTest::newRow("<(,)>olleH |words") + << standard[3] << 7 << 8 << QQuickTextEdit::SelectWords << 7 << 8 << true; + QTest::newRow("olleH|words") + << standard[3] << 6 << 8 << QQuickTextEdit::SelectWords << 1 << 8 << false; + QTest::newRow("dlrow<( ,)>olleH|words,reversed") + << standard[3] << 8 << 6 << QQuickTextEdit::SelectWords << 6 << 8 << false; + QTest::newRow("|words") + << standard[3] << 6 << 10 << QQuickTextEdit::SelectWords << 1 << 13 << false; + QTest::newRow("dlrow<( ,ol)leH>|words,reversed") + << standard[3] << 10 << 6 << QQuickTextEdit::SelectWords << 6 << 13 << false; + QTest::newRow(",<(ol)leH>,|words") + << standard[3] << 8 << 10 << QQuickTextEdit::SelectWords << 8 << 13 << true; + QTest::newRow(",<()>olleH|words") + << standard[3] << 8 << 8 << QQuickTextEdit::SelectWords << 8 << 8 << true; + QTest::newRow("<()>,olleH|words") + << standard[3] << 7 << 7 << QQuickTextEdit::SelectWords << 7 << 7 << true; + QTest::newRow(",olleH|words") + << standard[3] << 6 << 7 << QQuickTextEdit::SelectWords << 1 << 7 << false; + QTest::newRow("dlrow<( ),>olleH|words,reversed") + << standard[3] << 7 << 6 << QQuickTextEdit::SelectWords << 6 << 8 << false; + QTest::newRow("<(dlrow )>,olleH|words") + << standard[3] << 1 << 7 << QQuickTextEdit::SelectWords << 1 << 7 << false; + QTest::newRow("<(dlrow ),>olleH|words,reversed") + << standard[3] << 7 << 1 << QQuickTextEdit::SelectWords << 1 << 8 << false; + QTest::newRow("<(!dlrow )>,olleH|words") + << standard[3] << 0 << 7 << QQuickTextEdit::SelectWords << 0 << 7 << false; + QTest::newRow("<(!dlrow ),>olleH|words,reversed") + << standard[3] << 7 << 0 << QQuickTextEdit::SelectWords << 0 << 8 << false; + QTest::newRow("(!dlrow ,)olleH|words") + << standard[3] << 0 << 8 << QQuickTextEdit::SelectWords << 0 << 8 << true; + QTest::newRow("<(!)>dlrow|words") + << standard[3] << 0 << 1 << QQuickTextEdit::SelectWords << 0 << 1 << true; + QTest::newRow("<()>!dlrow|words") + << standard[3] << 0 << 0 << QQuickTextEdit::SelectWords << 0 << 0 << true; + QTest::newRow("!<()>dlrow|words") + << standard[3] << 1 << 1 << QQuickTextEdit::SelectWords << 1 << 1 << true; +} + +void tst_qquicktextedit::moveCursorSelection() +{ + QFETCH(QString, testStr); + QFETCH(int, cursorPosition); + QFETCH(int, movePosition); + QFETCH(QQuickTextEdit::SelectionMode, mode); + QFETCH(int, selectionStart); + QFETCH(int, selectionEnd); + QFETCH(bool, reversible); + + QString componentStr = "import QtQuick 2.0\nTextEdit { text: \""+ testStr +"\"; }"; + QQmlComponent textinputComponent(&engine); + textinputComponent.setData(componentStr.toLatin1(), QUrl()); + QQuickTextEdit *texteditObject = qobject_cast(textinputComponent.create()); + QVERIFY(texteditObject != 0); + + texteditObject->setCursorPosition(cursorPosition); + texteditObject->moveCursorSelection(movePosition, mode); + + QCOMPARE(texteditObject->selectedText(), testStr.mid(selectionStart, selectionEnd - selectionStart)); + QCOMPARE(texteditObject->selectionStart(), selectionStart); + QCOMPARE(texteditObject->selectionEnd(), selectionEnd); + + if (reversible) { + texteditObject->setCursorPosition(movePosition); + texteditObject->moveCursorSelection(cursorPosition, mode); + + QCOMPARE(texteditObject->selectedText(), testStr.mid(selectionStart, selectionEnd - selectionStart)); + QCOMPARE(texteditObject->selectionStart(), selectionStart); + QCOMPARE(texteditObject->selectionEnd(), selectionEnd); + } +} + +void tst_qquicktextedit::moveCursorSelectionSequence_data() +{ + QTest::addColumn("testStr"); + QTest::addColumn("cursorPosition"); + QTest::addColumn("movePosition1"); + QTest::addColumn("movePosition2"); + QTest::addColumn("selection1Start"); + QTest::addColumn("selection1End"); + QTest::addColumn("selection2Start"); + QTest::addColumn("selection2End"); + + QTest::newRow("the { f^ox} jumped|ltr") + << standard[0] + << 9 << 13 << 17 + << 4 << 15 + << 4 << 19; + QTest::newRow("the quick<( {bro)wn> f^ox} jumped|rtl") + << standard[0] + << 13 << 9 << 17 + << 9 << 15 + << 10 << 19; + QTest::newRow("the { ^}fox jumped|ltr") + << standard[0] + << 9 << 13 << 16 + << 4 << 15 + << 4 << 16; + QTest::newRow("the quick<( {bro)wn> ^}fox jumped|rtl") + << standard[0] + << 13 << 9 << 16 + << 9 << 15 + << 10 << 16; + QTest::newRow("the {} fox jumped|ltr") + << standard[0] + << 9 << 13 << 15 + << 4 << 15 + << 4 << 15; + QTest::newRow("the quick<( {bro)wn^>} f^ox jumped|rtl") + << standard[0] + << 13 << 9 << 15 + << 9 << 15 + << 10 << 15; + QTest::newRow("the { fox|ltr") + << standard[0] + << 9 << 13 << 10 + << 4 << 15 + << 4 << 10; + QTest::newRow("the quick<(^ {^bro)wn>} fox|rtl") + << standard[0] + << 13 << 9 << 10 + << 9 << 15 + << 10 << 15; + QTest::newRow("the { fox|ltr") + << standard[0] + << 9 << 13 << 9 + << 4 << 15 + << 4 << 9; + QTest::newRow("the quick{<(^ bro)wn>} fox|rtl") + << standard[0] + << 13 << 9 << 9 + << 9 << 15 + << 9 << 15; + QTest::newRow("the { fox|ltr") + << standard[0] + << 9 << 13 << 7 + << 4 << 15 + << 4 << 9; + QTest::newRow("the { fox|rtl") + << standard[0] + << 13 << 9 << 7 + << 9 << 15 + << 4 << 15; + QTest::newRow("the {<^quick}( bro)wn> fox|ltr") + << standard[0] + << 9 << 13 << 4 + << 4 << 15 + << 4 << 9; + QTest::newRow("the {<^quick}( bro)wn> fox|rtl") + << standard[0] + << 13 << 9 << 4 + << 9 << 15 + << 4 << 15; + QTest::newRow("the{^ fox|ltr") + << standard[0] + << 9 << 13 << 3 + << 4 << 15 + << 3 << 9; + QTest::newRow("the{^ fox|rtl") + << standard[0] + << 13 << 9 << 3 + << 9 << 15 + << 3 << 15; + QTest::newRow("{t^he fox|ltr") + << standard[0] + << 9 << 13 << 1 + << 4 << 15 + << 0 << 9; + QTest::newRow("{t^he fox|rtl") + << standard[0] + << 13 << 9 << 1 + << 9 << 15 + << 0 << 15; + + QTest::newRow("{, w^orld}!|ltr") + << standard[2] + << 2 << 4 << 8 + << 0 << 5 + << 0 << 12; + QTest::newRow("{, w^orld}!|rtl") + << standard[2] + << 4 << 2 << 8 + << 0 << 5 + << 0 << 12; + + QTest::newRow("!{dlro^w ,}|ltr") + << standard[3] + << 9 << 11 << 5 + << 8 << 13 + << 1 << 13; + QTest::newRow("!{dlro^w ,}|rtl") + << standard[3] + << 11 << 9 << 5 + << 8 << 13 + << 1 << 13; +} + +void tst_qquicktextedit::moveCursorSelectionSequence() +{ + QFETCH(QString, testStr); + QFETCH(int, cursorPosition); + QFETCH(int, movePosition1); + QFETCH(int, movePosition2); + QFETCH(int, selection1Start); + QFETCH(int, selection1End); + QFETCH(int, selection2Start); + QFETCH(int, selection2End); + + QString componentStr = "import QtQuick 2.0\nTextEdit { text: \""+ testStr +"\"; }"; + QQmlComponent texteditComponent(&engine); + texteditComponent.setData(componentStr.toLatin1(), QUrl()); + QQuickTextEdit *texteditObject = qobject_cast(texteditComponent.create()); + QVERIFY(texteditObject != 0); + + texteditObject->setCursorPosition(cursorPosition); + + texteditObject->moveCursorSelection(movePosition1, QQuickTextEdit::SelectWords); + QCOMPARE(texteditObject->selectedText(), testStr.mid(selection1Start, selection1End - selection1Start)); + QCOMPARE(texteditObject->selectionStart(), selection1Start); + QCOMPARE(texteditObject->selectionEnd(), selection1End); + + texteditObject->moveCursorSelection(movePosition2, QQuickTextEdit::SelectWords); + QCOMPARE(texteditObject->selectedText(), testStr.mid(selection2Start, selection2End - selection2Start)); + QCOMPARE(texteditObject->selectionStart(), selection2Start); + QCOMPARE(texteditObject->selectionEnd(), selection2End); +} + + +void tst_qquicktextedit::mouseSelection_data() +{ + QTest::addColumn("qmlfile"); + QTest::addColumn("from"); + QTest::addColumn("to"); + QTest::addColumn("selectedText"); + + // import installed + QTest::newRow("on") << testFile("mouseselection_true.qml") << 4 << 9 << "45678"; + QTest::newRow("off") << testFile("mouseselection_false.qml") << 4 << 9 << QString(); + QTest::newRow("default") << testFile("mouseselection_default.qml") << 4 << 9 << QString(); + QTest::newRow("off word selection") << testFile("mouseselection_false_words.qml") << 4 << 9 << QString(); + QTest::newRow("on word selection (4,9)") << testFile("mouseselection_true_words.qml") << 4 << 9 << "0123456789"; + QTest::newRow("on word selection (2,13)") << testFile("mouseselection_true_words.qml") << 2 << 13 << "0123456789 ABCDEFGHIJKLMNOPQRSTUVWXYZ"; + QTest::newRow("on word selection (2,30)") << testFile("mouseselection_true_words.qml") << 2 << 30 << "0123456789 ABCDEFGHIJKLMNOPQRSTUVWXYZ"; + QTest::newRow("on word selection (9,13)") << testFile("mouseselection_true_words.qml") << 9 << 13 << "0123456789 ABCDEFGHIJKLMNOPQRSTUVWXYZ"; + QTest::newRow("on word selection (9,30)") << testFile("mouseselection_true_words.qml") << 9 << 30 << "0123456789 ABCDEFGHIJKLMNOPQRSTUVWXYZ"; + QTest::newRow("on word selection (13,2)") << testFile("mouseselection_true_words.qml") << 13 << 2 << "0123456789 ABCDEFGHIJKLMNOPQRSTUVWXYZ"; + QTest::newRow("on word selection (20,2)") << testFile("mouseselection_true_words.qml") << 20 << 2 << "0123456789 ABCDEFGHIJKLMNOPQRSTUVWXYZ"; + QTest::newRow("on word selection (12,9)") << testFile("mouseselection_true_words.qml") << 12 << 9 << "0123456789 ABCDEFGHIJKLMNOPQRSTUVWXYZ"; + QTest::newRow("on word selection (30,9)") << testFile("mouseselection_true_words.qml") << 30 << 9 << "0123456789 ABCDEFGHIJKLMNOPQRSTUVWXYZ"; +} + +void tst_qquicktextedit::mouseSelection() +{ + QFETCH(QString, qmlfile); + QFETCH(int, from); + QFETCH(int, to); + QFETCH(QString, selectedText); + + QQuickView canvas(QUrl::fromLocalFile(qmlfile)); + + canvas.show(); + canvas.requestActivateWindow(); + QTest::qWaitForWindowShown(&canvas); + QTRY_COMPARE(&canvas, qGuiApp->focusWindow()); + + QVERIFY(canvas.rootObject() != 0); + QQuickTextEdit *textEditObject = qobject_cast(canvas.rootObject()); + QVERIFY(textEditObject != 0); + + // press-and-drag-and-release from x1 to x2 + QPoint p1 = textEditObject->positionToRectangle(from).center().toPoint(); + QPoint p2 = textEditObject->positionToRectangle(to).center().toPoint(); + QTest::mousePress(&canvas, Qt::LeftButton, 0, p1); + QTest::mouseMove(&canvas, p2); + QTest::mouseRelease(&canvas, Qt::LeftButton, 0, p2); + QTest::qWait(50); + QTRY_COMPARE(textEditObject->selectedText(), selectedText); + + // Clicking and shift to clicking between the same points should select the same text. + textEditObject->setCursorPosition(0); + QTest::mouseClick(&canvas, Qt::LeftButton, Qt::NoModifier, p1); + QTest::mouseClick(&canvas, Qt::LeftButton, Qt::ShiftModifier, p2); + QTest::qWait(50); + QTRY_COMPARE(textEditObject->selectedText(), selectedText); +} + +void tst_qquicktextedit::dragMouseSelection() +{ + QString qmlfile = testFile("mouseselection_true.qml"); + + QQuickView canvas(QUrl::fromLocalFile(qmlfile)); + + canvas.show(); + canvas.requestActivateWindow(); + QTest::qWaitForWindowShown(&canvas); + QTRY_COMPARE(&canvas, qGuiApp->focusWindow()); + + QVERIFY(canvas.rootObject() != 0); + QQuickTextEdit *textEditObject = qobject_cast(canvas.rootObject()); + QVERIFY(textEditObject != 0); + + // press-and-drag-and-release from x1 to x2 + int x1 = 10; + int x2 = 70; + int y = textEditObject->height()/2; + QTest::mousePress(&canvas, Qt::LeftButton, 0, QPoint(x1,y)); + QTest::mouseMove(&canvas, QPoint(x2, y)); + QTest::mouseRelease(&canvas, Qt::LeftButton, 0, QPoint(x2,y)); + QTest::qWait(300); + QString str1; + QTRY_VERIFY((str1 = textEditObject->selectedText()).length() > 3); + + // press and drag the current selection. + x1 = 40; + x2 = 100; + QTest::mousePress(&canvas, Qt::LeftButton, 0, QPoint(x1,y)); + QTest::mouseMove(&canvas, QPoint(x2, y)); + QTest::mouseRelease(&canvas, Qt::LeftButton, 0, QPoint(x2,y)); + QTest::qWait(300); + QString str2; + QTRY_VERIFY((str2 = textEditObject->selectedText()).length() > 3); + + QVERIFY(str1 != str2); // Verify the second press and drag is a new selection and not the first moved. +} + +void tst_qquicktextedit::mouseSelectionMode_data() +{ + QTest::addColumn("qmlfile"); + QTest::addColumn("selectWords"); + + // import installed + QTest::newRow("SelectWords") << testFile("mouseselectionmode_words.qml") << true; + QTest::newRow("SelectCharacters") << testFile("mouseselectionmode_characters.qml") << false; + QTest::newRow("default") << testFile("mouseselectionmode_default.qml") << false; +} + +void tst_qquicktextedit::mouseSelectionMode() +{ + QFETCH(QString, qmlfile); + QFETCH(bool, selectWords); + + QString text = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"; + + QQuickView canvas(QUrl::fromLocalFile(qmlfile)); + + canvas.show(); + canvas.requestActivateWindow(); + QTest::qWaitForWindowShown(&canvas); + QTRY_COMPARE(&canvas, qGuiApp->focusWindow()); + + QVERIFY(canvas.rootObject() != 0); + QQuickTextEdit *textEditObject = qobject_cast(canvas.rootObject()); + QVERIFY(textEditObject != 0); + + // press-and-drag-and-release from x1 to x2 + int x1 = 10; + int x2 = 70; + int y = textEditObject->height()/2; + QTest::mousePress(&canvas, Qt::LeftButton, 0, QPoint(x1,y)); + QTest::mouseMove(&canvas, QPoint(x2, y)); + //QTest::mouseMove(canvas, QPoint(x2,y)); // doesn't work +// QMouseEvent mv(QEvent::MouseMove, QPoint(x2,y), Qt::LeftButton, Qt::LeftButton,Qt::NoModifier); +// QGuiApplication::sendEvent(&canvas, &mv); + QTest::mouseRelease(&canvas, Qt::LeftButton, 0, QPoint(x2,y)); + QString str = textEditObject->selectedText(); + if (selectWords) { + QTRY_COMPARE(textEditObject->selectedText(), text); + } else { + QTRY_VERIFY(textEditObject->selectedText().length() > 3); + QVERIFY(str != text); + } +} + +void tst_qquicktextedit::inputMethodHints() +{ + QQuickView canvas(testFileUrl("inputmethodhints.qml")); + canvas.show(); + canvas.requestActivateWindow(); + + QVERIFY(canvas.rootObject() != 0); + QQuickTextEdit *textEditObject = qobject_cast(canvas.rootObject()); + QVERIFY(textEditObject != 0); + QVERIFY(textEditObject->inputMethodHints() & Qt::ImhNoPredictiveText); + QSignalSpy inputMethodHintSpy(textEditObject, SIGNAL(inputMethodHintsChanged())); + textEditObject->setInputMethodHints(Qt::ImhUppercaseOnly); + QVERIFY(textEditObject->inputMethodHints() & Qt::ImhUppercaseOnly); + QCOMPARE(inputMethodHintSpy.count(), 1); + textEditObject->setInputMethodHints(Qt::ImhUppercaseOnly); + QCOMPARE(inputMethodHintSpy.count(), 1); + + QQuickTextEdit plainTextEdit; + QCOMPARE(plainTextEdit.inputMethodHints(), Qt::ImhNone); +} + +void tst_qquicktextedit::positionAt() +{ + QQuickView canvas(testFileUrl("positionAt.qml")); + QVERIFY(canvas.rootObject() != 0); + canvas.show(); + canvas.requestActivateWindow(); + canvas.requestActivateWindow(); + QTest::qWaitForWindowShown(&canvas); + + QQuickTextEdit *texteditObject = qobject_cast(canvas.rootObject()); + QVERIFY(texteditObject != 0); + + QTextLayout layout(texteditObject->text()); + layout.setFont(texteditObject->font()); + + if (!qmlDisableDistanceField()) { + QTextOption option; + option.setUseDesignMetrics(true); + layout.setTextOption(option); + } + + layout.beginLayout(); + QTextLine line = layout.createLine(); + layout.endLayout(); + + const int y0 = line.height() / 2; + const int y1 = line.height() * 3 / 2; + + int pos = texteditObject->positionAt(texteditObject->width()/2, y0); + + int widthBegin = floor(line.cursorToX(pos - 1)); + int widthEnd = ceil(line.cursorToX(pos + 1)); + + QVERIFY(widthBegin <= texteditObject->width() / 2); + QVERIFY(widthEnd >= texteditObject->width() / 2); + + const qreal x0 = texteditObject->positionToRectangle(pos).x(); + const qreal x1 = texteditObject->positionToRectangle(pos + 1).x(); + + QString preeditText = texteditObject->text().mid(0, pos); + texteditObject->setText(texteditObject->text().mid(pos)); + texteditObject->setCursorPosition(0); + + QInputMethodEvent inputEvent(preeditText, QList()); + QGuiApplication::sendEvent(qGuiApp->focusObject(), &inputEvent); + + // Check all points within the preedit text return the same position. + QCOMPARE(texteditObject->positionAt(0, y0), 0); + QCOMPARE(texteditObject->positionAt(x0 / 2, y0), 0); + QCOMPARE(texteditObject->positionAt(x0, y0), 0); + + // Verify positioning returns to normal after the preedit text. + QCOMPARE(texteditObject->positionAt(x1, y0), 1); + QCOMPARE(texteditObject->positionToRectangle(1).x(), x1); + + QVERIFY(texteditObject->positionAt(x0 / 2, y1) > 0); +} + +void tst_qquicktextedit::linkActivated() +{ + QQuickView canvas(testFileUrl("linkActivated.qml")); + QVERIFY(canvas.rootObject() != 0); + canvas.show(); + canvas.requestActivateWindow(); + QTest::qWaitForWindowShown(&canvas); + + QQuickTextEdit *texteditObject = qobject_cast(canvas.rootObject()); + QVERIFY(texteditObject != 0); + + QSignalSpy spy(texteditObject, SIGNAL(linkActivated(QString))); + + const QString link("http://example.com/"); + + const QPointF linkPos = texteditObject->positionToRectangle(7).center(); + const QPointF textPos = texteditObject->positionToRectangle(2).center(); + + QTest::mouseClick(&canvas, Qt::LeftButton, 0, linkPos.toPoint()); + QTRY_COMPARE(spy.count(), 1); + QCOMPARE(spy.last()[0].toString(), link); + + QTest::mouseClick(&canvas, Qt::LeftButton, 0, textPos.toPoint()); + QTest::qWait(50); + QCOMPARE(spy.count(), 1); + + texteditObject->setReadOnly(true); + + QTest::mouseClick(&canvas, Qt::LeftButton, 0, linkPos.toPoint()); + QTRY_COMPARE(spy.count(), 2); + QCOMPARE(spy.last()[0].toString(), link); + + QTest::mouseClick(&canvas, Qt::LeftButton, 0, textPos.toPoint()); + QTest::qWait(50); + QCOMPARE(spy.count(), 2); +} + +void tst_qquicktextedit::cursorDelegate_data() +{ + QTest::addColumn("source"); + QTest::newRow("out of line") << testFileUrl("cursorTest.qml"); + QTest::newRow("in line") << testFileUrl("cursorTestInline.qml"); + QTest::newRow("external") << testFileUrl("cursorTestExternal.qml"); +} + +void tst_qquicktextedit::cursorDelegate() +{ + QFETCH(QUrl, source); + QQuickView view(source); + view.show(); + view.requestActivateWindow(); + QQuickTextEdit *textEditObject = view.rootObject()->findChild("textEditObject"); + QVERIFY(textEditObject != 0); + QVERIFY(textEditObject->findChild("cursorInstance")); + //Test Delegate gets created + textEditObject->setFocus(true); + QQuickItem* delegateObject = textEditObject->findChild("cursorInstance"); + QVERIFY(delegateObject); + QCOMPARE(delegateObject->property("localProperty").toString(), QString("Hello")); + //Test Delegate gets moved + for (int i=0; i<= textEditObject->text().length(); i++) { + textEditObject->setCursorPosition(i); + QCOMPARE(textEditObject->cursorRectangle().x(), qRound(delegateObject->x())); + QCOMPARE(textEditObject->cursorRectangle().y(), qRound(delegateObject->y())); + } + // Clear preedit text; + QInputMethodEvent event; + QGuiApplication::sendEvent(&view, &event); + + + // Test delegate gets moved on mouse press. + textEditObject->setSelectByMouse(true); + textEditObject->setCursorPosition(0); + const QPoint point1 = textEditObject->positionToRectangle(5).center().toPoint(); + QTest::mouseClick(&view, Qt::LeftButton, 0, point1); + QTest::qWait(50); + QTRY_VERIFY(textEditObject->cursorPosition() != 0); + QCOMPARE(textEditObject->cursorRectangle().x(), qRound(delegateObject->x())); + QCOMPARE(textEditObject->cursorRectangle().y(), qRound(delegateObject->y())); + + // Test delegate gets moved on mouse drag + textEditObject->setCursorPosition(0); + const QPoint point2 = textEditObject->positionToRectangle(10).center().toPoint(); + QTest::mousePress(&view, Qt::LeftButton, 0, point1); + QMouseEvent mv(QEvent::MouseMove, point2, Qt::LeftButton, Qt::LeftButton,Qt::NoModifier); + QGuiApplication::sendEvent(&view, &mv); + QTest::mouseRelease(&view, Qt::LeftButton, 0, point2); + QTest::qWait(50); + QTRY_COMPARE(textEditObject->cursorRectangle().x(), qRound(delegateObject->x())); + QCOMPARE(textEditObject->cursorRectangle().y(), qRound(delegateObject->y())); + + textEditObject->setReadOnly(true); + textEditObject->setCursorPosition(0); + QTest::mouseClick(&view, Qt::LeftButton, 0, textEditObject->positionToRectangle(5).center().toPoint()); + QTest::qWait(50); + QTRY_VERIFY(textEditObject->cursorPosition() != 0); + QCOMPARE(textEditObject->cursorRectangle().x(), qRound(delegateObject->x())); + QCOMPARE(textEditObject->cursorRectangle().y(), qRound(delegateObject->y())); + + textEditObject->setCursorPosition(0); + QTest::mouseClick(&view, Qt::LeftButton, 0, textEditObject->positionToRectangle(5).center().toPoint()); + QTest::qWait(50); + QTRY_VERIFY(textEditObject->cursorPosition() != 0); + QCOMPARE(textEditObject->cursorRectangle().x(), qRound(delegateObject->x())); + QCOMPARE(textEditObject->cursorRectangle().y(), qRound(delegateObject->y())); + + textEditObject->setCursorPosition(0); + QCOMPARE(textEditObject->cursorRectangle().x(), qRound(delegateObject->x())); + QCOMPARE(textEditObject->cursorRectangle().y(), qRound(delegateObject->y())); + //Test Delegate gets deleted + textEditObject->setCursorDelegate(0); + QVERIFY(!textEditObject->findChild("cursorInstance")); +} + +void tst_qquicktextedit::cursorVisible() +{ + QQuickView view(testFileUrl("cursorVisible.qml")); + view.show(); + view.requestActivateWindow(); + QTest::qWaitForWindowShown(&view); + QTRY_COMPARE(&view, qGuiApp->focusWindow()); + + QQuickTextEdit edit; + QSignalSpy spy(&edit, SIGNAL(cursorVisibleChanged(bool))); + + QCOMPARE(edit.isCursorVisible(), false); + + edit.setCursorVisible(true); + QCOMPARE(edit.isCursorVisible(), true); + QCOMPARE(spy.count(), 1); + + edit.setCursorVisible(false); + QCOMPARE(edit.isCursorVisible(), false); + QCOMPARE(spy.count(), 2); + + edit.setFocus(true); + QCOMPARE(edit.isCursorVisible(), false); + QCOMPARE(spy.count(), 2); + + edit.setParentItem(view.rootObject()); + QCOMPARE(edit.isCursorVisible(), true); + QCOMPARE(spy.count(), 3); + + edit.setFocus(false); + QCOMPARE(edit.isCursorVisible(), false); + QCOMPARE(spy.count(), 4); + + edit.setFocus(true); + QCOMPARE(edit.isCursorVisible(), true); + QCOMPARE(spy.count(), 5); + + QQuickView alternateView; + alternateView.show(); + alternateView.requestActivateWindow(); + QTest::qWaitForWindowShown(&alternateView); + + QCOMPARE(edit.isCursorVisible(), false); + QCOMPARE(spy.count(), 6); + + view.requestActivateWindow(); + QTest::qWaitForWindowShown(&view); + QCOMPARE(edit.isCursorVisible(), true); + QCOMPARE(spy.count(), 7); +} + +void tst_qquicktextedit::delegateLoading_data() +{ + QTest::addColumn("qmlfile"); + QTest::addColumn("error"); + + // import installed + QTest::newRow("pass") << "cursorHttpTestPass.qml" << ""; + QTest::newRow("fail1") << "cursorHttpTestFail1.qml" << "http://localhost:42332/FailItem.qml: Remote host closed the connection "; + QTest::newRow("fail2") << "cursorHttpTestFail2.qml" << "http://localhost:42332/ErrItem.qml:4:5: Fungus is not a type "; +} + +void tst_qquicktextedit::delegateLoading() +{ +#ifdef Q_OS_MAC + QSKIP("Test crashes during canvas tear down. QTBUG-23010"); +#endif + QFETCH(QString, qmlfile); + QFETCH(QString, error); + + TestHTTPServer server(42332); + server.serveDirectory(testFile("httpfail"), TestHTTPServer::Disconnect); + server.serveDirectory(testFile("httpslow"), TestHTTPServer::Delay); + server.serveDirectory(testFile("http")); + + QQuickView view(QUrl(QLatin1String("http://localhost:42332/") + qmlfile)); + view.show(); + view.requestActivateWindow(); + + if (!error.isEmpty()) { + QTest::ignoreMessage(QtWarningMsg, error.toUtf8()); + QTRY_VERIFY(view.status()==QQuickView::Error); + QTRY_VERIFY(!view.rootObject()); // there is fail item inside this test + } else { + QTRY_VERIFY(view.rootObject());//Wait for loading to finish. + QQuickTextEdit *textEditObject = view.rootObject()->findChild("textEditObject"); + // view.rootObject()->dumpObjectTree(); + QVERIFY(textEditObject != 0); + textEditObject->setFocus(true); + QQuickItem *delegate; + delegate = view.rootObject()->findChild("delegateOkay"); + QVERIFY(delegate); + delegate = view.rootObject()->findChild("delegateSlow"); + QVERIFY(delegate); + + delete delegate; + } + + + //A test should be added here with a component which is ready but component.create() returns null + //Not sure how to accomplish this with QQuickTextEdits cursor delegate + //###This was only needed for code coverage, and could be a case of overzealous defensive programming + //delegate = view.rootObject()->findChild("delegateErrorB"); + //QVERIFY(!delegate); +} + +/* +TextEdit element should only handle left/right keys until the cursor reaches +the extent of the text, then they should ignore the keys. +*/ +void tst_qquicktextedit::navigation() +{ + QQuickView canvas(testFileUrl("navigation.qml")); + canvas.show(); + canvas.requestActivateWindow(); + + QVERIFY(canvas.rootObject() != 0); + + QQuickItem *input = qobject_cast(qvariant_cast(canvas.rootObject()->property("myInput"))); + + QVERIFY(input != 0); + QTRY_VERIFY(input->hasActiveFocus() == true); + simulateKey(&canvas, Qt::Key_Left); + QVERIFY(input->hasActiveFocus() == false); + simulateKey(&canvas, Qt::Key_Right); + QVERIFY(input->hasActiveFocus() == true); + simulateKey(&canvas, Qt::Key_Right); + QVERIFY(input->hasActiveFocus() == true); + simulateKey(&canvas, Qt::Key_Right); + QVERIFY(input->hasActiveFocus() == false); + simulateKey(&canvas, Qt::Key_Left); + QVERIFY(input->hasActiveFocus() == true); +} + +void tst_qquicktextedit::copyAndPaste() { +#ifndef QT_NO_CLIPBOARD + +#ifdef Q_OS_MAC + { + PasteboardRef pasteboard; + OSStatus status = PasteboardCreate(0, &pasteboard); + if (status == noErr) + CFRelease(pasteboard); + else + QSKIP("This machine doesn't support the clipboard"); + } +#endif + + QString componentStr = "import QtQuick 2.0\nTextEdit { text: \"Hello world!\" }"; + QQmlComponent textEditComponent(&engine); + textEditComponent.setData(componentStr.toLatin1(), QUrl()); + QQuickTextEdit *textEdit = qobject_cast(textEditComponent.create()); + QVERIFY(textEdit != 0); + + // copy and paste + QCOMPARE(textEdit->text().length(), 12); + textEdit->select(0, textEdit->text().length());; + textEdit->copy(); + QCOMPARE(textEdit->selectedText(), QString("Hello world!")); + QCOMPARE(textEdit->selectedText().length(), 12); + textEdit->setCursorPosition(0); + QVERIFY(textEdit->canPaste()); + textEdit->paste(); + QCOMPARE(textEdit->text(), QString("Hello world!Hello world!")); + QCOMPARE(textEdit->text().length(), 24); + + // canPaste + QVERIFY(textEdit->canPaste()); + textEdit->setReadOnly(true); + QVERIFY(!textEdit->canPaste()); + textEdit->setReadOnly(false); + QVERIFY(textEdit->canPaste()); + + // QTBUG-12339 + // test that document and internal text attribute are in sync + QQuickItemPrivate* pri = QQuickItemPrivate::get(textEdit); + QQuickTextEditPrivate *editPrivate = static_cast(pri); + QCOMPARE(textEdit->text(), editPrivate->text); + + // select word + textEdit->setCursorPosition(0); + textEdit->selectWord(); + QCOMPARE(textEdit->selectedText(), QString("Hello")); + + // select all and cut + textEdit->selectAll(); + textEdit->cut(); + QCOMPARE(textEdit->text().length(), 0); + textEdit->paste(); + QCOMPARE(textEdit->text(), QString("Hello world!Hello world!")); + QCOMPARE(textEdit->text().length(), 24); +#endif +} + +void tst_qquicktextedit::canPaste() { +#ifndef QT_NO_CLIPBOARD + + QGuiApplication::clipboard()->setText("Some text"); + + QString componentStr = "import QtQuick 2.0\nTextEdit { text: \"Hello world!\" }"; + QQmlComponent textEditComponent(&engine); + textEditComponent.setData(componentStr.toLatin1(), QUrl()); + QQuickTextEdit *textEdit = qobject_cast(textEditComponent.create()); + QVERIFY(textEdit != 0); + + // check initial value - QTBUG-17765 + QQuickTextControl tc(0); + QCOMPARE(textEdit->canPaste(), tc.canPaste()); + +#endif +} + +void tst_qquicktextedit::canPasteEmpty() { +#ifndef QT_NO_CLIPBOARD + + QGuiApplication::clipboard()->clear(); + + QString componentStr = "import QtQuick 2.0\nTextEdit { text: \"Hello world!\" }"; + QQmlComponent textEditComponent(&engine); + textEditComponent.setData(componentStr.toLatin1(), QUrl()); + QQuickTextEdit *textEdit = qobject_cast(textEditComponent.create()); + QVERIFY(textEdit != 0); + + // check initial value - QTBUG-17765 + QQuickTextControl tc(0); + QCOMPARE(textEdit->canPaste(), tc.canPaste()); + +#endif +} + +void tst_qquicktextedit::readOnly() +{ + QQuickView canvas(testFileUrl("readOnly.qml")); + canvas.show(); + canvas.requestActivateWindow(); + + QVERIFY(canvas.rootObject() != 0); + + QQuickTextEdit *edit = qobject_cast(qvariant_cast(canvas.rootObject()->property("myInput"))); + + QVERIFY(edit != 0); + QTRY_VERIFY(edit->hasActiveFocus() == true); + QVERIFY(edit->isReadOnly() == true); + QString initial = edit->text(); + for (int k=Qt::Key_0; k<=Qt::Key_Z; k++) + simulateKey(&canvas, k); + simulateKey(&canvas, Qt::Key_Return); + simulateKey(&canvas, Qt::Key_Space); + simulateKey(&canvas, Qt::Key_Escape); + QCOMPARE(edit->text(), initial); + + edit->setCursorPosition(3); + edit->setReadOnly(false); + QCOMPARE(edit->isReadOnly(), false); + QCOMPARE(edit->cursorPosition(), edit->text().length()); +} + +void tst_qquicktextedit::simulateKey(QQuickView *view, int key, Qt::KeyboardModifiers modifiers) +{ + QKeyEvent press(QKeyEvent::KeyPress, key, modifiers); + QKeyEvent release(QKeyEvent::KeyRelease, key, modifiers); + + QGuiApplication::sendEvent(view, &press); + QGuiApplication::sendEvent(view, &release); +} + +void tst_qquicktextedit::textInput() +{ + QQuickView view(testFileUrl("inputMethodEvent.qml")); + view.show(); + view.requestActivateWindow(); + QTest::qWaitForWindowShown(&view); + QTRY_COMPARE(&view, qGuiApp->focusWindow()); + QQuickTextEdit *edit = qobject_cast(view.rootObject()); + QVERIFY(edit); + QVERIFY(edit->hasActiveFocus() == true); + + // test that input method event is committed and change signal is emitted + QSignalSpy spy(edit, SIGNAL(textChanged())); + QInputMethodEvent event; + event.setCommitString( "Hello world!", 0, 0); + QGuiApplication::sendEvent(qGuiApp->focusObject(), &event); + QCOMPARE(edit->text(), QString("Hello world!")); + QCOMPARE(spy.count(), 1); + + // QTBUG-12339 + // test that document and internal text attribute are in sync + QQuickTextEditPrivate *editPrivate = static_cast(QQuickItemPrivate::get(edit)); + QCOMPARE(editPrivate->text, QString("Hello world!")); + + // test that tentative commit is included in text property + edit->setText(""); + spy.clear(); + QList attributes; + QInputMethodEvent event2("preedit", attributes); + event2.setTentativeCommitString("string"); + QGuiApplication::sendEvent(qGuiApp->focusObject(), &event2); + QCOMPARE(spy.count(), 1); + QCOMPARE(edit->text(), QString("string")); + + QInputMethodQueryEvent queryEvent(Qt::ImEnabled); + QGuiApplication::sendEvent(qGuiApp->focusObject(), &queryEvent); + QCOMPARE(queryEvent.value(Qt::ImEnabled).toBool(), true); + + edit->setReadOnly(true); + QGuiApplication::sendEvent(edit, &queryEvent); + QCOMPARE(queryEvent.value(Qt::ImEnabled).toBool(), false); +} + +void tst_qquicktextedit::inputMethodUpdate() +{ + PlatformInputContext platformInputContext; + QInputMethodPrivate *inputMethodPrivate = QInputMethodPrivate::get(qApp->inputMethod()); + inputMethodPrivate->testContext = &platformInputContext; + + QQuickView view(testFileUrl("inputMethodEvent.qml")); + view.show(); + view.requestActivateWindow(); + QTest::qWaitForWindowShown(&view); + QTRY_COMPARE(&view, qGuiApp->focusWindow()); + QQuickTextEdit *edit = qobject_cast(view.rootObject()); + QVERIFY(edit); + QVERIFY(edit->hasActiveFocus() == true); + + // text change even without cursor position change needs to trigger update + edit->setText("test"); + platformInputContext.clear(); + edit->setText("xxxx"); + QVERIFY(platformInputContext.m_updateCallCount > 0); + + // input method event replacing text + platformInputContext.clear(); + { + QInputMethodEvent inputMethodEvent; + inputMethodEvent.setCommitString("y", -1, 1); + QGuiApplication::sendEvent(edit, &inputMethodEvent); + } + QVERIFY(platformInputContext.m_updateCallCount > 0); + + // input method changing selection + platformInputContext.clear(); + { + QList attributes; + attributes << QInputMethodEvent::Attribute(QInputMethodEvent::Selection, 0, 2, QVariant()); + QInputMethodEvent inputMethodEvent("", attributes); + QGuiApplication::sendEvent(edit, &inputMethodEvent); + } + QVERIFY(edit->selectionStart() != edit->selectionEnd()); + QVERIFY(platformInputContext.m_updateCallCount > 0); + + // font changes + platformInputContext.clear(); + QFont font = edit->font(); + font.setBold(!font.bold()); + edit->setFont(font); + QVERIFY(platformInputContext.m_updateCallCount > 0); + + // normal input + platformInputContext.clear(); + { + QInputMethodEvent inputMethodEvent; + inputMethodEvent.setCommitString("y"); + QGuiApplication::sendEvent(edit, &inputMethodEvent); + } + QVERIFY(platformInputContext.m_updateCallCount > 0); + + // changing cursor position + platformInputContext.clear(); + edit->setCursorPosition(0); + QVERIFY(platformInputContext.m_updateCallCount > 0); + + // continuing with selection + platformInputContext.clear(); + edit->moveCursorSelection(1); + QVERIFY(platformInputContext.m_updateCallCount > 0); + + // read only disabled input method + platformInputContext.clear(); + edit->setReadOnly(true); + QVERIFY(platformInputContext.m_updateCallCount > 0); + edit->setReadOnly(false); + + // no updates while no focus + edit->setFocus(false); + platformInputContext.clear(); + edit->setText("Foo"); + QCOMPARE(platformInputContext.m_updateCallCount, 0); + edit->setCursorPosition(1); + QCOMPARE(platformInputContext.m_updateCallCount, 0); + edit->selectAll(); + QCOMPARE(platformInputContext.m_updateCallCount, 0); + edit->setReadOnly(true); + QCOMPARE(platformInputContext.m_updateCallCount, 0); +} + +void tst_qquicktextedit::openInputPanel() +{ + PlatformInputContext platformInputContext; + QInputMethodPrivate *inputMethodPrivate = QInputMethodPrivate::get(qApp->inputMethod()); + inputMethodPrivate->testContext = &platformInputContext; + + QQuickView view(testFileUrl("openInputPanel.qml")); + view.show(); + view.requestActivateWindow(); + QTest::qWaitForWindowShown(&view); + QTRY_COMPARE(&view, qGuiApp->focusWindow()); + + QQuickTextEdit *edit = qobject_cast(view.rootObject()); + QVERIFY(edit); + + // check default values + QVERIFY(edit->focusOnPress()); + QVERIFY(!edit->hasActiveFocus()); + qDebug() << &edit << qApp->focusObject(); + QVERIFY(qApp->focusObject() != edit); + + QCOMPARE(qApp->inputMethod()->visible(), false); + + // input panel should open on focus + QPoint centerPoint(view.width()/2, view.height()/2); + Qt::KeyboardModifiers noModifiers = 0; + QTest::mousePress(&view, Qt::LeftButton, noModifiers, centerPoint); + QGuiApplication::processEvents(); + QVERIFY(edit->hasActiveFocus()); + QCOMPARE(qApp->focusObject(), edit); + QCOMPARE(qApp->inputMethod()->visible(), true); + QTest::mouseRelease(&view, Qt::LeftButton, noModifiers, centerPoint); + + // input panel should be re-opened when pressing already focused TextEdit + qApp->inputMethod()->hide(); + QCOMPARE(qApp->inputMethod()->visible(), false); + QVERIFY(edit->hasActiveFocus()); + QTest::mousePress(&view, Qt::LeftButton, noModifiers, centerPoint); + QGuiApplication::processEvents(); + QCOMPARE(qApp->inputMethod()->visible(), true); + QTest::mouseRelease(&view, Qt::LeftButton, noModifiers, centerPoint); + + // input panel should stay visible if focus is lost to another text editor + QSignalSpy inputPanelVisibilitySpy(qApp->inputMethod(), SIGNAL(visibleChanged())); + QQuickTextEdit anotherEdit; + anotherEdit.setParentItem(view.rootObject()); + anotherEdit.setFocus(true); + QCOMPARE(qApp->inputMethod()->visible(), true); + QCOMPARE(qApp->focusObject(), qobject_cast(&anotherEdit)); + QCOMPARE(inputPanelVisibilitySpy.count(), 0); + + anotherEdit.setFocus(false); + QVERIFY(qApp->focusObject() != &anotherEdit); + QCOMPARE(view.activeFocusItem(), view.rootItem()); + anotherEdit.setFocus(true); + + qApp->inputMethod()->hide(); + + // input panel should not be opened if TextEdit is read only + edit->setReadOnly(true); + edit->setFocus(true); + QCOMPARE(qApp->inputMethod()->visible(), false); + QTest::mousePress(&view, Qt::LeftButton, noModifiers, centerPoint); + QTest::mouseRelease(&view, Qt::LeftButton, noModifiers, centerPoint); + QGuiApplication::processEvents(); + QCOMPARE(qApp->inputMethod()->visible(), false); + + // input panel should not be opened if focusOnPress is set to false + edit->setFocusOnPress(false); + edit->setFocus(false); + edit->setFocus(true); + QCOMPARE(qApp->inputMethod()->visible(), false); + QTest::mousePress(&view, Qt::LeftButton, noModifiers, centerPoint); + QTest::mouseRelease(&view, Qt::LeftButton, noModifiers, centerPoint); + QCOMPARE(qApp->inputMethod()->visible(), false); + + // input panel should open when openSoftwareInputPanel is called + edit->openSoftwareInputPanel(); + QCOMPARE(qApp->inputMethod()->visible(), true); + + // input panel should close when closeSoftwareInputPanel is called + edit->closeSoftwareInputPanel(); + QCOMPARE(qApp->inputMethod()->visible(), false); + + inputMethodPrivate->testContext = 0; +} + +void tst_qquicktextedit::geometrySignals() +{ + QQmlComponent component(&engine, testFileUrl("geometrySignals.qml")); + QObject *o = component.create(); + QVERIFY(o); + QCOMPARE(o->property("bindingWidth").toInt(), 400); + QCOMPARE(o->property("bindingHeight").toInt(), 500); + delete o; +} + +void tst_qquicktextedit::pastingRichText_QTBUG_14003() +{ +#ifndef QT_NO_CLIPBOARD + QString componentStr = "import QtQuick 2.0\nTextEdit { textFormat: TextEdit.PlainText }"; + QQmlComponent component(&engine); + component.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); + QQuickTextEdit *obj = qobject_cast(component.create()); + + QTRY_VERIFY(obj != 0); + QTRY_VERIFY(obj->textFormat() == QQuickTextEdit::PlainText); + + QMimeData *mData = new QMimeData; + mData->setHtml("Hello"); + QGuiApplication::clipboard()->setMimeData(mData); + + obj->paste(); + QTRY_VERIFY(obj->text() == ""); + QTRY_VERIFY(obj->textFormat() == QQuickTextEdit::PlainText); +#endif +} + +void tst_qquicktextedit::implicitSize_data() +{ + QTest::addColumn("text"); + QTest::addColumn("wrap"); + QTest::newRow("plain") << "The quick red fox jumped over the lazy brown dog" << "TextEdit.NoWrap"; + QTest::newRow("richtext") << "The quick red fox jumped over the lazy brown dog" << "TextEdit.NoWrap"; + QTest::newRow("plain_wrap") << "The quick red fox jumped over the lazy brown dog" << "TextEdit.Wrap"; + QTest::newRow("richtext_wrap") << "The quick red fox jumped over the lazy brown dog" << "TextEdit.Wrap"; +} + +void tst_qquicktextedit::implicitSize() +{ + QFETCH(QString, text); + QFETCH(QString, wrap); + QString componentStr = "import QtQuick 2.0\nTextEdit { text: \"" + text + "\"; width: 50; wrapMode: " + wrap + " }"; + QQmlComponent textComponent(&engine); + textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); + QQuickTextEdit *textObject = qobject_cast(textComponent.create()); + + QVERIFY(textObject->width() < textObject->implicitWidth()); + QVERIFY(textObject->height() == textObject->implicitHeight()); + + textObject->resetWidth(); + QVERIFY(textObject->width() == textObject->implicitWidth()); + QVERIFY(textObject->height() == textObject->implicitHeight()); +} + +void tst_qquicktextedit::contentSize() +{ + QString componentStr = "import QtQuick 2.0\nTextEdit { width: 75; height: 16; font.pixelSize: 10 }"; + QQmlComponent textComponent(&engine); + textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); + QScopedPointer object(textComponent.create()); + QQuickTextEdit *textObject = qobject_cast(object.data()); + + QSignalSpy spy(textObject, SIGNAL(contentSizeChanged())); + + textObject->setText("The quick red fox jumped over the lazy brown dog"); + + QVERIFY(textObject->contentWidth() > textObject->width()); + QVERIFY(textObject->contentHeight() < textObject->height()); + QCOMPARE(spy.count(), 1); + + textObject->setWrapMode(QQuickTextEdit::WordWrap); + QVERIFY(textObject->contentWidth() <= textObject->width()); + QVERIFY(textObject->contentHeight() > textObject->height()); + QCOMPARE(spy.count(), 2); + + textObject->setText("The quickredfoxjumpedoverthe lazy brown dog"); + + QVERIFY(textObject->contentWidth() > textObject->width()); + QVERIFY(textObject->contentHeight() > textObject->height()); + QCOMPARE(spy.count(), 3); +} + +void tst_qquicktextedit::preeditCursorRectangle() +{ + QString preeditText = "super"; + + QQuickView view(testFileUrl("inputMethodEvent.qml")); + view.show(); + view.requestActivateWindow(); + QTest::qWaitForWindowShown(&view); + + QTRY_COMPARE(&view, qGuiApp->focusWindow()); + QQuickTextEdit *edit = qobject_cast(view.rootObject()); + QVERIFY(edit); + + QSignalSpy editSpy(edit, SIGNAL(cursorRectangleChanged())); + QSignalSpy panelSpy(qGuiApp->inputMethod(), SIGNAL(cursorRectangleChanged())); + + QRect currentRect; + + QInputMethodQueryEvent query(Qt::ImCursorRectangle); + QCoreApplication::sendEvent(qGuiApp->focusObject(), &query); + QRect previousRect = query.value(Qt::ImCursorRectangle).toRect(); + + // Verify that the micro focus rect is positioned the same for position 0 as + // it would be if there was no preedit text. + QInputMethodEvent imEvent(preeditText, QList() + << QInputMethodEvent::Attribute(QInputMethodEvent::Cursor, 0, preeditText.length(), QVariant())); + QCoreApplication::sendEvent(qGuiApp->focusObject(), &imEvent); + QCoreApplication::sendEvent(qGuiApp->focusObject(), &query); + currentRect = query.value(Qt::ImCursorRectangle).toRect(); + QCOMPARE(currentRect, previousRect); + QCOMPARE(editSpy.count(), 0); + QCOMPARE(panelSpy.count(), 0); + + // Verify that the micro focus rect moves to the left as the cursor position + // is incremented. + for (int i = 1; i <= 5; ++i) { + QInputMethodEvent imEvent(preeditText, QList() + << QInputMethodEvent::Attribute(QInputMethodEvent::Cursor, i, preeditText.length(), QVariant())); + QCoreApplication::sendEvent(qGuiApp->focusObject(), &imEvent); + QCoreApplication::sendEvent(qGuiApp->focusObject(), &query); + currentRect = query.value(Qt::ImCursorRectangle).toRect(); + QVERIFY(previousRect.left() < currentRect.left()); + QVERIFY(editSpy.count() > 0); editSpy.clear(); + QVERIFY(panelSpy.count() > 0); panelSpy.clear(); + previousRect = currentRect; + } + + // Verify that if there is no preedit cursor then the micro focus rect is the + // same as it would be if it were positioned at the end of the preedit text. + QCoreApplication::sendEvent(qGuiApp->focusObject(), &imEvent); + editSpy.clear(); + panelSpy.clear(); + { QInputMethodEvent imEvent(preeditText, QList()); + QCoreApplication::sendEvent(qGuiApp->focusObject(), &imEvent); } + QCoreApplication::sendEvent(qGuiApp->focusObject(), &query); + currentRect = query.value(Qt::ImCursorRectangle).toRect(); + QCOMPARE(currentRect, previousRect); + QVERIFY(editSpy.count() > 0); + QVERIFY(panelSpy.count() > 0); +} + +void tst_qquicktextedit::inputMethodComposing() +{ + QString text = "supercalifragisiticexpialidocious!"; + + QQuickView view(testFileUrl("inputContext.qml")); + view.show(); + view.requestActivateWindow(); + QTest::qWaitForWindowShown(&view); + QTRY_COMPARE(&view, qGuiApp->focusWindow()); + QQuickTextEdit *edit = qobject_cast(view.rootObject()); + QVERIFY(edit); + QSignalSpy spy(edit, SIGNAL(inputMethodComposingChanged())); + edit->setCursorPosition(12); + + QCOMPARE(edit->isInputMethodComposing(), false); + + { + QInputMethodEvent event(text.mid(3), QList()); + QGuiApplication::sendEvent(edit, &event); + } + + QCOMPARE(edit->isInputMethodComposing(), true); + QCOMPARE(spy.count(), 1); + + { + QInputMethodEvent event(text.mid(12), QList()); + QGuiApplication::sendEvent(edit, &event); + } + QCOMPARE(spy.count(), 1); + + { + QInputMethodEvent event; + QGuiApplication::sendEvent(edit, &event); + } + QCOMPARE(edit->isInputMethodComposing(), false); + QCOMPARE(spy.count(), 2); +} + +void tst_qquicktextedit::cursorRectangleSize() +{ + QQuickView *canvas = new QQuickView(testFileUrl("positionAt.qml")); + QVERIFY(canvas->rootObject() != 0); + QQuickTextEdit *textEdit = qobject_cast(canvas->rootObject()); + + // make sure cursor rectangle is not at (0,0) + textEdit->setX(10); + textEdit->setY(10); + textEdit->setCursorPosition(3); + QVERIFY(textEdit != 0); + textEdit->setFocus(true); + canvas->show(); + canvas->requestActivateWindow(); + QTest::qWaitForWindowShown(canvas); + + QInputMethodQueryEvent event(Qt::ImCursorRectangle); + qApp->sendEvent(qApp->focusObject(), &event); + QRectF cursorRectFromQuery = event.value(Qt::ImCursorRectangle).toRectF(); + + QRect cursorRectFromItem = textEdit->cursorRectangle(); + QRectF cursorRectFromPositionToRectangle = textEdit->positionToRectangle(textEdit->cursorPosition()); + + // item and input query cursor rectangles match + QCOMPARE(cursorRectFromItem, cursorRectFromQuery.toRect()); + + // item cursor rectangle and positionToRectangle calculations match + QCOMPARE(cursorRectFromItem, cursorRectFromPositionToRectangle.toRect()); + + // item-canvas transform and input item transform match + QCOMPARE(QQuickItemPrivate::get(textEdit)->itemToCanvasTransform(), qApp->inputMethod()->inputItemTransform()); + + // input panel cursorRectangle property and tranformed item cursor rectangle match + QRectF sceneCursorRect = QQuickItemPrivate::get(textEdit)->itemToCanvasTransform().mapRect(cursorRectFromItem); + QCOMPARE(sceneCursorRect, qApp->inputMethod()->cursorRectangle()); + + delete canvas; +} + +void tst_qquicktextedit::getText_data() +{ + QTest::addColumn("text"); + QTest::addColumn("start"); + QTest::addColumn("end"); + QTest::addColumn("expectedText"); + + const QString richBoldText = QStringLiteral("This is some bold text"); + const QString plainBoldText = QStringLiteral("This is some bold text"); + + QTest::newRow("all plain text") + << standard.at(0) + << 0 << standard.at(0).length() + << standard.at(0); + + QTest::newRow("plain text sub string") + << standard.at(0) + << 0 << 12 + << standard.at(0).mid(0, 12); + + QTest::newRow("plain text sub string reversed") + << standard.at(0) + << 12 << 0 + << standard.at(0).mid(0, 12); + + QTest::newRow("plain text cropped beginning") + << standard.at(0) + << -3 << 4 + << standard.at(0).mid(0, 4); + + QTest::newRow("plain text cropped end") + << standard.at(0) + << 23 << standard.at(0).length() + 8 + << standard.at(0).mid(23); + + QTest::newRow("plain text cropped beginning and end") + << standard.at(0) + << -9 << standard.at(0).length() + 4 + << standard.at(0); + + QTest::newRow("all rich text") + << richBoldText + << 0 << plainBoldText.length() + << plainBoldText; + + QTest::newRow("rich text sub string") + << richBoldText + << 14 << 21 + << plainBoldText.mid(14, 7); +} + +void tst_qquicktextedit::getText() +{ + QFETCH(QString, text); + QFETCH(int, start); + QFETCH(int, end); + QFETCH(QString, expectedText); + + QString componentStr = "import QtQuick 2.0\nTextEdit { textFormat: TextEdit.AutoText; text: \"" + text + "\" }"; + QQmlComponent textEditComponent(&engine); + textEditComponent.setData(componentStr.toLatin1(), QUrl()); + QQuickTextEdit *textEdit = qobject_cast(textEditComponent.create()); + QVERIFY(textEdit != 0); + + QCOMPARE(textEdit->getText(start, end), expectedText); +} + +void tst_qquicktextedit::getFormattedText_data() +{ + QTest::addColumn("text"); + QTest::addColumn("textFormat"); + QTest::addColumn("start"); + QTest::addColumn("end"); + QTest::addColumn("expectedText"); + + const QString richBoldText = QStringLiteral("This is some bold text"); + const QString plainBoldText = QStringLiteral("This is some bold text"); + + QTest::newRow("all plain text") + << standard.at(0) + << QQuickTextEdit::PlainText + << 0 << standard.at(0).length() + << standard.at(0); + + QTest::newRow("plain text sub string") + << standard.at(0) + << QQuickTextEdit::PlainText + << 0 << 12 + << standard.at(0).mid(0, 12); + + QTest::newRow("plain text sub string reversed") + << standard.at(0) + << QQuickTextEdit::PlainText + << 12 << 0 + << standard.at(0).mid(0, 12); + + QTest::newRow("plain text cropped beginning") + << standard.at(0) + << QQuickTextEdit::PlainText + << -3 << 4 + << standard.at(0).mid(0, 4); + + QTest::newRow("plain text cropped end") + << standard.at(0) + << QQuickTextEdit::PlainText + << 23 << standard.at(0).length() + 8 + << standard.at(0).mid(23); + + QTest::newRow("plain text cropped beginning and end") + << standard.at(0) + << QQuickTextEdit::PlainText + << -9 << standard.at(0).length() + 4 + << standard.at(0); + + QTest::newRow("all rich (Auto) text") + << richBoldText + << QQuickTextEdit::AutoText + << 0 << plainBoldText.length() + << QString("This is some \\<.*\\>bold\\ text"); + + QTest::newRow("all rich (Rich) text") + << richBoldText + << QQuickTextEdit::RichText + << 0 << plainBoldText.length() + << QString("This is some \\<.*\\>bold\\ text"); + + QTest::newRow("all rich (Plain) text") + << richBoldText + << QQuickTextEdit::PlainText + << 0 << richBoldText.length() + << richBoldText; + + QTest::newRow("rich (Auto) text sub string") + << richBoldText + << QQuickTextEdit::AutoText + << 14 << 21 + << QString("\\<.*\\>old\\ tex"); + + QTest::newRow("rich (Rich) text sub string") + << richBoldText + << QQuickTextEdit::RichText + << 14 << 21 + << QString("\\<.*\\>old\\ tex"); + + QTest::newRow("rich (Plain) text sub string") + << richBoldText + << QQuickTextEdit::PlainText + << 17 << 27 + << richBoldText.mid(17, 10); +} + +void tst_qquicktextedit::getFormattedText() +{ + QFETCH(QString, text); + QFETCH(QQuickTextEdit::TextFormat, textFormat); + QFETCH(int, start); + QFETCH(int, end); + QFETCH(QString, expectedText); + + QString componentStr = "import QtQuick 2.0\nTextEdit {}"; + QQmlComponent textEditComponent(&engine); + textEditComponent.setData(componentStr.toLatin1(), QUrl()); + QQuickTextEdit *textEdit = qobject_cast(textEditComponent.create()); + QVERIFY(textEdit != 0); + + textEdit->setTextFormat(textFormat); + textEdit->setText(text); + + if (textFormat == QQuickTextEdit::RichText + || (textFormat == QQuickTextEdit::AutoText && Qt::mightBeRichText(text))) { + QVERIFY(textEdit->getFormattedText(start, end).contains(QRegExp(expectedText))); + } else { + QCOMPARE(textEdit->getFormattedText(start, end), expectedText); + } +} + +void tst_qquicktextedit::insert_data() +{ + QTest::addColumn("text"); + QTest::addColumn("textFormat"); + QTest::addColumn("selectionStart"); + QTest::addColumn("selectionEnd"); + QTest::addColumn("insertPosition"); + QTest::addColumn("insertText"); + QTest::addColumn("expectedText"); + QTest::addColumn("expectedSelectionStart"); + QTest::addColumn("expectedSelectionEnd"); + QTest::addColumn("expectedCursorPosition"); + QTest::addColumn("selectionChanged"); + QTest::addColumn("cursorPositionChanged"); + + QTest::newRow("at cursor position (beginning)") + << standard.at(0) << QQuickTextEdit::PlainText + << 0 << 0 << 0 + << QString("Hello") + << QString("Hello") + standard.at(0) + << 5 << 5 << 5 + << false << true; + + QTest::newRow("at cursor position (end)") + << standard.at(0) << QQuickTextEdit::PlainText + << standard.at(0).length() << standard.at(0).length() << standard.at(0).length() + << QString("Hello") + << standard.at(0) + QString("Hello") + << standard.at(0).length() + 5 << standard.at(0).length() + 5 << standard.at(0).length() + 5 + << false << true; + + QTest::newRow("at cursor position (middle)") + << standard.at(0) << QQuickTextEdit::PlainText + << 18 << 18 << 18 + << QString("Hello") + << standard.at(0).mid(0, 18) + QString("Hello") + standard.at(0).mid(18) + << 23 << 23 << 23 + << false << true; + + QTest::newRow("after cursor position (beginning)") + << standard.at(0) << QQuickTextEdit::PlainText + << 0 << 0 << 18 + << QString("Hello") + << standard.at(0).mid(0, 18) + QString("Hello") + standard.at(0).mid(18) + << 0 << 0 << 0 + << false << false; + + QTest::newRow("before cursor position (end)") + << standard.at(0) << QQuickTextEdit::PlainText + << standard.at(0).length() << standard.at(0).length() << 18 + << QString("Hello") + << standard.at(0).mid(0, 18) + QString("Hello") + standard.at(0).mid(18) + << standard.at(0).length() + 5 << standard.at(0).length() + 5 << standard.at(0).length() + 5 + << false << true; + + QTest::newRow("before cursor position (middle)") + << standard.at(0) << QQuickTextEdit::PlainText + << 18 << 18 << 0 + << QString("Hello") + << QString("Hello") + standard.at(0) + << 23 << 23 << 23 + << false << true; + + QTest::newRow("after cursor position (middle)") + << standard.at(0) << QQuickTextEdit::PlainText + << 18 << 18 << standard.at(0).length() + << QString("Hello") + << standard.at(0) + QString("Hello") + << 18 << 18 << 18 + << false << false; + + QTest::newRow("before selection") + << standard.at(0) << QQuickTextEdit::PlainText + << 14 << 19 << 0 + << QString("Hello") + << QString("Hello") + standard.at(0) + << 19 << 24 << 24 + << false << true; + + QTest::newRow("before reversed selection") + << standard.at(0) << QQuickTextEdit::PlainText + << 19 << 14 << 0 + << QString("Hello") + << QString("Hello") + standard.at(0) + << 19 << 24 << 19 + << false << true; + + QTest::newRow("after selection") + << standard.at(0) << QQuickTextEdit::PlainText + << 14 << 19 << standard.at(0).length() + << QString("Hello") + << standard.at(0) + QString("Hello") + << 14 << 19 << 19 + << false << false; + + QTest::newRow("after reversed selection") + << standard.at(0) << QQuickTextEdit::PlainText + << 19 << 14 << standard.at(0).length() + << QString("Hello") + << standard.at(0) + QString("Hello") + << 14 << 19 << 14 + << false << false; + + QTest::newRow("into selection") + << standard.at(0) << QQuickTextEdit::PlainText + << 14 << 19 << 18 + << QString("Hello") + << standard.at(0).mid(0, 18) + QString("Hello") + standard.at(0).mid(18) + << 14 << 24 << 24 + << true << true; + + QTest::newRow("into reversed selection") + << standard.at(0) << QQuickTextEdit::PlainText + << 19 << 14 << 18 + << QString("Hello") + << standard.at(0).mid(0, 18) + QString("Hello") + standard.at(0).mid(18) + << 14 << 24 << 14 + << true << false; + + QTest::newRow("rich text into plain text") + << standard.at(0) << QQuickTextEdit::PlainText + << 0 << 0 << 0 + << QString("Hello") + << QString("Hello") + standard.at(0) + << 12 << 12 << 12 + << false << true; + + QTest::newRow("rich text into rich text") + << standard.at(0) << QQuickTextEdit::RichText + << 0 << 0 << 0 + << QString("Hello") + << QString("Hello") + standard.at(0) + << 5 << 5 << 5 + << false << true; + + QTest::newRow("rich text into auto text") + << standard.at(0) << QQuickTextEdit::AutoText + << 0 << 0 << 0 + << QString("Hello") + << QString("Hello") + standard.at(0) + << 5 << 5 << 5 + << false << true; + + QTest::newRow("before start") + << standard.at(0) << QQuickTextEdit::PlainText + << 0 << 0 << -3 + << QString("Hello") + << standard.at(0) + << 0 << 0 << 0 + << false << false; + + QTest::newRow("past end") + << standard.at(0) << QQuickTextEdit::PlainText + << 0 << 0 << standard.at(0).length() + 3 + << QString("Hello") + << standard.at(0) + << 0 << 0 << 0 + << false << false; +} + +void tst_qquicktextedit::insert() +{ + QFETCH(QString, text); + QFETCH(QQuickTextEdit::TextFormat, textFormat); + QFETCH(int, selectionStart); + QFETCH(int, selectionEnd); + QFETCH(int, insertPosition); + QFETCH(QString, insertText); + QFETCH(QString, expectedText); + QFETCH(int, expectedSelectionStart); + QFETCH(int, expectedSelectionEnd); + QFETCH(int, expectedCursorPosition); + QFETCH(bool, selectionChanged); + QFETCH(bool, cursorPositionChanged); + + QString componentStr = "import QtQuick 2.0\nTextEdit { text: \"" + text + "\" }"; + QQmlComponent textEditComponent(&engine); + textEditComponent.setData(componentStr.toLatin1(), QUrl()); + QQuickTextEdit *textEdit = qobject_cast(textEditComponent.create()); + QVERIFY(textEdit != 0); + + textEdit->setTextFormat(textFormat); + textEdit->select(selectionStart, selectionEnd); + + QSignalSpy selectionSpy(textEdit, SIGNAL(selectionChanged())); + QSignalSpy selectionStartSpy(textEdit, SIGNAL(selectionStartChanged())); + QSignalSpy selectionEndSpy(textEdit, SIGNAL(selectionEndChanged())); + QSignalSpy textSpy(textEdit, SIGNAL(textChanged())); + QSignalSpy cursorPositionSpy(textEdit, SIGNAL(cursorPositionChanged())); + + textEdit->insert(insertPosition, insertText); + + if (textFormat == QQuickTextEdit::RichText || (textFormat == QQuickTextEdit::AutoText && ( + Qt::mightBeRichText(text) || Qt::mightBeRichText(insertText)))) { + QCOMPARE(textEdit->getText(0, expectedText.length()), expectedText); + } else { + QCOMPARE(textEdit->text(), expectedText); + + } + QCOMPARE(textEdit->length(), expectedText.length()); + + QCOMPARE(textEdit->selectionStart(), expectedSelectionStart); + QCOMPARE(textEdit->selectionEnd(), expectedSelectionEnd); + QCOMPARE(textEdit->cursorPosition(), expectedCursorPosition); + + if (selectionStart > selectionEnd) + qSwap(selectionStart, selectionEnd); + + QEXPECT_FAIL("into selection", "selectionChanged signal isn't emitted on edits within selection", Continue); + QEXPECT_FAIL("into reversed selection", "selectionChanged signal isn't emitted on edits within selection", Continue); + QCOMPARE(selectionSpy.count() > 0, selectionChanged); + QCOMPARE(selectionStartSpy.count() > 0, selectionStart != expectedSelectionStart); + QEXPECT_FAIL("into reversed selection", "selectionEndChanged signal not emitted", Continue); + QCOMPARE(selectionEndSpy.count() > 0, selectionEnd != expectedSelectionEnd); + QCOMPARE(textSpy.count() > 0, text != expectedText); + QCOMPARE(cursorPositionSpy.count() > 0, cursorPositionChanged); +} + +void tst_qquicktextedit::remove_data() +{ + QTest::addColumn("text"); + QTest::addColumn("textFormat"); + QTest::addColumn("selectionStart"); + QTest::addColumn("selectionEnd"); + QTest::addColumn("removeStart"); + QTest::addColumn("removeEnd"); + QTest::addColumn("expectedText"); + QTest::addColumn("expectedSelectionStart"); + QTest::addColumn("expectedSelectionEnd"); + QTest::addColumn("expectedCursorPosition"); + QTest::addColumn("selectionChanged"); + QTest::addColumn("cursorPositionChanged"); + + const QString richBoldText = QStringLiteral("This is some bold text"); + const QString plainBoldText = QStringLiteral("This is some bold text"); + + QTest::newRow("from cursor position (beginning)") + << standard.at(0) << QQuickTextEdit::PlainText + << 0 << 0 + << 0 << 5 + << standard.at(0).mid(5) + << 0 << 0 << 0 + << false << false; + + QTest::newRow("to cursor position (beginning)") + << standard.at(0) << QQuickTextEdit::PlainText + << 0 << 0 + << 5 << 0 + << standard.at(0).mid(5) + << 0 << 0 << 0 + << false << false; + + QTest::newRow("to cursor position (end)") + << standard.at(0) << QQuickTextEdit::PlainText + << standard.at(0).length() << standard.at(0).length() + << standard.at(0).length() << standard.at(0).length() - 5 + << standard.at(0).mid(0, standard.at(0).length() - 5) + << standard.at(0).length() - 5 << standard.at(0).length() - 5 << standard.at(0).length() - 5 + << false << true; + + QTest::newRow("to cursor position (end)") + << standard.at(0) << QQuickTextEdit::PlainText + << standard.at(0).length() << standard.at(0).length() + << standard.at(0).length() - 5 << standard.at(0).length() + << standard.at(0).mid(0, standard.at(0).length() - 5) + << standard.at(0).length() - 5 << standard.at(0).length() - 5 << standard.at(0).length() - 5 + << false << true; + + QTest::newRow("from cursor position (middle)") + << standard.at(0) << QQuickTextEdit::PlainText + << 18 << 18 + << 18 << 23 + << standard.at(0).mid(0, 18) + standard.at(0).mid(23) + << 18 << 18 << 18 + << false << false; + + QTest::newRow("to cursor position (middle)") + << standard.at(0) << QQuickTextEdit::PlainText + << 23 << 23 + << 18 << 23 + << standard.at(0).mid(0, 18) + standard.at(0).mid(23) + << 18 << 18 << 18 + << false << true; + + QTest::newRow("after cursor position (beginning)") + << standard.at(0) << QQuickTextEdit::PlainText + << 0 << 0 + << 18 << 23 + << standard.at(0).mid(0, 18) + standard.at(0).mid(23) + << 0 << 0 << 0 + << false << false; + + QTest::newRow("before cursor position (end)") + << standard.at(0) << QQuickTextEdit::PlainText + << standard.at(0).length() << standard.at(0).length() + << 18 << 23 + << standard.at(0).mid(0, 18) + standard.at(0).mid(23) + << standard.at(0).length() - 5 << standard.at(0).length() - 5 << standard.at(0).length() - 5 + << false << true; + + QTest::newRow("before cursor position (middle)") + << standard.at(0) << QQuickTextEdit::PlainText + << 23 << 23 + << 0 << 5 + << standard.at(0).mid(5) + << 18 << 18 << 18 + << false << true; + + QTest::newRow("after cursor position (middle)") + << standard.at(0) << QQuickTextEdit::PlainText + << 18 << 18 + << 18 << 23 + << standard.at(0).mid(0, 18) + standard.at(0).mid(23) + << 18 << 18 << 18 + << false << false; + + QTest::newRow("before selection") + << standard.at(0) << QQuickTextEdit::PlainText + << 14 << 19 + << 0 << 5 + << standard.at(0).mid(5) + << 9 << 14 << 14 + << false << true; + + QTest::newRow("before reversed selection") + << standard.at(0) << QQuickTextEdit::PlainText + << 19 << 14 + << 0 << 5 + << standard.at(0).mid(5) + << 9 << 14 << 9 + << false << true; + + QTest::newRow("after selection") + << standard.at(0) << QQuickTextEdit::PlainText + << 14 << 19 + << standard.at(0).length() - 5 << standard.at(0).length() + << standard.at(0).mid(0, standard.at(0).length() - 5) + << 14 << 19 << 19 + << false << false; + + QTest::newRow("after reversed selection") + << standard.at(0) << QQuickTextEdit::PlainText + << 19 << 14 + << standard.at(0).length() - 5 << standard.at(0).length() + << standard.at(0).mid(0, standard.at(0).length() - 5) + << 14 << 19 << 14 + << false << false; + + QTest::newRow("from selection") + << standard.at(0) << QQuickTextEdit::PlainText + << 14 << 24 + << 18 << 23 + << standard.at(0).mid(0, 18) + standard.at(0).mid(23) + << 14 << 19 << 19 + << true << true; + + QTest::newRow("from reversed selection") + << standard.at(0) << QQuickTextEdit::PlainText + << 24 << 14 + << 18 << 23 + << standard.at(0).mid(0, 18) + standard.at(0).mid(23) + << 14 << 19 << 14 + << true << false; + + QTest::newRow("plain text cropped beginning") + << standard.at(0) << QQuickTextEdit::PlainText + << 0 << 0 + << -3 << 4 + << standard.at(0).mid(4) + << 0 << 0 << 0 + << false << false; + + QTest::newRow("plain text cropped end") + << standard.at(0) << QQuickTextEdit::PlainText + << 0 << 0 + << 23 << standard.at(0).length() + 8 + << standard.at(0).mid(0, 23) + << 0 << 0 << 0 + << false << false; + + QTest::newRow("plain text cropped beginning and end") + << standard.at(0) << QQuickTextEdit::PlainText + << 0 << 0 + << -9 << standard.at(0).length() + 4 + << QString() + << 0 << 0 << 0 + << false << false; + + QTest::newRow("all rich text") + << richBoldText << QQuickTextEdit::RichText + << 0 << 0 + << 0 << plainBoldText.length() + << QString() + << 0 << 0 << 0 + << false << false; + + QTest::newRow("rick text sub string") + << richBoldText << QQuickTextEdit::RichText + << 0 << 0 + << 14 << 21 + << plainBoldText.mid(0, 14) + plainBoldText.mid(21) + << 0 << 0 << 0 + << false << false; +} + +void tst_qquicktextedit::remove() +{ + QFETCH(QString, text); + QFETCH(QQuickTextEdit::TextFormat, textFormat); + QFETCH(int, selectionStart); + QFETCH(int, selectionEnd); + QFETCH(int, removeStart); + QFETCH(int, removeEnd); + QFETCH(QString, expectedText); + QFETCH(int, expectedSelectionStart); + QFETCH(int, expectedSelectionEnd); + QFETCH(int, expectedCursorPosition); + QFETCH(bool, selectionChanged); + QFETCH(bool, cursorPositionChanged); + + QString componentStr = "import QtQuick 2.0\nTextEdit { text: \"" + text + "\" }"; + QQmlComponent textEditComponent(&engine); + textEditComponent.setData(componentStr.toLatin1(), QUrl()); + QQuickTextEdit *textEdit = qobject_cast(textEditComponent.create()); + QVERIFY(textEdit != 0); + + textEdit->setTextFormat(textFormat); + textEdit->select(selectionStart, selectionEnd); + + QSignalSpy selectionSpy(textEdit, SIGNAL(selectionChanged())); + QSignalSpy selectionStartSpy(textEdit, SIGNAL(selectionStartChanged())); + QSignalSpy selectionEndSpy(textEdit, SIGNAL(selectionEndChanged())); + QSignalSpy textSpy(textEdit, SIGNAL(textChanged())); + QSignalSpy cursorPositionSpy(textEdit, SIGNAL(cursorPositionChanged())); + + textEdit->remove(removeStart, removeEnd); + + if (textFormat == QQuickTextEdit::RichText + || (textFormat == QQuickTextEdit::AutoText && Qt::mightBeRichText(text))) { + QCOMPARE(textEdit->getText(0, expectedText.length()), expectedText); + } else { + QCOMPARE(textEdit->text(), expectedText); + } + QCOMPARE(textEdit->length(), expectedText.length()); + + if (selectionStart > selectionEnd) // + qSwap(selectionStart, selectionEnd); + + QCOMPARE(textEdit->selectionStart(), expectedSelectionStart); + QCOMPARE(textEdit->selectionEnd(), expectedSelectionEnd); + QCOMPARE(textEdit->cursorPosition(), expectedCursorPosition); + + QEXPECT_FAIL("from selection", "selectionChanged signal isn't emitted on edits within selection", Continue); + QEXPECT_FAIL("from reversed selection", "selectionChanged signal isn't emitted on edits within selection", Continue); + QCOMPARE(selectionSpy.count() > 0, selectionChanged); + QCOMPARE(selectionStartSpy.count() > 0, selectionStart != expectedSelectionStart); + QEXPECT_FAIL("from reversed selection", "selectionEndChanged signal not emitted", Continue); + QCOMPARE(selectionEndSpy.count() > 0, selectionEnd != expectedSelectionEnd); + QCOMPARE(textSpy.count() > 0, text != expectedText); + + + if (cursorPositionChanged) // + QVERIFY(cursorPositionSpy.count() > 0); +} + + +void tst_qquicktextedit::keySequence_data() +{ + QTest::addColumn("text"); + QTest::addColumn("sequence"); + QTest::addColumn("selectionStart"); + QTest::addColumn("selectionEnd"); + QTest::addColumn("cursorPosition"); + QTest::addColumn("expectedText"); + QTest::addColumn("selectedText"); + + // standard[0] == "the [4]quick [10]brown [16]fox [20]jumped [27]over [32]the [36]lazy [41]dog" + + QTest::newRow("select all") + << standard.at(0) << QKeySequence(QKeySequence::SelectAll) << 0 << 0 + << 44 << standard.at(0) << standard.at(0); + QTest::newRow("select end of line") + << standard.at(0) << QKeySequence(QKeySequence::SelectEndOfLine) << 5 << 5 + << 44 << standard.at(0) << standard.at(0).mid(5); + QTest::newRow("select end of document") + << standard.at(0) << QKeySequence(QKeySequence::SelectEndOfDocument) << 3 << 3 + << 44 << standard.at(0) << standard.at(0).mid(3); + QTest::newRow("select end of block") + << standard.at(0) << QKeySequence(QKeySequence::SelectEndOfBlock) << 18 << 18 + << 44 << standard.at(0) << standard.at(0).mid(18); + QTest::newRow("delete end of line") + << standard.at(0) << QKeySequence(QKeySequence::DeleteEndOfLine) << 24 << 24 + << 24 << standard.at(0).mid(0, 24) << QString(); + QTest::newRow("move to start of line") + << standard.at(0) << QKeySequence(QKeySequence::MoveToStartOfLine) << 31 << 31 + << 0 << standard.at(0) << QString(); + QTest::newRow("move to start of block") + << standard.at(0) << QKeySequence(QKeySequence::MoveToStartOfBlock) << 25 << 25 + << 0 << standard.at(0) << QString(); + QTest::newRow("move to next char") + << standard.at(0) << QKeySequence(QKeySequence::MoveToNextChar) << 12 << 12 + << 13 << standard.at(0) << QString(); + QTest::newRow("move to previous char") + << standard.at(0) << QKeySequence(QKeySequence::MoveToPreviousChar) << 3 << 3 + << 2 << standard.at(0) << QString(); + QTest::newRow("select next char") + << standard.at(0) << QKeySequence(QKeySequence::SelectNextChar) << 23 << 23 + << 24 << standard.at(0) << standard.at(0).mid(23, 1); + QTest::newRow("select previous char") + << standard.at(0) << QKeySequence(QKeySequence::SelectPreviousChar) << 19 << 19 + << 18 << standard.at(0) << standard.at(0).mid(18, 1); + QTest::newRow("move to next word") + << standard.at(0) << QKeySequence(QKeySequence::MoveToNextWord) << 7 << 7 + << 10 << standard.at(0) << QString(); + QTest::newRow("move to previous word") + << standard.at(0) << QKeySequence(QKeySequence::MoveToPreviousWord) << 7 << 7 + << 4 << standard.at(0) << QString(); + QTest::newRow("select previous word") + << standard.at(0) << QKeySequence(QKeySequence::SelectPreviousWord) << 11 << 11 + << 10 << standard.at(0) << standard.at(0).mid(10, 1); + QTest::newRow("delete (selection)") + << standard.at(0) << QKeySequence(QKeySequence::Delete) << 12 << 15 + << 12 << (standard.at(0).mid(0, 12) + standard.at(0).mid(15)) << QString(); + QTest::newRow("delete (no selection)") + << standard.at(0) << QKeySequence(QKeySequence::Delete) << 15 << 15 + << 15 << (standard.at(0).mid(0, 15) + standard.at(0).mid(16)) << QString(); + QTest::newRow("delete end of word") + << standard.at(0) << QKeySequence(QKeySequence::DeleteEndOfWord) << 24 << 24 + << 24 << (standard.at(0).mid(0, 24) + standard.at(0).mid(27)) << QString(); + QTest::newRow("delete start of word") + << standard.at(0) << QKeySequence(QKeySequence::DeleteStartOfWord) << 7 << 7 + << 4 << (standard.at(0).mid(0, 4) + standard.at(0).mid(7)) << QString(); +} + +void tst_qquicktextedit::keySequence() +{ + QFETCH(QString, text); + QFETCH(QKeySequence, sequence); + QFETCH(int, selectionStart); + QFETCH(int, selectionEnd); + QFETCH(int, cursorPosition); + QFETCH(QString, expectedText); + QFETCH(QString, selectedText); + + if (sequence.isEmpty()) { + QSKIP("Key sequence is undefined"); + } + + QString componentStr = "import QtQuick 2.0\nTextEdit { focus: true; text: \"" + text + "\" }"; + QQmlComponent textEditComponent(&engine); + textEditComponent.setData(componentStr.toLatin1(), QUrl()); + QQuickTextEdit *textEdit = qobject_cast(textEditComponent.create()); + QVERIFY(textEdit != 0); + + QQuickCanvas canvas; + textEdit->setParentItem(canvas.rootItem()); + canvas.show(); + canvas.requestActivateWindow(); + QTest::qWaitForWindowShown(&canvas); + QTRY_COMPARE(QGuiApplication::activeWindow(), &canvas); + + textEdit->select(selectionStart, selectionEnd); + + simulateKeys(&canvas, sequence); + + QCOMPARE(textEdit->cursorPosition(), cursorPosition); + QCOMPARE(textEdit->text(), expectedText); + QCOMPARE(textEdit->selectedText(), selectedText); +} + +#define NORMAL 0 +#define REPLACE_UNTIL_END 1 + +void tst_qquicktextedit::undo_data() +{ + QTest::addColumn("insertString"); + QTest::addColumn("insertIndex"); + QTest::addColumn("insertMode"); + QTest::addColumn("expectedString"); + QTest::addColumn("use_keys"); + + for (int i=0; i<2; i++) { + QString keys_str = "keyboard"; + bool use_keys = true; + if (i==0) { + keys_str = "insert"; + use_keys = false; + } + + { + IntList insertIndex; + IntList insertMode; + QStringList insertString; + QStringList expectedString; + + insertIndex << -1; + insertMode << NORMAL; + insertString << "1"; + + insertIndex << -1; + insertMode << NORMAL; + insertString << "5"; + + insertIndex << 1; + insertMode << NORMAL; + insertString << "3"; + + insertIndex << 1; + insertMode << NORMAL; + insertString << "2"; + + insertIndex << 3; + insertMode << NORMAL; + insertString << "4"; + + expectedString << "12345"; + expectedString << "1235"; + expectedString << "135"; + expectedString << "15"; + expectedString << ""; + + QTest::newRow(QString(keys_str + "_numbers").toLatin1()) << + insertString << + insertIndex << + insertMode << + expectedString << + bool(use_keys); + } + { + IntList insertIndex; + IntList insertMode; + QStringList insertString; + QStringList expectedString; + + insertIndex << -1; + insertMode << NORMAL; + insertString << "World"; // World + + insertIndex << 0; + insertMode << NORMAL; + insertString << "Hello"; // HelloWorld + + insertIndex << 0; + insertMode << NORMAL; + insertString << "Well"; // WellHelloWorld + + insertIndex << 9; + insertMode << NORMAL; + insertString << "There"; // WellHelloThereWorld; + + expectedString << "WellHelloThereWorld"; + expectedString << "WellHelloWorld"; + expectedString << "HelloWorld"; + expectedString << "World"; + expectedString << ""; + + QTest::newRow(QString(keys_str + "_helloworld").toLatin1()) << + insertString << + insertIndex << + insertMode << + expectedString << + bool(use_keys); + } + { + IntList insertIndex; + IntList insertMode; + QStringList insertString; + QStringList expectedString; + + insertIndex << -1; + insertMode << NORMAL; + insertString << "Ensuring"; + + insertIndex << -1; + insertMode << NORMAL; + insertString << " instan"; + + insertIndex << 9; + insertMode << NORMAL; + insertString << "an "; + + insertIndex << 10; + insertMode << REPLACE_UNTIL_END; + insertString << " unique instance."; + + expectedString << "Ensuring a unique instance."; + expectedString << "Ensuring a "; // ### Not present in TextInput. + expectedString << "Ensuring an instan"; + expectedString << "Ensuring instan"; + expectedString << ""; + + QTest::newRow(QString(keys_str + "_patterns").toLatin1()) << + insertString << + insertIndex << + insertMode << + expectedString << + bool(use_keys); + } + } +} + +void tst_qquicktextedit::undo() +{ + QFETCH(QStringList, insertString); + QFETCH(IntList, insertIndex); + QFETCH(IntList, insertMode); + QFETCH(QStringList, expectedString); + + QString componentStr = "import QtQuick 2.0\nTextEdit { focus: true }"; + QQmlComponent textEditComponent(&engine); + textEditComponent.setData(componentStr.toLatin1(), QUrl()); + QQuickTextEdit *textEdit = qobject_cast(textEditComponent.create()); + QVERIFY(textEdit != 0); + + QQuickCanvas canvas; + textEdit->setParentItem(canvas.rootItem()); + canvas.show(); + canvas.requestActivateWindow(); + QTest::qWaitForWindowShown(&canvas); + QTRY_COMPARE(QGuiApplication::activeWindow(), &canvas); + + QVERIFY(!textEdit->canUndo()); + + QSignalSpy spy(textEdit, SIGNAL(canUndoChanged())); + + int i; + +// STEP 1: First build up an undo history by inserting or typing some strings... + for (i = 0; i < insertString.size(); ++i) { + if (insertIndex[i] > -1) + textEdit->setCursorPosition(insertIndex[i]); + + // experimental stuff + if (insertMode[i] == REPLACE_UNTIL_END) { + textEdit->select(insertIndex[i], insertIndex[i] + 8); + + // This is what I actually want... + // QTest::keyClick(testWidget, Qt::Key_End, Qt::ShiftModifier); + } + + for (int j = 0; j < insertString.at(i).length(); j++) + QTest::keyClick(&canvas, insertString.at(i).at(j).toLatin1()); + } + + QCOMPARE(spy.count(), 1); + +// STEP 2: Next call undo several times and see if we can restore to the previous state + for (i = 0; i < expectedString.size() - 1; ++i) { + QCOMPARE(textEdit->text(), expectedString[i]); + QVERIFY(textEdit->canUndo()); + textEdit->undo(); + } + +// STEP 3: Verify that we have undone everything + QVERIFY(textEdit->text().isEmpty()); + QVERIFY(!textEdit->canUndo()); + QCOMPARE(spy.count(), 2); +} + +void tst_qquicktextedit::redo_data() +{ + QTest::addColumn("insertString"); + QTest::addColumn("insertIndex"); + QTest::addColumn("expectedString"); + + { + IntList insertIndex; + QStringList insertString; + QStringList expectedString; + + insertIndex << -1; + insertString << "World"; // World + insertIndex << 0; + insertString << "Hello"; // HelloWorld + insertIndex << 0; + insertString << "Well"; // WellHelloWorld + insertIndex << 9; + insertString << "There"; // WellHelloThereWorld; + + expectedString << "World"; + expectedString << "HelloWorld"; + expectedString << "WellHelloWorld"; + expectedString << "WellHelloThereWorld"; + + QTest::newRow("Inserts and setting cursor") << insertString << insertIndex << expectedString; + } +} + +void tst_qquicktextedit::redo() +{ + QFETCH(QStringList, insertString); + QFETCH(IntList, insertIndex); + QFETCH(QStringList, expectedString); + + QString componentStr = "import QtQuick 2.0\nTextEdit { focus: true }"; + QQmlComponent textEditComponent(&engine); + textEditComponent.setData(componentStr.toLatin1(), QUrl()); + QQuickTextEdit *textEdit = qobject_cast(textEditComponent.create()); + QVERIFY(textEdit != 0); + + QQuickCanvas canvas; + textEdit->setParentItem(canvas.rootItem()); + canvas.show(); + canvas.requestActivateWindow(); + QTest::qWaitForWindowShown(&canvas); + QTRY_COMPARE(QGuiApplication::activeWindow(), &canvas); + + QVERIFY(!textEdit->canUndo()); + QVERIFY(!textEdit->canRedo()); + + QSignalSpy spy(textEdit, SIGNAL(canRedoChanged())); + + int i; + // inserts the diff strings at diff positions + for (i = 0; i < insertString.size(); ++i) { + if (insertIndex[i] > -1) + textEdit->setCursorPosition(insertIndex[i]); + for (int j = 0; j < insertString.at(i).length(); j++) + QTest::keyClick(&canvas, insertString.at(i).at(j).toLatin1()); + QVERIFY(textEdit->canUndo()); + QVERIFY(!textEdit->canRedo()); + } + + QCOMPARE(spy.count(), 0); + + // undo everything + while (!textEdit->text().isEmpty()) { + QVERIFY(textEdit->canUndo()); + textEdit->undo(); + QVERIFY(textEdit->canRedo()); + } + + QCOMPARE(spy.count(), 1); + + for (i = 0; i < expectedString.size(); ++i) { + QVERIFY(textEdit->canRedo()); + textEdit->redo(); + QCOMPARE(textEdit->text() , expectedString[i]); + QVERIFY(textEdit->canUndo()); + } + QVERIFY(!textEdit->canRedo()); + QCOMPARE(spy.count(), 2); +} + +void tst_qquicktextedit::undo_keypressevents_data() +{ + QTest::addColumn("keys"); + QTest::addColumn("expectedString"); + + { + KeyList keys; + QStringList expectedString; + + keys << "AFRAID" + << Qt::Key_Home + << "VERY" + << Qt::Key_Left + << Qt::Key_Left + << Qt::Key_Left + << Qt::Key_Left + << "BE" + << Qt::Key_End + << "!"; + + expectedString << "BEVERYAFRAID!"; + expectedString << "BEVERYAFRAID"; + expectedString << "VERYAFRAID"; + expectedString << "AFRAID"; + + QTest::newRow("Inserts and moving cursor") << keys << expectedString; + } { + KeyList keys; + QStringList expectedString; + + // inserting '1234' + keys << "1234" << Qt::Key_Home + // skipping '12' + << Qt::Key_Right << Qt::Key_Right + // selecting '34' + << (Qt::Key_Right | Qt::ShiftModifier) << (Qt::Key_Right | Qt::ShiftModifier) + // deleting '34' + << Qt::Key_Delete; + + expectedString << "12"; + expectedString << "1234"; + + QTest::newRow("Inserts,moving,selection and delete") << keys << expectedString; + } { + KeyList keys; + QStringList expectedString; + + // inserting 'AB12' + keys << "AB12" + << Qt::Key_Home + // selecting 'AB' + << (Qt::Key_Right | Qt::ShiftModifier) << (Qt::Key_Right | Qt::ShiftModifier) + << Qt::Key_Delete + << QKeySequence::Undo + // ### Text is selected in text input +// << Qt::Key_Right + << (Qt::Key_Right | Qt::ShiftModifier) << (Qt::Key_Right | Qt::ShiftModifier) + << Qt::Key_Delete; + + expectedString << "AB"; + expectedString << "AB12"; + + QTest::newRow("Inserts,moving,selection, delete and undo") << keys << expectedString; + } { + KeyList keys; + QStringList expectedString; + + // inserting 'ABCD' + keys << "abcd" + //move left two + << Qt::Key_Left << Qt::Key_Left + // inserting '1234' + << "1234" + // selecting '1234' + << (Qt::Key_Left | Qt::ShiftModifier) << (Qt::Key_Left | Qt::ShiftModifier) << (Qt::Key_Left | Qt::ShiftModifier) << (Qt::Key_Left | Qt::ShiftModifier) + // overwriting '1234' with '5' + << "5" + // undoing deletion of 'AB' + << QKeySequence::Undo + // ### Text is selected in text input + << (Qt::Key_Left | Qt::ShiftModifier) << (Qt::Key_Left | Qt::ShiftModifier) << (Qt::Key_Left | Qt::ShiftModifier) << (Qt::Key_Left | Qt::ShiftModifier) + // overwriting '1234' with '6' + << "6"; + + expectedString << "ab6cd"; + // for versions previous to 3.2 we overwrite needed two undo operations + expectedString << "ab1234cd"; + expectedString << "abcd"; + + QTest::newRow("Inserts,moving,selection and undo, removing selection") << keys << expectedString; + } { + KeyList keys; + QStringList expectedString; + + // inserting 'ABC' + keys << "ABC" + // removes 'C' + << Qt::Key_Backspace; + + expectedString << "AB"; + expectedString << "ABC"; + + QTest::newRow("Inserts,backspace") << keys << expectedString; + } { + KeyList keys; + QStringList expectedString; + + keys << "ABC" + // removes 'C' + << Qt::Key_Backspace + // inserting 'Z' + << "Z"; + + expectedString << "ABZ"; + expectedString << "AB"; + expectedString << "ABC"; + + QTest::newRow("Inserts,backspace,inserts") << keys << expectedString; + } { + KeyList keys; + QStringList expectedString; + + // inserting '123' + keys << "123" << Qt::Key_Home + // selecting '123' + << (Qt::Key_End | Qt::ShiftModifier) + // overwriting '123' with 'ABC' + << "ABC"; + + expectedString << "ABC"; + // ### One operation in TextInput. + expectedString << "A"; + expectedString << "123"; + + QTest::newRow("Inserts,moving,selection and overwriting") << keys << expectedString; + } +} + +void tst_qquicktextedit::undo_keypressevents() +{ + QFETCH(KeyList, keys); + QFETCH(QStringList, expectedString); + + QString componentStr = "import QtQuick 2.0\nTextEdit { focus: true }"; + QQmlComponent textEditComponent(&engine); + textEditComponent.setData(componentStr.toLatin1(), QUrl()); + QQuickTextEdit *textEdit = qobject_cast(textEditComponent.create()); + QVERIFY(textEdit != 0); + + QQuickCanvas canvas; + textEdit->setParentItem(canvas.rootItem()); + canvas.show(); + canvas.requestActivateWindow(); + QTest::qWaitForWindowShown(&canvas); + QTRY_COMPARE(QGuiApplication::activeWindow(), &canvas); + + simulateKeys(&canvas, keys); + + for (int i = 0; i < expectedString.size(); ++i) { + QCOMPARE(textEdit->text() , expectedString[i]); + textEdit->undo(); + } + QVERIFY(textEdit->text().isEmpty()); +} + +void tst_qquicktextedit::baseUrl() +{ + QUrl localUrl("file:///tests/text.qml"); + QUrl remoteUrl("http://qt.nokia.com/test.qml"); + + QQmlComponent textComponent(&engine); + textComponent.setData("import QtQuick 2.0\n TextEdit {}", localUrl); + QQuickTextEdit *textObject = qobject_cast(textComponent.create()); + + QCOMPARE(textObject->baseUrl(), localUrl); + + QSignalSpy spy(textObject, SIGNAL(baseUrlChanged())); + + textObject->setBaseUrl(localUrl); + QCOMPARE(textObject->baseUrl(), localUrl); + QCOMPARE(spy.count(), 0); + + textObject->setBaseUrl(remoteUrl); + QCOMPARE(textObject->baseUrl(), remoteUrl); + QCOMPARE(spy.count(), 1); + + textObject->resetBaseUrl(); + QCOMPARE(textObject->baseUrl(), localUrl); + QCOMPARE(spy.count(), 2); +} + +void tst_qquicktextedit::embeddedImages_data() +{ + QTest::addColumn("qmlfile"); + QTest::addColumn("error"); + QTest::newRow("local") << testFileUrl("embeddedImagesLocal.qml") << ""; + QTest::newRow("local-error") << testFileUrl("embeddedImagesLocalError.qml") + << testFileUrl("embeddedImagesLocalError.qml").toString()+":3:1: QML TextEdit: Cannot open: " + testFileUrl("http/notexists.png").toString(); + QTest::newRow("local") << testFileUrl("embeddedImagesLocalRelative.qml") << ""; + QTest::newRow("remote") << testFileUrl("embeddedImagesRemote.qml") << ""; + QTest::newRow("remote-error") << testFileUrl("embeddedImagesRemoteError.qml") + << testFileUrl("embeddedImagesRemoteError.qml").toString()+":3:1: QML TextEdit: Error downloading http://127.0.0.1:42332/notexists.png - server replied: Not found"; + QTest::newRow("remote") << testFileUrl("embeddedImagesRemoteRelative.qml") << ""; +} + +void tst_qquicktextedit::embeddedImages() +{ + QFETCH(QUrl, qmlfile); + QFETCH(QString, error); + + TestHTTPServer server(42332); + server.serveDirectory(testFile("http")); + + if (!error.isEmpty()) + QTest::ignoreMessage(QtWarningMsg, error.toLatin1()); + + QQmlComponent textComponent(&engine, qmlfile); + QQuickTextEdit *textObject = qobject_cast(textComponent.create()); + + QVERIFY(textObject != 0); + QTRY_COMPARE(QQuickTextEditPrivate::get(textObject)->document->resourcesLoading(), 0); + + QPixmap pm(testFile("http/exists.png")); + if (error.isEmpty()) { + QCOMPARE(textObject->width(), double(pm.width())); + QCOMPARE(textObject->height(), double(pm.height())); + } else { + QVERIFY(16 != pm.width()); // check test is effective + QCOMPARE(textObject->width(), 16.0); // default size of QTextDocument broken image icon + QCOMPARE(textObject->height(), 16.0); + } + + delete textObject; +} + +void tst_qquicktextedit::emptytags_QTBUG_22058() +{ + QQuickView canvas(testFileUrl("qtbug-22058.qml")); + QVERIFY(canvas.rootObject() != 0); + + canvas.show(); + canvas.requestActivateWindow(); + QTest::qWaitForWindowShown(&canvas); + QQuickTextEdit *input = qobject_cast(qvariant_cast(canvas.rootObject()->property("inputField"))); + QVERIFY(input->hasActiveFocus()); + + QInputMethodEvent event("", QList()); + event.setCommitString("Bold<"); + QGuiApplication::sendEvent(input, &event); + QCOMPARE(input->text(), QString("Bold<")); + event.setCommitString(">"); + QGuiApplication::sendEvent(input, &event); + QCOMPARE(input->text(), QString("Bold<>")); +} + +QTEST_MAIN(tst_qquicktextedit) + +#include "tst_qquicktextedit.moc" diff --git a/tests/auto/quick/qquicktextinput/data/Cursor.qml b/tests/auto/quick/qquicktextinput/data/Cursor.qml new file mode 100644 index 0000000000..e5c1853fc5 --- /dev/null +++ b/tests/auto/quick/qquicktextinput/data/Cursor.qml @@ -0,0 +1,5 @@ +import QtQuick 2.0 + +Rectangle { + property string localProperty +} diff --git a/tests/auto/quick/qquicktextinput/data/cursorTest.qml b/tests/auto/quick/qquicktextinput/data/cursorTest.qml new file mode 100644 index 0000000000..71a420ee7c --- /dev/null +++ b/tests/auto/quick/qquicktextinput/data/cursorTest.qml @@ -0,0 +1,9 @@ +import QtQuick 2.0 + +Rectangle { id:rect; width: 300; height: 300; color: "white" + property string contextualProperty: "Hello" + TextInput { text: "Hello world!"; id: textInputObject; objectName: "textInputObject" + resources: [ Component { id:cursor; Item { id:cursorInstance; objectName: "cursorInstance"; property string localProperty: contextualProperty } } ] + cursorDelegate: cursor + } +} diff --git a/tests/auto/quick/qquicktextinput/data/cursorTestExternal.qml b/tests/auto/quick/qquicktextinput/data/cursorTestExternal.qml new file mode 100644 index 0000000000..9277dcc518 --- /dev/null +++ b/tests/auto/quick/qquicktextinput/data/cursorTestExternal.qml @@ -0,0 +1,15 @@ +import QtQuick 2.0 + +Rectangle { width: 300; height: 300; color: "white" + property string contextualProperty: "Hello" + TextInput { + text: "Hello world!" + id: textInputObject; + objectName: "textInputObject" + cursorDelegate: Cursor { + id:cursorInstance; + objectName: "cursorInstance"; + localProperty: contextualProperty; + } + } +} diff --git a/tests/auto/quick/qquicktextinput/data/cursorTestInline.qml b/tests/auto/quick/qquicktextinput/data/cursorTestInline.qml new file mode 100644 index 0000000000..efc4b191da --- /dev/null +++ b/tests/auto/quick/qquicktextinput/data/cursorTestInline.qml @@ -0,0 +1,15 @@ +import QtQuick 2.0 + +Rectangle { width: 300; height: 300; color: "white" + property string contextualProperty: "Hello" + TextInput { + text: "Hello world!" + id: textInputObject + objectName: "textInputObject" + cursorDelegate: Item { + id:cursorInstance + objectName: "cursorInstance" + property string localProperty: contextualProperty + } + } +} diff --git a/tests/auto/quick/qquicktextinput/data/cursorVisible.qml b/tests/auto/quick/qquicktextinput/data/cursorVisible.qml new file mode 100644 index 0000000000..49e9386947 --- /dev/null +++ b/tests/auto/quick/qquicktextinput/data/cursorVisible.qml @@ -0,0 +1,6 @@ +import QtQuick 2.0 + +Item { + width: 100 + height: 20 +} diff --git a/tests/auto/quick/qquicktextinput/data/echoMode.qml b/tests/auto/quick/qquicktextinput/data/echoMode.qml new file mode 100644 index 0000000000..f8a6cf1c89 --- /dev/null +++ b/tests/auto/quick/qquicktextinput/data/echoMode.qml @@ -0,0 +1,11 @@ +import QtQuick 2.0 + +Rectangle { + property QtObject myInput: input + + width: 400; height: 200; color: "green" + + TextInput { id: input; focus: true + text: "ABCDefgh" + } +} diff --git a/tests/auto/quick/qquicktextinput/data/geometrySignals.qml b/tests/auto/quick/qquicktextinput/data/geometrySignals.qml new file mode 100644 index 0000000000..90855a61cf --- /dev/null +++ b/tests/auto/quick/qquicktextinput/data/geometrySignals.qml @@ -0,0 +1,12 @@ +import QtQuick 2.0 + +Item { + width: 400; height: 500; + property int bindingWidth: text.width + property int bindingHeight: text.height + + TextEdit { + id: text + anchors.fill: parent + } +} diff --git a/tests/auto/quick/qquicktextinput/data/halign_center.png b/tests/auto/quick/qquicktextinput/data/halign_center.png new file mode 100644 index 0000000000..53e09a8e5b Binary files /dev/null and b/tests/auto/quick/qquicktextinput/data/halign_center.png differ diff --git a/tests/auto/quick/qquicktextinput/data/halign_left.png b/tests/auto/quick/qquicktextinput/data/halign_left.png new file mode 100644 index 0000000000..247acbc9df Binary files /dev/null and b/tests/auto/quick/qquicktextinput/data/halign_left.png differ diff --git a/tests/auto/quick/qquicktextinput/data/halign_right.png b/tests/auto/quick/qquicktextinput/data/halign_right.png new file mode 100644 index 0000000000..691bc75c89 Binary files /dev/null and b/tests/auto/quick/qquicktextinput/data/halign_right.png differ diff --git a/tests/auto/quick/qquicktextinput/data/horizontalAlignment.qml b/tests/auto/quick/qquicktextinput/data/horizontalAlignment.qml new file mode 100644 index 0000000000..89934532e3 --- /dev/null +++ b/tests/auto/quick/qquicktextinput/data/horizontalAlignment.qml @@ -0,0 +1,23 @@ +import QtQuick 2.0 + +Rectangle { + id: top + width: 70; height: 70; + + property alias horizontalAlignment: text.horizontalAlignment + property string text: "Test" + + Rectangle { + anchors.centerIn: parent + width: 60 + height: 60 + color: "green" + + TextInput { + objectName: "text" + id: text + anchors.fill: parent + text: top.text + } + } +} diff --git a/tests/auto/quick/qquicktextinput/data/horizontalAlignment_RightToLeft.qml b/tests/auto/quick/qquicktextinput/data/horizontalAlignment_RightToLeft.qml new file mode 100644 index 0000000000..5f88025536 --- /dev/null +++ b/tests/auto/quick/qquicktextinput/data/horizontalAlignment_RightToLeft.qml @@ -0,0 +1,24 @@ +import QtQuick 2.0 + +Rectangle { + id: top + width: 200; height: 70; + + property alias horizontalAlignment: text.horizontalAlignment + property string text: "اختبا" + + Rectangle { + anchors.centerIn: parent + width: 180 + height: 20 + color: "green" + + TextInput { + id: text + objectName: "text" + anchors.fill: parent + text: top.text + focus: true + } + } +} diff --git a/tests/auto/quick/qquicktextinput/data/inputContext.qml b/tests/auto/quick/qquicktextinput/data/inputContext.qml new file mode 100644 index 0000000000..dfc80990c6 --- /dev/null +++ b/tests/auto/quick/qquicktextinput/data/inputContext.qml @@ -0,0 +1,8 @@ +import QtQuick 2.0 + +TextInput { + width: 200 + text: "supercalifra" + focus: true + cursorPosition: 12 +} diff --git a/tests/auto/quick/qquicktextinput/data/inputMethodEvent.qml b/tests/auto/quick/qquicktextinput/data/inputMethodEvent.qml new file mode 100644 index 0000000000..7aefdf28f4 --- /dev/null +++ b/tests/auto/quick/qquicktextinput/data/inputMethodEvent.qml @@ -0,0 +1,6 @@ +import QtQuick 2.0 + +TextInput { + focus: true + autoScroll: false +} diff --git a/tests/auto/quick/qquicktextinput/data/inputmethods.qml b/tests/auto/quick/qquicktextinput/data/inputmethods.qml new file mode 100644 index 0000000000..711e89144c --- /dev/null +++ b/tests/auto/quick/qquicktextinput/data/inputmethods.qml @@ -0,0 +1,7 @@ +import QtQuick 2.0 + +TextInput { + text: "Hello world!" + inputMethodHints: Qt.ImhNoPredictiveText + Keys.onLeftPressed: {} +} diff --git a/tests/auto/quick/qquicktextinput/data/masks.qml b/tests/auto/quick/qquicktextinput/data/masks.qml new file mode 100644 index 0000000000..589b6a3c15 --- /dev/null +++ b/tests/auto/quick/qquicktextinput/data/masks.qml @@ -0,0 +1,7 @@ +import QtQuick 2.0 + +TextInput{ + focus: true + objectName: "myInput" + inputMask: "HHHHhhhh; " +} diff --git a/tests/auto/quick/qquicktextinput/data/maxLength.qml b/tests/auto/quick/qquicktextinput/data/maxLength.qml new file mode 100644 index 0000000000..cca537ed6b --- /dev/null +++ b/tests/auto/quick/qquicktextinput/data/maxLength.qml @@ -0,0 +1,7 @@ +import QtQuick 2.0 + +TextInput{ + focus: true + objectName: "myInput" + maximumLength: 10 +} diff --git a/tests/auto/quick/qquicktextinput/data/mouseselection_true.qml b/tests/auto/quick/qquicktextinput/data/mouseselection_true.qml new file mode 100644 index 0000000000..974041b04a --- /dev/null +++ b/tests/auto/quick/qquicktextinput/data/mouseselection_true.qml @@ -0,0 +1,7 @@ +import QtQuick 2.0 + +TextInput { + focus: true + text: "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ" + selectByMouse: true +} diff --git a/tests/auto/quick/qquicktextinput/data/mouseselectionmode_characters.qml b/tests/auto/quick/qquicktextinput/data/mouseselectionmode_characters.qml new file mode 100644 index 0000000000..f7c658b618 --- /dev/null +++ b/tests/auto/quick/qquicktextinput/data/mouseselectionmode_characters.qml @@ -0,0 +1,8 @@ +import QtQuick 2.0 + +TextInput { + focus: true + text: "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ" + selectByMouse: true + mouseSelectionMode: TextInput.SelectCharacters +} diff --git a/tests/auto/quick/qquicktextinput/data/mouseselectionmode_default.qml b/tests/auto/quick/qquicktextinput/data/mouseselectionmode_default.qml new file mode 100644 index 0000000000..974041b04a --- /dev/null +++ b/tests/auto/quick/qquicktextinput/data/mouseselectionmode_default.qml @@ -0,0 +1,7 @@ +import QtQuick 2.0 + +TextInput { + focus: true + text: "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ" + selectByMouse: true +} diff --git a/tests/auto/quick/qquicktextinput/data/mouseselectionmode_words.qml b/tests/auto/quick/qquicktextinput/data/mouseselectionmode_words.qml new file mode 100644 index 0000000000..20e777e470 --- /dev/null +++ b/tests/auto/quick/qquicktextinput/data/mouseselectionmode_words.qml @@ -0,0 +1,8 @@ +import QtQuick 2.0 + +TextInput { + focus: true + text: "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ" + selectByMouse: true + mouseSelectionMode: TextInput.SelectWords +} diff --git a/tests/auto/quick/qquicktextinput/data/navigation.qml b/tests/auto/quick/qquicktextinput/data/navigation.qml new file mode 100644 index 0000000000..3a7d07b3c7 --- /dev/null +++ b/tests/auto/quick/qquicktextinput/data/navigation.qml @@ -0,0 +1,24 @@ +import QtQuick 2.0 + +Rectangle { + property variant myInput: input + + width: 800; height: 600; color: "blue" + + Item { + id: firstItem; + KeyNavigation.right: input + } + + TextInput { id: input; focus: true + text: "Needs some text" + KeyNavigation.left: firstItem + KeyNavigation.right: lastItem + KeyNavigation.up: firstItem + KeyNavigation.down: lastItem + } + Item { + id: lastItem + KeyNavigation.left: input + } +} diff --git a/tests/auto/quick/qquicktextinput/data/negativeDimensions.qml b/tests/auto/quick/qquicktextinput/data/negativeDimensions.qml new file mode 100644 index 0000000000..7a58c85b1d --- /dev/null +++ b/tests/auto/quick/qquicktextinput/data/negativeDimensions.qml @@ -0,0 +1,19 @@ +import QtQuick 2.0 + +Item { + TextInput { + objectName: "input" + + focus: true + width: -1 + height: -1 + text: "sushi" + + anchors { + left: parent.left; + leftMargin: 5 + top: parent.top + topMargin: font.pixelSize + } + } +} diff --git a/tests/auto/quick/qquicktextinput/data/openInputPanel.qml b/tests/auto/quick/qquicktextinput/data/openInputPanel.qml new file mode 100644 index 0000000000..ca5cb263aa --- /dev/null +++ b/tests/auto/quick/qquicktextinput/data/openInputPanel.qml @@ -0,0 +1,7 @@ +import QtQuick 2.0 + +TextInput { + width: 100; height: 100 + text: "Hello world" + focus: false +} diff --git a/tests/auto/quick/qquicktextinput/data/persistentSelection.qml b/tests/auto/quick/qquicktextinput/data/persistentSelection.qml new file mode 100644 index 0000000000..dea6e48b08 --- /dev/null +++ b/tests/auto/quick/qquicktextinput/data/persistentSelection.qml @@ -0,0 +1,8 @@ +import QtQuick 2.0 + +TextInput { + property string selected: selectedText + + text: "Hello World!" + focus: true +} diff --git a/tests/auto/quick/qquicktextinput/data/positionAt.qml b/tests/auto/quick/qquicktextinput/data/positionAt.qml new file mode 100644 index 0000000000..edb4744107 --- /dev/null +++ b/tests/auto/quick/qquicktextinput/data/positionAt.qml @@ -0,0 +1,9 @@ +import QtQuick 2.0 + +TextInput{ + focus: true + objectName: "myInput" + width: 50 + height: 100 + text: "AAAAAAAAAAAAAAAAAAAAAAAAAAAA" +} diff --git a/tests/auto/quick/qquicktextinput/data/preeditAutoScroll.qml b/tests/auto/quick/qquicktextinput/data/preeditAutoScroll.qml new file mode 100644 index 0000000000..9d98a2e220 --- /dev/null +++ b/tests/auto/quick/qquicktextinput/data/preeditAutoScroll.qml @@ -0,0 +1,7 @@ +import QtQuick 2.0 + +TextInput { + focus: true + text: "super" + autoScroll: true +} diff --git a/tests/auto/quick/qquicktextinput/data/qtbug-19956double.qml b/tests/auto/quick/qquicktextinput/data/qtbug-19956double.qml new file mode 100644 index 0000000000..e9b80fceb2 --- /dev/null +++ b/tests/auto/quick/qquicktextinput/data/qtbug-19956double.qml @@ -0,0 +1,15 @@ +import QtQuick 2.0 + +TextInput { + id: textinput + property real topvalue: 30 + property real bottomvalue: 10 + height: 50 + width: 200 + text: "20" + validator: DoubleValidator { + id: doublevalidator + bottom: bottomvalue + top: topvalue + } +} diff --git a/tests/auto/quick/qquicktextinput/data/qtbug-19956int.qml b/tests/auto/quick/qquicktextinput/data/qtbug-19956int.qml new file mode 100644 index 0000000000..0d70eedb80 --- /dev/null +++ b/tests/auto/quick/qquicktextinput/data/qtbug-19956int.qml @@ -0,0 +1,15 @@ +import QtQuick 2.0 + +TextInput { + id: textinput + property real topvalue: 30 + property real bottomvalue: 10 + height: 50 + width: 200 + text: "20" + validator: IntValidator { + id: intvalidator + bottom: bottomvalue + top: topvalue + } +} diff --git a/tests/auto/quick/qquicktextinput/data/qtbug-19956regexp.qml b/tests/auto/quick/qquicktextinput/data/qtbug-19956regexp.qml new file mode 100644 index 0000000000..b5af13cc4c --- /dev/null +++ b/tests/auto/quick/qquicktextinput/data/qtbug-19956regexp.qml @@ -0,0 +1,13 @@ +import QtQuick 2.0 + +TextInput { + id: textinput + property variant regexvalue + height: 50 + width: 200 + text: "abc" + validator: RegExpValidator { + id: regexpvalidator + regExp: regexvalue + } +} diff --git a/tests/auto/quick/qquicktextinput/data/readOnly.qml b/tests/auto/quick/qquicktextinput/data/readOnly.qml new file mode 100644 index 0000000000..9cda7fbd1d --- /dev/null +++ b/tests/auto/quick/qquicktextinput/data/readOnly.qml @@ -0,0 +1,12 @@ +import QtQuick 2.0 + +Rectangle { + property variant myInput: input + + width: 800; height: 600; color: "blue" + + TextInput { id: input; focus: true + readOnly: true + text: "I am the very model of a modern major general.\n" + } +} diff --git a/tests/auto/quick/qquicktextinput/data/validators.qml b/tests/auto/quick/qquicktextinput/data/validators.qml new file mode 100644 index 0000000000..0ba87e0592 --- /dev/null +++ b/tests/auto/quick/qquicktextinput/data/validators.qml @@ -0,0 +1,29 @@ +import QtQuick 2.0 + +Item { + property variant intInput: intInput + property variant dblInput: dblInput + property variant strInput: strInput + property variant unvalidatedInput: unvalidatedInput + + width: 800; height: 600; + + Column{ + TextInput { id: intInput; + property bool acceptable: acceptableInput + validator: IntValidator{top: 11; bottom: 2} + } + TextInput { id: dblInput; + property bool acceptable: acceptableInput + validator: DoubleValidator{top: 12.12; bottom: 2.93; decimals: 2; notation: DoubleValidator.StandardNotation} + } + TextInput { id: strInput; + property bool acceptable: acceptableInput + validator: RegExpValidator { regExp: /[a-zA-z]{2,4}/ } + } + TextInput { id: unvalidatedInput + property bool acceptable: acceptableInput + } + } + +} diff --git a/tests/auto/quick/qquicktextinput/qquicktextinput.pro b/tests/auto/quick/qquicktextinput/qquicktextinput.pro new file mode 100644 index 0000000000..78b39a2981 --- /dev/null +++ b/tests/auto/quick/qquicktextinput/qquicktextinput.pro @@ -0,0 +1,13 @@ +CONFIG += testcase +TARGET = tst_qquicktextinput +macx:CONFIG -= app_bundle + +SOURCES += tst_qquicktextinput.cpp + +include (../../shared/util.pri) + +testDataFiles.files = data +testDataFiles.path = . +DEPLOYMENT += testDataFiles + +QT += core-private gui-private v8-private qml-private quick-private opengl-private testlib diff --git a/tests/auto/quick/qquicktextinput/tst_qquicktextinput.cpp b/tests/auto/quick/qquicktextinput/tst_qquicktextinput.cpp new file mode 100644 index 0000000000..4141fea26f --- /dev/null +++ b/tests/auto/quick/qquicktextinput/tst_qquicktextinput.cpp @@ -0,0 +1,4706 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include +#include +#include "../../shared/util.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#ifdef Q_OS_MAC +#include +#endif + +#include "qplatformdefs.h" +#include "../../shared/platforminputcontext.h" + +Q_DECLARE_METATYPE(QQuickTextInput::SelectionMode) +DEFINE_BOOL_CONFIG_OPTION(qmlDisableDistanceField, QML_DISABLE_DISTANCEFIELD) + +QString createExpectedFileIfNotFound(const QString& filebasename, const QImage& actual) +{ + // XXX This will be replaced by some clever persistent platform image store. + QString persistent_dir = QQmlDataTest::instance()->dataDirectory(); + QString arch = "unknown-architecture"; // QTest needs to help with this. + + QString expectfile = persistent_dir + QDir::separator() + filebasename + "-" + arch + ".png"; + + if (!QFile::exists(expectfile)) { + actual.save(expectfile); + qWarning() << "created" << expectfile; + } + + return expectfile; +} + +template static T evaluate(QObject *scope, const QString &expression) +{ + QQmlExpression expr(qmlContext(scope), scope, expression); + T result = expr.evaluate().value(); + if (expr.hasError()) + qWarning() << expr.error().toString(); + return result; +} + +typedef QPair Key; + +class tst_qquicktextinput : public QQmlDataTest + +{ + Q_OBJECT +public: + tst_qquicktextinput(); + +private slots: + void cleanup(); + void text(); + void width(); + void font(); + void color(); + void wrap(); + void selection(); + void persistentSelection(); + void isRightToLeft_data(); + void isRightToLeft(); + void moveCursorSelection_data(); + void moveCursorSelection(); + void moveCursorSelectionSequence_data(); + void moveCursorSelectionSequence(); + void dragMouseSelection(); + void mouseSelectionMode_data(); + void mouseSelectionMode(); + void tripleClickSelectsAll(); + + void horizontalAlignment_data(); + void horizontalAlignment(); + void horizontalAlignment_RightToLeft(); + void verticalAlignment(); + + void boundingRect(); + + void positionAt(); + + void maxLength(); + void masks(); + void validators(); + void inputMethods(); + + void passwordCharacter(); + void cursorDelegate_data(); + void cursorDelegate(); + void cursorVisible(); + void cursorRectangle(); + void navigation(); + void navigation_RTL(); + void copyAndPaste(); + void copyAndPasteKeySequence(); + void canPasteEmpty(); + void canPaste(); + void readOnly(); + + void openInputPanel(); + void setHAlignClearCache(); + void focusOutClearSelection(); + + void echoMode(); +#ifdef QT_GUI_PASSWORD_ECHO_DELAY + void passwordEchoDelay(); +#endif + void geometrySignals(); + void contentSize(); + + void preeditAutoScroll(); + void preeditCursorRectangle(); + void inputContextMouseHandler(); + void inputMethodComposing(); + void inputMethodUpdate(); + void cursorRectangleSize(); + + void getText_data(); + void getText(); + void insert_data(); + void insert(); + void remove_data(); + void remove(); + + void keySequence_data(); + void keySequence(); + + void undo_data(); + void undo(); + void redo_data(); + void redo(); + void undo_keypressevents_data(); + void undo_keypressevents(); + + void QTBUG_19956(); + void QTBUG_19956_data(); + void QTBUG_19956_regexp(); + + void negativeDimensions(); + +private: + void simulateKey(QQuickView *, int key); + + void simulateKeys(QWindow *window, const QList &keys); + void simulateKeys(QWindow *window, const QKeySequence &sequence); + + QQmlEngine engine; + QStringList standard; + QStringList colorStrings; +}; + +typedef QList IntList; +Q_DECLARE_METATYPE(IntList) + +typedef QList KeyList; +Q_DECLARE_METATYPE(KeyList) + +void tst_qquicktextinput::simulateKeys(QWindow *window, const QList &keys) +{ + for (int i = 0; i < keys.count(); ++i) { + const int key = keys.at(i).first; + const int modifiers = key & Qt::KeyboardModifierMask; + const QString text = !keys.at(i).second.isNull() ? QString(keys.at(i).second) : QString(); + + QKeyEvent press(QEvent::KeyPress, Qt::Key(key), Qt::KeyboardModifiers(modifiers), text); + QKeyEvent release(QEvent::KeyRelease, Qt::Key(key), Qt::KeyboardModifiers(modifiers), text); + + QGuiApplication::sendEvent(window, &press); + QGuiApplication::sendEvent(window, &release); + } +} + +void tst_qquicktextinput::simulateKeys(QWindow *window, const QKeySequence &sequence) +{ + for (int i = 0; i < sequence.count(); ++i) { + const int key = sequence[i]; + const int modifiers = key & Qt::KeyboardModifierMask; + + QTest::keyClick(window, Qt::Key(key & ~modifiers), Qt::KeyboardModifiers(modifiers)); + } +} + +QList &operator <<(QList &keys, const QKeySequence &sequence) +{ + for (int i = 0; i < sequence.count(); ++i) + keys << Key(sequence[i], QChar()); + return keys; +} + +template QList &operator <<(QList &keys, const char (&characters)[N]) +{ + for (int i = 0; i < N - 1; ++i) { + int key = QTest::asciiToKey(characters[i]); + QChar character = QLatin1Char(characters[i]); + keys << Key(key, character); + } + return keys; +} + +QList &operator <<(QList &keys, Qt::Key key) +{ + keys << Key(key, QChar()); + return keys; +} + +void tst_qquicktextinput::cleanup() +{ + // ensure not even skipped tests with custom input context leave it dangling + QInputMethodPrivate *inputMethodPrivate = QInputMethodPrivate::get(qApp->inputMethod()); + inputMethodPrivate->testContext = 0; +} + +tst_qquicktextinput::tst_qquicktextinput() +{ + standard << "the quick brown fox jumped over the lazy dog" + << "It's supercalifragisiticexpialidocious!" + << "Hello, world!" + << "!dlrow ,olleH" + << " spacey text "; + + colorStrings << "aliceblue" + << "antiquewhite" + << "aqua" + << "darkkhaki" + << "darkolivegreen" + << "dimgray" + << "palevioletred" + << "lightsteelblue" + << "#000000" + << "#AAAAAA" + << "#FFFFFF" + << "#2AC05F"; +} + +void tst_qquicktextinput::text() +{ + { + QQmlComponent textinputComponent(&engine); + textinputComponent.setData("import QtQuick 2.0\nTextInput { text: \"\" }", QUrl()); + QQuickTextInput *textinputObject = qobject_cast(textinputComponent.create()); + + QVERIFY(textinputObject != 0); + QCOMPARE(textinputObject->text(), QString("")); + QCOMPARE(textinputObject->length(), 0); + + delete textinputObject; + } + + for (int i = 0; i < standard.size(); i++) + { + QString componentStr = "import QtQuick 2.0\nTextInput { text: \"" + standard.at(i) + "\" }"; + QQmlComponent textinputComponent(&engine); + textinputComponent.setData(componentStr.toLatin1(), QUrl()); + QQuickTextInput *textinputObject = qobject_cast(textinputComponent.create()); + + QVERIFY(textinputObject != 0); + QCOMPARE(textinputObject->text(), standard.at(i)); + QCOMPARE(textinputObject->length(), standard.at(i).length()); + + delete textinputObject; + } + +} + +void tst_qquicktextinput::width() +{ + // uses Font metrics to find the width for standard + { + QQmlComponent textinputComponent(&engine); + textinputComponent.setData("import QtQuick 2.0\nTextInput { text: \"\" }", QUrl()); + QQuickTextInput *textinputObject = qobject_cast(textinputComponent.create()); + + QVERIFY(textinputObject != 0); + QCOMPARE(textinputObject->width(), 0.0); + + delete textinputObject; + } + + bool requiresUnhintedMetrics = !qmlDisableDistanceField(); + + for (int i = 0; i < standard.size(); i++) + { + QString componentStr = "import QtQuick 2.0\nTextInput { text: \"" + standard.at(i) + "\" }"; + QQmlComponent textinputComponent(&engine); + textinputComponent.setData(componentStr.toLatin1(), QUrl()); + QQuickTextInput *textinputObject = qobject_cast(textinputComponent.create()); + + QString s = standard.at(i); + s.replace(QLatin1Char('\n'), QChar::LineSeparator); + + QTextLayout layout(s); + layout.setFont(textinputObject->font()); + layout.setFlags(Qt::TextExpandTabs | Qt::TextShowMnemonic); + if (requiresUnhintedMetrics) { + QTextOption option; + option.setUseDesignMetrics(true); + layout.setTextOption(option); + } + + layout.beginLayout(); + forever { + QTextLine line = layout.createLine(); + if (!line.isValid()) + break; + } + + layout.endLayout(); + + qreal metricWidth = ceil(layout.boundingRect().width()); + + QVERIFY(textinputObject != 0); + int delta = abs(int(int(textinputObject->width()) - metricWidth)); + QVERIFY(delta <= 3.0); // As best as we can hope for cross-platform. + + delete textinputObject; + } +} + +void tst_qquicktextinput::font() +{ + //test size, then bold, then italic, then family + { + QString componentStr = "import QtQuick 2.0\nTextInput { font.pointSize: 40; text: \"Hello World\" }"; + QQmlComponent textinputComponent(&engine); + textinputComponent.setData(componentStr.toLatin1(), QUrl()); + QQuickTextInput *textinputObject = qobject_cast(textinputComponent.create()); + + QVERIFY(textinputObject != 0); + QCOMPARE(textinputObject->font().pointSize(), 40); + QCOMPARE(textinputObject->font().bold(), false); + QCOMPARE(textinputObject->font().italic(), false); + + delete textinputObject; + } + + { + QString componentStr = "import QtQuick 2.0\nTextInput { font.bold: true; text: \"Hello World\" }"; + QQmlComponent textinputComponent(&engine); + textinputComponent.setData(componentStr.toLatin1(), QUrl()); + QQuickTextInput *textinputObject = qobject_cast(textinputComponent.create()); + + QVERIFY(textinputObject != 0); + QCOMPARE(textinputObject->font().bold(), true); + QCOMPARE(textinputObject->font().italic(), false); + + delete textinputObject; + } + + { + QString componentStr = "import QtQuick 2.0\nTextInput { font.italic: true; text: \"Hello World\" }"; + QQmlComponent textinputComponent(&engine); + textinputComponent.setData(componentStr.toLatin1(), QUrl()); + QQuickTextInput *textinputObject = qobject_cast(textinputComponent.create()); + + QVERIFY(textinputObject != 0); + QCOMPARE(textinputObject->font().italic(), true); + QCOMPARE(textinputObject->font().bold(), false); + + delete textinputObject; + } + + { + QString componentStr = "import QtQuick 2.0\nTextInput { font.family: \"Helvetica\"; text: \"Hello World\" }"; + QQmlComponent textinputComponent(&engine); + textinputComponent.setData(componentStr.toLatin1(), QUrl()); + QQuickTextInput *textinputObject = qobject_cast(textinputComponent.create()); + + QVERIFY(textinputObject != 0); + QCOMPARE(textinputObject->font().family(), QString("Helvetica")); + QCOMPARE(textinputObject->font().bold(), false); + QCOMPARE(textinputObject->font().italic(), false); + + delete textinputObject; + } + + { + QString componentStr = "import QtQuick 2.0\nTextInput { font.family: \"\"; text: \"Hello World\" }"; + QQmlComponent textinputComponent(&engine); + textinputComponent.setData(componentStr.toLatin1(), QUrl()); + QQuickTextInput *textinputObject = qobject_cast(textinputComponent.create()); + + QVERIFY(textinputObject != 0); + QCOMPARE(textinputObject->font().family(), QString("")); + + delete textinputObject; + } +} + +void tst_qquicktextinput::color() +{ + //test color + for (int i = 0; i < colorStrings.size(); i++) + { + QString componentStr = "import QtQuick 2.0\nTextInput { color: \"" + colorStrings.at(i) + "\"; text: \"Hello World\" }"; + QQmlComponent textinputComponent(&engine); + textinputComponent.setData(componentStr.toLatin1(), QUrl()); + QQuickTextInput *textinputObject = qobject_cast(textinputComponent.create()); + QVERIFY(textinputObject != 0); + QCOMPARE(textinputObject->color(), QColor(colorStrings.at(i))); + + delete textinputObject; + } + + //test selection color + for (int i = 0; i < colorStrings.size(); i++) + { + QString componentStr = "import QtQuick 2.0\nTextInput { selectionColor: \"" + colorStrings.at(i) + "\"; text: \"Hello World\" }"; + QQmlComponent textinputComponent(&engine); + textinputComponent.setData(componentStr.toLatin1(), QUrl()); + QQuickTextInput *textinputObject = qobject_cast(textinputComponent.create()); + QVERIFY(textinputObject != 0); + QCOMPARE(textinputObject->selectionColor(), QColor(colorStrings.at(i))); + + delete textinputObject; + } + + //test selected text color + for (int i = 0; i < colorStrings.size(); i++) + { + QString componentStr = "import QtQuick 2.0\nTextInput { selectedTextColor: \"" + colorStrings.at(i) + "\"; text: \"Hello World\" }"; + QQmlComponent textinputComponent(&engine); + textinputComponent.setData(componentStr.toLatin1(), QUrl()); + QQuickTextInput *textinputObject = qobject_cast(textinputComponent.create()); + QVERIFY(textinputObject != 0); + QCOMPARE(textinputObject->selectedTextColor(), QColor(colorStrings.at(i))); + + delete textinputObject; + } + + { + QString colorStr = "#AA001234"; + QColor testColor("#001234"); + testColor.setAlpha(170); + + QString componentStr = "import QtQuick 2.0\nTextInput { color: \"" + colorStr + "\"; text: \"Hello World\" }"; + QQmlComponent textinputComponent(&engine); + textinputComponent.setData(componentStr.toLatin1(), QUrl()); + QQuickTextInput *textinputObject = qobject_cast(textinputComponent.create()); + + QVERIFY(textinputObject != 0); + QCOMPARE(textinputObject->color(), testColor); + + delete textinputObject; + } +} + +void tst_qquicktextinput::wrap() +{ + int textHeight = 0; + // for specified width and wrap set true + { + QQmlComponent textComponent(&engine); + textComponent.setData("import QtQuick 2.0\nTextInput { text: \"Hello\"; wrapMode: Text.WrapAnywhere; width: 300 }", QUrl::fromLocalFile("")); + QQuickTextInput *textObject = qobject_cast(textComponent.create()); + textHeight = textObject->height(); + + QVERIFY(textObject != 0); + QVERIFY(textObject->wrapMode() == QQuickTextInput::WrapAnywhere); + QCOMPARE(textObject->width(), 300.); + + delete textObject; + } + + for (int i = 0; i < standard.count(); i++) { + QString componentStr = "import QtQuick 2.0\nTextInput { wrapMode: Text.WrapAnywhere; width: 30; text: \"" + standard.at(i) + "\" }"; + QQmlComponent textComponent(&engine); + textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); + QQuickTextInput *textObject = qobject_cast(textComponent.create()); + + QVERIFY(textObject != 0); + QCOMPARE(textObject->width(), 30.); + QVERIFY(textObject->height() > textHeight); + + int oldHeight = textObject->height(); + textObject->setWidth(100); + QVERIFY(textObject->height() < oldHeight); + + delete textObject; + } +} + +void tst_qquicktextinput::selection() +{ + QString testStr = standard[0]; + QString componentStr = "import QtQuick 2.0\nTextInput { text: \""+ testStr +"\"; }"; + QQmlComponent textinputComponent(&engine); + textinputComponent.setData(componentStr.toLatin1(), QUrl()); + QQuickTextInput *textinputObject = qobject_cast(textinputComponent.create()); + QVERIFY(textinputObject != 0); + + + //Test selection follows cursor + for (int i=0; i<= testStr.size(); i++) { + textinputObject->setCursorPosition(i); + QCOMPARE(textinputObject->cursorPosition(), i); + QCOMPARE(textinputObject->selectionStart(), i); + QCOMPARE(textinputObject->selectionEnd(), i); + QVERIFY(textinputObject->selectedText().isNull()); + } + + textinputObject->setCursorPosition(0); + QVERIFY(textinputObject->cursorPosition() == 0); + QVERIFY(textinputObject->selectionStart() == 0); + QVERIFY(textinputObject->selectionEnd() == 0); + QVERIFY(textinputObject->selectedText().isNull()); + + // Verify invalid positions are ignored. + textinputObject->setCursorPosition(-1); + QVERIFY(textinputObject->cursorPosition() == 0); + QVERIFY(textinputObject->selectionStart() == 0); + QVERIFY(textinputObject->selectionEnd() == 0); + QVERIFY(textinputObject->selectedText().isNull()); + + textinputObject->setCursorPosition(textinputObject->text().count()+1); + QVERIFY(textinputObject->cursorPosition() == 0); + QVERIFY(textinputObject->selectionStart() == 0); + QVERIFY(textinputObject->selectionEnd() == 0); + QVERIFY(textinputObject->selectedText().isNull()); + + //Test selection + for (int i=0; i<= testStr.size(); i++) { + textinputObject->select(0,i); + QCOMPARE(testStr.mid(0,i), textinputObject->selectedText()); + } + for (int i=0; i<= testStr.size(); i++) { + textinputObject->select(i,testStr.size()); + QCOMPARE(testStr.mid(i,testStr.size()-i), textinputObject->selectedText()); + } + + textinputObject->setCursorPosition(0); + QVERIFY(textinputObject->cursorPosition() == 0); + QVERIFY(textinputObject->selectionStart() == 0); + QVERIFY(textinputObject->selectionEnd() == 0); + QVERIFY(textinputObject->selectedText().isNull()); + + //Test Error Ignoring behaviour + textinputObject->setCursorPosition(0); + QVERIFY(textinputObject->selectedText().isNull()); + textinputObject->select(-10,0); + QVERIFY(textinputObject->selectedText().isNull()); + textinputObject->select(100,110); + QVERIFY(textinputObject->selectedText().isNull()); + textinputObject->select(0,-10); + QVERIFY(textinputObject->selectedText().isNull()); + textinputObject->select(0,100); + QVERIFY(textinputObject->selectedText().isNull()); + textinputObject->select(0,10); + QVERIFY(textinputObject->selectedText().size() == 10); + textinputObject->select(-10,10); + QVERIFY(textinputObject->selectedText().size() == 10); + textinputObject->select(100,101); + QVERIFY(textinputObject->selectedText().size() == 10); + textinputObject->select(0,-10); + QVERIFY(textinputObject->selectedText().size() == 10); + textinputObject->select(0,100); + QVERIFY(textinputObject->selectedText().size() == 10); + + textinputObject->deselect(); + QVERIFY(textinputObject->selectedText().isNull()); + textinputObject->select(0,10); + QVERIFY(textinputObject->selectedText().size() == 10); + textinputObject->deselect(); + QVERIFY(textinputObject->selectedText().isNull()); + + // test input method selection + QSignalSpy selectionSpy(textinputObject, SIGNAL(selectedTextChanged())); + textinputObject->setFocus(true); + { + QList attributes; + attributes << QInputMethodEvent::Attribute(QInputMethodEvent::Selection, 12, 5, QVariant()); + QInputMethodEvent event("", attributes); + QGuiApplication::sendEvent(textinputObject, &event); + } + QCOMPARE(selectionSpy.count(), 1); + QCOMPARE(textinputObject->selectionStart(), 12); + QCOMPARE(textinputObject->selectionEnd(), 17); + + delete textinputObject; +} + +void tst_qquicktextinput::persistentSelection() +{ + QQuickView canvas(testFileUrl("persistentSelection.qml")); + canvas.show(); + canvas.requestActivateWindow(); + QTest::qWaitForWindowShown(&canvas); + QTRY_COMPARE(&canvas, qGuiApp->focusWindow()); + canvas.requestActivateWindow(); + + QQuickTextInput *input = qobject_cast(canvas.rootObject()); + QVERIFY(input); + QVERIFY(input->hasActiveFocus()); + + QSignalSpy spy(input, SIGNAL(persistentSelectionChanged())); + + QCOMPARE(input->persistentSelection(), false); + + input->setPersistentSelection(false); + QCOMPARE(input->persistentSelection(), false); + QCOMPARE(spy.count(), 0); + + input->select(1, 4); + QCOMPARE(input->property("selected").toString(), QLatin1String("ell")); + + input->setFocus(false); + QCOMPARE(input->property("selected").toString(), QString()); + + input->setFocus(true); + QCOMPARE(input->property("selected").toString(), QString()); + + input->setPersistentSelection(true); + QCOMPARE(input->persistentSelection(), true); + QCOMPARE(spy.count(), 1); + + input->select(1, 4); + QCOMPARE(input->property("selected").toString(), QLatin1String("ell")); + + input->setFocus(false); + QCOMPARE(input->property("selected").toString(), QLatin1String("ell")); + + input->setFocus(true); + QCOMPARE(input->property("selected").toString(), QLatin1String("ell")); +} + +void tst_qquicktextinput::isRightToLeft_data() +{ + QTest::addColumn("text"); + QTest::addColumn("emptyString"); + QTest::addColumn("firstCharacter"); + QTest::addColumn("lastCharacter"); + QTest::addColumn("middleCharacter"); + QTest::addColumn("startString"); + QTest::addColumn("midString"); + QTest::addColumn("endString"); + + const quint16 arabic_str[] = { 0x0638, 0x0643, 0x00646, 0x0647, 0x0633, 0x0638, 0x0643, 0x00646, 0x0647, 0x0633, 0x0647}; + QTest::newRow("Empty") << "" << false << false << false << false << false << false << false; + QTest::newRow("Neutral") << "23244242" << false << false << false << false << false << false << false; + QTest::newRow("LTR") << "Hello world" << false << false << false << false << false << false << false; + QTest::newRow("RTL") << QString::fromUtf16(arabic_str, 11) << false << true << true << true << true << true << true; + QTest::newRow("Bidi RTL + LTR + RTL") << QString::fromUtf16(arabic_str, 11) + QString("Hello world") + QString::fromUtf16(arabic_str, 11) << false << true << true << false << true << true << true; + QTest::newRow("Bidi LTR + RTL + LTR") << QString("Hello world") + QString::fromUtf16(arabic_str, 11) + QString("Hello world") << false << false << false << true << false << false << false; +} + +void tst_qquicktextinput::isRightToLeft() +{ + QFETCH(QString, text); + QFETCH(bool, emptyString); + QFETCH(bool, firstCharacter); + QFETCH(bool, lastCharacter); + QFETCH(bool, middleCharacter); + QFETCH(bool, startString); + QFETCH(bool, midString); + QFETCH(bool, endString); + + QQuickTextInput textInput; + textInput.setText(text); + + // first test that the right string is delivered to the QString::isRightToLeft() + QCOMPARE(textInput.isRightToLeft(0,0), text.mid(0,0).isRightToLeft()); + QCOMPARE(textInput.isRightToLeft(0,1), text.mid(0,1).isRightToLeft()); + QCOMPARE(textInput.isRightToLeft(text.count()-2, text.count()-1), text.mid(text.count()-2, text.count()-1).isRightToLeft()); + QCOMPARE(textInput.isRightToLeft(text.count()/2, text.count()/2 + 1), text.mid(text.count()/2, text.count()/2 + 1).isRightToLeft()); + QCOMPARE(textInput.isRightToLeft(0,text.count()/4), text.mid(0,text.count()/4).isRightToLeft()); + QCOMPARE(textInput.isRightToLeft(text.count()/4,3*text.count()/4), text.mid(text.count()/4,3*text.count()/4).isRightToLeft()); + if (text.isEmpty()) + QTest::ignoreMessage(QtWarningMsg, ": QML TextInput: isRightToLeft(start, end) called with the end property being smaller than the start."); + QCOMPARE(textInput.isRightToLeft(3*text.count()/4,text.count()-1), text.mid(3*text.count()/4,text.count()-1).isRightToLeft()); + + // then test that the feature actually works + QCOMPARE(textInput.isRightToLeft(0,0), emptyString); + QCOMPARE(textInput.isRightToLeft(0,1), firstCharacter); + QCOMPARE(textInput.isRightToLeft(text.count()-2, text.count()-1), lastCharacter); + QCOMPARE(textInput.isRightToLeft(text.count()/2, text.count()/2 + 1), middleCharacter); + QCOMPARE(textInput.isRightToLeft(0,text.count()/4), startString); + QCOMPARE(textInput.isRightToLeft(text.count()/4,3*text.count()/4), midString); + if (text.isEmpty()) + QTest::ignoreMessage(QtWarningMsg, ": QML TextInput: isRightToLeft(start, end) called with the end property being smaller than the start."); + QCOMPARE(textInput.isRightToLeft(3*text.count()/4,text.count()-1), endString); +} + +void tst_qquicktextinput::moveCursorSelection_data() +{ + QTest::addColumn("testStr"); + QTest::addColumn("cursorPosition"); + QTest::addColumn("movePosition"); + QTest::addColumn("mode"); + QTest::addColumn("selectionStart"); + QTest::addColumn("selectionEnd"); + QTest::addColumn("reversible"); + + // () contains the text selected by the cursor. + // <> contains the actual selection. + + QTest::newRow("(t)he|characters") + << standard[0] << 0 << 1 << QQuickTextInput::SelectCharacters << 0 << 1 << true; + QTest::newRow("do(g)|characters") + << standard[0] << 43 << 44 << QQuickTextInput::SelectCharacters << 43 << 44 << true; + QTest::newRow("jum(p)ed|characters") + << standard[0] << 23 << 24 << QQuickTextInput::SelectCharacters << 23 << 24 << true; + QTest::newRow("jumped( )over|characters") + << standard[0] << 26 << 27 << QQuickTextInput::SelectCharacters << 26 << 27 << true; + QTest::newRow("(the )|characters") + << standard[0] << 0 << 4 << QQuickTextInput::SelectCharacters << 0 << 4 << true; + QTest::newRow("( dog)|characters") + << standard[0] << 40 << 44 << QQuickTextInput::SelectCharacters << 40 << 44 << true; + QTest::newRow("( jumped )|characters") + << standard[0] << 19 << 27 << QQuickTextInput::SelectCharacters << 19 << 27 << true; + QTest::newRow("th(e qu)ick|characters") + << standard[0] << 2 << 6 << QQuickTextInput::SelectCharacters << 2 << 6 << true; + QTest::newRow("la(zy d)og|characters") + << standard[0] << 38 << 42 << QQuickTextInput::SelectCharacters << 38 << 42 << true; + QTest::newRow("jum(ped ov)er|characters") + << standard[0] << 23 << 29 << QQuickTextInput::SelectCharacters << 23 << 29 << true; + QTest::newRow("()the|characters") + << standard[0] << 0 << 0 << QQuickTextInput::SelectCharacters << 0 << 0 << true; + QTest::newRow("dog()|characters") + << standard[0] << 44 << 44 << QQuickTextInput::SelectCharacters << 44 << 44 << true; + QTest::newRow("jum()ped|characters") + << standard[0] << 23 << 23 << QQuickTextInput::SelectCharacters << 23 << 23 << true; + + QTest::newRow("<(t)he>|words") + << standard[0] << 0 << 1 << QQuickTextInput::SelectWords << 0 << 3 << true; + QTest::newRow("|words") + << standard[0] << 43 << 44 << QQuickTextInput::SelectWords << 41 << 44 << true; + QTest::newRow("|words") + << standard[0] << 23 << 24 << QQuickTextInput::SelectWords << 20 << 26 << true; + QTest::newRow("over|words,ltr") + << standard[0] << 26 << 27 << QQuickTextInput::SelectWords << 20 << 27 << false; + QTest::newRow("jumped<( )over>|words,rtl") + << standard[0] << 27 << 26 << QQuickTextInput::SelectWords << 26 << 31 << false; + QTest::newRow("<(the )>quick|words,ltr") + << standard[0] << 0 << 4 << QQuickTextInput::SelectWords << 0 << 4 << false; + QTest::newRow("<(the )quick>|words,rtl") + << standard[0] << 4 << 0 << QQuickTextInput::SelectWords << 0 << 9 << false; + QTest::newRow("|words,ltr") + << standard[0] << 40 << 44 << QQuickTextInput::SelectWords << 36 << 44 << false; + QTest::newRow("lazy<( dog)>|words,rtl") + << standard[0] << 44 << 40 << QQuickTextInput::SelectWords << 40 << 44 << false; + QTest::newRow("over|words,ltr") + << standard[0] << 19 << 27 << QQuickTextInput::SelectWords << 16 << 27 << false; + QTest::newRow("fox<( jumped )over>|words,rtl") + << standard[0] << 27 << 19 << QQuickTextInput::SelectWords << 19 << 31 << false; + QTest::newRow("|words") + << standard[0] << 2 << 6 << QQuickTextInput::SelectWords << 0 << 9 << true; + QTest::newRow("") + << standard[0] << 38 << 42 << QQuickTextInput::SelectWords << 36 << 44 << true; + QTest::newRow("|words") + << standard[0] << 23 << 29 << QQuickTextInput::SelectWords << 20 << 31 << true; + QTest::newRow("<()>the|words") + << standard[0] << 0 << 0 << QQuickTextInput::SelectWords << 0 << 0 << true; + QTest::newRow("dog<()>|words") + << standard[0] << 44 << 44 << QQuickTextInput::SelectWords << 44 << 44 << true; + QTest::newRow("jum<()>ped|words") + << standard[0] << 23 << 23 << QQuickTextInput::SelectWords << 23 << 23 << true; + + QTest::newRow("Hello<(,)> |words") + << standard[2] << 5 << 6 << QQuickTextInput::SelectWords << 5 << 6 << true; + QTest::newRow("Hello<(, )>world|words,ltr") + << standard[2] << 5 << 7 << QQuickTextInput::SelectWords << 5 << 7 << false; + QTest::newRow("Hello<(, )world>|words,rtl") + << standard[2] << 7 << 5 << QQuickTextInput::SelectWords << 5 << 12 << false; + QTest::newRow("world|words,ltr") + << standard[2] << 3 << 7 << QQuickTextInput::SelectWords << 0 << 7 << false; + QTest::newRow("|words,rtl") + << standard[2] << 7 << 3 << QQuickTextInput::SelectWords << 0 << 12 << false; + QTest::newRow(",|words") + << standard[2] << 3 << 5 << QQuickTextInput::SelectWords << 0 << 5 << true; + QTest::newRow("Hello<()>,|words") + << standard[2] << 5 << 5 << QQuickTextInput::SelectWords << 5 << 5 << true; + QTest::newRow("Hello,<()>|words") + << standard[2] << 6 << 6 << QQuickTextInput::SelectWords << 6 << 6 << true; + QTest::newRow("Hello<,( )>world|words,ltr") + << standard[2] << 6 << 7 << QQuickTextInput::SelectWords << 5 << 7 << false; + QTest::newRow("Hello,<( )world>|words,rtl") + << standard[2] << 7 << 6 << QQuickTextInput::SelectWords << 6 << 12 << false; + QTest::newRow("Hello<,( world)>|words,ltr") + << standard[2] << 6 << 12 << QQuickTextInput::SelectWords << 5 << 12 << false; + QTest::newRow("Hello,<( world)>|words,rtl") + << standard[2] << 12 << 6 << QQuickTextInput::SelectWords << 6 << 12 << false; + QTest::newRow("Hello<,( world!)>|words,ltr") + << standard[2] << 6 << 13 << QQuickTextInput::SelectWords << 5 << 13 << false; + QTest::newRow("Hello,<( world!)>|words,rtl") + << standard[2] << 13 << 6 << QQuickTextInput::SelectWords << 6 << 13 << false; + QTest::newRow("Hello<(, world!)>|words") + << standard[2] << 5 << 13 << QQuickTextInput::SelectWords << 5 << 13 << true; + // Fails due to an issue with QTextBoundaryFinder and punctuation at the end of strings. + // QTBUG-11365 + // QTest::newRow("world<(!)>|words") + // << standard[2] << 12 << 13 << QQuickTextInput::SelectWords << 12 << 13 << true; + QTest::newRow("world!<()>)|words") + << standard[2] << 13 << 13 << QQuickTextInput::SelectWords << 13 << 13 << true; + QTest::newRow("world<()>!)|words") + << standard[2] << 12 << 12 << QQuickTextInput::SelectWords << 12 << 12 << true; + + QTest::newRow("<(,)>olleH |words") + << standard[3] << 7 << 8 << QQuickTextInput::SelectWords << 7 << 8 << true; + QTest::newRow("olleH|words,ltr") + << standard[3] << 6 << 8 << QQuickTextInput::SelectWords << 1 << 8 << false; + QTest::newRow("dlrow<( ,)>olleH|words,rtl") + << standard[3] << 8 << 6 << QQuickTextInput::SelectWords << 6 << 8 << false; + QTest::newRow("|words,ltr") + << standard[3] << 6 << 10 << QQuickTextInput::SelectWords << 1 << 13 << false; + QTest::newRow("dlrow<( ,ol)leH>|words,rtl") + << standard[3] << 10 << 6 << QQuickTextInput::SelectWords << 6 << 13 << false; + QTest::newRow(",<(ol)leH>,|words") + << standard[3] << 8 << 10 << QQuickTextInput::SelectWords << 8 << 13 << true; + QTest::newRow(",<()>olleH|words") + << standard[3] << 8 << 8 << QQuickTextInput::SelectWords << 8 << 8 << true; + QTest::newRow("<()>,olleH|words") + << standard[3] << 7 << 7 << QQuickTextInput::SelectWords << 7 << 7 << true; + QTest::newRow(",olleH|words,ltr") + << standard[3] << 6 << 7 << QQuickTextInput::SelectWords << 1 << 7 << false; + QTest::newRow("dlrow<( ),>olleH|words,rtl") + << standard[3] << 7 << 6 << QQuickTextInput::SelectWords << 6 << 8 << false; + QTest::newRow("<(dlrow )>,olleH|words,ltr") + << standard[3] << 1 << 7 << QQuickTextInput::SelectWords << 1 << 7 << false; + QTest::newRow("<(dlrow ),>olleH|words,rtl") + << standard[3] << 7 << 1 << QQuickTextInput::SelectWords << 1 << 8 << false; + QTest::newRow("<(!dlrow )>,olleH|words,ltr") + << standard[3] << 0 << 7 << QQuickTextInput::SelectWords << 0 << 7 << false; + QTest::newRow("<(!dlrow ),>olleH|words,rtl") + << standard[3] << 7 << 0 << QQuickTextInput::SelectWords << 0 << 8 << false; + QTest::newRow("(!dlrow ,)olleH|words") + << standard[3] << 0 << 8 << QQuickTextInput::SelectWords << 0 << 8 << true; + QTest::newRow("<(!)>dlrow|words") + << standard[3] << 0 << 1 << QQuickTextInput::SelectWords << 0 << 1 << true; + QTest::newRow("<()>!dlrow|words") + << standard[3] << 0 << 0 << QQuickTextInput::SelectWords << 0 << 0 << true; + QTest::newRow("!<()>dlrow|words") + << standard[3] << 1 << 1 << QQuickTextInput::SelectWords << 1 << 1 << true; + + QTest::newRow(" text |words") + << standard[4] << 1 << 4 << QQuickTextInput::SelectWords << 1 << 7 << true; + QTest::newRow(" spacey |words") + << standard[4] << 11 << 13 << QQuickTextInput::SelectWords << 10 << 14 << false; // Should be reversible. QTBUG-11365 + QTest::newRow("<( )>spacey text |words|ltr") + << standard[4] << 0 << 1 << QQuickTextInput::SelectWords << 0 << 1 << false; + QTest::newRow("<( )spacey> text |words|rtl") + << standard[4] << 1 << 0 << QQuickTextInput::SelectWords << 0 << 7 << false; + QTest::newRow("spacey |words|ltr") + << standard[4] << 14 << 15 << QQuickTextInput::SelectWords << 10 << 15 << false; +// QTBUG-11365 +// QTest::newRow("spacey text<( )>|words|rtl") +// << standard[4] << 15 << 14 << QQuickTextInput::SelectWords << 14 << 15 << false; + QTest::newRow("<()> spacey text |words") + << standard[4] << 0 << 0 << QQuickTextInput::SelectWords << 0 << 0 << false; + QTest::newRow(" spacey text <()>|words") + << standard[4] << 15 << 15 << QQuickTextInput::SelectWords << 15 << 15 << false; +} + +void tst_qquicktextinput::moveCursorSelection() +{ + QFETCH(QString, testStr); + QFETCH(int, cursorPosition); + QFETCH(int, movePosition); + QFETCH(QQuickTextInput::SelectionMode, mode); + QFETCH(int, selectionStart); + QFETCH(int, selectionEnd); + QFETCH(bool, reversible); + + QString componentStr = "import QtQuick 2.0\nTextInput { text: \""+ testStr +"\"; }"; + QQmlComponent textinputComponent(&engine); + textinputComponent.setData(componentStr.toLatin1(), QUrl()); + QQuickTextInput *textinputObject = qobject_cast(textinputComponent.create()); + QVERIFY(textinputObject != 0); + + textinputObject->setCursorPosition(cursorPosition); + textinputObject->moveCursorSelection(movePosition, mode); + + QCOMPARE(textinputObject->selectedText(), testStr.mid(selectionStart, selectionEnd - selectionStart)); + QCOMPARE(textinputObject->selectionStart(), selectionStart); + QCOMPARE(textinputObject->selectionEnd(), selectionEnd); + + if (reversible) { + textinputObject->setCursorPosition(movePosition); + textinputObject->moveCursorSelection(cursorPosition, mode); + + QCOMPARE(textinputObject->selectedText(), testStr.mid(selectionStart, selectionEnd - selectionStart)); + QCOMPARE(textinputObject->selectionStart(), selectionStart); + QCOMPARE(textinputObject->selectionEnd(), selectionEnd); + } + + delete textinputObject; +} + +void tst_qquicktextinput::moveCursorSelectionSequence_data() +{ + QTest::addColumn("testStr"); + QTest::addColumn("cursorPosition"); + QTest::addColumn("movePosition1"); + QTest::addColumn("movePosition2"); + QTest::addColumn("selection1Start"); + QTest::addColumn("selection1End"); + QTest::addColumn("selection2Start"); + QTest::addColumn("selection2End"); + + // () contains the text selected by the cursor. + // <> contains the actual selection. + // ^ is the revised cursor position. + // {} contains the revised selection. + + QTest::newRow("the { f^ox} jumped|ltr") + << standard[0] + << 9 << 13 << 17 + << 4 << 15 + << 4 << 19; + QTest::newRow("the quick<( {bro)wn> f^ox} jumped|rtl") + << standard[0] + << 13 << 9 << 17 + << 9 << 15 + << 10 << 19; + QTest::newRow("the { ^}fox jumped|ltr") + << standard[0] + << 9 << 13 << 16 + << 4 << 15 + << 4 << 16; + QTest::newRow("the quick<( {bro)wn> ^}fox jumped|rtl") + << standard[0] + << 13 << 9 << 16 + << 9 << 15 + << 10 << 16; + QTest::newRow("the {} fox jumped|ltr") + << standard[0] + << 9 << 13 << 15 + << 4 << 15 + << 4 << 15; + QTest::newRow("the quick<( {bro)wn^>} f^ox jumped|rtl") + << standard[0] + << 13 << 9 << 15 + << 9 << 15 + << 10 << 15; + QTest::newRow("the { fox|ltr") + << standard[0] + << 9 << 13 << 10 + << 4 << 15 + << 4 << 10; + QTest::newRow("the quick<( {^bro)wn>} fox|rtl") + << standard[0] + << 13 << 9 << 10 + << 9 << 15 + << 10 << 15; + QTest::newRow("the { fox|ltr") + << standard[0] + << 9 << 13 << 9 + << 4 << 15 + << 4 << 9; + QTest::newRow("the quick{<(^ bro)wn>} fox|rtl") + << standard[0] + << 13 << 9 << 9 + << 9 << 15 + << 9 << 15; + QTest::newRow("the { fox|ltr") + << standard[0] + << 9 << 13 << 7 + << 4 << 15 + << 4 << 9; + QTest::newRow("the { fox|rtl") + << standard[0] + << 13 << 9 << 7 + << 9 << 15 + << 4 << 15; + QTest::newRow("the {<^quick}( bro)wn> fox|ltr") + << standard[0] + << 9 << 13 << 4 + << 4 << 15 + << 4 << 9; + QTest::newRow("the {<^quick}( bro)wn> fox|rtl") + << standard[0] + << 13 << 9 << 4 + << 9 << 15 + << 4 << 15; + QTest::newRow("the{^ fox|ltr") + << standard[0] + << 9 << 13 << 3 + << 4 << 15 + << 3 << 9; + QTest::newRow("the{^ fox|rtl") + << standard[0] + << 13 << 9 << 3 + << 9 << 15 + << 3 << 15; + QTest::newRow("{t^he fox|ltr") + << standard[0] + << 9 << 13 << 1 + << 4 << 15 + << 0 << 9; + QTest::newRow("{t^he fox|rtl") + << standard[0] + << 13 << 9 << 1 + << 9 << 15 + << 0 << 15; + + QTest::newRow("{, w^orld}!|ltr") + << standard[2] + << 2 << 4 << 8 + << 0 << 5 + << 0 << 12; + QTest::newRow("{, w^orld}!|rtl") + << standard[2] + << 4 << 2 << 8 + << 0 << 5 + << 0 << 12; + + QTest::newRow("!{dlro^w ,}|ltr") + << standard[3] + << 9 << 11 << 5 + << 8 << 13 + << 1 << 13; + QTest::newRow("!{dlro^w ,}|rtl") + << standard[3] + << 11 << 9 << 5 + << 8 << 13 + << 1 << 13; + + QTest::newRow("{<(^} sp)acey> text |ltr") + << standard[4] + << 0 << 3 << 0 + << 0 << 7 + << 0 << 0; + QTest::newRow("{<( ^}sp)acey> text |ltr") + << standard[4] + << 0 << 3 << 1 + << 0 << 7 + << 0 << 1; + QTest::newRow("<( {s^p)acey>} text |rtl") + << standard[4] + << 3 << 0 << 2 + << 0 << 7 + << 1 << 7; + QTest::newRow("<( {^sp)acey>} text |rtl") + << standard[4] + << 3 << 0 << 1 + << 0 << 7 + << 1 << 7; + + QTest::newRow(" spacey }|rtl") + << standard[4] + << 15 << 12 << 15 + << 10 << 15 + << 15 << 15; +// QTBUG-11365 +// QTest::newRow(" spacey }|rtl") +// << standard[4] +// << 15 << 12 << 14 +// << 10 << 15 +// << 14 << 15; + QTest::newRow(" spacey {|ltr") + << standard[4] + << 12 << 15 << 13 + << 10 << 15 + << 10 << 14; +// QTBUG-11365 +// QTest::newRow(" spacey {|ltr") +// << standard[4] +// << 12 << 15 << 14 +// << 10 << 15 +// << 10 << 14; +} + +void tst_qquicktextinput::moveCursorSelectionSequence() +{ + QFETCH(QString, testStr); + QFETCH(int, cursorPosition); + QFETCH(int, movePosition1); + QFETCH(int, movePosition2); + QFETCH(int, selection1Start); + QFETCH(int, selection1End); + QFETCH(int, selection2Start); + QFETCH(int, selection2End); + + QString componentStr = "import QtQuick 2.0\nTextInput { text: \""+ testStr +"\"; }"; + QQmlComponent textinputComponent(&engine); + textinputComponent.setData(componentStr.toLatin1(), QUrl()); + QQuickTextInput *textinputObject = qobject_cast(textinputComponent.create()); + QVERIFY(textinputObject != 0); + + textinputObject->setCursorPosition(cursorPosition); + + textinputObject->moveCursorSelection(movePosition1, QQuickTextInput::SelectWords); + QCOMPARE(textinputObject->selectedText(), testStr.mid(selection1Start, selection1End - selection1Start)); + QCOMPARE(textinputObject->selectionStart(), selection1Start); + QCOMPARE(textinputObject->selectionEnd(), selection1End); + + textinputObject->moveCursorSelection(movePosition2, QQuickTextInput::SelectWords); + QCOMPARE(textinputObject->selectedText(), testStr.mid(selection2Start, selection2End - selection2Start)); + QCOMPARE(textinputObject->selectionStart(), selection2Start); + QCOMPARE(textinputObject->selectionEnd(), selection2End); + + delete textinputObject; +} + +void tst_qquicktextinput::dragMouseSelection() +{ + QString qmlfile = testFile("mouseselection_true.qml"); + + QQuickView canvas(QUrl::fromLocalFile(qmlfile)); + + canvas.show(); + canvas.requestActivateWindow(); + QTest::qWaitForWindowShown(&canvas); + + QTRY_COMPARE(&canvas, qGuiApp->focusWindow()); + + QVERIFY(canvas.rootObject() != 0); + QQuickTextInput *textInputObject = qobject_cast(canvas.rootObject()); + QVERIFY(textInputObject != 0); + + // press-and-drag-and-release from x1 to x2 + int x1 = 10; + int x2 = 70; + int y = textInputObject->height()/2; + QTest::mousePress(&canvas, Qt::LeftButton, 0, QPoint(x1,y)); + QTest::mouseMove(&canvas, QPoint(x2, y)); + QTest::mouseRelease(&canvas, Qt::LeftButton, 0, QPoint(x2,y)); + QTest::qWait(100); + QString str1; + QVERIFY((str1 = textInputObject->selectedText()).length() > 3); + QVERIFY(str1.length() > 3); + + // press and drag the current selection. + x1 = 40; + x2 = 100; + QTest::mousePress(&canvas, Qt::LeftButton, 0, QPoint(x1,y)); + QTest::mouseMove(&canvas, QPoint(x2, y)); + QTest::mouseRelease(&canvas, Qt::LeftButton, 0, QPoint(x2,y)); + QTest::qWait(300); + QString str2 = textInputObject->selectedText(); + QVERIFY(str2.length() > 3); + + QVERIFY(str1 != str2); +} + +void tst_qquicktextinput::mouseSelectionMode_data() +{ + QTest::addColumn("qmlfile"); + QTest::addColumn("selectWords"); + + // import installed + QTest::newRow("SelectWords") << testFile("mouseselectionmode_words.qml") << true; + QTest::newRow("SelectCharacters") << testFile("mouseselectionmode_characters.qml") << false; + QTest::newRow("default") << testFile("mouseselectionmode_default.qml") << false; +} + +void tst_qquicktextinput::mouseSelectionMode() +{ + QFETCH(QString, qmlfile); + QFETCH(bool, selectWords); + + QString text = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"; + + QQuickView canvas(QUrl::fromLocalFile(qmlfile)); + + canvas.show(); + canvas.requestActivateWindow(); + QTest::qWaitForWindowShown(&canvas); + QTRY_COMPARE(&canvas, qGuiApp->focusWindow()); + + QVERIFY(canvas.rootObject() != 0); + QQuickTextInput *textInputObject = qobject_cast(canvas.rootObject()); + QVERIFY(textInputObject != 0); + + // press-and-drag-and-release from x1 to x2 + int x1 = 10; + int x2 = 70; + int y = textInputObject->height()/2; + QTest::mousePress(&canvas, Qt::LeftButton, 0, QPoint(x1,y)); + QTest::mouseMove(&canvas, QPoint(x2,y)); // doesn't work + QTest::mouseRelease(&canvas, Qt::LeftButton, 0, QPoint(x2,y)); + QTest::qWait(300); + if (selectWords) { + QTRY_COMPARE(textInputObject->selectedText(), text); + } else { + QTRY_VERIFY(textInputObject->selectedText().length() > 3); + QVERIFY(textInputObject->selectedText() != text); + } +} + +void tst_qquicktextinput::horizontalAlignment_data() +{ + QTest::addColumn("hAlign"); + QTest::addColumn("expectfile"); + + QTest::newRow("L") << int(Qt::AlignLeft) << "halign_left"; + QTest::newRow("R") << int(Qt::AlignRight) << "halign_right"; + QTest::newRow("C") << int(Qt::AlignHCenter) << "halign_center"; +} + +void tst_qquicktextinput::horizontalAlignment() +{ + QSKIP("Image comparison of text is almost guaranteed to fail during development"); + + QFETCH(int, hAlign); + QFETCH(QString, expectfile); + + QQuickView canvas(testFileUrl("horizontalAlignment.qml")); + + canvas.show(); + canvas.requestActivateWindow(); + QTest::qWaitForWindowShown(&canvas); + QTRY_COMPARE(&canvas, qGuiApp->focusWindow()); + QObject *ob = canvas.rootObject(); + QVERIFY(ob != 0); + ob->setProperty("horizontalAlignment",hAlign); + QImage actual = canvas.grabFrameBuffer(); + + expectfile = createExpectedFileIfNotFound(expectfile, actual); + + QImage expect(expectfile); + + QCOMPARE(actual,expect); +} + +void tst_qquicktextinput::horizontalAlignment_RightToLeft() +{ + PlatformInputContext platformInputContext; + QInputMethodPrivate *inputMethodPrivate = QInputMethodPrivate::get(qApp->inputMethod()); + inputMethodPrivate->testContext = &platformInputContext; + + QQuickView canvas(testFileUrl("horizontalAlignment_RightToLeft.qml")); + QQuickTextInput *textInput = canvas.rootObject()->findChild("text"); + QVERIFY(textInput != 0); + canvas.show(); + + const QString rtlText = textInput->text(); + + QQuickTextInputPrivate *textInputPrivate = QQuickTextInputPrivate::get(textInput); + QVERIFY(textInputPrivate != 0); + QVERIFY(textInputPrivate->boundingRect.right() - textInputPrivate->hscroll >= textInput->width() - 1); + QVERIFY(textInputPrivate->boundingRect.right() - textInputPrivate->hscroll <= textInput->width() + 1); + + // implicit alignment should follow the reading direction of RTL text + QCOMPARE(textInput->hAlign(), QQuickTextInput::AlignRight); + QCOMPARE(textInput->effectiveHAlign(), textInput->hAlign()); + QVERIFY(textInputPrivate->boundingRect.right() - textInputPrivate->hscroll >= textInput->width() - 1); + QVERIFY(textInputPrivate->boundingRect.right() - textInputPrivate->hscroll <= textInput->width() + 1); + + // explicitly left aligned + textInput->setHAlign(QQuickTextInput::AlignLeft); + QCOMPARE(textInput->hAlign(), QQuickTextInput::AlignLeft); + QCOMPARE(textInput->effectiveHAlign(), textInput->hAlign()); + QCOMPARE(textInputPrivate->boundingRect.left() - textInputPrivate->hscroll, qreal(0)); + + // explicitly right aligned + textInput->setHAlign(QQuickTextInput::AlignRight); + QCOMPARE(textInput->effectiveHAlign(), textInput->hAlign()); + QCOMPARE(textInput->hAlign(), QQuickTextInput::AlignRight); + QVERIFY(textInputPrivate->boundingRect.right() - textInputPrivate->hscroll >= textInput->width() - 1); + QVERIFY(textInputPrivate->boundingRect.right() - textInputPrivate->hscroll <= textInput->width() + 1); + + // explicitly center aligned + textInput->setHAlign(QQuickTextInput::AlignHCenter); + QCOMPARE(textInput->effectiveHAlign(), textInput->hAlign()); + QCOMPARE(textInput->hAlign(), QQuickTextInput::AlignHCenter); + QVERIFY(textInputPrivate->boundingRect.left() - textInputPrivate->hscroll > 0); + QVERIFY(textInputPrivate->boundingRect.right() - textInputPrivate->hscroll < textInput->width()); + + // reseted alignment should go back to following the text reading direction + textInput->resetHAlign(); + QCOMPARE(textInput->hAlign(), QQuickTextInput::AlignRight); + QCOMPARE(textInput->effectiveHAlign(), textInput->hAlign()); + QVERIFY(textInputPrivate->boundingRect.right() - textInputPrivate->hscroll >= textInput->width() - 1); + QVERIFY(textInputPrivate->boundingRect.right() - textInputPrivate->hscroll <= textInput->width() + 1); + + // mirror the text item + QQuickItemPrivate::get(textInput)->setLayoutMirror(true); + + // mirrored implicit alignment should continue to follow the reading direction of the text + QCOMPARE(textInput->hAlign(), QQuickTextInput::AlignRight); + QCOMPARE(textInput->effectiveHAlign(), textInput->hAlign()); + QVERIFY(textInputPrivate->boundingRect.right() - textInputPrivate->hscroll >= textInput->width() - 1); + QVERIFY(textInputPrivate->boundingRect.right() - textInputPrivate->hscroll <= textInput->width() + 1); + + // explicitly right aligned behaves as left aligned + textInput->setHAlign(QQuickTextInput::AlignRight); + QCOMPARE(textInput->hAlign(), QQuickTextInput::AlignRight); + QCOMPARE(textInput->effectiveHAlign(), QQuickTextInput::AlignLeft); + QCOMPARE(textInputPrivate->boundingRect.left() - textInputPrivate->hscroll, qreal(0)); + + // mirrored explicitly left aligned behaves as right aligned + textInput->setHAlign(QQuickTextInput::AlignLeft); + QCOMPARE(textInput->hAlign(), QQuickTextInput::AlignLeft); + QCOMPARE(textInput->effectiveHAlign(), QQuickTextInput::AlignRight); + QVERIFY(textInputPrivate->boundingRect.right() - textInputPrivate->hscroll >= textInput->width() - 1); + QVERIFY(textInputPrivate->boundingRect.right() - textInputPrivate->hscroll <= textInput->width() + 1); + + // disable mirroring + QQuickItemPrivate::get(textInput)->setLayoutMirror(false); + QCOMPARE(textInput->effectiveHAlign(), textInput->hAlign()); + textInput->resetHAlign(); + + // English text should be implicitly left aligned + textInput->setText("Hello world!"); + QCOMPARE(textInput->hAlign(), QQuickTextInput::AlignLeft); + QCOMPARE(textInputPrivate->boundingRect.left() - textInputPrivate->hscroll, qreal(0)); + + canvas.requestActivateWindow(); + QTest::qWaitForWindowShown(&canvas); + QTRY_COMPARE(&canvas, qGuiApp->focusWindow()); + + // If there is no commited text, the preedit text should determine the alignment. + textInput->setText(QString()); + { QInputMethodEvent ev(rtlText, QList()); QGuiApplication::sendEvent(qGuiApp->focusObject(), &ev); } + QCOMPARE(textInput->hAlign(), QQuickTextInput::AlignRight); + { QInputMethodEvent ev("Hello world!", QList()); QGuiApplication::sendEvent(qGuiApp->focusObject(), &ev); } + QCOMPARE(textInput->hAlign(), QQuickTextInput::AlignLeft); + + // Clear pre-edit text. TextInput should maybe do this itself on setText, but that may be + // redundant as an actual input method may take care of it. + { QInputMethodEvent ev; QGuiApplication::sendEvent(qGuiApp->focusObject(), &ev); } + + // empty text with implicit alignment follows the system locale-based + // keyboard input direction from QInputMethod::inputDirection() + textInput->setText(""); + platformInputContext.setInputDirection(Qt::LeftToRight); + QVERIFY(qApp->inputMethod()->inputDirection() == Qt::LeftToRight); + QCOMPARE(textInput->hAlign(), QQuickTextInput::AlignLeft); + QCOMPARE(textInputPrivate->boundingRect.left() - textInputPrivate->hscroll, qreal(0)); + + QSignalSpy cursorRectangleSpy(textInput, SIGNAL(cursorRectangleChanged())); + platformInputContext.setInputDirection(Qt::RightToLeft); + QVERIFY(qApp->inputMethod()->inputDirection() == Qt::RightToLeft); + QCOMPARE(cursorRectangleSpy.count(), 1); + QCOMPARE(textInput->hAlign(), QQuickTextInput::AlignRight); + QVERIFY(textInputPrivate->boundingRect.right() - textInputPrivate->hscroll >= textInput->width() - 1); + QVERIFY(textInputPrivate->boundingRect.right() - textInputPrivate->hscroll <= textInput->width() + 1); + + // set input direction while having content + platformInputContext.setInputDirection(Qt::LeftToRight); + textInput->setText("a"); + platformInputContext.setInputDirection(Qt::RightToLeft); + QTest::keyClick(&canvas, Qt::Key_Backspace); + QVERIFY(textInput->text().isEmpty()); + QCOMPARE(textInput->hAlign(), QQuickTextInput::AlignRight); + QVERIFY(textInputPrivate->boundingRect.right() - textInputPrivate->hscroll >= textInput->width() - 1); + QVERIFY(textInputPrivate->boundingRect.right() - textInputPrivate->hscroll <= textInput->width() + 1); + + // input direction changed while not having focus + platformInputContext.setInputDirection(Qt::LeftToRight); + textInput->setFocus(false); + platformInputContext.setInputDirection(Qt::RightToLeft); + textInput->setFocus(true); + QCOMPARE(textInput->hAlign(), QQuickTextInput::AlignRight); + QVERIFY(textInputPrivate->boundingRect.right() - textInputPrivate->hscroll >= textInput->width() - 1); + QVERIFY(textInputPrivate->boundingRect.right() - textInputPrivate->hscroll <= textInput->width() + 1); + + textInput->setHAlign(QQuickTextInput::AlignRight); + QCOMPARE(textInput->hAlign(), QQuickTextInput::AlignRight); + QVERIFY(textInputPrivate->boundingRect.right() - textInputPrivate->hscroll >= textInput->width() - 1); + QVERIFY(textInputPrivate->boundingRect.right() - textInputPrivate->hscroll <= textInput->width() + 1); +} + +void tst_qquicktextinput::verticalAlignment() +{ + QQuickView canvas(testFileUrl("horizontalAlignment.qml")); + QQuickTextInput *textInput = canvas.rootObject()->findChild("text"); + QVERIFY(textInput != 0); + canvas.show(); + + QQuickTextInputPrivate *textInputPrivate = QQuickTextInputPrivate::get(textInput); + QVERIFY(textInputPrivate != 0); + + QCOMPARE(textInput->vAlign(), QQuickTextInput::AlignTop); + QVERIFY(textInputPrivate->boundingRect.bottom() - textInputPrivate->vscroll < canvas.height() / 2); + QVERIFY(textInput->cursorRectangle().bottom() < canvas.height() / 2); + QVERIFY(textInput->positionToRectangle(0).bottom() < canvas.height() / 2); + + // bottom aligned + textInput->setVAlign(QQuickTextInput::AlignBottom); + QCOMPARE(textInput->vAlign(), QQuickTextInput::AlignBottom); + QVERIFY(textInputPrivate->boundingRect.top() - textInputPrivate->vscroll > canvas.height() / 2); + QVERIFY(textInput->cursorRectangle().top() > canvas.height() / 2); + QVERIFY(textInput->positionToRectangle(0).top() > canvas.height() / 2); + + // explicitly center aligned + textInput->setVAlign(QQuickTextInput::AlignVCenter); + QCOMPARE(textInput->vAlign(), QQuickTextInput::AlignVCenter); + QVERIFY(textInputPrivate->boundingRect.top() - textInputPrivate->vscroll < canvas.height() / 2); + QVERIFY(textInputPrivate->boundingRect.bottom() - textInputPrivate->vscroll > canvas.height() / 2); + QVERIFY(textInput->cursorRectangle().top() < canvas.height() / 2); + QVERIFY(textInput->cursorRectangle().bottom() > canvas.height() / 2); + QVERIFY(textInput->positionToRectangle(0).top() < canvas.height() / 2); + QVERIFY(textInput->positionToRectangle(0).bottom() > canvas.height() / 2); +} + +void tst_qquicktextinput::boundingRect() +{ + QQmlComponent component(&engine); + component.setData("import QtQuick 2.0\n TextInput {}", QUrl()); + QScopedPointer object(component.create()); + QQuickTextInput *input = qobject_cast(object.data()); + QVERIFY(input); + + QCOMPARE(input->width() + input->cursorRectangle().width(), input->boundingRect().width()); + QCOMPARE(input->height(), input->boundingRect().height()); + + input->setText("Hello World"); + QCOMPARE(input->width() + input->cursorRectangle().width(), input->boundingRect().width()); + QCOMPARE(input->height(), input->boundingRect().height()); + + // bounding rect shouldn't exceed the size of the item, expect for the cursor width; + input->setWidth(input->width() / 2); + QCOMPARE(input->width() + input->cursorRectangle().width(), input->boundingRect().width()); + QCOMPARE(input->height(), input->boundingRect().height()); + + input->setHeight(input->height() * 2); + QCOMPARE(input->width() + input->cursorRectangle().width(), input->boundingRect().width()); + QCOMPARE(input->height(), input->boundingRect().height()); + + QQmlComponent cursorComponent(&engine); + cursorComponent.setData("import QtQuick 2.0\nRectangle { height: 20; width: 8 }", QUrl()); + + input->setCursorDelegate(&cursorComponent); + + // If a cursor delegate is used it's size should determine the excess width. + QCOMPARE(input->width() + 8, input->boundingRect().width()); + QCOMPARE(input->height(), input->boundingRect().height()); +} + +void tst_qquicktextinput::positionAt() +{ + QQuickView canvas(testFileUrl("positionAt.qml")); + QVERIFY(canvas.rootObject() != 0); + canvas.show(); + canvas.requestActivateWindow(); + QTest::qWaitForWindowShown(&canvas); + + QQuickTextInput *textinputObject = qobject_cast(canvas.rootObject()); + QVERIFY(textinputObject != 0); + + // Check autoscrolled... + + int pos = evaluate(textinputObject, QString("positionAt(%1)").arg(textinputObject->width()/2)); + + QTextLayout layout(textinputObject->text()); + layout.setFont(textinputObject->font()); + + if (!qmlDisableDistanceField()) { + QTextOption option; + option.setUseDesignMetrics(true); + layout.setTextOption(option); + } + layout.beginLayout(); + QTextLine line = layout.createLine(); + layout.endLayout(); + + int textLeftWidthBegin = floor(line.cursorToX(pos - 1)); + int textLeftWidthEnd = ceil(line.cursorToX(pos + 1)); + int textWidth = floor(line.horizontalAdvance()); + + QVERIFY(textLeftWidthBegin <= textWidth - textinputObject->width() / 2); + QVERIFY(textLeftWidthEnd >= textWidth - textinputObject->width() / 2); + + int x = textinputObject->positionToRectangle(pos + 1).x() - 1; + QCOMPARE(evaluate(textinputObject, QString("positionAt(%1, 0, TextInput.CursorBetweenCharacters)").arg(x)), pos + 1); + QCOMPARE(evaluate(textinputObject, QString("positionAt(%1, 0, TextInput.CursorOnCharacter)").arg(x)), pos); + + // Check without autoscroll... + textinputObject->setAutoScroll(false); + pos = evaluate(textinputObject, QString("positionAt(%1)").arg(textinputObject->width() / 2)); + + textLeftWidthBegin = floor(line.cursorToX(pos - 1)); + textLeftWidthEnd = ceil(line.cursorToX(pos + 1)); + + QVERIFY(textLeftWidthBegin <= textinputObject->width() / 2); + QVERIFY(textLeftWidthEnd >= textinputObject->width() / 2); + + x = textinputObject->positionToRectangle(pos + 1).x() - 1; + QCOMPARE(evaluate(textinputObject, QString("positionAt(%1, 0, TextInput.CursorBetweenCharacters)").arg(x)), pos + 1); + QCOMPARE(evaluate(textinputObject, QString("positionAt(%1, 0, TextInput.CursorOnCharacter)").arg(x)), pos); + + const qreal x0 = textinputObject->positionToRectangle(pos).x(); + const qreal x1 = textinputObject->positionToRectangle(pos + 1).x(); + + QString preeditText = textinputObject->text().mid(0, pos); + textinputObject->setText(textinputObject->text().mid(pos)); + textinputObject->setCursorPosition(0); + + { QInputMethodEvent inputEvent(preeditText, QList()); + QVERIFY(qGuiApp->focusObject()); + QGuiApplication::sendEvent(qGuiApp->focusObject(), &inputEvent); } + + // Check all points within the preedit text return the same position. + QCOMPARE(evaluate(textinputObject, QString("positionAt(%1)").arg(0)), 0); + QCOMPARE(evaluate(textinputObject, QString("positionAt(%1)").arg(x0 / 2)), 0); + QCOMPARE(evaluate(textinputObject, QString("positionAt(%1)").arg(x0)), 0); + + // Verify positioning returns to normal after the preedit text. + QCOMPARE(evaluate(textinputObject, QString("positionAt(%1)").arg(x1)), 1); + QCOMPARE(textinputObject->positionToRectangle(1).x(), x1); + + { QInputMethodEvent inputEvent; + QVERIFY(qGuiApp->focusObject()); + QGuiApplication::sendEvent(qGuiApp->focusObject(), &inputEvent); } + + // With wrapping. + textinputObject->setWrapMode(QQuickTextInput::WrapAnywhere); + + const qreal y0 = line.height() / 2; + const qreal y1 = line.height() * 3 / 2; + + QCOMPARE(evaluate(textinputObject, QString("positionAt(%1, %2)").arg(x0).arg(y0)), pos); + QCOMPARE(evaluate(textinputObject, QString("positionAt(%1, %2)").arg(x1).arg(y0)), pos + 1); + + int newLinePos = evaluate(textinputObject, QString("positionAt(%1, %2)").arg(x0).arg(y1)); + QVERIFY(newLinePos > pos); + QCOMPARE(evaluate(textinputObject, QString("positionAt(%1, %2)").arg(x1).arg(y1)), newLinePos + 1); +} + +void tst_qquicktextinput::maxLength() +{ + QQuickView canvas(testFileUrl("maxLength.qml")); + QVERIFY(canvas.rootObject() != 0); + canvas.show(); + canvas.requestActivateWindow(); + QTest::qWaitForWindowShown(&canvas); + + QQuickTextInput *textinputObject = qobject_cast(canvas.rootObject()); + QVERIFY(textinputObject != 0); + QVERIFY(textinputObject->text().isEmpty()); + QVERIFY(textinputObject->maxLength() == 10); + foreach (const QString &str, standard) { + QVERIFY(textinputObject->text().length() <= 10); + textinputObject->setText(str); + QVERIFY(textinputObject->text().length() <= 10); + } + + textinputObject->setText(""); + QTRY_VERIFY(textinputObject->hasActiveFocus() == true); + for (int i=0; i<20; i++) { + QTRY_COMPARE(textinputObject->text().length(), qMin(i,10)); + //simulateKey(&canvas, Qt::Key_A); + QTest::keyPress(&canvas, Qt::Key_A); + QTest::keyRelease(&canvas, Qt::Key_A, Qt::NoModifier ,10); + QTest::qWait(50); + } +} + +void tst_qquicktextinput::masks() +{ + //Not a comprehensive test of the possible masks, that's done elsewhere (QLineEdit) + //QString componentStr = "import QtQuick 2.0\nTextInput { inputMask: 'HHHHhhhh'; }"; + QQuickView canvas(testFileUrl("masks.qml")); + canvas.show(); + canvas.requestActivateWindow(); + QVERIFY(canvas.rootObject() != 0); + QQuickTextInput *textinputObject = qobject_cast(canvas.rootObject()); + QVERIFY(textinputObject != 0); + QTRY_VERIFY(textinputObject->hasActiveFocus() == true); + QVERIFY(textinputObject->text().length() == 0); + QCOMPARE(textinputObject->inputMask(), QString("HHHHhhhh; ")); + QCOMPARE(textinputObject->length(), 8); + for (int i=0; i<10; i++) { + QTRY_COMPARE(qMin(i,8), textinputObject->text().length()); + QCOMPARE(textinputObject->length(), 8); + QCOMPARE(textinputObject->getText(0, qMin(i, 8)), QString(qMin(i, 8), 'a')); + QCOMPARE(textinputObject->getText(qMin(i, 8), 8), QString(8 - qMin(i, 8), ' ')); + QCOMPARE(i>=4, textinputObject->hasAcceptableInput()); + //simulateKey(&canvas, Qt::Key_A); + QTest::keyPress(&canvas, Qt::Key_A); + QTest::keyRelease(&canvas, Qt::Key_A, Qt::NoModifier ,10); + QTest::qWait(50); + } +} + +void tst_qquicktextinput::validators() +{ + // Note that this test assumes that the validators are working properly + // so you may need to run their tests first. All validators are checked + // here to ensure that their exposure to QML is working. + + QLocale::setDefault(QLocale(QStringLiteral("C"))); + + QQuickView canvas(testFileUrl("validators.qml")); + canvas.show(); + canvas.requestActivateWindow(); + + QVERIFY(canvas.rootObject() != 0); + + QLocale defaultLocale; + QLocale enLocale("en"); + QLocale deLocale("de_DE"); + + QQuickTextInput *intInput = qobject_cast(qvariant_cast(canvas.rootObject()->property("intInput"))); + QVERIFY(intInput); + QSignalSpy intSpy(intInput, SIGNAL(acceptableInputChanged())); + + QQuickIntValidator *intValidator = qobject_cast(intInput->validator()); + QVERIFY(intValidator); + QCOMPARE(intValidator->localeName(), defaultLocale.name()); + QCOMPARE(intInput->validator()->locale(), defaultLocale); + intValidator->setLocaleName(enLocale.name()); + QCOMPARE(intValidator->localeName(), enLocale.name()); + QCOMPARE(intInput->validator()->locale(), enLocale); + intValidator->resetLocaleName(); + QCOMPARE(intValidator->localeName(), defaultLocale.name()); + QCOMPARE(intInput->validator()->locale(), defaultLocale); + + intInput->setFocus(true); + QTRY_VERIFY(intInput->hasActiveFocus()); + QCOMPARE(intInput->hasAcceptableInput(), false); + QCOMPARE(intInput->property("acceptable").toBool(), false); + QTest::keyPress(&canvas, Qt::Key_1); + QTest::keyRelease(&canvas, Qt::Key_1, Qt::NoModifier ,10); + QTest::qWait(50); + QTRY_COMPARE(intInput->text(), QLatin1String("1")); + QCOMPARE(intInput->hasAcceptableInput(), false); + QCOMPARE(intInput->property("acceptable").toBool(), false); + QCOMPARE(intSpy.count(), 0); + QTest::keyPress(&canvas, Qt::Key_2); + QTest::keyRelease(&canvas, Qt::Key_2, Qt::NoModifier ,10); + QTest::qWait(50); + QTRY_COMPARE(intInput->text(), QLatin1String("1")); + QCOMPARE(intInput->hasAcceptableInput(), false); + QCOMPARE(intInput->property("acceptable").toBool(), false); + QCOMPARE(intSpy.count(), 0); + QTest::keyPress(&canvas, Qt::Key_Period); + QTest::keyRelease(&canvas, Qt::Key_Period, Qt::NoModifier ,10); + QTest::qWait(50); + QTRY_COMPARE(intInput->text(), QLatin1String("1")); + QCOMPARE(intInput->hasAcceptableInput(), false); + QTest::keyPress(&canvas, Qt::Key_Comma); + QTest::keyRelease(&canvas, Qt::Key_Comma, Qt::NoModifier ,10); + QTest::qWait(50); + QTRY_COMPARE(intInput->text(), QLatin1String("1,")); + QCOMPARE(intInput->hasAcceptableInput(), false); + QTest::keyPress(&canvas, Qt::Key_Backspace); + QTest::keyRelease(&canvas, Qt::Key_Backspace, Qt::NoModifier ,10); + QTest::qWait(50); + QTRY_COMPARE(intInput->text(), QLatin1String("1")); + QCOMPARE(intInput->hasAcceptableInput(), false); + intValidator->setLocaleName(deLocale.name()); + QTest::keyPress(&canvas, Qt::Key_Period); + QTest::keyRelease(&canvas, Qt::Key_Period, Qt::NoModifier ,10); + QTest::qWait(50); + QTRY_COMPARE(intInput->text(), QLatin1String("1.")); + QCOMPARE(intInput->hasAcceptableInput(), false); + QTest::keyPress(&canvas, Qt::Key_Backspace); + QTest::keyRelease(&canvas, Qt::Key_Backspace, Qt::NoModifier ,10); + QTest::qWait(50); + QTRY_COMPARE(intInput->text(), QLatin1String("1")); + QCOMPARE(intInput->hasAcceptableInput(), false); + intValidator->resetLocaleName(); + QTest::keyPress(&canvas, Qt::Key_1); + QTest::keyRelease(&canvas, Qt::Key_1, Qt::NoModifier ,10); + QTest::qWait(50); + QCOMPARE(intInput->text(), QLatin1String("11")); + QCOMPARE(intInput->hasAcceptableInput(), true); + QCOMPARE(intInput->property("acceptable").toBool(), true); + QCOMPARE(intSpy.count(), 1); + QTest::keyPress(&canvas, Qt::Key_0); + QTest::keyRelease(&canvas, Qt::Key_0, Qt::NoModifier ,10); + QTest::qWait(50); + QCOMPARE(intInput->text(), QLatin1String("11")); + QCOMPARE(intInput->hasAcceptableInput(), true); + QCOMPARE(intInput->property("acceptable").toBool(), true); + QCOMPARE(intSpy.count(), 1); + + QQuickTextInput *dblInput = qobject_cast(qvariant_cast(canvas.rootObject()->property("dblInput"))); + QVERIFY(dblInput); + QSignalSpy dblSpy(dblInput, SIGNAL(acceptableInputChanged())); + + QQuickDoubleValidator *dblValidator = qobject_cast(dblInput->validator()); + QVERIFY(dblValidator); + QCOMPARE(dblValidator->localeName(), defaultLocale.name()); + QCOMPARE(dblInput->validator()->locale(), defaultLocale); + dblValidator->setLocaleName(enLocale.name()); + QCOMPARE(dblValidator->localeName(), enLocale.name()); + QCOMPARE(dblInput->validator()->locale(), enLocale); + dblValidator->resetLocaleName(); + QCOMPARE(dblValidator->localeName(), defaultLocale.name()); + QCOMPARE(dblInput->validator()->locale(), defaultLocale); + + dblInput->setFocus(true); + QVERIFY(dblInput->hasActiveFocus() == true); + QCOMPARE(dblInput->hasAcceptableInput(), false); + QCOMPARE(dblInput->property("acceptable").toBool(), false); + QTest::keyPress(&canvas, Qt::Key_1); + QTest::keyRelease(&canvas, Qt::Key_1, Qt::NoModifier ,10); + QTest::qWait(50); + QTRY_COMPARE(dblInput->text(), QLatin1String("1")); + QCOMPARE(dblInput->hasAcceptableInput(), false); + QCOMPARE(dblInput->property("acceptable").toBool(), false); + QCOMPARE(dblSpy.count(), 0); + QTest::keyPress(&canvas, Qt::Key_2); + QTest::keyRelease(&canvas, Qt::Key_2, Qt::NoModifier ,10); + QTest::qWait(50); + QTRY_COMPARE(dblInput->text(), QLatin1String("12")); + QCOMPARE(dblInput->hasAcceptableInput(), true); + QCOMPARE(dblInput->property("acceptable").toBool(), true); + QCOMPARE(dblSpy.count(), 1); + QTest::keyPress(&canvas, Qt::Key_Comma); + QTest::keyRelease(&canvas, Qt::Key_Comma, Qt::NoModifier ,10); + QTest::qWait(50); + QTRY_COMPARE(dblInput->text(), QLatin1String("12,")); + QCOMPARE(dblInput->hasAcceptableInput(), true); + QTest::keyPress(&canvas, Qt::Key_1); + QTest::keyRelease(&canvas, Qt::Key_1, Qt::NoModifier ,10); + QTest::qWait(50); + QTRY_COMPARE(dblInput->text(), QLatin1String("12,")); + QCOMPARE(dblInput->hasAcceptableInput(), true); + dblValidator->setLocaleName(deLocale.name()); + QCOMPARE(dblInput->hasAcceptableInput(), true); + QTest::keyPress(&canvas, Qt::Key_1); + QTest::keyRelease(&canvas, Qt::Key_1, Qt::NoModifier ,10); + QTest::qWait(50); + QTRY_COMPARE(dblInput->text(), QLatin1String("12,1")); + QCOMPARE(dblInput->hasAcceptableInput(), true); + QTest::keyPress(&canvas, Qt::Key_1); + QTest::keyRelease(&canvas, Qt::Key_1, Qt::NoModifier ,10); + QTest::qWait(50); + QTRY_COMPARE(dblInput->text(), QLatin1String("12,11")); + QCOMPARE(dblInput->hasAcceptableInput(), true); + QTest::keyPress(&canvas, Qt::Key_Backspace); + QTest::keyRelease(&canvas, Qt::Key_Backspace, Qt::NoModifier ,10); + QTest::qWait(50); + QTRY_COMPARE(dblInput->text(), QLatin1String("12,1")); + QCOMPARE(dblInput->hasAcceptableInput(), true); + QTest::keyPress(&canvas, Qt::Key_Backspace); + QTest::keyRelease(&canvas, Qt::Key_Backspace, Qt::NoModifier ,10); + QTest::qWait(50); + QTRY_COMPARE(dblInput->text(), QLatin1String("12,")); + QCOMPARE(dblInput->hasAcceptableInput(), true); + QTest::keyPress(&canvas, Qt::Key_Backspace); + QTest::keyRelease(&canvas, Qt::Key_Backspace, Qt::NoModifier ,10); + QTest::qWait(50); + QTRY_COMPARE(dblInput->text(), QLatin1String("12")); + QCOMPARE(dblInput->hasAcceptableInput(), true); + dblValidator->resetLocaleName(); + QTest::keyPress(&canvas, Qt::Key_Period); + QTest::keyRelease(&canvas, Qt::Key_Period, Qt::NoModifier ,10); + QTest::qWait(50); + QTRY_COMPARE(dblInput->text(), QLatin1String("12.")); + QCOMPARE(dblInput->hasAcceptableInput(), true); + QCOMPARE(dblInput->property("acceptable").toBool(), true); + QCOMPARE(dblSpy.count(), 1); + QTest::keyPress(&canvas, Qt::Key_1); + QTest::keyRelease(&canvas, Qt::Key_1, Qt::NoModifier ,10); + QTest::qWait(50); + QTRY_COMPARE(dblInput->text(), QLatin1String("12.1")); + QCOMPARE(dblInput->hasAcceptableInput(), true); + QCOMPARE(dblInput->property("acceptable").toBool(), true); + QCOMPARE(dblSpy.count(), 1); + QTest::keyPress(&canvas, Qt::Key_1); + QTest::keyRelease(&canvas, Qt::Key_1, Qt::NoModifier ,10); + QTest::qWait(50); + QTRY_COMPARE(dblInput->text(), QLatin1String("12.11")); + QCOMPARE(dblInput->hasAcceptableInput(), true); + QCOMPARE(dblInput->property("acceptable").toBool(), true); + QCOMPARE(dblSpy.count(), 1); + QTest::keyPress(&canvas, Qt::Key_1); + QTest::keyRelease(&canvas, Qt::Key_1, Qt::NoModifier ,10); + QTest::qWait(50); + QTRY_COMPARE(dblInput->text(), QLatin1String("12.11")); + QCOMPARE(dblInput->hasAcceptableInput(), true); + QCOMPARE(dblInput->property("acceptable").toBool(), true); + QCOMPARE(dblSpy.count(), 1); + + // Ensure the validator doesn't prevent characters being removed. + dblInput->setValidator(intInput->validator()); + QCOMPARE(dblInput->text(), QLatin1String("12.11")); + QCOMPARE(dblInput->hasAcceptableInput(), false); + QCOMPARE(dblInput->property("acceptable").toBool(), false); + QCOMPARE(dblSpy.count(), 2); + QTest::keyPress(&canvas, Qt::Key_Backspace); + QTest::keyRelease(&canvas, Qt::Key_Backspace, Qt::NoModifier ,10); + QTest::qWait(50); + QTRY_COMPARE(dblInput->text(), QLatin1String("12.1")); + QCOMPARE(dblInput->hasAcceptableInput(), false); + QCOMPARE(dblInput->property("acceptable").toBool(), false); + QCOMPARE(dblSpy.count(), 2); + // Once unacceptable input is in anything goes until it reaches an acceptable state again. + QTest::keyPress(&canvas, Qt::Key_1); + QTest::keyRelease(&canvas, Qt::Key_1, Qt::NoModifier ,10); + QTest::qWait(50); + QTRY_COMPARE(dblInput->text(), QLatin1String("12.11")); + QCOMPARE(dblInput->hasAcceptableInput(), false); + QCOMPARE(dblSpy.count(), 2); + QTest::keyPress(&canvas, Qt::Key_Backspace); + QTest::keyRelease(&canvas, Qt::Key_Backspace, Qt::NoModifier ,10); + QTest::qWait(50); + QTRY_COMPARE(dblInput->text(), QLatin1String("12.1")); + QCOMPARE(dblInput->hasAcceptableInput(), false); + QCOMPARE(dblInput->property("acceptable").toBool(), false); + QCOMPARE(dblSpy.count(), 2); + QTest::keyPress(&canvas, Qt::Key_Backspace); + QTest::keyRelease(&canvas, Qt::Key_Backspace, Qt::NoModifier ,10); + QTest::qWait(50); + QTRY_COMPARE(dblInput->text(), QLatin1String("12.")); + QCOMPARE(dblInput->hasAcceptableInput(), false); + QCOMPARE(dblInput->property("acceptable").toBool(), false); + QCOMPARE(dblSpy.count(), 2); + QTest::keyPress(&canvas, Qt::Key_Backspace); + QTest::keyRelease(&canvas, Qt::Key_Backspace, Qt::NoModifier ,10); + QTest::qWait(50); + QTRY_COMPARE(dblInput->text(), QLatin1String("12")); + QCOMPARE(dblInput->hasAcceptableInput(), false); + QCOMPARE(dblInput->property("acceptable").toBool(), false); + QCOMPARE(dblSpy.count(), 2); + QTest::keyPress(&canvas, Qt::Key_Backspace); + QTest::keyRelease(&canvas, Qt::Key_Backspace, Qt::NoModifier ,10); + QTest::qWait(50); + QTRY_COMPARE(dblInput->text(), QLatin1String("1")); + QCOMPARE(dblInput->hasAcceptableInput(), false); + QCOMPARE(dblInput->property("acceptable").toBool(), false); + QCOMPARE(dblSpy.count(), 2); + QTest::keyPress(&canvas, Qt::Key_1); + QTest::keyRelease(&canvas, Qt::Key_1, Qt::NoModifier ,10); + QTest::qWait(50); + QCOMPARE(dblInput->text(), QLatin1String("11")); + QCOMPARE(dblInput->property("acceptable").toBool(), true); + QCOMPARE(dblInput->hasAcceptableInput(), true); + QCOMPARE(dblSpy.count(), 3); + + QQuickTextInput *strInput = qobject_cast(qvariant_cast(canvas.rootObject()->property("strInput"))); + QVERIFY(strInput); + QSignalSpy strSpy(strInput, SIGNAL(acceptableInputChanged())); + strInput->setFocus(true); + QVERIFY(strInput->hasActiveFocus() == true); + QCOMPARE(strInput->hasAcceptableInput(), false); + QCOMPARE(strInput->property("acceptable").toBool(), false); + QTest::keyPress(&canvas, Qt::Key_1); + QTest::keyRelease(&canvas, Qt::Key_1, Qt::NoModifier ,10); + QTest::qWait(50); + QTRY_COMPARE(strInput->text(), QLatin1String("")); + QCOMPARE(strInput->hasAcceptableInput(), false); + QCOMPARE(strInput->property("acceptable").toBool(), false); + QCOMPARE(strSpy.count(), 0); + QTest::keyPress(&canvas, Qt::Key_A); + QTest::keyRelease(&canvas, Qt::Key_A, Qt::NoModifier ,10); + QTest::qWait(50); + QTRY_COMPARE(strInput->text(), QLatin1String("a")); + QCOMPARE(strInput->hasAcceptableInput(), false); + QCOMPARE(strInput->property("acceptable").toBool(), false); + QCOMPARE(strSpy.count(), 0); + QTest::keyPress(&canvas, Qt::Key_A); + QTest::keyRelease(&canvas, Qt::Key_A, Qt::NoModifier ,10); + QTest::qWait(50); + QTRY_COMPARE(strInput->text(), QLatin1String("aa")); + QCOMPARE(strInput->hasAcceptableInput(), true); + QCOMPARE(strInput->property("acceptable").toBool(), true); + QCOMPARE(strSpy.count(), 1); + QTest::keyPress(&canvas, Qt::Key_A); + QTest::keyRelease(&canvas, Qt::Key_A, Qt::NoModifier ,10); + QTest::qWait(50); + QTRY_COMPARE(strInput->text(), QLatin1String("aaa")); + QCOMPARE(strInput->hasAcceptableInput(), true); + QCOMPARE(strInput->property("acceptable").toBool(), true); + QCOMPARE(strSpy.count(), 1); + QTest::keyPress(&canvas, Qt::Key_A); + QTest::keyRelease(&canvas, Qt::Key_A, Qt::NoModifier ,10); + QTest::qWait(50); + QTRY_COMPARE(strInput->text(), QLatin1String("aaaa")); + QCOMPARE(strInput->hasAcceptableInput(), true); + QCOMPARE(strInput->property("acceptable").toBool(), true); + QCOMPARE(strSpy.count(), 1); + QTest::keyPress(&canvas, Qt::Key_A); + QTest::keyRelease(&canvas, Qt::Key_A, Qt::NoModifier ,10); + QTest::qWait(50); + QTRY_COMPARE(strInput->text(), QLatin1String("aaaa")); + QCOMPARE(strInput->hasAcceptableInput(), true); + QCOMPARE(strInput->property("acceptable").toBool(), true); + QCOMPARE(strSpy.count(), 1); + + QQuickTextInput *unvalidatedInput = qobject_cast(qvariant_cast(canvas.rootObject()->property("unvalidatedInput"))); + QVERIFY(unvalidatedInput); + QSignalSpy unvalidatedSpy(unvalidatedInput, SIGNAL(acceptableInputChanged())); + unvalidatedInput->setFocus(true); + QVERIFY(unvalidatedInput->hasActiveFocus() == true); + QCOMPARE(unvalidatedInput->hasAcceptableInput(), true); + QCOMPARE(unvalidatedInput->property("acceptable").toBool(), true); + QTest::keyPress(&canvas, Qt::Key_1); + QTest::keyRelease(&canvas, Qt::Key_1, Qt::NoModifier ,10); + QTest::qWait(50); + QTRY_COMPARE(unvalidatedInput->text(), QLatin1String("1")); + QCOMPARE(unvalidatedInput->hasAcceptableInput(), true); + QCOMPARE(unvalidatedInput->property("acceptable").toBool(), true); + QCOMPARE(unvalidatedSpy.count(), 0); + QTest::keyPress(&canvas, Qt::Key_A); + QTest::keyRelease(&canvas, Qt::Key_A, Qt::NoModifier ,10); + QTest::qWait(50); + QTRY_COMPARE(unvalidatedInput->text(), QLatin1String("1a")); + QCOMPARE(unvalidatedInput->hasAcceptableInput(), true); + QCOMPARE(unvalidatedInput->property("acceptable").toBool(), true); + QCOMPARE(unvalidatedSpy.count(), 0); +} + +void tst_qquicktextinput::inputMethods() +{ + QQuickView canvas(testFileUrl("inputmethods.qml")); + canvas.show(); + canvas.requestActivateWindow(); + QTest::qWaitForWindowShown(&canvas); + + // test input method hints + QVERIFY(canvas.rootObject() != 0); + QQuickTextInput *input = qobject_cast(canvas.rootObject()); + QVERIFY(input != 0); + QVERIFY(input->inputMethodHints() & Qt::ImhNoPredictiveText); + QSignalSpy inputMethodHintSpy(input, SIGNAL(inputMethodHintsChanged())); + input->setInputMethodHints(Qt::ImhUppercaseOnly); + QVERIFY(input->inputMethodHints() & Qt::ImhUppercaseOnly); + QCOMPARE(inputMethodHintSpy.count(), 1); + input->setInputMethodHints(Qt::ImhUppercaseOnly); + QCOMPARE(inputMethodHintSpy.count(), 1); + + // default value + QQuickTextInput plainInput; + QCOMPARE(plainInput.inputMethodHints(), Qt::ImhNone); + + input->setFocus(true); + QVERIFY(input->hasActiveFocus() == true); + // test that input method event is committed + QInputMethodEvent event; + event.setCommitString( "My ", -12, 0); + QTRY_COMPARE(qGuiApp->focusObject(), input); + QGuiApplication::sendEvent(qGuiApp->focusObject(), &event); + QCOMPARE(input->text(), QString("My Hello world!")); + + input->setCursorPosition(2); + event.setCommitString("Your", -2, 2); + QGuiApplication::sendEvent(qGuiApp->focusObject(), &event); + QCOMPARE(input->text(), QString("Your Hello world!")); + QCOMPARE(input->cursorPosition(), 4); + + input->setCursorPosition(7); + event.setCommitString("Goodbye", -2, 5); + QGuiApplication::sendEvent(qGuiApp->focusObject(), &event); + QCOMPARE(input->text(), QString("Your Goodbye world!")); + QCOMPARE(input->cursorPosition(), 12); + + input->setCursorPosition(8); + event.setCommitString("Our", -8, 4); + QGuiApplication::sendEvent(qGuiApp->focusObject(), &event); + QCOMPARE(input->text(), QString("Our Goodbye world!")); + QCOMPARE(input->cursorPosition(), 7); + + // test that basic tentative commit gets to text property on preedit state + input->setText(""); + QList attributes; + QInputMethodEvent preeditEvent("test", attributes); + preeditEvent.setTentativeCommitString("test"); + QGuiApplication::sendEvent(input, &preeditEvent); + QCOMPARE(input->text(), QString("test")); + + // tentative commit not allowed present in surrounding text + QInputMethodQueryEvent queryEvent(Qt::ImSurroundingText); + QGuiApplication::sendEvent(input, &queryEvent); + QCOMPARE(queryEvent.value(Qt::ImSurroundingText).toString(), QString("")); + + // if text with tentative commit does not validate, not allowed to be part of text property + input->setText(""); // ensure input state is reset + QValidator *validator = new QIntValidator(0, 100); + input->setValidator(validator); + QGuiApplication::sendEvent(input, &preeditEvent); + QCOMPARE(input->text(), QString("")); + input->setValidator(0); + delete validator; + + // input should reset selection even if replacement parameters are out of bounds + input->setText("text"); + input->setCursorPosition(0); + input->moveCursorSelection(input->text().length()); + event.setCommitString("replacement", -input->text().length(), input->text().length()); + QGuiApplication::sendEvent(qGuiApp->focusObject(), &event); + QCOMPARE(input->selectionStart(), input->selectionEnd()); + + QInputMethodQueryEvent enabledQueryEvent(Qt::ImEnabled); + QGuiApplication::sendEvent(input, &enabledQueryEvent); + QCOMPARE(enabledQueryEvent.value(Qt::ImEnabled).toBool(), true); + + input->setReadOnly(true); + QGuiApplication::sendEvent(input, &enabledQueryEvent); + QCOMPARE(enabledQueryEvent.value(Qt::ImEnabled).toBool(), false); +} + +/* +TextInput element should only handle left/right keys until the cursor reaches +the extent of the text, then they should ignore the keys. + +*/ +void tst_qquicktextinput::navigation() +{ + QQuickView canvas(testFileUrl("navigation.qml")); + canvas.show(); + canvas.requestActivateWindow(); + + QVERIFY(canvas.rootObject() != 0); + + QQuickTextInput *input = qobject_cast(qvariant_cast(canvas.rootObject()->property("myInput"))); + + QVERIFY(input != 0); + input->setCursorPosition(0); + QTRY_VERIFY(input->hasActiveFocus() == true); + simulateKey(&canvas, Qt::Key_Left); + QVERIFY(input->hasActiveFocus() == false); + simulateKey(&canvas, Qt::Key_Right); + QVERIFY(input->hasActiveFocus() == true); + //QT-2944: If text is selected, ensure we deselect upon cursor motion + input->setCursorPosition(input->text().length()); + input->select(0,input->text().length()); + QVERIFY(input->selectionStart() != input->selectionEnd()); + simulateKey(&canvas, Qt::Key_Right); + QVERIFY(input->selectionStart() == input->selectionEnd()); + QVERIFY(input->selectionStart() == input->text().length()); + QVERIFY(input->hasActiveFocus() == true); + simulateKey(&canvas, Qt::Key_Right); + QVERIFY(input->hasActiveFocus() == false); + simulateKey(&canvas, Qt::Key_Left); + QVERIFY(input->hasActiveFocus() == true); + + // Up and Down should NOT do Home/End, even on Mac OS X (QTBUG-10438). + input->setCursorPosition(2); + QCOMPARE(input->cursorPosition(),2); + simulateKey(&canvas, Qt::Key_Up); + QCOMPARE(input->cursorPosition(),2); + simulateKey(&canvas, Qt::Key_Down); + QCOMPARE(input->cursorPosition(),2); +} + +void tst_qquicktextinput::navigation_RTL() +{ + QQuickView canvas(testFileUrl("navigation.qml")); + canvas.show(); + canvas.requestActivateWindow(); + + QVERIFY(canvas.rootObject() != 0); + + QQuickTextInput *input = qobject_cast(qvariant_cast(canvas.rootObject()->property("myInput"))); + + QVERIFY(input != 0); + const quint16 arabic_str[] = { 0x0638, 0x0643, 0x00646, 0x0647, 0x0633, 0x0638, 0x0643, 0x00646, 0x0647, 0x0633, 0x0647}; + input->setText(QString::fromUtf16(arabic_str, 11)); + + input->setCursorPosition(0); + QTRY_VERIFY(input->hasActiveFocus() == true); + + // move off + simulateKey(&canvas, Qt::Key_Right); + QVERIFY(input->hasActiveFocus() == false); + + // move back + simulateKey(&canvas, Qt::Key_Left); + QVERIFY(input->hasActiveFocus() == true); + + input->setCursorPosition(input->text().length()); + QVERIFY(input->hasActiveFocus() == true); + + // move off + simulateKey(&canvas, Qt::Key_Left); + QVERIFY(input->hasActiveFocus() == false); + + // move back + simulateKey(&canvas, Qt::Key_Right); + QVERIFY(input->hasActiveFocus() == true); +} + +void tst_qquicktextinput::copyAndPaste() { +#ifndef QT_NO_CLIPBOARD + +#ifdef Q_OS_MAC + { + PasteboardRef pasteboard; + OSStatus status = PasteboardCreate(0, &pasteboard); + if (status == noErr) + CFRelease(pasteboard); + else + QSKIP("This machine doesn't support the clipboard"); + } +#endif + + QString componentStr = "import QtQuick 2.0\nTextInput { text: \"Hello world!\" }"; + QQmlComponent textInputComponent(&engine); + textInputComponent.setData(componentStr.toLatin1(), QUrl()); + QQuickTextInput *textInput = qobject_cast(textInputComponent.create()); + QVERIFY(textInput != 0); + + // copy and paste + QCOMPARE(textInput->text().length(), 12); + textInput->select(0, textInput->text().length());; + textInput->copy(); + QCOMPARE(textInput->selectedText(), QString("Hello world!")); + QCOMPARE(textInput->selectedText().length(), 12); + textInput->setCursorPosition(0); + QVERIFY(textInput->canPaste()); + textInput->paste(); + QCOMPARE(textInput->text(), QString("Hello world!Hello world!")); + QCOMPARE(textInput->text().length(), 24); + + // can paste + QVERIFY(textInput->canPaste()); + textInput->setReadOnly(true); + QVERIFY(!textInput->canPaste()); + textInput->setReadOnly(false); + QVERIFY(textInput->canPaste()); + + // select word + textInput->setCursorPosition(0); + textInput->selectWord(); + QCOMPARE(textInput->selectedText(), QString("Hello")); + + // select all and cut + textInput->selectAll(); + textInput->cut(); + QCOMPARE(textInput->text().length(), 0); + textInput->paste(); + QCOMPARE(textInput->text(), QString("Hello world!Hello world!")); + QCOMPARE(textInput->text().length(), 24); + + // clear copy buffer + QClipboard *clipboard = QGuiApplication::clipboard(); + QVERIFY(clipboard); + clipboard->clear(); + QVERIFY(!textInput->canPaste()); + + // test that copy functionality is disabled + // when echo mode is set to hide text/password mode + int index = 0; + while (index < 4) { + QQuickTextInput::EchoMode echoMode = QQuickTextInput::EchoMode(index); + textInput->setEchoMode(echoMode); + textInput->setText("My password"); + textInput->select(0, textInput->text().length());; + textInput->copy(); + if (echoMode == QQuickTextInput::Normal) { + QVERIFY(!clipboard->text().isEmpty()); + QCOMPARE(clipboard->text(), QString("My password")); + clipboard->clear(); + } else { + QVERIFY(clipboard->text().isEmpty()); + } + index++; + } + + delete textInput; +#endif +} + +void tst_qquicktextinput::copyAndPasteKeySequence() { +#ifndef QT_NO_CLIPBOARD + +#ifdef Q_OS_MAC + { + PasteboardRef pasteboard; + OSStatus status = PasteboardCreate(0, &pasteboard); + if (status == noErr) + CFRelease(pasteboard); + else + QSKIP("This machine doesn't support the clipboard"); + } +#endif + + QString componentStr = "import QtQuick 2.0\nTextInput { text: \"Hello world!\"; focus: true }"; + QQmlComponent textInputComponent(&engine); + textInputComponent.setData(componentStr.toLatin1(), QUrl()); + QQuickTextInput *textInput = qobject_cast(textInputComponent.create()); + QVERIFY(textInput != 0); + + QQuickCanvas canvas; + textInput->setParentItem(canvas.rootItem()); + canvas.show(); + canvas.requestActivateWindow(); + QTest::qWaitForWindowShown(&canvas); + QTRY_COMPARE(QGuiApplication::activeWindow(), &canvas); + + // copy and paste + QVERIFY(textInput->hasActiveFocus()); + QCOMPARE(textInput->text().length(), 12); + textInput->select(0, textInput->text().length()); + simulateKeys(&canvas, QKeySequence::Copy); + QCOMPARE(textInput->selectedText(), QString("Hello world!")); + QCOMPARE(textInput->selectedText().length(), 12); + textInput->setCursorPosition(0); + QVERIFY(textInput->canPaste()); + simulateKeys(&canvas, QKeySequence::Paste); + QCOMPARE(textInput->text(), QString("Hello world!Hello world!")); + QCOMPARE(textInput->text().length(), 24); + + // select all and cut + simulateKeys(&canvas, QKeySequence::SelectAll); + simulateKeys(&canvas, QKeySequence::Cut); + QCOMPARE(textInput->text().length(), 0); + simulateKeys(&canvas, QKeySequence::Paste); + QCOMPARE(textInput->text(), QString("Hello world!Hello world!")); + QCOMPARE(textInput->text().length(), 24); + + // clear copy buffer + QClipboard *clipboard = QGuiApplication::clipboard(); + QVERIFY(clipboard); + clipboard->clear(); + QVERIFY(!textInput->canPaste()); + + // test that copy functionality is disabled + // when echo mode is set to hide text/password mode + int index = 0; + while (index < 4) { + QQuickTextInput::EchoMode echoMode = QQuickTextInput::EchoMode(index); + textInput->setEchoMode(echoMode); + textInput->setText("My password"); + textInput->select(0, textInput->text().length());; + simulateKeys(&canvas, QKeySequence::Copy); + if (echoMode == QQuickTextInput::Normal) { + QVERIFY(!clipboard->text().isEmpty()); + QCOMPARE(clipboard->text(), QString("My password")); + clipboard->clear(); + } else { + QVERIFY(clipboard->text().isEmpty()); + } + index++; + } + + delete textInput; +#endif +} + +void tst_qquicktextinput::canPasteEmpty() { +#ifndef QT_NO_CLIPBOARD + + QGuiApplication::clipboard()->clear(); + + QString componentStr = "import QtQuick 2.0\nTextInput { text: \"Hello world!\" }"; + QQmlComponent textInputComponent(&engine); + textInputComponent.setData(componentStr.toLatin1(), QUrl()); + QQuickTextInput *textInput = qobject_cast(textInputComponent.create()); + QVERIFY(textInput != 0); + + bool cp = !textInput->isReadOnly() && QGuiApplication::clipboard()->text().length() != 0; + QCOMPARE(textInput->canPaste(), cp); + +#endif +} + +void tst_qquicktextinput::canPaste() { +#ifndef QT_NO_CLIPBOARD + + QGuiApplication::clipboard()->setText("Some text"); + + QString componentStr = "import QtQuick 2.0\nTextInput { text: \"Hello world!\" }"; + QQmlComponent textInputComponent(&engine); + textInputComponent.setData(componentStr.toLatin1(), QUrl()); + QQuickTextInput *textInput = qobject_cast(textInputComponent.create()); + QVERIFY(textInput != 0); + + bool cp = !textInput->isReadOnly() && QGuiApplication::clipboard()->text().length() != 0; + QCOMPARE(textInput->canPaste(), cp); + +#endif +} + +void tst_qquicktextinput::passwordCharacter() +{ + QString componentStr = "import QtQuick 2.0\nTextInput { text: \"Hello world!\"; font.family: \"Helvetica\"; echoMode: TextInput.Password }"; + QQmlComponent textInputComponent(&engine); + textInputComponent.setData(componentStr.toLatin1(), QUrl()); + QQuickTextInput *textInput = qobject_cast(textInputComponent.create()); + QVERIFY(textInput != 0); + + textInput->setPasswordCharacter("X"); + qreal implicitWidth = textInput->implicitWidth(); + textInput->setPasswordCharacter("."); + + // QTBUG-12383 content is updated and redrawn + QVERIFY(textInput->implicitWidth() < implicitWidth); + + delete textInput; +} + +void tst_qquicktextinput::cursorDelegate_data() +{ + QTest::addColumn("source"); + QTest::newRow("out of line") << testFileUrl("cursorTest.qml"); + QTest::newRow("in line") << testFileUrl("cursorTestInline.qml"); + QTest::newRow("external") << testFileUrl("cursorTestExternal.qml"); +} + +void tst_qquicktextinput::cursorDelegate() +{ + QFETCH(QUrl, source); + QQuickView view(source); + view.show(); + view.requestActivateWindow(); + QQuickTextInput *textInputObject = view.rootObject()->findChild("textInputObject"); + QVERIFY(textInputObject != 0); + QVERIFY(textInputObject->findChild("cursorInstance")); + //Test Delegate gets created + textInputObject->setFocus(true); + QQuickItem* delegateObject = textInputObject->findChild("cursorInstance"); + QVERIFY(delegateObject); + QCOMPARE(delegateObject->property("localProperty").toString(), QString("Hello")); + //Test Delegate gets moved + for (int i=0; i<= textInputObject->text().length(); i++) { + textInputObject->setCursorPosition(i); + QCOMPARE(textInputObject->cursorRectangle().x(), qRound(delegateObject->x())); + QCOMPARE(textInputObject->cursorRectangle().y(), qRound(delegateObject->y())); + } + textInputObject->setCursorPosition(0); + QCOMPARE(textInputObject->cursorRectangle().x(), qRound(delegateObject->x())); + QCOMPARE(textInputObject->cursorRectangle().y(), qRound(delegateObject->y())); + //Test Delegate gets deleted + textInputObject->setCursorDelegate(0); + QVERIFY(!textInputObject->findChild("cursorInstance")); +} + +void tst_qquicktextinput::cursorVisible() +{ + QQuickView view(testFileUrl("cursorVisible.qml")); + view.show(); + view.requestActivateWindow(); + QTest::qWaitForWindowShown(&view); + QTRY_COMPARE(&view, qGuiApp->focusWindow()); + + QQuickTextInput input; + input.componentComplete(); + QSignalSpy spy(&input, SIGNAL(cursorVisibleChanged(bool))); + + QCOMPARE(input.isCursorVisible(), false); + + input.setCursorVisible(true); + QCOMPARE(input.isCursorVisible(), true); + QCOMPARE(spy.count(), 1); + + input.setCursorVisible(false); + QCOMPARE(input.isCursorVisible(), false); + QCOMPARE(spy.count(), 2); + + input.setFocus(true); + QCOMPARE(input.isCursorVisible(), false); + QCOMPARE(spy.count(), 2); + + input.setParentItem(view.rootObject()); + QCOMPARE(input.isCursorVisible(), true); + QCOMPARE(spy.count(), 3); + + input.setFocus(false); + QCOMPARE(input.isCursorVisible(), false); + QCOMPARE(spy.count(), 4); + + input.setFocus(true); + QCOMPARE(input.isCursorVisible(), true); + QCOMPARE(spy.count(), 5); + + QQuickView alternateView; + alternateView.show(); + alternateView.requestActivateWindow(); + QTest::qWaitForWindowShown(&alternateView); + + QCOMPARE(input.isCursorVisible(), false); + QCOMPARE(spy.count(), 6); + + view.requestActivateWindow(); + QTest::qWaitForWindowShown(&view); + QCOMPARE(input.isCursorVisible(), true); + QCOMPARE(spy.count(), 7); +} + +static QRect round(const QRectF &r) { + return QRect(qRound(r.left()), qRound(r.top()), qCeil(r.width()), qCeil(r.height())); } + +void tst_qquicktextinput::cursorRectangle() +{ + + QString text = "Hello World!"; + + QQuickTextInput input; + input.setText(text); + input.componentComplete(); + + QTextLayout layout(text); + layout.setFont(input.font()); + if (!qmlDisableDistanceField()) { + QTextOption option; + option.setUseDesignMetrics(true); + layout.setTextOption(option); + } + layout.beginLayout(); + QTextLine line = layout.createLine(); + layout.endLayout(); + + input.setWidth(line.cursorToX(5, QTextLine::Leading)); + input.setHeight(qCeil(line.height() * 3 / 2)); + + QRect r; + + // some tolerance for different fonts. +#ifdef Q_OS_LINUX + const int error = 2; +#else + const int error = 5; +#endif + + for (int i = 0; i <= 5; ++i) { + input.setCursorPosition(i); + r = input.cursorRectangle(); + + QVERIFY(r.left() < qCeil(line.cursorToX(i, QTextLine::Trailing))); + QVERIFY(r.right() >= qFloor(line.cursorToX(i , QTextLine::Leading))); + QCOMPARE(input.inputMethodQuery(Qt::ImCursorRectangle).toRect(), r); + QCOMPARE(round(input.positionToRectangle(i)), r); + } + + // Check the cursor rectangle remains within the input bounding rect when auto scrolling. + QVERIFY(r.left() < input.width()); + QVERIFY(r.right() >= input.width() - error); + + for (int i = 6; i < text.length(); ++i) { + input.setCursorPosition(i); + QCOMPARE(r, input.cursorRectangle()); + QCOMPARE(input.inputMethodQuery(Qt::ImCursorRectangle).toRect(), r); + QCOMPARE(round(input.positionToRectangle(i)), r); + } + + for (int i = text.length() - 2; i >= 0; --i) { + input.setCursorPosition(i); + r = input.cursorRectangle(); + QCOMPARE(r.top(), 0); + QVERIFY(r.right() >= 0); + QCOMPARE(input.inputMethodQuery(Qt::ImCursorRectangle).toRect(), r); + QCOMPARE(round(input.positionToRectangle(i)), r); + } + + // Check position with word wrap. + input.setWrapMode(QQuickTextInput::WordWrap); + input.setAutoScroll(false); + for (int i = 0; i <= 5; ++i) { + input.setCursorPosition(i); + r = input.cursorRectangle(); + + QVERIFY(r.left() < qCeil(line.cursorToX(i, QTextLine::Trailing))); + QVERIFY(r.right() >= qFloor(line.cursorToX(i , QTextLine::Leading))); + QCOMPARE(r.top(), 0); + QCOMPARE(input.inputMethodQuery(Qt::ImCursorRectangle).toRect(), r); + QCOMPARE(round(input.positionToRectangle(i)), r); + } + + input.setCursorPosition(6); + r = input.cursorRectangle(); + QCOMPARE(r.left(), 0); + QVERIFY(r.top() > line.height() - error); + QCOMPARE(input.inputMethodQuery(Qt::ImCursorRectangle).toRect(), r); + QCOMPARE(round(input.positionToRectangle(6)), r); + + for (int i = 7; i < text.length(); ++i) { + input.setCursorPosition(i); + r = input.cursorRectangle(); + QVERIFY(r.top() > line.height() - error); + QCOMPARE(input.inputMethodQuery(Qt::ImCursorRectangle).toRect(), r); + QCOMPARE(round(input.positionToRectangle(i)), r); + } + + // Check vertical scrolling with word wrap. + input.setAutoScroll(true); + for (int i = 0; i <= 5; ++i) { + input.setCursorPosition(i); + r = input.cursorRectangle(); + + QVERIFY(r.left() < qCeil(line.cursorToX(i, QTextLine::Trailing))); + QVERIFY(r.right() >= qFloor(line.cursorToX(i , QTextLine::Leading))); + QCOMPARE(r.top(), 0); + QCOMPARE(input.inputMethodQuery(Qt::ImCursorRectangle).toRect(), r); + QCOMPARE(round(round(input.positionToRectangle(i))), r); + } + + input.setCursorPosition(6); + r = input.cursorRectangle(); + QCOMPARE(r.left(), 0); + QVERIFY(r.bottom() >= input.height() - error); + QCOMPARE(input.inputMethodQuery(Qt::ImCursorRectangle).toRect(), r); + QCOMPARE(round(input.positionToRectangle(6)), r); + + for (int i = 7; i < text.length(); ++i) { + input.setCursorPosition(i); + r = input.cursorRectangle(); + QVERIFY(r.bottom() >= input.height() - error); + QCOMPARE(input.inputMethodQuery(Qt::ImCursorRectangle).toRect(), r); + QCOMPARE(round(input.positionToRectangle(i)), r); + } + + for (int i = text.length() - 2; i >= 6; --i) { + input.setCursorPosition(i); + r = input.cursorRectangle(); + QVERIFY(r.bottom() >= input.height() - error); + QCOMPARE(input.inputMethodQuery(Qt::ImCursorRectangle).toRect(), r); + QCOMPARE(round(input.positionToRectangle(i)), r); + } + + for (int i = 5; i >= 0; --i) { + input.setCursorPosition(i); + r = input.cursorRectangle(); + QCOMPARE(r.top(), 0); + QCOMPARE(input.inputMethodQuery(Qt::ImCursorRectangle).toRect(), r); + QCOMPARE(round(input.positionToRectangle(i)), r); + } + + input.setText("Hi!"); + input.setHAlign(QQuickTextInput::AlignRight); + r = input.cursorRectangle(); + QVERIFY(r.left() < input.width() + error); + QVERIFY(r.right() >= input.width() - error); +} + +void tst_qquicktextinput::readOnly() +{ + QQuickView canvas(testFileUrl("readOnly.qml")); + canvas.show(); + canvas.requestActivateWindow(); + + QVERIFY(canvas.rootObject() != 0); + + QQuickTextInput *input = qobject_cast(qvariant_cast(canvas.rootObject()->property("myInput"))); + + QVERIFY(input != 0); + QTRY_VERIFY(input->hasActiveFocus() == true); + QVERIFY(input->isReadOnly() == true); + QString initial = input->text(); + for (int k=Qt::Key_0; k<=Qt::Key_Z; k++) + simulateKey(&canvas, k); + simulateKey(&canvas, Qt::Key_Return); + simulateKey(&canvas, Qt::Key_Space); + simulateKey(&canvas, Qt::Key_Escape); + QCOMPARE(input->text(), initial); + + input->setCursorPosition(3); + input->setReadOnly(false); + QCOMPARE(input->isReadOnly(), false); + QCOMPARE(input->cursorPosition(), input->text().length()); +} + +void tst_qquicktextinput::echoMode() +{ + QQuickView canvas(testFileUrl("echoMode.qml")); + canvas.show(); + canvas.requestActivateWindow(); + QTest::qWaitForWindowShown(&canvas); + QTRY_COMPARE(&canvas, qGuiApp->focusWindow()); + + QVERIFY(canvas.rootObject() != 0); + + QQuickTextInput *input = qobject_cast(qvariant_cast(canvas.rootObject()->property("myInput"))); + + QVERIFY(input != 0); + QTRY_VERIFY(input->hasActiveFocus() == true); + QString initial = input->text(); + Qt::InputMethodHints ref; + QCOMPARE(initial, QLatin1String("ABCDefgh")); + QCOMPARE(input->echoMode(), QQuickTextInput::Normal); + QCOMPARE(input->displayText(), input->text()); + //Normal + ref &= ~Qt::ImhHiddenText; + ref &= ~(Qt::ImhNoAutoUppercase | Qt::ImhNoPredictiveText | Qt::ImhSensitiveData); + QCOMPARE((Qt::InputMethodHints) input->inputMethodQuery(Qt::ImHints).toInt(), ref); + input->setEchoMode(QQuickTextInput::NoEcho); + QCOMPARE(input->text(), initial); + QCOMPARE(input->displayText(), QLatin1String("")); + QCOMPARE(input->passwordCharacter(), QLatin1String("*")); + //NoEcho + ref |= Qt::ImhHiddenText; + ref |= (Qt::ImhNoAutoUppercase | Qt::ImhNoPredictiveText | Qt::ImhSensitiveData); + QCOMPARE((Qt::InputMethodHints) input->inputMethodQuery(Qt::ImHints).toInt(), ref); + input->setEchoMode(QQuickTextInput::Password); + //Password + ref |= Qt::ImhHiddenText; + ref |= (Qt::ImhNoAutoUppercase | Qt::ImhNoPredictiveText | Qt::ImhSensitiveData); + QCOMPARE(input->text(), initial); + QCOMPARE(input->displayText(), QLatin1String("********")); + QCOMPARE((Qt::InputMethodHints) input->inputMethodQuery(Qt::ImHints).toInt(), ref); + // clearing input hints do not clear bits set by echo mode + input->setInputMethodHints(Qt::ImhNone); + QCOMPARE((Qt::InputMethodHints) input->inputMethodQuery(Qt::ImHints).toInt(), ref); + input->setPasswordCharacter(QChar('Q')); + QCOMPARE(input->passwordCharacter(), QLatin1String("Q")); + QCOMPARE(input->text(), initial); + QCOMPARE(input->displayText(), QLatin1String("QQQQQQQQ")); + input->setEchoMode(QQuickTextInput::PasswordEchoOnEdit); + //PasswordEchoOnEdit + ref &= ~Qt::ImhHiddenText; + ref |= (Qt::ImhNoAutoUppercase | Qt::ImhNoPredictiveText | Qt::ImhSensitiveData); + QCOMPARE((Qt::InputMethodHints) input->inputMethodQuery(Qt::ImHints).toInt(), ref); + QCOMPARE(input->text(), initial); + QCOMPARE(input->displayText(), QLatin1String("QQQQQQQQ")); + QCOMPARE(input->inputMethodQuery(Qt::ImSurroundingText).toString(), QLatin1String("QQQQQQQQ")); + QTest::keyPress(&canvas, Qt::Key_A);//Clearing previous entry is part of PasswordEchoOnEdit + QTest::keyRelease(&canvas, Qt::Key_A, Qt::NoModifier ,10); + QCOMPARE(input->text(), QLatin1String("a")); + QCOMPARE(input->displayText(), QLatin1String("a")); + QCOMPARE(input->inputMethodQuery(Qt::ImSurroundingText).toString(), QLatin1String("a")); + input->setFocus(false); + QVERIFY(input->hasActiveFocus() == false); + QCOMPARE(input->displayText(), QLatin1String("Q")); + QCOMPARE(input->inputMethodQuery(Qt::ImSurroundingText).toString(), QLatin1String("Q")); + input->setFocus(true); + QVERIFY(input->hasActiveFocus()); + QInputMethodEvent inputEvent; + inputEvent.setCommitString(initial); + QGuiApplication::sendEvent(input, &inputEvent); + QCOMPARE(input->text(), initial); + QCOMPARE(input->displayText(), initial); + QCOMPARE(input->inputMethodQuery(Qt::ImSurroundingText).toString(), initial); +} + +#ifdef QT_GUI_PASSWORD_ECHO_DELAY +void tst_qquicktextinput::passwordEchoDelay() +{ + QQuickView canvas(testFileUrl("echoMode.qml")); + canvas.show(); + canvas.requestActivateWindow(); + QTest::qWaitForWindowShown(&canvas); + QTRY_COMPARE(&canvas, qGuiApp->focusWindow()); + + QVERIFY(canvas.rootObject() != 0); + + QQuickTextInput *input = qobject_cast(qvariant_cast(canvas.rootObject()->property("myInput"))); + + QChar fillChar = QLatin1Char('*'); + + input->setEchoMode(QQuickTextInput::Password); + QCOMPARE(input->displayText(), QString(8, fillChar)); + input->setText(QString()); + QCOMPARE(input->displayText(), QString()); + + QTest::keyPress(&canvas, '0'); + QTest::keyPress(&canvas, '1'); + QTest::keyPress(&canvas, '2'); + QCOMPARE(input->displayText(), QString(2, fillChar) + QLatin1Char('2')); + QTest::keyPress(&canvas, '3'); + QTest::keyPress(&canvas, '4'); + QCOMPARE(input->displayText(), QString(4, fillChar) + QLatin1Char('4')); + QTest::keyPress(&canvas, Qt::Key_Backspace); + QCOMPARE(input->displayText(), QString(4, fillChar)); + QTest::keyPress(&canvas, '4'); + QCOMPARE(input->displayText(), QString(4, fillChar) + QLatin1Char('4')); + QTest::qWait(QT_GUI_PASSWORD_ECHO_DELAY); + QTRY_COMPARE(input->displayText(), QString(5, fillChar)); + QTest::keyPress(&canvas, '5'); + QCOMPARE(input->displayText(), QString(5, fillChar) + QLatin1Char('5')); + input->setFocus(false); + QVERIFY(!input->hasFocus()); + QCOMPARE(input->displayText(), QString(6, fillChar)); + input->setFocus(true); + QTRY_VERIFY(input->hasFocus()); + QCOMPARE(input->displayText(), QString(6, fillChar)); + QTest::keyPress(&canvas, '6'); + QCOMPARE(input->displayText(), QString(6, fillChar) + QLatin1Char('6')); + + QInputMethodEvent ev; + ev.setCommitString(QLatin1String("7")); + QGuiApplication::sendEvent(qGuiApp->focusObject(), &ev); + QCOMPARE(input->displayText(), QString(7, fillChar) + QLatin1Char('7')); + + input->setCursorPosition(3); + QCOMPARE(input->displayText(), QString(7, fillChar) + QLatin1Char('7')); + QTest::keyPress(&canvas, 'a'); + QCOMPARE(input->displayText(), QString(3, fillChar) + QLatin1Char('a') + QString(5, fillChar)); + QTest::keyPress(&canvas, Qt::Key_Backspace); + QCOMPARE(input->displayText(), QString(8, fillChar)); +} +#endif + + +void tst_qquicktextinput::simulateKey(QQuickView *view, int key) +{ + QKeyEvent press(QKeyEvent::KeyPress, key, 0); + QKeyEvent release(QKeyEvent::KeyRelease, key, 0); + + QGuiApplication::sendEvent(view, &press); + QGuiApplication::sendEvent(view, &release); +} + + +void tst_qquicktextinput::openInputPanel() +{ + PlatformInputContext platformInputContext; + QInputMethodPrivate *inputMethodPrivate = QInputMethodPrivate::get(qApp->inputMethod()); + inputMethodPrivate->testContext = &platformInputContext; + + QQuickView view(testFileUrl("openInputPanel.qml")); + view.show(); + view.requestActivateWindow(); + QTest::qWaitForWindowShown(&view); + QTRY_COMPARE(&view, qGuiApp->focusWindow()); + + QQuickTextInput *input = qobject_cast(view.rootObject()); + QVERIFY(input); + + // check default values + QVERIFY(input->focusOnPress()); + QVERIFY(!input->hasActiveFocus()); + QVERIFY(qApp->focusObject() != input); + QCOMPARE(qApp->inputMethod()->visible(), false); + + // input panel should open on focus + QPoint centerPoint(view.width()/2, view.height()/2); + Qt::KeyboardModifiers noModifiers = 0; + QTest::mousePress(&view, Qt::LeftButton, noModifiers, centerPoint); + QGuiApplication::processEvents(); + QVERIFY(input->hasActiveFocus()); + QCOMPARE(qApp->focusObject(), input); + QCOMPARE(qApp->inputMethod()->visible(), true); + QTest::mouseRelease(&view, Qt::LeftButton, noModifiers, centerPoint); + + // input panel should be re-opened when pressing already focused TextInput + qApp->inputMethod()->hide(); + QCOMPARE(qApp->inputMethod()->visible(), false); + QVERIFY(input->hasActiveFocus()); + QTest::mousePress(&view, Qt::LeftButton, noModifiers, centerPoint); + QGuiApplication::processEvents(); + QCOMPARE(qApp->inputMethod()->visible(), true); + QTest::mouseRelease(&view, Qt::LeftButton, noModifiers, centerPoint); + + // input panel should stay visible if focus is lost to another text inputor + QSignalSpy inputPanelVisibilitySpy(qApp->inputMethod(), SIGNAL(visibleChanged())); + QQuickTextInput anotherInput; + anotherInput.componentComplete(); + anotherInput.setParentItem(view.rootObject()); + anotherInput.setFocus(true); + QCOMPARE(qApp->inputMethod()->visible(), true); + QCOMPARE(qApp->focusObject(), qobject_cast(&anotherInput)); + QCOMPARE(inputPanelVisibilitySpy.count(), 0); + + anotherInput.setFocus(false); + QVERIFY(qApp->focusObject() != &anotherInput); + QCOMPARE(view.activeFocusItem(), view.rootItem()); + anotherInput.setFocus(true); + + qApp->inputMethod()->hide(); + + // input panel should not be opened if TextInput is read only + input->setReadOnly(true); + input->setFocus(true); + QCOMPARE(qApp->inputMethod()->visible(), false); + QTest::mousePress(&view, Qt::LeftButton, noModifiers, centerPoint); + QTest::mouseRelease(&view, Qt::LeftButton, noModifiers, centerPoint); + QGuiApplication::processEvents(); + QCOMPARE(qApp->inputMethod()->visible(), false); + + // input panel should not be opened if focusOnPress is set to false + input->setFocusOnPress(false); + input->setFocus(false); + input->setFocus(true); + QCOMPARE(qApp->inputMethod()->visible(), false); + QTest::mousePress(&view, Qt::LeftButton, noModifiers, centerPoint); + QTest::mouseRelease(&view, Qt::LeftButton, noModifiers, centerPoint); + QCOMPARE(qApp->inputMethod()->visible(), false); + + // input panel should open when openSoftwareInputPanel is called + input->openSoftwareInputPanel(); + QCOMPARE(qApp->inputMethod()->visible(), true); + + // input panel should close when closeSoftwareInputPanel is called + input->closeSoftwareInputPanel(); + QCOMPARE(qApp->inputMethod()->visible(), false); +} + +class MyTextInput : public QQuickTextInput +{ +public: + MyTextInput(QQuickItem *parent = 0) : QQuickTextInput(parent) + { + nbPaint = 0; + } + virtual QSGNode *updatePaintNode(QSGNode *node, UpdatePaintNodeData *data) + { + nbPaint++; + return QQuickTextInput::updatePaintNode(node, data); + } + int nbPaint; +}; + +void tst_qquicktextinput::setHAlignClearCache() +{ + QQuickView view; + MyTextInput input; + input.setText("Hello world"); + input.setParentItem(view.rootItem()); + view.show(); + view.requestActivateWindow(); + QTest::qWaitForWindowShown(&view); +#ifdef Q_OS_MAC + QEXPECT_FAIL("", "QTBUG-23485", Abort); +#endif + QTRY_COMPARE(input.nbPaint, 1); + input.setHAlign(QQuickTextInput::AlignRight); + //Changing the alignment should trigger a repaint + QTRY_COMPARE(input.nbPaint, 2); +} + +void tst_qquicktextinput::focusOutClearSelection() +{ + QQuickView view; + QQuickTextInput input; + QQuickTextInput input2; + input.setText(QLatin1String("Hello world")); + input.setFocus(true); + input2.setParentItem(view.rootItem()); + input.setParentItem(view.rootItem()); + input.componentComplete(); + input2.componentComplete(); + view.show(); + view.requestActivateWindow(); + QTest::qWaitForWindowShown(&view); + input.select(2,5); + //The selection should work + QTRY_COMPARE(input.selectedText(), QLatin1String("llo")); + input2.setFocus(true); + QGuiApplication::processEvents(); + //The input lost the focus selection should be cleared + QTRY_COMPARE(input.selectedText(), QLatin1String("")); +} + +void tst_qquicktextinput::geometrySignals() +{ + QQmlComponent component(&engine, testFileUrl("geometrySignals.qml")); + QObject *o = component.create(); + QVERIFY(o); + QCOMPARE(o->property("bindingWidth").toInt(), 400); + QCOMPARE(o->property("bindingHeight").toInt(), 500); + delete o; +} + +void tst_qquicktextinput::contentSize() +{ + QString componentStr = "import QtQuick 2.0\nTextInput { width: 75; height: 16; font.pixelSize: 10 }"; + QQmlComponent textComponent(&engine); + textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); + QScopedPointer object(textComponent.create()); + QQuickTextInput *textObject = qobject_cast(object.data()); + + QSignalSpy spy(textObject, SIGNAL(contentSizeChanged())); + + textObject->setText("The quick red fox jumped over the lazy brown dog"); + + QVERIFY(textObject->contentWidth() > textObject->width()); + QVERIFY(textObject->contentHeight() < textObject->height()); + QCOMPARE(spy.count(), 1); + + textObject->setWrapMode(QQuickTextInput::WordWrap); + QVERIFY(textObject->contentWidth() <= textObject->width()); + QVERIFY(textObject->contentHeight() > textObject->height()); + QCOMPARE(spy.count(), 2); + + textObject->setText("The quickredfoxjumpedoverthe lazy brown dog"); + + QVERIFY(textObject->contentWidth() > textObject->width()); + QVERIFY(textObject->contentHeight() > textObject->height()); + QCOMPARE(spy.count(), 3); +} + +static void sendPreeditText(const QString &text, int cursor) +{ + QInputMethodEvent event(text, QList() + << QInputMethodEvent::Attribute(QInputMethodEvent::Cursor, cursor, text.length(), QVariant())); + QCoreApplication::sendEvent(qGuiApp->focusObject(), &event); +} + +void tst_qquicktextinput::preeditAutoScroll() +{ + QString preeditText = "califragisiticexpialidocious!"; + + QQuickView view(testFileUrl("preeditAutoScroll.qml")); + view.show(); + view.requestActivateWindow(); + QTest::qWaitForWindowShown(&view); + QTRY_COMPARE(&view, qGuiApp->focusWindow()); + QQuickTextInput *input = qobject_cast(view.rootObject()); + QVERIFY(input); + QVERIFY(input->hasActiveFocus()); + + input->setWidth(input->implicitWidth()); + + QSignalSpy cursorRectangleSpy(input, SIGNAL(cursorRectangleChanged())); + int cursorRectangleChanges = 0; + + // test the text is scrolled so the preedit is visible. + sendPreeditText(preeditText.mid(0, 3), 1); + QVERIFY(evaluate(input, QString("positionAt(0)")) != 0); + QVERIFY(input->cursorRectangle().left() < input->boundingRect().width()); + QCOMPARE(cursorRectangleSpy.count(), ++cursorRectangleChanges); + + // test the text is scrolled back when the preedit is removed. + QInputMethodEvent imEvent; + QCoreApplication::sendEvent(qGuiApp->focusObject(), &imEvent); + QCOMPARE(evaluate(input, QString("positionAt(%1)").arg(0)), 0); + QCOMPARE(evaluate(input, QString("positionAt(%1)").arg(input->width())), 5); + QCOMPARE(cursorRectangleSpy.count(), ++cursorRectangleChanges); + + QTextLayout layout(preeditText); + layout.setFont(input->font()); + if (!qmlDisableDistanceField()) { + QTextOption option; + option.setUseDesignMetrics(true); + layout.setTextOption(option); + } + layout.beginLayout(); + QTextLine line = layout.createLine(); + layout.endLayout(); + + // test if the preedit is larger than the text input that the + // character preceding the cursor is still visible. + qreal x = input->positionToRectangle(0).x(); + for (int i = 0; i < 3; ++i) { + sendPreeditText(preeditText, i + 1); + int width = ceil(line.cursorToX(i, QTextLine::Trailing)) - floor(line.cursorToX(i)); + QVERIFY(input->cursorRectangle().right() >= width - 3); + QVERIFY(input->positionToRectangle(0).x() < x); + QCOMPARE(cursorRectangleSpy.count(), ++cursorRectangleChanges); + x = input->positionToRectangle(0).x(); + } + for (int i = 1; i >= 0; --i) { + sendPreeditText(preeditText, i + 1); + int width = ceil(line.cursorToX(i, QTextLine::Trailing)) - floor(line.cursorToX(i)); + QVERIFY(input->cursorRectangle().right() >= width - 3); + QVERIFY(input->positionToRectangle(0).x() > x); + QCOMPARE(cursorRectangleSpy.count(), ++cursorRectangleChanges); + x = input->positionToRectangle(0).x(); + } + + // Test incrementing the preedit cursor doesn't cause further + // scrolling when right most text is visible. + sendPreeditText(preeditText, preeditText.length() - 3); + QCOMPARE(cursorRectangleSpy.count(), ++cursorRectangleChanges); + x = input->positionToRectangle(0).x(); + for (int i = 2; i >= 0; --i) { + sendPreeditText(preeditText, preeditText.length() - i); + QCOMPARE(input->positionToRectangle(0).x(), x); + QCOMPARE(cursorRectangleSpy.count(), ++cursorRectangleChanges); + } + for (int i = 1; i < 3; ++i) { + sendPreeditText(preeditText, preeditText.length() - i); + QCOMPARE(input->positionToRectangle(0).x(), x); + QCOMPARE(cursorRectangleSpy.count(), ++cursorRectangleChanges); + } + + // Test disabling auto scroll. + QCoreApplication::sendEvent(qGuiApp->focusObject(), &imEvent); + + input->setAutoScroll(false); + sendPreeditText(preeditText.mid(0, 3), 1); + QCOMPARE(evaluate(input, QString("positionAt(%1)").arg(0)), 0); + QCOMPARE(evaluate(input, QString("positionAt(%1)").arg(input->width())), 5); +} + +void tst_qquicktextinput::preeditCursorRectangle() +{ + QString preeditText = "super"; + + QQuickView view(testFileUrl("inputMethodEvent.qml")); + view.show(); + view.requestActivateWindow(); + QTest::qWaitForWindowShown(&view); + QTRY_COMPARE(&view, qGuiApp->focusWindow()); + QQuickTextInput *input = qobject_cast(view.rootObject()); + QVERIFY(input); + + QRect currentRect; + + QInputMethodQueryEvent query(Qt::ImCursorRectangle); + QCoreApplication::sendEvent(qGuiApp->focusObject(), &query); + QRect previousRect = query.value(Qt::ImCursorRectangle).toRect(); + + // Verify that the micro focus rect is positioned the same for position 0 as + // it would be if there was no preedit text. + sendPreeditText(preeditText, 0); + QCoreApplication::sendEvent(qGuiApp->focusObject(), &query); + currentRect = query.value(Qt::ImCursorRectangle).toRect(); + QCOMPARE(currentRect, previousRect); + + QSignalSpy inputSpy(input, SIGNAL(cursorRectangleChanged())); + QSignalSpy panelSpy(qGuiApp->inputMethod(), SIGNAL(cursorRectangleChanged())); + + // Verify that the micro focus rect moves to the left as the cursor position + // is incremented. + for (int i = 1; i <= 5; ++i) { + sendPreeditText(preeditText, i); + QCoreApplication::sendEvent(qGuiApp->focusObject(), &query); + currentRect = query.value(Qt::ImCursorRectangle).toRect(); + QVERIFY(previousRect.left() < currentRect.left()); + QVERIFY(inputSpy.count() > 0); inputSpy.clear(); + QVERIFY(panelSpy.count() > 0); panelSpy.clear(); + previousRect = currentRect; + } + + // Verify that if there is no preedit cursor then the micro focus rect is the + // same as it would be if it were positioned at the end of the preedit text. + sendPreeditText(preeditText, 0); + QInputMethodEvent imEvent(preeditText, QList()); + QCoreApplication::sendEvent(qGuiApp->focusObject(), &imEvent); + QCoreApplication::sendEvent(qGuiApp->focusObject(), &query); + currentRect = query.value(Qt::ImCursorRectangle).toRect(); + QCOMPARE(currentRect, previousRect); + QVERIFY(inputSpy.count() > 0); + QVERIFY(panelSpy.count() > 0); +} + +void tst_qquicktextinput::inputContextMouseHandler() +{ + PlatformInputContext platformInputContext; + QInputMethodPrivate *inputMethodPrivate = QInputMethodPrivate::get(qApp->inputMethod()); + inputMethodPrivate->testContext = &platformInputContext; + + QString text = "supercalifragisiticexpialidocious!"; + QQuickView view(testFileUrl("inputContext.qml")); + QQuickTextInput *input = qobject_cast(view.rootObject()); + QVERIFY(input); + + input->setFocus(true); + input->setText(""); + + view.show(); + view.requestActivateWindow(); + QTest::qWaitForWindowShown(&view); + QTRY_COMPARE(&view, qGuiApp->focusWindow()); + + QTextLayout layout(text); + layout.setFont(input->font()); + if (!qmlDisableDistanceField()) { + QTextOption option; + option.setUseDesignMetrics(true); + layout.setTextOption(option); + } + layout.beginLayout(); + QTextLine line = layout.createLine(); + layout.endLayout(); + + const qreal x = line.cursorToX(2, QTextLine::Leading); + const qreal y = line.height() / 2; + QPoint position = QPointF(x, y).toPoint(); + + QInputMethodEvent inputEvent(text.mid(0, 5), QList()); + QGuiApplication::sendEvent(input, &inputEvent); + + QTest::mousePress(&view, Qt::LeftButton, Qt::NoModifier, position); + QTest::mouseRelease(&view, Qt::LeftButton, Qt::NoModifier, position); + QGuiApplication::processEvents(); + + QCOMPARE(platformInputContext.m_action, QInputMethod::Click); + QCOMPARE(platformInputContext.m_invokeActionCallCount, 1); + QCOMPARE(platformInputContext.m_cursorPosition, 2); +} + +void tst_qquicktextinput::inputMethodComposing() +{ + QString text = "supercalifragisiticexpialidocious!"; + + QQuickView view(testFileUrl("inputContext.qml")); + view.show(); + view.requestActivateWindow(); + QTest::qWaitForWindowShown(&view); + QTRY_COMPARE(&view, qGuiApp->focusWindow()); + QQuickTextInput *input = qobject_cast(view.rootObject()); + QVERIFY(input); + QSignalSpy spy(input, SIGNAL(inputMethodComposingChanged())); + + QCOMPARE(input->isInputMethodComposing(), false); + { + QInputMethodEvent event(text.mid(3), QList()); + QGuiApplication::sendEvent(input, &event); + } + QCOMPARE(input->isInputMethodComposing(), true); + QCOMPARE(spy.count(), 1); + + { + QInputMethodEvent event(text.mid(12), QList()); + QGuiApplication::sendEvent(input, &event); + } + QCOMPARE(spy.count(), 1); + + { + QInputMethodEvent event; + QGuiApplication::sendEvent(input, &event); + } + QCOMPARE(input->isInputMethodComposing(), false); + QCOMPARE(spy.count(), 2); +} + +void tst_qquicktextinput::inputMethodUpdate() +{ + PlatformInputContext platformInputContext; + QInputMethodPrivate *inputMethodPrivate = QInputMethodPrivate::get(qApp->inputMethod()); + inputMethodPrivate->testContext = &platformInputContext; + + QQuickView view(testFileUrl("inputContext.qml")); + view.show(); + view.requestActivateWindow(); + QTest::qWaitForWindowShown(&view); + QTRY_COMPARE(&view, qGuiApp->focusWindow()); + QQuickTextInput *input = qobject_cast(view.rootObject()); + QVERIFY(input); + + // text change even without cursor position change needs to trigger update + input->setText("test"); + platformInputContext.clear(); + input->setText("xxxx"); + QVERIFY(platformInputContext.m_updateCallCount > 0); + + // input method event replacing text + platformInputContext.clear(); + { + QInputMethodEvent inputMethodEvent; + inputMethodEvent.setCommitString("y", -1, 1); + QGuiApplication::sendEvent(input, &inputMethodEvent); + } + QVERIFY(platformInputContext.m_updateCallCount > 0); + + // input method changing selection + platformInputContext.clear(); + { + QList attributes; + attributes << QInputMethodEvent::Attribute(QInputMethodEvent::Selection, 0, 2, QVariant()); + QInputMethodEvent inputMethodEvent("", attributes); + QGuiApplication::sendEvent(input, &inputMethodEvent); + } + QVERIFY(input->selectionStart() != input->selectionEnd()); + QVERIFY(platformInputContext.m_updateCallCount > 0); + + // programmatical selections trigger update + platformInputContext.clear(); + input->selectAll(); + QVERIFY(platformInputContext.m_updateCallCount > 0); + + // font changes + platformInputContext.clear(); + QFont font = input->font(); + font.setBold(!font.bold()); + input->setFont(font); + QVERIFY(platformInputContext.m_updateCallCount > 0); + + // normal input + platformInputContext.clear(); + { + QInputMethodEvent inputMethodEvent; + inputMethodEvent.setCommitString("y"); + QGuiApplication::sendEvent(input, &inputMethodEvent); + } + QVERIFY(platformInputContext.m_updateCallCount > 0); + + // changing cursor position + platformInputContext.clear(); + input->setCursorPosition(0); + QVERIFY(platformInputContext.m_updateCallCount > 0); + + // read only disabled input method + platformInputContext.clear(); + input->setReadOnly(true); + QVERIFY(platformInputContext.m_updateCallCount > 0); + input->setReadOnly(false); + + // no updates while no focus + input->setFocus(false); + platformInputContext.clear(); + input->setText("Foo"); + QCOMPARE(platformInputContext.m_updateCallCount, 0); + input->setCursorPosition(1); + QCOMPARE(platformInputContext.m_updateCallCount, 0); + input->selectAll(); + QCOMPARE(platformInputContext.m_updateCallCount, 0); + input->setReadOnly(true); + QCOMPARE(platformInputContext.m_updateCallCount, 0); +} + +void tst_qquicktextinput::cursorRectangleSize() +{ + QQuickView *canvas = new QQuickView(testFileUrl("positionAt.qml")); + QVERIFY(canvas->rootObject() != 0); + QQuickTextInput *textInput = qobject_cast(canvas->rootObject()); + + // make sure cursor rectangle is not at (0,0) + textInput->setX(10); + textInput->setY(10); + textInput->setCursorPosition(3); + QVERIFY(textInput != 0); + textInput->setFocus(true); + canvas->show(); + canvas->requestActivateWindow(); + QTest::qWaitForWindowShown(canvas); + QTRY_VERIFY(qApp->focusObject()); + + QInputMethodQueryEvent event(Qt::ImCursorRectangle); + qApp->sendEvent(qApp->focusObject(), &event); + QRectF cursorRectFromQuery = event.value(Qt::ImCursorRectangle).toRectF(); + + QRect cursorRectFromItem = textInput->cursorRectangle(); + QRectF cursorRectFromPositionToRectangle = textInput->positionToRectangle(textInput->cursorPosition()); + + // item and input query cursor rectangles match + QCOMPARE(cursorRectFromItem, cursorRectFromQuery.toRect()); + + // item cursor rectangle and positionToRectangle calculations match + QCOMPARE(cursorRectFromItem, cursorRectFromPositionToRectangle.toRect()); + + // item-canvas transform and input item transform match + QCOMPARE(QQuickItemPrivate::get(textInput)->itemToCanvasTransform(), qApp->inputMethod()->inputItemTransform()); + + // input panel cursorRectangle property and tranformed item cursor rectangle match + QRectF sceneCursorRect = QQuickItemPrivate::get(textInput)->itemToCanvasTransform().mapRect(cursorRectFromItem); + QCOMPARE(sceneCursorRect, qApp->inputMethod()->cursorRectangle()); + + delete canvas; +} + +void tst_qquicktextinput::tripleClickSelectsAll() +{ + QString qmlfile = testFile("positionAt.qml"); + QQuickView view(QUrl::fromLocalFile(qmlfile)); + view.show(); + view.requestActivateWindow(); + QTest::qWaitForWindowShown(&view); + + QTRY_COMPARE(&view, qGuiApp->focusWindow()); + + QQuickTextInput* input = qobject_cast(view.rootObject()); + QVERIFY(input); + + QLatin1String hello("Hello world!"); + input->setSelectByMouse(true); + input->setText(hello); + + // Clicking on the same point inside TextInput three times in a row + // should trigger a triple click, thus selecting all the text. + QPoint pointInside = input->pos().toPoint() + QPoint(2,2); + QTest::mouseDClick(&view, Qt::LeftButton, 0, pointInside); + QTest::mouseClick(&view, Qt::LeftButton, 0, pointInside); + QGuiApplication::processEvents(); + QCOMPARE(input->selectedText(), hello); + + // Now it simulates user moving the mouse between the second and the third click. + // In this situation, we don't expect a triple click. + QPoint pointInsideButFar = QPoint(input->width(),input->height()) - QPoint(2,2); + QTest::mouseDClick(&view, Qt::LeftButton, 0, pointInside); + QTest::mouseClick(&view, Qt::LeftButton, 0, pointInsideButFar); + QGuiApplication::processEvents(); + QVERIFY(input->selectedText().isEmpty()); + + // And now we press the third click too late, so no triple click event is triggered. + QTest::mouseDClick(&view, Qt::LeftButton, 0, pointInside); + QGuiApplication::processEvents(); + QTest::qWait(qApp->styleHints()->mouseDoubleClickInterval() + 1); + QTest::mouseClick(&view, Qt::LeftButton, 0, pointInside); + QGuiApplication::processEvents(); + QVERIFY(input->selectedText().isEmpty()); +} + +void tst_qquicktextinput::QTBUG_19956_data() +{ + QTest::addColumn("url"); + QTest::newRow("intvalidator") << "qtbug-19956int.qml"; + QTest::newRow("doublevalidator") << "qtbug-19956double.qml"; +} + + +void tst_qquicktextinput::getText_data() +{ + QTest::addColumn("text"); + QTest::addColumn("inputMask"); + QTest::addColumn("start"); + QTest::addColumn("end"); + QTest::addColumn("expectedText"); + + QTest::newRow("all plain text") + << standard.at(0) + << QString() + << 0 << standard.at(0).length() + << standard.at(0); + + QTest::newRow("plain text sub string") + << standard.at(0) + << QString() + << 0 << 12 + << standard.at(0).mid(0, 12); + + QTest::newRow("plain text sub string reversed") + << standard.at(0) + << QString() + << 12 << 0 + << standard.at(0).mid(0, 12); + + QTest::newRow("plain text cropped beginning") + << standard.at(0) + << QString() + << -3 << 4 + << standard.at(0).mid(0, 4); + + QTest::newRow("plain text cropped end") + << standard.at(0) + << QString() + << 23 << standard.at(0).length() + 8 + << standard.at(0).mid(23); + + QTest::newRow("plain text cropped beginning and end") + << standard.at(0) + << QString() + << -9 << standard.at(0).length() + 4 + << standard.at(0); +} + +void tst_qquicktextinput::getText() +{ + QFETCH(QString, text); + QFETCH(QString, inputMask); + QFETCH(int, start); + QFETCH(int, end); + QFETCH(QString, expectedText); + + QString componentStr = "import QtQuick 2.0\nTextInput { text: \"" + text + "\"; inputMask: \"" + inputMask + "\" }"; + QQmlComponent textInputComponent(&engine); + textInputComponent.setData(componentStr.toLatin1(), QUrl()); + QQuickTextInput *textInput = qobject_cast(textInputComponent.create()); + QVERIFY(textInput != 0); + + QCOMPARE(textInput->getText(start, end), expectedText); +} + +void tst_qquicktextinput::insert_data() +{ + QTest::addColumn("text"); + QTest::addColumn("inputMask"); + QTest::addColumn("selectionStart"); + QTest::addColumn("selectionEnd"); + QTest::addColumn("insertPosition"); + QTest::addColumn("insertText"); + QTest::addColumn("expectedText"); + QTest::addColumn("expectedSelectionStart"); + QTest::addColumn("expectedSelectionEnd"); + QTest::addColumn("expectedCursorPosition"); + QTest::addColumn("selectionChanged"); + QTest::addColumn("cursorPositionChanged"); + + QTest::newRow("at cursor position (beginning)") + << standard.at(0) + << QString() + << 0 << 0 << 0 + << QString("Hello") + << QString("Hello") + standard.at(0) + << 5 << 5 << 5 + << false << true; + + QTest::newRow("at cursor position (end)") + << standard.at(0) + << QString() + << standard.at(0).length() << standard.at(0).length() << standard.at(0).length() + << QString("Hello") + << standard.at(0) + QString("Hello") + << standard.at(0).length() + 5 << standard.at(0).length() + 5 << standard.at(0).length() + 5 + << false << true; + + QTest::newRow("at cursor position (middle)") + << standard.at(0) + << QString() + << 18 << 18 << 18 + << QString("Hello") + << standard.at(0).mid(0, 18) + QString("Hello") + standard.at(0).mid(18) + << 23 << 23 << 23 + << false << true; + + QTest::newRow("after cursor position (beginning)") + << standard.at(0) + << QString() + << 0 << 0 << 18 + << QString("Hello") + << standard.at(0).mid(0, 18) + QString("Hello") + standard.at(0).mid(18) + << 0 << 0 << 0 + << false << false; + + QTest::newRow("before cursor position (end)") + << standard.at(0) + << QString() + << standard.at(0).length() << standard.at(0).length() << 18 + << QString("Hello") + << standard.at(0).mid(0, 18) + QString("Hello") + standard.at(0).mid(18) + << standard.at(0).length() + 5 << standard.at(0).length() + 5 << standard.at(0).length() + 5 + << false << true; + + QTest::newRow("before cursor position (middle)") + << standard.at(0) + << QString() + << 18 << 18 << 0 + << QString("Hello") + << QString("Hello") + standard.at(0) + << 23 << 23 << 23 + << false << true; + + QTest::newRow("after cursor position (middle)") + << standard.at(0) + << QString() + << 18 << 18 << standard.at(0).length() + << QString("Hello") + << standard.at(0) + QString("Hello") + << 18 << 18 << 18 + << false << false; + + QTest::newRow("before selection") + << standard.at(0) + << QString() + << 14 << 19 << 0 + << QString("Hello") + << QString("Hello") + standard.at(0) + << 19 << 24 << 24 + << false << true; + + QTest::newRow("before reversed selection") + << standard.at(0) + << QString() + << 19 << 14 << 0 + << QString("Hello") + << QString("Hello") + standard.at(0) + << 19 << 24 << 19 + << false << true; + + QTest::newRow("after selection") + << standard.at(0) + << QString() + << 14 << 19 << standard.at(0).length() + << QString("Hello") + << standard.at(0) + QString("Hello") + << 14 << 19 << 19 + << false << false; + + QTest::newRow("after reversed selection") + << standard.at(0) + << QString() + << 19 << 14 << standard.at(0).length() + << QString("Hello") + << standard.at(0) + QString("Hello") + << 14 << 19 << 14 + << false << false; + + QTest::newRow("into selection") + << standard.at(0) + << QString() + << 14 << 19 << 18 + << QString("Hello") + << standard.at(0).mid(0, 18) + QString("Hello") + standard.at(0).mid(18) + << 14 << 24 << 24 + << true << true; + + QTest::newRow("into reversed selection") + << standard.at(0) + << QString() + << 19 << 14 << 18 + << QString("Hello") + << standard.at(0).mid(0, 18) + QString("Hello") + standard.at(0).mid(18) + << 14 << 24 << 14 + << true << false; + + QTest::newRow("rich text into plain text") + << standard.at(0) + << QString() + << 0 << 0 << 0 + << QString("Hello") + << QString("Hello") + standard.at(0) + << 12 << 12 << 12 + << false << true; + + QTest::newRow("before start") + << standard.at(0) + << QString() + << 0 << 0 << -3 + << QString("Hello") + << standard.at(0) + << 0 << 0 << 0 + << false << false; + + QTest::newRow("past end") + << standard.at(0) + << QString() + << 0 << 0 << standard.at(0).length() + 3 + << QString("Hello") + << standard.at(0) + << 0 << 0 << 0 + << false << false; + + const QString inputMask = "009.009.009.009"; + const QString ip = "192.168.2.14"; + + QTest::newRow("mask: at cursor position (beginning)") + << ip + << inputMask + << 0 << 0 << 0 + << QString("125") + << QString("125.168.2.14") + << 0 << 0 << 0 + << false << false; + + QTest::newRow("mask: at cursor position (end)") + << ip + << inputMask + << inputMask.length() << inputMask.length() << inputMask.length() + << QString("8") + << ip + << inputMask.length() << inputMask.length() << inputMask.length() + << false << false; + + QTest::newRow("mask: at cursor position (middle)") + << ip + << inputMask + << 6 << 6 << 6 + << QString("75.2") + << QString("192.167.5.24") + << 6 << 6 << 6 + << false << false; + + QTest::newRow("mask: after cursor position (beginning)") + << ip + << inputMask + << 0 << 0 << 6 + << QString("75.2") + << QString("192.167.5.24") + << 0 << 0 << 0 + << false << false; + + QTest::newRow("mask: before cursor position (end)") + << ip + << inputMask + << inputMask.length() << inputMask.length() << 6 + << QString("75.2") + << QString("192.167.5.24") + << inputMask.length() << inputMask.length() << inputMask.length() + << false << false; + + QTest::newRow("mask: before cursor position (middle)") + << ip + << inputMask + << 6 << 6 << 0 + << QString("125") + << QString("125.168.2.14") + << 6 << 6 << 6 + << false << false; + + QTest::newRow("mask: after cursor position (middle)") + << ip + << inputMask + << 6 << 6 << 13 + << QString("8") + << "192.168.2.18" + << 6 << 6 << 6 + << false << false; + + QTest::newRow("mask: before selection") + << ip + << inputMask + << 6 << 8 << 0 + << QString("125") + << QString("125.168.2.14") + << 6 << 8 << 8 + << false << false; + + QTest::newRow("mask: before reversed selection") + << ip + << inputMask + << 8 << 6 << 0 + << QString("125") + << QString("125.168.2.14") + << 6 << 8 << 6 + << false << false; + + QTest::newRow("mask: after selection") + << ip + << inputMask + << 6 << 8 << 13 + << QString("8") + << "192.168.2.18" + << 6 << 8 << 8 + << false << false; + + QTest::newRow("mask: after reversed selection") + << ip + << inputMask + << 8 << 6 << 13 + << QString("8") + << "192.168.2.18" + << 6 << 8 << 6 + << false << false; + + QTest::newRow("mask: into selection") + << ip + << inputMask + << 5 << 8 << 6 + << QString("75.2") + << QString("192.167.5.24") + << 5 << 8 << 8 + << true << false; + + QTest::newRow("mask: into reversed selection") + << ip + << inputMask + << 8 << 5 << 6 + << QString("75.2") + << QString("192.167.5.24") + << 5 << 8 << 5 + << true << false; + + QTest::newRow("mask: before start") + << ip + << inputMask + << 0 << 0 << -3 + << QString("4") + << ip + << 0 << 0 << 0 + << false << false; + + QTest::newRow("mask: past end") + << ip + << inputMask + << 0 << 0 << ip.length() + 3 + << QString("4") + << ip + << 0 << 0 << 0 + << false << false; + + QTest::newRow("mask: invalid characters") + << ip + << inputMask + << 0 << 0 << 0 + << QString("abc") + << QString("192.168.2.14") + << 0 << 0 << 0 + << false << false; + + QTest::newRow("mask: mixed validity") + << ip + << inputMask + << 0 << 0 << 0 + << QString("a1b2c5") + << QString("125.168.2.14") + << 0 << 0 << 0 + << false << false; +} + +void tst_qquicktextinput::insert() +{ + QFETCH(QString, text); + QFETCH(QString, inputMask); + QFETCH(int, selectionStart); + QFETCH(int, selectionEnd); + QFETCH(int, insertPosition); + QFETCH(QString, insertText); + QFETCH(QString, expectedText); + QFETCH(int, expectedSelectionStart); + QFETCH(int, expectedSelectionEnd); + QFETCH(int, expectedCursorPosition); + QFETCH(bool, selectionChanged); + QFETCH(bool, cursorPositionChanged); + + QString componentStr = "import QtQuick 2.0\nTextInput { text: \"" + text + "\"; inputMask: \"" + inputMask + "\" }"; + QQmlComponent textInputComponent(&engine); + textInputComponent.setData(componentStr.toLatin1(), QUrl()); + QQuickTextInput *textInput = qobject_cast(textInputComponent.create()); + QVERIFY(textInput != 0); + + textInput->select(selectionStart, selectionEnd); + + QSignalSpy selectionSpy(textInput, SIGNAL(selectedTextChanged())); + QSignalSpy selectionStartSpy(textInput, SIGNAL(selectionStartChanged())); + QSignalSpy selectionEndSpy(textInput, SIGNAL(selectionEndChanged())); + QSignalSpy textSpy(textInput, SIGNAL(textChanged())); + QSignalSpy cursorPositionSpy(textInput, SIGNAL(cursorPositionChanged())); + + textInput->insert(insertPosition, insertText); + + QCOMPARE(textInput->text(), expectedText); + QCOMPARE(textInput->length(), inputMask.isEmpty() ? expectedText.length() : inputMask.length()); + + QCOMPARE(textInput->selectionStart(), expectedSelectionStart); + QCOMPARE(textInput->selectionEnd(), expectedSelectionEnd); + QCOMPARE(textInput->cursorPosition(), expectedCursorPosition); + + if (selectionStart > selectionEnd) + qSwap(selectionStart, selectionEnd); + + QCOMPARE(selectionSpy.count() > 0, selectionChanged); + QCOMPARE(selectionStartSpy.count() > 0, selectionStart != expectedSelectionStart); + QCOMPARE(selectionEndSpy.count() > 0, selectionEnd != expectedSelectionEnd); + QCOMPARE(textSpy.count() > 0, text != expectedText); + QCOMPARE(cursorPositionSpy.count() > 0, cursorPositionChanged); +} + +void tst_qquicktextinput::remove_data() +{ + QTest::addColumn("text"); + QTest::addColumn("inputMask"); + QTest::addColumn("selectionStart"); + QTest::addColumn("selectionEnd"); + QTest::addColumn("removeStart"); + QTest::addColumn("removeEnd"); + QTest::addColumn("expectedText"); + QTest::addColumn("expectedSelectionStart"); + QTest::addColumn("expectedSelectionEnd"); + QTest::addColumn("expectedCursorPosition"); + QTest::addColumn("selectionChanged"); + QTest::addColumn("cursorPositionChanged"); + + QTest::newRow("from cursor position (beginning)") + << standard.at(0) + << QString() + << 0 << 0 + << 0 << 5 + << standard.at(0).mid(5) + << 0 << 0 << 0 + << false << false; + + QTest::newRow("to cursor position (beginning)") + << standard.at(0) + << QString() + << 0 << 0 + << 5 << 0 + << standard.at(0).mid(5) + << 0 << 0 << 0 + << false << false; + + QTest::newRow("to cursor position (end)") + << standard.at(0) + << QString() + << standard.at(0).length() << standard.at(0).length() + << standard.at(0).length() << standard.at(0).length() - 5 + << standard.at(0).mid(0, standard.at(0).length() - 5) + << standard.at(0).length() - 5 << standard.at(0).length() - 5 << standard.at(0).length() - 5 + << false << true; + + QTest::newRow("to cursor position (end)") + << standard.at(0) + << QString() + << standard.at(0).length() << standard.at(0).length() + << standard.at(0).length() - 5 << standard.at(0).length() + << standard.at(0).mid(0, standard.at(0).length() - 5) + << standard.at(0).length() - 5 << standard.at(0).length() - 5 << standard.at(0).length() - 5 + << false << true; + + QTest::newRow("from cursor position (middle)") + << standard.at(0) + << QString() + << 18 << 18 + << 18 << 23 + << standard.at(0).mid(0, 18) + standard.at(0).mid(23) + << 18 << 18 << 18 + << false << false; + + QTest::newRow("to cursor position (middle)") + << standard.at(0) + << QString() + << 23 << 23 + << 18 << 23 + << standard.at(0).mid(0, 18) + standard.at(0).mid(23) + << 18 << 18 << 18 + << false << true; + + QTest::newRow("after cursor position (beginning)") + << standard.at(0) + << QString() + << 0 << 0 + << 18 << 23 + << standard.at(0).mid(0, 18) + standard.at(0).mid(23) + << 0 << 0 << 0 + << false << false; + + QTest::newRow("before cursor position (end)") + << standard.at(0) + << QString() + << standard.at(0).length() << standard.at(0).length() + << 18 << 23 + << standard.at(0).mid(0, 18) + standard.at(0).mid(23) + << standard.at(0).length() - 5 << standard.at(0).length() - 5 << standard.at(0).length() - 5 + << false << true; + + QTest::newRow("before cursor position (middle)") + << standard.at(0) + << QString() + << 23 << 23 + << 0 << 5 + << standard.at(0).mid(5) + << 18 << 18 << 18 + << false << true; + + QTest::newRow("after cursor position (middle)") + << standard.at(0) + << QString() + << 18 << 18 + << 18 << 23 + << standard.at(0).mid(0, 18) + standard.at(0).mid(23) + << 18 << 18 << 18 + << false << false; + + QTest::newRow("before selection") + << standard.at(0) + << QString() + << 14 << 19 + << 0 << 5 + << standard.at(0).mid(5) + << 9 << 14 << 14 + << false << true; + + QTest::newRow("before reversed selection") + << standard.at(0) + << QString() + << 19 << 14 + << 0 << 5 + << standard.at(0).mid(5) + << 9 << 14 << 9 + << false << true; + + QTest::newRow("after selection") + << standard.at(0) + << QString() + << 14 << 19 + << standard.at(0).length() - 5 << standard.at(0).length() + << standard.at(0).mid(0, standard.at(0).length() - 5) + << 14 << 19 << 19 + << false << false; + + QTest::newRow("after reversed selection") + << standard.at(0) + << QString() + << 19 << 14 + << standard.at(0).length() - 5 << standard.at(0).length() + << standard.at(0).mid(0, standard.at(0).length() - 5) + << 14 << 19 << 14 + << false << false; + + QTest::newRow("from selection") + << standard.at(0) + << QString() + << 14 << 24 + << 18 << 23 + << standard.at(0).mid(0, 18) + standard.at(0).mid(23) + << 14 << 19 << 19 + << true << true; + + QTest::newRow("from reversed selection") + << standard.at(0) + << QString() + << 24 << 14 + << 18 << 23 + << standard.at(0).mid(0, 18) + standard.at(0).mid(23) + << 14 << 19 << 14 + << true << false; + + QTest::newRow("cropped beginning") + << standard.at(0) + << QString() + << 0 << 0 + << -3 << 4 + << standard.at(0).mid(4) + << 0 << 0 << 0 + << false << false; + + QTest::newRow("cropped end") + << standard.at(0) + << QString() + << 0 << 0 + << 23 << standard.at(0).length() + 8 + << standard.at(0).mid(0, 23) + << 0 << 0 << 0 + << false << false; + + QTest::newRow("cropped beginning and end") + << standard.at(0) + << QString() + << 0 << 0 + << -9 << standard.at(0).length() + 4 + << QString() + << 0 << 0 << 0 + << false << false; + + const QString inputMask = "009.009.009.009"; + const QString ip = "192.168.2.14"; + + QTest::newRow("mask: from cursor position") + << ip + << inputMask + << 6 << 6 + << 6 << 9 + << QString("192.16..14") + << 6 << 6 << 6 + << false << false; + + QTest::newRow("mask: to cursor position") + << ip + << inputMask + << 6 << 6 + << 2 << 6 + << QString("19.8.2.14") + << 6 << 6 << 6 + << false << false; + + QTest::newRow("mask: before cursor position") + << ip + << inputMask + << 6 << 6 + << 0 << 2 + << QString("2.168.2.14") + << 6 << 6 << 6 + << false << false; + + QTest::newRow("mask: after cursor position") + << ip + << inputMask + << 6 << 6 + << 12 << 16 + << QString("192.168.2.") + << 6 << 6 << 6 + << false << false; + + QTest::newRow("mask: before selection") + << ip + << inputMask + << 6 << 8 + << 0 << 2 + << QString("2.168.2.14") + << 6 << 8 << 8 + << false << false; + + QTest::newRow("mask: before reversed selection") + << ip + << inputMask + << 8 << 6 + << 0 << 2 + << QString("2.168.2.14") + << 6 << 8 << 6 + << false << false; + + QTest::newRow("mask: after selection") + << ip + << inputMask + << 6 << 8 + << 12 << 16 + << QString("192.168.2.") + << 6 << 8 << 8 + << false << false; + + QTest::newRow("mask: after reversed selection") + << ip + << inputMask + << 8 << 6 + << 12 << 16 + << QString("192.168.2.") + << 6 << 8 << 6 + << false << false; + + QTest::newRow("mask: from selection") + << ip + << inputMask + << 6 << 13 + << 8 << 10 + << QString("192.168..14") + << 6 << 13 << 13 + << true << false; + + QTest::newRow("mask: from reversed selection") + << ip + << inputMask + << 13 << 6 + << 8 << 10 + << QString("192.168..14") + << 6 << 13 << 6 + << true << false; + + QTest::newRow("mask: cropped beginning") + << ip + << inputMask + << 0 << 0 + << -3 << 4 + << QString(".168.2.14") + << 0 << 0 << 0 + << false << false; + + QTest::newRow("mask: cropped end") + << ip + << inputMask + << 0 << 0 + << 13 << 28 + << QString("192.168.2.1") + << 0 << 0 << 0 + << false << false; + + QTest::newRow("mask: cropped beginning and end") + << ip + << inputMask + << 0 << 0 + << -9 << 28 + << QString("...") + << 0 << 0 << 0 + << false << false; +} + +void tst_qquicktextinput::remove() +{ + QFETCH(QString, text); + QFETCH(QString, inputMask); + QFETCH(int, selectionStart); + QFETCH(int, selectionEnd); + QFETCH(int, removeStart); + QFETCH(int, removeEnd); + QFETCH(QString, expectedText); + QFETCH(int, expectedSelectionStart); + QFETCH(int, expectedSelectionEnd); + QFETCH(int, expectedCursorPosition); + QFETCH(bool, selectionChanged); + QFETCH(bool, cursorPositionChanged); + + QString componentStr = "import QtQuick 2.0\nTextInput { text: \"" + text + "\"; inputMask: \"" + inputMask + "\" }"; + QQmlComponent textInputComponent(&engine); + textInputComponent.setData(componentStr.toLatin1(), QUrl()); + QQuickTextInput *textInput = qobject_cast(textInputComponent.create()); + QVERIFY(textInput != 0); + + textInput->select(selectionStart, selectionEnd); + + QSignalSpy selectionSpy(textInput, SIGNAL(selectedTextChanged())); + QSignalSpy selectionStartSpy(textInput, SIGNAL(selectionStartChanged())); + QSignalSpy selectionEndSpy(textInput, SIGNAL(selectionEndChanged())); + QSignalSpy textSpy(textInput, SIGNAL(textChanged())); + QSignalSpy cursorPositionSpy(textInput, SIGNAL(cursorPositionChanged())); + + textInput->remove(removeStart, removeEnd); + + QCOMPARE(textInput->text(), expectedText); + QCOMPARE(textInput->length(), inputMask.isEmpty() ? expectedText.length() : inputMask.length()); + + if (selectionStart > selectionEnd) // + qSwap(selectionStart, selectionEnd); + + QCOMPARE(textInput->selectionStart(), expectedSelectionStart); + QCOMPARE(textInput->selectionEnd(), expectedSelectionEnd); + QCOMPARE(textInput->cursorPosition(), expectedCursorPosition); + + QCOMPARE(selectionSpy.count() > 0, selectionChanged); + QCOMPARE(selectionStartSpy.count() > 0, selectionStart != expectedSelectionStart); + QCOMPARE(selectionEndSpy.count() > 0, selectionEnd != expectedSelectionEnd); + QCOMPARE(textSpy.count() > 0, text != expectedText); + + if (cursorPositionChanged) // + QVERIFY(cursorPositionSpy.count() > 0); +} + +void tst_qquicktextinput::keySequence_data() +{ + QTest::addColumn("text"); + QTest::addColumn("sequence"); + QTest::addColumn("selectionStart"); + QTest::addColumn("selectionEnd"); + QTest::addColumn("cursorPosition"); + QTest::addColumn("expectedText"); + QTest::addColumn("selectedText"); + + // standard[0] == "the [4]quick [10]brown [16]fox [20]jumped [27]over [32]the [36]lazy [41]dog" + + QTest::newRow("select all") + << standard.at(0) << QKeySequence(QKeySequence::SelectAll) << 0 << 0 + << 44 << standard.at(0) << standard.at(0); + QTest::newRow("select end of line") + << standard.at(0) << QKeySequence(QKeySequence::SelectEndOfLine) << 5 << 5 + << 44 << standard.at(0) << standard.at(0).mid(5); + QTest::newRow("select end of document") // ### Not handled. + << standard.at(0) << QKeySequence(QKeySequence::SelectEndOfDocument) << 3 << 3 + << 3 << standard.at(0) << QString(); + QTest::newRow("select end of block") + << standard.at(0) << QKeySequence(QKeySequence::SelectEndOfBlock) << 18 << 18 + << 44 << standard.at(0) << standard.at(0).mid(18); + QTest::newRow("delete end of line") + << standard.at(0) << QKeySequence(QKeySequence::DeleteEndOfLine) << 24 << 24 + << 24 << standard.at(0).mid(0, 24) << QString(); + QTest::newRow("move to start of line") + << standard.at(0) << QKeySequence(QKeySequence::MoveToStartOfLine) << 31 << 31 + << 0 << standard.at(0) << QString(); + QTest::newRow("move to start of block") + << standard.at(0) << QKeySequence(QKeySequence::MoveToStartOfBlock) << 25 << 25 + << 0 << standard.at(0) << QString(); + QTest::newRow("move to next char") + << standard.at(0) << QKeySequence(QKeySequence::MoveToNextChar) << 12 << 12 + << 13 << standard.at(0) << QString(); + QTest::newRow("move to previous char") + << standard.at(0) << QKeySequence(QKeySequence::MoveToPreviousChar) << 3 << 3 + << 2 << standard.at(0) << QString(); + QTest::newRow("select next char") + << standard.at(0) << QKeySequence(QKeySequence::SelectNextChar) << 23 << 23 + << 24 << standard.at(0) << standard.at(0).mid(23, 1); + QTest::newRow("select previous char") + << standard.at(0) << QKeySequence(QKeySequence::SelectPreviousChar) << 19 << 19 + << 18 << standard.at(0) << standard.at(0).mid(18, 1); + QTest::newRow("move to next word") + << standard.at(0) << QKeySequence(QKeySequence::MoveToNextWord) << 7 << 7 + << 10 << standard.at(0) << QString(); + QTest::newRow("move to previous word") + << standard.at(0) << QKeySequence(QKeySequence::MoveToPreviousWord) << 7 << 7 + << 4 << standard.at(0) << QString(); + QTest::newRow("select previous word") + << standard.at(0) << QKeySequence(QKeySequence::SelectPreviousWord) << 11 << 11 + << 10 << standard.at(0) << standard.at(0).mid(10, 1); + QTest::newRow("delete (selection)") + << standard.at(0) << QKeySequence(QKeySequence::Delete) << 12 << 15 + << 12 << (standard.at(0).mid(0, 12) + standard.at(0).mid(15)) << QString(); + QTest::newRow("delete (no selection)") + << standard.at(0) << QKeySequence(QKeySequence::Delete) << 15 << 15 + << 15 << (standard.at(0).mid(0, 15) + standard.at(0).mid(16)) << QString(); + QTest::newRow("delete end of word") + << standard.at(0) << QKeySequence(QKeySequence::DeleteEndOfWord) << 24 << 24 + << 24 << (standard.at(0).mid(0, 24) + standard.at(0).mid(27)) << QString(); + QTest::newRow("delete start of word") + << standard.at(0) << QKeySequence(QKeySequence::DeleteStartOfWord) << 7 << 7 + << 4 << (standard.at(0).mid(0, 4) + standard.at(0).mid(7)) << QString(); +} + +void tst_qquicktextinput::keySequence() +{ + QFETCH(QString, text); + QFETCH(QKeySequence, sequence); + QFETCH(int, selectionStart); + QFETCH(int, selectionEnd); + QFETCH(int, cursorPosition); + QFETCH(QString, expectedText); + QFETCH(QString, selectedText); + + if (sequence.isEmpty()) { + QSKIP("Key sequence is undefined"); + } + + QString componentStr = "import QtQuick 2.0\nTextInput { focus: true; text: \"" + text + "\" }"; + QQmlComponent textInputComponent(&engine); + textInputComponent.setData(componentStr.toLatin1(), QUrl()); + QQuickTextInput *textInput = qobject_cast(textInputComponent.create()); + QVERIFY(textInput != 0); + + QQuickCanvas canvas; + textInput->setParentItem(canvas.rootItem()); + canvas.show(); + canvas.requestActivateWindow(); + QTest::qWaitForWindowShown(&canvas); + QTRY_COMPARE(QGuiApplication::activeWindow(), &canvas); + + textInput->select(selectionStart, selectionEnd); + + simulateKeys(&canvas, sequence); + + QCOMPARE(textInput->cursorPosition(), cursorPosition); + QCOMPARE(textInput->text(), expectedText); + QCOMPARE(textInput->selectedText(), selectedText); +} + +#define NORMAL 0 +#define REPLACE_UNTIL_END 1 + +void tst_qquicktextinput::undo_data() +{ + QTest::addColumn("insertString"); + QTest::addColumn("insertIndex"); + QTest::addColumn("insertMode"); + QTest::addColumn("expectedString"); + QTest::addColumn("use_keys"); + + for (int i=0; i<2; i++) { + QString keys_str = "keyboard"; + bool use_keys = true; + if (i==0) { + keys_str = "insert"; + use_keys = false; + } + + { + IntList insertIndex; + IntList insertMode; + QStringList insertString; + QStringList expectedString; + + insertIndex << -1; + insertMode << NORMAL; + insertString << "1"; + + insertIndex << -1; + insertMode << NORMAL; + insertString << "5"; + + insertIndex << 1; + insertMode << NORMAL; + insertString << "3"; + + insertIndex << 1; + insertMode << NORMAL; + insertString << "2"; + + insertIndex << 3; + insertMode << NORMAL; + insertString << "4"; + + expectedString << "12345"; + expectedString << "1235"; + expectedString << "135"; + expectedString << "15"; + expectedString << ""; + + QTest::newRow(QString(keys_str + "_numbers").toLatin1()) << + insertString << + insertIndex << + insertMode << + expectedString << + bool(use_keys); + } + { + IntList insertIndex; + IntList insertMode; + QStringList insertString; + QStringList expectedString; + + insertIndex << -1; + insertMode << NORMAL; + insertString << "World"; // World + + insertIndex << 0; + insertMode << NORMAL; + insertString << "Hello"; // HelloWorld + + insertIndex << 0; + insertMode << NORMAL; + insertString << "Well"; // WellHelloWorld + + insertIndex << 9; + insertMode << NORMAL; + insertString << "There"; // WellHelloThereWorld; + + expectedString << "WellHelloThereWorld"; + expectedString << "WellHelloWorld"; + expectedString << "HelloWorld"; + expectedString << "World"; + expectedString << ""; + + QTest::newRow(QString(keys_str + "_helloworld").toLatin1()) << + insertString << + insertIndex << + insertMode << + expectedString << + bool(use_keys); + } + { + IntList insertIndex; + IntList insertMode; + QStringList insertString; + QStringList expectedString; + + insertIndex << -1; + insertMode << NORMAL; + insertString << "Ensuring"; + + insertIndex << -1; + insertMode << NORMAL; + insertString << " instan"; + + insertIndex << 9; + insertMode << NORMAL; + insertString << "an "; + + insertIndex << 10; + insertMode << REPLACE_UNTIL_END; + insertString << " unique instance."; + + expectedString << "Ensuring a unique instance."; + expectedString << "Ensuring an instan"; + expectedString << "Ensuring instan"; + expectedString << ""; + + QTest::newRow(QString(keys_str + "_patterns").toLatin1()) << + insertString << + insertIndex << + insertMode << + expectedString << + bool(use_keys); + } + } +} + +void tst_qquicktextinput::undo() +{ + QFETCH(QStringList, insertString); + QFETCH(IntList, insertIndex); + QFETCH(IntList, insertMode); + QFETCH(QStringList, expectedString); + + QString componentStr = "import QtQuick 2.0\nTextInput { focus: true }"; + QQmlComponent textInputComponent(&engine); + textInputComponent.setData(componentStr.toLatin1(), QUrl()); + QQuickTextInput *textInput = qobject_cast(textInputComponent.create()); + QVERIFY(textInput != 0); + + QQuickCanvas canvas; + textInput->setParentItem(canvas.rootItem()); + canvas.show(); + canvas.requestActivateWindow(); + QTest::qWaitForWindowShown(&canvas); + QTRY_COMPARE(QGuiApplication::activeWindow(), &canvas); + + QVERIFY(!textInput->canUndo()); + + QSignalSpy spy(textInput, SIGNAL(canUndoChanged())); + + int i; + +// STEP 1: First build up an undo history by inserting or typing some strings... + for (i = 0; i < insertString.size(); ++i) { + if (insertIndex[i] > -1) + textInput->setCursorPosition(insertIndex[i]); + + // experimental stuff + if (insertMode[i] == REPLACE_UNTIL_END) { + textInput->select(insertIndex[i], insertIndex[i] + 8); + + // This is what I actually want... + // QTest::keyClick(testWidget, Qt::Key_End, Qt::ShiftModifier); + } + + for (int j = 0; j < insertString.at(i).length(); j++) + QTest::keyClick(&canvas, insertString.at(i).at(j).toLatin1()); + } + + QCOMPARE(spy.count(), 1); + +// STEP 2: Next call undo several times and see if we can restore to the previous state + for (i = 0; i < expectedString.size() - 1; ++i) { + QCOMPARE(textInput->text(), expectedString[i]); + QVERIFY(textInput->canUndo()); + textInput->undo(); + } + +// STEP 3: Verify that we have undone everything + QVERIFY(textInput->text().isEmpty()); + QVERIFY(!textInput->canUndo()); + QCOMPARE(spy.count(), 2); +} + +void tst_qquicktextinput::redo_data() +{ + QTest::addColumn("insertString"); + QTest::addColumn("insertIndex"); + QTest::addColumn("expectedString"); + + { + IntList insertIndex; + QStringList insertString; + QStringList expectedString; + + insertIndex << -1; + insertString << "World"; // World + insertIndex << 0; + insertString << "Hello"; // HelloWorld + insertIndex << 0; + insertString << "Well"; // WellHelloWorld + insertIndex << 9; + insertString << "There"; // WellHelloThereWorld; + + expectedString << "World"; + expectedString << "HelloWorld"; + expectedString << "WellHelloWorld"; + expectedString << "WellHelloThereWorld"; + + QTest::newRow("Inserts and setting cursor") << insertString << insertIndex << expectedString; + } +} + +void tst_qquicktextinput::redo() +{ + QFETCH(QStringList, insertString); + QFETCH(IntList, insertIndex); + QFETCH(QStringList, expectedString); + + QString componentStr = "import QtQuick 2.0\nTextInput { focus: true }"; + QQmlComponent textInputComponent(&engine); + textInputComponent.setData(componentStr.toLatin1(), QUrl()); + QQuickTextInput *textInput = qobject_cast(textInputComponent.create()); + QVERIFY(textInput != 0); + + QQuickCanvas canvas; + textInput->setParentItem(canvas.rootItem()); + canvas.show(); + canvas.requestActivateWindow(); + QTest::qWaitForWindowShown(&canvas); + QTRY_COMPARE(QGuiApplication::activeWindow(), &canvas); + + QVERIFY(!textInput->canUndo()); + QVERIFY(!textInput->canRedo()); + + QSignalSpy spy(textInput, SIGNAL(canRedoChanged())); + + int i; + // inserts the diff strings at diff positions + for (i = 0; i < insertString.size(); ++i) { + if (insertIndex[i] > -1) + textInput->setCursorPosition(insertIndex[i]); + for (int j = 0; j < insertString.at(i).length(); j++) + QTest::keyClick(&canvas, insertString.at(i).at(j).toLatin1()); + QVERIFY(textInput->canUndo()); + QVERIFY(!textInput->canRedo()); + } + + QCOMPARE(spy.count(), 0); + + // undo everything + while (!textInput->text().isEmpty()) { + QVERIFY(textInput->canUndo()); + textInput->undo(); + QVERIFY(textInput->canRedo()); + } + + QCOMPARE(spy.count(), 1); + + for (i = 0; i < expectedString.size(); ++i) { + QVERIFY(textInput->canRedo()); + textInput->redo(); + QCOMPARE(textInput->text() , expectedString[i]); + QVERIFY(textInput->canUndo()); + } + QVERIFY(!textInput->canRedo()); + QCOMPARE(spy.count(), 2); +} + +void tst_qquicktextinput::undo_keypressevents_data() +{ + QTest::addColumn("keys"); + QTest::addColumn("expectedString"); + + { + KeyList keys; + QStringList expectedString; + + keys << "AFRAID" + << QKeySequence::MoveToStartOfLine + << "VERY" + << Qt::Key_Left + << Qt::Key_Left + << Qt::Key_Left + << Qt::Key_Left + << "BE" + << QKeySequence::MoveToEndOfLine + << "!"; + + expectedString << "BEVERYAFRAID!"; + expectedString << "BEVERYAFRAID"; + expectedString << "VERYAFRAID"; + expectedString << "AFRAID"; + + QTest::newRow("Inserts and moving cursor") << keys << expectedString; + } { + KeyList keys; + QStringList expectedString; + + // inserting '1234' + keys << "1234" << QKeySequence::MoveToStartOfLine + // skipping '12' + << Qt::Key_Right << Qt::Key_Right + // selecting '34' + << (Qt::Key_Right | Qt::ShiftModifier) << (Qt::Key_Right | Qt::ShiftModifier) + // deleting '34' + << Qt::Key_Delete; + + expectedString << "12"; + expectedString << "1234"; + + QTest::newRow("Inserts,moving,selection and delete") << keys << expectedString; + } { + KeyList keys; + QStringList expectedString; + + // inserting 'AB12' + keys << "AB12" + << QKeySequence::MoveToStartOfLine + // selecting 'AB' + << (Qt::Key_Right | Qt::ShiftModifier) << (Qt::Key_Right | Qt::ShiftModifier) + << Qt::Key_Delete + << QKeySequence::Undo + << Qt::Key_Right +#ifdef Q_OS_WIN //Mac(?) has a specialcase to handle jumping to the end of a selection + << Qt::Key_Left +#endif + << (Qt::Key_Right | Qt::ShiftModifier) << (Qt::Key_Right | Qt::ShiftModifier) + << Qt::Key_Delete; + + expectedString << "AB"; + expectedString << "AB12"; + + QTest::newRow("Inserts,moving,selection, delete and undo") << keys << expectedString; + } { + KeyList keys; + QStringList expectedString; + + // inserting 'ABCD' + keys << "abcd" + //move left two + << Qt::Key_Left << Qt::Key_Left + // inserting '1234' + << "1234" + // selecting '1234' + << (Qt::Key_Left | Qt::ShiftModifier) << (Qt::Key_Left | Qt::ShiftModifier) << (Qt::Key_Left | Qt::ShiftModifier) << (Qt::Key_Left | Qt::ShiftModifier) + // overwriting '1234' with '5' + << "5" + // undoing deletion of 'AB' + << QKeySequence::Undo + // overwriting '1234' with '6' + << "6"; + + expectedString << "ab6cd"; + // for versions previous to 3.2 we overwrite needed two undo operations + expectedString << "ab1234cd"; + expectedString << "abcd"; + + QTest::newRow("Inserts,moving,selection and undo, removing selection") << keys << expectedString; + } { + KeyList keys; + QStringList expectedString; + + // inserting 'ABC' + keys << "ABC" + // removes 'C' + << Qt::Key_Backspace; + + expectedString << "AB"; + expectedString << "ABC"; + + QTest::newRow("Inserts,backspace") << keys << expectedString; + } { + KeyList keys; + QStringList expectedString; + + keys << "ABC" + // removes 'C' + << Qt::Key_Backspace + // inserting 'Z' + << "Z"; + + expectedString << "ABZ"; + expectedString << "AB"; + expectedString << "ABC"; + + QTest::newRow("Inserts,backspace,inserts") << keys << expectedString; + } { + KeyList keys; + QStringList expectedString; + + // inserting '123' + keys << "123" << QKeySequence::MoveToStartOfLine + // selecting '123' + << QKeySequence::SelectEndOfLine + // overwriting '123' with 'ABC' + << "ABC"; + + expectedString << "ABC"; + // for versions previous to 3.2 we overwrite needed two undo operations + expectedString << "123"; + + QTest::newRow("Inserts,moving,selection and overwriting") << keys << expectedString; + } +} + +void tst_qquicktextinput::undo_keypressevents() +{ + QFETCH(KeyList, keys); + QFETCH(QStringList, expectedString); + + QString componentStr = "import QtQuick 2.0\nTextInput { focus: true }"; + QQmlComponent textInputComponent(&engine); + textInputComponent.setData(componentStr.toLatin1(), QUrl()); + QQuickTextInput *textInput = qobject_cast(textInputComponent.create()); + QVERIFY(textInput != 0); + + QQuickCanvas canvas; + textInput->setParentItem(canvas.rootItem()); + canvas.show(); + canvas.requestActivateWindow(); + QTest::qWaitForWindowShown(&canvas); + QTRY_COMPARE(QGuiApplication::activeWindow(), &canvas); + + simulateKeys(&canvas, keys); + + for (int i = 0; i < expectedString.size(); ++i) { + QCOMPARE(textInput->text() , expectedString[i]); + textInput->undo(); + } + QVERIFY(textInput->text().isEmpty()); +} + +void tst_qquicktextinput::QTBUG_19956() +{ + QFETCH(QString, url); + + QQuickView canvas(testFileUrl(url)); + canvas.show(); + canvas.requestActivateWindow(); + QTest::qWaitForWindowShown(&canvas); + QVERIFY(canvas.rootObject() != 0); + QQuickTextInput *input = qobject_cast(canvas.rootObject()); + QVERIFY(input); + input->setFocus(true); + QVERIFY(input->hasActiveFocus()); + + QCOMPARE(canvas.rootObject()->property("topvalue").toInt(), 30); + QCOMPARE(canvas.rootObject()->property("bottomvalue").toInt(), 10); + QCOMPARE(canvas.rootObject()->property("text").toString(), QString("20")); + QVERIFY(canvas.rootObject()->property("acceptableInput").toBool()); + + canvas.rootObject()->setProperty("topvalue", 15); + QCOMPARE(canvas.rootObject()->property("topvalue").toInt(), 15); + QVERIFY(!canvas.rootObject()->property("acceptableInput").toBool()); + + canvas.rootObject()->setProperty("topvalue", 25); + QCOMPARE(canvas.rootObject()->property("topvalue").toInt(), 25); + QVERIFY(canvas.rootObject()->property("acceptableInput").toBool()); + + canvas.rootObject()->setProperty("bottomvalue", 21); + QCOMPARE(canvas.rootObject()->property("bottomvalue").toInt(), 21); + QVERIFY(!canvas.rootObject()->property("acceptableInput").toBool()); + + canvas.rootObject()->setProperty("bottomvalue", 10); + QCOMPARE(canvas.rootObject()->property("bottomvalue").toInt(), 10); + QVERIFY(canvas.rootObject()->property("acceptableInput").toBool()); +} + +void tst_qquicktextinput::QTBUG_19956_regexp() +{ + QUrl url = testFileUrl("qtbug-19956regexp.qml"); + + QString warning = url.toString() + ":11: Unable to assign [undefined] to QRegExp"; + QTest::ignoreMessage(QtWarningMsg, qPrintable(warning)); + + QQuickView canvas(url); + canvas.show(); + canvas.requestActivateWindow(); + QTest::qWaitForWindowShown(&canvas); + QVERIFY(canvas.rootObject() != 0); + QQuickTextInput *input = qobject_cast(canvas.rootObject()); + QVERIFY(input); + input->setFocus(true); + QVERIFY(input->hasActiveFocus()); + + canvas.rootObject()->setProperty("regexvalue", QRegExp("abc")); + QCOMPARE(canvas.rootObject()->property("regexvalue").toRegExp(), QRegExp("abc")); + QCOMPARE(canvas.rootObject()->property("text").toString(), QString("abc")); + QVERIFY(canvas.rootObject()->property("acceptableInput").toBool()); + + canvas.rootObject()->setProperty("regexvalue", QRegExp("abcd")); + QCOMPARE(canvas.rootObject()->property("regexvalue").toRegExp(), QRegExp("abcd")); + QVERIFY(!canvas.rootObject()->property("acceptableInput").toBool()); + + canvas.rootObject()->setProperty("regexvalue", QRegExp("abc")); + QCOMPARE(canvas.rootObject()->property("regexvalue").toRegExp(), QRegExp("abc")); + QVERIFY(canvas.rootObject()->property("acceptableInput").toBool()); +} + + +void tst_qquicktextinput::negativeDimensions() +{ + // Verify this doesn't assert during initialization. + QQmlComponent component(&engine, testFileUrl("negativeDimensions.qml")); + QScopedPointer o(component.create()); + QVERIFY(o); + QQuickTextInput *input = o->findChild("input"); + QVERIFY(input); + QCOMPARE(input->width(), qreal(-1)); + QCOMPARE(input->height(), qreal(-1)); +} + +QTEST_MAIN(tst_qquicktextinput) + +#include "tst_qquicktextinput.moc" diff --git a/tests/auto/quick/qquicktimer/qquicktimer.pro b/tests/auto/quick/qquicktimer/qquicktimer.pro new file mode 100644 index 0000000000..7b399c778d --- /dev/null +++ b/tests/auto/quick/qquicktimer/qquicktimer.pro @@ -0,0 +1,8 @@ +CONFIG += testcase +TARGET = tst_qquicktimer +macx:CONFIG -= app_bundle + +SOURCES += tst_qquicktimer.cpp + +CONFIG += parallel_test +QT += core-private gui-private qml-private quick-private gui testlib diff --git a/tests/auto/quick/qquicktimer/tst_qquicktimer.cpp b/tests/auto/quick/qquicktimer/tst_qquicktimer.cpp new file mode 100644 index 0000000000..ff33609c06 --- /dev/null +++ b/tests/auto/quick/qquicktimer/tst_qquicktimer.cpp @@ -0,0 +1,393 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include +#include +#include +#include +#include +#include +#include + +class tst_qquicktimer : public QObject +{ + Q_OBJECT +public: + tst_qquicktimer(); + +private slots: + void notRepeating(); + void notRepeatingStart(); + void repeat(); + void noTriggerIfNotRunning(); + void triggeredOnStart(); + void triggeredOnStartRepeat(); + void changeDuration(); + void restart(); + void restartFromTriggered(); + void runningFromTriggered(); + void parentProperty(); +}; + +class TimerHelper : public QObject +{ + Q_OBJECT +public: + TimerHelper() : QObject(), count(0) + { + } + + int count; + +public slots: + void timeout() { + ++count; + } +}; + +#define TIMEOUT_TIMEOUT 200 + +tst_qquicktimer::tst_qquicktimer() +{ +} + +void tst_qquicktimer::notRepeating() +{ + QQmlEngine engine; + QQmlComponent component(&engine); + component.setData(QByteArray("import QtQuick 2.0\nTimer { interval: 100; running: true }"), QUrl::fromLocalFile("")); + QQuickTimer *timer = qobject_cast(component.create()); + QVERIFY(timer != 0); + QVERIFY(timer->isRunning()); + QVERIFY(!timer->isRepeating()); + QCOMPARE(timer->interval(), 100); + + TimerHelper helper; + connect(timer, SIGNAL(triggered()), &helper, SLOT(timeout())); + + QTest::qWait(TIMEOUT_TIMEOUT); + QCOMPARE(helper.count, 1); + QTest::qWait(TIMEOUT_TIMEOUT); + QCOMPARE(helper.count, 1); + QVERIFY(timer->isRunning() == false); +} + +void tst_qquicktimer::notRepeatingStart() +{ + QQmlEngine engine; + QQmlComponent component(&engine); + component.setData(QByteArray("import QtQuick 2.0\nTimer { interval: 100 }"), QUrl::fromLocalFile("")); + QQuickTimer *timer = qobject_cast(component.create()); + QVERIFY(timer != 0); + QVERIFY(!timer->isRunning()); + + TimerHelper helper; + connect(timer, SIGNAL(triggered()), &helper, SLOT(timeout())); + + QTest::qWait(TIMEOUT_TIMEOUT); + QCOMPARE(helper.count, 0); + + timer->start(); + QTest::qWait(TIMEOUT_TIMEOUT); + QCOMPARE(helper.count, 1); + QTest::qWait(TIMEOUT_TIMEOUT); + QCOMPARE(helper.count, 1); + QVERIFY(timer->isRunning() == false); + + delete timer; +} + +void tst_qquicktimer::repeat() +{ + QQmlEngine engine; + QQmlComponent component(&engine); + component.setData(QByteArray("import QtQuick 2.0\nTimer { interval: 100; repeat: true; running: true }"), QUrl::fromLocalFile("")); + QQuickTimer *timer = qobject_cast(component.create()); + QVERIFY(timer != 0); + + TimerHelper helper; + connect(timer, SIGNAL(triggered()), &helper, SLOT(timeout())); + QCOMPARE(helper.count, 0); + + QTest::qWait(TIMEOUT_TIMEOUT); + QVERIFY(helper.count > 0); + int oldCount = helper.count; + + QTest::qWait(TIMEOUT_TIMEOUT); + QVERIFY(helper.count > oldCount); + QVERIFY(timer->isRunning()); + + oldCount = helper.count; + timer->stop(); + + QTest::qWait(TIMEOUT_TIMEOUT); + QVERIFY(helper.count == oldCount); + QVERIFY(timer->isRunning() == false); + + QSignalSpy spy(timer, SIGNAL(repeatChanged())); + + timer->setRepeating(false); + QVERIFY(!timer->isRepeating()); + QCOMPARE(spy.count(),1); + + timer->setRepeating(false); + QCOMPARE(spy.count(),1); + + timer->setRepeating(true); + QCOMPARE(spy.count(),2); + + delete timer; +} + +void tst_qquicktimer::triggeredOnStart() +{ + QQmlEngine engine; + QQmlComponent component(&engine); + component.setData(QByteArray("import QtQuick 2.0\nTimer { interval: 100; running: true; triggeredOnStart: true }"), QUrl::fromLocalFile("")); + QQuickTimer *timer = qobject_cast(component.create()); + QVERIFY(timer != 0); + QVERIFY(timer->triggeredOnStart()); + + TimerHelper helper; + connect(timer, SIGNAL(triggered()), &helper, SLOT(timeout())); + QTest::qWait(1); + QCOMPARE(helper.count, 1); + + QTest::qWait(TIMEOUT_TIMEOUT); + QCOMPARE(helper.count, 2); + QTest::qWait(TIMEOUT_TIMEOUT); + QCOMPARE(helper.count, 2); + QVERIFY(timer->isRunning() == false); + + QSignalSpy spy(timer, SIGNAL(triggeredOnStartChanged())); + + timer->setTriggeredOnStart(false); + QVERIFY(!timer->triggeredOnStart()); + QCOMPARE(spy.count(),1); + + timer->setTriggeredOnStart(false); + QCOMPARE(spy.count(),1); + + timer->setTriggeredOnStart(true); + QCOMPARE(spy.count(),2); + + delete timer; +} + +void tst_qquicktimer::triggeredOnStartRepeat() +{ + QQmlEngine engine; + QQmlComponent component(&engine); + component.setData(QByteArray("import QtQuick 2.0\nTimer { interval: 100; running: true; triggeredOnStart: true; repeat: true }"), QUrl::fromLocalFile("")); + QQuickTimer *timer = qobject_cast(component.create()); + QVERIFY(timer != 0); + + TimerHelper helper; + connect(timer, SIGNAL(triggered()), &helper, SLOT(timeout())); + QTest::qWait(1); + QCOMPARE(helper.count, 1); + + QTest::qWait(TIMEOUT_TIMEOUT); + QVERIFY(helper.count > 1); + int oldCount = helper.count; + QTest::qWait(TIMEOUT_TIMEOUT); + QVERIFY(helper.count > oldCount); + QVERIFY(timer->isRunning()); + + delete timer; +} + +void tst_qquicktimer::noTriggerIfNotRunning() +{ + QQmlEngine engine; + QQmlComponent component(&engine); + component.setData(QByteArray( + "import QtQuick 2.0\n" + "Item { property bool ok: true\n" + "Timer { id: t1; interval: 100; repeat: true; running: true; onTriggered: if (!running) ok=false }" + "Timer { interval: 10; running: true; onTriggered: t1.running=false }" + "}" + ), QUrl::fromLocalFile("")); + QObject *item = component.create(); + QVERIFY(item != 0); + QTest::qWait(TIMEOUT_TIMEOUT); + QCOMPARE(item->property("ok").toBool(), true); + + delete item; +} + +void tst_qquicktimer::changeDuration() +{ + QQmlEngine engine; + QQmlComponent component(&engine); + component.setData(QByteArray("import QtQuick 2.0\nTimer { interval: 200; repeat: true; running: true }"), QUrl::fromLocalFile("")); + QQuickTimer *timer = qobject_cast(component.create()); + QVERIFY(timer != 0); + + TimerHelper helper; + connect(timer, SIGNAL(triggered()), &helper, SLOT(timeout())); + QCOMPARE(helper.count, 0); + + QTest::qWait(500); + QCOMPARE(helper.count, 2); + + timer->setInterval(500); + + QTest::qWait(600); + QCOMPARE(helper.count, 3); + QVERIFY(timer->isRunning()); + + QSignalSpy spy(timer, SIGNAL(intervalChanged())); + + timer->setInterval(200); + QCOMPARE(timer->interval(), 200); + QCOMPARE(spy.count(),1); + + timer->setInterval(200); + QCOMPARE(spy.count(),1); + + timer->setInterval(300); + QCOMPARE(spy.count(),2); + + delete timer; +} + +void tst_qquicktimer::restart() +{ + QQmlEngine engine; + QQmlComponent component(&engine); + component.setData(QByteArray("import QtQuick 2.0\nTimer { interval: 500; repeat: true; running: true }"), QUrl::fromLocalFile("")); + QQuickTimer *timer = qobject_cast(component.create()); + QVERIFY(timer != 0); + + TimerHelper helper; + connect(timer, SIGNAL(triggered()), &helper, SLOT(timeout())); + QCOMPARE(helper.count, 0); + + QTest::qWait(600); + QCOMPARE(helper.count, 1); + + QTest::qWait(300); + + timer->restart(); + + QTest::qWait(700); + + QCOMPARE(helper.count, 2); + QVERIFY(timer->isRunning()); + + delete timer; +} + +void tst_qquicktimer::restartFromTriggered() +{ + QQmlEngine engine; + QQmlComponent component(&engine); + component.setData(QByteArray("import QtQuick 2.0\nTimer { " + "interval: 500; " + "repeat: false; " + "running: true; " + "onTriggered: restart()" + " }"), QUrl::fromLocalFile("")); + QScopedPointer object(component.create()); + QQuickTimer *timer = qobject_cast(object.data()); + QVERIFY(timer != 0); + + TimerHelper helper; + connect(timer, SIGNAL(triggered()), &helper, SLOT(timeout())); + QCOMPARE(helper.count, 0); + + QTest::qWait(600); + QCOMPARE(helper.count, 1); + QVERIFY(timer->isRunning()); + + QTest::qWait(600); + QCOMPARE(helper.count, 2); + QVERIFY(timer->isRunning()); +} + +void tst_qquicktimer::runningFromTriggered() +{ + QQmlEngine engine; + QQmlComponent component(&engine); + component.setData(QByteArray("import QtQuick 2.0\nTimer { " + "property bool ok: false; " + "interval: 500; " + "repeat: false; " + "running: true; " + "onTriggered: { ok = !running; running = true }" + " }"), QUrl::fromLocalFile("")); + QScopedPointer object(component.create()); + QQuickTimer *timer = qobject_cast(object.data()); + QVERIFY(timer != 0); + + TimerHelper helper; + connect(timer, SIGNAL(triggered()), &helper, SLOT(timeout())); + QCOMPARE(helper.count, 0); + + QTest::qWait(600); + QCOMPARE(helper.count, 1); + QVERIFY(timer->property("ok").toBool()); + QVERIFY(timer->isRunning()); + + QTest::qWait(600); + QCOMPARE(helper.count, 2); + QVERIFY(timer->property("ok").toBool()); + QVERIFY(timer->isRunning()); +} + +void tst_qquicktimer::parentProperty() +{ + QQmlEngine engine; + QQmlComponent component(&engine); + component.setData(QByteArray("import QtQuick 2.0\nItem { Timer { objectName: \"timer\"; running: parent.visible } }"), QUrl::fromLocalFile("")); + QQuickItem *item = qobject_cast(component.create()); + QVERIFY(item != 0); + QQuickTimer *timer = item->findChild("timer"); + QVERIFY(timer != 0); + + QVERIFY(timer->isRunning()); + + delete timer; +} + +QTEST_MAIN(tst_qquicktimer) + +#include "tst_qquicktimer.moc" diff --git a/tests/auto/quick/qquickview/data/error1.qml b/tests/auto/quick/qquickview/data/error1.qml new file mode 100644 index 0000000000..09df679555 --- /dev/null +++ b/tests/auto/quick/qquickview/data/error1.qml @@ -0,0 +1,5 @@ +import QtQuick 2.0 + +Rectangle { + nonExistentProperty: 5 +} diff --git a/tests/auto/quick/qquickview/data/resizemodeitem.qml b/tests/auto/quick/qquickview/data/resizemodeitem.qml new file mode 100644 index 0000000000..ed73009b26 --- /dev/null +++ b/tests/auto/quick/qquickview/data/resizemodeitem.qml @@ -0,0 +1,5 @@ +import QtQuick 2.0 +Item { + width: 200 + height: 200 +} diff --git a/tests/auto/quick/qquickview/qquickview.pro b/tests/auto/quick/qquickview/qquickview.pro new file mode 100644 index 0000000000..77b0f7d86a --- /dev/null +++ b/tests/auto/quick/qquickview/qquickview.pro @@ -0,0 +1,13 @@ +CONFIG += testcase +TARGET = tst_qquickview +macx:CONFIG -= app_bundle + +SOURCES += tst_qquickview.cpp + +include (../../shared/util.pri) + +testDataFiles.files = data +testDataFiles.path = . +DEPLOYMENT += testDataFiles + +QT += core-private gui-private qml-private quick-private testlib diff --git a/tests/auto/quick/qquickview/tst_qquickview.cpp b/tests/auto/quick/qquickview/tst_qquickview.cpp new file mode 100644 index 0000000000..e5e8a83424 --- /dev/null +++ b/tests/auto/quick/qquickview/tst_qquickview.cpp @@ -0,0 +1,207 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include +#include +#include +#include +#include +#include +#include "../../shared/util.h" +#include +#include + +class tst_QQuickView : public QQmlDataTest +{ + Q_OBJECT +public: + tst_QQuickView(); + +private slots: + void resizemodeitem(); + void errors(); +}; + + +tst_QQuickView::tst_QQuickView() +{ +} + +void tst_QQuickView::resizemodeitem() +{ + QWindow window; + window.setGeometry(0, 0, 400, 400); + + QQuickView *canvas = new QQuickView(&window); + QVERIFY(canvas); + canvas->setResizeMode(QQuickView::SizeRootObjectToView); + QCOMPARE(QSize(0,0), canvas->initialSize()); + canvas->setSource(testFileUrl("resizemodeitem.qml")); + QQuickItem* item = qobject_cast(canvas->rootObject()); + QVERIFY(item); + window.show(); + + canvas->show(); + + // initial size from root object + QCOMPARE(item->width(), 200.0); + QCOMPARE(item->height(), 200.0); + QCOMPARE(canvas->size(), QSize(200, 200)); + QCOMPARE(canvas->size(), canvas->sizeHint()); + QCOMPARE(canvas->size(), canvas->initialSize()); + + // size update from view + canvas->resize(QSize(80,100)); + + QTRY_COMPARE(item->width(), 80.0); + QCOMPARE(item->height(), 100.0); + QCOMPARE(canvas->size(), QSize(80, 100)); + QCOMPARE(canvas->size(), canvas->sizeHint()); + + canvas->setResizeMode(QQuickView::SizeViewToRootObject); + + // size update from view disabled + canvas->resize(QSize(60,80)); + QCOMPARE(item->width(), 80.0); + QCOMPARE(item->height(), 100.0); + QTest::qWait(50); + QCOMPARE(canvas->size(), QSize(60, 80)); + + // size update from root object + item->setWidth(250); + item->setHeight(350); + QCOMPARE(item->width(), 250.0); + QCOMPARE(item->height(), 350.0); + QTRY_COMPARE(canvas->size(), QSize(250, 350)); + QCOMPARE(canvas->size(), QSize(250, 350)); + QCOMPARE(canvas->size(), canvas->sizeHint()); + + // reset canvas + window.hide(); + delete canvas; + canvas = new QQuickView(&window); + QVERIFY(canvas); + canvas->setResizeMode(QQuickView::SizeViewToRootObject); + canvas->setSource(testFileUrl("resizemodeitem.qml")); + item = qobject_cast(canvas->rootObject()); + QVERIFY(item); + window.show(); + + canvas->show(); + + // initial size for root object + QCOMPARE(item->width(), 200.0); + QCOMPARE(item->height(), 200.0); + QCOMPARE(canvas->size(), canvas->sizeHint()); + QCOMPARE(canvas->size(), canvas->initialSize()); + + // size update from root object + item->setWidth(80); + item->setHeight(100); + QCOMPARE(item->width(), 80.0); + QCOMPARE(item->height(), 100.0); + QTRY_COMPARE(canvas->size(), QSize(80, 100)); + QCOMPARE(canvas->size(), QSize(80, 100)); + QCOMPARE(canvas->size(), canvas->sizeHint()); + + // size update from root object disabled + canvas->setResizeMode(QQuickView::SizeRootObjectToView); + item->setWidth(60); + item->setHeight(80); + QCOMPARE(canvas->width(), 80); + QCOMPARE(canvas->height(), 100); + QCOMPARE(QSize(item->width(), item->height()), canvas->sizeHint()); + + // size update from view + canvas->resize(QSize(200,300)); + QTest::qWait(50); + QCOMPARE(item->width(), 200.0); + QCOMPARE(item->height(), 300.0); + QCOMPARE(canvas->size(), QSize(200, 300)); + QCOMPARE(canvas->size(), canvas->sizeHint()); + + window.hide(); + delete canvas; + + // if we set a specific size for the view then it should keep that size + // for SizeRootObjectToView mode. + canvas = new QQuickView(&window); + canvas->resize(300, 300); + canvas->setResizeMode(QQuickView::SizeRootObjectToView); + QCOMPARE(QSize(0,0), canvas->initialSize()); + canvas->setSource(testFileUrl("resizemodeitem.qml")); + canvas->resize(300, 300); + item = qobject_cast(canvas->rootObject()); + QVERIFY(item); + window.show(); + + canvas->show(); + QTest::qWait(50); + + // initial size from root object + QCOMPARE(item->width(), 300.0); + QCOMPARE(item->height(), 300.0); + QCOMPARE(canvas->size(), QSize(300, 300)); + QCOMPARE(canvas->size(), canvas->sizeHint()); + QCOMPARE(canvas->initialSize(), QSize(200, 200)); // initial object size + + delete canvas; +} + +static void silentErrorsMsgHandler(QtMsgType, const char *) +{ +} + +void tst_QQuickView::errors() +{ + QQuickView *canvas = new QQuickView; + QVERIFY(canvas); + QtMsgHandler old = qInstallMsgHandler(silentErrorsMsgHandler); + canvas->setSource(testFileUrl("error1.qml")); + qInstallMsgHandler(old); + QVERIFY(canvas->status() == QQuickView::Error); + QVERIFY(canvas->errors().count() == 1); + delete canvas; +} + + +QTEST_MAIN(tst_QQuickView) + +#include "tst_qquickview.moc" diff --git a/tests/auto/quick/qquickvisualdatamodel/data/create.qml b/tests/auto/quick/qquickvisualdatamodel/data/create.qml new file mode 100644 index 0000000000..9f4b754552 --- /dev/null +++ b/tests/auto/quick/qquickvisualdatamodel/data/create.qml @@ -0,0 +1,22 @@ +import QtQuick 2.0 + +ListView { + width: 200 + height: 200 + + property var persistentHandle + + model: VisualDataModel { + id: visualModel + + persistedItems.includeByDefault: true + + model: myModel + delegate: Item { + id: delegate + objectName: "delegate" + width: 200 + height: 20 + } + } +} diff --git a/tests/auto/quick/qquickvisualdatamodel/data/datalist-package.qml b/tests/auto/quick/qquickvisualdatamodel/data/datalist-package.qml new file mode 100644 index 0000000000..ae3bd81d91 --- /dev/null +++ b/tests/auto/quick/qquickvisualdatamodel/data/datalist-package.qml @@ -0,0 +1,20 @@ +import QtQuick 2.0 + +ListView { + width: 100 + height: 100 + model: visualModel.parts.package + VisualDataModel { + id: visualModel + objectName: "visualModel" + model: myModel + delegate: Package { + Rectangle { + height: 25 + width: 100 + Package.name: "package" + Text { objectName: "display"; text: display } + } + } + } +} diff --git a/tests/auto/quick/qquickvisualdatamodel/data/datalist.qml b/tests/auto/quick/qquickvisualdatamodel/data/datalist.qml new file mode 100644 index 0000000000..8ce59caddc --- /dev/null +++ b/tests/auto/quick/qquickvisualdatamodel/data/datalist.qml @@ -0,0 +1,18 @@ +import QtQuick 2.0 + +ListView { + width: 100 + height: 100 + model: VisualDataModel { + id: visualModel + objectName: "visualModel" + model: myModel + delegate: Component { + Rectangle { + height: 25 + width: 100 + Text { objectName: "display"; text: display } + } + } + } +} diff --git a/tests/auto/quick/qquickvisualdatamodel/data/groups-invalid.qml b/tests/auto/quick/qquickvisualdatamodel/data/groups-invalid.qml new file mode 100644 index 0000000000..70c6f9f995 --- /dev/null +++ b/tests/auto/quick/qquickvisualdatamodel/data/groups-invalid.qml @@ -0,0 +1,14 @@ +import QtQuick 2.0 + +VisualDataModel { + id: visualModel + + objectName: "visualModel" + + groups: [ + VisualDataGroup { id: visibleItems; objectName: "visibleItems"; name: "visible"; includeByDefault: true }, + VisualDataGroup { id: selectedItems; objectName: "selectedItems"; name: "selected" }, + VisualDataGroup { id: unnamed; objectName: "unnamed" }, + VisualDataGroup { id: capitalised; objectName: "capitalised"; name: "Capitalised" } + ] +} diff --git a/tests/auto/quick/qquickvisualdatamodel/data/groups-package.qml b/tests/auto/quick/qquickvisualdatamodel/data/groups-package.qml new file mode 100644 index 0000000000..ea5ad5d3bd --- /dev/null +++ b/tests/auto/quick/qquickvisualdatamodel/data/groups-package.qml @@ -0,0 +1,52 @@ +import QtQuick 2.0 + +ListView { + width: 100 + height: 100 + + function contains(array, value) { + for (var i = 0; i < array.length; ++i) + if (array[i] == value) + return true + return false + } + model: visualModel.parts.package + + VisualDataModel { + id: visualModel + + objectName: "visualModel" + + groups: [ + VisualDataGroup { id: visibleItems; objectName: "visibleItems"; name: "visible"; includeByDefault: true }, + VisualDataGroup { id: selectedItems; objectName: "selectedItems"; name: "selected" } + ] + + model: myModel + delegate: Package { + id: delegate + + property variant test1: name + property variant test2: index + property variant test3: VisualDataModel.itemsIndex + property variant test4: VisualDataModel.inItems + property variant test5: VisualDataModel.visibleIndex + property variant test6: VisualDataModel.inVisible + property variant test7: VisualDataModel.selectedIndex + property variant test8: VisualDataModel.inSelected + property variant test9: VisualDataModel.groups + + function hide() { VisualDataModel.inVisible = false } + function select() { VisualDataModel.inSelected = true } + + Item { + Package.name: "package" + + objectName: "delegate" + width: 100 + height: 2 + } + } + } + +} diff --git a/tests/auto/quick/qquickvisualdatamodel/data/groups.qml b/tests/auto/quick/qquickvisualdatamodel/data/groups.qml new file mode 100644 index 0000000000..7502dd2502 --- /dev/null +++ b/tests/auto/quick/qquickvisualdatamodel/data/groups.qml @@ -0,0 +1,46 @@ +import QtQuick 2.0 + +ListView { + width: 100 + height: 100 + + function contains(array, value) { + for (var i = 0; i < array.length; ++i) + if (array[i] == value) + return true + return false + } + + model: visualModel + VisualDataModel { + id: visualModel + + objectName: "visualModel" + + groups: [ + VisualDataGroup { id: visibleItems; objectName: "visibleItems"; name: "visible"; includeByDefault: true }, + VisualDataGroup { id: selectedItems; objectName: "selectedItems"; name: "selected" } + ] + + model: myModel + delegate: Item { + id: delegate + + objectName: "delegate" + width: 100 + height: 2 + property variant test1: name + property variant test2: index + property variant test3: VisualDataModel.itemsIndex + property variant test4: VisualDataModel.inItems + property variant test5: VisualDataModel.visibleIndex + property variant test6: VisualDataModel.inVisible + property variant test7: VisualDataModel.selectedIndex + property variant test8: VisualDataModel.inSelected + property variant test9: VisualDataModel.groups + + function hide() { VisualDataModel.inVisible = false } + function select() { VisualDataModel.inSelected = true } + } + } +} diff --git a/tests/auto/quick/qquickvisualdatamodel/data/itemsDestroyed_listView.qml b/tests/auto/quick/qquickvisualdatamodel/data/itemsDestroyed_listView.qml new file mode 100644 index 0000000000..103c4d2eb6 --- /dev/null +++ b/tests/auto/quick/qquickvisualdatamodel/data/itemsDestroyed_listView.qml @@ -0,0 +1,13 @@ +import QtQuick 2.0 + +ListView { + width: 100 + height: 100 + + model: myModel + delegate: Item { + objectName: "delegate" + width: 100 + height: 20 + } +} diff --git a/tests/auto/quick/qquickvisualdatamodel/data/itemsDestroyed_package.qml b/tests/auto/quick/qquickvisualdatamodel/data/itemsDestroyed_package.qml new file mode 100644 index 0000000000..b47f22dc34 --- /dev/null +++ b/tests/auto/quick/qquickvisualdatamodel/data/itemsDestroyed_package.qml @@ -0,0 +1,42 @@ +import QtQuick 2.0 + +Item { + width: 100 + height: 100 + + ListView { + anchors.fill: parent + + model: visualModel.parts.list + } + VisualDataModel { + id: visualModel + + model: myModel + delegate: Package { + Item { + Package.name: "list" + width: 100 + height: 20 + } + + Item { + id: gridItem + Package.name: "grid" + width: 50 + height: 50 + } + Rectangle { + objectName: "delegate" + parent: gridItem + width: 20 + height: 20 + } + } + } + GridView { + anchors.fill: parent + + model: visualModel.parts.grid + } +} diff --git a/tests/auto/quick/qquickvisualdatamodel/data/itemsDestroyed_pathView.qml b/tests/auto/quick/qquickvisualdatamodel/data/itemsDestroyed_pathView.qml new file mode 100644 index 0000000000..bc619124fd --- /dev/null +++ b/tests/auto/quick/qquickvisualdatamodel/data/itemsDestroyed_pathView.qml @@ -0,0 +1,18 @@ +import QtQuick 2.0 + +PathView { + width: 100 + height: 100 + + model: myModel + delegate: Item { + objectName: "delegate" + width: 100 + height: 20 + } + + path: Path { + startX: 50; startY: 0 + PathLine { x: 50; y: 100 } + } +} diff --git a/tests/auto/quick/qquickvisualdatamodel/data/itemsDestroyed_repeater.qml b/tests/auto/quick/qquickvisualdatamodel/data/itemsDestroyed_repeater.qml new file mode 100644 index 0000000000..e97e0dad2e --- /dev/null +++ b/tests/auto/quick/qquickvisualdatamodel/data/itemsDestroyed_repeater.qml @@ -0,0 +1,15 @@ +import QtQuick 2.0 + +Grid { + Repeater { + width: 100 + height: 100 + + model: myModel + delegate: Item { + objectName: "delegate" + width: 50 + height: 50 + } + } +} diff --git a/tests/auto/quick/qquickvisualdatamodel/data/listmodelproperties-package.qml b/tests/auto/quick/qquickvisualdatamodel/data/listmodelproperties-package.qml new file mode 100644 index 0000000000..b6b56727e8 --- /dev/null +++ b/tests/auto/quick/qquickvisualdatamodel/data/listmodelproperties-package.qml @@ -0,0 +1,51 @@ +import QtQuick 2.0 + +ListView { + width: 100 + height: 100 + model: visualModel.parts.package + + VisualDataModel { + id: visualModel + objectName: "visualModel" + + groups: [ + VisualDataGroup { id: visibleItems; objectName: "visibleItems"; name: "visible"; includeByDefault: true }, + VisualDataGroup { id: selectedItems; objectName: "selectedItems"; name: "selected" } + ] + + model: ListModel { + id: listModel + + ListElement { number: "one" } + ListElement { number: "two" } + ListElement { number: "three" } + ListElement { number: "four" } + } + + delegate: Package { + id: delegate + + property variant test1: index + property variant test2: model.index + property variant test3: number + property variant test4: model.number + property variant test5: modelData + property variant test6: model.modelData + + function setTest3(arg) { number = arg } + function setTest4(arg) { model.number = arg } + function setTest5(arg) { modelData = arg } + function setTest6(arg) { model.modelData = arg } + + Item { + objectName: "delegate" + + Package.name: "package" + + width: 100 + height: 2 + } + } + } +} diff --git a/tests/auto/quick/qquickvisualdatamodel/data/listmodelproperties.qml b/tests/auto/quick/qquickvisualdatamodel/data/listmodelproperties.qml new file mode 100644 index 0000000000..d2dfc37e07 --- /dev/null +++ b/tests/auto/quick/qquickvisualdatamodel/data/listmodelproperties.qml @@ -0,0 +1,45 @@ +import QtQuick 2.0 + +ListView { + width: 100 + height: 100 + model: VisualDataModel { + id: visualModel + objectName: "visualModel" + + groups: [ + VisualDataGroup { id: visibleItems; objectName: "visibleItems"; name: "visible"; includeByDefault: true }, + VisualDataGroup { id: selectedItems; objectName: "selectedItems"; name: "selected" } + ] + + model: ListModel { + id: listModel + + ListElement { number: "one" } + ListElement { number: "two" } + ListElement { number: "three" } + ListElement { number: "four" } + } + + delegate: Item { + id: delegate + + objectName: "delegate" + + property variant test1: index + property variant test2: model.index + property variant test3: number + property variant test4: model.number + property variant test5: modelData + property variant test6: model.modelData + + function setTest3(arg) { number = arg } + function setTest4(arg) { model.number = arg } + function setTest5(arg) { modelData = arg } + function setTest6(arg) { model.modelData = arg } + + width: 100 + height: 2 + } + } +} diff --git a/tests/auto/quick/qquickvisualdatamodel/data/modelproperties.qml b/tests/auto/quick/qquickvisualdatamodel/data/modelproperties.qml new file mode 100644 index 0000000000..73b766f1af --- /dev/null +++ b/tests/auto/quick/qquickvisualdatamodel/data/modelproperties.qml @@ -0,0 +1,21 @@ +import QtQuick 2.0 + +ListView { + width: 100 + height: 100 + model: myModel + delegate: Item { + objectName: "delegate" + width: 100 + height: 2 + property variant test1: name + property variant test2: model.name + property variant test3: modelData + property variant test4: model.modelData + property variant test5: modelData.name + property variant test6: model + property variant test7: index + property variant test8: model.index + property variant test9: model.modelData.name + } +} diff --git a/tests/auto/quick/qquickvisualdatamodel/data/modelproperties2.qml b/tests/auto/quick/qquickvisualdatamodel/data/modelproperties2.qml new file mode 100644 index 0000000000..ea5c240b29 --- /dev/null +++ b/tests/auto/quick/qquickvisualdatamodel/data/modelproperties2.qml @@ -0,0 +1,21 @@ +import QtQuick 2.0 + +ListView { + width: 100 + height: 100 + model: myModel + delegate: Item { + objectName: "delegate" + property variant test1: display + property variant test2: model.display + property variant test3: modelData + property variant test4: model.modelData + property variant test5: modelData.display + property variant test6: model + property variant test7: index + property variant test8: model.index + property variant test9: model.modelData.display + width: 100 + height: 2 + } +} diff --git a/tests/auto/quick/qquickvisualdatamodel/data/multipleroleproperties-package.qml b/tests/auto/quick/qquickvisualdatamodel/data/multipleroleproperties-package.qml new file mode 100644 index 0000000000..964ac426f8 --- /dev/null +++ b/tests/auto/quick/qquickvisualdatamodel/data/multipleroleproperties-package.qml @@ -0,0 +1,46 @@ +import QtQuick 2.0 +import tst_qquickvisualdatamodel 1.0 + +ListView { + width: 100 + height: 100 + model: visualModel.parts.package + VisualDataModel { + id: visualModel + objectName: "visualModel" + + groups: [ + VisualDataGroup { id: visibleItems; objectName: "visibleItems"; name: "visible"; includeByDefault: true }, + VisualDataGroup { id: selectedItems; objectName: "selectedItems"; name: "selected" } + ] + + model: StandardItemModel { + StandardItem { text: "Row 1 Item" } + StandardItem { text: "Row 2 Item" } + StandardItem { text: "Row 3 Item" } + StandardItem { text: "Row 4 Item" } + } + + delegate: Package { + id: delegate + + property variant test1: index + property variant test2: model.index + property variant test3: display + property variant test4: model.display + + function setTest3(arg) { display = arg } + function setTest4(arg) { model.display = arg } + + Item { + objectName: "delegate" + + width: 100 + height: 2 + + Package.name: "package" + } + } + } +} + diff --git a/tests/auto/quick/qquickvisualdatamodel/data/multipleroleproperties.qml b/tests/auto/quick/qquickvisualdatamodel/data/multipleroleproperties.qml new file mode 100644 index 0000000000..77e30b69b9 --- /dev/null +++ b/tests/auto/quick/qquickvisualdatamodel/data/multipleroleproperties.qml @@ -0,0 +1,41 @@ +import QtQuick 2.0 +import tst_qquickvisualdatamodel 1.0 + +ListView { + width: 100 + height: 100 + model: VisualDataModel { + id: visualModel + objectName: "visualModel" + + groups: [ + VisualDataGroup { id: visibleItems; objectName: "visibleItems"; name: "visible"; includeByDefault: true }, + VisualDataGroup { id: selectedItems; objectName: "selectedItems"; name: "selected" } + ] + + model: StandardItemModel { + StandardItem { text: "Row 1 Item" } + StandardItem { text: "Row 2 Item" } + StandardItem { text: "Row 3 Item" } + StandardItem { text: "Row 4 Item" } + } + + delegate: Item { + id: delegate + + objectName: "delegate" + + property variant test1: index + property variant test2: model.index + property variant test3: display + property variant test4: model.display + + function setTest3(arg) { display = arg } + function setTest4(arg) { model.display = arg } + + width: 100 + height: 2 + } + } +} + diff --git a/tests/auto/quick/qquickvisualdatamodel/data/objectlist.qml b/tests/auto/quick/qquickvisualdatamodel/data/objectlist.qml new file mode 100644 index 0000000000..b3952a8a4d --- /dev/null +++ b/tests/auto/quick/qquickvisualdatamodel/data/objectlist.qml @@ -0,0 +1,19 @@ +import QtQuick 2.0 + +ListView { + width: 100 + height: 100 + anchors.fill: parent + model: myModel + delegate: Component { + Rectangle { + height: 25 + width: 100 + color: model.modelData.color + Text { objectName: "name"; text: name; function getText() { return name } } + Text { objectName: "section"; text: parent.ListView.section } + } + } + section.property: "name" + section.criteria: ViewSection.FullString +} diff --git a/tests/auto/quick/qquickvisualdatamodel/data/objectlistproperties-package.qml b/tests/auto/quick/qquickvisualdatamodel/data/objectlistproperties-package.qml new file mode 100644 index 0000000000..c69e54c2f8 --- /dev/null +++ b/tests/auto/quick/qquickvisualdatamodel/data/objectlistproperties-package.qml @@ -0,0 +1,48 @@ +import QtQuick 2.0 +import tst_qquickvisualdatamodel 1.0 + +ListView { + width: 100 + height: 100 + model: visualModel.parts.package + + VisualDataModel { + id: visualModel + objectName: "visualModel" + + property list objects: [ + DataObject { name: "Item 1"; color: "red" }, + DataObject { name: "Item 2"; color: "green" }, + DataObject { name: "Item 3"; color: "blue"}, + DataObject { name: "Item 4"; color: "yellow" } + ] + + groups: [ + VisualDataGroup { id: visibleItems; objectName: "visibleItems"; name: "visible"; includeByDefault: true }, + VisualDataGroup { id: selectedItems; objectName: "selectedItems"; name: "selected" } + ] + + model: objects + + delegate: Package { + id: delegate + + property variant test1: index + property variant test2: model.index + property variant test3: name + property variant test4: model.name + + function setTest3(arg) { name = arg } + function setTest4(arg) { model.name = arg } + + Item { + objectName: "delegate" + + width: 100 + height: 2 + Package.name: "package" + } + } + } +} + diff --git a/tests/auto/quick/qquickvisualdatamodel/data/objectlistproperties.qml b/tests/auto/quick/qquickvisualdatamodel/data/objectlistproperties.qml new file mode 100644 index 0000000000..0dbe2f5459 --- /dev/null +++ b/tests/auto/quick/qquickvisualdatamodel/data/objectlistproperties.qml @@ -0,0 +1,43 @@ +import QtQuick 2.0 +import tst_qquickvisualdatamodel 1.0 + +ListView { + width: 100 + height: 100 + model: VisualDataModel { + id: visualModel + objectName: "visualModel" + + property list objects: [ + DataObject { name: "Item 1"; color: "red" }, + DataObject { name: "Item 2"; color: "green" }, + DataObject { name: "Item 3"; color: "blue"}, + DataObject { name: "Item 4"; color: "yellow" } + ] + + groups: [ + VisualDataGroup { id: visibleItems; objectName: "visibleItems"; name: "visible"; includeByDefault: true }, + VisualDataGroup { id: selectedItems; objectName: "selectedItems"; name: "selected" } + ] + + model: objects + + delegate: Item { + id: delegate + + objectName: "delegate" + + property variant test1: index + property variant test2: model.index + property variant test3: name + property variant test4: model.name + + function setTest3(arg) { name = arg } + function setTest4(arg) { model.name = arg } + + width: 100 + height: 2 + } + } +} + diff --git a/tests/auto/quick/qquickvisualdatamodel/data/onChanged.qml b/tests/auto/quick/qquickvisualdatamodel/data/onChanged.qml new file mode 100644 index 0000000000..71dc7d72d7 --- /dev/null +++ b/tests/auto/quick/qquickvisualdatamodel/data/onChanged.qml @@ -0,0 +1,87 @@ +import QtQuick 2.0 + +VisualDataModel { + id: vm + + property var inserted + property var removed + + Component.onCompleted: { + vm.inserted = [] + vm.removed = [] + vi.inserted = [] + vi.removed = [] + si.inserted = [] + si.removed = [] + } + + function verify(changes, indexes, counts, moveIds) { + if (changes.length != indexes.length + || changes.length != counts.length + || changes.length != moveIds.length) { + console.log("invalid length", changes.length, indexes.length, counts.length, moveIds.length) + return false + } + + var valid = true; + for (var i = 0; i < changes.length; ++i) { + if (changes[i].index != indexes[i]) { + console.log(i, "incorrect index. actual:", changes[i].index, "expected:", indexes[i]) + valid = false; + } + if (changes[i].count != counts[i]) { + console.log(i, "incorrect count. actual:", changes[i].count, "expected:", counts[i]) + valid = false; + } + if (changes[i].moveId != moveIds[i]) { + console.log(i, "incorrect moveId. actual:", changes[i].moveId, "expected:", moveIds[i]) + valid = false; + } + } + return valid + } + + groups: [ + VisualDataGroup { + id: vi; + + property var inserted + property var removed + + name: "visible" + includeByDefault: true + + onChanged: { + vi.inserted = inserted + vi.removed = removed + } + }, + VisualDataGroup { + id: si; + + property var inserted + property var removed + + name: "selected" + onChanged: { + si.inserted = inserted + si.removed = removed + } + } + ] + + model: ListModel { + id: listModel + ListElement { number: "one" } + ListElement { number: "two" } + ListElement { number: "three" } + ListElement { number: "four" } + } + + delegate: Item {} + + items.onChanged: { + vm.inserted = inserted + vm.removed = removed + } +} diff --git a/tests/auto/quick/qquickvisualdatamodel/data/packageView.qml b/tests/auto/quick/qquickvisualdatamodel/data/packageView.qml new file mode 100644 index 0000000000..682f3833d1 --- /dev/null +++ b/tests/auto/quick/qquickvisualdatamodel/data/packageView.qml @@ -0,0 +1,63 @@ +import QtQuick 2.0 + +Item { + width: 240 + height: 320 + + Component { + id: myDelegate + + Package { + Rectangle { + id: leftWrapper + objectName: "wrapper" + Package.name: "left" + height: 20 + width: 120 + Text { + text: index + } + color: ListView.isCurrentItem ? "lightsteelblue" : "white" + } + Rectangle { + id: rightWrapper + objectName: "wrapper" + Package.name: "right" + height: 20 + width: 120 + Text { + text: index + } + color: ListView.isCurrentItem ? "lightsteelblue" : "white" + } + } + + } + + VisualDataModel { + id: visualModel + + delegate: myDelegate + model: testModel + } + + ListView { + id: leftList + objectName: "leftList" + anchors { + left: parent.left; top: parent.top; + right: parent.horizontalCenter; bottom: parent.bottom + } + model: visualModel.parts.left + } + + ListView { + id: rightList + objectName: "rightList" + anchors { + left: parent.horizontalCenter; top: parent.top; + right: parent.right; bottom: parent.bottom + } + model: visualModel.parts.right + } +} diff --git a/tests/auto/quick/qquickvisualdatamodel/data/singlerole1.qml b/tests/auto/quick/qquickvisualdatamodel/data/singlerole1.qml new file mode 100644 index 0000000000..c471893e1d --- /dev/null +++ b/tests/auto/quick/qquickvisualdatamodel/data/singlerole1.qml @@ -0,0 +1,10 @@ +import QtQuick 2.0 + +ListView { + width: 100 + height: 100 + model: myModel + delegate: Component { + Text { objectName: "name"; text: name; function getText() { return name; } } + } +} diff --git a/tests/auto/quick/qquickvisualdatamodel/data/singlerole2.qml b/tests/auto/quick/qquickvisualdatamodel/data/singlerole2.qml new file mode 100644 index 0000000000..ab1798999d --- /dev/null +++ b/tests/auto/quick/qquickvisualdatamodel/data/singlerole2.qml @@ -0,0 +1,10 @@ +import QtQuick 2.0 + +ListView { + width: 100 + height: 100 + model: myModel + delegate: Component { + Text { objectName: "name"; text: modelData; function getText() { return modelData } } + } +} diff --git a/tests/auto/quick/qquickvisualdatamodel/data/singleroleproperties-package.qml b/tests/auto/quick/qquickvisualdatamodel/data/singleroleproperties-package.qml new file mode 100644 index 0000000000..910df816f3 --- /dev/null +++ b/tests/auto/quick/qquickvisualdatamodel/data/singleroleproperties-package.qml @@ -0,0 +1,45 @@ +import QtQuick 2.0 +import tst_qquickvisualdatamodel 1.0 + +ListView { + width: 100 + height: 100 + model: visualModel.parts.package + + VisualDataModel { + id: visualModel + objectName: "visualModel" + + groups: [ + VisualDataGroup { id: visibleItems; objectName: "visibleItems"; name: "visible"; includeByDefault: true }, + VisualDataGroup { id: selectedItems; objectName: "selectedItems"; name: "selected" } + ] + + model: SingleRoleModel {} + + delegate: Package { + id: delegate + + property variant test1: index + property variant test2: model.index + property variant test3: name + property variant test4: model.name + property variant test5: modelData + property variant test6: model.modelData + + + function setTest3(arg) { name = arg } + function setTest4(arg) { model.name = arg } + function setTest5(arg) { modelData = arg } + function setTest6(arg) { model.modelData = arg } + + Item { + objectName: "delegate" + width: 100 + height: 2 + Package.name: "package" + } + } + + } +} diff --git a/tests/auto/quick/qquickvisualdatamodel/data/singleroleproperties.qml b/tests/auto/quick/qquickvisualdatamodel/data/singleroleproperties.qml new file mode 100644 index 0000000000..6133c61bc5 --- /dev/null +++ b/tests/auto/quick/qquickvisualdatamodel/data/singleroleproperties.qml @@ -0,0 +1,39 @@ +import QtQuick 2.0 +import tst_qquickvisualdatamodel 1.0 + +ListView { + width: 100 + height: 100 + model: VisualDataModel { + id: visualModel + objectName: "visualModel" + + groups: [ + VisualDataGroup { id: visibleItems; objectName: "visibleItems"; name: "visible"; includeByDefault: true }, + VisualDataGroup { id: selectedItems; objectName: "selectedItems"; name: "selected" } + ] + + model: SingleRoleModel {} + + delegate: Item { + id: delegate + + objectName: "delegate" + width: 100 + height: 2 + property variant test1: index + property variant test2: model.index + property variant test3: name + property variant test4: model.name + property variant test5: modelData + property variant test6: model.modelData + + + function setTest3(arg) { name = arg } + function setTest4(arg) { model.name = arg } + function setTest5(arg) { modelData = arg } + function setTest6(arg) { model.modelData = arg } + } + + } +} diff --git a/tests/auto/quick/qquickvisualdatamodel/data/stringlistproperties-package.qml b/tests/auto/quick/qquickvisualdatamodel/data/stringlistproperties-package.qml new file mode 100644 index 0000000000..d1a4604b77 --- /dev/null +++ b/tests/auto/quick/qquickvisualdatamodel/data/stringlistproperties-package.qml @@ -0,0 +1,45 @@ +import QtQuick 2.0 +import tst_qquickvisualdatamodel 1.0 + +ListView { + width: 100 + height: 100 + model: visualModel.parts.package + VisualDataModel { + id: visualModel + objectName: "visualModel" + + groups: [ + VisualDataGroup { id: visibleItems; objectName: "visibleItems"; name: "visible"; includeByDefault: true }, + VisualDataGroup { id: selectedItems; objectName: "selectedItems"; name: "selected" } + ] + + model: [ + "one", + "two", + "three", + "four" + ] + + delegate: Package { + id: delegate + + property variant test1: index + property variant test2: model.index + property variant test3: modelData + property variant test4: model.modelData + + function setTest3(arg) { modelData = arg } + function setTest4(arg) { model.modelData = arg } + + Item { + objectName: "delegate" + + width: 100 + height: 2 + + Package.name: "package" + } + } + } +} diff --git a/tests/auto/quick/qquickvisualdatamodel/data/stringlistproperties.qml b/tests/auto/quick/qquickvisualdatamodel/data/stringlistproperties.qml new file mode 100644 index 0000000000..a075ccb4d9 --- /dev/null +++ b/tests/auto/quick/qquickvisualdatamodel/data/stringlistproperties.qml @@ -0,0 +1,40 @@ +import QtQuick 2.0 +import tst_qquickvisualdatamodel 1.0 + +ListView { + width: 100 + height: 100 + model: VisualDataModel { + id: visualModel + objectName: "visualModel" + + groups: [ + VisualDataGroup { id: visibleItems; objectName: "visibleItems"; name: "visible"; includeByDefault: true }, + VisualDataGroup { id: selectedItems; objectName: "selectedItems"; name: "selected" } + ] + + model: [ + "one", + "two", + "three", + "four" + ] + + delegate: Item { + id: delegate + + objectName: "delegate" + + property variant test1: index + property variant test2: model.index + property variant test3: modelData + property variant test4: model.modelData + + function setTest3(arg) { modelData = arg } + function setTest4(arg) { model.modelData = arg } + + width: 100 + height: 2 + } + } +} diff --git a/tests/auto/quick/qquickvisualdatamodel/data/visualdatamodel.qml b/tests/auto/quick/qquickvisualdatamodel/data/visualdatamodel.qml new file mode 100644 index 0000000000..0d4d9e2e46 --- /dev/null +++ b/tests/auto/quick/qquickvisualdatamodel/data/visualdatamodel.qml @@ -0,0 +1,12 @@ +import QtQuick 2.0 + +VisualDataModel { + function setRoot() { + rootIndex = modelIndex(0); + } + function setRootToParent() { + rootIndex = parentModelIndex(); + } + model: myModel + delegate: Item {} +} diff --git a/tests/auto/quick/qquickvisualdatamodel/qquickvisualdatamodel.pro b/tests/auto/quick/qquickvisualdatamodel/qquickvisualdatamodel.pro new file mode 100644 index 0000000000..bfadf196f9 --- /dev/null +++ b/tests/auto/quick/qquickvisualdatamodel/qquickvisualdatamodel.pro @@ -0,0 +1,16 @@ +CONFIG += testcase +TARGET = tst_qquickvisualdatamodel +macx:CONFIG -= app_bundle + +SOURCES += tst_qquickvisualdatamodel.cpp + +include (../../shared/util.pri) +include (../shared/util.pri) + +testDataFiles.files = data +testDataFiles.path = . +DEPLOYMENT += testDataFiles + +CONFIG += parallel_test + +QT += core-private gui-private v8-private qml-private quick-private widgets testlib diff --git a/tests/auto/quick/qquickvisualdatamodel/tst_qquickvisualdatamodel.cpp b/tests/auto/quick/qquickvisualdatamodel/tst_qquickvisualdatamodel.cpp new file mode 100644 index 0000000000..dbfd4919b9 --- /dev/null +++ b/tests/auto/quick/qquickvisualdatamodel/tst_qquickvisualdatamodel.cpp @@ -0,0 +1,3446 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include "../../shared/util.h" +#include "../shared/visualtestutil.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +using namespace QQuickVisualTestUtil; + +template int lengthOf(const T (&)[N]) { return N; } + +static void initStandardTreeModel(QStandardItemModel *model) +{ + QStandardItem *item; + item = new QStandardItem(QLatin1String("Row 1 Item")); + model->insertRow(0, item); + + item = new QStandardItem(QLatin1String("Row 2 Item")); + item->setCheckable(true); + model->insertRow(1, item); + + QStandardItem *childItem = new QStandardItem(QLatin1String("Row 2 Child Item")); + item->setChild(0, childItem); + + item = new QStandardItem(QLatin1String("Row 3 Item")); + item->setIcon(QIcon()); + model->insertRow(2, item); +} + +class SingleRoleModel : public QAbstractListModel +{ + Q_OBJECT + Q_PROPERTY(QStringList values WRITE setList) +public: + SingleRoleModel(const QByteArray &role = "name", QObject *parent = 0) + : QAbstractListModel(parent) + { + QHash roles; + roles.insert(Qt::DisplayRole , role); + setRoleNames(roles); + list << "one" << "two" << "three" << "four"; + } + + void emitMove(int sourceFirst, int sourceLast, int destinationChild) { + emit beginMoveRows(QModelIndex(), sourceFirst, sourceLast, QModelIndex(), destinationChild); + emit endMoveRows(); + } + + QStringList list; + + void setList(const QStringList &l) { list = l; } + +public slots: + void set(int idx, QString string) { + list[idx] = string; + emit dataChanged(index(idx,0), index(idx,0)); + } + +protected: + int rowCount(const QModelIndex & /* parent */ = QModelIndex()) const { + return list.count(); + } + QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const { + if (role == Qt::DisplayRole) + return list.at(index.row()); + return QVariant(); + } +}; + +class StandardItem : public QObject, public QStandardItem +{ + Q_OBJECT + Q_PROPERTY(QString text WRITE setText) + +public: + void writeText(const QString &text) { setText(text); } +}; + +class StandardItemModel : public QStandardItemModel +{ + Q_OBJECT + Q_PROPERTY(QQmlListProperty items READ items CONSTANT) + Q_CLASSINFO("DefaultProperty", "items") +public: + QQmlListProperty items() { return QQmlListProperty(this, 0, append); } + + static void append(QQmlListProperty *property, StandardItem *item) + { + static_cast(property->object)->appendRow(item); + } +}; + +class DataObject : public QObject +{ + Q_OBJECT + + Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged) + Q_PROPERTY(QString color READ color WRITE setColor NOTIFY colorChanged) + +public: + DataObject(QObject *parent=0) : QObject(parent) {} + DataObject(const QString &name, const QString &color, QObject *parent=0) + : QObject(parent), m_name(name), m_color(color) { } + + + QString name() const { return m_name; } + void setName(const QString &name) { + if (name != m_name) { + m_name = name; + emit nameChanged(); + } + } + + QString color() const { return m_color; } + void setColor(const QString &color) { + if (color != m_color) { + m_color = color; + emit colorChanged(); + } + } + +signals: + void nameChanged(); + void colorChanged(); + +private: + QString m_name; + QString m_color; +}; + +QML_DECLARE_TYPE(SingleRoleModel) +QML_DECLARE_TYPE(StandardItem) +QML_DECLARE_TYPE(StandardItemModel) +QML_DECLARE_TYPE(DataObject) + +class tst_qquickvisualdatamodel : public QQmlDataTest +{ + Q_OBJECT +public: + tst_qquickvisualdatamodel(); + +private slots: + void initTestCase(); + void cleanupTestCase(); + void rootIndex(); + void updateLayout_data(); + void updateLayout(); + void childChanged_data(); + void childChanged(); + void objectListModel(); + void singleRole(); + void modelProperties(); + void noDelegate_data(); + void noDelegate(); + void itemsDestroyed_data(); + void itemsDestroyed(); + void packagesDestroyed(); + void qaimRowsMoved(); + void qaimRowsMoved_data(); + void remove_data(); + void remove(); + void move_data(); + void move(); + void groups_data(); + void groups(); + void invalidGroups(); + void get(); + void onChanged_data(); + void onChanged(); + void create(); + void incompleteModel(); + void insert_data(); + void insert(); + void resolve_data(); + void resolve(); + void warnings_data(); + void warnings(); + +private: + template void groups_verify( + const SingleRoleModel &model, + QQuickItem *contentItem, + const int (&mIndex)[N], + const int (&iIndex)[N], + const int (&vIndex)[N], + const int (&sIndex)[N], + const bool (&vMember)[N], + const bool (&sMember)[N]); + + template void get_verify( + const SingleRoleModel &model, + QQuickVisualDataModel *visualModel, + QQuickVisualDataGroup *visibleItems, + QQuickVisualDataGroup *selectedItems, + const int (&mIndex)[N], + const int (&iIndex)[N], + const int (&vIndex)[N], + const int (&sIndex)[N], + const bool (&vMember)[N], + const bool (&sMember)[N]); + + bool failed; + QQmlEngine engine; +}; + +Q_DECLARE_METATYPE(QQuickChangeSet) + +template static T evaluate(QObject *scope, const QString &expression) +{ + QQmlExpression expr(qmlContext(scope), scope, expression); + T result = expr.evaluate().value(); + if (expr.hasError()) + qWarning() << expr.error().toString(); + return result; +} + +template <> void evaluate(QObject *scope, const QString &expression) +{ + QQmlExpression expr(qmlContext(scope), scope, expression); + expr.evaluate(); + if (expr.hasError()) + qWarning() << expr.error().toString(); +} + +void tst_qquickvisualdatamodel::initTestCase() +{ + QQmlDataTest::initTestCase(); + qRegisterMetaType(); + + qmlRegisterType("tst_qquickvisualdatamodel", 1, 0, "SingleRoleModel"); + qmlRegisterType("tst_qquickvisualdatamodel", 1, 0, "StandardItem"); + qmlRegisterType("tst_qquickvisualdatamodel", 1, 0, "StandardItemModel"); + qmlRegisterType("tst_qquickvisualdatamodel", 1, 0, "DataObject"); +} + +void tst_qquickvisualdatamodel::cleanupTestCase() +{ + +} + +tst_qquickvisualdatamodel::tst_qquickvisualdatamodel() +{ +} + +void tst_qquickvisualdatamodel::rootIndex() +{ + QQmlEngine engine; + QQmlComponent c(&engine, testFileUrl("visualdatamodel.qml")); + + QStandardItemModel model; + initStandardTreeModel(&model); + + engine.rootContext()->setContextProperty("myModel", &model); + + QQuickVisualDataModel *obj = qobject_cast(c.create()); + QVERIFY(obj != 0); + + QMetaObject::invokeMethod(obj, "setRoot"); + QVERIFY(qvariant_cast(obj->rootIndex()) == model.index(0,0)); + + QMetaObject::invokeMethod(obj, "setRootToParent"); + QVERIFY(qvariant_cast(obj->rootIndex()) == QModelIndex()); + + QMetaObject::invokeMethod(obj, "setRoot"); + QVERIFY(qvariant_cast(obj->rootIndex()) == model.index(0,0)); + model.clear(); // will emit modelReset() + QVERIFY(qvariant_cast(obj->rootIndex()) == QModelIndex()); + + delete obj; +} + +void tst_qquickvisualdatamodel::updateLayout_data() +{ + QTest::addColumn("source"); + + QTest::newRow("item delegate") << testFileUrl("datalist.qml"); + QTest::newRow("package delegate") << testFileUrl("datalist-package.qml"); +} + +void tst_qquickvisualdatamodel::updateLayout() +{ + QFETCH(QUrl, source); + + QQuickView view; + + QStandardItemModel model; + initStandardTreeModel(&model); + + view.rootContext()->setContextProperty("myModel", &model); + + view.setSource(source); + + QQuickListView *listview = qobject_cast(view.rootObject()); + QVERIFY(listview != 0); + + QQuickItem *contentItem = listview->contentItem(); + QVERIFY(contentItem != 0); + + QQuickText *name = findItem(contentItem, "display", 0); + QVERIFY(name); + QCOMPARE(name->text(), QString("Row 1 Item")); + name = findItem(contentItem, "display", 1); + QVERIFY(name); + QCOMPARE(name->text(), QString("Row 2 Item")); + name = findItem(contentItem, "display", 2); + QVERIFY(name); + QCOMPARE(name->text(), QString("Row 3 Item")); + + model.invisibleRootItem()->sortChildren(0, Qt::DescendingOrder); + + name = findItem(contentItem, "display", 0); + QVERIFY(name); + QCOMPARE(name->text(), QString("Row 3 Item")); + name = findItem(contentItem, "display", 1); + QVERIFY(name); + QCOMPARE(name->text(), QString("Row 2 Item")); + name = findItem(contentItem, "display", 2); + QVERIFY(name); + QCOMPARE(name->text(), QString("Row 1 Item")); +} + +void tst_qquickvisualdatamodel::childChanged_data() +{ + QTest::addColumn("source"); + + QTest::newRow("item delegate") << testFileUrl("datalist.qml"); + QTest::newRow("package delegate") << testFileUrl("datalist-package.qml"); +} + +void tst_qquickvisualdatamodel::childChanged() +{ + QFETCH(QUrl, source); + + QQuickView view; + + QStandardItemModel model; + initStandardTreeModel(&model); + + view.rootContext()->setContextProperty("myModel", &model); + + view.setSource(source); + + QQuickListView *listview = qobject_cast(view.rootObject()); + QVERIFY(listview != 0); + + QQuickItem *contentItem = listview->contentItem(); + QVERIFY(contentItem != 0); + + QQuickVisualDataModel *vdm = listview->findChild("visualModel"); + vdm->setRootIndex(QVariant::fromValue(model.indexFromItem(model.item(1,0)))); + QCOMPARE(listview->count(), 1); + + QQuickText *name = findItem(contentItem, "display", 0); + QVERIFY(name); + QCOMPARE(name->text(), QString("Row 2 Child Item")); + + model.item(1,0)->child(0,0)->setText("Row 2 updated child"); + + name = findItem(contentItem, "display", 0); + QVERIFY(name); + QCOMPARE(name->text(), QString("Row 2 updated child")); + + model.item(1,0)->appendRow(new QStandardItem(QLatin1String("Row 2 Child Item 2"))); + QCOMPARE(listview->count(), 2); + + name = findItem(contentItem, "display", 1); + QVERIFY(name != 0); + QCOMPARE(name->text(), QString("Row 2 Child Item 2")); + + model.item(1,0)->takeRow(1); + name = findItem(contentItem, "display", 1); + QVERIFY(name == 0); + + vdm->setRootIndex(QVariant::fromValue(QModelIndex())); + QCOMPARE(listview->count(), 3); + name = findItem(contentItem, "display", 0); + QVERIFY(name); + QCOMPARE(name->text(), QString("Row 1 Item")); + name = findItem(contentItem, "display", 1); + QVERIFY(name); + QCOMPARE(name->text(), QString("Row 2 Item")); + name = findItem(contentItem, "display", 2); + QVERIFY(name); + QCOMPARE(name->text(), QString("Row 3 Item")); +} + +void tst_qquickvisualdatamodel::objectListModel() +{ + QQuickView view; + + QList dataList; + dataList.append(new DataObject("Item 1", "red")); + dataList.append(new DataObject("Item 2", "green")); + dataList.append(new DataObject("Item 3", "blue")); + dataList.append(new DataObject("Item 4", "yellow")); + + QQmlContext *ctxt = view.rootContext(); + ctxt->setContextProperty("myModel", QVariant::fromValue(dataList)); + + view.setSource(testFileUrl("objectlist.qml")); + + QQuickListView *listview = qobject_cast(view.rootObject()); + QVERIFY(listview != 0); + + QQuickItem *contentItem = listview->contentItem(); + QVERIFY(contentItem != 0); + + QQuickText *name = findItem(contentItem, "name", 0); + QCOMPARE(name->text(), QString("Item 1")); + + QQuickText *section = findItem(contentItem, "section", 0); + QCOMPARE(section->text(), QString("Item 1")); + + dataList[0]->setProperty("name", QLatin1String("Changed")); + QCOMPARE(name->text(), QString("Changed")); +} + +void tst_qquickvisualdatamodel::singleRole() +{ + { + QQuickView view; + + SingleRoleModel model; + + QQmlContext *ctxt = view.rootContext(); + ctxt->setContextProperty("myModel", &model); + + view.setSource(testFileUrl("singlerole1.qml")); + + QQuickListView *listview = qobject_cast(view.rootObject()); + QVERIFY(listview != 0); + + QQuickItem *contentItem = listview->contentItem(); + QVERIFY(contentItem != 0); + + QQuickText *name = findItem(contentItem, "name", 1); + QCOMPARE(name->text(), QString("two")); + + model.set(1, "Changed"); + QCOMPARE(name->text(), QString("Changed")); + } + { + QQuickView view; + + SingleRoleModel model; + + QQmlContext *ctxt = view.rootContext(); + ctxt->setContextProperty("myModel", &model); + + view.setSource(testFileUrl("singlerole2.qml")); + + QQuickListView *listview = qobject_cast(view.rootObject()); + QVERIFY(listview != 0); + + QQuickItem *contentItem = listview->contentItem(); + QVERIFY(contentItem != 0); + + QQuickText *name = findItem(contentItem, "name", 1); + QCOMPARE(name->text(), QString("two")); + + model.set(1, "Changed"); + QCOMPARE(name->text(), QString("Changed")); + } + { + QQuickView view; + + SingleRoleModel model("modelData"); + + QQmlContext *ctxt = view.rootContext(); + ctxt->setContextProperty("myModel", &model); + + view.setSource(testFileUrl("singlerole2.qml")); + + QQuickListView *listview = qobject_cast(view.rootObject()); + QVERIFY(listview != 0); + + QQuickItem *contentItem = listview->contentItem(); + QVERIFY(contentItem != 0); + + QQuickText *name = findItem(contentItem, "name", 1); + QCOMPARE(name->text(), QString("two")); + + model.set(1, "Changed"); + QCOMPARE(name->text(), QString("Changed")); + } +} + +void tst_qquickvisualdatamodel::modelProperties() +{ + { + QQuickView view; + + SingleRoleModel model; + + QQmlContext *ctxt = view.rootContext(); + ctxt->setContextProperty("myModel", &model); + + view.setSource(testFileUrl("modelproperties.qml")); + + QQuickListView *listview = qobject_cast(view.rootObject()); + QVERIFY(listview != 0); + + QQuickItem *contentItem = listview->contentItem(); + QVERIFY(contentItem != 0); + + QQuickItem *delegate = findItem(contentItem, "delegate", 1); + QVERIFY(delegate); + QCOMPARE(delegate->property("test1").toString(),QString("two")); + QCOMPARE(delegate->property("test2").toString(),QString("two")); + QCOMPARE(delegate->property("test3").toString(),QString("two")); + QCOMPARE(delegate->property("test4").toString(),QString("two")); + QVERIFY(!delegate->property("test9").isValid()); + QCOMPARE(delegate->property("test5").toString(),QString("")); + QVERIFY(delegate->property("test6").value() != 0); + QCOMPARE(delegate->property("test7").toInt(),1); + QCOMPARE(delegate->property("test8").toInt(),1); + } + + { + QQuickView view; + + QList dataList; + dataList.append(new DataObject("Item 1", "red")); + dataList.append(new DataObject("Item 2", "green")); + dataList.append(new DataObject("Item 3", "blue")); + dataList.append(new DataObject("Item 4", "yellow")); + + QQmlContext *ctxt = view.rootContext(); + ctxt->setContextProperty("myModel", QVariant::fromValue(dataList)); + + view.setSource(testFileUrl("modelproperties.qml")); + + QQuickListView *listview = qobject_cast(view.rootObject()); + QVERIFY(listview != 0); + + QQuickItem *contentItem = listview->contentItem(); + QVERIFY(contentItem != 0); + + QQuickItem *delegate = findItem(contentItem, "delegate", 1); + QVERIFY(delegate); + QCOMPARE(delegate->property("test1").toString(),QString("Item 2")); + QCOMPARE(delegate->property("test2").toString(),QString("Item 2")); + QVERIFY(qobject_cast(delegate->property("test3").value()) != 0); + QVERIFY(qobject_cast(delegate->property("test4").value()) != 0); + QCOMPARE(delegate->property("test5").toString(),QString("Item 2")); + QCOMPARE(delegate->property("test9").toString(),QString("Item 2")); + QVERIFY(delegate->property("test6").value() != 0); + QCOMPARE(delegate->property("test7").toInt(),1); + QCOMPARE(delegate->property("test8").toInt(),1); + } + + { + QQuickView view; + + QStandardItemModel model; + initStandardTreeModel(&model); + + view.rootContext()->setContextProperty("myModel", &model); + + QUrl source(testFileUrl("modelproperties2.qml")); + + //3 items, 3 i each + QTest::ignoreMessage(QtWarningMsg, source.toString().toLatin1() + ":13: ReferenceError: Can't find variable: modelData"); + QTest::ignoreMessage(QtWarningMsg, source.toString().toLatin1() + ":13: ReferenceError: Can't find variable: modelData"); + QTest::ignoreMessage(QtWarningMsg, source.toString().toLatin1() + ":13: ReferenceError: Can't find variable: modelData"); + QTest::ignoreMessage(QtWarningMsg, source.toString().toLatin1() + ":11: ReferenceError: Can't find variable: modelData"); + QTest::ignoreMessage(QtWarningMsg, source.toString().toLatin1() + ":11: ReferenceError: Can't find variable: modelData"); + QTest::ignoreMessage(QtWarningMsg, source.toString().toLatin1() + ":11: ReferenceError: Can't find variable: modelData"); + QTest::ignoreMessage(QtWarningMsg, source.toString().toLatin1() + ":17: TypeError: Cannot read property 'display' of undefined"); + QTest::ignoreMessage(QtWarningMsg, source.toString().toLatin1() + ":17: TypeError: Cannot read property 'display' of undefined"); + QTest::ignoreMessage(QtWarningMsg, source.toString().toLatin1() + ":17: TypeError: Cannot read property 'display' of undefined"); + + view.setSource(source); + + QQuickListView *listview = qobject_cast(view.rootObject()); + QVERIFY(listview != 0); + + QQuickItem *contentItem = listview->contentItem(); + QVERIFY(contentItem != 0); + + QQuickItem *delegate = findItem(contentItem, "delegate", 1); + QVERIFY(delegate); + QCOMPARE(delegate->property("test1").toString(),QString("Row 2 Item")); + QCOMPARE(delegate->property("test2").toString(),QString("Row 2 Item")); + QVERIFY(!delegate->property("test3").isValid()); + QVERIFY(!delegate->property("test4").isValid()); + QVERIFY(!delegate->property("test5").isValid()); + QVERIFY(!delegate->property("test9").isValid()); + QVERIFY(delegate->property("test6").value() != 0); + QCOMPARE(delegate->property("test7").toInt(),1); + QCOMPARE(delegate->property("test8").toInt(),1); + } + + //### should also test QStringList and QVariantList +} + +void tst_qquickvisualdatamodel::noDelegate_data() +{ + QTest::addColumn("source"); + + QTest::newRow("item delegate") << testFileUrl("datalist.qml"); + QTest::newRow("package delegate") << testFileUrl("datalist-package.qml"); +} + +void tst_qquickvisualdatamodel::noDelegate() +{ + QFETCH(QUrl, source); + + QQuickView view; + + QStandardItemModel model; + initStandardTreeModel(&model); + + view.rootContext()->setContextProperty("myModel", &model); + + view.setSource(source); + + QQuickListView *listview = qobject_cast(view.rootObject()); + QVERIFY(listview != 0); + + QQuickVisualDataModel *vdm = listview->findChild("visualModel"); + QVERIFY(vdm != 0); + QCOMPARE(vdm->count(), 3); + + vdm->setDelegate(0); + QCOMPARE(vdm->count(), 0); +} + +void tst_qquickvisualdatamodel::itemsDestroyed_data() +{ + QTest::addColumn("source"); + + QTest::newRow("listView") << testFileUrl("itemsDestroyed_listView.qml"); + QTest::newRow("package") << testFileUrl("itemsDestroyed_package.qml"); + QTest::newRow("pathView") << testFileUrl("itemsDestroyed_pathView.qml"); + QTest::newRow("repeater") << testFileUrl("itemsDestroyed_repeater.qml"); +} + +void tst_qquickvisualdatamodel::itemsDestroyed() +{ + QFETCH(QUrl, source); + + QQmlGuard delegate; + + { + QQuickView view; + QStandardItemModel model; + initStandardTreeModel(&model); + view.rootContext()->setContextProperty("myModel", &model); + view.setSource(source); + + view.show(); + QTest::qWaitForWindowShown(&view); + + QVERIFY(delegate = findItem(view.rootItem(), "delegate", 1)); + } + QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete); + QVERIFY(!delegate); +} + +void tst_qquickvisualdatamodel::packagesDestroyed() +{ + SingleRoleModel model; + model.list.clear(); + for (int i=0; i<30; i++) + model.list << ("item " + i); + + QQuickView view; + view.rootContext()->setContextProperty("testModel", &model); + + QString filename(testFile("packageView.qml")); + view.setSource(QUrl::fromLocalFile(filename)); + + qApp->processEvents(); + + QQuickListView *leftview = findItem(view.rootObject(), "leftList"); + QTRY_VERIFY(leftview != 0); + + QQuickListView *rightview = findItem(view.rootObject(), "rightList"); + QTRY_VERIFY(rightview != 0); + + QQuickItem *leftContent = leftview->contentItem(); + QTRY_VERIFY(leftContent != 0); + + QQuickItem *rightContent = rightview->contentItem(); + QTRY_VERIFY(rightContent != 0); + + QCOMPARE(leftview->currentIndex(), 0); + QCOMPARE(rightview->currentIndex(), 0); + + rightview->setCurrentIndex(20); + QTRY_COMPARE(rightview->contentY(), 100.0); + + QQmlGuard left; + QQmlGuard right; + + QVERIFY(findItem(leftContent, "wrapper", 1)); + QVERIFY(findItem(rightContent, "wrapper", 1)); + + QVERIFY(left = findItem(leftContent, "wrapper", 19)); + QVERIFY(right = findItem(rightContent, "wrapper", 19)); + + rightview->setCurrentIndex(0); + QCOMPARE(rightview->currentIndex(), 0); + + QTRY_COMPARE(rightview->contentY(), 0.0); + QCoreApplication::sendPostedEvents(); + + QVERIFY(!left); + QVERIFY(!right); + + QVERIFY(left = findItem(leftContent, "wrapper", 1)); + QVERIFY(right = findItem(rightContent, "wrapper", 1)); + + rightview->setCurrentIndex(20); + QTRY_COMPARE(rightview->contentY(), 100.0); + + QVERIFY(left); + QVERIFY(right); + + QVERIFY(findItem(leftContent, "wrapper", 19)); + QVERIFY(findItem(rightContent, "wrapper", 19)); + + leftview->setCurrentIndex(20); + QTRY_COMPARE(leftview->contentY(), 100.0); + + QVERIFY(!left); + QVERIFY(!right); +} + +void tst_qquickvisualdatamodel::qaimRowsMoved() +{ + // Test parameters passed in QAIM::rowsMoved() signal are converted correctly + // when translated and emitted as the QListModelInterface::itemsMoved() signal + QFETCH(int, sourceFirst); + QFETCH(int, sourceLast); + QFETCH(int, destinationChild); + QFETCH(int, expectFrom); + QFETCH(int, expectTo); + QFETCH(int, expectCount); + + QQmlEngine engine; + QQmlComponent c(&engine, testFileUrl("visualdatamodel.qml")); + + SingleRoleModel model; + model.list.clear(); + for (int i=0; i<30; i++) + model.list << ("item " + i); + engine.rootContext()->setContextProperty("myModel", &model); + + QQuickVisualDataModel *obj = qobject_cast(c.create()); + QVERIFY(obj != 0); + + QSignalSpy spy(obj, SIGNAL(modelUpdated(QQuickChangeSet,bool))); + model.emitMove(sourceFirst, sourceLast, destinationChild); + QCOMPARE(spy.count(), 1); + + QCOMPARE(spy[0].count(), 2); + QQuickChangeSet changeSet = spy[0][0].value(); + QCOMPARE(changeSet.removes().count(), 1); + QCOMPARE(changeSet.removes().at(0).index, expectFrom); + QCOMPARE(changeSet.removes().at(0).count, expectCount); + QCOMPARE(changeSet.inserts().count(), 1); + QCOMPARE(changeSet.inserts().at(0).index, expectTo); + QCOMPARE(changeSet.inserts().at(0).count, expectCount); + QCOMPARE(changeSet.removes().at(0).moveId, changeSet.inserts().at(0).moveId); + QCOMPARE(spy[0][1].toBool(), false); + + delete obj; +} + +void tst_qquickvisualdatamodel::qaimRowsMoved_data() +{ + QTest::addColumn("sourceFirst"); + QTest::addColumn("sourceLast"); + QTest::addColumn("destinationChild"); + QTest::addColumn("expectFrom"); + QTest::addColumn("expectTo"); + QTest::addColumn("expectCount"); + + QTest::newRow("move 1 forward") + << 1 << 1 << 6 + << 1 << 5 << 1; + + QTest::newRow("move 1 backwards") + << 4 << 4 << 1 + << 4 << 1 << 1; + + QTest::newRow("move multiple forwards") + << 0 << 2 << 13 + << 0 << 10 << 3; + + QTest::newRow("move multiple forwards, with same to") + << 0 << 1 << 3 + << 0 << 1 << 2; + + QTest::newRow("move multiple backwards") + << 10 << 14 << 1 + << 10 << 1 << 5; +} + +void tst_qquickvisualdatamodel::remove_data() +{ + QTest::addColumn("source"); + QTest::addColumn("package delegate"); + + QTest::newRow("item delegate") + << testFileUrl("groups.qml") + << QString(); + QTest::newRow("package") + << testFileUrl("groups-package.qml") + << QString("package."); +} + +void tst_qquickvisualdatamodel::remove() +{ + QQuickView view; + + SingleRoleModel model; + model.list = QStringList() + << "one" + << "two" + << "three" + << "four" + << "five" + << "six" + << "seven" + << "eight" + << "nine" + << "ten" + << "eleven" + << "twelve"; + + QQmlContext *ctxt = view.rootContext(); + ctxt->setContextProperty("myModel", &model); + + view.setSource(testFileUrl("groups.qml")); + + QQuickListView *listview = qobject_cast(view.rootObject()); + QVERIFY(listview != 0); + + QQuickItem *contentItem = listview->contentItem(); + QVERIFY(contentItem != 0); + + QQuickVisualDataModel *visualModel = qobject_cast(qvariant_cast(listview->model())); + QVERIFY(visualModel); + + { + QCOMPARE(listview->count(), 12); + QCOMPARE(visualModel->items()->count(), 12); + static const int mIndex[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11 }; + static const int iIndex[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11 }; + + for (int i = 0; i < lengthOf(mIndex); ++i) { + QQuickItem *delegate = findItem(contentItem, "delegate", mIndex[i]); + QVERIFY(delegate); + QCOMPARE(delegate->property("test1").toString(), model.list.at(mIndex[i])); + QCOMPARE(delegate->property("test2").toInt(), mIndex[i]); + QCOMPARE(delegate->property("test3").toInt(), iIndex[i]); + } + } { + evaluate(visualModel, "items.remove(2)"); + QCOMPARE(listview->count(), 11); + QCOMPARE(visualModel->items()->count(), 11); + static const int mIndex[] = { 0, 1, 3, 4, 5, 6, 7, 8, 9,10,11 }; + static const int iIndex[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10 }; + + for (int i = 0; i < lengthOf(mIndex); ++i) { + QQuickItem *delegate = findItem(contentItem, "delegate", mIndex[i]); + QVERIFY(delegate); + QCOMPARE(delegate->property("test1").toString(), model.list.at(mIndex[i])); + QCOMPARE(delegate->property("test2").toInt(), mIndex[i]); + QCOMPARE(delegate->property("test3").toInt(), iIndex[i]); + } + } { + evaluate(visualModel, "items.remove(1, 4)"); + QCOMPARE(listview->count(), 7); + QCOMPARE(visualModel->items()->count(), 7); + static const int mIndex[] = { 0, 6, 7, 8, 9,10,11 }; + static const int iIndex[] = { 0, 1, 2, 3, 4, 5, 6 }; + + for (int i = 0; i < lengthOf(mIndex); ++i) { + QQuickItem *delegate = findItem(contentItem, "delegate", mIndex[i]); + QVERIFY(delegate); + QCOMPARE(delegate->property("test1").toString(), model.list.at(mIndex[i])); + QCOMPARE(delegate->property("test2").toInt(), mIndex[i]); + QCOMPARE(delegate->property("test3").toInt(), iIndex[i]); + } + } { + QTest::ignoreMessage(QtWarningMsg, ": QML VisualDataGroup: remove: index out of range"); + evaluate(visualModel, "items.remove(-8, 4)"); + QCOMPARE(listview->count(), 7); + QCOMPARE(visualModel->items()->count(), 7); + } { + QTest::ignoreMessage(QtWarningMsg, ": QML VisualDataGroup: remove: index out of range"); + evaluate(visualModel, "items.remove(12, 2)"); + QCOMPARE(listview->count(), 7); + QCOMPARE(visualModel->items()->count(), 7); + } { + QTest::ignoreMessage(QtWarningMsg, ": QML VisualDataGroup: remove: invalid count"); + evaluate(visualModel, "items.remove(5, 3)"); + QCOMPARE(listview->count(), 7); + QCOMPARE(visualModel->items()->count(), 7); + } { + QTest::ignoreMessage(QtWarningMsg, ": QML VisualDataGroup: remove: invalid count"); + evaluate(visualModel, "items.remove(5, -2)"); + QCOMPARE(listview->count(), 7); + QCOMPARE(visualModel->items()->count(), 7); + } +} + +void tst_qquickvisualdatamodel::move_data() +{ + QTest::addColumn("source"); + QTest::addColumn("package delegate"); + + QTest::newRow("item delegate") + << testFileUrl("groups.qml") + << QString(); + QTest::newRow("package") + << testFileUrl("groups-package.qml") + << QString("package."); +} + +void tst_qquickvisualdatamodel::move() +{ + QQuickView view; + + SingleRoleModel model; + model.list = QStringList() + << "one" + << "two" + << "three" + << "four" + << "five" + << "six" + << "seven" + << "eight" + << "nine" + << "ten" + << "eleven" + << "twelve"; + + QQmlContext *ctxt = view.rootContext(); + ctxt->setContextProperty("myModel", &model); + + view.setSource(testFileUrl("groups.qml")); + + QQuickListView *listview = qobject_cast(view.rootObject()); + QVERIFY(listview != 0); + + QQuickItem *contentItem = listview->contentItem(); + QVERIFY(contentItem != 0); + + QQuickVisualDataModel *visualModel = qobject_cast(qvariant_cast(listview->model())); + QVERIFY(visualModel); + + { + QCOMPARE(listview->count(), 12); + QCOMPARE(visualModel->items()->count(), 12); + static const int mIndex[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11 }; + static const int iIndex[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11 }; + + for (int i = 0; i < lengthOf(mIndex); ++i) { + QQuickItem *delegate = findItem(contentItem, "delegate", mIndex[i]); + QVERIFY(delegate); + QCOMPARE(delegate->property("test1").toString(), model.list.at(mIndex[i])); + QCOMPARE(delegate->property("test2").toInt(), mIndex[i]); + QCOMPARE(delegate->property("test3").toInt(), iIndex[i]); + } + } { + evaluate(visualModel, "items.move(2, 4)"); + QCOMPARE(listview->count(), 12); + QCOMPARE(visualModel->items()->count(), 12); + static const int mIndex[] = { 0, 1, 3, 4, 2, 5, 6, 7, 8, 9,10,11 }; + static const int iIndex[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11 }; + + for (int i = 0; i < lengthOf(mIndex); ++i) { + QQuickItem *delegate = findItem(contentItem, "delegate", mIndex[i]); + QVERIFY(delegate); + QCOMPARE(delegate->property("test1").toString(), model.list.at(mIndex[i])); + QCOMPARE(delegate->property("test2").toInt(), mIndex[i]); + QCOMPARE(delegate->property("test3").toInt(), iIndex[i]); + } + } { + evaluate(visualModel, "items.move(4, 2)"); + QCOMPARE(listview->count(), 12); + QCOMPARE(visualModel->items()->count(), 12); + static const int mIndex[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11 }; + static const int iIndex[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11 }; + + for (int i = 0; i < lengthOf(mIndex); ++i) { + QQuickItem *delegate = findItem(contentItem, "delegate", mIndex[i]); + QVERIFY(delegate); + QCOMPARE(delegate->property("test1").toString(), model.list.at(mIndex[i])); + QCOMPARE(delegate->property("test2").toInt(), mIndex[i]); + QCOMPARE(delegate->property("test3").toInt(), iIndex[i]); + } + } { + evaluate(visualModel, "items.move(8, 0, 4)"); + QCOMPARE(listview->count(), 12); + QCOMPARE(visualModel->items()->count(), 12); + static const int mIndex[] = { 8, 9,10,11, 0, 1, 2, 3, 4, 5, 6, 7 }; + static const int iIndex[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11 }; + + for (int i = 0; i < lengthOf(mIndex); ++i) { + QQuickItem *delegate = findItem(contentItem, "delegate", mIndex[i]); + QVERIFY(delegate); + QCOMPARE(delegate->property("test1").toString(), model.list.at(mIndex[i])); + QCOMPARE(delegate->property("test2").toInt(), mIndex[i]); + QCOMPARE(delegate->property("test3").toInt(), iIndex[i]); + } + } { + evaluate(visualModel, "items.move(3, 4, 5)"); + QCOMPARE(listview->count(), 12); + QCOMPARE(visualModel->items()->count(), 12); + static const int mIndex[] = { 8, 9,10,4, 11, 0, 1, 2, 3, 5, 6, 7 }; + static const int iIndex[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11 }; + + for (int i = 0; i < lengthOf(mIndex); ++i) { + QQuickItem *delegate = findItem(contentItem, "delegate", mIndex[i]); + QVERIFY(delegate); + QCOMPARE(delegate->property("test1").toString(), model.list.at(mIndex[i])); + QCOMPARE(delegate->property("test2").toInt(), mIndex[i]); + QCOMPARE(delegate->property("test3").toInt(), iIndex[i]); + } + } { + QTest::ignoreMessage(QtWarningMsg, ": QML VisualDataGroup: move: invalid count"); + evaluate(visualModel, "items.move(5, 2, -2)"); + QCOMPARE(listview->count(), 12); + QCOMPARE(visualModel->items()->count(), 12); + } { + QTest::ignoreMessage(QtWarningMsg, ": QML VisualDataGroup: move: from index out of range"); + evaluate(visualModel, "items.move(-6, 2, 1)"); + QCOMPARE(listview->count(), 12); + QCOMPARE(visualModel->items()->count(), 12); + } { + QTest::ignoreMessage(QtWarningMsg, ": QML VisualDataGroup: move: from index out of range"); + evaluate(visualModel, "items.move(15, 2, 1)"); + QCOMPARE(listview->count(), 12); + QCOMPARE(visualModel->items()->count(), 12); + } { + QTest::ignoreMessage(QtWarningMsg, ": QML VisualDataGroup: move: from index out of range"); + evaluate(visualModel, "items.move(11, 1, 3)"); + QCOMPARE(listview->count(), 12); + QCOMPARE(visualModel->items()->count(), 12); + } { + QTest::ignoreMessage(QtWarningMsg, ": QML VisualDataGroup: move: to index out of range"); + evaluate(visualModel, "items.move(2, -5, 1)"); + QCOMPARE(listview->count(), 12); + QCOMPARE(visualModel->items()->count(), 12); + } { + QTest::ignoreMessage(QtWarningMsg, ": QML VisualDataGroup: move: to index out of range"); + evaluate(visualModel, "items.move(2, 14, 1)"); + QCOMPARE(listview->count(), 12); + QCOMPARE(visualModel->items()->count(), 12); + } { + QTest::ignoreMessage(QtWarningMsg, ": QML VisualDataGroup: move: to index out of range"); + evaluate(visualModel, "items.move(2, 11, 4)"); + QCOMPARE(listview->count(), 12); + QCOMPARE(visualModel->items()->count(), 12); + } +} + +void tst_qquickvisualdatamodel::groups_data() +{ + QTest::addColumn("source"); + QTest::addColumn("part"); + + QTest::newRow("item delegate") + << testFileUrl("groups.qml") + << QString(); + QTest::newRow("package") + << testFileUrl("groups-package.qml") + << QString("visualModel.parts.package."); +} + +template void tst_qquickvisualdatamodel::groups_verify( + const SingleRoleModel &model, + QQuickItem *contentItem, + const int (&mIndex)[N], + const int (&iIndex)[N], + const int (&vIndex)[N], + const int (&sIndex)[N], + const bool (&vMember)[N], + const bool (&sMember)[N]) +{ + failed = true; + for (int i = 0; i < N; ++i) { + QQuickItem *delegate = findItem(contentItem, "delegate", mIndex[i]); + QVERIFY(delegate); + QCOMPARE(evaluate(delegate, "test1"), model.list.at(mIndex[i])); + QCOMPARE(evaluate(delegate, "test2") , mIndex[i]); + QCOMPARE(evaluate(delegate, "test3") , iIndex[i]); + QCOMPARE(evaluate(delegate, "test4"), true); + QCOMPARE(evaluate(delegate, "test5") , vIndex[i]); + QCOMPARE(evaluate(delegate, "test6"), vMember[i]); + QCOMPARE(evaluate(delegate, "test7") , sIndex[i]); + QCOMPARE(evaluate(delegate, "test8"), sMember[i]); + QCOMPARE(evaluate(delegate, "test9").contains("items") , bool(true)); + QCOMPARE(evaluate(delegate, "test9").contains("visible") , bool(vMember[i])); + QCOMPARE(evaluate(delegate, "test9").contains("selected"), bool(sMember[i])); + } + failed = false; +} + +#define VERIFY_GROUPS \ + groups_verify(model, contentItem, mIndex, iIndex, vIndex, sIndex, vMember, sMember); \ + QVERIFY(!failed) + + +void tst_qquickvisualdatamodel::groups() +{ + QFETCH(QUrl, source); + QFETCH(QString, part); + + QQuickView view; + + SingleRoleModel model; + model.list = QStringList() + << "one" + << "two" + << "three" + << "four" + << "five" + << "six" + << "seven" + << "eight" + << "nine" + << "ten" + << "eleven" + << "twelve"; + + QQmlContext *ctxt = view.rootContext(); + ctxt->setContextProperty("myModel", &model); + + view.setSource(source); + + QQuickListView *listview = qobject_cast(view.rootObject()); + QVERIFY(listview != 0); + + QQuickItem *contentItem = listview->contentItem(); + QVERIFY(contentItem != 0); + + QQuickVisualDataModel *visualModel = listview->findChild("visualModel"); + QVERIFY(visualModel); + + QQuickVisualDataGroup *visibleItems = listview->findChild("visibleItems"); + QVERIFY(visibleItems); + + QQuickVisualDataGroup *selectedItems = listview->findChild("selectedItems"); + QVERIFY(selectedItems); + + const bool f = false; + const bool t = true; + + { + QCOMPARE(listview->count(), 12); + QCOMPARE(visualModel->items()->count(), 12); + QCOMPARE(visibleItems->count(), 12); + QCOMPARE(selectedItems->count(), 0); + static const int mIndex [] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11 }; + static const int iIndex [] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11 }; + static const int vIndex [] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11 }; + static const bool vMember[] = { t, t, t, t, t, t, t, t, t, t, t, t }; + static const int sIndex [] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; + static const bool sMember[] = { f, f, f, f, f, f, f, f, f, f, f, f }; + VERIFY_GROUPS; + } { + evaluate(visualModel, "items.addGroups(8, \"selected\")"); + QCOMPARE(listview->count(), 12); + QCOMPARE(visualModel->items()->count(), 12); + QCOMPARE(visibleItems->count(), 12); + QCOMPARE(selectedItems->count(), 1); + static const int mIndex [] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11 }; + static const int iIndex [] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11 }; + static const int vIndex [] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11 }; + static const bool vMember[] = { t, t, t, t, t, t, t, t, t, t, t, t }; + static const int sIndex [] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1 }; + static const bool sMember[] = { f, f, f, f, f, f, f, f, t, f, f, f }; + VERIFY_GROUPS; + } { + evaluate(visualModel, "items.addGroups(6, 4, [\"visible\", \"selected\"])"); + QCOMPARE(listview->count(), 12); + QCOMPARE(visualModel->items()->count(), 12); + QCOMPARE(visibleItems->count(), 12); + QCOMPARE(selectedItems->count(), 4); + static const int mIndex [] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11 }; + static const int iIndex [] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11 }; + static const int vIndex [] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11 }; + static const bool vMember[] = { t, t, t, t, t, t, t, t, t, t, t, t }; + static const int sIndex [] = { 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 4, 4 }; + static const bool sMember[] = { f, f, f, f, f, f, t, t, t, t, f, f }; + VERIFY_GROUPS; + } { + evaluate(visualModel, "items.setGroups(2, [\"items\", \"selected\"])"); + QCOMPARE(listview->count(), 12); + QCOMPARE(visualModel->items()->count(), 12); + QCOMPARE(visibleItems->count(), 11); + QCOMPARE(selectedItems->count(), 5); + static const int mIndex [] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11 }; + static const int iIndex [] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11 }; + static const int vIndex [] = { 0, 1, 2, 2, 3, 4, 5, 6, 7, 8, 9,10 }; + static const bool vMember[] = { t, t, f, t, t, t, t, t, t, t, t, t }; + static const int sIndex [] = { 0, 0, 0, 1, 1, 1, 1, 2, 3, 4, 5, 5 }; + static const bool sMember[] = { f, f, t, f, f, f, t, t, t, t, f, f }; + VERIFY_GROUPS; + } { + evaluate(selectedItems, "setGroups(0, 3, \"items\")"); + QCOMPARE(listview->count(), 12); + QCOMPARE(visualModel->items()->count(), 12); + QCOMPARE(visibleItems->count(), 9); + QCOMPARE(selectedItems->count(), 2); + static const int mIndex [] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11 }; + static const int iIndex [] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11 }; + static const int vIndex [] = { 0, 1, 2, 2, 3, 4, 5, 5, 5, 6, 7, 8 }; + static const bool vMember[] = { t, t, f, t, t, t, f, f, t, t, t, t }; + static const int sIndex [] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 2 }; + static const bool sMember[] = { f, f, f, f, f, f, f, f, t, t, f, f }; + VERIFY_GROUPS; + } { + QTest::ignoreMessage(QtWarningMsg, ": QML VisualDataGroup: addGroups: invalid count"); + evaluate(visualModel, "items.addGroups(11, -4, \"items\")"); + QCOMPARE(listview->count(), 12); + QCOMPARE(visualModel->items()->count(), 12); + QCOMPARE(visibleItems->count(), 9); + QCOMPARE(selectedItems->count(), 2); + } { + QTest::ignoreMessage(QtWarningMsg, ": QML VisualDataGroup: addGroups: index out of range"); + evaluate(visualModel, "items.addGroups(-1, 3, \"items\")"); + QCOMPARE(listview->count(), 12); + QCOMPARE(visualModel->items()->count(), 12); + QCOMPARE(visibleItems->count(), 9); + QCOMPARE(selectedItems->count(), 2); + } { + QTest::ignoreMessage(QtWarningMsg, ": QML VisualDataGroup: addGroups: index out of range"); + evaluate(visualModel, "items.addGroups(14, 3, \"items\")"); + QCOMPARE(listview->count(), 12); + QCOMPARE(visualModel->items()->count(), 12); + QCOMPARE(visibleItems->count(), 9); + QCOMPARE(selectedItems->count(), 2); + } { + QTest::ignoreMessage(QtWarningMsg, ": QML VisualDataGroup: addGroups: invalid count"); + evaluate(visualModel, "items.addGroups(11, 5, \"items\")"); + QCOMPARE(listview->count(), 12); + QCOMPARE(visualModel->items()->count(), 12); + QCOMPARE(visibleItems->count(), 9); + QCOMPARE(selectedItems->count(), 2); + } { + QTest::ignoreMessage(QtWarningMsg, ": QML VisualDataGroup: setGroups: invalid count"); + evaluate(visualModel, "items.setGroups(11, -4, \"items\")"); + QCOMPARE(listview->count(), 12); + QCOMPARE(visualModel->items()->count(), 12); + QCOMPARE(visibleItems->count(), 9); + QCOMPARE(selectedItems->count(), 2); + } { + QTest::ignoreMessage(QtWarningMsg, ": QML VisualDataGroup: setGroups: index out of range"); + evaluate(visualModel, "items.setGroups(-1, 3, \"items\")"); + QCOMPARE(listview->count(), 12); + QCOMPARE(visualModel->items()->count(), 12); + QCOMPARE(visibleItems->count(), 9); + QCOMPARE(selectedItems->count(), 2); + } { + QTest::ignoreMessage(QtWarningMsg, ": QML VisualDataGroup: setGroups: index out of range"); + evaluate(visualModel, "items.setGroups(14, 3, \"items\")"); + QCOMPARE(listview->count(), 12); + QCOMPARE(visualModel->items()->count(), 12); + QCOMPARE(visibleItems->count(), 9); + QCOMPARE(selectedItems->count(), 2); + } { + QTest::ignoreMessage(QtWarningMsg, ": QML VisualDataGroup: setGroups: invalid count"); + evaluate(visualModel, "items.setGroups(11, 5, \"items\")"); + QCOMPARE(listview->count(), 12); + QCOMPARE(visualModel->items()->count(), 12); + QCOMPARE(visibleItems->count(), 9); + QCOMPARE(selectedItems->count(), 2); + } { + QTest::ignoreMessage(QtWarningMsg, ": QML VisualDataGroup: removeGroups: invalid count"); + evaluate(visualModel, "items.removeGroups(11, -4, \"items\")"); + QCOMPARE(listview->count(), 12); + QCOMPARE(visualModel->items()->count(), 12); + } { + QTest::ignoreMessage(QtWarningMsg, ": QML VisualDataGroup: removeGroups: index out of range"); + evaluate(visualModel, "items.removeGroups(-1, 3, \"items\")"); + QCOMPARE(listview->count(), 12); + QCOMPARE(visualModel->items()->count(), 12); + QCOMPARE(visibleItems->count(), 9); + QCOMPARE(selectedItems->count(), 2); + } { + QTest::ignoreMessage(QtWarningMsg, ": QML VisualDataGroup: removeGroups: index out of range"); + evaluate(visualModel, "items.removeGroups(14, 3, \"items\")"); + QCOMPARE(listview->count(), 12); + QCOMPARE(visualModel->items()->count(), 12); + QCOMPARE(visibleItems->count(), 9); + QCOMPARE(selectedItems->count(), 2); + } { + QTest::ignoreMessage(QtWarningMsg, ": QML VisualDataGroup: removeGroups: invalid count"); + evaluate(visualModel, "items.removeGroups(11, 5, \"items\")"); + QCOMPARE(listview->count(), 12); + QCOMPARE(visualModel->items()->count(), 12); + QCOMPARE(visibleItems->count(), 9); + QCOMPARE(selectedItems->count(), 2); + } { + evaluate(visualModel, part + "filterOnGroup = \"visible\""); + QCOMPARE(listview->count(), 9); + QCOMPARE(visualModel->items()->count(), 12); + QCOMPARE(visibleItems->count(), 9); + QCOMPARE(selectedItems->count(), 2); + QCOMPARE(evaluate(visualModel, part + "filterOnGroup"), QString("visible")); + } { + evaluate(visualModel, part + "filterOnGroup = \"selected\""); + QCOMPARE(listview->count(), 2); + QCOMPARE(visualModel->items()->count(), 12); + QCOMPARE(visibleItems->count(), 9); + QCOMPARE(selectedItems->count(), 2); + QCOMPARE(evaluate(visualModel, part + "filterOnGroup"), QString("selected")); + } { + evaluate(visualModel, part + "filterOnGroup = undefined"); + QCOMPARE(listview->count(), 12); + QCOMPARE(visualModel->items()->count(), 12); + QCOMPARE(visibleItems->count(), 9); + QCOMPARE(selectedItems->count(), 2); + QCOMPARE(evaluate(visualModel, part + "filterOnGroup"), QString("items")); + } { + QQuickItem *delegate = findItem(contentItem, "delegate", 5); + QVERIFY(delegate); + + evaluate(delegate, "hide()"); + QCOMPARE(listview->count(), 12); + QCOMPARE(visualModel->items()->count(), 12); + QCOMPARE(visibleItems->count(), 8); + QCOMPARE(selectedItems->count(), 2); + static const int mIndex [] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11 }; + static const int iIndex [] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11 }; + static const int vIndex [] = { 0, 1, 2, 2, 3, 4, 4, 4, 4, 5, 6, 7 }; + static const bool vMember[] = { t, t, f, t, t, f, f, f, t, t, t, t }; + static const int sIndex [] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 2 }; + static const bool sMember[] = { f, f, f, f, f, f, f, f, t, t, f, f }; + VERIFY_GROUPS; + } { + QQuickItem *delegate = findItem(contentItem, "delegate", 5); + QVERIFY(delegate); + + evaluate(delegate, "select()"); + QCOMPARE(listview->count(), 12); + QCOMPARE(visualModel->items()->count(), 12); + QCOMPARE(visibleItems->count(), 8); + QCOMPARE(selectedItems->count(), 3); + static const int mIndex [] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11 }; + static const int iIndex [] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11 }; + static const int vIndex [] = { 0, 1, 2, 2, 3, 4, 4, 4, 4, 5, 6, 7 }; + static const bool vMember[] = { t, t, f, t, t, f, f, f, t, t, t, t }; + static const int sIndex [] = { 0, 0, 0, 0, 0, 0, 1, 1, 1, 2, 3, 3 }; + static const bool sMember[] = { f, f, f, f, f, t, f, f, t, t, f, f }; + VERIFY_GROUPS; + } { + evaluate(visualModel, "items.move(2, 6, 3)"); + QCOMPARE(listview->count(), 12); + QCOMPARE(visualModel->items()->count(), 12); + QCOMPARE(visibleItems->count(), 8); + QCOMPARE(selectedItems->count(), 3); + static const int mIndex [] = { 0, 1, 5, 6, 7, 8, 2, 3, 4, 9,10,11 }; + static const int iIndex [] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11 }; + static const int vIndex [] = { 0, 1, 2, 2, 2, 2, 3, 3, 4, 5, 6, 7 }; + static const bool vMember[] = { t, t, f, f, f, t, f, t, t, t, t, t }; + static const int sIndex [] = { 0, 0, 0, 1, 1, 1, 2, 2, 2, 2, 3, 3 }; + static const bool sMember[] = { f, f, t, f, f, t, f, f, f, t, f, f }; + VERIFY_GROUPS; + } +} + +template void tst_qquickvisualdatamodel::get_verify( + const SingleRoleModel &model, + QQuickVisualDataModel *visualModel, + QQuickVisualDataGroup *visibleItems, + QQuickVisualDataGroup *selectedItems, + const int (&mIndex)[N], + const int (&iIndex)[N], + const int (&vIndex)[N], + const int (&sIndex)[N], + const bool (&vMember)[N], + const bool (&sMember)[N]) +{ + failed = true; + for (int i = 0; i < N; ++i) { + QCOMPARE(evaluate(visualModel, QString("items.get(%1).model.name").arg(i)), model.list.at(mIndex[i])); + QCOMPARE(evaluate(visualModel, QString("items.get(%1).model.modelData").arg(i)), model.list.at(mIndex[i])); + QCOMPARE(evaluate(visualModel, QString("items.get(%1).model.index").arg(i)), mIndex[i]); + QCOMPARE(evaluate(visualModel, QString("items.get(%1).itemsIndex").arg(i)), iIndex[i]); + QCOMPARE(evaluate(visualModel, QString("items.get(%1).inItems").arg(i)), true); + QCOMPARE(evaluate(visualModel, QString("items.get(%1).visibleIndex").arg(i)), vIndex[i]); + QCOMPARE(evaluate(visualModel, QString("items.get(%1).inVisible").arg(i)), vMember[i]); + QCOMPARE(evaluate(visualModel, QString("items.get(%1).selectedIndex").arg(i)), sIndex[i]); + QCOMPARE(evaluate(visualModel, QString("items.get(%1).inSelected").arg(i)), sMember[i]); + QCOMPARE(evaluate(visualModel, QString("contains(items.get(%1).groups, \"items\")").arg(i)), true); + QCOMPARE(evaluate(visualModel, QString("contains(items.get(%1).groups, \"visible\")").arg(i)), vMember[i]); + QCOMPARE(evaluate(visualModel, QString("contains(items.get(%1).groups, \"selected\")").arg(i)), sMember[i]); + + if (vMember[i]) { + QCOMPARE(evaluate(visibleItems, QString("get(%1).model.name").arg(vIndex[i])), model.list.at(mIndex[i])); + QCOMPARE(evaluate(visibleItems, QString("get(%1).model.modelData").arg(vIndex[i])), model.list.at(mIndex[i])); + QCOMPARE(evaluate(visibleItems, QString("get(%1).model.index").arg(vIndex[i])), mIndex[i]); + QCOMPARE(evaluate(visibleItems, QString("get(%1).itemsIndex").arg(vIndex[i])), iIndex[i]); + QCOMPARE(evaluate(visibleItems, QString("get(%1).inItems").arg(vIndex[i])), true); + QCOMPARE(evaluate(visibleItems, QString("get(%1).visibleIndex").arg(vIndex[i])), vIndex[i]); + QCOMPARE(evaluate(visibleItems, QString("get(%1).inVisible").arg(vIndex[i])), vMember[i]); + QCOMPARE(evaluate(visibleItems, QString("get(%1).selectedIndex").arg(vIndex[i])), sIndex[i]); + QCOMPARE(evaluate(visibleItems, QString("get(%1).inSelected").arg(vIndex[i])), sMember[i]); + + QCOMPARE(evaluate(visibleItems, QString("contains(get(%1).groups, \"items\")").arg(vIndex[i])), true); + QCOMPARE(evaluate(visibleItems, QString("contains(get(%1).groups, \"visible\")").arg(vIndex[i])), vMember[i]); + QCOMPARE(evaluate(visibleItems, QString("contains(get(%1).groups, \"selected\")").arg(vIndex[i])), sMember[i]); + } + if (sMember[i]) { + QCOMPARE(evaluate(selectedItems, QString("get(%1).model.name").arg(sIndex[i])), model.list.at(mIndex[i])); + QCOMPARE(evaluate(selectedItems, QString("get(%1).model.modelData").arg(sIndex[i])), model.list.at(mIndex[i])); + QCOMPARE(evaluate(selectedItems, QString("get(%1).model.index").arg(sIndex[i])), mIndex[i]); + QCOMPARE(evaluate(selectedItems, QString("get(%1).itemsIndex").arg(sIndex[i])), iIndex[i]); + QCOMPARE(evaluate(selectedItems, QString("get(%1).inItems").arg(sIndex[i])), true); + QCOMPARE(evaluate(selectedItems, QString("get(%1).visibleIndex").arg(sIndex[i])), vIndex[i]); + QCOMPARE(evaluate(selectedItems, QString("get(%1).inVisible").arg(sIndex[i])), vMember[i]); + QCOMPARE(evaluate(selectedItems, QString("get(%1).selectedIndex").arg(sIndex[i])), sIndex[i]); + QCOMPARE(evaluate(selectedItems, QString("get(%1).inSelected").arg(sIndex[i])), sMember[i]); + QCOMPARE(evaluate(selectedItems, QString("contains(get(%1).groups, \"items\")").arg(sIndex[i])), true); + QCOMPARE(evaluate(selectedItems, QString("contains(get(%1).groups, \"visible\")").arg(sIndex[i])), vMember[i]); + QCOMPARE(evaluate(selectedItems, QString("contains(get(%1).groups, \"selected\")").arg(sIndex[i])), sMember[i]); + } + } + failed = false; +} + +#define VERIFY_GET \ + get_verify(model, visualModel, visibleItems, selectedItems, mIndex, iIndex, vIndex, sIndex, vMember, sMember); \ + QVERIFY(!failed) + +void tst_qquickvisualdatamodel::get() +{ + QQuickView view; + + SingleRoleModel model; + model.list = QStringList() + << "one" + << "two" + << "three" + << "four" + << "five" + << "six" + << "seven" + << "eight" + << "nine" + << "ten" + << "eleven" + << "twelve"; + + QQmlContext *ctxt = view.rootContext(); + ctxt->setContextProperty("myModel", &model); + + view.setSource(testFileUrl("groups.qml")); + + QQuickListView *listview = qobject_cast(view.rootObject()); + QVERIFY(listview != 0); + + QQuickItem *contentItem = listview->contentItem(); + QVERIFY(contentItem != 0); + + QQuickVisualDataModel *visualModel = qobject_cast(qvariant_cast(listview->model())); + QVERIFY(visualModel); + + QQuickVisualDataGroup *visibleItems = visualModel->findChild("visibleItems"); + QVERIFY(visibleItems); + + QQuickVisualDataGroup *selectedItems = visualModel->findChild("selectedItems"); + QVERIFY(selectedItems); + + QV8Engine *v8Engine = QQmlEnginePrivate::getV8Engine(ctxt->engine()); + QVERIFY(v8Engine); + + const bool f = false; + const bool t = true; + + { + QCOMPARE(listview->count(), 12); + QCOMPARE(visualModel->items()->count(), 12); + QCOMPARE(visibleItems->count(), 12); + QCOMPARE(selectedItems->count(), 0); + static const int mIndex [] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11 }; + static const int iIndex [] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11 }; + static const int vIndex [] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11 }; + static const bool vMember[] = { t, t, t, t, t, t, t, t, t, t, t, t }; + static const int sIndex [] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; + static const bool sMember[] = { f, f, f, f, f, f, f, f, f, f, f, f }; + VERIFY_GET; + } { + evaluate(visualModel, "items.addGroups(8, \"selected\")"); + QCOMPARE(listview->count(), 12); + QCOMPARE(visualModel->items()->count(), 12); + QCOMPARE(visibleItems->count(), 12); + QCOMPARE(selectedItems->count(), 1); + static const int mIndex [] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11 }; + static const int iIndex [] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11 }; + static const int vIndex [] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11 }; + static const bool vMember[] = { t, t, t, t, t, t, t, t, t, t, t, t }; + static const int sIndex [] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1 }; + static const bool sMember[] = { f, f, f, f, f, f, f, f, t, f, f, f }; + VERIFY_GET; + } { + evaluate(visualModel, "items.addGroups(6, 4, [\"visible\", \"selected\"])"); + QCOMPARE(listview->count(), 12); + QCOMPARE(visualModel->items()->count(), 12); + QCOMPARE(visibleItems->count(), 12); + QCOMPARE(selectedItems->count(), 4); + static const int mIndex [] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11 }; + static const int iIndex [] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11 }; + static const int vIndex [] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11 }; + static const bool vMember[] = { t, t, t, t, t, t, t, t, t, t, t, t }; + static const int sIndex [] = { 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 4, 4 }; + static const bool sMember[] = { f, f, f, f, f, f, t, t, t, t, f, f }; + VERIFY_GET; + } { + evaluate(visualModel, "items.setGroups(2, [\"items\", \"selected\"])"); + QCOMPARE(listview->count(), 12); + QCOMPARE(visualModel->items()->count(), 12); + QCOMPARE(visibleItems->count(), 11); + QCOMPARE(selectedItems->count(), 5); + static const int mIndex [] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11 }; + static const int iIndex [] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11 }; + static const int vIndex [] = { 0, 1, 2, 2, 3, 4, 5, 6, 7, 8, 9,10 }; + static const bool vMember[] = { t, t, f, t, t, t, t, t, t, t, t, t }; + static const int sIndex [] = { 0, 0, 0, 1, 1, 1, 1, 2, 3, 4, 5, 5 }; + static const bool sMember[] = { f, f, t, f, f, f, t, t, t, t, f, f }; + VERIFY_GET; + } { + evaluate(selectedItems, "setGroups(0, 3, \"items\")"); + QCOMPARE(listview->count(), 12); + QCOMPARE(visualModel->items()->count(), 12); + QCOMPARE(visibleItems->count(), 9); + QCOMPARE(selectedItems->count(), 2); + static const int mIndex [] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11 }; + static const int iIndex [] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11 }; + static const int vIndex [] = { 0, 1, 2, 2, 3, 4, 5, 5, 5, 6, 7, 8 }; + static const bool vMember[] = { t, t, f, t, t, t, f, f, t, t, t, t }; + static const int sIndex [] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 2 }; + static const bool sMember[] = { f, f, f, f, f, f, f, f, t, t, f, f }; + VERIFY_GET; + } { + evaluate(visualModel, "items.get(5).inVisible = false"); + QCOMPARE(listview->count(), 12); + QCOMPARE(visualModel->items()->count(), 12); + QCOMPARE(visibleItems->count(), 8); + QCOMPARE(selectedItems->count(), 2); + static const int mIndex [] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11 }; + static const int iIndex [] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11 }; + static const int vIndex [] = { 0, 1, 2, 2, 3, 4, 4, 4, 4, 5, 6, 7 }; + static const bool vMember[] = { t, t, f, t, t, f, f, f, t, t, t, t }; + static const int sIndex [] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 2 }; + static const bool sMember[] = { f, f, f, f, f, f, f, f, t, t, f, f }; + VERIFY_GET; + } { + evaluate(visualModel, "items.get(5).inSelected = true"); + QCOMPARE(listview->count(), 12); + QCOMPARE(visualModel->items()->count(), 12); + QCOMPARE(visibleItems->count(), 8); + QCOMPARE(selectedItems->count(), 3); + static const int mIndex [] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11 }; + static const int iIndex [] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11 }; + static const int vIndex [] = { 0, 1, 2, 2, 3, 4, 4, 4, 4, 5, 6, 7 }; + static const bool vMember[] = { t, t, f, t, t, f, f, f, t, t, t, t }; + static const int sIndex [] = { 0, 0, 0, 0, 0, 0, 1, 1, 1, 2, 3, 3 }; + static const bool sMember[] = { f, f, f, f, f, t, f, f, t, t, f, f }; + VERIFY_GET; + } { + evaluate(visualModel, "items.get(5).groups = [\"visible\", \"items\"]"); + QCOMPARE(listview->count(), 12); + QCOMPARE(visualModel->items()->count(), 12); + QCOMPARE(visibleItems->count(), 9); + QCOMPARE(selectedItems->count(), 2); + static const int mIndex [] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11 }; + static const int iIndex [] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11 }; + static const int vIndex [] = { 0, 1, 2, 2, 3, 4, 5, 5, 5, 6, 7, 8 }; + static const bool vMember[] = { t, t, f, t, t, t, f, f, t, t, t, t }; + static const int sIndex [] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 2 }; + static const bool sMember[] = { f, f, f, f, f, f, f, f, t, t, f, f }; + VERIFY_GET; + } +} + +void tst_qquickvisualdatamodel::invalidGroups() +{ + QUrl source = testFileUrl("groups-invalid.qml"); + QTest::ignoreMessage(QtWarningMsg, (source.toString() + ":12:9: QML VisualDataGroup: " + QQuickVisualDataGroup::tr("Group names must start with a lower case letter")).toUtf8()); + + QQmlComponent component(&engine, source); + QScopedPointer object(component.create()); + QVERIFY(object); + + QCOMPARE(evaluate(object.data(), "groups.length"), 4); + QCOMPARE(evaluate(object.data(), "groups[0].name"), QString("items")); + QCOMPARE(evaluate(object.data(), "groups[1].name"), QString("persistedItems")); + QCOMPARE(evaluate(object.data(), "groups[2].name"), QString("visible")); + QCOMPARE(evaluate(object.data(), "groups[3].name"), QString("selected")); +} + +void tst_qquickvisualdatamodel::onChanged_data() +{ + QTest::addColumn("expression"); + QTest::addColumn("tests"); + + QTest::newRow("item appended") + << QString("listModel.append({\"number\": \"five\"})") + << (QStringList() + << "verify(vm.removed, [], [], [])" + << "verify(vm.inserted, [4], [1], [undefined])" + << "verify(vi.removed, [], [], [])" + << "verify(vi.inserted, [4], [1], [undefined])" + << "verify(si.removed, [], [], [])" + << "verify(si.inserted, [], [], [])"); + QTest::newRow("item prepended") + << QString("listModel.insert(0, {\"number\": \"five\"})") + << (QStringList() + << "verify(vm.removed, [], [], [])" + << "verify(vm.inserted, [0], [1], [undefined])" + << "verify(vi.removed, [], [], [])" + << "verify(vi.inserted, [0], [1], [undefined])" + << "verify(si.removed, [], [], [])" + << "verify(si.inserted, [], [], [])"); + QTest::newRow("item inserted") + << QString("listModel.insert(2, {\"number\": \"five\"})") + << (QStringList() + << "verify(vm.removed, [], [], [])" + << "verify(vm.inserted, [2], [1], [undefined])" + << "verify(vi.removed, [], [], [])" + << "verify(vi.inserted, [2], [1], [undefined])" + << "verify(si.removed, [], [], [])" + << "verify(si.inserted, [], [], [])"); + + QTest::newRow("item removed tail") + << QString("listModel.remove(3)") + << (QStringList() + << "verify(vm.removed, [3], [1], [undefined])" + << "verify(vm.inserted, [], [], [])" + << "verify(vi.removed, [3], [1], [undefined])" + << "verify(vi.inserted, [], [], [])" + << "verify(si.removed, [], [], [])" + << "verify(si.inserted, [], [], [])"); + QTest::newRow("item removed head") + << QString("listModel.remove(0)") + << (QStringList() + << "verify(vm.removed, [0], [1], [undefined])" + << "verify(vm.inserted, [], [], [])" + << "verify(vi.removed, [0], [1], [undefined])" + << "verify(vi.inserted, [], [], [])" + << "verify(si.removed, [], [], [])" + << "verify(si.inserted, [], [], [])"); + QTest::newRow("item removed middle") + << QString("listModel.remove(1)") + << (QStringList() + << "verify(vm.removed, [1], [1], [undefined])" + << "verify(vm.inserted, [], [], [])" + << "verify(vi.removed, [1], [1], [undefined])" + << "verify(vi.inserted, [], [], [])" + << "verify(si.removed, [], [], [])" + << "verify(si.inserted, [], [], [])"); + + + QTest::newRow("item moved from tail") + << QString("listModel.move(3, 0, 1)") + << (QStringList() + << "verify(vm.removed, [3], [1], [vm.inserted[0].moveId])" + << "verify(vm.inserted, [0], [1], [vm.removed[0].moveId])" + << "verify(vi.removed, [3], [1], [vi.inserted[0].moveId])" + << "verify(vi.inserted, [0], [1], [vi.removed[0].moveId])" + << "verify(si.removed, [], [], [])" + << "verify(si.inserted, [], [], [])"); + QTest::newRow("item moved from head") + << QString("listModel.move(0, 2, 2)") + << (QStringList() + << "verify(vm.removed, [0], [2], [vm.inserted[0].moveId])" + << "verify(vm.inserted, [2], [2], [vm.removed[0].moveId])" + << "verify(vi.removed, [0], [2], [vi.inserted[0].moveId])" + << "verify(vi.inserted, [2], [2], [vi.removed[0].moveId])" + << "verify(si.removed, [], [], [])" + << "verify(si.inserted, [], [], [])"); + + QTest::newRow("groups changed") + << QString("items.setGroups(1, 2, [\"items\", \"selected\"])") + << (QStringList() + << "verify(vm.inserted, [], [], [])" + << "verify(vm.removed, [], [], [])" + << "verify(vi.removed, [1], [2], [undefined])" + << "verify(vi.inserted, [], [], [])" + << "verify(si.removed, [], [], [])" + << "verify(si.inserted, [0], [2], [undefined])"); + + QTest::newRow("multiple removes") + << QString("{ vi.remove(1, 1); " + "vi.removeGroups(0, 2, \"items\") }") + << (QStringList() + << "verify(vm.removed, [0, 1], [1, 1], [undefined, undefined])" + << "verify(vm.inserted, [], [], [])" + << "verify(vi.removed, [1], [1], [undefined])" + << "verify(vi.inserted, [], [], [])" + << "verify(si.removed, [], [], [])" + << "verify(si.inserted, [], [], [])"); +} + +void tst_qquickvisualdatamodel::onChanged() +{ + QFETCH(QString, expression); + QFETCH(QStringList, tests); + + QQmlComponent component(&engine, testFileUrl("onChanged.qml")); + QScopedPointer object(component.create()); + QVERIFY(object); + + evaluate(object.data(), expression); + + foreach (const QString &test, tests) { + bool passed = evaluate(object.data(), test); + if (!passed) + qWarning() << test; + QVERIFY(passed); + } +} + +void tst_qquickvisualdatamodel::create() +{ + QQuickView view; + + SingleRoleModel model; + model.list = QStringList() + << "one" + << "two" + << "three" + << "four" + << "five" + << "six" + << "seven" + << "eight" + << "nine" + << "ten" + << "eleven" + << "twelve" + << "thirteen" + << "fourteen" + << "fifteen" + << "sixteen" + << "seventeen" + << "eighteen" + << "nineteen" + << "twenty"; + + QQmlContext *ctxt = view.rootContext(); + ctxt->setContextProperty("myModel", &model); + + view.setSource(testFileUrl("create.qml")); + + QQuickListView *listview = qobject_cast(view.rootObject()); + QVERIFY(listview != 0); + + QQuickItem *contentItem = listview->contentItem(); + QVERIFY(contentItem != 0); + + QQuickVisualDataModel *visualModel = qobject_cast(qvariant_cast(listview->model())); + QVERIFY(visualModel); + + QCOMPARE(listview->count(), 20); + + QQmlGuard delegate; + + // persistedItems.includeByDefault is true, so all items belong to persistedItems initially. + QVERIFY(delegate = findItem(contentItem, "delegate", 1)); + QCOMPARE(evaluate(delegate, "VisualDataModel.inPersistedItems"), true); + + // changing include by default doesn't remove persistance. + evaluate(visualModel, "persistedItems.includeByDefault = false"); + QCOMPARE(evaluate(delegate, "VisualDataModel.inPersistedItems"), true); + + // removing from persistedItems does. + evaluate(visualModel, "persistedItems.remove(0, 20)"); + QCOMPARE(listview->count(), 20); + QCOMPARE(evaluate(delegate, "VisualDataModel.inPersistedItems"), false); + + // Request an item instantiated by the view. + QVERIFY(delegate = qobject_cast(evaluate(visualModel, "items.create(1)"))); + QCOMPARE(delegate.data(), findItem(contentItem, "delegate", 1)); + QCOMPARE(evaluate(delegate, "VisualDataModel.inPersistedItems"), true); + QCOMPARE(evaluate(visualModel, "persistedItems.count"), 1); + + evaluate(delegate, "VisualDataModel.inPersistedItems = false"); + QCOMPARE(listview->count(), 20); + QCoreApplication::sendPostedEvents(delegate, QEvent::DeferredDelete); + QVERIFY(delegate); + QCOMPARE(evaluate(delegate, "VisualDataModel.inPersistedItems"), false); + QCOMPARE(evaluate(visualModel, "persistedItems.count"), 0); + + // Request an item not instantiated by the view. + QVERIFY(!findItem(contentItem, "delegate", 15)); + QVERIFY(delegate = qobject_cast(evaluate(visualModel, "items.create(15)"))); + QCOMPARE(delegate.data(), findItem(contentItem, "delegate", 15)); + QCOMPARE(evaluate(delegate, "VisualDataModel.inPersistedItems"), true); + QCOMPARE(evaluate(visualModel, "persistedItems.count"), 1); + + evaluate(visualModel, "persistedItems.remove(0)"); + QCoreApplication::sendPostedEvents(delegate, QEvent::DeferredDelete); + QVERIFY(!delegate); + QCOMPARE(evaluate(visualModel, "persistedItems.count"), 0); + + // Request an item not instantiated by the view, then scroll the view so it will request it. + QVERIFY(!findItem(contentItem, "delegate", 16)); + QVERIFY(delegate = qobject_cast(evaluate(visualModel, "items.create(16)"))); + QCOMPARE(delegate.data(), findItem(contentItem, "delegate", 16)); + QCOMPARE(evaluate(delegate, "VisualDataModel.inPersistedItems"), true); + QCOMPARE(evaluate(visualModel, "persistedItems.count"), 1); + + evaluate(listview, "positionViewAtIndex(19, ListView.End)"); + QCOMPARE(listview->count(), 20); + evaluate(delegate, "VisualDataModel.groups = [\"items\"]"); + QCoreApplication::sendPostedEvents(delegate, QEvent::DeferredDelete); + QVERIFY(delegate); + QCOMPARE(evaluate(delegate, "VisualDataModel.inPersistedItems"), false); + QCOMPARE(evaluate(visualModel, "persistedItems.count"), 0); + + // Request and release an item instantiated by the view, then scroll the view so it releases it. + QVERIFY(findItem(contentItem, "delegate", 17)); + QVERIFY(delegate = qobject_cast(evaluate(visualModel, "items.create(17)"))); + QCOMPARE(delegate.data(), findItem(contentItem, "delegate", 17)); + QCOMPARE(evaluate(delegate, "VisualDataModel.inPersistedItems"), true); + QCOMPARE(evaluate(visualModel, "persistedItems.count"), 1); + + evaluate(visualModel, "items.removeGroups(17, \"persistedItems\")"); + QCoreApplication::sendPostedEvents(delegate, QEvent::DeferredDelete); + QVERIFY(delegate); + QCOMPARE(evaluate(delegate, "VisualDataModel.inPersistedItems"), false); + QCOMPARE(evaluate(visualModel, "persistedItems.count"), 0); + evaluate(listview, "positionViewAtIndex(1, ListView.Beginning)"); + QCOMPARE(listview->count(), 20); + QCoreApplication::sendPostedEvents(delegate, QEvent::DeferredDelete); + QVERIFY(!delegate); + + // Adding an item to the persistedItems group won't instantiate it, but if later requested by + // the view it will be persisted. + evaluate(visualModel, "items.addGroups(18, \"persistedItems\")"); + QCOMPARE(evaluate(visualModel, "persistedItems.count"), 1); + QVERIFY(!findItem(contentItem, "delegate", 18)); + evaluate(listview, "positionViewAtIndex(19, ListView.End)"); + QCOMPARE(listview->count(), 20); + QVERIFY(delegate = findItem(contentItem, "delegate", 18)); + QCOMPARE(evaluate(delegate, "VisualDataModel.inPersistedItems"), true); + QCoreApplication::sendPostedEvents(delegate, QEvent::DeferredDelete); + QVERIFY(delegate); + evaluate(listview, "positionViewAtIndex(1, ListView.Beginning)"); + QCOMPARE(listview->count(), 20); + QCoreApplication::sendPostedEvents(delegate, QEvent::DeferredDelete); + QVERIFY(delegate); + + // Remove an uninstantiated but cached item from the persistedItems group. + evaluate(visualModel, "items.addGroups(19, \"persistedItems\")"); + QCOMPARE(evaluate(visualModel, "persistedItems.count"), 2); + QVERIFY(!findItem(contentItem, "delegate", 19)); + // Store a reference to the item so it is retained in the cache. + evaluate(visualModel, "persistentHandle = items.get(19)"); + QCOMPARE(evaluate(visualModel, "persistentHandle.inPersistedItems"), true); + evaluate(visualModel, "items.removeGroups(19, \"persistedItems\")"); + QCOMPARE(evaluate(visualModel, "persistentHandle.inPersistedItems"), false); +} + +void tst_qquickvisualdatamodel::incompleteModel() +{ + // VisualDataModel is first populated in componentComplete. Verify various functions are + // harmlessly ignored until then. + + QQmlComponent component(&engine); + component.setData("import QtQuick 2.0\n VisualDataModel {}", testFileUrl("")); + + QScopedPointer object(component.beginCreate(engine.rootContext())); + + QQuickVisualDataModel *model = qobject_cast(object.data()); + QVERIFY(model); + + QSignalSpy itemsSpy(model->items(), SIGNAL(countChanged())); + QSignalSpy persistedItemsSpy(model->items(), SIGNAL(countChanged())); + + evaluate(model, "items.removeGroups(0, items.count, \"items\")"); + QCOMPARE(itemsSpy.count(), 0); + QCOMPARE(persistedItemsSpy.count(), 0); + + evaluate(model, "items.setGroups(0, items.count, \"persistedItems\")"); + QCOMPARE(itemsSpy.count(), 0); + QCOMPARE(persistedItemsSpy.count(), 0); + + evaluate(model, "items.addGroups(0, items.count, \"persistedItems\")"); + QCOMPARE(itemsSpy.count(), 0); + QCOMPARE(persistedItemsSpy.count(), 0); + + evaluate(model, "items.remove(0, items.count)"); + QCOMPARE(itemsSpy.count(), 0); + QCOMPARE(persistedItemsSpy.count(), 0); + + evaluate(model, "items.insert([ \"color\": \"blue\" ])"); + QCOMPARE(itemsSpy.count(), 0); + QCOMPARE(persistedItemsSpy.count(), 0); + + QTest::ignoreMessage(QtWarningMsg, ": QML VisualDataGroup: get: index out of range"); + QVERIFY(evaluate(model, "items.get(0) === undefined")); + + component.completeCreate(); +} + +void tst_qquickvisualdatamodel::insert_data() +{ + QTest::addColumn("source"); + QTest::addColumn("expression"); + QTest::addColumn("modelCount"); + QTest::addColumn("visualCount"); + QTest::addColumn("index"); + QTest::addColumn("inItems"); + QTest::addColumn("persisted"); + QTest::addColumn("visible"); + QTest::addColumn("selected"); + QTest::addColumn("modelData"); + QTest::addColumn("property"); + QTest::addColumn("propertyData"); + + const QUrl listModelSource[] = { + testFileUrl("listmodelproperties.qml"), + testFileUrl("listmodelproperties-package.qml") }; + const QUrl singleRoleSource[] = { + testFileUrl("singleroleproperties.qml"), + testFileUrl("singleroleproperties-package.qml") }; + const QUrl multipleRoleSource[] = { + testFileUrl("multipleroleproperties.qml"), + testFileUrl("multipleroleproperties-package.qml") }; + const QUrl stringListSource[] = { + testFileUrl("stringlistproperties.qml"), + testFileUrl("stringlistproperties-package.qml") }; + const QUrl objectListSource[] = { + testFileUrl("objectlistproperties.qml"), + testFileUrl("objectlistproperties-package.qml") }; + + for (int i = 0; i < 2; ++i) { + // List Model. + QTest::newRow("ListModel.items prepend") + << listModelSource[i] + << QString("items.insert(0, {\"number\": \"eight\"})") + << 4 << 5 << 0 << true << false << false << false << true + << QString("number") + << (QStringList() << "eight" << "one" << "two" << "three" << "four"); + + QTest::newRow("ListModel.items append") + << listModelSource[i] + << QString("items.insert({\"number\": \"eight\"})") + << 4 << 5 << 4 << true << false << false << false << true + << QString("number") + << (QStringList() << "one" << "two" << "three" << "four" << "eight"); + + QTest::newRow("ListModel.items insert at 2") + << listModelSource[i] + << QString("items.insert(2, {\"number\": \"eight\"})") + << 4 << 5 << 2 << true << false << false << false << true + << QString("number") + << (QStringList() << "one" << "two" << "eight" << "three" << "four"); + + QTest::newRow("ListModel.items insert at items.get(2)") + << listModelSource[i] + << QString("items.insert(items.get(2), {\"number\": \"eight\"})") + << 4 << 5 << 2 << true << false << false << false << true + << QString("number") + << (QStringList() << "one" << "two" << "eight" << "three" << "four"); + + QTest::newRow("ListModel.items insert at visibleItems.get(2)") + << listModelSource[i] + << QString("items.insert(visibleItems.get(2), {\"number\": \"eight\"})") + << 4 << 5 << 2 << true << false << false << false << true + << QString("number") + << (QStringList() << "one" << "two" << "eight" << "three" << "four"); + + QTest::newRow("ListModel.selectedItems insert at items.get(2)") + << listModelSource[i] + << QString("selectedItems.insert(items.get(2), {\"number\": \"eight\"})") + << 4 << 5 << 2 << false << false << false << true << true + << QString("number") + << (QStringList() << "one" << "two" << "eight" << "three" << "four"); + + QTest::newRow("ListModel.selectedItems insert at visibleItems.get(2)") + << listModelSource[i] + << QString("selectedItems.insert(visibleItems.get(2), {\"number\": \"eight\"})") + << 4 << 5 << 2 << false << false << false << true << true + << QString("number") + << (QStringList() << "one" << "two" << "eight" << "three" << "four"); + + QTest::newRow("ListModel.items prepend modelData") + << listModelSource[i] + << QString("items.insert(0, {\"modelData\": \"eight\"})") + << 4 << 5 << 0 << true << false << false << false << true + << QString("number") + << (QStringList() << "eight" << "one" << "two" << "three" << "four"); + + QTest::newRow("ListModel.items prepend, edit number") + << listModelSource[i] + << QString("{ " + "items.insert(0, {\"number\": \"eight\"}); " + "items.get(0).model.number = \"seven\"; }") + << 4 << 5 << 0 << true << false << false << false << true + << QString("number") + << (QStringList() << "seven" << "one" << "two" << "three" << "four"); + + QTest::newRow("ListModel.items prepend, edit modelData") + << listModelSource[i] + << QString("{ " + "items.insert(0, {\"number\": \"eight\"}); " + "items.get(0).model.modelData = \"seven\"; }") + << 4 << 5 << 0 << true << false << false << false << true + << QString("number") + << (QStringList() << "seven" << "one" << "two" << "three" << "four"); + + QTest::newRow("ListModel.items prepend, edit resolved") + << listModelSource[i] + << QString("{ " + "items.insert(0, {\"number\": \"eight\"}); " + "items.get(2).model.number = \"seven\"; }") + << 4 << 5 << 0 << true << false << false << false << true + << QString("number") + << (QStringList() << "eight" << "one" << "two" << "three" << "four"); + + QTest::newRow("ListModel.items prepend with groups") + << listModelSource[i] + << QString("items.insert(0, {\"number\": \"eight\"}, [\"visible\", \"truncheon\"])") + << 4 << 5 << 0 << true << false << true << false << true + << QString("number") + << (QStringList() << "eight" << "one" << "two" << "three" << "four"); + + QTest::newRow("ListModel.items append with groups") + << listModelSource[i] + << QString("items.insert({\"number\": \"eight\"}, [\"visible\", \"selected\"])") + << 4 << 5 << 4 << true << false << true << true << true + << QString("number") + << (QStringList() << "one" << "two" << "three" << "four" << "eight"); + + QTest::newRow("ListModel.items insert at 2 with groups") + << listModelSource[i] + << QString("items.insert(2, {\"number\": \"eight\"}, \"visible\")") + << 4 << 5 << 2 << true << false << true << false << true + << QString("number") + << (QStringList() << "one" << "two" << "eight" << "three" << "four"); + + // create ListModel + QTest::newRow("ListModel.items prepend") + << listModelSource[i] + << QString("items.create(0, {\"number\": \"eight\"})") + << 4 << 5 << 0 << true << true << false << false << true + << QString("number") + << (QStringList() << "eight" << "one" << "two" << "three" << "four"); + + QTest::newRow("ListModel.items append") + << listModelSource[i] + << QString("items.create({\"number\": \"eight\"})") + << 4 << 5 << 4 << true << true << false << false << true + << QString("number") + << (QStringList() << "one" << "two" << "three" << "four" << "eight"); + + QTest::newRow("ListModel.items create at 2") + << listModelSource[i] + << QString("items.create(2, {\"number\": \"eight\"})") + << 4 << 5 << 2 << true << true << false << false << true + << QString("number") + << (QStringList() << "one" << "two" << "eight" << "three" << "four"); + + QTest::newRow("ListModel.items create at items.get(2)") + << listModelSource[i] + << QString("items.create(items.get(2), {\"number\": \"eight\"})") + << 4 << 5 << 2 << true << true << false << false << true + << QString("number") + << (QStringList() << "one" << "two" << "eight" << "three" << "four"); + + QTest::newRow("ListModel.items create at visibleItems.get(2)") + << listModelSource[i] + << QString("items.create(visibleItems.get(2), {\"number\": \"eight\"})") + << 4 << 5 << 2 << true << true << false << false << true + << QString("number") + << (QStringList() << "one" << "two" << "eight" << "three" << "four"); + + QTest::newRow("ListModel.selectedItems create at items.get(2)") + << listModelSource[i] + << QString("selectedItems.create(items.get(2), {\"number\": \"eight\"})") + << 4 << 5 << 2 << false << true << false << true << true + << QString("number") + << (QStringList() << "one" << "two" << "eight" << "three" << "four"); + + QTest::newRow("ListModel.selectedItems create at visibleItems.get(2)") + << listModelSource[i] + << QString("selectedItems.create(visibleItems.get(2), {\"number\": \"eight\"})") + << 4 << 5 << 2 << false << true << false << true << true + << QString("number") + << (QStringList() << "one" << "two" << "eight" << "three" << "four"); + + QTest::newRow("ListModel.items create prepended") + << listModelSource[i] + << QString("items.create(0, {\"number\": \"eight\"})") + << 4 << 5 << 0 << true << true << false << false << true + << QString("number") + << (QStringList() << "eight" << "one" << "two" << "three" << "four"); + + QTest::newRow("ListModel.items create appended") + << listModelSource[i] + << QString("items.create({\"number\": \"eight\"})") + << 4 << 5 << 4 << true << true << false << false << true + << QString("number") + << (QStringList() << "one" << "two" << "three" << "four" << "eight"); + + QTest::newRow("ListModel.items create at 2") + << listModelSource[i] + << QString("items.create(2, {\"number\": \"eight\"})") + << 4 << 5 << 2 << true << true << false << false << true + << QString("number") + << (QStringList() << "one" << "two" << "eight" << "three" << "four"); + + QTest::newRow("ListModel.items create at items.get(2)") + << listModelSource[i] + << QString("items.create(items.get(2), {\"number\": \"eight\"})") + << 4 << 5 << 2 << true << true << false << false << true + << QString("number") + << (QStringList() << "one" << "two" << "eight" << "three" << "four"); + + QTest::newRow("ListModel.items create at visibleItems.get(2)") + << listModelSource[i] + << QString("items.create(visibleItems.get(2), {\"number\": \"eight\"})") + << 4 << 5 << 2 << true << true << false << false << true + << QString("number") + << (QStringList() << "one" << "two" << "eight" << "three" << "four"); + + QTest::newRow("ListModel.create prepend modelData") + << listModelSource[i] + << QString("items.create(0, {\"modelData\": \"eight\"})") + << 4 << 5 << 0 << true << true << false << false << true + << QString("number") + << (QStringList() << "eight" << "one" << "two" << "three" << "four"); + + QTest::newRow("ListModel.items create prepended, edit number") + << listModelSource[i] + << QString("{ " + "var item = items.create(0, {\"number\": \"eight\"}); " + "item.setTest3(\"seven\"); }") + << 4 << 5 << 0 << true << true << false << false << true + << QString("number") + << (QStringList() << "seven" << "one" << "two" << "three" << "four"); + + QTest::newRow("ListModel.items create prepended, edit model.number") + << listModelSource[i] + << QString("{ " + "var item = items.create(0, {\"number\": \"eight\"}); " + "item.setTest4(\"seven\"); }") + << 4 << 5 << 0 << true << true << false << false << true + << QString("number") + << (QStringList() << "seven" << "one" << "two" << "three" << "four"); + + QTest::newRow("ListModel.items create prepended, edit modelData") + << listModelSource[i] + << QString("{ " + "var item = items.create(0, {\"number\": \"eight\"}); " + "item.setTest5(\"seven\"); }") + << 4 << 5 << 0 << true << true << false << false << true + << QString("number") + << (QStringList() << "seven" << "one" << "two" << "three" << "four"); + + QTest::newRow("ListModel.items create prepended, edit model.modelData") + << listModelSource[i] + << QString("{ " + "var item = items.create(0, {\"number\": \"eight\"}); " + "item.setTest6(\"seven\"); }") + << 4 << 5 << 0 << true << true << false << false << true + << QString("number") + << (QStringList() << "seven" << "one" << "two" << "three" << "four"); + + QTest::newRow("ListModel.items create prepended with groups") + << listModelSource[i] + << QString("items.create(0, {\"number\": \"eight\"}, [\"visible\", \"truncheon\"])") + << 4 << 5 << 0 << true << true << true << false << true + << QString("number") + << (QStringList() << "eight" << "one" << "two" << "three" << "four"); + + QTest::newRow("ListModel.items create appended with groups") + << listModelSource[i] + << QString("items.create({\"number\": \"eight\"}, [\"visible\", \"selected\"])") + << 4 << 5 << 4 << true << true << true << true << true + << QString("number") + << (QStringList() << "one" << "two" << "three" << "four" << "eight"); + + QTest::newRow("ListModel.items create inserted with groups") + << listModelSource[i] + << QString("items.create(2, {\"number\": \"eight\"}, \"visible\")") + << 4 << 5 << 2 << true << true << true << false << true + << QString("number") + << (QStringList() << "one" << "two" << "eight" << "three" << "four"); + + QTest::newRow("ListModel.items create prepended clear persistence") + << listModelSource[i] + << QString("{ items.create(0, {\"number\": \"eight\"}); " + "items.get(0).inPersistedItems = false }") + << 4 << 5 << 0 << true << false << false << false << true + << QString("number") + << (QStringList() << "eight" << "one" << "two" << "three" << "four"); + + QTest::newRow("ListModel.items create appended clear persistence") + << listModelSource[i] + << QString("{ items.create({\"number\": \"eight\"}); " + "items.get(4).inPersistedItems = false }") + << 4 << 5 << 4 << true << false << false << false << true + << QString("number") + << (QStringList() << "one" << "two" << "three" << "four" << "eight"); + + QTest::newRow("ListModel.items create inserted clear persistence") + << listModelSource[i] + << QString("{ items.create(2, {\"number\": \"eight\"}); " + "items.get(2).inPersistedItems = false }") + << 4 << 5 << 2 << true << false << false << false << true + << QString("number") + << (QStringList() << "one" << "two" << "eight" << "three" << "four"); + + // AbstractItemModel (Single Role). + QTest::newRow("AbstractItemModel.items prepend") + << singleRoleSource[i] + << QString("items.insert(0, {\"name\": \"eight\"})") + << 4 << 5 << 0 << true << false << false << false << true + << QString("name") + << (QStringList() << "eight" << "one" << "two" << "three" << "four"); + + QTest::newRow("AbstractItemModel.items append") + << singleRoleSource[i] + << QString("items.insert({\"name\": \"eight\"})") + << 4 << 5 << 4 << true << false << false << false << true + << QString("name") + << (QStringList() << "one" << "two" << "three" << "four" << "eight"); + + QTest::newRow("AbstractItemModel.items insert at 2") + << singleRoleSource[i] + << QString("items.insert(2, {\"name\": \"eight\"})") + << 4 << 5 << 2 << true << false << false << false << true + << QString("name") + << (QStringList() << "one" << "two" << "eight" << "three" << "four"); + + QTest::newRow("AbstractItemModel.items prepend modelData") + << singleRoleSource[i] + << QString("items.insert(0, {\"modelData\": \"eight\"})") + << 4 << 5 << 0 << true << false << false << false << true + << QString("name") + << (QStringList() << "eight" << "one" << "two" << "three" << "four"); + + QTest::newRow("AbstractItemModel.items prepend, edit name") + << singleRoleSource[i] + << QString("{ " + "items.insert(0, {\"name\": \"eight\"}); " + "items.get(0).model.name = \"seven\"; }") + << 4 << 5 << 0 << true << false << false << false << true + << QString("name") + << (QStringList() << "seven" << "one" << "two" << "three" << "four"); + + QTest::newRow("AbstractItemModel.items prepend, edit modelData") + << singleRoleSource[i] + << QString("{ " + "items.insert(0, {\"name\": \"eight\"}); " + "items.get(0).model.modelData = \"seven\"; }") + << 4 << 5 << 0 << true << false << false << false << true + << QString("name") + << (QStringList() << "seven" << "one" << "two" << "three" << "four"); + + QTest::newRow("AbstractItemModel.items prepend, edit resolved") + << singleRoleSource[i] + << QString("{ " + "items.insert(0, {\"name\": \"eight\"}); " + "items.get(2).model.name = \"seven\"; }") + << 4 << 5 << 0 << true << false << false << false << true + << QString("name") + << (QStringList() << "eight" << "one" << "two" << "three" << "four"); + + QTest::newRow("AbstractItemModel.create prepend modelData") + << singleRoleSource[i] + << QString("items.create(0, {\"modelData\": \"eight\"})") + << 4 << 5 << 0 << true << true << false << false << true + << QString("name") + << (QStringList() << "eight" << "one" << "two" << "three" << "four"); + + QTest::newRow("AbstractItemModel.items create prepended, edit name") + << singleRoleSource[i] + << QString("{ " + "var item = items.create(0, {\"name\": \"eight\"}); " + "item.setTest3(\"seven\"); }") + << 4 << 5 << 0 << true << true << false << false << true + << QString("name") + << (QStringList() << "seven" << "one" << "two" << "three" << "four"); + + QTest::newRow("AbstractItemModel.items create prepended, edit model.name") + << singleRoleSource[i] + << QString("{ " + "var item = items.create(0, {\"name\": \"eight\"}); " + "item.setTest4(\"seven\"); }") + << 4 << 5 << 0 << true << true << false << false << true + << QString("name") + << (QStringList() << "seven" << "one" << "two" << "three" << "four"); + + QTest::newRow("AbstractItemModel.items create prepended, edit modelData") + << singleRoleSource[i] + << QString("{ " + "var item = items.create(0, {\"name\": \"eight\"}); " + "item.setTest5(\"seven\"); }") + << 4 << 5 << 0 << true << true << false << false << true + << QString("name") + << (QStringList() << "seven" << "one" << "two" << "three" << "four"); + + QTest::newRow("AbstractItemModel.items create prepended, edit model.modelData") + << singleRoleSource[i] + << QString("{ " + "var item = items.create(0, {\"name\": \"eight\"}); " + "item.setTest6(\"seven\"); }") + << 4 << 5 << 0 << true << true << false << false << true + << QString("name") + << (QStringList() << "seven" << "one" << "two" << "three" << "four"); + + // AbstractItemModel (Multiple Roles). + QTest::newRow("StandardItemModel.items prepend") + << multipleRoleSource[i] + << QString("items.insert(0, {\"display\": \"Row 8 Item\"})") + << 4 << 5 << 0 << true << false << false << false << false + << QString("display") + << (QStringList() << "Row 8 Item" << "Row 1 Item" << "Row 2 Item" << "Row 3 Item" << "Row 4 Item"); + + QTest::newRow("StandardItemModel.items append") + << multipleRoleSource[i] + << QString("items.insert({\"display\": \"Row 8 Item\"})") + << 4 << 5 << 4 << true << false << false << false << false + << QString("display") + << (QStringList() << "Row 1 Item" << "Row 2 Item" << "Row 3 Item" << "Row 4 Item" << "Row 8 Item"); + + QTest::newRow("StandardItemModel.items insert at 2") + << multipleRoleSource[i] + << QString("items.insert(2, {\"display\": \"Row 8 Item\"})") + << 4 << 5 << 2 << true << false << false << false << false + << QString("display") + << (QStringList() << "Row 1 Item" << "Row 2 Item" << "Row 8 Item" << "Row 3 Item" << "Row 4 Item"); + + QTest::newRow("StandardItemModel.items prepend modelData") + << multipleRoleSource[i] + << QString("items.insert(0, {\"modelData\": \"Row 8 Item\"})") + << 4 << 5 << 0 << true << false << false << false << false + << QString("display") + << (QStringList() << QString() << "Row 1 Item" << "Row 2 Item" << "Row 3 Item" << "Row 4 Item"); + + QTest::newRow("StandardItemModel.items prepend, edit display") + << multipleRoleSource[i] + << QString("{ " + "items.insert(0, {\"display\": \"Row 8 Item\"}); " + "items.get(0).model.display = \"Row 7 Item\"; }") + << 4 << 5 << 0 << true << false << false << false << false + << QString("display") + << (QStringList() << "Row 7 Item" << "Row 1 Item" << "Row 2 Item" << "Row 3 Item" << "Row 4 Item"); + + QTest::newRow("StandardItemModel.items prepend, edit modelData") + << multipleRoleSource[i] + << QString("{ " + "items.insert(0, {\"display\": \"Row 8 Item\"}); " + "items.get(0).model.modelData = \"Row 7 Item\"; }") + << 4 << 5 << 0 << true << false << false << false << false + << QString("display") + << (QStringList() << "Row 8 Item" << "Row 1 Item" << "Row 2 Item" << "Row 3 Item" << "Row 4 Item"); + + QTest::newRow("StandardItemModel.items prepend, edit resolved") + << multipleRoleSource[i] + << QString("{ " + "items.insert(0, {\"display\": \"Row 8 Item\"}); " + "items.get(2).model.display = \"Row 7 Item\"; }") + << 4 << 5 << 0 << true << false << false << false << false + << QString("display") + << (QStringList() << "Row 8 Item" << "Row 1 Item" << "Row 2 Item" << "Row 3 Item" << "Row 4 Item"); + + QTest::newRow("StandardItemModel.create prepend modelData") + << multipleRoleSource[i] + << QString("items.create(0, {\"modelData\": \"Row 8 Item\"})") + << 4 << 5 << 0 << true << true << false << false << false + << QString("display") + << (QStringList() << QString() << "Row 1 Item" << "Row 2 Item" << "Row 3 Item" << "Row 4 Item"); + + QTest::newRow("StandardItemModel.items create prepended, edit display") + << multipleRoleSource[i] + << QString("{ " + "var item = items.create(0, {\"display\": \"Row 8 Item\"}); " + "item.setTest3(\"Row 7 Item\"); }") + << 4 << 5 << 0 << true << true << false << false << false + << QString("display") + << (QStringList() << "Row 7 Item" << "Row 1 Item" << "Row 2 Item" << "Row 3 Item" << "Row 4 Item"); + + QTest::newRow("StandardItemModel.items create prepended, edit model.display") + << multipleRoleSource[i] + << QString("{ " + "var item = items.create(0, {\"display\": \"Row 8 Item\"}); " + "item.setTest4(\"Row 7 Item\"); }") + << 4 << 5 << 0 << true << true << false << false << false + << QString("display") + << (QStringList() << "Row 7 Item" << "Row 1 Item" << "Row 2 Item" << "Row 3 Item" << "Row 4 Item"); + + // StringList. + QTest::newRow("StringList.items prepend") + << stringListSource[i] + << QString("items.insert(0, {\"modelData\": \"eight\"})") + << 4 << 5 << 0 << true << false << false << false << false + << QString("modelData") + << (QStringList() << "eight" << "one" << "two" << "three" << "four"); + + QTest::newRow("StringList.items append") + << stringListSource[i] + << QString("items.insert({\"modelData\": \"eight\"})") + << 4 << 5 << 4 << true << false << false << false << false + << QString("modelData") + << (QStringList() << "one" << "two" << "three" << "four" << "eight"); + + QTest::newRow("StringList.items insert at 2") + << stringListSource[i] + << QString("items.insert(2, {\"modelData\": \"eight\"})") + << 4 << 5 << 2 << true << false << false << false << false + << QString("modelData") + << (QStringList() << "one" << "two" << "eight" << "three" << "four"); + + QTest::newRow("StringList.items prepend, edit modelData") + << stringListSource[i] + << QString("{ " + "items.insert(0, {\"modelData\": \"eight\"}); " + "items.get(0).model.modelData = \"seven\"; }") + << 4 << 5 << 0 << true << false << false << false << false + << QString("modelData") + << (QStringList() << "seven" << "one" << "two" << "three" << "four"); + + QTest::newRow("StringList.items prepend, edit resolved") + << stringListSource[i] + << QString("{ " + "items.insert(0, {\"modelData\": \"eight\"}); " + "items.get(2).model.modelData = \"seven\"; }") + << 4 << 5 << 0 << true << false << false << false << false + << QString("modelData") + << (QStringList() << "eight" << "one" << "two" << "three" << "four"); + + QTest::newRow("StringList.create prepend modelData") + << stringListSource[i] + << QString("items.create(0, {\"modelData\": \"eight\"})") + << 4 << 5 << 0 << true << true << false << false << false + << QString("modelData") + << (QStringList() << "eight" << "one" << "two" << "three" << "four"); + + QTest::newRow("StringList.items create prepended, edit modelData") + << stringListSource[i] + << QString("{ " + "var item = items.create(0, {\"modelData\": \"eight\"}); " + "item.setTest3(\"seven\"); }") + << 4 << 5 << 0 << true << true << false << false << false + << QString("modelData") + << (QStringList() << "seven" << "one" << "two" << "three" << "four"); + + QTest::newRow("StringList.items create prepended, edit model.modelData") + << stringListSource[i] + << QString("{ " + "var item = items.create(0, {\"modelData\": \"eight\"}); " + "item.setTest4(\"seven\"); }") + << 4 << 5 << 0 << true << true << false << false << false + << QString("modelData") + << (QStringList() << "seven" << "one" << "two" << "three" << "four"); + + // ObjectList + QTest::newRow("ObjectList.items prepend") + << objectListSource[i] + << QString("items.insert(0, {\"name\": \"Item 8\"})") + << 4 << 4 << 4 << false << false << false << false << false + << QString("name") + << (QStringList() << "Item 1" << "Item 2" << "Item 3" << "Item 4"); + + QTest::newRow("ObjectList.items append") + << objectListSource[i] + << QString("items.insert({\"name\": \"Item 8\"})") + << 4 << 4 << 4 << false << false << false << false << false + << QString("name") + << (QStringList() << "Item 1" << "Item 2" << "Item 3" << "Item 4"); + + QTest::newRow("ObjectList.items insert at 2") + << objectListSource[i] + << QString("items.insert(2, {\"name\": \"Item 8\"})") + << 4 << 4 << 4 << false << false << false << false << false + << QString("name") + << (QStringList() << "Item 1" << "Item 2" << "Item 3" << "Item 4"); + } +} + +void tst_qquickvisualdatamodel::insert() +{ + QFETCH(QUrl, source); + QFETCH(QString, expression); + QFETCH(int, modelCount); + QFETCH(int, visualCount); + QFETCH(int, index); + QFETCH(bool, inItems); + QFETCH(bool, persisted); + QFETCH(bool, visible); + QFETCH(bool, selected); + QFETCH(bool, modelData); + QFETCH(QString, property); + QFETCH(QStringList, propertyData); + + QQuickCanvas canvas; + + QQmlComponent component(&engine); + component.loadUrl(source); + QScopedPointer object(component.create()); + QQuickListView *listView = qobject_cast(object.data()); + QVERIFY(listView); + listView->setParentItem(canvas.rootItem()); + + QQuickItem *contentItem = listView->contentItem(); + QVERIFY(contentItem); + + QObject *visualModel = listView->findChild("visualModel"); + QVERIFY(visualModel); + + evaluate(visualModel, expression); + + QCOMPARE(evaluate(listView, "count"), inItems ? visualCount : modelCount); + QCOMPARE(evaluate(visualModel, "count"), inItems ? visualCount : modelCount); + QCOMPARE(evaluate(visualModel, "items.count"), inItems ? visualCount : modelCount); + QCOMPARE(evaluate(visualModel, "persistedItems.count"), persisted ? 1 : 0); + QCOMPARE(evaluate(visualModel, "visibleItems.count"), visible ? visualCount : modelCount); + QCOMPARE(evaluate(visualModel, "selectedItems.count"), selected ? 1 : 0); + + QCOMPARE(propertyData.count(), visualCount); + for (int i = 0; i < visualCount; ++i) { + int modelIndex = i; + if (modelIndex > index) + modelIndex -= 1; + else if (modelIndex == index) + modelIndex = -1; + + const int itemsIndex = inItems || i <= index ? i : i - 1; + QString get; + + if (i != index) { + get = QString("items.get(%1)").arg(itemsIndex); + + QQuickItem *item = findItem(contentItem, "delegate", modelIndex); + QVERIFY(item); + + QCOMPARE(evaluate(item, "test1"), modelIndex); + QCOMPARE(evaluate(item, "test2"), modelIndex); + QCOMPARE(evaluate(item, "test3"), propertyData.at(i)); + QCOMPARE(evaluate(item, "test4"), propertyData.at(i)); + + if (modelData) { + QCOMPARE(evaluate(item, "test5"), propertyData.at(i)); + QCOMPARE(evaluate(item, "test6"), propertyData.at(i)); + } + + QCOMPARE(evaluate(item, "delegate.VisualDataModel.inItems"), true); + QCOMPARE(evaluate(item, "delegate.VisualDataModel.inPersistedItems"), false); + QCOMPARE(evaluate(item, "delegate.VisualDataModel.inVisible"), true); + QCOMPARE(evaluate(item, "delegate.VisualDataModel.inSelected"), false); + QCOMPARE(evaluate(item, "delegate.VisualDataModel.isUnresolved"), false); + + QCOMPARE(evaluate(item, "delegate.VisualDataModel.itemsIndex"), itemsIndex); + QCOMPARE(evaluate(item, "delegate.VisualDataModel.persistedItemsIndex"), persisted && i > index ? 1 : 0); + QCOMPARE(evaluate(item, "delegate.VisualDataModel.visibleIndex"), visible || i <= index ? i : i - 1); + QCOMPARE(evaluate(item, "delegate.VisualDataModel.selectedIndex"), selected && i > index ? 1 : 0); + } else if (inItems) { + get = QString("items.get(%1)").arg(index); + } else if (persisted) { + get = "persistedItems.get(0)"; + } else if (visible) { + get = QString("visibleItems.get(%1)").arg(index); + } else if (selected) { + get = "selectedItems.get(0)"; + } else { + continue; + } + + QCOMPARE(evaluate(visualModel, get + ".model.index"), modelIndex); + + QCOMPARE(evaluate(visualModel, get + ".model." + property), propertyData.at(i)); + + QCOMPARE(evaluate(visualModel, get + ".inItems"), inItems || i != index); + QCOMPARE(evaluate(visualModel, get + ".inPersistedItems"), persisted && i == index); + QCOMPARE(evaluate(visualModel, get + ".inVisible"), visible || i != index); + QCOMPARE(evaluate(visualModel, get + ".inSelected"), selected && i == index); + QCOMPARE(evaluate(visualModel, get + ".isUnresolved"), i == index); + + QCOMPARE(evaluate(visualModel, get + ".itemsIndex"), inItems || i <= index ? i : i - 1); + QCOMPARE(evaluate(visualModel, get + ".persistedItemsIndex"), persisted && i > index ? 1 : 0); + QCOMPARE(evaluate(visualModel, get + ".visibleIndex"), visible || i <= index ? i : i - 1); + QCOMPARE(evaluate(visualModel, get + ".selectedIndex"), selected && i > index ? 1 : 0); + } + + QObject *item = 0; + + if (inItems) + item = evaluate(visualModel, QString("items.create(%1)").arg(index)); + else if (persisted) + item = evaluate(visualModel, QString("persistedItems.create(%1)").arg(0)); + else if (visible) + item = evaluate(visualModel, QString("visibleItems.create(%1)").arg(index)); + else if (selected) + item = evaluate(visualModel, QString("selectedItems.create(%1)").arg(0)); + else + return; + + QVERIFY(item); + + QCOMPARE(evaluate(item, "test1"), -1); + QCOMPARE(evaluate(item, "test2"), -1); + QCOMPARE(evaluate(item, "test3"), propertyData.at(index)); + QCOMPARE(evaluate(item, "test4"), propertyData.at(index)); + + if (modelData) { + QCOMPARE(evaluate(item, "test5"), propertyData.at(index)); + QCOMPARE(evaluate(item, "test6"), propertyData.at(index)); + } + + QCOMPARE(evaluate(item, "delegate.VisualDataModel.inItems"), inItems); + QCOMPARE(evaluate(item, "delegate.VisualDataModel.inPersistedItems"), true); + QCOMPARE(evaluate(item, "delegate.VisualDataModel.inVisible"), visible); + QCOMPARE(evaluate(item, "delegate.VisualDataModel.inSelected"), selected); + QCOMPARE(evaluate(item, "delegate.VisualDataModel.isUnresolved"), true); + + QCOMPARE(evaluate(item, "delegate.VisualDataModel.itemsIndex"), index); + QCOMPARE(evaluate(item, "delegate.VisualDataModel.persistedItemsIndex"), 0); + QCOMPARE(evaluate(item, "delegate.VisualDataModel.visibleIndex"), index); + QCOMPARE(evaluate(item, "delegate.VisualDataModel.selectedIndex"), 0); +} + +void tst_qquickvisualdatamodel::resolve_data() +{ + QTest::addColumn("source"); + QTest::addColumn("setupExpression"); + QTest::addColumn("resolveExpression"); + QTest::addColumn("unresolvedCount"); + QTest::addColumn("modelCount"); + QTest::addColumn("visualCount"); + QTest::addColumn("index"); + QTest::addColumn("inItems"); + QTest::addColumn("persisted"); + QTest::addColumn("visible"); + QTest::addColumn("selected"); + QTest::addColumn("modelData"); + QTest::addColumn("property"); + QTest::addColumn("propertyData"); + + const QUrl listModelSource[] = { + testFileUrl("listmodelproperties.qml"), + testFileUrl("listmodelproperties-package.qml") }; + const QUrl singleRoleSource[] = { + testFileUrl("singleroleproperties.qml"), + testFileUrl("singleroleproperties-package.qml") }; + const QUrl multipleRoleSource[] = { + testFileUrl("multipleroleproperties.qml"), + testFileUrl("multipleroleproperties-package.qml") }; + const QUrl stringListSource[] = { + testFileUrl("stringlistproperties.qml"), + testFileUrl("stringlistproperties-package.qml") }; + const QUrl objectListSource[] = { + testFileUrl("objectlistproperties.qml"), + testFileUrl("objectlistproperties-package.qml") }; + + for (int i = 0; i < 2; ++i) { + // List Model. + QTest::newRow("ListModel.items prepend, resolve prepended") + << listModelSource[i] + << QString("items.insert(0, {\"number\": \"eight\"})") + << QString("{ listModel.insert(0, {\"number\": \"seven\"}); items.resolve(0, 1) }") + << 5 << 5 << 5 << 0 << true << false << true << false << true + << QString("number") + << (QStringList() << "seven" << "one" << "two" << "three" << "four"); + + QTest::newRow("ListModel.items prepend, resolve appended") + << listModelSource[i] + << QString("items.insert(0, {\"number\": \"eight\"})") + << QString("{ listModel.append({\"number\": \"seven\"}); items.resolve(0, 5) }") + << 5 << 5 << 5 << 4 << true << false << true << false << true + << QString("number") + << (QStringList() << "one" << "two" << "three" << "four" << "seven"); + + QTest::newRow("ListModel.items prepend, resolve inserted") + << listModelSource[i] + << QString("items.insert(0, {\"number\": \"eight\"})") + << QString("{ listModel.insert(2, {\"number\": \"seven\"}); items.resolve(0, 3) }") + << 5 << 5 << 5 << 2 << true << false << true << false << true + << QString("number") + << (QStringList() << "one" << "two" << "seven" << "three" << "four"); + + QTest::newRow("ListModel.items append, resolve prepended") + << listModelSource[i] + << QString("items.insert({\"number\": \"eight\"})") + << QString("{ listModel.insert(0, {\"number\": \"seven\"}); items.resolve(5, 0) }") + << 5 << 5 << 5 << 0 << true << false << true << false << true + << QString("number") + << (QStringList() << "seven" << "one" << "two" << "three" << "four"); + + QTest::newRow("ListModel.items append, resolve appended") + << listModelSource[i] + << QString("items.insert({\"number\": \"eight\"})") + << QString("{ listModel.append({\"number\": \"seven\"}); items.resolve(5, 4) }") + << 5 << 5 << 5 << 4 << true << false << true << false << true + << QString("number") + << (QStringList() << "one" << "two" << "three" << "four" << "seven"); + + QTest::newRow("ListModel.items append, resolve inserted") + << listModelSource[i] + << QString("items.insert({\"number\": \"eight\"})") + << QString("{ listModel.insert(2, {\"number\": \"seven\"}); items.resolve(5, 2) }") + << 5 << 5 << 5 << 2 << true << false << true << false << true + << QString("number") + << (QStringList() << "one" << "two" << "seven" << "three" << "four"); + + QTest::newRow("ListModel.items insert, resolve prepended") + << listModelSource[i] + << QString("items.insert(2, {\"number\": \"eight\"})") + << QString("{ listModel.insert(0, {\"number\": \"seven\"}); items.resolve(3, 0) }") + << 5 << 5 << 5 << 0 << true << false << true << false << true + << QString("number") + << (QStringList() << "seven" << "one" << "two" << "three" << "four"); + + QTest::newRow("ListModel.items insert, resolve appended") + << listModelSource[i] + << QString("items.insert(2, {\"number\": \"eight\"})") + << QString("{ listModel.append({\"number\": \"seven\"}); items.resolve(2, 5) }") + << 5 << 5 << 5 << 4 << true << false << true << false << true + << QString("number") + << (QStringList() << "one" << "two" << "three" << "four" << "seven"); + + QTest::newRow("ListModel.items insert, resolve inserted") + << listModelSource[i] + << QString("items.insert(2, {\"number\": \"eight\"})") + << QString("{ listModel.insert(2, {\"number\": \"seven\"}); items.resolve(2, 3) }") + << 5 << 5 << 5 << 2 << true << false << true << false << true + << QString("number") + << (QStringList() << "one" << "two" << "seven" << "three" << "four"); + + QTest::newRow("ListModel.items prepend, move resolved") + << listModelSource[i] + << QString("items.insert(0, {\"number\": \"eight\"})") + << QString("{ listModel.insert(0, {\"number\": \"seven\"}); " + "items.resolve(0, 1); " + "listModel.move(0, 2, 1) }") + << 5 << 5 << 5 << 2 << true << false << true << false << true + << QString("number") + << (QStringList() << "one" << "two" << "seven" << "three" << "four"); + + QTest::newRow("ListModel.items append, move resolved") + << listModelSource[i] + << QString("items.insert({\"number\": \"eight\"})") + << QString("{ listModel.append({\"number\": \"seven\"}); " + "items.resolve(5, 4); " + "listModel.move(4, 2, 1) }") + << 5 << 5 << 5 << 2 << true << false << true << false << true + << QString("number") + << (QStringList() << "one" << "two" << "seven" << "three" << "four"); + + QTest::newRow("ListModel.items insert, move resolved") + << listModelSource[i] + << QString("items.insert(2, {\"number\": \"eight\"})") + << QString("{ listModel.insert(2, {\"number\": \"seven\"}); " + "items.resolve(2, 3);" + "listModel.move(2, 0, 1) }") + << 5 << 5 << 5 << 0 << true << false << true << false << true + << QString("number") + << (QStringList() << "seven" << "one" << "two" << "three" << "four"); + + QTest::newRow("ListModel.items prepend, remove resolved") + << listModelSource[i] + << QString("items.insert(0, {\"number\": \"eight\"})") + << QString("{ listModel.insert(0, {\"number\": \"seven\"}); " + "items.resolve(0, 1); " + "listModel.remove(0, 1) }") + << 5 << 4 << 4 << 4 << false << false << false << false << true + << QString("number") + << (QStringList() << "one" << "two" << "three" << "four"); + + QTest::newRow("ListModel.items append, remove resolved") + << listModelSource[i] + << QString("items.insert({\"number\": \"eight\"})") + << QString("{ listModel.append({\"number\": \"seven\"}); " + "items.resolve(5, 4); " + "listModel.remove(4, 1) }") + << 5 << 4 << 4 << 4 << false << false << false << false << true + << QString("number") + << (QStringList() << "one" << "two" << "three" << "four"); + + QTest::newRow("ListModel.items insert, remove resolved") + << listModelSource[i] + << QString("items.insert(2, {\"number\": \"eight\"})") + << QString("{ listModel.insert(2, {\"number\": \"seven\"}); " + "items.resolve(2, 3);" + "listModel.remove(2, 1) }") + << 5 << 4 << 4 << 4 << false << false << false << false << true + << QString("number") + << (QStringList() << "one" << "two" << "three" << "four"); + + QTest::newRow("ListModel.selectedItems prepend, resolve prepended") + << listModelSource[i] + << QString("selectedItems.insert(0, {\"number\": \"eight\"})") + << QString("{ listModel.insert(0, {\"number\": \"seven\"}); " + "selectedItems.resolve(selectedItems.get(0), items.get(0)) }") + << 4 << 5 << 5 << 0 << true << false << true << true << true + << QString("number") + << (QStringList() << "seven" << "one" << "two" << "three" << "four"); + + QTest::newRow("ListModel.selectedItems prepend, resolve appended") + << listModelSource[i] + << QString("selectedItems.insert(0, {\"number\": \"eight\"})") + << QString("{ listModel.append({\"number\": \"seven\"}); " + "selectedItems.resolve(selectedItems.get(0), items.get(4)) }") + << 4 << 5 << 5 << 4 << true << false << true << true << true + << QString("number") + << (QStringList() << "one" << "two" << "three" << "four" << "seven"); + + QTest::newRow("ListModel.selectedItems prepend, resolve inserted") + << listModelSource[i] + << QString("selectedItems.insert(0, {\"number\": \"eight\"})") + << QString("{ listModel.insert(2, {\"number\": \"seven\"}); " + "selectedItems.resolve(selectedItems.get(0), items.get(2)) }") + << 4 << 5 << 5 << 2 << true << false << true << true << true + << QString("number") + << (QStringList() << "one" << "two" << "seven" << "three" << "four"); + + QTest::newRow("ListModel.selectedItems append, resolve prepended") + << listModelSource[i] + << QString("selectedItems.insert({\"number\": \"eight\"})") + << QString("{ listModel.insert(0, {\"number\": \"seven\"}); " + "selectedItems.resolve(selectedItems.get(0), items.get(0)) }") + << 4 << 5 << 5 << 0 << true << false << true << true << true + << QString("number") + << (QStringList() << "seven" << "one" << "two" << "three" << "four"); + + QTest::newRow("ListModel.selectedItems append, resolve appended") + << listModelSource[i] + << QString("selectedItems.insert({\"number\": \"eight\"})") + << QString("{ listModel.append({\"number\": \"seven\"}); " + "selectedItems.resolve(selectedItems.get(0), items.get(4)) }") + << 4 << 5 << 5 << 4 << true << false << true << true << true + << QString("number") + << (QStringList() << "one" << "two" << "three" << "four" << "seven"); + + QTest::newRow("ListModel.selectedItems append, resolve inserted") + << listModelSource[i] + << QString("selectedItems.insert({\"number\": \"eight\"})") + << QString("{ listModel.insert(2, {\"number\": \"seven\"}); " + "selectedItems.resolve(selectedItems.get(0), items.get(2)) }") + << 4 << 5 << 5 << 2 << true << false << true << true << true + << QString("number") + << (QStringList() << "one" << "two" << "seven" << "three" << "four"); + + // AbstractItemModel (Single Role) + QTest::newRow("ListModel.items prepend, resolve prepended") + << singleRoleSource[i] + << QString("items.insert(0, {\"name\": \"eight\"})") + << QString("{ items.resolve(0, 1) }") + << 5 << 4 << 4 << 0 << true << false << true << false << true + << QString("name") + << (QStringList() << "one" << "two" << "three" << "four"); + + + QTest::newRow("ListModel.items append, resolve appended") + << singleRoleSource[i] + << QString("items.insert({\"name\": \"eight\"})") + << QString("{ items.resolve(4, 3) }") + << 5 << 4 << 4 << 3 << true << false << true << false << true + << QString("name") + << (QStringList() << "one" << "two" << "three" << "four"); + + QTest::newRow("ListModel.items insert, resolve inserted") + << singleRoleSource[i] + << QString("items.insert(2, {\"name\": \"eight\"})") + << QString("{ items.resolve(2, 3) }") + << 5 << 4 << 4 << 2 << true << false << true << false << true + << QString("name") + << (QStringList() << "one" << "two" << "three" << "four"); + + // AbstractItemModel (Single Role) + QTest::newRow("AbstractItemModel.items prepend, resolve prepended") + << singleRoleSource[i] + << QString("items.insert(0, {\"name\": \"eight\"})") + << QString("{ items.resolve(0, 1) }") + << 5 << 4 << 4 << 0 << true << false << true << false << true + << QString("name") + << (QStringList() << "one" << "two" << "three" << "four"); + + QTest::newRow("AbstractItemModel.items append, resolve appended") + << singleRoleSource[i] + << QString("items.insert({\"name\": \"eight\"})") + << QString("{ items.resolve(4, 3) }") + << 5 << 4 << 4 << 3 << true << false << true << false << true + << QString("name") + << (QStringList() << "one" << "two" << "three" << "four"); + + QTest::newRow("AbstractItemModel.items insert, resolve inserted") + << singleRoleSource[i] + << QString("items.insert(2, {\"name\": \"eight\"})") + << QString("{ items.resolve(2, 3) }") + << 5 << 4 << 4 << 2 << true << false << true << false << true + << QString("name") + << (QStringList() << "one" << "two" << "three" << "four"); + + // AbstractItemModel (Multiple Roles) + QTest::newRow("StandardItemModel.items prepend, resolve prepended") + << multipleRoleSource[i] + << QString("items.insert(0, {\"display\": \"Row 8 Item\"})") + << QString("{ items.resolve(0, 1) }") + << 5 << 4 << 4 << 0 << true << false << true << false << false + << QString("display") + << (QStringList() << "Row 1 Item" << "Row 2 Item" << "Row 3 Item" << "Row 4 Item"); + + QTest::newRow("StandardItemModel.items append, resolve appended") + << multipleRoleSource[i] + << QString("items.insert({\"display\": \"Row 8 Item\"})") + << QString("{ items.resolve(4, 3) }") + << 5 << 4 << 4 << 3 << true << false << true << false << false + << QString("display") + << (QStringList() << "Row 1 Item" << "Row 2 Item" << "Row 3 Item" << "Row 4 Item"); + + QTest::newRow("StandardItemModel.items insert, resolve inserted") + << multipleRoleSource[i] + << QString("items.insert(2, {\"display\": \"Row 8 Item\"})") + << QString("{ items.resolve(2, 3) }") + << 5 << 4 << 4 << 2 << true << false << true << false << false + << QString("display") + << (QStringList() << "Row 1 Item" << "Row 2 Item" << "Row 3 Item" << "Row 4 Item"); + + // StringList + QTest::newRow("StringList.items prepend, resolve prepended") + << stringListSource[i] + << QString("items.insert(0, {\"modelData\": \"eight\"})") + << QString("{ items.resolve(0, 1) }") + << 5 << 4 << 4 << 0 << true << false << true << false << false + << QString("modelData") + << (QStringList() << "one" << "two" << "three" << "four"); + + QTest::newRow("StringList.items append, resolve appended") + << stringListSource[i] + << QString("items.insert({\"modelData\": \"eight\"})") + << QString("{ items.resolve(4, 3) }") + << 5 << 4 << 4 << 3 << true << false << true << false << false + << QString("modelData") + << (QStringList() << "one" << "two" << "three" << "four"); + + QTest::newRow("StringList.items insert, resolve inserted") + << stringListSource[i] + << QString("items.insert(2, {\"modelData\": \"eight\"})") + << QString("{ items.resolve(2, 3) }") + << 5 << 4 << 4 << 2 << true << false << true << false << false + << QString("modelData") + << (QStringList() << "one" << "two" << "three" << "four"); + } +} + +void tst_qquickvisualdatamodel::resolve() +{ + QFETCH(QUrl, source); + QFETCH(QString, setupExpression); + QFETCH(QString, resolveExpression); + QFETCH(int, unresolvedCount); + QFETCH(int, modelCount); + QFETCH(int, visualCount); + QFETCH(int, index); + QFETCH(bool, inItems); + QFETCH(bool, persisted); + QFETCH(bool, visible); + QFETCH(bool, selected); + QFETCH(bool, modelData); + QFETCH(QString, property); + QFETCH(QStringList, propertyData); + + QQuickCanvas canvas; + + QQmlComponent component(&engine); + component.loadUrl(source); + QScopedPointer object(component.create()); + QQuickListView *listView = qobject_cast(object.data()); + QVERIFY(listView); + listView->setParentItem(canvas.rootItem()); + + QQuickItem *contentItem = listView->contentItem(); + QVERIFY(contentItem); + + QObject *visualModel = listView->findChild("visualModel"); + QVERIFY(visualModel); + + evaluate(visualModel, setupExpression); + QCOMPARE(evaluate(listView, "count"), unresolvedCount); + + evaluate(visualModel, resolveExpression); + + QCOMPARE(evaluate(listView, "count"), inItems ? visualCount : modelCount); + QCOMPARE(evaluate(visualModel, "count"), inItems ? visualCount : modelCount); + QCOMPARE(evaluate(visualModel, "items.count"), inItems ? visualCount : modelCount); + QCOMPARE(evaluate(visualModel, "persistedItems.count"), persisted ? 1 : 0); + QCOMPARE(evaluate(visualModel, "visibleItems.count"), visible ? visualCount : modelCount); + QCOMPARE(evaluate(visualModel, "selectedItems.count"), selected ? 1 : 0); + + QCOMPARE(propertyData.count(), visualCount); + for (int i = 0; i < visualCount; ++i) { + int modelIndex = i; + + const int itemsIndex = inItems || i <= index ? i : i - 1; + QString get; + + if (i != index) { + get = QString("items.get(%1)").arg(itemsIndex); + + QQuickItem *item = findItem(contentItem, "delegate", modelIndex); + QVERIFY(item); + + QCOMPARE(evaluate(item, "test1"), modelIndex); + QCOMPARE(evaluate(item, "test2"), modelIndex); + QCOMPARE(evaluate(item, "test3"), propertyData.at(i)); + QCOMPARE(evaluate(item, "test4"), propertyData.at(i)); + + if (modelData) { + QCOMPARE(evaluate(item, "test5"), propertyData.at(i)); + QCOMPARE(evaluate(item, "test6"), propertyData.at(i)); + } + + QCOMPARE(evaluate(item, "delegate.VisualDataModel.inItems"), true); + QCOMPARE(evaluate(item, "delegate.VisualDataModel.inPersistedItems"), false); + QCOMPARE(evaluate(item, "delegate.VisualDataModel.inVisible"), true); + QCOMPARE(evaluate(item, "delegate.VisualDataModel.inSelected"), false); + QCOMPARE(evaluate(item, "delegate.VisualDataModel.isUnresolved"), false); + + QCOMPARE(evaluate(item, "delegate.VisualDataModel.itemsIndex"), itemsIndex); + QCOMPARE(evaluate(item, "delegate.VisualDataModel.persistedItemsIndex"), persisted && i > index ? 1 : 0); + QCOMPARE(evaluate(item, "delegate.VisualDataModel.visibleIndex"), visible || i <= index ? i : i - 1); + QCOMPARE(evaluate(item, "delegate.VisualDataModel.selectedIndex"), selected && i > index ? 1 : 0); + } else if (inItems) { + get = QString("items.get(%1)").arg(index); + } else if (persisted) { + get = "persistedItems.get(0)"; + } else if (visible) { + get = QString("visibleItems.get(%1)").arg(index); + } else if (selected) { + get = "selectedItems.get(0)"; + } else { + continue; + } + + QCOMPARE(evaluate(visualModel, get + ".model.index"), modelIndex); + + QCOMPARE(evaluate(visualModel, get + ".model." + property), propertyData.at(i)); + + QCOMPARE(evaluate(visualModel, get + ".inItems"), inItems || i != index); + QCOMPARE(evaluate(visualModel, get + ".inPersistedItems"), persisted && i == index); + QCOMPARE(evaluate(visualModel, get + ".inVisible"), visible || i != index); + QCOMPARE(evaluate(visualModel, get + ".inSelected"), selected && i == index); + QCOMPARE(evaluate(visualModel, get + ".isUnresolved"), false); + + QCOMPARE(evaluate(visualModel, get + ".itemsIndex"), inItems || i <= index ? i : i - 1); + QCOMPARE(evaluate(visualModel, get + ".persistedItemsIndex"), persisted && i > index ? 1 : 0); + QCOMPARE(evaluate(visualModel, get + ".visibleIndex"), visible || i <= index ? i : i - 1); + QCOMPARE(evaluate(visualModel, get + ".selectedIndex"), selected && i > index ? 1 : 0); + } + + QObject *item = 0; + + if (inItems) + item = evaluate(visualModel, QString("items.create(%1)").arg(index)); + else if (persisted) + item = evaluate(visualModel, QString("persistedItems.create(%1)").arg(0)); + else if (visible) + item = evaluate(visualModel, QString("visibleItems.create(%1)").arg(index)); + else if (selected) + item = evaluate(visualModel, QString("selectedItems.create(%1)").arg(0)); + else + return; + + QVERIFY(item); + + QCOMPARE(evaluate(item, "test1"), index); + QCOMPARE(evaluate(item, "test2"), index); + QCOMPARE(evaluate(item, "test3"), propertyData.at(index)); + QCOMPARE(evaluate(item, "test4"), propertyData.at(index)); + + if (modelData) { + QCOMPARE(evaluate(item, "test5"), propertyData.at(index)); + QCOMPARE(evaluate(item, "test6"), propertyData.at(index)); + } + + QCOMPARE(evaluate(item, "delegate.VisualDataModel.inItems"), inItems); + QCOMPARE(evaluate(item, "delegate.VisualDataModel.inPersistedItems"), true); + QCOMPARE(evaluate(item, "delegate.VisualDataModel.inVisible"), visible); + QCOMPARE(evaluate(item, "delegate.VisualDataModel.inSelected"), selected); + QCOMPARE(evaluate(item, "delegate.VisualDataModel.isUnresolved"), false); + + QCOMPARE(evaluate(item, "delegate.VisualDataModel.itemsIndex"), index); + QCOMPARE(evaluate(item, "delegate.VisualDataModel.persistedItemsIndex"), 0); + QCOMPARE(evaluate(item, "delegate.VisualDataModel.visibleIndex"), index); + QCOMPARE(evaluate(item, "delegate.VisualDataModel.selectedIndex"), 0); +} + +void tst_qquickvisualdatamodel::warnings_data() +{ + QTest::addColumn("source"); + QTest::addColumn("expression"); + QTest::addColumn("warning"); + QTest::addColumn("count"); + + QTest::newRow("insert < 0") + << testFileUrl("listmodelproperties.qml") + << QString("items.insert(-2, {\"number\": \"eight\"})") + << (": QML VisualDataGroup: " + QQuickVisualDataGroup::tr("insert: index out of range")) + << 4; + + QTest::newRow("insert > length") + << testFileUrl("listmodelproperties.qml") + << QString("items.insert(8, {\"number\": \"eight\"})") + << (": QML VisualDataGroup: " + QQuickVisualDataGroup::tr("insert: index out of range")) + << 4; + + QTest::newRow("create < 0") + << testFileUrl("listmodelproperties.qml") + << QString("items.create(-2, {\"number\": \"eight\"})") + << (": QML VisualDataGroup: " + QQuickVisualDataGroup::tr("create: index out of range")) + << 4; + + QTest::newRow("create > length") + << testFileUrl("listmodelproperties.qml") + << QString("items.create(8, {\"number\": \"eight\"})") + << (": QML VisualDataGroup: " + QQuickVisualDataGroup::tr("create: index out of range")) + << 4; + + QTest::newRow("resolve from < 0") + << testFileUrl("listmodelproperties.qml") + << QString("items.resolve(-2, 3)") + << (": QML VisualDataGroup: " + QQuickVisualDataGroup::tr("resolve: from index out of range")) + << 4; + + QTest::newRow("resolve from > length") + << testFileUrl("listmodelproperties.qml") + << QString("items.resolve(8, 3)") + << (": QML VisualDataGroup: " + QQuickVisualDataGroup::tr("resolve: from index out of range")) + << 4; + + QTest::newRow("resolve to < 0") + << testFileUrl("listmodelproperties.qml") + << QString("items.resolve(3, -2)") + << (": QML VisualDataGroup: " + QQuickVisualDataGroup::tr("resolve: to index out of range")) + << 4; + + QTest::newRow("resolve to > length") + << testFileUrl("listmodelproperties.qml") + << QString("items.resolve(3, 8)") + << (": QML VisualDataGroup: " + QQuickVisualDataGroup::tr("resolve: to index out of range")) + << 4; + + QTest::newRow("resolve from invalid index") + << testFileUrl("listmodelproperties.qml") + << QString("items.resolve(\"two\", 3)") + << (": QML VisualDataGroup: " + QQuickVisualDataGroup::tr("resolve: from index invalid")) + << 4; + + QTest::newRow("resolve to invalid index") + << testFileUrl("listmodelproperties.qml") + << QString("items.resolve(3, \"two\")") + << (": QML VisualDataGroup: " + QQuickVisualDataGroup::tr("resolve: to index invalid")) + << 4; + + QTest::newRow("resolve already resolved item") + << testFileUrl("listmodelproperties.qml") + << QString("items.resolve(3, 2)") + << (": QML VisualDataGroup: " + QQuickVisualDataGroup::tr("resolve: from is not an unresolved item")) + << 4; + + QTest::newRow("resolve already resolved item") + << testFileUrl("listmodelproperties.qml") + << QString("{ items.insert(0, {\"number\": \"eight\"});" + "items.insert(1, {\"number\": \"seven\"});" + "items.resolve(0, 1)}") + << (": QML VisualDataGroup: " + QQuickVisualDataGroup::tr("resolve: to is not a model item")) + << 6; + + QTest::newRow("remove index < 0") + << testFileUrl("listmodelproperties.qml") + << QString("items.remove(-2, 1)") + << (": QML VisualDataGroup: " + QQuickVisualDataGroup::tr("remove: index out of range")) + << 4; + + QTest::newRow("remove index == length") + << testFileUrl("listmodelproperties.qml") + << QString("items.remove(4, 1)") + << (": QML VisualDataGroup: " + QQuickVisualDataGroup::tr("remove: index out of range")) + << 4; + + QTest::newRow("remove index > length") + << testFileUrl("listmodelproperties.qml") + << QString("items.remove(9, 1)") + << (": QML VisualDataGroup: " + QQuickVisualDataGroup::tr("remove: index out of range")) + << 4; + + QTest::newRow("remove invalid index") + << testFileUrl("listmodelproperties.qml") + << QString("items.remove(\"nine\", 1)") + << (": QML VisualDataGroup: " + QQuickVisualDataGroup::tr("remove: invalid index")) + << 4; + + QTest::newRow("remove count < 0") + << testFileUrl("listmodelproperties.qml") + << QString("items.remove(1, -2)") + << (": QML VisualDataGroup: " + QQuickVisualDataGroup::tr("remove: invalid count")) + << 4; + + QTest::newRow("remove index + count > length") + << testFileUrl("listmodelproperties.qml") + << QString("items.remove(2, 4, \"selected\")") + << (": QML VisualDataGroup: " + QQuickVisualDataGroup::tr("remove: invalid count")) + << 4; + + QTest::newRow("addGroups index < 0") + << testFileUrl("listmodelproperties.qml") + << QString("items.addGroups(-2, 1, \"selected\")") + << (": QML VisualDataGroup: " + QQuickVisualDataGroup::tr("addGroups: index out of range")) + << 4; + + QTest::newRow("addGroups index == length") + << testFileUrl("listmodelproperties.qml") + << QString("items.addGroups(4, 1, \"selected\")") + << (": QML VisualDataGroup: " + QQuickVisualDataGroup::tr("addGroups: index out of range")) + << 4; + + QTest::newRow("addGroups index > length") + << testFileUrl("listmodelproperties.qml") + << QString("items.addGroups(9, 1, \"selected\")") + << (": QML VisualDataGroup: " + QQuickVisualDataGroup::tr("addGroups: index out of range")) + << 4; + + QTest::newRow("addGroups count < 0") + << testFileUrl("listmodelproperties.qml") + << QString("items.addGroups(1, -2, \"selected\")") + << (": QML VisualDataGroup: " + QQuickVisualDataGroup::tr("addGroups: invalid count")) + << 4; + + QTest::newRow("addGroups index + count > length") + << testFileUrl("listmodelproperties.qml") + << QString("items.addGroups(2, 4, \"selected\")") + << (": QML VisualDataGroup: " + QQuickVisualDataGroup::tr("addGroups: invalid count")) + << 4; + + QTest::newRow("removeGroups index < 0") + << testFileUrl("listmodelproperties.qml") + << QString("items.removeGroups(-2, 1, \"selected\")") + << (": QML VisualDataGroup: " + QQuickVisualDataGroup::tr("removeGroups: index out of range")) + << 4; + + QTest::newRow("removeGroups index == length") + << testFileUrl("listmodelproperties.qml") + << QString("items.removeGroups(4, 1, \"selected\")") + << (": QML VisualDataGroup: " + QQuickVisualDataGroup::tr("removeGroups: index out of range")) + << 4; + + QTest::newRow("removeGroups index > length") + << testFileUrl("listmodelproperties.qml") + << QString("items.removeGroups(9, 1, \"selected\")") + << (": QML VisualDataGroup: " + QQuickVisualDataGroup::tr("removeGroups: index out of range")) + << 4; + + QTest::newRow("removeGroups count < 0") + << testFileUrl("listmodelproperties.qml") + << QString("items.removeGroups(1, -2, \"selected\")") + << (": QML VisualDataGroup: " + QQuickVisualDataGroup::tr("removeGroups: invalid count")) + << 4; + + QTest::newRow("removeGroups index + count > length") + << testFileUrl("listmodelproperties.qml") + << QString("items.removeGroups(2, 4, \"selected\")") + << (": QML VisualDataGroup: " + QQuickVisualDataGroup::tr("removeGroups: invalid count")) + << 4; + + QTest::newRow("setGroups index < 0") + << testFileUrl("listmodelproperties.qml") + << QString("items.setGroups(-2, 1, \"selected\")") + << (": QML VisualDataGroup: " + QQuickVisualDataGroup::tr("setGroups: index out of range")) + << 4; + + QTest::newRow("setGroups index == length") + << testFileUrl("listmodelproperties.qml") + << QString("items.setGroups(4, 1, \"selected\")") + << (": QML VisualDataGroup: " + QQuickVisualDataGroup::tr("setGroups: index out of range")) + << 4; + + QTest::newRow("setGroups index > length") + << testFileUrl("listmodelproperties.qml") + << QString("items.setGroups(9, 1, \"selected\")") + << (": QML VisualDataGroup: " + QQuickVisualDataGroup::tr("setGroups: index out of range")) + << 4; + + QTest::newRow("setGroups count < 0") + << testFileUrl("listmodelproperties.qml") + << QString("items.setGroups(1, -2, \"selected\")") + << (": QML VisualDataGroup: " + QQuickVisualDataGroup::tr("setGroups: invalid count")) + << 4; + + QTest::newRow("setGroups index + count > length") + << testFileUrl("listmodelproperties.qml") + << QString("items.setGroups(2, 4, \"selected\")") + << (": QML VisualDataGroup: " + QQuickVisualDataGroup::tr("setGroups: invalid count")) + << 4; + + QTest::newRow("move from < 0") + << testFileUrl("listmodelproperties.qml") + << QString("items.move(-2, 1, 1)") + << (": QML VisualDataGroup: " + QQuickVisualDataGroup::tr("move: from index out of range")) + << 4; + + QTest::newRow("move from == length") + << testFileUrl("listmodelproperties.qml") + << QString("items.move(4, 1, 1)") + << (": QML VisualDataGroup: " + QQuickVisualDataGroup::tr("move: from index out of range")) + << 4; + + QTest::newRow("move from > length") + << testFileUrl("listmodelproperties.qml") + << QString("items.move(9, 1, 1)") + << (": QML VisualDataGroup: " + QQuickVisualDataGroup::tr("move: from index out of range")) + << 4; + + QTest::newRow("move invalid from") + << testFileUrl("listmodelproperties.qml") + << QString("items.move(\"nine\", 1, 1)") + << (": QML VisualDataGroup: " + QQuickVisualDataGroup::tr("move: invalid from index")) + << 4; + + QTest::newRow("move to < 0") + << testFileUrl("listmodelproperties.qml") + << QString("items.move(1, -2, 1)") + << (": QML VisualDataGroup: " + QQuickVisualDataGroup::tr("move: to index out of range")) + << 4; + + QTest::newRow("move to == length") + << testFileUrl("listmodelproperties.qml") + << QString("items.move(1, 4, 1)") + << (": QML VisualDataGroup: " + QQuickVisualDataGroup::tr("move: to index out of range")) + << 4; + + QTest::newRow("move to > length") + << testFileUrl("listmodelproperties.qml") + << QString("items.move(1, 9, 1)") + << (": QML VisualDataGroup: " + QQuickVisualDataGroup::tr("move: to index out of range")) + << 4; + + QTest::newRow("move invalid to") + << testFileUrl("listmodelproperties.qml") + << QString("items.move(1, \"nine\", 1)") + << (": QML VisualDataGroup: " + QQuickVisualDataGroup::tr("move: invalid to index")) + << 4; + + QTest::newRow("move count < 0") + << testFileUrl("listmodelproperties.qml") + << QString("items.move(1, 1, -2)") + << (": QML VisualDataGroup: " + QQuickVisualDataGroup::tr("move: invalid count")) + << 4; + + QTest::newRow("move from + count > length") + << testFileUrl("listmodelproperties.qml") + << QString("items.move(2, 1, 4)") + << (": QML VisualDataGroup: " + QQuickVisualDataGroup::tr("move: from index out of range")) + << 4; +} + +void tst_qquickvisualdatamodel::warnings() +{ + QFETCH(QUrl, source); + QFETCH(QString, expression); + QFETCH(QString, warning); + QFETCH(int, count); + + QQuickCanvas canvas; + + QQmlComponent component(&engine); + component.loadUrl(source); + QScopedPointer object(component.create()); + QQuickListView *listView = qobject_cast(object.data()); + QVERIFY(listView); + listView->setParentItem(canvas.rootItem()); + + QQuickItem *contentItem = listView->contentItem(); + QVERIFY(contentItem); + + QObject *visualModel = evaluate(listView, "model"); + QVERIFY(visualModel); + + QTest::ignoreMessage(QtWarningMsg, warning.toUtf8()); + + evaluate(visualModel, expression); + QCOMPARE(evaluate(listView, "count"), count); +} + + +QTEST_MAIN(tst_qquickvisualdatamodel) + +#include "tst_qquickvisualdatamodel.moc" diff --git a/tests/auto/quick/qquickxmllistmodel/data/empty.xml b/tests/auto/quick/qquickxmllistmodel/data/empty.xml new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/auto/quick/qquickxmllistmodel/data/get.qml b/tests/auto/quick/qquickxmllistmodel/data/get.qml new file mode 100644 index 0000000000..509da7174b --- /dev/null +++ b/tests/auto/quick/qquickxmllistmodel/data/get.qml @@ -0,0 +1,61 @@ +import QtQuick 2.0 +import QtQuick.XmlListModel 2.0 + +XmlListModel { + source: "model.xml" + query: "/Pets/Pet" + XmlRole { name: "name"; query: "name/string()" } + XmlRole { name: "type"; query: "type/string()" } + XmlRole { name: "age"; query: "age/number()" } + XmlRole { name: "size"; query: "size/string()" } + + id: root + + property bool preTest: false + property bool postTest: false + + function runPreTest() { + if (root.get(0) != undefined) + return; + + preTest = true; + } + + function runPostTest() { + if (root.get(-1) != undefined) + return; + + var row = root.get(0); + if (row.name != "Polly" || + row.type != "Parrot" || + row.age != 12 || + row.size != "Small") + return; + + row = root.get(1); + if (row.name != "Penny" || + row.type != "Turtle" || + row.age != 4 || + row.size != "Small") + return; + + row = root.get(7); + if (row.name != "Rover" || + row.type != "Dog" || + row.age != 0 || + row.size != "Large") + return; + + row = root.get(8); + if (row.name != "Tiny" || + row.type != "Elephant" || + row.age != 15 || + row.size != "Large") + return; + + if (root.get(9) != undefined) + return; + + postTest = true; + } +} diff --git a/tests/auto/quick/qquickxmllistmodel/data/model.qml b/tests/auto/quick/qquickxmllistmodel/data/model.qml new file mode 100644 index 0000000000..2df3927479 --- /dev/null +++ b/tests/auto/quick/qquickxmllistmodel/data/model.qml @@ -0,0 +1,11 @@ +import QtQuick 2.0 +import QtQuick.XmlListModel 2.0 + +XmlListModel { + source: "model.xml" + query: "/Pets/Pet" + XmlRole { name: "name"; query: "name/string()" } + XmlRole { name: "type"; query: "type/string()" } + XmlRole { name: "age"; query: "age/number()" } + XmlRole { name: "size"; query: "size/string()" } +} diff --git a/tests/auto/quick/qquickxmllistmodel/data/model.xml b/tests/auto/quick/qquickxmllistmodel/data/model.xml new file mode 100644 index 0000000000..40cd6d0432 --- /dev/null +++ b/tests/auto/quick/qquickxmllistmodel/data/model.xml @@ -0,0 +1,54 @@ + + + Polly + Parrot + 12 + Small + + + Penny + Turtle + 4 + Small + + + Warren + Rabbit + 2 + Small + + + Spot + Dog + 9 + Medium + + + Whiskers + Cat + 2 + Medium + + + Joey + Kangaroo + 1 + + + Kimba + Bunny + 65 + Large + + + Rover + Dog + Large + + + Tiny + Elephant + 15 + Large + + diff --git a/tests/auto/quick/qquickxmllistmodel/data/model2.xml b/tests/auto/quick/qquickxmllistmodel/data/model2.xml new file mode 100644 index 0000000000..dab2ec6dc0 --- /dev/null +++ b/tests/auto/quick/qquickxmllistmodel/data/model2.xml @@ -0,0 +1,14 @@ + + + Polly + Parrot + 12 + Small + + + Penny + Turtle + 4 + Small + + diff --git a/tests/auto/quick/qquickxmllistmodel/data/propertychanges.qml b/tests/auto/quick/qquickxmllistmodel/data/propertychanges.qml new file mode 100644 index 0000000000..f8a97bffc3 --- /dev/null +++ b/tests/auto/quick/qquickxmllistmodel/data/propertychanges.qml @@ -0,0 +1,11 @@ +import QtQuick 2.0 +import QtQuick.XmlListModel 2.0 + +XmlListModel { + source: "model.xml" + query: "/Pets/Pet" + XmlRole { objectName: "role"; name: "name"; query: "name/string()" } + XmlRole { name: "type"; query: "type/string()" } + XmlRole { name: "age"; query: "age/number()" } + XmlRole { name: "size"; query: "size/string()" } +} diff --git a/tests/auto/quick/qquickxmllistmodel/data/recipes.qml b/tests/auto/quick/qquickxmllistmodel/data/recipes.qml new file mode 100644 index 0000000000..dc609e95e3 --- /dev/null +++ b/tests/auto/quick/qquickxmllistmodel/data/recipes.qml @@ -0,0 +1,11 @@ +import QtQuick 2.0 +import QtQuick.XmlListModel 2.0 + +XmlListModel { + source: "recipes.xml" + query: "/recipes/recipe" + XmlRole { name: "title"; query: "@title/string()" } + XmlRole { name: "picture"; query: "picture/string()" } + XmlRole { name: "ingredients"; query: "ingredients/string()" } + XmlRole { name: "preparation"; query: "method/string()" } +} diff --git a/tests/auto/quick/qquickxmllistmodel/data/recipes.xml b/tests/auto/quick/qquickxmllistmodel/data/recipes.xml new file mode 100644 index 0000000000..d71de60710 --- /dev/null +++ b/tests/auto/quick/qquickxmllistmodel/data/recipes.xml @@ -0,0 +1,90 @@ + + + content/pics/pancakes.jpg + +

            +
          • 1 cup (150g) self-raising flour +
          • 1 tbs caster sugar +
          • 3/4 cup (185ml) milk +
          • 1 egg +
          + + ]]> + +
            +
          1. Sift flour and sugar together into a bowl. Add a pinch of salt. +
          2. Beat milk and egg together, then add to dry ingredients. Beat until smooth. +
          3. Pour mixture into a pan on medium heat and cook until bubbles appear on the surface. +
          4. Turn over and cook other side until golden. +
          + + ]]>
          + + + content/pics/fruit-salad.jpg + + + + + content/pics/vegetable-soup.jpg + +
            +
          • 1 onion +
          • 1 turnip +
          • 1 potato +
          • 1 carrot +
          • 1 head of celery +
          • 1 1/2 litres of water +
          + + ]]>
          + +
            +
          1. Chop vegetables. +
          2. Boil in water until vegetables soften. +
          3. Season with salt and pepper to taste. +
          + + ]]>
          +
          + + content/pics/hamburger.jpg + +
            +
          • 500g minced beef +
          • Seasoning +
          • lettuce, tomato, onion, cheese +
          • 1 hamburger bun for each burger +
          + + ]]>
          + +
            +
          1. Mix the beef, together with seasoning, in a food processor. +
          2. Shape the beef into burgers. +
          3. Grill the burgers for about 5 mins on each side (until cooked through) +
          4. Serve each burger on a bun with ketchup, cheese, lettuce, tomato and onion. +
          + + ]]>
          +
          + + content/pics/lemonade.jpg + +
            +
          • 1 cup Lemon Juice +
          • 1 cup Sugar +
          • 6 Cups of Water (2 cups warm water, 4 cups cold water) +
          + + ]]>
          + +
            +
          1. Pour 2 cups of warm water into a pitcher and stir in sugar until it dissolves. +
          2. Pour in lemon juice, stir again, and add 4 cups of cold water. +
          3. Chill or serve over ice cubes. +
          + + ]]>
          +
          + diff --git a/tests/auto/quick/qquickxmllistmodel/data/roleCrash.qml b/tests/auto/quick/qquickxmllistmodel/data/roleCrash.qml new file mode 100644 index 0000000000..6a7059bb45 --- /dev/null +++ b/tests/auto/quick/qquickxmllistmodel/data/roleCrash.qml @@ -0,0 +1,8 @@ +import QtQuick 2.0 +import QtQuick.XmlListModel 2.0 + +XmlListModel { + id: model + XmlRole {} + Component.onCompleted: model.roles = 0 +} diff --git a/tests/auto/quick/qquickxmllistmodel/data/roleErrors.qml b/tests/auto/quick/qquickxmllistmodel/data/roleErrors.qml new file mode 100644 index 0000000000..91664b6d4a --- /dev/null +++ b/tests/auto/quick/qquickxmllistmodel/data/roleErrors.qml @@ -0,0 +1,11 @@ +import QtQuick 2.0 +import QtQuick.XmlListModel 2.0 + +XmlListModel { + source: "model.xml" + query: "/Pets/Pet" + XmlRole { name: "name"; query: "/name/string()" } //starts with '/' + XmlRole { name: "type"; query: "type" } //no type + XmlRole { name: "age"; query: "age/" } //ends with '/' + XmlRole { name: "size"; query: "size/number()" } //wrong type +} diff --git a/tests/auto/quick/qquickxmllistmodel/data/roleKeys.qml b/tests/auto/quick/qquickxmllistmodel/data/roleKeys.qml new file mode 100644 index 0000000000..9f667d86e5 --- /dev/null +++ b/tests/auto/quick/qquickxmllistmodel/data/roleKeys.qml @@ -0,0 +1,13 @@ +import QtQuick 2.0 +import QtQuick.XmlListModel 2.0 + +XmlListModel { + query: "/data/item" + XmlRole { id: nameRole; name: "name"; query: "name/string()"; isKey: true } + XmlRole { name: "age"; query: "age/number()"; isKey: true } + XmlRole { name: "sport"; query: "sport/string()" } + + function disableNameKey() { + nameRole.isKey = false; + } +} diff --git a/tests/auto/quick/qquickxmllistmodel/data/testtypes.qml b/tests/auto/quick/qquickxmllistmodel/data/testtypes.qml new file mode 100644 index 0000000000..5ec1ffa35f --- /dev/null +++ b/tests/auto/quick/qquickxmllistmodel/data/testtypes.qml @@ -0,0 +1,8 @@ +import QtQuick 2.0 +import QtQuick.XmlListModel 2.0 + +XmlListModel { + query: "/data" + XmlRole { name: "stringValue"; query: "a-string/string()" } + XmlRole { name: "numberValue"; query: "a-number/number()" } +} diff --git a/tests/auto/quick/qquickxmllistmodel/data/unique.qml b/tests/auto/quick/qquickxmllistmodel/data/unique.qml new file mode 100644 index 0000000000..322a2e4e5c --- /dev/null +++ b/tests/auto/quick/qquickxmllistmodel/data/unique.qml @@ -0,0 +1,9 @@ +import QtQuick 2.0 +import QtQuick.XmlListModel 2.0 + +XmlListModel { + source: "model.xml" + query: "/Pets/Pet" + XmlRole { name: "name"; query: "name/string()" } + XmlRole { name: "name"; query: "type/string()" } +} diff --git a/tests/auto/quick/qquickxmllistmodel/qquickxmllistmodel.pro b/tests/auto/quick/qquickxmllistmodel/qquickxmllistmodel.pro new file mode 100644 index 0000000000..b18af50c9e --- /dev/null +++ b/tests/auto/quick/qquickxmllistmodel/qquickxmllistmodel.pro @@ -0,0 +1,15 @@ +CONFIG += testcase +TARGET = tst_qquickxmllistmodel +macx:CONFIG -= app_bundle + +SOURCES += tst_qquickxmllistmodel.cpp + +include (../../shared/util.pri) + +testDataFiles.files = data +testDataFiles.path = . +DEPLOYMENT += testDataFiles + +CONFIG += parallel_test + +QT += core-private gui-private v8-private qml-private network testlib xmlpatterns diff --git a/tests/auto/quick/qquickxmllistmodel/tst_qquickxmllistmodel.cpp b/tests/auto/quick/qquickxmllistmodel/tst_qquickxmllistmodel.cpp new file mode 100644 index 0000000000..4d337564c0 --- /dev/null +++ b/tests/auto/quick/qquickxmllistmodel/tst_qquickxmllistmodel.cpp @@ -0,0 +1,962 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "../../shared/util.h" +#include + +#include +#include +#include +#include "../../../../src/imports/xmllistmodel/qqmlxmllistmodel_p.h" + +typedef QPair QQuickXmlListRange; +typedef QList QQmlXmlModelData; + +Q_DECLARE_METATYPE(QList) +Q_DECLARE_METATYPE(QQmlXmlModelData) +Q_DECLARE_METATYPE(QQuickXmlListModel::Status) + +class tst_qquickxmllistmodel : public QQmlDataTest + +{ + Q_OBJECT +public: + tst_qquickxmllistmodel() {} + +private slots: + void initTestCase() { + QQmlDataTest::initTestCase(); + qRegisterMetaType(); + } + + void buildModel(); + void testTypes(); + void testTypes_data(); + void cdata(); + void attributes(); + void roles(); + void roleErrors(); + void uniqueRoleNames(); + void headers(); + void xml(); + void xml_data(); + void source(); + void source_data(); + void data(); + void get(); + void reload(); + void useKeys(); + void useKeys_data(); + void noKeysValueChanges(); + void keysChanged(); + void threading(); + void threading_data(); + void propertyChanges(); + + void roleCrash(); + +private: + QString errorString(QListModelInterface* model) { + QString ret; + QMetaObject::invokeMethod(model, "errorString", Q_RETURN_ARG(QString, ret)); + return ret; + } + + QString makeItemXmlAndData(const QString &data, QQmlXmlModelData *modelData = 0) const + { + if (modelData) + modelData->clear(); + QString xml; + + if (!data.isEmpty()) { + QStringList items = data.split(";"); + foreach(const QString &item, items) { + if (item.isEmpty()) + continue; + QVariantList variants; + xml += QLatin1String(""); + QStringList fields = item.split(","); + foreach(const QString &field, fields) { + QStringList values = field.split("="); + if (values.count() != 2) { + qWarning() << "makeItemXmlAndData: invalid field:" << field; + continue; + } + xml += QString("<%1>%2").arg(values[0], values[1]); + if (!modelData) + continue; + bool isNum = false; + int number = values[1].toInt(&isNum); + if (isNum) + variants << number; + else + variants << values[1]; + } + xml += QLatin1String(""); + if (modelData) + modelData->append(variants); + } + } + + QString decl = ""; + return decl + QLatin1String("") + xml + QLatin1String(""); + } + + QQmlEngine engine; +}; + +class CustomNetworkAccessManagerFactory : public QObject, public QQmlNetworkAccessManagerFactory +{ + Q_OBJECT +public: + QVariantMap lastSentHeaders; + +protected: + QNetworkAccessManager *create(QObject *parent); +}; + +class CustomNetworkAccessManager : public QNetworkAccessManager +{ + Q_OBJECT +public: + CustomNetworkAccessManager(CustomNetworkAccessManagerFactory *factory, QObject *parent) + : QNetworkAccessManager(parent), m_factory(factory) {} + +protected: + QNetworkReply *createRequest(Operation op, const QNetworkRequest &req, QIODevice * outgoingData = 0) + { + if (m_factory) { + QVariantMap map; + foreach (const QString &header, req.rawHeaderList()) + map[header] = req.rawHeader(header.toUtf8()); + m_factory->lastSentHeaders = map; + } + return QNetworkAccessManager::createRequest(op, req, outgoingData); + } + + QPointer m_factory; +}; + +QNetworkAccessManager *CustomNetworkAccessManagerFactory::create(QObject *parent) +{ + return new CustomNetworkAccessManager(this, parent); +} + + +void tst_qquickxmllistmodel::buildModel() +{ + QQmlComponent component(&engine, testFileUrl("model.qml")); + QListModelInterface *model = qobject_cast(component.create()); + QVERIFY(model != 0); + QTRY_COMPARE(model->count(), 9); + + QCOMPARE(model->data(3, Qt::UserRole).toString(), QLatin1String("Spot")); + QCOMPARE(model->data(3, Qt::UserRole+1).toString(), QLatin1String("Dog")); + QCOMPARE(model->data(3, Qt::UserRole+2).toInt(), 9); + QCOMPARE(model->data(3, Qt::UserRole+3).toString(), QLatin1String("Medium")); + + delete model; +} + +void tst_qquickxmllistmodel::testTypes() +{ + QFETCH(QString, xml); + QFETCH(QString, roleName); + QFETCH(QVariant, expectedValue); + + QQmlComponent component(&engine, testFileUrl("testtypes.qml")); + QListModelInterface *model = qobject_cast(component.create()); + QVERIFY(model != 0); + model->setProperty("xml",xml.toUtf8()); + QMetaObject::invokeMethod(model, "reload"); + QTRY_COMPARE(model->count(), 1); + + int role = -1; + foreach (int i, model->roles()) { + if (model->toString(i) == roleName) { + role = i; + break; + } + } + QVERIFY(role >= 0); + + if (expectedValue.toString() == "nan") + QVERIFY(qIsNaN(model->data(0, role).toDouble())); + else + QCOMPARE(model->data(0, role), expectedValue); + + delete model; +} + +void tst_qquickxmllistmodel::testTypes_data() +{ + QTest::addColumn("xml"); + QTest::addColumn("roleName"); + QTest::addColumn("expectedValue"); + + QTest::newRow("missing string field") << "" + << "stringValue" << QVariant(""); + QTest::newRow("empty string") << "" + << "stringValue" << QVariant(""); + QTest::newRow("1-char string") << "5" + << "stringValue" << QVariant("5"); + QTest::newRow("string ok") << "abc def g" + << "stringValue" << QVariant("abc def g"); + + QTest::newRow("missing number field") << "" + << "numberValue" << QVariant(""); + double nan = qQNaN(); + QTest::newRow("empty number field") << "" + << "numberValue" << QVariant(nan); + QTest::newRow("number field with string") << "a string" + << "numberValue" << QVariant(nan); + QTest::newRow("-1") << "-1" + << "numberValue" << QVariant("-1"); + QTest::newRow("-1.5") << "-1.5" + << "numberValue" << QVariant("-1.5"); + QTest::newRow("0") << "0" + << "numberValue" << QVariant("0"); + QTest::newRow("+1") << "1" + << "numberValue" << QVariant("1"); + QTest::newRow("+1.5") << "1.5" + << "numberValue" << QVariant("1.5"); +} + +void tst_qquickxmllistmodel::cdata() +{ + QQmlComponent component(&engine, testFileUrl("recipes.qml")); + QListModelInterface *model = qobject_cast(component.create()); + QVERIFY(model != 0); + QTRY_COMPARE(model->count(), 5); + + QVERIFY(model->data(2, Qt::UserRole+2).toString().startsWith(QLatin1String(""))); + + delete model; +} + +void tst_qquickxmllistmodel::attributes() +{ + QQmlComponent component(&engine, testFileUrl("recipes.qml")); + QListModelInterface *model = qobject_cast(component.create()); + QVERIFY(model != 0); + QTRY_COMPARE(model->count(), 5); + QCOMPARE(model->data(2, Qt::UserRole).toString(), QLatin1String("Vegetable Soup")); + + delete model; +} + +void tst_qquickxmllistmodel::roles() +{ + QQmlComponent component(&engine, testFileUrl("model.qml")); + QListModelInterface *model = qobject_cast(component.create()); + QVERIFY(model != 0); + QTRY_COMPARE(model->count(), 9); + + QList roles = model->roles(); + QCOMPARE(roles.count(), 4); + QCOMPARE(model->toString(roles.at(0)), QLatin1String("name")); + QCOMPARE(model->toString(roles.at(1)), QLatin1String("type")); + QCOMPARE(model->toString(roles.at(2)), QLatin1String("age")); + QCOMPARE(model->toString(roles.at(3)), QLatin1String("size")); + + delete model; +} + +void tst_qquickxmllistmodel::roleErrors() +{ + QQmlComponent component(&engine, testFileUrl("roleErrors.qml")); + QTest::ignoreMessage(QtWarningMsg, (testFileUrl("roleErrors.qml").toString() + ":7:5: QML XmlRole: An XmlRole query must not start with '/'").toUtf8().constData()); + QTest::ignoreMessage(QtWarningMsg, (testFileUrl("roleErrors.qml").toString() + ":10:5: QML XmlRole: invalid query: \"age/\"").toUtf8().constData()); + + //### make sure we receive all expected warning messages. + QListModelInterface *model = qobject_cast(component.create()); + QVERIFY(model != 0); + QTRY_COMPARE(model->count(), 9); + + + //### should any of these return valid values? + QCOMPARE(model->data(3, Qt::UserRole), QVariant()); + QCOMPARE(model->data(3, Qt::UserRole+1), QVariant()); + QCOMPARE(model->data(3, Qt::UserRole+2), QVariant()); + + QEXPECT_FAIL("", "QTBUG-10797", Continue); + QCOMPARE(model->data(3, Qt::UserRole+3), QVariant()); + + delete model; +} + +void tst_qquickxmllistmodel::uniqueRoleNames() +{ + QQmlComponent component(&engine, testFileUrl("unique.qml")); + QTest::ignoreMessage(QtWarningMsg, (testFileUrl("unique.qml").toString() + ":8:5: QML XmlRole: \"name\" duplicates a previous role name and will be disabled.").toUtf8().constData()); + QListModelInterface *model = qobject_cast(component.create()); + QVERIFY(model != 0); + QTRY_COMPARE(model->count(), 9); + + QList roles = model->roles(); + QCOMPARE(roles.count(), 1); + + delete model; +} + + +void tst_qquickxmllistmodel::xml() +{ + QFETCH(QString, xml); + QFETCH(int, count); + + QQmlComponent component(&engine, testFileUrl("model.qml")); + QListModelInterface *model = qobject_cast(component.create()); + + QSignalSpy spy(model, SIGNAL(statusChanged(QQuickXmlListModel::Status))); + QVERIFY(errorString(model).isEmpty()); + QCOMPARE(model->property("progress").toDouble(), qreal(0.0)); + QCOMPARE(qvariant_cast(model->property("status")), + QQuickXmlListModel::Loading); + QTRY_COMPARE(spy.count(), 1); spy.clear(); + QTest::qWait(50); + QCOMPARE(qvariant_cast(model->property("status")), + QQuickXmlListModel::Ready); + QVERIFY(errorString(model).isEmpty()); + QCOMPARE(model->property("progress").toDouble(), qreal(1.0)); + QCOMPARE(model->count(), 9); + + // if xml is empty (i.e. clearing) it won't have any effect if a source is set + if (xml.isEmpty()) + model->setProperty("source",QUrl()); + model->setProperty("xml",xml); + QCOMPARE(model->property("progress").toDouble(), qreal(1.0)); // immediately goes to 1.0 if using setXml() + QTRY_COMPARE(spy.count(), 1); spy.clear(); + QCOMPARE(qvariant_cast(model->property("status")), + QQuickXmlListModel::Loading); + QTRY_COMPARE(spy.count(), 1); spy.clear(); + if (xml.isEmpty()) + QCOMPARE(qvariant_cast(model->property("status")), + QQuickXmlListModel::Null); + else + QCOMPARE(qvariant_cast(model->property("status")), + QQuickXmlListModel::Ready); + QVERIFY(errorString(model).isEmpty()); + QCOMPARE(model->count(), count); + + delete model; +} + +void tst_qquickxmllistmodel::xml_data() +{ + QTest::addColumn("xml"); + QTest::addColumn("count"); + + QTest::newRow("xml with no items") << "" << 0; + QTest::newRow("empty xml") << "" << 0; + QTest::newRow("one item") << "HobbesTiger7Large" << 1; +} + +void tst_qquickxmllistmodel::headers() +{ + // ensure the QNetworkAccessManagers created for this test are immediately deleted + QQmlEngine qmlEng; + + CustomNetworkAccessManagerFactory factory; + qmlEng.setNetworkAccessManagerFactory(&factory); + + QQmlComponent component(&qmlEng, testFileUrl("model.qml")); + QListModelInterface *model = qobject_cast(component.create()); + QVERIFY(model != 0); + QTRY_COMPARE(qvariant_cast(model->property("status")), + QQuickXmlListModel::Ready); + + QVariantMap expectedHeaders; + expectedHeaders["Accept"] = "application/xml,*/*"; + + QCOMPARE(factory.lastSentHeaders.count(), expectedHeaders.count()); + foreach (const QString &header, expectedHeaders.keys()) { + QVERIFY(factory.lastSentHeaders.contains(header)); + QCOMPARE(factory.lastSentHeaders[header].toString(), expectedHeaders[header].toString()); + } + + delete model; +} + +void tst_qquickxmllistmodel::source() +{ + QFETCH(QUrl, source); + QFETCH(int, count); + QFETCH(QQuickXmlListModel::Status, status); + + QQmlComponent component(&engine, testFileUrl("model.qml")); + QListModelInterface *model = qobject_cast(component.create()); + QSignalSpy spy(model, SIGNAL(statusChanged(QQuickXmlListModel::Status))); + + QVERIFY(errorString(model).isEmpty()); + QCOMPARE(model->property("progress").toDouble(), qreal(0.0)); + QCOMPARE(qvariant_cast(model->property("status")), + QQuickXmlListModel::Loading); + QTRY_COMPARE(spy.count(), 1); spy.clear(); + QCOMPARE(qvariant_cast(model->property("status")), + QQuickXmlListModel::Ready); + QVERIFY(errorString(model).isEmpty()); + QCOMPARE(model->property("progress").toDouble(), qreal(1.0)); + QCOMPARE(model->count(), 9); + + model->setProperty("source",source); + if (model->property("source").toString().isEmpty()) + QCOMPARE(qvariant_cast(model->property("status")), + QQuickXmlListModel::Null); + QCOMPARE(model->property("progress").toDouble(), qreal(0.0)); + QTRY_COMPARE(spy.count(), 1); spy.clear(); + QCOMPARE(qvariant_cast(model->property("status")), + QQuickXmlListModel::Loading); + QVERIFY(errorString(model).isEmpty()); + + QEventLoop loop; + QTimer timer; + timer.setSingleShot(true); + connect(model, SIGNAL(statusChanged(QQuickXmlListModel::Status)), &loop, SLOT(quit())); + connect(&timer, SIGNAL(timeout()), &loop, SLOT(quit())); + timer.start(20000); + loop.exec(); + + if (spy.count() == 0 && status != QQuickXmlListModel::Ready) { + qWarning("QQuickXmlListModel invalid source test timed out"); + } else { + QCOMPARE(spy.count(), 1); spy.clear(); + } + + QCOMPARE(qvariant_cast(model->property("status")), status); + QCOMPARE(model->count(), count); + + if (status == QQuickXmlListModel::Ready) + QCOMPARE(model->property("progress").toDouble(), qreal(1.0)); + + QCOMPARE(errorString(model).isEmpty(), status == QQuickXmlListModel::Ready); + + delete model; +} + +void tst_qquickxmllistmodel::source_data() +{ + QTest::addColumn("source"); + QTest::addColumn("count"); + QTest::addColumn("status"); + + QTest::newRow("valid") << testFileUrl("model2.xml") << 2 + << QQuickXmlListModel::Ready; + QTest::newRow("invalid") << QUrl("http://blah.blah/blah.xml") << 0 + << QQuickXmlListModel::Error; + + // empty file + QTemporaryFile *temp = new QTemporaryFile(this); + if (temp->open()) + QTest::newRow("empty file") << QUrl::fromLocalFile(temp->fileName()) << 0 + << QQuickXmlListModel::Ready; + temp->close(); +} + +void tst_qquickxmllistmodel::data() +{ + QQmlComponent component(&engine, testFileUrl("model.qml")); + QListModelInterface *model = qobject_cast(component.create()); + QVERIFY(model != 0); + + for (int i=0; i<9; i++) { + for (int j=0; jroles().count(); j++) { + QCOMPARE(model->data(i, j), QVariant()); + } + } + QTRY_COMPARE(model->count(), 9); + + delete model; +} + +void tst_qquickxmllistmodel::get() +{ + QQmlComponent component(&engine, testFileUrl("get.qml")); + QListModelInterface *model = qobject_cast(component.create()); + + QVERIFY(model != 0); + + QVERIFY(QMetaObject::invokeMethod(model, "runPreTest")); + QCOMPARE(model->property("preTest").toBool(), true); + + QTRY_COMPARE(model->count(), 9); + + QVERIFY(QMetaObject::invokeMethod(model, "runPostTest")); + QCOMPARE(model->property("postTest").toBool(), true); + + delete model; +} + +void tst_qquickxmllistmodel::reload() +{ + // If no keys are used, the model should be rebuilt from scratch when + // reload() is called. + + QQmlComponent component(&engine, testFileUrl("model.qml")); + QListModelInterface *model = qobject_cast(component.create()); + QVERIFY(model != 0); + QTRY_COMPARE(model->count(), 9); + + QSignalSpy spyInsert(model, SIGNAL(itemsInserted(int,int))); + QSignalSpy spyRemove(model, SIGNAL(itemsRemoved(int,int))); + QSignalSpy spyCount(model, SIGNAL(countChanged())); + //reload multiple times to test the xml query aborting + QMetaObject::invokeMethod(model, "reload"); + QMetaObject::invokeMethod(model, "reload"); + QCoreApplication::processEvents(); + QMetaObject::invokeMethod(model, "reload"); + QMetaObject::invokeMethod(model, "reload"); + QTRY_COMPARE(spyCount.count(), 1); + QTRY_COMPARE(spyInsert.count(), 1); + QTRY_COMPARE(spyRemove.count(), 1); + + QCOMPARE(spyInsert[0][0].toInt(), 0); + QCOMPARE(spyInsert[0][1].toInt(), 9); + + QCOMPARE(spyRemove[0][0].toInt(), 0); + QCOMPARE(spyRemove[0][1].toInt(), 9); + + delete model; +} + +void tst_qquickxmllistmodel::useKeys() +{ + // If using incremental updates through keys, the model should only + // insert & remove some of the items, instead of throwing everything + // away and causing the view to repaint the whole view. + + QFETCH(QString, oldXml); + QFETCH(int, oldCount); + QFETCH(QString, newXml); + QFETCH(QQmlXmlModelData, newData); + QFETCH(QList, insertRanges); + QFETCH(QList, removeRanges); + + QQmlComponent component(&engine, testFileUrl("roleKeys.qml")); + QListModelInterface *model = qobject_cast(component.create()); + QVERIFY(model != 0); + + model->setProperty("xml",oldXml); + QTRY_COMPARE(model->count(), oldCount); + + QSignalSpy spyInsert(model, SIGNAL(itemsInserted(int,int))); + QSignalSpy spyRemove(model, SIGNAL(itemsRemoved(int,int))); + QSignalSpy spyCount(model, SIGNAL(countChanged())); + + model->setProperty("xml",newXml); + + if (oldCount != newData.count()) { + QTRY_COMPARE(model->count(), newData.count()); + QCOMPARE(spyCount.count(), 1); + } else { + QTRY_VERIFY(spyInsert.count() > 0 || spyRemove.count() > 0); + QCOMPARE(spyCount.count(), 0); + } + + QList roles = model->roles(); + for (int i=0; icount(); i++) { + for (int j=0; jdata(i, roles[j]), newData[i][j]); + } + + QCOMPARE(spyInsert.count(), insertRanges.count()); + for (int i=0; i("oldXml"); + QTest::addColumn("oldCount"); + QTest::addColumn("newXml"); + QTest::addColumn("newData"); + QTest::addColumn >("insertRanges"); + QTest::addColumn >("removeRanges"); + + QQmlXmlModelData modelData; + + QTest::newRow("append 1") + << makeItemXmlAndData("name=A,age=25,sport=Football") << 1 + << makeItemXmlAndData("name=A,age=25,sport=Football;name=B,age=35,sport=Athletics", &modelData) + << modelData + << (QList() << qMakePair(1, 1)) + << QList(); + + QTest::newRow("append multiple") + << makeItemXmlAndData("name=A,age=25,sport=Football") << 1 + << makeItemXmlAndData("name=A,age=25,sport=Football;name=B,age=35,sport=Athletics;name=C,age=45,sport=Curling", &modelData) + << modelData + << (QList() << qMakePair(1, 2)) + << QList(); + + QTest::newRow("insert in different spots") + << makeItemXmlAndData("name=B,age=35,sport=Athletics") << 1 + << makeItemXmlAndData("name=A,age=25,sport=Football;name=B,age=35,sport=Athletics;name=C,age=45,sport=Curling;name=D,age=55,sport=Golf", &modelData) + << modelData + << (QList() << qMakePair(0, 1) << qMakePair(2,2)) + << QList(); + + QTest::newRow("insert in middle") + << makeItemXmlAndData("name=A,age=25,sport=Football;name=D,age=55,sport=Golf") << 2 + << makeItemXmlAndData("name=A,age=25,sport=Football;name=B,age=35,sport=Athletics;name=C,age=45,sport=Curling;name=D,age=55,sport=Golf", &modelData) + << modelData + << (QList() << qMakePair(1, 2)) + << QList(); + + QTest::newRow("remove first") + << makeItemXmlAndData("name=A,age=25,sport=Football;name=B,age=35,sport=Athletics") << 2 + << makeItemXmlAndData("name=B,age=35,sport=Athletics", &modelData) + << modelData + << QList() + << (QList() << qMakePair(0, 1)); + + QTest::newRow("remove last") + << makeItemXmlAndData("name=A,age=25,sport=Football;name=B,age=35,sport=Athletics") << 2 + << makeItemXmlAndData("name=A,age=25,sport=Football", &modelData) + << modelData + << QList() + << (QList() << qMakePair(1, 1)); + + QTest::newRow("remove from multiple spots") + << makeItemXmlAndData("name=A,age=25,sport=Football;name=B,age=35,sport=Athletics;name=C,age=45,sport=Curling;name=D,age=55,sport=Golf;name=E,age=65,sport=Fencing") << 5 + << makeItemXmlAndData("name=A,age=25,sport=Football;name=C,age=45,sport=Curling", &modelData) + << modelData + << QList() + << (QList() << qMakePair(1, 1) << qMakePair(3,2)); + + QTest::newRow("remove all") + << makeItemXmlAndData("name=A,age=25,sport=Football;name=B,age=35,sport=Athletics;name=C,age=45,sport=Curling") << 3 + << makeItemXmlAndData("", &modelData) + << modelData + << QList() + << (QList() << qMakePair(0, 3)); + + QTest::newRow("replace item") + << makeItemXmlAndData("name=A,age=25,sport=Football") << 1 + << makeItemXmlAndData("name=ZZZ,age=25,sport=Football", &modelData) + << modelData + << (QList() << qMakePair(0, 1)) + << (QList() << qMakePair(0, 1)); + + QTest::newRow("add and remove simultaneously, in different spots") + << makeItemXmlAndData("name=A,age=25,sport=Football;name=B,age=35,sport=Athletics;name=C,age=45,sport=Curling;name=D,age=55,sport=Golf") << 4 + << makeItemXmlAndData("name=B,age=35,sport=Athletics;name=E,age=65,sport=Fencing", &modelData) + << modelData + << (QList() << qMakePair(1, 1)) + << (QList() << qMakePair(0, 1) << qMakePair(2,2)); + + QTest::newRow("insert at start, remove at end i.e. rss feed") + << makeItemXmlAndData("name=C,age=45,sport=Curling;name=D,age=55,sport=Golf;name=E,age=65,sport=Fencing") << 3 + << makeItemXmlAndData("name=A,age=25,sport=Football;name=B,age=35,sport=Athletics;name=C,age=45,sport=Curling", &modelData) + << modelData + << (QList() << qMakePair(0, 2)) + << (QList() << qMakePair(1, 2)); + + QTest::newRow("remove at start, insert at end") + << makeItemXmlAndData("name=A,age=25,sport=Football;name=B,age=35,sport=Athletics;name=C,age=45,sport=Curling") << 3 + << makeItemXmlAndData("name=C,age=45,sport=Curling;name=D,age=55,sport=Golf;name=E,age=65,sport=Fencing", &modelData) + << modelData + << (QList() << qMakePair(1, 2)) + << (QList() << qMakePair(0, 2)); + + QTest::newRow("all data has changed") + << makeItemXmlAndData("name=A,age=25,sport=Football;name=B,age=35") << 2 + << makeItemXmlAndData("name=C,age=45,sport=Curling;name=D,age=55,sport=Golf", &modelData) + << modelData + << (QList() << qMakePair(0, 2)) + << (QList() << qMakePair(0, 2)); +} + +void tst_qquickxmllistmodel::noKeysValueChanges() +{ + // The 'key' roles are 'name' and 'age', as defined in roleKeys.qml. + // If a 'sport' value is changed, the model should not be reloaded, + // since 'sport' is not marked as a key. + + QQmlComponent component(&engine, testFileUrl("roleKeys.qml")); + QListModelInterface *model = qobject_cast(component.create()); + QVERIFY(model != 0); + + QString xml; + + xml = makeItemXmlAndData("name=A,age=25,sport=Football;name=B,age=35,sport=Athletics"); + model->setProperty("xml",xml); + QTRY_COMPARE(model->count(), 2); + + model->setProperty("xml",""); + + QSignalSpy spyInsert(model, SIGNAL(itemsInserted(int,int))); + QSignalSpy spyRemove(model, SIGNAL(itemsRemoved(int,int))); + QSignalSpy spyCount(model, SIGNAL(countChanged())); + + xml = makeItemXmlAndData("name=A,age=25,sport=AussieRules;name=B,age=35,sport=Athletics"); + model->setProperty("xml",xml); + + // wait for the new xml data to be set, and verify no signals were emitted + QTRY_VERIFY(model->data(0, model->roles()[2]).toString() != QLatin1String("Football")); + QCOMPARE(model->data(0, model->roles()[2]).toString(), QLatin1String("AussieRules")); + + QVERIFY(spyInsert.count() == 0); + QVERIFY(spyRemove.count() == 0); + QVERIFY(spyCount.count() == 0); + + QCOMPARE(model->count(), 2); + + delete model; +} + +void tst_qquickxmllistmodel::keysChanged() +{ + // If the key roles change, the next time the data is reloaded, it should + // delete all its data and build a clean model (i.e. same behaviour as + // if no keys are set). + + QQmlComponent component(&engine, testFileUrl("roleKeys.qml")); + QListModelInterface *model = qobject_cast(component.create()); + QVERIFY(model != 0); + + QString xml = makeItemXmlAndData("name=A,age=25,sport=Football;name=B,age=35,sport=Athletics"); + model->setProperty("xml",xml); + QTRY_COMPARE(model->count(), 2); + + model->setProperty("xml",""); + + QSignalSpy spyInsert(model, SIGNAL(itemsInserted(int,int))); + QSignalSpy spyRemove(model, SIGNAL(itemsRemoved(int,int))); + QSignalSpy spyCount(model, SIGNAL(countChanged())); + + QVERIFY(QMetaObject::invokeMethod(model, "disableNameKey")); + model->setProperty("xml",xml); + + QTRY_VERIFY(spyInsert.count() > 0 && spyRemove.count() > 0); + + QCOMPARE(spyInsert.count(), 1); + QCOMPARE(spyInsert[0][0].toInt(), 0); + QCOMPARE(spyInsert[0][1].toInt(), 2); + + QCOMPARE(spyRemove.count(), 1); + QCOMPARE(spyRemove[0][0].toInt(), 0); + QCOMPARE(spyRemove[0][1].toInt(), 2); + + QCOMPARE(spyCount.count(), 0); + + delete model; +} + +void tst_qquickxmllistmodel::threading() +{ + QFETCH(int, xmlDataCount); + + QQmlComponent component(&engine, testFileUrl("roleKeys.qml")); + + QListModelInterface *m1 = qobject_cast(component.create()); + QVERIFY(m1 != 0); + QListModelInterface *m2 = qobject_cast(component.create()); + QVERIFY(m2 != 0); + QListModelInterface *m3 = qobject_cast(component.create()); + QVERIFY(m3 != 0); + + for (int dataCount=0; dataCountsetProperty("xml",makeItemXmlAndData(data1)); + m2->setProperty("xml",makeItemXmlAndData(data2)); + m3->setProperty("xml",makeItemXmlAndData(data3)); + QCoreApplication::processEvents(); + m2->setProperty("xml",makeItemXmlAndData(data2)); + m1->setProperty("xml",makeItemXmlAndData(data1)); + m2->setProperty("xml",makeItemXmlAndData(data2)); + QCoreApplication::processEvents(); + m3->setProperty("xml",makeItemXmlAndData(data3)); + QCoreApplication::processEvents(); + m2->setProperty("xml",makeItemXmlAndData(data2)); + m1->setProperty("xml",makeItemXmlAndData(data1)); + m2->setProperty("xml",makeItemXmlAndData(data2)); + m3->setProperty("xml",makeItemXmlAndData(data3)); + QCoreApplication::processEvents(); + m2->setProperty("xml",makeItemXmlAndData(data2)); + m3->setProperty("xml",makeItemXmlAndData(data3)); + m3->setProperty("xml",makeItemXmlAndData(data3)); + QCoreApplication::processEvents(); + + QTRY_VERIFY(m1->count() == dataCount && m2->count() == dataCount && m3->count() == dataCount); + + for (int i=0; idata(i, m1->roles()[0]).toString(), QString("A" + QString::number(i))); + QCOMPARE(m1->data(i, m1->roles()[1]).toString(), QString("1" + QString::number(i))); + QCOMPARE(m1->data(i, m1->roles()[2]).toString(), QString("Football")); + + QCOMPARE(m2->data(i, m2->roles()[0]).toString(), QString("B" + QString::number(i))); + QCOMPARE(m2->data(i, m2->roles()[1]).toString(), QString("2" + QString::number(i))); + QCOMPARE(m2->data(i, m2->roles()[2]).toString(), QString("Athletics")); + + QCOMPARE(m3->data(i, m3->roles()[0]).toString(), QString("C" + QString::number(i))); + QCOMPARE(m3->data(i, m3->roles()[1]).toString(), QString("3" + QString::number(i))); + QCOMPARE(m3->data(i, m3->roles()[2]).toString(), QString("Curling")); + } + } + + delete m1; + delete m2; + delete m3; +} + +void tst_qquickxmllistmodel::threading_data() +{ + QTest::addColumn("xmlDataCount"); + + QTest::newRow("1") << 1; + QTest::newRow("2") << 2; + QTest::newRow("10") << 10; +} + +void tst_qquickxmllistmodel::propertyChanges() +{ + QQmlComponent component(&engine, testFileUrl("propertychanges.qml")); + QListModelInterface *model = qobject_cast(component.create()); + QVERIFY(model != 0); + QTRY_COMPARE(model->count(), 9); + + QObject *role = model->findChild("role"); + QVERIFY(role); + + QSignalSpy nameSpy(role, SIGNAL(nameChanged())); + QSignalSpy querySpy(role, SIGNAL(queryChanged())); + QSignalSpy isKeySpy(role, SIGNAL(isKeyChanged())); + + role->setProperty("name","size"); + role->setProperty("query","size/string()"); + role->setProperty("isKey",true); + + QCOMPARE(role->property("name").toString(), QString("size")); + QCOMPARE(role->property("query").toString(), QString("size/string()")); + QVERIFY(role->property("isKey").toBool()); + + QCOMPARE(nameSpy.count(),1); + QCOMPARE(querySpy.count(),1); + QCOMPARE(isKeySpy.count(),1); + + role->setProperty("name","size"); + role->setProperty("query","size/string()"); + role->setProperty("isKey",true); + + QCOMPARE(nameSpy.count(),1); + QCOMPARE(querySpy.count(),1); + QCOMPARE(isKeySpy.count(),1); + + QSignalSpy sourceSpy(model, SIGNAL(sourceChanged())); + QSignalSpy xmlSpy(model, SIGNAL(xmlChanged())); + QSignalSpy modelQuerySpy(model, SIGNAL(queryChanged())); + QSignalSpy namespaceDeclarationsSpy(model, SIGNAL(namespaceDeclarationsChanged())); + + model->setProperty("source",QUrl("")); + model->setProperty("xml","PollyParrot12Small"); + model->setProperty("query","/Pets"); + model->setProperty("namespaceDeclarations","declare namespace media=\"http://search.yahoo.com/mrss/\";"); + + QCOMPARE(model->property("source").toUrl(), QUrl("")); + QCOMPARE(model->property("xml").toString(), QString("PollyParrot12Small")); + QCOMPARE(model->property("query").toString(), QString("/Pets")); + QCOMPARE(model->property("namespaceDeclarations").toString(), QString("declare namespace media=\"http://search.yahoo.com/mrss/\";")); + + QTRY_VERIFY(model->count() == 1); + + QCOMPARE(sourceSpy.count(),1); + QCOMPARE(xmlSpy.count(),1); + QCOMPARE(modelQuerySpy.count(),1); + QCOMPARE(namespaceDeclarationsSpy.count(),1); + + model->setProperty("source",QUrl("")); + model->setProperty("xml","PollyParrot12Small"); + model->setProperty("query","/Pets"); + model->setProperty("namespaceDeclarations","declare namespace media=\"http://search.yahoo.com/mrss/\";"); + + QCOMPARE(sourceSpy.count(),1); + QCOMPARE(xmlSpy.count(),1); + QCOMPARE(modelQuerySpy.count(),1); + QCOMPARE(namespaceDeclarationsSpy.count(),1); + + QTRY_VERIFY(model->count() == 1); + delete model; +} + +void tst_qquickxmllistmodel::roleCrash() +{ + // don't crash + QQmlComponent component(&engine, testFileUrl("roleCrash.qml")); + QListModelInterface *model = qobject_cast(component.create()); + QVERIFY(model != 0); + delete model; +} + +QTEST_MAIN(tst_qquickxmllistmodel) + +#include "tst_qquickxmllistmodel.moc" diff --git a/tests/auto/quick/quick.pro b/tests/auto/quick/quick.pro new file mode 100644 index 0000000000..6fba193790 --- /dev/null +++ b/tests/auto/quick/quick.pro @@ -0,0 +1,70 @@ +TEMPLATE = subdirs + +PUBLICTESTS += \ + examples \ + geometry \ + nodes \ + rendernode \ + qquickpixmapcache + +# This test requires the qtconcurrent module +!contains(QT_CONFIG, concurrent):PUBLICTESTS -= qqmlpixmapcache + +PRIVATETESTS += \ + qquickanimations \ + qquickapplication \ + qquickbehaviors \ + qquickfontloader \ + qquickpath \ + qquicksmoothedanimation \ + qquickspringanimation \ + qquickstyledtext \ + qquickstates \ + qquicksystempalette \ + qquicktimer \ + qquickxmllistmodel + +# This test requires the xmlpatterns module +!contains(QT_CONFIG,xmlpatterns):PRIVATETESTS -= qqmlxmllistmodel + +QUICKTESTS = \ + qquickaccessible \ + qquickanchors \ + qquickanimatedimage \ + qquickborderimage \ + qquickcanvas \ + qquickdrag \ + qquickdroparea \ + qquickflickable \ + qquickflipable \ + qquickfocusscope \ + qquickgridview \ + qquickimage \ + qquickitem \ + qquickitem2 \ + qquickitemlayer \ + qquicklistview \ + qquickloader \ + qquickmousearea \ + qquickmultipointtoucharea \ + qquickpathview \ + qquickpincharea \ + qquickpositioners \ + qquickrepeater \ + qquickshadereffect \ + qquickspriteimage \ + qquicktext \ + qquicktextedit \ + qquicktextinput \ + qquickvisualdatamodel \ + qquickview \ + qquickcanvasitem \ + qquickscreen \ + + +SUBDIRS += $$PUBLICTESTS + +contains(QT_CONFIG, private_tests) { + SUBDIRS += $$PRIVATETESTS + SUBDIRS += $$QUICKTESTS +} diff --git a/tests/auto/quick/rendernode/data/MessUpState.qml b/tests/auto/quick/rendernode/data/MessUpState.qml new file mode 100644 index 0000000000..58f6e80a2c --- /dev/null +++ b/tests/auto/quick/rendernode/data/MessUpState.qml @@ -0,0 +1,32 @@ +import QtQuick 2.0 +import Test 1.0 + +Rectangle { + width: 200 + height: 200 + color: "black" + Rectangle { + width: 200 + height: 100 + anchors.centerIn: parent + clip: true + color: "white" + Rectangle { + width: 100 + height: 100 + anchors.centerIn: parent + rotation: 45 + color: "blue" + clip: true + MessUpItem { + anchors.fill: parent + } + Rectangle { + anchors.fill: parent + anchors.margins: -50 + color: "red" + opacity: 0.5 + } + } + } +} diff --git a/tests/auto/quick/rendernode/data/RenderOrder.qml b/tests/auto/quick/rendernode/data/RenderOrder.qml new file mode 100644 index 0000000000..3342756e06 --- /dev/null +++ b/tests/auto/quick/rendernode/data/RenderOrder.qml @@ -0,0 +1,53 @@ +import QtQuick 2.0 +import Test 1.0 + +Rectangle { + id: root + + width: 200 + height: 200 + color: "black" + + Rectangle { + width: 100 + height: 100 + anchors.top: parent.top + anchors.left: parent.left + color: "red" + opacity: 0.5 + } + + Rectangle { + width: 100 + height: 100 + anchors.bottom: parent.bottom + anchors.left: parent.left + color: "red" + } + + ClearItem { + width: 100 + height: 100 + anchors.centerIn: parent + color: "white" + clip: true + } + + Rectangle { + width: 100 + height: 100 + anchors.top: parent.top + anchors.right: parent.right + color: "blue" + } + + Rectangle { + width: 100 + height: 100 + anchors.bottom: parent.bottom + anchors.right: parent.right + color: "blue" + opacity: 0.5 + } + +} diff --git a/tests/auto/quick/rendernode/rendernode.pro b/tests/auto/quick/rendernode/rendernode.pro new file mode 100644 index 0000000000..8484d591e5 --- /dev/null +++ b/tests/auto/quick/rendernode/rendernode.pro @@ -0,0 +1,18 @@ +CONFIG += testcase +TARGET = tst_rendernode +SOURCES += tst_rendernode.cpp + +macx:CONFIG -= app_bundle + +testDataFiles.files = data +testDataFiles.path = . +DEPLOYMENT += testDataFiles + +include(../../shared/util.pri) + +CONFIG += parallel_test +QT += core-private gui-private v8-private qml-private quick-private testlib + +OTHER_FILES += \ + data/RenderOrder.qml \ + data/MessUpState.qml \ diff --git a/tests/auto/quick/rendernode/tst_rendernode.cpp b/tests/auto/quick/rendernode/tst_rendernode.cpp new file mode 100644 index 0000000000..b456a5980e --- /dev/null +++ b/tests/auto/quick/rendernode/tst_rendernode.cpp @@ -0,0 +1,242 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include + +#include +#include +#include +#include + +#include "../../shared/util.h" + +class tst_rendernode: public QQmlDataTest +{ + Q_OBJECT +public: + tst_rendernode(); + + QImage runTest(const QString &url) + { + QQuickView view; + view.setSource(QUrl(url)); + + view.show(); + QTest::qWaitForWindowShown(&view); + + return view.grabFrameBuffer(); + } + +private slots: + void renderOrder(); + void messUpState(); +}; + +class ClearNode : public QSGRenderNode +{ +public: + virtual StateFlags changedStates() + { + return ColorState; + } + + virtual void render(const RenderState &) + { + // If clip has been set, scissoring will make sure the right area is cleared. + glClearColor(color.redF(), color.greenF(), color.blueF(), 1.0f); + glClear(GL_COLOR_BUFFER_BIT); + } + + QColor color; +}; + +class ClearItem : public QQuickItem +{ + Q_OBJECT + Q_PROPERTY(QColor color READ color WRITE setColor NOTIFY colorChanged) +public: + ClearItem() : m_color(Qt::black) + { + setFlag(ItemHasContents, true); + } + + QColor color() const { return m_color; } + void setColor(const QColor &color) + { + if (color == m_color) + return; + m_color = color; + emit colorChanged(); + } + +protected: + virtual QSGNode *updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *) + { + ClearNode *node = static_cast(oldNode); + if (!node) + node = new ClearNode; + node->color = m_color; + return node; + } + +Q_SIGNALS: + void colorChanged(); + +private: + QColor m_color; +}; + +class MessUpNode : public QSGRenderNode +{ +public: + virtual StateFlags changedStates() + { + return StateFlags(DepthState) | StencilState | ScissorState | ColorState | BlendState + | CullState | ViewportState; + } + + virtual void render(const RenderState &) + { + // Don't draw anything, just mess up the state + glViewport(10, 10, 10, 10); + glDisable(GL_SCISSOR_TEST); + glDepthMask(true); + glEnable(GL_DEPTH_TEST); + glDepthFunc(GL_EQUAL); +#if defined(QT_OPENGL_ES) + glClearDepthf(1); +#else + glClearDepth(1); +#endif + glClearStencil(42); + glClearColor(1.0f, 0.5f, 1.0f, 0.0f); + glClear(GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); + glEnable(GL_SCISSOR_TEST); + glScissor(190, 190, 10, 10); + glStencilFunc(GL_EQUAL, 28, 0xff); + glBlendFunc(GL_ZERO, GL_ZERO); + GLint frontFace; + glGetIntegerv(GL_FRONT_FACE, &frontFace); + glFrontFace(frontFace == GL_CW ? GL_CCW : GL_CW); + glEnable(GL_CULL_FACE); + } +}; + +class MessUpItem : public QQuickItem +{ + Q_OBJECT +public: + MessUpItem() + { + setFlag(ItemHasContents, true); + } + +protected: + virtual QSGNode *updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *) + { + MessUpNode *node = static_cast(oldNode); + if (!node) + node = new MessUpNode; + return node; + } +}; + +tst_rendernode::tst_rendernode() +{ + qmlRegisterType("Test", 1, 0, "ClearItem"); + qmlRegisterType("Test", 1, 0, "MessUpItem"); +} + +static void fuzzyCompareColor(QRgb x, QRgb y) +{ + QVERIFY(qAbs(qRed(x) - qRed(y)) < 4); + QVERIFY(qAbs(qGreen(x) - qGreen(y)) < 4); + QVERIFY(qAbs(qBlue(x) - qBlue(y)) < 4); +} + +void tst_rendernode::renderOrder() +{ + QImage fb = runTest(testFile("RenderOrder.qml")); + int x1 = fb.width() / 8; + int x2 = fb.width() * 3 / 8; + int x3 = fb.width() * 5 / 8; + int x4 = fb.width() * 7 / 8; + int y1 = fb.height() / 8; + int y2 = fb.height() * 3 / 8; + int y3 = fb.height() * 5 / 8; + int y4 = fb.height() * 7 / 8; + + fuzzyCompareColor(fb.pixel(x1, y1), qRgb(0x7f, 0x00, 0x00)); + QCOMPARE(fb.pixel(x2, y2), qRgb(0xff, 0xff, 0xff)); + QCOMPARE(fb.pixel(x3, y2), qRgb(0x00, 0x00, 0xff)); + QCOMPARE(fb.pixel(x4, y1), qRgb(0x00, 0x00, 0xff)); + QCOMPARE(fb.pixel(x1, y4), qRgb(0xff, 0x00, 0x00)); + QCOMPARE(fb.pixel(x2, y3), qRgb(0xff, 0xff, 0xff)); + fuzzyCompareColor(fb.pixel(x3, y3), qRgb(0x7f, 0x7f, 0xff)); + fuzzyCompareColor(fb.pixel(x4, y4), qRgb(0x00, 0x00, 0x7f)); +} + +void tst_rendernode::messUpState() +{ + QImage fb = runTest(testFile("MessUpState.qml")); + int x1 = 0; + int x2 = fb.width() / 2; + int x3 = fb.width() - 1; + int y1 = 0; + int y2 = fb.height() * 3 / 16; + int y3 = fb.height() / 2; + int y4 = fb.height() * 13 / 16; + int y5 = fb.height() - 1; + + QCOMPARE(fb.pixel(x1, y3), qRgb(0xff, 0xff, 0xff)); + QCOMPARE(fb.pixel(x3, y3), qRgb(0xff, 0xff, 0xff)); + + QCOMPARE(fb.pixel(x2, y1), qRgb(0x00, 0x00, 0x00)); + QCOMPARE(fb.pixel(x2, y2), qRgb(0x00, 0x00, 0x00)); + fuzzyCompareColor(fb.pixel(x2, y3), qRgb(0x7f, 0x00, 0x7f)); + QCOMPARE(fb.pixel(x2, y4), qRgb(0x00, 0x00, 0x00)); + QCOMPARE(fb.pixel(x2, y5), qRgb(0x00, 0x00, 0x00)); +} + + +QTEST_MAIN(tst_rendernode) + +#include "tst_rendernode.moc" diff --git a/tests/auto/quick/shared/util.pri b/tests/auto/quick/shared/util.pri new file mode 100644 index 0000000000..aa79c7ca98 --- /dev/null +++ b/tests/auto/quick/shared/util.pri @@ -0,0 +1,7 @@ + +HEADERS += $$PWD/visualtestutil.h \ + $$PWD/viewtestutil.h +SOURCES += $$PWD/visualtestutil.cpp \ + $$PWD/viewtestutil.cpp + +DEFINES += QT_QMLTEST_DATADIR=\\\"$${_PRO_FILE_PWD_}/data\\\" diff --git a/tests/auto/quick/shared/viewtestutil.cpp b/tests/auto/quick/shared/viewtestutil.cpp new file mode 100644 index 0000000000..d00a0e2a96 --- /dev/null +++ b/tests/auto/quick/shared/viewtestutil.cpp @@ -0,0 +1,493 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "viewtestutil.h" + +#include + +#include + +template +static void qquickmodelviewstestutil_move(int from, int to, int n, T *items) +{ + if (from > to) { + // Only move forwards - flip if backwards moving + int tfrom = from; + int tto = to; + from = tto; + to = tto+n; + n = tfrom-tto; + } + + T replaced; + int i=0; + typename T::ConstIterator it=items->begin(); it += from+n; + for (; ibegin(); it += from; + for (; ibegin(); t += from; + for (; f != replaced.end(); ++f, ++t) + *t = *f; +} + +QQuickView *QQuickViewTestUtil::createView() +{ + QQuickView *canvas = new QQuickView(0); + canvas->setGeometry(0,0,240,320); + + return canvas; +} + +void QQuickViewTestUtil::flick(QQuickView *canvas, const QPoint &from, const QPoint &to, int duration) +{ + const int pointCount = 5; + QPoint diff = to - from; + + // send press, five equally spaced moves, and release. + QTest::mousePress(canvas, Qt::LeftButton, 0, from); + + for (int i = 0; i < pointCount; ++i) { + QMouseEvent mv(QEvent::MouseMove, from + (i+1)*diff/pointCount, Qt::LeftButton, Qt::LeftButton,Qt::NoModifier); + QGuiApplication::sendEvent(canvas, &mv); + QTest::qWait(duration/pointCount); + QCoreApplication::processEvents(); + } + + QTest::mouseRelease(canvas, Qt::LeftButton, 0, to); + QTest::qWait(50); +} + +QList QQuickViewTestUtil::adjustIndexesForAddDisplaced(const QList &indexes, int index, int count) +{ + QList result; + for (int i=0; i= index) { + num += count; + } + result << num; + } + return result; +} + +QList QQuickViewTestUtil::adjustIndexesForMove(const QList &indexes, int from, int to, int count) +{ + QList result; + for (int i=0; i= from && num < from + count) + num += (to - from); // target + else if (num >= from && num < to + count) + num -= count; // displaced + } else if (from > to) { + if (num >= from && num < from + count) + num -= (from - to); // target + else if (num >= to && num < from + count) + num += count; // displaced + } + result << num; + } + return result; +} + +QList QQuickViewTestUtil::adjustIndexesForRemoveDisplaced(const QList &indexes, int index, int count) +{ + QList result; + for (int i=0; i= index) + num -= count; + result << num; + } + return result; +} + + +QQuickViewTestUtil::QmlListModel::QmlListModel(QObject *parent) + : QListModelInterface(parent) +{ +} + +QQuickViewTestUtil::QmlListModel::~QmlListModel() +{ +} + +QString QQuickViewTestUtil::QmlListModel::name(int index) const +{ + return list.at(index).first; +} + +QString QQuickViewTestUtil::QmlListModel::number(int index) const +{ + return list.at(index).second; +} + +int QQuickViewTestUtil::QmlListModel::count() const +{ + return list.count(); +} + +QList QQuickViewTestUtil::QmlListModel::roles() const +{ + return QList() << Name << Number; +} + +QString QQuickViewTestUtil::QmlListModel::toString(int role) const +{ + switch (role) { + case Name: + return "name"; + case Number: + return "number"; + default: + return ""; + } +} + +QVariant QQuickViewTestUtil::QmlListModel::data(int index, int role) const +{ + if (role==0) + return list.at(index).first; + if (role==1) + return list.at(index).second; + return QVariant(); +} + +QHash QQuickViewTestUtil::QmlListModel::data(int index, const QList &roles) const +{ + QHash returnHash; + + for (int i = 0; i < roles.size(); ++i) { + int role = roles.at(i); + QVariant info; + switch (role) { + case Name: + info = list.at(index).first; + break; + case Number: + info = list.at(index).second; + break; + default: + break; + } + returnHash.insert(role, info); + } + return returnHash; +} + +void QQuickViewTestUtil::QmlListModel::addItem(const QString &name, const QString &number) +{ + list.append(QPair(name, number)); + emit itemsInserted(list.count()-1, 1); +} + +void QQuickViewTestUtil::QmlListModel::insertItem(int index, const QString &name, const QString &number) +{ + list.insert(index, QPair(name, number)); + emit itemsInserted(index, 1); +} + +void QQuickViewTestUtil::QmlListModel::insertItems(int index, const QList > &items) +{ + for (int i=0; i(items[i].first, items[i].second)); + emit itemsInserted(index, items.count()); +} + +void QQuickViewTestUtil::QmlListModel::removeItem(int index) +{ + list.removeAt(index); + emit itemsRemoved(index, 1); +} + +void QQuickViewTestUtil::QmlListModel::removeItems(int index, int count) +{ + int c = count; + while (c--) + list.removeAt(index); + emit itemsRemoved(index, count); +} + +void QQuickViewTestUtil::QmlListModel::moveItem(int from, int to) +{ + list.move(from, to); + emit itemsMoved(from, to, 1); +} + +void QQuickViewTestUtil::QmlListModel::moveItems(int from, int to, int count) +{ + qquickmodelviewstestutil_move(from, to, count, &list); + emit itemsMoved(from, to, count); +} + +void QQuickViewTestUtil::QmlListModel::modifyItem(int index, const QString &name, const QString &number) +{ + list[index] = QPair(name, number); + emit itemsChanged(index, 1, roles()); +} + +void QQuickViewTestUtil::QmlListModel::clear() { + int count = list.count(); + list.clear(); + emit itemsRemoved(0, count); +} + +void QQuickViewTestUtil::QmlListModel::matchAgainst(const QList > &other, const QString &error1, const QString &error2) { + for (int i=0; i roles; + roles[Name] = "name"; + roles[Number] = "number"; + setRoleNames(roles); +} + +int QQuickViewTestUtil::QaimModel::rowCount(const QModelIndex &parent) const +{ + Q_UNUSED(parent); + return list.count(); +} + +QVariant QQuickViewTestUtil::QaimModel::data(const QModelIndex &index, int role) const +{ + QVariant rv; + if (role == Name) + rv = list.at(index.row()).first; + else if (role == Number) + rv = list.at(index.row()).second; + + return rv; +} + +int QQuickViewTestUtil::QaimModel::count() const +{ + return rowCount(); +} + +QString QQuickViewTestUtil::QaimModel::name(int index) const +{ + return list.at(index).first; +} + +QString QQuickViewTestUtil::QaimModel::number(int index) const +{ + return list.at(index).second; +} + +void QQuickViewTestUtil::QaimModel::addItem(const QString &name, const QString &number) +{ + emit beginInsertRows(QModelIndex(), list.count(), list.count()); + list.append(QPair(name, number)); + emit endInsertRows(); +} + +void QQuickViewTestUtil::QaimModel::addItems(const QList > &items) +{ + emit beginInsertRows(QModelIndex(), list.count(), list.count()+items.count()-1); + for (int i=0; i(items[i].first, items[i].second)); + emit endInsertRows(); +} + +void QQuickViewTestUtil::QaimModel::insertItem(int index, const QString &name, const QString &number) +{ + emit beginInsertRows(QModelIndex(), index, index); + list.insert(index, QPair(name, number)); + emit endInsertRows(); +} + +void QQuickViewTestUtil::QaimModel::insertItems(int index, const QList > &items) +{ + emit beginInsertRows(QModelIndex(), index, index+items.count()-1); + for (int i=0; i(items[i].first, items[i].second)); + emit endInsertRows(); +} + +void QQuickViewTestUtil::QaimModel::removeItem(int index) +{ + emit beginRemoveRows(QModelIndex(), index, index); + list.removeAt(index); + emit endRemoveRows(); +} + +void QQuickViewTestUtil::QaimModel::removeItems(int index, int count) +{ + emit beginRemoveRows(QModelIndex(), index, index+count-1); + while (count--) + list.removeAt(index); + emit endRemoveRows(); +} + +void QQuickViewTestUtil::QaimModel::moveItem(int from, int to) +{ + emit beginMoveRows(QModelIndex(), from, from, QModelIndex(), to); + list.move(from, to); + emit endMoveRows(); +} + +void QQuickViewTestUtil::QaimModel::moveItems(int from, int to, int count) +{ + emit beginMoveRows(QModelIndex(), from, from+count-1, QModelIndex(), to > from ? to+count : to); + qquickmodelviewstestutil_move(from, to, count, &list); + emit endMoveRows(); +} + +void QQuickViewTestUtil::QaimModel::modifyItem(int idx, const QString &name, const QString &number) +{ + list[idx] = QPair(name, number); + emit dataChanged(index(idx,0), index(idx,0)); +} + +void QQuickViewTestUtil::QaimModel::clear() +{ + int count = list.count(); + emit beginRemoveRows(QModelIndex(), 0, count-1); + list.clear(); + emit endRemoveRows(); +} + +void QQuickViewTestUtil::QaimModel::reset() +{ + emit beginResetModel(); + emit endResetModel(); +} + +void QQuickViewTestUtil::QaimModel::matchAgainst(const QList > &other, const QString &error1, const QString &error2) { + for (int i=0; i > QQuickViewTestUtil::ListRange::getModelDataValues(const QmlListModel &model) +{ + QList > data; + if (!valid) + return data; + for (int i=0; i > QQuickViewTestUtil::ListRange::getModelDataValues(const QaimModel &model) +{ + QList > data; + if (!valid) + return data; + for (int i=0; i +#include +#include +#include + +QT_FORWARD_DECLARE_CLASS(QQuickView) + +namespace QQuickViewTestUtil +{ + QQuickView *createView(); + + void flick(QQuickView *canvas, const QPoint &from, const QPoint &to, int duration); + + QList adjustIndexesForAddDisplaced(const QList &indexes, int index, int count); + QList adjustIndexesForMove(const QList &indexes, int from, int to, int count); + QList adjustIndexesForRemoveDisplaced(const QList &indexes, int index, int count); + + struct ListChange { + enum { Inserted, Removed, Moved, SetCurrent, SetContentY } type; + int index; + int count; + int to; // Move + qreal pos; // setContentY + + static ListChange insert(int index, int count = 1) { ListChange c = { Inserted, index, count, -1, 0.0 }; return c; } + static ListChange remove(int index, int count = 1) { ListChange c = { Removed, index, count, -1, 0.0 }; return c; } + static ListChange move(int index, int to, int count) { ListChange c = { Moved, index, count, to, 0.0 }; return c; } + static ListChange setCurrent(int index) { ListChange c = { SetCurrent, index, -1, -1, 0.0 }; return c; } + static ListChange setContentY(qreal pos) { ListChange c = { SetContentY, -1, -1, -1, pos }; return c; } + }; + + class QmlListModel : public QListModelInterface + { + Q_OBJECT + public: + QmlListModel(QObject *parent = 0); + ~QmlListModel(); + + enum Roles { Name, Number }; + + QString name(int index) const; + QString number(int index) const; + + int count() const; + + QList roles() const; + QString toString(int role) const; + + QVariant data(int index, int role) const; + QHash data(int index, const QList &roles) const; + + Q_INVOKABLE void addItem(const QString &name, const QString &number); + void insertItem(int index, const QString &name, const QString &number); + void insertItems(int index, const QList > &items); + + void removeItem(int index); + void removeItems(int index, int count); + + void moveItem(int from, int to); + void moveItems(int from, int to, int count); + + void modifyItem(int index, const QString &name, const QString &number); + + void clear(); + + void matchAgainst(const QList > &other, const QString &error1, const QString &error2); + + private: + QList > list; + }; + + class QaimModel : public QAbstractListModel + { + Q_OBJECT + public: + enum Roles { Name = Qt::UserRole+1, Number = Qt::UserRole+2 }; + + QaimModel(QObject *parent=0); + + int rowCount(const QModelIndex &parent=QModelIndex()) const; + QVariant data(const QModelIndex &index, int role=Qt::DisplayRole) const; + + int count() const; + QString name(int index) const; + QString number(int index) const; + + Q_INVOKABLE void addItem(const QString &name, const QString &number); + void addItems(const QList > &items); + void insertItem(int index, const QString &name, const QString &number); + void insertItems(int index, const QList > &items); + + void removeItem(int index); + void removeItems(int index, int count); + + void moveItem(int from, int to); + void moveItems(int from, int to, int count); + + void modifyItem(int idx, const QString &name, const QString &number); + + void clear(); + void reset(); + + void matchAgainst(const QList > &other, const QString &error1, const QString &error2); + + private: + QList > list; + }; + + class ListRange + { + public: + ListRange(); + ListRange(const ListRange &other); + ListRange(int start, int end); + + ~ListRange(); + + ListRange operator+(const ListRange &other) const; + bool operator==(const ListRange &other) const; + bool operator!=(const ListRange &other) const; + + bool isValid() const; + int count() const; + + QList > getModelDataValues(const QmlListModel &model); + QList > getModelDataValues(const QaimModel &model); + + QList indexes; + bool valid; + }; +} + +Q_DECLARE_METATYPE(QList) +Q_DECLARE_METATYPE(QQuickViewTestUtil::ListRange) + +#endif // QQUICKVIEWTESTUTIL_H diff --git a/tests/auto/quick/shared/visualtestutil.cpp b/tests/auto/quick/shared/visualtestutil.cpp new file mode 100644 index 0000000000..8680df10e9 --- /dev/null +++ b/tests/auto/quick/shared/visualtestutil.cpp @@ -0,0 +1,71 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "visualtestutil.h" + +#include +#include + +QQuickItem *QQuickVisualTestUtil::findVisibleChild(QQuickItem *parent, const QString &objectName) +{ + QQuickItem *item = 0; + QList items = parent->findChildren(objectName); + for (int i = 0; i < items.count(); ++i) { + if (items.at(i)->isVisible()) { + item = items.at(i); + break; + } + } + return item; +} + +void QQuickVisualTestUtil::dumpTree(QQuickItem *parent, int depth) +{ + static QString padding(" "); + for (int i = 0; i < parent->childItems().count(); ++i) { + QQuickItem *item = qobject_cast(parent->childItems().at(i)); + if (!item) + continue; + qDebug() << padding.left(depth*2) << item; + dumpTree(item, depth+1); + } +} + diff --git a/tests/auto/quick/shared/visualtestutil.h b/tests/auto/quick/shared/visualtestutil.h new file mode 100644 index 0000000000..9407ff8e8f --- /dev/null +++ b/tests/auto/quick/shared/visualtestutil.h @@ -0,0 +1,112 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QQUICKVISUALTESTUTIL_H +#define QQUICKVISUALTESTUTIL_H + +#include +#include + +namespace QQuickVisualTestUtil +{ + QQuickItem *findVisibleChild(QQuickItem *parent, const QString &objectName); + + void dumpTree(QQuickItem *parent, int depth = 0); + + + /* + Find an item with the specified objectName. If index is supplied then the + item must also evaluate the {index} expression equal to index + */ + template + T *findItem(QQuickItem *parent, const QString &objectName, int index = -1) + { + const QMetaObject &mo = T::staticMetaObject; + for (int i = 0; i < parent->childItems().count(); ++i) { + QQuickItem *item = qobject_cast(parent->childItems().at(i)); + if (!item) + continue; + if (mo.cast(item) && (objectName.isEmpty() || item->objectName() == objectName)) { + if (index != -1) { + QQmlExpression e(qmlContext(item), item, "index"); + if (e.evaluate().toInt() == index) + return static_cast(item); + } else { + return static_cast(item); + } + } + item = findItem(item, objectName, index); + if (item) + return static_cast(item); + } + + return 0; + } + + template + QList findItems(QQuickItem *parent, const QString &objectName, bool visibleOnly = true) + { + QList items; + const QMetaObject &mo = T::staticMetaObject; + for (int i = 0; i < parent->childItems().count(); ++i) { + QQuickItem *item = qobject_cast(parent->childItems().at(i)); + if (!item || (visibleOnly && !item->isVisible())) + continue; + if (mo.cast(item) && (objectName.isEmpty() || item->objectName() == objectName)) + items.append(static_cast(item)); + items += findItems(item, objectName); + } + + return items; + } + + template + QList findItems(QQuickItem *parent, const QString &objectName, const QList &indexes) + { + QList items; + for (int i=0; i(findItem(parent, objectName, indexes[i])); + return items; + } + +} + +#endif // QQUICKVISUALTESTUTIL_H diff --git a/tests/auto/shared/util.cpp b/tests/auto/shared/util.cpp index 5a3d50f695..c015898ab7 100644 --- a/tests/auto/shared/util.cpp +++ b/tests/auto/shared/util.cpp @@ -41,19 +41,19 @@ #include "util.h" -#include -#include -#include -#include +#include +#include +#include +#include #include -QDeclarativeDataTest *QDeclarativeDataTest::m_instance = 0; +QQmlDataTest *QQmlDataTest::m_instance = 0; -QDeclarativeDataTest::QDeclarativeDataTest() : +QQmlDataTest::QQmlDataTest() : #ifdef QT_TESTCASE_BUILDDIR - m_dataDirectory(QTest::qFindTestData("data", QT_DECLARATIVETEST_DATADIR, 0, QT_TESTCASE_BUILDDIR)), + m_dataDirectory(QTest::qFindTestData("data", QT_QMLTEST_DATADIR, 0, QT_TESTCASE_BUILDDIR)), #else - m_dataDirectory(QTest::qFindTestData("data", QT_DECLARATIVETEST_DATADIR, 0)), + m_dataDirectory(QTest::qFindTestData("data", QT_QMLTEST_DATADIR, 0)), #endif m_dataDirectoryUrl(QUrl::fromLocalFile(m_dataDirectory + QLatin1Char('/'))) @@ -61,33 +61,33 @@ QDeclarativeDataTest::QDeclarativeDataTest() : m_instance = this; } -QDeclarativeDataTest::~QDeclarativeDataTest() +QQmlDataTest::~QQmlDataTest() { m_instance = 0; } -void QDeclarativeDataTest::initTestCase() +void QQmlDataTest::initTestCase() { QVERIFY2(!m_dataDirectory.isEmpty(), "'data' directory not found"); m_directory = QFileInfo(m_dataDirectory).absolutePath(); QVERIFY2(QDir::setCurrent(m_directory), qPrintable(QLatin1String("Could not chdir to ") + m_directory)); } -QString QDeclarativeDataTest::testFile(const QString &fileName) const +QString QQmlDataTest::testFile(const QString &fileName) const { if (m_directory.isEmpty()) - qFatal("QDeclarativeDataTest::initTestCase() not called."); + qFatal("QQmlDataTest::initTestCase() not called."); QString result = m_dataDirectory; result += QLatin1Char('/'); result += fileName; return result; } -QByteArray QDeclarativeDataTest::msgComponentError(const QDeclarativeComponent &c, - const QDeclarativeEngine *engine /* = 0 */) +QByteArray QQmlDataTest::msgComponentError(const QQmlComponent &c, + const QQmlEngine *engine /* = 0 */) { QString result; - const QList errors = c.errors(); + const QList errors = c.errors(); QTextStream str(&result); str << "Component '" << c.url().toString() << "' has " << errors.size() << " errors: '"; @@ -98,7 +98,7 @@ QByteArray QDeclarativeDataTest::msgComponentError(const QDeclarativeComponent & } if (!engine) - if (QDeclarativeContext *context = c.creationContext()) + if (QQmlContext *context = c.creationContext()) engine = context->engine(); if (engine) { str << " Import paths: (" << engine->importPathList().join(QStringLiteral(", ")) diff --git a/tests/auto/shared/util.h b/tests/auto/shared/util.h index 9f73d9eb05..5a31ebd719 100644 --- a/tests/auto/shared/util.h +++ b/tests/auto/shared/util.h @@ -39,25 +39,25 @@ ** ****************************************************************************/ -#ifndef QDECLARATIVETESTUTILS_H -#define QDECLARATIVETESTUTILS_H +#ifndef QQMLTESTUTILS_H +#define QQMLTESTUTILS_H #include #include #include #include -QT_FORWARD_DECLARE_CLASS(QDeclarativeComponent) -QT_FORWARD_DECLARE_CLASS(QDeclarativeEngine) +QT_FORWARD_DECLARE_CLASS(QQmlComponent) +QT_FORWARD_DECLARE_CLASS(QQmlEngine) /* Base class for tests with data that are located in a "data" subfolder. */ -class QDeclarativeDataTest : public QObject +class QQmlDataTest : public QObject { Q_OBJECT public: - QDeclarativeDataTest(); - virtual ~QDeclarativeDataTest(); + QQmlDataTest(); + virtual ~QQmlDataTest(); QString testFile(const QString &fileName) const; inline QString testFile(const char *fileName) const @@ -71,20 +71,20 @@ public: inline QUrl dataDirectoryUrl() const { return m_dataDirectoryUrl; } inline QString directory() const { return m_directory; } - static inline QDeclarativeDataTest *instance() { return m_instance; } + static inline QQmlDataTest *instance() { return m_instance; } - static QByteArray msgComponentError(const QDeclarativeComponent &, - const QDeclarativeEngine *engine = 0); + static QByteArray msgComponentError(const QQmlComponent &, + const QQmlEngine *engine = 0); public slots: virtual void initTestCase(); private: - static QDeclarativeDataTest *m_instance; + static QQmlDataTest *m_instance; const QString m_dataDirectory; const QUrl m_dataDirectoryUrl; QString m_directory; }; -#endif // QDECLARATIVETESTUTILS_H +#endif // QQMLTESTUTILS_H diff --git a/tests/auto/shared/util.pri b/tests/auto/shared/util.pri index 916e5fb32a..8e82dcb33b 100644 --- a/tests/auto/shared/util.pri +++ b/tests/auto/shared/util.pri @@ -2,4 +2,4 @@ HEADERS += $$PWD/util.h SOURCES += $$PWD/util.cpp -DEFINES += QT_DECLARATIVETEST_DATADIR=\\\"$${_PRO_FILE_PWD_}/data\\\" +DEFINES += QT_QMLTEST_DATADIR=\\\"$${_PRO_FILE_PWD_}/data\\\" diff --git a/tests/benchmarks/declarative/animation/animation.pro b/tests/benchmarks/declarative/animation/animation.pro deleted file mode 100644 index fc72040a3d..0000000000 --- a/tests/benchmarks/declarative/animation/animation.pro +++ /dev/null @@ -1,10 +0,0 @@ -TEMPLATE = app -TARGET = tst_animation -QT += declarative -macx:CONFIG -= app_bundle - -SOURCES += tst_animation.cpp - -DEFINES += SRCDIR=\\\"$$PWD\\\" - -QT += testlib core-private gui-private declarative-private quick-private v8-private diff --git a/tests/benchmarks/declarative/animation/data/animation.qml b/tests/benchmarks/declarative/animation/data/animation.qml deleted file mode 100644 index c48f5ccbe3..0000000000 --- a/tests/benchmarks/declarative/animation/data/animation.qml +++ /dev/null @@ -1,75 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -ParallelAnimation { - NumberAnimation {} - NumberAnimation {} - NumberAnimation {} - NumberAnimation {} - NumberAnimation {} - NumberAnimation {} - NumberAnimation {} - NumberAnimation {} - NumberAnimation {} - NumberAnimation {} - NumberAnimation {} - NumberAnimation {} - NumberAnimation {} - NumberAnimation {} - NumberAnimation {} - NumberAnimation {} - NumberAnimation {} - NumberAnimation {} - NumberAnimation {} - NumberAnimation {} - NumberAnimation {} - NumberAnimation {} - NumberAnimation {} - NumberAnimation {} - NumberAnimation {} - NumberAnimation {} - NumberAnimation {} - NumberAnimation {} - NumberAnimation {} - NumberAnimation {} -} diff --git a/tests/benchmarks/declarative/animation/tst_animation.cpp b/tests/benchmarks/declarative/animation/tst_animation.cpp deleted file mode 100644 index 6273d9740e..0000000000 --- a/tests/benchmarks/declarative/animation/tst_animation.cpp +++ /dev/null @@ -1,204 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include -#include -#include -#include -#include -#include - -class tst_animation : public QObject -{ - Q_OBJECT -public: - tst_animation(); - -private slots: - void abstractAnimation(); - void bulkValueAnimator(); - void propertyUpdater(); - - void animationtree_qml(); - - void animationelements_data(); - void animationelements(); - - void numberAnimation(); - void numberAnimationStarted(); - void numberAnimationMultipleTargets(); - void numberAnimationEmpty(); - -private: - QDeclarativeEngine engine; -}; - -tst_animation::tst_animation() -{ -} - -inline QUrl TEST_FILE(const QString &filename) -{ - return QUrl::fromLocalFile(QLatin1String(SRCDIR) + QLatin1String("/data/") + filename); -} - -void tst_animation::abstractAnimation() -{ - QBENCHMARK { - QAbstractAnimationJob *animation = new QAbstractAnimationJob; - delete animation; - } -} - -void tst_animation::bulkValueAnimator() -{ - QBENCHMARK { - QDeclarativeBulkValueAnimator *animator = new QDeclarativeBulkValueAnimator; - delete animator; - } -} - -void tst_animation::propertyUpdater() -{ - QBENCHMARK { - QDeclarativeAnimationPropertyUpdater *updater = new QDeclarativeAnimationPropertyUpdater; - delete updater; - } -} - -void tst_animation::animationtree_qml() -{ - QDeclarativeComponent component(&engine, TEST_FILE("animation.qml")); - QObject *obj = component.create(); - delete obj; - - QBENCHMARK { - QObject *obj = component.create(); - delete obj; - } -} - -void tst_animation::animationelements_data() -{ - QTest::addColumn("type"); - - QSet types = QDeclarativeMetaType::qmlTypeNames().toSet(); - foreach (const QString &type, types) { - if (type.contains(QLatin1String("Animation"))) - QTest::newRow(type.toLatin1()) << type; - } - - QTest::newRow("QtQuick/Behavior") << "QtQuick/Behavior"; - QTest::newRow("QtQuick/Transition") << "QtQuick/Transition"; -} - -void tst_animation::animationelements() -{ - QFETCH(QString, type); - QDeclarativeType *t = QDeclarativeMetaType::qmlType(type, 2, 0); - if (!t || !t->isCreatable()) - QSKIP("Non-creatable type"); - - QBENCHMARK { - QObject *obj = t->create(); - delete obj; - } -} - -void tst_animation::numberAnimation() -{ - QDeclarativeComponent component(&engine); - component.setData("import QtQuick 2.0\nItem { Rectangle { id: rect; NumberAnimation { target: rect; property: \"x\"; to: 100; duration: 500; easing.type: Easing.InOutQuad } } }", QUrl()); - - QObject *obj = component.create(); - delete obj; - - QBENCHMARK { - QObject *obj = component.create(); - delete obj; - } -} - -void tst_animation::numberAnimationStarted() -{ - QDeclarativeComponent component(&engine); - component.setData("import QtQuick 2.0\nItem { Rectangle { id: rect; NumberAnimation { target: rect; property: \"x\"; to: 100; duration: 500; easing.type: Easing.InOutQuad; running: true; paused: true } } }", QUrl()); - - QObject *obj = component.create(); - delete obj; - - QBENCHMARK { - QObject *obj = component.create(); - delete obj; - } -} - -void tst_animation::numberAnimationMultipleTargets() -{ - QDeclarativeComponent component(&engine); - component.setData("import QtQuick 2.0\nItem { Rectangle { id: rect; NumberAnimation { target: rect; properties: \"x,y,z,width,height,implicitWidth,implicitHeight\"; to: 100; duration: 500; easing.type: Easing.InOutQuad; running: true; paused: true } } }", QUrl()); - - QObject *obj = component.create(); - delete obj; - - QBENCHMARK { - QObject *obj = component.create(); - delete obj; - } -} - -void tst_animation::numberAnimationEmpty() -{ - QDeclarativeComponent component(&engine); - component.setData("import QtQuick 2.0\nNumberAnimation { }", QUrl()); - - QObject *obj = component.create(); - delete obj; - - QBENCHMARK { - QObject *obj = component.create(); - delete obj; - } -} - -QTEST_MAIN(tst_animation) - -#include "tst_animation.moc" diff --git a/tests/benchmarks/declarative/binding/binding.pro b/tests/benchmarks/declarative/binding/binding.pro deleted file mode 100644 index ba59080232..0000000000 --- a/tests/benchmarks/declarative/binding/binding.pro +++ /dev/null @@ -1,11 +0,0 @@ -CONFIG += testcase -TEMPLATE = app -TARGET = tst_binding -QT += declarative testlib -macx:CONFIG -= app_bundle - -SOURCES += tst_binding.cpp testtypes.cpp -HEADERS += testtypes.h - -# Define SRCDIR equal to test's source directory -DEFINES += SRCDIR=\\\"$$PWD\\\" diff --git a/tests/benchmarks/declarative/binding/data/creation.txt b/tests/benchmarks/declarative/binding/data/creation.txt deleted file mode 100644 index 05704fa341..0000000000 --- a/tests/benchmarks/declarative/binding/data/creation.txt +++ /dev/null @@ -1,9 +0,0 @@ -import Test 1.0 - -MyQmlObject { - id: myObject - property int myValue: 1 - object: myObject - - result: ### -} diff --git a/tests/benchmarks/declarative/binding/data/idproperty.txt b/tests/benchmarks/declarative/binding/data/idproperty.txt deleted file mode 100644 index 4e474ba49a..0000000000 --- a/tests/benchmarks/declarative/binding/data/idproperty.txt +++ /dev/null @@ -1,9 +0,0 @@ -import Test 1.0 - -MyQmlObject { - id: myObject - - MyQmlObject { - result: ### - } -} diff --git a/tests/benchmarks/declarative/binding/data/localproperty.txt b/tests/benchmarks/declarative/binding/data/localproperty.txt deleted file mode 100644 index c7ca0efdb4..0000000000 --- a/tests/benchmarks/declarative/binding/data/localproperty.txt +++ /dev/null @@ -1,5 +0,0 @@ -import Test 1.0 - -MyQmlObject { - result: ### -} diff --git a/tests/benchmarks/declarative/binding/data/objectproperty.txt b/tests/benchmarks/declarative/binding/data/objectproperty.txt deleted file mode 100644 index 06409f2dd1..0000000000 --- a/tests/benchmarks/declarative/binding/data/objectproperty.txt +++ /dev/null @@ -1,8 +0,0 @@ -import Test 1.0 - -MyQmlObject { - id: myObject - object: myObject - - result: ### -} diff --git a/tests/benchmarks/declarative/binding/testtypes.cpp b/tests/benchmarks/declarative/binding/testtypes.cpp deleted file mode 100644 index 31af4f15b0..0000000000 --- a/tests/benchmarks/declarative/binding/testtypes.cpp +++ /dev/null @@ -1,46 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include "testtypes.h" - -void registerTypes() -{ - qmlRegisterType("Test", 1, 0, "MyQmlObject"); -} diff --git a/tests/benchmarks/declarative/binding/testtypes.h b/tests/benchmarks/declarative/binding/testtypes.h deleted file mode 100644 index 1c99842e33..0000000000 --- a/tests/benchmarks/declarative/binding/testtypes.h +++ /dev/null @@ -1,83 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#ifndef TESTTYPES_H -#define TESTTYPES_H - -#include -#include - -class MyQmlObject : public QObject -{ - Q_OBJECT - Q_PROPERTY(int result READ result WRITE setResult) - Q_PROPERTY(int value READ value WRITE setValue NOTIFY valueChanged) - Q_PROPERTY(MyQmlObject *object READ object WRITE setObject NOTIFY objectChanged) - Q_PROPERTY(QDeclarativeListProperty data READ data) - Q_CLASSINFO("DefaultProperty", "data") -public: - MyQmlObject() : m_result(0), m_value(0), m_object(0) {} - - int result() const { return m_result; } - void setResult(int r) { m_result = r; } - - int value() const { return m_value; } - void setValue(int v) { m_value = v; emit valueChanged(); } - - QDeclarativeListProperty data() { return QDeclarativeListProperty(this, m_data); } - - MyQmlObject *object() const { return m_object; } - void setObject(MyQmlObject *o) { m_object = o; emit objectChanged(); } - -signals: - void valueChanged(); - void objectChanged(); - -private: - QList m_data; - int m_result; - int m_value; - MyQmlObject *m_object; -}; -QML_DECLARE_TYPE(MyQmlObject); - -void registerTypes(); - -#endif // TESTTYPES_H diff --git a/tests/benchmarks/declarative/binding/tst_binding.cpp b/tests/benchmarks/declarative/binding/tst_binding.cpp deleted file mode 100644 index 858e99016b..0000000000 --- a/tests/benchmarks/declarative/binding/tst_binding.cpp +++ /dev/null @@ -1,188 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include -#include -#include -#include -#include -#include -#include "testtypes.h" - -class tst_binding : public QObject -{ - Q_OBJECT - -public: - tst_binding(); - virtual ~tst_binding(); - -public slots: - void initTestCase(); - void cleanupTestCase(); - -private slots: - void objectproperty_data(); - void objectproperty(); - void basicproperty_data(); - void basicproperty(); - void creation_data(); - void creation(); - -private: - QDeclarativeEngine engine; - MyQmlObject tstObject; -}; - -tst_binding::tst_binding() -{ -} - -tst_binding::~tst_binding() -{ -} - -void tst_binding::initTestCase() -{ - registerTypes(); - engine.rootContext()->setContextProperty("tstObject", &tstObject); -} - -void tst_binding::cleanupTestCase() -{ -} - -#define COMPONENT(filename, binding) \ - QDeclarativeComponent c(&engine); \ - { \ - QFile f(filename); \ - QVERIFY(f.open(QIODevice::ReadOnly)); \ - QByteArray data = f.readAll(); \ - data.replace("###", binding.toUtf8()); \ - c.setData(data, QUrl()); \ - QVERIFY(c.isReady()); \ - } - -void tst_binding::objectproperty_data() -{ - QTest::addColumn("file"); - QTest::addColumn("binding"); - - QTest::newRow("object.value") << SRCDIR "/data/objectproperty.txt" << "object.value"; - QTest::newRow("object.value + 10") << SRCDIR "/data/objectproperty.txt" << "object.value + 10"; -} - -void tst_binding::objectproperty() -{ - QFETCH(QString, file); - QFETCH(QString, binding); - - COMPONENT(file, binding); - - MyQmlObject object1; - MyQmlObject object2; - - MyQmlObject *object = qobject_cast(c.create()); - QVERIFY(object != 0); - object->setObject(&object2); - - QBENCHMARK { - object->setObject(&object1); - object->setObject(&object2); - } -} - -void tst_binding::basicproperty_data() -{ - QTest::addColumn("file"); - QTest::addColumn("binding"); - - QTest::newRow("value") << SRCDIR "/data/localproperty.txt" << "value"; - QTest::newRow("value + 10") << SRCDIR "/data/localproperty.txt" << "value + 10"; - QTest::newRow("value + value + 10") << SRCDIR "/data/localproperty.txt" << "value + value + 10"; - - QTest::newRow("myObject.value") << SRCDIR "/data/idproperty.txt" << "myObject.value"; - QTest::newRow("myObject.value + 10") << SRCDIR "/data/idproperty.txt" << "myObject.value + 10"; - QTest::newRow("myObject.value + myObject.value + 10") << SRCDIR "/data/idproperty.txt" << "myObject.value + myObject.value + 10"; -} - -void tst_binding::basicproperty() -{ - QFETCH(QString, file); - QFETCH(QString, binding); - - COMPONENT(file, binding); - - MyQmlObject *object = qobject_cast(c.create()); - QVERIFY(object != 0); - object->setValue(10); - - QBENCHMARK { - object->setValue(1); - } -} - -void tst_binding::creation_data() -{ - QTest::addColumn("file"); - QTest::addColumn("binding"); - - QTest::newRow("constant") << SRCDIR "/data/creation.txt" << "10"; - QTest::newRow("ownProperty") << SRCDIR "/data/creation.txt" << "myObject.value"; - QTest::newRow("declaredProperty") << SRCDIR "/data/creation.txt" << "myObject.myValue"; - QTest::newRow("contextProperty") << SRCDIR "/data/creation.txt" << "tstObject.value"; -} - -void tst_binding::creation() -{ - QFETCH(QString, file); - QFETCH(QString, binding); - - COMPONENT(file, binding); - - QBENCHMARK { - QObject *o = c.create(); - delete o; - } -} - -QTEST_MAIN(tst_binding) -#include "tst_binding.moc" diff --git a/tests/benchmarks/declarative/compilation/compilation.pro b/tests/benchmarks/declarative/compilation/compilation.pro deleted file mode 100644 index 44ea3d0c68..0000000000 --- a/tests/benchmarks/declarative/compilation/compilation.pro +++ /dev/null @@ -1,11 +0,0 @@ -CONFIG += testcase -TEMPLATE = app -TARGET = tst_compilation -QT += declarative testlib -macx:CONFIG -= app_bundle - -CONFIG += release - -SOURCES += tst_compilation.cpp - -DEFINES += SRCDIR=\\\"$$PWD\\\" diff --git a/tests/benchmarks/declarative/compilation/data/BoomBlock.qml b/tests/benchmarks/declarative/compilation/data/BoomBlock.qml deleted file mode 100644 index 58ef377b71..0000000000 --- a/tests/benchmarks/declarative/compilation/data/BoomBlock.qml +++ /dev/null @@ -1,106 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 -import Qt.labs.particles 1.0 - -Item { - id: block - property bool dying: false - property bool spawned: false - property int type: 0 - property int targetX: 0 - property int targetY: 0 - - SpringFollow on x { enabled: spawned; to: targetX; spring: 2; damping: 0.2 } - SpringFollow on y { to: targetY; spring: 2; damping: 0.2 } - - Image { - id: img - source: { - if(type == 0){ - "pics/redStone.png"; - } else if(type == 1) { - "pics/blueStone.png"; - } else { - "pics/greenStone.png"; - } - } - opacity: 0 - Behavior on opacity { NumberAnimation { duration: 200 } } - anchors.fill: parent - } - - Particles { - id: particles - - width: 1; height: 1 - anchors.centerIn: parent - - emissionRate: 0 - lifeSpan: 700; lifeSpanDeviation: 600 - angle: 0; angleDeviation: 360; - velocity: 100; velocityDeviation: 30 - source: { - if(type == 0){ - "pics/redStar.png"; - } else if (type == 1) { - "pics/blueStar.png"; - } else { - "pics/greenStar.png"; - } - } - } - - states: [ - State { - name: "AliveState"; when: spawned == true && dying == false - PropertyChanges { target: img; opacity: 1 } - }, - - State { - name: "DeathState"; when: dying == true - StateChangeScript { script: particles.burst(50); } - PropertyChanges { target: img; opacity: 0 } - StateChangeScript { script: block.destroy(1000); } - } - ] -} diff --git a/tests/benchmarks/declarative/compilation/tst_compilation.cpp b/tests/benchmarks/declarative/compilation/tst_compilation.cpp deleted file mode 100644 index b9c619af31..0000000000 --- a/tests/benchmarks/declarative/compilation/tst_compilation.cpp +++ /dev/null @@ -1,160 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include - -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include - -class tst_compilation : public QObject -{ - Q_OBJECT -public: - tst_compilation(); - -private slots: - void boomblock(); - - void jsparser_data(); - void jsparser(); - - void scriptparser_data(); - void scriptparser(); - -private: - QDeclarativeEngine engine; -}; - -tst_compilation::tst_compilation() -{ -} - -inline QUrl TEST_FILE(const QString &filename) -{ - return QUrl::fromLocalFile(QLatin1String(SRCDIR) + QLatin1String("/data/") + filename); -} - -void tst_compilation::boomblock() -{ - QFile f(SRCDIR + QLatin1String("/data/BoomBlock.qml")); - QVERIFY(f.open(QIODevice::ReadOnly)); - QByteArray data = f.readAll(); - - //get rid of initialization effects - { - QDeclarativeComponent c(&engine); - c.setData(data, QUrl()); - } - - QBENCHMARK { - QDeclarativeComponent c(&engine); - c.setData(data, QUrl()); -// QVERIFY(c.isReady()); - } -} - -void tst_compilation::jsparser_data() -{ - QTest::addColumn("file"); - - QTest::newRow("boomblock") << QString(SRCDIR + QLatin1String("/data/BoomBlock.qml")); -} - -void tst_compilation::jsparser() -{ - QFETCH(QString, file); - - QFile f(file); - QVERIFY(f.open(QIODevice::ReadOnly)); - QByteArray data = f.readAll(); - - QTextStream stream(data, QIODevice::ReadOnly); - const QString code = stream.readAll(); - - QBENCHMARK { - QDeclarativeJS::Engine engine; - QDeclarativeJS::NodePool nodePool(file, &engine); - - QDeclarativeJS::Lexer lexer(&engine); - lexer.setCode(code, -1); - - QDeclarativeJS::Parser parser(&engine); - parser.parse(); - parser.ast(); - } -} - -void tst_compilation::scriptparser_data() -{ - QTest::addColumn("file"); - - QTest::newRow("boomblock") << QString(SRCDIR + QLatin1String("/data/BoomBlock.qml")); -} - -void tst_compilation::scriptparser() -{ - QFETCH(QString, file); - - QFile f(file); - QVERIFY(f.open(QIODevice::ReadOnly)); - QByteArray data = f.readAll(); - - QUrl url = QUrl::fromLocalFile(file); - - QBENCHMARK { - QDeclarativeScript::Parser parser; - parser.parse(data, url); - parser.tree(); - } -} - -QTEST_MAIN(tst_compilation) - -#include "tst_compilation.moc" diff --git a/tests/benchmarks/declarative/creation/creation.pro b/tests/benchmarks/declarative/creation/creation.pro deleted file mode 100644 index 6d0d9d7e8f..0000000000 --- a/tests/benchmarks/declarative/creation/creation.pro +++ /dev/null @@ -1,10 +0,0 @@ -CONFIG += testcase -TEMPLATE = app -TARGET = tst_creation -macx:CONFIG -= app_bundle - -SOURCES += tst_creation.cpp - -DEFINES += SRCDIR=\\\"$$PWD\\\" - -QT += core-private gui-private declarative-private qtquick1-private widgets testlib diff --git a/tests/benchmarks/declarative/creation/data/item.qml b/tests/benchmarks/declarative/creation/data/item.qml deleted file mode 100644 index ebc50ceb13..0000000000 --- a/tests/benchmarks/declarative/creation/data/item.qml +++ /dev/null @@ -1,75 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -Item { - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} - Item {} -} diff --git a/tests/benchmarks/declarative/creation/data/qobject.qml b/tests/benchmarks/declarative/creation/data/qobject.qml deleted file mode 100644 index 4b59535bcb..0000000000 --- a/tests/benchmarks/declarative/creation/data/qobject.qml +++ /dev/null @@ -1,45 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -QtObject { -} diff --git a/tests/benchmarks/declarative/creation/tst_creation.cpp b/tests/benchmarks/declarative/creation/tst_creation.cpp deleted file mode 100644 index 809271e4d2..0000000000 --- a/tests/benchmarks/declarative/creation/tst_creation.cpp +++ /dev/null @@ -1,361 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -class tst_creation : public QObject -{ - Q_OBJECT -public: - tst_creation(); - -private slots: - void qobject_cpp(); - void qobject_qml(); - void qobject_qmltype(); - void qobject_alloc(); - - void qobject_10flat_qml(); - void qobject_10flat_cpp(); - - void qobject_10tree_qml(); - void qobject_10tree_cpp(); - - void itemtree_notree_cpp(); - void itemtree_objtree_cpp(); - void itemtree_cpp(); - void itemtree_data_cpp(); - void itemtree_qml(); - void itemtree_scene_cpp(); - - void elements_data(); - void elements(); - -private: - QDeclarativeEngine engine; -}; - -class TestType : public QObject -{ -Q_OBJECT -Q_PROPERTY(QDeclarativeListProperty resources READ resources) -Q_CLASSINFO("DefaultProperty", "resources") -public: - TestType(QObject *parent = 0) - : QObject(parent) {} - - QDeclarativeListProperty resources() { - return QDeclarativeListProperty(this, 0, resources_append); - } - - static void resources_append(QDeclarativeListProperty *p, QObject *o) { - o->setParent(p->object); - } -}; - -tst_creation::tst_creation() -{ - qmlRegisterType("Qt.test", 1, 0, "TestType"); - - //get rid of initialization effects - QDeclarative1TextInput te; -} - -inline QUrl TEST_FILE(const QString &filename) -{ - return QUrl::fromLocalFile(QLatin1String(SRCDIR) + QLatin1String("/data/") + filename); -} - -void tst_creation::qobject_cpp() -{ - QBENCHMARK { - QObject *obj = new QObject; - delete obj; - } -} - -void tst_creation::qobject_qml() -{ - QDeclarativeComponent component(&engine); - component.setData("import QtQuick 2.0\nQtObject {}", QUrl()); - QObject *obj = component.create(); - delete obj; - - QBENCHMARK { - QObject *obj = component.create(); - delete obj; - } -} - -void tst_creation::qobject_10flat_qml() -{ - QDeclarativeComponent component(&engine); - component.setData("import Qt.test 1.0\nTestType { resources: [ TestType{},TestType{},TestType{},TestType{},TestType{},TestType{},TestType{},TestType{},TestType{},TestType{} ] }", QUrl()); - QObject *obj = component.create(); - delete obj; - - QBENCHMARK { - QObject *obj = component.create(); - delete obj; - } -} - -void tst_creation::qobject_10flat_cpp() -{ - QBENCHMARK { - QObject *item = new TestType; - new TestType(item); - new TestType(item); - new TestType(item); - new TestType(item); - new TestType(item); - new TestType(item); - new TestType(item); - new TestType(item); - new TestType(item); - new TestType(item); - delete item; - } -} - -void tst_creation::qobject_10tree_qml() -{ - QDeclarativeComponent component(&engine); - component.setData("import Qt.test 1.0\nTestType { TestType{ TestType { TestType{ TestType{ TestType{ TestType{ TestType{ TestType{ TestType{ TestType{ } } } } } } } } } } }", QUrl()); - - QObject *obj = component.create(); - delete obj; - - QBENCHMARK { - QObject *obj = component.create(); - delete obj; - } -} - -void tst_creation::qobject_10tree_cpp() -{ - QBENCHMARK { - QObject *item = new TestType; - QObject *root = item; - item = new TestType(item); - item = new TestType(item); - item = new TestType(item); - item = new TestType(item); - item = new TestType(item); - item = new TestType(item); - item = new TestType(item); - item = new TestType(item); - item = new TestType(item); - item = new TestType(item); - delete root; - } -} - -void tst_creation::qobject_qmltype() -{ - QDeclarativeType *t = QDeclarativeMetaType::qmlType("QtQuick/QtObject", 2, 0); - - QBENCHMARK { - QObject *obj = t->create(); - delete obj; - } -} - -struct QObjectFakeData { - char data[sizeof(QObjectPrivate)]; -}; - -struct QObjectFake { - QObjectFake(); - virtual ~QObjectFake(); -private: - QObjectFakeData *d; -}; - -QObjectFake::QObjectFake() -{ - d = new QObjectFakeData; -} - -QObjectFake::~QObjectFake() -{ - delete d; -} - -void tst_creation::qobject_alloc() -{ - QBENCHMARK { - QObjectFake *obj = new QObjectFake; - delete obj; - } -} - -struct QDeclarativeGraphics_Derived : public QObject -{ - void setParent_noEvent(QObject *parent) { - bool sce = d_ptr->sendChildEvents; - d_ptr->sendChildEvents = false; - setParent(parent); - d_ptr->sendChildEvents = sce; - } -}; - -inline void QDeclarativeGraphics_setParent_noEvent(QObject *object, QObject *parent) -{ - static_cast(object)->setParent_noEvent(parent); -} - -void tst_creation::itemtree_notree_cpp() -{ - QBENCHMARK { - QDeclarativeItem *item = new QDeclarativeItem; - for (int i = 0; i < 30; ++i) { - QDeclarativeItem *child = new QDeclarativeItem; - Q_UNUSED(child); - } - delete item; - } -} - -void tst_creation::itemtree_objtree_cpp() -{ - QBENCHMARK { - QDeclarativeItem *item = new QDeclarativeItem; - for (int i = 0; i < 30; ++i) { - QDeclarativeItem *child = new QDeclarativeItem; - QDeclarativeGraphics_setParent_noEvent(child,item); - } - delete item; - } -} - -void tst_creation::itemtree_cpp() -{ - QBENCHMARK { - QDeclarativeItem *item = new QDeclarativeItem; - for (int i = 0; i < 30; ++i) { - QDeclarativeItem *child = new QDeclarativeItem; - QDeclarativeGraphics_setParent_noEvent(child,item); - child->setParentItem(item); - } - delete item; - } -} - -void tst_creation::itemtree_data_cpp() -{ - QBENCHMARK { - QDeclarativeItem *item = new QDeclarativeItem; - for (int i = 0; i < 30; ++i) { - QDeclarativeItem *child = new QDeclarativeItem; - QDeclarativeGraphics_setParent_noEvent(child,item); - QDeclarativeListReference ref(item, "data"); - ref.append(child); - } - delete item; - } -} - -void tst_creation::itemtree_qml() -{ - QDeclarativeComponent component(&engine, TEST_FILE("item.qml")); - QObject *obj = component.create(); - delete obj; - - QBENCHMARK { - QObject *obj = component.create(); - delete obj; - } -} - -void tst_creation::itemtree_scene_cpp() -{ - QGraphicsScene scene; - QDeclarativeItem *root = new QDeclarativeItem; - scene.addItem(root); - QBENCHMARK { - QDeclarativeItem *item = new QDeclarativeItem; - for (int i = 0; i < 30; ++i) { - QDeclarativeItem *child = new QDeclarativeItem; - QDeclarativeGraphics_setParent_noEvent(child,item); - child->setParentItem(item); - } - item->setParentItem(root); - delete item; - } - delete root; -} - -void tst_creation::elements_data() -{ - QTest::addColumn("type"); - - QList types = QDeclarativeMetaType::qmlTypeNames(); - foreach (QString type, types) - QTest::newRow(type.toLatin1()) << type; -} - -void tst_creation::elements() -{ - QFETCH(QString, type); - QDeclarativeType *t = QDeclarativeMetaType::qmlType(type, 2, 0); - if (!t || !t->isCreatable()) - QSKIP("Non-creatable type"); - - QBENCHMARK { - QObject *obj = t->create(); - delete obj; - } -} - -QTEST_MAIN(tst_creation) - -#include "tst_creation.moc" diff --git a/tests/benchmarks/declarative/declarative.pro b/tests/benchmarks/declarative/declarative.pro deleted file mode 100644 index 820d84b0a2..0000000000 --- a/tests/benchmarks/declarative/declarative.pro +++ /dev/null @@ -1,18 +0,0 @@ -TEMPLATE = subdirs - -SUBDIRS += \ - binding \ - creation \ - javascript \ - holistic \ - pointers \ - qdeclarativecomponent \ - qdeclarativeimage \ - qdeclarativemetaproperty \ - script \ - qmltime \ - js - -contains(QT_CONFIG, opengl): SUBDIRS += painting - -include(../trusted-benchmarks.pri) diff --git a/tests/benchmarks/declarative/holistic/data/dynamicTargets/DynamicFour.qml b/tests/benchmarks/declarative/holistic/data/dynamicTargets/DynamicFour.qml deleted file mode 100644 index ccccc371ac..0000000000 --- a/tests/benchmarks/declarative/holistic/data/dynamicTargets/DynamicFour.qml +++ /dev/null @@ -1,78 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -Item { - id: root - property int dynamicWidth: 100 - property int dynamicHeight: rect1.height + rect2.height - property int widthSignaledProperty: 10 - property int heightSignaledProperty: 10 - - Rectangle { - id: rect1 - width: root.dynamicWidth + 20 - height: width + (5*3) - 8 + (width/9) - color: "red" - border.color: "black" - border.width: 5 - radius: 10 - } - - Rectangle { - id: rect2 - width: rect1.width - 50 - height: width + (5*4) - 6 + (width/3) - color: "red" - border.color: "black" - border.width: 5 - radius: 10 - } - - onDynamicWidthChanged: { - widthSignaledProperty = widthSignaledProperty + (6*5) - 2; - } - - onDynamicHeightChanged: { - heightSignaledProperty = widthSignaledProperty + heightSignaledProperty + (5*3) - 7; - } -} diff --git a/tests/benchmarks/declarative/holistic/data/dynamicTargets/DynamicOne.qml b/tests/benchmarks/declarative/holistic/data/dynamicTargets/DynamicOne.qml deleted file mode 100644 index 154f9db9a3..0000000000 --- a/tests/benchmarks/declarative/holistic/data/dynamicTargets/DynamicOne.qml +++ /dev/null @@ -1,56 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -Item { - id: root - property int dynamicWidth: 10 - - Rectangle { - width: 100 - height: root.dynamicWidth + (5*3) - 8 + (root.dynamicWidth/10) - color: "red" - border.color: "black" - border.width: 5 - radius: 10 - } -} diff --git a/tests/benchmarks/declarative/holistic/data/dynamicTargets/DynamicThree.qml b/tests/benchmarks/declarative/holistic/data/dynamicTargets/DynamicThree.qml deleted file mode 100644 index 064ba57254..0000000000 --- a/tests/benchmarks/declarative/holistic/data/dynamicTargets/DynamicThree.qml +++ /dev/null @@ -1,61 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -Item { - id: root - property int dynamicWidth: 10 - property int widthSignaledProperty: 20 - - Rectangle { - width: 100 - height: root.dynamicWidth + (5*3) - 8 + (root.dynamicWidth/10) - color: "red" - border.color: "black" - border.width: 5 - radius: 10 - } - - onDynamicWidthChanged: { - widthSignaledProperty = dynamicWidth + (20/4) + 7 - 1; - } -} diff --git a/tests/benchmarks/declarative/holistic/data/dynamicTargets/DynamicTwo.qml b/tests/benchmarks/declarative/holistic/data/dynamicTargets/DynamicTwo.qml deleted file mode 100644 index a3aac3ebd6..0000000000 --- a/tests/benchmarks/declarative/holistic/data/dynamicTargets/DynamicTwo.qml +++ /dev/null @@ -1,68 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -Item { - id: root - property int dynamicWidth: 100 - property int dynamicHeight: rect1.height + rect2.height - - Rectangle { - id: rect1 - width: root.dynamicWidth + 20 - height: width + (5*3) - 8 + (width/9) - color: "red" - border.color: "black" - border.width: 5 - radius: 10 - } - - Rectangle { - id: rect2 - width: rect1.width - 50 - height: width + (5*4) - 6 + (width/3) - color: "red" - border.color: "black" - border.width: 5 - radius: 10 - } -} diff --git a/tests/benchmarks/declarative/holistic/data/jsImports/Mlbsi.qml b/tests/benchmarks/declarative/holistic/data/jsImports/Mlbsi.qml deleted file mode 100644 index 854cc3258d..0000000000 --- a/tests/benchmarks/declarative/holistic/data/jsImports/Mlbsi.qml +++ /dev/null @@ -1,49 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -import "mlbsi.js" as MlbsiJs - -Item { - id: testQtObject - property int importedScriptFunctionValue: MlbsiJs.testFunc(20) -} diff --git a/tests/benchmarks/declarative/holistic/data/jsImports/Mldsi.qml b/tests/benchmarks/declarative/holistic/data/jsImports/Mldsi.qml deleted file mode 100644 index 919fce1c46..0000000000 --- a/tests/benchmarks/declarative/holistic/data/jsImports/Mldsi.qml +++ /dev/null @@ -1,49 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -import "mldsi.js" as MldsiJs - -Item { - id: testQtObject - property int importedScriptFunctionValue: MldsiJs.testFunc(20) -} diff --git a/tests/benchmarks/declarative/holistic/data/jsImports/Mlsi.qml b/tests/benchmarks/declarative/holistic/data/jsImports/Mlsi.qml deleted file mode 100644 index 74451f85fd..0000000000 --- a/tests/benchmarks/declarative/holistic/data/jsImports/Mlsi.qml +++ /dev/null @@ -1,49 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -import "mlsi.js" as MlsiJs - -Item { - id: testQtObject - property int importedScriptFunctionValue: MlsiJs.testFunc(20) -} diff --git a/tests/benchmarks/declarative/holistic/data/jsImports/ModuleBm.qml b/tests/benchmarks/declarative/holistic/data/jsImports/ModuleBm.qml deleted file mode 100644 index 18ef8a2599..0000000000 --- a/tests/benchmarks/declarative/holistic/data/jsImports/ModuleBm.qml +++ /dev/null @@ -1,49 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -import "moduleBm.js" as ModuleBmJs - -Item { - id: testQtObject - property int importedScriptFunctionValue: ModuleBmJs.testFunc(20) -} diff --git a/tests/benchmarks/declarative/holistic/data/jsImports/Msbsi.qml b/tests/benchmarks/declarative/holistic/data/jsImports/Msbsi.qml deleted file mode 100644 index d7a8b74dd1..0000000000 --- a/tests/benchmarks/declarative/holistic/data/jsImports/Msbsi.qml +++ /dev/null @@ -1,49 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -import "msbsi.js" as MsbsiJs - -Item { - id: testQtObject - property int importedScriptFunctionValue: MsbsiJs.testFunc(20) -} diff --git a/tests/benchmarks/declarative/holistic/data/jsImports/Msdsi.qml b/tests/benchmarks/declarative/holistic/data/jsImports/Msdsi.qml deleted file mode 100644 index 266a26ef8e..0000000000 --- a/tests/benchmarks/declarative/holistic/data/jsImports/Msdsi.qml +++ /dev/null @@ -1,49 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -import "msdsi.js" as MsdsiJs - -Item { - id: testQtObject - property int importedScriptFunctionValue: MsdsiJs.testFunc(20) -} diff --git a/tests/benchmarks/declarative/holistic/data/jsImports/Mssi.qml b/tests/benchmarks/declarative/holistic/data/jsImports/Mssi.qml deleted file mode 100644 index e589981252..0000000000 --- a/tests/benchmarks/declarative/holistic/data/jsImports/Mssi.qml +++ /dev/null @@ -1,49 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -import "mssi.js" as MssiJs - -Item { - id: testQtObject - property int importedScriptFunctionValue: MssiJs.testFunc(20) -} diff --git a/tests/benchmarks/declarative/holistic/data/jsImports/PragmaBm.qml b/tests/benchmarks/declarative/holistic/data/jsImports/PragmaBm.qml deleted file mode 100644 index f5753af88b..0000000000 --- a/tests/benchmarks/declarative/holistic/data/jsImports/PragmaBm.qml +++ /dev/null @@ -1,55 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -import "pragmaBmOne.js" as PragmaBmOneJs -import "pragmaBmTwo.js" as PragmaBmTwoJs - -Item { - id: testQtObject - - // value = 20 + 2 + 9 + (nbr times shared testFunc has been called previously == 0) - property int importedScriptFunctionValueOne: PragmaBmOneJs.testFuncOne(20) - - // value = 20 + 3 + 9 + (nbr times shared testFunc has been called previously == 1) - property int importedScriptFunctionValueTwo: PragmaBmTwoJs.testFuncTwo(20) -} diff --git a/tests/benchmarks/declarative/holistic/data/jsImports/PragmaModuleBm.qml b/tests/benchmarks/declarative/holistic/data/jsImports/PragmaModuleBm.qml deleted file mode 100644 index 8e1baa8572..0000000000 --- a/tests/benchmarks/declarative/holistic/data/jsImports/PragmaModuleBm.qml +++ /dev/null @@ -1,51 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -import "pragmaModuleBm.js" as PragmaModuleBmJs - -Item { - id: testQtObject - - // value = 20 + (Qt.test.Enum3 == 2) + 9 + (nbr times shared testFunc has been called previously = 0) + 9 + (nbr times shared testFunc has been called previously = 1) - property int importedScriptFunctionValue: PragmaModuleBmJs.testFuncThree(20) -} diff --git a/tests/benchmarks/declarative/holistic/data/jsImports/Slsi.qml b/tests/benchmarks/declarative/holistic/data/jsImports/Slsi.qml deleted file mode 100644 index aa21358b47..0000000000 --- a/tests/benchmarks/declarative/holistic/data/jsImports/Slsi.qml +++ /dev/null @@ -1,49 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -import "slsi.js" as SlsiJs - -Item { - id: testQtObject - property int importedScriptFunctionValue: SlsiJs.testFunc(20) -} diff --git a/tests/benchmarks/declarative/holistic/data/jsImports/Sssi.qml b/tests/benchmarks/declarative/holistic/data/jsImports/Sssi.qml deleted file mode 100644 index 0ed7a3ee72..0000000000 --- a/tests/benchmarks/declarative/holistic/data/jsImports/Sssi.qml +++ /dev/null @@ -1,49 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -import "sssi.js" as SssiJs - -Item { - id: testQtObject - property int importedScriptFunctionValue: SssiJs.testFunc(20) -} diff --git a/tests/benchmarks/declarative/holistic/data/jsImports/mlbsi.js b/tests/benchmarks/declarative/holistic/data/jsImports/mlbsi.js deleted file mode 100644 index 36a5fea77f..0000000000 --- a/tests/benchmarks/declarative/holistic/data/jsImports/mlbsi.js +++ /dev/null @@ -1,133 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -// This JavaScript file is a single, small, imported script. -// It imports many other (non-nested) single, small, scripts. - -.import "mlbsi1.js" as Mlbsi1 -.import "mlbsi2.js" as Mlbsi2 -.import "mlbsi3.js" as Mlbsi3 -.import "mlbsi4.js" as Mlbsi4 -.import "mlbsi5.js" as Mlbsi5 -.import "mlbsi6.js" as Mlbsi6 -.import "mlbsi7.js" as Mlbsi7 -.import "mlbsi8.js" as Mlbsi8 -.import "mlbsi9.js" as Mlbsi9 -.import "mlbsi10.js" as Mlbsi10 -.import "mlbsi11.js" as Mlbsi11 -.import "mlbsi12.js" as Mlbsi12 -.import "mlbsi13.js" as Mlbsi13 -.import "mlbsi14.js" as Mlbsi14 -.import "mlbsi15.js" as Mlbsi15 - -function testFunc(seedValue) { - var firstFactor = calculateFirstFactor(seedValue); - var secondFactor = calculateSecondFactor(seedValue); - var modificationTerm = calculateModificationTerm(seedValue); - - // do some regexp matching - var someString = "This is a random string which we'll perform regular expression matching on to reduce considerably. This is meant to be part of a complex javascript expression whose evaluation takes considerably longer than the creation cost of QScriptValue."; - var regexpPattern = new RegExp("is", "i"); - var regexpOutputLength = 0; - var temp = regexpPattern.exec(someString); - while (temp == "is") { - regexpOutputLength += 4; - regexpOutputLength *= 2; - temp = regexpPattern.exec(someString); - if (regexpOutputLength > (seedValue * 3)) { - temp = "break"; - } - } - - // spin in a for loop for a while - var i = 0; - var j = 0; - var cumulativeTotal = 3; - for (i = 20; i > 1; i--) { - for (j = 31; j > 5; j--) { - var branchVariable = i + j; - if (branchVariable % 3 == 0) { - cumulativeTotal -= secondFactor; - } else { - cumulativeTotal += firstFactor; - } - - if (cumulativeTotal > (seedValue * 50)) { - break; - } - } - } - var retn = cumulativeTotal * 0.53; - retn += Mlbsi1.testFunc(seedValue); - retn += Mlbsi2.testFunc(seedValue); - retn += Mlbsi3.testFunc(seedValue); - retn += Mlbsi4.testFunc(seedValue); - retn += Mlbsi5.testFunc(seedValue); - retn += Mlbsi6.testFunc(retn); - retn += Mlbsi7.testFunc(seedValue); - retn += Mlbsi8.testFunc(seedValue); - retn += Mlbsi9.testFunc(retn); - retn += Mlbsi10.testFunc(seedValue); - retn += Mlbsi11.testFunc(seedValue); - retn += Mlbsi12.testFunc(seedValue); - retn += Mlbsi13.testFunc(seedValue); - retn += Mlbsi14.testFunc(seedValue); - retn += Mlbsi15.testFunc(seedValue); - return retn; -} - -function calculateFirstFactor(seedValue) { - var firstFactor = (0.45 * (9.3 / 3.1) - 0.90); - firstFactor *= (1 + (0.000017 / seedValue)); - return firstFactor; -} - -function calculateSecondFactor(seedValue) { - var secondFactor = 0.78 * (6.3 / 2.1) - (0.39 * 4); - secondFactor *= (1 + (0.000017 / seedValue)); - return secondFactor; -} - -function calculateModificationTerm(seedValue) { - var modificationTerm = (12 + (9*7) - 54 + 16 - ((calculateFirstFactor(seedValue) * seedValue) / 3) + (4*calculateSecondFactor(seedValue) * seedValue * 1.33)) + (calculateSecondFactor(seedValue) * seedValue); - modificationTerm = modificationTerm + (33/2) + 19 - (9*2) - (61*3) + 177; - return modificationTerm; -} diff --git a/tests/benchmarks/declarative/holistic/data/jsImports/mlbsi1.js b/tests/benchmarks/declarative/holistic/data/jsImports/mlbsi1.js deleted file mode 100644 index 459451609b..0000000000 --- a/tests/benchmarks/declarative/holistic/data/jsImports/mlbsi1.js +++ /dev/null @@ -1,108 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -// This JavaScript file is a single, large, imported script. -// It doesn't import any other scripts. -// It is imported from another script. - -function testFunc(seedValue) { - var retn = 5; - retn += (seedValue * 0.145); - var firstFactor = calculateFirstFactor(seedValue); - var secondFactor = calculateSecondFactor(seedValue); - var modificationTerm = calculateModificationTerm(seedValue); - - // do some regexp matching - var someString = "This is a random string which we'll perform regular expression matching on to reduce considerably. This is meant to be part of a complex javascript expression whose evaluation takes considerably longer than the creation cost of QScriptValue."; - var regexpPattern = new RegExp("is", "i"); - var regexpOutputLength = 0; - var temp = regexpPattern.exec(someString); - while (temp == "is") { - regexpOutputLength += 4; - regexpOutputLength *= 2; - temp = regexpPattern.exec(someString); - if (regexpOutputLength > (seedValue * 3)) { - temp = "break"; - } - } - - // spin in a for loop for a while - var i = 0; - var j = 0; - var cumulativeTotal = 3; - for (i = 20; i > 1; i--) { - for (j = 31; j > 5; j--) { - var branchVariable = i + j; - if (branchVariable % 3 == 0) { - cumulativeTotal -= secondFactor; - } else { - cumulativeTotal += firstFactor; - } - - if (cumulativeTotal > (seedValue * 50)) { - break; - } - } - } - retn *= (1 + (cumulativeTotal * 0.001)); - retn *= (1 + (3.1415962 / seedValue)); - retn /= 2.41497; - retn -= (seedValue * -1); - return retn; -} - -function calculateFirstFactor(seedValue) { - var firstFactor = (0.45 * (9.3 / 3.1) - 0.90); - firstFactor *= (1 + (0.00001 / seedValue)); - return firstFactor; -} - -function calculateSecondFactor(seedValue) { - var secondFactor = 0.78 * (6.3 / 2.1) - (0.39 * 4); - secondFactor *= (1 + (0.00001 / seedValue)); - return secondFactor; -} - -function calculateModificationTerm(seedValue) { - var modificationTerm = (12 + (9*7) - 54 + 16 - ((calculateFirstFactor(seedValue) * seedValue) / 3) + (4*calculateSecondFactor(seedValue) * seedValue * 1.33)) + (calculateSecondFactor(seedValue) * seedValue); - modificationTerm = modificationTerm + (33/2) + 19 - (9*2) - (61*3) + 177; - return modificationTerm; -} diff --git a/tests/benchmarks/declarative/holistic/data/jsImports/mlbsi10.js b/tests/benchmarks/declarative/holistic/data/jsImports/mlbsi10.js deleted file mode 100644 index 69202e63eb..0000000000 --- a/tests/benchmarks/declarative/holistic/data/jsImports/mlbsi10.js +++ /dev/null @@ -1,108 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -// This JavaScript file is a single, large, imported script. -// It doesn't import any other scripts. -// It is imported from another script. - -function testFunc(seedValue) { - var retn = 5; - retn += (seedValue * 0.1045); - var firstFactor = calculateFirstFactor(seedValue); - var secondFactor = calculateSecondFactor(seedValue); - var modificationTerm = calculateModificationTerm(seedValue); - - // do some regexp matching - var someString = "This is a random string which we'll perform regular expression matching on to reduce considerably. This is meant to be part of a complex javascript expression whose evaluation takes considerably longer than the creation cost of QScriptValue."; - var regexpPattern = new RegExp("is", "i"); - var regexpOutputLength = 0; - var temp = regexpPattern.exec(someString); - while (temp == "is") { - regexpOutputLength += 4; - regexpOutputLength *= 2; - temp = regexpPattern.exec(someString); - if (regexpOutputLength > (seedValue * 3)) { - temp = "break"; - } - } - - // spin in a for loop for a while - var i = 0; - var j = 0; - var cumulativeTotal = 3; - for (i = 20; i > 1; i--) { - for (j = 31; j > 5; j--) { - var branchVariable = i + j; - if (branchVariable % 3 == 0) { - cumulativeTotal -= secondFactor; - } else { - cumulativeTotal += firstFactor; - } - - if (cumulativeTotal > (seedValue * 50)) { - break; - } - } - } - retn *= (1 + (cumulativeTotal * 0.001)); - retn *= (1 + (3.1415962 / seedValue)); - retn /= 2.41497; - retn -= (seedValue * -1); - return retn; -} - -function calculateFirstFactor(seedValue) { - var firstFactor = (0.45 * (9.3 / 3.1) - 0.90); - firstFactor *= (1 + (0.000010 / seedValue)); - return firstFactor; -} - -function calculateSecondFactor(seedValue) { - var secondFactor = 0.78 * (6.3 / 2.1) - (0.39 * 4); - secondFactor *= (1 + (0.000010 / seedValue)); - return secondFactor; -} - -function calculateModificationTerm(seedValue) { - var modificationTerm = (12 + (9*7) - 54 + 16 - ((calculateFirstFactor(seedValue) * seedValue) / 3) + (4*calculateSecondFactor(seedValue) * seedValue * 1.33)) + (calculateSecondFactor(seedValue) * seedValue); - modificationTerm = modificationTerm + (33/2) + 19 - (9*2) - (61*3) + 177; - return modificationTerm; -} diff --git a/tests/benchmarks/declarative/holistic/data/jsImports/mlbsi11.js b/tests/benchmarks/declarative/holistic/data/jsImports/mlbsi11.js deleted file mode 100644 index 9f3e28a1f6..0000000000 --- a/tests/benchmarks/declarative/holistic/data/jsImports/mlbsi11.js +++ /dev/null @@ -1,108 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -// This JavaScript file is a single, large, imported script. -// It doesn't import any other scripts. -// It is imported from another script. - -function testFunc(seedValue) { - var retn = 5; - retn += (seedValue * 0.1145); - var firstFactor = calculateFirstFactor(seedValue); - var secondFactor = calculateSecondFactor(seedValue); - var modificationTerm = calculateModificationTerm(seedValue); - - // do some regexp matching - var someString = "This is a random string which we'll perform regular expression matching on to reduce considerably. This is meant to be part of a complex javascript expression whose evaluation takes considerably longer than the creation cost of QScriptValue."; - var regexpPattern = new RegExp("is", "i"); - var regexpOutputLength = 0; - var temp = regexpPattern.exec(someString); - while (temp == "is") { - regexpOutputLength += 4; - regexpOutputLength *= 2; - temp = regexpPattern.exec(someString); - if (regexpOutputLength > (seedValue * 3)) { - temp = "break"; - } - } - - // spin in a for loop for a while - var i = 0; - var j = 0; - var cumulativeTotal = 3; - for (i = 20; i > 1; i--) { - for (j = 31; j > 5; j--) { - var branchVariable = i + j; - if (branchVariable % 3 == 0) { - cumulativeTotal -= secondFactor; - } else { - cumulativeTotal += firstFactor; - } - - if (cumulativeTotal > (seedValue * 50)) { - break; - } - } - } - retn *= (1 + (cumulativeTotal * 0.001)); - retn *= (1 + (3.1415962 / seedValue)); - retn /= 2.41497; - retn -= (seedValue * -1); - return retn; -} - -function calculateFirstFactor(seedValue) { - var firstFactor = (0.45 * (9.3 / 3.1) - 0.90); - firstFactor *= (1 + (0.000011 / seedValue)); - return firstFactor; -} - -function calculateSecondFactor(seedValue) { - var secondFactor = 0.78 * (6.3 / 2.1) - (0.39 * 4); - secondFactor *= (1 + (0.000011 / seedValue)); - return secondFactor; -} - -function calculateModificationTerm(seedValue) { - var modificationTerm = (12 + (9*7) - 54 + 16 - ((calculateFirstFactor(seedValue) * seedValue) / 3) + (4*calculateSecondFactor(seedValue) * seedValue * 1.33)) + (calculateSecondFactor(seedValue) * seedValue); - modificationTerm = modificationTerm + (33/2) + 19 - (9*2) - (61*3) + 177; - return modificationTerm; -} diff --git a/tests/benchmarks/declarative/holistic/data/jsImports/mlbsi12.js b/tests/benchmarks/declarative/holistic/data/jsImports/mlbsi12.js deleted file mode 100644 index 349c7cdd3f..0000000000 --- a/tests/benchmarks/declarative/holistic/data/jsImports/mlbsi12.js +++ /dev/null @@ -1,108 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -// This JavaScript file is a single, large, imported script. -// It doesn't import any other scripts. -// It is imported from another script. - -function testFunc(seedValue) { - var retn = 5; - retn += (seedValue * 0.1245); - var firstFactor = calculateFirstFactor(seedValue); - var secondFactor = calculateSecondFactor(seedValue); - var modificationTerm = calculateModificationTerm(seedValue); - - // do some regexp matching - var someString = "This is a random string which we'll perform regular expression matching on to reduce considerably. This is meant to be part of a complex javascript expression whose evaluation takes considerably longer than the creation cost of QScriptValue."; - var regexpPattern = new RegExp("is", "i"); - var regexpOutputLength = 0; - var temp = regexpPattern.exec(someString); - while (temp == "is") { - regexpOutputLength += 4; - regexpOutputLength *= 2; - temp = regexpPattern.exec(someString); - if (regexpOutputLength > (seedValue * 3)) { - temp = "break"; - } - } - - // spin in a for loop for a while - var i = 0; - var j = 0; - var cumulativeTotal = 3; - for (i = 20; i > 1; i--) { - for (j = 31; j > 5; j--) { - var branchVariable = i + j; - if (branchVariable % 3 == 0) { - cumulativeTotal -= secondFactor; - } else { - cumulativeTotal += firstFactor; - } - - if (cumulativeTotal > (seedValue * 50)) { - break; - } - } - } - retn *= (1 + (cumulativeTotal * 0.001)); - retn *= (1 + (3.1415962 / seedValue)); - retn /= 2.41497; - retn -= (seedValue * -1); - return retn; -} - -function calculateFirstFactor(seedValue) { - var firstFactor = (0.45 * (9.3 / 3.1) - 0.90); - firstFactor *= (1 + (0.000012 / seedValue)); - return firstFactor; -} - -function calculateSecondFactor(seedValue) { - var secondFactor = 0.78 * (6.3 / 2.1) - (0.39 * 4); - secondFactor *= (1 + (0.000012 / seedValue)); - return secondFactor; -} - -function calculateModificationTerm(seedValue) { - var modificationTerm = (12 + (9*7) - 54 + 16 - ((calculateFirstFactor(seedValue) * seedValue) / 3) + (4*calculateSecondFactor(seedValue) * seedValue * 1.33)) + (calculateSecondFactor(seedValue) * seedValue); - modificationTerm = modificationTerm + (33/2) + 19 - (9*2) - (61*3) + 177; - return modificationTerm; -} diff --git a/tests/benchmarks/declarative/holistic/data/jsImports/mlbsi13.js b/tests/benchmarks/declarative/holistic/data/jsImports/mlbsi13.js deleted file mode 100644 index 925178fadb..0000000000 --- a/tests/benchmarks/declarative/holistic/data/jsImports/mlbsi13.js +++ /dev/null @@ -1,108 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -// This JavaScript file is a single, large, imported script. -// It doesn't import any other scripts. -// It is imported from another script. - -function testFunc(seedValue) { - var retn = 5; - retn += (seedValue * 0.1345); - var firstFactor = calculateFirstFactor(seedValue); - var secondFactor = calculateSecondFactor(seedValue); - var modificationTerm = calculateModificationTerm(seedValue); - - // do some regexp matching - var someString = "This is a random string which we'll perform regular expression matching on to reduce considerably. This is meant to be part of a complex javascript expression whose evaluation takes considerably longer than the creation cost of QScriptValue."; - var regexpPattern = new RegExp("is", "i"); - var regexpOutputLength = 0; - var temp = regexpPattern.exec(someString); - while (temp == "is") { - regexpOutputLength += 4; - regexpOutputLength *= 2; - temp = regexpPattern.exec(someString); - if (regexpOutputLength > (seedValue * 3)) { - temp = "break"; - } - } - - // spin in a for loop for a while - var i = 0; - var j = 0; - var cumulativeTotal = 3; - for (i = 20; i > 1; i--) { - for (j = 31; j > 5; j--) { - var branchVariable = i + j; - if (branchVariable % 3 == 0) { - cumulativeTotal -= secondFactor; - } else { - cumulativeTotal += firstFactor; - } - - if (cumulativeTotal > (seedValue * 50)) { - break; - } - } - } - retn *= (1 + (cumulativeTotal * 0.001)); - retn *= (1 + (3.1415962 / seedValue)); - retn /= 2.41497; - retn -= (seedValue * -1); - return retn; -} - -function calculateFirstFactor(seedValue) { - var firstFactor = (0.45 * (9.3 / 3.1) - 0.90); - firstFactor *= (1 + (0.000013 / seedValue)); - return firstFactor; -} - -function calculateSecondFactor(seedValue) { - var secondFactor = 0.78 * (6.3 / 2.1) - (0.39 * 4); - secondFactor *= (1 + (0.000013 / seedValue)); - return secondFactor; -} - -function calculateModificationTerm(seedValue) { - var modificationTerm = (12 + (9*7) - 54 + 16 - ((calculateFirstFactor(seedValue) * seedValue) / 3) + (4*calculateSecondFactor(seedValue) * seedValue * 1.33)) + (calculateSecondFactor(seedValue) * seedValue); - modificationTerm = modificationTerm + (33/2) + 19 - (9*2) - (61*3) + 177; - return modificationTerm; -} diff --git a/tests/benchmarks/declarative/holistic/data/jsImports/mlbsi14.js b/tests/benchmarks/declarative/holistic/data/jsImports/mlbsi14.js deleted file mode 100644 index 25f17ca1b8..0000000000 --- a/tests/benchmarks/declarative/holistic/data/jsImports/mlbsi14.js +++ /dev/null @@ -1,108 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -// This JavaScript file is a single, large, imported script. -// It doesn't import any other scripts. -// It is imported from another script. - -function testFunc(seedValue) { - var retn = 5; - retn += (seedValue * 0.1445); - var firstFactor = calculateFirstFactor(seedValue); - var secondFactor = calculateSecondFactor(seedValue); - var modificationTerm = calculateModificationTerm(seedValue); - - // do some regexp matching - var someString = "This is a random string which we'll perform regular expression matching on to reduce considerably. This is meant to be part of a complex javascript expression whose evaluation takes considerably longer than the creation cost of QScriptValue."; - var regexpPattern = new RegExp("is", "i"); - var regexpOutputLength = 0; - var temp = regexpPattern.exec(someString); - while (temp == "is") { - regexpOutputLength += 4; - regexpOutputLength *= 2; - temp = regexpPattern.exec(someString); - if (regexpOutputLength > (seedValue * 3)) { - temp = "break"; - } - } - - // spin in a for loop for a while - var i = 0; - var j = 0; - var cumulativeTotal = 3; - for (i = 20; i > 1; i--) { - for (j = 31; j > 5; j--) { - var branchVariable = i + j; - if (branchVariable % 3 == 0) { - cumulativeTotal -= secondFactor; - } else { - cumulativeTotal += firstFactor; - } - - if (cumulativeTotal > (seedValue * 50)) { - break; - } - } - } - retn *= (1 + (cumulativeTotal * 0.001)); - retn *= (1 + (3.1415962 / seedValue)); - retn /= 2.41497; - retn -= (seedValue * -1); - return retn; -} - -function calculateFirstFactor(seedValue) { - var firstFactor = (0.45 * (9.3 / 3.1) - 0.90); - firstFactor *= (1 + (0.000014 / seedValue)); - return firstFactor; -} - -function calculateSecondFactor(seedValue) { - var secondFactor = 0.78 * (6.3 / 2.1) - (0.39 * 4); - secondFactor *= (1 + (0.000014 / seedValue)); - return secondFactor; -} - -function calculateModificationTerm(seedValue) { - var modificationTerm = (12 + (9*7) - 54 + 16 - ((calculateFirstFactor(seedValue) * seedValue) / 3) + (4*calculateSecondFactor(seedValue) * seedValue * 1.33)) + (calculateSecondFactor(seedValue) * seedValue); - modificationTerm = modificationTerm + (33/2) + 19 - (9*2) - (61*3) + 177; - return modificationTerm; -} diff --git a/tests/benchmarks/declarative/holistic/data/jsImports/mlbsi15.js b/tests/benchmarks/declarative/holistic/data/jsImports/mlbsi15.js deleted file mode 100644 index 9445222cd9..0000000000 --- a/tests/benchmarks/declarative/holistic/data/jsImports/mlbsi15.js +++ /dev/null @@ -1,108 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -// This JavaScript file is a single, large, imported script. -// It doesn't import any other scripts. -// It is imported from another script. - -function testFunc(seedValue) { - var retn = 5; - retn += (seedValue * 0.1545); - var firstFactor = calculateFirstFactor(seedValue); - var secondFactor = calculateSecondFactor(seedValue); - var modificationTerm = calculateModificationTerm(seedValue); - - // do some regexp matching - var someString = "This is a random string which we'll perform regular expression matching on to reduce considerably. This is meant to be part of a complex javascript expression whose evaluation takes considerably longer than the creation cost of QScriptValue."; - var regexpPattern = new RegExp("is", "i"); - var regexpOutputLength = 0; - var temp = regexpPattern.exec(someString); - while (temp == "is") { - regexpOutputLength += 4; - regexpOutputLength *= 2; - temp = regexpPattern.exec(someString); - if (regexpOutputLength > (seedValue * 3)) { - temp = "break"; - } - } - - // spin in a for loop for a while - var i = 0; - var j = 0; - var cumulativeTotal = 3; - for (i = 20; i > 1; i--) { - for (j = 31; j > 5; j--) { - var branchVariable = i + j; - if (branchVariable % 3 == 0) { - cumulativeTotal -= secondFactor; - } else { - cumulativeTotal += firstFactor; - } - - if (cumulativeTotal > (seedValue * 50)) { - break; - } - } - } - retn *= (1 + (cumulativeTotal * 0.001)); - retn *= (1 + (3.1415962 / seedValue)); - retn /= 2.41497; - retn -= (seedValue * -1); - return retn; -} - -function calculateFirstFactor(seedValue) { - var firstFactor = (0.45 * (9.3 / 3.1) - 0.90); - firstFactor *= (1 + (0.000015 / seedValue)); - return firstFactor; -} - -function calculateSecondFactor(seedValue) { - var secondFactor = 0.78 * (6.3 / 2.1) - (0.39 * 4); - secondFactor *= (1 + (0.000015 / seedValue)); - return secondFactor; -} - -function calculateModificationTerm(seedValue) { - var modificationTerm = (12 + (9*7) - 54 + 16 - ((calculateFirstFactor(seedValue) * seedValue) / 3) + (4*calculateSecondFactor(seedValue) * seedValue * 1.33)) + (calculateSecondFactor(seedValue) * seedValue); - modificationTerm = modificationTerm + (33/2) + 19 - (9*2) - (61*3) + 177; - return modificationTerm; -} diff --git a/tests/benchmarks/declarative/holistic/data/jsImports/mlbsi2.js b/tests/benchmarks/declarative/holistic/data/jsImports/mlbsi2.js deleted file mode 100644 index f375c57663..0000000000 --- a/tests/benchmarks/declarative/holistic/data/jsImports/mlbsi2.js +++ /dev/null @@ -1,108 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -// This JavaScript file is a single, large, imported script. -// It doesn't import any other scripts. -// It is imported from another script. - -function testFunc(seedValue) { - var retn = 5; - retn += (seedValue * 0.245); - var firstFactor = calculateFirstFactor(seedValue); - var secondFactor = calculateSecondFactor(seedValue); - var modificationTerm = calculateModificationTerm(seedValue); - - // do some regexp matching - var someString = "This is a random string which we'll perform regular expression matching on to reduce considerably. This is meant to be part of a complex javascript expression whose evaluation takes considerably longer than the creation cost of QScriptValue."; - var regexpPattern = new RegExp("is", "i"); - var regexpOutputLength = 0; - var temp = regexpPattern.exec(someString); - while (temp == "is") { - regexpOutputLength += 4; - regexpOutputLength *= 2; - temp = regexpPattern.exec(someString); - if (regexpOutputLength > (seedValue * 3)) { - temp = "break"; - } - } - - // spin in a for loop for a while - var i = 0; - var j = 0; - var cumulativeTotal = 3; - for (i = 20; i > 1; i--) { - for (j = 31; j > 5; j--) { - var branchVariable = i + j; - if (branchVariable % 3 == 0) { - cumulativeTotal -= secondFactor; - } else { - cumulativeTotal += firstFactor; - } - - if (cumulativeTotal > (seedValue * 50)) { - break; - } - } - } - retn *= (1 + (cumulativeTotal * 0.001)); - retn *= (1 + (3.1415962 / seedValue)); - retn /= 2.41497; - retn -= (seedValue * -1); - return retn; -} - -function calculateFirstFactor(seedValue) { - var firstFactor = (0.45 * (9.3 / 3.1) - 0.90); - firstFactor *= (1 + (0.00002 / seedValue)); - return firstFactor; -} - -function calculateSecondFactor(seedValue) { - var secondFactor = 0.78 * (6.3 / 2.1) - (0.39 * 4); - secondFactor *= (1 + (0.00002 / seedValue)); - return secondFactor; -} - -function calculateModificationTerm(seedValue) { - var modificationTerm = (12 + (9*7) - 54 + 16 - ((calculateFirstFactor(seedValue) * seedValue) / 3) + (4*calculateSecondFactor(seedValue) * seedValue * 1.33)) + (calculateSecondFactor(seedValue) * seedValue); - modificationTerm = modificationTerm + (33/2) + 19 - (9*2) - (61*3) + 177; - return modificationTerm; -} diff --git a/tests/benchmarks/declarative/holistic/data/jsImports/mlbsi3.js b/tests/benchmarks/declarative/holistic/data/jsImports/mlbsi3.js deleted file mode 100644 index 0bfe7f021d..0000000000 --- a/tests/benchmarks/declarative/holistic/data/jsImports/mlbsi3.js +++ /dev/null @@ -1,108 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -// This JavaScript file is a single, large, imported script. -// It doesn't import any other scripts. -// It is imported from another script. - -function testFunc(seedValue) { - var retn = 5; - retn += (seedValue * 0.345); - var firstFactor = calculateFirstFactor(seedValue); - var secondFactor = calculateSecondFactor(seedValue); - var modificationTerm = calculateModificationTerm(seedValue); - - // do some regexp matching - var someString = "This is a random string which we'll perform regular expression matching on to reduce considerably. This is meant to be part of a complex javascript expression whose evaluation takes considerably longer than the creation cost of QScriptValue."; - var regexpPattern = new RegExp("is", "i"); - var regexpOutputLength = 0; - var temp = regexpPattern.exec(someString); - while (temp == "is") { - regexpOutputLength += 4; - regexpOutputLength *= 2; - temp = regexpPattern.exec(someString); - if (regexpOutputLength > (seedValue * 3)) { - temp = "break"; - } - } - - // spin in a for loop for a while - var i = 0; - var j = 0; - var cumulativeTotal = 3; - for (i = 20; i > 1; i--) { - for (j = 31; j > 5; j--) { - var branchVariable = i + j; - if (branchVariable % 3 == 0) { - cumulativeTotal -= secondFactor; - } else { - cumulativeTotal += firstFactor; - } - - if (cumulativeTotal > (seedValue * 50)) { - break; - } - } - } - retn *= (1 + (cumulativeTotal * 0.001)); - retn *= (1 + (3.1415962 / seedValue)); - retn /= 2.41497; - retn -= (seedValue * -1); - return retn; -} - -function calculateFirstFactor(seedValue) { - var firstFactor = (0.45 * (9.3 / 3.1) - 0.90); - firstFactor *= (1 + (0.00003 / seedValue)); - return firstFactor; -} - -function calculateSecondFactor(seedValue) { - var secondFactor = 0.78 * (6.3 / 2.1) - (0.39 * 4); - secondFactor *= (1 + (0.00003 / seedValue)); - return secondFactor; -} - -function calculateModificationTerm(seedValue) { - var modificationTerm = (12 + (9*7) - 54 + 16 - ((calculateFirstFactor(seedValue) * seedValue) / 3) + (4*calculateSecondFactor(seedValue) * seedValue * 1.33)) + (calculateSecondFactor(seedValue) * seedValue); - modificationTerm = modificationTerm + (33/2) + 19 - (9*2) - (61*3) + 177; - return modificationTerm; -} diff --git a/tests/benchmarks/declarative/holistic/data/jsImports/mlbsi4.js b/tests/benchmarks/declarative/holistic/data/jsImports/mlbsi4.js deleted file mode 100644 index 8707e296ec..0000000000 --- a/tests/benchmarks/declarative/holistic/data/jsImports/mlbsi4.js +++ /dev/null @@ -1,108 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -// This JavaScript file is a single, large, imported script. -// It doesn't import any other scripts. -// It is imported from another script. - -function testFunc(seedValue) { - var retn = 5; - retn += (seedValue * 0.445); - var firstFactor = calculateFirstFactor(seedValue); - var secondFactor = calculateSecondFactor(seedValue); - var modificationTerm = calculateModificationTerm(seedValue); - - // do some regexp matching - var someString = "This is a random string which we'll perform regular expression matching on to reduce considerably. This is meant to be part of a complex javascript expression whose evaluation takes considerably longer than the creation cost of QScriptValue."; - var regexpPattern = new RegExp("is", "i"); - var regexpOutputLength = 0; - var temp = regexpPattern.exec(someString); - while (temp == "is") { - regexpOutputLength += 4; - regexpOutputLength *= 2; - temp = regexpPattern.exec(someString); - if (regexpOutputLength > (seedValue * 3)) { - temp = "break"; - } - } - - // spin in a for loop for a while - var i = 0; - var j = 0; - var cumulativeTotal = 3; - for (i = 20; i > 1; i--) { - for (j = 31; j > 5; j--) { - var branchVariable = i + j; - if (branchVariable % 3 == 0) { - cumulativeTotal -= secondFactor; - } else { - cumulativeTotal += firstFactor; - } - - if (cumulativeTotal > (seedValue * 50)) { - break; - } - } - } - retn *= (1 + (cumulativeTotal * 0.001)); - retn *= (1 + (3.1415962 / seedValue)); - retn /= 2.41497; - retn -= (seedValue * -1); - return retn; -} - -function calculateFirstFactor(seedValue) { - var firstFactor = (0.45 * (9.3 / 3.1) - 0.90); - firstFactor *= (1 + (0.00004 / seedValue)); - return firstFactor; -} - -function calculateSecondFactor(seedValue) { - var secondFactor = 0.78 * (6.3 / 2.1) - (0.39 * 4); - secondFactor *= (1 + (0.00004 / seedValue)); - return secondFactor; -} - -function calculateModificationTerm(seedValue) { - var modificationTerm = (12 + (9*7) - 54 + 16 - ((calculateFirstFactor(seedValue) * seedValue) / 3) + (4*calculateSecondFactor(seedValue) * seedValue * 1.33)) + (calculateSecondFactor(seedValue) * seedValue); - modificationTerm = modificationTerm + (33/2) + 19 - (9*2) - (61*3) + 177; - return modificationTerm; -} diff --git a/tests/benchmarks/declarative/holistic/data/jsImports/mlbsi5.js b/tests/benchmarks/declarative/holistic/data/jsImports/mlbsi5.js deleted file mode 100644 index 0b1e8cf3de..0000000000 --- a/tests/benchmarks/declarative/holistic/data/jsImports/mlbsi5.js +++ /dev/null @@ -1,108 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -// This JavaScript file is a single, large, imported script. -// It doesn't import any other scripts. -// It is imported from another script. - -function testFunc(seedValue) { - var retn = 5; - retn += (seedValue * 0.545); - var firstFactor = calculateFirstFactor(seedValue); - var secondFactor = calculateSecondFactor(seedValue); - var modificationTerm = calculateModificationTerm(seedValue); - - // do some regexp matching - var someString = "This is a random string which we'll perform regular expression matching on to reduce considerably. This is meant to be part of a complex javascript expression whose evaluation takes considerably longer than the creation cost of QScriptValue."; - var regexpPattern = new RegExp("is", "i"); - var regexpOutputLength = 0; - var temp = regexpPattern.exec(someString); - while (temp == "is") { - regexpOutputLength += 4; - regexpOutputLength *= 2; - temp = regexpPattern.exec(someString); - if (regexpOutputLength > (seedValue * 3)) { - temp = "break"; - } - } - - // spin in a for loop for a while - var i = 0; - var j = 0; - var cumulativeTotal = 3; - for (i = 20; i > 1; i--) { - for (j = 31; j > 5; j--) { - var branchVariable = i + j; - if (branchVariable % 3 == 0) { - cumulativeTotal -= secondFactor; - } else { - cumulativeTotal += firstFactor; - } - - if (cumulativeTotal > (seedValue * 50)) { - break; - } - } - } - retn *= (1 + (cumulativeTotal * 0.001)); - retn *= (1 + (3.1415962 / seedValue)); - retn /= 2.41497; - retn -= (seedValue * -1); - return retn; -} - -function calculateFirstFactor(seedValue) { - var firstFactor = (0.45 * (9.3 / 3.1) - 0.90); - firstFactor *= (1 + (0.00005 / seedValue)); - return firstFactor; -} - -function calculateSecondFactor(seedValue) { - var secondFactor = 0.78 * (6.3 / 2.1) - (0.39 * 4); - secondFactor *= (1 + (0.00005 / seedValue)); - return secondFactor; -} - -function calculateModificationTerm(seedValue) { - var modificationTerm = (12 + (9*7) - 54 + 16 - ((calculateFirstFactor(seedValue) * seedValue) / 3) + (4*calculateSecondFactor(seedValue) * seedValue * 1.33)) + (calculateSecondFactor(seedValue) * seedValue); - modificationTerm = modificationTerm + (33/2) + 19 - (9*2) - (61*3) + 177; - return modificationTerm; -} diff --git a/tests/benchmarks/declarative/holistic/data/jsImports/mlbsi6.js b/tests/benchmarks/declarative/holistic/data/jsImports/mlbsi6.js deleted file mode 100644 index eb839108de..0000000000 --- a/tests/benchmarks/declarative/holistic/data/jsImports/mlbsi6.js +++ /dev/null @@ -1,108 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -// This JavaScript file is a single, large, imported script. -// It doesn't import any other scripts. -// It is imported from another script. - -function testFunc(seedValue) { - var retn = 5; - retn += (seedValue * 0.645); - var firstFactor = calculateFirstFactor(seedValue); - var secondFactor = calculateSecondFactor(seedValue); - var modificationTerm = calculateModificationTerm(seedValue); - - // do some regexp matching - var someString = "This is a random string which we'll perform regular expression matching on to reduce considerably. This is meant to be part of a complex javascript expression whose evaluation takes considerably longer than the creation cost of QScriptValue."; - var regexpPattern = new RegExp("is", "i"); - var regexpOutputLength = 0; - var temp = regexpPattern.exec(someString); - while (temp == "is") { - regexpOutputLength += 4; - regexpOutputLength *= 2; - temp = regexpPattern.exec(someString); - if (regexpOutputLength > (seedValue * 3)) { - temp = "break"; - } - } - - // spin in a for loop for a while - var i = 0; - var j = 0; - var cumulativeTotal = 3; - for (i = 20; i > 1; i--) { - for (j = 31; j > 5; j--) { - var branchVariable = i + j; - if (branchVariable % 3 == 0) { - cumulativeTotal -= secondFactor; - } else { - cumulativeTotal += firstFactor; - } - - if (cumulativeTotal > (seedValue * 50)) { - break; - } - } - } - retn *= (1 + (cumulativeTotal * 0.001)); - retn *= (1 + (3.1415962 / seedValue)); - retn /= 2.41497; - retn -= (seedValue * -1); - return retn; -} - -function calculateFirstFactor(seedValue) { - var firstFactor = (0.45 * (9.3 / 3.1) - 0.90); - firstFactor *= (1 + (0.00006 / seedValue)); - return firstFactor; -} - -function calculateSecondFactor(seedValue) { - var secondFactor = 0.78 * (6.3 / 2.1) - (0.39 * 4); - secondFactor *= (1 + (0.00006 / seedValue)); - return secondFactor; -} - -function calculateModificationTerm(seedValue) { - var modificationTerm = (12 + (9*7) - 54 + 16 - ((calculateFirstFactor(seedValue) * seedValue) / 3) + (4*calculateSecondFactor(seedValue) * seedValue * 1.33)) + (calculateSecondFactor(seedValue) * seedValue); - modificationTerm = modificationTerm + (33/2) + 19 - (9*2) - (61*3) + 177; - return modificationTerm; -} diff --git a/tests/benchmarks/declarative/holistic/data/jsImports/mlbsi7.js b/tests/benchmarks/declarative/holistic/data/jsImports/mlbsi7.js deleted file mode 100644 index fb22fa8f73..0000000000 --- a/tests/benchmarks/declarative/holistic/data/jsImports/mlbsi7.js +++ /dev/null @@ -1,108 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -// This JavaScript file is a single, large, imported script. -// It doesn't import any other scripts. -// It is imported from another script. - -function testFunc(seedValue) { - var retn = 5; - retn += (seedValue * 0.745); - var firstFactor = calculateFirstFactor(seedValue); - var secondFactor = calculateSecondFactor(seedValue); - var modificationTerm = calculateModificationTerm(seedValue); - - // do some regexp matching - var someString = "This is a random string which we'll perform regular expression matching on to reduce considerably. This is meant to be part of a complex javascript expression whose evaluation takes considerably longer than the creation cost of QScriptValue."; - var regexpPattern = new RegExp("is", "i"); - var regexpOutputLength = 0; - var temp = regexpPattern.exec(someString); - while (temp == "is") { - regexpOutputLength += 4; - regexpOutputLength *= 2; - temp = regexpPattern.exec(someString); - if (regexpOutputLength > (seedValue * 3)) { - temp = "break"; - } - } - - // spin in a for loop for a while - var i = 0; - var j = 0; - var cumulativeTotal = 3; - for (i = 20; i > 1; i--) { - for (j = 31; j > 5; j--) { - var branchVariable = i + j; - if (branchVariable % 3 == 0) { - cumulativeTotal -= secondFactor; - } else { - cumulativeTotal += firstFactor; - } - - if (cumulativeTotal > (seedValue * 50)) { - break; - } - } - } - retn *= (1 + (cumulativeTotal * 0.001)); - retn *= (1 + (3.1415962 / seedValue)); - retn /= 2.41497; - retn -= (seedValue * -1); - return retn; -} - -function calculateFirstFactor(seedValue) { - var firstFactor = (0.45 * (9.3 / 3.1) - 0.90); - firstFactor *= (1 + (0.00007 / seedValue)); - return firstFactor; -} - -function calculateSecondFactor(seedValue) { - var secondFactor = 0.78 * (6.3 / 2.1) - (0.39 * 4); - secondFactor *= (1 + (0.00007 / seedValue)); - return secondFactor; -} - -function calculateModificationTerm(seedValue) { - var modificationTerm = (12 + (9*7) - 54 + 16 - ((calculateFirstFactor(seedValue) * seedValue) / 3) + (4*calculateSecondFactor(seedValue) * seedValue * 1.33)) + (calculateSecondFactor(seedValue) * seedValue); - modificationTerm = modificationTerm + (33/2) + 19 - (9*2) - (61*3) + 177; - return modificationTerm; -} diff --git a/tests/benchmarks/declarative/holistic/data/jsImports/mlbsi8.js b/tests/benchmarks/declarative/holistic/data/jsImports/mlbsi8.js deleted file mode 100644 index 736703c5bc..0000000000 --- a/tests/benchmarks/declarative/holistic/data/jsImports/mlbsi8.js +++ /dev/null @@ -1,108 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -// This JavaScript file is a single, large, imported script. -// It doesn't import any other scripts. -// It is imported from another script. - -function testFunc(seedValue) { - var retn = 5; - retn += (seedValue * 0.845); - var firstFactor = calculateFirstFactor(seedValue); - var secondFactor = calculateSecondFactor(seedValue); - var modificationTerm = calculateModificationTerm(seedValue); - - // do some regexp matching - var someString = "This is a random string which we'll perform regular expression matching on to reduce considerably. This is meant to be part of a complex javascript expression whose evaluation takes considerably longer than the creation cost of QScriptValue."; - var regexpPattern = new RegExp("is", "i"); - var regexpOutputLength = 0; - var temp = regexpPattern.exec(someString); - while (temp == "is") { - regexpOutputLength += 4; - regexpOutputLength *= 2; - temp = regexpPattern.exec(someString); - if (regexpOutputLength > (seedValue * 3)) { - temp = "break"; - } - } - - // spin in a for loop for a while - var i = 0; - var j = 0; - var cumulativeTotal = 3; - for (i = 20; i > 1; i--) { - for (j = 31; j > 5; j--) { - var branchVariable = i + j; - if (branchVariable % 3 == 0) { - cumulativeTotal -= secondFactor; - } else { - cumulativeTotal += firstFactor; - } - - if (cumulativeTotal > (seedValue * 50)) { - break; - } - } - } - retn *= (1 + (cumulativeTotal * 0.001)); - retn *= (1 + (3.1415962 / seedValue)); - retn /= 2.41497; - retn -= (seedValue * -1); - return retn; -} - -function calculateFirstFactor(seedValue) { - var firstFactor = (0.45 * (9.3 / 3.1) - 0.90); - firstFactor *= (1 + (0.00008 / seedValue)); - return firstFactor; -} - -function calculateSecondFactor(seedValue) { - var secondFactor = 0.78 * (6.3 / 2.1) - (0.39 * 4); - secondFactor *= (1 + (0.00008 / seedValue)); - return secondFactor; -} - -function calculateModificationTerm(seedValue) { - var modificationTerm = (12 + (9*7) - 54 + 16 - ((calculateFirstFactor(seedValue) * seedValue) / 3) + (4*calculateSecondFactor(seedValue) * seedValue * 1.33)) + (calculateSecondFactor(seedValue) * seedValue); - modificationTerm = modificationTerm + (33/2) + 19 - (9*2) - (61*3) + 177; - return modificationTerm; -} diff --git a/tests/benchmarks/declarative/holistic/data/jsImports/mlbsi9.js b/tests/benchmarks/declarative/holistic/data/jsImports/mlbsi9.js deleted file mode 100644 index a1587a7de9..0000000000 --- a/tests/benchmarks/declarative/holistic/data/jsImports/mlbsi9.js +++ /dev/null @@ -1,108 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -// This JavaScript file is a single, large, imported script. -// It doesn't import any other scripts. -// It is imported from another script. - -function testFunc(seedValue) { - var retn = 5; - retn += (seedValue * 0.945); - var firstFactor = calculateFirstFactor(seedValue); - var secondFactor = calculateSecondFactor(seedValue); - var modificationTerm = calculateModificationTerm(seedValue); - - // do some regexp matching - var someString = "This is a random string which we'll perform regular expression matching on to reduce considerably. This is meant to be part of a complex javascript expression whose evaluation takes considerably longer than the creation cost of QScriptValue."; - var regexpPattern = new RegExp("is", "i"); - var regexpOutputLength = 0; - var temp = regexpPattern.exec(someString); - while (temp == "is") { - regexpOutputLength += 4; - regexpOutputLength *= 2; - temp = regexpPattern.exec(someString); - if (regexpOutputLength > (seedValue * 3)) { - temp = "break"; - } - } - - // spin in a for loop for a while - var i = 0; - var j = 0; - var cumulativeTotal = 3; - for (i = 20; i > 1; i--) { - for (j = 31; j > 5; j--) { - var branchVariable = i + j; - if (branchVariable % 3 == 0) { - cumulativeTotal -= secondFactor; - } else { - cumulativeTotal += firstFactor; - } - - if (cumulativeTotal > (seedValue * 50)) { - break; - } - } - } - retn *= (1 + (cumulativeTotal * 0.001)); - retn *= (1 + (3.1415962 / seedValue)); - retn /= 2.41497; - retn -= (seedValue * -1); - return retn; -} - -function calculateFirstFactor(seedValue) { - var firstFactor = (0.45 * (9.3 / 3.1) - 0.90); - firstFactor *= (1 + (0.00009 / seedValue)); - return firstFactor; -} - -function calculateSecondFactor(seedValue) { - var secondFactor = 0.78 * (6.3 / 2.1) - (0.39 * 4); - secondFactor *= (1 + (0.00009 / seedValue)); - return secondFactor; -} - -function calculateModificationTerm(seedValue) { - var modificationTerm = (12 + (9*7) - 54 + 16 - ((calculateFirstFactor(seedValue) * seedValue) / 3) + (4*calculateSecondFactor(seedValue) * seedValue * 1.33)) + (calculateSecondFactor(seedValue) * seedValue); - modificationTerm = modificationTerm + (33/2) + 19 - (9*2) - (61*3) + 177; - return modificationTerm; -} diff --git a/tests/benchmarks/declarative/holistic/data/jsImports/mldsi.js b/tests/benchmarks/declarative/holistic/data/jsImports/mldsi.js deleted file mode 100644 index c0bad9c5a6..0000000000 --- a/tests/benchmarks/declarative/holistic/data/jsImports/mldsi.js +++ /dev/null @@ -1,105 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -// This JavaScript file is a single, small, imported script. -// It imports other small scripts which are deeply nested. - -.import "mldsi1.js" as Mldsi1 - -function testFunc(seedValue) { - var firstFactor = calculateFirstFactor(seedValue); - var secondFactor = calculateSecondFactor(seedValue); - var modificationTerm = calculateModificationTerm(seedValue); - - // do some regexp matching - var someString = "This is a random string which we'll perform regular expression matching on to reduce considerably. This is meant to be part of a complex javascript expression whose evaluation takes considerably longer than the creation cost of QScriptValue."; - var regexpPattern = new RegExp("is", "i"); - var regexpOutputLength = 0; - var temp = regexpPattern.exec(someString); - while (temp == "is") { - regexpOutputLength += 4; - regexpOutputLength *= 2; - temp = regexpPattern.exec(someString); - if (regexpOutputLength > (seedValue * 3)) { - temp = "break"; - } - } - - // spin in a for loop for a while - var i = 0; - var j = 0; - var cumulativeTotal = 3; - for (i = 20; i > 1; i--) { - for (j = 31; j > 5; j--) { - var branchVariable = i + j; - if (branchVariable % 3 == 0) { - cumulativeTotal -= secondFactor; - } else { - cumulativeTotal += firstFactor; - } - - if (cumulativeTotal > (seedValue * 50)) { - break; - } - } - } - var retn = cumulativeTotal * 0.5; - retn *= Mldsi1.testFunc(seedValue + retn); - return retn; -} - -function calculateFirstFactor(seedValue) { - var firstFactor = (0.45 * (9.3 / 3.1) - 0.90); - firstFactor *= (1 + (0.000017 / seedValue)); - return firstFactor; -} - -function calculateSecondFactor(seedValue) { - var secondFactor = 0.78 * (6.3 / 2.1) - (0.39 * 4); - secondFactor *= (1 + (0.000017 / seedValue)); - return secondFactor; -} - -function calculateModificationTerm(seedValue) { - var modificationTerm = (12 + (9*7) - 54 + 16 - ((calculateFirstFactor(seedValue) * seedValue) / 3) + (4*calculateSecondFactor(seedValue) * seedValue * 1.33)) + (calculateSecondFactor(seedValue) * seedValue); - modificationTerm = modificationTerm + (33/2) + 19 - (9*2) - (61*3) + 177; - return modificationTerm; -} diff --git a/tests/benchmarks/declarative/holistic/data/jsImports/mldsi1.js b/tests/benchmarks/declarative/holistic/data/jsImports/mldsi1.js deleted file mode 100644 index b2a513da3b..0000000000 --- a/tests/benchmarks/declarative/holistic/data/jsImports/mldsi1.js +++ /dev/null @@ -1,107 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -// This JavaScript file is a single, large, imported script. -// It imports other large scripts which are deeply nested. -// It is imported by another script. - -.import "msdsi2.js" as Msdsi2 - -function testFunc(seedValue) { - var retn = 0.15; - var firstFactor = calculateFirstFactor(seedValue); - var secondFactor = calculateSecondFactor(seedValue); - var modificationTerm = calculateModificationTerm(seedValue); - - // do some regexp matching - var someString = "This is a random string which we'll perform regular expression matching on to reduce considerably. This is meant to be part of a complex javascript expression whose evaluation takes considerably longer than the creation cost of QScriptValue."; - var regexpPattern = new RegExp("is", "i"); - var regexpOutputLength = 0; - var temp = regexpPattern.exec(someString); - while (temp == "is") { - regexpOutputLength += 4; - regexpOutputLength *= 2; - temp = regexpPattern.exec(someString); - if (regexpOutputLength > (seedValue * 3)) { - temp = "break"; - } - } - - // spin in a for loop for a while - var i = 0; - var j = 0; - var cumulativeTotal = 3; - for (i = 20; i > 1; i--) { - for (j = 31; j > 5; j--) { - var branchVariable = i + j; - if (branchVariable % 3 == 0) { - cumulativeTotal -= secondFactor; - } else { - cumulativeTotal += firstFactor; - } - - if (cumulativeTotal > (seedValue * 50)) { - break; - } - } - } - retn *= (1 + (cumulativeTotal * 0.001)); - retn *= Msdsi2.testFunc(seedValue + retn); - return retn; -} - -function calculateFirstFactor(seedValue) { - var firstFactor = (0.45 * (9.3 / 3.1) - 0.90); - firstFactor *= (1 + (0.00001 / seedValue)); - return firstFactor; -} - -function calculateSecondFactor(seedValue) { - var secondFactor = 0.78 * (6.3 / 2.1) - (0.39 * 4); - secondFactor *= (1 + (0.00001 / seedValue)); - return secondFactor; -} - -function calculateModificationTerm(seedValue) { - var modificationTerm = (12 + (9*7) - 54 + 16 - ((calculateFirstFactor(seedValue) * seedValue) / 3) + (4*calculateSecondFactor(seedValue) * seedValue * 1.33)) + (calculateSecondFactor(seedValue) * seedValue); - modificationTerm = modificationTerm + (33/2) + 19 - (9*2) - (61*3) + 177; - return modificationTerm; -} diff --git a/tests/benchmarks/declarative/holistic/data/jsImports/mldsi10.js b/tests/benchmarks/declarative/holistic/data/jsImports/mldsi10.js deleted file mode 100644 index 864f027a6e..0000000000 --- a/tests/benchmarks/declarative/holistic/data/jsImports/mldsi10.js +++ /dev/null @@ -1,107 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -// This JavaScript file is a single, large, imported script. -// It imports other large scripts which are deeply nested. -// It is imported by another script. - -.import "msdsi11.js" as Msdsi11 - -function testFunc(seedValue) { - var retn = 0.105; - var firstFactor = calculateFirstFactor(seedValue); - var secondFactor = calculateSecondFactor(seedValue); - var modificationTerm = calculateModificationTerm(seedValue); - - // do some regexp matching - var someString = "This is a random string which we'll perform regular expression matching on to reduce considerably. This is meant to be part of a complex javascript expression whose evaluation takes considerably longer than the creation cost of QScriptValue."; - var regexpPattern = new RegExp("is", "i"); - var regexpOutputLength = 0; - var temp = regexpPattern.exec(someString); - while (temp == "is") { - regexpOutputLength += 4; - regexpOutputLength *= 2; - temp = regexpPattern.exec(someString); - if (regexpOutputLength > (seedValue * 3)) { - temp = "break"; - } - } - - // spin in a for loop for a while - var i = 0; - var j = 0; - var cumulativeTotal = 3; - for (i = 20; i > 1; i--) { - for (j = 31; j > 5; j--) { - var branchVariable = i + j; - if (branchVariable % 3 == 0) { - cumulativeTotal -= secondFactor; - } else { - cumulativeTotal += firstFactor; - } - - if (cumulativeTotal > (seedValue * 50)) { - break; - } - } - } - retn *= (1 + (cumulativeTotal * 0.001)); - retn *= Msdsi11.testFunc(seedValue + retn); - return retn; -} - -function calculateFirstFactor(seedValue) { - var firstFactor = (0.45 * (9.3 / 3.1) - 0.90); - firstFactor *= (1 + (0.000010 / seedValue)); - return firstFactor; -} - -function calculateSecondFactor(seedValue) { - var secondFactor = 0.78 * (6.3 / 2.1) - (0.39 * 4); - secondFactor *= (1 + (0.000010 / seedValue)); - return secondFactor; -} - -function calculateModificationTerm(seedValue) { - var modificationTerm = (12 + (9*7) - 54 + 16 - ((calculateFirstFactor(seedValue) * seedValue) / 3) + (4*calculateSecondFactor(seedValue) * seedValue * 1.33)) + (calculateSecondFactor(seedValue) * seedValue); - modificationTerm = modificationTerm + (33/2) + 19 - (9*2) - (61*3) + 177; - return modificationTerm; -} diff --git a/tests/benchmarks/declarative/holistic/data/jsImports/mldsi11.js b/tests/benchmarks/declarative/holistic/data/jsImports/mldsi11.js deleted file mode 100644 index 2c126ec1c6..0000000000 --- a/tests/benchmarks/declarative/holistic/data/jsImports/mldsi11.js +++ /dev/null @@ -1,107 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -// This JavaScript file is a single, large, imported script. -// It imports other large scripts which are deeply nested. -// It is imported by another script. - -.import "msdsi12.js" as Msdsi12 - -function testFunc(seedValue) { - var retn = 0.115; - var firstFactor = calculateFirstFactor(seedValue); - var secondFactor = calculateSecondFactor(seedValue); - var modificationTerm = calculateModificationTerm(seedValue); - - // do some regexp matching - var someString = "This is a random string which we'll perform regular expression matching on to reduce considerably. This is meant to be part of a complex javascript expression whose evaluation takes considerably longer than the creation cost of QScriptValue."; - var regexpPattern = new RegExp("is", "i"); - var regexpOutputLength = 0; - var temp = regexpPattern.exec(someString); - while (temp == "is") { - regexpOutputLength += 4; - regexpOutputLength *= 2; - temp = regexpPattern.exec(someString); - if (regexpOutputLength > (seedValue * 3)) { - temp = "break"; - } - } - - // spin in a for loop for a while - var i = 0; - var j = 0; - var cumulativeTotal = 3; - for (i = 20; i > 1; i--) { - for (j = 31; j > 5; j--) { - var branchVariable = i + j; - if (branchVariable % 3 == 0) { - cumulativeTotal -= secondFactor; - } else { - cumulativeTotal += firstFactor; - } - - if (cumulativeTotal > (seedValue * 50)) { - break; - } - } - } - retn *= (1 + (cumulativeTotal * 0.001)); - retn *= Msdsi12.testFunc(seedValue + retn); - return retn; -} - -function calculateFirstFactor(seedValue) { - var firstFactor = (0.45 * (9.3 / 3.1) - 0.90); - firstFactor *= (1 + (0.000011 / seedValue)); - return firstFactor; -} - -function calculateSecondFactor(seedValue) { - var secondFactor = 0.78 * (6.3 / 2.1) - (0.39 * 4); - secondFactor *= (1 + (0.000011 / seedValue)); - return secondFactor; -} - -function calculateModificationTerm(seedValue) { - var modificationTerm = (12 + (9*7) - 54 + 16 - ((calculateFirstFactor(seedValue) * seedValue) / 3) + (4*calculateSecondFactor(seedValue) * seedValue * 1.33)) + (calculateSecondFactor(seedValue) * seedValue); - modificationTerm = modificationTerm + (33/2) + 19 - (9*2) - (61*3) + 177; - return modificationTerm; -} diff --git a/tests/benchmarks/declarative/holistic/data/jsImports/mldsi12.js b/tests/benchmarks/declarative/holistic/data/jsImports/mldsi12.js deleted file mode 100644 index 76c14d8771..0000000000 --- a/tests/benchmarks/declarative/holistic/data/jsImports/mldsi12.js +++ /dev/null @@ -1,107 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -// This JavaScript file is a single, large, imported script. -// It imports other large scripts which are deeply nested. -// It is imported by another script. - -.import "msdsi13.js" as Msdsi13 - -function testFunc(seedValue) { - var retn = 0.125; - var firstFactor = calculateFirstFactor(seedValue); - var secondFactor = calculateSecondFactor(seedValue); - var modificationTerm = calculateModificationTerm(seedValue); - - // do some regexp matching - var someString = "This is a random string which we'll perform regular expression matching on to reduce considerably. This is meant to be part of a complex javascript expression whose evaluation takes considerably longer than the creation cost of QScriptValue."; - var regexpPattern = new RegExp("is", "i"); - var regexpOutputLength = 0; - var temp = regexpPattern.exec(someString); - while (temp == "is") { - regexpOutputLength += 4; - regexpOutputLength *= 2; - temp = regexpPattern.exec(someString); - if (regexpOutputLength > (seedValue * 3)) { - temp = "break"; - } - } - - // spin in a for loop for a while - var i = 0; - var j = 0; - var cumulativeTotal = 3; - for (i = 20; i > 1; i--) { - for (j = 31; j > 5; j--) { - var branchVariable = i + j; - if (branchVariable % 3 == 0) { - cumulativeTotal -= secondFactor; - } else { - cumulativeTotal += firstFactor; - } - - if (cumulativeTotal > (seedValue * 50)) { - break; - } - } - } - retn *= (1 + (cumulativeTotal * 0.001)); - retn *= Msdsi13.testFunc(seedValue + retn); - return retn; -} - -function calculateFirstFactor(seedValue) { - var firstFactor = (0.45 * (9.3 / 3.1) - 0.90); - firstFactor *= (1 + (0.000012 / seedValue)); - return firstFactor; -} - -function calculateSecondFactor(seedValue) { - var secondFactor = 0.78 * (6.3 / 2.1) - (0.39 * 4); - secondFactor *= (1 + (0.000012 / seedValue)); - return secondFactor; -} - -function calculateModificationTerm(seedValue) { - var modificationTerm = (12 + (9*7) - 54 + 16 - ((calculateFirstFactor(seedValue) * seedValue) / 3) + (4*calculateSecondFactor(seedValue) * seedValue * 1.33)) + (calculateSecondFactor(seedValue) * seedValue); - modificationTerm = modificationTerm + (33/2) + 19 - (9*2) - (61*3) + 177; - return modificationTerm; -} diff --git a/tests/benchmarks/declarative/holistic/data/jsImports/mldsi13.js b/tests/benchmarks/declarative/holistic/data/jsImports/mldsi13.js deleted file mode 100644 index aaa2c6ab14..0000000000 --- a/tests/benchmarks/declarative/holistic/data/jsImports/mldsi13.js +++ /dev/null @@ -1,107 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -// This JavaScript file is a single, large, imported script. -// It imports other large scripts which are deeply nested. -// It is imported by another script. - -.import "msdsi14.js" as Msdsi14 - -function testFunc(seedValue) { - var retn = 0.135; - var firstFactor = calculateFirstFactor(seedValue); - var secondFactor = calculateSecondFactor(seedValue); - var modificationTerm = calculateModificationTerm(seedValue); - - // do some regexp matching - var someString = "This is a random string which we'll perform regular expression matching on to reduce considerably. This is meant to be part of a complex javascript expression whose evaluation takes considerably longer than the creation cost of QScriptValue."; - var regexpPattern = new RegExp("is", "i"); - var regexpOutputLength = 0; - var temp = regexpPattern.exec(someString); - while (temp == "is") { - regexpOutputLength += 4; - regexpOutputLength *= 2; - temp = regexpPattern.exec(someString); - if (regexpOutputLength > (seedValue * 3)) { - temp = "break"; - } - } - - // spin in a for loop for a while - var i = 0; - var j = 0; - var cumulativeTotal = 3; - for (i = 20; i > 1; i--) { - for (j = 31; j > 5; j--) { - var branchVariable = i + j; - if (branchVariable % 3 == 0) { - cumulativeTotal -= secondFactor; - } else { - cumulativeTotal += firstFactor; - } - - if (cumulativeTotal > (seedValue * 50)) { - break; - } - } - } - retn *= (1 + (cumulativeTotal * 0.001)); - retn *= Msdsi14.testFunc(seedValue + retn); - return retn; -} - -function calculateFirstFactor(seedValue) { - var firstFactor = (0.45 * (9.3 / 3.1) - 0.90); - firstFactor *= (1 + (0.000013 / seedValue)); - return firstFactor; -} - -function calculateSecondFactor(seedValue) { - var secondFactor = 0.78 * (6.3 / 2.1) - (0.39 * 4); - secondFactor *= (1 + (0.000013 / seedValue)); - return secondFactor; -} - -function calculateModificationTerm(seedValue) { - var modificationTerm = (12 + (9*7) - 54 + 16 - ((calculateFirstFactor(seedValue) * seedValue) / 3) + (4*calculateSecondFactor(seedValue) * seedValue * 1.33)) + (calculateSecondFactor(seedValue) * seedValue); - modificationTerm = modificationTerm + (33/2) + 19 - (9*2) - (61*3) + 177; - return modificationTerm; -} diff --git a/tests/benchmarks/declarative/holistic/data/jsImports/mldsi14.js b/tests/benchmarks/declarative/holistic/data/jsImports/mldsi14.js deleted file mode 100644 index 11394a87fb..0000000000 --- a/tests/benchmarks/declarative/holistic/data/jsImports/mldsi14.js +++ /dev/null @@ -1,107 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -// This JavaScript file is a single, large, imported script. -// It imports other large scripts which are deeply nested. -// It is imported by another script. - -.import "msdsi15.js" as Msdsi15 - -function testFunc(seedValue) { - var retn = 0.145; - var firstFactor = calculateFirstFactor(seedValue); - var secondFactor = calculateSecondFactor(seedValue); - var modificationTerm = calculateModificationTerm(seedValue); - - // do some regexp matching - var someString = "This is a random string which we'll perform regular expression matching on to reduce considerably. This is meant to be part of a complex javascript expression whose evaluation takes considerably longer than the creation cost of QScriptValue."; - var regexpPattern = new RegExp("is", "i"); - var regexpOutputLength = 0; - var temp = regexpPattern.exec(someString); - while (temp == "is") { - regexpOutputLength += 4; - regexpOutputLength *= 2; - temp = regexpPattern.exec(someString); - if (regexpOutputLength > (seedValue * 3)) { - temp = "break"; - } - } - - // spin in a for loop for a while - var i = 0; - var j = 0; - var cumulativeTotal = 3; - for (i = 20; i > 1; i--) { - for (j = 31; j > 5; j--) { - var branchVariable = i + j; - if (branchVariable % 3 == 0) { - cumulativeTotal -= secondFactor; - } else { - cumulativeTotal += firstFactor; - } - - if (cumulativeTotal > (seedValue * 50)) { - break; - } - } - } - retn *= (1 + (cumulativeTotal * 0.001)); - retn *= Msdsi15.testFunc(seedValue + retn); - return retn; -} - -function calculateFirstFactor(seedValue) { - var firstFactor = (0.45 * (9.3 / 3.1) - 0.90); - firstFactor *= (1 + (0.000014 / seedValue)); - return firstFactor; -} - -function calculateSecondFactor(seedValue) { - var secondFactor = 0.78 * (6.3 / 2.1) - (0.39 * 4); - secondFactor *= (1 + (0.000014 / seedValue)); - return secondFactor; -} - -function calculateModificationTerm(seedValue) { - var modificationTerm = (12 + (9*7) - 54 + 16 - ((calculateFirstFactor(seedValue) * seedValue) / 3) + (4*calculateSecondFactor(seedValue) * seedValue * 1.33)) + (calculateSecondFactor(seedValue) * seedValue); - modificationTerm = modificationTerm + (33/2) + 19 - (9*2) - (61*3) + 177; - return modificationTerm; -} diff --git a/tests/benchmarks/declarative/holistic/data/jsImports/mldsi15.js b/tests/benchmarks/declarative/holistic/data/jsImports/mldsi15.js deleted file mode 100644 index 2978dbedf3..0000000000 --- a/tests/benchmarks/declarative/holistic/data/jsImports/mldsi15.js +++ /dev/null @@ -1,104 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -// This JavaScript file is a single, large, imported script. -// It is imported by another script. - -function testFunc(seedValue) { - var retn = 0.155; - var firstFactor = calculateFirstFactor(seedValue); - var secondFactor = calculateSecondFactor(seedValue); - var modificationTerm = calculateModificationTerm(seedValue); - - // do some regexp matching - var someString = "This is a random string which we'll perform regular expression matching on to reduce considerably. This is meant to be part of a complex javascript expression whose evaluation takes considerably longer than the creation cost of QScriptValue."; - var regexpPattern = new RegExp("is", "i"); - var regexpOutputLength = 0; - var temp = regexpPattern.exec(someString); - while (temp == "is") { - regexpOutputLength += 4; - regexpOutputLength *= 2; - temp = regexpPattern.exec(someString); - if (regexpOutputLength > (seedValue * 3)) { - temp = "break"; - } - } - - // spin in a for loop for a while - var i = 0; - var j = 0; - var cumulativeTotal = 3; - for (i = 20; i > 1; i--) { - for (j = 31; j > 5; j--) { - var branchVariable = i + j; - if (branchVariable % 3 == 0) { - cumulativeTotal -= secondFactor; - } else { - cumulativeTotal += firstFactor; - } - - if (cumulativeTotal > (seedValue * 50)) { - break; - } - } - } - retn *= (1 + (cumulativeTotal * 0.001)); - retn *= (seedValue + retn); - return retn; -} - -function calculateFirstFactor(seedValue) { - var firstFactor = (0.45 * (9.3 / 3.1) - 0.90); - firstFactor *= (1 + (0.000015 / seedValue)); - return firstFactor; -} - -function calculateSecondFactor(seedValue) { - var secondFactor = 0.78 * (6.3 / 2.1) - (0.39 * 4); - secondFactor *= (1 + (0.000015 / seedValue)); - return secondFactor; -} - -function calculateModificationTerm(seedValue) { - var modificationTerm = (12 + (9*7) - 54 + 16 - ((calculateFirstFactor(seedValue) * seedValue) / 3) + (4*calculateSecondFactor(seedValue) * seedValue * 1.33)) + (calculateSecondFactor(seedValue) * seedValue); - modificationTerm = modificationTerm + (33/2) + 19 - (9*2) - (61*3) + 177; - return modificationTerm; -} diff --git a/tests/benchmarks/declarative/holistic/data/jsImports/mldsi2.js b/tests/benchmarks/declarative/holistic/data/jsImports/mldsi2.js deleted file mode 100644 index f9105c07f2..0000000000 --- a/tests/benchmarks/declarative/holistic/data/jsImports/mldsi2.js +++ /dev/null @@ -1,107 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -// This JavaScript file is a single, large, imported script. -// It imports other large scripts which are deeply nested. -// It is imported by another script. - -.import "msdsi3.js" as Msdsi3 - -function testFunc(seedValue) { - var retn = 0.25; - var firstFactor = calculateFirstFactor(seedValue); - var secondFactor = calculateSecondFactor(seedValue); - var modificationTerm = calculateModificationTerm(seedValue); - - // do some regexp matching - var someString = "This is a random string which we'll perform regular expression matching on to reduce considerably. This is meant to be part of a complex javascript expression whose evaluation takes considerably longer than the creation cost of QScriptValue."; - var regexpPattern = new RegExp("is", "i"); - var regexpOutputLength = 0; - var temp = regexpPattern.exec(someString); - while (temp == "is") { - regexpOutputLength += 4; - regexpOutputLength *= 2; - temp = regexpPattern.exec(someString); - if (regexpOutputLength > (seedValue * 3)) { - temp = "break"; - } - } - - // spin in a for loop for a while - var i = 0; - var j = 0; - var cumulativeTotal = 3; - for (i = 20; i > 1; i--) { - for (j = 31; j > 5; j--) { - var branchVariable = i + j; - if (branchVariable % 3 == 0) { - cumulativeTotal -= secondFactor; - } else { - cumulativeTotal += firstFactor; - } - - if (cumulativeTotal > (seedValue * 50)) { - break; - } - } - } - retn *= (1 + (cumulativeTotal * 0.001)); - retn *= Msdsi3.testFunc(seedValue + retn); - return retn; -} - -function calculateFirstFactor(seedValue) { - var firstFactor = (0.45 * (9.3 / 3.1) - 0.90); - firstFactor *= (1 + (0.00002 / seedValue)); - return firstFactor; -} - -function calculateSecondFactor(seedValue) { - var secondFactor = 0.78 * (6.3 / 2.1) - (0.39 * 4); - secondFactor *= (1 + (0.00002 / seedValue)); - return secondFactor; -} - -function calculateModificationTerm(seedValue) { - var modificationTerm = (12 + (9*7) - 54 + 16 - ((calculateFirstFactor(seedValue) * seedValue) / 3) + (4*calculateSecondFactor(seedValue) * seedValue * 1.33)) + (calculateSecondFactor(seedValue) * seedValue); - modificationTerm = modificationTerm + (33/2) + 19 - (9*2) - (61*3) + 177; - return modificationTerm; -} diff --git a/tests/benchmarks/declarative/holistic/data/jsImports/mldsi3.js b/tests/benchmarks/declarative/holistic/data/jsImports/mldsi3.js deleted file mode 100644 index 046988b47a..0000000000 --- a/tests/benchmarks/declarative/holistic/data/jsImports/mldsi3.js +++ /dev/null @@ -1,107 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -// This JavaScript file is a single, large, imported script. -// It imports other large scripts which are deeply nested. -// It is imported by another script. - -.import "msdsi4.js" as Msdsi4 - -function testFunc(seedValue) { - var retn = 0.35; - var firstFactor = calculateFirstFactor(seedValue); - var secondFactor = calculateSecondFactor(seedValue); - var modificationTerm = calculateModificationTerm(seedValue); - - // do some regexp matching - var someString = "This is a random string which we'll perform regular expression matching on to reduce considerably. This is meant to be part of a complex javascript expression whose evaluation takes considerably longer than the creation cost of QScriptValue."; - var regexpPattern = new RegExp("is", "i"); - var regexpOutputLength = 0; - var temp = regexpPattern.exec(someString); - while (temp == "is") { - regexpOutputLength += 4; - regexpOutputLength *= 2; - temp = regexpPattern.exec(someString); - if (regexpOutputLength > (seedValue * 3)) { - temp = "break"; - } - } - - // spin in a for loop for a while - var i = 0; - var j = 0; - var cumulativeTotal = 3; - for (i = 20; i > 1; i--) { - for (j = 31; j > 5; j--) { - var branchVariable = i + j; - if (branchVariable % 3 == 0) { - cumulativeTotal -= secondFactor; - } else { - cumulativeTotal += firstFactor; - } - - if (cumulativeTotal > (seedValue * 50)) { - break; - } - } - } - retn *= (1 + (cumulativeTotal * 0.001)); - retn *= Msdsi4.testFunc(seedValue + retn); - return retn; -} - -function calculateFirstFactor(seedValue) { - var firstFactor = (0.45 * (9.3 / 3.1) - 0.90); - firstFactor *= (1 + (0.00003 / seedValue)); - return firstFactor; -} - -function calculateSecondFactor(seedValue) { - var secondFactor = 0.78 * (6.3 / 2.1) - (0.39 * 4); - secondFactor *= (1 + (0.00003 / seedValue)); - return secondFactor; -} - -function calculateModificationTerm(seedValue) { - var modificationTerm = (12 + (9*7) - 54 + 16 - ((calculateFirstFactor(seedValue) * seedValue) / 3) + (4*calculateSecondFactor(seedValue) * seedValue * 1.33)) + (calculateSecondFactor(seedValue) * seedValue); - modificationTerm = modificationTerm + (33/2) + 19 - (9*2) - (61*3) + 177; - return modificationTerm; -} diff --git a/tests/benchmarks/declarative/holistic/data/jsImports/mldsi4.js b/tests/benchmarks/declarative/holistic/data/jsImports/mldsi4.js deleted file mode 100644 index 7996c0d3f1..0000000000 --- a/tests/benchmarks/declarative/holistic/data/jsImports/mldsi4.js +++ /dev/null @@ -1,107 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -// This JavaScript file is a single, large, imported script. -// It imports other large scripts which are deeply nested. -// It is imported by another script. - -.import "msdsi5.js" as Msdsi5 - -function testFunc(seedValue) { - var retn = 0.45; - var firstFactor = calculateFirstFactor(seedValue); - var secondFactor = calculateSecondFactor(seedValue); - var modificationTerm = calculateModificationTerm(seedValue); - - // do some regexp matching - var someString = "This is a random string which we'll perform regular expression matching on to reduce considerably. This is meant to be part of a complex javascript expression whose evaluation takes considerably longer than the creation cost of QScriptValue."; - var regexpPattern = new RegExp("is", "i"); - var regexpOutputLength = 0; - var temp = regexpPattern.exec(someString); - while (temp == "is") { - regexpOutputLength += 4; - regexpOutputLength *= 2; - temp = regexpPattern.exec(someString); - if (regexpOutputLength > (seedValue * 3)) { - temp = "break"; - } - } - - // spin in a for loop for a while - var i = 0; - var j = 0; - var cumulativeTotal = 3; - for (i = 20; i > 1; i--) { - for (j = 31; j > 5; j--) { - var branchVariable = i + j; - if (branchVariable % 3 == 0) { - cumulativeTotal -= secondFactor; - } else { - cumulativeTotal += firstFactor; - } - - if (cumulativeTotal > (seedValue * 50)) { - break; - } - } - } - retn *= (1 + (cumulativeTotal * 0.001)); - retn *= Msdsi5.testFunc(seedValue + retn); - return retn; -} - -function calculateFirstFactor(seedValue) { - var firstFactor = (0.45 * (9.3 / 3.1) - 0.90); - firstFactor *= (1 + (0.00004 / seedValue)); - return firstFactor; -} - -function calculateSecondFactor(seedValue) { - var secondFactor = 0.78 * (6.3 / 2.1) - (0.39 * 4); - secondFactor *= (1 + (0.00004 / seedValue)); - return secondFactor; -} - -function calculateModificationTerm(seedValue) { - var modificationTerm = (12 + (9*7) - 54 + 16 - ((calculateFirstFactor(seedValue) * seedValue) / 3) + (4*calculateSecondFactor(seedValue) * seedValue * 1.33)) + (calculateSecondFactor(seedValue) * seedValue); - modificationTerm = modificationTerm + (33/2) + 19 - (9*2) - (61*3) + 177; - return modificationTerm; -} diff --git a/tests/benchmarks/declarative/holistic/data/jsImports/mldsi5.js b/tests/benchmarks/declarative/holistic/data/jsImports/mldsi5.js deleted file mode 100644 index 183a09153a..0000000000 --- a/tests/benchmarks/declarative/holistic/data/jsImports/mldsi5.js +++ /dev/null @@ -1,107 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -// This JavaScript file is a single, large, imported script. -// It imports other large scripts which are deeply nested. -// It is imported by another script. - -.import "msdsi6.js" as Msdsi6 - -function testFunc(seedValue) { - var retn = 0.55; - var firstFactor = calculateFirstFactor(seedValue); - var secondFactor = calculateSecondFactor(seedValue); - var modificationTerm = calculateModificationTerm(seedValue); - - // do some regexp matching - var someString = "This is a random string which we'll perform regular expression matching on to reduce considerably. This is meant to be part of a complex javascript expression whose evaluation takes considerably longer than the creation cost of QScriptValue."; - var regexpPattern = new RegExp("is", "i"); - var regexpOutputLength = 0; - var temp = regexpPattern.exec(someString); - while (temp == "is") { - regexpOutputLength += 4; - regexpOutputLength *= 2; - temp = regexpPattern.exec(someString); - if (regexpOutputLength > (seedValue * 3)) { - temp = "break"; - } - } - - // spin in a for loop for a while - var i = 0; - var j = 0; - var cumulativeTotal = 3; - for (i = 20; i > 1; i--) { - for (j = 31; j > 5; j--) { - var branchVariable = i + j; - if (branchVariable % 3 == 0) { - cumulativeTotal -= secondFactor; - } else { - cumulativeTotal += firstFactor; - } - - if (cumulativeTotal > (seedValue * 50)) { - break; - } - } - } - retn *= (1 + (cumulativeTotal * 0.001)); - retn *= Msdsi6.testFunc(seedValue + retn); - return retn; -} - -function calculateFirstFactor(seedValue) { - var firstFactor = (0.45 * (9.3 / 3.1) - 0.90); - firstFactor *= (1 + (0.00005 / seedValue)); - return firstFactor; -} - -function calculateSecondFactor(seedValue) { - var secondFactor = 0.78 * (6.3 / 2.1) - (0.39 * 4); - secondFactor *= (1 + (0.00005 / seedValue)); - return secondFactor; -} - -function calculateModificationTerm(seedValue) { - var modificationTerm = (12 + (9*7) - 54 + 16 - ((calculateFirstFactor(seedValue) * seedValue) / 3) + (4*calculateSecondFactor(seedValue) * seedValue * 1.33)) + (calculateSecondFactor(seedValue) * seedValue); - modificationTerm = modificationTerm + (33/2) + 19 - (9*2) - (61*3) + 177; - return modificationTerm; -} diff --git a/tests/benchmarks/declarative/holistic/data/jsImports/mldsi6.js b/tests/benchmarks/declarative/holistic/data/jsImports/mldsi6.js deleted file mode 100644 index ad17faa47d..0000000000 --- a/tests/benchmarks/declarative/holistic/data/jsImports/mldsi6.js +++ /dev/null @@ -1,107 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -// This JavaScript file is a single, large, imported script. -// It imports other large scripts which are deeply nested. -// It is imported by another script. - -.import "msdsi7.js" as Msdsi7 - -function testFunc(seedValue) { - var retn = 0.65; - var firstFactor = calculateFirstFactor(seedValue); - var secondFactor = calculateSecondFactor(seedValue); - var modificationTerm = calculateModificationTerm(seedValue); - - // do some regexp matching - var someString = "This is a random string which we'll perform regular expression matching on to reduce considerably. This is meant to be part of a complex javascript expression whose evaluation takes considerably longer than the creation cost of QScriptValue."; - var regexpPattern = new RegExp("is", "i"); - var regexpOutputLength = 0; - var temp = regexpPattern.exec(someString); - while (temp == "is") { - regexpOutputLength += 4; - regexpOutputLength *= 2; - temp = regexpPattern.exec(someString); - if (regexpOutputLength > (seedValue * 3)) { - temp = "break"; - } - } - - // spin in a for loop for a while - var i = 0; - var j = 0; - var cumulativeTotal = 3; - for (i = 20; i > 1; i--) { - for (j = 31; j > 5; j--) { - var branchVariable = i + j; - if (branchVariable % 3 == 0) { - cumulativeTotal -= secondFactor; - } else { - cumulativeTotal += firstFactor; - } - - if (cumulativeTotal > (seedValue * 50)) { - break; - } - } - } - retn *= (1 + (cumulativeTotal * 0.001)); - retn *= Msdsi7.testFunc(seedValue + retn); - return retn; -} - -function calculateFirstFactor(seedValue) { - var firstFactor = (0.45 * (9.3 / 3.1) - 0.90); - firstFactor *= (1 + (0.00006 / seedValue)); - return firstFactor; -} - -function calculateSecondFactor(seedValue) { - var secondFactor = 0.78 * (6.3 / 2.1) - (0.39 * 4); - secondFactor *= (1 + (0.00006 / seedValue)); - return secondFactor; -} - -function calculateModificationTerm(seedValue) { - var modificationTerm = (12 + (9*7) - 54 + 16 - ((calculateFirstFactor(seedValue) * seedValue) / 3) + (4*calculateSecondFactor(seedValue) * seedValue * 1.33)) + (calculateSecondFactor(seedValue) * seedValue); - modificationTerm = modificationTerm + (33/2) + 19 - (9*2) - (61*3) + 177; - return modificationTerm; -} diff --git a/tests/benchmarks/declarative/holistic/data/jsImports/mldsi7.js b/tests/benchmarks/declarative/holistic/data/jsImports/mldsi7.js deleted file mode 100644 index 07e69fe6ee..0000000000 --- a/tests/benchmarks/declarative/holistic/data/jsImports/mldsi7.js +++ /dev/null @@ -1,107 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -// This JavaScript file is a single, large, imported script. -// It imports other large scripts which are deeply nested. -// It is imported by another script. - -.import "msdsi8.js" as Msdsi8 - -function testFunc(seedValue) { - var retn = 0.75; - var firstFactor = calculateFirstFactor(seedValue); - var secondFactor = calculateSecondFactor(seedValue); - var modificationTerm = calculateModificationTerm(seedValue); - - // do some regexp matching - var someString = "This is a random string which we'll perform regular expression matching on to reduce considerably. This is meant to be part of a complex javascript expression whose evaluation takes considerably longer than the creation cost of QScriptValue."; - var regexpPattern = new RegExp("is", "i"); - var regexpOutputLength = 0; - var temp = regexpPattern.exec(someString); - while (temp == "is") { - regexpOutputLength += 4; - regexpOutputLength *= 2; - temp = regexpPattern.exec(someString); - if (regexpOutputLength > (seedValue * 3)) { - temp = "break"; - } - } - - // spin in a for loop for a while - var i = 0; - var j = 0; - var cumulativeTotal = 3; - for (i = 20; i > 1; i--) { - for (j = 31; j > 5; j--) { - var branchVariable = i + j; - if (branchVariable % 3 == 0) { - cumulativeTotal -= secondFactor; - } else { - cumulativeTotal += firstFactor; - } - - if (cumulativeTotal > (seedValue * 50)) { - break; - } - } - } - retn *= (1 + (cumulativeTotal * 0.001)); - retn *= Msdsi8.testFunc(seedValue + retn); - return retn; -} - -function calculateFirstFactor(seedValue) { - var firstFactor = (0.45 * (9.3 / 3.1) - 0.90); - firstFactor *= (1 + (0.00007 / seedValue)); - return firstFactor; -} - -function calculateSecondFactor(seedValue) { - var secondFactor = 0.78 * (6.3 / 2.1) - (0.39 * 4); - secondFactor *= (1 + (0.00007 / seedValue)); - return secondFactor; -} - -function calculateModificationTerm(seedValue) { - var modificationTerm = (12 + (9*7) - 54 + 16 - ((calculateFirstFactor(seedValue) * seedValue) / 3) + (4*calculateSecondFactor(seedValue) * seedValue * 1.33)) + (calculateSecondFactor(seedValue) * seedValue); - modificationTerm = modificationTerm + (33/2) + 19 - (9*2) - (61*3) + 177; - return modificationTerm; -} diff --git a/tests/benchmarks/declarative/holistic/data/jsImports/mldsi8.js b/tests/benchmarks/declarative/holistic/data/jsImports/mldsi8.js deleted file mode 100644 index cf245f461c..0000000000 --- a/tests/benchmarks/declarative/holistic/data/jsImports/mldsi8.js +++ /dev/null @@ -1,107 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -// This JavaScript file is a single, large, imported script. -// It imports other large scripts which are deeply nested. -// It is imported by another script. - -.import "msdsi9.js" as Msdsi9 - -function testFunc(seedValue) { - var retn = 0.85; - var firstFactor = calculateFirstFactor(seedValue); - var secondFactor = calculateSecondFactor(seedValue); - var modificationTerm = calculateModificationTerm(seedValue); - - // do some regexp matching - var someString = "This is a random string which we'll perform regular expression matching on to reduce considerably. This is meant to be part of a complex javascript expression whose evaluation takes considerably longer than the creation cost of QScriptValue."; - var regexpPattern = new RegExp("is", "i"); - var regexpOutputLength = 0; - var temp = regexpPattern.exec(someString); - while (temp == "is") { - regexpOutputLength += 4; - regexpOutputLength *= 2; - temp = regexpPattern.exec(someString); - if (regexpOutputLength > (seedValue * 3)) { - temp = "break"; - } - } - - // spin in a for loop for a while - var i = 0; - var j = 0; - var cumulativeTotal = 3; - for (i = 20; i > 1; i--) { - for (j = 31; j > 5; j--) { - var branchVariable = i + j; - if (branchVariable % 3 == 0) { - cumulativeTotal -= secondFactor; - } else { - cumulativeTotal += firstFactor; - } - - if (cumulativeTotal > (seedValue * 50)) { - break; - } - } - } - retn *= (1 + (cumulativeTotal * 0.001)); - retn *= Msdsi9.testFunc(seedValue + retn); - return retn; -} - -function calculateFirstFactor(seedValue) { - var firstFactor = (0.45 * (9.3 / 3.1) - 0.90); - firstFactor *= (1 + (0.00008 / seedValue)); - return firstFactor; -} - -function calculateSecondFactor(seedValue) { - var secondFactor = 0.78 * (6.3 / 2.1) - (0.39 * 4); - secondFactor *= (1 + (0.00008 / seedValue)); - return secondFactor; -} - -function calculateModificationTerm(seedValue) { - var modificationTerm = (12 + (9*7) - 54 + 16 - ((calculateFirstFactor(seedValue) * seedValue) / 3) + (4*calculateSecondFactor(seedValue) * seedValue * 1.33)) + (calculateSecondFactor(seedValue) * seedValue); - modificationTerm = modificationTerm + (33/2) + 19 - (9*2) - (61*3) + 177; - return modificationTerm; -} diff --git a/tests/benchmarks/declarative/holistic/data/jsImports/mldsi9.js b/tests/benchmarks/declarative/holistic/data/jsImports/mldsi9.js deleted file mode 100644 index 2286e15d79..0000000000 --- a/tests/benchmarks/declarative/holistic/data/jsImports/mldsi9.js +++ /dev/null @@ -1,107 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -// This JavaScript file is a single, large, imported script. -// It imports other large scripts which are deeply nested. -// It is imported by another script. - -.import "msdsi10.js" as Msdsi10 - -function testFunc(seedValue) { - var retn = 0.95; - var firstFactor = calculateFirstFactor(seedValue); - var secondFactor = calculateSecondFactor(seedValue); - var modificationTerm = calculateModificationTerm(seedValue); - - // do some regexp matching - var someString = "This is a random string which we'll perform regular expression matching on to reduce considerably. This is meant to be part of a complex javascript expression whose evaluation takes considerably longer than the creation cost of QScriptValue."; - var regexpPattern = new RegExp("is", "i"); - var regexpOutputLength = 0; - var temp = regexpPattern.exec(someString); - while (temp == "is") { - regexpOutputLength += 4; - regexpOutputLength *= 2; - temp = regexpPattern.exec(someString); - if (regexpOutputLength > (seedValue * 3)) { - temp = "break"; - } - } - - // spin in a for loop for a while - var i = 0; - var j = 0; - var cumulativeTotal = 3; - for (i = 20; i > 1; i--) { - for (j = 31; j > 5; j--) { - var branchVariable = i + j; - if (branchVariable % 3 == 0) { - cumulativeTotal -= secondFactor; - } else { - cumulativeTotal += firstFactor; - } - - if (cumulativeTotal > (seedValue * 50)) { - break; - } - } - } - retn *= (1 + (cumulativeTotal * 0.001)); - retn *= Msdsi10.testFunc(seedValue + retn); - return retn; -} - -function calculateFirstFactor(seedValue) { - var firstFactor = (0.45 * (9.3 / 3.1) - 0.90); - firstFactor *= (1 + (0.00009 / seedValue)); - return firstFactor; -} - -function calculateSecondFactor(seedValue) { - var secondFactor = 0.78 * (6.3 / 2.1) - (0.39 * 4); - secondFactor *= (1 + (0.00009 / seedValue)); - return secondFactor; -} - -function calculateModificationTerm(seedValue) { - var modificationTerm = (12 + (9*7) - 54 + 16 - ((calculateFirstFactor(seedValue) * seedValue) / 3) + (4*calculateSecondFactor(seedValue) * seedValue * 1.33)) + (calculateSecondFactor(seedValue) * seedValue); - modificationTerm = modificationTerm + (33/2) + 19 - (9*2) - (61*3) + 177; - return modificationTerm; -} diff --git a/tests/benchmarks/declarative/holistic/data/jsImports/mlsi.js b/tests/benchmarks/declarative/holistic/data/jsImports/mlsi.js deleted file mode 100644 index 8c05cfb8bd..0000000000 --- a/tests/benchmarks/declarative/holistic/data/jsImports/mlsi.js +++ /dev/null @@ -1,138 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -// This JavaScript file is a single, large, imported script. -// It imports many other (non-nested) single, large, scripts, -// and also imports many other nested, large scripts. - -.import "mldsi4.js" as Mldsi4 -.import "mldsi9.js" as Mldsi9 -.import "mlbsi1.js" as Mlbsi1 -.import "mlbsi2.js" as Mlbsi2 -.import "mlbsi3.js" as Mlbsi3 -.import "mlbsi4.js" as Mlbsi4 -.import "mlbsi5.js" as Mlbsi5 -.import "mlbsi6.js" as Mlbsi6 -.import "mlbsi7.js" as Mlbsi7 -.import "mlbsi8.js" as Mlbsi8 -.import "mlbsi9.js" as Mlbsi9 -.import "mlbsi10.js" as Mlbsi10 -.import "mlbsi11.js" as Mlbsi11 -.import "mlbsi12.js" as Mlbsi12 -.import "mlbsi13.js" as Mlbsi13 -.import "mlbsi14.js" as Mlbsi14 -.import "mlbsi15.js" as Mlbsi15 - -function testFunc(seedValue) { - var firstFactor = calculateFirstFactor(seedValue); - var secondFactor = calculateSecondFactor(seedValue); - var modificationTerm = calculateModificationTerm(seedValue); - - // do some regexp matching - var someString = "This is a random string which we'll perform regular expression matching on to reduce considerably. This is meant to be part of a complex javascript expression whose evaluation takes considerably longer than the creation cost of QScriptValue."; - var regexpPattern = new RegExp("is", "i"); - var regexpOutputLength = 0; - var temp = regexpPattern.exec(someString); - while (temp == "is") { - regexpOutputLength += 4; - regexpOutputLength *= 2; - temp = regexpPattern.exec(someString); - if (regexpOutputLength > (seedValue * 3)) { - temp = "break"; - } - } - - // spin in a for loop for a while - var i = 0; - var j = 0; - var cumulativeTotal = 3; - for (i = 20; i > 1; i--) { - for (j = 31; j > 5; j--) { - var branchVariable = i + j; - if (branchVariable % 3 == 0) { - cumulativeTotal -= secondFactor; - } else { - cumulativeTotal += firstFactor; - } - - if (cumulativeTotal > (seedValue * 50)) { - break; - } - } - } - var retn = cumulativeTotal; - retn += Mlbsi1.testFunc(seedValue); - retn += Mlbsi2.testFunc(seedValue); - retn += Mlbsi3.testFunc(retn); - retn += Mlbsi4.testFunc(seedValue); - retn += Mlbsi5.testFunc(seedValue); - retn += Mlbsi6.testFunc(seedValue); - retn *= Mldsi9.testFunc(retn); - retn += Mlbsi7.testFunc(seedValue); - retn += Mlbsi8.testFunc(retn); - retn += Mlbsi9.testFunc(seedValue); - retn += Mlbsi10.testFunc(seedValue); - retn += Mlbsi11.testFunc(seedValue); - retn *= Mldsi4.testFunc(retn); - retn += Mlbsi12.testFunc(seedValue); - retn += Mlbsi13.testFunc(retn); - retn += Mlbsi14.testFunc(seedValue); - retn += Mlbsi15.testFunc(seedValue); - return retn; -} - -function calculateFirstFactor(seedValue) { - var firstFactor = (0.45 * (9.3 / 3.1) - 0.90); - firstFactor *= (1 + (0.00001 / seedValue)); - return firstFactor; -} - -function calculateSecondFactor(seedValue) { - var secondFactor = 0.78 * (6.3 / 2.1) - (0.39 * 4); - secondFactor *= (1 + (0.00001 / seedValue)); - return secondFactor; -} - -function calculateModificationTerm(seedValue) { - var modificationTerm = (12 + (9*7) - 54 + 16 - ((calculateFirstFactor(seedValue) * seedValue) / 3) + (4*calculateSecondFactor(seedValue) * seedValue * 1.33)) + (calculateSecondFactor(seedValue) * seedValue); - modificationTerm = modificationTerm + (33/2) + 19 - (9*2) - (61*3) + 177; - return modificationTerm; -} diff --git a/tests/benchmarks/declarative/holistic/data/jsImports/moduleBm.js b/tests/benchmarks/declarative/holistic/data/jsImports/moduleBm.js deleted file mode 100644 index 29bd1f83af..0000000000 --- a/tests/benchmarks/declarative/holistic/data/jsImports/moduleBm.js +++ /dev/null @@ -1,109 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -// This JavaScript file is a single, large, imported script. -// It doesn't import any other scripts. -.import Qt.test 1.0 as QtTest - -function testFunc(seedValue) { - var retn = QtTest.EnumValue3; - var firstFactor = calculateFirstFactor(seedValue); - var secondFactor = calculateSecondFactor(seedValue); - var modificationTerm = calculateModificationTerm(seedValue); - - // do some regexp matching - var someString = "This is a random string which we'll perform regular expression matching on to reduce considerably. This is meant to be part of a complex javascript expression whose evaluation takes considerably longer than the creation cost of QScriptValue."; - var regexpPattern = new RegExp("is", "i"); - var regexpOutputLength = 0; - var temp = regexpPattern.exec(someString); - while (temp == "is") { - regexpOutputLength += 4; - regexpOutputLength *= 2; - temp = regexpPattern.exec(someString); - if (regexpOutputLength > (seedValue * 3)) { - temp = "break"; - } - } - - // spin in a for loop for a while - var i = 0; - var j = 0; - var cumulativeTotal = 3; - for (i = 20; i > 1; i--) { - for (j = 31; j > 5; j--) { - var branchVariable = i + j; - if (branchVariable % 3 == 0) { - cumulativeTotal -= secondFactor; - } else { - cumulativeTotal += firstFactor; - } - - if (cumulativeTotal > (seedValue * 50)) { - break; - } - } - } - retn += (cumulativeTotal * 0.45); - retn *= (1 + (3.1415962 / seedValue)); - retn /= 2.41497; - retn -= (seedValue * -1); - return retn; -} - -function calculateFirstFactor(seedValue) { - var firstFactor = (0.45 * (9.3 / 3.1) - 0.90); - firstFactor *= (1 + (0.00001 / seedValue)); - return firstFactor; -} - -function calculateSecondFactor(seedValue) { - var secondFactor = 0.78 * (6.3 / 2.1) - (0.39 * 4); - secondFactor *= (1 + (0.00001 / seedValue)); - return secondFactor; -} - -function calculateModificationTerm(seedValue) { - var modificationTerm = (12 + (9*7) - 54 + 16 - ((calculateFirstFactor(seedValue) * seedValue) / 3) + (4*calculateSecondFactor(seedValue) * seedValue * 1.33)) + (calculateSecondFactor(seedValue) * seedValue); - modificationTerm = modificationTerm + (33/2) + 19 - (9*2) - (61*3) + 177; - return modificationTerm; -} - - diff --git a/tests/benchmarks/declarative/holistic/data/jsImports/msbsi.js b/tests/benchmarks/declarative/holistic/data/jsImports/msbsi.js deleted file mode 100644 index 5126faca00..0000000000 --- a/tests/benchmarks/declarative/holistic/data/jsImports/msbsi.js +++ /dev/null @@ -1,79 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -// This JavaScript file is a single, small, imported script. -// It imports many other (non-nested) single, small, scripts. - -.import "msbsi1.js" as Msbsi1 -.import "msbsi2.js" as Msbsi2 -.import "msbsi3.js" as Msbsi3 -.import "msbsi4.js" as Msbsi4 -.import "msbsi5.js" as Msbsi5 -.import "msbsi6.js" as Msbsi6 -.import "msbsi7.js" as Msbsi7 -.import "msbsi8.js" as Msbsi8 -.import "msbsi9.js" as Msbsi9 -.import "msbsi10.js" as Msbsi10 -.import "msbsi11.js" as Msbsi11 -.import "msbsi12.js" as Msbsi12 -.import "msbsi13.js" as Msbsi13 -.import "msbsi14.js" as Msbsi14 -.import "msbsi15.js" as Msbsi15 - -function testFunc(seedValue) { - var retn = 10 * (seedValue * 0.45); - retn += Msbsi1.testFunc(seedValue); - retn += Msbsi2.testFunc(seedValue); - retn += Msbsi3.testFunc(seedValue); - retn += Msbsi4.testFunc(seedValue); - retn += Msbsi5.testFunc(seedValue); - retn += Msbsi6.testFunc(seedValue); - retn += Msbsi7.testFunc(seedValue); - retn += Msbsi8.testFunc(seedValue); - retn += Msbsi9.testFunc(seedValue); - retn += Msbsi10.testFunc(seedValue); - retn += Msbsi11.testFunc(seedValue); - retn += Msbsi12.testFunc(seedValue); - retn += Msbsi13.testFunc(seedValue); - retn += Msbsi14.testFunc(seedValue); - retn += Msbsi15.testFunc(seedValue); - return retn; -} diff --git a/tests/benchmarks/declarative/holistic/data/jsImports/msbsi1.js b/tests/benchmarks/declarative/holistic/data/jsImports/msbsi1.js deleted file mode 100644 index d5ba35fc97..0000000000 --- a/tests/benchmarks/declarative/holistic/data/jsImports/msbsi1.js +++ /dev/null @@ -1,53 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -// This JavaScript file is a single, small, imported script. -// It doesn't import any other scripts. -// It is imported from another script. - -function testFunc(seedValue) { - var retn = 5; - retn += (seedValue * 0.145); - retn *= (1 + (3.1415962 / seedValue)); - retn /= 2.41497; - retn -= (seedValue * -1); - return retn; -} diff --git a/tests/benchmarks/declarative/holistic/data/jsImports/msbsi10.js b/tests/benchmarks/declarative/holistic/data/jsImports/msbsi10.js deleted file mode 100644 index f24ad0f7ee..0000000000 --- a/tests/benchmarks/declarative/holistic/data/jsImports/msbsi10.js +++ /dev/null @@ -1,53 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -// This JavaScript file is a single, small, imported script. -// It doesn't import any other scripts. -// It is imported from another script. - -function testFunc(seedValue) { - var retn = 5; - retn += (seedValue * 0.1045); - retn *= (1 + (3.1415962 / seedValue)); - retn /= 2.41497; - retn -= (seedValue * -1); - return retn; -} diff --git a/tests/benchmarks/declarative/holistic/data/jsImports/msbsi11.js b/tests/benchmarks/declarative/holistic/data/jsImports/msbsi11.js deleted file mode 100644 index 30e072ab04..0000000000 --- a/tests/benchmarks/declarative/holistic/data/jsImports/msbsi11.js +++ /dev/null @@ -1,53 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -// This JavaScript file is a single, small, imported script. -// It doesn't import any other scripts. -// It is imported from another script. - -function testFunc(seedValue) { - var retn = 5; - retn += (seedValue * 0.1145); - retn *= (1 + (3.1415962 / seedValue)); - retn /= 2.41497; - retn -= (seedValue * -1); - return retn; -} diff --git a/tests/benchmarks/declarative/holistic/data/jsImports/msbsi12.js b/tests/benchmarks/declarative/holistic/data/jsImports/msbsi12.js deleted file mode 100644 index 3bf414a0ec..0000000000 --- a/tests/benchmarks/declarative/holistic/data/jsImports/msbsi12.js +++ /dev/null @@ -1,53 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -// This JavaScript file is a single, small, imported script. -// It doesn't import any other scripts. -// It is imported from another script. - -function testFunc(seedValue) { - var retn = 5; - retn += (seedValue * 0.1245); - retn *= (1 + (3.1415962 / seedValue)); - retn /= 2.41497; - retn -= (seedValue * -1); - return retn; -} diff --git a/tests/benchmarks/declarative/holistic/data/jsImports/msbsi13.js b/tests/benchmarks/declarative/holistic/data/jsImports/msbsi13.js deleted file mode 100644 index 7487b7f1a9..0000000000 --- a/tests/benchmarks/declarative/holistic/data/jsImports/msbsi13.js +++ /dev/null @@ -1,53 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -// This JavaScript file is a single, small, imported script. -// It doesn't import any other scripts. -// It is imported from another script. - -function testFunc(seedValue) { - var retn = 5; - retn += (seedValue * 0.1345); - retn *= (1 + (3.1415962 / seedValue)); - retn /= 2.41497; - retn -= (seedValue * -1); - return retn; -} diff --git a/tests/benchmarks/declarative/holistic/data/jsImports/msbsi14.js b/tests/benchmarks/declarative/holistic/data/jsImports/msbsi14.js deleted file mode 100644 index 504b365752..0000000000 --- a/tests/benchmarks/declarative/holistic/data/jsImports/msbsi14.js +++ /dev/null @@ -1,53 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -// This JavaScript file is a single, small, imported script. -// It doesn't import any other scripts. -// It is imported from another script. - -function testFunc(seedValue) { - var retn = 5; - retn += (seedValue * 0.1445); - retn *= (1 + (3.1415962 / seedValue)); - retn /= 2.41497; - retn -= (seedValue * -1); - return retn; -} diff --git a/tests/benchmarks/declarative/holistic/data/jsImports/msbsi15.js b/tests/benchmarks/declarative/holistic/data/jsImports/msbsi15.js deleted file mode 100644 index 1887f157c1..0000000000 --- a/tests/benchmarks/declarative/holistic/data/jsImports/msbsi15.js +++ /dev/null @@ -1,53 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -// This JavaScript file is a single, small, imported script. -// It doesn't import any other scripts. -// It is imported from another script. - -function testFunc(seedValue) { - var retn = 5; - retn += (seedValue * 0.1545); - retn *= (1 + (3.1415962 / seedValue)); - retn /= 2.41497; - retn -= (seedValue * -1); - return retn; -} diff --git a/tests/benchmarks/declarative/holistic/data/jsImports/msbsi2.js b/tests/benchmarks/declarative/holistic/data/jsImports/msbsi2.js deleted file mode 100644 index 56997c1394..0000000000 --- a/tests/benchmarks/declarative/holistic/data/jsImports/msbsi2.js +++ /dev/null @@ -1,53 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -// This JavaScript file is a single, small, imported script. -// It doesn't import any other scripts. -// It is imported from another script. - -function testFunc(seedValue) { - var retn = 5; - retn += (seedValue * 0.245); - retn *= (1 + (3.1415962 / seedValue)); - retn /= 2.41497; - retn -= (seedValue * -1); - return retn; -} diff --git a/tests/benchmarks/declarative/holistic/data/jsImports/msbsi3.js b/tests/benchmarks/declarative/holistic/data/jsImports/msbsi3.js deleted file mode 100644 index ce84ab63e4..0000000000 --- a/tests/benchmarks/declarative/holistic/data/jsImports/msbsi3.js +++ /dev/null @@ -1,53 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -// This JavaScript file is a single, small, imported script. -// It doesn't import any other scripts. -// It is imported from another script. - -function testFunc(seedValue) { - var retn = 5; - retn += (seedValue * 0.345); - retn *= (1 + (3.1415962 / seedValue)); - retn /= 2.41497; - retn -= (seedValue * -1); - return retn; -} diff --git a/tests/benchmarks/declarative/holistic/data/jsImports/msbsi4.js b/tests/benchmarks/declarative/holistic/data/jsImports/msbsi4.js deleted file mode 100644 index 61d15d11af..0000000000 --- a/tests/benchmarks/declarative/holistic/data/jsImports/msbsi4.js +++ /dev/null @@ -1,53 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -// This JavaScript file is a single, small, imported script. -// It doesn't import any other scripts. -// It is imported from another script. - -function testFunc(seedValue) { - var retn = 5; - retn += (seedValue * 0.445); - retn *= (1 + (3.1415962 / seedValue)); - retn /= 2.41497; - retn -= (seedValue * -1); - return retn; -} diff --git a/tests/benchmarks/declarative/holistic/data/jsImports/msbsi5.js b/tests/benchmarks/declarative/holistic/data/jsImports/msbsi5.js deleted file mode 100644 index e5bf0e1527..0000000000 --- a/tests/benchmarks/declarative/holistic/data/jsImports/msbsi5.js +++ /dev/null @@ -1,53 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -// This JavaScript file is a single, small, imported script. -// It doesn't import any other scripts. -// It is imported from another script. - -function testFunc(seedValue) { - var retn = 5; - retn += (seedValue * 0.545); - retn *= (1 + (3.1415962 / seedValue)); - retn /= 2.41497; - retn -= (seedValue * -1); - return retn; -} diff --git a/tests/benchmarks/declarative/holistic/data/jsImports/msbsi6.js b/tests/benchmarks/declarative/holistic/data/jsImports/msbsi6.js deleted file mode 100644 index 8f25ad23d8..0000000000 --- a/tests/benchmarks/declarative/holistic/data/jsImports/msbsi6.js +++ /dev/null @@ -1,53 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -// This JavaScript file is a single, small, imported script. -// It doesn't import any other scripts. -// It is imported from another script. - -function testFunc(seedValue) { - var retn = 5; - retn += (seedValue * 0.645); - retn *= (1 + (3.1415962 / seedValue)); - retn /= 2.41497; - retn -= (seedValue * -1); - return retn; -} diff --git a/tests/benchmarks/declarative/holistic/data/jsImports/msbsi7.js b/tests/benchmarks/declarative/holistic/data/jsImports/msbsi7.js deleted file mode 100644 index 70d521d3dc..0000000000 --- a/tests/benchmarks/declarative/holistic/data/jsImports/msbsi7.js +++ /dev/null @@ -1,53 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -// This JavaScript file is a single, small, imported script. -// It doesn't import any other scripts. -// It is imported from another script. - -function testFunc(seedValue) { - var retn = 5; - retn += (seedValue * 0.745); - retn *= (1 + (3.1415962 / seedValue)); - retn /= 2.41497; - retn -= (seedValue * -1); - return retn; -} diff --git a/tests/benchmarks/declarative/holistic/data/jsImports/msbsi8.js b/tests/benchmarks/declarative/holistic/data/jsImports/msbsi8.js deleted file mode 100644 index ed9f473ff9..0000000000 --- a/tests/benchmarks/declarative/holistic/data/jsImports/msbsi8.js +++ /dev/null @@ -1,53 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -// This JavaScript file is a single, small, imported script. -// It doesn't import any other scripts. -// It is imported from another script. - -function testFunc(seedValue) { - var retn = 5; - retn += (seedValue * 0.845); - retn *= (1 + (3.1415962 / seedValue)); - retn /= 2.41497; - retn -= (seedValue * -1); - return retn; -} diff --git a/tests/benchmarks/declarative/holistic/data/jsImports/msbsi9.js b/tests/benchmarks/declarative/holistic/data/jsImports/msbsi9.js deleted file mode 100644 index 73a8eaf37b..0000000000 --- a/tests/benchmarks/declarative/holistic/data/jsImports/msbsi9.js +++ /dev/null @@ -1,53 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -// This JavaScript file is a single, small, imported script. -// It doesn't import any other scripts. -// It is imported from another script. - -function testFunc(seedValue) { - var retn = 5; - retn += (seedValue * 0.945); - retn *= (1 + (3.1415962 / seedValue)); - retn /= 2.41497; - retn -= (seedValue * -1); - return retn; -} diff --git a/tests/benchmarks/declarative/holistic/data/jsImports/msdsi.js b/tests/benchmarks/declarative/holistic/data/jsImports/msdsi.js deleted file mode 100644 index f88af5b416..0000000000 --- a/tests/benchmarks/declarative/holistic/data/jsImports/msdsi.js +++ /dev/null @@ -1,51 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -// This JavaScript file is a single, small, imported script. -// It imports other small scripts which are deeply nested. - -.import "msdsi1.js" as Msdsi1 - -function testFunc(seedValue) { - var retn = 0.5; - retn *= Msdsi1.testFunc(seedValue + retn); - return retn; -} diff --git a/tests/benchmarks/declarative/holistic/data/jsImports/msdsi1.js b/tests/benchmarks/declarative/holistic/data/jsImports/msdsi1.js deleted file mode 100644 index 1d60d24b5e..0000000000 --- a/tests/benchmarks/declarative/holistic/data/jsImports/msdsi1.js +++ /dev/null @@ -1,52 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -// This JavaScript file is a single, small, imported script. -// It imports other small scripts which are deeply nested. -// It is imported by another script. - -.import "msdsi2.js" as Msdsi2 - -function testFunc(seedValue) { - var retn = 0.15; - retn *= Msdsi2.testFunc(seedValue + retn); - return retn; -} diff --git a/tests/benchmarks/declarative/holistic/data/jsImports/msdsi10.js b/tests/benchmarks/declarative/holistic/data/jsImports/msdsi10.js deleted file mode 100644 index 8b1151f3e2..0000000000 --- a/tests/benchmarks/declarative/holistic/data/jsImports/msdsi10.js +++ /dev/null @@ -1,52 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -// This JavaScript file is a single, small, imported script. -// It imports other small scripts which are deeply nested. -// It is imported by another script. - -.import "msdsi11.js" as Msdsi11 - -function testFunc(seedValue) { - var retn = 0.105; - retn *= Msdsi11.testFunc(seedValue + retn); - return retn; -} diff --git a/tests/benchmarks/declarative/holistic/data/jsImports/msdsi11.js b/tests/benchmarks/declarative/holistic/data/jsImports/msdsi11.js deleted file mode 100644 index b27d0f37af..0000000000 --- a/tests/benchmarks/declarative/holistic/data/jsImports/msdsi11.js +++ /dev/null @@ -1,52 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -// This JavaScript file is a single, small, imported script. -// It imports other small scripts which are deeply nested. -// It is imported by another script. - -.import "msdsi12.js" as Msdsi12 - -function testFunc(seedValue) { - var retn = 0.115; - retn *= Msdsi12.testFunc(seedValue + retn); - return retn; -} diff --git a/tests/benchmarks/declarative/holistic/data/jsImports/msdsi12.js b/tests/benchmarks/declarative/holistic/data/jsImports/msdsi12.js deleted file mode 100644 index ba62852113..0000000000 --- a/tests/benchmarks/declarative/holistic/data/jsImports/msdsi12.js +++ /dev/null @@ -1,52 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -// This JavaScript file is a single, small, imported script. -// It imports other small scripts which are deeply nested. -// It is imported by another script. - -.import "msdsi13.js" as Msdsi13 - -function testFunc(seedValue) { - var retn = 0.125; - retn *= Msdsi13.testFunc(seedValue + retn); - return retn; -} diff --git a/tests/benchmarks/declarative/holistic/data/jsImports/msdsi13.js b/tests/benchmarks/declarative/holistic/data/jsImports/msdsi13.js deleted file mode 100644 index f4b17ff627..0000000000 --- a/tests/benchmarks/declarative/holistic/data/jsImports/msdsi13.js +++ /dev/null @@ -1,52 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -// This JavaScript file is a single, small, imported script. -// It imports other small scripts which are deeply nested. -// It is imported by another script. - -.import "msdsi14.js" as Msdsi14 - -function testFunc(seedValue) { - var retn = 0.135; - retn *= Msdsi14.testFunc(seedValue + retn); - return retn; -} diff --git a/tests/benchmarks/declarative/holistic/data/jsImports/msdsi14.js b/tests/benchmarks/declarative/holistic/data/jsImports/msdsi14.js deleted file mode 100644 index 4f96539faf..0000000000 --- a/tests/benchmarks/declarative/holistic/data/jsImports/msdsi14.js +++ /dev/null @@ -1,52 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -// This JavaScript file is a single, small, imported script. -// It imports other small scripts which are deeply nested. -// It is imported by another script. - -.import "msdsi15.js" as Msdsi15 - -function testFunc(seedValue) { - var retn = 0.145; - retn *= Msdsi15.testFunc(seedValue + retn); - return retn; -} diff --git a/tests/benchmarks/declarative/holistic/data/jsImports/msdsi15.js b/tests/benchmarks/declarative/holistic/data/jsImports/msdsi15.js deleted file mode 100644 index 113ed1bdc8..0000000000 --- a/tests/benchmarks/declarative/holistic/data/jsImports/msdsi15.js +++ /dev/null @@ -1,49 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -// This JavaScript file is a single, small, imported script. -// It is imported by another script. - -function testFunc(seedValue) { - var retn = 0.155; - retn *= (seedValue + retn); - return retn; -} diff --git a/tests/benchmarks/declarative/holistic/data/jsImports/msdsi2.js b/tests/benchmarks/declarative/holistic/data/jsImports/msdsi2.js deleted file mode 100644 index 67a35bc3ae..0000000000 --- a/tests/benchmarks/declarative/holistic/data/jsImports/msdsi2.js +++ /dev/null @@ -1,52 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -// This JavaScript file is a single, small, imported script. -// It imports other small scripts which are deeply nested. -// It is imported by another script. - -.import "msdsi3.js" as Msdsi3 - -function testFunc(seedValue) { - var retn = 0.25; - retn *= Msdsi3.testFunc(seedValue + retn); - return retn; -} diff --git a/tests/benchmarks/declarative/holistic/data/jsImports/msdsi3.js b/tests/benchmarks/declarative/holistic/data/jsImports/msdsi3.js deleted file mode 100644 index 81b4747409..0000000000 --- a/tests/benchmarks/declarative/holistic/data/jsImports/msdsi3.js +++ /dev/null @@ -1,52 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -// This JavaScript file is a single, small, imported script. -// It imports other small scripts which are deeply nested. -// It is imported by another script. - -.import "msdsi4.js" as Msdsi4 - -function testFunc(seedValue) { - var retn = 0.35; - retn *= Msdsi4.testFunc(seedValue + retn); - return retn; -} diff --git a/tests/benchmarks/declarative/holistic/data/jsImports/msdsi4.js b/tests/benchmarks/declarative/holistic/data/jsImports/msdsi4.js deleted file mode 100644 index 37a4d9d2aa..0000000000 --- a/tests/benchmarks/declarative/holistic/data/jsImports/msdsi4.js +++ /dev/null @@ -1,52 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -// This JavaScript file is a single, small, imported script. -// It imports other small scripts which are deeply nested. -// It is imported by another script. - -.import "msdsi5.js" as Msdsi5 - -function testFunc(seedValue) { - var retn = 0.45; - retn *= Msdsi5.testFunc(seedValue + retn); - return retn; -} diff --git a/tests/benchmarks/declarative/holistic/data/jsImports/msdsi5.js b/tests/benchmarks/declarative/holistic/data/jsImports/msdsi5.js deleted file mode 100644 index df57e75cea..0000000000 --- a/tests/benchmarks/declarative/holistic/data/jsImports/msdsi5.js +++ /dev/null @@ -1,52 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -// This JavaScript file is a single, small, imported script. -// It imports other small scripts which are deeply nested. -// It is imported by another script. - -.import "msdsi6.js" as Msdsi6 - -function testFunc(seedValue) { - var retn = 0.55; - retn *= Msdsi6.testFunc(seedValue + retn); - return retn; -} diff --git a/tests/benchmarks/declarative/holistic/data/jsImports/msdsi6.js b/tests/benchmarks/declarative/holistic/data/jsImports/msdsi6.js deleted file mode 100644 index 43e0b43877..0000000000 --- a/tests/benchmarks/declarative/holistic/data/jsImports/msdsi6.js +++ /dev/null @@ -1,52 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -// This JavaScript file is a single, small, imported script. -// It imports other small scripts which are deeply nested. -// It is imported by another script. - -.import "msdsi7.js" as Msdsi7 - -function testFunc(seedValue) { - var retn = 0.65; - retn *= Msdsi7.testFunc(seedValue + retn); - return retn; -} diff --git a/tests/benchmarks/declarative/holistic/data/jsImports/msdsi7.js b/tests/benchmarks/declarative/holistic/data/jsImports/msdsi7.js deleted file mode 100644 index 569b613e92..0000000000 --- a/tests/benchmarks/declarative/holistic/data/jsImports/msdsi7.js +++ /dev/null @@ -1,52 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -// This JavaScript file is a single, small, imported script. -// It imports other small scripts which are deeply nested. -// It is imported by another script. - -.import "msdsi8.js" as Msdsi8 - -function testFunc(seedValue) { - var retn = 0.75; - retn *= Msdsi8.testFunc(seedValue + retn); - return retn; -} diff --git a/tests/benchmarks/declarative/holistic/data/jsImports/msdsi8.js b/tests/benchmarks/declarative/holistic/data/jsImports/msdsi8.js deleted file mode 100644 index b1a5bd514b..0000000000 --- a/tests/benchmarks/declarative/holistic/data/jsImports/msdsi8.js +++ /dev/null @@ -1,52 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -// This JavaScript file is a single, small, imported script. -// It imports other small scripts which are deeply nested. -// It is imported by another script. - -.import "msdsi9.js" as Msdsi9 - -function testFunc(seedValue) { - var retn = 0.85; - retn *= Msdsi9.testFunc(seedValue + retn); - return retn; -} diff --git a/tests/benchmarks/declarative/holistic/data/jsImports/msdsi9.js b/tests/benchmarks/declarative/holistic/data/jsImports/msdsi9.js deleted file mode 100644 index 3a0c4d0354..0000000000 --- a/tests/benchmarks/declarative/holistic/data/jsImports/msdsi9.js +++ /dev/null @@ -1,52 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -// This JavaScript file is a single, small, imported script. -// It imports other small scripts which are deeply nested. -// It is imported by another script. - -.import "msdsi10.js" as Msdsi10 - -function testFunc(seedValue) { - var retn = 0.95; - retn *= Msdsi10.testFunc(seedValue + retn); - return retn; -} diff --git a/tests/benchmarks/declarative/holistic/data/jsImports/mssi.js b/tests/benchmarks/declarative/holistic/data/jsImports/mssi.js deleted file mode 100644 index 7a82033d88..0000000000 --- a/tests/benchmarks/declarative/holistic/data/jsImports/mssi.js +++ /dev/null @@ -1,84 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -// This JavaScript file is a single, small, imported script. -// It imports many other (non-nested) single, small, scripts, -// and also imports many other nested, small scripts. - -.import "msdsi4.js" as Msdsi4 -.import "msdsi9.js" as Msdsi9 -.import "msbsi1.js" as Msbsi1 -.import "msbsi2.js" as Msbsi2 -.import "msbsi3.js" as Msbsi3 -.import "msbsi4.js" as Msbsi4 -.import "msbsi5.js" as Msbsi5 -.import "msbsi6.js" as Msbsi6 -.import "msbsi7.js" as Msbsi7 -.import "msbsi8.js" as Msbsi8 -.import "msbsi9.js" as Msbsi9 -.import "msbsi10.js" as Msbsi10 -.import "msbsi11.js" as Msbsi11 -.import "msbsi12.js" as Msbsi12 -.import "msbsi13.js" as Msbsi13 -.import "msbsi14.js" as Msbsi14 -.import "msbsi15.js" as Msbsi15 - -function testFunc(seedValue) { - var retn = 10 * (seedValue * 0.85); - retn += Msbsi1.testFunc(seedValue); - retn += Msbsi2.testFunc(seedValue); - retn += Msbsi3.testFunc(retn); - retn += Msbsi4.testFunc(seedValue); - retn += Msbsi5.testFunc(seedValue); - retn += Msbsi6.testFunc(seedValue); - retn *= Msdsi9.testFunc(retn); - retn += Msbsi7.testFunc(seedValue); - retn += Msbsi8.testFunc(retn); - retn += Msbsi9.testFunc(seedValue); - retn += Msbsi10.testFunc(seedValue); - retn += Msbsi11.testFunc(seedValue); - retn *= Msdsi4.testFunc(retn); - retn += Msbsi12.testFunc(seedValue); - retn += Msbsi13.testFunc(retn); - retn += Msbsi14.testFunc(seedValue); - retn += Msbsi15.testFunc(seedValue); - return retn; -} diff --git a/tests/benchmarks/declarative/holistic/data/jsImports/pragmaBmOne.js b/tests/benchmarks/declarative/holistic/data/jsImports/pragmaBmOne.js deleted file mode 100644 index b92b79afaf..0000000000 --- a/tests/benchmarks/declarative/holistic/data/jsImports/pragmaBmOne.js +++ /dev/null @@ -1,50 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -// This JavaScript file is a single, large, imported script. -// It imports a shared library script. -.import "pragmaLib.js" as PragmaLibJs - -function testFuncOne(seedValue) { - var retn = seedValue + 2; - retn += PragmaLibJs.testFunc(); - return retn; -} diff --git a/tests/benchmarks/declarative/holistic/data/jsImports/pragmaBmTwo.js b/tests/benchmarks/declarative/holistic/data/jsImports/pragmaBmTwo.js deleted file mode 100644 index c086016bef..0000000000 --- a/tests/benchmarks/declarative/holistic/data/jsImports/pragmaBmTwo.js +++ /dev/null @@ -1,50 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -// This JavaScript file is a single, large, imported script. -// It imports a shared library script. -.import "pragmaLib.js" as PragmaLibJs - -function testFuncTwo(seedValue) { - var retn = seedValue + 3; - retn += PragmaLibJs.testFunc(); - return retn; -} diff --git a/tests/benchmarks/declarative/holistic/data/jsImports/pragmaLib.js b/tests/benchmarks/declarative/holistic/data/jsImports/pragmaLib.js deleted file mode 100644 index 8b65a68111..0000000000 --- a/tests/benchmarks/declarative/holistic/data/jsImports/pragmaLib.js +++ /dev/null @@ -1,119 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -// This JavaScript file is a single, large, imported script. -// It doesn't import any other scripts. -// It is a shared script, with data which should be shared. -.pragma library - -var sharedValue = 9; - -function testFunc() { - var retn = sharedValue; - sharedValue += 1; // increment the shared value - return retn; -} - -function testFuncBig(seedValue) { - var retn = sharedValue; - var firstFactor = calculateFirstFactor(seedValue); - var secondFactor = calculateSecondFactor(seedValue); - var modificationTerm = calculateModificationTerm(seedValue); - - // do some regexp matching - var someString = "This is a random string which we'll perform regular expression matching on to reduce considerably. This is meant to be part of a complex javascript expression whose evaluation takes considerably longer than the creation cost of QScriptValue."; - var regexpPattern = new RegExp("is", "i"); - var regexpOutputLength = 0; - var temp = regexpPattern.exec(someString); - while (temp == "is") { - regexpOutputLength += 4; - regexpOutputLength *= 2; - temp = regexpPattern.exec(someString); - if (regexpOutputLength > (seedValue * 3)) { - temp = "break"; - } - } - - // spin in a for loop for a while - var i = 0; - var j = 0; - var cumulativeTotal = 3; - for (i = 20; i > 1; i--) { - for (j = 31; j > 5; j--) { - var branchVariable = i + j; - if (branchVariable % 3 == 0) { - cumulativeTotal -= secondFactor; - } else { - cumulativeTotal += firstFactor; - } - - if (cumulativeTotal > (seedValue * 50)) { - break; - } - } - } - retn += (cumulativeTotal * 0.45); - retn *= (1 + (3.1415962 / seedValue)); - retn /= 2.41497; - retn -= (seedValue * -1); - sharedValue += 1; // increment the shared value - return retn; -} - -function calculateFirstFactor(seedValue) { - var firstFactor = (0.45 * (9.3 / 3.1) - 0.90); - firstFactor *= (1 + (0.00001 / seedValue)); - return firstFactor; -} - -function calculateSecondFactor(seedValue) { - var secondFactor = 0.78 * (6.3 / 2.1) - (0.39 * 4); - secondFactor *= (1 + (0.00001 / seedValue)); - return secondFactor; -} - -function calculateModificationTerm(seedValue) { - var modificationTerm = (12 + (9*7) - 54 + 16 - ((calculateFirstFactor(seedValue) * seedValue) / 3) + (4*calculateSecondFactor(seedValue) * seedValue * 1.33)) + (calculateSecondFactor(seedValue) * seedValue); - modificationTerm = modificationTerm + (33/2) + 19 - (9*2) - (61*3) + 177; - return modificationTerm; -} - - diff --git a/tests/benchmarks/declarative/holistic/data/jsImports/pragmaModuleBm.js b/tests/benchmarks/declarative/holistic/data/jsImports/pragmaModuleBm.js deleted file mode 100644 index df710f1acf..0000000000 --- a/tests/benchmarks/declarative/holistic/data/jsImports/pragmaModuleBm.js +++ /dev/null @@ -1,57 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -// This JavaScript file is a single, large, imported script. -// It imports a QML module and two other scripts. -// Each of those two other scripts imports a single script, -// which is a .pragma library script (shared between the two). - -.import Qt.test 1.0 as QtTest -.import "pragmaBmOne.js" as PragmaBmOneJs -.import "pragmaBmTwo.js" as PragmaBmTwoJs - -function testFuncThree(seedValue) { - var retn = seedValue + QtTest.EnumValue3; - retn += PragmaBmOneJs.testFuncOne(seedValue); - retn += PragmaBmTwoJs.testFuncTwo(seedValue); - return retn; -} - diff --git a/tests/benchmarks/declarative/holistic/data/jsImports/slsi.js b/tests/benchmarks/declarative/holistic/data/jsImports/slsi.js deleted file mode 100644 index 98af47885f..0000000000 --- a/tests/benchmarks/declarative/holistic/data/jsImports/slsi.js +++ /dev/null @@ -1,108 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -// This JavaScript file is a single, large, imported script. -// It doesn't import any other scripts. - -function testFunc(seedValue) { - var retn = 5; - var firstFactor = calculateFirstFactor(seedValue); - var secondFactor = calculateSecondFactor(seedValue); - var modificationTerm = calculateModificationTerm(seedValue); - - // do some regexp matching - var someString = "This is a random string which we'll perform regular expression matching on to reduce considerably. This is meant to be part of a complex javascript expression whose evaluation takes considerably longer than the creation cost of QScriptValue."; - var regexpPattern = new RegExp("is", "i"); - var regexpOutputLength = 0; - var temp = regexpPattern.exec(someString); - while (temp == "is") { - regexpOutputLength += 4; - regexpOutputLength *= 2; - temp = regexpPattern.exec(someString); - if (regexpOutputLength > (seedValue * 3)) { - temp = "break"; - } - } - - // spin in a for loop for a while - var i = 0; - var j = 0; - var cumulativeTotal = 3; - for (i = 20; i > 1; i--) { - for (j = 31; j > 5; j--) { - var branchVariable = i + j; - if (branchVariable % 3 == 0) { - cumulativeTotal -= secondFactor; - } else { - cumulativeTotal += firstFactor; - } - - if (cumulativeTotal > (seedValue * 50)) { - break; - } - } - } - retn += (cumulativeTotal * 0.45); - retn *= (1 + (3.1415962 / seedValue)); - retn /= 2.41497; - retn -= (seedValue * -1); - return retn; -} - -function calculateFirstFactor(seedValue) { - var firstFactor = (0.45 * (9.3 / 3.1) - 0.90); - firstFactor *= (1 + (0.00001 / seedValue)); - return firstFactor; -} - -function calculateSecondFactor(seedValue) { - var secondFactor = 0.78 * (6.3 / 2.1) - (0.39 * 4); - secondFactor *= (1 + (0.00001 / seedValue)); - return secondFactor; -} - -function calculateModificationTerm(seedValue) { - var modificationTerm = (12 + (9*7) - 54 + 16 - ((calculateFirstFactor(seedValue) * seedValue) / 3) + (4*calculateSecondFactor(seedValue) * seedValue * 1.33)) + (calculateSecondFactor(seedValue) * seedValue); - modificationTerm = modificationTerm + (33/2) + 19 - (9*2) - (61*3) + 177; - return modificationTerm; -} - - diff --git a/tests/benchmarks/declarative/holistic/data/jsImports/sssi.js b/tests/benchmarks/declarative/holistic/data/jsImports/sssi.js deleted file mode 100644 index 88d9fb643b..0000000000 --- a/tests/benchmarks/declarative/holistic/data/jsImports/sssi.js +++ /dev/null @@ -1,52 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -// This JavaScript file is a single, small, imported script. -// It doesn't import any other scripts. - -function testFunc(seedValue) { - var retn = 5; - retn += (seedValue * 0.45); - retn *= (1 + (3.1415962 / seedValue)); - retn /= 2.41497; - retn -= (seedValue * -1); - return retn; -} diff --git a/tests/benchmarks/declarative/holistic/data/jsTargets/JsOne.qml b/tests/benchmarks/declarative/holistic/data/jsTargets/JsOne.qml deleted file mode 100644 index 41d4ff5bbd..0000000000 --- a/tests/benchmarks/declarative/holistic/data/jsTargets/JsOne.qml +++ /dev/null @@ -1,61 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -Item { - id: root - property int dynamicWidth: 10 - property int widthSignaledProperty: 20 - - Rectangle { - width: 100 - height: 50 - color: "red" - border.color: "black" - border.width: 5 - radius: 10 - } - - onDynamicWidthChanged: { - widthSignaledProperty = dynamicWidth + (20/4) + 7 - 1; - } -} diff --git a/tests/benchmarks/declarative/holistic/data/jsTargets/JsTwo.qml b/tests/benchmarks/declarative/holistic/data/jsTargets/JsTwo.qml deleted file mode 100644 index cb5da5a22d..0000000000 --- a/tests/benchmarks/declarative/holistic/data/jsTargets/JsTwo.qml +++ /dev/null @@ -1,118 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -Item { - id: root - property int dynamicWidth: 10 - property int widthSignaledProperty: 20 - - Rectangle { - width: 100 - height: 50 - color: "red" - border.color: "black" - border.width: 5 - radius: 10 - } - - function calculateFirstFactor(seedValue) { - var firstFactor = (0.45 * (9.3 / 3.1) - 0.90); - firstFactor *= (1 + (0.00001 / seedValue)); - return firstFactor; - } - - function calculateSecondFactor(seedValue) { - var secondFactor = 0.78 * (6.3 / 2.1) - (0.39 * 4); - secondFactor *= (1 + (0.00001 / seedValue)); - return secondFactor; - } - - function calculateModificationTerm(seedValue) { - var modificationTerm = (12 + (9*7) - 54 + 16 - ((root.calculateFirstFactor(seedValue + 0.3) * seedValue) / 3) + (4*root.calculateSecondFactor(seedValue+2) * seedValue * 1.33)) + (root.calculateSecondFactor(seedValue+1) * seedValue); - modificationTerm = modificationTerm + (33/2) + 19 - (9*2) - (61*3) + 177; - return modificationTerm; - } - - onDynamicWidthChanged: { - // do a bit of maths - var firstFactor = root.calculateFirstFactor(8); - var secondFactor = root.calculateSecondFactor(dynamicWidth / firstFactor); - var modificationTerm = root.calculateModificationTerm(dynamicWidth / secondFactor); - - // do some regexp matching - var someString = "This is a random string which we'll perform regular expression matching on to reduce considerably. This is meant to be part of a complex javascript expression whose evaluation takes considerably longer than the creation cost of QScriptValue."; - var regexpPattern = new RegExp("is", "i"); - var regexpOutputLength = 0; - var temp = regexpPattern.exec(someString); - while (temp == "is") { - regexpOutputLength += 4; - regexpOutputLength *= 2; - temp = regexpPattern.exec(someString); - if (regexpOutputLength > (dynamicWidth * 3)) { - temp = "break"; - } - } - - // spin in a for loop for a while - var i = 0; - var j = 0; - var cumulativeTotal = 3; - for (i = 20; i > 1; i--) { - for (j = 31; j > 5; j--) { - var branchVariable = i + j; - if (branchVariable % 3 == 0) { - cumulativeTotal -= secondFactor; - } else { - cumulativeTotal += firstFactor; - } - - if (cumulativeTotal > (dynamicWidth * 50)) { - break; - } - } - } - - // and update the property - widthSignaledProperty = (dynamicWidth + (20/4) + 7 - 1) * modificationTerm + regexpOutputLength - (cumulativeTotal / 73); - } -} diff --git a/tests/benchmarks/declarative/holistic/data/largeTargets/gridview-example.qml b/tests/benchmarks/declarative/holistic/data/largeTargets/gridview-example.qml deleted file mode 100644 index 373b1b8ced..0000000000 --- a/tests/benchmarks/declarative/holistic/data/largeTargets/gridview-example.qml +++ /dev/null @@ -1,91 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -Rectangle { - width: 300; height: 400 - color: "white" - - ListModel { - id: appModel - ListElement { name: "Music"; shade: "blue" } - ListElement { name: "Movies"; shade: "red" } - ListElement { name: "Camera"; shade: "green" } - ListElement { name: "Calendar"; shade: "yellow" } - ListElement { name: "Messaging"; shade: "cyan" } - ListElement { name: "Todo List"; shade: "magenta" } - ListElement { name: "Contacts"; shade: "black" } - } - - Component { - id: appDelegate - - Item { - width: 100; height: 100 - - Rectangle { - id: myColoredIcon - width: 20 - height: 20 - y: 20; anchors.horizontalCenter: parent.horizontalCenter - color: shade - } - Text { - anchors { top: myColoredIcon.bottom; horizontalCenter: parent.horizontalCenter } - text: name - } - } - } - - Component { - id: appHighlight - Rectangle { width: 80; height: 80; color: "lightsteelblue" } - } - - GridView { - anchors.fill: parent - cellWidth: 100; cellHeight: 100 - highlight: appHighlight - focus: true - model: appModel - delegate: appDelegate - } -} diff --git a/tests/benchmarks/declarative/holistic/data/largeTargets/layoutdirection.qml b/tests/benchmarks/declarative/holistic/data/largeTargets/layoutdirection.qml deleted file mode 100644 index 9f039594b3..0000000000 --- a/tests/benchmarks/declarative/holistic/data/largeTargets/layoutdirection.qml +++ /dev/null @@ -1,151 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -Rectangle { - - width: column.width + 100 - height: column.height + 100 - property int direction: Qt.application.layoutDirection - - Column { - id: column - spacing: 10 - anchors.centerIn: parent - width: 230 - - Text { - text: "Row" - anchors.horizontalCenter: parent.horizontalCenter - } - Row { - layoutDirection: direction - spacing: 10 - move: Transition { - NumberAnimation { - properties: "x" - } - } - Repeater { - model: 4 - Loader { - property int value: index - sourceComponent: delegate - } - } - } - Text { - text: "Grid" - anchors.horizontalCenter: parent.horizontalCenter - } - Grid { - layoutDirection: direction - spacing: 10; columns: 4 - move: Transition { - NumberAnimation { - properties: "x" - } - } - Repeater { - model: 11 - Loader { - property int value: index - sourceComponent: delegate - } - } - } - Text { - text: "Flow" - anchors.horizontalCenter: parent.horizontalCenter - } - Flow { - layoutDirection: direction - spacing: 10; width: parent.width - move: Transition { - NumberAnimation { - properties: "x" - } - } - Repeater { - model: 10 - Loader { - property int value: index - sourceComponent: delegate - } - } - } - Rectangle { - height: 50; width: parent.width - color: mouseArea.pressed ? "black" : "gray" - Text { - text: direction ? "Right to left" : "Left to right" - color: "white" - font.pixelSize: 16 - anchors.centerIn: parent - } - MouseArea { - id: mouseArea - onClicked: { - if (direction == Qt.LeftToRight) { - direction = Qt.RightToLeft; - } else { - direction = Qt.LeftToRight; - } - } - anchors.fill: parent - } - } - } - - Component { - id: delegate - Rectangle { - width: 50; height: 50 - color: Qt.rgba(0.8/(parent.value+1),0.8/(parent.value+1),0.8/(parent.value+1),1.0) - Text { - text: parent.parent.value+1 - color: "white" - font.pixelSize: 20 - anchors.centerIn: parent - } - } - } -} diff --git a/tests/benchmarks/declarative/holistic/data/largeTargets/mousearea-example.qml b/tests/benchmarks/declarative/holistic/data/largeTargets/mousearea-example.qml deleted file mode 100644 index 4c82b58302..0000000000 --- a/tests/benchmarks/declarative/holistic/data/largeTargets/mousearea-example.qml +++ /dev/null @@ -1,112 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -Rectangle { - id: box - width: 350; height: 250 - - Rectangle { - id: redSquare - width: 80; height: 80 - anchors.top: parent.top; anchors.left: parent.left; anchors.margins: 10 - color: "red" - - Text { text: "Click"; font.pixelSize: 16; anchors.centerIn: parent } - - MouseArea { - anchors.fill: parent - hoverEnabled: true - acceptedButtons: Qt.LeftButton | Qt.RightButton - - onEntered: info.text = 'Entered' - onExited: info.text = 'Exited (pressed=' + pressed + ')' - - onPressed: { - info.text = 'Pressed (button=' + (mouse.button == Qt.RightButton ? 'right' : 'left') - + ' shift=' + (mouse.modifiers & Qt.ShiftModifier ? 'true' : 'false') + ')' - var posInBox = redSquare.mapToItem(box, mouse.x, mouse.y) - posInfo.text = + mouse.x + ',' + mouse.y + ' in square' - + ' (' + posInBox.x + ',' + posInBox.y + ' in window)' - } - - onReleased: { - info.text = 'Released (isClick=' + mouse.isClick + ' wasHeld=' + mouse.wasHeld + ')' - posInfo.text = '' - } - - onPressAndHold: info.text = 'Press and hold' - onClicked: info.text = 'Clicked (wasHeld=' + mouse.wasHeld + ')' - onDoubleClicked: info.text = 'Double clicked' - } - } - - Rectangle { - id: blueSquare - width: 80; height: 80 - x: box.width - width - 10; y: 10 // making this item draggable, so don't use anchors - color: "blue" - - Text { text: "Drag"; font.pixelSize: 16; color: "white"; anchors.centerIn: parent } - - MouseArea { - anchors.fill: parent - drag.target: blueSquare - drag.axis: Drag.XandYAxis - drag.minimumX: 0 - drag.maximumX: box.width - parent.width - drag.minimumY: 0 - drag.maximumY: box.height - parent.width - } - } - - Text { - id: info - anchors.bottom: posInfo.top; anchors.horizontalCenter: parent.horizontalCenter; anchors.margins: 30 - - onTextChanged: console.log(text) - } - - Text { - id: posInfo - anchors.bottom: parent.bottom; anchors.horizontalCenter: parent.horizontalCenter; anchors.margins: 30 - } -} diff --git a/tests/benchmarks/declarative/holistic/data/resolutionTargets/ResolveOne.qml b/tests/benchmarks/declarative/holistic/data/resolutionTargets/ResolveOne.qml deleted file mode 100644 index 2673ac36ed..0000000000 --- a/tests/benchmarks/declarative/holistic/data/resolutionTargets/ResolveOne.qml +++ /dev/null @@ -1,111 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -// This file has some nested items and does a lot of id resolution. -// This will allow us to benchmark the cost of resolving names in -// bindings. - -import QtQuick 2.0 - -Item { - id: root - property int baseWidth: 500 - property int baseHeight: 600 - property string baseColor: "red" - - Item { - id: childOne - property int baseWidth: root.baseWidth - 1 - property int baseHeight: root.baseHeight - 1 - property string baseColor: root.baseColor - - Item { - id: childTwo - property int baseWidth: root.baseWidth - 2 - property int baseHeight: childOne.baseHeight - 1 - property string baseColor: childOne.baseColor - - Item { - id: childThree - property int baseWidth: childOne.baseWidth - 2 - property int baseHeight: root.baseHeight - 3 - property string baseColor: "blue" - - Item { - id: childFour - property int baseWidth: childTwo.baseWidth - 2 - property int baseHeight: childThree.baseHeight - 1 - property string baseColor: "earthy " + root.baseColor - - Item { - id: childFive - property int baseWidth: root.baseWidth - 5 - property int baseHeight: childFour.baseHeight - 1 - property string baseColor: "carnelian " + childTwo.baseColor - } - } - - Item { - id: childSix - property int baseWidth: parent.baseWidth - 3 - property int baseHeight: root.baseHeight - 6 - property string baseColor: "rust " + root.baseColor - - Item { - id: childSeven - property int baseWidth: childOne.baseWidth - 6 - property int baseHeight: childTwo.baseHeight - 5 - property string baseColor: "sky " + childThree.baseColor - } - } - } - } - } - - Rectangle { - width: childOne.baseWidth - height: childOne.baseHeight - color: parent.baseColor - border.color: "black" - border.width: 5 - radius: 10 - } -} diff --git a/tests/benchmarks/declarative/holistic/data/scopeSwitching/CppToJs.qml b/tests/benchmarks/declarative/holistic/data/scopeSwitching/CppToJs.qml deleted file mode 100644 index d319f6e8cb..0000000000 --- a/tests/benchmarks/declarative/holistic/data/scopeSwitching/CppToJs.qml +++ /dev/null @@ -1,52 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 -import "cppToJs.js" as CppToJs - -Item { - id: jsConsumer - property int sideEffect: 10 - - function callJsFunction() { - jsConsumer.sideEffect = jsConsumer.sideEffect + CppToJs.nextValue; - } -} diff --git a/tests/benchmarks/declarative/holistic/data/scopeSwitching/CppToQml.qml b/tests/benchmarks/declarative/holistic/data/scopeSwitching/CppToQml.qml deleted file mode 100644 index a9d064f740..0000000000 --- a/tests/benchmarks/declarative/holistic/data/scopeSwitching/CppToQml.qml +++ /dev/null @@ -1,48 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -Item { - id: root - property int arbitrary: 10 - property int dependent: arbitrary + 5 -} diff --git a/tests/benchmarks/declarative/holistic/data/scopeSwitching/JsToCppEight.qml b/tests/benchmarks/declarative/holistic/data/scopeSwitching/JsToCppEight.qml deleted file mode 100644 index 97bb125bfc..0000000000 --- a/tests/benchmarks/declarative/holistic/data/scopeSwitching/JsToCppEight.qml +++ /dev/null @@ -1,54 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 -import Qt.test 1.0 - -Item { - id: arbitraryVariantConsumer - property MyArbitraryVariantProvider a: MyArbitraryVariantProvider { id: arbitraryVariantProvider } - property int sideEffect: 10 - - function callCppFunction() { - // in this case, we call a nonconst CPP function with an integer return value and an integer argument. - arbitraryVariantConsumer.sideEffect = arbitraryVariantConsumer.sideEffect + arbitraryVariantProvider.modifyVariantChangeCount(arbitraryVariantConsumer.sideEffect); - } -} diff --git a/tests/benchmarks/declarative/holistic/data/scopeSwitching/JsToCppEleven.qml b/tests/benchmarks/declarative/holistic/data/scopeSwitching/JsToCppEleven.qml deleted file mode 100644 index 2258e82500..0000000000 --- a/tests/benchmarks/declarative/holistic/data/scopeSwitching/JsToCppEleven.qml +++ /dev/null @@ -1,57 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 -import Qt.test 1.0 - -Item { - id: arbitraryVariantConsumer - property MyArbitraryVariantProvider a: MyArbitraryVariantProvider { id: arbitraryVariantProvider } - property variant someVariant; - property int sideEffect: 10 - - function callCppFunction() { - // in this case, we call a nonconst CPP function with variant return value and variant + integer arguments. - arbitraryVariantConsumer.sideEffect = arbitraryVariantConsumer.sideEffect + 3; - var tempVariant = arbitraryVariantProvider.setVariantToFilledPixmap(sideEffect + 183, sideEffect + 134, sideEffect + 38, sideEffect + 77, sideEffect + 21); - someVariant = arbitraryVariantProvider.setVariantAddCount(sideEffect, tempVariant); - } -} diff --git a/tests/benchmarks/declarative/holistic/data/scopeSwitching/JsToCppFive.qml b/tests/benchmarks/declarative/holistic/data/scopeSwitching/JsToCppFive.qml deleted file mode 100644 index f349d0fcbf..0000000000 --- a/tests/benchmarks/declarative/holistic/data/scopeSwitching/JsToCppFive.qml +++ /dev/null @@ -1,54 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 -import Qt.test 1.0 - -Item { - id: arbitraryVariantConsumer - property MyArbitraryVariantProvider a: MyArbitraryVariantProvider { id: arbitraryVariantProvider } - property int sideEffect: 10 - - function callCppFunction() { - // in this case, we call a const CPP function with an integer return value and no arguments. - arbitraryVariantConsumer.sideEffect = arbitraryVariantConsumer.sideEffect + arbitraryVariantProvider.variantChangeCount(); - } -} diff --git a/tests/benchmarks/declarative/holistic/data/scopeSwitching/JsToCppFour.qml b/tests/benchmarks/declarative/holistic/data/scopeSwitching/JsToCppFour.qml deleted file mode 100644 index 267d36fba2..0000000000 --- a/tests/benchmarks/declarative/holistic/data/scopeSwitching/JsToCppFour.qml +++ /dev/null @@ -1,55 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 -import Qt.test 1.0 - -Item { - id: arbitraryVariantConsumer - property MyArbitraryVariantProvider a: MyArbitraryVariantProvider { id: arbitraryVariantProvider } - property int sideEffect: 10 - - function callCppFunction() { - // in this case, we call a nonconst CPP function with no return value and an integer argument. - arbitraryVariantConsumer.sideEffect = arbitraryVariantConsumer.sideEffect + 2; - arbitraryVariantProvider.setVariantChangeCount(arbitraryVariantConsumer.sideEffect); - } -} diff --git a/tests/benchmarks/declarative/holistic/data/scopeSwitching/JsToCppNine.qml b/tests/benchmarks/declarative/holistic/data/scopeSwitching/JsToCppNine.qml deleted file mode 100644 index ec3772ea62..0000000000 --- a/tests/benchmarks/declarative/holistic/data/scopeSwitching/JsToCppNine.qml +++ /dev/null @@ -1,56 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 -import Qt.test 1.0 - -Item { - id: arbitraryVariantConsumer - property MyArbitraryVariantProvider a: MyArbitraryVariantProvider { id: arbitraryVariantProvider } - property variant someVariant; - property int sideEffect: 10 - - function callCppFunction() { - // in this case, we call a const CPP function with variant return value and integer arguments. - arbitraryVariantConsumer.sideEffect = arbitraryVariantConsumer.sideEffect + 3; - someVariant = arbitraryVariantProvider.possibleVariant(sideEffect, sideEffect * 2, sideEffect * 5); - } -} diff --git a/tests/benchmarks/declarative/holistic/data/scopeSwitching/JsToCppOne.qml b/tests/benchmarks/declarative/holistic/data/scopeSwitching/JsToCppOne.qml deleted file mode 100644 index e4a3c1acc2..0000000000 --- a/tests/benchmarks/declarative/holistic/data/scopeSwitching/JsToCppOne.qml +++ /dev/null @@ -1,55 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 -import Qt.test 1.0 - -Item { - id: arbitraryVariantConsumer - property MyArbitraryVariantProvider a: MyArbitraryVariantProvider { id: arbitraryVariantProvider } - property int sideEffect: 10 - - function callCppFunction() { - // in this case, we call a const CPP function with no return value and no arguments. - arbitraryVariantConsumer.sideEffect = arbitraryVariantConsumer.sideEffect + 2; - arbitraryVariantProvider.doNothing(); - } -} diff --git a/tests/benchmarks/declarative/holistic/data/scopeSwitching/JsToCppSeven.qml b/tests/benchmarks/declarative/holistic/data/scopeSwitching/JsToCppSeven.qml deleted file mode 100644 index 56c18a02db..0000000000 --- a/tests/benchmarks/declarative/holistic/data/scopeSwitching/JsToCppSeven.qml +++ /dev/null @@ -1,54 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 -import Qt.test 1.0 - -Item { - id: arbitraryVariantConsumer - property MyArbitraryVariantProvider a: MyArbitraryVariantProvider { id: arbitraryVariantProvider } - property int sideEffect: 10 - - function callCppFunction() { - // in this case, we call a const CPP function with an integer return value and an integer argument. - arbitraryVariantConsumer.sideEffect = arbitraryVariantConsumer.sideEffect + arbitraryVariantProvider.countPlus(arbitraryVariantConsumer.sideEffect); - } -} diff --git a/tests/benchmarks/declarative/holistic/data/scopeSwitching/JsToCppSix.qml b/tests/benchmarks/declarative/holistic/data/scopeSwitching/JsToCppSix.qml deleted file mode 100644 index c14c43075b..0000000000 --- a/tests/benchmarks/declarative/holistic/data/scopeSwitching/JsToCppSix.qml +++ /dev/null @@ -1,54 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 -import Qt.test 1.0 - -Item { - id: arbitraryVariantConsumer - property MyArbitraryVariantProvider a: MyArbitraryVariantProvider { id: arbitraryVariantProvider } - property int sideEffect: 10 - - function callCppFunction() { - // in this case, we call a nonconst CPP function with an integer return value and no arguments. - arbitraryVariantConsumer.sideEffect = arbitraryVariantConsumer.sideEffect + arbitraryVariantProvider.modifyVariantChangeCount(); - } -} diff --git a/tests/benchmarks/declarative/holistic/data/scopeSwitching/JsToCppTen.qml b/tests/benchmarks/declarative/holistic/data/scopeSwitching/JsToCppTen.qml deleted file mode 100644 index 05ededef38..0000000000 --- a/tests/benchmarks/declarative/holistic/data/scopeSwitching/JsToCppTen.qml +++ /dev/null @@ -1,56 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 -import Qt.test 1.0 - -Item { - id: arbitraryVariantConsumer - property MyArbitraryVariantProvider a: MyArbitraryVariantProvider { id: arbitraryVariantProvider } - property variant someVariant; - property int sideEffect: 10 - - function callCppFunction() { - // in this case, we call a nonconst CPP function with variant return value and integer arguments. - arbitraryVariantConsumer.sideEffect = arbitraryVariantConsumer.sideEffect + 3; - someVariant = arbitraryVariantProvider.setVariantToFilledPixmap(sideEffect + 183, sideEffect + 134, sideEffect + 38, sideEffect + 77, sideEffect + 21); - } -} diff --git a/tests/benchmarks/declarative/holistic/data/scopeSwitching/JsToCppThree.qml b/tests/benchmarks/declarative/holistic/data/scopeSwitching/JsToCppThree.qml deleted file mode 100644 index 2f11f9acb3..0000000000 --- a/tests/benchmarks/declarative/holistic/data/scopeSwitching/JsToCppThree.qml +++ /dev/null @@ -1,55 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 -import Qt.test 1.0 - -Item { - id: arbitraryVariantConsumer - property MyArbitraryVariantProvider a: MyArbitraryVariantProvider { id: arbitraryVariantProvider } - property int sideEffect: 10 - - function callCppFunction() { - // in this case, we call a const CPP function with no return value and an integer argument. - arbitraryVariantConsumer.sideEffect = arbitraryVariantConsumer.sideEffect + 2; - arbitraryVariantProvider.doNothing(arbitraryVariantConsumer.sideEffect); - } -} diff --git a/tests/benchmarks/declarative/holistic/data/scopeSwitching/JsToCppTwo.qml b/tests/benchmarks/declarative/holistic/data/scopeSwitching/JsToCppTwo.qml deleted file mode 100644 index 0fe6d18507..0000000000 --- a/tests/benchmarks/declarative/holistic/data/scopeSwitching/JsToCppTwo.qml +++ /dev/null @@ -1,55 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 -import Qt.test 1.0 - -Item { - id: arbitraryVariantConsumer - property MyArbitraryVariantProvider a: MyArbitraryVariantProvider { id: arbitraryVariantProvider } - property int sideEffect: 10 - - function callCppFunction() { - // in this case, we call a nonconst CPP function with no return value and no arguments. - arbitraryVariantConsumer.sideEffect = arbitraryVariantConsumer.sideEffect + 2; - arbitraryVariantProvider.incrementVariantChangeCount(); - } -} diff --git a/tests/benchmarks/declarative/holistic/data/scopeSwitching/ScarceOne.qml b/tests/benchmarks/declarative/holistic/data/scopeSwitching/ScarceOne.qml deleted file mode 100644 index d604242a99..0000000000 --- a/tests/benchmarks/declarative/holistic/data/scopeSwitching/ScarceOne.qml +++ /dev/null @@ -1,57 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 -import Qt.test 1.0 - -Item { - id: scarceResourceConsumer - - property MyScarceResourceProvider a: MyScarceResourceProvider { id: scarceResourceProvider } - - property variant ssr; - property variant lsr; - - function copyScarceResources() { - ssr = scarceResourceProvider.smallScarceResource; - lsr = scarceResourceProvider.largeScarceResource; - } -} diff --git a/tests/benchmarks/declarative/holistic/data/scopeSwitching/ScarceTwo.qml b/tests/benchmarks/declarative/holistic/data/scopeSwitching/ScarceTwo.qml deleted file mode 100644 index cd79bb8074..0000000000 --- a/tests/benchmarks/declarative/holistic/data/scopeSwitching/ScarceTwo.qml +++ /dev/null @@ -1,52 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 -import Qt.test 1.0 - -Item { - id: scarceResourceConsumer - - property MyScarceResourceProvider a: MyScarceResourceProvider { id: scarceResourceProvider } - - property variant ssr: scarceResourceProvider.smallScarceResource - property variant lsr: scarceResourceProvider.largeScarceResource -} diff --git a/tests/benchmarks/declarative/holistic/data/scopeSwitching/cppToJs.js b/tests/benchmarks/declarative/holistic/data/scopeSwitching/cppToJs.js deleted file mode 100644 index e62c2f27d6..0000000000 --- a/tests/benchmarks/declarative/holistic/data/scopeSwitching/cppToJs.js +++ /dev/null @@ -1,49 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -.pragma library - -var generatedValue = 5; - -function generateNextValue() { - generatedValue += 1; - return generatedValue; -} diff --git a/tests/benchmarks/declarative/holistic/data/smallTargets/SmallFour.qml b/tests/benchmarks/declarative/holistic/data/smallTargets/SmallFour.qml deleted file mode 100644 index 80af3bfee9..0000000000 --- a/tests/benchmarks/declarative/holistic/data/smallTargets/SmallFour.qml +++ /dev/null @@ -1,49 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -Text { - text: "Hello World!" - font.family: "Helvetica" - font.pointSize: 24 - color: "red" -} diff --git a/tests/benchmarks/declarative/holistic/data/smallTargets/SmallOne.qml b/tests/benchmarks/declarative/holistic/data/smallTargets/SmallOne.qml deleted file mode 100644 index 58d52fe25d..0000000000 --- a/tests/benchmarks/declarative/holistic/data/smallTargets/SmallOne.qml +++ /dev/null @@ -1,51 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -Rectangle { - width: 100 - height: 100 - color: "red" - border.color: "black" - border.width: 5 - radius: 10 -} diff --git a/tests/benchmarks/declarative/holistic/data/smallTargets/SmallThree.qml b/tests/benchmarks/declarative/holistic/data/smallTargets/SmallThree.qml deleted file mode 100644 index a3e27f9ad6..0000000000 --- a/tests/benchmarks/declarative/holistic/data/smallTargets/SmallThree.qml +++ /dev/null @@ -1,51 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -Rectangle { - width: 100; height: 100 - gradient: Gradient { - GradientStop { position: 0.0; color: "red" } - GradientStop { position: 0.33; color: "yellow" } - GradientStop { position: 1.0; color: "green" } - } -} diff --git a/tests/benchmarks/declarative/holistic/data/smallTargets/SmallTwo.qml b/tests/benchmarks/declarative/holistic/data/smallTargets/SmallTwo.qml deleted file mode 100644 index 3ff2c5e8b0..0000000000 --- a/tests/benchmarks/declarative/holistic/data/smallTargets/SmallTwo.qml +++ /dev/null @@ -1,51 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -Rectangle { - width: 100 - height: 100 - color: "blue" - border.color: "black" - border.width: 5 - radius: 10 -} diff --git a/tests/benchmarks/declarative/holistic/holistic.pro b/tests/benchmarks/declarative/holistic/holistic.pro deleted file mode 100644 index 586af79275..0000000000 --- a/tests/benchmarks/declarative/holistic/holistic.pro +++ /dev/null @@ -1,13 +0,0 @@ -CONFIG += testcase -TEMPLATE = app -TARGET = tst_holistic -QT += declarative network testlib -macx:CONFIG -= app_bundle - -CONFIG += release - -SOURCES += tst_holistic.cpp \ - testtypes.cpp -HEADERS += testtypes.h - -DEFINES += SRCDIR=\\\"$$PWD\\\" diff --git a/tests/benchmarks/declarative/holistic/testtypes.cpp b/tests/benchmarks/declarative/holistic/testtypes.cpp deleted file mode 100644 index 872a3be7b1..0000000000 --- a/tests/benchmarks/declarative/holistic/testtypes.cpp +++ /dev/null @@ -1,98 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include "testtypes.h" -#include -#include -#include -#include - -static QScriptValue script_api(QDeclarativeEngine *engine, QScriptEngine *scriptEngine) -{ - Q_UNUSED(engine) - Q_UNUSED(scriptEngine) - - static int testProperty = 13; - QScriptValue v = scriptEngine->newObject(); - v.setProperty("scriptTestProperty", testProperty++); - return v; -} - -static QObject *qobject_api(QDeclarativeEngine *engine, QScriptEngine *scriptEngine) -{ - Q_UNUSED(engine) - Q_UNUSED(scriptEngine) - - testQObjectApi *o = new testQObjectApi(); - o->setQObjectTestProperty(20); - return o; -} - -static QObject *qobject_api_engine_parent(QDeclarativeEngine *engine, QScriptEngine *scriptEngine) -{ - Q_UNUSED(scriptEngine) - - static int testProperty = 26; - testQObjectApi *o = new testQObjectApi(engine); - o->setQObjectTestProperty(testProperty++); - return o; -} - -void registerTypes() -{ - qmlRegisterType("Qt.test", 1,0, "MyQmlObjectAlias"); - qmlRegisterType("Qt.test", 1,0, "MyQmlObject"); - - qmlRegisterType("Qt.test",1,0,"QPlainTextEdit"); - qRegisterMetaType("MyQmlObject::MyType"); - - qmlRegisterType("Qt.test", 1,0, "MyScarceResourceProvider"); - qmlRegisterType("Qt.test", 1,0, "MyArbitraryVariantProvider"); - - qmlRegisterModuleApi("Qt.test",1,0,script_api); // register (script) module API for an existing uri which contains elements - qmlRegisterModuleApi("Qt.test",1,0,qobject_api); // register (qobject) for an existing uri for which another module API was previously regd. Should replace! - qmlRegisterModuleApi("Qt.test.scriptApi",1,0,script_api); // register (script) module API for a uri which doesn't contain elements - qmlRegisterModuleApi("Qt.test.qobjectApi",1,0,qobject_api); // register (qobject) module API for a uri which doesn't contain elements - qmlRegisterModuleApi("Qt.test.qobjectApi",1,3,qobject_api); // register (qobject) module API for a uri which doesn't contain elements, minor version set - qmlRegisterModuleApi("Qt.test.qobjectApi",2,0,qobject_api); // register (qobject) module API for a uri which doesn't contain elements, major version set - qmlRegisterModuleApi("Qt.test.qobjectApiParented",1,0,qobject_api_engine_parent); // register (parented qobject) module API for a uri which doesn't contain elements -} - -//#include "testtypes.moc" diff --git a/tests/benchmarks/declarative/holistic/testtypes.h b/tests/benchmarks/declarative/holistic/testtypes.h deleted file mode 100644 index c3824d2352..0000000000 --- a/tests/benchmarks/declarative/holistic/testtypes.h +++ /dev/null @@ -1,355 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#ifndef TESTTYPES_H -#define TESTTYPES_H - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -class MyQmlAttachedObject : public QObject -{ - Q_OBJECT - Q_PROPERTY(int value READ value CONSTANT) - Q_PROPERTY(int value2 READ value2 WRITE setValue2) -public: - MyQmlAttachedObject(QObject *parent) : QObject(parent), m_value2(0) {} - - int value() const { return 19; } - int value2() const { return m_value2; } - void setValue2(int v) { m_value2 = v; } - - void emitMySignal() { emit mySignal(); } - -signals: - void mySignal(); - -private: - int m_value2; -}; - -class MyQmlObject : public QObject -{ - Q_OBJECT - Q_ENUMS(MyEnum) - Q_ENUMS(MyEnum2) - Q_PROPERTY(int deleteOnSet READ deleteOnSet WRITE setDeleteOnSet) - Q_PROPERTY(bool trueProperty READ trueProperty CONSTANT) - Q_PROPERTY(bool falseProperty READ falseProperty CONSTANT) - Q_PROPERTY(int value READ value WRITE setValue) - Q_PROPERTY(int console READ console CONSTANT) - Q_PROPERTY(QString stringProperty READ stringProperty WRITE setStringProperty NOTIFY stringChanged) - Q_PROPERTY(QObject *objectProperty READ objectProperty WRITE setObjectProperty NOTIFY objectChanged) - Q_PROPERTY(QDeclarativeListProperty objectListProperty READ objectListProperty CONSTANT) - Q_PROPERTY(int resettableProperty READ resettableProperty WRITE setResettableProperty RESET resetProperty) - Q_PROPERTY(QRegExp regExp READ regExp WRITE setRegExp) - Q_PROPERTY(int nonscriptable READ nonscriptable WRITE setNonscriptable SCRIPTABLE false) - -public: - MyQmlObject(): myinvokableObject(0), m_methodCalled(false), m_methodIntCalled(false), m_object(0), m_value(0), m_resetProperty(13) {} - - enum MyEnum { EnumValue1 = 0, EnumValue2 = 1 }; - enum MyEnum2 { EnumValue3 = 2, EnumValue4 = 3 }; - - bool trueProperty() const { return true; } - bool falseProperty() const { return false; } - - QString stringProperty() const { return m_string; } - void setStringProperty(const QString &s) - { - if (s == m_string) - return; - m_string = s; - emit stringChanged(); - } - - QObject *objectProperty() const { return m_object; } - void setObjectProperty(QObject *obj) { - if (obj == m_object) - return; - m_object = obj; - emit objectChanged(); - } - - QDeclarativeListProperty objectListProperty() { return QDeclarativeListProperty(this, m_objectQList); } - - bool methodCalled() const { return m_methodCalled; } - bool methodIntCalled() const { return m_methodIntCalled; } - - QString string() const { return m_string; } - - static MyQmlAttachedObject *qmlAttachedProperties(QObject *o) { - return new MyQmlAttachedObject(o); - } - - int deleteOnSet() const { return 1; } - void setDeleteOnSet(int v) { if(v) delete this; } - - int value() const { return m_value; } - void setValue(int v) { m_value = v; } - - int resettableProperty() const { return m_resetProperty; } - void setResettableProperty(int v) { m_resetProperty = v; } - void resetProperty() { m_resetProperty = 13; } - - QRegExp regExp() { return m_regExp; } - void setRegExp(const QRegExp ®Exp) { m_regExp = regExp; } - - int console() const { return 11; } - - int nonscriptable() const { return 0; } - void setNonscriptable(int) {} - - MyQmlObject *myinvokableObject; - Q_INVOKABLE MyQmlObject *returnme() { return this; } - - struct MyType { - int value; - }; - QVariant variant() const { return m_variant; } - -signals: - void basicSignal(); - void argumentSignal(int a, QString b, qreal c); - void stringChanged(); - void objectChanged(); - void anotherBasicSignal(); - void thirdBasicSignal(); - void signalWithUnknownType(const MyQmlObject::MyType &arg); - -public slots: - void deleteMe() { delete this; } - void methodNoArgs() { m_methodCalled = true; } - void method(int a) { if(a == 163) m_methodIntCalled = true; } - void setString(const QString &s) { m_string = s; } - void myinvokable(MyQmlObject *o) { myinvokableObject = o; } - void variantMethod(const QVariant &v) { m_variant = v; } - -private: - friend class tst_qdeclarativeecmascript; - bool m_methodCalled; - bool m_methodIntCalled; - - QObject *m_object; - QString m_string; - QList m_objectQList; - int m_value; - int m_resetProperty; - QRegExp m_regExp; - QVariant m_variant; -}; - -QML_DECLARE_TYPEINFO(MyQmlObject, QML_HAS_ATTACHED_PROPERTIES) -Q_DECLARE_METATYPE(MyQmlObject::MyType) - -class testQObjectApi : public QObject -{ - Q_OBJECT - Q_PROPERTY (int qobjectTestProperty READ qobjectTestProperty NOTIFY qobjectTestPropertyChanged) - -public: - testQObjectApi(QObject* parent = 0) - : QObject(parent), m_testProperty(0) - { - } - - ~testQObjectApi() {} - - int qobjectTestProperty() const { return m_testProperty; } - void setQObjectTestProperty(int tp) { m_testProperty = tp; emit qobjectTestPropertyChanged(tp); } - -signals: - void qobjectTestPropertyChanged(int testProperty); - -private: - int m_testProperty; -}; - -class ArbitraryVariantProvider : public QObject -{ - Q_OBJECT - Q_PROPERTY(QVariant arbitraryVariant READ arbitraryVariant WRITE setArbitraryVariant NOTIFY arbitraryVariantChanged) - -public: - ArbitraryVariantProvider(QObject *parent = 0) - : QObject(parent), m_value(QVariant(QString(QLatin1String("random string value")))), m_count(1) - { - } - - ~ArbitraryVariantProvider() {} - - // the variant provided by the provider - QVariant arbitraryVariant() const { return m_value; } - void setArbitraryVariant(const QVariant& value) { m_value = value; emit arbitraryVariantChanged(); } - Q_INVOKABLE int changeVariant() - { - QPixmap pv(150, 150); - pv.fill(Qt::green); - int choice = qrand() % 4; - switch (choice) { - case 0: setArbitraryVariant(QVariant(QString(QLatin1String("string variant value")))); break; - case 1: setArbitraryVariant(QVariant(QColor(110, 120, 130))); break; - case 2: setArbitraryVariant(QVariant(55)); break; - default: setArbitraryVariant(QVariant(pv)); break; - } - - m_count += 1; - return m_count; - } - Q_INVOKABLE QVariant setVariantToFilledPixmap(int width, int height, int r, int g, int b) - { - QPixmap pv(width % 300, height % 300); - pv.fill(QColor(r % 256, g % 256, b % 256)); - m_value = pv; - m_count += 1; - return m_value; - } - Q_INVOKABLE QVariant setVariantAddCount(int addToCount, const QVariant& newValue) - { - m_value = newValue; - m_count += addToCount; - return m_value; - } - Q_INVOKABLE QVariant possibleVariant(int randomFactorOne, int randomFactorTwo, int randomFactorThree) const - { - QVariant retn; - QPixmap pv(randomFactorOne % 300, randomFactorTwo % 300); - pv.fill(QColor(randomFactorOne % 256, randomFactorTwo % 256, randomFactorThree % 256)); - int choice = qrand() % 4; - switch (choice) { - case 0: retn = QVariant(QString(QLatin1String("string variant value"))); break; - case 1: retn = QVariant(QColor(randomFactorThree % 256, randomFactorTwo % 256, randomFactorOne % 256)); break; - case 2: retn = QVariant((55 + randomFactorThree)); break; - default: retn = QVariant(pv); break; - } - return retn; - } - - // the following functions cover permutations of return value and arguments. - // functions with no return value: - Q_INVOKABLE void doNothing() const { /* does nothing */ } // no args, const - Q_INVOKABLE void incrementVariantChangeCount() { m_count = m_count + 1; } // no args, nonconst - Q_INVOKABLE void doNothing(int) const { /* does nothing. */ } // arg, const - Q_INVOKABLE void setVariantChangeCount(int newCount) { m_count = newCount; } // arg, nonconst - // functions with return value: - Q_INVOKABLE int variantChangeCount() const { return m_count; } // no args, const - Q_INVOKABLE int modifyVariantChangeCount() { m_count += 3; return m_count; } // no args, nonconst - Q_INVOKABLE int countPlus(int value) const { return m_count + value; } // arg, const - Q_INVOKABLE int modifyVariantChangeCount(int modifier) { m_count += modifier; return m_count; } // arg, nonconst. - -signals: - void arbitraryVariantChanged(); - -private: - QVariant m_value; - int m_count; -}; - -class ScarceResourceProvider : public QObject -{ - Q_OBJECT - Q_PROPERTY(QPixmap smallScarceResource READ smallScarceResource WRITE setSmallScarceResource NOTIFY smallScarceResourceChanged) - Q_PROPERTY(QPixmap largeScarceResource READ largeScarceResource WRITE setLargeScarceResource NOTIFY largeScarceResourceChanged) - -public: - ScarceResourceProvider(QObject *parent = 0) - : QObject(parent), m_small(100, 100), m_large(1000, 1000), m_colour(1) - { - m_small.fill(Qt::blue); - m_large.fill(Qt::blue); - } - - ~ScarceResourceProvider() {} - - QPixmap smallScarceResource() const { return m_small; } - void setSmallScarceResource(QPixmap v) { m_small = v; emit smallScarceResourceChanged(); } - bool smallScarceResourceIsDetached() const { return m_small.isDetached(); } - - QPixmap largeScarceResource() const { return m_large; } - void setLargeScarceResource(QPixmap v) { m_large = v; emit largeScarceResourceChanged(); } - bool largeScarceResourceIsDetached() const { return m_large.isDetached(); } - - Q_INVOKABLE void changeResources() - { - QPixmap newSmall(100, 100); - QPixmap newLarge(1000, 1000); - - if (m_colour == 1) { - m_colour = 2; - newSmall.fill(Qt::red); - newLarge.fill(Qt::red); - } else { - m_colour = 1; - newSmall.fill(Qt::blue); - newLarge.fill(Qt::blue); - } - - setSmallScarceResource(newSmall); - setLargeScarceResource(newLarge); - } - -signals: - void smallScarceResourceChanged(); - void largeScarceResourceChanged(); - -private: - QPixmap m_small; - QPixmap m_large; - - int m_colour; -}; - -void registerTypes(); - -#endif // TESTTYPES_H - diff --git a/tests/benchmarks/declarative/holistic/tst_holistic.cpp b/tests/benchmarks/declarative/holistic/tst_holistic.cpp deleted file mode 100644 index 6a2aa19804..0000000000 --- a/tests/benchmarks/declarative/holistic/tst_holistic.cpp +++ /dev/null @@ -1,607 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "testtypes.h" - -#include -#include -#include -#include -#include -#include -#include - -// Conceptually, there are several different "holistic" areas to benchmark: -// 1) Loading -// - read file from disk -// - parse/lex file -// - handle nested imports -// 2) Compilation -// - create meta object templates etc -// - compile to bytecode and cache it -// 3) Instantiation -// - running the bytecode to create an object tree, assign properties, etc -// - and, importantly, to evaluate bindings for the first time (incl. js expressions) -// 4) Dynamicism -// - bindings evaluation -// - signal handlers -// -// Aside from this, we also need to determine: -// 1) JavaScript Metrics -// - simple expressions -// - complex expressions -// - instantiation vs evaluation time -// - imports and nested imports -// 2) Context-switch costs -// - how expensive is it to call a cpp function from QML -// - how expensive is it to call a js function from cpp via QML -// - how expensive is it to pass around objects between them -// 3) Complete creation time. -// - loading + compilation + instantiation (for "application startup time" metric) -// -// In some cases, we want to include "initialization costs"; -// i.e., we need to tell the engine not to cache type data resulting -// in compilation between rounds, and we need to tell the engine not -// to cache whatever it caches between instantiations of components. -// The reason for this is that it is often the "first start of application" -// performance which we're attempting to benchmark. - -// define some custom types we use in test data functions. -typedef QList PropertyNameList; -Q_DECLARE_METATYPE(PropertyNameList); -typedef QList PropertyValueList; -Q_DECLARE_METATYPE(PropertyValueList); - -class tst_holistic : public QObject -{ - Q_OBJECT - -public: - tst_holistic(); - -private slots: - void initTestCase() - { - registerTypes(); - qRegisterMetaType("PropertyNameList"); - qRegisterMetaType("PropertyValueList"); - } - - void compilation_data(); - void compilation(); - void instantiation_data() { compilation_data(); } - void instantiation(); - void creation_data() { compilation_data(); } - void creation(); - void dynamicity_data(); - void dynamicity(); - - void cppToJsDirect_data(); - void cppToJsDirect(); - void cppToJsIndirect(); - - void typeResolution_data(); - void typeResolution(); - -private: - QDeclarativeEngine engine; -}; - -tst_holistic::tst_holistic() -{ -} - -inline QUrl TEST_FILE(const QString &filename) -{ - return QUrl::fromLocalFile(QLatin1String(SRCDIR) + QLatin1String("/data/") + filename); -} - - -void tst_holistic::compilation_data() -{ - QTest::addColumn("files"); - QTest::addColumn("repetitions"); - - QStringList f; - - // Benchmarks: a single, small component once with no caching. - f << QString(SRCDIR + QLatin1String("/data/smallTargets/SmallOne.qml")); - QTest::newRow("single small component") << f << 1; - - // Benchmarks: a single, small component ten times with caching. - QTest::newRow("single small component cached") << f << 10; f.clear(); - - // Benchmarks: a single, large component once with no caching. - f << QString(SRCDIR + QLatin1String("/data/largeTargets/mousearea-example.qml")); - QTest::newRow("single large component") << f << 1; - - // Benchmarks: a single, large component ten times with caching. - QTest::newRow("single large component cached") << f << 10; f.clear(); - - // Benchmarks: 4 small components once each with no caching - f << QString(SRCDIR + QLatin1String("/data/smallTargets/SmallOne.qml")); - f << QString(SRCDIR + QLatin1String("/data/smallTargets/SmallTwo.qml")); - f << QString(SRCDIR + QLatin1String("/data/smallTargets/SmallThree.qml")); - f << QString(SRCDIR + QLatin1String("/data/smallTargets/SmallFour.qml")); - QTest::newRow("multiple small components") << f << 1; - - // Benchmarks: 4 small components ten times each with caching - QTest::newRow("multiple small components cached") << f << 10; f.clear(); - - // Benchmarks: 3 large components once each with no caching. - f << QString(SRCDIR + QLatin1String("/data/largeTargets/mousearea-example.qml")); - f << QString(SRCDIR + QLatin1String("/data/largeTargets/gridview-example.qml")); - f << QString(SRCDIR + QLatin1String("/data/largeTargets/layoutdirection.qml")); - QTest::newRow("multiple large components") << f << 1; - - // Benchmarks: 3 large components ten times each with caching. - QTest::newRow("multiple large components cached") << f << 10; f.clear(); - - // Benchmarks: single small component which imports a single small js file, no caching - f << QString(SRCDIR + QLatin1String("/data/jsImports/Sssi.qml")); - QTest::newRow("single small js import") << f << 1; - - // Benchmarks: single small component which imports a single small js file, 10 reps, with caching - QTest::newRow("single small js import, cached") << f << 10; f.clear(); - - // Benchmarks: single small component which imports multiple small js files (no deep nesting), no caching - f << QString(SRCDIR + QLatin1String("/data/jsImports/Msbsi.qml")); - QTest::newRow("multiple small js imports, shallow") << f << 1; - - // Benchmarks: single small component which imports multiple small js files (no deep nesting), 10 reps, with caching - QTest::newRow("multiple small js imports, shallow, cached") << f << 10; f.clear(); - - // Benchmarks: single small component which imports multiple small js files (with deep nesting), no caching - f << QString(SRCDIR + QLatin1String("/data/jsImports/Msdsi.qml")); - QTest::newRow("multiple small js imports, deeply nested") << f << 1; - - // Benchmarks: single small component which imports multiple small js files (with deep nesting), 10 reps, with caching - QTest::newRow("multiple small js imports, deeply nested, cached") << f << 10; f.clear(); - - // Benchmarks: single small component which imports multiple small js files (nested and unnested), no caching - f << QString(SRCDIR + QLatin1String("/data/jsImports/Mssi.qml")); - QTest::newRow("muliple small js imports, both") << f << 1; - - // Benchmarks: single small component which imports multiple small js files (nested and unnested), 10 reps, with caching - QTest::newRow("muliple small js imports, both, cached") << f << 10; f.clear(); - - // Benchmarks: single small component which imports a single large js file, no caching - f << QString(SRCDIR + QLatin1String("/data/jsImports/Slsi.qml")); - QTest::newRow("single large js import") << f << 1; - - // Benchmarks: single small component which imports a single large js file, 10 reps, with caching - QTest::newRow("single large js import, cached") << f << 10; f.clear(); - - // Benchmarks: single small component which imports multiple large js files (no deep nesting), no caching - f << QString(SRCDIR + QLatin1String("/data/jsImports/Mlbsi.qml")); - QTest::newRow("multiple large js imports, shallow") << f << 1; - - // Benchmarks: single small component which imports multiple large js files (no deep nesting), 10 reps, with caching - QTest::newRow("multiple large js imports, shallow, cached") << f << 10; f.clear(); - - // Benchmarks: single small component which imports multiple large js files (with deep nesting), no caching - f << QString(SRCDIR + QLatin1String("/data/jsImports/Mldsi.qml")); - QTest::newRow("multiple large js imports, deeply nested") << f << 1; - - // Benchmarks: single small component which imports multiple large js files (with deep nesting), 10 reps, with caching - QTest::newRow("multiple large js imports, deeply nested, cached") << f << 10; f.clear(); - - // Benchmarks: single small component which imports multiple large js files (nested and unnested), no caching - f << QString(SRCDIR + QLatin1String("/data/jsImports/Mlsi.qml")); - QTest::newRow("multiple large js imports, both") << f << 1; - - // Benchmarks: single small component which imports multiple large js files (nested and unnested), 10 reps, with caching - QTest::newRow("multiple large js imports, both, cached") << f << 10; f.clear(); - - // Benchmarks: single small component which imports multiple js files which all import a .pragma library js file, no caching - f << QString(SRCDIR + QLatin1String("/data/jsImports/PragmaBm.qml")); - QTest::newRow(".pragma library js import") << f << 1; - - // Benchmarks: single small component which imports multiple js files which all import a .pragma library js file, 10 reps, with caching - QTest::newRow(".pragma library js import, cached") << f << 10; f.clear(); - - // Benchmarks: single small component which imports a js file which imports a QML module, no caching - f << QString(SRCDIR + QLatin1String("/data/jsImports/ModuleBm.qml")); - QTest::newRow("import js with QML import") << f << 1; - - // Benchmarks: single small component which imports a js file which imports a QML module, 10 reps, with caching - QTest::newRow("import js with QML import, cached") << f << 10; f.clear(); - - // Benchmarks: single small component which imports multiple js files which all import a .pragma library js file and a QML module, no caching - f << QString(SRCDIR + QLatin1String("/data/jsImports/PragmaModuleBm.qml")); - QTest::newRow("import js with QML import and .pragma library") << f << 1; - - // Benchmarks: single small component which imports multiple js files which all import a .pragma library js file and a QML module, 10 reps, with caching - QTest::newRow("import js with QML import and .pragma library, cached") << f << 10; f.clear(); -} - -void tst_holistic::compilation() -{ - // This function benchmarks the cost of loading and compiling specified QML files. - // If "repetitions" is non-zero, each file from "files" will be compiled "repetitions" - // times, without clearing the engine's component cache between compilations. - - QFETCH(QStringList, files); - QFETCH(int, repetitions); - Q_ASSERT(files.size() > 0); - Q_ASSERT(repetitions > 0); - - QBENCHMARK { - engine.clearComponentCache(); - for (int i = 0; i < repetitions; ++i) { - for (int j = 0; j < files.size(); ++j) { - QDeclarativeComponent c(&engine, QUrl::fromLocalFile(files.at(j))); - } - } - } -} - -void tst_holistic::instantiation() -{ - // This function benchmarks the cost of instantiating components compiled from specified QML files. - // If "repetitions" is non-zero, each component compiled from "files" will be instantiated "repetitions" - // times, without clearing the component's instantiation cache between instantiations. - - QFETCH(QStringList, files); - QFETCH(int, repetitions); - Q_ASSERT(files.size() > 0); - Q_ASSERT(repetitions > 0); - - QList components; - for (int i = 0; i < files.size(); ++i) { - QDeclarativeComponent *c = new QDeclarativeComponent(&engine, QUrl::fromLocalFile(files.at(i))); - components.append(c); - } - - QBENCHMARK { - // XXX TODO: clear each component's instantiation cache - - for (int i = 0; i < repetitions; ++i) { - for (int j = 0; j < components.size(); ++j) { - QObject *obj = components.at(j)->create(); - delete obj; - } - } - } - - // cleanup - for (int i = 0; i < components.size(); ++i) { - delete components.at(i); - } -} - -void tst_holistic::creation() -{ - // This function benchmarks the cost of loading, compiling and instantiating specified QML files. - // If "repetitions" is non-zero, each file from "files" will be created "repetitions" - // times, without clearing the engine's component cache between component creation. - - QFETCH(QStringList, files); - QFETCH(int, repetitions); - Q_ASSERT(files.size() > 0); - Q_ASSERT(repetitions > 0); - - QBENCHMARK { - engine.clearComponentCache(); - for (int i = 0; i < repetitions; ++i) { - for (int j = 0; j < files.size(); ++j) { - QDeclarativeComponent c(&engine, QUrl::fromLocalFile(files.at(j))); - QObject *obj = c.create(); - delete obj; - } - } - } -} - -void tst_holistic::dynamicity_data() -{ - QTest::addColumn("file"); - QTest::addColumn("writeProperty"); - QTest::addColumn("writeValueOne"); - QTest::addColumn("writeValueTwo"); - QTest::addColumn("readProperty"); - - QString f; - - // Benchmarks: single simple property binding - f = QString(SRCDIR + QLatin1String("/data/dynamicTargets/DynamicOne.qml")); - QTest::newRow("single simple property binding") << f << QString(QLatin1String("dynamicWidth")) << QVariant(300) << QVariant(500) << QString(QLatin1String("height")); - - // Benchmarks: multiple simple property bindings in one component - f = QString(SRCDIR + QLatin1String("/data/dynamicTargets/DynamicTwo.qml")); - QTest::newRow("multiple simple property bindings") << f << QString(QLatin1String("dynamicWidth")) << QVariant(300) << QVariant(500) << QString(QLatin1String("dynamicWidth")); - - // Benchmarks: single simple property binding plus onPropertyChanged slot - f = QString(SRCDIR + QLatin1String("/data/dynamicTargets/DynamicThree.qml")); - QTest::newRow("single simple plus slot") << f << QString(QLatin1String("dynamicWidth")) << QVariant(300) << QVariant(500) << QString(QLatin1String("dynamicWidth")); - - // Benchmarks: multiple simple property bindings plus multiple onPropertyChanged slots in one component - f = QString(SRCDIR + QLatin1String("/data/dynamicTargets/DynamicFour.qml")); - QTest::newRow("multiple simple plus slots") << f << QString(QLatin1String("dynamicWidth")) << QVariant(300) << QVariant(500) << QString(QLatin1String("dynamicHeight")); - - // Benchmarks: single simple js expression in a slot - f = QString(SRCDIR + QLatin1String("/data/jsTargets/JsOne.qml")); - QTest::newRow("single simple js expression slot") << f << QString(QLatin1String("dynamicWidth")) << QVariant(300) << QVariant(500) << QString(QLatin1String("dynamicWidth")); - - // Benchmarks: single complex js expression in a slot - f = QString(SRCDIR + QLatin1String("/data/jsTargets/JsTwo.qml")); - QTest::newRow("single complex js expression slot") << f << QString(QLatin1String("dynamicWidth")) << QVariant(300) << QVariant(500) << QString(QLatin1String("dynamicWidth")); - - // Benchmarks: simple property assignment and bindings update - f = QString(SRCDIR + QLatin1String("/data/scopeSwitching/CppToQml.qml")); - QTest::newRow("single simple property binding") << f << QString(QLatin1String("arbitrary")) << QVariant(36) << QVariant(35) << QString(QLatin1String("arbitrary")); -} - -void tst_holistic::dynamicity() -{ - // This function benchmarks the cost of "continued operation" - signal invocation, - // updating bindings, etc. Note that we take two different writeValues in order - // to force updates to occur, and we read to force lazy evaluation to occur. - - QFETCH(QString, file); - QFETCH(QString, writeProperty); - QFETCH(QVariant, writeValueOne); - QFETCH(QVariant, writeValueTwo); - QFETCH(QString, readProperty); - - QDeclarativeComponent c(&engine, file); - QObject *obj = c.create(); - - QVariant readValue; - QVariant writeValue; - bool usedFirst = false; - - QBENCHMARK { - if (usedFirst) { - writeValue = writeValueTwo; - usedFirst = false; - } else { - writeValue = writeValueOne; - usedFirst = true; - } - - obj->setProperty(writeProperty.toAscii().constData(), writeValue); - readValue = obj->property(readProperty.toAscii().constData()); - } - - delete obj; -} - - - - - - - -void tst_holistic::cppToJsDirect_data() -{ - QTest::addColumn("file"); - QTest::addColumn("methodName"); - - QString f; - - // Benchmarks: cost of calling a js function from cpp directly - f = QString(SRCDIR + QLatin1String("/data/scopeSwitching/CppToJs.qml")); - QTest::newRow("cpp-to-js") << f << QString(QLatin1String("callJsFunction")); - - // Benchmarks: cost of calling js function which calls cpp function: - // const CPP function with no return value and no arguments. - f = QString(SRCDIR + QLatin1String("/data/scopeSwitching/JsToCppOne.qml")); - QTest::newRow("cpp-to-js-to-cpp: no retn, no args") << f << QString(QLatin1String("callCppFunction")); - - // Benchmarks: cost of calling js function which calls cpp function: - // nonconst CPP function with no return value and no arguments. - f = QString(SRCDIR + QLatin1String("/data/scopeSwitching/JsToCppTwo.qml")); - QTest::newRow("cpp-to-js-to-cpp: nonconst, no retn, no args") << f << QString(QLatin1String("callCppFunction")); - - // Benchmarks: cost of calling js function which calls cpp function: - // const CPP function with no return value and a single integer argument. - f = QString(SRCDIR + QLatin1String("/data/scopeSwitching/JsToCppThree.qml")); - QTest::newRow("cpp-to-js-to-cpp: const, no retn, int arg") << f << QString(QLatin1String("callCppFunction")); - - // Benchmarks: cost of calling js function which calls cpp function: - // nonconst CPP function with no return value and a single integer argument. - f = QString(SRCDIR + QLatin1String("/data/scopeSwitching/JsToCppFour.qml")); - QTest::newRow("cpp-to-js-to-cpp: nonconst, no retn, int arg") << f << QString(QLatin1String("callCppFunction")); - - // Benchmarks: cost of calling js function which calls cpp function: - // const CPP function with an integer return value and no arguments. - f = QString(SRCDIR + QLatin1String("/data/scopeSwitching/JsToCppFive.qml")); - QTest::newRow("cpp-to-js-to-cpp: const, int retn, no args") << f << QString(QLatin1String("callCppFunction")); - - // Benchmarks: cost of calling js function which calls cpp function: - // nonconst CPP function with an integer return value and no arguments. - f = QString(SRCDIR + QLatin1String("/data/scopeSwitching/JsToCppSix.qml")); - QTest::newRow("cpp-to-js-to-cpp: nonconst, int retn, no args") << f << QString(QLatin1String("callCppFunction")); - - // Benchmarks: cost of calling js function which calls cpp function: - // const CPP function with an integer return value and a single integer argument. - f = QString(SRCDIR + QLatin1String("/data/scopeSwitching/JsToCppSeven.qml")); - QTest::newRow("cpp-to-js-to-cpp: const, int retn, int arg") << f << QString(QLatin1String("callCppFunction")); - - // Benchmarks: cost of calling js function which calls cpp function: - // nonconst CPP function with an integer return value and a single integer argument. - f = QString(SRCDIR + QLatin1String("/data/scopeSwitching/JsToCppEight.qml")); - QTest::newRow("cpp-to-js-to-cpp: nonconst, int retn, int arg") << f << QString(QLatin1String("callCppFunction")); - - // Benchmarks: cost of calling js function which calls cpp function: - // const CPP function with a variant return value and multiple integer arguments. - f = QString(SRCDIR + QLatin1String("/data/scopeSwitching/JsToCppNine.qml")); - QTest::newRow("cpp-to-js-to-cpp: const, variant retn, int args") << f << QString(QLatin1String("callCppFunction")); - - // Benchmarks: cost of calling js function which calls cpp function: - // nonconst CPP function with a variant return value and multiple integer arguments. - f = QString(SRCDIR + QLatin1String("/data/scopeSwitching/JsToCppTen.qml")); - QTest::newRow("cpp-to-js-to-cpp: nonconst, variant retn, int args") << f << QString(QLatin1String("callCppFunction")); - - // Benchmarks: cost of calling js function which calls cpp function: - // nonconst CPP function with a variant return value and multiple integer arguments. - f = QString(SRCDIR + QLatin1String("/data/scopeSwitching/JsToCppEleven.qml")); - QTest::newRow("cpp-to-js-to-cpp: nonconst, variant retn, variant + int args") << f << QString(QLatin1String("callCppFunction")); - - // Benchmarks: calling js function which copies scarce resources by calling back into cpp scope - f = QString(SRCDIR + QLatin1String("/data/scopeSwitching/ScarceOne.qml")); - QTest::newRow("cpp-to-js-to-coo: copy scarce resources") << f << QString(QLatin1String("copyScarceResources")); -} - - -void tst_holistic::cppToJsDirect() -{ - // This function benchmarks the cost of calling from CPP scope to JS scope - // (and possibly vice versa, if the invoked js method then calls to cpp). - - QFETCH(QString, file); - QFETCH(QString, methodName); - - QDeclarativeComponent c(&engine, file); - QObject *obj = c.create(); - - QBENCHMARK { - QMetaObject::invokeMethod(obj, methodName.toLatin1().constData()); - } - - delete obj; -} - - -void tst_holistic::cppToJsIndirect() -{ - // This function benchmarks the cost of binding scarce resources - // to properties of a QML component. The engine should automatically release such - // resources when they are no longer used. - // The benchmark deliberately causes change signals to be emitted (and - // modifies the scarce resources) so that the properties are updated. - - QDeclarativeComponent c(&engine, QString(SRCDIR + QLatin1String("/data/scopeSwitching/ScarceTwo.qml"))); - QObject *obj = c.create(); - - ScarceResourceProvider *srp = 0; - srp = qobject_cast(QDeclarativeProperty::read(obj, "a").value()); - - QBENCHMARK { - srp->changeResources(); // will cause small+large scarce resources changed signals to be emitted. - } - - delete obj; -} - - - - - -void tst_holistic::typeResolution_data() -{ - QTest::addColumn("file"); - QTest::addColumn("propertyNameOne"); - QTest::addColumn("propertyValueOne"); - QTest::addColumn("propertyNameTwo"); - QTest::addColumn("propertyValueTwo"); - QTest::addColumn("repetitions"); - - QString f; - PropertyNameList pn1; - PropertyValueList pv1; - PropertyNameList pn2; - PropertyValueList pv2; - - // Benchmarks: resolving nested ids and types, no caching - f = QString(SRCDIR + QLatin1String("/data/resolutionTargets/ResolveOne.qml")); - pn1 << QString(QLatin1String("baseWidth")) << QString(QLatin1String("baseHeight")) << QString(QLatin1String("baseColor")); - pv1 << QVariant(401) << QVariant(402) << QVariant(QString(QLatin1String("brown"))); - pn2 << QString(QLatin1String("baseWidth")) << QString(QLatin1String("baseHeight")) << QString(QLatin1String("baseColor")); - pv2 << QVariant(403) << QVariant(404) << QVariant(QString(QLatin1String("orange"))); - QTest::newRow("nested id resolution") << f << pn1 << pv1 << pn2 << pv2 << 1; - - // Benchmarks: resolving nested ids and types, 10 reps with caching - QTest::newRow("nested id resolution, cached") << f << pn1 << pv1 << pn2 << pv2 << 10; - pn1.clear(); pn2.clear(); pv1.clear(); pv2.clear(); -} - -void tst_holistic::typeResolution() -{ - // This function benchmarks the cost of "continued operation" (signal invocation, - // updating bindings, etc) where the component has lots of nested items with - // lots of resolving required. Note that we take two different writeValues in order - // to force updates to occur. - - QFETCH(QString, file); - QFETCH(PropertyNameList, propertyNameOne); - QFETCH(PropertyValueList, propertyValueOne); - QFETCH(PropertyNameList, propertyNameTwo); - QFETCH(PropertyValueList, propertyValueTwo); - QFETCH(int, repetitions); - - Q_ASSERT(propertyNameOne.size() == propertyValueOne.size()); - Q_ASSERT(propertyNameTwo.size() == propertyValueTwo.size()); - Q_ASSERT(repetitions > 0); - - QDeclarativeComponent c(&engine, file); - QObject *obj = c.create(); - - PropertyNameList writeProperty; - PropertyValueList writeValue; - bool usedFirst = false; - - QBENCHMARK { - for (int i = 0; i < repetitions; ++i) { - if (usedFirst) { - writeProperty = propertyNameOne; - writeValue = propertyValueOne; - usedFirst = false; - } else { - writeProperty = propertyNameTwo; - writeValue = propertyValueTwo; - usedFirst = true; - } - - for (int j = 0; j < writeProperty.size(); ++j) { - obj->setProperty(writeProperty.at(j).toAscii().constData(), writeValue.at(j)); - } - } - } - - delete obj; -} - - -QTEST_MAIN(tst_holistic) - -#include "tst_holistic.moc" diff --git a/tests/benchmarks/declarative/javascript/data/NestedIdObject.qml b/tests/benchmarks/declarative/javascript/data/NestedIdObject.qml deleted file mode 100644 index 753d547ace..0000000000 --- a/tests/benchmarks/declarative/javascript/data/NestedIdObject.qml +++ /dev/null @@ -1,9 +0,0 @@ -import QtQuick 2.0 - -QtObject { - function runtest() { - for (var ii = 0; ii < 5000000; ++ii) { - root - } - } -} diff --git a/tests/benchmarks/declarative/javascript/data/intQObjectProperty.qml b/tests/benchmarks/declarative/javascript/data/intQObjectProperty.qml deleted file mode 100644 index c3e6ebc16a..0000000000 --- a/tests/benchmarks/declarative/javascript/data/intQObjectProperty.qml +++ /dev/null @@ -1,13 +0,0 @@ -import Qt.test 1.0 - -TestObject { - id: root - - function runtest() { - var r = root; - - for (var ii = 0; ii < 5000000; ++ii) { - r.intValue - } - } -} diff --git a/tests/benchmarks/declarative/javascript/data/localId.qml b/tests/benchmarks/declarative/javascript/data/localId.qml deleted file mode 100644 index d42b891092..0000000000 --- a/tests/benchmarks/declarative/javascript/data/localId.qml +++ /dev/null @@ -1,13 +0,0 @@ -// Benchmarks the cost of accessing an id in the same file as the script. - -import QtQuick 2.0 - -QtObject { - id: root - - function runtest() { - for (var ii = 0; ii < 5000000; ++ii) { - root - } - } -} diff --git a/tests/benchmarks/declarative/javascript/data/nestedId.qml b/tests/benchmarks/declarative/javascript/data/nestedId.qml deleted file mode 100644 index 538699d452..0000000000 --- a/tests/benchmarks/declarative/javascript/data/nestedId.qml +++ /dev/null @@ -1,13 +0,0 @@ -// Benchmarks the cost of accessing an id in a parent context of the script. - -import QtQuick 2.0 - -QtObject { - id: root - - property variant object: NestedIdObject {} - function runtest() { - object.runtest(); - } -} - diff --git a/tests/benchmarks/declarative/javascript/data/stringQObjectProperty.qml b/tests/benchmarks/declarative/javascript/data/stringQObjectProperty.qml deleted file mode 100644 index ccd8a791b6..0000000000 --- a/tests/benchmarks/declarative/javascript/data/stringQObjectProperty.qml +++ /dev/null @@ -1,14 +0,0 @@ -import Qt.test 1.0 - -TestObject { - id: root - - function runtest() { - var r = root; - - for (var ii = 0; ii < 5000000; ++ii) { - r.stringValue - } - } -} - diff --git a/tests/benchmarks/declarative/javascript/javascript.pro b/tests/benchmarks/declarative/javascript/javascript.pro deleted file mode 100644 index 8026540309..0000000000 --- a/tests/benchmarks/declarative/javascript/javascript.pro +++ /dev/null @@ -1,11 +0,0 @@ -CONFIG += testcase -TEMPLATE = app -TARGET = tst_javascript -QT += declarative testlib -macx:CONFIG -= app_bundle - -SOURCES += tst_javascript.cpp testtypes.cpp -HEADERS += testtypes.h - -# Define SRCDIR equal to test's source directory -DEFINES += SRCDIR=\\\"$$PWD\\\" diff --git a/tests/benchmarks/declarative/javascript/testtypes.cpp b/tests/benchmarks/declarative/javascript/testtypes.cpp deleted file mode 100644 index 0ba82a495d..0000000000 --- a/tests/benchmarks/declarative/javascript/testtypes.cpp +++ /dev/null @@ -1,48 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "testtypes.h" -#include - -void registerTypes() -{ - qmlRegisterType("Qt.test", 1,0, "TestObject"); -} diff --git a/tests/benchmarks/declarative/javascript/testtypes.h b/tests/benchmarks/declarative/javascript/testtypes.h deleted file mode 100644 index 91be9078ed..0000000000 --- a/tests/benchmarks/declarative/javascript/testtypes.h +++ /dev/null @@ -1,65 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef TESTTYPES_H -#define TESTTYPES_H - -#include - -class TestObject : public QObject -{ - Q_OBJECT - Q_PROPERTY(int intValue READ intValue); - Q_PROPERTY(QString stringValue READ stringValue); - -public: - TestObject() : m_string("Hello world!") {} - - int intValue() const { return 13; } - QString stringValue() const { return m_string; } - -private: - QString m_string; -}; - -void registerTypes(); - -#endif // TESTTYPES_H diff --git a/tests/benchmarks/declarative/javascript/tst_javascript.cpp b/tests/benchmarks/declarative/javascript/tst_javascript.cpp deleted file mode 100644 index f27c7e5b73..0000000000 --- a/tests/benchmarks/declarative/javascript/tst_javascript.cpp +++ /dev/null @@ -1,123 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include -#include -#include -#include -#include - -#include "testtypes.h" - -class tst_javascript : public QObject -{ - Q_OBJECT - -public: - tst_javascript(); - virtual ~tst_javascript(); - -private slots: - void run_data(); - void run(); - -private: - QDeclarativeEngine engine; -}; - -tst_javascript::tst_javascript() -{ - registerTypes(); -} - -tst_javascript::~tst_javascript() -{ -} - -void tst_javascript::run_data() -{ - QTest::addColumn("file"); - - QDir dir(SRCDIR "/data"); - - QStringList files = dir.entryList(QDir::Files | QDir::NoDotAndDotDot); - - for (int ii = 0; ii < files.count(); ++ii) { - QString file = files.at(ii); - if (file.endsWith(".qml") && file.at(0).isLower()) { - - QString testName = file.left(file.length() - 4 /* strlen(".qml") */); - QString fileName = QLatin1String(SRCDIR) + QLatin1String("/data/") + file; - - - QTest::newRow(qPrintable(testName)) << fileName; - - } - } -} - -void tst_javascript::run() -{ - QFETCH(QString, file); - - QDeclarativeComponent c(&engine, file); - - if (c.isError()) { - qWarning() << c.errors(); - } - - QVERIFY(!c.isError()); - - QObject *o = c.create(); - QVERIFY(o != 0); - - QMetaMethod method = o->metaObject()->method(o->metaObject()->indexOfMethod("runtest()")); - - QBENCHMARK { - method.invoke(o); - } - - delete o; -} - -QTEST_MAIN(tst_javascript) - -#include "tst_javascript.moc" diff --git a/tests/benchmarks/declarative/js/js.pro b/tests/benchmarks/declarative/js/js.pro deleted file mode 100644 index b1448d8eb8..0000000000 --- a/tests/benchmarks/declarative/js/js.pro +++ /dev/null @@ -1,10 +0,0 @@ -TEMPLATE = subdirs -SUBDIRS = \ - qjsengine \ - qjsvalue \ - qjsvalueiterator \ - -TRUSTED_BENCHMARKS += \ - qjsvalue \ - qjsengine \ - diff --git a/tests/benchmarks/declarative/js/qjsengine/qjsengine.pro b/tests/benchmarks/declarative/js/qjsengine/qjsengine.pro deleted file mode 100644 index f04da8ec95..0000000000 --- a/tests/benchmarks/declarative/js/qjsengine/qjsengine.pro +++ /dev/null @@ -1,7 +0,0 @@ -CONFIG += testcase -TEMPLATE = app -TARGET = tst_bench_qjsengine - -SOURCES += tst_qjsengine.cpp - -QT += declarative testlib diff --git a/tests/benchmarks/declarative/js/qjsengine/tst_qjsengine.cpp b/tests/benchmarks/declarative/js/qjsengine/tst_qjsengine.cpp deleted file mode 100644 index c7011e40a0..0000000000 --- a/tests/benchmarks/declarative/js/qjsengine/tst_qjsengine.cpp +++ /dev/null @@ -1,600 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include -#include -#include - - -Q_DECLARE_METATYPE(QJSValue) - -class tst_QJSEngine : public QObject -{ - Q_OBJECT - -public: - tst_QJSEngine(); - virtual ~tst_QJSEngine(); - -public slots: - void init(); - void cleanup(); - -private slots: - void constructor(); -#if 0 // No defaultPrototype for now - void defaultPrototype(); - void setDefaultPrototype(); -#endif - void evaluate_data(); - void evaluate(); -#if 0 // No program - void evaluateProgram_data(); - void evaluateProgram(); -#endif -#if 0 // no connections for now - void connectAndDisconnect(); -#endif - void globalObject(); - void hasUncaughtException(); -#if 0 // no is Evaluating for now - void isEvaluating(); -#endif - void newArray_data(); - void newArray(); - void newDate(); - void newObject(); -#if 0 // No ScriptClass - void newObjectWithScriptClass(); -#endif -#if 0 // no qmetaobject - void newQMetaObject(); -#endif - void newQObject(); -#if 0 // no native functions for now - void newFunction(); -#endif - void newRegExp(); - void newVariant(); - void undefinedValue(); - void collectGarbage(); -#if 0 // No extensions - void availableExtensions(); - void importedExtensions(); -#endif -#if 0 // no context - void currentContext(); - void pushAndPopContext(); -#endif -#if 0 // no stringhandle - void toStringHandle(); -#endif - void castValueToQreal(); -#if 0 // no native functions for now - void nativeCall(); -#endif -#if 0 // no translations - void installTranslatorFunctions(); - void translation_data(); - void translation(); -#endif -#if 0 // no declarative class - void readScopeProperty_data(); - void readScopeProperty(); -#endif -#if 0 // no context - void evaluateInNewContext(); - void evaluateInNewContextWithScope(); -#endif -#if 0 // no pushScope - void evaluateBindingExpression(); -#endif - -private: - void defineStandardTestValues(); - void newEngine() - { - delete m_engine; - m_engine = new QJSEngine; - } - - QJSEngine *m_engine; -}; - -tst_QJSEngine::tst_QJSEngine() - : m_engine(0) -{ -} - -tst_QJSEngine::~tst_QJSEngine() -{ - delete m_engine; -} - -void tst_QJSEngine::init() -{ -} - -void tst_QJSEngine::cleanup() -{ -} - -void tst_QJSEngine::constructor() -{ - QBENCHMARK { - QJSEngine engine; - (void)engine.parent(); - } -} - -#if 0 // No defaultPrototype for now -void tst_QJSEngine::defaultPrototype() -{ - newEngine(); - int type = qMetaTypeId(); - m_engine->setDefaultPrototype(type, m_engine->newObject()); - QBENCHMARK { - m_engine->defaultPrototype(type); - } -} - -void tst_QJSEngine::setDefaultPrototype() -{ - newEngine(); - int type = qMetaTypeId(); - QJSValue proto = m_engine->newObject(); - QBENCHMARK { - m_engine->setDefaultPrototype(type, proto); - } -} - -#endif - -void tst_QJSEngine::evaluate_data() -{ - QTest::addColumn("code"); - QTest::newRow("empty script") << QString::fromLatin1(""); - QTest::newRow("number literal") << QString::fromLatin1("123"); - QTest::newRow("string literal") << QString::fromLatin1("'ciao'"); - QTest::newRow("regexp literal") << QString::fromLatin1("/foo/gim"); - QTest::newRow("null literal") << QString::fromLatin1("null"); - QTest::newRow("undefined literal") << QString::fromLatin1("undefined"); - QTest::newRow("null literal") << QString::fromLatin1("null"); - QTest::newRow("empty object literal") << QString::fromLatin1("{}"); - QTest::newRow("this") << QString::fromLatin1("this"); - QTest::newRow("object literal with one property") << QString::fromLatin1("{ foo: 123 }"); - QTest::newRow("object literal with two properties") << QString::fromLatin1("{ foo: 123, bar: 456 }"); - QTest::newRow("object literal with many properties") << QString::fromLatin1("{ a: 1, b: 2, c: 3, d: 4, e: 5, f: 6, g: 7, h: 8, i: 9, j: 10 }"); - QTest::newRow("empty array literal") << QString::fromLatin1("[]"); - QTest::newRow("array literal with one element") << QString::fromLatin1("[1]"); - QTest::newRow("array literal with two elements") << QString::fromLatin1("[1,2]"); - QTest::newRow("array literal with many elements") << QString::fromLatin1("[1,2,3,4,5,6,7,8,9,10,9,8,7,6,5,4,3,2,1]"); - QTest::newRow("empty function definition") << QString::fromLatin1("function foo() { }"); - QTest::newRow("function definition") << QString::fromLatin1("function foo() { return 123; }"); - QTest::newRow("for loop with empty body (1000 iterations)") << QString::fromLatin1("for (i = 0; i < 1000; ++i) {}"); - QTest::newRow("for loop with empty body (10000 iterations)") << QString::fromLatin1("for (i = 0; i < 10000; ++i) {}"); - QTest::newRow("for loop with empty body (100000 iterations)") << QString::fromLatin1("for (i = 0; i < 100000; ++i) {}"); - QTest::newRow("for loop with empty body (1000000 iterations)") << QString::fromLatin1("for (i = 0; i < 1000000; ++i) {}"); - QTest::newRow("for loop (1000 iterations)") << QString::fromLatin1("j = 0; for (i = 0; i < 1000; ++i) { j += i; }; j"); - QTest::newRow("for loop (10000 iterations)") << QString::fromLatin1("j = 0; for (i = 0; i < 10000; ++i) { j += i; }; j"); - QTest::newRow("for loop (100000 iterations)") << QString::fromLatin1("j = 0; for (i = 0; i < 100000; ++i) { j += i; }; j"); - QTest::newRow("for loop (1000000 iterations)") << QString::fromLatin1("j = 0; for (i = 0; i < 1000000; ++i) { j += i; }; j"); - QTest::newRow("assignments") << QString::fromLatin1("a = 1; b = 2; c = 3; d = 4"); - QTest::newRow("while loop (1000 iterations)") << QString::fromLatin1("i = 0; while (i < 1000) { ++i; }; i"); - QTest::newRow("while loop (10000 iterations)") << QString::fromLatin1("i = 0; while (i < 10000) { ++i; }; i"); - QTest::newRow("while loop (100000 iterations)") << QString::fromLatin1("i = 0; while (i < 100000) { ++i; }; i"); - QTest::newRow("while loop (1000000 iterations)") << QString::fromLatin1("i = 0; while (i < 1000000) { ++i; }; i"); - QTest::newRow("function expression") << QString::fromLatin1("(function(a, b, c){ return a + b + c; })(1, 2, 3)"); -} - -void tst_QJSEngine::evaluate() -{ - QFETCH(QString, code); - newEngine(); - - QBENCHMARK { - (void)m_engine->evaluate(code); - } -} - -#if 0 -void tst_QJSEngine::connectAndDisconnect() -{ - newEngine(); - QJSValue fun = m_engine->evaluate("(function() { })"); - QBENCHMARK { - qScriptConnect(m_engine, SIGNAL(destroyed()), QJSValue(), fun); - qScriptDisconnect(m_engine, SIGNAL(destroyed()), QJSValue(), fun); - } -} - -void tst_QJSEngine::evaluateProgram_data() -{ - evaluate_data(); -} - -void tst_QJSEngine::evaluateProgram() -{ - QFETCH(QString, code); - QScriptProgram program(code); - newEngine(); - - QBENCHMARK { - (void)m_engine->evaluate(program); - } -} -#endif - -void tst_QJSEngine::globalObject() -{ - newEngine(); - QBENCHMARK { - m_engine->globalObject(); - } -} - -void tst_QJSEngine::hasUncaughtException() -{ - newEngine(); - QBENCHMARK { - m_engine->hasUncaughtException(); - } -} - -#if 0 -void tst_QJSEngine::isEvaluating() -{ - newEngine(); - QBENCHMARK { - m_engine->isEvaluating(); - } -} -#endif - -void tst_QJSEngine::newArray_data() -{ - QTest::addColumn("size"); - QTest::newRow("size=0") << 0; - QTest::newRow("size=10") << 10; - QTest::newRow("size=100") << 0; - QTest::newRow("size=1000") << 0; - QTest::newRow("size=10000") << 0; - QTest::newRow("size=50000") << 0; -} - -void tst_QJSEngine::newArray() -{ - QFETCH(int, size); - newEngine(); - QBENCHMARK { - m_engine->newArray(size); - } -} - -void tst_QJSEngine::newDate() -{ - newEngine(); - QDateTime dt = QDateTime::currentDateTime(); - QBENCHMARK { - m_engine->toScriptValue(dt); - } -} - -void tst_QJSEngine::newObject() -{ - newEngine(); - QBENCHMARK { - (void)m_engine->newObject(); - } -} - -#if 0 -void tst_QJSEngine::newObjectWithScriptClass() -{ - newEngine(); - QScriptClass cls(m_engine); - QBENCHMARK { - m_engine->newObject(&cls); - } -} - -void tst_QJSEngine::newQMetaObject() -{ - newEngine(); - QBENCHMARK { - m_engine->newQMetaObject(&QJSEngine::staticMetaObject); - } -} -#endif - -void tst_QJSEngine::newQObject() -{ - newEngine(); - QBENCHMARK { - (void)m_engine->newQObject(QCoreApplication::instance()); - } -} - -#if 0 -static QJSValue testFunction(QScriptContext *, QJSEngine *) -{ - return 0; -} - -void tst_QJSEngine::newFunction() -{ - newEngine(); - QBENCHMARK { - (void)m_engine->newFunction(testFunction); - } -} -#endif - -void tst_QJSEngine::newRegExp() -{ - newEngine(); - QRegExp re = QRegExp("foo"); - QBENCHMARK { - m_engine->toScriptValue(re); - } -} - -void tst_QJSEngine::newVariant() -{ - newEngine(); - QVariant var(QPoint(10, 20)); - QBENCHMARK { - (void)m_engine->toScriptValue(var); - } -} - -void tst_QJSEngine::undefinedValue() -{ - newEngine(); - QVariant var; - QBENCHMARK { - m_engine->toScriptValue(var); - } -} - -void tst_QJSEngine::collectGarbage() -{ - newEngine(); - QBENCHMARK { - m_engine->collectGarbage(); - } -} - -#if 0 -void tst_QJSEngine::availableExtensions() -{ - newEngine(); - QBENCHMARK { - m_engine->availableExtensions(); - } -} - -void tst_QJSEngine::importedExtensions() -{ - newEngine(); - QBENCHMARK { - m_engine->importedExtensions(); - } -} - -void tst_QJSEngine::currentContext() -{ - newEngine(); - QBENCHMARK { - m_engine->currentContext(); - } -} - -void tst_QJSEngine::pushAndPopContext() -{ - newEngine(); - QBENCHMARK { - (void)m_engine->pushContext(); - m_engine->popContext(); - } -} -#endif - -#if 0 -void tst_QJSEngine::toStringHandle() -{ - newEngine(); - QString str = QString::fromLatin1("foobarbaz"); - QBENCHMARK { - (void)m_engine->toStringHandle(str); - } -} -#endif - -void tst_QJSEngine::castValueToQreal() -{ - QJSValue val(123); - QBENCHMARK { - (void)qjsvalue_cast(val); - } -} - -#if 0 -static QJSValue native_function(QScriptContext *, QJSEngine *) -{ - return 42; -} - -void tst_QJSEngine::nativeCall() -{ - newEngine(); - m_engine->globalObject().setProperty("fun", m_engine->newFunction(native_function)); - QBENCHMARK{ - m_engine->evaluate("var w = 0; for (i = 0; i < 100000; ++i) {\n" - " w += fun() + fun(); w -= fun(); fun(); w -= fun(); }"); - } -} - -void tst_QJSEngine::installTranslatorFunctions() -{ - newEngine(); - QBENCHMARK { - m_engine->installTranslatorFunctions(); - } -} - -void tst_QJSEngine::translation_data() -{ - QTest::addColumn("text"); - QTest::addColumn("fileName"); - QTest::newRow("no translation") << "\"hello world\"" << ""; - QTest::newRow("qsTr") << "qsTr(\"hello world\")" << ""; - QTest::newRow("qsTranslate") << "qsTranslate(\"\", \"hello world\")" << ""; - QTest::newRow("qsTr:script.js") << "qsTr(\"hello world\")" << "script.js"; -} - -void tst_QJSEngine::translation() -{ - QFETCH(QString, text); - QFETCH(QString, fileName); - newEngine(); - m_engine->installTranslatorFunctions(); - - QBENCHMARK { - (void)m_engine->evaluate(text, fileName); - } -} -#endif - -#if 0 -void tst_QJSEngine::readScopeProperty_data() -{ - QTest::addColumn("staticScope"); - QTest::addColumn("nestedScope"); - QTest::newRow("single dynamic scope") << false << false; - QTest::newRow("single static scope") << true << false; - QTest::newRow("double dynamic scope") << false << true; - QTest::newRow("double static scope") << true << true; -} - -void tst_QJSEngine::readScopeProperty() -{ - QFETCH(bool, staticScope); - QFETCH(bool, nestedScope); - - newEngine(); - QScriptContext *ctx = m_engine->pushContext(); - - QJSValue scope; - if (staticScope) - scope = QScriptDeclarativeClass::newStaticScopeObject(m_engine); - else - scope = m_engine->newObject(); - scope.setProperty("foo", 123); - ctx->pushScope(scope); - - if (nestedScope) { - QJSValue scope2; - if (staticScope) - scope2 = QScriptDeclarativeClass::newStaticScopeObject(m_engine); - else - scope2 = m_engine->newObject(); - scope2.setProperty("bar", 456); // ensure a miss in inner scope - ctx->pushScope(scope2); - } - - QJSValue fun = m_engine->evaluate("(function() {\n" - " for (var i = 0; i < 10000; ++i) {\n" - " foo; foo; foo; foo; foo; foo; foo; foo;\n" - " }\n" - "})"); - m_engine->popContext(); - QVERIFY(fun.isFunction()); - QBENCHMARK { - fun.call(); - } -} - -void tst_QJSEngine::evaluateInNewContext() -{ - QJSEngine engine; - QBENCHMARK { - engine.pushContext(); - engine.evaluate("var a = 10"); - engine.popContext(); - } -} - -void tst_QJSEngine::evaluateInNewContextWithScope() -{ - QJSEngine engine; - QJSValue scope = engine.newObject(); - scope.setProperty("foo", 123); - QBENCHMARK { - QScriptContext *ctx = engine.pushContext(); - ctx->pushScope(scope); - engine.evaluate("foo"); - engine.popContext(); - } -} - -// Binding expressions in QML are implemented as anonymous functions -// with custom scopes. -void tst_QJSEngine::evaluateBindingExpression() -{ - QJSEngine engine; - QScriptContext *ctx = engine.pushContext(); - QJSValue scope = engine.newObject(); - scope.setProperty("foo", 123); - ctx->pushScope(scope); - QJSValue fun = engine.evaluate("(function() { return foo; })"); - QVERIFY(fun.isFunction()); - engine.popContext(); - QVERIFY(fun.call().equals(scope.property("foo"))); - QJSValue receiver = engine.globalObject(); - QBENCHMARK { - fun.call(receiver); - } -} -#endif - -QTEST_MAIN(tst_QJSEngine) -#include "tst_qjsengine.moc" diff --git a/tests/benchmarks/declarative/js/qjsvalue/qjsvalue.pro b/tests/benchmarks/declarative/js/qjsvalue/qjsvalue.pro deleted file mode 100644 index 2dc917d3aa..0000000000 --- a/tests/benchmarks/declarative/js/qjsvalue/qjsvalue.pro +++ /dev/null @@ -1,7 +0,0 @@ -CONFIG += testcase -TEMPLATE = app -TARGET = tst_bench_qjsvalue - -SOURCES += tst_qjsvalue.cpp - -QT += declarative testlib diff --git a/tests/benchmarks/declarative/js/qjsvalue/tst_qjsvalue.cpp b/tests/benchmarks/declarative/js/qjsvalue/tst_qjsvalue.cpp deleted file mode 100644 index 4c085ab437..0000000000 --- a/tests/benchmarks/declarative/js/qjsvalue/tst_qjsvalue.cpp +++ /dev/null @@ -1,979 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include -#include -#include - -Q_DECLARE_METATYPE(QJSValue) - -class tst_QJSValue : public QObject -{ - Q_OBJECT - -public: - tst_QJSValue(); - virtual ~tst_QJSValue(); - -public slots: - void init(); - void cleanup(); - -private slots: - void boolConstructor(); - void floatConstructor(); - void numberConstructor(); - void stringConstructor(); - void nullConstructor(); - void undefinedConstructor(); - void boolConstructorWithEngine(); - void floatConstructorWithEngine(); - void intConstructorWithEngine(); - void stringConstructorWithEngine(); - void undefinedConstructorWithEngine(); - void copyConstructor_data(); - void copyConstructor(); - void call_data(); - void call(); - void construct_data(); - void construct(); -#if 0 // no data - void data(); - void setData(); - void data_noData_data(); - void data_noData(); -#endif - void equalsSelf_data(); - void equalsSelf(); -#if 0 // no less then - void lessThanSelf_data(); - void lessThanSelf(); -#endif - void strictlyEqualsSelf_data(); - void strictlyEqualsSelf(); - void isArray_data(); - void isArray(); - void isBool_data(); - void isBool(); - void isDate_data(); - void isDate(); - void isError_data(); - void isError(); - void isCallable_data(); - void isCallable(); - void isNull_data(); - void isNull(); - void isNumber_data(); - void isNumber(); - void isObject_data(); - void isObject(); -#if 0 // no qmetaobject - void isQMetaObject_data(); - void isQMetaObject(); -#endif - void isQObject_data(); - void isQObject(); - void isRegExp_data(); - void isRegExp(); - void isString_data(); - void isString(); - void isUndefined_data(); - void isUndefined(); - void isVariant_data(); - void isVariant(); - void toBool_data(); - void toBool(); - void toDateTime_data(); - void toDateTime(); - void toInt_data(); - void toInt(); - void toNumber_data(); - void toNumber(); - void toRegExp_data(); - void toRegExp(); - void toString_data(); - void toString(); - void toUInt_data(); - void toUInt(); -#if 0 // no qmetaobject - void toQMetaObject_data(); - void toQMetaObject(); -#endif - void toQObject_data(); - void toQObject(); - void toVariant_data(); - void toVariant(); - void property_data(); - void property(); -#if 0 // no string handle - void propertyById_data(); - void propertyById(); -#endif - void propertyByIndex(); - void setProperty_data(); - void setProperty(); -#if 0 // no string handle - void setPropertyById_data(); - void setPropertyById(); -#endif - void setPropertyByIndex(); -#if 0 // no propertyFlags for now - void propertyFlags_data(); - void propertyFlags(); - void propertyFlagsById_data(); - void propertyFlagsById(); -#endif - void prototype_data(); - void prototype(); - void setPrototype(); -#if 0 // no script class - void scriptClass_data(); - void scriptClass(); - void setScriptClass(); -#endif -#if 0 // no string handle - void readMetaProperty(); - void writeMetaProperty(); -#endif - -private: - void defineStandardTestValues(); - void newEngine() - { - delete m_engine; - m_engine = new QJSEngine; - } - - QJSEngine *m_engine; -}; - -tst_QJSValue::tst_QJSValue() - : m_engine(0) -{ -} - -tst_QJSValue::~tst_QJSValue() -{ - delete m_engine; -} - -void tst_QJSValue::init() -{ -} - -void tst_QJSValue::cleanup() -{ -} - -void tst_QJSValue::boolConstructor() -{ - QBENCHMARK { - QJSValue val(true); - } -} - -void tst_QJSValue::floatConstructor() -{ - QBENCHMARK { - QJSValue val(123.0); - } -} - -void tst_QJSValue::numberConstructor() -{ - QBENCHMARK { - (void)QJSValue(123); - } -} - -void tst_QJSValue::stringConstructor() -{ - QString str = QString::fromLatin1("ciao"); - QBENCHMARK { - (void)QJSValue(str); - } -} - -void tst_QJSValue::nullConstructor() -{ - QBENCHMARK { - QJSValue val(QJSValue::NullValue); - } -} - -void tst_QJSValue::undefinedConstructor() -{ - QBENCHMARK { - QJSValue val(QJSValue::UndefinedValue); - } -} - -void tst_QJSValue::boolConstructorWithEngine() -{ - newEngine(); - QBENCHMARK { - m_engine->toScriptValue(true); - } -} - -void tst_QJSValue::floatConstructorWithEngine() -{ - newEngine(); - QBENCHMARK { - m_engine->toScriptValue(123.0); - } -} - -void tst_QJSValue::intConstructorWithEngine() -{ - newEngine(); - QBENCHMARK { - m_engine->toScriptValue(123); - } -} - -void tst_QJSValue::stringConstructorWithEngine() -{ - newEngine(); - QString str = QString::fromLatin1("ciao"); - QBENCHMARK { - m_engine->toScriptValue(str); - } -} - -void tst_QJSValue::undefinedConstructorWithEngine() -{ - newEngine(); - QVariant var; - QBENCHMARK { - m_engine->toScriptValue(var); - } -} - -void tst_QJSValue::copyConstructor_data() -{ - defineStandardTestValues(); -} - -void tst_QJSValue::copyConstructor() -{ - QFETCH(QJSValue, val); - QBENCHMARK { - QJSValue copy(val); - } -} - -void tst_QJSValue::call_data() -{ - newEngine(); - QTest::addColumn("code"); - QTest::newRow("empty function") << QString::fromLatin1("(function(){})"); - QTest::newRow("function returning number") << QString::fromLatin1("(function(){ return 123; })"); - QTest::newRow("closure") << QString::fromLatin1("(function(a, b){ return function() { return a + b; }; })(1, 2)"); -} - -void tst_QJSValue::call() -{ - QFETCH(QString, code); - QJSValue fun = m_engine->evaluate(code); - QVERIFY(fun.isCallable()); - QBENCHMARK { - (void)fun.call(); - } -} - -void tst_QJSValue::construct_data() -{ - newEngine(); - QTest::addColumn("code"); - QTest::newRow("empty function") << QString::fromLatin1("(function(){})"); - QTest::newRow("simple constructor") << QString::fromLatin1("(function(){ this.x = 10; this.y = 20; })"); -} - -void tst_QJSValue::construct() -{ - QFETCH(QString, code); - QJSValue fun = m_engine->evaluate(code); - QVERIFY(fun.isCallable()); - QBENCHMARK { - (void)fun.callAsConstructor(); - } -} - -#if 0 -void tst_QJSValue::data() -{ - newEngine(); - QJSValue obj = m_engine->newObject(); - obj.setData(QJSValue(m_engine, 123)); - QBENCHMARK { - obj.data(); - } -} - -void tst_QJSValue::setData() -{ - newEngine(); - QJSValue obj = m_engine->newObject(); - QJSValue val(m_engine, 123); - QBENCHMARK { - obj.setData(val); - } -} - -void tst_QJSValue::data_noData_data() -{ - defineStandardTestValues(); -} - -void tst_QJSValue::data_noData() -{ - QFETCH(QJSValue, val); - QVERIFY(!val.data().isValid()); - QBENCHMARK { - val.data(); - } -} -#endif - -void tst_QJSValue::equalsSelf_data() -{ - defineStandardTestValues(); -} - -void tst_QJSValue::equalsSelf() -{ - QFETCH(QJSValue, val); - QBENCHMARK { - val.equals(val); - } -} - -#if 0 -void tst_QJSValue::lessThanSelf_data() -{ - defineStandardTestValues(); -} - -void tst_QJSValue::lessThanSelf() -{ - QFETCH(QJSValue, val); - QBENCHMARK { - val.lessThan(val); - } -} -#endif - -void tst_QJSValue::strictlyEqualsSelf_data() -{ - defineStandardTestValues(); -} - -void tst_QJSValue::strictlyEqualsSelf() -{ - QFETCH(QJSValue, val); - QBENCHMARK { - val.strictlyEquals(val); - } -} - -void tst_QJSValue::isArray_data() -{ - defineStandardTestValues(); -} - -void tst_QJSValue::isArray() -{ - QFETCH(QJSValue, val); - QBENCHMARK { - val.isArray(); - } -} - -void tst_QJSValue::isBool_data() -{ - defineStandardTestValues(); -} - -void tst_QJSValue::isBool() -{ - QFETCH(QJSValue, val); - QBENCHMARK { - val.isBool(); - } -} - -void tst_QJSValue::isDate_data() -{ - defineStandardTestValues(); -} - -void tst_QJSValue::isDate() -{ - QFETCH(QJSValue, val); - QBENCHMARK { - val.isDate(); - } -} - -void tst_QJSValue::isError_data() -{ - defineStandardTestValues(); -} - -void tst_QJSValue::isError() -{ - QFETCH(QJSValue, val); - QBENCHMARK { - val.isError(); - } -} - -void tst_QJSValue::isCallable_data() -{ - defineStandardTestValues(); -} - -void tst_QJSValue::isCallable() -{ - QFETCH(QJSValue, val); - QBENCHMARK { - val.isCallable(); - } -} - -void tst_QJSValue::isNull_data() -{ - defineStandardTestValues(); -} - -void tst_QJSValue::isNull() -{ - QFETCH(QJSValue, val); - QBENCHMARK { - val.isNull(); - } -} - -void tst_QJSValue::isNumber_data() -{ - defineStandardTestValues(); -} - -void tst_QJSValue::isNumber() -{ - QFETCH(QJSValue, val); - QBENCHMARK { - val.isNumber(); - } -} - -void tst_QJSValue::isObject_data() -{ - defineStandardTestValues(); -} - -void tst_QJSValue::isObject() -{ - QFETCH(QJSValue, val); - QBENCHMARK { - val.isObject(); - } -} - -#if 0 -void tst_QJSValue::isQMetaObject_data() -{ - defineStandardTestValues(); -} - -void tst_QJSValue::isQMetaObject() -{ - QFETCH(QJSValue, val); - QBENCHMARK { - val.isQMetaObject(); - } -} -#endif - -void tst_QJSValue::isQObject_data() -{ - defineStandardTestValues(); -} - -void tst_QJSValue::isQObject() -{ - QFETCH(QJSValue, val); - QBENCHMARK { - val.isQObject(); - } -} - -void tst_QJSValue::isRegExp_data() -{ - defineStandardTestValues(); -} - -void tst_QJSValue::isRegExp() -{ - QFETCH(QJSValue, val); - QBENCHMARK { - val.isRegExp(); - } -} - -void tst_QJSValue::isString_data() -{ - defineStandardTestValues(); -} - -void tst_QJSValue::isString() -{ - QFETCH(QJSValue, val); - QBENCHMARK { - val.isString(); - } -} - -void tst_QJSValue::isUndefined_data() -{ - defineStandardTestValues(); -} - -void tst_QJSValue::isUndefined() -{ - QFETCH(QJSValue, val); - QBENCHMARK { - val.isUndefined(); - } -} - -void tst_QJSValue::isVariant_data() -{ - defineStandardTestValues(); -} - -void tst_QJSValue::isVariant() -{ - QFETCH(QJSValue, val); - QBENCHMARK { - val.isVariant(); - } -} - -void tst_QJSValue::toBool_data() -{ - defineStandardTestValues(); -} - -void tst_QJSValue::toBool() -{ - QFETCH(QJSValue, val); - QBENCHMARK { - val.toBool(); - } -} - -void tst_QJSValue::toDateTime_data() -{ - defineStandardTestValues(); -} - -void tst_QJSValue::toDateTime() -{ - QFETCH(QJSValue, val); - QBENCHMARK { - val.toDateTime(); - } -} - -void tst_QJSValue::toInt_data() -{ - defineStandardTestValues(); -} - -void tst_QJSValue::toInt() -{ - QFETCH(QJSValue, val); - QBENCHMARK { - val.toInt(); - } -} - -void tst_QJSValue::toNumber_data() -{ - defineStandardTestValues(); -} - -void tst_QJSValue::toNumber() -{ - QFETCH(QJSValue, val); - QBENCHMARK { - val.toNumber(); - } -} - -void tst_QJSValue::toRegExp_data() -{ - defineStandardTestValues(); -} - -void tst_QJSValue::toRegExp() -{ - QFETCH(QJSValue, val); - QBENCHMARK { - qjsvalue_cast(val); - } -} - -void tst_QJSValue::toString_data() -{ - defineStandardTestValues(); -} - -void tst_QJSValue::toString() -{ - QFETCH(QJSValue, val); - QBENCHMARK { - (void)val.toString(); - } -} - -#if 0 -void tst_QJSValue::toQMetaObject_data() -{ - defineStandardTestValues(); -} - -void tst_QJSValue::toQMetaObject() -{ - QFETCH(QJSValue, val); - QBENCHMARK { - val.toQMetaObject(); - } -} -#endif - -void tst_QJSValue::toQObject_data() -{ - defineStandardTestValues(); -} - -void tst_QJSValue::toQObject() -{ - QFETCH(QJSValue, val); - QBENCHMARK { - (void)val.toQObject(); - } -} - -void tst_QJSValue::toUInt_data() -{ - defineStandardTestValues(); -} - -void tst_QJSValue::toUInt() -{ - QFETCH(QJSValue, val); - QBENCHMARK { - val.toUInt(); - } -} - -void tst_QJSValue::toVariant_data() -{ - defineStandardTestValues(); -} - -void tst_QJSValue::toVariant() -{ - QFETCH(QJSValue, val); - QBENCHMARK { - val.toVariant(); - } -} -void tst_QJSValue::property_data() -{ - QTest::addColumn("propertyName"); - QTest::addColumn("create"); - QTest::newRow("foo") << QString::fromLatin1("foo") << true; - QTest::newRow("hasOwnProperty") << QString::fromLatin1("hasOwnProperty") << false; // From Object.prototype. - QTest::newRow("noSuchProperty") << QString::fromLatin1("noSuchProperty") << false; -} - -void tst_QJSValue::property() -{ - QFETCH(QString, propertyName); - QFETCH(bool, create); - newEngine(); - QJSValue obj = m_engine->newObject(); - if (create) - obj.setProperty(propertyName, 123); - QBENCHMARK { - (void)obj.property(propertyName); - } -} - -#if 0 -void tst_QJSValue::propertyById_data() -{ - property_data(); -} - -void tst_QJSValue::propertyById() -{ - QFETCH(QString, propertyName); - QFETCH(bool, create); - newEngine(); - QJSValue obj = m_engine->newObject(); - QJSString id = m_engine->toStringHandle(propertyName); - if (create) - obj.setProperty(id, 123); - QBENCHMARK { - obj.property(id); - } -} -#endif - -void tst_QJSValue::propertyByIndex() -{ - newEngine(); - QJSValue obj = m_engine->newObject(); - obj.setProperty(123, 456); - QBENCHMARK { - obj.property(123); - } -} - -void tst_QJSValue::setProperty_data() -{ - newEngine(); - QTest::addColumn("propertyName"); - QTest::addColumn("val"); - QTest::newRow("foo") << QString::fromLatin1("foo") << QJSValue(123); - QTest::newRow("bar") << QString::fromLatin1("bar") << m_engine->toScriptValue(123); - QTest::newRow("baz") << QString::fromLatin1("baz") << QJSValue(); - QTest::newRow("toString") << QString::fromLatin1("toString") << m_engine->toScriptValue(true); -} - -void tst_QJSValue::setProperty() -{ - QFETCH(QString, propertyName); - QFETCH(QJSValue, val); - QJSValue obj = m_engine->newObject(); - QBENCHMARK { - obj.setProperty(propertyName, val); - } -} - -#if 0 -void tst_QJSValue::setPropertyById_data() -{ - setProperty_data(); -} - -void tst_QJSValue::setPropertyById() -{ - QFETCH(QString, propertyName); - QFETCH(QJSValue, val); - QJSValue obj = m_engine->newObject(); - QJSString id = m_engine->toStringHandle(propertyName); - QBENCHMARK { - obj.setProperty(id, val); - } -} -#endif - -void tst_QJSValue::setPropertyByIndex() -{ - newEngine(); - QJSValue obj = m_engine->newObject(); - QJSValue val(456); - QBENCHMARK { - obj.setProperty(123, 456); - } -} - -#if 0 -void tst_QJSValue::propertyFlags_data() -{ - property_data(); -} - -void tst_QJSValue::propertyFlags() -{ - QFETCH(QString, propertyName); - QFETCH(bool, create); - newEngine(); - QJSValue obj = m_engine->newObject(); - if (create) - obj.setProperty(propertyName, 123, QJSValue::SkipInEnumeration | QJSValue::ReadOnly); - QBENCHMARK { - (void)obj.propertyFlags(propertyName); - } -} - -void tst_QJSValue::propertyFlagsById_data() -{ - propertyFlags_data(); -} - -void tst_QJSValue::propertyFlagsById() -{ - QFETCH(QString, propertyName); - QFETCH(bool, create); - newEngine(); - QJSValue obj = m_engine->newObject(); - QJSString id = m_engine->toStringHandle(propertyName); - if (create) - obj.setProperty(id, 123, QJSValue::SkipInEnumeration | QJSValue::ReadOnly); - QBENCHMARK { - obj.propertyFlags(id); - } -} -#endif - -void tst_QJSValue::prototype_data() -{ - defineStandardTestValues(); -} - -void tst_QJSValue::prototype() -{ - QFETCH(QJSValue, val); - QBENCHMARK { - val.prototype(); - } -} - -void tst_QJSValue::setPrototype() -{ - newEngine(); - QJSValue obj = m_engine->newObject(); - QJSValue proto = m_engine->newObject(); - QBENCHMARK { - obj.setPrototype(proto); - } -} - -#if 0 -void tst_QJSValue::scriptClass_data() -{ - defineStandardTestValues(); -} - -void tst_QJSValue::scriptClass() -{ - QFETCH(QJSValue, val); - QBENCHMARK { - val.scriptClass(); - } -} - -void tst_QJSValue::setScriptClass() -{ - newEngine(); - QJSValue obj = m_engine->newObject(); - QJSClass cls(m_engine); - QBENCHMARK { - obj.setScriptClass(&cls); - } -} - -void tst_QJSValue::readMetaProperty() -{ - newEngine(); - QJSValue object = m_engine->newQObject(QCoreApplication::instance()); - QJSString propertyName = m_engine->toStringHandle("objectName"); - QBENCHMARK { - for (int i = 0; i < 10000; ++i) - object.property(propertyName); - } -} - -void tst_QJSValue::writeMetaProperty() -{ - newEngine(); - QJSValue object = m_engine->newQObject(QCoreApplication::instance()); - QJSString propertyName = m_engine->toStringHandle("objectName"); - QJSValue value(m_engine, "foo"); - QBENCHMARK { - for (int i = 0; i < 10000; ++i) - object.setProperty(propertyName, value); - } -} -#endif - -void tst_QJSValue::defineStandardTestValues() -{ - newEngine(); - QTest::addColumn("val"); - QTest::newRow("bool") << m_engine->evaluate("true"); - QTest::newRow("number") << m_engine->evaluate("123"); - QTest::newRow("string") << m_engine->evaluate("'ciao'"); - QTest::newRow("null") << m_engine->evaluate("null"); - QTest::newRow("undefined") << m_engine->evaluate("undefined"); - QTest::newRow("object") << m_engine->evaluate("({foo:123})"); - QTest::newRow("array") << m_engine->evaluate("[10,20,30]"); - QTest::newRow("function") << m_engine->evaluate("(function foo(a, b, c) { return a + b + c; })"); - QTest::newRow("date") << m_engine->evaluate("new Date"); - QTest::newRow("regexp") << m_engine->evaluate("new RegExp('foo')"); - QTest::newRow("error") << m_engine->evaluate("new Error"); - - QTest::newRow("qobject") << m_engine->newQObject(this); -#if 0 // no qmetaobject - QTest::newRow("qmetaobject") << m_engine->newQMetaObject(&QJSEngine::staticMetaObject); -#endif - QTest::newRow("variant") << m_engine->toScriptValue(QPoint(10, 20)); -#if 0 // no classess - QTest::newRow("qscriptclassobject") << m_engine->newObject(new QJSClass(m_engine)); -#endif - - QTest::newRow("invalid") << QJSValue(); - QTest::newRow("bool-no-engine") << QJSValue(true); - QTest::newRow("number-no-engine") << QJSValue(123.0); - QTest::newRow("string-no-engine") << QJSValue(QString::fromLatin1("hello")); - QTest::newRow("null-no-engine") << QJSValue(QJSValue::NullValue); - QTest::newRow("undefined-no-engine") << QJSValue(QJSValue::UndefinedValue); -} - -QTEST_MAIN(tst_QJSValue) -#include "tst_qjsvalue.moc" diff --git a/tests/benchmarks/declarative/js/qjsvalueiterator/qjsvalueiterator.pro b/tests/benchmarks/declarative/js/qjsvalueiterator/qjsvalueiterator.pro deleted file mode 100644 index a15ceba9a4..0000000000 --- a/tests/benchmarks/declarative/js/qjsvalueiterator/qjsvalueiterator.pro +++ /dev/null @@ -1,7 +0,0 @@ -CONFIG += testcase -TEMPLATE = app -TARGET = tst_bench_qjsvalueiterator - -SOURCES += tst_qjsvalueiterator.cpp - -QT = core declarative testlib diff --git a/tests/benchmarks/declarative/js/qjsvalueiterator/tst_qjsvalueiterator.cpp b/tests/benchmarks/declarative/js/qjsvalueiterator/tst_qjsvalueiterator.cpp deleted file mode 100644 index f8426fbefb..0000000000 --- a/tests/benchmarks/declarative/js/qjsvalueiterator/tst_qjsvalueiterator.cpp +++ /dev/null @@ -1,309 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include -#include -#include -#include - -class tst_QJSValueIterator : public QObject -{ - Q_OBJECT - -public: - tst_QJSValueIterator(); - virtual ~tst_QJSValueIterator(); - - void dataHelper(); - -private slots: - void init(); - void cleanup(); - - void hasNextAndNext(); - - void constructAndNext_data(); - void constructAndNext(); - - void name_data(); - void name(); -#if 0 // No string handle - void scriptName_data(); - void scriptName(); -#endif - - void value_data(); - void value(); -#if 0 // no setValue - void setValue_data(); - void setValue(); -#endif -#if 0 // no flags - void flags(); -#endif - -#if 0 // no array index - void iterateArrayAndConvertNameToIndex(); -#endif -#if 0 // no setValue - void iterateArrayAndDoubleElements(); -#endif -#if 0 // no remove - void iterateArrayAndRemoveAllElements(); -#endif -}; - -tst_QJSValueIterator::tst_QJSValueIterator() -{ -} - -tst_QJSValueIterator::~tst_QJSValueIterator() -{ -} - -void tst_QJSValueIterator::init() -{ -} - -void tst_QJSValueIterator::cleanup() -{ -} - -void tst_QJSValueIterator::dataHelper() -{ - QTest::addColumn("code"); - QTest::newRow("{ foo: 123 }") << QString::fromLatin1("({ foo: 123 })"); - QTest::newRow("Math") << QString::fromLatin1("Math"); - QTest::newRow("Array.prototype") << QString::fromLatin1("Array.prototype"); - QTest::newRow("Global Object") << QString::fromLatin1("this"); - QTest::newRow("['foo']") << QString::fromLatin1("['foo']"); - QTest::newRow("array with 1000 elements") - << QString::fromLatin1("(function() {" - " var a = new Array;" - " for (i = 0; i < 1000; ++i)" - " a[i] = i;" - " return a;" - "})()"); -} - -void tst_QJSValueIterator::hasNextAndNext() -{ - QJSEngine engine; - QJSValue object = engine.newObject(); - for (int i = 0; i < 2000; ++i) - object.setProperty(i, i); - QBENCHMARK { - for (int i = 0; i < 1000; ++i) { - QJSValueIterator it(object); - while (it.hasNext()) - it.next(); - } - } -} - -void tst_QJSValueIterator::constructAndNext_data() -{ - dataHelper(); -} - -void tst_QJSValueIterator::constructAndNext() -{ - QFETCH(QString, code); - QJSEngine engine; - QJSValue object = engine.evaluate(code); - Q_ASSERT(object.isObject()); - - QBENCHMARK { - for (int i = 0; i < 100; ++i) { - QJSValueIterator it(object); - it.next(); - } - } -} - -void tst_QJSValueIterator::name_data() -{ - dataHelper(); -} - -void tst_QJSValueIterator::name() -{ - QFETCH(QString, code); - QJSEngine engine; - QJSValue object = engine.evaluate(code); - Q_ASSERT(object.isObject()); - - QJSValueIterator it(object); - it.next(); - QBENCHMARK { - for (int i = 0; i < 200000; ++i) - it.name(); - } -} - -#if 0 -void tst_QJSValueIterator::scriptName_data() -{ - dataHelper(); -} - -void tst_QJSValueIterator::scriptName() -{ - QFETCH(QString, code); - QJSEngine engine; - QJSValue object = engine.evaluate(code); - Q_ASSERT(object.isObject()); - - QJSValueIterator it(object); - it.next(); - QBENCHMARK { - for (int i = 0; i < 50000; ++i) - it.scriptName(); - } -} -#endif - -void tst_QJSValueIterator::value_data() -{ - dataHelper(); -} - -void tst_QJSValueIterator::value() -{ - QFETCH(QString, code); - QJSEngine engine; - QJSValue object = engine.evaluate(code); - Q_ASSERT(object.isObject()); - - QJSValueIterator it(object); - it.next(); - QBENCHMARK { - for (int i = 0; i < 50000; ++i) - it.value(); - } -} - -#if 0 -void tst_QJSValueIterator::setValue_data() -{ - dataHelper(); -} - -void tst_QJSValueIterator::setValue() -{ - QFETCH(QString, code); - QJSEngine engine; - QJSValue object = engine.evaluate(code); - Q_ASSERT(object.isObject()); - - QJSValueIterator it(object); - it.next(); - QJSValue newValue(&engine, 456); - QBENCHMARK { - for (int i = 0; i < 50000; ++i) - it.setValue(newValue); - } -} - -void tst_QJSValueIterator::flags() -{ - QJSEngine engine; - QJSValue object = engine.newObject(); - QJSValue::PropertyFlags flags = flags; - object.setProperty("foo", 123, QJSValue::SkipInEnumeration | QJSValue::ReadOnly | QJSValue::Undeletable); - QJSValueIterator it(object); - it.next(); - QBENCHMARK { - for (int i = 0; i < 50000; ++i) - it.flags(); - } -} -#endif - -#if 0 -void tst_QJSValueIterator::iterateArrayAndConvertNameToIndex() -{ - QJSEngine engine; - QJSValue array = engine.newArray(); - for (int i = 0; i < 20000; ++i) - array.setProperty(i, i); - QBENCHMARK { - QJSValueIterator it(array); - while (it.hasNext()) { - it.next(); - it.scriptName().toArrayIndex(); - } - } -} - -void tst_QJSValueIterator::iterateArrayAndDoubleElements() -{ - QJSEngine engine; - QJSValue array = engine.newArray(); - for (int i = 0; i < 20000; ++i) - array.setProperty(i, i); - QBENCHMARK { - QJSValueIterator it(array); - while (it.hasNext()) { - it.next(); - it.setValue(QJSValue(&engine, it.value().toNumber() * 2)); - } - } -} - -void tst_QJSValueIterator::iterateArrayAndRemoveAllElements() -{ - QJSEngine engine; - QJSValue array = engine.newArray(); - for (int i = 0; i < 20000; ++i) - array.setProperty(i, i); - QBENCHMARK { - QJSValueIterator it(array); - while (it.hasNext()) { - it.next(); - it.remove(); - } - } -} -#endif - -QTEST_MAIN(tst_QJSValueIterator) -#include "tst_qjsvalueiterator.moc" diff --git a/tests/benchmarks/declarative/painting/data/63x63.png b/tests/benchmarks/declarative/painting/data/63x63.png deleted file mode 100644 index d9efda8a7a..0000000000 Binary files a/tests/benchmarks/declarative/painting/data/63x63.png and /dev/null differ diff --git a/tests/benchmarks/declarative/painting/data/63x63_opaque.png b/tests/benchmarks/declarative/painting/data/63x63_opaque.png deleted file mode 100644 index d1429080db..0000000000 Binary files a/tests/benchmarks/declarative/painting/data/63x63_opaque.png and /dev/null differ diff --git a/tests/benchmarks/declarative/painting/data/64x64.png b/tests/benchmarks/declarative/painting/data/64x64.png deleted file mode 100644 index b149f33c3d..0000000000 Binary files a/tests/benchmarks/declarative/painting/data/64x64.png and /dev/null differ diff --git a/tests/benchmarks/declarative/painting/data/64x64_opaque.png b/tests/benchmarks/declarative/painting/data/64x64_opaque.png deleted file mode 100644 index 94c07f3b3e..0000000000 Binary files a/tests/benchmarks/declarative/painting/data/64x64_opaque.png and /dev/null differ diff --git a/tests/benchmarks/declarative/painting/paintbenchmark.cpp b/tests/benchmarks/declarative/painting/paintbenchmark.cpp deleted file mode 100644 index 548a9269f6..0000000000 --- a/tests/benchmarks/declarative/painting/paintbenchmark.cpp +++ /dev/null @@ -1,417 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -int iterations = 20; -const int count = 600; -const int lines = 12; -const int spacing = 36; -QSizeF size(1000, 800); -const qreal lineWidth = 1000; -QString strings[lines]; -QGLWidget *testWidget = 0; - -void paint_QTextLayout(QPainter &p, bool useCache) -{ - static bool first = true; - static QTextLayout *textLayout[lines]; - if (first) { - for (int i = 0; i < lines; ++i) { - textLayout[i] = new QTextLayout(strings[i]); - int leading = p.fontMetrics().leading(); - qreal height = 0; - qreal widthUsed = 0; - textLayout[i]->setCacheEnabled(useCache); - textLayout[i]->beginLayout(); - while (1) { - QTextLine line = textLayout[i]->createLine(); - if (!line.isValid()) - break; - - line.setLineWidth(lineWidth); - height += leading; - line.setPosition(QPointF(0, height)); - height += line.height(); - widthUsed = qMax(widthUsed, line.naturalTextWidth()); - } - textLayout[i]->endLayout(); - } - first = false; - } - for (int i = 0; i < count; ++i) { - for (int j = 0; j < lines; ++j) { - textLayout[j]->draw(&p, QPoint(0, j*spacing)); - } - } -} - -void paint_QTextLayout_noCache(QPainter &p) -{ - paint_QTextLayout(p, false); -} - -void paint_QTextLayout_cache(QPainter &p) -{ - paint_QTextLayout(p, true); -} - -void paint_QStaticText(QPainter &p, bool useOptimizations) -{ - static QStaticText *staticText[lines]; - static bool first = true; - if (first) { - for (int i = 0; i < lines; ++i) { - staticText[i] = new QStaticText(strings[i]); - if (useOptimizations) - staticText[i]->setPerformanceHint(QStaticText::AggressiveCaching); - else - staticText[i]->setPerformanceHint(QStaticText::ModerateCaching); - } - first = false; - } - for (int i = 0; i < count; ++i) { - for (int j = 0; j < lines; ++j) { - p.drawStaticText(QPointF(0, 30 + j*spacing), *staticText[j]); - } - } -} - -void paint_QStaticText_noOptimizations(QPainter &p) -{ - paint_QStaticText(p, false); -} - -void paint_QStaticText_optimizations(QPainter &p) -{ - paint_QStaticText(p, true); -} - -void paint_QPixmapCachedText(QPainter &p) -{ - static bool first = true; - static QPixmap cacheText[lines]; - if (first) { - for (int i = 0; i < lines; ++i) { - QRectF trueSize; - trueSize = p.boundingRect(QRectF(QPointF(0,0), size), 0, strings[i]); - cacheText[i] = QPixmap(trueSize.size().toSize()); - cacheText[i].fill(Qt::transparent); - QPainter paint(&cacheText[i]); - paint.setPen(Qt::black); - paint.drawText(QRectF(QPointF(0,0), trueSize.size().toSize()), strings[i]); - } - first = false; - } - for (int i = 0; i < count; i++) { - for (int j = 0; j < lines; ++j) { - p.drawPixmap(0,j*spacing,cacheText[j]); - } - } -} - -void paint_RoundedRect(QPainter &p) -{ - static bool first = true; - if (first) { - if (testWidget) { - QGLFormat format = testWidget->format(); - if (!format.sampleBuffers()) - qWarning() << "Cannot paint antialiased rounded rect without sampleBuffers"; - } - first = false; - } - p.setRenderHint(QPainter::Antialiasing, true); - p.setPen(Qt::black); - p.setBrush(Qt::red); - for (int i = 0; i < count; i++) { - for (int j = 0; j < lines; ++j) { - QSize size((j+1)*50, spacing-1); - p.drawRoundedRect(QRectF(QPointF(0,j*spacing), size), 8, 8); - } - } -} - -void paint_QPixmapCachedRoundedRect(QPainter &p) -{ - static bool first = true; - static QPixmap cacheRect; - if (first) { - const int pw = 0; - const int radius = 8; - cacheRect = QPixmap(radius*2 + 3 + pw*2, radius*2 + 3 + pw*2); - cacheRect.fill(Qt::transparent); - QPainter paint(&cacheRect); - paint.setRenderHint(QPainter::Antialiasing); - paint.setPen(Qt::black); - paint.setBrush(Qt::red); - if (pw%2) - paint.drawRoundedRect(QRectF(qreal(pw)/2+1, qreal(pw)/2+1, cacheRect.width()-(pw+1), cacheRect.height()-(pw+1)), radius, radius); - else - paint.drawRoundedRect(QRectF(qreal(pw)/2, qreal(pw)/2, cacheRect.width()-pw, cacheRect.height()-pw), radius, radius); - - first = false; - } - for (int i = 0; i < count; i++) { - for (int j = 0; j < lines; ++j) { - QSize size((j+1)*50, spacing-1); - - p.setRenderHints(QPainter::Antialiasing | QPainter::SmoothPixmapTransform, true); - - const int pw = 0; - - int xOffset = (cacheRect.width()-1)/2; - int yOffset = (cacheRect.height()-1)/2; - - QMargins margins(xOffset, yOffset, xOffset, yOffset); - QTileRules rules(Qt::StretchTile, Qt::StretchTile); - //NOTE: even though our item may have qreal-based width and height, qDrawBorderPixmap only supports QRects - qDrawBorderPixmap(&p, QRect(-pw/2, j*spacing-pw/2, size.width()+pw, size.height()+pw), margins, cacheRect, cacheRect.rect(), margins, rules); - } - } -} - -void paint_pathCacheRoundedRect(QPainter &p) -{ - static bool first = true; - static QPainterPath path[lines]; - if (first) { - for (int j = 0; j < lines; ++j) { - path[j].addRoundedRect(QRectF(0,0,(j+1)*50, spacing-1), 8, 8); - } - first = false; - } - p.setRenderHint(QPainter::Antialiasing, true); - p.setPen(Qt::black); - p.setBrush(Qt::red); - for (int i = 0; i < count; i++) { - for (int j = 0; j < lines; ++j) { - p.translate(0,j*spacing); - p.drawPath(path[j]); - p.translate(0,-j*spacing); - } - } -} - -void paint_QPixmap63x63_opaque(QPainter &p) -{ - static bool first = true; - static QPixmap pm; - if (first) { - pm.load("data/63x63_opaque.png"); - first = false; - } - for (int i = 0; i < count; i++) { - for (int j = 0; j < lines; ++j) { - p.drawPixmap((i%10) * 64,j*spacing, pm); - } - } -} - -void paint_QPixmap64x64_opaque(QPainter &p) -{ - static bool first = true; - static QPixmap pm; - if (first) { - pm.load("data/64x64_opaque.png"); - first = false; - } - for (int i = 0; i < count; i++) { - for (int j = 0; j < lines; ++j) { - p.drawPixmap((i%10) * 64,j*spacing, pm); - } - } -} - -void paint_QPixmap63x63(QPainter &p) -{ - static bool first = true; - static QPixmap pm; - if (first) { - pm.load("data/63x63.png"); - first = false; - } - for (int i = 0; i < count; i++) { - for (int j = 0; j < lines; ++j) { - p.drawPixmap((i%10) * 64,j*spacing, pm); - } - } -} - -void paint_QPixmap64x64(QPainter &p) -{ - static bool first = true; - static QPixmap pm; - if (first) { - pm.load("data/64x64.png"); - first = false; - } - for (int i = 0; i < count; i++) { - for (int j = 0; j < lines; ++j) { - p.drawPixmap((i%10) * 64,j*spacing, pm); - } - } -} -typedef void(*PaintFunc)(QPainter &); - -struct { - const char *name; - PaintFunc func; -} funcs[] = { - { "QTextLayoutNoCache", &paint_QTextLayout_noCache }, - { "QTextLayoutWithCache", &paint_QTextLayout_cache }, - { "QStaticTextNoBackendOptimizations", &paint_QStaticText_noOptimizations }, - { "QStaticTextWithBackendOptimizations", &paint_QStaticText_optimizations }, - { "CachedText", &paint_QPixmapCachedText }, - { "RoundedRect", &paint_RoundedRect }, - { "CachedRoundedRect", &paint_QPixmapCachedRoundedRect }, - { "PathCacheRoundedRect", &paint_pathCacheRoundedRect }, - { "QPixmap63x63_opaque", &paint_QPixmap63x63_opaque }, - { "QPixmap64x64_opaque", &paint_QPixmap64x64_opaque }, - { "QPixmap63x63", &paint_QPixmap63x63 }, - { "QPixmap64x64", &paint_QPixmap64x64 }, - { 0, 0 } -}; - -PaintFunc testFunc = 0; - -class MyGLWidget : public QGLWidget -{ -public: - MyGLWidget(const QGLFormat &format) : QGLWidget(format), frames(0) { - const char chars[] = "abcd efgh ijkl mnop qrst uvwx yz!$. ABCD 1234"; - int len = strlen(chars); - for (int i = 0; i < lines; ++i) { - for (int j = 0; j < 60; j++) { - strings[i] += QChar(chars[rand() % len]); - } - } - } - - void paintEvent(QPaintEvent *) { - static int last = 0; - static bool firstRun = true; - if (firstRun) { - timer.start(); - firstRun = false; - } else { - int elapsed = timer.elapsed(); - qDebug() << "frame elapsed:" << elapsed - last; - last = elapsed; - } - QPainter p(this); - p.fillRect(rect(), Qt::white); - p.setPen(Qt::black); - QTime drawTimer; - drawTimer.start(); - testFunc(p); - qDebug() << "draw time" << drawTimer.elapsed(); - if (iterations--) - update(); - else - qApp->quit(); - } - - QTime timer; - int frames; -}; - -int main(int argc, char *argv[]) -{ - QApplication app(argc, argv); - - bool sampleBuffers = false; - - for (int i = 1; i < argc; ++i) { - QString arg = argv[i]; - if (arg == "-test") { - arg = argv[++i]; - int j = 0; - while (funcs[j].name) { - if (arg == funcs[j].name) { - testFunc = funcs[j].func; - qDebug() << "Running test" << arg; - break; - } - ++j; - } - } else if (arg == "-iterations") { - arg = argv[++i]; - iterations = arg.toInt(); - } else if (arg == "-sampleBuffers") { - sampleBuffers = true; - } - } - - if (testFunc == 0) { - qDebug() << "Usage: textspeed -test [-sampleBuffers] [-iterations n]"; - qDebug() << "where can be:"; - int j = 0; - while (funcs[j].name) { - qDebug() << " " << funcs[j].name; - ++j; - } - exit(1); - } - - QWidget w; - QGLFormat format = QGLFormat::defaultFormat(); - format.setSampleBuffers(sampleBuffers); - testWidget = new MyGLWidget(format); - testWidget->setAutoFillBackground(false); - QVBoxLayout *layout = new QVBoxLayout(&w); - w.setLayout(layout); - layout->addWidget(testWidget); - w.showFullScreen(); - app.exec(); - - return 0; -} diff --git a/tests/benchmarks/declarative/painting/painting.pro b/tests/benchmarks/declarative/painting/painting.pro deleted file mode 100644 index ff85b5f5f2..0000000000 --- a/tests/benchmarks/declarative/painting/painting.pro +++ /dev/null @@ -1,7 +0,0 @@ -requires(contains(QT_CONFIG,opengl)) - -QT += opengl -CONFIG += console -macx:CONFIG -= app_bundle - -SOURCES += paintbenchmark.cpp diff --git a/tests/benchmarks/declarative/pointers/pointers.pro b/tests/benchmarks/declarative/pointers/pointers.pro deleted file mode 100644 index d4112f94ec..0000000000 --- a/tests/benchmarks/declarative/pointers/pointers.pro +++ /dev/null @@ -1,8 +0,0 @@ -CONFIG += testcase -QT += declarative testlib -TEMPLATE = app -TARGET = tst_pointers -macx:CONFIG -= app_bundle - -SOURCES += tst_pointers.cpp - diff --git a/tests/benchmarks/declarative/pointers/tst_pointers.cpp b/tests/benchmarks/declarative/pointers/tst_pointers.cpp deleted file mode 100644 index ce81c7f5c9..0000000000 --- a/tests/benchmarks/declarative/pointers/tst_pointers.cpp +++ /dev/null @@ -1,77 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include -#include "private/qdeclarativeguard_p.h" -#include - -class tst_pointers : public QObject -{ - Q_OBJECT - -public: - tst_pointers() {} - -private slots: - void qmlguard(); - void weakPointer(); -}; - -void tst_pointers::qmlguard() -{ - QObject *obj = new QObject; - QBENCHMARK { - QDeclarativeGuard guardedObject; - guardedObject = obj; - } -} - -void tst_pointers::weakPointer() -{ - QObject *obj = new QObject; - QBENCHMARK { - QWeakPointer guardedObject; - guardedObject = obj; - } -} - -QTEST_MAIN(tst_pointers) -#include "tst_pointers.moc" diff --git a/tests/benchmarks/declarative/qdeclarativecomponent/data/myqmlobject.qml b/tests/benchmarks/declarative/qdeclarativecomponent/data/myqmlobject.qml deleted file mode 100644 index a7db476f70..0000000000 --- a/tests/benchmarks/declarative/qdeclarativecomponent/data/myqmlobject.qml +++ /dev/null @@ -1,44 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import Qt.test 4.6 - -MyQmlObject {} diff --git a/tests/benchmarks/declarative/qdeclarativecomponent/data/myqmlobject_binding.qml b/tests/benchmarks/declarative/qdeclarativecomponent/data/myqmlobject_binding.qml deleted file mode 100644 index a8add75aee..0000000000 --- a/tests/benchmarks/declarative/qdeclarativecomponent/data/myqmlobject_binding.qml +++ /dev/null @@ -1,47 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import Qt.test 4.6 - -MyQmlObject { - result: value -} - diff --git a/tests/benchmarks/declarative/qdeclarativecomponent/data/object.qml b/tests/benchmarks/declarative/qdeclarativecomponent/data/object.qml deleted file mode 100644 index 91371c80d6..0000000000 --- a/tests/benchmarks/declarative/qdeclarativecomponent/data/object.qml +++ /dev/null @@ -1,44 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -QtObject {} diff --git a/tests/benchmarks/declarative/qdeclarativecomponent/data/object_id.qml b/tests/benchmarks/declarative/qdeclarativecomponent/data/object_id.qml deleted file mode 100644 index 240f27b4ac..0000000000 --- a/tests/benchmarks/declarative/qdeclarativecomponent/data/object_id.qml +++ /dev/null @@ -1,47 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -QtObject { - id: blah -} - diff --git a/tests/benchmarks/declarative/qdeclarativecomponent/data/samegame/BoomBlock.qml b/tests/benchmarks/declarative/qdeclarativecomponent/data/samegame/BoomBlock.qml deleted file mode 100644 index dbe9e99260..0000000000 --- a/tests/benchmarks/declarative/qdeclarativecomponent/data/samegame/BoomBlock.qml +++ /dev/null @@ -1,112 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 -import QtQuick.Particles 2.0 - -Item { - id: block - property bool dying: false - property bool spawned: false - property int type: 0 - property ParticleSystem particleSystem - - Behavior on x { - enabled: spawned; - SpringAnimation{ spring: 2; damping: 0.2 } - } - Behavior on y { - SpringAnimation{ spring: 2; damping: 0.2 } - } - - Image { - id: img - source: { - if(type == 0){ - "pics/redStone.png"; - } else if(type == 1) { - "pics/blueStone.png"; - } else { - "pics/greenStone.png"; - } - } - opacity: 0 - Behavior on opacity { NumberAnimation { duration: 200 } } - anchors.fill: parent - } - Emitter { - id: particles - system: particleSystem - group: { - if(type == 0){ - "red"; - } else if (type == 1) { - "blue"; - } else { - "green"; - } - } - anchors.fill: parent - - speed: TargetDirection{targetX: block.width/2; targetY: block.height/2; magnitude: -60; magnitudeVariation: 60} - shape: EllipseShape{fill:true} - enabled: false; - lifeSpan: 700; lifeSpanVariation: 100 - emitRate: 1000 - maximumEmitted: 100 //only fires 0.1s bursts (still 2x old number) - size: 28 - endSize: 14 - } - - states: [ - State { - name: "AliveState"; when: spawned == true && dying == false - PropertyChanges { target: img; opacity: 1 } - }, - - State { - name: "DeathState"; when: dying == true - StateChangeScript { script: particles.pulse(0.1); } - PropertyChanges { target: img; opacity: 0 } - StateChangeScript { script: block.destroy(1000); } - } - ] -} diff --git a/tests/benchmarks/declarative/qdeclarativecomponent/data/samegame/pics/blueStone.png b/tests/benchmarks/declarative/qdeclarativecomponent/data/samegame/pics/blueStone.png deleted file mode 100644 index 20e43c75b6..0000000000 Binary files a/tests/benchmarks/declarative/qdeclarativecomponent/data/samegame/pics/blueStone.png and /dev/null differ diff --git a/tests/benchmarks/declarative/qdeclarativecomponent/data/samegame/pics/greenStone.png b/tests/benchmarks/declarative/qdeclarativecomponent/data/samegame/pics/greenStone.png deleted file mode 100644 index b568a1900c..0000000000 Binary files a/tests/benchmarks/declarative/qdeclarativecomponent/data/samegame/pics/greenStone.png and /dev/null differ diff --git a/tests/benchmarks/declarative/qdeclarativecomponent/data/samegame/pics/redStone.png b/tests/benchmarks/declarative/qdeclarativecomponent/data/samegame/pics/redStone.png deleted file mode 100644 index 36b09a2686..0000000000 Binary files a/tests/benchmarks/declarative/qdeclarativecomponent/data/samegame/pics/redStone.png and /dev/null differ diff --git a/tests/benchmarks/declarative/qdeclarativecomponent/data/samegame/pics/yellowStone.png b/tests/benchmarks/declarative/qdeclarativecomponent/data/samegame/pics/yellowStone.png deleted file mode 100644 index b1ce76212c..0000000000 Binary files a/tests/benchmarks/declarative/qdeclarativecomponent/data/samegame/pics/yellowStone.png and /dev/null differ diff --git a/tests/benchmarks/declarative/qdeclarativecomponent/data/synthesized_properties.2.qml b/tests/benchmarks/declarative/qdeclarativecomponent/data/synthesized_properties.2.qml deleted file mode 100644 index 3a86c48af1..0000000000 --- a/tests/benchmarks/declarative/qdeclarativecomponent/data/synthesized_properties.2.qml +++ /dev/null @@ -1,56 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -QtObject { - property int a - property bool b - property double c - property real d - property string e - property url f - property color g - property date h - property variant i - property variant j -} - diff --git a/tests/benchmarks/declarative/qdeclarativecomponent/data/synthesized_properties.qml b/tests/benchmarks/declarative/qdeclarativecomponent/data/synthesized_properties.qml deleted file mode 100644 index 9d4dc03c82..0000000000 --- a/tests/benchmarks/declarative/qdeclarativecomponent/data/synthesized_properties.qml +++ /dev/null @@ -1,46 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -QtObject { - property int a -} diff --git a/tests/benchmarks/declarative/qdeclarativecomponent/qdeclarativecomponent.pro b/tests/benchmarks/declarative/qdeclarativecomponent/qdeclarativecomponent.pro deleted file mode 100644 index 0d415db8ba..0000000000 --- a/tests/benchmarks/declarative/qdeclarativecomponent/qdeclarativecomponent.pro +++ /dev/null @@ -1,11 +0,0 @@ -CONFIG += testcase -TEMPLATE = app -TARGET = tst_qdeclarativecomponent -QT += declarative testlib -macx:CONFIG -= app_bundle - -SOURCES += tst_qdeclarativecomponent.cpp testtypes.cpp -HEADERS += testtypes.h - -# Define SRCDIR equal to test's source directory -DEFINES += SRCDIR=\\\"$$PWD\\\" diff --git a/tests/benchmarks/declarative/qdeclarativecomponent/testtypes.cpp b/tests/benchmarks/declarative/qdeclarativecomponent/testtypes.cpp deleted file mode 100644 index 4d2932aa79..0000000000 --- a/tests/benchmarks/declarative/qdeclarativecomponent/testtypes.cpp +++ /dev/null @@ -1,46 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include "testtypes.h" - -void registerTypes() -{ - qmlRegisterType("Qt.test", 4, 6, "MyQmlObject"); -} diff --git a/tests/benchmarks/declarative/qdeclarativecomponent/testtypes.h b/tests/benchmarks/declarative/qdeclarativecomponent/testtypes.h deleted file mode 100644 index 1c99842e33..0000000000 --- a/tests/benchmarks/declarative/qdeclarativecomponent/testtypes.h +++ /dev/null @@ -1,83 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#ifndef TESTTYPES_H -#define TESTTYPES_H - -#include -#include - -class MyQmlObject : public QObject -{ - Q_OBJECT - Q_PROPERTY(int result READ result WRITE setResult) - Q_PROPERTY(int value READ value WRITE setValue NOTIFY valueChanged) - Q_PROPERTY(MyQmlObject *object READ object WRITE setObject NOTIFY objectChanged) - Q_PROPERTY(QDeclarativeListProperty data READ data) - Q_CLASSINFO("DefaultProperty", "data") -public: - MyQmlObject() : m_result(0), m_value(0), m_object(0) {} - - int result() const { return m_result; } - void setResult(int r) { m_result = r; } - - int value() const { return m_value; } - void setValue(int v) { m_value = v; emit valueChanged(); } - - QDeclarativeListProperty data() { return QDeclarativeListProperty(this, m_data); } - - MyQmlObject *object() const { return m_object; } - void setObject(MyQmlObject *o) { m_object = o; emit objectChanged(); } - -signals: - void valueChanged(); - void objectChanged(); - -private: - QList m_data; - int m_result; - int m_value; - MyQmlObject *m_object; -}; -QML_DECLARE_TYPE(MyQmlObject); - -void registerTypes(); - -#endif // TESTTYPES_H diff --git a/tests/benchmarks/declarative/qdeclarativecomponent/tst_qdeclarativecomponent.cpp b/tests/benchmarks/declarative/qdeclarativecomponent/tst_qdeclarativecomponent.cpp deleted file mode 100644 index d20126b132..0000000000 --- a/tests/benchmarks/declarative/qdeclarativecomponent/tst_qdeclarativecomponent.cpp +++ /dev/null @@ -1,116 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include -#include -#include -#include -#include -#include "testtypes.h" - -class tst_qmlcomponent : public QObject -{ - Q_OBJECT - -public: - tst_qmlcomponent(); - virtual ~tst_qmlcomponent(); - -public slots: - void initTestCase(); - void cleanupTestCase(); - -private slots: - void creation_data(); - void creation(); - -private: - QDeclarativeEngine engine; -}; - -tst_qmlcomponent::tst_qmlcomponent() -{ -} - -tst_qmlcomponent::~tst_qmlcomponent() -{ -} - -void tst_qmlcomponent::initTestCase() -{ - registerTypes(); -} - -void tst_qmlcomponent::cleanupTestCase() -{ -} - -void tst_qmlcomponent::creation_data() -{ - QTest::addColumn("file"); - - QTest::newRow("Object") << SRCDIR "/data/object.qml"; - QTest::newRow("Object - Id") << SRCDIR "/data/object_id.qml"; - QTest::newRow("MyQmlObject") << SRCDIR "/data/myqmlobject.qml"; - QTest::newRow("MyQmlObject: basic binding") << SRCDIR "/data/myqmlobject_binding.qml"; - QTest::newRow("Synthesized properties") << SRCDIR "/data/synthesized_properties.qml"; - QTest::newRow("Synthesized properties.2") << SRCDIR "/data/synthesized_properties.2.qml"; - QTest::newRow("SameGame - BoomBlock") << SRCDIR "/data/samegame/BoomBlock.qml"; -} - -void tst_qmlcomponent::creation() -{ - QFETCH(QString, file); - - QDeclarativeComponent c(&engine, file); - QVERIFY(c.isReady()); - - QObject *obj = c.create(); - delete obj; - - QBENCHMARK { - QObject *obj = c.create(); - delete obj; - } -} - -QTEST_MAIN(tst_qmlcomponent) -#include "tst_qdeclarativecomponent.moc" diff --git a/tests/benchmarks/declarative/qdeclarativedebugtrace/qdeclarativedebugtrace.pro b/tests/benchmarks/declarative/qdeclarativedebugtrace/qdeclarativedebugtrace.pro deleted file mode 100644 index 6f2712adec..0000000000 --- a/tests/benchmarks/declarative/qdeclarativedebugtrace/qdeclarativedebugtrace.pro +++ /dev/null @@ -1,8 +0,0 @@ -CONFIG += testcase -QT += declarative testlib -TEMPLATE = app -TARGET = tst_qdeclarativedebugtrace -macx:CONFIG -= app_bundle - -SOURCES += tst_qdeclarativedebugtrace.cpp - diff --git a/tests/benchmarks/declarative/qdeclarativedebugtrace/tst_qdeclarativedebugtrace.cpp b/tests/benchmarks/declarative/qdeclarativedebugtrace/tst_qdeclarativedebugtrace.cpp deleted file mode 100644 index a8ac44a008..0000000000 --- a/tests/benchmarks/declarative/qdeclarativedebugtrace/tst_qdeclarativedebugtrace.cpp +++ /dev/null @@ -1,100 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include -#include -#include - -class tst_qdeclarativedebugtrace : public QObject -{ - Q_OBJECT - -public: - tst_qdeclarativedebugtrace() {} - -private slots: - void all(); - void startElapsed(); - void doubleElapsed(); - void trace(); -}; - -void tst_qdeclarativedebugtrace::all() -{ - QBENCHMARK { - QElapsedTimer t; - t.start(); - t.nsecsElapsed(); - } -} - -void tst_qdeclarativedebugtrace::startElapsed() -{ - QElapsedTimer t; - QBENCHMARK { - t.start(); - t.nsecsElapsed(); - } -} - -void tst_qdeclarativedebugtrace::doubleElapsed() -{ - QElapsedTimer t; - t.start(); - QBENCHMARK { - t.nsecsElapsed(); - t.nsecsElapsed(); - } -} - -void tst_qdeclarativedebugtrace::trace() -{ - QString s("A decent sized string of text here."); - QBENCHMARK { - QByteArray data; - QDataStream ds(&data, QIODevice::WriteOnly); - ds << (qint64)100 << (int)5 << (int)5 << s; - } -} - -QTEST_MAIN(tst_qdeclarativedebugtrace) - -#include "tst_qdeclarativedebugtrace.moc" diff --git a/tests/benchmarks/declarative/qdeclarativeimage/image.png b/tests/benchmarks/declarative/qdeclarativeimage/image.png deleted file mode 100644 index 623d36233d..0000000000 Binary files a/tests/benchmarks/declarative/qdeclarativeimage/image.png and /dev/null differ diff --git a/tests/benchmarks/declarative/qdeclarativeimage/qdeclarativeimage.pro b/tests/benchmarks/declarative/qdeclarativeimage/qdeclarativeimage.pro deleted file mode 100644 index 6a46e8f40c..0000000000 --- a/tests/benchmarks/declarative/qdeclarativeimage/qdeclarativeimage.pro +++ /dev/null @@ -1,11 +0,0 @@ -CONFIG += testcase -TEMPLATE = app -TARGET = tst_qdeclarativeimage -QT += declarative testlib -macx:CONFIG -= app_bundle -CONFIG += release - -SOURCES += tst_qdeclarativeimage.cpp - -DEFINES += SRCDIR=\\\"$$PWD\\\" - diff --git a/tests/benchmarks/declarative/qdeclarativeimage/tst_qdeclarativeimage.cpp b/tests/benchmarks/declarative/qdeclarativeimage/tst_qdeclarativeimage.cpp deleted file mode 100644 index fcebd35671..0000000000 --- a/tests/benchmarks/declarative/qdeclarativeimage/tst_qdeclarativeimage.cpp +++ /dev/null @@ -1,108 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include -#include -#include -#include - -class tst_qmlgraphicsimage : public QObject -{ - Q_OBJECT -public: - tst_qmlgraphicsimage() {} - -private slots: - void qmlgraphicsimage(); - void qmlgraphicsimage_file(); - void qmlgraphicsimage_url(); - -private: - QDeclarativeEngine engine; -}; - -void tst_qmlgraphicsimage::qmlgraphicsimage() -{ - int x = 0; - QUrl url(SRCDIR "/image.png"); - QBENCHMARK { - QUrl url2("http://localhost/image" + QString::number(x++) + ".png"); - QDeclarativeImage *image = new QDeclarativeImage; - QDeclarativeEngine::setContextForObject(image, engine.rootContext()); - delete image; - } -} - -void tst_qmlgraphicsimage::qmlgraphicsimage_file() -{ - int x = 0; - QUrl url(SRCDIR "/image.png"); - //get rid of initialization effects - { - QDeclarativeImage *image = new QDeclarativeImage; - QDeclarativeEngine::setContextForObject(image, engine.rootContext()); - image->setSource(url); - } - QBENCHMARK { - QUrl url2("http://localhost/image" + QString::number(x++) + ".png"); - QDeclarativeImage *image = new QDeclarativeImage; - QDeclarativeEngine::setContextForObject(image, engine.rootContext()); - image->setSource(url); - delete image; - } -} - -void tst_qmlgraphicsimage::qmlgraphicsimage_url() -{ - int x = 0; - QUrl url(SRCDIR "/image.png"); - QBENCHMARK { - QUrl url2("http://localhost/image" + QString::number(x++) + ".png"); - QDeclarativeImage *image = new QDeclarativeImage; - QDeclarativeEngine::setContextForObject(image, engine.rootContext()); - image->setSource(url2); - delete image; - } -} - -QTEST_MAIN(tst_qmlgraphicsimage) - -#include "tst_qdeclarativeimage.moc" diff --git a/tests/benchmarks/declarative/qdeclarativemetaproperty/data/object.qml b/tests/benchmarks/declarative/qdeclarativemetaproperty/data/object.qml deleted file mode 100644 index c386df72a3..0000000000 --- a/tests/benchmarks/declarative/qdeclarativemetaproperty/data/object.qml +++ /dev/null @@ -1,44 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -Item {} diff --git a/tests/benchmarks/declarative/qdeclarativemetaproperty/data/synthesized_object.qml b/tests/benchmarks/declarative/qdeclarativemetaproperty/data/synthesized_object.qml deleted file mode 100644 index 6eec87aea1..0000000000 --- a/tests/benchmarks/declarative/qdeclarativemetaproperty/data/synthesized_object.qml +++ /dev/null @@ -1,47 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -Item { - property int blah -} - diff --git a/tests/benchmarks/declarative/qdeclarativemetaproperty/qdeclarativemetaproperty.pro b/tests/benchmarks/declarative/qdeclarativemetaproperty/qdeclarativemetaproperty.pro deleted file mode 100644 index 1ac0bb240a..0000000000 --- a/tests/benchmarks/declarative/qdeclarativemetaproperty/qdeclarativemetaproperty.pro +++ /dev/null @@ -1,10 +0,0 @@ -CONFIG += testcase -TEMPLATE = app -TARGET = tst_qdeclarativemetaproperty -QT += declarative testlib -macx:CONFIG -= app_bundle - -SOURCES += tst_qdeclarativemetaproperty.cpp - -# Define SRCDIR equal to test's source directory -DEFINES += SRCDIR=\\\"$$PWD\\\" diff --git a/tests/benchmarks/declarative/qdeclarativemetaproperty/tst_qdeclarativemetaproperty.cpp b/tests/benchmarks/declarative/qdeclarativemetaproperty/tst_qdeclarativemetaproperty.cpp deleted file mode 100644 index 7726c051ac..0000000000 --- a/tests/benchmarks/declarative/qdeclarativemetaproperty/tst_qdeclarativemetaproperty.cpp +++ /dev/null @@ -1,110 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include -#include -#include -#include -#include -#include - -class tst_qmlmetaproperty : public QObject -{ - Q_OBJECT - -public: - tst_qmlmetaproperty(); - virtual ~tst_qmlmetaproperty(); - -public slots: - void init(); - void cleanup(); - -private slots: - void lookup_data(); - void lookup(); - -private: - QDeclarativeEngine engine; -}; - -tst_qmlmetaproperty::tst_qmlmetaproperty() -{ -} - -tst_qmlmetaproperty::~tst_qmlmetaproperty() -{ -} - -void tst_qmlmetaproperty::init() -{ -} - -void tst_qmlmetaproperty::cleanup() -{ -} - -void tst_qmlmetaproperty::lookup_data() -{ - QTest::addColumn("file"); - - QTest::newRow("Simple Object") << SRCDIR "/data/object.qml"; - QTest::newRow("Synthesized Object") << SRCDIR "/data/synthesized_object.qml"; -} - -void tst_qmlmetaproperty::lookup() -{ - QFETCH(QString, file); - - QDeclarativeComponent c(&engine, file); - QVERIFY(c.isReady()); - - QObject *obj = c.create(); - - QBENCHMARK { - QDeclarativeProperty p(obj, "x"); - } - - delete obj; -} - -QTEST_MAIN(tst_qmlmetaproperty) -#include "tst_qdeclarativemetaproperty.moc" diff --git a/tests/benchmarks/declarative/qmltime/example.qml b/tests/benchmarks/declarative/qmltime/example.qml deleted file mode 100644 index f608963930..0000000000 --- a/tests/benchmarks/declarative/qmltime/example.qml +++ /dev/null @@ -1,55 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 -import QmlTime 1.0 as QmlTime - -Item { - - property string name: "Bob Smith" - - QmlTime.Timer { - component: Item { - Text { text: name } - } - } -} - diff --git a/tests/benchmarks/declarative/qmltime/qmltime.cpp b/tests/benchmarks/declarative/qmltime/qmltime.cpp deleted file mode 100644 index f33b9205e7..0000000000 --- a/tests/benchmarks/declarative/qmltime/qmltime.cpp +++ /dev/null @@ -1,283 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include -#include -#include -#include -#include -#include -#include -#include - -class Timer : public QObject -{ - Q_OBJECT - Q_PROPERTY(QDeclarativeComponent *component READ component WRITE setComponent) - -public: - Timer(); - - QDeclarativeComponent *component() const; - void setComponent(QDeclarativeComponent *); - - static Timer *timerInstance(); - - void run(uint); - - bool willParent() const; - void setWillParent(bool p); - -private: - void runTest(QDeclarativeContext *, uint); - - QDeclarativeComponent *m_component; - static Timer *m_timer; - - bool m_willparent; - QGraphicsScene m_scene; - QGraphicsRectItem m_item; -}; -QML_DECLARE_TYPE(Timer); - -Timer *Timer::m_timer = 0; - -Timer::Timer() -: m_component(0), m_willparent(false) -{ - if (m_timer) - qWarning("Timer: Timer already registered"); - m_timer = this; - - m_scene.setItemIndexMethod(QGraphicsScene::NoIndex); - m_scene.addItem(&m_item); -} - -QDeclarativeComponent *Timer::component() const -{ - return m_component; -} - -void Timer::setComponent(QDeclarativeComponent *c) -{ - m_component = c; -} - -Timer *Timer::timerInstance() -{ - return m_timer; -} - -void Timer::run(uint iterations) -{ - QDeclarativeContext context(qmlContext(this)); - - QObject *o = m_component->create(&context); - QGraphicsObject *go = qobject_cast(o); - if (m_willparent && go) - go->setParentItem(&m_item); - delete o; - - runTest(&context, iterations); -} - -bool Timer::willParent() const -{ - return m_willparent; -} - -void Timer::setWillParent(bool p) -{ - m_willparent = p; -} - -void Timer::runTest(QDeclarativeContext *context, uint iterations) -{ - QTime t; - t.start(); - for (uint ii = 0; ii < iterations; ++ii) { - QObject *o = m_component->create(context); - QGraphicsObject *go = qobject_cast(o); - if (m_willparent && go) - go->setParentItem(&m_item); - delete o; - } - - int e = t.elapsed(); - - qWarning() << "Total:" << e << "ms, Per iteration:" << qreal(e) / qreal(iterations) << "ms"; - -} - -void usage(const char *name) -{ - qWarning("Usage: %s [-iterations ] [-parent] \n", name); - - qWarning("qmltime is a tool for benchmarking the runtime cost of instantiating\n" - "a QML component. It is typically run as follows:\n" - "\n" - "%s path/to/benchmark.qml\n" - "\n" - "If the -parent option is specified, the component being measured will also\n" - "be parented to an item already in the scene.\n" - "\n" - "If the -iterations option is specified, the benchmark will run the specified\n" - "number of iterations. If -iterations is not specified, 1024 iterations\n" - "are performed.\n" - "\n" - "qmltime expects the file to be benchmarked to contain a certain structure.\n" - "Specifically, it requires the presence of a QmlTime.Timer element. For example,\n" - "say we wanted to benchmark the following list delegate:\n" - "\n" - "Rectangle {\n" - " color: \"green\"\n" - " width: 400; height: 100\n" - " Text {\n" - " anchors.centerIn: parent\n" - " text: name\n" - " }\n" - "}\n" - "\n" - "we would create a benchmark file that looks like this:\n" - "\n" - "import QtQuick 2.0\n" - "import QmlTime 1.0 as QmlTime\n" - "\n" - "Item {\n" - "\n" - " property string name: \"Bob Smith\"\n" - "\n" - " QmlTime.Timer {\n" - " component: Rectangle {\n" - " color: \"green\"\n" - " width: 400; height: 100\n" - " Text {\n" - " anchors.centerIn: parent\n" - " text: name\n" - " }\n" - " }\n" - " }\n" - "}\n" - "\n" - "The outer Item functions as a dummy data provider for any additional\n" - "data required by the bindings in the component being benchmarked (in the\n" - "example above we provide a \"name\" property).\n" - "\n" - "When started, the component is instantiated once before running\n" - "the benchmark, which means that the reported time does not include\n" - "compile time (as the results of compilation are cached internally).\n" - "In this sense the times reported by qmltime best correspond to the\n" - "costs associated with delegate creation in the view classes, where the\n" - "same delegate is instantiated over and over. Conversely, it is not a\n" - "good approximation for e.g. Loader, which typically only instantiates\n" - "an element once (and so for Loader the compile time is very relevant\n" - "to the overall cost).", name); - - exit(-1); -} - -int main(int argc, char ** argv) -{ - QApplication app(argc, argv); - - qmlRegisterType("QmlTime", 1, 0, "Timer"); - - uint iterations = 1024; - QString filename; - bool willParent = false; - - for (int ii = 1; ii < argc; ++ii) { - QByteArray arg(argv[ii]); - - if (arg == "-iterations") { - if (ii + 1 < argc) { - ++ii; - QByteArray its(argv[ii]); - bool ok = false; - iterations = its.toUInt(&ok); - if (!ok) - usage(argv[0]); - } else { - usage(argv[0]); - } - } else if (arg == "-parent") { - willParent = true; - } else if (arg == "-help") { - usage(argv[0]); - } else { - filename = QLatin1String(argv[ii]); - } - } - - if (filename.isEmpty()) - usage(argv[0]); - - QDeclarativeEngine engine; - QDeclarativeComponent component(&engine, filename); - if (component.isError()) { - qWarning() << component.errors(); - return -1; - } - - QObject *obj = component.create(); - if (!obj) { - qWarning() << component.errors(); - return -1; - } - - Timer *timer = Timer::timerInstance(); - if (!timer) { - qWarning() << "A Tester.Timer instance is required."; - return -1; - } - - timer->setWillParent(willParent); - - if (!timer->component()) { - qWarning() << "The timer has no component"; - return -1; - } - - timer->run(iterations); - - return 0; -} - -#include "qmltime.moc" diff --git a/tests/benchmarks/declarative/qmltime/qmltime.pro b/tests/benchmarks/declarative/qmltime/qmltime.pro deleted file mode 100644 index e1948981bf..0000000000 --- a/tests/benchmarks/declarative/qmltime/qmltime.pro +++ /dev/null @@ -1,8 +0,0 @@ -CONFIG += testcase -TEMPLATE = app -TARGET = qmltime -QT += declarative widgets testlib -macx:CONFIG -= app_bundle - -SOURCES += qmltime.cpp - diff --git a/tests/benchmarks/declarative/qmltime/tests/anchors/empty.qml b/tests/benchmarks/declarative/qmltime/tests/anchors/empty.qml deleted file mode 100644 index b08b43268c..0000000000 --- a/tests/benchmarks/declarative/qmltime/tests/anchors/empty.qml +++ /dev/null @@ -1,75 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 -import QmlTime 1.0 as QmlTime - -Item { - - QmlTime.Timer { - component: Component { - Item { - Item { - anchors.leftMargin: 0 - } - Item { - anchors.leftMargin: 0 - } - Item { - anchors.leftMargin: 0 - } - Item { - anchors.leftMargin: 0 - } - Item { - anchors.leftMargin: 0 - } - Item { - anchors.leftMargin: 0 - } - Item { - anchors.leftMargin: 0 - } - } - } - } -} - diff --git a/tests/benchmarks/declarative/qmltime/tests/anchors/fill.qml b/tests/benchmarks/declarative/qmltime/tests/anchors/fill.qml deleted file mode 100644 index a173050427..0000000000 --- a/tests/benchmarks/declarative/qmltime/tests/anchors/fill.qml +++ /dev/null @@ -1,82 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 -import QmlTime 1.0 as QmlTime - -Item { - - QmlTime.Timer { - component: Component { - Item { - Item { - anchors.fill: parent - anchors.leftMargin: 0 - } - Item { - anchors.fill: parent - anchors.leftMargin: 0 - } - Item { - anchors.fill: parent - anchors.leftMargin: 0 - } - Item { - anchors.fill: parent - anchors.leftMargin: 0 - } - Item { - anchors.fill: parent - anchors.leftMargin: 0 - } - Item { - anchors.fill: parent - anchors.leftMargin: 0 - } - Item { - anchors.fill: parent - anchors.leftMargin: 0 - } - } - } - } -} - diff --git a/tests/benchmarks/declarative/qmltime/tests/anchors/null.qml b/tests/benchmarks/declarative/qmltime/tests/anchors/null.qml deleted file mode 100644 index ea01839e14..0000000000 --- a/tests/benchmarks/declarative/qmltime/tests/anchors/null.qml +++ /dev/null @@ -1,68 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 -import QmlTime 1.0 as QmlTime - -Item { - - QmlTime.Timer { - component: Component { - Item { - Item { - } - Item { - } - Item { - } - Item { - } - Item { - } - Item { - } - Item { - } - } - } - } -} - diff --git a/tests/benchmarks/declarative/qmltime/tests/animation/large.qml b/tests/benchmarks/declarative/qmltime/tests/animation/large.qml deleted file mode 100644 index b58de4955b..0000000000 --- a/tests/benchmarks/declarative/qmltime/tests/animation/large.qml +++ /dev/null @@ -1,82 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 -import QmlTime 1.0 as QmlTime - -Item { - - QmlTime.Timer { - component: Component { - ParallelAnimation { - NumberAnimation { duration: 500 } - NumberAnimation { duration: 4000; } - NumberAnimation { duration: 2000; easing.type: "OutBack"} - ColorAnimation { duration: 3000} - SequentialAnimation { - PauseAnimation { duration: 1000 } - ScriptAction { script: doSomething(); } - PauseAnimation { duration: 800 } - ScriptAction { script: doSomethingElse(); } - PauseAnimation { duration: 800 } - ParallelAnimation { - NumberAnimation { duration: 200;} - SequentialAnimation { - PauseAnimation { duration: 200} - ParallelAnimation { - NumberAnimation { duration: 300;} - NumberAnimation { duration: 300;} - } - NumberAnimation { from: 0; to: 1; duration: 500 } - PauseAnimation { duration: 200 } - NumberAnimation { from: 1; to: 0; duration: 500 } - } - SequentialAnimation { - PauseAnimation { duration: 150} - NumberAnimation { duration: 300; easing.type: "OutBounce" } - } - } - } - } - } - } - -} diff --git a/tests/benchmarks/declarative/qmltime/tests/animation/largeNoProps.qml b/tests/benchmarks/declarative/qmltime/tests/animation/largeNoProps.qml deleted file mode 100644 index fbe4acb8d3..0000000000 --- a/tests/benchmarks/declarative/qmltime/tests/animation/largeNoProps.qml +++ /dev/null @@ -1,82 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 -import QmlTime 1.0 as QmlTime - -Item { - - QmlTime.Timer { - component: Component { - ParallelAnimation { - NumberAnimation { } - NumberAnimation { } - NumberAnimation { } - ColorAnimation { } - SequentialAnimation { - PauseAnimation { } - ScriptAction { } - PauseAnimation { } - ScriptAction { } - PauseAnimation { } - ParallelAnimation { - NumberAnimation { } - SequentialAnimation { - PauseAnimation { } - ParallelAnimation { - NumberAnimation { } - NumberAnimation { } - } - NumberAnimation { } - PauseAnimation { } - NumberAnimation { } - } - SequentialAnimation { - PauseAnimation { } - NumberAnimation { } - } - } - } - } - } - } - -} diff --git a/tests/benchmarks/declarative/qmltime/tests/item_creation/children.qml b/tests/benchmarks/declarative/qmltime/tests/item_creation/children.qml deleted file mode 100644 index 85698d6bf6..0000000000 --- a/tests/benchmarks/declarative/qmltime/tests/item_creation/children.qml +++ /dev/null @@ -1,75 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 -import QmlTime 1.0 as QmlTime - -Item { - - QmlTime.Timer { - component: Component { - Item { - children: [ - Rectangle { }, - Rectangle { }, - Item { }, - Image { }, - Text { }, - Item { }, - Item { }, - Image { }, - Image { }, - Row { }, - Image { }, - Image { }, - Column { }, - Row { }, - Text { }, - Text { }, - Text { }, - MouseArea { } - ] - - } - } - } - -} diff --git a/tests/benchmarks/declarative/qmltime/tests/item_creation/data.qml b/tests/benchmarks/declarative/qmltime/tests/item_creation/data.qml deleted file mode 100644 index 6a8ca1b968..0000000000 --- a/tests/benchmarks/declarative/qmltime/tests/item_creation/data.qml +++ /dev/null @@ -1,75 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 -import QmlTime 1.0 as QmlTime - -Item { - - QmlTime.Timer { - component: Component { - Item { - data: [ - Rectangle { }, - Rectangle { }, - Item { }, - Image { }, - Text { }, - Item { }, - Item { }, - Image { }, - Image { }, - Row { }, - Image { }, - Image { }, - Column { }, - Row { }, - Text { }, - Text { }, - Text { }, - MouseArea { } - ] - - } - } - } - -} diff --git a/tests/benchmarks/declarative/qmltime/tests/item_creation/no_creation.qml b/tests/benchmarks/declarative/qmltime/tests/item_creation/no_creation.qml deleted file mode 100644 index 4dde9f289e..0000000000 --- a/tests/benchmarks/declarative/qmltime/tests/item_creation/no_creation.qml +++ /dev/null @@ -1,53 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 -import QmlTime 1.0 as QmlTime - -Item { - - QmlTime.Timer { - component: Component { - Item { - } - } - } -} diff --git a/tests/benchmarks/declarative/qmltime/tests/item_creation/resources.qml b/tests/benchmarks/declarative/qmltime/tests/item_creation/resources.qml deleted file mode 100644 index 802598839c..0000000000 --- a/tests/benchmarks/declarative/qmltime/tests/item_creation/resources.qml +++ /dev/null @@ -1,75 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 -import QmlTime 1.0 as QmlTime - -Item { - - QmlTime.Timer { - component: Component { - Item { - resources: [ - Rectangle { }, - Rectangle { }, - Item { }, - Image { }, - Text { }, - Item { }, - Item { }, - Image { }, - Image { }, - Row { }, - Image { }, - Image { }, - Column { }, - Row { }, - Text { }, - Text { }, - Text { }, - MouseArea { } - ] - - } - } - } - -} diff --git a/tests/benchmarks/declarative/qmltime/tests/loader/Loaded.qml b/tests/benchmarks/declarative/qmltime/tests/loader/Loaded.qml deleted file mode 100644 index d5d22f948c..0000000000 --- a/tests/benchmarks/declarative/qmltime/tests/loader/Loaded.qml +++ /dev/null @@ -1,48 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -Item { - Rectangle {} - Text {} - Image {} -} diff --git a/tests/benchmarks/declarative/qmltime/tests/loader/component_loader.qml b/tests/benchmarks/declarative/qmltime/tests/loader/component_loader.qml deleted file mode 100644 index ab42dfb2f9..0000000000 --- a/tests/benchmarks/declarative/qmltime/tests/loader/component_loader.qml +++ /dev/null @@ -1,57 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 -import QmlTime 1.0 as QmlTime - -Item { - - QmlTime.Timer { - component: Component { - Item { - Loader { - sourceComponent: Loaded {} - } - } - } - } -} - diff --git a/tests/benchmarks/declarative/qmltime/tests/loader/empty_loader.qml b/tests/benchmarks/declarative/qmltime/tests/loader/empty_loader.qml deleted file mode 100644 index c32ca2e61b..0000000000 --- a/tests/benchmarks/declarative/qmltime/tests/loader/empty_loader.qml +++ /dev/null @@ -1,56 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 -import QmlTime 1.0 as QmlTime - -Item { - - QmlTime.Timer { - component: Component { - Item { - Loader {} - Loaded {} - } - } - } -} - diff --git a/tests/benchmarks/declarative/qmltime/tests/loader/no_loader.qml b/tests/benchmarks/declarative/qmltime/tests/loader/no_loader.qml deleted file mode 100644 index dff5f11f99..0000000000 --- a/tests/benchmarks/declarative/qmltime/tests/loader/no_loader.qml +++ /dev/null @@ -1,55 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 -import QmlTime 1.0 as QmlTime - -Item { - - QmlTime.Timer { - component: Component { - Item { - Loaded {} - } - } - } -} - diff --git a/tests/benchmarks/declarative/qmltime/tests/loader/source_loader.qml b/tests/benchmarks/declarative/qmltime/tests/loader/source_loader.qml deleted file mode 100644 index 6b16afc1c4..0000000000 --- a/tests/benchmarks/declarative/qmltime/tests/loader/source_loader.qml +++ /dev/null @@ -1,57 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 -import QmlTime 1.0 as QmlTime - -Item { - - QmlTime.Timer { - component: Component { - Item { - Loader { - source: "Loaded.qml" - } - } - } - } -} - diff --git a/tests/benchmarks/declarative/qmltime/tests/positioner_creation/no_positioner.qml b/tests/benchmarks/declarative/qmltime/tests/positioner_creation/no_positioner.qml deleted file mode 100644 index e9f13e9deb..0000000000 --- a/tests/benchmarks/declarative/qmltime/tests/positioner_creation/no_positioner.qml +++ /dev/null @@ -1,78 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 -import QmlTime 1.0 as QmlTime - -Item { - QmlTime.Timer { - component: Component { - Item { - Rectangle { } - Rectangle { } - Item { - Image { } - Text { } - } - - Item { - Item { - Image { } - Image { } - Item { - Image { } - Image { } - } - } - - Item { - Item { - Text { } - Text { } - } - Text { } - } - } - MouseArea { } - } - } - } -} diff --git a/tests/benchmarks/declarative/qmltime/tests/positioner_creation/null_positioner.qml b/tests/benchmarks/declarative/qmltime/tests/positioner_creation/null_positioner.qml deleted file mode 100644 index d50da90764..0000000000 --- a/tests/benchmarks/declarative/qmltime/tests/positioner_creation/null_positioner.qml +++ /dev/null @@ -1,75 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 -import QmlTime 1.0 as QmlTime - -Item { - QmlTime.Timer { - component: Component { - Item { - Rectangle { } - Rectangle { } - Item { - Image { } - Text { } - } - - Item { - Item { - Image { } - Image { } - Row { } - Image { } - Image { } - } - - Column { } - Row { } - Text { } - Text { } - Text { } - } - MouseArea { } - } - } - } -} diff --git a/tests/benchmarks/declarative/qmltime/tests/positioner_creation/positioner.qml b/tests/benchmarks/declarative/qmltime/tests/positioner_creation/positioner.qml deleted file mode 100644 index 8f7814be6a..0000000000 --- a/tests/benchmarks/declarative/qmltime/tests/positioner_creation/positioner.qml +++ /dev/null @@ -1,78 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 -import QmlTime 1.0 as QmlTime - -Item { - QmlTime.Timer { - component: Component { - Item { - Rectangle { } - Rectangle { } - Item { - Image { } - Text { } - } - - Item { - Item { - Image { } - Image { } - Row { - Image { } - Image { } - } - } - - Column { - Row { - Text { } - Text { } - } - Text { } - } - } - MouseArea { } - } - } - } -} diff --git a/tests/benchmarks/declarative/qmltime/tests/vmemetaobject/null.qml b/tests/benchmarks/declarative/qmltime/tests/vmemetaobject/null.qml deleted file mode 100644 index 34d6b30670..0000000000 --- a/tests/benchmarks/declarative/qmltime/tests/vmemetaobject/null.qml +++ /dev/null @@ -1,54 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 -import QmlTime 1.0 as QmlTime - -Item { - - QmlTime.Timer { - component: Component { - QtObject { - } - } - } - -} diff --git a/tests/benchmarks/declarative/qmltime/tests/vmemetaobject/property.qml b/tests/benchmarks/declarative/qmltime/tests/vmemetaobject/property.qml deleted file mode 100644 index 4dd63bb36e..0000000000 --- a/tests/benchmarks/declarative/qmltime/tests/vmemetaobject/property.qml +++ /dev/null @@ -1,59 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 -import QmlTime 1.0 as QmlTime - -Item { - - QmlTime.Timer { - component: Component { - QtObject { - property string s - property string s2 - property string s3 - property string s4 - } - } - } - -} - diff --git a/tests/benchmarks/declarative/script/data/CustomObject.qml b/tests/benchmarks/declarative/script/data/CustomObject.qml deleted file mode 100644 index 7c8c561114..0000000000 --- a/tests/benchmarks/declarative/script/data/CustomObject.qml +++ /dev/null @@ -1,48 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -QtObject { - property real prop1: 0 - property real prop2: 1 - property real prop3: 0 -} diff --git a/tests/benchmarks/declarative/script/data/block.qml b/tests/benchmarks/declarative/script/data/block.qml deleted file mode 100644 index 67ad5cbed2..0000000000 --- a/tests/benchmarks/declarative/script/data/block.qml +++ /dev/null @@ -1,75 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -Rectangle { - width: 200; height: 200 - CustomObject { id: theObject } - function doSomethingDirect() { - theObject.prop1 = 0; - - for (var i = 0; i < 1000; ++i) - theObject.prop1 += theObject.prop2; - - theObject.prop3 = theObject.prop1; - } - - function doSomethingLocalObj() { - theObject.prop1 = 0; - - var incrementObj = theObject; - for (var i = 0; i < 1000; ++i) - incrementObj.prop1 += incrementObj.prop2; - - incrementObj.prop3 = incrementObj.prop1; - } - - function doSomethingLocal() { - theObject.prop1 = 0; - - var increment = theObject.prop2; - for (var i = 0; i < 1000; ++i) - theObject.prop1 += increment; - - theObject.prop3 = theObject.prop1; - } -} diff --git a/tests/benchmarks/declarative/script/data/enums.qml b/tests/benchmarks/declarative/script/data/enums.qml deleted file mode 100644 index 8450b15732..0000000000 --- a/tests/benchmarks/declarative/script/data/enums.qml +++ /dev/null @@ -1,51 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the Declarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -Item { - function runtest() { - var a = 0; - for (var ii = 0; ii < 100000; ++ii) - a += Text.RichText; - return a; - } -} diff --git a/tests/benchmarks/declarative/script/data/global.js b/tests/benchmarks/declarative/script/data/global.js deleted file mode 100644 index 4e3a4780f9..0000000000 --- a/tests/benchmarks/declarative/script/data/global.js +++ /dev/null @@ -1,54 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -var incVar = 1; -var total; - -function doSomething() { - for (var i = 0; i < 10000; ++i) - Math.sin(90); -} - -function doIncrement() { - total = 0; - for (var i = 0; i < 100000; ++i) - total += incVar; -} diff --git a/tests/benchmarks/declarative/script/data/global_prop.qml b/tests/benchmarks/declarative/script/data/global_prop.qml deleted file mode 100644 index c77faaf9f4..0000000000 --- a/tests/benchmarks/declarative/script/data/global_prop.qml +++ /dev/null @@ -1,53 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 -import "global.js" as Program - -Rectangle { - width: 200; height: 200 - - signal triggered - signal incrementTriggered - - onTriggered: Program.doSomething(); - onIncrementTriggered: Program.doIncrement(); -} diff --git a/tests/benchmarks/declarative/script/data/namespacedEnums.qml b/tests/benchmarks/declarative/script/data/namespacedEnums.qml deleted file mode 100644 index e49bf7e1ad..0000000000 --- a/tests/benchmarks/declarative/script/data/namespacedEnums.qml +++ /dev/null @@ -1,52 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the Declarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 as QtQuick - -QtQuick.Item { - function runtest() { - var a = 0; - for (var ii = 0; ii < 100000; ++ii) - a += QtQuick.Text.RichText; - return a; - } -} - diff --git a/tests/benchmarks/declarative/script/data/script.js b/tests/benchmarks/declarative/script/data/script.js deleted file mode 100644 index 9f46570004..0000000000 --- a/tests/benchmarks/declarative/script/data/script.js +++ /dev/null @@ -1 +0,0 @@ -function func() { return 1; } diff --git a/tests/benchmarks/declarative/script/data/script2.js b/tests/benchmarks/declarative/script/data/script2.js deleted file mode 100644 index 102f081140..0000000000 --- a/tests/benchmarks/declarative/script/data/script2.js +++ /dev/null @@ -1,2 +0,0 @@ -function func() { return 2; } - diff --git a/tests/benchmarks/declarative/script/data/scriptCall.qml b/tests/benchmarks/declarative/script/data/scriptCall.qml deleted file mode 100644 index 420f621dfc..0000000000 --- a/tests/benchmarks/declarative/script/data/scriptCall.qml +++ /dev/null @@ -1,54 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the Declarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 -import "script.js" as Script -import "script2.js" as OtherScript - -Item { - function runtest() { - var a = 0; - for (var ii = 0; ii < 1000000; ++ii) - a += Script.func(); - return a; - } -} - diff --git a/tests/benchmarks/declarative/script/data/signal_args.qml b/tests/benchmarks/declarative/script/data/signal_args.qml deleted file mode 100644 index ed5c56a197..0000000000 --- a/tests/benchmarks/declarative/script/data/signal_args.qml +++ /dev/null @@ -1,47 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import Qt.test 1.0 - -TestObject { - onMySignalWithArgs: { var a = n; return a; } -} - diff --git a/tests/benchmarks/declarative/script/data/signal_qml.qml b/tests/benchmarks/declarative/script/data/signal_qml.qml deleted file mode 100644 index c5bda7d18e..0000000000 --- a/tests/benchmarks/declarative/script/data/signal_qml.qml +++ /dev/null @@ -1,47 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import Qt.test 1.0 - -TestObject { - onMySignal: { var a = 1; return a; } -} - diff --git a/tests/benchmarks/declarative/script/data/signal_unconnected.qml b/tests/benchmarks/declarative/script/data/signal_unconnected.qml deleted file mode 100644 index 90fe2bc6f5..0000000000 --- a/tests/benchmarks/declarative/script/data/signal_unconnected.qml +++ /dev/null @@ -1,45 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import Qt.test 1.0 - -TestObject { -} diff --git a/tests/benchmarks/declarative/script/data/signal_unusedArgs.qml b/tests/benchmarks/declarative/script/data/signal_unusedArgs.qml deleted file mode 100644 index 6de5815939..0000000000 --- a/tests/benchmarks/declarative/script/data/signal_unusedArgs.qml +++ /dev/null @@ -1,47 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import Qt.test 1.0 - -TestObject { - onMySignalWithArgs: { var a = 1; return a; } -} - diff --git a/tests/benchmarks/declarative/script/data/slot_complex.qml b/tests/benchmarks/declarative/script/data/slot_complex.qml deleted file mode 100644 index 8e2cb30089..0000000000 --- a/tests/benchmarks/declarative/script/data/slot_complex.qml +++ /dev/null @@ -1,57 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import Qt.test 1.0 - -TestObject { - function myCustomFunction(b) { - var n = b; - var a = 1; - while (n > 0) { - a = a * n; - n--; - } - return a; - } - - onMySignal: { for (var ii = 0; ii < 10000; ++ii) { myCustomFunction(10); } } -} - diff --git a/tests/benchmarks/declarative/script/data/slot_complex_js.js b/tests/benchmarks/declarative/script/data/slot_complex_js.js deleted file mode 100644 index 64a1f65daa..0000000000 --- a/tests/benchmarks/declarative/script/data/slot_complex_js.js +++ /dev/null @@ -1,8 +0,0 @@ -function myCustomFunction(n) { - var a = 1; - while (n > 0) { - a = a * n; - n--; - } - return a; -} diff --git a/tests/benchmarks/declarative/script/data/slot_complex_js.qml b/tests/benchmarks/declarative/script/data/slot_complex_js.qml deleted file mode 100644 index ca06046389..0000000000 --- a/tests/benchmarks/declarative/script/data/slot_complex_js.qml +++ /dev/null @@ -1,49 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import Qt.test 1.0 -import "slot_complex_js.js" as Logic - -TestObject { - onMySignal: { for (var ii = 0; ii < 10000; ++ii) { Logic.myCustomFunction(10); } } -} - - diff --git a/tests/benchmarks/declarative/script/data/slot_simple.qml b/tests/benchmarks/declarative/script/data/slot_simple.qml deleted file mode 100644 index c93fbcc757..0000000000 --- a/tests/benchmarks/declarative/script/data/slot_simple.qml +++ /dev/null @@ -1,50 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import Qt.test 1.0 - -TestObject { - function myCustomFunction() { - return 0; - } - - onMySignal: { for (var ii = 0; ii < 10000; ++ii) { myCustomFunction(); } } -} diff --git a/tests/benchmarks/declarative/script/data/slot_simple_js.js b/tests/benchmarks/declarative/script/data/slot_simple_js.js deleted file mode 100644 index d6e60608da..0000000000 --- a/tests/benchmarks/declarative/script/data/slot_simple_js.js +++ /dev/null @@ -1,3 +0,0 @@ -function myCustomFunction() { - return 0; -} diff --git a/tests/benchmarks/declarative/script/data/slot_simple_js.qml b/tests/benchmarks/declarative/script/data/slot_simple_js.qml deleted file mode 100644 index 07334ab4fa..0000000000 --- a/tests/benchmarks/declarative/script/data/slot_simple_js.qml +++ /dev/null @@ -1,48 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import Qt.test 1.0 -import "slot_simple_js.js" as Logic - -TestObject { - onMySignal: { for (var ii = 0; ii < 10000; ++ii) { Logic.myCustomFunction(); } } -} - diff --git a/tests/benchmarks/declarative/script/script.pro b/tests/benchmarks/declarative/script/script.pro deleted file mode 100644 index 310d17d3c9..0000000000 --- a/tests/benchmarks/declarative/script/script.pro +++ /dev/null @@ -1,10 +0,0 @@ -CONFIG += testcase -TEMPLATE = app -TARGET = tst_script -QT += declarative testlib -macx:CONFIG -= app_bundle -CONFIG += release - -SOURCES += tst_script.cpp - -DEFINES += SRCDIR=\\\"$$PWD\\\" diff --git a/tests/benchmarks/declarative/script/tst_script.cpp b/tests/benchmarks/declarative/script/tst_script.cpp deleted file mode 100644 index 0e5d782134..0000000000 --- a/tests/benchmarks/declarative/script/tst_script.cpp +++ /dev/null @@ -1,803 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include -#include -#include -#include -#include -#include -#include -#include - -class tst_script : public QObject -{ - Q_OBJECT -public: - tst_script() {} - -private slots: - void initTestCase(); - - void property_js(); - void property_getter(); - void property_getter_js(); - void property_getter_qobject(); - void property_getter_qmetaproperty(); - void property_qobject(); - void property_qmlobject(); - - void setproperty_js(); - void setproperty_qmlobject(); - - void function_js(); - void function_cpp(); - void function_qobject(); - void function_qmlobject(); - - void function_args_js(); - void function_args_cpp(); - void function_args_qobject(); - void function_args_qmlobject(); - - void signal_unconnected(); - void signal_qml(); - void signal_args(); - void signal_unusedArgs(); - - void slot_simple(); - void slot_simple_js(); - void slot_complex(); - void slot_complex_js(); - - void block_data(); - void block(); - - void global_property_js(); - void global_property_qml(); - void global_property_qml_js(); - - void scriptfile_property(); - - void enums(); - void namespacedEnums(); - void scriptCall(); -}; - -inline QUrl TEST_FILE(const QString &filename) -{ - return QUrl::fromLocalFile(QLatin1String(SRCDIR) + QLatin1String("/data/") + filename); -} - -class TestObject : public QObject -{ - Q_OBJECT - Q_PROPERTY(int x READ x WRITE setX) - -public: - TestObject(QObject *parent = 0); - - int x(); - void setX(int x) { m_x = x; } - - void emitMySignal() { emit mySignal(); } - void emitMySignalWithArgs(int n) { emit mySignalWithArgs(n); } - -signals: - void mySignal(); - void mySignalWithArgs(int n); - -public slots: - int method() { - return x(); - } - - int methodArgs(int val) { - return val + x(); - } - -private: - int m_x; -}; -QML_DECLARE_TYPE(TestObject); - -TestObject::TestObject(QObject *parent) -: QObject(parent), m_x(0) -{ -} - -int TestObject::x() -{ - return m_x++; -} - -void tst_script::initTestCase() -{ - qmlRegisterType("Qt.test", 1, 0, "TestObject"); -} - - -#define PROPERTY_PROGRAM \ - "(function(testObject) { return (function() { " \ - " var test = 0; " \ - " for (var ii = 0; ii < 10000; ++ii) { " \ - " test += testObject.x; " \ - " } " \ - " return test; " \ - "}); })" - -void tst_script::property_js() -{ - QScriptEngine engine; - - QScriptValue v = engine.newObject(); - v.setProperty(QLatin1String("x"), 10); - - QScriptValueList args; - args << v; - QScriptValue prog = engine.evaluate(PROPERTY_PROGRAM).call(engine.globalObject(), args); - prog.call(); - - QBENCHMARK { - prog.call().toNumber(); - } -} - -static QScriptValue property_getter_method(QScriptContext *, QScriptEngine *engine) -{ - static int x = 0; - return QScriptValue(engine,x++); -} - -void tst_script::property_getter() -{ - QScriptEngine engine; - - QScriptValue v = engine.newObject(); - v.setProperty(QLatin1String("x"), engine.newFunction(property_getter_method), - QScriptValue::PropertyGetter); - - QScriptValueList args; - args << v; - QScriptValue prog = engine.evaluate(PROPERTY_PROGRAM).call(engine.globalObject(), args); - prog.call(); - - QBENCHMARK { - prog.call(); - } -} - -static TestObject *property_getter_qobject_object = 0; -static QScriptValue property_getter_qobject_method(QScriptContext *, QScriptEngine *) -{ - static int idx = -1; - if (idx == -1) - idx = TestObject::staticMetaObject.indexOfProperty("x"); - - int value = 0; - void *args[] = { &value, 0 }; - QMetaObject::metacall(property_getter_qobject_object, QMetaObject::ReadProperty, idx, args); - - return QScriptValue(value); -} - -static QScriptValue property_getter_qmetaproperty_method(QScriptContext *, QScriptEngine *) -{ - static int idx = -1; - if (idx == -1) - idx = TestObject::staticMetaObject.indexOfProperty("x"); - - int value = 0; - value = property_getter_qobject_object->metaObject()->property(idx).read(property_getter_qobject_object).toInt(); - - return QScriptValue(value); -} - -void tst_script::property_getter_qobject() -{ - QScriptEngine engine; - - TestObject to; - property_getter_qobject_object = &to; - QScriptValue v = engine.newObject(); - v.setProperty(QLatin1String("x"), engine.newFunction(property_getter_qobject_method), - QScriptValue::PropertyGetter); - - QScriptValueList args; - args << v; - QScriptValue prog = engine.evaluate(PROPERTY_PROGRAM).call(engine.globalObject(), args); - prog.call(); - - QBENCHMARK { - prog.call(); - } - property_getter_qobject_object = 0; -} - -void tst_script::property_getter_qmetaproperty() -{ - QScriptEngine engine; - - TestObject to; - property_getter_qobject_object = &to; - QScriptValue v = engine.newObject(); - v.setProperty(QLatin1String("x"), engine.newFunction(property_getter_qmetaproperty_method), - QScriptValue::PropertyGetter); - - QScriptValueList args; - args << v; - QScriptValue prog = engine.evaluate(PROPERTY_PROGRAM).call(engine.globalObject(), args); - prog.call(); - - QBENCHMARK { - prog.call(); - } - property_getter_qobject_object = 0; -} - - -void tst_script::property_getter_js() -{ - QScriptEngine engine; - - QScriptValue v = engine.evaluate("(function() { var o = new Object; o._x = 0; o.__defineGetter__(\"x\", function() { return this._x++; }); return o; })").call(); - - QScriptValueList args; - args << v; - QScriptValue prog = engine.evaluate(PROPERTY_PROGRAM).call(engine.globalObject(), args); - prog.call(); - - QBENCHMARK { - prog.call(); - } -} - -void tst_script::property_qobject() -{ - QScriptEngine engine; - - TestObject to; - QScriptValue v = engine.newQObject(&to); - - QScriptValueList args; - args << v; - QScriptValue prog = engine.evaluate(PROPERTY_PROGRAM).call(engine.globalObject(), args); - prog.call(); - - QBENCHMARK { - prog.call(); - } -} - -void tst_script::property_qmlobject() -{ - QDeclarativeEngine qmlengine; - - QScriptEngine *engine = QDeclarativeEnginePrivate::getScriptEngine(&qmlengine); - TestObject to; - - QScriptValue v = QDeclarativeEnginePrivate::get(&qmlengine)->objectClass->newQObject(&to); - - QScriptValueList args; - args << v; - QScriptValue prog = engine->evaluate(PROPERTY_PROGRAM).call(engine->globalObject(), args); - prog.call(); - - QBENCHMARK { - prog.call(); - } -} - -#define SETPROPERTY_PROGRAM \ - "(function(testObject) { return (function() { " \ - " for (var ii = 0; ii < 10000; ++ii) { " \ - " testObject.x = ii; " \ - " } " \ - "}); })" - -void tst_script::setproperty_js() -{ - QScriptEngine engine; - - QScriptValue v = engine.newObject(); - v.setProperty(QLatin1String("x"), 0); - - QScriptValueList args; - args << v; - QScriptValue prog = engine.evaluate(SETPROPERTY_PROGRAM).call(engine.globalObject(), args); - prog.call(); - - QBENCHMARK { - prog.call(); - } -} - -void tst_script::setproperty_qmlobject() -{ - QDeclarativeEngine qmlengine; - - QScriptEngine *engine = QDeclarativeEnginePrivate::getScriptEngine(&qmlengine); - TestObject to; - - QScriptValue v = QDeclarativeEnginePrivate::get(&qmlengine)->objectClass->newQObject(&to); - - QScriptValueList args; - args << v; - QScriptValue prog = engine->evaluate(SETPROPERTY_PROGRAM).call(engine->globalObject(), args); - prog.call(); - - QBENCHMARK { - prog.call(); - } -} - -#define FUNCTION_PROGRAM \ - "(function(testObject) { return (function() { " \ - " var test = 0; " \ - " for (var ii = 0; ii < 10000; ++ii) { " \ - " test += testObject.method(); " \ - " } " \ - " return test; " \ - "}); })" - -void tst_script::function_js() -{ - QScriptEngine engine; - - QScriptValue v = engine.evaluate("(function() { var o = new Object; o._x = 0; o.method = (function() { return this._x++; }); return o; })").call(); - - QScriptValueList args; - args << v; - QScriptValue prog = engine.evaluate(FUNCTION_PROGRAM).call(engine.globalObject(), args); - prog.call(); - - QBENCHMARK { - prog.call(); - } -} - -static QScriptValue function_method(QScriptContext *, QScriptEngine *) -{ - static int x = 0; - return QScriptValue(x++); -} - -void tst_script::function_cpp() -{ - QScriptEngine engine; - - QScriptValue v = engine.newObject(); - v.setProperty(QLatin1String("method"), engine.newFunction(function_method)); - - QScriptValueList args; - args << v; - QScriptValue prog = engine.evaluate(FUNCTION_PROGRAM).call(engine.globalObject(), args); - prog.call(); - - QBENCHMARK { - prog.call(); - } -} - -void tst_script::function_qobject() -{ - QScriptEngine engine; - - TestObject to; - QScriptValue v = engine.newQObject(&to); - - QScriptValueList args; - args << v; - QScriptValue prog = engine.evaluate(FUNCTION_PROGRAM).call(engine.globalObject(), args); - prog.call(); - - QBENCHMARK { - prog.call(); - } -} - -void tst_script::function_qmlobject() -{ - QDeclarativeEngine qmlengine; - - QScriptEngine *engine = QDeclarativeEnginePrivate::getScriptEngine(&qmlengine); - TestObject to; - - QScriptValue v = QDeclarativeEnginePrivate::get(&qmlengine)->objectClass->newQObject(&to); - - QScriptValueList args; - args << v; - QScriptValue prog = engine->evaluate(FUNCTION_PROGRAM).call(engine->globalObject(), args); - prog.call(); - - QBENCHMARK { - prog.call(); - } -} - -#define FUNCTION_ARGS_PROGRAM \ - "(function(testObject) { return (function() { " \ - " var test = 0; " \ - " for (var ii = 0; ii < 10000; ++ii) { " \ - " test += testObject.methodArgs(ii); " \ - " } " \ - " return test; " \ - "}); })" - -void tst_script::function_args_js() -{ - QScriptEngine engine; - - QScriptValue v = engine.evaluate("(function() { var o = new Object; o._x = 0; o.methodArgs = (function(a) { return a + this._x++; }); return o; })").call(); - - QScriptValueList args; - args << v; - QScriptValue prog = engine.evaluate(FUNCTION_ARGS_PROGRAM).call(engine.globalObject(), args); - prog.call(); - - QBENCHMARK { - prog.call(); - } -} - -static QScriptValue function_args_method(QScriptContext *ctxt, QScriptEngine *) -{ - static int x = 0; - return QScriptValue(ctxt->argument(0).toNumber() + x++); -} - -void tst_script::function_args_cpp() -{ - QScriptEngine engine; - - QScriptValue v = engine.newObject(); - v.setProperty(QLatin1String("methodArgs"), engine.newFunction(function_args_method)); - - QScriptValueList args; - args << v; - QScriptValue prog = engine.evaluate(FUNCTION_ARGS_PROGRAM).call(engine.globalObject(), args); - prog.call(); - - QBENCHMARK { - prog.call(); - } -} - -void tst_script::function_args_qobject() -{ - QScriptEngine engine; - - TestObject to; - QScriptValue v = engine.newQObject(&to); - - QScriptValueList args; - args << v; - QScriptValue prog = engine.evaluate(FUNCTION_ARGS_PROGRAM).call(engine.globalObject(), args); - prog.call(); - - QBENCHMARK { - prog.call(); - } -} - -void tst_script::function_args_qmlobject() -{ - QDeclarativeEngine qmlengine; - - QScriptEngine *engine = QDeclarativeEnginePrivate::getScriptEngine(&qmlengine); - TestObject to; - - QScriptValue v = QDeclarativeEnginePrivate::get(&qmlengine)->objectClass->newQObject(&to); - - QScriptValueList args; - args << v; - QScriptValue prog = engine->evaluate(FUNCTION_ARGS_PROGRAM).call(engine->globalObject(), args); - prog.call(); - - QBENCHMARK { - prog.call(); - } -} - -void tst_script::signal_unconnected() -{ - QDeclarativeEngine engine; - QDeclarativeComponent component(&engine, TEST_FILE("signal_unconnected.qml")); - TestObject *object = qobject_cast(component.create()); - QVERIFY(object != 0); - - QBENCHMARK { - object->emitMySignal(); - } - - delete object; -} - -void tst_script::signal_qml() -{ - QDeclarativeEngine engine; - QDeclarativeComponent component(&engine, TEST_FILE("signal_qml.qml")); - TestObject *object = qobject_cast(component.create()); - QVERIFY(object != 0); - - QBENCHMARK { - object->emitMySignal(); - } - - delete object; -} - -void tst_script::signal_args() -{ - QDeclarativeEngine engine; - QDeclarativeComponent component(&engine, TEST_FILE("signal_args.qml")); - TestObject *object = qobject_cast(component.create()); - QVERIFY(object != 0); - - QBENCHMARK { - object->emitMySignalWithArgs(11); - } - - delete object; -} - -void tst_script::signal_unusedArgs() -{ - QDeclarativeEngine engine; - QDeclarativeComponent component(&engine, TEST_FILE("signal_unusedArgs.qml")); - TestObject *object = qobject_cast(component.create()); - QVERIFY(object != 0); - - QBENCHMARK { - object->emitMySignalWithArgs(11); - } - - delete object; -} - -void tst_script::slot_simple() -{ - QDeclarativeEngine engine; - QDeclarativeComponent component(&engine, TEST_FILE("slot_simple.qml")); - TestObject *object = qobject_cast(component.create()); - QVERIFY(object != 0); - - QBENCHMARK { - object->emitMySignal(); - } - - delete object; -} - -void tst_script::slot_simple_js() -{ - QDeclarativeEngine engine; - QDeclarativeComponent component(&engine, TEST_FILE("slot_simple_js.qml")); - TestObject *object = qobject_cast(component.create()); - QVERIFY(object != 0); - - QBENCHMARK { - object->emitMySignal(); - } - - delete object; -} - -void tst_script::slot_complex() -{ - QDeclarativeEngine engine; - QDeclarativeComponent component(&engine, TEST_FILE("slot_complex.qml")); - TestObject *object = qobject_cast(component.create()); - QVERIFY(object != 0); - - QBENCHMARK { - object->emitMySignal(); - } - - delete object; -} - -void tst_script::slot_complex_js() -{ - QDeclarativeEngine engine; - QDeclarativeComponent component(&engine, TEST_FILE("slot_complex_js.qml")); - TestObject *object = qobject_cast(component.create()); - QVERIFY(object != 0); - - QBENCHMARK { - object->emitMySignal(); - } - - delete object; -} - -void tst_script::block_data() -{ - QTest::addColumn("methodName"); - QTest::newRow("direct") << "doSomethingDirect()"; - QTest::newRow("localObj") << "doSomethingLocalObj()"; - QTest::newRow("local") << "doSomethingLocal()"; -} - -void tst_script::block() -{ - QFETCH(QString, methodName); - QDeclarativeEngine engine; - QDeclarativeComponent component(&engine, TEST_FILE("block.qml")); - QDeclarativeRectangle *rect = qobject_cast(component.create()); - QVERIFY(rect != 0); - - int index = rect->metaObject()->indexOfMethod(methodName.toUtf8()); - QVERIFY(index != -1); - QMetaMethod method = rect->metaObject()->method(index); - - QBENCHMARK { - method.invoke(rect, Qt::DirectConnection); - } - - delete rect; -} - -#define GLOBALPROPERTY_PROGRAM \ - "(function() { " \ - " for (var ii = 0; ii < 10000; ++ii) { " \ - " Math.sin(90); " \ - " } " \ - "})" - -void tst_script::global_property_js() -{ - QScriptEngine engine; - - QScriptValue prog = engine.evaluate(GLOBALPROPERTY_PROGRAM); - prog.call(); - - QBENCHMARK { - prog.call(); - } -} - -void tst_script::global_property_qml() -{ - QDeclarativeEngine qmlengine; - - QScriptEngine *engine = QDeclarativeEnginePrivate::getScriptEngine(&qmlengine); - QScriptValue prog = engine->evaluate(GLOBALPROPERTY_PROGRAM); - prog.call(); - - QBENCHMARK { - prog.call(); - } -} - -void tst_script::global_property_qml_js() -{ - QDeclarativeEngine engine; - QDeclarativeComponent component(&engine, TEST_FILE("global_prop.qml")); - QDeclarativeRectangle *rect = qobject_cast(component.create()); - QVERIFY(rect != 0); - - int index = rect->metaObject()->indexOfMethod("triggered()"); - QVERIFY(index != -1); - QMetaMethod method = rect->metaObject()->method(index); - - QBENCHMARK { - method.invoke(rect, Qt::DirectConnection); - } - - delete rect; -} - -void tst_script::scriptfile_property() -{ - QDeclarativeEngine engine; - QDeclarativeComponent component(&engine, TEST_FILE("global_prop.qml")); - QDeclarativeRectangle *rect = qobject_cast(component.create()); - QVERIFY(rect != 0); - - int index = rect->metaObject()->indexOfMethod("incrementTriggered()"); - QVERIFY(index != -1); - QMetaMethod method = rect->metaObject()->method(index); - - QBENCHMARK { - method.invoke(rect, Qt::DirectConnection); - } - - delete rect; -} - -void tst_script::enums() -{ - QDeclarativeEngine engine; - QDeclarativeComponent component(&engine, TEST_FILE("enums.qml")); - QObject *o = component.create(); - QVERIFY(o != 0); - - int index = o->metaObject()->indexOfMethod("runtest()"); - QVERIFY(index != -1); - QMetaMethod method = o->metaObject()->method(index); - - QBENCHMARK { - method.invoke(o, Qt::DirectConnection); - } - - delete o; -} - -void tst_script::namespacedEnums() -{ - QDeclarativeEngine engine; - QDeclarativeComponent component(&engine, TEST_FILE("namespacedEnums.qml")); - QObject *o = component.create(); - QVERIFY(o != 0); - - int index = o->metaObject()->indexOfMethod("runtest()"); - QVERIFY(index != -1); - QMetaMethod method = o->metaObject()->method(index); - - QBENCHMARK { - method.invoke(o, Qt::DirectConnection); - } - - delete o; -} - -void tst_script::scriptCall() -{ - QDeclarativeEngine engine; - QDeclarativeComponent component(&engine, TEST_FILE("scriptCall.qml")); - QObject *o = component.create(); - QVERIFY(o != 0); - - int index = o->metaObject()->indexOfMethod("runtest()"); - QVERIFY(index != -1); - QMetaMethod method = o->metaObject()->method(index); - - QBENCHMARK { - method.invoke(o, Qt::DirectConnection); - } - - delete o; -} - -QTEST_MAIN(tst_script) - -#include "tst_script.moc" diff --git a/tests/benchmarks/declarative/typeimports/data/QmlTestType1.qml b/tests/benchmarks/declarative/typeimports/data/QmlTestType1.qml deleted file mode 100644 index 47467a64a6..0000000000 --- a/tests/benchmarks/declarative/typeimports/data/QmlTestType1.qml +++ /dev/null @@ -1,43 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import Qt.test 2.0 -TestType1 { } diff --git a/tests/benchmarks/declarative/typeimports/data/QmlTestType2.qml b/tests/benchmarks/declarative/typeimports/data/QmlTestType2.qml deleted file mode 100644 index 2547d44ec0..0000000000 --- a/tests/benchmarks/declarative/typeimports/data/QmlTestType2.qml +++ /dev/null @@ -1,43 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import Qt.test 2.0 -TestType2 { } diff --git a/tests/benchmarks/declarative/typeimports/data/QmlTestType3.qml b/tests/benchmarks/declarative/typeimports/data/QmlTestType3.qml deleted file mode 100644 index b07f70a802..0000000000 --- a/tests/benchmarks/declarative/typeimports/data/QmlTestType3.qml +++ /dev/null @@ -1,43 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import Qt.test 2.0 -TestType3 { } diff --git a/tests/benchmarks/declarative/typeimports/data/QmlTestType4.qml b/tests/benchmarks/declarative/typeimports/data/QmlTestType4.qml deleted file mode 100644 index 3407b3b0bd..0000000000 --- a/tests/benchmarks/declarative/typeimports/data/QmlTestType4.qml +++ /dev/null @@ -1,43 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import Qt.test 2.0 -TestType4 { } diff --git a/tests/benchmarks/declarative/typeimports/data/cpp.qml b/tests/benchmarks/declarative/typeimports/data/cpp.qml deleted file mode 100644 index 28bc3222d3..0000000000 --- a/tests/benchmarks/declarative/typeimports/data/cpp.qml +++ /dev/null @@ -1,56 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import Qt.test 2.0 - -TestType1 { - TestType1 { } TestType2 { } TestType3 { } TestType4 { } - TestType1 { } TestType2 { } TestType3 { } TestType4 { } - TestType1 { } TestType2 { } TestType3 { } TestType4 { } - TestType1 { } TestType2 { } TestType3 { } TestType4 { } - TestType1 { } TestType2 { } TestType3 { } TestType4 { } - - TestType1 { } TestType2 { } TestType3 { } TestType4 { } - TestType1 { } TestType2 { } TestType3 { } TestType4 { } - TestType1 { } TestType2 { } TestType3 { } TestType4 { } - TestType1 { } TestType2 { } TestType3 { } TestType4 { } - TestType1 { } TestType2 { } TestType3 { } TestType4 { } -} diff --git a/tests/benchmarks/declarative/typeimports/data/qml.qml b/tests/benchmarks/declarative/typeimports/data/qml.qml deleted file mode 100644 index c6a71b30c5..0000000000 --- a/tests/benchmarks/declarative/typeimports/data/qml.qml +++ /dev/null @@ -1,54 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -QmlTestType1 { - QmlTestType1 { } QmlTestType2 { } QmlTestType3 { } QmlTestType4 { } - QmlTestType1 { } QmlTestType2 { } QmlTestType3 { } QmlTestType4 { } - QmlTestType1 { } QmlTestType2 { } QmlTestType3 { } QmlTestType4 { } - QmlTestType1 { } QmlTestType2 { } QmlTestType3 { } QmlTestType4 { } - QmlTestType1 { } QmlTestType2 { } QmlTestType3 { } QmlTestType4 { } - - QmlTestType1 { } QmlTestType2 { } QmlTestType3 { } QmlTestType4 { } - QmlTestType1 { } QmlTestType2 { } QmlTestType3 { } QmlTestType4 { } - QmlTestType1 { } QmlTestType2 { } QmlTestType3 { } QmlTestType4 { } - QmlTestType1 { } QmlTestType2 { } QmlTestType3 { } QmlTestType4 { } - QmlTestType1 { } QmlTestType2 { } QmlTestType3 { } QmlTestType4 { } -} diff --git a/tests/benchmarks/declarative/typeimports/tst_typeimports.cpp b/tests/benchmarks/declarative/typeimports/tst_typeimports.cpp deleted file mode 100644 index a4fb034eb2..0000000000 --- a/tests/benchmarks/declarative/typeimports/tst_typeimports.cpp +++ /dev/null @@ -1,135 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include -#include -#include -#include - -class tst_typeimports : public QObject -{ - Q_OBJECT -public: - tst_typeimports(); - -private slots: - void cpp(); - void qml(); - -private: - QDeclarativeEngine engine; -}; - -class TestType1 : public QObject -{ - Q_OBJECT - Q_PROPERTY(QDeclarativeListProperty resources READ resources); - Q_CLASSINFO("DefaultProperty", "resources"); -public: - TestType1(QObject *parent = 0) : QObject(parent) {} - - QDeclarativeListProperty resources() { - return QDeclarativeListProperty(this, 0, resources_append); - } - - static void resources_append(QDeclarativeListProperty *p, QObject *o) { - o->setParent(p->object); - } -}; - -class TestType2 : public TestType1 -{ - Q_OBJECT -public: - TestType2(QObject *parent = 0) : TestType1(parent) {} -}; - - -class TestType3 : public TestType1 -{ - Q_OBJECT -public: - TestType3(QObject *parent = 0) : TestType1(parent) {} -}; - -class TestType4 : public TestType1 -{ - Q_OBJECT -public: - TestType4(QObject *parent = 0) : TestType1(parent) {} -}; - - -tst_typeimports::tst_typeimports() -{ - qmlRegisterType("Qt.test", 1, 0, "TestType1"); - qmlRegisterType("Qt.test", 1, 0, "TestType2"); - qmlRegisterType("Qt.test", 2, 0, "TestType3"); - qmlRegisterType("Qt.test", 2, 0, "TestType4"); -} - -inline QUrl TEST_FILE(const QString &filename) -{ - return QUrl::fromLocalFile(QLatin1String(SRCDIR) + QLatin1String("/data/") + filename); -} - -void tst_typeimports::cpp() -{ - QBENCHMARK { - QDeclarativeComponent component(&engine, TEST_FILE("cpp.qml")); - QVERIFY(component.isReady()); - } -} - -void tst_typeimports::qml() -{ - //get rid of initialization effects - { QDeclarativeComponent component(&engine, TEST_FILE("qml.qml")); } - - QBENCHMARK { - QDeclarativeComponent component(&engine, TEST_FILE("qml.qml")); - QVERIFY(component.isReady()); - } -} - -QTEST_MAIN(tst_typeimports) - -#include "tst_typeimports.moc" diff --git a/tests/benchmarks/declarative/typeimports/typeimports.pro b/tests/benchmarks/declarative/typeimports/typeimports.pro deleted file mode 100644 index 403387f0ce..0000000000 --- a/tests/benchmarks/declarative/typeimports/typeimports.pro +++ /dev/null @@ -1,9 +0,0 @@ -CONFIG += testcase -TEMPLATE = app -TARGET = tst_typeimports -QT += declarative testlib -macx:CONFIG -= app_bundle - -SOURCES += tst_typeimports.cpp - -DEFINES += SRCDIR=\\\"$$PWD\\\" diff --git a/tests/benchmarks/particles/affectors/affectors.pro b/tests/benchmarks/particles/affectors/affectors.pro index 17b23255ac..654f788465 100644 --- a/tests/benchmarks/particles/affectors/affectors.pro +++ b/tests/benchmarks/particles/affectors/affectors.pro @@ -7,4 +7,4 @@ testDataFiles.files = data testDataFiles.path = . DEPLOYMENT += testDataFiles -QT += core-private gui-private v8-private declarative-private quick-private opengl-private testlib +QT += core-private gui-private v8-private qml-private quick-private opengl-private testlib diff --git a/tests/benchmarks/particles/emission/emission.pro b/tests/benchmarks/particles/emission/emission.pro index 343bdf0430..7c00c68c90 100644 --- a/tests/benchmarks/particles/emission/emission.pro +++ b/tests/benchmarks/particles/emission/emission.pro @@ -7,4 +7,4 @@ testDataFiles.files = data testDataFiles.path = . DEPLOYMENT += testDataFiles -QT += core-private gui-private v8-private declarative-private quick-private opengl-private testlib +QT += core-private gui-private v8-private qml-private quick-private opengl-private testlib diff --git a/tests/benchmarks/qml/animation/animation.pro b/tests/benchmarks/qml/animation/animation.pro new file mode 100644 index 0000000000..5efac8da1c --- /dev/null +++ b/tests/benchmarks/qml/animation/animation.pro @@ -0,0 +1,10 @@ +TEMPLATE = app +TARGET = tst_animation +QT += qml +macx:CONFIG -= app_bundle + +SOURCES += tst_animation.cpp + +DEFINES += SRCDIR=\\\"$$PWD\\\" + +QT += testlib core-private gui-private qml-private quick-private v8-private diff --git a/tests/benchmarks/qml/animation/data/animation.qml b/tests/benchmarks/qml/animation/data/animation.qml new file mode 100644 index 0000000000..c48f5ccbe3 --- /dev/null +++ b/tests/benchmarks/qml/animation/data/animation.qml @@ -0,0 +1,75 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +ParallelAnimation { + NumberAnimation {} + NumberAnimation {} + NumberAnimation {} + NumberAnimation {} + NumberAnimation {} + NumberAnimation {} + NumberAnimation {} + NumberAnimation {} + NumberAnimation {} + NumberAnimation {} + NumberAnimation {} + NumberAnimation {} + NumberAnimation {} + NumberAnimation {} + NumberAnimation {} + NumberAnimation {} + NumberAnimation {} + NumberAnimation {} + NumberAnimation {} + NumberAnimation {} + NumberAnimation {} + NumberAnimation {} + NumberAnimation {} + NumberAnimation {} + NumberAnimation {} + NumberAnimation {} + NumberAnimation {} + NumberAnimation {} + NumberAnimation {} + NumberAnimation {} +} diff --git a/tests/benchmarks/qml/animation/tst_animation.cpp b/tests/benchmarks/qml/animation/tst_animation.cpp new file mode 100644 index 0000000000..e5619caa6c --- /dev/null +++ b/tests/benchmarks/qml/animation/tst_animation.cpp @@ -0,0 +1,204 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include +#include +#include +#include +#include + +class tst_animation : public QObject +{ + Q_OBJECT +public: + tst_animation(); + +private slots: + void abstractAnimation(); + void bulkValueAnimator(); + void propertyUpdater(); + + void animationtree_qml(); + + void animationelements_data(); + void animationelements(); + + void numberAnimation(); + void numberAnimationStarted(); + void numberAnimationMultipleTargets(); + void numberAnimationEmpty(); + +private: + QQmlEngine engine; +}; + +tst_animation::tst_animation() +{ +} + +inline QUrl TEST_FILE(const QString &filename) +{ + return QUrl::fromLocalFile(QLatin1String(SRCDIR) + QLatin1String("/data/") + filename); +} + +void tst_animation::abstractAnimation() +{ + QBENCHMARK { + QAbstractAnimationJob *animation = new QAbstractAnimationJob; + delete animation; + } +} + +void tst_animation::bulkValueAnimator() +{ + QBENCHMARK { + QQuickBulkValueAnimator *animator = new QQuickBulkValueAnimator; + delete animator; + } +} + +void tst_animation::propertyUpdater() +{ + QBENCHMARK { + QQuickAnimationPropertyUpdater *updater = new QQuickAnimationPropertyUpdater; + delete updater; + } +} + +void tst_animation::animationtree_qml() +{ + QQmlComponent component(&engine, TEST_FILE("animation.qml")); + QObject *obj = component.create(); + delete obj; + + QBENCHMARK { + QObject *obj = component.create(); + delete obj; + } +} + +void tst_animation::animationelements_data() +{ + QTest::addColumn("type"); + + QSet types = QQmlMetaType::qmlTypeNames().toSet(); + foreach (const QString &type, types) { + if (type.contains(QLatin1String("Animation"))) + QTest::newRow(type.toLatin1()) << type; + } + + QTest::newRow("QtQuick/Behavior") << "QtQuick/Behavior"; + QTest::newRow("QtQuick/Transition") << "QtQuick/Transition"; +} + +void tst_animation::animationelements() +{ + QFETCH(QString, type); + QQmlType *t = QQmlMetaType::qmlType(type, 2, 0); + if (!t || !t->isCreatable()) + QSKIP("Non-creatable type"); + + QBENCHMARK { + QObject *obj = t->create(); + delete obj; + } +} + +void tst_animation::numberAnimation() +{ + QQmlComponent component(&engine); + component.setData("import QtQuick 2.0\nItem { Rectangle { id: rect; NumberAnimation { target: rect; property: \"x\"; to: 100; duration: 500; easing.type: Easing.InOutQuad } } }", QUrl()); + + QObject *obj = component.create(); + delete obj; + + QBENCHMARK { + QObject *obj = component.create(); + delete obj; + } +} + +void tst_animation::numberAnimationStarted() +{ + QQmlComponent component(&engine); + component.setData("import QtQuick 2.0\nItem { Rectangle { id: rect; NumberAnimation { target: rect; property: \"x\"; to: 100; duration: 500; easing.type: Easing.InOutQuad; running: true; paused: true } } }", QUrl()); + + QObject *obj = component.create(); + delete obj; + + QBENCHMARK { + QObject *obj = component.create(); + delete obj; + } +} + +void tst_animation::numberAnimationMultipleTargets() +{ + QQmlComponent component(&engine); + component.setData("import QtQuick 2.0\nItem { Rectangle { id: rect; NumberAnimation { target: rect; properties: \"x,y,z,width,height,implicitWidth,implicitHeight\"; to: 100; duration: 500; easing.type: Easing.InOutQuad; running: true; paused: true } } }", QUrl()); + + QObject *obj = component.create(); + delete obj; + + QBENCHMARK { + QObject *obj = component.create(); + delete obj; + } +} + +void tst_animation::numberAnimationEmpty() +{ + QQmlComponent component(&engine); + component.setData("import QtQuick 2.0\nNumberAnimation { }", QUrl()); + + QObject *obj = component.create(); + delete obj; + + QBENCHMARK { + QObject *obj = component.create(); + delete obj; + } +} + +QTEST_MAIN(tst_animation) + +#include "tst_animation.moc" diff --git a/tests/benchmarks/qml/binding/binding.pro b/tests/benchmarks/qml/binding/binding.pro new file mode 100644 index 0000000000..776c8390a3 --- /dev/null +++ b/tests/benchmarks/qml/binding/binding.pro @@ -0,0 +1,11 @@ +CONFIG += testcase +TEMPLATE = app +TARGET = tst_binding +QT += qml testlib +macx:CONFIG -= app_bundle + +SOURCES += tst_binding.cpp testtypes.cpp +HEADERS += testtypes.h + +# Define SRCDIR equal to test's source directory +DEFINES += SRCDIR=\\\"$$PWD\\\" diff --git a/tests/benchmarks/qml/binding/data/creation.txt b/tests/benchmarks/qml/binding/data/creation.txt new file mode 100644 index 0000000000..05704fa341 --- /dev/null +++ b/tests/benchmarks/qml/binding/data/creation.txt @@ -0,0 +1,9 @@ +import Test 1.0 + +MyQmlObject { + id: myObject + property int myValue: 1 + object: myObject + + result: ### +} diff --git a/tests/benchmarks/qml/binding/data/idproperty.txt b/tests/benchmarks/qml/binding/data/idproperty.txt new file mode 100644 index 0000000000..4e474ba49a --- /dev/null +++ b/tests/benchmarks/qml/binding/data/idproperty.txt @@ -0,0 +1,9 @@ +import Test 1.0 + +MyQmlObject { + id: myObject + + MyQmlObject { + result: ### + } +} diff --git a/tests/benchmarks/qml/binding/data/localproperty.txt b/tests/benchmarks/qml/binding/data/localproperty.txt new file mode 100644 index 0000000000..c7ca0efdb4 --- /dev/null +++ b/tests/benchmarks/qml/binding/data/localproperty.txt @@ -0,0 +1,5 @@ +import Test 1.0 + +MyQmlObject { + result: ### +} diff --git a/tests/benchmarks/qml/binding/data/objectproperty.txt b/tests/benchmarks/qml/binding/data/objectproperty.txt new file mode 100644 index 0000000000..06409f2dd1 --- /dev/null +++ b/tests/benchmarks/qml/binding/data/objectproperty.txt @@ -0,0 +1,8 @@ +import Test 1.0 + +MyQmlObject { + id: myObject + object: myObject + + result: ### +} diff --git a/tests/benchmarks/qml/binding/testtypes.cpp b/tests/benchmarks/qml/binding/testtypes.cpp new file mode 100644 index 0000000000..31af4f15b0 --- /dev/null +++ b/tests/benchmarks/qml/binding/testtypes.cpp @@ -0,0 +1,46 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include "testtypes.h" + +void registerTypes() +{ + qmlRegisterType("Test", 1, 0, "MyQmlObject"); +} diff --git a/tests/benchmarks/qml/binding/testtypes.h b/tests/benchmarks/qml/binding/testtypes.h new file mode 100644 index 0000000000..03542ca24c --- /dev/null +++ b/tests/benchmarks/qml/binding/testtypes.h @@ -0,0 +1,83 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#ifndef TESTTYPES_H +#define TESTTYPES_H + +#include +#include + +class MyQmlObject : public QObject +{ + Q_OBJECT + Q_PROPERTY(int result READ result WRITE setResult) + Q_PROPERTY(int value READ value WRITE setValue NOTIFY valueChanged) + Q_PROPERTY(MyQmlObject *object READ object WRITE setObject NOTIFY objectChanged) + Q_PROPERTY(QQmlListProperty data READ data) + Q_CLASSINFO("DefaultProperty", "data") +public: + MyQmlObject() : m_result(0), m_value(0), m_object(0) {} + + int result() const { return m_result; } + void setResult(int r) { m_result = r; } + + int value() const { return m_value; } + void setValue(int v) { m_value = v; emit valueChanged(); } + + QQmlListProperty data() { return QQmlListProperty(this, m_data); } + + MyQmlObject *object() const { return m_object; } + void setObject(MyQmlObject *o) { m_object = o; emit objectChanged(); } + +signals: + void valueChanged(); + void objectChanged(); + +private: + QList m_data; + int m_result; + int m_value; + MyQmlObject *m_object; +}; +QML_DECLARE_TYPE(MyQmlObject); + +void registerTypes(); + +#endif // TESTTYPES_H diff --git a/tests/benchmarks/qml/binding/tst_binding.cpp b/tests/benchmarks/qml/binding/tst_binding.cpp new file mode 100644 index 0000000000..cd854e06e0 --- /dev/null +++ b/tests/benchmarks/qml/binding/tst_binding.cpp @@ -0,0 +1,188 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include +#include +#include +#include +#include +#include "testtypes.h" + +class tst_binding : public QObject +{ + Q_OBJECT + +public: + tst_binding(); + virtual ~tst_binding(); + +public slots: + void initTestCase(); + void cleanupTestCase(); + +private slots: + void objectproperty_data(); + void objectproperty(); + void basicproperty_data(); + void basicproperty(); + void creation_data(); + void creation(); + +private: + QQmlEngine engine; + MyQmlObject tstObject; +}; + +tst_binding::tst_binding() +{ +} + +tst_binding::~tst_binding() +{ +} + +void tst_binding::initTestCase() +{ + registerTypes(); + engine.rootContext()->setContextProperty("tstObject", &tstObject); +} + +void tst_binding::cleanupTestCase() +{ +} + +#define COMPONENT(filename, binding) \ + QQmlComponent c(&engine); \ + { \ + QFile f(filename); \ + QVERIFY(f.open(QIODevice::ReadOnly)); \ + QByteArray data = f.readAll(); \ + data.replace("###", binding.toUtf8()); \ + c.setData(data, QUrl()); \ + QVERIFY(c.isReady()); \ + } + +void tst_binding::objectproperty_data() +{ + QTest::addColumn("file"); + QTest::addColumn("binding"); + + QTest::newRow("object.value") << SRCDIR "/data/objectproperty.txt" << "object.value"; + QTest::newRow("object.value + 10") << SRCDIR "/data/objectproperty.txt" << "object.value + 10"; +} + +void tst_binding::objectproperty() +{ + QFETCH(QString, file); + QFETCH(QString, binding); + + COMPONENT(file, binding); + + MyQmlObject object1; + MyQmlObject object2; + + MyQmlObject *object = qobject_cast(c.create()); + QVERIFY(object != 0); + object->setObject(&object2); + + QBENCHMARK { + object->setObject(&object1); + object->setObject(&object2); + } +} + +void tst_binding::basicproperty_data() +{ + QTest::addColumn("file"); + QTest::addColumn("binding"); + + QTest::newRow("value") << SRCDIR "/data/localproperty.txt" << "value"; + QTest::newRow("value + 10") << SRCDIR "/data/localproperty.txt" << "value + 10"; + QTest::newRow("value + value + 10") << SRCDIR "/data/localproperty.txt" << "value + value + 10"; + + QTest::newRow("myObject.value") << SRCDIR "/data/idproperty.txt" << "myObject.value"; + QTest::newRow("myObject.value + 10") << SRCDIR "/data/idproperty.txt" << "myObject.value + 10"; + QTest::newRow("myObject.value + myObject.value + 10") << SRCDIR "/data/idproperty.txt" << "myObject.value + myObject.value + 10"; +} + +void tst_binding::basicproperty() +{ + QFETCH(QString, file); + QFETCH(QString, binding); + + COMPONENT(file, binding); + + MyQmlObject *object = qobject_cast(c.create()); + QVERIFY(object != 0); + object->setValue(10); + + QBENCHMARK { + object->setValue(1); + } +} + +void tst_binding::creation_data() +{ + QTest::addColumn("file"); + QTest::addColumn("binding"); + + QTest::newRow("constant") << SRCDIR "/data/creation.txt" << "10"; + QTest::newRow("ownProperty") << SRCDIR "/data/creation.txt" << "myObject.value"; + QTest::newRow("declaredProperty") << SRCDIR "/data/creation.txt" << "myObject.myValue"; + QTest::newRow("contextProperty") << SRCDIR "/data/creation.txt" << "tstObject.value"; +} + +void tst_binding::creation() +{ + QFETCH(QString, file); + QFETCH(QString, binding); + + COMPONENT(file, binding); + + QBENCHMARK { + QObject *o = c.create(); + delete o; + } +} + +QTEST_MAIN(tst_binding) +#include "tst_binding.moc" diff --git a/tests/benchmarks/qml/compilation/compilation.pro b/tests/benchmarks/qml/compilation/compilation.pro new file mode 100644 index 0000000000..4fa9e49918 --- /dev/null +++ b/tests/benchmarks/qml/compilation/compilation.pro @@ -0,0 +1,11 @@ +CONFIG += testcase +TEMPLATE = app +TARGET = tst_compilation +QT += qml qml-private testlib core-private v8-private +macx:CONFIG -= app_bundle + +CONFIG += release + +SOURCES += tst_compilation.cpp + +DEFINES += SRCDIR=\\\"$$PWD\\\" diff --git a/tests/benchmarks/qml/compilation/data/BoomBlock.qml b/tests/benchmarks/qml/compilation/data/BoomBlock.qml new file mode 100644 index 0000000000..65d253e074 --- /dev/null +++ b/tests/benchmarks/qml/compilation/data/BoomBlock.qml @@ -0,0 +1,106 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtQml module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import Qt.labs.particles 1.0 + +Item { + id: block + property bool dying: false + property bool spawned: false + property int type: 0 + property int targetX: 0 + property int targetY: 0 + + SpringFollow on x { enabled: spawned; to: targetX; spring: 2; damping: 0.2 } + SpringFollow on y { to: targetY; spring: 2; damping: 0.2 } + + Image { + id: img + source: { + if(type == 0){ + "pics/redStone.png"; + } else if(type == 1) { + "pics/blueStone.png"; + } else { + "pics/greenStone.png"; + } + } + opacity: 0 + Behavior on opacity { NumberAnimation { duration: 200 } } + anchors.fill: parent + } + + Particles { + id: particles + + width: 1; height: 1 + anchors.centerIn: parent + + emissionRate: 0 + lifeSpan: 700; lifeSpanDeviation: 600 + angle: 0; angleDeviation: 360; + velocity: 100; velocityDeviation: 30 + source: { + if(type == 0){ + "pics/redStar.png"; + } else if (type == 1) { + "pics/blueStar.png"; + } else { + "pics/greenStar.png"; + } + } + } + + states: [ + State { + name: "AliveState"; when: spawned == true && dying == false + PropertyChanges { target: img; opacity: 1 } + }, + + State { + name: "DeathState"; when: dying == true + StateChangeScript { script: particles.burst(50); } + PropertyChanges { target: img; opacity: 0 } + StateChangeScript { script: block.destroy(1000); } + } + ] +} diff --git a/tests/benchmarks/qml/compilation/tst_compilation.cpp b/tests/benchmarks/qml/compilation/tst_compilation.cpp new file mode 100644 index 0000000000..9eeed7e9ed --- /dev/null +++ b/tests/benchmarks/qml/compilation/tst_compilation.cpp @@ -0,0 +1,160 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include + +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +class tst_compilation : public QObject +{ + Q_OBJECT +public: + tst_compilation(); + +private slots: + void boomblock(); + + void jsparser_data(); + void jsparser(); + + void scriptparser_data(); + void scriptparser(); + +private: + QQmlEngine engine; +}; + +tst_compilation::tst_compilation() +{ +} + +inline QUrl TEST_FILE(const QString &filename) +{ + return QUrl::fromLocalFile(QLatin1String(SRCDIR) + QLatin1String("/data/") + filename); +} + +void tst_compilation::boomblock() +{ + QFile f(SRCDIR + QLatin1String("/data/BoomBlock.qml")); + QVERIFY(f.open(QIODevice::ReadOnly)); + QByteArray data = f.readAll(); + + //get rid of initialization effects + { + QQmlComponent c(&engine); + c.setData(data, QUrl()); + } + + QBENCHMARK { + QQmlComponent c(&engine); + c.setData(data, QUrl()); +// QVERIFY(c.isReady()); + } +} + +void tst_compilation::jsparser_data() +{ + QTest::addColumn("file"); + + QTest::newRow("boomblock") << QString(SRCDIR + QLatin1String("/data/BoomBlock.qml")); +} + +void tst_compilation::jsparser() +{ + QFETCH(QString, file); + + QFile f(file); + QVERIFY(f.open(QIODevice::ReadOnly)); + QByteArray data = f.readAll(); + + QTextStream stream(data, QIODevice::ReadOnly); + const QString code = stream.readAll(); + + QBENCHMARK { + QQmlJS::Engine engine; + QQmlJS::NodePool nodePool(file, &engine); + + QQmlJS::Lexer lexer(&engine); + lexer.setCode(code, -1); + + QQmlJS::Parser parser(&engine); + parser.parse(); + parser.ast(); + } +} + +void tst_compilation::scriptparser_data() +{ + QTest::addColumn("file"); + + QTest::newRow("boomblock") << QString(SRCDIR + QLatin1String("/data/BoomBlock.qml")); +} + +void tst_compilation::scriptparser() +{ + QFETCH(QString, file); + + QFile f(file); + QVERIFY(f.open(QIODevice::ReadOnly)); + QByteArray data = f.readAll(); + + QUrl url = QUrl::fromLocalFile(file); + + QBENCHMARK { + QQmlScript::Parser parser; + parser.parse(data, url); + parser.tree(); + } +} + +QTEST_MAIN(tst_compilation) + +#include "tst_compilation.moc" diff --git a/tests/benchmarks/qml/creation/creation.pro b/tests/benchmarks/qml/creation/creation.pro new file mode 100644 index 0000000000..d887a1ffbf --- /dev/null +++ b/tests/benchmarks/qml/creation/creation.pro @@ -0,0 +1,10 @@ +CONFIG += testcase +TEMPLATE = app +TARGET = tst_creation +macx:CONFIG -= app_bundle + +SOURCES += tst_creation.cpp + +DEFINES += SRCDIR=\\\"$$PWD\\\" + +QT += core-private gui-private qml-private qtquick1-private widgets testlib diff --git a/tests/benchmarks/qml/creation/data/item.qml b/tests/benchmarks/qml/creation/data/item.qml new file mode 100644 index 0000000000..af6c2f3f59 --- /dev/null +++ b/tests/benchmarks/qml/creation/data/item.qml @@ -0,0 +1,75 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtQml module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Item { + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} + Item {} +} diff --git a/tests/benchmarks/qml/creation/data/qobject.qml b/tests/benchmarks/qml/creation/data/qobject.qml new file mode 100644 index 0000000000..90620ab35e --- /dev/null +++ b/tests/benchmarks/qml/creation/data/qobject.qml @@ -0,0 +1,45 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtQml module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +QtObject { +} diff --git a/tests/benchmarks/qml/creation/tst_creation.cpp b/tests/benchmarks/qml/creation/tst_creation.cpp new file mode 100644 index 0000000000..6bdaae48fd --- /dev/null +++ b/tests/benchmarks/qml/creation/tst_creation.cpp @@ -0,0 +1,361 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +class tst_creation : public QObject +{ + Q_OBJECT +public: + tst_creation(); + +private slots: + void qobject_cpp(); + void qobject_qml(); + void qobject_qmltype(); + void qobject_alloc(); + + void qobject_10flat_qml(); + void qobject_10flat_cpp(); + + void qobject_10tree_qml(); + void qobject_10tree_cpp(); + + void itemtree_notree_cpp(); + void itemtree_objtree_cpp(); + void itemtree_cpp(); + void itemtree_data_cpp(); + void itemtree_qml(); + void itemtree_scene_cpp(); + + void elements_data(); + void elements(); + +private: + QQmlEngine engine; +}; + +class TestType : public QObject +{ +Q_OBJECT +Q_PROPERTY(QQmlListProperty resources READ resources) +Q_CLASSINFO("DefaultProperty", "resources") +public: + TestType(QObject *parent = 0) + : QObject(parent) {} + + QQmlListProperty resources() { + return QQmlListProperty(this, 0, resources_append); + } + + static void resources_append(QQmlListProperty *p, QObject *o) { + o->setParent(p->object); + } +}; + +tst_creation::tst_creation() +{ + qmlRegisterType("Qt.test", 1, 0, "TestType"); + + //get rid of initialization effects + QDeclarative1TextInput te; +} + +inline QUrl TEST_FILE(const QString &filename) +{ + return QUrl::fromLocalFile(QLatin1String(SRCDIR) + QLatin1String("/data/") + filename); +} + +void tst_creation::qobject_cpp() +{ + QBENCHMARK { + QObject *obj = new QObject; + delete obj; + } +} + +void tst_creation::qobject_qml() +{ + QQmlComponent component(&engine); + component.setData("import QtQuick 2.0\nQtObject {}", QUrl()); + QObject *obj = component.create(); + delete obj; + + QBENCHMARK { + QObject *obj = component.create(); + delete obj; + } +} + +void tst_creation::qobject_10flat_qml() +{ + QQmlComponent component(&engine); + component.setData("import Qt.test 1.0\nTestType { resources: [ TestType{},TestType{},TestType{},TestType{},TestType{},TestType{},TestType{},TestType{},TestType{},TestType{} ] }", QUrl()); + QObject *obj = component.create(); + delete obj; + + QBENCHMARK { + QObject *obj = component.create(); + delete obj; + } +} + +void tst_creation::qobject_10flat_cpp() +{ + QBENCHMARK { + QObject *item = new TestType; + new TestType(item); + new TestType(item); + new TestType(item); + new TestType(item); + new TestType(item); + new TestType(item); + new TestType(item); + new TestType(item); + new TestType(item); + new TestType(item); + delete item; + } +} + +void tst_creation::qobject_10tree_qml() +{ + QQmlComponent component(&engine); + component.setData("import Qt.test 1.0\nTestType { TestType{ TestType { TestType{ TestType{ TestType{ TestType{ TestType{ TestType{ TestType{ TestType{ } } } } } } } } } } }", QUrl()); + + QObject *obj = component.create(); + delete obj; + + QBENCHMARK { + QObject *obj = component.create(); + delete obj; + } +} + +void tst_creation::qobject_10tree_cpp() +{ + QBENCHMARK { + QObject *item = new TestType; + QObject *root = item; + item = new TestType(item); + item = new TestType(item); + item = new TestType(item); + item = new TestType(item); + item = new TestType(item); + item = new TestType(item); + item = new TestType(item); + item = new TestType(item); + item = new TestType(item); + item = new TestType(item); + delete root; + } +} + +void tst_creation::qobject_qmltype() +{ + QQmlType *t = QQmlMetaType::qmlType("QtQuick/QtObject", 2, 0); + + QBENCHMARK { + QObject *obj = t->create(); + delete obj; + } +} + +struct QObjectFakeData { + char data[sizeof(QObjectPrivate)]; +}; + +struct QObjectFake { + QObjectFake(); + virtual ~QObjectFake(); +private: + QObjectFakeData *d; +}; + +QObjectFake::QObjectFake() +{ + d = new QObjectFakeData; +} + +QObjectFake::~QObjectFake() +{ + delete d; +} + +void tst_creation::qobject_alloc() +{ + QBENCHMARK { + QObjectFake *obj = new QObjectFake; + delete obj; + } +} + +struct QQmlGraphics_Derived : public QObject +{ + void setParent_noEvent(QObject *parent) { + bool sce = d_ptr->sendChildEvents; + d_ptr->sendChildEvents = false; + setParent(parent); + d_ptr->sendChildEvents = sce; + } +}; + +inline void QQmlGraphics_setParent_noEvent(QObject *object, QObject *parent) +{ + static_cast(object)->setParent_noEvent(parent); +} + +void tst_creation::itemtree_notree_cpp() +{ + QBENCHMARK { + QQuickItem *item = new QQuickItem; + for (int i = 0; i < 30; ++i) { + QQuickItem *child = new QQuickItem; + Q_UNUSED(child); + } + delete item; + } +} + +void tst_creation::itemtree_objtree_cpp() +{ + QBENCHMARK { + QQuickItem *item = new QQuickItem; + for (int i = 0; i < 30; ++i) { + QQuickItem *child = new QQuickItem; + QQmlGraphics_setParent_noEvent(child,item); + } + delete item; + } +} + +void tst_creation::itemtree_cpp() +{ + QBENCHMARK { + QQuickItem *item = new QQuickItem; + for (int i = 0; i < 30; ++i) { + QQuickItem *child = new QQuickItem; + QQmlGraphics_setParent_noEvent(child,item); + child->setParentItem(item); + } + delete item; + } +} + +void tst_creation::itemtree_data_cpp() +{ + QBENCHMARK { + QQuickItem *item = new QQuickItem; + for (int i = 0; i < 30; ++i) { + QQuickItem *child = new QQuickItem; + QQmlGraphics_setParent_noEvent(child,item); + QQmlListReference ref(item, "data"); + ref.append(child); + } + delete item; + } +} + +void tst_creation::itemtree_qml() +{ + QQmlComponent component(&engine, TEST_FILE("item.qml")); + QObject *obj = component.create(); + delete obj; + + QBENCHMARK { + QObject *obj = component.create(); + delete obj; + } +} + +void tst_creation::itemtree_scene_cpp() +{ + QGraphicsScene scene; + QQuickItem *root = new QQuickItem; + scene.addItem(root); + QBENCHMARK { + QQuickItem *item = new QQuickItem; + for (int i = 0; i < 30; ++i) { + QQuickItem *child = new QQuickItem; + QQmlGraphics_setParent_noEvent(child,item); + child->setParentItem(item); + } + item->setParentItem(root); + delete item; + } + delete root; +} + +void tst_creation::elements_data() +{ + QTest::addColumn("type"); + + QList types = QQmlMetaType::qmlTypeNames(); + foreach (QString type, types) + QTest::newRow(type.toLatin1()) << type; +} + +void tst_creation::elements() +{ + QFETCH(QString, type); + QQmlType *t = QQmlMetaType::qmlType(type, 2, 0); + if (!t || !t->isCreatable()) + QSKIP("Non-creatable type"); + + QBENCHMARK { + QObject *obj = t->create(); + delete obj; + } +} + +QTEST_MAIN(tst_creation) + +#include "tst_creation.moc" diff --git a/tests/benchmarks/qml/holistic/data/dynamicTargets/DynamicFour.qml b/tests/benchmarks/qml/holistic/data/dynamicTargets/DynamicFour.qml new file mode 100644 index 0000000000..ccccc371ac --- /dev/null +++ b/tests/benchmarks/qml/holistic/data/dynamicTargets/DynamicFour.qml @@ -0,0 +1,78 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Item { + id: root + property int dynamicWidth: 100 + property int dynamicHeight: rect1.height + rect2.height + property int widthSignaledProperty: 10 + property int heightSignaledProperty: 10 + + Rectangle { + id: rect1 + width: root.dynamicWidth + 20 + height: width + (5*3) - 8 + (width/9) + color: "red" + border.color: "black" + border.width: 5 + radius: 10 + } + + Rectangle { + id: rect2 + width: rect1.width - 50 + height: width + (5*4) - 6 + (width/3) + color: "red" + border.color: "black" + border.width: 5 + radius: 10 + } + + onDynamicWidthChanged: { + widthSignaledProperty = widthSignaledProperty + (6*5) - 2; + } + + onDynamicHeightChanged: { + heightSignaledProperty = widthSignaledProperty + heightSignaledProperty + (5*3) - 7; + } +} diff --git a/tests/benchmarks/qml/holistic/data/dynamicTargets/DynamicOne.qml b/tests/benchmarks/qml/holistic/data/dynamicTargets/DynamicOne.qml new file mode 100644 index 0000000000..154f9db9a3 --- /dev/null +++ b/tests/benchmarks/qml/holistic/data/dynamicTargets/DynamicOne.qml @@ -0,0 +1,56 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Item { + id: root + property int dynamicWidth: 10 + + Rectangle { + width: 100 + height: root.dynamicWidth + (5*3) - 8 + (root.dynamicWidth/10) + color: "red" + border.color: "black" + border.width: 5 + radius: 10 + } +} diff --git a/tests/benchmarks/qml/holistic/data/dynamicTargets/DynamicThree.qml b/tests/benchmarks/qml/holistic/data/dynamicTargets/DynamicThree.qml new file mode 100644 index 0000000000..064ba57254 --- /dev/null +++ b/tests/benchmarks/qml/holistic/data/dynamicTargets/DynamicThree.qml @@ -0,0 +1,61 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Item { + id: root + property int dynamicWidth: 10 + property int widthSignaledProperty: 20 + + Rectangle { + width: 100 + height: root.dynamicWidth + (5*3) - 8 + (root.dynamicWidth/10) + color: "red" + border.color: "black" + border.width: 5 + radius: 10 + } + + onDynamicWidthChanged: { + widthSignaledProperty = dynamicWidth + (20/4) + 7 - 1; + } +} diff --git a/tests/benchmarks/qml/holistic/data/dynamicTargets/DynamicTwo.qml b/tests/benchmarks/qml/holistic/data/dynamicTargets/DynamicTwo.qml new file mode 100644 index 0000000000..a3aac3ebd6 --- /dev/null +++ b/tests/benchmarks/qml/holistic/data/dynamicTargets/DynamicTwo.qml @@ -0,0 +1,68 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Item { + id: root + property int dynamicWidth: 100 + property int dynamicHeight: rect1.height + rect2.height + + Rectangle { + id: rect1 + width: root.dynamicWidth + 20 + height: width + (5*3) - 8 + (width/9) + color: "red" + border.color: "black" + border.width: 5 + radius: 10 + } + + Rectangle { + id: rect2 + width: rect1.width - 50 + height: width + (5*4) - 6 + (width/3) + color: "red" + border.color: "black" + border.width: 5 + radius: 10 + } +} diff --git a/tests/benchmarks/qml/holistic/data/jsImports/Mlbsi.qml b/tests/benchmarks/qml/holistic/data/jsImports/Mlbsi.qml new file mode 100644 index 0000000000..854cc3258d --- /dev/null +++ b/tests/benchmarks/qml/holistic/data/jsImports/Mlbsi.qml @@ -0,0 +1,49 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +import "mlbsi.js" as MlbsiJs + +Item { + id: testQtObject + property int importedScriptFunctionValue: MlbsiJs.testFunc(20) +} diff --git a/tests/benchmarks/qml/holistic/data/jsImports/Mldsi.qml b/tests/benchmarks/qml/holistic/data/jsImports/Mldsi.qml new file mode 100644 index 0000000000..919fce1c46 --- /dev/null +++ b/tests/benchmarks/qml/holistic/data/jsImports/Mldsi.qml @@ -0,0 +1,49 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +import "mldsi.js" as MldsiJs + +Item { + id: testQtObject + property int importedScriptFunctionValue: MldsiJs.testFunc(20) +} diff --git a/tests/benchmarks/qml/holistic/data/jsImports/Mlsi.qml b/tests/benchmarks/qml/holistic/data/jsImports/Mlsi.qml new file mode 100644 index 0000000000..74451f85fd --- /dev/null +++ b/tests/benchmarks/qml/holistic/data/jsImports/Mlsi.qml @@ -0,0 +1,49 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +import "mlsi.js" as MlsiJs + +Item { + id: testQtObject + property int importedScriptFunctionValue: MlsiJs.testFunc(20) +} diff --git a/tests/benchmarks/qml/holistic/data/jsImports/ModuleBm.qml b/tests/benchmarks/qml/holistic/data/jsImports/ModuleBm.qml new file mode 100644 index 0000000000..18ef8a2599 --- /dev/null +++ b/tests/benchmarks/qml/holistic/data/jsImports/ModuleBm.qml @@ -0,0 +1,49 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +import "moduleBm.js" as ModuleBmJs + +Item { + id: testQtObject + property int importedScriptFunctionValue: ModuleBmJs.testFunc(20) +} diff --git a/tests/benchmarks/qml/holistic/data/jsImports/Msbsi.qml b/tests/benchmarks/qml/holistic/data/jsImports/Msbsi.qml new file mode 100644 index 0000000000..d7a8b74dd1 --- /dev/null +++ b/tests/benchmarks/qml/holistic/data/jsImports/Msbsi.qml @@ -0,0 +1,49 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +import "msbsi.js" as MsbsiJs + +Item { + id: testQtObject + property int importedScriptFunctionValue: MsbsiJs.testFunc(20) +} diff --git a/tests/benchmarks/qml/holistic/data/jsImports/Msdsi.qml b/tests/benchmarks/qml/holistic/data/jsImports/Msdsi.qml new file mode 100644 index 0000000000..266a26ef8e --- /dev/null +++ b/tests/benchmarks/qml/holistic/data/jsImports/Msdsi.qml @@ -0,0 +1,49 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +import "msdsi.js" as MsdsiJs + +Item { + id: testQtObject + property int importedScriptFunctionValue: MsdsiJs.testFunc(20) +} diff --git a/tests/benchmarks/qml/holistic/data/jsImports/Mssi.qml b/tests/benchmarks/qml/holistic/data/jsImports/Mssi.qml new file mode 100644 index 0000000000..e589981252 --- /dev/null +++ b/tests/benchmarks/qml/holistic/data/jsImports/Mssi.qml @@ -0,0 +1,49 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +import "mssi.js" as MssiJs + +Item { + id: testQtObject + property int importedScriptFunctionValue: MssiJs.testFunc(20) +} diff --git a/tests/benchmarks/qml/holistic/data/jsImports/PragmaBm.qml b/tests/benchmarks/qml/holistic/data/jsImports/PragmaBm.qml new file mode 100644 index 0000000000..f5753af88b --- /dev/null +++ b/tests/benchmarks/qml/holistic/data/jsImports/PragmaBm.qml @@ -0,0 +1,55 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +import "pragmaBmOne.js" as PragmaBmOneJs +import "pragmaBmTwo.js" as PragmaBmTwoJs + +Item { + id: testQtObject + + // value = 20 + 2 + 9 + (nbr times shared testFunc has been called previously == 0) + property int importedScriptFunctionValueOne: PragmaBmOneJs.testFuncOne(20) + + // value = 20 + 3 + 9 + (nbr times shared testFunc has been called previously == 1) + property int importedScriptFunctionValueTwo: PragmaBmTwoJs.testFuncTwo(20) +} diff --git a/tests/benchmarks/qml/holistic/data/jsImports/PragmaModuleBm.qml b/tests/benchmarks/qml/holistic/data/jsImports/PragmaModuleBm.qml new file mode 100644 index 0000000000..8e1baa8572 --- /dev/null +++ b/tests/benchmarks/qml/holistic/data/jsImports/PragmaModuleBm.qml @@ -0,0 +1,51 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +import "pragmaModuleBm.js" as PragmaModuleBmJs + +Item { + id: testQtObject + + // value = 20 + (Qt.test.Enum3 == 2) + 9 + (nbr times shared testFunc has been called previously = 0) + 9 + (nbr times shared testFunc has been called previously = 1) + property int importedScriptFunctionValue: PragmaModuleBmJs.testFuncThree(20) +} diff --git a/tests/benchmarks/qml/holistic/data/jsImports/Slsi.qml b/tests/benchmarks/qml/holistic/data/jsImports/Slsi.qml new file mode 100644 index 0000000000..aa21358b47 --- /dev/null +++ b/tests/benchmarks/qml/holistic/data/jsImports/Slsi.qml @@ -0,0 +1,49 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +import "slsi.js" as SlsiJs + +Item { + id: testQtObject + property int importedScriptFunctionValue: SlsiJs.testFunc(20) +} diff --git a/tests/benchmarks/qml/holistic/data/jsImports/Sssi.qml b/tests/benchmarks/qml/holistic/data/jsImports/Sssi.qml new file mode 100644 index 0000000000..0ed7a3ee72 --- /dev/null +++ b/tests/benchmarks/qml/holistic/data/jsImports/Sssi.qml @@ -0,0 +1,49 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +import "sssi.js" as SssiJs + +Item { + id: testQtObject + property int importedScriptFunctionValue: SssiJs.testFunc(20) +} diff --git a/tests/benchmarks/qml/holistic/data/jsImports/mlbsi.js b/tests/benchmarks/qml/holistic/data/jsImports/mlbsi.js new file mode 100644 index 0000000000..36a5fea77f --- /dev/null +++ b/tests/benchmarks/qml/holistic/data/jsImports/mlbsi.js @@ -0,0 +1,133 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +// This JavaScript file is a single, small, imported script. +// It imports many other (non-nested) single, small, scripts. + +.import "mlbsi1.js" as Mlbsi1 +.import "mlbsi2.js" as Mlbsi2 +.import "mlbsi3.js" as Mlbsi3 +.import "mlbsi4.js" as Mlbsi4 +.import "mlbsi5.js" as Mlbsi5 +.import "mlbsi6.js" as Mlbsi6 +.import "mlbsi7.js" as Mlbsi7 +.import "mlbsi8.js" as Mlbsi8 +.import "mlbsi9.js" as Mlbsi9 +.import "mlbsi10.js" as Mlbsi10 +.import "mlbsi11.js" as Mlbsi11 +.import "mlbsi12.js" as Mlbsi12 +.import "mlbsi13.js" as Mlbsi13 +.import "mlbsi14.js" as Mlbsi14 +.import "mlbsi15.js" as Mlbsi15 + +function testFunc(seedValue) { + var firstFactor = calculateFirstFactor(seedValue); + var secondFactor = calculateSecondFactor(seedValue); + var modificationTerm = calculateModificationTerm(seedValue); + + // do some regexp matching + var someString = "This is a random string which we'll perform regular expression matching on to reduce considerably. This is meant to be part of a complex javascript expression whose evaluation takes considerably longer than the creation cost of QScriptValue."; + var regexpPattern = new RegExp("is", "i"); + var regexpOutputLength = 0; + var temp = regexpPattern.exec(someString); + while (temp == "is") { + regexpOutputLength += 4; + regexpOutputLength *= 2; + temp = regexpPattern.exec(someString); + if (regexpOutputLength > (seedValue * 3)) { + temp = "break"; + } + } + + // spin in a for loop for a while + var i = 0; + var j = 0; + var cumulativeTotal = 3; + for (i = 20; i > 1; i--) { + for (j = 31; j > 5; j--) { + var branchVariable = i + j; + if (branchVariable % 3 == 0) { + cumulativeTotal -= secondFactor; + } else { + cumulativeTotal += firstFactor; + } + + if (cumulativeTotal > (seedValue * 50)) { + break; + } + } + } + var retn = cumulativeTotal * 0.53; + retn += Mlbsi1.testFunc(seedValue); + retn += Mlbsi2.testFunc(seedValue); + retn += Mlbsi3.testFunc(seedValue); + retn += Mlbsi4.testFunc(seedValue); + retn += Mlbsi5.testFunc(seedValue); + retn += Mlbsi6.testFunc(retn); + retn += Mlbsi7.testFunc(seedValue); + retn += Mlbsi8.testFunc(seedValue); + retn += Mlbsi9.testFunc(retn); + retn += Mlbsi10.testFunc(seedValue); + retn += Mlbsi11.testFunc(seedValue); + retn += Mlbsi12.testFunc(seedValue); + retn += Mlbsi13.testFunc(seedValue); + retn += Mlbsi14.testFunc(seedValue); + retn += Mlbsi15.testFunc(seedValue); + return retn; +} + +function calculateFirstFactor(seedValue) { + var firstFactor = (0.45 * (9.3 / 3.1) - 0.90); + firstFactor *= (1 + (0.000017 / seedValue)); + return firstFactor; +} + +function calculateSecondFactor(seedValue) { + var secondFactor = 0.78 * (6.3 / 2.1) - (0.39 * 4); + secondFactor *= (1 + (0.000017 / seedValue)); + return secondFactor; +} + +function calculateModificationTerm(seedValue) { + var modificationTerm = (12 + (9*7) - 54 + 16 - ((calculateFirstFactor(seedValue) * seedValue) / 3) + (4*calculateSecondFactor(seedValue) * seedValue * 1.33)) + (calculateSecondFactor(seedValue) * seedValue); + modificationTerm = modificationTerm + (33/2) + 19 - (9*2) - (61*3) + 177; + return modificationTerm; +} diff --git a/tests/benchmarks/qml/holistic/data/jsImports/mlbsi1.js b/tests/benchmarks/qml/holistic/data/jsImports/mlbsi1.js new file mode 100644 index 0000000000..459451609b --- /dev/null +++ b/tests/benchmarks/qml/holistic/data/jsImports/mlbsi1.js @@ -0,0 +1,108 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +// This JavaScript file is a single, large, imported script. +// It doesn't import any other scripts. +// It is imported from another script. + +function testFunc(seedValue) { + var retn = 5; + retn += (seedValue * 0.145); + var firstFactor = calculateFirstFactor(seedValue); + var secondFactor = calculateSecondFactor(seedValue); + var modificationTerm = calculateModificationTerm(seedValue); + + // do some regexp matching + var someString = "This is a random string which we'll perform regular expression matching on to reduce considerably. This is meant to be part of a complex javascript expression whose evaluation takes considerably longer than the creation cost of QScriptValue."; + var regexpPattern = new RegExp("is", "i"); + var regexpOutputLength = 0; + var temp = regexpPattern.exec(someString); + while (temp == "is") { + regexpOutputLength += 4; + regexpOutputLength *= 2; + temp = regexpPattern.exec(someString); + if (regexpOutputLength > (seedValue * 3)) { + temp = "break"; + } + } + + // spin in a for loop for a while + var i = 0; + var j = 0; + var cumulativeTotal = 3; + for (i = 20; i > 1; i--) { + for (j = 31; j > 5; j--) { + var branchVariable = i + j; + if (branchVariable % 3 == 0) { + cumulativeTotal -= secondFactor; + } else { + cumulativeTotal += firstFactor; + } + + if (cumulativeTotal > (seedValue * 50)) { + break; + } + } + } + retn *= (1 + (cumulativeTotal * 0.001)); + retn *= (1 + (3.1415962 / seedValue)); + retn /= 2.41497; + retn -= (seedValue * -1); + return retn; +} + +function calculateFirstFactor(seedValue) { + var firstFactor = (0.45 * (9.3 / 3.1) - 0.90); + firstFactor *= (1 + (0.00001 / seedValue)); + return firstFactor; +} + +function calculateSecondFactor(seedValue) { + var secondFactor = 0.78 * (6.3 / 2.1) - (0.39 * 4); + secondFactor *= (1 + (0.00001 / seedValue)); + return secondFactor; +} + +function calculateModificationTerm(seedValue) { + var modificationTerm = (12 + (9*7) - 54 + 16 - ((calculateFirstFactor(seedValue) * seedValue) / 3) + (4*calculateSecondFactor(seedValue) * seedValue * 1.33)) + (calculateSecondFactor(seedValue) * seedValue); + modificationTerm = modificationTerm + (33/2) + 19 - (9*2) - (61*3) + 177; + return modificationTerm; +} diff --git a/tests/benchmarks/qml/holistic/data/jsImports/mlbsi10.js b/tests/benchmarks/qml/holistic/data/jsImports/mlbsi10.js new file mode 100644 index 0000000000..69202e63eb --- /dev/null +++ b/tests/benchmarks/qml/holistic/data/jsImports/mlbsi10.js @@ -0,0 +1,108 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +// This JavaScript file is a single, large, imported script. +// It doesn't import any other scripts. +// It is imported from another script. + +function testFunc(seedValue) { + var retn = 5; + retn += (seedValue * 0.1045); + var firstFactor = calculateFirstFactor(seedValue); + var secondFactor = calculateSecondFactor(seedValue); + var modificationTerm = calculateModificationTerm(seedValue); + + // do some regexp matching + var someString = "This is a random string which we'll perform regular expression matching on to reduce considerably. This is meant to be part of a complex javascript expression whose evaluation takes considerably longer than the creation cost of QScriptValue."; + var regexpPattern = new RegExp("is", "i"); + var regexpOutputLength = 0; + var temp = regexpPattern.exec(someString); + while (temp == "is") { + regexpOutputLength += 4; + regexpOutputLength *= 2; + temp = regexpPattern.exec(someString); + if (regexpOutputLength > (seedValue * 3)) { + temp = "break"; + } + } + + // spin in a for loop for a while + var i = 0; + var j = 0; + var cumulativeTotal = 3; + for (i = 20; i > 1; i--) { + for (j = 31; j > 5; j--) { + var branchVariable = i + j; + if (branchVariable % 3 == 0) { + cumulativeTotal -= secondFactor; + } else { + cumulativeTotal += firstFactor; + } + + if (cumulativeTotal > (seedValue * 50)) { + break; + } + } + } + retn *= (1 + (cumulativeTotal * 0.001)); + retn *= (1 + (3.1415962 / seedValue)); + retn /= 2.41497; + retn -= (seedValue * -1); + return retn; +} + +function calculateFirstFactor(seedValue) { + var firstFactor = (0.45 * (9.3 / 3.1) - 0.90); + firstFactor *= (1 + (0.000010 / seedValue)); + return firstFactor; +} + +function calculateSecondFactor(seedValue) { + var secondFactor = 0.78 * (6.3 / 2.1) - (0.39 * 4); + secondFactor *= (1 + (0.000010 / seedValue)); + return secondFactor; +} + +function calculateModificationTerm(seedValue) { + var modificationTerm = (12 + (9*7) - 54 + 16 - ((calculateFirstFactor(seedValue) * seedValue) / 3) + (4*calculateSecondFactor(seedValue) * seedValue * 1.33)) + (calculateSecondFactor(seedValue) * seedValue); + modificationTerm = modificationTerm + (33/2) + 19 - (9*2) - (61*3) + 177; + return modificationTerm; +} diff --git a/tests/benchmarks/qml/holistic/data/jsImports/mlbsi11.js b/tests/benchmarks/qml/holistic/data/jsImports/mlbsi11.js new file mode 100644 index 0000000000..9f3e28a1f6 --- /dev/null +++ b/tests/benchmarks/qml/holistic/data/jsImports/mlbsi11.js @@ -0,0 +1,108 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +// This JavaScript file is a single, large, imported script. +// It doesn't import any other scripts. +// It is imported from another script. + +function testFunc(seedValue) { + var retn = 5; + retn += (seedValue * 0.1145); + var firstFactor = calculateFirstFactor(seedValue); + var secondFactor = calculateSecondFactor(seedValue); + var modificationTerm = calculateModificationTerm(seedValue); + + // do some regexp matching + var someString = "This is a random string which we'll perform regular expression matching on to reduce considerably. This is meant to be part of a complex javascript expression whose evaluation takes considerably longer than the creation cost of QScriptValue."; + var regexpPattern = new RegExp("is", "i"); + var regexpOutputLength = 0; + var temp = regexpPattern.exec(someString); + while (temp == "is") { + regexpOutputLength += 4; + regexpOutputLength *= 2; + temp = regexpPattern.exec(someString); + if (regexpOutputLength > (seedValue * 3)) { + temp = "break"; + } + } + + // spin in a for loop for a while + var i = 0; + var j = 0; + var cumulativeTotal = 3; + for (i = 20; i > 1; i--) { + for (j = 31; j > 5; j--) { + var branchVariable = i + j; + if (branchVariable % 3 == 0) { + cumulativeTotal -= secondFactor; + } else { + cumulativeTotal += firstFactor; + } + + if (cumulativeTotal > (seedValue * 50)) { + break; + } + } + } + retn *= (1 + (cumulativeTotal * 0.001)); + retn *= (1 + (3.1415962 / seedValue)); + retn /= 2.41497; + retn -= (seedValue * -1); + return retn; +} + +function calculateFirstFactor(seedValue) { + var firstFactor = (0.45 * (9.3 / 3.1) - 0.90); + firstFactor *= (1 + (0.000011 / seedValue)); + return firstFactor; +} + +function calculateSecondFactor(seedValue) { + var secondFactor = 0.78 * (6.3 / 2.1) - (0.39 * 4); + secondFactor *= (1 + (0.000011 / seedValue)); + return secondFactor; +} + +function calculateModificationTerm(seedValue) { + var modificationTerm = (12 + (9*7) - 54 + 16 - ((calculateFirstFactor(seedValue) * seedValue) / 3) + (4*calculateSecondFactor(seedValue) * seedValue * 1.33)) + (calculateSecondFactor(seedValue) * seedValue); + modificationTerm = modificationTerm + (33/2) + 19 - (9*2) - (61*3) + 177; + return modificationTerm; +} diff --git a/tests/benchmarks/qml/holistic/data/jsImports/mlbsi12.js b/tests/benchmarks/qml/holistic/data/jsImports/mlbsi12.js new file mode 100644 index 0000000000..349c7cdd3f --- /dev/null +++ b/tests/benchmarks/qml/holistic/data/jsImports/mlbsi12.js @@ -0,0 +1,108 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +// This JavaScript file is a single, large, imported script. +// It doesn't import any other scripts. +// It is imported from another script. + +function testFunc(seedValue) { + var retn = 5; + retn += (seedValue * 0.1245); + var firstFactor = calculateFirstFactor(seedValue); + var secondFactor = calculateSecondFactor(seedValue); + var modificationTerm = calculateModificationTerm(seedValue); + + // do some regexp matching + var someString = "This is a random string which we'll perform regular expression matching on to reduce considerably. This is meant to be part of a complex javascript expression whose evaluation takes considerably longer than the creation cost of QScriptValue."; + var regexpPattern = new RegExp("is", "i"); + var regexpOutputLength = 0; + var temp = regexpPattern.exec(someString); + while (temp == "is") { + regexpOutputLength += 4; + regexpOutputLength *= 2; + temp = regexpPattern.exec(someString); + if (regexpOutputLength > (seedValue * 3)) { + temp = "break"; + } + } + + // spin in a for loop for a while + var i = 0; + var j = 0; + var cumulativeTotal = 3; + for (i = 20; i > 1; i--) { + for (j = 31; j > 5; j--) { + var branchVariable = i + j; + if (branchVariable % 3 == 0) { + cumulativeTotal -= secondFactor; + } else { + cumulativeTotal += firstFactor; + } + + if (cumulativeTotal > (seedValue * 50)) { + break; + } + } + } + retn *= (1 + (cumulativeTotal * 0.001)); + retn *= (1 + (3.1415962 / seedValue)); + retn /= 2.41497; + retn -= (seedValue * -1); + return retn; +} + +function calculateFirstFactor(seedValue) { + var firstFactor = (0.45 * (9.3 / 3.1) - 0.90); + firstFactor *= (1 + (0.000012 / seedValue)); + return firstFactor; +} + +function calculateSecondFactor(seedValue) { + var secondFactor = 0.78 * (6.3 / 2.1) - (0.39 * 4); + secondFactor *= (1 + (0.000012 / seedValue)); + return secondFactor; +} + +function calculateModificationTerm(seedValue) { + var modificationTerm = (12 + (9*7) - 54 + 16 - ((calculateFirstFactor(seedValue) * seedValue) / 3) + (4*calculateSecondFactor(seedValue) * seedValue * 1.33)) + (calculateSecondFactor(seedValue) * seedValue); + modificationTerm = modificationTerm + (33/2) + 19 - (9*2) - (61*3) + 177; + return modificationTerm; +} diff --git a/tests/benchmarks/qml/holistic/data/jsImports/mlbsi13.js b/tests/benchmarks/qml/holistic/data/jsImports/mlbsi13.js new file mode 100644 index 0000000000..925178fadb --- /dev/null +++ b/tests/benchmarks/qml/holistic/data/jsImports/mlbsi13.js @@ -0,0 +1,108 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +// This JavaScript file is a single, large, imported script. +// It doesn't import any other scripts. +// It is imported from another script. + +function testFunc(seedValue) { + var retn = 5; + retn += (seedValue * 0.1345); + var firstFactor = calculateFirstFactor(seedValue); + var secondFactor = calculateSecondFactor(seedValue); + var modificationTerm = calculateModificationTerm(seedValue); + + // do some regexp matching + var someString = "This is a random string which we'll perform regular expression matching on to reduce considerably. This is meant to be part of a complex javascript expression whose evaluation takes considerably longer than the creation cost of QScriptValue."; + var regexpPattern = new RegExp("is", "i"); + var regexpOutputLength = 0; + var temp = regexpPattern.exec(someString); + while (temp == "is") { + regexpOutputLength += 4; + regexpOutputLength *= 2; + temp = regexpPattern.exec(someString); + if (regexpOutputLength > (seedValue * 3)) { + temp = "break"; + } + } + + // spin in a for loop for a while + var i = 0; + var j = 0; + var cumulativeTotal = 3; + for (i = 20; i > 1; i--) { + for (j = 31; j > 5; j--) { + var branchVariable = i + j; + if (branchVariable % 3 == 0) { + cumulativeTotal -= secondFactor; + } else { + cumulativeTotal += firstFactor; + } + + if (cumulativeTotal > (seedValue * 50)) { + break; + } + } + } + retn *= (1 + (cumulativeTotal * 0.001)); + retn *= (1 + (3.1415962 / seedValue)); + retn /= 2.41497; + retn -= (seedValue * -1); + return retn; +} + +function calculateFirstFactor(seedValue) { + var firstFactor = (0.45 * (9.3 / 3.1) - 0.90); + firstFactor *= (1 + (0.000013 / seedValue)); + return firstFactor; +} + +function calculateSecondFactor(seedValue) { + var secondFactor = 0.78 * (6.3 / 2.1) - (0.39 * 4); + secondFactor *= (1 + (0.000013 / seedValue)); + return secondFactor; +} + +function calculateModificationTerm(seedValue) { + var modificationTerm = (12 + (9*7) - 54 + 16 - ((calculateFirstFactor(seedValue) * seedValue) / 3) + (4*calculateSecondFactor(seedValue) * seedValue * 1.33)) + (calculateSecondFactor(seedValue) * seedValue); + modificationTerm = modificationTerm + (33/2) + 19 - (9*2) - (61*3) + 177; + return modificationTerm; +} diff --git a/tests/benchmarks/qml/holistic/data/jsImports/mlbsi14.js b/tests/benchmarks/qml/holistic/data/jsImports/mlbsi14.js new file mode 100644 index 0000000000..25f17ca1b8 --- /dev/null +++ b/tests/benchmarks/qml/holistic/data/jsImports/mlbsi14.js @@ -0,0 +1,108 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +// This JavaScript file is a single, large, imported script. +// It doesn't import any other scripts. +// It is imported from another script. + +function testFunc(seedValue) { + var retn = 5; + retn += (seedValue * 0.1445); + var firstFactor = calculateFirstFactor(seedValue); + var secondFactor = calculateSecondFactor(seedValue); + var modificationTerm = calculateModificationTerm(seedValue); + + // do some regexp matching + var someString = "This is a random string which we'll perform regular expression matching on to reduce considerably. This is meant to be part of a complex javascript expression whose evaluation takes considerably longer than the creation cost of QScriptValue."; + var regexpPattern = new RegExp("is", "i"); + var regexpOutputLength = 0; + var temp = regexpPattern.exec(someString); + while (temp == "is") { + regexpOutputLength += 4; + regexpOutputLength *= 2; + temp = regexpPattern.exec(someString); + if (regexpOutputLength > (seedValue * 3)) { + temp = "break"; + } + } + + // spin in a for loop for a while + var i = 0; + var j = 0; + var cumulativeTotal = 3; + for (i = 20; i > 1; i--) { + for (j = 31; j > 5; j--) { + var branchVariable = i + j; + if (branchVariable % 3 == 0) { + cumulativeTotal -= secondFactor; + } else { + cumulativeTotal += firstFactor; + } + + if (cumulativeTotal > (seedValue * 50)) { + break; + } + } + } + retn *= (1 + (cumulativeTotal * 0.001)); + retn *= (1 + (3.1415962 / seedValue)); + retn /= 2.41497; + retn -= (seedValue * -1); + return retn; +} + +function calculateFirstFactor(seedValue) { + var firstFactor = (0.45 * (9.3 / 3.1) - 0.90); + firstFactor *= (1 + (0.000014 / seedValue)); + return firstFactor; +} + +function calculateSecondFactor(seedValue) { + var secondFactor = 0.78 * (6.3 / 2.1) - (0.39 * 4); + secondFactor *= (1 + (0.000014 / seedValue)); + return secondFactor; +} + +function calculateModificationTerm(seedValue) { + var modificationTerm = (12 + (9*7) - 54 + 16 - ((calculateFirstFactor(seedValue) * seedValue) / 3) + (4*calculateSecondFactor(seedValue) * seedValue * 1.33)) + (calculateSecondFactor(seedValue) * seedValue); + modificationTerm = modificationTerm + (33/2) + 19 - (9*2) - (61*3) + 177; + return modificationTerm; +} diff --git a/tests/benchmarks/qml/holistic/data/jsImports/mlbsi15.js b/tests/benchmarks/qml/holistic/data/jsImports/mlbsi15.js new file mode 100644 index 0000000000..9445222cd9 --- /dev/null +++ b/tests/benchmarks/qml/holistic/data/jsImports/mlbsi15.js @@ -0,0 +1,108 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +// This JavaScript file is a single, large, imported script. +// It doesn't import any other scripts. +// It is imported from another script. + +function testFunc(seedValue) { + var retn = 5; + retn += (seedValue * 0.1545); + var firstFactor = calculateFirstFactor(seedValue); + var secondFactor = calculateSecondFactor(seedValue); + var modificationTerm = calculateModificationTerm(seedValue); + + // do some regexp matching + var someString = "This is a random string which we'll perform regular expression matching on to reduce considerably. This is meant to be part of a complex javascript expression whose evaluation takes considerably longer than the creation cost of QScriptValue."; + var regexpPattern = new RegExp("is", "i"); + var regexpOutputLength = 0; + var temp = regexpPattern.exec(someString); + while (temp == "is") { + regexpOutputLength += 4; + regexpOutputLength *= 2; + temp = regexpPattern.exec(someString); + if (regexpOutputLength > (seedValue * 3)) { + temp = "break"; + } + } + + // spin in a for loop for a while + var i = 0; + var j = 0; + var cumulativeTotal = 3; + for (i = 20; i > 1; i--) { + for (j = 31; j > 5; j--) { + var branchVariable = i + j; + if (branchVariable % 3 == 0) { + cumulativeTotal -= secondFactor; + } else { + cumulativeTotal += firstFactor; + } + + if (cumulativeTotal > (seedValue * 50)) { + break; + } + } + } + retn *= (1 + (cumulativeTotal * 0.001)); + retn *= (1 + (3.1415962 / seedValue)); + retn /= 2.41497; + retn -= (seedValue * -1); + return retn; +} + +function calculateFirstFactor(seedValue) { + var firstFactor = (0.45 * (9.3 / 3.1) - 0.90); + firstFactor *= (1 + (0.000015 / seedValue)); + return firstFactor; +} + +function calculateSecondFactor(seedValue) { + var secondFactor = 0.78 * (6.3 / 2.1) - (0.39 * 4); + secondFactor *= (1 + (0.000015 / seedValue)); + return secondFactor; +} + +function calculateModificationTerm(seedValue) { + var modificationTerm = (12 + (9*7) - 54 + 16 - ((calculateFirstFactor(seedValue) * seedValue) / 3) + (4*calculateSecondFactor(seedValue) * seedValue * 1.33)) + (calculateSecondFactor(seedValue) * seedValue); + modificationTerm = modificationTerm + (33/2) + 19 - (9*2) - (61*3) + 177; + return modificationTerm; +} diff --git a/tests/benchmarks/qml/holistic/data/jsImports/mlbsi2.js b/tests/benchmarks/qml/holistic/data/jsImports/mlbsi2.js new file mode 100644 index 0000000000..f375c57663 --- /dev/null +++ b/tests/benchmarks/qml/holistic/data/jsImports/mlbsi2.js @@ -0,0 +1,108 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +// This JavaScript file is a single, large, imported script. +// It doesn't import any other scripts. +// It is imported from another script. + +function testFunc(seedValue) { + var retn = 5; + retn += (seedValue * 0.245); + var firstFactor = calculateFirstFactor(seedValue); + var secondFactor = calculateSecondFactor(seedValue); + var modificationTerm = calculateModificationTerm(seedValue); + + // do some regexp matching + var someString = "This is a random string which we'll perform regular expression matching on to reduce considerably. This is meant to be part of a complex javascript expression whose evaluation takes considerably longer than the creation cost of QScriptValue."; + var regexpPattern = new RegExp("is", "i"); + var regexpOutputLength = 0; + var temp = regexpPattern.exec(someString); + while (temp == "is") { + regexpOutputLength += 4; + regexpOutputLength *= 2; + temp = regexpPattern.exec(someString); + if (regexpOutputLength > (seedValue * 3)) { + temp = "break"; + } + } + + // spin in a for loop for a while + var i = 0; + var j = 0; + var cumulativeTotal = 3; + for (i = 20; i > 1; i--) { + for (j = 31; j > 5; j--) { + var branchVariable = i + j; + if (branchVariable % 3 == 0) { + cumulativeTotal -= secondFactor; + } else { + cumulativeTotal += firstFactor; + } + + if (cumulativeTotal > (seedValue * 50)) { + break; + } + } + } + retn *= (1 + (cumulativeTotal * 0.001)); + retn *= (1 + (3.1415962 / seedValue)); + retn /= 2.41497; + retn -= (seedValue * -1); + return retn; +} + +function calculateFirstFactor(seedValue) { + var firstFactor = (0.45 * (9.3 / 3.1) - 0.90); + firstFactor *= (1 + (0.00002 / seedValue)); + return firstFactor; +} + +function calculateSecondFactor(seedValue) { + var secondFactor = 0.78 * (6.3 / 2.1) - (0.39 * 4); + secondFactor *= (1 + (0.00002 / seedValue)); + return secondFactor; +} + +function calculateModificationTerm(seedValue) { + var modificationTerm = (12 + (9*7) - 54 + 16 - ((calculateFirstFactor(seedValue) * seedValue) / 3) + (4*calculateSecondFactor(seedValue) * seedValue * 1.33)) + (calculateSecondFactor(seedValue) * seedValue); + modificationTerm = modificationTerm + (33/2) + 19 - (9*2) - (61*3) + 177; + return modificationTerm; +} diff --git a/tests/benchmarks/qml/holistic/data/jsImports/mlbsi3.js b/tests/benchmarks/qml/holistic/data/jsImports/mlbsi3.js new file mode 100644 index 0000000000..0bfe7f021d --- /dev/null +++ b/tests/benchmarks/qml/holistic/data/jsImports/mlbsi3.js @@ -0,0 +1,108 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +// This JavaScript file is a single, large, imported script. +// It doesn't import any other scripts. +// It is imported from another script. + +function testFunc(seedValue) { + var retn = 5; + retn += (seedValue * 0.345); + var firstFactor = calculateFirstFactor(seedValue); + var secondFactor = calculateSecondFactor(seedValue); + var modificationTerm = calculateModificationTerm(seedValue); + + // do some regexp matching + var someString = "This is a random string which we'll perform regular expression matching on to reduce considerably. This is meant to be part of a complex javascript expression whose evaluation takes considerably longer than the creation cost of QScriptValue."; + var regexpPattern = new RegExp("is", "i"); + var regexpOutputLength = 0; + var temp = regexpPattern.exec(someString); + while (temp == "is") { + regexpOutputLength += 4; + regexpOutputLength *= 2; + temp = regexpPattern.exec(someString); + if (regexpOutputLength > (seedValue * 3)) { + temp = "break"; + } + } + + // spin in a for loop for a while + var i = 0; + var j = 0; + var cumulativeTotal = 3; + for (i = 20; i > 1; i--) { + for (j = 31; j > 5; j--) { + var branchVariable = i + j; + if (branchVariable % 3 == 0) { + cumulativeTotal -= secondFactor; + } else { + cumulativeTotal += firstFactor; + } + + if (cumulativeTotal > (seedValue * 50)) { + break; + } + } + } + retn *= (1 + (cumulativeTotal * 0.001)); + retn *= (1 + (3.1415962 / seedValue)); + retn /= 2.41497; + retn -= (seedValue * -1); + return retn; +} + +function calculateFirstFactor(seedValue) { + var firstFactor = (0.45 * (9.3 / 3.1) - 0.90); + firstFactor *= (1 + (0.00003 / seedValue)); + return firstFactor; +} + +function calculateSecondFactor(seedValue) { + var secondFactor = 0.78 * (6.3 / 2.1) - (0.39 * 4); + secondFactor *= (1 + (0.00003 / seedValue)); + return secondFactor; +} + +function calculateModificationTerm(seedValue) { + var modificationTerm = (12 + (9*7) - 54 + 16 - ((calculateFirstFactor(seedValue) * seedValue) / 3) + (4*calculateSecondFactor(seedValue) * seedValue * 1.33)) + (calculateSecondFactor(seedValue) * seedValue); + modificationTerm = modificationTerm + (33/2) + 19 - (9*2) - (61*3) + 177; + return modificationTerm; +} diff --git a/tests/benchmarks/qml/holistic/data/jsImports/mlbsi4.js b/tests/benchmarks/qml/holistic/data/jsImports/mlbsi4.js new file mode 100644 index 0000000000..8707e296ec --- /dev/null +++ b/tests/benchmarks/qml/holistic/data/jsImports/mlbsi4.js @@ -0,0 +1,108 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +// This JavaScript file is a single, large, imported script. +// It doesn't import any other scripts. +// It is imported from another script. + +function testFunc(seedValue) { + var retn = 5; + retn += (seedValue * 0.445); + var firstFactor = calculateFirstFactor(seedValue); + var secondFactor = calculateSecondFactor(seedValue); + var modificationTerm = calculateModificationTerm(seedValue); + + // do some regexp matching + var someString = "This is a random string which we'll perform regular expression matching on to reduce considerably. This is meant to be part of a complex javascript expression whose evaluation takes considerably longer than the creation cost of QScriptValue."; + var regexpPattern = new RegExp("is", "i"); + var regexpOutputLength = 0; + var temp = regexpPattern.exec(someString); + while (temp == "is") { + regexpOutputLength += 4; + regexpOutputLength *= 2; + temp = regexpPattern.exec(someString); + if (regexpOutputLength > (seedValue * 3)) { + temp = "break"; + } + } + + // spin in a for loop for a while + var i = 0; + var j = 0; + var cumulativeTotal = 3; + for (i = 20; i > 1; i--) { + for (j = 31; j > 5; j--) { + var branchVariable = i + j; + if (branchVariable % 3 == 0) { + cumulativeTotal -= secondFactor; + } else { + cumulativeTotal += firstFactor; + } + + if (cumulativeTotal > (seedValue * 50)) { + break; + } + } + } + retn *= (1 + (cumulativeTotal * 0.001)); + retn *= (1 + (3.1415962 / seedValue)); + retn /= 2.41497; + retn -= (seedValue * -1); + return retn; +} + +function calculateFirstFactor(seedValue) { + var firstFactor = (0.45 * (9.3 / 3.1) - 0.90); + firstFactor *= (1 + (0.00004 / seedValue)); + return firstFactor; +} + +function calculateSecondFactor(seedValue) { + var secondFactor = 0.78 * (6.3 / 2.1) - (0.39 * 4); + secondFactor *= (1 + (0.00004 / seedValue)); + return secondFactor; +} + +function calculateModificationTerm(seedValue) { + var modificationTerm = (12 + (9*7) - 54 + 16 - ((calculateFirstFactor(seedValue) * seedValue) / 3) + (4*calculateSecondFactor(seedValue) * seedValue * 1.33)) + (calculateSecondFactor(seedValue) * seedValue); + modificationTerm = modificationTerm + (33/2) + 19 - (9*2) - (61*3) + 177; + return modificationTerm; +} diff --git a/tests/benchmarks/qml/holistic/data/jsImports/mlbsi5.js b/tests/benchmarks/qml/holistic/data/jsImports/mlbsi5.js new file mode 100644 index 0000000000..0b1e8cf3de --- /dev/null +++ b/tests/benchmarks/qml/holistic/data/jsImports/mlbsi5.js @@ -0,0 +1,108 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +// This JavaScript file is a single, large, imported script. +// It doesn't import any other scripts. +// It is imported from another script. + +function testFunc(seedValue) { + var retn = 5; + retn += (seedValue * 0.545); + var firstFactor = calculateFirstFactor(seedValue); + var secondFactor = calculateSecondFactor(seedValue); + var modificationTerm = calculateModificationTerm(seedValue); + + // do some regexp matching + var someString = "This is a random string which we'll perform regular expression matching on to reduce considerably. This is meant to be part of a complex javascript expression whose evaluation takes considerably longer than the creation cost of QScriptValue."; + var regexpPattern = new RegExp("is", "i"); + var regexpOutputLength = 0; + var temp = regexpPattern.exec(someString); + while (temp == "is") { + regexpOutputLength += 4; + regexpOutputLength *= 2; + temp = regexpPattern.exec(someString); + if (regexpOutputLength > (seedValue * 3)) { + temp = "break"; + } + } + + // spin in a for loop for a while + var i = 0; + var j = 0; + var cumulativeTotal = 3; + for (i = 20; i > 1; i--) { + for (j = 31; j > 5; j--) { + var branchVariable = i + j; + if (branchVariable % 3 == 0) { + cumulativeTotal -= secondFactor; + } else { + cumulativeTotal += firstFactor; + } + + if (cumulativeTotal > (seedValue * 50)) { + break; + } + } + } + retn *= (1 + (cumulativeTotal * 0.001)); + retn *= (1 + (3.1415962 / seedValue)); + retn /= 2.41497; + retn -= (seedValue * -1); + return retn; +} + +function calculateFirstFactor(seedValue) { + var firstFactor = (0.45 * (9.3 / 3.1) - 0.90); + firstFactor *= (1 + (0.00005 / seedValue)); + return firstFactor; +} + +function calculateSecondFactor(seedValue) { + var secondFactor = 0.78 * (6.3 / 2.1) - (0.39 * 4); + secondFactor *= (1 + (0.00005 / seedValue)); + return secondFactor; +} + +function calculateModificationTerm(seedValue) { + var modificationTerm = (12 + (9*7) - 54 + 16 - ((calculateFirstFactor(seedValue) * seedValue) / 3) + (4*calculateSecondFactor(seedValue) * seedValue * 1.33)) + (calculateSecondFactor(seedValue) * seedValue); + modificationTerm = modificationTerm + (33/2) + 19 - (9*2) - (61*3) + 177; + return modificationTerm; +} diff --git a/tests/benchmarks/qml/holistic/data/jsImports/mlbsi6.js b/tests/benchmarks/qml/holistic/data/jsImports/mlbsi6.js new file mode 100644 index 0000000000..eb839108de --- /dev/null +++ b/tests/benchmarks/qml/holistic/data/jsImports/mlbsi6.js @@ -0,0 +1,108 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +// This JavaScript file is a single, large, imported script. +// It doesn't import any other scripts. +// It is imported from another script. + +function testFunc(seedValue) { + var retn = 5; + retn += (seedValue * 0.645); + var firstFactor = calculateFirstFactor(seedValue); + var secondFactor = calculateSecondFactor(seedValue); + var modificationTerm = calculateModificationTerm(seedValue); + + // do some regexp matching + var someString = "This is a random string which we'll perform regular expression matching on to reduce considerably. This is meant to be part of a complex javascript expression whose evaluation takes considerably longer than the creation cost of QScriptValue."; + var regexpPattern = new RegExp("is", "i"); + var regexpOutputLength = 0; + var temp = regexpPattern.exec(someString); + while (temp == "is") { + regexpOutputLength += 4; + regexpOutputLength *= 2; + temp = regexpPattern.exec(someString); + if (regexpOutputLength > (seedValue * 3)) { + temp = "break"; + } + } + + // spin in a for loop for a while + var i = 0; + var j = 0; + var cumulativeTotal = 3; + for (i = 20; i > 1; i--) { + for (j = 31; j > 5; j--) { + var branchVariable = i + j; + if (branchVariable % 3 == 0) { + cumulativeTotal -= secondFactor; + } else { + cumulativeTotal += firstFactor; + } + + if (cumulativeTotal > (seedValue * 50)) { + break; + } + } + } + retn *= (1 + (cumulativeTotal * 0.001)); + retn *= (1 + (3.1415962 / seedValue)); + retn /= 2.41497; + retn -= (seedValue * -1); + return retn; +} + +function calculateFirstFactor(seedValue) { + var firstFactor = (0.45 * (9.3 / 3.1) - 0.90); + firstFactor *= (1 + (0.00006 / seedValue)); + return firstFactor; +} + +function calculateSecondFactor(seedValue) { + var secondFactor = 0.78 * (6.3 / 2.1) - (0.39 * 4); + secondFactor *= (1 + (0.00006 / seedValue)); + return secondFactor; +} + +function calculateModificationTerm(seedValue) { + var modificationTerm = (12 + (9*7) - 54 + 16 - ((calculateFirstFactor(seedValue) * seedValue) / 3) + (4*calculateSecondFactor(seedValue) * seedValue * 1.33)) + (calculateSecondFactor(seedValue) * seedValue); + modificationTerm = modificationTerm + (33/2) + 19 - (9*2) - (61*3) + 177; + return modificationTerm; +} diff --git a/tests/benchmarks/qml/holistic/data/jsImports/mlbsi7.js b/tests/benchmarks/qml/holistic/data/jsImports/mlbsi7.js new file mode 100644 index 0000000000..fb22fa8f73 --- /dev/null +++ b/tests/benchmarks/qml/holistic/data/jsImports/mlbsi7.js @@ -0,0 +1,108 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +// This JavaScript file is a single, large, imported script. +// It doesn't import any other scripts. +// It is imported from another script. + +function testFunc(seedValue) { + var retn = 5; + retn += (seedValue * 0.745); + var firstFactor = calculateFirstFactor(seedValue); + var secondFactor = calculateSecondFactor(seedValue); + var modificationTerm = calculateModificationTerm(seedValue); + + // do some regexp matching + var someString = "This is a random string which we'll perform regular expression matching on to reduce considerably. This is meant to be part of a complex javascript expression whose evaluation takes considerably longer than the creation cost of QScriptValue."; + var regexpPattern = new RegExp("is", "i"); + var regexpOutputLength = 0; + var temp = regexpPattern.exec(someString); + while (temp == "is") { + regexpOutputLength += 4; + regexpOutputLength *= 2; + temp = regexpPattern.exec(someString); + if (regexpOutputLength > (seedValue * 3)) { + temp = "break"; + } + } + + // spin in a for loop for a while + var i = 0; + var j = 0; + var cumulativeTotal = 3; + for (i = 20; i > 1; i--) { + for (j = 31; j > 5; j--) { + var branchVariable = i + j; + if (branchVariable % 3 == 0) { + cumulativeTotal -= secondFactor; + } else { + cumulativeTotal += firstFactor; + } + + if (cumulativeTotal > (seedValue * 50)) { + break; + } + } + } + retn *= (1 + (cumulativeTotal * 0.001)); + retn *= (1 + (3.1415962 / seedValue)); + retn /= 2.41497; + retn -= (seedValue * -1); + return retn; +} + +function calculateFirstFactor(seedValue) { + var firstFactor = (0.45 * (9.3 / 3.1) - 0.90); + firstFactor *= (1 + (0.00007 / seedValue)); + return firstFactor; +} + +function calculateSecondFactor(seedValue) { + var secondFactor = 0.78 * (6.3 / 2.1) - (0.39 * 4); + secondFactor *= (1 + (0.00007 / seedValue)); + return secondFactor; +} + +function calculateModificationTerm(seedValue) { + var modificationTerm = (12 + (9*7) - 54 + 16 - ((calculateFirstFactor(seedValue) * seedValue) / 3) + (4*calculateSecondFactor(seedValue) * seedValue * 1.33)) + (calculateSecondFactor(seedValue) * seedValue); + modificationTerm = modificationTerm + (33/2) + 19 - (9*2) - (61*3) + 177; + return modificationTerm; +} diff --git a/tests/benchmarks/qml/holistic/data/jsImports/mlbsi8.js b/tests/benchmarks/qml/holistic/data/jsImports/mlbsi8.js new file mode 100644 index 0000000000..736703c5bc --- /dev/null +++ b/tests/benchmarks/qml/holistic/data/jsImports/mlbsi8.js @@ -0,0 +1,108 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +// This JavaScript file is a single, large, imported script. +// It doesn't import any other scripts. +// It is imported from another script. + +function testFunc(seedValue) { + var retn = 5; + retn += (seedValue * 0.845); + var firstFactor = calculateFirstFactor(seedValue); + var secondFactor = calculateSecondFactor(seedValue); + var modificationTerm = calculateModificationTerm(seedValue); + + // do some regexp matching + var someString = "This is a random string which we'll perform regular expression matching on to reduce considerably. This is meant to be part of a complex javascript expression whose evaluation takes considerably longer than the creation cost of QScriptValue."; + var regexpPattern = new RegExp("is", "i"); + var regexpOutputLength = 0; + var temp = regexpPattern.exec(someString); + while (temp == "is") { + regexpOutputLength += 4; + regexpOutputLength *= 2; + temp = regexpPattern.exec(someString); + if (regexpOutputLength > (seedValue * 3)) { + temp = "break"; + } + } + + // spin in a for loop for a while + var i = 0; + var j = 0; + var cumulativeTotal = 3; + for (i = 20; i > 1; i--) { + for (j = 31; j > 5; j--) { + var branchVariable = i + j; + if (branchVariable % 3 == 0) { + cumulativeTotal -= secondFactor; + } else { + cumulativeTotal += firstFactor; + } + + if (cumulativeTotal > (seedValue * 50)) { + break; + } + } + } + retn *= (1 + (cumulativeTotal * 0.001)); + retn *= (1 + (3.1415962 / seedValue)); + retn /= 2.41497; + retn -= (seedValue * -1); + return retn; +} + +function calculateFirstFactor(seedValue) { + var firstFactor = (0.45 * (9.3 / 3.1) - 0.90); + firstFactor *= (1 + (0.00008 / seedValue)); + return firstFactor; +} + +function calculateSecondFactor(seedValue) { + var secondFactor = 0.78 * (6.3 / 2.1) - (0.39 * 4); + secondFactor *= (1 + (0.00008 / seedValue)); + return secondFactor; +} + +function calculateModificationTerm(seedValue) { + var modificationTerm = (12 + (9*7) - 54 + 16 - ((calculateFirstFactor(seedValue) * seedValue) / 3) + (4*calculateSecondFactor(seedValue) * seedValue * 1.33)) + (calculateSecondFactor(seedValue) * seedValue); + modificationTerm = modificationTerm + (33/2) + 19 - (9*2) - (61*3) + 177; + return modificationTerm; +} diff --git a/tests/benchmarks/qml/holistic/data/jsImports/mlbsi9.js b/tests/benchmarks/qml/holistic/data/jsImports/mlbsi9.js new file mode 100644 index 0000000000..a1587a7de9 --- /dev/null +++ b/tests/benchmarks/qml/holistic/data/jsImports/mlbsi9.js @@ -0,0 +1,108 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +// This JavaScript file is a single, large, imported script. +// It doesn't import any other scripts. +// It is imported from another script. + +function testFunc(seedValue) { + var retn = 5; + retn += (seedValue * 0.945); + var firstFactor = calculateFirstFactor(seedValue); + var secondFactor = calculateSecondFactor(seedValue); + var modificationTerm = calculateModificationTerm(seedValue); + + // do some regexp matching + var someString = "This is a random string which we'll perform regular expression matching on to reduce considerably. This is meant to be part of a complex javascript expression whose evaluation takes considerably longer than the creation cost of QScriptValue."; + var regexpPattern = new RegExp("is", "i"); + var regexpOutputLength = 0; + var temp = regexpPattern.exec(someString); + while (temp == "is") { + regexpOutputLength += 4; + regexpOutputLength *= 2; + temp = regexpPattern.exec(someString); + if (regexpOutputLength > (seedValue * 3)) { + temp = "break"; + } + } + + // spin in a for loop for a while + var i = 0; + var j = 0; + var cumulativeTotal = 3; + for (i = 20; i > 1; i--) { + for (j = 31; j > 5; j--) { + var branchVariable = i + j; + if (branchVariable % 3 == 0) { + cumulativeTotal -= secondFactor; + } else { + cumulativeTotal += firstFactor; + } + + if (cumulativeTotal > (seedValue * 50)) { + break; + } + } + } + retn *= (1 + (cumulativeTotal * 0.001)); + retn *= (1 + (3.1415962 / seedValue)); + retn /= 2.41497; + retn -= (seedValue * -1); + return retn; +} + +function calculateFirstFactor(seedValue) { + var firstFactor = (0.45 * (9.3 / 3.1) - 0.90); + firstFactor *= (1 + (0.00009 / seedValue)); + return firstFactor; +} + +function calculateSecondFactor(seedValue) { + var secondFactor = 0.78 * (6.3 / 2.1) - (0.39 * 4); + secondFactor *= (1 + (0.00009 / seedValue)); + return secondFactor; +} + +function calculateModificationTerm(seedValue) { + var modificationTerm = (12 + (9*7) - 54 + 16 - ((calculateFirstFactor(seedValue) * seedValue) / 3) + (4*calculateSecondFactor(seedValue) * seedValue * 1.33)) + (calculateSecondFactor(seedValue) * seedValue); + modificationTerm = modificationTerm + (33/2) + 19 - (9*2) - (61*3) + 177; + return modificationTerm; +} diff --git a/tests/benchmarks/qml/holistic/data/jsImports/mldsi.js b/tests/benchmarks/qml/holistic/data/jsImports/mldsi.js new file mode 100644 index 0000000000..c0bad9c5a6 --- /dev/null +++ b/tests/benchmarks/qml/holistic/data/jsImports/mldsi.js @@ -0,0 +1,105 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +// This JavaScript file is a single, small, imported script. +// It imports other small scripts which are deeply nested. + +.import "mldsi1.js" as Mldsi1 + +function testFunc(seedValue) { + var firstFactor = calculateFirstFactor(seedValue); + var secondFactor = calculateSecondFactor(seedValue); + var modificationTerm = calculateModificationTerm(seedValue); + + // do some regexp matching + var someString = "This is a random string which we'll perform regular expression matching on to reduce considerably. This is meant to be part of a complex javascript expression whose evaluation takes considerably longer than the creation cost of QScriptValue."; + var regexpPattern = new RegExp("is", "i"); + var regexpOutputLength = 0; + var temp = regexpPattern.exec(someString); + while (temp == "is") { + regexpOutputLength += 4; + regexpOutputLength *= 2; + temp = regexpPattern.exec(someString); + if (regexpOutputLength > (seedValue * 3)) { + temp = "break"; + } + } + + // spin in a for loop for a while + var i = 0; + var j = 0; + var cumulativeTotal = 3; + for (i = 20; i > 1; i--) { + for (j = 31; j > 5; j--) { + var branchVariable = i + j; + if (branchVariable % 3 == 0) { + cumulativeTotal -= secondFactor; + } else { + cumulativeTotal += firstFactor; + } + + if (cumulativeTotal > (seedValue * 50)) { + break; + } + } + } + var retn = cumulativeTotal * 0.5; + retn *= Mldsi1.testFunc(seedValue + retn); + return retn; +} + +function calculateFirstFactor(seedValue) { + var firstFactor = (0.45 * (9.3 / 3.1) - 0.90); + firstFactor *= (1 + (0.000017 / seedValue)); + return firstFactor; +} + +function calculateSecondFactor(seedValue) { + var secondFactor = 0.78 * (6.3 / 2.1) - (0.39 * 4); + secondFactor *= (1 + (0.000017 / seedValue)); + return secondFactor; +} + +function calculateModificationTerm(seedValue) { + var modificationTerm = (12 + (9*7) - 54 + 16 - ((calculateFirstFactor(seedValue) * seedValue) / 3) + (4*calculateSecondFactor(seedValue) * seedValue * 1.33)) + (calculateSecondFactor(seedValue) * seedValue); + modificationTerm = modificationTerm + (33/2) + 19 - (9*2) - (61*3) + 177; + return modificationTerm; +} diff --git a/tests/benchmarks/qml/holistic/data/jsImports/mldsi1.js b/tests/benchmarks/qml/holistic/data/jsImports/mldsi1.js new file mode 100644 index 0000000000..b2a513da3b --- /dev/null +++ b/tests/benchmarks/qml/holistic/data/jsImports/mldsi1.js @@ -0,0 +1,107 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +// This JavaScript file is a single, large, imported script. +// It imports other large scripts which are deeply nested. +// It is imported by another script. + +.import "msdsi2.js" as Msdsi2 + +function testFunc(seedValue) { + var retn = 0.15; + var firstFactor = calculateFirstFactor(seedValue); + var secondFactor = calculateSecondFactor(seedValue); + var modificationTerm = calculateModificationTerm(seedValue); + + // do some regexp matching + var someString = "This is a random string which we'll perform regular expression matching on to reduce considerably. This is meant to be part of a complex javascript expression whose evaluation takes considerably longer than the creation cost of QScriptValue."; + var regexpPattern = new RegExp("is", "i"); + var regexpOutputLength = 0; + var temp = regexpPattern.exec(someString); + while (temp == "is") { + regexpOutputLength += 4; + regexpOutputLength *= 2; + temp = regexpPattern.exec(someString); + if (regexpOutputLength > (seedValue * 3)) { + temp = "break"; + } + } + + // spin in a for loop for a while + var i = 0; + var j = 0; + var cumulativeTotal = 3; + for (i = 20; i > 1; i--) { + for (j = 31; j > 5; j--) { + var branchVariable = i + j; + if (branchVariable % 3 == 0) { + cumulativeTotal -= secondFactor; + } else { + cumulativeTotal += firstFactor; + } + + if (cumulativeTotal > (seedValue * 50)) { + break; + } + } + } + retn *= (1 + (cumulativeTotal * 0.001)); + retn *= Msdsi2.testFunc(seedValue + retn); + return retn; +} + +function calculateFirstFactor(seedValue) { + var firstFactor = (0.45 * (9.3 / 3.1) - 0.90); + firstFactor *= (1 + (0.00001 / seedValue)); + return firstFactor; +} + +function calculateSecondFactor(seedValue) { + var secondFactor = 0.78 * (6.3 / 2.1) - (0.39 * 4); + secondFactor *= (1 + (0.00001 / seedValue)); + return secondFactor; +} + +function calculateModificationTerm(seedValue) { + var modificationTerm = (12 + (9*7) - 54 + 16 - ((calculateFirstFactor(seedValue) * seedValue) / 3) + (4*calculateSecondFactor(seedValue) * seedValue * 1.33)) + (calculateSecondFactor(seedValue) * seedValue); + modificationTerm = modificationTerm + (33/2) + 19 - (9*2) - (61*3) + 177; + return modificationTerm; +} diff --git a/tests/benchmarks/qml/holistic/data/jsImports/mldsi10.js b/tests/benchmarks/qml/holistic/data/jsImports/mldsi10.js new file mode 100644 index 0000000000..864f027a6e --- /dev/null +++ b/tests/benchmarks/qml/holistic/data/jsImports/mldsi10.js @@ -0,0 +1,107 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +// This JavaScript file is a single, large, imported script. +// It imports other large scripts which are deeply nested. +// It is imported by another script. + +.import "msdsi11.js" as Msdsi11 + +function testFunc(seedValue) { + var retn = 0.105; + var firstFactor = calculateFirstFactor(seedValue); + var secondFactor = calculateSecondFactor(seedValue); + var modificationTerm = calculateModificationTerm(seedValue); + + // do some regexp matching + var someString = "This is a random string which we'll perform regular expression matching on to reduce considerably. This is meant to be part of a complex javascript expression whose evaluation takes considerably longer than the creation cost of QScriptValue."; + var regexpPattern = new RegExp("is", "i"); + var regexpOutputLength = 0; + var temp = regexpPattern.exec(someString); + while (temp == "is") { + regexpOutputLength += 4; + regexpOutputLength *= 2; + temp = regexpPattern.exec(someString); + if (regexpOutputLength > (seedValue * 3)) { + temp = "break"; + } + } + + // spin in a for loop for a while + var i = 0; + var j = 0; + var cumulativeTotal = 3; + for (i = 20; i > 1; i--) { + for (j = 31; j > 5; j--) { + var branchVariable = i + j; + if (branchVariable % 3 == 0) { + cumulativeTotal -= secondFactor; + } else { + cumulativeTotal += firstFactor; + } + + if (cumulativeTotal > (seedValue * 50)) { + break; + } + } + } + retn *= (1 + (cumulativeTotal * 0.001)); + retn *= Msdsi11.testFunc(seedValue + retn); + return retn; +} + +function calculateFirstFactor(seedValue) { + var firstFactor = (0.45 * (9.3 / 3.1) - 0.90); + firstFactor *= (1 + (0.000010 / seedValue)); + return firstFactor; +} + +function calculateSecondFactor(seedValue) { + var secondFactor = 0.78 * (6.3 / 2.1) - (0.39 * 4); + secondFactor *= (1 + (0.000010 / seedValue)); + return secondFactor; +} + +function calculateModificationTerm(seedValue) { + var modificationTerm = (12 + (9*7) - 54 + 16 - ((calculateFirstFactor(seedValue) * seedValue) / 3) + (4*calculateSecondFactor(seedValue) * seedValue * 1.33)) + (calculateSecondFactor(seedValue) * seedValue); + modificationTerm = modificationTerm + (33/2) + 19 - (9*2) - (61*3) + 177; + return modificationTerm; +} diff --git a/tests/benchmarks/qml/holistic/data/jsImports/mldsi11.js b/tests/benchmarks/qml/holistic/data/jsImports/mldsi11.js new file mode 100644 index 0000000000..2c126ec1c6 --- /dev/null +++ b/tests/benchmarks/qml/holistic/data/jsImports/mldsi11.js @@ -0,0 +1,107 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +// This JavaScript file is a single, large, imported script. +// It imports other large scripts which are deeply nested. +// It is imported by another script. + +.import "msdsi12.js" as Msdsi12 + +function testFunc(seedValue) { + var retn = 0.115; + var firstFactor = calculateFirstFactor(seedValue); + var secondFactor = calculateSecondFactor(seedValue); + var modificationTerm = calculateModificationTerm(seedValue); + + // do some regexp matching + var someString = "This is a random string which we'll perform regular expression matching on to reduce considerably. This is meant to be part of a complex javascript expression whose evaluation takes considerably longer than the creation cost of QScriptValue."; + var regexpPattern = new RegExp("is", "i"); + var regexpOutputLength = 0; + var temp = regexpPattern.exec(someString); + while (temp == "is") { + regexpOutputLength += 4; + regexpOutputLength *= 2; + temp = regexpPattern.exec(someString); + if (regexpOutputLength > (seedValue * 3)) { + temp = "break"; + } + } + + // spin in a for loop for a while + var i = 0; + var j = 0; + var cumulativeTotal = 3; + for (i = 20; i > 1; i--) { + for (j = 31; j > 5; j--) { + var branchVariable = i + j; + if (branchVariable % 3 == 0) { + cumulativeTotal -= secondFactor; + } else { + cumulativeTotal += firstFactor; + } + + if (cumulativeTotal > (seedValue * 50)) { + break; + } + } + } + retn *= (1 + (cumulativeTotal * 0.001)); + retn *= Msdsi12.testFunc(seedValue + retn); + return retn; +} + +function calculateFirstFactor(seedValue) { + var firstFactor = (0.45 * (9.3 / 3.1) - 0.90); + firstFactor *= (1 + (0.000011 / seedValue)); + return firstFactor; +} + +function calculateSecondFactor(seedValue) { + var secondFactor = 0.78 * (6.3 / 2.1) - (0.39 * 4); + secondFactor *= (1 + (0.000011 / seedValue)); + return secondFactor; +} + +function calculateModificationTerm(seedValue) { + var modificationTerm = (12 + (9*7) - 54 + 16 - ((calculateFirstFactor(seedValue) * seedValue) / 3) + (4*calculateSecondFactor(seedValue) * seedValue * 1.33)) + (calculateSecondFactor(seedValue) * seedValue); + modificationTerm = modificationTerm + (33/2) + 19 - (9*2) - (61*3) + 177; + return modificationTerm; +} diff --git a/tests/benchmarks/qml/holistic/data/jsImports/mldsi12.js b/tests/benchmarks/qml/holistic/data/jsImports/mldsi12.js new file mode 100644 index 0000000000..76c14d8771 --- /dev/null +++ b/tests/benchmarks/qml/holistic/data/jsImports/mldsi12.js @@ -0,0 +1,107 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +// This JavaScript file is a single, large, imported script. +// It imports other large scripts which are deeply nested. +// It is imported by another script. + +.import "msdsi13.js" as Msdsi13 + +function testFunc(seedValue) { + var retn = 0.125; + var firstFactor = calculateFirstFactor(seedValue); + var secondFactor = calculateSecondFactor(seedValue); + var modificationTerm = calculateModificationTerm(seedValue); + + // do some regexp matching + var someString = "This is a random string which we'll perform regular expression matching on to reduce considerably. This is meant to be part of a complex javascript expression whose evaluation takes considerably longer than the creation cost of QScriptValue."; + var regexpPattern = new RegExp("is", "i"); + var regexpOutputLength = 0; + var temp = regexpPattern.exec(someString); + while (temp == "is") { + regexpOutputLength += 4; + regexpOutputLength *= 2; + temp = regexpPattern.exec(someString); + if (regexpOutputLength > (seedValue * 3)) { + temp = "break"; + } + } + + // spin in a for loop for a while + var i = 0; + var j = 0; + var cumulativeTotal = 3; + for (i = 20; i > 1; i--) { + for (j = 31; j > 5; j--) { + var branchVariable = i + j; + if (branchVariable % 3 == 0) { + cumulativeTotal -= secondFactor; + } else { + cumulativeTotal += firstFactor; + } + + if (cumulativeTotal > (seedValue * 50)) { + break; + } + } + } + retn *= (1 + (cumulativeTotal * 0.001)); + retn *= Msdsi13.testFunc(seedValue + retn); + return retn; +} + +function calculateFirstFactor(seedValue) { + var firstFactor = (0.45 * (9.3 / 3.1) - 0.90); + firstFactor *= (1 + (0.000012 / seedValue)); + return firstFactor; +} + +function calculateSecondFactor(seedValue) { + var secondFactor = 0.78 * (6.3 / 2.1) - (0.39 * 4); + secondFactor *= (1 + (0.000012 / seedValue)); + return secondFactor; +} + +function calculateModificationTerm(seedValue) { + var modificationTerm = (12 + (9*7) - 54 + 16 - ((calculateFirstFactor(seedValue) * seedValue) / 3) + (4*calculateSecondFactor(seedValue) * seedValue * 1.33)) + (calculateSecondFactor(seedValue) * seedValue); + modificationTerm = modificationTerm + (33/2) + 19 - (9*2) - (61*3) + 177; + return modificationTerm; +} diff --git a/tests/benchmarks/qml/holistic/data/jsImports/mldsi13.js b/tests/benchmarks/qml/holistic/data/jsImports/mldsi13.js new file mode 100644 index 0000000000..aaa2c6ab14 --- /dev/null +++ b/tests/benchmarks/qml/holistic/data/jsImports/mldsi13.js @@ -0,0 +1,107 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +// This JavaScript file is a single, large, imported script. +// It imports other large scripts which are deeply nested. +// It is imported by another script. + +.import "msdsi14.js" as Msdsi14 + +function testFunc(seedValue) { + var retn = 0.135; + var firstFactor = calculateFirstFactor(seedValue); + var secondFactor = calculateSecondFactor(seedValue); + var modificationTerm = calculateModificationTerm(seedValue); + + // do some regexp matching + var someString = "This is a random string which we'll perform regular expression matching on to reduce considerably. This is meant to be part of a complex javascript expression whose evaluation takes considerably longer than the creation cost of QScriptValue."; + var regexpPattern = new RegExp("is", "i"); + var regexpOutputLength = 0; + var temp = regexpPattern.exec(someString); + while (temp == "is") { + regexpOutputLength += 4; + regexpOutputLength *= 2; + temp = regexpPattern.exec(someString); + if (regexpOutputLength > (seedValue * 3)) { + temp = "break"; + } + } + + // spin in a for loop for a while + var i = 0; + var j = 0; + var cumulativeTotal = 3; + for (i = 20; i > 1; i--) { + for (j = 31; j > 5; j--) { + var branchVariable = i + j; + if (branchVariable % 3 == 0) { + cumulativeTotal -= secondFactor; + } else { + cumulativeTotal += firstFactor; + } + + if (cumulativeTotal > (seedValue * 50)) { + break; + } + } + } + retn *= (1 + (cumulativeTotal * 0.001)); + retn *= Msdsi14.testFunc(seedValue + retn); + return retn; +} + +function calculateFirstFactor(seedValue) { + var firstFactor = (0.45 * (9.3 / 3.1) - 0.90); + firstFactor *= (1 + (0.000013 / seedValue)); + return firstFactor; +} + +function calculateSecondFactor(seedValue) { + var secondFactor = 0.78 * (6.3 / 2.1) - (0.39 * 4); + secondFactor *= (1 + (0.000013 / seedValue)); + return secondFactor; +} + +function calculateModificationTerm(seedValue) { + var modificationTerm = (12 + (9*7) - 54 + 16 - ((calculateFirstFactor(seedValue) * seedValue) / 3) + (4*calculateSecondFactor(seedValue) * seedValue * 1.33)) + (calculateSecondFactor(seedValue) * seedValue); + modificationTerm = modificationTerm + (33/2) + 19 - (9*2) - (61*3) + 177; + return modificationTerm; +} diff --git a/tests/benchmarks/qml/holistic/data/jsImports/mldsi14.js b/tests/benchmarks/qml/holistic/data/jsImports/mldsi14.js new file mode 100644 index 0000000000..11394a87fb --- /dev/null +++ b/tests/benchmarks/qml/holistic/data/jsImports/mldsi14.js @@ -0,0 +1,107 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +// This JavaScript file is a single, large, imported script. +// It imports other large scripts which are deeply nested. +// It is imported by another script. + +.import "msdsi15.js" as Msdsi15 + +function testFunc(seedValue) { + var retn = 0.145; + var firstFactor = calculateFirstFactor(seedValue); + var secondFactor = calculateSecondFactor(seedValue); + var modificationTerm = calculateModificationTerm(seedValue); + + // do some regexp matching + var someString = "This is a random string which we'll perform regular expression matching on to reduce considerably. This is meant to be part of a complex javascript expression whose evaluation takes considerably longer than the creation cost of QScriptValue."; + var regexpPattern = new RegExp("is", "i"); + var regexpOutputLength = 0; + var temp = regexpPattern.exec(someString); + while (temp == "is") { + regexpOutputLength += 4; + regexpOutputLength *= 2; + temp = regexpPattern.exec(someString); + if (regexpOutputLength > (seedValue * 3)) { + temp = "break"; + } + } + + // spin in a for loop for a while + var i = 0; + var j = 0; + var cumulativeTotal = 3; + for (i = 20; i > 1; i--) { + for (j = 31; j > 5; j--) { + var branchVariable = i + j; + if (branchVariable % 3 == 0) { + cumulativeTotal -= secondFactor; + } else { + cumulativeTotal += firstFactor; + } + + if (cumulativeTotal > (seedValue * 50)) { + break; + } + } + } + retn *= (1 + (cumulativeTotal * 0.001)); + retn *= Msdsi15.testFunc(seedValue + retn); + return retn; +} + +function calculateFirstFactor(seedValue) { + var firstFactor = (0.45 * (9.3 / 3.1) - 0.90); + firstFactor *= (1 + (0.000014 / seedValue)); + return firstFactor; +} + +function calculateSecondFactor(seedValue) { + var secondFactor = 0.78 * (6.3 / 2.1) - (0.39 * 4); + secondFactor *= (1 + (0.000014 / seedValue)); + return secondFactor; +} + +function calculateModificationTerm(seedValue) { + var modificationTerm = (12 + (9*7) - 54 + 16 - ((calculateFirstFactor(seedValue) * seedValue) / 3) + (4*calculateSecondFactor(seedValue) * seedValue * 1.33)) + (calculateSecondFactor(seedValue) * seedValue); + modificationTerm = modificationTerm + (33/2) + 19 - (9*2) - (61*3) + 177; + return modificationTerm; +} diff --git a/tests/benchmarks/qml/holistic/data/jsImports/mldsi15.js b/tests/benchmarks/qml/holistic/data/jsImports/mldsi15.js new file mode 100644 index 0000000000..2978dbedf3 --- /dev/null +++ b/tests/benchmarks/qml/holistic/data/jsImports/mldsi15.js @@ -0,0 +1,104 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +// This JavaScript file is a single, large, imported script. +// It is imported by another script. + +function testFunc(seedValue) { + var retn = 0.155; + var firstFactor = calculateFirstFactor(seedValue); + var secondFactor = calculateSecondFactor(seedValue); + var modificationTerm = calculateModificationTerm(seedValue); + + // do some regexp matching + var someString = "This is a random string which we'll perform regular expression matching on to reduce considerably. This is meant to be part of a complex javascript expression whose evaluation takes considerably longer than the creation cost of QScriptValue."; + var regexpPattern = new RegExp("is", "i"); + var regexpOutputLength = 0; + var temp = regexpPattern.exec(someString); + while (temp == "is") { + regexpOutputLength += 4; + regexpOutputLength *= 2; + temp = regexpPattern.exec(someString); + if (regexpOutputLength > (seedValue * 3)) { + temp = "break"; + } + } + + // spin in a for loop for a while + var i = 0; + var j = 0; + var cumulativeTotal = 3; + for (i = 20; i > 1; i--) { + for (j = 31; j > 5; j--) { + var branchVariable = i + j; + if (branchVariable % 3 == 0) { + cumulativeTotal -= secondFactor; + } else { + cumulativeTotal += firstFactor; + } + + if (cumulativeTotal > (seedValue * 50)) { + break; + } + } + } + retn *= (1 + (cumulativeTotal * 0.001)); + retn *= (seedValue + retn); + return retn; +} + +function calculateFirstFactor(seedValue) { + var firstFactor = (0.45 * (9.3 / 3.1) - 0.90); + firstFactor *= (1 + (0.000015 / seedValue)); + return firstFactor; +} + +function calculateSecondFactor(seedValue) { + var secondFactor = 0.78 * (6.3 / 2.1) - (0.39 * 4); + secondFactor *= (1 + (0.000015 / seedValue)); + return secondFactor; +} + +function calculateModificationTerm(seedValue) { + var modificationTerm = (12 + (9*7) - 54 + 16 - ((calculateFirstFactor(seedValue) * seedValue) / 3) + (4*calculateSecondFactor(seedValue) * seedValue * 1.33)) + (calculateSecondFactor(seedValue) * seedValue); + modificationTerm = modificationTerm + (33/2) + 19 - (9*2) - (61*3) + 177; + return modificationTerm; +} diff --git a/tests/benchmarks/qml/holistic/data/jsImports/mldsi2.js b/tests/benchmarks/qml/holistic/data/jsImports/mldsi2.js new file mode 100644 index 0000000000..f9105c07f2 --- /dev/null +++ b/tests/benchmarks/qml/holistic/data/jsImports/mldsi2.js @@ -0,0 +1,107 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +// This JavaScript file is a single, large, imported script. +// It imports other large scripts which are deeply nested. +// It is imported by another script. + +.import "msdsi3.js" as Msdsi3 + +function testFunc(seedValue) { + var retn = 0.25; + var firstFactor = calculateFirstFactor(seedValue); + var secondFactor = calculateSecondFactor(seedValue); + var modificationTerm = calculateModificationTerm(seedValue); + + // do some regexp matching + var someString = "This is a random string which we'll perform regular expression matching on to reduce considerably. This is meant to be part of a complex javascript expression whose evaluation takes considerably longer than the creation cost of QScriptValue."; + var regexpPattern = new RegExp("is", "i"); + var regexpOutputLength = 0; + var temp = regexpPattern.exec(someString); + while (temp == "is") { + regexpOutputLength += 4; + regexpOutputLength *= 2; + temp = regexpPattern.exec(someString); + if (regexpOutputLength > (seedValue * 3)) { + temp = "break"; + } + } + + // spin in a for loop for a while + var i = 0; + var j = 0; + var cumulativeTotal = 3; + for (i = 20; i > 1; i--) { + for (j = 31; j > 5; j--) { + var branchVariable = i + j; + if (branchVariable % 3 == 0) { + cumulativeTotal -= secondFactor; + } else { + cumulativeTotal += firstFactor; + } + + if (cumulativeTotal > (seedValue * 50)) { + break; + } + } + } + retn *= (1 + (cumulativeTotal * 0.001)); + retn *= Msdsi3.testFunc(seedValue + retn); + return retn; +} + +function calculateFirstFactor(seedValue) { + var firstFactor = (0.45 * (9.3 / 3.1) - 0.90); + firstFactor *= (1 + (0.00002 / seedValue)); + return firstFactor; +} + +function calculateSecondFactor(seedValue) { + var secondFactor = 0.78 * (6.3 / 2.1) - (0.39 * 4); + secondFactor *= (1 + (0.00002 / seedValue)); + return secondFactor; +} + +function calculateModificationTerm(seedValue) { + var modificationTerm = (12 + (9*7) - 54 + 16 - ((calculateFirstFactor(seedValue) * seedValue) / 3) + (4*calculateSecondFactor(seedValue) * seedValue * 1.33)) + (calculateSecondFactor(seedValue) * seedValue); + modificationTerm = modificationTerm + (33/2) + 19 - (9*2) - (61*3) + 177; + return modificationTerm; +} diff --git a/tests/benchmarks/qml/holistic/data/jsImports/mldsi3.js b/tests/benchmarks/qml/holistic/data/jsImports/mldsi3.js new file mode 100644 index 0000000000..046988b47a --- /dev/null +++ b/tests/benchmarks/qml/holistic/data/jsImports/mldsi3.js @@ -0,0 +1,107 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +// This JavaScript file is a single, large, imported script. +// It imports other large scripts which are deeply nested. +// It is imported by another script. + +.import "msdsi4.js" as Msdsi4 + +function testFunc(seedValue) { + var retn = 0.35; + var firstFactor = calculateFirstFactor(seedValue); + var secondFactor = calculateSecondFactor(seedValue); + var modificationTerm = calculateModificationTerm(seedValue); + + // do some regexp matching + var someString = "This is a random string which we'll perform regular expression matching on to reduce considerably. This is meant to be part of a complex javascript expression whose evaluation takes considerably longer than the creation cost of QScriptValue."; + var regexpPattern = new RegExp("is", "i"); + var regexpOutputLength = 0; + var temp = regexpPattern.exec(someString); + while (temp == "is") { + regexpOutputLength += 4; + regexpOutputLength *= 2; + temp = regexpPattern.exec(someString); + if (regexpOutputLength > (seedValue * 3)) { + temp = "break"; + } + } + + // spin in a for loop for a while + var i = 0; + var j = 0; + var cumulativeTotal = 3; + for (i = 20; i > 1; i--) { + for (j = 31; j > 5; j--) { + var branchVariable = i + j; + if (branchVariable % 3 == 0) { + cumulativeTotal -= secondFactor; + } else { + cumulativeTotal += firstFactor; + } + + if (cumulativeTotal > (seedValue * 50)) { + break; + } + } + } + retn *= (1 + (cumulativeTotal * 0.001)); + retn *= Msdsi4.testFunc(seedValue + retn); + return retn; +} + +function calculateFirstFactor(seedValue) { + var firstFactor = (0.45 * (9.3 / 3.1) - 0.90); + firstFactor *= (1 + (0.00003 / seedValue)); + return firstFactor; +} + +function calculateSecondFactor(seedValue) { + var secondFactor = 0.78 * (6.3 / 2.1) - (0.39 * 4); + secondFactor *= (1 + (0.00003 / seedValue)); + return secondFactor; +} + +function calculateModificationTerm(seedValue) { + var modificationTerm = (12 + (9*7) - 54 + 16 - ((calculateFirstFactor(seedValue) * seedValue) / 3) + (4*calculateSecondFactor(seedValue) * seedValue * 1.33)) + (calculateSecondFactor(seedValue) * seedValue); + modificationTerm = modificationTerm + (33/2) + 19 - (9*2) - (61*3) + 177; + return modificationTerm; +} diff --git a/tests/benchmarks/qml/holistic/data/jsImports/mldsi4.js b/tests/benchmarks/qml/holistic/data/jsImports/mldsi4.js new file mode 100644 index 0000000000..7996c0d3f1 --- /dev/null +++ b/tests/benchmarks/qml/holistic/data/jsImports/mldsi4.js @@ -0,0 +1,107 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +// This JavaScript file is a single, large, imported script. +// It imports other large scripts which are deeply nested. +// It is imported by another script. + +.import "msdsi5.js" as Msdsi5 + +function testFunc(seedValue) { + var retn = 0.45; + var firstFactor = calculateFirstFactor(seedValue); + var secondFactor = calculateSecondFactor(seedValue); + var modificationTerm = calculateModificationTerm(seedValue); + + // do some regexp matching + var someString = "This is a random string which we'll perform regular expression matching on to reduce considerably. This is meant to be part of a complex javascript expression whose evaluation takes considerably longer than the creation cost of QScriptValue."; + var regexpPattern = new RegExp("is", "i"); + var regexpOutputLength = 0; + var temp = regexpPattern.exec(someString); + while (temp == "is") { + regexpOutputLength += 4; + regexpOutputLength *= 2; + temp = regexpPattern.exec(someString); + if (regexpOutputLength > (seedValue * 3)) { + temp = "break"; + } + } + + // spin in a for loop for a while + var i = 0; + var j = 0; + var cumulativeTotal = 3; + for (i = 20; i > 1; i--) { + for (j = 31; j > 5; j--) { + var branchVariable = i + j; + if (branchVariable % 3 == 0) { + cumulativeTotal -= secondFactor; + } else { + cumulativeTotal += firstFactor; + } + + if (cumulativeTotal > (seedValue * 50)) { + break; + } + } + } + retn *= (1 + (cumulativeTotal * 0.001)); + retn *= Msdsi5.testFunc(seedValue + retn); + return retn; +} + +function calculateFirstFactor(seedValue) { + var firstFactor = (0.45 * (9.3 / 3.1) - 0.90); + firstFactor *= (1 + (0.00004 / seedValue)); + return firstFactor; +} + +function calculateSecondFactor(seedValue) { + var secondFactor = 0.78 * (6.3 / 2.1) - (0.39 * 4); + secondFactor *= (1 + (0.00004 / seedValue)); + return secondFactor; +} + +function calculateModificationTerm(seedValue) { + var modificationTerm = (12 + (9*7) - 54 + 16 - ((calculateFirstFactor(seedValue) * seedValue) / 3) + (4*calculateSecondFactor(seedValue) * seedValue * 1.33)) + (calculateSecondFactor(seedValue) * seedValue); + modificationTerm = modificationTerm + (33/2) + 19 - (9*2) - (61*3) + 177; + return modificationTerm; +} diff --git a/tests/benchmarks/qml/holistic/data/jsImports/mldsi5.js b/tests/benchmarks/qml/holistic/data/jsImports/mldsi5.js new file mode 100644 index 0000000000..183a09153a --- /dev/null +++ b/tests/benchmarks/qml/holistic/data/jsImports/mldsi5.js @@ -0,0 +1,107 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +// This JavaScript file is a single, large, imported script. +// It imports other large scripts which are deeply nested. +// It is imported by another script. + +.import "msdsi6.js" as Msdsi6 + +function testFunc(seedValue) { + var retn = 0.55; + var firstFactor = calculateFirstFactor(seedValue); + var secondFactor = calculateSecondFactor(seedValue); + var modificationTerm = calculateModificationTerm(seedValue); + + // do some regexp matching + var someString = "This is a random string which we'll perform regular expression matching on to reduce considerably. This is meant to be part of a complex javascript expression whose evaluation takes considerably longer than the creation cost of QScriptValue."; + var regexpPattern = new RegExp("is", "i"); + var regexpOutputLength = 0; + var temp = regexpPattern.exec(someString); + while (temp == "is") { + regexpOutputLength += 4; + regexpOutputLength *= 2; + temp = regexpPattern.exec(someString); + if (regexpOutputLength > (seedValue * 3)) { + temp = "break"; + } + } + + // spin in a for loop for a while + var i = 0; + var j = 0; + var cumulativeTotal = 3; + for (i = 20; i > 1; i--) { + for (j = 31; j > 5; j--) { + var branchVariable = i + j; + if (branchVariable % 3 == 0) { + cumulativeTotal -= secondFactor; + } else { + cumulativeTotal += firstFactor; + } + + if (cumulativeTotal > (seedValue * 50)) { + break; + } + } + } + retn *= (1 + (cumulativeTotal * 0.001)); + retn *= Msdsi6.testFunc(seedValue + retn); + return retn; +} + +function calculateFirstFactor(seedValue) { + var firstFactor = (0.45 * (9.3 / 3.1) - 0.90); + firstFactor *= (1 + (0.00005 / seedValue)); + return firstFactor; +} + +function calculateSecondFactor(seedValue) { + var secondFactor = 0.78 * (6.3 / 2.1) - (0.39 * 4); + secondFactor *= (1 + (0.00005 / seedValue)); + return secondFactor; +} + +function calculateModificationTerm(seedValue) { + var modificationTerm = (12 + (9*7) - 54 + 16 - ((calculateFirstFactor(seedValue) * seedValue) / 3) + (4*calculateSecondFactor(seedValue) * seedValue * 1.33)) + (calculateSecondFactor(seedValue) * seedValue); + modificationTerm = modificationTerm + (33/2) + 19 - (9*2) - (61*3) + 177; + return modificationTerm; +} diff --git a/tests/benchmarks/qml/holistic/data/jsImports/mldsi6.js b/tests/benchmarks/qml/holistic/data/jsImports/mldsi6.js new file mode 100644 index 0000000000..ad17faa47d --- /dev/null +++ b/tests/benchmarks/qml/holistic/data/jsImports/mldsi6.js @@ -0,0 +1,107 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +// This JavaScript file is a single, large, imported script. +// It imports other large scripts which are deeply nested. +// It is imported by another script. + +.import "msdsi7.js" as Msdsi7 + +function testFunc(seedValue) { + var retn = 0.65; + var firstFactor = calculateFirstFactor(seedValue); + var secondFactor = calculateSecondFactor(seedValue); + var modificationTerm = calculateModificationTerm(seedValue); + + // do some regexp matching + var someString = "This is a random string which we'll perform regular expression matching on to reduce considerably. This is meant to be part of a complex javascript expression whose evaluation takes considerably longer than the creation cost of QScriptValue."; + var regexpPattern = new RegExp("is", "i"); + var regexpOutputLength = 0; + var temp = regexpPattern.exec(someString); + while (temp == "is") { + regexpOutputLength += 4; + regexpOutputLength *= 2; + temp = regexpPattern.exec(someString); + if (regexpOutputLength > (seedValue * 3)) { + temp = "break"; + } + } + + // spin in a for loop for a while + var i = 0; + var j = 0; + var cumulativeTotal = 3; + for (i = 20; i > 1; i--) { + for (j = 31; j > 5; j--) { + var branchVariable = i + j; + if (branchVariable % 3 == 0) { + cumulativeTotal -= secondFactor; + } else { + cumulativeTotal += firstFactor; + } + + if (cumulativeTotal > (seedValue * 50)) { + break; + } + } + } + retn *= (1 + (cumulativeTotal * 0.001)); + retn *= Msdsi7.testFunc(seedValue + retn); + return retn; +} + +function calculateFirstFactor(seedValue) { + var firstFactor = (0.45 * (9.3 / 3.1) - 0.90); + firstFactor *= (1 + (0.00006 / seedValue)); + return firstFactor; +} + +function calculateSecondFactor(seedValue) { + var secondFactor = 0.78 * (6.3 / 2.1) - (0.39 * 4); + secondFactor *= (1 + (0.00006 / seedValue)); + return secondFactor; +} + +function calculateModificationTerm(seedValue) { + var modificationTerm = (12 + (9*7) - 54 + 16 - ((calculateFirstFactor(seedValue) * seedValue) / 3) + (4*calculateSecondFactor(seedValue) * seedValue * 1.33)) + (calculateSecondFactor(seedValue) * seedValue); + modificationTerm = modificationTerm + (33/2) + 19 - (9*2) - (61*3) + 177; + return modificationTerm; +} diff --git a/tests/benchmarks/qml/holistic/data/jsImports/mldsi7.js b/tests/benchmarks/qml/holistic/data/jsImports/mldsi7.js new file mode 100644 index 0000000000..07e69fe6ee --- /dev/null +++ b/tests/benchmarks/qml/holistic/data/jsImports/mldsi7.js @@ -0,0 +1,107 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +// This JavaScript file is a single, large, imported script. +// It imports other large scripts which are deeply nested. +// It is imported by another script. + +.import "msdsi8.js" as Msdsi8 + +function testFunc(seedValue) { + var retn = 0.75; + var firstFactor = calculateFirstFactor(seedValue); + var secondFactor = calculateSecondFactor(seedValue); + var modificationTerm = calculateModificationTerm(seedValue); + + // do some regexp matching + var someString = "This is a random string which we'll perform regular expression matching on to reduce considerably. This is meant to be part of a complex javascript expression whose evaluation takes considerably longer than the creation cost of QScriptValue."; + var regexpPattern = new RegExp("is", "i"); + var regexpOutputLength = 0; + var temp = regexpPattern.exec(someString); + while (temp == "is") { + regexpOutputLength += 4; + regexpOutputLength *= 2; + temp = regexpPattern.exec(someString); + if (regexpOutputLength > (seedValue * 3)) { + temp = "break"; + } + } + + // spin in a for loop for a while + var i = 0; + var j = 0; + var cumulativeTotal = 3; + for (i = 20; i > 1; i--) { + for (j = 31; j > 5; j--) { + var branchVariable = i + j; + if (branchVariable % 3 == 0) { + cumulativeTotal -= secondFactor; + } else { + cumulativeTotal += firstFactor; + } + + if (cumulativeTotal > (seedValue * 50)) { + break; + } + } + } + retn *= (1 + (cumulativeTotal * 0.001)); + retn *= Msdsi8.testFunc(seedValue + retn); + return retn; +} + +function calculateFirstFactor(seedValue) { + var firstFactor = (0.45 * (9.3 / 3.1) - 0.90); + firstFactor *= (1 + (0.00007 / seedValue)); + return firstFactor; +} + +function calculateSecondFactor(seedValue) { + var secondFactor = 0.78 * (6.3 / 2.1) - (0.39 * 4); + secondFactor *= (1 + (0.00007 / seedValue)); + return secondFactor; +} + +function calculateModificationTerm(seedValue) { + var modificationTerm = (12 + (9*7) - 54 + 16 - ((calculateFirstFactor(seedValue) * seedValue) / 3) + (4*calculateSecondFactor(seedValue) * seedValue * 1.33)) + (calculateSecondFactor(seedValue) * seedValue); + modificationTerm = modificationTerm + (33/2) + 19 - (9*2) - (61*3) + 177; + return modificationTerm; +} diff --git a/tests/benchmarks/qml/holistic/data/jsImports/mldsi8.js b/tests/benchmarks/qml/holistic/data/jsImports/mldsi8.js new file mode 100644 index 0000000000..cf245f461c --- /dev/null +++ b/tests/benchmarks/qml/holistic/data/jsImports/mldsi8.js @@ -0,0 +1,107 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +// This JavaScript file is a single, large, imported script. +// It imports other large scripts which are deeply nested. +// It is imported by another script. + +.import "msdsi9.js" as Msdsi9 + +function testFunc(seedValue) { + var retn = 0.85; + var firstFactor = calculateFirstFactor(seedValue); + var secondFactor = calculateSecondFactor(seedValue); + var modificationTerm = calculateModificationTerm(seedValue); + + // do some regexp matching + var someString = "This is a random string which we'll perform regular expression matching on to reduce considerably. This is meant to be part of a complex javascript expression whose evaluation takes considerably longer than the creation cost of QScriptValue."; + var regexpPattern = new RegExp("is", "i"); + var regexpOutputLength = 0; + var temp = regexpPattern.exec(someString); + while (temp == "is") { + regexpOutputLength += 4; + regexpOutputLength *= 2; + temp = regexpPattern.exec(someString); + if (regexpOutputLength > (seedValue * 3)) { + temp = "break"; + } + } + + // spin in a for loop for a while + var i = 0; + var j = 0; + var cumulativeTotal = 3; + for (i = 20; i > 1; i--) { + for (j = 31; j > 5; j--) { + var branchVariable = i + j; + if (branchVariable % 3 == 0) { + cumulativeTotal -= secondFactor; + } else { + cumulativeTotal += firstFactor; + } + + if (cumulativeTotal > (seedValue * 50)) { + break; + } + } + } + retn *= (1 + (cumulativeTotal * 0.001)); + retn *= Msdsi9.testFunc(seedValue + retn); + return retn; +} + +function calculateFirstFactor(seedValue) { + var firstFactor = (0.45 * (9.3 / 3.1) - 0.90); + firstFactor *= (1 + (0.00008 / seedValue)); + return firstFactor; +} + +function calculateSecondFactor(seedValue) { + var secondFactor = 0.78 * (6.3 / 2.1) - (0.39 * 4); + secondFactor *= (1 + (0.00008 / seedValue)); + return secondFactor; +} + +function calculateModificationTerm(seedValue) { + var modificationTerm = (12 + (9*7) - 54 + 16 - ((calculateFirstFactor(seedValue) * seedValue) / 3) + (4*calculateSecondFactor(seedValue) * seedValue * 1.33)) + (calculateSecondFactor(seedValue) * seedValue); + modificationTerm = modificationTerm + (33/2) + 19 - (9*2) - (61*3) + 177; + return modificationTerm; +} diff --git a/tests/benchmarks/qml/holistic/data/jsImports/mldsi9.js b/tests/benchmarks/qml/holistic/data/jsImports/mldsi9.js new file mode 100644 index 0000000000..2286e15d79 --- /dev/null +++ b/tests/benchmarks/qml/holistic/data/jsImports/mldsi9.js @@ -0,0 +1,107 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +// This JavaScript file is a single, large, imported script. +// It imports other large scripts which are deeply nested. +// It is imported by another script. + +.import "msdsi10.js" as Msdsi10 + +function testFunc(seedValue) { + var retn = 0.95; + var firstFactor = calculateFirstFactor(seedValue); + var secondFactor = calculateSecondFactor(seedValue); + var modificationTerm = calculateModificationTerm(seedValue); + + // do some regexp matching + var someString = "This is a random string which we'll perform regular expression matching on to reduce considerably. This is meant to be part of a complex javascript expression whose evaluation takes considerably longer than the creation cost of QScriptValue."; + var regexpPattern = new RegExp("is", "i"); + var regexpOutputLength = 0; + var temp = regexpPattern.exec(someString); + while (temp == "is") { + regexpOutputLength += 4; + regexpOutputLength *= 2; + temp = regexpPattern.exec(someString); + if (regexpOutputLength > (seedValue * 3)) { + temp = "break"; + } + } + + // spin in a for loop for a while + var i = 0; + var j = 0; + var cumulativeTotal = 3; + for (i = 20; i > 1; i--) { + for (j = 31; j > 5; j--) { + var branchVariable = i + j; + if (branchVariable % 3 == 0) { + cumulativeTotal -= secondFactor; + } else { + cumulativeTotal += firstFactor; + } + + if (cumulativeTotal > (seedValue * 50)) { + break; + } + } + } + retn *= (1 + (cumulativeTotal * 0.001)); + retn *= Msdsi10.testFunc(seedValue + retn); + return retn; +} + +function calculateFirstFactor(seedValue) { + var firstFactor = (0.45 * (9.3 / 3.1) - 0.90); + firstFactor *= (1 + (0.00009 / seedValue)); + return firstFactor; +} + +function calculateSecondFactor(seedValue) { + var secondFactor = 0.78 * (6.3 / 2.1) - (0.39 * 4); + secondFactor *= (1 + (0.00009 / seedValue)); + return secondFactor; +} + +function calculateModificationTerm(seedValue) { + var modificationTerm = (12 + (9*7) - 54 + 16 - ((calculateFirstFactor(seedValue) * seedValue) / 3) + (4*calculateSecondFactor(seedValue) * seedValue * 1.33)) + (calculateSecondFactor(seedValue) * seedValue); + modificationTerm = modificationTerm + (33/2) + 19 - (9*2) - (61*3) + 177; + return modificationTerm; +} diff --git a/tests/benchmarks/qml/holistic/data/jsImports/mlsi.js b/tests/benchmarks/qml/holistic/data/jsImports/mlsi.js new file mode 100644 index 0000000000..8c05cfb8bd --- /dev/null +++ b/tests/benchmarks/qml/holistic/data/jsImports/mlsi.js @@ -0,0 +1,138 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +// This JavaScript file is a single, large, imported script. +// It imports many other (non-nested) single, large, scripts, +// and also imports many other nested, large scripts. + +.import "mldsi4.js" as Mldsi4 +.import "mldsi9.js" as Mldsi9 +.import "mlbsi1.js" as Mlbsi1 +.import "mlbsi2.js" as Mlbsi2 +.import "mlbsi3.js" as Mlbsi3 +.import "mlbsi4.js" as Mlbsi4 +.import "mlbsi5.js" as Mlbsi5 +.import "mlbsi6.js" as Mlbsi6 +.import "mlbsi7.js" as Mlbsi7 +.import "mlbsi8.js" as Mlbsi8 +.import "mlbsi9.js" as Mlbsi9 +.import "mlbsi10.js" as Mlbsi10 +.import "mlbsi11.js" as Mlbsi11 +.import "mlbsi12.js" as Mlbsi12 +.import "mlbsi13.js" as Mlbsi13 +.import "mlbsi14.js" as Mlbsi14 +.import "mlbsi15.js" as Mlbsi15 + +function testFunc(seedValue) { + var firstFactor = calculateFirstFactor(seedValue); + var secondFactor = calculateSecondFactor(seedValue); + var modificationTerm = calculateModificationTerm(seedValue); + + // do some regexp matching + var someString = "This is a random string which we'll perform regular expression matching on to reduce considerably. This is meant to be part of a complex javascript expression whose evaluation takes considerably longer than the creation cost of QScriptValue."; + var regexpPattern = new RegExp("is", "i"); + var regexpOutputLength = 0; + var temp = regexpPattern.exec(someString); + while (temp == "is") { + regexpOutputLength += 4; + regexpOutputLength *= 2; + temp = regexpPattern.exec(someString); + if (regexpOutputLength > (seedValue * 3)) { + temp = "break"; + } + } + + // spin in a for loop for a while + var i = 0; + var j = 0; + var cumulativeTotal = 3; + for (i = 20; i > 1; i--) { + for (j = 31; j > 5; j--) { + var branchVariable = i + j; + if (branchVariable % 3 == 0) { + cumulativeTotal -= secondFactor; + } else { + cumulativeTotal += firstFactor; + } + + if (cumulativeTotal > (seedValue * 50)) { + break; + } + } + } + var retn = cumulativeTotal; + retn += Mlbsi1.testFunc(seedValue); + retn += Mlbsi2.testFunc(seedValue); + retn += Mlbsi3.testFunc(retn); + retn += Mlbsi4.testFunc(seedValue); + retn += Mlbsi5.testFunc(seedValue); + retn += Mlbsi6.testFunc(seedValue); + retn *= Mldsi9.testFunc(retn); + retn += Mlbsi7.testFunc(seedValue); + retn += Mlbsi8.testFunc(retn); + retn += Mlbsi9.testFunc(seedValue); + retn += Mlbsi10.testFunc(seedValue); + retn += Mlbsi11.testFunc(seedValue); + retn *= Mldsi4.testFunc(retn); + retn += Mlbsi12.testFunc(seedValue); + retn += Mlbsi13.testFunc(retn); + retn += Mlbsi14.testFunc(seedValue); + retn += Mlbsi15.testFunc(seedValue); + return retn; +} + +function calculateFirstFactor(seedValue) { + var firstFactor = (0.45 * (9.3 / 3.1) - 0.90); + firstFactor *= (1 + (0.00001 / seedValue)); + return firstFactor; +} + +function calculateSecondFactor(seedValue) { + var secondFactor = 0.78 * (6.3 / 2.1) - (0.39 * 4); + secondFactor *= (1 + (0.00001 / seedValue)); + return secondFactor; +} + +function calculateModificationTerm(seedValue) { + var modificationTerm = (12 + (9*7) - 54 + 16 - ((calculateFirstFactor(seedValue) * seedValue) / 3) + (4*calculateSecondFactor(seedValue) * seedValue * 1.33)) + (calculateSecondFactor(seedValue) * seedValue); + modificationTerm = modificationTerm + (33/2) + 19 - (9*2) - (61*3) + 177; + return modificationTerm; +} diff --git a/tests/benchmarks/qml/holistic/data/jsImports/moduleBm.js b/tests/benchmarks/qml/holistic/data/jsImports/moduleBm.js new file mode 100644 index 0000000000..29bd1f83af --- /dev/null +++ b/tests/benchmarks/qml/holistic/data/jsImports/moduleBm.js @@ -0,0 +1,109 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +// This JavaScript file is a single, large, imported script. +// It doesn't import any other scripts. +.import Qt.test 1.0 as QtTest + +function testFunc(seedValue) { + var retn = QtTest.EnumValue3; + var firstFactor = calculateFirstFactor(seedValue); + var secondFactor = calculateSecondFactor(seedValue); + var modificationTerm = calculateModificationTerm(seedValue); + + // do some regexp matching + var someString = "This is a random string which we'll perform regular expression matching on to reduce considerably. This is meant to be part of a complex javascript expression whose evaluation takes considerably longer than the creation cost of QScriptValue."; + var regexpPattern = new RegExp("is", "i"); + var regexpOutputLength = 0; + var temp = regexpPattern.exec(someString); + while (temp == "is") { + regexpOutputLength += 4; + regexpOutputLength *= 2; + temp = regexpPattern.exec(someString); + if (regexpOutputLength > (seedValue * 3)) { + temp = "break"; + } + } + + // spin in a for loop for a while + var i = 0; + var j = 0; + var cumulativeTotal = 3; + for (i = 20; i > 1; i--) { + for (j = 31; j > 5; j--) { + var branchVariable = i + j; + if (branchVariable % 3 == 0) { + cumulativeTotal -= secondFactor; + } else { + cumulativeTotal += firstFactor; + } + + if (cumulativeTotal > (seedValue * 50)) { + break; + } + } + } + retn += (cumulativeTotal * 0.45); + retn *= (1 + (3.1415962 / seedValue)); + retn /= 2.41497; + retn -= (seedValue * -1); + return retn; +} + +function calculateFirstFactor(seedValue) { + var firstFactor = (0.45 * (9.3 / 3.1) - 0.90); + firstFactor *= (1 + (0.00001 / seedValue)); + return firstFactor; +} + +function calculateSecondFactor(seedValue) { + var secondFactor = 0.78 * (6.3 / 2.1) - (0.39 * 4); + secondFactor *= (1 + (0.00001 / seedValue)); + return secondFactor; +} + +function calculateModificationTerm(seedValue) { + var modificationTerm = (12 + (9*7) - 54 + 16 - ((calculateFirstFactor(seedValue) * seedValue) / 3) + (4*calculateSecondFactor(seedValue) * seedValue * 1.33)) + (calculateSecondFactor(seedValue) * seedValue); + modificationTerm = modificationTerm + (33/2) + 19 - (9*2) - (61*3) + 177; + return modificationTerm; +} + + diff --git a/tests/benchmarks/qml/holistic/data/jsImports/msbsi.js b/tests/benchmarks/qml/holistic/data/jsImports/msbsi.js new file mode 100644 index 0000000000..5126faca00 --- /dev/null +++ b/tests/benchmarks/qml/holistic/data/jsImports/msbsi.js @@ -0,0 +1,79 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +// This JavaScript file is a single, small, imported script. +// It imports many other (non-nested) single, small, scripts. + +.import "msbsi1.js" as Msbsi1 +.import "msbsi2.js" as Msbsi2 +.import "msbsi3.js" as Msbsi3 +.import "msbsi4.js" as Msbsi4 +.import "msbsi5.js" as Msbsi5 +.import "msbsi6.js" as Msbsi6 +.import "msbsi7.js" as Msbsi7 +.import "msbsi8.js" as Msbsi8 +.import "msbsi9.js" as Msbsi9 +.import "msbsi10.js" as Msbsi10 +.import "msbsi11.js" as Msbsi11 +.import "msbsi12.js" as Msbsi12 +.import "msbsi13.js" as Msbsi13 +.import "msbsi14.js" as Msbsi14 +.import "msbsi15.js" as Msbsi15 + +function testFunc(seedValue) { + var retn = 10 * (seedValue * 0.45); + retn += Msbsi1.testFunc(seedValue); + retn += Msbsi2.testFunc(seedValue); + retn += Msbsi3.testFunc(seedValue); + retn += Msbsi4.testFunc(seedValue); + retn += Msbsi5.testFunc(seedValue); + retn += Msbsi6.testFunc(seedValue); + retn += Msbsi7.testFunc(seedValue); + retn += Msbsi8.testFunc(seedValue); + retn += Msbsi9.testFunc(seedValue); + retn += Msbsi10.testFunc(seedValue); + retn += Msbsi11.testFunc(seedValue); + retn += Msbsi12.testFunc(seedValue); + retn += Msbsi13.testFunc(seedValue); + retn += Msbsi14.testFunc(seedValue); + retn += Msbsi15.testFunc(seedValue); + return retn; +} diff --git a/tests/benchmarks/qml/holistic/data/jsImports/msbsi1.js b/tests/benchmarks/qml/holistic/data/jsImports/msbsi1.js new file mode 100644 index 0000000000..d5ba35fc97 --- /dev/null +++ b/tests/benchmarks/qml/holistic/data/jsImports/msbsi1.js @@ -0,0 +1,53 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +// This JavaScript file is a single, small, imported script. +// It doesn't import any other scripts. +// It is imported from another script. + +function testFunc(seedValue) { + var retn = 5; + retn += (seedValue * 0.145); + retn *= (1 + (3.1415962 / seedValue)); + retn /= 2.41497; + retn -= (seedValue * -1); + return retn; +} diff --git a/tests/benchmarks/qml/holistic/data/jsImports/msbsi10.js b/tests/benchmarks/qml/holistic/data/jsImports/msbsi10.js new file mode 100644 index 0000000000..f24ad0f7ee --- /dev/null +++ b/tests/benchmarks/qml/holistic/data/jsImports/msbsi10.js @@ -0,0 +1,53 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +// This JavaScript file is a single, small, imported script. +// It doesn't import any other scripts. +// It is imported from another script. + +function testFunc(seedValue) { + var retn = 5; + retn += (seedValue * 0.1045); + retn *= (1 + (3.1415962 / seedValue)); + retn /= 2.41497; + retn -= (seedValue * -1); + return retn; +} diff --git a/tests/benchmarks/qml/holistic/data/jsImports/msbsi11.js b/tests/benchmarks/qml/holistic/data/jsImports/msbsi11.js new file mode 100644 index 0000000000..30e072ab04 --- /dev/null +++ b/tests/benchmarks/qml/holistic/data/jsImports/msbsi11.js @@ -0,0 +1,53 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +// This JavaScript file is a single, small, imported script. +// It doesn't import any other scripts. +// It is imported from another script. + +function testFunc(seedValue) { + var retn = 5; + retn += (seedValue * 0.1145); + retn *= (1 + (3.1415962 / seedValue)); + retn /= 2.41497; + retn -= (seedValue * -1); + return retn; +} diff --git a/tests/benchmarks/qml/holistic/data/jsImports/msbsi12.js b/tests/benchmarks/qml/holistic/data/jsImports/msbsi12.js new file mode 100644 index 0000000000..3bf414a0ec --- /dev/null +++ b/tests/benchmarks/qml/holistic/data/jsImports/msbsi12.js @@ -0,0 +1,53 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +// This JavaScript file is a single, small, imported script. +// It doesn't import any other scripts. +// It is imported from another script. + +function testFunc(seedValue) { + var retn = 5; + retn += (seedValue * 0.1245); + retn *= (1 + (3.1415962 / seedValue)); + retn /= 2.41497; + retn -= (seedValue * -1); + return retn; +} diff --git a/tests/benchmarks/qml/holistic/data/jsImports/msbsi13.js b/tests/benchmarks/qml/holistic/data/jsImports/msbsi13.js new file mode 100644 index 0000000000..7487b7f1a9 --- /dev/null +++ b/tests/benchmarks/qml/holistic/data/jsImports/msbsi13.js @@ -0,0 +1,53 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +// This JavaScript file is a single, small, imported script. +// It doesn't import any other scripts. +// It is imported from another script. + +function testFunc(seedValue) { + var retn = 5; + retn += (seedValue * 0.1345); + retn *= (1 + (3.1415962 / seedValue)); + retn /= 2.41497; + retn -= (seedValue * -1); + return retn; +} diff --git a/tests/benchmarks/qml/holistic/data/jsImports/msbsi14.js b/tests/benchmarks/qml/holistic/data/jsImports/msbsi14.js new file mode 100644 index 0000000000..504b365752 --- /dev/null +++ b/tests/benchmarks/qml/holistic/data/jsImports/msbsi14.js @@ -0,0 +1,53 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +// This JavaScript file is a single, small, imported script. +// It doesn't import any other scripts. +// It is imported from another script. + +function testFunc(seedValue) { + var retn = 5; + retn += (seedValue * 0.1445); + retn *= (1 + (3.1415962 / seedValue)); + retn /= 2.41497; + retn -= (seedValue * -1); + return retn; +} diff --git a/tests/benchmarks/qml/holistic/data/jsImports/msbsi15.js b/tests/benchmarks/qml/holistic/data/jsImports/msbsi15.js new file mode 100644 index 0000000000..1887f157c1 --- /dev/null +++ b/tests/benchmarks/qml/holistic/data/jsImports/msbsi15.js @@ -0,0 +1,53 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +// This JavaScript file is a single, small, imported script. +// It doesn't import any other scripts. +// It is imported from another script. + +function testFunc(seedValue) { + var retn = 5; + retn += (seedValue * 0.1545); + retn *= (1 + (3.1415962 / seedValue)); + retn /= 2.41497; + retn -= (seedValue * -1); + return retn; +} diff --git a/tests/benchmarks/qml/holistic/data/jsImports/msbsi2.js b/tests/benchmarks/qml/holistic/data/jsImports/msbsi2.js new file mode 100644 index 0000000000..56997c1394 --- /dev/null +++ b/tests/benchmarks/qml/holistic/data/jsImports/msbsi2.js @@ -0,0 +1,53 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +// This JavaScript file is a single, small, imported script. +// It doesn't import any other scripts. +// It is imported from another script. + +function testFunc(seedValue) { + var retn = 5; + retn += (seedValue * 0.245); + retn *= (1 + (3.1415962 / seedValue)); + retn /= 2.41497; + retn -= (seedValue * -1); + return retn; +} diff --git a/tests/benchmarks/qml/holistic/data/jsImports/msbsi3.js b/tests/benchmarks/qml/holistic/data/jsImports/msbsi3.js new file mode 100644 index 0000000000..ce84ab63e4 --- /dev/null +++ b/tests/benchmarks/qml/holistic/data/jsImports/msbsi3.js @@ -0,0 +1,53 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +// This JavaScript file is a single, small, imported script. +// It doesn't import any other scripts. +// It is imported from another script. + +function testFunc(seedValue) { + var retn = 5; + retn += (seedValue * 0.345); + retn *= (1 + (3.1415962 / seedValue)); + retn /= 2.41497; + retn -= (seedValue * -1); + return retn; +} diff --git a/tests/benchmarks/qml/holistic/data/jsImports/msbsi4.js b/tests/benchmarks/qml/holistic/data/jsImports/msbsi4.js new file mode 100644 index 0000000000..61d15d11af --- /dev/null +++ b/tests/benchmarks/qml/holistic/data/jsImports/msbsi4.js @@ -0,0 +1,53 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +// This JavaScript file is a single, small, imported script. +// It doesn't import any other scripts. +// It is imported from another script. + +function testFunc(seedValue) { + var retn = 5; + retn += (seedValue * 0.445); + retn *= (1 + (3.1415962 / seedValue)); + retn /= 2.41497; + retn -= (seedValue * -1); + return retn; +} diff --git a/tests/benchmarks/qml/holistic/data/jsImports/msbsi5.js b/tests/benchmarks/qml/holistic/data/jsImports/msbsi5.js new file mode 100644 index 0000000000..e5bf0e1527 --- /dev/null +++ b/tests/benchmarks/qml/holistic/data/jsImports/msbsi5.js @@ -0,0 +1,53 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +// This JavaScript file is a single, small, imported script. +// It doesn't import any other scripts. +// It is imported from another script. + +function testFunc(seedValue) { + var retn = 5; + retn += (seedValue * 0.545); + retn *= (1 + (3.1415962 / seedValue)); + retn /= 2.41497; + retn -= (seedValue * -1); + return retn; +} diff --git a/tests/benchmarks/qml/holistic/data/jsImports/msbsi6.js b/tests/benchmarks/qml/holistic/data/jsImports/msbsi6.js new file mode 100644 index 0000000000..8f25ad23d8 --- /dev/null +++ b/tests/benchmarks/qml/holistic/data/jsImports/msbsi6.js @@ -0,0 +1,53 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +// This JavaScript file is a single, small, imported script. +// It doesn't import any other scripts. +// It is imported from another script. + +function testFunc(seedValue) { + var retn = 5; + retn += (seedValue * 0.645); + retn *= (1 + (3.1415962 / seedValue)); + retn /= 2.41497; + retn -= (seedValue * -1); + return retn; +} diff --git a/tests/benchmarks/qml/holistic/data/jsImports/msbsi7.js b/tests/benchmarks/qml/holistic/data/jsImports/msbsi7.js new file mode 100644 index 0000000000..70d521d3dc --- /dev/null +++ b/tests/benchmarks/qml/holistic/data/jsImports/msbsi7.js @@ -0,0 +1,53 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +// This JavaScript file is a single, small, imported script. +// It doesn't import any other scripts. +// It is imported from another script. + +function testFunc(seedValue) { + var retn = 5; + retn += (seedValue * 0.745); + retn *= (1 + (3.1415962 / seedValue)); + retn /= 2.41497; + retn -= (seedValue * -1); + return retn; +} diff --git a/tests/benchmarks/qml/holistic/data/jsImports/msbsi8.js b/tests/benchmarks/qml/holistic/data/jsImports/msbsi8.js new file mode 100644 index 0000000000..ed9f473ff9 --- /dev/null +++ b/tests/benchmarks/qml/holistic/data/jsImports/msbsi8.js @@ -0,0 +1,53 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +// This JavaScript file is a single, small, imported script. +// It doesn't import any other scripts. +// It is imported from another script. + +function testFunc(seedValue) { + var retn = 5; + retn += (seedValue * 0.845); + retn *= (1 + (3.1415962 / seedValue)); + retn /= 2.41497; + retn -= (seedValue * -1); + return retn; +} diff --git a/tests/benchmarks/qml/holistic/data/jsImports/msbsi9.js b/tests/benchmarks/qml/holistic/data/jsImports/msbsi9.js new file mode 100644 index 0000000000..73a8eaf37b --- /dev/null +++ b/tests/benchmarks/qml/holistic/data/jsImports/msbsi9.js @@ -0,0 +1,53 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +// This JavaScript file is a single, small, imported script. +// It doesn't import any other scripts. +// It is imported from another script. + +function testFunc(seedValue) { + var retn = 5; + retn += (seedValue * 0.945); + retn *= (1 + (3.1415962 / seedValue)); + retn /= 2.41497; + retn -= (seedValue * -1); + return retn; +} diff --git a/tests/benchmarks/qml/holistic/data/jsImports/msdsi.js b/tests/benchmarks/qml/holistic/data/jsImports/msdsi.js new file mode 100644 index 0000000000..f88af5b416 --- /dev/null +++ b/tests/benchmarks/qml/holistic/data/jsImports/msdsi.js @@ -0,0 +1,51 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +// This JavaScript file is a single, small, imported script. +// It imports other small scripts which are deeply nested. + +.import "msdsi1.js" as Msdsi1 + +function testFunc(seedValue) { + var retn = 0.5; + retn *= Msdsi1.testFunc(seedValue + retn); + return retn; +} diff --git a/tests/benchmarks/qml/holistic/data/jsImports/msdsi1.js b/tests/benchmarks/qml/holistic/data/jsImports/msdsi1.js new file mode 100644 index 0000000000..1d60d24b5e --- /dev/null +++ b/tests/benchmarks/qml/holistic/data/jsImports/msdsi1.js @@ -0,0 +1,52 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +// This JavaScript file is a single, small, imported script. +// It imports other small scripts which are deeply nested. +// It is imported by another script. + +.import "msdsi2.js" as Msdsi2 + +function testFunc(seedValue) { + var retn = 0.15; + retn *= Msdsi2.testFunc(seedValue + retn); + return retn; +} diff --git a/tests/benchmarks/qml/holistic/data/jsImports/msdsi10.js b/tests/benchmarks/qml/holistic/data/jsImports/msdsi10.js new file mode 100644 index 0000000000..8b1151f3e2 --- /dev/null +++ b/tests/benchmarks/qml/holistic/data/jsImports/msdsi10.js @@ -0,0 +1,52 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +// This JavaScript file is a single, small, imported script. +// It imports other small scripts which are deeply nested. +// It is imported by another script. + +.import "msdsi11.js" as Msdsi11 + +function testFunc(seedValue) { + var retn = 0.105; + retn *= Msdsi11.testFunc(seedValue + retn); + return retn; +} diff --git a/tests/benchmarks/qml/holistic/data/jsImports/msdsi11.js b/tests/benchmarks/qml/holistic/data/jsImports/msdsi11.js new file mode 100644 index 0000000000..b27d0f37af --- /dev/null +++ b/tests/benchmarks/qml/holistic/data/jsImports/msdsi11.js @@ -0,0 +1,52 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +// This JavaScript file is a single, small, imported script. +// It imports other small scripts which are deeply nested. +// It is imported by another script. + +.import "msdsi12.js" as Msdsi12 + +function testFunc(seedValue) { + var retn = 0.115; + retn *= Msdsi12.testFunc(seedValue + retn); + return retn; +} diff --git a/tests/benchmarks/qml/holistic/data/jsImports/msdsi12.js b/tests/benchmarks/qml/holistic/data/jsImports/msdsi12.js new file mode 100644 index 0000000000..ba62852113 --- /dev/null +++ b/tests/benchmarks/qml/holistic/data/jsImports/msdsi12.js @@ -0,0 +1,52 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +// This JavaScript file is a single, small, imported script. +// It imports other small scripts which are deeply nested. +// It is imported by another script. + +.import "msdsi13.js" as Msdsi13 + +function testFunc(seedValue) { + var retn = 0.125; + retn *= Msdsi13.testFunc(seedValue + retn); + return retn; +} diff --git a/tests/benchmarks/qml/holistic/data/jsImports/msdsi13.js b/tests/benchmarks/qml/holistic/data/jsImports/msdsi13.js new file mode 100644 index 0000000000..f4b17ff627 --- /dev/null +++ b/tests/benchmarks/qml/holistic/data/jsImports/msdsi13.js @@ -0,0 +1,52 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +// This JavaScript file is a single, small, imported script. +// It imports other small scripts which are deeply nested. +// It is imported by another script. + +.import "msdsi14.js" as Msdsi14 + +function testFunc(seedValue) { + var retn = 0.135; + retn *= Msdsi14.testFunc(seedValue + retn); + return retn; +} diff --git a/tests/benchmarks/qml/holistic/data/jsImports/msdsi14.js b/tests/benchmarks/qml/holistic/data/jsImports/msdsi14.js new file mode 100644 index 0000000000..4f96539faf --- /dev/null +++ b/tests/benchmarks/qml/holistic/data/jsImports/msdsi14.js @@ -0,0 +1,52 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +// This JavaScript file is a single, small, imported script. +// It imports other small scripts which are deeply nested. +// It is imported by another script. + +.import "msdsi15.js" as Msdsi15 + +function testFunc(seedValue) { + var retn = 0.145; + retn *= Msdsi15.testFunc(seedValue + retn); + return retn; +} diff --git a/tests/benchmarks/qml/holistic/data/jsImports/msdsi15.js b/tests/benchmarks/qml/holistic/data/jsImports/msdsi15.js new file mode 100644 index 0000000000..113ed1bdc8 --- /dev/null +++ b/tests/benchmarks/qml/holistic/data/jsImports/msdsi15.js @@ -0,0 +1,49 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +// This JavaScript file is a single, small, imported script. +// It is imported by another script. + +function testFunc(seedValue) { + var retn = 0.155; + retn *= (seedValue + retn); + return retn; +} diff --git a/tests/benchmarks/qml/holistic/data/jsImports/msdsi2.js b/tests/benchmarks/qml/holistic/data/jsImports/msdsi2.js new file mode 100644 index 0000000000..67a35bc3ae --- /dev/null +++ b/tests/benchmarks/qml/holistic/data/jsImports/msdsi2.js @@ -0,0 +1,52 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +// This JavaScript file is a single, small, imported script. +// It imports other small scripts which are deeply nested. +// It is imported by another script. + +.import "msdsi3.js" as Msdsi3 + +function testFunc(seedValue) { + var retn = 0.25; + retn *= Msdsi3.testFunc(seedValue + retn); + return retn; +} diff --git a/tests/benchmarks/qml/holistic/data/jsImports/msdsi3.js b/tests/benchmarks/qml/holistic/data/jsImports/msdsi3.js new file mode 100644 index 0000000000..81b4747409 --- /dev/null +++ b/tests/benchmarks/qml/holistic/data/jsImports/msdsi3.js @@ -0,0 +1,52 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +// This JavaScript file is a single, small, imported script. +// It imports other small scripts which are deeply nested. +// It is imported by another script. + +.import "msdsi4.js" as Msdsi4 + +function testFunc(seedValue) { + var retn = 0.35; + retn *= Msdsi4.testFunc(seedValue + retn); + return retn; +} diff --git a/tests/benchmarks/qml/holistic/data/jsImports/msdsi4.js b/tests/benchmarks/qml/holistic/data/jsImports/msdsi4.js new file mode 100644 index 0000000000..37a4d9d2aa --- /dev/null +++ b/tests/benchmarks/qml/holistic/data/jsImports/msdsi4.js @@ -0,0 +1,52 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +// This JavaScript file is a single, small, imported script. +// It imports other small scripts which are deeply nested. +// It is imported by another script. + +.import "msdsi5.js" as Msdsi5 + +function testFunc(seedValue) { + var retn = 0.45; + retn *= Msdsi5.testFunc(seedValue + retn); + return retn; +} diff --git a/tests/benchmarks/qml/holistic/data/jsImports/msdsi5.js b/tests/benchmarks/qml/holistic/data/jsImports/msdsi5.js new file mode 100644 index 0000000000..df57e75cea --- /dev/null +++ b/tests/benchmarks/qml/holistic/data/jsImports/msdsi5.js @@ -0,0 +1,52 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +// This JavaScript file is a single, small, imported script. +// It imports other small scripts which are deeply nested. +// It is imported by another script. + +.import "msdsi6.js" as Msdsi6 + +function testFunc(seedValue) { + var retn = 0.55; + retn *= Msdsi6.testFunc(seedValue + retn); + return retn; +} diff --git a/tests/benchmarks/qml/holistic/data/jsImports/msdsi6.js b/tests/benchmarks/qml/holistic/data/jsImports/msdsi6.js new file mode 100644 index 0000000000..43e0b43877 --- /dev/null +++ b/tests/benchmarks/qml/holistic/data/jsImports/msdsi6.js @@ -0,0 +1,52 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +// This JavaScript file is a single, small, imported script. +// It imports other small scripts which are deeply nested. +// It is imported by another script. + +.import "msdsi7.js" as Msdsi7 + +function testFunc(seedValue) { + var retn = 0.65; + retn *= Msdsi7.testFunc(seedValue + retn); + return retn; +} diff --git a/tests/benchmarks/qml/holistic/data/jsImports/msdsi7.js b/tests/benchmarks/qml/holistic/data/jsImports/msdsi7.js new file mode 100644 index 0000000000..569b613e92 --- /dev/null +++ b/tests/benchmarks/qml/holistic/data/jsImports/msdsi7.js @@ -0,0 +1,52 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +// This JavaScript file is a single, small, imported script. +// It imports other small scripts which are deeply nested. +// It is imported by another script. + +.import "msdsi8.js" as Msdsi8 + +function testFunc(seedValue) { + var retn = 0.75; + retn *= Msdsi8.testFunc(seedValue + retn); + return retn; +} diff --git a/tests/benchmarks/qml/holistic/data/jsImports/msdsi8.js b/tests/benchmarks/qml/holistic/data/jsImports/msdsi8.js new file mode 100644 index 0000000000..b1a5bd514b --- /dev/null +++ b/tests/benchmarks/qml/holistic/data/jsImports/msdsi8.js @@ -0,0 +1,52 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +// This JavaScript file is a single, small, imported script. +// It imports other small scripts which are deeply nested. +// It is imported by another script. + +.import "msdsi9.js" as Msdsi9 + +function testFunc(seedValue) { + var retn = 0.85; + retn *= Msdsi9.testFunc(seedValue + retn); + return retn; +} diff --git a/tests/benchmarks/qml/holistic/data/jsImports/msdsi9.js b/tests/benchmarks/qml/holistic/data/jsImports/msdsi9.js new file mode 100644 index 0000000000..3a0c4d0354 --- /dev/null +++ b/tests/benchmarks/qml/holistic/data/jsImports/msdsi9.js @@ -0,0 +1,52 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +// This JavaScript file is a single, small, imported script. +// It imports other small scripts which are deeply nested. +// It is imported by another script. + +.import "msdsi10.js" as Msdsi10 + +function testFunc(seedValue) { + var retn = 0.95; + retn *= Msdsi10.testFunc(seedValue + retn); + return retn; +} diff --git a/tests/benchmarks/qml/holistic/data/jsImports/mssi.js b/tests/benchmarks/qml/holistic/data/jsImports/mssi.js new file mode 100644 index 0000000000..7a82033d88 --- /dev/null +++ b/tests/benchmarks/qml/holistic/data/jsImports/mssi.js @@ -0,0 +1,84 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +// This JavaScript file is a single, small, imported script. +// It imports many other (non-nested) single, small, scripts, +// and also imports many other nested, small scripts. + +.import "msdsi4.js" as Msdsi4 +.import "msdsi9.js" as Msdsi9 +.import "msbsi1.js" as Msbsi1 +.import "msbsi2.js" as Msbsi2 +.import "msbsi3.js" as Msbsi3 +.import "msbsi4.js" as Msbsi4 +.import "msbsi5.js" as Msbsi5 +.import "msbsi6.js" as Msbsi6 +.import "msbsi7.js" as Msbsi7 +.import "msbsi8.js" as Msbsi8 +.import "msbsi9.js" as Msbsi9 +.import "msbsi10.js" as Msbsi10 +.import "msbsi11.js" as Msbsi11 +.import "msbsi12.js" as Msbsi12 +.import "msbsi13.js" as Msbsi13 +.import "msbsi14.js" as Msbsi14 +.import "msbsi15.js" as Msbsi15 + +function testFunc(seedValue) { + var retn = 10 * (seedValue * 0.85); + retn += Msbsi1.testFunc(seedValue); + retn += Msbsi2.testFunc(seedValue); + retn += Msbsi3.testFunc(retn); + retn += Msbsi4.testFunc(seedValue); + retn += Msbsi5.testFunc(seedValue); + retn += Msbsi6.testFunc(seedValue); + retn *= Msdsi9.testFunc(retn); + retn += Msbsi7.testFunc(seedValue); + retn += Msbsi8.testFunc(retn); + retn += Msbsi9.testFunc(seedValue); + retn += Msbsi10.testFunc(seedValue); + retn += Msbsi11.testFunc(seedValue); + retn *= Msdsi4.testFunc(retn); + retn += Msbsi12.testFunc(seedValue); + retn += Msbsi13.testFunc(retn); + retn += Msbsi14.testFunc(seedValue); + retn += Msbsi15.testFunc(seedValue); + return retn; +} diff --git a/tests/benchmarks/qml/holistic/data/jsImports/pragmaBmOne.js b/tests/benchmarks/qml/holistic/data/jsImports/pragmaBmOne.js new file mode 100644 index 0000000000..b92b79afaf --- /dev/null +++ b/tests/benchmarks/qml/holistic/data/jsImports/pragmaBmOne.js @@ -0,0 +1,50 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +// This JavaScript file is a single, large, imported script. +// It imports a shared library script. +.import "pragmaLib.js" as PragmaLibJs + +function testFuncOne(seedValue) { + var retn = seedValue + 2; + retn += PragmaLibJs.testFunc(); + return retn; +} diff --git a/tests/benchmarks/qml/holistic/data/jsImports/pragmaBmTwo.js b/tests/benchmarks/qml/holistic/data/jsImports/pragmaBmTwo.js new file mode 100644 index 0000000000..c086016bef --- /dev/null +++ b/tests/benchmarks/qml/holistic/data/jsImports/pragmaBmTwo.js @@ -0,0 +1,50 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +// This JavaScript file is a single, large, imported script. +// It imports a shared library script. +.import "pragmaLib.js" as PragmaLibJs + +function testFuncTwo(seedValue) { + var retn = seedValue + 3; + retn += PragmaLibJs.testFunc(); + return retn; +} diff --git a/tests/benchmarks/qml/holistic/data/jsImports/pragmaLib.js b/tests/benchmarks/qml/holistic/data/jsImports/pragmaLib.js new file mode 100644 index 0000000000..8b65a68111 --- /dev/null +++ b/tests/benchmarks/qml/holistic/data/jsImports/pragmaLib.js @@ -0,0 +1,119 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +// This JavaScript file is a single, large, imported script. +// It doesn't import any other scripts. +// It is a shared script, with data which should be shared. +.pragma library + +var sharedValue = 9; + +function testFunc() { + var retn = sharedValue; + sharedValue += 1; // increment the shared value + return retn; +} + +function testFuncBig(seedValue) { + var retn = sharedValue; + var firstFactor = calculateFirstFactor(seedValue); + var secondFactor = calculateSecondFactor(seedValue); + var modificationTerm = calculateModificationTerm(seedValue); + + // do some regexp matching + var someString = "This is a random string which we'll perform regular expression matching on to reduce considerably. This is meant to be part of a complex javascript expression whose evaluation takes considerably longer than the creation cost of QScriptValue."; + var regexpPattern = new RegExp("is", "i"); + var regexpOutputLength = 0; + var temp = regexpPattern.exec(someString); + while (temp == "is") { + regexpOutputLength += 4; + regexpOutputLength *= 2; + temp = regexpPattern.exec(someString); + if (regexpOutputLength > (seedValue * 3)) { + temp = "break"; + } + } + + // spin in a for loop for a while + var i = 0; + var j = 0; + var cumulativeTotal = 3; + for (i = 20; i > 1; i--) { + for (j = 31; j > 5; j--) { + var branchVariable = i + j; + if (branchVariable % 3 == 0) { + cumulativeTotal -= secondFactor; + } else { + cumulativeTotal += firstFactor; + } + + if (cumulativeTotal > (seedValue * 50)) { + break; + } + } + } + retn += (cumulativeTotal * 0.45); + retn *= (1 + (3.1415962 / seedValue)); + retn /= 2.41497; + retn -= (seedValue * -1); + sharedValue += 1; // increment the shared value + return retn; +} + +function calculateFirstFactor(seedValue) { + var firstFactor = (0.45 * (9.3 / 3.1) - 0.90); + firstFactor *= (1 + (0.00001 / seedValue)); + return firstFactor; +} + +function calculateSecondFactor(seedValue) { + var secondFactor = 0.78 * (6.3 / 2.1) - (0.39 * 4); + secondFactor *= (1 + (0.00001 / seedValue)); + return secondFactor; +} + +function calculateModificationTerm(seedValue) { + var modificationTerm = (12 + (9*7) - 54 + 16 - ((calculateFirstFactor(seedValue) * seedValue) / 3) + (4*calculateSecondFactor(seedValue) * seedValue * 1.33)) + (calculateSecondFactor(seedValue) * seedValue); + modificationTerm = modificationTerm + (33/2) + 19 - (9*2) - (61*3) + 177; + return modificationTerm; +} + + diff --git a/tests/benchmarks/qml/holistic/data/jsImports/pragmaModuleBm.js b/tests/benchmarks/qml/holistic/data/jsImports/pragmaModuleBm.js new file mode 100644 index 0000000000..df710f1acf --- /dev/null +++ b/tests/benchmarks/qml/holistic/data/jsImports/pragmaModuleBm.js @@ -0,0 +1,57 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +// This JavaScript file is a single, large, imported script. +// It imports a QML module and two other scripts. +// Each of those two other scripts imports a single script, +// which is a .pragma library script (shared between the two). + +.import Qt.test 1.0 as QtTest +.import "pragmaBmOne.js" as PragmaBmOneJs +.import "pragmaBmTwo.js" as PragmaBmTwoJs + +function testFuncThree(seedValue) { + var retn = seedValue + QtTest.EnumValue3; + retn += PragmaBmOneJs.testFuncOne(seedValue); + retn += PragmaBmTwoJs.testFuncTwo(seedValue); + return retn; +} + diff --git a/tests/benchmarks/qml/holistic/data/jsImports/slsi.js b/tests/benchmarks/qml/holistic/data/jsImports/slsi.js new file mode 100644 index 0000000000..98af47885f --- /dev/null +++ b/tests/benchmarks/qml/holistic/data/jsImports/slsi.js @@ -0,0 +1,108 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +// This JavaScript file is a single, large, imported script. +// It doesn't import any other scripts. + +function testFunc(seedValue) { + var retn = 5; + var firstFactor = calculateFirstFactor(seedValue); + var secondFactor = calculateSecondFactor(seedValue); + var modificationTerm = calculateModificationTerm(seedValue); + + // do some regexp matching + var someString = "This is a random string which we'll perform regular expression matching on to reduce considerably. This is meant to be part of a complex javascript expression whose evaluation takes considerably longer than the creation cost of QScriptValue."; + var regexpPattern = new RegExp("is", "i"); + var regexpOutputLength = 0; + var temp = regexpPattern.exec(someString); + while (temp == "is") { + regexpOutputLength += 4; + regexpOutputLength *= 2; + temp = regexpPattern.exec(someString); + if (regexpOutputLength > (seedValue * 3)) { + temp = "break"; + } + } + + // spin in a for loop for a while + var i = 0; + var j = 0; + var cumulativeTotal = 3; + for (i = 20; i > 1; i--) { + for (j = 31; j > 5; j--) { + var branchVariable = i + j; + if (branchVariable % 3 == 0) { + cumulativeTotal -= secondFactor; + } else { + cumulativeTotal += firstFactor; + } + + if (cumulativeTotal > (seedValue * 50)) { + break; + } + } + } + retn += (cumulativeTotal * 0.45); + retn *= (1 + (3.1415962 / seedValue)); + retn /= 2.41497; + retn -= (seedValue * -1); + return retn; +} + +function calculateFirstFactor(seedValue) { + var firstFactor = (0.45 * (9.3 / 3.1) - 0.90); + firstFactor *= (1 + (0.00001 / seedValue)); + return firstFactor; +} + +function calculateSecondFactor(seedValue) { + var secondFactor = 0.78 * (6.3 / 2.1) - (0.39 * 4); + secondFactor *= (1 + (0.00001 / seedValue)); + return secondFactor; +} + +function calculateModificationTerm(seedValue) { + var modificationTerm = (12 + (9*7) - 54 + 16 - ((calculateFirstFactor(seedValue) * seedValue) / 3) + (4*calculateSecondFactor(seedValue) * seedValue * 1.33)) + (calculateSecondFactor(seedValue) * seedValue); + modificationTerm = modificationTerm + (33/2) + 19 - (9*2) - (61*3) + 177; + return modificationTerm; +} + + diff --git a/tests/benchmarks/qml/holistic/data/jsImports/sssi.js b/tests/benchmarks/qml/holistic/data/jsImports/sssi.js new file mode 100644 index 0000000000..88d9fb643b --- /dev/null +++ b/tests/benchmarks/qml/holistic/data/jsImports/sssi.js @@ -0,0 +1,52 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +// This JavaScript file is a single, small, imported script. +// It doesn't import any other scripts. + +function testFunc(seedValue) { + var retn = 5; + retn += (seedValue * 0.45); + retn *= (1 + (3.1415962 / seedValue)); + retn /= 2.41497; + retn -= (seedValue * -1); + return retn; +} diff --git a/tests/benchmarks/qml/holistic/data/jsTargets/JsOne.qml b/tests/benchmarks/qml/holistic/data/jsTargets/JsOne.qml new file mode 100644 index 0000000000..41d4ff5bbd --- /dev/null +++ b/tests/benchmarks/qml/holistic/data/jsTargets/JsOne.qml @@ -0,0 +1,61 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Item { + id: root + property int dynamicWidth: 10 + property int widthSignaledProperty: 20 + + Rectangle { + width: 100 + height: 50 + color: "red" + border.color: "black" + border.width: 5 + radius: 10 + } + + onDynamicWidthChanged: { + widthSignaledProperty = dynamicWidth + (20/4) + 7 - 1; + } +} diff --git a/tests/benchmarks/qml/holistic/data/jsTargets/JsTwo.qml b/tests/benchmarks/qml/holistic/data/jsTargets/JsTwo.qml new file mode 100644 index 0000000000..cb5da5a22d --- /dev/null +++ b/tests/benchmarks/qml/holistic/data/jsTargets/JsTwo.qml @@ -0,0 +1,118 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Item { + id: root + property int dynamicWidth: 10 + property int widthSignaledProperty: 20 + + Rectangle { + width: 100 + height: 50 + color: "red" + border.color: "black" + border.width: 5 + radius: 10 + } + + function calculateFirstFactor(seedValue) { + var firstFactor = (0.45 * (9.3 / 3.1) - 0.90); + firstFactor *= (1 + (0.00001 / seedValue)); + return firstFactor; + } + + function calculateSecondFactor(seedValue) { + var secondFactor = 0.78 * (6.3 / 2.1) - (0.39 * 4); + secondFactor *= (1 + (0.00001 / seedValue)); + return secondFactor; + } + + function calculateModificationTerm(seedValue) { + var modificationTerm = (12 + (9*7) - 54 + 16 - ((root.calculateFirstFactor(seedValue + 0.3) * seedValue) / 3) + (4*root.calculateSecondFactor(seedValue+2) * seedValue * 1.33)) + (root.calculateSecondFactor(seedValue+1) * seedValue); + modificationTerm = modificationTerm + (33/2) + 19 - (9*2) - (61*3) + 177; + return modificationTerm; + } + + onDynamicWidthChanged: { + // do a bit of maths + var firstFactor = root.calculateFirstFactor(8); + var secondFactor = root.calculateSecondFactor(dynamicWidth / firstFactor); + var modificationTerm = root.calculateModificationTerm(dynamicWidth / secondFactor); + + // do some regexp matching + var someString = "This is a random string which we'll perform regular expression matching on to reduce considerably. This is meant to be part of a complex javascript expression whose evaluation takes considerably longer than the creation cost of QScriptValue."; + var regexpPattern = new RegExp("is", "i"); + var regexpOutputLength = 0; + var temp = regexpPattern.exec(someString); + while (temp == "is") { + regexpOutputLength += 4; + regexpOutputLength *= 2; + temp = regexpPattern.exec(someString); + if (regexpOutputLength > (dynamicWidth * 3)) { + temp = "break"; + } + } + + // spin in a for loop for a while + var i = 0; + var j = 0; + var cumulativeTotal = 3; + for (i = 20; i > 1; i--) { + for (j = 31; j > 5; j--) { + var branchVariable = i + j; + if (branchVariable % 3 == 0) { + cumulativeTotal -= secondFactor; + } else { + cumulativeTotal += firstFactor; + } + + if (cumulativeTotal > (dynamicWidth * 50)) { + break; + } + } + } + + // and update the property + widthSignaledProperty = (dynamicWidth + (20/4) + 7 - 1) * modificationTerm + regexpOutputLength - (cumulativeTotal / 73); + } +} diff --git a/tests/benchmarks/qml/holistic/data/largeTargets/gridview-example.qml b/tests/benchmarks/qml/holistic/data/largeTargets/gridview-example.qml new file mode 100644 index 0000000000..373b1b8ced --- /dev/null +++ b/tests/benchmarks/qml/holistic/data/largeTargets/gridview-example.qml @@ -0,0 +1,91 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Rectangle { + width: 300; height: 400 + color: "white" + + ListModel { + id: appModel + ListElement { name: "Music"; shade: "blue" } + ListElement { name: "Movies"; shade: "red" } + ListElement { name: "Camera"; shade: "green" } + ListElement { name: "Calendar"; shade: "yellow" } + ListElement { name: "Messaging"; shade: "cyan" } + ListElement { name: "Todo List"; shade: "magenta" } + ListElement { name: "Contacts"; shade: "black" } + } + + Component { + id: appDelegate + + Item { + width: 100; height: 100 + + Rectangle { + id: myColoredIcon + width: 20 + height: 20 + y: 20; anchors.horizontalCenter: parent.horizontalCenter + color: shade + } + Text { + anchors { top: myColoredIcon.bottom; horizontalCenter: parent.horizontalCenter } + text: name + } + } + } + + Component { + id: appHighlight + Rectangle { width: 80; height: 80; color: "lightsteelblue" } + } + + GridView { + anchors.fill: parent + cellWidth: 100; cellHeight: 100 + highlight: appHighlight + focus: true + model: appModel + delegate: appDelegate + } +} diff --git a/tests/benchmarks/qml/holistic/data/largeTargets/layoutdirection.qml b/tests/benchmarks/qml/holistic/data/largeTargets/layoutdirection.qml new file mode 100644 index 0000000000..9f039594b3 --- /dev/null +++ b/tests/benchmarks/qml/holistic/data/largeTargets/layoutdirection.qml @@ -0,0 +1,151 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Rectangle { + + width: column.width + 100 + height: column.height + 100 + property int direction: Qt.application.layoutDirection + + Column { + id: column + spacing: 10 + anchors.centerIn: parent + width: 230 + + Text { + text: "Row" + anchors.horizontalCenter: parent.horizontalCenter + } + Row { + layoutDirection: direction + spacing: 10 + move: Transition { + NumberAnimation { + properties: "x" + } + } + Repeater { + model: 4 + Loader { + property int value: index + sourceComponent: delegate + } + } + } + Text { + text: "Grid" + anchors.horizontalCenter: parent.horizontalCenter + } + Grid { + layoutDirection: direction + spacing: 10; columns: 4 + move: Transition { + NumberAnimation { + properties: "x" + } + } + Repeater { + model: 11 + Loader { + property int value: index + sourceComponent: delegate + } + } + } + Text { + text: "Flow" + anchors.horizontalCenter: parent.horizontalCenter + } + Flow { + layoutDirection: direction + spacing: 10; width: parent.width + move: Transition { + NumberAnimation { + properties: "x" + } + } + Repeater { + model: 10 + Loader { + property int value: index + sourceComponent: delegate + } + } + } + Rectangle { + height: 50; width: parent.width + color: mouseArea.pressed ? "black" : "gray" + Text { + text: direction ? "Right to left" : "Left to right" + color: "white" + font.pixelSize: 16 + anchors.centerIn: parent + } + MouseArea { + id: mouseArea + onClicked: { + if (direction == Qt.LeftToRight) { + direction = Qt.RightToLeft; + } else { + direction = Qt.LeftToRight; + } + } + anchors.fill: parent + } + } + } + + Component { + id: delegate + Rectangle { + width: 50; height: 50 + color: Qt.rgba(0.8/(parent.value+1),0.8/(parent.value+1),0.8/(parent.value+1),1.0) + Text { + text: parent.parent.value+1 + color: "white" + font.pixelSize: 20 + anchors.centerIn: parent + } + } + } +} diff --git a/tests/benchmarks/qml/holistic/data/largeTargets/mousearea-example.qml b/tests/benchmarks/qml/holistic/data/largeTargets/mousearea-example.qml new file mode 100644 index 0000000000..4c82b58302 --- /dev/null +++ b/tests/benchmarks/qml/holistic/data/largeTargets/mousearea-example.qml @@ -0,0 +1,112 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Rectangle { + id: box + width: 350; height: 250 + + Rectangle { + id: redSquare + width: 80; height: 80 + anchors.top: parent.top; anchors.left: parent.left; anchors.margins: 10 + color: "red" + + Text { text: "Click"; font.pixelSize: 16; anchors.centerIn: parent } + + MouseArea { + anchors.fill: parent + hoverEnabled: true + acceptedButtons: Qt.LeftButton | Qt.RightButton + + onEntered: info.text = 'Entered' + onExited: info.text = 'Exited (pressed=' + pressed + ')' + + onPressed: { + info.text = 'Pressed (button=' + (mouse.button == Qt.RightButton ? 'right' : 'left') + + ' shift=' + (mouse.modifiers & Qt.ShiftModifier ? 'true' : 'false') + ')' + var posInBox = redSquare.mapToItem(box, mouse.x, mouse.y) + posInfo.text = + mouse.x + ',' + mouse.y + ' in square' + + ' (' + posInBox.x + ',' + posInBox.y + ' in window)' + } + + onReleased: { + info.text = 'Released (isClick=' + mouse.isClick + ' wasHeld=' + mouse.wasHeld + ')' + posInfo.text = '' + } + + onPressAndHold: info.text = 'Press and hold' + onClicked: info.text = 'Clicked (wasHeld=' + mouse.wasHeld + ')' + onDoubleClicked: info.text = 'Double clicked' + } + } + + Rectangle { + id: blueSquare + width: 80; height: 80 + x: box.width - width - 10; y: 10 // making this item draggable, so don't use anchors + color: "blue" + + Text { text: "Drag"; font.pixelSize: 16; color: "white"; anchors.centerIn: parent } + + MouseArea { + anchors.fill: parent + drag.target: blueSquare + drag.axis: Drag.XandYAxis + drag.minimumX: 0 + drag.maximumX: box.width - parent.width + drag.minimumY: 0 + drag.maximumY: box.height - parent.width + } + } + + Text { + id: info + anchors.bottom: posInfo.top; anchors.horizontalCenter: parent.horizontalCenter; anchors.margins: 30 + + onTextChanged: console.log(text) + } + + Text { + id: posInfo + anchors.bottom: parent.bottom; anchors.horizontalCenter: parent.horizontalCenter; anchors.margins: 30 + } +} diff --git a/tests/benchmarks/qml/holistic/data/resolutionTargets/ResolveOne.qml b/tests/benchmarks/qml/holistic/data/resolutionTargets/ResolveOne.qml new file mode 100644 index 0000000000..2673ac36ed --- /dev/null +++ b/tests/benchmarks/qml/holistic/data/resolutionTargets/ResolveOne.qml @@ -0,0 +1,111 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +// This file has some nested items and does a lot of id resolution. +// This will allow us to benchmark the cost of resolving names in +// bindings. + +import QtQuick 2.0 + +Item { + id: root + property int baseWidth: 500 + property int baseHeight: 600 + property string baseColor: "red" + + Item { + id: childOne + property int baseWidth: root.baseWidth - 1 + property int baseHeight: root.baseHeight - 1 + property string baseColor: root.baseColor + + Item { + id: childTwo + property int baseWidth: root.baseWidth - 2 + property int baseHeight: childOne.baseHeight - 1 + property string baseColor: childOne.baseColor + + Item { + id: childThree + property int baseWidth: childOne.baseWidth - 2 + property int baseHeight: root.baseHeight - 3 + property string baseColor: "blue" + + Item { + id: childFour + property int baseWidth: childTwo.baseWidth - 2 + property int baseHeight: childThree.baseHeight - 1 + property string baseColor: "earthy " + root.baseColor + + Item { + id: childFive + property int baseWidth: root.baseWidth - 5 + property int baseHeight: childFour.baseHeight - 1 + property string baseColor: "carnelian " + childTwo.baseColor + } + } + + Item { + id: childSix + property int baseWidth: parent.baseWidth - 3 + property int baseHeight: root.baseHeight - 6 + property string baseColor: "rust " + root.baseColor + + Item { + id: childSeven + property int baseWidth: childOne.baseWidth - 6 + property int baseHeight: childTwo.baseHeight - 5 + property string baseColor: "sky " + childThree.baseColor + } + } + } + } + } + + Rectangle { + width: childOne.baseWidth + height: childOne.baseHeight + color: parent.baseColor + border.color: "black" + border.width: 5 + radius: 10 + } +} diff --git a/tests/benchmarks/qml/holistic/data/scopeSwitching/CppToJs.qml b/tests/benchmarks/qml/holistic/data/scopeSwitching/CppToJs.qml new file mode 100644 index 0000000000..d319f6e8cb --- /dev/null +++ b/tests/benchmarks/qml/holistic/data/scopeSwitching/CppToJs.qml @@ -0,0 +1,52 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import "cppToJs.js" as CppToJs + +Item { + id: jsConsumer + property int sideEffect: 10 + + function callJsFunction() { + jsConsumer.sideEffect = jsConsumer.sideEffect + CppToJs.nextValue; + } +} diff --git a/tests/benchmarks/qml/holistic/data/scopeSwitching/CppToQml.qml b/tests/benchmarks/qml/holistic/data/scopeSwitching/CppToQml.qml new file mode 100644 index 0000000000..a9d064f740 --- /dev/null +++ b/tests/benchmarks/qml/holistic/data/scopeSwitching/CppToQml.qml @@ -0,0 +1,48 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Item { + id: root + property int arbitrary: 10 + property int dependent: arbitrary + 5 +} diff --git a/tests/benchmarks/qml/holistic/data/scopeSwitching/JsToCppEight.qml b/tests/benchmarks/qml/holistic/data/scopeSwitching/JsToCppEight.qml new file mode 100644 index 0000000000..97bb125bfc --- /dev/null +++ b/tests/benchmarks/qml/holistic/data/scopeSwitching/JsToCppEight.qml @@ -0,0 +1,54 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import Qt.test 1.0 + +Item { + id: arbitraryVariantConsumer + property MyArbitraryVariantProvider a: MyArbitraryVariantProvider { id: arbitraryVariantProvider } + property int sideEffect: 10 + + function callCppFunction() { + // in this case, we call a nonconst CPP function with an integer return value and an integer argument. + arbitraryVariantConsumer.sideEffect = arbitraryVariantConsumer.sideEffect + arbitraryVariantProvider.modifyVariantChangeCount(arbitraryVariantConsumer.sideEffect); + } +} diff --git a/tests/benchmarks/qml/holistic/data/scopeSwitching/JsToCppEleven.qml b/tests/benchmarks/qml/holistic/data/scopeSwitching/JsToCppEleven.qml new file mode 100644 index 0000000000..2258e82500 --- /dev/null +++ b/tests/benchmarks/qml/holistic/data/scopeSwitching/JsToCppEleven.qml @@ -0,0 +1,57 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import Qt.test 1.0 + +Item { + id: arbitraryVariantConsumer + property MyArbitraryVariantProvider a: MyArbitraryVariantProvider { id: arbitraryVariantProvider } + property variant someVariant; + property int sideEffect: 10 + + function callCppFunction() { + // in this case, we call a nonconst CPP function with variant return value and variant + integer arguments. + arbitraryVariantConsumer.sideEffect = arbitraryVariantConsumer.sideEffect + 3; + var tempVariant = arbitraryVariantProvider.setVariantToFilledPixmap(sideEffect + 183, sideEffect + 134, sideEffect + 38, sideEffect + 77, sideEffect + 21); + someVariant = arbitraryVariantProvider.setVariantAddCount(sideEffect, tempVariant); + } +} diff --git a/tests/benchmarks/qml/holistic/data/scopeSwitching/JsToCppFive.qml b/tests/benchmarks/qml/holistic/data/scopeSwitching/JsToCppFive.qml new file mode 100644 index 0000000000..f349d0fcbf --- /dev/null +++ b/tests/benchmarks/qml/holistic/data/scopeSwitching/JsToCppFive.qml @@ -0,0 +1,54 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import Qt.test 1.0 + +Item { + id: arbitraryVariantConsumer + property MyArbitraryVariantProvider a: MyArbitraryVariantProvider { id: arbitraryVariantProvider } + property int sideEffect: 10 + + function callCppFunction() { + // in this case, we call a const CPP function with an integer return value and no arguments. + arbitraryVariantConsumer.sideEffect = arbitraryVariantConsumer.sideEffect + arbitraryVariantProvider.variantChangeCount(); + } +} diff --git a/tests/benchmarks/qml/holistic/data/scopeSwitching/JsToCppFour.qml b/tests/benchmarks/qml/holistic/data/scopeSwitching/JsToCppFour.qml new file mode 100644 index 0000000000..267d36fba2 --- /dev/null +++ b/tests/benchmarks/qml/holistic/data/scopeSwitching/JsToCppFour.qml @@ -0,0 +1,55 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import Qt.test 1.0 + +Item { + id: arbitraryVariantConsumer + property MyArbitraryVariantProvider a: MyArbitraryVariantProvider { id: arbitraryVariantProvider } + property int sideEffect: 10 + + function callCppFunction() { + // in this case, we call a nonconst CPP function with no return value and an integer argument. + arbitraryVariantConsumer.sideEffect = arbitraryVariantConsumer.sideEffect + 2; + arbitraryVariantProvider.setVariantChangeCount(arbitraryVariantConsumer.sideEffect); + } +} diff --git a/tests/benchmarks/qml/holistic/data/scopeSwitching/JsToCppNine.qml b/tests/benchmarks/qml/holistic/data/scopeSwitching/JsToCppNine.qml new file mode 100644 index 0000000000..ec3772ea62 --- /dev/null +++ b/tests/benchmarks/qml/holistic/data/scopeSwitching/JsToCppNine.qml @@ -0,0 +1,56 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import Qt.test 1.0 + +Item { + id: arbitraryVariantConsumer + property MyArbitraryVariantProvider a: MyArbitraryVariantProvider { id: arbitraryVariantProvider } + property variant someVariant; + property int sideEffect: 10 + + function callCppFunction() { + // in this case, we call a const CPP function with variant return value and integer arguments. + arbitraryVariantConsumer.sideEffect = arbitraryVariantConsumer.sideEffect + 3; + someVariant = arbitraryVariantProvider.possibleVariant(sideEffect, sideEffect * 2, sideEffect * 5); + } +} diff --git a/tests/benchmarks/qml/holistic/data/scopeSwitching/JsToCppOne.qml b/tests/benchmarks/qml/holistic/data/scopeSwitching/JsToCppOne.qml new file mode 100644 index 0000000000..e4a3c1acc2 --- /dev/null +++ b/tests/benchmarks/qml/holistic/data/scopeSwitching/JsToCppOne.qml @@ -0,0 +1,55 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import Qt.test 1.0 + +Item { + id: arbitraryVariantConsumer + property MyArbitraryVariantProvider a: MyArbitraryVariantProvider { id: arbitraryVariantProvider } + property int sideEffect: 10 + + function callCppFunction() { + // in this case, we call a const CPP function with no return value and no arguments. + arbitraryVariantConsumer.sideEffect = arbitraryVariantConsumer.sideEffect + 2; + arbitraryVariantProvider.doNothing(); + } +} diff --git a/tests/benchmarks/qml/holistic/data/scopeSwitching/JsToCppSeven.qml b/tests/benchmarks/qml/holistic/data/scopeSwitching/JsToCppSeven.qml new file mode 100644 index 0000000000..56c18a02db --- /dev/null +++ b/tests/benchmarks/qml/holistic/data/scopeSwitching/JsToCppSeven.qml @@ -0,0 +1,54 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import Qt.test 1.0 + +Item { + id: arbitraryVariantConsumer + property MyArbitraryVariantProvider a: MyArbitraryVariantProvider { id: arbitraryVariantProvider } + property int sideEffect: 10 + + function callCppFunction() { + // in this case, we call a const CPP function with an integer return value and an integer argument. + arbitraryVariantConsumer.sideEffect = arbitraryVariantConsumer.sideEffect + arbitraryVariantProvider.countPlus(arbitraryVariantConsumer.sideEffect); + } +} diff --git a/tests/benchmarks/qml/holistic/data/scopeSwitching/JsToCppSix.qml b/tests/benchmarks/qml/holistic/data/scopeSwitching/JsToCppSix.qml new file mode 100644 index 0000000000..c14c43075b --- /dev/null +++ b/tests/benchmarks/qml/holistic/data/scopeSwitching/JsToCppSix.qml @@ -0,0 +1,54 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import Qt.test 1.0 + +Item { + id: arbitraryVariantConsumer + property MyArbitraryVariantProvider a: MyArbitraryVariantProvider { id: arbitraryVariantProvider } + property int sideEffect: 10 + + function callCppFunction() { + // in this case, we call a nonconst CPP function with an integer return value and no arguments. + arbitraryVariantConsumer.sideEffect = arbitraryVariantConsumer.sideEffect + arbitraryVariantProvider.modifyVariantChangeCount(); + } +} diff --git a/tests/benchmarks/qml/holistic/data/scopeSwitching/JsToCppTen.qml b/tests/benchmarks/qml/holistic/data/scopeSwitching/JsToCppTen.qml new file mode 100644 index 0000000000..05ededef38 --- /dev/null +++ b/tests/benchmarks/qml/holistic/data/scopeSwitching/JsToCppTen.qml @@ -0,0 +1,56 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import Qt.test 1.0 + +Item { + id: arbitraryVariantConsumer + property MyArbitraryVariantProvider a: MyArbitraryVariantProvider { id: arbitraryVariantProvider } + property variant someVariant; + property int sideEffect: 10 + + function callCppFunction() { + // in this case, we call a nonconst CPP function with variant return value and integer arguments. + arbitraryVariantConsumer.sideEffect = arbitraryVariantConsumer.sideEffect + 3; + someVariant = arbitraryVariantProvider.setVariantToFilledPixmap(sideEffect + 183, sideEffect + 134, sideEffect + 38, sideEffect + 77, sideEffect + 21); + } +} diff --git a/tests/benchmarks/qml/holistic/data/scopeSwitching/JsToCppThree.qml b/tests/benchmarks/qml/holistic/data/scopeSwitching/JsToCppThree.qml new file mode 100644 index 0000000000..2f11f9acb3 --- /dev/null +++ b/tests/benchmarks/qml/holistic/data/scopeSwitching/JsToCppThree.qml @@ -0,0 +1,55 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import Qt.test 1.0 + +Item { + id: arbitraryVariantConsumer + property MyArbitraryVariantProvider a: MyArbitraryVariantProvider { id: arbitraryVariantProvider } + property int sideEffect: 10 + + function callCppFunction() { + // in this case, we call a const CPP function with no return value and an integer argument. + arbitraryVariantConsumer.sideEffect = arbitraryVariantConsumer.sideEffect + 2; + arbitraryVariantProvider.doNothing(arbitraryVariantConsumer.sideEffect); + } +} diff --git a/tests/benchmarks/qml/holistic/data/scopeSwitching/JsToCppTwo.qml b/tests/benchmarks/qml/holistic/data/scopeSwitching/JsToCppTwo.qml new file mode 100644 index 0000000000..0fe6d18507 --- /dev/null +++ b/tests/benchmarks/qml/holistic/data/scopeSwitching/JsToCppTwo.qml @@ -0,0 +1,55 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import Qt.test 1.0 + +Item { + id: arbitraryVariantConsumer + property MyArbitraryVariantProvider a: MyArbitraryVariantProvider { id: arbitraryVariantProvider } + property int sideEffect: 10 + + function callCppFunction() { + // in this case, we call a nonconst CPP function with no return value and no arguments. + arbitraryVariantConsumer.sideEffect = arbitraryVariantConsumer.sideEffect + 2; + arbitraryVariantProvider.incrementVariantChangeCount(); + } +} diff --git a/tests/benchmarks/qml/holistic/data/scopeSwitching/ScarceOne.qml b/tests/benchmarks/qml/holistic/data/scopeSwitching/ScarceOne.qml new file mode 100644 index 0000000000..d604242a99 --- /dev/null +++ b/tests/benchmarks/qml/holistic/data/scopeSwitching/ScarceOne.qml @@ -0,0 +1,57 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import Qt.test 1.0 + +Item { + id: scarceResourceConsumer + + property MyScarceResourceProvider a: MyScarceResourceProvider { id: scarceResourceProvider } + + property variant ssr; + property variant lsr; + + function copyScarceResources() { + ssr = scarceResourceProvider.smallScarceResource; + lsr = scarceResourceProvider.largeScarceResource; + } +} diff --git a/tests/benchmarks/qml/holistic/data/scopeSwitching/ScarceTwo.qml b/tests/benchmarks/qml/holistic/data/scopeSwitching/ScarceTwo.qml new file mode 100644 index 0000000000..cd79bb8074 --- /dev/null +++ b/tests/benchmarks/qml/holistic/data/scopeSwitching/ScarceTwo.qml @@ -0,0 +1,52 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import Qt.test 1.0 + +Item { + id: scarceResourceConsumer + + property MyScarceResourceProvider a: MyScarceResourceProvider { id: scarceResourceProvider } + + property variant ssr: scarceResourceProvider.smallScarceResource + property variant lsr: scarceResourceProvider.largeScarceResource +} diff --git a/tests/benchmarks/qml/holistic/data/scopeSwitching/cppToJs.js b/tests/benchmarks/qml/holistic/data/scopeSwitching/cppToJs.js new file mode 100644 index 0000000000..e62c2f27d6 --- /dev/null +++ b/tests/benchmarks/qml/holistic/data/scopeSwitching/cppToJs.js @@ -0,0 +1,49 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +.pragma library + +var generatedValue = 5; + +function generateNextValue() { + generatedValue += 1; + return generatedValue; +} diff --git a/tests/benchmarks/qml/holistic/data/smallTargets/SmallFour.qml b/tests/benchmarks/qml/holistic/data/smallTargets/SmallFour.qml new file mode 100644 index 0000000000..80af3bfee9 --- /dev/null +++ b/tests/benchmarks/qml/holistic/data/smallTargets/SmallFour.qml @@ -0,0 +1,49 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Text { + text: "Hello World!" + font.family: "Helvetica" + font.pointSize: 24 + color: "red" +} diff --git a/tests/benchmarks/qml/holistic/data/smallTargets/SmallOne.qml b/tests/benchmarks/qml/holistic/data/smallTargets/SmallOne.qml new file mode 100644 index 0000000000..58d52fe25d --- /dev/null +++ b/tests/benchmarks/qml/holistic/data/smallTargets/SmallOne.qml @@ -0,0 +1,51 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Rectangle { + width: 100 + height: 100 + color: "red" + border.color: "black" + border.width: 5 + radius: 10 +} diff --git a/tests/benchmarks/qml/holistic/data/smallTargets/SmallThree.qml b/tests/benchmarks/qml/holistic/data/smallTargets/SmallThree.qml new file mode 100644 index 0000000000..a3e27f9ad6 --- /dev/null +++ b/tests/benchmarks/qml/holistic/data/smallTargets/SmallThree.qml @@ -0,0 +1,51 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Rectangle { + width: 100; height: 100 + gradient: Gradient { + GradientStop { position: 0.0; color: "red" } + GradientStop { position: 0.33; color: "yellow" } + GradientStop { position: 1.0; color: "green" } + } +} diff --git a/tests/benchmarks/qml/holistic/data/smallTargets/SmallTwo.qml b/tests/benchmarks/qml/holistic/data/smallTargets/SmallTwo.qml new file mode 100644 index 0000000000..3ff2c5e8b0 --- /dev/null +++ b/tests/benchmarks/qml/holistic/data/smallTargets/SmallTwo.qml @@ -0,0 +1,51 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Rectangle { + width: 100 + height: 100 + color: "blue" + border.color: "black" + border.width: 5 + radius: 10 +} diff --git a/tests/benchmarks/qml/holistic/holistic.pro b/tests/benchmarks/qml/holistic/holistic.pro new file mode 100644 index 0000000000..82f2ef6e4e --- /dev/null +++ b/tests/benchmarks/qml/holistic/holistic.pro @@ -0,0 +1,13 @@ +CONFIG += testcase +TEMPLATE = app +TARGET = tst_holistic +QT += qml network testlib +macx:CONFIG -= app_bundle + +CONFIG += release + +SOURCES += tst_holistic.cpp \ + testtypes.cpp +HEADERS += testtypes.h + +DEFINES += SRCDIR=\\\"$$PWD\\\" diff --git a/tests/benchmarks/qml/holistic/testtypes.cpp b/tests/benchmarks/qml/holistic/testtypes.cpp new file mode 100644 index 0000000000..65d3ee8522 --- /dev/null +++ b/tests/benchmarks/qml/holistic/testtypes.cpp @@ -0,0 +1,98 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include "testtypes.h" +#include +#include +#include +#include + +static QScriptValue script_api(QQmlEngine *engine, QScriptEngine *scriptEngine) +{ + Q_UNUSED(engine) + Q_UNUSED(scriptEngine) + + static int testProperty = 13; + QScriptValue v = scriptEngine->newObject(); + v.setProperty("scriptTestProperty", testProperty++); + return v; +} + +static QObject *qobject_api(QQmlEngine *engine, QScriptEngine *scriptEngine) +{ + Q_UNUSED(engine) + Q_UNUSED(scriptEngine) + + testQObjectApi *o = new testQObjectApi(); + o->setQObjectTestProperty(20); + return o; +} + +static QObject *qobject_api_engine_parent(QQmlEngine *engine, QScriptEngine *scriptEngine) +{ + Q_UNUSED(scriptEngine) + + static int testProperty = 26; + testQObjectApi *o = new testQObjectApi(engine); + o->setQObjectTestProperty(testProperty++); + return o; +} + +void registerTypes() +{ + qmlRegisterType("Qt.test", 1,0, "MyQmlObjectAlias"); + qmlRegisterType("Qt.test", 1,0, "MyQmlObject"); + + qmlRegisterType("Qt.test",1,0,"QPlainTextEdit"); + qRegisterMetaType("MyQmlObject::MyType"); + + qmlRegisterType("Qt.test", 1,0, "MyScarceResourceProvider"); + qmlRegisterType("Qt.test", 1,0, "MyArbitraryVariantProvider"); + + qmlRegisterModuleApi("Qt.test",1,0,script_api); // register (script) module API for an existing uri which contains elements + qmlRegisterModuleApi("Qt.test",1,0,qobject_api); // register (qobject) for an existing uri for which another module API was previously regd. Should replace! + qmlRegisterModuleApi("Qt.test.scriptApi",1,0,script_api); // register (script) module API for a uri which doesn't contain elements + qmlRegisterModuleApi("Qt.test.qobjectApi",1,0,qobject_api); // register (qobject) module API for a uri which doesn't contain elements + qmlRegisterModuleApi("Qt.test.qobjectApi",1,3,qobject_api); // register (qobject) module API for a uri which doesn't contain elements, minor version set + qmlRegisterModuleApi("Qt.test.qobjectApi",2,0,qobject_api); // register (qobject) module API for a uri which doesn't contain elements, major version set + qmlRegisterModuleApi("Qt.test.qobjectApiParented",1,0,qobject_api_engine_parent); // register (parented qobject) module API for a uri which doesn't contain elements +} + +//#include "testtypes.moc" diff --git a/tests/benchmarks/qml/holistic/testtypes.h b/tests/benchmarks/qml/holistic/testtypes.h new file mode 100644 index 0000000000..66d755d944 --- /dev/null +++ b/tests/benchmarks/qml/holistic/testtypes.h @@ -0,0 +1,355 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#ifndef TESTTYPES_H +#define TESTTYPES_H + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +class MyQmlAttachedObject : public QObject +{ + Q_OBJECT + Q_PROPERTY(int value READ value CONSTANT) + Q_PROPERTY(int value2 READ value2 WRITE setValue2) +public: + MyQmlAttachedObject(QObject *parent) : QObject(parent), m_value2(0) {} + + int value() const { return 19; } + int value2() const { return m_value2; } + void setValue2(int v) { m_value2 = v; } + + void emitMySignal() { emit mySignal(); } + +signals: + void mySignal(); + +private: + int m_value2; +}; + +class MyQmlObject : public QObject +{ + Q_OBJECT + Q_ENUMS(MyEnum) + Q_ENUMS(MyEnum2) + Q_PROPERTY(int deleteOnSet READ deleteOnSet WRITE setDeleteOnSet) + Q_PROPERTY(bool trueProperty READ trueProperty CONSTANT) + Q_PROPERTY(bool falseProperty READ falseProperty CONSTANT) + Q_PROPERTY(int value READ value WRITE setValue) + Q_PROPERTY(int console READ console CONSTANT) + Q_PROPERTY(QString stringProperty READ stringProperty WRITE setStringProperty NOTIFY stringChanged) + Q_PROPERTY(QObject *objectProperty READ objectProperty WRITE setObjectProperty NOTIFY objectChanged) + Q_PROPERTY(QQmlListProperty objectListProperty READ objectListProperty CONSTANT) + Q_PROPERTY(int resettableProperty READ resettableProperty WRITE setResettableProperty RESET resetProperty) + Q_PROPERTY(QRegExp regExp READ regExp WRITE setRegExp) + Q_PROPERTY(int nonscriptable READ nonscriptable WRITE setNonscriptable SCRIPTABLE false) + +public: + MyQmlObject(): myinvokableObject(0), m_methodCalled(false), m_methodIntCalled(false), m_object(0), m_value(0), m_resetProperty(13) {} + + enum MyEnum { EnumValue1 = 0, EnumValue2 = 1 }; + enum MyEnum2 { EnumValue3 = 2, EnumValue4 = 3 }; + + bool trueProperty() const { return true; } + bool falseProperty() const { return false; } + + QString stringProperty() const { return m_string; } + void setStringProperty(const QString &s) + { + if (s == m_string) + return; + m_string = s; + emit stringChanged(); + } + + QObject *objectProperty() const { return m_object; } + void setObjectProperty(QObject *obj) { + if (obj == m_object) + return; + m_object = obj; + emit objectChanged(); + } + + QQmlListProperty objectListProperty() { return QQmlListProperty(this, m_objectQList); } + + bool methodCalled() const { return m_methodCalled; } + bool methodIntCalled() const { return m_methodIntCalled; } + + QString string() const { return m_string; } + + static MyQmlAttachedObject *qmlAttachedProperties(QObject *o) { + return new MyQmlAttachedObject(o); + } + + int deleteOnSet() const { return 1; } + void setDeleteOnSet(int v) { if(v) delete this; } + + int value() const { return m_value; } + void setValue(int v) { m_value = v; } + + int resettableProperty() const { return m_resetProperty; } + void setResettableProperty(int v) { m_resetProperty = v; } + void resetProperty() { m_resetProperty = 13; } + + QRegExp regExp() { return m_regExp; } + void setRegExp(const QRegExp ®Exp) { m_regExp = regExp; } + + int console() const { return 11; } + + int nonscriptable() const { return 0; } + void setNonscriptable(int) {} + + MyQmlObject *myinvokableObject; + Q_INVOKABLE MyQmlObject *returnme() { return this; } + + struct MyType { + int value; + }; + QVariant variant() const { return m_variant; } + +signals: + void basicSignal(); + void argumentSignal(int a, QString b, qreal c); + void stringChanged(); + void objectChanged(); + void anotherBasicSignal(); + void thirdBasicSignal(); + void signalWithUnknownType(const MyQmlObject::MyType &arg); + +public slots: + void deleteMe() { delete this; } + void methodNoArgs() { m_methodCalled = true; } + void method(int a) { if(a == 163) m_methodIntCalled = true; } + void setString(const QString &s) { m_string = s; } + void myinvokable(MyQmlObject *o) { myinvokableObject = o; } + void variantMethod(const QVariant &v) { m_variant = v; } + +private: + friend class tst_qdeclarativeecmascript; + bool m_methodCalled; + bool m_methodIntCalled; + + QObject *m_object; + QString m_string; + QList m_objectQList; + int m_value; + int m_resetProperty; + QRegExp m_regExp; + QVariant m_variant; +}; + +QML_DECLARE_TYPEINFO(MyQmlObject, QML_HAS_ATTACHED_PROPERTIES) +Q_DECLARE_METATYPE(MyQmlObject::MyType) + +class testQObjectApi : public QObject +{ + Q_OBJECT + Q_PROPERTY (int qobjectTestProperty READ qobjectTestProperty NOTIFY qobjectTestPropertyChanged) + +public: + testQObjectApi(QObject* parent = 0) + : QObject(parent), m_testProperty(0) + { + } + + ~testQObjectApi() {} + + int qobjectTestProperty() const { return m_testProperty; } + void setQObjectTestProperty(int tp) { m_testProperty = tp; emit qobjectTestPropertyChanged(tp); } + +signals: + void qobjectTestPropertyChanged(int testProperty); + +private: + int m_testProperty; +}; + +class ArbitraryVariantProvider : public QObject +{ + Q_OBJECT + Q_PROPERTY(QVariant arbitraryVariant READ arbitraryVariant WRITE setArbitraryVariant NOTIFY arbitraryVariantChanged) + +public: + ArbitraryVariantProvider(QObject *parent = 0) + : QObject(parent), m_value(QVariant(QString(QLatin1String("random string value")))), m_count(1) + { + } + + ~ArbitraryVariantProvider() {} + + // the variant provided by the provider + QVariant arbitraryVariant() const { return m_value; } + void setArbitraryVariant(const QVariant& value) { m_value = value; emit arbitraryVariantChanged(); } + Q_INVOKABLE int changeVariant() + { + QPixmap pv(150, 150); + pv.fill(Qt::green); + int choice = qrand() % 4; + switch (choice) { + case 0: setArbitraryVariant(QVariant(QString(QLatin1String("string variant value")))); break; + case 1: setArbitraryVariant(QVariant(QColor(110, 120, 130))); break; + case 2: setArbitraryVariant(QVariant(55)); break; + default: setArbitraryVariant(QVariant(pv)); break; + } + + m_count += 1; + return m_count; + } + Q_INVOKABLE QVariant setVariantToFilledPixmap(int width, int height, int r, int g, int b) + { + QPixmap pv(width % 300, height % 300); + pv.fill(QColor(r % 256, g % 256, b % 256)); + m_value = pv; + m_count += 1; + return m_value; + } + Q_INVOKABLE QVariant setVariantAddCount(int addToCount, const QVariant& newValue) + { + m_value = newValue; + m_count += addToCount; + return m_value; + } + Q_INVOKABLE QVariant possibleVariant(int randomFactorOne, int randomFactorTwo, int randomFactorThree) const + { + QVariant retn; + QPixmap pv(randomFactorOne % 300, randomFactorTwo % 300); + pv.fill(QColor(randomFactorOne % 256, randomFactorTwo % 256, randomFactorThree % 256)); + int choice = qrand() % 4; + switch (choice) { + case 0: retn = QVariant(QString(QLatin1String("string variant value"))); break; + case 1: retn = QVariant(QColor(randomFactorThree % 256, randomFactorTwo % 256, randomFactorOne % 256)); break; + case 2: retn = QVariant((55 + randomFactorThree)); break; + default: retn = QVariant(pv); break; + } + return retn; + } + + // the following functions cover permutations of return value and arguments. + // functions with no return value: + Q_INVOKABLE void doNothing() const { /* does nothing */ } // no args, const + Q_INVOKABLE void incrementVariantChangeCount() { m_count = m_count + 1; } // no args, nonconst + Q_INVOKABLE void doNothing(int) const { /* does nothing. */ } // arg, const + Q_INVOKABLE void setVariantChangeCount(int newCount) { m_count = newCount; } // arg, nonconst + // functions with return value: + Q_INVOKABLE int variantChangeCount() const { return m_count; } // no args, const + Q_INVOKABLE int modifyVariantChangeCount() { m_count += 3; return m_count; } // no args, nonconst + Q_INVOKABLE int countPlus(int value) const { return m_count + value; } // arg, const + Q_INVOKABLE int modifyVariantChangeCount(int modifier) { m_count += modifier; return m_count; } // arg, nonconst. + +signals: + void arbitraryVariantChanged(); + +private: + QVariant m_value; + int m_count; +}; + +class ScarceResourceProvider : public QObject +{ + Q_OBJECT + Q_PROPERTY(QPixmap smallScarceResource READ smallScarceResource WRITE setSmallScarceResource NOTIFY smallScarceResourceChanged) + Q_PROPERTY(QPixmap largeScarceResource READ largeScarceResource WRITE setLargeScarceResource NOTIFY largeScarceResourceChanged) + +public: + ScarceResourceProvider(QObject *parent = 0) + : QObject(parent), m_small(100, 100), m_large(1000, 1000), m_colour(1) + { + m_small.fill(Qt::blue); + m_large.fill(Qt::blue); + } + + ~ScarceResourceProvider() {} + + QPixmap smallScarceResource() const { return m_small; } + void setSmallScarceResource(QPixmap v) { m_small = v; emit smallScarceResourceChanged(); } + bool smallScarceResourceIsDetached() const { return m_small.isDetached(); } + + QPixmap largeScarceResource() const { return m_large; } + void setLargeScarceResource(QPixmap v) { m_large = v; emit largeScarceResourceChanged(); } + bool largeScarceResourceIsDetached() const { return m_large.isDetached(); } + + Q_INVOKABLE void changeResources() + { + QPixmap newSmall(100, 100); + QPixmap newLarge(1000, 1000); + + if (m_colour == 1) { + m_colour = 2; + newSmall.fill(Qt::red); + newLarge.fill(Qt::red); + } else { + m_colour = 1; + newSmall.fill(Qt::blue); + newLarge.fill(Qt::blue); + } + + setSmallScarceResource(newSmall); + setLargeScarceResource(newLarge); + } + +signals: + void smallScarceResourceChanged(); + void largeScarceResourceChanged(); + +private: + QPixmap m_small; + QPixmap m_large; + + int m_colour; +}; + +void registerTypes(); + +#endif // TESTTYPES_H + diff --git a/tests/benchmarks/qml/holistic/tst_holistic.cpp b/tests/benchmarks/qml/holistic/tst_holistic.cpp new file mode 100644 index 0000000000..db8cc1cecb --- /dev/null +++ b/tests/benchmarks/qml/holistic/tst_holistic.cpp @@ -0,0 +1,607 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "testtypes.h" + +#include +#include +#include +#include +#include +#include +#include + +// Conceptually, there are several different "holistic" areas to benchmark: +// 1) Loading +// - read file from disk +// - parse/lex file +// - handle nested imports +// 2) Compilation +// - create meta object templates etc +// - compile to bytecode and cache it +// 3) Instantiation +// - running the bytecode to create an object tree, assign properties, etc +// - and, importantly, to evaluate bindings for the first time (incl. js expressions) +// 4) Dynamicism +// - bindings evaluation +// - signal handlers +// +// Aside from this, we also need to determine: +// 1) JavaScript Metrics +// - simple expressions +// - complex expressions +// - instantiation vs evaluation time +// - imports and nested imports +// 2) Context-switch costs +// - how expensive is it to call a cpp function from QML +// - how expensive is it to call a js function from cpp via QML +// - how expensive is it to pass around objects between them +// 3) Complete creation time. +// - loading + compilation + instantiation (for "application startup time" metric) +// +// In some cases, we want to include "initialization costs"; +// i.e., we need to tell the engine not to cache type data resulting +// in compilation between rounds, and we need to tell the engine not +// to cache whatever it caches between instantiations of components. +// The reason for this is that it is often the "first start of application" +// performance which we're attempting to benchmark. + +// define some custom types we use in test data functions. +typedef QList PropertyNameList; +Q_DECLARE_METATYPE(PropertyNameList); +typedef QList PropertyValueList; +Q_DECLARE_METATYPE(PropertyValueList); + +class tst_holistic : public QObject +{ + Q_OBJECT + +public: + tst_holistic(); + +private slots: + void initTestCase() + { + registerTypes(); + qRegisterMetaType("PropertyNameList"); + qRegisterMetaType("PropertyValueList"); + } + + void compilation_data(); + void compilation(); + void instantiation_data() { compilation_data(); } + void instantiation(); + void creation_data() { compilation_data(); } + void creation(); + void dynamicity_data(); + void dynamicity(); + + void cppToJsDirect_data(); + void cppToJsDirect(); + void cppToJsIndirect(); + + void typeResolution_data(); + void typeResolution(); + +private: + QQmlEngine engine; +}; + +tst_holistic::tst_holistic() +{ +} + +inline QUrl TEST_FILE(const QString &filename) +{ + return QUrl::fromLocalFile(QLatin1String(SRCDIR) + QLatin1String("/data/") + filename); +} + + +void tst_holistic::compilation_data() +{ + QTest::addColumn("files"); + QTest::addColumn("repetitions"); + + QStringList f; + + // Benchmarks: a single, small component once with no caching. + f << QString(SRCDIR + QLatin1String("/data/smallTargets/SmallOne.qml")); + QTest::newRow("single small component") << f << 1; + + // Benchmarks: a single, small component ten times with caching. + QTest::newRow("single small component cached") << f << 10; f.clear(); + + // Benchmarks: a single, large component once with no caching. + f << QString(SRCDIR + QLatin1String("/data/largeTargets/mousearea-example.qml")); + QTest::newRow("single large component") << f << 1; + + // Benchmarks: a single, large component ten times with caching. + QTest::newRow("single large component cached") << f << 10; f.clear(); + + // Benchmarks: 4 small components once each with no caching + f << QString(SRCDIR + QLatin1String("/data/smallTargets/SmallOne.qml")); + f << QString(SRCDIR + QLatin1String("/data/smallTargets/SmallTwo.qml")); + f << QString(SRCDIR + QLatin1String("/data/smallTargets/SmallThree.qml")); + f << QString(SRCDIR + QLatin1String("/data/smallTargets/SmallFour.qml")); + QTest::newRow("multiple small components") << f << 1; + + // Benchmarks: 4 small components ten times each with caching + QTest::newRow("multiple small components cached") << f << 10; f.clear(); + + // Benchmarks: 3 large components once each with no caching. + f << QString(SRCDIR + QLatin1String("/data/largeTargets/mousearea-example.qml")); + f << QString(SRCDIR + QLatin1String("/data/largeTargets/gridview-example.qml")); + f << QString(SRCDIR + QLatin1String("/data/largeTargets/layoutdirection.qml")); + QTest::newRow("multiple large components") << f << 1; + + // Benchmarks: 3 large components ten times each with caching. + QTest::newRow("multiple large components cached") << f << 10; f.clear(); + + // Benchmarks: single small component which imports a single small js file, no caching + f << QString(SRCDIR + QLatin1String("/data/jsImports/Sssi.qml")); + QTest::newRow("single small js import") << f << 1; + + // Benchmarks: single small component which imports a single small js file, 10 reps, with caching + QTest::newRow("single small js import, cached") << f << 10; f.clear(); + + // Benchmarks: single small component which imports multiple small js files (no deep nesting), no caching + f << QString(SRCDIR + QLatin1String("/data/jsImports/Msbsi.qml")); + QTest::newRow("multiple small js imports, shallow") << f << 1; + + // Benchmarks: single small component which imports multiple small js files (no deep nesting), 10 reps, with caching + QTest::newRow("multiple small js imports, shallow, cached") << f << 10; f.clear(); + + // Benchmarks: single small component which imports multiple small js files (with deep nesting), no caching + f << QString(SRCDIR + QLatin1String("/data/jsImports/Msdsi.qml")); + QTest::newRow("multiple small js imports, deeply nested") << f << 1; + + // Benchmarks: single small component which imports multiple small js files (with deep nesting), 10 reps, with caching + QTest::newRow("multiple small js imports, deeply nested, cached") << f << 10; f.clear(); + + // Benchmarks: single small component which imports multiple small js files (nested and unnested), no caching + f << QString(SRCDIR + QLatin1String("/data/jsImports/Mssi.qml")); + QTest::newRow("muliple small js imports, both") << f << 1; + + // Benchmarks: single small component which imports multiple small js files (nested and unnested), 10 reps, with caching + QTest::newRow("muliple small js imports, both, cached") << f << 10; f.clear(); + + // Benchmarks: single small component which imports a single large js file, no caching + f << QString(SRCDIR + QLatin1String("/data/jsImports/Slsi.qml")); + QTest::newRow("single large js import") << f << 1; + + // Benchmarks: single small component which imports a single large js file, 10 reps, with caching + QTest::newRow("single large js import, cached") << f << 10; f.clear(); + + // Benchmarks: single small component which imports multiple large js files (no deep nesting), no caching + f << QString(SRCDIR + QLatin1String("/data/jsImports/Mlbsi.qml")); + QTest::newRow("multiple large js imports, shallow") << f << 1; + + // Benchmarks: single small component which imports multiple large js files (no deep nesting), 10 reps, with caching + QTest::newRow("multiple large js imports, shallow, cached") << f << 10; f.clear(); + + // Benchmarks: single small component which imports multiple large js files (with deep nesting), no caching + f << QString(SRCDIR + QLatin1String("/data/jsImports/Mldsi.qml")); + QTest::newRow("multiple large js imports, deeply nested") << f << 1; + + // Benchmarks: single small component which imports multiple large js files (with deep nesting), 10 reps, with caching + QTest::newRow("multiple large js imports, deeply nested, cached") << f << 10; f.clear(); + + // Benchmarks: single small component which imports multiple large js files (nested and unnested), no caching + f << QString(SRCDIR + QLatin1String("/data/jsImports/Mlsi.qml")); + QTest::newRow("multiple large js imports, both") << f << 1; + + // Benchmarks: single small component which imports multiple large js files (nested and unnested), 10 reps, with caching + QTest::newRow("multiple large js imports, both, cached") << f << 10; f.clear(); + + // Benchmarks: single small component which imports multiple js files which all import a .pragma library js file, no caching + f << QString(SRCDIR + QLatin1String("/data/jsImports/PragmaBm.qml")); + QTest::newRow(".pragma library js import") << f << 1; + + // Benchmarks: single small component which imports multiple js files which all import a .pragma library js file, 10 reps, with caching + QTest::newRow(".pragma library js import, cached") << f << 10; f.clear(); + + // Benchmarks: single small component which imports a js file which imports a QML module, no caching + f << QString(SRCDIR + QLatin1String("/data/jsImports/ModuleBm.qml")); + QTest::newRow("import js with QML import") << f << 1; + + // Benchmarks: single small component which imports a js file which imports a QML module, 10 reps, with caching + QTest::newRow("import js with QML import, cached") << f << 10; f.clear(); + + // Benchmarks: single small component which imports multiple js files which all import a .pragma library js file and a QML module, no caching + f << QString(SRCDIR + QLatin1String("/data/jsImports/PragmaModuleBm.qml")); + QTest::newRow("import js with QML import and .pragma library") << f << 1; + + // Benchmarks: single small component which imports multiple js files which all import a .pragma library js file and a QML module, 10 reps, with caching + QTest::newRow("import js with QML import and .pragma library, cached") << f << 10; f.clear(); +} + +void tst_holistic::compilation() +{ + // This function benchmarks the cost of loading and compiling specified QML files. + // If "repetitions" is non-zero, each file from "files" will be compiled "repetitions" + // times, without clearing the engine's component cache between compilations. + + QFETCH(QStringList, files); + QFETCH(int, repetitions); + Q_ASSERT(files.size() > 0); + Q_ASSERT(repetitions > 0); + + QBENCHMARK { + engine.clearComponentCache(); + for (int i = 0; i < repetitions; ++i) { + for (int j = 0; j < files.size(); ++j) { + QQmlComponent c(&engine, QUrl::fromLocalFile(files.at(j))); + } + } + } +} + +void tst_holistic::instantiation() +{ + // This function benchmarks the cost of instantiating components compiled from specified QML files. + // If "repetitions" is non-zero, each component compiled from "files" will be instantiated "repetitions" + // times, without clearing the component's instantiation cache between instantiations. + + QFETCH(QStringList, files); + QFETCH(int, repetitions); + Q_ASSERT(files.size() > 0); + Q_ASSERT(repetitions > 0); + + QList components; + for (int i = 0; i < files.size(); ++i) { + QQmlComponent *c = new QQmlComponent(&engine, QUrl::fromLocalFile(files.at(i))); + components.append(c); + } + + QBENCHMARK { + // XXX TODO: clear each component's instantiation cache + + for (int i = 0; i < repetitions; ++i) { + for (int j = 0; j < components.size(); ++j) { + QObject *obj = components.at(j)->create(); + delete obj; + } + } + } + + // cleanup + for (int i = 0; i < components.size(); ++i) { + delete components.at(i); + } +} + +void tst_holistic::creation() +{ + // This function benchmarks the cost of loading, compiling and instantiating specified QML files. + // If "repetitions" is non-zero, each file from "files" will be created "repetitions" + // times, without clearing the engine's component cache between component creation. + + QFETCH(QStringList, files); + QFETCH(int, repetitions); + Q_ASSERT(files.size() > 0); + Q_ASSERT(repetitions > 0); + + QBENCHMARK { + engine.clearComponentCache(); + for (int i = 0; i < repetitions; ++i) { + for (int j = 0; j < files.size(); ++j) { + QQmlComponent c(&engine, QUrl::fromLocalFile(files.at(j))); + QObject *obj = c.create(); + delete obj; + } + } + } +} + +void tst_holistic::dynamicity_data() +{ + QTest::addColumn("file"); + QTest::addColumn("writeProperty"); + QTest::addColumn("writeValueOne"); + QTest::addColumn("writeValueTwo"); + QTest::addColumn("readProperty"); + + QString f; + + // Benchmarks: single simple property binding + f = QString(SRCDIR + QLatin1String("/data/dynamicTargets/DynamicOne.qml")); + QTest::newRow("single simple property binding") << f << QString(QLatin1String("dynamicWidth")) << QVariant(300) << QVariant(500) << QString(QLatin1String("height")); + + // Benchmarks: multiple simple property bindings in one component + f = QString(SRCDIR + QLatin1String("/data/dynamicTargets/DynamicTwo.qml")); + QTest::newRow("multiple simple property bindings") << f << QString(QLatin1String("dynamicWidth")) << QVariant(300) << QVariant(500) << QString(QLatin1String("dynamicWidth")); + + // Benchmarks: single simple property binding plus onPropertyChanged slot + f = QString(SRCDIR + QLatin1String("/data/dynamicTargets/DynamicThree.qml")); + QTest::newRow("single simple plus slot") << f << QString(QLatin1String("dynamicWidth")) << QVariant(300) << QVariant(500) << QString(QLatin1String("dynamicWidth")); + + // Benchmarks: multiple simple property bindings plus multiple onPropertyChanged slots in one component + f = QString(SRCDIR + QLatin1String("/data/dynamicTargets/DynamicFour.qml")); + QTest::newRow("multiple simple plus slots") << f << QString(QLatin1String("dynamicWidth")) << QVariant(300) << QVariant(500) << QString(QLatin1String("dynamicHeight")); + + // Benchmarks: single simple js expression in a slot + f = QString(SRCDIR + QLatin1String("/data/jsTargets/JsOne.qml")); + QTest::newRow("single simple js expression slot") << f << QString(QLatin1String("dynamicWidth")) << QVariant(300) << QVariant(500) << QString(QLatin1String("dynamicWidth")); + + // Benchmarks: single complex js expression in a slot + f = QString(SRCDIR + QLatin1String("/data/jsTargets/JsTwo.qml")); + QTest::newRow("single complex js expression slot") << f << QString(QLatin1String("dynamicWidth")) << QVariant(300) << QVariant(500) << QString(QLatin1String("dynamicWidth")); + + // Benchmarks: simple property assignment and bindings update + f = QString(SRCDIR + QLatin1String("/data/scopeSwitching/CppToQml.qml")); + QTest::newRow("single simple property binding") << f << QString(QLatin1String("arbitrary")) << QVariant(36) << QVariant(35) << QString(QLatin1String("arbitrary")); +} + +void tst_holistic::dynamicity() +{ + // This function benchmarks the cost of "continued operation" - signal invocation, + // updating bindings, etc. Note that we take two different writeValues in order + // to force updates to occur, and we read to force lazy evaluation to occur. + + QFETCH(QString, file); + QFETCH(QString, writeProperty); + QFETCH(QVariant, writeValueOne); + QFETCH(QVariant, writeValueTwo); + QFETCH(QString, readProperty); + + QQmlComponent c(&engine, file); + QObject *obj = c.create(); + + QVariant readValue; + QVariant writeValue; + bool usedFirst = false; + + QBENCHMARK { + if (usedFirst) { + writeValue = writeValueTwo; + usedFirst = false; + } else { + writeValue = writeValueOne; + usedFirst = true; + } + + obj->setProperty(writeProperty.toAscii().constData(), writeValue); + readValue = obj->property(readProperty.toAscii().constData()); + } + + delete obj; +} + + + + + + + +void tst_holistic::cppToJsDirect_data() +{ + QTest::addColumn("file"); + QTest::addColumn("methodName"); + + QString f; + + // Benchmarks: cost of calling a js function from cpp directly + f = QString(SRCDIR + QLatin1String("/data/scopeSwitching/CppToJs.qml")); + QTest::newRow("cpp-to-js") << f << QString(QLatin1String("callJsFunction")); + + // Benchmarks: cost of calling js function which calls cpp function: + // const CPP function with no return value and no arguments. + f = QString(SRCDIR + QLatin1String("/data/scopeSwitching/JsToCppOne.qml")); + QTest::newRow("cpp-to-js-to-cpp: no retn, no args") << f << QString(QLatin1String("callCppFunction")); + + // Benchmarks: cost of calling js function which calls cpp function: + // nonconst CPP function with no return value and no arguments. + f = QString(SRCDIR + QLatin1String("/data/scopeSwitching/JsToCppTwo.qml")); + QTest::newRow("cpp-to-js-to-cpp: nonconst, no retn, no args") << f << QString(QLatin1String("callCppFunction")); + + // Benchmarks: cost of calling js function which calls cpp function: + // const CPP function with no return value and a single integer argument. + f = QString(SRCDIR + QLatin1String("/data/scopeSwitching/JsToCppThree.qml")); + QTest::newRow("cpp-to-js-to-cpp: const, no retn, int arg") << f << QString(QLatin1String("callCppFunction")); + + // Benchmarks: cost of calling js function which calls cpp function: + // nonconst CPP function with no return value and a single integer argument. + f = QString(SRCDIR + QLatin1String("/data/scopeSwitching/JsToCppFour.qml")); + QTest::newRow("cpp-to-js-to-cpp: nonconst, no retn, int arg") << f << QString(QLatin1String("callCppFunction")); + + // Benchmarks: cost of calling js function which calls cpp function: + // const CPP function with an integer return value and no arguments. + f = QString(SRCDIR + QLatin1String("/data/scopeSwitching/JsToCppFive.qml")); + QTest::newRow("cpp-to-js-to-cpp: const, int retn, no args") << f << QString(QLatin1String("callCppFunction")); + + // Benchmarks: cost of calling js function which calls cpp function: + // nonconst CPP function with an integer return value and no arguments. + f = QString(SRCDIR + QLatin1String("/data/scopeSwitching/JsToCppSix.qml")); + QTest::newRow("cpp-to-js-to-cpp: nonconst, int retn, no args") << f << QString(QLatin1String("callCppFunction")); + + // Benchmarks: cost of calling js function which calls cpp function: + // const CPP function with an integer return value and a single integer argument. + f = QString(SRCDIR + QLatin1String("/data/scopeSwitching/JsToCppSeven.qml")); + QTest::newRow("cpp-to-js-to-cpp: const, int retn, int arg") << f << QString(QLatin1String("callCppFunction")); + + // Benchmarks: cost of calling js function which calls cpp function: + // nonconst CPP function with an integer return value and a single integer argument. + f = QString(SRCDIR + QLatin1String("/data/scopeSwitching/JsToCppEight.qml")); + QTest::newRow("cpp-to-js-to-cpp: nonconst, int retn, int arg") << f << QString(QLatin1String("callCppFunction")); + + // Benchmarks: cost of calling js function which calls cpp function: + // const CPP function with a variant return value and multiple integer arguments. + f = QString(SRCDIR + QLatin1String("/data/scopeSwitching/JsToCppNine.qml")); + QTest::newRow("cpp-to-js-to-cpp: const, variant retn, int args") << f << QString(QLatin1String("callCppFunction")); + + // Benchmarks: cost of calling js function which calls cpp function: + // nonconst CPP function with a variant return value and multiple integer arguments. + f = QString(SRCDIR + QLatin1String("/data/scopeSwitching/JsToCppTen.qml")); + QTest::newRow("cpp-to-js-to-cpp: nonconst, variant retn, int args") << f << QString(QLatin1String("callCppFunction")); + + // Benchmarks: cost of calling js function which calls cpp function: + // nonconst CPP function with a variant return value and multiple integer arguments. + f = QString(SRCDIR + QLatin1String("/data/scopeSwitching/JsToCppEleven.qml")); + QTest::newRow("cpp-to-js-to-cpp: nonconst, variant retn, variant + int args") << f << QString(QLatin1String("callCppFunction")); + + // Benchmarks: calling js function which copies scarce resources by calling back into cpp scope + f = QString(SRCDIR + QLatin1String("/data/scopeSwitching/ScarceOne.qml")); + QTest::newRow("cpp-to-js-to-coo: copy scarce resources") << f << QString(QLatin1String("copyScarceResources")); +} + + +void tst_holistic::cppToJsDirect() +{ + // This function benchmarks the cost of calling from CPP scope to JS scope + // (and possibly vice versa, if the invoked js method then calls to cpp). + + QFETCH(QString, file); + QFETCH(QString, methodName); + + QQmlComponent c(&engine, file); + QObject *obj = c.create(); + + QBENCHMARK { + QMetaObject::invokeMethod(obj, methodName.toLatin1().constData()); + } + + delete obj; +} + + +void tst_holistic::cppToJsIndirect() +{ + // This function benchmarks the cost of binding scarce resources + // to properties of a QML component. The engine should automatically release such + // resources when they are no longer used. + // The benchmark deliberately causes change signals to be emitted (and + // modifies the scarce resources) so that the properties are updated. + + QQmlComponent c(&engine, QString(SRCDIR + QLatin1String("/data/scopeSwitching/ScarceTwo.qml"))); + QObject *obj = c.create(); + + ScarceResourceProvider *srp = 0; + srp = qobject_cast(QQmlProperty::read(obj, "a").value()); + + QBENCHMARK { + srp->changeResources(); // will cause small+large scarce resources changed signals to be emitted. + } + + delete obj; +} + + + + + +void tst_holistic::typeResolution_data() +{ + QTest::addColumn("file"); + QTest::addColumn("propertyNameOne"); + QTest::addColumn("propertyValueOne"); + QTest::addColumn("propertyNameTwo"); + QTest::addColumn("propertyValueTwo"); + QTest::addColumn("repetitions"); + + QString f; + PropertyNameList pn1; + PropertyValueList pv1; + PropertyNameList pn2; + PropertyValueList pv2; + + // Benchmarks: resolving nested ids and types, no caching + f = QString(SRCDIR + QLatin1String("/data/resolutionTargets/ResolveOne.qml")); + pn1 << QString(QLatin1String("baseWidth")) << QString(QLatin1String("baseHeight")) << QString(QLatin1String("baseColor")); + pv1 << QVariant(401) << QVariant(402) << QVariant(QString(QLatin1String("brown"))); + pn2 << QString(QLatin1String("baseWidth")) << QString(QLatin1String("baseHeight")) << QString(QLatin1String("baseColor")); + pv2 << QVariant(403) << QVariant(404) << QVariant(QString(QLatin1String("orange"))); + QTest::newRow("nested id resolution") << f << pn1 << pv1 << pn2 << pv2 << 1; + + // Benchmarks: resolving nested ids and types, 10 reps with caching + QTest::newRow("nested id resolution, cached") << f << pn1 << pv1 << pn2 << pv2 << 10; + pn1.clear(); pn2.clear(); pv1.clear(); pv2.clear(); +} + +void tst_holistic::typeResolution() +{ + // This function benchmarks the cost of "continued operation" (signal invocation, + // updating bindings, etc) where the component has lots of nested items with + // lots of resolving required. Note that we take two different writeValues in order + // to force updates to occur. + + QFETCH(QString, file); + QFETCH(PropertyNameList, propertyNameOne); + QFETCH(PropertyValueList, propertyValueOne); + QFETCH(PropertyNameList, propertyNameTwo); + QFETCH(PropertyValueList, propertyValueTwo); + QFETCH(int, repetitions); + + Q_ASSERT(propertyNameOne.size() == propertyValueOne.size()); + Q_ASSERT(propertyNameTwo.size() == propertyValueTwo.size()); + Q_ASSERT(repetitions > 0); + + QQmlComponent c(&engine, file); + QObject *obj = c.create(); + + PropertyNameList writeProperty; + PropertyValueList writeValue; + bool usedFirst = false; + + QBENCHMARK { + for (int i = 0; i < repetitions; ++i) { + if (usedFirst) { + writeProperty = propertyNameOne; + writeValue = propertyValueOne; + usedFirst = false; + } else { + writeProperty = propertyNameTwo; + writeValue = propertyValueTwo; + usedFirst = true; + } + + for (int j = 0; j < writeProperty.size(); ++j) { + obj->setProperty(writeProperty.at(j).toAscii().constData(), writeValue.at(j)); + } + } + } + + delete obj; +} + + +QTEST_MAIN(tst_holistic) + +#include "tst_holistic.moc" diff --git a/tests/benchmarks/qml/javascript/data/NestedIdObject.qml b/tests/benchmarks/qml/javascript/data/NestedIdObject.qml new file mode 100644 index 0000000000..753d547ace --- /dev/null +++ b/tests/benchmarks/qml/javascript/data/NestedIdObject.qml @@ -0,0 +1,9 @@ +import QtQuick 2.0 + +QtObject { + function runtest() { + for (var ii = 0; ii < 5000000; ++ii) { + root + } + } +} diff --git a/tests/benchmarks/qml/javascript/data/intQObjectProperty.qml b/tests/benchmarks/qml/javascript/data/intQObjectProperty.qml new file mode 100644 index 0000000000..c3e6ebc16a --- /dev/null +++ b/tests/benchmarks/qml/javascript/data/intQObjectProperty.qml @@ -0,0 +1,13 @@ +import Qt.test 1.0 + +TestObject { + id: root + + function runtest() { + var r = root; + + for (var ii = 0; ii < 5000000; ++ii) { + r.intValue + } + } +} diff --git a/tests/benchmarks/qml/javascript/data/localId.qml b/tests/benchmarks/qml/javascript/data/localId.qml new file mode 100644 index 0000000000..d42b891092 --- /dev/null +++ b/tests/benchmarks/qml/javascript/data/localId.qml @@ -0,0 +1,13 @@ +// Benchmarks the cost of accessing an id in the same file as the script. + +import QtQuick 2.0 + +QtObject { + id: root + + function runtest() { + for (var ii = 0; ii < 5000000; ++ii) { + root + } + } +} diff --git a/tests/benchmarks/qml/javascript/data/nestedId.qml b/tests/benchmarks/qml/javascript/data/nestedId.qml new file mode 100644 index 0000000000..538699d452 --- /dev/null +++ b/tests/benchmarks/qml/javascript/data/nestedId.qml @@ -0,0 +1,13 @@ +// Benchmarks the cost of accessing an id in a parent context of the script. + +import QtQuick 2.0 + +QtObject { + id: root + + property variant object: NestedIdObject {} + function runtest() { + object.runtest(); + } +} + diff --git a/tests/benchmarks/qml/javascript/data/stringQObjectProperty.qml b/tests/benchmarks/qml/javascript/data/stringQObjectProperty.qml new file mode 100644 index 0000000000..ccd8a791b6 --- /dev/null +++ b/tests/benchmarks/qml/javascript/data/stringQObjectProperty.qml @@ -0,0 +1,14 @@ +import Qt.test 1.0 + +TestObject { + id: root + + function runtest() { + var r = root; + + for (var ii = 0; ii < 5000000; ++ii) { + r.stringValue + } + } +} + diff --git a/tests/benchmarks/qml/javascript/javascript.pro b/tests/benchmarks/qml/javascript/javascript.pro new file mode 100644 index 0000000000..281bbd0069 --- /dev/null +++ b/tests/benchmarks/qml/javascript/javascript.pro @@ -0,0 +1,11 @@ +CONFIG += testcase +TEMPLATE = app +TARGET = tst_javascript +QT += qml testlib +macx:CONFIG -= app_bundle + +SOURCES += tst_javascript.cpp testtypes.cpp +HEADERS += testtypes.h + +# Define SRCDIR equal to test's source directory +DEFINES += SRCDIR=\\\"$$PWD\\\" diff --git a/tests/benchmarks/qml/javascript/testtypes.cpp b/tests/benchmarks/qml/javascript/testtypes.cpp new file mode 100644 index 0000000000..43abef2d03 --- /dev/null +++ b/tests/benchmarks/qml/javascript/testtypes.cpp @@ -0,0 +1,48 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "testtypes.h" +#include + +void registerTypes() +{ + qmlRegisterType("Qt.test", 1,0, "TestObject"); +} diff --git a/tests/benchmarks/qml/javascript/testtypes.h b/tests/benchmarks/qml/javascript/testtypes.h new file mode 100644 index 0000000000..91be9078ed --- /dev/null +++ b/tests/benchmarks/qml/javascript/testtypes.h @@ -0,0 +1,65 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef TESTTYPES_H +#define TESTTYPES_H + +#include + +class TestObject : public QObject +{ + Q_OBJECT + Q_PROPERTY(int intValue READ intValue); + Q_PROPERTY(QString stringValue READ stringValue); + +public: + TestObject() : m_string("Hello world!") {} + + int intValue() const { return 13; } + QString stringValue() const { return m_string; } + +private: + QString m_string; +}; + +void registerTypes(); + +#endif // TESTTYPES_H diff --git a/tests/benchmarks/qml/javascript/tst_javascript.cpp b/tests/benchmarks/qml/javascript/tst_javascript.cpp new file mode 100644 index 0000000000..d506951b9f --- /dev/null +++ b/tests/benchmarks/qml/javascript/tst_javascript.cpp @@ -0,0 +1,123 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include +#include +#include +#include + +#include "testtypes.h" + +class tst_javascript : public QObject +{ + Q_OBJECT + +public: + tst_javascript(); + virtual ~tst_javascript(); + +private slots: + void run_data(); + void run(); + +private: + QQmlEngine engine; +}; + +tst_javascript::tst_javascript() +{ + registerTypes(); +} + +tst_javascript::~tst_javascript() +{ +} + +void tst_javascript::run_data() +{ + QTest::addColumn("file"); + + QDir dir(SRCDIR "/data"); + + QStringList files = dir.entryList(QDir::Files | QDir::NoDotAndDotDot); + + for (int ii = 0; ii < files.count(); ++ii) { + QString file = files.at(ii); + if (file.endsWith(".qml") && file.at(0).isLower()) { + + QString testName = file.left(file.length() - 4 /* strlen(".qml") */); + QString fileName = QLatin1String(SRCDIR) + QLatin1String("/data/") + file; + + + QTest::newRow(qPrintable(testName)) << fileName; + + } + } +} + +void tst_javascript::run() +{ + QFETCH(QString, file); + + QQmlComponent c(&engine, file); + + if (c.isError()) { + qWarning() << c.errors(); + } + + QVERIFY(!c.isError()); + + QObject *o = c.create(); + QVERIFY(o != 0); + + QMetaMethod method = o->metaObject()->method(o->metaObject()->indexOfMethod("runtest()")); + + QBENCHMARK { + method.invoke(o); + } + + delete o; +} + +QTEST_MAIN(tst_javascript) + +#include "tst_javascript.moc" diff --git a/tests/benchmarks/qml/js/js.pro b/tests/benchmarks/qml/js/js.pro new file mode 100644 index 0000000000..b1448d8eb8 --- /dev/null +++ b/tests/benchmarks/qml/js/js.pro @@ -0,0 +1,10 @@ +TEMPLATE = subdirs +SUBDIRS = \ + qjsengine \ + qjsvalue \ + qjsvalueiterator \ + +TRUSTED_BENCHMARKS += \ + qjsvalue \ + qjsengine \ + diff --git a/tests/benchmarks/qml/js/qjsengine/qjsengine.pro b/tests/benchmarks/qml/js/qjsengine/qjsengine.pro new file mode 100644 index 0000000000..f8f2874a63 --- /dev/null +++ b/tests/benchmarks/qml/js/qjsengine/qjsengine.pro @@ -0,0 +1,7 @@ +CONFIG += testcase +TEMPLATE = app +TARGET = tst_bench_qjsengine + +SOURCES += tst_qjsengine.cpp + +QT += qml testlib diff --git a/tests/benchmarks/qml/js/qjsengine/tst_qjsengine.cpp b/tests/benchmarks/qml/js/qjsengine/tst_qjsengine.cpp new file mode 100644 index 0000000000..5713eb2f2e --- /dev/null +++ b/tests/benchmarks/qml/js/qjsengine/tst_qjsengine.cpp @@ -0,0 +1,600 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include +#include + + +Q_DECLARE_METATYPE(QJSValue) + +class tst_QJSEngine : public QObject +{ + Q_OBJECT + +public: + tst_QJSEngine(); + virtual ~tst_QJSEngine(); + +public slots: + void init(); + void cleanup(); + +private slots: + void constructor(); +#if 0 // No defaultPrototype for now + void defaultPrototype(); + void setDefaultPrototype(); +#endif + void evaluate_data(); + void evaluate(); +#if 0 // No program + void evaluateProgram_data(); + void evaluateProgram(); +#endif +#if 0 // no connections for now + void connectAndDisconnect(); +#endif + void globalObject(); + void hasUncaughtException(); +#if 0 // no is Evaluating for now + void isEvaluating(); +#endif + void newArray_data(); + void newArray(); + void newDate(); + void newObject(); +#if 0 // No ScriptClass + void newObjectWithScriptClass(); +#endif +#if 0 // no qmetaobject + void newQMetaObject(); +#endif + void newQObject(); +#if 0 // no native functions for now + void newFunction(); +#endif + void newRegExp(); + void newVariant(); + void undefinedValue(); + void collectGarbage(); +#if 0 // No extensions + void availableExtensions(); + void importedExtensions(); +#endif +#if 0 // no context + void currentContext(); + void pushAndPopContext(); +#endif +#if 0 // no stringhandle + void toStringHandle(); +#endif + void castValueToQreal(); +#if 0 // no native functions for now + void nativeCall(); +#endif +#if 0 // no translations + void installTranslatorFunctions(); + void translation_data(); + void translation(); +#endif +#if 0 // no declarative class + void readScopeProperty_data(); + void readScopeProperty(); +#endif +#if 0 // no context + void evaluateInNewContext(); + void evaluateInNewContextWithScope(); +#endif +#if 0 // no pushScope + void evaluateBindingExpression(); +#endif + +private: + void defineStandardTestValues(); + void newEngine() + { + delete m_engine; + m_engine = new QJSEngine; + } + + QJSEngine *m_engine; +}; + +tst_QJSEngine::tst_QJSEngine() + : m_engine(0) +{ +} + +tst_QJSEngine::~tst_QJSEngine() +{ + delete m_engine; +} + +void tst_QJSEngine::init() +{ +} + +void tst_QJSEngine::cleanup() +{ +} + +void tst_QJSEngine::constructor() +{ + QBENCHMARK { + QJSEngine engine; + (void)engine.parent(); + } +} + +#if 0 // No defaultPrototype for now +void tst_QJSEngine::defaultPrototype() +{ + newEngine(); + int type = qMetaTypeId(); + m_engine->setDefaultPrototype(type, m_engine->newObject()); + QBENCHMARK { + m_engine->defaultPrototype(type); + } +} + +void tst_QJSEngine::setDefaultPrototype() +{ + newEngine(); + int type = qMetaTypeId(); + QJSValue proto = m_engine->newObject(); + QBENCHMARK { + m_engine->setDefaultPrototype(type, proto); + } +} + +#endif + +void tst_QJSEngine::evaluate_data() +{ + QTest::addColumn("code"); + QTest::newRow("empty script") << QString::fromLatin1(""); + QTest::newRow("number literal") << QString::fromLatin1("123"); + QTest::newRow("string literal") << QString::fromLatin1("'ciao'"); + QTest::newRow("regexp literal") << QString::fromLatin1("/foo/gim"); + QTest::newRow("null literal") << QString::fromLatin1("null"); + QTest::newRow("undefined literal") << QString::fromLatin1("undefined"); + QTest::newRow("null literal") << QString::fromLatin1("null"); + QTest::newRow("empty object literal") << QString::fromLatin1("{}"); + QTest::newRow("this") << QString::fromLatin1("this"); + QTest::newRow("object literal with one property") << QString::fromLatin1("{ foo: 123 }"); + QTest::newRow("object literal with two properties") << QString::fromLatin1("{ foo: 123, bar: 456 }"); + QTest::newRow("object literal with many properties") << QString::fromLatin1("{ a: 1, b: 2, c: 3, d: 4, e: 5, f: 6, g: 7, h: 8, i: 9, j: 10 }"); + QTest::newRow("empty array literal") << QString::fromLatin1("[]"); + QTest::newRow("array literal with one element") << QString::fromLatin1("[1]"); + QTest::newRow("array literal with two elements") << QString::fromLatin1("[1,2]"); + QTest::newRow("array literal with many elements") << QString::fromLatin1("[1,2,3,4,5,6,7,8,9,10,9,8,7,6,5,4,3,2,1]"); + QTest::newRow("empty function definition") << QString::fromLatin1("function foo() { }"); + QTest::newRow("function definition") << QString::fromLatin1("function foo() { return 123; }"); + QTest::newRow("for loop with empty body (1000 iterations)") << QString::fromLatin1("for (i = 0; i < 1000; ++i) {}"); + QTest::newRow("for loop with empty body (10000 iterations)") << QString::fromLatin1("for (i = 0; i < 10000; ++i) {}"); + QTest::newRow("for loop with empty body (100000 iterations)") << QString::fromLatin1("for (i = 0; i < 100000; ++i) {}"); + QTest::newRow("for loop with empty body (1000000 iterations)") << QString::fromLatin1("for (i = 0; i < 1000000; ++i) {}"); + QTest::newRow("for loop (1000 iterations)") << QString::fromLatin1("j = 0; for (i = 0; i < 1000; ++i) { j += i; }; j"); + QTest::newRow("for loop (10000 iterations)") << QString::fromLatin1("j = 0; for (i = 0; i < 10000; ++i) { j += i; }; j"); + QTest::newRow("for loop (100000 iterations)") << QString::fromLatin1("j = 0; for (i = 0; i < 100000; ++i) { j += i; }; j"); + QTest::newRow("for loop (1000000 iterations)") << QString::fromLatin1("j = 0; for (i = 0; i < 1000000; ++i) { j += i; }; j"); + QTest::newRow("assignments") << QString::fromLatin1("a = 1; b = 2; c = 3; d = 4"); + QTest::newRow("while loop (1000 iterations)") << QString::fromLatin1("i = 0; while (i < 1000) { ++i; }; i"); + QTest::newRow("while loop (10000 iterations)") << QString::fromLatin1("i = 0; while (i < 10000) { ++i; }; i"); + QTest::newRow("while loop (100000 iterations)") << QString::fromLatin1("i = 0; while (i < 100000) { ++i; }; i"); + QTest::newRow("while loop (1000000 iterations)") << QString::fromLatin1("i = 0; while (i < 1000000) { ++i; }; i"); + QTest::newRow("function expression") << QString::fromLatin1("(function(a, b, c){ return a + b + c; })(1, 2, 3)"); +} + +void tst_QJSEngine::evaluate() +{ + QFETCH(QString, code); + newEngine(); + + QBENCHMARK { + (void)m_engine->evaluate(code); + } +} + +#if 0 +void tst_QJSEngine::connectAndDisconnect() +{ + newEngine(); + QJSValue fun = m_engine->evaluate("(function() { })"); + QBENCHMARK { + qScriptConnect(m_engine, SIGNAL(destroyed()), QJSValue(), fun); + qScriptDisconnect(m_engine, SIGNAL(destroyed()), QJSValue(), fun); + } +} + +void tst_QJSEngine::evaluateProgram_data() +{ + evaluate_data(); +} + +void tst_QJSEngine::evaluateProgram() +{ + QFETCH(QString, code); + QScriptProgram program(code); + newEngine(); + + QBENCHMARK { + (void)m_engine->evaluate(program); + } +} +#endif + +void tst_QJSEngine::globalObject() +{ + newEngine(); + QBENCHMARK { + m_engine->globalObject(); + } +} + +void tst_QJSEngine::hasUncaughtException() +{ + newEngine(); + QBENCHMARK { + m_engine->hasUncaughtException(); + } +} + +#if 0 +void tst_QJSEngine::isEvaluating() +{ + newEngine(); + QBENCHMARK { + m_engine->isEvaluating(); + } +} +#endif + +void tst_QJSEngine::newArray_data() +{ + QTest::addColumn("size"); + QTest::newRow("size=0") << 0; + QTest::newRow("size=10") << 10; + QTest::newRow("size=100") << 0; + QTest::newRow("size=1000") << 0; + QTest::newRow("size=10000") << 0; + QTest::newRow("size=50000") << 0; +} + +void tst_QJSEngine::newArray() +{ + QFETCH(int, size); + newEngine(); + QBENCHMARK { + m_engine->newArray(size); + } +} + +void tst_QJSEngine::newDate() +{ + newEngine(); + QDateTime dt = QDateTime::currentDateTime(); + QBENCHMARK { + m_engine->toScriptValue(dt); + } +} + +void tst_QJSEngine::newObject() +{ + newEngine(); + QBENCHMARK { + (void)m_engine->newObject(); + } +} + +#if 0 +void tst_QJSEngine::newObjectWithScriptClass() +{ + newEngine(); + QScriptClass cls(m_engine); + QBENCHMARK { + m_engine->newObject(&cls); + } +} + +void tst_QJSEngine::newQMetaObject() +{ + newEngine(); + QBENCHMARK { + m_engine->newQMetaObject(&QJSEngine::staticMetaObject); + } +} +#endif + +void tst_QJSEngine::newQObject() +{ + newEngine(); + QBENCHMARK { + (void)m_engine->newQObject(QCoreApplication::instance()); + } +} + +#if 0 +static QJSValue testFunction(QScriptContext *, QJSEngine *) +{ + return 0; +} + +void tst_QJSEngine::newFunction() +{ + newEngine(); + QBENCHMARK { + (void)m_engine->newFunction(testFunction); + } +} +#endif + +void tst_QJSEngine::newRegExp() +{ + newEngine(); + QRegExp re = QRegExp("foo"); + QBENCHMARK { + m_engine->toScriptValue(re); + } +} + +void tst_QJSEngine::newVariant() +{ + newEngine(); + QVariant var(QPoint(10, 20)); + QBENCHMARK { + (void)m_engine->toScriptValue(var); + } +} + +void tst_QJSEngine::undefinedValue() +{ + newEngine(); + QVariant var; + QBENCHMARK { + m_engine->toScriptValue(var); + } +} + +void tst_QJSEngine::collectGarbage() +{ + newEngine(); + QBENCHMARK { + m_engine->collectGarbage(); + } +} + +#if 0 +void tst_QJSEngine::availableExtensions() +{ + newEngine(); + QBENCHMARK { + m_engine->availableExtensions(); + } +} + +void tst_QJSEngine::importedExtensions() +{ + newEngine(); + QBENCHMARK { + m_engine->importedExtensions(); + } +} + +void tst_QJSEngine::currentContext() +{ + newEngine(); + QBENCHMARK { + m_engine->currentContext(); + } +} + +void tst_QJSEngine::pushAndPopContext() +{ + newEngine(); + QBENCHMARK { + (void)m_engine->pushContext(); + m_engine->popContext(); + } +} +#endif + +#if 0 +void tst_QJSEngine::toStringHandle() +{ + newEngine(); + QString str = QString::fromLatin1("foobarbaz"); + QBENCHMARK { + (void)m_engine->toStringHandle(str); + } +} +#endif + +void tst_QJSEngine::castValueToQreal() +{ + QJSValue val(123); + QBENCHMARK { + (void)qjsvalue_cast(val); + } +} + +#if 0 +static QJSValue native_function(QScriptContext *, QJSEngine *) +{ + return 42; +} + +void tst_QJSEngine::nativeCall() +{ + newEngine(); + m_engine->globalObject().setProperty("fun", m_engine->newFunction(native_function)); + QBENCHMARK{ + m_engine->evaluate("var w = 0; for (i = 0; i < 100000; ++i) {\n" + " w += fun() + fun(); w -= fun(); fun(); w -= fun(); }"); + } +} + +void tst_QJSEngine::installTranslatorFunctions() +{ + newEngine(); + QBENCHMARK { + m_engine->installTranslatorFunctions(); + } +} + +void tst_QJSEngine::translation_data() +{ + QTest::addColumn("text"); + QTest::addColumn("fileName"); + QTest::newRow("no translation") << "\"hello world\"" << ""; + QTest::newRow("qsTr") << "qsTr(\"hello world\")" << ""; + QTest::newRow("qsTranslate") << "qsTranslate(\"\", \"hello world\")" << ""; + QTest::newRow("qsTr:script.js") << "qsTr(\"hello world\")" << "script.js"; +} + +void tst_QJSEngine::translation() +{ + QFETCH(QString, text); + QFETCH(QString, fileName); + newEngine(); + m_engine->installTranslatorFunctions(); + + QBENCHMARK { + (void)m_engine->evaluate(text, fileName); + } +} +#endif + +#if 0 +void tst_QJSEngine::readScopeProperty_data() +{ + QTest::addColumn("staticScope"); + QTest::addColumn("nestedScope"); + QTest::newRow("single dynamic scope") << false << false; + QTest::newRow("single static scope") << true << false; + QTest::newRow("double dynamic scope") << false << true; + QTest::newRow("double static scope") << true << true; +} + +void tst_QJSEngine::readScopeProperty() +{ + QFETCH(bool, staticScope); + QFETCH(bool, nestedScope); + + newEngine(); + QScriptContext *ctx = m_engine->pushContext(); + + QJSValue scope; + if (staticScope) + scope = QScriptDeclarativeClass::newStaticScopeObject(m_engine); + else + scope = m_engine->newObject(); + scope.setProperty("foo", 123); + ctx->pushScope(scope); + + if (nestedScope) { + QJSValue scope2; + if (staticScope) + scope2 = QScriptDeclarativeClass::newStaticScopeObject(m_engine); + else + scope2 = m_engine->newObject(); + scope2.setProperty("bar", 456); // ensure a miss in inner scope + ctx->pushScope(scope2); + } + + QJSValue fun = m_engine->evaluate("(function() {\n" + " for (var i = 0; i < 10000; ++i) {\n" + " foo; foo; foo; foo; foo; foo; foo; foo;\n" + " }\n" + "})"); + m_engine->popContext(); + QVERIFY(fun.isFunction()); + QBENCHMARK { + fun.call(); + } +} + +void tst_QJSEngine::evaluateInNewContext() +{ + QJSEngine engine; + QBENCHMARK { + engine.pushContext(); + engine.evaluate("var a = 10"); + engine.popContext(); + } +} + +void tst_QJSEngine::evaluateInNewContextWithScope() +{ + QJSEngine engine; + QJSValue scope = engine.newObject(); + scope.setProperty("foo", 123); + QBENCHMARK { + QScriptContext *ctx = engine.pushContext(); + ctx->pushScope(scope); + engine.evaluate("foo"); + engine.popContext(); + } +} + +// Binding expressions in QML are implemented as anonymous functions +// with custom scopes. +void tst_QJSEngine::evaluateBindingExpression() +{ + QJSEngine engine; + QScriptContext *ctx = engine.pushContext(); + QJSValue scope = engine.newObject(); + scope.setProperty("foo", 123); + ctx->pushScope(scope); + QJSValue fun = engine.evaluate("(function() { return foo; })"); + QVERIFY(fun.isFunction()); + engine.popContext(); + QVERIFY(fun.call().equals(scope.property("foo"))); + QJSValue receiver = engine.globalObject(); + QBENCHMARK { + fun.call(receiver); + } +} +#endif + +QTEST_MAIN(tst_QJSEngine) +#include "tst_qjsengine.moc" diff --git a/tests/benchmarks/qml/js/qjsvalue/qjsvalue.pro b/tests/benchmarks/qml/js/qjsvalue/qjsvalue.pro new file mode 100644 index 0000000000..772aa5da8c --- /dev/null +++ b/tests/benchmarks/qml/js/qjsvalue/qjsvalue.pro @@ -0,0 +1,7 @@ +CONFIG += testcase +TEMPLATE = app +TARGET = tst_bench_qjsvalue + +SOURCES += tst_qjsvalue.cpp + +QT += qml testlib diff --git a/tests/benchmarks/qml/js/qjsvalue/tst_qjsvalue.cpp b/tests/benchmarks/qml/js/qjsvalue/tst_qjsvalue.cpp new file mode 100644 index 0000000000..6c760f37aa --- /dev/null +++ b/tests/benchmarks/qml/js/qjsvalue/tst_qjsvalue.cpp @@ -0,0 +1,979 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include +#include + +Q_DECLARE_METATYPE(QJSValue) + +class tst_QJSValue : public QObject +{ + Q_OBJECT + +public: + tst_QJSValue(); + virtual ~tst_QJSValue(); + +public slots: + void init(); + void cleanup(); + +private slots: + void boolConstructor(); + void floatConstructor(); + void numberConstructor(); + void stringConstructor(); + void nullConstructor(); + void undefinedConstructor(); + void boolConstructorWithEngine(); + void floatConstructorWithEngine(); + void intConstructorWithEngine(); + void stringConstructorWithEngine(); + void undefinedConstructorWithEngine(); + void copyConstructor_data(); + void copyConstructor(); + void call_data(); + void call(); + void construct_data(); + void construct(); +#if 0 // no data + void data(); + void setData(); + void data_noData_data(); + void data_noData(); +#endif + void equalsSelf_data(); + void equalsSelf(); +#if 0 // no less then + void lessThanSelf_data(); + void lessThanSelf(); +#endif + void strictlyEqualsSelf_data(); + void strictlyEqualsSelf(); + void isArray_data(); + void isArray(); + void isBool_data(); + void isBool(); + void isDate_data(); + void isDate(); + void isError_data(); + void isError(); + void isCallable_data(); + void isCallable(); + void isNull_data(); + void isNull(); + void isNumber_data(); + void isNumber(); + void isObject_data(); + void isObject(); +#if 0 // no qmetaobject + void isQMetaObject_data(); + void isQMetaObject(); +#endif + void isQObject_data(); + void isQObject(); + void isRegExp_data(); + void isRegExp(); + void isString_data(); + void isString(); + void isUndefined_data(); + void isUndefined(); + void isVariant_data(); + void isVariant(); + void toBool_data(); + void toBool(); + void toDateTime_data(); + void toDateTime(); + void toInt_data(); + void toInt(); + void toNumber_data(); + void toNumber(); + void toRegExp_data(); + void toRegExp(); + void toString_data(); + void toString(); + void toUInt_data(); + void toUInt(); +#if 0 // no qmetaobject + void toQMetaObject_data(); + void toQMetaObject(); +#endif + void toQObject_data(); + void toQObject(); + void toVariant_data(); + void toVariant(); + void property_data(); + void property(); +#if 0 // no string handle + void propertyById_data(); + void propertyById(); +#endif + void propertyByIndex(); + void setProperty_data(); + void setProperty(); +#if 0 // no string handle + void setPropertyById_data(); + void setPropertyById(); +#endif + void setPropertyByIndex(); +#if 0 // no propertyFlags for now + void propertyFlags_data(); + void propertyFlags(); + void propertyFlagsById_data(); + void propertyFlagsById(); +#endif + void prototype_data(); + void prototype(); + void setPrototype(); +#if 0 // no script class + void scriptClass_data(); + void scriptClass(); + void setScriptClass(); +#endif +#if 0 // no string handle + void readMetaProperty(); + void writeMetaProperty(); +#endif + +private: + void defineStandardTestValues(); + void newEngine() + { + delete m_engine; + m_engine = new QJSEngine; + } + + QJSEngine *m_engine; +}; + +tst_QJSValue::tst_QJSValue() + : m_engine(0) +{ +} + +tst_QJSValue::~tst_QJSValue() +{ + delete m_engine; +} + +void tst_QJSValue::init() +{ +} + +void tst_QJSValue::cleanup() +{ +} + +void tst_QJSValue::boolConstructor() +{ + QBENCHMARK { + QJSValue val(true); + } +} + +void tst_QJSValue::floatConstructor() +{ + QBENCHMARK { + QJSValue val(123.0); + } +} + +void tst_QJSValue::numberConstructor() +{ + QBENCHMARK { + (void)QJSValue(123); + } +} + +void tst_QJSValue::stringConstructor() +{ + QString str = QString::fromLatin1("ciao"); + QBENCHMARK { + (void)QJSValue(str); + } +} + +void tst_QJSValue::nullConstructor() +{ + QBENCHMARK { + QJSValue val(QJSValue::NullValue); + } +} + +void tst_QJSValue::undefinedConstructor() +{ + QBENCHMARK { + QJSValue val(QJSValue::UndefinedValue); + } +} + +void tst_QJSValue::boolConstructorWithEngine() +{ + newEngine(); + QBENCHMARK { + m_engine->toScriptValue(true); + } +} + +void tst_QJSValue::floatConstructorWithEngine() +{ + newEngine(); + QBENCHMARK { + m_engine->toScriptValue(123.0); + } +} + +void tst_QJSValue::intConstructorWithEngine() +{ + newEngine(); + QBENCHMARK { + m_engine->toScriptValue(123); + } +} + +void tst_QJSValue::stringConstructorWithEngine() +{ + newEngine(); + QString str = QString::fromLatin1("ciao"); + QBENCHMARK { + m_engine->toScriptValue(str); + } +} + +void tst_QJSValue::undefinedConstructorWithEngine() +{ + newEngine(); + QVariant var; + QBENCHMARK { + m_engine->toScriptValue(var); + } +} + +void tst_QJSValue::copyConstructor_data() +{ + defineStandardTestValues(); +} + +void tst_QJSValue::copyConstructor() +{ + QFETCH(QJSValue, val); + QBENCHMARK { + QJSValue copy(val); + } +} + +void tst_QJSValue::call_data() +{ + newEngine(); + QTest::addColumn("code"); + QTest::newRow("empty function") << QString::fromLatin1("(function(){})"); + QTest::newRow("function returning number") << QString::fromLatin1("(function(){ return 123; })"); + QTest::newRow("closure") << QString::fromLatin1("(function(a, b){ return function() { return a + b; }; })(1, 2)"); +} + +void tst_QJSValue::call() +{ + QFETCH(QString, code); + QJSValue fun = m_engine->evaluate(code); + QVERIFY(fun.isCallable()); + QBENCHMARK { + (void)fun.call(); + } +} + +void tst_QJSValue::construct_data() +{ + newEngine(); + QTest::addColumn("code"); + QTest::newRow("empty function") << QString::fromLatin1("(function(){})"); + QTest::newRow("simple constructor") << QString::fromLatin1("(function(){ this.x = 10; this.y = 20; })"); +} + +void tst_QJSValue::construct() +{ + QFETCH(QString, code); + QJSValue fun = m_engine->evaluate(code); + QVERIFY(fun.isCallable()); + QBENCHMARK { + (void)fun.callAsConstructor(); + } +} + +#if 0 +void tst_QJSValue::data() +{ + newEngine(); + QJSValue obj = m_engine->newObject(); + obj.setData(QJSValue(m_engine, 123)); + QBENCHMARK { + obj.data(); + } +} + +void tst_QJSValue::setData() +{ + newEngine(); + QJSValue obj = m_engine->newObject(); + QJSValue val(m_engine, 123); + QBENCHMARK { + obj.setData(val); + } +} + +void tst_QJSValue::data_noData_data() +{ + defineStandardTestValues(); +} + +void tst_QJSValue::data_noData() +{ + QFETCH(QJSValue, val); + QVERIFY(!val.data().isValid()); + QBENCHMARK { + val.data(); + } +} +#endif + +void tst_QJSValue::equalsSelf_data() +{ + defineStandardTestValues(); +} + +void tst_QJSValue::equalsSelf() +{ + QFETCH(QJSValue, val); + QBENCHMARK { + val.equals(val); + } +} + +#if 0 +void tst_QJSValue::lessThanSelf_data() +{ + defineStandardTestValues(); +} + +void tst_QJSValue::lessThanSelf() +{ + QFETCH(QJSValue, val); + QBENCHMARK { + val.lessThan(val); + } +} +#endif + +void tst_QJSValue::strictlyEqualsSelf_data() +{ + defineStandardTestValues(); +} + +void tst_QJSValue::strictlyEqualsSelf() +{ + QFETCH(QJSValue, val); + QBENCHMARK { + val.strictlyEquals(val); + } +} + +void tst_QJSValue::isArray_data() +{ + defineStandardTestValues(); +} + +void tst_QJSValue::isArray() +{ + QFETCH(QJSValue, val); + QBENCHMARK { + val.isArray(); + } +} + +void tst_QJSValue::isBool_data() +{ + defineStandardTestValues(); +} + +void tst_QJSValue::isBool() +{ + QFETCH(QJSValue, val); + QBENCHMARK { + val.isBool(); + } +} + +void tst_QJSValue::isDate_data() +{ + defineStandardTestValues(); +} + +void tst_QJSValue::isDate() +{ + QFETCH(QJSValue, val); + QBENCHMARK { + val.isDate(); + } +} + +void tst_QJSValue::isError_data() +{ + defineStandardTestValues(); +} + +void tst_QJSValue::isError() +{ + QFETCH(QJSValue, val); + QBENCHMARK { + val.isError(); + } +} + +void tst_QJSValue::isCallable_data() +{ + defineStandardTestValues(); +} + +void tst_QJSValue::isCallable() +{ + QFETCH(QJSValue, val); + QBENCHMARK { + val.isCallable(); + } +} + +void tst_QJSValue::isNull_data() +{ + defineStandardTestValues(); +} + +void tst_QJSValue::isNull() +{ + QFETCH(QJSValue, val); + QBENCHMARK { + val.isNull(); + } +} + +void tst_QJSValue::isNumber_data() +{ + defineStandardTestValues(); +} + +void tst_QJSValue::isNumber() +{ + QFETCH(QJSValue, val); + QBENCHMARK { + val.isNumber(); + } +} + +void tst_QJSValue::isObject_data() +{ + defineStandardTestValues(); +} + +void tst_QJSValue::isObject() +{ + QFETCH(QJSValue, val); + QBENCHMARK { + val.isObject(); + } +} + +#if 0 +void tst_QJSValue::isQMetaObject_data() +{ + defineStandardTestValues(); +} + +void tst_QJSValue::isQMetaObject() +{ + QFETCH(QJSValue, val); + QBENCHMARK { + val.isQMetaObject(); + } +} +#endif + +void tst_QJSValue::isQObject_data() +{ + defineStandardTestValues(); +} + +void tst_QJSValue::isQObject() +{ + QFETCH(QJSValue, val); + QBENCHMARK { + val.isQObject(); + } +} + +void tst_QJSValue::isRegExp_data() +{ + defineStandardTestValues(); +} + +void tst_QJSValue::isRegExp() +{ + QFETCH(QJSValue, val); + QBENCHMARK { + val.isRegExp(); + } +} + +void tst_QJSValue::isString_data() +{ + defineStandardTestValues(); +} + +void tst_QJSValue::isString() +{ + QFETCH(QJSValue, val); + QBENCHMARK { + val.isString(); + } +} + +void tst_QJSValue::isUndefined_data() +{ + defineStandardTestValues(); +} + +void tst_QJSValue::isUndefined() +{ + QFETCH(QJSValue, val); + QBENCHMARK { + val.isUndefined(); + } +} + +void tst_QJSValue::isVariant_data() +{ + defineStandardTestValues(); +} + +void tst_QJSValue::isVariant() +{ + QFETCH(QJSValue, val); + QBENCHMARK { + val.isVariant(); + } +} + +void tst_QJSValue::toBool_data() +{ + defineStandardTestValues(); +} + +void tst_QJSValue::toBool() +{ + QFETCH(QJSValue, val); + QBENCHMARK { + val.toBool(); + } +} + +void tst_QJSValue::toDateTime_data() +{ + defineStandardTestValues(); +} + +void tst_QJSValue::toDateTime() +{ + QFETCH(QJSValue, val); + QBENCHMARK { + val.toDateTime(); + } +} + +void tst_QJSValue::toInt_data() +{ + defineStandardTestValues(); +} + +void tst_QJSValue::toInt() +{ + QFETCH(QJSValue, val); + QBENCHMARK { + val.toInt(); + } +} + +void tst_QJSValue::toNumber_data() +{ + defineStandardTestValues(); +} + +void tst_QJSValue::toNumber() +{ + QFETCH(QJSValue, val); + QBENCHMARK { + val.toNumber(); + } +} + +void tst_QJSValue::toRegExp_data() +{ + defineStandardTestValues(); +} + +void tst_QJSValue::toRegExp() +{ + QFETCH(QJSValue, val); + QBENCHMARK { + qjsvalue_cast(val); + } +} + +void tst_QJSValue::toString_data() +{ + defineStandardTestValues(); +} + +void tst_QJSValue::toString() +{ + QFETCH(QJSValue, val); + QBENCHMARK { + (void)val.toString(); + } +} + +#if 0 +void tst_QJSValue::toQMetaObject_data() +{ + defineStandardTestValues(); +} + +void tst_QJSValue::toQMetaObject() +{ + QFETCH(QJSValue, val); + QBENCHMARK { + val.toQMetaObject(); + } +} +#endif + +void tst_QJSValue::toQObject_data() +{ + defineStandardTestValues(); +} + +void tst_QJSValue::toQObject() +{ + QFETCH(QJSValue, val); + QBENCHMARK { + (void)val.toQObject(); + } +} + +void tst_QJSValue::toUInt_data() +{ + defineStandardTestValues(); +} + +void tst_QJSValue::toUInt() +{ + QFETCH(QJSValue, val); + QBENCHMARK { + val.toUInt(); + } +} + +void tst_QJSValue::toVariant_data() +{ + defineStandardTestValues(); +} + +void tst_QJSValue::toVariant() +{ + QFETCH(QJSValue, val); + QBENCHMARK { + val.toVariant(); + } +} +void tst_QJSValue::property_data() +{ + QTest::addColumn("propertyName"); + QTest::addColumn("create"); + QTest::newRow("foo") << QString::fromLatin1("foo") << true; + QTest::newRow("hasOwnProperty") << QString::fromLatin1("hasOwnProperty") << false; // From Object.prototype. + QTest::newRow("noSuchProperty") << QString::fromLatin1("noSuchProperty") << false; +} + +void tst_QJSValue::property() +{ + QFETCH(QString, propertyName); + QFETCH(bool, create); + newEngine(); + QJSValue obj = m_engine->newObject(); + if (create) + obj.setProperty(propertyName, 123); + QBENCHMARK { + (void)obj.property(propertyName); + } +} + +#if 0 +void tst_QJSValue::propertyById_data() +{ + property_data(); +} + +void tst_QJSValue::propertyById() +{ + QFETCH(QString, propertyName); + QFETCH(bool, create); + newEngine(); + QJSValue obj = m_engine->newObject(); + QJSString id = m_engine->toStringHandle(propertyName); + if (create) + obj.setProperty(id, 123); + QBENCHMARK { + obj.property(id); + } +} +#endif + +void tst_QJSValue::propertyByIndex() +{ + newEngine(); + QJSValue obj = m_engine->newObject(); + obj.setProperty(123, 456); + QBENCHMARK { + obj.property(123); + } +} + +void tst_QJSValue::setProperty_data() +{ + newEngine(); + QTest::addColumn("propertyName"); + QTest::addColumn("val"); + QTest::newRow("foo") << QString::fromLatin1("foo") << QJSValue(123); + QTest::newRow("bar") << QString::fromLatin1("bar") << m_engine->toScriptValue(123); + QTest::newRow("baz") << QString::fromLatin1("baz") << QJSValue(); + QTest::newRow("toString") << QString::fromLatin1("toString") << m_engine->toScriptValue(true); +} + +void tst_QJSValue::setProperty() +{ + QFETCH(QString, propertyName); + QFETCH(QJSValue, val); + QJSValue obj = m_engine->newObject(); + QBENCHMARK { + obj.setProperty(propertyName, val); + } +} + +#if 0 +void tst_QJSValue::setPropertyById_data() +{ + setProperty_data(); +} + +void tst_QJSValue::setPropertyById() +{ + QFETCH(QString, propertyName); + QFETCH(QJSValue, val); + QJSValue obj = m_engine->newObject(); + QJSString id = m_engine->toStringHandle(propertyName); + QBENCHMARK { + obj.setProperty(id, val); + } +} +#endif + +void tst_QJSValue::setPropertyByIndex() +{ + newEngine(); + QJSValue obj = m_engine->newObject(); + QJSValue val(456); + QBENCHMARK { + obj.setProperty(123, 456); + } +} + +#if 0 +void tst_QJSValue::propertyFlags_data() +{ + property_data(); +} + +void tst_QJSValue::propertyFlags() +{ + QFETCH(QString, propertyName); + QFETCH(bool, create); + newEngine(); + QJSValue obj = m_engine->newObject(); + if (create) + obj.setProperty(propertyName, 123, QJSValue::SkipInEnumeration | QJSValue::ReadOnly); + QBENCHMARK { + (void)obj.propertyFlags(propertyName); + } +} + +void tst_QJSValue::propertyFlagsById_data() +{ + propertyFlags_data(); +} + +void tst_QJSValue::propertyFlagsById() +{ + QFETCH(QString, propertyName); + QFETCH(bool, create); + newEngine(); + QJSValue obj = m_engine->newObject(); + QJSString id = m_engine->toStringHandle(propertyName); + if (create) + obj.setProperty(id, 123, QJSValue::SkipInEnumeration | QJSValue::ReadOnly); + QBENCHMARK { + obj.propertyFlags(id); + } +} +#endif + +void tst_QJSValue::prototype_data() +{ + defineStandardTestValues(); +} + +void tst_QJSValue::prototype() +{ + QFETCH(QJSValue, val); + QBENCHMARK { + val.prototype(); + } +} + +void tst_QJSValue::setPrototype() +{ + newEngine(); + QJSValue obj = m_engine->newObject(); + QJSValue proto = m_engine->newObject(); + QBENCHMARK { + obj.setPrototype(proto); + } +} + +#if 0 +void tst_QJSValue::scriptClass_data() +{ + defineStandardTestValues(); +} + +void tst_QJSValue::scriptClass() +{ + QFETCH(QJSValue, val); + QBENCHMARK { + val.scriptClass(); + } +} + +void tst_QJSValue::setScriptClass() +{ + newEngine(); + QJSValue obj = m_engine->newObject(); + QJSClass cls(m_engine); + QBENCHMARK { + obj.setScriptClass(&cls); + } +} + +void tst_QJSValue::readMetaProperty() +{ + newEngine(); + QJSValue object = m_engine->newQObject(QCoreApplication::instance()); + QJSString propertyName = m_engine->toStringHandle("objectName"); + QBENCHMARK { + for (int i = 0; i < 10000; ++i) + object.property(propertyName); + } +} + +void tst_QJSValue::writeMetaProperty() +{ + newEngine(); + QJSValue object = m_engine->newQObject(QCoreApplication::instance()); + QJSString propertyName = m_engine->toStringHandle("objectName"); + QJSValue value(m_engine, "foo"); + QBENCHMARK { + for (int i = 0; i < 10000; ++i) + object.setProperty(propertyName, value); + } +} +#endif + +void tst_QJSValue::defineStandardTestValues() +{ + newEngine(); + QTest::addColumn("val"); + QTest::newRow("bool") << m_engine->evaluate("true"); + QTest::newRow("number") << m_engine->evaluate("123"); + QTest::newRow("string") << m_engine->evaluate("'ciao'"); + QTest::newRow("null") << m_engine->evaluate("null"); + QTest::newRow("undefined") << m_engine->evaluate("undefined"); + QTest::newRow("object") << m_engine->evaluate("({foo:123})"); + QTest::newRow("array") << m_engine->evaluate("[10,20,30]"); + QTest::newRow("function") << m_engine->evaluate("(function foo(a, b, c) { return a + b + c; })"); + QTest::newRow("date") << m_engine->evaluate("new Date"); + QTest::newRow("regexp") << m_engine->evaluate("new RegExp('foo')"); + QTest::newRow("error") << m_engine->evaluate("new Error"); + + QTest::newRow("qobject") << m_engine->newQObject(this); +#if 0 // no qmetaobject + QTest::newRow("qmetaobject") << m_engine->newQMetaObject(&QJSEngine::staticMetaObject); +#endif + QTest::newRow("variant") << m_engine->toScriptValue(QPoint(10, 20)); +#if 0 // no classess + QTest::newRow("qscriptclassobject") << m_engine->newObject(new QJSClass(m_engine)); +#endif + + QTest::newRow("invalid") << QJSValue(); + QTest::newRow("bool-no-engine") << QJSValue(true); + QTest::newRow("number-no-engine") << QJSValue(123.0); + QTest::newRow("string-no-engine") << QJSValue(QString::fromLatin1("hello")); + QTest::newRow("null-no-engine") << QJSValue(QJSValue::NullValue); + QTest::newRow("undefined-no-engine") << QJSValue(QJSValue::UndefinedValue); +} + +QTEST_MAIN(tst_QJSValue) +#include "tst_qjsvalue.moc" diff --git a/tests/benchmarks/qml/js/qjsvalueiterator/qjsvalueiterator.pro b/tests/benchmarks/qml/js/qjsvalueiterator/qjsvalueiterator.pro new file mode 100644 index 0000000000..7601789ca9 --- /dev/null +++ b/tests/benchmarks/qml/js/qjsvalueiterator/qjsvalueiterator.pro @@ -0,0 +1,7 @@ +CONFIG += testcase +TEMPLATE = app +TARGET = tst_bench_qjsvalueiterator + +SOURCES += tst_qjsvalueiterator.cpp + +QT = core qml testlib diff --git a/tests/benchmarks/qml/js/qjsvalueiterator/tst_qjsvalueiterator.cpp b/tests/benchmarks/qml/js/qjsvalueiterator/tst_qjsvalueiterator.cpp new file mode 100644 index 0000000000..51c6cffd99 --- /dev/null +++ b/tests/benchmarks/qml/js/qjsvalueiterator/tst_qjsvalueiterator.cpp @@ -0,0 +1,309 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include +#include +#include + +class tst_QJSValueIterator : public QObject +{ + Q_OBJECT + +public: + tst_QJSValueIterator(); + virtual ~tst_QJSValueIterator(); + + void dataHelper(); + +private slots: + void init(); + void cleanup(); + + void hasNextAndNext(); + + void constructAndNext_data(); + void constructAndNext(); + + void name_data(); + void name(); +#if 0 // No string handle + void scriptName_data(); + void scriptName(); +#endif + + void value_data(); + void value(); +#if 0 // no setValue + void setValue_data(); + void setValue(); +#endif +#if 0 // no flags + void flags(); +#endif + +#if 0 // no array index + void iterateArrayAndConvertNameToIndex(); +#endif +#if 0 // no setValue + void iterateArrayAndDoubleElements(); +#endif +#if 0 // no remove + void iterateArrayAndRemoveAllElements(); +#endif +}; + +tst_QJSValueIterator::tst_QJSValueIterator() +{ +} + +tst_QJSValueIterator::~tst_QJSValueIterator() +{ +} + +void tst_QJSValueIterator::init() +{ +} + +void tst_QJSValueIterator::cleanup() +{ +} + +void tst_QJSValueIterator::dataHelper() +{ + QTest::addColumn("code"); + QTest::newRow("{ foo: 123 }") << QString::fromLatin1("({ foo: 123 })"); + QTest::newRow("Math") << QString::fromLatin1("Math"); + QTest::newRow("Array.prototype") << QString::fromLatin1("Array.prototype"); + QTest::newRow("Global Object") << QString::fromLatin1("this"); + QTest::newRow("['foo']") << QString::fromLatin1("['foo']"); + QTest::newRow("array with 1000 elements") + << QString::fromLatin1("(function() {" + " var a = new Array;" + " for (i = 0; i < 1000; ++i)" + " a[i] = i;" + " return a;" + "})()"); +} + +void tst_QJSValueIterator::hasNextAndNext() +{ + QJSEngine engine; + QJSValue object = engine.newObject(); + for (int i = 0; i < 2000; ++i) + object.setProperty(i, i); + QBENCHMARK { + for (int i = 0; i < 1000; ++i) { + QJSValueIterator it(object); + while (it.hasNext()) + it.next(); + } + } +} + +void tst_QJSValueIterator::constructAndNext_data() +{ + dataHelper(); +} + +void tst_QJSValueIterator::constructAndNext() +{ + QFETCH(QString, code); + QJSEngine engine; + QJSValue object = engine.evaluate(code); + Q_ASSERT(object.isObject()); + + QBENCHMARK { + for (int i = 0; i < 100; ++i) { + QJSValueIterator it(object); + it.next(); + } + } +} + +void tst_QJSValueIterator::name_data() +{ + dataHelper(); +} + +void tst_QJSValueIterator::name() +{ + QFETCH(QString, code); + QJSEngine engine; + QJSValue object = engine.evaluate(code); + Q_ASSERT(object.isObject()); + + QJSValueIterator it(object); + it.next(); + QBENCHMARK { + for (int i = 0; i < 200000; ++i) + it.name(); + } +} + +#if 0 +void tst_QJSValueIterator::scriptName_data() +{ + dataHelper(); +} + +void tst_QJSValueIterator::scriptName() +{ + QFETCH(QString, code); + QJSEngine engine; + QJSValue object = engine.evaluate(code); + Q_ASSERT(object.isObject()); + + QJSValueIterator it(object); + it.next(); + QBENCHMARK { + for (int i = 0; i < 50000; ++i) + it.scriptName(); + } +} +#endif + +void tst_QJSValueIterator::value_data() +{ + dataHelper(); +} + +void tst_QJSValueIterator::value() +{ + QFETCH(QString, code); + QJSEngine engine; + QJSValue object = engine.evaluate(code); + Q_ASSERT(object.isObject()); + + QJSValueIterator it(object); + it.next(); + QBENCHMARK { + for (int i = 0; i < 50000; ++i) + it.value(); + } +} + +#if 0 +void tst_QJSValueIterator::setValue_data() +{ + dataHelper(); +} + +void tst_QJSValueIterator::setValue() +{ + QFETCH(QString, code); + QJSEngine engine; + QJSValue object = engine.evaluate(code); + Q_ASSERT(object.isObject()); + + QJSValueIterator it(object); + it.next(); + QJSValue newValue(&engine, 456); + QBENCHMARK { + for (int i = 0; i < 50000; ++i) + it.setValue(newValue); + } +} + +void tst_QJSValueIterator::flags() +{ + QJSEngine engine; + QJSValue object = engine.newObject(); + QJSValue::PropertyFlags flags = flags; + object.setProperty("foo", 123, QJSValue::SkipInEnumeration | QJSValue::ReadOnly | QJSValue::Undeletable); + QJSValueIterator it(object); + it.next(); + QBENCHMARK { + for (int i = 0; i < 50000; ++i) + it.flags(); + } +} +#endif + +#if 0 +void tst_QJSValueIterator::iterateArrayAndConvertNameToIndex() +{ + QJSEngine engine; + QJSValue array = engine.newArray(); + for (int i = 0; i < 20000; ++i) + array.setProperty(i, i); + QBENCHMARK { + QJSValueIterator it(array); + while (it.hasNext()) { + it.next(); + it.scriptName().toArrayIndex(); + } + } +} + +void tst_QJSValueIterator::iterateArrayAndDoubleElements() +{ + QJSEngine engine; + QJSValue array = engine.newArray(); + for (int i = 0; i < 20000; ++i) + array.setProperty(i, i); + QBENCHMARK { + QJSValueIterator it(array); + while (it.hasNext()) { + it.next(); + it.setValue(QJSValue(&engine, it.value().toNumber() * 2)); + } + } +} + +void tst_QJSValueIterator::iterateArrayAndRemoveAllElements() +{ + QJSEngine engine; + QJSValue array = engine.newArray(); + for (int i = 0; i < 20000; ++i) + array.setProperty(i, i); + QBENCHMARK { + QJSValueIterator it(array); + while (it.hasNext()) { + it.next(); + it.remove(); + } + } +} +#endif + +QTEST_MAIN(tst_QJSValueIterator) +#include "tst_qjsvalueiterator.moc" diff --git a/tests/benchmarks/qml/painting/data/63x63.png b/tests/benchmarks/qml/painting/data/63x63.png new file mode 100644 index 0000000000..d9efda8a7a Binary files /dev/null and b/tests/benchmarks/qml/painting/data/63x63.png differ diff --git a/tests/benchmarks/qml/painting/data/63x63_opaque.png b/tests/benchmarks/qml/painting/data/63x63_opaque.png new file mode 100644 index 0000000000..d1429080db Binary files /dev/null and b/tests/benchmarks/qml/painting/data/63x63_opaque.png differ diff --git a/tests/benchmarks/qml/painting/data/64x64.png b/tests/benchmarks/qml/painting/data/64x64.png new file mode 100644 index 0000000000..b149f33c3d Binary files /dev/null and b/tests/benchmarks/qml/painting/data/64x64.png differ diff --git a/tests/benchmarks/qml/painting/data/64x64_opaque.png b/tests/benchmarks/qml/painting/data/64x64_opaque.png new file mode 100644 index 0000000000..94c07f3b3e Binary files /dev/null and b/tests/benchmarks/qml/painting/data/64x64_opaque.png differ diff --git a/tests/benchmarks/qml/painting/paintbenchmark.cpp b/tests/benchmarks/qml/painting/paintbenchmark.cpp new file mode 100644 index 0000000000..548a9269f6 --- /dev/null +++ b/tests/benchmarks/qml/painting/paintbenchmark.cpp @@ -0,0 +1,417 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +int iterations = 20; +const int count = 600; +const int lines = 12; +const int spacing = 36; +QSizeF size(1000, 800); +const qreal lineWidth = 1000; +QString strings[lines]; +QGLWidget *testWidget = 0; + +void paint_QTextLayout(QPainter &p, bool useCache) +{ + static bool first = true; + static QTextLayout *textLayout[lines]; + if (first) { + for (int i = 0; i < lines; ++i) { + textLayout[i] = new QTextLayout(strings[i]); + int leading = p.fontMetrics().leading(); + qreal height = 0; + qreal widthUsed = 0; + textLayout[i]->setCacheEnabled(useCache); + textLayout[i]->beginLayout(); + while (1) { + QTextLine line = textLayout[i]->createLine(); + if (!line.isValid()) + break; + + line.setLineWidth(lineWidth); + height += leading; + line.setPosition(QPointF(0, height)); + height += line.height(); + widthUsed = qMax(widthUsed, line.naturalTextWidth()); + } + textLayout[i]->endLayout(); + } + first = false; + } + for (int i = 0; i < count; ++i) { + for (int j = 0; j < lines; ++j) { + textLayout[j]->draw(&p, QPoint(0, j*spacing)); + } + } +} + +void paint_QTextLayout_noCache(QPainter &p) +{ + paint_QTextLayout(p, false); +} + +void paint_QTextLayout_cache(QPainter &p) +{ + paint_QTextLayout(p, true); +} + +void paint_QStaticText(QPainter &p, bool useOptimizations) +{ + static QStaticText *staticText[lines]; + static bool first = true; + if (first) { + for (int i = 0; i < lines; ++i) { + staticText[i] = new QStaticText(strings[i]); + if (useOptimizations) + staticText[i]->setPerformanceHint(QStaticText::AggressiveCaching); + else + staticText[i]->setPerformanceHint(QStaticText::ModerateCaching); + } + first = false; + } + for (int i = 0; i < count; ++i) { + for (int j = 0; j < lines; ++j) { + p.drawStaticText(QPointF(0, 30 + j*spacing), *staticText[j]); + } + } +} + +void paint_QStaticText_noOptimizations(QPainter &p) +{ + paint_QStaticText(p, false); +} + +void paint_QStaticText_optimizations(QPainter &p) +{ + paint_QStaticText(p, true); +} + +void paint_QPixmapCachedText(QPainter &p) +{ + static bool first = true; + static QPixmap cacheText[lines]; + if (first) { + for (int i = 0; i < lines; ++i) { + QRectF trueSize; + trueSize = p.boundingRect(QRectF(QPointF(0,0), size), 0, strings[i]); + cacheText[i] = QPixmap(trueSize.size().toSize()); + cacheText[i].fill(Qt::transparent); + QPainter paint(&cacheText[i]); + paint.setPen(Qt::black); + paint.drawText(QRectF(QPointF(0,0), trueSize.size().toSize()), strings[i]); + } + first = false; + } + for (int i = 0; i < count; i++) { + for (int j = 0; j < lines; ++j) { + p.drawPixmap(0,j*spacing,cacheText[j]); + } + } +} + +void paint_RoundedRect(QPainter &p) +{ + static bool first = true; + if (first) { + if (testWidget) { + QGLFormat format = testWidget->format(); + if (!format.sampleBuffers()) + qWarning() << "Cannot paint antialiased rounded rect without sampleBuffers"; + } + first = false; + } + p.setRenderHint(QPainter::Antialiasing, true); + p.setPen(Qt::black); + p.setBrush(Qt::red); + for (int i = 0; i < count; i++) { + for (int j = 0; j < lines; ++j) { + QSize size((j+1)*50, spacing-1); + p.drawRoundedRect(QRectF(QPointF(0,j*spacing), size), 8, 8); + } + } +} + +void paint_QPixmapCachedRoundedRect(QPainter &p) +{ + static bool first = true; + static QPixmap cacheRect; + if (first) { + const int pw = 0; + const int radius = 8; + cacheRect = QPixmap(radius*2 + 3 + pw*2, radius*2 + 3 + pw*2); + cacheRect.fill(Qt::transparent); + QPainter paint(&cacheRect); + paint.setRenderHint(QPainter::Antialiasing); + paint.setPen(Qt::black); + paint.setBrush(Qt::red); + if (pw%2) + paint.drawRoundedRect(QRectF(qreal(pw)/2+1, qreal(pw)/2+1, cacheRect.width()-(pw+1), cacheRect.height()-(pw+1)), radius, radius); + else + paint.drawRoundedRect(QRectF(qreal(pw)/2, qreal(pw)/2, cacheRect.width()-pw, cacheRect.height()-pw), radius, radius); + + first = false; + } + for (int i = 0; i < count; i++) { + for (int j = 0; j < lines; ++j) { + QSize size((j+1)*50, spacing-1); + + p.setRenderHints(QPainter::Antialiasing | QPainter::SmoothPixmapTransform, true); + + const int pw = 0; + + int xOffset = (cacheRect.width()-1)/2; + int yOffset = (cacheRect.height()-1)/2; + + QMargins margins(xOffset, yOffset, xOffset, yOffset); + QTileRules rules(Qt::StretchTile, Qt::StretchTile); + //NOTE: even though our item may have qreal-based width and height, qDrawBorderPixmap only supports QRects + qDrawBorderPixmap(&p, QRect(-pw/2, j*spacing-pw/2, size.width()+pw, size.height()+pw), margins, cacheRect, cacheRect.rect(), margins, rules); + } + } +} + +void paint_pathCacheRoundedRect(QPainter &p) +{ + static bool first = true; + static QPainterPath path[lines]; + if (first) { + for (int j = 0; j < lines; ++j) { + path[j].addRoundedRect(QRectF(0,0,(j+1)*50, spacing-1), 8, 8); + } + first = false; + } + p.setRenderHint(QPainter::Antialiasing, true); + p.setPen(Qt::black); + p.setBrush(Qt::red); + for (int i = 0; i < count; i++) { + for (int j = 0; j < lines; ++j) { + p.translate(0,j*spacing); + p.drawPath(path[j]); + p.translate(0,-j*spacing); + } + } +} + +void paint_QPixmap63x63_opaque(QPainter &p) +{ + static bool first = true; + static QPixmap pm; + if (first) { + pm.load("data/63x63_opaque.png"); + first = false; + } + for (int i = 0; i < count; i++) { + for (int j = 0; j < lines; ++j) { + p.drawPixmap((i%10) * 64,j*spacing, pm); + } + } +} + +void paint_QPixmap64x64_opaque(QPainter &p) +{ + static bool first = true; + static QPixmap pm; + if (first) { + pm.load("data/64x64_opaque.png"); + first = false; + } + for (int i = 0; i < count; i++) { + for (int j = 0; j < lines; ++j) { + p.drawPixmap((i%10) * 64,j*spacing, pm); + } + } +} + +void paint_QPixmap63x63(QPainter &p) +{ + static bool first = true; + static QPixmap pm; + if (first) { + pm.load("data/63x63.png"); + first = false; + } + for (int i = 0; i < count; i++) { + for (int j = 0; j < lines; ++j) { + p.drawPixmap((i%10) * 64,j*spacing, pm); + } + } +} + +void paint_QPixmap64x64(QPainter &p) +{ + static bool first = true; + static QPixmap pm; + if (first) { + pm.load("data/64x64.png"); + first = false; + } + for (int i = 0; i < count; i++) { + for (int j = 0; j < lines; ++j) { + p.drawPixmap((i%10) * 64,j*spacing, pm); + } + } +} +typedef void(*PaintFunc)(QPainter &); + +struct { + const char *name; + PaintFunc func; +} funcs[] = { + { "QTextLayoutNoCache", &paint_QTextLayout_noCache }, + { "QTextLayoutWithCache", &paint_QTextLayout_cache }, + { "QStaticTextNoBackendOptimizations", &paint_QStaticText_noOptimizations }, + { "QStaticTextWithBackendOptimizations", &paint_QStaticText_optimizations }, + { "CachedText", &paint_QPixmapCachedText }, + { "RoundedRect", &paint_RoundedRect }, + { "CachedRoundedRect", &paint_QPixmapCachedRoundedRect }, + { "PathCacheRoundedRect", &paint_pathCacheRoundedRect }, + { "QPixmap63x63_opaque", &paint_QPixmap63x63_opaque }, + { "QPixmap64x64_opaque", &paint_QPixmap64x64_opaque }, + { "QPixmap63x63", &paint_QPixmap63x63 }, + { "QPixmap64x64", &paint_QPixmap64x64 }, + { 0, 0 } +}; + +PaintFunc testFunc = 0; + +class MyGLWidget : public QGLWidget +{ +public: + MyGLWidget(const QGLFormat &format) : QGLWidget(format), frames(0) { + const char chars[] = "abcd efgh ijkl mnop qrst uvwx yz!$. ABCD 1234"; + int len = strlen(chars); + for (int i = 0; i < lines; ++i) { + for (int j = 0; j < 60; j++) { + strings[i] += QChar(chars[rand() % len]); + } + } + } + + void paintEvent(QPaintEvent *) { + static int last = 0; + static bool firstRun = true; + if (firstRun) { + timer.start(); + firstRun = false; + } else { + int elapsed = timer.elapsed(); + qDebug() << "frame elapsed:" << elapsed - last; + last = elapsed; + } + QPainter p(this); + p.fillRect(rect(), Qt::white); + p.setPen(Qt::black); + QTime drawTimer; + drawTimer.start(); + testFunc(p); + qDebug() << "draw time" << drawTimer.elapsed(); + if (iterations--) + update(); + else + qApp->quit(); + } + + QTime timer; + int frames; +}; + +int main(int argc, char *argv[]) +{ + QApplication app(argc, argv); + + bool sampleBuffers = false; + + for (int i = 1; i < argc; ++i) { + QString arg = argv[i]; + if (arg == "-test") { + arg = argv[++i]; + int j = 0; + while (funcs[j].name) { + if (arg == funcs[j].name) { + testFunc = funcs[j].func; + qDebug() << "Running test" << arg; + break; + } + ++j; + } + } else if (arg == "-iterations") { + arg = argv[++i]; + iterations = arg.toInt(); + } else if (arg == "-sampleBuffers") { + sampleBuffers = true; + } + } + + if (testFunc == 0) { + qDebug() << "Usage: textspeed -test [-sampleBuffers] [-iterations n]"; + qDebug() << "where can be:"; + int j = 0; + while (funcs[j].name) { + qDebug() << " " << funcs[j].name; + ++j; + } + exit(1); + } + + QWidget w; + QGLFormat format = QGLFormat::defaultFormat(); + format.setSampleBuffers(sampleBuffers); + testWidget = new MyGLWidget(format); + testWidget->setAutoFillBackground(false); + QVBoxLayout *layout = new QVBoxLayout(&w); + w.setLayout(layout); + layout->addWidget(testWidget); + w.showFullScreen(); + app.exec(); + + return 0; +} diff --git a/tests/benchmarks/qml/painting/painting.pro b/tests/benchmarks/qml/painting/painting.pro new file mode 100644 index 0000000000..ff85b5f5f2 --- /dev/null +++ b/tests/benchmarks/qml/painting/painting.pro @@ -0,0 +1,7 @@ +requires(contains(QT_CONFIG,opengl)) + +QT += opengl +CONFIG += console +macx:CONFIG -= app_bundle + +SOURCES += paintbenchmark.cpp diff --git a/tests/benchmarks/qml/pointers/pointers.pro b/tests/benchmarks/qml/pointers/pointers.pro new file mode 100644 index 0000000000..d2f9729a14 --- /dev/null +++ b/tests/benchmarks/qml/pointers/pointers.pro @@ -0,0 +1,8 @@ +CONFIG += testcase +QT += qml testlib +TEMPLATE = app +TARGET = tst_pointers +macx:CONFIG -= app_bundle + +SOURCES += tst_pointers.cpp + diff --git a/tests/benchmarks/qml/pointers/tst_pointers.cpp b/tests/benchmarks/qml/pointers/tst_pointers.cpp new file mode 100644 index 0000000000..d65376460a --- /dev/null +++ b/tests/benchmarks/qml/pointers/tst_pointers.cpp @@ -0,0 +1,77 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include "private/qqmlguard_p.h" +#include + +class tst_pointers : public QObject +{ + Q_OBJECT + +public: + tst_pointers() {} + +private slots: + void qmlguard(); + void weakPointer(); +}; + +void tst_pointers::qmlguard() +{ + QObject *obj = new QObject; + QBENCHMARK { + QQmlGuard guardedObject; + guardedObject = obj; + } +} + +void tst_pointers::weakPointer() +{ + QObject *obj = new QObject; + QBENCHMARK { + QWeakPointer guardedObject; + guardedObject = obj; + } +} + +QTEST_MAIN(tst_pointers) +#include "tst_pointers.moc" diff --git a/tests/benchmarks/qml/qml.pro b/tests/benchmarks/qml/qml.pro new file mode 100644 index 0000000000..7a75c69dd1 --- /dev/null +++ b/tests/benchmarks/qml/qml.pro @@ -0,0 +1,18 @@ +TEMPLATE = subdirs + +SUBDIRS += \ + binding \ + creation \ + javascript \ + holistic \ + pointers \ + qqmlcomponent \ + qqmlimage \ + qqmlmetaproperty \ + script \ + qmltime \ + js + +contains(QT_CONFIG, opengl): SUBDIRS += painting + +include(../trusted-benchmarks.pri) diff --git a/tests/benchmarks/qml/qmltime/example.qml b/tests/benchmarks/qml/qmltime/example.qml new file mode 100644 index 0000000000..66c4fdacaa --- /dev/null +++ b/tests/benchmarks/qml/qmltime/example.qml @@ -0,0 +1,55 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtQml module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import QmlTime 1.0 as QmlTime + +Item { + + property string name: "Bob Smith" + + QmlTime.Timer { + component: Item { + Text { text: name } + } + } +} + diff --git a/tests/benchmarks/qml/qmltime/qmltime.cpp b/tests/benchmarks/qml/qmltime/qmltime.cpp new file mode 100644 index 0000000000..7bca7e6544 --- /dev/null +++ b/tests/benchmarks/qml/qmltime/qmltime.cpp @@ -0,0 +1,283 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include +#include +#include +#include +#include +#include +#include +#include + +class Timer : public QObject +{ + Q_OBJECT + Q_PROPERTY(QQmlComponent *component READ component WRITE setComponent) + +public: + Timer(); + + QQmlComponent *component() const; + void setComponent(QQmlComponent *); + + static Timer *timerInstance(); + + void run(uint); + + bool willParent() const; + void setWillParent(bool p); + +private: + void runTest(QQmlContext *, uint); + + QQmlComponent *m_component; + static Timer *m_timer; + + bool m_willparent; + QGraphicsScene m_scene; + QGraphicsRectItem m_item; +}; +QML_DECLARE_TYPE(Timer); + +Timer *Timer::m_timer = 0; + +Timer::Timer() +: m_component(0), m_willparent(false) +{ + if (m_timer) + qWarning("Timer: Timer already registered"); + m_timer = this; + + m_scene.setItemIndexMethod(QGraphicsScene::NoIndex); + m_scene.addItem(&m_item); +} + +QQmlComponent *Timer::component() const +{ + return m_component; +} + +void Timer::setComponent(QQmlComponent *c) +{ + m_component = c; +} + +Timer *Timer::timerInstance() +{ + return m_timer; +} + +void Timer::run(uint iterations) +{ + QQmlContext context(qmlContext(this)); + + QObject *o = m_component->create(&context); + QGraphicsObject *go = qobject_cast(o); + if (m_willparent && go) + go->setParentItem(&m_item); + delete o; + + runTest(&context, iterations); +} + +bool Timer::willParent() const +{ + return m_willparent; +} + +void Timer::setWillParent(bool p) +{ + m_willparent = p; +} + +void Timer::runTest(QQmlContext *context, uint iterations) +{ + QTime t; + t.start(); + for (uint ii = 0; ii < iterations; ++ii) { + QObject *o = m_component->create(context); + QGraphicsObject *go = qobject_cast(o); + if (m_willparent && go) + go->setParentItem(&m_item); + delete o; + } + + int e = t.elapsed(); + + qWarning() << "Total:" << e << "ms, Per iteration:" << qreal(e) / qreal(iterations) << "ms"; + +} + +void usage(const char *name) +{ + qWarning("Usage: %s [-iterations ] [-parent] \n", name); + + qWarning("qmltime is a tool for benchmarking the runtime cost of instantiating\n" + "a QML component. It is typically run as follows:\n" + "\n" + "%s path/to/benchmark.qml\n" + "\n" + "If the -parent option is specified, the component being measured will also\n" + "be parented to an item already in the scene.\n" + "\n" + "If the -iterations option is specified, the benchmark will run the specified\n" + "number of iterations. If -iterations is not specified, 1024 iterations\n" + "are performed.\n" + "\n" + "qmltime expects the file to be benchmarked to contain a certain structure.\n" + "Specifically, it requires the presence of a QmlTime.Timer element. For example,\n" + "say we wanted to benchmark the following list delegate:\n" + "\n" + "Rectangle {\n" + " color: \"green\"\n" + " width: 400; height: 100\n" + " Text {\n" + " anchors.centerIn: parent\n" + " text: name\n" + " }\n" + "}\n" + "\n" + "we would create a benchmark file that looks like this:\n" + "\n" + "import QtQuick 2.0\n" + "import QmlTime 1.0 as QmlTime\n" + "\n" + "Item {\n" + "\n" + " property string name: \"Bob Smith\"\n" + "\n" + " QmlTime.Timer {\n" + " component: Rectangle {\n" + " color: \"green\"\n" + " width: 400; height: 100\n" + " Text {\n" + " anchors.centerIn: parent\n" + " text: name\n" + " }\n" + " }\n" + " }\n" + "}\n" + "\n" + "The outer Item functions as a dummy data provider for any additional\n" + "data required by the bindings in the component being benchmarked (in the\n" + "example above we provide a \"name\" property).\n" + "\n" + "When started, the component is instantiated once before running\n" + "the benchmark, which means that the reported time does not include\n" + "compile time (as the results of compilation are cached internally).\n" + "In this sense the times reported by qmltime best correspond to the\n" + "costs associated with delegate creation in the view classes, where the\n" + "same delegate is instantiated over and over. Conversely, it is not a\n" + "good approximation for e.g. Loader, which typically only instantiates\n" + "an element once (and so for Loader the compile time is very relevant\n" + "to the overall cost).", name); + + exit(-1); +} + +int main(int argc, char ** argv) +{ + QApplication app(argc, argv); + + qmlRegisterType("QmlTime", 1, 0, "Timer"); + + uint iterations = 1024; + QString filename; + bool willParent = false; + + for (int ii = 1; ii < argc; ++ii) { + QByteArray arg(argv[ii]); + + if (arg == "-iterations") { + if (ii + 1 < argc) { + ++ii; + QByteArray its(argv[ii]); + bool ok = false; + iterations = its.toUInt(&ok); + if (!ok) + usage(argv[0]); + } else { + usage(argv[0]); + } + } else if (arg == "-parent") { + willParent = true; + } else if (arg == "-help") { + usage(argv[0]); + } else { + filename = QLatin1String(argv[ii]); + } + } + + if (filename.isEmpty()) + usage(argv[0]); + + QQmlEngine engine; + QQmlComponent component(&engine, filename); + if (component.isError()) { + qWarning() << component.errors(); + return -1; + } + + QObject *obj = component.create(); + if (!obj) { + qWarning() << component.errors(); + return -1; + } + + Timer *timer = Timer::timerInstance(); + if (!timer) { + qWarning() << "A Tester.Timer instance is required."; + return -1; + } + + timer->setWillParent(willParent); + + if (!timer->component()) { + qWarning() << "The timer has no component"; + return -1; + } + + timer->run(iterations); + + return 0; +} + +#include "qmltime.moc" diff --git a/tests/benchmarks/qml/qmltime/qmltime.pro b/tests/benchmarks/qml/qmltime/qmltime.pro new file mode 100644 index 0000000000..6cc6d13b34 --- /dev/null +++ b/tests/benchmarks/qml/qmltime/qmltime.pro @@ -0,0 +1,8 @@ +CONFIG += testcase +TEMPLATE = app +TARGET = qmltime +QT += qml widgets testlib +macx:CONFIG -= app_bundle + +SOURCES += qmltime.cpp + diff --git a/tests/benchmarks/qml/qmltime/tests/anchors/empty.qml b/tests/benchmarks/qml/qmltime/tests/anchors/empty.qml new file mode 100644 index 0000000000..6ecfb3d48f --- /dev/null +++ b/tests/benchmarks/qml/qmltime/tests/anchors/empty.qml @@ -0,0 +1,75 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtQml module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import QmlTime 1.0 as QmlTime + +Item { + + QmlTime.Timer { + component: Component { + Item { + Item { + anchors.leftMargin: 0 + } + Item { + anchors.leftMargin: 0 + } + Item { + anchors.leftMargin: 0 + } + Item { + anchors.leftMargin: 0 + } + Item { + anchors.leftMargin: 0 + } + Item { + anchors.leftMargin: 0 + } + Item { + anchors.leftMargin: 0 + } + } + } + } +} + diff --git a/tests/benchmarks/qml/qmltime/tests/anchors/fill.qml b/tests/benchmarks/qml/qmltime/tests/anchors/fill.qml new file mode 100644 index 0000000000..c2e3b3decb --- /dev/null +++ b/tests/benchmarks/qml/qmltime/tests/anchors/fill.qml @@ -0,0 +1,82 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtQml module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import QmlTime 1.0 as QmlTime + +Item { + + QmlTime.Timer { + component: Component { + Item { + Item { + anchors.fill: parent + anchors.leftMargin: 0 + } + Item { + anchors.fill: parent + anchors.leftMargin: 0 + } + Item { + anchors.fill: parent + anchors.leftMargin: 0 + } + Item { + anchors.fill: parent + anchors.leftMargin: 0 + } + Item { + anchors.fill: parent + anchors.leftMargin: 0 + } + Item { + anchors.fill: parent + anchors.leftMargin: 0 + } + Item { + anchors.fill: parent + anchors.leftMargin: 0 + } + } + } + } +} + diff --git a/tests/benchmarks/qml/qmltime/tests/anchors/null.qml b/tests/benchmarks/qml/qmltime/tests/anchors/null.qml new file mode 100644 index 0000000000..677281f162 --- /dev/null +++ b/tests/benchmarks/qml/qmltime/tests/anchors/null.qml @@ -0,0 +1,68 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtQml module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import QmlTime 1.0 as QmlTime + +Item { + + QmlTime.Timer { + component: Component { + Item { + Item { + } + Item { + } + Item { + } + Item { + } + Item { + } + Item { + } + Item { + } + } + } + } +} + diff --git a/tests/benchmarks/qml/qmltime/tests/animation/large.qml b/tests/benchmarks/qml/qmltime/tests/animation/large.qml new file mode 100644 index 0000000000..16aad5c9ec --- /dev/null +++ b/tests/benchmarks/qml/qmltime/tests/animation/large.qml @@ -0,0 +1,82 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtQml module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import QmlTime 1.0 as QmlTime + +Item { + + QmlTime.Timer { + component: Component { + ParallelAnimation { + NumberAnimation { duration: 500 } + NumberAnimation { duration: 4000; } + NumberAnimation { duration: 2000; easing.type: "OutBack"} + ColorAnimation { duration: 3000} + SequentialAnimation { + PauseAnimation { duration: 1000 } + ScriptAction { script: doSomething(); } + PauseAnimation { duration: 800 } + ScriptAction { script: doSomethingElse(); } + PauseAnimation { duration: 800 } + ParallelAnimation { + NumberAnimation { duration: 200;} + SequentialAnimation { + PauseAnimation { duration: 200} + ParallelAnimation { + NumberAnimation { duration: 300;} + NumberAnimation { duration: 300;} + } + NumberAnimation { from: 0; to: 1; duration: 500 } + PauseAnimation { duration: 200 } + NumberAnimation { from: 1; to: 0; duration: 500 } + } + SequentialAnimation { + PauseAnimation { duration: 150} + NumberAnimation { duration: 300; easing.type: "OutBounce" } + } + } + } + } + } + } + +} diff --git a/tests/benchmarks/qml/qmltime/tests/animation/largeNoProps.qml b/tests/benchmarks/qml/qmltime/tests/animation/largeNoProps.qml new file mode 100644 index 0000000000..5538182646 --- /dev/null +++ b/tests/benchmarks/qml/qmltime/tests/animation/largeNoProps.qml @@ -0,0 +1,82 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtQml module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import QmlTime 1.0 as QmlTime + +Item { + + QmlTime.Timer { + component: Component { + ParallelAnimation { + NumberAnimation { } + NumberAnimation { } + NumberAnimation { } + ColorAnimation { } + SequentialAnimation { + PauseAnimation { } + ScriptAction { } + PauseAnimation { } + ScriptAction { } + PauseAnimation { } + ParallelAnimation { + NumberAnimation { } + SequentialAnimation { + PauseAnimation { } + ParallelAnimation { + NumberAnimation { } + NumberAnimation { } + } + NumberAnimation { } + PauseAnimation { } + NumberAnimation { } + } + SequentialAnimation { + PauseAnimation { } + NumberAnimation { } + } + } + } + } + } + } + +} diff --git a/tests/benchmarks/qml/qmltime/tests/item_creation/children.qml b/tests/benchmarks/qml/qmltime/tests/item_creation/children.qml new file mode 100644 index 0000000000..4677bb6e72 --- /dev/null +++ b/tests/benchmarks/qml/qmltime/tests/item_creation/children.qml @@ -0,0 +1,75 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtQml module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import QmlTime 1.0 as QmlTime + +Item { + + QmlTime.Timer { + component: Component { + Item { + children: [ + Rectangle { }, + Rectangle { }, + Item { }, + Image { }, + Text { }, + Item { }, + Item { }, + Image { }, + Image { }, + Row { }, + Image { }, + Image { }, + Column { }, + Row { }, + Text { }, + Text { }, + Text { }, + MouseArea { } + ] + + } + } + } + +} diff --git a/tests/benchmarks/qml/qmltime/tests/item_creation/data.qml b/tests/benchmarks/qml/qmltime/tests/item_creation/data.qml new file mode 100644 index 0000000000..af54e9c9e9 --- /dev/null +++ b/tests/benchmarks/qml/qmltime/tests/item_creation/data.qml @@ -0,0 +1,75 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtQml module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import QmlTime 1.0 as QmlTime + +Item { + + QmlTime.Timer { + component: Component { + Item { + data: [ + Rectangle { }, + Rectangle { }, + Item { }, + Image { }, + Text { }, + Item { }, + Item { }, + Image { }, + Image { }, + Row { }, + Image { }, + Image { }, + Column { }, + Row { }, + Text { }, + Text { }, + Text { }, + MouseArea { } + ] + + } + } + } + +} diff --git a/tests/benchmarks/qml/qmltime/tests/item_creation/no_creation.qml b/tests/benchmarks/qml/qmltime/tests/item_creation/no_creation.qml new file mode 100644 index 0000000000..87d61b810e --- /dev/null +++ b/tests/benchmarks/qml/qmltime/tests/item_creation/no_creation.qml @@ -0,0 +1,53 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtQml module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import QmlTime 1.0 as QmlTime + +Item { + + QmlTime.Timer { + component: Component { + Item { + } + } + } +} diff --git a/tests/benchmarks/qml/qmltime/tests/item_creation/resources.qml b/tests/benchmarks/qml/qmltime/tests/item_creation/resources.qml new file mode 100644 index 0000000000..029f782ef5 --- /dev/null +++ b/tests/benchmarks/qml/qmltime/tests/item_creation/resources.qml @@ -0,0 +1,75 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtQml module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import QmlTime 1.0 as QmlTime + +Item { + + QmlTime.Timer { + component: Component { + Item { + resources: [ + Rectangle { }, + Rectangle { }, + Item { }, + Image { }, + Text { }, + Item { }, + Item { }, + Image { }, + Image { }, + Row { }, + Image { }, + Image { }, + Column { }, + Row { }, + Text { }, + Text { }, + Text { }, + MouseArea { } + ] + + } + } + } + +} diff --git a/tests/benchmarks/qml/qmltime/tests/loader/Loaded.qml b/tests/benchmarks/qml/qmltime/tests/loader/Loaded.qml new file mode 100644 index 0000000000..1310115c43 --- /dev/null +++ b/tests/benchmarks/qml/qmltime/tests/loader/Loaded.qml @@ -0,0 +1,48 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtQml module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Item { + Rectangle {} + Text {} + Image {} +} diff --git a/tests/benchmarks/qml/qmltime/tests/loader/component_loader.qml b/tests/benchmarks/qml/qmltime/tests/loader/component_loader.qml new file mode 100644 index 0000000000..bed709991e --- /dev/null +++ b/tests/benchmarks/qml/qmltime/tests/loader/component_loader.qml @@ -0,0 +1,57 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtQml module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import QmlTime 1.0 as QmlTime + +Item { + + QmlTime.Timer { + component: Component { + Item { + Loader { + sourceComponent: Loaded {} + } + } + } + } +} + diff --git a/tests/benchmarks/qml/qmltime/tests/loader/empty_loader.qml b/tests/benchmarks/qml/qmltime/tests/loader/empty_loader.qml new file mode 100644 index 0000000000..a25cbb8f45 --- /dev/null +++ b/tests/benchmarks/qml/qmltime/tests/loader/empty_loader.qml @@ -0,0 +1,56 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtQml module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import QmlTime 1.0 as QmlTime + +Item { + + QmlTime.Timer { + component: Component { + Item { + Loader {} + Loaded {} + } + } + } +} + diff --git a/tests/benchmarks/qml/qmltime/tests/loader/no_loader.qml b/tests/benchmarks/qml/qmltime/tests/loader/no_loader.qml new file mode 100644 index 0000000000..ae2ad3e60e --- /dev/null +++ b/tests/benchmarks/qml/qmltime/tests/loader/no_loader.qml @@ -0,0 +1,55 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtQml module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import QmlTime 1.0 as QmlTime + +Item { + + QmlTime.Timer { + component: Component { + Item { + Loaded {} + } + } + } +} + diff --git a/tests/benchmarks/qml/qmltime/tests/loader/source_loader.qml b/tests/benchmarks/qml/qmltime/tests/loader/source_loader.qml new file mode 100644 index 0000000000..a077f448d5 --- /dev/null +++ b/tests/benchmarks/qml/qmltime/tests/loader/source_loader.qml @@ -0,0 +1,57 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtQml module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import QmlTime 1.0 as QmlTime + +Item { + + QmlTime.Timer { + component: Component { + Item { + Loader { + source: "Loaded.qml" + } + } + } + } +} + diff --git a/tests/benchmarks/qml/qmltime/tests/positioner_creation/no_positioner.qml b/tests/benchmarks/qml/qmltime/tests/positioner_creation/no_positioner.qml new file mode 100644 index 0000000000..0377a8e1a2 --- /dev/null +++ b/tests/benchmarks/qml/qmltime/tests/positioner_creation/no_positioner.qml @@ -0,0 +1,78 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtQml module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import QmlTime 1.0 as QmlTime + +Item { + QmlTime.Timer { + component: Component { + Item { + Rectangle { } + Rectangle { } + Item { + Image { } + Text { } + } + + Item { + Item { + Image { } + Image { } + Item { + Image { } + Image { } + } + } + + Item { + Item { + Text { } + Text { } + } + Text { } + } + } + MouseArea { } + } + } + } +} diff --git a/tests/benchmarks/qml/qmltime/tests/positioner_creation/null_positioner.qml b/tests/benchmarks/qml/qmltime/tests/positioner_creation/null_positioner.qml new file mode 100644 index 0000000000..e9fc2c06ec --- /dev/null +++ b/tests/benchmarks/qml/qmltime/tests/positioner_creation/null_positioner.qml @@ -0,0 +1,75 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtQml module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import QmlTime 1.0 as QmlTime + +Item { + QmlTime.Timer { + component: Component { + Item { + Rectangle { } + Rectangle { } + Item { + Image { } + Text { } + } + + Item { + Item { + Image { } + Image { } + Row { } + Image { } + Image { } + } + + Column { } + Row { } + Text { } + Text { } + Text { } + } + MouseArea { } + } + } + } +} diff --git a/tests/benchmarks/qml/qmltime/tests/positioner_creation/positioner.qml b/tests/benchmarks/qml/qmltime/tests/positioner_creation/positioner.qml new file mode 100644 index 0000000000..3a5daec0a5 --- /dev/null +++ b/tests/benchmarks/qml/qmltime/tests/positioner_creation/positioner.qml @@ -0,0 +1,78 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtQml module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import QmlTime 1.0 as QmlTime + +Item { + QmlTime.Timer { + component: Component { + Item { + Rectangle { } + Rectangle { } + Item { + Image { } + Text { } + } + + Item { + Item { + Image { } + Image { } + Row { + Image { } + Image { } + } + } + + Column { + Row { + Text { } + Text { } + } + Text { } + } + } + MouseArea { } + } + } + } +} diff --git a/tests/benchmarks/qml/qmltime/tests/vmemetaobject/null.qml b/tests/benchmarks/qml/qmltime/tests/vmemetaobject/null.qml new file mode 100644 index 0000000000..c283261dd5 --- /dev/null +++ b/tests/benchmarks/qml/qmltime/tests/vmemetaobject/null.qml @@ -0,0 +1,54 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtQml module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import QmlTime 1.0 as QmlTime + +Item { + + QmlTime.Timer { + component: Component { + QtObject { + } + } + } + +} diff --git a/tests/benchmarks/qml/qmltime/tests/vmemetaobject/property.qml b/tests/benchmarks/qml/qmltime/tests/vmemetaobject/property.qml new file mode 100644 index 0000000000..4722150d98 --- /dev/null +++ b/tests/benchmarks/qml/qmltime/tests/vmemetaobject/property.qml @@ -0,0 +1,59 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtQml module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import QmlTime 1.0 as QmlTime + +Item { + + QmlTime.Timer { + component: Component { + QtObject { + property string s + property string s2 + property string s3 + property string s4 + } + } + } + +} + diff --git a/tests/benchmarks/qml/qqmlcomponent/data/myqmlobject.qml b/tests/benchmarks/qml/qqmlcomponent/data/myqmlobject.qml new file mode 100644 index 0000000000..4c7e48fc7c --- /dev/null +++ b/tests/benchmarks/qml/qqmlcomponent/data/myqmlobject.qml @@ -0,0 +1,44 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtQml module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import Qt.test 4.6 + +MyQmlObject {} diff --git a/tests/benchmarks/qml/qqmlcomponent/data/myqmlobject_binding.qml b/tests/benchmarks/qml/qqmlcomponent/data/myqmlobject_binding.qml new file mode 100644 index 0000000000..918f93c30e --- /dev/null +++ b/tests/benchmarks/qml/qqmlcomponent/data/myqmlobject_binding.qml @@ -0,0 +1,47 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtQml module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import Qt.test 4.6 + +MyQmlObject { + result: value +} + diff --git a/tests/benchmarks/qml/qqmlcomponent/data/object.qml b/tests/benchmarks/qml/qqmlcomponent/data/object.qml new file mode 100644 index 0000000000..726871b8ea --- /dev/null +++ b/tests/benchmarks/qml/qqmlcomponent/data/object.qml @@ -0,0 +1,44 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtQml module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +QtObject {} diff --git a/tests/benchmarks/qml/qqmlcomponent/data/object_id.qml b/tests/benchmarks/qml/qqmlcomponent/data/object_id.qml new file mode 100644 index 0000000000..eb99567717 --- /dev/null +++ b/tests/benchmarks/qml/qqmlcomponent/data/object_id.qml @@ -0,0 +1,47 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtQml module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +QtObject { + id: blah +} + diff --git a/tests/benchmarks/qml/qqmlcomponent/data/samegame/BoomBlock.qml b/tests/benchmarks/qml/qqmlcomponent/data/samegame/BoomBlock.qml new file mode 100644 index 0000000000..5678fa400e --- /dev/null +++ b/tests/benchmarks/qml/qqmlcomponent/data/samegame/BoomBlock.qml @@ -0,0 +1,112 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtQml module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import QtQuick.Particles 2.0 + +Item { + id: block + property bool dying: false + property bool spawned: false + property int type: 0 + property ParticleSystem particleSystem + + Behavior on x { + enabled: spawned; + SpringAnimation{ spring: 2; damping: 0.2 } + } + Behavior on y { + SpringAnimation{ spring: 2; damping: 0.2 } + } + + Image { + id: img + source: { + if(type == 0){ + "pics/redStone.png"; + } else if(type == 1) { + "pics/blueStone.png"; + } else { + "pics/greenStone.png"; + } + } + opacity: 0 + Behavior on opacity { NumberAnimation { duration: 200 } } + anchors.fill: parent + } + Emitter { + id: particles + system: particleSystem + group: { + if(type == 0){ + "red"; + } else if (type == 1) { + "blue"; + } else { + "green"; + } + } + anchors.fill: parent + + speed: TargetDirection{targetX: block.width/2; targetY: block.height/2; magnitude: -60; magnitudeVariation: 60} + shape: EllipseShape{fill:true} + enabled: false; + lifeSpan: 700; lifeSpanVariation: 100 + emitRate: 1000 + maximumEmitted: 100 //only fires 0.1s bursts (still 2x old number) + size: 28 + endSize: 14 + } + + states: [ + State { + name: "AliveState"; when: spawned == true && dying == false + PropertyChanges { target: img; opacity: 1 } + }, + + State { + name: "DeathState"; when: dying == true + StateChangeScript { script: particles.pulse(0.1); } + PropertyChanges { target: img; opacity: 0 } + StateChangeScript { script: block.destroy(1000); } + } + ] +} diff --git a/tests/benchmarks/qml/qqmlcomponent/data/samegame/pics/blueStone.png b/tests/benchmarks/qml/qqmlcomponent/data/samegame/pics/blueStone.png new file mode 100644 index 0000000000..20e43c75b6 Binary files /dev/null and b/tests/benchmarks/qml/qqmlcomponent/data/samegame/pics/blueStone.png differ diff --git a/tests/benchmarks/qml/qqmlcomponent/data/samegame/pics/greenStone.png b/tests/benchmarks/qml/qqmlcomponent/data/samegame/pics/greenStone.png new file mode 100644 index 0000000000..b568a1900c Binary files /dev/null and b/tests/benchmarks/qml/qqmlcomponent/data/samegame/pics/greenStone.png differ diff --git a/tests/benchmarks/qml/qqmlcomponent/data/samegame/pics/redStone.png b/tests/benchmarks/qml/qqmlcomponent/data/samegame/pics/redStone.png new file mode 100644 index 0000000000..36b09a2686 Binary files /dev/null and b/tests/benchmarks/qml/qqmlcomponent/data/samegame/pics/redStone.png differ diff --git a/tests/benchmarks/qml/qqmlcomponent/data/samegame/pics/yellowStone.png b/tests/benchmarks/qml/qqmlcomponent/data/samegame/pics/yellowStone.png new file mode 100644 index 0000000000..b1ce76212c Binary files /dev/null and b/tests/benchmarks/qml/qqmlcomponent/data/samegame/pics/yellowStone.png differ diff --git a/tests/benchmarks/qml/qqmlcomponent/data/synthesized_properties.2.qml b/tests/benchmarks/qml/qqmlcomponent/data/synthesized_properties.2.qml new file mode 100644 index 0000000000..ec987defb3 --- /dev/null +++ b/tests/benchmarks/qml/qqmlcomponent/data/synthesized_properties.2.qml @@ -0,0 +1,56 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtQml module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +QtObject { + property int a + property bool b + property double c + property real d + property string e + property url f + property color g + property date h + property variant i + property variant j +} + diff --git a/tests/benchmarks/qml/qqmlcomponent/data/synthesized_properties.qml b/tests/benchmarks/qml/qqmlcomponent/data/synthesized_properties.qml new file mode 100644 index 0000000000..397efae5f8 --- /dev/null +++ b/tests/benchmarks/qml/qqmlcomponent/data/synthesized_properties.qml @@ -0,0 +1,46 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtQml module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +QtObject { + property int a +} diff --git a/tests/benchmarks/qml/qqmlcomponent/qqmlcomponent.pro b/tests/benchmarks/qml/qqmlcomponent/qqmlcomponent.pro new file mode 100644 index 0000000000..ba41f5a95b --- /dev/null +++ b/tests/benchmarks/qml/qqmlcomponent/qqmlcomponent.pro @@ -0,0 +1,11 @@ +CONFIG += testcase +TEMPLATE = app +TARGET = tst_qqmlcomponent +QT += qml testlib +macx:CONFIG -= app_bundle + +SOURCES += tst_qqmlcomponent.cpp testtypes.cpp +HEADERS += testtypes.h + +# Define SRCDIR equal to test's source directory +DEFINES += SRCDIR=\\\"$$PWD\\\" diff --git a/tests/benchmarks/qml/qqmlcomponent/testtypes.cpp b/tests/benchmarks/qml/qqmlcomponent/testtypes.cpp new file mode 100644 index 0000000000..4d2932aa79 --- /dev/null +++ b/tests/benchmarks/qml/qqmlcomponent/testtypes.cpp @@ -0,0 +1,46 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include "testtypes.h" + +void registerTypes() +{ + qmlRegisterType("Qt.test", 4, 6, "MyQmlObject"); +} diff --git a/tests/benchmarks/qml/qqmlcomponent/testtypes.h b/tests/benchmarks/qml/qqmlcomponent/testtypes.h new file mode 100644 index 0000000000..03542ca24c --- /dev/null +++ b/tests/benchmarks/qml/qqmlcomponent/testtypes.h @@ -0,0 +1,83 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#ifndef TESTTYPES_H +#define TESTTYPES_H + +#include +#include + +class MyQmlObject : public QObject +{ + Q_OBJECT + Q_PROPERTY(int result READ result WRITE setResult) + Q_PROPERTY(int value READ value WRITE setValue NOTIFY valueChanged) + Q_PROPERTY(MyQmlObject *object READ object WRITE setObject NOTIFY objectChanged) + Q_PROPERTY(QQmlListProperty data READ data) + Q_CLASSINFO("DefaultProperty", "data") +public: + MyQmlObject() : m_result(0), m_value(0), m_object(0) {} + + int result() const { return m_result; } + void setResult(int r) { m_result = r; } + + int value() const { return m_value; } + void setValue(int v) { m_value = v; emit valueChanged(); } + + QQmlListProperty data() { return QQmlListProperty(this, m_data); } + + MyQmlObject *object() const { return m_object; } + void setObject(MyQmlObject *o) { m_object = o; emit objectChanged(); } + +signals: + void valueChanged(); + void objectChanged(); + +private: + QList m_data; + int m_result; + int m_value; + MyQmlObject *m_object; +}; +QML_DECLARE_TYPE(MyQmlObject); + +void registerTypes(); + +#endif // TESTTYPES_H diff --git a/tests/benchmarks/qml/qqmlcomponent/tst_qqmlcomponent.cpp b/tests/benchmarks/qml/qqmlcomponent/tst_qqmlcomponent.cpp new file mode 100644 index 0000000000..47b7455a94 --- /dev/null +++ b/tests/benchmarks/qml/qqmlcomponent/tst_qqmlcomponent.cpp @@ -0,0 +1,116 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include +#include +#include +#include +#include "testtypes.h" + +class tst_qmlcomponent : public QObject +{ + Q_OBJECT + +public: + tst_qmlcomponent(); + virtual ~tst_qmlcomponent(); + +public slots: + void initTestCase(); + void cleanupTestCase(); + +private slots: + void creation_data(); + void creation(); + +private: + QQmlEngine engine; +}; + +tst_qmlcomponent::tst_qmlcomponent() +{ +} + +tst_qmlcomponent::~tst_qmlcomponent() +{ +} + +void tst_qmlcomponent::initTestCase() +{ + registerTypes(); +} + +void tst_qmlcomponent::cleanupTestCase() +{ +} + +void tst_qmlcomponent::creation_data() +{ + QTest::addColumn("file"); + + QTest::newRow("Object") << SRCDIR "/data/object.qml"; + QTest::newRow("Object - Id") << SRCDIR "/data/object_id.qml"; + QTest::newRow("MyQmlObject") << SRCDIR "/data/myqmlobject.qml"; + QTest::newRow("MyQmlObject: basic binding") << SRCDIR "/data/myqmlobject_binding.qml"; + QTest::newRow("Synthesized properties") << SRCDIR "/data/synthesized_properties.qml"; + QTest::newRow("Synthesized properties.2") << SRCDIR "/data/synthesized_properties.2.qml"; + QTest::newRow("SameGame - BoomBlock") << SRCDIR "/data/samegame/BoomBlock.qml"; +} + +void tst_qmlcomponent::creation() +{ + QFETCH(QString, file); + + QQmlComponent c(&engine, file); + QVERIFY(c.isReady()); + + QObject *obj = c.create(); + delete obj; + + QBENCHMARK { + QObject *obj = c.create(); + delete obj; + } +} + +QTEST_MAIN(tst_qmlcomponent) +#include "tst_qqmlcomponent.moc" diff --git a/tests/benchmarks/qml/qqmldebugtrace/qqmldebugtrace.pro b/tests/benchmarks/qml/qqmldebugtrace/qqmldebugtrace.pro new file mode 100644 index 0000000000..ebf0ae074f --- /dev/null +++ b/tests/benchmarks/qml/qqmldebugtrace/qqmldebugtrace.pro @@ -0,0 +1,8 @@ +CONFIG += testcase +QT += qml testlib +TEMPLATE = app +TARGET = tst_qqmldebugtrace +macx:CONFIG -= app_bundle + +SOURCES += tst_qqmldebugtrace.cpp + diff --git a/tests/benchmarks/qml/qqmldebugtrace/tst_qqmldebugtrace.cpp b/tests/benchmarks/qml/qqmldebugtrace/tst_qqmldebugtrace.cpp new file mode 100644 index 0000000000..36144f6a76 --- /dev/null +++ b/tests/benchmarks/qml/qqmldebugtrace/tst_qqmldebugtrace.cpp @@ -0,0 +1,100 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include +#include + +class tst_qqmldebugtrace : public QObject +{ + Q_OBJECT + +public: + tst_qqmldebugtrace() {} + +private slots: + void all(); + void startElapsed(); + void doubleElapsed(); + void trace(); +}; + +void tst_qqmldebugtrace::all() +{ + QBENCHMARK { + QElapsedTimer t; + t.start(); + t.nsecsElapsed(); + } +} + +void tst_qqmldebugtrace::startElapsed() +{ + QElapsedTimer t; + QBENCHMARK { + t.start(); + t.nsecsElapsed(); + } +} + +void tst_qqmldebugtrace::doubleElapsed() +{ + QElapsedTimer t; + t.start(); + QBENCHMARK { + t.nsecsElapsed(); + t.nsecsElapsed(); + } +} + +void tst_qqmldebugtrace::trace() +{ + QString s("A decent sized string of text here."); + QBENCHMARK { + QByteArray data; + QDataStream ds(&data, QIODevice::WriteOnly); + ds << (qint64)100 << (int)5 << (int)5 << s; + } +} + +QTEST_MAIN(tst_qqmldebugtrace) + +#include "tst_qqmldebugtrace.moc" diff --git a/tests/benchmarks/qml/qqmlimage/image.png b/tests/benchmarks/qml/qqmlimage/image.png new file mode 100644 index 0000000000..623d36233d Binary files /dev/null and b/tests/benchmarks/qml/qqmlimage/image.png differ diff --git a/tests/benchmarks/qml/qqmlimage/qqmlimage.pro b/tests/benchmarks/qml/qqmlimage/qqmlimage.pro new file mode 100644 index 0000000000..21d3efdd1f --- /dev/null +++ b/tests/benchmarks/qml/qqmlimage/qqmlimage.pro @@ -0,0 +1,11 @@ +CONFIG += testcase +TEMPLATE = app +TARGET = tst_qqmlimage +QT += qml quick-private testlib +macx:CONFIG -= app_bundle +CONFIG += release + +SOURCES += tst_qqmlimage.cpp + +DEFINES += SRCDIR=\\\"$$PWD\\\" + diff --git a/tests/benchmarks/qml/qqmlimage/tst_qqmlimage.cpp b/tests/benchmarks/qml/qqmlimage/tst_qqmlimage.cpp new file mode 100644 index 0000000000..ec872b881a --- /dev/null +++ b/tests/benchmarks/qml/qqmlimage/tst_qqmlimage.cpp @@ -0,0 +1,108 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include +#include +#include + +class tst_qmlgraphicsimage : public QObject +{ + Q_OBJECT +public: + tst_qmlgraphicsimage() {} + +private slots: + void qmlgraphicsimage(); + void qmlgraphicsimage_file(); + void qmlgraphicsimage_url(); + +private: + QQmlEngine engine; +}; + +void tst_qmlgraphicsimage::qmlgraphicsimage() +{ + int x = 0; + QUrl url(SRCDIR "/image.png"); + QBENCHMARK { + QUrl url2("http://localhost/image" + QString::number(x++) + ".png"); + QQuickImage *image = new QQuickImage; + QQmlEngine::setContextForObject(image, engine.rootContext()); + delete image; + } +} + +void tst_qmlgraphicsimage::qmlgraphicsimage_file() +{ + int x = 0; + QUrl url(SRCDIR "/image.png"); + //get rid of initialization effects + { + QQuickImage *image = new QQuickImage; + QQmlEngine::setContextForObject(image, engine.rootContext()); + image->setSource(url); + } + QBENCHMARK { + QUrl url2("http://localhost/image" + QString::number(x++) + ".png"); + QQuickImage *image = new QQuickImage; + QQmlEngine::setContextForObject(image, engine.rootContext()); + image->setSource(url); + delete image; + } +} + +void tst_qmlgraphicsimage::qmlgraphicsimage_url() +{ + int x = 0; + QUrl url(SRCDIR "/image.png"); + QBENCHMARK { + QUrl url2("http://localhost/image" + QString::number(x++) + ".png"); + QQuickImage *image = new QQuickImage; + QQmlEngine::setContextForObject(image, engine.rootContext()); + image->setSource(url2); + delete image; + } +} + +QTEST_MAIN(tst_qmlgraphicsimage) + +#include "tst_qqmlimage.moc" diff --git a/tests/benchmarks/qml/qqmlmetaproperty/data/object.qml b/tests/benchmarks/qml/qqmlmetaproperty/data/object.qml new file mode 100644 index 0000000000..47c0442d29 --- /dev/null +++ b/tests/benchmarks/qml/qqmlmetaproperty/data/object.qml @@ -0,0 +1,44 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtQml module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Item {} diff --git a/tests/benchmarks/qml/qqmlmetaproperty/data/synthesized_object.qml b/tests/benchmarks/qml/qqmlmetaproperty/data/synthesized_object.qml new file mode 100644 index 0000000000..a4609cb6e0 --- /dev/null +++ b/tests/benchmarks/qml/qqmlmetaproperty/data/synthesized_object.qml @@ -0,0 +1,47 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtQml module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Item { + property int blah +} + diff --git a/tests/benchmarks/qml/qqmlmetaproperty/qqmlmetaproperty.pro b/tests/benchmarks/qml/qqmlmetaproperty/qqmlmetaproperty.pro new file mode 100644 index 0000000000..9d507e9581 --- /dev/null +++ b/tests/benchmarks/qml/qqmlmetaproperty/qqmlmetaproperty.pro @@ -0,0 +1,10 @@ +CONFIG += testcase +TEMPLATE = app +TARGET = tst_qqmlmetaproperty +QT += qml testlib +macx:CONFIG -= app_bundle + +SOURCES += tst_qqmlmetaproperty.cpp + +# Define SRCDIR equal to test's source directory +DEFINES += SRCDIR=\\\"$$PWD\\\" diff --git a/tests/benchmarks/qml/qqmlmetaproperty/tst_qqmlmetaproperty.cpp b/tests/benchmarks/qml/qqmlmetaproperty/tst_qqmlmetaproperty.cpp new file mode 100644 index 0000000000..216d603da8 --- /dev/null +++ b/tests/benchmarks/qml/qqmlmetaproperty/tst_qqmlmetaproperty.cpp @@ -0,0 +1,110 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include +#include +#include +#include +#include + +class tst_qmlmetaproperty : public QObject +{ + Q_OBJECT + +public: + tst_qmlmetaproperty(); + virtual ~tst_qmlmetaproperty(); + +public slots: + void init(); + void cleanup(); + +private slots: + void lookup_data(); + void lookup(); + +private: + QQmlEngine engine; +}; + +tst_qmlmetaproperty::tst_qmlmetaproperty() +{ +} + +tst_qmlmetaproperty::~tst_qmlmetaproperty() +{ +} + +void tst_qmlmetaproperty::init() +{ +} + +void tst_qmlmetaproperty::cleanup() +{ +} + +void tst_qmlmetaproperty::lookup_data() +{ + QTest::addColumn("file"); + + QTest::newRow("Simple Object") << SRCDIR "/data/object.qml"; + QTest::newRow("Synthesized Object") << SRCDIR "/data/synthesized_object.qml"; +} + +void tst_qmlmetaproperty::lookup() +{ + QFETCH(QString, file); + + QQmlComponent c(&engine, file); + QVERIFY(c.isReady()); + + QObject *obj = c.create(); + + QBENCHMARK { + QQmlProperty p(obj, "x"); + } + + delete obj; +} + +QTEST_MAIN(tst_qmlmetaproperty) +#include "tst_qqmlmetaproperty.moc" diff --git a/tests/benchmarks/qml/script/data/CustomObject.qml b/tests/benchmarks/qml/script/data/CustomObject.qml new file mode 100644 index 0000000000..485f8a1354 --- /dev/null +++ b/tests/benchmarks/qml/script/data/CustomObject.qml @@ -0,0 +1,48 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtQml module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +QtObject { + property real prop1: 0 + property real prop2: 1 + property real prop3: 0 +} diff --git a/tests/benchmarks/qml/script/data/block.qml b/tests/benchmarks/qml/script/data/block.qml new file mode 100644 index 0000000000..3816b9f64b --- /dev/null +++ b/tests/benchmarks/qml/script/data/block.qml @@ -0,0 +1,75 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtQml module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Rectangle { + width: 200; height: 200 + CustomObject { id: theObject } + function doSomethingDirect() { + theObject.prop1 = 0; + + for (var i = 0; i < 1000; ++i) + theObject.prop1 += theObject.prop2; + + theObject.prop3 = theObject.prop1; + } + + function doSomethingLocalObj() { + theObject.prop1 = 0; + + var incrementObj = theObject; + for (var i = 0; i < 1000; ++i) + incrementObj.prop1 += incrementObj.prop2; + + incrementObj.prop3 = incrementObj.prop1; + } + + function doSomethingLocal() { + theObject.prop1 = 0; + + var increment = theObject.prop2; + for (var i = 0; i < 1000; ++i) + theObject.prop1 += increment; + + theObject.prop3 = theObject.prop1; + } +} diff --git a/tests/benchmarks/qml/script/data/enums.qml b/tests/benchmarks/qml/script/data/enums.qml new file mode 100644 index 0000000000..8450b15732 --- /dev/null +++ b/tests/benchmarks/qml/script/data/enums.qml @@ -0,0 +1,51 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the Declarative module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Item { + function runtest() { + var a = 0; + for (var ii = 0; ii < 100000; ++ii) + a += Text.RichText; + return a; + } +} diff --git a/tests/benchmarks/qml/script/data/global.js b/tests/benchmarks/qml/script/data/global.js new file mode 100644 index 0000000000..4e3a4780f9 --- /dev/null +++ b/tests/benchmarks/qml/script/data/global.js @@ -0,0 +1,54 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +var incVar = 1; +var total; + +function doSomething() { + for (var i = 0; i < 10000; ++i) + Math.sin(90); +} + +function doIncrement() { + total = 0; + for (var i = 0; i < 100000; ++i) + total += incVar; +} diff --git a/tests/benchmarks/qml/script/data/global_prop.qml b/tests/benchmarks/qml/script/data/global_prop.qml new file mode 100644 index 0000000000..c77faaf9f4 --- /dev/null +++ b/tests/benchmarks/qml/script/data/global_prop.qml @@ -0,0 +1,53 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import "global.js" as Program + +Rectangle { + width: 200; height: 200 + + signal triggered + signal incrementTriggered + + onTriggered: Program.doSomething(); + onIncrementTriggered: Program.doIncrement(); +} diff --git a/tests/benchmarks/qml/script/data/namespacedEnums.qml b/tests/benchmarks/qml/script/data/namespacedEnums.qml new file mode 100644 index 0000000000..e49bf7e1ad --- /dev/null +++ b/tests/benchmarks/qml/script/data/namespacedEnums.qml @@ -0,0 +1,52 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the Declarative module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 as QtQuick + +QtQuick.Item { + function runtest() { + var a = 0; + for (var ii = 0; ii < 100000; ++ii) + a += QtQuick.Text.RichText; + return a; + } +} + diff --git a/tests/benchmarks/qml/script/data/script.js b/tests/benchmarks/qml/script/data/script.js new file mode 100644 index 0000000000..9f46570004 --- /dev/null +++ b/tests/benchmarks/qml/script/data/script.js @@ -0,0 +1 @@ +function func() { return 1; } diff --git a/tests/benchmarks/qml/script/data/script2.js b/tests/benchmarks/qml/script/data/script2.js new file mode 100644 index 0000000000..102f081140 --- /dev/null +++ b/tests/benchmarks/qml/script/data/script2.js @@ -0,0 +1,2 @@ +function func() { return 2; } + diff --git a/tests/benchmarks/qml/script/data/scriptCall.qml b/tests/benchmarks/qml/script/data/scriptCall.qml new file mode 100644 index 0000000000..420f621dfc --- /dev/null +++ b/tests/benchmarks/qml/script/data/scriptCall.qml @@ -0,0 +1,54 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the Declarative module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import "script.js" as Script +import "script2.js" as OtherScript + +Item { + function runtest() { + var a = 0; + for (var ii = 0; ii < 1000000; ++ii) + a += Script.func(); + return a; + } +} + diff --git a/tests/benchmarks/qml/script/data/signal_args.qml b/tests/benchmarks/qml/script/data/signal_args.qml new file mode 100644 index 0000000000..757ac1a1f9 --- /dev/null +++ b/tests/benchmarks/qml/script/data/signal_args.qml @@ -0,0 +1,47 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtQml module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import Qt.test 1.0 + +TestObject { + onMySignalWithArgs: { var a = n; return a; } +} + diff --git a/tests/benchmarks/qml/script/data/signal_qml.qml b/tests/benchmarks/qml/script/data/signal_qml.qml new file mode 100644 index 0000000000..c7314a6b1e --- /dev/null +++ b/tests/benchmarks/qml/script/data/signal_qml.qml @@ -0,0 +1,47 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtQml module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import Qt.test 1.0 + +TestObject { + onMySignal: { var a = 1; return a; } +} + diff --git a/tests/benchmarks/qml/script/data/signal_unconnected.qml b/tests/benchmarks/qml/script/data/signal_unconnected.qml new file mode 100644 index 0000000000..a33942dd2d --- /dev/null +++ b/tests/benchmarks/qml/script/data/signal_unconnected.qml @@ -0,0 +1,45 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtQml module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import Qt.test 1.0 + +TestObject { +} diff --git a/tests/benchmarks/qml/script/data/signal_unusedArgs.qml b/tests/benchmarks/qml/script/data/signal_unusedArgs.qml new file mode 100644 index 0000000000..52b4e1a54f --- /dev/null +++ b/tests/benchmarks/qml/script/data/signal_unusedArgs.qml @@ -0,0 +1,47 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtQml module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import Qt.test 1.0 + +TestObject { + onMySignalWithArgs: { var a = 1; return a; } +} + diff --git a/tests/benchmarks/qml/script/data/slot_complex.qml b/tests/benchmarks/qml/script/data/slot_complex.qml new file mode 100644 index 0000000000..4763146c65 --- /dev/null +++ b/tests/benchmarks/qml/script/data/slot_complex.qml @@ -0,0 +1,57 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtQml module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import Qt.test 1.0 + +TestObject { + function myCustomFunction(b) { + var n = b; + var a = 1; + while (n > 0) { + a = a * n; + n--; + } + return a; + } + + onMySignal: { for (var ii = 0; ii < 10000; ++ii) { myCustomFunction(10); } } +} + diff --git a/tests/benchmarks/qml/script/data/slot_complex_js.js b/tests/benchmarks/qml/script/data/slot_complex_js.js new file mode 100644 index 0000000000..64a1f65daa --- /dev/null +++ b/tests/benchmarks/qml/script/data/slot_complex_js.js @@ -0,0 +1,8 @@ +function myCustomFunction(n) { + var a = 1; + while (n > 0) { + a = a * n; + n--; + } + return a; +} diff --git a/tests/benchmarks/qml/script/data/slot_complex_js.qml b/tests/benchmarks/qml/script/data/slot_complex_js.qml new file mode 100644 index 0000000000..e44fc73f8e --- /dev/null +++ b/tests/benchmarks/qml/script/data/slot_complex_js.qml @@ -0,0 +1,49 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtQml module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import Qt.test 1.0 +import "slot_complex_js.js" as Logic + +TestObject { + onMySignal: { for (var ii = 0; ii < 10000; ++ii) { Logic.myCustomFunction(10); } } +} + + diff --git a/tests/benchmarks/qml/script/data/slot_simple.qml b/tests/benchmarks/qml/script/data/slot_simple.qml new file mode 100644 index 0000000000..b788970d12 --- /dev/null +++ b/tests/benchmarks/qml/script/data/slot_simple.qml @@ -0,0 +1,50 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtQml module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import Qt.test 1.0 + +TestObject { + function myCustomFunction() { + return 0; + } + + onMySignal: { for (var ii = 0; ii < 10000; ++ii) { myCustomFunction(); } } +} diff --git a/tests/benchmarks/qml/script/data/slot_simple_js.js b/tests/benchmarks/qml/script/data/slot_simple_js.js new file mode 100644 index 0000000000..d6e60608da --- /dev/null +++ b/tests/benchmarks/qml/script/data/slot_simple_js.js @@ -0,0 +1,3 @@ +function myCustomFunction() { + return 0; +} diff --git a/tests/benchmarks/qml/script/data/slot_simple_js.qml b/tests/benchmarks/qml/script/data/slot_simple_js.qml new file mode 100644 index 0000000000..5af1b0868f --- /dev/null +++ b/tests/benchmarks/qml/script/data/slot_simple_js.qml @@ -0,0 +1,48 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtQml module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import Qt.test 1.0 +import "slot_simple_js.js" as Logic + +TestObject { + onMySignal: { for (var ii = 0; ii < 10000; ++ii) { Logic.myCustomFunction(); } } +} + diff --git a/tests/benchmarks/qml/script/script.pro b/tests/benchmarks/qml/script/script.pro new file mode 100644 index 0000000000..88e8d9b33d --- /dev/null +++ b/tests/benchmarks/qml/script/script.pro @@ -0,0 +1,10 @@ +CONFIG += testcase +TEMPLATE = app +TARGET = tst_script +QT += qml qml-private testlib v8-private core-private +macx:CONFIG -= app_bundle +CONFIG += release + +SOURCES += tst_script.cpp + +DEFINES += SRCDIR=\\\"$$PWD\\\" diff --git a/tests/benchmarks/qml/script/tst_script.cpp b/tests/benchmarks/qml/script/tst_script.cpp new file mode 100644 index 0000000000..204fb945eb --- /dev/null +++ b/tests/benchmarks/qml/script/tst_script.cpp @@ -0,0 +1,803 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include +#include +#include +#include +#include +#include +#include + +class tst_script : public QObject +{ + Q_OBJECT +public: + tst_script() {} + +private slots: + void initTestCase(); + + void property_js(); + void property_getter(); + void property_getter_js(); + void property_getter_qobject(); + void property_getter_qmetaproperty(); + void property_qobject(); + void property_qmlobject(); + + void setproperty_js(); + void setproperty_qmlobject(); + + void function_js(); + void function_cpp(); + void function_qobject(); + void function_qmlobject(); + + void function_args_js(); + void function_args_cpp(); + void function_args_qobject(); + void function_args_qmlobject(); + + void signal_unconnected(); + void signal_qml(); + void signal_args(); + void signal_unusedArgs(); + + void slot_simple(); + void slot_simple_js(); + void slot_complex(); + void slot_complex_js(); + + void block_data(); + void block(); + + void global_property_js(); + void global_property_qml(); + void global_property_qml_js(); + + void scriptfile_property(); + + void enums(); + void namespacedEnums(); + void scriptCall(); +}; + +inline QUrl TEST_FILE(const QString &filename) +{ + return QUrl::fromLocalFile(QLatin1String(SRCDIR) + QLatin1String("/data/") + filename); +} + +class TestObject : public QObject +{ + Q_OBJECT + Q_PROPERTY(int x READ x WRITE setX) + +public: + TestObject(QObject *parent = 0); + + int x(); + void setX(int x) { m_x = x; } + + void emitMySignal() { emit mySignal(); } + void emitMySignalWithArgs(int n) { emit mySignalWithArgs(n); } + +signals: + void mySignal(); + void mySignalWithArgs(int n); + +public slots: + int method() { + return x(); + } + + int methodArgs(int val) { + return val + x(); + } + +private: + int m_x; +}; +QML_DECLARE_TYPE(TestObject); + +TestObject::TestObject(QObject *parent) +: QObject(parent), m_x(0) +{ +} + +int TestObject::x() +{ + return m_x++; +} + +void tst_script::initTestCase() +{ + qmlRegisterType("Qt.test", 1, 0, "TestObject"); +} + + +#define PROPERTY_PROGRAM \ + "(function(testObject) { return (function() { " \ + " var test = 0; " \ + " for (var ii = 0; ii < 10000; ++ii) { " \ + " test += testObject.x; " \ + " } " \ + " return test; " \ + "}); })" + +void tst_script::property_js() +{ + QScriptEngine engine; + + QScriptValue v = engine.newObject(); + v.setProperty(QLatin1String("x"), 10); + + QScriptValueList args; + args << v; + QScriptValue prog = engine.evaluate(PROPERTY_PROGRAM).call(engine.globalObject(), args); + prog.call(); + + QBENCHMARK { + prog.call().toNumber(); + } +} + +static QScriptValue property_getter_method(QScriptContext *, QScriptEngine *engine) +{ + static int x = 0; + return QScriptValue(engine,x++); +} + +void tst_script::property_getter() +{ + QScriptEngine engine; + + QScriptValue v = engine.newObject(); + v.setProperty(QLatin1String("x"), engine.newFunction(property_getter_method), + QScriptValue::PropertyGetter); + + QScriptValueList args; + args << v; + QScriptValue prog = engine.evaluate(PROPERTY_PROGRAM).call(engine.globalObject(), args); + prog.call(); + + QBENCHMARK { + prog.call(); + } +} + +static TestObject *property_getter_qobject_object = 0; +static QScriptValue property_getter_qobject_method(QScriptContext *, QScriptEngine *) +{ + static int idx = -1; + if (idx == -1) + idx = TestObject::staticMetaObject.indexOfProperty("x"); + + int value = 0; + void *args[] = { &value, 0 }; + QMetaObject::metacall(property_getter_qobject_object, QMetaObject::ReadProperty, idx, args); + + return QScriptValue(value); +} + +static QScriptValue property_getter_qmetaproperty_method(QScriptContext *, QScriptEngine *) +{ + static int idx = -1; + if (idx == -1) + idx = TestObject::staticMetaObject.indexOfProperty("x"); + + int value = 0; + value = property_getter_qobject_object->metaObject()->property(idx).read(property_getter_qobject_object).toInt(); + + return QScriptValue(value); +} + +void tst_script::property_getter_qobject() +{ + QScriptEngine engine; + + TestObject to; + property_getter_qobject_object = &to; + QScriptValue v = engine.newObject(); + v.setProperty(QLatin1String("x"), engine.newFunction(property_getter_qobject_method), + QScriptValue::PropertyGetter); + + QScriptValueList args; + args << v; + QScriptValue prog = engine.evaluate(PROPERTY_PROGRAM).call(engine.globalObject(), args); + prog.call(); + + QBENCHMARK { + prog.call(); + } + property_getter_qobject_object = 0; +} + +void tst_script::property_getter_qmetaproperty() +{ + QScriptEngine engine; + + TestObject to; + property_getter_qobject_object = &to; + QScriptValue v = engine.newObject(); + v.setProperty(QLatin1String("x"), engine.newFunction(property_getter_qmetaproperty_method), + QScriptValue::PropertyGetter); + + QScriptValueList args; + args << v; + QScriptValue prog = engine.evaluate(PROPERTY_PROGRAM).call(engine.globalObject(), args); + prog.call(); + + QBENCHMARK { + prog.call(); + } + property_getter_qobject_object = 0; +} + + +void tst_script::property_getter_js() +{ + QScriptEngine engine; + + QScriptValue v = engine.evaluate("(function() { var o = new Object; o._x = 0; o.__defineGetter__(\"x\", function() { return this._x++; }); return o; })").call(); + + QScriptValueList args; + args << v; + QScriptValue prog = engine.evaluate(PROPERTY_PROGRAM).call(engine.globalObject(), args); + prog.call(); + + QBENCHMARK { + prog.call(); + } +} + +void tst_script::property_qobject() +{ + QScriptEngine engine; + + TestObject to; + QScriptValue v = engine.newQObject(&to); + + QScriptValueList args; + args << v; + QScriptValue prog = engine.evaluate(PROPERTY_PROGRAM).call(engine.globalObject(), args); + prog.call(); + + QBENCHMARK { + prog.call(); + } +} + +void tst_script::property_qmlobject() +{ + QQmlEngine qmlengine; + + QScriptEngine *engine = QQmlEnginePrivate::getScriptEngine(&qmlengine); + TestObject to; + + QScriptValue v = QQmlEnginePrivate::get(&qmlengine)->objectClass->newQObject(&to); + + QScriptValueList args; + args << v; + QScriptValue prog = engine->evaluate(PROPERTY_PROGRAM).call(engine->globalObject(), args); + prog.call(); + + QBENCHMARK { + prog.call(); + } +} + +#define SETPROPERTY_PROGRAM \ + "(function(testObject) { return (function() { " \ + " for (var ii = 0; ii < 10000; ++ii) { " \ + " testObject.x = ii; " \ + " } " \ + "}); })" + +void tst_script::setproperty_js() +{ + QScriptEngine engine; + + QScriptValue v = engine.newObject(); + v.setProperty(QLatin1String("x"), 0); + + QScriptValueList args; + args << v; + QScriptValue prog = engine.evaluate(SETPROPERTY_PROGRAM).call(engine.globalObject(), args); + prog.call(); + + QBENCHMARK { + prog.call(); + } +} + +void tst_script::setproperty_qmlobject() +{ + QQmlEngine qmlengine; + + QScriptEngine *engine = QQmlEnginePrivate::getScriptEngine(&qmlengine); + TestObject to; + + QScriptValue v = QQmlEnginePrivate::get(&qmlengine)->objectClass->newQObject(&to); + + QScriptValueList args; + args << v; + QScriptValue prog = engine->evaluate(SETPROPERTY_PROGRAM).call(engine->globalObject(), args); + prog.call(); + + QBENCHMARK { + prog.call(); + } +} + +#define FUNCTION_PROGRAM \ + "(function(testObject) { return (function() { " \ + " var test = 0; " \ + " for (var ii = 0; ii < 10000; ++ii) { " \ + " test += testObject.method(); " \ + " } " \ + " return test; " \ + "}); })" + +void tst_script::function_js() +{ + QScriptEngine engine; + + QScriptValue v = engine.evaluate("(function() { var o = new Object; o._x = 0; o.method = (function() { return this._x++; }); return o; })").call(); + + QScriptValueList args; + args << v; + QScriptValue prog = engine.evaluate(FUNCTION_PROGRAM).call(engine.globalObject(), args); + prog.call(); + + QBENCHMARK { + prog.call(); + } +} + +static QScriptValue function_method(QScriptContext *, QScriptEngine *) +{ + static int x = 0; + return QScriptValue(x++); +} + +void tst_script::function_cpp() +{ + QScriptEngine engine; + + QScriptValue v = engine.newObject(); + v.setProperty(QLatin1String("method"), engine.newFunction(function_method)); + + QScriptValueList args; + args << v; + QScriptValue prog = engine.evaluate(FUNCTION_PROGRAM).call(engine.globalObject(), args); + prog.call(); + + QBENCHMARK { + prog.call(); + } +} + +void tst_script::function_qobject() +{ + QScriptEngine engine; + + TestObject to; + QScriptValue v = engine.newQObject(&to); + + QScriptValueList args; + args << v; + QScriptValue prog = engine.evaluate(FUNCTION_PROGRAM).call(engine.globalObject(), args); + prog.call(); + + QBENCHMARK { + prog.call(); + } +} + +void tst_script::function_qmlobject() +{ + QQmlEngine qmlengine; + + QScriptEngine *engine = QQmlEnginePrivate::getScriptEngine(&qmlengine); + TestObject to; + + QScriptValue v = QQmlEnginePrivate::get(&qmlengine)->objectClass->newQObject(&to); + + QScriptValueList args; + args << v; + QScriptValue prog = engine->evaluate(FUNCTION_PROGRAM).call(engine->globalObject(), args); + prog.call(); + + QBENCHMARK { + prog.call(); + } +} + +#define FUNCTION_ARGS_PROGRAM \ + "(function(testObject) { return (function() { " \ + " var test = 0; " \ + " for (var ii = 0; ii < 10000; ++ii) { " \ + " test += testObject.methodArgs(ii); " \ + " } " \ + " return test; " \ + "}); })" + +void tst_script::function_args_js() +{ + QScriptEngine engine; + + QScriptValue v = engine.evaluate("(function() { var o = new Object; o._x = 0; o.methodArgs = (function(a) { return a + this._x++; }); return o; })").call(); + + QScriptValueList args; + args << v; + QScriptValue prog = engine.evaluate(FUNCTION_ARGS_PROGRAM).call(engine.globalObject(), args); + prog.call(); + + QBENCHMARK { + prog.call(); + } +} + +static QScriptValue function_args_method(QScriptContext *ctxt, QScriptEngine *) +{ + static int x = 0; + return QScriptValue(ctxt->argument(0).toNumber() + x++); +} + +void tst_script::function_args_cpp() +{ + QScriptEngine engine; + + QScriptValue v = engine.newObject(); + v.setProperty(QLatin1String("methodArgs"), engine.newFunction(function_args_method)); + + QScriptValueList args; + args << v; + QScriptValue prog = engine.evaluate(FUNCTION_ARGS_PROGRAM).call(engine.globalObject(), args); + prog.call(); + + QBENCHMARK { + prog.call(); + } +} + +void tst_script::function_args_qobject() +{ + QScriptEngine engine; + + TestObject to; + QScriptValue v = engine.newQObject(&to); + + QScriptValueList args; + args << v; + QScriptValue prog = engine.evaluate(FUNCTION_ARGS_PROGRAM).call(engine.globalObject(), args); + prog.call(); + + QBENCHMARK { + prog.call(); + } +} + +void tst_script::function_args_qmlobject() +{ + QQmlEngine qmlengine; + + QScriptEngine *engine = QQmlEnginePrivate::getScriptEngine(&qmlengine); + TestObject to; + + QScriptValue v = QQmlEnginePrivate::get(&qmlengine)->objectClass->newQObject(&to); + + QScriptValueList args; + args << v; + QScriptValue prog = engine->evaluate(FUNCTION_ARGS_PROGRAM).call(engine->globalObject(), args); + prog.call(); + + QBENCHMARK { + prog.call(); + } +} + +void tst_script::signal_unconnected() +{ + QQmlEngine engine; + QQmlComponent component(&engine, TEST_FILE("signal_unconnected.qml")); + TestObject *object = qobject_cast(component.create()); + QVERIFY(object != 0); + + QBENCHMARK { + object->emitMySignal(); + } + + delete object; +} + +void tst_script::signal_qml() +{ + QQmlEngine engine; + QQmlComponent component(&engine, TEST_FILE("signal_qml.qml")); + TestObject *object = qobject_cast(component.create()); + QVERIFY(object != 0); + + QBENCHMARK { + object->emitMySignal(); + } + + delete object; +} + +void tst_script::signal_args() +{ + QQmlEngine engine; + QQmlComponent component(&engine, TEST_FILE("signal_args.qml")); + TestObject *object = qobject_cast(component.create()); + QVERIFY(object != 0); + + QBENCHMARK { + object->emitMySignalWithArgs(11); + } + + delete object; +} + +void tst_script::signal_unusedArgs() +{ + QQmlEngine engine; + QQmlComponent component(&engine, TEST_FILE("signal_unusedArgs.qml")); + TestObject *object = qobject_cast(component.create()); + QVERIFY(object != 0); + + QBENCHMARK { + object->emitMySignalWithArgs(11); + } + + delete object; +} + +void tst_script::slot_simple() +{ + QQmlEngine engine; + QQmlComponent component(&engine, TEST_FILE("slot_simple.qml")); + TestObject *object = qobject_cast(component.create()); + QVERIFY(object != 0); + + QBENCHMARK { + object->emitMySignal(); + } + + delete object; +} + +void tst_script::slot_simple_js() +{ + QQmlEngine engine; + QQmlComponent component(&engine, TEST_FILE("slot_simple_js.qml")); + TestObject *object = qobject_cast(component.create()); + QVERIFY(object != 0); + + QBENCHMARK { + object->emitMySignal(); + } + + delete object; +} + +void tst_script::slot_complex() +{ + QQmlEngine engine; + QQmlComponent component(&engine, TEST_FILE("slot_complex.qml")); + TestObject *object = qobject_cast(component.create()); + QVERIFY(object != 0); + + QBENCHMARK { + object->emitMySignal(); + } + + delete object; +} + +void tst_script::slot_complex_js() +{ + QQmlEngine engine; + QQmlComponent component(&engine, TEST_FILE("slot_complex_js.qml")); + TestObject *object = qobject_cast(component.create()); + QVERIFY(object != 0); + + QBENCHMARK { + object->emitMySignal(); + } + + delete object; +} + +void tst_script::block_data() +{ + QTest::addColumn("methodName"); + QTest::newRow("direct") << "doSomethingDirect()"; + QTest::newRow("localObj") << "doSomethingLocalObj()"; + QTest::newRow("local") << "doSomethingLocal()"; +} + +void tst_script::block() +{ + QFETCH(QString, methodName); + QQmlEngine engine; + QQmlComponent component(&engine, TEST_FILE("block.qml")); + QQuickRectangle *rect = qobject_cast(component.create()); + QVERIFY(rect != 0); + + int index = rect->metaObject()->indexOfMethod(methodName.toUtf8()); + QVERIFY(index != -1); + QMetaMethod method = rect->metaObject()->method(index); + + QBENCHMARK { + method.invoke(rect, Qt::DirectConnection); + } + + delete rect; +} + +#define GLOBALPROPERTY_PROGRAM \ + "(function() { " \ + " for (var ii = 0; ii < 10000; ++ii) { " \ + " Math.sin(90); " \ + " } " \ + "})" + +void tst_script::global_property_js() +{ + QScriptEngine engine; + + QScriptValue prog = engine.evaluate(GLOBALPROPERTY_PROGRAM); + prog.call(); + + QBENCHMARK { + prog.call(); + } +} + +void tst_script::global_property_qml() +{ + QQmlEngine qmlengine; + + QScriptEngine *engine = QQmlEnginePrivate::getScriptEngine(&qmlengine); + QScriptValue prog = engine->evaluate(GLOBALPROPERTY_PROGRAM); + prog.call(); + + QBENCHMARK { + prog.call(); + } +} + +void tst_script::global_property_qml_js() +{ + QQmlEngine engine; + QQmlComponent component(&engine, TEST_FILE("global_prop.qml")); + QQuickRectangle *rect = qobject_cast(component.create()); + QVERIFY(rect != 0); + + int index = rect->metaObject()->indexOfMethod("triggered()"); + QVERIFY(index != -1); + QMetaMethod method = rect->metaObject()->method(index); + + QBENCHMARK { + method.invoke(rect, Qt::DirectConnection); + } + + delete rect; +} + +void tst_script::scriptfile_property() +{ + QQmlEngine engine; + QQmlComponent component(&engine, TEST_FILE("global_prop.qml")); + QQuickRectangle *rect = qobject_cast(component.create()); + QVERIFY(rect != 0); + + int index = rect->metaObject()->indexOfMethod("incrementTriggered()"); + QVERIFY(index != -1); + QMetaMethod method = rect->metaObject()->method(index); + + QBENCHMARK { + method.invoke(rect, Qt::DirectConnection); + } + + delete rect; +} + +void tst_script::enums() +{ + QQmlEngine engine; + QQmlComponent component(&engine, TEST_FILE("enums.qml")); + QObject *o = component.create(); + QVERIFY(o != 0); + + int index = o->metaObject()->indexOfMethod("runtest()"); + QVERIFY(index != -1); + QMetaMethod method = o->metaObject()->method(index); + + QBENCHMARK { + method.invoke(o, Qt::DirectConnection); + } + + delete o; +} + +void tst_script::namespacedEnums() +{ + QQmlEngine engine; + QQmlComponent component(&engine, TEST_FILE("namespacedEnums.qml")); + QObject *o = component.create(); + QVERIFY(o != 0); + + int index = o->metaObject()->indexOfMethod("runtest()"); + QVERIFY(index != -1); + QMetaMethod method = o->metaObject()->method(index); + + QBENCHMARK { + method.invoke(o, Qt::DirectConnection); + } + + delete o; +} + +void tst_script::scriptCall() +{ + QQmlEngine engine; + QQmlComponent component(&engine, TEST_FILE("scriptCall.qml")); + QObject *o = component.create(); + QVERIFY(o != 0); + + int index = o->metaObject()->indexOfMethod("runtest()"); + QVERIFY(index != -1); + QMetaMethod method = o->metaObject()->method(index); + + QBENCHMARK { + method.invoke(o, Qt::DirectConnection); + } + + delete o; +} + +QTEST_MAIN(tst_script) + +#include "tst_script.moc" diff --git a/tests/benchmarks/qml/typeimports/data/QmlTestType1.qml b/tests/benchmarks/qml/typeimports/data/QmlTestType1.qml new file mode 100644 index 0000000000..eb1ae13881 --- /dev/null +++ b/tests/benchmarks/qml/typeimports/data/QmlTestType1.qml @@ -0,0 +1,43 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtQml module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import Qt.test 2.0 +TestType1 { } diff --git a/tests/benchmarks/qml/typeimports/data/QmlTestType2.qml b/tests/benchmarks/qml/typeimports/data/QmlTestType2.qml new file mode 100644 index 0000000000..f6801cddef --- /dev/null +++ b/tests/benchmarks/qml/typeimports/data/QmlTestType2.qml @@ -0,0 +1,43 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtQml module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import Qt.test 2.0 +TestType2 { } diff --git a/tests/benchmarks/qml/typeimports/data/QmlTestType3.qml b/tests/benchmarks/qml/typeimports/data/QmlTestType3.qml new file mode 100644 index 0000000000..21ade835ec --- /dev/null +++ b/tests/benchmarks/qml/typeimports/data/QmlTestType3.qml @@ -0,0 +1,43 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtQml module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import Qt.test 2.0 +TestType3 { } diff --git a/tests/benchmarks/qml/typeimports/data/QmlTestType4.qml b/tests/benchmarks/qml/typeimports/data/QmlTestType4.qml new file mode 100644 index 0000000000..45fdbfbb09 --- /dev/null +++ b/tests/benchmarks/qml/typeimports/data/QmlTestType4.qml @@ -0,0 +1,43 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtQml module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import Qt.test 2.0 +TestType4 { } diff --git a/tests/benchmarks/qml/typeimports/data/cpp.qml b/tests/benchmarks/qml/typeimports/data/cpp.qml new file mode 100644 index 0000000000..8700846b5a --- /dev/null +++ b/tests/benchmarks/qml/typeimports/data/cpp.qml @@ -0,0 +1,56 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtQml module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import Qt.test 2.0 + +TestType1 { + TestType1 { } TestType2 { } TestType3 { } TestType4 { } + TestType1 { } TestType2 { } TestType3 { } TestType4 { } + TestType1 { } TestType2 { } TestType3 { } TestType4 { } + TestType1 { } TestType2 { } TestType3 { } TestType4 { } + TestType1 { } TestType2 { } TestType3 { } TestType4 { } + + TestType1 { } TestType2 { } TestType3 { } TestType4 { } + TestType1 { } TestType2 { } TestType3 { } TestType4 { } + TestType1 { } TestType2 { } TestType3 { } TestType4 { } + TestType1 { } TestType2 { } TestType3 { } TestType4 { } + TestType1 { } TestType2 { } TestType3 { } TestType4 { } +} diff --git a/tests/benchmarks/qml/typeimports/data/qml.qml b/tests/benchmarks/qml/typeimports/data/qml.qml new file mode 100644 index 0000000000..1235cde924 --- /dev/null +++ b/tests/benchmarks/qml/typeimports/data/qml.qml @@ -0,0 +1,54 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtQml module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +QmlTestType1 { + QmlTestType1 { } QmlTestType2 { } QmlTestType3 { } QmlTestType4 { } + QmlTestType1 { } QmlTestType2 { } QmlTestType3 { } QmlTestType4 { } + QmlTestType1 { } QmlTestType2 { } QmlTestType3 { } QmlTestType4 { } + QmlTestType1 { } QmlTestType2 { } QmlTestType3 { } QmlTestType4 { } + QmlTestType1 { } QmlTestType2 { } QmlTestType3 { } QmlTestType4 { } + + QmlTestType1 { } QmlTestType2 { } QmlTestType3 { } QmlTestType4 { } + QmlTestType1 { } QmlTestType2 { } QmlTestType3 { } QmlTestType4 { } + QmlTestType1 { } QmlTestType2 { } QmlTestType3 { } QmlTestType4 { } + QmlTestType1 { } QmlTestType2 { } QmlTestType3 { } QmlTestType4 { } + QmlTestType1 { } QmlTestType2 { } QmlTestType3 { } QmlTestType4 { } +} diff --git a/tests/benchmarks/qml/typeimports/tst_typeimports.cpp b/tests/benchmarks/qml/typeimports/tst_typeimports.cpp new file mode 100644 index 0000000000..69b3f2e215 --- /dev/null +++ b/tests/benchmarks/qml/typeimports/tst_typeimports.cpp @@ -0,0 +1,135 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include +#include +#include + +class tst_typeimports : public QObject +{ + Q_OBJECT +public: + tst_typeimports(); + +private slots: + void cpp(); + void qml(); + +private: + QQmlEngine engine; +}; + +class TestType1 : public QObject +{ + Q_OBJECT + Q_PROPERTY(QQmlListProperty resources READ resources); + Q_CLASSINFO("DefaultProperty", "resources"); +public: + TestType1(QObject *parent = 0) : QObject(parent) {} + + QQmlListProperty resources() { + return QQmlListProperty(this, 0, resources_append); + } + + static void resources_append(QQmlListProperty *p, QObject *o) { + o->setParent(p->object); + } +}; + +class TestType2 : public TestType1 +{ + Q_OBJECT +public: + TestType2(QObject *parent = 0) : TestType1(parent) {} +}; + + +class TestType3 : public TestType1 +{ + Q_OBJECT +public: + TestType3(QObject *parent = 0) : TestType1(parent) {} +}; + +class TestType4 : public TestType1 +{ + Q_OBJECT +public: + TestType4(QObject *parent = 0) : TestType1(parent) {} +}; + + +tst_typeimports::tst_typeimports() +{ + qmlRegisterType("Qt.test", 1, 0, "TestType1"); + qmlRegisterType("Qt.test", 1, 0, "TestType2"); + qmlRegisterType("Qt.test", 2, 0, "TestType3"); + qmlRegisterType("Qt.test", 2, 0, "TestType4"); +} + +inline QUrl TEST_FILE(const QString &filename) +{ + return QUrl::fromLocalFile(QLatin1String(SRCDIR) + QLatin1String("/data/") + filename); +} + +void tst_typeimports::cpp() +{ + QBENCHMARK { + QQmlComponent component(&engine, TEST_FILE("cpp.qml")); + QVERIFY(component.isReady()); + } +} + +void tst_typeimports::qml() +{ + //get rid of initialization effects + { QQmlComponent component(&engine, TEST_FILE("qml.qml")); } + + QBENCHMARK { + QQmlComponent component(&engine, TEST_FILE("qml.qml")); + QVERIFY(component.isReady()); + } +} + +QTEST_MAIN(tst_typeimports) + +#include "tst_typeimports.moc" diff --git a/tests/benchmarks/qml/typeimports/typeimports.pro b/tests/benchmarks/qml/typeimports/typeimports.pro new file mode 100644 index 0000000000..dc58e4044b --- /dev/null +++ b/tests/benchmarks/qml/typeimports/typeimports.pro @@ -0,0 +1,9 @@ +CONFIG += testcase +TEMPLATE = app +TARGET = tst_typeimports +QT += qml testlib +macx:CONFIG -= app_bundle + +SOURCES += tst_typeimports.cpp + +DEFINES += SRCDIR=\\\"$$PWD\\\" diff --git a/tests/global/global.cfg b/tests/global/global.cfg index 80e064a74f..e01462a5a0 100644 --- a/tests/global/global.cfg +++ b/tests/global/global.cfg @@ -1,5 +1,5 @@ - + diff --git a/tests/manual/accessibility/animation.qml b/tests/manual/accessibility/animation.qml index 3d75f28573..bb5c7ac192 100644 --- a/tests/manual/accessibility/animation.qml +++ b/tests/manual/accessibility/animation.qml @@ -3,7 +3,7 @@ ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/ ** -** This file is part of the QtDeclarative module of the Qt Toolkit. +** This file is part of the QtQml module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ ** GNU Lesser General Public License Usage diff --git a/tests/manual/accessibility/behavior.qml b/tests/manual/accessibility/behavior.qml index de86284dcd..614330fbb5 100644 --- a/tests/manual/accessibility/behavior.qml +++ b/tests/manual/accessibility/behavior.qml @@ -3,7 +3,7 @@ ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/ ** -** This file is part of the QtDeclarative module of the Qt Toolkit. +** This file is part of the QtQml module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ ** GNU Lesser General Public License Usage diff --git a/tests/manual/accessibility/flickable.qml b/tests/manual/accessibility/flickable.qml index 24a3b93edc..1014d307ee 100644 --- a/tests/manual/accessibility/flickable.qml +++ b/tests/manual/accessibility/flickable.qml @@ -3,7 +3,7 @@ ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/ ** -** This file is part of the QtDeclarative module of the Qt Toolkit. +** This file is part of the QtQml module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ ** GNU Lesser General Public License Usage diff --git a/tests/manual/accessibility/hittest.qml b/tests/manual/accessibility/hittest.qml index 9f94b7e999..10d65707b0 100644 --- a/tests/manual/accessibility/hittest.qml +++ b/tests/manual/accessibility/hittest.qml @@ -3,7 +3,7 @@ ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/ ** -** This file is part of the QtDeclarative module of the Qt Toolkit. +** This file is part of the QtQml module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ ** GNU Lesser General Public License Usage diff --git a/tests/manual/accessibility/numberanimation.qml b/tests/manual/accessibility/numberanimation.qml index 91c54ecbd3..c35c022272 100644 --- a/tests/manual/accessibility/numberanimation.qml +++ b/tests/manual/accessibility/numberanimation.qml @@ -3,7 +3,7 @@ ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/ ** -** This file is part of the QtDeclarative module of the Qt Toolkit. +** This file is part of the QtQml module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ ** GNU Lesser General Public License Usage diff --git a/tests/manual/accessibility/textandbuttons.qml b/tests/manual/accessibility/textandbuttons.qml index 893cb071b2..6abdb1ea49 100644 --- a/tests/manual/accessibility/textandbuttons.qml +++ b/tests/manual/accessibility/textandbuttons.qml @@ -3,7 +3,7 @@ ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/ ** -** This file is part of the QtDeclarative module of the Qt Toolkit. +** This file is part of the QtQml module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ ** GNU Lesser General Public License Usage diff --git a/tests/manual/accessibility/transition.qml b/tests/manual/accessibility/transition.qml index 05714503a2..d606da7744 100644 --- a/tests/manual/accessibility/transition.qml +++ b/tests/manual/accessibility/transition.qml @@ -3,7 +3,7 @@ ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/ ** -** This file is part of the QtDeclarative module of the Qt Toolkit. +** This file is part of the QtQml module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ ** GNU Lesser General Public License Usage diff --git a/tests/testapplications/qsgimage/ImageNG.qml b/tests/testapplications/qsgimage/ImageNG.qml index fbcef04662..afc4d0c22e 100644 --- a/tests/testapplications/qsgimage/ImageNG.qml +++ b/tests/testapplications/qsgimage/ImageNG.qml @@ -3,7 +3,7 @@ ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/ ** -** This file is part of the QtDeclarative module of the Qt Toolkit. +** This file is part of the QtQml module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ ** GNU Lesser General Public License Usage diff --git a/tests/testapplications/qsgimage/img-align.qml b/tests/testapplications/qsgimage/img-align.qml index b751e006a5..7d118f7538 100644 --- a/tests/testapplications/qsgimage/img-align.qml +++ b/tests/testapplications/qsgimage/img-align.qml @@ -3,7 +3,7 @@ ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/ ** -** This file is part of the QtDeclarative module of the Qt Toolkit. +** This file is part of the QtQml module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ ** GNU Lesser General Public License Usage diff --git a/tools/qmleasing/TextField.qml b/tools/qmleasing/TextField.qml index ccdb562cfa..2d7cb5ec28 100644 --- a/tools/qmleasing/TextField.qml +++ b/tools/qmleasing/TextField.qml @@ -3,7 +3,7 @@ ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/ ** -** This file is part of the QtDeclarative module of the Qt Toolkit. +** This file is part of the QtQml module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ ** GNU Lesser General Public License Usage diff --git a/tools/qmleasing/easing.qml b/tools/qmleasing/easing.qml index 50a349357f..437bc7da3d 100644 --- a/tools/qmleasing/easing.qml +++ b/tools/qmleasing/easing.qml @@ -3,7 +3,7 @@ ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/ ** -** This file is part of the QtDeclarative module of the Qt Toolkit. +** This file is part of the QtQml module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ ** GNU Lesser General Public License Usage diff --git a/tools/qmleasing/qmleasing.pro b/tools/qmleasing/qmleasing.pro index 6f5e56b147..488ec5748a 100644 --- a/tools/qmleasing/qmleasing.pro +++ b/tools/qmleasing/qmleasing.pro @@ -1,4 +1,4 @@ -QT += declarative quick widgets +QT += qml quick widgets CONFIG -= app_bundle SOURCES += main.cpp diff --git a/tools/qmlmin/main.cpp b/tools/qmlmin/main.cpp index f59eedec84..8baa131b9a 100644 --- a/tools/qmlmin/main.cpp +++ b/tools/qmlmin/main.cpp @@ -3,7 +3,7 @@ ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/ ** -** This file is part of the QtDeclarative module of the Qt Toolkit. +** This file is part of the QtQml module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ ** GNU Lesser General Public License Usage @@ -39,9 +39,9 @@ ** ****************************************************************************/ -#include -#include -#include +#include +#include +#include #include #include #include @@ -55,7 +55,7 @@ QT_BEGIN_NAMESPACE // // QML/JS minifier // -namespace QDeclarativeJS { +namespace QQmlJS { enum RegExpFlag { Global = 0x01, @@ -66,7 +66,7 @@ enum RegExpFlag { class QmlminLexer: protected Lexer, public Directives { - QDeclarativeJS::Engine _engine; + QQmlJS::Engine _engine; QString _fileName; QString _directives; @@ -492,7 +492,7 @@ bool Tokenize::parse(int startToken) return false; } -} // end of QDeclarativeJS namespace +} // end of QQmlJS namespace static void usage(bool showHelp = false) { @@ -571,7 +571,7 @@ int runQmlmin(int argc, char *argv[]) const QString code = QString::fromUtf8(file.readAll()); // QML files are UTF-8 encoded. file.close(); - QDeclarativeJS::Minify minify; + QQmlJS::Minify minify; if (! minify(fileName, code)) { std::cerr << "qmlmin: cannot minify '" << qPrintable(fileName) << "' (not a valid QML/JS file)" << std::endl; return EXIT_FAILURE; @@ -580,13 +580,13 @@ int runQmlmin(int argc, char *argv[]) // // verify the output // - QDeclarativeJS::Minify secondMinify; + QQmlJS::Minify secondMinify; if (! secondMinify(fileName, minify.minifiedCode()) || secondMinify.minifiedCode() != minify.minifiedCode()) { std::cerr << "qmlmin: cannot minify '" << qPrintable(fileName) << "'" << std::endl; return EXIT_FAILURE; } - QDeclarativeJS::Tokenize originalTokens, minimizedTokens; + QQmlJS::Tokenize originalTokens, minimizedTokens; originalTokens(fileName, code); minimizedTokens(fileName, minify.minifiedCode()); diff --git a/tools/qmlmin/qmlmin.pro b/tools/qmlmin/qmlmin.pro index 67c7004c18..c57ec29d5b 100644 --- a/tools/qmlmin/qmlmin.pro +++ b/tools/qmlmin/qmlmin.pro @@ -1,7 +1,7 @@ QT = core qmldevtools-private CONFIG += console CONFIG -= app_bundle -DESTDIR = $$QT.declarative.bins +DESTDIR = $$QT.qml.bins SOURCES += main.cpp target.path = $$[QT_INSTALL_BINS] diff --git a/tools/qmlplugindump/main.cpp b/tools/qmlplugindump/main.cpp index ad8a3a6d64..2c12941d07 100644 --- a/tools/qmlplugindump/main.cpp +++ b/tools/qmlplugindump/main.cpp @@ -39,9 +39,9 @@ ** ****************************************************************************/ -#include -#include -#include +#include +#include +#include #include #include @@ -101,14 +101,14 @@ void collectReachableMetaObjects(QObject *object, QSet *met for (int index = 0; index < meta->propertyCount(); ++index) { QMetaProperty prop = meta->property(index); - if (QDeclarativeMetaType::isQObject(prop.userType())) { + if (QQmlMetaType::isQObject(prop.userType())) { if (verbose) qDebug() << " Processing property" << prop.name(); currentProperty = QString("%1::%2").arg(meta->className(), prop.name()); // if the property was not initialized during construction, // accessing a member of oo is going to cause a segmentation fault - QObject *oo = QDeclarativeMetaType::toQObject(prop.read(object)); + QObject *oo = QQmlMetaType::toQObject(prop.read(object)); if (oo && !metas->contains(oo->metaObject())) collectReachableMetaObjects(oo, metas); currentProperty.clear(); @@ -116,7 +116,7 @@ void collectReachableMetaObjects(QObject *object, QSet *met } } -void collectReachableMetaObjects(const QDeclarativeType *ty, QSet *metas) +void collectReachableMetaObjects(const QQmlType *ty, QSet *metas) { collectReachableMetaObjects(ty->metaObject(), metas, ty->isExtendedType()); if (ty->attachedPropertiesType()) @@ -136,7 +136,7 @@ public: To do this, we need to find the QDeclarativeTypes associated with this QMetaObject. */ -static QHash > qmlTypesByCppName; +static QHash > qmlTypesByCppName; static QHash cppToId; @@ -187,13 +187,13 @@ public: }; QList moduleApis; -QSet collectReachableMetaObjects(QDeclarativeEngine *engine, const QList &skip = QList()) +QSet collectReachableMetaObjects(QQmlEngine *engine, const QList &skip = QList()) { QSet metas; metas.insert(FriendlyQObject::qtMeta()); QHash > extensions; - foreach (const QDeclarativeType *ty, QDeclarativeMetaType::qmlTypes()) { + foreach (const QQmlType *ty, QQmlMetaType::qmlTypes()) { qmlTypesByCppName[ty->metaObject()->className()].insert(ty); if (ty->isExtendedType()) { extensions[ty->typeName()].insert(ty->metaObject()->className()); @@ -206,18 +206,18 @@ QSet collectReachableMetaObjects(QDeclarativeEngine *engine // Example: QDeclarativeGraphicsWidget overrides the QtQuick/QGraphicsWidget export // of QGraphicsWidget. foreach (const QByteArray &baseCpp, extensions.keys()) { - QSet baseExports = qmlTypesByCppName.value(baseCpp); + QSet baseExports = qmlTypesByCppName.value(baseCpp); const QSet extensionCppNames = extensions.value(baseCpp); foreach (const QByteArray &extensionCppName, extensionCppNames) { - const QSet extensionExports = qmlTypesByCppName.value(extensionCppName); + const QSet extensionExports = qmlTypesByCppName.value(extensionCppName); // remove extension exports from base imports - // unfortunately the QDeclarativeType pointers don't match, so can't use QSet::substract - QSet newBaseExports; - foreach (const QDeclarativeType *baseExport, baseExports) { + // unfortunately the QQmlType pointers don't match, so can't use QSet::substract + QSet newBaseExports; + foreach (const QQmlType *baseExport, baseExports) { bool match = false; - foreach (const QDeclarativeType *extensionExport, extensionExports) { + foreach (const QQmlType *extensionExport, extensionExports) { if (baseExport->qmlTypeName() == extensionExport->qmlTypeName() && baseExport->majorVersion() == extensionExport->majorVersion() && baseExport->minorVersion() == extensionExport->minorVersion()) { @@ -235,14 +235,14 @@ QSet collectReachableMetaObjects(QDeclarativeEngine *engine // find even more QMetaObjects by instantiating QML types and running // over the instances - foreach (QDeclarativeType *ty, QDeclarativeMetaType::qmlTypes()) { + foreach (QQmlType *ty, QQmlMetaType::qmlTypes()) { if (skip.contains(ty)) continue; if (ty->isExtendedType()) continue; if (!ty->isCreatable()) continue; - if (ty->typeName() == "QDeclarativeComponent") + if (ty->typeName() == "QQmlComponent") continue; QString tyName = ty->qmlTypeName(); @@ -261,10 +261,10 @@ QSet collectReachableMetaObjects(QDeclarativeEngine *engine } // extract exported module api - QHashIterator > moduleApiIt(QDeclarativeMetaType::moduleApis()); + QHashIterator > moduleApiIt(QQmlMetaType::moduleApis()); while (moduleApiIt.hasNext()) { moduleApiIt.next(); - foreach (const QDeclarativeMetaType::ModuleApi &api, moduleApiIt.value()) { + foreach (const QQmlMetaType::ModuleApi &api, moduleApiIt.value()) { ModuleApi moduleApi; moduleApi.uri = moduleApiIt.key(); moduleApi.majorVersion = api.major; @@ -322,11 +322,11 @@ public: if (meta->superClass()) qml->writeScriptBinding(QLatin1String("prototype"), enquote(convertToId(meta->superClass()))); - QSet qmlTypes = qmlTypesByCppName.value(meta->className()); + QSet qmlTypes = qmlTypesByCppName.value(meta->className()); if (!qmlTypes.isEmpty()) { - QHash exports; + QHash exports; - foreach (const QDeclarativeType *qmlTy, qmlTypes) { + foreach (const QQmlType *qmlTy, qmlTypes) { QString qmlTyName = qmlTy->qmlTypeName(); if (qmlTyName.startsWith(relocatableModuleUri + QLatin1Char('/'))) { qmlTyName.remove(0, relocatableModuleUri.size() + 1); @@ -432,7 +432,7 @@ public: { qml->writeStartObject(QLatin1String("Component")); qml->writeScriptBinding(QLatin1String("name"), enquote(QLatin1String("QEasingCurve"))); - qml->writeScriptBinding(QLatin1String("prototype"), enquote(QLatin1String("QDeclarativeEasingValueType"))); + qml->writeScriptBinding(QLatin1String("prototype"), enquote(QLatin1String("QQmlEasingValueType"))); qml->writeEndObject(); } @@ -447,7 +447,7 @@ private: */ static void removePointerAndList(QByteArray *typeName, bool *isList, bool *isPointer) { - static QByteArray declListPrefix = "QDeclarativeListProperty<"; + static QByteArray declListPrefix = "QQmlListProperty<"; if (typeName->endsWith('*')) { *isPointer = true; @@ -670,7 +670,7 @@ int main(int argc, char *argv[]) } } - QDeclarativeEngine engine; + QQmlEngine engine; if (!pluginImportPath.isEmpty()) { QDir cur = QDir::current(); cur.cd(pluginImportPath); @@ -682,11 +682,11 @@ int main(int argc, char *argv[]) // load the QtQuick 2 plugin { QByteArray code("import QtQuick 2.0\nQtObject {}"); - QDeclarativeComponent c(&engine); + QQmlComponent c(&engine); c.setData(code, QUrl::fromLocalFile(pluginImportPath + "/loadqtquick2.qml")); c.create(); if (!c.errors().isEmpty()) { - foreach (const QDeclarativeError &error, c.errors()) + foreach (const QQmlError &error, c.errors()) qWarning() << error.toString(); return EXIT_IMPORTERROR; } @@ -694,7 +694,7 @@ int main(int argc, char *argv[]) // find all QMetaObjects reachable from the builtin module QSet defaultReachable = collectReachableMetaObjects(&engine); - QList defaultTypes = QDeclarativeMetaType::qmlTypes(); + QList defaultTypes = QQmlMetaType::qmlTypes(); // add some otherwise unreachable QMetaObjects defaultReachable.insert(&QQuickMouseEvent::staticMetaObject); @@ -708,7 +708,7 @@ int main(int argc, char *argv[]) } else { // find a valid QtQuick import QByteArray importCode; - QDeclarativeType *qtObjectType = QDeclarativeMetaType::qmlType(&QObject::staticMetaObject); + QQmlType *qtObjectType = QQmlMetaType::qmlType(&QObject::staticMetaObject); if (!qtObjectType) { qWarning() << "Could not find QtObject type"; importCode = QByteArray("import QtQuick 2.0\n"); @@ -733,12 +733,12 @@ int main(int argc, char *argv[]) { QByteArray code = importCode; code += "QtObject {}"; - QDeclarativeComponent c(&engine); + QQmlComponent c(&engine); c.setData(code, QUrl::fromLocalFile(pluginImportPath + "/typelist.qml")); c.create(); if (!c.errors().isEmpty()) { - foreach (const QDeclarativeError &error, c.errors()) + foreach (const QQmlError &error, c.errors()) qWarning() << error.toString(); return EXIT_IMPORTERROR; } @@ -761,7 +761,7 @@ int main(int argc, char *argv[]) // setup static rewrites of type names cppToId.insert("QString", "string"); - cppToId.insert("QDeclarativeEasingValueType::Type", "Type"); + cppToId.insert("QQmlEasingValueType::Type", "Type"); // start dumping data QByteArray bytes; @@ -787,7 +787,7 @@ int main(int argc, char *argv[]) dumper.dump(meta); } - // define QEasingCurve as an extension of QDeclarativeEasingValueType, this way + // define QEasingCurve as an extension of QQmlEasingValueType, this way // properties using the QEasingCurve type get useful type information. if (pluginImportUri.isEmpty()) dumper.writeEasingCurve(); diff --git a/tools/qmlplugindump/qmlplugindump.pro b/tools/qmlplugindump/qmlplugindump.pro index e1c8485e27..7662fd79c8 100644 --- a/tools/qmlplugindump/qmlplugindump.pro +++ b/tools/qmlplugindump/qmlplugindump.pro @@ -1,8 +1,8 @@ TEMPLATE = app CONFIG += qt uic console -DESTDIR = $$QT.declarative.bins +DESTDIR = $$QT.qml.bins -QT += declarative declarative-private quick-private core-private +QT += qml qml-private quick-private core-private TARGET = qmlplugindump diff --git a/tools/qmlprofiler/commandlistener.cpp b/tools/qmlprofiler/commandlistener.cpp index cc969160d6..aa3659636d 100644 --- a/tools/qmlprofiler/commandlistener.cpp +++ b/tools/qmlprofiler/commandlistener.cpp @@ -3,7 +3,7 @@ ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/ ** -** This file is part of the QtDeclarative module of the Qt Toolkit. +** This file is part of the QtQml module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ ** GNU Lesser General Public License Usage diff --git a/tools/qmlprofiler/commandlistener.h b/tools/qmlprofiler/commandlistener.h index 77fd79362d..abe302cb8a 100644 --- a/tools/qmlprofiler/commandlistener.h +++ b/tools/qmlprofiler/commandlistener.h @@ -3,7 +3,7 @@ ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/ ** -** This file is part of the QtDeclarative module of the Qt Toolkit. +** This file is part of the QtQml module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ ** GNU Lesser General Public License Usage diff --git a/tools/qmlprofiler/constants.h b/tools/qmlprofiler/constants.h index 2e6acda275..e5a1f8025d 100644 --- a/tools/qmlprofiler/constants.h +++ b/tools/qmlprofiler/constants.h @@ -3,7 +3,7 @@ ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/ ** -** This file is part of the QtDeclarative module of the Qt Toolkit. +** This file is part of the QtQml module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ ** GNU Lesser General Public License Usage diff --git a/tools/qmlprofiler/profileclient.cpp b/tools/qmlprofiler/profileclient.cpp index 3e84569f2f..5871aa29af 100644 --- a/tools/qmlprofiler/profileclient.cpp +++ b/tools/qmlprofiler/profileclient.cpp @@ -3,7 +3,7 @@ ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/ ** -** This file is part of the QtDeclarative module of the Qt Toolkit. +** This file is part of the QtQml module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ ** GNU Lesser General Public License Usage @@ -45,8 +45,8 @@ #include ProfileClient::ProfileClient(const QString &clientName, - QDeclarativeDebugConnection *client) - : QDeclarativeDebugClient(clientName, client), + QQmlDebugConnection *client) + : QQmlDebugClient(clientName, client), m_recording(false), m_enabled(false) { @@ -111,19 +111,19 @@ public: , maximumTime(0) { ::memset(rangeCount, 0, - QDeclarativeProfilerService::MaximumRangeType * sizeof(int)); + QQmlProfilerService::MaximumRangeType * sizeof(int)); } qint64 inProgressRanges; - QStack rangeStartTimes[QDeclarativeProfilerService::MaximumRangeType]; - QStack rangeDatas[QDeclarativeProfilerService::MaximumRangeType]; - QStack rangeLocations[QDeclarativeProfilerService::MaximumRangeType]; - int rangeCount[QDeclarativeProfilerService::MaximumRangeType]; + QStack rangeStartTimes[QQmlProfilerService::MaximumRangeType]; + QStack rangeDatas[QQmlProfilerService::MaximumRangeType]; + QStack rangeLocations[QQmlProfilerService::MaximumRangeType]; + int rangeCount[QQmlProfilerService::MaximumRangeType]; qint64 maximumTime; }; DeclarativeProfileClient::DeclarativeProfileClient( - QDeclarativeDebugConnection *client) + QQmlDebugConnection *client) : ProfileClient(QLatin1String("CanvasFrameRate"), client), d(new DeclarativeProfileClientPrivate) { @@ -137,7 +137,7 @@ DeclarativeProfileClient::~DeclarativeProfileClient() void DeclarativeProfileClient::clearData() { ::memset(d->rangeCount, 0, - QDeclarativeProfilerService::MaximumRangeType * sizeof(int)); + QQmlProfilerService::MaximumRangeType * sizeof(int)); ProfileClient::clearData(); } @@ -159,43 +159,43 @@ void DeclarativeProfileClient::messageReceived(const QByteArray &data) stream >> time >> messageType; - if (messageType >= QDeclarativeProfilerService::MaximumMessage) + if (messageType >= QQmlProfilerService::MaximumMessage) return; - if (messageType == QDeclarativeProfilerService::Event) { + if (messageType == QQmlProfilerService::Event) { int event; stream >> event; - if (event == QDeclarativeProfilerService::EndTrace) { + if (event == QQmlProfilerService::EndTrace) { emit this->traceFinished(time); d->maximumTime = time; d->maximumTime = qMax(time, d->maximumTime); - } else if (event == QDeclarativeProfilerService::AnimationFrame) { + } else if (event == QQmlProfilerService::AnimationFrame) { int frameRate, animationCount; stream >> frameRate >> animationCount; emit this->frame(time, frameRate, animationCount); d->maximumTime = qMax(time, d->maximumTime); - } else if (event == QDeclarativeProfilerService::StartTrace) { + } else if (event == QQmlProfilerService::StartTrace) { emit this->traceStarted(time); d->maximumTime = time; - } else if (event < QDeclarativeProfilerService::MaximumEventType) { + } else if (event < QQmlProfilerService::MaximumEventType) { d->maximumTime = qMax(time, d->maximumTime); } - } else if (messageType == QDeclarativeProfilerService::Complete) { + } else if (messageType == QQmlProfilerService::Complete) { emit complete(); } else { int range; stream >> range; - if (range >= QDeclarativeProfilerService::MaximumRangeType) + if (range >= QQmlProfilerService::MaximumRangeType) return; - if (messageType == QDeclarativeProfilerService::RangeStart) { + if (messageType == QQmlProfilerService::RangeStart) { d->rangeStartTimes[range].push(time); d->inProgressRanges |= (static_cast(1) << range); ++d->rangeCount[range]; - } else if (messageType == QDeclarativeProfilerService::RangeData) { + } else if (messageType == QQmlProfilerService::RangeData) { QString data; stream >> data; @@ -206,7 +206,7 @@ void DeclarativeProfileClient::messageReceived(const QByteArray &data) d->rangeDatas[range][count-1] << data; } - } else if (messageType == QDeclarativeProfilerService::RangeLocation) { + } else if (messageType == QQmlProfilerService::RangeLocation) { QString fileName; int line; int column = -1; @@ -232,7 +232,7 @@ void DeclarativeProfileClient::messageReceived(const QByteArray &data) d->rangeLocations[range].pop() : EventLocation(); qint64 startTime = d->rangeStartTimes[range].pop(); - emit this->range((QDeclarativeProfilerService::RangeType)range, + emit this->range((QQmlProfilerService::RangeType)range, startTime, time - startTime, data, location); if (d->rangeCount[range] == 0) { int count = d->rangeDatas[range].count() + @@ -246,7 +246,7 @@ void DeclarativeProfileClient::messageReceived(const QByteArray &data) } } -V8ProfileClient::V8ProfileClient(QDeclarativeDebugConnection *client) +V8ProfileClient::V8ProfileClient(QQmlDebugConnection *client) : ProfileClient(QLatin1String("V8Profiler"), client) { } diff --git a/tools/qmlprofiler/profileclient.h b/tools/qmlprofiler/profileclient.h index 87e9dbc508..fd581c59c4 100644 --- a/tools/qmlprofiler/profileclient.h +++ b/tools/qmlprofiler/profileclient.h @@ -3,7 +3,7 @@ ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/ ** -** This file is part of the QtDeclarative module of the Qt Toolkit. +** This file is part of the QtQml module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ ** GNU Lesser General Public License Usage @@ -44,11 +44,11 @@ #include "profiledata.h" -#include -#include +#include +#include class ProfileClientPrivate; -class ProfileClient : public QDeclarativeDebugClient +class ProfileClient : public QQmlDebugClient { Q_OBJECT @@ -58,7 +58,7 @@ class ProfileClient : public QDeclarativeDebugClient public: ProfileClient(const QString & clientName, - QDeclarativeDebugConnection *client); + QQmlDebugConnection *client); ~ProfileClient(); bool isEnabled() const; @@ -88,7 +88,7 @@ class DeclarativeProfileClient : public ProfileClient Q_OBJECT public: - DeclarativeProfileClient(QDeclarativeDebugConnection *client); + DeclarativeProfileClient(QQmlDebugConnection *client); ~DeclarativeProfileClient(); public slots: @@ -98,7 +98,7 @@ public slots: signals: void traceFinished( qint64 time ); void traceStarted( qint64 time ); - void range(QDeclarativeProfilerService::RangeType type, qint64 startTime, + void range(QQmlProfilerService::RangeType type, qint64 startTime, qint64 length, const QStringList &data, const EventLocation &location); void frame(qint64 time, int frameRate, int animationCount); @@ -122,7 +122,7 @@ public: V8MaximumMessage }; - V8ProfileClient(QDeclarativeDebugConnection *client); + V8ProfileClient(QQmlDebugConnection *client); ~V8ProfileClient(); public slots: diff --git a/tools/qmlprofiler/profiledata.cpp b/tools/qmlprofiler/profiledata.cpp index 19c282b97c..96d7520844 100644 --- a/tools/qmlprofiler/profiledata.cpp +++ b/tools/qmlprofiler/profiledata.cpp @@ -3,7 +3,7 @@ ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/ ** -** This file is part of the QtDeclarative module of the Qt Toolkit. +** This file is part of the QtQml module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ ** GNU Lesser General Public License Usage @@ -52,7 +52,7 @@ using namespace Constants; DeclarativeEvent::DeclarativeEvent() { - eventType = QDeclarativeProfilerService::MaximumRangeType; + eventType = QQmlProfilerService::MaximumRangeType; eventId = -1; duration = 0; calls = 0; @@ -204,22 +204,22 @@ bool compareStartIndexes(const DeclarativeEventEndTime &t1, return t1.startTimeIndex < t2.startTimeIndex; } -QString declarativeEventType(QDeclarativeProfilerService::RangeType typeEnum) +QString declarativeEventType(QQmlProfilerService::RangeType typeEnum) { switch (typeEnum) { - case QDeclarativeProfilerService::Painting: + case QQmlProfilerService::Painting: return QLatin1String(TYPE_PAINTING_STR); break; - case QDeclarativeProfilerService::Compiling: + case QQmlProfilerService::Compiling: return QLatin1String(TYPE_COMPILING_STR); break; - case QDeclarativeProfilerService::Creating: + case QQmlProfilerService::Creating: return QLatin1String(TYPE_CREATING_STR); break; - case QDeclarativeProfilerService::Binding: + case QQmlProfilerService::Binding: return QLatin1String(TYPE_BINDING_STR); break; - case QDeclarativeProfilerService::HandlingSignal: + case QQmlProfilerService::HandlingSignal: return QLatin1String(TYPE_HANDLINGSIGNAL_STR); break; default: @@ -227,32 +227,32 @@ QString declarativeEventType(QDeclarativeProfilerService::RangeType typeEnum) } } -QDeclarativeProfilerService::RangeType declarativeEventType(const QString &typeString) +QQmlProfilerService::RangeType declarativeEventType(const QString &typeString) { if (typeString == QLatin1String(TYPE_PAINTING_STR)) { - return QDeclarativeProfilerService::Painting; + return QQmlProfilerService::Painting; } else if (typeString == QLatin1String(TYPE_COMPILING_STR)) { - return QDeclarativeProfilerService::Compiling; + return QQmlProfilerService::Compiling; } else if (typeString == QLatin1String(TYPE_CREATING_STR)) { - return QDeclarativeProfilerService::Creating; + return QQmlProfilerService::Creating; } else if (typeString == QLatin1String(TYPE_BINDING_STR)) { - return QDeclarativeProfilerService::Binding; + return QQmlProfilerService::Binding; } else if (typeString == QLatin1String(TYPE_HANDLINGSIGNAL_STR)) { - return QDeclarativeProfilerService::HandlingSignal; + return QQmlProfilerService::HandlingSignal; } else { bool isNumber = false; int type = typeString.toUInt(&isNumber); if (isNumber) { - return (QDeclarativeProfilerService::RangeType)type; + return (QQmlProfilerService::RangeType)type; } else { - return QDeclarativeProfilerService::MaximumRangeType; + return QQmlProfilerService::MaximumRangeType; } } } QString getHashStringForDeclarativeEvent( EventLocation location, - QDeclarativeProfilerService::RangeType eventType) + QQmlProfilerService::RangeType eventType) { return QString("%1:%2:%3:%4").arg(location.filename, QString::number(location.line), @@ -383,7 +383,7 @@ const V8Events& ProfileData::getV8Events() const } void ProfileData::addDeclarativeEvent( - QDeclarativeProfilerService::RangeType type, qint64 startTime, qint64 length, + QQmlProfilerService::RangeType type, qint64 startTime, qint64 length, const QStringList &data, const EventLocation &location) { const QChar colon = QLatin1Char(':'); @@ -408,7 +408,7 @@ void ProfileData::addDeclarativeEvent( // backwards compatibility: "compiling" events don't have a proper location in older // version of the protocol, but the filename is passed in the details string - if (type == QDeclarativeProfilerService::Compiling && eventLocation.filename.isEmpty()) { + if (type == QQmlProfilerService::Compiling && eventLocation.filename.isEmpty()) { eventLocation.filename = details; eventLocation.line = 1; eventLocation.column = 1; @@ -544,7 +544,7 @@ void ProfileData::addFrameEvent(qint64 time, int framerate, int animationcount) newEvent = new DeclarativeEvent; newEvent->displayname = displayName; newEvent->eventHashStr = eventHashStr; - newEvent->eventType = QDeclarativeProfilerService::Painting; + newEvent->eventType = QQmlProfilerService::Painting; newEvent->details = details; d->m_eventDescriptions.insert(eventHashStr, newEvent); } @@ -651,7 +651,7 @@ void ProfileDataPrivate::clearDeclarativeRootEvent() m_qmlRootEvent.location = EventLocation(); m_qmlRootEvent.eventHashStr = m_rootEventName; m_qmlRootEvent.details = m_rootEventDesc; - m_qmlRootEvent.eventType = QDeclarativeProfilerService::Binding; + m_qmlRootEvent.eventType = QQmlProfilerService::Binding; m_qmlRootEvent.duration = 0; m_qmlRootEvent.calls = 0; m_qmlRootEvent.minTime = 0; @@ -721,7 +721,7 @@ void ProfileData::compileStatistics(qint64 startTime, qint64 endTime) continue; } - if (eventDescription->eventType == QDeclarativeProfilerService::Painting) { + if (eventDescription->eventType == QQmlProfilerService::Painting) { // skip animation/paint events continue; } @@ -948,7 +948,7 @@ void ProfileData::findAnimationLimits() for (int i = 0; i < d->m_startTimeSortedList.count(); i++) { if (d->m_startTimeSortedList[i].description->eventType == - QDeclarativeProfilerService::Painting && + QQmlProfilerService::Painting && d->m_startTimeSortedList[i].animationCount >= 0) { int animationcount = d->m_startTimeSortedList[i].animationCount; if (d->m_lastFrameEvent) { @@ -974,7 +974,7 @@ void ProfileData::computeNestingLevels() int level = MIN_LEVEL; endtimesPerLevel[MIN_LEVEL] = 0; - for (int i = 0; i < QDeclarativeProfilerService::MaximumRangeType; i++) { + for (int i = 0; i < QQmlProfilerService::MaximumRangeType; i++) { nestingLevels << MIN_LEVEL; QHash dummyHash; dummyHash[MIN_LEVEL] = 0; @@ -985,7 +985,7 @@ void ProfileData::computeNestingLevels() qint64 st = d->m_startTimeSortedList[i].startTime; int type = d->m_startTimeSortedList[i].description->eventType; - if (type == QDeclarativeProfilerService::Painting) { + if (type == QQmlProfilerService::Painting) { // animation/paint events have level 1 by definition, // but are not considered parents of other events for // statistical purposes @@ -1075,8 +1075,8 @@ void ProfileData::reloadDetails() { // request binding/signal details from the AST foreach (DeclarativeEvent *event, d->m_eventDescriptions.values()) { - if (event->eventType != QDeclarativeProfilerService::Binding && - event->eventType != QDeclarativeProfilerService::HandlingSignal) + if (event->eventType != QQmlProfilerService::Binding && + event->eventType != QQmlProfilerService::HandlingSignal) continue; // This skips anonymous bindings in Qt4.8 (we don't have valid location data for them) @@ -1146,7 +1146,7 @@ void ProfileData::findBindingLoops(qint64 startTime, qint64 endTime) } void ProfileData::rewriteDetailsString( - QDeclarativeProfilerService::RangeType eventType, + QQmlProfilerService::RangeType eventType, const EventLocation &location, const QString &newString) { QString eventHashStr = getHashStringForDeclarativeEvent(location, @@ -1366,7 +1366,7 @@ bool ProfileData::save(const QString &filename) QString::number(d->m_eventDescriptions.keys().indexOf( rangedEvent.description->eventHashStr))); if (rangedEvent.description->eventType == - QDeclarativeProfilerService::Painting && rangedEvent.animationCount >= 0) { + QQmlProfilerService::Painting && rangedEvent.animationCount >= 0) { // animation frame stream.writeAttribute("framerate", QString::number(rangedEvent.frameRate)); @@ -1825,7 +1825,7 @@ QString ProfileData::getDetails(int index) const { // special: animations if (d->m_startTimeSortedList[index].description->eventType == - QDeclarativeProfilerService::Painting && + QQmlProfilerService::Painting && d->m_startTimeSortedList[index].animationCount >= 0) return tr("%1 animations at %2 FPS").arg( QString::number(d->m_startTimeSortedList[index].animationCount), diff --git a/tools/qmlprofiler/profiledata.h b/tools/qmlprofiler/profiledata.h index eaa2127f4a..4dd12f7fd3 100644 --- a/tools/qmlprofiler/profiledata.h +++ b/tools/qmlprofiler/profiledata.h @@ -3,7 +3,7 @@ ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/ ** -** This file is part of the QtDeclarative module of the Qt Toolkit. +** This file is part of the QtQml module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ ** GNU Lesser General Public License Usage @@ -42,7 +42,7 @@ #ifndef PROFILEDATA_H #define PROFILEDATA_H -#include +#include #include #include @@ -87,7 +87,7 @@ struct DeclarativeEvent QString eventHashStr; QString details; EventLocation location; - QDeclarativeProfilerService::RangeType eventType; + QQmlProfilerService::RangeType eventType; QHash parentHash; QHash childrenHash; qint64 duration; @@ -205,7 +205,7 @@ signals: public slots: void clear(); - void addDeclarativeEvent(QDeclarativeProfilerService::RangeType type, + void addDeclarativeEvent(QQmlProfilerService::RangeType type, qint64 startTime, qint64 length, const QStringList &data, const EventLocation &location); @@ -222,7 +222,7 @@ public slots: void setTraceEndTime( qint64 time ); void setTraceStartTime( qint64 time ); - void rewriteDetailsString(QDeclarativeProfilerService::RangeType eventType, + void rewriteDetailsString(QQmlProfilerService::RangeType eventType, const EventLocation &location, const QString &newString); void finishedRewritingDetails(); diff --git a/tools/qmlprofiler/qmlprofiler.pro b/tools/qmlprofiler/qmlprofiler.pro index 1d8f89a150..ec5f50e376 100644 --- a/tools/qmlprofiler/qmlprofiler.pro +++ b/tools/qmlprofiler/qmlprofiler.pro @@ -1,8 +1,8 @@ TEMPLATE = app TARGET = qmlprofiler -DESTDIR = $$QT.declarative.bins +DESTDIR = $$QT.qml.bins -QT += declarative declarative-private network +QT += qml qml-private network target.path = $$[QT_INSTALL_BINS] INSTALLS += target diff --git a/tools/qmlprofiler/qmlprofilerapplication.cpp b/tools/qmlprofiler/qmlprofilerapplication.cpp index af5f4298a8..855ede711c 100644 --- a/tools/qmlprofiler/qmlprofilerapplication.cpp +++ b/tools/qmlprofiler/qmlprofilerapplication.cpp @@ -3,7 +3,7 @@ ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/ ** -** This file is part of the QtDeclarative module of the Qt Toolkit. +** This file is part of the QtQml module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ ** GNU Lesser General Public License Usage @@ -104,8 +104,8 @@ QmlProfilerApplication::QmlProfilerApplication(int &argc, char **argv) : connect(&m_declarativeProfilerClient, SIGNAL(enabledChanged()), this, SLOT(traceClientEnabled())); connect(&m_declarativeProfilerClient, SIGNAL(recordingChanged(bool)), this, SLOT(recordingChanged())); - connect(&m_declarativeProfilerClient, SIGNAL(range(QDeclarativeProfilerService::RangeType,qint64,qint64,QStringList,EventLocation)), - &m_profileData, SLOT(addDeclarativeEvent(QDeclarativeProfilerService::RangeType,qint64,qint64,QStringList,EventLocation))); + connect(&m_declarativeProfilerClient, SIGNAL(range(QQmlProfilerService::RangeType,qint64,qint64,QStringList,EventLocation)), + &m_profileData, SLOT(addDeclarativeEvent(QQmlProfilerService::RangeType,qint64,qint64,QStringList,EventLocation))); connect(&m_declarativeProfilerClient, SIGNAL(traceFinished(qint64)), &m_profileData, SLOT(setTraceEndTime(qint64))); connect(&m_declarativeProfilerClient, SIGNAL(traceStarted(qint64)), &m_profileData, SLOT(setTraceStartTime(qint64))); connect(&m_declarativeProfilerClient, SIGNAL(frame(qint64,int,int)), &m_profileData, SLOT(addFrameEvent(qint64,int,int))); @@ -414,7 +414,7 @@ void QmlProfilerApplication::logStatus(const QString &status) void QmlProfilerApplication::declarativeComplete() { m_declarativeDataReady = true; - if (m_v8profilerClient.state() != QDeclarativeDebugClient::Enabled || + if (m_v8profilerClient.state() != QQmlDebugClient::Enabled || m_v8DataReady) { m_profileData.complete(); // once complete is sent, reset the flag @@ -425,7 +425,7 @@ void QmlProfilerApplication::declarativeComplete() void QmlProfilerApplication::v8Complete() { m_v8DataReady = true; - if (m_declarativeProfilerClient.state() != QDeclarativeDebugClient::Enabled || + if (m_declarativeProfilerClient.state() != QQmlDebugClient::Enabled || m_declarativeDataReady) { m_profileData.complete(); // once complete is sent, reset the flag diff --git a/tools/qmlprofiler/qmlprofilerapplication.h b/tools/qmlprofiler/qmlprofilerapplication.h index 49ddaf88cd..5bedb46cff 100644 --- a/tools/qmlprofiler/qmlprofilerapplication.h +++ b/tools/qmlprofiler/qmlprofilerapplication.h @@ -3,7 +3,7 @@ ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/ ** -** This file is part of the QtDeclarative module of the Qt Toolkit. +** This file is part of the QtQml module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ ** GNU Lesser General Public License Usage @@ -103,7 +103,7 @@ private: bool m_verbose; bool m_quitAfterSave; - QDeclarativeDebugConnection m_connection; + QQmlDebugConnection m_connection; DeclarativeProfileClient m_declarativeProfilerClient; V8ProfileClient m_v8profilerClient; ProfileData m_profileData; diff --git a/tools/qmlscene/main.cpp b/tools/qmlscene/main.cpp index d586131845..327dfc6889 100644 --- a/tools/qmlscene/main.cpp +++ b/tools/qmlscene/main.cpp @@ -47,10 +47,10 @@ #include -#include -#include -#include -#include +#include +#include +#include +#include #include #include @@ -308,7 +308,7 @@ static void displayFileDialog(Options *options) #endif } -static void loadDummyDataFiles(QDeclarativeEngine &engine, const QString& directory) +static void loadDummyDataFiles(QQmlEngine &engine, const QString& directory) { QDir dir(directory+"/dummydata", "*.qml"); QStringList list = dir.entryList(); @@ -317,13 +317,13 @@ static void loadDummyDataFiles(QDeclarativeEngine &engine, const QString& direct QFile f(dir.filePath(qml)); f.open(QIODevice::ReadOnly); QByteArray data = f.readAll(); - QDeclarativeComponent comp(&engine); + QQmlComponent comp(&engine); comp.setData(data, QUrl()); QObject *dummyData = comp.create(); if(comp.isError()) { - QList errors = comp.errors(); - foreach (const QDeclarativeError &error, errors) { + QList errors = comp.errors(); + foreach (const QQmlError &error, errors) { qWarning() << error; } } @@ -401,7 +401,7 @@ int main(int argc, char ** argv) #endif QWindow *window = 0; - QDeclarativeEngine *engine = 0; + QQmlEngine *engine = 0; int exitCode = 0; diff --git a/tools/qmlscene/qmlscene.pro b/tools/qmlscene/qmlscene.pro index 5e4d79253e..392e607b88 100644 --- a/tools/qmlscene/qmlscene.pro +++ b/tools/qmlscene/qmlscene.pro @@ -1,8 +1,8 @@ TEMPLATE = app TARGET = qmlscene -DESTDIR= $$QT.declarative.bins +DESTDIR= $$QT.qml.bins -QT += declarative quick core-private +QT += qml quick core-private !isEmpty(QT.widgets.name): QT += widgets target.path = $$[QT_INSTALL_BINS] diff --git a/tools/qmltestrunner/qmltestrunner.pro b/tools/qmltestrunner/qmltestrunner.pro index 72990d6f98..a6c9533e0a 100644 --- a/tools/qmltestrunner/qmltestrunner.pro +++ b/tools/qmltestrunner/qmltestrunner.pro @@ -1,11 +1,11 @@ TEMPLATE = app TARGET = qmltestrunner -DESTDIR= $$QT.declarative.bins +DESTDIR= $$QT.qml.bins CONFIG += warn_on SOURCES += main.cpp -QT += declarative qmltest +QT += qml qmltest macx: CONFIG -= app_bundle -- cgit v1.2.3